canvaskit-wasm
Version:
A WASM version of Skia's Canvas API
107 lines (105 loc) • 128 kB
JavaScript
var CanvasKitInit = (() => {
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
return (
function(moduleArg = {}) {
var w=moduleArg,ba,fa;w.ready=new Promise((a,b)=>{ba=a;fa=b});
(function(a){a.Td=a.Td||[];a.Td.push(function(){a.MakeSWCanvasSurface=function(b){var c=b,f="undefined"!==typeof OffscreenCanvas&&c instanceof OffscreenCanvas;if(!("undefined"!==typeof HTMLCanvasElement&&c instanceof HTMLCanvasElement||f||(c=document.getElementById(b),c)))throw"Canvas with id "+b+" was not found";if(b=a.MakeSurface(c.width,c.height))b.Ld=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.Ld=null,f.Hf=b,f.Df=c,f.Ff=h,f.bf=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.Md(this.Kd);this._flush();if(this.Ld){var c=new Uint8ClampedArray(a.HEAPU8.buffer,this.bf,this.Ff);c=new ImageData(c,this.Hf,this.Df);b?this.Ld.getContext("2d").putImageData(c,
0,0,b[0],b[1],b[2]-b[0],b[3]-b[1]):this.Ld.getContext("2d").putImageData(c,0,0)}};a.Surface.prototype.dispose=function(){this.bf&&a._free(this.bf);this.delete()};a.Md=a.Md||function(){};a.Te=a.Te||function(){return null}})})(w);
(function(a){a.Td=a.Td||[];a.Td.push(function(){function b(n,p,v){return n&&n.hasOwnProperty(p)?n[p]:v}function c(n){var p=ha(ia);ia[p]=n;return p}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,p,v,E){n.bindTexture(n.TEXTURE_2D,p);E||v.alphaType!==a.AlphaType.Premul||n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0);return p}function u(n,p,v){v||p.alphaType!==a.AlphaType.Premul||
n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1);n.bindTexture(n.TEXTURE_2D,null)}a.GetWebGLContext=function(n,p){if(!n)throw"null canvas passed into makeWebGLContext";var v={alpha:b(p,"alpha",1),depth:b(p,"depth",1),stencil:b(p,"stencil",8),antialias:b(p,"antialias",0),premultipliedAlpha:b(p,"premultipliedAlpha",1),preserveDrawingBuffer:b(p,"preserveDrawingBuffer",0),preferLowPowerToHighPerformance:b(p,"preferLowPowerToHighPerformance",0),failIfMajorPerformanceCaveat:b(p,"failIfMajorPerformanceCaveat",
0),enableExtensionsByDefault:b(p,"enableExtensionsByDefault",1),explicitSwapControl:b(p,"explicitSwapControl",0),renderViaOffscreenBackBuffer:b(p,"renderViaOffscreenBackBuffer",0)};v.majorVersion=p&&p.majorVersion?p.majorVersion:"undefined"!==typeof WebGL2RenderingContext?2:1;if(v.explicitSwapControl)throw"explicitSwapControl is not supported";n=la(n,v);if(!n)return 0;oa(n);A.fe.getExtension("WEBGL_debug_renderer_info");return n};a.deleteContext=function(n){A===pa[n]&&(A=null);"object"==typeof JSEvents&&
JSEvents.ug(pa[n].fe.canvas);pa[n]&&pa[n].fe.canvas&&(pa[n].fe.canvas.zf=void 0);pa[n]=null};a._setTextureCleanup({deleteTexture:function(n,p){var v=ia[p];v&&pa[n].fe.deleteTexture(v);ia[p]=null}});a.MakeWebGLContext=function(n){if(!this.Md(n))return null;var p=this._MakeGrContext();if(!p)return null;p.Kd=n;var v=p.delete.bind(p);p["delete"]=function(){a.Md(this.Kd);v()}.bind(p);return A.ff=p};a.MakeGrContext=a.MakeWebGLContext;a.GrDirectContext.prototype.getResourceCacheLimitBytes=function(){a.Md(this.Kd);
this._getResourceCacheLimitBytes()};a.GrDirectContext.prototype.getResourceCacheUsageBytes=function(){a.Md(this.Kd);this._getResourceCacheUsageBytes()};a.GrDirectContext.prototype.releaseResourcesAndAbandonContext=function(){a.Md(this.Kd);this._releaseResourcesAndAbandonContext()};a.GrDirectContext.prototype.setResourceCacheLimitBytes=function(n){a.Md(this.Kd);this._setResourceCacheLimitBytes(n)};a.MakeOnScreenGLSurface=function(n,p,v,E,H,L){if(!this.Md(n.Kd))return null;p=void 0===H||void 0===L?
this._MakeOnScreenGLSurface(n,p,v,E):this._MakeOnScreenGLSurface(n,p,v,E,H,L);if(!p)return null;p.Kd=n.Kd;return p};a.MakeRenderTarget=function(){var n=arguments[0];if(!this.Md(n.Kd))return null;if(3===arguments.length){var p=this._MakeRenderTargetWH(n,arguments[1],arguments[2]);if(!p)return null}else if(2===arguments.length){if(p=this._MakeRenderTargetII(n,arguments[1]),!p)return null}else return null;p.Kd=n.Kd;return p};a.MakeWebGLCanvasSurface=function(n,p,v){p=p||null;var E=n,H="undefined"!==
typeof OffscreenCanvas&&E instanceof OffscreenCanvas;if(!("undefined"!==typeof HTMLCanvasElement&&E instanceof HTMLCanvasElement||H||(E=document.getElementById(n),E)))throw"Canvas with id "+n+" was not found";n=this.GetWebGLContext(E,v);if(!n||0>n)throw"failed to create webgl context: err "+n;n=this.MakeWebGLContext(n);p=this.MakeOnScreenGLSurface(n,E.width,E.height,p);return p?p:(p=E.cloneNode(!0),E.parentNode.replaceChild(p,E),p.classList.add("ck-replaced"),a.MakeSWCanvasSurface(p))};a.MakeCanvasSurface=
a.MakeWebGLCanvasSurface;a.Surface.prototype.makeImageFromTexture=function(n,p){a.Md(this.Kd);n=c(n);if(p=this._makeImageFromTexture(this.Kd,n,p))p.Le=n;return p};a.Surface.prototype.makeImageFromTextureSource=function(n,p,v){p||(p={height:f(n),width:h(n),colorType:a.ColorType.RGBA_8888,alphaType:v?a.AlphaType.Premul:a.AlphaType.Unpremul});p.colorSpace||(p.colorSpace=a.ColorSpace.SRGB);a.Md(this.Kd);var E=A.fe;v=m(E,E.createTexture(),p,v);2===A.version?E.texImage2D(E.TEXTURE_2D,0,E.RGBA,p.width,p.height,
0,E.RGBA,E.UNSIGNED_BYTE,n):E.texImage2D(E.TEXTURE_2D,0,E.RGBA,E.RGBA,E.UNSIGNED_BYTE,n);u(E,p);this._resetContext();return this.makeImageFromTexture(v,p)};a.Surface.prototype.updateTextureFromSource=function(n,p,v){if(n.Le){a.Md(this.Kd);var E=n.getImageInfo(),H=A.fe,L=m(H,ia[n.Le],E,v);2===A.version?H.texImage2D(H.TEXTURE_2D,0,H.RGBA,h(p),f(p),0,H.RGBA,H.UNSIGNED_BYTE,p):H.texImage2D(H.TEXTURE_2D,0,H.RGBA,H.RGBA,H.UNSIGNED_BYTE,p);u(H,E,v);this._resetContext();ia[n.Le]=null;n.Le=c(L);E.colorSpace=
n.getColorSpace();p=this._makeImageFromTexture(this.Kd,n.Le,E);v=n.Jd.Rd;H=n.Jd.Yd;n.Jd.Rd=p.Jd.Rd;n.Jd.Yd=p.Jd.Yd;p.Jd.Rd=v;p.Jd.Yd=H;p.delete();E.colorSpace.delete()}};a.MakeLazyImageFromTextureSource=function(n,p,v){p||(p={height:f(n),width:h(n),colorType:a.ColorType.RGBA_8888,alphaType:v?a.AlphaType.Premul:a.AlphaType.Unpremul});p.colorSpace||(p.colorSpace=a.ColorSpace.SRGB);var E={makeTexture:function(){var H=A,L=H.fe,y=m(L,L.createTexture(),p,v);2===H.version?L.texImage2D(L.TEXTURE_2D,0,L.RGBA,
p.width,p.height,0,L.RGBA,L.UNSIGNED_BYTE,n):L.texImage2D(L.TEXTURE_2D,0,L.RGBA,L.RGBA,L.UNSIGNED_BYTE,n);u(L,p,v);return c(y)},freeSrc:function(){}};"VideoFrame"===n.constructor.name&&(E.freeSrc=function(){n.close()});return a.Image._makeFromGenerator(p,E)};a.Md=function(n){return n?oa(n):!1};a.Te=function(){return A&&A.ff&&!A.ff.isDeleted()?A.ff:null}})})(w);
(function(a){function b(e,d,g,l,t){for(var x=0;x<e.length;x++)d[x*g+(x*t+l+g)%g]=e[x];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 u(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 p(e,d){d&&d._ck||a._free(e)}function v(e,d,g){if(!e||!e.length)return W;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 E(e){var d={be:W,count:e.length,colorType:a.ColorType.RGBA_F32};
if(e instanceof Float32Array)d.be=v(e,"HEAPF32"),d.count=e.length/4;else if(e instanceof Uint32Array)d.be=v(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,t=g/4,x=0;x<e.length;x++)for(var C=0;4>C;C++)a.HEAPF32[t+l]=e[x][C],l++;e=g}else e=W;d.be=e}else throw"Invalid argument to copyFlexibleColorArray, Not a color array "+typeof e;return d}function H(e){if(!e)return W;var d=Vb.toTypedArray();if(e.length){if(6===e.length||
9===e.length)return v(e,"HEAPF32",Na),6===e.length&&a.HEAPF32.set(wd,6+Na/4),Na;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],Na;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 Na}function L(e){if(!e)return W;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 v(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 y(e,d){return v(e,"HEAPF32",d||Ta)}function N(e,
d,g,l){var t=Xb.toTypedArray();t[0]=e;t[1]=d;t[2]=g;t[3]=l;return Ta}function T(e){for(var d=new Float32Array(4),g=0;4>g;g++)d[g]=a.HEAPF32[e/4+g];return d}function S(e,d){return v(e,"HEAPF32",d||ja)}function sa(e,d){return v(e,"HEAPF32",d||Yb)}function ma(){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),t=0;t<g;t++)for(var x=0;x<g;x++){for(var C=0,J=0;J<g;J++)C+=e[g*t+J]*d[g*J+x];l[t*g+x]=C}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 t=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),t=17*parseInt(e.slice(3,4),16)}return a.Color(g,
l,t,d/255)}return e.startsWith("rgba")?(e=e.slice(5,-1),e=e.split(","),a.Color(+e[0],+e[1],+e[2],u(e[3]))):e.startsWith("rgb")?(e=e.slice(4,-1),e=e.split(","),a.Color(+e[0],+e[1],+e[2],u(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,qe:null,subarray:function(l,t){l=this.toTypedArray().subarray(l,
t);l._ck=!0;return l},toTypedArray:function(){if(this.qe&&this.qe.length)return this.qe;this.qe=new e(a.HEAPU8.buffer,g,d);this.qe._ck=!0;return this.qe}}};a.Free=function(e){a._free(e.byteOffset);e.byteOffset=W;e.toTypedArray=null;e.qe=null};var Na=W,Vb,$a=W,Wb,Ta=W,Xb,Ba,ja=W,xc,Oa=W,yc,Zb=W,zc,$b=W,yb,ib=W,Ac,Yb=W,Bc,Cc=W,wd=Float32Array.of(0,0,1),W=0;a.onRuntimeInitialized=function(){function e(d,g,l,t,x,C,J){C||(C=4*t.width,t.colorType===a.ColorType.RGBA_F16?C*=2:t.colorType===a.ColorType.RGBA_F32&&
(C*=4));var P=C*t.height;var O=x?x.byteOffset:a._malloc(P);if(J?!d._readPixels(t,O,C,g,l,J):!d._readPixels(t,O,C,g,l))return x||a._free(O),null;if(x)return x.toTypedArray();switch(t.colorType){case a.ColorType.RGBA_8888:case a.ColorType.RGBA_F16:d=(new Uint8Array(a.HEAPU8.buffer,O,P)).slice();break;case a.ColorType.RGBA_F32:d=(new Float32Array(a.HEAPU8.buffer,O,P)).slice();break;default:return null}a._free(O);return d}Xb=a.Malloc(Float32Array,4);Ta=Xb.byteOffset;Wb=a.Malloc(Float32Array,16);$a=Wb.byteOffset;
Vb=a.Malloc(Float32Array,9);Na=Vb.byteOffset;Ac=a.Malloc(Float32Array,12);Yb=Ac.byteOffset;Bc=a.Malloc(Float32Array,12);Cc=Bc.byteOffset;Ba=a.Malloc(Float32Array,4);ja=Ba.byteOffset;xc=a.Malloc(Float32Array,4);Oa=xc.byteOffset;yc=a.Malloc(Float32Array,3);Zb=yc.byteOffset;zc=a.Malloc(Float32Array,3);$b=zc.byteOffset;yb=a.Malloc(Int32Array,4);ib=yb.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=v(d,"HEAPF32"),l=a.Path._MakeFromCmds(g,d.length);p(g,d);return l};a.Path.MakeFromVerbsPointsWeights=function(d,g,l){var t=v(d,"HEAPU8"),x=v(g,"HEAPF32"),C=v(l,"HEAPF32"),J=a.Path._MakeFromVerbsPointsWeights(t,d.length,x,g.length,C,l&&l.length||0);p(t,d);p(x,g);p(C,l);return J};a.Path.prototype.addArc=function(d,g,l){d=S(d);this._addArc(d,g,l);return this};a.Path.prototype.addCircle=function(d,g,l,t){this._addCircle(d,
g,l,!!t);return this};a.Path.prototype.addOval=function(d,g,l){void 0===l&&(l=1);d=S(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=v(d,"HEAPF32");this._addPoly(l,d.length/2,g);p(l,d);return this};a.Path.prototype.addRect=function(d,g){d=S(d);this._addRect(d,!!g);return this};a.Path.prototype.addRRect=function(d,g){d=sa(d);this._addRRect(d,!!g);return this};a.Path.prototype.addVerbsPointsWeights=function(d,g,l){var t=v(d,"HEAPU8"),x=v(g,"HEAPF32"),C=v(l,"HEAPF32");this._addVerbsPointsWeights(t,d.length,x,g.length,C,l&&l.length||0);
p(t,d);p(x,g);p(C,l)};a.Path.prototype.arc=function(d,g,l,t,x,C){d=a.LTRBRect(d-l,g-l,d+l,g+l);x=(x-t)/Math.PI*180-360*!!C;C=new a.Path;C.addArc(d,t/Math.PI*180,x);this.addPath(C,!0);C.delete();return this};a.Path.prototype.arcToOval=function(d,g,l,t){d=S(d);this._arcToOval(d,g,l,t);return this};a.Path.prototype.arcToRotated=function(d,g,l,t,x,C,J){this._arcToRotated(d,g,l,!!t,!!x,C,J);return this};a.Path.prototype.arcToTangent=function(d,g,l,t,x){this._arcToTangent(d,g,l,t,x);return this};a.Path.prototype.close=
function(){this._close();return this};a.Path.prototype.conicTo=function(d,g,l,t,x){this._conicTo(d,g,l,t,x);return this};a.Path.prototype.computeTightBounds=function(d){this._computeTightBounds(ja);var g=Ba.toTypedArray();return d?(d.set(g),d):g.slice()};a.Path.prototype.cubicTo=function(d,g,l,t,x,C){this._cubicTo(d,g,l,t,x,C);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(ja);var g=Ba.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,t){this._quadTo(d,g,l,t);return this};a.Path.prototype.rArcTo=function(d,g,l,t,x,C,J){this._rArcTo(d,g,l,t,x,C,J);return this};a.Path.prototype.rConicTo=function(d,g,l,t,x){this._rConicTo(d,g,l,t,x);return this};a.Path.prototype.rCubicTo=
function(d,g,l,t,x,C){this._rCubicTo(d,g,l,t,x,C);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,t){this._rQuadTo(d,g,l,t);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.encodeToBytes=function(d,g){var l=
a.Te();d=d||a.ImageFormat.PNG;g=g||100;return l?this._encodeToBytes(d,g,l):this._encodeToBytes(d,g)};a.Image.prototype.makeShaderCubic=function(d,g,l,t,x){x=H(x);return this._makeShaderCubic(d,g,l,t,x)};a.Image.prototype.makeShaderOptions=function(d,g,l,t,x){x=H(x);return this._makeShaderOptions(d,g,l,t,x)};a.Image.prototype.readPixels=function(d,g,l,t,x){var C=a.Te();return e(this,d,g,l,t,x,C)};a.Canvas.prototype.clear=function(d){a.Md(this.Kd);d=y(d);this._clear(d)};a.Canvas.prototype.clipRRect=
function(d,g,l){a.Md(this.Kd);d=sa(d);this._clipRRect(d,g,l)};a.Canvas.prototype.clipRect=function(d,g,l){a.Md(this.Kd);d=S(d);this._clipRect(d,g,l)};a.Canvas.prototype.concat=function(d){a.Md(this.Kd);d=L(d);this._concat(d)};a.Canvas.prototype.drawArc=function(d,g,l,t,x){a.Md(this.Kd);d=S(d);this._drawArc(d,g,l,t,x)};a.Canvas.prototype.drawAtlas=function(d,g,l,t,x,C,J){if(d&&t&&g&&l&&g.length===l.length){a.Md(this.Kd);x||(x=a.BlendMode.SrcOver);var P=v(g,"HEAPF32"),O=v(l,"HEAPF32"),Y=l.length/4,
aa=v(m(C),"HEAPU32");if(J&&"B"in J&&"C"in J)this._drawAtlasCubic(d,O,P,aa,Y,x,J.B,J.C,t);else{let r=a.FilterMode.Linear,D=a.MipmapMode.None;J&&(r=J.filter,"mipmap"in J&&(D=J.mipmap));this._drawAtlasOptions(d,O,P,aa,Y,x,r,D,t)}p(P,g);p(O,l);p(aa,C)}};a.Canvas.prototype.drawCircle=function(d,g,l,t){a.Md(this.Kd);this._drawCircle(d,g,l,t)};a.Canvas.prototype.drawColor=function(d,g){a.Md(this.Kd);d=y(d);void 0!==g?this._drawColor(d,g):this._drawColor(d)};a.Canvas.prototype.drawColorInt=function(d,g){a.Md(this.Kd);
this._drawColorInt(d,g||a.BlendMode.SrcOver)};a.Canvas.prototype.drawColorComponents=function(d,g,l,t,x){a.Md(this.Kd);d=N(d,g,l,t);void 0!==x?this._drawColor(d,x):this._drawColor(d)};a.Canvas.prototype.drawDRRect=function(d,g,l){a.Md(this.Kd);d=sa(d,Yb);g=sa(g,Cc);this._drawDRRect(d,g,l)};a.Canvas.prototype.drawImage=function(d,g,l,t){a.Md(this.Kd);this._drawImage(d,g,l,t||null)};a.Canvas.prototype.drawImageCubic=function(d,g,l,t,x,C){a.Md(this.Kd);this._drawImageCubic(d,g,l,t,x,C||null)};a.Canvas.prototype.drawImageOptions=
function(d,g,l,t,x,C){a.Md(this.Kd);this._drawImageOptions(d,g,l,t,x,C||null)};a.Canvas.prototype.drawImageNine=function(d,g,l,t,x){a.Md(this.Kd);g=v(g,"HEAP32",ib);l=S(l);this._drawImageNine(d,g,l,t,x||null)};a.Canvas.prototype.drawImageRect=function(d,g,l,t,x){a.Md(this.Kd);S(g,ja);S(l,Oa);this._drawImageRect(d,ja,Oa,t,!!x)};a.Canvas.prototype.drawImageRectCubic=function(d,g,l,t,x,C){a.Md(this.Kd);S(g,ja);S(l,Oa);this._drawImageRectCubic(d,ja,Oa,t,x,C||null)};a.Canvas.prototype.drawImageRectOptions=
function(d,g,l,t,x,C){a.Md(this.Kd);S(g,ja);S(l,Oa);this._drawImageRectOptions(d,ja,Oa,t,x,C||null)};a.Canvas.prototype.drawLine=function(d,g,l,t,x){a.Md(this.Kd);this._drawLine(d,g,l,t,x)};a.Canvas.prototype.drawOval=function(d,g){a.Md(this.Kd);d=S(d);this._drawOval(d,g)};a.Canvas.prototype.drawPaint=function(d){a.Md(this.Kd);this._drawPaint(d)};a.Canvas.prototype.drawParagraph=function(d,g,l){a.Md(this.Kd);this._drawParagraph(d,g,l)};a.Canvas.prototype.drawPatch=function(d,g,l,t,x){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.Md(this.Kd);const C=v(d,"HEAPF32"),J=g?v(m(g),"HEAPU32"):W,P=l?v(l,"HEAPF32"):W;t||(t=a.BlendMode.Modulate);this._drawPatch(C,J,P,t,x);p(P,l);p(J,g);p(C,d)};a.Canvas.prototype.drawPath=function(d,g){a.Md(this.Kd);this._drawPath(d,g)};a.Canvas.prototype.drawPicture=function(d){a.Md(this.Kd);this._drawPicture(d)};a.Canvas.prototype.drawPoints=function(d,g,l){a.Md(this.Kd);var t=v(g,"HEAPF32");this._drawPoints(d,
t,g.length/2,l);p(t,g)};a.Canvas.prototype.drawRRect=function(d,g){a.Md(this.Kd);d=sa(d);this._drawRRect(d,g)};a.Canvas.prototype.drawRect=function(d,g){a.Md(this.Kd);d=S(d);this._drawRect(d,g)};a.Canvas.prototype.drawRect4f=function(d,g,l,t,x){a.Md(this.Kd);this._drawRect4f(d,g,l,t,x)};a.Canvas.prototype.drawShadow=function(d,g,l,t,x,C,J){a.Md(this.Kd);var P=v(x,"HEAPF32"),O=v(C,"HEAPF32");g=v(g,"HEAPF32",Zb);l=v(l,"HEAPF32",$b);this._drawShadow(d,g,l,t,P,O,J);p(P,x);p(O,C)};a.getShadowLocalBounds=
function(d,g,l,t,x,C,J){d=H(d);l=v(l,"HEAPF32",Zb);t=v(t,"HEAPF32",$b);if(!this._getShadowLocalBounds(d,g,l,t,x,C,ja))return null;g=Ba.toTypedArray();return J?(J.set(g),J):g.slice()};a.Canvas.prototype.drawTextBlob=function(d,g,l,t){a.Md(this.Kd);this._drawTextBlob(d,g,l,t)};a.Canvas.prototype.drawVertices=function(d,g,l){a.Md(this.Kd);this._drawVertices(d,g,l)};a.Canvas.prototype.getDeviceClipBounds=function(d){this._getDeviceClipBounds(ib);var g=yb.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(Na);for(var d=Array(9),g=0;9>g;g++)d[g]=a.HEAPF32[Na/4+g];return d};a.Canvas.prototype.makeSurface=function(d){d=this._makeSurface(d);d.Kd=this.Kd;return d};a.Canvas.prototype.readPixels=function(d,g,l,t,x){a.Md(this.Kd);return e(this,d,g,l,t,x)};a.Canvas.prototype.saveLayer=function(d,g,l,
t){g=S(g);return this._saveLayer(d||null,g,l||null,t||0)};a.Canvas.prototype.writePixels=function(d,g,l,t,x,C,J,P){if(d.byteLength%(g*l))throw"pixels length must be a multiple of the srcWidth * srcHeight";a.Md(this.Kd);var O=d.byteLength/(g*l);C=C||a.AlphaType.Unpremul;J=J||a.ColorType.RGBA_8888;P=P||a.ColorSpace.SRGB;var Y=O*g;O=v(d,"HEAPU8");g=this._writePixels({width:g,height:l,colorType:J,alphaType:C,colorSpace:P},O,Y,t,x);p(O,d);return g};a.ColorFilter.MakeBlend=function(d,g,l){d=y(d);l=l||a.ColorSpace.SRGB;
return a.ColorFilter._MakeBlend(d,g,l)};a.ColorFilter.MakeMatrix=function(d){if(!d||20!==d.length)throw"invalid color matrix";var g=v(d,"HEAPF32"),l=a.ColorFilter._makeMatrix(g);p(g,d);return l};a.ContourMeasure.prototype.getPosTan=function(d,g){this._getPosTan(d,ja);d=Ba.toTypedArray();return g?(g.set(d),g):d.slice()};a.ImageFilter.prototype.getOutputBounds=function(d,g,l){d=S(d,ja);g=H(g);this._getOutputBounds(d,g,ib);g=yb.toTypedArray();return l?(l.set(g),l):g.slice()};a.ImageFilter.MakeDropShadow=
function(d,g,l,t,x,C){x=y(x,Ta);return a.ImageFilter._MakeDropShadow(d,g,l,t,x,C)};a.ImageFilter.MakeDropShadowOnly=function(d,g,l,t,x,C){x=y(x,Ta);return a.ImageFilter._MakeDropShadowOnly(d,g,l,t,x,C)};a.ImageFilter.MakeImage=function(d,g,l,t){l=S(l,ja);t=S(t,Oa);if("B"in g&&"C"in g)return a.ImageFilter._MakeImageCubic(d,g.B,g.C,l,t);const x=g.filter;let C=a.MipmapMode.None;"mipmap"in g&&(C=g.mipmap);return a.ImageFilter._MakeImageOptions(d,x,C,l,t)};a.ImageFilter.MakeMatrixTransform=function(d,
g,l){d=H(d);if("B"in g&&"C"in g)return a.ImageFilter._MakeMatrixTransformCubic(d,g.B,g.C,l);const t=g.filter;let x=a.MipmapMode.None;"mipmap"in g&&(x=g.mipmap);return a.ImageFilter._MakeMatrixTransformOptions(d,t,x,l)};a.Paint.prototype.getColor=function(){this._getColor(Ta);return T(Ta)};a.Paint.prototype.setColor=function(d,g){g=g||null;d=y(d);this._setColor(d,g)};a.Paint.prototype.setColorComponents=function(d,g,l,t,x){x=x||null;d=N(d,g,l,t);this._setColor(d,x)};a.Path.prototype.getPoint=function(d,
g){this._getPoint(d,ja);d=Ba.toTypedArray();return g?(g[0]=d[0],g[1]=d[1],g):d.slice(0,2)};a.Picture.prototype.makeShader=function(d,g,l,t,x){t=H(t);x=S(x);return this._makeShader(d,g,l,t,x)};a.Picture.prototype.cullRect=function(d){this._cullRect(ja);var g=Ba.toTypedArray();return d?(d.set(g),d):g.slice()};a.PictureRecorder.prototype.beginRecording=function(d,g){d=S(d);return this._beginRecording(d,!!g)};a.Surface.prototype.getCanvas=function(){var d=this._getCanvas();d.Kd=this.Kd;return d};a.Surface.prototype.makeImageSnapshot=
function(d){a.Md(this.Kd);d=v(d,"HEAP32",ib);return this._makeImageSnapshot(d)};a.Surface.prototype.makeSurface=function(d){a.Md(this.Kd);d=this._makeSurface(d);d.Kd=this.Kd;return d};a.Surface.prototype.Gf=function(d,g){this.He||(this.He=this.getCanvas());return requestAnimationFrame(function(){a.Md(this.Kd);d(this.He);this.flush(g)}.bind(this))};a.Surface.prototype.requestAnimationFrame||(a.Surface.prototype.requestAnimationFrame=a.Surface.prototype.Gf);a.Surface.prototype.Cf=function(d,g){this.He||
(this.He=this.getCanvas());requestAnimationFrame(function(){a.Md(this.Kd);d(this.He);this.flush(g);this.dispose()}.bind(this))};a.Surface.prototype.drawOnce||(a.Surface.prototype.drawOnce=a.Surface.prototype.Cf);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=v(d,"HEAPF32");g=a.PathEffect._MakeDash(l,d.length,g);p(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=y(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,t,x,C,J,P){P=P||null;var O=E(l),Y=v(t,"HEAPF32");J=J||0;C=H(C);var aa=Ba.toTypedArray();aa.set(d);aa.set(g,2);d=a.Shader._MakeLinearGradient(ja,O.be,O.colorType,Y,O.count,x,J,C,P);p(O.be,l);t&&p(Y,t);return d};a.Shader.MakeRadialGradient=function(d,
g,l,t,x,C,J,P){P=P||null;var O=E(l),Y=v(t,"HEAPF32");J=J||0;C=H(C);d=a.Shader._MakeRadialGradient(d[0],d[1],g,O.be,O.colorType,Y,O.count,x,J,C,P);p(O.be,l);t&&p(Y,t);return d};a.Shader.MakeSweepGradient=function(d,g,l,t,x,C,J,P,O,Y){Y=Y||null;var aa=E(l),r=v(t,"HEAPF32");J=J||0;P=P||0;O=O||360;C=H(C);d=a.Shader._MakeSweepGradient(d,g,aa.be,aa.colorType,r,aa.count,x,P,O,J,C,Y);p(aa.be,l);t&&p(r,t);return d};a.Shader.MakeTwoPointConicalGradient=function(d,g,l,t,x,C,J,P,O,Y){Y=Y||null;var aa=E(x),r=
v(C,"HEAPF32");O=O||0;P=H(P);var D=Ba.toTypedArray();D.set(d);D.set(l,2);d=a.Shader._MakeTwoPointConicalGradient(ja,g,t,aa.be,aa.colorType,r,aa.count,J,O,P,Y);p(aa.be,x);C&&p(r,C);return d};a.Vertices.prototype.bounds=function(d){this._bounds(ja);var g=Ba.toTypedArray();return d?(d.set(g),d):g.slice()};a.Td&&a.Td.forEach(function(d){d()})};a.computeTonalColors=function(e){var d=v(e.ambient,"HEAPF32"),g=v(e.spot,"HEAPF32");this._computeTonalColors(d,g);var l={ambient:T(d),spot:T(g)};p(d,e.ambient);
p(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 jb=null;a.MakeImageFromCanvasImageSource=function(e){var d=e.width,g=e.height;jb||(jb=document.createElement("canvas"));jb.width=d;jb.height=g;var l=jb.getContext("2d",{willReadFrequently:!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,t,x){var C=t&&t.length||0,J=0;g&&g.length&&(J|=1);l&&l.length&&(J|=2);void 0===x||x||(J|=4);e=new a._VerticesBuilder(e,d.length/2,C,J);v(d,"HEAPF32",e.positions());e.texCoords()&&v(g,"HEAPF32",e.texCoords());e.colors()&&v(m(l),"HEAPU32",e.colors());e.indices()&&v(t,"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],t=d[g+1],x=e[6]*l+e[7]*t+e[8],
C=e[3]*l+e[4]*t+e[5];d[g]=(e[0]*l+e[1]*t+e[2])/x;d[g+1]=C/x}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,ma(l,g,1-e,d),l,e,ma(-l,d,1-e,g),0,0,1]};a.Matrix.scaled=function(e,d,g,l){g=g||0;l=l||0;var t=b([e,d],c(3),3,0,1);return b([g-e*g,l-d*l],t,3,2,0)};a.Matrix.skewed=function(e,d,g,l){g=g||0;l=l||0;var t=b([e,d],c(3),3,1,-1);return b([-e*g,-d*l],t,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],t=e[1];e=e[2];var x=1-g;return[x*l*l+g,x*l*t-d*e,x*l*e+d*t,0,x*l*t+d*e,x*t*t+g,x*t*e-d*l,0,x*l*e-d*t,x*t*e+d*l,x*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],t=e[12],x=e[1],C=e[5],J=e[9],P=e[13],O=e[2],Y=e[6],aa=e[10],r=e[14],D=e[3],U=e[7],ca=e[11];e=e[15];var ka=d*C-g*x,va=d*J-l*x,wa=d*P-t*x,na=g*J-l*C,G=g*P-t*C,k=l*P-t*J,q=O*U-Y*D,z=O*ca-aa*D,B=O*e-r*D,F=Y*ca-aa*U,I=Y*e-r*U,M=aa*e-r*ca,da=ka*M-va*I+wa*F+na*B-G*z+k*q,ea=
1/da;if(0===da||Infinity===ea)return null;ka*=ea;va*=ea;wa*=ea;na*=ea;G*=ea;k*=ea;q*=ea;z*=ea;B*=ea;F*=ea;I*=ea;M*=ea;d=[C*M-J*I+P*F,J*B-x*M-P*z,x*I-C*B+P*q,C*z-x*F-J*q,l*I-g*M-t*F,d*M-l*B+t*z,g*B-d*I-t*q,d*F-g*z+l*q,U*k-ca*G+e*na,ca*wa-D*k-e*va,D*G-U*wa+e*ka,U*va-D*na-ca*ka,aa*G-Y*k-r*na,O*k-aa*wa+r*va,Y*wa-O*G-r*ka,O*na-Y*va+aa*ka];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 t=new Float32Array(20);t[0]=e;t[6]=d;t[12]=g;t[18]=l;return t};var xd=[[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=xd[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,t){e[4]+=d;e[9]+=g;e[14]+=l;e[19]+=t;return e};a.ColorMatrix.concat=function(e,d){for(var g=new Float32Array(20),l=0,t=0;20>t;t+=5){for(var x=0;4>
x;x++)g[l++]=e[t]*d[x]+e[t+1]*d[x+5]+e[t+2]*d[x+10]+e[t+3]*d[x+15];g[l++]=e[t]*d[4]+e[t+1]*d[9]+e[t+2]*d[14]+e[t+3]*d[19]+e[t+4]}return g};(function(e){e.Td=e.Td||[];e.Td.push(function(){function d(r){r&&(r.dir=0===r.dir?e.TextDirection.RTL:e.TextDirection.LTR);return r}function g(r){if(!r||!r.length)return[];for(var D=[],U=0;U<r.length;U+=5){var ca=e.LTRBRect(r[U],r[U+1],r[U+2],r[U+3]),ka=e.TextDirection.LTR;0===r[U+4]&&(ka=e.TextDirection.RTL);D.push({rect:ca,dir:ka})}e._free(r.byteOffset);return D}
function l(r){r=r||{};void 0===r.weight&&(r.weight=e.FontWeight.Normal);r.width=r.width||e.FontWidth.Normal;r.slant=r.slant||e.FontSlant.Upright;return r}function t(r){if(!r||!r.length)return W;for(var D=[],U=0;U<r.length;U++){var ca=x(r[U]);D.push(ca)}return v(D,"HEAPU32")}function x(r){if(P[r])return P[r];var D=qa(r)+1,U=e._malloc(D);ra(r,K,U,D);return P[r]=U}function C(r){r._colorPtr=y(r.color);r._foregroundColorPtr=W;r._backgroundColorPtr=W;r._decorationColorPtr=W;r.foregroundColor&&(r._foregroundColorPtr=
y(r.foregroundColor,O));r.backgroundColor&&(r._backgroundColorPtr=y(r.backgroundColor,Y));r.decorationColor&&(r._decorationColorPtr=y(r.decorationColor,aa));Array.isArray(r.fontFamilies)&&r.fontFamilies.length?(r._fontFamiliesPtr=t(r.fontFamilies),r._fontFamiliesLen=r.fontFamilies.length):(r._fontFamiliesPtr=W,r._fontFamiliesLen=0);if(r.locale){var D=r.locale;r._localePtr=x(D);r._localeLen=qa(D)+1}else r._localePtr=W,r._localeLen=0;if(Array.isArray(r.shadows)&&r.shadows.length){D=r.shadows;var U=
D.map(function(G){return G.color||e.BLACK}),ca=D.map(function(G){return G.blurRadius||0});r._shadowLen=D.length;for(var ka=e._malloc(8*D.length),va=ka/4,wa=0;wa<D.length;wa++){var na=D[wa].offset||[0,0];e.HEAPF32[va]=na[0];e.HEAPF32[va+1]=na[1];va+=2}r._shadowColorsPtr=E(U).be;r._shadowOffsetsPtr=ka;r._shadowBlurRadiiPtr=v(ca,"HEAPF32")}else r._shadowLen=0,r._shadowColorsPtr=W,r._shadowOffsetsPtr=W,r._shadowBlurRadiiPtr=W;Array.isArray(r.fontFeatures)&&r.fontFeatures.length?(D=r.fontFeatures,U=D.map(function(G){return G.name}),
ca=D.map(function(G){return G.value}),r._fontFeatureLen=D.length,r._fontFeatureNamesPtr=t(U),r._fontFeatureValuesPtr=v(ca,"HEAPU32")):(r._fontFeatureLen=0,r._fontFeatureNamesPtr=W,r._fontFeatureValuesPtr=W);Array.isArray(r.fontVariations)&&r.fontVariations.length?(D=r.fontVariations,U=D.map(function(G){return G.axis}),ca=D.map(function(G){return G.value}),r._fontVariationLen=D.length,r._fontVariationAxesPtr=t(U),r._fontVariationValuesPtr=v(ca,"HEAPF32")):(r._fontVariationLen=0,r._fontVariationAxesPtr=
W,r._fontVariationValuesPtr=W)}function J(r){e._free(r._fontFamiliesPtr);e._free(r._shadowColorsPtr);e._free(r._shadowOffsetsPtr);e._free(r._shadowBlurRadiiPtr);e._free(r._fontFeatureNamesPtr);e._free(r._fontFeatureValuesPtr);e._free(r._fontVariationAxesPtr);e._free(r._fontVariationValuesPtr)}e.Paragraph.prototype.getRectsForRange=function(r,D,U,ca){r=this._getRectsForRange(r,D,U,ca);return g(r)};e.Paragraph.prototype.getRectsForPlaceholders=function(){var r=this._getRectsForPlaceholders();return g(r)};
e.Paragraph.prototype.getGlyphInfoAt=function(r){return d(this._getGlyphInfoAt(r))};e.Paragraph.prototype.getClosestGlyphInfoAtCoordinate=function(r,D){return d(this._getClosestGlyphInfoAtCoordinate(r,D))};e.TypefaceFontProvider.prototype.registerFont=function(r,D){r=e.Typeface.MakeFreeTypeFaceFromData(r);if(!r)return null;D=x(D);this._registerFont(r,D)};e.ParagraphStyle=function(r){r.disableHinting=r.disableHinting||!1;if(r.ellipsis){var D=r.ellipsis;r._ellipsisPtr=x(D);r._ellipsisLen=qa(D)+1}else r._ellipsisPtr=
W,r._ellipsisLen=0;null==r.heightMultiplier&&(r.heightMultiplier=-1);r.maxLines=r.maxLines||0;r.replaceTabCharacters=r.replaceTabCharacters||!1;D=(D=r.strutStyle)||{};D.strutEnabled=D.strutEnabled||!1;D.strutEnabled&&Array.isArray(D.fontFamilies)&&D.fontFamilies.length?(D._fontFamiliesPtr=t(D.fontFamilies),D._fontFamiliesLen=D.fontFamilies.length):(D._fontFamiliesPtr=W,D._fontFamiliesLen=0);D.fontStyle=l(D.fontStyle);null==D.fontSize&&(D.fontSize=-1);null==D.heightMultiplier&&(D.heightMultiplier=
-1);D.halfLeading=D.halfLeading||!1;D.leading=D.leading||0;D.forceStrutHeight=D.forceStrutHeight||!1;r.strutStyle=D;r.textAlign=r.textAlign||e.TextAlign.Start;r.textDirection=r.textDirection||e.TextDirection.LTR;r.textHeightBehavior=r.textHeightBehavior||e.TextHeightBehavior.All;r.textStyle=e.TextStyle(r.textStyle);r.applyRoundingHack=!1!==r.applyRoundingHack;return r};e.TextStyle=function(r){r.color||(r.color=e.BLACK);r.decoration=r.decoration||0;r.decorationThickness=r.decorationThickness||0;r.decorationStyle=
r.decorationStyle||e.DecorationStyle.Solid;r.textBaseline=r.textBaseline||e.TextBaseline.Alphabetic;null==r.fontSize&&(r.fontSize=-1);r.letterSpacing=r.letterSpacing||0;r.wordSpacing=r.wordSpacing||0;null==r.heightMultiplier&&(r.heightMultiplier=-1);r.halfLeading=r.halfLeading||!1;r.fontStyle=l(r.fontStyle);return r};var P={},O=e._malloc(16),Y=e._malloc(16),aa=e._malloc(16);e.ParagraphBuilder.Make=function(r,D){C(r.textStyle);D=e.ParagraphBuilder._Make(r,D);J(r.textStyle);return D};e.ParagraphBuilder.MakeFromFontProvider=
function(r,D){C(r.textStyle);D=e.ParagraphBuilder._MakeFromFontProvider(r,D);J(r.textStyle);return D};e.ParagraphBuilder.MakeFromFontCollection=function(r,D){C(r.textStyle);D=e.ParagraphBuilder._MakeFromFontCollection(r,D);J(r.textStyle);return D};e.ParagraphBuilder.ShapeText=function(r,D,U){let ca=0;for(const ka of D)ca+=ka.length;if(ca!==r.length)throw"Accumulated block lengths must equal text.length";return e.ParagraphBuilder._ShapeText(r,D,U)};e.ParagraphBuilder.prototype.pushStyle=function(r){C(r);
this._pushStyle(r);J(r)};e.ParagraphBuilder.prototype.pushPaintStyle=function(r,D,U){C(r);this._pushPaintStyle(r,D,U);J(r)};e.ParagraphBuilder.prototype.addPlaceholder=function(r,D,U,ca,ka){U=U||e.PlaceholderAlignment.Baseline;ca=ca||e.TextBaseline.Alphabetic;this._addPlaceholder(r||0,D||0,U,ca,ka||0)};e.ParagraphBuilder.prototype.setWordsUtf8=function(r){var D=v(r,"HEAPU32");this._setWordsUtf8(D,r&&r.length||0);p(D,r)};e.ParagraphBuilder.prototype.setWordsUtf16=function(r){var D=v(r,"HEAPU32");this._setWordsUtf16(D,
r&&r.length||0);p(D,r)};e.ParagraphBuilder.prototype.setGraphemeBreaksUtf8=function(r){var D=v(r,"HEAPU32");this._setGraphemeBreaksUtf8(D,r&&r.length||0);p(D,r)};e.ParagraphBuilder.prototype.setGraphemeBreaksUtf16=function(r){var D=v(r,"HEAPU32");this._setGraphemeBreaksUtf16(D,r&&r.length||0);p(D,r)};e.ParagraphBuilder.prototype.setLineBreaksUtf8=function(r){var D=v(r,"HEAPU32");this._setLineBreaksUtf8(D,r&&r.length||0);p(D,r)};e.ParagraphBuilder.prototype.setLineBreaksUtf16=function(r){var D=v(r,
"HEAPU32");this._setLineBreaksUtf16(D,r&&r.length||0);p(D,r)}})})(w);a.Td=a.Td||[];a.Td.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.Td=a.Td||[];a.Td.push(function(){a.Canvas.prototype.drawText=function(e,d,g,l,t){var x=qa(e),C=a._malloc(x+1);ra(e,K,C,x+1);this._drawSimpleText(C,x,d,g,t,l);a._free(C)};a.Canvas.prototype.drawGlyphs=function(e,d,g,l,t,x){if(!(2*e.length<=d.length))throw"Not enough positions for the array of gyphs";
a.Md(this.Kd);const C=v(e,"HEAPU16"),J=v(d,"HEAPF32");this._drawGlyphs(e.length,C,J,g,l,t,x);p(J,d);p(C,e)};a.Font.prototype.getGlyphBounds=function(e,d,g){var l=v(e,"HEAPU16"),t=a._malloc(16*e.length);this._getGlyphWidthBounds(l,e.length,W,t,d||null);d=new Float32Array(a.HEAPU8.buffer,t,4*e.length);p(l,e);if(g)return g.set(d),a._free(t),g;e=Float32Array.from(d);a._free(t);return e};a.Font.prototype.getGlyphIDs=function(e,d,g){d||(d=e.length);var l=qa(e)+1,t=a._malloc(l);ra(e,K,t,l);e=a._malloc(2*
d);d=this._getGlyphIDs(t,l-1,d,e);a._free(t);if(0>d)return a._free(e),null;t=new Uint16Array(a.HEAPU8.buffer,e,d);if(g)return g.set(t),a._free(e),g;g=Uint16Array.from(t);a._free(e);return g};a.Font.prototype.getGlyphIntercepts=function(e,d,g,l){var t=v(e,"HEAPU16"),x=v(d,"HEAPF32");return this._getGlyphIntercepts(t,e.length,!(e&&e._ck),x,d.length,!(d&&d._ck),g,l)};a.Font.prototype.getGlyphWidths=function(e,d,g){var l=v(e,"HEAPU16"),t=a._malloc(4*e.length);this._getGlyphWidthBounds(l,e.length,t,W,
d||null);d=new Float32Array(a.HEAPU8.buffer,t,e.length);p(l,e);if(g)return g.set(d),a._free(t),g;e=Float32Array.from(d);a._free(t);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 t=new Uint8Array(e[l]),x=v(t,"HEAPU8");d.push(x);g.push(t.byteLength)}d=v(d,"HEAPU32");g=v(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=v(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=qa(e)+1,t=a._malloc(l);ra(e,K,t,l);e=a._malloc(2*d);d=this._getGlyphIDs(t,l-1,d,e);a._free(t);if(0>d)return a._free(e),null;t=new Uint16Array(a.HEAPU8.buffer,e,d);if(g)return g.set(t),a._free(e),g;g=Uint16Array.from(t);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 t=g.getGlyphIDs(e);t=g.getGlyphWidths(t);var x=[];d=new a.ContourMeasureIter(d,!1,1);for(var C=d.next(),J=new Float32Array(4),P=0;P<e.length&&C;P++){var O=t[P];l+=O/2;if(l>C.length()){C.delete();C=d.next();if(!C){e=e.substring(0,P);break}l=O/2}C.getPosTan(l,J);var Y=J[2],aa=J[3];x.push(Y,aa,J[0]-O/2*Y,J[1]-O/2*aa);l+=O/2}e=this.MakeFromRSXform(e,x,g);C&&C.delete();d.delete();return e}};
a.TextBlob.MakeFromRSXform=function(e,d,g){var l=qa(e)+1,t=a._malloc(l);ra(e,K,t,l);e=v(d,"HEAPF32");g=a.TextBlob._MakeFromRSXform(t,l-1,e,g);a._free(t);return g?g:null};a.TextBlob.MakeFromRSXformGlyphs=function(e,d,g){var l=v(e,"HEAPU16");d=v(d,"HEAPF32");g=a.TextBlob._MakeFromRSXformGlyphs(l,2*e.length,d,g);p(l,e);return g?g:null};a.TextBlob.MakeFromGlyphs=function(e,d){var g=v(e,"HEAPU16");d=a.TextBlob._MakeFromGlyphs(g,2*e.length,d);p(g,e);return d?d:null};a.TextBlob.MakeFromText=function(e,d){var g=
qa(e)+1,l=a._malloc(g);ra(e,K,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.Td=a.Td||[];a.Td.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}});a.Td=a.Td||[];a.Td.push(function(){a.RuntimeEffect.Make=function(e,d){return a.RuntimeEffect._Make(e,{onError:d||function(g){console.log("RuntimeEffect error",
g)}})};a.RuntimeEffect.MakeForBlender=function(e,d){return a.RuntimeEffect._MakeForBlender(e,{onError:d||function(g){console.log("RuntimeEffect error",g)}})};a.RuntimeEffect.prototype.makeShader=function(e,d){var g=!e._ck,l=v(e,"HEAPF32");d=H(d);return this._makeShader(l,4*e.length,g,d)};a.RuntimeEffect.prototype.makeShaderWithChildren=function(e,d,g){var l=!e._ck,t=v(e,"HEAPF32");g=H(g);for(var x=[],C=0;C<d.length;C++)x.push(d[C].Jd.Rd);d=v(x,"HEAPU32");return this._makeShaderWithChildren(t,4*e.length,
l,d,x.length,g)};a.RuntimeEffect.prototype.makeBlender=function(e){var d=!e._ck,g=v(e,"HEAPF32");return this._makeBlender(g,4*e.length,d)}});(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 q=k[1],z=k[2];k=k[3];if(1===k)return G=G.toString(16).toLowerCase(),q=q.toString(16).toLowerCase(),z=z.toString(16).toLowerCase(),G=1===G.length?"0"+G:G,q=1===q.length?"0"+q:q,z=1===z.length?"0"+
z:z,"#"+G+q+z;k=0===k||1===k?k:k.toFixed(8);return"rgba("+G+", "+q+", "+z+", "+k+")"}function g(G){return a.parseColorString(G,va)}function l(G){G=wa.exec(G);if(!G)return null;var k=parseFloat(G[4]),q=16;switch(G[5]){case "em":case "rem":q=16*k;break;case "pt":q=4*k/3;break;case "px":q=k;break;case "pc":q=16*k;break;case "in":q=96*k;break;case "cm":q=96*k/2.54;break;case "mm":q=96/25.4*k;break;case "q":q=96/25.4/4*k;break;case "%":q=16/75*k}return{style:G[1],variant:G[2],weight:G[3],sizePx:q,family:G[6].trim()}}
function t(G){this.Ld=G;this.Od=new a.Paint;this.Od.setAntiAlias(!0);this.Od.setStrokeMiter(10);this.Od.setStrokeCap(a.StrokeCap.Butt);this.Od.setStrokeJoin(a.StrokeJoin.Miter);this.Re="10px monospace";this.me=new a.Font(null,10);this.me.setSubpixel(!0);this.ae=this.ge=a.BLACK;this.ve=0;this.Je=a.TRANSPARENT;this.xe=this.we=0;this.Ke=this.ie=1;this.Ie=0;this.ue=[];this.Nd=a.BlendMode.SrcOver;this.Od.setStrokeWidth(this.Ke);this.Od.setBlendMode(this.Nd);this.Qd=new a.Path;this.Sd=a.Matrix.identity();
this.lf=[];this.Be=[];this.le=function(){this.Qd.delete();this.Od.delete();this.me.delete();this.Be.forEach(function(k){k.le()})};Object.defineProperty(this,"currentTransform",{enumerable:!0,get:function(){return{a:this.Sd[0],c:this.Sd[1],e:this.Sd[2],b:this.Sd[3],d:this.Sd[4],f:this.Sd[5]}},set:function(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.ae)?d(this.ae):this.ae},set:function(k){"string"===typeof k?
this.ae=g(k):k.te&&(this.ae=k)}});Object.defineProperty(this,"font",{enumerable:!0,get:function(){return this.Re},set:function(k){var q=l(k),z=q.family;q.typeface=na[z]?na[z][(q.style||"normal")+"|"+(q.variant||"normal")+"|"+(q.weight||"normal")]||na[z]["*"]:null;q&&(this.me.setSize(q.sizePx),this.me.setTypeface(q.typeface),this.Re=k)}});Object.defineProperty(this,"globalAlpha",{enumerable:!0,get:function(){return this.ie},set:function(k){!isFinite(k)||0>k||1<k||(this.ie=k)}});Object.defineProperty(this,
"globalCompositeOperation",{enumerable:!0,get:function(){switch(this.Nd){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.Nd=a.BlendMode.SrcOver;break;case "destination-over":this.Nd=a.BlendMode.DstOver;break;case "copy":this.Nd=a.BlendMode.Src;break;case "destination":this.Nd=a.BlendMode.Dst;break;case "clear":this.Nd=
a.BlendMode.Clear;break;case "source-in":this.Nd=a.BlendMode.SrcIn;break;case "destination-in":this.Nd=a.BlendMode.DstIn;break;case "source-out":this.Nd=a.BlendMode.SrcOut;break;case "destination-out":this.Nd=a.BlendMode.DstOut;break;case "source-atop":this.Nd=a.BlendMode.SrcATop;break;case "destination-atop":this.Nd=a.BlendMode.DstATop;break;case "xor":this.Nd=a.BlendMode.Xor;break;case "lighter":this.Nd=a.BlendMode.Plus;break;case "plus-lighter":this.Nd=a.BlendMode.Plus;break;case "plus-darker":throw"plus-darker is not supported";
case "multiply":th