@antv/g-mobile-canvas
Version:
A renderer implemented with Canvas2D API in mobile environment
50 lines • 76 kB
JavaScript
/*!
* @antv/g-mobile-canvas
* @description A renderer implemented with Canvas2D API in mobile environment
* @version 1.0.35
* @date 1/17/2025, 2:09:53 PM
* @author AntVis
* @docs https://g.antv.antgroup.com/
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).G=e.G||{},e.G.MobileCanvas2D={}),e.window.G)}(this,(function(e,t){"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function n(e){var t=function(e,t){if("object"!=r(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==r(t)?t:t+""}function i(e,t){for(var r=0;t.length>r;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,n(i.key),i)}}function a(e,t,r){return t&&i(e.prototype,t),r&&i(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},s(e)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(l=function(){return!!e})()}function c(e,t){if(t&&("object"==r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function u(e,t,r){return t=s(t),c(e,l()?Reflect.construct(t,r||[],s(e).constructor):t.apply(e,r))}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function f(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}function d(e,t,r){return(t=n(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);t>r;r++)n[r]=e[r];return n}function p(e,t){if(e){if("string"==typeof e)return v(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?v(e,t):void 0}}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,a,o,s=[],l=!0,c=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=a.call(r)).done)&&(s.push(n.value),s.length!==t);l=!0);}catch(e){c=!0,i=e}finally{try{if(!l&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(c)throw i}}return s}}(e,t)||p(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e){return null==e}function m(e){return"string"==typeof e}var b=function(e,t,r){return t>e?t:e>r?r:e},x="undefined"!=typeof Float32Array?Float32Array:Array;function S(){var e=new x(16);return x!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function w(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function k(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3],s=t[4],l=t[5],c=t[6],u=t[7],h=t[8],f=t[9],d=t[10],v=t[11],p=t[12],y=t[13],g=t[14],m=t[15],b=r[0],x=r[1],S=r[2],w=r[3];return e[0]=b*n+x*s+S*h+w*p,e[1]=b*i+x*l+S*f+w*y,e[2]=b*a+x*c+S*d+w*g,e[3]=b*o+x*u+S*v+w*m,e[4]=(b=r[4])*n+(x=r[5])*s+(S=r[6])*h+(w=r[7])*p,e[5]=b*i+x*l+S*f+w*y,e[6]=b*a+x*c+S*d+w*g,e[7]=b*o+x*u+S*v+w*m,e[8]=(b=r[8])*n+(x=r[9])*s+(S=r[10])*h+(w=r[11])*p,e[9]=b*i+x*l+S*f+w*y,e[10]=b*a+x*c+S*d+w*g,e[11]=b*o+x*u+S*v+w*m,e[12]=(b=r[12])*n+(x=r[13])*s+(S=r[14])*h+(w=r[15])*p,e[13]=b*i+x*l+S*f+w*y,e[14]=b*a+x*c+S*d+w*g,e[15]=b*o+x*u+S*v+w*m,e}function M(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]}function E(){var e=new x(3);return x!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function T(e,t,r,n){return e[0]=t,e[1]=r,e[2]=n,e}function P(e,t,r){var n=t[0],i=t[1],a=t[2],o=r[3]*n+r[7]*i+r[11]*a+r[15];return e[0]=(r[0]*n+r[4]*i+r[8]*a+r[12])/(o=o||1),e[1]=(r[1]*n+r[5]*i+r[9]*a+r[13])/o,e[2]=(r[2]*n+r[6]*i+r[10]*a+r[14])/o,e}function O(e,t,r){return{x:e*Math.cos(r)-t*Math.sin(r),y:e*Math.sin(r)+t*Math.cos(r)}}function C(e,t,r,n,i,a,o,s,l,c){var u,h,f,d,v,p=e,y=t,g=r,m=n,b=s,x=l,S=120*Math.PI/180,w=Math.PI/180*(+i||0),k=[];if(c)h=c[0],f=c[1],d=c[2],v=c[3];else{y=(u=O(p,y,-w)).y;var M=((p=u.x)-(b=(u=O(b,x,-w)).x))/2,E=(y-(x=u.y))/2,T=M*M/(g*g)+E*E/(m*m);T>1&&(g*=T=Math.sqrt(T),m*=T);var P=g*g,A=m*m,R=(a===o?-1:1)*Math.sqrt(Math.abs((P*A-P*E*E-A*M*M)/(P*E*E+A*M*M)));d=R*g*E/m+(p+b)/2,h=Math.asin(((y-(v=R*-m*M/g+(y+x)/2))/m*1e9|0)/1e9),f=Math.asin(((x-v)/m*1e9|0)/1e9),0>(h=d>p?Math.PI-h:h)&&(h=2*Math.PI+h),0>(f=d>b?Math.PI-f:f)&&(f=2*Math.PI+f),o&&h>f&&(h-=2*Math.PI),!o&&f>h&&(f-=2*Math.PI)}var L=f-h;if(Math.abs(L)>S){var D=f,I=b,F=x;k=C(b=d+g*Math.cos(f=h+S*(o&&f>h?1:-1)),x=v+m*Math.sin(f),g,m,i,0,o,I,F,[f,D,d,v])}L=f-h;var j=Math.cos(h),N=Math.sin(h),B=Math.cos(f),G=Math.sin(f),_=Math.tan(L/4),W=4/3*g*_,z=4/3*m*_,Y=[p,y],H=[p+W*N,y-z*j],X=[b+W*G,x-z*B],U=[b,x];if(H[0]=2*Y[0]-H[0],H[1]=2*Y[1]-H[1],c)return H.concat(X,U,k);for(var V=[],q=0,Q=(k=H.concat(X,U,k)).length;Q>q;q+=1)V[q]=q%2?O(k[q-1],k[q],w).y:O(k[q],k[q+1],w).x;return V}
/*!
* @antv/g-plugin-canvas-path-generator
* @description A G plugin of path generator with Canvas2D API
* @version 2.1.15
* @date 1/17/2025, 2:06:42 PM
* @author AntVis
* @docs https://g.antv.antgroup.com/
*/
function A(e,t){var r=t.cx,n=t.cy;e.arc(void 0===r?0:r,void 0===n?0:n,t.r,0,2*Math.PI,!1)}function R(e,t){var r=t.cx,n=void 0===r?0:r,i=t.cy,a=void 0===i?0:i,o=t.rx,s=t.ry;if(e.ellipse)e.ellipse(n,a,o,s,0,0,2*Math.PI,!1);else{var l=o>s?o:s,c=o>s?1:o/s,u=o>s?s/o:1;e.save(),e.scale(c,u),e.arc(n,a,l,0,2*Math.PI)}}function L(e,r){var n=r.x1,i=r.y1,a=r.x2,o=r.y2,s=r.markerStart,l=r.markerEnd,c=r.markerStartOffset,u=r.markerEndOffset,h=0,f=0,d=0,v=0,p=0;s&&t.isDisplayObject(s)&&c&&(h=Math.cos(p=Math.atan2(o-i,a-n))*(c||0),f=Math.sin(p)*(c||0)),l&&t.isDisplayObject(l)&&u&&(d=Math.cos(p=Math.atan2(i-o,n-a))*(u||0),v=Math.sin(p)*(u||0)),e.moveTo(n+h,i+f),e.lineTo(a+d,o+v)}function D(e,r){var n=r.markerStart,i=r.markerEnd,a=r.markerStartOffset,o=r.markerEndOffset,s=r.d,l=s.absolutePath,c=s.segments,u=0,h=0,f=0,d=0,v=0;if(n&&t.isDisplayObject(n)&&a){var p=y(n.parentNode.getStartTangent(),2),g=p[0],m=p[1];u=Math.cos(v=Math.atan2(g[1]-m[1],g[0]-m[0]))*(a||0),h=Math.sin(v)*(a||0)}if(i&&t.isDisplayObject(i)&&o){var b=y(i.parentNode.getEndTangent(),2),x=b[0],S=b[1];f=Math.cos(v=Math.atan2(x[1]-S[1],x[0]-S[0]))*(o||0),d=Math.sin(v)*(o||0)}for(var w=0;l.length>w;w++){var k=l[w],M=k[0],E=l[w+1],T=(w===l.length-1||E&&("M"===E[0]||"Z"===E[0]))&&0!==f&&0!==d,P=y(0===w&&(0!==u||0!==h)?[u,h]:[0,0],2),O=P[0],C=P[1],A=y(T?[f,d]:[0,0],2),R=A[0],L=A[1];switch(M){case"M":e.moveTo(k[1]+O,k[2]+C);break;case"L":e.lineTo(k[1]+R,k[2]+L);break;case"Q":e.quadraticCurveTo(k[1],k[2],k[3]+R,k[4]+L);break;case"C":e.bezierCurveTo(k[1],k[2],k[3],k[4],k[5]+R,k[6]+L);break;case"A":var D=c[w].arcParams,I=D.cx,F=D.cy,j=D.rx,N=D.ry,B=D.startAngle,G=D.endAngle,_=D.xRotation,W=D.sweepFlag;if(e.ellipse)e.ellipse(I,F,j,N,_,B,G,!!(1-W));else{var z=j>N?j:N,Y=j>N?1:j/N,H=j>N?N/j:1;e.translate(I,F),e.rotate(_),e.scale(Y,H),e.arc(0,0,z,B,G,!!(1-W)),e.scale(1/Y,1/H),e.rotate(-_),e.translate(-I,-F)}T&&e.lineTo(k[6]+f,k[7]+d);break;case"Z":e.closePath()}}}function I(e,r){var n=r.markerStart,i=r.markerEnd,a=r.markerStartOffset,o=r.markerEndOffset,s=r.points.points,l=s.length,c=s[0][0],u=s[0][1],h=s[l-1][0],f=s[l-1][1],d=0,v=0,p=0,y=0,g=0;n&&t.isDisplayObject(n)&&a&&(d=Math.cos(g=Math.atan2(s[1][1]-s[0][1],s[1][0]-s[0][0]))*(a||0),v=Math.sin(g)*(a||0)),i&&t.isDisplayObject(i)&&o&&(p=Math.cos(g=Math.atan2(s[l-1][1]-s[0][1],s[l-1][0]-s[0][0]))*(o||0),y=Math.sin(g)*(o||0)),e.moveTo(c+(d||p),u+(v||y));for(var m=1;l-1>m;m++){var b=s[m];e.lineTo(b[0],b[1])}e.lineTo(h,f)}function F(e,r){var n=r.markerStart,i=r.markerEnd,a=r.markerStartOffset,o=r.markerEndOffset,s=r.points.points,l=s.length,c=s[0][0],u=s[0][1],h=s[l-1][0],f=s[l-1][1],d=0,v=0,p=0,y=0,g=0;n&&t.isDisplayObject(n)&&a&&(d=Math.cos(g=Math.atan2(s[1][1]-s[0][1],s[1][0]-s[0][0]))*(a||0),v=Math.sin(g)*(a||0)),i&&t.isDisplayObject(i)&&o&&(p=Math.cos(g=Math.atan2(s[l-2][1]-s[l-1][1],s[l-2][0]-s[l-1][0]))*(o||0),y=Math.sin(g)*(o||0)),e.moveTo(c+d,u+v);for(var m=1;l-1>m;m++){var b=s[m];e.lineTo(b[0],b[1])}e.lineTo(h+p,f+y)}function j(e,t){var r=t.x,n=void 0===r?0:r,i=t.y,a=void 0===i?0:i,o=t.radius,s=t.width,l=t.height,c=s,u=l;if(o&&o.some((function(e){return 0!==e}))){var h=s>0?1:-1,f=l>0?1:-1,d=h+f===0,v=y(o.map((function(e){return b(e,0,Math.min(Math.abs(c)/2,Math.abs(u)/2))})),4),p=v[0],g=v[1],m=v[2],x=v[3];e.moveTo(h*p+n,a),e.lineTo(c-h*g+n,a),0!==g&&e.arc(c-h*g+n,f*g+a,g,-f*Math.PI/2,h>0?0:Math.PI,d),e.lineTo(c+n,u-f*m+a),0!==m&&e.arc(c-h*m+n,u-f*m+a,m,h>0?0:Math.PI,f>0?Math.PI/2:1.5*Math.PI,d),e.lineTo(h*x+n,u+a),0!==x&&e.arc(h*x+n,u-f*x+a,x,f>0?Math.PI/2:-Math.PI/2,h>0?Math.PI:0,d),e.lineTo(n,f*p+a),0!==p&&e.arc(h*p+n,f*p+a,p,h>0?Math.PI:0,f>0?1.5*Math.PI:Math.PI/2,d)}else e.rect(n,a,c,u)}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)}),E(),function(){var e,t=(e=new x(2),x!=Float32Array&&(e[0]=0,e[1]=0),e)}();var N=function(e){function r(){var e;o(this,r);for(var t=arguments.length,n=Array(t),i=0;t>i;i++)n[i]=arguments[i];return(e=u(this,r,[].concat(n))).name="canvas-path-generator",e}return f(r,e),a(r,[{key:"init",value:function(){var e,r=(d(d(d(d(d(d(d(d(d(d(e={},t.Shape.CIRCLE,A),t.Shape.ELLIPSE,R),t.Shape.RECT,j),t.Shape.LINE,L),t.Shape.POLYLINE,F),t.Shape.POLYGON,I),t.Shape.PATH,D),t.Shape.TEXT,void 0),t.Shape.GROUP,void 0),t.Shape.IMAGE,void 0),d(d(d(e,t.Shape.HTML,void 0),t.Shape.MESH,void 0),t.Shape.FRAGMENT,void 0));this.context.pathGeneratorFactory=r}},{key:"destroy",value:function(){delete this.context.pathGeneratorFactory}}])}(t.AbstractRendererPlugin);function B(){B=function(){return t};var e,t={},n=Object.prototype,i=n.hasOwnProperty,a=Object.defineProperty||function(e,t,r){e[t]=r.value},o="function"==typeof Symbol?Symbol:{},s=o.iterator||"@@iterator",l=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function h(e,t,r,n){var i=Object.create((t&&t.prototype instanceof m?t:m).prototype),o=new R(n||[]);return a(i,"_invoke",{value:P(e,r,o)}),i}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=h;var d="suspendedStart",v="suspendedYield",p="executing",y="completed",g={};function m(){}function b(){}function x(){}var S={};u(S,s,(function(){return this}));var w=Object.getPrototypeOf,k=w&&w(w(L([])));k&&k!==n&&i.call(k,s)&&(S=k);var M=x.prototype=m.prototype=Object.create(S);function E(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function T(e,t){function n(a,o,s,l){var c=f(e[a],e,o);if("throw"!==c.type){var u=c.arg,h=u.value;return h&&"object"==r(h)&&i.call(h,"__await")?t.resolve(h.__await).then((function(e){n("next",e,s,l)}),(function(e){n("throw",e,s,l)})):t.resolve(h).then((function(e){u.value=e,s(u)}),(function(e){return n("throw",e,s,l)}))}l(c.arg)}var o;a(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function P(t,r,n){var i=d;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:e,done:!0}}for(n.method=a,n.arg=o;;){var s=n.delegate;if(s){var l=O(s,n);if(l){if(l===g)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===d)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var c=f(t,r,n);if("normal"===c.type){if(i=n.done?y:v,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function O(t,r){var n=r.method,i=t.iterator[n];if(i===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,O(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var a=f(i,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,g;var o=a.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,g):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function C(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function R(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(C,this),this.reset(!0)}function L(t){if(t||""===t){var n=t[s];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,o=function r(){for(;++a<t.length;)if(i.call(t,a))return r.value=t[a],r.done=!1,r;return r.value=e,r.done=!0,r};return o.next=o}}throw new TypeError(r(t)+" is not iterable")}return b.prototype=x,a(M,"constructor",{value:x,configurable:!0}),a(x,"constructor",{value:b,configurable:!0}),b.displayName=u(x,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===b||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,x):(e.__proto__=x,u(e,c,"GeneratorFunction")),e.prototype=Object.create(M),e},t.awrap=function(e){return{__await:e}},E(T.prototype),u(T.prototype,l,(function(){return this})),t.AsyncIterator=T,t.async=function(e,r,n,i,a){void 0===a&&(a=Promise);var o=new T(h(e,r,n,i),a);return t.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},E(M),u(M,c,"Generator"),u(M,s,(function(){return this})),u(M,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=L,R.prototype={constructor:R,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(A),!t)for(var r in this)"t"===r.charAt(0)&&i.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function n(n,i){return s.type="throw",s.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return n("end");if(this.prev>=o.tryLoc){var l=i.call(o,"catchLoc"),c=i.call(o,"finallyLoc");if(l&&c){if(o.catchLoc>this.prev)return n(o.catchLoc,!0);if(o.finallyLoc>this.prev)return n(o.finallyLoc)}else if(l){if(o.catchLoc>this.prev)return n(o.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(this.prev>=n.tryLoc&&i.call(n,"finallyLoc")&&n.finallyLoc>this.prev){var a=n;break}}a&&("break"===e||"continue"===e)&&t>=a.tryLoc&&a.finallyLoc>=t&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,g):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),A(r),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;A(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:L(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),g}},t}function G(e,t,r,n,i,a,o){try{var s=e[a](o),l=s.value}catch(e){return void r(e)}s.done?t(l):Promise.resolve(l).then(n,i)}function _(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var a=e.apply(t,r);function o(e){G(a,n,i,o,s,"next",e)}function s(e){G(a,n,i,o,s,"throw",e)}o(void 0)}))}}function W(e){return function(e){if(Array.isArray(e))return v(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||p(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}
/*!
* @antv/g-math
* @description Geometry util
* @version 3.0.0
* @date 1/17/2025, 2:05:31 PM
* @author AntVis
* @docs https://g.antv.antgroup.com/
*/function z(e,t,r,n){var i=e-r,a=t-n;return Math.sqrt(i*i+a*a)}function Y(e,t,r,n,i,a){var o=-1,s=1/0,l=[r,n],c=20;a&&a>200&&(c=a/10);for(var u=1/c,h=u/10,f=0;c>=f;f++){var d=f*u,v=[i.apply(void 0,W(e.concat([d]))),i.apply(void 0,W(t.concat([d])))],p=z(l[0],l[1],v[0],v[1]);s>p&&(o=d,s=p)}if(0===o)return{x:e[0],y:t[0]};if(1===o){var y=e.length;return{x:e[y-1],y:t[y-1]}}s=1/0;for(var g=0;32>g&&1e-4<=h;g++){var m=o-h,b=o+h,x=[i.apply(void 0,W(e.concat([m]))),i.apply(void 0,W(t.concat([m])))],S=z(l[0],l[1],x[0],x[1]);if(m>=0&&s>S)o=m,s=S;else{var w=[i.apply(void 0,W(e.concat([b]))),i.apply(void 0,W(t.concat([b])))],k=z(l[0],l[1],w[0],w[1]);1>=b&&s>k?(o=b,s=k):h*=.5}}return{x:i.apply(void 0,W(e.concat([o]))),y:i.apply(void 0,W(t.concat([o])))}}function H(e,t,r,n,i,a){var o=[r-e,n-t];if(function(e,t){return e[0]===t[0]&&e[1]===t[1]}(o,[0,0]))return Math.sqrt((i-e)*(i-e)+(a-t)*(a-t));var s=[-o[1],o[0]];return function(e,t){var r=t[0],n=t[1],i=r*r+n*n;i>0&&(i=1/Math.sqrt(i)),e[0]=t[0]*i,e[1]=t[1]*i}(s,s),Math.abs(function(e,t){return e[0]*t[0]+e[1]*t[1]}([i-e,a-t],s))}function X(e,t,r,n,i){var a=1-i;return a*a*a*e+3*t*i*a*a+3*r*i*i*a+n*i*i*i}function U(e,t,r,n,i,a,o,s,l,c,u){var h=function(e,t,r,n,i,a,o,s,l,c,u){return Y([e,r,i,o],[t,n,a,s],l,c,X,u)}(e,t,r,n,i,a,o,s,l,c,u);return z(h.x,h.y,l,c)}function V(e,t,r,n){var i=1-n;return i*i*e+2*n*i*t+n*n*r}function q(e,t,r,n,i,a,o,s){var l=function(e,t,r,n,i,a,o,s){return Y([e,r,i],[t,n,a],o,s,V)}(e,t,r,n,i,a,o,s);return z(l.x,l.y,o,s)}function Q(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function $(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Q(Object(r),!0).forEach((function(t){d(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Q(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}
/*!
* @antv/g-plugin-canvas-picker
* @description A G plugin for picking in canvas
* @version 2.1.17
* @date 1/17/2025, 2:08:48 PM
* @author AntVis
* @docs https://g.antv.antgroup.com/
*/var J=E(),K=E(),Z=E(),ee=S(),te=function(){function e(){var r=this;o(this,e),this.isHit=function(e,n,i,a){var o,s,l,c,u,h,f,d,v,p,y,g,m,b,x,S,w,k,M,E,O,C,A,R,L,D,I,F,j,N,B,G=r.context.pointInPathPickerFactory[e.nodeName];if(G){var _=(o=ee,(B=(M=(l=(s=i)[0])*(d=s[5])-(c=s[1])*(f=s[4]))*(N=(m=s[10])*(k=s[15])-(b=s[11])*(w=s[14]))-(E=l*(v=s[6])-(u=s[2])*f)*(j=(g=s[9])*k-b*(S=s[13]))+(O=l*(p=s[7])-(h=s[3])*f)*(F=g*w-m*S)+(C=c*v-u*d)*(I=(y=s[8])*k-b*(x=s[12]))-(A=c*p-h*d)*(D=y*w-m*x)+(R=u*p-h*v)*(L=y*S-g*x))?(o[0]=(d*N-v*j+p*F)*(B=1/B),o[1]=(u*j-c*N-h*F)*B,o[2]=(S*R-w*A+k*C)*B,o[3]=(m*A-g*R-b*C)*B,o[4]=(v*I-f*N-p*D)*B,o[5]=(l*N-u*I+h*D)*B,o[6]=(w*O-x*R-k*E)*B,o[7]=(y*R-m*O+b*E)*B,o[8]=(f*j-d*I+p*L)*B,o[9]=(c*I-l*j-h*L)*B,o[10]=(x*A-S*O+k*M)*B,o[11]=(g*O-y*A-b*M)*B,o[12]=(d*D-f*F-v*L)*B,o[13]=(l*F-c*D+u*L)*B,o[14]=(S*E-x*C-w*M)*B,o[15]=(y*C-g*E+m*M)*B,o):null),W=P(K,T(Z,n[0],n[1],0),_);if(G(e,new t.Point(W[0],W[1]),a,r.isPointInPath,r.context,r.runtime))return!0}return!1},this.isPointInPath=function(e,t){var n=r.runtime.offscreenCanvasCreator.getOrCreateContext(r.context.config.offscreenCanvas),i=r.context.pathGeneratorFactory[e.nodeName];return i&&(n.beginPath(),i(n,e.parsedStyle),n.closePath()),n.isPointInPath(t.x,t.y)}}return a(e,[{key:"apply",value:function(t,r){var n,i=this,a=t.renderingService,o=t.renderingContext;this.context=t,this.runtime=r;var s=null===(n=o.root)||void 0===n?void 0:n.ownerDocument;a.hooks.pick.tapPromise(e.tag,function(){var e=_(B().mark((function e(t){return B().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",i.pick(s,t));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),a.hooks.pickSync.tap(e.tag,(function(e){return i.pick(s,e)}))}},{key:"pick",value:function(e,r){var n,i=r.topmost,a=r.position,o=T(J,a.x,a.y,0),s=[],l=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=p(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return e.length>n?{done:!1,value:e[n++]}:{done:!0}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}(e.elementsFromBBox(o[0],o[1],o[0],o[1]));try{for(l.s();!(n=l.n()).done;){var c=n.value,u=c.getWorldTransform();if(this.isHit(c,o,u,!1)){var h=t.findClosestClipPathTarget(c);if(h){var f=h.parsedStyle.clipPath;if(this.isHit(f,o,f.getWorldTransform(),!0)){if(i)return r.picked=[c],r;s.push(c)}}else{if(i)return r.picked=[c],r;s.push(c)}}}}catch(e){l.e(e)}finally{l.f()}return r.picked=s,r}}])}();function re(e,r,n){var i=e.parsedStyle,a=i.cx,o=i.cy,s=i.r,l=i.fill,c=i.stroke,u=i.lineWidth,h=i.increasedLineWidthForHitTesting,f=i.pointerEvents,d=void 0===f?"auto":f,v=((void 0===u?1:u)+(void 0===h?0:h))/2,p=z(void 0===a?0:a,void 0===o?0:o,r.x,r.y),g=y(t.isFillOrStrokeAffected(d,l,c),2),m=g[0],b=g[1];return m&&b||n?s+v>=p:m?s>=p:!!b&&(p>=s-v&&s+v>=p)}function ne(e,t,r,n){return e/(r*r)+t/(n*n)}function ie(e,r,n){var i=e.parsedStyle,a=i.cx,o=void 0===a?0:a,s=i.cy,l=void 0===s?0:s,c=i.rx,u=i.ry,h=i.lineWidth,f=void 0===h?1:h,d=i.increasedLineWidthForHitTesting,v=void 0===d?0:d,p=i.pointerEvents,g=r.x,m=r.y,b=y(t.isFillOrStrokeAffected(void 0===p?"auto":p,i.fill,i.stroke),2),x=b[0],S=b[1],w=(f+v)/2,k=(g-o)*(g-o),M=(m-l)*(m-l);return x&&S||n?1>=ne(k,M,c+w,u+w):x?1>=ne(k,M,c,u):!!S&&(ne(k,M,c-w,u-w)>=1&&1>=ne(k,M,c+w,u+w))}function ae(e,t,r,n,i,a){return!(e>i||i>e+r||t>a||a>t+n)}function oe(e,t,r,n,i,a,o,s){var l=(Math.atan2(s-t,o-e)+2*Math.PI)%(2*Math.PI),c={x:e+r*Math.cos(l),y:t+r*Math.sin(l)};return z(c.x,c.y,o,s)<=a/2}function se(e,t,r,n,i,a,o){var s=i/2;return!(Math.min(e,r)-s>a||a>Math.max(e,r)+s||Math.min(t,n)-s>o||o>Math.max(t,n)+s)&&H(e,t,r,n,a,o)<=i/2}function le(e,t,r,n,i){var a=e.length;if(2>a)return!1;for(var o=0;a-1>o;o++){if(se(e[o][0],e[o][1],e[o+1][0],e[o+1][1],t,r,n))return!0}if(i){var s=e[0],l=e[a-1];if(se(s[0],s[1],l[0],l[1],t,r,n))return!0}return!1}te.tag="CanvasPicker";function ce(e){return 1e-6>Math.abs(e)?0:0>e?-1:1}function ue(e,t,r){return!((r[0]-e[0])*(t[1]-e[1])!=(t[0]-e[0])*(r[1]-e[1])||Math.min(e[0],t[0])>r[0]||r[0]>Math.max(e[0],t[0])||Math.min(e[1],t[1])>r[1]||r[1]>Math.max(e[1],t[1]))}function he(e,t,r){var n=!1,i=e.length;if(2>=i)return!1;for(var a=0;i>a;a++){var o=e[a],s=e[(a+1)%i];if(ue(o,s,[t,r]))return!0;ce(o[1]-r)>0!=ce(s[1]-r)>0&&0>ce(t-(r-o[1])*(o[0]-s[0])/(o[1]-s[1])-o[0])&&(n=!n)}return n}function fe(e,t,r){for(var n=!1,i=0;e.length>i;i++){if(n=he(e[i],t,r))break}return n}function de(e,r,n){var i=e.parsedStyle,a=i.x1,o=i.y1,s=i.x2,l=i.y2,c=i.lineWidth,u=void 0===c?1:c,h=i.increasedLineWidthForHitTesting,f=void 0===h?0:h,d=i.pointerEvents;return!(!y(t.isFillOrStrokeAffected(void 0===d?"auto":d,i.fill,i.stroke),2)[1]&&!n||!u)&&se(a,o,s,l,u+f,r.x,r.y)}function ve(e,r,n,i,a,o){var s=e.parsedStyle,l=s.lineWidth,c=void 0===l?1:l,u=s.increasedLineWidthForHitTesting,h=void 0===u?0:u,f=s.d,d=s.pointerEvents,v=f.segments,p=f.hasArc,g=f.polylines,m=f.polygons,b=y(t.isFillOrStrokeAffected(void 0===d?"auto":d,(null==m?void 0:m.length)&&s.fill,s.stroke),2),x=b[0],S=b[1],w=t.getOrCalculatePathTotalLength(e),k=!1;return x||n?k=p?i(e,r):fe(m,r.x,r.y)||fe(g,r.x,r.y):((S||n)&&(k=function(e,t,r,n,i){for(var a=!1,o=t/2,s=0;e.length>s;s++){var l=e[s],c=l.currentPoint,u=l.params,h=l.prePoint,f=l.box;if(!f||ae(f.x-o,f.y-o,f.width+t,f.height+t,r,n))switch(l.command){case"L":case"Z":if(a=se(h[0],h[1],c[0],c[1],t,r,n))return!0;break;case"Q":if(a=t/2>=q(h[0],h[1],u[1],u[2],u[3],u[4],r,n))return!0;break;case"C":if(a=t/2>=U(h[0],h[1],u[1],u[2],u[3],u[4],u[5],u[6],r,n,i))return!0;break;case"A":l.cubicParams||(l.cubicParams=C(h[0],h[1],u[1],u[2],u[3],u[4],u[5],u[6],u[7],void 0));for(var d=l.cubicParams,v=h,p=0;d.length>p;p+=6){var y=U(v[0],v[1],d[p],d[p+1],d[p+2],d[p+3],d[p+4],d[p+5],r,n,i);if(v=[d[p+4],d[p+5]],a=t/2>=y)return!0}}}return a}(v,c+h,r.x,r.y,w)),k)}function pe(e,r,n){var i=e.parsedStyle,a=i.lineWidth,o=void 0===a?1:a,s=i.increasedLineWidthForHitTesting,l=void 0===s?0:s,c=i.points,u=i.pointerEvents,h=y(t.isFillOrStrokeAffected(void 0===u?"auto":u,i.fill,i.stroke),2),f=h[0],d=!1;return(h[1]||n)&&(d=le(c.points,o+l,r.x,r.y,!0)),d||!f&&!n||(d=he(c.points,r.x,r.y)),d}function ye(e,r,n){var i=e.parsedStyle,a=i.lineWidth,o=void 0===a?1:a,s=i.increasedLineWidthForHitTesting,l=void 0===s?0:s,c=i.points,u=i.pointerEvents;return!(!y(t.isFillOrStrokeAffected(void 0===u?"auto":u,i.fill,i.stroke),2)[1]&&!n||!o)&&le(c.points,o+l,r.x,r.y,!1)}function ge(e,r,n,i,a){var o=e.parsedStyle,s=o.radius,l=o.lineWidth,c=void 0===l?1:l,u=o.increasedLineWidthForHitTesting,h=void 0===u?0:u,f=o.x,d=void 0===f?0:f,v=o.y,p=void 0===v?0:v,g=o.width,m=o.height,x=o.pointerEvents,S=y(t.isFillOrStrokeAffected(void 0===x?"auto":x,o.fill,o.stroke),2),w=S[0],k=S[1],M=c+h;if(s&&s.some((function(e){return 0!==e}))){var E=!1;return(k||n)&&(E=function(e,t,r,n,i,a,o,s){var l=y(i,4),c=l[0],u=l[1],h=l[2],f=l[3];return se(e+c,t,e+r-u,t,a,o,s)||se(e+r,t+u,e+r,t+n-h,a,o,s)||se(e+r-h,t+n,e+f,t+n,a,o,s)||se(e,t+n-f,e,t+c,a,o,s)||oe(e+r-u,t+u,u,0,0,a,o,s)||oe(e+r-h,t+n-h,h,0,0,a,o,s)||oe(e+f,t+n-f,f,0,0,a,o,s)||oe(e+c,t+c,c,0,0,a,o,s)}(d,p,g,m,s.map((function(e){return b(e,0,Math.min(Math.abs(g)/2,Math.abs(m)/2))})),M,r.x,r.y)),E||!w&&!n||(E=i(e,r)),E}var T=M/2;return w&&k||n?ae(d-T,p-T,g+T,m+T,r.x,r.y):w?ae(d,p,g,m,r.x,r.y):!!k&&function(e,t,r,n,i,a,o){var s=i/2;return ae(e-s,t-s,r,i,a,o)||ae(e+r-s,t-s,i,n,a,o)||ae(e+s,t+n-s,r,i,a,o)||ae(e-s,t+s,i,n,a,o)}(d,p,g,m,M,r.x,r.y)}function me(e,r,n,i,a,o){var s=e.parsedStyle,l=s.pointerEvents,c=s.x,u=void 0===c?0:c,h=s.y,f=void 0===h?0:h,d=s.width,v=s.height;if("non-transparent-pixel"===(void 0===l?"auto":l)){var p=a.config.offscreenCanvas,y=o.offscreenCanvasCreator.getOrCreateCanvas(p),g=o.offscreenCanvasCreator.getOrCreateContext(p,{willReadFrequently:!0});return y.width=d,y.height=v,a.defaultStyleRendererFactory[t.Shape.IMAGE].render(g,$($({},e.parsedStyle),{},{x:0,y:0}),e,void 0,void 0,void 0),g.getImageData(r.x-u,r.y-f,1,1).data.every((function(e){return 0!==e}))}return!0}function be(e,t,r,n){var i=e.getGeometryBounds();return!(i.min[0]>t.x||i.min[1]>t.y||t.x>i.max[0]||t.y>i.max[1])}var xe=function(e){function r(){var e;o(this,r);for(var t=arguments.length,n=Array(t),i=0;t>i;i++)n[i]=arguments[i];return(e=u(this,r,[].concat(n))).name="canvas-picker",e}return f(r,e),a(r,[{key:"init",value:function(){var e,r=(d(d(d(d(d(d(d(d(d(d(e={},t.Shape.CIRCLE,re),t.Shape.ELLIPSE,ie),t.Shape.RECT,ge),t.Shape.LINE,de),t.Shape.POLYLINE,ye),t.Shape.POLYGON,pe),t.Shape.PATH,ve),t.Shape.TEXT,be),t.Shape.GROUP,null),t.Shape.IMAGE,me),d(d(e,t.Shape.HTML,null),t.Shape.MESH,null));this.context.pointInPathPickerFactory=r,this.addRenderingPlugin(new te)}},{key:"destroy",value:function(){delete this.context.pointInPathPickerFactory,this.removeAllRenderingPlugins()}}])}(t.AbstractRendererPlugin),Se=Object.freeze({__proto__:null,Plugin:xe});function we(e,t){if(!{}.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}var ke=0;function Me(e){return"__private_"+ke+++"_"+e}
/*!
* @antv/g-plugin-image-loader
* @description A G plugin for loading image
* @version 2.1.17
* @date 1/17/2025, 2:07:09 PM
* @author AntVis
* @docs https://g.antv.antgroup.com/
*/var Ee=function(){return a((function e(){o(this,e),this.cacheStore=new Map}),[{key:"onRefAdded",value:function(e){}},{key:"has",value:function(e){return this.cacheStore.has(e)}},{key:"put",value:function(e,t,r){return!this.cacheStore.has(e)&&(this.cacheStore.set(e,{value:t,counter:new Set([r])}),this.onRefAdded(r),!0)}},{key:"get",value:function(e,t){var r=this.cacheStore.get(e);return r?(r.counter.has(t)||(r.counter.add(t),this.onRefAdded(t)),r.value):null}},{key:"update",value:function(e,t,r){var n=this.cacheStore.get(e);return!!n&&(n.value=$($({},n.value),t),n.counter.has(r)||(n.counter.add(r),this.onRefAdded(r)),!0)}},{key:"release",value:function(e,t){var r=this.cacheStore.get(e);return!!r&&(r.counter.delete(t),r.counter.size>0||this.cacheStore.delete(e),!0)}},{key:"releaseRef",value:function(e){var t=this;Array.from(this.cacheStore.keys()).forEach((function(r){t.release(r,e)}))}},{key:"getSize",value:function(){return this.cacheStore.size}},{key:"clear",value:function(){this.cacheStore.clear()}}])}(),Te=[],Pe=[],Oe=function(){function e(){o(this,e)}return a(e,null,[{key:"stop",value:function(){e.rafId&&((arguments.length>0&&void 0!==arguments[0]?arguments[0]:e.api).cancelAnimationFrame(e.rafId),e.rafId=null)}},{key:"executeTask",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e.api;(Te.length>0||Pe.length>0)&&(Pe.forEach((function(e){return e()})),Pe=Te.splice(0,e.TASK_NUM_PER_FRAME),e.rafId=t.requestAnimationFrame((function(){e.executeTask(t)})))}},{key:"sliceImage",value:function(t,r,n,i){for(var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:e.api,s=t.naturalWidth||t.width,l=t.naturalHeight||t.height,c=r-a,u=n-a,h=Math.ceil(s/c),f=Math.ceil(l/u),d={tileSize:[r,n],gridSize:[f,h],tiles:Array(f).fill(null).map((function(){return Array(h).fill(null)}))},v=function(e){for(var a=function(a){Te.push((function(){var h=a*c,f=e*u,v=[Math.min(r,s-h),Math.min(n,l-f)],p=v[0],y=v[1],g=o.createCanvas();g.width=r,g.height=n,g.getContext("2d").drawImage(t,h,f,p,y,0,0,p,y),d.tiles[e][a]={x:h,y:f,tileX:a,tileY:e,data:g},i()}))},f=0;h>f;f++)a(f)},p=0;f>p;p++)v(p);return e.stop(),e.executeTask(),d}}])}();Oe.TASK_NUM_PER_FRAME=10;var Ce=new Ee;Ce.onRefAdded=function(e){var r=this;e.addEventListener(t.ElementEvent.DESTROY,(function(){r.releaseRef(e)}),{once:!0})};var Ae=function(){return a((function e(t,r){o(this,e),this.gradientCache={},this.patternCache={},this.context=t,this.runtime=r}),[{key:"getImageSync",value:function(e,t,r){var n=m(e)?e:e.src;if(Ce.has(n)){var i=Ce.get(n,t);if(i.img.complete)return null==r||r(i),i}return this.getOrCreateImage(e,t).then((function(e){null==r||r(e)})).catch((function(){})),null}},{key:"getOrCreateImage",value:function(e,t){var r=this,n=m(e)?e:e.src;if(!m(e)&&!Ce.has(n)){var i={img:e,size:[e.naturalWidth||e.width,e.naturalHeight||e.height],tileSize:Re(e)};Ce.put(n,i,t)}if(Ce.has(n)){var a=Ce.get(n,t);return a.img.complete?Promise.resolve(a):new Promise((function(e,t){a.img.addEventListener("load",(function(){a.size=[a.img.naturalWidth||a.img.width,a.img.naturalHeight||a.img.height],a.tileSize=Re(a.img),e(a)})),a.img.addEventListener("error",(function(e){t(e)}))}))}return new Promise((function(e,i){var a=r.context.config.createImage();if(a){var o={img:a,size:[0,0],tileSize:Re(a)};Ce.put(n,o,t),a.onload=function(){o.size=[a.naturalWidth||a.width,a.naturalHeight||a.height],o.tileSize=Re(o.img),e(o)},a.onerror=function(e){i(e)},a.crossOrigin="Anonymous",a.src=n}}))}},{key:"createDownSampledImage",value:(r=_(B().mark((function e(t,r){var n,i,a,o,s,l,c,u,h,f,d,v,p,g;return B().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getOrCreateImage(t,r);case 2:if(void 0===(n=e.sent).downSamplingRate){e.next=5;break}return e.abrupt("return",n);case 5:if(s=void 0===(o=(a="boolean"==typeof(i=this.context.config.enableLargeImageOptimization)?{}:i).maxDownSampledImageSize)?2048:o,c=void 0===(l=a.downSamplingRateThreshold)?.5:l,u=this.runtime.globalThis.createImageBitmap,h=y(n.size,2),v=n.img,p=Math.min((s+s)/((f=h[0])+(d=h[1])),Math.max(.01,Math.min(c,.5))),g=$($({},n),{},{downSamplingRate:p}),Ce.update(n.img.src,g,r),!u){e.next=25;break}return e.prev=14,e.next=17,u(n.img,{resizeWidth:f*p,resizeHeight:d*p});case 17:v=e.sent,e.next=23;break;case 20:e.prev=20,e.t0=e.catch(14),p=1;case 23:e.next=26;break;case 25:p=1;case 26:return g=$($({},this.getImageSync(t,r)),{},{downSampled:v,downSamplingRate:p}),Ce.update(n.img.src,g,r),e.abrupt("return",g);case 29:case"end":return e.stop()}}),e,this,[[14,20]])}))),function(e,t){return r.apply(this,arguments)})},{key:"createImageTiles",value:(e=_(B().mark((function e(r,n,i,a){var o,s,l;return B().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getOrCreateImage(r,a);case 2:return o=e.sent,Oe.api={requestAnimationFrame:(s=a.ownerDocument.defaultView).requestAnimationFrame,cancelAnimationFrame:s.cancelAnimationFrame,createCanvas:function(){return t.OffscreenCanvasCreator.createCanvas()}},l=$($({},o),Oe.sliceImage(o.img,o.tileSize[0],o.tileSize[0],i)),Ce.update(o.img.src,l,a),e.abrupt("return",l);case 8:case"end":return e.stop()}}),e,this)}))),function(t,r,n,i){return e.apply(this,arguments)})},{key:"releaseImage",value:function(e,t){Ce.release(m(e)?e:e.src,t)}},{key:"releaseImageRef",value:function(e){Ce.releaseRef(e)}},{key:"getOrCreatePatternSync",value:function(e,r,n,i,a,o,s){var l=this.generatePatternKey(r);if(l&&this.patternCache[l])return this.patternCache[l];var c,u=r.image,h=r.repetition,f=r.transform,d=!1;if(m(u)){var v=this.getImageSync(u,e,s);c=null==v?void 0:v.img}else i?(c=i,d=!0):c=u;var p,y,g=c&&n.createPattern(c,h);g&&(f?p=t.parsedTransformToMat4(t.parseTransform(f),new t.DisplayObject({})):((y=S())[0]=1,y[1]=0,y[2]=0,y[3]=0,y[4]=0,y[5]=1,y[6]=0,y[7]=0,y[8]=0,y[9]=0,y[10]=1,y[11]=0,y[12]=0,y[13]=0,y[14]=0,y[15]=1,p=y),d&&function(e,t,r){var n=r[0],i=r[1],a=r[2];e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*a,e[9]=t[9]*a,e[10]=t[10]*a,e[11]=t[11]*a,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]}(p,p,[1/a,1/a,1]),g.setTransform({a:p[0],b:p[1],c:p[4],d:p[5],e:p[12]+o[0],f:p[13]+o[1]}));return l&&g&&(this.patternCache[l]=g),g}},{key:"getOrCreateGradient",value:function(e,r){var n=this.generateGradientKey(e),i=e.type,a=e.steps,o=e.min,s=e.width,l=e.height,c=e.cx,u=e.cy,h=e.size;if(this.gradientCache[n])return this.gradientCache[n];var f=null;if(i===t.GradientType.LinearGradient){var d=t.computeLinearGradient(o,s,l,e.angle);f=r.createLinearGradient(d.x1,d.y1,d.x2,d.y2)}else if(i===t.GradientType.RadialGradient){var v=t.computeRadialGradient(o,s,l,c,u,h),p=v.x,y=v.y;f=r.createRadialGradient(p,y,0,p,y,v.r)}return f&&(a.forEach((function(e){var r,n=e.offset;n.unit===t.UnitType.kPercentage&&(null===(r=f)||void 0===r||r.addColorStop(n.value/100,""+e.color))})),this.gradientCache[n]=f),this.gradientCache[n]}},{key:"generateGradientKey",value:function(e){var t=e.min,r=e.width,n=e.height,i=e.steps,a=e.angle,o=e.cx,s=e.cy,l=e.size;return"gradient-".concat(e.type,"-").concat((null==a?void 0:""+a)||0,"-").concat((null==o?void 0:""+o)||0,"-").concat((null==s?void 0:""+s)||0,"-").concat((null==l?void 0:""+l)||0,"-").concat(t[0],"-").concat(t[1],"-").concat(r,"-").concat(n,"-").concat(i.map((function(e){var t=e.color;return"".concat(e.offset).concat(t)})).join("-"))}},{key:"generatePatternKey",value:function(e){var t=e.image,r=e.repetition;return m(t)?"pattern-".concat(t,"-").concat(r):"rect"===t.nodeName?"pattern-".concat(t.entity,"-").concat(r):void 0}}]);var e,r}();function Re(e){if(!e.complete)return[0,0];var t=e.naturalWidth||e.width,r=e.naturalHeight||e.height,n=256;return[256,512].forEach((function(e){1e3>Math.ceil(r/e)*Math.ceil(t/e)&&(n=e)})),[n,n]}Ae.isSupportTile=!!t.OffscreenCanvasCreator.createCanvas();var Le=function(){function e(){o(this,e)}return a(e,[{key:"apply",value:function(r){var n=r.renderingService,i=r.imagePool,a=r.renderingContext.root.ownerDocument.defaultView,o=function(e,t,r){var n=e.parsedStyle,i=n.width,a=n.height;i&&!a?e.setAttribute("height",r/t*i):!i&&a&&e.setAttribute("width",t/r*a)},s=function(e){var r=e.target,a=r.attributes;if(r.nodeName===t.Shape.IMAGE){var s=a.keepAspectRatio;i.getImageSync(a.src,r,(function(e){var t=e.img;s&&o(r,t.width,t.height),r.renderable.dirty=!0,n.dirtify()}))}},l=function(e){var r=e.target,a=e.prevValue,s=e.newValue;r.nodeName===t.Shape.IMAGE&&"src"===e.attrName&&(a!==s&&i.releaseImage(a,r),m(s)&&i.getOrCreateImage(s,r).then((function(e){var t=e.img;r.attributes.keepAspectRatio&&o(r,t.width,t.height),r.renderable.dirty=!0,n.dirtify()})).catch((function(){})))};n.hooks.init.tap(e.tag,(function(){a.addEventListener(t.ElementEvent.MOUNTED,s),a.addEventListener(t.ElementEvent.ATTR_MODIFIED,l)})),n.hooks.destroy.tap(e.tag,(function(){a.removeEventListener(t.ElementEvent.MOUNTED,s),a.removeEventListener(t.ElementEvent.ATTR_MODIFIED,l)}))}}])}();Le.tag="LoadImage";var De=function(e){function t(){var e;o(this,t);for(var r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];return(e=u(this,t,[].concat(n))).name="image-loader",e}return f(t,e),a(t,[{key:"init",value:function(e){this.context.imagePool=new Ae(this.context,e),this.addRenderingPlugin(new Le)}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}}])}(t.AbstractRendererPlugin),Ie=Me("renderState"),Fe=function(){function e(t){o(this,e),this.removedRBushNodeAABBs=[],this.renderQueue=[],Object.defineProperty(this,Ie,{writable:!0,value:{restoreStack:[],prevObject:null,currentContext:new Map}}),this.clearFullScreenLastFrame=!1,this.clearFullScreen=!1,this.vpMatrix=S(),this.dprMatrix=S(),this.tmpMat4=S(),this.vec3a=E(),this.vec3b=E(),this.vec3c=E(),this.vec3d=E(),this.canvasRendererPluginOptions=t}return a(e,[{key:"apply",value:function(r,n){var i=this;this.context=r;var a=this.context,o=a.config,s=a.camera,l=a.renderingService,c=a.renderingContext,u=a.rBushRoot,h=a.pathGeneratorFactory,f=o.renderer.getConfig().enableRenderingOptimization;o.renderer.getConfig().enableDirtyCheck=!1,o.renderer.getConfig().enableDirtyRectangleRendering=!1,this.rBush=u,this.pathGeneratorFactory=h;var d=r.contextService,v=c.root.ownerDocument.defaultView,p=function(e){var t=e.target.rBushNode;t.aabb&&i.removedRBushNodeAABBs.push(t.aabb)},y=function(e){var t=e.target.rBushNode;t.aabb&&i.removedRBushNodeAABBs.push(t.aabb)};l.hooks.init.tap(e.tag,(function(){v.addEventListener(t.ElementEvent.UNMOUNTED,p),v.addEventListener(t.ElementEvent.CULLED,y);var e=d.getDPR(),r=o.width,n=o.height,a=d.getContext();i.clearRect(a,0,0,r*e,n*e,o.background)})),l.hooks.destroy.tap(e.tag,(function(){v.removeEventListener(t.ElementEvent.UNMOUNTED,p),v.removeEventListener(t.ElementEvent.CULLED,y),i.renderQueue=[],i.removedRBushNodeAABBs=[],we(i,Ie)[Ie]={restoreStack:[],prevObject:null,currentContext:null}})),l.hooks.beginFrame.tap(e.tag,(function(){var e,t=d.getContext(),r=d.getDPR(),n=o.width,a=o.height,s=i.canvasRendererPluginOptions,c=s.dirtyObjectNumThreshold,u=s.dirtyObjectRatioThreshold,h=l.getStats(),f=h.rendered,p=f/h.total;i.clearFullScreen=i.clearFullScreenLastFrame||!(null!==(e=v.context.renderingPlugins[1])&&void 0!==e&&e.isFirstTimeRenderingFinished)||l.disableDirtyRectangleRendering()||f>c&&p>u,t&&("function"==typeof t.resetTransform?t.resetTransform():t.setTransform(1,0,0,1,0,0),i.clearFullScreen&&i.clearRect(t,0,0,n*r,a*r,o.background))}));var g=function(e,t){for(var r=[e];r.length>0;){var a=r.pop();a.isVisible()&&!a.isCulled()&&(f?i.renderDisplayObjectOptimized(a,t,i.context,we(i,Ie)[Ie],n):i.renderDisplayObject(a,t,i.context,we(i,Ie)[Ie],n));for(var o=a.sortable.sorted||a.childNodes,s=o.length-1;s>=0;s--)r.push(o[s])}};l.hooks.endFrame.tap(e.tag,(function(){if(0!==c.root.childNodes.length){f=o.renderer.getConfig().enableRenderingOptimization,we(i,Ie)[Ie]={restoreStack:[],prevObject:null,currentContext:we(i,Ie)[Ie].currentContext},we(i,Ie)[Ie].currentContext.clear(),i.clearFullScreenLastFrame=!1;var e,r,a=d.getContext(),l=d.getDPR();if((e=i.dprMatrix)[0]=(r=[l,l,1])[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=r[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=r[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,k(i.vpMatrix,i.dprMatrix,s.getOrthoMatrix()),i.clearFullScreen)f?(a.save(),g(c.root,a),a.restore()):g(c.root,a),i.removedRBushNodeAABBs=[];else{var u=i.safeMergeAABB.apply(i,[i.mergeDirtyAABBs(i.renderQueue)].concat(W(i.removedRBushNodeAABBs.map((function(e){var r=e.minX,n=e.minY,i=e.maxX,a=e.maxY,o=new t.AABB;return o.setMinMax([r,n,0],[i,a,0]),o})))));if(i.removedRBushNodeAABBs=[],t.AABB.isEmpty(u))return void(i.renderQueue=[]);var h=i.convertAABB2Rect(u),p=h.x,y=h.y,m=h.width,b=h.height,x=P(i.vec3a,[p,y,0],i.vpMatrix),S=P(i.vec3b,[p+m,y,0],i.vpMatrix),w=P(i.vec3c,[p,y+b,0],i.vpMatrix),M=P(i.vec3d,[p+m,y+b,0],i.vpMatrix),E=Math.min(x[0],S[0],M[0],w[0]),T=Math.min(x[1],S[1],M[1],w[1]),O=Math.max(x[0],S[0],M[0],w[0]),C=Math.max(x[1],S[1],M[1],w[1]),A=Math.floor(E),R=Math.floor(T),L=Math.ceil(O-E),D=Math.ceil(C-T);a.save(),i.clearRect(a,A,R,L,D,o.background),a.beginPath(),a.rect(A,R,L,D),a.clip(),a.setTransform(i.vpMatrix[0],i.vpMatrix[1],i.vpMatrix[4],i.vpMatrix[5],i.vpMatrix[12],i.vpMatrix[13]),o.renderer.getConfig().enableDirtyRectangleRenderingDebug&&v.dispatchEvent(new t.CustomEvent(t.CanvasEvent.DIRTY_RECTANGLE,{dirtyRect:{x:A,y:R,width:L,height:D}})),i.searchDirtyObjects(u).sort((function(e,t){return e.sortable.renderOrder-t.sortable.renderOrder})).forEach((function(e){e&&e.isVisible()&&!e.isCulled()&&i.renderDisplayObject(e,a,i.context,we(i,Ie)[Ie],n)})),a.restore(),i.renderQueue.forEach((function(e){i.saveDirtyAABB(e)})),i.renderQueue=[]}we(i,Ie)[Ie].restoreStack.forEach((function(){a.restore()})),we(i,Ie)[Ie].restoreStack=[]}else i.clearFullScreenLastFrame=!0})),l.hooks.render.tap(e.tag,(function(e){i.clearFullScreen||i.renderQueue.push(e)}))}},{key:"clearRect",value:function(e,t,r,n,i,a){e.clearRect(t,r,n,i),a&&(e.fillStyle=a,e.fillRect(t,r,n,i))}},{key:"renderDisplayObjectOptimized",value:function(e,r,n,i,a){var o=e.nodeName,s=!1,l=this.context.styleRendererFactory[o],c=this.pathGeneratorFactory[o],u=e.parsedStyle.clipPath;if(u){(!i.prevObject||!M(u.getWorldTransform(),i.prevObject.getWorldTransform()))&&(this.applyWorldTransform(r,u),i.prevObject=null);var h=this.pathGeneratorFactory[u.nodeName];h&&(r.save(),s=!0,r.beginPath(),h(r,u.parsedStyle),r.closePath(),r.clip())}if(l){(!i.prevObject||!M(e.getWorldTransform(),i.prevObject.getWorldTransform()))&&this.applyWorldTransform(r,e);var f=!i.prevObject;if(!f){var d=i.prevObject.nodeName;f=o===t.Shape.TEXT?d!==t.Shape.TEXT:o===t.Shape.IMAGE?d!==t.Shape.IMAGE:d===t.Shape.TEXT||d===t.Shape.IMAGE}l.applyStyleToContext(r,e,f,i),i.prevObject=e}c&&(r.beginPath(),c(r,e.parsedStyle),o!==t.Shape.LINE&&o!==t.Shape.PATH&&o!==t.Shape.POLYLINE&&r.closePath()),l&&l.drawToContext(r,e,we(this,Ie)[Ie],this,a),s&&r.restore(),e.renderable.dirty=!1}},{key:"renderDisplayObject",value:function(e,r,n,i,a){var o=e.nodeName,s=i.restoreStack[i.restoreStack.length-1];!s||e.compareDocumentPosition(s)&t.Node.DOCUMENT_POSITION_CONTAINS||(r.restore(),i.restoreStack.pop());var l=this.context.styleRendererFactory[o],c=this.pathGeneratorFactory[o],u=e.parsedStyle.clipPath;if(u){this.applyWorldTransform(r,u);var h=this.pathGeneratorFactory[u.nodeName];h&&(r.save(),i.restoreStack.push(e),r.beginPath(),h(r,u.parsedStyle),r.closePath(),r.clip())}l&&(this.applyWorldTransform(r,e),r.save(),this.applyAttributesToContext(r,e)),c&&(r.beginPath(),c(r,e.parsedStyle),o!==t.Shape.LINE&&o!==t.Shape.PATH&&o!==t.Shape.POLYLINE&&r.closePath()),l&&(l.render(r,e.parsedStyle,e,n,this,a),r.restore()),e.renderable.dirty=!1}},{key:"applyAttributesToContext",value:function(e,t){var r=t.parsedStyle,n=r.stroke,i=r.fill,a=r.opacity,o=r.lineDash,s=r.lineDashOffset;o&&e.setLineDash(o),g(s)||(e.lineDashOffset=s),g(a)||(e.globalAlpha*=a),g(n)||Array.isArray(n)||n.isNone||(e.strokeStyle=t.attributes.stroke),g(i)||Array.isArray(i)||i.isNone||(e.fillStyle=t.attributes.fill)}},{key:"convertAABB2Rect",value:function(e){var t=e.getMin(),r=e.getMax(),n=Math.floor(t[0]),i=Math.floor(t[1]);return{x:n,y:i,width:Math.ceil(r[0])-n,height:Math.ceil(r[1])-i}}},{key:"mergeDirtyAABBs",value:function(e){var r=new t.AABB;return e.forEach((function(e){var t=e.getRenderBounds();r.add(t);var n=e.renderable.dirtyRenderBounds;n&&r.add(n)})),r}},{key:"searchDirtyObjects",value:function(e){var t=y(e.getMin(),2),r=t[0],n=t[1],i=y(e.getMax(),2);return this.rBush.search({minX:r,minY:n,maxX:i[0],maxY:i[1]}).map((function(e){return e.displayObject}))}},{key:"saveDirtyAABB",value:function(e){var r=e.renderable;r.dirtyRenderBounds||(r.dirtyRenderBounds=new t.AABB);var n=e.getRenderBounds();n&&r.dirtyRenderBounds.update(n.center,n.halfExtents)}},{key:"applyWorldTransform",value:function(e,t,r){r?(w(this.tmpMat4,t.getLocalTransform()),k(this.tmpMat4,r,this.tmpMat4),k(this.tmpMat4,this.vpMatrix,this.tmpMat4)):(w(this.tmpMat4,t.getWorldTransform()),k(this.tmpMat4,this.vpMatrix,this.tmpMat4)),e.setTransform(this.tmpMat4[0],this.tmpMat4[1],this.tmpMat4[4],this.tmpMat4[5],this.tmpMat4[12],this.tmpMat4[13])}},{key:"safeMergeAABB",value:function(){for(var e=new t.AABB,r=arguments.length,n=Array(r),i=0;r>i;i++)n[i]=arguments[i];return n.forEach((function(t){e.add(t)})),e}}])}();
/*!
* @antv/g-plugin-canvas-renderer
* @description A G plugin of renderer implementation with Canvas2D API
* @version 2.2.17
* @date 1/17/2025, 2:07:56 PM
* @author AntVis
* @docs https://g.antv.antgroup.com/
*/function je(e,t,r,n,i,a,o){var s,l;if("rect"===e.image.nodeName){var c=e.image.parsedStyle,u=c.width,h=c.height;l=n.contextService.getDPR();var f=n.config.offscreenCanvas;(s=a.offscreenCanvasCreator.getOrCreateCanvas(f)).width=u*l,s.height=h*l;var d=a.offscreenCanvasCreator.getOrCreateContext(f),v={restoreStack:[],prevObject:null,currentContext:new Map};e.image.forEach((function(e){i.renderDisplayObject(e,d,n,v,a)})),v.restoreStack.forEach((function(){d.restore()}))}return o.getOrCreatePatternSync(t,e,r,s,l,t.getGeometryBounds().min,(function(){t.renderable.dirty=!0,n.renderingService.dirtify()}))}function Ne(e,r,n,i){var a;if(e.type===t.GradientType.LinearGradient||e.type===t.GradientType.RadialGradient){var o=r.getGeometryBounds(),s=o&&2*o.halfExtents[0]||1,l=o&&2*o.halfExtents[1]||1,c=o&&o.min||[0,0];a=i.getOrCreateGradient($($({type:e.type},e.value),{},{min:c,width:s,height:l}),n)}return a}Fe.tag="CanvasRenderer";var Be=["shadowBlur","shadowOffsetX","shadowOffsetY"],Ge=["lineCap","lineJoin","miterLimit"],_e={globalAlpha:1,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,shadowColor:"#000",filter:"none",globalCompositeOperation:"source-over",strokeStyle:"#000",strokeOpacity:1,lineWidth:1,lineDash:[],lineDashOffset:0,lineCap:"butt",lineJoin:"miter",miterLimit:10,fillStyle:"#000",fillOpacity:1},We={};function ze(e,t,r,n){var i=n.has(t)?n.get(t):_e[t];return i!==r&&("lineDash"===t?e.setLineDash(r):e[t]=r,n.set(t,r)),i}var Ye=function(){return a((function e(t){o(this,e),this.imagePool=t}),[{key:"applyAttributesToContext",value:function(e,t){}},{key:"render",value:function(e,t,r,n,i,a){}},{key:"applyCommonStyleToContext",value:function(e,t,r,n){var i=r?We:n.prevObject.parsedStyle,a=t.parsedStyle;(r||a.opacity!==i.opacity)&&ze(e,"globalAlpha",g(a.opacity)?_e.globalAlpha:a.opacity,n.currentContext),(r||a.blend!==i.blend)&&ze(e,"globalCompositeOperatio