@visactor/vchart
Version: 
charts lib based @visactor/VGrammar
15 lines (13 loc) • 2.16 MB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).VChart={})}(this,(function(t){"use strict";
/*! *****************************************************************************
    Copyright (c) Microsoft Corporation.
    Permission to use, copy, modify, and/or distribute this software for any
    purpose with or without fee is hereby granted.
    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
    REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
    AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
    INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
    LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
    OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
    PERFORMANCE OF THIS SOFTWARE.
    ***************************************************************************** */function e(t,e){var i={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(s=Object.getOwnPropertySymbols(t);n<s.length;n++)e.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(t,s[n])&&(i[s[n]]=t[s[n]])}return i}function i(t,e,i,s){return new(i||(i=Promise))((function(n,r){function a(t){try{l(s.next(t))}catch(t){r(t)}}function o(t){try{l(s.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}l((s=s.apply(t,e||[])).next())}))}const s=t=>t;var n,r;function a(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}t.RenderModeEnum=void 0,(n=t.RenderModeEnum||(t.RenderModeEnum={}))["desktop-browser"]="desktop-browser",n["mobile-browser"]="mobile-browser",n.node="node",n.worker="worker",n.miniApp="miniApp",n.wx="wx",n.tt="tt",n.harmony="harmony",n["desktop-miniApp"]="desktop-miniApp",n.lynx="lynx",function(t){t.cartesianAxis="cartesianAxis",t.cartesianBandAxis="cartesianAxis-band",t.cartesianLinearAxis="cartesianAxis-linear",t.cartesianTimeAxis="cartesianAxis-time",t.cartesianLogAxis="cartesianAxis-log",t.cartesianSymlogAxis="cartesianAxis-symlog",t.polarAxis="polarAxis",t.polarBandAxis="polarAxis-band",t.polarLinearAxis="polarAxis-linear",t.crosshair="crosshair",t.cartesianCrosshair="cartesianCrosshair",t.polarCrosshair="polarCrosshair",t.dataZoom="dataZoom",t.geoCoordinate="geoCoordinate",t.indicator="indicator",t.discreteLegend="discreteLegend",t.continuousLegend="continuousLegend",t.colorLegend="colorLegend",t.sizeLegend="sizeLegend",t.markLine="markLine",t.markArea="markArea",t.markPoint="markPoint",t.polarMarkLine="polarMarkLine",t.polarMarkArea="polarMarkArea",t.polarMarkPoint="polarMarkPoint",t.geoMarkPoint="geoMarkPoint",t.tooltip="tooltip",t.title="title",t.player="player",t.scrollBar="scrollBar",t.label="label",t.totalLabel="totalLabel",t.brush="brush",t.poptip="poptip",t.customMark="customMark"}(r||(r={}));var o={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,i="~";function s(){}function n(t,e,i){this.fn=t,this.context=e,this.once=i||!1}function r(t,e,s,r,a){if("function"!=typeof s)throw new TypeError("The listener must be a function");var o=new n(s,r||t,a),l=i?i+e:e;return t._events[l]?t._events[l].fn?t._events[l]=[t._events[l],o]:t._events[l].push(o):(t._events[l]=o,t._eventsCount++),t}function a(t,e){0==--t._eventsCount?t._events=new s:delete t._events[e]}function o(){this._events=new s,this._eventsCount=0}Object.create&&(s.prototype=Object.create(null),(new s).__proto__||(i=!1)),o.prototype.eventNames=function(){var t,s,n=[];if(0===this._eventsCount)return n;for(s in t=this._events)e.call(t,s)&&n.push(i?s.slice(1):s);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(t)):n},o.prototype.listeners=function(t){var e=i?i+t:t,s=this._events[e];if(!s)return[];if(s.fn)return[s.fn];for(var n=0,r=s.length,a=new Array(r);n<r;n++)a[n]=s[n].fn;return a},o.prototype.listenerCount=function(t){var e=i?i+t:t,s=this._events[e];return s?s.fn?1:s.length:0},o.prototype.emit=function(t,e,s,n,r,a){var o=i?i+t:t;if(!this._events[o])return!1;var l,h,c=this._events[o],d=arguments.length;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),d){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,s),!0;case 4:return c.fn.call(c.context,e,s,n),!0;case 5:return c.fn.call(c.context,e,s,n,r),!0;case 6:return c.fn.call(c.context,e,s,n,r,a),!0}for(h=1,l=new Array(d-1);h<d;h++)l[h-1]=arguments[h];c.fn.apply(c.context,l)}else{var u,p=c.length;for(h=0;h<p;h++)switch(c[h].once&&this.removeListener(t,c[h].fn,void 0,!0),d){case 1:c[h].fn.call(c[h].context);break;case 2:c[h].fn.call(c[h].context,e);break;case 3:c[h].fn.call(c[h].context,e,s);break;case 4:c[h].fn.call(c[h].context,e,s,n);break;default:if(!l)for(u=1,l=new Array(d-1);u<d;u++)l[u-1]=arguments[u];c[h].fn.apply(c[h].context,l)}}return!0},o.prototype.on=function(t,e,i){return r(this,t,e,i,!1)},o.prototype.once=function(t,e,i){return r(this,t,e,i,!0)},o.prototype.removeListener=function(t,e,s,n){var r=i?i+t:t;if(!this._events[r])return this;if(!e)return a(this,r),this;var o=this._events[r];if(o.fn)o.fn!==e||n&&!o.once||s&&o.context!==s||a(this,r);else{for(var l=0,h=[],c=o.length;l<c;l++)(o[l].fn!==e||n&&!o[l].once||s&&o[l].context!==s)&&h.push(o[l]);h.length?this._events[r]=1===h.length?h[0]:h:a(this,r)}return this},o.prototype.removeAllListeners=function(t){var e;return t?(e=i?i+t:t,this._events[e]&&a(this,e)):(this._events=new s,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=i,o.EventEmitter=o,t.exports=o}(o);var l=a(o.exports);var h=(t,e)=>Object.prototype.toString.call(t)===`[object ${e}]`;var c=(t,e=!1)=>e?"boolean"==typeof t:!0===t||!1===t||h(t,"Boolean");var d=t=>"function"==typeof t;var u=t=>null==t;var p=t=>null!=t;var g=t=>{const e=typeof t;return null!==t&&"object"===e||"function"===e};var f=t=>"object"==typeof t&&null!==t;var m=function(t){if(!f(t)||!h(t,"Object"))return!1;if(null===Object.getPrototypeOf(t))return!0;let e=t;for(;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e};var v=t=>void 0===t;var y=(t,e=!1)=>{const i=typeof t;return e?"string"===i:"string"===i||h(t,"String")};var _=t=>Array.isArray?Array.isArray(t):h(t,"Array");var b=function(t){return null!==t&&"function"!=typeof t&&Number.isFinite(t.length)};var x=t=>h(t,"Date");var S=(t,e=!1)=>{const i=typeof t;return e?"number"===i:"number"===i||h(t,"Number")};var A=t=>"string"==typeof t&&!isNaN(Number(t))&&!isNaN(parseFloat(t));var k=t=>S(t)&&Number.isFinite(t);var T=t=>new RegExp(/^(http(s)?:\/\/)\w+[^\s]+(\.[^\s]+){1,}$/).test(t);var M=t=>new RegExp(/^data:image\/(?:gif|png|jpeg|bmp|webp|svg\+xml)(?:;charset=utf-8)?;base64,(?:[A-Za-z0-9]|[+/])+={0,2}/g).test(t);var C=t=>({}.toString.call(t).replace(/^\[object /,"").replace(/]$/,""));const w=Object.prototype;var E=function(t){const e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||w)};const B=Object.prototype.hasOwnProperty;function P(t){if(u(t))return!0;if(b(t))return!t.length;const e=C(t);if("Map"===e||"Set"===e)return!t.size;if(E(t))return!Object.keys(t).length;for(const e in t)if(B.call(t,e))return!1;return!0}var R=(t,e,i)=>{const s=y(e)?e.split("."):e;for(let e=0;e<s.length;e++)t=t?t[s[e]]:void 0;return void 0===t?i:t};const I=Object.prototype.hasOwnProperty;var L=(t,e)=>null!=t&&I.call(t,e);function O(t,e,i){let s;if(!p(t)||"object"!=typeof t||e&&e(t))return t;const n=_(t),r=t.length;s=n?new Array(r):"object"==typeof t?{}:c(t)||S(t)||y(t)?t:x(t)?new Date(+t):void 0;const a=n?void 0:Object.keys(Object(t));let o=-1;if(s)for(;++o<(a||t).length;){const n=a?a[o]:o,r=t[n];i&&i.includes(n.toString())?s[n]=r:s[n]=O(r,e,i)}return s}function D(t,e,i=!1,s=!1){if(e){if(t===e)return;if(p(e)&&"object"==typeof e){const n=Object(e),r=[];for(const t in n)r.push(t);let{length:a}=r,o=-1;for(;a--;){const a=r[++o];!p(n[a])||"object"!=typeof n[a]||s&&_(t[a])?z(t,a,n[a]):F(t,e,a,i,s)}}}}function F(t,e,i,s=!1,n=!1){const r=t[i],a=e[i];let o=e[i],l=!0;if(_(a)){if(s)o=[];else if(_(r))o=r;else if(b(r)){o=new Array(r.length);let t=-1;const e=r.length;for(;++t<e;)o[t]=r[t]}}else m(a)?(o=null!=r?r:{},"function"!=typeof r&&"object"==typeof r||(o={})):l=!1;l&&D(o,a,s,n),z(t,i,o)}function z(t,e,i){(void 0!==i&&!function(t,e){return t===e||Number.isNaN(t)&&Number.isNaN(e)}(t[e],i)||void 0===i&&!(e in t))&&(t[e]=i)}function j(t,...e){let i=-1;const s=e.length;for(;++i<s;)D(t,e[i],!0);return t}function H(t,e){if(!t||!m(t))return t;const i={};return Object.keys(t).forEach((s=>{const n=t[s];let r=!1;e.forEach((t=>{(y(t)&&t===s||t instanceof RegExp&&s.match(t))&&(r=!0)})),r||(i[s]=n)})),i}function N(t){return Object.prototype.toString.call(t)}function V(t){return Object.keys(t)}function U(t,e,i){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(null==t||null==e)return!1;if(Number.isNaN(t)&&Number.isNaN(e))return!0;if(N(t)!==N(e))return!1;if(d(t))return!!(null==i?void 0:i.skipFunction);if("object"!=typeof t)return!1;if(_(t)){if(t.length!==e.length)return!1;for(let s=t.length-1;s>=0;s--)if(!U(t[s],e[s],i))return!1;return!0}if(!m(t))return!1;const s=V(t),n=V(e);if(s.length!==n.length)return!1;s.sort(),n.sort();for(let t=s.length-1;t>=0;t--)if(s[t]!=n[t])return!1;for(let n=s.length-1;n>=0;n--){const r=s[n];if(!U(t[r],e[r],i))return!1}return!0}function W(t,e,i){const s=function(t){if(!t)return[];if(Object.keys)return Object.keys(t);const e=[];for(const i in t)t.hasOwnProperty(i)&&e.push(i);return e}(e);for(let n=0;n<s.length;n++){const r=s[n];(i?null!=e[r]:null==t[r])&&(t[r]=e[r])}return t}function G(t,e,i=!0){if(t="prototype"in t?t.prototype:t,e="prototype"in e?e.prototype:e,Object.getOwnPropertyNames){const s=Object.getOwnPropertyNames(e);for(let n=0;n<s.length;n++){const r=s[n];"constructor"!==r&&(i?null!=e[r]:null==t[r])&&(t[r]=e[r])}}else W(t,e,i)}function Y(t){return p(t)?_(t)?t:[t]:[]}function X(t){if(b(t))return t[t.length-1]}const $=(t,e)=>{var i;if(0===t.length)return;let s=t[0];for(let n=1;n<t.length;n++){const r=t[n];(null!==(i=null==e?void 0:e(r,s))&&void 0!==i?i:r-s)>0&&(s=r)}return s},K=(t,e)=>{var i;if(0===t.length)return;let s=t[0];for(let n=1;n<t.length;n++){const r=t[n];(null!==(i=null==e?void 0:e(r,s))&&void 0!==i?i:r-s)<0&&(s=r)}return s};function q(t,e){if(!_(t)||!_(e))return!1;if(t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!==e[i])return!1;return!0}function Z(t,e=Math.random){let i,s,n=t.length;for(;n;)i=Math.floor(e()*n),s=t[--n],t[n]=t[i],t[i]=s;return t}function J(t){if(!_(t))return[t];const e=[];for(const i of t)e.push(...J(i));return e}function Q(t,e,i){p(e)||(e=t,t=0),p(i)||(i=1);let s=-1;const n=0|Math.max(0,Math.ceil((e-t)/i)),r=new Array(n);for(;++s<n;)r[s]=t+s*i;return r}function et(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function it(t){return Number(t)}const st="undefined"!=typeof console;function nt(t,e,i){const s=[e].concat([].slice.call(i));st&&console[t].apply(console,s)}var rt;!function(t){t[t.None=0]="None",t[t.Error=1]="Error",t[t.Warn=2]="Warn",t[t.Info=3]="Info",t[t.Debug=4]="Debug"}(rt||(rt={}));class at{static getInstance(t,e){return at._instance&&S(t)?at._instance.level(t):at._instance||(at._instance=new at(t,e)),at._instance}static setInstance(t){return at._instance=t}static setInstanceLevel(t){at._instance?at._instance.level(t):at._instance=new at(t)}static clearInstance(){at._instance=null}constructor(t=rt.None,e){this._onErrorHandler=[],this._level=t,this._method=e}addErrorHandler(t){this._onErrorHandler.find((e=>e===t))||this._onErrorHandler.push(t)}removeErrorHandler(t){const e=this._onErrorHandler.findIndex((e=>e===t));e<0||this._onErrorHandler.splice(e,1)}callErrorHandler(...t){this._onErrorHandler.forEach((e=>e(...t)))}canLogInfo(){return this._level>=rt.Info}canLogDebug(){return this._level>=rt.Debug}canLogError(){return this._level>=rt.Error}canLogWarn(){return this._level>=rt.Warn}level(t){return arguments.length?(this._level=+t,this):this._level}error(...t){var e;return this._level>=rt.Error&&(this._onErrorHandler.length?this.callErrorHandler(...t):nt(null!==(e=this._method)&&void 0!==e?e:"error","ERROR",t)),this}warn(...t){return this._level>=rt.Warn&&nt(this._method||"warn","WARN",t),this}info(...t){return this._level>=rt.Info&&nt(this._method||"log","INFO",t),this}debug(...t){return this._level>=rt.Debug&&nt(this._method||"log","DEBUG",t),this}}function ot(t,e,i=0,s){for(u(s)&&(s=t.length);i<s;){const n=i+s>>>1;et(t[n],e)>0?s=n:i=n+1}return i}at._instance=null;const lt=(t,e)=>ht(0,t.length,(i=>e(t[i]))),ht=(t,e,i)=>{let s=t,n=e;for(;s<n;){const t=Math.floor((s+n)/2);i(t)>=0?n=t:s=t+1}return s},ct=(t,e)=>{let i=t;return!0!==e&&(i=t.sort(et)),function(t,e,i=it){const s=t.length;if(!s)return;if(e<=0||s<2)return i(t[0],0,t);if(e>=1)return i(t[s-1],s-1,t);const n=(s-1)*e,r=Math.floor(n),a=i(t[r],r,t);return a+(i(t[r+1],r+1,t)-a)*(n-r)}(i,.5)},dt=1e-10,ut=1e-10;function pt(t,e,i=ut,s=dt){const n=s,r=i*Math.max(t,e);return Math.abs(t-e)<=Math.max(n,r)}function gt(t,e,i,s){return t>e&&!pt(t,e,i,s)}function ft(t,e,i,s){return t<e&&!pt(t,e,i,s)}const mt=t=>{let e=null,i=null;return(...s)=>(e&&s.every(((t,i)=>t===e[i]))||(e=s,i=t(...s)),i)};var vt=function(t,e,i){return t<e?e:t>i?i:t};var yt=(t,e,i)=>{let[s,n]=t;n<s&&(s=t[1],n=t[0]);const r=n-s;return r>=i-e?[e,i]:(s=Math.min(Math.max(s,e),i-r),[s,s+r])};function _t(t,e){let i;return t>e&&(i=t,t=e,e=i),i=>Math.max(t,Math.min(e,i))}let bt=!1;try{bt="function"==typeof requestAnimationFrame&&"function"==typeof cancelAnimationFrame}catch(t){bt=!1}function xt(t,e,i){let s,n,r,a,o,l,h=0,c=!1,d=!1,u=!0;const p=!e&&0!==e&&bt;if("function"!=typeof t)throw new TypeError("Expected a function");function f(e){const i=s,r=n;return s=n=void 0,h=e,a=t.apply(r,i),a}function m(t,e){return p?(cancelAnimationFrame(o),requestAnimationFrame(t)):setTimeout(t,e)}function v(t){const i=t-l;return void 0===l||i>=e||i<0||d&&t-h>=r}function y(){const t=Date.now();if(v(t))return _(t);o=m(y,function(t){const i=t-h,s=e-(t-l);return d?Math.min(s,r-i):s}(t))}function _(t){return o=void 0,u&&s?f(t):(s=n=void 0,a)}function b(...t){const i=Date.now(),r=v(i);if(s=t,n=this,l=i,r){if(void 0===o)return function(t){return h=t,o=m(y,e),c?f(t):a}(l);if(d)return o=m(y,e),f(l)}return void 0===o&&(o=m(y,e)),a}return e=+e||0,g(i)&&(c=!!i.leading,d="maxWait"in i,d&&(r=Math.max(k(i.maxWait)?i.maxWait:0,e)),u="trailing"in i?!!i.trailing:u),b.cancel=function(){void 0!==o&&function(t){if(p)return cancelAnimationFrame(t);clearTimeout(t)}(o),h=0,s=l=n=o=void 0},b.flush=function(){return void 0===o?a:_(Date.now())},b.pending=function(){return void 0!==o},b}function St(t,e,i){let s=!0,n=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return g(i)&&(s="leading"in i?!!i.leading:s,n="trailing"in i?!!i.trailing:n),xt(t,e,{leading:s,trailing:n,maxWait:e})}function At(t,e){return i=>t*(1-i)+e*i}function kt(t,e){return function(i){return Math.round(t*(1-i)+e*i)}}function Tt(t){if(k(t))return t;const e=+t;return k(e)?e:0}function Mt(t){return parseFloat("0."+Math.sin(t).toString().substring(6))}bt=!1;const Ct=4294967296;const wt=t=>e=>R(e,t),Et=(t,e={})=>{if(d(t))return t;const i=[t];return(e&&e.get||wt)(i)},Bt=(t,e={})=>{if(_(t)){const i=t.map((t=>Et(t,e)));return t=>i.map((e=>e(t)))}return Et(t,e)},Pt=t=>t?"string"==typeof t||"number"==typeof t?()=>t:d(t)?t:e=>e[t.field]:null,Rt=(t,e)=>u(t)?e:y(t)?e*parseFloat(t)/100:t,It=t=>0,Lt=(t,e)=>{const i=d(e)?e:t=>t;let s,n;if(t&&t.length){const e=t.length;for(let r=0;r<e;r+=1){let e=i(t[r]);u(e)||!S(e=+e)||Number.isNaN(e)||(u(s)?(s=e,n=e):(s=Math.min(s,e),n=Math.max(n,e)))}return[s,n]}return[s,n]};function Ot(t,e,i,s){let n,r,a=-1;t.forEach((t=>{n=e(t),r=i(t),!u(n)&&(n=+n)>=n&&!u(r)&&(r=+r)>=r&&s(n,r,++a)}))}function Dt(t,e,i,s,n){let r=0,a=0;return Ot(t,e,i,((t,e)=>{const i=e-n(t),o=e-s;r+=i*i,a+=o*o})),1-r/a}function Ft(t,e=(t=>t.x),i=(t=>t.y)){let s=0,n=0,r=0,a=0,o=0;Ot(t,e,i,((t,e)=>{++o,s+=(t-s)/o,n+=(e-n)/o,r+=(t*e-r)/o,a+=(t*t-a)/o}));const l=function(t,e,i,s){const n=s-t*t,r=Math.abs(n)<1e-24?0:(i-t*e)/n;return[e-r*t,r]}(s,n,r,a),h=t=>l[0]+l[1]*t;return{coef:l,predict:h,rSquared:Dt(t,e,i,n,h)}}const zt=1e-12,jt=Math.PI,Ht=jt/2,Nt=2*jt,Vt=2*Math.PI,Ut=Math.abs,Wt=Math.atan2,Gt=Math.cos,Yt=Math.max,Xt=Math.min,$t=Math.sin,Kt=Math.sqrt,qt=Math.pow;function Zt(t){return t>=1?Ht:t<=-1?-Ht:Math.asin(t)}function Jt(t,e,i,s,n){let r=i,a=s;return"number"==typeof t&&"number"==typeof i&&(r=(1-n)*t+n*i),"number"==typeof e&&"number"==typeof s&&(a=(1-n)*e+n*s),{x:r,y:a}}function Qt(t,e){return t[0]*e[1]-t[1]*e[0]}function te(t,e){let i=0;for(let s=0;s<t.length;++s)i+=t[s]*e[s];return i}function ee(t,e=10){return Math.round(t*e)/e}function ie(t){const e=t.toString().split(/[eE]/),i=(e[0].split(".")[1]||"").length-(+e[1]||0);return i>0?i:0}function se(t,e){return ee(t+e,10**Math.max(ie(t),ie(e)))}function ne(t,e){return ee(t-e,10**Math.max(ie(t),ie(e)))}class re{constructor(t=0,e=0,i,s){this.x=0,this.y=0,this.x=t,this.y=e,this.x1=i,this.y1=s}clone(){return new re(this.x,this.y)}copyFrom(t){return this.x=t.x,this.y=t.y,this.x1=t.x1,this.y1=t.y1,this.defined=t.defined,this.context=t.context,this}set(t,e){return this.x=t,this.y=e,this}add(t){return S(t)?(this.x+=t,void(this.y+=t)):(this.x+=t.x,this.y+=t.y,this)}sub(t){return S(t)?(this.x-=t,void(this.y-=t)):(this.x-=t.x,this.y-=t.y,this)}multi(t){throw new Error("暂不支持")}div(t){throw new Error("暂不支持")}}class ae{static distancePP(t,e){return Kt(qt(t.x-e.x,2)+qt(t.y-e.y,2))}static distanceNN(t,e,i,s){return Kt(qt(t-i,2)+qt(e-s,2))}static distancePN(t,e,i){return Kt(qt(e-t.x,2)+qt(i-t.y,2))}static pointAtPP(t,e,i){return new re((e.x-t.x)*i+t.x,(e.y-t.y)*i+t.y)}}function oe(t){return t*(Math.PI/180)}function le(t){return 180*t/Math.PI}const he=(t=0)=>{if(t<0)for(;t<-Nt;)t+=Nt;else if(t>0)for(;t>Nt;)t-=Nt;return t};function ce(t,e,i){return e?{x:t.x+e*Math.cos(i),y:t.y+e*Math.sin(i)}:{x:t.x,y:t.y}}function de(t,e={x:0,y:0},i=0,s=2*Math.PI){const{x:n,y:r}=t,{x:a,y:o}=e;let l=n-a,h=r-o;const c=Math.sqrt(l*l+h*h);if(0===c)return{radius:0,angle:0};l/=c,h/=c;let d=Math.atan2(h,l);if(d<i)for(;d<=i;)d+=2*Math.PI;if(d>s)for(;d>=s;)d-=2*Math.PI;return{radius:c,angle:d}}function ue(t,e){return Math.atan2(e.y-t.y,e.x-t.x)}function pe(t){for(;t<0;)t+=2*Math.PI;for(;t>=2*Math.PI;)t-=2*Math.PI;return t}function ge(t,e,i,s){const{x:n,y:r}=e,a=function(t,e){const i=Math.abs(e-t);if(i>=2*Math.PI||2*Math.PI-i<1e-6)return[0,Math.PI/2,Math.PI,1.5*Math.PI];const s=pe(Math.min(t,e)),n=s+i,r=[s,n];let a=Math.floor(s/Math.PI)*Math.PI/2;for(;a<n;)a>s&&r.push(a),a+=Math.PI/2;return r}(i,s),{width:o,height:l}=t,h=[];return a.forEach((t=>{const e=Math.sin(t),i=Math.cos(t);1===e?h.push(l-r):-1===e?h.push(r):1===i?h.push(o-n):-1===i?h.push(n):(e>0?h.push(Math.abs((l-r)/e)):h.push(Math.abs(r/e)),i>0?h.push(Math.abs((o-n)/i)):h.push(Math.abs(n/i)))})),Math.min.apply(null,h)}function fe(t){return(t=pe(t))>0&&t<=Math.PI/2?2:t>Math.PI/2&&t<=Math.PI?3:t>Math.PI&&t<=3*Math.PI/2?4:1}function me(t,e,i){t[0]=e[0]-i[0],t[1]=e[1]-i[1]}function ve(t,e,i,s){let n=t[0],r=e[0],a=i[0],o=s[0];return r<n&&([n,r]=[r,n]),o<a&&([o,a]=[a,o]),!(r<a||o<n||(n=t[1],r=e[1],a=i[1],o=s[1],r<n&&([n,r]=[r,n]),o<a&&([o,a]=[a,o]),r<a||o<n))}function ye(t,e,i,s){if(!ve(t,e,i,s))return!1;const n=[0,0],r=[0,0],a=[0,0];if(me(n,e,t),me(r,s,i),function(t,e){return Ut(t[0]-e[0])+Ut(t[1]-e[1])<1e-12}(n,r))return!0;me(a,i,t);const o=Qt(a,r)/Qt(n,r);return o>=0&&o<=1&&[t[0]+n[0]*o,t[1]+n[1]*o]}function _e(t,e,i){if(null===t)return e;if(null===e)return t;const{x11:s,x12:n,y11:r,y12:a,x21:o,x22:l,y21:h,y22:c}=xe(t,e,i);return s>=l||n<=o||r>=c||a<=h?{x1:0,y1:0,x2:0,y2:0}:{x1:Math.max(s,o),y1:Math.max(r,h),x2:Math.min(n,l),y2:Math.min(a,c)}}var be;!function(t){t[t.NONE=0]="NONE",t[t.BBOX1=1]="BBOX1",t[t.BBOX2=2]="BBOX2"}(be||(be={}));const xe=(t,e,i)=>{let s=t.x1,n=t.x2,r=t.y1,a=t.y2,o=e.x1,l=e.x2,h=e.y1,c=e.y2;return i&&(s>n&&([s,n]=[n,s]),r>a&&([r,a]=[a,r]),o>l&&([o,l]=[l,o]),h>c&&([h,c]=[c,h])),{x11:s,x12:n,y11:r,y12:a,x21:o,x22:l,y21:h,y22:c}};function Se(t,e,i){if(!t||!e)return be.NONE;const{x11:s,x12:n,y11:r,y12:a,x21:o,x22:l,y21:h,y22:c}=xe(t,e,i);return s>o&&n<l&&r>h&&a<c?be.BBOX1:o>s&&l<n&&h>r&&c<a?be.BBOX2:be.NONE}function Ae(t,e,i){if(t&&e){if(!i)return!(t.x1>e.x2||t.x2<e.x1||t.y1>e.y2||t.y2<e.y1);const{x11:s,x12:n,y11:r,y12:a,x21:o,x22:l,y21:h,y22:c}=xe(t,e,!0);return!(s>l||n<o||r>c||a<h)}return!0}function ke(t,e,i){if(!e)return!0;if(!i)return t.x>=e.x1&&t.x<=e.x2&&t.y>=e.y1&&t.y<=e.y2;let s=e.x1,n=e.x2,r=e.y1,a=e.y2;return s>n&&([s,n]=[n,s]),r>a&&([r,a]=[a,r]),t.x>=s&&t.x<=n&&t.y>=r&&t.y<=a}function Te(t,e){return Math.abs(e[0]*t[0]+e[1]*t[1])}function Me({x:t,y:e},i,s={x:0,y:0}){return{x:(t-s.x)*Math.cos(i)-(e-s.y)*Math.sin(i)+s.x,y:(t-s.x)*Math.sin(i)+(e-s.y)*Math.cos(i)+s.y}}function Ce(t){return{x:(t.x1+t.x2)/2,y:(t.y1+t.y2)/2}}function we(t,e){const i=e?oe(t.angle):t.angle,s=Ce(t);return[Me({x:t.x1,y:t.y1},i,s),Me({x:t.x2,y:t.y1},i,s),Me({x:t.x2,y:t.y2},i,s),Me({x:t.x1,y:t.y2},i,s)]}function Ee(t,e,i=!1){const s=we(t,i),n=we(e,i),r=(t,e)=>[e.x-t.x,e.y-t.y],a=r(Ce(t),Ce(e)),o=r(s[0],s[1]),l=r(s[1],s[2]),h=r(n[0],n[1]),c=r(n[1],n[2]),d=i?oe(t.angle):t.angle;let u=i?oe(90-t.angle):t.angle+Ht;const p=i?oe(e.angle):e.angle;let g=i?oe(90-e.angle):e.angle+Ht;u>Vt&&(u-=Vt),g>Vt&&(g-=Vt);const f=(t,e,i,s)=>{const n=[Math.cos(e),Math.sin(e)];return t+(Te(n,i)+Te(n,s))/2>Te(n,a)};return f((t.x2-t.x1)/2,d,h,c)&&f((t.y2-t.y1)/2,u,h,c)&&f((e.x2-e.x1)/2,p,o,l)&&f((e.y2-e.y1)/2,g,o,l)}const Be=1e-8;function Pe(t,e,i,s,n){for(let r=0,a=n[n.length-1];r<n.length;r++){const o=n[r];if(ve([t,e],[i,s],[o.x,o.y],[a.x,a.y]))return!0;a=o}return!1}function Re(t,e,i){let s=0,n=t[0];if(!n)return!1;for(let r=1;r<t.length;r++){const a=t[r];s+=Ie(n.x,n.y,a.x,a.y,e,i),n=a}const r=t[0];return Le(n.x,r.x)&&Le(n.y,r.y)||(s+=Ie(n.x,n.y,r.x,r.y,e,i)),0!==s}function Ie(t,e,i,s,n,r){if(r>e&&r>s||r<e&&r<s)return 0;if(s===e)return 0;const a=(r-e)/(s-e);let o=s<e?1:-1;1!==a&&0!==a||(o=s<e?.5:-.5);const l=a*(i-t)+t;return l===n?1/0:l>n?o:0}function Le(t,e){return Math.abs(t-e)<Be}const Oe=t=>{let e=t.charCodeAt(0),i=2===t.length?t.charCodeAt(1):0,s=e;return 55296<=e&&e<=56319&&56320<=i&&i<=57343&&(e&=1023,i&=1023,s=e<<10|i,s+=65536),12288===s||65281<=s&&s<=65376||65504<=s&&s<=65510?"F":8361===s||65377<=s&&s<=65470||65474<=s&&s<=65479||65482<=s&&s<=65487||65490<=s&&s<=65495||65498<=s&&s<=65500||65512<=s&&s<=65518?"H":4352<=s&&s<=4447||4515<=s&&s<=4519||4602<=s&&s<=4607||9001<=s&&s<=9002||11904<=s&&s<=11929||11931<=s&&s<=12019||12032<=s&&s<=12245||12272<=s&&s<=12283||12289<=s&&s<=12350||12353<=s&&s<=12438||12441<=s&&s<=12543||12549<=s&&s<=12589||12593<=s&&s<=12686||12688<=s&&s<=12730||12736<=s&&s<=12771||12784<=s&&s<=12830||12832<=s&&s<=12871||12880<=s&&s<=13054||13056<=s&&s<=19903||19968<=s&&s<=42124||42128<=s&&s<=42182||43360<=s&&s<=43388||44032<=s&&s<=55203||55216<=s&&s<=55238||55243<=s&&s<=55291||63744<=s&&s<=64255||65040<=s&&s<=65049||65072<=s&&s<=65106||65108<=s&&s<=65126||65128<=s&&s<=65131||110592<=s&&s<=110593||127488<=s&&s<=127490||127504<=s&&s<=127546||127552<=s&&s<=127560||127568<=s&&s<=127569||131072<=s&&s<=194367||177984<=s&&s<=196605||196608<=s&&s<=262141?"W":32<=s&&s<=126||162<=s&&s<=163||165<=s&&s<=166||172===s||175===s||10214<=s&&s<=10221||10629<=s&&s<=10630?"Na":161===s||164===s||167<=s&&s<=168||170===s||173<=s&&s<=174||176<=s&&s<=180||182<=s&&s<=186||188<=s&&s<=191||198===s||208===s||215<=s&&s<=216||222<=s&&s<=225||230===s||232<=s&&s<=234||236<=s&&s<=237||240===s||242<=s&&s<=243||247<=s&&s<=250||252===s||254===s||257===s||273===s||275===s||283===s||294<=s&&s<=295||299===s||305<=s&&s<=307||312===s||319<=s&&s<=322||324===s||328<=s&&s<=331||333===s||338<=s&&s<=339||358<=s&&s<=359||363===s||462===s||464===s||466===s||468===s||470===s||472===s||474===s||476===s||593===s||609===s||708===s||711===s||713<=s&&s<=715||717===s||720===s||728<=s&&s<=731||733===s||735===s||768<=s&&s<=879||913<=s&&s<=929||931<=s&&s<=937||945<=s&&s<=961||963<=s&&s<=969||1025===s||1040<=s&&s<=1103||1105===s||8208===s||8211<=s&&s<=8214||8216<=s&&s<=8217||8220<=s&&s<=8221||8224<=s&&s<=8226||8228<=s&&s<=8231||8240===s||8242<=s&&s<=8243||8245===s||8251===s||8254===s||8308===s||8319===s||8321<=s&&s<=8324||8364===s||8451===s||8453===s||8457===s||8467===s||8470===s||8481<=s&&s<=8482||8486===s||8491===s||8531<=s&&s<=8532||8539<=s&&s<=8542||8544<=s&&s<=8555||8560<=s&&s<=8569||8585===s||8592<=s&&s<=8601||8632<=s&&s<=8633||8658===s||8660===s||8679===s||8704===s||8706<=s&&s<=8707||8711<=s&&s<=8712||8715===s||8719===s||8721===s||8725===s||8730===s||8733<=s&&s<=8736||8739===s||8741===s||8743<=s&&s<=8748||8750===s||8756<=s&&s<=8759||8764<=s&&s<=8765||8776===s||8780===s||8786===s||8800<=s&&s<=8801||8804<=s&&s<=8807||8810<=s&&s<=8811||8814<=s&&s<=8815||8834<=s&&s<=8835||8838<=s&&s<=8839||8853===s||8857===s||8869===s||8895===s||8978===s||9312<=s&&s<=9449||9451<=s&&s<=9547||9552<=s&&s<=9587||9600<=s&&s<=9615||9618<=s&&s<=9621||9632<=s&&s<=9633||9635<=s&&s<=9641||9650<=s&&s<=9651||9654<=s&&s<=9655||9660<=s&&s<=9661||9664<=s&&s<=9665||9670<=s&&s<=9672||9675===s||9678<=s&&s<=9681||9698<=s&&s<=9701||9711===s||9733<=s&&s<=9734||9737===s||9742<=s&&s<=9743||9748<=s&&s<=9749||9756===s||9758===s||9792===s||9794===s||9824<=s&&s<=9825||9827<=s&&s<=9829||9831<=s&&s<=9834||9836<=s&&s<=9837||9839===s||9886<=s&&s<=9887||9918<=s&&s<=9919||9924<=s&&s<=9933||9935<=s&&s<=9953||9955===s||9960<=s&&s<=9983||10045===s||10071===s||10102<=s&&s<=10111||11093<=s&&s<=11097||12872<=s&&s<=12879||57344<=s&&s<=63743||65024<=s&&s<=65039||65533===s||127232<=s&&s<=127242||127248<=s&&s<=127277||127280<=s&&s<=127337||127344<=s&&s<=127386||917760<=s&&s<=917999||983040<=s&&s<=1048573||1048576<=s&&s<=1114109?"A":"N"};function De(t,e={},i){i||(i=1);const{fontStyle:s=e.fontStyle,fontVariant:n=e.fontVariant,fontWeight:r=e.fontWeight,fontSize:a=e.fontSize,fontFamily:o=e.fontFamily}=t;return(s?s+" ":"")+(n?n+" ":"")+(r?r+" ":"")+a*i+"px "+(o||"sans-serif")}class Fe{constructor(t,e){this._numberCharSize=null,this._fullCharSize=null,this._letterCharSize=null,this._specialCharSizeMap={},this._canvas=null,this._context=null,this._contextSaved=!1,this._notSupportCanvas=!1,this._notSupportVRender=!1,this._userSpec={},this.specialCharSet="-/: .,@%'\"~",this._option=t,this._userSpec=null!=e?e:{},this.textSpec=this._initSpec(),p(t.specialCharSet)&&(this.specialCharSet=t.specialCharSet),this._standardMethod=p(t.getTextBounds)?this.fullMeasure.bind(this):this.measureWithNaiveCanvas.bind(this)}initContext(){if(this._notSupportCanvas)return!1;if(u(this._canvas)&&(p(this._option.getCanvasForMeasure)&&(this._canvas=this._option.getCanvasForMeasure()),u(this._canvas)&&"undefined"!=typeof window&&void 0!==window.document&&globalThis&&p(globalThis.document)&&(this._canvas=globalThis.document.createElement("canvas"))),u(this._context)&&p(this._canvas)){const t=this._canvas.getContext("2d");p(t)&&(t.save(),t.font=De(this.textSpec),this._contextSaved=!0,this._context=t)}return!u(this._context)||(this._notSupportCanvas=!0,!1)}_initSpec(){var t,e,i;const{defaultFontParams:s={}}=this._option,{fontStyle:n=s.fontStyle,fontVariant:r=s.fontVariant,fontWeight:a=(null!==(t=s.fontWeight)&&void 0!==t?t:"normal"),fontSize:o=(null!==(e=s.fontSize)&&void 0!==e?e:12),fontFamily:l=(null!==(i=s.fontFamily)&&void 0!==i?i:"sans-serif"),align:h,textAlign:c=(null!=h?h:"center"),baseline:d,textBaseline:u=(null!=d?d:"middle"),ellipsis:p,limit:g}=this._userSpec;let{lineHeight:f=o}=this._userSpec;if(y(f)&&"%"===f[f.length-1]){const t=Number.parseFloat(f.substring(0,f.length-1))/100;f=o*t}return{fontStyle:n,fontVariant:r,fontFamily:l,fontSize:o,fontWeight:a,textAlign:c,textBaseline:u,ellipsis:p,limit:g,lineHeight:f}}measure(t,e){switch(e){case"vrender":case"canopus":return this.fullMeasure(t);case"canvas":return this.measureWithNaiveCanvas(t);case"simple":return this.quickMeasureWithoutCanvas(t);default:return this.quickMeasure(t)}}fullMeasure(t){if(u(t))return{width:0,height:0};if(u(this._option.getTextBounds)||!this._notSupportVRender)return this.measureWithNaiveCanvas(t);const{fontFamily:e,fontSize:i,fontWeight:s,textAlign:n,textBaseline:r,ellipsis:a,limit:o,lineHeight:l}=this.textSpec;let h;try{const c=this._option.getTextBounds({text:t,fontFamily:e,fontSize:i,fontWeight:s,textAlign:n,textBaseline:r,ellipsis:!!a,maxLineWidth:o||1/0,lineHeight:l});h={width:c.width(),height:c.height()}}catch(e){this._notSupportVRender=!0,h=this.measureWithNaiveCanvas(t)}return h}measureWithNaiveCanvas(t){return this._measureReduce(t,this._measureWithNaiveCanvas.bind(this))}_measureWithNaiveCanvas(t){var e;if(!this.initContext())return this._quickMeasureWithoutCanvas(t);const i=this._context.measureText(t),{fontSize:s,lineHeight:n}=this.textSpec;return{width:i.width,height:null!==(e=n)&&void 0!==e?e:s,fontBoundingBoxAscent:i.fontBoundingBoxAscent,fontBoundingBoxDescent:i.fontBoundingBoxDescent}}quickMeasure(t){return this._measureReduce(t,this._quickMeasure.bind(this))}_quickMeasure(t){const e={width:0,height:0};for(let i=0;i<t.length;i++){const s=t[i];let n=this._measureSpecialChar(s);u(n)&&Fe.NUMBERS_CHAR_SET.includes(s)&&(n=this._measureNumberChar()),u(n)&&["F","W"].includes(Oe(s))&&(n=this._measureFullSizeChar()),u(n)&&(n=this._measureLetterChar()),e.width+=n.width,e.height=Math.max(e.height,n.height),!u(n.fontBoundingBoxAscent)&&(e.fontBoundingBoxAscent=n.fontBoundingBoxAscent),!u(n.fontBoundingBoxDescent)&&(e.fontBoundingBoxDescent=n.fontBoundingBoxDescent)}return e}quickMeasureWithoutCanvas(t){return this._measureReduce(t,this._quickMeasureWithoutCanvas.bind(this))}_quickMeasureWithoutCanvas(t){var e;const i={width:0,height:0},{fontSize:s,lineHeight:n}=this.textSpec;for(let e=0;e<t.length;e++){const n=t[e],r=["F","W"].includes(Oe(n))?1:.53;i.width+=r*s}return i.height=null!==(e=n)&&void 0!==e?e:s,i}_measureReduce(t,e){var i;const{fontSize:s,lineHeight:n}=this.textSpec,r={width:0,height:0};if(u(t))return r;if(_(t)){const a=t.filter(p).map((t=>t.toString()));return 0===a.length?r:1===a.length?e(a[0]):{width:a.reduce(((t,i)=>Math.max(t,e(i).width)),0),height:a.length*((null!==(i=n)&&void 0!==i?i:s)+1)+1}}return e(t.toString())}_measureNumberChar(){if(u(this._numberCharSize)){const t=this._standardMethod(Fe.NUMBERS_CHAR_SET);this._numberCharSize={width:t.width/Fe.NUMBERS_CHAR_SET.length,height:t.height,fontBoundingBoxAscent:t.fontBoundingBoxAscent,fontBoundingBoxDescent:t.fontBoundingBoxDescent}}return this._numberCharSize}_measureFullSizeChar(){return u(this._fullCharSize)&&(this._fullCharSize=this._standardMethod(Fe.FULL_SIZE_CHAR)),this._fullCharSize}_measureLetterChar(){if(u(this._letterCharSize)){const t=this._standardMethod(Fe.ALPHABET_CHAR_SET);this._letterCharSize={width:t.width/Fe.ALPHABET_CHAR_SET.length,height:t.height,fontBoundingBoxAscent:t.fontBoundingBoxAscent,fontBoundingBoxDescent:t.fontBoundingBoxDescent}}return this._letterCharSize}_measureSpecialChar(t){return p(this._specialCharSizeMap[t])?this._specialCharSizeMap[t]:this.specialCharSet.includes(t)?(this._specialCharSizeMap[t]=this._standardMethod(t),this._specialCharSizeMap[t]):null}release(){p(this._canvas)&&(this._canvas=null),p(this._context)&&(this._contextSaved&&(this._context.restore(),this._contextSaved=!1),this._context=null)}}Fe.ALPHABET_CHAR_SET="abcdefghijklmnopqrstuvwxyz",Fe.NUMBERS_CHAR_SET="0123456789",Fe.FULL_SIZE_CHAR="字";const ze=(t,e)=>{const{x1:i,x2:s,y1:n,y2:r}=t,a=Math.abs(s-i),o=Math.abs(r-n);let l=(i+s)/2,h=(n+r)/2,c=0,d=0;switch(e){case"top":case"inside-top":d=-.5;break;case"bottom":case"inside-bottom":d=.5;break;case"left":case"inside-left":c=-.5;break;case"right":case"inside-right":c=.5;break;case"top-right":c=.5,d=-.5;break;case"top-left":c=-.5,d=-.5;break;case"bottom-right":c=.5,d=.5;break;case"bottom-left":c=-.5,d=.5}return l+=c*a,h+=d*o,{x:l,y:h}},je=(t,e)=>Math.max(e.x1-t.x2,t.x1-e.x2,e.y1-t.y2,t.y1-e.y2),He=(t,e)=>{const i=[{x:Math.cos(t.angle),y:Math.sin(t.angle)},{x:-Math.sin(t.angle),y:Math.cos(t.angle)},{x:Math.cos(e.angle),y:Math.sin(t.angle)},{x:-Math.sin(e.angle),y:Math.cos(t.angle)}];function s(t,e,i){const s=t.getRotatedCorners().map((t=>t.x*e+t.y*i));return{min:Math.min(...s),max:Math.max(...s)}}let n=0;for(const r of i){const i=s(t,r.x,r.y),a=s(e,r.x,r.y);let o;o=i.max<a.min?a.min-i.max:a.max<i.min?i.min-a.max:0,n=Math.max(n,o)}return n};function Ne(t,e,i){const{x1:s,y1:n,x2:r,y2:a}=e;return i.onlyTranslate()?(t!==e&&t.setValue(e.x1,e.y1,e.x2,e.y2),t.translate(i.e,i.f),e):(t.clear(),t.add(i.a*s+i.c*n+i.e,i.b*s+i.d*n+i.f),t.add(i.a*r+i.c*n+i.e,i.b*r+i.d*n+i.f),t.add(i.a*r+i.c*a+i.e,i.b*r+i.d*a+i.f),t.add(i.a*s+i.c*a+i.e,i.b*s+i.d*a+i.f),e)}class Ve{constructor(t){t?this.setValue(t.x1,t.y1,t.x2,t.y2):this.clear()}clone(){return new Ve(this)}clear(){return this.x1=+Number.MAX_VALUE,this.y1=+Number.MAX_VALUE,this.x2=-Number.MAX_VALUE,this.y2=-Number.MAX_VALUE,this}empty(){return this.x1===+Number.MAX_VALUE&&this.y1===+Number.MAX_VALUE&&this.x2===-Number.MAX_VALUE&&this.y2===-Number.MAX_VALUE}equals(t){return this.x1===t.x1&&this.y1===t.y1&&this.x2===t.x2&&this.y2===t.y2}setValue(t=0,e=0,i=0,s=0){return this.x1=t,this.y1=e,this.x2=i,this.y2=s,this}set(t=0,e=0,i=0,s=0){return i<t?(this.x2=t,this.x1=i):(this.x1=t,this.x2=i),s<e?(this.y2=e,this.y1=s):(this.y1=e,this.y2=s),this}add(t=0,e=0){return t<this.x1&&(this.x1=t),e<this.y1&&(this.y1=e),t>this.x2&&(this.x2=t),e>this.y2&&(this.y2=e),this}expand(t=0){return _(t)?(this.y1-=t[0],this.x2+=t[1],this.y2+=t[2],this.x1-=t[3]):(this.x1-=t,this.y1-=t,this.x2+=t,this.y2+=t),this}round(){return this.x1=Math.floor(this.x1),this.y1=Math.floor(this.y1),this.x2=Math.ceil(this.x2),this.y2=Math.ceil(this.y2),this}translate(t=0,e=0){return this.x1+=t,this.x2+=t,this.y1+=e,this.y2+=e,this}rotate(t=0,e=0,i=0){const s=this.rotatedPoints(t,e,i);return this.clear().add(s[0],s[1]).add(s[2],s[3]).add(s[4],s[5]).add(s[6],s[7])}scale(t=0,e=0,i=0,s=0){const n=this.scalePoints(t,e,i,s);return this.clear().add(n[0],n[1]).add(n[2],n[3])}union(t){return t.x1<this.x1&&(this.x1=t.x1),t.y1<this.y1&&(this.y1=t.y1),t.x2>this.x2&&(this.x2=t.x2),t.y2>this.y2&&(this.y2=t.y2),this}intersect(t){return t.x1>this.x1&&(this.x1=t.x1),t.y1>this.y1&&(this.y1=t.y1),t.x2<this.x2&&(this.x2=t.x2),t.y2<this.y2&&(this.y2=t.y2),this}encloses(t){return t&&this.x1<=t.x1&&this.x2>=t.x2&&this.y1<=t.y1&&this.y2>=t.y2}alignsWith(t){return t&&(this.x1===t.x1||this.x2===t.x2||this.y1===t.y1||this.y2===t.y2)}intersects(t){return t&&!(this.x2<t.x1||this.x1>t.x2||this.y2<t.y1||this.y1>t.y2)}contains(t=0,e=0){return!(t<this.x1||t>this.x2||e<this.y1||e>this.y2)}containsPoint(t){return!(t.x<this.x1||t.x>this.x2||t.y<this.y1||t.y>this.y2)}width(){return this.empty()?0:this.x2-this.x1}height(){return this.empty()?0:this.y2-this.y1}scaleX(t=0){return this.x1*=t,this.x2*=t,this}scaleY(t=0){return this.y1*=t,this.y2*=t,this}transformWithMatrix(t){return Ne(this,this,t),this}copy(t){return this.x1=t.x1,this.y1=t.y1,this.x2=t.x2,this.y2=t.y2,this}rotatedPoints(t,e,i){const{x1:s,y1:n,x2:r,y2:a}=this,o=Math.cos(t),l=Math.sin(t),h=e-e*o+i*l,c=i-e*l-i*o;return[o*s-l*n+h,l*s+o*n+c,o*s-l*a+h,l*s+o*a+c,o*r-l*n+h,l*r+o*n+c,o*r-l*a+h,l*r+o*a+c]}scalePoints(t,e,i,s){const{x1:n,y1:r,x2:a,y2:o}=this;return[t*n+(1-t)*i,e*r+(1-e)*s,t*a+(1-t)*i,e*o+(1-e)*s]}}class Ue extends Ve{}class We extends Ve{constructor(t,e=0){var i;super(t),t&&(this.angle=null!==(i=t.angle)&&void 0!==i?i:e)}intersects(t){return Ee(this,t)}setValue(t=0,e=0,i=0,s=0,n=0){return super.setValue(t,e,i,s),this.angle=n,this}clone(){return new We(this)}getRotatedCorners(){const t={x:(this.x1+this.x2)/2,y:(this.y1+this.y2)/2};return[Me({x:this.x1,y:this.y1},this.angle,t),Me({x:this.x2,y:this.y1},this.angle,t),Me({x:this.x1,y:this.y2},this.angle,t),Me({x:this.x2,y:this.y2},this.angle,t)]}}class Ge{constructor(t=1,e=0,i=0,s=1,n=0,r=0){this.a=t,this.b=e,this.c=i,this.d=s,this.e=n,this.f=r}equalToMatrix(t){return!(this.e!==t.e||this.f!==t.f||this.a!==t.a||this.d!==t.d||this.b!==t.b||this.c!==t.c)}equalTo(t,e,i,s,n,r){return!(this.e!==n||this.f!==r||this.a!==t||this.d!==s||this.b!==e||this.c!==i)}setValue(t,e,i,s,n,r){return this.a=t,this.b=e,this.c=i,this.d=s,this.e=n,this.f=r,this}reset(){return this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0,this}getInverse(){const t=this.a,e=this.b,i=this.c,s=this.d,n=this.e,r=this.f,a=new Ge,o=t*s-e*i;return a.a=s/o,a.b=-e/o,a.c=-i/o,a.d=t/o,a.e=(i*r-s*n)/o,a.f=-(t*r-e*n)/o,a}rotate(t){const e=Math.cos(t),i=Math.sin(t),s=this.a*e+this.c*i,n=this.b*e+this.d*i,r=this.a*-i+this.c*e,a=this.b*-i+this.d*e;return this.a=s,this.b=n,this.c=r,this.d=a,this}rotateByCenter(t,e,i){const s=Math.cos(t),n=Math.sin(t),r=(1-s)*e+n*i,a=(1-s)*i-n*e,o=s*this.a-n*this.b,l=n*this.a+s*this.b,h=s*this.c-n*this.d,c=n*this.c+s*this.d,d=s*this.e-n*this.f+r,u=n*this.e+s*this.f+a;return this.a=o,this.b=l,this.c=h,this.d=c,this.e=d,this.f=u,this}scale(t,e){return this.a*=t,this.b*=t,this.c*=e,this.d*=e,this}setScale(t,e){return this.b=this.b/this.a*t,this.c=this.c/this.d*e,this.a=t,this.d=e,this}transform(t,e,i,s,n,r){return this.multiply(t,e,i,s,n,r),this}translate(t,e){return this.e+=this.a*t+this.c*e,this.f+=this.b*t+this.d*e,this}transpose(){const{a:t,b:e,c:i,d:s,e:n,f:r}=this;return this.a=e,this.b=t,this.c=s,this.d=i,this.e=r,this.f=n,this}multiply(t,e,i,s,n,r){const a=this.a,o=this.b,l=this.c,h=this.d,c=a*t+l*e,d=o*t+h*e,u=a*i+l*s,p=o*i+h*s,g=a*n+l*r+this.e,f=o*n+h*r+this.f;return this.a=c,this.b=d,this.c=u,this.d=p,this.e=g,this.f=f,this}interpolate(t,e){const i=new Ge;return i.a=this.a+(t.a-this.a)*e,i.b=this.b+(t.b-this.b)*e,i.c=this.c+(t.c-this.c)*e,i.d=this.d+(t.d-this.d)*e,i.e=this.e+(t.e-this.e)*e,i.f=this.f+(t.f-this.f)*e,i}transformPoint(t,e){const{a:i,b:s,c:n,d:r,e:a,f:o}=this,l=i*r-s*n,h=r/l,c=-s/l,d=-n/l,u=i/l,p=(n*o-r*a)/l,g=-(i*o-s*a)/l,{x:f,y:m}=t;e.x=f*h+m*d+p,e.y=f*c+m*u+g}onlyTranslate(t=1){return this.a===t&&0===this.b&&0===this.c&&this.d===t}clone(){return new Ge(this.a,this.b,this.c,this.d,this.e,this.f)}toTransformAttrs(){const t=this.a,e=this.b,i=this.c,s=this.d,n=t*s-e*i,r={x:this.e,y:this.f,rotateDeg:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!==t||0!==e){const a=Math.sqrt(t*t+e*e);r.rotateDeg=e>0?Math.acos(t/a):-Math.acos(t/a),r.scaleX=a,r.scaleY=n/a,r.skewX=(t*i+e*s)/n,r.skewY=0}else if(0!==i||0!==s){const a=Math.sqrt(i*i+s*s);r.rotateDeg=Math.PI/2-(s>0?Math.acos(-i/a):-Math.acos(i/a)),r.scaleX=n/a,r.scaleY=a,r.skewX=0,r.skewY=(t*i+e*s)/n}return r.rotateDeg=le(r.rotateDeg),r}}class Ye{constructor(){this.CLEAN_THRESHOLD=1e3,this.L_TIME=1e3,this.R_COUNT=1,this.R_TIMESTAMP_MAX_SIZE=20}clearCache(t,e){const{CLEAN_THRESHOLD:i=this.CLEAN_THRESHOLD,L_TIME:s=this.L_TIME,R_COUNT:n=this.R_COUNT}=e;if(t.size<i)return 0;let r=0;const a=e=>{r++,t.delete(e)},o=Date.now();return t.forEach(((t,e)=>{if(t.timestamp.length<n)return a(e);let i=0;for(;o-t.timestamp[t.timestamp.length-1-i]<s&&(i++,!(i>=n)););if(i<n)return a(e);for(;o-t.timestamp[0]>s;)t.timestamp.shift()})),r}addLimitedTimestamp(t,e,i){const{R_TIMESTAMP_MAX_SIZE:s=this.R_TIMESTAMP_MAX_SIZE}=i;t.timestamp.length>s&&t.timestamp.shift(),t.timestamp.push(e)}clearTimeStamp(t,e){const{L_TIME:i=this.L_TIME}=e,s=Date.now();t.forEach((t=>{for(;s-t.timestamp[0]>i;)t.timestamp.shift()}))}clearItemTimestamp(t,e){const{L_TIME:i=this.L_TIME}=e,s=Date.now();for(;s-t.timestamp[0]>i;)t.timestamp.shift()}}function Xe(t,e,i){e/=100,i/=100;const s=(1-Math.abs(2*i-1))*e,n=s*(1-Math.abs(t/60%2-1)),r=i-s/2;let a=0,o=0,l=0;return 0<=t&&t<60?(a=s,o=n,l=0):60<=t&&t<120?(a=n,o=s,l=0):120<=t&&t<180?(a=0,o=s,l=n):180<=t&&t<240?(a=0,o=n,l=s):240<=t&&t<300?(a=n,o=0,l=s):300<=t&&t<360&&(a=s,o=0,l=n),a=Math.round(255*(a+r)),o=Math.round(255*(o+r)),l=Math.round(255*(l+r)),{r:a,g:o,b:l}}function $e(t,e,i){t/=255,e/=255,i/=255;const s=Math.min(t,e,i),n=Math.max(t,e,i),r=n-s;let a=0,o=0,l=0;return a=0===r?0:n===t?(e-i)/r%6:n===e?(i-t)/r+2:(t-e)/r+4,a=Math.round(60*a),a<0&&(a+=360),l=(n+s)/2,o=0===r?0:r/(1-Math.abs(2*l-1)),o=+(100*o).toFixed(1),l=+(100*l).toFixed(1),{h:a,s:o,l:l}}const Ke=/^#([0-9a-f]{3,8})$/,qe={transparent:4294967040},Ze={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function Je(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function Qe(t){return S(t)?new ni(t>>16,t>>8&255,255&t,1):_(t)?new ni(t[0],t[1],t[2]):new ni(255,255,255)}function ti(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function ei(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}const ii=(t,e)=>{const i=Ke.exec(t);if(e||i){const t=parseInt(i[1],16),e=i[1].length;return 3===e?new ni((t>>8&15)+((t>>8&15)<<4),(t>>4&15)+((t>>4&15)<<4),(15&t)+((15&t)<<4),1):6===e?Qe(t):8===e?new ni(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):null}};class si{static Brighter(t,e=1){return 1===e?t:new si(t).brighter(e).toRGBA()}static SetOpacity(t,e=1){return 1===e?t:new si(t).setOpacity(e).toRGBA()}static getColorBrightness(t,e="hsl"){const i=t instanceof si?t:new si(t);switch(e){case"hsv":default:return i.getHSVBrightness();case"hsl":return i.getHSLBrightness();case"lum":return i.getLuminance();case"lum2":return i.getLuminance2();case"lum3":return i.getLuminance3();case"wcag":return i.getLuminanceWCAG()}}static parseColorString(t){if(p(qe[t]))return function(t){return S(t)?new ni(t>>>24,t>>>16&255,t>>>8&255,255&t):_(t)?new ni(t[0],t[1],t[2],t[3]):new ni(255,255,255,1)}(qe[t]);if(p(Ze[t]))return Qe(Ze[t]);const e=`${t}`.trim().toLowerCase(),i=ii(e);if(void 0!==i)return i;if(/^(rgb|RGB|rgba|RGBA)/.test(e)){const t=e.replace(/(?:\(|\)|rgba|RGBA|rgb|RGB)*/g,"").split(",");return new ni(parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10),parseFloat(t[3]))}if(/^(hsl|HSL|hsla|HSLA)/.test(e)){const t=e.replace(/(?:\(|\)|hsla|HSLA|hsl|HSL)*/g,"").split(","),i=Xe(parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10));return new ni(i.r,i.g,i.b,parseFloat(t[3]))}}constructor(t){const e=si.parseColorString(t);e?this.color=e:(console.warn(`Warn: 传入${t}无法解析为Color`),this.color=new ni(255,255,255))}toRGBA(){return this.color.formatRgb()}toString(){return this.color.formatRgb()}toHex(){return this.color.formatHex()}toHsl(){return this.color.formatHsl()}brighter(t){const{r:e,g:i,b:s}=this.color;return this.color.r=Math.max(0,Math.min(255,Math.floor(e*t))),this.color.g=Math.max(0,Math.min(255,Math.floor(i*t))),this.color.b=Math.max(0,Math.min(255,Math.floor(s*t))),this}add(t){const{r:e,g:i,b:s}=this.color;return this.color.r+=Math.min(255,e+t.color.r),this.color.g+=Math.min(255,i+t.color.g),this.color.b+=Math.min(255,s+t.color.b),this}sub(t){return this.color.r=Math.max(0,this.color.r-t.color.r),this.color.g=Math.max(0,this.color.g-t.color.g),this.color.b=Math.max(0,this.color.b-t.color.b),this}multiply(t){const{r:e,g:i,b:s}=this.color;return this.color.r=Math.max(0,Math.min(255,Math.floor(e*t.color.r))),this.color.g=Math.max(0,Math.min(255,Math.floor(i*t.color.g))),this.color.b=Math.max(0,Math.min(255,Math.floor(s*t.color.b))),this}getHSVBrightness(){return Math.max(this.color.r,this.color.g,this.color.b)/255}getHSLBrightness(){return.5*(Math.max(this.color.r,this.color.g,this.color.b)/255+Math.min(this.color.r,this.color.g,this.color.b)/255)}setHsl(t,e,i){const s=this.color.opacity,n=$e(this.color.r,this.color.g,this.color.b),r=Xe(u(t)?n.h:vt(t,0,360),u(e)?n.s:e>=0&&e<=1?100*e:e,u(i)?n.l:i<=1&&i>=0?100*i:i);return this.color=new ni(r.r,r.g,r.b,s),this}setRGB(t,e,i){return!u(t)&&(this.color.r=t),!u(e)&&(this.color.g=e),!u(i)&&(this.color.b=i),this}setHex(t){const e=`${t}`.trim().toLowerCase(),i=ii(e,!0);return null!=i?i:this}setColorName(t){const e=Ze[t.toLowerCase()];return void 0!==e?this.setHex(e):console.warn("THREE.Color: Unknown color "+t),this}setScalar(t){return this.color.r=t,this.color.g=t,this.color.b=t,this}setOpacity(t=1){return this.color.opacity=t,this}getLuminance(){return(.2126*this.color.r+.7152*this.color.g+.0722*this.color.b)/255}getLuminance2(){return(.2627*this.color.r+.678*this.color.g+.0593*this.color.b)/255}getLuminance3(){return(.299*this.color.r+.587*this.color.g+.114*this.color.b)/255}getLuminanceWCAG(){const t=this.color.r/255,e=this.color.g/255,i=this.color.b/255;let s,n,r;return s=t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4),n=e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4),r=i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4),.2126*s+.7152*n+.0722*r}clone(){return new si(this.color.toString())}copyGammaToLinear(t,e=2){return this.color.r=Math.pow(t.color.r,e),this.color.g=Math.pow(t.color.g,e),this.color.b=Math.pow(t.color.b,e),this}copyLinearToGamma(t,e=2){const i=e>0?1/e:1;return this.color.r=Math.pow(t.color.r,i),this.color.g=Math.pow(t.color.g,i),this.color.b=Math.pow(t.color.b,i),this}convertGammaToLinear(t){return this.copyGammaToLinear(this,t),this}convertLinearToGamma(t){return this.copyLinearToGamma(this,t),this}copySRGBToLinear(t){return this.color.r=ti(t.color.r),this.color.g=ti(t.color.g),this.color.b=ti(t.color.b),this}copyLinearToSRGB(t){return this.color.r=ei(t.color.r),this.color.g=ei(t.color.g),this.color.b=ei(t.color.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}}class ni{constructor(t,e,i,s){this.r=isNaN(+t)?255:Math.max(0,Math.min(255,+t)),this.g=isNaN(+e)?255:Math.max(0,Math.min(255,+e)),this.b=isNaN(+i)?255:Math.max(0,Math.min(255,+i)),p(s)?this.opacity=isNaN(+s)?1:Math.max(0,Math.min(1,+s)):this.opacity=1}formatHex(){return`#${Je(this.r)+Je(this.g)+Je(this.b)+(1===this.opacity?"":Je(255*this.opacity))}`}formatRgb(){const t=this.opacity;return`${1===t?"rgb(":"rgba("}${this.r},${this.g},${this.b}${1===t?")":`,${t})`}`}formatHsl(){const t=this.opacity,{h:e,s:i,l:s}=$e(this.r,this.g,this.b);return`${1===t?"hsl(":"hsla("}${e},${i}%,${s}%${1===t?")":`,${t})`}`}toString(){return this.formatHex()}}function ri(t){let e="",i="",s="";const n="#"===t[0]?1:0;for(let r=n;r<t.length;r++)"#"!==t[r]&&(r<n+2?e+=t[r]:r<n+4?i+=t[r]:r<n+6&&(s+=t[r]));return[parseInt(e,16),parseInt(i,16),parseInt(s,16)]}var ai=Object.freeze({__proto__:null,Color:si,DEFAULT_COLORS:Ze,RGB:ni,hexToRgb:ri,hslToRgb:Xe,interpolateRgb:function(t,e){const i=t.r,s=e.r,n=t.g,r=e.g,a=t.b,o=e.b,l=t.opacity,h=e.opacity;return t=>{const e=Math.round(i*(1-t)+s*t),c=Math.round(n*(1-t)+r*t),d=Math.round(a*(1-t)+o*t);return new ni(e,c,d,l*(1-t)+h*t)}},rgbToHex:function(t,e,i){return Number((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1)},rgbToHsl:$e});function oi(t){if(k(t))return[t,t,t,t];if(_(t)){const e=t.length;if(1===e){const e=t[0];return[e,e,e,e]}if(2===e){const[e,i]=t;return[e,i,e,i]}if(3===e){const[e,i,s]=t;return[e,i,s,i]}if(4===e)return t}if(g(t)){const{top:e=0,right:i=0,bottom:s=0,left:n=0}=t;return[e,i,s,n]}return[0,0,0,0]}function li(t,e=0,i=0){if(!t)return{width:e,height:i};let s;try{s=null===window||void 0===window?void 0:window.getComputedStyle}catch(t){s=()=>({})}const n=s(t);if(/^(\d*\.?\d+)(px)$/.exec(n.width)){const s=parseFloat(n.width)-parseFloat(n.paddingLeft)-parseFloat(n.paddingRight)||t.clientWidth-1,r=parseFloat(n.height)-parseFloat(n.paddingTop)-parseFloat(n.padd