UNPKG

@visactor/vtable-gantt

Version:

canvas table width high performance

1 lines 1.87 MB
!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).VTableGantt={})}(this,(function(t){"use strict";var e,i,n,o;!function(t){t.default="default",t.grabing="grabing",t.scrolling="scrolling"}(e||(e={})),function(t){t.FinishToStart="finish_to_start",t.StartToStart="start_to_start",t.FinishToFinish="finish_to_finish",t.StartToFinish="start_to_finish"}(i||(i={})),function(t){t.Tasks_Separate="tasks_separate",t.Sub_Tasks_Inline="sub_tasks_inline",t.Sub_Tasks_Separate="sub_tasks_separate",t.Sub_Tasks_Arrange="sub_tasks_arrange",t.Sub_Tasks_Compact="sub_tasks_compact",t.Project_Sub_Tasks_Inline="project_sub_tasks_inline"}(n||(n={})),function(t){t.TASK="task",t.PROJECT="project",t.MILESTONE="milestone"}(o||(o={}));const r={SCROLL:"scroll",CHANGE_DATE_RANGE:"change_date_range",CLICK_TASK_BAR:"click_task_bar",CONTEXTMENU_TASK_BAR:"contextmenu_task_bar",MOUSEENTER_TASK_BAR:"mouseenter_task_bar",MOUSELEAVE_TASK_BAR:"mouseleave_task_bar",CREATE_TASK_SCHEDULE:"create_task_schedule",CREATE_DEPENDENCY_LINK:"create_dependency_link",DELETE_DEPENDENCY_LINK:"delete_dependency_link",CLICK_DEPENDENCY_LINK_POINT:"click_dependency_link_point",CONTEXTMENU_DEPENDENCY_LINK:"contextmenu_dependency_link",CLICK_MARKLINE_CREATE:"click_markline_create",CLICK_MARKLINE_CONTENT:"click_markline_content"};var s=Object.freeze({__proto__:null,get DependencyType(){return i},GANTT_EVENT_TYPE:r,get InteractionState(){return e},get TaskType(){return o},get TasksShowMode(){return n}});class a{static GenAutoIncrementId(){return a.auto_increment_id++}}a.auto_increment_id=0;class l{constructor(t){this.id=a.GenAutoIncrementId(),this.registry=t}}const h="named",d="inject",c="multi_inject",u="inversify:tagged",g="inversify:paramtypes";class p{constructor(t,e){this.key=t,this.value=e}toString(){return this.key===h?`named: ${String(this.value).toString()} `:`tagged: { key:${this.key.toString()}, value: ${String(this.value)} }`}}var f=function(t){var e;return function(t){const e="function"==typeof Symbol&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",i=Object.getPrototypeOf(Function),n=("object"==typeof process&&process.env&&process.env.REFLECT_METADATA_USE_MAP_POLYFILL,Map),o=new WeakMap;function r(t,e,i){let r=o.get(t);if(h(r)){if(!i)return;r=new n,o.set(t,r)}let s=r.get(e);if(h(s)){if(!i)return;s=new n,r.set(e,s)}return s}function s(t,e,i){if(a(t,e,i))return!0;const n=f(e);return!d(n)&&s(t,n,i)}function a(t,e,i){const n=r(e,i,!1);return!h(n)&&!!n.has(t)}function l(t,e,i){if(a(t,e,i))return function(t,e,i){const n=r(e,i,!1);if(!h(n))return n.get(t)}(t,e,i);const n=f(e);return d(n)?void 0:l(t,n,i)}function h(t){return void 0===t}function d(t){return null===t}function c(t){return"object"==typeof t?null!==t:"function"==typeof t}function u(t,i){switch(function(t){if(null===t)return 1;switch(typeof t){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===t?1:6;default:return 6}}(t)){case 0:case 1:case 2:case 3:case 4:case 5:return t}const n=3===i?"string":5===i?"number":"default",o=function(t,e){const i=t[e];if(null!=i){if(!p(i))throw new TypeError;return i}}(t,e);if(void 0!==o){const e=o.call(t,n);if(c(e))throw new TypeError;return e}return function(t,e){if("string"===e){const e=t.toString;if(p(e)){const i=e.call(t);if(!c(i))return i}const i=t.valueOf;if(p(i)){const e=i.call(t);if(!c(e))return e}}else{const e=t.valueOf;if(p(e)){const i=e.call(t);if(!c(i))return i}const i=t.toString;if(p(i)){const e=i.call(t);if(!c(e))return e}}throw new TypeError}(t,"default"===n?"number":n)}function g(t){const e=u(t,3);return"symbol"==typeof e?e:function(t){return""+t}(e)}function p(t){return"function"==typeof t}function f(t){const e=Object.getPrototypeOf(t);if("function"!=typeof t||t===i)return e;if(e!==i)return e;const n=t.prototype,o=n&&Object.getPrototypeOf(n);if(null==o||o===Object.prototype)return e;const r=o.constructor;return"function"!=typeof r||r===t?e:r}t("defineMetadata",(function(t,e,i,n){if(!c(i))throw new TypeError;return o=t,s=e,void r(i,n,!0).set(o,s);var o,s})),t("hasMetadata",(function(t,e,i){if(!c(e))throw new TypeError;return h(i)||(i=g(i)),s(t,e,i)})),t("hasOwnMetadata",(function(t,e,i){if(!c(e))throw new TypeError;return h(i)||(i=g(i)),a(t,e,i)})),t("getMetadata",(function(t,e,i){if(!c(e))throw new TypeError;return h(i)||(i=g(i)),l(t,e,i)}))}((e=t,function(t,i){"function"!=typeof e[t]&&Object.defineProperty(e,t,{configurable:!0,writable:!0,value:i})})),t}({});function b(t,e,i,n){!function(t,e,i,n){const o=[n];let r={};f.hasOwnMetadata(t,e)&&(r=f.getMetadata(t,e));let s=r[i];void 0===s&&(s=[]),s.push(...o),r[i]=s,f.defineMetadata(t,r,e)}(u,t,i.toString(),n)}function m(t){return(e,i,n)=>{b(e,0,n,t)}}function v(t){return e=>(i,n,o)=>m(new p(t,e))(i,n,o)}const y=v(d),C=v(c);function w(){return function(t){return f.defineMetadata(g,null,t),t}}function x(t){return m(new p(h,t))}const _="Singleton",S="Transient",A="ConstantValue",B="DynamicValue",T="Factory",R="Function",k="Instance",M="Invalid";class L{constructor(t,e){this.id=a.GenAutoIncrementId(),this.activated=!1,this.serviceIdentifier=t,this.scope=e,this.type=M,this.constraint=t=>!0,this.implementationType=null,this.cache=null,this.factory=null,this.provider=null,this.dynamicValue=null}clone(){const t=new L(this.serviceIdentifier,this.scope);return t.activated=t.scope===_&&this.activated,t.implementationType=this.implementationType,t.dynamicValue=this.dynamicValue,t.scope=this.scope,t.type=this.type,t.provider=this.provider,t.constraint=this.constraint,t.cache=this.cache,t}}class P{getConstructorMetadata(t){return{compilerGeneratedMetadata:f.getMetadata(g,t),userGeneratedMetadata:f.getMetadata(u,t)||{}}}getPropertiesMetadata(t){throw new Error("暂未实现")}}const E=(H=h,t=>{const e=e=>{if(null==e)return!1;if(e.key===H&&e.value===t)return!0;if(null==e.constructorArgsMetadata)return!1;const i=e.constructorArgsMetadata;for(let e=0;e<i.length;e++)if(i[e].key===H&&i[e].value===t)return!0;return!1};return e.metaData=new p(H,t),e});var H;class O{constructor(t){this._binding=t}inRequestScope(){throw new Error("暂未实现")}inSingletonScope(){return this._binding.scope=_,this}inTransientScope(){return this._binding.scope=S,this}whenTargetNamed(t){return this._binding.constraint=E(t),this}}class F{constructor(t){this._binding=t}to(t){return this._binding.type=k,this._binding.implementationType=t,new O(this._binding)}toSelf(){const t=this._binding.serviceIdentifier;return this.to(t)}toDynamicValue(t){return this._binding.type=B,this._binding.cache=null,this._binding.dynamicValue=t,this._binding.implementationType=null,new O(this._binding)}toConstantValue(t){return this._binding.type=A,this._binding.cache=t,this._binding.dynamicValue=null,this._binding.implementationType=null,this._binding.scope=_,new O(this._binding)}toFactory(t){return this._binding.type=T,this._binding.factory=t,this._binding.scope=_,new O(this._binding)}toService(t){this.toDynamicValue((e=>e.container.get(t)))}}const I=Symbol("ContributionProvider");class z{constructor(t,e){this.serviceIdentifier=t,this.container=e,W.setStore(this.serviceIdentifier,this)}getContributions(){return this.caches||(this.caches=[],this.container&&this.container.isBound(this.serviceIdentifier)&&this.caches.push(...this.container.getAll(this.serviceIdentifier))),this.caches}refresh(){this.caches&&(this.caches.length=0,this.container&&this.container.isBound(this.serviceIdentifier)&&this.caches.push(...this.container.getAll(this.serviceIdentifier)))}}function D(t,e){t(I).toDynamicValue((({container:t})=>new z(e,t))).inSingletonScope().whenTargetNamed(e)}class W{static getStore(t){return this.store.get(t)}static setStore(t,e){this.store.set(t,e)}static refreshAllContributions(){this.store.forEach((t=>{t.refresh()}))}}W.store=new Map;class N{constructor(t,e){this._args=t,this.name=e,this.taps=[]}tap(t,e){this._tap("sync",t,e)}unTap(t,e){const i="string"==typeof t?t.trim():t.name;i&&(this.taps=this.taps.filter((t=>!(t.name===i&&(!e||t.fn===e)))))}_parseOptions(t,e,i){let n;if("string"==typeof e)n={name:e.trim()};else if("object"!=typeof e||null===e)throw new Error("Invalid tap options");if("string"!=typeof n.name||""===n.name)throw new Error("Missing name for tap");return n=Object.assign({type:t,fn:i},n),n}_tap(t,e,i){this._insert(this._parseOptions(t,e,i))}_insert(t){let e;"string"==typeof t.before?e=new Set([t.before]):Array.isArray(t.before)&&(e=new Set(t.before));let i=0;"number"==typeof t.stage&&(i=t.stage);let n=this.taps.length;for(;n>0;){n--;const t=this.taps[n];this.taps[n+1]=t;const o=t.stage||0;if(e){if(e.has(t.name)){e.delete(t.name);continue}if(e.size>0)continue}if(!(o>i)){n++;break}}this.taps[n]=t}}class G extends N{call(...t){this.taps.map((t=>t.fn)).forEach((e=>e(...t)))}}const j=Symbol.for("EnvContribution"),V=Symbol.for("VGlobal");const U=new class{};let X=0;class ${constructor(){this.nextAnimationFrameCbs=new Map,this._rafHandle=null,this.runAnimationFrame=t=>{this._rafHandle=null;const e=this.nextAnimationFrameCbs;this.nextAnimationFrameCbs=new Map,e.forEach((e=>e(t)))},this.tryRunAnimationFrameNextFrame=()=>{null===this._rafHandle&&0!==this.nextAnimationFrameCbs.size&&(this._rafHandle=U.global.getRequestAnimationFrame()(this.runAnimationFrame))}}addAnimationFrameCb(t){return this.nextAnimationFrameCbs.set(++X,t),this.tryRunAnimationFrameNextFrame(),X}removeAnimationFrameCb(t){return!!this.nextAnimationFrameCbs.has(t)&&(this.nextAnimationFrameCbs.delete(t),!0)}}class Y{constructor(){this._listenerMap=new Map,this._eventListenerTransformer=t=>t}setEventListenerTransformer(t){this._eventListenerTransformer=t||(t=>t)}addEventListener(t,e,i){if(!e)return;const n=t=>{const i=this._eventListenerTransformer(t);"function"==typeof e?e(i):e.handleEvent&&e.handleEvent(i)};this._listenerMap.has(t)||this._listenerMap.set(t,new Map),this._listenerMap.get(t).set(e,n),this._nativeAddEventListener(t,n,i)}removeEventListener(t,e,i){var n;if(!e)return;const o=null===(n=this._listenerMap.get(t))||void 0===n?void 0:n.get(e);o&&(this._nativeRemoveEventListener(t,o,i),this._listenerMap.get(t).delete(e),0===this._listenerMap.get(t).size&&this._listenerMap.delete(t))}dispatchEvent(t){return this._nativeDispatchEvent(t)}clearAllEventListeners(){this._listenerMap.forEach(((t,e)=>{t.forEach(((t,i)=>{this._nativeRemoveEventListener(e,t,void 0)}))})),this._listenerMap.clear()}_nativeAddEventListener(t,e,i){throw new Error("_nativeAddEventListener must be implemented by derived classes")}_nativeRemoveEventListener(t,e,i){throw new Error("_nativeRemoveEventListener must be implemented by derived classes")}_nativeDispatchEvent(t){throw new Error("_nativeDispatchEvent must be implemented by derived classes")}}var K=function(t,e,i,n){var o,r=arguments.length,s=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(r<3?o(s):r>3?o(e,i,s):o(e,i))||s);return r>3&&s&&Object.defineProperty(e,i,s),s},q=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},Z=function(t,e){return function(i,n){e(i,n,t)}},J=function(t,e,i,n){return new(i||(i=Promise))((function(o,r){function s(t){try{l(n.next(t))}catch(t){r(t)}}function a(t){try{l(n.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}l((n=n.apply(t,e||[])).next())}))};let Q=class extends Y{get env(){return this._env}get isImageAnonymous(){return this._isImageAnonymous}set isImageAnonymous(t){this._isImageAnonymous=t}get devicePixelRatio(){return this._env||this.setEnv("browser"),this.envContribution.getDevicePixelRatio()}get supportEvent(){return this._env||this.setEnv("browser"),this.envContribution.supportEvent}set supportEvent(t){this._env||this.setEnv("browser"),this.envContribution.supportEvent=t}get supportsTouchEvents(){return this._env||this.setEnv("browser"),this.envContribution.supportsTouchEvents}set supportsTouchEvents(t){this._env||this.setEnv("browser"),this.envContribution.supportsTouchEvents=t}get supportsPointerEvents(){return this._env||this.setEnv("browser"),this.envContribution.supportsPointerEvents}set supportsPointerEvents(t){this._env||this.setEnv("browser"),this.envContribution.supportsPointerEvents=t}get supportsMouseEvents(){return this._env||this.setEnv("browser"),this.envContribution.supportsMouseEvents}set supportsMouseEvents(t){this._env||this.setEnv("browser"),this.envContribution.supportsMouseEvents=t}get applyStyles(){return this._env||this.setEnv("browser"),this.envContribution.applyStyles}set applyStyles(t){this._env||this.setEnv("browser"),this.envContribution.applyStyles=t}constructor(t){super(),this.contributions=t,this._isImageAnonymous=!0,this._performanceRAFList=[],this.eventListenerTransformer=t=>t,this.id=a.GenAutoIncrementId(),this.hooks={onSetEnv:new G(["lastEnv","env","global"])},this.measureTextMethod="native",this.optimizeVisible=!1}_nativeAddEventListener(t,e,i){return this._env||this.setEnv("browser"),this.envContribution.addEventListener(t,e,i)}_nativeRemoveEventListener(t,e,i){return this._env||this.setEnv("browser"),this.envContribution.removeEventListener(t,e,i)}_nativeDispatchEvent(t){return this._env||this.setEnv("browser"),this.envContribution.dispatchEvent(t)}bindContribution(t){const e=[];if(this.contributions.getContributions().forEach((i=>{const n=i.configure(this,t);n&&n.then&&e.push(n)})),e.length)return Promise.all(e)}getDynamicCanvasCount(){return this._env||this.setEnv("browser"),this.envContribution.getDynamicCanvasCount()}getStaticCanvasCount(){return this._env||this.setEnv("browser"),this.envContribution.getStaticCanvasCount()}setEnv(t,e){if(e&&!0===e.force||this._env!==t)return this.deactiveCurrentEnv(),this.activeEnv(t,e)}deactiveCurrentEnv(){this.envContribution&&this.envContribution.release()}activeEnv(t,e){const i=this._env;this._env=t;const n=this.bindContribution(e);if(n&&n.then)return n.then((()=>{this.envParams=e,this.hooks.onSetEnv.call(i,t,this)}));this.envParams=e,this.hooks.onSetEnv.call(i,t,this)}setActiveEnvContribution(t){this.envContribution=t}createCanvas(t){return this._env||this.setEnv("browser"),this.envContribution.createCanvas(t)}createOffscreenCanvas(t){return this._env||this.setEnv("browser"),this.envContribution.createOffscreenCanvas(t)}releaseCanvas(t){return this._env||this.setEnv("browser"),this.envContribution.releaseCanvas(t)}getRequestAnimationFrame(){return this._env||this.setEnv("browser"),this.envContribution.getRequestAnimationFrame()}getSpecifiedRequestAnimationFrame(t){this._env||this.setEnv("browser"),this._performanceRAFList[t]||(this._performanceRAFList[t]=new $);const e=this._performanceRAFList[t];return t=>e.addAnimationFrameCb(t)}getSpecifiedCancelAnimationFrame(t){if(this._env||this.setEnv("browser"),!this._performanceRAFList[t])return()=>!1;const e=this._performanceRAFList[t];return t=>e.removeAnimationFrameCb(t)}getCancelAnimationFrame(){return this._env||this.setEnv("browser"),this.envContribution.getCancelAnimationFrame()}getElementById(t){return this._env||this.setEnv("browser"),this.envContribution.getElementById?this.envContribution.getElementById(t):null}getRootElement(){return this._env||this.setEnv("browser"),this.envContribution.getRootElement?this.envContribution.getRootElement():null}getDocument(){return this._env||this.setEnv("browser"),this.envContribution.getDocument?this.envContribution.getDocument():null}mapToCanvasPoint(t,e){return this._env||this.setEnv("browser"),this.envContribution.mapToCanvasPoint?this.envContribution.mapToCanvasPoint(t,e):null}loadImage(t){return this._env||this.setEnv("browser"),this.envContribution.loadImage(t)}loadSvg(t){return this._env||this.setEnv("browser"),this.envContribution.loadSvg(t)}loadJson(t){return this._env||this.setEnv("browser"),this.envContribution.loadJson(t)}loadArrayBuffer(t){return this._env||this.setEnv("browser"),this.envContribution.loadArrayBuffer(t)}loadBlob(t){return this._env||this.setEnv("browser"),this.envContribution.loadBlob(t)}loadFont(t,e,i){return J(this,void 0,void 0,(function*(){return this._env||this.setEnv("browser"),this.envContribution.loadFont(t,e,i)}))}isChrome(){return null!=this._isChrome||(this._env||this.setEnv("browser"),this._isChrome="browser"===this._env&&navigator.userAgent.indexOf("Chrome")>-1),this._isChrome}isSafari(){return null!=this._isSafari||(this._env||this.setEnv("browser"),this._isSafari="browser"===this._env&&/Safari/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)),this._isSafari}getNativeAABBBounds(t){return this._env||this.setEnv("browser"),this.envContribution.getNativeAABBBounds(t)}removeDom(t){return this._env||this.setEnv("browser"),this.envContribution.removeDom(t)}createDom(t){return this._env||this.setEnv("browser"),this.envContribution.createDom(t)}updateDom(t,e){return this._env||this.setEnv("browser"),this.envContribution.updateDom(t,e)}getElementTop(t,e=!1){return this._env||this.setEnv("browser"),this.envContribution.getElementTop(t,e)}getElementLeft(t,e=!1){return this._env||this.setEnv("browser"),this.envContribution.getElementLeft(t,e)}getElementTopLeft(t,e=!1){return this._env||this.setEnv("browser"),this.envContribution.getElementTopLeft(t,e)}isMacOS(){return this._env||this.setEnv("browser"),this.envContribution.isMacOS()}copyToClipBoard(t){return this._env||this.setEnv("browser"),this.envContribution.copyToClipBoard(t)}};var tt,et,it,nt;Q=K([w(),Z(0,y(I)),Z(0,x(j)),q("design:paramtypes",[Object])],Q),function(t){t[t.estimate=0]="estimate",t[t.actualBounding=1]="actualBounding",t[t.fontBounding=2]="fontBounding"}(tt||(tt={})),function(t){t[t.INITIAL=0]="INITIAL",t[t.RUNNING=1]="RUNNING",t[t.PAUSE=2]="PAUSE"}(et||(et={})),function(t){t.wait="wait",t.from="from",t.to="to",t.customAnimate="customAnimate"}(it||(it={})),function(t){t[t.INITIAL=0]="INITIAL",t[t.RUNNING=1]="RUNNING",t[t.PAUSED=2]="PAUSED",t[t.END=3]="END"}(nt||(nt={}));var ot="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function rt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var st={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,i="~";function n(){}function o(t,e,i){this.fn=t,this.context=e,this.once=i||!1}function r(t,e,n,r,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new o(n,r||t,s),l=i?i+e:e;return t._events[l]?t._events[l].fn?t._events[l]=[t._events[l],a]:t._events[l].push(a):(t._events[l]=a,t._eventsCount++),t}function s(t,e){0==--t._eventsCount?t._events=new n:delete t._events[e]}function a(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(i=!1)),a.prototype.eventNames=function(){var t,n,o=[];if(0===this._eventsCount)return o;for(n in t=this._events)e.call(t,n)&&o.push(i?n.slice(1):n);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(t)):o},a.prototype.listeners=function(t){var e=i?i+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,r=n.length,s=new Array(r);o<r;o++)s[o]=n[o].fn;return s},a.prototype.listenerCount=function(t){var e=i?i+t:t,n=this._events[e];return n?n.fn?1:n.length:0},a.prototype.emit=function(t,e,n,o,r,s){var a=i?i+t:t;if(!this._events[a])return!1;var l,h,d=this._events[a],c=arguments.length;if(d.fn){switch(d.once&&this.removeListener(t,d.fn,void 0,!0),c){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,e),!0;case 3:return d.fn.call(d.context,e,n),!0;case 4:return d.fn.call(d.context,e,n,o),!0;case 5:return d.fn.call(d.context,e,n,o,r),!0;case 6:return d.fn.call(d.context,e,n,o,r,s),!0}for(h=1,l=new Array(c-1);h<c;h++)l[h-1]=arguments[h];d.fn.apply(d.context,l)}else{var u,g=d.length;for(h=0;h<g;h++)switch(d[h].once&&this.removeListener(t,d[h].fn,void 0,!0),c){case 1:d[h].fn.call(d[h].context);break;case 2:d[h].fn.call(d[h].context,e);break;case 3:d[h].fn.call(d[h].context,e,n);break;case 4:d[h].fn.call(d[h].context,e,n,o);break;default:if(!l)for(u=1,l=new Array(c-1);u<c;u++)l[u-1]=arguments[u];d[h].fn.apply(d[h].context,l)}}return!0},a.prototype.on=function(t,e,i){return r(this,t,e,i,!1)},a.prototype.once=function(t,e,i){return r(this,t,e,i,!0)},a.prototype.removeListener=function(t,e,n,o){var r=i?i+t:t;if(!this._events[r])return this;if(!e)return s(this,r),this;var a=this._events[r];if(a.fn)a.fn!==e||o&&!a.once||n&&a.context!==n||s(this,r);else{for(var l=0,h=[],d=a.length;l<d;l++)(a[l].fn!==e||o&&!a[l].once||n&&a[l].context!==n)&&h.push(a[l]);h.length?this._events[r]=1===h.length?h[0]:h:s(this,r)}return this},a.prototype.removeAllListeners=function(t){var e;return t?(e=i?i+t:t,this._events[e]&&s(this,e)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=i,a.EventEmitter=a,t.exports=a}(st);var at=rt(st.exports);var lt=(t,e)=>Object.prototype.toString.call(t)===`[object ${e}]`;var ht=(t,e=!1)=>e?"boolean"==typeof t:!0===t||!1===t||lt(t,"Boolean");var dt=t=>"function"==typeof t;var ct=t=>null==t;var ut=t=>null!=t;var gt=t=>{const e=typeof t;return null!==t&&"object"===e||"function"===e};var pt=t=>"object"==typeof t&&null!==t;var ft=function(t){if(!pt(t)||!lt(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 bt=t=>void 0===t;var mt=(t,e=!1)=>{const i=typeof t;return e?"string"===i:"string"===i||lt(t,"String")};var vt=t=>Array.isArray?Array.isArray(t):lt(t,"Array");var yt=function(t){return null!==t&&"function"!=typeof t&&Number.isFinite(t.length)};var Ct=t=>lt(t,"Date");var wt=(t,e=!1)=>{const i=typeof t;return e?"number"===i:"number"===i||lt(t,"Number")};var xt=t=>wt(t)&&Number.isFinite(t);var _t=t=>new RegExp(/^(http(s)?:\/\/)\w+[^\s]+(\.[^\s]+){1,}$/).test(t);var St=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 At=t=>({}.toString.call(t).replace(/^\[object /,"").replace(/]$/,""));const Bt=Object.prototype;var Tt=function(t){const e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Bt)};const Rt=Object.prototype.hasOwnProperty;function kt(t){if(ct(t))return!0;if(yt(t))return!t.length;const e=At(t);if("Map"===e||"Set"===e)return!t.size;if(Tt(t))return!Object.keys(t).length;for(const e in t)if(Rt.call(t,e))return!1;return!0}var Mt=(t,e,i)=>{const n=mt(e)?e.split("."):e;for(let e=0;e<n.length;e++)t=t?t[n[e]]:void 0;return void 0===t?i:t};const Lt=Object.prototype.hasOwnProperty;var Pt=(t,e)=>null!=t&&Lt.call(t,e);function Et(t,e,i){let n;if(!ut(t)||"object"!=typeof t||e&&e(t))return t;const o=vt(t),r=t.length;n=o?new Array(r):"object"==typeof t?{}:ht(t)||wt(t)||mt(t)?t:Ct(t)?new Date(+t):void 0;const s=o?void 0:Object.keys(Object(t));let a=-1;if(n)for(;++a<(s||t).length;){const o=s?s[a]:a,r=t[o];i&&i.includes(o.toString())?n[o]=r:n[o]=Et(r,e,i)}return n}function Ht(t,e,i=!1,n=!1){if(e){if(t===e)return;if(ut(e)&&"object"==typeof e){const o=Object(e),r=[];for(const t in o)r.push(t);let{length:s}=r,a=-1;for(;s--;){const s=r[++a];!ut(o[s])||"object"!=typeof o[s]||n&&vt(t[s])?Ft(t,s,o[s]):Ot(t,e,s,i,n)}}}}function Ot(t,e,i,n=!1,o=!1){const r=t[i],s=e[i];let a=e[i],l=!0;if(vt(s)){if(n)a=[];else if(vt(r))a=r;else if(yt(r)){a=new Array(r.length);let t=-1;const e=r.length;for(;++t<e;)a[t]=r[t]}}else ft(s)?(a=null!=r?r:{},"function"!=typeof r&&"object"==typeof r||(a={})):l=!1;l&&Ht(a,s,n,o),Ft(t,i,a)}function Ft(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 It(t,...e){let i=-1;const n=e.length;for(;++i<n;)Ht(t,e[i],!0);return t}function zt(t){return Object.prototype.toString.call(t)}function Dt(t){return Object.keys(t)}function Wt(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(zt(t)!==zt(e))return!1;if(dt(t))return!!(null==i?void 0:i.skipFunction);if("object"!=typeof t)return!1;if(vt(t)){if(t.length!==e.length)return!1;for(let n=t.length-1;n>=0;n--)if(!Wt(t[n],e[n],i))return!1;return!0}if(!ft(t))return!1;const n=Dt(t),o=Dt(e);if(n.length!==o.length)return!1;n.sort(),o.sort();for(let t=n.length-1;t>=0;t--)if(n[t]!=o[t])return!1;for(let o=n.length-1;o>=0;o--){const r=n[o];if(!Wt(t[r],e[r],i))return!1}return!0}function Nt(t,e,i){const n=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 o=0;o<n.length;o++){const r=n[o];(i?null!=e[r]:null==t[r])&&(t[r]=e[r])}return t}function Gt(t){return ut(t)?vt(t)?t:[t]:[]}function jt(t){if(yt(t))return t[t.length-1]}const Vt=(t,e)=>{var i;if(0===t.length)return;let n=t[0];for(let o=1;o<t.length;o++){const r=t[o];(null!==(i=null==e?void 0:e(r,n))&&void 0!==i?i:r-n)>0&&(n=r)}return n},Ut=(t,e)=>{var i;if(0===t.length)return;let n=t[0];for(let o=1;o<t.length;o++){const r=t[o];(null!==(i=null==e?void 0:e(r,n))&&void 0!==i?i:r-n)<0&&(n=r)}return n};function Xt(t,e){if(!vt(t)||!vt(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 $t(t){if(!vt(t))return[t];const e=[];for(const i of t)e.push(...$t(i));return e}function Yt(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function Kt(t){return Number(t)}const qt="undefined"!=typeof console;function Zt(t,e,i){const n=[e].concat([].slice.call(i));qt&&console[t].apply(console,n)}var Jt;!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"}(Jt||(Jt={}));let Qt=class t{static getInstance(e,i){return t._instance&&wt(e)?t._instance.level(e):t._instance||(t._instance=new t(e,i)),t._instance}static setInstance(e){return t._instance=e}static setInstanceLevel(e){t._instance?t._instance.level(e):t._instance=new t(e)}static clearInstance(){t._instance=null}constructor(t=Jt.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>=Jt.Info}canLogDebug(){return this._level>=Jt.Debug}canLogError(){return this._level>=Jt.Error}canLogWarn(){return this._level>=Jt.Warn}level(t){return arguments.length?(this._level=+t,this):this._level}error(...t){var e;return this._level>=Jt.Error&&(this._onErrorHandler.length?this.callErrorHandler(...t):Zt(null!==(e=this._method)&&void 0!==e?e:"error","ERROR",t)),this}warn(...t){return this._level>=Jt.Warn&&Zt(this._method||"warn","WARN",t),this}info(...t){return this._level>=Jt.Info&&Zt(this._method||"log","INFO",t),this}debug(...t){return this._level>=Jt.Debug&&Zt(this._method||"log","DEBUG",t),this}};Qt._instance=null;function te(t,e,i=1e-10,n=1e-10){const o=n,r=i*Math.max(t,e);return Math.abs(t-e)<=Math.max(o,r)}const ee=t=>{let e=null,i=null;return(...n)=>(e&&n.every(((t,i)=>t===e[i]))||(e=n,i=t(...n)),i)};var ie=function(t,e,i){return t<e?e:t>i?i:t};var ne=(t,e,i)=>{let[n,o]=t;o<n&&(n=t[1],o=t[0]);const r=o-n;return r>=i-e?[e,i]:(n=Math.min(Math.max(n,e),i-r),[n,n+r])};let oe=!1;try{oe="function"==typeof requestAnimationFrame&&"function"==typeof cancelAnimationFrame}catch(t){oe=!1}function re(t,e,i){let n,o,r,s,a,l,h=0,d=!1,c=!1,u=!0;const g=!e&&0!==e&&oe;if("function"!=typeof t)throw new TypeError("Expected a function");function p(e){const i=n,r=o;return n=o=void 0,h=e,s=t.apply(r,i),s}function f(t,e){return g?(cancelAnimationFrame(a),requestAnimationFrame(t)):setTimeout(t,e)}function b(t){const i=t-l;return void 0===l||i>=e||i<0||c&&t-h>=r}function m(){const t=Date.now();if(b(t))return v(t);a=f(m,function(t){const i=t-h,n=e-(t-l);return c?Math.min(n,r-i):n}(t))}function v(t){return a=void 0,u&&n?p(t):(n=o=void 0,s)}function y(...t){const i=Date.now(),r=b(i);if(n=t,o=this,l=i,r){if(void 0===a)return function(t){return h=t,a=f(m,e),d?p(t):s}(l);if(c)return a=f(m,e),p(l)}return void 0===a&&(a=f(m,e)),s}return e=+e||0,gt(i)&&(d=!!i.leading,c="maxWait"in i,c&&(r=Math.max(xt(i.maxWait)?i.maxWait:0,e)),u="trailing"in i?!!i.trailing:u),y.cancel=function(){void 0!==a&&function(t){if(g)return cancelAnimationFrame(t);clearTimeout(t)}(a),h=0,n=l=o=a=void 0},y.flush=function(){return void 0===a?s:v(Date.now())},y.pending=function(){return void 0!==a},y}function se(t,e,i){let n=!0,o=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return gt(i)&&(n="leading"in i?!!i.leading:n,o="trailing"in i?!!i.trailing:o),re(t,e,{leading:n,trailing:o,maxWait:e})}function ae(t,e){return i=>t*(1-i)+e*i}function le(t,e){return function(i){return Math.round(t*(1-i)+e*i)}}oe=!1;const he=1e-12,de=Math.PI,ce=de/2,ue=2*de,ge=2*Math.PI,pe=Math.abs,fe=Math.atan2,be=Math.cos,me=Math.max,ve=Math.min,ye=Math.sin,Ce=Math.sqrt,we=Math.pow;function xe(t){return t>=1?ce:t<=-1?-ce:Math.asin(t)}function _e(t,e,i,n,o){let r=i,s=n;return"number"==typeof t&&"number"==typeof i&&(r=(1-o)*t+o*i),"number"==typeof e&&"number"==typeof n&&(s=(1-o)*e+o*n),{x:r,y:s}}class Se{constructor(t=0,e=0,i,n){this.x=0,this.y=0,this.x=t,this.y=e,this.x1=i,this.y1=n}clone(){return new Se(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 wt(t)?(this.x+=t,void(this.y+=t)):(this.x+=t.x,this.y+=t.y,this)}sub(t){return wt(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 Ce(we(t.x-e.x,2)+we(t.y-e.y,2))}static distanceNN(t,e,i,n){return Ce(we(t-i,2)+we(e-n,2))}static distancePN(t,e,i){return Ce(we(e-t.x,2)+we(i-t.y,2))}static pointAtPP(t,e,i){return new Se((e.x-t.x)*i+t.x,(e.y-t.y)*i+t.y)}}function Be(t){return t*(Math.PI/180)}const Te=(t=0)=>{if(t<0)for(;t<-ue;)t+=ue;else if(t>0)for(;t>ue;)t-=ue;return t};function Re(t){for(;t<0;)t+=2*Math.PI;for(;t>=2*Math.PI;)t-=2*Math.PI;return t}function ke(t,e,i){if(null===t)return e;if(null===e)return t;const{x11:n,x12:o,y11:r,y12:s,x21:a,x22:l,y21:h,y22:d}=Le(t,e,i);return n>=l||o<=a||r>=d||s<=h?{x1:0,y1:0,x2:0,y2:0}:{x1:Math.max(n,a),y1:Math.max(r,h),x2:Math.min(o,l),y2:Math.min(s,d)}}var Me;!function(t){t[t.NONE=0]="NONE",t[t.BBOX1=1]="BBOX1",t[t.BBOX2=2]="BBOX2"}(Me||(Me={}));const Le=(t,e,i)=>{let n=t.x1,o=t.x2,r=t.y1,s=t.y2,a=e.x1,l=e.x2,h=e.y1,d=e.y2;return i&&(n>o&&([n,o]=[o,n]),r>s&&([r,s]=[s,r]),a>l&&([a,l]=[l,a]),h>d&&([h,d]=[d,h])),{x11:n,x12:o,y11:r,y12:s,x21:a,x22:l,y21:h,y22:d}};function Pe(t,e,i){if(!t||!e)return Me.NONE;const{x11:n,x12:o,y11:r,y12:s,x21:a,x22:l,y21:h,y22:d}=Le(t,e,i);return n>a&&o<l&&r>h&&s<d?Me.BBOX1:a>n&&l<o&&h>r&&d<s?Me.BBOX2:Me.NONE}function Ee(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:n,x12:o,y11:r,y12:s,x21:a,x22:l,y21:h,y22:d}=Le(t,e,!0);return!(n>l||o<a||r>d||s<h)}return!0}function He(t,e){return Math.abs(e[0]*t[0]+e[1]*t[1])}function Oe({x:t,y:e},i,n={x:0,y:0}){return{x:(t-n.x)*Math.cos(i)-(e-n.y)*Math.sin(i)+n.x,y:(t-n.x)*Math.sin(i)+(e-n.y)*Math.cos(i)+n.y}}function Fe(t){return{x:(t.x1+t.x2)/2,y:(t.y1+t.y2)/2}}function Ie(t,e){const i=e?Be(t.angle):t.angle,n=Fe(t);return[Oe({x:t.x1,y:t.y1},i,n),Oe({x:t.x2,y:t.y1},i,n),Oe({x:t.x2,y:t.y2},i,n),Oe({x:t.x1,y:t.y2},i,n)]}function ze(t,e,i=!1){const n=Ie(t,i),o=Ie(e,i),r=(t,e)=>[e.x-t.x,e.y-t.y],s=r(Fe(t),Fe(e)),a=r(n[0],n[1]),l=r(n[1],n[2]),h=r(o[0],o[1]),d=r(o[1],o[2]),c=i?Be(t.angle):t.angle;let u=i?Be(90-t.angle):t.angle+ce;const g=i?Be(e.angle):e.angle;let p=i?Be(90-e.angle):e.angle+ce;u>ge&&(u-=ge),p>ge&&(p-=ge);const f=(t,e,i,n)=>{const o=[Math.cos(e),Math.sin(e)];return t+(He(o,i)+He(o,n))/2>He(o,s)};return f((t.x2-t.x1)/2,c,h,d)&&f((t.y2-t.y1)/2,u,h,d)&&f((e.x2-e.x1)/2,g,a,l)&&f((e.y2-e.y1)/2,p,a,l)}function De(t,e,i,n,o,r){if(r>e&&r>n||r<e&&r<n)return 0;if(n===e)return 0;const s=(r-e)/(n-e);let a=n<e?1:-1;1!==s&&0!==s||(a=n<e?.5:-.5);const l=s*(i-t)+t;return l===o?1/0:l>o?a:0}const We=t=>{let e=t.charCodeAt(0),i=2===t.length?t.charCodeAt(1):0,n=e;return 55296<=e&&e<=56319&&56320<=i&&i<=57343&&(e&=1023,i&=1023,n=e<<10|i,n+=65536),12288===n||65281<=n&&n<=65376||65504<=n&&n<=65510?"F":8361===n||65377<=n&&n<=65470||65474<=n&&n<=65479||65482<=n&&n<=65487||65490<=n&&n<=65495||65498<=n&&n<=65500||65512<=n&&n<=65518?"H":4352<=n&&n<=4447||4515<=n&&n<=4519||4602<=n&&n<=4607||9001<=n&&n<=9002||11904<=n&&n<=11929||11931<=n&&n<=12019||12032<=n&&n<=12245||12272<=n&&n<=12283||12289<=n&&n<=12350||12353<=n&&n<=12438||12441<=n&&n<=12543||12549<=n&&n<=12589||12593<=n&&n<=12686||12688<=n&&n<=12730||12736<=n&&n<=12771||12784<=n&&n<=12830||12832<=n&&n<=12871||12880<=n&&n<=13054||13056<=n&&n<=19903||19968<=n&&n<=42124||42128<=n&&n<=42182||43360<=n&&n<=43388||44032<=n&&n<=55203||55216<=n&&n<=55238||55243<=n&&n<=55291||63744<=n&&n<=64255||65040<=n&&n<=65049||65072<=n&&n<=65106||65108<=n&&n<=65126||65128<=n&&n<=65131||110592<=n&&n<=110593||127488<=n&&n<=127490||127504<=n&&n<=127546||127552<=n&&n<=127560||127568<=n&&n<=127569||131072<=n&&n<=194367||177984<=n&&n<=196605||196608<=n&&n<=262141?"W":32<=n&&n<=126||162<=n&&n<=163||165<=n&&n<=166||172===n||175===n||10214<=n&&n<=10221||10629<=n&&n<=10630?"Na":161===n||164===n||167<=n&&n<=168||170===n||173<=n&&n<=174||176<=n&&n<=180||182<=n&&n<=186||188<=n&&n<=191||198===n||208===n||215<=n&&n<=216||222<=n&&n<=225||230===n||232<=n&&n<=234||236<=n&&n<=237||240===n||242<=n&&n<=243||247<=n&&n<=250||252===n||254===n||257===n||273===n||275===n||283===n||294<=n&&n<=295||299===n||305<=n&&n<=307||312===n||319<=n&&n<=322||324===n||328<=n&&n<=331||333===n||338<=n&&n<=339||358<=n&&n<=359||363===n||462===n||464===n||466===n||468===n||470===n||472===n||474===n||476===n||593===n||609===n||708===n||711===n||713<=n&&n<=715||717===n||720===n||728<=n&&n<=731||733===n||735===n||768<=n&&n<=879||913<=n&&n<=929||931<=n&&n<=937||945<=n&&n<=961||963<=n&&n<=969||1025===n||1040<=n&&n<=1103||1105===n||8208===n||8211<=n&&n<=8214||8216<=n&&n<=8217||8220<=n&&n<=8221||8224<=n&&n<=8226||8228<=n&&n<=8231||8240===n||8242<=n&&n<=8243||8245===n||8251===n||8254===n||8308===n||8319===n||8321<=n&&n<=8324||8364===n||8451===n||8453===n||8457===n||8467===n||8470===n||8481<=n&&n<=8482||8486===n||8491===n||8531<=n&&n<=8532||8539<=n&&n<=8542||8544<=n&&n<=8555||8560<=n&&n<=8569||8585===n||8592<=n&&n<=8601||8632<=n&&n<=8633||8658===n||8660===n||8679===n||8704===n||8706<=n&&n<=8707||8711<=n&&n<=8712||8715===n||8719===n||8721===n||8725===n||8730===n||8733<=n&&n<=8736||8739===n||8741===n||8743<=n&&n<=8748||8750===n||8756<=n&&n<=8759||8764<=n&&n<=8765||8776===n||8780===n||8786===n||8800<=n&&n<=8801||8804<=n&&n<=8807||8810<=n&&n<=8811||8814<=n&&n<=8815||8834<=n&&n<=8835||8838<=n&&n<=8839||8853===n||8857===n||8869===n||8895===n||8978===n||9312<=n&&n<=9449||9451<=n&&n<=9547||9552<=n&&n<=9587||9600<=n&&n<=9615||9618<=n&&n<=9621||9632<=n&&n<=9633||9635<=n&&n<=9641||9650<=n&&n<=9651||9654<=n&&n<=9655||9660<=n&&n<=9661||9664<=n&&n<=9665||9670<=n&&n<=9672||9675===n||9678<=n&&n<=9681||9698<=n&&n<=9701||9711===n||9733<=n&&n<=9734||9737===n||9742<=n&&n<=9743||9748<=n&&n<=9749||9756===n||9758===n||9792===n||9794===n||9824<=n&&n<=9825||9827<=n&&n<=9829||9831<=n&&n<=9834||9836<=n&&n<=9837||9839===n||9886<=n&&n<=9887||9918<=n&&n<=9919||9924<=n&&n<=9933||9935<=n&&n<=9953||9955===n||9960<=n&&n<=9983||10045===n||10071===n||10102<=n&&n<=10111||11093<=n&&n<=11097||12872<=n&&n<=12879||57344<=n&&n<=63743||65024<=n&&n<=65039||65533===n||127232<=n&&n<=127242||127248<=n&&n<=127277||127280<=n&&n<=127337||127344<=n&&n<=127386||917760<=n&&n<=917999||983040<=n&&n<=1048573||1048576<=n&&n<=1114109?"A":"N"};function Ne(t,e={},i){i||(i=1);const{fontStyle:n=e.fontStyle,fontVariant:o=e.fontVariant,fontWeight:r=e.fontWeight,fontSize:s=e.fontSize,fontFamily:a=e.fontFamily}=t;return(n?n+" ":"")+(o?o+" ":"")+(r?r+" ":"")+s*i+"px "+(a||"sans-serif")}let Ge=class t{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(),ut(t.specialCharSet)&&(this.specialCharSet=t.specialCharSet),this._standardMethod=ut(t.getTextBounds)?this.fullMeasure.bind(this):this.measureWithNaiveCanvas.bind(this)}initContext(){if(this._notSupportCanvas)return!1;if(ct(this._canvas)&&(ut(this._option.getCanvasForMeasure)&&(this._canvas=this._option.getCanvasForMeasure()),ct(this._canvas)&&"undefined"!=typeof window&&void 0!==window.document&&globalThis&&ut(globalThis.document)&&(this._canvas=globalThis.document.createElement("canvas"))),ct(this._context)&&ut(this._canvas)){const t=this._canvas.getContext("2d");ut(t)&&(t.save(),t.font=Ne(this.textSpec),this._contextSaved=!0,this._context=t)}return!ct(this._context)||(this._notSupportCanvas=!0,!1)}_initSpec(){var t,e,i;const{defaultFontParams:n={}}=this._option,{fontStyle:o=n.fontStyle,fontVariant:r=n.fontVariant,fontWeight:s=(null!==(t=n.fontWeight)&&void 0!==t?t:"normal"),fontSize:a=(null!==(e=n.fontSize)&&void 0!==e?e:12),fontFamily:l=(null!==(i=n.fontFamily)&&void 0!==i?i:"sans-serif"),align:h,textAlign:d=(null!=h?h:"center"),baseline:c,textBaseline:u=(null!=c?c:"middle"),ellipsis:g,limit:p}=this._userSpec;let{lineHeight:f=a}=this._userSpec;if(mt(f)&&"%"===f[f.length-1]){const t=Number.parseFloat(f.substring(0,f.length-1))/100;f=a*t}return{fontStyle:o,fontVariant:r,fontFamily:l,fontSize:a,fontWeight:s,textAlign:d,textBaseline:u,ellipsis:g,limit:p,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(ct(t))return{width:0,height:0};if(ct(this._option.getTextBounds)||!this._notSupportVRender)return this.measureWithNaiveCanvas(t);const{fontFamily:e,fontSize:i,fontWeight:n,textAlign:o,textBaseline:r,ellipsis:s,limit:a,lineHeight:l}=this.textSpec;let h;try{const d=this._option.getTextBounds({text:t,fontFamily:e,fontSize:i,fontWeight:n,textAlign:o,textBaseline:r,ellipsis:!!s,maxLineWidth:a||1/0,lineHeight:l});h={width:d.width(),height:d.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:n,lineHeight:o}=this.textSpec;return{width:i.width,height:null!==(e=o)&&void 0!==e?e:n,fontBoundingBoxAscent:i.fontBoundingBoxAscent,fontBoundingBoxDescent:i.fontBoundingBoxDescent}}quickMeasure(t){return this._measureReduce(t,this._quickMeasure.bind(this))}_quickMeasure(e){const i={width:0,height:0};for(let n=0;n<e.length;n++){const o=e[n];let r=this._measureSpecialChar(o);ct(r)&&t.NUMBERS_CHAR_SET.includes(o)&&(r=this._measureNumberChar()),ct(r)&&["F","W"].includes(We(o))&&(r=this._measureFullSizeChar()),ct(r)&&(r=this._measureLetterChar()),i.width+=r.width,i.height=Math.max(i.height,r.height),!ct(r.fontBoundingBoxAscent)&&(i.fontBoundingBoxAscent=r.fontBoundingBoxAscent),!ct(r.fontBoundingBoxDescent)&&(i.fontBoundingBoxDescent=r.fontBoundingBoxDescent)}return i}quickMeasureWithoutCanvas(t){return this._measureReduce(t,this._quickMeasureWithoutCanvas.bind(this))}_quickMeasureWithoutCanvas(t){var e;const i={width:0,height:0},{fontSize:n,lineHeight:o}=this.textSpec;for(let e=0;e<t.length;e++){const o=t[e],r=["F","W"].includes(We(o))?1:.53;i.width+=r*n}return i.height=null!==(e=o)&&void 0!==e?e:n,i}_measureReduce(t,e){var i;const{fontSize:n,lineHeight:o}=this.textSpec,r={width:0,height:0};if(ct(t))return r;if(vt(t)){const s=t.filter(ut).map((t=>t.toString()));return 0===s.length?r:1===s.length?e(s[0]):{width:s.reduce(((t,i)=>Math.max(t,e(i).width)),0),height:s.length*((null!==(i=o)&&void 0!==i?i:n)+1)+1}}return e(t.toString())}_measureNumberChar(){if(ct(this._numberCharSize)){const e=this._standardMethod(t.NUMBERS_CHAR_SET);this._numberCharSize={width:e.width/t.NUMBERS_CHAR_SET.length,height:e.height,fontBoundingBoxAscent:e.fontBoundingBoxAscent,fontBoundingBoxDescent:e.fontBoundingBoxDescent}}return this._numberCharSize}_measureFullSizeChar(){return ct(this._fullCharSize)&&(this._fullCharSize=this._standardMethod(t.FULL_SIZE_CHAR)),this._fullCharSize}_measureLetterChar(){if(ct(this._letterCharSize)){const e=this._standardMethod(t.ALPHABET_CHAR_SET);this._letterCharSize={width:e.width/t.ALPHABET_CHAR_SET.length,height:e.height,fontBoundingBoxAscent:e.fontBoundingBoxAscent,fontBoundingBoxDescent:e.fontBoundingBoxDescent}}return this._letterCharSize}_measureSpecialChar(t){return ut(this._specialCharSizeMap[t])?this._specialCharSizeMap[t]:this.specialCharSet.includes(t)?(this._specialCharSizeMap[t]=this._standardMethod(t),this._specialCharSizeMap[t]):null}release(){ut(this._canvas)&&(this._canvas=null),ut(this._context)&&(this._contextSaved&&(this._context.restore(),this._contextSaved=!1),this._context=null)}};Ge.ALPHABET_CHAR_SET="abcdefghijklmnopqrstuvwxyz",Ge.NUMBERS_CHAR_SET="0123456789",Ge.FULL_SIZE_CHAR="字";const je=(t,e)=>Math.max(e.x1-t.x2,t.x1-e.x2,e.y1-t.y2,t.y1-e.y2),Ve=(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 n(t,e,i){const n=t.getRotatedCorners().map((t=>t.x*e+t.y*i));return{min:Math.min(...n),max:Math.max(...n)}}let o=0;for(const r of i){const i=n(t,r.x,r.y),s=n(e,r.x,r.y);let a;a=i.max<s.min?s.min-i.max:s.max<i.min?i.min-s.max:0,o=Math.max(o,a)}return o};function Ue(t,e,i){const{x1:n,y1:o,x2:r,y2:s}=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*n+i.c*o+i.e,i.b*n+i.d*o+i.f),t.add(i.a*r+i.c*o+i.e,i.b*r+i.d*o+i.f),t.add(i.a*r+i.c*s+i.e,i.b*r+i.d*s+i.f),t.add(i.a*n+i.c*s+i.e,i.b*n+i.d*s+i.f),e)}let Xe=class t{constructor(t){t?this.setValue(t.x1,t.y1,t.x2,t.y2):this.clear()}clone(){return new t(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,n=0){return this.x1=t,this.y1=e,this.x2=i,this.y2=n,this}set(t=0,e=0,i=0,n=0){return i<t?(this.x2=t,this.x1=i):(this.x1=t,this.x2=i),n<e?(this.y2=e,this.y1=n):(this.y1=e,this.y2=n),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 vt(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 n=this.rotatedPoints(t,e,i);return this.clear().add(n[0],n[1]).add(n[2],n[3]).add(n[4],n[5]).add(n[6],n[7])}scale(t=0,e=0,i=0,n=0){const o=this.scalePoints(t,e,i,n);return this.clear().add(o[0],o[1]).add(o[2],o[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 Ue(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:n,y1:o,x2:r,y2:s}=this,a=Math.cos(t),l=Math.sin(t),h=e-e*a+i*l,d=i-e*l-i*a;return[a*n-l*o+h,l*n+a*o+d,a*n-l*s+h,l*n+a*s+d,a*r-l*o+h,l*r+a*o+d,a*r-l*s+h,l*r+a*s+d]}scalePoints(t,e,i,n){const{x1:o,y1:r,x2:s,y2:a}=this;return[t*o+(1-t)*i,e*r+(1-e)*n,t*s+(1-t)*i,e*a+(1-e)*n]}},$e=class extends Xe{};class Ye extends Xe{constructor(t,e=0){var i;super(t),t&&(this.angle=null!==(i=t.angle)&&void 0!==i?i:e)}intersects(t){return ze(this,t)}setValue(t=0,e=0,i=0,n=0,o=0){return super.setValue(t,e,i,n),this.angle=o,this}clone(){return new Ye(this)}getRotatedCorners(){const t={x:(this.x1+this.x2)/2,y:(this.y1+this.y2)/2};return[Oe({x:this.x1,y:this.y1},this.angle,t),Oe({x:this.x2,y:this.y1},this.angle,t),Oe({x:this.x1,y:this.y2},this.angle,t),Oe({x:this.x2,y:this.y2},this.angle,t)]}}class Ke{constructor(t=1,e=0,i=0,n=1,o=0,r=0){this.a=t,this.b=e,this.c=i,this.d=n,this.e=o,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,n,o,r){return!(this.e!==o||this.f!==r||this.a!==t||this.d!==n||this.b!==e||this.c!==i)}setValue(t,e,i,n,o,r){return this.a=t,this.b=e,this.c=i,this.d=n,this.e=o,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,n=this.d,o=this.e,r=this.f,s=new Ke,a=t*n-e*i;return s.a=n/a,s.b=-e/a,s.c=-i/a,s.d=t/a,s.e=(i*r-n*o)/a,s.f=-(t*r-e*o)/a,s}rotate(t){const e=Math.cos(t),i=Math.sin(t),n=this.a*e+this.c*i,o=this.b*e+this.d*i,r=this.a*-i+this.c*e,s=this.b*-i+this.d*e;return this.a=n,this.b=o,this.c=r,this.d=s,this}rotateByCenter(t,e,i){const n=Math.cos(t),o=Math.sin(t),r=(1-n)*e+o*i,s=(1-n)*i-o*e,a=n*this.a-o*this.b,l=o*this.a+n*this.b,h=n*this.c-o*this.d,d=o*this.c+n*this.d,c=n*this.e-o*this.f+r,u=o*this.e+n*this.f+s;return this.a=a,this.b=l,this.c=h,this.d=d,this.e=c,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,n,o,r){return this.multiply(t,e,i,n,o,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:n,e:o,f:r}=this;return this.a=e,this.b=t,this.c=n,this.d=i,this.e=r,this.f=o,this}multiply(t,e,i,n,o,r){const s=this.a,a=this.b,l=this.c,h=this.d,d=s*t+l*e,c=a*t+h*e,u=s*i+l*n,g=a*i+h*n,p=s*o+l*r+this.e,f=a*o+h*r+this.f;return this.a=d,this.b=c,this.c=u,this.d=g,this.e=p,this.f=f,this}interpolate(t,e){const i=new Ke;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:n,c:o,d:r,e:s,f:a}=this,l=i*r-n*o,h=r/l,d=-n/l,c=-o/l,u=i/l,g=(o*a-r*s)/l,p=-(i*a-n*s)/l,{x:f,y:b}=t;e.x=f*h+b*c+g,e.y=f*d+b*u+p}onlyTranslate(t=1){return this.a===t&&0===this.b&&0===this.c&&this.d===t}clone(){return new Ke(this.a,this.b,this.c,this.d,this.e,this.f)}toTransformAttrs(){const t=this.a,e=this.b,i=this.c,n=this.d,o=t*n-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 s=Math.sqrt(t*t+e*e);r.rotateDeg=e>0?Math.acos(t/s):-Math.acos(t/s),r.scaleX=s,r.scaleY=o/s,r.skewX=(t*i+e*n)/o,r.skewY=0}else if(0!==i||0!==n){const s=Math.sqrt(i*i+n*n);r.rotateDeg=Math.PI/2-(n>0?Math.acos(-i/s):-Math.acos(i/s)),r.scaleX=o/s,r.scaleY=s,r.skewX=0,r.skewY=(t*i+e*n)/o}return r.rotateDeg=180*r.rotateDeg/Math.PI,r}}class qe{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:n=this.L_TIME,R_COUNT:o=this.R_COUNT}=e;if(t.size<i)return 0;let r=0;const s=e=>{r++,t.delete(e)},a=Date.now();return t.forEach(((t,e)=>{if(t.timestamp.length<o)return s(e);let i=0;for(;a-t.timestamp[t.timestamp.length-1-i]<n&&(i++,!(i>=o)););if(i<o)return s(e);for(;a-t.timestamp[0]>n;)t.timestamp.shift()})),r}addLimitedTimestamp(t,e,i){const{R_TIMESTAMP_MAX_SIZE:n=this.R_TIMESTAMP_MAX_SIZE}=i;t.timestamp.length>n&&t.timestamp.shift(),t.timestamp.push(e)}clearTimeStamp(t,e){const{L_TIME:i=this.L_TIME}=e,n=Date.now();t.forEach((t=>{for(;n-t.timestamp[0]>i;)t.timestamp.shift()}))}clearItemTimestamp(t,e){const{L_TIME:i=this.L_TIME}=e,n=Date.now();for(;n-t.timestamp[0]>i;)t.timestamp.shift()}}function Ze(t,e,i){e/=100,i/=100;const n=(1-Math.abs(2*i-1))*e,o=n*(1-Math.abs(t/60%2-1)),r=i-n/2;let s=0,a=0,l=0;return 0<=t&&t<60?(s=n,a=o,l=0):60<=t&&t<120?(s=o,a=n,l=0):120<=t&&t<180?(s=0,a=n,l=o):180<=t&&t<240?(s=0,a=o,l=n):240<=t&&t<300?(s=o,a=0,l=n):300<=t&&t<360&&(s=n,a=0,l=o),s=Math.round(255*(s+r)),a=Math.round(255*(a+r)),l=Math.round(255*(l+r)),{r:s,g:a,b:l}}function Je(t,e,i){t/=255,e/=255,i/=255;const n=Math.min(t,e,i),o=Math.max(t,e,i),r=o-n;let s=0,a=0,l=0;return s=0===r?0:o===t?(e-i)/r%6:o===e?(i-t)/r+2:(t-e)/r+4,s=Math.round(60*s),s<0&&(s+=360),l=(o+n)/2,a=0===r?0:r/(1-Math.abs(2*l-1)),a=+(10