@m2c2kit/core 0.3.30 → 0.3.32

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,4 +1,4 @@
1
- var dt=(m=>(m.Node="Node",m.Scene="Scene",m.Sprite="Sprite",m.Label="Label",m.TextLine="TextLine",m.Shape="Shape",m.Composite="Composite",m.SoundPlayer="SoundPlayer",m.SoundRecorder="SoundRecorder",m))(dt||{});const jt={Deferred:"Deferred",WillFetch:"WillFetch",Fetching:"Fetching",Fetched:"Fetched",Decoding:"Decoding",Ready:"Ready",Error:"Error"};var mt=(m=>(m.Sequence="Sequence",m.Group="Group",m.Wait="Wait",m.Custom="Custom",m.Move="Move",m.Scale="Scale",m.FadeAlpha="FadeAlpha",m.Rotate="Rotate",m.Play="Play",m.Repeat="Repeat",m.RepeatForever="RepeatForever",m))(mt||{});class C extends Error{constructor(...t){super(...t),this.name="M2Error",Object.setPrototypeOf(this,C.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,C)}}const xt=class nt{static toTypeAsString(t){switch(t){case nt.none:return"None";case nt.linear:return"Linear";case nt.quadraticIn:return"QuadraticIn";case nt.quadraticOut:return"QuadraticOut";case nt.quadraticInOut:return"QuadraticInOut";case nt.cubicIn:return"CubicIn";case nt.cubicOut:return"CubicOut";case nt.cubicInOut:return"CubicInOut";case nt.quarticIn:return"QuarticIn";case nt.quarticOut:return"QuarticOut";case nt.quarticInOut:return"QuarticInOut";case nt.quinticIn:return"QuinticIn";case nt.quinticOut:return"QuinticOut";case nt.quinticInOut:return"QuinticInOut";case nt.sinusoidalIn:return"SinusoidalIn";case nt.sinusoidalOut:return"SinusoidalOut";case nt.sinusoidalInOut:return"SinusoidalInOut";case nt.exponentialIn:return"ExponentialIn";case nt.exponentialOut:return"ExponentialOut";case nt.exponentialInOut:return"ExponentialInOut";case nt.circularIn:return"CircularIn";case nt.circularOut:return"CircularOut";case nt.circularInOut:return"CircularInOut";default:throw new C("Easings.toTypeAsString(): Unknown easing function")}}static fromTypeAsString(t){switch(t){case"None":return nt.none;case"Linear":return nt.linear;case"QuadraticIn":return nt.quadraticIn;case"QuadraticOut":return nt.quadraticOut;case"QuadraticInOut":return nt.quadraticInOut;case"CubicIn":return nt.cubicIn;case"CubicOut":return nt.cubicOut;case"CubicInOut":return nt.cubicInOut;case"QuarticIn":return nt.quarticIn;case"QuarticOut":return nt.quarticOut;case"QuarticInOut":return nt.quarticInOut;case"QuinticIn":return nt.quinticIn;case"QuinticOut":return nt.quinticOut;case"QuinticInOut":return nt.quinticInOut;case"SinusoidalIn":return nt.sinusoidalIn;case"SinusoidalOut":return nt.sinusoidalOut;case"SinusoidalInOut":return nt.sinusoidalInOut;case"ExponentialIn":return nt.exponentialIn;case"ExponentialOut":return nt.exponentialOut;case"ExponentialInOut":return nt.exponentialInOut;case"CircularIn":return nt.circularIn;case"CircularOut":return nt.circularOut;case"CircularInOut":return nt.circularInOut;default:throw new C(`Easings.fromTypeAsString(): Unknown easing function type ${t}`)}}};xt.none=(m,t,i,r)=>i+t,xt.linear=(m,t,i,r)=>i*m/r+t,xt.quadraticIn=(m,t,i,r)=>(m/=r,i*m*m+t),xt.quadraticOut=(m,t,i,r)=>(m/=r,-i*m*(m-2)+t),xt.quadraticInOut=(m,t,i,r)=>(m/=r/2,m<1?i/2*m*m+t:(m--,-i/2*(m*(m-2)-1)+t)),xt.cubicIn=(m,t,i,r)=>(m/=r,i*m*m*m+t),xt.cubicOut=(m,t,i,r)=>(m/=r,m--,i*(m*m*m+1)+t),xt.cubicInOut=(m,t,i,r)=>(m/=r/2,m<1?i/2*m*m*m+t:(m-=2,i/2*(m*m*m+2)+t)),xt.quarticIn=(m,t,i,r)=>(m/=r,i*m*m*m*m+t),xt.quarticOut=(m,t,i,r)=>(m/=r,m--,-i*(m*m*m*m-1)+t),xt.quarticInOut=(m,t,i,r)=>(m/=r/2,m<1?i/2*m*m*m*m+t:(m-=2,-i/2*(m*m*m*m-2)+t)),xt.quinticIn=(m,t,i,r)=>(m/=r,i*m*m*m*m*m+t),xt.quinticOut=(m,t,i,r)=>(m/=r,m--,i*(m*m*m*m*m+1)+t),xt.quinticInOut=(m,t,i,r)=>(m/=r/2,m<1?i/2*m*m*m*m*m+t:(m-=2,i/2*(m*m*m*m*m+2)+t)),xt.sinusoidalIn=(m,t,i,r)=>-i*Math.cos(m/r*(Math.PI/2))+i+t,xt.sinusoidalOut=(m,t,i,r)=>i*Math.sin(m/r*(Math.PI/2))+t,xt.sinusoidalInOut=(m,t,i,r)=>-i/2*(Math.cos(Math.PI*m/r)-1)+t,xt.exponentialIn=(m,t,i,r)=>i*Math.pow(2,10*(m/r-1))+t,xt.exponentialOut=(m,t,i,r)=>i*(-Math.pow(2,-10*m/r)+1)+t,xt.exponentialInOut=(m,t,i,r)=>(m/=r/2,m<1?i/2*Math.pow(2,10*(m-1))+t:(m--,i/2*(-Math.pow(2,-10*m)+2)+t)),xt.circularIn=(m,t,i,r)=>(m/=r,-i*(Math.sqrt(1-m*m)-1)+t),xt.circularOut=(m,t,i,r)=>(m/=r,m--,i*Math.sqrt(1-m*m)+t),xt.circularInOut=(m,t,i,r)=>(m/=r/2,m<1?-i/2*(Math.sqrt(1-m*m)-1)+t:(m-=2,i/2*(Math.sqrt(1-m*m)+1)+t));let De=xt;var Kt=(m=>(m.Undefined="Undefined",m.Rectangle="Rectangle",m.Circle="Circle",m.Path="Path",m))(Kt||{});const xr=class ss{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(r=>r.name!==t);const i=new ss(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(r=>r.name===t).find(Boolean);if(i===void 0)throw new C(`can't start timer. timer with name ${t} does not exist.`);if(i.stopped===!1)throw new C(`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(r=>r.name===t).find(Boolean);if(i===void 0)throw new C(`can't stop timer. timer with name ${t} does not exist.`);if(i.stopped===!0)throw new C(`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(r=>r.name===t).find(Boolean);if(i===void 0)throw new C(`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(r=>r.name===t).find(Boolean)===void 0)throw new C(`can't remove timer. timer with name ${t} does not exist.`);this._timers=this._timers.filter(r=>r.name!=t)}static removeAll(){this._timers=new Array}static exists(t){return this._timers.some(i=>i.name===t)}};xr._timers=new Array;let Vt=xr;class R{}R.Transparent=[0,0,0,0],R.MediumVioletRed=[199,21,133,1],R.DeepPink=[255,20,147,1],R.PaleVioletRed=[219,112,147,1],R.HotPink=[255,105,180,1],R.LightPink=[255,182,193,1],R.Pink=[255,192,203,1],R.DarkRed=[139,0,0,1],R.Red=[255,0,0,1],R.Firebrick=[178,34,34,1],R.Crimson=[220,20,60,1],R.IndianRed=[205,92,92,1],R.LightCoral=[240,128,128,1],R.Salmon=[250,128,114,1],R.DarkSalmon=[233,150,122,1],R.LightSalmon=[255,160,122,1],R.OrangeRed=[255,69,0,1],R.Tomato=[255,99,71,1],R.DarkOrange=[255,140,0,1],R.Coral=[255,127,80,1],R.Orange=[255,165,0,1],R.DarkKhaki=[189,183,107,1],R.Gold=[255,215,0,1],R.Khaki=[240,230,140,1],R.PeachPuff=[255,218,185,1],R.Yellow=[255,255,0,1],R.PaleGoldenrod=[238,232,170,1],R.Moccasin=[255,228,181,1],R.PapayaWhip=[255,239,213,1],R.LightGoldenrodYellow=[250,250,210,1],R.LemonChiffon=[255,250,205,1],R.LightYellow=[255,255,224,1],R.Maroon=[128,0,0,1],R.Brown=[165,42,42,1],R.SaddleBrown=[139,69,19,1],R.Sienna=[160,82,45,1],R.Chocolate=[210,105,30,1],R.DarkGoldenrod=[184,134,11,1],R.Peru=[205,133,63,1],R.RosyBrown=[188,143,143,1],R.Goldenrod=[218,165,32,1],R.SandyBrown=[244,164,96,1],R.Tan=[210,180,140,1],R.Burlywood=[222,184,135,1],R.Wheat=[245,222,179,1],R.NavajoWhite=[255,222,173,1],R.Bisque=[255,228,196,1],R.BlanchedAlmond=[255,235,205,1],R.Cornsilk=[255,248,220,1],R.DarkGreen=[0,100,0,1],R.Green=[0,128,0,1],R.DarkOliveGreen=[85,107,47,1],R.ForestGreen=[34,139,34,1],R.SeaGreen=[46,139,87,1],R.Olive=[128,128,0,1],R.OliveDrab=[107,142,35,1],R.MediumSeaGreen=[60,179,113,1],R.LimeGreen=[50,205,50,1],R.Lime=[0,255,0,1],R.SpringGreen=[0,255,127,1],R.MediumSpringGreen=[0,250,154,1],R.DarkSeaGreen=[143,188,143,1],R.MediumAquamarine=[102,205,170,1],R.YellowGreen=[154,205,50,1],R.LawnGreen=[124,252,0,1],R.Chartreuse=[127,255,0,1],R.LightGreen=[144,238,144,1],R.GreenYellow=[173,255,47,1],R.PaleGreen=[152,251,152,1],R.Teal=[0,128,128,1],R.DarkCyan=[0,139,139,1],R.LightSeaGreen=[32,178,170,1],R.CadetBlue=[95,158,160,1],R.DarkTurquoise=[0,206,209,1],R.MediumTurquoise=[72,209,204,1],R.Turquoise=[64,224,208,1],R.Aqua=[0,255,255,1],R.Cyan=[0,255,255,1],R.Aquamarine=[127,255,212,1],R.PaleTurquoise=[175,238,238,1],R.LightCyan=[224,255,255,1],R.Navy=[0,0,128,1],R.DarkBlue=[0,0,139,1],R.MediumBlue=[0,0,205,1],R.Blue=[0,0,255,1],R.MidnightBlue=[25,25,112,1],R.RoyalBlue=[65,105,225,1],R.SteelBlue=[70,130,180,1],R.DodgerBlue=[30,144,255,1],R.DeepSkyBlue=[0,191,255,1],R.CornflowerBlue=[100,149,237,1],R.SkyBlue=[135,206,235,1],R.LightSkyBlue=[135,206,250,1],R.LightSteelBlue=[176,196,222,1],R.LightBlue=[173,216,230,1],R.PowderBlue=[176,224,230,1],R.Indigo=[75,0,130,1],R.Purple=[128,0,128,1],R.DarkMagenta=[139,0,139,1],R.DarkViolet=[148,0,211,1],R.DarkSlateBlue=[72,61,139,1],R.BlueViolet=[138,43,226,1],R.DarkOrchid=[153,50,204,1],R.Fuchsia=[255,0,255,1],R.Magenta=[255,0,255,1],R.SlateBlue=[106,90,205,1],R.MediumSlateBlue=[123,104,238,1],R.MediumOrchid=[186,85,211,1],R.MediumPurple=[147,112,219,1],R.Orchid=[218,112,214,1],R.Violet=[238,130,238,1],R.Plum=[221,160,221,1],R.Thistle=[216,191,216,1],R.Lavender=[230,230,250,1],R.MistyRose=[255,228,225,1],R.AntiqueWhite=[250,235,215,1],R.Linen=[250,240,230,1],R.Beige=[245,245,220,1],R.WhiteSmoke=[245,245,245,1],R.LavenderBlush=[255,240,245,1],R.OldLace=[253,245,230,1],R.AliceBlue=[240,248,255,1],R.Seashell=[255,245,238,1],R.GhostWhite=[248,248,255,1],R.Honeydew=[240,255,240,1],R.FloralWhite=[255,250,240,1],R.Azure=[240,255,255,1],R.MintCream=[245,255,250,1],R.Snow=[255,250,250,1],R.Ivory=[255,255,240,1],R.White=[255,255,255,1],R.Black=[0,0,0,1],R.DarkSlateGray=[47,79,79,1],R.DimGray=[105,105,105,1],R.SlateGray=[112,128,144,1],R.Gray=[128,128,128,1],R.LightSlateGray=[119,136,153,1],R.DarkGray=[169,169,169,1],R.Silver=[192,192,192,1],R.LightGray=[211,211,211,1],R.Gainsboro=[220,220,220,1],R.RebeccaPurple=[102,51,153,1];class Q{}Q.FPS_DISPLAY_TEXT_FONT_SIZE=12,Q.FPS_DISPLAY_TEXT_COLOR=[0,0,0,.5],Q.FPS_DISPLAY_UPDATE_INTERVAL=1e3,Q.MAXIMUM_RECORDED_ACTIVITY_METRICS=32,Q.FPS_METRIC_REPORT_THRESHOLD=59,Q.DEFAULT_SCENE_BACKGROUND_COLOR=R.White,Q.DEFAULT_SHAPE_FILL_COLOR=R.Red,Q.DEFAULT_PATH_STROKE_COLOR=R.Red,Q.DEFAULT_PATH_LINE_WIDTH=2,Q.DEFAULT_FONT_COLOR=R.Black,Q.DEFAULT_FONT_SIZE=16,Q.LIMITED_FPS_RATE=5,Q.FREE_NODES_SCENE_NAME="__freeNodesScene",Q.OUTGOING_SCENE_NAME="__outgoingScene",Q.OUTGOING_SCENE_SPRITE_NAME="__outgoingSceneSprite",Q.OUTGOING_SCENE_IMAGE_NAME="__outgoingSceneSnapshot",Q.SESSION_INITIALIZATION_POLLING_INTERVAL_MS=50,Q.MODULE_METADATA_PLACEHOLDER={name:"",version:"",dependencies:{}},Q.DEFAULT_ROOT_ELEMENT_ID="m2c2kit",Q.ERUDA_URL="https://cdn.jsdelivr.net/npm/eruda@3.4.1/eruda.js",Q.ERUDA_SRI="sha384-daS5bEfWdSq146t9c4BureB/fQWO3lHohseXBelPqKvbOUx2D6PE3TxcQ9jrKZDM";class V{static getUrlFromManifest(t,i){const r=t.manifest;return r&&r[i]?r[i]:i}static urlHasScheme(t){return/^[a-z]+:\/\//i.test(t)}static convertValueToType(t,i){function r(U){return typeof U=="string"||typeof U=="object"||!Number.isNaN(parseFloat(U))||typeof U=="boolean"}function h(U){if(typeof U=="string")return U;if(typeof U=="object")return console.warn(`convertValueToType() converted an object to a string. This may not be the desired behavior. The object was: ${JSON.stringify(U)}`),JSON.stringify(U);if(!Number.isNaN(parseFloat(U)))return U;if(typeof U=="boolean")return U.toString();throw new C(`Error parsing "${U}" as a string.`)}function c(U){if(typeof U=="number")return!0;if(typeof U!="string")return!1;const ut=parseFloat(U);return!Number.isNaN(ut)}function S(U){if(typeof U=="number")return U;if(typeof U!="string")throw new C(`Error parsing "${U}" as a number.`);const ut=parseFloat(U);if(Number.isNaN(ut))throw new C(`Error parsing "${U}" as a number.`);return ut}function x(U){if(typeof U=="number")return!0;if(typeof U!="string")return!1;const ut=parseInt(U);return!Number.isNaN(ut)}function z(U){if(typeof U=="number")return U;if(typeof U!="string")throw new C(`Error parsing "${U}" as an integer.`);const ut=parseInt(U);if(Number.isNaN(ut))throw new C(`Error parsing "${U}" as an integer.`);return ut}function G(U){return typeof U=="boolean"?!0:!(U!=="true"&&U!=="false")}function q(U){if(typeof U=="boolean")return U;if(U!=="true"&&U!=="false")throw new C(`Error parsing "${U}" as a boolean.`);return U==="true"}function st(U){if(Array.isArray(U))return!0;if(typeof U!="string")return!1;try{const ut=JSON.parse(U);if(Array.isArray(ut))return!0}catch{const ut=JSON.parse(decodeURIComponent(U));if(Array.isArray(ut))return!0}return!1}function lt(U){if(Array.isArray(U))return U;if(typeof U!="string")throw new C(`Error parsing "${U}" as an array.`);try{const ut=JSON.parse(U);if(Array.isArray(ut))return ut}catch{const ut=JSON.parse(decodeURIComponent(U));if(Array.isArray(ut))return ut}throw new C(`Error parsing "${U}" as an array.`)}function yt(U){if(typeof U=="object"&&!Array.isArray(U)&&U!==null)return!0;if(typeof U!="string")return!1;try{const ut=JSON.parse(U);if(typeof ut=="object"&&!Array.isArray(ut)&&ut!==null)return!0}catch{const ut=JSON.parse(decodeURIComponent(U));if(typeof ut=="object"&&!Array.isArray(ut)&&ut!==null)return!0}return!1}function rt(U){if(typeof U=="object"&&!Array.isArray(U)&&U!==null)return U;if(typeof U!="string")throw new C(`Error parsing "${U}" as an object.`);try{const ut=JSON.parse(U);if(typeof ut=="object"&&!Array.isArray(ut)&&ut!==null)return ut}catch{const ut=JSON.parse(decodeURIComponent(U));if(typeof ut=="object"&&!Array.isArray(ut)&&ut!==null)return ut}throw new C(`Error parsing "${U}" as an object.`)}function Et(U){return U===null||U==="null"}function Wt(U){if(U!=="null"&&U!==null)throw new C(`Error parsing "${U}" as null.`);return null}const Bt={string:r,number:c,integer:x,boolean:G,array:st,object:yt,null:Et},se={string:h,number:S,integer:z,boolean:q,array:lt,object:rt,null:Wt};if(i===void 0)throw new C(`Error with "${t}" as a target type.`);if(!Array.isArray(i)){if(Bt[i](t))return se[i](t);throw new C(`Error parsing "${t}" as a ${i}.`)}for(const U of i)if(Bt[U](t))return se[U](t);throw new C(`Error parsing "${t}" as one of ${i}.`)}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 r=document.createElement("script");r.src=i,r.async=!0,document.head.appendChild(r),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: ${Q.ERUDA_URL}`);const r=document.createElement("script");r.src=Q.ERUDA_URL,r.integrity=Q.ERUDA_SRI,r.crossOrigin="anonymous",r.async=!0,document.head.appendChild(r),m2c2Globals.erudaRequested=!0;let h=0;const c=()=>{const S=window?.eruda;typeof S<"u"?(console.log("\u26AA eruda ready"),S.init(),m2c2Globals.erudaInitialized=!0):h<i?(h++,setTimeout(c,t)):console.log(`eruda was requested, but could not be loaded after ${t*i} milliseconds.`)};c()}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?Vt.now():m2c2Globals.now,iso8601Timestamp:m2c2Globals.iso8601Now?m2c2Globals.iso8601Now:new Date().toISOString()}}static createTimestamps(){return{timestamp:Vt.now(),iso8601Timestamp:new Date().toISOString()}}static calculateRotatedPoints(t){const i=t.ancestors;i.reverse(),i.push(t);const r=i.map(h=>{const c=V.calculateNodeAbsoluteBoundingBox(h);return V.boundingBoxToPoints(c)});for(let h=0;h<r.length;h++){if(!cn(i[h]))continue;const c=r[h],S=i[h].zRotation,x=V.findCentroid(c);for(let z=h;z<i.length;z++)r[z]=ha(r[z],S,x)}return r[r.length-1]}static rotateCanvasForDrawableNode(t,i){const r=V.calculateRotationTransforms(i);if(r.length===0)return;const h=m2c2Globals.canvasScale/i.absoluteScale;la(r,h,t)}static calculateNodeAbsoluteBoundingBox(t){const i=t.anchorPoint,r=t.absoluteScale;let h=t.size.width,c=t.size.height;if(t.type===dt.Shape&&t.shapeType===Kt.Circle){const q=t.circleOfRadius;if(!q)throw"circleOfRadius is undefined";h=q*2,c=q*2}const S=t.absolutePosition.x-h*i.x*r,x=t.absolutePosition.x+h*(1-i.x)*r,z=t.absolutePosition.y-c*i.y*r,G=t.absolutePosition.y+c*(1-i.y)*r;return{xMin:S,xMax:x,yMin:z,yMax:G}}static radiansToDegrees(t){return-V.normalizeAngleRadians(t)*(180/Math.PI)}static normalizeAngleRadians(t){const i=Math.floor(t/(2*Math.PI));let r=t-i*(2*Math.PI);return r<0&&(r+=2*Math.PI),r}static arePointsOnSameSideOfLine(t,i,r,h){const c=(h.x-r.x)*(t.y-r.y)-(h.y-r.y)*(t.x-r.x),S=(h.x-r.x)*(i.y-r.y)-(h.y-r.y)*(i.x-r.x);return c*S>=0}static isPointInsideRectangle(t,i){if(i.length!==4)throw new C("Invalid input: expected an array of four points");return V.arePointsOnSameSideOfLine(t,i[2],i[0],i[1])&&V.arePointsOnSameSideOfLine(t,i[3],i[1],i[2])&&V.arePointsOnSameSideOfLine(t,i[0],i[2],i[3])&&V.arePointsOnSameSideOfLine(t,i[1],i[3],i[0])}static nodeOrAncestorHasBeenRotated(t){const i=t.ancestors;return i.push(t),i.some(r=>cn(r))}static boundingBoxToPoints(t){const{xMin:i,xMax:r,yMin:h,yMax:c}=t;return[{x:i,y:h},{x:r,y:h},{x:r,y:c},{x:i,y:c}]}static findCentroid(t){if(t.length!==4)throw new C("Invalid input: expected an array of four points");let i=0,r=0;for(const S of t)i+=S.x,r+=S.y;const h=i/4,c=r/4;return{x:h,y:c}}static rotatePoint(t,i,r){const h=t.x-r.x,c=t.y-r.y,S=h*Math.cos(-i)-c*Math.sin(-i),x=h*Math.sin(-i)+c*Math.cos(-i);return{x:S+r.x,y:x+r.y}}static calculateRotationTransforms(t){const i=[],r=t.ancestors;return r.reverse(),r.push(t),r.forEach(h=>{if(cn(h)){const c=h;if(c.type===dt.Scene){const G={x:c.absolutePosition.x+c.size.width*.5,y:c.absolutePosition.y+c.size.height*.5};i.push({radians:c.zRotation,center:G});return}const S=V.calculateNodeAbsoluteBoundingBox(c),x=V.boundingBoxToPoints(S),z=V.findCentroid(x);i.push({radians:c.zRotation,center:z})}}),i}}function la(m,t,i){m.forEach(r=>{i.rotate(V.radiansToDegrees(r.radians),r.center.x*t,r.center.y*t)})}function cn(m){return V.normalizeAngleRadians(m.zRotation)!==0&&m.isDrawable}function ha(m,t,i){if(m.length!==4)throw new C("Invalid input: expected an array of four points");const r=[];for(const h of m)r.push(V.rotatePoint(h,t,i));return r}class zt{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 C("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(Di.Add,...t),this}subtract(...t){return this.appendOperation(Di.Subtract,...t),this}appendOperation(t,...i){i.forEach(r=>{this.pushToExpression(t),this.pushToExpression(r)})}get value(){let t=0;const i=this.expression.flat(1/0);let r=1;for(let h=0;h<i.length;h++){if(typeof i[h]=="number"){t=t+r*i[h];continue}if(i[h]instanceof zt){t=t+r*i[h].value;continue}if(i[h]===Di.Add){r=1;continue}if(i[h]===Di.Subtract){r=-1;continue}}return t}}const Di={Add:"Add",Subtract:"Subtract"};class X{constructor(t=!1){this.startOffset=new zt(0),this.started=!1,this.running=!1,this._completed=!1,this.runStartTime=-1,this.duration=new zt,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,r){if(r!==void 0&&(t.key=r),this.isParent(t)){const h=t.children;h.forEach(c=>{c.parent=t}),h.filter(c=>this.isParent(c)).forEach(c=>this.assignParents(c,i,r))}}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===mt.Group){const r=t.children.map(h=>this.calculateDuration(h)).reduce((h,c)=>Math.max(h,c.value),0);return new zt(r)}if(t.type===mt.Sequence){const r=t.children.map(h=>this.calculateDuration(h)).reduce((h,c)=>h+c.value,0);return new zt(r)}return this.isRepeating(t)?new zt: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 zt(0);if(t.parent.type!==mt.Sequence)return t.parent.startOffset;const i=new zt(0);i.add(t.parent.startOffset);for(const r of t.parent.children){if(r===t)break;i.add(r.duration)}return i}static evaluateAction(t,i,r,h){if(i.involvedInSceneTransition()&&!t.runDuringTransition||(t.runStartTime===-1&&t.assignRunStartTimes(t,r),r<t.runStartTime+t.startOffset.value))return;if(t.shouldBeRunning(r)&&(t.running=!0),t.isParent(t)){if(t.children.forEach(S=>{X.evaluateAction(S,i,r,h)}),!t.isRepeating(t)){t.started||(t.started=!0),t.running&&t.completed&&(t.running=!1);return}X.evaluateRepeatingActions(t,r);return}if(t.shouldBeRunning(r)||(t.running=!1),t.running===!1&&t.completed===!0)return;const c=r-(t.runStartTime+t.startOffset.value);switch(t.type){case mt.Custom:X.evaluateCustomAction(t);break;case mt.Play:X.evaluatePlayAction(i,t);break;case mt.Wait:X.evaluateWaitAction(t,r);break;case mt.Move:X.evaluateMoveAction(t,i,c);break;case mt.Scale:X.evaluateScaleAction(t,i,c,h);break;case mt.FadeAlpha:X.evaluateFadeAlphaAction(t,i,c,h);break;case mt.Rotate:X.evaluateRotateAction(t,i,c,h);break;default:throw new C(`Action type not recognized: ${t.type}`)}}static evaluateRepeatingActions(t,i){if(t.started||(t.started=!0),t.repetitionHasCompleted){t.completedRepetitions++;const r=t.children[0].duration.value;if(t.cumulativeDuration=t.cumulativeDuration+r,!isFinite(r))throw"repetitionDuration is not finite";if(!t.completed)t.restartAction(t,i);else{if(t.type===mt.RepeatForever)throw new C("RepeatForever action should never complete");t.duration.assign(t.cumulativeDuration),t.running=!1}}}static evaluateRotateAction(t,i,r,h){const c=t;c.started||(c.byAngle!==void 0&&(c.delta=c.byAngle),c.toAngle!==void 0&&(c.toAngle=V.normalizeAngleRadians(c.toAngle),i.zRotation=V.normalizeAngleRadians(i.zRotation),c.delta=c.toAngle-i.zRotation,c.shortestUnitArc===!0&&Math.abs(c.delta)>Math.PI&&(c.delta=2*Math.PI-Math.abs(c.delta))),c.started=!0,c.finalValue=i.zRotation+c.delta),r<c.duration.value?(i.zRotation=i.zRotation+c.delta*(h/c.duration.value),c.delta<=0&&i.zRotation<c.finalValue&&(i.zRotation=c.finalValue),c.delta>0&&i.zRotation>c.finalValue&&(i.zRotation=c.finalValue)):(i.zRotation=c.finalValue,c.running=!1,c.completed=!0)}static evaluateFadeAlphaAction(t,i,r,h){const c=t;c.started||(c.delta=c.alpha-i.alpha,c.started=!0),r<c.duration.value?i.alpha=i.alpha+c.delta*(h/c.duration.value):(i.alpha=c.alpha,c.running=!1,c.completed=!0)}static evaluateScaleAction(t,i,r,h){const c=t;c.started||(c.delta=c.scale-i.scale,c.started=!0),r<c.duration.value?i.scale=i.scale+c.delta*(h/c.duration.value):(i.scale=c.scale,c.running=!1,c.completed=!0)}static evaluateMoveAction(t,i,r){const h=t;h.started||(h.dx=h.point.x-i.position.x,h.dy=h.point.y-i.position.y,h.startPoint.x=i.position.x,h.startPoint.y=i.position.y,h.started=!0),r<h.duration.value?(i.position.x=h.easing(r,h.startPoint.x,h.dx,h.duration.value),i.position.y=h.easing(r,h.startPoint.y,h.dy,h.duration.value)):(i.position.x=h.point.x,i.position.y=h.point.y,h.running=!1,h.completed=!0)}static evaluateWaitAction(t,i){const r=t;i>t.runStartTime+t.startOffset.value+t.duration.value&&(r.running=!1,r.completed=!0)}static evaluatePlayAction(t,i){if(t.type!==dt.SoundPlayer)throw new C("Play action can only be used with a SoundPlayer");const r=i,h=t,c=h.game.soundManager;if(!r.started){const S=c.getSound(h.soundName);if(S.audioBuffer)S.audioBufferSource=c.audioContext.createBufferSource(),S.audioBufferSource.buffer=S.audioBuffer,S.audioBufferSource.onended=()=>{r.running=!1,r.completed=!0;const x=performance.now()-(i.runStartTime+i.startOffset.value);i.duration.assign(x)},S.audioBufferSource.connect(c.audioContext.destination),S.audioBufferSource.start(),r.started=!0;else{if(S.status===jt.Error)throw new C(`error loading sound ${S.soundName} (url ${S.url})`);console.warn(`Play action: audio buffer not ready for sound ${h.soundName} (url: ${S.url}); will try next frame`),S.status===jt.Deferred&&c.fetchDeferredSound(S)}}}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(r=>{t.assignRunStartTimes(r,i)})}restartAction(t,i){if(t.runStartTime=i,t.running=!0,t.started=!0,t.type===mt.Play&&(t.duration=new zt),t.isParent(t)){t.children.forEach(r=>{t.restartAction(r,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 Or(t.point,new zt(t.duration),t.easing??De.linear,t.runDuringTransition??!1)}static wait(t){return new Ir(new zt(t.duration),t.runDuringTransition??!1)}static custom(t){return new kr(t.callback,t.runDuringTransition??!1)}static play(t){return new Nr(t?.runDuringTransition??!1)}static scale(t){return new Dr(t.scale,new zt(t.duration),t.runDuringTransition)}static fadeAlpha(t){return new zr(t.alpha,new zt(t.duration),t.runDuringTransition)}static rotate(t){if(t.byAngle!==void 0&&t.toAngle!==void 0)throw new C("rotate Action: cannot specify both byAngle and toAngle");if(t.byAngle===void 0&&t.toAngle===void 0)throw new C("rotate Action: must specify either byAngle or toAngle");if(t.toAngle===void 0&&t.shortestUnitArc!==void 0)throw new C("rotate Action: shortestUnitArc can only be specified when toAngle is provided");return t.toAngle!==void 0&&t.shortestUnitArc===void 0&&(t.shortestUnitArc=!0),new Lr(t.byAngle,t.toAngle,t.shortestUnitArc,new zt(t.duration),t.runDuringTransition)}static sequence(t){const i=new Fr(t);return i.children=t,i}static group(t){const i=new Mr(t);return i.children=t,i}static repeat(t){return new un(t.action,t.count,t.runDuringTransition)}static repeatForever(t){return new Rr(t.action,t.runDuringTransition)}isParent(t){return t.type===mt.Group||t.type===mt.Sequence||t.type===mt.Repeat||t.type===mt.RepeatForever}isRepeating(t){return t.type===mt.Repeat||t.type===mt.RepeatForever}get completed(){return this._completed}set completed(t){this._completed=t}}class Fr extends X{constructor(t){super(),this.type=mt.Sequence,this.children=t}clone(){const t=this.children.map(r=>r.clone()),i=X.sequence(t);return i.children.forEach(r=>r.key=this.key),i.key=this.key,i}get completed(){return this.children.every(t=>t.completed)}get descendants(){return dn(this)}}class Mr extends X{constructor(t){super(),this.type=mt.Group,this.children=new Array,this.children=t}clone(){const t=this.children.map(r=>r.clone()),i=X.group(t);return i.children.forEach(r=>r.key=this.key),i.key=this.key,i}get completed(){return this.children.every(t=>t.completed)}get descendants(){return dn(this)}}class un extends X{constructor(t,i,r=!1){super(r),this.type=mt.Repeat,this.completedRepetitions=0,this.cumulativeDuration=0,this.children=[t],this.count=i,this.duration=new zt}clone(){if(this.children.length!==1)throw new C("Repeat action must have exactly one child");const t=X.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 dn(this)}}class Rr extends un{constructor(t,i=!1){super(t,1/0,i),this.type=mt.RepeatForever,this.count=1/0}clone(){if(this.children.length!==1)throw new C("RepeatForever action must have exactly one child");const t=X.repeatForever({action:this.children[0].clone(),runDuringTransition:this.runDuringTransition});return t.children[0].key=this.key,t.key=this.key,t}}function dn(m){const t=[];function i(r){if(r.isParent(r))for(const h of r.children)t.push(h),i(h)}return i(m),t}class kr extends X{constructor(t,i=!1){super(i),this.type=mt.Custom,this.callback=t,this.duration=new zt(0)}clone(){const t=X.custom({callback:this.callback,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class Nr extends X{constructor(t=!1){super(t),this.type=mt.Play,this.duration=new zt}clone(){const t=X.play({runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class Ir extends X{constructor(t,i){super(i),this.type=mt.Wait,this.duration=t}clone(){const t=X.wait({duration:this.duration.value,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class Or extends X{constructor(t,i,r,h){super(h),this.type=mt.Move,this.startPoint={x:NaN,y:NaN},this.dx=0,this.dy=0,this.duration=i,this.point=t,this.easing=r}clone(){const t=X.move({point:this.point,duration:this.duration.value,easing:this.easing,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class Dr extends X{constructor(t,i,r=!1){super(r),this.type=mt.Scale,this.delta=0,this.duration=i,this.scale=t}clone(){const t=X.scale({scale:this.scale,duration:this.duration.value,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class zr extends X{constructor(t,i,r=!1){super(r),this.type=mt.FadeAlpha,this.delta=0,this.duration=i,this.alpha=t}clone(){const t=X.fadeAlpha({alpha:this.alpha,duration:this.duration.value,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class Lr extends X{constructor(t,i,r,h,c=!1){super(c),this.type=mt.Rotate,this.delta=0,this.finalValue=NaN,this.duration=h,this.byAngle=t,this.toAngle=i,this.shortestUnitArc=r}clone(){const t=X.rotate({byAngle:this.byAngle,toAngle:this.toAngle,shortestUnitArc:this.shortestUnitArc,duration:this.duration.value,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}var ui=(m=>(m.Game="Game",m.Survey="Survey",m))(ui||{});class Nt{static Dispose(t){t.filter(i=>!i?.isDeleted()).forEach(i=>i?.delete())}static makePaint(t,i,r,h){const c=new t.Paint;return c.setColor(t.Color(i[0],i[1],i[2],i[3])),c.setStyle(r),c.setAntiAlias(h),c}}class Bi{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 Bi;return t._subpaths=JSON.parse(JSON.stringify(this._subpaths)),t.currentPath=JSON.parse(JSON.stringify(this.currentPath)),t}}class ca extends Bi{constructor(){super(...arguments),this.strokeColor=Q.DEFAULT_PATH_STROKE_COLOR,this.lineWidth=Q.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=Q.DEFAULT_PATH_STROKE_COLOR,this.lineWidth=Q.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 Gt=(m=>(m.topToTopOf="topToTopOf",m.topToBottomOf="topToBottomOf",m.bottomToTopOf="bottomToTopOf",m.bottomToBottomOf="bottomToBottomOf",m.startToStartOf="startToStartOf",m.startToEndOf="startToEndOf",m.endToEndOf="endToEndOf",m.endToStartOf="endToStartOf",m))(Gt||{});class Br{constructor(t,i){this.verticalConstraint=!1,this.focalNodeMinimum=!1,this.alterNodeMinimum=!1,this.verticalTypes=[Gt.topToTopOf,Gt.topToBottomOf,Gt.bottomToTopOf,Gt.bottomToBottomOf],this.focalNodeMinimumTypes=[Gt.topToTopOf,Gt.topToBottomOf,Gt.startToStartOf,Gt.startToEndOf],this.alterNodeMinimumTypes=[Gt.topToTopOf,Gt.bottomToTopOf,Gt.startToStartOf,Gt.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 ze{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 H={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",KeyDown:"KeyDown",KeyUp:"KeyUp",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 K{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"?K.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 r=0;r<t.length;r++)if(!K.objectsDeepEqual(t[r],i[r]))return!1;return!0}if(typeof t=="object"&&!Array.isArray(t)&&t!==null&&typeof i=="object"&&!Array.isArray(i)&&i!==null){const r=Object.keys(t),h=Object.keys(i);if(r.length!==h.length)return!1;for(const c of r)if(!(c in i)||!K.objectsDeepEqual(t[c],i[c]))return!1;return!0}return!1}}function ua(m,t){t.anchorPoint&&(m.anchorPoint=t.anchorPoint),t.zPosition!==void 0&&(m.zPosition=t.zPosition)}function da(m,t){t.text!==void 0&&(m.text=t.text),t.fontName!==void 0&&(m.fontName=t.fontName),t.fontColor&&(m.fontColor=t.fontColor),t.fontSize!==void 0&&(m.fontSize=t.fontSize),t.interpolation&&(m.interpolation=t.interpolation),t.localize!==void 0&&(m.localize=t.localize)}function Le(m,t){m.isDrawable&&ua(m,t),m.isText&&da(m,t)}class fe{constructor(t={}){this.type=dt.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=ze.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==dt.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?Vt.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 C("initialize() called in abstract base class Node.")}get completeNodeOptions(){throw new C("get completeNodeOptions() called in abstract base class Node.")}saveNodeNewEvent(){if(this.suppressEvents)return;const t={type:H.NodeNew,target:this,nodeType:this.type,compositeType:this.type===dt.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 r={type:H.NodePropertyChange,target:this,uuid:this.uuid,property:t,value:i,...V.createFrameUpdateTimestamps()};this.saveEvent(r)}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===dt.Scene?i.parent:t(i.parent);throw new C(`Node ${this} has not been added to a scene.`)};return t(this).game}isPartOfGame(){if(this.type===dt.Scene&&this._game===void 0)return!1;if(this.type===dt.Scene&&this._game!==void 0)return!0;const t=i=>{if(i.parent)return i.parent.type===dt.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 C(`Cannot add node ${t.toString()} as a child to itself.`);if(t.type==dt.Scene)throw new C(`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(c=>c!==t).map(c=>c.name).includes(t.name))throw new C(`Cannot add child node ${t.toString()} to parent node ${this.toString()}. A child with name "${t.name}" already exists on this parent.`);let r=new Array;if(this.isPartOfGame())r=this.game.nodes.filter(c=>c.children.includes(t));else{const c=this.descendants;c.includes(t)&&(r=c.filter(S=>S.children.includes(t)).map(S=>S.parent??void 0))}if(r.length===0){t.parent=this,this.children.push(t);const c={type:"NodeAddChild",target:this,uuid:this.uuid,childUuid:t.uuid,...V.createFrameUpdateTimestamps()};i||this.saveEvent(c),this.saveChildEvents(t);return}const h=r.find(Boolean);throw h===this?new C(`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 C(`Cannot add child node ${t.toString()} to parent node ${this.toString()}. This child already exists on other parent node: ${h?.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(h=>h!==t);else throw new C(`cannot remove node ${t} from parent ${this} because the node is not currently a child of the parent`);const r={type:"NodeRemoveChild",target:this,uuid:this.uuid,childUuid:t.uuid,...V.createFrameUpdateTimestamps()};i||this.saveEvent(r)}removeChildren(t){t.forEach(i=>{if(!this.children.includes(i))throw new C(`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(r=>r.name===t).find(Boolean);if(i===void 0)throw new C(`descendant with name ${t} not found on parent ${this.toString()}`);return i}get descendants(){function t(r,h){h.push(r),r.children.forEach(c=>t(c,h))}const i=new Array;return this.children.forEach(r=>t(r,i)),i}get ancestors(){function t(r,h){return r.type==dt.Scene||!r.parent?h:(h.push(r.parent),t(r.parent,h))}const i=new Array;return t(this,i)}involvedInActionAffectingAppearance(){return this.ancestors.concat(this).flatMap(r=>r.actions).some(r=>r.running&&(r.type===mt.Move||r.type===mt.Scale))}involvedInSceneTransition(){let t;return this.type===dt.Scene?t=this:t=this.parentSceneAsNode,t._transitioning}onTapDown(t,i){this.addEventListener(H.TapDown,t,i)}onTapUp(t,i){this.addEventListener(H.TapUp,t,i)}onTapUpAny(t,i){this.addEventListener(H.TapUpAny,t,i)}onTapLeave(t,i){this.addEventListener(H.TapLeave,t,i)}onPointerDown(t,i){this.addEventListener(H.PointerDown,t,i)}onPointerUp(t,i){this.addEventListener(H.PointerUp,t,i)}onPointerMove(t,i){this.addEventListener(H.PointerMove,t,i)}onPointerLeave(t,i){this.addEventListener(H.PointerLeave,t,i)}onDragStart(t,i){this.addEventListener(H.DragStart,t,i)}onDrag(t,i){this.addEventListener(H.Drag,t,i)}onDragEnd(t,i){this.addEventListener(H.DragEnd,t,i)}addEventListener(t,i,r){const h={type:t,nodeUuid:this.uuid,callback:i};r?.replaceExisting&&(this.eventListeners=this.eventListeners.filter(c=>!(c.nodeUuid===h.nodeUuid&&c.type===h.type))),this.eventListeners.push(h)}parseLayoutConstraints(t,i){const r=new Array;return Object.values(Gt).forEach(c=>{if(t[c]!==void 0){let S,x="";if(typeof t[c]=="object")S=t[c];else{const G=t[c];S=i.filter(q=>q.name===G||q.uuid===G).find(Boolean),S||(S=this.game.materializedNodes.filter(q=>q.name===G||q.uuid===G).find(Boolean)),x=`. sibling node named "${G}" has not been added to the game object`}if(S===void 0)throw new C("could not find sibling node for constraint"+x);const z=new Br(c,S);r.push(z)}}),r}calculateYFromConstraint(t,i,r,h){let c=t.alterNode.absolutePosition.y;return t.alterNodeMinimum?t.alterNode.type!==dt.Scene&&(c=c-t.alterNode.size.height*.5*h):t.alterNode.type!==dt.Scene?c=c+t.alterNode.size.height*.5*h:c=c+t.alterNode.size.height*h,t.focalNodeMinimum?(c=c+this.size.height*.5*h,c=c+i*h):(c=c-this.size.height*.5*h,c=c-r*h),c}calculateXFromConstraint(t,i,r,h){let c=t.alterNode.absolutePosition.x;return t.alterNodeMinimum?t.alterNode.type!==dt.Scene&&(c=c-t.alterNode.size.width*.5*h):t.alterNode.type!==dt.Scene?c=c+t.alterNode.size.width*.5*h:c=c+t.alterNode.size.width*h,t.focalNodeMinimum?(c=c+this.size.width*.5*h,c=c+i*h):(c=c-this.size.width*.5*h,c=c-r*h),c}calculateAbsoluteAlpha(t,i){const r=i.reduce((h,c)=>h*c.alpha,1);return t*r}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 h=this.layout?.constraints?.horizontalBias??.5,c=this.layout?.constraints?.verticalBias??.5,S=this.layout?.marginTop??0,x=this.layout?.marginBottom??0,z=this.layout?.marginStart??0,G=this.layout?.marginEnd??0,q=this.parseLayoutConstraints(this.layout?.constraints,this.parentSceneAsNode.descendants),st=this.parent.absoluteScale,lt=q.filter(rt=>rt.verticalConstraint).map(rt=>this.calculateYFromConstraint(rt,S,x,st));lt.length===0||(lt.length===1?this.absolutePosition.y=lt[0]:lt.length===2&&(this.absolutePosition.y=Math.min(lt[0],lt[1])+c*Math.abs(lt[0]-lt[1])));const yt=q.filter(rt=>!rt.verticalConstraint).map(rt=>this.calculateXFromConstraint(rt,z,G,st));yt.length===0||(yt.length===1?this.absolutePosition.x=yt[0]:yt.length===2&&(this.absolutePosition.x=Math.min(yt[0],yt[1])+h*Math.abs(yt[0]-yt[1])))}this.actions.forEach(h=>X.evaluateAction(h,this,m2c2Globals.now,m2c2Globals.deltaTime));function t(h,c){const S=new Array;return c===void 0||Object.values(Gt).forEach(z=>{if(c[z]!==void 0){let G,q="";if(typeof c[z]=="object")G=c[z];else{const st=c[z];let lt;h.type===dt.Scene?lt=h.descendants:lt=h.parentSceneAsNode.descendants,G=lt.filter(yt=>yt.name===st||yt.uuid===st).find(Boolean),G===void 0&&(G=h.game.materializedNodes.filter(yt=>yt.name===st||yt.uuid===st).find(Boolean)),G===void 0&&(q=`. sibling node named "${st}" has not been added to the game object`)}if(G===void 0)throw new C("error getting uuid of sibling constraint"+q);G!==h&&S.push(G.uuid)}}),S}const i=new Map;this.children.forEach(h=>{i.set(h.uuid,t(this,h.layout?.constraints))});const r=this.findTopologicalSort(i);if(r.length>0){const h=r.reverse(),c=new Array;h.forEach(S=>{const x=this.children.filter(z=>z.uuid===S).find(Boolean);if(x===void 0)throw new C("error in dag topological sort");c.push(x)}),c.forEach(S=>S.update())}else this.children.forEach(h=>h.update())}drawChildren(t){this.children.filter(i=>!i.hidden&&i.isDrawable).map(i=>i).sort((i,r)=>i.zPosition-r.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 C("getDrawableOptions() called object that is not IDrawable");return{anchorPoint:this.anchorPoint,zPosition:this.zPosition}}getTextOptions(){if(!this.isText)throw new C("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===dt.Scene)throw new C(`Node ${this} is a scene and cannot have a parent scene`);if(this.parent&&this.parent.type===dt.Scene)return this.parent;if(this.parent)return this.parent.parentSceneAsNode;throw new C(`Node ${this} has not been added to a scene`)}get size(){const t=this;return{get height(){return t._size.height},set height(i){K.value(t._size.height,i)||(t._size.height=i,t.savePropertyChangeEvent("size",t.size))},get width(){return t._size.width},set width(i){K.value(t._size.width,i)||(t._size.width=i,t.savePropertyChangeEvent("size",t.size))}}}set size(t){K.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){K.value(t._position.x,i)||(t._position.x=i,t.savePropertyChangeEvent("position",t.position))},get y(){return t._position.y},set y(i){K.value(t._position.y,i)||(t._position.y=i,t.savePropertyChangeEvent("position",t.position))}}}set position(t){K.value(this._position,t)||(this._position=t,this.savePropertyChangeEvent("position",this.position))}get zRotation(){return this._zRotation}set zRotation(t){K.value(this._zRotation,t)||(this._zRotation=t,this.savePropertyChangeEvent("zRotation",t))}get scale(){return this._scale}set scale(t){K.value(this._scale,t)||(this._scale=t,this.savePropertyChangeEvent("scale",t))}get alpha(){return this._alpha}set alpha(t){K.value(this._alpha,t)||(this._alpha=t,this.savePropertyChangeEvent("alpha",t))}get isUserInteractionEnabled(){return this._isUserInteractionEnabled}set isUserInteractionEnabled(t){K.value(this._isUserInteractionEnabled,t)||(this._isUserInteractionEnabled=t,this.savePropertyChangeEvent("isUserInteractionEnabled",t))}get hidden(){return this._hidden}set hidden(t){K.value(this._hidden,t)||(this._hidden=t,this.savePropertyChangeEvent("hidden",t))}get draggable(){return this._draggable}set draggable(t){K.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=[],r=new Map;t.forEach((c,S)=>{r.has(S)||r.set(S,0),c.forEach(x=>{if(r.has(x)){const z=r.get(x);if(z===void 0)throw new C(`Could not find inDegree for edge ${x}`);r.set(x,z+1)}else r.set(x,1)})});const h=[];for(r.forEach((c,S)=>{c==0&&h.push(S)});h.length>0;){const c=h.shift();if(c===void 0)throw"current vertex is undefined";i.push(c),t.has(c)&&t.get(c)?.forEach(S=>{const x=r.get(S);if(x===void 0)throw new C(`Could not find inDegree for edge ${S}`);if(r.has(S)&&x>0){const z=x-1;r.set(S,z),z==0&&h.push(S)}})}return i}}class fa extends fe{constructor(t={}){super(t),this.type=dt.Composite,this.compositeType="<compositeType>",this.isDrawable=!0,this._anchorPoint={x:.5,y:.5},this._zPosition=0,Le(this,t)}initialize(){}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){K.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){K.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){K.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){K.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}dispose(){}update(){super.update()}draw(t){super.drawChildren(t)}handleCompositeEvent(t){}}var Ur=(m=>(m[m.MatchConstraint=0]="MatchConstraint",m))(Ur||{});const ne={Deferred:"Deferred",Loading:"Loading",Ready:"Ready",Error:"Error"};class fn{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(r=>{let h=r.url;r.url&&!V.urlHasScheme(r.url)&&(h=V.getUrlFromManifest(this.game,`${this.baseUrls.assets}/${r.url}`)),r.dataUrl&&(h=r.dataUrl);const c={imageName:r.imageName,url:h,originalUrl:h,isFallback:!1,localize:r.localize??!1,svgString:r.svgString,canvaskitImage:void 0,width:r.width,height:r.height,status:r.lazy?ne.Deferred:ne.Loading};return c.localize&&this.configureImageLocalization(c),this.images[r.imageName]=c,c.status===ne.Loading?this.renderM2Image(c):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=Nt.makePaint(this.canvasKit,this.game.i18n.missingLocalizationColor,this.canvasKit.PaintStyle.Stroke,!0),this.missingLocalizationImagePaint.setStrokeWidth(4)))}localizeImageUrl(t,i){const r=t.lastIndexOf(".");if(r===-1)throw new C("URL does not have an extension");return t.slice(0,r)+`.${i}`+t.slice(r)}reinitializeLocalizedImages(){Object.keys(this.game.imageManager.images).forEach(i=>{const r=this.game.imageManager.images[i];r.localize&&this.game.imageManager.configureImageLocalization(r)}),this.game.nodes.filter(i=>i.type===dt.Sprite).forEach(i=>{i.needsInitialization=!0})}checkImageNamesForDuplicates(t){const r=(h=>h.filter((c,S)=>h.indexOf(c)!=S))(t.map(h=>h.imageName));if(r.length>0)throw new C(`image names must be unique. these image names are duplicated within a game ${this.game.id}: `+r.join(", "))}prepareDeferredImage(t){return t.status=ne.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 C(`prepareDeferredImage(): unable to render image named ${t.imageName}. image source was ${t.svgString?"svgString":`url: ${t.url}`}`)}}})}renderM2Image(t){const i=document.createElement("img"),r=h=>{if(!this.scratchCanvas||!this.ctx||!this.scale)throw new C("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(c=>{if(!c)throw new C(`renderM2Image(): blob is undefined for ${t.imageName}`);c.arrayBuffer().then(S=>{const x=this.canvasKit.MakeImageFromEncoded(S);if(!x)throw new C(`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=x,this.images[t.imageName].status=ne.Ready,this.game.nodes.filter(G=>G.type==="Sprite").forEach(G=>{G.imageName===t.imageName&&(G.needsInitialization=!0)}),h()})})};return new Promise((h,c)=>{if(i.width=t.width,i.height=t.height,i.crossOrigin="Anonymous",i.onerror=()=>{c(new Error(`unable to render image named ${t.imageName}. image source was ${t.svgString?"svgString":`url: ${t.url}`}`))},i.onload=()=>{r(h)},!t.svgString&&!t.url)throw new C(`no svgString or url provided for image named ${t.imageName}`);if(t.svgString&&t.url)throw new C(`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 S={type:H.BrowserImageDataReady,target:this,imageName:t.imageName,width:t.width,height:t.height,svgString:t.svgString,...V.createFrameUpdateTimestamps()};this.game.eventStore.addEvent(S)}else t.url&&fetch(t.url).then(S=>S.arrayBuffer()).then(S=>{this.arrayBufferToBase64Async(S).then(x=>{const z=this.inferImageSubtypeFromUrl(t.url);i.src="data:image/"+z+";base64,"+x;const G={type:H.BrowserImageDataReady,target:this,imageName:t.imageName,width:t.width,height:t.height,dataUrl:i.src,...V.createFrameUpdateTimestamps()};this.game.eventStore.addEvent(G)})})})}arrayBufferToBase64Async(t){return new Promise((i,r)=>{const h=new FileReader;h.onload=()=>{i(h.result?.toString().split(",")[1]??"")},h.onerror=r,h.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 C("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()}}const di="{{}}",pn="[[]]";class zi{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){const r=this.attemptTranslation(t,i);if(r.isFallbackOrMissingTranslation){const h=this.handleTranslationPlaceholders(t,r,i);if(h)return i!==void 0&&(h.text=this.insertInterpolations(di,h.text,i)),h}return r}attemptTranslation(t,i){let r=this.tf(t,i),h=!1;return r?.text===void 0&&(r=this.tf(t,{useFallbackLocale:!0,...i}),h=!0),{text:r?.text??t,fontSize:r?.fontSize,fontName:r?.fontName,fontNames:r?.fontNames,isFallbackOrMissingTranslation:h}}handleTranslationPlaceholders(t,i,r){const h=this.getTranslationPlaceholders(t);if(h.length===0)return null;const c={size:new Set,name:new Set,names:new Set},S={};let x=!1;h.forEach(lt=>{const yt=this.translatePlaceholder(lt,c,r);S[lt]=yt.text,x=x||yt.isFallback}),this.warnConflictingFontProperties(t,c);const z=this.insertInterpolations(pn,t,S),G=i.fontSize||(c.size.size>0?[...c.size][0]:void 0),q=i.fontName||(c.name.size>0?[...c.name][0]:void 0),st=i.fontNames||(c.names.size>0?[...c.names][0].split(","):void 0);return{text:z,fontSize:G,fontName:q,fontNames:st,isFallbackOrMissingTranslation:x}}translatePlaceholder(t,i,r){let h=this.tf(t,r),c=!1;return h?.text===void 0&&(h=this.tf(t,{useFallbackLocale:!0,...r}),c=!0),h?.fontSize!==void 0&&i.size.add(h.fontSize),h?.fontName!==void 0&&i.name.add(h.fontName),h?.fontNames!==void 0&&i.names.add(h.fontNames.sort().join(",")),{text:h?.text??t,isFallback:c}}getTranslationPlaceholders(t){const[i,r]=[pn.slice(0,2),pn.slice(2)],h=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),S=new RegExp(`${h}(.*?)${c}`,"g"),x=t.match(S);return x?x.map(z=>z.slice(i.length,-r.length).trim()):[]}warnConflictingFontProperties(t,i){i.size.size>1&&console.warn(`i18n: placeholders set multiple different font sizes in string to be localized. Only one will be used. String: ${t}`),i.name.size>1&&console.warn(`i18n: placeholders set multiple different font names within string to be localized. Only one will be used. String: ${t}`),i.names.size>1&&console.warn(`i18n: placeholders set multiple different font names arrays within string to be localized. Only one will be used. String: ${t}`)}t(t,i){const{useFallbackLocale:r,...h}=i??{};if(r!==!0){const S=this.translation[this.locale]?.[t];return this.isStringOrTextWithFontCustomization(S)?this.insertInterpolations(di,this.getKeyText(S),h):void 0}const c=this.translation[this.fallbackLocale]?.[t];if(this.isStringOrTextWithFontCustomization(c))return this.insertInterpolations(di,this.getKeyText(c),h)}tf(t,i){const{useFallbackLocale:r,...h}=i??{};if(r!==!0){const S=this.translation[this.locale]?.[t];if(this.isStringOrTextWithFontCustomization(S)){const x=this.getKeyTextAndFont(S,this.locale);return x.text&&(x.text=this.insertInterpolations(di,x.text,h)),x}return}const c=this.translation[this.fallbackLocale]?.[t];if(this.isStringOrTextWithFontCustomization(c)){const S=this.getKeyTextAndFont(c,this.fallbackLocale);return S.text&&(S.text=this.insertInterpolations(di,S.text,h)),S}}getKeyText(t){return this.isTextWithFontCustomization(t)?t.text:t}getKeyTextAndFont(t,i){let r,h=new Array;this.isString(this.translation[i]?.fontName)?h.push(this.translation[i].fontName):this.isStringArray(this.translation[i]?.fontName)?h.push(...this.translation[i].fontName):h.push("default");let c;switch(this.isTextWithFontCustomization(t)?(c=t.text,r=t.fontSize,this.isString(t.additionalFontName)&&h.push(t.additionalFontName),this.isStringArray(t.additionalFontName)&&h.push(...t.additionalFontName),t.overrideFontName&&(h.length=0,this.isString(t.overrideFontName)&&h.push(t.overrideFontName),this.isStringArray(t.overrideFontName)&&h.push(...t.overrideFontName))):c=t,h=h.filter(S=>S!=="default"),h.length){case 0:return{text:c,fontSize:r};case 1:return{text:c,fontSize:r,fontName:h[0]};default:return{text:c,fontSize:r,fontNames:h}}}insertInterpolations(t,i,r){if(!r)return i;const[h,c]=[t.slice(0,2),t.slice(2)],S=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),x=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),z=new RegExp(`${S}(.*?)${x}`,"g");return i.replace(z,(G,q)=>{if(Object.prototype.hasOwnProperty.call(r,q))return r[q];throw new C(`insertInterpolations(): placeholder "${q}" not found. Text was ${i}, provided interpolation was ${JSON.stringify(r)}`)})}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 r={},h=new Array;for(const c in t)h.push(c),r[c]={...t[c],...i[c]};for(const c in i)h.includes(c)||(r[c]=i[c]);return r}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 ve={Disabled:"Disabled",Record:"Record",Replay:"Replay"};class $r{constructor(){this.events=new Array,this.replayBeginTimestamp=NaN,this.firstTimestamp=NaN,this.replayThoughSequence=Number.MAX_VALUE,this.serializedEventsBeforeReplay="",this.mode=ve.Disabled}serializeEvent(t){const i=t.target;if(t.type===H.NodeNew&&t.nodeOptions?.layout?.constraints!==void 0){const h=t.nodeOptions?.layout?.constraints,c={};for(const x in h){if(x==="horizontalBias"||x==="verticalBias"){c[x]=h[x];continue}const z=h[x];z instanceof fe&&(c[x]=z.uuid)}t.target=i.uuid,t.nodeOptions.layout.constraints=c;const S=JSON.stringify(t);return t.target=i,t.nodeOptions.layout.constraints=h,S}if(i instanceof fe){t.target=i.uuid;const h=JSON.stringify(t);return t.target=i,h}if(i instanceof Element){t.target=i.nodeName;const h=JSON.stringify(t);return t.target=i,h}if(i instanceof fn){t.target="ImageManager";const h=JSON.stringify(t);return t.target=i,h}if(i instanceof zi){t.target="I18n";const h=JSON.stringify(t);return t.target=i,h}t.target="object";const r=JSON.stringify(t);return t.target=i,r}addEvent(t){if(this.mode===ve.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=ve.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=ve.Replay,this.replayBeginTimestamp=Vt.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,r=t-this.replayBeginTimestamp+this.firstTimestamp;for(;this.events.length>0&&this.events[0].timestamp<=r;){const h=this.events.shift();if(!h)throw new C("EventStore.dequeueEvents(): undefined event");h.sequence!==void 0&&h.sequence>this.replayThoughSequence||i.push(h)}return i}get eventQueueLength(){return this.events.length}sortEventStore(t){t.sort((i,r)=>{if(i.sequence===void 0||r.sequence===void 0)throw new C("EventStore.sortEventStore(): undefined sequence");return i.sequence!==r.sequence?i.sequence-r.sequence:0})}}var He=(m=>(m[m.Center=0]="Center",m[m.Left=1]="Left",m[m.Right=2]="Right",m))(He||{});const re={Deferred:"Deferred",Loading:"Loading",Ready:"Ready"},Jt={UNDERLINE:"u",ITALIC:"i",BOLD:"b",STRIKETHROUGH:"s",OVERLINE:"o"};class Ui extends fe{constructor(t={}){super(t),this.type=dt.Label,this.isDrawable=!0,this.isText=!0,this._anchorPoint={x:.5,y:.5},this._zPosition=0,this._text="",this._fontColor=Q.DEFAULT_FONT_COLOR,this._fontSize=Q.DEFAULT_FONT_SIZE,this._interpolation={},this._horizontalAlignmentMode=He.Center,this._localize=!0,this.localizedFontNames=[],this.textAfterLocalization="",this.plainText="",this.styleSegments=[],Le(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 He.Center:t=this.canvasKit.TextAlign.Center;break;case He.Left:t=this.canvasKit.TextAlign.Left;break;case He.Right:t=this.canvasKit.TextAlign.Right;break;default:throw new C("unknown horizontalAlignmentMode")}this.text||(this.text="");let i=this.canvasKit.Color(this.fontColor[0],this.fontColor[1],this.fontColor[2],this.fontColor[3]);const r=this.game.i18n;if(r&&this.localize!==!1){const q=r.getTextLocalization(this.text,this.interpolation);this.textAfterLocalization=q.text,this.localizedFontSize=q.fontSize,this.localizedFontName=q.fontName,this.localizedFontNames=q.fontNames??[],q.isFallbackOrMissingTranslation&&r.missingLocalizationColor&&(i=this.canvasKit.Color(r.missingLocalizationColor[0],r.missingLocalizationColor[1],r.missingLocalizationColor[2],r.missingLocalizationColor[3]))}else this.textAfterLocalization=this.text;const h=this.parseFormattedText(this.textAfterLocalization);if(this.plainText=h.plainText,this.styleSegments=h.styleSegments,this.fontName&&this.fontNames)throw new C("cannot specify both fontName and fontNames");const c=this.game.fontManager,S=this.getRequiredLabelFonts(c);if(S.forEach(q=>{if(q.status===re.Deferred){c.prepareDeferredFont(q);return}}),!S.every(q=>q.status===re.Ready))return;this.paraStyle=new this.canvasKit.ParagraphStyle({textStyle:{},textAlign:t}),this.builder&&this.builder.delete(),this.builder=this.canvasKit.ParagraphBuilder.MakeFromFontProvider(this.paraStyle,c.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));const x={fontFamilies:S.map(q=>q.fontName),fontSize:(this.localizedFontSize??this.fontSize)*m2c2Globals.canvasScale,fontStyle:{weight:this.canvasKit.FontWeight.Normal,width:this.canvasKit.FontWidth.Normal,slant:this.canvasKit.FontSlant.Upright},decoration:0,decorationThickness:1,decorationStyle:this.canvasKit.DecorationStyle.Solid,heightMultiplier:-1,halfLeading:!1,letterSpacing:0,wordSpacing:0};this.builder.pushPaintStyle(x,this.fontPaint,this.backgroundPaint),this.addStyleSegmentsToParagraphBuilder(this.builder,this.styleSegments,x),this.paragraph&&this.paragraph.delete(),this.paragraph=this.builder.build();const z=this.preferredMaxLayoutWidth??m2c2Globals.canvasCssWidth;let G=z;if(z===0||this.layout.width===0){if(this.parent===void 0)throw new C("width is set to match parent, but node has no parent");const q=this.layout.marginStart??0,st=this.layout.marginEnd??0;G=this.parent.size.width-(q+st)}this.paragraph.layout(G*m2c2Globals.canvasScale),z===0||this.layout.width===0?this.size.width=G:(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}parseFormattedText(t){let i="";const r=[],h=[],c=new Set([Jt.UNDERLINE,Jt.BOLD,Jt.ITALIC,Jt.STRIKETHROUGH,Jt.OVERLINE]),S=/<\/?([^>]+)>/g;let x=0,z=0,G=null;const q=rt=>{let Et=1,Wt=1;for(let Bt=0;Bt<rt;Bt++)t[Bt]===`
2
- `?(Et++,Wt=1):Wt++;return`line ${Et}, column ${Wt}`};for(;(G=S.exec(t))!==null;){const rt=G[0],Et=G[1],Wt=rt.charAt(1)==="/",Bt=q(G.index);if(!c.has(Et)){const U=t.substring(x,G.index);i+=U,z+=U.length,i+=rt,z+=rt.length,x=G.index+rt.length;continue}const se=t.substring(x,G.index);if(i+=se,z+=se.length,Wt){if(h.length===0)throw new C(`Label has closing tag </${Et}> at ${Bt} without matching opening tag. Text is: ${t}`);const U=h.pop();if(U!==Et)throw new C(`Label has improperly nested tags at ${Bt}. Expected </${U}> but found </${Et}>. Tags must be properly nested. Text is: ${t}`);r.push({position:z,style:Et,isStart:!1})}else h.push(Et),r.push({position:z,style:Et,isStart:!0});x=G.index+rt.length}if(i+=t.substring(x),h.length>0)throw new C(`Label has unclosed format tags: <${h.join(">, <")}>. All tags must be closed. Text is: ${t}`);const st=new Set,lt=[];let yt=0;r.sort((rt,Et)=>rt.position-Et.position);for(const rt of r)rt.position>yt&&st.size>0&&lt.push({start:yt,end:rt.position,styles:new Set(st)}),rt.isStart?st.add(rt.style):st.delete(rt.style),yt=rt.position;return{plainText:i,styleSegments:lt}}addStyleSegmentsToParagraphBuilder(t,i,r){if(i.length===0)t.addText(this.plainText);else{let h=0;for(const c of i){c.start>h&&this.addTextWithStyle(t,this.plainText.substring(h,c.start),r);const S={};if(c.styles.has(Jt.BOLD)&&(S.fontStyle={...S.fontStyle||r.fontStyle,weight:this.canvasKit.FontWeight.Black}),c.styles.has(Jt.ITALIC)&&(S.fontStyle={...S.fontStyle||r.fontStyle,slant:this.canvasKit.FontSlant.Italic}),c.styles.has(Jt.UNDERLINE)&&(S.decoration=this.canvasKit.UnderlineDecoration,S.decorationThickness=1,S.decorationStyle=this.canvasKit.DecorationStyle.Solid,S.decorationColor=this.fontColor),c.styles.has(Jt.STRIKETHROUGH)&&(S.decoration=this.canvasKit.LineThroughDecoration,S.decorationThickness=1,S.decorationStyle=this.canvasKit.DecorationStyle.Solid,S.decorationColor=this.fontColor),c.styles.has(Jt.OVERLINE)&&(S.decoration=this.canvasKit.OverlineDecoration,S.decorationThickness=1,S.decorationStyle=this.canvasKit.DecorationStyle.Solid,S.decorationColor=this.fontColor),[Jt.UNDERLINE,Jt.STRIKETHROUGH,Jt.OVERLINE].filter(z=>c.styles.has(z)).length>1)throw new C(`Label does not support multiple text decorations (underline, overline, or strikethrough) on a single text segment. Text is: ${this.textAfterLocalization}`);this.addTextWithStyle(t,this.plainText.substring(c.start,c.end),r,S),h=c.end}h<this.plainText.length&&this.addTextWithStyle(t,this.plainText.substring(h),r)}}addTextWithStyle(t,i,r,h={}){if(!i)return;const c={...r,...h};t.pushPaintStyle(c,this.fontPaint,this.backgroundPaint),t.addText(i),t.pop()}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(r=>t.fonts[r]),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(r=>t.fonts[r]);else throw new C("cannot determine required fonts");return i}dispose(){Nt.Dispose([this.paragraph,this.builder,this._fontPaint,this._backgroundPaint])}get text(){return this._text}set text(t){K.value(this._text,t)||(this._text=t,this.needsInitialization=!0,this.savePropertyChangeEvent("text",t))}get interpolation(){return this._interpolation}set interpolation(t){K.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){K.value(this._fontName,t)||(this._fontName=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontName",t))}get fontNames(){return this._fontNames}set fontNames(t){K.value(this._fontNames,t)||(this._fontNames=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontNames",t))}get fontColor(){return this._fontColor}set fontColor(t){K.value(this._fontColor,t)||(this._fontColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontColor",t))}get fontSize(){return this._fontSize}set fontSize(t){K.value(this._fontSize,t)||(this._fontSize=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontSize",t))}get horizontalAlignmentMode(){return this._horizontalAlignmentMode}set horizontalAlignmentMode(t){K.value(this._horizontalAlignmentMode,t)||(this._horizontalAlignmentMode=t,this.needsInitialization=!0,this.savePropertyChangeEvent("horizontalAlignmentMode",t))}get preferredMaxLayoutWidth(){return this._preferredMaxLayoutWidth}set preferredMaxLayoutWidth(t){K.value(this._preferredMaxLayoutWidth,t)||(this._preferredMaxLayoutWidth=t,this.needsInitialization=!0,this.savePropertyChangeEvent("preferredMaxLayoutWidth",t))}get backgroundColor(){return this._backgroundColor}set backgroundColor(t){K.value(this._backgroundColor,t)||(this._backgroundColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("backgroundColor",t))}get localize(){return this._localize}set localize(t){K.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){K.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){K.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){K.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){K.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}get backgroundPaint(){if(!this._backgroundPaint)throw new C("backgroundPaint cannot be undefined");return this._backgroundPaint}set backgroundPaint(t){this._backgroundPaint=t}get fontPaint(){if(!this._fontPaint)throw new C("fontPaint cannot be undefined");return this._fontPaint}set fontPaint(t){this._fontPaint=t}duplicate(t){const i=new Ui({...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(r=>{const h=r.duplicate();return h.parent=i,h})),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),V.rotateCanvasForDrawableNode(t,this);const r=(this.absolutePosition.x-this.size.width*this.anchorPoint.x*this.absoluteScale)*i,h=(this.absolutePosition.y-this.size.height*this.anchorPoint.y*this.absoluteScale)*i;if(this.paragraph===void 0)throw new C("no paragraph");t.drawParagraph(this.paragraph,r,h),t.restore()}super.drawChildren(t)}warmup(t){const i=this.game.i18n;if(i&&this.localize!==!1){const h=i.getTextLocalization(this.text,this.interpolation);this.localizedFontName=h.fontName,this.localizedFontNames=h.fontNames??[]}if(!this.getRequiredLabelFonts(this.game.fontManager).some(h=>h.status===re.Deferred)&&Object.keys(this.layout).length===0){if(this.initialize(),!this.paragraph)throw new C(`warmup Label node ${this.toString()}: paragraph is undefined`);t.drawParagraph(this.paragraph,0,0)}}}class Ve extends fe{constructor(t={}){super(t),this.type=dt.Scene,this.isDrawable=!0,this._anchorPoint={x:0,y:0},this._zPosition=0,this._backgroundColor=Q.DEFAULT_SCENE_BACKGROUND_COLOR,this._active=!1,this._transitioning=!1,Le(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=Nt.makePaint(this.canvasKit,this.backgroundColor,this.canvasKit.PaintStyle.Fill,!1),this.needsInitialization=!1}dispose(){Nt.Dispose([this.backgroundPaint])}set game(t){this._game=t}get game(){if(this._game===void 0)throw new C(`Scene ${this} has not been added to a game.`);return this._game}get backgroundColor(){return this._backgroundColor}set backgroundColor(t){K.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){K.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){K.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){K.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){K.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}duplicate(t){const i=new Ve({...this.getNodeOptions(),...this.getDrawableOptions(),backgroundColor:this.backgroundColor,name:t});return i.game=this.game,this.children.length>0&&(i.children=this.children.map(r=>{const h=r.duplicate();return h.parent=i,h})),i}onSetup(t,i){this.addEventListener("SceneSetup",t,i)}onAppear(t,i){this.addEventListener("SceneAppear",t,i)}onKeyDown(t,i){this.addEventListener(H.KeyDown,t,i)}onKeyUp(t,i){this.addEventListener(H.KeyUp,t,i)}update(){super.update()}draw(t){t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;if(t.scale(1/i,1/i),V.rotateCanvasForDrawableNode(t,this),!this.backgroundPaint)throw new C(`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 C(`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(r=>{r.isDrawable&&r.warmup(t)})}}class fi extends fe{constructor(t={}){if(super(t),this.type=dt.Shape,this.isDrawable=!0,this.isShape=!0,this._anchorPoint={x:.5,y:.5},this._zPosition=0,this.shapeType=Kt.Undefined,this.ckPath=null,this._cornerRadius=0,this._fillColor=Q.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,Le(this,t),t.path!==void 0){if(this.path=t.path,this.shapeType=Kt.Path,this.shapeIsM2Path()&&t.size!==void 0&&(this.size=t.size),this.shapeIsSvgStringPath()&&t.size!==void 0)throw new C("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 C("Cannot specify both width and height for SVG string path.");if(this.strokeColor||(this.strokeColor=Q.DEFAULT_PATH_STROKE_COLOR),this.lineWidth===void 0&&(this.lineWidth=Q.DEFAULT_PATH_LINE_WIDTH),t.circleOfRadius||t.rect)throw new C("Shape must specify only one of: path, circleOfRadius, or rect")}if(t.circleOfRadius!==void 0){if(this.circleOfRadius=t.circleOfRadius,this.shapeType=Kt.Circle,t.size!==void 0)throw new C("Size cannot be specified for circle shape");if(t.path||t.rect)throw new C("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=Kt.Rectangle,t.size!==void 0))throw new C("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===Kt.Path&&this.shapeIsSvgStringPath()){const t=this.path.pathString??this.path.svgPathString;if(!t)throw new C("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 C("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 C("Size of shape must have non-zero height and width when path is M2Path");this.fillColor&&(this.fillColorPaintAntialiased=Nt.makePaint(this.canvasKit,this.fillColor,this.canvasKit.PaintStyle.Fill,!0),this.fillColorPaintNotAntialiased=Nt.makePaint(this.canvasKit,this.fillColor,this.canvasKit.PaintStyle.Fill,!1)),this.strokeColor&&(this.strokeColorPaintAntialiased=Nt.makePaint(this.canvasKit,this.strokeColor,this.canvasKit.PaintStyle.Stroke,!0),this.strokeColorPaintNotAntialiased=Nt.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){K.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){K.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){K.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){K.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}dispose(){Nt.Dispose([this._strokeColorPaintAntialiased,this._strokeColorPaintNotAntialiased,this._fillColorPaintAntialiased,this._fillColorPaintNotAntialiased,this.ckPath,...Array.from(this.colorfulPathPaints.values())])}duplicate(t){const i=new fi({...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(r=>{const h=r.duplicate();return h.parent=i,h})),i}update(){super.update()}draw(t){t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;t.scale(1/i,1/i),V.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===Kt.Circle&&this.drawCircle(t),this.shapeType===Kt.Rectangle&&this.drawRectangle(t),t.restore(),super.drawChildren(t)}applyAlphaToPaints(t,i){i.forEach(r=>{r&&r.setAlphaf(t)})}drawPathFromM2Path(t){const i=m2c2Globals.canvasScale/this.absoluteScale,r=(this.absolutePosition.x-this.anchorPoint.x*this.size.width*this.absoluteScale)*i,h=(this.absolutePosition.y-this.anchorPoint.y*this.size.height*this.absoluteScale)*i;if(this.pathIsM2ColorfulPath(this.path)){const c=this.path.linePresentations;let S=0;const x=this.path.subpaths;let z;for(let G=0;G<x.length;G++){const st=x[G].flat();for(let lt=0;lt<st.length-1;lt++){if(c[S].subpathIndex===G&&c[S].pointIndex===lt){const yt=c[S].strokeColor,rt=c[S].lineWidth,Et=[...yt,rt].toString();z=this.colorfulPathPaints.get(Et),z===void 0&&(z=Nt.makePaint(this.canvasKit,yt,this.canvasKit.PaintStyle.Stroke,!0),z.setStrokeWidth(rt*m2c2Globals.canvasScale),this.colorfulPathPaints.set(Et,z)),S<c.length-1&&S++}if(z===void 0)throw new C("paint is undefined");t.drawLine(r+st[lt].x*m2c2Globals.canvasScale,h+st[lt].y*m2c2Globals.canvasScale,r+st[lt+1].x*m2c2Globals.canvasScale,h+st[lt+1].y*m2c2Globals.canvasScale,z)}}return}if(this.strokeColor&&this.strokeColorPaintAntialiased&&this.lineWidth){this.strokeColorPaintAntialiased.setStrokeWidth(this.lineWidth*m2c2Globals.canvasScale);const c=this.path.subpaths;for(const S of c){const x=S.flat();for(let z=0;z<x.length-1;z++)t.drawLine(r+x[z].x*m2c2Globals.canvasScale,h+x[z].y*m2c2Globals.canvasScale,r+x[z+1].x*m2c2Globals.canvasScale,h+x[z+1].y*m2c2Globals.canvasScale,this.strokeColorPaintAntialiased)}}}drawPathFromSvgString(t){if(!this.ckPath)return;const i=this.calculateSvgPathX(),r=this.calculateSvgPathY();if(this.pathNeedsTransform(i,r)){const c=m2c2Globals.canvasScale/this.absoluteScale*this.svgPathScaleForResizing*m2c2Globals.rootScale,S=this.calculateTransformationMatrix(c,i,r);this.ckPath=this.ckPath.transform(S),this.saveSvgPathAbsolutePosition(i,r)}if(this.fillColor){const h=this.getFillPaint();t.drawPath(this.ckPath,h)}if(this.strokeColor&&this.lineWidth){const h=this.getStrokePaint(this.lineWidth);t.drawPath(this.ckPath,h)}}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,r){let h;this.svgFirstPathDraw?(h=t,this.svgFirstPathDraw=!1):h=1;const c=i-this.svgPreviousAbsoluteX,S=r-this.svgPreviousAbsoluteY;return[h,0,c,0,h,S,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 r=m2c2Globals.canvasScale/this.absoluteScale,h=this.absolutePosition.x*r,c=this.absolutePosition.y*r,S=this.circleOfRadius*this.absoluteScale*r;t.drawCircle(h,c,S,i)}drawRectangleWithCanvasKit(t,i){const r=this.calculateCKRoundedRectangle();t.drawRRect(r,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 r=m2c2Globals.canvasScale/this.absoluteScale;return i.setStrokeWidth(t*r),i}warmup(t){this.initialize(),t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;t.scale(1/i,1/i),this.shapeType===Kt.Circle&&(this.fillColor&&this.warmupFilledCircle(t),this.strokeColor&&this.lineWidth&&this.warmupStrokedCircle(t)),this.shapeType===Kt.Rectangle&&(this.fillColor&&this.warmupFilledRectangle(t),this.strokeColor&&this.lineWidth&&this.warmupStrokedRectangle(t)),t.restore(),this.children.forEach(r=>{r.isDrawable&&r.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){K.value(t,this._circleOfRadius)||(this._circleOfRadius=t,this.needsInitialization=!0,this.savePropertyChangeEvent("circleOfRadius",t))}get rect(){return this._rect}set rect(t){K.value(t,this._rect)||(this._rect=t,this.needsInitialization=!0,this.savePropertyChangeEvent("rect",t))}get cornerRadius(){return this._cornerRadius}set cornerRadius(t){K.value(t,this._cornerRadius)||(this._cornerRadius=t??0,this.needsInitialization=!0,this.savePropertyChangeEvent("cornerRadius",t??0))}get lineWidth(){return this._lineWidth}set lineWidth(t){K.value(t,this._lineWidth)||(this._lineWidth=t,this.needsInitialization=!0,this.savePropertyChangeEvent("lineWidth",t))}get path(){return this._path}set path(t){K.value(t,this._path)||(this._path=t,this.needsInitialization=!0,this.savePropertyChangeEvent("path",t))}get fillColor(){return this._fillColor}set fillColor(t){K.value(t,this._fillColor)||(this._fillColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fillColor",t))}get strokeColor(){return this._strokeColor}set strokeColor(t){K.value(t,this._strokeColor)||(this._strokeColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("strokeColor",t))}get isAntialiased(){return this._isAntialiased}set isAntialiased(t){K.value(t,this._isAntialiased)||(this._isAntialiased=t,this.needsInitialization=!0,this.savePropertyChangeEvent("isAntialiased",t))}get fillColorPaintAntialiased(){if(!this._fillColorPaintAntialiased)throw new C("fillColorPaintAntiAliased is undefined");return this._fillColorPaintAntialiased}set fillColorPaintAntialiased(t){this._fillColorPaintAntialiased=t}get strokeColorPaintAntialiased(){if(!this._strokeColorPaintAntialiased)throw new C("strokeColorPaintAntiAliased is undefined");return this._strokeColorPaintAntialiased}set strokeColorPaintAntialiased(t){this._strokeColorPaintAntialiased=t}get fillColorPaintNotAntialiased(){if(!this._fillColorPaintNotAntialiased)throw new C("fillColorPaintNotAntiAliased is undefined");return this._fillColorPaintNotAntialiased}set fillColorPaintNotAntialiased(t){this._fillColorPaintNotAntialiased=t}get strokeColorPaintNotAntialiased(){if(!this._strokeColorPaintNotAntialiased)throw new C("strokeColorPaintNotAntiAliased is undefined");return this._strokeColorPaintNotAntialiased}set strokeColorPaintNotAntialiased(t){this._strokeColorPaintNotAntialiased=t}}class $i extends fe{constructor(t={}){super(t),this.type=dt.TextLine,this.isDrawable=!0,this.isText=!0,this._zPosition=0,this._anchorPoint={x:0,y:.5},this._text="",this._fontColor=Q.DEFAULT_FONT_COLOR,this._fontSize=Q.DEFAULT_FONT_SIZE,this._interpolation={},this._localize=!0,this.typeface=null,this.tryMissingTranslationPaint=!1,this.textForDraw="",this.localizedFontNames=[],Le(this,t),this.size.height=this.localizedFontSize??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 r=t.getTextLocalization(this.text,this.interpolation);this.textForDraw=r.text,this.localizedFontSize=r.fontSize,this.localizedFontName=r.fontName,this.localizedFontNames=r.fontNames??[],r.isFallbackOrMissingTranslation&&(this.tryMissingTranslationPaint=!0)}else this.textForDraw=this.text;const i=this.game.fontManager;if(this.fontForDraw=this.getRequiredTextLineFont(i),this.fontForDraw.status===re.Deferred){i.prepareDeferredFont(this.fontForDraw);return}this.fontForDraw.status!==re.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 C("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.localizedFontSize??this.fontSize)*m2c2Globals.canvasScale)}get text(){return this._text}set text(t){K.value(this._text,t)||(this._text=t,this.needsInitialization=!0,this.savePropertyChangeEvent("text",t))}get fontName(){return this._fontName}set fontName(t){K.value(this._fontName,t)||(this._fontName=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontName",t))}get fontColor(){return this._fontColor}set fontColor(t){K.value(this._fontColor,t)||(this._fontColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontColor",t))}get fontSize(){return this._fontSize}set fontSize(t){K.value(this._fontSize,t)||(this._fontSize=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontSize",t))}get interpolation(){return this._interpolation}set interpolation(t){K.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){K.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){K.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){K.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){K.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){K.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}dispose(){Nt.Dispose([this.font,this.typeface,this.paint])}duplicate(t){const i=new $i({...this.getNodeOptions(),...this.getDrawableOptions(),...this.getTextOptions(),width:this.size.width,name:t});return this.children.length>0&&(i.children=this.children.map(r=>{const h=r.duplicate();return h.parent=i,h})),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),V.rotateCanvasForDrawableNode(t,this);const r=this.absolutePosition.x*i,h=(this.absolutePosition.y+this.size.height*this.anchorPoint.y*this.absoluteScale)*i;if(this.paint===void 0||this.font===void 0)throw new C(`in TextLine node ${this}, Paint or Font is undefined.`);this.absoluteAlphaChange!==0&&this.paint.setAlphaf(this.absoluteAlpha),t.drawText(this.textForDraw,r,h,this.paint,this.font),t.restore()}super.drawChildren(t)}warmup(t){const i=this.game.i18n;if(i&&this.localize!==!1){const h=i.getTextLocalization(this.text,this.interpolation);this.localizedFontName=h.fontName,this.localizedFontNames=h.fontNames??[]}if(this.getRequiredTextLineFont(this.game.fontManager).status!==re.Deferred){if(this.initialize(),this.paint===void 0||this.font===void 0)throw new C(`warmup TextLine node ${this.toString()}: Paint or Font is undefined.`);t.drawText(this.text,0,0,this.paint,this.font)}}}class pi extends fe{constructor(t={}){super(t),this.type=dt.Sprite,this.isDrawable=!0,this._anchorPoint={x:.5,y:.5},this._zPosition=0,this._imageName="",Le(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 C(`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(){Nt.Dispose([this.m2Image?.canvaskitImage,this._paint])}get imageName(){return this._imageName}set imageName(t){K.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){K.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){K.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){K.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){K.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}set paint(t){this._paint=t}get paint(){if(!this._paint)throw new C(`in paint getter: Sprite node ${this.toString()} paint is undefined.`);return this._paint}duplicate(t){const i=new pi({...this.getNodeOptions(),...this.getDrawableOptions(),imageName:this.imageName,name:t});return this.children.length>0&&(i.children=this.children.map(r=>{const h=r.duplicate();return h.parent=i,h})),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),V.rotateCanvasForDrawableNode(t,this);const r=(this.absolutePosition.x-this.size.width*this.anchorPoint.x*this.absoluteScale)*i,h=(this.absolutePosition.y-this.size.height*this.anchorPoint.y*this.absoluteScale)*i;if(this.absoluteAlphaChange!==0&&this.paint.setAlphaf(this.absoluteAlpha),this.m2Image.status===ne.Ready&&this.m2Image.canvaskitImage)this.m2Image.isFallback&&this.drawFallbackImageBorder(t),t.drawImage(this.m2Image.canvaskitImage,r,h,this.paint);else if(this.m2Image.status===ne.Deferred&&(console.log(`begin loading lazy image ${this.m2Image.imageName} for Sprite node ${this.toString()}`),this.game.imageManager.prepareDeferredImage(this.m2Image)),this.m2Image.status===ne.Error)throw new C(`error status on image ${this.m2Image.imageName} for Sprite node ${this.toString()}`);t.restore()}super.drawChildren(t)}}warmup(t){if(this.m2Image?.status===ne.Ready){if(this.initialize(),!this.m2Image)throw new C(`in Sprite.warmup(): Sprite node ${this.toString()}: image not loaded.`);if(!this.m2Image.canvaskitImage)throw new C(`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 r=m2c2Globals.canvasScale/this.absoluteScale,h=this.canvasKit.RRectXY(this.canvasKit.LTRBRect((this.absolutePosition.x-this.anchorPoint.x*this.size.width*this.absoluteScale)*r,(this.absolutePosition.y-this.anchorPoint.y*this.size.height*this.absoluteScale)*r,(this.absolutePosition.x+this.size.width*this.absoluteScale-this.anchorPoint.x*this.size.width*this.absoluteScale)*r,(this.absolutePosition.y+this.size.height*this.absoluteScale-this.anchorPoint.y*this.size.height*this.absoluteScale)*r),0,0);t.drawRRect(h,i)}}class Gr{constructor(){V.registerM2NodeClass(Ui,fi,pi,Ve,$i)}createNode(t,i,r){const h=i||t;if(!this.hasClassRegistration(h))throw new C(`Unknown node type: ${h}`);if(!m2c2Globals.m2NodeClassRegistry)throw new C("Node class registry is not initialized.");const c=m2c2Globals.m2NodeClassRegistry[h];return new c(r)}hasClassRegistration(t){return Object.keys(m2c2Globals.m2NodeClassRegistry??{}).includes(t)}}class pa{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 Wr{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((r,h)=>{let c=r.url;V.urlHasScheme(r.url)||(c=V.getUrlFromManifest(this.game,`${this.baseUrls.assets}/${r.url}`));const S={fontName:r.fontName,typeface:void 0,data:r.sharedFont?.data,default:h===0,url:r.sharedFont?.url??c,status:r.lazy?re.Deferred:re.Loading};if(this.fonts[r.fontName]=S,S.status===re.Loading)return this.prepareFont(S)});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=re.Loading,this.prepareFont(t)}async fetchFontAsArrayBuffer(t){const i=await fetch(t.url);if(!i.ok)throw new C(`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 r=this.canvasKit.Typeface.MakeFreeTypeFaceFromData(t);if(!r)throw new C(`cannot make typeface for font ${i.fontName} at url ${i.url}`);i.typeface=r,i.status=re.Ready}getFont(t){return this.fonts[t]}getDefaultFont(){const t=Object.values(this.fonts).find(i=>i.default);if(!t)throw new C("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);Nt.Dispose([...t,this.provider])}getTypeface(t){const i=this.fonts[t]?.typeface;if(!i)throw new C(`font ${t} not found`);return i}getFontNames(){return Object.keys(this.fonts)}}var gn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ga(m){return m&&m.__esModule&&Object.prototype.hasOwnProperty.call(m,"default")?m.default:m}function jr(m){if(Object.prototype.hasOwnProperty.call(m,"__esModule"))return m;var t=m.default;if(typeof t=="function"){var i=function r(){return this instanceof r?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(m).forEach(function(r){var h=Object.getOwnPropertyDescriptor(m,r);Object.defineProperty(i,r,h.get?h:{enumerable:!0,get:function(){return m[r]}})}),i}var mn={exports:{}},ma={},ya=Object.freeze({__proto__:null,default:ma}),va=jr(ya);function Hr(m,t){for(var i=0,r=m.length-1;r>=0;r--){var h=m[r];h==="."?m.splice(r,1):h===".."?(m.splice(r,1),i++):i&&(m.splice(r,1),i--)}if(t)for(;i--;i)m.unshift("..");return m}var wa=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,yn=function(m){return wa.exec(m).slice(1)};function Li(){for(var m="",t=!1,i=arguments.length-1;i>=-1&&!t;i--){var r=i>=0?arguments[i]:"/";if(typeof r!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!r)continue;m=r+"/"+m,t=r.charAt(0)==="/"}return m=Hr(Sn(m.split("/"),function(h){return!!h}),!t).join("/"),(t?"/":"")+m||"."}function vn(m){var t=wn(m),i=ba(m,-1)==="/";return m=Hr(Sn(m.split("/"),function(r){return!!r}),!t).join("/"),!m&&!t&&(m="."),m&&i&&(m+="/"),(t?"/":"")+m}function wn(m){return m.charAt(0)==="/"}function Kr(){var m=Array.prototype.slice.call(arguments,0);return vn(Sn(m,function(t,i){if(typeof t!="string")throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))}function Vr(m,t){m=Li(m).substr(1),t=Li(t).substr(1);function i(G){for(var q=0;q<G.length&&G[q]==="";q++);for(var st=G.length-1;st>=0&&G[st]==="";st--);return q>st?[]:G.slice(q,st-q+1)}for(var r=i(m.split("/")),h=i(t.split("/")),c=Math.min(r.length,h.length),S=c,x=0;x<c;x++)if(r[x]!==h[x]){S=x;break}for(var z=[],x=S;x<r.length;x++)z.push("..");return z=z.concat(h.slice(S)),z.join("/")}var qr="/",Yr=":";function Xr(m){var t=yn(m),i=t[0],r=t[1];return!i&&!r?".":(r&&(r=r.substr(0,r.length-1)),i+r)}function Jr(m,t){var i=yn(m)[2];return t&&i.substr(-1*t.length)===t&&(i=i.substr(0,i.length-t.length)),i}function Qr(m){return yn(m)[3]}var Sa={extname:Qr,basename:Jr,dirname:Xr,sep:qr,delimiter:Yr,relative:Vr,join:Kr,isAbsolute:wn,normalize:vn,resolve:Li};function Sn(m,t){if(m.filter)return m.filter(t);for(var i=[],r=0;r<m.length;r++)t(m[r],r,m)&&i.push(m[r]);return i}var ba="ab".substr(-1)==="b"?function(m,t,i){return m.substr(t,i)}:function(m,t,i){return t<0&&(t=m.length+t),m.substr(t,i)},Pa=Object.freeze({__proto__:null,basename:Jr,default:Sa,delimiter:Yr,dirname:Xr,extname:Qr,isAbsolute:wn,join:Kr,normalize:vn,relative:Vr,resolve:Li,sep:qr}),Aa=jr(Pa),Zr;function Ca(){return Zr||(Zr=1,function(m,t){var i=(()=>{var r=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<"u"&&(r=r||__filename),function(h={}){var c=h,S,x;c.ready=new Promise((e,n)=>{S=e,x=n}),function(e){e.ke=e.ke||[],e.ke.push(function(){e.MakeSWCanvasSurface=function(n){var s=n,l=typeof OffscreenCanvas<"u"&&s instanceof OffscreenCanvas;if(!(typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||l||(s=document.getElementById(n),s)))throw"Canvas with id "+n+" was not found";return(n=e.MakeSurface(s.width,s.height))&&(n.ce=s),n},e.MakeCanvasSurface||(e.MakeCanvasSurface=e.MakeSWCanvasSurface),e.MakeSurface=function(n,s){var l={width:n,height:s,colorType:e.ColorType.RGBA_8888,alphaType:e.AlphaType.Unpremul,colorSpace:e.ColorSpace.SRGB},d=n*s*4,g=e._malloc(d);return(l=e.Surface._makeRasterDirect(l,g,4*n))&&(l.ce=null,l.Xf=n,l.Tf=s,l.Vf=d,l.wf=g,l.getCanvas().clear(e.TRANSPARENT)),l},e.MakeRasterDirectSurface=function(n,s,l){return e.Surface._makeRasterDirect(n,s.byteOffset,l)},e.Surface.prototype.flush=function(n){if(e.de(this.be),this._flush(),this.ce){var s=new Uint8ClampedArray(e.HEAPU8.buffer,this.wf,this.Vf);s=new ImageData(s,this.Xf,this.Tf),n?this.ce.getContext("2d").putImageData(s,0,0,n[0],n[1],n[2]-n[0],n[3]-n[1]):this.ce.getContext("2d").putImageData(s,0,0)}},e.Surface.prototype.dispose=function(){this.wf&&e._free(this.wf),this.delete()},e.de=e.de||function(){},e.mf=e.mf||function(){return null}})}(c),function(e){e.ke=e.ke||[],e.ke.push(function(){function n(y,v,T){return y&&y.hasOwnProperty(v)?y[v]:T}function s(y){var v=Ne(ee);return ee[v]=y,v}function l(y){return y.naturalHeight||y.videoHeight||y.displayHeight||y.height}function d(y){return y.naturalWidth||y.videoWidth||y.displayWidth||y.width}function g(y,v,T,O){return y.bindTexture(y.TEXTURE_2D,v),O||T.alphaType!==e.AlphaType.Premul||y.pixelStorei(y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),v}function A(y,v,T){T||v.alphaType!==e.AlphaType.Premul||y.pixelStorei(y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),y.bindTexture(y.TEXTURE_2D,null)}e.GetWebGLContext=function(y,v){if(!y)throw"null canvas passed into makeWebGLContext";var T={alpha:n(v,"alpha",1),depth:n(v,"depth",1),stencil:n(v,"stencil",8),antialias:n(v,"antialias",0),premultipliedAlpha:n(v,"premultipliedAlpha",1),preserveDrawingBuffer:n(v,"preserveDrawingBuffer",0),preferLowPowerToHighPerformance:n(v,"preferLowPowerToHighPerformance",0),failIfMajorPerformanceCaveat:n(v,"failIfMajorPerformanceCaveat",0),enableExtensionsByDefault:n(v,"enableExtensionsByDefault",1),explicitSwapControl:n(v,"explicitSwapControl",0),renderViaOffscreenBackBuffer:n(v,"renderViaOffscreenBackBuffer",0)};if(T.majorVersion=v&&v.majorVersion?v.majorVersion:typeof WebGL2RenderingContext<"u"?2:1,T.explicitSwapControl)throw"explicitSwapControl is not supported";return y=Is(y,T),y?(tr(y),at.xe.getExtension("WEBGL_debug_renderer_info"),y):0},e.deleteContext=function(y){at===ye[y]&&(at=null),typeof JSEvents=="object"&&JSEvents.Mg(ye[y].xe.canvas),ye[y]&&ye[y].xe.canvas&&(ye[y].xe.canvas.Rf=void 0),ye[y]=null},e._setTextureCleanup({deleteTexture:function(y,v){var T=ee[v];T&&ye[y].xe.deleteTexture(T),ee[v]=null}}),e.MakeWebGLContext=function(y){if(!this.de(y))return null;var v=this._MakeGrContext();if(!v)return null;v.be=y;var T=v.delete.bind(v);return v.delete=function(){e.de(this.be),T()}.bind(v),at.Af=v},e.MakeGrContext=e.MakeWebGLContext,e.GrDirectContext.prototype.getResourceCacheLimitBytes=function(){e.de(this.be),this._getResourceCacheLimitBytes()},e.GrDirectContext.prototype.getResourceCacheUsageBytes=function(){e.de(this.be),this._getResourceCacheUsageBytes()},e.GrDirectContext.prototype.releaseResourcesAndAbandonContext=function(){e.de(this.be),this._releaseResourcesAndAbandonContext()},e.GrDirectContext.prototype.setResourceCacheLimitBytes=function(y){e.de(this.be),this._setResourceCacheLimitBytes(y)},e.MakeOnScreenGLSurface=function(y,v,T,O,L,Y){return!this.de(y.be)||(v=L===void 0||Y===void 0?this._MakeOnScreenGLSurface(y,v,T,O):this._MakeOnScreenGLSurface(y,v,T,O,L,Y),!v)?null:(v.be=y.be,v)},e.MakeRenderTarget=function(){var y=arguments[0];if(!this.de(y.be))return null;if(arguments.length===3){var v=this._MakeRenderTargetWH(y,arguments[1],arguments[2]);if(!v)return null}else if(arguments.length===2){if(v=this._MakeRenderTargetII(y,arguments[1]),!v)return null}else return null;return v.be=y.be,v},e.MakeWebGLCanvasSurface=function(y,v,T){v=v||null;var O=y,L=typeof OffscreenCanvas<"u"&&O instanceof OffscreenCanvas;if(!(typeof HTMLCanvasElement<"u"&&O instanceof HTMLCanvasElement||L||(O=document.getElementById(y),O)))throw"Canvas with id "+y+" was not found";if(y=this.GetWebGLContext(O,T),!y||0>y)throw"failed to create webgl context: err "+y;return y=this.MakeWebGLContext(y),v=this.MakeOnScreenGLSurface(y,O.width,O.height,v),v||(v=O.cloneNode(!0),O.parentNode.replaceChild(v,O),v.classList.add("ck-replaced"),e.MakeSWCanvasSurface(v))},e.MakeCanvasSurface=e.MakeWebGLCanvasSurface,e.Surface.prototype.makeImageFromTexture=function(y,v){return e.de(this.be),y=s(y),(v=this._makeImageFromTexture(this.be,y,v))&&(v.cf=y),v},e.Surface.prototype.makeImageFromTextureSource=function(y,v,T){v||(v={height:l(y),width:d(y),colorType:e.ColorType.RGBA_8888,alphaType:T?e.AlphaType.Premul:e.AlphaType.Unpremul}),v.colorSpace||(v.colorSpace=e.ColorSpace.SRGB),e.de(this.be);var O=at.xe;return T=g(O,O.createTexture(),v,T),at.version===2?O.texImage2D(O.TEXTURE_2D,0,O.RGBA,v.width,v.height,0,O.RGBA,O.UNSIGNED_BYTE,y):O.texImage2D(O.TEXTURE_2D,0,O.RGBA,O.RGBA,O.UNSIGNED_BYTE,y),A(O,v),this._resetContext(),this.makeImageFromTexture(T,v)},e.Surface.prototype.updateTextureFromSource=function(y,v,T){if(y.cf){e.de(this.be);var O=y.getImageInfo(),L=at.xe,Y=g(L,ee[y.cf],O,T);at.version===2?L.texImage2D(L.TEXTURE_2D,0,L.RGBA,d(v),l(v),0,L.RGBA,L.UNSIGNED_BYTE,v):L.texImage2D(L.TEXTURE_2D,0,L.RGBA,L.RGBA,L.UNSIGNED_BYTE,v),A(L,O,T),this._resetContext(),ee[y.cf]=null,y.cf=s(Y),O.colorSpace=y.getColorSpace(),v=this._makeImageFromTexture(this.be,y.cf,O),T=y.ae.ie,L=y.ae.pe,y.ae.ie=v.ae.ie,y.ae.pe=v.ae.pe,v.ae.ie=T,v.ae.pe=L,v.delete(),O.colorSpace.delete()}},e.MakeLazyImageFromTextureSource=function(y,v,T){v||(v={height:l(y),width:d(y),colorType:e.ColorType.RGBA_8888,alphaType:T?e.AlphaType.Premul:e.AlphaType.Unpremul}),v.colorSpace||(v.colorSpace=e.ColorSpace.SRGB);var O={makeTexture:function(){var L=at,Y=L.xe,F=g(Y,Y.createTexture(),v,T);return L.version===2?Y.texImage2D(Y.TEXTURE_2D,0,Y.RGBA,v.width,v.height,0,Y.RGBA,Y.UNSIGNED_BYTE,y):Y.texImage2D(Y.TEXTURE_2D,0,Y.RGBA,Y.RGBA,Y.UNSIGNED_BYTE,y),A(Y,v,T),s(F)},freeSrc:function(){}};return y.constructor.name==="VideoFrame"&&(O.freeSrc=function(){y.close()}),e.Image._makeFromGenerator(v,O)},e.de=function(y){return y?tr(y):!1},e.mf=function(){return at&&at.Af&&!at.Af.isDeleted()?at.Af:null}})}(c),function(e){function n(o,a,u,p,P){for(var E=0;E<o.length;E++)a[E*u+(E*P+p+u)%u]=o[E];return a}function s(o){for(var a=o*o,u=Array(a);a--;)u[a]=a%(o+1)===0?1:0;return u}function l(o){return o?o.constructor===Float32Array&&o.length===4:!1}function d(o){return(y(255*o[3])<<24|y(255*o[0])<<16|y(255*o[1])<<8|y(255*o[2])<<0)>>>0}function g(o){if(o&&o._ck)return o;if(o instanceof Float32Array){for(var a=Math.floor(o.length/4),u=new Uint32Array(a),p=0;p<a;p++)u[p]=d(o.slice(4*p,4*(p+1)));return u}if(o instanceof Uint32Array)return o;if(o instanceof Array&&o[0]instanceof Float32Array)return o.map(d)}function A(o){if(o===void 0)return 1;var a=parseFloat(o);return o&&o.indexOf("%")!==-1?a/100:a}function y(o){return Math.round(Math.max(0,Math.min(o||0,255)))}function v(o,a){a&&a._ck||e._free(o)}function T(o,a,u){if(!o||!o.length)return gt;if(o&&o._ck)return o.byteOffset;var p=e[a].BYTES_PER_ELEMENT;return u||(u=e._malloc(o.length*p)),e[a].set(o,u/p),u}function O(o){var a={te:gt,count:o.length,colorType:e.ColorType.RGBA_F32};if(o instanceof Float32Array)a.te=T(o,"HEAPF32"),a.count=o.length/4;else if(o instanceof Uint32Array)a.te=T(o,"HEAPU32"),a.colorType=e.ColorType.RGBA_8888;else if(o instanceof Array){if(o&&o.length){for(var u=e._malloc(16*o.length),p=0,P=u/4,E=0;E<o.length;E++)for(var N=0;4>N;N++)e.HEAPF32[P+p]=o[E][N],p++;o=u}else o=gt;a.te=o}else throw"Invalid argument to copyFlexibleColorArray, Not a color array "+typeof o;return a}function L(o){if(!o)return gt;var a=rn.toTypedArray();if(o.length){if(o.length===6||o.length===9)return T(o,"HEAPF32",_e),o.length===6&&e.HEAPF32.set(aa,6+_e/4),_e;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],_e;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,_e}function Y(o){if(!o)return gt;var a=sn.toTypedArray();if(o.length){if(o.length!==16&&o.length!==6&&o.length!==9)throw"invalid matrix size";return o.length===16?T(o,"HEAPF32",We):(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),We)}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,We}function F(o,a){return T(o,"HEAPF32",a||Oe)}function J(o,a,u,p){var P=an.toTypedArray();return P[0]=o,P[1]=a,P[2]=u,P[3]=p,Oe}function ht(o){for(var a=new Float32Array(4),u=0;4>u;u++)a[u]=e.HEAPF32[o/4+u];return a}function ot(o,a){return T(o,"HEAPF32",a||Rt)}function Ht(o,a){return T(o,"HEAPF32",a||hn)}function Lt(){for(var o=0,a=0;a<arguments.length-1;a+=2)o+=arguments[a]*arguments[a+1];return o}function ai(o,a,u){for(var p=Array(o.length),P=0;P<u;P++)for(var E=0;E<u;E++){for(var N=0,j=0;j<u;j++)N+=o[u*P+j]*a[u*j+E];p[P*u+E]=N}return p}function oi(o,a){for(var u=ai(a[0],a[1],o),p=2;p<a.length;)u=ai(u,a[p],o),p++;return u}e.Color=function(o,a,u,p){return p===void 0&&(p=1),e.Color4f(y(o)/255,y(a)/255,y(u)/255,p)},e.ColorAsInt=function(o,a,u,p){return p===void 0&&(p=255),(y(p)<<24|y(o)<<16|y(a)<<8|y(u)<<0&268435455)>>>0},e.Color4f=function(o,a,u,p){return p===void 0&&(p=1),Float32Array.of(o,a,u,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 u=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:u=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(u,p,P,a/255)}return o.startsWith("rgba")?(o=o.slice(5,-1),o=o.split(","),e.Color(+o[0],+o[1],+o[2],A(o[3]))):o.startsWith("rgb")?(o=o.slice(4,-1),o=o.split(","),e.Color(+o[0],+o[1],+o[2],A(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 u=e._malloc(a*o.BYTES_PER_ELEMENT);return{_ck:!0,length:a,byteOffset:u,Je:null,subarray:function(p,P){return p=this.toTypedArray().subarray(p,P),p._ck=!0,p},toTypedArray:function(){return this.Je&&this.Je.length?this.Je:(this.Je=new o(e.HEAPU8.buffer,u,a),this.Je._ck=!0,this.Je)}}},e.Free=function(o){e._free(o.byteOffset),o.byteOffset=gt,o.toTypedArray=null,o.Je=null};var _e=gt,rn,We=gt,sn,Oe=gt,an,ue,Rt=gt,Pr,Ee=gt,Ar,on=gt,Cr,ln=gt,Oi,li=gt,Tr,hn=gt,_r,Er=gt,aa=Float32Array.of(0,0,1),gt=0;e.onRuntimeInitialized=function(){function o(a,u,p,P,E,N,j){N||(N=4*P.width,P.colorType===e.ColorType.RGBA_F16?N*=2:P.colorType===e.ColorType.RGBA_F32&&(N*=4));var tt=N*P.height,et=E?E.byteOffset:e._malloc(tt);if(j?!a._readPixels(P,et,N,u,p,j):!a._readPixels(P,et,N,u,p))return E||e._free(et),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,et,tt).slice();break;case e.ColorType.RGBA_F32:a=new Float32Array(e.HEAPU8.buffer,et,tt).slice();break;default:return null}return e._free(et),a}an=e.Malloc(Float32Array,4),Oe=an.byteOffset,sn=e.Malloc(Float32Array,16),We=sn.byteOffset,rn=e.Malloc(Float32Array,9),_e=rn.byteOffset,Tr=e.Malloc(Float32Array,12),hn=Tr.byteOffset,_r=e.Malloc(Float32Array,12),Er=_r.byteOffset,ue=e.Malloc(Float32Array,4),Rt=ue.byteOffset,Pr=e.Malloc(Float32Array,4),Ee=Pr.byteOffset,Ar=e.Malloc(Float32Array,3),on=Ar.byteOffset,Cr=e.Malloc(Float32Array,3),ln=Cr.byteOffset,Oi=e.Malloc(Int32Array,4),li=Oi.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 u=T(a,"HEAPF32"),p=e.Path._MakeFromCmds(u,a.length);return v(u,a),p},e.Path.MakeFromVerbsPointsWeights=function(a,u,p){var P=T(a,"HEAPU8"),E=T(u,"HEAPF32"),N=T(p,"HEAPF32"),j=e.Path._MakeFromVerbsPointsWeights(P,a.length,E,u.length,N,p&&p.length||0);return v(P,a),v(E,u),v(N,p),j},e.Path.prototype.addArc=function(a,u,p){return a=ot(a),this._addArc(a,u,p),this},e.Path.prototype.addCircle=function(a,u,p,P){return this._addCircle(a,u,p,!!P),this},e.Path.prototype.addOval=function(a,u,p){return p===void 0&&(p=1),a=ot(a),this._addOval(a,!!u,p),this},e.Path.prototype.addPath=function(){var a=Array.prototype.slice.call(arguments),u=a[0],p=!1;if(typeof a[a.length-1]=="boolean"&&(p=a.pop()),a.length===1)this._addPath(u,1,0,0,0,1,0,0,0,1,p);else if(a.length===2)a=a[1],this._addPath(u,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(u,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,u){var p=T(a,"HEAPF32");return this._addPoly(p,a.length/2,u),v(p,a),this},e.Path.prototype.addRect=function(a,u){return a=ot(a),this._addRect(a,!!u),this},e.Path.prototype.addRRect=function(a,u){return a=Ht(a),this._addRRect(a,!!u),this},e.Path.prototype.addVerbsPointsWeights=function(a,u,p){var P=T(a,"HEAPU8"),E=T(u,"HEAPF32"),N=T(p,"HEAPF32");this._addVerbsPointsWeights(P,a.length,E,u.length,N,p&&p.length||0),v(P,a),v(E,u),v(N,p)},e.Path.prototype.arc=function(a,u,p,P,E,N){return a=e.LTRBRect(a-p,u-p,a+p,u+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,u,p,P){return a=ot(a),this._arcToOval(a,u,p,P),this},e.Path.prototype.arcToRotated=function(a,u,p,P,E,N,j){return this._arcToRotated(a,u,p,!!P,!!E,N,j),this},e.Path.prototype.arcToTangent=function(a,u,p,P,E){return this._arcToTangent(a,u,p,P,E),this},e.Path.prototype.close=function(){return this._close(),this},e.Path.prototype.conicTo=function(a,u,p,P,E){return this._conicTo(a,u,p,P,E),this},e.Path.prototype.computeTightBounds=function(a){this._computeTightBounds(Rt);var u=ue.toTypedArray();return a?(a.set(u),a):u.slice()},e.Path.prototype.cubicTo=function(a,u,p,P,E,N){return this._cubicTo(a,u,p,P,E,N),this},e.Path.prototype.dash=function(a,u,p){return this._dash(a,u,p)?this:null},e.Path.prototype.getBounds=function(a){this._getBounds(Rt);var u=ue.toTypedArray();return a?(a.set(u),a):u.slice()},e.Path.prototype.lineTo=function(a,u){return this._lineTo(a,u),this},e.Path.prototype.moveTo=function(a,u){return this._moveTo(a,u),this},e.Path.prototype.offset=function(a,u){return this._transform(1,0,a,0,1,u,0,0,1),this},e.Path.prototype.quadTo=function(a,u,p,P){return this._quadTo(a,u,p,P),this},e.Path.prototype.rArcTo=function(a,u,p,P,E,N,j){return this._rArcTo(a,u,p,P,E,N,j),this},e.Path.prototype.rConicTo=function(a,u,p,P,E){return this._rConicTo(a,u,p,P,E),this},e.Path.prototype.rCubicTo=function(a,u,p,P,E,N){return this._rCubicTo(a,u,p,P,E,N),this},e.Path.prototype.rLineTo=function(a,u){return this._rLineTo(a,u),this},e.Path.prototype.rMoveTo=function(a,u){return this._rMoveTo(a,u),this},e.Path.prototype.rQuadTo=function(a,u,p,P){return this._rQuadTo(a,u,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,u,p){return this._trim(a,u,!!p)?this:null},e.Image.prototype.encodeToBytes=function(a,u){var p=e.mf();return a=a||e.ImageFormat.PNG,u=u||100,p?this._encodeToBytes(a,u,p):this._encodeToBytes(a,u)},e.Image.prototype.makeShaderCubic=function(a,u,p,P,E){return E=L(E),this._makeShaderCubic(a,u,p,P,E)},e.Image.prototype.makeShaderOptions=function(a,u,p,P,E){return E=L(E),this._makeShaderOptions(a,u,p,P,E)},e.Image.prototype.readPixels=function(a,u,p,P,E){var N=e.mf();return o(this,a,u,p,P,E,N)},e.Canvas.prototype.clear=function(a){e.de(this.be),a=F(a),this._clear(a)},e.Canvas.prototype.clipRRect=function(a,u,p){e.de(this.be),a=Ht(a),this._clipRRect(a,u,p)},e.Canvas.prototype.clipRect=function(a,u,p){e.de(this.be),a=ot(a),this._clipRect(a,u,p)},e.Canvas.prototype.concat=function(a){e.de(this.be),a=Y(a),this._concat(a)},e.Canvas.prototype.drawArc=function(a,u,p,P,E){e.de(this.be),a=ot(a),this._drawArc(a,u,p,P,E)},e.Canvas.prototype.drawAtlas=function(a,u,p,P,E,N,j){if(a&&P&&u&&p&&u.length===p.length){e.de(this.be),E||(E=e.BlendMode.SrcOver);var tt=T(u,"HEAPF32"),et=T(p,"HEAPF32"),vt=p.length/4,bt=T(g(N),"HEAPU32");if(j&&"B"in j&&"C"in j)this._drawAtlasCubic(a,et,tt,bt,vt,E,j.B,j.C,P);else{let b=e.FilterMode.Linear,I=e.MipmapMode.None;j&&(b=j.filter,"mipmap"in j&&(I=j.mipmap)),this._drawAtlasOptions(a,et,tt,bt,vt,E,b,I,P)}v(tt,u),v(et,p),v(bt,N)}},e.Canvas.prototype.drawCircle=function(a,u,p,P){e.de(this.be),this._drawCircle(a,u,p,P)},e.Canvas.prototype.drawColor=function(a,u){e.de(this.be),a=F(a),u!==void 0?this._drawColor(a,u):this._drawColor(a)},e.Canvas.prototype.drawColorInt=function(a,u){e.de(this.be),this._drawColorInt(a,u||e.BlendMode.SrcOver)},e.Canvas.prototype.drawColorComponents=function(a,u,p,P,E){e.de(this.be),a=J(a,u,p,P),E!==void 0?this._drawColor(a,E):this._drawColor(a)},e.Canvas.prototype.drawDRRect=function(a,u,p){e.de(this.be),a=Ht(a,hn),u=Ht(u,Er),this._drawDRRect(a,u,p)},e.Canvas.prototype.drawImage=function(a,u,p,P){e.de(this.be),this._drawImage(a,u,p,P||null)},e.Canvas.prototype.drawImageCubic=function(a,u,p,P,E,N){e.de(this.be),this._drawImageCubic(a,u,p,P,E,N||null)},e.Canvas.prototype.drawImageOptions=function(a,u,p,P,E,N){e.de(this.be),this._drawImageOptions(a,u,p,P,E,N||null)},e.Canvas.prototype.drawImageNine=function(a,u,p,P,E){e.de(this.be),u=T(u,"HEAP32",li),p=ot(p),this._drawImageNine(a,u,p,P,E||null)},e.Canvas.prototype.drawImageRect=function(a,u,p,P,E){e.de(this.be),ot(u,Rt),ot(p,Ee),this._drawImageRect(a,Rt,Ee,P,!!E)},e.Canvas.prototype.drawImageRectCubic=function(a,u,p,P,E,N){e.de(this.be),ot(u,Rt),ot(p,Ee),this._drawImageRectCubic(a,Rt,Ee,P,E,N||null)},e.Canvas.prototype.drawImageRectOptions=function(a,u,p,P,E,N){e.de(this.be),ot(u,Rt),ot(p,Ee),this._drawImageRectOptions(a,Rt,Ee,P,E,N||null)},e.Canvas.prototype.drawLine=function(a,u,p,P,E){e.de(this.be),this._drawLine(a,u,p,P,E)},e.Canvas.prototype.drawOval=function(a,u){e.de(this.be),a=ot(a),this._drawOval(a,u)},e.Canvas.prototype.drawPaint=function(a){e.de(this.be),this._drawPaint(a)},e.Canvas.prototype.drawParagraph=function(a,u,p){e.de(this.be),this._drawParagraph(a,u,p)},e.Canvas.prototype.drawPatch=function(a,u,p,P,E){if(24>a.length)throw"Need 12 cubic points";if(u&&4>u.length)throw"Need 4 colors";if(p&&8>p.length)throw"Need 4 shader coordinates";e.de(this.be);const N=T(a,"HEAPF32"),j=u?T(g(u),"HEAPU32"):gt,tt=p?T(p,"HEAPF32"):gt;P||(P=e.BlendMode.Modulate),this._drawPatch(N,j,tt,P,E),v(tt,p),v(j,u),v(N,a)},e.Canvas.prototype.drawPath=function(a,u){e.de(this.be),this._drawPath(a,u)},e.Canvas.prototype.drawPicture=function(a){e.de(this.be),this._drawPicture(a)},e.Canvas.prototype.drawPoints=function(a,u,p){e.de(this.be);var P=T(u,"HEAPF32");this._drawPoints(a,P,u.length/2,p),v(P,u)},e.Canvas.prototype.drawRRect=function(a,u){e.de(this.be),a=Ht(a),this._drawRRect(a,u)},e.Canvas.prototype.drawRect=function(a,u){e.de(this.be),a=ot(a),this._drawRect(a,u)},e.Canvas.prototype.drawRect4f=function(a,u,p,P,E){e.de(this.be),this._drawRect4f(a,u,p,P,E)},e.Canvas.prototype.drawShadow=function(a,u,p,P,E,N,j){e.de(this.be);var tt=T(E,"HEAPF32"),et=T(N,"HEAPF32");u=T(u,"HEAPF32",on),p=T(p,"HEAPF32",ln),this._drawShadow(a,u,p,P,tt,et,j),v(tt,E),v(et,N)},e.getShadowLocalBounds=function(a,u,p,P,E,N,j){return a=L(a),p=T(p,"HEAPF32",on),P=T(P,"HEAPF32",ln),this._getShadowLocalBounds(a,u,p,P,E,N,Rt)?(u=ue.toTypedArray(),j?(j.set(u),j):u.slice()):null},e.Canvas.prototype.drawTextBlob=function(a,u,p,P){e.de(this.be),this._drawTextBlob(a,u,p,P)},e.Canvas.prototype.drawVertices=function(a,u,p){e.de(this.be),this._drawVertices(a,u,p)},e.Canvas.prototype.getDeviceClipBounds=function(a){this._getDeviceClipBounds(li);var u=Oi.toTypedArray();return a?a.set(u):a=u.slice(),a},e.Canvas.prototype.quickReject=function(a){return a=ot(a),this._quickReject(a)},e.Canvas.prototype.getLocalToDevice=function(){this._getLocalToDevice(We);for(var a=We,u=Array(16),p=0;16>p;p++)u[p]=e.HEAPF32[a/4+p];return u},e.Canvas.prototype.getTotalMatrix=function(){this._getTotalMatrix(_e);for(var a=Array(9),u=0;9>u;u++)a[u]=e.HEAPF32[_e/4+u];return a},e.Canvas.prototype.makeSurface=function(a){return a=this._makeSurface(a),a.be=this.be,a},e.Canvas.prototype.readPixels=function(a,u,p,P,E){return e.de(this.be),o(this,a,u,p,P,E)},e.Canvas.prototype.saveLayer=function(a,u,p,P,E){return u=ot(u),this._saveLayer(a||null,u,p||null,P||0,E||e.TileMode.Clamp)},e.Canvas.prototype.writePixels=function(a,u,p,P,E,N,j,tt){if(a.byteLength%(u*p))throw"pixels length must be a multiple of the srcWidth * srcHeight";e.de(this.be);var et=a.byteLength/(u*p);N=N||e.AlphaType.Unpremul,j=j||e.ColorType.RGBA_8888,tt=tt||e.ColorSpace.SRGB;var vt=et*u;return et=T(a,"HEAPU8"),u=this._writePixels({width:u,height:p,colorType:j,alphaType:N,colorSpace:tt},et,vt,P,E),v(et,a),u},e.ColorFilter.MakeBlend=function(a,u,p){return a=F(a),p=p||e.ColorSpace.SRGB,e.ColorFilter._MakeBlend(a,u,p)},e.ColorFilter.MakeMatrix=function(a){if(!a||a.length!==20)throw"invalid color matrix";var u=T(a,"HEAPF32"),p=e.ColorFilter._makeMatrix(u);return v(u,a),p},e.ContourMeasure.prototype.getPosTan=function(a,u){return this._getPosTan(a,Rt),a=ue.toTypedArray(),u?(u.set(a),u):a.slice()},e.ImageFilter.prototype.getOutputBounds=function(a,u,p){return a=ot(a,Rt),u=L(u),this._getOutputBounds(a,u,li),u=Oi.toTypedArray(),p?(p.set(u),p):u.slice()},e.ImageFilter.MakeDropShadow=function(a,u,p,P,E,N){return E=F(E,Oe),e.ImageFilter._MakeDropShadow(a,u,p,P,E,N)},e.ImageFilter.MakeDropShadowOnly=function(a,u,p,P,E,N){return E=F(E,Oe),e.ImageFilter._MakeDropShadowOnly(a,u,p,P,E,N)},e.ImageFilter.MakeImage=function(a,u,p,P){if(p=ot(p,Rt),P=ot(P,Ee),"B"in u&&"C"in u)return e.ImageFilter._MakeImageCubic(a,u.B,u.C,p,P);const E=u.filter;let N=e.MipmapMode.None;return"mipmap"in u&&(N=u.mipmap),e.ImageFilter._MakeImageOptions(a,E,N,p,P)},e.ImageFilter.MakeMatrixTransform=function(a,u,p){if(a=L(a),"B"in u&&"C"in u)return e.ImageFilter._MakeMatrixTransformCubic(a,u.B,u.C,p);const P=u.filter;let E=e.MipmapMode.None;return"mipmap"in u&&(E=u.mipmap),e.ImageFilter._MakeMatrixTransformOptions(a,P,E,p)},e.Paint.prototype.getColor=function(){return this._getColor(Oe),ht(Oe)},e.Paint.prototype.setColor=function(a,u){u=u||null,a=F(a),this._setColor(a,u)},e.Paint.prototype.setColorComponents=function(a,u,p,P,E){E=E||null,a=J(a,u,p,P),this._setColor(a,E)},e.Path.prototype.getPoint=function(a,u){return this._getPoint(a,Rt),a=ue.toTypedArray(),u?(u[0]=a[0],u[1]=a[1],u):a.slice(0,2)},e.Picture.prototype.makeShader=function(a,u,p,P,E){return P=L(P),E=ot(E),this._makeShader(a,u,p,P,E)},e.Picture.prototype.cullRect=function(a){this._cullRect(Rt);var u=ue.toTypedArray();return a?(a.set(u),a):u.slice()},e.PictureRecorder.prototype.beginRecording=function(a,u){return a=ot(a),this._beginRecording(a,!!u)},e.Surface.prototype.getCanvas=function(){var a=this._getCanvas();return a.be=this.be,a},e.Surface.prototype.makeImageSnapshot=function(a){return e.de(this.be),a=T(a,"HEAP32",li),this._makeImageSnapshot(a)},e.Surface.prototype.makeSurface=function(a){return e.de(this.be),a=this._makeSurface(a),a.be=this.be,a},e.Surface.prototype.Wf=function(a,u){return this.Ze||(this.Ze=this.getCanvas()),requestAnimationFrame(function(){e.de(this.be),a(this.Ze),this.flush(u)}.bind(this))},e.Surface.prototype.requestAnimationFrame||(e.Surface.prototype.requestAnimationFrame=e.Surface.prototype.Wf),e.Surface.prototype.Sf=function(a,u){this.Ze||(this.Ze=this.getCanvas()),requestAnimationFrame(function(){e.de(this.be),a(this.Ze),this.flush(u),this.dispose()}.bind(this))},e.Surface.prototype.drawOnce||(e.Surface.prototype.drawOnce=e.Surface.prototype.Sf),e.PathEffect.MakeDash=function(a,u){if(u||(u=0),!a.length||a.length%2===1)throw"Intervals array must have even length";var p=T(a,"HEAPF32");return u=e.PathEffect._MakeDash(p,a.length,u),v(p,a),u},e.PathEffect.MakeLine2D=function(a,u){return u=L(u),e.PathEffect._MakeLine2D(a,u)},e.PathEffect.MakePath2D=function(a,u){return a=L(a),e.PathEffect._MakePath2D(a,u)},e.Shader.MakeColor=function(a,u){return u=u||null,a=F(a),e.Shader._MakeColor(a,u)},e.Shader.Blend=e.Shader.MakeBlend,e.Shader.Color=e.Shader.MakeColor,e.Shader.MakeLinearGradient=function(a,u,p,P,E,N,j,tt){tt=tt||null;var et=O(p),vt=T(P,"HEAPF32");j=j||0,N=L(N);var bt=ue.toTypedArray();return bt.set(a),bt.set(u,2),a=e.Shader._MakeLinearGradient(Rt,et.te,et.colorType,vt,et.count,E,j,N,tt),v(et.te,p),P&&v(vt,P),a},e.Shader.MakeRadialGradient=function(a,u,p,P,E,N,j,tt){tt=tt||null;var et=O(p),vt=T(P,"HEAPF32");return j=j||0,N=L(N),a=e.Shader._MakeRadialGradient(a[0],a[1],u,et.te,et.colorType,vt,et.count,E,j,N,tt),v(et.te,p),P&&v(vt,P),a},e.Shader.MakeSweepGradient=function(a,u,p,P,E,N,j,tt,et,vt){vt=vt||null;var bt=O(p),b=T(P,"HEAPF32");return j=j||0,tt=tt||0,et=et||360,N=L(N),a=e.Shader._MakeSweepGradient(a,u,bt.te,bt.colorType,b,bt.count,E,tt,et,j,N,vt),v(bt.te,p),P&&v(b,P),a},e.Shader.MakeTwoPointConicalGradient=function(a,u,p,P,E,N,j,tt,et,vt){vt=vt||null;var bt=O(E),b=T(N,"HEAPF32");et=et||0,tt=L(tt);var I=ue.toTypedArray();return I.set(a),I.set(p,2),a=e.Shader._MakeTwoPointConicalGradient(Rt,u,P,bt.te,bt.colorType,b,bt.count,j,et,tt,vt),v(bt.te,E),N&&v(b,N),a},e.Vertices.prototype.bounds=function(a){this._bounds(Rt);var u=ue.toTypedArray();return a?(a.set(u),a):u.slice()},e.ke&&e.ke.forEach(function(a){a()})},e.computeTonalColors=function(o){var a=T(o.ambient,"HEAPF32"),u=T(o.spot,"HEAPF32");this._computeTonalColors(a,u);var p={ambient:ht(a),spot:ht(u)};return v(a,o.ambient),v(u,o.spot),p},e.LTRBRect=function(o,a,u,p){return Float32Array.of(o,a,u,p)},e.XYWHRect=function(o,a,u,p){return Float32Array.of(o,a,o+u,a+p)},e.LTRBiRect=function(o,a,u,p){return Int32Array.of(o,a,u,p)},e.XYWHiRect=function(o,a,u,p){return Int32Array.of(o,a,o+u,a+p)},e.RRectXY=function(o,a,u){return Float32Array.of(o[0],o[1],o[2],o[3],a,u,a,u,a,u,a,u)},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 hi=null;e.MakeImageFromCanvasImageSource=function(o){var a=o.width,u=o.height;hi||(hi=document.createElement("canvas")),hi.width=a,hi.height=u;var p=hi.getContext("2d",{willReadFrequently:!0});return p.drawImage(o,0,0),o=p.getImageData(0,0,a,u),e.MakeImage({width:a,height:u,alphaType:e.AlphaType.Unpremul,colorType:e.ColorType.RGBA_8888,colorSpace:e.ColorSpace.SRGB},o.data,4*a)},e.MakeImage=function(o,a,u){var p=e._malloc(a.length);return e.HEAPU8.set(a,p),e._MakeImage(o,p,a.length,u)},e.MakeVertices=function(o,a,u,p,P,E){var N=P&&P.length||0,j=0;return u&&u.length&&(j|=1),p&&p.length&&(j|=2),E===void 0||E||(j|=4),o=new e._VerticesBuilder(o,a.length/2,N,j),T(a,"HEAPF32",o.positions()),o.texCoords()&&T(u,"HEAPF32",o.texCoords()),o.colors()&&T(g(p),"HEAPU32",o.colors()),o.indices()&&T(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 u=0;u<a.length;u+=2){var p=a[u],P=a[u+1],E=o[6]*p+o[7]*P+o[8],N=o[3]*p+o[4]*P+o[5];a[u]=(o[0]*p+o[1]*P+o[2])/E,a[u+1]=N/E}return a},e.Matrix.multiply=function(){return oi(3,arguments)},e.Matrix.rotated=function(o,a,u){a=a||0,u=u||0;var p=Math.sin(o);return o=Math.cos(o),[o,-p,Lt(p,u,1-o,a),p,o,Lt(-p,a,1-o,u),0,0,1]},e.Matrix.scaled=function(o,a,u,p){u=u||0,p=p||0;var P=n([o,a],s(3),3,0,1);return n([u-o*u,p-a*p],P,3,2,0)},e.Matrix.skewed=function(o,a,u,p){u=u||0,p=p||0;var P=n([o,a],s(3),3,1,-1);return n([-o*u,-a*p],P,3,2,0)},e.Matrix.translated=function(o,a){return n(arguments,s(3),3,2,0)},e.Vector={},e.Vector.dot=function(o,a){return o.map(function(u,p){return u*a[p]}).reduce(function(u,p){return u+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(u){return u*a})},e.Vector.add=function(o,a){return o.map(function(u,p){return u+a[p]})},e.Vector.sub=function(o,a){return o.map(function(u,p){return u-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 n(o,s(4),4,3,0)},e.M44.scaled=function(o){return n(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,u){var p=o[0],P=o[1];o=o[2];var E=1-u;return[E*p*p+u,E*p*P-a*o,E*p*o+a*P,0,E*p*P+a*o,E*P*P+u,E*P*o-a*p,0,E*p*o-a*P,E*P*o+a*p,E*o*o+u,0,0,0,0,1]},e.M44.lookat=function(o,a,u){a=e.Vector.normalize(e.Vector.sub(a,o)),u=e.Vector.normalize(u),u=e.Vector.normalize(e.Vector.cross(a,u));var p=e.M44.identity();return n(u,p,4,0,0),n(e.Vector.cross(u,a),p,4,1,0),n(e.Vector.mulScalar(a,-1),p,4,2,0),n(o,p,4,3,0),o=e.M44.invert(p),o===null?e.M44.identity():o},e.M44.perspective=function(o,a,u){var p=1/(a-o);return u/=2,u=Math.cos(u)/Math.sin(u),[u,0,0,0,0,u,0,0,0,0,(a+o)*p,2*a*o*p,0,0,-1,1]},e.M44.rc=function(o,a,u){return o[4*a+u]},e.M44.multiply=function(){return oi(4,arguments)},e.M44.invert=function(o){var a=o[0],u=o[4],p=o[8],P=o[12],E=o[1],N=o[5],j=o[9],tt=o[13],et=o[2],vt=o[6],bt=o[10],b=o[14],I=o[3],ct=o[7],Ct=o[11];o=o[15];var kt=a*N-u*E,Xt=a*j-p*E,ie=a*tt-P*E,de=u*j-p*N,Tt=u*tt-P*N,$=p*tt-P*j,f=et*ct-vt*I,w=et*Ct-bt*I,M=et*o-b*I,k=vt*Ct-bt*ct,D=vt*o-b*ct,B=bt*o-b*Ct,Z=kt*B-Xt*D+ie*k+de*M-Tt*w+$*f,pt=1/Z;return Z===0||pt===1/0?null:(kt*=pt,Xt*=pt,ie*=pt,de*=pt,Tt*=pt,$*=pt,f*=pt,w*=pt,M*=pt,k*=pt,D*=pt,B*=pt,a=[N*B-j*D+tt*k,j*M-E*B-tt*w,E*D-N*M+tt*f,N*w-E*k-j*f,p*D-u*B-P*k,a*B-p*M+P*w,u*M-a*D-P*f,a*k-u*w+p*f,ct*$-Ct*Tt+o*de,Ct*ie-I*$-o*Xt,I*Tt-ct*ie+o*kt,ct*Xt-I*de-Ct*kt,bt*Tt-vt*$-b*de,et*$-bt*ie+b*Xt,vt*ie-et*Tt-b*kt,et*de-vt*Xt+bt*kt],a.every(function($t){return!isNaN($t)&&$t!==1/0&&$t!==-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,u){var p=e.M44.lookat(u.eye,u.coa,u.up);return u=e.M44.perspective(u.near,u.far,u.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,u,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,u,p){var P=new Float32Array(20);return P[0]=o,P[6]=a,P[12]=u,P[18]=p,P};var oa=[[6,7,11,12],[0,10,2,12],[0,1,5,6]];e.ColorMatrix.rotated=function(o,a,u){var p=e.ColorMatrix.identity();return o=oa[o],p[o[0]]=u,p[o[1]]=a,p[o[2]]=-a,p[o[3]]=u,p},e.ColorMatrix.postTranslate=function(o,a,u,p,P){return o[4]+=a,o[9]+=u,o[14]+=p,o[19]+=P,o},e.ColorMatrix.concat=function(o,a){for(var u=new Float32Array(20),p=0,P=0;20>P;P+=5){for(var E=0;4>E;E++)u[p++]=o[P]*a[E]+o[P+1]*a[E+5]+o[P+2]*a[E+10]+o[P+3]*a[E+15];u[p++]=o[P]*a[4]+o[P+1]*a[9]+o[P+2]*a[14]+o[P+3]*a[19]+o[P+4]}return u},function(o){o.ke=o.ke||[],o.ke.push(function(){function a(b){return b&&(b.dir=b.dir===0?o.TextDirection.RTL:o.TextDirection.LTR),b}function u(b){if(!b||!b.length)return[];for(var I=[],ct=0;ct<b.length;ct+=5){var Ct=o.LTRBRect(b[ct],b[ct+1],b[ct+2],b[ct+3]),kt=o.TextDirection.LTR;b[ct+4]===0&&(kt=o.TextDirection.RTL),I.push({rect:Ct,dir:kt})}return o._free(b.byteOffset),I}function p(b){return b=b||{},b.weight===void 0&&(b.weight=o.FontWeight.Normal),b.width=b.width||o.FontWidth.Normal,b.slant=b.slant||o.FontSlant.Upright,b}function P(b){if(!b||!b.length)return gt;for(var I=[],ct=0;ct<b.length;ct++){var Ct=E(b[ct]);I.push(Ct)}return T(I,"HEAPU32")}function E(b){if(tt[b])return tt[b];var I=le(b)+1,ct=o._malloc(I);return oe(b,ft,ct,I),tt[b]=ct}function N(b){if(b._colorPtr=F(b.color),b._foregroundColorPtr=gt,b._backgroundColorPtr=gt,b._decorationColorPtr=gt,b.foregroundColor&&(b._foregroundColorPtr=F(b.foregroundColor,et)),b.backgroundColor&&(b._backgroundColorPtr=F(b.backgroundColor,vt)),b.decorationColor&&(b._decorationColorPtr=F(b.decorationColor,bt)),Array.isArray(b.fontFamilies)&&b.fontFamilies.length?(b._fontFamiliesPtr=P(b.fontFamilies),b._fontFamiliesLen=b.fontFamilies.length):(b._fontFamiliesPtr=gt,b._fontFamiliesLen=0),b.locale){var I=b.locale;b._localePtr=E(I),b._localeLen=le(I)}else b._localePtr=gt,b._localeLen=0;if(Array.isArray(b.shadows)&&b.shadows.length){I=b.shadows;var ct=I.map(function(Tt){return Tt.color||o.BLACK}),Ct=I.map(function(Tt){return Tt.blurRadius||0});b._shadowLen=I.length;for(var kt=o._malloc(8*I.length),Xt=kt/4,ie=0;ie<I.length;ie++){var de=I[ie].offset||[0,0];o.HEAPF32[Xt]=de[0],o.HEAPF32[Xt+1]=de[1],Xt+=2}b._shadowColorsPtr=O(ct).te,b._shadowOffsetsPtr=kt,b._shadowBlurRadiiPtr=T(Ct,"HEAPF32")}else b._shadowLen=0,b._shadowColorsPtr=gt,b._shadowOffsetsPtr=gt,b._shadowBlurRadiiPtr=gt;Array.isArray(b.fontFeatures)&&b.fontFeatures.length?(I=b.fontFeatures,ct=I.map(function(Tt){return Tt.name}),Ct=I.map(function(Tt){return Tt.value}),b._fontFeatureLen=I.length,b._fontFeatureNamesPtr=P(ct),b._fontFeatureValuesPtr=T(Ct,"HEAPU32")):(b._fontFeatureLen=0,b._fontFeatureNamesPtr=gt,b._fontFeatureValuesPtr=gt),Array.isArray(b.fontVariations)&&b.fontVariations.length?(I=b.fontVariations,ct=I.map(function(Tt){return Tt.axis}),Ct=I.map(function(Tt){return Tt.value}),b._fontVariationLen=I.length,b._fontVariationAxesPtr=P(ct),b._fontVariationValuesPtr=T(Ct,"HEAPF32")):(b._fontVariationLen=0,b._fontVariationAxesPtr=gt,b._fontVariationValuesPtr=gt)}function j(b){o._free(b._fontFamiliesPtr),o._free(b._shadowColorsPtr),o._free(b._shadowOffsetsPtr),o._free(b._shadowBlurRadiiPtr),o._free(b._fontFeatureNamesPtr),o._free(b._fontFeatureValuesPtr),o._free(b._fontVariationAxesPtr),o._free(b._fontVariationValuesPtr)}o.Paragraph.prototype.getRectsForRange=function(b,I,ct,Ct){return b=this._getRectsForRange(b,I,ct,Ct),u(b)},o.Paragraph.prototype.getRectsForPlaceholders=function(){var b=this._getRectsForPlaceholders();return u(b)},o.Paragraph.prototype.getGlyphInfoAt=function(b){return a(this._getGlyphInfoAt(b))},o.Paragraph.prototype.getClosestGlyphInfoAtCoordinate=function(b,I){return a(this._getClosestGlyphInfoAtCoordinate(b,I))},o.TypefaceFontProvider.prototype.registerFont=function(b,I){if(b=o.Typeface.MakeTypefaceFromData(b),!b)return null;I=E(I),this._registerFont(b,I),b.delete()},o.ParagraphStyle=function(b){if(b.disableHinting=b.disableHinting||!1,b.ellipsis){var I=b.ellipsis;b._ellipsisPtr=E(I),b._ellipsisLen=le(I)}else b._ellipsisPtr=gt,b._ellipsisLen=0;return b.heightMultiplier==null&&(b.heightMultiplier=-1),b.maxLines=b.maxLines||0,b.replaceTabCharacters=b.replaceTabCharacters||!1,I=(I=b.strutStyle)||{},I.strutEnabled=I.strutEnabled||!1,I.strutEnabled&&Array.isArray(I.fontFamilies)&&I.fontFamilies.length?(I._fontFamiliesPtr=P(I.fontFamilies),I._fontFamiliesLen=I.fontFamilies.length):(I._fontFamiliesPtr=gt,I._fontFamiliesLen=0),I.fontStyle=p(I.fontStyle),I.fontSize==null&&(I.fontSize=-1),I.heightMultiplier==null&&(I.heightMultiplier=-1),I.halfLeading=I.halfLeading||!1,I.leading=I.leading||0,I.forceStrutHeight=I.forceStrutHeight||!1,b.strutStyle=I,b.textAlign=b.textAlign||o.TextAlign.Start,b.textDirection=b.textDirection||o.TextDirection.LTR,b.textHeightBehavior=b.textHeightBehavior||o.TextHeightBehavior.All,b.textStyle=o.TextStyle(b.textStyle),b.applyRoundingHack=b.applyRoundingHack!==!1,b},o.TextStyle=function(b){return b.color||(b.color=o.BLACK),b.decoration=b.decoration||0,b.decorationThickness=b.decorationThickness||0,b.decorationStyle=b.decorationStyle||o.DecorationStyle.Solid,b.textBaseline=b.textBaseline||o.TextBaseline.Alphabetic,b.fontSize==null&&(b.fontSize=-1),b.letterSpacing=b.letterSpacing||0,b.wordSpacing=b.wordSpacing||0,b.heightMultiplier==null&&(b.heightMultiplier=-1),b.halfLeading=b.halfLeading||!1,b.fontStyle=p(b.fontStyle),b};var tt={},et=o._malloc(16),vt=o._malloc(16),bt=o._malloc(16);o.ParagraphBuilder.Make=function(b,I){return N(b.textStyle),I=o.ParagraphBuilder._Make(b,I),j(b.textStyle),I},o.ParagraphBuilder.MakeFromFontProvider=function(b,I){return N(b.textStyle),I=o.ParagraphBuilder._MakeFromFontProvider(b,I),j(b.textStyle),I},o.ParagraphBuilder.MakeFromFontCollection=function(b,I){return N(b.textStyle),I=o.ParagraphBuilder._MakeFromFontCollection(b,I),j(b.textStyle),I},o.ParagraphBuilder.ShapeText=function(b,I,ct){let Ct=0;for(const kt of I)Ct+=kt.length;if(Ct!==b.length)throw"Accumulated block lengths must equal text.length";return o.ParagraphBuilder._ShapeText(b,I,ct)},o.ParagraphBuilder.prototype.pushStyle=function(b){N(b),this._pushStyle(b),j(b)},o.ParagraphBuilder.prototype.pushPaintStyle=function(b,I,ct){N(b),this._pushPaintStyle(b,I,ct),j(b)},o.ParagraphBuilder.prototype.addPlaceholder=function(b,I,ct,Ct,kt){ct=ct||o.PlaceholderAlignment.Baseline,Ct=Ct||o.TextBaseline.Alphabetic,this._addPlaceholder(b||0,I||0,ct,Ct,kt||0)},o.ParagraphBuilder.prototype.setWordsUtf8=function(b){var I=T(b,"HEAPU32");this._setWordsUtf8(I,b&&b.length||0),v(I,b)},o.ParagraphBuilder.prototype.setWordsUtf16=function(b){var I=T(b,"HEAPU32");this._setWordsUtf16(I,b&&b.length||0),v(I,b)},o.ParagraphBuilder.prototype.setGraphemeBreaksUtf8=function(b){var I=T(b,"HEAPU32");this._setGraphemeBreaksUtf8(I,b&&b.length||0),v(I,b)},o.ParagraphBuilder.prototype.setGraphemeBreaksUtf16=function(b){var I=T(b,"HEAPU32");this._setGraphemeBreaksUtf16(I,b&&b.length||0),v(I,b)},o.ParagraphBuilder.prototype.setLineBreaksUtf8=function(b){var I=T(b,"HEAPU32");this._setLineBreaksUtf8(I,b&&b.length||0),v(I,b)},o.ParagraphBuilder.prototype.setLineBreaksUtf16=function(b){var I=T(b,"HEAPU32");this._setLineBreaksUtf16(I,b&&b.length||0),v(I,b)}})}(c),e.ke=e.ke||[],e.ke.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.ke=e.ke||[],e.ke.push(function(){e.Canvas.prototype.drawText=function(o,a,u,p,P){var E=le(o),N=e._malloc(E+1);oe(o,ft,N,E+1),this._drawSimpleText(N,E,a,u,P,p),e._free(N)},e.Canvas.prototype.drawGlyphs=function(o,a,u,p,P,E){if(!(2*o.length<=a.length))throw"Not enough positions for the array of gyphs";e.de(this.be);const N=T(o,"HEAPU16"),j=T(a,"HEAPF32");this._drawGlyphs(o.length,N,j,u,p,P,E),v(j,a),v(N,o)},e.Font.prototype.getGlyphBounds=function(o,a,u){var p=T(o,"HEAPU16"),P=e._malloc(16*o.length);return this._getGlyphWidthBounds(p,o.length,gt,P,a||null),a=new Float32Array(e.HEAPU8.buffer,P,4*o.length),v(p,o),u?(u.set(a),e._free(P),u):(o=Float32Array.from(a),e._free(P),o)},e.Font.prototype.getGlyphIDs=function(o,a,u){a||(a=o.length);var p=le(o)+1,P=e._malloc(p);return oe(o,ft,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),u?(u.set(P),e._free(o),u):(u=Uint16Array.from(P),e._free(o),u))},e.Font.prototype.getGlyphIntercepts=function(o,a,u,p){var P=T(o,"HEAPU16"),E=T(a,"HEAPF32");return this._getGlyphIntercepts(P,o.length,!(o&&o._ck),E,a.length,!(a&&a._ck),u,p)},e.Font.prototype.getGlyphWidths=function(o,a,u){var p=T(o,"HEAPU16"),P=e._malloc(4*o.length);return this._getGlyphWidthBounds(p,o.length,P,gt,a||null),a=new Float32Array(e.HEAPU8.buffer,P,o.length),v(p,o),u?(u.set(a),e._free(P),u):(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=[],u=[],p=0;p<o.length;p++){var P=new Uint8Array(o[p]),E=T(P,"HEAPU8");a.push(E),u.push(P.byteLength)}return a=T(a,"HEAPU32"),u=T(u,"HEAPU32"),o=e.FontMgr._fromData(a,u,o.length),e._free(a),e._free(u),o},e.Typeface.MakeTypefaceFromData=function(o){o=new Uint8Array(o);var a=T(o,"HEAPU8");return(o=e.Typeface._MakeTypefaceFromData(a,o.byteLength))?o:null},e.Typeface.MakeFreeTypeFaceFromData=e.Typeface.MakeTypefaceFromData,e.Typeface.prototype.getGlyphIDs=function(o,a,u){a||(a=o.length);var p=le(o)+1,P=e._malloc(p);return oe(o,ft,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),u?(u.set(P),e._free(o),u):(u=Uint16Array.from(P),e._free(o),u))},e.TextBlob.MakeOnPath=function(o,a,u,p){if(o&&o.length&&a&&a.countPoints()){if(a.countPoints()===1)return this.MakeFromText(o,u);p||(p=0);var P=u.getGlyphIDs(o);P=u.getGlyphWidths(P);var E=[];a=new e.ContourMeasureIter(a,!1,1);for(var N=a.next(),j=new Float32Array(4),tt=0;tt<o.length&&N;tt++){var et=P[tt];if(p+=et/2,p>N.length()){if(N.delete(),N=a.next(),!N){o=o.substring(0,tt);break}p=et/2}N.getPosTan(p,j);var vt=j[2],bt=j[3];E.push(vt,bt,j[0]-et/2*vt,j[1]-et/2*bt),p+=et/2}return o=this.MakeFromRSXform(o,E,u),N&&N.delete(),a.delete(),o}},e.TextBlob.MakeFromRSXform=function(o,a,u){var p=le(o)+1,P=e._malloc(p);return oe(o,ft,P,p),o=T(a,"HEAPF32"),u=e.TextBlob._MakeFromRSXform(P,p-1,o,u),e._free(P),u||null},e.TextBlob.MakeFromRSXformGlyphs=function(o,a,u){var p=T(o,"HEAPU16");return a=T(a,"HEAPF32"),u=e.TextBlob._MakeFromRSXformGlyphs(p,2*o.length,a,u),v(p,o),u||null},e.TextBlob.MakeFromGlyphs=function(o,a){var u=T(o,"HEAPU16");return a=e.TextBlob._MakeFromGlyphs(u,2*o.length,a),v(u,o),a||null},e.TextBlob.MakeFromText=function(o,a){var u=le(o)+1,p=e._malloc(u);return oe(o,ft,p,u),o=e.TextBlob._MakeFromText(p,u-1,a),e._free(p),o||null},e.MallocGlyphIDs=function(o){return e.Malloc(Uint16Array,o)}}),e.ke=e.ke||[],e.ke.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.ke=e.ke||[],e.ke.push(function(){e.RuntimeEffect.Make=function(o,a){return e.RuntimeEffect._Make(o,{onError:a||function(u){console.log("RuntimeEffect error",u)}})},e.RuntimeEffect.MakeForBlender=function(o,a){return e.RuntimeEffect._MakeForBlender(o,{onError:a||function(u){console.log("RuntimeEffect error",u)}})},e.RuntimeEffect.prototype.makeShader=function(o,a){var u=!o._ck,p=T(o,"HEAPF32");return a=L(a),this._makeShader(p,4*o.length,u,a)},e.RuntimeEffect.prototype.makeShaderWithChildren=function(o,a,u){var p=!o._ck,P=T(o,"HEAPF32");u=L(u);for(var E=[],N=0;N<a.length;N++)E.push(a[N].ae.ie);return a=T(E,"HEAPU32"),this._makeShaderWithChildren(P,4*o.length,p,a,E.length,u)},e.RuntimeEffect.prototype.makeBlender=function(o){var a=!o._ck,u=T(o,"HEAPF32");return this._makeBlender(u,4*o.length,a)}}),function(){function o($){for(var f=0;f<$.length;f++)if($[f]!==void 0&&!Number.isFinite($[f]))return!1;return!0}function a($){var f=e.getColorComponents($);$=f[0];var w=f[1],M=f[2];return f=f[3],f===1?($=$.toString(16).toLowerCase(),w=w.toString(16).toLowerCase(),M=M.toString(16).toLowerCase(),$=$.length===1?"0"+$:$,w=w.length===1?"0"+w:w,M=M.length===1?"0"+M:M,"#"+$+w+M):(f=f===0||f===1?f:f.toFixed(8),"rgba("+$+", "+w+", "+M+", "+f+")")}function u($){return e.parseColorString($,ie)}function p($){if($=de.exec($),!$)return null;var f=parseFloat($[4]),w=16;switch($[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:$[1],variant:$[2],weight:$[3],sizePx:w,family:$[6].trim()}}function P(){Tt||(Tt={"Noto Mono":{"*":e.Typeface.GetDefault()},monospace:{"*":e.Typeface.GetDefault()}})}function E($){this.ce=$,this.fe=new e.Paint,this.fe.setAntiAlias(!0),this.fe.setStrokeMiter(10),this.fe.setStrokeCap(e.StrokeCap.Butt),this.fe.setStrokeJoin(e.StrokeJoin.Miter),this.kf="10px monospace",this.Fe=new e.Font(e.Typeface.GetDefault(),10),this.Fe.setSubpixel(!0),this.se=this.ye=e.BLACK,this.Oe=0,this.af=e.TRANSPARENT,this.Qe=this.Pe=0,this.bf=this.Be=1,this.$e=0,this.Ne=[],this.ee=e.BlendMode.SrcOver,this.fe.setStrokeWidth(this.bf),this.fe.setBlendMode(this.ee),this.he=new e.Path,this.je=e.Matrix.identity(),this.Ff=[],this.Ue=[],this.Ee=function(){this.he.delete(),this.fe.delete(),this.Fe.delete(),this.Ue.forEach(function(f){f.Ee()})},Object.defineProperty(this,"currentTransform",{enumerable:!0,get:function(){return{a:this.je[0],c:this.je[1],e:this.je[2],b:this.je[3],d:this.je[4],f:this.je[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.se)?a(this.se):this.se},set:function(f){typeof f=="string"?this.se=u(f):f.Me&&(this.se=f)}}),Object.defineProperty(this,"font",{enumerable:!0,get:function(){return this.kf},set:function(f){var w=p(f),M=(w.style||"normal")+"|"+(w.variant||"normal")+"|"+(w.weight||"normal"),k=w.family;P(),M=Tt[k]?Tt[k][M]||Tt[k]["*"]:e.Typeface.GetDefault(),w.typeface=M,w&&(this.Fe.setSize(w.sizePx),this.Fe.setTypeface(w.typeface),this.kf=f)}}),Object.defineProperty(this,"globalAlpha",{enumerable:!0,get:function(){return this.Be},set:function(f){!isFinite(f)||0>f||1<f||(this.Be=f)}}),Object.defineProperty(this,"globalCompositeOperation",{enumerable:!0,get:function(){switch(this.ee){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.ee=e.BlendMode.SrcOver;break;case"destination-over":this.ee=e.BlendMode.DstOver;break;case"copy":this.ee=e.BlendMode.Src;break;case"destination":this.ee=e.BlendMode.Dst;break;case"clear":this.ee=e.BlendMode.Clear;break;case"source-in":this.ee=e.BlendMode.SrcIn;break;case"destination-in":this.ee=e.BlendMode.DstIn;break;case"source-out":this.ee=e.BlendMode.SrcOut;break;case"destination-out":this.ee=e.BlendMode.DstOut;break;case"source-atop":this.ee=e.BlendMode.SrcATop;break;case"destination-atop":this.ee=e.BlendMode.DstATop;break;case"xor":this.ee=e.BlendMode.Xor;break;case"lighter":this.ee=e.BlendMode.Plus;break;case"plus-lighter":this.ee=e.BlendMode.Plus;break;case"plus-darker":throw"plus-darker is not supported";case"multiply":this.ee=e.BlendMode.Multiply;break;case"screen":this.ee=e.BlendMode.Screen;break;case"overlay":this.ee=e.BlendMode.Overlay;break;case"darken":this.ee=e.BlendMode.Darken;break;case"lighten":this.ee=e.BlendMode.Lighten;break;case"color-dodge":this.ee=e.BlendMode.ColorDodge;break;case"color-burn":this.ee=e.BlendMode.ColorBurn;break;case"hard-light":this.ee=e.BlendMode.HardLight;break;case"soft-light":this.ee=e.BlendMode.SoftLight;break;case"difference":this.ee=e.BlendMode.Difference;break;case"exclusion":this.ee=e.BlendMode.Exclusion;break;case"hue":this.ee=e.BlendMode.Hue;break;case"saturation":this.ee=e.BlendMode.Saturation;break;case"color":this.ee=e.BlendMode.Color;break;case"luminosity":this.ee=e.BlendMode.Luminosity;break;default:return}this.fe.setBlendMode(this.ee)}}),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.fe.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.fe.setStrokeCap(e.StrokeCap.Butt);break;case"round":this.fe.setStrokeCap(e.StrokeCap.Round);break;case"square":this.fe.setStrokeCap(e.StrokeCap.Square)}}}),Object.defineProperty(this,"lineDashOffset",{enumerable:!0,get:function(){return this.$e},set:function(f){isFinite(f)&&(this.$e=f)}}),Object.defineProperty(this,"lineJoin",{enumerable:!0,get:function(){switch(this.fe.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.fe.setStrokeJoin(e.StrokeJoin.Miter);break;case"round":this.fe.setStrokeJoin(e.StrokeJoin.Round);break;case"bevel":this.fe.setStrokeJoin(e.StrokeJoin.Bevel)}}}),Object.defineProperty(this,"lineWidth",{enumerable:!0,get:function(){return this.fe.getStrokeWidth()},set:function(f){0>=f||!f||(this.bf=f,this.fe.setStrokeWidth(f))}}),Object.defineProperty(this,"miterLimit",{enumerable:!0,get:function(){return this.fe.getStrokeMiter()},set:function(f){0>=f||!f||this.fe.setStrokeMiter(f)}}),Object.defineProperty(this,"shadowBlur",{enumerable:!0,get:function(){return this.Oe},set:function(f){0>f||!isFinite(f)||(this.Oe=f)}}),Object.defineProperty(this,"shadowColor",{enumerable:!0,get:function(){return a(this.af)},set:function(f){this.af=u(f)}}),Object.defineProperty(this,"shadowOffsetX",{enumerable:!0,get:function(){return this.Pe},set:function(f){isFinite(f)&&(this.Pe=f)}}),Object.defineProperty(this,"shadowOffsetY",{enumerable:!0,get:function(){return this.Qe},set:function(f){isFinite(f)&&(this.Qe=f)}}),Object.defineProperty(this,"strokeStyle",{enumerable:!0,get:function(){return a(this.ye)},set:function(f){typeof f=="string"?this.ye=u(f):f.Me&&(this.ye=f)}}),this.arc=function(f,w,M,k,D,B){I(this.he,f,w,M,M,0,k,D,B)},this.arcTo=function(f,w,M,k,D){vt(this.he,f,w,M,k,D)},this.beginPath=function(){this.he.delete(),this.he=new e.Path},this.bezierCurveTo=function(f,w,M,k,D,B){var Z=this.he;o([f,w,M,k,D,B])&&(Z.isEmpty()&&Z.moveTo(f,w),Z.cubicTo(f,w,M,k,D,B))},this.clearRect=function(f,w,M,k){this.fe.setStyle(e.PaintStyle.Fill),this.fe.setBlendMode(e.BlendMode.Clear),this.ce.drawRect(e.XYWHRect(f,w,M,k),this.fe),this.fe.setBlendMode(this.ee)},this.clip=function(f,w){typeof f=="string"?(w=f,f=this.he):f&&f.vf&&(f=f.le),f||(f=this.he),f=f.copy(),w&&w.toLowerCase()==="evenodd"?f.setFillType(e.FillType.EvenOdd):f.setFillType(e.FillType.Winding),this.ce.clipPath(f,e.ClipOp.Intersect,!0),f.delete()},this.closePath=function(){bt(this.he)},this.createImageData=function(){if(arguments.length===1){var f=arguments[0];return new tt(new Uint8ClampedArray(4*f.width*f.height),f.width,f.height)}if(arguments.length===2){f=arguments[0];var w=arguments[1];return new tt(new Uint8ClampedArray(4*f*w),f,w)}throw"createImageData expects 1 or 2 arguments, got "+arguments.length},this.createLinearGradient=function(f,w,M,k){if(o(arguments)){var D=new et(f,w,M,k);return this.Ue.push(D),D}},this.createPattern=function(f,w){return f=new kt(f,w),this.Ue.push(f),f},this.createRadialGradient=function(f,w,M,k,D,B){if(o(arguments)){var Z=new Xt(f,w,M,k,D,B);return this.Ue.push(Z),Z}},this.drawImage=function(f){f instanceof j&&(f=f.Lf());var w=this.jf();if(arguments.length===3||arguments.length===5)var M=e.XYWHRect(arguments[1],arguments[2],arguments[3]||f.width(),arguments[4]||f.height()),k=e.XYWHRect(0,0,f.width(),f.height());else if(arguments.length===9)M=e.XYWHRect(arguments[5],arguments[6],arguments[7],arguments[8]),k=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.ce.drawImageRect(f,k,M,w,!1),w.dispose()},this.ellipse=function(f,w,M,k,D,B,Z,pt){I(this.he,f,w,M,k,D,B,Z,pt)},this.jf=function(){var f=this.fe.copy();if(f.setStyle(e.PaintStyle.Fill),l(this.se)){var w=e.multiplyByAlpha(this.se,this.Be);f.setColor(w)}else w=this.se.Me(this.je),f.setColor(e.Color(0,0,0,this.Be)),f.setShader(w);return f.dispose=function(){this.delete()},f},this.fill=function(f,w){if(typeof f=="string"?(w=f,f=this.he):f&&f.vf&&(f=f.le),w==="evenodd")this.he.setFillType(e.FillType.EvenOdd);else{if(w!=="nonzero"&&w)throw"invalid fill rule";this.he.setFillType(e.FillType.Winding)}f||(f=this.he),w=this.jf();var M=this.Re(w);M&&(this.ce.save(),this.Ke(),this.ce.drawPath(f,M),this.ce.restore(),M.dispose()),this.ce.drawPath(f,w),w.dispose()},this.fillRect=function(f,w,M,k){var D=this.jf(),B=this.Re(D);B&&(this.ce.save(),this.Ke(),this.ce.drawRect(e.XYWHRect(f,w,M,k),B),this.ce.restore(),B.dispose()),this.ce.drawRect(e.XYWHRect(f,w,M,k),D),D.dispose()},this.fillText=function(f,w,M){var k=this.jf();f=e.TextBlob.MakeFromText(f,this.Fe);var D=this.Re(k);D&&(this.ce.save(),this.Ke(),this.ce.drawTextBlob(f,w,M,D),this.ce.restore(),D.dispose()),this.ce.drawTextBlob(f,w,M,k),f.delete(),k.dispose()},this.getImageData=function(f,w,M,k){return(f=this.ce.readPixels(f,w,{width:M,height:k,colorType:e.ColorType.RGBA_8888,alphaType:e.AlphaType.Unpremul,colorSpace:e.ColorSpace.SRGB}))?new tt(new Uint8ClampedArray(f.buffer),M,k):null},this.getLineDash=function(){return this.Ne.slice()},this.Gf=function(f){var w=e.Matrix.invert(this.je);return e.Matrix.mapPoints(w,f),f},this.isPointInPath=function(f,w,M){var k=arguments;if(k.length===3)var D=this.he;else if(k.length===4)D=k[0],f=k[1],w=k[2],M=k[3];else throw"invalid arg count, need 3 or 4, got "+k.length;return!isFinite(f)||!isFinite(w)||(M=M||"nonzero",M!=="nonzero"&&M!=="evenodd")?!1:(k=this.Gf([f,w]),f=k[0],w=k[1],D.setFillType(M==="nonzero"?e.FillType.Winding:e.FillType.EvenOdd),D.contains(f,w))},this.isPointInStroke=function(f,w){var M=arguments;if(M.length===2)var k=this.he;else if(M.length===3)k=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.Gf([f,w]),f=M[0],w=M[1],k=k.copy(),k.setFillType(e.FillType.Winding),k.stroke({width:this.lineWidth,miter_limit:this.miterLimit,cap:this.fe.getStrokeCap(),join:this.fe.getStrokeJoin(),precision:.3}),M=k.contains(f,w),k.delete(),M)},this.lineTo=function(f,w){ct(this.he,f,w)},this.measureText=function(f){f=this.Fe.getGlyphIDs(f),f=this.Fe.getGlyphWidths(f);let w=0;for(const M of f)w+=M;return{width:w}},this.moveTo=function(f,w){var M=this.he;o([f,w])&&M.moveTo(f,w)},this.putImageData=function(f,w,M,k,D,B,Z){if(o([w,M,k,D,B,Z])){if(k===void 0)this.ce.writePixels(f.data,f.width,f.height,w,M);else if(k=k||0,D=D||0,B=B||f.width,Z=Z||f.height,0>B&&(k+=B,B=Math.abs(B)),0>Z&&(D+=Z,Z=Math.abs(Z)),0>k&&(B+=k,k=0),0>D&&(Z+=D,D=0),!(0>=B||0>=Z)){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(k,D,B,Z);w=e.XYWHRect(w+k,M+D,B,Z),M=e.Matrix.invert(this.je),this.ce.save(),this.ce.concat(M),this.ce.drawImageRect(f,pt,w,null,!1),this.ce.restore(),f.delete()}}},this.quadraticCurveTo=function(f,w,M,k){var D=this.he;o([f,w,M,k])&&(D.isEmpty()&&D.moveTo(f,w),D.quadTo(f,w,M,k))},this.rect=function(f,w,M,k){var D=this.he;f=e.XYWHRect(f,w,M,k),o(f)&&D.addRect(f)},this.resetTransform=function(){this.he.transform(this.je);var f=e.Matrix.invert(this.je);this.ce.concat(f),this.je=this.ce.getTotalMatrix()},this.restore=function(){var f=this.Ff.pop();if(f){var w=e.Matrix.multiply(this.je,e.Matrix.invert(f.ag));this.he.transform(w),this.fe.delete(),this.fe=f.sg,this.Ne=f.qg,this.bf=f.Eg,this.ye=f.Dg,this.se=f.fs,this.Pe=f.Bg,this.Qe=f.Cg,this.Oe=f.sb,this.af=f.Ag,this.Be=f.ga,this.ee=f.hg,this.$e=f.rg,this.kf=f.gg,this.ce.restore(),this.je=this.ce.getTotalMatrix()}},this.rotate=function(f){if(isFinite(f)){var w=e.Matrix.rotated(-f);this.he.transform(w),this.ce.rotate(f/Math.PI*180,0,0),this.je=this.ce.getTotalMatrix()}},this.save=function(){if(this.se.Le){var f=this.se.Le();this.Ue.push(f)}else f=this.se;if(this.ye.Le){var w=this.ye.Le();this.Ue.push(w)}else w=this.ye;this.Ff.push({ag:this.je.slice(),qg:this.Ne.slice(),Eg:this.bf,Dg:w,fs:f,Bg:this.Pe,Cg:this.Qe,sb:this.Oe,Ag:this.af,ga:this.Be,rg:this.$e,hg:this.ee,sg:this.fe.copy(),gg:this.kf}),this.ce.save()},this.scale=function(f,w){if(o(arguments)){var M=e.Matrix.scaled(1/f,1/w);this.he.transform(M),this.ce.scale(f,w),this.je=this.ce.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.Ne=f},this.setTransform=function(f,w,M,k,D,B){o(arguments)&&(this.resetTransform(),this.transform(f,w,M,k,D,B))},this.Ke=function(){var f=e.Matrix.invert(this.je);this.ce.concat(f),this.ce.concat(e.Matrix.translated(this.Pe,this.Qe)),this.ce.concat(this.je)},this.Re=function(f){var w=e.multiplyByAlpha(this.af,this.Be);if(!e.getColorComponents(w)[3]||!(this.Oe||this.Qe||this.Pe))return null;f=f.copy(),f.setColor(w);var M=e.MaskFilter.MakeBlur(e.BlurStyle.Normal,this.Oe/2,!1);return f.setMaskFilter(M),f.dispose=function(){M.delete(),this.delete()},f},this.xf=function(){var f=this.fe.copy();if(f.setStyle(e.PaintStyle.Stroke),l(this.ye)){var w=e.multiplyByAlpha(this.ye,this.Be);f.setColor(w)}else w=this.ye.Me(this.je),f.setColor(e.Color(0,0,0,this.Be)),f.setShader(w);if(f.setStrokeWidth(this.bf),this.Ne.length){var M=e.PathEffect.MakeDash(this.Ne,this.$e);f.setPathEffect(M)}return f.dispose=function(){M&&M.delete(),this.delete()},f},this.stroke=function(f){f=f?f.le:this.he;var w=this.xf(),M=this.Re(w);M&&(this.ce.save(),this.Ke(),this.ce.drawPath(f,M),this.ce.restore(),M.dispose()),this.ce.drawPath(f,w),w.dispose()},this.strokeRect=function(f,w,M,k){var D=this.xf(),B=this.Re(D);B&&(this.ce.save(),this.Ke(),this.ce.drawRect(e.XYWHRect(f,w,M,k),B),this.ce.restore(),B.dispose()),this.ce.drawRect(e.XYWHRect(f,w,M,k),D),D.dispose()},this.strokeText=function(f,w,M){var k=this.xf();f=e.TextBlob.MakeFromText(f,this.Fe);var D=this.Re(k);D&&(this.ce.save(),this.Ke(),this.ce.drawTextBlob(f,w,M,D),this.ce.restore(),D.dispose()),this.ce.drawTextBlob(f,w,M,k),f.delete(),k.dispose()},this.translate=function(f,w){if(o(arguments)){var M=e.Matrix.translated(-f,-w);this.he.transform(M),this.ce.translate(f,w),this.je=this.ce.getTotalMatrix()}},this.transform=function(f,w,M,k,D,B){f=[f,M,D,w,k,B,0,0,1],w=e.Matrix.invert(f),this.he.transform(w),this.ce.concat(f),this.je=this.ce.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 N($){this.yf=$,this.be=new E($.getCanvas()),this.lf=[],this.decodeImage=function(f){if(f=e.MakeImageFromEncoded(f),!f)throw"Invalid input";return this.lf.push(f),new j(f)},this.loadFont=function(f,w){if(f=e.Typeface.MakeTypefaceFromData(f),!f)return null;this.lf.push(f);var M=(w.style||"normal")+"|"+(w.variant||"normal")+"|"+(w.weight||"normal");w=w.family,P(),Tt[w]||(Tt[w]={"*":f}),Tt[w][M]=f},this.makePath2D=function(f){return f=new Ct(f),this.lf.push(f.le),f},this.getContext=function(f){return f==="2d"?this.be:null},this.toDataURL=function(f,w){this.yf.flush();var M=this.yf.makeImageSnapshot();if(M){f=f||"image/png";var k=e.ImageFormat.PNG;if(f==="image/jpeg"&&(k=e.ImageFormat.JPEG),w=M.encodeToBytes(k,w||.92)){if(M.delete(),f="data:"+f+";base64,",typeof Buffer<"u")w=Buffer.from(w).toString("base64");else{M=0,k=w.length;for(var D="",B;M<k;)B=w.slice(M,Math.min(M+32768,k)),D+=String.fromCharCode.apply(null,B),M+=32768;w=btoa(D)}return f+w}}},this.dispose=function(){this.be.Ee(),this.lf.forEach(function(f){f.delete()}),this.yf.dispose()}}function j($){this.width=$.width(),this.height=$.height(),this.naturalWidth=this.width,this.naturalHeight=this.height,this.Lf=function(){return $}}function tt($,f,w){if(!f||w===0)throw new TypeError("invalid dimensions, width and height must be non-zero");if($.length%4)throw new TypeError("arr must be a multiple of 4");w=w||$.length/(4*f),Object.defineProperty(this,"data",{value:$,writable:!1}),Object.defineProperty(this,"height",{value:w,writable:!1}),Object.defineProperty(this,"width",{value:f,writable:!1})}function et($,f,w,M){this.ne=null,this.ue=[],this.qe=[],this.addColorStop=function(k,D){if(0>k||1<k||!isFinite(k))throw"offset must be between 0 and 1 inclusively";D=u(D);var B=this.qe.indexOf(k);if(B!==-1)this.ue[B]=D;else{for(B=0;B<this.qe.length&&!(this.qe[B]>k);B++);this.qe.splice(B,0,k),this.ue.splice(B,0,D)}},this.Le=function(){var k=new et($,f,w,M);return k.ue=this.ue.slice(),k.qe=this.qe.slice(),k},this.Ee=function(){this.ne&&(this.ne.delete(),this.ne=null)},this.Me=function(k){var D=[$,f,w,M];e.Matrix.mapPoints(k,D),k=D[0];var B=D[1],Z=D[2];return D=D[3],this.Ee(),this.ne=e.Shader.MakeLinearGradient([k,B],[Z,D],this.ue,this.qe,e.TileMode.Clamp)}}function vt($,f,w,M,k,D){if(o([f,w,M,k,D])){if(0>D)throw"radii cannot be negative";$.isEmpty()&&$.moveTo(f,w),$.arcToTangent(f,w,M,k,D)}}function bt($){if(!$.isEmpty()){var f=$.getBounds();(f[3]-f[1]||f[2]-f[0])&&$.close()}}function b($,f,w,M,k,D,B){B=(B-D)/Math.PI*180,D=D/Math.PI*180,f=e.LTRBRect(f-M,w-k,f+M,w+k),1e-5>Math.abs(Math.abs(B)-360)?(w=B/2,$.arcToOval(f,D,w,!1),$.arcToOval(f,D+w,w,!1)):$.arcToOval(f,D,B,!1)}function I($,f,w,M,k,D,B,Z,pt){if(o([f,w,M,k,D,B,Z])){if(0>M||0>k)throw"radii cannot be negative";var $t=2*Math.PI,je=B%$t;0>je&&(je+=$t);var ci=je-B;B=je,Z+=ci,!pt&&Z-B>=$t?Z=B+$t:pt&&B-Z>=$t?Z=B-$t:!pt&&B>Z?Z=B+($t-(B-Z)%$t):pt&&B<Z&&(Z=B-($t-(Z-B)%$t)),D?(pt=e.Matrix.rotated(D,f,w),D=e.Matrix.rotated(-D,f,w),$.transform(D),b($,f,w,M,k,B,Z),$.transform(pt)):b($,f,w,M,k,B,Z)}}function ct($,f,w){o([f,w])&&($.isEmpty()&&$.moveTo(f,w),$.lineTo(f,w))}function Ct($){this.le=null,this.le=typeof $=="string"?e.Path.MakeFromSVGString($):$&&$.vf?$.le.copy():new e.Path,this.vf=function(){return this.le},this.addPath=function(f,w){w||(w={a:1,c:0,e:0,b:0,d:1,f:0}),this.le.addPath(f.le,[w.a,w.c,w.e,w.b,w.d,w.f])},this.arc=function(f,w,M,k,D,B){I(this.le,f,w,M,M,0,k,D,B)},this.arcTo=function(f,w,M,k,D){vt(this.le,f,w,M,k,D)},this.bezierCurveTo=function(f,w,M,k,D,B){var Z=this.le;o([f,w,M,k,D,B])&&(Z.isEmpty()&&Z.moveTo(f,w),Z.cubicTo(f,w,M,k,D,B))},this.closePath=function(){bt(this.le)},this.ellipse=function(f,w,M,k,D,B,Z,pt){I(this.le,f,w,M,k,D,B,Z,pt)},this.lineTo=function(f,w){ct(this.le,f,w)},this.moveTo=function(f,w){var M=this.le;o([f,w])&&M.moveTo(f,w)},this.quadraticCurveTo=function(f,w,M,k){var D=this.le;o([f,w,M,k])&&(D.isEmpty()&&D.moveTo(f,w),D.quadTo(f,w,M,k))},this.rect=function(f,w,M,k){var D=this.le;f=e.XYWHRect(f,w,M,k),o(f)&&D.addRect(f)}}function kt($,f){switch(this.ne=null,$ instanceof j&&($=$.Lf()),this.Uf=$,this._transform=e.Matrix.identity(),f===""&&(f="repeat"),f){case"repeat-x":this.Se=e.TileMode.Repeat,this.Te=e.TileMode.Decal;break;case"repeat-y":this.Se=e.TileMode.Decal,this.Te=e.TileMode.Repeat;break;case"repeat":this.Te=this.Se=e.TileMode.Repeat;break;case"no-repeat":this.Te=this.Se=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.Le=function(){var w=new kt;return w.Se=this.Se,w.Te=this.Te,w},this.Ee=function(){this.ne&&(this.ne.delete(),this.ne=null)},this.Me=function(){return this.Ee(),this.ne=this.Uf.makeShaderCubic(this.Se,this.Te,.3333333333333333,.3333333333333333,this._transform)}}function Xt($,f,w,M,k,D){this.ne=null,this.ue=[],this.qe=[],this.addColorStop=function(B,Z){if(0>B||1<B||!isFinite(B))throw"offset must be between 0 and 1 inclusively";Z=u(Z);var pt=this.qe.indexOf(B);if(pt!==-1)this.ue[pt]=Z;else{for(pt=0;pt<this.qe.length&&!(this.qe[pt]>B);pt++);this.qe.splice(pt,0,B),this.ue.splice(pt,0,Z)}},this.Le=function(){var B=new Xt($,f,w,M,k,D);return B.ue=this.ue.slice(),B.qe=this.qe.slice(),B},this.Ee=function(){this.ne&&(this.ne.delete(),this.ne=null)},this.Me=function(B){var Z=[$,f,M,k];e.Matrix.mapPoints(B,Z);var pt=Z[0],$t=Z[1],je=Z[2];Z=Z[3];var ci=(Math.abs(B[0])+Math.abs(B[4]))/2;return B=w*ci,ci*=D,this.Ee(),this.ne=e.Shader.MakeTwoPointConicalGradient([pt,$t],B,[je,Z],ci,this.ue,this.qe,e.TileMode.Clamp)}}e._testing={};var ie={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=u,e._testing.colorToString=a;var de=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)(.+)"),Tt;e._testing.parseFontString=p,e.MakeCanvas=function($,f){return($=e.MakeSurface($,f))?new N($):null},e.ImageData=function(){if(arguments.length===2){var $=arguments[0],f=arguments[1];return new tt(new Uint8ClampedArray(4*$*f),$,f)}if(arguments.length===3){var w=arguments[0];if(w.prototype.constructor!==Uint8ClampedArray)throw new TypeError("bytes must be given as a Uint8ClampedArray");if($=arguments[1],f=arguments[2],w%4)throw new TypeError("bytes must be given in a multiple of 4");if(w%$)throw new TypeError("bytes must divide evenly by width");if(f&&f!==w/(4*$))throw new TypeError("invalid height given");return new tt(w,$,w/(4*$))}throw new TypeError("invalid number of arguments - takes 2 or 3, saw "+arguments.length)}}()}(c);var z=Object.assign({},c),G="./this.program",q=(e,n)=>{throw n},st=typeof window=="object",lt=typeof importScripts=="function",yt=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",rt="",Et,Wt,Bt;if(yt){var se=va,U=Aa;rt=lt?U.dirname(rt)+"/":__dirname+"/",Et=(e,n)=>(e=e.startsWith("file://")?new URL(e):U.normalize(e),se.readFileSync(e,n?void 0:"utf8")),Bt=e=>(e=Et(e,!0),e.buffer||(e=new Uint8Array(e)),e),Wt=(e,n,s,l=!0)=>{e=e.startsWith("file://")?new URL(e):U.normalize(e),se.readFile(e,l?void 0:"utf8",(d,g)=>{d?s(d):n(l?g.buffer:g)})},!c.thisProgram&&1<process.argv.length&&(G=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),q=(e,n)=>{throw process.exitCode=e,n},c.inspect=()=>"[Emscripten Module object]"}else(st||lt)&&(lt?rt=self.location.href:typeof document<"u"&&document.currentScript&&(rt=document.currentScript.src),r&&(rt=r),rt.indexOf("blob:")!==0?rt=rt.substr(0,rt.replace(/[?#].*/,"").lastIndexOf("/")+1):rt="",Et=e=>{var n=new XMLHttpRequest;return n.open("GET",e,!1),n.send(null),n.responseText},lt&&(Bt=e=>{var n=new XMLHttpRequest;return n.open("GET",e,!1),n.responseType="arraybuffer",n.send(null),new Uint8Array(n.response)}),Wt=(e,n,s)=>{var l=new XMLHttpRequest;l.open("GET",e,!0),l.responseType="arraybuffer",l.onload=()=>{l.status==200||l.status==0&&l.response?n(l.response):s()},l.onerror=s,l.send(null)});var ut=c.print||console.log.bind(console),Pe=c.printErr||console.error.bind(console);Object.assign(c,z),z=null,c.thisProgram&&(G=c.thisProgram),c.quit&&(q=c.quit);var qe;c.wasmBinary&&(qe=c.wasmBinary),c.noExitRuntime,typeof WebAssembly!="object"&&Gi("no native wasm support detected");var gi,Pt,Cn=!1,pe,ft,Ae,Be,W,_t,it,Tn;function _n(){var e=gi.buffer;c.HEAP8=pe=new Int8Array(e),c.HEAP16=Ae=new Int16Array(e),c.HEAP32=W=new Int32Array(e),c.HEAPU8=ft=new Uint8Array(e),c.HEAPU16=Be=new Uint16Array(e),c.HEAPU32=_t=new Uint32Array(e),c.HEAPF32=it=new Float32Array(e),c.HEAPF64=Tn=new Float64Array(e)}var Mt,En=[],xn=[],Fn=[];function os(){var e=c.preRun.shift();En.unshift(e)}var xe=0,Ye=null;function Gi(e){throw c.onAbort&&c.onAbort(e),e="Aborted("+e+")",Pe(e),Cn=!0,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),x(e),e}function Mn(e){return e.startsWith("data:application/octet-stream;base64,")}var Ue;if(Ue="canvaskit.wasm",!Mn(Ue)){var Rn=Ue;Ue=c.locateFile?c.locateFile(Rn,rt):rt+Rn}function kn(e){if(e==Ue&&qe)return new Uint8Array(qe);if(Bt)return Bt(e);throw"both async and sync fetching of the wasm failed"}function ls(e){if(!qe&&(st||lt)){if(typeof fetch=="function"&&!e.startsWith("file://"))return fetch(e,{credentials:"same-origin"}).then(n=>{if(!n.ok)throw"failed to load wasm binary file at '"+e+"'";return n.arrayBuffer()}).catch(()=>kn(e));if(Wt)return new Promise((n,s)=>{Wt(e,l=>n(new Uint8Array(l)),s)})}return Promise.resolve().then(()=>kn(e))}function Nn(e,n,s){return ls(e).then(l=>WebAssembly.instantiate(l,n)).then(l=>l).then(s,l=>{Pe("failed to asynchronously prepare wasm: "+l),Gi(l)})}function hs(e,n){var s=Ue;return qe||typeof WebAssembly.instantiateStreaming!="function"||Mn(s)||s.startsWith("file://")||yt||typeof fetch!="function"?Nn(s,e,n):fetch(s,{credentials:"same-origin"}).then(l=>WebAssembly.instantiateStreaming(l,e).then(n,function(d){return Pe("wasm streaming compile failed: "+d),Pe("falling back to ArrayBuffer instantiation"),Nn(s,e,n)}))}function cs(e){this.name="ExitStatus",this.message=`Program terminated with exit(${e})`,this.status=e}var Wi=e=>{for(;0<e.length;)e.shift()(c)},In=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Fe=(e,n,s)=>{var l=n+s;for(s=n;e[s]&&!(s>=l);)++s;if(16<s-n&&e.buffer&&In)return In.decode(e.subarray(n,s));for(l="";n<s;){var d=e[n++];if(d&128){var g=e[n++]&63;if((d&224)==192)l+=String.fromCharCode((d&31)<<6|g);else{var A=e[n++]&63;d=(d&240)==224?(d&15)<<12|g<<6|A:(d&7)<<18|g<<12|A<<6|e[n++]&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},mi={};function ji(e){for(;e.length;){var n=e.pop();e.pop()(n)}}function Xe(e){return this.fromWireType(W[e>>2])}var $e={},Me={},yi={},On=void 0;function vi(e){throw new On(e)}function ae(e,n,s){function l(y){y=s(y),y.length!==e.length&&vi("Mismatched type converter count");for(var v=0;v<e.length;++v)ge(e[v],y[v])}e.forEach(function(y){yi[y]=n});var d=Array(n.length),g=[],A=0;n.forEach((y,v)=>{Me.hasOwnProperty(y)?d[v]=Me[y]:(g.push(y),$e.hasOwnProperty(y)||($e[y]=[]),$e[y].push(()=>{d[v]=Me[y],++A,A===g.length&&l(d)}))}),g.length===0&&l(d)}function wi(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 Dn=void 0;function Ft(e){for(var n="";ft[e];)n+=Dn[ft[e++]];return n}var Ge=void 0;function wt(e){throw new Ge(e)}function us(e,n,s={}){var l=n.name;if(e||wt(`type "${l}" must have a positive integer typeid pointer`),Me.hasOwnProperty(e)){if(s.ng)return;wt(`Cannot register type '${l}' twice`)}Me[e]=n,delete yi[e],$e.hasOwnProperty(e)&&(n=$e[e],delete $e[e],n.forEach(d=>d()))}function ge(e,n,s={}){if(!("argPackAdvance"in n))throw new TypeError("registerType registeredInstance requires argPackAdvance");us(e,n,s)}function Hi(e){wt(e.ae.me.ge.name+" instance already deleted")}var Ki=!1;function zn(){}function Ln(e){--e.count.value,e.count.value===0&&(e.pe?e.we.De(e.pe):e.me.ge.De(e.ie))}function Bn(e,n,s){return n===s?e:s.re===void 0?null:(e=Bn(e,n,s.re),e===null?null:s.dg(e))}var Un={},Je=[];function Vi(){for(;Je.length;){var e=Je.pop();e.ae.Xe=!1,e.delete()}}var Qe=void 0,Ze={};function ds(e,n){for(n===void 0&&wt("ptr should not be undefined");e.re;)n=e.gf(n),e=e.re;return Ze[n]}function Si(e,n){return n.me&&n.ie||vi("makeClassHandle requires ptr and ptrType"),!!n.we!=!!n.pe&&vi("Both smartPtrType and smartPtr must be specified"),n.count={value:1},ti(Object.create(e,{ae:{value:n}}))}function ti(e){return typeof FinalizationRegistry>"u"?(ti=n=>n,e):(Ki=new FinalizationRegistry(n=>{Ln(n.ae)}),ti=n=>{var s=n.ae;return s.pe&&Ki.register(n,{ae:s},n),n},zn=n=>{Ki.unregister(n)},ti(e))}function Ce(){}function $n(e){if(e===void 0)return"_unknown";e=e.replace(/[^a-zA-Z0-9_]/g,"$");var n=e.charCodeAt(0);return 48<=n&&57>=n?`_${e}`:e}function qi(e,n){return e=$n(e),{[e]:function(){return n.apply(this,arguments)}}[e]}function Yi(e,n,s){if(e[n].oe===void 0){var l=e[n];e[n]=function(){return e[n].oe.hasOwnProperty(arguments.length)||wt(`Function '${s}' called with an invalid number of arguments (${arguments.length}) - expects one of (${e[n].oe})!`),e[n].oe[arguments.length].apply(this,arguments)},e[n].oe=[],e[n].oe[l.Ve]=l}}function Xi(e,n,s){c.hasOwnProperty(e)?((s===void 0||c[e].oe!==void 0&&c[e].oe[s]!==void 0)&&wt(`Cannot register public name '${e}' twice`),Yi(c,e,e),c.hasOwnProperty(s)&&wt(`Cannot register multiple overloads of a function with the same number of arguments (${s})!`),c[e].oe[s]=n):(c[e]=n,s!==void 0&&(c[e].Lg=s))}function fs(e,n,s,l,d,g,A,y){this.name=e,this.constructor=n,this.Ye=s,this.De=l,this.re=d,this.ig=g,this.gf=A,this.dg=y,this.ug=[]}function Ji(e,n,s){for(;n!==s;)n.gf||wt(`Expected null or instance of ${s.name}, got an instance of ${n.name}`),e=n.gf(e),n=n.re;return e}function ps(e,n){return n===null?(this.Bf&&wt(`null is not a valid ${this.name}`),0):(n.ae||wt(`Cannot pass "${Zi(n)}" as a ${this.name}`),n.ae.ie||wt(`Cannot pass deleted object as a pointer of type ${this.name}`),Ji(n.ae.ie,n.ae.me.ge,this.ge))}function gs(e,n){if(n===null){if(this.Bf&&wt(`null is not a valid ${this.name}`),this.pf){var s=this.Cf();return e!==null&&e.push(this.De,s),s}return 0}if(n.ae||wt(`Cannot pass "${Zi(n)}" as a ${this.name}`),n.ae.ie||wt(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.nf&&n.ae.me.nf&&wt(`Cannot convert argument of type ${n.ae.we?n.ae.we.name:n.ae.me.name} to parameter type ${this.name}`),s=Ji(n.ae.ie,n.ae.me.ge,this.ge),this.pf)switch(n.ae.pe===void 0&&wt("Passing raw pointer to smart pointer is illegal"),this.zg){case 0:n.ae.we===this?s=n.ae.pe:wt(`Cannot convert argument of type ${n.ae.we?n.ae.we.name:n.ae.me.name} to parameter type ${this.name}`);break;case 1:s=n.ae.pe;break;case 2:if(n.ae.we===this)s=n.ae.pe;else{var l=n.clone();s=this.vg(s,te(function(){l.delete()})),e!==null&&e.push(this.De,s)}break;default:wt("Unsupporting sharing policy")}return s}function ms(e,n){return n===null?(this.Bf&&wt(`null is not a valid ${this.name}`),0):(n.ae||wt(`Cannot pass "${Zi(n)}" as a ${this.name}`),n.ae.ie||wt(`Cannot pass deleted object as a pointer of type ${this.name}`),n.ae.me.nf&&wt(`Cannot convert argument of type ${n.ae.me.name} to parameter type ${this.name}`),Ji(n.ae.ie,n.ae.me.ge,this.ge))}function me(e,n,s,l,d,g,A,y,v,T,O){this.name=e,this.ge=n,this.Bf=s,this.nf=l,this.pf=d,this.tg=g,this.zg=A,this.Nf=y,this.Cf=v,this.vg=T,this.De=O,d||n.re!==void 0?this.toWireType=gs:(this.toWireType=l?ps:ms,this.ve=null)}function Gn(e,n,s){c.hasOwnProperty(e)||vi("Replacing nonexistant public symbol"),c[e].oe!==void 0&&s!==void 0?c[e].oe[s]=n:(c[e]=n,c[e].Ve=s)}var ys=(e,n)=>{var s=[];return function(){if(s.length=0,Object.assign(s,arguments),e.includes("j")){var l=c["dynCall_"+e];l=s&&s.length?l.apply(null,[n].concat(s)):l.call(null,n)}else l=Mt.get(n).apply(null,s);return l}};function Ut(e,n){e=Ft(e);var s=e.includes("j")?ys(e,n):Mt.get(n);return typeof s!="function"&&wt(`unknown function pointer with signature ${e}: ${n}`),s}var Wn=void 0;function jn(e){e=Sr(e);var n=Ft(e);return we(e),n}function ei(e,n){function s(g){d[g]||Me[g]||(yi[g]?yi[g].forEach(s):(l.push(g),d[g]=!0))}var l=[],d={};throw n.forEach(s),new Wn(`${e}: `+l.map(jn).join([", "]))}function bi(e,n,s,l,d){var g=n.length;2>g&&wt("argTypes array size mismatch! Must at least get return value and 'this' types!");var A=n[1]!==null&&s!==null,y=!1;for(s=1;s<n.length;++s)if(n[s]!==null&&n[s].ve===void 0){y=!0;break}var v=n[0].name!=="void",T=g-2,O=Array(T),L=[],Y=[];return function(){if(arguments.length!==T&&wt(`function ${e} called with ${arguments.length} arguments, expected ${T} args!`),Y.length=0,L.length=A?2:1,L[0]=d,A){var F=n[1].toWireType(Y,this);L[1]=F}for(var J=0;J<T;++J)O[J]=n[J+2].toWireType(Y,arguments[J]),L.push(O[J]);if(J=l.apply(null,L),y)ji(Y);else for(var ht=A?1:2;ht<n.length;ht++){var ot=ht===1?F:O[ht-2];n[ht].ve!==null&&n[ht].ve(ot)}return F=v?n[0].fromWireType(J):void 0,F}}function Pi(e,n){for(var s=[],l=0;l<e;l++)s.push(_t[n+4*l>>2]);return s}function Hn(){this.Ce=[void 0],this.Kf=[]}var Qt=new Hn;function Qi(e){e>=Qt.df&&--Qt.get(e).Of===0&&Qt.Zf(e)}var Zt=e=>(e||wt("Cannot use deleted val. handle = "+e),Qt.get(e).value),te=e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return Qt.Yf({Of:1,value:e})}};function vs(e,n,s){switch(n){case 0:return function(l){return this.fromWireType((s?pe:ft)[l])};case 1:return function(l){return this.fromWireType((s?Ae:Be)[l>>1])};case 2:return function(l){return this.fromWireType((s?W:_t)[l>>2])};default:throw new TypeError("Unknown integer type: "+e)}}function ii(e,n){var s=Me[e];return s===void 0&&wt(n+" has unknown type "+jn(e)),s}function Zi(e){if(e===null)return"null";var n=typeof e;return n==="object"||n==="array"||n==="function"?e.toString():""+e}function ws(e,n){switch(n){case 2:return function(s){return this.fromWireType(it[s>>2])};case 3:return function(s){return this.fromWireType(Tn[s>>3])};default:throw new TypeError("Unknown float type: "+e)}}function Ss(e,n,s){switch(n){case 0:return s?function(l){return pe[l]}:function(l){return ft[l]};case 1:return s?function(l){return Ae[l>>1]}:function(l){return Be[l>>1]};case 2:return s?function(l){return W[l>>2]}:function(l){return _t[l>>2]};default:throw new TypeError("Unknown integer type: "+e)}}var oe=(e,n,s,l)=>{if(!(0<l))return 0;var d=s;l=s+l-1;for(var g=0;g<e.length;++g){var A=e.charCodeAt(g);if(55296<=A&&57343>=A){var y=e.charCodeAt(++g);A=65536+((A&1023)<<10)|y&1023}if(127>=A){if(s>=l)break;n[s++]=A}else{if(2047>=A){if(s+1>=l)break;n[s++]=192|A>>6}else{if(65535>=A){if(s+2>=l)break;n[s++]=224|A>>12}else{if(s+3>=l)break;n[s++]=240|A>>18,n[s++]=128|A>>12&63}n[s++]=128|A>>6&63}n[s++]=128|A&63}}return n[s]=0,s-d},le=e=>{for(var n=0,s=0;s<e.length;++s){var l=e.charCodeAt(s);127>=l?n++:2047>=l?n+=2:55296<=l&&57343>=l?(n+=4,++s):n+=3}return n},Kn=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,bs=(e,n)=>{for(var s=e>>1,l=s+n/2;!(s>=l)&&Be[s];)++s;if(s<<=1,32<s-e&&Kn)return Kn.decode(ft.subarray(e,s));for(s="",l=0;!(l>=n/2);++l){var d=Ae[e+2*l>>1];if(d==0)break;s+=String.fromCharCode(d)}return s},Ps=(e,n,s)=>{if(s===void 0&&(s=2147483647),2>s)return 0;s-=2;var l=n;s=s<2*e.length?s/2:e.length;for(var d=0;d<s;++d)Ae[n>>1]=e.charCodeAt(d),n+=2;return Ae[n>>1]=0,n-l},As=e=>2*e.length,Cs=(e,n)=>{for(var s=0,l="";!(s>=n/4);){var d=W[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},Ts=(e,n,s)=>{if(s===void 0&&(s=2147483647),4>s)return 0;var l=n;s=l+s-4;for(var d=0;d<e.length;++d){var g=e.charCodeAt(d);if(55296<=g&&57343>=g){var A=e.charCodeAt(++d);g=65536+((g&1023)<<10)|A&1023}if(W[n>>2]=g,n+=4,n+4>s)break}return W[n>>2]=0,n-l},_s=e=>{for(var n=0,s=0;s<e.length;++s){var l=e.charCodeAt(s);55296<=l&&57343>=l&&++s,n+=4}return n},Es={};function Ai(e){var n=Es[e];return n===void 0?Ft(e):n}var Ci=[];function Vn(){function e(n){n.$$$embind_global$$$=n;var s=typeof $$$embind_global$$$=="object"&&n.$$$embind_global$$$==n;return s||delete n.$$$embind_global$$$,s}if(typeof globalThis=="object")return globalThis;if(typeof $$$embind_global$$$=="object"||(typeof gn=="object"&&e(gn)?$$$embind_global$$$=gn:typeof self=="object"&&e(self)&&($$$embind_global$$$=self),typeof $$$embind_global$$$=="object"))return $$$embind_global$$$;throw Error("unable to get global object.")}function xs(e){var n=Ci.length;return Ci.push(e),n}function Fs(e,n){for(var s=Array(e),l=0;l<e;++l)s[l]=ii(_t[n+4*l>>2],"parameter "+l);return s}var qn=[];function Ms(e){var n=Array(e+1);return function(s,l,d){n[0]=s;for(var g=0;g<e;++g){var A=ii(_t[l+4*g>>2],"parameter "+g);n[g+1]=A.readValueFromPointer(d),d+=A.argPackAdvance}return s=new(s.bind.apply(s,n)),te(s)}}var Yn={};function Rs(e){var n=e.getExtension("ANGLE_instanced_arrays");n&&(e.vertexAttribDivisor=function(s,l){n.vertexAttribDivisorANGLE(s,l)},e.drawArraysInstanced=function(s,l,d,g){n.drawArraysInstancedANGLE(s,l,d,g)},e.drawElementsInstanced=function(s,l,d,g,A){n.drawElementsInstancedANGLE(s,l,d,g,A)})}function ks(e){var n=e.getExtension("OES_vertex_array_object");n&&(e.createVertexArray=function(){return n.createVertexArrayOES()},e.deleteVertexArray=function(s){n.deleteVertexArrayOES(s)},e.bindVertexArray=function(s){n.bindVertexArrayOES(s)},e.isVertexArray=function(s){return n.isVertexArrayOES(s)})}function Ns(e){var n=e.getExtension("WEBGL_draw_buffers");n&&(e.drawBuffers=function(s,l){n.drawBuffersWEBGL(s,l)})}var Xn=1,Ti=[],he=[],_i=[],ni=[],ee=[],ce=[],Ei=[],ye=[],qt=[],Re=[],ke=[],Jn={},Qn={},Zn=4;function St(e){xi||(xi=e)}function Ne(e){for(var n=Xn++,s=e.length;s<n;s++)e[s]=null;return n}function Is(e,n){e.df||(e.df=e.getContext,e.getContext=function(l,d){return d=e.df(l,d),l=="webgl"==d instanceof WebGLRenderingContext?d:null});var s=1<n.majorVersion?e.getContext("webgl2",n):e.getContext("webgl",n);return s?Os(s,n):0}function Os(e,n){var s=Ne(ye),l={handle:s,attributes:n,version:n.majorVersion,xe:e};return e.canvas&&(e.canvas.Rf=l),ye[s]=l,(typeof n.eg>"u"||n.eg)&&Ds(l),s}function tr(e){return at=ye[e],c.Jg=_=at&&at.xe,!(e&&!_)}function Ds(e){if(e||(e=at),!e.og){e.og=!0;var n=e.xe;Rs(n),ks(n),Ns(n),n.If=n.getExtension("WEBGL_draw_instanced_base_vertex_base_instance"),n.Mf=n.getExtension("WEBGL_multi_draw_instanced_base_vertex_base_instance"),2<=e.version&&(n.ze=n.getExtension("EXT_disjoint_timer_query_webgl2")),(2>e.version||!n.ze)&&(n.ze=n.getExtension("EXT_disjoint_timer_query")),n.Kg=n.getExtension("WEBGL_multi_draw"),(n.getSupportedExtensions()||[]).forEach(function(s){s.includes("lose_context")||s.includes("debug")||n.getExtension(s)})}}var at,xi;function er(e,n){_.bindFramebuffer(e,_i[n])}function ir(e){_.bindVertexArray(Ei[e])}function nr(e){_.clear(e)}function rr(e,n,s,l){_.clearColor(e,n,s,l)}function sr(e){_.clearStencil(e)}function ar(e,n){for(var s=0;s<e;s++){var l=W[n+4*s>>2];_.deleteVertexArray(Ei[l]),Ei[l]=null}}var Fi=[];function or(e,n,s,l){_.drawElements(e,n,s,l)}function Ie(e,n,s,l){for(var d=0;d<e;d++){var g=_[s](),A=g&&Ne(l);g?(g.name=A,l[A]=g):St(1282),W[n+4*d>>2]=A}}function lr(e,n){Ie(e,n,"createVertexArray",Ei)}function hr(e,n){_t[e>>2]=n,_t[e+4>>2]=(n-_t[e>>2])/4294967296}function cr(e,n,s){if(n){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>at.version){St(1282);return}l=2*(_.getSupportedExtensions()||[]).length;break;case 33307:case 33308:if(2>at.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:W[n+4*e>>2]=d[e];break;case 2:it[n+4*e>>2]=d[e];break;case 4:pe[n+e>>0]=d[e]?1:0}return}try{l=d.name|0}catch(g){St(1280),Pe("GL_INVALID_ENUM in glGet"+s+"v: Unknown object returned from WebGL getParameter("+e+")! (error: "+g+")");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:hr(n,l);break;case 0:W[n>>2]=l;break;case 2:it[n>>2]=l;break;case 4:pe[n>>0]=l?1:0}}else St(1281)}function ur(e,n){cr(e,n,0)}function dr(e,n,s){if(s){e=qt[e],n=2>at.version?_.ze.getQueryObjectEXT(e,n):_.getQueryParameter(e,n);var l;typeof n=="boolean"?l=n?1:0:l=n,hr(s,l)}else St(1281)}var ri=e=>{var n=le(e)+1,s=Ni(n);return s&&oe(e,ft,s,n),s};function fr(e){var n=Jn[e];if(!n){switch(e){case 7939:n=_.getSupportedExtensions()||[],n=n.concat(n.map(function(l){return"GL_"+l})),n=ri(n.join(" "));break;case 7936:case 7937:case 37445:case 37446:(n=_.getParameter(e))||St(1280),n=n&&ri(n);break;case 7938:n=_.getParameter(7938),n=2<=at.version?"OpenGL ES 3.0 ("+n+")":"OpenGL ES 2.0 ("+n+")",n=ri(n);break;case 35724:n=_.getParameter(35724);var s=n.match(/^WebGL GLSL ES ([0-9]\.[0-9][0-9]?)(?:$| .*)/);s!==null&&(s[1].length==3&&(s[1]+="0"),n="OpenGL ES GLSL ES "+s[1]+" ("+n+")"),n=ri(n);break;default:St(1280)}Jn[e]=n}return n}function pr(e,n){if(2>at.version)return St(1282),0;var s=Qn[e];if(s)return 0>n||n>=s.length?(St(1281),0):s[n];switch(e){case 7939:return s=_.getSupportedExtensions()||[],s=s.concat(s.map(function(l){return"GL_"+l})),s=s.map(function(l){return ri(l)}),s=Qn[e]=s,0>n||n>=s.length?(St(1281),0):s[n];default:return St(1280),0}}function gr(e){return e.slice(-1)=="]"&&e.lastIndexOf("[")}function Mi(e){return e-=5120,e==0?pe:e==1?ft:e==2?Ae:e==4?W:e==6?it:e==5||e==28922||e==28520||e==30779||e==30782?_t:Be}function tn(e,n,s,l,d){e=Mi(e);var g=31-Math.clz32(e.BYTES_PER_ELEMENT),A=Zn;return e.subarray(d>>g,d+l*(s*({5:3,6:4,8:2,29502:3,29504:4,26917:2,26918:2,29846:3,29847:4}[n-6402]||1)*(1<<g)+A-1&-A)>>g)}function At(e){var n=_.bg;if(n){var s=n.ff[e];return typeof s=="number"&&(n.ff[e]=s=_.getUniformLocation(n,n.Pf[e]+(0<s?"["+s+"]":""))),s}St(1282)}var Te=[],si=[],en={},mr=()=>{if(!nn){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",_:G||"./this.program"},n;for(n in en)en[n]===void 0?delete e[n]:e[n]=en[n];var s=[];for(n in e)s.push(`${n}=${e[n]}`);nn=s}return nn},nn,zs=[null,[],[]],Ri=e=>e%4===0&&(e%100!==0||e%400===0),yr=[31,29,31,30,31,30,31,31,30,31,30,31],vr=[31,28,31,30,31,30,31,31,30,31,30,31];function Ls(e){var n=Array(le(e)+1);return oe(e,n,0,n.length),n}var Bs=(e,n,s,l)=>{function d(F,J,ht){for(F=typeof F=="number"?F.toString():F||"";F.length<J;)F=ht[0]+F;return F}function g(F,J){return d(F,J,"0")}function A(F,J){function ht(Ht){return 0>Ht?-1:0<Ht?1:0}var ot;return(ot=ht(F.getFullYear()-J.getFullYear()))===0&&(ot=ht(F.getMonth()-J.getMonth()))===0&&(ot=ht(F.getDate()-J.getDate())),ot}function y(F){switch(F.getDay()){case 0:return new Date(F.getFullYear()-1,11,29);case 1:return F;case 2:return new Date(F.getFullYear(),0,3);case 3:return new Date(F.getFullYear(),0,2);case 4:return new Date(F.getFullYear(),0,1);case 5:return new Date(F.getFullYear()-1,11,31);case 6:return new Date(F.getFullYear()-1,11,30)}}function v(F){var J=F.He;for(F=new Date(new Date(F.Ie+1900,0,1).getTime());0<J;){var ht=F.getMonth(),ot=(Ri(F.getFullYear())?yr:vr)[ht];if(J>ot-F.getDate())J-=ot-F.getDate()+1,F.setDate(1),11>ht?F.setMonth(ht+1):(F.setMonth(0),F.setFullYear(F.getFullYear()+1));else{F.setDate(F.getDate()+J);break}}return ht=new Date(F.getFullYear()+1,0,4),J=y(new Date(F.getFullYear(),0,4)),ht=y(ht),0>=A(J,F)?0>=A(ht,F)?F.getFullYear()+1:F.getFullYear():F.getFullYear()-1}var T=W[l+40>>2];l={Hg:W[l>>2],Gg:W[l+4>>2],tf:W[l+8>>2],Df:W[l+12>>2],uf:W[l+16>>2],Ie:W[l+20>>2],Ae:W[l+24>>2],He:W[l+28>>2],Ng:W[l+32>>2],Fg:W[l+36>>2],Ig:T&&T?Fe(ft,T):""},s=s?Fe(ft,s):"",T={"%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 T)s=s.replace(new RegExp(O,"g"),T[O]);var L="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),Y="January February March April May June July August September October November December".split(" ");T={"%a":F=>L[F.Ae].substring(0,3),"%A":F=>L[F.Ae],"%b":F=>Y[F.uf].substring(0,3),"%B":F=>Y[F.uf],"%C":F=>g((F.Ie+1900)/100|0,2),"%d":F=>g(F.Df,2),"%e":F=>d(F.Df,2," "),"%g":F=>v(F).toString().substring(2),"%G":F=>v(F),"%H":F=>g(F.tf,2),"%I":F=>(F=F.tf,F==0?F=12:12<F&&(F-=12),g(F,2)),"%j":F=>{for(var J=0,ht=0;ht<=F.uf-1;J+=(Ri(F.Ie+1900)?yr:vr)[ht++]);return g(F.Df+J,3)},"%m":F=>g(F.uf+1,2),"%M":F=>g(F.Gg,2),"%n":()=>`
3
- `,"%p":F=>0<=F.tf&&12>F.tf?"AM":"PM","%S":F=>g(F.Hg,2),"%t":()=>" ","%u":F=>F.Ae||7,"%U":F=>g(Math.floor((F.He+7-F.Ae)/7),2),"%V":F=>{var J=Math.floor((F.He+7-(F.Ae+6)%7)/7);if(2>=(F.Ae+371-F.He-2)%7&&J++,J)J==53&&(ht=(F.Ae+371-F.He)%7,ht==4||ht==3&&Ri(F.Ie)||(J=1));else{J=52;var ht=(F.Ae+7-F.He-1)%7;(ht==4||ht==5&&Ri(F.Ie%400-1))&&J++}return g(J,2)},"%w":F=>F.Ae,"%W":F=>g(Math.floor((F.He+7-(F.Ae+6)%7)/7),2),"%y":F=>(F.Ie+1900).toString().substring(2),"%Y":F=>F.Ie+1900,"%z":F=>{F=F.Fg;var J=0<=F;return F=Math.abs(F)/60,(J?"+":"-")+("0000"+(F/60*100+F%60)).slice(-4)},"%Z":F=>F.Ig,"%%":()=>"%"},s=s.replace(/%%/g,"\0\0");for(O in T)s.includes(O)&&(s=s.replace(new RegExp(O,"g"),T[O](l)));return s=s.replace(/\0\0/g,"%"),O=Ls(s),O.length>n?0:(pe.set(O,e),O.length-1)};On=c.InternalError=class extends Error{constructor(e){super(e),this.name="InternalError"}};for(var wr=Array(256),ki=0;256>ki;++ki)wr[ki]=String.fromCharCode(ki);Dn=wr,Ge=c.BindingError=class extends Error{constructor(e){super(e),this.name="BindingError"}},Ce.prototype.isAliasOf=function(e){if(!(this instanceof Ce&&e instanceof Ce))return!1;var n=this.ae.me.ge,s=this.ae.ie,l=e.ae.me.ge;for(e=e.ae.ie;n.re;)s=n.gf(s),n=n.re;for(;l.re;)e=l.gf(e),l=l.re;return n===l&&s===e},Ce.prototype.clone=function(){if(this.ae.ie||Hi(this),this.ae.ef)return this.ae.count.value+=1,this;var e=ti,n=Object,s=n.create,l=Object.getPrototypeOf(this),d=this.ae;return e=e(s.call(n,l,{ae:{value:{count:d.count,Xe:d.Xe,ef:d.ef,ie:d.ie,me:d.me,pe:d.pe,we:d.we}}})),e.ae.count.value+=1,e.ae.Xe=!1,e},Ce.prototype.delete=function(){this.ae.ie||Hi(this),this.ae.Xe&&!this.ae.ef&&wt("Object already scheduled for deletion"),zn(this),Ln(this.ae),this.ae.ef||(this.ae.pe=void 0,this.ae.ie=void 0)},Ce.prototype.isDeleted=function(){return!this.ae.ie},Ce.prototype.deleteLater=function(){return this.ae.ie||Hi(this),this.ae.Xe&&!this.ae.ef&&wt("Object already scheduled for deletion"),Je.push(this),Je.length===1&&Qe&&Qe(Vi),this.ae.Xe=!0,this},c.getInheritedInstanceCount=function(){return Object.keys(Ze).length},c.getLiveInheritedInstances=function(){var e=[],n;for(n in Ze)Ze.hasOwnProperty(n)&&e.push(Ze[n]);return e},c.flushPendingDeletes=Vi,c.setDelayFunction=function(e){Qe=e,Je.length&&Qe&&Qe(Vi)},me.prototype.jg=function(e){return this.Nf&&(e=this.Nf(e)),e},me.prototype.Hf=function(e){this.De&&this.De(e)},me.prototype.argPackAdvance=8,me.prototype.readValueFromPointer=Xe,me.prototype.deleteObject=function(e){e!==null&&e.delete()},me.prototype.fromWireType=function(e){function n(){return this.pf?Si(this.ge.Ye,{me:this.tg,ie:s,we:this,pe:e}):Si(this.ge.Ye,{me:this,ie:e})}var s=this.jg(e);if(!s)return this.Hf(e),null;var l=ds(this.ge,s);if(l!==void 0)return l.ae.count.value===0?(l.ae.ie=s,l.ae.pe=e,l.clone()):(l=l.clone(),this.Hf(e),l);if(l=this.ge.ig(s),l=Un[l],!l)return n.call(this);l=this.nf?l.$f:l.pointerType;var d=Bn(s,this.ge,l.ge);return d===null?n.call(this):this.pf?Si(l.ge.Ye,{me:l,ie:d,we:this,pe:e}):Si(l.ge.Ye,{me:l,ie:d})},Wn=c.UnboundTypeError=function(e,n){var s=qi(n,function(l){this.name=n,this.message=l,l=Error(l).stack,l!==void 0&&(this.stack=this.toString()+`
4
- `+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(Hn.prototype,{get(e){return this.Ce[e]},has(e){return this.Ce[e]!==void 0},Yf(e){var n=this.Kf.pop()||this.Ce.length;return this.Ce[n]=e,n},Zf(e){this.Ce[e]=void 0,this.Kf.push(e)}}),Qt.Ce.push({value:void 0},{value:null},{value:!0},{value:!1}),Qt.df=Qt.Ce.length,c.count_emval_handles=function(){for(var e=0,n=Qt.df;n<Qt.Ce.length;++n)Qt.Ce[n]!==void 0&&++e;return e};for(var _,Yt=0;32>Yt;++Yt)Fi.push(Array(Yt));var Us=new Float32Array(288);for(Yt=0;288>Yt;++Yt)Te[Yt]=Us.subarray(0,Yt+1);var $s=new Int32Array(288);for(Yt=0;288>Yt;++Yt)si[Yt]=$s.subarray(0,Yt+1);var Gs={R:function(){return 0},wb:()=>{},yb:function(){return 0},tb:()=>{},ub:()=>{},S:function(){},vb:()=>{},B:function(e){var n=mi[e];delete mi[e];var s=n.Cf,l=n.De,d=n.Jf,g=d.map(A=>A.mg).concat(d.map(A=>A.xg));ae([e],g,A=>{var y={};return d.forEach((v,T)=>{var O=A[T],L=v.kg,Y=v.lg,F=A[T+d.length],J=v.wg,ht=v.yg;y[v.fg]={read:ot=>O.fromWireType(L(Y,ot)),write:(ot,Ht)=>{var Lt=[];J(ht,ot,F.toWireType(Lt,Ht)),ji(Lt)}}}),[{name:n.name,fromWireType:function(v){var T={},O;for(O in y)T[O]=y[O].read(v);return l(v),T},toWireType:function(v,T){for(var O in y)if(!(O in T))throw new TypeError(`Missing field: "${O}"`);var L=s();for(O in y)y[O].write(L,T[O]);return v!==null&&v.push(l,L),L},argPackAdvance:8,readValueFromPointer:Xe,ve:l}]})},nb:function(){},Cb:function(e,n,s,l,d){var g=wi(s);n=Ft(n),ge(e,{name:n,fromWireType:function(A){return!!A},toWireType:function(A,y){return y?l:d},argPackAdvance:8,readValueFromPointer:function(A){if(s===1)var y=pe;else if(s===2)y=Ae;else if(s===4)y=W;else throw new TypeError("Unknown boolean type size: "+n);return this.fromWireType(y[A>>g])},ve:null})},n:function(e,n,s,l,d,g,A,y,v,T,O,L,Y){O=Ft(O),g=Ut(d,g),y&&(y=Ut(A,y)),T&&(T=Ut(v,T)),Y=Ut(L,Y);var F=$n(O);Xi(F,function(){ei(`Cannot construct ${O} due to unbound types`,[l])}),ae([e,n,s],l?[l]:[],function(J){if(J=J[0],l)var ht=J.ge,ot=ht.Ye;else ot=Ce.prototype;J=qi(F,function(){if(Object.getPrototypeOf(this)!==Ht)throw new Ge("Use 'new' to construct "+O);if(Lt.Ge===void 0)throw new Ge(O+" has no accessible constructor");var oi=Lt.Ge[arguments.length];if(oi===void 0)throw new Ge(`Tried to invoke ctor of ${O} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(Lt.Ge).toString()}) parameters instead!`);return oi.apply(this,arguments)});var Ht=Object.create(ot,{constructor:{value:J}});J.prototype=Ht;var Lt=new fs(O,J,Ht,Y,ht,g,y,T);Lt.re&&(Lt.re.hf===void 0&&(Lt.re.hf=[]),Lt.re.hf.push(Lt)),ht=new me(O,Lt,!0,!1,!1),ot=new me(O+"*",Lt,!1,!1,!1);var ai=new me(O+" const*",Lt,!1,!0,!1);return Un[e]={pointerType:ot,$f:ai},Gn(F,J),[ht,ot,ai]})},f:function(e,n,s,l,d,g,A){var y=Pi(s,l);n=Ft(n),g=Ut(d,g),ae([],[e],function(v){function T(){ei(`Cannot call ${O} due to unbound types`,y)}v=v[0];var O=`${v.name}.${n}`;n.startsWith("@@")&&(n=Symbol[n.substring(2)]);var L=v.ge.constructor;return L[n]===void 0?(T.Ve=s-1,L[n]=T):(Yi(L,n,O),L[n].oe[s-1]=T),ae([],y,function(Y){if(Y=[Y[0],null].concat(Y.slice(1)),Y=bi(O,Y,null,g,A),L[n].oe===void 0?(Y.Ve=s-1,L[n]=Y):L[n].oe[s-1]=Y,v.ge.hf)for(const F of v.ge.hf)F.constructor.hasOwnProperty(n)||(F.constructor[n]=Y);return[]}),[]})},A:function(e,n,s,l,d,g){var A=Pi(n,s);d=Ut(l,d),ae([],[e],function(y){y=y[0];var v=`constructor ${y.name}`;if(y.ge.Ge===void 0&&(y.ge.Ge=[]),y.ge.Ge[n-1]!==void 0)throw new Ge(`Cannot register multiple constructors with identical number of parameters (${n-1}) for class '${y.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return y.ge.Ge[n-1]=()=>{ei(`Cannot construct ${y.name} due to unbound types`,A)},ae([],A,function(T){return T.splice(1,0,null),y.ge.Ge[n-1]=bi(v,T,null,d,g),[]}),[]})},b:function(e,n,s,l,d,g,A,y){var v=Pi(s,l);n=Ft(n),g=Ut(d,g),ae([],[e],function(T){function O(){ei(`Cannot call ${L} due to unbound types`,v)}T=T[0];var L=`${T.name}.${n}`;n.startsWith("@@")&&(n=Symbol[n.substring(2)]),y&&T.ge.ug.push(n);var Y=T.ge.Ye,F=Y[n];return F===void 0||F.oe===void 0&&F.className!==T.name&&F.Ve===s-2?(O.Ve=s-2,O.className=T.name,Y[n]=O):(Yi(Y,n,L),Y[n].oe[s-2]=O),ae([],v,function(J){return J=bi(L,J,T,g,A),Y[n].oe===void 0?(J.Ve=s-2,Y[n]=J):Y[n].oe[s-2]=J,[]}),[]})},t:function(e,n,s){e=Ft(e),ae([],[n],function(l){return l=l[0],c[e]=l.fromWireType(s),[]})},Bb:function(e,n){n=Ft(n),ge(e,{name:n,fromWireType:function(s){var l=Zt(s);return Qi(s),l},toWireType:function(s,l){return te(l)},argPackAdvance:8,readValueFromPointer:Xe,ve:null})},m:function(e,n,s,l){function d(){}s=wi(s),n=Ft(n),d.values={},ge(e,{name:n,constructor:d,fromWireType:function(g){return this.constructor.values[g]},toWireType:function(g,A){return A.value},argPackAdvance:8,readValueFromPointer:vs(n,s,l),ve:null}),Xi(n,d)},c:function(e,n,s){var l=ii(e,"enum");n=Ft(n),e=l.constructor,l=Object.create(l.constructor.prototype,{value:{value:s},constructor:{value:qi(`${l.name}_${n}`,function(){})}}),e.values[s]=l,e[n]=l},U:function(e,n,s){s=wi(s),n=Ft(n),ge(e,{name:n,fromWireType:function(l){return l},toWireType:function(l,d){return d},argPackAdvance:8,readValueFromPointer:ws(n,s),ve:null})},y:function(e,n,s,l,d,g){var A=Pi(n,s);e=Ft(e),d=Ut(l,d),Xi(e,function(){ei(`Cannot call ${e} due to unbound types`,A)},n-1),ae([],A,function(y){return y=[y[0],null].concat(y.slice(1)),Gn(e,bi(e,y,null,d,g),n-1),[]})},E:function(e,n,s,l,d){n=Ft(n),d===-1&&(d=4294967295),d=wi(s);var g=y=>y;if(l===0){var A=32-8*s;g=y=>y<<A>>>A}s=n.includes("unsigned")?function(y,v){return v>>>0}:function(y,v){return v},ge(e,{name:n,fromWireType:g,toWireType:s,argPackAdvance:8,readValueFromPointer:Ss(n,d,l!==0),ve:null})},r:function(e,n,s){function l(g){g>>=2;var A=_t;return new d(A.buffer,A[g+1],A[g])}var d=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][n];s=Ft(s),ge(e,{name:s,fromWireType:l,argPackAdvance:8,readValueFromPointer:l},{ng:!0})},q:function(e,n,s,l,d,g,A,y,v,T,O,L){s=Ft(s),g=Ut(d,g),y=Ut(A,y),T=Ut(v,T),L=Ut(O,L),ae([e],[n],function(Y){return Y=Y[0],[new me(s,Y.ge,!1,!1,!0,Y,l,g,y,T,L)]})},T:function(e,n){n=Ft(n);var s=n==="std::string";ge(e,{name:n,fromWireType:function(l){var d=_t[l>>2],g=l+4;if(s)for(var A=g,y=0;y<=d;++y){var v=g+y;if(y==d||ft[v]==0){if(A=A?Fe(ft,A,v-A):"",T===void 0)var T=A;else T+="\0",T+=A;A=v+1}}else{for(T=Array(d),y=0;y<d;++y)T[y]=String.fromCharCode(ft[g+y]);T=T.join("")}return we(l),T},toWireType:function(l,d){d instanceof ArrayBuffer&&(d=new Uint8Array(d));var g=typeof d=="string";g||d instanceof Uint8Array||d instanceof Uint8ClampedArray||d instanceof Int8Array||wt("Cannot pass non-string to std::string");var A=s&&g?le(d):d.length,y=Ni(4+A+1),v=y+4;if(_t[y>>2]=A,s&&g)oe(d,ft,v,A+1);else if(g)for(g=0;g<A;++g){var T=d.charCodeAt(g);255<T&&(we(v),wt("String has UTF-16 code units that do not fit in 8 bits")),ft[v+g]=T}else for(g=0;g<A;++g)ft[v+g]=d[g];return l!==null&&l.push(we,y),y},argPackAdvance:8,readValueFromPointer:Xe,ve:function(l){we(l)}})},N:function(e,n,s){if(s=Ft(s),n===2)var l=bs,d=Ps,g=As,A=()=>Be,y=1;else n===4&&(l=Cs,d=Ts,g=_s,A=()=>_t,y=2);ge(e,{name:s,fromWireType:function(v){for(var T=_t[v>>2],O=A(),L,Y=v+4,F=0;F<=T;++F){var J=v+4+F*n;(F==T||O[J>>y]==0)&&(Y=l(Y,J-Y),L===void 0?L=Y:(L+="\0",L+=Y),Y=J+n)}return we(v),L},toWireType:function(v,T){typeof T!="string"&&wt(`Cannot pass non-string to C++ string type ${s}`);var O=g(T),L=Ni(4+O+n);return _t[L>>2]=O>>y,d(T,L+4,O+n),v!==null&&v.push(we,L),L},argPackAdvance:8,readValueFromPointer:Xe,ve:function(v){we(v)}})},C:function(e,n,s,l,d,g){mi[e]={name:Ft(n),Cf:Ut(s,l),De:Ut(d,g),Jf:[]}},e:function(e,n,s,l,d,g,A,y,v,T){mi[e].Jf.push({fg:Ft(n),mg:s,kg:Ut(l,d),lg:g,xg:A,wg:Ut(y,v),yg:T})},Db:function(e,n){n=Ft(n),ge(e,{pg:!0,name:n,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},Ab:()=>!0,pb:()=>{throw 1/0},F:function(e,n,s){e=Zt(e),n=ii(n,"emval::as");var l=[],d=te(l);return _t[s>>2]=d,n.toWireType(l,e)},X:function(e,n,s,l,d){e=Ci[e],n=Zt(n),s=Ai(s);var g=[];return _t[l>>2]=te(g),e(n,s,g,d)},x:function(e,n,s,l){e=Ci[e],n=Zt(n),s=Ai(s),e(n,s,null,l)},d:Qi,K:function(e){return e===0?te(Vn()):(e=Ai(e),te(Vn()[e]))},u:function(e,n){var s=Fs(e,n),l=s[0];n=l.name+"_$"+s.slice(1).map(function(A){return A.name}).join("_")+"$";var d=qn[n];if(d!==void 0)return d;var g=Array(e-1);return d=xs((A,y,v,T)=>{for(var O=0,L=0;L<e-1;++L)g[L]=s[L+1].readValueFromPointer(T+O),O+=s[L+1].argPackAdvance;for(A=A[y].apply(A,g),L=0;L<e-1;++L)s[L+1].cg&&s[L+1].cg(g[L]);if(!l.pg)return l.toWireType(v,A)}),qn[n]=d},z:function(e,n){return e=Zt(e),n=Zt(n),te(e[n])},p:function(e){4<e&&(Qt.get(e).Of+=1)},J:function(e,n,s,l){e=Zt(e);var d=Yn[n];return d||(d=Ms(n),Yn[n]=d),d(e,s,l)},H:function(){return te([])},g:function(e){return te(Ai(e))},G:function(){return te({})},gb:function(e){return e=Zt(e),!e},D:function(e){var n=Zt(e);ji(n),Qi(e)},l:function(e,n,s){e=Zt(e),n=Zt(n),s=Zt(s),e[n]=s},h:function(e,n){return e=ii(e,"_emval_take_value"),e=e.readValueFromPointer(n),te(e)},kb:function(){return-52},lb:function(){},a:()=>{Gi("")},zb:()=>performance.now(),sd:function(e){_.activeTexture(e)},td:function(e,n){_.attachShader(he[e],ce[n])},Yb:function(e,n){_.beginQuery(e,qt[n])},Sb:function(e,n){_.ze.beginQueryEXT(e,qt[n])},ud:function(e,n,s){_.bindAttribLocation(he[e],n,s?Fe(ft,s):"")},vd:function(e,n){e==35051?_.zf=n:e==35052&&(_.We=n),_.bindBuffer(e,Ti[n])},uc:er,vc:function(e,n){_.bindRenderbuffer(e,ni[n])},cc:function(e,n){_.bindSampler(e,Re[n])},wd:function(e,n){_.bindTexture(e,ee[n])},Pc:ir,Tc:ir,Y:function(e,n,s,l){_.blendColor(e,n,s,l)},Z:function(e){_.blendEquation(e)},_:function(e,n){_.blendFunc(e,n)},oc:function(e,n,s,l,d,g,A,y,v,T){_.blitFramebuffer(e,n,s,l,d,g,A,y,v,T)},$:function(e,n,s,l){2<=at.version?s&&n?_.bufferData(e,ft,l,s,n):_.bufferData(e,n,l):_.bufferData(e,s?ft.subarray(s,s+n):n,l)},aa:function(e,n,s,l){2<=at.version?s&&_.bufferSubData(e,n,ft,l,s):_.bufferSubData(e,n,ft.subarray(l,l+s))},wc:function(e){return _.checkFramebufferStatus(e)},ba:nr,ca:rr,da:sr,lc:function(e,n,s,l){return _.clientWaitSync(ke[e],n,(s>>>0)+4294967296*l)},ea:function(e,n,s,l){_.colorMask(!!e,!!n,!!s,!!l)},fa:function(e){_.compileShader(ce[e])},ga:function(e,n,s,l,d,g,A,y){2<=at.version?_.We||!A?_.compressedTexImage2D(e,n,s,l,d,g,A,y):_.compressedTexImage2D(e,n,s,l,d,g,ft,y,A):_.compressedTexImage2D(e,n,s,l,d,g,y?ft.subarray(y,y+A):null)},ha:function(e,n,s,l,d,g,A,y,v){2<=at.version?_.We||!y?_.compressedTexSubImage2D(e,n,s,l,d,g,A,y,v):_.compressedTexSubImage2D(e,n,s,l,d,g,A,ft,v,y):_.compressedTexSubImage2D(e,n,s,l,d,g,A,v?ft.subarray(v,v+y):null)},nc:function(e,n,s,l,d){_.copyBufferSubData(e,n,s,l,d)},ia:function(e,n,s,l,d,g,A,y){_.copyTexSubImage2D(e,n,s,l,d,g,A,y)},ja:function(){var e=Ne(he),n=_.createProgram();return n.name=e,n.sf=n.qf=n.rf=0,n.Ef=1,he[e]=n,e},ka:function(e){var n=Ne(ce);return ce[n]=_.createShader(e),n},la:function(e){_.cullFace(e)},ma:function(e,n){for(var s=0;s<e;s++){var l=W[n+4*s>>2],d=Ti[l];d&&(_.deleteBuffer(d),d.name=0,Ti[l]=null,l==_.zf&&(_.zf=0),l==_.We&&(_.We=0))}},xc:function(e,n){for(var s=0;s<e;++s){var l=W[n+4*s>>2],d=_i[l];d&&(_.deleteFramebuffer(d),d.name=0,_i[l]=null)}},na:function(e){if(e){var n=he[e];n?(_.deleteProgram(n),n.name=0,he[e]=null):St(1281)}},Zb:function(e,n){for(var s=0;s<e;s++){var l=W[n+4*s>>2],d=qt[l];d&&(_.deleteQuery(d),qt[l]=null)}},Tb:function(e,n){for(var s=0;s<e;s++){var l=W[n+4*s>>2],d=qt[l];d&&(_.ze.deleteQueryEXT(d),qt[l]=null)}},yc:function(e,n){for(var s=0;s<e;s++){var l=W[n+4*s>>2],d=ni[l];d&&(_.deleteRenderbuffer(d),d.name=0,ni[l]=null)}},dc:function(e,n){for(var s=0;s<e;s++){var l=W[n+4*s>>2],d=Re[l];d&&(_.deleteSampler(d),d.name=0,Re[l]=null)}},oa:function(e){if(e){var n=ce[e];n?(_.deleteShader(n),ce[e]=null):St(1281)}},mc:function(e){if(e){var n=ke[e];n?(_.deleteSync(n),n.name=0,ke[e]=null):St(1281)}},pa:function(e,n){for(var s=0;s<e;s++){var l=W[n+4*s>>2],d=ee[l];d&&(_.deleteTexture(d),d.name=0,ee[l]=null)}},Qc:ar,Uc:ar,qa:function(e){_.depthMask(!!e)},ra:function(e){_.disable(e)},sa:function(e){_.disableVertexAttribArray(e)},ta:function(e,n,s){_.drawArrays(e,n,s)},Nc:function(e,n,s,l){_.drawArraysInstanced(e,n,s,l)},Lc:function(e,n,s,l,d){_.If.drawArraysInstancedBaseInstanceWEBGL(e,n,s,l,d)},Jc:function(e,n){for(var s=Fi[e],l=0;l<e;l++)s[l]=W[n+4*l>>2];_.drawBuffers(s)},ua:or,Oc:function(e,n,s,l,d){_.drawElementsInstanced(e,n,s,l,d)},Mc:function(e,n,s,l,d,g,A){_.If.drawElementsInstancedBaseVertexBaseInstanceWEBGL(e,n,s,l,d,g,A)},Dc:function(e,n,s,l,d,g){or(e,l,d,g)},va:function(e){_.enable(e)},wa:function(e){_.enableVertexAttribArray(e)},_b:function(e){_.endQuery(e)},Ub:function(e){_.ze.endQueryEXT(e)},ic:function(e,n){return(e=_.fenceSync(e,n))?(n=Ne(ke),e.name=n,ke[n]=e,n):0},xa:function(){_.finish()},ya:function(){_.flush()},zc:function(e,n,s,l){_.framebufferRenderbuffer(e,n,s,ni[l])},Ac:function(e,n,s,l,d){_.framebufferTexture2D(e,n,s,ee[l],d)},za:function(e){_.frontFace(e)},Aa:function(e,n){Ie(e,n,"createBuffer",Ti)},Bc:function(e,n){Ie(e,n,"createFramebuffer",_i)},$b:function(e,n){Ie(e,n,"createQuery",qt)},Vb:function(e,n){for(var s=0;s<e;s++){var l=_.ze.createQueryEXT();if(!l){for(St(1282);s<e;)W[n+4*s++>>2]=0;break}var d=Ne(qt);l.name=d,qt[d]=l,W[n+4*s>>2]=d}},Cc:function(e,n){Ie(e,n,"createRenderbuffer",ni)},ec:function(e,n){Ie(e,n,"createSampler",Re)},Ba:function(e,n){Ie(e,n,"createTexture",ee)},Rc:lr,Vc:lr,qc:function(e){_.generateMipmap(e)},Ca:function(e,n,s){s?W[s>>2]=_.getBufferParameter(e,n):St(1281)},Da:function(){var e=_.getError()||xi;return xi=0,e},Ea:function(e,n){cr(e,n,2)},rc:function(e,n,s,l){e=_.getFramebufferAttachmentParameter(e,n,s),(e instanceof WebGLRenderbuffer||e instanceof WebGLTexture)&&(e=e.name|0),W[l>>2]=e},Fa:ur,Ga:function(e,n,s,l){e=_.getProgramInfoLog(he[e]),e===null&&(e="(unknown error)"),n=0<n&&l?oe(e,ft,l,n):0,s&&(W[s>>2]=n)},Ha:function(e,n,s){if(s)if(e>=Xn)St(1281);else if(e=he[e],n==35716)e=_.getProgramInfoLog(e),e===null&&(e="(unknown error)"),W[s>>2]=e.length+1;else if(n==35719){if(!e.sf)for(n=0;n<_.getProgramParameter(e,35718);++n)e.sf=Math.max(e.sf,_.getActiveUniform(e,n).name.length+1);W[s>>2]=e.sf}else if(n==35722){if(!e.qf)for(n=0;n<_.getProgramParameter(e,35721);++n)e.qf=Math.max(e.qf,_.getActiveAttrib(e,n).name.length+1);W[s>>2]=e.qf}else if(n==35381){if(!e.rf)for(n=0;n<_.getProgramParameter(e,35382);++n)e.rf=Math.max(e.rf,_.getActiveUniformBlockName(e,n).length+1);W[s>>2]=e.rf}else W[s>>2]=_.getProgramParameter(e,n);else St(1281)},Pb:dr,Qb:dr,ac:function(e,n,s){if(s){e=_.getQueryParameter(qt[e],n);var l;typeof e=="boolean"?l=e?1:0:l=e,W[s>>2]=l}else St(1281)},Wb:function(e,n,s){if(s){e=_.ze.getQueryObjectEXT(qt[e],n);var l;typeof e=="boolean"?l=e?1:0:l=e,W[s>>2]=l}else St(1281)},bc:function(e,n,s){s?W[s>>2]=_.getQuery(e,n):St(1281)},Xb:function(e,n,s){s?W[s>>2]=_.ze.getQueryEXT(e,n):St(1281)},sc:function(e,n,s){s?W[s>>2]=_.getRenderbufferParameter(e,n):St(1281)},Ia:function(e,n,s,l){e=_.getShaderInfoLog(ce[e]),e===null&&(e="(unknown error)"),n=0<n&&l?oe(e,ft,l,n):0,s&&(W[s>>2]=n)},Mb:function(e,n,s,l){e=_.getShaderPrecisionFormat(e,n),W[s>>2]=e.rangeMin,W[s+4>>2]=e.rangeMax,W[l>>2]=e.precision},Ja:function(e,n,s){s?n==35716?(e=_.getShaderInfoLog(ce[e]),e===null&&(e="(unknown error)"),W[s>>2]=e?e.length+1:0):n==35720?(e=_.getShaderSource(ce[e]),W[s>>2]=e?e.length+1:0):W[s>>2]=_.getShaderParameter(ce[e],n):St(1281)},Ka:fr,Sc:pr,La:function(e,n){if(n=n?Fe(ft,n):"",e=he[e]){var s=e,l=s.ff,d=s.Qf,g;if(!l)for(s.ff=l={},s.Pf={},g=0;g<_.getProgramParameter(s,35718);++g){var A=_.getActiveUniform(s,g),y=A.name;A=A.size;var v=gr(y);v=0<v?y.slice(0,v):y;var T=s.Ef;for(s.Ef+=A,d[v]=[A,T],y=0;y<A;++y)l[T]=y,s.Pf[T++]=v}if(s=e.ff,l=0,d=n,g=gr(n),0<g&&(l=parseInt(n.slice(g+1))>>>0,d=n.slice(0,g)),(d=e.Qf[d])&&l<d[0]&&(l+=d[1],s[l]=s[l]||_.getUniformLocation(e,n)))return l}else St(1281);return-1},Nb:function(e,n,s){for(var l=Fi[n],d=0;d<n;d++)l[d]=W[s+4*d>>2];_.invalidateFramebuffer(e,l)},Ob:function(e,n,s,l,d,g,A){for(var y=Fi[n],v=0;v<n;v++)y[v]=W[s+4*v>>2];_.invalidateSubFramebuffer(e,y,l,d,g,A)},jc:function(e){return _.isSync(ke[e])},Ma:function(e){return(e=ee[e])?_.isTexture(e):0},Na:function(e){_.lineWidth(e)},Oa:function(e){e=he[e],_.linkProgram(e),e.ff=0,e.Qf={}},Hc:function(e,n,s,l,d,g){_.Mf.multiDrawArraysInstancedBaseInstanceWEBGL(e,W,n>>2,W,s>>2,W,l>>2,_t,d>>2,g)},Ic:function(e,n,s,l,d,g,A,y){_.Mf.multiDrawElementsInstancedBaseVertexBaseInstanceWEBGL(e,W,n>>2,s,W,l>>2,W,d>>2,W,g>>2,_t,A>>2,y)},Pa:function(e,n){e==3317&&(Zn=n),_.pixelStorei(e,n)},Rb:function(e,n){_.ze.queryCounterEXT(qt[e],n)},Kc:function(e){_.readBuffer(e)},Qa:function(e,n,s,l,d,g,A){if(2<=at.version)if(_.zf)_.readPixels(e,n,s,l,d,g,A);else{var y=Mi(g);_.readPixels(e,n,s,l,d,g,y,A>>31-Math.clz32(y.BYTES_PER_ELEMENT))}else(A=tn(g,d,s,l,A))?_.readPixels(e,n,s,l,d,g,A):St(1280)},tc:function(e,n,s,l){_.renderbufferStorage(e,n,s,l)},pc:function(e,n,s,l,d){_.renderbufferStorageMultisample(e,n,s,l,d)},fc:function(e,n,s){_.samplerParameterf(Re[e],n,s)},gc:function(e,n,s){_.samplerParameteri(Re[e],n,s)},hc:function(e,n,s){_.samplerParameteri(Re[e],n,W[s>>2])},Ra:function(e,n,s,l){_.scissor(e,n,s,l)},Sa:function(e,n,s,l){for(var d="",g=0;g<n;++g){var A=l?W[l+4*g>>2]:-1,y=W[s+4*g>>2];A=y?Fe(ft,y,0>A?void 0:A):"",d+=A}_.shaderSource(ce[e],d)},Ta:function(e,n,s){_.stencilFunc(e,n,s)},Ua:function(e,n,s,l){_.stencilFuncSeparate(e,n,s,l)},Va:function(e){_.stencilMask(e)},Wa:function(e,n){_.stencilMaskSeparate(e,n)},Xa:function(e,n,s){_.stencilOp(e,n,s)},Ya:function(e,n,s,l){_.stencilOpSeparate(e,n,s,l)},Za:function(e,n,s,l,d,g,A,y,v){if(2<=at.version)if(_.We)_.texImage2D(e,n,s,l,d,g,A,y,v);else if(v){var T=Mi(y);_.texImage2D(e,n,s,l,d,g,A,y,T,v>>31-Math.clz32(T.BYTES_PER_ELEMENT))}else _.texImage2D(e,n,s,l,d,g,A,y,null);else _.texImage2D(e,n,s,l,d,g,A,y,v?tn(y,A,l,d,v):null)},_a:function(e,n,s){_.texParameterf(e,n,s)},$a:function(e,n,s){_.texParameterf(e,n,it[s>>2])},ab:function(e,n,s){_.texParameteri(e,n,s)},bb:function(e,n,s){_.texParameteri(e,n,W[s>>2])},Ec:function(e,n,s,l,d){_.texStorage2D(e,n,s,l,d)},cb:function(e,n,s,l,d,g,A,y,v){if(2<=at.version)if(_.We)_.texSubImage2D(e,n,s,l,d,g,A,y,v);else if(v){var T=Mi(y);_.texSubImage2D(e,n,s,l,d,g,A,y,T,v>>31-Math.clz32(T.BYTES_PER_ELEMENT))}else _.texSubImage2D(e,n,s,l,d,g,A,y,null);else T=null,v&&(T=tn(y,A,d,g,v)),_.texSubImage2D(e,n,s,l,d,g,A,y,T)},db:function(e,n){_.uniform1f(At(e),n)},eb:function(e,n,s){if(2<=at.version)n&&_.uniform1fv(At(e),it,s>>2,n);else{if(288>=n)for(var l=Te[n-1],d=0;d<n;++d)l[d]=it[s+4*d>>2];else l=it.subarray(s>>2,s+4*n>>2);_.uniform1fv(At(e),l)}},od:function(e,n){_.uniform1i(At(e),n)},pd:function(e,n,s){if(2<=at.version)n&&_.uniform1iv(At(e),W,s>>2,n);else{if(288>=n)for(var l=si[n-1],d=0;d<n;++d)l[d]=W[s+4*d>>2];else l=W.subarray(s>>2,s+4*n>>2);_.uniform1iv(At(e),l)}},qd:function(e,n,s){_.uniform2f(At(e),n,s)},rd:function(e,n,s){if(2<=at.version)n&&_.uniform2fv(At(e),it,s>>2,2*n);else{if(144>=n)for(var l=Te[2*n-1],d=0;d<2*n;d+=2)l[d]=it[s+4*d>>2],l[d+1]=it[s+(4*d+4)>>2];else l=it.subarray(s>>2,s+8*n>>2);_.uniform2fv(At(e),l)}},nd:function(e,n,s){_.uniform2i(At(e),n,s)},md:function(e,n,s){if(2<=at.version)n&&_.uniform2iv(At(e),W,s>>2,2*n);else{if(144>=n)for(var l=si[2*n-1],d=0;d<2*n;d+=2)l[d]=W[s+4*d>>2],l[d+1]=W[s+(4*d+4)>>2];else l=W.subarray(s>>2,s+8*n>>2);_.uniform2iv(At(e),l)}},ld:function(e,n,s,l){_.uniform3f(At(e),n,s,l)},kd:function(e,n,s){if(2<=at.version)n&&_.uniform3fv(At(e),it,s>>2,3*n);else{if(96>=n)for(var l=Te[3*n-1],d=0;d<3*n;d+=3)l[d]=it[s+4*d>>2],l[d+1]=it[s+(4*d+4)>>2],l[d+2]=it[s+(4*d+8)>>2];else l=it.subarray(s>>2,s+12*n>>2);_.uniform3fv(At(e),l)}},jd:function(e,n,s,l){_.uniform3i(At(e),n,s,l)},id:function(e,n,s){if(2<=at.version)n&&_.uniform3iv(At(e),W,s>>2,3*n);else{if(96>=n)for(var l=si[3*n-1],d=0;d<3*n;d+=3)l[d]=W[s+4*d>>2],l[d+1]=W[s+(4*d+4)>>2],l[d+2]=W[s+(4*d+8)>>2];else l=W.subarray(s>>2,s+12*n>>2);_.uniform3iv(At(e),l)}},hd:function(e,n,s,l,d){_.uniform4f(At(e),n,s,l,d)},gd:function(e,n,s){if(2<=at.version)n&&_.uniform4fv(At(e),it,s>>2,4*n);else{if(72>=n){var l=Te[4*n-1],d=it;s>>=2;for(var g=0;g<4*n;g+=4){var A=s+g;l[g]=d[A],l[g+1]=d[A+1],l[g+2]=d[A+2],l[g+3]=d[A+3]}}else l=it.subarray(s>>2,s+16*n>>2);_.uniform4fv(At(e),l)}},Wc:function(e,n,s,l,d){_.uniform4i(At(e),n,s,l,d)},Xc:function(e,n,s){if(2<=at.version)n&&_.uniform4iv(At(e),W,s>>2,4*n);else{if(72>=n)for(var l=si[4*n-1],d=0;d<4*n;d+=4)l[d]=W[s+4*d>>2],l[d+1]=W[s+(4*d+4)>>2],l[d+2]=W[s+(4*d+8)>>2],l[d+3]=W[s+(4*d+12)>>2];else l=W.subarray(s>>2,s+16*n>>2);_.uniform4iv(At(e),l)}},Yc:function(e,n,s,l){if(2<=at.version)n&&_.uniformMatrix2fv(At(e),!!s,it,l>>2,4*n);else{if(72>=n)for(var d=Te[4*n-1],g=0;g<4*n;g+=4)d[g]=it[l+4*g>>2],d[g+1]=it[l+(4*g+4)>>2],d[g+2]=it[l+(4*g+8)>>2],d[g+3]=it[l+(4*g+12)>>2];else d=it.subarray(l>>2,l+16*n>>2);_.uniformMatrix2fv(At(e),!!s,d)}},Zc:function(e,n,s,l){if(2<=at.version)n&&_.uniformMatrix3fv(At(e),!!s,it,l>>2,9*n);else{if(32>=n)for(var d=Te[9*n-1],g=0;g<9*n;g+=9)d[g]=it[l+4*g>>2],d[g+1]=it[l+(4*g+4)>>2],d[g+2]=it[l+(4*g+8)>>2],d[g+3]=it[l+(4*g+12)>>2],d[g+4]=it[l+(4*g+16)>>2],d[g+5]=it[l+(4*g+20)>>2],d[g+6]=it[l+(4*g+24)>>2],d[g+7]=it[l+(4*g+28)>>2],d[g+8]=it[l+(4*g+32)>>2];else d=it.subarray(l>>2,l+36*n>>2);_.uniformMatrix3fv(At(e),!!s,d)}},_c:function(e,n,s,l){if(2<=at.version)n&&_.uniformMatrix4fv(At(e),!!s,it,l>>2,16*n);else{if(18>=n){var d=Te[16*n-1],g=it;l>>=2;for(var A=0;A<16*n;A+=16){var y=l+A;d[A]=g[y],d[A+1]=g[y+1],d[A+2]=g[y+2],d[A+3]=g[y+3],d[A+4]=g[y+4],d[A+5]=g[y+5],d[A+6]=g[y+6],d[A+7]=g[y+7],d[A+8]=g[y+8],d[A+9]=g[y+9],d[A+10]=g[y+10],d[A+11]=g[y+11],d[A+12]=g[y+12],d[A+13]=g[y+13],d[A+14]=g[y+14],d[A+15]=g[y+15]}}else d=it.subarray(l>>2,l+64*n>>2);_.uniformMatrix4fv(At(e),!!s,d)}},$c:function(e){e=he[e],_.useProgram(e),_.bg=e},ad:function(e,n){_.vertexAttrib1f(e,n)},bd:function(e,n){_.vertexAttrib2f(e,it[n>>2],it[n+4>>2])},cd:function(e,n){_.vertexAttrib3f(e,it[n>>2],it[n+4>>2],it[n+8>>2])},dd:function(e,n){_.vertexAttrib4f(e,it[n>>2],it[n+4>>2],it[n+8>>2],it[n+12>>2])},Fc:function(e,n){_.vertexAttribDivisor(e,n)},Gc:function(e,n,s,l,d){_.vertexAttribIPointer(e,n,s,l,d)},ed:function(e,n,s,l,d,g){_.vertexAttribPointer(e,n,s,!!l,d,g)},fd:function(e,n,s,l){_.viewport(e,n,s,l)},kc:function(e,n,s,l){_.waitSync(ke[e],n,(s>>>0)+4294967296*l)},qb:e=>{var n=ft.length;if(e>>>=0,2147483648<e)return!1;for(var s=1;4>=s;s*=2){var l=n*(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)-gi.buffer.byteLength+65535>>>16;try{gi.grow(d),_n();var g=1;break t}catch{}g=void 0}if(g)return!0}return!1},hb:function(){return at?at.handle:0},rb:(e,n)=>{var s=0;return mr().forEach(function(l,d){var g=n+s;for(d=_t[e+4*d>>2]=g,g=0;g<l.length;++g)pe[d++>>0]=l.charCodeAt(g);pe[d>>0]=0,s+=l.length+1}),0},sb:(e,n)=>{var s=mr();_t[e>>2]=s.length;var l=0;return s.forEach(function(d){l+=d.length+1}),_t[n>>2]=l,0},Eb:e=>{q(e,new cs(e))},M:()=>52,jb:function(){return 52},xb:()=>52,mb:function(){return 70},Q:(e,n,s,l)=>{for(var d=0,g=0;g<s;g++){var A=_t[n>>2],y=_t[n+4>>2];n+=8;for(var v=0;v<y;v++){var T=ft[A+v],O=zs[e];T===0||T===10?((e===1?ut:Pe)(Fe(O,0)),O.length=0):O.push(T)}d+=y}return _t[l>>2]=d,0},yd:er,ib:nr,xd:rr,Kb:sr,L:ur,P:fr,fb:pr,Ib:Zs,j:qs,o:Js,k:Ws,I:na,Hb:ta,Fb:sa,W:ea,V:ra,O:Vs,i:Xs,w:Ks,v:Hs,s:Ys,Gb:ia,Jb:Qs,Lb:js,ob:(e,n,s,l)=>Bs(e,n,s,l)};(function(){function e(s){if(Pt=s=s.exports,gi=Pt.zd,_n(),Mt=Pt.Cd,xn.unshift(Pt.Ad),xe--,c.monitorRunDependencies&&c.monitorRunDependencies(xe),xe==0&&Ye){var l=Ye;Ye=null,l()}return s}var n={a:Gs};if(xe++,c.monitorRunDependencies&&c.monitorRunDependencies(xe),c.instantiateWasm)try{return c.instantiateWasm(n,e)}catch(s){Pe("Module.instantiateWasm callback failed with error: "+s),x(s)}return hs(n,function(s){e(s.instance)}).catch(x),{}})();var Ni=c._malloc=e=>(Ni=c._malloc=Pt.Bd)(e),we=c._free=e=>(we=c._free=Pt.Dd)(e),Sr=e=>(Sr=Pt.Ed)(e);c.__embind_initialize_bindings=()=>(c.__embind_initialize_bindings=Pt.Fd)();var It=(e,n)=>(It=Pt.Gd)(e,n),Ot=()=>(Ot=Pt.Hd)(),Dt=e=>(Dt=Pt.Id)(e);c.dynCall_viji=(e,n,s,l,d)=>(c.dynCall_viji=Pt.Jd)(e,n,s,l,d),c.dynCall_vijiii=(e,n,s,l,d,g,A)=>(c.dynCall_vijiii=Pt.Kd)(e,n,s,l,d,g,A),c.dynCall_viiiiij=(e,n,s,l,d,g,A,y)=>(c.dynCall_viiiiij=Pt.Ld)(e,n,s,l,d,g,A,y),c.dynCall_jii=(e,n,s)=>(c.dynCall_jii=Pt.Md)(e,n,s),c.dynCall_vij=(e,n,s,l)=>(c.dynCall_vij=Pt.Nd)(e,n,s,l),c.dynCall_jiiiiii=(e,n,s,l,d,g,A)=>(c.dynCall_jiiiiii=Pt.Od)(e,n,s,l,d,g,A),c.dynCall_jiiiiji=(e,n,s,l,d,g,A,y)=>(c.dynCall_jiiiiji=Pt.Pd)(e,n,s,l,d,g,A,y),c.dynCall_ji=(e,n)=>(c.dynCall_ji=Pt.Qd)(e,n),c.dynCall_iijj=(e,n,s,l,d,g)=>(c.dynCall_iijj=Pt.Rd)(e,n,s,l,d,g),c.dynCall_iiiji=(e,n,s,l,d,g)=>(c.dynCall_iiiji=Pt.Sd)(e,n,s,l,d,g),c.dynCall_iiji=(e,n,s,l,d)=>(c.dynCall_iiji=Pt.Td)(e,n,s,l,d),c.dynCall_iijjiii=(e,n,s,l,d,g,A,y,v)=>(c.dynCall_iijjiii=Pt.Ud)(e,n,s,l,d,g,A,y,v),c.dynCall_iij=(e,n,s,l)=>(c.dynCall_iij=Pt.Vd)(e,n,s,l),c.dynCall_vijjjii=(e,n,s,l,d,g,A,y,v,T)=>(c.dynCall_vijjjii=Pt.Wd)(e,n,s,l,d,g,A,y,v,T),c.dynCall_jiji=(e,n,s,l,d)=>(c.dynCall_jiji=Pt.Xd)(e,n,s,l,d),c.dynCall_viijii=(e,n,s,l,d,g,A)=>(c.dynCall_viijii=Pt.Yd)(e,n,s,l,d,g,A),c.dynCall_iiiiij=(e,n,s,l,d,g,A)=>(c.dynCall_iiiiij=Pt.Zd)(e,n,s,l,d,g,A),c.dynCall_iiiiijj=(e,n,s,l,d,g,A,y,v)=>(c.dynCall_iiiiijj=Pt._d)(e,n,s,l,d,g,A,y,v),c.dynCall_iiiiiijj=(e,n,s,l,d,g,A,y,v,T)=>(c.dynCall_iiiiiijj=Pt.$d)(e,n,s,l,d,g,A,y,v,T);function Ws(e,n,s,l){var d=Ot();try{return Mt.get(e)(n,s,l)}catch(g){if(Dt(d),g!==g+0)throw g;It(1,0)}}function js(e,n,s,l,d,g,A,y,v,T){var O=Ot();try{Mt.get(e)(n,s,l,d,g,A,y,v,T)}catch(L){if(Dt(O),L!==L+0)throw L;It(1,0)}}function Hs(e,n,s,l){var d=Ot();try{Mt.get(e)(n,s,l)}catch(g){if(Dt(d),g!==g+0)throw g;It(1,0)}}function Ks(e,n,s){var l=Ot();try{Mt.get(e)(n,s)}catch(d){if(Dt(l),d!==d+0)throw d;It(1,0)}}function Vs(e){var n=Ot();try{Mt.get(e)()}catch(s){if(Dt(n),s!==s+0)throw s;It(1,0)}}function qs(e,n){var s=Ot();try{return Mt.get(e)(n)}catch(l){if(Dt(s),l!==l+0)throw l;It(1,0)}}function Ys(e,n,s,l,d){var g=Ot();try{Mt.get(e)(n,s,l,d)}catch(A){if(Dt(g),A!==A+0)throw A;It(1,0)}}function Xs(e,n){var s=Ot();try{Mt.get(e)(n)}catch(l){if(Dt(s),l!==l+0)throw l;It(1,0)}}function Js(e,n,s){var l=Ot();try{return Mt.get(e)(n,s)}catch(d){if(Dt(l),d!==d+0)throw d;It(1,0)}}function Qs(e,n,s,l,d,g,A){var y=Ot();try{Mt.get(e)(n,s,l,d,g,A)}catch(v){if(Dt(y),v!==v+0)throw v;It(1,0)}}function Zs(e){var n=Ot();try{return Mt.get(e)()}catch(s){if(Dt(n),s!==s+0)throw s;It(1,0)}}function ta(e,n,s,l,d,g){var A=Ot();try{return Mt.get(e)(n,s,l,d,g)}catch(y){if(Dt(A),y!==y+0)throw y;It(1,0)}}function ea(e,n,s,l,d,g,A,y){var v=Ot();try{return Mt.get(e)(n,s,l,d,g,A,y)}catch(T){if(Dt(v),T!==T+0)throw T;It(1,0)}}function ia(e,n,s,l,d,g){var A=Ot();try{Mt.get(e)(n,s,l,d,g)}catch(y){if(Dt(A),y!==y+0)throw y;It(1,0)}}function na(e,n,s,l,d){var g=Ot();try{return Mt.get(e)(n,s,l,d)}catch(A){if(Dt(g),A!==A+0)throw A;It(1,0)}}function ra(e,n,s,l,d,g,A,y,v,T){var O=Ot();try{return Mt.get(e)(n,s,l,d,g,A,y,v,T)}catch(L){if(Dt(O),L!==L+0)throw L;It(1,0)}}function sa(e,n,s,l,d,g,A){var y=Ot();try{return Mt.get(e)(n,s,l,d,g,A)}catch(v){if(Dt(y),v!==v+0)throw v;It(1,0)}}var Ii;Ye=function e(){Ii||br(),Ii||(Ye=e)};function br(){function e(){if(!Ii&&(Ii=!0,c.calledRun=!0,!Cn)){if(Wi(xn),S(c),c.onRuntimeInitialized&&c.onRuntimeInitialized(),c.postRun)for(typeof c.postRun=="function"&&(c.postRun=[c.postRun]);c.postRun.length;){var n=c.postRun.shift();Fn.unshift(n)}Wi(Fn)}}if(!(0<xe)){if(c.preRun)for(typeof c.preRun=="function"&&(c.preRun=[c.preRun]);c.preRun.length;)os();Wi(En),0<xe||(c.setStatus?(c.setStatus("Running..."),setTimeout(function(){setTimeout(function(){c.setStatus("")},1),e()},1)):e())}}if(c.preInit)for(typeof c.preInit=="function"&&(c.preInit=[c.preInit]);0<c.preInit.length;)c.preInit.pop()();return br(),h.ready}})();m.exports=i}(mn)),mn.exports}var Ta=Ca(),_a=ga(Ta);class Ke{static slide(t){let i=De.linear;return typeof t.easing=="string"?i=De.fromTypeAsString(t.easing):t.easing!==void 0&&(i=t.easing),new es(t.direction,t.duration,i)}static none(){return new ts}}class ts extends Ke{constructor(){super(),this.type=Se.None,this.duration=NaN,this.easing=De.none}}class es extends Ke{constructor(t,i,r){super(),this.type=Se.Slide,this.direction=t,this.duration=i,this.easing=r}}const Se={Slide:"Slide",None:"None"},be={Up:"Up",Down:"Down",Right:"Right",Left:"Left"};class is{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 Pn{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 r="no webgl context";if(!i)return r;const h=i.getExtension("WEBGL_debug_renderer_info");return h!=null?r=String(i.getParameter(h.UNMASKED_VENDOR_WEBGL))+", "+String(i.getParameter(h.UNMASKED_RENDERER_WEBGL)):r="no debug renderer info",t.remove(),r}static dispose(){const t=document.getElementById("webgl-renderer-info-canvas");t&&t.remove()}}class ns{constructor(t,i){this.sounds={},this.game=t,this.baseUrls=i}get audioContext(){if(!this._audioContext){if(!navigator.userActivation.hasBeenActive)throw new C("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 r=i.url;V.urlHasScheme(i.url)||(r=V.getUrlFromManifest(this.game,`${this.baseUrls.assets}/${i.url}`));const h={soundName:i.soundName,data:void 0,audioBuffer:void 0,audioBufferSource:void 0,url:r,status:i.lazy?jt.Deferred:jt.WillFetch};this.sounds[i.soundName]&&console.warn(`A sound named ${i.soundName} has already been loaded. It will be replaced.`),this.sounds[i.soundName]=h}),this.fetchSounds())}async fetchSounds(){const t=Object.values(this.sounds).map(i=>i.status===jt.WillFetch?(i.status=jt.Fetching,fetch(i.url).then(r=>{if(!r.ok)throw i.status=jt.Error,new C(`cannot fetch sound ${i.soundName} at url ${i.url}: ${r.statusText}`);return r.arrayBuffer().then(h=>{i.data=h,i.status=jt.Fetched,console.log(`\u26AA sound fetched. name: ${i.soundName}, bytes: ${h.byteLength}`)})})):Promise.resolve());await Promise.all(t)}fetchDeferredSound(t){return t.status=jt.WillFetch,this.fetchSounds()}hasSoundsToDecode(){return Object.values(this.sounds).filter(t=>t.status===jt.Fetched).length>0}decodeFetchedSounds(){const i=Object.values(this.sounds).filter(r=>r.status===jt.Fetched).map(r=>this.decodeSound(r));return Promise.all(i)}async decodeSound(t){if(!t.data)throw new C(`data is undefined for sound ${t.soundName} (url ${t.url})`);try{t.status=jt.Decoding;const i=await this.audioContext.decodeAudioData(t.data);t.audioBuffer=i,t.status=jt.Ready,console.log(`\u26AA sound decoded. name: ${t.soundName}, duration (seconds): ${i.duration}`)}catch{throw t.status=jt.Error,new C(`error decoding sound ${t.soundName} (url: ${t.url})`)}}getSound(t){const i=this.sounds[t];if(!i)throw new C(`getSound(): sound ${t} not found`);return i}dispose(){}getSoundNames(){return Object.keys(this.sounds)}}class Ea{constructor(t){this.game=t.game,this.nodeFactory=t.nodeFactory,this.freeNodesScene=t.freeNodesScene,this.configureI18n=t.configureI18n,this.eventMaterializers=new Map([[H.NodeNew,this.materializeNodeNewEvent.bind(this)],[H.Composite,this.materializeCompositeEvent.bind(this)],[H.ScenePresent,this.materializeScenePresentEvent.bind(this)],[H.NodePropertyChange,this.materializeNodePropertyChangeEvent.bind(this)],[H.NodeAddChild,this.materializeNodeAddChildEvent.bind(this)],[H.NodeRemoveChild,this.materializeNodeRemoveChildEvent.bind(this)],[H.DomPointerDown,this.materializeDomPointerDownEvent.bind(this)],[H.BrowserImageDataReady,this.materializeBrowserImageDataReadyEvent.bind(this)],[H.I18nDataReadyEvent,this.materializeI18nDataReadyEvent.bind(this)]])}materialize(t){t.length>0&&(console.log(`Replaying ${t.length} events`),t.forEach(i=>{const r=this.eventMaterializers.get(i.type);r?r(i):console.log(`EventMaterializer unhandled event: ${i.type}`)}))}materializeCompositeEvent(t){const i=this.game.materializedNodes.find(r=>r.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===dt.Composite)i.handleCompositeEvent(t);else throw new C(`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===dt.Scene&&(i.name===Q.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(r=>r.uuid===t.uuid);if(!i)throw new C(`EventMaterializer: node with uuid ${t.uuid} not found`);if(t.property in i)i[t.property]=t.value;else throw new C(`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(h=>h.uuid===t.uuid);if(!i)throw new C(`EventMaterializer: parent node with uuid ${t.uuid} not found`);const r=this.game.materializedNodes.find(h=>h.uuid===t.childUuid);if(!r)throw new C(`EventMaterializer: child node with uuid ${t.childUuid} not found`);i.addChild(r)}materializeNodeRemoveChildEvent(t){const i=this.game.materializedNodes.find(h=>h.uuid===t.uuid);if(!i)throw new C(`EventMaterializer: parent node with uuid ${t.uuid} not found`);const r=this.game.materializedNodes.find(h=>h.uuid===t.childUuid);if(!r)throw new C(`EventMaterializer: child node with uuid ${t.childUuid} not found`);i.removeChild(r)}materializeDomPointerDownEvent(t){this.game.currentScene?.run(X.custom({callback:()=>{const i=new fi({circleOfRadius:16,fillColor:R.LightGray,strokeColor:R.Black,lineWidth:2,alpha:.75,position:{x:t.x,y:t.y}});this.game.currentScene?.addChild(i),i.run(X.sequence([X.group([X.fadeAlpha({duration:750,alpha:0}),X.scale({duration:750,scale:0})]),X.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=Ke.none();if(t.transitionType===Se.Slide){if(t.direction===void 0)throw new C("EventMaterializer: ScenePresentEvent direction is undefined for slide transition");if(t.duration===void 0)throw new C("EventMaterializer: ScenePresentEvent duration is undefined for slide transition");if(t.easingType===void 0)throw new C("EventMaterializer: ScenePresentEvent easingType is undefined for slide transition");const r=this.game.materializedNodes.find(h=>h.uuid===t.uuid);if(!r)throw new C(`EventMaterializer: Scene with uuid ${t.uuid} not found`);switch(t.direction){case be.Left:{r.position.x=r.size.width;break}case be.Right:{r.position.x=-r.size.width;break}case be.Up:{r.position.y=r.size.height;break}case be.Down:{r.position.y=-r.size.height;break}}i=Ke.slide({direction:t.direction,duration:t.duration,easing:De.fromTypeAsString(t.easingType)})}this.game.presentScene(t.uuid,i)}}class xa{constructor(t){if(this.type=ui.Game,this.sessionUuid="",this.uuid=ze.generate(),this.publishUuid="",this.canvasKitWasmVersion="0.40.0",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 $r,this.nodeFactory=new Gr,this.materializedNodes=new Array,this.data={trials:new Array,scoring:{}},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 Ve({name:Q.FREE_NODES_SCENE_NAME,backgroundColor:[255,255,255,0]}),this.incomingSceneTransitions=new Array,this.replayEventsButtonEnabled=!0,this.automaticScoringSchema={data_type:{type:"string",description:"Type of data."},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.automaticTrialSchema={data_type:{type:"string",description:"Type of data."},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 C("id is required in GameOptions");if(!ze.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??Q.FPS_METRIC_REPORT_THRESHOLD,this.maximumRecordedActivityMetrics=t.maximumRecordedActivityMetrics??Q.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={}),this.options.scoringSchema||(this.options.scoringSchema={}),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:Q.FREE_NODES_SCENE_NAME,backgroundColor:[255,255,255,0],uuid:this.freeNodesScene.uuid},i={type:H.NodeNew,target:this.freeNodesScene,nodeType:dt.Scene,...V.createFrameUpdateTimestamps(),nodeOptions:t,sequence:m2c2Globals.eventSequence};this.eventStore.addEvent(i)}getImportedModuleBaseUrl(t,i){const r=new RegExp(`^.*${t}[^\\/]*`),h=i.match(r);if(!h||h.length===0)throw new C(`Could not calculate imported assessment package base URL. Package name: ${t}, module URL: ${i}`);return h[0]}addLocalizationParametersToGameParameters(){this.options.parameters={...this.options.parameters,...zi.makeLocalizationParameters()}}async init(){return this.initialize()}loadCanvasKit(t){return _a({locateFile:()=>t})}async resolveGameBaseUrls(t){let i,r=!1,h=`assets/${t.id}`;if(t.moduleMetadata.name)try{i=await import.meta.resolve(t.moduleMetadata.name),h=t.getImportedModuleBaseUrl(t.moduleMetadata.name,i)+"/assets",r=!0}catch{}let c=`assets/${t.id}`;try{const S=await import.meta.resolve("@m2c2kit/core");c=t.getImportedModuleBaseUrl("@m2c2kit/core",S)+"/assets"}catch{if(r)throw new C(`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:h,canvasKitWasm:c}}async configureI18n(t){if(this.i18n=new zi(this,t),!this.i18n)throw new C("I18n object is undefined");await this.i18n.initialize(),this.eventStore.addEvent({type:"I18nDataReadyEvent",target:this.i18n,localizationOptions:t,...V.createFrameUpdateTimestamps()})}async waitForErudaInitialization(t=5e3){await new Promise(i=>{let r=0;const h=setInterval(()=>{m2c2Globals.erudaInitialized===!0&&(clearInterval(h),i(void 0)),r=r+100,r>t&&(console.warn(`Could not initialize eruda within ${t} milliseconds.`),clearInterval(h),i(void 0))},100)})}async initialize(){m2c2Globals.erudaRequested===!0&&await this.waitForErudaInitialization(),this.options.recordEvents===!0&&(this.eventStore.mode=ve.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=V.getUrlFromManifest(this,t.canvasKitWasm+`/canvaskit-${this.canvasKitWasmVersion}.wasm`);try{this.canvasKit=await this.loadCanvasKit(i)}catch{throw new C(`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 Wr(this,t),this.imageManager=new fn(this,t),this.soundManager=new ns(this,t),this.eventMaterializer=new Ea({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 C(`Error ${i.status} on GET manifest.json from ${t}.`)}catch{throw new C(`Network error on GET manifest.json from ${t}.`)}try{return await i.json()}catch{throw new C(`Error parsing manifest.json from ${t}.`)}}get fontManager(){if(!this._fontManager)throw new C("fontManager is undefined");return this._fontManager}set fontManager(t){this._fontManager=t}get imageManager(){if(!this._imageManager)throw new C("imageManager is undefined");return this._imageManager}set imageManager(t){this._imageManager=t}get soundManager(){if(!this._soundManager)throw new C("soundManager is undefined");return this._soundManager}set soundManager(t){this._soundManager=t}get eventMaterializer(){if(!this._eventMaterializer)throw new C("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 C(`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,r=!1){const h=r?t:this.addPrefixesToKey(t);return this.dataStores[0].setItem(h,i,r?"":this.publishUuid)}storeGetItem(t,i=!1){const r=i?t:this.addPrefixesToKey(t);return this.dataStores[0].getItem(r)}storeDeleteItem(t,i=!1){const r=i?t:this.addPrefixesToKey(t);return this.dataStores[0].deleteItem(r)}storeClearItems(){return this.dataStores[0].clearItemsByActivityPublishUuid(this.publishUuid)}storeItemsKeys(t=!1){return this.dataStores[0].itemsKeysByActivityPublishUuid(t?"":this.publishUuid)}storeItemExists(t,i=!1){const r=i?t:this.addPrefixesToKey(t);return this.dataStores[0].itemExists(r)}get dataStores(){if(!this._dataStores)throw new C("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),r=this.getParameterOrFallback("missing_localization_color",void 0),h=this.getParameterOrFallback("translation",void 0),c=this.options.translation;return{locale:t,fallbackLocale:i,missingLocalizationColor:r,additionalTranslation:h,translation:c}}isLocalizationRequested(){const t=this.getParameterOrFallback("locale",void 0);if(t==="")throw new C("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(r=>{if(r!=="diagnostics"){if(r==="eruda"){t[r]===!0&&V.loadEruda();return}if(r==="scripts"){const h=t[r];h&&V.loadScriptUrls(h);return}if(!i||!(r in i))console.warn(`game ${this.options.name} does not have a parameter named ${r}. attempt to set parameter ${r} to value ${t[r]} will be ignored`);else if(this.options.parameters&&this.options.parameters[r]){const h=t[r];let c;if(this.options.parameters[r].type!==void 0&&h!==void 0)try{c=V.convertValueToType(h,this.options.parameters[r].type)}catch(S){throw new C("Error setting parameter "+r+": "+S.message)}else c=h;this.options.parameters[r].default=c}this.additionalParameters===void 0&&(this.additionalParameters={}),this.additionalParameters[r]=t[r]}})}get canvasKit(){if(!this._canvasKit)throw new C("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(r=>r.name===t).find(Boolean);if(!i)throw new C(`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){this.scenes.includes(t)&&console.warn(`Game.addScene(): scene ${t.toString()} has already been added to the game. This will cause unpredictable behavior. This warning will become an error in a future release.`),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 C(`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 C(`cannot remove scene named "${t}" from game because the scene is not currently added to the game`)}presentScene(t,i){let r;if(typeof t=="string"){if(r=this.scenes.filter(x=>x.name===t).find(Boolean),r===void 0&&(r=this.scenes.filter(x=>x.uuid===t).find(Boolean)),r===void 0)throw new C(`scene ${t} not found`)}else{if(!this.scenes.some(x=>x===t))throw new C(`scene ${t} exists, but it has not been added to the game object`);r=t}r.initialize(),r.needsInitialization=!1;const h=new is(r,i??Ke.none());this.incomingSceneTransitions.push(h),r.game.bodyBackgroundColor!==void 0?document.body.style.backgroundColor=`rgb(${r.game.bodyBackgroundColor[0]},${r.game.bodyBackgroundColor[1]},${r.game.bodyBackgroundColor[2]},${r.game.bodyBackgroundColor[3]})`:document.body.style.backgroundColor=`rgb(${r.backgroundColor[0]},${r.backgroundColor[1]},${r.backgroundColor[2]},${r.backgroundColor[3]})`;let c;i?.type===Se.Slide&&(c=i.direction);const S={type:"ScenePresent",target:r,uuid:r.uuid,...V.createFrameUpdateTimestamps(),transitionType:i?.type??Se.None,duration:i?.duration,direction:c,easingType:i?.easing?De.toTypeAsString(i.easing):void 0};this.eventStore.addEvent(S)}getParameter(t){if(this.options.parameters!==void 0&&Object.keys(this.options.parameters).includes(t))return this.options.parameters[t].default;throw new C(`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=Vt.now(),this.beginIso8601Timestamp=new Date().toISOString();let r;if(t!==void 0?typeof t=="object"?r=t:r=this.scenes.filter(S=>S.name===t).find(Boolean):this.entryScene!==void 0?typeof this.entryScene=="object"?r=this.entryScene:r=this.scenes.filter(S=>S.name===this.entryScene).find(Boolean):r=this.scenes.find(Boolean),r===void 0)throw new C("cannot start game. entry scene has not been added to the game object.");if(this.presentScene(r),this.surface===void 0)throw new C("CanvasKit surface is undefined");this.options.timeStepping?(this.addTimeSteppingControlsToDom(),this.updateTimeSteppingOutput()):this.removeTimeSteppingControlsFromDom(),this.options.showEventStoreControls&&this.addEventControlsToDom(),this.warmupFinished=!1;const h={target:this,type:H.GameWarmupStart,...V.createFrameUpdateTimestamps()};this.raiseActivityEventOnListeners(h),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 c={target:this,type:H.ActivityStart,...V.createFrameUpdateTimestamps()};this.raiseActivityEventOnListeners(c)}playEventsHandler(t){if(t?.target?.id==="replay-events"&&(this.eventStore.mode=ve.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===ve.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 r=document.createElement("div");r.id="m2c2kit-event-controls-div",r.style.position="fixed",r.style.top="4px",r.style.left="4px",i.prepend(r);const h=document.createElement("button");h.id="replay-events",h.title="replay event recording",h.innerText="\u25B6\uFE0F",h.style.marginRight="4px",r.appendChild(h),h.addEventListener("click",this.playEventsHandler.bind(this));const c=document.createElement("button");c.id="stop-replay",c.title="stop event replay",c.innerText="\u23F9\uFE0F",c.style.marginRight="4px",c.disabled=!0,r.appendChild(c),c.addEventListener("click",this.playEventsHandler.bind(this));const S=document.createElement("button");S.id="log-events",S.title="log events to console",S.innerText="\u{1F4C4}",S.style.marginRight="4px",r.appendChild(S),S.addEventListener("click",this.playEventsHandler.bind(this));const x=document.createElement("span");x.title="optional: replay events only through a given sequence number. Default is to replay all events.",x.innerText="Replay through sequence: ",r.appendChild(x);const z=document.createElement("input");z.id="sequence-number",z.title="optional: replay events only through a given sequence number. Default is to replay all events.",z.style.marginRight="4px",r.appendChild(z)}}addTimeSteppingControlsToDom(){if(document.getElementById("m2c2kit-time-stepping-div"))return;const i=document.getElementsByTagName("body")[0];if(i){const r=document.createElement("div");r.id="m2c2kit-time-stepping-div",i.prepend(r);const h=document.createElement("button");h.id="1-step-advance",h.title="advance 1 step (16.667 ms)",h.innerText=">",h.style.marginRight="4px",r.appendChild(h),h.addEventListener("click",this.advanceStepsHandler.bind(this));const c=document.createElement("button");c.id="55-step-advance",c.title="advance 55 steps (916.667 ms)",c.innerText=">>",c.style.marginRight="4px",r.appendChild(c),c.addEventListener("click",this.advanceStepsHandler.bind(this));const S=document.createElement("input");S.id="time-stepping-steps-input",S.title="steps",S.style.width="40px",S.style.marginRight="4px",S.setAttribute("readonly","true"),r.appendChild(S);const x=document.createElement("input");x.id="time-stepping-now-input",x.title="milliseconds",x.style.width="80px",x.style.marginRight="4px",x.setAttribute("readonly","true"),r.appendChild(x)}}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 C("surface is undefined");const r=this.surface.width(),h=this.surface.height(),c=Math.round(r/2)+i,S=Math.round(h/2)+i,x=i,z=i,G=Nt.makePaint(this.canvasKit,R.White,this.canvasKit.PaintStyle.Fill,!0);t.drawRect([0,0,this.surface.width(),this.surface.height()],G);const q=Nt.makePaint(this.canvasKit,R.Black,this.canvasKit.PaintStyle.Fill,!1),st=Nt.makePaint(this.canvasKit,R.Black,this.canvasKit.PaintStyle.Fill,!0),lt=Nt.makePaint(this.canvasKit,R.Black,this.canvasKit.PaintStyle.Stroke,!1);lt.setStrokeWidth(2);const yt=Nt.makePaint(this.canvasKit,R.Black,this.canvasKit.PaintStyle.Stroke,!0);yt.setStrokeWidth(2),t.drawCircle(c,S,32,q),t.drawCircle(c,S,32,st),t.drawCircle(c,S,32,lt),t.drawCircle(c,S,32,yt);const rt=this.fontManager,Et=this.fontManager.getFontNames();if(Et.length>0&&rt.fonts[Et[0]].status===re.Ready){const Bt=rt.getTypeface(Et[0]),se=new this.canvasKit.Font(Bt,16*m2c2Globals.canvasScale);t.drawText("abc",c,S,q,se),t.drawText("abc",c,S,st,se)}const Wt=this.takeCurrentSceneSnapshot();t.drawImage(Wt,x,z),Wt.delete(),t.drawRect([x,z,16,16],q),t.drawRect([x,z,16,16],st),t.drawRect([x,z,16,16],lt),t.drawRect([x,z,16,16],yt),t.restore()}warmupShadersWithScenes(t){[...this.scenes,this.freeNodesScene].forEach(c=>{c.warmup(t)});const i=this.nodes.filter(c=>c.type===dt.Sprite).map(c=>c.imageName),r=this.imageManager.images;r&&Object.keys(r).filter(S=>S!=="__outgoingSceneSnapshot").forEach(S=>{if(!i.includes(S)&&r[S].status===ne.Ready){const x=r[S].canvaskitImage;if(!x)throw new C(`image ${S} is undefined`);t.drawImage(x,0,0)}});const h=new this.canvasKit.Paint;if(h.setColor(this.canvasKit.Color(255,255,255,1)),!this.surface)throw new C("surface is undefined");t.drawRect([0,0,this.surface.width(),this.surface.height()],h)}stop(){this.currentScene&&(this.currentScene._active=!1),this.gameStopRequested=!0,Vt.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,scoring:{}};const t=this.options.trialSchema??{},i=this.options.scoringSchema??{};this.validateSchema(t),this.validateSchema(i)}validateSchema(t){const i=Object.entries(t);for(const[r,h]of i)if(h.type!==void 0&&!this.propertySchemaDataTypeIsValid(h.type))throw new C(`invalid schema. variable ${r} is type ${h.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 r=!0;if(Array.isArray(t))t.forEach(h=>{i.includes(h)||(r=!1)});else throw new C(`Invalid data type: ${t}`);return r}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 C("no trial schema were provided in GameOptions. cannot add trial data");if(this.data.trials.length<this.trialIndex+1){const c={},S=Object.entries(this.options.trialSchema);for(const[x]of S)c[x]=null;this.data.trials.push({data_type:"trial",document_uuid:ze.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,...c,device_metadata:this.getDeviceMetadata()})}if(!(t in this.options.trialSchema))throw new C(`trial variable ${t} not defined in schema`);let r;Array.isArray(this.options.trialSchema[t].type)?r=this.options.trialSchema[t].type:r=[this.options.trialSchema[t].type];let h=typeof i;if(h==="object"&&Object.prototype.toString.call(i)==="[object Array]"&&(h="array"),i==null&&(h="null"),!r.includes(h)&&!(h==="number"&&Number.isInteger(i)&&r.includes("integer")))throw new C(`type for variable ${t} (value: ${i}) is "${h}". Based on schema for this variable, expected type was "${r}"`);this.data.trials[this.trialIndex][t]=i}addScoringData(t,i){if(!this.options.scoringSchema)throw new C("no scoring schema were provided in GameOptions. cannot add scoring data");if(Object.keys(this.data.scoring).length===0){const h={data_type:"scoring",document_uuid:ze.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,device_metadata:this.getDeviceMetadata()},c=Object.entries(this.options.scoringSchema);for(const[S]of c)h[S]=null;this.data.scoring=h}if(typeof t=="object"){let h;Array.isArray(t)?(t.length!==1&&console.warn(`Array of objects passed to addScoringData() is length ${t.length}. This is likely an error in the assessment's code for calculateScores().`),h=t[0]):h=t;for(const[c,S]of Object.entries(h))this.validateAndSetScoringVariable(c,S);return}const r=t;if(i===void 0)throw new C("Value must be provided when adding a single scoring variable");this.validateAndSetScoringVariable(r,i)}validateAndSetScoringVariable(t,i){if(!this.options.scoringSchema)throw new C("no scoring schema were provided in GameOptions. cannot add scoring data");if(!(t in this.options.scoringSchema))throw new C(`scoring variable ${t} not defined in schema`);let r;Array.isArray(this.options.scoringSchema[t].type)?r=this.options.scoringSchema[t].type:r=[this.options.scoringSchema[t].type];let h=typeof i;if(h==="object"&&Object.prototype.toString.call(i)==="[object Array]"&&(h="array"),i==null&&(h="null"),!r.includes(h)&&!(h==="number"&&Number.isInteger(i)&&r.includes("integer")))throw new C(`type for variable ${t} (value: ${i}) is "${h}". Based on schema for this variable, expected type was "${r}"`);this.data.scoring[t]=i}addTrialSchema(t){Object.keys(t).forEach(r=>{if(!this.options.trialSchema)throw new C("trial schema is undefined");this.options.trialSchema[r]=t[r]})}addStaticTrialData(t,i){if(!this.options.trialSchema)throw new C("trial schema is undefined");if(this.options.trialSchema[t]===void 0)throw new C(`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:H.ActivityData,...V.createFrameUpdateTimestamps(),target:this,newData:this.data.trials[this.trialIndex-1],newDataSchema:this.makeNewGameDataSchema(),data:this.data,dataSchema:this.makeGameDataSchema(),dataType:"Trial",activityConfiguration:this.makeGameActivityConfiguration(this.options.parameters??{}),activityConfigurationSchema:this.makeGameActivityConfigurationSchema(this.options.parameters??{}),activityMetrics:this.gameMetrics};this.raiseActivityEventOnListeners(t)}scoringComplete(){const t={type:H.ActivityData,...V.createFrameUpdateTimestamps(),target:this,newData:this.data.scoring,newDataSchema:this.makeScoringDataSchema(),data:this.data.scoring,dataSchema:this.makeScoringDataSchema(),dataType:"Scoring",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:r,fallback_locale:h,missing_localization_color:c,translation:S,...x}=i;for(const z in x)for(const G in x[z])G=="default"&&(x[z]=x[z][G]);return x}makeGameActivityConfigurationSchema(t){const i=JSON.parse(JSON.stringify(t)),{locale:r,fallback_locale:h,missing_localization_color:c,translation:S,...x}=i;for(const z in x){if(!("type"in x[z])&&"value"in x[z]){const G=typeof x[z].default;G!=="bigint"&&G!=="function"&&G!=="symbol"&&G!=="undefined"&&(x[z].type=G)}for(const G in x[z])G=="default"&&delete x[z][G]}return{description:`activity configuration from the assessment ${this.name}`,type:"object",properties:x}}makeScoringDataSchema(){return{description:`Scoring data 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.automaticScoringSchema,...this.options.scoringSchema,device_metadata:bn}}}end(){const t={target:this,type:H.ActivityEnd,...V.createFrameUpdateTimestamps()},i={data:this.data,dataSchema:this.makeGameDataSchema(),dataType:"Trial",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:H.ActivityCancel,...V.createFrameUpdateTimestamps()},i={data:this.data,dataSchema:this.makeGameDataSchema(),dataType:"Trial",activityConfiguration:this.makeGameActivityConfiguration(this.options.parameters??{}),activityConfigurationSchema:this.makeGameActivityConfigurationSchema(this.options.parameters??{}),activityMetrics:this.gameMetrics};this.raiseActivityEventOnListeners(t,i)}setupHtmlCanvases(t,i,r,h){m2c2Globals.canvasScale=Math.round(window.devicePixelRatio*100)/100;let c;if(t===void 0){const S=document.getElementsByTagName("canvas");let x=new Array;for(let G=0;G<S.length;G++)x.push(S[G]);if(x=x.filter(G=>!G.id.startsWith("m2c2kit-scratch-canvas")),x.length===0)throw new C("no html canvas tag was found in the html");const z=x.filter(G=>G.id==="m2c2kit-canvas")[0];z?(c=z,x.length>1&&console.log("using canvas with id 'm2c2kit-canvas'")):(c=S[0],x.length>1&&console.log("using first canvas"))}else if(c=document.getElementById(t),c===void 0)throw new C(`could not find canvas HTML element with id "${t}"`);if(h||window.innerWidth<i||window.innerHeight<r){const S=r/i;window.innerHeight/window.innerWidth<S?m2c2Globals.rootScale=window.innerHeight/r:m2c2Globals.rootScale=window.innerWidth/i}c.style.width=m2c2Globals.rootScale*i+"px",c.style.height=m2c2Globals.rootScale*r+"px",c.width=m2c2Globals.rootScale*i*m2c2Globals.canvasScale,c.height=m2c2Globals.rootScale*r*m2c2Globals.canvasScale,this.htmlCanvas=c,this.canvasCssWidth=i,this.canvasCssHeight=r,m2c2Globals.canvasCssWidth=i,m2c2Globals.canvasCssHeight=r}setupCanvasKitSurface(){if(this.htmlCanvas===void 0)throw new C("main html canvas is undefined");window.logWebGl=this.options.logWebGl,this.interceptWebGlCalls();try{this.webGlRendererInfo=Pn.getRendererString()}catch{this.webGlRendererInfo="err",Pn.dispose()}const t=this.canvasKit.MakeWebGLCanvasSurface(this.htmlCanvas);if(t===null)throw new C("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(h=>h.toString()).join(", ")})`);const r=t.apply(this,[...i]);if(r.__proto__.compileShader&&!r.__proto__.m2c2ModifiedCompileShader){r.__proto__.m2c2ModifiedCompileShader=!0;const h=r.__proto__.compileShader;r.__proto__.compileShader=function(...c){if(window.logWebGl){const S=c[0],x=r.getShaderSource(S);console.log("\u{1F53C} compileShader():"),console.log(x)}return h.apply(this,[...c])}}return r}}}setupFpsFont(){this.fpsTextFont=new this.canvasKit.Font(null,Q.FPS_DISPLAY_TEXT_FONT_SIZE*m2c2Globals.canvasScale),this.fpsTextPaint=new this.canvasKit.Paint,this.fpsTextPaint.setColor(this.canvasKit.Color(Q.FPS_DISPLAY_TEXT_COLOR[0],Q.FPS_DISPLAY_TEXT_COLOR[1],Q.FPS_DISPLAY_TEXT_COLOR[2],Q.FPS_DISPLAY_TEXT_COLOR[3])),this.fpsTextPaint.setAntiAlias(!0)}setupCanvasDomEventHandlers(){if(this.htmlCanvas===void 0)throw new C("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)),document.addEventListener("keydown",this.documentKeyDownHandler.bind(this)),document.addEventListener("keyup",this.documentKeyUpHandler.bind(this))}loop(t){if(!this.surface)throw new C("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:H.GameWarmupEnd,...V.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/Q.LIMITED_FPS_RATE)===0){if(this.currentScene===void 0&&this.incomingSceneTransitions.length===0&&this.eventStore.mode!==ve.Replay)throw new C("Can not run game without a current or incoming scene");if(this.updateGameTime(),this.eventStore.mode===ve.Replay){const i=this.eventStore.dequeueEvents(Vt.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===Se.None)){const i=t.shift();if(i===void 0)throw new C("no incoming scene transition");const r=i.scene,h=i.transition;if(h.type===Se.None){this.currentScene&&(this.currentScene._active=!1),this.currentScene=r,this.currentScene._active=!0,this.raiseSceneEvent(r,"SceneSetup"),this.raiseSceneEvent(r,"SceneAppear");return}if(this.currentSceneSnapshot=this.snapshots.shift(),!this.currentSceneSnapshot)throw new C("No snapshot available for outgoing scene");const c=this.createOutgoingScene(this.currentSceneSnapshot);c._active=!0,this.currentScene&&(this.currentScene._active=!1),this.currentScene=r,this.currentScene._active=!0,this.raiseSceneEvent(r,"SceneSetup"),this.animateSceneTransition(r,h,c)}}createOutgoingScene(t){const i=new Ve({name:Q.OUTGOING_SCENE_NAME});i.size.width=this.canvasCssWidth,i.size.height=this.canvasCssHeight,this.addScene(i);const r={imageName:Q.OUTGOING_SCENE_IMAGE_NAME,canvaskitImage:t,width:this.canvasCssWidth,height:this.canvasCssHeight,status:ne.Ready,localize:!1,isFallback:!1};this.imageManager.addImage(r);const h=new pi({name:Q.OUTGOING_SCENE_SPRITE_NAME,imageName:Q.OUTGOING_SCENE_IMAGE_NAME,position:{x:this.canvasCssWidth/m2c2Globals.rootScale/2,y:this.canvasCssHeight/m2c2Globals.rootScale/2}});return h.scale=1/m2c2Globals.rootScale,i.addChild(h),i}async registerPlugin(t){if(t.type!==ui.Game)throw new C(`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 C(`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+Q.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+Q.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:Q.FPS_DISPLAY_UPDATE_INTERVAL,fps_report_threshold:this.fpsMetricReportThreshold,activity_type:ui.Game,activity_uuid:this.uuid,iso8601_timestamp:new Date().toISOString()}))}takeCurrentSceneSnapshot(){if(this.surface===void 0)throw new C("CanvasKit surface is undefined");return this.surface.makeImageSnapshot()}handlePendingScreenshot(t){if(!this.surface)throw new C("no surface");let i;if(t.rect.length==4){const h=t.rect[0]*m2c2Globals.canvasScale,c=t.rect[1]*m2c2Globals.canvasScale,S=t.rect[2]*m2c2Globals.canvasScale,x=t.rect[3]*m2c2Globals.canvasScale,z=[h,c,h+S,c+x];i=this.surface.makeImageSnapshot(z)}else i=this.surface.makeImageSnapshot();const r=i.encodeToBytes();t.promiseResolve(r)}takeScreenshot(t,i,r,h){if(!this.surface)throw new C("no canvaskit surface. unable to take screenshot.");const c=[t,i,r,h].map(S=>S?0:1).reduce((S,x)=>S+x);return new Promise((S,x)=>{switch(c){case 0:{if(!t||!i||!r||!h){x("missing values in arguments for takeScreenshot()");return}this.pendingScreenshot={rect:[t,i,r,h],promiseResolve:S};break}case 4:{this.pendingScreenshot={rect:[],promiseResolve:S};break}default:x("Exactly 0 or 4 arguments must be supplied to takeScreenshot()")}})}animateSceneTransition(t,i,r){const h=i.duration;switch(t._transitioning=!0,r._transitioning=!0,i.type){case Se.Slide:{switch(i.direction){case be.Left:t.position.x=t.size.width,t.run(X.sequence([X.move({point:{x:0,y:0},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{t._transitioning=!1,this.raiseSceneEvent(t,"SceneAppear"),this.removeScene(Q.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),r.run(X.sequence([X.move({point:{x:-r.size.width,y:0},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{r._active=!1,r._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;case be.Right:t.position.x=-t.size.width,t.run(X.sequence([X.move({point:{x:0,y:0},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{t._transitioning=!1,this.raiseSceneEvent(t,"SceneAppear"),this.removeScene(Q.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),r.run(X.sequence([X.move({point:{x:r.size.width,y:0},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{r._active=!1,r._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;case be.Up:t.position.y=t.size.height,t.run(X.sequence([X.move({point:{x:0,y:0},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{t._transitioning=!1,this.raiseSceneEvent(t,"SceneAppear"),this.removeScene(Q.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),r.run(X.sequence([X.move({point:{x:0,y:-r.size.height},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{r._active=!1,r._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;case be.Down:t.position.y=-t.size.height,t.run(X.sequence([X.move({point:{x:0,y:0},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{t._transitioning=!1,this.raiseSceneEvent(t,"SceneAppear"),this.removeScene(Q.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),r.run(X.sequence([X.move({point:{x:0,y:r.size.height},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{r._active=!1,r._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;default:throw new C("unknown transition direction")}break}default:throw new C("unknown transition type")}}drawFps(t){t.save();const i=m2c2Globals.canvasScale;if(t.scale(1/i,1/i),!this.fpsTextFont||!this.fpsTextPaint)throw new C("fps font or paint is undefined");t.drawText("FPS: "+this.fpsRate.toFixed(2),0,0+Q.FPS_DISPLAY_TEXT_FONT_SIZE*i,this.fpsTextPaint,this.fpsTextFont),t.restore()}createEventListener(t,i,r,h){const c=this.nodes.filter(x=>x.name===i);c.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 S=c.filter(x=>x.name===i).find(Boolean);if(S===void 0)throw new C(`could not create event listener. node with name ${i} could not be found in the game node tree`);if(!Object.values(H).includes(t))throw new C(`game ${this.id}: could not create event listener. event type ${t} is not known`);S.addEventListener(t,r,h)}get nodes(){function t(r,h){h.push(r),r.children.forEach(c=>t(c,h))}const i=new Array;return[...this.scenes,this.freeNodesScene].forEach(r=>t(r,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 C("main html canvas is undefined");const r={type:"DomPointerDown",target:this.htmlCanvas,x:t.offsetX/m2c2Globals.rootScale,y:t.offsetY/m2c2Globals.rootScale,...V.createTimestamps()};this.eventStore.addEvent(r);const h={target:i,type:H.PointerDown,handled:!1,...V.createTimestamps()};this.processDomPointerDown(this.freeNodesScene,h,t),this.processDomPointerDown(i,h,t)}htmlCanvasPointerUpHandler(t){t.preventDefault();const i=this.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;const r={target:i,type:H.PointerUp,handled:!1,...V.createTimestamps()};this.processDomPointerUp(this.freeNodesScene,r,t),this.processDomPointerUp(i,r,t)}htmlCanvasPointerMoveHandler(t){t.preventDefault();const i=this.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;const r={target:i,type:H.PointerMove,handled:!1,...V.createTimestamps()};this.processDomPointerMove(this.freeNodesScene,r,t),this.processDomPointerMove(i,r,t)}htmlCanvasPointerLeaveHandler(t){if(!this.currentScene)return;t.preventDefault();const i=this.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;const r={target:i,type:H.PointerLeave,handled:!1,...V.createTimestamps()};this.processDomPointerLeave(this.freeNodesScene,r,t),this.processDomPointerLeave(i,r,t)}documentKeyDownHandler(t){const i=this.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;const r={target:i,type:H.KeyDown,handled:!1,...V.createTimestamps()};this.raiseEventOnListeningNodes(this.freeNodesScene,r,t),this.raiseEventOnListeningNodes(i,r,t)}documentKeyUpHandler(t){const i=this.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;const r={target:i,type:H.KeyUp,handled:!1,...V.createTimestamps()};this.raiseEventOnListeningNodes(this.freeNodesScene,r,t),this.raiseEventOnListeningNodes(i,r,t)}processDomPointerDown(t,i,r){i.handled||(t.isUserInteractionEnabled&&this.IsCanvasPointWithinNodeBounds(t,r.offsetX,r.offsetY)&&(t.pressed=!0,t.pressedAndWithinHitArea=!0,t.pressedInitialPointerOffset={x:r.offsetX,y:r.offsetY},this.raiseM2PointerDownEvent(t,i,r),this.raiseTapDownEvent(t,i,r)),t.children&&t.children.filter(h=>!h.hidden).filter(h=>h.isDrawable).sort((h,c)=>{const S=c.zPosition-h.zPosition;return S!==0?S:t.children.indexOf(c)-t.children.indexOf(h)}).forEach(h=>this.processDomPointerDown(h,i,r)))}processDomPointerUp(t,i,r){if(!i.handled){if(t.dragging){t.dragging=!1,t.pressed=!1,t.pressedAndWithinHitArea=!1,this.raiseM2DragEndEvent(t,i,r);return}t.isUserInteractionEnabled&&t.pressed&&t.pressedAndWithinHitArea?(t.pressed=!1,t.pressedAndWithinHitArea=!1,this.raiseTapUpEvent(t,i,r),this.raiseTapUpAny(t,i,r),this.raiseM2PointerUpEvent(t,i,r)):t.isUserInteractionEnabled&&t.pressed&&t.pressedAndWithinHitArea==!1?(t.pressed=!1,t.pressedAndWithinHitArea=!1,this.raiseTapUpAny(t,i,r)):t.isUserInteractionEnabled&&this.IsCanvasPointWithinNodeBounds(t,r.offsetX,r.offsetY)&&(t.pressed=!1,t.pressedAndWithinHitArea=!1,this.raiseM2PointerUpEvent(t,i,r)),t.children&&t.children.filter(h=>!h.hidden).filter(h=>h.isDrawable).sort((h,c)=>{const S=c.zPosition-h.zPosition;return S!==0?S:t.children.indexOf(c)-t.children.indexOf(h)}).forEach(h=>this.processDomPointerUp(h,i,r))}}processDomPointerMove(t,i,r){if(!i.handled){if(t.isUserInteractionEnabled&&t.draggable&&t.pressed){let h=!1,c,S;t.dragging===!1?(t.dragging=!0,h=!0,c=r.offsetX-t.pressedInitialPointerOffset.x,S=r.offsetY-t.pressedInitialPointerOffset.y):(c=r.offsetX-t.draggingLastPointerOffset.x,S=r.offsetY-t.draggingLastPointerOffset.y),t.position.x+=c,t.position.y+=S,t.draggingLastPointerOffset={x:r.offsetX,y:r.offsetY},h?this.raiseM2DragStartEvent(t,i,r):this.raiseM2DragEvent(t,i,r);return}t.isUserInteractionEnabled&&t.pressed&&t.pressedAndWithinHitArea&&!this.IsCanvasPointWithinNodeBounds(t,r.offsetX,r.offsetY)&&(t.pressedAndWithinHitArea=!1,this.raiseTapLeaveEvent(t,i,r)),t.isUserInteractionEnabled&&this.IsCanvasPointWithinNodeBounds(t,r.offsetX,r.offsetY)&&(this.raiseM2PointerMoveEvent(t,i,r),t.withinHitArea=!0),t.isUserInteractionEnabled&&t.withinHitArea&&!this.IsCanvasPointWithinNodeBounds(t,r.offsetX,r.offsetY)&&(t.withinHitArea=!1,this.raiseM2PointerLeaveEvent(t,i,r)),t.children&&t.children.filter(h=>!h.hidden).filter(h=>h.isDrawable).sort((h,c)=>{const S=c.zPosition-h.zPosition;return S!==0?S:t.children.indexOf(c)-t.children.indexOf(h)}).forEach(h=>this.processDomPointerMove(h,i,r))}}processDomPointerLeave(t,i,r){if(!i.handled){if(t.dragging){const h={target:t,type:H.DragEnd,handled:!1,...V.createTimestamps()};t.dragging=!1,t.pressed=!1,t.pressedAndWithinHitArea=!1,this.raiseM2DragEndEvent(t,h,r);return}t.isUserInteractionEnabled&&t.pressed&&t.pressedAndWithinHitArea&&!this.IsCanvasPointWithinNodeBounds(t,r.offsetX,r.offsetY)&&(t.pressedAndWithinHitArea=!1,this.raiseTapLeaveEvent(t,i,r)),t.isUserInteractionEnabled&&t.withinHitArea&&!this.IsCanvasPointWithinNodeBounds(t,r.offsetX,r.offsetY)&&(t.withinHitArea=!1,this.raiseM2PointerLeaveEvent(t,i,r)),t.children&&t.children.filter(h=>!h.hidden).filter(h=>h.isDrawable).sort((h,c)=>{const S=c.zPosition-h.zPosition;return S!==0?S:t.children.indexOf(c)-t.children.indexOf(h)}).forEach(h=>this.processDomPointerLeave(h,i,r))}}raiseM2PointerDownEvent(t,i,r){i.target=t,i.type=H.PointerDown,this.raiseEventOnListeningNodes(t,i,r)}raiseTapDownEvent(t,i,r){i.target=t,i.type=H.TapDown,this.raiseEventOnListeningNodes(t,i,r)}raiseTapLeaveEvent(t,i,r){i.target=t,i.type=H.TapLeave,this.raiseEventOnListeningNodes(t,i,r)}raiseM2PointerUpEvent(t,i,r){i.target=t,i.type=H.PointerUp,this.raiseEventOnListeningNodes(t,i,r)}raiseTapUpEvent(t,i,r){i.target=t,i.type=H.TapUp,this.raiseEventOnListeningNodes(t,i,r)}raiseTapUpAny(t,i,r){i.target=t,i.type=H.TapUpAny,this.raiseEventOnListeningNodes(t,i,r)}raiseM2PointerMoveEvent(t,i,r){i.target=t,i.type=H.PointerMove,this.raiseEventOnListeningNodes(t,i,r)}raiseM2PointerLeaveEvent(t,i,r){i.target=t,i.type=H.PointerLeave,this.raiseEventOnListeningNodes(t,i,r)}raiseM2DragStartEvent(t,i,r){i.target=t,i.type=H.DragStart,this.raiseEventOnListeningNodes(t,i,r)}raiseM2DragEvent(t,i,r){i.target=t,i.type=H.Drag,this.raiseEventOnListeningNodes(t,i,r)}raiseM2DragEndEvent(t,i,r){i.target=t,i.type=H.DragEnd,this.raiseEventOnListeningNodes(t,i,r)}raiseSceneEvent(t,i){const r={target:t,type:i,...V.createFrameUpdateTimestamps()};t.eventListeners.filter(h=>h.type===i).forEach(h=>h.callback(r))}calculatePointWithinNodeFromDomPointerEvent(t,i){let r=t.size.width,h=t.size.height;if(t.type===dt.Shape&&t.shapeType===Kt.Circle){const q=t.circleOfRadius;if(!q)throw"circleOfRadius is undefined";r=q*2,h=q*2}let c=i.offsetX,S=i.offsetY;const x=V.calculateNodeAbsoluteBoundingBox(t);V.nodeOrAncestorHasBeenRotated(t)&&V.calculateRotationTransforms(t).forEach(st=>{const lt=V.rotatePoint({x:c,y:S},-st.radians,st.center);c=lt.x,S=lt.y});const z=(c-x.xMin)/(x.xMax-x.xMin)*r,G=(S-x.yMin)/(x.yMax-x.yMin)*h;return{x:z,y:G}}onStart(t,i){this.addEventListener(H.ActivityStart,t,i)}onCancel(t,i){this.addEventListener(H.ActivityCancel,t,i)}onEnd(t,i){this.addEventListener(H.ActivityEnd,t,i)}onData(t,i){this.addEventListener(H.ActivityData,t,i)}onWarmupStart(t,i){this.addEventListener(H.GameWarmupStart,t,i)}onWarmupEnd(t,i){this.addEventListener(H.GameWarmupEnd,t,i)}addEventListener(t,i,r){const h={type:t,activityUuid:this.uuid,callback:i};r?.replaceExisting&&(this.eventListeners=this.eventListeners.filter(c=>!(c.activityUuid===h.activityUuid&&c.type===h.type))),this.eventListeners.push(h)}raiseActivityEventOnListeners(t,i){i&&(t={...t,...i}),this.eventListeners.filter(r=>r.type===t.type).forEach(r=>{r.callback(t)})}raiseEventOnListeningNodes(t,i,r){t.eventListeners.filter(h=>h.type===i.type).forEach(h=>{if(h.nodeUuid===t.uuid){switch(i.target=t,i.type){case H.PointerDown:case H.PointerMove:case H.PointerUp:case H.PointerLeave:i.point=this.calculatePointWithinNodeFromDomPointerEvent(t,r),i.buttons=r.buttons,h.callback(i);break;case H.KeyDown:case H.KeyUp:i.key=r.key,i.code=r.code,i.shiftKey=r.shiftKey,i.ctrlKey=r.ctrlKey,i.metaKey=r.metaKey,i.altKey=r.altKey,i.repeat=r.repeat,h.callback(i);break;case H.TapDown:case H.TapUp:case H.TapUpAny:case H.TapLeave:i.point=this.calculatePointWithinNodeFromDomPointerEvent(t,r),i.buttons=r.buttons,h.callback(i);break;case H.DragStart:case H.Drag:case H.DragEnd:i.position={x:t.position.x,y:t.position.y},i.buttons=r.buttons,h.callback(i);break}t.suppressEvents||this.eventStore.addEvent(i)}})}sceneCanReceiveUserInteraction(t){return!!(t._active&&t._transitioning===!1)}IsCanvasPointWithinNodeBounds(t,i,r){if(!t.isDrawable)throw"only drawable nodes can receive pointer events";if(t.type===dt.Shape&&t.shapeType===Kt.Circle){const c=V.calculateNodeAbsoluteBoundingBox(t),S=t.circleOfRadius;if(!S)throw"circleOfRadius is undefined";const x={x:c.xMin+S*t.absoluteScale,y:c.yMin+S*t.absoluteScale};return Math.sqrt(Math.pow(i-x.x,2)+Math.pow(r-x.y,2))<=S*t.absoluteScale}if(t.size.width===0||t.size.height===0||t.type===dt.TextLine&&isNaN(t.size.width))return!1;const h=V.calculateRotatedPoints(t);return t.isUserInteractionEnabled&&V.isPointInsideRectangle({x:i,y:r},h)}}function Fa(){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:[]}}Fa();const rs=class as{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(r=>r.name===t).find(Boolean);if(i===void 0)i=new as(t),i.cumulativeElapsed=0,this._timers.push(i);else if(i.stopped==!1)throw new C(`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(r=>r.name===t).find(Boolean);if(i===void 0)throw new C(`can't stop timer. timer with name ${t} does not exist`);if(i.stopped===!0)throw new C(`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(r=>r.name===t).find(Boolean);if(i===void 0)throw new C(`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(r=>r.name===t).find(Boolean);if(i===void 0)throw new C(`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(r=>r.name===t).find(Boolean)===void 0)throw new C(`can't remove timer. timer with name ${t} does not exist`);this._timers=this._timers.filter(r=>r.name!=t)}static removeAll(){this._timers=new Array}static exists(t){return this._timers.some(i=>i.name===t)}};rs._timers=new Array;let Ma=rs;class An{static SingleFromRange(t,i){return Math.floor(Math.random()*(i-t+1))+t}static FromRangeWithoutReplacement(t,i,r){if(t>r-i+1)throw new C(`number of requested draws (n = ${t}) is greater than number of integers in range [ ${i}, ${r}]`);const h=new Array;for(let c=0;c<t;c++){const S=An.SingleFromRange(i,r);h.includes(S)?t++:h.push(S)}return h}static FromGridWithoutReplacement(t,i,r,h){const c=new Array,S=i*r-1,x=this.FromRangeWithoutReplacement(t,0,S);let z=0,G=NaN;for(;z<t;){const q=x[z]%r,st=(x[z]-q)/r;if(h===void 0||h(st,q))c.push({row:st,column:q}),z++;else{do G=this.FromRangeWithoutReplacement(1,0,S)[0];while(x.includes(G));x[z]=G}}return c}}class Ra extends fe{constructor(t){super(t),this.type=dt.SoundPlayer,this.isDrawable=!1,this.soundName=t.soundName}initialize(){}removeAction(t){const i=this.actions.find(r=>r.key===t);i?.type===mt.Play&&this.stopSoundActionAudio(i),this.actions=this.actions.filter(r=>r.key!==t)}removeAllActions(){for(;this.actions.length;){const t=this.actions.pop();t?.type===mt.Play&&this.stopSoundActionAudio(t)}}stopSoundActionAudio(t){if(t.running){const i=this.game.soundManager.getSound(this.soundName);i.audioBufferSource?.stop(),i.audioBufferSource?.disconnect()}}dispose(){}duplicate(t){throw new C("Method not implemented.")}}class ka extends fe{constructor(t){if(super(t),this.type=dt.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 r=this.getSupportedBackupMimeType(t.backupMimeTypes);r&&(this.mimeType=r,console.log(`Using backup MIME type: ${r}.`))}}t?.audioTrackConstraints&&(this.audioTrackConstraints=t.audioTrackConstraints),t?.maximumDuration&&(this.maximumDuration=t.maximumDuration)}initialize(){}async start(){if(this.isRecording)throw new C("cannot start SoundRecorder because it is already started.");this.audioChunks=[],this.endIso8601Timestamp=void 0;const t=this.getMediaRecorderSupportedAudioMimeTypes();if(t.length===0)throw new C("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(h){throw new C(`Error getting user media: ${h}.`)}if(!i)throw new C("no stream.");const r=i.getAudioTracks();this.mediaTrackSettings=r?.map(h=>h.getSettings()),this.mediaRecorder=new MediaRecorder(i,{mimeType:this.mimeType}),this.mediaRecorder.ondataavailable=h=>{this.audioChunks.push(h.data)},this.mediaRecorder.onerror=h=>{throw new C(`MediaRecorder error: ${h?.error?.message} ${h?.message}`)},this.mediaRecorder.start(),this.beginIso8601Timestamp=new Date().toISOString(),this.timerUuid=ze.generate(),Vt.startNew(this.timerUuid),this._isRecording=!0,this._isPaused=!1}async stop(){if(!this.isRecording)throw new C("cannot stop SoundRecorder because it has not started.");return new Promise(t=>{if(!this.mediaRecorder)throw new C("no media recorder");this.mediaRecorder.onstop=async()=>{if(!this.mimeType)throw new C("no mimeType");this._isRecording=!1,this._isPaused=!1;const i=new Blob(this.audioChunks,{type:this.getMimeTypeWithoutCodecs(this.mimeType)}),r=await this.blobToBase64(i);t({mimeType:this.mimeType,beginIso8601Timestamp:this.beginIso8601Timestamp??"",endIso8601Timestamp:this.endIso8601Timestamp??"",duration:Vt.elapsed(this.timerUuid),audioTrackSettings:this.mediaTrackSettings,audioBase64:r,audioBlob:i})},this.mediaRecorder.stop(),this.endIso8601Timestamp=new Date().toISOString(),this.isPaused||Vt.stop(this.timerUuid)})}pause(){if(!this.isRecording)throw new C("cannot pause SoundRecorder because it is not started.");if(this.isPaused)throw new C("cannot pause SoundRecorder because it is already paused.");this.mediaRecorder?.pause(),this._isPaused=!0,Vt.stop(this.timerUuid)}resume(){if(!this.isRecording)throw new C("cannot resume SoundRecorder because it is not started.");if(!this.isPaused)throw new C("cannot resume SoundRecorder because it is not paused.");this.mediaRecorder?.resume(),this._isPaused=!1,Vt.start(this.timerUuid)}async queryPermission(){try{return(await navigator.permissions.query({name:"microphone"})).state}catch(t){console.warn(`Error calling navigator.permissions.query({ name: "microphone" }): ${t}.`);return}}async requestPermission(){try{return(await navigator.mediaDevices.getUserMedia({audio:this.audioTrackConstraints?this.audioTrackConstraints:!0})).getTracks().forEach(i=>i.stop()),!0}catch(t){return console.warn(`Microphone access denied: ${t}`),!1}}get isRecording(){return this._isRecording}get isPaused(){return this._isPaused}update(){if(super.update(),this.isRecording&&!this.isPaused&&this.maximumDuration!==void 0&&Vt.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"],r=["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(h=>t.flatMap(c=>[`${c}/${h}`]))),...new Set(i.flatMap(h=>r.flatMap(c=>t.flatMap(S=>[`${S}/${h};codecs=${c}`])))),...new Set(i.flatMap(h=>r.flatMap(c=>r.flatMap(S=>t.flatMap(x=>[`${x}/${h};codecs="${c}, ${S}"`])))))].filter(h=>MediaRecorder.isTypeSupported(h))}blobToBase64(t){return new Promise((i,r)=>{const h=new FileReader;h.onloadend=()=>{const c=h.result?.toString().split(",").pop();if(c===void 0)throw new C("base64WithoutPrefix is undefined.");i(c)},h.onerror=r,h.readAsDataURL(t)})}getMimeTypeWithoutCodecs(t){const i=t.match(/^[^;]+/);return i?i[0]:""}getSupportedBackupMimeType(t){const i=this.getMediaRecorderSupportedAudioMimeTypes();for(const r of t)if(i.includes(r))return r}dispose(){}duplicate(t){throw new C(`Method not implemented. ${t}`)}}class Na{static create(t){return new Array}}console.log("\u26AA @m2c2kit/core version 0.3.30 (9f27c146)");export{X as Action,ui as ActivityType,Nt as CanvasKitHelpers,ca as ColorfulMutablePath,fa as Composite,Q as Constants,Gt as ConstraintType,kr as CustomAction,Ur as Dimensions,De as Easings,K as Equal,pa as Equals,$r as EventStore,ve as EventStoreMode,zr as FadeAlphaAction,Wr as FontManager,xa as Game,Mr as GroupAction,zi as I18n,fn as ImageManager,Ui as Label,He as LabelHorizontalAlignmentMode,Br as LayoutConstraint,Ma as LegacyTimer,C as M2Error,H as M2EventType,ne as M2ImageStatus,fe as M2Node,Gr as M2NodeFactory,dt as M2NodeType,jt as M2SoundStatus,V as M2c2KitHelpers,Or as MoveAction,Bi as MutablePath,ts as NoneTransition,Nr as PlayAction,An as RandomDraws,un as RepeatAction,Rr as RepeatForeverAction,Lr as RotateAction,Dr as ScaleAction,Ve as Scene,is as SceneTransition,Fr as SequenceAction,fi as Shape,Kt as ShapeType,es as SlideTransition,ns as SoundManager,Ra as SoundPlayer,ka as SoundRecorder,pi as Sprite,Na as Story,$i as TextLine,Vt as Timer,Ke as Transition,be as TransitionDirection,Se as TransitionType,ze as Uuid,Ir as WaitAction,R as WebColors,Pn as WebGlInfo,Le as handleInterfaceOptions};
1
+ var de=(m=>(m.Node="Node",m.Scene="Scene",m.Sprite="Sprite",m.Label="Label",m.TextLine="TextLine",m.Shape="Shape",m.Composite="Composite",m.SoundPlayer="SoundPlayer",m.SoundRecorder="SoundRecorder",m))(de||{});const je={Deferred:"Deferred",WillFetch:"WillFetch",Fetching:"Fetching",Fetched:"Fetched",Decoding:"Decoding",Ready:"Ready",Error:"Error"};var me=(m=>(m.Sequence="Sequence",m.Group="Group",m.Wait="Wait",m.Custom="Custom",m.Move="Move",m.Scale="Scale",m.FadeAlpha="FadeAlpha",m.Rotate="Rotate",m.Play="Play",m.Repeat="Repeat",m.RepeatForever="RepeatForever",m))(me||{});class C extends Error{constructor(...e){super(...e),this.name="M2Error",Object.setPrototypeOf(this,C.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,C)}}const Me=class re{static toTypeAsString(e){switch(e){case re.none:return"None";case re.linear:return"Linear";case re.quadraticIn:return"QuadraticIn";case re.quadraticOut:return"QuadraticOut";case re.quadraticInOut:return"QuadraticInOut";case re.cubicIn:return"CubicIn";case re.cubicOut:return"CubicOut";case re.cubicInOut:return"CubicInOut";case re.quarticIn:return"QuarticIn";case re.quarticOut:return"QuarticOut";case re.quarticInOut:return"QuarticInOut";case re.quinticIn:return"QuinticIn";case re.quinticOut:return"QuinticOut";case re.quinticInOut:return"QuinticInOut";case re.sinusoidalIn:return"SinusoidalIn";case re.sinusoidalOut:return"SinusoidalOut";case re.sinusoidalInOut:return"SinusoidalInOut";case re.exponentialIn:return"ExponentialIn";case re.exponentialOut:return"ExponentialOut";case re.exponentialInOut:return"ExponentialInOut";case re.circularIn:return"CircularIn";case re.circularOut:return"CircularOut";case re.circularInOut:return"CircularInOut";default:throw new C("Easings.toTypeAsString(): Unknown easing function")}}static fromTypeAsString(e){switch(e){case"None":return re.none;case"Linear":return re.linear;case"QuadraticIn":return re.quadraticIn;case"QuadraticOut":return re.quadraticOut;case"QuadraticInOut":return re.quadraticInOut;case"CubicIn":return re.cubicIn;case"CubicOut":return re.cubicOut;case"CubicInOut":return re.cubicInOut;case"QuarticIn":return re.quarticIn;case"QuarticOut":return re.quarticOut;case"QuarticInOut":return re.quarticInOut;case"QuinticIn":return re.quinticIn;case"QuinticOut":return re.quinticOut;case"QuinticInOut":return re.quinticInOut;case"SinusoidalIn":return re.sinusoidalIn;case"SinusoidalOut":return re.sinusoidalOut;case"SinusoidalInOut":return re.sinusoidalInOut;case"ExponentialIn":return re.exponentialIn;case"ExponentialOut":return re.exponentialOut;case"ExponentialInOut":return re.exponentialInOut;case"CircularIn":return re.circularIn;case"CircularOut":return re.circularOut;case"CircularInOut":return re.circularInOut;default:throw new C(`Easings.fromTypeAsString(): Unknown easing function type ${e}`)}}};Me.none=(m,e,i,r)=>i+e,Me.linear=(m,e,i,r)=>i*m/r+e,Me.quadraticIn=(m,e,i,r)=>(m/=r,i*m*m+e),Me.quadraticOut=(m,e,i,r)=>(m/=r,-i*m*(m-2)+e),Me.quadraticInOut=(m,e,i,r)=>(m/=r/2,m<1?i/2*m*m+e:(m--,-i/2*(m*(m-2)-1)+e)),Me.cubicIn=(m,e,i,r)=>(m/=r,i*m*m*m+e),Me.cubicOut=(m,e,i,r)=>(m/=r,m--,i*(m*m*m+1)+e),Me.cubicInOut=(m,e,i,r)=>(m/=r/2,m<1?i/2*m*m*m+e:(m-=2,i/2*(m*m*m+2)+e)),Me.quarticIn=(m,e,i,r)=>(m/=r,i*m*m*m*m+e),Me.quarticOut=(m,e,i,r)=>(m/=r,m--,-i*(m*m*m*m-1)+e),Me.quarticInOut=(m,e,i,r)=>(m/=r/2,m<1?i/2*m*m*m*m+e:(m-=2,-i/2*(m*m*m*m-2)+e)),Me.quinticIn=(m,e,i,r)=>(m/=r,i*m*m*m*m*m+e),Me.quinticOut=(m,e,i,r)=>(m/=r,m--,i*(m*m*m*m*m+1)+e),Me.quinticInOut=(m,e,i,r)=>(m/=r/2,m<1?i/2*m*m*m*m*m+e:(m-=2,i/2*(m*m*m*m*m+2)+e)),Me.sinusoidalIn=(m,e,i,r)=>-i*Math.cos(m/r*(Math.PI/2))+i+e,Me.sinusoidalOut=(m,e,i,r)=>i*Math.sin(m/r*(Math.PI/2))+e,Me.sinusoidalInOut=(m,e,i,r)=>-i/2*(Math.cos(Math.PI*m/r)-1)+e,Me.exponentialIn=(m,e,i,r)=>i*Math.pow(2,10*(m/r-1))+e,Me.exponentialOut=(m,e,i,r)=>i*(-Math.pow(2,-10*m/r)+1)+e,Me.exponentialInOut=(m,e,i,r)=>(m/=r/2,m<1?i/2*Math.pow(2,10*(m-1))+e:(m--,i/2*(-Math.pow(2,-10*m)+2)+e)),Me.circularIn=(m,e,i,r)=>(m/=r,-i*(Math.sqrt(1-m*m)-1)+e),Me.circularOut=(m,e,i,r)=>(m/=r,m--,i*Math.sqrt(1-m*m)+e),Me.circularInOut=(m,e,i,r)=>(m/=r/2,m<1?-i/2*(Math.sqrt(1-m*m)-1)+e:(m-=2,i/2*(Math.sqrt(1-m*m)+1)+e));let Dt=Me;var Ke=(m=>(m.Undefined="Undefined",m.Rectangle="Rectangle",m.Circle="Circle",m.Path="Path",m))(Ke||{});const Mr=class aa{constructor(e){this.startTime=NaN,this.stopTime=NaN,this.stopped=!0,this.cumulativeElapsed=NaN,this.name=e}static now(){return window.performance.now()}static new(e){this._timers=this._timers.filter(r=>r.name!==e);const i=new aa(e);i.cumulativeElapsed=0,this._timers.push(i)}static startNew(e){this.new(e),this.start(e)}static start(e){const i=this._timers.filter(r=>r.name===e).find(Boolean);if(i===void 0)throw new C(`can't start timer. timer with name ${e} does not exist.`);if(i.stopped===!1)throw new C(`can't start timer. timer with name ${e} is already started.`);i.startTime=window.performance.now(),i.stopped=!1}static stop(e){const i=this._timers.filter(r=>r.name===e).find(Boolean);if(i===void 0)throw new C(`can't stop timer. timer with name ${e} does not exist.`);if(i.stopped===!0)throw new C(`can't stop timer. timer with name ${e} is already stopped.`);i.stopTime=window.performance.now(),i.cumulativeElapsed=i.cumulativeElapsed+i.stopTime-i.startTime,i.stopped=!0}static elapsed(e){const i=this._timers.filter(r=>r.name===e).find(Boolean);if(i===void 0)throw new C(`can't get elapsed time. timer with name ${e} does not exist.`);return i.stopped?i.cumulativeElapsed:i.cumulativeElapsed+window.performance.now()-i.startTime}static remove(e){if(this._timers.filter(r=>r.name===e).find(Boolean)===void 0)throw new C(`can't remove timer. timer with name ${e} does not exist.`);this._timers=this._timers.filter(r=>r.name!=e)}static removeAll(){this._timers=new Array}static exists(e){return this._timers.some(i=>i.name===e)}};Mr._timers=new Array;let Ve=Mr;class R{}R.Transparent=[0,0,0,0],R.MediumVioletRed=[199,21,133,1],R.DeepPink=[255,20,147,1],R.PaleVioletRed=[219,112,147,1],R.HotPink=[255,105,180,1],R.LightPink=[255,182,193,1],R.Pink=[255,192,203,1],R.DarkRed=[139,0,0,1],R.Red=[255,0,0,1],R.Firebrick=[178,34,34,1],R.Crimson=[220,20,60,1],R.IndianRed=[205,92,92,1],R.LightCoral=[240,128,128,1],R.Salmon=[250,128,114,1],R.DarkSalmon=[233,150,122,1],R.LightSalmon=[255,160,122,1],R.OrangeRed=[255,69,0,1],R.Tomato=[255,99,71,1],R.DarkOrange=[255,140,0,1],R.Coral=[255,127,80,1],R.Orange=[255,165,0,1],R.DarkKhaki=[189,183,107,1],R.Gold=[255,215,0,1],R.Khaki=[240,230,140,1],R.PeachPuff=[255,218,185,1],R.Yellow=[255,255,0,1],R.PaleGoldenrod=[238,232,170,1],R.Moccasin=[255,228,181,1],R.PapayaWhip=[255,239,213,1],R.LightGoldenrodYellow=[250,250,210,1],R.LemonChiffon=[255,250,205,1],R.LightYellow=[255,255,224,1],R.Maroon=[128,0,0,1],R.Brown=[165,42,42,1],R.SaddleBrown=[139,69,19,1],R.Sienna=[160,82,45,1],R.Chocolate=[210,105,30,1],R.DarkGoldenrod=[184,134,11,1],R.Peru=[205,133,63,1],R.RosyBrown=[188,143,143,1],R.Goldenrod=[218,165,32,1],R.SandyBrown=[244,164,96,1],R.Tan=[210,180,140,1],R.Burlywood=[222,184,135,1],R.Wheat=[245,222,179,1],R.NavajoWhite=[255,222,173,1],R.Bisque=[255,228,196,1],R.BlanchedAlmond=[255,235,205,1],R.Cornsilk=[255,248,220,1],R.DarkGreen=[0,100,0,1],R.Green=[0,128,0,1],R.DarkOliveGreen=[85,107,47,1],R.ForestGreen=[34,139,34,1],R.SeaGreen=[46,139,87,1],R.Olive=[128,128,0,1],R.OliveDrab=[107,142,35,1],R.MediumSeaGreen=[60,179,113,1],R.LimeGreen=[50,205,50,1],R.Lime=[0,255,0,1],R.SpringGreen=[0,255,127,1],R.MediumSpringGreen=[0,250,154,1],R.DarkSeaGreen=[143,188,143,1],R.MediumAquamarine=[102,205,170,1],R.YellowGreen=[154,205,50,1],R.LawnGreen=[124,252,0,1],R.Chartreuse=[127,255,0,1],R.LightGreen=[144,238,144,1],R.GreenYellow=[173,255,47,1],R.PaleGreen=[152,251,152,1],R.Teal=[0,128,128,1],R.DarkCyan=[0,139,139,1],R.LightSeaGreen=[32,178,170,1],R.CadetBlue=[95,158,160,1],R.DarkTurquoise=[0,206,209,1],R.MediumTurquoise=[72,209,204,1],R.Turquoise=[64,224,208,1],R.Aqua=[0,255,255,1],R.Cyan=[0,255,255,1],R.Aquamarine=[127,255,212,1],R.PaleTurquoise=[175,238,238,1],R.LightCyan=[224,255,255,1],R.Navy=[0,0,128,1],R.DarkBlue=[0,0,139,1],R.MediumBlue=[0,0,205,1],R.Blue=[0,0,255,1],R.MidnightBlue=[25,25,112,1],R.RoyalBlue=[65,105,225,1],R.SteelBlue=[70,130,180,1],R.DodgerBlue=[30,144,255,1],R.DeepSkyBlue=[0,191,255,1],R.CornflowerBlue=[100,149,237,1],R.SkyBlue=[135,206,235,1],R.LightSkyBlue=[135,206,250,1],R.LightSteelBlue=[176,196,222,1],R.LightBlue=[173,216,230,1],R.PowderBlue=[176,224,230,1],R.Indigo=[75,0,130,1],R.Purple=[128,0,128,1],R.DarkMagenta=[139,0,139,1],R.DarkViolet=[148,0,211,1],R.DarkSlateBlue=[72,61,139,1],R.BlueViolet=[138,43,226,1],R.DarkOrchid=[153,50,204,1],R.Fuchsia=[255,0,255,1],R.Magenta=[255,0,255,1],R.SlateBlue=[106,90,205,1],R.MediumSlateBlue=[123,104,238,1],R.MediumOrchid=[186,85,211,1],R.MediumPurple=[147,112,219,1],R.Orchid=[218,112,214,1],R.Violet=[238,130,238,1],R.Plum=[221,160,221,1],R.Thistle=[216,191,216,1],R.Lavender=[230,230,250,1],R.MistyRose=[255,228,225,1],R.AntiqueWhite=[250,235,215,1],R.Linen=[250,240,230,1],R.Beige=[245,245,220,1],R.WhiteSmoke=[245,245,245,1],R.LavenderBlush=[255,240,245,1],R.OldLace=[253,245,230,1],R.AliceBlue=[240,248,255,1],R.Seashell=[255,245,238,1],R.GhostWhite=[248,248,255,1],R.Honeydew=[240,255,240,1],R.FloralWhite=[255,250,240,1],R.Azure=[240,255,255,1],R.MintCream=[245,255,250,1],R.Snow=[255,250,250,1],R.Ivory=[255,255,240,1],R.White=[255,255,255,1],R.Black=[0,0,0,1],R.DarkSlateGray=[47,79,79,1],R.DimGray=[105,105,105,1],R.SlateGray=[112,128,144,1],R.Gray=[128,128,128,1],R.LightSlateGray=[119,136,153,1],R.DarkGray=[169,169,169,1],R.Silver=[192,192,192,1],R.LightGray=[211,211,211,1],R.Gainsboro=[220,220,220,1],R.RebeccaPurple=[102,51,153,1];class Q{}Q.FPS_DISPLAY_TEXT_FONT_SIZE=12,Q.FPS_DISPLAY_TEXT_COLOR=[0,0,0,.5],Q.FPS_DISPLAY_UPDATE_INTERVAL=1e3,Q.MAXIMUM_RECORDED_ACTIVITY_METRICS=32,Q.FPS_METRIC_REPORT_THRESHOLD=59,Q.DEFAULT_SCENE_BACKGROUND_COLOR=R.White,Q.DEFAULT_SHAPE_FILL_COLOR=R.Red,Q.DEFAULT_PATH_STROKE_COLOR=R.Red,Q.DEFAULT_PATH_LINE_WIDTH=2,Q.DEFAULT_FONT_COLOR=R.Black,Q.DEFAULT_FONT_SIZE=16,Q.LIMITED_FPS_RATE=5,Q.FREE_NODES_SCENE_NAME="__freeNodesScene",Q.OUTGOING_SCENE_NAME="__outgoingScene",Q.OUTGOING_SCENE_SPRITE_NAME="__outgoingSceneSprite",Q.OUTGOING_SCENE_IMAGE_NAME="__outgoingSceneSnapshot",Q.SESSION_INITIALIZATION_POLLING_INTERVAL_MS=50,Q.MODULE_METADATA_PLACEHOLDER={name:"",version:"",dependencies:{}},Q.DEFAULT_ROOT_ELEMENT_ID="m2c2kit",Q.ERUDA_URL="https://cdn.jsdelivr.net/npm/eruda@3.4.1/eruda.js",Q.ERUDA_SRI="sha384-daS5bEfWdSq146t9c4BureB/fQWO3lHohseXBelPqKvbOUx2D6PE3TxcQ9jrKZDM";class V{static getUrlFromManifest(e,i){const r=e.manifest;return r&&r[i]?r[i]:i}static urlHasScheme(e){return/^[a-z]+:\/\//i.test(e)}static sanitizeParameters(e){if(!e)return;if(typeof e!="object"||Array.isArray(e))throw new C("failed to sanitize parameters: parameters must be an object of key-value pairs");let i;try{i=JSON.parse(JSON.stringify(e))}catch(r){throw new C(`failed to sanitize parameters. check for circular references. Original error: ${r}`)}return Object.keys(i).reduce((r,h)=>(h!=="__proto__"&&h!=="constructor"&&h!=="prototype"&&(r[h]=i[h]),r),Object.create(null))}static convertValueToType(e,i){function r(U){return typeof U=="string"||typeof U=="object"||!Number.isNaN(parseFloat(U))||typeof U=="boolean"}function h(U){if(typeof U=="string")return U;if(typeof U=="object")return console.warn(`convertValueToType() converted an object to a string. This may not be the desired behavior. The object was: ${JSON.stringify(U)}`),JSON.stringify(U);if(!Number.isNaN(parseFloat(U)))return U;if(typeof U=="boolean")return U.toString();throw new C(`Error parsing "${U}" as a string.`)}function c(U){if(typeof U=="number")return!0;if(typeof U!="string")return!1;const ue=parseFloat(U);return!Number.isNaN(ue)}function S(U){if(typeof U=="number")return U;if(typeof U!="string")throw new C(`Error parsing "${U}" as a number.`);const ue=parseFloat(U);if(Number.isNaN(ue))throw new C(`Error parsing "${U}" as a number.`);return ue}function E(U){if(typeof U=="number")return!0;if(typeof U!="string")return!1;const ue=parseInt(U);return!Number.isNaN(ue)}function O(U){if(typeof U=="number")return U;if(typeof U!="string")throw new C(`Error parsing "${U}" as an integer.`);const ue=parseInt(U);if(Number.isNaN(ue))throw new C(`Error parsing "${U}" as an integer.`);return ue}function G(U){return typeof U=="boolean"?!0:!(U!=="true"&&U!=="false")}function K(U){if(typeof U=="boolean")return U;if(U!=="true"&&U!=="false")throw new C(`Error parsing "${U}" as a boolean.`);return U==="true"}function ie(U){if(Array.isArray(U))return!0;if(typeof U!="string")return!1;try{const ue=JSON.parse(U);if(Array.isArray(ue))return!0}catch{const ue=JSON.parse(decodeURIComponent(U));if(Array.isArray(ue))return!0}return!1}function le(U){if(Array.isArray(U))return U;if(typeof U!="string")throw new C(`Error parsing "${U}" as an array.`);try{const ue=JSON.parse(U);if(Array.isArray(ue))return ue}catch{const ue=JSON.parse(decodeURIComponent(U));if(Array.isArray(ue))return ue}throw new C(`Error parsing "${U}" as an array.`)}function ye(U){if(typeof U=="object"&&!Array.isArray(U)&&U!==null)return!0;if(typeof U!="string")return!1;try{const ue=JSON.parse(U);if(typeof ue=="object"&&!Array.isArray(ue)&&ue!==null)return!0}catch{const ue=JSON.parse(decodeURIComponent(U));if(typeof ue=="object"&&!Array.isArray(ue)&&ue!==null)return!0}return!1}function ae(U){if(typeof U=="object"&&!Array.isArray(U)&&U!==null)return U;if(typeof U!="string")throw new C(`Error parsing "${U}" as an object.`);try{const ue=JSON.parse(U);if(typeof ue=="object"&&!Array.isArray(ue)&&ue!==null)return ue}catch{const ue=JSON.parse(decodeURIComponent(U));if(typeof ue=="object"&&!Array.isArray(ue)&&ue!==null)return ue}throw new C(`Error parsing "${U}" as an object.`)}function Ee(U){return U===null||U==="null"}function We(U){if(U!=="null"&&U!==null)throw new C(`Error parsing "${U}" as null.`);return null}const Be={string:r,number:c,integer:E,boolean:G,array:ie,object:ye,null:Ee},at={string:h,number:S,integer:O,boolean:K,array:le,object:ae,null:We};if(i===void 0)throw new C(`Error with "${e}" as a target type.`);if(!Array.isArray(i)){if(Be[i](e))return at[i](e);throw new C(`Error parsing "${e}" as a ${i}.`)}for(const U of i)if(Be[U](e))return at[U](e);throw new C(`Error parsing "${e}" as one of ${i}.`)}static loadScriptUrls(e){if(!Array.isArray(e)||!e.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}e.forEach(i=>{if(!m2c2Globals.addedScriptUrls.includes(i)){const r=document.createElement("script");r.src=i,r.async=!0,document.head.appendChild(r),console.log(`\u26AA added script: ${i}`),m2c2Globals.addedScriptUrls.push(i)}})}static loadEruda(e=100,i=50){if(m2c2Globals.erudaRequested===!0)return;console.log(`\u26AA added eruda script: ${Q.ERUDA_URL}`);const r=document.createElement("script");r.src=Q.ERUDA_URL,r.integrity=Q.ERUDA_SRI,r.crossOrigin="anonymous",r.async=!0,document.head.appendChild(r),m2c2Globals.erudaRequested=!0;let h=0;const c=()=>{const S=window?.eruda;typeof S<"u"?(console.log("\u26AA eruda ready"),S.init(),m2c2Globals.erudaInitialized=!0):h<i?(h++,setTimeout(c,e)):console.log(`eruda was requested, but could not be loaded after ${e*i} milliseconds.`)};c()}static registerM2NodeClass(...e){m2c2Globals.m2NodeClassRegistry||(m2c2Globals.m2NodeClassRegistry={}),e.forEach(i=>{m2c2Globals.m2NodeClassRegistry={...m2c2Globals.m2NodeClassRegistry,[i.name]:i}})}static createFrameUpdateTimestamps(){return{timestamp:Number.isNaN(m2c2Globals?.now)||m2c2Globals?.now===void 0?Ve.now():m2c2Globals.now,iso8601Timestamp:m2c2Globals.iso8601Now?m2c2Globals.iso8601Now:new Date().toISOString()}}static createTimestamps(){return{timestamp:Ve.now(),iso8601Timestamp:new Date().toISOString()}}static calculateRotatedPoints(e){const i=e.ancestors;i.reverse(),i.push(e);const r=i.map(h=>{const c=V.calculateNodeAbsoluteBoundingBox(h);return V.boundingBoxToPoints(c)});for(let h=0;h<r.length;h++){if(!un(i[h]))continue;const c=r[h],S=i[h].zRotation,E=V.findCentroid(c);for(let O=h;O<i.length;O++)r[O]=hs(r[O],S,E)}return r[r.length-1]}static rotateCanvasForDrawableNode(e,i){const r=V.calculateRotationTransforms(i);if(r.length===0)return;const h=m2c2Globals.canvasScale/i.absoluteScale;ls(r,h,e)}static calculateNodeAbsoluteBoundingBox(e){const i=e.anchorPoint,r=e.absoluteScale;let h=e.size.width,c=e.size.height;if(e.type===de.Shape&&e.shapeType===Ke.Circle){const K=e.circleOfRadius;if(!K)throw"circleOfRadius is undefined";h=K*2,c=K*2}const S=e.absolutePosition.x-h*i.x*r,E=e.absolutePosition.x+h*(1-i.x)*r,O=e.absolutePosition.y-c*i.y*r,G=e.absolutePosition.y+c*(1-i.y)*r;return{xMin:S,xMax:E,yMin:O,yMax:G}}static radiansToDegrees(e){return-V.normalizeAngleRadians(e)*(180/Math.PI)}static normalizeAngleRadians(e){const i=Math.floor(e/(2*Math.PI));let r=e-i*(2*Math.PI);return r<0&&(r+=2*Math.PI),r}static arePointsOnSameSideOfLine(e,i,r,h){const c=(h.x-r.x)*(e.y-r.y)-(h.y-r.y)*(e.x-r.x),S=(h.x-r.x)*(i.y-r.y)-(h.y-r.y)*(i.x-r.x);return c*S>=0}static isPointInsideRectangle(e,i){if(i.length!==4)throw new C("Invalid input: expected an array of four points");return V.arePointsOnSameSideOfLine(e,i[2],i[0],i[1])&&V.arePointsOnSameSideOfLine(e,i[3],i[1],i[2])&&V.arePointsOnSameSideOfLine(e,i[0],i[2],i[3])&&V.arePointsOnSameSideOfLine(e,i[1],i[3],i[0])}static nodeOrAncestorHasBeenRotated(e){const i=e.ancestors;return i.push(e),i.some(r=>un(r))}static boundingBoxToPoints(e){const{xMin:i,xMax:r,yMin:h,yMax:c}=e;return[{x:i,y:h},{x:r,y:h},{x:r,y:c},{x:i,y:c}]}static findCentroid(e){if(e.length!==4)throw new C("Invalid input: expected an array of four points");let i=0,r=0;for(const S of e)i+=S.x,r+=S.y;const h=i/4,c=r/4;return{x:h,y:c}}static rotatePoint(e,i,r){const h=e.x-r.x,c=e.y-r.y,S=h*Math.cos(-i)-c*Math.sin(-i),E=h*Math.sin(-i)+c*Math.cos(-i);return{x:S+r.x,y:E+r.y}}static calculateRotationTransforms(e){const i=[],r=e.ancestors;return r.reverse(),r.push(e),r.forEach(h=>{if(un(h)){const c=h;if(c.type===de.Scene){const G={x:c.absolutePosition.x+c.size.width*.5,y:c.absolutePosition.y+c.size.height*.5};i.push({radians:c.zRotation,center:G});return}const S=V.calculateNodeAbsoluteBoundingBox(c),E=V.boundingBoxToPoints(S),O=V.findCentroid(E);i.push({radians:c.zRotation,center:O})}}),i}}function ls(m,e,i){m.forEach(r=>{i.rotate(V.radiansToDegrees(r.radians),r.center.x*e,r.center.y*e)})}function un(m){return V.normalizeAngleRadians(m.zRotation)!==0&&m.isDrawable}function hs(m,e,i){if(m.length!==4)throw new C("Invalid input: expected an array of four points");const r=[];for(const h of m)r.push(V.rotatePoint(h,e,i));return r}class Le{constructor(e){if(this.expression=new Array,this.WARNING_EXPRESSION_LENGTH=32,typeof e=="number"){this.pushToExpression(e);return}if(e===void 0){this.pushToExpression(1/0);return}this.pushToExpression(e)}pushToExpression(e){if(e===this)throw new C("Cannot add, subtract, or assign a Futurable with itself.");this.expression.push(e),this.expression.length===this.WARNING_EXPRESSION_LENGTH&&console.warn(`Expression length is ${this.WARNING_EXPRESSION_LENGTH} elements. Something may be wrong.`)}assign(e){for(;this.expression.length>0;)this.expression.pop();this.pushToExpression(e)}add(...e){return this.appendOperation(Di.Add,...e),this}subtract(...e){return this.appendOperation(Di.Subtract,...e),this}appendOperation(e,...i){i.forEach(r=>{this.pushToExpression(e),this.pushToExpression(r)})}get value(){let e=0;const i=this.expression.flat(1/0);let r=1;for(let h=0;h<i.length;h++){if(typeof i[h]=="number"){e=e+r*i[h];continue}if(i[h]instanceof Le){e=e+r*i[h].value;continue}if(i[h]===Di.Add){r=1;continue}if(i[h]===Di.Subtract){r=-1;continue}}return e}}const Di={Add:"Add",Subtract:"Subtract"};class X{constructor(e=!1){this.startOffset=new Le(0),this.started=!1,this.running=!1,this._completed=!1,this.runStartTime=-1,this.duration=new Le,this.runDuringTransition=e}initialize(e){const i=this.clone();return this.assignParents(i,i,e),this.propagateRunDuringTransition(i),this.assignDurations(i),this.assignStartOffsets(i),i}assignParents(e,i,r){if(r!==void 0&&(e.key=r),this.isParent(e)){const h=e.children;h.forEach(c=>{c.parent=e}),h.filter(c=>this.isParent(c)).forEach(c=>this.assignParents(c,i,r))}}propagateRunDuringTransition(e){this.isParent(e)&&(e.descendants.some(i=>i.runDuringTransition)&&(e.runDuringTransition=!0),e.children.forEach(i=>this.propagateRunDuringTransition(i)))}assignDurations(e){e.duration=this.calculateDuration(e),this.isParent(e)&&e.children.forEach(i=>this.assignDurations(i))}calculateDuration(e){if(e.type===me.Group){const r=e.children.map(h=>this.calculateDuration(h)).reduce((h,c)=>Math.max(h,c.value),0);return new Le(r)}if(e.type===me.Sequence){const r=e.children.map(h=>this.calculateDuration(h)).reduce((h,c)=>h+c.value,0);return new Le(r)}return this.isRepeating(e)?new Le:e.duration}assignStartOffsets(e){e.startOffset=this.calculateStartOffset(e),this.isParent(e)&&e.children.forEach(i=>this.assignStartOffsets(i))}calculateStartOffset(e){if(e.parent===void 0)return new Le(0);if(e.parent.type!==me.Sequence)return e.parent.startOffset;const i=new Le(0);i.add(e.parent.startOffset);for(const r of e.parent.children){if(r===e)break;i.add(r.duration)}return i}static evaluateAction(e,i,r,h){if(i.involvedInSceneTransition()&&!e.runDuringTransition||(e.runStartTime===-1&&e.assignRunStartTimes(e,r),r<e.runStartTime+e.startOffset.value))return;if(e.shouldBeRunning(r)&&(e.running=!0),e.isParent(e)){if(e.children.forEach(S=>{X.evaluateAction(S,i,r,h)}),!e.isRepeating(e)){e.started||(e.started=!0),e.running&&e.completed&&(e.running=!1);return}X.evaluateRepeatingActions(e,r);return}if(e.shouldBeRunning(r)||(e.running=!1),e.running===!1&&e.completed===!0)return;const c=r-(e.runStartTime+e.startOffset.value);switch(e.type){case me.Custom:X.evaluateCustomAction(e);break;case me.Play:X.evaluatePlayAction(i,e);break;case me.Wait:X.evaluateWaitAction(e,r);break;case me.Move:X.evaluateMoveAction(e,i,c);break;case me.Scale:X.evaluateScaleAction(e,i,c,h);break;case me.FadeAlpha:X.evaluateFadeAlphaAction(e,i,c,h);break;case me.Rotate:X.evaluateRotateAction(e,i,c,h);break;default:throw new C(`Action type not recognized: ${e.type}`)}}static evaluateRepeatingActions(e,i){if(e.started||(e.started=!0),e.repetitionHasCompleted){e.completedRepetitions++;const r=e.children[0].duration.value;if(e.cumulativeDuration=e.cumulativeDuration+r,!isFinite(r))throw"repetitionDuration is not finite";if(!e.completed)e.restartAction(e,i);else{if(e.type===me.RepeatForever)throw new C("RepeatForever action should never complete");e.duration.assign(e.cumulativeDuration),e.running=!1}}}static evaluateRotateAction(e,i,r,h){const c=e;c.started||(c.byAngle!==void 0&&(c.delta=c.byAngle),c.toAngle!==void 0&&(c.toAngle=V.normalizeAngleRadians(c.toAngle),i.zRotation=V.normalizeAngleRadians(i.zRotation),c.delta=c.toAngle-i.zRotation,c.shortestUnitArc===!0&&Math.abs(c.delta)>Math.PI&&(c.delta=2*Math.PI-Math.abs(c.delta))),c.started=!0,c.finalValue=i.zRotation+c.delta),r<c.duration.value?(i.zRotation=i.zRotation+c.delta*(h/c.duration.value),c.delta<=0&&i.zRotation<c.finalValue&&(i.zRotation=c.finalValue),c.delta>0&&i.zRotation>c.finalValue&&(i.zRotation=c.finalValue)):(i.zRotation=c.finalValue,c.running=!1,c.completed=!0)}static evaluateFadeAlphaAction(e,i,r,h){const c=e;c.started||(c.delta=c.alpha-i.alpha,c.started=!0),r<c.duration.value?i.alpha=i.alpha+c.delta*(h/c.duration.value):(i.alpha=c.alpha,c.running=!1,c.completed=!0)}static evaluateScaleAction(e,i,r,h){const c=e;c.started||(c.delta=c.scale-i.scale,c.started=!0),r<c.duration.value?i.scale=i.scale+c.delta*(h/c.duration.value):(i.scale=c.scale,c.running=!1,c.completed=!0)}static evaluateMoveAction(e,i,r){const h=e;h.started||(h.dx=h.point.x-i.position.x,h.dy=h.point.y-i.position.y,h.startPoint.x=i.position.x,h.startPoint.y=i.position.y,h.started=!0),r<h.duration.value?(i.position.x=h.easing(r,h.startPoint.x,h.dx,h.duration.value),i.position.y=h.easing(r,h.startPoint.y,h.dy,h.duration.value)):(i.position.x=h.point.x,i.position.y=h.point.y,h.running=!1,h.completed=!0)}static evaluateWaitAction(e,i){const r=e;i>e.runStartTime+e.startOffset.value+e.duration.value&&(r.running=!1,r.completed=!0)}static evaluatePlayAction(e,i){if(e.type!==de.SoundPlayer)throw new C("Play action can only be used with a SoundPlayer");const r=i,h=e,c=h.game.soundManager;if(!r.started){const S=c.getSound(h.soundName);if(S.audioBuffer)S.audioBufferSource=c.audioContext.createBufferSource(),S.audioBufferSource.buffer=S.audioBuffer,S.audioBufferSource.onended=()=>{r.running=!1,r.completed=!0;const E=performance.now()-(i.runStartTime+i.startOffset.value);i.duration.assign(E)},S.audioBufferSource.connect(c.audioContext.destination),S.audioBufferSource.start(),r.started=!0;else{if(S.status===je.Error)throw new C(`error loading sound ${S.soundName} (url ${S.url})`);console.warn(`Play action: audio buffer not ready for sound ${h.soundName} (url: ${S.url}); will try next frame`),S.status===je.Deferred&&c.fetchDeferredSound(S)}}}static evaluateCustomAction(e){const i=e;i.callback(),i.running=!1,i.completed=!0}assignRunStartTimes(e,i){e.runStartTime=i,e.isParent(e)&&e.children.forEach(r=>{e.assignRunStartTimes(r,i)})}restartAction(e,i){if(e.runStartTime=i,e.running=!0,e.started=!0,e.type===me.Play&&(e.duration=new Le),e.isParent(e)){e.children.forEach(r=>{e.restartAction(r,i)});return}e.completed=!1}shouldBeRunning(e){return e>=this.runStartTime+this.startOffset.value&&e<=this.runStartTime+this.startOffset.value+this.duration.value}static move(e){return new Or(e.point,new Le(e.duration),e.easing??Dt.linear,e.runDuringTransition??!1)}static wait(e){return new Ir(new Le(e.duration),e.runDuringTransition??!1)}static custom(e){return new kr(e.callback,e.runDuringTransition??!1)}static play(e){return new Nr(e?.runDuringTransition??!1)}static scale(e){return new Dr(e.scale,new Le(e.duration),e.runDuringTransition)}static fadeAlpha(e){return new Lr(e.alpha,new Le(e.duration),e.runDuringTransition)}static rotate(e){if(e.byAngle!==void 0&&e.toAngle!==void 0)throw new C("rotate Action: cannot specify both byAngle and toAngle");if(e.byAngle===void 0&&e.toAngle===void 0)throw new C("rotate Action: must specify either byAngle or toAngle");if(e.toAngle===void 0&&e.shortestUnitArc!==void 0)throw new C("rotate Action: shortestUnitArc can only be specified when toAngle is provided");return e.toAngle!==void 0&&e.shortestUnitArc===void 0&&(e.shortestUnitArc=!0),new zr(e.byAngle,e.toAngle,e.shortestUnitArc,new Le(e.duration),e.runDuringTransition)}static sequence(e){const i=new xr(e);return i.children=e,i}static group(e){const i=new Fr(e);return i.children=e,i}static repeat(e){return new dn(e.action,e.count,e.runDuringTransition)}static repeatForever(e){return new Rr(e.action,e.runDuringTransition)}isParent(e){return e.type===me.Group||e.type===me.Sequence||e.type===me.Repeat||e.type===me.RepeatForever}isRepeating(e){return e.type===me.Repeat||e.type===me.RepeatForever}get completed(){return this._completed}set completed(e){this._completed=e}}class xr extends X{constructor(e){super(),this.type=me.Sequence,this.children=e}clone(){const e=this.children.map(r=>r.clone()),i=X.sequence(e);return i.children.forEach(r=>r.key=this.key),i.key=this.key,i}get completed(){return this.children.every(e=>e.completed)}get descendants(){return fn(this)}}class Fr extends X{constructor(e){super(),this.type=me.Group,this.children=new Array,this.children=e}clone(){const e=this.children.map(r=>r.clone()),i=X.group(e);return i.children.forEach(r=>r.key=this.key),i.key=this.key,i}get completed(){return this.children.every(e=>e.completed)}get descendants(){return fn(this)}}class dn extends X{constructor(e,i,r=!1){super(r),this.type=me.Repeat,this.completedRepetitions=0,this.cumulativeDuration=0,this.children=[e],this.count=i,this.duration=new Le}clone(){if(this.children.length!==1)throw new C("Repeat action must have exactly one child");const e=X.repeat({action:this.children[0].clone(),count:this.count,runDuringTransition:this.runDuringTransition});return e.children[0].key=this.key,e.key=this.key,e}get completed(){return this.children.every(e=>e.completed)&&this.completedRepetitions===this.count}get descendantsAreCompleted(){return this.children.every(e=>e.completed)}get repetitionHasCompleted(){return this.running&&this.descendantsAreCompleted&&!this.completed}get descendants(){return fn(this)}}class Rr extends dn{constructor(e,i=!1){super(e,1/0,i),this.type=me.RepeatForever,this.count=1/0}clone(){if(this.children.length!==1)throw new C("RepeatForever action must have exactly one child");const e=X.repeatForever({action:this.children[0].clone(),runDuringTransition:this.runDuringTransition});return e.children[0].key=this.key,e.key=this.key,e}}function fn(m){const e=[];function i(r){if(r.isParent(r))for(const h of r.children)e.push(h),i(h)}return i(m),e}class kr extends X{constructor(e,i=!1){super(i),this.type=me.Custom,this.callback=e,this.duration=new Le(0)}clone(){const e=X.custom({callback:this.callback,runDuringTransition:this.runDuringTransition});return e.key=this.key,e}}class Nr extends X{constructor(e=!1){super(e),this.type=me.Play,this.duration=new Le}clone(){const e=X.play({runDuringTransition:this.runDuringTransition});return e.key=this.key,e}}class Ir extends X{constructor(e,i){super(i),this.type=me.Wait,this.duration=e}clone(){const e=X.wait({duration:this.duration.value,runDuringTransition:this.runDuringTransition});return e.key=this.key,e}}class Or extends X{constructor(e,i,r,h){super(h),this.type=me.Move,this.startPoint={x:NaN,y:NaN},this.dx=0,this.dy=0,this.duration=i,this.point=e,this.easing=r}clone(){const e=X.move({point:this.point,duration:this.duration.value,easing:this.easing,runDuringTransition:this.runDuringTransition});return e.key=this.key,e}}class Dr extends X{constructor(e,i,r=!1){super(r),this.type=me.Scale,this.delta=0,this.duration=i,this.scale=e}clone(){const e=X.scale({scale:this.scale,duration:this.duration.value,runDuringTransition:this.runDuringTransition});return e.key=this.key,e}}class Lr extends X{constructor(e,i,r=!1){super(r),this.type=me.FadeAlpha,this.delta=0,this.duration=i,this.alpha=e}clone(){const e=X.fadeAlpha({alpha:this.alpha,duration:this.duration.value,runDuringTransition:this.runDuringTransition});return e.key=this.key,e}}class zr extends X{constructor(e,i,r,h,c=!1){super(c),this.type=me.Rotate,this.delta=0,this.finalValue=NaN,this.duration=h,this.byAngle=e,this.toAngle=i,this.shortestUnitArc=r}clone(){const e=X.rotate({byAngle:this.byAngle,toAngle:this.toAngle,shortestUnitArc:this.shortestUnitArc,duration:this.duration.value,runDuringTransition:this.runDuringTransition});return e.key=this.key,e}}var ui=(m=>(m.Game="Game",m.Survey="Survey",m))(ui||{});class Ne{static Dispose(e){e.filter(i=>!i?.isDeleted()).forEach(i=>i?.delete())}static makePaint(e,i,r,h){const c=new e.Paint;return c.setColor(e.Color(i[0],i[1],i[2],i[3])),c.setStyle(r),c.setAntiAlias(h),c}}class Ui{constructor(){this._subpaths=new Array,this.currentPath=new Array}get subpaths(){return this.currentPath.length>0?[...this._subpaths,this.currentPath]:this._subpaths}move(e){this.currentPath.length>0&&this._subpaths.push(this.currentPath),this.currentPath=new Array,this.currentPath.push(e)}addLine(e){this.currentPath.push(e)}clear(){this._subpaths=new Array,this.currentPath=new Array}duplicate(){const e=new Ui;return e._subpaths=JSON.parse(JSON.stringify(this._subpaths)),e.currentPath=JSON.parse(JSON.stringify(this.currentPath)),e}}class cs extends Ui{constructor(){super(...arguments),this.strokeColor=Q.DEFAULT_PATH_STROKE_COLOR,this.lineWidth=Q.DEFAULT_PATH_LINE_WIDTH,this.linePresentations=[]}addLine(e){this.isNewLinePresentation()&&this.linePresentations.push({strokeColor:this.strokeColor,lineWidth:this.lineWidth,subpathIndex:this._subpaths.length,pointIndex:this.currentPath.length-1}),this.currentPath.push(e)}isNewLinePresentation(){if(this.linePresentations.length===0)return!0;const e=this.linePresentations[this.linePresentations.length-1];return e.strokeColor!==this.strokeColor||e.lineWidth!==this.lineWidth}clear(){super.clear(),this.linePresentations=[],this.strokeColor=Q.DEFAULT_PATH_STROKE_COLOR,this.lineWidth=Q.DEFAULT_PATH_LINE_WIDTH}duplicate(){const e=super.duplicate();return e.strokeColor=JSON.parse(JSON.stringify(this.strokeColor)),e.lineWidth=this.lineWidth,e.linePresentations=JSON.parse(JSON.stringify(this.linePresentations)),e}}var Ge=(m=>(m.topToTopOf="topToTopOf",m.topToBottomOf="topToBottomOf",m.bottomToTopOf="bottomToTopOf",m.bottomToBottomOf="bottomToBottomOf",m.startToStartOf="startToStartOf",m.startToEndOf="startToEndOf",m.endToEndOf="endToEndOf",m.endToStartOf="endToStartOf",m))(Ge||{});class Br{constructor(e,i){this.verticalConstraint=!1,this.focalNodeMinimum=!1,this.alterNodeMinimum=!1,this.verticalTypes=[Ge.topToTopOf,Ge.topToBottomOf,Ge.bottomToTopOf,Ge.bottomToBottomOf],this.focalNodeMinimumTypes=[Ge.topToTopOf,Ge.topToBottomOf,Ge.startToStartOf,Ge.startToEndOf],this.alterNodeMinimumTypes=[Ge.topToTopOf,Ge.bottomToTopOf,Ge.startToStartOf,Ge.endToStartOf],this.type=e,this.alterNode=i,this.verticalTypes.includes(e)?(this.verticalConstraint=!0,this.focalNodeMinimumTypes.includes(e)?this.focalNodeMinimum=!0:this.focalNodeMinimum=!1,this.alterNodeMinimumTypes.includes(e)?this.alterNodeMinimum=!0:this.alterNodeMinimum=!1):(this.verticalConstraint=!1,this.focalNodeMinimumTypes.includes(e)?this.focalNodeMinimum=!0:this.focalNodeMinimum=!1,this.alterNodeMinimumTypes.includes(e)?this.alterNodeMinimum=!0:this.alterNodeMinimum=!1)}}class Lt{static generate(){try{return crypto.randomUUID()}catch{let e;try{e=()=>crypto.getRandomValues(new Uint8Array(1))[0]}catch{e=()=>Math.floor(Math.random()*256)}return("10000000-1000-4000-8000"+-1e11).replace(/[018]/g,i=>(Number(i)^e()&15>>Number(i)/4).toString(16))}}static isValid(e){return e?e==="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(e):!1}}const H={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",KeyDown:"KeyDown",KeyUp:"KeyUp",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 q{static rgbaColor(e,i){return!e||!i?!1:e[0]===i[0]&&e[1]===i[1]&&e[2]===i[2]&&e[3]===i[3]}static value(e,i){return typeof e!=typeof i?!1:e&&typeof e=="object"&&i&&typeof i=="object"?q.objectsDeepEqual(e,i):e===i}static objectsDeepEqual(e,i){if(e===i)return!0;if(Array.isArray(e)&&Array.isArray(i)){if(e.length!==i.length)return!1;for(let r=0;r<e.length;r++)if(!q.objectsDeepEqual(e[r],i[r]))return!1;return!0}if(typeof e=="object"&&!Array.isArray(e)&&e!==null&&typeof i=="object"&&!Array.isArray(i)&&i!==null){const r=Object.keys(e),h=Object.keys(i);if(r.length!==h.length)return!1;for(const c of r)if(!(c in i)||!q.objectsDeepEqual(e[c],i[c]))return!1;return!0}return!1}}function us(m,e){e.anchorPoint&&(m.anchorPoint=e.anchorPoint),e.zPosition!==void 0&&(m.zPosition=e.zPosition)}function ds(m,e){e.text!==void 0&&(m.text=e.text),e.fontName!==void 0&&(m.fontName=e.fontName),e.fontColor&&(m.fontColor=e.fontColor),e.fontSize!==void 0&&(m.fontSize=e.fontSize),e.interpolation&&(m.interpolation=e.interpolation),e.localize!==void 0&&(m.localize=e.localize)}function zt(m,e){m.isDrawable&&us(m,e),m.isText&&ds(m,e)}class ft{constructor(e={}){this.type=de.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=Lt.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==de.Composite&&(i=this.compositeType),this.name!==this.uuid?`${this.name} (${i}, ${this.uuid})`:`${i} (${this.uuid})`},e.suppressEvents!==void 0&&(this.suppressEvents=e.suppressEvents),this.constructionTimeStamp=Number.isNaN(m2c2Globals?.now)||m2c2Globals?.now===void 0?Ve.now():m2c2Globals.now,this.constructionIso8601TimeStamp=new Date().toISOString(),this.constructionSequence=m2c2Globals.eventSequence,this.options=e,e.uuid!==void 0&&(this.uuid=e.uuid),e.name===void 0?this.name=this.uuid:this.name=e.name,e.position!==void 0&&(this.position=e.position),e.scale!==void 0&&(this.scale=e.scale),e.alpha!==void 0&&(this.alpha=e.alpha),e.zRotation!==void 0&&(this.zRotation=e.zRotation),e.isUserInteractionEnabled!==void 0&&(this.isUserInteractionEnabled=e.isUserInteractionEnabled),e.draggable!==void 0&&(this.draggable=e.draggable),e.hidden!==void 0&&(this.hidden=e.hidden),e.layout!==void 0&&(this.layout=e.layout)}initialize(){throw new C("initialize() called in abstract base class Node.")}get completeNodeOptions(){throw new C("get completeNodeOptions() called in abstract base class Node.")}saveNodeNewEvent(){if(this.suppressEvents)return;const e={type:H.NodeNew,target:this,nodeType:this.type,compositeType:this.type===de.Composite?this.compositeType:void 0,timestamp:this.constructionTimeStamp,iso8601Timestamp:this.constructionIso8601TimeStamp,nodeOptions:this.completeNodeOptions,sequence:this.constructionSequence};this.saveEvent(e)}savePropertyChangeEvent(e,i){if(this.suppressEvents)return;const r={type:H.NodePropertyChange,target:this,uuid:this.uuid,property:e,value:i,...V.createFrameUpdateTimestamps()};this.saveEvent(r)}saveEvent(e){e.sequence===void 0&&(e.sequence=m2c2Globals.eventSequence);try{this.game.eventStore.addEvent(e)}catch{this.nodeEvents.push(e)}}get game(){const e=i=>{if(i.parent)return i.parent.type===de.Scene?i.parent:e(i.parent);throw new C(`Node ${this} has not been added to a scene.`)};return e(this).game}isPartOfGame(){if(this.type===de.Scene&&this._game===void 0)return!1;if(this.type===de.Scene&&this._game!==void 0)return!0;const e=i=>{if(i.parent)return i.parent.type===de.Scene?i.parent:e(i.parent)};return e(this)?._game!==void 0}addChild(e){const i=this.suppressEvents||e.suppressEvents;if(e===this)throw new C(`Cannot add node ${e.toString()} as a child to itself.`);if(e.type==de.Scene)throw new C(`Cannot add scene ${e.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(c=>c!==e).map(c=>c.name).includes(e.name))throw new C(`Cannot add child node ${e.toString()} to parent node ${this.toString()}. A child with name "${e.name}" already exists on this parent.`);let r=new Array;if(this.isPartOfGame())r=this.game.nodes.filter(c=>c.children.includes(e));else{const c=this.descendants;c.includes(e)&&(r=c.filter(S=>S.children.includes(e)).map(S=>S.parent??void 0))}if(r.length===0){e.parent=this,this.children.push(e);const c={type:"NodeAddChild",target:this,uuid:this.uuid,childUuid:e.uuid,...V.createFrameUpdateTimestamps()};i||this.saveEvent(c),this.saveChildEvents(e);return}const h=r.find(Boolean);throw h===this?new C(`Cannot add child node ${e.toString()} to parent node ${this.toString()}. This child already exists on this parent. The child cannot be added again.`):new C(`Cannot add child node ${e.toString()} to parent node ${this.toString()}. This child already exists on other parent node: ${h?.toString()}}. Remove the child from the other parent first.`)}saveChildEvents(e){e.nodeEvents.forEach(i=>{this.saveEvent(i)}),e.nodeEvents.length=0;for(const i of e.children)this.saveChildEvents(i)}removeAllChildren(){this.children.forEach(e=>this.removeChild(e))}removeChild(e){const i=this.suppressEvents||e.suppressEvents;if(this.children.includes(e))e.parent=void 0,this.children=this.children.filter(h=>h!==e);else throw new C(`cannot remove node ${e} from parent ${this} because the node is not currently a child of the parent`);const r={type:"NodeRemoveChild",target:this,uuid:this.uuid,childUuid:e.uuid,...V.createFrameUpdateTimestamps()};i||this.saveEvent(r)}removeChildren(e){e.forEach(i=>{if(!this.children.includes(i))throw new C(`cannot remove node ${i} from parent ${this} because the node is not currently a child of the parent`);this.removeChild(i)})}descendant(e){const i=this.descendants.filter(r=>r.name===e).find(Boolean);if(i===void 0)throw new C(`descendant with name ${e} not found on parent ${this.toString()}`);return i}get descendants(){function e(r,h){h.push(r),r.children.forEach(c=>e(c,h))}const i=new Array;return this.children.forEach(r=>e(r,i)),i}get ancestors(){function e(r,h){return r.type==de.Scene||!r.parent?h:(h.push(r.parent),e(r.parent,h))}const i=new Array;return e(this,i)}involvedInActionAffectingAppearance(){return this.ancestors.concat(this).flatMap(r=>r.actions).some(r=>r.running&&(r.type===me.Move||r.type===me.Scale))}involvedInSceneTransition(){let e;return this.type===de.Scene?e=this:e=this.parentSceneAsNode,e._transitioning}onTapDown(e,i){this.addEventListener(H.TapDown,e,i)}onTapUp(e,i){this.addEventListener(H.TapUp,e,i)}onTapUpAny(e,i){this.addEventListener(H.TapUpAny,e,i)}onTapLeave(e,i){this.addEventListener(H.TapLeave,e,i)}onPointerDown(e,i){this.addEventListener(H.PointerDown,e,i)}onPointerUp(e,i){this.addEventListener(H.PointerUp,e,i)}onPointerMove(e,i){this.addEventListener(H.PointerMove,e,i)}onPointerLeave(e,i){this.addEventListener(H.PointerLeave,e,i)}onDragStart(e,i){this.addEventListener(H.DragStart,e,i)}onDrag(e,i){this.addEventListener(H.Drag,e,i)}onDragEnd(e,i){this.addEventListener(H.DragEnd,e,i)}addEventListener(e,i,r){const h={type:e,nodeUuid:this.uuid,callback:i};r?.replaceExisting&&(this.eventListeners=this.eventListeners.filter(c=>!(c.nodeUuid===h.nodeUuid&&c.type===h.type))),this.eventListeners.push(h)}parseLayoutConstraints(e,i){const r=new Array;return Object.values(Ge).forEach(c=>{if(e[c]!==void 0){let S,E="";if(typeof e[c]=="object")S=e[c];else{const G=e[c];S=i.filter(K=>K.name===G||K.uuid===G).find(Boolean),S||(S=this.game.materializedNodes.filter(K=>K.name===G||K.uuid===G).find(Boolean)),E=`. sibling node named "${G}" has not been added to the game object`}if(S===void 0)throw new C("could not find sibling node for constraint"+E);const O=new Br(c,S);r.push(O)}}),r}calculateYFromConstraint(e,i,r,h){let c=e.alterNode.absolutePosition.y;return e.alterNodeMinimum?e.alterNode.type!==de.Scene&&(c=c-e.alterNode.size.height*.5*h):e.alterNode.type!==de.Scene?c=c+e.alterNode.size.height*.5*h:c=c+e.alterNode.size.height*h,e.focalNodeMinimum?(c=c+this.size.height*.5*h,c=c+i*h):(c=c-this.size.height*.5*h,c=c-r*h),c}calculateXFromConstraint(e,i,r,h){let c=e.alterNode.absolutePosition.x;return e.alterNodeMinimum?e.alterNode.type!==de.Scene&&(c=c-e.alterNode.size.width*.5*h):e.alterNode.type!==de.Scene?c=c+e.alterNode.size.width*.5*h:c=c+e.alterNode.size.width*h,e.focalNodeMinimum?(c=c+this.size.width*.5*h,c=c+i*h):(c=c-this.size.width*.5*h,c=c-r*h),c}calculateAbsoluteAlpha(e,i){const r=i.reduce((h,c)=>h*c.alpha,1);return e*r}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 h=this.layout?.constraints?.horizontalBias??.5,c=this.layout?.constraints?.verticalBias??.5,S=this.layout?.marginTop??0,E=this.layout?.marginBottom??0,O=this.layout?.marginStart??0,G=this.layout?.marginEnd??0,K=this.parseLayoutConstraints(this.layout?.constraints,this.parentSceneAsNode.descendants),ie=this.parent.absoluteScale,le=K.filter(ae=>ae.verticalConstraint).map(ae=>this.calculateYFromConstraint(ae,S,E,ie));le.length===0||(le.length===1?this.absolutePosition.y=le[0]:le.length===2&&(this.absolutePosition.y=Math.min(le[0],le[1])+c*Math.abs(le[0]-le[1])));const ye=K.filter(ae=>!ae.verticalConstraint).map(ae=>this.calculateXFromConstraint(ae,O,G,ie));ye.length===0||(ye.length===1?this.absolutePosition.x=ye[0]:ye.length===2&&(this.absolutePosition.x=Math.min(ye[0],ye[1])+h*Math.abs(ye[0]-ye[1])))}this.actions.forEach(h=>X.evaluateAction(h,this,m2c2Globals.now,m2c2Globals.deltaTime));function e(h,c){const S=new Array;return c===void 0||Object.values(Ge).forEach(O=>{if(c[O]!==void 0){let G,K="";if(typeof c[O]=="object")G=c[O];else{const ie=c[O];let le;h.type===de.Scene?le=h.descendants:le=h.parentSceneAsNode.descendants,G=le.filter(ye=>ye.name===ie||ye.uuid===ie).find(Boolean),G===void 0&&(G=h.game.materializedNodes.filter(ye=>ye.name===ie||ye.uuid===ie).find(Boolean)),G===void 0&&(K=`. sibling node named "${ie}" has not been added to the game object`)}if(G===void 0)throw new C("error getting uuid of sibling constraint"+K);G!==h&&S.push(G.uuid)}}),S}const i=new Map;this.children.forEach(h=>{i.set(h.uuid,e(this,h.layout?.constraints))});const r=this.findTopologicalSort(i);if(r.length>0){const h=r.reverse(),c=new Array;h.forEach(S=>{const E=this.children.filter(O=>O.uuid===S).find(Boolean);if(E===void 0)throw new C("error in dag topological sort");c.push(E)}),c.forEach(S=>S.update())}else this.children.forEach(h=>h.update())}drawChildren(e){this.children.filter(i=>!i.hidden&&i.isDrawable).map(i=>i).sort((i,r)=>i.zPosition-r.zPosition).forEach(i=>i.draw(e))}run(e,i){this.actions.push(e.initialize(i))}removeAction(e){this.actions=this.actions.filter(i=>i.key!==e)}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 C("getDrawableOptions() called object that is not IDrawable");return{anchorPoint:this.anchorPoint,zPosition:this.zPosition}}getTextOptions(){if(!this.isText)throw new C("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===de.Scene)throw new C(`Node ${this} is a scene and cannot have a parent scene`);if(this.parent&&this.parent.type===de.Scene)return this.parent;if(this.parent)return this.parent.parentSceneAsNode;throw new C(`Node ${this} has not been added to a scene`)}get size(){const e=this;return{get height(){return e._size.height},set height(i){q.value(e._size.height,i)||(e._size.height=i,e.savePropertyChangeEvent("size",e.size))},get width(){return e._size.width},set width(i){q.value(e._size.width,i)||(e._size.width=i,e.savePropertyChangeEvent("size",e.size))}}}set size(e){q.value(this._size.width,e.width)||(this._size=e,this.savePropertyChangeEvent("size",this.size))}get position(){const e=this;return{get x(){return e._position.x},set x(i){q.value(e._position.x,i)||(e._position.x=i,e.savePropertyChangeEvent("position",e.position))},get y(){return e._position.y},set y(i){q.value(e._position.y,i)||(e._position.y=i,e.savePropertyChangeEvent("position",e.position))}}}set position(e){q.value(this._position,e)||(this._position=e,this.savePropertyChangeEvent("position",this.position))}get zRotation(){return this._zRotation}set zRotation(e){q.value(this._zRotation,e)||(this._zRotation=e,this.savePropertyChangeEvent("zRotation",e))}get scale(){return this._scale}set scale(e){q.value(this._scale,e)||(this._scale=e,this.savePropertyChangeEvent("scale",e))}get alpha(){return this._alpha}set alpha(e){q.value(this._alpha,e)||(this._alpha=e,this.savePropertyChangeEvent("alpha",e))}get isUserInteractionEnabled(){return this._isUserInteractionEnabled}set isUserInteractionEnabled(e){q.value(this._isUserInteractionEnabled,e)||(this._isUserInteractionEnabled=e,this.savePropertyChangeEvent("isUserInteractionEnabled",e))}get hidden(){return this._hidden}set hidden(e){q.value(this._hidden,e)||(this._hidden=e,this.savePropertyChangeEvent("hidden",e))}get draggable(){return this._draggable}set draggable(e){q.value(this._draggable,e)||(this._draggable=e,this.savePropertyChangeEvent("draggable",e))}get suppressEvents(){return this._suppressEvents}set suppressEvents(e){this._suppressEvents=e}findTopologicalSort(e){const i=[],r=new Map;e.forEach((c,S)=>{r.has(S)||r.set(S,0),c.forEach(E=>{if(r.has(E)){const O=r.get(E);if(O===void 0)throw new C(`Could not find inDegree for edge ${E}`);r.set(E,O+1)}else r.set(E,1)})});const h=[];for(r.forEach((c,S)=>{c==0&&h.push(S)});h.length>0;){const c=h.shift();if(c===void 0)throw"current vertex is undefined";i.push(c),e.has(c)&&e.get(c)?.forEach(S=>{const E=r.get(S);if(E===void 0)throw new C(`Could not find inDegree for edge ${S}`);if(r.has(S)&&E>0){const O=E-1;r.set(S,O),O==0&&h.push(S)}})}return i}}class fs extends ft{constructor(e={}){super(e),this.type=de.Composite,this.compositeType="<compositeType>",this.isDrawable=!0,this._anchorPoint={x:.5,y:.5},this._zPosition=0,zt(this,e)}initialize(){}get anchorPoint(){const e=this;return{get x(){return e._anchorPoint.x},set x(i){q.value(e._anchorPoint.x,i)||(e._anchorPoint.x=i,e.savePropertyChangeEvent("anchorPoint",e.anchorPoint))},get y(){return e._anchorPoint.y},set y(i){q.value(e._anchorPoint.y,i)||(e._anchorPoint.y=i,e.savePropertyChangeEvent("anchorPoint",e.anchorPoint))}}}set anchorPoint(e){q.value(this._anchorPoint,e)||(this._anchorPoint=e,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(e){q.value(this._zPosition,e)||(this._zPosition=e,this.savePropertyChangeEvent("zPosition",e))}dispose(){}update(){super.update()}draw(e){super.drawChildren(e)}handleCompositeEvent(e){}}var Ur=(m=>(m[m.MatchConstraint=0]="MatchConstraint",m))(Ur||{});const nt={Deferred:"Deferred",Loading:"Loading",Ready:"Ready",Error:"Error"};class pn{constructor(e,i){this.images={},this.game=e,this.baseUrls=i,this.canvasKit=e.canvasKit}initializeImages(e){return this.loadImages(e??[])}async loadImages(e){if(e.length===0)return;this.checkImageNamesForDuplicates(e);const i=e.map(r=>{let h=r.url;r.url&&!V.urlHasScheme(r.url)&&(h=V.getUrlFromManifest(this.game,`${this.baseUrls.assets}/${r.url}`)),r.dataUrl&&(h=r.dataUrl);const c={imageName:r.imageName,url:h,originalUrl:h,isFallback:!1,localize:r.localize??!1,svgString:r.svgString,canvaskitImage:void 0,width:r.width,height:r.height,status:r.lazy?nt.Deferred:nt.Loading};return c.localize&&this.configureImageLocalization(c),this.images[r.imageName]=c,c.status===nt.Loading?this.renderM2Image(c):Promise.resolve()});await Promise.all(i)}configureImageLocalization(e){e.fallbackLocalizationUrls=new Array,e.originalUrl&&this.game.i18n?.locale&&(e.status="Deferred",this.game.i18n?.fallbackLocale&&this.game.i18n?.fallbackLocale!==this.game.i18n?.baseLocale&&e.fallbackLocalizationUrls.push(this.localizeImageUrl(e.originalUrl,this.game.i18n.fallbackLocale)),this.game.i18n?.locale===this.game.i18n?.baseLocale?e.url=e.originalUrl:e.url=this.localizeImageUrl(e.originalUrl,this.game.i18n.locale),e.url!==e.originalUrl&&e.fallbackLocalizationUrls.push(e.originalUrl),this.game.i18n.missingLocalizationColor&&!this.missingLocalizationImagePaint&&(this.missingLocalizationImagePaint=Ne.makePaint(this.canvasKit,this.game.i18n.missingLocalizationColor,this.canvasKit.PaintStyle.Stroke,!0),this.missingLocalizationImagePaint.setStrokeWidth(4)))}localizeImageUrl(e,i){const r=e.lastIndexOf(".");if(r===-1)throw new C("URL does not have an extension");return e.slice(0,r)+`.${i}`+e.slice(r)}reinitializeLocalizedImages(){Object.keys(this.game.imageManager.images).forEach(i=>{const r=this.game.imageManager.images[i];r.localize&&this.game.imageManager.configureImageLocalization(r)}),this.game.nodes.filter(i=>i.type===de.Sprite).forEach(i=>{i.needsInitialization=!0})}checkImageNamesForDuplicates(e){const r=(h=>h.filter((c,S)=>h.indexOf(c)!=S))(e.map(h=>h.imageName));if(r.length>0)throw new C(`image names must be unique. these image names are duplicated within a game ${this.game.id}: `+r.join(", "))}prepareDeferredImage(e){return e.status=nt.Loading,e.isFallback=!1,this.renderM2Image(e).catch(async()=>{for(e.isFallback=!0;e.fallbackLocalizationUrls?.length;){e.url=e.fallbackLocalizationUrls.shift();try{await this.renderM2Image(e)}catch(i){if(e.fallbackLocalizationUrls.length===0)throw i instanceof Error?i:new C(`prepareDeferredImage(): unable to render image named ${e.imageName}. image source was ${e.svgString?"svgString":`url: ${e.url}`}`)}}})}renderM2Image(e){const i=document.createElement("img"),r=h=>{if(!this.scratchCanvas||!this.ctx||!this.scale)throw new C("image manager not set up");this.scratchCanvas.width=e.width*this.scale,this.scratchCanvas.height=e.height*this.scale,this.ctx.scale(this.scale,this.scale),this.ctx.clearRect(0,0,e.width,e.height),this.ctx.drawImage(i,0,0,e.width,e.height),this.scratchCanvas.toBlob(c=>{if(!c)throw new C(`renderM2Image(): blob is undefined for ${e.imageName}`);c.arrayBuffer().then(S=>{const E=this.canvasKit.MakeImageFromEncoded(S);if(!E)throw new C(`could not create image with name "${e.imageName}."`);console.log(`image loaded. name: ${e.imageName}, w: ${e.width}, h: ${e.height}`),this.images[e.imageName].canvaskitImage=E,this.images[e.imageName].status=nt.Ready,this.game.nodes.filter(G=>G.type==="Sprite").forEach(G=>{G.imageName===e.imageName&&(G.needsInitialization=!0)}),h()})})};return new Promise((h,c)=>{if(i.width=e.width,i.height=e.height,i.crossOrigin="Anonymous",i.onerror=()=>{c(new Error(`unable to render image named ${e.imageName}. image source was ${e.svgString?"svgString":`url: ${e.url}`}`))},i.onload=()=>{r(h)},!e.svgString&&!e.url)throw new C(`no svgString or url provided for image named ${e.imageName}`);if(e.svgString&&e.url)throw new C(`provide svgString or url. both were provided for image named ${e.imageName}`);if(e.svgString){i.src="data:image/svg+xml,"+encodeURIComponent(e.svgString);const S={type:H.BrowserImageDataReady,target:this,imageName:e.imageName,width:e.width,height:e.height,svgString:e.svgString,...V.createFrameUpdateTimestamps()};this.game.eventStore.addEvent(S)}else e.url&&fetch(e.url).then(S=>S.arrayBuffer()).then(S=>{this.arrayBufferToBase64Async(S).then(E=>{const O=this.inferImageSubtypeFromUrl(e.url);i.src="data:image/"+O+";base64,"+E;const G={type:H.BrowserImageDataReady,target:this,imageName:e.imageName,width:e.width,height:e.height,dataUrl:i.src,...V.createFrameUpdateTimestamps()};this.game.eventStore.addEvent(G)})})})}arrayBufferToBase64Async(e){return new Promise((i,r)=>{const h=new FileReader;h.onload=()=>{i(h.result?.toString().split(",")[1]??"")},h.onerror=r,h.readAsDataURL(new Blob([e]))})}inferImageSubtypeFromUrl(e){if(e?.startsWith("data:image/"))return e.split(";")[0].split("/")[1];let i="jpeg";return e?.includes(".")&&(i=e.split(".").pop()?.toLowerCase()??"jpeg",i===""&&(i="jpeg")),i==="svg"&&(i="svg+xml"),i}getImage(e){return this.images[e]}addImage(e){this.images[e.imageName]=e}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 e=this._scratchCanvas.getContext("2d");if(e===null)throw new C("could not get 2d canvas context from scratch canvas");this.ctx=e,this.scale=window.devicePixelRatio}return this._scratchCanvas}removeScratchCanvas(){this.ctx=void 0,this._scratchCanvas?.remove()}}const di="{{}}",gn="[[]]";class Li{constructor(e,i){this.locale="",this.fallbackLocale="en-US",this.baseLocale="en-US",this.game=e,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 e=await this.game.storeGetItem("locale"),i=await this.game.storeGetItem("fallbackLocale");if(typeof e=="string"&&typeof i=="string"){this.locale=e,this.fallbackLocale=i;return}}if(this.locale?.toLowerCase()==="auto"){const e=this.getEnvironmentLocale();e?this.localeTranslationAvailable(e)?(this.locale=e,this.localeTranslationAvailable(this.fallbackLocale)||(this.fallbackLocale=this.baseLocale)):this.fallbackLocale&&this.localeTranslationAvailable(this.fallbackLocale)?(console.warn(`auto locale requested, but detected locale ${e} 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 ${e} 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(e){return this.translation[e]!==void 0||e===this.baseLocale}switchToLocale(e){this.locale=e,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(e,i){const r=this.attemptTranslation(e,i);if(r.isFallbackOrMissingTranslation){const h=this.handleTranslationPlaceholders(e,r,i);if(h)return i!==void 0&&(h.text=this.insertInterpolations(di,h.text,i)),h}return r}attemptTranslation(e,i){let r=this.tf(e,i),h=!1;return r?.text===void 0&&(r=this.tf(e,{useFallbackLocale:!0,...i}),h=!0),{text:r?.text??e,fontSize:r?.fontSize,fontName:r?.fontName,fontNames:r?.fontNames,isFallbackOrMissingTranslation:h}}handleTranslationPlaceholders(e,i,r){const h=this.getTranslationPlaceholders(e);if(h.length===0)return null;const c={size:new Set,name:new Set,names:new Set},S={};let E=!1;h.forEach(le=>{const ye=this.translatePlaceholder(le,c,r);S[le]=ye.text,E=E||ye.isFallback}),this.warnConflictingFontProperties(e,c);const O=this.insertInterpolations(gn,e,S),G=i.fontSize||(c.size.size>0?[...c.size][0]:void 0),K=i.fontName||(c.name.size>0?[...c.name][0]:void 0),ie=i.fontNames||(c.names.size>0?[...c.names][0].split(","):void 0);return{text:O,fontSize:G,fontName:K,fontNames:ie,isFallbackOrMissingTranslation:E}}translatePlaceholder(e,i,r){let h=this.tf(e,r),c=!1;return h?.text===void 0&&(h=this.tf(e,{useFallbackLocale:!0,...r}),c=!0),h?.fontSize!==void 0&&i.size.add(h.fontSize),h?.fontName!==void 0&&i.name.add(h.fontName),h?.fontNames!==void 0&&i.names.add(h.fontNames.sort().join(",")),{text:h?.text??e,isFallback:c}}getTranslationPlaceholders(e){const[i,r]=[gn.slice(0,2),gn.slice(2)],h=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),S=new RegExp(`${h}(.*?)${c}`,"g"),E=e.match(S);return E?E.map(O=>O.slice(i.length,-r.length).trim()):[]}warnConflictingFontProperties(e,i){i.size.size>1&&console.warn(`i18n: placeholders set multiple different font sizes in string to be localized. Only one will be used. String: ${e}`),i.name.size>1&&console.warn(`i18n: placeholders set multiple different font names within string to be localized. Only one will be used. String: ${e}`),i.names.size>1&&console.warn(`i18n: placeholders set multiple different font names arrays within string to be localized. Only one will be used. String: ${e}`)}t(e,i){const{useFallbackLocale:r,...h}=i??{};if(r!==!0){const S=this.translation[this.locale]?.[e];return this.isStringOrTextWithFontCustomization(S)?this.insertInterpolations(di,this.getKeyText(S),h):void 0}const c=this.translation[this.fallbackLocale]?.[e];if(this.isStringOrTextWithFontCustomization(c))return this.insertInterpolations(di,this.getKeyText(c),h)}tf(e,i){const{useFallbackLocale:r,...h}=i??{};if(r!==!0){const S=this.translation[this.locale]?.[e];if(this.isStringOrTextWithFontCustomization(S)){const E=this.getKeyTextAndFont(S,this.locale);return E.text&&(E.text=this.insertInterpolations(di,E.text,h)),E}return}const c=this.translation[this.fallbackLocale]?.[e];if(this.isStringOrTextWithFontCustomization(c)){const S=this.getKeyTextAndFont(c,this.fallbackLocale);return S.text&&(S.text=this.insertInterpolations(di,S.text,h)),S}}getKeyText(e){return this.isTextWithFontCustomization(e)?e.text:e}getKeyTextAndFont(e,i){let r,h=new Array;this.isString(this.translation[i]?.fontName)?h.push(this.translation[i].fontName):this.isStringArray(this.translation[i]?.fontName)?h.push(...this.translation[i].fontName):h.push("default");let c;switch(this.isTextWithFontCustomization(e)?(c=e.text,r=e.fontSize,this.isString(e.additionalFontName)&&h.push(e.additionalFontName),this.isStringArray(e.additionalFontName)&&h.push(...e.additionalFontName),e.overrideFontName&&(h.length=0,this.isString(e.overrideFontName)&&h.push(e.overrideFontName),this.isStringArray(e.overrideFontName)&&h.push(...e.overrideFontName))):c=e,h=h.filter(S=>S!=="default"),h.length){case 0:return{text:c,fontSize:r};case 1:return{text:c,fontSize:r,fontName:h[0]};default:return{text:c,fontSize:r,fontNames:h}}}insertInterpolations(e,i,r){if(!r)return i;const[h,c]=[e.slice(0,2),e.slice(2)],S=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),E=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),O=new RegExp(`${S}(.*?)${E}`,"g");return i.replace(O,(G,K)=>{if(Object.prototype.hasOwnProperty.call(r,K))return r[K];throw new C(`insertInterpolations(): placeholder "${K}" not found. Text was ${i}, provided interpolation was ${JSON.stringify(r)}`)})}get translation(){return this._translation}set translation(e){this._translation=e}getEnvironmentLocale(){return(navigator.languages&&navigator.languages.length?navigator.languages[0]:navigator.language)??""}mergeAdditionalTranslation(e,i){if(!e&&!i)return;if(!i)return e;if(!e)return i;const r={},h=new Array;for(const c in e)h.push(c),r[c]={...e[c],...i[c]};for(const c in i)h.includes(c)||(r[c]=i[c]);return r}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(e){return e?.text!==void 0}isStringOrTextWithFontCustomization(e){return typeof e=="string"||this.isTextWithFontCustomization(e)}isStringArray(e){return Array.isArray(e)&&e.every(i=>typeof i=="string")}isString(e){return typeof e=="string"}}const vt={Disabled:"Disabled",Record:"Record",Replay:"Replay"};class $r{constructor(){this.events=new Array,this.replayBeginTimestamp=NaN,this.firstTimestamp=NaN,this.replayThoughSequence=Number.MAX_VALUE,this.serializedEventsBeforeReplay="",this.mode=vt.Disabled}serializeEvent(e){const i=e.target;if(e.type===H.NodeNew&&e.nodeOptions?.layout?.constraints!==void 0){const h=e.nodeOptions?.layout?.constraints,c={};for(const E in h){if(E==="horizontalBias"||E==="verticalBias"){c[E]=h[E];continue}const O=h[E];O instanceof ft&&(c[E]=O.uuid)}e.target=i.uuid,e.nodeOptions.layout.constraints=c;const S=JSON.stringify(e);return e.target=i,e.nodeOptions.layout.constraints=h,S}if(i instanceof ft){e.target=i.uuid;const h=JSON.stringify(e);return e.target=i,h}if(i instanceof Element){e.target=i.nodeName;const h=JSON.stringify(e);return e.target=i,h}if(i instanceof pn){e.target="ImageManager";const h=JSON.stringify(e);return e.target=i,h}if(i instanceof Li){e.target="I18n";const h=JSON.stringify(e);return e.target=i,h}e.target="object";const r=JSON.stringify(e);return e.target=i,r}addEvent(e){if(this.mode===vt.Record){e.sequence===void 0&&(e.sequence=m2c2Globals.eventSequence);const i=this.serializeEvent(e);this.events.push(JSON.parse(i))}}addEvents(e){e.forEach(i=>{this.addEvent(i)})}clearEvents(){this.events=[]}record(){this.mode=vt.Record}replay(e){if(e&&(this.events=e),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=vt.Replay,this.replayBeginTimestamp=Ve.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(e){const i=new Array,r=e-this.replayBeginTimestamp+this.firstTimestamp;for(;this.events.length>0&&this.events[0].timestamp<=r;){const h=this.events.shift();if(!h)throw new C("EventStore.dequeueEvents(): undefined event");h.sequence!==void 0&&h.sequence>this.replayThoughSequence||i.push(h)}return i}get eventQueueLength(){return this.events.length}sortEventStore(e){e.sort((i,r)=>{if(i.sequence===void 0||r.sequence===void 0)throw new C("EventStore.sortEventStore(): undefined sequence");return i.sequence!==r.sequence?i.sequence-r.sequence:0})}}var Ht=(m=>(m[m.Center=0]="Center",m[m.Left=1]="Left",m[m.Right=2]="Right",m))(Ht||{});const rt={Deferred:"Deferred",Loading:"Loading",Ready:"Ready"},Je={UNDERLINE:"u",ITALIC:"i",BOLD:"b",STRIKETHROUGH:"s",OVERLINE:"o"};class $i extends ft{constructor(e={}){super(e),this.type=de.Label,this.isDrawable=!0,this.isText=!0,this._anchorPoint={x:.5,y:.5},this._zPosition=0,this._text="",this._fontColor=Q.DEFAULT_FONT_COLOR,this._fontSize=Q.DEFAULT_FONT_SIZE,this._interpolation={},this._horizontalAlignmentMode=Ht.Center,this._localize=!0,this.localizedFontNames=[],this.textAfterLocalization="",this.plainText="",this.styleSegments=[],zt(this,e),e.horizontalAlignmentMode&&(this.horizontalAlignmentMode=e.horizontalAlignmentMode),e.preferredMaxLayoutWidth!==void 0&&(this.preferredMaxLayoutWidth=e.preferredMaxLayoutWidth),e.backgroundColor&&(this.backgroundColor=e.backgroundColor),e.fontNames&&(this.fontNames=e.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 e=this.canvasKit.TextAlign.Center;switch(this.horizontalAlignmentMode){case Ht.Center:e=this.canvasKit.TextAlign.Center;break;case Ht.Left:e=this.canvasKit.TextAlign.Left;break;case Ht.Right:e=this.canvasKit.TextAlign.Right;break;default:throw new C("unknown horizontalAlignmentMode")}this.text||(this.text="");let i=this.canvasKit.Color(this.fontColor[0],this.fontColor[1],this.fontColor[2],this.fontColor[3]);const r=this.game.i18n;if(r&&this.localize!==!1){const K=r.getTextLocalization(this.text,this.interpolation);this.textAfterLocalization=K.text,this.localizedFontSize=K.fontSize,this.localizedFontName=K.fontName,this.localizedFontNames=K.fontNames??[],K.isFallbackOrMissingTranslation&&r.missingLocalizationColor&&(i=this.canvasKit.Color(r.missingLocalizationColor[0],r.missingLocalizationColor[1],r.missingLocalizationColor[2],r.missingLocalizationColor[3]))}else this.textAfterLocalization=this.text;const h=this.parseFormattedText(this.textAfterLocalization);if(this.plainText=h.plainText,this.styleSegments=h.styleSegments,this.fontName&&this.fontNames)throw new C("cannot specify both fontName and fontNames");const c=this.game.fontManager,S=this.getRequiredLabelFonts(c);if(S.forEach(K=>{if(K.status===rt.Deferred){c.prepareDeferredFont(K);return}}),!S.every(K=>K.status===rt.Ready))return;this.paraStyle=new this.canvasKit.ParagraphStyle({textStyle:{},textAlign:e}),this.builder&&this.builder.delete(),this.builder=this.canvasKit.ParagraphBuilder.MakeFromFontProvider(this.paraStyle,c.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));const E={fontFamilies:S.map(K=>K.fontName),fontSize:(this.localizedFontSize??this.fontSize)*m2c2Globals.canvasScale,fontStyle:{weight:this.canvasKit.FontWeight.Normal,width:this.canvasKit.FontWidth.Normal,slant:this.canvasKit.FontSlant.Upright},decoration:0,decorationThickness:1,decorationStyle:this.canvasKit.DecorationStyle.Solid,heightMultiplier:-1,halfLeading:!1,letterSpacing:0,wordSpacing:0};this.builder.pushPaintStyle(E,this.fontPaint,this.backgroundPaint),this.addStyleSegmentsToParagraphBuilder(this.builder,this.styleSegments,E),this.paragraph&&this.paragraph.delete(),this.paragraph=this.builder.build();const O=this.preferredMaxLayoutWidth??m2c2Globals.canvasCssWidth;let G=O;if(O===0||this.layout.width===0){if(this.parent===void 0)throw new C("width is set to match parent, but node has no parent");const K=this.layout.marginStart??0,ie=this.layout.marginEnd??0;G=this.parent.size.width-(K+ie)}this.paragraph.layout(G*m2c2Globals.canvasScale),O===0||this.layout.width===0?this.size.width=G:(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}parseFormattedText(e){let i="";const r=[],h=[],c=new Set([Je.UNDERLINE,Je.BOLD,Je.ITALIC,Je.STRIKETHROUGH,Je.OVERLINE]),S=/<\/?([^>]+)>/g;let E=0,O=0,G=null;const K=ae=>{let Ee=1,We=1;for(let Be=0;Be<ae;Be++)e[Be]===`
2
+ `?(Ee++,We=1):We++;return`line ${Ee}, column ${We}`};for(;(G=S.exec(e))!==null;){const ae=G[0],Ee=G[1],We=ae.charAt(1)==="/",Be=K(G.index);if(!c.has(Ee)){const U=e.substring(E,G.index);i+=U,O+=U.length,i+=ae,O+=ae.length,E=G.index+ae.length;continue}const at=e.substring(E,G.index);if(i+=at,O+=at.length,We){if(h.length===0)throw new C(`Label has closing tag </${Ee}> at ${Be} without matching opening tag. Text is: ${e}`);const U=h.pop();if(U!==Ee)throw new C(`Label has improperly nested tags at ${Be}. Expected </${U}> but found </${Ee}>. Tags must be properly nested. Text is: ${e}`);r.push({position:O,style:Ee,isStart:!1})}else h.push(Ee),r.push({position:O,style:Ee,isStart:!0});E=G.index+ae.length}if(i+=e.substring(E),h.length>0)throw new C(`Label has unclosed format tags: <${h.join(">, <")}>. All tags must be closed. Text is: ${e}`);const ie=new Set,le=[];let ye=0;r.sort((ae,Ee)=>ae.position-Ee.position);for(const ae of r)ae.position>ye&&ie.size>0&&le.push({start:ye,end:ae.position,styles:new Set(ie)}),ae.isStart?ie.add(ae.style):ie.delete(ae.style),ye=ae.position;return{plainText:i,styleSegments:le}}addStyleSegmentsToParagraphBuilder(e,i,r){if(i.length===0)e.addText(this.plainText);else{let h=0;for(const c of i){c.start>h&&this.addTextWithStyle(e,this.plainText.substring(h,c.start),r);const S={};if(c.styles.has(Je.BOLD)&&(S.fontStyle={...S.fontStyle||r.fontStyle,weight:this.canvasKit.FontWeight.Black}),c.styles.has(Je.ITALIC)&&(S.fontStyle={...S.fontStyle||r.fontStyle,slant:this.canvasKit.FontSlant.Italic}),c.styles.has(Je.UNDERLINE)&&(S.decoration=this.canvasKit.UnderlineDecoration,S.decorationThickness=1,S.decorationStyle=this.canvasKit.DecorationStyle.Solid,S.decorationColor=this.fontColor),c.styles.has(Je.STRIKETHROUGH)&&(S.decoration=this.canvasKit.LineThroughDecoration,S.decorationThickness=1,S.decorationStyle=this.canvasKit.DecorationStyle.Solid,S.decorationColor=this.fontColor),c.styles.has(Je.OVERLINE)&&(S.decoration=this.canvasKit.OverlineDecoration,S.decorationThickness=1,S.decorationStyle=this.canvasKit.DecorationStyle.Solid,S.decorationColor=this.fontColor),[Je.UNDERLINE,Je.STRIKETHROUGH,Je.OVERLINE].filter(O=>c.styles.has(O)).length>1)throw new C(`Label does not support multiple text decorations (underline, overline, or strikethrough) on a single text segment. Text is: ${this.textAfterLocalization}`);this.addTextWithStyle(e,this.plainText.substring(c.start,c.end),r,S),h=c.end}h<this.plainText.length&&this.addTextWithStyle(e,this.plainText.substring(h),r)}}addTextWithStyle(e,i,r,h={}){if(!i)return;const c={...r,...h};e.pushPaintStyle(c,this.fontPaint,this.backgroundPaint),e.addText(i),e.pop()}getRequiredLabelFonts(e){let i;if(this.game.i18n&&this.localize!==!1){if(this.localizedFontName)return i=[e.fonts[this.localizedFontName]],i;if(this.localizedFontNames.length>0)return i=this.localizedFontNames.map(r=>e.fonts[r]),i}if(this.fontName===void 0&&this.fontNames===void 0)i=[e.getDefaultFont()];else if(this.fontName!==void 0)i=[e.fonts[this.fontName]];else if(this.fontNames!==void 0&&this.fontNames.length>0)i=this.fontNames.map(r=>e.fonts[r]);else throw new C("cannot determine required fonts");return i}dispose(){Ne.Dispose([this.paragraph,this.builder,this._fontPaint,this._backgroundPaint])}get text(){return this._text}set text(e){q.value(this._text,e)||(this._text=e,this.needsInitialization=!0,this.savePropertyChangeEvent("text",e))}get interpolation(){return this._interpolation}set interpolation(e){q.value(this._interpolation,e)||(this._interpolation=e,Object.freeze(this._interpolation),this.needsInitialization=!0,this.savePropertyChangeEvent("interpolation",e))}get fontName(){return this._fontName}set fontName(e){q.value(this._fontName,e)||(this._fontName=e,this.needsInitialization=!0,this.savePropertyChangeEvent("fontName",e))}get fontNames(){return this._fontNames}set fontNames(e){q.value(this._fontNames,e)||(this._fontNames=e,this.needsInitialization=!0,this.savePropertyChangeEvent("fontNames",e))}get fontColor(){return this._fontColor}set fontColor(e){q.value(this._fontColor,e)||(this._fontColor=e,this.needsInitialization=!0,this.savePropertyChangeEvent("fontColor",e))}get fontSize(){return this._fontSize}set fontSize(e){q.value(this._fontSize,e)||(this._fontSize=e,this.needsInitialization=!0,this.savePropertyChangeEvent("fontSize",e))}get horizontalAlignmentMode(){return this._horizontalAlignmentMode}set horizontalAlignmentMode(e){q.value(this._horizontalAlignmentMode,e)||(this._horizontalAlignmentMode=e,this.needsInitialization=!0,this.savePropertyChangeEvent("horizontalAlignmentMode",e))}get preferredMaxLayoutWidth(){return this._preferredMaxLayoutWidth}set preferredMaxLayoutWidth(e){q.value(this._preferredMaxLayoutWidth,e)||(this._preferredMaxLayoutWidth=e,this.needsInitialization=!0,this.savePropertyChangeEvent("preferredMaxLayoutWidth",e))}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){q.value(this._backgroundColor,e)||(this._backgroundColor=e,this.needsInitialization=!0,this.savePropertyChangeEvent("backgroundColor",e))}get localize(){return this._localize}set localize(e){q.value(this._localize,e)||(this._localize=e,this.needsInitialization=!0,this.savePropertyChangeEvent("localize",e))}get anchorPoint(){const e=this;return{get x(){return e._anchorPoint.x},set x(i){q.value(e._anchorPoint.x,i)||(e._anchorPoint.x=i,e.savePropertyChangeEvent("anchorPoint",e.anchorPoint))},get y(){return e._anchorPoint.y},set y(i){q.value(e._anchorPoint.y,i)||(e._anchorPoint.y=i,e.savePropertyChangeEvent("anchorPoint",e.anchorPoint))}}}set anchorPoint(e){q.value(this._anchorPoint,e)||(this._anchorPoint=e,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(e){q.value(this._zPosition,e)||(this._zPosition=e,this.savePropertyChangeEvent("zPosition",e))}get backgroundPaint(){if(!this._backgroundPaint)throw new C("backgroundPaint cannot be undefined");return this._backgroundPaint}set backgroundPaint(e){this._backgroundPaint=e}get fontPaint(){if(!this._fontPaint)throw new C("fontPaint cannot be undefined");return this._fontPaint}set fontPaint(e){this._fontPaint=e}duplicate(e){const i=new $i({...this.getNodeOptions(),...this.getDrawableOptions(),...this.getTextOptions(),horizontalAlignmentMode:this.horizontalAlignmentMode,preferredMaxLayoutWidth:this.preferredMaxLayoutWidth,backgroundColor:this.backgroundColor,name:e});return this.children.length>0&&(i.children=this.children.map(r=>{const h=r.duplicate();return h.parent=i,h})),i}update(){super.update(),this.absoluteAlphaChange!==0&&this.initialize()}draw(e){if(this.parent&&this.text!==""&&!this.needsInitialization){e.save();const i=m2c2Globals.canvasScale/this.absoluteScale;e.scale(1/i,1/i),V.rotateCanvasForDrawableNode(e,this);const r=(this.absolutePosition.x-this.size.width*this.anchorPoint.x*this.absoluteScale)*i,h=(this.absolutePosition.y-this.size.height*this.anchorPoint.y*this.absoluteScale)*i;if(this.paragraph===void 0)throw new C("no paragraph");e.drawParagraph(this.paragraph,r,h),e.restore()}super.drawChildren(e)}warmup(e){const i=this.game.i18n;if(i&&this.localize!==!1){const h=i.getTextLocalization(this.text,this.interpolation);this.localizedFontName=h.fontName,this.localizedFontNames=h.fontNames??[]}if(!this.getRequiredLabelFonts(this.game.fontManager).some(h=>h.status===rt.Deferred)&&Object.keys(this.layout).length===0){if(this.initialize(),!this.paragraph)throw new C(`warmup Label node ${this.toString()}: paragraph is undefined`);e.drawParagraph(this.paragraph,0,0)}}}class Vt extends ft{constructor(e={}){super(e),this.type=de.Scene,this.isDrawable=!0,this._anchorPoint={x:0,y:0},this._zPosition=0,this._backgroundColor=Q.DEFAULT_SCENE_BACKGROUND_COLOR,this._active=!1,this._transitioning=!1,zt(this,e),e.backgroundColor&&(this.backgroundColor=e.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=Ne.makePaint(this.canvasKit,this.backgroundColor,this.canvasKit.PaintStyle.Fill,!1),this.needsInitialization=!1}dispose(){Ne.Dispose([this.backgroundPaint])}set game(e){this._game=e}get game(){if(this._game===void 0)throw new C(`Scene ${this} has not been added to a game.`);return this._game}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){q.value(this._backgroundColor,e)||(this._backgroundColor=e,this.needsInitialization=!0,this.savePropertyChangeEvent("backgroundColor",e))}get anchorPoint(){const e=this;return{get x(){return e._anchorPoint.x},set x(i){q.value(e._anchorPoint.x,i)||(e._anchorPoint.x=i,e.savePropertyChangeEvent("anchorPoint",e.anchorPoint))},get y(){return e._anchorPoint.y},set y(i){q.value(e._anchorPoint.y,i)||(e._anchorPoint.y=i,e.savePropertyChangeEvent("anchorPoint",e.anchorPoint))}}}set anchorPoint(e){q.value(this._anchorPoint,e)||(this._anchorPoint=e,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(e){q.value(this._zPosition,e)||(this._zPosition=e,this.savePropertyChangeEvent("zPosition",e))}duplicate(e){const i=new Vt({...this.getNodeOptions(),...this.getDrawableOptions(),backgroundColor:this.backgroundColor,name:e});return i.game=this.game,this.children.length>0&&(i.children=this.children.map(r=>{const h=r.duplicate();return h.parent=i,h})),i}onSetup(e,i){this.addEventListener("SceneSetup",e,i)}onAppear(e,i){this.addEventListener("SceneAppear",e,i)}onKeyDown(e,i){this.addEventListener(H.KeyDown,e,i)}onKeyUp(e,i){this.addEventListener(H.KeyUp,e,i)}update(){super.update()}draw(e){e.save();const i=m2c2Globals.canvasScale/this.absoluteScale;if(e.scale(1/i,1/i),V.rotateCanvasForDrawableNode(e,this),!this.backgroundPaint)throw new C(`in Scene ${this}, background paint is undefined.`);this.absoluteAlphaChange!==0&&this.backgroundPaint.setAlphaf(this.absoluteAlpha),e.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),e.restore(),super.drawChildren(e)}warmup(e){this.initialize(),e.save();const i=m2c2Globals.canvasScale/this.absoluteScale;if(e.scale(1/i,1/i),!this.backgroundPaint)throw new C(`in Scene ${this}, background paint is undefined.`);e.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),e.restore(),this.children.forEach(r=>{r.isDrawable&&r.warmup(e)})}}class fi extends ft{constructor(e={}){if(super(e),this.type=de.Shape,this.isDrawable=!0,this.isShape=!0,this._anchorPoint={x:.5,y:.5},this._zPosition=0,this.shapeType=Ke.Undefined,this.ckPath=null,this._cornerRadius=0,this._fillColor=Q.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,zt(this,e),e.path!==void 0){if(this.path=e.path,this.shapeType=Ke.Path,this.shapeIsM2Path()&&e.size!==void 0&&(this.size=e.size),this.shapeIsSvgStringPath()&&e.size!==void 0)throw new C("Size cannot be specified when path is SVG string path");if(this.svgPathRequestedWidth=e.path.width,this.svgPathRequestedHeight=e.path.height,this.svgPathRequestedHeight!==void 0&&this.svgPathRequestedWidth!==void 0)throw new C("Cannot specify both width and height for SVG string path.");if(this.strokeColor||(this.strokeColor=Q.DEFAULT_PATH_STROKE_COLOR),this.lineWidth===void 0&&(this.lineWidth=Q.DEFAULT_PATH_LINE_WIDTH),e.circleOfRadius||e.rect)throw new C("Shape must specify only one of: path, circleOfRadius, or rect")}if(e.circleOfRadius!==void 0){if(this.circleOfRadius=e.circleOfRadius,this.shapeType=Ke.Circle,e.size!==void 0)throw new C("Size cannot be specified for circle shape");if(e.path||e.rect)throw new C("Shape must specify only one of: path, circleOfRadius, or rect");this.size.width=this.circleOfRadius*2,this.size.height=this.circleOfRadius*2}if(e.rect&&(this.rect=e.rect,e.rect.size?(this.size.width=e.rect.size.width,this.size.height=e.rect.size.height):e.rect.width!==void 0&&e.rect.height!==void 0&&(this.size.width=e.rect.width,this.size.height=e.rect.height),e.rect.origin?this.position=e.rect.origin:e.rect.x!==void 0&&e.rect.y!==void 0&&(this.position={x:e.rect.x,y:e.rect.y}),this.shapeType=Ke.Rectangle,e.size!==void 0))throw new C("Size cannot be specified for rectangle shape");e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius),e.fillColor&&(this.fillColor=e.fillColor),e.strokeColor&&(this.strokeColor=e.strokeColor),e.lineWidth!==void 0&&(this.lineWidth=e.lineWidth),e.isAntialiased!==void 0&&(this.isAntialiased=e.isAntialiased),e.strokeColor&&!e.lineWidth&&console.warn(`warning: for node ${this}, strokeColor = ${e.strokeColor} but lineWidth is non-zero. In normal usage, both would be set or both would be undefined.`),e.strokeColor===void 0&&e.lineWidth&&console.warn(`warning: for node ${this}, lineWidth = ${e.lineWidth} but strokeColor is undefined. In normal usage, both would be set or both would be undefined.`),this.saveNodeNewEvent()}get completeNodeOptions(){let e;return this.shapeIsM2Path()&&(e=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:e,isAntialiased:this.isAntialiased}}initialize(){if(this.shapeType===Ke.Path&&this.shapeIsSvgStringPath()){const e=this.path.pathString??this.path.svgPathString;if(!e)throw new C("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(e),!this.ckPath)throw new C("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 C("Size of shape must have non-zero height and width when path is M2Path");this.fillColor&&(this.fillColorPaintAntialiased=Ne.makePaint(this.canvasKit,this.fillColor,this.canvasKit.PaintStyle.Fill,!0),this.fillColorPaintNotAntialiased=Ne.makePaint(this.canvasKit,this.fillColor,this.canvasKit.PaintStyle.Fill,!1)),this.strokeColor&&(this.strokeColorPaintAntialiased=Ne.makePaint(this.canvasKit,this.strokeColor,this.canvasKit.PaintStyle.Stroke,!0),this.strokeColorPaintNotAntialiased=Ne.makePaint(this.canvasKit,this.strokeColor,this.canvasKit.PaintStyle.Stroke,!1)),this.svgFirstPathDraw=!0,this.needsInitialization=!1}get anchorPoint(){const e=this;return{get x(){return e._anchorPoint.x},set x(i){q.value(e._anchorPoint.x,i)||(e._anchorPoint.x=i,e.savePropertyChangeEvent("anchorPoint",e.anchorPoint))},get y(){return e._anchorPoint.y},set y(i){q.value(e._anchorPoint.y,i)||(e._anchorPoint.y=i,e.savePropertyChangeEvent("anchorPoint",e.anchorPoint))}}}set anchorPoint(e){q.value(this._anchorPoint,e)||(this._anchorPoint=e,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(e){q.value(this._zPosition,e)||(this._zPosition=e,this.savePropertyChangeEvent("zPosition",e))}dispose(){Ne.Dispose([this._strokeColorPaintAntialiased,this._strokeColorPaintNotAntialiased,this._fillColorPaintAntialiased,this._fillColorPaintNotAntialiased,this.ckPath,...Array.from(this.colorfulPathPaints.values())])}duplicate(e){const i=new fi({...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:e});return this.children.length>0&&(i.children=this.children.map(r=>{const h=r.duplicate();return h.parent=i,h})),i}update(){super.update()}draw(e){e.save();const i=m2c2Globals.canvasScale/this.absoluteScale;e.scale(1/i,1/i),V.rotateCanvasForDrawableNode(e,this),this.absoluteAlphaChange!==0&&this.applyAlphaToPaints(this.absoluteAlpha,[this._fillColorPaintAntialiased,this._fillColorPaintNotAntialiased,this._strokeColorPaintAntialiased,this._strokeColorPaintNotAntialiased]),this.shapeIsM2Path()&&this.drawPathFromM2Path(e),this.shapeIsSvgStringPath()&&this.drawPathFromSvgString(e),this.shapeType===Ke.Circle&&this.drawCircle(e),this.shapeType===Ke.Rectangle&&this.drawRectangle(e),e.restore(),super.drawChildren(e)}applyAlphaToPaints(e,i){i.forEach(r=>{r&&r.setAlphaf(e)})}drawPathFromM2Path(e){const i=m2c2Globals.canvasScale/this.absoluteScale,r=(this.absolutePosition.x-this.anchorPoint.x*this.size.width*this.absoluteScale)*i,h=(this.absolutePosition.y-this.anchorPoint.y*this.size.height*this.absoluteScale)*i;if(this.pathIsM2ColorfulPath(this.path)){const c=this.path.linePresentations;let S=0;const E=this.path.subpaths;let O;for(let G=0;G<E.length;G++){const ie=E[G].flat();for(let le=0;le<ie.length-1;le++){if(c[S].subpathIndex===G&&c[S].pointIndex===le){const ye=c[S].strokeColor,ae=c[S].lineWidth,Ee=[...ye,ae].toString();O=this.colorfulPathPaints.get(Ee),O===void 0&&(O=Ne.makePaint(this.canvasKit,ye,this.canvasKit.PaintStyle.Stroke,!0),O.setStrokeWidth(ae*m2c2Globals.canvasScale),this.colorfulPathPaints.set(Ee,O)),S<c.length-1&&S++}if(O===void 0)throw new C("paint is undefined");e.drawLine(r+ie[le].x*m2c2Globals.canvasScale,h+ie[le].y*m2c2Globals.canvasScale,r+ie[le+1].x*m2c2Globals.canvasScale,h+ie[le+1].y*m2c2Globals.canvasScale,O)}}return}if(this.strokeColor&&this.strokeColorPaintAntialiased&&this.lineWidth){this.strokeColorPaintAntialiased.setStrokeWidth(this.lineWidth*m2c2Globals.canvasScale);const c=this.path.subpaths;for(const S of c){const E=S.flat();for(let O=0;O<E.length-1;O++)e.drawLine(r+E[O].x*m2c2Globals.canvasScale,h+E[O].y*m2c2Globals.canvasScale,r+E[O+1].x*m2c2Globals.canvasScale,h+E[O+1].y*m2c2Globals.canvasScale,this.strokeColorPaintAntialiased)}}}drawPathFromSvgString(e){if(!this.ckPath)return;const i=this.calculateSvgPathX(),r=this.calculateSvgPathY();if(this.pathNeedsTransform(i,r)){const c=m2c2Globals.canvasScale/this.absoluteScale*this.svgPathScaleForResizing*m2c2Globals.rootScale,S=this.calculateTransformationMatrix(c,i,r);this.ckPath=this.ckPath.transform(S),this.saveSvgPathAbsolutePosition(i,r)}if(this.fillColor){const h=this.getFillPaint();e.drawPath(this.ckPath,h)}if(this.strokeColor&&this.lineWidth){const h=this.getStrokePaint(this.lineWidth);e.drawPath(this.ckPath,h)}}calculateSvgPathY(){const e=m2c2Globals.canvasScale/this.absoluteScale;return(this.absolutePosition.y-this.size.height*this.absoluteScale/2)*e}calculateSvgPathX(){const e=m2c2Globals.canvasScale/this.absoluteScale;return(this.absolutePosition.x-this.size.width*this.absoluteScale/2)*e}saveSvgPathAbsolutePosition(e,i){this.svgPreviousAbsoluteX=e,this.svgPreviousAbsoluteY=i}calculateTransformationMatrix(e,i,r){let h;this.svgFirstPathDraw?(h=e,this.svgFirstPathDraw=!1):h=1;const c=i-this.svgPreviousAbsoluteX,S=r-this.svgPreviousAbsoluteY;return[h,0,c,0,h,S,0,0,1]}pathNeedsTransform(e,i){return this.svgFirstPathDraw===!0||e!==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(e){return e!==void 0&&"linePresentations"in e}drawCircle(e){if(this.circleOfRadius){if(this.fillColor){const i=this.getFillPaint();this.drawCircleWithCanvasKit(e,i)}if(this.strokeColor&&this.lineWidth){const i=this.getStrokePaint(this.lineWidth);this.drawCircleWithCanvasKit(e,i)}}}drawRectangle(e){if(this.fillColor){const i=this.getFillPaint();this.drawRectangleWithCanvasKit(e,i)}if(this.strokeColor&&this.lineWidth){const i=this.getStrokePaint(this.lineWidth);this.drawRectangleWithCanvasKit(e,i)}}drawCircleWithCanvasKit(e,i){if(!this.circleOfRadius)return;const r=m2c2Globals.canvasScale/this.absoluteScale,h=this.absolutePosition.x*r,c=this.absolutePosition.y*r,S=this.circleOfRadius*this.absoluteScale*r;e.drawCircle(h,c,S,i)}drawRectangleWithCanvasKit(e,i){const r=this.calculateCKRoundedRectangle();e.drawRRect(r,i)}calculateCKRoundedRectangle(){const e=m2c2Globals.canvasScale/this.absoluteScale;return this.canvasKit.RRectXY(this.canvasKit.LTRBRect((this.absolutePosition.x-this.anchorPoint.x*this.size.width*this.absoluteScale)*e,(this.absolutePosition.y-this.anchorPoint.y*this.size.height*this.absoluteScale)*e,(this.absolutePosition.x+this.size.width*this.absoluteScale-this.anchorPoint.x*this.size.width*this.absoluteScale)*e,(this.absolutePosition.y+this.size.height*this.absoluteScale-this.anchorPoint.y*this.size.height*this.absoluteScale)*e),this.cornerRadius*e,this.cornerRadius*e)}getFillPaint(){return this.involvedInActionAffectingAppearance()?this.fillColorPaintNotAntialiased:this.isAntialiased?this.fillColorPaintAntialiased:this.fillColorPaintNotAntialiased}getStrokePaint(e){let i;this.involvedInActionAffectingAppearance()?i=this.strokeColorPaintNotAntialiased:i=this.isAntialiased?this.strokeColorPaintAntialiased:this.strokeColorPaintNotAntialiased;const r=m2c2Globals.canvasScale/this.absoluteScale;return i.setStrokeWidth(e*r),i}warmup(e){this.initialize(),e.save();const i=m2c2Globals.canvasScale/this.absoluteScale;e.scale(1/i,1/i),this.shapeType===Ke.Circle&&(this.fillColor&&this.warmupFilledCircle(e),this.strokeColor&&this.lineWidth&&this.warmupStrokedCircle(e)),this.shapeType===Ke.Rectangle&&(this.fillColor&&this.warmupFilledRectangle(e),this.strokeColor&&this.lineWidth&&this.warmupStrokedRectangle(e)),e.restore(),this.children.forEach(r=>{r.isDrawable&&r.warmup(e)})}warmupFilledCircle(e){this.circleOfRadius&&(this.drawCircleWithCanvasKit(e,this.fillColorPaintAntialiased),this.drawCircleWithCanvasKit(e,this.fillColorPaintNotAntialiased))}warmupStrokedCircle(e){if(!this.lineWidth||!this.circleOfRadius)return;const i=m2c2Globals.canvasScale/this.absoluteScale;this.strokeColorPaintAntialiased.setStrokeWidth(this.lineWidth*i),this.drawCircleWithCanvasKit(e,this.strokeColorPaintAntialiased),this.strokeColorPaintNotAntialiased.setStrokeWidth(this.lineWidth*i),this.drawCircleWithCanvasKit(e,this.strokeColorPaintNotAntialiased)}warmupFilledRectangle(e){this.drawRectangleWithCanvasKit(e,this.fillColorPaintAntialiased),this.drawRectangleWithCanvasKit(e,this.fillColorPaintNotAntialiased)}warmupStrokedRectangle(e){if(!this.lineWidth||!this.circleOfRadius)return;const i=m2c2Globals.canvasScale/this.absoluteScale;this.strokeColorPaintAntialiased.setStrokeWidth(this.lineWidth*i),this.drawRectangleWithCanvasKit(e,this.strokeColorPaintAntialiased),this.strokeColorPaintNotAntialiased.setStrokeWidth(this.lineWidth*i),this.drawRectangleWithCanvasKit(e,this.strokeColorPaintNotAntialiased)}get circleOfRadius(){return this._circleOfRadius}set circleOfRadius(e){q.value(e,this._circleOfRadius)||(this._circleOfRadius=e,this.needsInitialization=!0,this.savePropertyChangeEvent("circleOfRadius",e))}get rect(){return this._rect}set rect(e){q.value(e,this._rect)||(this._rect=e,this.needsInitialization=!0,this.savePropertyChangeEvent("rect",e))}get cornerRadius(){return this._cornerRadius}set cornerRadius(e){q.value(e,this._cornerRadius)||(this._cornerRadius=e??0,this.needsInitialization=!0,this.savePropertyChangeEvent("cornerRadius",e??0))}get lineWidth(){return this._lineWidth}set lineWidth(e){q.value(e,this._lineWidth)||(this._lineWidth=e,this.needsInitialization=!0,this.savePropertyChangeEvent("lineWidth",e))}get path(){return this._path}set path(e){q.value(e,this._path)||(this._path=e,this.needsInitialization=!0,this.savePropertyChangeEvent("path",e))}get fillColor(){return this._fillColor}set fillColor(e){q.value(e,this._fillColor)||(this._fillColor=e,this.needsInitialization=!0,this.savePropertyChangeEvent("fillColor",e))}get strokeColor(){return this._strokeColor}set strokeColor(e){q.value(e,this._strokeColor)||(this._strokeColor=e,this.needsInitialization=!0,this.savePropertyChangeEvent("strokeColor",e))}get isAntialiased(){return this._isAntialiased}set isAntialiased(e){q.value(e,this._isAntialiased)||(this._isAntialiased=e,this.needsInitialization=!0,this.savePropertyChangeEvent("isAntialiased",e))}get fillColorPaintAntialiased(){if(!this._fillColorPaintAntialiased)throw new C("fillColorPaintAntiAliased is undefined");return this._fillColorPaintAntialiased}set fillColorPaintAntialiased(e){this._fillColorPaintAntialiased=e}get strokeColorPaintAntialiased(){if(!this._strokeColorPaintAntialiased)throw new C("strokeColorPaintAntiAliased is undefined");return this._strokeColorPaintAntialiased}set strokeColorPaintAntialiased(e){this._strokeColorPaintAntialiased=e}get fillColorPaintNotAntialiased(){if(!this._fillColorPaintNotAntialiased)throw new C("fillColorPaintNotAntiAliased is undefined");return this._fillColorPaintNotAntialiased}set fillColorPaintNotAntialiased(e){this._fillColorPaintNotAntialiased=e}get strokeColorPaintNotAntialiased(){if(!this._strokeColorPaintNotAntialiased)throw new C("strokeColorPaintNotAntiAliased is undefined");return this._strokeColorPaintNotAntialiased}set strokeColorPaintNotAntialiased(e){this._strokeColorPaintNotAntialiased=e}}class Gi extends ft{constructor(e={}){super(e),this.type=de.TextLine,this.isDrawable=!0,this.isText=!0,this._zPosition=0,this._anchorPoint={x:0,y:.5},this._text="",this._fontColor=Q.DEFAULT_FONT_COLOR,this._fontSize=Q.DEFAULT_FONT_SIZE,this._interpolation={},this._localize=!0,this.typeface=null,this.tryMissingTranslationPaint=!1,this.textForDraw="",this.localizedFontNames=[],zt(this,e),this.size.height=this.localizedFontSize??this.fontSize,this.size.width=e.width??NaN,this.saveNodeNewEvent()}get completeNodeOptions(){return{...this.options,...this.getNodeOptions(),...this.getDrawableOptions(),...this.getTextOptions(),width:this.size.width}}initialize(){const e=this.game.i18n;if(this.tryMissingTranslationPaint=!1,e&&this.localize!==!1){const r=e.getTextLocalization(this.text,this.interpolation);this.textForDraw=r.text,this.localizedFontSize=r.fontSize,this.localizedFontName=r.fontName,this.localizedFontNames=r.fontNames??[],r.isFallbackOrMissingTranslation&&(this.tryMissingTranslationPaint=!0)}else this.textForDraw=this.text;const i=this.game.fontManager;if(this.fontForDraw=this.getRequiredTextLineFont(i),this.fontForDraw.status===rt.Deferred){i.prepareDeferredFont(this.fontForDraw);return}this.fontForDraw.status!==rt.Loading&&(this.createFontPaint(e),this.createFont(i),this.needsInitialization=!1)}getRequiredTextLineFont(e){if(this.game.i18n){if(this.localizedFontName!==void 0&&this.localizedFontNames.length!==0||this.localizedFontNames.length>1)throw new C("TextLine supports only one font, but multiple fonts are specified in translation.");if(this.localizedFontName!==void 0)return e.fonts[this.localizedFontName];if(this.localizedFontNames.length==1)return e.fonts[this.localizedFontNames[0]]}return this.fontName===void 0?e.getDefaultFont():e.getFont(this.fontName)}createFontPaint(e){this.paint&&this.paint.delete(),this.paint=new this.canvasKit.Paint,this.tryMissingTranslationPaint&&this.localize!==!1?e?.missingLocalizationColor&&this.paint.setColor(this.canvasKit.Color(e.missingLocalizationColor[0],e.missingLocalizationColor[1],e.missingLocalizationColor[2],e.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(e){if(this.fontForDraw)this.typeface=e.getTypeface(this.fontForDraw.fontName);else{const i=e.getFontNames();i.length>0&&(this.typeface=e.getTypeface(i[0]))}this.font&&this.font.delete(),this.font=new this.canvasKit.Font(this.typeface,(this.localizedFontSize??this.fontSize)*m2c2Globals.canvasScale)}get text(){return this._text}set text(e){q.value(this._text,e)||(this._text=e,this.needsInitialization=!0,this.savePropertyChangeEvent("text",e))}get fontName(){return this._fontName}set fontName(e){q.value(this._fontName,e)||(this._fontName=e,this.needsInitialization=!0,this.savePropertyChangeEvent("fontName",e))}get fontColor(){return this._fontColor}set fontColor(e){q.value(this._fontColor,e)||(this._fontColor=e,this.needsInitialization=!0,this.savePropertyChangeEvent("fontColor",e))}get fontSize(){return this._fontSize}set fontSize(e){q.value(this._fontSize,e)||(this._fontSize=e,this.needsInitialization=!0,this.savePropertyChangeEvent("fontSize",e))}get interpolation(){return this._interpolation}set interpolation(e){q.value(this._interpolation,e)||(this._interpolation=e,Object.freeze(this._interpolation),this.needsInitialization=!0,this.savePropertyChangeEvent("interpolation",e))}get localize(){return this._localize}set localize(e){q.value(this._localize,e)||(this._localize=e,this.needsInitialization=!0,this.savePropertyChangeEvent("localize",e))}get anchorPoint(){const e=this;return{get x(){return e._anchorPoint.x},set x(i){q.value(e._anchorPoint.x,i)||(e._anchorPoint.x=i,e.savePropertyChangeEvent("anchorPoint",e.anchorPoint))},get y(){return e._anchorPoint.y},set y(i){q.value(e._anchorPoint.y,i)||(e._anchorPoint.y=i,e.savePropertyChangeEvent("anchorPoint",e.anchorPoint))}}}set anchorPoint(e){q.value(this._anchorPoint,e)||(this._anchorPoint=e,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(e){q.value(this._zPosition,e)||(this._zPosition=e,this.savePropertyChangeEvent("zPosition",e))}dispose(){Ne.Dispose([this.font,this.typeface,this.paint])}duplicate(e){const i=new Gi({...this.getNodeOptions(),...this.getDrawableOptions(),...this.getTextOptions(),width:this.size.width,name:e});return this.children.length>0&&(i.children=this.children.map(r=>{const h=r.duplicate();return h.parent=i,h})),i}update(){super.update()}draw(e){if(this.parent&&this.text&&!this.needsInitialization){e.save();const i=m2c2Globals.canvasScale/this.absoluteScale;e.scale(1/i,1/i),V.rotateCanvasForDrawableNode(e,this);const r=this.absolutePosition.x*i,h=(this.absolutePosition.y+this.size.height*this.anchorPoint.y*this.absoluteScale)*i;if(this.paint===void 0||this.font===void 0)throw new C(`in TextLine node ${this}, Paint or Font is undefined.`);this.absoluteAlphaChange!==0&&this.paint.setAlphaf(this.absoluteAlpha),e.drawText(this.textForDraw,r,h,this.paint,this.font),e.restore()}super.drawChildren(e)}warmup(e){const i=this.game.i18n;if(i&&this.localize!==!1){const h=i.getTextLocalization(this.text,this.interpolation);this.localizedFontName=h.fontName,this.localizedFontNames=h.fontNames??[]}if(this.getRequiredTextLineFont(this.game.fontManager).status!==rt.Deferred){if(this.initialize(),this.paint===void 0||this.font===void 0)throw new C(`warmup TextLine node ${this.toString()}: Paint or Font is undefined.`);e.drawText(this.text,0,0,this.paint,this.font)}}}class pi extends ft{constructor(e={}){super(e),this.type=de.Sprite,this.isDrawable=!0,this._anchorPoint={x:.5,y:.5},this._zPosition=0,this._imageName="",zt(this,e),e.imageName!==void 0&&(this.imageName=e.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 C(`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(){Ne.Dispose([this.m2Image?.canvaskitImage,this._paint])}get imageName(){return this._imageName}set imageName(e){q.value(this._imageName,e)||(this._imageName=e,this.needsInitialization=!0)}get anchorPoint(){const e=this;return{get x(){return e._anchorPoint.x},set x(i){q.value(e._anchorPoint.x,i)||(e._anchorPoint.x=i,e.savePropertyChangeEvent("anchorPoint",e.anchorPoint))},get y(){return e._anchorPoint.y},set y(i){q.value(e._anchorPoint.y,i)||(e._anchorPoint.y=i,e.savePropertyChangeEvent("anchorPoint",e.anchorPoint))}}}set anchorPoint(e){q.value(this._anchorPoint,e)||(this._anchorPoint=e,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(e){q.value(this._zPosition,e)||(this._zPosition=e,this.savePropertyChangeEvent("zPosition",e))}set paint(e){this._paint=e}get paint(){if(!this._paint)throw new C(`in paint getter: Sprite node ${this.toString()} paint is undefined.`);return this._paint}duplicate(e){const i=new pi({...this.getNodeOptions(),...this.getDrawableOptions(),imageName:this.imageName,name:e});return this.children.length>0&&(i.children=this.children.map(r=>{const h=r.duplicate();return h.parent=i,h})),i}update(){super.update()}draw(e){if(!this.hidden){if(this.m2Image){e.save();const i=m2c2Globals.canvasScale/this.absoluteScale;e.scale(1/i,1/i),V.rotateCanvasForDrawableNode(e,this);const r=(this.absolutePosition.x-this.size.width*this.anchorPoint.x*this.absoluteScale)*i,h=(this.absolutePosition.y-this.size.height*this.anchorPoint.y*this.absoluteScale)*i;if(this.absoluteAlphaChange!==0&&this.paint.setAlphaf(this.absoluteAlpha),this.m2Image.status===nt.Ready&&this.m2Image.canvaskitImage)this.m2Image.isFallback&&this.drawFallbackImageBorder(e),e.drawImage(this.m2Image.canvaskitImage,r,h,this.paint);else if(this.m2Image.status===nt.Deferred&&(console.log(`begin loading lazy image ${this.m2Image.imageName} for Sprite node ${this.toString()}`),this.game.imageManager.prepareDeferredImage(this.m2Image)),this.m2Image.status===nt.Error)throw new C(`error status on image ${this.m2Image.imageName} for Sprite node ${this.toString()}`);e.restore()}super.drawChildren(e)}}warmup(e){if(this.m2Image?.status===nt.Ready){if(this.initialize(),!this.m2Image)throw new C(`in Sprite.warmup(): Sprite node ${this.toString()}: image not loaded.`);if(!this.m2Image.canvaskitImage)throw new C(`in Sprite.warmup(): Sprite node ${this.toString()} image ${this.m2Image.imageName} is undefined.`);e.drawImage(this.m2Image.canvaskitImage,0,0)}this.children.forEach(i=>{i.isDrawable&&i.warmup(e)})}drawFallbackImageBorder(e){const i=this.game.imageManager.missingLocalizationImagePaint;if(!i)return;const r=m2c2Globals.canvasScale/this.absoluteScale,h=this.canvasKit.RRectXY(this.canvasKit.LTRBRect((this.absolutePosition.x-this.anchorPoint.x*this.size.width*this.absoluteScale)*r,(this.absolutePosition.y-this.anchorPoint.y*this.size.height*this.absoluteScale)*r,(this.absolutePosition.x+this.size.width*this.absoluteScale-this.anchorPoint.x*this.size.width*this.absoluteScale)*r,(this.absolutePosition.y+this.size.height*this.absoluteScale-this.anchorPoint.y*this.size.height*this.absoluteScale)*r),0,0);e.drawRRect(h,i)}}class Gr{constructor(){V.registerM2NodeClass($i,fi,pi,Vt,Gi)}createNode(e,i,r){const h=i||e;if(!this.hasClassRegistration(h))throw new C(`Unknown node type: ${h}`);if(!m2c2Globals.m2NodeClassRegistry)throw new C("Node class registry is not initialized.");const c=m2c2Globals.m2NodeClassRegistry[h];return new c(r)}hasClassRegistration(e){return Object.keys(m2c2Globals.m2NodeClassRegistry??{}).includes(e)}}class ps{static rgbaColor(e,i){return!e||!i?!1:e[0]===i[0]&&e[1]===i[1]&&e[2]===i[2]&&e[3]===i[3]}}class Wr{constructor(e,i){this.fonts={},this.game=e,this.baseUrls=i,this.canvasKit=e.canvasKit,this.provider=this.canvasKit.TypefaceFontProvider.Make()}initializeFonts(e){return this.loadFonts(e??[])}async loadFonts(e){if(e.length===0)return;const i=e.map((r,h)=>{let c=r.url;V.urlHasScheme(r.url)||(c=V.getUrlFromManifest(this.game,`${this.baseUrls.assets}/${r.url}`));const S={fontName:r.fontName,typeface:void 0,data:r.sharedFont?.data,default:h===0,url:r.sharedFont?.url??c,status:r.lazy?rt.Deferred:rt.Loading};if(this.fonts[r.fontName]=S,S.status===rt.Loading)return this.prepareFont(S)});await Promise.all(i)}async prepareFont(e){const i=e.data??await this.fetchFontAsArrayBuffer(e);this.registerFont(i,e),console.log(`\u26AA font ${e.fontName}${e.default?" (default)":""} loaded for game ${this.game.id} from ${e.url}`)}async prepareDeferredFont(e){return e.status=rt.Loading,this.prepareFont(e)}async fetchFontAsArrayBuffer(e){const i=await fetch(e.url);if(!i.ok)throw new C(`cannot fetch font ${e.fontName} at url ${e.url}: ${i.statusText}`);return await i.arrayBuffer()}registerFont(e,i){this.provider.registerFont(e,i.fontName);const r=this.canvasKit.Typeface.MakeFreeTypeFaceFromData(e);if(!r)throw new C(`cannot make typeface for font ${i.fontName} at url ${i.url}`);i.typeface=r,i.status=rt.Ready}getFont(e){return this.fonts[e]}getDefaultFont(){const e=Object.values(this.fonts).find(i=>i.default);if(!e)throw new C("no default font found; please make sure at least one font is loaded");return e}dispose(){const e=Object.entries(this.fonts).map(([,i])=>i.typeface);Ne.Dispose([...e,this.provider])}getTypeface(e){const i=this.fonts[e]?.typeface;if(!i)throw new C(`font ${e} not found`);return i}getFontNames(){return Object.keys(this.fonts)}}var mn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function gs(m){return m&&m.__esModule&&Object.prototype.hasOwnProperty.call(m,"default")?m.default:m}function jr(m){if(Object.prototype.hasOwnProperty.call(m,"__esModule"))return m;var e=m.default;if(typeof e=="function"){var i=function r(){var h=!1;try{h=this instanceof r}catch{}return h?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};i.prototype=e.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(m).forEach(function(r){var h=Object.getOwnPropertyDescriptor(m,r);Object.defineProperty(i,r,h.get?h:{enumerable:!0,get:function(){return m[r]}})}),i}var yn={exports:{}},ms={},ys=Object.freeze({__proto__:null,default:ms}),vs=jr(ys);function Hr(m,e){for(var i=0,r=m.length-1;r>=0;r--){var h=m[r];h==="."?m.splice(r,1):h===".."?(m.splice(r,1),i++):i&&(m.splice(r,1),i--)}if(e)for(;i--;i)m.unshift("..");return m}var ws=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,vn=function(m){return ws.exec(m).slice(1)};function zi(){for(var m="",e=!1,i=arguments.length-1;i>=-1&&!e;i--){var r=i>=0?arguments[i]:"/";if(typeof r!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!r)continue;m=r+"/"+m,e=r.charAt(0)==="/"}return m=Hr(bn(m.split("/"),function(h){return!!h}),!e).join("/"),(e?"/":"")+m||"."}function wn(m){var e=Sn(m),i=bs(m,-1)==="/";return m=Hr(bn(m.split("/"),function(r){return!!r}),!e).join("/"),!m&&!e&&(m="."),m&&i&&(m+="/"),(e?"/":"")+m}function Sn(m){return m.charAt(0)==="/"}function Kr(){var m=Array.prototype.slice.call(arguments,0);return wn(bn(m,function(e,i){if(typeof e!="string")throw new TypeError("Arguments to path.join must be strings");return e}).join("/"))}function Vr(m,e){m=zi(m).substr(1),e=zi(e).substr(1);function i(G){for(var K=0;K<G.length&&G[K]==="";K++);for(var ie=G.length-1;ie>=0&&G[ie]==="";ie--);return K>ie?[]:G.slice(K,ie-K+1)}for(var r=i(m.split("/")),h=i(e.split("/")),c=Math.min(r.length,h.length),S=c,E=0;E<c;E++)if(r[E]!==h[E]){S=E;break}for(var O=[],E=S;E<r.length;E++)O.push("..");return O=O.concat(h.slice(S)),O.join("/")}var qr="/",Yr=":";function Xr(m){var e=vn(m),i=e[0],r=e[1];return!i&&!r?".":(r&&(r=r.substr(0,r.length-1)),i+r)}function Jr(m,e){var i=vn(m)[2];return e&&i.substr(-1*e.length)===e&&(i=i.substr(0,i.length-e.length)),i}function Qr(m){return vn(m)[3]}var Ss={extname:Qr,basename:Jr,dirname:Xr,sep:qr,delimiter:Yr,relative:Vr,join:Kr,isAbsolute:Sn,normalize:wn,resolve:zi};function bn(m,e){if(m.filter)return m.filter(e);for(var i=[],r=0;r<m.length;r++)e(m[r],r,m)&&i.push(m[r]);return i}var bs="ab".substr(-1)==="b"?function(m,e,i){return m.substr(e,i)}:function(m,e,i){return e<0&&(e=m.length+e),m.substr(e,i)},Ps=Object.freeze({__proto__:null,basename:Jr,default:Ss,delimiter:Yr,dirname:Xr,extname:Qr,isAbsolute:Sn,join:Kr,normalize:wn,relative:Vr,resolve:zi,sep:qr}),As=jr(Ps),Zr;function Cs(){return Zr||(Zr=1,function(m,e){var i=(()=>{var r=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<"u"&&(r=r||__filename),function(h={}){var c=h,S,E;c.ready=new Promise((t,n)=>{S=t,E=n}),function(t){t.ke=t.ke||[],t.ke.push(function(){t.MakeSWCanvasSurface=function(n){var a=n,l=typeof OffscreenCanvas<"u"&&a instanceof OffscreenCanvas;if(!(typeof HTMLCanvasElement<"u"&&a instanceof HTMLCanvasElement||l||(a=document.getElementById(n),a)))throw"Canvas with id "+n+" was not found";return(n=t.MakeSurface(a.width,a.height))&&(n.ce=a),n},t.MakeCanvasSurface||(t.MakeCanvasSurface=t.MakeSWCanvasSurface),t.MakeSurface=function(n,a){var l={width:n,height:a,colorType:t.ColorType.RGBA_8888,alphaType:t.AlphaType.Unpremul,colorSpace:t.ColorSpace.SRGB},d=n*a*4,g=t._malloc(d);return(l=t.Surface._makeRasterDirect(l,g,4*n))&&(l.ce=null,l.Xf=n,l.Tf=a,l.Vf=d,l.wf=g,l.getCanvas().clear(t.TRANSPARENT)),l},t.MakeRasterDirectSurface=function(n,a,l){return t.Surface._makeRasterDirect(n,a.byteOffset,l)},t.Surface.prototype.flush=function(n){if(t.de(this.be),this._flush(),this.ce){var a=new Uint8ClampedArray(t.HEAPU8.buffer,this.wf,this.Vf);a=new ImageData(a,this.Xf,this.Tf),n?this.ce.getContext("2d").putImageData(a,0,0,n[0],n[1],n[2]-n[0],n[3]-n[1]):this.ce.getContext("2d").putImageData(a,0,0)}},t.Surface.prototype.dispose=function(){this.wf&&t._free(this.wf),this.delete()},t.de=t.de||function(){},t.mf=t.mf||function(){return null}})}(c),function(t){t.ke=t.ke||[],t.ke.push(function(){function n(y,v,T){return y&&y.hasOwnProperty(v)?y[v]:T}function a(y){var v=Nt(tt);return tt[v]=y,v}function l(y){return y.naturalHeight||y.videoHeight||y.displayHeight||y.height}function d(y){return y.naturalWidth||y.videoWidth||y.displayWidth||y.width}function g(y,v,T,D){return y.bindTexture(y.TEXTURE_2D,v),D||T.alphaType!==t.AlphaType.Premul||y.pixelStorei(y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),v}function A(y,v,T){T||v.alphaType!==t.AlphaType.Premul||y.pixelStorei(y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),y.bindTexture(y.TEXTURE_2D,null)}t.GetWebGLContext=function(y,v){if(!y)throw"null canvas passed into makeWebGLContext";var T={alpha:n(v,"alpha",1),depth:n(v,"depth",1),stencil:n(v,"stencil",8),antialias:n(v,"antialias",0),premultipliedAlpha:n(v,"premultipliedAlpha",1),preserveDrawingBuffer:n(v,"preserveDrawingBuffer",0),preferLowPowerToHighPerformance:n(v,"preferLowPowerToHighPerformance",0),failIfMajorPerformanceCaveat:n(v,"failIfMajorPerformanceCaveat",0),enableExtensionsByDefault:n(v,"enableExtensionsByDefault",1),explicitSwapControl:n(v,"explicitSwapControl",0),renderViaOffscreenBackBuffer:n(v,"renderViaOffscreenBackBuffer",0)};if(T.majorVersion=v&&v.majorVersion?v.majorVersion:typeof WebGL2RenderingContext<"u"?2:1,T.explicitSwapControl)throw"explicitSwapControl is not supported";return y=Ia(y,T),y?(er(y),se.xe.getExtension("WEBGL_debug_renderer_info"),y):0},t.deleteContext=function(y){se===yt[y]&&(se=null),typeof JSEvents=="object"&&JSEvents.Mg(yt[y].xe.canvas),yt[y]&&yt[y].xe.canvas&&(yt[y].xe.canvas.Rf=void 0),yt[y]=null},t._setTextureCleanup({deleteTexture:function(y,v){var T=tt[v];T&&yt[y].xe.deleteTexture(T),tt[v]=null}}),t.MakeWebGLContext=function(y){if(!this.de(y))return null;var v=this._MakeGrContext();if(!v)return null;v.be=y;var T=v.delete.bind(v);return v.delete=function(){t.de(this.be),T()}.bind(v),se.Af=v},t.MakeGrContext=t.MakeWebGLContext,t.GrDirectContext.prototype.getResourceCacheLimitBytes=function(){t.de(this.be),this._getResourceCacheLimitBytes()},t.GrDirectContext.prototype.getResourceCacheUsageBytes=function(){t.de(this.be),this._getResourceCacheUsageBytes()},t.GrDirectContext.prototype.releaseResourcesAndAbandonContext=function(){t.de(this.be),this._releaseResourcesAndAbandonContext()},t.GrDirectContext.prototype.setResourceCacheLimitBytes=function(y){t.de(this.be),this._setResourceCacheLimitBytes(y)},t.MakeOnScreenGLSurface=function(y,v,T,D,z,Y){return!this.de(y.be)||(v=z===void 0||Y===void 0?this._MakeOnScreenGLSurface(y,v,T,D):this._MakeOnScreenGLSurface(y,v,T,D,z,Y),!v)?null:(v.be=y.be,v)},t.MakeRenderTarget=function(){var y=arguments[0];if(!this.de(y.be))return null;if(arguments.length===3){var v=this._MakeRenderTargetWH(y,arguments[1],arguments[2]);if(!v)return null}else if(arguments.length===2){if(v=this._MakeRenderTargetII(y,arguments[1]),!v)return null}else return null;return v.be=y.be,v},t.MakeWebGLCanvasSurface=function(y,v,T){v=v||null;var D=y,z=typeof OffscreenCanvas<"u"&&D instanceof OffscreenCanvas;if(!(typeof HTMLCanvasElement<"u"&&D instanceof HTMLCanvasElement||z||(D=document.getElementById(y),D)))throw"Canvas with id "+y+" was not found";if(y=this.GetWebGLContext(D,T),!y||0>y)throw"failed to create webgl context: err "+y;return y=this.MakeWebGLContext(y),v=this.MakeOnScreenGLSurface(y,D.width,D.height,v),v||(v=D.cloneNode(!0),D.parentNode.replaceChild(v,D),v.classList.add("ck-replaced"),t.MakeSWCanvasSurface(v))},t.MakeCanvasSurface=t.MakeWebGLCanvasSurface,t.Surface.prototype.makeImageFromTexture=function(y,v){return t.de(this.be),y=a(y),(v=this._makeImageFromTexture(this.be,y,v))&&(v.cf=y),v},t.Surface.prototype.makeImageFromTextureSource=function(y,v,T){v||(v={height:l(y),width:d(y),colorType:t.ColorType.RGBA_8888,alphaType:T?t.AlphaType.Premul:t.AlphaType.Unpremul}),v.colorSpace||(v.colorSpace=t.ColorSpace.SRGB),t.de(this.be);var D=se.xe;return T=g(D,D.createTexture(),v,T),se.version===2?D.texImage2D(D.TEXTURE_2D,0,D.RGBA,v.width,v.height,0,D.RGBA,D.UNSIGNED_BYTE,y):D.texImage2D(D.TEXTURE_2D,0,D.RGBA,D.RGBA,D.UNSIGNED_BYTE,y),A(D,v),this._resetContext(),this.makeImageFromTexture(T,v)},t.Surface.prototype.updateTextureFromSource=function(y,v,T){if(y.cf){t.de(this.be);var D=y.getImageInfo(),z=se.xe,Y=g(z,tt[y.cf],D,T);se.version===2?z.texImage2D(z.TEXTURE_2D,0,z.RGBA,d(v),l(v),0,z.RGBA,z.UNSIGNED_BYTE,v):z.texImage2D(z.TEXTURE_2D,0,z.RGBA,z.RGBA,z.UNSIGNED_BYTE,v),A(z,D,T),this._resetContext(),tt[y.cf]=null,y.cf=a(Y),D.colorSpace=y.getColorSpace(),v=this._makeImageFromTexture(this.be,y.cf,D),T=y.ae.ie,z=y.ae.pe,y.ae.ie=v.ae.ie,y.ae.pe=v.ae.pe,v.ae.ie=T,v.ae.pe=z,v.delete(),D.colorSpace.delete()}},t.MakeLazyImageFromTextureSource=function(y,v,T){v||(v={height:l(y),width:d(y),colorType:t.ColorType.RGBA_8888,alphaType:T?t.AlphaType.Premul:t.AlphaType.Unpremul}),v.colorSpace||(v.colorSpace=t.ColorSpace.SRGB);var D={makeTexture:function(){var z=se,Y=z.xe,x=g(Y,Y.createTexture(),v,T);return z.version===2?Y.texImage2D(Y.TEXTURE_2D,0,Y.RGBA,v.width,v.height,0,Y.RGBA,Y.UNSIGNED_BYTE,y):Y.texImage2D(Y.TEXTURE_2D,0,Y.RGBA,Y.RGBA,Y.UNSIGNED_BYTE,y),A(Y,v,T),a(x)},freeSrc:function(){}};return y.constructor.name==="VideoFrame"&&(D.freeSrc=function(){y.close()}),t.Image._makeFromGenerator(v,D)},t.de=function(y){return y?er(y):!1},t.mf=function(){return se&&se.Af&&!se.Af.isDeleted()?se.Af:null}})}(c),function(t){function n(o,s,u,p,P){for(var M=0;M<o.length;M++)s[M*u+(M*P+p+u)%u]=o[M];return s}function a(o){for(var s=o*o,u=Array(s);s--;)u[s]=s%(o+1)===0?1:0;return u}function l(o){return o?o.constructor===Float32Array&&o.length===4:!1}function d(o){return(y(255*o[3])<<24|y(255*o[0])<<16|y(255*o[1])<<8|y(255*o[2])<<0)>>>0}function g(o){if(o&&o._ck)return o;if(o instanceof Float32Array){for(var s=Math.floor(o.length/4),u=new Uint32Array(s),p=0;p<s;p++)u[p]=d(o.slice(4*p,4*(p+1)));return u}if(o instanceof Uint32Array)return o;if(o instanceof Array&&o[0]instanceof Float32Array)return o.map(d)}function A(o){if(o===void 0)return 1;var s=parseFloat(o);return o&&o.indexOf("%")!==-1?s/100:s}function y(o){return Math.round(Math.max(0,Math.min(o||0,255)))}function v(o,s){s&&s._ck||t._free(o)}function T(o,s,u){if(!o||!o.length)return ge;if(o&&o._ck)return o.byteOffset;var p=t[s].BYTES_PER_ELEMENT;return u||(u=t._malloc(o.length*p)),t[s].set(o,u/p),u}function D(o){var s={te:ge,count:o.length,colorType:t.ColorType.RGBA_F32};if(o instanceof Float32Array)s.te=T(o,"HEAPF32"),s.count=o.length/4;else if(o instanceof Uint32Array)s.te=T(o,"HEAPU32"),s.colorType=t.ColorType.RGBA_8888;else if(o instanceof Array){if(o&&o.length){for(var u=t._malloc(16*o.length),p=0,P=u/4,M=0;M<o.length;M++)for(var N=0;4>N;N++)t.HEAPF32[P+p]=o[M][N],p++;o=u}else o=ge;s.te=o}else throw"Invalid argument to copyFlexibleColorArray, Not a color array "+typeof o;return s}function z(o){if(!o)return ge;var s=an.toTypedArray();if(o.length){if(o.length===6||o.length===9)return T(o,"HEAPF32",_t),o.length===6&&t.HEAPF32.set(ss,6+_t/4),_t;if(o.length===16)return s[0]=o[0],s[1]=o[1],s[2]=o[3],s[3]=o[4],s[4]=o[5],s[5]=o[7],s[6]=o[12],s[7]=o[13],s[8]=o[15],_t;throw"invalid matrix size"}if(o.m11===void 0)throw"invalid matrix argument";return s[0]=o.m11,s[1]=o.m21,s[2]=o.m41,s[3]=o.m12,s[4]=o.m22,s[5]=o.m42,s[6]=o.m14,s[7]=o.m24,s[8]=o.m44,_t}function Y(o){if(!o)return ge;var s=sn.toTypedArray();if(o.length){if(o.length!==16&&o.length!==6&&o.length!==9)throw"invalid matrix size";return o.length===16?T(o,"HEAPF32",Wt):(s.fill(0),s[0]=o[0],s[1]=o[1],s[3]=o[2],s[4]=o[3],s[5]=o[4],s[7]=o[5],s[10]=1,s[12]=o[6],s[13]=o[7],s[15]=o[8],o.length===6&&(s[12]=0,s[13]=0,s[15]=1),Wt)}if(o.m11===void 0)throw"invalid matrix argument";return s[0]=o.m11,s[1]=o.m21,s[2]=o.m31,s[3]=o.m41,s[4]=o.m12,s[5]=o.m22,s[6]=o.m32,s[7]=o.m42,s[8]=o.m13,s[9]=o.m23,s[10]=o.m33,s[11]=o.m43,s[12]=o.m14,s[13]=o.m24,s[14]=o.m34,s[15]=o.m44,Wt}function x(o,s){return T(o,"HEAPF32",s||Ot)}function J(o,s,u,p){var P=on.toTypedArray();return P[0]=o,P[1]=s,P[2]=u,P[3]=p,Ot}function he(o){for(var s=new Float32Array(4),u=0;4>u;u++)s[u]=t.HEAPF32[o/4+u];return s}function oe(o,s){return T(o,"HEAPF32",s||Re)}function He(o,s){return T(o,"HEAPF32",s||cn)}function ze(){for(var o=0,s=0;s<arguments.length-1;s+=2)o+=arguments[s]*arguments[s+1];return o}function si(o,s,u){for(var p=Array(o.length),P=0;P<u;P++)for(var M=0;M<u;M++){for(var N=0,j=0;j<u;j++)N+=o[u*P+j]*s[u*j+M];p[P*u+M]=N}return p}function oi(o,s){for(var u=si(s[0],s[1],o),p=2;p<s.length;)u=si(u,s[p],o),p++;return u}t.Color=function(o,s,u,p){return p===void 0&&(p=1),t.Color4f(y(o)/255,y(s)/255,y(u)/255,p)},t.ColorAsInt=function(o,s,u,p){return p===void 0&&(p=255),(y(p)<<24|y(o)<<16|y(s)<<8|y(u)<<0&268435455)>>>0},t.Color4f=function(o,s,u,p){return p===void 0&&(p=1),Float32Array.of(o,s,u,p)},Object.defineProperty(t,"TRANSPARENT",{get:function(){return t.Color4f(0,0,0,0)}}),Object.defineProperty(t,"BLACK",{get:function(){return t.Color4f(0,0,0,1)}}),Object.defineProperty(t,"WHITE",{get:function(){return t.Color4f(1,1,1,1)}}),Object.defineProperty(t,"RED",{get:function(){return t.Color4f(1,0,0,1)}}),Object.defineProperty(t,"GREEN",{get:function(){return t.Color4f(0,1,0,1)}}),Object.defineProperty(t,"BLUE",{get:function(){return t.Color4f(0,0,1,1)}}),Object.defineProperty(t,"YELLOW",{get:function(){return t.Color4f(1,1,0,1)}}),Object.defineProperty(t,"CYAN",{get:function(){return t.Color4f(0,1,1,1)}}),Object.defineProperty(t,"MAGENTA",{get:function(){return t.Color4f(1,0,1,1)}}),t.getColorComponents=function(o){return[Math.floor(255*o[0]),Math.floor(255*o[1]),Math.floor(255*o[2]),o[3]]},t.parseColorString=function(o,s){if(o=o.toLowerCase(),o.startsWith("#")){switch(s=255,o.length){case 9:s=parseInt(o.slice(7,9),16);case 7:var u=parseInt(o.slice(1,3),16),p=parseInt(o.slice(3,5),16),P=parseInt(o.slice(5,7),16);break;case 5:s=17*parseInt(o.slice(4,5),16);case 4:u=17*parseInt(o.slice(1,2),16),p=17*parseInt(o.slice(2,3),16),P=17*parseInt(o.slice(3,4),16)}return t.Color(u,p,P,s/255)}return o.startsWith("rgba")?(o=o.slice(5,-1),o=o.split(","),t.Color(+o[0],+o[1],+o[2],A(o[3]))):o.startsWith("rgb")?(o=o.slice(4,-1),o=o.split(","),t.Color(+o[0],+o[1],+o[2],A(o[3]))):o.startsWith("gray(")||o.startsWith("hsl")||!s||(o=s[o],o===void 0)?t.BLACK:o},t.multiplyByAlpha=function(o,s){return o=o.slice(),o[3]=Math.max(0,Math.min(o[3]*s,1)),o},t.Malloc=function(o,s){var u=t._malloc(s*o.BYTES_PER_ELEMENT);return{_ck:!0,length:s,byteOffset:u,Je:null,subarray:function(p,P){return p=this.toTypedArray().subarray(p,P),p._ck=!0,p},toTypedArray:function(){return this.Je&&this.Je.length?this.Je:(this.Je=new o(t.HEAPU8.buffer,u,s),this.Je._ck=!0,this.Je)}}},t.Free=function(o){t._free(o.byteOffset),o.byteOffset=ge,o.toTypedArray=null,o.Je=null};var _t=ge,an,Wt=ge,sn,Ot=ge,on,ut,Re=ge,Pr,Et=ge,Ar,ln=ge,Cr,hn=ge,Oi,li=ge,Tr,cn=ge,_r,Er=ge,ss=Float32Array.of(0,0,1),ge=0;t.onRuntimeInitialized=function(){function o(s,u,p,P,M,N,j){N||(N=4*P.width,P.colorType===t.ColorType.RGBA_F16?N*=2:P.colorType===t.ColorType.RGBA_F32&&(N*=4));var ee=N*P.height,te=M?M.byteOffset:t._malloc(ee);if(j?!s._readPixels(P,te,N,u,p,j):!s._readPixels(P,te,N,u,p))return M||t._free(te),null;if(M)return M.toTypedArray();switch(P.colorType){case t.ColorType.RGBA_8888:case t.ColorType.RGBA_F16:s=new Uint8Array(t.HEAPU8.buffer,te,ee).slice();break;case t.ColorType.RGBA_F32:s=new Float32Array(t.HEAPU8.buffer,te,ee).slice();break;default:return null}return t._free(te),s}on=t.Malloc(Float32Array,4),Ot=on.byteOffset,sn=t.Malloc(Float32Array,16),Wt=sn.byteOffset,an=t.Malloc(Float32Array,9),_t=an.byteOffset,Tr=t.Malloc(Float32Array,12),cn=Tr.byteOffset,_r=t.Malloc(Float32Array,12),Er=_r.byteOffset,ut=t.Malloc(Float32Array,4),Re=ut.byteOffset,Pr=t.Malloc(Float32Array,4),Et=Pr.byteOffset,Ar=t.Malloc(Float32Array,3),ln=Ar.byteOffset,Cr=t.Malloc(Float32Array,3),hn=Cr.byteOffset,Oi=t.Malloc(Int32Array,4),li=Oi.byteOffset,t.ColorSpace.SRGB=t.ColorSpace._MakeSRGB(),t.ColorSpace.DISPLAY_P3=t.ColorSpace._MakeDisplayP3(),t.ColorSpace.ADOBE_RGB=t.ColorSpace._MakeAdobeRGB(),t.GlyphRunFlags={IsWhiteSpace:t._GlyphRunFlags_isWhiteSpace},t.Path.MakeFromCmds=function(s){var u=T(s,"HEAPF32"),p=t.Path._MakeFromCmds(u,s.length);return v(u,s),p},t.Path.MakeFromVerbsPointsWeights=function(s,u,p){var P=T(s,"HEAPU8"),M=T(u,"HEAPF32"),N=T(p,"HEAPF32"),j=t.Path._MakeFromVerbsPointsWeights(P,s.length,M,u.length,N,p&&p.length||0);return v(P,s),v(M,u),v(N,p),j},t.Path.prototype.addArc=function(s,u,p){return s=oe(s),this._addArc(s,u,p),this},t.Path.prototype.addCircle=function(s,u,p,P){return this._addCircle(s,u,p,!!P),this},t.Path.prototype.addOval=function(s,u,p){return p===void 0&&(p=1),s=oe(s),this._addOval(s,!!u,p),this},t.Path.prototype.addPath=function(){var s=Array.prototype.slice.call(arguments),u=s[0],p=!1;if(typeof s[s.length-1]=="boolean"&&(p=s.pop()),s.length===1)this._addPath(u,1,0,0,0,1,0,0,0,1,p);else if(s.length===2)s=s[1],this._addPath(u,s[0],s[1],s[2],s[3],s[4],s[5],s[6]||0,s[7]||0,s[8]||1,p);else if(s.length===7||s.length===10)this._addPath(u,s[1],s[2],s[3],s[4],s[5],s[6],s[7]||0,s[8]||0,s[9]||1,p);else return null;return this},t.Path.prototype.addPoly=function(s,u){var p=T(s,"HEAPF32");return this._addPoly(p,s.length/2,u),v(p,s),this},t.Path.prototype.addRect=function(s,u){return s=oe(s),this._addRect(s,!!u),this},t.Path.prototype.addRRect=function(s,u){return s=He(s),this._addRRect(s,!!u),this},t.Path.prototype.addVerbsPointsWeights=function(s,u,p){var P=T(s,"HEAPU8"),M=T(u,"HEAPF32"),N=T(p,"HEAPF32");this._addVerbsPointsWeights(P,s.length,M,u.length,N,p&&p.length||0),v(P,s),v(M,u),v(N,p)},t.Path.prototype.arc=function(s,u,p,P,M,N){return s=t.LTRBRect(s-p,u-p,s+p,u+p),M=(M-P)/Math.PI*180-360*!!N,N=new t.Path,N.addArc(s,P/Math.PI*180,M),this.addPath(N,!0),N.delete(),this},t.Path.prototype.arcToOval=function(s,u,p,P){return s=oe(s),this._arcToOval(s,u,p,P),this},t.Path.prototype.arcToRotated=function(s,u,p,P,M,N,j){return this._arcToRotated(s,u,p,!!P,!!M,N,j),this},t.Path.prototype.arcToTangent=function(s,u,p,P,M){return this._arcToTangent(s,u,p,P,M),this},t.Path.prototype.close=function(){return this._close(),this},t.Path.prototype.conicTo=function(s,u,p,P,M){return this._conicTo(s,u,p,P,M),this},t.Path.prototype.computeTightBounds=function(s){this._computeTightBounds(Re);var u=ut.toTypedArray();return s?(s.set(u),s):u.slice()},t.Path.prototype.cubicTo=function(s,u,p,P,M,N){return this._cubicTo(s,u,p,P,M,N),this},t.Path.prototype.dash=function(s,u,p){return this._dash(s,u,p)?this:null},t.Path.prototype.getBounds=function(s){this._getBounds(Re);var u=ut.toTypedArray();return s?(s.set(u),s):u.slice()},t.Path.prototype.lineTo=function(s,u){return this._lineTo(s,u),this},t.Path.prototype.moveTo=function(s,u){return this._moveTo(s,u),this},t.Path.prototype.offset=function(s,u){return this._transform(1,0,s,0,1,u,0,0,1),this},t.Path.prototype.quadTo=function(s,u,p,P){return this._quadTo(s,u,p,P),this},t.Path.prototype.rArcTo=function(s,u,p,P,M,N,j){return this._rArcTo(s,u,p,P,M,N,j),this},t.Path.prototype.rConicTo=function(s,u,p,P,M){return this._rConicTo(s,u,p,P,M),this},t.Path.prototype.rCubicTo=function(s,u,p,P,M,N){return this._rCubicTo(s,u,p,P,M,N),this},t.Path.prototype.rLineTo=function(s,u){return this._rLineTo(s,u),this},t.Path.prototype.rMoveTo=function(s,u){return this._rMoveTo(s,u),this},t.Path.prototype.rQuadTo=function(s,u,p,P){return this._rQuadTo(s,u,p,P),this},t.Path.prototype.stroke=function(s){return s=s||{},s.width=s.width||1,s.miter_limit=s.miter_limit||4,s.cap=s.cap||t.StrokeCap.Butt,s.join=s.join||t.StrokeJoin.Miter,s.precision=s.precision||1,this._stroke(s)?this:null},t.Path.prototype.transform=function(){if(arguments.length===1){var s=arguments[0];this._transform(s[0],s[1],s[2],s[3],s[4],s[5],s[6]||0,s[7]||0,s[8]||1)}else if(arguments.length===6||arguments.length===9)s=arguments,this._transform(s[0],s[1],s[2],s[3],s[4],s[5],s[6]||0,s[7]||0,s[8]||1);else throw"transform expected to take 1 or 9 arguments. Got "+arguments.length;return this},t.Path.prototype.trim=function(s,u,p){return this._trim(s,u,!!p)?this:null},t.Image.prototype.encodeToBytes=function(s,u){var p=t.mf();return s=s||t.ImageFormat.PNG,u=u||100,p?this._encodeToBytes(s,u,p):this._encodeToBytes(s,u)},t.Image.prototype.makeShaderCubic=function(s,u,p,P,M){return M=z(M),this._makeShaderCubic(s,u,p,P,M)},t.Image.prototype.makeShaderOptions=function(s,u,p,P,M){return M=z(M),this._makeShaderOptions(s,u,p,P,M)},t.Image.prototype.readPixels=function(s,u,p,P,M){var N=t.mf();return o(this,s,u,p,P,M,N)},t.Canvas.prototype.clear=function(s){t.de(this.be),s=x(s),this._clear(s)},t.Canvas.prototype.clipRRect=function(s,u,p){t.de(this.be),s=He(s),this._clipRRect(s,u,p)},t.Canvas.prototype.clipRect=function(s,u,p){t.de(this.be),s=oe(s),this._clipRect(s,u,p)},t.Canvas.prototype.concat=function(s){t.de(this.be),s=Y(s),this._concat(s)},t.Canvas.prototype.drawArc=function(s,u,p,P,M){t.de(this.be),s=oe(s),this._drawArc(s,u,p,P,M)},t.Canvas.prototype.drawAtlas=function(s,u,p,P,M,N,j){if(s&&P&&u&&p&&u.length===p.length){t.de(this.be),M||(M=t.BlendMode.SrcOver);var ee=T(u,"HEAPF32"),te=T(p,"HEAPF32"),ve=p.length/4,be=T(g(N),"HEAPU32");if(j&&"B"in j&&"C"in j)this._drawAtlasCubic(s,te,ee,be,ve,M,j.B,j.C,P);else{let b=t.FilterMode.Linear,I=t.MipmapMode.None;j&&(b=j.filter,"mipmap"in j&&(I=j.mipmap)),this._drawAtlasOptions(s,te,ee,be,ve,M,b,I,P)}v(ee,u),v(te,p),v(be,N)}},t.Canvas.prototype.drawCircle=function(s,u,p,P){t.de(this.be),this._drawCircle(s,u,p,P)},t.Canvas.prototype.drawColor=function(s,u){t.de(this.be),s=x(s),u!==void 0?this._drawColor(s,u):this._drawColor(s)},t.Canvas.prototype.drawColorInt=function(s,u){t.de(this.be),this._drawColorInt(s,u||t.BlendMode.SrcOver)},t.Canvas.prototype.drawColorComponents=function(s,u,p,P,M){t.de(this.be),s=J(s,u,p,P),M!==void 0?this._drawColor(s,M):this._drawColor(s)},t.Canvas.prototype.drawDRRect=function(s,u,p){t.de(this.be),s=He(s,cn),u=He(u,Er),this._drawDRRect(s,u,p)},t.Canvas.prototype.drawImage=function(s,u,p,P){t.de(this.be),this._drawImage(s,u,p,P||null)},t.Canvas.prototype.drawImageCubic=function(s,u,p,P,M,N){t.de(this.be),this._drawImageCubic(s,u,p,P,M,N||null)},t.Canvas.prototype.drawImageOptions=function(s,u,p,P,M,N){t.de(this.be),this._drawImageOptions(s,u,p,P,M,N||null)},t.Canvas.prototype.drawImageNine=function(s,u,p,P,M){t.de(this.be),u=T(u,"HEAP32",li),p=oe(p),this._drawImageNine(s,u,p,P,M||null)},t.Canvas.prototype.drawImageRect=function(s,u,p,P,M){t.de(this.be),oe(u,Re),oe(p,Et),this._drawImageRect(s,Re,Et,P,!!M)},t.Canvas.prototype.drawImageRectCubic=function(s,u,p,P,M,N){t.de(this.be),oe(u,Re),oe(p,Et),this._drawImageRectCubic(s,Re,Et,P,M,N||null)},t.Canvas.prototype.drawImageRectOptions=function(s,u,p,P,M,N){t.de(this.be),oe(u,Re),oe(p,Et),this._drawImageRectOptions(s,Re,Et,P,M,N||null)},t.Canvas.prototype.drawLine=function(s,u,p,P,M){t.de(this.be),this._drawLine(s,u,p,P,M)},t.Canvas.prototype.drawOval=function(s,u){t.de(this.be),s=oe(s),this._drawOval(s,u)},t.Canvas.prototype.drawPaint=function(s){t.de(this.be),this._drawPaint(s)},t.Canvas.prototype.drawParagraph=function(s,u,p){t.de(this.be),this._drawParagraph(s,u,p)},t.Canvas.prototype.drawPatch=function(s,u,p,P,M){if(24>s.length)throw"Need 12 cubic points";if(u&&4>u.length)throw"Need 4 colors";if(p&&8>p.length)throw"Need 4 shader coordinates";t.de(this.be);const N=T(s,"HEAPF32"),j=u?T(g(u),"HEAPU32"):ge,ee=p?T(p,"HEAPF32"):ge;P||(P=t.BlendMode.Modulate),this._drawPatch(N,j,ee,P,M),v(ee,p),v(j,u),v(N,s)},t.Canvas.prototype.drawPath=function(s,u){t.de(this.be),this._drawPath(s,u)},t.Canvas.prototype.drawPicture=function(s){t.de(this.be),this._drawPicture(s)},t.Canvas.prototype.drawPoints=function(s,u,p){t.de(this.be);var P=T(u,"HEAPF32");this._drawPoints(s,P,u.length/2,p),v(P,u)},t.Canvas.prototype.drawRRect=function(s,u){t.de(this.be),s=He(s),this._drawRRect(s,u)},t.Canvas.prototype.drawRect=function(s,u){t.de(this.be),s=oe(s),this._drawRect(s,u)},t.Canvas.prototype.drawRect4f=function(s,u,p,P,M){t.de(this.be),this._drawRect4f(s,u,p,P,M)},t.Canvas.prototype.drawShadow=function(s,u,p,P,M,N,j){t.de(this.be);var ee=T(M,"HEAPF32"),te=T(N,"HEAPF32");u=T(u,"HEAPF32",ln),p=T(p,"HEAPF32",hn),this._drawShadow(s,u,p,P,ee,te,j),v(ee,M),v(te,N)},t.getShadowLocalBounds=function(s,u,p,P,M,N,j){return s=z(s),p=T(p,"HEAPF32",ln),P=T(P,"HEAPF32",hn),this._getShadowLocalBounds(s,u,p,P,M,N,Re)?(u=ut.toTypedArray(),j?(j.set(u),j):u.slice()):null},t.Canvas.prototype.drawTextBlob=function(s,u,p,P){t.de(this.be),this._drawTextBlob(s,u,p,P)},t.Canvas.prototype.drawVertices=function(s,u,p){t.de(this.be),this._drawVertices(s,u,p)},t.Canvas.prototype.getDeviceClipBounds=function(s){this._getDeviceClipBounds(li);var u=Oi.toTypedArray();return s?s.set(u):s=u.slice(),s},t.Canvas.prototype.quickReject=function(s){return s=oe(s),this._quickReject(s)},t.Canvas.prototype.getLocalToDevice=function(){this._getLocalToDevice(Wt);for(var s=Wt,u=Array(16),p=0;16>p;p++)u[p]=t.HEAPF32[s/4+p];return u},t.Canvas.prototype.getTotalMatrix=function(){this._getTotalMatrix(_t);for(var s=Array(9),u=0;9>u;u++)s[u]=t.HEAPF32[_t/4+u];return s},t.Canvas.prototype.makeSurface=function(s){return s=this._makeSurface(s),s.be=this.be,s},t.Canvas.prototype.readPixels=function(s,u,p,P,M){return t.de(this.be),o(this,s,u,p,P,M)},t.Canvas.prototype.saveLayer=function(s,u,p,P,M){return u=oe(u),this._saveLayer(s||null,u,p||null,P||0,M||t.TileMode.Clamp)},t.Canvas.prototype.writePixels=function(s,u,p,P,M,N,j,ee){if(s.byteLength%(u*p))throw"pixels length must be a multiple of the srcWidth * srcHeight";t.de(this.be);var te=s.byteLength/(u*p);N=N||t.AlphaType.Unpremul,j=j||t.ColorType.RGBA_8888,ee=ee||t.ColorSpace.SRGB;var ve=te*u;return te=T(s,"HEAPU8"),u=this._writePixels({width:u,height:p,colorType:j,alphaType:N,colorSpace:ee},te,ve,P,M),v(te,s),u},t.ColorFilter.MakeBlend=function(s,u,p){return s=x(s),p=p||t.ColorSpace.SRGB,t.ColorFilter._MakeBlend(s,u,p)},t.ColorFilter.MakeMatrix=function(s){if(!s||s.length!==20)throw"invalid color matrix";var u=T(s,"HEAPF32"),p=t.ColorFilter._makeMatrix(u);return v(u,s),p},t.ContourMeasure.prototype.getPosTan=function(s,u){return this._getPosTan(s,Re),s=ut.toTypedArray(),u?(u.set(s),u):s.slice()},t.ImageFilter.prototype.getOutputBounds=function(s,u,p){return s=oe(s,Re),u=z(u),this._getOutputBounds(s,u,li),u=Oi.toTypedArray(),p?(p.set(u),p):u.slice()},t.ImageFilter.MakeDropShadow=function(s,u,p,P,M,N){return M=x(M,Ot),t.ImageFilter._MakeDropShadow(s,u,p,P,M,N)},t.ImageFilter.MakeDropShadowOnly=function(s,u,p,P,M,N){return M=x(M,Ot),t.ImageFilter._MakeDropShadowOnly(s,u,p,P,M,N)},t.ImageFilter.MakeImage=function(s,u,p,P){if(p=oe(p,Re),P=oe(P,Et),"B"in u&&"C"in u)return t.ImageFilter._MakeImageCubic(s,u.B,u.C,p,P);const M=u.filter;let N=t.MipmapMode.None;return"mipmap"in u&&(N=u.mipmap),t.ImageFilter._MakeImageOptions(s,M,N,p,P)},t.ImageFilter.MakeMatrixTransform=function(s,u,p){if(s=z(s),"B"in u&&"C"in u)return t.ImageFilter._MakeMatrixTransformCubic(s,u.B,u.C,p);const P=u.filter;let M=t.MipmapMode.None;return"mipmap"in u&&(M=u.mipmap),t.ImageFilter._MakeMatrixTransformOptions(s,P,M,p)},t.Paint.prototype.getColor=function(){return this._getColor(Ot),he(Ot)},t.Paint.prototype.setColor=function(s,u){u=u||null,s=x(s),this._setColor(s,u)},t.Paint.prototype.setColorComponents=function(s,u,p,P,M){M=M||null,s=J(s,u,p,P),this._setColor(s,M)},t.Path.prototype.getPoint=function(s,u){return this._getPoint(s,Re),s=ut.toTypedArray(),u?(u[0]=s[0],u[1]=s[1],u):s.slice(0,2)},t.Picture.prototype.makeShader=function(s,u,p,P,M){return P=z(P),M=oe(M),this._makeShader(s,u,p,P,M)},t.Picture.prototype.cullRect=function(s){this._cullRect(Re);var u=ut.toTypedArray();return s?(s.set(u),s):u.slice()},t.PictureRecorder.prototype.beginRecording=function(s,u){return s=oe(s),this._beginRecording(s,!!u)},t.Surface.prototype.getCanvas=function(){var s=this._getCanvas();return s.be=this.be,s},t.Surface.prototype.makeImageSnapshot=function(s){return t.de(this.be),s=T(s,"HEAP32",li),this._makeImageSnapshot(s)},t.Surface.prototype.makeSurface=function(s){return t.de(this.be),s=this._makeSurface(s),s.be=this.be,s},t.Surface.prototype.Wf=function(s,u){return this.Ze||(this.Ze=this.getCanvas()),requestAnimationFrame(function(){t.de(this.be),s(this.Ze),this.flush(u)}.bind(this))},t.Surface.prototype.requestAnimationFrame||(t.Surface.prototype.requestAnimationFrame=t.Surface.prototype.Wf),t.Surface.prototype.Sf=function(s,u){this.Ze||(this.Ze=this.getCanvas()),requestAnimationFrame(function(){t.de(this.be),s(this.Ze),this.flush(u),this.dispose()}.bind(this))},t.Surface.prototype.drawOnce||(t.Surface.prototype.drawOnce=t.Surface.prototype.Sf),t.PathEffect.MakeDash=function(s,u){if(u||(u=0),!s.length||s.length%2===1)throw"Intervals array must have even length";var p=T(s,"HEAPF32");return u=t.PathEffect._MakeDash(p,s.length,u),v(p,s),u},t.PathEffect.MakeLine2D=function(s,u){return u=z(u),t.PathEffect._MakeLine2D(s,u)},t.PathEffect.MakePath2D=function(s,u){return s=z(s),t.PathEffect._MakePath2D(s,u)},t.Shader.MakeColor=function(s,u){return u=u||null,s=x(s),t.Shader._MakeColor(s,u)},t.Shader.Blend=t.Shader.MakeBlend,t.Shader.Color=t.Shader.MakeColor,t.Shader.MakeLinearGradient=function(s,u,p,P,M,N,j,ee){ee=ee||null;var te=D(p),ve=T(P,"HEAPF32");j=j||0,N=z(N);var be=ut.toTypedArray();return be.set(s),be.set(u,2),s=t.Shader._MakeLinearGradient(Re,te.te,te.colorType,ve,te.count,M,j,N,ee),v(te.te,p),P&&v(ve,P),s},t.Shader.MakeRadialGradient=function(s,u,p,P,M,N,j,ee){ee=ee||null;var te=D(p),ve=T(P,"HEAPF32");return j=j||0,N=z(N),s=t.Shader._MakeRadialGradient(s[0],s[1],u,te.te,te.colorType,ve,te.count,M,j,N,ee),v(te.te,p),P&&v(ve,P),s},t.Shader.MakeSweepGradient=function(s,u,p,P,M,N,j,ee,te,ve){ve=ve||null;var be=D(p),b=T(P,"HEAPF32");return j=j||0,ee=ee||0,te=te||360,N=z(N),s=t.Shader._MakeSweepGradient(s,u,be.te,be.colorType,b,be.count,M,ee,te,j,N,ve),v(be.te,p),P&&v(b,P),s},t.Shader.MakeTwoPointConicalGradient=function(s,u,p,P,M,N,j,ee,te,ve){ve=ve||null;var be=D(M),b=T(N,"HEAPF32");te=te||0,ee=z(ee);var I=ut.toTypedArray();return I.set(s),I.set(p,2),s=t.Shader._MakeTwoPointConicalGradient(Re,u,P,be.te,be.colorType,b,be.count,j,te,ee,ve),v(be.te,M),N&&v(b,N),s},t.Vertices.prototype.bounds=function(s){this._bounds(Re);var u=ut.toTypedArray();return s?(s.set(u),s):u.slice()},t.ke&&t.ke.forEach(function(s){s()})},t.computeTonalColors=function(o){var s=T(o.ambient,"HEAPF32"),u=T(o.spot,"HEAPF32");this._computeTonalColors(s,u);var p={ambient:he(s),spot:he(u)};return v(s,o.ambient),v(u,o.spot),p},t.LTRBRect=function(o,s,u,p){return Float32Array.of(o,s,u,p)},t.XYWHRect=function(o,s,u,p){return Float32Array.of(o,s,o+u,s+p)},t.LTRBiRect=function(o,s,u,p){return Int32Array.of(o,s,u,p)},t.XYWHiRect=function(o,s,u,p){return Int32Array.of(o,s,o+u,s+p)},t.RRectXY=function(o,s,u){return Float32Array.of(o[0],o[1],o[2],o[3],s,u,s,u,s,u,s,u)},t.MakeAnimatedImageFromEncoded=function(o){o=new Uint8Array(o);var s=t._malloc(o.byteLength);return t.HEAPU8.set(o,s),(o=t._decodeAnimatedImage(s,o.byteLength))?o:null},t.MakeImageFromEncoded=function(o){o=new Uint8Array(o);var s=t._malloc(o.byteLength);return t.HEAPU8.set(o,s),(o=t._decodeImage(s,o.byteLength))?o:null};var hi=null;t.MakeImageFromCanvasImageSource=function(o){var s=o.width,u=o.height;hi||(hi=document.createElement("canvas")),hi.width=s,hi.height=u;var p=hi.getContext("2d",{willReadFrequently:!0});return p.drawImage(o,0,0),o=p.getImageData(0,0,s,u),t.MakeImage({width:s,height:u,alphaType:t.AlphaType.Unpremul,colorType:t.ColorType.RGBA_8888,colorSpace:t.ColorSpace.SRGB},o.data,4*s)},t.MakeImage=function(o,s,u){var p=t._malloc(s.length);return t.HEAPU8.set(s,p),t._MakeImage(o,p,s.length,u)},t.MakeVertices=function(o,s,u,p,P,M){var N=P&&P.length||0,j=0;return u&&u.length&&(j|=1),p&&p.length&&(j|=2),M===void 0||M||(j|=4),o=new t._VerticesBuilder(o,s.length/2,N,j),T(s,"HEAPF32",o.positions()),o.texCoords()&&T(u,"HEAPF32",o.texCoords()),o.colors()&&T(g(p),"HEAPU32",o.colors()),o.indices()&&T(P,"HEAPU16",o.indices()),o.detach()},t.Matrix={},t.Matrix.identity=function(){return a(3)},t.Matrix.invert=function(o){var s=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 s?[(o[4]*o[8]-o[5]*o[7])/s,(o[2]*o[7]-o[1]*o[8])/s,(o[1]*o[5]-o[2]*o[4])/s,(o[5]*o[6]-o[3]*o[8])/s,(o[0]*o[8]-o[2]*o[6])/s,(o[2]*o[3]-o[0]*o[5])/s,(o[3]*o[7]-o[4]*o[6])/s,(o[1]*o[6]-o[0]*o[7])/s,(o[0]*o[4]-o[1]*o[3])/s]:null},t.Matrix.mapPoints=function(o,s){for(var u=0;u<s.length;u+=2){var p=s[u],P=s[u+1],M=o[6]*p+o[7]*P+o[8],N=o[3]*p+o[4]*P+o[5];s[u]=(o[0]*p+o[1]*P+o[2])/M,s[u+1]=N/M}return s},t.Matrix.multiply=function(){return oi(3,arguments)},t.Matrix.rotated=function(o,s,u){s=s||0,u=u||0;var p=Math.sin(o);return o=Math.cos(o),[o,-p,ze(p,u,1-o,s),p,o,ze(-p,s,1-o,u),0,0,1]},t.Matrix.scaled=function(o,s,u,p){u=u||0,p=p||0;var P=n([o,s],a(3),3,0,1);return n([u-o*u,p-s*p],P,3,2,0)},t.Matrix.skewed=function(o,s,u,p){u=u||0,p=p||0;var P=n([o,s],a(3),3,1,-1);return n([-o*u,-s*p],P,3,2,0)},t.Matrix.translated=function(o,s){return n(arguments,a(3),3,2,0)},t.Vector={},t.Vector.dot=function(o,s){return o.map(function(u,p){return u*s[p]}).reduce(function(u,p){return u+p})},t.Vector.lengthSquared=function(o){return t.Vector.dot(o,o)},t.Vector.length=function(o){return Math.sqrt(t.Vector.lengthSquared(o))},t.Vector.mulScalar=function(o,s){return o.map(function(u){return u*s})},t.Vector.add=function(o,s){return o.map(function(u,p){return u+s[p]})},t.Vector.sub=function(o,s){return o.map(function(u,p){return u-s[p]})},t.Vector.dist=function(o,s){return t.Vector.length(t.Vector.sub(o,s))},t.Vector.normalize=function(o){return t.Vector.mulScalar(o,1/t.Vector.length(o))},t.Vector.cross=function(o,s){return[o[1]*s[2]-o[2]*s[1],o[2]*s[0]-o[0]*s[2],o[0]*s[1]-o[1]*s[0]]},t.M44={},t.M44.identity=function(){return a(4)},t.M44.translated=function(o){return n(o,a(4),4,3,0)},t.M44.scaled=function(o){return n(o,a(4),4,0,1)},t.M44.rotated=function(o,s){return t.M44.rotatedUnitSinCos(t.Vector.normalize(o),Math.sin(s),Math.cos(s))},t.M44.rotatedUnitSinCos=function(o,s,u){var p=o[0],P=o[1];o=o[2];var M=1-u;return[M*p*p+u,M*p*P-s*o,M*p*o+s*P,0,M*p*P+s*o,M*P*P+u,M*P*o-s*p,0,M*p*o-s*P,M*P*o+s*p,M*o*o+u,0,0,0,0,1]},t.M44.lookat=function(o,s,u){s=t.Vector.normalize(t.Vector.sub(s,o)),u=t.Vector.normalize(u),u=t.Vector.normalize(t.Vector.cross(s,u));var p=t.M44.identity();return n(u,p,4,0,0),n(t.Vector.cross(u,s),p,4,1,0),n(t.Vector.mulScalar(s,-1),p,4,2,0),n(o,p,4,3,0),o=t.M44.invert(p),o===null?t.M44.identity():o},t.M44.perspective=function(o,s,u){var p=1/(s-o);return u/=2,u=Math.cos(u)/Math.sin(u),[u,0,0,0,0,u,0,0,0,0,(s+o)*p,2*s*o*p,0,0,-1,1]},t.M44.rc=function(o,s,u){return o[4*s+u]},t.M44.multiply=function(){return oi(4,arguments)},t.M44.invert=function(o){var s=o[0],u=o[4],p=o[8],P=o[12],M=o[1],N=o[5],j=o[9],ee=o[13],te=o[2],ve=o[6],be=o[10],b=o[14],I=o[3],ce=o[7],Ce=o[11];o=o[15];var ke=s*N-u*M,Xe=s*j-p*M,it=s*ee-P*M,dt=u*j-p*N,Te=u*ee-P*N,$=p*ee-P*j,f=te*ce-ve*I,w=te*Ce-be*I,F=te*o-b*I,k=ve*Ce-be*ce,L=ve*o-b*ce,B=be*o-b*Ce,Z=ke*B-Xe*L+it*k+dt*F-Te*w+$*f,pe=1/Z;return Z===0||pe===1/0?null:(ke*=pe,Xe*=pe,it*=pe,dt*=pe,Te*=pe,$*=pe,f*=pe,w*=pe,F*=pe,k*=pe,L*=pe,B*=pe,s=[N*B-j*L+ee*k,j*F-M*B-ee*w,M*L-N*F+ee*f,N*w-M*k-j*f,p*L-u*B-P*k,s*B-p*F+P*w,u*F-s*L-P*f,s*k-u*w+p*f,ce*$-Ce*Te+o*dt,Ce*it-I*$-o*Xe,I*Te-ce*it+o*ke,ce*Xe-I*dt-Ce*ke,be*Te-ve*$-b*dt,te*$-be*it+b*Xe,ve*it-te*Te-b*ke,te*dt-ve*Xe+be*ke],s.every(function($e){return!isNaN($e)&&$e!==1/0&&$e!==-1/0})?s:null)},t.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]]},t.M44.mustInvert=function(o){if(o=t.M44.invert(o),o===null)throw"Matrix not invertible";return o},t.M44.setupCamera=function(o,s,u){var p=t.M44.lookat(u.eye,u.coa,u.up);return u=t.M44.perspective(u.near,u.far,u.angle),s=[(o[2]-o[0])/2,(o[3]-o[1])/2,s],o=t.M44.multiply(t.M44.translated([(o[0]+o[2])/2,(o[1]+o[3])/2,0]),t.M44.scaled(s)),t.M44.multiply(o,u,p,t.M44.mustInvert(o))},t.ColorMatrix={},t.ColorMatrix.identity=function(){var o=new Float32Array(20);return o[0]=1,o[6]=1,o[12]=1,o[18]=1,o},t.ColorMatrix.scaled=function(o,s,u,p){var P=new Float32Array(20);return P[0]=o,P[6]=s,P[12]=u,P[18]=p,P};var os=[[6,7,11,12],[0,10,2,12],[0,1,5,6]];t.ColorMatrix.rotated=function(o,s,u){var p=t.ColorMatrix.identity();return o=os[o],p[o[0]]=u,p[o[1]]=s,p[o[2]]=-s,p[o[3]]=u,p},t.ColorMatrix.postTranslate=function(o,s,u,p,P){return o[4]+=s,o[9]+=u,o[14]+=p,o[19]+=P,o},t.ColorMatrix.concat=function(o,s){for(var u=new Float32Array(20),p=0,P=0;20>P;P+=5){for(var M=0;4>M;M++)u[p++]=o[P]*s[M]+o[P+1]*s[M+5]+o[P+2]*s[M+10]+o[P+3]*s[M+15];u[p++]=o[P]*s[4]+o[P+1]*s[9]+o[P+2]*s[14]+o[P+3]*s[19]+o[P+4]}return u},function(o){o.ke=o.ke||[],o.ke.push(function(){function s(b){return b&&(b.dir=b.dir===0?o.TextDirection.RTL:o.TextDirection.LTR),b}function u(b){if(!b||!b.length)return[];for(var I=[],ce=0;ce<b.length;ce+=5){var Ce=o.LTRBRect(b[ce],b[ce+1],b[ce+2],b[ce+3]),ke=o.TextDirection.LTR;b[ce+4]===0&&(ke=o.TextDirection.RTL),I.push({rect:Ce,dir:ke})}return o._free(b.byteOffset),I}function p(b){return b=b||{},b.weight===void 0&&(b.weight=o.FontWeight.Normal),b.width=b.width||o.FontWidth.Normal,b.slant=b.slant||o.FontSlant.Upright,b}function P(b){if(!b||!b.length)return ge;for(var I=[],ce=0;ce<b.length;ce++){var Ce=M(b[ce]);I.push(Ce)}return T(I,"HEAPU32")}function M(b){if(ee[b])return ee[b];var I=lt(b)+1,ce=o._malloc(I);return ot(b,fe,ce,I),ee[b]=ce}function N(b){if(b._colorPtr=x(b.color),b._foregroundColorPtr=ge,b._backgroundColorPtr=ge,b._decorationColorPtr=ge,b.foregroundColor&&(b._foregroundColorPtr=x(b.foregroundColor,te)),b.backgroundColor&&(b._backgroundColorPtr=x(b.backgroundColor,ve)),b.decorationColor&&(b._decorationColorPtr=x(b.decorationColor,be)),Array.isArray(b.fontFamilies)&&b.fontFamilies.length?(b._fontFamiliesPtr=P(b.fontFamilies),b._fontFamiliesLen=b.fontFamilies.length):(b._fontFamiliesPtr=ge,b._fontFamiliesLen=0),b.locale){var I=b.locale;b._localePtr=M(I),b._localeLen=lt(I)}else b._localePtr=ge,b._localeLen=0;if(Array.isArray(b.shadows)&&b.shadows.length){I=b.shadows;var ce=I.map(function(Te){return Te.color||o.BLACK}),Ce=I.map(function(Te){return Te.blurRadius||0});b._shadowLen=I.length;for(var ke=o._malloc(8*I.length),Xe=ke/4,it=0;it<I.length;it++){var dt=I[it].offset||[0,0];o.HEAPF32[Xe]=dt[0],o.HEAPF32[Xe+1]=dt[1],Xe+=2}b._shadowColorsPtr=D(ce).te,b._shadowOffsetsPtr=ke,b._shadowBlurRadiiPtr=T(Ce,"HEAPF32")}else b._shadowLen=0,b._shadowColorsPtr=ge,b._shadowOffsetsPtr=ge,b._shadowBlurRadiiPtr=ge;Array.isArray(b.fontFeatures)&&b.fontFeatures.length?(I=b.fontFeatures,ce=I.map(function(Te){return Te.name}),Ce=I.map(function(Te){return Te.value}),b._fontFeatureLen=I.length,b._fontFeatureNamesPtr=P(ce),b._fontFeatureValuesPtr=T(Ce,"HEAPU32")):(b._fontFeatureLen=0,b._fontFeatureNamesPtr=ge,b._fontFeatureValuesPtr=ge),Array.isArray(b.fontVariations)&&b.fontVariations.length?(I=b.fontVariations,ce=I.map(function(Te){return Te.axis}),Ce=I.map(function(Te){return Te.value}),b._fontVariationLen=I.length,b._fontVariationAxesPtr=P(ce),b._fontVariationValuesPtr=T(Ce,"HEAPF32")):(b._fontVariationLen=0,b._fontVariationAxesPtr=ge,b._fontVariationValuesPtr=ge)}function j(b){o._free(b._fontFamiliesPtr),o._free(b._shadowColorsPtr),o._free(b._shadowOffsetsPtr),o._free(b._shadowBlurRadiiPtr),o._free(b._fontFeatureNamesPtr),o._free(b._fontFeatureValuesPtr),o._free(b._fontVariationAxesPtr),o._free(b._fontVariationValuesPtr)}o.Paragraph.prototype.getRectsForRange=function(b,I,ce,Ce){return b=this._getRectsForRange(b,I,ce,Ce),u(b)},o.Paragraph.prototype.getRectsForPlaceholders=function(){var b=this._getRectsForPlaceholders();return u(b)},o.Paragraph.prototype.getGlyphInfoAt=function(b){return s(this._getGlyphInfoAt(b))},o.Paragraph.prototype.getClosestGlyphInfoAtCoordinate=function(b,I){return s(this._getClosestGlyphInfoAtCoordinate(b,I))},o.TypefaceFontProvider.prototype.registerFont=function(b,I){if(b=o.Typeface.MakeTypefaceFromData(b),!b)return null;I=M(I),this._registerFont(b,I),b.delete()},o.ParagraphStyle=function(b){if(b.disableHinting=b.disableHinting||!1,b.ellipsis){var I=b.ellipsis;b._ellipsisPtr=M(I),b._ellipsisLen=lt(I)}else b._ellipsisPtr=ge,b._ellipsisLen=0;return b.heightMultiplier==null&&(b.heightMultiplier=-1),b.maxLines=b.maxLines||0,b.replaceTabCharacters=b.replaceTabCharacters||!1,I=(I=b.strutStyle)||{},I.strutEnabled=I.strutEnabled||!1,I.strutEnabled&&Array.isArray(I.fontFamilies)&&I.fontFamilies.length?(I._fontFamiliesPtr=P(I.fontFamilies),I._fontFamiliesLen=I.fontFamilies.length):(I._fontFamiliesPtr=ge,I._fontFamiliesLen=0),I.fontStyle=p(I.fontStyle),I.fontSize==null&&(I.fontSize=-1),I.heightMultiplier==null&&(I.heightMultiplier=-1),I.halfLeading=I.halfLeading||!1,I.leading=I.leading||0,I.forceStrutHeight=I.forceStrutHeight||!1,b.strutStyle=I,b.textAlign=b.textAlign||o.TextAlign.Start,b.textDirection=b.textDirection||o.TextDirection.LTR,b.textHeightBehavior=b.textHeightBehavior||o.TextHeightBehavior.All,b.textStyle=o.TextStyle(b.textStyle),b.applyRoundingHack=b.applyRoundingHack!==!1,b},o.TextStyle=function(b){return b.color||(b.color=o.BLACK),b.decoration=b.decoration||0,b.decorationThickness=b.decorationThickness||0,b.decorationStyle=b.decorationStyle||o.DecorationStyle.Solid,b.textBaseline=b.textBaseline||o.TextBaseline.Alphabetic,b.fontSize==null&&(b.fontSize=-1),b.letterSpacing=b.letterSpacing||0,b.wordSpacing=b.wordSpacing||0,b.heightMultiplier==null&&(b.heightMultiplier=-1),b.halfLeading=b.halfLeading||!1,b.fontStyle=p(b.fontStyle),b};var ee={},te=o._malloc(16),ve=o._malloc(16),be=o._malloc(16);o.ParagraphBuilder.Make=function(b,I){return N(b.textStyle),I=o.ParagraphBuilder._Make(b,I),j(b.textStyle),I},o.ParagraphBuilder.MakeFromFontProvider=function(b,I){return N(b.textStyle),I=o.ParagraphBuilder._MakeFromFontProvider(b,I),j(b.textStyle),I},o.ParagraphBuilder.MakeFromFontCollection=function(b,I){return N(b.textStyle),I=o.ParagraphBuilder._MakeFromFontCollection(b,I),j(b.textStyle),I},o.ParagraphBuilder.ShapeText=function(b,I,ce){let Ce=0;for(const ke of I)Ce+=ke.length;if(Ce!==b.length)throw"Accumulated block lengths must equal text.length";return o.ParagraphBuilder._ShapeText(b,I,ce)},o.ParagraphBuilder.prototype.pushStyle=function(b){N(b),this._pushStyle(b),j(b)},o.ParagraphBuilder.prototype.pushPaintStyle=function(b,I,ce){N(b),this._pushPaintStyle(b,I,ce),j(b)},o.ParagraphBuilder.prototype.addPlaceholder=function(b,I,ce,Ce,ke){ce=ce||o.PlaceholderAlignment.Baseline,Ce=Ce||o.TextBaseline.Alphabetic,this._addPlaceholder(b||0,I||0,ce,Ce,ke||0)},o.ParagraphBuilder.prototype.setWordsUtf8=function(b){var I=T(b,"HEAPU32");this._setWordsUtf8(I,b&&b.length||0),v(I,b)},o.ParagraphBuilder.prototype.setWordsUtf16=function(b){var I=T(b,"HEAPU32");this._setWordsUtf16(I,b&&b.length||0),v(I,b)},o.ParagraphBuilder.prototype.setGraphemeBreaksUtf8=function(b){var I=T(b,"HEAPU32");this._setGraphemeBreaksUtf8(I,b&&b.length||0),v(I,b)},o.ParagraphBuilder.prototype.setGraphemeBreaksUtf16=function(b){var I=T(b,"HEAPU32");this._setGraphemeBreaksUtf16(I,b&&b.length||0),v(I,b)},o.ParagraphBuilder.prototype.setLineBreaksUtf8=function(b){var I=T(b,"HEAPU32");this._setLineBreaksUtf8(I,b&&b.length||0),v(I,b)},o.ParagraphBuilder.prototype.setLineBreaksUtf16=function(b){var I=T(b,"HEAPU32");this._setLineBreaksUtf16(I,b&&b.length||0),v(I,b)}})}(c),t.ke=t.ke||[],t.ke.push(function(){t.Path.prototype.op=function(o,s){return this._op(o,s)?this:null},t.Path.prototype.simplify=function(){return this._simplify()?this:null}}),t.ke=t.ke||[],t.ke.push(function(){t.Canvas.prototype.drawText=function(o,s,u,p,P){var M=lt(o),N=t._malloc(M+1);ot(o,fe,N,M+1),this._drawSimpleText(N,M,s,u,P,p),t._free(N)},t.Canvas.prototype.drawGlyphs=function(o,s,u,p,P,M){if(!(2*o.length<=s.length))throw"Not enough positions for the array of gyphs";t.de(this.be);const N=T(o,"HEAPU16"),j=T(s,"HEAPF32");this._drawGlyphs(o.length,N,j,u,p,P,M),v(j,s),v(N,o)},t.Font.prototype.getGlyphBounds=function(o,s,u){var p=T(o,"HEAPU16"),P=t._malloc(16*o.length);return this._getGlyphWidthBounds(p,o.length,ge,P,s||null),s=new Float32Array(t.HEAPU8.buffer,P,4*o.length),v(p,o),u?(u.set(s),t._free(P),u):(o=Float32Array.from(s),t._free(P),o)},t.Font.prototype.getGlyphIDs=function(o,s,u){s||(s=o.length);var p=lt(o)+1,P=t._malloc(p);return ot(o,fe,P,p),o=t._malloc(2*s),s=this._getGlyphIDs(P,p-1,s,o),t._free(P),0>s?(t._free(o),null):(P=new Uint16Array(t.HEAPU8.buffer,o,s),u?(u.set(P),t._free(o),u):(u=Uint16Array.from(P),t._free(o),u))},t.Font.prototype.getGlyphIntercepts=function(o,s,u,p){var P=T(o,"HEAPU16"),M=T(s,"HEAPF32");return this._getGlyphIntercepts(P,o.length,!(o&&o._ck),M,s.length,!(s&&s._ck),u,p)},t.Font.prototype.getGlyphWidths=function(o,s,u){var p=T(o,"HEAPU16"),P=t._malloc(4*o.length);return this._getGlyphWidthBounds(p,o.length,P,ge,s||null),s=new Float32Array(t.HEAPU8.buffer,P,o.length),v(p,o),u?(u.set(s),t._free(P),u):(o=Float32Array.from(s),t._free(P),o)},t.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 s=[],u=[],p=0;p<o.length;p++){var P=new Uint8Array(o[p]),M=T(P,"HEAPU8");s.push(M),u.push(P.byteLength)}return s=T(s,"HEAPU32"),u=T(u,"HEAPU32"),o=t.FontMgr._fromData(s,u,o.length),t._free(s),t._free(u),o},t.Typeface.MakeTypefaceFromData=function(o){o=new Uint8Array(o);var s=T(o,"HEAPU8");return(o=t.Typeface._MakeTypefaceFromData(s,o.byteLength))?o:null},t.Typeface.MakeFreeTypeFaceFromData=t.Typeface.MakeTypefaceFromData,t.Typeface.prototype.getGlyphIDs=function(o,s,u){s||(s=o.length);var p=lt(o)+1,P=t._malloc(p);return ot(o,fe,P,p),o=t._malloc(2*s),s=this._getGlyphIDs(P,p-1,s,o),t._free(P),0>s?(t._free(o),null):(P=new Uint16Array(t.HEAPU8.buffer,o,s),u?(u.set(P),t._free(o),u):(u=Uint16Array.from(P),t._free(o),u))},t.TextBlob.MakeOnPath=function(o,s,u,p){if(o&&o.length&&s&&s.countPoints()){if(s.countPoints()===1)return this.MakeFromText(o,u);p||(p=0);var P=u.getGlyphIDs(o);P=u.getGlyphWidths(P);var M=[];s=new t.ContourMeasureIter(s,!1,1);for(var N=s.next(),j=new Float32Array(4),ee=0;ee<o.length&&N;ee++){var te=P[ee];if(p+=te/2,p>N.length()){if(N.delete(),N=s.next(),!N){o=o.substring(0,ee);break}p=te/2}N.getPosTan(p,j);var ve=j[2],be=j[3];M.push(ve,be,j[0]-te/2*ve,j[1]-te/2*be),p+=te/2}return o=this.MakeFromRSXform(o,M,u),N&&N.delete(),s.delete(),o}},t.TextBlob.MakeFromRSXform=function(o,s,u){var p=lt(o)+1,P=t._malloc(p);return ot(o,fe,P,p),o=T(s,"HEAPF32"),u=t.TextBlob._MakeFromRSXform(P,p-1,o,u),t._free(P),u||null},t.TextBlob.MakeFromRSXformGlyphs=function(o,s,u){var p=T(o,"HEAPU16");return s=T(s,"HEAPF32"),u=t.TextBlob._MakeFromRSXformGlyphs(p,2*o.length,s,u),v(p,o),u||null},t.TextBlob.MakeFromGlyphs=function(o,s){var u=T(o,"HEAPU16");return s=t.TextBlob._MakeFromGlyphs(u,2*o.length,s),v(u,o),s||null},t.TextBlob.MakeFromText=function(o,s){var u=lt(o)+1,p=t._malloc(u);return ot(o,fe,p,u),o=t.TextBlob._MakeFromText(p,u-1,s),t._free(p),o||null},t.MallocGlyphIDs=function(o){return t.Malloc(Uint16Array,o)}}),t.ke=t.ke||[],t.ke.push(function(){t.MakePicture=function(o){o=new Uint8Array(o);var s=t._malloc(o.byteLength);return t.HEAPU8.set(o,s),(o=t._MakePicture(s,o.byteLength))?o:null}}),t.ke=t.ke||[],t.ke.push(function(){t.RuntimeEffect.Make=function(o,s){return t.RuntimeEffect._Make(o,{onError:s||function(u){console.log("RuntimeEffect error",u)}})},t.RuntimeEffect.MakeForBlender=function(o,s){return t.RuntimeEffect._MakeForBlender(o,{onError:s||function(u){console.log("RuntimeEffect error",u)}})},t.RuntimeEffect.prototype.makeShader=function(o,s){var u=!o._ck,p=T(o,"HEAPF32");return s=z(s),this._makeShader(p,4*o.length,u,s)},t.RuntimeEffect.prototype.makeShaderWithChildren=function(o,s,u){var p=!o._ck,P=T(o,"HEAPF32");u=z(u);for(var M=[],N=0;N<s.length;N++)M.push(s[N].ae.ie);return s=T(M,"HEAPU32"),this._makeShaderWithChildren(P,4*o.length,p,s,M.length,u)},t.RuntimeEffect.prototype.makeBlender=function(o){var s=!o._ck,u=T(o,"HEAPF32");return this._makeBlender(u,4*o.length,s)}}),function(){function o($){for(var f=0;f<$.length;f++)if($[f]!==void 0&&!Number.isFinite($[f]))return!1;return!0}function s($){var f=t.getColorComponents($);$=f[0];var w=f[1],F=f[2];return f=f[3],f===1?($=$.toString(16).toLowerCase(),w=w.toString(16).toLowerCase(),F=F.toString(16).toLowerCase(),$=$.length===1?"0"+$:$,w=w.length===1?"0"+w:w,F=F.length===1?"0"+F:F,"#"+$+w+F):(f=f===0||f===1?f:f.toFixed(8),"rgba("+$+", "+w+", "+F+", "+f+")")}function u($){return t.parseColorString($,it)}function p($){if($=dt.exec($),!$)return null;var f=parseFloat($[4]),w=16;switch($[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:$[1],variant:$[2],weight:$[3],sizePx:w,family:$[6].trim()}}function P(){Te||(Te={"Noto Mono":{"*":t.Typeface.GetDefault()},monospace:{"*":t.Typeface.GetDefault()}})}function M($){this.ce=$,this.fe=new t.Paint,this.fe.setAntiAlias(!0),this.fe.setStrokeMiter(10),this.fe.setStrokeCap(t.StrokeCap.Butt),this.fe.setStrokeJoin(t.StrokeJoin.Miter),this.kf="10px monospace",this.Fe=new t.Font(t.Typeface.GetDefault(),10),this.Fe.setSubpixel(!0),this.se=this.ye=t.BLACK,this.Oe=0,this.af=t.TRANSPARENT,this.Qe=this.Pe=0,this.bf=this.Be=1,this.$e=0,this.Ne=[],this.ee=t.BlendMode.SrcOver,this.fe.setStrokeWidth(this.bf),this.fe.setBlendMode(this.ee),this.he=new t.Path,this.je=t.Matrix.identity(),this.Ff=[],this.Ue=[],this.Ee=function(){this.he.delete(),this.fe.delete(),this.Fe.delete(),this.Ue.forEach(function(f){f.Ee()})},Object.defineProperty(this,"currentTransform",{enumerable:!0,get:function(){return{a:this.je[0],c:this.je[1],e:this.je[2],b:this.je[3],d:this.je[4],f:this.je[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.se)?s(this.se):this.se},set:function(f){typeof f=="string"?this.se=u(f):f.Me&&(this.se=f)}}),Object.defineProperty(this,"font",{enumerable:!0,get:function(){return this.kf},set:function(f){var w=p(f),F=(w.style||"normal")+"|"+(w.variant||"normal")+"|"+(w.weight||"normal"),k=w.family;P(),F=Te[k]?Te[k][F]||Te[k]["*"]:t.Typeface.GetDefault(),w.typeface=F,w&&(this.Fe.setSize(w.sizePx),this.Fe.setTypeface(w.typeface),this.kf=f)}}),Object.defineProperty(this,"globalAlpha",{enumerable:!0,get:function(){return this.Be},set:function(f){!isFinite(f)||0>f||1<f||(this.Be=f)}}),Object.defineProperty(this,"globalCompositeOperation",{enumerable:!0,get:function(){switch(this.ee){case t.BlendMode.SrcOver:return"source-over";case t.BlendMode.DstOver:return"destination-over";case t.BlendMode.Src:return"copy";case t.BlendMode.Dst:return"destination";case t.BlendMode.Clear:return"clear";case t.BlendMode.SrcIn:return"source-in";case t.BlendMode.DstIn:return"destination-in";case t.BlendMode.SrcOut:return"source-out";case t.BlendMode.DstOut:return"destination-out";case t.BlendMode.SrcATop:return"source-atop";case t.BlendMode.DstATop:return"destination-atop";case t.BlendMode.Xor:return"xor";case t.BlendMode.Plus:return"lighter";case t.BlendMode.Multiply:return"multiply";case t.BlendMode.Screen:return"screen";case t.BlendMode.Overlay:return"overlay";case t.BlendMode.Darken:return"darken";case t.BlendMode.Lighten:return"lighten";case t.BlendMode.ColorDodge:return"color-dodge";case t.BlendMode.ColorBurn:return"color-burn";case t.BlendMode.HardLight:return"hard-light";case t.BlendMode.SoftLight:return"soft-light";case t.BlendMode.Difference:return"difference";case t.BlendMode.Exclusion:return"exclusion";case t.BlendMode.Hue:return"hue";case t.BlendMode.Saturation:return"saturation";case t.BlendMode.Color:return"color";case t.BlendMode.Luminosity:return"luminosity"}},set:function(f){switch(f){case"source-over":this.ee=t.BlendMode.SrcOver;break;case"destination-over":this.ee=t.BlendMode.DstOver;break;case"copy":this.ee=t.BlendMode.Src;break;case"destination":this.ee=t.BlendMode.Dst;break;case"clear":this.ee=t.BlendMode.Clear;break;case"source-in":this.ee=t.BlendMode.SrcIn;break;case"destination-in":this.ee=t.BlendMode.DstIn;break;case"source-out":this.ee=t.BlendMode.SrcOut;break;case"destination-out":this.ee=t.BlendMode.DstOut;break;case"source-atop":this.ee=t.BlendMode.SrcATop;break;case"destination-atop":this.ee=t.BlendMode.DstATop;break;case"xor":this.ee=t.BlendMode.Xor;break;case"lighter":this.ee=t.BlendMode.Plus;break;case"plus-lighter":this.ee=t.BlendMode.Plus;break;case"plus-darker":throw"plus-darker is not supported";case"multiply":this.ee=t.BlendMode.Multiply;break;case"screen":this.ee=t.BlendMode.Screen;break;case"overlay":this.ee=t.BlendMode.Overlay;break;case"darken":this.ee=t.BlendMode.Darken;break;case"lighten":this.ee=t.BlendMode.Lighten;break;case"color-dodge":this.ee=t.BlendMode.ColorDodge;break;case"color-burn":this.ee=t.BlendMode.ColorBurn;break;case"hard-light":this.ee=t.BlendMode.HardLight;break;case"soft-light":this.ee=t.BlendMode.SoftLight;break;case"difference":this.ee=t.BlendMode.Difference;break;case"exclusion":this.ee=t.BlendMode.Exclusion;break;case"hue":this.ee=t.BlendMode.Hue;break;case"saturation":this.ee=t.BlendMode.Saturation;break;case"color":this.ee=t.BlendMode.Color;break;case"luminosity":this.ee=t.BlendMode.Luminosity;break;default:return}this.fe.setBlendMode(this.ee)}}),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.fe.getStrokeCap()){case t.StrokeCap.Butt:return"butt";case t.StrokeCap.Round:return"round";case t.StrokeCap.Square:return"square"}},set:function(f){switch(f){case"butt":this.fe.setStrokeCap(t.StrokeCap.Butt);break;case"round":this.fe.setStrokeCap(t.StrokeCap.Round);break;case"square":this.fe.setStrokeCap(t.StrokeCap.Square)}}}),Object.defineProperty(this,"lineDashOffset",{enumerable:!0,get:function(){return this.$e},set:function(f){isFinite(f)&&(this.$e=f)}}),Object.defineProperty(this,"lineJoin",{enumerable:!0,get:function(){switch(this.fe.getStrokeJoin()){case t.StrokeJoin.Miter:return"miter";case t.StrokeJoin.Round:return"round";case t.StrokeJoin.Bevel:return"bevel"}},set:function(f){switch(f){case"miter":this.fe.setStrokeJoin(t.StrokeJoin.Miter);break;case"round":this.fe.setStrokeJoin(t.StrokeJoin.Round);break;case"bevel":this.fe.setStrokeJoin(t.StrokeJoin.Bevel)}}}),Object.defineProperty(this,"lineWidth",{enumerable:!0,get:function(){return this.fe.getStrokeWidth()},set:function(f){0>=f||!f||(this.bf=f,this.fe.setStrokeWidth(f))}}),Object.defineProperty(this,"miterLimit",{enumerable:!0,get:function(){return this.fe.getStrokeMiter()},set:function(f){0>=f||!f||this.fe.setStrokeMiter(f)}}),Object.defineProperty(this,"shadowBlur",{enumerable:!0,get:function(){return this.Oe},set:function(f){0>f||!isFinite(f)||(this.Oe=f)}}),Object.defineProperty(this,"shadowColor",{enumerable:!0,get:function(){return s(this.af)},set:function(f){this.af=u(f)}}),Object.defineProperty(this,"shadowOffsetX",{enumerable:!0,get:function(){return this.Pe},set:function(f){isFinite(f)&&(this.Pe=f)}}),Object.defineProperty(this,"shadowOffsetY",{enumerable:!0,get:function(){return this.Qe},set:function(f){isFinite(f)&&(this.Qe=f)}}),Object.defineProperty(this,"strokeStyle",{enumerable:!0,get:function(){return s(this.ye)},set:function(f){typeof f=="string"?this.ye=u(f):f.Me&&(this.ye=f)}}),this.arc=function(f,w,F,k,L,B){I(this.he,f,w,F,F,0,k,L,B)},this.arcTo=function(f,w,F,k,L){ve(this.he,f,w,F,k,L)},this.beginPath=function(){this.he.delete(),this.he=new t.Path},this.bezierCurveTo=function(f,w,F,k,L,B){var Z=this.he;o([f,w,F,k,L,B])&&(Z.isEmpty()&&Z.moveTo(f,w),Z.cubicTo(f,w,F,k,L,B))},this.clearRect=function(f,w,F,k){this.fe.setStyle(t.PaintStyle.Fill),this.fe.setBlendMode(t.BlendMode.Clear),this.ce.drawRect(t.XYWHRect(f,w,F,k),this.fe),this.fe.setBlendMode(this.ee)},this.clip=function(f,w){typeof f=="string"?(w=f,f=this.he):f&&f.vf&&(f=f.le),f||(f=this.he),f=f.copy(),w&&w.toLowerCase()==="evenodd"?f.setFillType(t.FillType.EvenOdd):f.setFillType(t.FillType.Winding),this.ce.clipPath(f,t.ClipOp.Intersect,!0),f.delete()},this.closePath=function(){be(this.he)},this.createImageData=function(){if(arguments.length===1){var f=arguments[0];return new ee(new Uint8ClampedArray(4*f.width*f.height),f.width,f.height)}if(arguments.length===2){f=arguments[0];var w=arguments[1];return new ee(new Uint8ClampedArray(4*f*w),f,w)}throw"createImageData expects 1 or 2 arguments, got "+arguments.length},this.createLinearGradient=function(f,w,F,k){if(o(arguments)){var L=new te(f,w,F,k);return this.Ue.push(L),L}},this.createPattern=function(f,w){return f=new ke(f,w),this.Ue.push(f),f},this.createRadialGradient=function(f,w,F,k,L,B){if(o(arguments)){var Z=new Xe(f,w,F,k,L,B);return this.Ue.push(Z),Z}},this.drawImage=function(f){f instanceof j&&(f=f.Lf());var w=this.jf();if(arguments.length===3||arguments.length===5)var F=t.XYWHRect(arguments[1],arguments[2],arguments[3]||f.width(),arguments[4]||f.height()),k=t.XYWHRect(0,0,f.width(),f.height());else if(arguments.length===9)F=t.XYWHRect(arguments[5],arguments[6],arguments[7],arguments[8]),k=t.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.ce.drawImageRect(f,k,F,w,!1),w.dispose()},this.ellipse=function(f,w,F,k,L,B,Z,pe){I(this.he,f,w,F,k,L,B,Z,pe)},this.jf=function(){var f=this.fe.copy();if(f.setStyle(t.PaintStyle.Fill),l(this.se)){var w=t.multiplyByAlpha(this.se,this.Be);f.setColor(w)}else w=this.se.Me(this.je),f.setColor(t.Color(0,0,0,this.Be)),f.setShader(w);return f.dispose=function(){this.delete()},f},this.fill=function(f,w){if(typeof f=="string"?(w=f,f=this.he):f&&f.vf&&(f=f.le),w==="evenodd")this.he.setFillType(t.FillType.EvenOdd);else{if(w!=="nonzero"&&w)throw"invalid fill rule";this.he.setFillType(t.FillType.Winding)}f||(f=this.he),w=this.jf();var F=this.Re(w);F&&(this.ce.save(),this.Ke(),this.ce.drawPath(f,F),this.ce.restore(),F.dispose()),this.ce.drawPath(f,w),w.dispose()},this.fillRect=function(f,w,F,k){var L=this.jf(),B=this.Re(L);B&&(this.ce.save(),this.Ke(),this.ce.drawRect(t.XYWHRect(f,w,F,k),B),this.ce.restore(),B.dispose()),this.ce.drawRect(t.XYWHRect(f,w,F,k),L),L.dispose()},this.fillText=function(f,w,F){var k=this.jf();f=t.TextBlob.MakeFromText(f,this.Fe);var L=this.Re(k);L&&(this.ce.save(),this.Ke(),this.ce.drawTextBlob(f,w,F,L),this.ce.restore(),L.dispose()),this.ce.drawTextBlob(f,w,F,k),f.delete(),k.dispose()},this.getImageData=function(f,w,F,k){return(f=this.ce.readPixels(f,w,{width:F,height:k,colorType:t.ColorType.RGBA_8888,alphaType:t.AlphaType.Unpremul,colorSpace:t.ColorSpace.SRGB}))?new ee(new Uint8ClampedArray(f.buffer),F,k):null},this.getLineDash=function(){return this.Ne.slice()},this.Gf=function(f){var w=t.Matrix.invert(this.je);return t.Matrix.mapPoints(w,f),f},this.isPointInPath=function(f,w,F){var k=arguments;if(k.length===3)var L=this.he;else if(k.length===4)L=k[0],f=k[1],w=k[2],F=k[3];else throw"invalid arg count, need 3 or 4, got "+k.length;return!isFinite(f)||!isFinite(w)||(F=F||"nonzero",F!=="nonzero"&&F!=="evenodd")?!1:(k=this.Gf([f,w]),f=k[0],w=k[1],L.setFillType(F==="nonzero"?t.FillType.Winding:t.FillType.EvenOdd),L.contains(f,w))},this.isPointInStroke=function(f,w){var F=arguments;if(F.length===2)var k=this.he;else if(F.length===3)k=F[0],f=F[1],w=F[2];else throw"invalid arg count, need 2 or 3, got "+F.length;return!isFinite(f)||!isFinite(w)?!1:(F=this.Gf([f,w]),f=F[0],w=F[1],k=k.copy(),k.setFillType(t.FillType.Winding),k.stroke({width:this.lineWidth,miter_limit:this.miterLimit,cap:this.fe.getStrokeCap(),join:this.fe.getStrokeJoin(),precision:.3}),F=k.contains(f,w),k.delete(),F)},this.lineTo=function(f,w){ce(this.he,f,w)},this.measureText=function(f){f=this.Fe.getGlyphIDs(f),f=this.Fe.getGlyphWidths(f);let w=0;for(const F of f)w+=F;return{width:w}},this.moveTo=function(f,w){var F=this.he;o([f,w])&&F.moveTo(f,w)},this.putImageData=function(f,w,F,k,L,B,Z){if(o([w,F,k,L,B,Z])){if(k===void 0)this.ce.writePixels(f.data,f.width,f.height,w,F);else if(k=k||0,L=L||0,B=B||f.width,Z=Z||f.height,0>B&&(k+=B,B=Math.abs(B)),0>Z&&(L+=Z,Z=Math.abs(Z)),0>k&&(B+=k,k=0),0>L&&(Z+=L,L=0),!(0>=B||0>=Z)){f=t.MakeImage({width:f.width,height:f.height,alphaType:t.AlphaType.Unpremul,colorType:t.ColorType.RGBA_8888,colorSpace:t.ColorSpace.SRGB},f.data,4*f.width);var pe=t.XYWHRect(k,L,B,Z);w=t.XYWHRect(w+k,F+L,B,Z),F=t.Matrix.invert(this.je),this.ce.save(),this.ce.concat(F),this.ce.drawImageRect(f,pe,w,null,!1),this.ce.restore(),f.delete()}}},this.quadraticCurveTo=function(f,w,F,k){var L=this.he;o([f,w,F,k])&&(L.isEmpty()&&L.moveTo(f,w),L.quadTo(f,w,F,k))},this.rect=function(f,w,F,k){var L=this.he;f=t.XYWHRect(f,w,F,k),o(f)&&L.addRect(f)},this.resetTransform=function(){this.he.transform(this.je);var f=t.Matrix.invert(this.je);this.ce.concat(f),this.je=this.ce.getTotalMatrix()},this.restore=function(){var f=this.Ff.pop();if(f){var w=t.Matrix.multiply(this.je,t.Matrix.invert(f.ag));this.he.transform(w),this.fe.delete(),this.fe=f.sg,this.Ne=f.qg,this.bf=f.Eg,this.ye=f.Dg,this.se=f.fs,this.Pe=f.Bg,this.Qe=f.Cg,this.Oe=f.sb,this.af=f.Ag,this.Be=f.ga,this.ee=f.hg,this.$e=f.rg,this.kf=f.gg,this.ce.restore(),this.je=this.ce.getTotalMatrix()}},this.rotate=function(f){if(isFinite(f)){var w=t.Matrix.rotated(-f);this.he.transform(w),this.ce.rotate(f/Math.PI*180,0,0),this.je=this.ce.getTotalMatrix()}},this.save=function(){if(this.se.Le){var f=this.se.Le();this.Ue.push(f)}else f=this.se;if(this.ye.Le){var w=this.ye.Le();this.Ue.push(w)}else w=this.ye;this.Ff.push({ag:this.je.slice(),qg:this.Ne.slice(),Eg:this.bf,Dg:w,fs:f,Bg:this.Pe,Cg:this.Qe,sb:this.Oe,Ag:this.af,ga:this.Be,rg:this.$e,hg:this.ee,sg:this.fe.copy(),gg:this.kf}),this.ce.save()},this.scale=function(f,w){if(o(arguments)){var F=t.Matrix.scaled(1/f,1/w);this.he.transform(F),this.ce.scale(f,w),this.je=this.ce.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.Ne=f},this.setTransform=function(f,w,F,k,L,B){o(arguments)&&(this.resetTransform(),this.transform(f,w,F,k,L,B))},this.Ke=function(){var f=t.Matrix.invert(this.je);this.ce.concat(f),this.ce.concat(t.Matrix.translated(this.Pe,this.Qe)),this.ce.concat(this.je)},this.Re=function(f){var w=t.multiplyByAlpha(this.af,this.Be);if(!t.getColorComponents(w)[3]||!(this.Oe||this.Qe||this.Pe))return null;f=f.copy(),f.setColor(w);var F=t.MaskFilter.MakeBlur(t.BlurStyle.Normal,this.Oe/2,!1);return f.setMaskFilter(F),f.dispose=function(){F.delete(),this.delete()},f},this.xf=function(){var f=this.fe.copy();if(f.setStyle(t.PaintStyle.Stroke),l(this.ye)){var w=t.multiplyByAlpha(this.ye,this.Be);f.setColor(w)}else w=this.ye.Me(this.je),f.setColor(t.Color(0,0,0,this.Be)),f.setShader(w);if(f.setStrokeWidth(this.bf),this.Ne.length){var F=t.PathEffect.MakeDash(this.Ne,this.$e);f.setPathEffect(F)}return f.dispose=function(){F&&F.delete(),this.delete()},f},this.stroke=function(f){f=f?f.le:this.he;var w=this.xf(),F=this.Re(w);F&&(this.ce.save(),this.Ke(),this.ce.drawPath(f,F),this.ce.restore(),F.dispose()),this.ce.drawPath(f,w),w.dispose()},this.strokeRect=function(f,w,F,k){var L=this.xf(),B=this.Re(L);B&&(this.ce.save(),this.Ke(),this.ce.drawRect(t.XYWHRect(f,w,F,k),B),this.ce.restore(),B.dispose()),this.ce.drawRect(t.XYWHRect(f,w,F,k),L),L.dispose()},this.strokeText=function(f,w,F){var k=this.xf();f=t.TextBlob.MakeFromText(f,this.Fe);var L=this.Re(k);L&&(this.ce.save(),this.Ke(),this.ce.drawTextBlob(f,w,F,L),this.ce.restore(),L.dispose()),this.ce.drawTextBlob(f,w,F,k),f.delete(),k.dispose()},this.translate=function(f,w){if(o(arguments)){var F=t.Matrix.translated(-f,-w);this.he.transform(F),this.ce.translate(f,w),this.je=this.ce.getTotalMatrix()}},this.transform=function(f,w,F,k,L,B){f=[f,F,L,w,k,B,0,0,1],w=t.Matrix.invert(f),this.he.transform(w),this.ce.concat(f),this.je=this.ce.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 N($){this.yf=$,this.be=new M($.getCanvas()),this.lf=[],this.decodeImage=function(f){if(f=t.MakeImageFromEncoded(f),!f)throw"Invalid input";return this.lf.push(f),new j(f)},this.loadFont=function(f,w){if(f=t.Typeface.MakeTypefaceFromData(f),!f)return null;this.lf.push(f);var F=(w.style||"normal")+"|"+(w.variant||"normal")+"|"+(w.weight||"normal");w=w.family,P(),Te[w]||(Te[w]={"*":f}),Te[w][F]=f},this.makePath2D=function(f){return f=new Ce(f),this.lf.push(f.le),f},this.getContext=function(f){return f==="2d"?this.be:null},this.toDataURL=function(f,w){this.yf.flush();var F=this.yf.makeImageSnapshot();if(F){f=f||"image/png";var k=t.ImageFormat.PNG;if(f==="image/jpeg"&&(k=t.ImageFormat.JPEG),w=F.encodeToBytes(k,w||.92)){if(F.delete(),f="data:"+f+";base64,",typeof Buffer<"u")w=Buffer.from(w).toString("base64");else{F=0,k=w.length;for(var L="",B;F<k;)B=w.slice(F,Math.min(F+32768,k)),L+=String.fromCharCode.apply(null,B),F+=32768;w=btoa(L)}return f+w}}},this.dispose=function(){this.be.Ee(),this.lf.forEach(function(f){f.delete()}),this.yf.dispose()}}function j($){this.width=$.width(),this.height=$.height(),this.naturalWidth=this.width,this.naturalHeight=this.height,this.Lf=function(){return $}}function ee($,f,w){if(!f||w===0)throw new TypeError("invalid dimensions, width and height must be non-zero");if($.length%4)throw new TypeError("arr must be a multiple of 4");w=w||$.length/(4*f),Object.defineProperty(this,"data",{value:$,writable:!1}),Object.defineProperty(this,"height",{value:w,writable:!1}),Object.defineProperty(this,"width",{value:f,writable:!1})}function te($,f,w,F){this.ne=null,this.ue=[],this.qe=[],this.addColorStop=function(k,L){if(0>k||1<k||!isFinite(k))throw"offset must be between 0 and 1 inclusively";L=u(L);var B=this.qe.indexOf(k);if(B!==-1)this.ue[B]=L;else{for(B=0;B<this.qe.length&&!(this.qe[B]>k);B++);this.qe.splice(B,0,k),this.ue.splice(B,0,L)}},this.Le=function(){var k=new te($,f,w,F);return k.ue=this.ue.slice(),k.qe=this.qe.slice(),k},this.Ee=function(){this.ne&&(this.ne.delete(),this.ne=null)},this.Me=function(k){var L=[$,f,w,F];t.Matrix.mapPoints(k,L),k=L[0];var B=L[1],Z=L[2];return L=L[3],this.Ee(),this.ne=t.Shader.MakeLinearGradient([k,B],[Z,L],this.ue,this.qe,t.TileMode.Clamp)}}function ve($,f,w,F,k,L){if(o([f,w,F,k,L])){if(0>L)throw"radii cannot be negative";$.isEmpty()&&$.moveTo(f,w),$.arcToTangent(f,w,F,k,L)}}function be($){if(!$.isEmpty()){var f=$.getBounds();(f[3]-f[1]||f[2]-f[0])&&$.close()}}function b($,f,w,F,k,L,B){B=(B-L)/Math.PI*180,L=L/Math.PI*180,f=t.LTRBRect(f-F,w-k,f+F,w+k),1e-5>Math.abs(Math.abs(B)-360)?(w=B/2,$.arcToOval(f,L,w,!1),$.arcToOval(f,L+w,w,!1)):$.arcToOval(f,L,B,!1)}function I($,f,w,F,k,L,B,Z,pe){if(o([f,w,F,k,L,B,Z])){if(0>F||0>k)throw"radii cannot be negative";var $e=2*Math.PI,jt=B%$e;0>jt&&(jt+=$e);var ci=jt-B;B=jt,Z+=ci,!pe&&Z-B>=$e?Z=B+$e:pe&&B-Z>=$e?Z=B-$e:!pe&&B>Z?Z=B+($e-(B-Z)%$e):pe&&B<Z&&(Z=B-($e-(Z-B)%$e)),L?(pe=t.Matrix.rotated(L,f,w),L=t.Matrix.rotated(-L,f,w),$.transform(L),b($,f,w,F,k,B,Z),$.transform(pe)):b($,f,w,F,k,B,Z)}}function ce($,f,w){o([f,w])&&($.isEmpty()&&$.moveTo(f,w),$.lineTo(f,w))}function Ce($){this.le=null,this.le=typeof $=="string"?t.Path.MakeFromSVGString($):$&&$.vf?$.le.copy():new t.Path,this.vf=function(){return this.le},this.addPath=function(f,w){w||(w={a:1,c:0,e:0,b:0,d:1,f:0}),this.le.addPath(f.le,[w.a,w.c,w.e,w.b,w.d,w.f])},this.arc=function(f,w,F,k,L,B){I(this.le,f,w,F,F,0,k,L,B)},this.arcTo=function(f,w,F,k,L){ve(this.le,f,w,F,k,L)},this.bezierCurveTo=function(f,w,F,k,L,B){var Z=this.le;o([f,w,F,k,L,B])&&(Z.isEmpty()&&Z.moveTo(f,w),Z.cubicTo(f,w,F,k,L,B))},this.closePath=function(){be(this.le)},this.ellipse=function(f,w,F,k,L,B,Z,pe){I(this.le,f,w,F,k,L,B,Z,pe)},this.lineTo=function(f,w){ce(this.le,f,w)},this.moveTo=function(f,w){var F=this.le;o([f,w])&&F.moveTo(f,w)},this.quadraticCurveTo=function(f,w,F,k){var L=this.le;o([f,w,F,k])&&(L.isEmpty()&&L.moveTo(f,w),L.quadTo(f,w,F,k))},this.rect=function(f,w,F,k){var L=this.le;f=t.XYWHRect(f,w,F,k),o(f)&&L.addRect(f)}}function ke($,f){switch(this.ne=null,$ instanceof j&&($=$.Lf()),this.Uf=$,this._transform=t.Matrix.identity(),f===""&&(f="repeat"),f){case"repeat-x":this.Se=t.TileMode.Repeat,this.Te=t.TileMode.Decal;break;case"repeat-y":this.Se=t.TileMode.Decal,this.Te=t.TileMode.Repeat;break;case"repeat":this.Te=this.Se=t.TileMode.Repeat;break;case"no-repeat":this.Te=this.Se=t.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.Le=function(){var w=new ke;return w.Se=this.Se,w.Te=this.Te,w},this.Ee=function(){this.ne&&(this.ne.delete(),this.ne=null)},this.Me=function(){return this.Ee(),this.ne=this.Uf.makeShaderCubic(this.Se,this.Te,.3333333333333333,.3333333333333333,this._transform)}}function Xe($,f,w,F,k,L){this.ne=null,this.ue=[],this.qe=[],this.addColorStop=function(B,Z){if(0>B||1<B||!isFinite(B))throw"offset must be between 0 and 1 inclusively";Z=u(Z);var pe=this.qe.indexOf(B);if(pe!==-1)this.ue[pe]=Z;else{for(pe=0;pe<this.qe.length&&!(this.qe[pe]>B);pe++);this.qe.splice(pe,0,B),this.ue.splice(pe,0,Z)}},this.Le=function(){var B=new Xe($,f,w,F,k,L);return B.ue=this.ue.slice(),B.qe=this.qe.slice(),B},this.Ee=function(){this.ne&&(this.ne.delete(),this.ne=null)},this.Me=function(B){var Z=[$,f,F,k];t.Matrix.mapPoints(B,Z);var pe=Z[0],$e=Z[1],jt=Z[2];Z=Z[3];var ci=(Math.abs(B[0])+Math.abs(B[4]))/2;return B=w*ci,ci*=L,this.Ee(),this.ne=t.Shader.MakeTwoPointConicalGradient([pe,$e],B,[jt,Z],ci,this.ue,this.qe,t.TileMode.Clamp)}}t._testing={};var it={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)};t._testing.parseColor=u,t._testing.colorToString=s;var dt=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)(.+)"),Te;t._testing.parseFontString=p,t.MakeCanvas=function($,f){return($=t.MakeSurface($,f))?new N($):null},t.ImageData=function(){if(arguments.length===2){var $=arguments[0],f=arguments[1];return new ee(new Uint8ClampedArray(4*$*f),$,f)}if(arguments.length===3){var w=arguments[0];if(w.prototype.constructor!==Uint8ClampedArray)throw new TypeError("bytes must be given as a Uint8ClampedArray");if($=arguments[1],f=arguments[2],w%4)throw new TypeError("bytes must be given in a multiple of 4");if(w%$)throw new TypeError("bytes must divide evenly by width");if(f&&f!==w/(4*$))throw new TypeError("invalid height given");return new ee(w,$,w/(4*$))}throw new TypeError("invalid number of arguments - takes 2 or 3, saw "+arguments.length)}}()}(c);var O=Object.assign({},c),G="./this.program",K=(t,n)=>{throw n},ie=typeof window=="object",le=typeof importScripts=="function",ye=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",ae="",Ee,We,Be;if(ye){var at=vs,U=As;ae=le?U.dirname(ae)+"/":__dirname+"/",Ee=(t,n)=>(t=t.startsWith("file://")?new URL(t):U.normalize(t),at.readFileSync(t,n?void 0:"utf8")),Be=t=>(t=Ee(t,!0),t.buffer||(t=new Uint8Array(t)),t),We=(t,n,a,l=!0)=>{t=t.startsWith("file://")?new URL(t):U.normalize(t),at.readFile(t,l?void 0:"utf8",(d,g)=>{d?a(d):n(l?g.buffer:g)})},!c.thisProgram&&1<process.argv.length&&(G=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),K=(t,n)=>{throw process.exitCode=t,n},c.inspect=()=>"[Emscripten Module object]"}else(ie||le)&&(le?ae=self.location.href:typeof document<"u"&&document.currentScript&&(ae=document.currentScript.src),r&&(ae=r),ae.indexOf("blob:")!==0?ae=ae.substr(0,ae.replace(/[?#].*/,"").lastIndexOf("/")+1):ae="",Ee=t=>{var n=new XMLHttpRequest;return n.open("GET",t,!1),n.send(null),n.responseText},le&&(Be=t=>{var n=new XMLHttpRequest;return n.open("GET",t,!1),n.responseType="arraybuffer",n.send(null),new Uint8Array(n.response)}),We=(t,n,a)=>{var l=new XMLHttpRequest;l.open("GET",t,!0),l.responseType="arraybuffer",l.onload=()=>{l.status==200||l.status==0&&l.response?n(l.response):a()},l.onerror=a,l.send(null)});var ue=c.print||console.log.bind(console),Pt=c.printErr||console.error.bind(console);Object.assign(c,O),O=null,c.thisProgram&&(G=c.thisProgram),c.quit&&(K=c.quit);var qt;c.wasmBinary&&(qt=c.wasmBinary),c.noExitRuntime,typeof WebAssembly!="object"&&Wi("no native wasm support detected");var gi,Pe,Cn=!1,pt,fe,At,Bt,W,_e,ne,Tn;function _n(){var t=gi.buffer;c.HEAP8=pt=new Int8Array(t),c.HEAP16=At=new Int16Array(t),c.HEAP32=W=new Int32Array(t),c.HEAPU8=fe=new Uint8Array(t),c.HEAPU16=Bt=new Uint16Array(t),c.HEAPU32=_e=new Uint32Array(t),c.HEAPF32=ne=new Float32Array(t),c.HEAPF64=Tn=new Float64Array(t)}var Fe,En=[],Mn=[],xn=[];function oa(){var t=c.preRun.shift();En.unshift(t)}var Mt=0,Yt=null;function Wi(t){throw c.onAbort&&c.onAbort(t),t="Aborted("+t+")",Pt(t),Cn=!0,t=new WebAssembly.RuntimeError(t+". Build with -sASSERTIONS for more info."),E(t),t}function Fn(t){return t.startsWith("data:application/octet-stream;base64,")}var Ut;if(Ut="canvaskit.wasm",!Fn(Ut)){var Rn=Ut;Ut=c.locateFile?c.locateFile(Rn,ae):ae+Rn}function kn(t){if(t==Ut&&qt)return new Uint8Array(qt);if(Be)return Be(t);throw"both async and sync fetching of the wasm failed"}function la(t){if(!qt&&(ie||le)){if(typeof fetch=="function"&&!t.startsWith("file://"))return fetch(t,{credentials:"same-origin"}).then(n=>{if(!n.ok)throw"failed to load wasm binary file at '"+t+"'";return n.arrayBuffer()}).catch(()=>kn(t));if(We)return new Promise((n,a)=>{We(t,l=>n(new Uint8Array(l)),a)})}return Promise.resolve().then(()=>kn(t))}function Nn(t,n,a){return la(t).then(l=>WebAssembly.instantiate(l,n)).then(l=>l).then(a,l=>{Pt("failed to asynchronously prepare wasm: "+l),Wi(l)})}function ha(t,n){var a=Ut;return qt||typeof WebAssembly.instantiateStreaming!="function"||Fn(a)||a.startsWith("file://")||ye||typeof fetch!="function"?Nn(a,t,n):fetch(a,{credentials:"same-origin"}).then(l=>WebAssembly.instantiateStreaming(l,t).then(n,function(d){return Pt("wasm streaming compile failed: "+d),Pt("falling back to ArrayBuffer instantiation"),Nn(a,t,n)}))}function ca(t){this.name="ExitStatus",this.message=`Program terminated with exit(${t})`,this.status=t}var ji=t=>{for(;0<t.length;)t.shift()(c)},In=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,xt=(t,n,a)=>{var l=n+a;for(a=n;t[a]&&!(a>=l);)++a;if(16<a-n&&t.buffer&&In)return In.decode(t.subarray(n,a));for(l="";n<a;){var d=t[n++];if(d&128){var g=t[n++]&63;if((d&224)==192)l+=String.fromCharCode((d&31)<<6|g);else{var A=t[n++]&63;d=(d&240)==224?(d&15)<<12|g<<6|A:(d&7)<<18|g<<12|A<<6|t[n++]&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},mi={};function Hi(t){for(;t.length;){var n=t.pop();t.pop()(n)}}function Xt(t){return this.fromWireType(W[t>>2])}var $t={},Ft={},yi={},On=void 0;function vi(t){throw new On(t)}function st(t,n,a){function l(y){y=a(y),y.length!==t.length&&vi("Mismatched type converter count");for(var v=0;v<t.length;++v)gt(t[v],y[v])}t.forEach(function(y){yi[y]=n});var d=Array(n.length),g=[],A=0;n.forEach((y,v)=>{Ft.hasOwnProperty(y)?d[v]=Ft[y]:(g.push(y),$t.hasOwnProperty(y)||($t[y]=[]),$t[y].push(()=>{d[v]=Ft[y],++A,A===g.length&&l(d)}))}),g.length===0&&l(d)}function wi(t){switch(t){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError(`Unknown type size: ${t}`)}}var Dn=void 0;function xe(t){for(var n="";fe[t];)n+=Dn[fe[t++]];return n}var Gt=void 0;function we(t){throw new Gt(t)}function ua(t,n,a={}){var l=n.name;if(t||we(`type "${l}" must have a positive integer typeid pointer`),Ft.hasOwnProperty(t)){if(a.ng)return;we(`Cannot register type '${l}' twice`)}Ft[t]=n,delete yi[t],$t.hasOwnProperty(t)&&(n=$t[t],delete $t[t],n.forEach(d=>d()))}function gt(t,n,a={}){if(!("argPackAdvance"in n))throw new TypeError("registerType registeredInstance requires argPackAdvance");ua(t,n,a)}function Ki(t){we(t.ae.me.ge.name+" instance already deleted")}var Vi=!1;function Ln(){}function zn(t){--t.count.value,t.count.value===0&&(t.pe?t.we.De(t.pe):t.me.ge.De(t.ie))}function Bn(t,n,a){return n===a?t:a.re===void 0?null:(t=Bn(t,n,a.re),t===null?null:a.dg(t))}var Un={},Jt=[];function qi(){for(;Jt.length;){var t=Jt.pop();t.ae.Xe=!1,t.delete()}}var Qt=void 0,Zt={};function da(t,n){for(n===void 0&&we("ptr should not be undefined");t.re;)n=t.gf(n),t=t.re;return Zt[n]}function Si(t,n){return n.me&&n.ie||vi("makeClassHandle requires ptr and ptrType"),!!n.we!=!!n.pe&&vi("Both smartPtrType and smartPtr must be specified"),n.count={value:1},ei(Object.create(t,{ae:{value:n}}))}function ei(t){return typeof FinalizationRegistry>"u"?(ei=n=>n,t):(Vi=new FinalizationRegistry(n=>{zn(n.ae)}),ei=n=>{var a=n.ae;return a.pe&&Vi.register(n,{ae:a},n),n},Ln=n=>{Vi.unregister(n)},ei(t))}function Ct(){}function $n(t){if(t===void 0)return"_unknown";t=t.replace(/[^a-zA-Z0-9_]/g,"$");var n=t.charCodeAt(0);return 48<=n&&57>=n?`_${t}`:t}function Yi(t,n){return t=$n(t),{[t]:function(){return n.apply(this,arguments)}}[t]}function Xi(t,n,a){if(t[n].oe===void 0){var l=t[n];t[n]=function(){return t[n].oe.hasOwnProperty(arguments.length)||we(`Function '${a}' called with an invalid number of arguments (${arguments.length}) - expects one of (${t[n].oe})!`),t[n].oe[arguments.length].apply(this,arguments)},t[n].oe=[],t[n].oe[l.Ve]=l}}function Ji(t,n,a){c.hasOwnProperty(t)?((a===void 0||c[t].oe!==void 0&&c[t].oe[a]!==void 0)&&we(`Cannot register public name '${t}' twice`),Xi(c,t,t),c.hasOwnProperty(a)&&we(`Cannot register multiple overloads of a function with the same number of arguments (${a})!`),c[t].oe[a]=n):(c[t]=n,a!==void 0&&(c[t].Lg=a))}function fa(t,n,a,l,d,g,A,y){this.name=t,this.constructor=n,this.Ye=a,this.De=l,this.re=d,this.ig=g,this.gf=A,this.dg=y,this.ug=[]}function Qi(t,n,a){for(;n!==a;)n.gf||we(`Expected null or instance of ${a.name}, got an instance of ${n.name}`),t=n.gf(t),n=n.re;return t}function pa(t,n){return n===null?(this.Bf&&we(`null is not a valid ${this.name}`),0):(n.ae||we(`Cannot pass "${en(n)}" as a ${this.name}`),n.ae.ie||we(`Cannot pass deleted object as a pointer of type ${this.name}`),Qi(n.ae.ie,n.ae.me.ge,this.ge))}function ga(t,n){if(n===null){if(this.Bf&&we(`null is not a valid ${this.name}`),this.pf){var a=this.Cf();return t!==null&&t.push(this.De,a),a}return 0}if(n.ae||we(`Cannot pass "${en(n)}" as a ${this.name}`),n.ae.ie||we(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.nf&&n.ae.me.nf&&we(`Cannot convert argument of type ${n.ae.we?n.ae.we.name:n.ae.me.name} to parameter type ${this.name}`),a=Qi(n.ae.ie,n.ae.me.ge,this.ge),this.pf)switch(n.ae.pe===void 0&&we("Passing raw pointer to smart pointer is illegal"),this.zg){case 0:n.ae.we===this?a=n.ae.pe:we(`Cannot convert argument of type ${n.ae.we?n.ae.we.name:n.ae.me.name} to parameter type ${this.name}`);break;case 1:a=n.ae.pe;break;case 2:if(n.ae.we===this)a=n.ae.pe;else{var l=n.clone();a=this.vg(a,et(function(){l.delete()})),t!==null&&t.push(this.De,a)}break;default:we("Unsupporting sharing policy")}return a}function ma(t,n){return n===null?(this.Bf&&we(`null is not a valid ${this.name}`),0):(n.ae||we(`Cannot pass "${en(n)}" as a ${this.name}`),n.ae.ie||we(`Cannot pass deleted object as a pointer of type ${this.name}`),n.ae.me.nf&&we(`Cannot convert argument of type ${n.ae.me.name} to parameter type ${this.name}`),Qi(n.ae.ie,n.ae.me.ge,this.ge))}function mt(t,n,a,l,d,g,A,y,v,T,D){this.name=t,this.ge=n,this.Bf=a,this.nf=l,this.pf=d,this.tg=g,this.zg=A,this.Nf=y,this.Cf=v,this.vg=T,this.De=D,d||n.re!==void 0?this.toWireType=ga:(this.toWireType=l?pa:ma,this.ve=null)}function Gn(t,n,a){c.hasOwnProperty(t)||vi("Replacing nonexistant public symbol"),c[t].oe!==void 0&&a!==void 0?c[t].oe[a]=n:(c[t]=n,c[t].Ve=a)}var ya=(t,n)=>{var a=[];return function(){if(a.length=0,Object.assign(a,arguments),t.includes("j")){var l=c["dynCall_"+t];l=a&&a.length?l.apply(null,[n].concat(a)):l.call(null,n)}else l=Fe.get(n).apply(null,a);return l}};function Ue(t,n){t=xe(t);var a=t.includes("j")?ya(t,n):Fe.get(n);return typeof a!="function"&&we(`unknown function pointer with signature ${t}: ${n}`),a}var Wn=void 0;function jn(t){t=Sr(t);var n=xe(t);return wt(t),n}function ti(t,n){function a(g){d[g]||Ft[g]||(yi[g]?yi[g].forEach(a):(l.push(g),d[g]=!0))}var l=[],d={};throw n.forEach(a),new Wn(`${t}: `+l.map(jn).join([", "]))}function bi(t,n,a,l,d){var g=n.length;2>g&&we("argTypes array size mismatch! Must at least get return value and 'this' types!");var A=n[1]!==null&&a!==null,y=!1;for(a=1;a<n.length;++a)if(n[a]!==null&&n[a].ve===void 0){y=!0;break}var v=n[0].name!=="void",T=g-2,D=Array(T),z=[],Y=[];return function(){if(arguments.length!==T&&we(`function ${t} called with ${arguments.length} arguments, expected ${T} args!`),Y.length=0,z.length=A?2:1,z[0]=d,A){var x=n[1].toWireType(Y,this);z[1]=x}for(var J=0;J<T;++J)D[J]=n[J+2].toWireType(Y,arguments[J]),z.push(D[J]);if(J=l.apply(null,z),y)Hi(Y);else for(var he=A?1:2;he<n.length;he++){var oe=he===1?x:D[he-2];n[he].ve!==null&&n[he].ve(oe)}return x=v?n[0].fromWireType(J):void 0,x}}function Pi(t,n){for(var a=[],l=0;l<t;l++)a.push(_e[n+4*l>>2]);return a}function Hn(){this.Ce=[void 0],this.Kf=[]}var Qe=new Hn;function Zi(t){t>=Qe.df&&--Qe.get(t).Of===0&&Qe.Zf(t)}var Ze=t=>(t||we("Cannot use deleted val. handle = "+t),Qe.get(t).value),et=t=>{switch(t){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return Qe.Yf({Of:1,value:t})}};function va(t,n,a){switch(n){case 0:return function(l){return this.fromWireType((a?pt:fe)[l])};case 1:return function(l){return this.fromWireType((a?At:Bt)[l>>1])};case 2:return function(l){return this.fromWireType((a?W:_e)[l>>2])};default:throw new TypeError("Unknown integer type: "+t)}}function ii(t,n){var a=Ft[t];return a===void 0&&we(n+" has unknown type "+jn(t)),a}function en(t){if(t===null)return"null";var n=typeof t;return n==="object"||n==="array"||n==="function"?t.toString():""+t}function wa(t,n){switch(n){case 2:return function(a){return this.fromWireType(ne[a>>2])};case 3:return function(a){return this.fromWireType(Tn[a>>3])};default:throw new TypeError("Unknown float type: "+t)}}function Sa(t,n,a){switch(n){case 0:return a?function(l){return pt[l]}:function(l){return fe[l]};case 1:return a?function(l){return At[l>>1]}:function(l){return Bt[l>>1]};case 2:return a?function(l){return W[l>>2]}:function(l){return _e[l>>2]};default:throw new TypeError("Unknown integer type: "+t)}}var ot=(t,n,a,l)=>{if(!(0<l))return 0;var d=a;l=a+l-1;for(var g=0;g<t.length;++g){var A=t.charCodeAt(g);if(55296<=A&&57343>=A){var y=t.charCodeAt(++g);A=65536+((A&1023)<<10)|y&1023}if(127>=A){if(a>=l)break;n[a++]=A}else{if(2047>=A){if(a+1>=l)break;n[a++]=192|A>>6}else{if(65535>=A){if(a+2>=l)break;n[a++]=224|A>>12}else{if(a+3>=l)break;n[a++]=240|A>>18,n[a++]=128|A>>12&63}n[a++]=128|A>>6&63}n[a++]=128|A&63}}return n[a]=0,a-d},lt=t=>{for(var n=0,a=0;a<t.length;++a){var l=t.charCodeAt(a);127>=l?n++:2047>=l?n+=2:55296<=l&&57343>=l?(n+=4,++a):n+=3}return n},Kn=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,ba=(t,n)=>{for(var a=t>>1,l=a+n/2;!(a>=l)&&Bt[a];)++a;if(a<<=1,32<a-t&&Kn)return Kn.decode(fe.subarray(t,a));for(a="",l=0;!(l>=n/2);++l){var d=At[t+2*l>>1];if(d==0)break;a+=String.fromCharCode(d)}return a},Pa=(t,n,a)=>{if(a===void 0&&(a=2147483647),2>a)return 0;a-=2;var l=n;a=a<2*t.length?a/2:t.length;for(var d=0;d<a;++d)At[n>>1]=t.charCodeAt(d),n+=2;return At[n>>1]=0,n-l},Aa=t=>2*t.length,Ca=(t,n)=>{for(var a=0,l="";!(a>=n/4);){var d=W[t+4*a>>2];if(d==0)break;++a,65536<=d?(d-=65536,l+=String.fromCharCode(55296|d>>10,56320|d&1023)):l+=String.fromCharCode(d)}return l},Ta=(t,n,a)=>{if(a===void 0&&(a=2147483647),4>a)return 0;var l=n;a=l+a-4;for(var d=0;d<t.length;++d){var g=t.charCodeAt(d);if(55296<=g&&57343>=g){var A=t.charCodeAt(++d);g=65536+((g&1023)<<10)|A&1023}if(W[n>>2]=g,n+=4,n+4>a)break}return W[n>>2]=0,n-l},_a=t=>{for(var n=0,a=0;a<t.length;++a){var l=t.charCodeAt(a);55296<=l&&57343>=l&&++a,n+=4}return n},Ea={};function Ai(t){var n=Ea[t];return n===void 0?xe(t):n}var Ci=[];function Vn(){function t(n){n.$$$embind_global$$$=n;var a=typeof $$$embind_global$$$=="object"&&n.$$$embind_global$$$==n;return a||delete n.$$$embind_global$$$,a}if(typeof globalThis=="object")return globalThis;if(typeof $$$embind_global$$$=="object"||(typeof mn=="object"&&t(mn)?$$$embind_global$$$=mn:typeof self=="object"&&t(self)&&($$$embind_global$$$=self),typeof $$$embind_global$$$=="object"))return $$$embind_global$$$;throw Error("unable to get global object.")}function Ma(t){var n=Ci.length;return Ci.push(t),n}function xa(t,n){for(var a=Array(t),l=0;l<t;++l)a[l]=ii(_e[n+4*l>>2],"parameter "+l);return a}var qn=[];function Fa(t){var n=Array(t+1);return function(a,l,d){n[0]=a;for(var g=0;g<t;++g){var A=ii(_e[l+4*g>>2],"parameter "+g);n[g+1]=A.readValueFromPointer(d),d+=A.argPackAdvance}return a=new(a.bind.apply(a,n)),et(a)}}var Yn={};function Ra(t){var n=t.getExtension("ANGLE_instanced_arrays");n&&(t.vertexAttribDivisor=function(a,l){n.vertexAttribDivisorANGLE(a,l)},t.drawArraysInstanced=function(a,l,d,g){n.drawArraysInstancedANGLE(a,l,d,g)},t.drawElementsInstanced=function(a,l,d,g,A){n.drawElementsInstancedANGLE(a,l,d,g,A)})}function ka(t){var n=t.getExtension("OES_vertex_array_object");n&&(t.createVertexArray=function(){return n.createVertexArrayOES()},t.deleteVertexArray=function(a){n.deleteVertexArrayOES(a)},t.bindVertexArray=function(a){n.bindVertexArrayOES(a)},t.isVertexArray=function(a){return n.isVertexArrayOES(a)})}function Na(t){var n=t.getExtension("WEBGL_draw_buffers");n&&(t.drawBuffers=function(a,l){n.drawBuffersWEBGL(a,l)})}var Xn=1,Ti=[],ht=[],_i=[],ni=[],tt=[],ct=[],Ei=[],yt=[],qe=[],Rt=[],kt=[],Jn={},Qn={},Zn=4;function Se(t){Mi||(Mi=t)}function Nt(t){for(var n=Xn++,a=t.length;a<n;a++)t[a]=null;return n}function Ia(t,n){t.df||(t.df=t.getContext,t.getContext=function(l,d){return d=t.df(l,d),l=="webgl"==d instanceof WebGLRenderingContext?d:null});var a=1<n.majorVersion?t.getContext("webgl2",n):t.getContext("webgl",n);return a?Oa(a,n):0}function Oa(t,n){var a=Nt(yt),l={handle:a,attributes:n,version:n.majorVersion,xe:t};return t.canvas&&(t.canvas.Rf=l),yt[a]=l,(typeof n.eg>"u"||n.eg)&&Da(l),a}function er(t){return se=yt[t],c.Jg=_=se&&se.xe,!(t&&!_)}function Da(t){if(t||(t=se),!t.og){t.og=!0;var n=t.xe;Ra(n),ka(n),Na(n),n.If=n.getExtension("WEBGL_draw_instanced_base_vertex_base_instance"),n.Mf=n.getExtension("WEBGL_multi_draw_instanced_base_vertex_base_instance"),2<=t.version&&(n.ze=n.getExtension("EXT_disjoint_timer_query_webgl2")),(2>t.version||!n.ze)&&(n.ze=n.getExtension("EXT_disjoint_timer_query")),n.Kg=n.getExtension("WEBGL_multi_draw"),(n.getSupportedExtensions()||[]).forEach(function(a){a.includes("lose_context")||a.includes("debug")||n.getExtension(a)})}}var se,Mi;function tr(t,n){_.bindFramebuffer(t,_i[n])}function ir(t){_.bindVertexArray(Ei[t])}function nr(t){_.clear(t)}function rr(t,n,a,l){_.clearColor(t,n,a,l)}function ar(t){_.clearStencil(t)}function sr(t,n){for(var a=0;a<t;a++){var l=W[n+4*a>>2];_.deleteVertexArray(Ei[l]),Ei[l]=null}}var xi=[];function or(t,n,a,l){_.drawElements(t,n,a,l)}function It(t,n,a,l){for(var d=0;d<t;d++){var g=_[a](),A=g&&Nt(l);g?(g.name=A,l[A]=g):Se(1282),W[n+4*d>>2]=A}}function lr(t,n){It(t,n,"createVertexArray",Ei)}function hr(t,n){_e[t>>2]=n,_e[t+4>>2]=(n-_e[t>>2])/4294967296}function cr(t,n,a){if(n){var l=void 0;switch(t){case 36346:l=1;break;case 36344:a!=0&&a!=1&&Se(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>se.version){Se(1282);return}l=2*(_.getSupportedExtensions()||[]).length;break;case 33307:case 33308:if(2>se.version){Se(1280);return}l=t==33307?3:0}if(l===void 0)switch(d=_.getParameter(t),typeof d){case"number":l=d;break;case"boolean":l=d?1:0;break;case"string":Se(1280);return;case"object":if(d===null)switch(t){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:Se(1280);return}else{if(d instanceof Float32Array||d instanceof Uint32Array||d instanceof Int32Array||d instanceof Array){for(t=0;t<d.length;++t)switch(a){case 0:W[n+4*t>>2]=d[t];break;case 2:ne[n+4*t>>2]=d[t];break;case 4:pt[n+t>>0]=d[t]?1:0}return}try{l=d.name|0}catch(g){Se(1280),Pt("GL_INVALID_ENUM in glGet"+a+"v: Unknown object returned from WebGL getParameter("+t+")! (error: "+g+")");return}}break;default:Se(1280),Pt("GL_INVALID_ENUM in glGet"+a+"v: Native code calling glGet"+a+"v("+t+") and it returns "+d+" of type "+typeof d+"!");return}switch(a){case 1:hr(n,l);break;case 0:W[n>>2]=l;break;case 2:ne[n>>2]=l;break;case 4:pt[n>>0]=l?1:0}}else Se(1281)}function ur(t,n){cr(t,n,0)}function dr(t,n,a){if(a){t=qe[t],n=2>se.version?_.ze.getQueryObjectEXT(t,n):_.getQueryParameter(t,n);var l;typeof n=="boolean"?l=n?1:0:l=n,hr(a,l)}else Se(1281)}var ri=t=>{var n=lt(t)+1,a=Ni(n);return a&&ot(t,fe,a,n),a};function fr(t){var n=Jn[t];if(!n){switch(t){case 7939:n=_.getSupportedExtensions()||[],n=n.concat(n.map(function(l){return"GL_"+l})),n=ri(n.join(" "));break;case 7936:case 7937:case 37445:case 37446:(n=_.getParameter(t))||Se(1280),n=n&&ri(n);break;case 7938:n=_.getParameter(7938),n=2<=se.version?"OpenGL ES 3.0 ("+n+")":"OpenGL ES 2.0 ("+n+")",n=ri(n);break;case 35724:n=_.getParameter(35724);var a=n.match(/^WebGL GLSL ES ([0-9]\.[0-9][0-9]?)(?:$| .*)/);a!==null&&(a[1].length==3&&(a[1]+="0"),n="OpenGL ES GLSL ES "+a[1]+" ("+n+")"),n=ri(n);break;default:Se(1280)}Jn[t]=n}return n}function pr(t,n){if(2>se.version)return Se(1282),0;var a=Qn[t];if(a)return 0>n||n>=a.length?(Se(1281),0):a[n];switch(t){case 7939:return a=_.getSupportedExtensions()||[],a=a.concat(a.map(function(l){return"GL_"+l})),a=a.map(function(l){return ri(l)}),a=Qn[t]=a,0>n||n>=a.length?(Se(1281),0):a[n];default:return Se(1280),0}}function gr(t){return t.slice(-1)=="]"&&t.lastIndexOf("[")}function Fi(t){return t-=5120,t==0?pt:t==1?fe:t==2?At:t==4?W:t==6?ne:t==5||t==28922||t==28520||t==30779||t==30782?_e:Bt}function tn(t,n,a,l,d){t=Fi(t);var g=31-Math.clz32(t.BYTES_PER_ELEMENT),A=Zn;return t.subarray(d>>g,d+l*(a*({5:3,6:4,8:2,29502:3,29504:4,26917:2,26918:2,29846:3,29847:4}[n-6402]||1)*(1<<g)+A-1&-A)>>g)}function Ae(t){var n=_.bg;if(n){var a=n.ff[t];return typeof a=="number"&&(n.ff[t]=a=_.getUniformLocation(n,n.Pf[t]+(0<a?"["+a+"]":""))),a}Se(1282)}var Tt=[],ai=[],nn={},mr=()=>{if(!rn){var t={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",_:G||"./this.program"},n;for(n in nn)nn[n]===void 0?delete t[n]:t[n]=nn[n];var a=[];for(n in t)a.push(`${n}=${t[n]}`);rn=a}return rn},rn,La=[null,[],[]],Ri=t=>t%4===0&&(t%100!==0||t%400===0),yr=[31,29,31,30,31,30,31,31,30,31,30,31],vr=[31,28,31,30,31,30,31,31,30,31,30,31];function za(t){var n=Array(lt(t)+1);return ot(t,n,0,n.length),n}var Ba=(t,n,a,l)=>{function d(x,J,he){for(x=typeof x=="number"?x.toString():x||"";x.length<J;)x=he[0]+x;return x}function g(x,J){return d(x,J,"0")}function A(x,J){function he(He){return 0>He?-1:0<He?1:0}var oe;return(oe=he(x.getFullYear()-J.getFullYear()))===0&&(oe=he(x.getMonth()-J.getMonth()))===0&&(oe=he(x.getDate()-J.getDate())),oe}function y(x){switch(x.getDay()){case 0:return new Date(x.getFullYear()-1,11,29);case 1:return x;case 2:return new Date(x.getFullYear(),0,3);case 3:return new Date(x.getFullYear(),0,2);case 4:return new Date(x.getFullYear(),0,1);case 5:return new Date(x.getFullYear()-1,11,31);case 6:return new Date(x.getFullYear()-1,11,30)}}function v(x){var J=x.He;for(x=new Date(new Date(x.Ie+1900,0,1).getTime());0<J;){var he=x.getMonth(),oe=(Ri(x.getFullYear())?yr:vr)[he];if(J>oe-x.getDate())J-=oe-x.getDate()+1,x.setDate(1),11>he?x.setMonth(he+1):(x.setMonth(0),x.setFullYear(x.getFullYear()+1));else{x.setDate(x.getDate()+J);break}}return he=new Date(x.getFullYear()+1,0,4),J=y(new Date(x.getFullYear(),0,4)),he=y(he),0>=A(J,x)?0>=A(he,x)?x.getFullYear()+1:x.getFullYear():x.getFullYear()-1}var T=W[l+40>>2];l={Hg:W[l>>2],Gg:W[l+4>>2],tf:W[l+8>>2],Df:W[l+12>>2],uf:W[l+16>>2],Ie:W[l+20>>2],Ae:W[l+24>>2],He:W[l+28>>2],Ng:W[l+32>>2],Fg:W[l+36>>2],Ig:T&&T?xt(fe,T):""},a=a?xt(fe,a):"",T={"%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 D in T)a=a.replace(new RegExp(D,"g"),T[D]);var z="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),Y="January February March April May June July August September October November December".split(" ");T={"%a":x=>z[x.Ae].substring(0,3),"%A":x=>z[x.Ae],"%b":x=>Y[x.uf].substring(0,3),"%B":x=>Y[x.uf],"%C":x=>g((x.Ie+1900)/100|0,2),"%d":x=>g(x.Df,2),"%e":x=>d(x.Df,2," "),"%g":x=>v(x).toString().substring(2),"%G":x=>v(x),"%H":x=>g(x.tf,2),"%I":x=>(x=x.tf,x==0?x=12:12<x&&(x-=12),g(x,2)),"%j":x=>{for(var J=0,he=0;he<=x.uf-1;J+=(Ri(x.Ie+1900)?yr:vr)[he++]);return g(x.Df+J,3)},"%m":x=>g(x.uf+1,2),"%M":x=>g(x.Gg,2),"%n":()=>`
3
+ `,"%p":x=>0<=x.tf&&12>x.tf?"AM":"PM","%S":x=>g(x.Hg,2),"%t":()=>" ","%u":x=>x.Ae||7,"%U":x=>g(Math.floor((x.He+7-x.Ae)/7),2),"%V":x=>{var J=Math.floor((x.He+7-(x.Ae+6)%7)/7);if(2>=(x.Ae+371-x.He-2)%7&&J++,J)J==53&&(he=(x.Ae+371-x.He)%7,he==4||he==3&&Ri(x.Ie)||(J=1));else{J=52;var he=(x.Ae+7-x.He-1)%7;(he==4||he==5&&Ri(x.Ie%400-1))&&J++}return g(J,2)},"%w":x=>x.Ae,"%W":x=>g(Math.floor((x.He+7-(x.Ae+6)%7)/7),2),"%y":x=>(x.Ie+1900).toString().substring(2),"%Y":x=>x.Ie+1900,"%z":x=>{x=x.Fg;var J=0<=x;return x=Math.abs(x)/60,(J?"+":"-")+("0000"+(x/60*100+x%60)).slice(-4)},"%Z":x=>x.Ig,"%%":()=>"%"},a=a.replace(/%%/g,"\0\0");for(D in T)a.includes(D)&&(a=a.replace(new RegExp(D,"g"),T[D](l)));return a=a.replace(/\0\0/g,"%"),D=za(a),D.length>n?0:(pt.set(D,t),D.length-1)};On=c.InternalError=class extends Error{constructor(t){super(t),this.name="InternalError"}};for(var wr=Array(256),ki=0;256>ki;++ki)wr[ki]=String.fromCharCode(ki);Dn=wr,Gt=c.BindingError=class extends Error{constructor(t){super(t),this.name="BindingError"}},Ct.prototype.isAliasOf=function(t){if(!(this instanceof Ct&&t instanceof Ct))return!1;var n=this.ae.me.ge,a=this.ae.ie,l=t.ae.me.ge;for(t=t.ae.ie;n.re;)a=n.gf(a),n=n.re;for(;l.re;)t=l.gf(t),l=l.re;return n===l&&a===t},Ct.prototype.clone=function(){if(this.ae.ie||Ki(this),this.ae.ef)return this.ae.count.value+=1,this;var t=ei,n=Object,a=n.create,l=Object.getPrototypeOf(this),d=this.ae;return t=t(a.call(n,l,{ae:{value:{count:d.count,Xe:d.Xe,ef:d.ef,ie:d.ie,me:d.me,pe:d.pe,we:d.we}}})),t.ae.count.value+=1,t.ae.Xe=!1,t},Ct.prototype.delete=function(){this.ae.ie||Ki(this),this.ae.Xe&&!this.ae.ef&&we("Object already scheduled for deletion"),Ln(this),zn(this.ae),this.ae.ef||(this.ae.pe=void 0,this.ae.ie=void 0)},Ct.prototype.isDeleted=function(){return!this.ae.ie},Ct.prototype.deleteLater=function(){return this.ae.ie||Ki(this),this.ae.Xe&&!this.ae.ef&&we("Object already scheduled for deletion"),Jt.push(this),Jt.length===1&&Qt&&Qt(qi),this.ae.Xe=!0,this},c.getInheritedInstanceCount=function(){return Object.keys(Zt).length},c.getLiveInheritedInstances=function(){var t=[],n;for(n in Zt)Zt.hasOwnProperty(n)&&t.push(Zt[n]);return t},c.flushPendingDeletes=qi,c.setDelayFunction=function(t){Qt=t,Jt.length&&Qt&&Qt(qi)},mt.prototype.jg=function(t){return this.Nf&&(t=this.Nf(t)),t},mt.prototype.Hf=function(t){this.De&&this.De(t)},mt.prototype.argPackAdvance=8,mt.prototype.readValueFromPointer=Xt,mt.prototype.deleteObject=function(t){t!==null&&t.delete()},mt.prototype.fromWireType=function(t){function n(){return this.pf?Si(this.ge.Ye,{me:this.tg,ie:a,we:this,pe:t}):Si(this.ge.Ye,{me:this,ie:t})}var a=this.jg(t);if(!a)return this.Hf(t),null;var l=da(this.ge,a);if(l!==void 0)return l.ae.count.value===0?(l.ae.ie=a,l.ae.pe=t,l.clone()):(l=l.clone(),this.Hf(t),l);if(l=this.ge.ig(a),l=Un[l],!l)return n.call(this);l=this.nf?l.$f:l.pointerType;var d=Bn(a,this.ge,l.ge);return d===null?n.call(this):this.pf?Si(l.ge.Ye,{me:l,ie:d,we:this,pe:t}):Si(l.ge.Ye,{me:l,ie:d})},Wn=c.UnboundTypeError=function(t,n){var a=Yi(n,function(l){this.name=n,this.message=l,l=Error(l).stack,l!==void 0&&(this.stack=this.toString()+`
4
+ `+l.replace(/^Error(:[^\n]*)?\n/,""))});return a.prototype=Object.create(t.prototype),a.prototype.constructor=a,a.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},a}(Error,"UnboundTypeError"),Object.assign(Hn.prototype,{get(t){return this.Ce[t]},has(t){return this.Ce[t]!==void 0},Yf(t){var n=this.Kf.pop()||this.Ce.length;return this.Ce[n]=t,n},Zf(t){this.Ce[t]=void 0,this.Kf.push(t)}}),Qe.Ce.push({value:void 0},{value:null},{value:!0},{value:!1}),Qe.df=Qe.Ce.length,c.count_emval_handles=function(){for(var t=0,n=Qe.df;n<Qe.Ce.length;++n)Qe.Ce[n]!==void 0&&++t;return t};for(var _,Ye=0;32>Ye;++Ye)xi.push(Array(Ye));var Ua=new Float32Array(288);for(Ye=0;288>Ye;++Ye)Tt[Ye]=Ua.subarray(0,Ye+1);var $a=new Int32Array(288);for(Ye=0;288>Ye;++Ye)ai[Ye]=$a.subarray(0,Ye+1);var Ga={R:function(){return 0},wb:()=>{},yb:function(){return 0},tb:()=>{},ub:()=>{},S:function(){},vb:()=>{},B:function(t){var n=mi[t];delete mi[t];var a=n.Cf,l=n.De,d=n.Jf,g=d.map(A=>A.mg).concat(d.map(A=>A.xg));st([t],g,A=>{var y={};return d.forEach((v,T)=>{var D=A[T],z=v.kg,Y=v.lg,x=A[T+d.length],J=v.wg,he=v.yg;y[v.fg]={read:oe=>D.fromWireType(z(Y,oe)),write:(oe,He)=>{var ze=[];J(he,oe,x.toWireType(ze,He)),Hi(ze)}}}),[{name:n.name,fromWireType:function(v){var T={},D;for(D in y)T[D]=y[D].read(v);return l(v),T},toWireType:function(v,T){for(var D in y)if(!(D in T))throw new TypeError(`Missing field: "${D}"`);var z=a();for(D in y)y[D].write(z,T[D]);return v!==null&&v.push(l,z),z},argPackAdvance:8,readValueFromPointer:Xt,ve:l}]})},nb:function(){},Cb:function(t,n,a,l,d){var g=wi(a);n=xe(n),gt(t,{name:n,fromWireType:function(A){return!!A},toWireType:function(A,y){return y?l:d},argPackAdvance:8,readValueFromPointer:function(A){if(a===1)var y=pt;else if(a===2)y=At;else if(a===4)y=W;else throw new TypeError("Unknown boolean type size: "+n);return this.fromWireType(y[A>>g])},ve:null})},n:function(t,n,a,l,d,g,A,y,v,T,D,z,Y){D=xe(D),g=Ue(d,g),y&&(y=Ue(A,y)),T&&(T=Ue(v,T)),Y=Ue(z,Y);var x=$n(D);Ji(x,function(){ti(`Cannot construct ${D} due to unbound types`,[l])}),st([t,n,a],l?[l]:[],function(J){if(J=J[0],l)var he=J.ge,oe=he.Ye;else oe=Ct.prototype;J=Yi(x,function(){if(Object.getPrototypeOf(this)!==He)throw new Gt("Use 'new' to construct "+D);if(ze.Ge===void 0)throw new Gt(D+" has no accessible constructor");var oi=ze.Ge[arguments.length];if(oi===void 0)throw new Gt(`Tried to invoke ctor of ${D} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(ze.Ge).toString()}) parameters instead!`);return oi.apply(this,arguments)});var He=Object.create(oe,{constructor:{value:J}});J.prototype=He;var ze=new fa(D,J,He,Y,he,g,y,T);ze.re&&(ze.re.hf===void 0&&(ze.re.hf=[]),ze.re.hf.push(ze)),he=new mt(D,ze,!0,!1,!1),oe=new mt(D+"*",ze,!1,!1,!1);var si=new mt(D+" const*",ze,!1,!0,!1);return Un[t]={pointerType:oe,$f:si},Gn(x,J),[he,oe,si]})},f:function(t,n,a,l,d,g,A){var y=Pi(a,l);n=xe(n),g=Ue(d,g),st([],[t],function(v){function T(){ti(`Cannot call ${D} due to unbound types`,y)}v=v[0];var D=`${v.name}.${n}`;n.startsWith("@@")&&(n=Symbol[n.substring(2)]);var z=v.ge.constructor;return z[n]===void 0?(T.Ve=a-1,z[n]=T):(Xi(z,n,D),z[n].oe[a-1]=T),st([],y,function(Y){if(Y=[Y[0],null].concat(Y.slice(1)),Y=bi(D,Y,null,g,A),z[n].oe===void 0?(Y.Ve=a-1,z[n]=Y):z[n].oe[a-1]=Y,v.ge.hf)for(const x of v.ge.hf)x.constructor.hasOwnProperty(n)||(x.constructor[n]=Y);return[]}),[]})},A:function(t,n,a,l,d,g){var A=Pi(n,a);d=Ue(l,d),st([],[t],function(y){y=y[0];var v=`constructor ${y.name}`;if(y.ge.Ge===void 0&&(y.ge.Ge=[]),y.ge.Ge[n-1]!==void 0)throw new Gt(`Cannot register multiple constructors with identical number of parameters (${n-1}) for class '${y.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return y.ge.Ge[n-1]=()=>{ti(`Cannot construct ${y.name} due to unbound types`,A)},st([],A,function(T){return T.splice(1,0,null),y.ge.Ge[n-1]=bi(v,T,null,d,g),[]}),[]})},b:function(t,n,a,l,d,g,A,y){var v=Pi(a,l);n=xe(n),g=Ue(d,g),st([],[t],function(T){function D(){ti(`Cannot call ${z} due to unbound types`,v)}T=T[0];var z=`${T.name}.${n}`;n.startsWith("@@")&&(n=Symbol[n.substring(2)]),y&&T.ge.ug.push(n);var Y=T.ge.Ye,x=Y[n];return x===void 0||x.oe===void 0&&x.className!==T.name&&x.Ve===a-2?(D.Ve=a-2,D.className=T.name,Y[n]=D):(Xi(Y,n,z),Y[n].oe[a-2]=D),st([],v,function(J){return J=bi(z,J,T,g,A),Y[n].oe===void 0?(J.Ve=a-2,Y[n]=J):Y[n].oe[a-2]=J,[]}),[]})},t:function(t,n,a){t=xe(t),st([],[n],function(l){return l=l[0],c[t]=l.fromWireType(a),[]})},Bb:function(t,n){n=xe(n),gt(t,{name:n,fromWireType:function(a){var l=Ze(a);return Zi(a),l},toWireType:function(a,l){return et(l)},argPackAdvance:8,readValueFromPointer:Xt,ve:null})},m:function(t,n,a,l){function d(){}a=wi(a),n=xe(n),d.values={},gt(t,{name:n,constructor:d,fromWireType:function(g){return this.constructor.values[g]},toWireType:function(g,A){return A.value},argPackAdvance:8,readValueFromPointer:va(n,a,l),ve:null}),Ji(n,d)},c:function(t,n,a){var l=ii(t,"enum");n=xe(n),t=l.constructor,l=Object.create(l.constructor.prototype,{value:{value:a},constructor:{value:Yi(`${l.name}_${n}`,function(){})}}),t.values[a]=l,t[n]=l},U:function(t,n,a){a=wi(a),n=xe(n),gt(t,{name:n,fromWireType:function(l){return l},toWireType:function(l,d){return d},argPackAdvance:8,readValueFromPointer:wa(n,a),ve:null})},y:function(t,n,a,l,d,g){var A=Pi(n,a);t=xe(t),d=Ue(l,d),Ji(t,function(){ti(`Cannot call ${t} due to unbound types`,A)},n-1),st([],A,function(y){return y=[y[0],null].concat(y.slice(1)),Gn(t,bi(t,y,null,d,g),n-1),[]})},E:function(t,n,a,l,d){n=xe(n),d===-1&&(d=4294967295),d=wi(a);var g=y=>y;if(l===0){var A=32-8*a;g=y=>y<<A>>>A}a=n.includes("unsigned")?function(y,v){return v>>>0}:function(y,v){return v},gt(t,{name:n,fromWireType:g,toWireType:a,argPackAdvance:8,readValueFromPointer:Sa(n,d,l!==0),ve:null})},r:function(t,n,a){function l(g){g>>=2;var A=_e;return new d(A.buffer,A[g+1],A[g])}var d=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][n];a=xe(a),gt(t,{name:a,fromWireType:l,argPackAdvance:8,readValueFromPointer:l},{ng:!0})},q:function(t,n,a,l,d,g,A,y,v,T,D,z){a=xe(a),g=Ue(d,g),y=Ue(A,y),T=Ue(v,T),z=Ue(D,z),st([t],[n],function(Y){return Y=Y[0],[new mt(a,Y.ge,!1,!1,!0,Y,l,g,y,T,z)]})},T:function(t,n){n=xe(n);var a=n==="std::string";gt(t,{name:n,fromWireType:function(l){var d=_e[l>>2],g=l+4;if(a)for(var A=g,y=0;y<=d;++y){var v=g+y;if(y==d||fe[v]==0){if(A=A?xt(fe,A,v-A):"",T===void 0)var T=A;else T+="\0",T+=A;A=v+1}}else{for(T=Array(d),y=0;y<d;++y)T[y]=String.fromCharCode(fe[g+y]);T=T.join("")}return wt(l),T},toWireType:function(l,d){d instanceof ArrayBuffer&&(d=new Uint8Array(d));var g=typeof d=="string";g||d instanceof Uint8Array||d instanceof Uint8ClampedArray||d instanceof Int8Array||we("Cannot pass non-string to std::string");var A=a&&g?lt(d):d.length,y=Ni(4+A+1),v=y+4;if(_e[y>>2]=A,a&&g)ot(d,fe,v,A+1);else if(g)for(g=0;g<A;++g){var T=d.charCodeAt(g);255<T&&(wt(v),we("String has UTF-16 code units that do not fit in 8 bits")),fe[v+g]=T}else for(g=0;g<A;++g)fe[v+g]=d[g];return l!==null&&l.push(wt,y),y},argPackAdvance:8,readValueFromPointer:Xt,ve:function(l){wt(l)}})},N:function(t,n,a){if(a=xe(a),n===2)var l=ba,d=Pa,g=Aa,A=()=>Bt,y=1;else n===4&&(l=Ca,d=Ta,g=_a,A=()=>_e,y=2);gt(t,{name:a,fromWireType:function(v){for(var T=_e[v>>2],D=A(),z,Y=v+4,x=0;x<=T;++x){var J=v+4+x*n;(x==T||D[J>>y]==0)&&(Y=l(Y,J-Y),z===void 0?z=Y:(z+="\0",z+=Y),Y=J+n)}return wt(v),z},toWireType:function(v,T){typeof T!="string"&&we(`Cannot pass non-string to C++ string type ${a}`);var D=g(T),z=Ni(4+D+n);return _e[z>>2]=D>>y,d(T,z+4,D+n),v!==null&&v.push(wt,z),z},argPackAdvance:8,readValueFromPointer:Xt,ve:function(v){wt(v)}})},C:function(t,n,a,l,d,g){mi[t]={name:xe(n),Cf:Ue(a,l),De:Ue(d,g),Jf:[]}},e:function(t,n,a,l,d,g,A,y,v,T){mi[t].Jf.push({fg:xe(n),mg:a,kg:Ue(l,d),lg:g,xg:A,wg:Ue(y,v),yg:T})},Db:function(t,n){n=xe(n),gt(t,{pg:!0,name:n,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},Ab:()=>!0,pb:()=>{throw 1/0},F:function(t,n,a){t=Ze(t),n=ii(n,"emval::as");var l=[],d=et(l);return _e[a>>2]=d,n.toWireType(l,t)},X:function(t,n,a,l,d){t=Ci[t],n=Ze(n),a=Ai(a);var g=[];return _e[l>>2]=et(g),t(n,a,g,d)},x:function(t,n,a,l){t=Ci[t],n=Ze(n),a=Ai(a),t(n,a,null,l)},d:Zi,K:function(t){return t===0?et(Vn()):(t=Ai(t),et(Vn()[t]))},u:function(t,n){var a=xa(t,n),l=a[0];n=l.name+"_$"+a.slice(1).map(function(A){return A.name}).join("_")+"$";var d=qn[n];if(d!==void 0)return d;var g=Array(t-1);return d=Ma((A,y,v,T)=>{for(var D=0,z=0;z<t-1;++z)g[z]=a[z+1].readValueFromPointer(T+D),D+=a[z+1].argPackAdvance;for(A=A[y].apply(A,g),z=0;z<t-1;++z)a[z+1].cg&&a[z+1].cg(g[z]);if(!l.pg)return l.toWireType(v,A)}),qn[n]=d},z:function(t,n){return t=Ze(t),n=Ze(n),et(t[n])},p:function(t){4<t&&(Qe.get(t).Of+=1)},J:function(t,n,a,l){t=Ze(t);var d=Yn[n];return d||(d=Fa(n),Yn[n]=d),d(t,a,l)},H:function(){return et([])},g:function(t){return et(Ai(t))},G:function(){return et({})},gb:function(t){return t=Ze(t),!t},D:function(t){var n=Ze(t);Hi(n),Zi(t)},l:function(t,n,a){t=Ze(t),n=Ze(n),a=Ze(a),t[n]=a},h:function(t,n){return t=ii(t,"_emval_take_value"),t=t.readValueFromPointer(n),et(t)},kb:function(){return-52},lb:function(){},a:()=>{Wi("")},zb:()=>performance.now(),sd:function(t){_.activeTexture(t)},td:function(t,n){_.attachShader(ht[t],ct[n])},Yb:function(t,n){_.beginQuery(t,qe[n])},Sb:function(t,n){_.ze.beginQueryEXT(t,qe[n])},ud:function(t,n,a){_.bindAttribLocation(ht[t],n,a?xt(fe,a):"")},vd:function(t,n){t==35051?_.zf=n:t==35052&&(_.We=n),_.bindBuffer(t,Ti[n])},uc:tr,vc:function(t,n){_.bindRenderbuffer(t,ni[n])},cc:function(t,n){_.bindSampler(t,Rt[n])},wd:function(t,n){_.bindTexture(t,tt[n])},Pc:ir,Tc:ir,Y:function(t,n,a,l){_.blendColor(t,n,a,l)},Z:function(t){_.blendEquation(t)},_:function(t,n){_.blendFunc(t,n)},oc:function(t,n,a,l,d,g,A,y,v,T){_.blitFramebuffer(t,n,a,l,d,g,A,y,v,T)},$:function(t,n,a,l){2<=se.version?a&&n?_.bufferData(t,fe,l,a,n):_.bufferData(t,n,l):_.bufferData(t,a?fe.subarray(a,a+n):n,l)},aa:function(t,n,a,l){2<=se.version?a&&_.bufferSubData(t,n,fe,l,a):_.bufferSubData(t,n,fe.subarray(l,l+a))},wc:function(t){return _.checkFramebufferStatus(t)},ba:nr,ca:rr,da:ar,lc:function(t,n,a,l){return _.clientWaitSync(kt[t],n,(a>>>0)+4294967296*l)},ea:function(t,n,a,l){_.colorMask(!!t,!!n,!!a,!!l)},fa:function(t){_.compileShader(ct[t])},ga:function(t,n,a,l,d,g,A,y){2<=se.version?_.We||!A?_.compressedTexImage2D(t,n,a,l,d,g,A,y):_.compressedTexImage2D(t,n,a,l,d,g,fe,y,A):_.compressedTexImage2D(t,n,a,l,d,g,y?fe.subarray(y,y+A):null)},ha:function(t,n,a,l,d,g,A,y,v){2<=se.version?_.We||!y?_.compressedTexSubImage2D(t,n,a,l,d,g,A,y,v):_.compressedTexSubImage2D(t,n,a,l,d,g,A,fe,v,y):_.compressedTexSubImage2D(t,n,a,l,d,g,A,v?fe.subarray(v,v+y):null)},nc:function(t,n,a,l,d){_.copyBufferSubData(t,n,a,l,d)},ia:function(t,n,a,l,d,g,A,y){_.copyTexSubImage2D(t,n,a,l,d,g,A,y)},ja:function(){var t=Nt(ht),n=_.createProgram();return n.name=t,n.sf=n.qf=n.rf=0,n.Ef=1,ht[t]=n,t},ka:function(t){var n=Nt(ct);return ct[n]=_.createShader(t),n},la:function(t){_.cullFace(t)},ma:function(t,n){for(var a=0;a<t;a++){var l=W[n+4*a>>2],d=Ti[l];d&&(_.deleteBuffer(d),d.name=0,Ti[l]=null,l==_.zf&&(_.zf=0),l==_.We&&(_.We=0))}},xc:function(t,n){for(var a=0;a<t;++a){var l=W[n+4*a>>2],d=_i[l];d&&(_.deleteFramebuffer(d),d.name=0,_i[l]=null)}},na:function(t){if(t){var n=ht[t];n?(_.deleteProgram(n),n.name=0,ht[t]=null):Se(1281)}},Zb:function(t,n){for(var a=0;a<t;a++){var l=W[n+4*a>>2],d=qe[l];d&&(_.deleteQuery(d),qe[l]=null)}},Tb:function(t,n){for(var a=0;a<t;a++){var l=W[n+4*a>>2],d=qe[l];d&&(_.ze.deleteQueryEXT(d),qe[l]=null)}},yc:function(t,n){for(var a=0;a<t;a++){var l=W[n+4*a>>2],d=ni[l];d&&(_.deleteRenderbuffer(d),d.name=0,ni[l]=null)}},dc:function(t,n){for(var a=0;a<t;a++){var l=W[n+4*a>>2],d=Rt[l];d&&(_.deleteSampler(d),d.name=0,Rt[l]=null)}},oa:function(t){if(t){var n=ct[t];n?(_.deleteShader(n),ct[t]=null):Se(1281)}},mc:function(t){if(t){var n=kt[t];n?(_.deleteSync(n),n.name=0,kt[t]=null):Se(1281)}},pa:function(t,n){for(var a=0;a<t;a++){var l=W[n+4*a>>2],d=tt[l];d&&(_.deleteTexture(d),d.name=0,tt[l]=null)}},Qc:sr,Uc:sr,qa:function(t){_.depthMask(!!t)},ra:function(t){_.disable(t)},sa:function(t){_.disableVertexAttribArray(t)},ta:function(t,n,a){_.drawArrays(t,n,a)},Nc:function(t,n,a,l){_.drawArraysInstanced(t,n,a,l)},Lc:function(t,n,a,l,d){_.If.drawArraysInstancedBaseInstanceWEBGL(t,n,a,l,d)},Jc:function(t,n){for(var a=xi[t],l=0;l<t;l++)a[l]=W[n+4*l>>2];_.drawBuffers(a)},ua:or,Oc:function(t,n,a,l,d){_.drawElementsInstanced(t,n,a,l,d)},Mc:function(t,n,a,l,d,g,A){_.If.drawElementsInstancedBaseVertexBaseInstanceWEBGL(t,n,a,l,d,g,A)},Dc:function(t,n,a,l,d,g){or(t,l,d,g)},va:function(t){_.enable(t)},wa:function(t){_.enableVertexAttribArray(t)},_b:function(t){_.endQuery(t)},Ub:function(t){_.ze.endQueryEXT(t)},ic:function(t,n){return(t=_.fenceSync(t,n))?(n=Nt(kt),t.name=n,kt[n]=t,n):0},xa:function(){_.finish()},ya:function(){_.flush()},zc:function(t,n,a,l){_.framebufferRenderbuffer(t,n,a,ni[l])},Ac:function(t,n,a,l,d){_.framebufferTexture2D(t,n,a,tt[l],d)},za:function(t){_.frontFace(t)},Aa:function(t,n){It(t,n,"createBuffer",Ti)},Bc:function(t,n){It(t,n,"createFramebuffer",_i)},$b:function(t,n){It(t,n,"createQuery",qe)},Vb:function(t,n){for(var a=0;a<t;a++){var l=_.ze.createQueryEXT();if(!l){for(Se(1282);a<t;)W[n+4*a++>>2]=0;break}var d=Nt(qe);l.name=d,qe[d]=l,W[n+4*a>>2]=d}},Cc:function(t,n){It(t,n,"createRenderbuffer",ni)},ec:function(t,n){It(t,n,"createSampler",Rt)},Ba:function(t,n){It(t,n,"createTexture",tt)},Rc:lr,Vc:lr,qc:function(t){_.generateMipmap(t)},Ca:function(t,n,a){a?W[a>>2]=_.getBufferParameter(t,n):Se(1281)},Da:function(){var t=_.getError()||Mi;return Mi=0,t},Ea:function(t,n){cr(t,n,2)},rc:function(t,n,a,l){t=_.getFramebufferAttachmentParameter(t,n,a),(t instanceof WebGLRenderbuffer||t instanceof WebGLTexture)&&(t=t.name|0),W[l>>2]=t},Fa:ur,Ga:function(t,n,a,l){t=_.getProgramInfoLog(ht[t]),t===null&&(t="(unknown error)"),n=0<n&&l?ot(t,fe,l,n):0,a&&(W[a>>2]=n)},Ha:function(t,n,a){if(a)if(t>=Xn)Se(1281);else if(t=ht[t],n==35716)t=_.getProgramInfoLog(t),t===null&&(t="(unknown error)"),W[a>>2]=t.length+1;else if(n==35719){if(!t.sf)for(n=0;n<_.getProgramParameter(t,35718);++n)t.sf=Math.max(t.sf,_.getActiveUniform(t,n).name.length+1);W[a>>2]=t.sf}else if(n==35722){if(!t.qf)for(n=0;n<_.getProgramParameter(t,35721);++n)t.qf=Math.max(t.qf,_.getActiveAttrib(t,n).name.length+1);W[a>>2]=t.qf}else if(n==35381){if(!t.rf)for(n=0;n<_.getProgramParameter(t,35382);++n)t.rf=Math.max(t.rf,_.getActiveUniformBlockName(t,n).length+1);W[a>>2]=t.rf}else W[a>>2]=_.getProgramParameter(t,n);else Se(1281)},Pb:dr,Qb:dr,ac:function(t,n,a){if(a){t=_.getQueryParameter(qe[t],n);var l;typeof t=="boolean"?l=t?1:0:l=t,W[a>>2]=l}else Se(1281)},Wb:function(t,n,a){if(a){t=_.ze.getQueryObjectEXT(qe[t],n);var l;typeof t=="boolean"?l=t?1:0:l=t,W[a>>2]=l}else Se(1281)},bc:function(t,n,a){a?W[a>>2]=_.getQuery(t,n):Se(1281)},Xb:function(t,n,a){a?W[a>>2]=_.ze.getQueryEXT(t,n):Se(1281)},sc:function(t,n,a){a?W[a>>2]=_.getRenderbufferParameter(t,n):Se(1281)},Ia:function(t,n,a,l){t=_.getShaderInfoLog(ct[t]),t===null&&(t="(unknown error)"),n=0<n&&l?ot(t,fe,l,n):0,a&&(W[a>>2]=n)},Mb:function(t,n,a,l){t=_.getShaderPrecisionFormat(t,n),W[a>>2]=t.rangeMin,W[a+4>>2]=t.rangeMax,W[l>>2]=t.precision},Ja:function(t,n,a){a?n==35716?(t=_.getShaderInfoLog(ct[t]),t===null&&(t="(unknown error)"),W[a>>2]=t?t.length+1:0):n==35720?(t=_.getShaderSource(ct[t]),W[a>>2]=t?t.length+1:0):W[a>>2]=_.getShaderParameter(ct[t],n):Se(1281)},Ka:fr,Sc:pr,La:function(t,n){if(n=n?xt(fe,n):"",t=ht[t]){var a=t,l=a.ff,d=a.Qf,g;if(!l)for(a.ff=l={},a.Pf={},g=0;g<_.getProgramParameter(a,35718);++g){var A=_.getActiveUniform(a,g),y=A.name;A=A.size;var v=gr(y);v=0<v?y.slice(0,v):y;var T=a.Ef;for(a.Ef+=A,d[v]=[A,T],y=0;y<A;++y)l[T]=y,a.Pf[T++]=v}if(a=t.ff,l=0,d=n,g=gr(n),0<g&&(l=parseInt(n.slice(g+1))>>>0,d=n.slice(0,g)),(d=t.Qf[d])&&l<d[0]&&(l+=d[1],a[l]=a[l]||_.getUniformLocation(t,n)))return l}else Se(1281);return-1},Nb:function(t,n,a){for(var l=xi[n],d=0;d<n;d++)l[d]=W[a+4*d>>2];_.invalidateFramebuffer(t,l)},Ob:function(t,n,a,l,d,g,A){for(var y=xi[n],v=0;v<n;v++)y[v]=W[a+4*v>>2];_.invalidateSubFramebuffer(t,y,l,d,g,A)},jc:function(t){return _.isSync(kt[t])},Ma:function(t){return(t=tt[t])?_.isTexture(t):0},Na:function(t){_.lineWidth(t)},Oa:function(t){t=ht[t],_.linkProgram(t),t.ff=0,t.Qf={}},Hc:function(t,n,a,l,d,g){_.Mf.multiDrawArraysInstancedBaseInstanceWEBGL(t,W,n>>2,W,a>>2,W,l>>2,_e,d>>2,g)},Ic:function(t,n,a,l,d,g,A,y){_.Mf.multiDrawElementsInstancedBaseVertexBaseInstanceWEBGL(t,W,n>>2,a,W,l>>2,W,d>>2,W,g>>2,_e,A>>2,y)},Pa:function(t,n){t==3317&&(Zn=n),_.pixelStorei(t,n)},Rb:function(t,n){_.ze.queryCounterEXT(qe[t],n)},Kc:function(t){_.readBuffer(t)},Qa:function(t,n,a,l,d,g,A){if(2<=se.version)if(_.zf)_.readPixels(t,n,a,l,d,g,A);else{var y=Fi(g);_.readPixels(t,n,a,l,d,g,y,A>>31-Math.clz32(y.BYTES_PER_ELEMENT))}else(A=tn(g,d,a,l,A))?_.readPixels(t,n,a,l,d,g,A):Se(1280)},tc:function(t,n,a,l){_.renderbufferStorage(t,n,a,l)},pc:function(t,n,a,l,d){_.renderbufferStorageMultisample(t,n,a,l,d)},fc:function(t,n,a){_.samplerParameterf(Rt[t],n,a)},gc:function(t,n,a){_.samplerParameteri(Rt[t],n,a)},hc:function(t,n,a){_.samplerParameteri(Rt[t],n,W[a>>2])},Ra:function(t,n,a,l){_.scissor(t,n,a,l)},Sa:function(t,n,a,l){for(var d="",g=0;g<n;++g){var A=l?W[l+4*g>>2]:-1,y=W[a+4*g>>2];A=y?xt(fe,y,0>A?void 0:A):"",d+=A}_.shaderSource(ct[t],d)},Ta:function(t,n,a){_.stencilFunc(t,n,a)},Ua:function(t,n,a,l){_.stencilFuncSeparate(t,n,a,l)},Va:function(t){_.stencilMask(t)},Wa:function(t,n){_.stencilMaskSeparate(t,n)},Xa:function(t,n,a){_.stencilOp(t,n,a)},Ya:function(t,n,a,l){_.stencilOpSeparate(t,n,a,l)},Za:function(t,n,a,l,d,g,A,y,v){if(2<=se.version)if(_.We)_.texImage2D(t,n,a,l,d,g,A,y,v);else if(v){var T=Fi(y);_.texImage2D(t,n,a,l,d,g,A,y,T,v>>31-Math.clz32(T.BYTES_PER_ELEMENT))}else _.texImage2D(t,n,a,l,d,g,A,y,null);else _.texImage2D(t,n,a,l,d,g,A,y,v?tn(y,A,l,d,v):null)},_a:function(t,n,a){_.texParameterf(t,n,a)},$a:function(t,n,a){_.texParameterf(t,n,ne[a>>2])},ab:function(t,n,a){_.texParameteri(t,n,a)},bb:function(t,n,a){_.texParameteri(t,n,W[a>>2])},Ec:function(t,n,a,l,d){_.texStorage2D(t,n,a,l,d)},cb:function(t,n,a,l,d,g,A,y,v){if(2<=se.version)if(_.We)_.texSubImage2D(t,n,a,l,d,g,A,y,v);else if(v){var T=Fi(y);_.texSubImage2D(t,n,a,l,d,g,A,y,T,v>>31-Math.clz32(T.BYTES_PER_ELEMENT))}else _.texSubImage2D(t,n,a,l,d,g,A,y,null);else T=null,v&&(T=tn(y,A,d,g,v)),_.texSubImage2D(t,n,a,l,d,g,A,y,T)},db:function(t,n){_.uniform1f(Ae(t),n)},eb:function(t,n,a){if(2<=se.version)n&&_.uniform1fv(Ae(t),ne,a>>2,n);else{if(288>=n)for(var l=Tt[n-1],d=0;d<n;++d)l[d]=ne[a+4*d>>2];else l=ne.subarray(a>>2,a+4*n>>2);_.uniform1fv(Ae(t),l)}},od:function(t,n){_.uniform1i(Ae(t),n)},pd:function(t,n,a){if(2<=se.version)n&&_.uniform1iv(Ae(t),W,a>>2,n);else{if(288>=n)for(var l=ai[n-1],d=0;d<n;++d)l[d]=W[a+4*d>>2];else l=W.subarray(a>>2,a+4*n>>2);_.uniform1iv(Ae(t),l)}},qd:function(t,n,a){_.uniform2f(Ae(t),n,a)},rd:function(t,n,a){if(2<=se.version)n&&_.uniform2fv(Ae(t),ne,a>>2,2*n);else{if(144>=n)for(var l=Tt[2*n-1],d=0;d<2*n;d+=2)l[d]=ne[a+4*d>>2],l[d+1]=ne[a+(4*d+4)>>2];else l=ne.subarray(a>>2,a+8*n>>2);_.uniform2fv(Ae(t),l)}},nd:function(t,n,a){_.uniform2i(Ae(t),n,a)},md:function(t,n,a){if(2<=se.version)n&&_.uniform2iv(Ae(t),W,a>>2,2*n);else{if(144>=n)for(var l=ai[2*n-1],d=0;d<2*n;d+=2)l[d]=W[a+4*d>>2],l[d+1]=W[a+(4*d+4)>>2];else l=W.subarray(a>>2,a+8*n>>2);_.uniform2iv(Ae(t),l)}},ld:function(t,n,a,l){_.uniform3f(Ae(t),n,a,l)},kd:function(t,n,a){if(2<=se.version)n&&_.uniform3fv(Ae(t),ne,a>>2,3*n);else{if(96>=n)for(var l=Tt[3*n-1],d=0;d<3*n;d+=3)l[d]=ne[a+4*d>>2],l[d+1]=ne[a+(4*d+4)>>2],l[d+2]=ne[a+(4*d+8)>>2];else l=ne.subarray(a>>2,a+12*n>>2);_.uniform3fv(Ae(t),l)}},jd:function(t,n,a,l){_.uniform3i(Ae(t),n,a,l)},id:function(t,n,a){if(2<=se.version)n&&_.uniform3iv(Ae(t),W,a>>2,3*n);else{if(96>=n)for(var l=ai[3*n-1],d=0;d<3*n;d+=3)l[d]=W[a+4*d>>2],l[d+1]=W[a+(4*d+4)>>2],l[d+2]=W[a+(4*d+8)>>2];else l=W.subarray(a>>2,a+12*n>>2);_.uniform3iv(Ae(t),l)}},hd:function(t,n,a,l,d){_.uniform4f(Ae(t),n,a,l,d)},gd:function(t,n,a){if(2<=se.version)n&&_.uniform4fv(Ae(t),ne,a>>2,4*n);else{if(72>=n){var l=Tt[4*n-1],d=ne;a>>=2;for(var g=0;g<4*n;g+=4){var A=a+g;l[g]=d[A],l[g+1]=d[A+1],l[g+2]=d[A+2],l[g+3]=d[A+3]}}else l=ne.subarray(a>>2,a+16*n>>2);_.uniform4fv(Ae(t),l)}},Wc:function(t,n,a,l,d){_.uniform4i(Ae(t),n,a,l,d)},Xc:function(t,n,a){if(2<=se.version)n&&_.uniform4iv(Ae(t),W,a>>2,4*n);else{if(72>=n)for(var l=ai[4*n-1],d=0;d<4*n;d+=4)l[d]=W[a+4*d>>2],l[d+1]=W[a+(4*d+4)>>2],l[d+2]=W[a+(4*d+8)>>2],l[d+3]=W[a+(4*d+12)>>2];else l=W.subarray(a>>2,a+16*n>>2);_.uniform4iv(Ae(t),l)}},Yc:function(t,n,a,l){if(2<=se.version)n&&_.uniformMatrix2fv(Ae(t),!!a,ne,l>>2,4*n);else{if(72>=n)for(var d=Tt[4*n-1],g=0;g<4*n;g+=4)d[g]=ne[l+4*g>>2],d[g+1]=ne[l+(4*g+4)>>2],d[g+2]=ne[l+(4*g+8)>>2],d[g+3]=ne[l+(4*g+12)>>2];else d=ne.subarray(l>>2,l+16*n>>2);_.uniformMatrix2fv(Ae(t),!!a,d)}},Zc:function(t,n,a,l){if(2<=se.version)n&&_.uniformMatrix3fv(Ae(t),!!a,ne,l>>2,9*n);else{if(32>=n)for(var d=Tt[9*n-1],g=0;g<9*n;g+=9)d[g]=ne[l+4*g>>2],d[g+1]=ne[l+(4*g+4)>>2],d[g+2]=ne[l+(4*g+8)>>2],d[g+3]=ne[l+(4*g+12)>>2],d[g+4]=ne[l+(4*g+16)>>2],d[g+5]=ne[l+(4*g+20)>>2],d[g+6]=ne[l+(4*g+24)>>2],d[g+7]=ne[l+(4*g+28)>>2],d[g+8]=ne[l+(4*g+32)>>2];else d=ne.subarray(l>>2,l+36*n>>2);_.uniformMatrix3fv(Ae(t),!!a,d)}},_c:function(t,n,a,l){if(2<=se.version)n&&_.uniformMatrix4fv(Ae(t),!!a,ne,l>>2,16*n);else{if(18>=n){var d=Tt[16*n-1],g=ne;l>>=2;for(var A=0;A<16*n;A+=16){var y=l+A;d[A]=g[y],d[A+1]=g[y+1],d[A+2]=g[y+2],d[A+3]=g[y+3],d[A+4]=g[y+4],d[A+5]=g[y+5],d[A+6]=g[y+6],d[A+7]=g[y+7],d[A+8]=g[y+8],d[A+9]=g[y+9],d[A+10]=g[y+10],d[A+11]=g[y+11],d[A+12]=g[y+12],d[A+13]=g[y+13],d[A+14]=g[y+14],d[A+15]=g[y+15]}}else d=ne.subarray(l>>2,l+64*n>>2);_.uniformMatrix4fv(Ae(t),!!a,d)}},$c:function(t){t=ht[t],_.useProgram(t),_.bg=t},ad:function(t,n){_.vertexAttrib1f(t,n)},bd:function(t,n){_.vertexAttrib2f(t,ne[n>>2],ne[n+4>>2])},cd:function(t,n){_.vertexAttrib3f(t,ne[n>>2],ne[n+4>>2],ne[n+8>>2])},dd:function(t,n){_.vertexAttrib4f(t,ne[n>>2],ne[n+4>>2],ne[n+8>>2],ne[n+12>>2])},Fc:function(t,n){_.vertexAttribDivisor(t,n)},Gc:function(t,n,a,l,d){_.vertexAttribIPointer(t,n,a,l,d)},ed:function(t,n,a,l,d,g){_.vertexAttribPointer(t,n,a,!!l,d,g)},fd:function(t,n,a,l){_.viewport(t,n,a,l)},kc:function(t,n,a,l){_.waitSync(kt[t],n,(a>>>0)+4294967296*l)},qb:t=>{var n=fe.length;if(t>>>=0,2147483648<t)return!1;for(var a=1;4>=a;a*=2){var l=n*(1+.2/a);l=Math.min(l,t+100663296);var d=Math;l=Math.max(t,l);e:{d=d.min.call(d,2147483648,l+(65536-l%65536)%65536)-gi.buffer.byteLength+65535>>>16;try{gi.grow(d),_n();var g=1;break e}catch{}g=void 0}if(g)return!0}return!1},hb:function(){return se?se.handle:0},rb:(t,n)=>{var a=0;return mr().forEach(function(l,d){var g=n+a;for(d=_e[t+4*d>>2]=g,g=0;g<l.length;++g)pt[d++>>0]=l.charCodeAt(g);pt[d>>0]=0,a+=l.length+1}),0},sb:(t,n)=>{var a=mr();_e[t>>2]=a.length;var l=0;return a.forEach(function(d){l+=d.length+1}),_e[n>>2]=l,0},Eb:t=>{K(t,new ca(t))},M:()=>52,jb:function(){return 52},xb:()=>52,mb:function(){return 70},Q:(t,n,a,l)=>{for(var d=0,g=0;g<a;g++){var A=_e[n>>2],y=_e[n+4>>2];n+=8;for(var v=0;v<y;v++){var T=fe[A+v],D=La[t];T===0||T===10?((t===1?ue:Pt)(xt(D,0)),D.length=0):D.push(T)}d+=y}return _e[l>>2]=d,0},yd:tr,ib:nr,xd:rr,Kb:ar,L:ur,P:fr,fb:pr,Ib:Za,j:qa,o:Ja,k:Wa,I:ns,Hb:es,Fb:as,W:ts,V:rs,O:Va,i:Xa,w:Ka,v:Ha,s:Ya,Gb:is,Jb:Qa,Lb:ja,ob:(t,n,a,l)=>Ba(t,n,a,l)};(function(){function t(a){if(Pe=a=a.exports,gi=Pe.zd,_n(),Fe=Pe.Cd,Mn.unshift(Pe.Ad),Mt--,c.monitorRunDependencies&&c.monitorRunDependencies(Mt),Mt==0&&Yt){var l=Yt;Yt=null,l()}return a}var n={a:Ga};if(Mt++,c.monitorRunDependencies&&c.monitorRunDependencies(Mt),c.instantiateWasm)try{return c.instantiateWasm(n,t)}catch(a){Pt("Module.instantiateWasm callback failed with error: "+a),E(a)}return ha(n,function(a){t(a.instance)}).catch(E),{}})();var Ni=c._malloc=t=>(Ni=c._malloc=Pe.Bd)(t),wt=c._free=t=>(wt=c._free=Pe.Dd)(t),Sr=t=>(Sr=Pe.Ed)(t);c.__embind_initialize_bindings=()=>(c.__embind_initialize_bindings=Pe.Fd)();var Ie=(t,n)=>(Ie=Pe.Gd)(t,n),Oe=()=>(Oe=Pe.Hd)(),De=t=>(De=Pe.Id)(t);c.dynCall_viji=(t,n,a,l,d)=>(c.dynCall_viji=Pe.Jd)(t,n,a,l,d),c.dynCall_vijiii=(t,n,a,l,d,g,A)=>(c.dynCall_vijiii=Pe.Kd)(t,n,a,l,d,g,A),c.dynCall_viiiiij=(t,n,a,l,d,g,A,y)=>(c.dynCall_viiiiij=Pe.Ld)(t,n,a,l,d,g,A,y),c.dynCall_jii=(t,n,a)=>(c.dynCall_jii=Pe.Md)(t,n,a),c.dynCall_vij=(t,n,a,l)=>(c.dynCall_vij=Pe.Nd)(t,n,a,l),c.dynCall_jiiiiii=(t,n,a,l,d,g,A)=>(c.dynCall_jiiiiii=Pe.Od)(t,n,a,l,d,g,A),c.dynCall_jiiiiji=(t,n,a,l,d,g,A,y)=>(c.dynCall_jiiiiji=Pe.Pd)(t,n,a,l,d,g,A,y),c.dynCall_ji=(t,n)=>(c.dynCall_ji=Pe.Qd)(t,n),c.dynCall_iijj=(t,n,a,l,d,g)=>(c.dynCall_iijj=Pe.Rd)(t,n,a,l,d,g),c.dynCall_iiiji=(t,n,a,l,d,g)=>(c.dynCall_iiiji=Pe.Sd)(t,n,a,l,d,g),c.dynCall_iiji=(t,n,a,l,d)=>(c.dynCall_iiji=Pe.Td)(t,n,a,l,d),c.dynCall_iijjiii=(t,n,a,l,d,g,A,y,v)=>(c.dynCall_iijjiii=Pe.Ud)(t,n,a,l,d,g,A,y,v),c.dynCall_iij=(t,n,a,l)=>(c.dynCall_iij=Pe.Vd)(t,n,a,l),c.dynCall_vijjjii=(t,n,a,l,d,g,A,y,v,T)=>(c.dynCall_vijjjii=Pe.Wd)(t,n,a,l,d,g,A,y,v,T),c.dynCall_jiji=(t,n,a,l,d)=>(c.dynCall_jiji=Pe.Xd)(t,n,a,l,d),c.dynCall_viijii=(t,n,a,l,d,g,A)=>(c.dynCall_viijii=Pe.Yd)(t,n,a,l,d,g,A),c.dynCall_iiiiij=(t,n,a,l,d,g,A)=>(c.dynCall_iiiiij=Pe.Zd)(t,n,a,l,d,g,A),c.dynCall_iiiiijj=(t,n,a,l,d,g,A,y,v)=>(c.dynCall_iiiiijj=Pe._d)(t,n,a,l,d,g,A,y,v),c.dynCall_iiiiiijj=(t,n,a,l,d,g,A,y,v,T)=>(c.dynCall_iiiiiijj=Pe.$d)(t,n,a,l,d,g,A,y,v,T);function Wa(t,n,a,l){var d=Oe();try{return Fe.get(t)(n,a,l)}catch(g){if(De(d),g!==g+0)throw g;Ie(1,0)}}function ja(t,n,a,l,d,g,A,y,v,T){var D=Oe();try{Fe.get(t)(n,a,l,d,g,A,y,v,T)}catch(z){if(De(D),z!==z+0)throw z;Ie(1,0)}}function Ha(t,n,a,l){var d=Oe();try{Fe.get(t)(n,a,l)}catch(g){if(De(d),g!==g+0)throw g;Ie(1,0)}}function Ka(t,n,a){var l=Oe();try{Fe.get(t)(n,a)}catch(d){if(De(l),d!==d+0)throw d;Ie(1,0)}}function Va(t){var n=Oe();try{Fe.get(t)()}catch(a){if(De(n),a!==a+0)throw a;Ie(1,0)}}function qa(t,n){var a=Oe();try{return Fe.get(t)(n)}catch(l){if(De(a),l!==l+0)throw l;Ie(1,0)}}function Ya(t,n,a,l,d){var g=Oe();try{Fe.get(t)(n,a,l,d)}catch(A){if(De(g),A!==A+0)throw A;Ie(1,0)}}function Xa(t,n){var a=Oe();try{Fe.get(t)(n)}catch(l){if(De(a),l!==l+0)throw l;Ie(1,0)}}function Ja(t,n,a){var l=Oe();try{return Fe.get(t)(n,a)}catch(d){if(De(l),d!==d+0)throw d;Ie(1,0)}}function Qa(t,n,a,l,d,g,A){var y=Oe();try{Fe.get(t)(n,a,l,d,g,A)}catch(v){if(De(y),v!==v+0)throw v;Ie(1,0)}}function Za(t){var n=Oe();try{return Fe.get(t)()}catch(a){if(De(n),a!==a+0)throw a;Ie(1,0)}}function es(t,n,a,l,d,g){var A=Oe();try{return Fe.get(t)(n,a,l,d,g)}catch(y){if(De(A),y!==y+0)throw y;Ie(1,0)}}function ts(t,n,a,l,d,g,A,y){var v=Oe();try{return Fe.get(t)(n,a,l,d,g,A,y)}catch(T){if(De(v),T!==T+0)throw T;Ie(1,0)}}function is(t,n,a,l,d,g){var A=Oe();try{Fe.get(t)(n,a,l,d,g)}catch(y){if(De(A),y!==y+0)throw y;Ie(1,0)}}function ns(t,n,a,l,d){var g=Oe();try{return Fe.get(t)(n,a,l,d)}catch(A){if(De(g),A!==A+0)throw A;Ie(1,0)}}function rs(t,n,a,l,d,g,A,y,v,T){var D=Oe();try{return Fe.get(t)(n,a,l,d,g,A,y,v,T)}catch(z){if(De(D),z!==z+0)throw z;Ie(1,0)}}function as(t,n,a,l,d,g,A){var y=Oe();try{return Fe.get(t)(n,a,l,d,g,A)}catch(v){if(De(y),v!==v+0)throw v;Ie(1,0)}}var Ii;Yt=function t(){Ii||br(),Ii||(Yt=t)};function br(){function t(){if(!Ii&&(Ii=!0,c.calledRun=!0,!Cn)){if(ji(Mn),S(c),c.onRuntimeInitialized&&c.onRuntimeInitialized(),c.postRun)for(typeof c.postRun=="function"&&(c.postRun=[c.postRun]);c.postRun.length;){var n=c.postRun.shift();xn.unshift(n)}ji(xn)}}if(!(0<Mt)){if(c.preRun)for(typeof c.preRun=="function"&&(c.preRun=[c.preRun]);c.preRun.length;)oa();ji(En),0<Mt||(c.setStatus?(c.setStatus("Running..."),setTimeout(function(){setTimeout(function(){c.setStatus("")},1),t()},1)):t())}}if(c.preInit)for(typeof c.preInit=="function"&&(c.preInit=[c.preInit]);0<c.preInit.length;)c.preInit.pop()();return br(),h.ready}})();m.exports=i}(yn)),yn.exports}var Ts=Cs(),_s=gs(Ts);class ea{constructor(e,i){this.sounds={},this.game=e,this.baseUrls=i}get audioContext(){if(!this._audioContext){if(!navigator.userActivation.hasBeenActive)throw new C("AudioContext cannot be created until user has interacted with the page");this._audioContext=new AudioContext}return this._audioContext}initializeSounds(e){return e?this.loadSounds(e):Promise.resolve()}loadSounds(e){return e.length===0?Promise.resolve():(e.forEach(i=>{let r=i.url;V.urlHasScheme(i.url)||(r=V.getUrlFromManifest(this.game,`${this.baseUrls.assets}/${i.url}`));const h={soundName:i.soundName,data:void 0,audioBuffer:void 0,audioBufferSource:void 0,url:r,status:i.lazy?je.Deferred:je.WillFetch};this.sounds[i.soundName]&&console.warn(`A sound named ${i.soundName} has already been loaded. It will be replaced.`),this.sounds[i.soundName]=h}),this.fetchSounds())}async fetchSounds(){const e=Object.values(this.sounds).map(i=>i.status===je.WillFetch?(i.status=je.Fetching,fetch(i.url).then(r=>{if(!r.ok)throw i.status=je.Error,new C(`cannot fetch sound ${i.soundName} at url ${i.url}: ${r.statusText}`);return r.arrayBuffer().then(h=>{i.data=h,i.status=je.Fetched,console.log(`\u26AA sound fetched. name: ${i.soundName}, bytes: ${h.byteLength}`)})})):Promise.resolve());await Promise.all(e)}fetchDeferredSound(e){return e.status=je.WillFetch,this.fetchSounds()}hasSoundsToDecode(){return Object.values(this.sounds).filter(e=>e.status===je.Fetched).length>0}decodeFetchedSounds(){const i=Object.values(this.sounds).filter(r=>r.status===je.Fetched).map(r=>this.decodeSound(r));return Promise.all(i)}async decodeSound(e){if(!e.data)throw new C(`data is undefined for sound ${e.soundName} (url ${e.url})`);try{e.status=je.Decoding;const i=await this.audioContext.decodeAudioData(e.data);e.audioBuffer=i,e.status=je.Ready,console.log(`\u26AA sound decoded. name: ${e.soundName}, duration (seconds): ${i.duration}`)}catch{throw e.status=je.Error,new C(`error decoding sound ${e.soundName} (url: ${e.url})`)}}getSound(e){const i=this.sounds[e];if(!i)throw new C(`getSound(): sound ${e} not found`);return i}dispose(){}getSoundNames(){return Object.keys(this.sounds)}}class Kt{static slide(e){let i=Dt.linear;return typeof e.easing=="string"?i=Dt.fromTypeAsString(e.easing):e.easing!==void 0&&(i=e.easing),new ia(e.direction,e.duration,i)}static none(){return new ta}}class ta extends Kt{constructor(){super(),this.type=St.None,this.duration=NaN,this.easing=Dt.none}}class ia extends Kt{constructor(e,i,r){super(),this.type=St.Slide,this.direction=e,this.duration=i,this.easing=r}}const St={Slide:"Slide",None:"None"},bt={Up:"Up",Down:"Down",Right:"Right",Left:"Left"};class na{constructor(e,i){this.scene=e,this.transition=i}}class Es{constructor(e){this.game=e.game,this.nodeFactory=e.nodeFactory,this.freeNodesScene=e.freeNodesScene,this.configureI18n=e.configureI18n,this.eventMaterializers=new Map([[H.NodeNew,this.materializeNodeNewEvent.bind(this)],[H.Composite,this.materializeCompositeEvent.bind(this)],[H.ScenePresent,this.materializeScenePresentEvent.bind(this)],[H.NodePropertyChange,this.materializeNodePropertyChangeEvent.bind(this)],[H.NodeAddChild,this.materializeNodeAddChildEvent.bind(this)],[H.NodeRemoveChild,this.materializeNodeRemoveChildEvent.bind(this)],[H.DomPointerDown,this.materializeDomPointerDownEvent.bind(this)],[H.BrowserImageDataReady,this.materializeBrowserImageDataReadyEvent.bind(this)],[H.I18nDataReadyEvent,this.materializeI18nDataReadyEvent.bind(this)]])}materialize(e){e.length>0&&(console.log(`Replaying ${e.length} events`),e.forEach(i=>{const r=this.eventMaterializers.get(i.type);r?r(i):console.log(`EventMaterializer unhandled event: ${i.type}`)}))}materializeCompositeEvent(e){const i=this.game.materializedNodes.find(r=>r.uuid===e.target);if(!i)console.log(`EventMaterializer: composite node of type ${e.compositeType} with uuid ${e.target} not found when handling CompositeEvent ${e.compositeEventType}`);else if(i.type===de.Composite)i.handleCompositeEvent(e);else throw new C(`EventMaterializer: node was expected to be composite, but was of type ${i.type}`)}materializeNodeNewEvent(e){const i=this.nodeFactory.createNode(e.nodeType,e.compositeType,e.nodeOptions);i.type===de.Scene&&(i.name===Q.FREE_NODES_SCENE_NAME?(this.freeNodesScene=i,this.freeNodesScene.game=this.game,this.freeNodesScene.needsInitialization=!0,this.game.sceneManager.freeNodesScene=this.freeNodesScene):this.game.addScene(i)),this.game.materializedNodes.push(i)}materializeNodePropertyChangeEvent(e){const i=this.game.materializedNodes.find(r=>r.uuid===e.uuid);if(!i)throw new C(`EventMaterializer: node with uuid ${e.uuid} not found`);if(e.property in i)i[e.property]=e.value;else throw new C(`EventMaterializer: on node ${i.name}, type ${i.type}, nodePropertyChangeEvent tried to set unknown property ${e.property} to value ${JSON.stringify(e.value)}`)}materializeNodeAddChildEvent(e){const i=this.game.materializedNodes.find(h=>h.uuid===e.uuid);if(!i)throw new C(`EventMaterializer: parent node with uuid ${e.uuid} not found`);const r=this.game.materializedNodes.find(h=>h.uuid===e.childUuid);if(!r)throw new C(`EventMaterializer: child node with uuid ${e.childUuid} not found`);i.addChild(r)}materializeNodeRemoveChildEvent(e){const i=this.game.materializedNodes.find(h=>h.uuid===e.uuid);if(!i)throw new C(`EventMaterializer: parent node with uuid ${e.uuid} not found`);const r=this.game.materializedNodes.find(h=>h.uuid===e.childUuid);if(!r)throw new C(`EventMaterializer: child node with uuid ${e.childUuid} not found`);i.removeChild(r)}materializeDomPointerDownEvent(e){this.game.currentScene?.run(X.custom({callback:()=>{const i=new fi({circleOfRadius:16,fillColor:R.LightGray,strokeColor:R.Black,lineWidth:2,alpha:.75,position:{x:e.x,y:e.y}});this.game.currentScene?.addChild(i),i.run(X.sequence([X.group([X.fadeAlpha({duration:750,alpha:0}),X.scale({duration:750,scale:0})]),X.custom({callback:()=>{this.game.currentScene?.removeChild(i)}})]))}}))}materializeBrowserImageDataReadyEvent(e){this.game.imageManager.loadImages([{imageName:e.imageName,width:e.width,height:e.height,dataUrl:e.dataUrl,svgString:e.svgString}])}materializeI18nDataReadyEvent(e){this.configureI18n(e.localizationOptions)}materializeScenePresentEvent(e){let i=Kt.none();if(e.transitionType===St.Slide){if(e.direction===void 0)throw new C("EventMaterializer: ScenePresentEvent direction is undefined for slide transition");if(e.duration===void 0)throw new C("EventMaterializer: ScenePresentEvent duration is undefined for slide transition");if(e.easingType===void 0)throw new C("EventMaterializer: ScenePresentEvent easingType is undefined for slide transition");const r=this.game.materializedNodes.find(h=>h.uuid===e.uuid);if(!r)throw new C(`EventMaterializer: Scene with uuid ${e.uuid} not found`);switch(e.direction){case bt.Left:{r.position.x=r.size.width;break}case bt.Right:{r.position.x=-r.size.width;break}case bt.Up:{r.position.y=r.size.height;break}case bt.Down:{r.position.y=-r.size.height;break}}i=Kt.slide({direction:e.direction,duration:e.duration,easing:Dt.fromTypeAsString(e.easingType)})}this.game.sceneManager.present(e.uuid,i)}}class Ms{constructor(e,i){this.game=e,this.htmlCanvas=i,this.addEventListeners()}dispose(){this.removeEventListeners()}addEventListeners(){if(this.htmlCanvas===void 0)throw new C("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",e=>{e.preventDefault()}),this.htmlCanvas.addEventListener("pointerleave",this.htmlCanvasPointerLeaveHandler.bind(this)),document.addEventListener("keydown",this.documentKeyDownHandler.bind(this)),document.addEventListener("keyup",this.documentKeyUpHandler.bind(this))}removeEventListeners(){this.htmlCanvas.removeEventListener("pointerdown",this.htmlCanvasPointerDownHandler.bind(this)),this.htmlCanvas.removeEventListener("pointerup",this.htmlCanvasPointerUpHandler.bind(this)),this.htmlCanvas.removeEventListener("pointermove",this.htmlCanvasPointerMoveHandler.bind(this)),this.htmlCanvas.removeEventListener("pointerleave",this.htmlCanvasPointerLeaveHandler.bind(this)),this.htmlCanvas.removeEventListener("touchstart",this.touchStartHandler),document.removeEventListener("keydown",this.documentKeyDownHandler.bind(this)),document.removeEventListener("keyup",this.documentKeyUpHandler.bind(this))}touchStartHandler(e){e.preventDefault()}htmlCanvasPointerDownHandler(e){e.preventDefault();const i=this.game.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;if(!this.htmlCanvas)throw new C("main html canvas is undefined");const r={type:"DomPointerDown",target:this.htmlCanvas,x:e.offsetX/m2c2Globals.rootScale,y:e.offsetY/m2c2Globals.rootScale,...V.createTimestamps()};this.game.eventStore.addEvent(r);const h={target:i,type:H.PointerDown,handled:!1,...V.createTimestamps()};this.processDomPointerDown(this.game.sceneManager.freeNodesScene,h,e),this.processDomPointerDown(i,h,e)}htmlCanvasPointerUpHandler(e){e.preventDefault();const i=this.game.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;const r={target:i,type:H.PointerUp,handled:!1,...V.createTimestamps()};this.processDomPointerUp(this.game.sceneManager.freeNodesScene,r,e),this.processDomPointerUp(i,r,e)}htmlCanvasPointerMoveHandler(e){e.preventDefault();const i=this.game.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;const r={target:i,type:H.PointerMove,handled:!1,...V.createTimestamps()};this.processDomPointerMove(this.game.sceneManager.freeNodesScene,r,e),this.processDomPointerMove(i,r,e)}htmlCanvasPointerLeaveHandler(e){if(!this.game.currentScene)return;e.preventDefault();const i=this.game.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;const r={target:i,type:H.PointerLeave,handled:!1,...V.createTimestamps()};this.processDomPointerLeave(this.game.sceneManager.freeNodesScene,r,e),this.processDomPointerLeave(i,r,e)}documentKeyDownHandler(e){const i=this.game.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;const r={target:i,type:H.KeyDown,handled:!1,...V.createTimestamps()};this.raiseEventOnListeningNodes(this.game.sceneManager.freeNodesScene,r,e),this.raiseEventOnListeningNodes(i,r,e)}documentKeyUpHandler(e){const i=this.game.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;const r={target:i,type:H.KeyUp,handled:!1,...V.createTimestamps()};this.raiseEventOnListeningNodes(this.game.sceneManager.freeNodesScene,r,e),this.raiseEventOnListeningNodes(i,r,e)}processDomPointerDown(e,i,r){i.handled||(e.isUserInteractionEnabled&&this.IsCanvasPointWithinNodeBounds(e,r.offsetX,r.offsetY)&&(e.pressed=!0,e.pressedAndWithinHitArea=!0,e.pressedInitialPointerOffset={x:r.offsetX,y:r.offsetY},this.raiseM2PointerDownEvent(e,i,r),this.raiseTapDownEvent(e,i,r)),e.children&&e.children.filter(h=>!h.hidden).filter(h=>h.isDrawable).sort((h,c)=>{const S=c.zPosition-h.zPosition;return S!==0?S:e.children.indexOf(c)-e.children.indexOf(h)}).forEach(h=>this.processDomPointerDown(h,i,r)))}processDomPointerUp(e,i,r){if(!i.handled){if(e.dragging){e.dragging=!1,e.pressed=!1,e.pressedAndWithinHitArea=!1,this.raiseM2DragEndEvent(e,i,r);return}e.isUserInteractionEnabled&&e.pressed&&e.pressedAndWithinHitArea?(e.pressed=!1,e.pressedAndWithinHitArea=!1,this.raiseTapUpEvent(e,i,r),this.raiseTapUpAny(e,i,r),this.raiseM2PointerUpEvent(e,i,r)):e.isUserInteractionEnabled&&e.pressed&&e.pressedAndWithinHitArea==!1?(e.pressed=!1,e.pressedAndWithinHitArea=!1,this.raiseTapUpAny(e,i,r)):e.isUserInteractionEnabled&&this.IsCanvasPointWithinNodeBounds(e,r.offsetX,r.offsetY)&&(e.pressed=!1,e.pressedAndWithinHitArea=!1,this.raiseM2PointerUpEvent(e,i,r)),e.children&&e.children.filter(h=>!h.hidden).filter(h=>h.isDrawable).sort((h,c)=>{const S=c.zPosition-h.zPosition;return S!==0?S:e.children.indexOf(c)-e.children.indexOf(h)}).forEach(h=>this.processDomPointerUp(h,i,r))}}processDomPointerMove(e,i,r){if(!i.handled){if(e.isUserInteractionEnabled&&e.draggable&&e.pressed){let h=!1,c,S;e.dragging===!1?(e.dragging=!0,h=!0,c=r.offsetX-e.pressedInitialPointerOffset.x,S=r.offsetY-e.pressedInitialPointerOffset.y):(c=r.offsetX-e.draggingLastPointerOffset.x,S=r.offsetY-e.draggingLastPointerOffset.y),e.position.x+=c,e.position.y+=S,e.draggingLastPointerOffset={x:r.offsetX,y:r.offsetY},h?this.raiseM2DragStartEvent(e,i,r):this.raiseM2DragEvent(e,i,r);return}e.isUserInteractionEnabled&&e.pressed&&e.pressedAndWithinHitArea&&!this.IsCanvasPointWithinNodeBounds(e,r.offsetX,r.offsetY)&&(e.pressedAndWithinHitArea=!1,this.raiseTapLeaveEvent(e,i,r)),e.isUserInteractionEnabled&&this.IsCanvasPointWithinNodeBounds(e,r.offsetX,r.offsetY)&&(this.raiseM2PointerMoveEvent(e,i,r),e.withinHitArea=!0),e.isUserInteractionEnabled&&e.withinHitArea&&!this.IsCanvasPointWithinNodeBounds(e,r.offsetX,r.offsetY)&&(e.withinHitArea=!1,this.raiseM2PointerLeaveEvent(e,i,r)),e.children&&e.children.filter(h=>!h.hidden).filter(h=>h.isDrawable).sort((h,c)=>{const S=c.zPosition-h.zPosition;return S!==0?S:e.children.indexOf(c)-e.children.indexOf(h)}).forEach(h=>this.processDomPointerMove(h,i,r))}}processDomPointerLeave(e,i,r){if(!i.handled){if(e.dragging){const h={target:e,type:H.DragEnd,handled:!1,...V.createTimestamps()};e.dragging=!1,e.pressed=!1,e.pressedAndWithinHitArea=!1,this.raiseM2DragEndEvent(e,h,r);return}e.isUserInteractionEnabled&&e.pressed&&e.pressedAndWithinHitArea&&!this.IsCanvasPointWithinNodeBounds(e,r.offsetX,r.offsetY)&&(e.pressedAndWithinHitArea=!1,this.raiseTapLeaveEvent(e,i,r)),e.isUserInteractionEnabled&&e.withinHitArea&&!this.IsCanvasPointWithinNodeBounds(e,r.offsetX,r.offsetY)&&(e.withinHitArea=!1,this.raiseM2PointerLeaveEvent(e,i,r)),e.children&&e.children.filter(h=>!h.hidden).filter(h=>h.isDrawable).sort((h,c)=>{const S=c.zPosition-h.zPosition;return S!==0?S:e.children.indexOf(c)-e.children.indexOf(h)}).forEach(h=>this.processDomPointerLeave(h,i,r))}}raiseEventOnListeningNodes(e,i,r){e.eventListeners.filter(h=>h.type===i.type).forEach(h=>{if(h.nodeUuid===e.uuid){switch(i.target=e,i.type){case H.PointerDown:case H.PointerMove:case H.PointerUp:case H.PointerLeave:i.point=this.calculatePointWithinNodeFromDomPointerEvent(e,r),i.buttons=r.buttons,h.callback(i);break;case H.KeyDown:case H.KeyUp:i.key=r.key,i.code=r.code,i.shiftKey=r.shiftKey,i.ctrlKey=r.ctrlKey,i.metaKey=r.metaKey,i.altKey=r.altKey,i.repeat=r.repeat,h.callback(i);break;case H.TapDown:case H.TapUp:case H.TapUpAny:case H.TapLeave:i.point=this.calculatePointWithinNodeFromDomPointerEvent(e,r),i.buttons=r.buttons,h.callback(i);break;case H.DragStart:case H.Drag:case H.DragEnd:i.position={x:e.position.x,y:e.position.y},i.buttons=r.buttons,h.callback(i);break}e.suppressEvents||this.game.eventStore.addEvent(i)}})}raiseM2PointerDownEvent(e,i,r){i.target=e,i.type=H.PointerDown,this.raiseEventOnListeningNodes(e,i,r)}raiseTapDownEvent(e,i,r){i.target=e,i.type=H.TapDown,this.raiseEventOnListeningNodes(e,i,r)}raiseTapLeaveEvent(e,i,r){i.target=e,i.type=H.TapLeave,this.raiseEventOnListeningNodes(e,i,r)}raiseM2PointerUpEvent(e,i,r){i.target=e,i.type=H.PointerUp,this.raiseEventOnListeningNodes(e,i,r)}raiseTapUpEvent(e,i,r){i.target=e,i.type=H.TapUp,this.raiseEventOnListeningNodes(e,i,r)}raiseTapUpAny(e,i,r){i.target=e,i.type=H.TapUpAny,this.raiseEventOnListeningNodes(e,i,r)}raiseM2PointerMoveEvent(e,i,r){i.target=e,i.type=H.PointerMove,this.raiseEventOnListeningNodes(e,i,r)}raiseM2PointerLeaveEvent(e,i,r){i.target=e,i.type=H.PointerLeave,this.raiseEventOnListeningNodes(e,i,r)}raiseM2DragStartEvent(e,i,r){i.target=e,i.type=H.DragStart,this.raiseEventOnListeningNodes(e,i,r)}raiseM2DragEvent(e,i,r){i.target=e,i.type=H.Drag,this.raiseEventOnListeningNodes(e,i,r)}raiseM2DragEndEvent(e,i,r){i.target=e,i.type=H.DragEnd,this.raiseEventOnListeningNodes(e,i,r)}sceneCanReceiveUserInteraction(e){return!!(e._active&&e._transitioning===!1)}IsCanvasPointWithinNodeBounds(e,i,r){if(!e.isDrawable)throw"only drawable nodes can receive pointer events";if(e.type===de.Shape&&e.shapeType===Ke.Circle){const c=V.calculateNodeAbsoluteBoundingBox(e),S=e.circleOfRadius;if(!S)throw"circleOfRadius is undefined";const E={x:c.xMin+S*e.absoluteScale,y:c.yMin+S*e.absoluteScale};return Math.sqrt(Math.pow(i-E.x,2)+Math.pow(r-E.y,2))<=S*e.absoluteScale}if(e.size.width===0||e.size.height===0||e.type===de.TextLine&&isNaN(e.size.width))return!1;const h=V.calculateRotatedPoints(e);return e.isUserInteractionEnabled&&V.isPointInsideRectangle({x:i,y:r},h)}calculatePointWithinNodeFromDomPointerEvent(e,i){let r=e.size.width,h=e.size.height;if(e.type===de.Shape&&e.shapeType===Ke.Circle){const K=e.circleOfRadius;if(!K)throw"circleOfRadius is undefined";r=K*2,h=K*2}let c=i.offsetX,S=i.offsetY;const E=V.calculateNodeAbsoluteBoundingBox(e);V.nodeOrAncestorHasBeenRotated(e)&&V.calculateRotationTransforms(e).forEach(ie=>{const le=V.rotatePoint({x:c,y:S},-ie.radians,ie.center);c=le.x,S=le.y});const O=(c-E.xMin)/(E.xMax-E.xMin)*r,G=(S-E.yMin)/(E.yMax-E.yMin)*h;return{x:O,y:G}}}class xs{constructor(e){this.scenes=new Array,this.incomingSceneTransitions=new Array,this.snapshots=new Array,this.game=e,this.freeNodesScene=this.createFreeNodesScene()}clearCurrentScene(){this.currentScene=void 0}updateScenes(){this.scenes.filter(e=>e._active).forEach(e=>e.update()),this.freeNodesScene.update()}drawScenes(e){this.scenes.filter(i=>i._active).forEach(i=>i.draw(e))}addNodeEvents(e){this.game.eventStore.addEvents(e.nodeEvents),e.nodeEvents.length=0;for(const i of e.children)this.addNodeEvents(i)}add(e){this.scenes.includes(e)&&console.warn(`Game.addScene(): scene ${e.toString()} has already been added to the game. This will cause unpredictable behavior. This warning will become an error in a future release.`),e.game=this.game,e.needsInitialization=!0,this.scenes.push(e),this.addNodeEvents(e)}remove(e){if(typeof e=="object")if(this.scenes.includes(e))this.scenes=this.scenes.filter(i=>i!==e);else throw new C(`cannot remove scene ${e} from game because the scene is not currently added to the game`);else if(this.scenes.map(i=>i.name).includes(e))this.scenes=this.scenes.filter(i=>i.name!==e);else throw new C(`cannot remove scene named "${e}" from game because the scene is not currently added to the game`)}present(e,i){let r;if(typeof e=="string"){if(r=this.scenes.filter(E=>E.name===e).find(Boolean),r===void 0&&(r=this.scenes.filter(E=>E.uuid===e).find(Boolean)),r===void 0)throw new C(`scene ${e} not found`)}else{if(!this.scenes.some(E=>E===e))throw new C(`scene ${e} exists, but it has not been added to the game object`);r=e}r.initialize(),r.needsInitialization=!1;const h=new na(r,i??Kt.none());this.incomingSceneTransitions.push(h),r.game.bodyBackgroundColor!==void 0?document.body.style.backgroundColor=`rgb(${r.game.bodyBackgroundColor[0]},${r.game.bodyBackgroundColor[1]},${r.game.bodyBackgroundColor[2]},${r.game.bodyBackgroundColor[3]})`:document.body.style.backgroundColor=`rgb(${r.backgroundColor[0]},${r.backgroundColor[1]},${r.backgroundColor[2]},${r.backgroundColor[3]})`;let c;i?.type===St.Slide&&(c=i.direction);const S={type:"ScenePresent",target:r,uuid:r.uuid,...V.createFrameUpdateTimestamps(),transitionType:i?.type??St.None,duration:i?.duration,direction:c,easingType:i?.easing?Dt.toTypeAsString(i.easing):void 0};this.game.eventStore.addEvent(S)}handleIncomingSceneTransitions(){if(this.incomingSceneTransitions.length!==0&&(this.snapshots.length>0||this.incomingSceneTransitions[0].transition.type===St.None)){const e=this.incomingSceneTransitions.shift();if(e===void 0)throw new C("no incoming scene transition");const i=e.scene,r=e.transition;if(r.type===St.None){this.currentScene&&(this.currentScene._active=!1),this.currentScene=i,this.currentScene._active=!0,this.raiseSceneEvent(i,"SceneSetup"),this.raiseSceneEvent(i,"SceneAppear");return}if(this.currentSceneSnapshot=this.snapshots.shift(),!this.currentSceneSnapshot)throw new C("No snapshot available for outgoing scene");const h=this.createOutgoingScene(this.currentSceneSnapshot);h._active=!0,this.currentScene&&(this.currentScene._active=!1),this.currentScene=i,this.currentScene._active=!0,this.raiseSceneEvent(i,"SceneSetup"),this.animateSceneTransition(i,r,h)}}createOutgoingScene(e){const i=new Vt({name:Q.OUTGOING_SCENE_NAME});i.size.width=this.game.canvasCssWidth,i.size.height=this.game.canvasCssHeight,this.add(i);const r={imageName:Q.OUTGOING_SCENE_IMAGE_NAME,canvaskitImage:e,width:this.game.canvasCssWidth,height:this.game.canvasCssHeight,status:nt.Ready,localize:!1,isFallback:!1};this.game.imageManager.addImage(r);const h=new pi({name:Q.OUTGOING_SCENE_SPRITE_NAME,imageName:Q.OUTGOING_SCENE_IMAGE_NAME,position:{x:this.game.canvasCssWidth/m2c2Globals.rootScale/2,y:this.game.canvasCssHeight/m2c2Globals.rootScale/2}});return h.scale=1/m2c2Globals.rootScale,i.addChild(h),i}animateSceneTransition(e,i,r){const h=i.duration;switch(e._transitioning=!0,r._transitioning=!0,i.type){case St.Slide:{switch(i.direction){case bt.Left:e.position.x=e.size.width,e.run(X.sequence([X.move({point:{x:0,y:0},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{e._transitioning=!1,this.raiseSceneEvent(e,"SceneAppear"),this.remove(Q.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),r.run(X.sequence([X.move({point:{x:-r.size.width,y:0},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{r._active=!1,r._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;case bt.Right:e.position.x=-e.size.width,e.run(X.sequence([X.move({point:{x:0,y:0},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{e._transitioning=!1,this.raiseSceneEvent(e,"SceneAppear"),this.remove(Q.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),r.run(X.sequence([X.move({point:{x:r.size.width,y:0},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{r._active=!1,r._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;case bt.Up:e.position.y=e.size.height,e.run(X.sequence([X.move({point:{x:0,y:0},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{e._transitioning=!1,this.raiseSceneEvent(e,"SceneAppear"),this.remove(Q.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),r.run(X.sequence([X.move({point:{x:0,y:-r.size.height},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{r._active=!1,r._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;case bt.Down:e.position.y=-e.size.height,e.run(X.sequence([X.move({point:{x:0,y:0},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{e._transitioning=!1,this.raiseSceneEvent(e,"SceneAppear"),this.remove(Q.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),r.run(X.sequence([X.move({point:{x:0,y:r.size.height},duration:h,easing:i.easing,runDuringTransition:!0}),X.custom({callback:()=>{r._active=!1,r._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;default:throw new C("unknown transition direction")}break}default:throw new C("unknown transition type")}}takeScreenshot(e,i,r,h){if(!this.game.surface)throw new C("no canvaskit surface. unable to take screenshot.");const c=[e,i,r,h].map(S=>S===void 0?1:0).reduce((S,E)=>S+E);return new Promise((S,E)=>{switch(c){case 0:{if(e===void 0||i===void 0||r===void 0||h===void 0){E("missing values in arguments for takeScreenshot()");return}this.pendingScreenshot={rect:[e,i,r,h],promiseResolve:S};break}case 4:{this.pendingScreenshot={rect:[],promiseResolve:S};break}default:E("Exactly 0 or 4 arguments must be supplied to takeScreenshot()")}})}handleScreenshots(){for(;this.snapshots.length>0;)this.snapshots.shift()?.delete();this.snapshots.push(this.takeCurrentSceneSnapshot()),this.pendingScreenshot&&(this.handlePendingScreenshot(this.pendingScreenshot),this.pendingScreenshot=void 0)}takeCurrentSceneSnapshot(){if(this.game.surface===void 0)throw new C("CanvasKit surface is undefined");return this.game.surface.makeImageSnapshot()}handlePendingScreenshot(e){if(!this.game.surface)throw new C("no surface");let i;if(e.rect.length==4){const h=e.rect[0]*m2c2Globals.canvasScale,c=e.rect[1]*m2c2Globals.canvasScale,S=e.rect[2]*m2c2Globals.canvasScale,E=e.rect[3]*m2c2Globals.canvasScale,O=[h,c,h+S,c+E];i=this.game.surface.makeImageSnapshot(O)}else i=this.game.surface.makeImageSnapshot();const r=i.encodeToBytes();e.promiseResolve(r)}raiseSceneEvent(e,i){const r={target:e,type:i,...V.createFrameUpdateTimestamps()};e.eventListeners.filter(h=>h.type===i).forEach(h=>h.callback(r))}createFreeNodesScene(){const e=new Vt({name:Q.FREE_NODES_SCENE_NAME,backgroundColor:[255,255,255,0]});e.game=this.game,e.needsInitialization=!0;const i={name:Q.FREE_NODES_SCENE_NAME,backgroundColor:[255,255,255,0],uuid:e.uuid},r={type:H.NodeNew,target:e,nodeType:de.Scene,...V.createFrameUpdateTimestamps(),nodeOptions:i,sequence:m2c2Globals.eventSequence};return this.game.eventStore.addEvent(r),e}get freeNodes(){return this.freeNodesScene.children}addFreeNode(e){this.freeNodesScene.addChild(e)}removeFreeNode(e){if(typeof e=="string"){const i=this.freeNodesScene.children.filter(r=>r.name===e).find(Boolean);if(!i)throw new C(`cannot remove free node named "${e}" because it is not currently part of the game's free nodes. `);this.freeNodesScene.removeChild(i)}else this.freeNodesScene.removeChild(e)}removeAllFreeNodes(){for(;this.freeNodesScene.children.length;)this.freeNodesScene.children.pop()}}const Pn={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 Bi{static getRendererString(){const e=document.createElement("canvas");e.id="webgl-renderer-info-canvas",e.height=0,e.width=0,e.hidden=!0,document.body.appendChild(e);const i=e.getContext("webgl");let r="no webgl context";if(!i)return r;const h=i.getExtension("WEBGL_debug_renderer_info");return h!=null?r=String(i.getParameter(h.UNMASKED_VENDOR_WEBGL))+", "+String(i.getParameter(h.UNMASKED_RENDERER_WEBGL)):r="no debug renderer info",e.remove(),r}static dispose(){const e=document.getElementById("webgl-renderer-info-canvas");e&&e.remove()}static interceptWebGlCalls(e){const i=Object.getPrototypeOf(e);if(i.m2c2ModifiedGetContext){i.m2c2ModifiedGetContext=!0;const r=i.getContext;i.getContext=function(...h){window.logWebGl&&console.log(`\u{1F53C} getContext(${h.map(E=>String(E)).join(", ")})`);const c=r.apply(this,[...h]),S=Object.getPrototypeOf(c);if(S.compileShader&&!S.m2c2ModifiedCompileShader){S.m2c2ModifiedCompileShader=!0;const E=S.compileShader;S.compileShader=function(...O){if(window.logWebGl){const G=O[0],K=c.getShaderSource(G);console.log("\u{1F53C} compileShader():"),console.log(K)}return E.apply(this,[...O])}}return c}}}}class Fs{constructor(e){this.webGlRendererInfo="",this.data={trials:new Array,scoring:{}},this.trialIndex=0,this.staticTrialSchema={},this.automaticTrialSchema={data_type:{type:"string",description:"Type of data."},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.automaticScoringSchema={data_type:{type:"string",description:"Type of data."},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.game=e}initializeData(){this.trialIndex=0,this.data={trials:new Array,scoring:{}};const e=this.game.options.trialSchema??{},i=this.game.options.scoringSchema??{};this.validateSchema(e),this.validateSchema(i)}queryWebGlRendererInfo(){try{this.webGlRendererInfo=Bi.getRendererString()}catch{this.webGlRendererInfo="err"}finally{Bi.dispose()}}propertySchemaDataTypeIsValid(e){const i=["string","number","integer","object","array","boolean","null"];if(typeof e=="string")return i.includes(e);let r=!0;if(Array.isArray(e))e.forEach(h=>{i.includes(h)||(r=!1)});else throw new C(`Invalid data type: ${e}`);return r}incrementTrialIndex(){this.trialIndex=this.trialIndex+1}addTrialData(e,i){if(!this.game.options.trialSchema)throw new C("no trial schema were provided in GameOptions. cannot add trial data");if(this.data.trials.length<this.trialIndex+1){const c={},S=Object.entries(this.game.options.trialSchema);for(const[E]of S)c[E]=null;this.data.trials.push({data_type:"trial",document_uuid:Lt.generate(),study_id:this.game.studyId??null,study_uuid:this.game.studyUuid??null,session_uuid:this.game.sessionUuid,activity_uuid:this.game.uuid,activity_id:this.game.options.id,activity_publish_uuid:this.game.options.publishUuid,activity_version:this.game.options.version,device_timezone:Intl?.DateTimeFormat()?.resolvedOptions()?.timeZone??"",device_timezone_offset_minutes:new Date().getTimezoneOffset(),locale:this.game.i18n?.locale??null,...c,device_metadata:this.getDeviceMetadata()})}if(!(e in this.game.options.trialSchema))throw new C(`trial variable ${e} not defined in schema`);let r;Array.isArray(this.game.options.trialSchema[e].type)?r=this.game.options.trialSchema[e].type:r=[this.game.options.trialSchema[e].type];let h=typeof i;if(h==="object"&&Object.prototype.toString.call(i)==="[object Array]"&&(h="array"),i==null&&(h="null"),!r.includes(h)&&!(h==="number"&&Number.isInteger(i)&&r.includes("integer")))throw new C(`type for variable ${e} (value: ${i}) is "${h}". Based on schema for this variable, expected type was "${r}"`);this.data.trials[this.trialIndex][e]=i}addStaticTrialData(e,i){if(!this.game.options.trialSchema)throw new C("trial schema is undefined");if(this.game.options.trialSchema[e]===void 0)throw new C(`trial variable ${e} not defined in schema`);this.staticTrialSchema[e]=i}addScoringData(e,i){if(!this.game.options.scoringSchema)throw new C("no scoring schema were provided in GameOptions. cannot add scoring data");if(Object.keys(this.data.scoring).length===0){const h={data_type:"scoring",document_uuid:Lt.generate(),study_id:this.game.studyId??null,study_uuid:this.game.studyUuid??null,session_uuid:this.game.sessionUuid,activity_uuid:this.game.uuid,activity_id:this.game.options.id,activity_publish_uuid:this.game.options.publishUuid,activity_version:this.game.options.version,device_timezone:Intl?.DateTimeFormat()?.resolvedOptions()?.timeZone??"",device_timezone_offset_minutes:new Date().getTimezoneOffset(),locale:this.game.i18n?.locale??null,device_metadata:this.getDeviceMetadata()},c=Object.entries(this.game.options.scoringSchema);for(const[S]of c)h[S]=null;this.data.scoring=h}if(typeof e=="object"){let h;Array.isArray(e)?(e.length!==1&&console.warn(`Array of objects passed to addScoringData() is length ${e.length}. This is likely an error in the assessment's code for calculateScores().`),h=e[0]):h=e;for(const[c,S]of Object.entries(h))this.validateAndSetScoringVariable(c,S);return}const r=e;if(i===void 0)throw new C("Value must be provided when adding a single scoring variable");this.validateAndSetScoringVariable(r,i)}validateAndSetScoringVariable(e,i){if(!this.game.options.scoringSchema)throw new C("no scoring schema were provided in GameOptions. cannot add scoring data");if(!(e in this.game.options.scoringSchema))throw new C(`scoring variable ${e} not defined in schema`);let r;Array.isArray(this.game.options.scoringSchema[e].type)?r=this.game.options.scoringSchema[e].type:r=[this.game.options.scoringSchema[e].type];let h=typeof i;if(h==="object"&&Object.prototype.toString.call(i)==="[object Array]"&&(h="array"),i==null&&(h="null"),!r.includes(h)&&!(h==="number"&&Number.isInteger(i)&&r.includes("integer")))throw new C(`type for variable ${e} (value: ${i}) is "${h}". Based on schema for this variable, expected type was "${r}"`);this.data.scoring[e]=i}getDeviceMetadata(){const e=window.screen;return e.orientation?{userAgent:navigator.userAgent,devicePixelRatio:window.devicePixelRatio,screen:{availHeight:e.availHeight,availWidth:e.availWidth,colorDepth:e.colorDepth,height:e.height,orientation:{type:e.orientation.type,angle:e.orientation.angle},pixelDepth:e.pixelDepth,width:e.width},webGlRenderer:this.webGlRendererInfo}:{userAgent:navigator.userAgent,devicePixelRatio:window.devicePixelRatio,screen:{availHeight:e.availHeight,availWidth:e.availWidth,colorDepth:e.colorDepth,height:e.height,pixelDepth:e.pixelDepth,width:e.width},webGlRenderer:this.webGlRendererInfo}}makeNewGameDataSchema(){return{description:`A single trial and metadata from the assessment ${this.game.name}.`,$comment:`Activity identifier: ${this.game.options.id}, version: ${this.game.options.version}.`,$schema:"https://json-schema.org/draft/2019-09/schema",type:"object",properties:{...this.automaticTrialSchema,...this.game.options.trialSchema,device_metadata:Pn}}}makeGameDataSchema(){return{description:`All trials and metadata from the assessment ${this.game.name}.`,$comment:`Activity identifier: ${this.game.options.id}, version: ${this.game.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.game.options.trialSchema,device_metadata:Pn}}}}}makeScoringDataSchema(){return{description:`Scoring data and metadata from the assessment ${this.game.name}.`,$comment:`Activity identifier: ${this.game.options.id}, version: ${this.game.options.version}.`,$schema:"https://json-schema.org/draft/2019-09/schema",type:"object",properties:{...this.automaticScoringSchema,...this.game.options.scoringSchema,device_metadata:Pn}}}validateSchema(e){const i=Object.entries(e);for(const[r,h]of i)if(h.type!==void 0&&!this.propertySchemaDataTypeIsValid(h.type))throw new C(`invalid schema. variable ${r} is type ${h.type}. type must be number, string, boolean, object, or array`)}}class Rs{constructor(e){if(this.type=ui.Game,this.sessionUuid="",this.uuid=Lt.generate(),this.publishUuid="",this.canvasKitWasmVersion="0.40.0",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.eventStore=new $r,this.nodeFactory=new Gr,this.materializedNodes=new Array,this.drawnFrames=0,this.lastFpsUpdate=0,this.nextFpsUpdate=0,this.fpsRate=0,this.animationFramesRequested=0,this.limitFps=!1,this.gameStopRequested=!1,this.canvasCssWidth=0,this.canvasCssHeight=0,this.replayEventsButtonEnabled=!0,!e.id||e.id.trim()==="")throw new C("id is required in GameOptions");if(!Lt.isValid(e.publishUuid)){const h=e.publishUuid?`Provided publishUuid was ${e.publishUuid}. `:"";console.warn(`Missing or invalid publishUuid in GameOptions. ${h}To generate a valid UUID, visit a site such as https://www.uuidgenerator.net/version4`)}const{parameters:i,...r}=e;this.options=r,this.options.parameters=V.sanitizeParameters(i),this.name=e.name,this.id=e.id,this.publishUuid=e.publishUuid,this.fpsMetricReportThreshold=e.fpsMetricReportThreshold??Q.FPS_METRIC_REPORT_THRESHOLD,this.maximumRecordedActivityMetrics=e.maximumRecordedActivityMetrics??Q.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={}),this.options.scoringSchema||(this.options.scoringSchema={}),e.moduleMetadata?this.moduleMetadata=e.moduleMetadata:this.moduleMetadata={name:"",version:"",dependencies:{}},e.moduleMetadata?.name&&e.version&&console.log(`\u26AA ${e.moduleMetadata.name} version ${e.version}`),this.sceneManager=new xs(this),this.dataManager=new Fs(this)}getImportedModuleBaseUrl(e,i){const r=new URL(i),h=r.pathname.split("/").filter(Boolean);let c=-1;for(let E=0;E<h.length-1;E++)if(e.startsWith("@")){const O=e.split("/");if(O.length===2){const G=O[0],K=O[1];for(let ie=0;ie<h.length-1;ie++)h[ie]===G&&(h[ie+1]===K||h[ie+1].startsWith(`${K}@`))&&(c=ie+1)}}else(h[E]===e||h[E].startsWith(`${e}@`))&&(c=E);if(c===-1)throw new Error(`Could not locate base URL for package "${e}" in "${i}"`);const S=h.slice(0,c+1).join("/");return`${r.origin}/${S}`.replace(/\/*$/,"")}addLocalizationParametersToGameParameters(){this.options.parameters={...this.options.parameters,...Li.makeLocalizationParameters()}}async init(){return this.initialize()}loadCanvasKit(e){return _s({locateFile:()=>e})}async resolveGameBaseUrls(e){let i,r=!1,h=`assets/${e.id}`;if(e.moduleMetadata.name)try{i=await import.meta.resolve(e.moduleMetadata.name),h=e.getImportedModuleBaseUrl(e.moduleMetadata.name,i)+"/assets",r=!0}catch{}let c=`assets/${e.id}`;try{const S=await import.meta.resolve("@m2c2kit/core");c=e.getImportedModuleBaseUrl("@m2c2kit/core",S)+"/assets"}catch{if(r)throw new C(`the package ${e.moduleMetadata.name} has been imported from a module URL (${i}), but the @m2c2kit/core package module URL could not be determined.`)}return{assets:h,canvasKitWasm:c}}async configureI18n(e){if(this.i18n=new Li(this,e),!this.i18n)throw new C("I18n object is undefined");await this.i18n.initialize(),this.eventStore.addEvent({type:"I18nDataReadyEvent",target:this.i18n,localizationOptions:e,...V.createFrameUpdateTimestamps()})}async waitForErudaInitialization(e=5e3){await new Promise(i=>{let r=0;const h=setInterval(()=>{m2c2Globals.erudaInitialized===!0&&(clearInterval(h),i(void 0)),r=r+100,r>e&&(console.warn(`Could not initialize eruda within ${e} milliseconds.`),clearInterval(h),i(void 0))},100)})}async initialize(){m2c2Globals.erudaRequested===!0&&await this.waitForErudaInitialization(),this.options.recordEvents===!0&&(this.eventStore.mode=vt.Record);const e=await this.resolveGameBaseUrls(this);if(this.manifest===void 0&&(this.manifest=await this.loadManifest()),this._canvasKit===void 0){const i=V.getUrlFromManifest(this,e.canvasKitWasm+`/canvaskit-${this.canvasKitWasmVersion}.wasm`);try{this.canvasKit=await this.loadCanvasKit(i)}catch(r){throw new C(`game ${this.id} could not load canvaskit wasm file from ${i}. err: ${r instanceof Error?r.message:String(r)}`)}}if(this.isLocalizationRequested()){const i=this.getLocalizationOptionsFromGameParameters();await this.configureI18n(i)}return this.fontManager=new Wr(this,e),this.imageManager=new pn(this,e),this.soundManager=new ea(this,e),this.eventMaterializer=new Es({game:this,nodeFactory:this.nodeFactory,freeNodesScene:this.sceneManager.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(e="__NO_M2C2KIT_MANIFEST_JSON_URL__"){if(e.includes("NO_M2C2KIT_MANIFEST_JSON_URL"))return{};let i;try{if(i=await fetch(e),!i.ok)throw new C(`Error ${i.status} on GET manifest.json from ${e}.`)}catch{throw new C(`Network error on GET manifest.json from ${e}.`)}try{return await i.json()}catch{throw new C(`Error parsing manifest.json from ${e}.`)}}get fontManager(){if(!this._fontManager)throw new C("fontManager is undefined");return this._fontManager}set fontManager(e){this._fontManager=e}get imageManager(){if(!this._imageManager)throw new C("imageManager is undefined");return this._imageManager}set imageManager(e){this._imageManager=e}get soundManager(){if(!this._soundManager)throw new C("soundManager is undefined");return this._soundManager}set soundManager(e){this._soundManager=e}get eventMaterializer(){if(!this._eventMaterializer)throw new C("eventMaterializer is undefined");return this._eventMaterializer}set eventMaterializer(e){this._eventMaterializer=e}get inputManager(){if(!this._inputManager)throw new C("inputManager is undefined");return this._inputManager}set inputManager(e){this._inputManager=e}get scenes(){return this.sceneManager.scenes}get currentScene(){return this.sceneManager.currentScene}get snapshots(){return this.sceneManager.snapshots}addPrefixesToKey(e){let i="";if(this.studyId&&this.studyUuid)i=this.studyId.concat(":",this.studyUuid,":");else if(this.studyId||this.studyUuid)throw new C(`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,":",e))}storeSetItem(e,i,r=!1){const h=r?e:this.addPrefixesToKey(e);return this.dataStores[0].setItem(h,i,r?"":this.publishUuid)}storeGetItem(e,i=!1){const r=i?e:this.addPrefixesToKey(e);return this.dataStores[0].getItem(r)}storeDeleteItem(e,i=!1){const r=i?e:this.addPrefixesToKey(e);return this.dataStores[0].deleteItem(r)}storeClearItems(){return this.dataStores[0].clearItemsByActivityPublishUuid(this.publishUuid)}storeItemsKeys(e=!1){return this.dataStores[0].itemsKeysByActivityPublishUuid(e?"":this.publishUuid)}storeItemExists(e,i=!1){const r=i?e:this.addPrefixesToKey(e);return this.dataStores[0].itemExists(r)}get dataStores(){if(!this._dataStores)throw new C("dataStores is undefined");return this._dataStores}set dataStores(e){this._dataStores=e}hasDataStores(){return this._dataStores&&this._dataStores.length>0||!1}getLocalizationOptionsFromGameParameters(){const e=this.getParameter("locale"),i=this.getParameterOrFallback("fallback_locale",void 0),r=this.getParameterOrFallback("missing_localization_color",void 0),h=this.getParameterOrFallback("translation",void 0),c=this.options.translation;return{locale:e,fallbackLocale:i,missingLocalizationColor:r,additionalTranslation:h,translation:c}}isLocalizationRequested(){const e=this.getParameterOrFallback("locale",void 0);if(e==="")throw new C("Empty string in locale. Leave locale undefined or null to prevent localization.");return e==null&&this.options.translation?(this.setParameters({locale:this.options.translation.baseLocale}),!0):!(e==null&&this.options.translation===void 0)}setParameters(e){const i=V.sanitizeParameters(e),{parameters:r}=this.options;Object.keys(i).forEach(h=>{if(h!=="diagnostics"){if(h==="eruda"){i[h]===!0&&V.loadEruda();return}if(h==="scripts"){const c=i[h];c&&V.loadScriptUrls(c);return}if(!r||!(h in r))console.warn(`game ${this.options.name} does not have a parameter named ${h}. attempt to set parameter ${h} to value ${i[h]} will be ignored`);else if(this.options.parameters&&this.options.parameters[h]){const c=i[h];let S;if(this.options.parameters[h].type!==void 0&&c!==void 0)try{S=V.convertValueToType(c,this.options.parameters[h].type)}catch(E){throw new C("Error setting parameter "+h+": "+E.message)}else S=c;this.options.parameters[h].default=S}this.additionalParameters===void 0&&(this.additionalParameters={}),this.additionalParameters[h]=i[h]}})}get canvasKit(){if(!this._canvasKit)throw new C("canvaskit is undefined");return this._canvasKit}set canvasKit(e){this._canvasKit=e}get data(){return this.dataManager.data}get trialIndex(){return this.dataManager.trialIndex}addFreeNode(e){this.sceneManager.addFreeNode(e)}addFreeEntity(e){this.sceneManager.addFreeNode(e)}removeFreeNode(e){this.sceneManager.removeFreeNode(e)}removeFreeEntity(e){this.sceneManager.removeFreeNode(e)}removeAllFreeNodes(){this.sceneManager.removeAllFreeNodes()}removeAllFreeEntities(){this.sceneManager.removeAllFreeNodes()}get freeNodes(){return this.sceneManager.freeNodes}get freeEntities(){return this.sceneManager.freeNodes}addScene(e){this.sceneManager.add(e)}addScenes(e){e.forEach(i=>{this.sceneManager.add(i)})}removeScene(e){this.sceneManager.remove(e)}presentScene(e,i){this.sceneManager.present(e,i)}getParameter(e){if(this.options.parameters!==void 0&&Object.keys(this.options.parameters).includes(e))return this.options.parameters[e].default;throw new C(`game parameter ${e} not found`)}getParameterOrFallback(e,i){return this.options.parameters!==void 0&&Object.keys(this.options.parameters).includes(e)?this.options.parameters[e].default:i}hasParameter(e){return!!(this.options.parameters!==void 0&&Object.keys(this.options.parameters).includes(e))}async start(e){const i=this.options;this.setupHtmlCanvases(i.canvasId,i.width,i.height,i.stretch),this.showFps=i.showFps??!1,this.bodyBackgroundColor=i.bodyBackgroundColor,this.dataManager.initializeData(),this.setupCanvasKitSurface(),this.setupFpsFont(),this.setupInputManager(),this.beginTimestamp=Ve.now(),this.beginIso8601Timestamp=new Date().toISOString();let r;if(e!==void 0?typeof e=="object"?r=e:r=this.scenes.filter(S=>S.name===e).find(Boolean):this.entryScene!==void 0?typeof this.entryScene=="object"?r=this.entryScene:r=this.scenes.filter(S=>S.name===this.entryScene).find(Boolean):r=this.scenes.find(Boolean),r===void 0)throw new C("cannot start game. entry scene has not been added to the game object.");if(this.sceneManager.present(r),this.surface===void 0)throw new C("CanvasKit surface is undefined");this.options.timeStepping?(this.addTimeSteppingControlsToDom(),this.updateTimeSteppingOutput()):this.removeTimeSteppingControlsFromDom(),this.options.showEventStoreControls&&this.addEventControlsToDom(),this.warmupFinished=!1;const h={target:this,type:H.GameWarmupStart,...V.createFrameUpdateTimestamps()};this.raiseActivityEventOnListeners(h),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 c={target:this,type:H.ActivityStart,...V.createFrameUpdateTimestamps()};this.raiseActivityEventOnListeners(c)}playEventsHandler(e){if(e?.target?.id==="replay-events"&&(this.eventStore.mode=vt.Disabled,this.scenes.forEach(i=>{this.removeScene(i)}),this.sceneManager.clearCurrentScene(),this.eventListeners=new Array,this.sceneManager.freeNodesScene.removeAllChildren(),this.materializedNodes=[],this.eventStore.replay(),this.setReplayEventsButtonEnabled(!1),this.setStopReplayButtonEnabled(!0)),e?.target?.id==="stop-replay"&&(this.eventStore.clearEvents(),this.setReplayEventsButtonEnabled(!0),this.setStopReplayButtonEnabled(!1)),e?.target?.id==="log-events"){if(this.eventStore.mode===vt.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(e){const i=document.getElementById("replay-events");if(i){if(e){i.removeAttribute("disabled"),this.replayEventsButtonEnabled=!0;return}i.setAttribute("disabled","true"),this.replayEventsButtonEnabled=!1}}setStopReplayButtonEnabled(e){const i=document.getElementById("stop-replay");if(i){if(e){i.removeAttribute("disabled");return}i.setAttribute("disabled","true")}}addEventControlsToDom(){const e=document.getElementById("m2c2kit-event-controls-div");e&&e.remove();const i=document.getElementsByTagName("body")[0];if(i){const r=document.createElement("div");r.id="m2c2kit-event-controls-div",r.style.position="fixed",r.style.top="4px",r.style.left="4px",i.prepend(r);const h=document.createElement("button");h.id="replay-events",h.title="replay event recording",h.innerText="\u25B6\uFE0F",h.style.marginRight="4px",r.appendChild(h),h.addEventListener("click",this.playEventsHandler.bind(this));const c=document.createElement("button");c.id="stop-replay",c.title="stop event replay",c.innerText="\u23F9\uFE0F",c.style.marginRight="4px",c.disabled=!0,r.appendChild(c),c.addEventListener("click",this.playEventsHandler.bind(this));const S=document.createElement("button");S.id="log-events",S.title="log events to console",S.innerText="\u{1F4C4}",S.style.marginRight="4px",r.appendChild(S),S.addEventListener("click",this.playEventsHandler.bind(this));const E=document.createElement("span");E.title="optional: replay events only through a given sequence number. Default is to replay all events.",E.innerText="Replay through sequence: ",r.appendChild(E);const O=document.createElement("input");O.id="sequence-number",O.title="optional: replay events only through a given sequence number. Default is to replay all events.",O.style.marginRight="4px",r.appendChild(O)}}addTimeSteppingControlsToDom(){if(document.getElementById("m2c2kit-time-stepping-div"))return;const i=document.getElementsByTagName("body")[0];if(i){const r=document.createElement("div");r.id="m2c2kit-time-stepping-div",i.prepend(r);const h=document.createElement("button");h.id="1-step-advance",h.title="advance 1 step (16.667 ms)",h.innerText=">",h.style.marginRight="4px",r.appendChild(h),h.addEventListener("click",this.advanceStepsHandler.bind(this));const c=document.createElement("button");c.id="55-step-advance",c.title="advance 55 steps (916.667 ms)",c.innerText=">>",c.style.marginRight="4px",r.appendChild(c),c.addEventListener("click",this.advanceStepsHandler.bind(this));const S=document.createElement("input");S.id="time-stepping-steps-input",S.title="steps",S.style.width="40px",S.style.marginRight="4px",S.setAttribute("readonly","true"),r.appendChild(S);const E=document.createElement("input");E.id="time-stepping-now-input",E.title="milliseconds",E.style.width="80px",E.style.marginRight="4px",E.setAttribute("readonly","true"),r.appendChild(E)}}updateTimeSteppingOutput(){const e=document.getElementById("time-stepping-steps-input");e&&(e.value=this.stepCount.toString());const i=document.getElementById("time-stepping-now-input");i&&(i.value=this.steppingNow.toFixed(2))}advanceStepsHandler(e){e?.target?.id==="1-step-advance"?(this.steppingNow=this.steppingNow+16.66666666666667,this.stepCount=this.stepCount+1):e?.target?.id==="55-step-advance"&&(this.steppingNow=this.steppingNow+16.66666666666667*55,this.stepCount=this.stepCount+55),this.updateTimeSteppingOutput()}removeTimeSteppingControlsFromDom(){const e=document.getElementById("m2c2kit-time-stepping-div");e&&e.remove()}warmupShadersWithPrimitives(e,i=0){if(e.save(),i==0?e.scale(1/m2c2Globals.canvasScale,1/m2c2Globals.canvasScale):e.scale(1/m2c2Globals.canvasScale*1.13,1/m2c2Globals.canvasScale*1.13),!this.surface)throw new C("surface is undefined");const r=this.surface.width(),h=this.surface.height(),c=Math.round(r/2)+i,S=Math.round(h/2)+i,E=i,O=i,G=Ne.makePaint(this.canvasKit,R.White,this.canvasKit.PaintStyle.Fill,!0);e.drawRect([0,0,this.surface.width(),this.surface.height()],G);const K=Ne.makePaint(this.canvasKit,R.Black,this.canvasKit.PaintStyle.Fill,!1),ie=Ne.makePaint(this.canvasKit,R.Black,this.canvasKit.PaintStyle.Fill,!0),le=Ne.makePaint(this.canvasKit,R.Black,this.canvasKit.PaintStyle.Stroke,!1);le.setStrokeWidth(2);const ye=Ne.makePaint(this.canvasKit,R.Black,this.canvasKit.PaintStyle.Stroke,!0);ye.setStrokeWidth(2),e.drawCircle(c,S,32,K),e.drawCircle(c,S,32,ie),e.drawCircle(c,S,32,le),e.drawCircle(c,S,32,ye);const ae=this.fontManager,Ee=this.fontManager.getFontNames();if(Ee.length>0&&ae.fonts[Ee[0]].status===rt.Ready){const Be=ae.getTypeface(Ee[0]),at=new this.canvasKit.Font(Be,16*m2c2Globals.canvasScale);e.drawText("abc",c,S,K,at),e.drawText("abc",c,S,ie,at)}const We=this.sceneManager.takeCurrentSceneSnapshot();e.drawImage(We,E,O),We.delete(),e.drawRect([E,O,16,16],K),e.drawRect([E,O,16,16],ie),e.drawRect([E,O,16,16],le),e.drawRect([E,O,16,16],ye),e.restore()}warmupShadersWithScenes(e){[...this.scenes,this.sceneManager.freeNodesScene].forEach(c=>{c.warmup(e)});const i=this.nodes.filter(c=>c.type===de.Sprite).map(c=>c.imageName),r=this.imageManager.images;r&&Object.keys(r).filter(S=>S!=="__outgoingSceneSnapshot").forEach(S=>{if(!i.includes(S)&&r[S].status===nt.Ready){const E=r[S].canvaskitImage;if(!E)throw new C(`image ${S} is undefined`);e.drawImage(E,0,0)}});const h=new this.canvasKit.Paint;if(h.setColor(this.canvasKit.Color(255,255,255,1)),!this.surface)throw new C("surface is undefined");e.drawRect([0,0,this.surface.width(),this.surface.height()],h)}stop(){this.currentScene&&(this.currentScene._active=!1),this.gameStopRequested=!0,Ve.removeAll(),this.dispose()}dispose(){this.inputManager.dispose(),this.nodes.filter(e=>e.isDrawable).forEach(e=>e.dispose()),this.fontManager.dispose()}addTrialData(e,i){this.dataManager.addTrialData(e,i)}addScoringData(e,i){this.dataManager.addScoringData(e,i)}addTrialSchema(e){Object.keys(e).forEach(r=>{if(!this.options.trialSchema)throw new C("trial schema is undefined");this.options.trialSchema[r]=e[r]})}addStaticTrialData(e,i){this.dataManager.addStaticTrialData(e,i)}trialComplete(){this.dataManager.data.trials[this.trialIndex]?.locale&&(this.dataManager.data.trials[this.trialIndex].locale=this.i18n?.locale??null),this.dataManager.data.trials[this.trialIndex]?.device_metadata&&(this.dataManager.data.trials[this.trialIndex].device_metadata=this.dataManager.getDeviceMetadata()),Object.keys(this.dataManager.staticTrialSchema).length>0&&(this.dataManager.data.trials[this.trialIndex]={...this.dataManager.data.trials[this.trialIndex],...this.dataManager.staticTrialSchema}),this.dataManager.incrementTrialIndex();const e={type:H.ActivityData,...V.createFrameUpdateTimestamps(),target:this,newData:this.dataManager.data.trials[this.trialIndex-1],newDataSchema:this.dataManager.makeNewGameDataSchema(),data:this.dataManager.data,dataSchema:this.dataManager.makeGameDataSchema(),dataType:"Trial",activityConfiguration:this.makeGameActivityConfiguration(this.options.parameters??{}),activityConfigurationSchema:this.makeGameActivityConfigurationSchema(this.options.parameters??{}),activityMetrics:this.gameMetrics};this.raiseActivityEventOnListeners(e)}scoringComplete(){const e={type:H.ActivityData,...V.createFrameUpdateTimestamps(),target:this,newData:this.dataManager.data.scoring,newDataSchema:this.dataManager.makeScoringDataSchema(),data:this.dataManager.data.scoring,dataSchema:this.dataManager.makeScoringDataSchema(),dataType:"Scoring",activityConfiguration:this.makeGameActivityConfiguration(this.options.parameters??{}),activityConfigurationSchema:this.makeGameActivityConfigurationSchema(this.options.parameters??{}),activityMetrics:this.gameMetrics};this.raiseActivityEventOnListeners(e)}makeGameActivityConfiguration(e){const i=JSON.parse(JSON.stringify(e)),{locale:r,fallback_locale:h,missing_localization_color:c,translation:S,...E}=i;for(const O in E)for(const G in E[O])G=="default"&&(E[O]=E[O][G]);return E}makeGameActivityConfigurationSchema(e){const i=JSON.parse(JSON.stringify(e)),{locale:r,fallback_locale:h,missing_localization_color:c,translation:S,...E}=i;for(const O in E){if(!("type"in E[O])&&"value"in E[O]){const G=typeof E[O].default;G!=="bigint"&&G!=="function"&&G!=="symbol"&&G!=="undefined"&&(E[O].type=G)}for(const G in E[O])G=="default"&&delete E[O][G]}return{description:`activity configuration from the assessment ${this.name}`,type:"object",properties:E}}end(){const e={target:this,type:H.ActivityEnd,...V.createFrameUpdateTimestamps()},i={data:this.dataManager.data,dataSchema:this.dataManager.makeGameDataSchema(),dataType:"Trial",activityConfiguration:this.makeGameActivityConfiguration(this.options.parameters??{}),activityConfigurationSchema:this.makeGameActivityConfigurationSchema(this.options.parameters??{}),activityMetrics:this.gameMetrics};this.raiseActivityEventOnListeners(e,i)}cancel(){const e={target:this,type:H.ActivityCancel,...V.createFrameUpdateTimestamps()},i={data:this.dataManager.data,dataSchema:this.dataManager.makeGameDataSchema(),dataType:"Trial",activityConfiguration:this.makeGameActivityConfiguration(this.options.parameters??{}),activityConfigurationSchema:this.makeGameActivityConfigurationSchema(this.options.parameters??{}),activityMetrics:this.gameMetrics};this.raiseActivityEventOnListeners(e,i)}setupHtmlCanvases(e,i,r,h){m2c2Globals.canvasScale=Math.round(window.devicePixelRatio*100)/100;let c;if(e===void 0){const S=document.getElementsByTagName("canvas");let E=new Array;for(let G=0;G<S.length;G++)E.push(S[G]);if(E=E.filter(G=>!G.id.startsWith("m2c2kit-scratch-canvas")),E.length===0)throw new C("no html canvas tag was found in the html");const O=E.filter(G=>G.id==="m2c2kit-canvas")[0];O?(c=O,E.length>1&&console.log("using canvas with id 'm2c2kit-canvas'")):(c=S[0],E.length>1&&console.log("using first canvas"))}else if(c=document.getElementById(e),c===void 0)throw new C(`could not find canvas HTML element with id "${e}"`);if(h||window.innerWidth<i||window.innerHeight<r){const S=r/i;window.innerHeight/window.innerWidth<S?m2c2Globals.rootScale=window.innerHeight/r:m2c2Globals.rootScale=window.innerWidth/i}c.style.width=m2c2Globals.rootScale*i+"px",c.style.height=m2c2Globals.rootScale*r+"px",c.width=m2c2Globals.rootScale*i*m2c2Globals.canvasScale,c.height=m2c2Globals.rootScale*r*m2c2Globals.canvasScale,this.htmlCanvas=c,this.canvasCssWidth=i,this.canvasCssHeight=r,m2c2Globals.canvasCssWidth=i,m2c2Globals.canvasCssHeight=r}setupCanvasKitSurface(){if(this.htmlCanvas===void 0)throw new C("main html canvas is undefined");window.logWebGl=this.options.logWebGl,Bi.interceptWebGlCalls(this.htmlCanvas),this.dataManager.queryWebGlRendererInfo();const e=this.canvasKit.MakeWebGLCanvasSurface(this.htmlCanvas);if(e===null)throw new C("could not make CanvasKit surface from canvas HTML element");this.surface=e,console.log(`\u26AA CanvasKit surface is backed by ${this.surface.reportBackendTypeIsGPU()?"GPU":"CPU"}`),this.surface.getCanvas().scale(m2c2Globals.canvasScale,m2c2Globals.canvasScale)}setupFpsFont(){this.fpsTextFont=new this.canvasKit.Font(null,Q.FPS_DISPLAY_TEXT_FONT_SIZE*m2c2Globals.canvasScale),this.fpsTextPaint=new this.canvasKit.Paint,this.fpsTextPaint.setColor(this.canvasKit.Color(Q.FPS_DISPLAY_TEXT_COLOR[0],Q.FPS_DISPLAY_TEXT_COLOR[1],Q.FPS_DISPLAY_TEXT_COLOR[2],Q.FPS_DISPLAY_TEXT_COLOR[3])),this.fpsTextPaint.setAntiAlias(!0)}setupInputManager(){if(this.htmlCanvas===void 0)throw new C("main html canvas is undefined");this.inputManager=new Ms(this,this.htmlCanvas)}loop(e){if(!this.surface)throw new C("surface is undefined");if(this.warmupFunctionQueue.length>0){const i=this.warmupFunctionQueue.shift();i?.warmupFunction.call(this,e,i.positionOffset),this.surface.requestAnimationFrame(this.loop.bind(this));return}if(!this.warmupFinished){this.warmupFinished=!0;const i={target:this,type:H.GameWarmupEnd,...V.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/Q.LIMITED_FPS_RATE)===0){if(this.currentScene===void 0&&this.sceneManager.incomingSceneTransitions.length===0&&this.eventStore.mode!==vt.Replay)throw new C("Can not run game without a current or incoming scene");if(this.updateGameTime(),this.eventStore.mode===vt.Replay){const i=this.eventStore.dequeueEvents(Ve.now());this.eventMaterializer.materialize(i),this.eventStore.eventQueueLength===0&&!this.replayEventsButtonEnabled&&(this.setReplayEventsButtonEnabled(!0),this.setStopReplayButtonEnabled(!1))}this.sceneManager.handleIncomingSceneTransitions(),this.update(),this.draw(e),this.sceneManager.handleScreenshots(),this.sceneManager.freeNodesScene.draw(e)}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}async registerPlugin(e){if(e.type!==ui.Game)throw new C(`registerPlugin(): plugin ${e.id} is not a game plugin. It is a ${e.type} plugin.`);if(this.plugins.includes(e)||this.plugins.map(i=>i.id).includes(e.id))throw new C(`registerPlugin(): plugin ${e.id} already registered.`);this.plugins.push(e),e.initialize&&await e.initialize(this)}update(){this.executeBeforeUpdatePlugins(),this.sceneManager.updateScenes(),this.executeAfterUpdatePlugins()}executeBeforeUpdatePlugins(){this.plugins.filter(e=>typeof e.beforeUpdate=="function"&&e.disabled!==!0).forEach(e=>{e.beforeUpdate&&e.beforeUpdate(this,m2c2Globals.deltaTime)})}executeAfterUpdatePlugins(){this.plugins.filter(e=>typeof e.afterUpdate=="function"&&e.disabled!==!0).forEach(e=>{e.afterUpdate&&e.afterUpdate(this,m2c2Globals.deltaTime)})}draw(e){this.sceneManager.drawScenes(e),this.drawnFrames++,this.calculateFps(),this.showFps&&this.drawFps(e)}calculateFps(){this.lastFpsUpdate===0?(this.lastFpsUpdate=m2c2Globals.now,this.nextFpsUpdate=m2c2Globals.now+Q.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+Q.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:Q.FPS_DISPLAY_UPDATE_INTERVAL,fps_report_threshold:this.fpsMetricReportThreshold,activity_type:ui.Game,activity_uuid:this.uuid,iso8601_timestamp:new Date().toISOString()}))}takeScreenshot(e,i,r,h){return this.sceneManager.takeScreenshot(e,i,r,h)}drawFps(e){e.save();const i=m2c2Globals.canvasScale;if(e.scale(1/i,1/i),!this.fpsTextFont||!this.fpsTextPaint)throw new C("fps font or paint is undefined");e.drawText("FPS: "+this.fpsRate.toFixed(2),0,0+Q.FPS_DISPLAY_TEXT_FONT_SIZE*i,this.fpsTextPaint,this.fpsTextFont),e.restore()}createEventListener(e,i,r,h){const c=this.nodes.filter(E=>E.name===i);c.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 S=c.filter(E=>E.name===i).find(Boolean);if(S===void 0)throw new C(`could not create event listener. node with name ${i} could not be found in the game node tree`);if(!Object.values(H).includes(e))throw new C(`game ${this.id}: could not create event listener. event type ${e} is not known`);S.addEventListener(e,r,h)}get nodes(){function e(r,h){h.push(r),r.children.forEach(c=>e(c,h))}const i=new Array;return[...this.scenes,this.sceneManager.freeNodesScene].forEach(r=>e(r,i)),i}get entities(){return this.nodes}onStart(e,i){this.addEventListener(H.ActivityStart,e,i)}onCancel(e,i){this.addEventListener(H.ActivityCancel,e,i)}onEnd(e,i){this.addEventListener(H.ActivityEnd,e,i)}onData(e,i){this.addEventListener(H.ActivityData,e,i)}onWarmupStart(e,i){this.addEventListener(H.GameWarmupStart,e,i)}onWarmupEnd(e,i){this.addEventListener(H.GameWarmupEnd,e,i)}addEventListener(e,i,r){const h={type:e,activityUuid:this.uuid,callback:i};r?.replaceExisting&&(this.eventListeners=this.eventListeners.filter(c=>!(c.activityUuid===h.activityUuid&&c.type===h.type))),this.eventListeners.push(h)}raiseActivityEventOnListeners(e,i){i&&(e={...e,...i}),this.eventListeners.filter(r=>r.type===e.type).forEach(r=>{r.callback(e)})}}function ks(){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:[]}}ks();const ra=class sa{constructor(e){this.startTime=NaN,this.stopTime=NaN,this.stopped=!0,this.cumulativeElapsed=NaN,this.name=e}static now(){return window.performance.now()}static start(e){let i=this._timers.filter(r=>r.name===e).find(Boolean);if(i===void 0)i=new sa(e),i.cumulativeElapsed=0,this._timers.push(i);else if(i.stopped==!1)throw new C(`can't start timer. timer with name ${e} is already started`);i.startTime=window.performance.now(),i.stopped=!1}static stop(e){const i=this._timers.filter(r=>r.name===e).find(Boolean);if(i===void 0)throw new C(`can't stop timer. timer with name ${e} does not exist`);if(i.stopped===!0)throw new C(`can't stop timer. timer with name ${e} is already stopped`);i.stopTime=window.performance.now(),i.cumulativeElapsed=i.cumulativeElapsed+i.stopTime-i.startTime,i.stopped=!0}static restart(e){const i=this._timers.filter(r=>r.name===e).find(Boolean);if(i===void 0)throw new C(`can't restart timer. timer with name ${e} does not exist`);i.startTime=window.performance.now(),i.cumulativeElapsed=0,i.stopped=!1}static elapsed(e){const i=this._timers.filter(r=>r.name===e).find(Boolean);if(i===void 0)throw new C(`can't get elapsed time. timer with name ${e} does not exist`);return i.stopped?i.cumulativeElapsed:i.cumulativeElapsed+window.performance.now()-i.startTime}static remove(e){if(this._timers.filter(r=>r.name===e).find(Boolean)===void 0)throw new C(`can't remove timer. timer with name ${e} does not exist`);this._timers=this._timers.filter(r=>r.name!=e)}static removeAll(){this._timers=new Array}static exists(e){return this._timers.some(i=>i.name===e)}};ra._timers=new Array;let Ns=ra;class An{static SingleFromRange(e,i){return Math.floor(Math.random()*(i-e+1))+e}static FromRangeWithoutReplacement(e,i,r){if(e>r-i+1)throw new C(`number of requested draws (n = ${e}) is greater than number of integers in range [ ${i}, ${r}]`);const h=new Array;for(let c=0;c<e;c++){const S=An.SingleFromRange(i,r);h.includes(S)?e++:h.push(S)}return h}static FromGridWithoutReplacement(e,i,r,h){const c=new Array,S=i*r-1,E=this.FromRangeWithoutReplacement(e,0,S);let O=0,G=NaN;for(;O<e;){const K=E[O]%r,ie=(E[O]-K)/r;if(h===void 0||h(ie,K))c.push({row:ie,column:K}),O++;else{do G=this.FromRangeWithoutReplacement(1,0,S)[0];while(E.includes(G));E[O]=G}}return c}}class Is extends ft{constructor(e){super(e),this.type=de.SoundPlayer,this.isDrawable=!1,this.soundName=e.soundName}initialize(){}removeAction(e){const i=this.actions.find(r=>r.key===e);i?.type===me.Play&&this.stopSoundActionAudio(i),this.actions=this.actions.filter(r=>r.key!==e)}removeAllActions(){for(;this.actions.length;){const e=this.actions.pop();e?.type===me.Play&&this.stopSoundActionAudio(e)}}stopSoundActionAudio(e){if(e.running){const i=this.game.soundManager.getSound(this.soundName);i.audioBufferSource?.stop(),i.audioBufferSource?.disconnect()}}dispose(){}duplicate(e){throw new C("Method not implemented.")}}class Os extends ft{constructor(e){if(super(e),this.type=de.SoundRecorder,this.isDrawable=!1,this._isRecording=!1,this._isPaused=!1,this.audioChunks=[],this.timerUuid="",e?.mimeType){const i=this.getMediaRecorderSupportedAudioMimeTypes();if(i.includes(e.mimeType))this.mimeType=e.mimeType;else if(console.warn(`Unsupported MIME type in SoundRecorderOptions: ${e.mimeType}. Supported types are: ${i}.`),e.backupMimeTypes){const r=this.getSupportedBackupMimeType(e.backupMimeTypes);r&&(this.mimeType=r,console.log(`Using backup MIME type: ${r}.`))}}e?.audioTrackConstraints&&(this.audioTrackConstraints=e.audioTrackConstraints),e?.maximumDuration&&(this.maximumDuration=e.maximumDuration)}initialize(){}async start(){if(this.isRecording)throw new C("cannot start SoundRecorder because it is already started.");this.audioChunks=[],this.endIso8601Timestamp=void 0;const e=this.getMediaRecorderSupportedAudioMimeTypes();if(e.length===0)throw new C("SoundRecorder found no supported MIME types for MediaRecorder.");this.mimeType||(this.mimeType=e[0],console.log(`Using MIME type: ${this.mimeType}.`));let i;try{i=await navigator.mediaDevices.getUserMedia({audio:this.audioTrackConstraints?this.audioTrackConstraints:!0})}catch(h){throw new C(`Error getting user media: ${h}.`)}if(!i)throw new C("no stream.");const r=i.getAudioTracks();this.mediaTrackSettings=r?.map(h=>h.getSettings()),this.mediaRecorder=new MediaRecorder(i,{mimeType:this.mimeType}),this.mediaRecorder.ondataavailable=h=>{this.audioChunks.push(h.data)},this.mediaRecorder.onerror=h=>{throw new C(`MediaRecorder error: ${h?.error?.message} ${h?.message}`)},this.mediaRecorder.start(),this.beginIso8601Timestamp=new Date().toISOString(),this.timerUuid=Lt.generate(),Ve.startNew(this.timerUuid),this._isRecording=!0,this._isPaused=!1}async stop(){if(!this.isRecording)throw new C("cannot stop SoundRecorder because it has not started.");return new Promise(e=>{if(!this.mediaRecorder)throw new C("no media recorder");this.mediaRecorder.onstop=async()=>{if(!this.mimeType)throw new C("no mimeType");this._isRecording=!1,this._isPaused=!1;const i=new Blob(this.audioChunks,{type:this.getMimeTypeWithoutCodecs(this.mimeType)}),r=await this.blobToBase64(i);e({mimeType:this.mimeType,beginIso8601Timestamp:this.beginIso8601Timestamp??"",endIso8601Timestamp:this.endIso8601Timestamp??"",duration:Ve.elapsed(this.timerUuid),audioTrackSettings:this.mediaTrackSettings,audioBase64:r,audioBlob:i})},this.mediaRecorder.stop(),this.endIso8601Timestamp=new Date().toISOString(),this.isPaused||Ve.stop(this.timerUuid)})}pause(){if(!this.isRecording)throw new C("cannot pause SoundRecorder because it is not started.");if(this.isPaused)throw new C("cannot pause SoundRecorder because it is already paused.");this.mediaRecorder?.pause(),this._isPaused=!0,Ve.stop(this.timerUuid)}resume(){if(!this.isRecording)throw new C("cannot resume SoundRecorder because it is not started.");if(!this.isPaused)throw new C("cannot resume SoundRecorder because it is not paused.");this.mediaRecorder?.resume(),this._isPaused=!1,Ve.start(this.timerUuid)}async queryPermission(){try{return(await navigator.permissions.query({name:"microphone"})).state}catch(e){console.warn(`Error calling navigator.permissions.query({ name: "microphone" }): ${e}.`);return}}async requestPermission(){try{return(await navigator.mediaDevices.getUserMedia({audio:this.audioTrackConstraints?this.audioTrackConstraints:!0})).getTracks().forEach(i=>i.stop()),!0}catch(e){return console.warn(`Microphone access denied: ${e}`),!1}}get isRecording(){return this._isRecording}get isPaused(){return this._isPaused}update(){if(super.update(),this.isRecording&&!this.isPaused&&this.maximumDuration!==void 0&&Ve.elapsed(this.timerUuid)>this.maximumDuration){this.pause();return}}getMediaRecorderSupportedAudioMimeTypes(){const e=["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"],r=["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(h=>e.flatMap(c=>[`${c}/${h}`]))),...new Set(i.flatMap(h=>r.flatMap(c=>e.flatMap(S=>[`${S}/${h};codecs=${c}`])))),...new Set(i.flatMap(h=>r.flatMap(c=>r.flatMap(S=>e.flatMap(E=>[`${E}/${h};codecs="${c}, ${S}"`])))))].filter(h=>MediaRecorder.isTypeSupported(h))}blobToBase64(e){return new Promise((i,r)=>{const h=new FileReader;h.onloadend=()=>{const c=h.result?.toString().split(",").pop();if(c===void 0)throw new C("base64WithoutPrefix is undefined.");i(c)},h.onerror=r,h.readAsDataURL(e)})}getMimeTypeWithoutCodecs(e){const i=e.match(/^[^;]+/);return i?i[0]:""}getSupportedBackupMimeType(e){const i=this.getMediaRecorderSupportedAudioMimeTypes();for(const r of e)if(i.includes(r))return r}dispose(){}duplicate(e){throw new C(`Method not implemented. ${e}`)}}class Ds{static create(e){return new Array}}console.log("\u26AA @m2c2kit/core version 0.3.32 (f8bdff76)");export{X as Action,ui as ActivityType,Ne as CanvasKitHelpers,cs as ColorfulMutablePath,fs as Composite,Q as Constants,Ge as ConstraintType,kr as CustomAction,Ur as Dimensions,Dt as Easings,q as Equal,ps as Equals,$r as EventStore,vt as EventStoreMode,Lr as FadeAlphaAction,Wr as FontManager,Rs as Game,Fr as GroupAction,Li as I18n,pn as ImageManager,$i as Label,Ht as LabelHorizontalAlignmentMode,Br as LayoutConstraint,Ns as LegacyTimer,C as M2Error,H as M2EventType,nt as M2ImageStatus,ft as M2Node,Gr as M2NodeFactory,de as M2NodeType,je as M2SoundStatus,V as M2c2KitHelpers,Or as MoveAction,Ui as MutablePath,ta as NoneTransition,Nr as PlayAction,An as RandomDraws,dn as RepeatAction,Rr as RepeatForeverAction,zr as RotateAction,Dr as ScaleAction,Vt as Scene,na as SceneTransition,xr as SequenceAction,fi as Shape,Ke as ShapeType,ia as SlideTransition,ea as SoundManager,Is as SoundPlayer,Os as SoundRecorder,pi as Sprite,Ds as Story,Gi as TextLine,Ve as Timer,Kt as Transition,bt as TransitionDirection,St as TransitionType,Lt as Uuid,Ir as WaitAction,R as WebColors,Bi as WebGlInfo,zt as handleInterfaceOptions};