@m2c2kit/core 0.3.32 → 0.3.33

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 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};
1
+ var de=(g=>(g.Node="Node",g.Scene="Scene",g.Sprite="Sprite",g.Label="Label",g.TextLine="TextLine",g.Shape="Shape",g.Composite="Composite",g.SoundPlayer="SoundPlayer",g.SoundRecorder="SoundRecorder",g))(de||{});const je={Deferred:"Deferred",WillFetch:"WillFetch",Fetching:"Fetching",Fetched:"Fetched",Decoding:"Decoding",Ready:"Ready",Error:"Error"};var me=(g=>(g.Sequence="Sequence",g.Group="Group",g.Wait="Wait",g.Custom="Custom",g.Move="Move",g.Scale="Scale",g.FadeAlpha="FadeAlpha",g.Rotate="Rotate",g.Play="Play",g.Repeat="Repeat",g.RepeatForever="RepeatForever",g))(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=(g,e,i,r)=>i+e,Me.linear=(g,e,i,r)=>i*g/r+e,Me.quadraticIn=(g,e,i,r)=>(g/=r,i*g*g+e),Me.quadraticOut=(g,e,i,r)=>(g/=r,-i*g*(g-2)+e),Me.quadraticInOut=(g,e,i,r)=>(g/=r/2,g<1?i/2*g*g+e:(g--,-i/2*(g*(g-2)-1)+e)),Me.cubicIn=(g,e,i,r)=>(g/=r,i*g*g*g+e),Me.cubicOut=(g,e,i,r)=>(g/=r,g--,i*(g*g*g+1)+e),Me.cubicInOut=(g,e,i,r)=>(g/=r/2,g<1?i/2*g*g*g+e:(g-=2,i/2*(g*g*g+2)+e)),Me.quarticIn=(g,e,i,r)=>(g/=r,i*g*g*g*g+e),Me.quarticOut=(g,e,i,r)=>(g/=r,g--,-i*(g*g*g*g-1)+e),Me.quarticInOut=(g,e,i,r)=>(g/=r/2,g<1?i/2*g*g*g*g+e:(g-=2,-i/2*(g*g*g*g-2)+e)),Me.quinticIn=(g,e,i,r)=>(g/=r,i*g*g*g*g*g+e),Me.quinticOut=(g,e,i,r)=>(g/=r,g--,i*(g*g*g*g*g+1)+e),Me.quinticInOut=(g,e,i,r)=>(g/=r/2,g<1?i/2*g*g*g*g*g+e:(g-=2,i/2*(g*g*g*g*g+2)+e)),Me.sinusoidalIn=(g,e,i,r)=>-i*Math.cos(g/r*(Math.PI/2))+i+e,Me.sinusoidalOut=(g,e,i,r)=>i*Math.sin(g/r*(Math.PI/2))+e,Me.sinusoidalInOut=(g,e,i,r)=>-i/2*(Math.cos(Math.PI*g/r)-1)+e,Me.exponentialIn=(g,e,i,r)=>i*Math.pow(2,10*(g/r-1))+e,Me.exponentialOut=(g,e,i,r)=>i*(-Math.pow(2,-10*g/r)+1)+e,Me.exponentialInOut=(g,e,i,r)=>(g/=r/2,g<1?i/2*Math.pow(2,10*(g-1))+e:(g--,i/2*(-Math.pow(2,-10*g)+2)+e)),Me.circularIn=(g,e,i,r)=>(g/=r,-i*(Math.sqrt(1-g*g)-1)+e),Me.circularOut=(g,e,i,r)=>(g/=r,g--,i*Math.sqrt(1-g*g)+e),Me.circularInOut=(g,e,i,r)=>(g/=r/2,g<1?-i/2*(Math.sqrt(1-g*g)-1)+e:(g-=2,i/2*(Math.sqrt(1-g*g)+1)+e));let Lt=Me;var Ke=(g=>(g.Undefined="Undefined",g.Rectangle="Rectangle",g.Circle="Circle",g.Path="Path",g))(Ke||{});const Fr=class ua{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 ua(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)}};Fr._timers=new Array;let Ve=Fr;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 v(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:v,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 v=window?.eruda;typeof v<"u"?(console.log("\u26AA eruda ready"),v.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(!fn(i[h]))continue;const c=r[h],v=i[h].zRotation,E=V.findCentroid(c);for(let O=h;O<i.length;O++)r[O]=ms(r[O],v,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;gs(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 v=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:v,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),v=(h.x-r.x)*(i.y-r.y)-(h.y-r.y)*(i.x-r.x);return c*v>=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=>fn(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 v of e)i+=v.x,r+=v.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,v=h*Math.cos(-i)-c*Math.sin(-i),E=h*Math.sin(-i)+c*Math.cos(-i);return{x:v+r.x,y:E+r.y}}static calculateRotationTransforms(e){const i=[],r=e.ancestors;return r.reverse(),r.push(e),r.forEach(h=>{if(fn(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 v=V.calculateNodeAbsoluteBoundingBox(c),E=V.boundingBoxToPoints(v),O=V.findCentroid(E);i.push({radians:c.zRotation,center:O})}}),i}}function gs(g,e,i){g.forEach(r=>{i.rotate(V.radiansToDegrees(r.radians),r.center.x*e,r.center.y*e)})}function fn(g){return V.normalizeAngleRadians(g.zRotation)!==0&&g.isDrawable}function ms(g,e,i){if(g.length!==4)throw new C("Invalid input: expected an array of four points");const r=[];for(const h of g)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(zi.Add,...e),this}subtract(...e){return this.appendOperation(zi.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]===zi.Add){r=1;continue}if(i[h]===zi.Subtract){r=-1;continue}}return e}}const zi={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(v=>{X.evaluateAction(v,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 v=c.getSound(h.soundName);if(v.audioBuffer)v.audioBufferSource=c.audioContext.createBufferSource(),v.audioBufferSource.buffer=v.audioBuffer,v.audioBufferSource.onended=()=>{r.running=!1,r.completed=!0;const E=performance.now()-(i.runStartTime+i.startOffset.value);i.duration.assign(E)},v.audioBufferSource.connect(c.audioContext.destination),v.audioBufferSource.start(),r.started=!0;else{if(v.status===je.Error)throw new C(`error loading sound ${v.soundName} (url ${v.url})`);console.warn(`Play action: audio buffer not ready for sound ${h.soundName} (url: ${v.url}); will try next frame`),v.status===je.Deferred&&c.fetchDeferredSound(v)}}}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 Lr(e.point,new Le(e.duration),e.easing??Lt.linear,e.runDuringTransition??!1)}static wait(e){return new Dr(new Le(e.duration),e.runDuringTransition??!1)}static custom(e){return new Ir(e.callback,e.runDuringTransition??!1)}static play(e){return new Or(e?.runDuringTransition??!1)}static scale(e){return new zr(e.scale,new Le(e.duration),e.runDuringTransition)}static fadeAlpha(e){return new Br(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 Ur(e.byAngle,e.toAngle,e.shortestUnitArc,new Le(e.duration),e.runDuringTransition)}static sequence(e){const i=new Rr(e);return i.children=e,i}static group(e){const i=new kr(e);return i.children=e,i}static repeat(e){return new pn(e.action,e.count,e.runDuringTransition)}static repeatForever(e){return new Nr(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 Rr 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 gn(this)}}class kr 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 gn(this)}}class pn 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 gn(this)}}class Nr extends pn{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 gn(g){const e=[];function i(r){if(r.isParent(r))for(const h of r.children)e.push(h),i(h)}return i(g),e}class Ir 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 Or 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 Dr 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 Lr 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 zr 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 Br 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 Ur 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 fi=(g=>(g.Game="Game",g.Survey="Survey",g))(fi||{});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 Gi{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 Gi;return e._subpaths=JSON.parse(JSON.stringify(this._subpaths)),e.currentPath=JSON.parse(JSON.stringify(this.currentPath)),e}}class ys extends Gi{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=(g=>(g.topToTopOf="topToTopOf",g.topToBottomOf="topToBottomOf",g.bottomToTopOf="bottomToTopOf",g.bottomToBottomOf="bottomToBottomOf",g.startToStartOf="startToStartOf",g.startToEndOf="startToEndOf",g.endToEndOf="endToEndOf",g.endToStartOf="endToStartOf",g))(Ge||{});class $r{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 zt{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 vs(g,e){e.anchorPoint&&(g.anchorPoint=e.anchorPoint),e.zPosition!==void 0&&(g.zPosition=e.zPosition)}function ws(g,e){e.text!==void 0&&(g.text=e.text),e.fontName!==void 0&&(g.fontName=e.fontName),e.fontColor&&(g.fontColor=e.fontColor),e.fontSize!==void 0&&(g.fontSize=e.fontSize),e.interpolation&&(g.interpolation=e.interpolation),e.localize!==void 0&&(g.localize=e.localize)}function Bt(g,e){g.isDrawable&&vs(g,e),g.isText&&ws(g,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=zt.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(v=>v.children.includes(e)).map(v=>v.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 v,E="";if(typeof e[c]=="object")v=e[c];else{const G=e[c];v=i.filter(K=>K.name===G||K.uuid===G).find(Boolean),v||(v=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(v===void 0)throw new C("could not find sibling node for constraint"+E);const O=new $r(c,v);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,v=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,v,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 v=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&&v.push(G.uuid)}}),v}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(v=>{const E=this.children.filter(O=>O.uuid===v).find(Boolean);if(E===void 0)throw new C("error in dag topological sort");c.push(E)}),c.forEach(v=>v.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,v)=>{r.has(v)||r.set(v,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,v)=>{c==0&&h.push(v)});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(v=>{const E=r.get(v);if(E===void 0)throw new C(`Could not find inDegree for edge ${v}`);if(r.has(v)&&E>0){const O=E-1;r.set(v,O),O==0&&h.push(v)}})}return i}}class Ss 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,Bt(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 Gr=(g=>(g[g.MatchConstraint=0]="MatchConstraint",g))(Gr||{});const nt={Deferred:"Deferred",Loading:"Loading",Ready:"Ready",Error:"Error"};class mn{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,v)=>h.indexOf(c)!=v))(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(v=>{const E=this.canvasKit.MakeImageFromEncoded(v);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 v={type:H.BrowserImageDataReady,target:this,imageName:e.imageName,width:e.width,height:e.height,svgString:e.svgString,...V.createFrameUpdateTimestamps()};this.game.eventStore.addEvent(v)}else e.url&&fetch(e.url).then(v=>v.arrayBuffer()).then(v=>{this.arrayBufferToBase64Async(v).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 pi="{{}}",yn="[[]]";class Bi{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(pi,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},v={};let E=!1;h.forEach(le=>{const ye=this.translatePlaceholder(le,c,r);v[le]=ye.text,E=E||ye.isFallback}),this.warnConflictingFontProperties(e,c);const O=this.insertInterpolations(yn,e,v),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]=[yn.slice(0,2),yn.slice(2)],h=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),v=new RegExp(`${h}(.*?)${c}`,"g"),E=e.match(v);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 v=this.translation[this.locale]?.[e];return this.isStringOrTextWithFontCustomization(v)?this.insertInterpolations(pi,this.getKeyText(v),h):void 0}const c=this.translation[this.fallbackLocale]?.[e];if(this.isStringOrTextWithFontCustomization(c))return this.insertInterpolations(pi,this.getKeyText(c),h)}tf(e,i){const{useFallbackLocale:r,...h}=i??{};if(r!==!0){const v=this.translation[this.locale]?.[e];if(this.isStringOrTextWithFontCustomization(v)){const E=this.getKeyTextAndFont(v,this.locale);return E.text&&(E.text=this.insertInterpolations(pi,E.text,h)),E}return}const c=this.translation[this.fallbackLocale]?.[e];if(this.isStringOrTextWithFontCustomization(c)){const v=this.getKeyTextAndFont(c,this.fallbackLocale);return v.text&&(v.text=this.insertInterpolations(pi,v.text,h)),v}}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(v=>v!=="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)],v=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),E=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),O=new RegExp(`${v}(.*?)${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 Wr{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 v=JSON.stringify(e);return e.target=i,e.nodeOptions.layout.constraints=h,v}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 mn){e.target="ImageManager";const h=JSON.stringify(e);return e.target=i,h}if(i instanceof Bi){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 Vt=(g=>(g[g.Center=0]="Center",g[g.Left=1]="Left",g[g.Right=2]="Right",g))(Vt||{});const rt={Deferred:"Deferred",Loading:"Loading",Ready:"Ready"},Je={UNDERLINE:"u",ITALIC:"i",BOLD:"b",STRIKETHROUGH:"s",OVERLINE:"o"};class Wi 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=Vt.Center,this._localize=!0,this.localizedFontNames=[],this.textAfterLocalization="",this.plainText="",this.styleSegments=[],Bt(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 Vt.Center:e=this.canvasKit.TextAlign.Center;break;case Vt.Left:e=this.canvasKit.TextAlign.Left;break;case Vt.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,v=this.getRequiredLabelFonts(c);if(v.forEach(K=>{if(K.status===rt.Deferred){c.prepareDeferredFont(K);return}}),!v.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:v.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]),v=/<\/?([^>]+)>/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=v.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 v={};if(c.styles.has(Je.BOLD)&&(v.fontStyle={...v.fontStyle||r.fontStyle,weight:this.canvasKit.FontWeight.Black}),c.styles.has(Je.ITALIC)&&(v.fontStyle={...v.fontStyle||r.fontStyle,slant:this.canvasKit.FontSlant.Italic}),c.styles.has(Je.UNDERLINE)&&(v.decoration=this.canvasKit.UnderlineDecoration,v.decorationThickness=1,v.decorationStyle=this.canvasKit.DecorationStyle.Solid,v.decorationColor=this.fontColor),c.styles.has(Je.STRIKETHROUGH)&&(v.decoration=this.canvasKit.LineThroughDecoration,v.decorationThickness=1,v.decorationStyle=this.canvasKit.DecorationStyle.Solid,v.decorationColor=this.fontColor),c.styles.has(Je.OVERLINE)&&(v.decoration=this.canvasKit.OverlineDecoration,v.decorationThickness=1,v.decorationStyle=this.canvasKit.DecorationStyle.Solid,v.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,v),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 Wi({...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 Yt 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,Bt(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 Yt({...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 gi 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,Bt(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 gi({...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 v=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[v].subpathIndex===G&&c[v].pointIndex===le){const ye=c[v].strokeColor,ae=c[v].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)),v<c.length-1&&v++}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 v of c){const E=v.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,v=this.calculateTransformationMatrix(c,i,r);this.ckPath=this.ckPath.transform(v),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,v=r-this.svgPreviousAbsoluteY;return[h,0,c,0,h,v,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,v=this.circleOfRadius*this.absoluteScale*r;e.drawCircle(h,c,v,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 ji 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=[],Bt(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 ji({...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 mi extends ft{constructor(e={}){super(e),this.type=de.Sprite,this.isDrawable=!0,this._anchorPoint={x:.5,y:.5},this._zPosition=0,this._imageName="",Bt(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 mi({...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 jr{constructor(){V.registerM2NodeClass(Wi,gi,mi,Yt,ji)}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 bs{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 Hr{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 v={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]=v,v.status===rt.Loading)return this.prepareFont(v)});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 vn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ps(g){return g&&g.__esModule&&Object.prototype.hasOwnProperty.call(g,"default")?g.default:g}function Kr(g){if(Object.prototype.hasOwnProperty.call(g,"__esModule"))return g;var e=g.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(g).forEach(function(r){var h=Object.getOwnPropertyDescriptor(g,r);Object.defineProperty(i,r,h.get?h:{enumerable:!0,get:function(){return g[r]}})}),i}var wn={exports:{}},As={},Cs=Object.freeze({__proto__:null,default:As}),Ts=Kr(Cs);function Vr(g,e){for(var i=0,r=g.length-1;r>=0;r--){var h=g[r];h==="."?g.splice(r,1):h===".."?(g.splice(r,1),i++):i&&(g.splice(r,1),i--)}if(e)for(;i--;i)g.unshift("..");return g}var _s=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,Sn=function(g){return _s.exec(g).slice(1)};function Ui(){for(var g="",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;g=r+"/"+g,e=r.charAt(0)==="/"}return g=Vr(An(g.split("/"),function(h){return!!h}),!e).join("/"),(e?"/":"")+g||"."}function bn(g){var e=Pn(g),i=Ms(g,-1)==="/";return g=Vr(An(g.split("/"),function(r){return!!r}),!e).join("/"),!g&&!e&&(g="."),g&&i&&(g+="/"),(e?"/":"")+g}function Pn(g){return g.charAt(0)==="/"}function qr(){var g=Array.prototype.slice.call(arguments,0);return bn(An(g,function(e,i){if(typeof e!="string")throw new TypeError("Arguments to path.join must be strings");return e}).join("/"))}function Yr(g,e){g=Ui(g).substr(1),e=Ui(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(g.split("/")),h=i(e.split("/")),c=Math.min(r.length,h.length),v=c,E=0;E<c;E++)if(r[E]!==h[E]){v=E;break}for(var O=[],E=v;E<r.length;E++)O.push("..");return O=O.concat(h.slice(v)),O.join("/")}var Xr="/",Jr=":";function Qr(g){var e=Sn(g),i=e[0],r=e[1];return!i&&!r?".":(r&&(r=r.substr(0,r.length-1)),i+r)}function Zr(g,e){var i=Sn(g)[2];return e&&i.substr(-1*e.length)===e&&(i=i.substr(0,i.length-e.length)),i}function ea(g){return Sn(g)[3]}var Es={extname:ea,basename:Zr,dirname:Qr,sep:Xr,delimiter:Jr,relative:Yr,join:qr,isAbsolute:Pn,normalize:bn,resolve:Ui};function An(g,e){if(g.filter)return g.filter(e);for(var i=[],r=0;r<g.length;r++)e(g[r],r,g)&&i.push(g[r]);return i}var Ms="ab".substr(-1)==="b"?function(g,e,i){return g.substr(e,i)}:function(g,e,i){return e<0&&(e=g.length+e),g.substr(e,i)},xs=Object.freeze({__proto__:null,basename:Zr,default:Es,delimiter:Jr,dirname:Qr,extname:ea,isAbsolute:Pn,join:qr,normalize:bn,relative:Yr,resolve:Ui,sep:Xr}),Fs=Kr(xs),ta;function Rs(){return ta||(ta=1,(function(g,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,v,E;c.ready=new Promise((t,n)=>{v=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,m=t._malloc(d);return(l=t.Surface._makeRasterDirect(l,m,4*n))&&(l.ce=null,l.Xf=n,l.Tf=a,l.Vf=d,l.wf=m,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,w,T){return y&&y.hasOwnProperty(w)?y[w]:T}function a(y){var w=It(tt);return tt[w]=y,w}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 m(y,w,T,D){return y.bindTexture(y.TEXTURE_2D,w),D||T.alphaType!==t.AlphaType.Premul||y.pixelStorei(y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),w}function A(y,w,T){T||w.alphaType!==t.AlphaType.Premul||y.pixelStorei(y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),y.bindTexture(y.TEXTURE_2D,null)}t.GetWebGLContext=function(y,w){if(!y)throw"null canvas passed into makeWebGLContext";var T={alpha:n(w,"alpha",1),depth:n(w,"depth",1),stencil:n(w,"stencil",8),antialias:n(w,"antialias",0),premultipliedAlpha:n(w,"premultipliedAlpha",1),preserveDrawingBuffer:n(w,"preserveDrawingBuffer",0),preferLowPowerToHighPerformance:n(w,"preferLowPowerToHighPerformance",0),failIfMajorPerformanceCaveat:n(w,"failIfMajorPerformanceCaveat",0),enableExtensionsByDefault:n(w,"enableExtensionsByDefault",1),explicitSwapControl:n(w,"explicitSwapControl",0),renderViaOffscreenBackBuffer:n(w,"renderViaOffscreenBackBuffer",0)};if(T.majorVersion=w&&w.majorVersion?w.majorVersion:typeof WebGL2RenderingContext<"u"?2:1,T.explicitSwapControl)throw"explicitSwapControl is not supported";return y=$a(y,T),y?(ir(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,w){var T=tt[w];T&&yt[y].xe.deleteTexture(T),tt[w]=null}}),t.MakeWebGLContext=function(y){if(!this.de(y))return null;var w=this._MakeGrContext();if(!w)return null;w.be=y;var T=w.delete.bind(w);return w.delete=function(){t.de(this.be),T()}.bind(w),se.Af=w},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,w,T,D,z,Y){return!this.de(y.be)||(w=z===void 0||Y===void 0?this._MakeOnScreenGLSurface(y,w,T,D):this._MakeOnScreenGLSurface(y,w,T,D,z,Y),!w)?null:(w.be=y.be,w)},t.MakeRenderTarget=function(){var y=arguments[0];if(!this.de(y.be))return null;if(arguments.length===3){var w=this._MakeRenderTargetWH(y,arguments[1],arguments[2]);if(!w)return null}else if(arguments.length===2){if(w=this._MakeRenderTargetII(y,arguments[1]),!w)return null}else return null;return w.be=y.be,w},t.MakeWebGLCanvasSurface=function(y,w,T){w=w||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),w=this.MakeOnScreenGLSurface(y,D.width,D.height,w),w||(w=D.cloneNode(!0),D.parentNode.replaceChild(w,D),w.classList.add("ck-replaced"),t.MakeSWCanvasSurface(w))},t.MakeCanvasSurface=t.MakeWebGLCanvasSurface,t.Surface.prototype.makeImageFromTexture=function(y,w){return t.de(this.be),y=a(y),(w=this._makeImageFromTexture(this.be,y,w))&&(w.cf=y),w},t.Surface.prototype.makeImageFromTextureSource=function(y,w,T){w||(w={height:l(y),width:d(y),colorType:t.ColorType.RGBA_8888,alphaType:T?t.AlphaType.Premul:t.AlphaType.Unpremul}),w.colorSpace||(w.colorSpace=t.ColorSpace.SRGB),t.de(this.be);var D=se.xe;return T=m(D,D.createTexture(),w,T),se.version===2?D.texImage2D(D.TEXTURE_2D,0,D.RGBA,w.width,w.height,0,D.RGBA,D.UNSIGNED_BYTE,y):D.texImage2D(D.TEXTURE_2D,0,D.RGBA,D.RGBA,D.UNSIGNED_BYTE,y),A(D,w),this._resetContext(),this.makeImageFromTexture(T,w)},t.Surface.prototype.updateTextureFromSource=function(y,w,T){if(y.cf){t.de(this.be);var D=y.getImageInfo(),z=se.xe,Y=m(z,tt[y.cf],D,T);se.version===2?z.texImage2D(z.TEXTURE_2D,0,z.RGBA,d(w),l(w),0,z.RGBA,z.UNSIGNED_BYTE,w):z.texImage2D(z.TEXTURE_2D,0,z.RGBA,z.RGBA,z.UNSIGNED_BYTE,w),A(z,D,T),this._resetContext(),tt[y.cf]=null,y.cf=a(Y),D.colorSpace=y.getColorSpace(),w=this._makeImageFromTexture(this.be,y.cf,D),T=y.ae.ie,z=y.ae.pe,y.ae.ie=w.ae.ie,y.ae.pe=w.ae.pe,w.ae.ie=T,w.ae.pe=z,w.delete(),D.colorSpace.delete()}},t.MakeLazyImageFromTextureSource=function(y,w,T){w||(w={height:l(y),width:d(y),colorType:t.ColorType.RGBA_8888,alphaType:T?t.AlphaType.Premul:t.AlphaType.Unpremul}),w.colorSpace||(w.colorSpace=t.ColorSpace.SRGB);var D={makeTexture:function(){var z=se,Y=z.xe,x=m(Y,Y.createTexture(),w,T);return z.version===2?Y.texImage2D(Y.TEXTURE_2D,0,Y.RGBA,w.width,w.height,0,Y.RGBA,Y.UNSIGNED_BYTE,y):Y.texImage2D(Y.TEXTURE_2D,0,Y.RGBA,Y.RGBA,Y.UNSIGNED_BYTE,y),A(Y,w,T),a(x)},freeSrc:function(){}};return y.constructor.name==="VideoFrame"&&(D.freeSrc=function(){y.close()}),t.Image._makeFromGenerator(w,D)},t.de=function(y){return y?ir(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 m(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 w(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=on.toTypedArray();if(o.length){if(o.length===6||o.length===9)return T(o,"HEAPF32",_t),o.length===6&&t.HEAPF32.set(fs,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=ln.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",Ht):(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),Ht)}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,Ht}function x(o,s){return T(o,"HEAPF32",s||Dt)}function J(o,s,u,p){var P=hn.toTypedArray();return P[0]=o,P[1]=s,P[2]=u,P[3]=p,Dt}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||dn)}function ze(){for(var o=0,s=0;s<arguments.length-1;s+=2)o+=arguments[s]*arguments[s+1];return o}function li(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 hi(o,s){for(var u=li(s[0],s[1],o),p=2;p<s.length;)u=li(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,on,Ht=ge,ln,Dt=ge,hn,ut,Re=ge,Cr,Et=ge,Tr,cn=ge,_r,un=ge,Li,ci=ge,Er,dn=ge,Mr,xr=ge,fs=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}hn=t.Malloc(Float32Array,4),Dt=hn.byteOffset,ln=t.Malloc(Float32Array,16),Ht=ln.byteOffset,on=t.Malloc(Float32Array,9),_t=on.byteOffset,Er=t.Malloc(Float32Array,12),dn=Er.byteOffset,Mr=t.Malloc(Float32Array,12),xr=Mr.byteOffset,ut=t.Malloc(Float32Array,4),Re=ut.byteOffset,Cr=t.Malloc(Float32Array,4),Et=Cr.byteOffset,Tr=t.Malloc(Float32Array,3),cn=Tr.byteOffset,_r=t.Malloc(Float32Array,3),un=_r.byteOffset,Li=t.Malloc(Int32Array,4),ci=Li.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 w(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 w(P,s),w(M,u),w(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),w(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),w(P,s),w(M,u),w(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(m(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)}w(ee,u),w(te,p),w(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,dn),u=He(u,xr),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",ci),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(m(u),"HEAPU32"):ge,ee=p?T(p,"HEAPF32"):ge;P||(P=t.BlendMode.Modulate),this._drawPatch(N,j,ee,P,M),w(ee,p),w(j,u),w(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),w(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",cn),p=T(p,"HEAPF32",un),this._drawShadow(s,u,p,P,ee,te,j),w(ee,M),w(te,N)},t.getShadowLocalBounds=function(s,u,p,P,M,N,j){return s=z(s),p=T(p,"HEAPF32",cn),P=T(P,"HEAPF32",un),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(ci);var u=Li.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(Ht);for(var s=Ht,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),w(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 w(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,ci),u=Li.toTypedArray(),p?(p.set(u),p):u.slice()},t.ImageFilter.MakeDropShadow=function(s,u,p,P,M,N){return M=x(M,Dt),t.ImageFilter._MakeDropShadow(s,u,p,P,M,N)},t.ImageFilter.MakeDropShadowOnly=function(s,u,p,P,M,N){return M=x(M,Dt),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(Dt),he(Dt)},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",ci),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),w(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),w(te.te,p),P&&w(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),w(te.te,p),P&&w(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),w(be.te,p),P&&w(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),w(be.te,M),N&&w(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 w(s,o.ambient),w(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 ui=null;t.MakeImageFromCanvasImageSource=function(o){var s=o.width,u=o.height;ui||(ui=document.createElement("canvas")),ui.width=s,ui.height=u;var p=ui.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(m(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 hi(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 hi(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,S=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*S+$*f,pe=1/Z;return Z===0||pe===1/0?null:(ke*=pe,Xe*=pe,it*=pe,dt*=pe,Te*=pe,$*=pe,f*=pe,S*=pe,F*=pe,k*=pe,L*=pe,B*=pe,s=[N*B-j*L+ee*k,j*F-M*B-ee*S,M*L-N*F+ee*f,N*S-M*k-j*f,p*L-u*B-P*k,s*B-p*F+P*S,u*F-s*L-P*f,s*k-u*S+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 ps=[[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=ps[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),w(I,b)},o.ParagraphBuilder.prototype.setWordsUtf16=function(b){var I=T(b,"HEAPU32");this._setWordsUtf16(I,b&&b.length||0),w(I,b)},o.ParagraphBuilder.prototype.setGraphemeBreaksUtf8=function(b){var I=T(b,"HEAPU32");this._setGraphemeBreaksUtf8(I,b&&b.length||0),w(I,b)},o.ParagraphBuilder.prototype.setGraphemeBreaksUtf16=function(b){var I=T(b,"HEAPU32");this._setGraphemeBreaksUtf16(I,b&&b.length||0),w(I,b)},o.ParagraphBuilder.prototype.setLineBreaksUtf8=function(b){var I=T(b,"HEAPU32");this._setLineBreaksUtf8(I,b&&b.length||0),w(I,b)},o.ParagraphBuilder.prototype.setLineBreaksUtf16=function(b){var I=T(b,"HEAPU32");this._setLineBreaksUtf16(I,b&&b.length||0),w(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),w(j,s),w(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),w(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),w(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),w(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),w(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 S=f[1],F=f[2];return f=f[3],f===1?($=$.toString(16).toLowerCase(),S=S.toString(16).toLowerCase(),F=F.toString(16).toLowerCase(),$=$.length===1?"0"+$:$,S=S.length===1?"0"+S:S,F=F.length===1?"0"+F:F,"#"+$+S+F):(f=f===0||f===1?f:f.toFixed(8),"rgba("+$+", "+S+", "+F+", "+f+")")}function u($){return t.parseColorString($,it)}function p($){if($=dt.exec($),!$)return null;var f=parseFloat($[4]),S=16;switch($[5]){case"em":case"rem":S=16*f;break;case"pt":S=4*f/3;break;case"px":S=f;break;case"pc":S=16*f;break;case"in":S=96*f;break;case"cm":S=96*f/2.54;break;case"mm":S=3.7795275590551185*f;break;case"q":S=.9448818897637796*f;break;case"%":S=.21333333333333335*f}return{style:$[1],variant:$[2],weight:$[3],sizePx:S,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 S=p(f),F=(S.style||"normal")+"|"+(S.variant||"normal")+"|"+(S.weight||"normal"),k=S.family;P(),F=Te[k]?Te[k][F]||Te[k]["*"]:t.Typeface.GetDefault(),S.typeface=F,S&&(this.Fe.setSize(S.sizePx),this.Fe.setTypeface(S.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,S,F,k,L,B){I(this.he,f,S,F,F,0,k,L,B)},this.arcTo=function(f,S,F,k,L){ve(this.he,f,S,F,k,L)},this.beginPath=function(){this.he.delete(),this.he=new t.Path},this.bezierCurveTo=function(f,S,F,k,L,B){var Z=this.he;o([f,S,F,k,L,B])&&(Z.isEmpty()&&Z.moveTo(f,S),Z.cubicTo(f,S,F,k,L,B))},this.clearRect=function(f,S,F,k){this.fe.setStyle(t.PaintStyle.Fill),this.fe.setBlendMode(t.BlendMode.Clear),this.ce.drawRect(t.XYWHRect(f,S,F,k),this.fe),this.fe.setBlendMode(this.ee)},this.clip=function(f,S){typeof f=="string"?(S=f,f=this.he):f&&f.vf&&(f=f.le),f||(f=this.he),f=f.copy(),S&&S.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 S=arguments[1];return new ee(new Uint8ClampedArray(4*f*S),f,S)}throw"createImageData expects 1 or 2 arguments, got "+arguments.length},this.createLinearGradient=function(f,S,F,k){if(o(arguments)){var L=new te(f,S,F,k);return this.Ue.push(L),L}},this.createPattern=function(f,S){return f=new ke(f,S),this.Ue.push(f),f},this.createRadialGradient=function(f,S,F,k,L,B){if(o(arguments)){var Z=new Xe(f,S,F,k,L,B);return this.Ue.push(Z),Z}},this.drawImage=function(f){f instanceof j&&(f=f.Lf());var S=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,S,!1),S.dispose()},this.ellipse=function(f,S,F,k,L,B,Z,pe){I(this.he,f,S,F,k,L,B,Z,pe)},this.jf=function(){var f=this.fe.copy();if(f.setStyle(t.PaintStyle.Fill),l(this.se)){var S=t.multiplyByAlpha(this.se,this.Be);f.setColor(S)}else S=this.se.Me(this.je),f.setColor(t.Color(0,0,0,this.Be)),f.setShader(S);return f.dispose=function(){this.delete()},f},this.fill=function(f,S){if(typeof f=="string"?(S=f,f=this.he):f&&f.vf&&(f=f.le),S==="evenodd")this.he.setFillType(t.FillType.EvenOdd);else{if(S!=="nonzero"&&S)throw"invalid fill rule";this.he.setFillType(t.FillType.Winding)}f||(f=this.he),S=this.jf();var F=this.Re(S);F&&(this.ce.save(),this.Ke(),this.ce.drawPath(f,F),this.ce.restore(),F.dispose()),this.ce.drawPath(f,S),S.dispose()},this.fillRect=function(f,S,F,k){var L=this.jf(),B=this.Re(L);B&&(this.ce.save(),this.Ke(),this.ce.drawRect(t.XYWHRect(f,S,F,k),B),this.ce.restore(),B.dispose()),this.ce.drawRect(t.XYWHRect(f,S,F,k),L),L.dispose()},this.fillText=function(f,S,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,S,F,L),this.ce.restore(),L.dispose()),this.ce.drawTextBlob(f,S,F,k),f.delete(),k.dispose()},this.getImageData=function(f,S,F,k){return(f=this.ce.readPixels(f,S,{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 S=t.Matrix.invert(this.je);return t.Matrix.mapPoints(S,f),f},this.isPointInPath=function(f,S,F){var k=arguments;if(k.length===3)var L=this.he;else if(k.length===4)L=k[0],f=k[1],S=k[2],F=k[3];else throw"invalid arg count, need 3 or 4, got "+k.length;return!isFinite(f)||!isFinite(S)||(F=F||"nonzero",F!=="nonzero"&&F!=="evenodd")?!1:(k=this.Gf([f,S]),f=k[0],S=k[1],L.setFillType(F==="nonzero"?t.FillType.Winding:t.FillType.EvenOdd),L.contains(f,S))},this.isPointInStroke=function(f,S){var F=arguments;if(F.length===2)var k=this.he;else if(F.length===3)k=F[0],f=F[1],S=F[2];else throw"invalid arg count, need 2 or 3, got "+F.length;return!isFinite(f)||!isFinite(S)?!1:(F=this.Gf([f,S]),f=F[0],S=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,S),k.delete(),F)},this.lineTo=function(f,S){ce(this.he,f,S)},this.measureText=function(f){f=this.Fe.getGlyphIDs(f),f=this.Fe.getGlyphWidths(f);let S=0;for(const F of f)S+=F;return{width:S}},this.moveTo=function(f,S){var F=this.he;o([f,S])&&F.moveTo(f,S)},this.putImageData=function(f,S,F,k,L,B,Z){if(o([S,F,k,L,B,Z])){if(k===void 0)this.ce.writePixels(f.data,f.width,f.height,S,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);S=t.XYWHRect(S+k,F+L,B,Z),F=t.Matrix.invert(this.je),this.ce.save(),this.ce.concat(F),this.ce.drawImageRect(f,pe,S,null,!1),this.ce.restore(),f.delete()}}},this.quadraticCurveTo=function(f,S,F,k){var L=this.he;o([f,S,F,k])&&(L.isEmpty()&&L.moveTo(f,S),L.quadTo(f,S,F,k))},this.rect=function(f,S,F,k){var L=this.he;f=t.XYWHRect(f,S,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 S=t.Matrix.multiply(this.je,t.Matrix.invert(f.ag));this.he.transform(S),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 S=t.Matrix.rotated(-f);this.he.transform(S),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 S=this.ye.Le();this.Ue.push(S)}else S=this.ye;this.Ff.push({ag:this.je.slice(),qg:this.Ne.slice(),Eg:this.bf,Dg:S,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,S){if(o(arguments)){var F=t.Matrix.scaled(1/f,1/S);this.he.transform(F),this.ce.scale(f,S),this.je=this.ce.getTotalMatrix()}},this.setLineDash=function(f){for(var S=0;S<f.length;S++)if(!isFinite(f[S])||0>f[S])return;f.length%2===1&&Array.prototype.push.apply(f,f),this.Ne=f},this.setTransform=function(f,S,F,k,L,B){o(arguments)&&(this.resetTransform(),this.transform(f,S,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 S=t.multiplyByAlpha(this.af,this.Be);if(!t.getColorComponents(S)[3]||!(this.Oe||this.Qe||this.Pe))return null;f=f.copy(),f.setColor(S);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 S=t.multiplyByAlpha(this.ye,this.Be);f.setColor(S)}else S=this.ye.Me(this.je),f.setColor(t.Color(0,0,0,this.Be)),f.setShader(S);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 S=this.xf(),F=this.Re(S);F&&(this.ce.save(),this.Ke(),this.ce.drawPath(f,F),this.ce.restore(),F.dispose()),this.ce.drawPath(f,S),S.dispose()},this.strokeRect=function(f,S,F,k){var L=this.xf(),B=this.Re(L);B&&(this.ce.save(),this.Ke(),this.ce.drawRect(t.XYWHRect(f,S,F,k),B),this.ce.restore(),B.dispose()),this.ce.drawRect(t.XYWHRect(f,S,F,k),L),L.dispose()},this.strokeText=function(f,S,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,S,F,L),this.ce.restore(),L.dispose()),this.ce.drawTextBlob(f,S,F,k),f.delete(),k.dispose()},this.translate=function(f,S){if(o(arguments)){var F=t.Matrix.translated(-f,-S);this.he.transform(F),this.ce.translate(f,S),this.je=this.ce.getTotalMatrix()}},this.transform=function(f,S,F,k,L,B){f=[f,F,L,S,k,B,0,0,1],S=t.Matrix.invert(f),this.he.transform(S),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,S){if(f=t.Typeface.MakeTypefaceFromData(f),!f)return null;this.lf.push(f);var F=(S.style||"normal")+"|"+(S.variant||"normal")+"|"+(S.weight||"normal");S=S.family,P(),Te[S]||(Te[S]={"*":f}),Te[S][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,S){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),S=F.encodeToBytes(k,S||.92)){if(F.delete(),f="data:"+f+";base64,",typeof Buffer<"u")S=Buffer.from(S).toString("base64");else{F=0,k=S.length;for(var L="",B;F<k;)B=S.slice(F,Math.min(F+32768,k)),L+=String.fromCharCode.apply(null,B),F+=32768;S=btoa(L)}return f+S}}},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,S){if(!f||S===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");S=S||$.length/(4*f),Object.defineProperty(this,"data",{value:$,writable:!1}),Object.defineProperty(this,"height",{value:S,writable:!1}),Object.defineProperty(this,"width",{value:f,writable:!1})}function te($,f,S,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,S,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,S,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,S,F,k,L){if(o([f,S,F,k,L])){if(0>L)throw"radii cannot be negative";$.isEmpty()&&$.moveTo(f,S),$.arcToTangent(f,S,F,k,L)}}function be($){if(!$.isEmpty()){var f=$.getBounds();(f[3]-f[1]||f[2]-f[0])&&$.close()}}function b($,f,S,F,k,L,B){B=(B-L)/Math.PI*180,L=L/Math.PI*180,f=t.LTRBRect(f-F,S-k,f+F,S+k),1e-5>Math.abs(Math.abs(B)-360)?(S=B/2,$.arcToOval(f,L,S,!1),$.arcToOval(f,L+S,S,!1)):$.arcToOval(f,L,B,!1)}function I($,f,S,F,k,L,B,Z,pe){if(o([f,S,F,k,L,B,Z])){if(0>F||0>k)throw"radii cannot be negative";var $e=2*Math.PI,Kt=B%$e;0>Kt&&(Kt+=$e);var di=Kt-B;B=Kt,Z+=di,!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,S),L=t.Matrix.rotated(-L,f,S),$.transform(L),b($,f,S,F,k,B,Z),$.transform(pe)):b($,f,S,F,k,B,Z)}}function ce($,f,S){o([f,S])&&($.isEmpty()&&$.moveTo(f,S),$.lineTo(f,S))}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,S){S||(S={a:1,c:0,e:0,b:0,d:1,f:0}),this.le.addPath(f.le,[S.a,S.c,S.e,S.b,S.d,S.f])},this.arc=function(f,S,F,k,L,B){I(this.le,f,S,F,F,0,k,L,B)},this.arcTo=function(f,S,F,k,L){ve(this.le,f,S,F,k,L)},this.bezierCurveTo=function(f,S,F,k,L,B){var Z=this.le;o([f,S,F,k,L,B])&&(Z.isEmpty()&&Z.moveTo(f,S),Z.cubicTo(f,S,F,k,L,B))},this.closePath=function(){be(this.le)},this.ellipse=function(f,S,F,k,L,B,Z,pe){I(this.le,f,S,F,k,L,B,Z,pe)},this.lineTo=function(f,S){ce(this.le,f,S)},this.moveTo=function(f,S){var F=this.le;o([f,S])&&F.moveTo(f,S)},this.quadraticCurveTo=function(f,S,F,k){var L=this.le;o([f,S,F,k])&&(L.isEmpty()&&L.moveTo(f,S),L.quadTo(f,S,F,k))},this.rect=function(f,S,F,k){var L=this.le;f=t.XYWHRect(f,S,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(S){S=[S.a,S.c,S.e,S.b,S.d,S.f,0,0,1],o(S)&&(this._transform=S)},this.Le=function(){var S=new ke;return S.Se=this.Se,S.Te=this.Te,S},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,S,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,S,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],Kt=Z[2];Z=Z[3];var di=(Math.abs(B[0])+Math.abs(B[4]))/2;return B=S*di,di*=L,this.Ee(),this.ne=t.Shader.MakeTwoPointConicalGradient([pe,$e],B,[Kt,Z],di,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 S=arguments[0];if(S.prototype.constructor!==Uint8ClampedArray)throw new TypeError("bytes must be given as a Uint8ClampedArray");if($=arguments[1],f=arguments[2],S%4)throw new TypeError("bytes must be given in a multiple of 4");if(S%$)throw new TypeError("bytes must divide evenly by width");if(f&&f!==S/(4*$))throw new TypeError("invalid height given");return new ee(S,$,S/(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=Ts,U=Fs;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,m)=>{d?a(d):n(l?m.buffer:m)})},!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 Xt;c.wasmBinary&&(Xt=c.wasmBinary),c.noExitRuntime,typeof WebAssembly!="object"&&Hi("no native wasm support detected");var yi,Pe,_n=!1,pt,fe,At,$t,W,_e,ne,En;function Mn(){var t=yi.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=$t=new Uint16Array(t),c.HEAPU32=_e=new Uint32Array(t),c.HEAPF32=ne=new Float32Array(t),c.HEAPF64=En=new Float64Array(t)}var Fe,xn=[],Fn=[],Rn=[];function pa(){var t=c.preRun.shift();xn.unshift(t)}var xt=0,Jt=null;function Hi(t){throw c.onAbort&&c.onAbort(t),t="Aborted("+t+")",Pt(t),_n=!0,t=new WebAssembly.RuntimeError(t+". Build with -sASSERTIONS for more info."),E(t),t}function kn(t){return t.startsWith("data:application/octet-stream;base64,")}var Gt;if(Gt="canvaskit.wasm",!kn(Gt)){var Nn=Gt;Gt=c.locateFile?c.locateFile(Nn,ae):ae+Nn}function In(t){if(t==Gt&&Xt)return new Uint8Array(Xt);if(Be)return Be(t);throw"both async and sync fetching of the wasm failed"}function ga(t){if(!Xt&&(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(()=>In(t));if(We)return new Promise((n,a)=>{We(t,l=>n(new Uint8Array(l)),a)})}return Promise.resolve().then(()=>In(t))}function On(t,n,a){return ga(t).then(l=>WebAssembly.instantiate(l,n)).then(l=>l).then(a,l=>{Pt("failed to asynchronously prepare wasm: "+l),Hi(l)})}function ma(t,n){var a=Gt;return Xt||typeof WebAssembly.instantiateStreaming!="function"||kn(a)||a.startsWith("file://")||ye||typeof fetch!="function"?On(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"),On(a,t,n)}))}function ya(t){this.name="ExitStatus",this.message=`Program terminated with exit(${t})`,this.status=t}var Ki=t=>{for(;0<t.length;)t.shift()(c)},Dn=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Ft=(t,n,a)=>{var l=n+a;for(a=n;t[a]&&!(a>=l);)++a;if(16<a-n&&t.buffer&&Dn)return Dn.decode(t.subarray(n,a));for(l="";n<a;){var d=t[n++];if(d&128){var m=t[n++]&63;if((d&224)==192)l+=String.fromCharCode((d&31)<<6|m);else{var A=t[n++]&63;d=(d&240)==224?(d&15)<<12|m<<6|A:(d&7)<<18|m<<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},vi={};function Vi(t){for(;t.length;){var n=t.pop();t.pop()(n)}}function Qt(t){return this.fromWireType(W[t>>2])}var Wt={},Rt={},wi={},Ln=void 0;function Si(t){throw new Ln(t)}function st(t,n,a){function l(y){y=a(y),y.length!==t.length&&Si("Mismatched type converter count");for(var w=0;w<t.length;++w)gt(t[w],y[w])}t.forEach(function(y){wi[y]=n});var d=Array(n.length),m=[],A=0;n.forEach((y,w)=>{Rt.hasOwnProperty(y)?d[w]=Rt[y]:(m.push(y),Wt.hasOwnProperty(y)||(Wt[y]=[]),Wt[y].push(()=>{d[w]=Rt[y],++A,A===m.length&&l(d)}))}),m.length===0&&l(d)}function bi(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 zn=void 0;function xe(t){for(var n="";fe[t];)n+=zn[fe[t++]];return n}var jt=void 0;function we(t){throw new jt(t)}function va(t,n,a={}){var l=n.name;if(t||we(`type "${l}" must have a positive integer typeid pointer`),Rt.hasOwnProperty(t)){if(a.ng)return;we(`Cannot register type '${l}' twice`)}Rt[t]=n,delete wi[t],Wt.hasOwnProperty(t)&&(n=Wt[t],delete Wt[t],n.forEach(d=>d()))}function gt(t,n,a={}){if(!("argPackAdvance"in n))throw new TypeError("registerType registeredInstance requires argPackAdvance");va(t,n,a)}function qi(t){we(t.ae.me.ge.name+" instance already deleted")}var Yi=!1;function Bn(){}function Un(t){--t.count.value,t.count.value===0&&(t.pe?t.we.De(t.pe):t.me.ge.De(t.ie))}function $n(t,n,a){return n===a?t:a.re===void 0?null:(t=$n(t,n,a.re),t===null?null:a.dg(t))}var Gn={},Zt=[];function Xi(){for(;Zt.length;){var t=Zt.pop();t.ae.Xe=!1,t.delete()}}var ei=void 0,ti={};function wa(t,n){for(n===void 0&&we("ptr should not be undefined");t.re;)n=t.gf(n),t=t.re;return ti[n]}function Pi(t,n){return n.me&&n.ie||Si("makeClassHandle requires ptr and ptrType"),!!n.we!=!!n.pe&&Si("Both smartPtrType and smartPtr must be specified"),n.count={value:1},ii(Object.create(t,{ae:{value:n}}))}function ii(t){return typeof FinalizationRegistry>"u"?(ii=n=>n,t):(Yi=new FinalizationRegistry(n=>{Un(n.ae)}),ii=n=>{var a=n.ae;return a.pe&&Yi.register(n,{ae:a},n),n},Bn=n=>{Yi.unregister(n)},ii(t))}function Ct(){}function Wn(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 Ji(t,n){return t=Wn(t),{[t]:function(){return n.apply(this,arguments)}}[t]}function Qi(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 Zi(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`),Qi(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 Sa(t,n,a,l,d,m,A,y){this.name=t,this.constructor=n,this.Ye=a,this.De=l,this.re=d,this.ig=m,this.gf=A,this.dg=y,this.ug=[]}function en(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 ba(t,n){return n===null?(this.Bf&&we(`null is not a valid ${this.name}`),0):(n.ae||we(`Cannot pass "${nn(n)}" as a ${this.name}`),n.ae.ie||we(`Cannot pass deleted object as a pointer of type ${this.name}`),en(n.ae.ie,n.ae.me.ge,this.ge))}function Pa(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 "${nn(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=en(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 Aa(t,n){return n===null?(this.Bf&&we(`null is not a valid ${this.name}`),0):(n.ae||we(`Cannot pass "${nn(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}`),en(n.ae.ie,n.ae.me.ge,this.ge))}function mt(t,n,a,l,d,m,A,y,w,T,D){this.name=t,this.ge=n,this.Bf=a,this.nf=l,this.pf=d,this.tg=m,this.zg=A,this.Nf=y,this.Cf=w,this.vg=T,this.De=D,d||n.re!==void 0?this.toWireType=Pa:(this.toWireType=l?ba:Aa,this.ve=null)}function jn(t,n,a){c.hasOwnProperty(t)||Si("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 Ca=(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")?Ca(t,n):Fe.get(n);return typeof a!="function"&&we(`unknown function pointer with signature ${t}: ${n}`),a}var Hn=void 0;function Kn(t){t=Pr(t);var n=xe(t);return wt(t),n}function ni(t,n){function a(m){d[m]||Rt[m]||(wi[m]?wi[m].forEach(a):(l.push(m),d[m]=!0))}var l=[],d={};throw n.forEach(a),new Hn(`${t}: `+l.map(Kn).join([", "]))}function Ai(t,n,a,l,d){var m=n.length;2>m&&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 w=n[0].name!=="void",T=m-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)Vi(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=w?n[0].fromWireType(J):void 0,x}}function Ci(t,n){for(var a=[],l=0;l<t;l++)a.push(_e[n+4*l>>2]);return a}function Vn(){this.Ce=[void 0],this.Kf=[]}var Qe=new Vn;function tn(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 Ta(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:$t)[l>>1])};case 2:return function(l){return this.fromWireType((a?W:_e)[l>>2])};default:throw new TypeError("Unknown integer type: "+t)}}function ri(t,n){var a=Rt[t];return a===void 0&&we(n+" has unknown type "+Kn(t)),a}function nn(t){if(t===null)return"null";var n=typeof t;return n==="object"||n==="array"||n==="function"?t.toString():""+t}function _a(t,n){switch(n){case 2:return function(a){return this.fromWireType(ne[a>>2])};case 3:return function(a){return this.fromWireType(En[a>>3])};default:throw new TypeError("Unknown float type: "+t)}}function Ea(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 $t[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 m=0;m<t.length;++m){var A=t.charCodeAt(m);if(55296<=A&&57343>=A){var y=t.charCodeAt(++m);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},qn=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,Ma=(t,n)=>{for(var a=t>>1,l=a+n/2;!(a>=l)&&$t[a];)++a;if(a<<=1,32<a-t&&qn)return qn.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},xa=(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},Fa=t=>2*t.length,Ra=(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},ka=(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 m=t.charCodeAt(d);if(55296<=m&&57343>=m){var A=t.charCodeAt(++d);m=65536+((m&1023)<<10)|A&1023}if(W[n>>2]=m,n+=4,n+4>a)break}return W[n>>2]=0,n-l},Na=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},Ia={};function Ti(t){var n=Ia[t];return n===void 0?xe(t):n}var _i=[];function Yn(){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 vn=="object"&&t(vn)?$$$embind_global$$$=vn:typeof self=="object"&&t(self)&&($$$embind_global$$$=self),typeof $$$embind_global$$$=="object"))return $$$embind_global$$$;throw Error("unable to get global object.")}function Oa(t){var n=_i.length;return _i.push(t),n}function Da(t,n){for(var a=Array(t),l=0;l<t;++l)a[l]=ri(_e[n+4*l>>2],"parameter "+l);return a}var Xn=[];function La(t){var n=Array(t+1);return function(a,l,d){n[0]=a;for(var m=0;m<t;++m){var A=ri(_e[l+4*m>>2],"parameter "+m);n[m+1]=A.readValueFromPointer(d),d+=A.argPackAdvance}return a=new(a.bind.apply(a,n)),et(a)}}var Jn={};function za(t){var n=t.getExtension("ANGLE_instanced_arrays");n&&(t.vertexAttribDivisor=function(a,l){n.vertexAttribDivisorANGLE(a,l)},t.drawArraysInstanced=function(a,l,d,m){n.drawArraysInstancedANGLE(a,l,d,m)},t.drawElementsInstanced=function(a,l,d,m,A){n.drawElementsInstancedANGLE(a,l,d,m,A)})}function Ba(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 Ua(t){var n=t.getExtension("WEBGL_draw_buffers");n&&(t.drawBuffers=function(a,l){n.drawBuffersWEBGL(a,l)})}var Qn=1,Ei=[],ht=[],Mi=[],ai=[],tt=[],ct=[],xi=[],yt=[],qe=[],kt=[],Nt=[],Zn={},er={},tr=4;function Se(t){Fi||(Fi=t)}function It(t){for(var n=Qn++,a=t.length;a<n;a++)t[a]=null;return n}function $a(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?Ga(a,n):0}function Ga(t,n){var a=It(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)&&Wa(l),a}function ir(t){return se=yt[t],c.Jg=_=se&&se.xe,!(t&&!_)}function Wa(t){if(t||(t=se),!t.og){t.og=!0;var n=t.xe;za(n),Ba(n),Ua(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,Fi;function nr(t,n){_.bindFramebuffer(t,Mi[n])}function rr(t){_.bindVertexArray(xi[t])}function ar(t){_.clear(t)}function sr(t,n,a,l){_.clearColor(t,n,a,l)}function or(t){_.clearStencil(t)}function lr(t,n){for(var a=0;a<t;a++){var l=W[n+4*a>>2];_.deleteVertexArray(xi[l]),xi[l]=null}}var Ri=[];function hr(t,n,a,l){_.drawElements(t,n,a,l)}function Ot(t,n,a,l){for(var d=0;d<t;d++){var m=_[a](),A=m&&It(l);m?(m.name=A,l[A]=m):Se(1282),W[n+4*d>>2]=A}}function cr(t,n){Ot(t,n,"createVertexArray",xi)}function ur(t,n){_e[t>>2]=n,_e[t+4>>2]=(n-_e[t>>2])/4294967296}function dr(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(m){Se(1280),Pt("GL_INVALID_ENUM in glGet"+a+"v: Unknown object returned from WebGL getParameter("+t+")! (error: "+m+")");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:ur(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 fr(t,n){dr(t,n,0)}function pr(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,ur(a,l)}else Se(1281)}var si=t=>{var n=lt(t)+1,a=Oi(n);return a&&ot(t,fe,a,n),a};function gr(t){var n=Zn[t];if(!n){switch(t){case 7939:n=_.getSupportedExtensions()||[],n=n.concat(n.map(function(l){return"GL_"+l})),n=si(n.join(" "));break;case 7936:case 7937:case 37445:case 37446:(n=_.getParameter(t))||Se(1280),n=n&&si(n);break;case 7938:n=_.getParameter(7938),n=2<=se.version?"OpenGL ES 3.0 ("+n+")":"OpenGL ES 2.0 ("+n+")",n=si(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=si(n);break;default:Se(1280)}Zn[t]=n}return n}function mr(t,n){if(2>se.version)return Se(1282),0;var a=er[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 si(l)}),a=er[t]=a,0>n||n>=a.length?(Se(1281),0):a[n];default:return Se(1280),0}}function yr(t){return t.slice(-1)=="]"&&t.lastIndexOf("[")}function ki(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:$t}function rn(t,n,a,l,d){t=ki(t);var m=31-Math.clz32(t.BYTES_PER_ELEMENT),A=tr;return t.subarray(d>>m,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<<m)+A-1&-A)>>m)}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=[],oi=[],an={},vr=()=>{if(!sn){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 an)an[n]===void 0?delete t[n]:t[n]=an[n];var a=[];for(n in t)a.push(`${n}=${t[n]}`);sn=a}return sn},sn,ja=[null,[],[]],Ni=t=>t%4===0&&(t%100!==0||t%400===0),wr=[31,29,31,30,31,30,31,31,30,31,30,31],Sr=[31,28,31,30,31,30,31,31,30,31,30,31];function Ha(t){var n=Array(lt(t)+1);return ot(t,n,0,n.length),n}var Ka=(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 m(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 w(x){var J=x.He;for(x=new Date(new Date(x.Ie+1900,0,1).getTime());0<J;){var he=x.getMonth(),oe=(Ni(x.getFullYear())?wr:Sr)[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?Ft(fe,T):""},a=a?Ft(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=>m((x.Ie+1900)/100|0,2),"%d":x=>m(x.Df,2),"%e":x=>d(x.Df,2," "),"%g":x=>w(x).toString().substring(2),"%G":x=>w(x),"%H":x=>m(x.tf,2),"%I":x=>(x=x.tf,x==0?x=12:12<x&&(x-=12),m(x,2)),"%j":x=>{for(var J=0,he=0;he<=x.uf-1;J+=(Ni(x.Ie+1900)?wr:Sr)[he++]);return m(x.Df+J,3)},"%m":x=>m(x.uf+1,2),"%M":x=>m(x.Gg,2),"%n":()=>`
3
+ `,"%p":x=>0<=x.tf&&12>x.tf?"AM":"PM","%S":x=>m(x.Hg,2),"%t":()=>" ","%u":x=>x.Ae||7,"%U":x=>m(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&&Ni(x.Ie)||(J=1));else{J=52;var he=(x.Ae+7-x.He-1)%7;(he==4||he==5&&Ni(x.Ie%400-1))&&J++}return m(J,2)},"%w":x=>x.Ae,"%W":x=>m(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=Ha(a),D.length>n?0:(pt.set(D,t),D.length-1)};Ln=c.InternalError=class extends Error{constructor(t){super(t),this.name="InternalError"}};for(var br=Array(256),Ii=0;256>Ii;++Ii)br[Ii]=String.fromCharCode(Ii);zn=br,jt=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||qi(this),this.ae.ef)return this.ae.count.value+=1,this;var t=ii,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||qi(this),this.ae.Xe&&!this.ae.ef&&we("Object already scheduled for deletion"),Bn(this),Un(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||qi(this),this.ae.Xe&&!this.ae.ef&&we("Object already scheduled for deletion"),Zt.push(this),Zt.length===1&&ei&&ei(Xi),this.ae.Xe=!0,this},c.getInheritedInstanceCount=function(){return Object.keys(ti).length},c.getLiveInheritedInstances=function(){var t=[],n;for(n in ti)ti.hasOwnProperty(n)&&t.push(ti[n]);return t},c.flushPendingDeletes=Xi,c.setDelayFunction=function(t){ei=t,Zt.length&&ei&&ei(Xi)},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=Qt,mt.prototype.deleteObject=function(t){t!==null&&t.delete()},mt.prototype.fromWireType=function(t){function n(){return this.pf?Pi(this.ge.Ye,{me:this.tg,ie:a,we:this,pe:t}):Pi(this.ge.Ye,{me:this,ie:t})}var a=this.jg(t);if(!a)return this.Hf(t),null;var l=wa(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=Gn[l],!l)return n.call(this);l=this.nf?l.$f:l.pointerType;var d=$n(a,this.ge,l.ge);return d===null?n.call(this):this.pf?Pi(l.ge.Ye,{me:l,ie:d,we:this,pe:t}):Pi(l.ge.Ye,{me:l,ie:d})},Hn=c.UnboundTypeError=(function(t,n){var a=Ji(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(Vn.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)Ri.push(Array(Ye));var Va=new Float32Array(288);for(Ye=0;288>Ye;++Ye)Tt[Ye]=Va.subarray(0,Ye+1);var qa=new Int32Array(288);for(Ye=0;288>Ye;++Ye)oi[Ye]=qa.subarray(0,Ye+1);var Ya={R:function(){return 0},wb:()=>{},yb:function(){return 0},tb:()=>{},ub:()=>{},S:function(){},vb:()=>{},B:function(t){var n=vi[t];delete vi[t];var a=n.Cf,l=n.De,d=n.Jf,m=d.map(A=>A.mg).concat(d.map(A=>A.xg));st([t],m,A=>{var y={};return d.forEach((w,T)=>{var D=A[T],z=w.kg,Y=w.lg,x=A[T+d.length],J=w.wg,he=w.yg;y[w.fg]={read:oe=>D.fromWireType(z(Y,oe)),write:(oe,He)=>{var ze=[];J(he,oe,x.toWireType(ze,He)),Vi(ze)}}}),[{name:n.name,fromWireType:function(w){var T={},D;for(D in y)T[D]=y[D].read(w);return l(w),T},toWireType:function(w,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 w!==null&&w.push(l,z),z},argPackAdvance:8,readValueFromPointer:Qt,ve:l}]})},nb:function(){},Cb:function(t,n,a,l,d){var m=bi(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>>m])},ve:null})},n:function(t,n,a,l,d,m,A,y,w,T,D,z,Y){D=xe(D),m=Ue(d,m),y&&(y=Ue(A,y)),T&&(T=Ue(w,T)),Y=Ue(z,Y);var x=Wn(D);Zi(x,function(){ni(`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=Ji(x,function(){if(Object.getPrototypeOf(this)!==He)throw new jt("Use 'new' to construct "+D);if(ze.Ge===void 0)throw new jt(D+" has no accessible constructor");var hi=ze.Ge[arguments.length];if(hi===void 0)throw new jt(`Tried to invoke ctor of ${D} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(ze.Ge).toString()}) parameters instead!`);return hi.apply(this,arguments)});var He=Object.create(oe,{constructor:{value:J}});J.prototype=He;var ze=new Sa(D,J,He,Y,he,m,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 li=new mt(D+" const*",ze,!1,!0,!1);return Gn[t]={pointerType:oe,$f:li},jn(x,J),[he,oe,li]})},f:function(t,n,a,l,d,m,A){var y=Ci(a,l);n=xe(n),m=Ue(d,m),st([],[t],function(w){function T(){ni(`Cannot call ${D} due to unbound types`,y)}w=w[0];var D=`${w.name}.${n}`;n.startsWith("@@")&&(n=Symbol[n.substring(2)]);var z=w.ge.constructor;return z[n]===void 0?(T.Ve=a-1,z[n]=T):(Qi(z,n,D),z[n].oe[a-1]=T),st([],y,function(Y){if(Y=[Y[0],null].concat(Y.slice(1)),Y=Ai(D,Y,null,m,A),z[n].oe===void 0?(Y.Ve=a-1,z[n]=Y):z[n].oe[a-1]=Y,w.ge.hf)for(const x of w.ge.hf)x.constructor.hasOwnProperty(n)||(x.constructor[n]=Y);return[]}),[]})},A:function(t,n,a,l,d,m){var A=Ci(n,a);d=Ue(l,d),st([],[t],function(y){y=y[0];var w=`constructor ${y.name}`;if(y.ge.Ge===void 0&&(y.ge.Ge=[]),y.ge.Ge[n-1]!==void 0)throw new jt(`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]=()=>{ni(`Cannot construct ${y.name} due to unbound types`,A)},st([],A,function(T){return T.splice(1,0,null),y.ge.Ge[n-1]=Ai(w,T,null,d,m),[]}),[]})},b:function(t,n,a,l,d,m,A,y){var w=Ci(a,l);n=xe(n),m=Ue(d,m),st([],[t],function(T){function D(){ni(`Cannot call ${z} due to unbound types`,w)}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):(Qi(Y,n,z),Y[n].oe[a-2]=D),st([],w,function(J){return J=Ai(z,J,T,m,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 tn(a),l},toWireType:function(a,l){return et(l)},argPackAdvance:8,readValueFromPointer:Qt,ve:null})},m:function(t,n,a,l){function d(){}a=bi(a),n=xe(n),d.values={},gt(t,{name:n,constructor:d,fromWireType:function(m){return this.constructor.values[m]},toWireType:function(m,A){return A.value},argPackAdvance:8,readValueFromPointer:Ta(n,a,l),ve:null}),Zi(n,d)},c:function(t,n,a){var l=ri(t,"enum");n=xe(n),t=l.constructor,l=Object.create(l.constructor.prototype,{value:{value:a},constructor:{value:Ji(`${l.name}_${n}`,function(){})}}),t.values[a]=l,t[n]=l},U:function(t,n,a){a=bi(a),n=xe(n),gt(t,{name:n,fromWireType:function(l){return l},toWireType:function(l,d){return d},argPackAdvance:8,readValueFromPointer:_a(n,a),ve:null})},y:function(t,n,a,l,d,m){var A=Ci(n,a);t=xe(t),d=Ue(l,d),Zi(t,function(){ni(`Cannot call ${t} due to unbound types`,A)},n-1),st([],A,function(y){return y=[y[0],null].concat(y.slice(1)),jn(t,Ai(t,y,null,d,m),n-1),[]})},E:function(t,n,a,l,d){n=xe(n),d===-1&&(d=4294967295),d=bi(a);var m=y=>y;if(l===0){var A=32-8*a;m=y=>y<<A>>>A}a=n.includes("unsigned")?function(y,w){return w>>>0}:function(y,w){return w},gt(t,{name:n,fromWireType:m,toWireType:a,argPackAdvance:8,readValueFromPointer:Ea(n,d,l!==0),ve:null})},r:function(t,n,a){function l(m){m>>=2;var A=_e;return new d(A.buffer,A[m+1],A[m])}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,m,A,y,w,T,D,z){a=xe(a),m=Ue(d,m),y=Ue(A,y),T=Ue(w,T),z=Ue(D,z),st([t],[n],function(Y){return Y=Y[0],[new mt(a,Y.ge,!1,!1,!0,Y,l,m,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],m=l+4;if(a)for(var A=m,y=0;y<=d;++y){var w=m+y;if(y==d||fe[w]==0){if(A=A?Ft(fe,A,w-A):"",T===void 0)var T=A;else T+="\0",T+=A;A=w+1}}else{for(T=Array(d),y=0;y<d;++y)T[y]=String.fromCharCode(fe[m+y]);T=T.join("")}return wt(l),T},toWireType:function(l,d){d instanceof ArrayBuffer&&(d=new Uint8Array(d));var m=typeof d=="string";m||d instanceof Uint8Array||d instanceof Uint8ClampedArray||d instanceof Int8Array||we("Cannot pass non-string to std::string");var A=a&&m?lt(d):d.length,y=Oi(4+A+1),w=y+4;if(_e[y>>2]=A,a&&m)ot(d,fe,w,A+1);else if(m)for(m=0;m<A;++m){var T=d.charCodeAt(m);255<T&&(wt(w),we("String has UTF-16 code units that do not fit in 8 bits")),fe[w+m]=T}else for(m=0;m<A;++m)fe[w+m]=d[m];return l!==null&&l.push(wt,y),y},argPackAdvance:8,readValueFromPointer:Qt,ve:function(l){wt(l)}})},N:function(t,n,a){if(a=xe(a),n===2)var l=Ma,d=xa,m=Fa,A=()=>$t,y=1;else n===4&&(l=Ra,d=ka,m=Na,A=()=>_e,y=2);gt(t,{name:a,fromWireType:function(w){for(var T=_e[w>>2],D=A(),z,Y=w+4,x=0;x<=T;++x){var J=w+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(w),z},toWireType:function(w,T){typeof T!="string"&&we(`Cannot pass non-string to C++ string type ${a}`);var D=m(T),z=Oi(4+D+n);return _e[z>>2]=D>>y,d(T,z+4,D+n),w!==null&&w.push(wt,z),z},argPackAdvance:8,readValueFromPointer:Qt,ve:function(w){wt(w)}})},C:function(t,n,a,l,d,m){vi[t]={name:xe(n),Cf:Ue(a,l),De:Ue(d,m),Jf:[]}},e:function(t,n,a,l,d,m,A,y,w,T){vi[t].Jf.push({fg:xe(n),mg:a,kg:Ue(l,d),lg:m,xg:A,wg:Ue(y,w),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=ri(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=_i[t],n=Ze(n),a=Ti(a);var m=[];return _e[l>>2]=et(m),t(n,a,m,d)},x:function(t,n,a,l){t=_i[t],n=Ze(n),a=Ti(a),t(n,a,null,l)},d:tn,K:function(t){return t===0?et(Yn()):(t=Ti(t),et(Yn()[t]))},u:function(t,n){var a=Da(t,n),l=a[0];n=l.name+"_$"+a.slice(1).map(function(A){return A.name}).join("_")+"$";var d=Xn[n];if(d!==void 0)return d;var m=Array(t-1);return d=Oa((A,y,w,T)=>{for(var D=0,z=0;z<t-1;++z)m[z]=a[z+1].readValueFromPointer(T+D),D+=a[z+1].argPackAdvance;for(A=A[y].apply(A,m),z=0;z<t-1;++z)a[z+1].cg&&a[z+1].cg(m[z]);if(!l.pg)return l.toWireType(w,A)}),Xn[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=Jn[n];return d||(d=La(n),Jn[n]=d),d(t,a,l)},H:function(){return et([])},g:function(t){return et(Ti(t))},G:function(){return et({})},gb:function(t){return t=Ze(t),!t},D:function(t){var n=Ze(t);Vi(n),tn(t)},l:function(t,n,a){t=Ze(t),n=Ze(n),a=Ze(a),t[n]=a},h:function(t,n){return t=ri(t,"_emval_take_value"),t=t.readValueFromPointer(n),et(t)},kb:function(){return-52},lb:function(){},a:()=>{Hi("")},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?Ft(fe,a):"")},vd:function(t,n){t==35051?_.zf=n:t==35052&&(_.We=n),_.bindBuffer(t,Ei[n])},uc:nr,vc:function(t,n){_.bindRenderbuffer(t,ai[n])},cc:function(t,n){_.bindSampler(t,kt[n])},wd:function(t,n){_.bindTexture(t,tt[n])},Pc:rr,Tc:rr,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,m,A,y,w,T){_.blitFramebuffer(t,n,a,l,d,m,A,y,w,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:ar,ca:sr,da:or,lc:function(t,n,a,l){return _.clientWaitSync(Nt[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,m,A,y){2<=se.version?_.We||!A?_.compressedTexImage2D(t,n,a,l,d,m,A,y):_.compressedTexImage2D(t,n,a,l,d,m,fe,y,A):_.compressedTexImage2D(t,n,a,l,d,m,y?fe.subarray(y,y+A):null)},ha:function(t,n,a,l,d,m,A,y,w){2<=se.version?_.We||!y?_.compressedTexSubImage2D(t,n,a,l,d,m,A,y,w):_.compressedTexSubImage2D(t,n,a,l,d,m,A,fe,w,y):_.compressedTexSubImage2D(t,n,a,l,d,m,A,w?fe.subarray(w,w+y):null)},nc:function(t,n,a,l,d){_.copyBufferSubData(t,n,a,l,d)},ia:function(t,n,a,l,d,m,A,y){_.copyTexSubImage2D(t,n,a,l,d,m,A,y)},ja:function(){var t=It(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=It(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=Ei[l];d&&(_.deleteBuffer(d),d.name=0,Ei[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=Mi[l];d&&(_.deleteFramebuffer(d),d.name=0,Mi[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=ai[l];d&&(_.deleteRenderbuffer(d),d.name=0,ai[l]=null)}},dc:function(t,n){for(var a=0;a<t;a++){var l=W[n+4*a>>2],d=kt[l];d&&(_.deleteSampler(d),d.name=0,kt[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=Nt[t];n?(_.deleteSync(n),n.name=0,Nt[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:lr,Uc:lr,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=Ri[t],l=0;l<t;l++)a[l]=W[n+4*l>>2];_.drawBuffers(a)},ua:hr,Oc:function(t,n,a,l,d){_.drawElementsInstanced(t,n,a,l,d)},Mc:function(t,n,a,l,d,m,A){_.If.drawElementsInstancedBaseVertexBaseInstanceWEBGL(t,n,a,l,d,m,A)},Dc:function(t,n,a,l,d,m){hr(t,l,d,m)},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=It(Nt),t.name=n,Nt[n]=t,n):0},xa:function(){_.finish()},ya:function(){_.flush()},zc:function(t,n,a,l){_.framebufferRenderbuffer(t,n,a,ai[l])},Ac:function(t,n,a,l,d){_.framebufferTexture2D(t,n,a,tt[l],d)},za:function(t){_.frontFace(t)},Aa:function(t,n){Ot(t,n,"createBuffer",Ei)},Bc:function(t,n){Ot(t,n,"createFramebuffer",Mi)},$b:function(t,n){Ot(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=It(qe);l.name=d,qe[d]=l,W[n+4*a>>2]=d}},Cc:function(t,n){Ot(t,n,"createRenderbuffer",ai)},ec:function(t,n){Ot(t,n,"createSampler",kt)},Ba:function(t,n){Ot(t,n,"createTexture",tt)},Rc:cr,Vc:cr,qc:function(t){_.generateMipmap(t)},Ca:function(t,n,a){a?W[a>>2]=_.getBufferParameter(t,n):Se(1281)},Da:function(){var t=_.getError()||Fi;return Fi=0,t},Ea:function(t,n){dr(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:fr,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>=Qn)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:pr,Qb:pr,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:gr,Sc:mr,La:function(t,n){if(n=n?Ft(fe,n):"",t=ht[t]){var a=t,l=a.ff,d=a.Qf,m;if(!l)for(a.ff=l={},a.Pf={},m=0;m<_.getProgramParameter(a,35718);++m){var A=_.getActiveUniform(a,m),y=A.name;A=A.size;var w=yr(y);w=0<w?y.slice(0,w):y;var T=a.Ef;for(a.Ef+=A,d[w]=[A,T],y=0;y<A;++y)l[T]=y,a.Pf[T++]=w}if(a=t.ff,l=0,d=n,m=yr(n),0<m&&(l=parseInt(n.slice(m+1))>>>0,d=n.slice(0,m)),(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=Ri[n],d=0;d<n;d++)l[d]=W[a+4*d>>2];_.invalidateFramebuffer(t,l)},Ob:function(t,n,a,l,d,m,A){for(var y=Ri[n],w=0;w<n;w++)y[w]=W[a+4*w>>2];_.invalidateSubFramebuffer(t,y,l,d,m,A)},jc:function(t){return _.isSync(Nt[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,m){_.Mf.multiDrawArraysInstancedBaseInstanceWEBGL(t,W,n>>2,W,a>>2,W,l>>2,_e,d>>2,m)},Ic:function(t,n,a,l,d,m,A,y){_.Mf.multiDrawElementsInstancedBaseVertexBaseInstanceWEBGL(t,W,n>>2,a,W,l>>2,W,d>>2,W,m>>2,_e,A>>2,y)},Pa:function(t,n){t==3317&&(tr=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,m,A){if(2<=se.version)if(_.zf)_.readPixels(t,n,a,l,d,m,A);else{var y=ki(m);_.readPixels(t,n,a,l,d,m,y,A>>31-Math.clz32(y.BYTES_PER_ELEMENT))}else(A=rn(m,d,a,l,A))?_.readPixels(t,n,a,l,d,m,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(kt[t],n,a)},gc:function(t,n,a){_.samplerParameteri(kt[t],n,a)},hc:function(t,n,a){_.samplerParameteri(kt[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="",m=0;m<n;++m){var A=l?W[l+4*m>>2]:-1,y=W[a+4*m>>2];A=y?Ft(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,m,A,y,w){if(2<=se.version)if(_.We)_.texImage2D(t,n,a,l,d,m,A,y,w);else if(w){var T=ki(y);_.texImage2D(t,n,a,l,d,m,A,y,T,w>>31-Math.clz32(T.BYTES_PER_ELEMENT))}else _.texImage2D(t,n,a,l,d,m,A,y,null);else _.texImage2D(t,n,a,l,d,m,A,y,w?rn(y,A,l,d,w):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,m,A,y,w){if(2<=se.version)if(_.We)_.texSubImage2D(t,n,a,l,d,m,A,y,w);else if(w){var T=ki(y);_.texSubImage2D(t,n,a,l,d,m,A,y,T,w>>31-Math.clz32(T.BYTES_PER_ELEMENT))}else _.texSubImage2D(t,n,a,l,d,m,A,y,null);else T=null,w&&(T=rn(y,A,d,m,w)),_.texSubImage2D(t,n,a,l,d,m,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=oi[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=oi[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=oi[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 m=0;m<4*n;m+=4){var A=a+m;l[m]=d[A],l[m+1]=d[A+1],l[m+2]=d[A+2],l[m+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=oi[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],m=0;m<4*n;m+=4)d[m]=ne[l+4*m>>2],d[m+1]=ne[l+(4*m+4)>>2],d[m+2]=ne[l+(4*m+8)>>2],d[m+3]=ne[l+(4*m+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],m=0;m<9*n;m+=9)d[m]=ne[l+4*m>>2],d[m+1]=ne[l+(4*m+4)>>2],d[m+2]=ne[l+(4*m+8)>>2],d[m+3]=ne[l+(4*m+12)>>2],d[m+4]=ne[l+(4*m+16)>>2],d[m+5]=ne[l+(4*m+20)>>2],d[m+6]=ne[l+(4*m+24)>>2],d[m+7]=ne[l+(4*m+28)>>2],d[m+8]=ne[l+(4*m+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],m=ne;l>>=2;for(var A=0;A<16*n;A+=16){var y=l+A;d[A]=m[y],d[A+1]=m[y+1],d[A+2]=m[y+2],d[A+3]=m[y+3],d[A+4]=m[y+4],d[A+5]=m[y+5],d[A+6]=m[y+6],d[A+7]=m[y+7],d[A+8]=m[y+8],d[A+9]=m[y+9],d[A+10]=m[y+10],d[A+11]=m[y+11],d[A+12]=m[y+12],d[A+13]=m[y+13],d[A+14]=m[y+14],d[A+15]=m[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,m){_.vertexAttribPointer(t,n,a,!!l,d,m)},fd:function(t,n,a,l){_.viewport(t,n,a,l)},kc:function(t,n,a,l){_.waitSync(Nt[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)-yi.buffer.byteLength+65535>>>16;try{yi.grow(d),Mn();var m=1;break e}catch{}m=void 0}if(m)return!0}return!1},hb:function(){return se?se.handle:0},rb:(t,n)=>{var a=0;return vr().forEach(function(l,d){var m=n+a;for(d=_e[t+4*d>>2]=m,m=0;m<l.length;++m)pt[d++>>0]=l.charCodeAt(m);pt[d>>0]=0,a+=l.length+1}),0},sb:(t,n)=>{var a=vr();_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 ya(t))},M:()=>52,jb:function(){return 52},xb:()=>52,mb:function(){return 70},Q:(t,n,a,l)=>{for(var d=0,m=0;m<a;m++){var A=_e[n>>2],y=_e[n+4>>2];n+=8;for(var w=0;w<y;w++){var T=fe[A+w],D=ja[t];T===0||T===10?((t===1?ue:Pt)(Ft(D,0)),D.length=0):D.push(T)}d+=y}return _e[l>>2]=d,0},yd:nr,ib:ar,xd:sr,Kb:or,L:fr,P:gr,fb:mr,Ib:ss,j:ts,o:rs,k:Xa,I:cs,Hb:os,Fb:ds,W:ls,V:us,O:es,i:ns,w:Za,v:Qa,s:is,Gb:hs,Jb:as,Lb:Ja,ob:(t,n,a,l)=>Ka(t,n,a,l)};(function(){function t(a){if(Pe=a=a.exports,yi=Pe.zd,Mn(),Fe=Pe.Cd,Fn.unshift(Pe.Ad),xt--,c.monitorRunDependencies&&c.monitorRunDependencies(xt),xt==0&&Jt){var l=Jt;Jt=null,l()}return a}var n={a:Ya};if(xt++,c.monitorRunDependencies&&c.monitorRunDependencies(xt),c.instantiateWasm)try{return c.instantiateWasm(n,t)}catch(a){Pt("Module.instantiateWasm callback failed with error: "+a),E(a)}return ma(n,function(a){t(a.instance)}).catch(E),{}})();var Oi=c._malloc=t=>(Oi=c._malloc=Pe.Bd)(t),wt=c._free=t=>(wt=c._free=Pe.Dd)(t),Pr=t=>(Pr=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,m,A)=>(c.dynCall_vijiii=Pe.Kd)(t,n,a,l,d,m,A),c.dynCall_viiiiij=(t,n,a,l,d,m,A,y)=>(c.dynCall_viiiiij=Pe.Ld)(t,n,a,l,d,m,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,m,A)=>(c.dynCall_jiiiiii=Pe.Od)(t,n,a,l,d,m,A),c.dynCall_jiiiiji=(t,n,a,l,d,m,A,y)=>(c.dynCall_jiiiiji=Pe.Pd)(t,n,a,l,d,m,A,y),c.dynCall_ji=(t,n)=>(c.dynCall_ji=Pe.Qd)(t,n),c.dynCall_iijj=(t,n,a,l,d,m)=>(c.dynCall_iijj=Pe.Rd)(t,n,a,l,d,m),c.dynCall_iiiji=(t,n,a,l,d,m)=>(c.dynCall_iiiji=Pe.Sd)(t,n,a,l,d,m),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,m,A,y,w)=>(c.dynCall_iijjiii=Pe.Ud)(t,n,a,l,d,m,A,y,w),c.dynCall_iij=(t,n,a,l)=>(c.dynCall_iij=Pe.Vd)(t,n,a,l),c.dynCall_vijjjii=(t,n,a,l,d,m,A,y,w,T)=>(c.dynCall_vijjjii=Pe.Wd)(t,n,a,l,d,m,A,y,w,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,m,A)=>(c.dynCall_viijii=Pe.Yd)(t,n,a,l,d,m,A),c.dynCall_iiiiij=(t,n,a,l,d,m,A)=>(c.dynCall_iiiiij=Pe.Zd)(t,n,a,l,d,m,A),c.dynCall_iiiiijj=(t,n,a,l,d,m,A,y,w)=>(c.dynCall_iiiiijj=Pe._d)(t,n,a,l,d,m,A,y,w),c.dynCall_iiiiiijj=(t,n,a,l,d,m,A,y,w,T)=>(c.dynCall_iiiiiijj=Pe.$d)(t,n,a,l,d,m,A,y,w,T);function Xa(t,n,a,l){var d=Oe();try{return Fe.get(t)(n,a,l)}catch(m){if(De(d),m!==m+0)throw m;Ie(1,0)}}function Ja(t,n,a,l,d,m,A,y,w,T){var D=Oe();try{Fe.get(t)(n,a,l,d,m,A,y,w,T)}catch(z){if(De(D),z!==z+0)throw z;Ie(1,0)}}function Qa(t,n,a,l){var d=Oe();try{Fe.get(t)(n,a,l)}catch(m){if(De(d),m!==m+0)throw m;Ie(1,0)}}function Za(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 es(t){var n=Oe();try{Fe.get(t)()}catch(a){if(De(n),a!==a+0)throw a;Ie(1,0)}}function ts(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 is(t,n,a,l,d){var m=Oe();try{Fe.get(t)(n,a,l,d)}catch(A){if(De(m),A!==A+0)throw A;Ie(1,0)}}function ns(t,n){var a=Oe();try{Fe.get(t)(n)}catch(l){if(De(a),l!==l+0)throw l;Ie(1,0)}}function rs(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 as(t,n,a,l,d,m,A){var y=Oe();try{Fe.get(t)(n,a,l,d,m,A)}catch(w){if(De(y),w!==w+0)throw w;Ie(1,0)}}function ss(t){var n=Oe();try{return Fe.get(t)()}catch(a){if(De(n),a!==a+0)throw a;Ie(1,0)}}function os(t,n,a,l,d,m){var A=Oe();try{return Fe.get(t)(n,a,l,d,m)}catch(y){if(De(A),y!==y+0)throw y;Ie(1,0)}}function ls(t,n,a,l,d,m,A,y){var w=Oe();try{return Fe.get(t)(n,a,l,d,m,A,y)}catch(T){if(De(w),T!==T+0)throw T;Ie(1,0)}}function hs(t,n,a,l,d,m){var A=Oe();try{Fe.get(t)(n,a,l,d,m)}catch(y){if(De(A),y!==y+0)throw y;Ie(1,0)}}function cs(t,n,a,l,d){var m=Oe();try{return Fe.get(t)(n,a,l,d)}catch(A){if(De(m),A!==A+0)throw A;Ie(1,0)}}function us(t,n,a,l,d,m,A,y,w,T){var D=Oe();try{return Fe.get(t)(n,a,l,d,m,A,y,w,T)}catch(z){if(De(D),z!==z+0)throw z;Ie(1,0)}}function ds(t,n,a,l,d,m,A){var y=Oe();try{return Fe.get(t)(n,a,l,d,m,A)}catch(w){if(De(y),w!==w+0)throw w;Ie(1,0)}}var Di;Jt=function t(){Di||Ar(),Di||(Jt=t)};function Ar(){function t(){if(!Di&&(Di=!0,c.calledRun=!0,!_n)){if(Ki(Fn),v(c),c.onRuntimeInitialized&&c.onRuntimeInitialized(),c.postRun)for(typeof c.postRun=="function"&&(c.postRun=[c.postRun]);c.postRun.length;){var n=c.postRun.shift();Rn.unshift(n)}Ki(Rn)}}if(!(0<xt)){if(c.preRun)for(typeof c.preRun=="function"&&(c.preRun=[c.preRun]);c.preRun.length;)pa();Ki(xn),0<xt||(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 Ar(),h.ready})})();g.exports=i})(wn)),wn.exports}var ks=Rs(),Ns=Ps(ks);class ia{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 qt{static slide(e){let i=Lt.linear;return typeof e.easing=="string"?i=Lt.fromTypeAsString(e.easing):e.easing!==void 0&&(i=e.easing),new ra(e.direction,e.duration,i)}static none(){return new na}}class na extends qt{constructor(){super(),this.type=St.None,this.duration=NaN,this.easing=Lt.none}}class ra extends qt{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 aa{constructor(e,i){this.scene=e,this.transition=i}}class Is{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 gi({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=qt.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=qt.slide({direction:e.direction,duration:e.duration,easing:Lt.fromTypeAsString(e.easingType)})}this.game.sceneManager.present(e.uuid,i)}}class Os{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 v=c.zPosition-h.zPosition;return v!==0?v: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 v=c.zPosition-h.zPosition;return v!==0?v: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,v;e.dragging===!1?(e.dragging=!0,h=!0,c=r.offsetX-e.pressedInitialPointerOffset.x,v=r.offsetY-e.pressedInitialPointerOffset.y):(c=r.offsetX-e.draggingLastPointerOffset.x,v=r.offsetY-e.draggingLastPointerOffset.y),e.position.x+=c,e.position.y+=v,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 v=c.zPosition-h.zPosition;return v!==0?v: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 v=c.zPosition-h.zPosition;return v!==0?v: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),v=e.circleOfRadius;if(!v)throw"circleOfRadius is undefined";const E={x:c.xMin+v*e.absoluteScale,y:c.yMin+v*e.absoluteScale};return Math.sqrt(Math.pow(i-E.x,2)+Math.pow(r-E.y,2))<=v*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,v=i.offsetY;const E=V.calculateNodeAbsoluteBoundingBox(e);V.nodeOrAncestorHasBeenRotated(e)&&V.calculateRotationTransforms(e).forEach(ie=>{const le=V.rotatePoint({x:c,y:v},-ie.radians,ie.center);c=le.x,v=le.y});const O=(c-E.xMin)/(E.xMax-E.xMin)*r,G=(v-E.yMin)/(E.yMax-E.yMin)*h;return{x:O,y:G}}}class Ds{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 aa(r,i??qt.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 v={type:"ScenePresent",target:r,uuid:r.uuid,...V.createFrameUpdateTimestamps(),transitionType:i?.type??St.None,duration:i?.duration,direction:c,easingType:i?.easing?Lt.toTypeAsString(i.easing):void 0};this.game.eventStore.addEvent(v)}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 Yt({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 mi({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(v=>v===void 0?1:0).reduce((v,E)=>v+E);return new Promise((v,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:v};break}case 4:{this.pendingScreenshot={rect:[],promiseResolve:v};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,v=e.rect[2]*m2c2Globals.canvasScale,E=e.rect[3]*m2c2Globals.canvasScale,O=[h,c,h+v,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 Yt({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 Cn={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 $i{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]),v=Object.getPrototypeOf(c);if(v.compileShader&&!v.m2c2ModifiedCompileShader){v.m2c2ModifiedCompileShader=!0;const E=v.compileShader;v.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 Ls{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=$i.getRendererString()}catch{this.webGlRendererInfo="err"}finally{$i.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={},v=Object.entries(this.game.options.trialSchema);for(const[E]of v)c[E]=null;this.data.trials.push({data_type:"trial",document_uuid:zt.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:zt.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[v]of c)h[v]=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,v]of Object.entries(h))this.validateAndSetScoringVariable(c,v);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:Cn}}}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:Cn}}}}}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:Cn}}}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 zs{constructor(e){if(this.type=fi.Game,this.sessionUuid="",this.uuid=zt.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 Wr,this.nodeFactory=new jr,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(!zt.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 Ds(this),this.dataManager=new Ls(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 v=h.slice(0,c+1).join("/");return`${r.origin}/${v}`.replace(/\/*$/,"")}addLocalizationParametersToGameParameters(){this.options.parameters={...this.options.parameters,...Bi.makeLocalizationParameters()}}async init(){return this.initialize()}loadCanvasKit(e){return Ns({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 v=await import.meta.resolve("@m2c2kit/core");c=e.getImportedModuleBaseUrl("@m2c2kit/core",v)+"/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 Bi(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 Hr(this,e),this.imageManager=new mn(this,e),this.soundManager=new ia(this,e),this.eventMaterializer=new Is({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 v;if(this.options.parameters[h].type!==void 0&&c!==void 0)try{v=V.convertValueToType(c,this.options.parameters[h].type)}catch(E){throw new C("Error setting parameter "+h+": "+E.message)}else v=c;this.options.parameters[h].default=v}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(v=>v.name===e).find(Boolean):this.entryScene!==void 0?typeof this.entryScene=="object"?r=this.entryScene:r=this.scenes.filter(v=>v.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 v=document.createElement("button");v.id="log-events",v.title="log events to console",v.innerText="\u{1F4C4}",v.style.marginRight="4px",r.appendChild(v),v.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 v=document.createElement("input");v.id="time-stepping-steps-input",v.title="steps",v.style.width="40px",v.style.marginRight="4px",v.setAttribute("readonly","true"),r.appendChild(v);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,v=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,v,32,K),e.drawCircle(c,v,32,ie),e.drawCircle(c,v,32,le),e.drawCircle(c,v,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,v,K,at),e.drawText("abc",c,v,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(v=>v!=="__outgoingSceneSnapshot").forEach(v=>{if(!i.includes(v)&&r[v].status===nt.Ready){const E=r[v].canvaskitImage;if(!E)throw new C(`image ${v} 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:v,...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:v,...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 v=document.getElementsByTagName("canvas");let E=new Array;for(let G=0;G<v.length;G++)E.push(v[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=v[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 v=r/i;window.innerHeight/window.innerWidth<v?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,$i.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 Os(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!==fi.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:fi.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 v=c.filter(E=>E.name===i).find(Boolean);if(v===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`);v.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 Bs(){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:[]}}Bs();const sa=class da{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 da(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)}};sa._timers=new Array;let Us=sa;const Tn=class fa{static setSeed(e){this.seededPRNG=Ks(e),this.randomFunction=this.seededPRNG}static useDefaultRandom(){this.randomFunction=Math.random}static useSeededRandom(){if(this.seededPRNG===null)throw new C("Cannot use seeded random function because no seed has been set. Call setSeed() first.");this.randomFunction=this.seededPRNG}static random(){return this.randomFunction()}static singleFromRange(e,i){if(!Number.isInteger(e)||!Number.isInteger(i))throw new C("All inputs must be integers");if(i<e)throw new C(`maximumInclusive (${i}) must be >= minimumInclusive (${e})`);return Math.floor(this.randomFunction()*(i-e+1))+e}static SingleFromRange(e,i){return this.singleFromRange(e,i)}static fromRangeWithoutReplacement(e,i,r){if(!Number.isInteger(e)||!Number.isInteger(i)||!Number.isInteger(r))throw new C("All inputs must be integers");const h=r-i+1;if(e>h)throw new C(`number of requested draws (n = ${e}) is greater than number of integers in range [${i}, ${r}]`);const c=new Set;for(let v=h-e;v<h;v++){const E=fa.singleFromRange(i,i+v);c.has(E)?c.add(i+v):c.add(E)}return Array.from(c)}static FromRangeWithoutReplacement(e,i,r){return this.fromRangeWithoutReplacement(e,i,r)}static fromGridWithoutReplacement(e,i,r,h){const c=new Array,v=i*r-1,E=this.fromRangeWithoutReplacement(e,0,v);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,v)[0];while(E.includes(G));E[O]=G}}return c}static FromGridWithoutReplacement(e,i,r,h){return this.fromGridWithoutReplacement(e,i,r,h)}};Tn.randomFunction=Math.random,Tn.seededPRNG=null;let $s=Tn;const Gs=[],Mt=256,oa=6,Ws=52,js=Math.pow(Mt,oa),la=Math.pow(2,Ws),Hs=la*2,Ut=Mt-1;function Ks(g){const e=[];ha(g,e);const i=new Vs(e),r=(()=>{let h=i.g(oa),c=js,v=0;for(;h<la;)h=(h+v)*Mt,c*=Mt,v=i.g(1);for(;h>=Hs;)h/=2,c/=2,v>>>=1;return(h+v)/c});return r.int32=()=>i.g(4)|0,r.quick=()=>i.g(4)/4294967296,r.double=r,ha(ca(i.S),Gs),r}class Vs{constructor(e){this.i=0,this.j=0,this.S=[];let i,r=e.length;const h=this.S;r||(e=[r++]);for(let c=0;c<Mt;c++)h[c]=c;for(let c=0,v=0;c<Mt;c++)i=h[c],v=Ut&v+e[c%r]+i,h[c]=h[v],h[v]=i;this.g(Mt)}g(e){let i=0,r=this.i,h=this.j;const c=this.S;for(;e--;){const v=c[r=Ut&r+1],E=c[h=Ut&h+v];c[r]=E,c[h]=v,i=i*Mt+c[Ut&E+v]}return this.i=r,this.j=h,i}}function ha(g,e){let i=0,r=0;for(;r<g.length;)e[Ut&r]=Ut&(i^=e[Ut&r]*19)+g.charCodeAt(r),r++;return ca(e)}function ca(g){const e=Array.prototype.slice.call(g,0);return String.fromCharCode.apply(null,e)}class qs 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 Ys 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=zt.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(v=>[`${v}/${h};codecs=${c}`])))),...new Set(i.flatMap(h=>r.flatMap(c=>r.flatMap(v=>e.flatMap(E=>[`${E}/${h};codecs="${c}, ${v}"`])))))].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 Xs{static create(e){return new Array}}console.log("\u26AA @m2c2kit/core version 0.3.33 (92cfffbe)");export{X as Action,fi as ActivityType,Ne as CanvasKitHelpers,ys as ColorfulMutablePath,Ss as Composite,Q as Constants,Ge as ConstraintType,Ir as CustomAction,Gr as Dimensions,Lt as Easings,q as Equal,bs as Equals,Wr as EventStore,vt as EventStoreMode,Br as FadeAlphaAction,Hr as FontManager,zs as Game,kr as GroupAction,Bi as I18n,mn as ImageManager,Wi as Label,Vt as LabelHorizontalAlignmentMode,$r as LayoutConstraint,Us as LegacyTimer,C as M2Error,H as M2EventType,nt as M2ImageStatus,ft as M2Node,jr as M2NodeFactory,de as M2NodeType,je as M2SoundStatus,V as M2c2KitHelpers,Lr as MoveAction,Gi as MutablePath,na as NoneTransition,Or as PlayAction,$s as RandomDraws,pn as RepeatAction,Nr as RepeatForeverAction,Ur as RotateAction,zr as ScaleAction,Yt as Scene,aa as SceneTransition,Rr as SequenceAction,gi as Shape,Ke as ShapeType,ra as SlideTransition,ia as SoundManager,qs as SoundPlayer,Ys as SoundRecorder,mi as Sprite,Xs as Story,ji as TextLine,Ve as Timer,qt as Transition,bt as TransitionDirection,St as TransitionType,zt as Uuid,Dr as WaitAction,R as WebColors,$i as WebGlInfo,Bt as handleInterfaceOptions};