UNPKG

canvaskit-wasm

Version:

A WASM version of Skia's Canvas API

108 lines (105 loc) 123 kB
var CanvasKitInit = (function() { 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 r;r||(r=typeof CanvasKitInit !== 'undefined' ? CanvasKitInit : {});var ca,ea;r.ready=new Promise(function(a,b){ca=a;ea=b}); (function(a){a.Sd=a.Sd||[];a.Sd.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.Jd=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.Jd=null,f.wf=b,f.tf=c,f.vf=h,f.$e=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){this._flush();if(this.Jd){var c=new Uint8ClampedArray(a.HEAPU8.buffer,this.$e,this.vf);c=new ImageData(c,this.wf,this.tf);b?this.Jd.getContext("2d").putImageData(c,0,0,b[0],b[1],b[2]-b[0],b[3]-b[1]):this.Jd.getContext("2d").putImageData(c,0,0)}};a.Surface.prototype.dispose=function(){this.$e&& a._free(this.$e);this.delete()};a.currentContext=a.currentContext||function(){};a.setCurrentContext=a.setCurrentContext||function(){}})})(r); (function(a){a.Sd=a.Sd||[];a.Sd.push(function(){function b(c,f,h){return c&&c.hasOwnProperty(f)?c[f]:h}a.GetWebGLContext=function(c,f){if(!c)throw"null canvas passed into makeWebGLContext";var h={alpha:b(f,"alpha",1),depth:b(f,"depth",1),stencil:b(f,"stencil",8),antialias:b(f,"antialias",0),premultipliedAlpha:b(f,"premultipliedAlpha",1),preserveDrawingBuffer:b(f,"preserveDrawingBuffer",0),preferLowPowerToHighPerformance:b(f,"preferLowPowerToHighPerformance",0),failIfMajorPerformanceCaveat:b(f,"failIfMajorPerformanceCaveat", 0),enableExtensionsByDefault:b(f,"enableExtensionsByDefault",1),explicitSwapControl:b(f,"explicitSwapControl",0),renderViaOffscreenBackBuffer:b(f,"renderViaOffscreenBackBuffer",0)};h.majorVersion=f&&f.majorVersion?f.majorVersion:"undefined"!==typeof WebGL2RenderingContext?2:1;if(h.explicitSwapControl)throw"explicitSwapControl is not supported";if(c=1<h.majorVersion?c.getContext("webgl2",h):c.getContext("webgl",h)){f=ha(ja);var m={Of:f,attributes:h,version:h.majorVersion,Ee:c};c.canvas&&(c.canvas.jf= m);ja[f]=m;("undefined"===typeof h.Cf||h.Cf)&&la(m);h=f}else h=0;if(!h)return 0;ma(h);return h};a.deleteContext=function(c){u===ja[c]&&(u=null);"object"===typeof JSEvents&&JSEvents.yg(ja[c].Ee.canvas);ja[c]&&ja[c].Ee.canvas&&(ja[c].Ee.canvas.jf=void 0);ja[c]=null};a.MakeWebGLCanvasSurface=function(c,f,h){f=f||null;var m=c,p="undefined"!==typeof OffscreenCanvas&&m instanceof OffscreenCanvas;if(!("undefined"!==typeof HTMLCanvasElement&&m instanceof HTMLCanvasElement||p||(m=document.getElementById(c), m)))throw"Canvas with id "+c+" was not found";c=this.GetWebGLContext(m,h);if(!c||0>c)throw"failed to create webgl context: err "+c;h=this.MakeGrContext(c);f=this.MakeOnScreenGLSurface(h,m.width,m.height,f);if(!f)return f=m.cloneNode(!0),m.parentNode.replaceChild(f,m),f.classList.add("ck-replaced"),a.MakeSWCanvasSurface(f);f.je=c;f.grContext=h;f.openGLversion=m.jf.version;return f};a.MakeCanvasSurface=a.MakeWebGLCanvasSurface})})(r); (function(a){function b(d,e,g,l,q){for(var z=0;z<d.length;z++)e[z*g+(z*q+l+g)%g]=d[z];return e}function c(d){for(var e=d*d,g=Array(e);e--;)g[e]=0===e%(d+1)?1:0;return g}function f(d){return d?d.constructor===Float32Array&&4===d.length:!1}function h(d){return(t(255*d[3])<<24|t(255*d[0])<<16|t(255*d[1])<<8|t(255*d[2])<<0)>>>0}function m(d){if(d instanceof Float32Array){for(var e=Math.floor(d.length/4),g=new Uint32Array(e),l=0;l<e;l++)g[l]=h(d.slice(4*l,4*(l+1)));return g}if(d instanceof Uint32Array)return d; if(d instanceof Array&&d[0]instanceof Float32Array)return d.map(h)}function p(d){if(void 0===d)return 1;var e=parseFloat(d);return d&&-1!==d.indexOf("%")?e/100:e}function t(d){return Math.round(Math.max(0,Math.min(d||0,255)))}function x(d,e){e&&!e._ck&&a._free(d)}function w(d,e,g){if(!d||!d.length)return T;if(d._ck)return d.byteOffset;var l=a[e].BYTES_PER_ELEMENT;g||(g=a._malloc(d.length*l));a[e].set(d,g/l);return g}function H(d){var e={Zd:T,count:d.length,Le:a.ColorType.RGBA_F32};if(d instanceof Float32Array)e.Zd=w(d,"HEAPF32"),e.count=d.length/4;else if(d instanceof Uint32Array)e.Zd=w(d,"HEAPU32"),e.Le=a.ColorType.RGBA_8888;else if(d instanceof Array){if(d&&d.length){for(var g=a._malloc(16*d.length),l=0,q=g/4,z=0;z<d.length;z++)for(var D=0;4>D;D++)a.HEAPF32[q+l]=d[z][D],l++;d=g}else d=T;e.Zd=d}else throw"Invalid argument to copyFlexibleColorArray, Not a color array "+typeof d;return e}function L(d){if(!d)return T;if(d.length){if(6===d.length||9===d.length)return w(d,"HEAPF32",Ja),6===d.length&& a.HEAPF32.set(Id,6+Ja/4),Ja;if(16===d.length){var e=Ab.toTypedArray();e[0]=d[0];e[1]=d[1];e[2]=d[3];e[3]=d[4];e[4]=d[5];e[5]=d[7];e[6]=d[12];e[7]=d[13];e[8]=d[15];return Ja}throw"invalid matrix size";}e=Ab.toTypedArray();e[0]=d.m11;e[1]=d.m21;e[2]=d.m41;e[3]=d.m12;e[4]=d.m22;e[5]=d.m42;e[6]=d.m14;e[7]=d.m24;e[8]=d.m44;return Ja}function P(d){if(!d)return T;var e=cc.toTypedArray();if(d.length){if(16!==d.length&&6!==d.length&&9!==d.length)throw"invalid matrix size";if(16===d.length)return w(d,"HEAPF32", Ka);e.fill(0);e[0]=d[0];e[1]=d[1];e[3]=d[2];e[4]=d[3];e[5]=d[4];e[7]=d[5];e[12]=d[6];e[13]=d[7];e[15]=d[8];6===d.length&&(e[12]=0,e[13]=0,e[15]=1);return Ka}e[0]=d.m11;e[1]=d.m21;e[2]=d.m31;e[3]=d.m41;e[4]=d.m12;e[5]=d.m22;e[6]=d.m32;e[7]=d.m42;e[8]=d.m13;e[9]=d.m23;e[10]=d.m33;e[11]=d.m43;e[12]=d.m14;e[13]=d.m24;e[14]=d.m34;e[15]=d.m44;return Ka}function A(d){for(var e=Array(16),g=0;16>g;g++)e[g]=a.HEAPF32[d/4+g];return e}function M(d,e){return w(d,"HEAPF32",e||hb)}function Y(d,e,g,l){var q=dc.toTypedArray(); q[0]=d;q[1]=e;q[2]=g;q[3]=l;return hb}function da(d){for(var e=new Float32Array(4),g=0;4>g;g++)e[g]=a.HEAPF32[d/4+g];return e}function aa(d,e){return w(d,"HEAPF32",e||ia)}function oa(d,e){return w(d,"HEAPF32",e||ec)}function Bb(d,e){if(Mc)require("fs").writeFile(e,new Buffer(d),function(l){if(l)throw l;});else{url=window.URL.createObjectURL(new Blob([d],{type:"application/octet-stream"}));var g=document.createElement("a");document.body.appendChild(g);g.href=url;g.download=e;g.click();setTimeout(function(){URL.revokeObjectURL(url); g.remove()},50)}}function ib(){for(var d=0,e=0;e<arguments.length-1;e+=2)d+=arguments[e]*arguments[e+1];return d}function Nc(d,e,g){for(var l=Array(d.length),q=0;q<g;q++)for(var z=0;z<g;z++){for(var D=0,J=0;J<g;J++)D+=d[g*q+J]*e[g*J+z];l[q*g+z]=D}return l}function Oc(d,e){for(var g=Nc(e[0],e[1],d),l=2;l<e.length;)g=Nc(g,e[l],d),l++;return g}a.Color=function(d,e,g,l){void 0===l&&(l=1);return a.Color4f(t(d)/255,t(e)/255,t(g)/255,l)};a.ColorAsInt=function(d,e,g,l){void 0===l&&(l=255);return(t(l)<<24| t(d)<<16|t(e)<<8|t(g)<<0&268435455)>>>0};a.Color4f=function(d,e,g,l){void 0===l&&(l=1);return Float32Array.of(d,e,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(d){return[Math.floor(255*d[0]),Math.floor(255*d[1]),Math.floor(255*d[2]),d[3]]};a.parseColorString=function(d,e){d=d.toLowerCase();if(d.startsWith("#")){e= 255;switch(d.length){case 9:e=parseInt(d.slice(7,9),16);case 7:var g=parseInt(d.slice(1,3),16);var l=parseInt(d.slice(3,5),16);var q=parseInt(d.slice(5,7),16);break;case 5:e=17*parseInt(d.slice(4,5),16);case 4:g=17*parseInt(d.slice(1,2),16),l=17*parseInt(d.slice(2,3),16),q=17*parseInt(d.slice(3,4),16)}return a.Color(g,l,q,e/255)}return d.startsWith("rgba")?(d=d.slice(5,-1),d=d.split(","),a.Color(+d[0],+d[1],+d[2],p(d[3]))):d.startsWith("rgb")?(d=d.slice(4,-1),d=d.split(","),a.Color(+d[0],+d[1],+d[2], p(d[3]))):d.startsWith("gray(")||d.startsWith("hsl")||!e||(d=e[d],void 0===d)?a.BLACK:d};a.multiplyByAlpha=function(d,e){d=d.slice();d[3]=Math.max(0,Math.min(d[3]*e,1));return d};a.Malloc=function(d,e){var g=a._malloc(e*d.BYTES_PER_ELEMENT);return{_ck:!0,length:e,byteOffset:g,le:null,subarray:function(l,q){l=this.toTypedArray().subarray(l,q);l._ck=!0;return l},toTypedArray:function(){if(this.le&&this.le.length)return this.le;this.le=new d(a.HEAPU8.buffer,g,e);this.le._ck=!0;return this.le}}};a.Free= function(d){a._free(d.byteOffset);d.byteOffset=T;d.toTypedArray=null;d.le=null};var Ja=T,Ab,Ka=T,cc,hb=T,dc,ya,ia=T,Pc,Sa=T,Qc,fc=T,Rc,hc=T,Sc,ic=T,Tc,ec=T,Uc,Vc=T,Id=Float32Array.of(0,0,1),jc={};a.me=function(){this.ie=[];this.Qd=null;Object.defineProperty(this,"length",{enumerable:!0,get:function(){return this.ie.length/4}})};a.me.prototype.push=function(d,e,g,l){this.Qd||this.ie.push(d,e,g,l)};a.me.prototype.set=function(d,e,g,l,q){0>d||d>=this.ie.length/4||(d*=4,this.Qd?(d=this.Qd/4+d,a.HEAPF32[d]= e,a.HEAPF32[d+1]=g,a.HEAPF32[d+2]=l,a.HEAPF32[d+3]=q):(this.ie[d]=e,this.ie[d+1]=g,this.ie[d+2]=l,this.ie[d+3]=q))};a.me.prototype.build=function(){return this.Qd?this.Qd:this.Qd=w(this.ie,"HEAPF32")};a.me.prototype.delete=function(){this.Qd&&(a._free(this.Qd),this.Qd=null)};a.Fe=function(){this.Ke=[];this.Qd=null;Object.defineProperty(this,"length",{enumerable:!0,get:function(){return this.Ke.length}})};a.Fe.prototype.push=function(d){this.Qd||this.Ke.push(d)};a.Fe.prototype.set=function(d,e){0> d||d>=this.Ke.length||(d*=4,this.Qd?a.HEAPU32[this.Qd/4+d]=e:this.Ke[d]=e)};a.Fe.prototype.build=function(){return this.Qd?this.Qd:this.Qd=w(this.Ke,"HEAPU32")};a.Fe.prototype.delete=function(){this.Qd&&(a._free(this.Qd),this.Qd=null)};a.RectBuilder=a.me;a.RSXFormBuilder=a.me;a.ColorBuilder=a.Fe;var T=0,Mc=!(new Function("try {return this===window;}catch(e){ return false;}"))();a.onRuntimeInitialized=function(){function d(e,g,l,q,z,D){D||(D=4*q.width,q.colorType===a.ColorType.RGBA_F16?D*=2:q.colorType=== a.ColorType.RGBA_F32&&(D*=4));var J=D*q.height;var N=z?z.byteOffset:a._malloc(J);if(!e._readPixels(q,N,D,g,l))return z||a._free(N),null;if(z)return z.toTypedArray();switch(q.colorType){case a.ColorType.RGBA_8888:case a.ColorType.RGBA_F16:e=(new Uint8Array(a.HEAPU8.buffer,N,J)).slice();break;case a.ColorType.RGBA_F32:e=(new Float32Array(a.HEAPU8.buffer,N,J)).slice();break;default:return null}a._free(N);return e}dc=a.Malloc(Float32Array,4);hb=dc.byteOffset;cc=a.Malloc(Float32Array,16);Ka=cc.byteOffset; Ab=a.Malloc(Float32Array,9);Ja=Ab.byteOffset;Tc=a.Malloc(Float32Array,12);ec=Tc.byteOffset;Uc=a.Malloc(Float32Array,12);Vc=Uc.byteOffset;ya=a.Malloc(Float32Array,4);ia=ya.byteOffset;Pc=a.Malloc(Float32Array,4);Sa=Pc.byteOffset;Qc=a.Malloc(Float32Array,3);fc=Qc.byteOffset;Rc=a.Malloc(Float32Array,3);hc=Rc.byteOffset;Sc=a.Malloc(Int32Array,4);ic=Sc.byteOffset;a.ColorSpace.SRGB=a.ColorSpace._MakeSRGB();a.ColorSpace.DISPLAY_P3=a.ColorSpace._MakeDisplayP3();a.ColorSpace.ADOBE_RGB=a.ColorSpace._MakeAdobeRGB(); a.Path.MakeFromCmds=function(e){for(var g=0,l=0;l<e.length;l++)g+=e[l].length;if(jc[g])var q=jc[g];else q=new Float32Array(g),jc[g]=q;var z=0;for(l=0;l<e.length;l++)for(var D=0;D<e[l].length;D++)q[z]=e[l][D],z++;e=[w(q,"HEAPF32"),g];g=a.Path._MakeFromCmds(e[0],e[1]);a._free(e[0]);return g};a.Path.MakeFromVerbsPointsWeights=function(e,g,l){var q=w(e,"HEAPU8"),z=w(g,"HEAPF32"),D=w(l,"HEAPF32"),J=a.Path._MakeFromVerbsPointsWeights(q,e.length,z,g.length,D,l&&l.length||0);x(q,e);x(z,g);x(D,l);return J}; a.Path.prototype.addArc=function(e,g,l){e=aa(e);this._addArc(e,g,l);return this};a.Path.prototype.addOval=function(e,g,l){void 0===l&&(l=1);e=aa(e);this._addOval(e,!!g,l);return this};a.Path.prototype.addPath=function(){var e=Array.prototype.slice.call(arguments),g=e[0],l=!1;"boolean"===typeof e[e.length-1]&&(l=e.pop());if(1===e.length)this._addPath(g,1,0,0,0,1,0,0,0,1,l);else if(2===e.length)e=e[1],this._addPath(g,e[0],e[1],e[2],e[3],e[4],e[5],e[6]||0,e[7]||0,e[8]||1,l);else if(7===e.length||10=== e.length)this._addPath(g,e[1],e[2],e[3],e[4],e[5],e[6],e[7]||0,e[8]||0,e[9]||1,l);else return null;return this};a.Path.prototype.addPoly=function(e,g){var l=w(e,"HEAPF32");this._addPoly(l,e.length/2,g);x(l,e);return this};a.Path.prototype.addRect=function(e,g){e=aa(e);this._addRect(e,!!g);return this};a.Path.prototype.addRRect=function(e,g){e=oa(e);this._addRRect(e,!!g);return this};a.Path.prototype.addVerbsPointsWeights=function(e,g,l){var q=w(e,"HEAPU8"),z=w(g,"HEAPF32"),D=w(l,"HEAPF32");this._addVerbsPointsWeights(q, e.length,z,g.length,D,l&&l.length||0);x(q,e);x(z,g);x(D,l)};a.Path.prototype.arc=function(e,g,l,q,z,D){e=a.LTRBRect(e-l,g-l,e+l,g+l);z=(z-q)/Math.PI*180-360*!!D;D=new a.Path;D.addArc(e,q/Math.PI*180,z);this.addPath(D,!0);D.delete();return this};a.Path.prototype.arcToOval=function(e,g,l,q){e=aa(e);this._arcToOval(e,g,l,q);return this};a.Path.prototype.arcToRotated=function(e,g,l,q,z,D,J){this._arcToRotated(e,g,l,!!q,!!z,D,J);return this};a.Path.prototype.arcToTangent=function(e,g,l,q,z){this._arcToTangent(e, g,l,q,z);return this};a.Path.prototype.close=function(){this._close();return this};a.Path.prototype.conicTo=function(e,g,l,q,z){this._conicTo(e,g,l,q,z);return this};a.Path.prototype.computeTightBounds=function(e){this._computeTightBounds(ia);var g=ya.toTypedArray();return e?(e.set(g),e):g.slice()};a.Path.prototype.cubicTo=function(e,g,l,q,z,D){this._cubicTo(e,g,l,q,z,D);return this};a.Path.prototype.dash=function(e,g,l){return this._dash(e,g,l)?this:null};a.Path.prototype.getBounds=function(e){this._getBounds(ia); var g=ya.toTypedArray();return e?(e.set(g),e):g.slice()};a.Path.prototype.lineTo=function(e,g){this._lineTo(e,g);return this};a.Path.prototype.moveTo=function(e,g){this._moveTo(e,g);return this};a.Path.prototype.offset=function(e,g){this._transform(1,0,e,0,1,g,0,0,1);return this};a.Path.prototype.quadTo=function(e,g,l,q){this._quadTo(e,g,l,q);return this};a.Path.prototype.rArcTo=function(e,g,l,q,z,D,J){this._rArcTo(e,g,l,q,z,D,J);return this};a.Path.prototype.rConicTo=function(e,g,l,q,z){this._rConicTo(e, g,l,q,z);return this};a.Path.prototype.rCubicTo=function(e,g,l,q,z,D){this._rCubicTo(e,g,l,q,z,D);return this};a.Path.prototype.rLineTo=function(e,g){this._rLineTo(e,g);return this};a.Path.prototype.rMoveTo=function(e,g){this._rMoveTo(e,g);return this};a.Path.prototype.rQuadTo=function(e,g,l,q){this._rQuadTo(e,g,l,q);return this};a.Path.prototype.stroke=function(e){e=e||{};e.width=e.width||1;e.miter_limit=e.miter_limit||4;e.cap=e.cap||a.StrokeCap.Butt;e.join=e.join||a.StrokeJoin.Miter;e.precision= e.precision||1;return this._stroke(e)?this:null};a.Path.prototype.transform=function(){if(1===arguments.length){var e=arguments[0];this._transform(e[0],e[1],e[2],e[3],e[4],e[5],e[6]||0,e[7]||0,e[8]||1)}else if(6===arguments.length||9===arguments.length)e=arguments,this._transform(e[0],e[1],e[2],e[3],e[4],e[5],e[6]||0,e[7]||0,e[8]||1);else throw"transform expected to take 1 or 9 arguments. Got "+arguments.length;return this};a.Path.prototype.trim=function(e,g,l){return this._trim(e,g,!!l)?this:null}; a.Image.prototype.encodeToData=function(){if(!arguments.length)return this._encodeToData();if(2===arguments.length){var e=arguments;return this._encodeToDataWithFormat(e[0],e[1])}throw"encodeToData expected to take 0 or 2 arguments. Got "+arguments.length;};a.Image.prototype.makeShaderCubic=function(e,g,l,q,z){z=L(z);return this._makeShaderCubic(e,g,l,q,z)};a.Image.prototype.makeShaderOptions=function(e,g,l,q,z){z=L(z);return this._makeShaderOptions(e,g,l,q,z)};a.Image.prototype.readPixels=function(e, g,l,q,z){return d(this,e,g,l,q,z)};a.Canvas.prototype.clear=function(e){e=M(e);this._clear(e)};a.Canvas.prototype.clipRRect=function(e,g,l){e=oa(e);this._clipRRect(e,g,l)};a.Canvas.prototype.clipRect=function(e,g,l){e=aa(e);this._clipRect(e,g,l)};a.Canvas.prototype.concat=function(e){e=P(e);this._concat(e)};a.Canvas.prototype.drawArc=function(e,g,l,q,z){e=aa(e);this._drawArc(e,g,l,q,z)};a.Canvas.prototype.drawAtlas=function(e,g,l,q,z,D){if(e&&q&&g&&l&&g.length===l.length){z||(z=a.BlendMode.SrcOver); var J;g.build?J=g.build():J=w(g,"HEAPF32");if(l.build){var N=l.build();var Q=l.length}else N=w(l,"HEAPF32"),Q=l.length/4;var S=T;D&&(D.build?S=D.build():S=w(m(D),"HEAPU32"));this._drawAtlas(e,N,J,S,Q,z,q);J&&!g.build&&x(J,g);N&&!l.build&&x(N,l);S&&!D.build&&x(S,D)}};a.Canvas.prototype.drawColor=function(e,g){e=M(e);void 0!==g?this._drawColor(e,g):this._drawColor(e)};a.Canvas.prototype.drawColorComponents=function(e,g,l,q,z){e=Y(e,g,l,q);void 0!==z?this._drawColor(e,z):this._drawColor(e)};a.Canvas.prototype.drawDRRect= function(e,g,l){e=oa(e,ec);g=oa(g,Vc);this._drawDRRect(e,g,l)};a.Canvas.prototype.drawImageNine=function(e,g,l,q,z){g=w(g,"HEAP32",ic);l=aa(l);this._drawImageNine(e,g,l,q,z||null)};a.Canvas.prototype.drawImageRect=function(e,g,l,q,z){aa(g,ia);aa(l,Sa);this._drawImageRect(e,ia,Sa,q,!!z)};a.Canvas.prototype.drawImageRectCubic=function(e,g,l,q,z,D){aa(g,ia);aa(l,Sa);this._drawImageRectCubic(e,ia,Sa,q,z,D||null)};a.Canvas.prototype.drawImageRectOptions=function(e,g,l,q,z,D){aa(g,ia);aa(l,Sa);this._drawImageRectOptions(e, ia,Sa,q,z,D||null)};a.Canvas.prototype.drawOval=function(e,g){e=aa(e);this._drawOval(e,g)};a.Canvas.prototype.drawPoints=function(e,g,l){var q=w(g,"HEAPF32");this._drawPoints(e,q,g.length/2,l);x(q,g)};a.Canvas.prototype.drawRRect=function(e,g){e=oa(e);this._drawRRect(e,g)};a.Canvas.prototype.drawRect=function(e,g){e=aa(e);this._drawRect(e,g)};a.Canvas.prototype.drawShadow=function(e,g,l,q,z,D,J){var N=w(z,"HEAPF32"),Q=w(D,"HEAPF32");g=w(g,"HEAPF32",fc);l=w(l,"HEAPF32",hc);this._drawShadow(e,g,l,q, N,Q,J);x(N,z);x(Q,D)};a.getShadowLocalBounds=function(e,g,l,q,z,D,J){e=L(e);l=w(l,"HEAPF32",fc);q=w(q,"HEAPF32",hc);if(!this._getShadowLocalBounds(e,g,l,q,z,D,ia))return null;g=ya.toTypedArray();return J?(J.set(g),J):g.slice()};a.Canvas.prototype.getLocalToDevice=function(){this._getLocalToDevice(Ka);return A(Ka)};a.Canvas.prototype.findMarkedCTM=function(e){return this._findMarkedCTM(e,Ka)?A(Ka):null};a.Canvas.prototype.getTotalMatrix=function(){this._getTotalMatrix(Ja);for(var e=Array(9),g=0;9> g;g++)e[g]=a.HEAPF32[Ja/4+g];return e};a.Canvas.prototype.readPixels=function(e,g,l,q,z){return d(this,e,g,l,q,z)};a.Canvas.prototype.saveLayer=function(e,g,l,q){g=aa(g);return this._saveLayer(e||null,g,l||null,q||0)};a.Canvas.prototype.writePixels=function(e,g,l,q,z,D,J,N){if(e.byteLength%(g*l))throw"pixels length must be a multiple of the srcWidth * srcHeight";var Q=e.byteLength/(g*l);D=D||a.AlphaType.Unpremul;J=J||a.ColorType.RGBA_8888;N=N||a.ColorSpace.SRGB;var S=Q*g;Q=w(e,"HEAPU8");g=this._writePixels({width:g, height:l,colorType:J,alphaType:D,colorSpace:N},Q,S,q,z);x(Q,e);return g};a.ColorFilter.MakeBlend=function(e,g){e=M(e);return a.ColorFilter._MakeBlend(e,g)};a.ColorFilter.MakeMatrix=function(e){if(!e||20!==e.length)throw"invalid color matrix";var g=w(e,"HEAPF32"),l=a.ColorFilter._makeMatrix(g);x(g,e);return l};a.ContourMeasure.prototype.getPosTan=function(e,g){this._getPosTan(e,ia);e=ya.toTypedArray();return g?(g.set(e),g):e.slice()};a.ImageFilter.MakeMatrixTransform=function(e,g,l){e=L(e);return a.ImageFilter._MakeMatrixTransform(e, g,l)};a.Paint.prototype.getColor=function(){this._getColor(hb);return da(hb)};a.Paint.prototype.setColor=function(e,g){g=g||null;e=M(e);this._setColor(e,g)};a.Paint.prototype.setColorComponents=function(e,g,l,q,z){z=z||null;e=Y(e,g,l,q);this._setColor(e,z)};a.Path.prototype.getPoint=function(e,g){this._getPoint(e,ia);e=ya.toTypedArray();return g?(g[0]=e[0],g[1]=e[1],g):e.slice(0,2)};a.PictureRecorder.prototype.beginRecording=function(e){e=aa(e);return this._beginRecording(e)};a.Surface.prototype.makeImageSnapshot= function(e){e=w(e,"HEAP32",ic);return this._makeImageSnapshot(e)};a.Surface.prototype.requestAnimationFrame=function(e,g){this.Ge||(this.Ge=this.getCanvas());requestAnimationFrame(function(){void 0!==this.je&&a.setCurrentContext(this.je);e(this.Ge);this.flush(g)}.bind(this))};a.Surface.prototype.drawOnce=function(e,g){this.Ge||(this.Ge=this.getCanvas());requestAnimationFrame(function(){void 0!==this.je&&a.setCurrentContext(this.je);e(this.Ge);this.flush(g);this.dispose()}.bind(this))};a.PathEffect.MakeDash= function(e,g){g||(g=0);if(!e.length||1===e.length%2)throw"Intervals array must have even length";var l=w(e,"HEAPF32");g=a.PathEffect._MakeDash(l,e.length,g);x(l,e);return g};a.Shader.MakeColor=function(e,g){g=g||null;e=M(e);return a.Shader._MakeColor(e,g)};a.Shader.Blend=a.Shader.MakeBlend;a.Shader.Color=a.Shader.MakeColor;a.Shader.Lerp=a.Shader.MakeLerp;a.Shader.MakeLinearGradient=function(e,g,l,q,z,D,J,N){N=N||null;var Q=H(l),S=w(q,"HEAPF32");J=J||0;D=L(D);var v=ya.toTypedArray();v.set(e);v.set(g, 2);e=a.Shader._MakeLinearGradient(ia,Q.Zd,Q.Le,S,Q.count,z,J,D,N);x(Q.Zd,l);q&&x(S,q);return e};a.Shader.MakeRadialGradient=function(e,g,l,q,z,D,J,N){N=N||null;var Q=H(l),S=w(q,"HEAPF32");J=J||0;D=L(D);e=a.Shader._MakeRadialGradient(e[0],e[1],g,Q.Zd,Q.Le,S,Q.count,z,J,D,N);x(Q.Zd,l);q&&x(S,q);return e};a.Shader.MakeSweepGradient=function(e,g,l,q,z,D,J,N,Q,S){S=S||null;var v=H(l),I=w(q,"HEAPF32");J=J||0;N=N||0;Q=Q||360;D=L(D);e=a.Shader._MakeSweepGradient(e,g,v.Zd,v.Le,I,v.count,z,N,Q,J,D,S);x(v.Zd, l);q&&x(I,q);return e};a.Shader.MakeTwoPointConicalGradient=function(e,g,l,q,z,D,J,N,Q,S){S=S||null;var v=H(z),I=w(D,"HEAPF32");Q=Q||0;N=L(N);var R=ya.toTypedArray();R.set(e);R.set(l,2);e=a.Shader._MakeTwoPointConicalGradient(ia,g,q,v.Zd,v.Le,I,v.count,J,Q,N,S);x(v.Zd,z);D&&x(I,D);return e};a.Vertices.prototype.bounds=function(e){this._bounds(ia);var g=ya.toTypedArray();return e?(e.set(g),e):g.slice()};a.Sd&&a.Sd.forEach(function(e){e()})};a.computeTonalColors=function(d){var e=w(d.ambient,"HEAPF32"), g=w(d.spot,"HEAPF32");this._computeTonalColors(e,g);var l={ambient:da(e),spot:da(g)};x(e,d.ambient);x(g,d.spot);return l};a.LTRBRect=function(d,e,g,l){return Float32Array.of(d,e,g,l)};a.XYWHRect=function(d,e,g,l){return Float32Array.of(d,e,d+g,e+l)};a.LTRBiRect=function(d,e,g,l){return Int32Array.of(d,e,g,l)};a.XYWHiRect=function(d,e,g,l){return Int32Array.of(d,e,d+g,e+l)};a.RRectXY=function(d,e,g){return Float32Array.of(d[0],d[1],d[2],d[3],e,g,e,g,e,g,e,g)};a.MakeAnimatedImageFromEncoded=function(d){d= new Uint8Array(d);var e=a._malloc(d.byteLength);a.HEAPU8.set(d,e);return(d=a._decodeAnimatedImage(e,d.byteLength))?d:null};a.MakeImageFromEncoded=function(d){d=new Uint8Array(d);var e=a._malloc(d.byteLength);a.HEAPU8.set(d,e);return(d=a._decodeImage(e,d.byteLength))?d:null};var jb=null;a.MakeImageFromCanvasImageSource=function(d){var e=d.width,g=d.height;jb||(jb=document.createElement("canvas"));jb.width=e;jb.height=g;var l=jb.getContext("2d");l.drawImage(d,0,0);d=l.getImageData(0,0,e,g);return a.MakeImage({width:e, height:g,alphaType:a.AlphaType.Unpremul,colorType:a.ColorType.RGBA_8888,colorSpace:a.ColorSpace.SRGB},d.data,4*e)};a.MakeImage=function(d,e,g){var l=a._malloc(e.length);a.HEAPU8.set(e,l);return a._MakeImage(d,l,e.length,g)};a.MakeVertices=function(d,e,g,l,q,z){var D=q&&q.length||0,J=0;g&&g.length&&(J|=1);l&&l.length&&(J|=2);void 0===z||z||(J|=4);d=new a._VerticesBuilder(d,e.length/2,D,J);w(e,"HEAPF32",d.positions());d.texCoords()&&w(g,"HEAPF32",d.texCoords());if(d.colors()){if(l.build)throw"Color builder not accepted by MakeVertices, use array of ints"; w(m(l),"HEAPU32",d.colors())}d.indices()&&w(q,"HEAPU16",d.indices());return d.detach()};a.Matrix={};a.Matrix.identity=function(){return c(3)};a.Matrix.invert=function(d){var e=d[0]*d[4]*d[8]+d[1]*d[5]*d[6]+d[2]*d[3]*d[7]-d[2]*d[4]*d[6]-d[1]*d[3]*d[8]-d[0]*d[5]*d[7];return e?[(d[4]*d[8]-d[5]*d[7])/e,(d[2]*d[7]-d[1]*d[8])/e,(d[1]*d[5]-d[2]*d[4])/e,(d[5]*d[6]-d[3]*d[8])/e,(d[0]*d[8]-d[2]*d[6])/e,(d[2]*d[3]-d[0]*d[5])/e,(d[3]*d[7]-d[4]*d[6])/e,(d[1]*d[6]-d[0]*d[7])/e,(d[0]*d[4]-d[1]*d[3])/e]:null};a.Matrix.mapPoints= function(d,e){for(var g=0;g<e.length;g+=2){var l=e[g],q=e[g+1],z=d[6]*l+d[7]*q+d[8],D=d[3]*l+d[4]*q+d[5];e[g]=(d[0]*l+d[1]*q+d[2])/z;e[g+1]=D/z}return e};a.Matrix.multiply=function(){return Oc(3,arguments)};a.Matrix.rotated=function(d,e,g){e=e||0;g=g||0;var l=Math.sin(d);d=Math.cos(d);return[d,-l,ib(l,g,1-d,e),l,d,ib(-l,e,1-d,g),0,0,1]};a.Matrix.scaled=function(d,e,g,l){g=g||0;l=l||0;var q=b([d,e],c(3),3,0,1);return b([g-d*g,l-e*l],q,3,2,0)};a.Matrix.skewed=function(d,e,g,l){g=g||0;l=l||0;var q=b([d, e],c(3),3,1,-1);return b([-d*g,-e*l],q,3,2,0)};a.Matrix.translated=function(d,e){return b(arguments,c(3),3,2,0)};a.Vector={};a.Vector.dot=function(d,e){return d.map(function(g,l){return g*e[l]}).reduce(function(g,l){return g+l})};a.Vector.lengthSquared=function(d){return a.Vector.dot(d,d)};a.Vector.length=function(d){return Math.sqrt(a.Vector.lengthSquared(d))};a.Vector.mulScalar=function(d,e){return d.map(function(g){return g*e})};a.Vector.add=function(d,e){return d.map(function(g,l){return g+e[l]})}; a.Vector.sub=function(d,e){return d.map(function(g,l){return g-e[l]})};a.Vector.dist=function(d,e){return a.Vector.length(a.Vector.sub(d,e))};a.Vector.normalize=function(d){return a.Vector.mulScalar(d,1/a.Vector.length(d))};a.Vector.cross=function(d,e){return[d[1]*e[2]-d[2]*e[1],d[2]*e[0]-d[0]*e[2],d[0]*e[1]-d[1]*e[0]]};a.M44={};a.M44.identity=function(){return c(4)};a.M44.translated=function(d){return b(d,c(4),4,3,0)};a.M44.scaled=function(d){return b(d,c(4),4,0,1)};a.M44.rotated=function(d,e){return a.M44.rotatedUnitSinCos(a.Vector.normalize(d), Math.sin(e),Math.cos(e))};a.M44.rotatedUnitSinCos=function(d,e,g){var l=d[0],q=d[1];d=d[2];var z=1-g;return[z*l*l+g,z*l*q-e*d,z*l*d+e*q,0,z*l*q+e*d,z*q*q+g,z*q*d-e*l,0,z*l*d-e*q,z*q*d+e*l,z*d*d+g,0,0,0,0,1]};a.M44.lookat=function(d,e,g){e=a.Vector.normalize(a.Vector.sub(e,d));g=a.Vector.normalize(g);g=a.Vector.normalize(a.Vector.cross(e,g));var l=a.M44.identity();b(g,l,4,0,0);b(a.Vector.cross(g,e),l,4,1,0);b(a.Vector.mulScalar(e,-1),l,4,2,0);b(d,l,4,3,0);d=a.M44.invert(l);return null===d?a.M44.identity(): d};a.M44.perspective=function(d,e,g){var l=1/(e-d);g/=2;g=Math.cos(g)/Math.sin(g);return[g,0,0,0,0,g,0,0,0,0,(e+d)*l,2*e*d*l,0,0,-1,1]};a.M44.rc=function(d,e,g){return d[4*e+g]};a.M44.multiply=function(){return Oc(4,arguments)};a.M44.invert=function(d){var e=d[0],g=d[4],l=d[8],q=d[12],z=d[1],D=d[5],J=d[9],N=d[13],Q=d[2],S=d[6],v=d[10],I=d[14],R=d[3],ba=d[7],qa=d[11];d=d[15];var va=e*D-g*z,wa=e*J-l*z,ka=e*N-q*z,F=g*J-l*D,k=g*N-q*D,n=l*N-q*J,y=Q*ba-S*R,B=Q*qa-v*R,C=Q*d-I*R,E=S*qa-v*ba,K=S*d-I*ba,Z= v*d-I*qa,pa=va*Z-wa*K+ka*E+F*C-k*B+n*y,fa=1/pa;if(0===pa||Infinity===fa)return null;va*=fa;wa*=fa;ka*=fa;F*=fa;k*=fa;n*=fa;y*=fa;B*=fa;C*=fa;E*=fa;K*=fa;Z*=fa;e=[D*Z-J*K+N*E,J*C-z*Z-N*B,z*K-D*C+N*y,D*B-z*E-J*y,l*K-g*Z-q*E,e*Z-l*C+q*B,g*C-e*K-q*y,e*E-g*B+l*y,ba*n-qa*k+d*F,qa*ka-R*n-d*wa,R*k-ba*ka+d*va,ba*wa-R*F-qa*va,v*k-S*n-I*F,Q*n-v*ka+I*wa,S*ka-Q*k-I*va,Q*F-S*wa+v*va];return e.every(function(Ea){return!isNaN(Ea)&&Infinity!==Ea&&-Infinity!==Ea})?e:null};a.M44.transpose=function(d){return[d[0],d[4], d[8],d[12],d[1],d[5],d[9],d[13],d[2],d[6],d[10],d[14],d[3],d[7],d[11],d[15]]};a.M44.mustInvert=function(d){d=a.M44.invert(d);if(null===d)throw"Matrix not invertible";return d};a.M44.setupCamera=function(d,e,g){var l=a.M44.lookat(g.eye,g.coa,g.up);g=a.M44.perspective(g.near,g.far,g.angle);e=[(d[2]-d[0])/2,(d[3]-d[1])/2,e];d=a.M44.multiply(a.M44.translated([(d[0]+d[2])/2,(d[1]+d[3])/2,0]),a.M44.scaled(e));return a.M44.multiply(d,g,l,a.M44.mustInvert(d))};a.ColorMatrix={};a.ColorMatrix.identity=function(){var d= new Float32Array(20);d[0]=1;d[6]=1;d[12]=1;d[18]=1;return d};a.ColorMatrix.scaled=function(d,e,g,l){var q=new Float32Array(20);q[0]=d;q[6]=e;q[12]=g;q[18]=l;return q};var Jd=[[6,7,11,12],[0,10,2,12],[0,1,5,6]];a.ColorMatrix.rotated=function(d,e,g){var l=a.ColorMatrix.identity();d=Jd[d];l[d[0]]=g;l[d[1]]=e;l[d[2]]=-e;l[d[3]]=g;return l};a.ColorMatrix.postTranslate=function(d,e,g,l,q){d[4]+=e;d[9]+=g;d[14]+=l;d[19]+=q;return d};a.ColorMatrix.concat=function(d,e){for(var g=new Float32Array(20),l=0,q= 0;20>q;q+=5){for(var z=0;4>z;z++)g[l++]=d[q]*e[z]+d[q+1]*e[z+5]+d[q+2]*e[z+10]+d[q+3]*e[z+15];g[l++]=d[q]*e[4]+d[q+1]*e[9]+d[q+2]*e[14]+d[q+3]*e[19]+d[q+4]}return g};(function(d){d.Sd=d.Sd||[];d.Sd.push(function(){function e(v){if(!v||!v.length)return[];for(var I=[],R=0;R<v.length;R+=5){var ba=d.LTRBRect(v[R],v[R+1],v[R+2],v[R+3]);ba.direction=0===v[R+4]?d.TextDirection.RTL:d.TextDirection.LTR;I.push(ba)}d._free(v.byteOffset);return I}function g(v){v=v||{};void 0===v.weight&&(v.weight=d.FontWeight.Normal); v.width=v.width||d.FontWidth.Normal;v.slant=v.slant||d.FontSlant.Upright;return v}function l(v){if(!v||!v.length)return T;for(var I=[],R=0;R<v.length;R++){var ba=q(v[R]);I.push(ba)}return w(I,"HEAPU32")}function q(v){if(J[v])return J[v];var I=na(v)+1,R=d._malloc(I);ra(v,G,R,I);return J[v]=R}function z(v){v._colorPtr=M(v.color);v._foregroundColorPtr=T;v._backgroundColorPtr=T;v._decorationColorPtr=T;v.foregroundColor&&(v._foregroundColorPtr=M(v.foregroundColor,N));v.backgroundColor&&(v._backgroundColorPtr= M(v.backgroundColor,Q));v.decorationColor&&(v._decorationColorPtr=M(v.decorationColor,S));Array.isArray(v.fontFamilies)&&v.fontFamilies.length?(v._fontFamiliesPtr=l(v.fontFamilies),v._fontFamiliesLen=v.fontFamilies.length):(v._fontFamiliesPtr=T,v._fontFamiliesLen=0)}function D(v){d._free(v._fontFamiliesPtr)}d.Paragraph.prototype.getRectsForRange=function(v,I,R,ba){v=this._getRectsForRange(v,I,R,ba);return e(v)};d.Paragraph.prototype.getRectsForPlaceholders=function(){var v=this._getRectsForPlaceholders(); return e(v)};d.TypefaceFontProvider.prototype.registerFont=function(v,I){v=d.FontMgr.RefDefault().MakeTypefaceFromData(v);if(!v)return null;I=q(I);this._registerFont(v,I)};d.ParagraphStyle=function(v){v.disableHinting=v.disableHinting||!1;if(v.ellipsis){var I=v.ellipsis;v._ellipsisPtr=q(I);v._ellipsisLen=na(I)+1}else v._ellipsisPtr=T,v._ellipsisLen=0;v.heightMultiplier=v.heightMultiplier||0;v.maxLines=v.maxLines||0;v.textAlign=v.textAlign||d.TextAlign.Start;v.textDirection=v.textDirection||d.TextDirection.LTR; v.textStyle=d.TextStyle(v.textStyle);I=(I=v.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=T,I._fontFamiliesLen=0);I.fontStyle=g(I.fontStyle);I.fontSize=I.fontSize||0;I.heightMultiplier=I.heightMultiplier||0;I.leading=I.leading||0;I.forceStrutHeight=I.forceStrutHeight||!1;v.strutStyle=I;return v};d.TextStyle=function(v){v.color|| (v.color=d.BLACK);v.decoration=v.decoration||0;v.decorationThickness=v.decorationThickness||0;v.decorationStyle=v.decorationStyle||d.DecorationStyle.Solid;v.textBaseline=v.textBaseline||d.TextBaseline.Alphabetic;v.fontSize=v.fontSize||0;v.letterSpacing=v.letterSpacing||0;v.wordSpacing=v.wordSpacing||0;v.heightMultiplier=v.heightMultiplier||0;if(v.locale){var I=v.locale;v._localePtr=q(I);v._localeLen=na(I)+1}else v._localePtr=T,v._localeLen=0;v.fontStyle=g(v.fontStyle);if(v.shadows){I=v.shadows;var R= I.map(function(F){return F.color||d.BLACK}),ba=I.map(function(F){return F.blurRadius||0});v._shadowLen=I.length;for(var qa=d._malloc(2*I.length,"HEAPF32"),va=qa/4,wa=0;wa<I.length;wa++){var ka=I[wa].offset||[0,0];d.HEAPF32[va]=ka[0];d.HEAPF32[va+1]=ka[1];va+=2}v._shadowColorsPtr=H(R).Zd;v._shadowOffsetsPtr=qa;v._shadowBlurRadiiPtr=w(ba,"HEAPF32")}else v._shadowLen=0,v._shadowColorsPtr=T,v._shadowOffsetsPtr=T,v._shadowBlurRadiiPtr=T;v.fontFeatures?(I=v.fontFeatures,R=I.map(function(F){return F.name}), ba=I.map(function(F){return F.value}),v._fontFeatureLen=I.length,v._fontFeatureNamesPtr=l(R),v._fontFeatureValuesPtr=w(ba,"HEAPU32")):(v._fontFeatureLen=0,v._fontFeatureNamesPtr=T,v._fontFeatureValuesPtr=T);return v};var J={},N=d._malloc(16),Q=d._malloc(16),S=d._malloc(16);d.ParagraphBuilder.Make=function(v,I){z(v.textStyle);I=d.ParagraphBuilder._Make(v,I);D(v.textStyle);return I};d.ParagraphBuilder.MakeFromFontProvider=function(v,I){z(v.textStyle);I=d.ParagraphBuilder._MakeFromFontProvider(v,I); D(v.textStyle);return I};d.ParagraphBuilder.prototype.pushStyle=function(v){z(v);this._pushStyle(v);D(v)};d.ParagraphBuilder.prototype.pushPaintStyle=function(v,I,R){z(v);this._pushPaintStyle(v,I,R);D(v)};d.ParagraphBuilder.prototype.addPlaceholder=function(v,I,R,ba,qa){R=R||d.PlaceholderAlignment.Baseline;ba=ba||d.TextBaseline.Alphabetic;this._addPlaceholder(v||0,I||0,R,ba,qa||0)}})})(r);a.Sd=a.Sd||[];a.Sd.push(function(){a.Path.prototype.op=function(d,e){return this._op(d,e)?this:null};a.Path.prototype.simplify= function(){return this._simplify()?this:null}});a.Sd=a.Sd||[];a.Sd.push(function(){a.Canvas.prototype.drawText=function(d,e,g,l,q){if("string"===typeof d){var z=na(d),D=a._malloc(z+1);ra(d,G,D,z+1);this._drawSimpleText(D,z,e,g,q,l);a._free(D)}else this._drawShapedText(d,e,g,l)};a.Font.prototype.getGlyphBounds=function(d,e,g){var l=w(d,"HEAPU16"),q=a._malloc(16*d.length);this._getGlyphWidthBounds(l,d.length,T,q,e||null);e=new Float32Array(a.HEAPU8.buffer,q,4*d.length);x(l,d);if(g)return g.set(e),a._free(q), g;d=Float32Array.from(e);a._free(q);return d};a.Font.prototype.getGlyphIDs=function(d,e,g){e||(e=d.length);var l=na(d)+1,q=a._malloc(l);ra(d,G,q,l);d=a._malloc(2*e);e=this._getGlyphIDs(q,l-1,e,d);a._free(q);if(0>e)return a._free(d),null;q=new Uint16Array(a.HEAPU8.buffer,d,e);if(g)return g.set(q),a._free(d),g;g=Uint32Array.from(q);a._free(d);return g};a.Font.prototype.getGlyphWidths=function(d,e,g){var l=w(d,"HEAPU16"),q=a._malloc(4*d.length);this._getGlyphWidthBounds(l,d.length,q,T,e||null);e=new Float32Array(a.HEAPU8.buffer, q,d.length);x(l,d);if(g)return g.set(e),a._free(q),g;d=Float32Array.from(e);a._free(q);return d};a.Font.prototype.getWidths=function(d){var e=d.length+1,g=na(d)+1,l=a._malloc(g);ra(d,G,l,g);d=a._malloc(4*e);if(!this._getWidths(l,g,e,d))return a._free(l),a._free(d),null;e=new Float32Array(a.HEAPU8.buffer,d,e);e=Array.from(e);a._free(l);a._free(d);return e};a.FontMgr.FromData=function(){if(!arguments.length)return null;var d=arguments;1===d.length&&Array.isArray(d[0])&&(d=arguments[0]);if(!d.length)return null; for(var e=[],g=[],l=0;l<d.length;l++){var q=new Uint8Array(d[l]),z=w(q,"HEAPU8");e.push(z);g.push(q.byteLength)}e=w(e,"HEAPU32");g=w(g,"HEAPU32");d=a.FontMgr._fromData(e,g,d.length);a._free(e);a._free(g);return d};a.FontMgr.prototype.MakeTypefaceFromData=function(d){d=new Uint8Array(d);var e=w(d,"HEAPU8");return(d=this._makeTypefaceFromData(e,d.byteLength))?d:null};a.ShapedText.prototype.getBounds=function(d){this._getBounds(ia);var e=ya.toTypedArray();return d?(d.set(e),d):e.slice()};a.TextBlob.MakeOnPath= function(d,e,g,l){if(d&&d.length&&e&&e.countPoints()){if(1===e.countPoints())return this.MakeFromText(d,g);l||(l=0);var q=g.getWidths(d),z=new a.RSXFormBuilder;e=new a.ContourMeasureIter(e,!1,1);for(var D=e.next(),J=new Float32Array(4),N=0;N<d.length&&D;N++){var Q=q[N];l+=Q/2;if(l>D.length()){D.delete();D=e.next();if(!D){d=d.substring(0,N);break}l=Q/2}D.getPosTan(l,J);var S=J[2],v=J[3];z.push(S,v,J[0]-Q/2*S,J[1]-Q/2*v);l+=Q/2}d=this.MakeFromRSXform(d,z,g);z.delete();D&&D.delete();e.delete();return d}}; a.TextBlob.MakeFromRSXform=function(d,e,g){var l=na(d)+1,q=a._malloc(l);ra(d,G,q,l);d=T;e.build?d=e.build():d=w(e,"HEAPF32");e=a.TextBlob._MakeFromRSXform(q,l-1,d,g);a._free(q);return e?e:null};a.TextBlob.MakeFromRSXformGlyphs=function(d,e,g){var l=w(d,"HEAPU16"),q=T;e.build?q=e.build():q=w(e,"HEAPF32");e=a.TextBlob._MakeFromRSXformGlyphs(l,2*d.length,q,g);x(l,d);return e?e:null};a.TextBlob.MakeFromGlyphs=function(d,e){var g=w(d,"HEAPU16");e=a.TextBlob._MakeFromGlyphs(g,2*d.length,e);x(g,d);return e? e:null};a.TextBlob.MakeFromText=function(d,e){var g=na(d)+1,l=a._malloc(g);ra(d,G,l,g);d=a.TextBlob._MakeFromText(l,g-1,e);a._free(l);return d?d:null};a.MallocGlyphIDs=function(d){return a.Malloc(Uint16Array,d)}});a.Sd=a.Sd||[];a.Sd.push(function(){a.MakePicture=function(d){d=new Uint8Array(d);var e=a._malloc(d.byteLength);a.HEAPU8.set(d,e);return(d=a._MakePicture(e,d.byteLength))?d:null};a.Picture.prototype.saveAsFile=function(d){var e=this.serialize();if(e){var g=a.getDataBytes(e);Bb(g,d);e.delete()}}}); (function(){function d(F){for(var k=0;k<F.length;k++)if(void 0!==F[k]&&!Number.isFinite(F[k]))return!1;return!0}function e(F){var k=a.getColorComponents(F);F=k[0];var n=k[1],y=k[2];k=k[3];if(1===k)return F=F.toString(16).toLowerCase(),n=n.toString(16).toLowerCase(),y=y.toString(16).toLowerCase(),F=1===F.length?"0"+F:F,n=1===n.length?"0"+n:n,y=1===y.length?"0"+y:y,"#"+F+n+y;k=0===k||1===k?k:k.toFixed(8);return"rgba("+F+", "+n+", "+y+", "+k+")"}function g(F){return a.parseColorString(F,va)}function l(F){F= wa.exec(F);if(!F)return null;var k=parseFloat(F[4]),n=16;switch(F[5]){case "em":case "rem":n=16*k;break;case "pt":n=4*k/3;break;case "px":n=k;break;case "pc":n=16*k;break;case "in":n=96*k;break;case "cm":n=96*k/2.54;break;case "mm":n=96/25.4*k;break;case "q":n=96/25.4/4*k;break;case "%":n=16/75*k}return{style:F[1],variant:F[2],weight:F[3],sizePx:n,family:F[6].trim()}}function q(F){this.Jd=F;this.Ld=new a.Paint;this.Ld.setAntiAlias(!0);this.Ld.setStrokeMiter(10);this.Ld.setStrokeCap(a.StrokeCap.Butt); this.Ld.setStrokeJoin(a.StrokeJoin.Miter);this.Se="10px monospace";this.pe=new a.Font(null,10);this.pe.setSubpixel(!0);this.Yd=this.de=a.BLACK;this.se=0;this.Ie=a.TRANSPARENT;this.ue=this.te=0;this.Je=this.fe=1;this.He=0;this.re=[];this.Kd=a.BlendMode.SrcOver;this.Ld.setStrokeWidth(this.Je);this.Ld.setBlendMode(this.Kd);this.Od=new a.Path;this.Pd=a.Matrix.identity();this.kf=[];this.ye=[];this.he=function(){this.Od.delete();this.Ld.delete();this.pe.delete();this.ye.forEach(function(k){k.he()})};Object.defineProperty(this, "currentTransform",{enumerable:!0,get:function(){return{a:this.Pd[0],c:this.Pd[1],e:this.Pd[2],b:this.Pd[3],d:this.Pd[4],f:this.Pd[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.Yd)?e(this.Yd):this.Yd},set:function(k){"string"===typeof k?this.Yd=g(k):k.qe&&(this.Yd=k)}});Object.defineProperty(this,"font",{enumerable:!0,get:function(){return this.Se},set:function(k){var n=l(k),y=n.family;n.typeface= ka[y]?ka[y][(n.style||"normal")+"|"+(n.variant||"normal")+"|"+(n.weight||"normal")]||ka[y]["*"]:null;n&&(this.pe.setSize(n.sizePx),this.pe.setTypeface(n.typeface),this.Se=k)}});Object.defineProperty(this,"globalAlpha",{enumerable:!0,get:function(){return this.fe},set:function(k){!isFinite(k)||0>k||1<k||(this.fe=k)}});Object.defineProperty(this,"globalCompositeOperation",{enumerable:!0,get:function(){switch(this.Kd){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.Kd=a.BlendMode.SrcOver;break;case "destination-over":this.Kd=a.BlendMode.DstOver;break;case "copy":this.Kd=a.BlendMode.Src;break;case "destination":this.Kd=a.BlendMode.Dst;break;case "clear":this.Kd=a.BlendMode.Clear;break;case "source-in":this.Kd=a.BlendMode.SrcIn;break;case "destination-in":this.Kd=a.BlendMode.DstIn;break;case "source-out":this.Kd=a.BlendMode.SrcOut;break;case "destination-out":this.Kd= a.BlendMode.DstOut;break;case "source-atop":this.Kd=a.BlendMode.SrcATop;break;case "destination-atop":this.Kd=a.BlendMode.DstATop;break;case "xor":this.Kd=a.BlendMode.Xor;break;case "lighter":this.Kd=a.BlendMode.Plus;break;case "plus-lighter":this.Kd=a.BlendMode.Plus;break;case "plus-darker":throw"plus-darker is not supported";case "multiply":this.Kd=a.BlendMode.Multiply;break;case "screen":this.Kd=a.BlendMode.Screen;break;case "overlay":this.Kd=a.BlendMode.Overlay;break;case "darken":this.Kd=a.BlendMode.Darken; break;case "lighten":this.Kd=a.BlendMode.Lighten;break;case "color-dodge":this.Kd=a.BlendMode.ColorDodge;break;case "color-burn":this.Kd=a.BlendMode.ColorBurn;break;case "hard-light":this.Kd=a.BlendMode.HardLight;break;case "soft-light":this.Kd=a.BlendMode.SoftLight;break;case "difference":this.Kd=a.BlendMode.Difference;break;case "exclusion":this.Kd=a.BlendMode.Exclusion;break;case "hue":this.Kd=a.BlendMode.Hue;break;case "saturation":this.Kd=a.BlendMode.Saturation;break;case "color":this.Kd=a.BlendMode.Color; break;case "luminosity":this.Kd=a.BlendMode.Luminosity;break;default:return}this.Ld.setBlendMode(this.Kd)}});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.Ld.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.Ld.setStrokeCap(a.StrokeCap.Butt);break;case "round":this.Ld.setStrokeCap(a.StrokeCap.Round);break;case "square":this.Ld.setStrokeCap(a.StrokeCap.Square)}}});Object.defineProperty(this,"lineDashOffset",{enumerable:!0,get:function(){return this.He},set:function(k){isFinite(k)&&(this.He=k)}});Object.defineProperty(this,"lineJoin",{enumerable:!0,get:function(){switch(this.Ld.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.Ld.setStrokeJoin(a.StrokeJoin.Miter);break;case "round":this.Ld.setStrokeJoin(a.StrokeJoin.Round);break;case "bevel":this.Ld.setStrokeJoin(a.StrokeJoin.Bevel)}}});Object.defineProperty(this,"lineWidth",{enumerable:!0,get:function(){return this.Ld.getStrokeWidth()},set:function(k){0>=k||!k||(this.Je=k,this.Ld.setStrokeWidth(k))}});Object.defineProperty(this,"miterLimit",{enumerable:!0, get:function(){return this.Ld.getStrokeMiter()},set:function(k){0>=k||!k||this.Ld.setStrokeMiter(k)}});Object.defineProperty(this,"shadowBlur",{enumerable:!0,get:function(){return this.se},set:function(k){0>k||!isFinite(k)||(this.se=k)}});Object.defineProperty(this,"shadowColor",{enumerable:!0,get:function(){return e(this.Ie)},set:function(k){this.Ie=g(k)}});Object.defineProperty(this,"shadowOffsetX",{enumerable:!0,get:function(){return this.te},set:function(k){isFinite(k)&&(this.te=k)}});Object.defineProperty(this, "shadowOffsetY",{enumerable:!0,get:function(){return this.ue},set:function(k){isFinite(k)&&(this.ue=k)}});Object.defineProperty(this,"strokeStyle",{enumerable:!0,get:function(){return e(this.de)},set:function(k){"string"===typeof k?this.de=g(k):k.qe&&(this.de=k)}});this.arc=function(k,n,y,B,C,E){v(this.Od,k,n,y,y,0,B,C,E)};this.arcTo=function(k,n,y,B,C){N(this.Od,k,n,y,B,C)};this.beginPath=function(){this.Od.delete();this.Od=new a.Path};this.bezierCurveTo=function(k,n,y,B,C,E){var K=this.Od;d([k, n,y,B,C,E])&&(K.isEmpty()&&K.moveTo(k,n),K.cubicTo(k,n,y,B,C,E))};this.clearRect=function(k,n,y,B){this.Ld.setStyle(a.PaintStyle.Fill);this.Ld.setBlendMode(a.BlendMode.Clear);this.Jd.drawRect(a.XYWHRect(k,n,y,B),this.Ld);this.Ld.setBlendMode(this.Kd)};this.clip=function(k,n){"string"===typeof k?(n=k,k=this.Od):k&&k.Ze&&(k=k.Rd);k||(k=this.Od);k=k.copy();n&&"evenodd"===n.toLowerCase()?k.setFillType(a.FillType.EvenOdd):k.setFillType(a.FillType.Winding);this.Jd.clipPath(k,a.ClipOp.Intersect,!0);k.delete()}; this.closePath=function(){Q(this.Od)};this.createImageData=function(){if(1===arguments.length){var k=arguments[0];return new D(new Uint8ClampedArray(4*k.width*k.height),k.width,k.height)}if(2===arguments.length){k=arguments[0];var n=arguments[1];return new D(new Uint8ClampedArray(4*k*n),k,n)}throw"createImageData expects 1 or 2 arguments, got "+arguments.length;};this.createLinearGradient=function(k,n,y,B){if(d(arguments)){var C=new J(k,n,y,B);this.ye.push(C);return C}};this.createPattern=function(k, n){k=new ba(k,n);this.ye.push(k);return k};this.createRadialGradient=function(k,n,y,B,C,E){if(d(arguments)){var K=new qa(k,n,y,B,C,E);this.ye.push(K);return K}};this.drawImage=function(k){var n=this.Re();if(3===arguments.length||5===arguments.length)var y=a.XYWHRect(arguments[1],arguments[2],arguments[3]||k.width(),arguments[4]||k.height()),B=a.XYWHRect(0,0,k.width(),k.height());else if(9===arguments.length)y=a.XYWHRect(arguments[5],arguments[6],arguments[7],arguments[8]),B=a.XYWHRect(arguments[1], arguments[2],arguments[3],arguments[4]);else throw"invalid number of args for drawImage, need 3, 5, or 9; got "+arguments.length;this.Jd.drawImageRect(k,B,y,n,!1);n.dispose()};this.ellipse=function(k,n,y,B,C,E,K,Z){v(this.Od,k,n,y,B,C,E,K,Z)};this.Re=function(){var k=this.Ld.copy();k.setStyle(a.PaintStyle.Fill);if(f(this.Yd)){var n=a.multiplyByAlpha(this.Yd,this.fe);k.setColor(n)}else n=this.Yd.qe(this.Pd),k.setColor(a.Color(0,0,0,this.fe)),k.setShader(n);k.dispose=function(){this.delete()};return k}; this.fill=function(k,n){"string"===typeof k?(n=k,k=this.Od):k&&k.Ze&&(k=k.Rd);if("evenodd"===n)this.Od.setFillType(a.FillType.EvenOdd);else{if("nonzero"!==n&&n)throw"invalid fill rule";this.Od.setFillType(a.FillType.Winding)}k||(k=this.Od);n=this.Re();var y=this.ve(n);y&&(this.Jd.save(),this.ne(),this.Jd.drawPath(k,y),this.Jd.restore(),y.dispose());this.Jd.drawPath(k,n);n.dispose()};this.fillRect=function(k,n,y,B){var C=this.Re(),E=this.ve(C);E&&(this.Jd.save(),this.ne(),this.Jd.drawRect(a.XYWHRect(k, n,y,B),E),this.Jd.restore(),E.dispose());this.Jd.drawRect(a.XYWHRect(k,n,y,B),C);C.dispose()};this.fillText=function(k,n,y){var B=this.Re();k=a.TextBlob.MakeFromText(k,this.pe);var C=this.ve(B);C&&(this.Jd.save(),this.ne(),this.Jd.drawTextBlob(k,n,y,C),this.Jd.restore(),C.dispose());this.Jd.drawTextBlob(k,n,y,B);k.delete();B.dispose()};this.getImageData=function(k,n,y,B){return(k=this.Jd.readPixels(k,n,{width:y,height:B,colorType:a.ColorType.RGBA_8888,alphaType:a.AlphaType.Unpremul,colorSpace:a.ColorSpace.SRGB}))? new D(new Uint8ClampedArray(k.buffer),y,B):null};this.getLineDash=function(){return this.re.slice()};this.lf=function(k){var n=a.Matrix.invert(this.Pd);a.Matrix.mapPoints(n,k);return k};this.isPointInPath=function(k,n,y){var B=arguments;if(3===B.length)var C=this.Od;else if(4===B.length)C=B[0],k=B[1],n=B[2],y=B[3];else throw"invalid arg count, need 3 or 4, got "+B.length;if(!isFinite(k)||!isFinite(n))return!1;y=y||"nonzero";if("nonzero"!==y&&"evenodd"!==y)return!1;B=this.lf([k,n]);k=B[0];n=B[1];C.setFillType("nonzero"=== y?a.FillType.Winding:a.FillType.EvenOdd);return C.contains(k,n)};this.isPointInStroke=function(k,n){var y=arguments;if(2===y.length)var B=this.Od;else if(3===y.length)B=y[0],k=y[1],n=y[2];else throw"invalid arg count, need 2 or 3, got "+y.length;if(!isFinite(k)||!isFinite(n))return!1;y=this.lf([k,n]);k=y[0];n=y[1];B=B.copy();B.setFillType(a.FillType.Winding);B.stroke({width:this.lineWidth,miter_limit:this.miterLimit,cap:this.Ld.getStrokeCap(),join:this.Ld.getStrokeJoin(),precision:.3});y=B.contains(k, n);B.delete();return y};this.lineTo=function(k,n){I(this.Od,k,n)};this.measureText=function(){throw Error("Clients wishing to properly measure text should use the Paragraph API");};this.moveTo=function(k,n){var y=this.Od;d([k,n])&&y.moveTo(k,n)};this.putImageData=function(k,n,y,B,C,E,K){if(d([n,y,B,C,E,K]))if(void 0===B)this.Jd.writePixels(k.data,k.width,k.height,n,y);else if(B=B||0,C=C||0,E=E||k.width,K=K||k.height,0>E&&(B+=E,E=Math.abs(E)),0>K&&(C+=K,K=Math.abs(K)),0>B&&(E+=B,B=0),0>C&&(K+=C,C= 0),!(0>=E||0>=K)){k=a.MakeImage({width:k.width,height:k.height,alphaType:a.AlphaType.Unpremul,colorType:a.ColorType.RGBA_8888,colorSpace:a.ColorSpace.SRGB},k.data,4*k.width);var Z=a.XYWHRect(B,C,E,K);n=a.XYWHRect(n+B,y+C,E,K);y=a.Matrix.invert(this.Pd);this.Jd.save();this.Jd.concat(y);this.Jd.drawImageRect(k,Z,n,null,!1);this.Jd.restore();k.delete()}};this.quadraticCurveTo=function(k,n,y,B){var C=this.Od;d([k,n,y,B])&&(C.isEmpty()&&C.moveTo(k,n),C.quadTo(k,n,y,B))};this.rect=function(k,n,y,B){var C= this.Od;k=a.XYWHRect(k,n,y,B);d(k)&&C.addRect(k)};this.resetTransform=function(){this.Od.transform(this.Pd);var k=a.Matrix.invert(this.Pd);this.Jd.concat(k);this.Pd=this.Jd.getTotalMatrix()};this.restore=function(){var k=this.kf.pop();if(k){var n=a.Matrix.multiply(this.Pd,a.Matrix.invert(k