You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
22 KiB

4 months ago
/*!
* @antv/g-plugin-canvas-picker
* @description A G plugin for picking in canvas
* @version 2.1.27
* @date 7/30/2025, 1:37:32 PM
* @author AntVis
* @docs https://g.antv.antgroup.com/
*/
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],r):r(((t="undefined"!=typeof globalThis?globalThis:t||self).G=t.G||{},t.G.CanvasPicker={}),t.window.G)}(this,function(t,r){"use strict";function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function e(t){var r=function(t,r){if("object"!=n(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var o=e.call(t,r||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"==n(r)?r:r+""}function o(t,r,n){return(r=e(r))in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function i(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function a(t,r){for(var n=0;r.length>n;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,e(o.key),o)}}function u(t,r,n){return r&&a(t.prototype,r),n&&a(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function c(t){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},c(t)}function f(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(f=function(){return!!t})()}function l(t,r){if(r&&("object"==n(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function s(t,r){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},s(t,r)}function v(t,r){(null==r||r>t.length)&&(r=t.length);for(var n=0,e=Array(r);r>n;n++)e[n]=t[n];return e}function y(t,r){if(t){if("string"==typeof t)return v(t,r);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?v(t,r):void 0}}function p(t,r){this.v=t,this.k=r}function h(t,r,n,e){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}h=function(t,r,n,e){function i(r,n){h(t,r,function(t){return this._invoke(r,n,t)})}r?o?o(t,r,{value:n,enumerable:!e,configurable:!e,writable:!e}):t[r]=n:(i("next",0),i("throw",1),i("return",2))},h(t,r,n,e)}function d(){
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
var t,r,n="function"==typeof Symbol?Symbol:{},e=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,e,o,i){var c=Object.create((e&&e.prototype instanceof u?e:u).prototype);return h(c,"_invoke",function(n,e,o){var i,u,c,f=0,l=o||[],s=!1,v={p:0,n:0,v:t,a:y,f:y.bind(t,4),d:function(r,n){return i=r,u=0,c=t,v.n=n,a}};function y(n,e){for(u=n,c=e,r=0;!s&&f&&!o&&l.length>r;r++){var o,i=l[r],y=v.p,p=i[2];n>3?(o=p===e)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):y>=i[0]&&((o=2>n&&i[1]>y)?(u=0,v.v=e,v.n=i[1]):p>y&&(o=3>n||i[0]>e||e>p)&&(i[4]=n,i[5]=e,v.n=p,u=0))}if(o||n>1)return a;throw s=!0,e}return function(o,l,p){if(f>1)throw TypeError("Generator is already running");for(s&&1===l&&y(l,p),u=l,c=p;(r=2>u?t:c)||!s;){i||(u?3>u?(u>1&&(v.n=-1),y(u,c)):v.n=c:v.v=c);try{if(f=2,i){if(u||(o="next"),r=i[o]){if(!(r=r.call(i,c)))throw TypeError("iterator result is not an object");if(!r.done)return r;c=r.value,2>u&&(u=0)}else 1===u&&(r=i.return)&&r.call(i),2>u&&(c=TypeError("The iterator does not provide a '"+o+"' method"),u=1);i=t}else if((r=(s=0>v.n)?c:n.call(e,v))!==a)break}catch(r){i=t,u=1,c=r}finally{f=1}}return{value:r,done:s}}}(n,o,i),!0),c}var a={};function u(){}function c(){}function f(){}r=Object.getPrototypeOf;var l=[][e]?r(r([][e]())):(h(r={},e,function(){return this}),r),s=f.prototype=u.prototype=Object.create(l);function v(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,h(t,o,"GeneratorFunction")),t.prototype=Object.create(s),t}return c.prototype=f,h(s,"constructor",f),h(f,"constructor",c),c.displayName="GeneratorFunction",h(f,o,"GeneratorFunction"),h(s),h(s,o,"Generator"),h(s,e,function(){return this}),h(s,"toString",function(){return"[object Generator]"}),(d=function(){return{w:i,m:v}})()}function b(t,r){function n(e,o,i,a){try{var u=t[e](o),c=u.value;return c instanceof p?r.resolve(c.v).then(function(t){n("next",t,i,a)},function(t){n("throw",t,i,a)}):r.resolve(c).then(function(t){u.value=t,i(u)},function(t){return n("throw",t,i,a)})}catch(t){a(t)}}var e;this.next||(h(b.prototype),h(b.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),h(this,"_invoke",function(t,o,i){function a(){return new r(function(r,e){n(t,i,r,e)})}return e=e?e.then(a,a):a()},!0)}function m(t,r,n,e,o){return new b(d().w(t,r,n,e),o||Promise)}function g(t,r,n,e,o){var i=m(t,r,n,e,o);return i.next().then(function(t){return t.done?t.value:i.next()})}function x(t){var r=Object(t),n=[];for(var e in r)n.unshift(e);return function t(){for(;n.length;)if((e=n.pop())in r)return t.value=e,t.done=!1,t;return t.done=!0,t}}function P(t){if(null!=t){var r=t["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],e=0;if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return{next:function(){return t&&e>=t.length&&(t=void 0),{value:t&&t[e++],done:!t}}}}throw new TypeError(n(t)+" is not iterable")}function w(){var t=d(),r=t.m(w),n=(Object.getPrototypeOf?Object.getPrototypeOf(r):r.__proto__).constructor;function e(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===n||"GeneratorFunction"===(r.displayName||r.name))}var o={throw:1,return:2,break:3,continue:3};function i(t){var r,n;return function(e){r||(r={stop:function(){return n(e.a,2)},catch:function(){return e.v},abrupt:function(t,r){return n(e.a,o[t],r)},delegateYield:function(t,o,i){return r.resultName=o,n(e.d,P(t),i)},finish:function(t){return n(e.f,t)}},n=function(t,n,o){e.p=r.prev,e.n=r.next;try{return t(n,o)}finally{r.next=e.n}}),r.resultName&&(r[r.resultName]=e.v,r.resultName=void 0),r.sent=e.v,r.next=e.n;try{return t.call(this,r)}finally{e.p=r.prev,e.n=r.next}}}return(w=function(){return{wrap:function(r,n,e,o){return t.w(i(r),n,e,o&&o.reverse())},isGeneratorFunction:e,mark:t.m,awrap:function(t,r){return new p(t,r)},AsyncIterator:b,async:function(t,r,n,o,a){return(e(r)?m:g)(i(t),r,n,o,a)},keys:x,values:P}})()}function O(t,r,n,e,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void n(t)}u.done?r(c):Promise.resolve(c).then(e,o)}var S="undefined"!=typeof Float32Array?Float32Array:Array;fun
/*!
* @antv/g-math
* @description Geometry util
* @version 3.0.1
* @date 7/30/2025, 1:34:14 PM
* @author AntVis
* @docs https://g.antv.antgroup.com/
*/function N(t,r,n,e){var o=t-n,i=r-e;return Math.sqrt(o*o+i*i)}function H(t,r,n,e,o,i){var a=-1,u=1/0,c=[n,e],f=20;i&&i>200&&(f=i/10);for(var l=1/f,s=l/10,v=0;f>=v;v++){var y=v*l,p=[o.apply(void 0,_(t.concat([y]))),o.apply(void 0,_(r.concat([y])))],h=N(c[0],c[1],p[0],p[1]);u>h&&(a=y,u=h)}if(0===a)return{x:t[0],y:r[0]};if(1===a){var d=t.length;return{x:t[d-1],y:r[d-1]}}u=1/0;for(var b=0;32>b&&1e-4<=s;b++){var m=a-s,g=a+s,x=[o.apply(void 0,_(t.concat([m]))),o.apply(void 0,_(r.concat([m])))],P=N(c[0],c[1],x[0],x[1]);if(m>=0&&u>P)a=m,u=P;else{var w=[o.apply(void 0,_(t.concat([g]))),o.apply(void 0,_(r.concat([g])))],O=N(c[0],c[1],w[0],w[1]);1>=g&&u>O?(a=g,u=O):s*=.5}}return{x:o.apply(void 0,_(t.concat([a]))),y:o.apply(void 0,_(r.concat([a])))}}function R(t,r,n,e,o,i){var a=[n-t,e-r];if(function(t,r){return t[0]===r[0]&&t[1]===r[1]}(a,[0,0]))return Math.sqrt((o-t)*(o-t)+(i-r)*(i-r));var u=[-a[1],a[0]];return function(t,r){var n=r[0],e=r[1],o=n*n+e*e;o>0&&(o=1/Math.sqrt(o)),t[0]=r[0]*o,t[1]=r[1]*o}(u,u),Math.abs(function(t,r){return t[0]*r[0]+t[1]*r[1]}([o-t,i-r],u))}function q(t,r,n,e,o){var i=1-o;return i*i*i*t+3*r*o*i*i+3*n*o*o*i+e*o*o*o}function D(t,r,n,e,o,i,a,u,c,f,l){var s=function(t,r,n,e,o,i,a,u,c,f,l){return H([t,n,o,a],[r,e,i,u],c,f,q,l)}(t,r,n,e,o,i,a,u,c,f,l);return N(s.x,s.y,c,f)}function B(t,r,n,e){var o=1-e;return o*o*t+2*e*o*r+e*e*n}function Y(t,r,n,e,o,i,a,u){var c=function(t,r,n,e,o,i,a,u){return H([t,n,o],[r,e,i],a,u,B)}(t,r,n,e,o,i,a,u);return N(c.x,c.y,a,u)}function U(t,n,e){var o=t.parsedStyle,i=o.cx,a=o.cy,u=o.r,c=o.fill,f=o.stroke,l=o.lineWidth,s=o.increasedLineWidthForHitTesting,v=o.pointerEvents,y=void 0===v?"auto":v,p=((void 0===l?1:l)+(void 0===s?0:s))/2,h=N(void 0===i?0:i,void 0===a?0:a,n.x,n.y),d=C(r.isFillOrStrokeAffected(y,c,f),2),b=d[0],m=d[1];return b&&m||e?u+p>=h:b?u>=h:!!m&&(h>=u-p&&u+p>=h)}function Q(t,r,n,e){return t/(n*n)+r/(e*e)}function X(t,n,e){var o=t.parsedStyle,i=o.cx,a=void 0===i?0:i,u=o.cy,c=void 0===u?0:u,f=o.rx,l=o.ry,s=o.lineWidth,v=void 0===s?1:s,y=o.increasedLineWidthForHitTesting,p=void 0===y?0:y,h=o.pointerEvents,d=n.x,b=n.y,m=C(r.isFillOrStrokeAffected(void 0===h?"auto":h,o.fill,o.stroke),2),g=m[0],x=m[1],P=(v+p)/2,w=(d-a)*(d-a),O=(b-c)*(b-c);return g&&x||e?1>=Q(w,O,f+P,l+P):g?1>=Q(w,O,f,l):!!x&&(Q(w,O,f-P,l-P)>=1&&1>=Q(w,O,f+P,l+P))}function Z(t,r,n,e,o,i){return!(t>o||o>t+n||r>i||i>r+e)}function $(t,r,n,e,o,i,a,u){var c=(Math.atan2(u-r,a-t)+2*Math.PI)%(2*Math.PI),f={x:t+n*Math.cos(c),y:r+n*Math.sin(c)};return N(f.x,f.y,a,u)<=i/2}function z(t,r,n,e,o,i,a){var u=o/2;return!(Math.min(t,n)-u>i||i>Math.max(t,n)+u||Math.min(r,e)-u>a||a>Math.max(r,e)+u)&&R(t,r,n,e,i,a)<=o/2}function J(t,r,n,e,o){var i=t.length;if(2>i)return!1;for(var a=0;i-1>a;a++){if(z(t[a][0],t[a][1],t[a+1][0],t[a+1][1],r,n,e))return!0}if(o){var u=t[0],c=t[i-1];if(z(u[0],u[1],c[0],c[1],r,n,e))return!0}return!1}function K(t){return 1e-6>Math.abs(t)?0:0>t?-1:1}function V(t,r,n){return!((n[0]-t[0])*(r[1]-t[1])!==(r[0]-t[0])*(n[1]-t[1])||Math.min(t[0],r[0])>n[0]||n[0]>Math.max(t[0],r[0])||Math.min(t[1],r[1])>n[1]||n[1]>Math.max(t[1],r[1]))}function tt(t,r,n){var e=!1,o=t.length;if(2>=o)return!1;for(var i=0;o>i;i++){var a=t[i],u=t[(i+1)%o];if(V(a,u,[r,n]))return!0;K(a[1]-n)>0!=K(u[1]-n)>0&&0>K(r-(n-a[1])*(a[0]-u[0])/(a[1]-u[1])-a[0])&&(e=!e)}return e}function rt(t,r,n){for(var e=!1,o=0;t.length>o;o++){if(e=tt(t[o],r,n))break}return e}function nt(t,n,e){var o=t.parsedStyle,i=o.x1,a=o.y1,u=o.x2,c=o.y2,f=o.lineWidth,l=void 0===f?1:f,s=o.increasedLineWidthForHitTesting,v=void 0===s?0:s,y=o.pointerEvents;return!(!C(r.isFillOrStrokeAffected(void 0===y?"auto":y,o.fill,o.stroke),2)[1]&&!e||!l)&&z(i,a,u,c,l+v,n.x,n.y)}function et(t,n,e,o,i,a){var u=t.parsedStyle,c=u.lineWidth,f=void 0===c?1:c,l=u.increasedLineWidthForHitTesting,s=void 0===l?0:l,v=u.d,y=u.pointerEvents,p=v.segments,h=v.hasArc,d=v.polylines,b=v.polygons,m=C(r.isFillOrStrokeAffected(void 0===y?"auto":y,(null==b?void 0:b.length)&&u.fill,u.stroke),2),g=m[0],x=m[1],P=r.getOrCalculatePathTotalLength(t),w=!1;return g||e?w=h?o(t,n):rt(b,n.x,n.y)||rt(d,n.x,n.y)
//# sourceMappingURL=index.umd.min.js.map