@m2c2kit/addons 0.1.10 → 0.3.2

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +409 -222
  2. package/dist/index.js +1234 -1
  3. package/package.json +11 -13
package/dist/index.js CHANGED
@@ -1,2 +1,1235 @@
1
- var t,e,n;!function(t){t.sequence="Sequence",t.group="Group",t.wait="Wait",t.custom="Custom",t.move="Move",t.scale="Scale"}(t||(t={}));class r{constructor(t=!1){this.startOffset=-1,this.endOffset=-1,this.started=!1,this.running=!1,this.completed=!1,this.runStartTime=-1,this.duration=0,this.isParent=!1,this.isChild=!1,this.runDuringTransition=t}static Move(t){var e;return new l(t.point,t.duration,null!==(e=t.runDuringTransition)&&void 0!==e&&e)}static Wait(t){var e;return new s(t.duration,null!==(e=t.runDuringTransition)&&void 0!==e&&e)}static Custom(t){var e;return new a(t.callback,null!==(e=t.runDuringTransition)&&void 0!==e&&e)}static Scale(t){return new u(t.scale,t.duration,t.runDuringTransition)}static Sequence(t){const e=new i(t);return e.children=t,e}static Group(t){const e=new o(t);return e.children=t,e}initialize(e,n){this.assignParents(this,this,n);const i=this.flattenActions(this);return i.forEach((t=>t.duration=this.calculateDuration(t))),this.calculateStartEndOffsets(this),i.filter((e=>e.type!==t.group&&e.type!==t.sequence)).map((t=>r.cloneAction(t,n)))}static cloneAction(e,n){let i;switch(e.type){case t.sequence:{const t=e.children.map((t=>r.cloneAction(t,n)));i=r.Sequence(t);break}case t.group:{const t=e.children.map((t=>r.cloneAction(t,n)));i=r.Sequence(t);break}case t.move:{const t=e;i=r.Move({point:t.point,duration:t.duration,runDuringTransition:t.runDuringTransition});break}case t.custom:{const t=e;i=r.Custom({callback:t.callback,runDuringTransition:t.runDuringTransition});break}case t.scale:{const t=e;i=r.Scale({scale:t.scale,duration:t.duration,runDuringTransition:t.runDuringTransition});break}case t.wait:{const t=e;i=r.Wait({duration:t.duration,runDuringTransition:t.runDuringTransition});break}default:throw new Error("unknown action")}return void 0!==n&&(i.key=n),i.startOffset=e.startOffset,i.endOffset=e.endOffset,i}static evaluateAction(e,n,r,i){if(r<e.runStartTime+e.startOffset)return;if(r>=e.runStartTime+e.startOffset&&r<=e.runStartTime+e.startOffset+e.duration?e.running=!0:e.running=!1,!1===e.running&&!0===e.completed)return;const o=r-(e.runStartTime+e.startOffset);if(e.type===t.custom){const t=e;t.callback(),t.running=!1,t.completed=!0}if(e.type===t.wait){const t=e;r>e.runStartTime+e.startOffset+e.duration&&(t.running=!1,t.completed=!0)}if(e.type===t.move){const t=e;t.started||(t.dx=t.point.x-n.position.x,t.dy=t.point.y-n.position.y,t.started=!0),o<t.duration?(n.position.x=n.position.x+t.dx*(i/t.duration),n.position.y=n.position.y+t.dy*(i/t.duration)):(n.position.x=t.point.x,n.position.y=t.point.y,t.running=!1,t.completed=!0)}if(e.type===t.scale){const t=e;t.started||(t.delta=t.scale-n.scale,t.started=!0),o<t.duration?n.scale=n.scale+t.delta*(i/t.duration):(n.scale=t.scale,t.running=!1,t.completed=!0)}}calculateDuration(e){return e.type===t.group?e.children.map((t=>this.calculateDuration(t))).reduce(((t,e)=>Math.max(t,e)),0):e.type===t.sequence?e.children.map((t=>this.calculateDuration(t))).reduce(((t,e)=>t+e),0):e.duration}calculateStartEndOffsets(e){var n,r,i;let o=0;if(void 0!==e.parent&&(o=e.parent.startOffset),(null===(n=e.parent)||void 0===n?void 0:n.type)===t.group)e.startOffset=o,e.endOffset=e.startOffset+e.duration;else if((null===(r=e.parent)||void 0===r?void 0:r.type)===t.sequence){const t=e.parent;let n=0;for(const r of t.children){if(r===e)break;n+=r.duration}e.startOffset=n,e.endOffset=e.startOffset+e.duration}else e.startOffset=o,e.endOffset=e.startOffset+e.duration;e.isParent&&(null===(i=e.children)||void 0===i||i.forEach((t=>this.calculateStartEndOffsets(t))))}flattenActions(t,e){if(e||(e=new Array).push(t),t.isParent){const n=t,r=n.children;e.push(...r),n.children.filter((t=>t.isParent)).forEach((t=>this.flattenActions(t,e)))}return e}assignParents(t,e,n){if(void 0!==n&&(t.key=n),e||((e=t).parent=void 0),t.isParent){const r=t;r.children.forEach((e=>{e.parent=t})),r.children.filter((t=>t.isParent)).forEach((t=>this.assignParents(t,e,n)))}}}class i extends r{constructor(e){super(),this.type=t.sequence,this.children=e,this.isParent=!0}}class o extends r{constructor(e){super(),this.type=t.group,this.children=new Array,this.children=e,this.isParent=!0}}class a extends r{constructor(e,n=!1){super(n),this.type=t.custom,this.callback=e,this.isParent=!1,this.duration=0}}class s extends r{constructor(e,n){super(n),this.type=t.wait,this.duration=e,this.isParent=!1}}class l extends r{constructor(e,n,r){super(r),this.type=t.move,this.dx=0,this.dy=0,this.duration=n,this.point=e,this.isParent=!1}}class u extends r{constructor(e,n,r=!1){super(r),this.type=t.scale,this.delta=0,this.duration=n,this.scale=e,this.isParent=!1}}!function(t){t.game="Game",t.survey="Survey"}(e||(e={})),function(t){t.activityData="ActivityData",t.activityLifecycle="ActivityLifecycle",t.sessionLifecycle="SessionLifecycle"}(n||(n={}));globalThis.Globals=new class{constructor(){this.now=NaN,this.deltaTime=NaN,this.canvasScale=NaN,this.rootScale=1,this.canvasCssWidth=NaN,this.canvasCssHeight=NaN}};var c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function h(t){if(t.__esModule)return t;var e=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(t).forEach((function(n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})})),e}var d,f,p,g,y,m,v,b={exports:{}},w=h(Object.freeze({__proto__:null,path_empty_shim:function(){}})),C=h(Object.freeze({__proto__:null,fs_empty_shim:function(){}}));!function(t,e){var n,r=(n="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,"undefined"!=typeof __filename&&(n=n||__filename),function(t){var e;t=t||{},e||(e=void 0!==t?t:{});var r,i,o,a=Object.assign;e.ready=new Promise((function(t,e){r=t,i=e})),(o=e).Vd=o.Vd||[],o.Vd.push((function(){o.MakeSWCanvasSurface=function(t){var e=t;if("CANVAS"!==e.tagName&&!(e=document.getElementById(t)))throw"Canvas with id "+t+" was not found";return(t=o.MakeSurface(e.width,e.height))&&(t.Nd=e),t},o.MakeCanvasSurface||(o.MakeCanvasSurface=o.MakeSWCanvasSurface),o.MakeSurface=function(t,e){var n={width:t,height:e,colorType:o.ColorType.RGBA_8888,alphaType:o.AlphaType.Unpremul,colorSpace:o.ColorSpace.SRGB},r=t*e*4,i=o._malloc(r);return(n=o.Surface._makeRasterDirect(n,i,4*t))&&(n.Nd=null,n.Cf=t,n.zf=e,n.Bf=r,n.bf=i,n.getCanvas().clear(o.TRANSPARENT)),n},o.MakeRasterDirectSurface=function(t,e,n){return o.Surface._makeRasterDirect(t,e.byteOffset,n)},o.Surface.prototype.flush=function(t){if(o.Od(this.Md),this._flush(),this.Nd){var e=new Uint8ClampedArray(o.HEAPU8.buffer,this.bf,this.Bf);e=new ImageData(e,this.Cf,this.zf),t?this.Nd.getContext("2d").putImageData(e,0,0,t[0],t[1],t[2]-t[0],t[3]-t[1]):this.Nd.getContext("2d").putImageData(e,0,0)}},o.Surface.prototype.dispose=function(){this.bf&&o._free(this.bf),this.delete()},o.Od=o.Od||function(){}})),function(t){t.Vd=t.Vd||[],t.Vd.push((function(){function e(t,e,n){return t&&t.hasOwnProperty(e)?t[e]:n}function n(t){var e=Ge(Ee);return Ee[e]=t,e}function r(t){return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}function i(t){return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}t.GetWebGLContext=function(t,n){if(!t)throw"null canvas passed into makeWebGLContext";var r={alpha:e(n,"alpha",1),depth:e(n,"depth",1),stencil:e(n,"stencil",8),antialias:e(n,"antialias",0),premultipliedAlpha:e(n,"premultipliedAlpha",1),preserveDrawingBuffer:e(n,"preserveDrawingBuffer",0),preferLowPowerToHighPerformance:e(n,"preferLowPowerToHighPerformance",0),failIfMajorPerformanceCaveat:e(n,"failIfMajorPerformanceCaveat",0),enableExtensionsByDefault:e(n,"enableExtensionsByDefault",1),explicitSwapControl:e(n,"explicitSwapControl",0),renderViaOffscreenBackBuffer:e(n,"renderViaOffscreenBackBuffer",0)};if(r.majorVersion=n&&n.majorVersion?n.majorVersion:"undefined"!=typeof WebGL2RenderingContext?2:1,r.explicitSwapControl)throw"explicitSwapControl is not supported";return t=function(t,e){t.sf||(t.sf=t.getContext,t.getContext=function(e,n){return"webgl"==e==(n=t.sf(e,n))instanceof WebGLRenderingContext?n:null});var n=1<e.majorVersion?t.getContext("webgl2",e):t.getContext("webgl",e);return n?function(t,e){var n=Ge(Re),r={Vf:n,attributes:e,version:e.majorVersion,je:t};return t.canvas&&(t.canvas.yf=r),Re[n]=r,(void 0===e.Kf||e.Kf)&&function(t){if(t||(t=Ue),!t.Yf){t.Yf=!0;var e=t.je;!function(t){var e=t.getExtension("ANGLE_instanced_arrays");e&&(t.vertexAttribDivisor=function(t,n){e.vertexAttribDivisorANGLE(t,n)},t.drawArraysInstanced=function(t,n,r,i){e.drawArraysInstancedANGLE(t,n,r,i)},t.drawElementsInstanced=function(t,n,r,i,o){e.drawElementsInstancedANGLE(t,n,r,i,o)})}(e),function(t){var e=t.getExtension("OES_vertex_array_object");e&&(t.createVertexArray=function(){return e.createVertexArrayOES()},t.deleteVertexArray=function(t){e.deleteVertexArrayOES(t)},t.bindVertexArray=function(t){e.bindVertexArrayOES(t)},t.isVertexArray=function(t){return e.isVertexArrayOES(t)})}(e),function(t){var e=t.getExtension("WEBGL_draw_buffers");e&&(t.drawBuffers=function(t,n){e.drawBuffersWEBGL(t,n)})}(e),e.pf=e.getExtension("WEBGL_draw_instanced_base_vertex_base_instance"),e.uf=e.getExtension("WEBGL_multi_draw_instanced_base_vertex_base_instance"),2<=t.version&&(e.qf=e.getExtension("EXT_disjoint_timer_query_webgl2")),(2>t.version||!e.qf)&&(e.qf=e.getExtension("EXT_disjoint_timer_query")),e.Eg=e.getExtension("WEBGL_multi_draw"),(e.getSupportedExtensions()||[]).forEach((function(t){t.includes("lose_context")||t.includes("debug")||e.getExtension(t)}))}}(r),n}(n,e):0}(t,r),t?(Ne(t),t):0},t.deleteContext=function(t){Ue===Re[t]&&(Ue=null),"object"==typeof JSEvents&&JSEvents.Hg(Re[t].je.canvas),Re[t]&&Re[t].je.canvas&&(Re[t].je.canvas.yf=void 0),Re[t]=null},t._setTextureCleanup({deleteTexture:function(t,e){var n=Ee[e];n&&Re[t].je.deleteTexture(n),Ee[e]=null}}),t.MakeGrContext=function(t){if(!this.Od(t))return null;var e=this._MakeGrContext();return e?(e.Md=t,e):null},t.MakeOnScreenGLSurface=function(t,e,n,r){return this.Od(t.Md)&&(e=this._MakeOnScreenGLSurface(t,e,n,r))?(e.Md=t.Md,e):null},t.MakeRenderTarget=function(){var t=arguments[0];if(!this.Od(t.Md))return null;if(3===arguments.length){var e=this._MakeRenderTargetWH(t,arguments[1],arguments[2]);if(!e)return null}else{if(2!==arguments.length)return null;if(!(e=this._MakeRenderTargetII(t,arguments[1])))return null}return e.Md=t.Md,e},t.MakeWebGLCanvasSurface=function(e,n,r){n=n||null;var i=e,o="undefined"!=typeof OffscreenCanvas&&i instanceof OffscreenCanvas;if(!("undefined"!=typeof HTMLCanvasElement&&i instanceof HTMLCanvasElement||o||(i=document.getElementById(e),i)))throw"Canvas with id "+e+" was not found";if(!(e=this.GetWebGLContext(i,r))||0>e)throw"failed to create webgl context: err "+e;return e=this.MakeGrContext(e),(n=this.MakeOnScreenGLSurface(e,i.width,i.height,n))||(n=i.cloneNode(!0),i.parentNode.replaceChild(n,i),n.classList.add("ck-replaced"),t.MakeSWCanvasSurface(n))},t.MakeCanvasSurface=t.MakeWebGLCanvasSurface,t.Surface.prototype.makeImageFromTexture=function(e,r){return t.Od(this.Md),e=n(e),(r=this._makeImageFromTexture(this.Md,e,r))&&(r.Ke=e),r},t.Surface.prototype.makeImageFromTextureSource=function(e,n){n||(n={height:r(e),width:i(e),colorType:t.ColorType.RGBA_8888,alphaType:t.AlphaType.Unpremul}),n.colorSpace||(n.colorSpace=t.ColorSpace.SRGB),t.Od(this.Md);var o=Ue.je,a=o.createTexture();return o.bindTexture(o.TEXTURE_2D,a),2===Ue.version?o.texImage2D(o.TEXTURE_2D,0,o.RGBA,n.width,n.height,0,o.RGBA,o.UNSIGNED_BYTE,e):o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,e),o.bindTexture(o.TEXTURE_2D,null),this.makeImageFromTexture(a,n)},t.Surface.prototype.updateTextureFromSource=function(e,o){if(e.Ke){t.Od(this.Md);var a=Ue.je,s=Ee[e.Ke];a.bindTexture(a.TEXTURE_2D,s),2===Ue.version?a.texImage2D(a.TEXTURE_2D,0,a.RGBA,i(o),r(o),0,a.RGBA,a.UNSIGNED_BYTE,o):a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,o),a.bindTexture(a.TEXTURE_2D,null),this._resetContext(),Ee[e.Ke]=null,e.Ke=n(s),(o=e.getImageInfo()).colorSpace=e.getColorSpace(),a=this._makeImageFromTexture(this.Md,e.Ke,o),s=e.Ld.Qd;var l=e.Ld.$d;e.Ld.Qd=a.Ld.Qd,e.Ld.$d=a.Ld.$d,a.Ld.Qd=s,a.Ld.$d=l,a.delete(),o.colorSpace.delete()}},t.MakeLazyImageFromTextureSource=function(e,o){o||(o={height:r(e),width:i(e),colorType:t.ColorType.RGBA_8888,alphaType:t.AlphaType.Unpremul}),o.colorSpace||(o.colorSpace=t.ColorSpace.SRGB);var a={makeTexture:function(){var t=Ue,r=t.je,i=r.createTexture();return r.bindTexture(r.TEXTURE_2D,i),2===t.version?r.texImage2D(r.TEXTURE_2D,0,r.RGBA,o.width,o.height,0,r.RGBA,r.UNSIGNED_BYTE,e):r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,e),r.bindTexture(r.TEXTURE_2D,null),n(i)},freeSrc:function(){}};return"VideoFrame"===e.constructor.name&&(a.freeSrc=function(){e.close()}),t.Image._makeFromGenerator(o,a)},t.Od=function(t){return!!t&&Ne(t)}}))}(e),function(t){function n(t,e,n,r,i){for(var o=0;o<t.length;o++)e[o*n+(o*i+r+n)%n]=t[o];return e}function r(t){for(var e=t*t,n=Array(e);e--;)n[e]=0==e%(t+1)?1:0;return n}function i(t){return!!t&&t.constructor===Float32Array&&4===t.length}function o(t){return(l(255*t[3])<<24|l(255*t[0])<<16|l(255*t[1])<<8|l(255*t[2])<<0)>>>0}function a(t){if(t&&t._ck)return t;if(t instanceof Float32Array){for(var e=Math.floor(t.length/4),n=new Uint32Array(e),r=0;r<e;r++)n[r]=o(t.slice(4*r,4*(r+1)));return n}return t instanceof Uint32Array?t:t instanceof Array&&t[0]instanceof Float32Array?t.map(o):void 0}function s(t){if(void 0===t)return 1;var e=parseFloat(t);return t&&-1!==t.indexOf("%")?e/100:e}function l(t){return Math.round(Math.max(0,Math.min(t||0,255)))}function u(e,n){n&&n._ck||t._free(e)}function c(e,n,r){if(!e||!e.length)return V;if(e&&e._ck)return e.byteOffset;var i=t[n].BYTES_PER_ELEMENT;return r||(r=t._malloc(e.length*i)),t[n].set(e,r/i),r}function h(e){var n={de:V,count:e.length,Le:t.ColorType.RGBA_F32};if(e instanceof Float32Array)n.de=c(e,"HEAPF32"),n.count=e.length/4;else if(e instanceof Uint32Array)n.de=c(e,"HEAPU32"),n.Le=t.ColorType.RGBA_8888;else{if(!(e instanceof Array))throw"Invalid argument to copyFlexibleColorArray, Not a color array "+typeof e;if(e&&e.length){for(var r=t._malloc(16*e.length),i=0,o=r/4,a=0;a<e.length;a++)for(var s=0;4>s;s++)t.HEAPF32[o+i]=e[a][s],i++;e=r}else e=V;n.de=e}return n}function d(e){if(!e)return V;if(e.length){if(6===e.length||9===e.length)return c(e,"HEAPF32",E),6===e.length&&t.HEAPF32.set(H,6+E/4),E;if(16===e.length){var n=C.toTypedArray();return n[0]=e[0],n[1]=e[1],n[2]=e[3],n[3]=e[4],n[4]=e[5],n[5]=e[7],n[6]=e[12],n[7]=e[13],n[8]=e[15],E}throw"invalid matrix size"}return(n=C.toTypedArray())[0]=e.m11,n[1]=e.m21,n[2]=e.m41,n[3]=e.m12,n[4]=e.m22,n[5]=e.m42,n[6]=e.m14,n[7]=e.m24,n[8]=e.m44,E}function f(t,e){return c(t,"HEAPF32",e||L)}function p(t,e,n,r){var i=T.toTypedArray();return i[0]=t,i[1]=e,i[2]=n,i[3]=r,L}function g(e){for(var n=new Float32Array(4),r=0;4>r;r++)n[r]=t.HEAPF32[e/4+r];return n}function y(t,e){return c(t,"HEAPF32",e||I)}function m(t,e){return c(t,"HEAPF32",e||N)}function v(){for(var t=0,e=0;e<arguments.length-1;e+=2)t+=arguments[e]*arguments[e+1];return t}function b(t,e,n){for(var r=Array(t.length),i=0;i<n;i++)for(var o=0;o<n;o++){for(var a=0,s=0;s<n;s++)a+=t[n*i+s]*e[n*s+o];r[i*n+o]=a}return r}function w(t,e){for(var n=b(e[0],e[1],t),r=2;r<e.length;)n=b(n,e[r],t),r++;return n}t.Color=function(e,n,r,i){return void 0===i&&(i=1),t.Color4f(l(e)/255,l(n)/255,l(r)/255,i)},t.ColorAsInt=function(t,e,n,r){return void 0===r&&(r=255),(l(r)<<24|l(t)<<16|l(e)<<8|l(n)<<0&268435455)>>>0},t.Color4f=function(t,e,n,r){return void 0===r&&(r=1),Float32Array.of(t,e,n,r)},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(t){return[Math.floor(255*t[0]),Math.floor(255*t[1]),Math.floor(255*t[2]),t[3]]},t.parseColorString=function(e,n){if((e=e.toLowerCase()).startsWith("#")){switch(n=255,e.length){case 9:n=parseInt(e.slice(7,9),16);case 7:var r=parseInt(e.slice(1,3),16),i=parseInt(e.slice(3,5),16),o=parseInt(e.slice(5,7),16);break;case 5:n=17*parseInt(e.slice(4,5),16);case 4:r=17*parseInt(e.slice(1,2),16),i=17*parseInt(e.slice(2,3),16),o=17*parseInt(e.slice(3,4),16)}return t.Color(r,i,o,n/255)}return e.startsWith("rgba")?(e=(e=e.slice(5,-1)).split(","),t.Color(+e[0],+e[1],+e[2],s(e[3]))):e.startsWith("rgb")?(e=(e=e.slice(4,-1)).split(","),t.Color(+e[0],+e[1],+e[2],s(e[3]))):e.startsWith("gray(")||e.startsWith("hsl")||!n||void 0===(e=n[e])?t.BLACK:e},t.multiplyByAlpha=function(t,e){return(t=t.slice())[3]=Math.max(0,Math.min(t[3]*e,1)),t},t.Malloc=function(e,n){var r=t._malloc(n*e.BYTES_PER_ELEMENT);return{_ck:!0,length:n,byteOffset:r,pe:null,subarray:function(t,e){return(t=this.toTypedArray().subarray(t,e))._ck=!0,t},toTypedArray:function(){return this.pe&&this.pe.length||(this.pe=new e(t.HEAPU8.buffer,r,n),this.pe._ck=!0),this.pe}}},t.Free=function(e){t._free(e.byteOffset),e.byteOffset=V,e.toTypedArray=null,e.pe=null};var C,A,T,S,P,_,M,k,x,F,E=V,O=V,L=V,I=V,W=V,j=V,z=V,G=V,N=V,U=V,H=Float32Array.of(0,0,1),V=0;t.onRuntimeInitialized=function(){function e(e,n,r,i,o,a){a||(a=4*i.width,i.colorType===t.ColorType.RGBA_F16?a*=2:i.colorType===t.ColorType.RGBA_F32&&(a*=4));var s=a*i.height,l=o?o.byteOffset:t._malloc(s);if(!e._readPixels(i,l,a,n,r))return o||t._free(l),null;if(o)return o.toTypedArray();switch(i.colorType){case t.ColorType.RGBA_8888:case t.ColorType.RGBA_F16:e=new Uint8Array(t.HEAPU8.buffer,l,s).slice();break;case t.ColorType.RGBA_F32:e=new Float32Array(t.HEAPU8.buffer,l,s).slice();break;default:return null}return t._free(l),e}T=t.Malloc(Float32Array,4),L=T.byteOffset,A=t.Malloc(Float32Array,16),O=A.byteOffset,C=t.Malloc(Float32Array,9),E=C.byteOffset,x=t.Malloc(Float32Array,12),N=x.byteOffset,F=t.Malloc(Float32Array,12),U=F.byteOffset,S=t.Malloc(Float32Array,4),I=S.byteOffset,P=t.Malloc(Float32Array,4),W=P.byteOffset,_=t.Malloc(Float32Array,3),j=_.byteOffset,M=t.Malloc(Float32Array,3),z=M.byteOffset,k=t.Malloc(Int32Array,4),G=k.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(e){var n=c(e,"HEAPF32"),r=t.Path._MakeFromCmds(n,e.length);return u(n,e),r},t.Path.MakeFromVerbsPointsWeights=function(e,n,r){var i=c(e,"HEAPU8"),o=c(n,"HEAPF32"),a=c(r,"HEAPF32"),s=t.Path._MakeFromVerbsPointsWeights(i,e.length,o,n.length,a,r&&r.length||0);return u(i,e),u(o,n),u(a,r),s},t.Path.prototype.addArc=function(t,e,n){return t=y(t),this._addArc(t,e,n),this},t.Path.prototype.addOval=function(t,e,n){return void 0===n&&(n=1),t=y(t),this._addOval(t,!!e,n),this},t.Path.prototype.addPath=function(){var t=Array.prototype.slice.call(arguments),e=t[0],n=!1;if("boolean"==typeof t[t.length-1]&&(n=t.pop()),1===t.length)this._addPath(e,1,0,0,0,1,0,0,0,1,n);else if(2===t.length)t=t[1],this._addPath(e,t[0],t[1],t[2],t[3],t[4],t[5],t[6]||0,t[7]||0,t[8]||1,n);else{if(7!==t.length&&10!==t.length)return null;this._addPath(e,t[1],t[2],t[3],t[4],t[5],t[6],t[7]||0,t[8]||0,t[9]||1,n)}return this},t.Path.prototype.addPoly=function(t,e){var n=c(t,"HEAPF32");return this._addPoly(n,t.length/2,e),u(n,t),this},t.Path.prototype.addRect=function(t,e){return t=y(t),this._addRect(t,!!e),this},t.Path.prototype.addRRect=function(t,e){return t=m(t),this._addRRect(t,!!e),this},t.Path.prototype.addVerbsPointsWeights=function(t,e,n){var r=c(t,"HEAPU8"),i=c(e,"HEAPF32"),o=c(n,"HEAPF32");this._addVerbsPointsWeights(r,t.length,i,e.length,o,n&&n.length||0),u(r,t),u(i,e),u(o,n)},t.Path.prototype.arc=function(e,n,r,i,o,a){return e=t.LTRBRect(e-r,n-r,e+r,n+r),o=(o-i)/Math.PI*180-360*!!a,(a=new t.Path).addArc(e,i/Math.PI*180,o),this.addPath(a,!0),a.delete(),this},t.Path.prototype.arcToOval=function(t,e,n,r){return t=y(t),this._arcToOval(t,e,n,r),this},t.Path.prototype.arcToRotated=function(t,e,n,r,i,o,a){return this._arcToRotated(t,e,n,!!r,!!i,o,a),this},t.Path.prototype.arcToTangent=function(t,e,n,r,i){return this._arcToTangent(t,e,n,r,i),this},t.Path.prototype.close=function(){return this._close(),this},t.Path.prototype.conicTo=function(t,e,n,r,i){return this._conicTo(t,e,n,r,i),this},t.Path.prototype.computeTightBounds=function(t){this._computeTightBounds(I);var e=S.toTypedArray();return t?(t.set(e),t):e.slice()},t.Path.prototype.cubicTo=function(t,e,n,r,i,o){return this._cubicTo(t,e,n,r,i,o),this},t.Path.prototype.dash=function(t,e,n){return this._dash(t,e,n)?this:null},t.Path.prototype.getBounds=function(t){this._getBounds(I);var e=S.toTypedArray();return t?(t.set(e),t):e.slice()},t.Path.prototype.lineTo=function(t,e){return this._lineTo(t,e),this},t.Path.prototype.moveTo=function(t,e){return this._moveTo(t,e),this},t.Path.prototype.offset=function(t,e){return this._transform(1,0,t,0,1,e,0,0,1),this},t.Path.prototype.quadTo=function(t,e,n,r){return this._quadTo(t,e,n,r),this},t.Path.prototype.rArcTo=function(t,e,n,r,i,o,a){return this._rArcTo(t,e,n,r,i,o,a),this},t.Path.prototype.rConicTo=function(t,e,n,r,i){return this._rConicTo(t,e,n,r,i),this},t.Path.prototype.rCubicTo=function(t,e,n,r,i,o){return this._rCubicTo(t,e,n,r,i,o),this},t.Path.prototype.rLineTo=function(t,e){return this._rLineTo(t,e),this},t.Path.prototype.rMoveTo=function(t,e){return this._rMoveTo(t,e),this},t.Path.prototype.rQuadTo=function(t,e,n,r){return this._rQuadTo(t,e,n,r),this},t.Path.prototype.stroke=function(e){return(e=e||{}).width=e.width||1,e.miter_limit=e.miter_limit||4,e.cap=e.cap||t.StrokeCap.Butt,e.join=e.join||t.StrokeJoin.Miter,e.precision=e.precision||1,this._stroke(e)?this:null},t.Path.prototype.transform=function(){if(1===arguments.length){var t=arguments[0];this._transform(t[0],t[1],t[2],t[3],t[4],t[5],t[6]||0,t[7]||0,t[8]||1)}else{if(6!==arguments.length&&9!==arguments.length)throw"transform expected to take 1 or 9 arguments. Got "+arguments.length;t=arguments,this._transform(t[0],t[1],t[2],t[3],t[4],t[5],t[6]||0,t[7]||0,t[8]||1)}return this},t.Path.prototype.trim=function(t,e,n){return this._trim(t,e,!!n)?this:null},t.Image.prototype.makeShaderCubic=function(t,e,n,r,i){return i=d(i),this._makeShaderCubic(t,e,n,r,i)},t.Image.prototype.makeShaderOptions=function(t,e,n,r,i){return i=d(i),this._makeShaderOptions(t,e,n,r,i)},t.Image.prototype.readPixels=function(t,n,r,i,o){return e(this,t,n,r,i,o)},t.Canvas.prototype.clear=function(e){t.Od(this.Md),e=f(e),this._clear(e)},t.Canvas.prototype.clipRRect=function(e,n,r){t.Od(this.Md),e=m(e),this._clipRRect(e,n,r)},t.Canvas.prototype.clipRect=function(e,n,r){t.Od(this.Md),e=y(e),this._clipRect(e,n,r)},t.Canvas.prototype.concat=function(e){t.Od(this.Md),e=function(t){if(!t)return V;var e=A.toTypedArray();if(t.length){if(16!==t.length&&6!==t.length&&9!==t.length)throw"invalid matrix size";return 16===t.length?c(t,"HEAPF32",O):(e.fill(0),e[0]=t[0],e[1]=t[1],e[3]=t[2],e[4]=t[3],e[5]=t[4],e[7]=t[5],e[12]=t[6],e[13]=t[7],e[15]=t[8],6===t.length&&(e[12]=0,e[13]=0,e[15]=1),O)}return e[0]=t.m11,e[1]=t.m21,e[2]=t.m31,e[3]=t.m41,e[4]=t.m12,e[5]=t.m22,e[6]=t.m32,e[7]=t.m42,e[8]=t.m13,e[9]=t.m23,e[10]=t.m33,e[11]=t.m43,e[12]=t.m14,e[13]=t.m24,e[14]=t.m34,e[15]=t.m44,O}(e),this._concat(e)},t.Canvas.prototype.drawArc=function(e,n,r,i,o){t.Od(this.Md),e=y(e),this._drawArc(e,n,r,i,o)},t.Canvas.prototype.drawAtlas=function(e,n,r,i,o,s,l){if(e&&i&&n&&r&&n.length===r.length){t.Od(this.Md),o||(o=t.BlendMode.SrcOver);var h=c(n,"HEAPF32"),d=c(r,"HEAPF32"),f=r.length/4,p=c(a(s),"HEAPU32");if(l&&"B"in l&&"C"in l)this._drawAtlasCubic(e,d,h,p,f,o,l.B,l.C,i);else{let n=t.FilterMode.Linear,r=t.MipmapMode.None;l&&(n=l.filter,"mipmap"in l&&(r=l.mipmap)),this._drawAtlasOptions(e,d,h,p,f,o,n,r,i)}u(h,n),u(d,r),u(p,s)}},t.Canvas.prototype.drawCircle=function(e,n,r,i){t.Od(this.Md),this._drawCircle(e,n,r,i)},t.Canvas.prototype.drawColor=function(e,n){t.Od(this.Md),e=f(e),void 0!==n?this._drawColor(e,n):this._drawColor(e)},t.Canvas.prototype.drawColorInt=function(e,n){t.Od(this.Md),this._drawColorInt(e,n||t.BlendMode.SrcOver)},t.Canvas.prototype.drawColorComponents=function(e,n,r,i,o){t.Od(this.Md),e=p(e,n,r,i),void 0!==o?this._drawColor(e,o):this._drawColor(e)},t.Canvas.prototype.drawDRRect=function(e,n,r){t.Od(this.Md),e=m(e,N),n=m(n,U),this._drawDRRect(e,n,r)},t.Canvas.prototype.drawGlyphs=function(e,n,r,i,o,a){if(!(2*e.length<=n.length))throw"Not enough positions for the array of gyphs";t.Od(this.Md);const s=c(e,"HEAPU16"),l=c(n,"HEAPF32");this._drawGlyphs(e.length,s,l,r,i,o,a),u(l,n),u(s,e)},t.Canvas.prototype.drawImage=function(e,n,r,i){t.Od(this.Md),this._drawImage(e,n,r,i||null)},t.Canvas.prototype.drawImageCubic=function(e,n,r,i,o,a){t.Od(this.Md),this._drawImageCubic(e,n,r,i,o,a||null)},t.Canvas.prototype.drawImageOptions=function(e,n,r,i,o,a){t.Od(this.Md),this._drawImageOptions(e,n,r,i,o,a||null)},t.Canvas.prototype.drawImageNine=function(e,n,r,i,o){t.Od(this.Md),n=c(n,"HEAP32",G),r=y(r),this._drawImageNine(e,n,r,i,o||null)},t.Canvas.prototype.drawImageRect=function(e,n,r,i,o){t.Od(this.Md),y(n,I),y(r,W),this._drawImageRect(e,I,W,i,!!o)},t.Canvas.prototype.drawImageRectCubic=function(e,n,r,i,o,a){t.Od(this.Md),y(n,I),y(r,W),this._drawImageRectCubic(e,I,W,i,o,a||null)},t.Canvas.prototype.drawImageRectOptions=function(e,n,r,i,o,a){t.Od(this.Md),y(n,I),y(r,W),this._drawImageRectOptions(e,I,W,i,o,a||null)},t.Canvas.prototype.drawLine=function(e,n,r,i,o){t.Od(this.Md),this._drawLine(e,n,r,i,o)},t.Canvas.prototype.drawOval=function(e,n){t.Od(this.Md),e=y(e),this._drawOval(e,n)},t.Canvas.prototype.drawPaint=function(e){t.Od(this.Md),this._drawPaint(e)},t.Canvas.prototype.drawParagraph=function(e,n,r){t.Od(this.Md),this._drawParagraph(e,n,r)},t.Canvas.prototype.drawPatch=function(e,n,r,i,o){if(24>e.length)throw"Need 12 cubic points";if(n&&4>n.length)throw"Need 4 colors";if(r&&8>r.length)throw"Need 4 shader coordinates";t.Od(this.Md);const s=c(e,"HEAPF32"),l=n?c(a(n),"HEAPU32"):V,h=r?c(r,"HEAPF32"):V;i||(i=t.BlendMode.Modulate),this._drawPatch(s,l,h,i,o),u(h,r),u(l,n),u(s,e)},t.Canvas.prototype.drawPath=function(e,n){t.Od(this.Md),this._drawPath(e,n)},t.Canvas.prototype.drawPicture=function(e){t.Od(this.Md),this._drawPicture(e)},t.Canvas.prototype.drawPoints=function(e,n,r){t.Od(this.Md);var i=c(n,"HEAPF32");this._drawPoints(e,i,n.length/2,r),u(i,n)},t.Canvas.prototype.drawRRect=function(e,n){t.Od(this.Md),e=m(e),this._drawRRect(e,n)},t.Canvas.prototype.drawRect=function(e,n){t.Od(this.Md),e=y(e),this._drawRect(e,n)},t.Canvas.prototype.drawRect4f=function(e,n,r,i,o){t.Od(this.Md),this._drawRect4f(e,n,r,i,o)},t.Canvas.prototype.drawShadow=function(e,n,r,i,o,a,s){t.Od(this.Md);var l=c(o,"HEAPF32"),h=c(a,"HEAPF32");n=c(n,"HEAPF32",j),r=c(r,"HEAPF32",z),this._drawShadow(e,n,r,i,l,h,s),u(l,o),u(h,a)},t.getShadowLocalBounds=function(t,e,n,r,i,o,a){return t=d(t),n=c(n,"HEAPF32",j),r=c(r,"HEAPF32",z),this._getShadowLocalBounds(t,e,n,r,i,o,I)?(e=S.toTypedArray(),a?(a.set(e),a):e.slice()):null},t.Canvas.prototype.drawTextBlob=function(e,n,r,i){t.Od(this.Md),this._drawTextBlob(e,n,r,i)},t.Canvas.prototype.drawVertices=function(e,n,r){t.Od(this.Md),this._drawVertices(e,n,r)},t.Canvas.prototype.getLocalToDevice=function(){this._getLocalToDevice(O);for(var e=O,n=Array(16),r=0;16>r;r++)n[r]=t.HEAPF32[e/4+r];return n},t.Canvas.prototype.getTotalMatrix=function(){this._getTotalMatrix(E);for(var e=Array(9),n=0;9>n;n++)e[n]=t.HEAPF32[E/4+n];return e},t.Canvas.prototype.makeSurface=function(t){return(t=this._makeSurface(t)).Md=this.Md,t},t.Canvas.prototype.readPixels=function(n,r,i,o,a){return t.Od(this.Md),e(this,n,r,i,o,a)},t.Canvas.prototype.saveLayer=function(t,e,n,r){return e=y(e),this._saveLayer(t||null,e,n||null,r||0)},t.Canvas.prototype.writePixels=function(e,n,r,i,o,a,s,l){if(e.byteLength%(n*r))throw"pixels length must be a multiple of the srcWidth * srcHeight";t.Od(this.Md);var h=e.byteLength/(n*r);a=a||t.AlphaType.Unpremul,s=s||t.ColorType.RGBA_8888,l=l||t.ColorSpace.SRGB;var d=h*n;return h=c(e,"HEAPU8"),n=this._writePixels({width:n,height:r,colorType:s,alphaType:a,colorSpace:l},h,d,i,o),u(h,e),n},t.ColorFilter.MakeBlend=function(e,n){return e=f(e),t.ColorFilter._MakeBlend(e,n)},t.ColorFilter.MakeMatrix=function(e){if(!e||20!==e.length)throw"invalid color matrix";var n=c(e,"HEAPF32"),r=t.ColorFilter._makeMatrix(n);return u(n,e),r},t.ContourMeasure.prototype.getPosTan=function(t,e){return this._getPosTan(t,I),t=S.toTypedArray(),e?(e.set(t),e):t.slice()},t.ImageFilter.MakeMatrixTransform=function(e,n,r){if(e=d(e),"B"in n&&"C"in n)return t.ImageFilter._MakeMatrixTransformCubic(e,n.Ag,n.Bg,r);const i=n.filter;let o=t.MipmapMode.None;return"mipmap"in n&&(o=n.mipmap),t.ImageFilter._MakeMatrixTransformOptions(e,i,o,r)},t.Paint.prototype.getColor=function(){return this._getColor(L),g(L)},t.Paint.prototype.setColor=function(t,e){e=e||null,t=f(t),this._setColor(t,e)},t.Paint.prototype.setColorComponents=function(t,e,n,r,i){i=i||null,t=p(t,e,n,r),this._setColor(t,i)},t.Path.prototype.getPoint=function(t,e){return this._getPoint(t,I),t=S.toTypedArray(),e?(e[0]=t[0],e[1]=t[1],e):t.slice(0,2)},t.PictureRecorder.prototype.beginRecording=function(t){return t=y(t),this._beginRecording(t)},t.Surface.prototype.getCanvas=function(){var t=this._getCanvas();return t.Md=this.Md,t},t.Surface.prototype.makeImageSnapshot=function(e){return t.Od(this.Md),e=c(e,"HEAP32",G),this._makeImageSnapshot(e)},t.Surface.prototype.makeSurface=function(e){return t.Od(this.Md),(e=this._makeSurface(e)).Md=this.Md,e},t.Surface.prototype.requestAnimationFrame=function(e,n){this.Ge||(this.Ge=this.getCanvas()),requestAnimationFrame(function(){t.Od(this.Md),e(this.Ge),this.flush(n)}.bind(this))},t.Surface.prototype.drawOnce=function(e,n){this.Ge||(this.Ge=this.getCanvas()),requestAnimationFrame(function(){t.Od(this.Md),e(this.Ge),this.flush(n),this.dispose()}.bind(this))},t.PathEffect.MakeDash=function(e,n){if(n||(n=0),!e.length||1==e.length%2)throw"Intervals array must have even length";var r=c(e,"HEAPF32");return n=t.PathEffect._MakeDash(r,e.length,n),u(r,e),n},t.PathEffect.MakeLine2D=function(e,n){return n=d(n),t.PathEffect._MakeLine2D(e,n)},t.PathEffect.MakePath2D=function(e,n){return e=d(e),t.PathEffect._MakePath2D(e,n)},t.Shader.MakeColor=function(e,n){return n=n||null,e=f(e),t.Shader._MakeColor(e,n)},t.Shader.Blend=t.Shader.MakeBlend,t.Shader.Color=t.Shader.MakeColor,t.Shader.MakeLinearGradient=function(e,n,r,i,o,a,s,l){l=l||null;var f=h(r),p=c(i,"HEAPF32");s=s||0,a=d(a);var g=S.toTypedArray();return g.set(e),g.set(n,2),e=t.Shader._MakeLinearGradient(I,f.de,f.Le,p,f.count,o,s,a,l),u(f.de,r),i&&u(p,i),e},t.Shader.MakeRadialGradient=function(e,n,r,i,o,a,s,l){l=l||null;var f=h(r),p=c(i,"HEAPF32");return s=s||0,a=d(a),e=t.Shader._MakeRadialGradient(e[0],e[1],n,f.de,f.Le,p,f.count,o,s,a,l),u(f.de,r),i&&u(p,i),e},t.Shader.MakeSweepGradient=function(e,n,r,i,o,a,s,l,f,p){p=p||null;var g=h(r),y=c(i,"HEAPF32");return s=s||0,l=l||0,f=f||360,a=d(a),e=t.Shader._MakeSweepGradient(e,n,g.de,g.Le,y,g.count,o,l,f,s,a,p),u(g.de,r),i&&u(y,i),e},t.Shader.MakeTwoPointConicalGradient=function(e,n,r,i,o,a,s,l,f,p){p=p||null;var g=h(o),y=c(a,"HEAPF32");f=f||0,l=d(l);var m=S.toTypedArray();return m.set(e),m.set(r,2),e=t.Shader._MakeTwoPointConicalGradient(I,n,i,g.de,g.Le,y,g.count,s,f,l,p),u(g.de,o),a&&u(y,a),e},t.Vertices.prototype.bounds=function(t){this._bounds(I);var e=S.toTypedArray();return t?(t.set(e),t):e.slice()},t.Vd&&t.Vd.forEach((function(t){t()}))},t.computeTonalColors=function(t){var e=c(t.ambient,"HEAPF32"),n=c(t.spot,"HEAPF32");this._computeTonalColors(e,n);var r={ambient:g(e),spot:g(n)};return u(e,t.ambient),u(n,t.spot),r},t.LTRBRect=function(t,e,n,r){return Float32Array.of(t,e,n,r)},t.XYWHRect=function(t,e,n,r){return Float32Array.of(t,e,t+n,e+r)},t.LTRBiRect=function(t,e,n,r){return Int32Array.of(t,e,n,r)},t.XYWHiRect=function(t,e,n,r){return Int32Array.of(t,e,t+n,e+r)},t.RRectXY=function(t,e,n){return Float32Array.of(t[0],t[1],t[2],t[3],e,n,e,n,e,n,e,n)},t.MakeAnimatedImageFromEncoded=function(e){e=new Uint8Array(e);var n=t._malloc(e.byteLength);return t.HEAPU8.set(e,n),(e=t._decodeAnimatedImage(n,e.byteLength))?e:null},t.MakeImageFromEncoded=function(e){e=new Uint8Array(e);var n=t._malloc(e.byteLength);return t.HEAPU8.set(e,n),(e=t._decodeImage(n,e.byteLength))?e:null};var $=null;t.MakeImageFromCanvasImageSource=function(e){var n=e.width,r=e.height;$||($=document.createElement("canvas")),$.width=n,$.height=r;var i=$.getContext("2d",{Jg:!0});return i.drawImage(e,0,0),e=i.getImageData(0,0,n,r),t.MakeImage({width:n,height:r,alphaType:t.AlphaType.Unpremul,colorType:t.ColorType.RGBA_8888,colorSpace:t.ColorSpace.SRGB},e.data,4*n)},t.MakeImage=function(e,n,r){var i=t._malloc(n.length);return t.HEAPU8.set(n,i),t._MakeImage(e,i,n.length,r)},t.MakeVertices=function(e,n,r,i,o,s){var l=o&&o.length||0,u=0;return r&&r.length&&(u|=1),i&&i.length&&(u|=2),void 0===s||s||(u|=4),c(n,"HEAPF32",(e=new t._VerticesBuilder(e,n.length/2,l,u)).positions()),e.texCoords()&&c(r,"HEAPF32",e.texCoords()),e.colors()&&c(a(i),"HEAPU32",e.colors()),e.indices()&&c(o,"HEAPU16",e.indices()),e.detach()},t.Matrix={},t.Matrix.identity=function(){return r(3)},t.Matrix.invert=function(t){var e=t[0]*t[4]*t[8]+t[1]*t[5]*t[6]+t[2]*t[3]*t[7]-t[2]*t[4]*t[6]-t[1]*t[3]*t[8]-t[0]*t[5]*t[7];return e?[(t[4]*t[8]-t[5]*t[7])/e,(t[2]*t[7]-t[1]*t[8])/e,(t[1]*t[5]-t[2]*t[4])/e,(t[5]*t[6]-t[3]*t[8])/e,(t[0]*t[8]-t[2]*t[6])/e,(t[2]*t[3]-t[0]*t[5])/e,(t[3]*t[7]-t[4]*t[6])/e,(t[1]*t[6]-t[0]*t[7])/e,(t[0]*t[4]-t[1]*t[3])/e]:null},t.Matrix.mapPoints=function(t,e){for(var n=0;n<e.length;n+=2){var r=e[n],i=e[n+1],o=t[6]*r+t[7]*i+t[8],a=t[3]*r+t[4]*i+t[5];e[n]=(t[0]*r+t[1]*i+t[2])/o,e[n+1]=a/o}return e},t.Matrix.multiply=function(){return w(3,arguments)},t.Matrix.rotated=function(t,e,n){e=e||0,n=n||0;var r=Math.sin(t);return[t=Math.cos(t),-r,v(r,n,1-t,e),r,t,v(-r,e,1-t,n),0,0,1]},t.Matrix.scaled=function(t,e,i,o){i=i||0,o=o||0;var a=n([t,e],r(3),3,0,1);return n([i-t*i,o-e*o],a,3,2,0)},t.Matrix.skewed=function(t,e,i,o){i=i||0,o=o||0;var a=n([t,e],r(3),3,1,-1);return n([-t*i,-e*o],a,3,2,0)},t.Matrix.translated=function(t,e){return n(arguments,r(3),3,2,0)},t.Vector={},t.Vector.dot=function(t,e){return t.map((function(t,n){return t*e[n]})).reduce((function(t,e){return t+e}))},t.Vector.lengthSquared=function(e){return t.Vector.dot(e,e)},t.Vector.length=function(e){return Math.sqrt(t.Vector.lengthSquared(e))},t.Vector.mulScalar=function(t,e){return t.map((function(t){return t*e}))},t.Vector.add=function(t,e){return t.map((function(t,n){return t+e[n]}))},t.Vector.sub=function(t,e){return t.map((function(t,n){return t-e[n]}))},t.Vector.dist=function(e,n){return t.Vector.length(t.Vector.sub(e,n))},t.Vector.normalize=function(e){return t.Vector.mulScalar(e,1/t.Vector.length(e))},t.Vector.cross=function(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]},t.M44={},t.M44.identity=function(){return r(4)},t.M44.translated=function(t){return n(t,r(4),4,3,0)},t.M44.scaled=function(t){return n(t,r(4),4,0,1)},t.M44.rotated=function(e,n){return t.M44.rotatedUnitSinCos(t.Vector.normalize(e),Math.sin(n),Math.cos(n))},t.M44.rotatedUnitSinCos=function(t,e,n){var r=t[0],i=t[1],o=1-n;return[o*r*r+n,o*r*i-e*(t=t[2]),o*r*t+e*i,0,o*r*i+e*t,o*i*i+n,o*i*t-e*r,0,o*r*t-e*i,o*i*t+e*r,o*t*t+n,0,0,0,0,1]},t.M44.lookat=function(e,r,i){r=t.Vector.normalize(t.Vector.sub(r,e)),i=t.Vector.normalize(i),i=t.Vector.normalize(t.Vector.cross(r,i));var o=t.M44.identity();return n(i,o,4,0,0),n(t.Vector.cross(i,r),o,4,1,0),n(t.Vector.mulScalar(r,-1),o,4,2,0),n(e,o,4,3,0),null===(e=t.M44.invert(o))?t.M44.identity():e},t.M44.perspective=function(t,e,n){var r=1/(e-t);return n/=2,[n=Math.cos(n)/Math.sin(n),0,0,0,0,n,0,0,0,0,(e+t)*r,2*e*t*r,0,0,-1,1]},t.M44.rc=function(t,e,n){return t[4*e+n]},t.M44.multiply=function(){return w(4,arguments)},t.M44.invert=function(t){var e=t[0],n=t[4],r=t[8],i=t[12],o=t[1],a=t[5],s=t[9],l=t[13],u=t[2],c=t[6],h=t[10],d=t[14],f=t[3],p=t[7],g=t[11],y=e*a-n*o,m=e*s-r*o,v=e*l-i*o,b=n*s-r*a,w=n*l-i*a,C=r*l-i*s,A=u*p-c*f,T=u*g-h*f,S=u*(t=t[15])-d*f,P=c*g-h*p,_=c*t-d*p,M=h*t-d*g,k=y*M-m*_+v*P+b*S-w*T+C*A,x=1/k;return 0===k||1/0===x?null:(e=[a*(M*=x)-s*(_*=x)+l*(P*=x),s*(S*=x)-o*M-l*(T*=x),o*_-a*S+l*(A*=x),a*T-o*P-s*A,r*_-n*M-i*P,e*M-r*S+i*T,n*S-e*_-i*A,e*P-n*T+r*A,p*(C*=x)-g*(w*=x)+t*(b*=x),g*(v*=x)-f*C-t*(m*=x),f*w-p*v+t*(y*=x),p*m-f*b-g*y,h*w-c*C-d*b,u*C-h*v+d*m,c*v-u*w-d*y,u*b-c*m+h*y]).every((function(t){return!isNaN(t)&&1/0!==t&&-1/0!==t}))?e:null},t.M44.transpose=function(t){return[t[0],t[4],t[8],t[12],t[1],t[5],t[9],t[13],t[2],t[6],t[10],t[14],t[3],t[7],t[11],t[15]]},t.M44.mustInvert=function(e){if(null===(e=t.M44.invert(e)))throw"Matrix not invertible";return e},t.M44.setupCamera=function(e,n,r){var i=t.M44.lookat(r.eye,r.coa,r.up);return r=t.M44.perspective(r.near,r.far,r.angle),n=[(e[2]-e[0])/2,(e[3]-e[1])/2,n],e=t.M44.multiply(t.M44.translated([(e[0]+e[2])/2,(e[1]+e[3])/2,0]),t.M44.scaled(n)),t.M44.multiply(e,r,i,t.M44.mustInvert(e))},t.ColorMatrix={},t.ColorMatrix.identity=function(){var t=new Float32Array(20);return t[0]=1,t[6]=1,t[12]=1,t[18]=1,t},t.ColorMatrix.scaled=function(t,e,n,r){var i=new Float32Array(20);return i[0]=t,i[6]=e,i[12]=n,i[18]=r,i};var Y,X=[[6,7,11,12],[0,10,2,12],[0,1,5,6]];t.ColorMatrix.rotated=function(e,n,r){var i=t.ColorMatrix.identity();return i[(e=X[e])[0]]=r,i[e[1]]=n,i[e[2]]=-n,i[e[3]]=r,i},t.ColorMatrix.postTranslate=function(t,e,n,r,i){return t[4]+=e,t[9]+=n,t[14]+=r,t[19]+=i,t},t.ColorMatrix.concat=function(t,e){for(var n=new Float32Array(20),r=0,i=0;20>i;i+=5){for(var o=0;4>o;o++)n[r++]=t[i]*e[o]+t[i+1]*e[o+5]+t[i+2]*e[o+10]+t[i+3]*e[o+15];n[r++]=t[i]*e[4]+t[i+1]*e[9]+t[i+2]*e[14]+t[i+3]*e[19]+t[i+4]}return n},(Y=e).Vd=Y.Vd||[],Y.Vd.push((function(){function t(t){if(!t||!t.length)return[];for(var e=[],n=0;n<t.length;n+=5){var r=Y.LTRBRect(t[n],t[n+1],t[n+2],t[n+3]);r.direction=0===t[n+4]?Y.TextDirection.RTL:Y.TextDirection.LTR,e.push(r)}return Y._free(t.byteOffset),e}function e(t){return void 0===(t=t||{}).weight&&(t.weight=Y.FontWeight.Normal),t.width=t.width||Y.FontWidth.Normal,t.slant=t.slant||Y.FontSlant.Upright,t}function n(t){if(!t||!t.length)return V;for(var e=[],n=0;n<t.length;n++){var i=r(t[n]);e.push(i)}return c(e,"HEAPU32")}function r(t){if(a[t])return a[t];var e=R(t)+1,n=Y._malloc(e);return B(t,D,n,e),a[t]=n}function i(t){if(t._colorPtr=f(t.color),t._foregroundColorPtr=V,t._backgroundColorPtr=V,t._decorationColorPtr=V,t.foregroundColor&&(t._foregroundColorPtr=f(t.foregroundColor,s)),t.backgroundColor&&(t._backgroundColorPtr=f(t.backgroundColor,l)),t.decorationColor&&(t._decorationColorPtr=f(t.decorationColor,u)),Array.isArray(t.fontFamilies)&&t.fontFamilies.length?(t._fontFamiliesPtr=n(t.fontFamilies),t._fontFamiliesLen=t.fontFamilies.length):(t._fontFamiliesPtr=V,t._fontFamiliesLen=0),t.locale){var e=t.locale;t._localePtr=r(e),t._localeLen=R(e)+1}else t._localePtr=V,t._localeLen=0;if(Array.isArray(t.shadows)&&t.shadows.length){var i=(e=t.shadows).map((function(t){return t.color||Y.BLACK})),o=e.map((function(t){return t.blurRadius||0}));t._shadowLen=e.length;for(var a=Y._malloc(8*e.length),d=a/4,p=0;p<e.length;p++){var g=e[p].offset||[0,0];Y.HEAPF32[d]=g[0],Y.HEAPF32[d+1]=g[1],d+=2}t._shadowColorsPtr=h(i).de,t._shadowOffsetsPtr=a,t._shadowBlurRadiiPtr=c(o,"HEAPF32")}else t._shadowLen=0,t._shadowColorsPtr=V,t._shadowOffsetsPtr=V,t._shadowBlurRadiiPtr=V;Array.isArray(t.fontFeatures)&&t.fontFeatures.length?(i=(e=t.fontFeatures).map((function(t){return t.name})),o=e.map((function(t){return t.value})),t._fontFeatureLen=e.length,t._fontFeatureNamesPtr=n(i),t._fontFeatureValuesPtr=c(o,"HEAPU32")):(t._fontFeatureLen=0,t._fontFeatureNamesPtr=V,t._fontFeatureValuesPtr=V)}function o(t){Y._free(t._fontFamiliesPtr),Y._free(t._shadowColorsPtr),Y._free(t._shadowOffsetsPtr),Y._free(t._shadowBlurRadiiPtr),Y._free(t._fontFeatureNamesPtr),Y._free(t._fontFeatureValuesPtr)}Y.Paragraph.prototype.getRectsForRange=function(e,n,r,i){return t(e=this._getRectsForRange(e,n,r,i))},Y.Paragraph.prototype.getRectsForPlaceholders=function(){return t(this._getRectsForPlaceholders())},Y.TypefaceFontProvider.prototype.registerFont=function(t,e){if(!(t=Y.Typeface.MakeFreeTypeFaceFromData(t)))return null;e=r(e),this._registerFont(t,e)},Y.ParagraphStyle=function(t){if(t.disableHinting=t.disableHinting||!1,t.ellipsis){var i=t.ellipsis;t._ellipsisPtr=r(i),t._ellipsisLen=R(i)+1}else t._ellipsisPtr=V,t._ellipsisLen=0;return t.heightMultiplier=t.heightMultiplier||0,t.maxLines=t.maxLines||0,(i=(i=t.strutStyle)||{}).strutEnabled=i.strutEnabled||!1,i.strutEnabled&&Array.isArray(i.fontFamilies)&&i.fontFamilies.length?(i._fontFamiliesPtr=n(i.fontFamilies),i._fontFamiliesLen=i.fontFamilies.length):(i._fontFamiliesPtr=V,i._fontFamiliesLen=0),i.fontStyle=e(i.fontStyle),i.fontSize=i.fontSize||0,i.heightMultiplier=i.heightMultiplier||0,i.halfLeading=i.halfLeading||!1,i.leading=i.leading||0,i.forceStrutHeight=i.forceStrutHeight||!1,t.strutStyle=i,t.textAlign=t.textAlign||Y.TextAlign.Start,t.textDirection=t.textDirection||Y.TextDirection.LTR,t.textHeightBehavior=t.textHeightBehavior||Y.TextHeightBehavior.All,t.textStyle=Y.TextStyle(t.textStyle),t},Y.TextStyle=function(t){return t.color||(t.color=Y.BLACK),t.decoration=t.decoration||0,t.decorationThickness=t.decorationThickness||0,t.decorationStyle=t.decorationStyle||Y.DecorationStyle.Solid,t.textBaseline=t.textBaseline||Y.TextBaseline.Alphabetic,t.fontSize=t.fontSize||0,t.letterSpacing=t.letterSpacing||0,t.wordSpacing=t.wordSpacing||0,t.heightMultiplier=t.heightMultiplier||0,t.halfLeading=t.halfLeading||!1,t.fontStyle=e(t.fontStyle),t};var a={},s=Y._malloc(16),l=Y._malloc(16),u=Y._malloc(16);Y.ParagraphBuilder.Make=function(t,e){return i(t.textStyle),e=Y.ParagraphBuilder._Make(t,e),o(t.textStyle),e},Y.ParagraphBuilder.MakeFromFontProvider=function(t,e){return i(t.textStyle),e=Y.ParagraphBuilder._MakeFromFontProvider(t,e),o(t.textStyle),e},Y.ParagraphBuilder.ShapeText=function(t,e,n){let r=0;for(const t of e)r+=t.length;if(r!==t.length)throw"Accumulated block lengths must equal text.length";return Y.ParagraphBuilder._ShapeText(t,e,n)},Y.ParagraphBuilder.prototype.pushStyle=function(t){i(t),this._pushStyle(t),o(t)},Y.ParagraphBuilder.prototype.pushPaintStyle=function(t,e,n){i(t),this._pushPaintStyle(t,e,n),o(t)},Y.ParagraphBuilder.prototype.addPlaceholder=function(t,e,n,r,i){n=n||Y.PlaceholderAlignment.Baseline,r=r||Y.TextBaseline.Alphabetic,this._addPlaceholder(t||0,e||0,n,r,i||0)}})),t.Vd=t.Vd||[],t.Vd.push((function(){t.Path.prototype.op=function(t,e){return this._op(t,e)?this:null},t.Path.prototype.simplify=function(){return this._simplify()?this:null}})),t.Vd=t.Vd||[],t.Vd.push((function(){t.Canvas.prototype.drawText=function(e,n,r,i,o){var a=R(e),s=t._malloc(a+1);B(e,D,s,a+1),this._drawSimpleText(s,a,n,r,o,i),t._free(s)},t.Font.prototype.getGlyphBounds=function(e,n,r){var i=c(e,"HEAPU16"),o=t._malloc(16*e.length);return this._getGlyphWidthBounds(i,e.length,V,o,n||null),n=new Float32Array(t.HEAPU8.buffer,o,4*e.length),u(i,e),r?(r.set(n),t._free(o),r):(e=Float32Array.from(n),t._free(o),e)},t.Font.prototype.getGlyphIDs=function(e,n,r){n||(n=e.length);var i=R(e)+1,o=t._malloc(i);return B(e,D,o,i),e=t._malloc(2*n),n=this._getGlyphIDs(o,i-1,n,e),t._free(o),0>n?(t._free(e),null):(o=new Uint16Array(t.HEAPU8.buffer,e,n),r?(r.set(o),t._free(e),r):(r=Uint16Array.from(o),t._free(e),r))},t.Font.prototype.getGlyphIntercepts=function(t,e,n,r){var i=c(t,"HEAPU16"),o=c(e,"HEAPF32");return this._getGlyphIntercepts(i,t.length,!(t&&t._ck),o,e.length,!(e&&e._ck),n,r)},t.Font.prototype.getGlyphWidths=function(e,n,r){var i=c(e,"HEAPU16"),o=t._malloc(4*e.length);return this._getGlyphWidthBounds(i,e.length,o,V,n||null),n=new Float32Array(t.HEAPU8.buffer,o,e.length),u(i,e),r?(r.set(n),t._free(o),r):(e=Float32Array.from(n),t._free(o),e)},t.FontMgr.FromData=function(){if(!arguments.length)return null;var e=arguments;if(1===e.length&&Array.isArray(e[0])&&(e=arguments[0]),!e.length)return null;for(var n=[],r=[],i=0;i<e.length;i++){var o=new Uint8Array(e[i]),a=c(o,"HEAPU8");n.push(a),r.push(o.byteLength)}return n=c(n,"HEAPU32"),r=c(r,"HEAPU32"),e=t.FontMgr._fromData(n,r,e.length),t._free(n),t._free(r),e},t.Typeface.MakeFreeTypeFaceFromData=function(e){var n=c(e=new Uint8Array(e),"HEAPU8");return(e=t.Typeface._MakeFreeTypeFaceFromData(n,e.byteLength))?e:null},t.Typeface.prototype.getGlyphIDs=function(e,n,r){n||(n=e.length);var i=R(e)+1,o=t._malloc(i);return B(e,D,o,i),e=t._malloc(2*n),n=this._getGlyphIDs(o,i-1,n,e),t._free(o),0>n?(t._free(e),null):(o=new Uint16Array(t.HEAPU8.buffer,e,n),r?(r.set(o),t._free(e),r):(r=Uint16Array.from(o),t._free(e),r))},t.TextBlob.MakeOnPath=function(e,n,r,i){if(e&&e.length&&n&&n.countPoints()){if(1===n.countPoints())return this.MakeFromText(e,r);i||(i=0);var o=r.getGlyphIDs(e);o=r.getGlyphWidths(o);for(var a=[],s=(n=new t.ContourMeasureIter(n,!1,1)).next(),l=new Float32Array(4),u=0;u<e.length&&s;u++){var c=o[u];if((i+=c/2)>s.length()){if(s.delete(),!(s=n.next())){e=e.substring(0,u);break}i=c/2}s.getPosTan(i,l);var h=l[2],d=l[3];a.push(h,d,l[0]-c/2*h,l[1]-c/2*d),i+=c/2}return e=this.MakeFromRSXform(e,a,r),s&&s.delete(),n.delete(),e}},t.TextBlob.MakeFromRSXform=function(e,n,r){var i=R(e)+1,o=t._malloc(i);return B(e,D,o,i),e=c(n,"HEAPF32"),r=t.TextBlob._MakeFromRSXform(o,i-1,e,r),t._free(o),r||null},t.TextBlob.MakeFromRSXformGlyphs=function(e,n,r){var i=c(e,"HEAPU16");return n=c(n,"HEAPF32"),r=t.TextBlob._MakeFromRSXformGlyphs(i,2*e.length,n,r),u(i,e),r||null},t.TextBlob.MakeFromGlyphs=function(e,n){var r=c(e,"HEAPU16");return n=t.TextBlob._MakeFromGlyphs(r,2*e.length,n),u(r,e),n||null},t.TextBlob.MakeFromText=function(e,n){var r=R(e)+1,i=t._malloc(r);return B(e,D,i,r),e=t.TextBlob._MakeFromText(i,r-1,n),t._free(i),e||null},t.MallocGlyphIDs=function(e){return t.Malloc(Uint16Array,e)}})),t.Vd=t.Vd||[],t.Vd.push((function(){t.MakePicture=function(e){e=new Uint8Array(e);var n=t._malloc(e.byteLength);return t.HEAPU8.set(e,n),(e=t._MakePicture(n,e.byteLength))?e:null}})),function(){function e(t){for(var e=0;e<t.length;e++)if(void 0!==t[e]&&!Number.isFinite(t[e]))return!1;return!0}function n(e){var n=t.getColorComponents(e);e=n[0];var r=n[1],i=n[2];return 1===(n=n[3])?(e=e.toString(16).toLowerCase(),r=r.toString(16).toLowerCase(),i=i.toString(16).toLowerCase(),"#"+(e=1===e.length?"0"+e:e)+(r=1===r.length?"0"+r:r)+(i=1===i.length?"0"+i:i)):"rgba("+e+", "+r+", "+i+", "+(n=0===n||1===n?n:n.toFixed(8))+")"}function r(e){return t.parseColorString(e,b)}function o(t){if(!(t=w.exec(t)))return null;var e=parseFloat(t[4]),n=16;switch(t[5]){case"em":case"rem":case"pc":n=16*e;break;case"pt":n=4*e/3;break;case"px":n=e;break;case"in":n=96*e;break;case"cm":n=96*e/2.54;break;case"mm":n=96/25.4*e;break;case"q":n=96/25.4/4*e;break;case"%":n=16/75*e}return{style:t[1],variant:t[2],weight:t[3],sizePx:n,family:t[6].trim()}}function a(a){this.Nd=a,this.Rd=new t.Paint,this.Rd.setAntiAlias(!0),this.Rd.setStrokeMiter(10),this.Rd.setStrokeCap(t.StrokeCap.Butt),this.Rd.setStrokeJoin(t.StrokeJoin.Miter),this.Re="10px monospace",this.ne=new t.Font(null,10),this.ne.setSubpixel(!0),this.ce=this.he=t.BLACK,this.ue=0,this.Ie=t.TRANSPARENT,this.we=this.ve=0,this.Je=this.ke=1,this.He=0,this.te=[],this.Pd=t.BlendMode.SrcOver,this.Rd.setStrokeWidth(this.Je),this.Rd.setBlendMode(this.Pd),this.Td=new t.Path,this.Ud=t.Matrix.identity(),this.lf=[],this.Ae=[],this.me=function(){this.Td.delete(),this.Rd.delete(),this.ne.delete(),this.Ae.forEach((function(t){t.me()}))},Object.defineProperty(this,"currentTransform",{enumerable:!0,get:function(){return{a:this.Ud[0],c:this.Ud[1],e:this.Ud[2],b:this.Ud[3],d:this.Ud[4],f:this.Ud[5]}},set:function(t){t.a&&this.setTransform(t.a,t.b,t.c,t.d,t.e,t.f)}}),Object.defineProperty(this,"fillStyle",{enumerable:!0,get:function(){return i(this.ce)?n(this.ce):this.ce},set:function(t){"string"==typeof t?this.ce=r(t):t.se&&(this.ce=t)}}),Object.defineProperty(this,"font",{enumerable:!0,get:function(){return this.Re},set:function(t){var e=o(t),n=e.family;e.typeface=C[n]?C[n][(e.style||"normal")+"|"+(e.variant||"normal")+"|"+(e.weight||"normal")]||C[n]["*"]:null,e&&(this.ne.setSize(e.sizePx),this.ne.setTypeface(e.typeface),this.Re=t)}}),Object.defineProperty(this,"globalAlpha",{enumerable:!0,get:function(){return this.ke},set:function(t){!isFinite(t)||0>t||1<t||(this.ke=t)}}),Object.defineProperty(this,"globalCompositeOperation",{enumerable:!0,get:function(){switch(this.Pd){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(e){switch(e){case"source-over":this.Pd=t.BlendMode.SrcOver;break;case"destination-over":this.Pd=t.BlendMode.DstOver;break;case"copy":this.Pd=t.BlendMode.Src;break;case"destination":this.Pd=t.BlendMode.Dst;break;case"clear":this.Pd=t.BlendMode.Clear;break;case"source-in":this.Pd=t.BlendMode.SrcIn;break;case"destination-in":this.Pd=t.BlendMode.DstIn;break;case"source-out":this.Pd=t.BlendMode.SrcOut;break;case"destination-out":this.Pd=t.BlendMode.DstOut;break;case"source-atop":this.Pd=t.BlendMode.SrcATop;break;case"destination-atop":this.Pd=t.BlendMode.DstATop;break;case"xor":this.Pd=t.BlendMode.Xor;break;case"lighter":case"plus-lighter":this.Pd=t.BlendMode.Plus;break;case"plus-darker":throw"plus-darker is not supported";case"multiply":this.Pd=t.BlendMode.Multiply;break;case"screen":this.Pd=t.BlendMode.Screen;break;case"overlay":this.Pd=t.BlendMode.Overlay;break;case"darken":this.Pd=t.BlendMode.Darken;break;case"lighten":this.Pd=t.BlendMode.Lighten;break;case"color-dodge":this.Pd=t.BlendMode.ColorDodge;break;case"color-burn":this.Pd=t.BlendMode.ColorBurn;break;case"hard-light":this.Pd=t.BlendMode.HardLight;break;case"soft-light":this.Pd=t.BlendMode.SoftLight;break;case"difference":this.Pd=t.BlendMode.Difference;break;case"exclusion":this.Pd=t.BlendMode.Exclusion;break;case"hue":this.Pd=t.BlendMode.Hue;break;case"saturation":this.Pd=t.BlendMode.Saturation;break;case"color":this.Pd=t.BlendMode.Color;break;case"luminosity":this.Pd=t.BlendMode.Luminosity;break;default:return}this.Rd.setBlendMode(this.Pd)}}),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.Rd.getStrokeCap()){case t.StrokeCap.Butt:return"butt";case t.StrokeCap.Round:return"round";case t.StrokeCap.Square:return"square"}},set:function(e){switch(e){case"butt":this.Rd.setStrokeCap(t.StrokeCap.Butt);break;case"round":this.Rd.setStrokeCap(t.StrokeCap.Round);break;case"square":this.Rd.setStrokeCap(t.StrokeCap.Square)}}}),Object.defineProperty(this,"lineDashOffset",{enumerable:!0,get:function(){return this.He},set:function(t){isFinite(t)&&(this.He=t)}}),Object.defineProperty(this,"lineJoin",{enumerable:!0,get:function(){switch(this.Rd.getStrokeJoin()){case t.StrokeJoin.Miter:return"miter";case t.StrokeJoin.Round:return"round";case t.StrokeJoin.Bevel:return"bevel"}},set:function(e){switch(e){case"miter":this.Rd.setStrokeJoin(t.StrokeJoin.Miter);break;case"round":this.Rd.setStrokeJoin(t.StrokeJoin.Round);break;case"bevel":this.Rd.setStrokeJoin(t.StrokeJoin.Bevel)}}}),Object.defineProperty(this,"lineWidth",{enumerable:!0,get:function(){return this.Rd.getStrokeWidth()},set:function(t){0>=t||!t||(this.Je=t,this.Rd.setStrokeWidth(t))}}),Object.defineProperty(this,"miterLimit",{enumerable:!0,get:function(){return this.Rd.getStrokeMiter()},set:function(t){0>=t||!t||this.Rd.setStrokeMiter(t)}}),Object.defineProperty(this,"shadowBlur",{enumerable:!0,get:function(){return this.ue},set:function(t){0>t||!isFinite(t)||(this.ue=t)}}),Object.defineProperty(this,"shadowColor",{enumerable:!0,get:function(){return n(this.Ie)},set:function(t){this.Ie=r(t)}}),Object.defineProperty(this,"shadowOffsetX",{enumerable:!0,get:function(){return this.ve},set:function(t){isFinite(t)&&(this.ve=t)}}),Object.defineProperty(this,"shadowOffsetY",{enumerable:!0,get:function(){return this.we},set:function(t){isFinite(t)&&(this.we=t)}}),Object.defineProperty(this,"strokeStyle",{enumerable:!0,get:function(){return n(this.he)},set:function(t){"string"==typeof t?this.he=r(t):t.se&&(this.he=t)}}),this.arc=function(t,e,n,r,i,o){p(this.Td,t,e,n,n,0,r,i,o)},this.arcTo=function(t,e,n,r,i){h(this.Td,t,e,n,r,i)},this.beginPath=function(){this.Td.delete(),this.Td=new t.Path},this.bezierCurveTo=function(t,n,r,i,o,a){var s=this.Td;e([t,n,r,i,o,a])&&(s.isEmpty()&&s.moveTo(t,n),s.cubicTo(t,n,r,i,o,a))},this.clearRect=function(e,n,r,i){this.Rd.setStyle(t.PaintStyle.Fill),this.Rd.setBlendMode(t.BlendMode.Clear),this.Nd.drawRect(t.XYWHRect(e,n,r,i),this.Rd),this.Rd.setBlendMode(this.Pd)},this.clip=function(e,n){"string"==typeof e?(n=e,e=this.Td):e&&e.af&&(e=e.Wd),e||(e=this.Td),e=e.copy(),n&&"evenodd"===n.toLowerCase()?e.setFillType(t.FillType.EvenOdd):e.setFillType(t.FillType.Winding),this.Nd.clipPath(e,t.ClipOp.Intersect,!0),e.delete()},this.closePath=function(){d(this.Td)},this.createImageData=function(){if(1===arguments.length){var t=arguments[0];return new u(new Uint8ClampedArray(4*t.width*t.height),t.width,t.height)}if(2===arguments.length){t=arguments[0];var e=arguments[1];return new u(new Uint8ClampedArray(4*t*e),t,e)}throw"createImageData expects 1 or 2 arguments, got "+arguments.length},this.createLinearGradient=function(t,n,r,i){if(e(arguments)){var o=new c(t,n,r,i);return this.Ae.push(o),o}},this.createPattern=function(t,e){return t=new m(t,e),this.Ae.push(t),t},this.createRadialGradient=function(t,n,r,i,o,a){if(e(arguments)){var s=new v(t,n,r,i,o,a);return this.Ae.push(s),s}},this.drawImage=function(e){e instanceof l&&(e=e.tf());var n=this.Qe();if(3===arguments.length||5===arguments.length)var r=t.XYWHRect(arguments[1],arguments[2],arguments[3]||e.width(),arguments[4]||e.height()),i=t.XYWHRect(0,0,e.width(),e.height());else{if(9!==arguments.length)throw"invalid number of args for drawImage, need 3, 5, or 9; got "+arguments.length;r=t.XYWHRect(arguments[5],arguments[6],arguments[7],arguments[8]),i=t.XYWHRect(arguments[1],arguments[2],arguments[3],arguments[4])}this.Nd.drawImageRect(e,i,r,n,!1),n.dispose()},this.ellipse=function(t,e,n,r,i,o,a,s){p(this.Td,t,e,n,r,i,o,a,s)},this.Qe=function(){var e=this.Rd.copy();if(e.setStyle(t.PaintStyle.Fill),i(this.ce)){var n=t.multiplyByAlpha(this.ce,this.ke);e.setColor(n)}else n=this.ce.se(this.Ud),e.setColor(t.Color(0,0,0,this.ke)),e.setShader(n);return e.dispose=function(){this.delete()},e},this.fill=function(e,n){if("string"==typeof e?(n=e,e=this.Td):e&&e.af&&(e=e.Wd),"evenodd"===n)this.Td.setFillType(t.FillType.EvenOdd);else{if("nonzero"!==n&&n)throw"invalid fill rule";this.Td.setFillType(t.FillType.Winding)}e||(e=this.Td),n=this.Qe();var r=this.xe(n);r&&(this.Nd.save(),this.qe(),this.Nd.drawPath(e,r),this.Nd.restore(),r.dispose()),this.Nd.drawPath(e,n),n.dispose()},this.fillRect=function(e,n,r,i){var o=this.Qe(),a=this.xe(o);a&&(this.Nd.save(),this.qe(),this.Nd.drawRect(t.XYWHRect(e,n,r,i),a),this.Nd.restore(),a.dispose()),this.Nd.drawRect(t.XYWHRect(e,n,r,i),o),o.dispose()},this.fillText=function(e,n,r){var i=this.Qe();e=t.TextBlob.MakeFromText(e,this.ne);var o=this.xe(i);o&&(this.Nd.save(),this.qe(),this.Nd.drawTextBlob(e,n,r,o),this.Nd.restore(),o.dispose()),this.Nd.drawTextBlob(e,n,r,i),e.delete(),i.dispose()},this.getImageData=function(e,n,r,i){return(e=this.Nd.readPixels(e,n,{width:r,height:i,colorType:t.ColorType.RGBA_8888,alphaType:t.AlphaType.Unpremul,colorSpace:t.ColorSpace.SRGB}))?new u(new Uint8ClampedArray(e.buffer),r,i):null},this.getLineDash=function(){return this.te.slice()},this.mf=function(e){var n=t.Matrix.invert(this.Ud);return t.Matrix.mapPoints(n,e),e},this.isPointInPath=function(e,n,r){var i=arguments;if(3===i.length)var o=this.Td;else{if(4!==i.length)throw"invalid arg count, need 3 or 4, got "+i.length;o=i[0],e=i[1],n=i[2],r=i[3]}return!(!isFinite(e)||!isFinite(n))&&("nonzero"===(r=r||"nonzero")||"evenodd"===r)&&(e=(i=this.mf([e,n]))[0],n=i[1],o.setFillType("nonzero"===r?t.FillType.Winding:t.FillType.EvenOdd),o.contains(e,n))},this.isPointInStroke=function(e,n){var r=arguments;if(2===r.length)var i=this.Td;else{if(3!==r.length)throw"invalid arg count, need 2 or 3, got "+r.length;i=r[0],e=r[1],n=r[2]}return!(!isFinite(e)||!isFinite(n))&&(e=(r=this.mf([e,n]))[0],n=r[1],(i=i.copy()).setFillType(t.FillType.Winding),i.stroke({width:this.lineWidth,miter_limit:this.miterLimit,cap:this.Rd.getStrokeCap(),join:this.Rd.getStrokeJoin(),precision:.3}),r=i.contains(e,n),i.delete(),r)},this.lineTo=function(t,e){g(this.Td,t,e)},this.measureText=function(t){t=this.ne.getGlyphIDs(t),t=this.ne.getGlyphWidths(t);let e=0;for(const n of t)e+=n;return{width:e}},this.moveTo=function(t,n){var r=this.Td;e([t,n])&&r.moveTo(t,n)},this.putImageData=function(n,r,i,o,a,s,l){if(e([r,i,o,a,s,l]))if(void 0===o)this.Nd.writePixels(n.data,n.width,n.height,r,i);else if(o=o||0,a=a||0,s=s||n.width,l=l||n.height,0>s&&(o+=s,s=Math.abs(s)),0>l&&(a+=l,l=Math.abs(l)),0>o&&(s+=o,o=0),0>a&&(l+=a,a=0),!(0>=s||0>=l)){n=t.MakeImage({width:n.width,height:n.height,alphaType:t.AlphaType.Unpremul,colorType:t.ColorType.RGBA_8888,colorSpace:t.ColorSpace.SRGB},n.data,4*n.width);var u=t.XYWHRect(o,a,s,l);r=t.XYWHRect(r+o,i+a,s,l),i=t.Matrix.invert(this.Ud),this.Nd.save(),this.Nd.concat(i),this.Nd.drawImageRect(n,u,r,null,!1),this.Nd.restore(),n.delete()}},this.quadraticCurveTo=function(t,n,r,i){var o=this.Td;e([t,n,r,i])&&(o.isEmpty()&&o.moveTo(t,n),o.quadTo(t,n,r,i))},this.rect=function(n,r,i,o){var a=this.Td;e(n=t.XYWHRect(n,r,i,o))&&a.addRect(n)},this.resetTransform=function(){this.Td.transform(this.Ud);var e=t.Matrix.invert(this.Ud);this.Nd.concat(e),this.Ud=this.Nd.getTotalMatrix()},this.restore=function(){var e=this.lf.pop();if(e){var n=t.Matrix.multiply(this.Ud,t.Matrix.invert(e.Ff));this.Td.transform(n),this.Rd.delete(),this.Rd=e.dg,this.te=e.$f,this.Je=e.vg,this.he=e.ug,this.ce=e.fs,this.ve=e.sg,this.we=e.tg,this.ue=e.hg,this.Ie=e.rg,this.ke=e.Nf,this.Pd=e.Of,this.He=e.ag,this.Re=e.Mf,this.Nd.restore(),this.Ud=this.Nd.getTotalMatrix()}},this.rotate=function(e){if(isFinite(e)){var n=t.Matrix.rotated(-e);this.Td.transform(n),this.Nd.rotate(e/Math.PI*180,0,0),this.Ud=this.Nd.getTotalMatrix()}},this.save=function(){if(this.ce.re){var t=this.ce.re();this.Ae.push(t)}else t=this.ce;if(this.he.re){var e=this.he.re();this.Ae.push(e)}else e=this.he;this.lf.push({Ff:this.Ud.slice(),$f:this.te.slice(),vg:this.Je,ug:e,fs:t,sg:this.ve,tg:this.we,hg:this.ue,rg:this.Ie,Nf:this.ke,ag:this.He,Of:this.Pd,dg:this.Rd.copy(),Mf:this.Re}),this.Nd.save()},this.scale=function(n,r){if(e(arguments)){var i=t.Matrix.scaled(1/n,1/r);this.Td.transform(i),this.Nd.scale(n,r),this.Ud=this.Nd.getTotalMatrix()}},this.setLineDash=function(t){for(var e=0;e<t.length;e++)if(!isFinite(t[e])||0>t[e])return;1==t.length%2&&Array.prototype.push.apply(t,t),this.te=t},this.setTransform=function(t,n,r,i,o,a){e(arguments)&&(this.resetTransform(),this.transform(t,n,r,i,o,a))},this.qe=function(){var e=t.Matrix.invert(this.Ud);this.Nd.concat(e),this.Nd.concat(t.Matrix.translated(this.ve,this.we)),this.Nd.concat(this.Ud)},this.xe=function(e){var n=t.multiplyByAlpha(this.Ie,this.ke);if(!t.getColorComponents(n)[3]||!(this.ue||this.we||this.ve))return null;(e=e.copy()).setColor(n);var r=t.MaskFilter.MakeBlur(t.BlurStyle.Normal,this.ue/2,!1);return e.setMaskFilter(r),e.dispose=function(){r.delete(),this.delete()},e},this.cf=function(){var e=this.Rd.copy();if(e.setStyle(t.PaintStyle.Stroke),i(this.he)){var n=t.multiplyByAlpha(this.he,this.ke);e.setColor(n)}else n=this.he.se(this.Ud),e.setColor(t.Color(0,0,0,this.ke)),e.setShader(n);if(e.setStrokeWidth(this.Je),this.te.length){var r=t.PathEffect.MakeDash(this.te,this.He);e.setPathEffect(r)}return e.dispose=function(){r&&r.delete(),this.delete()},e},this.stroke=function(t){t=t?t.Wd:this.Td;var e=this.cf(),n=this.xe(e);n&&(this.Nd.save(),this.qe(),this.Nd.drawPath(t,n),this.Nd.restore(),n.dispose()),this.Nd.drawPath(t,e),e.dispose()},this.strokeRect=function(e,n,r,i){var o=this.cf(),a=this.xe(o);a&&(this.Nd.save(),this.qe(),this.Nd.drawRect(t.XYWHRect(e,n,r,i),a),this.Nd.restore(),a.dispose()),this.Nd.drawRect(t.XYWHRect(e,n,r,i),o),o.dispose()},this.strokeText=function(e,n,r){var i=this.cf();e=t.TextBlob.MakeFromText(e,this.ne);var o=this.xe(i);o&&(this.Nd.save(),this.qe(),this.Nd.drawTextBlob(e,n,r,o),this.Nd.restore(),o.dispose()),this.Nd.drawTextBlob(e,n,r,i),e.delete(),i.dispose()},this.translate=function(n,r){if(e(arguments)){var i=t.Matrix.translated(-n,-r);this.Td.transform(i),this.Nd.translate(n,r),this.Ud=this.Nd.getTotalMatrix()}},this.transform=function(e,n,r,i,o,a){e=[e,r,o,n,i,a,0,0,1],n=t.Matrix.invert(e),this.Td.transform(n),this.Nd.concat(e),this.Ud=this.Nd.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 s(e){this.df=e,this.Md=new a(e.getCanvas()),this.Se=[],this.decodeImage=function(e){if(!(e=t.MakeImageFromEncoded(e)))throw"Invalid input";return this.Se.push(e),new l(e)},this.loadFont=function(e,n){if(!(e=t.Typeface.MakeFreeTypeFaceFromData(e)))return null;this.Se.push(e);var r=(n.style||"normal")+"|"+(n.variant||"normal")+"|"+(n.weight||"normal");n=n.family,C[n]||(C[n]={"*":e}),C[n][r]=e},this.makePath2D=function(t){return t=new y(t),this.Se.push(t.Wd),t},this.getContext=function(t){return"2d"===t?this.Md:null},this.toDataURL=function(e,n){this.df.flush();var r=this.df.makeImageSnapshot();if(r){e=e||"image/png";var i=t.ImageFormat.PNG;if("image/jpeg"===e&&(i=t.ImageFormat.JPEG),n=r.encodeToBytes(i,n||.92)){if(r.delete(),e="data:"+e+";base64,","undefined"!=typeof Buffer)n=Buffer.from(n).toString("base64");else{r=0,i=n.length;for(var o,a="";r<i;)o=n.slice(r,Math.min(r+32768,i)),a+=String.fromCharCode.apply(null,o),r+=32768;n=btoa(a)}return e+n}}},this.dispose=function(){this.Md.me(),this.Se.forEach((function(t){t.delete()})),this.df.dispose()}}function l(t){this.width=t.width(),this.height=t.height(),this.naturalWidth=this.width,this.naturalHeight=this.height,this.tf=function(){return t}}function u(t,e,n){if(!e||0===n)throw"invalid dimensions, width and height must be non-zero";if(t.length%4)throw"arr must be a multiple of 4";n=n||t.length/(4*e),Object.defineProperty(this,"data",{value:t,writable:!1}),Object.defineProperty(this,"height",{value:n,writable:!1}),Object.defineProperty(this,"width",{value:e,writable:!1})}function c(e,n,i,o){this.Yd=null,this.ee=[],this.ae=[],this.addColorStop=function(t,e){if(0>t||1<t||!isFinite(t))throw"offset must be between 0 and 1 inclusively";e=r(e);var n=this.ae.indexOf(t);if(-1!==n)this.ee[n]=e;else{for(n=0;n<this.ae.length&&!(this.ae[n]>t);n++);this.ae.splice(n,0,t),this.ee.splice(n,0,e)}},this.re=function(){var t=new c(e,n,i,o);return t.ee=this.ee.slice(),t.ae=this.ae.slice(),t},this.me=function(){this.Yd&&(this.Yd.delete(),this.Yd=null)},this.se=function(r){var a=[e,n,i,o];t.Matrix.mapPoints(r,a),r=a[0];var s=a[1],l=a[2];return a=a[3],this.me(),this.Yd=t.Shader.MakeLinearGradient([r,s],[l,a],this.ee,this.ae,t.TileMode.Clamp)}}function h(t,n,r,i,o,a){if(e([n,r,i,o,a])){if(0>a)throw"radii cannot be negative";t.isEmpty()&&t.moveTo(n,r),t.arcToTangent(n,r,i,o,a)}}function d(t){if(!t.isEmpty()){var e=t.getBounds();(e[3]-e[1]||e[2]-e[0])&&t.close()}}function f(e,n,r,i,o,a,s){s=(s-a)/Math.PI*180,a=a/Math.PI*180,n=t.LTRBRect(n-i,r-o,n+i,r+o),1e-5>Math.abs(Math.abs(s)-360)?(r=s/2,e.arcToOval(n,a,r,!1),e.arcToOval(n,a+r,r,!1)):e.arcToOval(n,a,s,!1)}function p(n,r,i,o,a,s,l,u,c){if(e([r,i,o,a,s,l,u])){if(0>o||0>a)throw"radii cannot be negative";var h=2*Math.PI,d=l%h;0>d&&(d+=h);var p=d-l;l=d,u+=p,!c&&u-l>=h?u=l+h:c&&l-u>=h?u=l-h:!c&&l>u?u=l+(h-(l-u)%h):c&&l<u&&(u=l-(h-(u-l)%h)),s?(c=t.Matrix.rotated(s,r,i),s=t.Matrix.rotated(-s,r,i),n.transform(s),f(n,r,i,o,a,l,u),n.transform(c)):f(n,r,i,o,a,l,u)}}function g(t,n,r){e([n,r])&&(t.isEmpty()&&t.moveTo(n,r),t.lineTo(n,r))}function y(n){this.Wd=null,this.Wd="string"==typeof n?t.Path.MakeFromSVGString(n):n&&n.af?n.Wd.copy():new t.Path,this.af=function(){return this.Wd},this.addPath=function(t,e){e||(e={a:1,c:0,e:0,b:0,d:1,f:0}),this.Wd.addPath(t.Wd,[e.a,e.c,e.e,e.b,e.d,e.f])},this.arc=function(t,e,n,r,i,o){p(this.Wd,t,e,n,n,0,r,i,o)},this.arcTo=function(t,e,n,r,i){h(this.Wd,t,e,n,r,i)},this.bezierCurveTo=function(t,n,r,i,o,a){var s=this.Wd;e([t,n,r,i,o,a])&&(s.isEmpty()&&s.moveTo(t,n),s.cubicTo(t,n,r,i,o,a))},this.closePath=function(){d(this.Wd)},this.ellipse=function(t,e,n,r,i,o,a,s){p(this.Wd,t,e,n,r,i,o,a,s)},this.lineTo=function(t,e){g(this.Wd,t,e)},this.moveTo=function(t,n){var r=this.Wd;e([t,n])&&r.moveTo(t,n)},this.quadraticCurveTo=function(t,n,r,i){var o=this.Wd;e([t,n,r,i])&&(o.isEmpty()&&o.moveTo(t,n),o.quadTo(t,n,r,i))},this.rect=function(n,r,i,o){var a=this.Wd;e(n=t.XYWHRect(n,r,i,o))&&a.addRect(n)}}function m(n,r){switch(this.Yd=null,n instanceof l&&(n=n.tf()),this.Af=n,this._transform=t.Matrix.identity(),""===r&&(r="repeat"),r){case"repeat-x":this.ye=t.TileMode.Repeat,this.ze=t.TileMode.Decal;break;case"repeat-y":this.ye=t.TileMode.Decal,this.ze=t.TileMode.Repeat;break;case"repeat":this.ze=this.ye=t.TileMode.Repeat;break;case"no-repeat":this.ze=this.ye=t.TileMode.Decal;break;default:throw"invalid repetition mode "+r}this.setTransform=function(t){e(t=[t.a,t.c,t.e,t.b,t.d,t.f,0,0,1])&&(this._transform=t)},this.re=function(){var t=new m;return t.ye=this.ye,t.ze=this.ze,t},this.me=function(){this.Yd&&(this.Yd.delete(),this.Yd=null)},this.se=function(){return this.me(),this.Yd=this.Af.makeShaderCubic(this.ye,this.ze,1/3,1/3,this._transform)}}function v(e,n,i,o,a,s){this.Yd=null,this.ee=[],this.ae=[],this.addColorStop=function(t,e){if(0>t||1<t||!isFinite(t))throw"offset must be between 0 and 1 inclusively";e=r(e);var n=this.ae.indexOf(t);if(-1!==n)this.ee[n]=e;else{for(n=0;n<this.ae.length&&!(this.ae[n]>t);n++);this.ae.splice(n,0,t),this.ee.splice(n,0,e)}},this.re=function(){var t=new v(e,n,i,o,a,s);return t.ee=this.ee.slice(),t.ae=this.ae.slice(),t},this.me=function(){this.Yd&&(this.Yd.delete(),this.Yd=null)},this.se=function(r){var l=[e,n,o,a];t.Matrix.mapPoints(r,l);var u=l[0],c=l[1],h=l[2];l=l[3];var d=(Math.abs(r[0])+Math.abs(r[4]))/2;return r=i*d,d*=s,this.me(),this.Yd=t.Shader.MakeTwoPointConicalGradient([u,c],r,[h,l],d,this.ee,this.ae,t.TileMode.Clamp)}}t._testing={};var b={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=r,t._testing.colorToString=n;var w=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)(.+)"),C={"Noto Mono":{"*":null},monospace:{"*":null}};t._testing.parseFontString=o,t.MakeCanvas=function(e,n){return(e=t.MakeSurface(e,n))?new s(e):null},t.ImageData=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];return new u(new Uint8ClampedArray(4*t*e),t,e)}if(3===arguments.length){var n=arguments[0];if(n.prototype.constructor!==Uint8ClampedArray)throw"bytes must be given as a Uint8ClampedArray";if(n%4)throw"bytes must be given in a multiple of 4";if(n%(t=arguments[1]))throw"bytes must divide evenly by width";if((e=arguments[2])&&e!==n/(4*t))throw"invalid height given";return new u(n,t,n/(4*t))}throw"invalid number of arguments - takes 2 or 3, saw "+arguments.length}}()}(e);var s,l,u,h,d,f,p=a({},e),g="./this.program",y=(t,e)=>{throw e},m="object"==typeof window,v="function"==typeof importScripts,b="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,A="";b?(A=v?w.dirname(A)+"/":__dirname+"/",f=()=>{d||(h=C,d=w)},s=function(t,e){return f(),t=d.normalize(t),h.readFileSync(t,e?null:"utf8")},u=t=>((t=s(t,!0)).buffer||(t=new Uint8Array(t)),t),l=(t,e,n)=>{f(),t=d.normalize(t),h.readFile(t,(function(t,r){t?n(t):e(r.buffer)}))},1<process.argv.length&&(g=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),process.on("uncaughtException",(function(t){if(!(t instanceof Pn))throw t})),process.on("unhandledRejection",(function(t){throw t})),y=(t,e)=>{if(M||0<nt)throw process.exitCode=t,e;e instanceof Pn||S("exiting due to exception: "+e),process.exit(t)},e.inspect=function(){return"[Emscripten Module object]"}):(m||v)&&(v?A=self.location.href:"undefined"!=typeof document&&document.currentScript&&(A=document.currentScript.src),n&&(A=n),A=0!==A.indexOf("blob:")?A.substr(0,A.replace(/[?#].*/,"").lastIndexOf("/")+1):"",s=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.send(null),e.responseText},v&&(u=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),l=(t,e,n)=>{var r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType="arraybuffer",r.onload=()=>{200==r.status||0==r.status&&r.response?e(r.response):n()},r.onerror=n,r.send(null)});var T=e.print||console.log.bind(console),S=e.printErr||console.warn.bind(console);a(e,p),p=null,e.thisProgram&&(g=e.thisProgram),e.quit&&(y=e.quit);var P,_=0;e.wasmBinary&&(P=e.wasmBinary);var M=e.noExitRuntime||!0;"object"!=typeof WebAssembly&&st("no native wasm support detected");var k,x=!1,F="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function E(t,e,n){var r=e+n;for(n=e;t[n]&&!(n>=r);)++n;if(16<n-e&&t.subarray&&F)return F.decode(t.subarray(e,n));for(r="";e<n;){var i=t[e++];if(128&i){var o=63&t[e++];if(192==(224&i))r+=String.fromCharCode((31&i)<<6|o);else{var a=63&t[e++];65536>(i=224==(240&i)?(15&i)<<12|o<<6|a:(7&i)<<18|o<<12|a<<6|63&t[e++])?r+=String.fromCharCode(i):(i-=65536,r+=String.fromCharCode(55296|i>>10,56320|1023&i))}}else r+=String.fromCharCode(i)}return r}function O(t,e){return t?E(D,t,e):""}function B(t,e,n,r){if(!(0<r))return 0;var i=n;r=n+r-1;for(var o=0;o<t.length;++o){var a=t.charCodeAt(o);if(55296<=a&&57343>=a&&(a=65536+((1023&a)<<10)|1023&t.charCodeAt(++o)),127>=a){if(n>=r)break;e[n++]=a}else{if(2047>=a){if(n+1>=r)break;e[n++]=192|a>>6}else{if(65535>=a){if(n+2>=r)break;e[n++]=224|a>>12}else{if(n+3>=r)break;e[n++]=240|a>>18,e[n++]=128|a>>12&63}e[n++]=128|a>>6&63}e[n++]=128|63&a}}return e[n]=0,n-i}function R(t){for(var e=0,n=0;n<t.length;++n){var r=t.charCodeAt(n);55296<=r&&57343>=r&&(r=65536+((1023&r)<<10)|1023&t.charCodeAt(++n)),127>=r?++e:e=2047>=r?e+2:65535>=r?e+3:e+4}return e}var L,I,D,W,j,z,G,N,U,H="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0;function V(t,e){for(var n=t>>1,r=n+e/2;!(n>=r)&&j[n];)++n;if(32<(n<<=1)-t&&H)return H.decode(D.subarray(t,n));for(n="",r=0;!(r>=e/2);++r){var i=W[t+2*r>>1];if(0==i)break;n+=String.fromCharCode(i)}return n}function $(t,e,n){if(void 0===n&&(n=2147483647),2>n)return 0;var r=e;n=(n-=2)<2*t.length?n/2:t.length;for(var i=0;i<n;++i)W[e>>1]=t.charCodeAt(i),e+=2;return W[e>>1]=0,e-r}function Y(t){return 2*t.length}function X(t,e){for(var n=0,r="";!(n>=e/4);){var i=z[t+4*n>>2];if(0==i)break;++n,65536<=i?(i-=65536,r+=String.fromCharCode(55296|i>>10,56320|1023&i)):r+=String.fromCharCode(i)}return r}function q(t,e,n){if(void 0===n&&(n=2147483647),4>n)return 0;var r=e;n=r+n-4;for(var i=0;i<t.length;++i){var o=t.charCodeAt(i);if(55296<=o&&57343>=o&&(o=65536+((1023&o)<<10)|1023&t.charCodeAt(++i)),z[e>>2]=o,(e+=4)+4>n)break}return z[e>>2]=0,e-r}function Q(t){for(var e=0,n=0;n<t.length;++n){var r=t.charCodeAt(n);55296<=r&&57343>=r&&++n,e+=4}return e}function K(){var t=k.buffer;L=t,e.HEAP8=I=new Int8Array(t),e.HEAP16=W=new Int16Array(t),e.HEAP32=z=new Int32Array(t),e.HEAPU8=D=new Uint8Array(t),e.HEAPU16=j=new Uint16Array(t),e.HEAPU32=G=new Uint32Array(t),e.HEAPF32=N=new Float32Array(t),e.HEAPF64=U=new Float64Array(t)}var J,Z=[],tt=[],et=[],nt=0;function rt(){var t=e.preRun.shift();Z.unshift(t)}var it,ot=0,at=null;function st(t){throw e.onAbort&&e.onAbort(t),S(t="Aborted("+t+")"),x=!0,t=new WebAssembly.RuntimeError(t+". Build with -s ASSERTIONS=1 for more info."),i(t),t}function lt(){return it.startsWith("data:application/octet-stream;base64,")}if(e.preloadedImages={},e.preloadedAudios={},it="canvaskit.wasm",!lt()){var ut=it;it=e.locateFile?e.locateFile(ut,A):A+ut}function ct(){var t=it;try{if(t==it&&P)return new Uint8Array(P);if(u)return u(t);throw"both async and sync fetching of the wasm failed"}catch(t){st(t)}}function ht(t){for(;0<t.length;){var n=t.shift();if("function"==typeof n)n(e);else{var r=n.Dg;"number"==typeof r?void 0===n.ef?dt(r)():dt(r)(n.ef):r(void 0===n.ef?null:n.ef)}}}function dt(t){return J.get(t)}function ft(t){this.Qd=t-16,this.mg=function(t){z[this.Qd+4>>2]=t},this.jg=function(t){z[this.Qd+8>>2]=t},this.kg=function(){z[this.Qd>>2]=0},this.ig=function(){I[this.Qd+12>>0]=0},this.lg=function(){I[this.Qd+13>>0]=0},this.Xf=function(t,e){this.mg(t),this.jg(e),this.kg(),this.ig(),this.lg()}}var pt={},gt=[null,[],[]],yt={},mt={};function vt(t){for(;t.length;){var e=t.pop();t.pop()(e)}}function bt(t){return this.fromWireType(G[t>>2])}var wt={},Ct={},At={};function Tt(t){if(void 0===t)return"_unknown";var e=(t=t.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return 48<=e&&57>=e?"_"+t:t}function St(t,e){return t=Tt(t),function(){return e.apply(this,arguments)}}function Pt(t){var e=Error,n=St(t,(function(e){this.name=t,this.message=e,void 0!==(e=Error(e).stack)&&(this.stack=this.toString()+"\n"+e.replace(/^Error(:[^\n]*)?\n/,""))}));return n.prototype=Object.create(e.prototype),n.prototype.constructor=n,n.prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message},n}var _t=void 0;function Mt(t){throw new _t(t)}function kt(t,e,n){function r(e){(e=n(e)).length!==t.length&&Mt("Mismatched type converter count");for(var r=0;r<t.length;++r)Rt(t[r],e[r])}t.forEach((function(t){At[t]=e}));var i=Array(e.length),o=[],a=0;e.forEach((function(t,e){Ct.hasOwnProperty(t)?i[e]=Ct[t]:(o.push(t),wt.hasOwnProperty(t)||(wt[t]=[]),wt[t].push((function(){i[e]=Ct[t],++a===o.length&&r(i)})))})),0===o.length&&r(i)}function xt(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 Ft=void 0;function Et(t){for(var e="";D[t];)e+=Ft[D[t++]];return e}var Ot=void 0;function Bt(t){throw new Ot(t)}function Rt(t,e,n={}){if(!("argPackAdvance"in e))throw new TypeError("registerType registeredInstance requires argPackAdvance");var r=e.name;if(t||Bt('type "'+r+'" must have a positive integer typeid pointer'),Ct.hasOwnProperty(t)){if(n.Wf)return;Bt("Cannot register type '"+r+"' twice")}Ct[t]=e,delete At[t],wt.hasOwnProperty(t)&&(e=wt[t],delete wt[t],e.forEach((function(t){t()})))}function Lt(t){Bt(t.Ld.Xd.Sd.name+" instance already deleted")}var It=!1;function Dt(){}function Wt(t){--t.count.value,0===t.count.value&&(t.$d?t.ge.le(t.$d):t.Xd.Sd.le(t.Qd))}function jt(t){return"undefined"==typeof FinalizationGroup?(jt=t=>t,t):(It=new FinalizationGroup((function(t){for(var e=t.next();!e.done;e=t.next())(e=e.value).Qd?Wt(e):console.warn("object already deleted: "+e.Qd)})),Dt=t=>{It.unregister(t.Ld)},(jt=t=>(It.register(t,t.Ld,t.Ld),t))(t))}var zt=void 0,Gt=[];function Nt(){for(;Gt.length;){var t=Gt.pop();t.Ld.De=!1,t.delete()}}function Ut(){}var Ht={};function Vt(t,e,n){if(void 0===t[e].Zd){var r=t[e];t[e]=function(){return t[e].Zd.hasOwnProperty(arguments.length)||Bt("Function '"+n+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+t[e].Zd+")!"),t[e].Zd[arguments.length].apply(this,arguments)},t[e].Zd=[],t[e].Zd[r.Be]=r}}function $t(t,n,r){e.hasOwnProperty(t)?((void 0===r||void 0!==e[t].Zd&&void 0!==e[t].Zd[r])&&Bt("Cannot register public name '"+t+"' twice"),Vt(e,t,t),e.hasOwnProperty(r)&&Bt("Cannot register multiple overloads of a function with the same number of arguments ("+r+")!"),e[t].Zd[r]=n):(e[t]=n,void 0!==r&&(e[t].Fg=r))}function Yt(t,e,n,r,i,o,a,s){this.name=t,this.constructor=e,this.Ee=n,this.le=r,this.ie=i,this.Pf=o,this.Pe=a,this.Jf=s,this.fg=[]}function Xt(t,e,n){for(;e!==n;)e.Pe||Bt("Expected null or instance of "+n.name+", got an instance of "+e.name),t=e.Pe(t),e=e.ie;return t}function qt(t,e){return null===e?(this.gf&&Bt("null is not a valid "+this.name),0):(e.Ld||Bt('Cannot pass "'+ye(e)+'" as a '+this.name),e.Ld.Qd||Bt("Cannot pass deleted object as a pointer of type "+this.name),Xt(e.Ld.Qd,e.Ld.Xd.Sd,this.Sd))}function Qt(t,e){if(null===e){if(this.gf&&Bt("null is not a valid "+this.name),this.Ue){var n=this.hf();return null!==t&&t.push(this.le,n),n}return 0}if(e.Ld||Bt('Cannot pass "'+ye(e)+'" as a '+this.name),e.Ld.Qd||Bt("Cannot pass deleted object as a pointer of type "+this.name),!this.Te&&e.Ld.Xd.Te&&Bt("Cannot convert argument of type "+(e.Ld.ge?e.Ld.ge.name:e.Ld.Xd.name)+" to parameter type "+this.name),n=Xt(e.Ld.Qd,e.Ld.Xd.Sd,this.Sd),this.Ue)switch(void 0===e.Ld.$d&&Bt("Passing raw pointer to smart pointer is illegal"),this.qg){case 0:e.Ld.ge===this?n=e.Ld.$d:Bt("Cannot convert argument of type "+(e.Ld.ge?e.Ld.ge.name:e.Ld.Xd.name)+" to parameter type "+this.name);break;case 1:n=e.Ld.$d;break;case 2:if(e.Ld.ge===this)n=e.Ld.$d;else{var r=e.clone();n=this.gg(n,fe((function(){r.delete()}))),null!==t&&t.push(this.le,n)}break;default:Bt("Unsupporting sharing policy")}return n}function Kt(t,e){return null===e?(this.gf&&Bt("null is not a valid "+this.name),0):(e.Ld||Bt('Cannot pass "'+ye(e)+'" as a '+this.name),e.Ld.Qd||Bt("Cannot pass deleted object as a pointer of type "+this.name),e.Ld.Xd.Te&&Bt("Cannot convert argument of type "+e.Ld.Xd.name+" to parameter type "+this.name),Xt(e.Ld.Qd,e.Ld.Xd.Sd,this.Sd))}function Jt(t,e,n){return e===n?t:void 0===n.ie||null===(t=Jt(t,e,n.ie))?null:n.Jf(t)}var Zt={};function te(t,e){return e.Xd&&e.Qd||Mt("makeClassHandle requires ptr and ptrType"),!!e.ge!=!!e.$d&&Mt("Both smartPtrType and smartPtr must be specified"),e.count={value:1},jt(Object.create(t,{Ld:{value:e}}))}function ee(t,e,n,r,i,o,a,s,l,u,c){this.name=t,this.Sd=e,this.gf=n,this.Te=r,this.Ue=i,this.eg=o,this.qg=a,this.vf=s,this.hf=l,this.gg=u,this.le=c,i||void 0!==e.ie?this.toWireType=Qt:(this.toWireType=r?qt:Kt,this.fe=null)}function ne(t,n,r){e.hasOwnProperty(t)||Mt("Replacing nonexistant public symbol"),void 0!==e[t].Zd&&void 0!==r?e[t].Zd[r]=n:(e[t]=n,e[t].Be=r)}function re(t,n){var r=(t=Et(t)).includes("j")?function(t,n){var r=[];return function(){r.length=arguments.length;for(var i=0;i<arguments.length;i++)r[i]=arguments[i];return t.includes("j")?(i=e["dynCall_"+t],i=r&&r.length?i.apply(null,[n].concat(r)):i.call(null,n)):i=dt(n).apply(null,r),i}}(t,n):dt(n);return"function"!=typeof r&&Bt("unknown function pointer with signature "+t+": "+n),r}var ie=void 0;function oe(t){var e=Et(t=bn(t));return mn(t),e}function ae(t,e){var n=[],r={};throw e.forEach((function t(e){r[e]||Ct[e]||(At[e]?At[e].forEach(t):(n.push(e),r[e]=!0))})),new ie(t+": "+n.map(oe).join([", "]))}function se(t,e,n,r,i){var o=e.length;2>o&&Bt("argTypes array size mismatch! Must at least get return value and 'this' types!");var a=null!==e[1]&&null!==n,s=!1;for(n=1;n<e.length;++n)if(null!==e[n]&&void 0===e[n].fe){s=!0;break}var l="void"!==e[0].name,u=o-2,c=Array(u),h=[],d=[];return function(){if(arguments.length!==u&&Bt("function "+t+" called with "+arguments.length+" arguments, expected "+u+" args!"),d.length=0,h.length=a?2:1,h[0]=i,a){var n=e[1].toWireType(d,this);h[1]=n}for(var o=0;o<u;++o)c[o]=e[o+2].toWireType(d,arguments[o]),h.push(c[o]);if(o=r.apply(null,h),s)vt(d);else for(var f=a?1:2;f<e.length;f++){var p=1===f?n:c[f-2];null!==e[f].fe&&e[f].fe(p)}return l?e[0].fromWireType(o):void 0}}function le(t,e){for(var n=[],r=0;r<t;r++)n.push(z[(e>>2)+r]);return n}var ue=[],ce=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function he(t){4<t&&0==--ce[t].jf&&(ce[t]=void 0,ue.push(t))}function de(t){return t||Bt("Cannot use deleted val. handle = "+t),ce[t].value}function fe(t){switch(t){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:var e=ue.length?ue.pop():ce.length;return ce[e]={jf:1,value:t},e}}function pe(t,e,n){switch(e){case 0:return function(t){return this.fromWireType((n?I:D)[t])};case 1:return function(t){return this.fromWireType((n?W:j)[t>>1])};case 2:return function(t){return this.fromWireType((n?z:G)[t>>2])};default:throw new TypeError("Unknown integer type: "+t)}}function ge(t,e){var n=Ct[t];return void 0===n&&Bt(e+" has unknown type "+oe(t)),n}function ye(t){if(null===t)return"null";var e=typeof t;return"object"===e||"array"===e||"function"===e?t.toString():""+t}function me(t,e){switch(e){case 2:return function(t){return this.fromWireType(N[t>>2])};case 3:return function(t){return this.fromWireType(U[t>>3])};default:throw new TypeError("Unknown float type: "+t)}}function ve(t,e,n){switch(e){case 0:return n?function(t){return I[t]}:function(t){return D[t]};case 1:return n?function(t){return W[t>>1]}:function(t){return j[t>>1]};case 2:return n?function(t){return z[t>>2]}:function(t){return G[t>>2]};default:throw new TypeError("Unknown integer type: "+t)}}var be={};function we(t){var e=be[t];return void 0===e?Et(t):e}var Ce=[];function Ae(){function t(t){t.$$$embind_global$$$=t;var e="object"==typeof $$$embind_global$$$&&t.$$$embind_global$$$===t;return e||delete t.$$$embind_global$$$,e}if("object"==typeof globalThis)return globalThis;if("object"==typeof $$$embind_global$$$)return $$$embind_global$$$;if("object"==typeof c&&t(c)?$$$embind_global$$$=c:"object"==typeof self&&t(self)&&($$$embind_global$$$=self),"object"==typeof $$$embind_global$$$)return $$$embind_global$$$;throw Error("unable to get global object.")}var Te,Se=[],Pe={};Te=b?()=>{var t=process.hrtime();return 1e3*t[0]+t[1]/1e6}:()=>performance.now();var _e=1,Me=[],ke=[],xe=[],Fe=[],Ee=[],Oe=[],Be=[],Re=[],Le=[],Ie=[],De={},We={},je=4;function ze(t){He||(He=t)}function Ge(t){for(var e=_e++,n=t.length;n<e;n++)t[n]=null;return e}function Ne(t){return Ue=Re[t],e.Cg=hn=Ue&&Ue.je,!(t&&!hn)}var Ue,He,Ve=[];function $e(t,e,n,r){for(var i=0;i<t;i++){var o=hn[n](),a=o&&Ge(r);o?(o.name=a,r[a]=o):ze(1282),z[e+4*i>>2]=a}}function Ye(t){var e=R(t)+1,n=yn(e);return B(t,D,n,e),n}function Xe(t){return"]"==t.slice(-1)&&t.lastIndexOf("[")}function qe(t){return 0==(t-=5120)?I:1==t?D:2==t?W:4==t?z:6==t?N:5==t||28922==t||28520==t||30779==t||30782==t?G:j}function Qe(t,e,n,r,i){t=qe(t);var o=31-Math.clz32(t.BYTES_PER_ELEMENT),a=je;return t.subarray(i>>o,i+r*(n*({5:3,6:4,8:2,29502:3,29504:4,26917:2,26918:2,29846:3,29847:4}[e-6402]||1)*(1<<o)+a-1&-a)>>o)}function Ke(t){var e=hn.Gf;if(e){var n=e.Oe[t];return"number"==typeof n&&(e.Oe[t]=n=hn.getUniformLocation(e,e.wf[t]+(0<n?"["+n+"]":""))),n}ze(1282)}var Je,Ze=[],tn=[],en={};function nn(){if(!Je){var t,e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:g||"./this.program"};for(t in en)void 0===en[t]?delete e[t]:e[t]=en[t];var n=[];for(t in e)n.push(t+"="+e[t]);Je=n}return Je}function rn(t){return 0==t%4&&(0!=t%100||0==t%400)}function on(t,e){for(var n=0,r=0;r<=e;n+=t[r++]);return n}var an=[31,29,31,30,31,30,31,31,30,31,30,31],sn=[31,28,31,30,31,30,31,31,30,31,30,31];function ln(t,e){for(t=new Date(t.getTime());0<e;){var n=t.getMonth(),r=(rn(t.getFullYear())?an:sn)[n];if(!(e>r-t.getDate())){t.setDate(t.getDate()+e);break}e-=r-t.getDate()+1,t.setDate(1),11>n?t.setMonth(n+1):(t.setMonth(0),t.setFullYear(t.getFullYear()+1))}return t}_t=e.InternalError=Pt("InternalError");for(var un=Array(256),cn=0;256>cn;++cn)un[cn]=String.fromCharCode(cn);Ft=un,Ot=e.BindingError=Pt("BindingError"),Ut.prototype.isAliasOf=function(t){if(!(this instanceof Ut&&t instanceof Ut))return!1;var e=this.Ld.Xd.Sd,n=this.Ld.Qd,r=t.Ld.Xd.Sd;for(t=t.Ld.Qd;e.ie;)n=e.Pe(n),e=e.ie;for(;r.ie;)t=r.Pe(t),r=r.ie;return e===r&&n===t},Ut.prototype.clone=function(){if(this.Ld.Qd||Lt(this),this.Ld.Me)return this.Ld.count.value+=1,this;var t=jt,e=Object,n=e.create,r=Object.getPrototypeOf(this),i=this.Ld;return(t=t(n.call(e,r,{Ld:{value:{count:i.count,De:i.De,Me:i.Me,Qd:i.Qd,Xd:i.Xd,$d:i.$d,ge:i.ge}}}))).Ld.count.value+=1,t.Ld.De=!1,t},Ut.prototype.delete=function(){this.Ld.Qd||Lt(this),this.Ld.De&&!this.Ld.Me&&Bt("Object already scheduled for deletion"),Dt(this),Wt(this.Ld),this.Ld.Me||(this.Ld.$d=void 0,this.Ld.Qd=void 0)},Ut.prototype.isDeleted=function(){return!this.Ld.Qd},Ut.prototype.deleteLater=function(){return this.Ld.Qd||Lt(this),this.Ld.De&&!this.Ld.Me&&Bt("Object already scheduled for deletion"),Gt.push(this),1===Gt.length&&zt&&zt(Nt),this.Ld.De=!0,this},ee.prototype.Qf=function(t){return this.vf&&(t=this.vf(t)),t},ee.prototype.nf=function(t){this.le&&this.le(t)},ee.prototype.argPackAdvance=8,ee.prototype.readValueFromPointer=bt,ee.prototype.deleteObject=function(t){null!==t&&t.delete()},ee.prototype.fromWireType=function(t){function e(){return this.Ue?te(this.Sd.Ee,{Xd:this.eg,Qd:n,ge:this,$d:t}):te(this.Sd.Ee,{Xd:this,Qd:t})}var n=this.Qf(t);if(!n)return this.nf(t),null;var r=function(t,e){for(void 0===e&&Bt("ptr should not be undefined");t.ie;)e=t.Pe(e),t=t.ie;return Zt[e]}(this.Sd,n);if(void 0!==r)return 0===r.Ld.count.value?(r.Ld.Qd=n,r.Ld.$d=t,r.clone()):(r=r.clone(),this.nf(t),r);if(r=this.Sd.Pf(n),!(r=Ht[r]))return e.call(this);r=this.Te?r.Ef:r.pointerType;var i=Jt(n,this.Sd,r.Sd);return null===i?e.call(this):this.Ue?te(r.Sd.Ee,{Xd:r,Qd:i,ge:this,$d:t}):te(r.Sd.Ee,{Xd:r,Qd:i})},e.getInheritedInstanceCount=function(){return Object.keys(Zt).length},e.getLiveInheritedInstances=function(){var t,e=[];for(t in Zt)Zt.hasOwnProperty(t)&&e.push(Zt[t]);return e},e.flushPendingDeletes=Nt,e.setDelayFunction=function(t){zt=t,Gt.length&&zt&&zt(Nt)},ie=e.UnboundTypeError=Pt("UnboundTypeError"),e.count_emval_handles=function(){for(var t=0,e=5;e<ce.length;++e)void 0!==ce[e]&&++t;return t},e.get_first_emval=function(){for(var t=5;t<ce.length;++t)if(void 0!==ce[t])return ce[t];return null};for(var hn,dn=0;32>dn;++dn)Ve.push(Array(dn));var fn=new Float32Array(288);for(dn=0;288>dn;++dn)Ze[dn]=fn.subarray(0,dn+1);var pn=new Int32Array(288);for(dn=0;288>dn;++dn)tn[dn]=pn.subarray(0,dn+1);var gn={Lb:function(t){return yn(t+16)+16},Eb:function(t,e,n){throw new ft(t).Xf(e,n),t},P:function(){return 0},zb:function(){},xb:function(){},Cb:function(){return 0},wb:function(){},tb:function(t,e,n,r,i,o){if(o<<=12,0!=(16&r)&&0!=t%65536)e=-28;else if(0!=(32&r)){t=65536*Math.ceil(e/65536);var a=Cn(65536,t);a?(D.fill(0,a,a+t),t=a):t=0,t?(pt[t]={cg:t,bg:e,Df:!0,fd:i,Gg:n,flags:r,offset:o},e=t):e=-48}else e=-52;return e},sb:function(t,e){var n=pt[t];return 0!==e&&n?(e===n.bg&&(pt[t]=null,n.Df&&mn(n.cg)),t=0):t=-28,t},Q:function(){},yb:function(){},x:function(t){var e=mt[t];delete mt[t];var n=e.hf,r=e.le,i=e.rf;kt([t],i.map((function(t){return t.Uf})).concat(i.map((function(t){return t.og}))),(function(t){var o={};return i.forEach((function(e,n){var r=t[n],a=e.Sf,s=e.Tf,l=t[n+i.length],u=e.ng,c=e.pg;o[e.Lf]={read:function(t){return r.fromWireType(a(s,t))},write:function(t,e){var n=[];u(c,t,l.toWireType(n,e)),vt(n)}}})),[{name:e.name,fromWireType:function(t){var e,n={};for(e in o)n[e]=o[e].read(t);return r(t),n},toWireType:function(t,e){for(var i in o)if(!(i in e))throw new TypeError('Missing field: "'+i+'"');var a=n();for(i in o)o[i].write(a,e[i]);return null!==t&&t.push(r,a),a},argPackAdvance:8,readValueFromPointer:bt,fe:r}]}))},mb:function(){},Fb:function(t,e,n,r,i){var o=xt(n);Rt(t,{name:e=Et(e),fromWireType:function(t){return!!t},toWireType:function(t,e){return e?r:i},argPackAdvance:8,readValueFromPointer:function(t){if(1===n)var r=I;else if(2===n)r=W;else{if(4!==n)throw new TypeError("Unknown boolean type size: "+e);r=z}return this.fromWireType(r[t>>o])},fe:null})},l:function(t,e,n,r,i,o,a,s,l,u,c,h,d){c=Et(c),o=re(i,o),s&&(s=re(a,s)),u&&(u=re(l,u)),d=re(h,d);var f=Tt(c);$t(f,(function(){ae("Cannot construct "+c+" due to unbound types",[r])})),kt([t,e,n],r?[r]:[],(function(e){if(e=e[0],r)var n=e.Sd,i=n.Ee;else i=Ut.prototype;e=St(f,(function(){if(Object.getPrototypeOf(this)!==a)throw new Ot("Use 'new' to construct "+c);if(void 0===l.oe)throw new Ot(c+" has no accessible constructor");var t=l.oe[arguments.length];if(void 0===t)throw new Ot("Tried to invoke ctor of "+c+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(l.oe).toString()+") parameters instead!");return t.apply(this,arguments)}));var a=Object.create(i,{constructor:{value:e}});e.prototype=a;var l=new Yt(c,e,a,d,n,o,s,u);n=new ee(c,l,!0,!1,!1),i=new ee(c+"*",l,!1,!1,!1);var h=new ee(c+" const*",l,!1,!0,!1);return Ht[t]={pointerType:i,Ef:h},ne(f,e),[n,i,h]}))},e:function(t,e,n,r,i,o,a){var s=le(n,r);e=Et(e),o=re(i,o),kt([],[t],(function(t){function r(){ae("Cannot call "+i+" due to unbound types",s)}var i=(t=t[0]).name+"."+e;e.startsWith("@@")&&(e=Symbol[e.substring(2)]);var l=t.Sd.constructor;return void 0===l[e]?(r.Be=n-1,l[e]=r):(Vt(l,e,i),l[e].Zd[n-1]=r),kt([],s,(function(t){return t=[t[0],null].concat(t.slice(1)),t=se(i,t,null,o,a),void 0===l[e].Zd?(t.Be=n-1,l[e]=t):l[e].Zd[n-1]=t,[]})),[]}))},u:function(t,e,n,r,i,o){0<e||st(void 0);var a=le(e,n);i=re(r,i),kt([],[t],(function(t){var n="constructor "+(t=t[0]).name;if(void 0===t.Sd.oe&&(t.Sd.oe=[]),void 0!==t.Sd.oe[e-1])throw new Ot("Cannot register multiple constructors with identical number of parameters ("+(e-1)+") for class '"+t.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");return t.Sd.oe[e-1]=()=>{ae("Cannot construct "+t.name+" due to unbound types",a)},kt([],a,(function(r){return r.splice(1,0,null),t.Sd.oe[e-1]=se(n,r,null,i,o),[]})),[]}))},d:function(t,e,n,r,i,o,a,s){var l=le(n,r);e=Et(e),o=re(i,o),kt([],[t],(function(t){function r(){ae("Cannot call "+i+" due to unbound types",l)}var i=(t=t[0]).name+"."+e;e.startsWith("@@")&&(e=Symbol[e.substring(2)]),s&&t.Sd.fg.push(e);var u=t.Sd.Ee,c=u[e];return void 0===c||void 0===c.Zd&&c.className!==t.name&&c.Be===n-2?(r.Be=n-2,r.className=t.name,u[e]=r):(Vt(u,e,i),u[e].Zd[n-2]=r),kt([],l,(function(r){return r=se(i,r,t,o,a),void 0===u[e].Zd?(r.Be=n-2,u[e]=r):u[e].Zd[n-2]=r,[]})),[]}))},V:function(t,n,r){t=Et(t),kt([],[n],(function(n){return n=n[0],e[t]=n.fromWireType(r),[]}))},Db:function(t,e){Rt(t,{name:e=Et(e),fromWireType:function(t){var e=de(t);return he(t),e},toWireType:function(t,e){return fe(e)},argPackAdvance:8,readValueFromPointer:bt,fe:null})},k:function(t,e,n,r){function i(){}n=xt(n),e=Et(e),i.values={},Rt(t,{name:e,constructor:i,fromWireType:function(t){return this.constructor.values[t]},toWireType:function(t,e){return e.value},argPackAdvance:8,readValueFromPointer:pe(e,n,r),fe:null}),$t(e,i)},j:function(t,e,n){var r=ge(t,"enum");e=Et(e),t=r.constructor,r=Object.create(r.constructor.prototype,{value:{value:n},constructor:{value:St(r.name+"_"+e,(function(){}))}}),t.values[n]=r,t[e]=r},S:function(t,e,n){n=xt(n),Rt(t,{name:e=Et(e),fromWireType:function(t){return t},toWireType:function(t,e){return e},argPackAdvance:8,readValueFromPointer:me(e,n),fe:null})},t:function(t,e,n,r,i,o){var a=le(e,n);t=Et(t),i=re(r,i),$t(t,(function(){ae("Cannot call "+t+" due to unbound types",a)}),e-1),kt([],a,(function(n){return n=[n[0],null].concat(n.slice(1)),ne(t,se(t,n,null,i,o),e-1),[]}))},w:function(t,e,n,r,i){e=Et(e),-1===i&&(i=4294967295),i=xt(n);var o=t=>t;if(0===r){var a=32-8*n;o=t=>t<<a>>>a}n=e.includes("unsigned")?function(t,e){return e>>>0}:function(t,e){return e},Rt(t,{name:e,fromWireType:o,toWireType:n,argPackAdvance:8,readValueFromPointer:ve(e,i,0!==r),fe:null})},p:function(t,e,n){function r(t){var e=G;return new i(L,e[1+(t>>=2)],e[t])}var i=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][e];Rt(t,{name:n=Et(n),fromWireType:r,argPackAdvance:8,readValueFromPointer:r},{Wf:!0})},o:function(t,e,n,r,i,o,a,s,l,u,c,h){n=Et(n),o=re(i,o),s=re(a,s),u=re(l,u),h=re(c,h),kt([t],[e],(function(t){return t=t[0],[new ee(n,t.Sd,!1,!1,!0,t,r,o,s,u,h)]}))},R:function(t,e){var n="std::string"===(e=Et(e));Rt(t,{name:e,fromWireType:function(t){var e=G[t>>2];if(n)for(var r=t+4,i=0;i<=e;++i){var o=t+4+i;if(i==e||0==D[o]){if(r=O(r,o-r),void 0===a)var a=r;else a+=String.fromCharCode(0),a+=r;r=o+1}}else{for(a=Array(e),i=0;i<e;++i)a[i]=String.fromCharCode(D[t+4+i]);a=a.join("")}return mn(t),a},toWireType:function(t,e){e instanceof ArrayBuffer&&(e=new Uint8Array(e));var r="string"==typeof e;r||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int8Array||Bt("Cannot pass non-string to std::string");var i=(n&&r?()=>R(e):()=>e.length)(),o=yn(4+i+1);if(G[o>>2]=i,n&&r)B(e,D,o+4,i+1);else if(r)for(r=0;r<i;++r){var a=e.charCodeAt(r);255<a&&(mn(o),Bt("String has UTF-16 code units that do not fit in 8 bits")),D[o+4+r]=a}else for(r=0;r<i;++r)D[o+4+r]=e[r];return null!==t&&t.push(mn,o),o},argPackAdvance:8,readValueFromPointer:bt,fe:function(t){mn(t)}})},H:function(t,e,n){if(n=Et(n),2===e)var r=V,i=$,o=Y,a=()=>j,s=1;else 4===e&&(r=X,i=q,o=Q,a=()=>G,s=2);Rt(t,{name:n,fromWireType:function(t){for(var n,i=G[t>>2],o=a(),l=t+4,u=0;u<=i;++u){var c=t+4+u*e;u!=i&&0!=o[c>>s]||(l=r(l,c-l),void 0===n?n=l:(n+=String.fromCharCode(0),n+=l),l=c+e)}return mn(t),n},toWireType:function(t,r){"string"!=typeof r&&Bt("Cannot pass non-string to C++ string type "+n);var a=o(r),l=yn(4+a+e);return G[l>>2]=a>>s,i(r,l+4,a+e),null!==t&&t.push(mn,l),l},argPackAdvance:8,readValueFromPointer:bt,fe:function(t){mn(t)}})},y:function(t,e,n,r,i,o){mt[t]={name:Et(e),hf:re(n,r),le:re(i,o),rf:[]}},g:function(t,e,n,r,i,o,a,s,l,u){mt[t].rf.push({Lf:Et(e),Uf:n,Sf:re(r,i),Tf:o,og:a,ng:re(s,l),pg:u})},Gb:function(t,e){Rt(t,{Zf:!0,name:e=Et(e),argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},pb:function(){throw"longjmp"},A:function(t,e,n){t=de(t),e=ge(e,"emval::as");var r=[],i=fe(r);return z[n>>2]=i,e.toWireType(r,t)},M:function(t,e,n,r,i){t=Ce[t],e=de(e),n=we(n);var o=[];return z[r>>2]=fe(o),t(e,n,o,i)},B:function(t,e,n,r){(t=Ce[t])(e=de(e),n=we(n),null,r)},D:he,Bb:function(t){return 0===t?fe(Ae()):(t=we(t),fe(Ae()[t]))},z:function(t,e){var n=function(t,e){for(var n=Array(t),r=0;r<t;++r)n[r]=ge(z[(e>>2)+r],"parameter "+r);return n}(t,e),r=n[0];e=r.name+"_$"+n.slice(1).map((function(t){return t.name})).join("_")+"$";var i=Se[e];if(void 0!==i)return i;var o=Array(t-1);return i=function(t){var e=Ce.length;return Ce.push(t),e}(((e,i,a,s)=>{for(var l=0,u=0;u<t-1;++u)o[u]=n[u+1].readValueFromPointer(s+l),l+=n[u+1].argPackAdvance;for(e=e[i].apply(e,o),u=0;u<t-1;++u)n[u+1].Hf&&n[u+1].Hf(o[u]);if(!r.Zf)return r.toWireType(a,e)})),Se[e]=i},K:function(t,e){return fe((t=de(t))[e=de(e)])},F:function(t){4<t&&(ce[t].jf+=1)},rb:function(t,e,n,r){t=de(t);var i=Pe[e];return i||(i=function(t){var e=Array(t+1);return function(n,r,i){e[0]=n;for(var o=0;o<t;++o){var a=ge(z[(r>>2)+o],"parameter "+o);e[o+1]=a.readValueFromPointer(i),i+=a.argPackAdvance}return fe(n=new(n.bind.apply(n,e)))}}(e),Pe[e]=i),i(t,n,r)},gb:function(){return fe([])},Ka:function(t){return fe(we(t))},hb:function(){return fe({})},fb:function(t){return!(t=de(t))},jb:function(t){vt(de(t)),he(t)},v:function(t,e,n){t=de(t),e=de(e),n=de(n),t[e]=n},r:function(t,e){return fe(t=(t=ge(t,"_emval_take_value")).readValueFromPointer(e))},a:function(){st("")},ob:function(t,e){if(0===t)t=Date.now();else{if(1!==t&&4!==t)return z[vn()>>2]=28,-1;t=Te()}return z[e>>2]=t/1e3|0,z[e+4>>2]=t%1e3*1e6|0,0},_c:function(t){hn.activeTexture(t)},$c:function(t,e){hn.attachShader(ke[t],Oe[e])},ad:function(t,e,n){hn.bindAttribLocation(ke[t],e,O(n))},Y:function(t,e){35051==t?hn.ff=e:35052==t&&(hn.Ce=e),hn.bindBuffer(t,Me[e])},X:function(t,e){hn.bindFramebuffer(t,xe[e])},cc:function(t,e){hn.bindRenderbuffer(t,Fe[e])},Qb:function(t,e){hn.bindSampler(t,Le[e])},Z:function(t,e){hn.bindTexture(t,Ee[e])},wc:function(t){hn.bindVertexArray(Be[t])},zc:function(t){hn.bindVertexArray(Be[t])},_:function(t,e,n,r){hn.blendColor(t,e,n,r)},$:function(t){hn.blendEquation(t)},aa:function(t,e){hn.blendFunc(t,e)},Xb:function(t,e,n,r,i,o,a,s,l,u){hn.blitFramebuffer(t,e,n,r,i,o,a,s,l,u)},ba:function(t,e,n,r){2<=Ue.version?n?hn.bufferData(t,D,r,n,e):hn.bufferData(t,e,r):hn.bufferData(t,n?D.subarray(n,n+e):e,r)},ca:function(t,e,n,r){2<=Ue.version?hn.bufferSubData(t,e,D,r,n):hn.bufferSubData(t,e,D.subarray(r,r+n))},dc:function(t){return hn.checkFramebufferStatus(t)},L:function(t){hn.clear(t)},W:function(t,e,n,r){hn.clearColor(t,e,n,r)},O:function(t){hn.clearStencil(t)},db:function(t,e,n,r){return hn.clientWaitSync(Ie[t],e,(n>>>0)+4294967296*r)},da:function(t,e,n,r){hn.colorMask(!!t,!!e,!!n,!!r)},ea:function(t){hn.compileShader(Oe[t])},fa:function(t,e,n,r,i,o,a,s){2<=Ue.version?hn.Ce?hn.compressedTexImage2D(t,e,n,r,i,o,a,s):hn.compressedTexImage2D(t,e,n,r,i,o,D,s,a):hn.compressedTexImage2D(t,e,n,r,i,o,s?D.subarray(s,s+a):null)},ga:function(t,e,n,r,i,o,a,s,l){2<=Ue.version?hn.Ce?hn.compressedTexSubImage2D(t,e,n,r,i,o,a,s,l):hn.compressedTexSubImage2D(t,e,n,r,i,o,a,D,l,s):hn.compressedTexSubImage2D(t,e,n,r,i,o,a,l?D.subarray(l,l+s):null)},ha:function(t,e,n,r,i,o,a,s){hn.copyTexSubImage2D(t,e,n,r,i,o,a,s)},ia:function(){var t=Ge(ke),e=hn.createProgram();return e.name=t,e.Xe=e.Ve=e.We=0,e.kf=1,ke[t]=e,t},ja:function(t){var e=Ge(Oe);return Oe[e]=hn.createShader(t),e},ka:function(t){hn.cullFace(t)},la:function(t,e){for(var n=0;n<t;n++){var r=z[e+4*n>>2],i=Me[r];i&&(hn.deleteBuffer(i),i.name=0,Me[r]=null,r==hn.ff&&(hn.ff=0),r==hn.Ce&&(hn.Ce=0))}},ec:function(t,e){for(var n=0;n<t;++n){var r=z[e+4*n>>2],i=xe[r];i&&(hn.deleteFramebuffer(i),i.name=0,xe[r]=null)}},ma:function(t){if(t){var e=ke[t];e?(hn.deleteProgram(e),e.name=0,ke[t]=null):ze(1281)}},fc:function(t,e){for(var n=0;n<t;n++){var r=z[e+4*n>>2],i=Fe[r];i&&(hn.deleteRenderbuffer(i),i.name=0,Fe[r]=null)}},Rb:function(t,e){for(var n=0;n<t;n++){var r=z[e+4*n>>2],i=Le[r];i&&(hn.deleteSampler(i),i.name=0,Le[r]=null)}},na:function(t){if(t){var e=Oe[t];e?(hn.deleteShader(e),Oe[t]=null):ze(1281)}},Zb:function(t){if(t){var e=Ie[t];e?(hn.deleteSync(e),e.name=0,Ie[t]=null):ze(1281)}},oa:function(t,e){for(var n=0;n<t;n++){var r=z[e+4*n>>2],i=Ee[r];i&&(hn.deleteTexture(i),i.name=0,Ee[r]=null)}},xc:function(t,e){for(var n=0;n<t;n++){var r=z[e+4*n>>2];hn.deleteVertexArray(Be[r]),Be[r]=null}},Ac:function(t,e){for(var n=0;n<t;n++){var r=z[e+4*n>>2];hn.deleteVertexArray(Be[r]),Be[r]=null}},pa:function(t){hn.depthMask(!!t)},qa:function(t){hn.disable(t)},ra:function(t){hn.disableVertexAttribArray(t)},sa:function(t,e,n){hn.drawArrays(t,e,n)},uc:function(t,e,n,r){hn.drawArraysInstanced(t,e,n,r)},sc:function(t,e,n,r,i){hn.pf.drawArraysInstancedBaseInstanceWEBGL(t,e,n,r,i)},qc:function(t,e){for(var n=Ve[t],r=0;r<t;r++)n[r]=z[e+4*r>>2];hn.drawBuffers(n)},ta:function(t,e,n,r){hn.drawElements(t,e,n,r)},vc:function(t,e,n,r,i){hn.drawElementsInstanced(t,e,n,r,i)},tc:function(t,e,n,r,i,o,a){hn.pf.drawElementsInstancedBaseVertexBaseInstanceWEBGL(t,e,n,r,i,o,a)},kc:function(t,e,n,r,i,o){hn.drawElements(t,r,i,o)},ua:function(t){hn.enable(t)},va:function(t){hn.enableVertexAttribArray(t)},Vb:function(t,e){return(t=hn.fenceSync(t,e))?(e=Ge(Ie),t.name=e,Ie[e]=t,e):0},wa:function(){hn.finish()},xa:function(){hn.flush()},gc:function(t,e,n,r){hn.framebufferRenderbuffer(t,e,n,Fe[r])},hc:function(t,e,n,r,i){hn.framebufferTexture2D(t,e,n,Ee[r],i)},ya:function(t){hn.frontFace(t)},za:function(t,e){$e(t,e,"createBuffer",Me)},ic:function(t,e){$e(t,e,"createFramebuffer",xe)},jc:function(t,e){$e(t,e,"createRenderbuffer",Fe)},Sb:function(t,e){$e(t,e,"createSampler",Le)},Aa:function(t,e){$e(t,e,"createTexture",Ee)},yc:function(t,e){$e(t,e,"createVertexArray",Be)},Bc:function(t,e){$e(t,e,"createVertexArray",Be)},_b:function(t){hn.generateMipmap(t)},Ba:function(t,e,n){n?z[n>>2]=hn.getBufferParameter(t,e):ze(1281)},Ca:function(){var t=hn.getError()||He;return He=0,t},$b:function(t,e,n,r){((t=hn.getFramebufferAttachmentParameter(t,e,n))instanceof WebGLRenderbuffer||t instanceof WebGLTexture)&&(t=0|t.name),z[r>>2]=t},E:function(t,e){!function(t,e){if(e){var n=void 0;switch(t){case 36346:n=1;break;case 36344:return;case 34814:case 36345:n=0;break;case 34466:var r=hn.getParameter(34467);n=r?r.length:0;break;case 33309:if(2>Ue.version)return void ze(1282);n=2*(hn.getSupportedExtensions()||[]).length;break;case 33307:case 33308:if(2>Ue.version)return void ze(1280);n=33307==t?3:0}if(void 0===n)switch(r=hn.getParameter(t),typeof r){case"number":n=r;break;case"boolean":n=r?1:0;break;case"string":return void ze(1280);case"object":if(null===r)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:n=0;break;default:return void ze(1280)}else{if(r instanceof Float32Array||r instanceof Uint32Array||r instanceof Int32Array||r instanceof Array){for(t=0;t<r.length;++t)z[e+4*t>>2]=r[t];return}try{n=0|r.name}catch(e){return ze(1280),void S("GL_INVALID_ENUM in glGet0v: Unknown object returned from WebGL getParameter("+t+")! (error: "+e+")")}}break;default:return ze(1280),void S("GL_INVALID_ENUM in glGet0v: Native code calling glGet0v("+t+") and it returns "+r+" of type "+typeof r+"!")}z[e>>2]=n}else ze(1281)}(t,e)},Da:function(t,e,n,r){null===(t=hn.getProgramInfoLog(ke[t]))&&(t="(unknown error)"),e=0<e&&r?B(t,D,r,e):0,n&&(z[n>>2]=e)},Ea:function(t,e,n){if(n)if(t>=_e)ze(1281);else if(t=ke[t],35716==e)null===(t=hn.getProgramInfoLog(t))&&(t="(unknown error)"),z[n>>2]=t.length+1;else if(35719==e){if(!t.Xe)for(e=0;e<hn.getProgramParameter(t,35718);++e)t.Xe=Math.max(t.Xe,hn.getActiveUniform(t,e).name.length+1);z[n>>2]=t.Xe}else if(35722==e){if(!t.Ve)for(e=0;e<hn.getProgramParameter(t,35721);++e)t.Ve=Math.max(t.Ve,hn.getActiveAttrib(t,e).name.length+1);z[n>>2]=t.Ve}else if(35381==e){if(!t.We)for(e=0;e<hn.getProgramParameter(t,35382);++e)t.We=Math.max(t.We,hn.getActiveUniformBlockName(t,e).length+1);z[n>>2]=t.We}else z[n>>2]=hn.getProgramParameter(t,e);else ze(1281)},ac:function(t,e,n){n?z[n>>2]=hn.getRenderbufferParameter(t,e):ze(1281)},Fa:function(t,e,n,r){null===(t=hn.getShaderInfoLog(Oe[t]))&&(t="(unknown error)"),e=0<e&&r?B(t,D,r,e):0,n&&(z[n>>2]=e)},Nb:function(t,e,n,r){t=hn.getShaderPrecisionFormat(t,e),z[n>>2]=t.rangeMin,z[n+4>>2]=t.rangeMax,z[r>>2]=t.precision},Ga:function(t,e,n){n?35716==e?(null===(t=hn.getShaderInfoLog(Oe[t]))&&(t="(unknown error)"),z[n>>2]=t?t.length+1:0):35720==e?(t=hn.getShaderSource(Oe[t]),z[n>>2]=t?t.length+1:0):z[n>>2]=hn.getShaderParameter(Oe[t],e):ze(1281)},J:function(t){var e=De[t];if(!e){switch(t){case 7939:e=Ye((e=(e=hn.getSupportedExtensions()||[]).concat(e.map((function(t){return"GL_"+t})))).join(" "));break;case 7936:case 7937:case 37445:case 37446:(e=hn.getParameter(t))||ze(1280),e=e&&Ye(e);break;case 7938:e=hn.getParameter(7938),e=Ye(e=2<=Ue.version?"OpenGL ES 3.0 ("+e+")":"OpenGL ES 2.0 ("+e+")");break;case 35724:var n=(e=hn.getParameter(35724)).match(/^WebGL GLSL ES ([0-9]\.[0-9][0-9]?)(?:$| .*)/);null!==n&&(3==n[1].length&&(n[1]+="0"),e="OpenGL ES GLSL ES "+n[1]+" ("+e+")"),e=Ye(e);break;default:ze(1280)}De[t]=e}return e},cb:function(t,e){if(2>Ue.version)return ze(1282),0;var n=We[t];return n?0>e||e>=n.length?(ze(1281),0):n[e]:7939===t?(n=(n=(n=hn.getSupportedExtensions()||[]).concat(n.map((function(t){return"GL_"+t})))).map((function(t){return Ye(t)})),n=We[t]=n,0>e||e>=n.length?(ze(1281),0):n[e]):(ze(1280),0)},Ha:function(t,e){if(e=O(e),t=ke[t]){var n,r=t,i=r.Oe,o=r.xf;if(!i)for(r.Oe=i={},r.wf={},n=0;n<hn.getProgramParameter(r,35718);++n){var a=hn.getActiveUniform(r,n),s=a.name;a=a.size;var l=Xe(s);l=0<l?s.slice(0,l):s;var u=r.kf;for(r.kf+=a,o[l]=[a,u],s=0;s<a;++s)i[u]=s,r.wf[u++]=l}if(r=t.Oe,i=0,o=e,0<(n=Xe(e))&&(i=parseInt(e.slice(n+1))>>>0,o=e.slice(0,n)),(o=t.xf[o])&&i<o[0]&&(r[i+=o[1]]=r[i]||hn.getUniformLocation(t,e)))return i}else ze(1281);return-1},Ob:function(t,e,n){for(var r=Ve[e],i=0;i<e;i++)r[i]=z[n+4*i>>2];hn.invalidateFramebuffer(t,r)},Pb:function(t,e,n,r,i,o,a){for(var s=Ve[e],l=0;l<e;l++)s[l]=z[n+4*l>>2];hn.invalidateSubFramebuffer(t,s,r,i,o,a)},Wb:function(t){return hn.isSync(Ie[t])},Ia:function(t){return(t=Ee[t])?hn.isTexture(t):0},Ja:function(t){hn.lineWidth(t)},La:function(t){t=ke[t],hn.linkProgram(t),t.Oe=0,t.xf={}},oc:function(t,e,n,r,i,o){hn.uf.multiDrawArraysInstancedBaseInstanceWEBGL(t,z,e>>2,z,n>>2,z,r>>2,G,i>>2,o)},pc:function(t,e,n,r,i,o,a,s){hn.uf.multiDrawElementsInstancedBaseVertexBaseInstanceWEBGL(t,z,e>>2,n,z,r>>2,z,i>>2,z,o>>2,G,a>>2,s)},Ma:function(t,e){3317==t&&(je=e),hn.pixelStorei(t,e)},rc:function(t){hn.readBuffer(t)},Na:function(t,e,n,r,i,o,a){if(2<=Ue.version)if(hn.ff)hn.readPixels(t,e,n,r,i,o,a);else{var s=qe(o);hn.readPixels(t,e,n,r,i,o,s,a>>31-Math.clz32(s.BYTES_PER_ELEMENT))}else(a=Qe(o,i,n,r,a))?hn.readPixels(t,e,n,r,i,o,a):ze(1280)},bc:function(t,e,n,r){hn.renderbufferStorage(t,e,n,r)},Yb:function(t,e,n,r,i){hn.renderbufferStorageMultisample(t,e,n,r,i)},Tb:function(t,e,n){hn.samplerParameteri(Le[t],e,n)},Ub:function(t,e,n){hn.samplerParameteri(Le[t],e,z[n>>2])},Oa:function(t,e,n,r){hn.scissor(t,e,n,r)},Pa:function(t,e,n,r){for(var i="",o=0;o<e;++o){var a=r?z[r+4*o>>2]:-1;i+=O(z[n+4*o>>2],0>a?void 0:a)}hn.shaderSource(Oe[t],i)},Qa:function(t,e,n){hn.stencilFunc(t,e,n)},Ra:function(t,e,n,r){hn.stencilFuncSeparate(t,e,n,r)},Sa:function(t){hn.stencilMask(t)},Ta:function(t,e){hn.stencilMaskSeparate(t,e)},Ua:function(t,e,n){hn.stencilOp(t,e,n)},Va:function(t,e,n,r){hn.stencilOpSeparate(t,e,n,r)},Wa:function(t,e,n,r,i,o,a,s,l){if(2<=Ue.version)if(hn.Ce)hn.texImage2D(t,e,n,r,i,o,a,s,l);else if(l){var u=qe(s);hn.texImage2D(t,e,n,r,i,o,a,s,u,l>>31-Math.clz32(u.BYTES_PER_ELEMENT))}else hn.texImage2D(t,e,n,r,i,o,a,s,null);else hn.texImage2D(t,e,n,r,i,o,a,s,l?Qe(s,a,r,i,l):null)},Xa:function(t,e,n){hn.texParameterf(t,e,n)},Ya:function(t,e,n){hn.texParameterf(t,e,N[n>>2])},Za:function(t,e,n){hn.texParameteri(t,e,n)},_a:function(t,e,n){hn.texParameteri(t,e,z[n>>2])},lc:function(t,e,n,r,i){hn.texStorage2D(t,e,n,r,i)},$a:function(t,e,n,r,i,o,a,s,l){if(2<=Ue.version)if(hn.Ce)hn.texSubImage2D(t,e,n,r,i,o,a,s,l);else if(l){var u=qe(s);hn.texSubImage2D(t,e,n,r,i,o,a,s,u,l>>31-Math.clz32(u.BYTES_PER_ELEMENT))}else hn.texSubImage2D(t,e,n,r,i,o,a,s,null);else u=null,l&&(u=Qe(s,a,i,o,l)),hn.texSubImage2D(t,e,n,r,i,o,a,s,u)},ab:function(t,e){hn.uniform1f(Ke(t),e)},bb:function(t,e,n){if(2<=Ue.version)hn.uniform1fv(Ke(t),N,n>>2,e);else{if(288>=e)for(var r=Ze[e-1],i=0;i<e;++i)r[i]=N[n+4*i>>2];else r=N.subarray(n>>2,n+4*e>>2);hn.uniform1fv(Ke(t),r)}},Wc:function(t,e){hn.uniform1i(Ke(t),e)},Xc:function(t,e,n){if(2<=Ue.version)hn.uniform1iv(Ke(t),z,n>>2,e);else{if(288>=e)for(var r=tn[e-1],i=0;i<e;++i)r[i]=z[n+4*i>>2];else r=z.subarray(n>>2,n+4*e>>2);hn.uniform1iv(Ke(t),r)}},Yc:function(t,e,n){hn.uniform2f(Ke(t),e,n)},Zc:function(t,e,n){if(2<=Ue.version)hn.uniform2fv(Ke(t),N,n>>2,2*e);else{if(144>=e)for(var r=Ze[2*e-1],i=0;i<2*e;i+=2)r[i]=N[n+4*i>>2],r[i+1]=N[n+(4*i+4)>>2];else r=N.subarray(n>>2,n+8*e>>2);hn.uniform2fv(Ke(t),r)}},Vc:function(t,e,n){hn.uniform2i(Ke(t),e,n)},Uc:function(t,e,n){if(2<=Ue.version)hn.uniform2iv(Ke(t),z,n>>2,2*e);else{if(144>=e)for(var r=tn[2*e-1],i=0;i<2*e;i+=2)r[i]=z[n+4*i>>2],r[i+1]=z[n+(4*i+4)>>2];else r=z.subarray(n>>2,n+8*e>>2);hn.uniform2iv(Ke(t),r)}},Tc:function(t,e,n,r){hn.uniform3f(Ke(t),e,n,r)},Sc:function(t,e,n){if(2<=Ue.version)hn.uniform3fv(Ke(t),N,n>>2,3*e);else{if(96>=e)for(var r=Ze[3*e-1],i=0;i<3*e;i+=3)r[i]=N[n+4*i>>2],r[i+1]=N[n+(4*i+4)>>2],r[i+2]=N[n+(4*i+8)>>2];else r=N.subarray(n>>2,n+12*e>>2);hn.uniform3fv(Ke(t),r)}},Rc:function(t,e,n,r){hn.uniform3i(Ke(t),e,n,r)},Qc:function(t,e,n){if(2<=Ue.version)hn.uniform3iv(Ke(t),z,n>>2,3*e);else{if(96>=e)for(var r=tn[3*e-1],i=0;i<3*e;i+=3)r[i]=z[n+4*i>>2],r[i+1]=z[n+(4*i+4)>>2],r[i+2]=z[n+(4*i+8)>>2];else r=z.subarray(n>>2,n+12*e>>2);hn.uniform3iv(Ke(t),r)}},Pc:function(t,e,n,r,i){hn.uniform4f(Ke(t),e,n,r,i)},Oc:function(t,e,n){if(2<=Ue.version)hn.uniform4fv(Ke(t),N,n>>2,4*e);else{if(72>=e){var r=Ze[4*e-1],i=N;n>>=2;for(var o=0;o<4*e;o+=4){var a=n+o;r[o]=i[a],r[o+1]=i[a+1],r[o+2]=i[a+2],r[o+3]=i[a+3]}}else r=N.subarray(n>>2,n+16*e>>2);hn.uniform4fv(Ke(t),r)}},Cc:function(t,e,n,r,i){hn.uniform4i(Ke(t),e,n,r,i)},Dc:function(t,e,n){if(2<=Ue.version)hn.uniform4iv(Ke(t),z,n>>2,4*e);else{if(72>=e)for(var r=tn[4*e-1],i=0;i<4*e;i+=4)r[i]=z[n+4*i>>2],r[i+1]=z[n+(4*i+4)>>2],r[i+2]=z[n+(4*i+8)>>2],r[i+3]=z[n+(4*i+12)>>2];else r=z.subarray(n>>2,n+16*e>>2);hn.uniform4iv(Ke(t),r)}},Ec:function(t,e,n,r){if(2<=Ue.version)hn.uniformMatrix2fv(Ke(t),!!n,N,r>>2,4*e);else{if(72>=e)for(var i=Ze[4*e-1],o=0;o<4*e;o+=4)i[o]=N[r+4*o>>2],i[o+1]=N[r+(4*o+4)>>2],i[o+2]=N[r+(4*o+8)>>2],i[o+3]=N[r+(4*o+12)>>2];else i=N.subarray(r>>2,r+16*e>>2);hn.uniformMatrix2fv(Ke(t),!!n,i)}},Fc:function(t,e,n,r){if(2<=Ue.version)hn.uniformMatrix3fv(Ke(t),!!n,N,r>>2,9*e);else{if(32>=e)for(var i=Ze[9*e-1],o=0;o<9*e;o+=9)i[o]=N[r+4*o>>2],i[o+1]=N[r+(4*o+4)>>2],i[o+2]=N[r+(4*o+8)>>2],i[o+3]=N[r+(4*o+12)>>2],i[o+4]=N[r+(4*o+16)>>2],i[o+5]=N[r+(4*o+20)>>2],i[o+6]=N[r+(4*o+24)>>2],i[o+7]=N[r+(4*o+28)>>2],i[o+8]=N[r+(4*o+32)>>2];else i=N.subarray(r>>2,r+36*e>>2);hn.uniformMatrix3fv(Ke(t),!!n,i)}},Gc:function(t,e,n,r){if(2<=Ue.version)hn.uniformMatrix4fv(Ke(t),!!n,N,r>>2,16*e);else{if(18>=e){var i=Ze[16*e-1],o=N;r>>=2;for(var a=0;a<16*e;a+=16){var s=r+a;i[a]=o[s],i[a+1]=o[s+1],i[a+2]=o[s+2],i[a+3]=o[s+3],i[a+4]=o[s+4],i[a+5]=o[s+5],i[a+6]=o[s+6],i[a+7]=o[s+7],i[a+8]=o[s+8],i[a+9]=o[s+9],i[a+10]=o[s+10],i[a+11]=o[s+11],i[a+12]=o[s+12],i[a+13]=o[s+13],i[a+14]=o[s+14],i[a+15]=o[s+15]}}else i=N.subarray(r>>2,r+64*e>>2);hn.uniformMatrix4fv(Ke(t),!!n,i)}},Hc:function(t){t=ke[t],hn.useProgram(t),hn.Gf=t},Ic:function(t,e){hn.vertexAttrib1f(t,e)},Jc:function(t,e){hn.vertexAttrib2f(t,N[e>>2],N[e+4>>2])},Kc:function(t,e){hn.vertexAttrib3f(t,N[e>>2],N[e+4>>2],N[e+8>>2])},Lc:function(t,e){hn.vertexAttrib4f(t,N[e>>2],N[e+4>>2],N[e+8>>2],N[e+12>>2])},mc:function(t,e){hn.vertexAttribDivisor(t,e)},nc:function(t,e,n,r,i){hn.vertexAttribIPointer(t,e,n,r,i)},Mc:function(t,e,n,r,i,o){hn.vertexAttribPointer(t,e,n,!!r,i,o)},Nc:function(t,e,n,r){hn.viewport(t,e,n,r)},eb:function(t,e,n,r){hn.waitSync(Ie[t],e,(n>>>0)+4294967296*r)},qb:function(t){var e=D.length;if(2147483648<(t>>>=0))return!1;for(var n=1;4>=n;n*=2){var r=e*(1+.2/n);r=Math.min(r,t+100663296),0<(r=Math.max(t,r))%65536&&(r+=65536-r%65536);t:{try{k.grow(Math.min(2147483648,r)-L.byteLength+65535>>>16),K();var i=1;break t}catch(t){}i=void 0}if(i)return!0}return!1},ib:function(){return Ue?Ue.Vf:0},ub:function(t,e){var n=0;return nn().forEach((function(r,i){var o=e+n;for(i=z[t+4*i>>2]=o,o=0;o<r.length;++o)I[i++>>0]=r.charCodeAt(o);I[i>>0]=0,n+=r.length+1})),0},vb:function(t,e){var n=nn();z[t>>2]=n.length;var r=0;return n.forEach((function(t){r+=t.length+1})),z[e>>2]=r,0},Hb:function(t){M||0<nt||(e.onExit&&e.onExit(t),x=!0),y(t,new Pn(t))},G:function(){return 0},kb:function(t,e,n,r,i,o){return t=yt.Rf(t),e=yt.If(t,e,n,r),z[o>>2]=e,0},Ab:function(t,e,n,r){return t=yt.Rf(t),e=yt.If(t,e,n),z[r>>2]=e,0},lb:function(){},N:function(t,e,n,r){for(var i=0,o=0;o<n;o++){var a=z[e>>2],s=z[e+4>>2];e+=8;for(var l=0;l<s;l++){var u=D[a+l],c=gt[t];0===u||10===u?((1===t?T:S)(E(c,0)),c.length=0):c.push(u)}i+=s}return z[r>>2]=i,0},b:function(){return _},i:function(t,e){var n=Tn();try{return dt(t)(e)}catch(t){if(Sn(n),t!==t+0&&"longjmp"!==t)throw t;An(1,0)}},n:function(t,e,n){var r=Tn();try{return dt(t)(e,n)}catch(t){if(Sn(r),t!==t+0&&"longjmp"!==t)throw t;An(1,0)}},f:function(t,e,n,r){var i=Tn();try{return dt(t)(e,n,r)}catch(t){if(Sn(i),t!==t+0&&"longjmp"!==t)throw t;An(1,0)}},C:function(t,e,n,r,i){var o=Tn();try{return dt(t)(e,n,r,i)}catch(t){if(Sn(o),t!==t+0&&"longjmp"!==t)throw t;An(1,0)}},Mb:function(t,e,n,r,i,o){var a=Tn();try{return dt(t)(e,n,r,i,o)}catch(t){if(Sn(a),t!==t+0&&"longjmp"!==t)throw t;An(1,0)}},U:function(t,e,n,r,i,o,a){var s=Tn();try{return dt(t)(e,n,r,i,o,a)}catch(t){if(Sn(s),t!==t+0&&"longjmp"!==t)throw t;An(1,0)}},T:function(t,e,n,r,i,o,a,s,l,u){var c=Tn();try{return dt(t)(e,n,r,i,o,a,s,l,u)}catch(t){if(Sn(c),t!==t+0&&"longjmp"!==t)throw t;An(1,0)}},I:function(t){var e=Tn();try{dt(t)()}catch(t){if(Sn(e),t!==t+0&&"longjmp"!==t)throw t;An(1,0)}},m:function(t,e){var n=Tn();try{dt(t)(e)}catch(t){if(Sn(n),t!==t+0&&"longjmp"!==t)throw t;An(1,0)}},s:function(t,e,n){var r=Tn();try{dt(t)(e,n)}catch(t){if(Sn(r),t!==t+0&&"longjmp"!==t)throw t;An(1,0)}},h:function(t,e,n,r){var i=Tn();try{dt(t)(e,n,r)}catch(t){if(Sn(i),t!==t+0&&"longjmp"!==t)throw t;An(1,0)}},q:function(t,e,n,r,i){var o=Tn();try{dt(t)(e,n,r,i)}catch(t){if(Sn(o),t!==t+0&&"longjmp"!==t)throw t;An(1,0)}},Kb:function(t,e,n,r,i,o){var a=Tn();try{dt(t)(e,n,r,i,o)}catch(t){if(Sn(a),t!==t+0&&"longjmp"!==t)throw t;An(1,0)}},Ib:function(t,e,n,r,i,o,a){var s=Tn();try{dt(t)(e,n,r,i,o,a)}catch(t){if(Sn(s),t!==t+0&&"longjmp"!==t)throw t;An(1,0)}},Jb:function(t,e,n,r,i,o,a,s,l,u){var c=Tn();try{dt(t)(e,n,r,i,o,a,s,l,u)}catch(t){if(Sn(c),t!==t+0&&"longjmp"!==t)throw t;An(1,0)}},c:function(t){_=t},nb:function(t,e,n,r){return function(t,e,n,r){function i(t,e,n){for(t="number"==typeof t?t.toString():t||"";t.length<e;)t=n[0]+t;return t}function o(t,e){return i(t,e,"0")}function a(t,e){function n(t){return 0>t?-1:0<t?1:0}var r;return 0===(r=n(t.getFullYear()-e.getFullYear()))&&0===(r=n(t.getMonth()-e.getMonth()))&&(r=n(t.getDate()-e.getDate())),r}function s(t){switch(t.getDay()){case 0:return new Date(t.getFullYear()-1,11,29);case 1:return t;case 2:return new Date(t.getFullYear(),0,3);case 3:return new Date(t.getFullYear(),0,2);case 4:return new Date(t.getFullYear(),0,1);case 5:return new Date(t.getFullYear()-1,11,31);case 6:return new Date(t.getFullYear()-1,11,30)}}function l(t){t=ln(new Date(t.be+1900,0,1),t.$e);var e=new Date(t.getFullYear()+1,0,4),n=s(new Date(t.getFullYear(),0,4));return e=s(e),0>=a(n,t)?0>=a(e,t)?t.getFullYear()+1:t.getFullYear():t.getFullYear()-1}var u=z[r+40>>2];for(var c in r={yg:z[r>>2],xg:z[r+4>>2],Ye:z[r+8>>2],Ne:z[r+12>>2],Fe:z[r+16>>2],be:z[r+20>>2],Ze:z[r+24>>2],$e:z[r+28>>2],Ig:z[r+32>>2],wg:z[r+36>>2],zg:u?O(u):""},n=O(n),u={"%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"})n=n.replace(new RegExp(c,"g"),u[c]);var h="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),d="January February March April May June July August September October November December".split(" ");for(c in u={"%a":function(t){return h[t.Ze].substring(0,3)},"%A":function(t){return h[t.Ze]},"%b":function(t){return d[t.Fe].substring(0,3)},"%B":function(t){return d[t.Fe]},"%C":function(t){return o((t.be+1900)/100|0,2)},"%d":function(t){return o(t.Ne,2)},"%e":function(t){return i(t.Ne,2," ")},"%g":function(t){return l(t).toString().substring(2)},"%G":function(t){return l(t)},"%H":function(t){return o(t.Ye,2)},"%I":function(t){return 0==(t=t.Ye)?t=12:12<t&&(t-=12),o(t,2)},"%j":function(t){return o(t.Ne+on(rn(t.be+1900)?an:sn,t.Fe-1),3)},"%m":function(t){return o(t.Fe+1,2)},"%M":function(t){return o(t.xg,2)},"%n":function(){return"\n"},"%p":function(t){return 0<=t.Ye&&12>t.Ye?"AM":"PM"},"%S":function(t){return o(t.yg,2)},"%t":function(){return"\t"},"%u":function(t){return t.Ze||7},"%U":function(t){var e=new Date(t.be+1900,0,1),n=0===e.getDay()?e:ln(e,7-e.getDay());return 0>a(n,t=new Date(t.be+1900,t.Fe,t.Ne))?o(Math.ceil((31-n.getDate()+(on(rn(t.getFullYear())?an:sn,t.getMonth()-1)-31)+t.getDate())/7),2):0===a(n,e)?"01":"00"},"%V":function(t){var e=new Date(t.be+1901,0,4),n=s(new Date(t.be+1900,0,4));e=s(e);var r=ln(new Date(t.be+1900,0,1),t.$e);return 0>a(r,n)?"53":0>=a(e,r)?"01":o(Math.ceil((n.getFullYear()<t.be+1900?t.$e+32-n.getDate():t.$e+1-n.getDate())/7),2)},"%w":function(t){return t.Ze},"%W":function(t){var e=new Date(t.be,0,1),n=1===e.getDay()?e:ln(e,0===e.getDay()?1:7-e.getDay()+1);return 0>a(n,t=new Date(t.be+1900,t.Fe,t.Ne))?o(Math.ceil((31-n.getDate()+(on(rn(t.getFullYear())?an:sn,t.getMonth()-1)-31)+t.getDate())/7),2):0===a(n,e)?"01":"00"},"%y":function(t){return(t.be+1900).toString().substring(2)},"%Y":function(t){return t.be+1900},"%z":function(t){var e=0<=(t=t.wg);return t=Math.abs(t)/60,(e?"+":"-")+String("0000"+(t/60*100+t%60)).slice(-4)},"%Z":function(t){return t.zg},"%%":function(){return"%"}})n.includes(c)&&(n=n.replace(new RegExp(c,"g"),u[c](r)));return c=function(t){var e=Array(R(t)+1);return B(t,e,0,e.length),e}(n),c.length>e?0:(I.set(c,t),c.length-1)}(t,e,n,r)}};!function(){function t(t){e.asm=t.exports,k=e.asm.bd,K(),J=e.asm.dd,tt.unshift(e.asm.cd),ot--,e.monitorRunDependencies&&e.monitorRunDependencies(ot),0==ot&&at&&(t=at,at=null,t())}function n(e){t(e.instance)}function r(t){return function(){if(!P&&(m||v)){if("function"==typeof fetch&&!it.startsWith("file://"))return fetch(it,{credentials:"same-origin"}).then((function(t){if(!t.ok)throw"failed to load wasm binary file at '"+it+"'";return t.arrayBuffer()})).catch((function(){return ct()}));if(l)return new Promise((function(t,e){l(it,(function(e){t(new Uint8Array(e))}),e)}))}return Promise.resolve().then((function(){return ct()}))}().then((function(t){return WebAssembly.instantiate(t,o)})).then((function(t){return t})).then(t,(function(t){S("failed to asynchronously prepare wasm: "+t),st(t)}))}var o={a:gn};if(ot++,e.monitorRunDependencies&&e.monitorRunDependencies(ot),e.instantiateWasm)try{return e.instantiateWasm(o,t)}catch(t){return S("Module.instantiateWasm callback failed with error: "+t),!1}(P||"function"!=typeof WebAssembly.instantiateStreaming||lt()||it.startsWith("file://")||"function"!=typeof fetch?r(n):fetch(it,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,o).then(n,(function(t){return S("wasm streaming compile failed: "+t),S("falling back to ArrayBuffer instantiation"),r(n)}))}))).catch(i)}(),e.___wasm_call_ctors=function(){return(e.___wasm_call_ctors=e.asm.cd).apply(null,arguments)};var yn=e._malloc=function(){return(yn=e._malloc=e.asm.ed).apply(null,arguments)},mn=e._free=function(){return(mn=e._free=e.asm.fd).apply(null,arguments)},vn=e.___errno_location=function(){return(vn=e.___errno_location=e.asm.gd).apply(null,arguments)},bn=e.___getTypeName=function(){return(bn=e.___getTypeName=e.asm.hd).apply(null,arguments)};e.___embind_register_native_and_builtin_types=function(){return(e.___embind_register_native_and_builtin_types=e.asm.id).apply(null,arguments)};var wn,Cn=e._memalign=function(){return(Cn=e._memalign=e.asm.jd).apply(null,arguments)},An=e._setThrew=function(){return(An=e._setThrew=e.asm.kd).apply(null,arguments)},Tn=e.stackSave=function(){return(Tn=e.stackSave=e.asm.ld).apply(null,arguments)},Sn=e.stackRestore=function(){return(Sn=e.stackRestore=e.asm.md).apply(null,arguments)};function Pn(t){this.name="ExitStatus",this.message="Program terminated with exit("+t+")",this.status=t}function _n(){function t(){if(!wn&&(wn=!0,e.calledRun=!0,!x)){if(ht(tt),r(e),e.onRuntimeInitialized&&e.onRuntimeInitialized(),e.postRun)for("function"==typeof e.postRun&&(e.postRun=[e.postRun]);e.postRun.length;){var t=e.postRun.shift();et.unshift(t)}ht(et)}}if(!(0<ot)){if(e.preRun)for("function"==typeof e.preRun&&(e.preRun=[e.preRun]);e.preRun.length;)rt();ht(Z),0<ot||(e.setStatus?(e.setStatus("Running..."),setTimeout((function(){setTimeout((function(){e.setStatus("")}),1),t()}),1)):t())}}if(e.dynCall_iiiji=function(){return(e.dynCall_iiiji=e.asm.nd).apply(null,arguments)},e.dynCall_ji=function(){return(e.dynCall_ji=e.asm.od).apply(null,arguments)},e.dynCall_iiji=function(){return(e.dynCall_iiji=e.asm.pd).apply(null,arguments)},e.dynCall_iijjiii=function(){return(e.dynCall_iijjiii=e.asm.qd).apply(null,arguments)},e.dynCall_iij=function(){return(e.dynCall_iij=e.asm.rd).apply(null,arguments)},e.dynCall_vijjjii=function(){return(e.dynCall_vijjjii=e.asm.sd).apply(null,arguments)},e.dynCall_viji=function(){return(e.dynCall_viji=e.asm.td).apply(null,arguments)},e.dynCall_vijiii=function(){return(e.dynCall_vijiii=e.asm.ud).apply(null,arguments)},e.dynCall_viiiiij=function(){return(e.dynCall_viiiiij=e.asm.vd).apply(null,arguments)},e.dynCall_jii=function(){return(e.dynCall_jii=e.asm.wd).apply(null,arguments)},e.dynCall_iiij=function(){return(e.dynCall_iiij=e.asm.xd).apply(null,arguments)},e.dynCall_iiiij=function(){return(e.dynCall_iiiij=e.asm.yd).apply(null,arguments)},e.dynCall_viij=function(){return(e.dynCall_viij=e.asm.zd).apply(null,arguments)},e.dynCall_viiij=function(){return(e.dynCall_viiij=e.asm.Ad).apply(null,arguments)},e.dynCall_vij=function(){return(e.dynCall_vij=e.asm.Bd).apply(null,arguments)},e.dynCall_jiiii=function(){return(e.dynCall_jiiii=e.asm.Cd).apply(null,arguments)},e.dynCall_jiiiiii=function(){return(e.dynCall_jiiiiii=e.asm.Dd).apply(null,arguments)},e.dynCall_jiiiiji=function(){return(e.dynCall_jiiiiji=e.asm.Ed).apply(null,arguments)},e.dynCall_iijj=function(){return(e.dynCall_iijj=e.asm.Fd).apply(null,arguments)},e.dynCall_jiji=function(){return(e.dynCall_jiji=e.asm.Gd).apply(null,arguments)},e.dynCall_viijii=function(){return(e.dynCall_viijii=e.asm.Hd).apply(null,arguments)},e.dynCall_iiiiij=function(){return(e.dynCall_iiiiij=e.asm.Id).apply(null,arguments)},e.dynCall_iiiiijj=function(){return(e.dynCall_iiiiijj=e.asm.Jd).apply(null,arguments)},e.dynCall_iiiiiijj=function(){return(e.dynCall_iiiiiijj=e.asm.Kd).apply(null,arguments)},at=function t(){wn||_n(),wn||(at=t)},e.run=_n,e.preInit)for("function"==typeof e.preInit&&(e.preInit=[e.preInit]);0<e.preInit.length;)e.preInit.pop()();return _n(),t.ready});t.exports=r}(b),new Array;!function(t){t.topToTopOf="topToTopOf",t.topToBottomOf="topToBottomOf",t.bottomToTopOf="bottomToTopOf",t.bottomToBottomOf="bottomToBottomOf",t.startToStartOf="startToStartOf",t.startToEndOf="startToEndOf",t.endToEndOf="endToEndOf",t.endToStartOf="endToStartOf"}(d||(d={}));class A{constructor(t,e){this.verticalConstraint=!1,this.focalEntityMinimum=!1,this.alterEntityMinimum=!1,this.verticalTypes=[d.topToTopOf,d.topToBottomOf,d.bottomToTopOf,d.bottomToBottomOf],this.focalEntityMinimumTypes=[d.topToTopOf,d.topToBottomOf,d.startToStartOf,d.startToEndOf],this.alterEntityMinimumTypes=[d.topToTopOf,d.bottomToTopOf,d.startToStartOf,d.endToStartOf],this.type=t,this.alterEntity=e,this.verticalTypes.includes(t)?(this.verticalConstraint=!0,this.focalEntityMinimumTypes.includes(t)?this.focalEntityMinimum=!0:this.focalEntityMinimum=!1,this.alterEntityMinimumTypes.includes(t)?this.alterEntityMinimum=!0:this.alterEntityMinimum=!1):(this.verticalConstraint=!1,this.focalEntityMinimumTypes.includes(t)?this.focalEntityMinimum=!0:this.focalEntityMinimum=!1,this.alterEntityMinimumTypes.includes(t)?this.alterEntityMinimum=!0:this.alterEntityMinimum=!1)}}function T(t,e){t.isDrawable&&function(t,e){e.anchorPoint&&(t.anchorPoint=e.anchorPoint),e.zPosition&&(t.zPosition=e.zPosition)}(t,e),t.isText&&function(t,e){e.text&&(t.text=e.text),e.fontName&&(t.fontName=e.fontName),e.fontColor&&(t.fontColor=e.fontColor),e.fontSize&&(t.fontSize=e.fontSize)}(t,e)}!function(t){t.entity="Entity",t.scene="Scene",t.sprite="Sprite",t.label="Label",t.textline="TextLine",t.shape="Shape",t.composite="Composite"}(f||(f={}));class S{constructor(t={}){this.type=f.entity,this.isDrawable=!1,this.isShape=!1,this.isText=!1,this.position={x:0,y:0},this.scale=1,this.isUserInteractionEnabled=!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.actions=new Array,this.originalActions=new Array,this.eventListeners=new Array,this.uuid=class{static generate(){let t=(new Date).getTime(),e=performance&&performance.now&&1e3*performance.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(n=>{let r=16*Math.random();return t>0?(r=(t+r)%16|0,t=Math.floor(t/16)):(r=(e+r)%16|0,e=Math.floor(e/16)),("x"==n?r:7&r|8).toString(16)}))}}.generate(),this.needsInitialization=!0,this.userData={},this.loopMessages=new Set,this.toString=()=>this.name!==this.uuid?`"${this.name}" (${this.type}, ${this.uuid})`:`"${this.type} (${this.uuid})`,void 0===t.name?this.name=this.uuid:this.name=t.name,t.position&&(this.position=t.position),t.scale&&(this.scale=t.scale),t.isUserInteractionEnabled&&(this.isUserInteractionEnabled=t.isUserInteractionEnabled),t.hidden&&(this.hidden=t.hidden),t.layout&&(this.layout=t.layout)}initialize(){throw new Error("initialize() called in abstract base class Entity.")}addChild(t){if(t.type==f.scene)throw new Error("A scene cannot be the child of an entity. A scene can only be added to a game object");if(t.parent=this,this.children.map((t=>t.name)).includes(t.name))throw new Error(`Cannot add child entity ${t.toString()} to parent entity ${this.toString()}. A child with name "${t.name}" already exists on parent.`);this.children.push(t)}removeAllChildren(){for(;this.children.length;)this.children.pop()}removeChild(t){if(!this.children.includes(t))throw new Error(`cannot remove entity ${t} from parent ${this} because the entity is not currently a child of the parent`);this.children=this.children.filter((t=>t!=t))}descendant(t){const e=this.descendants.filter((e=>e.name===t)).find(Boolean);if(void 0===e)throw new Error(`descendant with name ${t} not found on parent ${this.toString()}`);return e}get descendants(){function t(e,n){n.push(e),e.children.forEach((e=>t(e,n)))}const e=new Array;return this.children.forEach((n=>t(n,e))),e}onTapDown(t,e=!0){const n={eventType:"tapdown",entityName:this.name,callback:t};e&&(this.eventListeners=this.eventListeners.filter((t=>t.entityName!==n.entityName))),this.eventListeners.push(n)}parseLayoutConstraints(t,e){const n=new Array;return Object.values(d).forEach((r=>{if(void 0!==t[r]){let i,o="";if(t[r]instanceof S)i=t[r];else{const n=t[r];i=e.filter((t=>t.name===n)).find(Boolean),o=`. sibling entity named "${n}" has not been added to the game object`}if(void 0===i)throw new Error("could not find sibling entity for constraint"+o);const a=new A(r,i);n.push(a)}})),n}calculateYFromConstraint(t,e,n,r){let i=t.alterEntity.absolutePosition.y;return t.alterEntityMinimum?t.alterEntity.type!==f.scene&&(i-=.5*t.alterEntity.size.height*r):t.alterEntity.type!==f.scene?i+=.5*t.alterEntity.size.height*r:i+=t.alterEntity.size.height*r,t.focalEntityMinimum?(i+=.5*this.size.height*r,i+=e*r):(i-=.5*this.size.height*r,i-=n*r),i}calculateXFromConstraint(t,e,n,r){let i=t.alterEntity.absolutePosition.x;return t.alterEntityMinimum?t.alterEntity.type!==f.scene&&(i-=.5*t.alterEntity.size.width*r):t.alterEntity.type!==f.scene?i+=.5*t.alterEntity.size.width*r:i+=t.alterEntity.size.width*r,t.focalEntityMinimum?(i+=.5*this.size.width*r,i+=e*r):(i-=.5*this.size.width*r,i-=n*r),i}update(){var t,e,n,i,o,a,s,l,u,c,h,p,g,y,m,v;if(this.needsInitialization&&(this.initialize(),this.needsInitialization=!1),void 0===this.parent)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,void 0===(null===(t=this.layout)||void 0===t?void 0:t.constraints))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 t=null!==(i=null===(n=null===(e=this.layout)||void 0===e?void 0:e.constraints)||void 0===n?void 0:n.horizontalBias)&&void 0!==i?i:.5,r=null!==(s=null===(a=null===(o=this.layout)||void 0===o?void 0:o.constraints)||void 0===a?void 0:a.verticalBias)&&void 0!==s?s:.5,d=null!==(u=null===(l=this.layout)||void 0===l?void 0:l.marginTop)&&void 0!==u?u:0,f=null!==(h=null===(c=this.layout)||void 0===c?void 0:c.marginBottom)&&void 0!==h?h:0,b=null!==(g=null===(p=this.layout)||void 0===p?void 0:p.marginStart)&&void 0!==g?g:0,w=null!==(m=null===(y=this.layout)||void 0===y?void 0:y.marginEnd)&&void 0!==m?m:0,C=this.parseLayoutConstraints(null===(v=this.layout)||void 0===v?void 0:v.constraints,this.parentSceneAsEntity.descendants),A=this.parent.absoluteScale,T=C.filter((t=>t.verticalConstraint)).map((t=>this.calculateYFromConstraint(t,d,f,A)));0===T.length||(1===T.length?this.absolutePosition.y=T[0]:2===T.length&&(this.absolutePosition.y=Math.min(T[0],T[1])+r*Math.abs(T[0]-T[1])));const S=C.filter((t=>!t.verticalConstraint)).map((t=>this.calculateXFromConstraint(t,b,w,A)));0===S.length||(1===S.length?this.absolutePosition.x=S[0]:2===S.length&&(this.absolutePosition.x=Math.min(S[0],S[1])+t*Math.abs(S[0]-S[1])))}const b=this.actions.filter((t=>t.runDuringTransition&&!t.completed)),w=this.actions.filter((t=>!t.runDuringTransition&&!t.completed));b.length>0?(b.forEach((t=>{-1===t.runStartTime&&(t.runStartTime=Globals.now)})),b.forEach((t=>r.evaluateAction(t,this,Globals.now,Globals.deltaTime)))):w.length>0&&(w.forEach((t=>{-1===t.runStartTime&&(t.runStartTime=Globals.now)})),w.forEach((t=>r.evaluateAction(t,this,Globals.now,Globals.deltaTime))));const C=new Map;this.children.forEach((t=>{var e;C.set(t.uuid,function(t,e){const n=new Array;return void 0===e||Object.values(d).forEach((r=>{if(void 0!==e[r]){let i,o="";if(e[r]instanceof S)i=e[r];else{const n=e[r];let a;a=t.type===f.scene?t.descendants:t.parentSceneAsEntity.descendants,i=a.filter((t=>t.name===n)).find(Boolean),void 0===i&&(o=`. sibling entity named "${n}" has not been added to the game object`)}if(void 0===i)throw new Error("error getting uuid of sibling contraint"+o);i!==t&&n.push(i.uuid)}})),n}(this,null===(e=t.layout)||void 0===e?void 0:e.constraints))}));const A=this.findTopologicalSort(C);if(A.length>0){const t=A.reverse(),e=new Array;t.forEach((t=>{const n=this.children.filter((e=>e.uuid===t)).find(Boolean);if(void 0===n)throw new Error("error in dag topological sort");e.push(n)})),e.forEach((t=>t.update()))}else this.children.forEach((t=>t.update()))}drawChildren(t){this.children.filter((t=>!t.hidden&&t.isDrawable)).map((t=>t)).sort(((t,e)=>t.zPosition-e.zPosition)).forEach((e=>e.draw(t)))}run(t,e){this.actions.push(...t.initialize(this,e)),this.originalActions=this.actions.filter((t=>!1===t.runDuringTransition)).map((t=>r.cloneAction(t,e)))}removeAction(t){this.actions=this.actions.filter((e=>e.key!==t))}removeAllActions(){for(;this.actions.length;)this.actions.pop()}getEntityOptions(){return{name:this.name,position:this.position,scale:this.scale,isUserInteractionEnabled:this.isUserInteractionEnabled,hidden:this.hidden}}getDrawableOptions(){if(!this.isDrawable)throw new Error("getDrawableOptions() called object that is not IDrawable");return{anchorPoint:this.anchorPoint,zPosition:this.zPosition}}getTextOptions(){if(!this.isText)throw new Error("getTextOptions() called object that is not IText");return{text:this.text,fontName:this.fontName,fontColor:this.fontColor,fontSize:this.fontSize}}get canvasKit(){let t;return t=this.type===f.scene?this:this.parentSceneAsEntity,t.game.canvasKit}get parentSceneAsEntity(){if(this.type===f.scene)throw new Error(`Entity ${this} is a scene and cannot have a parent scene`);if(this.parent&&this.parent.type===f.scene)return this.parent;if(this.parent)return this.parent.parentSceneAsEntity;throw new Error(`Entity ${this} has not been added to a scene`)}findTopologicalSort(t){var e;const n=[],r=new Map;t.forEach(((t,e)=>{r.has(e)||r.set(e,0),t.forEach((t=>{r.has(t)?r.set(t,r.get(t)+1):r.set(t,1)}))}));const i=[];for(r.forEach(((t,e)=>{0==t&&i.push(e)}));i.length>0;){const o=i.shift();if(void 0===o)throw"bad";n.push(o),t.has(o)&&(null===(e=t.get(o))||void 0===e||e.forEach((t=>{if(r.has(t)&&r.get(t)>0){const e=r.get(t)-1;r.set(t,e),0==e&&i.push(t)}})))}return n}}class P extends S{constructor(t={}){super(t),this.type=f.composite,this.compositeType="<compositeType>",this.isDrawable=!0,this.anchorPoint={x:.5,y:.5},this.zPosition=0,T(this,t)}initialize(){}update(){super.update()}draw(t){super.drawChildren(t)}}class _{}_.Transparent=[0,0,0,0],_.MediumVioletRed=[199,21,133,1],_.DeepPink=[255,20,147,1],_.PaleVioletRed=[219,112,147,1],_.HotPink=[255,105,180,1],_.LightPink=[255,182,193,1],_.Pink=[255,192,203,1],_.DarkRed=[139,0,0,1],_.Red=[255,0,0,1],_.Firebrick=[178,34,34,1],_.Crimson=[220,20,60,1],_.IndianRed=[205,92,92,1],_.LightCoral=[240,128,128,1],_.Salmon=[250,128,114,1],_.DarkSalmon=[233,150,122,1],_.LightSalmon=[255,160,122,1],_.OrangeRed=[255,69,0,1],_.Tomato=[255,99,71,1],_.DarkOrange=[255,140,0,1],_.Coral=[255,127,80,1],_.Orange=[255,165,0,1],_.DarkKhaki=[189,183,107,1],_.Gold=[255,215,0,1],_.Khaki=[240,230,140,1],_.PeachPuff=[255,218,185,1],_.Yellow=[255,255,0,1],_.PaleGoldenrod=[238,232,170,1],_.Moccasin=[255,228,181,1],_.PapayaWhip=[255,239,213,1],_.LightGoldenrodYellow=[250,250,210,1],_.LemonChiffon=[255,250,205,1],_.LightYellow=[255,255,224,1],_.Maroon=[128,0,0,1],_.Brown=[165,42,42,1],_.SaddleBrown=[139,69,19,1],_.Sienna=[160,82,45,1],_.Chocolate=[210,105,30,1],_.DarkGoldenrod=[184,134,11,1],_.Peru=[205,133,63,1],_.RosyBrown=[188,143,143,1],_.Goldenrod=[218,165,32,1],_.SandyBrown=[244,164,96,1],_.Tan=[210,180,140,1],_.Burlywood=[222,184,135,1],_.Wheat=[245,222,179,1],_.NavajoWhite=[255,222,173,1],_.Bisque=[255,228,196,1],_.BlanchedAlmond=[255,235,205,1],_.Cornsilk=[255,248,220,1],_.DarkGreen=[0,100,0,1],_.Green=[0,128,0,1],_.DarkOliveGreen=[85,107,47,1],_.ForestGreen=[34,139,34,1],_.SeaGreen=[46,139,87,1],_.Olive=[128,128,0,1],_.OliveDrab=[107,142,35,1],_.MediumSeaGreen=[60,179,113,1],_.LimeGreen=[50,205,50,1],_.Lime=[0,255,0,1],_.SpringGreen=[0,255,127,1],_.MediumSpringGreen=[0,250,154,1],_.DarkSeaGreen=[143,188,143,1],_.MediumAquamarine=[102,205,170,1],_.YellowGreen=[154,205,50,1],_.LawnGreen=[124,252,0,1],_.Chartreuse=[127,255,0,1],_.LightGreen=[144,238,144,1],_.GreenYellow=[173,255,47,1],_.PaleGreen=[152,251,152,1],_.Teal=[0,128,128,1],_.DarkCyan=[0,139,139,1],_.LightSeaGreen=[32,178,170,1],_.CadetBlue=[95,158,160,1],_.DarkTurquoise=[0,206,209,1],_.MediumTurquoise=[72,209,204,1],_.Turquoise=[64,224,208,1],_.Aqua=[0,255,255,1],_.Cyan=[0,255,255,1],_.Aquamarine=[127,255,212,1],_.PaleTurquoise=[175,238,238,1],_.LightCyan=[224,255,255,1],_.Navy=[0,0,128,1],_.DarkBlue=[0,0,139,1],_.MediumBlue=[0,0,205,1],_.Blue=[0,0,255,1],_.MidnightBlue=[25,25,112,1],_.RoyalBlue=[65,105,225,1],_.SteelBlue=[70,130,180,1],_.DodgerBlue=[30,144,255,1],_.DeepSkyBlue=[0,191,255,1],_.CornflowerBlue=[100,149,237,1],_.SkyBlue=[135,206,235,1],_.LightSkyBlue=[135,206,250,1],_.LightSteelBlue=[176,196,222,1],_.LightBlue=[173,216,230,1],_.PowderBlue=[176,224,230,1],_.Indigo=[75,0,130,1],_.Purple=[128,0,128,1],_.DarkMagenta=[139,0,139,1],_.DarkViolet=[148,0,211,1],_.DarkSlateBlue=[72,61,139,1],_.BlueViolet=[138,43,226,1],_.DarkOrchid=[153,50,204,1],_.Fuchsia=[255,0,255,1],_.Magenta=[255,0,255,1],_.SlateBlue=[106,90,205,1],_.MediumSlateBlue=[123,104,238,1],_.MediumOrchid=[186,85,211,1],_.MediumPurple=[147,112,219,1],_.Orchid=[218,112,214,1],_.Violet=[238,130,238,1],_.Plum=[221,160,221,1],_.Thistle=[216,191,216,1],_.Lavender=[230,230,250,1],_.MistyRose=[255,228,225,1],_.AntiqueWhite=[250,235,215,1],_.Linen=[250,240,230,1],_.Beige=[245,245,220,1],_.WhiteSmoke=[245,245,245,1],_.LavenderBlush=[255,240,245,1],_.OldLace=[253,245,230,1],_.AliceBlue=[240,248,255,1],_.Seashell=[255,245,238,1],_.GhostWhite=[248,248,255,1],_.Honeydew=[240,255,240,1],_.FloralWhite=[255,250,240,1],_.Azure=[240,255,255,1],_.MintCream=[245,255,250,1],_.Snow=[255,250,250,1],_.Ivory=[255,255,240,1],_.White=[255,255,255,1],_.Black=[0,0,0,1],_.DarkSlateGray=[47,79,79,1],_.DimGray=[105,105,105,1],_.SlateGray=[112,128,144,1],_.Gray=[128,128,128,1],_.LightSlateGray=[119,136,153,1],_.DarkGray=[169,169,169,1],_.Silver=[192,192,192,1],_.LightGray=[211,211,211,1],_.Gainsboro=[220,220,220,1],_.RebeccaPurple=[102,51,153,1];class M{}M.FPS_DISPLAY_TEXT_FONT_SIZE=12,M.FPS_DISPLAY_TEXT_COLOR=[0,0,0,.5],M.FPS_DISPLAY_UPDATE_INTERVAL=500,M.DEFAULT_SCENE_BACKGROUND_COLOR=_.White,M.DEFAULT_SHAPE_FILL_COLOR=_.Red,M.DEFAULT_FONT_COLOR=_.Black,M.DEFAULT_FONT_SIZE=16,M.LIMITED_FPS_RATE=5,function(t){t[t.MATCH_CONSTRAINT=0]="MATCH_CONSTRAINT"}(p||(p={}));class k extends S{constructor(t={}){super(t),this.type=f.sprite,this.isDrawable=!0,this.anchorPoint={x:.5,y:.5},this.zPosition=0,this._imageName="",T(this,t),t.imageName&&(this.imageName=t.imageName)}initialize(){const t=this.parentSceneAsEntity.game.session;if(!t)throw new Error("activity is undefined");const e=t.imageManager,n=this.parentSceneAsEntity.game.uuid;if(this.loadedImage=e.getLoadedImage(n,this._imageName),!this.loadedImage)throw new Error(`could not create sprite. the image named ${this._imageName} has not been loaded`);this.size.width=this.loadedImage.width,this.size.height=this.loadedImage.height}set imageName(t){this._imageName=t,this.needsInitialization=!0}get imageName(){return this._imageName}duplicate(t){const e=new k(Object.assign(Object.assign(Object.assign({},this.getEntityOptions()),this.getDrawableOptions()),{imageName:this.imageName,name:t}));return this.children.length>0&&(e.children=this.children.map((t=>{const n=t.duplicate();return n.parent=e,n}))),e}update(){super.update()}draw(t){if(!this.hidden){if(this.loadedImage){t.save();const e=Globals.canvasScale/this.absoluteScale;t.scale(1/e,1/e);const n=(this.absolutePosition.x-this.size.width*this.anchorPoint.x*this.absoluteScale)*e,r=(this.absolutePosition.y-this.size.height*this.anchorPoint.y*this.absoluteScale)*e;t.drawImage(this.loadedImage.image,n,r),t.restore()}super.drawChildren(t)}}}class x extends S{constructor(t={}){super(t),this.type=f.scene,this.isDrawable=!0,this.anchorPoint={x:0,y:0},this.zPosition=0,this._backgroundColor=M.DEFAULT_SCENE_BACKGROUND_COLOR,this._active=!1,this._transitioning=!1,T(this,t),t.backgroundColor&&(this.backgroundColor=t.backgroundColor)}initialize(){this.scale=Globals.rootScale,this.size.width=this.game.canvasCssWidth,this.size.height=this.game.canvasCssHeight,this.backgroundPaint=new this.canvasKit.Paint,this.backgroundPaint.setColor(this.canvasKit.Color(this.backgroundColor[0],this.backgroundColor[1],this.backgroundColor[2],this.backgroundColor[3])),this.backgroundPaint.setStyle(this.canvasKit.PaintStyle.Fill)}set game(t){this._game=t}get game(){if(void 0===this._game)throw new Error("no active game");return this._game}get backgroundColor(){return this._backgroundColor}set backgroundColor(t){this._backgroundColor=t,this.needsInitialization=!0}duplicate(t){const e=new x(Object.assign(Object.assign(Object.assign({},this.getEntityOptions()),this.getDrawableOptions()),{backgroundColor:this.backgroundColor,name:t}));return e.game=this.game,this.children.length>0&&(e.children=this.children.map((t=>{const n=t.duplicate();return n.parent=e,n}))),e}onSetup(t){this._setupCallback=t}onAppear(t){this._appearCallback=t}draw(t){t.save();const e=Globals.canvasScale/this.absoluteScale;t.scale(1/e,1/e);const n=this.canvasKit.RRectXY(this.canvasKit.LTRBRect(this.position.x*e*Globals.rootScale,this.position.y*e*Globals.rootScale,(this.position.x+this.size.width)*e*Globals.rootScale,(this.position.y+this.size.height)*e*Globals.rootScale),0,0);t.drawRRect(n,this.backgroundPaint),t.restore(),super.drawChildren(t)}}class F{constructor(){this.duration=0}static push(t,e){return new E(t,e)}}class E extends F{constructor(t,e){super(),this.type=g.push,this.direction=t,this.duration=e}}(g||(g={})).push="Push",function(t){t.up="Up",t.down="Down",t.right="Right",t.left="Left"}(y||(y={})),function(t){t[t.center=0]="center",t[t.left=1]="left",t[t.right=2]="right"}(m||(m={}));class O extends S{constructor(t={}){super(t),this.type=f.label,this.isDrawable=!0,this.isText=!0,this.anchorPoint={x:.5,y:.5},this.zPosition=0,this._text="",this._fontColor=M.DEFAULT_FONT_COLOR,this._fontSize=M.DEFAULT_FONT_SIZE,this._horizontalAlignmentMode=m.center,T(this,t),t.horizontalAlignmentMode&&(this.horizontalAlignmentMode=t.horizontalAlignmentMode),void 0!==t.preferredMaxLayoutWidth&&(this.preferredMaxLayoutWidth=t.preferredMaxLayoutWidth),t.backgroundColor&&(this.backgroundColor=t.backgroundColor)}initialize(){var t,e,n;let r=this.canvasKit.TextAlign.Center;switch(this.horizontalAlignmentMode){case m.center:r=this.canvasKit.TextAlign.Center;break;case m.left:r=this.canvasKit.TextAlign.Left;break;case m.right:r=this.canvasKit.TextAlign.Right;break;default:throw new Error("unknown horizontalAlignmentMode")}this.paraStyle=new this.canvasKit.ParagraphStyle({textStyle:{color:this.canvasKit.Color(this.fontColor[0],this.fontColor[1],this.fontColor[2],this.fontColor[3]),fontSize:this.fontSize*Globals.canvasScale},textAlign:r}),this.fontName&&this.paraStyle.textStyle&&(this.paraStyle.textStyle.fontFamilies=[this.fontName]),this.backgroundColor&&this.paraStyle.textStyle&&(this.paraStyle.textStyle.backgroundColor=this.backgroundColor);const i=this.parentSceneAsEntity.game.session;if(!i)throw new Error("activity is undefined");const o=i.fontManager;if(void 0===o.fontMgr)throw new Error("no fonts loaded");const a=this.canvasKit.ParagraphBuilder.Make(this.paraStyle,o.fontMgr);this.text||(this.text=""),a.addText(this.text),""===this.text&&console.warn(`warning: empty text in label "${this.name}"`),this.paragraph=a.build();const s=null!==(t=this.preferredMaxLayoutWidth)&&void 0!==t?t:Globals.canvasCssWidth;let l=s;if(0===s||0===this.layout.width){if(void 0===this.parent)throw new Error("width is set to match parent, but entity has no parent");const t=null!==(e=this.layout.marginStart)&&void 0!==e?e:0,r=null!==(n=this.layout.marginEnd)&&void 0!==n?n:0;l=this.parent.size.width-(t+r)}this.paragraph.layout(l*Globals.canvasScale),0===s||0===this.layout.width?this.size.width=l:(this.paragraph.layout(Math.ceil(this.paragraph.getMaxIntrinsicWidth())),this.size.width=this.paragraph.getMaxIntrinsicWidth()/Globals.canvasScale),this.size.height=this.paragraph.getHeight()/Globals.canvasScale}get text(){return this._text}set text(t){this._text=t,this.needsInitialization=!0}get fontName(){return this._fontName}set fontName(t){this._fontName=t,this.needsInitialization=!0}get fontColor(){return this._fontColor}set fontColor(t){this._fontColor=t,this.needsInitialization=!0}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize=t,this.needsInitialization=!0}get horizontalAlignmentMode(){return this._horizontalAlignmentMode}set horizontalAlignmentMode(t){this._horizontalAlignmentMode=t,this.needsInitialization=!0}get preferredMaxLayoutWidth(){return this._preferredMaxLayoutWidth}set preferredMaxLayoutWidth(t){this._preferredMaxLayoutWidth=t,this.needsInitialization=!0}get backgroundColor(){return this._backgroundColor}set backgroundColor(t){this._backgroundColor=t,this.needsInitialization=!0}duplicate(t){const e=new O(Object.assign(Object.assign(Object.assign(Object.assign({},this.getEntityOptions()),this.getDrawableOptions()),this.getTextOptions()),{horizontalAlignmentMode:this.horizontalAlignmentMode,preferredMaxLayoutWidth:this.preferredMaxLayoutWidth,backgroundColor:this.backgroundColor,name:t}));return this.children.length>0&&(e.children=this.children.map((t=>{const n=t.duplicate();return n.parent=e,n}))),e}update(){super.update()}draw(t){if(this.parent&&""!==this.text){t.save();const e=Globals.canvasScale/this.absoluteScale;t.scale(1/e,1/e);const n=(this.absolutePosition.x-this.size.width*this.anchorPoint.x*this.absoluteScale)*e,r=(this.absolutePosition.y-this.size.height*this.anchorPoint.y*this.absoluteScale)*e;if(void 0===this.paragraph)throw new Error("no paragraph");t.drawParagraph(this.paragraph,n,r),t.restore()}super.drawChildren(t)}}!function(t){t[void 0]="Undefined",t.rectangle="Rectangle",t.circle="Circle"}(v||(v={}));class B extends S{constructor(t={}){super(t),this.type=f.shape,this.isDrawable=!0,this.isShape=!0,this.anchorPoint={x:.5,y:.5},this.zPosition=0,this.shapeType=v.undefined,this.cornerRadius=0,this._fillColor=M.DEFAULT_SHAPE_FILL_COLOR,T(this,t),void 0!==t.circleOfRadius&&(this.circleOfRadius=t.circleOfRadius,this.shapeType=v.circle),t.rect&&(this.rect=t.rect,t.rect.size?(this.size.width=t.rect.size.width,this.size.height=t.rect.size.height):void 0!==t.rect.width&&void 0!==t.rect.height&&(this.size.width=t.rect.width,this.size.height=t.rect.height),t.rect.origin?this.position=t.rect.origin:void 0!==t.rect.x&&void 0!==t.rect.y&&(this.position={x:t.rect.x,y:t.rect.y}),this.shapeType=v.rectangle),t.cornerRadius&&(this.cornerRadius=t.cornerRadius),t.fillColor&&(this.fillColor=t.fillColor),t.strokeColor&&(this.strokeColor=t.strokeColor),t.lineWidth&&(this.lineWidth=t.lineWidth),t.strokeColor&&void 0===t.lineWidth&&console.warn(`warning: for entity ${this}, strokeColor = ${t.strokeColor} but lineWidth is undefined. In normal usage, both would be set or both would be undefined.`),void 0===t.strokeColor&&t.lineWidth&&console.warn(`warning: for entity ${this}, lineWidth = ${t.lineWidth} but strokeColor is undefined. In normal usage, both would be set or both would be undefined.`)}initialize(){if(this.fillColor){const t=this.canvasKit;this.fillColorPaint=new t.Paint,this.fillColorPaint.setColor(t.Color(this.fillColor[0],this.fillColor[1],this.fillColor[2],this.fillColor[3])),this.fillColorPaint.setStyle(t.PaintStyle.Fill),this.fillColorPaint.setAntiAlias(!0)}if(this.strokeColor){const t=this.canvasKit;this.strokeColorPaint=new t.Paint,this.strokeColorPaint.setColor(t.Color(this.strokeColor[0],this.strokeColor[1],this.strokeColor[2],this.strokeColor[3])),this.strokeColorPaint.setStyle(t.PaintStyle.Stroke),this.strokeColorPaint.setAntiAlias(!0)}}get fillColor(){return this._fillColor}set fillColor(t){this._fillColor=t,this.needsInitialization=!0}get strokeColor(){return this._strokeColor}set strokeColor(t){this._strokeColor=t,this.needsInitialization=!0}duplicate(t){const e=new B(Object.assign(Object.assign(Object.assign({},this.getEntityOptions()),this.getDrawableOptions()),{shapeType:this.shapeType,circleOfRadius:this.circleOfRadius,rect:this.rect,cornerRadius:this.cornerRadius,fillColor:this.fillColor,strokeColor:this.strokeColor,lineWidth:this.lineWidth,name:t}));return this.children.length>0&&(e.children=this.children.map((t=>{const n=t.duplicate();return n.parent=e,n}))),e}update(){super.update()}draw(t){t.save();const e=Globals.canvasScale/this.absoluteScale;if(t.scale(1/e,1/e),this.shapeType===v.circle&&void 0!==this.circleOfRadius){const n=this.absolutePosition.x*e,r=this.absolutePosition.y*e,i=this.circleOfRadius*this.absoluteScale*e;this.fillColor&&this.fillColorPaint&&t.drawCircle(n,r,i,this.fillColorPaint),this.strokeColor&&this.strokeColorPaint&&this.lineWidth&&(this.strokeColorPaint.setStrokeWidth(this.lineWidth*e),t.drawCircle(n,r,i,this.strokeColorPaint))}if(this.shapeType===v.rectangle){const n=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);this.fillColor&&this.fillColorPaint&&t.drawRRect(n,this.fillColorPaint),this.strokeColor&&this.strokeColorPaint&&this.lineWidth&&(this.strokeColorPaint.setStrokeWidth(this.lineWidth*e),t.drawRRect(n,this.strokeColorPaint))}t.restore(),super.drawChildren(t)}}class R extends P{constructor(t){if(super(t),this.compositeType="grid",this.rows=0,this.columns=0,this.gridBackgroundColor=[0,0,233,.25],this.gridLineColor=_.Red,this.gridLineWidth=1,this.gridChildren=new Array,!t.size)throw new Error("grid size must be specified");if(this.size=t.size,!t.rows)throw new Error("rows must be specified");if(!(t.rows>=1))throw new Error("rows must be at least 1");if(this.rows=t.rows,!t.columns)throw new Error("columns must be specified");if(!(t.columns>=1))throw new Error("columns must be at least 1");this.columns=t.columns,t.backgroundColor&&(this.gridBackgroundColor=t.backgroundColor),t.gridLineColor&&(this.gridLineColor=t.gridLineColor),t.gridLineWidth&&(this.gridLineWidth=t.gridLineWidth),this.cellWidth=this.size.width/this.columns,this.cellHeight=this.size.height/this.rows}initialize(){super.removeAllChildren(),this.gridBackground=new B({name:"_"+this.name+"-gridBackground",rect:{size:this.size},fillColor:this.gridBackgroundColor,strokeColor:this.gridLineColor,lineWidth:this.gridLineWidth,isUserInteractionEnabled:this.isUserInteractionEnabled}),this.addChild(this.gridBackground),this.gridBackground.isUserInteractionEnabled=this.isUserInteractionEnabled;for(let t=1;t<this.columns;t++){const e=new B({name:"_"+this.name+"-gridVerticalLine-"+t,rect:{size:{width:this.gridLineWidth,height:this.size.height},origin:{x:-this.size.width/2+this.cellWidth*t,y:0}},fillColor:this.gridLineColor});this.gridBackground.addChild(e)}for(let t=1;t<this.rows;t++){const e=new B({name:"_"+this.name+"-gridHorizontalLine-"+t,rect:{size:{width:this.size.width,height:this.gridLineWidth},origin:{x:0,y:-this.size.height/2+this.cellHeight*t}},fillColor:this.gridLineColor});this.gridBackground.addChild(e)}this.gridChildren&&this.gridChildren.forEach((t=>{if(!this.cellWidth||!this.cellHeight||!this.gridBackground)throw new Error("cellWidth, cellHeight, or gridBackground undefined or null");const e=-this.size.width/2+this.cellWidth/2+t.column*this.cellWidth,n=-this.size.height/2+this.cellHeight/2+t.row*this.cellHeight;t.entity.position={x:e,y:n},this.gridBackground.addChild(t.entity)})),this.needsInitialization=!1}duplicate(t){const e=new R(Object.assign(Object.assign(Object.assign({},this.getEntityOptions()),this.getDrawableOptions()),{rows:this.rows,columns:this.columns,size:this.size,backgroundColor:this.gridBackgroundColor,gridLineWidth:this.gridLineWidth,gridLineColor:this.gridLineColor,name:t}));return this.children.length>0&&(e.children=this.children.map((t=>{const n=t.duplicate();return n.parent=e,n}))),e}update(){super.update()}draw(t){super.drawChildren(t)}removeAllChildren(){if(0!==this.gridChildren.length){for(;this.gridChildren.length;)this.gridChildren.pop();this.needsInitialization=!0}}addAtCell(t,e,n){(e<0||e>=this.rows||n<0||n>=this.columns)&&console.warn(`warning: addAtCell() requested to add entity at row ${e}, column ${n}. This is outside the bounds of grid ${this.name}, which is size ${this.rows}x${this.columns}. Note that addAtCell() uses zero-based indexing. AddAtCell() will proceed, but may draw entities outside the grid`),this.gridChildren.push({entity:t,row:e,column:n}),this.needsInitialization=!0}removeAllAtCell(t,e){this.gridChildren=this.gridChildren.filter((n=>n.row!=t&&n.column!=e)),this.needsInitialization=!0}removeChild(t){if(!this.gridBackground)throw new Error("gridBackground is null or undefined");this.gridBackground.removeChild(t),this.gridChildren=this.gridChildren.filter((e=>e.entity!=t)),this.needsInitialization=!0}}class L extends P{constructor(t){super(t),this.compositeType="button",this._backgroundColor=_.RoyalBlue,this.size={width:200,height:50},this.cornerRadius=9,this.fontSize=20,this.text="",this._fontColor=_.White,t.text&&(this.text=t.text),t.size&&(this.size=t.size),t.cornerRadius&&(this.cornerRadius=t.cornerRadius),t.fontSize&&(this.fontSize=t.fontSize),t.fontColor&&(this.fontColor=t.fontColor),t.backgroundColor&&(this.backgroundColor=t.backgroundColor)}initialize(){this.removeAllChildren(),this.backgroundPaint=new this.canvasKit.Paint,this.backgroundPaint.setColor(this.canvasKit.Color(this.backgroundColor[0],this.backgroundColor[1],this.backgroundColor[2],this.backgroundColor[3])),this.backgroundPaint.setStyle(this.canvasKit.PaintStyle.Fill);const t=new B({rect:{size:this.size},cornerRadius:this.cornerRadius,fillColor:this._backgroundColor});this.addChild(t);const e=new O({text:this.text,fontSize:this.fontSize,fontColor:this.fontColor});t.addChild(e),this.needsInitialization=!1}get backgroundColor(){return this._backgroundColor}set backgroundColor(t){this._backgroundColor=t,this.needsInitialization=!0}get fontColor(){return this._fontColor}set fontColor(t){this._fontColor=t,this.needsInitialization=!0}duplicate(t){const e=new L(Object.assign(Object.assign(Object.assign(Object.assign({},this.getEntityOptions()),this.getDrawableOptions()),this.getTextOptions()),{size:this.size,cornerRadius:this.cornerRadius,backgroundColor:this.backgroundColor,fontColor:this.fontColor,name:t}));return this.children.length>0&&(e.children=this.children.map((t=>{const n=t.duplicate();return n.parent=e,n}))),e}update(){super.update()}draw(t){super.drawChildren(t)}}class I extends class{static Create(t){return new Array}}{static Create(t){const e=new Array;return t.instructionScenes.forEach(((n,r)=>{var i,o,a,s,l,u,c,h,d,f,g,v,b,w,C,A,T,S,P,M,E,B,R,I,D,W,j,z,G,N,U,H,V,$;const Y=null!==(o=null!==(i=n.nextSceneTransition)&&void 0!==i?i:t.nextSceneTransition)&&void 0!==o?o:F.push(y.left,500),X=null!==(s=null!==(a=n.backSceneTransition)&&void 0!==a?a:t.backSceneTransition)&&void 0!==s?s:F.push(y.right,500),q=null!==(u=null!==(l=n.backButtonText)&&void 0!==l?l:t.backButtonText)&&void 0!==u?u:"Back",Q=null!==(h=null!==(c=n.nextButtonText)&&void 0!==c?c:t.nextButtonText)&&void 0!==h?h:"Next",K=null!==(f=null!==(d=n.backButtonWidth)&&void 0!==d?d:t.backButtonWidth)&&void 0!==f?f:125,J=null!==(v=null!==(g=n.nextButtonWidth)&&void 0!==g?g:t.nextButtonWidth)&&void 0!==v?v:125,Z=null!==(w=null!==(b=n.backButtonHeight)&&void 0!==b?b:t.backButtonHeight)&&void 0!==w?w:50,tt=null!==(A=null!==(C=n.nextButtonHeight)&&void 0!==C?C:t.nextButtonHeight)&&void 0!==A?A:50,et=null!==(T=n.backgroundColor)&&void 0!==T?T:t.backgroundColor,nt=null===(S=n.imageAboveText)||void 0===S||S,rt=null!==(P=n.imageMarginTop)&&void 0!==P?P:0,it=null!==(M=n.imageMarginBottom)&&void 0!==M?M:0,ot=null!==(E=n.textMarginStart)&&void 0!==E?E:48,at=null!==(B=n.textMarginEnd)&&void 0!==B?B:48,st=null!==(R=n.textAlignmentMode)&&void 0!==R?R:m.left,lt=null!==(I=n.textFontSize)&&void 0!==I?I:16,ut=null!==(D=n.titleFontSize)&&void 0!==D?D:16,ct=null!==(W=n.titleMarginTop)&&void 0!==W?W:48,ht=null!==(z=null!==(j=n.backButtonBackgroundColor)&&void 0!==j?j:t.backButtonBackgroundColor)&&void 0!==z?z:_.RoyalBlue,dt=null!==(N=null!==(G=n.backButtonFontColor)&&void 0!==G?G:t.backButtonFontColor)&&void 0!==N?N:_.White,ft=null!==(H=null!==(U=n.nextButtonBackgroundColor)&&void 0!==U?U:t.nextButtonBackgroundColor)&&void 0!==H?H:_.RoyalBlue,pt=null!==($=null!==(V=n.nextButtonFontColor)&&void 0!==V?V:t.nextButtonFontColor)&&void 0!==$?$:_.White,gt=new x({name:t.sceneNamePrefix+"-"+(r+1).toString().padStart(2,"0"),backgroundColor:et});let yt,mt;if(void 0!==n.title&&(yt=new O({text:n.title,fontSize:ut,layout:{marginTop:ct,constraints:{topToTopOf:gt,startToStartOf:gt,endToEndOf:gt}}}),gt.addChild(yt)),void 0!==n.text&&(mt=new O({text:n.text,preferredMaxLayoutWidth:p.MATCH_CONSTRAINT,horizontalAlignmentMode:st,fontSize:lt,layout:{marginStart:ot,marginEnd:at,constraints:{topToTopOf:gt,bottomToBottomOf:gt,startToStartOf:gt,endToEndOf:gt,verticalBias:n.textVerticalBias}}}),gt.addChild(mt)),void 0!==n.image){let t;t=new k(void 0!==mt?nt?{imageName:n.image,layout:{marginBottom:it,constraints:{bottomToTopOf:mt,startToStartOf:gt,endToEndOf:gt}}}:{imageName:n.image,layout:{marginTop:rt,constraints:{topToBottomOf:mt,startToStartOf:gt,endToEndOf:gt}}}:{imageName:n.image,layout:{constraints:{topToTopOf:gt,bottomToBottomOf:gt,verticalBias:n.imageVerticalBias,startToStartOf:gt,endToEndOf:gt}}}),gt.addChild(t)}if(r>0){const e=new L({text:q,fontColor:dt,backgroundColor:ht,size:{width:K,height:Z},layout:{marginStart:32,marginBottom:32,constraints:{bottomToBottomOf:gt,startToStartOf:gt}}});e.isUserInteractionEnabled=!0,e.onTapDown((()=>{gt.game.presentScene(t.sceneNamePrefix+"-"+(r+1-1).toString().padStart(2,"0"),X)})),gt.addChild(e)}const vt=new L({name:"nextButton",text:Q,fontColor:pt,backgroundColor:ft,size:{width:J,height:tt},layout:{marginEnd:32,marginBottom:32,constraints:{bottomToBottomOf:gt,endToEndOf:gt}}});vt.isUserInteractionEnabled=!0,r!==t.instructionScenes.length-1?vt.onTapDown((()=>{gt.game.presentScene(t.sceneNamePrefix+"-"+(r+1+1).toString().padStart(2,"0"),Y)})):void 0!==t.postInstructionsScene?vt.onTapDown((()=>{var e;gt.game.presentScene(null!==(e=t.postInstructionsScene)&&void 0!==e?e:"",Y)})):console.warn("warning: instructions postInstructionsScene is not defined"),gt.addChild(vt),e.push(gt)})),e}}export{L as Button,R as Grid,I as Instructions};
1
+ import { Composite, WebColors, Shape, Label, CanvasKitHelpers, EventType, Easings, Story, Transition, TransitionDirection, LabelHorizontalAlignmentMode, Scene, Dimensions, Sprite } from '@m2c2kit/core';
2
+
3
+ var __defProp$1 = Object.defineProperty;
4
+ var __defProps$1 = Object.defineProperties;
5
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
7
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues$1 = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp$1.call(b, prop))
13
+ __defNormalProp$1(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols$1)
15
+ for (var prop of __getOwnPropSymbols$1(b)) {
16
+ if (__propIsEnum$1.call(b, prop))
17
+ __defNormalProp$1(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
21
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
22
+ class Grid extends Composite {
23
+ /**
24
+ * A rectangular grid that supports placement of entities within the grid's
25
+ * cells.
26
+ *
27
+ * @remarks This composite entity is composed of rectangles and lines. It
28
+ * has convenience functions for placing and clearing entities on the grid
29
+ * by row and column position (zero-based indexing)
30
+ *
31
+ * @param options - {@link GridOptions}
32
+ */
33
+ constructor(options) {
34
+ super(options);
35
+ this.compositeType = "grid";
36
+ // Grid options
37
+ // TODO: make getter, setter for these so they can be changed after initial construction
38
+ this.rows = 0;
39
+ this.columns = 0;
40
+ // default Grid is: transparent gray, red lines, line width 1
41
+ this.gridBackgroundColor = [0, 0, 233, 0.25];
42
+ this.gridLineColor = WebColors.Red;
43
+ this.gridLineWidth = 1;
44
+ this.gridChildren = new Array();
45
+ if (options.size) {
46
+ this.size = options.size;
47
+ } else {
48
+ throw new Error("grid size must be specified");
49
+ }
50
+ if (options.rows) {
51
+ if (options.rows >= 1) {
52
+ this.rows = options.rows;
53
+ } else {
54
+ throw new Error("rows must be at least 1");
55
+ }
56
+ } else {
57
+ throw new Error("rows must be specified");
58
+ }
59
+ if (options.columns) {
60
+ if (options.columns >= 1) {
61
+ this.columns = options.columns;
62
+ } else {
63
+ throw new Error("columns must be at least 1");
64
+ }
65
+ } else {
66
+ throw new Error("columns must be specified");
67
+ }
68
+ if (options.backgroundColor) {
69
+ this.gridBackgroundColor = options.backgroundColor;
70
+ }
71
+ if (options.gridLineColor) {
72
+ this.gridLineColor = options.gridLineColor;
73
+ }
74
+ if (options.gridLineWidth) {
75
+ this.gridLineWidth = options.gridLineWidth;
76
+ }
77
+ this.cellWidth = this.size.width / this.columns;
78
+ this.cellHeight = this.size.height / this.rows;
79
+ }
80
+ initialize() {
81
+ super.removeAllChildren();
82
+ this.gridBackground = new Shape({
83
+ name: "_" + this.name + "-gridBackground",
84
+ rect: { size: this.size },
85
+ //size: this.size,
86
+ fillColor: this.gridBackgroundColor,
87
+ strokeColor: this.gridLineColor,
88
+ lineWidth: this.gridLineWidth,
89
+ isUserInteractionEnabled: this.isUserInteractionEnabled
90
+ });
91
+ this.addChild(this.gridBackground);
92
+ this.gridBackground.isUserInteractionEnabled = this.isUserInteractionEnabled;
93
+ for (let col = 1; col < this.columns; col++) {
94
+ const verticalLine = new Shape({
95
+ name: "_" + this.name + "-gridVerticalLine-" + col,
96
+ rect: {
97
+ size: { width: this.gridLineWidth, height: this.size.height },
98
+ origin: { x: -this.size.width / 2 + this.cellWidth * col, y: 0 }
99
+ },
100
+ fillColor: this.gridLineColor
101
+ });
102
+ this.gridBackground.addChild(verticalLine);
103
+ }
104
+ for (let row = 1; row < this.rows; row++) {
105
+ const horizontalLine = new Shape({
106
+ name: "_" + this.name + "-gridHorizontalLine-" + row,
107
+ rect: {
108
+ size: { width: this.size.width, height: this.gridLineWidth },
109
+ origin: { x: 0, y: -this.size.height / 2 + this.cellHeight * row }
110
+ },
111
+ fillColor: this.gridLineColor
112
+ });
113
+ this.gridBackground.addChild(horizontalLine);
114
+ }
115
+ if (this.gridChildren) {
116
+ this.gridChildren.forEach((gridChild) => {
117
+ if (!this.cellWidth || !this.cellHeight || !this.gridBackground) {
118
+ throw new Error(
119
+ "cellWidth, cellHeight, or gridBackground undefined or null"
120
+ );
121
+ }
122
+ const x = -this.size.width / 2 + this.cellWidth / 2 + gridChild.column * this.cellWidth;
123
+ const y = -this.size.height / 2 + this.cellHeight / 2 + gridChild.row * this.cellHeight;
124
+ gridChild.entity.position = { x, y };
125
+ this.gridBackground.addChild(gridChild.entity);
126
+ });
127
+ }
128
+ this.needsInitialization = false;
129
+ }
130
+ // all entities that make up grid are added as children, so they
131
+ // have their own dispose methods
132
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
133
+ dispose() {
134
+ }
135
+ /**
136
+ * Duplicates an entity using deep copy.
137
+ *
138
+ * @remarks This is a deep recursive clone (entity and children).
139
+ * The uuid property of all duplicated entities will be newly created,
140
+ * because uuid must be unique.
141
+ *
142
+ * @param newName - optional name of the new, duplicated entity. If not
143
+ * provided, name will be the new uuid
144
+ */
145
+ duplicate(newName) {
146
+ const dest = new Grid(__spreadProps$1(__spreadValues$1(__spreadValues$1({}, this.getEntityOptions()), this.getDrawableOptions()), {
147
+ rows: this.rows,
148
+ columns: this.columns,
149
+ size: this.size,
150
+ backgroundColor: this.gridBackgroundColor,
151
+ gridLineWidth: this.gridLineWidth,
152
+ gridLineColor: this.gridLineColor,
153
+ name: newName
154
+ }));
155
+ if (this.children.length > 0) {
156
+ dest.children = this.children.map((child) => {
157
+ const clonedChild = child.duplicate();
158
+ clonedChild.parent = dest;
159
+ return clonedChild;
160
+ });
161
+ }
162
+ return dest;
163
+ }
164
+ update() {
165
+ super.update();
166
+ }
167
+ draw(canvas) {
168
+ super.drawChildren(canvas);
169
+ }
170
+ warmup(canvas) {
171
+ this.initialize();
172
+ this.children.filter((child) => child.isDrawable).forEach((child) => {
173
+ child.warmup(canvas);
174
+ });
175
+ }
176
+ // override Entity.RemoveAllChildren() so that when RemoveAllChildren() is called on a Grid,
177
+ // it removes only entities added to the grid cells (what we call grid children), not the grid lines!
178
+ // note: when we upgrade to typescript 4.3+, we can mark this with override keyword to make intention explicit
179
+ /**
180
+ * Removes all children from the grid, but retains grid lines.
181
+ *
182
+ */
183
+ removeAllChildren() {
184
+ if (this.gridChildren.length === 0) {
185
+ return;
186
+ }
187
+ while (this.gridChildren.length) {
188
+ this.gridChildren.pop();
189
+ }
190
+ this.needsInitialization = true;
191
+ }
192
+ /**
193
+ * Adds an entity to the grid at the specified row and column position.
194
+ *
195
+ * @param entity - entity to add to the grid
196
+ * @param row - row position within grid to add entity; zero-based indexing
197
+ * @param column - column position within grid to add entity; zero-based indexing
198
+ */
199
+ addAtCell(entity, row, column) {
200
+ if (row < 0 || row >= this.rows || column < 0 || column >= this.columns) {
201
+ console.warn(
202
+ `warning: addAtCell() requested to add entity at row ${row}, column ${column}. This is outside the bounds of grid ${this.name}, which is size ${this.rows}x${this.columns}. Note that addAtCell() uses zero-based indexing. AddAtCell() will proceed, but may draw entities outside the grid`
203
+ );
204
+ }
205
+ this.gridChildren.push({ entity, row, column });
206
+ this.needsInitialization = true;
207
+ }
208
+ /**
209
+ * Removes all child entities at the specified row and column position.
210
+ *
211
+ * @param row - row position within grid at which to remove children; zero-based indexing
212
+ * @param column - column position within grid at which to remove children; zero-based indexing
213
+ */
214
+ removeAllAtCell(row, column) {
215
+ this.gridChildren = this.gridChildren.filter(
216
+ (gridChild) => gridChild.row != row && gridChild.column != column
217
+ );
218
+ this.needsInitialization = true;
219
+ }
220
+ // override Entity.RemoveChild() so that when RemoveChild() is called on a Grid, it removes the
221
+ // entity from the gridBackground rectangle AND our grid's own list of children (in gridChildren)
222
+ /**
223
+ * Removes the child entity from the grid.
224
+ *
225
+ * @param entity - entity to remove
226
+ */
227
+ removeChild(entity) {
228
+ if (!this.gridBackground) {
229
+ throw new Error("gridBackground is null or undefined");
230
+ }
231
+ this.gridBackground.removeChild(entity);
232
+ this.gridChildren = this.gridChildren.filter(
233
+ (gridChild) => gridChild.entity != entity
234
+ );
235
+ this.needsInitialization = true;
236
+ }
237
+ }
238
+
239
+ var __defProp = Object.defineProperty;
240
+ var __defProps = Object.defineProperties;
241
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
242
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
243
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
244
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
245
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
246
+ var __spreadValues = (a, b) => {
247
+ for (var prop in b || (b = {}))
248
+ if (__hasOwnProp.call(b, prop))
249
+ __defNormalProp(a, prop, b[prop]);
250
+ if (__getOwnPropSymbols)
251
+ for (var prop of __getOwnPropSymbols(b)) {
252
+ if (__propIsEnum.call(b, prop))
253
+ __defNormalProp(a, prop, b[prop]);
254
+ }
255
+ return a;
256
+ };
257
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
258
+ class Button extends Composite {
259
+ // todo: add getters/setters so button can respond to changes in its options
260
+ // todo: add default "behaviors" (?) like button click animation?
261
+ /**
262
+ * A simple button of rectangle with text centered inside.
263
+ *
264
+ * @remarks This composite entity is composed of a rectangle and text. To
265
+ * respond to user taps, the isUserInteractionEnabled property must be set
266
+ * to true and an appropriate callback must be set to handle the tap event.
267
+ *
268
+ * @param options - {@link ButtonOptions}
269
+ */
270
+ constructor(options) {
271
+ super(options);
272
+ this.compositeType = "button";
273
+ // Button options
274
+ this._backgroundColor = WebColors.Black;
275
+ this.size = { width: 200, height: 50 };
276
+ this.cornerRadius = 9;
277
+ this.fontSize = 20;
278
+ this.text = "";
279
+ this._fontColor = WebColors.White;
280
+ if (options.text) {
281
+ this.text = options.text;
282
+ }
283
+ if (options.size) {
284
+ this.size = options.size;
285
+ }
286
+ if (options.cornerRadius) {
287
+ this.cornerRadius = options.cornerRadius;
288
+ }
289
+ if (options.fontSize) {
290
+ this.fontSize = options.fontSize;
291
+ }
292
+ if (options.fontColor) {
293
+ this.fontColor = options.fontColor;
294
+ }
295
+ if (options.backgroundColor) {
296
+ this.backgroundColor = options.backgroundColor;
297
+ }
298
+ }
299
+ initialize() {
300
+ this.removeAllChildren();
301
+ this.backgroundPaint = new this.canvasKit.Paint();
302
+ this.backgroundPaint.setColor(
303
+ this.canvasKit.Color(
304
+ this.backgroundColor[0],
305
+ this.backgroundColor[1],
306
+ this.backgroundColor[2],
307
+ this.backgroundColor[3]
308
+ )
309
+ );
310
+ this.backgroundPaint.setStyle(this.canvasKit.PaintStyle.Fill);
311
+ const buttonRectangle = new Shape({
312
+ rect: { size: this.size },
313
+ cornerRadius: this.cornerRadius,
314
+ fillColor: this._backgroundColor
315
+ });
316
+ this.addChild(buttonRectangle);
317
+ const buttonLabel = new Label({
318
+ text: this.text,
319
+ fontSize: this.fontSize,
320
+ fontColor: this.fontColor
321
+ });
322
+ buttonRectangle.addChild(buttonLabel);
323
+ this.needsInitialization = false;
324
+ }
325
+ dispose() {
326
+ CanvasKitHelpers.Dispose([this.backgroundPaint]);
327
+ }
328
+ get backgroundColor() {
329
+ return this._backgroundColor;
330
+ }
331
+ set backgroundColor(backgroundColor) {
332
+ this._backgroundColor = backgroundColor;
333
+ this.needsInitialization = true;
334
+ }
335
+ get fontColor() {
336
+ return this._fontColor;
337
+ }
338
+ set fontColor(fontColor) {
339
+ this._fontColor = fontColor;
340
+ this.needsInitialization = true;
341
+ }
342
+ /**
343
+ * Duplicates an entity using deep copy.
344
+ *
345
+ * @remarks This is a deep recursive clone (entity and children).
346
+ * The uuid property of all duplicated entities will be newly created,
347
+ * because uuid must be unique.
348
+ *
349
+ * @param newName - optional name of the new, duplicated entity. If not
350
+ * provided, name will be the new uuid
351
+ */
352
+ duplicate(newName) {
353
+ const dest = new Button(__spreadProps(__spreadValues(__spreadValues(__spreadValues({}, this.getEntityOptions()), this.getDrawableOptions()), this.getTextOptions()), {
354
+ size: this.size,
355
+ cornerRadius: this.cornerRadius,
356
+ backgroundColor: this.backgroundColor,
357
+ fontColor: this.fontColor,
358
+ name: newName
359
+ }));
360
+ if (this.children.length > 0) {
361
+ dest.children = this.children.map((child) => {
362
+ const clonedChild = child.duplicate();
363
+ clonedChild.parent = dest;
364
+ return clonedChild;
365
+ });
366
+ }
367
+ return dest;
368
+ }
369
+ update() {
370
+ super.update();
371
+ }
372
+ draw(canvas) {
373
+ super.drawChildren(canvas);
374
+ }
375
+ warmup(canvas) {
376
+ this.initialize();
377
+ this.children.filter((child) => child.isDrawable).forEach((child) => {
378
+ child.warmup(canvas);
379
+ });
380
+ }
381
+ }
382
+
383
+ var DialogResult = /* @__PURE__ */ ((DialogResult2) => {
384
+ DialogResult2["Dismiss"] = "Dismiss";
385
+ DialogResult2["Positive"] = "Positive";
386
+ DialogResult2["Negative"] = "Negative";
387
+ return DialogResult2;
388
+ })(DialogResult || {});
389
+ class Dialog extends Composite {
390
+ // todo: add getters/setters so button can respond to changes in its options
391
+ // todo: add default "behaviors" (?) like button click animation?
392
+ constructor(options) {
393
+ super(options);
394
+ this.compositeType = "dialog";
395
+ this._backgroundColor = WebColors.White;
396
+ this.cornerRadius = 9;
397
+ this.overlayAlpha = 0.5;
398
+ this.contentText = "";
399
+ this.positiveButtonText = "";
400
+ this.negativeButtonText = "";
401
+ this.zPosition = Number.MAX_VALUE;
402
+ this.hidden = true;
403
+ this._fontColor = WebColors.White;
404
+ if (!options) {
405
+ return;
406
+ }
407
+ if (options.overlayAlpha) {
408
+ this.overlayAlpha = options.overlayAlpha;
409
+ }
410
+ if (options.messageText) {
411
+ this.contentText = options.messageText;
412
+ }
413
+ if (options.positiveButtonText) {
414
+ this.positiveButtonText = options.positiveButtonText;
415
+ }
416
+ if (options.negativeButtonText) {
417
+ this.negativeButtonText = options.negativeButtonText;
418
+ }
419
+ if (options.size) {
420
+ this.size = options.size;
421
+ }
422
+ if (options.cornerRadius) {
423
+ this.cornerRadius = options.cornerRadius;
424
+ }
425
+ if (options.fontColor) {
426
+ this.fontColor = options.fontColor;
427
+ }
428
+ if (options.backgroundColor) {
429
+ this.backgroundColor = options.backgroundColor;
430
+ }
431
+ }
432
+ show() {
433
+ this.hidden = false;
434
+ }
435
+ onDialolgResult(callback, replaceExistingCallback = true) {
436
+ const eventListener = {
437
+ type: EventType.CompositeCustom,
438
+ entityUuid: this.uuid,
439
+ callback
440
+ };
441
+ if (replaceExistingCallback) {
442
+ this.eventListeners = this.eventListeners.filter(
443
+ (listener) => !(listener.entityUuid === eventListener.entityUuid && listener.type === eventListener.type)
444
+ );
445
+ }
446
+ this.eventListeners.push(eventListener);
447
+ }
448
+ initialize() {
449
+ this.removeAllChildren();
450
+ const overlay = new Shape({
451
+ rect: {
452
+ width: Globals.canvasCssWidth,
453
+ height: Globals.canvasCssHeight,
454
+ x: Globals.canvasCssWidth / 2,
455
+ y: Globals.canvasCssHeight / 2
456
+ },
457
+ fillColor: [0, 0, 0, this.overlayAlpha],
458
+ zPosition: -1,
459
+ isUserInteractionEnabled: true
460
+ });
461
+ overlay.onTapDown((e) => {
462
+ e.handled = true;
463
+ this.hidden = true;
464
+ if (this.eventListeners.length > 0) {
465
+ this.eventListeners.filter((listener) => listener.type === EventType.CompositeCustom).forEach((listener) => {
466
+ const dialogEvent = {
467
+ type: EventType.CompositeCustom,
468
+ target: this,
469
+ handled: false,
470
+ dialogResult: "Dismiss" /* Dismiss */
471
+ };
472
+ listener.callback(dialogEvent);
473
+ });
474
+ }
475
+ });
476
+ this.addChild(overlay);
477
+ const dialogBox = new Shape({
478
+ rect: {
479
+ width: 300,
480
+ height: 150,
481
+ x: Globals.canvasCssWidth / 2,
482
+ y: Globals.canvasCssHeight / 2
483
+ },
484
+ cornerRadius: this.cornerRadius,
485
+ fillColor: this.backgroundColor,
486
+ isUserInteractionEnabled: true
487
+ });
488
+ dialogBox.onTapDown((e) => {
489
+ e.handled = true;
490
+ });
491
+ this.addChild(dialogBox);
492
+ const dialogBoxPrimaryText = new Label({
493
+ text: this.contentText,
494
+ fontSize: 24,
495
+ position: { x: 200, y: 360 }
496
+ });
497
+ this.addChild(dialogBoxPrimaryText);
498
+ const negativeButton = new Button({
499
+ text: this.negativeButtonText,
500
+ position: { x: 120, y: 440 },
501
+ size: { width: 100, height: 40 },
502
+ isUserInteractionEnabled: true,
503
+ zPosition: 1
504
+ });
505
+ negativeButton.onTapDown((e) => {
506
+ e.handled = true;
507
+ this.hidden = true;
508
+ });
509
+ negativeButton.onTapDown((e) => {
510
+ e.handled = true;
511
+ this.hidden = true;
512
+ if (this.eventListeners.length > 0) {
513
+ this.eventListeners.filter((listener) => listener.type === EventType.CompositeCustom).forEach((listener) => {
514
+ const dialogEvent = {
515
+ type: EventType.CompositeCustom,
516
+ target: this,
517
+ handled: false,
518
+ dialogResult: "Negative" /* Negative */
519
+ };
520
+ listener.callback(dialogEvent);
521
+ });
522
+ }
523
+ });
524
+ const positiveButton = new Button({
525
+ text: this.positiveButtonText,
526
+ position: { x: 280, y: 440 },
527
+ size: { width: 100, height: 40 },
528
+ isUserInteractionEnabled: true,
529
+ zPosition: 1
530
+ });
531
+ positiveButton.onTapDown((e) => {
532
+ e.handled = true;
533
+ this.hidden = true;
534
+ if (this.eventListeners.length > 0) {
535
+ this.eventListeners.filter((listener) => listener.type === EventType.CompositeCustom).forEach((listener) => {
536
+ const dialogEvent = {
537
+ type: EventType.CompositeCustom,
538
+ target: this,
539
+ handled: false,
540
+ dialogResult: "Positive" /* Positive */
541
+ };
542
+ listener.callback(dialogEvent);
543
+ });
544
+ }
545
+ });
546
+ this.addChild(negativeButton);
547
+ this.addChild(positiveButton);
548
+ this.needsInitialization = false;
549
+ }
550
+ get backgroundColor() {
551
+ return this._backgroundColor;
552
+ }
553
+ set backgroundColor(backgroundColor) {
554
+ this._backgroundColor = backgroundColor;
555
+ this.needsInitialization = true;
556
+ }
557
+ get fontColor() {
558
+ return this._fontColor;
559
+ }
560
+ set fontColor(fontColor) {
561
+ this._fontColor = fontColor;
562
+ this.needsInitialization = true;
563
+ }
564
+ /**
565
+ * Duplicates an entity using deep copy.
566
+ *
567
+ * @remarks This is a deep recursive clone (entity and children).
568
+ * The uuid property of all duplicated entities will be newly created,
569
+ * because uuid must be unique.
570
+ *
571
+ * @param newName - optional name of the new, duplicated entity. If not
572
+ * provided, name will be the new uuid
573
+ */
574
+ duplicate(newName) {
575
+ throw new Error("duplicate not implemented");
576
+ }
577
+ update() {
578
+ super.update();
579
+ }
580
+ draw(canvas) {
581
+ super.drawChildren(canvas);
582
+ }
583
+ warmup(canvas) {
584
+ this.initialize();
585
+ this.children.filter((child) => child.isDrawable).forEach((child) => {
586
+ child.warmup(canvas);
587
+ });
588
+ }
589
+ }
590
+
591
+ class VirtualKeyboard extends Composite {
592
+ /**
593
+ * An on-screen keyboard that can be used to enter text.
594
+ *
595
+ * @param options - {@link VirtualKeyboardOptions}
596
+ */
597
+ constructor(options) {
598
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
599
+ super(options);
600
+ this.rowsConfiguration = new Array();
601
+ this.shiftActivated = false;
602
+ this.size = options.size;
603
+ this.position = (_a = options.position) != null ? _a : { x: 0, y: 0 };
604
+ this.keyboardHorizontalPaddingPercent = (_b = options.keyboardHorizontalPaddingPercent) != null ? _b : 0.02;
605
+ this.keyboardVerticalPaddingPercent = (_c = options.keyboardVerticalPaddingPercent) != null ? _c : 0.025;
606
+ this.keyHorizontalPaddingPercent = (_d = options.keyHorizontalPaddingPercent) != null ? _d : 0.1;
607
+ this.keyVerticalPaddingPercent = (_e = options.keyVerticalPaddingPercent) != null ? _e : 0.1;
608
+ if (options.rows !== void 0) {
609
+ this.rowsConfiguration = options.rows;
610
+ }
611
+ this.keysPerRow = (_f = options.keysPerRow) != null ? _f : NaN;
612
+ this.fontSize = (_g = options.fontSize) != null ? _g : NaN;
613
+ this.hiddenKeys = (_h = options.hiddenKeys) != null ? _h : "";
614
+ this.captialLettersOnly = (_i = options.captialLettersOnly) != null ? _i : false;
615
+ this.keyColor = (_j = options.keyColor) != null ? _j : WebColors.White;
616
+ this.keyDownColor = (_k = options.keyDownColor) != null ? _k : WebColors.Transparent;
617
+ this.specialKeyDownColor = (_l = options.specialKeyDownColor) != null ? _l : WebColors.LightSteelBlue;
618
+ this.backgroundColor = (_m = options.backgroundColor) != null ? _m : [242, 240, 244, 1];
619
+ this.showKeyDownPreview = (_n = options.showKeyDownPreview) != null ? _n : true;
620
+ }
621
+ initialize() {
622
+ var _a, _b, _c, _d, _e, _f, _g;
623
+ const shiftArrowShape = new Shape({
624
+ path: {
625
+ // Public Domain from https://www.freesvg.org
626
+ svgString: "m288-6.6849e-14 -288 288h144v288h288v-288h144l-288-288z",
627
+ width: 24
628
+ },
629
+ lineWidth: 2,
630
+ strokeColor: WebColors.Black,
631
+ fillColor: WebColors.Transparent
632
+ });
633
+ const backspaceShape = new Shape({
634
+ path: {
635
+ // CC0 from https://www.svgrepo.com
636
+ svgString: "M10.625 5.09 0 22.09l10.625 17H44.18v-34H10.625zm31.555 32H11.734l-9.375-15 9.375-15H42.18v30zm-23.293-6.293 7.293-7.293 7.293 7.293 1.414-1.414-7.293-7.293 7.293-7.293-1.414-1.414-7.293 7.293-7.293-7.293-1.414 1.414 7.293 7.293-7.293 7.293",
637
+ width: 24
638
+ },
639
+ lineWidth: 1,
640
+ strokeColor: WebColors.Black,
641
+ fillColor: WebColors.Red
642
+ });
643
+ if (this.rowsConfiguration.length === 0) {
644
+ const numKeys = [
645
+ ["1", "!"],
646
+ ["2", "@"],
647
+ ["3", "#"],
648
+ ["4", "$"],
649
+ ["5", "%"],
650
+ ["6", "^"],
651
+ ["7", "&"],
652
+ ["8", "*"],
653
+ ["9", "("],
654
+ ["0", ")"]
655
+ ];
656
+ const row1 = [
657
+ "q",
658
+ "w",
659
+ "e",
660
+ "r",
661
+ "t",
662
+ "y",
663
+ "u",
664
+ "i",
665
+ "o",
666
+ "p"
667
+ ];
668
+ const row2 = [
669
+ "a",
670
+ "s",
671
+ "d",
672
+ "f",
673
+ "g",
674
+ "h",
675
+ "j",
676
+ "k",
677
+ "l"
678
+ ];
679
+ const row3 = [
680
+ {
681
+ code: "Shift",
682
+ isShift: true,
683
+ widthRatio: 1.5,
684
+ keyIcon: shiftArrowShape
685
+ },
686
+ "z",
687
+ "x",
688
+ "c",
689
+ "v",
690
+ "b",
691
+ "n",
692
+ "m",
693
+ { code: "Backspace", widthRatio: 1.5, keyIcon: backspaceShape }
694
+ ];
695
+ const row4 = [
696
+ { code: " ", labelText: "SPACE", widthRatio: 5 }
697
+ ];
698
+ const keyboardRows = [
699
+ numKeys,
700
+ row1,
701
+ row2,
702
+ row3,
703
+ row4
704
+ ];
705
+ this.rowsConfiguration = keyboardRows;
706
+ this.keysPerRow = this.rowsConfiguration.reduce(
707
+ (max, row) => Math.max(max, row.length),
708
+ 0
709
+ );
710
+ this.fontSize = this.size.height / this.rowsConfiguration.length / 2.5;
711
+ }
712
+ const keyboardRectangle = new Shape({
713
+ rect: { size: this.size },
714
+ fillColor: this.backgroundColor
715
+ });
716
+ this.addChild(keyboardRectangle);
717
+ const rows = this.rowsConfiguration.map((row) => {
718
+ return row.map((key) => {
719
+ var _a2, _b2, _c2, _d2;
720
+ let widthRatio = 1;
721
+ const heightRatio = 1;
722
+ let code;
723
+ let label;
724
+ let labelShifted;
725
+ let keyIcon;
726
+ let isShift = false;
727
+ if (typeof key === "string") {
728
+ code = key;
729
+ if (this.captialLettersOnly) {
730
+ label = code.toUpperCase();
731
+ } else {
732
+ label = code;
733
+ }
734
+ labelShifted = code.toUpperCase();
735
+ } else if (Array.isArray(key)) {
736
+ code = key[0];
737
+ label = code;
738
+ labelShifted = key[1];
739
+ } else {
740
+ code = key.code;
741
+ label = (_a2 = key.labelText) != null ? _a2 : "";
742
+ labelShifted = (_b2 = key.labelTextShifted) != null ? _b2 : label;
743
+ widthRatio = (_c2 = key.widthRatio) != null ? _c2 : 1;
744
+ keyIcon = key.keyIcon;
745
+ isShift = (_d2 = key.isShift) != null ? _d2 : false;
746
+ }
747
+ return {
748
+ widthRatio,
749
+ heightRatio,
750
+ code,
751
+ labelText: label,
752
+ labelTextShifted: labelShifted,
753
+ keyIcon,
754
+ isShift
755
+ };
756
+ });
757
+ });
758
+ const keyboardOrigin = {
759
+ x: -keyboardRectangle.size.width / 2,
760
+ y: -keyboardRectangle.size.height / 2
761
+ };
762
+ const keyboardVerticalPadding = ((_a = this.keyboardVerticalPaddingPercent) != null ? _a : 0.025) * this.size.height;
763
+ const keyboardHorizontalPadding = ((_b = this.keyboardHorizontalPaddingPercent) != null ? _b : 0.02) * this.size.width;
764
+ const keyboxHeight = (this.size.height - 2 * keyboardVerticalPadding) / rows.length;
765
+ const keyboxWidth = (this.size.width - 2 * keyboardHorizontalPadding) / this.keysPerRow;
766
+ for (let r = 0; r < rows.length; r++) {
767
+ const row = rows[r];
768
+ const rowSumKeyWidths = row.reduce(
769
+ (sum, key) => {
770
+ var _a2;
771
+ return sum + ((_a2 = key.widthRatio) != null ? _a2 : 1);
772
+ },
773
+ 0
774
+ );
775
+ let extraPadding = 0;
776
+ if (rowSumKeyWidths < this.keysPerRow) {
777
+ extraPadding = (this.size.width - 2 * keyboardHorizontalPadding - keyboxWidth * rowSumKeyWidths) / 2;
778
+ }
779
+ for (let k = 0; k < row.length; k++) {
780
+ const key = row[k];
781
+ if ((_c = this.hiddenKeys) == null ? void 0 : _c.split(",").map((s) => s.trim()).includes(key.code)) {
782
+ continue;
783
+ }
784
+ const keyBoxWidthsSoFar = row.slice(0, k).reduce((sum, key2) => {
785
+ var _a2;
786
+ return sum + ((_a2 = key2.widthRatio) != null ? _a2 : 1);
787
+ }, 0) * keyboxWidth;
788
+ const keyBox = new Shape({
789
+ rect: {
790
+ size: {
791
+ width: keyboxWidth * ((_d = key.widthRatio) != null ? _d : 1),
792
+ height: keyboxHeight
793
+ }
794
+ },
795
+ fillColor: WebColors.Transparent,
796
+ strokeColor: WebColors.Transparent,
797
+ lineWidth: 1,
798
+ position: {
799
+ x: extraPadding + keyboardOrigin.x + keyboardHorizontalPadding + keyBoxWidthsSoFar + ((_e = key.widthRatio) != null ? _e : 1) * keyboxWidth / 2,
800
+ y: keyboardOrigin.y + keyboardVerticalPadding + r * keyboxHeight + keyboxHeight / 2
801
+ },
802
+ isUserInteractionEnabled: true
803
+ });
804
+ const keyWidth = keyboxWidth * ((_f = key.widthRatio) != null ? _f : 1) - 2 * this.keyHorizontalPaddingPercent * keyboxWidth;
805
+ const keyHeight = keyboxHeight - ((_g = key.heightRatio) != null ? _g : 1) - 2 * this.keyVerticalPaddingPercent * keyboxHeight;
806
+ const keyShape = new Shape({
807
+ rect: { size: { width: keyWidth, height: keyHeight } },
808
+ cornerRadius: 4,
809
+ fillColor: this.keyColor,
810
+ lineWidth: 0
811
+ });
812
+ keyBox.addChild(keyShape);
813
+ keyBox.onTapUp(() => {
814
+ var _a2, _b2;
815
+ let keyAsString = "";
816
+ if (!key.isShift) {
817
+ if (this.shiftActivated) {
818
+ this.shiftActivated = false;
819
+ if (this.shiftKeyShape) {
820
+ this.shiftKeyShape.fillColor = this.keyColor;
821
+ shiftArrowShape.fillColor = WebColors.Transparent;
822
+ }
823
+ rows.flatMap((k2) => k2).forEach((k2) => {
824
+ var _a3, _b3;
825
+ if (((_a3 = k2.keyLabel) == null ? void 0 : _a3.text) !== void 0) {
826
+ k2.keyLabel.text = (_b3 = k2.labelText) != null ? _b3 : "";
827
+ }
828
+ });
829
+ keyAsString = (_a2 = key.labelTextShifted) != null ? _a2 : key.code;
830
+ } else {
831
+ keyAsString = (_b2 = key.labelText) != null ? _b2 : key.code;
832
+ }
833
+ if (key.code === " " || key.code === "Backspace") {
834
+ keyAsString = key.code;
835
+ }
836
+ keyShape.fillColor = this.keyColor;
837
+ } else {
838
+ if (!this.shiftActivated) {
839
+ keyShape.fillColor = this.keyColor;
840
+ } else {
841
+ keyShape.fillColor = this.specialKeyDownColor;
842
+ }
843
+ keyAsString = key.code;
844
+ }
845
+ letterCircle.hidden = true;
846
+ if (this.eventListeners.length > 0) {
847
+ this.eventListeners.filter(
848
+ (listener) => listener.type === EventType.CompositeCustom && listener.compositeType === "VirtualKeyboardKeyUp"
849
+ ).forEach((listener) => {
850
+ const virtualKeyboardEvent = {
851
+ type: EventType.CompositeCustom,
852
+ target: this,
853
+ handled: false,
854
+ key: keyAsString,
855
+ code: key.code,
856
+ shiftKey: this.shiftActivated
857
+ };
858
+ listener.callback(virtualKeyboardEvent);
859
+ });
860
+ }
861
+ });
862
+ keyBox.onTapDown(() => {
863
+ var _a2, _b2, _c2, _d2;
864
+ if (key.isShift) {
865
+ this.shiftActivated = !this.shiftActivated;
866
+ if (this.shiftActivated) {
867
+ keyShape.fillColor = this.specialKeyDownColor;
868
+ shiftArrowShape.fillColor = WebColors.Black;
869
+ rows.flatMap((k2) => k2).forEach((k2) => {
870
+ var _a3, _b3, _c3;
871
+ if (((_a3 = k2.keyLabel) == null ? void 0 : _a3.text) !== void 0) {
872
+ k2.keyLabel.text = (_c3 = (_b3 = k2.labelTextShifted) != null ? _b3 : k2.labelText) != null ? _c3 : "";
873
+ }
874
+ });
875
+ } else {
876
+ keyShape.fillColor = this.keyColor;
877
+ shiftArrowShape.fillColor = WebColors.Transparent;
878
+ rows.flatMap((k2) => k2).forEach((k2) => {
879
+ var _a3, _b3;
880
+ if (((_a3 = k2.keyLabel) == null ? void 0 : _a3.text) !== void 0) {
881
+ k2.keyLabel.text = (_b3 = k2.labelText) != null ? _b3 : "";
882
+ }
883
+ });
884
+ }
885
+ }
886
+ let keyAsString = "";
887
+ if (key.isShift || key.code === " " || key.code === "Backspace") {
888
+ keyShape.fillColor = this.specialKeyDownColor;
889
+ keyAsString = key.code;
890
+ } else {
891
+ keyShape.fillColor = this.keyDownColor;
892
+ if (this.showKeyDownPreview) {
893
+ letterCircle.hidden = false;
894
+ letterCircle.position.x = keyBox.position.x;
895
+ letterCircle.position.y = keyBox.position.y - keyHeight * 1.2;
896
+ if (this.shiftActivated) {
897
+ letterCircleLabel.text = (_a2 = key.labelTextShifted) != null ? _a2 : key.code;
898
+ } else {
899
+ letterCircleLabel.text = (_b2 = key.labelText) != null ? _b2 : key.code;
900
+ }
901
+ }
902
+ if (this.shiftActivated) {
903
+ keyAsString = (_c2 = key.labelTextShifted) != null ? _c2 : key.code;
904
+ } else {
905
+ keyAsString = (_d2 = key.labelText) != null ? _d2 : key.code;
906
+ }
907
+ }
908
+ if (this.eventListeners.length > 0) {
909
+ this.eventListeners.filter(
910
+ (listener) => listener.type === EventType.CompositeCustom && listener.compositeType === "VirtualKeyboardKeyDown"
911
+ ).forEach((listener) => {
912
+ const virtualKeyboardEvent = {
913
+ type: EventType.CompositeCustom,
914
+ target: this,
915
+ handled: false,
916
+ key: keyAsString,
917
+ code: key.code,
918
+ shiftKey: this.shiftActivated
919
+ };
920
+ listener.callback(virtualKeyboardEvent);
921
+ });
922
+ }
923
+ });
924
+ keyBox.onTapLeave(() => {
925
+ keyShape.fillColor = this.keyColor;
926
+ letterCircle.hidden = true;
927
+ });
928
+ const keyLabel = new Label({
929
+ text: key.labelText,
930
+ fontSize: this.fontSize
931
+ });
932
+ keyBox.addChild(keyLabel);
933
+ key.keyLabel = keyLabel;
934
+ if (key.isShift) {
935
+ this.shiftKeyShape = keyShape;
936
+ }
937
+ if (key.keyIcon) {
938
+ keyBox.addChild(key.keyIcon);
939
+ }
940
+ keyboardRectangle.addChild(keyBox);
941
+ }
942
+ }
943
+ const letterCircle = new Shape({
944
+ circleOfRadius: 28,
945
+ fillColor: WebColors.Silver,
946
+ hidden: true
947
+ });
948
+ keyboardRectangle.addChild(letterCircle);
949
+ const letterCircleLabel = new Label({
950
+ text: "",
951
+ fontSize: this.fontSize
952
+ });
953
+ letterCircle.addChild(letterCircleLabel);
954
+ this.needsInitialization = false;
955
+ }
956
+ /**
957
+ * Executes a callback when the user presses down on a key.
958
+ *
959
+ * @param callback - function to execute
960
+ * @param replaceExistingCallback - should the provided callback replace
961
+ * any existing callbacks of the same event type on this entity? Usually
962
+ * there should be only one callback defined, instead of chaining multiple
963
+ * ones. It is strongly recommended not to change this, unless you have a
964
+ * special use case. Default is true.
965
+ */
966
+ onKeyDown(callback, replaceExistingCallback = true) {
967
+ const eventListener = {
968
+ type: EventType.CompositeCustom,
969
+ compositeType: "VirtualKeyboardKeyDown",
970
+ entityUuid: this.uuid,
971
+ callback
972
+ };
973
+ this.addVirtualKeyboardEventListener(
974
+ replaceExistingCallback,
975
+ eventListener
976
+ );
977
+ }
978
+ /**
979
+ * Executes a callback when the user releases a key.
980
+ *
981
+ * @param callback - function to execute
982
+ * @param replaceExistingCallback - should the provided callback replace
983
+ * any existing callbacks of the same event type on this entity? Usually
984
+ * there should be only one callback defined, instead of chaining multiple
985
+ * ones. It is strongly recommended not to change this, unless you have a
986
+ * special use case. Default is true.
987
+ */
988
+ onKeyUp(callback, replaceExistingCallback = true) {
989
+ const eventListener = {
990
+ type: EventType.CompositeCustom,
991
+ compositeType: "VirtualKeyboardKeyUp",
992
+ entityUuid: this.uuid,
993
+ callback
994
+ };
995
+ this.addVirtualKeyboardEventListener(
996
+ replaceExistingCallback,
997
+ eventListener
998
+ );
999
+ }
1000
+ addVirtualKeyboardEventListener(replaceExistingCallback, eventListener) {
1001
+ if (replaceExistingCallback) {
1002
+ this.eventListeners = this.eventListeners.filter(
1003
+ (listener) => !(listener.entityUuid === eventListener.entityUuid && listener.type === eventListener.type && listener.compositeType === eventListener.compositeType)
1004
+ );
1005
+ }
1006
+ this.eventListeners.push(eventListener);
1007
+ }
1008
+ update() {
1009
+ super.update();
1010
+ }
1011
+ draw(canvas) {
1012
+ super.drawChildren(canvas);
1013
+ }
1014
+ warmup(canvas) {
1015
+ this.initialize();
1016
+ this.children.filter((child) => child.isDrawable).forEach((child) => {
1017
+ child.warmup(canvas);
1018
+ });
1019
+ }
1020
+ duplicate(newName) {
1021
+ throw new Error("Method not implemented.");
1022
+ }
1023
+ }
1024
+
1025
+ const SCENE_TRANSITION_EASING = Easings.sinusoidalInOut;
1026
+ const SCENE_TRANSITION_DURATION = 500;
1027
+ class Instructions extends Story {
1028
+ /**
1029
+ * Create an array of scenes containing instructions on how to complete the task
1030
+ *
1031
+ * @param options - {@link InstructionsOptions}
1032
+ * @returns
1033
+ */
1034
+ static Create(options) {
1035
+ const scenes = new Array();
1036
+ options.instructionScenes.forEach((s, i) => {
1037
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I;
1038
+ const nextSceneTransition = (_b = (_a = s.nextSceneTransition) != null ? _a : options.nextSceneTransition) != null ? _b : Transition.slide({
1039
+ direction: TransitionDirection.Left,
1040
+ duration: SCENE_TRANSITION_DURATION,
1041
+ easing: SCENE_TRANSITION_EASING
1042
+ });
1043
+ const backSceneTransition = (_d = (_c = s.backSceneTransition) != null ? _c : options.backSceneTransition) != null ? _d : Transition.slide({
1044
+ direction: TransitionDirection.Right,
1045
+ duration: SCENE_TRANSITION_DURATION,
1046
+ easing: SCENE_TRANSITION_EASING
1047
+ });
1048
+ const backButtonText = (_f = (_e = s.backButtonText) != null ? _e : options.backButtonText) != null ? _f : "Back";
1049
+ const nextButtonText = (_h = (_g = s.nextButtonText) != null ? _g : options.nextButtonText) != null ? _h : "Next";
1050
+ const backButtonWidth = (_j = (_i = s.backButtonWidth) != null ? _i : options.backButtonWidth) != null ? _j : 125;
1051
+ const nextButtonWidth = (_l = (_k = s.nextButtonWidth) != null ? _k : options.nextButtonWidth) != null ? _l : 125;
1052
+ const backButtonHeight = (_n = (_m = s.backButtonHeight) != null ? _m : options.backButtonHeight) != null ? _n : 50;
1053
+ const nextButtonHeight = (_p = (_o = s.nextButtonHeight) != null ? _o : options.nextButtonHeight) != null ? _p : 50;
1054
+ const backgroundColor = (_q = s.backgroundColor) != null ? _q : options.backgroundColor;
1055
+ const imageAboveText = (_r = s.imageAboveText) != null ? _r : true;
1056
+ const imageMarginTop = (_s = s.imageMarginTop) != null ? _s : 0;
1057
+ const imageMarginBottom = (_t = s.imageMarginBottom) != null ? _t : 0;
1058
+ const textMarginStart = (_u = s.textMarginStart) != null ? _u : 48;
1059
+ const textMarginEnd = (_v = s.textMarginEnd) != null ? _v : 48;
1060
+ const textAlignmentMode = (_w = s.textAlignmentMode) != null ? _w : LabelHorizontalAlignmentMode.Left;
1061
+ const textFontSize = (_x = s.textFontSize) != null ? _x : 16;
1062
+ const titleFontSize = (_y = s.titleFontSize) != null ? _y : 16;
1063
+ const titleMarginTop = (_z = s.titleMarginTop) != null ? _z : 48;
1064
+ const backButtonBackgroundColor = (_B = (_A = s.backButtonBackgroundColor) != null ? _A : options.backButtonBackgroundColor) != null ? _B : WebColors.Black;
1065
+ const backButtonFontColor = (_D = (_C = s.backButtonFontColor) != null ? _C : options.backButtonFontColor) != null ? _D : WebColors.White;
1066
+ const nextButtonBackgroundColor = (_F = (_E = s.nextButtonBackgroundColor) != null ? _E : options.nextButtonBackgroundColor) != null ? _F : WebColors.Black;
1067
+ const nextButtonFontColor = (_H = (_G = s.nextButtonFontColor) != null ? _G : options.nextButtonFontColor) != null ? _H : WebColors.White;
1068
+ const sceneNamePrefix = (_I = options.sceneNamePrefix) != null ? _I : "instructions";
1069
+ const scene = new Scene({
1070
+ name: sceneNamePrefix + "-" + (i + 1).toString().padStart(2, "0"),
1071
+ backgroundColor
1072
+ });
1073
+ let titleLabel;
1074
+ if (s.title !== void 0) {
1075
+ titleLabel = new Label({
1076
+ text: s.title,
1077
+ fontSize: titleFontSize,
1078
+ layout: {
1079
+ marginTop: titleMarginTop,
1080
+ constraints: {
1081
+ topToTopOf: scene,
1082
+ startToStartOf: scene,
1083
+ endToEndOf: scene
1084
+ }
1085
+ }
1086
+ });
1087
+ scene.addChild(titleLabel);
1088
+ }
1089
+ let textLabel;
1090
+ if (s.text !== void 0) {
1091
+ textLabel = new Label({
1092
+ text: s.text,
1093
+ preferredMaxLayoutWidth: Dimensions.MatchConstraint,
1094
+ horizontalAlignmentMode: textAlignmentMode,
1095
+ fontSize: textFontSize,
1096
+ layout: {
1097
+ marginStart: textMarginStart,
1098
+ marginEnd: textMarginEnd,
1099
+ constraints: {
1100
+ topToTopOf: scene,
1101
+ bottomToBottomOf: scene,
1102
+ startToStartOf: scene,
1103
+ endToEndOf: scene,
1104
+ verticalBias: s.textVerticalBias
1105
+ }
1106
+ }
1107
+ });
1108
+ scene.addChild(textLabel);
1109
+ }
1110
+ if (s.imageName !== void 0) {
1111
+ let image;
1112
+ if (textLabel !== void 0) {
1113
+ if (imageAboveText) {
1114
+ image = new Sprite({
1115
+ imageName: s.imageName,
1116
+ layout: {
1117
+ marginBottom: imageMarginBottom,
1118
+ constraints: {
1119
+ bottomToTopOf: textLabel,
1120
+ startToStartOf: scene,
1121
+ endToEndOf: scene
1122
+ }
1123
+ }
1124
+ });
1125
+ } else {
1126
+ image = new Sprite({
1127
+ imageName: s.imageName,
1128
+ layout: {
1129
+ marginTop: imageMarginTop,
1130
+ constraints: {
1131
+ topToBottomOf: textLabel,
1132
+ startToStartOf: scene,
1133
+ endToEndOf: scene
1134
+ }
1135
+ }
1136
+ });
1137
+ }
1138
+ } else {
1139
+ image = new Sprite({
1140
+ imageName: s.imageName,
1141
+ layout: {
1142
+ constraints: {
1143
+ topToTopOf: scene,
1144
+ bottomToBottomOf: scene,
1145
+ verticalBias: s.imageVerticalBias,
1146
+ startToStartOf: scene,
1147
+ endToEndOf: scene
1148
+ }
1149
+ }
1150
+ });
1151
+ }
1152
+ scene.addChild(image);
1153
+ }
1154
+ if (i > 0) {
1155
+ const backButton = new Button({
1156
+ text: backButtonText,
1157
+ fontColor: backButtonFontColor,
1158
+ backgroundColor: backButtonBackgroundColor,
1159
+ size: { width: backButtonWidth, height: backButtonHeight },
1160
+ layout: {
1161
+ marginStart: 32,
1162
+ marginBottom: 80,
1163
+ constraints: { bottomToBottomOf: scene, startToStartOf: scene }
1164
+ }
1165
+ });
1166
+ backButton.isUserInteractionEnabled = true;
1167
+ backButton.onTapDown(() => {
1168
+ scene.game.presentScene(
1169
+ sceneNamePrefix + "-" + (i + 1 - 1).toString().padStart(2, "0"),
1170
+ backSceneTransition
1171
+ );
1172
+ });
1173
+ scene.addChild(backButton);
1174
+ }
1175
+ const nextButton = new Button({
1176
+ name: "nextButton",
1177
+ text: nextButtonText,
1178
+ fontColor: nextButtonFontColor,
1179
+ backgroundColor: nextButtonBackgroundColor,
1180
+ size: { width: nextButtonWidth, height: nextButtonHeight },
1181
+ layout: {
1182
+ marginEnd: 32,
1183
+ marginBottom: 80,
1184
+ constraints: { bottomToBottomOf: scene, endToEndOf: scene }
1185
+ }
1186
+ });
1187
+ nextButton.isUserInteractionEnabled = true;
1188
+ if (i !== options.instructionScenes.length - 1) {
1189
+ nextButton.onTapDown(() => {
1190
+ scene.game.presentScene(
1191
+ sceneNamePrefix + "-" + (i + 1 + 1).toString().padStart(2, "0"),
1192
+ nextSceneTransition
1193
+ );
1194
+ });
1195
+ } else {
1196
+ if (options.postInstructionsScene !== void 0) {
1197
+ nextButton.onTapDown(() => {
1198
+ var _a2;
1199
+ scene.game.presentScene(
1200
+ (_a2 = options.postInstructionsScene) != null ? _a2 : "",
1201
+ nextSceneTransition
1202
+ );
1203
+ });
1204
+ } else {
1205
+ nextButton.onTapDown(() => {
1206
+ const sceneIndex = scene.game.scenes.indexOf(scene);
1207
+ if (sceneIndex === -1) {
1208
+ console.warn(
1209
+ "warning: postInstructionsScene is not defined, and next scene cannot be determined."
1210
+ );
1211
+ } else {
1212
+ const nextSceneIndex = sceneIndex + 1;
1213
+ if (nextSceneIndex < scene.game.scenes.length) {
1214
+ scene.game.presentScene(
1215
+ scene.game.scenes[nextSceneIndex],
1216
+ nextSceneTransition
1217
+ );
1218
+ } else {
1219
+ console.warn(
1220
+ "warning: postInstructionsScene is not defined, and there is no next scene to present."
1221
+ );
1222
+ }
1223
+ }
1224
+ });
1225
+ }
1226
+ }
1227
+ scene.addChild(nextButton);
1228
+ scenes.push(scene);
1229
+ });
1230
+ return scenes;
1231
+ }
1232
+ }
1233
+
1234
+ export { Button, Dialog, DialogResult, Grid, Instructions, VirtualKeyboard };
2
1235
  //# sourceMappingURL=index.js.map