UNPKG

canvaskit-wasm

Version:

A WASM version of Skia's Canvas API

109 lines (106 loc) 125 kB
var CanvasKitInit = (() => { var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined; if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename; return ( function(CanvasKitInit) { CanvasKitInit = CanvasKitInit || {}; null;var v;v||(v=typeof CanvasKitInit !== 'undefined' ? CanvasKitInit : {});var da,fa;v.ready=new Promise(function(a,b){da=a;fa=b}); (function(a){a.Wd=a.Wd||[];a.Wd.push(function(){a.MakeSWCanvasSurface=function(b){var c=b;if("CANVAS"!==c.tagName&&(c=document.getElementById(b),!c))throw"Canvas with id "+b+" was not found";if(b=a.MakeSurface(c.width,c.height))b.Od=c;return b};a.MakeCanvasSurface||(a.MakeCanvasSurface=a.MakeSWCanvasSurface);a.MakeSurface=function(b,c){var f={width:b,height:c,colorType:a.ColorType.RGBA_8888,alphaType:a.AlphaType.Unpremul,colorSpace:a.ColorSpace.SRGB},h=b*c*4,m=a._malloc(h);if(f=a.Surface._makeRasterDirect(f, m,4*b))f.Od=null,f.Ff=b,f.Bf=c,f.Df=h,f.af=m,f.getCanvas().clear(a.TRANSPARENT);return f};a.MakeRasterDirectSurface=function(b,c,f){return a.Surface._makeRasterDirect(b,c.byteOffset,f)};a.Surface.prototype.flush=function(b){a.Pd(this.Nd);this._flush();if(this.Od){var c=new Uint8ClampedArray(a.HEAPU8.buffer,this.af,this.Df);c=new ImageData(c,this.Ff,this.Bf);b?this.Od.getContext("2d").putImageData(c,0,0,b[0],b[1],b[2]-b[0],b[3]-b[1]):this.Od.getContext("2d").putImageData(c,0,0)}};a.Surface.prototype.dispose= function(){this.af&&a._free(this.af);this.delete()};a.Pd=a.Pd||function(){}})})(v); (function(a){a.Wd=a.Wd||[];a.Wd.push(function(){function b(n,q,x){return n&&n.hasOwnProperty(q)?n[q]:x}function c(n){var q=ha(ka);ka[q]=n;return q}function f(n){return n.naturalHeight||n.videoHeight||n.displayHeight||n.height}function h(n){return n.naturalWidth||n.videoWidth||n.displayWidth||n.width}function m(n,q,x,C){n.bindTexture(n.TEXTURE_2D,q);C||x.alphaType!==a.AlphaType.Premul||n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0);return q}function t(n,q,x){x||q.alphaType!==a.AlphaType.Premul|| n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1);n.bindTexture(n.TEXTURE_2D,null)}a.GetWebGLContext=function(n,q){if(!n)throw"null canvas passed into makeWebGLContext";var x={alpha:b(q,"alpha",1),depth:b(q,"depth",1),stencil:b(q,"stencil",8),antialias:b(q,"antialias",0),premultipliedAlpha:b(q,"premultipliedAlpha",1),preserveDrawingBuffer:b(q,"preserveDrawingBuffer",0),preferLowPowerToHighPerformance:b(q,"preferLowPowerToHighPerformance",0),failIfMajorPerformanceCaveat:b(q,"failIfMajorPerformanceCaveat", 0),enableExtensionsByDefault:b(q,"enableExtensionsByDefault",1),explicitSwapControl:b(q,"explicitSwapControl",0),renderViaOffscreenBackBuffer:b(q,"renderViaOffscreenBackBuffer",0)};x.majorVersion=q&&q.majorVersion?q.majorVersion:"undefined"!==typeof WebGL2RenderingContext?2:1;if(x.explicitSwapControl)throw"explicitSwapControl is not supported";n=la(n,x);if(!n)return 0;ma(n);return n};a.deleteContext=function(n){w===na[n]&&(w=null);"object"==typeof JSEvents&&JSEvents.Ag(na[n].ke.canvas);na[n]&&na[n].ke.canvas&& (na[n].ke.canvas.yf=void 0);na[n]=null};a._setTextureCleanup({deleteTexture:function(n,q){var x=ka[q];x&&na[n].ke.deleteTexture(x);ka[q]=null}});a.zf=function(n){if(!this.Pd(n))return null;var q=this._MakeGrContext();if(!q)return null;q.Nd=n;return q};a.MakeGrContext=a.zf;a.MakeOnScreenGLSurface=function(n,q,x,C){if(!this.Pd(n.Nd))return null;q=this._MakeOnScreenGLSurface(n,q,x,C);if(!q)return null;q.Nd=n.Nd;return q};a.MakeRenderTarget=function(){var n=arguments[0];if(!this.Pd(n.Nd))return null; if(3===arguments.length){var q=this._MakeRenderTargetWH(n,arguments[1],arguments[2]);if(!q)return null}else if(2===arguments.length){if(q=this._MakeRenderTargetII(n,arguments[1]),!q)return null}else return null;q.Nd=n.Nd;return q};a.MakeWebGLCanvasSurface=function(n,q,x){q=q||null;var C=n,H="undefined"!==typeof OffscreenCanvas&&C instanceof OffscreenCanvas;if(!("undefined"!==typeof HTMLCanvasElement&&C instanceof HTMLCanvasElement||H||(C=document.getElementById(n),C)))throw"Canvas with id "+n+" was not found"; n=this.GetWebGLContext(C,x);if(!n||0>n)throw"failed to create webgl context: err "+n;n=this.MakeGrContext(n);q=this.MakeOnScreenGLSurface(n,C.width,C.height,q);return q?q:(q=C.cloneNode(!0),C.parentNode.replaceChild(q,C),q.classList.add("ck-replaced"),a.MakeSWCanvasSurface(q))};a.MakeCanvasSurface=a.MakeWebGLCanvasSurface;a.Surface.prototype.makeImageFromTexture=function(n,q){a.Pd(this.Nd);n=c(n);if(q=this._makeImageFromTexture(this.Nd,n,q))q.Me=n;return q};a.Surface.prototype.makeImageFromTextureSource= function(n,q,x){q||(q={height:f(n),width:h(n),colorType:a.ColorType.RGBA_8888,alphaType:x?a.AlphaType.Premul:a.AlphaType.Unpremul});q.colorSpace||(q.colorSpace=a.ColorSpace.SRGB);a.Pd(this.Nd);var C=w.ke;x=m(C,C.createTexture(),q,x);2===w.version?C.texImage2D(C.TEXTURE_2D,0,C.RGBA,q.width,q.height,0,C.RGBA,C.UNSIGNED_BYTE,n):C.texImage2D(C.TEXTURE_2D,0,C.RGBA,C.RGBA,C.UNSIGNED_BYTE,n);t(C,q);return this.makeImageFromTexture(x,q)};a.Surface.prototype.updateTextureFromSource=function(n,q,x){if(n.Me){a.Pd(this.Nd); var C=n.getImageInfo(),H=w.ke,M=m(H,ka[n.Me],C,x);2===w.version?H.texImage2D(H.TEXTURE_2D,0,H.RGBA,h(q),f(q),0,H.RGBA,H.UNSIGNED_BYTE,q):H.texImage2D(H.TEXTURE_2D,0,H.RGBA,H.RGBA,H.UNSIGNED_BYTE,q);t(H,C,x);this._resetContext();ka[n.Me]=null;n.Me=c(M);C.colorSpace=n.getColorSpace();q=this._makeImageFromTexture(this.Nd,n.Me,C);x=n.Md.Ud;H=n.Md.ae;n.Md.Ud=q.Md.Ud;n.Md.ae=q.Md.ae;q.Md.Ud=x;q.Md.ae=H;q.delete();C.colorSpace.delete()}};a.MakeLazyImageFromTextureSource=function(n,q,x){q||(q={height:f(n), width:h(n),colorType:a.ColorType.RGBA_8888,alphaType:x?a.AlphaType.Premul:a.AlphaType.Unpremul});q.colorSpace||(q.colorSpace=a.ColorSpace.SRGB);var C={makeTexture:function(){var H=w,M=H.ke,A=m(M,M.createTexture(),q,x);2===H.version?M.texImage2D(M.TEXTURE_2D,0,M.RGBA,q.width,q.height,0,M.RGBA,M.UNSIGNED_BYTE,n):M.texImage2D(M.TEXTURE_2D,0,M.RGBA,M.RGBA,M.UNSIGNED_BYTE,n);t(M,q,x);return c(A)},freeSrc:function(){}};"VideoFrame"===n.constructor.name&&(C.freeSrc=function(){n.close()});return a.Image._makeFromGenerator(q, C)};a.Pd=function(n){return n?ma(n):!1}})})(v); (function(a){function b(e,d,g,l,r){for(var y=0;y<e.length;y++)d[y*g+(y*r+l+g)%g]=e[y];return d}function c(e){for(var d=e*e,g=Array(d);d--;)g[d]=0===d%(e+1)?1:0;return g}function f(e){return e?e.constructor===Float32Array&&4===e.length:!1}function h(e){return(n(255*e[3])<<24|n(255*e[0])<<16|n(255*e[1])<<8|n(255*e[2])<<0)>>>0}function m(e){if(e&&e._ck)return e;if(e instanceof Float32Array){for(var d=Math.floor(e.length/4),g=new Uint32Array(d),l=0;l<d;l++)g[l]=h(e.slice(4*l,4*(l+1)));return g}if(e instanceof Uint32Array)return e;if(e instanceof Array&&e[0]instanceof Float32Array)return e.map(h)}function t(e){if(void 0===e)return 1;var d=parseFloat(e);return e&&-1!==e.indexOf("%")?d/100:d}function n(e){return Math.round(Math.max(0,Math.min(e||0,255)))}function q(e,d){d&&d._ck||a._free(e)}function x(e,d,g){if(!e||!e.length)return V;if(e&&e._ck)return e.byteOffset;var l=a[d].BYTES_PER_ELEMENT;g||(g=a._malloc(e.length*l));a[d].set(e,g/l);return g}function C(e){var d={de:V,count:e.length,colorType:a.ColorType.RGBA_F32}; if(e instanceof Float32Array)d.de=x(e,"HEAPF32"),d.count=e.length/4;else if(e instanceof Uint32Array)d.de=x(e,"HEAPU32"),d.colorType=a.ColorType.RGBA_8888;else if(e instanceof Array){if(e&&e.length){for(var g=a._malloc(16*e.length),l=0,r=g/4,y=0;y<e.length;y++)for(var E=0;4>E;E++)a.HEAPF32[r+l]=e[y][E],l++;e=g}else e=V;d.de=e}else throw"Invalid argument to copyFlexibleColorArray, Not a color array "+typeof e;return d}function H(e){if(!e)return V;var d=Vb.toTypedArray();if(e.length){if(6===e.length|| 9===e.length)return x(e,"HEAPF32",Oa),6===e.length&&a.HEAPF32.set(zd,6+Oa/4),Oa;if(16===e.length)return d[0]=e[0],d[1]=e[1],d[2]=e[3],d[3]=e[4],d[4]=e[5],d[5]=e[7],d[6]=e[12],d[7]=e[13],d[8]=e[15],Oa;throw"invalid matrix size";}if(void 0===e.m11)throw"invalid matrix argument";d[0]=e.m11;d[1]=e.m21;d[2]=e.m41;d[3]=e.m12;d[4]=e.m22;d[5]=e.m42;d[6]=e.m14;d[7]=e.m24;d[8]=e.m44;return Oa}function M(e){if(!e)return V;var d=Wb.toTypedArray();if(e.length){if(16!==e.length&&6!==e.length&&9!==e.length)throw"invalid matrix size"; if(16===e.length)return x(e,"HEAPF32",$a);d.fill(0);d[0]=e[0];d[1]=e[1];d[3]=e[2];d[4]=e[3];d[5]=e[4];d[7]=e[5];d[10]=1;d[12]=e[6];d[13]=e[7];d[15]=e[8];6===e.length&&(d[12]=0,d[13]=0,d[15]=1);return $a}if(void 0===e.m11)throw"invalid matrix argument";d[0]=e.m11;d[1]=e.m21;d[2]=e.m31;d[3]=e.m41;d[4]=e.m12;d[5]=e.m22;d[6]=e.m32;d[7]=e.m42;d[8]=e.m13;d[9]=e.m23;d[10]=e.m33;d[11]=e.m43;d[12]=e.m14;d[13]=e.m24;d[14]=e.m34;d[15]=e.m44;return $a}function A(e,d){return x(e,"HEAPF32",d||fb)}function N(e, d,g,l){var r=Xb.toTypedArray();r[0]=e;r[1]=d;r[2]=g;r[3]=l;return fb}function S(e){for(var d=new Float32Array(4),g=0;4>g;g++)d[g]=a.HEAPF32[e/4+g];return d}function T(e,d){return x(e,"HEAPF32",d||ia)}function pa(e,d){return x(e,"HEAPF32",d||Yb)}function ta(){for(var e=0,d=0;d<arguments.length-1;d+=2)e+=arguments[d]*arguments[d+1];return e}function gb(e,d,g){for(var l=Array(e.length),r=0;r<g;r++)for(var y=0;y<g;y++){for(var E=0,K=0;K<g;K++)E+=e[g*r+K]*d[g*K+y];l[r*g+y]=E}return l}function hb(e,d){for(var g= gb(d[0],d[1],e),l=2;l<d.length;)g=gb(g,d[l],e),l++;return g}a.Color=function(e,d,g,l){void 0===l&&(l=1);return a.Color4f(n(e)/255,n(d)/255,n(g)/255,l)};a.ColorAsInt=function(e,d,g,l){void 0===l&&(l=255);return(n(l)<<24|n(e)<<16|n(d)<<8|n(g)<<0&268435455)>>>0};a.Color4f=function(e,d,g,l){void 0===l&&(l=1);return Float32Array.of(e,d,g,l)};Object.defineProperty(a,"TRANSPARENT",{get:function(){return a.Color4f(0,0,0,0)}});Object.defineProperty(a,"BLACK",{get:function(){return a.Color4f(0,0,0,1)}});Object.defineProperty(a, "WHITE",{get:function(){return a.Color4f(1,1,1,1)}});Object.defineProperty(a,"RED",{get:function(){return a.Color4f(1,0,0,1)}});Object.defineProperty(a,"GREEN",{get:function(){return a.Color4f(0,1,0,1)}});Object.defineProperty(a,"BLUE",{get:function(){return a.Color4f(0,0,1,1)}});Object.defineProperty(a,"YELLOW",{get:function(){return a.Color4f(1,1,0,1)}});Object.defineProperty(a,"CYAN",{get:function(){return a.Color4f(0,1,1,1)}});Object.defineProperty(a,"MAGENTA",{get:function(){return a.Color4f(1, 0,1,1)}});a.getColorComponents=function(e){return[Math.floor(255*e[0]),Math.floor(255*e[1]),Math.floor(255*e[2]),e[3]]};a.parseColorString=function(e,d){e=e.toLowerCase();if(e.startsWith("#")){d=255;switch(e.length){case 9:d=parseInt(e.slice(7,9),16);case 7:var g=parseInt(e.slice(1,3),16);var l=parseInt(e.slice(3,5),16);var r=parseInt(e.slice(5,7),16);break;case 5:d=17*parseInt(e.slice(4,5),16);case 4:g=17*parseInt(e.slice(1,2),16),l=17*parseInt(e.slice(2,3),16),r=17*parseInt(e.slice(3,4),16)}return a.Color(g, l,r,d/255)}return e.startsWith("rgba")?(e=e.slice(5,-1),e=e.split(","),a.Color(+e[0],+e[1],+e[2],t(e[3]))):e.startsWith("rgb")?(e=e.slice(4,-1),e=e.split(","),a.Color(+e[0],+e[1],+e[2],t(e[3]))):e.startsWith("gray(")||e.startsWith("hsl")||!d||(e=d[e],void 0===e)?a.BLACK:e};a.multiplyByAlpha=function(e,d){e=e.slice();e[3]=Math.max(0,Math.min(e[3]*d,1));return e};a.Malloc=function(e,d){var g=a._malloc(d*e.BYTES_PER_ELEMENT);return{_ck:!0,length:d,byteOffset:g,se:null,subarray:function(l,r){l=this.toTypedArray().subarray(l, r);l._ck=!0;return l},toTypedArray:function(){if(this.se&&this.se.length)return this.se;this.se=new e(a.HEAPU8.buffer,g,d);this.se._ck=!0;return this.se}}};a.Free=function(e){a._free(e.byteOffset);e.byteOffset=V;e.toTypedArray=null;e.se=null};var Oa=V,Vb,$a=V,Wb,fb=V,Xb,Ha,ia=V,Cc,Ta=V,Dc,Zb=V,Ec,$b=V,ac,xb=V,Fc,Yb=V,Gc,Hc=V,zd=Float32Array.of(0,0,1),V=0;a.onRuntimeInitialized=function(){function e(d,g,l,r,y,E){E||(E=4*r.width,r.colorType===a.ColorType.RGBA_F16?E*=2:r.colorType===a.ColorType.RGBA_F32&& (E*=4));var K=E*r.height;var O=y?y.byteOffset:a._malloc(K);if(!d._readPixels(r,O,E,g,l))return y||a._free(O),null;if(y)return y.toTypedArray();switch(r.colorType){case a.ColorType.RGBA_8888:case a.ColorType.RGBA_F16:d=(new Uint8Array(a.HEAPU8.buffer,O,K)).slice();break;case a.ColorType.RGBA_F32:d=(new Float32Array(a.HEAPU8.buffer,O,K)).slice();break;default:return null}a._free(O);return d}Xb=a.Malloc(Float32Array,4);fb=Xb.byteOffset;Wb=a.Malloc(Float32Array,16);$a=Wb.byteOffset;Vb=a.Malloc(Float32Array, 9);Oa=Vb.byteOffset;Fc=a.Malloc(Float32Array,12);Yb=Fc.byteOffset;Gc=a.Malloc(Float32Array,12);Hc=Gc.byteOffset;Ha=a.Malloc(Float32Array,4);ia=Ha.byteOffset;Cc=a.Malloc(Float32Array,4);Ta=Cc.byteOffset;Dc=a.Malloc(Float32Array,3);Zb=Dc.byteOffset;Ec=a.Malloc(Float32Array,3);$b=Ec.byteOffset;ac=a.Malloc(Int32Array,4);xb=ac.byteOffset;a.ColorSpace.SRGB=a.ColorSpace._MakeSRGB();a.ColorSpace.DISPLAY_P3=a.ColorSpace._MakeDisplayP3();a.ColorSpace.ADOBE_RGB=a.ColorSpace._MakeAdobeRGB();a.GlyphRunFlags={IsWhiteSpace:a._GlyphRunFlags_isWhiteSpace}; a.Path.MakeFromCmds=function(d){var g=x(d,"HEAPF32"),l=a.Path._MakeFromCmds(g,d.length);q(g,d);return l};a.Path.MakeFromVerbsPointsWeights=function(d,g,l){var r=x(d,"HEAPU8"),y=x(g,"HEAPF32"),E=x(l,"HEAPF32"),K=a.Path._MakeFromVerbsPointsWeights(r,d.length,y,g.length,E,l&&l.length||0);q(r,d);q(y,g);q(E,l);return K};a.Path.prototype.addArc=function(d,g,l){d=T(d);this._addArc(d,g,l);return this};a.Path.prototype.addOval=function(d,g,l){void 0===l&&(l=1);d=T(d);this._addOval(d,!!g,l);return this};a.Path.prototype.addPath= function(){var d=Array.prototype.slice.call(arguments),g=d[0],l=!1;"boolean"===typeof d[d.length-1]&&(l=d.pop());if(1===d.length)this._addPath(g,1,0,0,0,1,0,0,0,1,l);else if(2===d.length)d=d[1],this._addPath(g,d[0],d[1],d[2],d[3],d[4],d[5],d[6]||0,d[7]||0,d[8]||1,l);else if(7===d.length||10===d.length)this._addPath(g,d[1],d[2],d[3],d[4],d[5],d[6],d[7]||0,d[8]||0,d[9]||1,l);else return null;return this};a.Path.prototype.addPoly=function(d,g){var l=x(d,"HEAPF32");this._addPoly(l,d.length/2,g);q(l,d); return this};a.Path.prototype.addRect=function(d,g){d=T(d);this._addRect(d,!!g);return this};a.Path.prototype.addRRect=function(d,g){d=pa(d);this._addRRect(d,!!g);return this};a.Path.prototype.addVerbsPointsWeights=function(d,g,l){var r=x(d,"HEAPU8"),y=x(g,"HEAPF32"),E=x(l,"HEAPF32");this._addVerbsPointsWeights(r,d.length,y,g.length,E,l&&l.length||0);q(r,d);q(y,g);q(E,l)};a.Path.prototype.arc=function(d,g,l,r,y,E){d=a.LTRBRect(d-l,g-l,d+l,g+l);y=(y-r)/Math.PI*180-360*!!E;E=new a.Path;E.addArc(d,r/ Math.PI*180,y);this.addPath(E,!0);E.delete();return this};a.Path.prototype.arcToOval=function(d,g,l,r){d=T(d);this._arcToOval(d,g,l,r);return this};a.Path.prototype.arcToRotated=function(d,g,l,r,y,E,K){this._arcToRotated(d,g,l,!!r,!!y,E,K);return this};a.Path.prototype.arcToTangent=function(d,g,l,r,y){this._arcToTangent(d,g,l,r,y);return this};a.Path.prototype.close=function(){this._close();return this};a.Path.prototype.conicTo=function(d,g,l,r,y){this._conicTo(d,g,l,r,y);return this};a.Path.prototype.computeTightBounds= function(d){this._computeTightBounds(ia);var g=Ha.toTypedArray();return d?(d.set(g),d):g.slice()};a.Path.prototype.cubicTo=function(d,g,l,r,y,E){this._cubicTo(d,g,l,r,y,E);return this};a.Path.prototype.dash=function(d,g,l){return this._dash(d,g,l)?this:null};a.Path.prototype.getBounds=function(d){this._getBounds(ia);var g=Ha.toTypedArray();return d?(d.set(g),d):g.slice()};a.Path.prototype.lineTo=function(d,g){this._lineTo(d,g);return this};a.Path.prototype.moveTo=function(d,g){this._moveTo(d,g);return this}; a.Path.prototype.offset=function(d,g){this._transform(1,0,d,0,1,g,0,0,1);return this};a.Path.prototype.quadTo=function(d,g,l,r){this._quadTo(d,g,l,r);return this};a.Path.prototype.rArcTo=function(d,g,l,r,y,E,K){this._rArcTo(d,g,l,r,y,E,K);return this};a.Path.prototype.rConicTo=function(d,g,l,r,y){this._rConicTo(d,g,l,r,y);return this};a.Path.prototype.rCubicTo=function(d,g,l,r,y,E){this._rCubicTo(d,g,l,r,y,E);return this};a.Path.prototype.rLineTo=function(d,g){this._rLineTo(d,g);return this};a.Path.prototype.rMoveTo= function(d,g){this._rMoveTo(d,g);return this};a.Path.prototype.rQuadTo=function(d,g,l,r){this._rQuadTo(d,g,l,r);return this};a.Path.prototype.stroke=function(d){d=d||{};d.width=d.width||1;d.miter_limit=d.miter_limit||4;d.cap=d.cap||a.StrokeCap.Butt;d.join=d.join||a.StrokeJoin.Miter;d.precision=d.precision||1;return this._stroke(d)?this:null};a.Path.prototype.transform=function(){if(1===arguments.length){var d=arguments[0];this._transform(d[0],d[1],d[2],d[3],d[4],d[5],d[6]||0,d[7]||0,d[8]||1)}else if(6=== arguments.length||9===arguments.length)d=arguments,this._transform(d[0],d[1],d[2],d[3],d[4],d[5],d[6]||0,d[7]||0,d[8]||1);else throw"transform expected to take 1 or 9 arguments. Got "+arguments.length;return this};a.Path.prototype.trim=function(d,g,l){return this._trim(d,g,!!l)?this:null};a.Image.prototype.makeShaderCubic=function(d,g,l,r,y){y=H(y);return this._makeShaderCubic(d,g,l,r,y)};a.Image.prototype.makeShaderOptions=function(d,g,l,r,y){y=H(y);return this._makeShaderOptions(d,g,l,r,y)};a.Image.prototype.readPixels= function(d,g,l,r,y){return e(this,d,g,l,r,y)};a.Canvas.prototype.clear=function(d){a.Pd(this.Nd);d=A(d);this._clear(d)};a.Canvas.prototype.clipRRect=function(d,g,l){a.Pd(this.Nd);d=pa(d);this._clipRRect(d,g,l)};a.Canvas.prototype.clipRect=function(d,g,l){a.Pd(this.Nd);d=T(d);this._clipRect(d,g,l)};a.Canvas.prototype.concat=function(d){a.Pd(this.Nd);d=M(d);this._concat(d)};a.Canvas.prototype.drawArc=function(d,g,l,r,y){a.Pd(this.Nd);d=T(d);this._drawArc(d,g,l,r,y)};a.Canvas.prototype.drawAtlas=function(d, g,l,r,y,E,K){if(d&&r&&g&&l&&g.length===l.length){a.Pd(this.Nd);y||(y=a.BlendMode.SrcOver);var O=x(g,"HEAPF32"),Q=x(l,"HEAPF32"),W=l.length/4,u=x(m(E),"HEAPU32");if(K&&"B"in K&&"C"in K)this._drawAtlasCubic(d,Q,O,u,W,y,K.B,K.C,r);else{let I=a.FilterMode.Linear,R=a.MipmapMode.None;K&&(I=K.filter,"mipmap"in K&&(R=K.mipmap));this._drawAtlasOptions(d,Q,O,u,W,y,I,R,r)}q(O,g);q(Q,l);q(u,E)}};a.Canvas.prototype.drawCircle=function(d,g,l,r){a.Pd(this.Nd);this._drawCircle(d,g,l,r)};a.Canvas.prototype.drawColor= function(d,g){a.Pd(this.Nd);d=A(d);void 0!==g?this._drawColor(d,g):this._drawColor(d)};a.Canvas.prototype.drawColorInt=function(d,g){a.Pd(this.Nd);this._drawColorInt(d,g||a.BlendMode.SrcOver)};a.Canvas.prototype.drawColorComponents=function(d,g,l,r,y){a.Pd(this.Nd);d=N(d,g,l,r);void 0!==y?this._drawColor(d,y):this._drawColor(d)};a.Canvas.prototype.drawDRRect=function(d,g,l){a.Pd(this.Nd);d=pa(d,Yb);g=pa(g,Hc);this._drawDRRect(d,g,l)};a.Canvas.prototype.drawImage=function(d,g,l,r){a.Pd(this.Nd);this._drawImage(d, g,l,r||null)};a.Canvas.prototype.drawImageCubic=function(d,g,l,r,y,E){a.Pd(this.Nd);this._drawImageCubic(d,g,l,r,y,E||null)};a.Canvas.prototype.drawImageOptions=function(d,g,l,r,y,E){a.Pd(this.Nd);this._drawImageOptions(d,g,l,r,y,E||null)};a.Canvas.prototype.drawImageNine=function(d,g,l,r,y){a.Pd(this.Nd);g=x(g,"HEAP32",xb);l=T(l);this._drawImageNine(d,g,l,r,y||null)};a.Canvas.prototype.drawImageRect=function(d,g,l,r,y){a.Pd(this.Nd);T(g,ia);T(l,Ta);this._drawImageRect(d,ia,Ta,r,!!y)};a.Canvas.prototype.drawImageRectCubic= function(d,g,l,r,y,E){a.Pd(this.Nd);T(g,ia);T(l,Ta);this._drawImageRectCubic(d,ia,Ta,r,y,E||null)};a.Canvas.prototype.drawImageRectOptions=function(d,g,l,r,y,E){a.Pd(this.Nd);T(g,ia);T(l,Ta);this._drawImageRectOptions(d,ia,Ta,r,y,E||null)};a.Canvas.prototype.drawLine=function(d,g,l,r,y){a.Pd(this.Nd);this._drawLine(d,g,l,r,y)};a.Canvas.prototype.drawOval=function(d,g){a.Pd(this.Nd);d=T(d);this._drawOval(d,g)};a.Canvas.prototype.drawPaint=function(d){a.Pd(this.Nd);this._drawPaint(d)};a.Canvas.prototype.drawParagraph= function(d,g,l){a.Pd(this.Nd);this._drawParagraph(d,g,l)};a.Canvas.prototype.drawPatch=function(d,g,l,r,y){if(24>d.length)throw"Need 12 cubic points";if(g&&4>g.length)throw"Need 4 colors";if(l&&8>l.length)throw"Need 4 shader coordinates";a.Pd(this.Nd);const E=x(d,"HEAPF32"),K=g?x(m(g),"HEAPU32"):V,O=l?x(l,"HEAPF32"):V;r||(r=a.BlendMode.Modulate);this._drawPatch(E,K,O,r,y);q(O,l);q(K,g);q(E,d)};a.Canvas.prototype.drawPath=function(d,g){a.Pd(this.Nd);this._drawPath(d,g)};a.Canvas.prototype.drawPicture= function(d){a.Pd(this.Nd);this._drawPicture(d)};a.Canvas.prototype.drawPoints=function(d,g,l){a.Pd(this.Nd);var r=x(g,"HEAPF32");this._drawPoints(d,r,g.length/2,l);q(r,g)};a.Canvas.prototype.drawRRect=function(d,g){a.Pd(this.Nd);d=pa(d);this._drawRRect(d,g)};a.Canvas.prototype.drawRect=function(d,g){a.Pd(this.Nd);d=T(d);this._drawRect(d,g)};a.Canvas.prototype.drawRect4f=function(d,g,l,r,y){a.Pd(this.Nd);this._drawRect4f(d,g,l,r,y)};a.Canvas.prototype.drawShadow=function(d,g,l,r,y,E,K){a.Pd(this.Nd); var O=x(y,"HEAPF32"),Q=x(E,"HEAPF32");g=x(g,"HEAPF32",Zb);l=x(l,"HEAPF32",$b);this._drawShadow(d,g,l,r,O,Q,K);q(O,y);q(Q,E)};a.getShadowLocalBounds=function(d,g,l,r,y,E,K){d=H(d);l=x(l,"HEAPF32",Zb);r=x(r,"HEAPF32",$b);if(!this._getShadowLocalBounds(d,g,l,r,y,E,ia))return null;g=Ha.toTypedArray();return K?(K.set(g),K):g.slice()};a.Canvas.prototype.drawTextBlob=function(d,g,l,r){a.Pd(this.Nd);this._drawTextBlob(d,g,l,r)};a.Canvas.prototype.drawVertices=function(d,g,l){a.Pd(this.Nd);this._drawVertices(d, g,l)};a.Canvas.prototype.getDeviceClipBounds=function(d){this._getDeviceClipBounds(xb);var g=ac.toTypedArray();d?d.set(g):d=g.slice();return d};a.Canvas.prototype.getLocalToDevice=function(){this._getLocalToDevice($a);for(var d=$a,g=Array(16),l=0;16>l;l++)g[l]=a.HEAPF32[d/4+l];return g};a.Canvas.prototype.getTotalMatrix=function(){this._getTotalMatrix(Oa);for(var d=Array(9),g=0;9>g;g++)d[g]=a.HEAPF32[Oa/4+g];return d};a.Canvas.prototype.makeSurface=function(d){d=this._makeSurface(d);d.Nd=this.Nd; return d};a.Canvas.prototype.readPixels=function(d,g,l,r,y){a.Pd(this.Nd);return e(this,d,g,l,r,y)};a.Canvas.prototype.saveLayer=function(d,g,l,r){g=T(g);return this._saveLayer(d||null,g,l||null,r||0)};a.Canvas.prototype.writePixels=function(d,g,l,r,y,E,K,O){if(d.byteLength%(g*l))throw"pixels length must be a multiple of the srcWidth * srcHeight";a.Pd(this.Nd);var Q=d.byteLength/(g*l);E=E||a.AlphaType.Unpremul;K=K||a.ColorType.RGBA_8888;O=O||a.ColorSpace.SRGB;var W=Q*g;Q=x(d,"HEAPU8");g=this._writePixels({width:g, height:l,colorType:K,alphaType:E,colorSpace:O},Q,W,r,y);q(Q,d);return g};a.ColorFilter.MakeBlend=function(d,g){d=A(d);return a.ColorFilter._MakeBlend(d,g)};a.ColorFilter.MakeMatrix=function(d){if(!d||20!==d.length)throw"invalid color matrix";var g=x(d,"HEAPF32"),l=a.ColorFilter._makeMatrix(g);q(g,d);return l};a.ContourMeasure.prototype.getPosTan=function(d,g){this._getPosTan(d,ia);d=Ha.toTypedArray();return g?(g.set(d),g):d.slice()};a.ImageFilter.MakeMatrixTransform=function(d,g,l){d=H(d);if("B"in g&&"C"in g)return a.ImageFilter._MakeMatrixTransformCubic(d,g.ug,g.vg,l);const r=g.filter;let y=a.MipmapMode.None;"mipmap"in g&&(y=g.mipmap);return a.ImageFilter._MakeMatrixTransformOptions(d,r,y,l)};a.Paint.prototype.getColor=function(){this._getColor(fb);return S(fb)};a.Paint.prototype.setColor=function(d,g){g=g||null;d=A(d);this._setColor(d,g)};a.Paint.prototype.setColorComponents=function(d,g,l,r,y){y=y||null;d=N(d,g,l,r);this._setColor(d,y)};a.Path.prototype.getPoint=function(d,g){this._getPoint(d, ia);d=Ha.toTypedArray();return g?(g[0]=d[0],g[1]=d[1],g):d.slice(0,2)};a.Picture.prototype.makeShader=function(d,g,l,r,y){r=H(r);y=T(y);return this._makeShader(d,g,l,r,y)};a.PictureRecorder.prototype.beginRecording=function(d){d=T(d);return this._beginRecording(d)};a.Surface.prototype.getCanvas=function(){var d=this._getCanvas();d.Nd=this.Nd;return d};a.Surface.prototype.makeImageSnapshot=function(d){a.Pd(this.Nd);d=x(d,"HEAP32",xb);return this._makeImageSnapshot(d)};a.Surface.prototype.makeSurface= function(d){a.Pd(this.Nd);d=this._makeSurface(d);d.Nd=this.Nd;return d};a.Surface.prototype.Ef=function(d,g){this.Ie||(this.Ie=this.getCanvas());requestAnimationFrame(function(){a.Pd(this.Nd);d(this.Ie);this.flush(g)}.bind(this))};a.Surface.prototype.requestAnimationFrame||(a.Surface.prototype.requestAnimationFrame=a.Surface.prototype.Ef);a.Surface.prototype.Af=function(d,g){this.Ie||(this.Ie=this.getCanvas());requestAnimationFrame(function(){a.Pd(this.Nd);d(this.Ie);this.flush(g);this.dispose()}.bind(this))}; a.Surface.prototype.drawOnce||(a.Surface.prototype.drawOnce=a.Surface.prototype.Af);a.PathEffect.MakeDash=function(d,g){g||(g=0);if(!d.length||1===d.length%2)throw"Intervals array must have even length";var l=x(d,"HEAPF32");g=a.PathEffect._MakeDash(l,d.length,g);q(l,d);return g};a.PathEffect.MakeLine2D=function(d,g){g=H(g);return a.PathEffect._MakeLine2D(d,g)};a.PathEffect.MakePath2D=function(d,g){d=H(d);return a.PathEffect._MakePath2D(d,g)};a.Shader.MakeColor=function(d,g){g=g||null;d=A(d);return a.Shader._MakeColor(d, g)};a.Shader.Blend=a.Shader.MakeBlend;a.Shader.Color=a.Shader.MakeColor;a.Shader.MakeLinearGradient=function(d,g,l,r,y,E,K,O){O=O||null;var Q=C(l),W=x(r,"HEAPF32");K=K||0;E=H(E);var u=Ha.toTypedArray();u.set(d);u.set(g,2);d=a.Shader._MakeLinearGradient(ia,Q.de,Q.colorType,W,Q.count,y,K,E,O);q(Q.de,l);r&&q(W,r);return d};a.Shader.MakeRadialGradient=function(d,g,l,r,y,E,K,O){O=O||null;var Q=C(l),W=x(r,"HEAPF32");K=K||0;E=H(E);d=a.Shader._MakeRadialGradient(d[0],d[1],g,Q.de,Q.colorType,W,Q.count,y,K, E,O);q(Q.de,l);r&&q(W,r);return d};a.Shader.MakeSweepGradient=function(d,g,l,r,y,E,K,O,Q,W){W=W||null;var u=C(l),I=x(r,"HEAPF32");K=K||0;O=O||0;Q=Q||360;E=H(E);d=a.Shader._MakeSweepGradient(d,g,u.de,u.colorType,I,u.count,y,O,Q,K,E,W);q(u.de,l);r&&q(I,r);return d};a.Shader.MakeTwoPointConicalGradient=function(d,g,l,r,y,E,K,O,Q,W){W=W||null;var u=C(y),I=x(E,"HEAPF32");Q=Q||0;O=H(O);var R=Ha.toTypedArray();R.set(d);R.set(l,2);d=a.Shader._MakeTwoPointConicalGradient(ia,g,r,u.de,u.colorType,I,u.count, K,Q,O,W);q(u.de,y);E&&q(I,E);return d};a.Vertices.prototype.bounds=function(d){this._bounds(ia);var g=Ha.toTypedArray();return d?(d.set(g),d):g.slice()};a.Wd&&a.Wd.forEach(function(d){d()})};a.computeTonalColors=function(e){var d=x(e.ambient,"HEAPF32"),g=x(e.spot,"HEAPF32");this._computeTonalColors(d,g);var l={ambient:S(d),spot:S(g)};q(d,e.ambient);q(g,e.spot);return l};a.LTRBRect=function(e,d,g,l){return Float32Array.of(e,d,g,l)};a.XYWHRect=function(e,d,g,l){return Float32Array.of(e,d,e+g,d+l)}; a.LTRBiRect=function(e,d,g,l){return Int32Array.of(e,d,g,l)};a.XYWHiRect=function(e,d,g,l){return Int32Array.of(e,d,e+g,d+l)};a.RRectXY=function(e,d,g){return Float32Array.of(e[0],e[1],e[2],e[3],d,g,d,g,d,g,d,g)};a.MakeAnimatedImageFromEncoded=function(e){e=new Uint8Array(e);var d=a._malloc(e.byteLength);a.HEAPU8.set(e,d);return(e=a._decodeAnimatedImage(d,e.byteLength))?e:null};a.MakeImageFromEncoded=function(e){e=new Uint8Array(e);var d=a._malloc(e.byteLength);a.HEAPU8.set(e,d);return(e=a._decodeImage(d, e.byteLength))?e:null};var ib=null;a.MakeImageFromCanvasImageSource=function(e){var d=e.width,g=e.height;ib||(ib=document.createElement("canvas"));ib.width=d;ib.height=g;var l=ib.getContext("2d",{Cg:!0});l.drawImage(e,0,0);e=l.getImageData(0,0,d,g);return a.MakeImage({width:d,height:g,alphaType:a.AlphaType.Unpremul,colorType:a.ColorType.RGBA_8888,colorSpace:a.ColorSpace.SRGB},e.data,4*d)};a.MakeImage=function(e,d,g){var l=a._malloc(d.length);a.HEAPU8.set(d,l);return a._MakeImage(e,l,d.length,g)}; a.MakeVertices=function(e,d,g,l,r,y){var E=r&&r.length||0,K=0;g&&g.length&&(K|=1);l&&l.length&&(K|=2);void 0===y||y||(K|=4);e=new a._VerticesBuilder(e,d.length/2,E,K);x(d,"HEAPF32",e.positions());e.texCoords()&&x(g,"HEAPF32",e.texCoords());e.colors()&&x(m(l),"HEAPU32",e.colors());e.indices()&&x(r,"HEAPU16",e.indices());return e.detach()};a.Matrix={};a.Matrix.identity=function(){return c(3)};a.Matrix.invert=function(e){var d=e[0]*e[4]*e[8]+e[1]*e[5]*e[6]+e[2]*e[3]*e[7]-e[2]*e[4]*e[6]-e[1]*e[3]*e[8]- e[0]*e[5]*e[7];return d?[(e[4]*e[8]-e[5]*e[7])/d,(e[2]*e[7]-e[1]*e[8])/d,(e[1]*e[5]-e[2]*e[4])/d,(e[5]*e[6]-e[3]*e[8])/d,(e[0]*e[8]-e[2]*e[6])/d,(e[2]*e[3]-e[0]*e[5])/d,(e[3]*e[7]-e[4]*e[6])/d,(e[1]*e[6]-e[0]*e[7])/d,(e[0]*e[4]-e[1]*e[3])/d]:null};a.Matrix.mapPoints=function(e,d){for(var g=0;g<d.length;g+=2){var l=d[g],r=d[g+1],y=e[6]*l+e[7]*r+e[8],E=e[3]*l+e[4]*r+e[5];d[g]=(e[0]*l+e[1]*r+e[2])/y;d[g+1]=E/y}return d};a.Matrix.multiply=function(){return hb(3,arguments)};a.Matrix.rotated=function(e, d,g){d=d||0;g=g||0;var l=Math.sin(e);e=Math.cos(e);return[e,-l,ta(l,g,1-e,d),l,e,ta(-l,d,1-e,g),0,0,1]};a.Matrix.scaled=function(e,d,g,l){g=g||0;l=l||0;var r=b([e,d],c(3),3,0,1);return b([g-e*g,l-d*l],r,3,2,0)};a.Matrix.skewed=function(e,d,g,l){g=g||0;l=l||0;var r=b([e,d],c(3),3,1,-1);return b([-e*g,-d*l],r,3,2,0)};a.Matrix.translated=function(e,d){return b(arguments,c(3),3,2,0)};a.Vector={};a.Vector.dot=function(e,d){return e.map(function(g,l){return g*d[l]}).reduce(function(g,l){return g+l})};a.Vector.lengthSquared= function(e){return a.Vector.dot(e,e)};a.Vector.length=function(e){return Math.sqrt(a.Vector.lengthSquared(e))};a.Vector.mulScalar=function(e,d){return e.map(function(g){return g*d})};a.Vector.add=function(e,d){return e.map(function(g,l){return g+d[l]})};a.Vector.sub=function(e,d){return e.map(function(g,l){return g-d[l]})};a.Vector.dist=function(e,d){return a.Vector.length(a.Vector.sub(e,d))};a.Vector.normalize=function(e){return a.Vector.mulScalar(e,1/a.Vector.length(e))};a.Vector.cross=function(e, d){return[e[1]*d[2]-e[2]*d[1],e[2]*d[0]-e[0]*d[2],e[0]*d[1]-e[1]*d[0]]};a.M44={};a.M44.identity=function(){return c(4)};a.M44.translated=function(e){return b(e,c(4),4,3,0)};a.M44.scaled=function(e){return b(e,c(4),4,0,1)};a.M44.rotated=function(e,d){return a.M44.rotatedUnitSinCos(a.Vector.normalize(e),Math.sin(d),Math.cos(d))};a.M44.rotatedUnitSinCos=function(e,d,g){var l=e[0],r=e[1];e=e[2];var y=1-g;return[y*l*l+g,y*l*r-d*e,y*l*e+d*r,0,y*l*r+d*e,y*r*r+g,y*r*e-d*l,0,y*l*e-d*r,y*r*e+d*l,y*e*e+g,0, 0,0,0,1]};a.M44.lookat=function(e,d,g){d=a.Vector.normalize(a.Vector.sub(d,e));g=a.Vector.normalize(g);g=a.Vector.normalize(a.Vector.cross(d,g));var l=a.M44.identity();b(g,l,4,0,0);b(a.Vector.cross(g,d),l,4,1,0);b(a.Vector.mulScalar(d,-1),l,4,2,0);b(e,l,4,3,0);e=a.M44.invert(l);return null===e?a.M44.identity():e};a.M44.perspective=function(e,d,g){var l=1/(d-e);g/=2;g=Math.cos(g)/Math.sin(g);return[g,0,0,0,0,g,0,0,0,0,(d+e)*l,2*d*e*l,0,0,-1,1]};a.M44.rc=function(e,d,g){return e[4*d+g]};a.M44.multiply= function(){return hb(4,arguments)};a.M44.invert=function(e){var d=e[0],g=e[4],l=e[8],r=e[12],y=e[1],E=e[5],K=e[9],O=e[13],Q=e[2],W=e[6],u=e[10],I=e[14],R=e[3],aa=e[7],ja=e[11];e=e[15];var qa=d*E-g*y,ua=d*K-l*y,Aa=d*O-r*y,ea=g*K-l*E,G=g*O-r*E,k=l*O-r*K,p=Q*aa-W*R,z=Q*ja-u*R,B=Q*e-I*R,D=W*ja-u*aa,F=W*e-I*aa,L=u*e-I*ja,ba=qa*L-ua*F+Aa*D+ea*B-G*z+k*p,ca=1/ba;if(0===ba||Infinity===ca)return null;qa*=ca;ua*=ca;Aa*=ca;ea*=ca;G*=ca;k*=ca;p*=ca;z*=ca;B*=ca;D*=ca;F*=ca;L*=ca;d=[E*L-K*F+O*D,K*B-y*L-O*z,y*F- E*B+O*p,E*z-y*D-K*p,l*F-g*L-r*D,d*L-l*B+r*z,g*B-d*F-r*p,d*D-g*z+l*p,aa*k-ja*G+e*ea,ja*Aa-R*k-e*ua,R*G-aa*Aa+e*qa,aa*ua-R*ea-ja*qa,u*G-W*k-I*ea,Q*k-u*Aa+I*ua,W*Aa-Q*G-I*qa,Q*ea-W*ua+u*qa];return d.every(function(Ia){return!isNaN(Ia)&&Infinity!==Ia&&-Infinity!==Ia})?d:null};a.M44.transpose=function(e){return[e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13],e[2],e[6],e[10],e[14],e[3],e[7],e[11],e[15]]};a.M44.mustInvert=function(e){e=a.M44.invert(e);if(null===e)throw"Matrix not invertible";return e};a.M44.setupCamera= function(e,d,g){var l=a.M44.lookat(g.eye,g.coa,g.up);g=a.M44.perspective(g.near,g.far,g.angle);d=[(e[2]-e[0])/2,(e[3]-e[1])/2,d];e=a.M44.multiply(a.M44.translated([(e[0]+e[2])/2,(e[1]+e[3])/2,0]),a.M44.scaled(d));return a.M44.multiply(e,g,l,a.M44.mustInvert(e))};a.ColorMatrix={};a.ColorMatrix.identity=function(){var e=new Float32Array(20);e[0]=1;e[6]=1;e[12]=1;e[18]=1;return e};a.ColorMatrix.scaled=function(e,d,g,l){var r=new Float32Array(20);r[0]=e;r[6]=d;r[12]=g;r[18]=l;return r};var Ad=[[6,7,11, 12],[0,10,2,12],[0,1,5,6]];a.ColorMatrix.rotated=function(e,d,g){var l=a.ColorMatrix.identity();e=Ad[e];l[e[0]]=g;l[e[1]]=d;l[e[2]]=-d;l[e[3]]=g;return l};a.ColorMatrix.postTranslate=function(e,d,g,l,r){e[4]+=d;e[9]+=g;e[14]+=l;e[19]+=r;return e};a.ColorMatrix.concat=function(e,d){for(var g=new Float32Array(20),l=0,r=0;20>r;r+=5){for(var y=0;4>y;y++)g[l++]=e[r]*d[y]+e[r+1]*d[y+5]+e[r+2]*d[y+10]+e[r+3]*d[y+15];g[l++]=e[r]*d[4]+e[r+1]*d[9]+e[r+2]*d[14]+e[r+3]*d[19]+e[r+4]}return g};(function(e){e.Wd= e.Wd||[];e.Wd.push(function(){function d(u){if(!u||!u.length)return[];for(var I=[],R=0;R<u.length;R+=5){var aa=e.LTRBRect(u[R],u[R+1],u[R+2],u[R+3]);aa.direction=0===u[R+4]?e.TextDirection.RTL:e.TextDirection.LTR;I.push(aa)}e._free(u.byteOffset);return I}function g(u){u=u||{};void 0===u.weight&&(u.weight=e.FontWeight.Normal);u.width=u.width||e.FontWidth.Normal;u.slant=u.slant||e.FontSlant.Upright;return u}function l(u){if(!u||!u.length)return V;for(var I=[],R=0;R<u.length;R++){var aa=r(u[R]);I.push(aa)}return x(I, "HEAPU32")}function r(u){if(K[u])return K[u];var I=oa(u)+1,R=e._malloc(I);ra(u,J,R,I);return K[u]=R}function y(u){u._colorPtr=A(u.color);u._foregroundColorPtr=V;u._backgroundColorPtr=V;u._decorationColorPtr=V;u.foregroundColor&&(u._foregroundColorPtr=A(u.foregroundColor,O));u.backgroundColor&&(u._backgroundColorPtr=A(u.backgroundColor,Q));u.decorationColor&&(u._decorationColorPtr=A(u.decorationColor,W));Array.isArray(u.fontFamilies)&&u.fontFamilies.length?(u._fontFamiliesPtr=l(u.fontFamilies),u._fontFamiliesLen= u.fontFamilies.length):(u._fontFamiliesPtr=V,u._fontFamiliesLen=0);if(u.locale){var I=u.locale;u._localePtr=r(I);u._localeLen=oa(I)+1}else u._localePtr=V,u._localeLen=0;if(Array.isArray(u.shadows)&&u.shadows.length){I=u.shadows;var R=I.map(function(ea){return ea.color||e.BLACK}),aa=I.map(function(ea){return ea.blurRadius||0});u._shadowLen=I.length;for(var ja=e._malloc(8*I.length),qa=ja/4,ua=0;ua<I.length;ua++){var Aa=I[ua].offset||[0,0];e.HEAPF32[qa]=Aa[0];e.HEAPF32[qa+1]=Aa[1];qa+=2}u._shadowColorsPtr= C(R).de;u._shadowOffsetsPtr=ja;u._shadowBlurRadiiPtr=x(aa,"HEAPF32")}else u._shadowLen=0,u._shadowColorsPtr=V,u._shadowOffsetsPtr=V,u._shadowBlurRadiiPtr=V;Array.isArray(u.fontFeatures)&&u.fontFeatures.length?(I=u.fontFeatures,R=I.map(function(ea){return ea.name}),aa=I.map(function(ea){return ea.value}),u._fontFeatureLen=I.length,u._fontFeatureNamesPtr=l(R),u._fontFeatureValuesPtr=x(aa,"HEAPU32")):(u._fontFeatureLen=0,u._fontFeatureNamesPtr=V,u._fontFeatureValuesPtr=V)}function E(u){e._free(u._fontFamiliesPtr); e._free(u._shadowColorsPtr);e._free(u._shadowOffsetsPtr);e._free(u._shadowBlurRadiiPtr);e._free(u._fontFeatureNamesPtr);e._free(u._fontFeatureValuesPtr)}e.Paragraph.prototype.getRectsForRange=function(u,I,R,aa){u=this._getRectsForRange(u,I,R,aa);return d(u)};e.Paragraph.prototype.getRectsForPlaceholders=function(){var u=this._getRectsForPlaceholders();return d(u)};e.TypefaceFontProvider.prototype.registerFont=function(u,I){u=e.Typeface.MakeFreeTypeFaceFromData(u);if(!u)return null;I=r(I);this._registerFont(u, I)};e.ParagraphStyle=function(u){u.disableHinting=u.disableHinting||!1;if(u.ellipsis){var I=u.ellipsis;u._ellipsisPtr=r(I);u._ellipsisLen=oa(I)+1}else u._ellipsisPtr=V,u._ellipsisLen=0;u.heightMultiplier=u.heightMultiplier||0;u.maxLines=u.maxLines||0;I=(I=u.strutStyle)||{};I.strutEnabled=I.strutEnabled||!1;I.strutEnabled&&Array.isArray(I.fontFamilies)&&I.fontFamilies.length?(I._fontFamiliesPtr=l(I.fontFamilies),I._fontFamiliesLen=I.fontFamilies.length):(I._fontFamiliesPtr=V,I._fontFamiliesLen=0); I.fontStyle=g(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;u.strutStyle=I;u.textAlign=u.textAlign||e.TextAlign.Start;u.textDirection=u.textDirection||e.TextDirection.LTR;u.textHeightBehavior=u.textHeightBehavior||e.TextHeightBehavior.All;u.textStyle=e.TextStyle(u.textStyle);return u};e.TextStyle=function(u){u.color||(u.color=e.BLACK);u.decoration=u.decoration||0;u.decorationThickness= u.decorationThickness||0;u.decorationStyle=u.decorationStyle||e.DecorationStyle.Solid;u.textBaseline=u.textBaseline||e.TextBaseline.Alphabetic;u.fontSize=u.fontSize||0;u.letterSpacing=u.letterSpacing||0;u.wordSpacing=u.wordSpacing||0;u.heightMultiplier=u.heightMultiplier||0;u.halfLeading=u.halfLeading||!1;u.fontStyle=g(u.fontStyle);return u};var K={},O=e._malloc(16),Q=e._malloc(16),W=e._malloc(16);e.ParagraphBuilder.Make=function(u,I){y(u.textStyle);I=e.ParagraphBuilder._Make(u,I);E(u.textStyle); return I};e.ParagraphBuilder.MakeFromFontProvider=function(u,I){y(u.textStyle);I=e.ParagraphBuilder._MakeFromFontProvider(u,I);E(u.textStyle);return I};e.ParagraphBuilder.ShapeText=function(u,I,R){let aa=0;for(const ja of I)aa+=ja.length;if(aa!==u.length)throw"Accumulated block lengths must equal text.length";return e.ParagraphBuilder._ShapeText(u,I,R)};e.ParagraphBuilder.prototype.pushStyle=function(u){y(u);this._pushStyle(u);E(u)};e.ParagraphBuilder.prototype.pushPaintStyle=function(u,I,R){y(u); this._pushPaintStyle(u,I,R);E(u)};e.ParagraphBuilder.prototype.addPlaceholder=function(u,I,R,aa,ja){R=R||e.PlaceholderAlignment.Baseline;aa=aa||e.TextBaseline.Alphabetic;this._addPlaceholder(u||0,I||0,R,aa,ja||0)}})})(v);a.Wd=a.Wd||[];a.Wd.push(function(){a.Path.prototype.op=function(e,d){return this._op(e,d)?this:null};a.Path.prototype.simplify=function(){return this._simplify()?this:null}});a.Wd=a.Wd||[];a.Wd.push(function(){a.Canvas.prototype.drawText=function(e,d,g,l,r){var y=oa(e),E=a._malloc(y+ 1);ra(e,J,E,y+1);this._drawSimpleText(E,y,d,g,r,l);a._free(E)};a.Canvas.prototype.drawGlyphs=function(e,d,g,l,r,y){if(!(2*e.length<=d.length))throw"Not enough positions for the array of gyphs";a.Pd(this.Nd);const E=x(e,"HEAPU16"),K=x(d,"HEAPF32");this._drawGlyphs(e.length,E,K,g,l,r,y);q(K,d);q(E,e)};a.Font.prototype.getGlyphBounds=function(e,d,g){var l=x(e,"HEAPU16"),r=a._malloc(16*e.length);this._getGlyphWidthBounds(l,e.length,V,r,d||null);d=new Float32Array(a.HEAPU8.buffer,r,4*e.length);q(l,e); if(g)return g.set(d),a._free(r),g;e=Float32Array.from(d);a._free(r);return e};a.Font.prototype.getGlyphIDs=function(e,d,g){d||(d=e.length);var l=oa(e)+1,r=a._malloc(l);ra(e,J,r,l);e=a._malloc(2*d);d=this._getGlyphIDs(r,l-1,d,e);a._free(r);if(0>d)return a._free(e),null;r=new Uint16Array(a.HEAPU8.buffer,e,d);if(g)return g.set(r),a._free(e),g;g=Uint16Array.from(r);a._free(e);return g};a.Font.prototype.getGlyphIntercepts=function(e,d,g,l){var r=x(e,"HEAPU16"),y=x(d,"HEAPF32");return this._getGlyphIntercepts(r, e.length,!(e&&e._ck),y,d.length,!(d&&d._ck),g,l)};a.Font.prototype.getGlyphWidths=function(e,d,g){var l=x(e,"HEAPU16"),r=a._malloc(4*e.length);this._getGlyphWidthBounds(l,e.length,r,V,d||null);d=new Float32Array(a.HEAPU8.buffer,r,e.length);q(l,e);if(g)return g.set(d),a._free(r),g;e=Float32Array.from(d);a._free(r);return e};a.FontMgr.FromData=function(){if(!arguments.length)return null;var e=arguments;1===e.length&&Array.isArray(e[0])&&(e=arguments[0]);if(!e.length)return null;for(var d=[],g=[],l= 0;l<e.length;l++){var r=new Uint8Array(e[l]),y=x(r,"HEAPU8");d.push(y);g.push(r.byteLength)}d=x(d,"HEAPU32");g=x(g,"HEAPU32");e=a.FontMgr._fromData(d,g,e.length);a._free(d);a._free(g);return e};a.Typeface.MakeFreeTypeFaceFromData=function(e){e=new Uint8Array(e);var d=x(e,"HEAPU8");return(e=a.Typeface._MakeFreeTypeFaceFromData(d,e.byteLength))?e:null};a.Typeface.prototype.getGlyphIDs=function(e,d,g){d||(d=e.length);var l=oa(e)+1,r=a._malloc(l);ra(e,J,r,l);e=a._malloc(2*d);d=this._getGlyphIDs(r,l-1, d,e);a._free(r);if(0>d)return a._free(e),null;r=new Uint16Array(a.HEAPU8.buffer,e,d);if(g)return g.set(r),a._free(e),g;g=Uint16Array.from(r);a._free(e);return g};a.TextBlob.MakeOnPath=function(e,d,g,l){if(e&&e.length&&d&&d.countPoints()){if(1===d.countPoints())return this.MakeFromText(e,g);l||(l=0);var r=g.getGlyphIDs(e);r=g.getGlyphWidths(r);var y=[];d=new a.ContourMeasureIter(d,!1,1);for(var E=d.next(),K=new Float32Array(4),O=0;O<e.length&&E;O++){var Q=r[O];l+=Q/2;if(l>E.length()){E.delete();E= d.next();if(!E){e=e.substring(0,O);break}l=Q/2}E.getPosTan(l,K);var W=K[2],u=K[3];y.push(W,u,K[0]-Q/2*W,K[1]-Q/2*u);l+=Q/2}e=this.MakeFromRSXform(e,y,g);E&&E.delete();d.delete();return e}};a.TextBlob.MakeFromRSXform=function(e,d,g){var l=oa(e)+1,r=a._malloc(l);ra(e,J,r,l);e=x(d,"HEAPF32");g=a.TextBlob._MakeFromRSXform(r,l-1,e,g);a._free(r);return g?g:null};a.TextBlob.MakeFromRSXformGlyphs=function(e,d,g){var l=x(e,"HEAPU16");d=x(d,"HEAPF32");g=a.TextBlob._MakeFromRSXformGlyphs(l,2*e.length,d,g);q(l, e);return g?g:null};a.TextBlob.MakeFromGlyphs=function(e,d){var g=x(e,"HEAPU16");d=a.TextBlob._MakeFromGlyphs(g,2*e.length,d);q(g,e);return d?d:null};a.TextBlob.MakeFromText=function(e,d){var g=oa(e)+1,l=a._malloc(g);ra(e,J,l,g);e=a.TextBlob._MakeFromText(l,g-1,d);a._free(l);return e?e:null};a.MallocGlyphIDs=function(e){return a.Malloc(Uint16Array,e)}});a.Wd=a.Wd||[];a.Wd.push(function(){a.MakePicture=function(e){e=new Uint8Array(e);var d=a._malloc(e.byteLength);a.HEAPU8.set(e,d);return(e=a._MakePicture(d, e.byteLength))?e:null}});(function(){function e(G){for(var k=0;k<G.length;k++)if(void 0!==G[k]&&!Number.isFinite(G[k]))return!1;return!0}function d(G){var k=a.getColorComponents(G);G=k[0];var p=k[1],z=k[2];k=k[3];if(1===k)return G=G.toString(16).toLowerCase(),p=p.toString(16).toLowerCase(),z=z.toString(16).toLowerCase(),G=1===G.length?"0"+G:G,p=1===p.length?"0"+p:p,z=1===z.length?"0"+z:z,"#"+G+p+z;k=0===k||1===k?k:k.toFixed(8);return"rgba("+G+", "+p+", "+z+", "+k+")"}function g(G){return a.parseColorString(G, ua)}function l(G){G=Aa.exec(G);if(!G)return null;var k=parseFloat(G[4]),p=16;switch(G[5]){case "em":case "rem":p=16*k;break;case "pt":p=4*k/3;break;case "px":p=k;break;case "pc":p=16*k;break;case "in":p=96*k;break;case "cm":p=96*k/2.54;break;case "mm":p=96/25.4*k;break;case "q":p=96/25.4/4*k;break;case "%":p=16/75*k}return{style:G[1],variant:G[2],weight:G[3],sizePx:p,family:G[6].trim()}}function r(G){this.Od=G;this.Rd=new a.Paint;this.Rd.setAntiAlias(!0);this.Rd.setStrokeMiter(10);this.Rd.setStrokeCap(a.StrokeCap.Butt); this.Rd.setStrokeJoin(a.StrokeJoin.Miter);this.Re="10px monospace";this.oe=new a.Font(null,10);this.oe.setSubpixel(!0);this.ce=this.he=a.BLACK;this.xe=0;this.Ke=a.TRANSPARENT;this.ze=this.ye=0;this.Le=this.le=1;this.Je=0;this.we=[];this.Qd=a.BlendMode.SrcOver;this.Rd.setStrokeWidth(this.Le);this.Rd.setBlendMode(this.Qd);this.Td=new a.Path;this.Vd=a.Matrix.identity();this.mf=[];this.De=[];this.ne=function(){this.Td.delete();this.Rd.delete();this.oe.delete();this.De.forEach(function(k){k.ne()})};Object.defineProperty(this, "currentTransform",{enumerable:!0,get:function(){return{a:this.Vd[0],c:this.Vd[1],e:this.Vd[2],b:this.Vd[3],d:this.Vd[4],f:this.Vd[5]}},set:function(k){k.a&&this.setTransform(k.a,k.b,k.c,k.d,k.e,k.f)}});Object.defineProperty(this,"fillStyle",{enumerable:!0,get:function(){return f(this.ce)?d(this.ce):this.ce},set:function(k){"string"===typeof k?this.ce=g(k):k.ve&&(this.ce=k)}});Object.defineProperty(this,"font",{enumerable:!0,get:function(){return this.Re},set:function(k){var p=l(k),z=p.family;p.typeface= ea[z]?ea[z][(p.style||"normal")+"|"+(p.variant||"normal")+"|"+(p.weight||"normal")]||ea[z]["*"]:null;p&&(this.oe.setSize(p.sizePx),this.oe.setTypeface(p.typeface),this.Re=k)}});Object.defineProperty(this,"globalAlpha",{enumerable:!0,get:function(){return this.le},set:function(k){!isFinite(k)||0>k||1<k||(this.le=k)}});Object.defineProperty(this,"globalCompositeOperation",{enumerable:!0,get:function(){switch(this.Qd){case a.BlendMode.SrcOver:return"source-over";case a.BlendMode.DstOver:return"destination-over"; case a.BlendMode.Src:return"copy";case a.BlendMode.Dst:return"destination";case a.BlendMode.Clear:return"clear";case a.BlendMode.SrcIn:return"source-in";case a.BlendMode.DstIn:return"destination-in";case a.BlendMode.SrcOut:return"source-out";case a.BlendMode.DstOut:return"destination-out";case a.BlendMode.SrcATop:return"source-atop";case a.BlendMode.DstATop:return"destination-atop";case a.BlendMode.Xor:return"xor";case a.BlendMode.Plus:return"lighter";case a.BlendMode.Multiply:return"multiply";case a.BlendMode.Screen:return"screen"; case a.BlendMode.Overlay:return"overlay";case a.BlendMode.Darken:return"darken";case a.BlendMode.Lighten:return"lighten";case a.BlendMode.ColorDodge:return"color-dodge";case a.BlendMode.ColorBurn:return"color-burn";case a.BlendMode.HardLight:return"hard-light";case a.BlendMode.SoftLight:return"soft-light";case a.BlendMode.Difference:return"difference";case a.BlendMode.Exclusion:return"exclusion";case a.BlendMode.Hue:return"hue";case a.BlendMode.Saturation:return"saturation";case a.BlendMode.Color:return"color"; case a.BlendMode.Luminosity:return"luminosity"}},set:function(k){switch(k){case "source-over":this.Qd=a.BlendMode.SrcOver;break;case "destination-over":this.Qd=a.BlendMode.DstOver;break;case "copy":this.Qd=a.BlendMode.Src;break;case "destination":this.Qd=a.BlendMode.Dst;break;case "clear":this.Qd=a.BlendMode.Clear;break;case "source-in":this.Qd=a.BlendMode.SrcIn;break;case "destination-in":this.Qd=a.BlendMode.DstIn;break;case "source-out":this.Qd=a.BlendMode.SrcOut;break;case "destination-out":this.Qd= a.BlendMode.DstOut;break;case "source-atop":this.Qd=a.BlendMode.SrcATop;break;case "destination-atop":this.Qd=a.BlendMode.DstATop;break;case "xor":this.Qd=a.BlendMode.Xor;break;case "lighter":this.Qd=a.BlendMode.Plus;break;case "plus-lighter":this.Qd=a.BlendMode.Plus;break;case "plus-darker":throw"plus-darker is not supported";case "multiply":this.Qd=a.BlendMode.Multiply;break;case "screen":this.Qd=a.BlendMode.Screen;break;case "overlay":this.Qd=a.BlendMode.Overlay;break;case "darken":this.Qd=a.BlendMode.Darken; break;case "lighten":this.Qd=a.BlendMode.Lighten;break;case "color-dodge":this.Qd=a.BlendMode.ColorDodge;break;case "color-burn":this.Qd=a.BlendMode.ColorBurn;break;case "hard-light":this.Qd=a.BlendMode.HardLight;break;case "soft-light":this.Qd=a.BlendMode.SoftLight;break;case "difference":this.Qd=a.BlendMode.Difference;break;case "exclusion":this.Qd=a.BlendMode.Exclusion;break;case "hue":this.Qd=a.BlendMode.Hue;break;case "saturation":this.Qd=a.BlendMode.Saturation;break;case "color":this.Qd=a.BlendMode.Color; break;case "luminosity":this.Qd=a.BlendMode.Luminosity;break;default:return}this.Rd.setBlendMode(this.Qd)}});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 a.StrokeCap.Butt:return"butt";case a.StrokeCap.Round:return"round"; case a.StrokeCap.Square:return"square"}},set:function(k){switch(k){case "butt":this.Rd.setStrokeCap(a.StrokeCap.Butt);break;case "round":this.Rd.setStrokeCap(a.StrokeCap.Round);break;case "square":this.Rd.setStrokeCap(a.StrokeCap.Square)}}});Object.defineProperty(this,"lineDashOffset",{enumerable:!0,get:function(){return this.Je},set:function(k){isFinite(k)&&(this.Je=k)}});Object.defineProperty(this,"lineJoin",{enumerable:!0,get:function(){switch(this.Rd.getStrokeJoin()){case a.StrokeJoin.Miter:return"miter"; case a.StrokeJoin.Round:return"round";case a.StrokeJoin.Bevel:return"bevel"}},set:function(k){switch(k){case "miter":this.Rd.setStrokeJoin(a.StrokeJoin.Miter);break;case "round":this.Rd.setStrokeJoin(a.StrokeJoin.Round);break;case "bevel":this.Rd.setStrokeJoin(a.StrokeJoin.Bevel)}}});Object.defineProperty(this,"lineWidth",{enumerable:!0,get:function(){return this.Rd.getStrokeWidth()},set:function(k){0>=k||!k||(this.Le=k,this.Rd.setStrokeWidth(k))}});Object.defineProperty(this,"miterLimit",{enumerable:!0, get:function(){return this.Rd.getStrokeMiter()},set:function(k){0>=k||!k||this.Rd.setStrokeMiter(k)}});Object.defineProperty(this,"shadowBlur",{enumerable:!0,get:function(){return this.xe},set:function(k){0>k||!isFinite(k)||(this.xe=k)}});Object.defineProperty(this,"shadowColor",{enumerable:!0,get:function(){return d(this.Ke)},set:function(k){this.Ke=g(k)}});Object.defineProperty(this,"shadowOffsetX",{enumerable:!0,get:function(){return this.ye},set:function(k){isFinite(k)&&(this.ye=k)}});Object.defineProperty(this, "shadowOffsetY",{enumerable:!0,get:function(){return this.ze},set:function(k){isFinite(k)&&(this.ze=k)}});Object.defineProperty(this,"strokeStyle",{enumerable:!0,get:function(){return d(this.he)},set:function(k){"string"===typeof k?this.he=g(k):k.ve&&(this.he=k)}});this.arc=function(k,p,z,B,D,F){I(this.Td,k,p,z,z,0,B,D,F)};this.arcTo=function(k,p,z,B,D){Q(this.Td,k,p,z,B,D)};this.beginPath=function(){this.Td.delete();this.Td=new a.Path};this.bezierCurveTo=function(k,p,z,B,D,F){var L=this.Td;e([k, p,z,B,D,F])&&(L.isEmpty()&&L.moveTo(k,p),L.cubicTo(k,p,z,B,D,F))};this.clearRect=function(k,p,z,B){this.Rd.setStyle(a.PaintStyle.Fill);this.Rd.setBlendMode(a.BlendMode.Clear);this.Od.drawRect(a.XYWHRect(k,p,z,B),this.Rd);this.Rd.setBlendMode(this.Qd)};this.clip=function(k,p){"string"===typeof k?(p=k,k=this.Td):k&&k.$e&&(k=k.Xd);k||(k=this.Td);k=k.copy();p&&"evenodd"===p.toLowerCase()?k.setFillType(a.FillType.EvenOdd):k.setFillType(a.FillType.Winding);this.Od.clipPath(k,a.ClipOp.Intersect,!0);k.delete()}; this.closePath=function(){W(this.Td)};this.createImageData=function(){if(1===arguments.length){var k=arguments[0];return new K(new Uint8ClampedArray(4*k.width*k.height),k.width,k.height)}if(2===arguments.length){k=arguments[0];var p=arguments[1];return new K(new Uint8ClampedArray(4*k*p),k,p)}throw"createImageData expects 1 or 2 arguments, got "+arguments.length;};this.createLinearGradient=function(k,p,z,B){if(e(arguments)){var D=new O(k,p,z,B);this.De.push(D);return D}};this.createPattern=function(k, p){k=new ja(k,p);this.De.push(k);return k};this.createRadialGradient=function(k,p,z,B,D,F){if(e(arguments)){var L=new qa(k,p,z,B,D,F);this.De.push(L);return L}};this.drawImage=function(k){k instanceof E&&(k=k.tf());var p=this.Qe();if(3===arguments.length||5===arguments.leng