nhanh-pure-function 4.2.2 → 4.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Canvas/Axis/OverlayGroup/billboard.d.ts +1 -1
- package/dist/File/index.d.ts +9 -0
- package/dist/Utility/index.d.ts +83 -0
- package/dist/index.cjs.js +3 -3
- package/dist/index.es.js +607 -412
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document<"u"){var a=document.createElement("style");a.appendChild(document.createTextNode(".no-select{-webkit-user-select:none;-ms-user-select:none;user-select:none}._nhanh_canvas{cursor:initial}._nhanh_canvas:active{cursor:pointer}._nhanh_canvas._nhanh_canvas_draggable{cursor:grab}._nhanh_canvas._nhanh_canvas_draggable:active{cursor:grabbing}._nhanh_canvas_hover_overlay{cursor:pointer!important}._nhanh_canvas_hover_overlay:active{cursor:grabbing!important}._nhanh_canvas_hover_overlay_draggable{cursor:pointer!important}._nhanh_canvas_hover_overlay_draggable:active{cursor:move!important}._nhanh_canvas_hover_overlay_draggable_ew{cursor:pointer!important}._nhanh_canvas_hover_overlay_draggable_ew:active{cursor:e-resize!important;cursor:ew-resize!important}._nhanh_canvas_hover_overlay_draggable_ns{cursor:pointer!important}._nhanh_canvas_hover_overlay_draggable_ns:active{cursor:n-resize!important;cursor:ns-resize!important}")),document.head.appendChild(a)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
|
|
2
|
-
"use strict";var ni=Object.defineProperty;var Me=r=>{throw TypeError(r)};var ri=(r,s,t)=>s in r?ni(r,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[s]=t;var d=(r,s,t)=>ri(r,typeof s!="symbol"?s+"":s,t),De=(r,s,t)=>s.has(r)||Me("Cannot "+t);var x=(r,s,t)=>(De(r,s,"read from private field"),t?t.call(r):s.get(r)),A=(r,s,t)=>s.has(r)?Me("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(r):s.set(r,t),M=(r,s,t,e)=>(De(r,s,"write to private field"),e?e.call(r,t):s.set(r,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ae={".mp3":"audio/mpeg",".mp4":"video/mp4",".m4a":"audio/mp4",".aac":"audio/aac",".ogg":"audio/ogg",".wav":"audio/wav",".flac":"audio/flac",".opus":"audio/opus",".webm":"video/webm",".avi":"video/x-msvideo",".mov":"video/quicktime",".wmv":"video/x-ms-wmv",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".bmp":"image/bmp",".tiff":"image/tiff",".ico":"image/vnd.microsoft.icon",".svg":"image/svg+xml",".webp":"image/webp",".heif":"image/heif",".heic":"image/heic",".json":"application/json",".xml":"application/xml",".html":"text/html",".htm":"text/html",".css":"text/css",".js":"application/javascript",".ts":"application/typescript",".csv":"text/csv",".tsv":"text/tab-separated-values",".txt":"text/plain",".md":"text/markdown",".rtf":"application/rtf",".pdf":"application/pdf",".zip":"application/zip",".rar":"application/x-rar-compressed",".tar":"application/x-tar",".gz":"application/gzip",".7z":"application/x-7z-compressed",".exe":"application/x-msdownload",".apk":"application/vnd.android.package-archive",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".odt":"application/vnd.oasis.opendocument.text",".ods":"application/vnd.oasis.opendocument.spreadsheet",".odp":"application/vnd.oasis.opendocument.presentation",".jsonld":"application/ld+json",".yaml":"application/x-yaml",".yml":"application/x-yaml",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject",".map":"application/json"},Ut={image:[".jpg",".jpeg",".png",".gif",".bmp",".webp",".tiff",".svg",".heif",".heic",".ico",".raw",".jfif",".avif",".png8",".indd",".eps",".ai"],ppt:[".ppt",".pptx",".odp"],word:[".doc",".docx",".odt",".rtf"],excel:[".xls",".xlsx",".ods",".csv",".tsv"],pdf:[".pdf"],text:[".txt",".csv",".md",".json",".yaml",".yml",".log",".ini",".rtf"],audio:[".mp3",".wav",".ogg",".flac",".aac",".wma",".m4a",".alac",".ape",".opus",".amr",".ra",".mid",".midi",".aiff",".pcm",".au",".wavpack",".spx"],video:[".mp4",".avi",".mkv",".mov",".wmv",".flv",".webm",".mpg",".mpeg",".3gp",".vob",".ogv",".m4v",".ts",".rm",".rmvb",".m2ts",".divx",".xvid",".swf",".f4v"],archive:[".zip",".rar",".tar",".gz",".bz2",".xz",".7z",".tar.gz",".tar.bz2",".tar.xz",".tar.lz",".tar.lzma",".cab",".iso",".dmg",".tgz",".apk",".gz2",".tar.zst"],code:[".js",".ts",".py",".java",".cpp",".c",".html",".css",".scss",".less",".sass",".php",".rb",".go",".swift",".rs",".kt",".scala",".lua",".pl",".m",".h",".xml",".json",".yaml",".yml",".toml",".vue",".ejs",".handlebars",".jinja",".dart"],font:[".woff",".woff2",".ttf",".otf",".eot",".svg",".ttc",".fnt",".fon",".otc"],database:[".sql",".sqlite",".db",".mdb",".accdb",".jsonld",".xml",".csv"],markup:[".html",".htm",".xhtml",".xml",".json",".yaml",".yml"],configuration:[".ini",".conf",".cfg",".env",".properties",".json",".toml"],logs:[".log",".err",".trace",".out"],script:[".bash",".sh",".zsh",".bat",".ps1",".vbs",".cmd",".sed",".awk",".php"]},fe=["","万","亿","兆","京","垓","秭","穰","沟","涧","正","载","极"],oi=["_self","_blank","_parent","_top"],Pe={Letter:{width:215.9,height:279.4},Legal:{width:215.9,height:355.6},Tabloid:{width:279.4,height:431.8},Ledger:{width:431.8,height:279.4},Executive:{width:184.2,height:266.7},Folio:{width:215.9,height:330.2},Quarto:{width:215,height:275},"Government-Letter":{width:203.2,height:266.7},A0:{width:841,height:1189},A1:{width:594,height:841},A2:{width:420,height:594},A3:{width:297,height:420},A4:{width:210,height:297},A5:{width:148,height:210},A6:{width:105,height:148},A7:{width:74,height:105},A8:{width:52,height:74},A9:{width:37,height:52},A10:{width:26,height:37},B0:{width:1e3,height:1414},B1:{width:707,height:1e3},B2:{width:500,height:707},B3:{width:353,height:500},B4:{width:250,height:353},B5:{width:176,height:250},B6:{width:125,height:176},B7:{width:88,height:125},B8:{width:62,height:88},B9:{width:44,height:62},B10:{width:31,height:44},C0:{width:917,height:1297},C1:{width:648,height:917},C2:{width:458,height:648},C3:{width:324,height:458},C4:{width:229,height:324},C5:{width:162,height:229},C6:{width:114,height:162},C7:{width:81,height:114},C8:{width:57,height:81}},ai=Object.keys(Pe).map(r=>({value:r,label:r}));function Vt(r,s=500){let t,e=!0;function i(n){if(!e)return;t||(t=n);let o=Math.min((n-t)/s,1);r(o),n-t<s&&requestAnimationFrame(i)}return requestAnimationFrame(i),()=>e=!1}function li(r,s,t,e,i=2){let n=r,o=!1,a=1,l=r,c=s,h=t;const u=()=>{const P=(c-l)/h;return Number(P.toFixed(i))};let f=u();const m=P=>Math.min(Math.max(P,l),c),p=P=>Number(P.toFixed(i)),g=(P,b,E)=>{const T=[];return P>=b&&T.push("最小值必须小于最大值"),E<=0?T.push("分段数必须为正数"):u()==0&&T.push("数值精度过低,致使动画步长为 0"),T},y=(P,b,E)=>{const T=g(P,b,E);return T.length>0?(console.error(`参数更新失败: ${T.join("; ")}`),!1):(l=P,c=b,h=E,f=u(),n=m(n),!0)},w=()=>{o&&(a=n>=c?-1:n<=l?1:a,n=m(n+f*a),e(p(n)),requestAnimationFrame(w))};return{play(P=n){if(n=m(P),g(l,c,h).length)return console.error("配置参数错误",this.getParams());o||(o=!0,w())},pause(){o=!1},getCurrent:()=>p(n),isPlaying:()=>o,updateParams:y,getParams:()=>({min:l,max:c,steps:h,precision:i,stepSize:f})}}function Ie(r,s,t,e,i=4){if(t<=0)return console.error("动画步数 必须为正数");const n=u=>Number(u.toFixed(i)),o=s-r,a=n(Math.abs(o)/t);if(a===0)return console.error("数值精度过低,致使动画步长为 0");const l=Math.sign(o);let c=r;const h=()=>{c=n(c+a*l),(l>0?c<s:c>s)?(e(c),requestAnimationFrame(h)):e(s)};h()}function ci(r,s,t,e){const i=l=>3*(1-l)**2*l*r+3*(1-l)*l**2*t+l**3,n=l=>3*(1-l)**2*l*s+3*(1-l)*l**2*e+l**3,o=l=>3*r*(1-l)*(1-3*l)+3*t*(2*l-3*l**2)+3*l**2,a=l=>{if(l<=0)return 0;if(l>=1)return 1;let c=l;for(let f=0;f<8;f++){const m=i(c)-l;if(Math.abs(m)<1e-6)return c;const p=o(c);if(Math.abs(p)<1e-6)break;const g=c-m/p;if(g<0||g>1)break;c=g}let h=0,u=1;c=l;for(let f=0;f<24;f++){const m=i(c)-l;if(Math.abs(m)<1e-6)return c;m>0?u=c:h=c,c=(h+u)/2}return c};return l=>{const c=Math.min(1,Math.max(0,l));return n(a(c))}}function hi(r,s="image/png"){try{let t,e=s;if(r instanceof File)return URL.createObjectURL(r);if(typeof r=="string"){let n=r;const o=n.match(/^data:([^;]*)(;base64)?,(.*)$/i);if(o){if(!o[2])return console.error("无效的数据 URL:缺少 base64 编码声明");if(e=o[1]||e,n=o[3],!n)return console.error("数据 URL 包含空有效负载")}n=n.replace(/[^A-Za-z0-9+/=]/g,"");const a=atob(n);t=new Uint8Array(a.length);for(let l=0;l<a.length;l++)t[l]=a.charCodeAt(l)}else if(r instanceof ArrayBuffer)t=new Uint8Array(r);else if(r instanceof Uint8Array)t=r;else return console.error("不支持的数据类型。应为 Base64 字符串、ArrayBuffer 或 Uint8Array");const i=new Blob([t],{type:e});return URL.createObjectURL(i)}catch(t){return console.error("数据到 ImageURL 的转换失败:",t.message,t.stack||"没有可用的堆栈跟踪"),null}}function ui(r){return r.charAt(0).toUpperCase()+r.slice(1)}function di(r,s,t=2){return!Number.isFinite(r)||!Number.isFinite(s)||!Number.isFinite(t)?(console.error("所有参数必须是有限的数字"),""):s===0?(console.error("分母不能为零"),""):t<0?(console.error("小数位数不能为负数"),""):(r/s*100).toFixed(t)+"%"}function Qt(r){const t=r.toString().split("."),e=t[0].replace(/\B(?=(\d{3})+(?!\d))/g,",");return t.length>1?e+"."+t[1]:e}function fi(r,s){const t={join:!0,suffix:"",decimalPlaces:2},{join:e,suffix:i,decimalPlaces:n}={...t,...s||{}},o=Number(r);if(isNaN(o))return e?`0${i}`:[0,i];const a=Math.abs(o),l=o>=0,c=Math.max(0,Math.floor(Math.log10(a)/4)),h=Math.pow(1e4,c),u=a/h,f=(l?1:-1)*parseFloat(u.toFixed(Math.max(0,n)));return e?`${f}${fe[c]}${i}`:[f,fe[c]+i]}function mi(r){const s=["B","KB","MB","GB","TB","PB"];let t=0;for(;r>1024;)r/=1024,t++;return`${Math.round(r*100)/100} ${s[t]}`}function Le(r,s="YYYY-MM-DD hh:mm:ss",t=!0){const e=new Date(r);if(isNaN(e.getTime()))return console.error("Invalid date"),"";const i={YYYY:n=>n.getFullYear(),MM:n=>n.getMonth()+1,DD:n=>n.getDate(),hh:n=>n.getHours(),mm:n=>n.getMinutes(),ss:n=>n.getSeconds(),ms:n=>n.getMilliseconds()};return s.replace(/YYYY|MM|DD|hh|mm|ss|ms/g,n=>{const o=i[n](e);return t?String(o).padStart(2,"0"):String(o)})}function Jt(r,s="file"){if(!r||(r=String(r).trim(),r===""))return s;const t=r.split("/");return t[t.length-1].split("?")[0]}function gi(r,s){return r=r.replace(/([^a-zA-Z][a-z])/g,t=>t.toUpperCase()),s?r.replace(/[^a-zA-Z]+/g,""):r}function pi(r,s,t=","){const e=new RegExp(`(^|${t})${s}(${t}|$)`,"g");return r.replace(e,function(i,n,o){return n===o?t:""})}function vi(r,s=!0){const t={"\b":"\\b"," ":"\\t","\n":"\\n","\v":"\\v","\f":"\\f","\r":"\\r"," ":"\\s"},e=Object.fromEntries(Object.entries(t).map(([i,n])=>[n,i]));return s?r.replace(/[\b\t\n\v\f\r ]/g,i=>t[i]):r.replace(/\\[btnvfrs]/g,i=>e[i]||i)}const Bt=[["年",365*24*60*60*1e3],["月",30*24*60*60*1e3],["周",7*24*60*60*1e3],["天",24*60*60*1e3],["时",60*60*1e3],["分",60*1e3],["秒",1e3],["毫秒",1]];function yi(r,s){if(!Number.isFinite(r)||r<0)return"0毫秒";r=Math.round(r);const t=s?Bt.findIndex(([i])=>i===s):0,e=t===-1?0:t;for(let i=e;i<Bt.length;i++){const[n,o]=Bt[i];if(r>=o){const a=o===1?r:Math.round(r/o*10)/10;let l=Number.isInteger(a)?a:a.toFixed(1).replace(/\.0$/,"");return n===Bt[e][0]&&(l=Qt(Number(l))),`${l}${n}`}}return"0毫秒"}function wi(r,s){if(s<1)return console.error("分割大小必须大于0"),[];const t=[];for(let e=0;e<r.length;e+=s){const i=r.slice(e,e+s);t.push(i)}return t}function oe(r,s=2){if(Array.isArray(r)&&r.length>=s){for(let e=0;e<r.length;e++)if(typeof r[e]!="number"||!Number.isFinite(r[e]))return!1}else return!1;return!0}function Ot(r,s=1,t=2){if(Array.isArray(r)&&r.length>=s){for(let i=0;i<r.length;i++)if(!oe(r[i],t))return!1}else return!1;return!0}function xi(r,s,t){return Math.abs(r-s)<=t}function Pi(r,s){let t=!1;const{x:e,y:i}=r,n=s.length;for(let o=0,a=n-1;o<n;a=o++){const l=s[o].x,c=s[o].y,h=s[a].x,u=s[a].y;c>i!=u>i&&e<(h-l)*(i-c)/(u-c)+l&&(t=!t)}return t}function bi(r,s,t,e){const i=Math.min(r[0],s[0]),n=Math.max(r[0],s[0]),o=Math.min(r[1],s[1]),a=Math.max(r[1],s[1]),l=[[i,o],[n,o],[n,a],[i,a]],c=e[1]-t[1],h=t[0]-e[0],u=e[0]*t[1]-t[0]*e[1];if(c===0&&h===0){const[g,y]=t;return g>=i&&g<=n&&y>=o&&y<=a}const f=1e-10;let m=!1,p=!1;for(const[g,y]of l){const w=c*g+h*y+u;if(Math.abs(w)<f||(w>f?m=!0:p=!0,m&&p))return!0}return m&&p}function Kt(r){return Object.prototype.toString.call(r).slice(8,-1).toLowerCase()}function Ci(r){return["https:","wss:","ftps:","sftp:","smpts:","smtp+tls:","imap+tls:","pop3+tls:","rdp:","vpn:"].some(t=>r.startsWith(t))}function _i(r){return new Promise((s,t)=>{if(typeof r!="string"||r.trim()===""||!r.includes("://")){t(new Error("Invalid URL: Must be a non-empty string"));return}try{new XMLHttpRequest().open("HEAD",r,!0)}catch(n){t(new Error(`Invalid URL format: ${n.message}`));return}const e=new XMLHttpRequest;e.open("HEAD",r,!0);const i=n=>{t(new Error(`Request failed: ${n.type}`))};e.onreadystatechange=function(){e.readyState===XMLHttpRequest.DONE&&(e.status===0?t(new Error("Network error or CORS blocked")):e.status>=200&&e.status<300?s(!0):t(new Error(`HTTP Error: ${e.status}`)))},e.onerror=i,e.onabort=i,e.ontimeout=i;try{e.send()}catch(n){t(new Error(`Request send failed: ${n.message}`))}})}const it=class it{constructor(){if(new.target===it)throw new Error("请直接使用静态方法,而不是实例化此类")}static check(s,t){if(!s||typeof s!="string")return console.error("Invalid URL provided"),t?!1:"unknown";const e=Jt(s).toLowerCase();if(t){if(!Ut.hasOwnProperty(t))return console.error(`Unknown file type: ${t}`),"unknown";const i=Ut[t];return it._checkExtension(e,i)}return it._detectFileType(e)}static parseAddresses(s){return!s||typeof s!="string"?(console.error("Invalid URL provided"),[]):s.split(",").map(t=>{const e=Jt(t),i=this.check(t);return{url:t,name:e,type:i}})}static matchesMimeType(s,t){if(!t)return!0;if(typeof s!="string"||typeof t!="string")return!1;const e=it._normalizeType(s),i=t.split(",").map(a=>it._normalizeType(a.trim())),[n,o="*"]=e.split("/");return i.some(a=>{const[l,c="*"]=a.split("/");return(l==="*"||n==="*"||l===n)&&(c==="*"||o==="*"||c===o)})}static _normalizeType(s){return s.startsWith(".")&&!s.includes("/")?Ae[s.toLowerCase()]||s:s.includes("/")?s:`${s}/*`}static _checkExtension(s,t){return t.some(e=>s.endsWith(e))}static _detectFileType(s){for(const[t,e]of it.cachedEntries)if(e.some(i=>s.endsWith(i)))return t;return"unknown"}};d(it,"cachedEntries",Object.entries(Ut));let me=it;const Si=/\w*(?:\[\d+\])+|\w+/g,Ne=/^\w*(?:\[\d+\])+$/,He=/\w+|(\[\d+\])/g,Fe=/\[(\d+)\]/;function Be(r){return r?r.match(Si)||[]:[]}function Ei(r,s=3e3){if(typeof r!="function")return console.error("非函数:",r);const t=window.requestIdleCallback,e=function(i){i.timeRemaining()<=0&&!i.didTimeout?t(e,{timeout:s}):r(i)};t?t(e,{timeout:s}):requestAnimationFrame(()=>r())}function ze(r,s){const t=Date.now();return new Promise((e,i)=>{const n=()=>{const o=Date.now()-t;if(o>=s)return i(o);if(r())return e(o);requestAnimationFrame(n)};n()})}function rt(r,s,t=[],e=Date.now()){if(e<Date.now()-50){console.error("_MergeObjects 合并异常:疑似死循环");return}const i=Kt(r),n=Kt(s);if(i!=n)return s;if(i=="object"||i=="array"){if(t.some(([o,a])=>o==r&&a==s))return r;if(t.push([r,s]),i=="object"){for(const o in s)if(Object.prototype.hasOwnProperty.call(s,o)){const a=s[o],l=r[o],c=rt(l,a,t,e);r[o]=c}return r}else if(i=="array")return s.forEach((o,a)=>{const l=o,c=r[a],h=rt(c,l,t,e);r[a]=h}),r}else return s}function te(r=""){return r+"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(s){const t=Math.random()*16|0;return(s==="x"?t:t&3|8).toString(16)})}function be(r,s){let t;return function(...e){clearTimeout(t),t=setTimeout(()=>{r(...e),t=void 0},s)}}function Mi(r,s){let t=-1/0;return function(...e){const i=performance.now();if(i-t>s){t=i;try{r(...e)}catch(n){console.error("Throttled function execution failed:",n)}}}}function Di(r,s){if(!r||!s)return r;const t=Be(s);return t.length?t.reduce((e,i,n)=>{const o=n===t.length-1;if(Ne.test(i)){const a=i.match(He)||[];return a.reduce((l,c,h)=>{if(/^\w+$/.test(c))return l[c]||(h<a.length-1?[]:{});const u=c.match(Fe),f=u?parseInt(u[1],10):0,m=h===a.length-1;return m&&o?l[f]:l[f]||(m?{}:[])},e)}return o?e[i]:e[i]||{}},r):r}function Ri(r,s,t,e){if(!r||!s)return t;const i=Be(s);return i.length?i.reduce((n,o,a)=>{const l=a===i.length-1;if(Ne.test(o)){const c=o.match(He)||[];return c.reduce((h,u,f)=>{const m=f===c.length-1;if(/^\w+$/.test(u))return h.hasOwnProperty(u)||(h[u]=[]),h[u];const p=u.match(Fe),g=p?parseInt(p[1],10):0,y=m&&l;return h.hasOwnProperty(g)?y&&!e&&(h[g]=t):h[g]=y?t:m?{}:[],h[g]},n)}return l?((!e||!n.hasOwnProperty(o))&&(n[o]=t),n[o]):(n.hasOwnProperty(o)||(n[o]={}),n[o])},r):t}function ki(r){return r.map((s,t)=>r.slice(t).concat(r.slice(0,t)))}function Ue(r){const s=window.structuredClone,t=(e,i=new WeakMap)=>{const n=e;if(n===null||typeof n!="object")return n;if(i.has(n))return i.get(n);switch(Kt(n)){case"array":{const a=[];i.set(n,a);for(const l of n)a.push(t(l,i));return a}case"object":{if(n===null)return n;const a={};i.set(n,a);for(const l in n)Object.prototype.hasOwnProperty.call(n,l)&&(a[l]=t(n[l],i));return a}case"date":{const a=new Date(n.getTime());return i.set(n,a),a}case"regexp":{const a=n,l=new RegExp(a.source,a.flags);return l.lastIndex=a.lastIndex,i.set(n,l),l}case"map":{const a=new Map;return i.set(n,a),n.forEach((l,c)=>{a.set(t(c,i),t(l,i))}),a}case"set":{const a=new Set;return i.set(n,a),n.forEach(l=>{a.add(t(l,i))}),a}case"arraybuffer":case"dataview":case"int8array":case"uint8array":case"uint8clampedarray":case"int16array":case"uint16array":case"int32array":case"uint32array":case"float32array":case"float64array":case"bigint64array":case"biguint64array":{const a=n,l=a.constructor,c=a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength),h=new l(c,a.byteOffset,a.byteLength/a.BYTES_PER_ELEMENT);return i.set(n,h),h}case"error":{const a=n,l=new a.constructor(a.message);return l.stack=a.stack,l.name=a.name,i.set(n,l),l}case"function":case"promise":case"weakmap":case"weakset":case"file":default:return n}};try{return s?s(r):t(r)}catch(e){return console.warn("structuredClone error:",e),s&&t(r)}}function Ge(r,s){const t=[[11,"#d03050"],[8,"#f0a020"],[5,"#2080f0"],[2,"#18a058"]],{level:e=t,maxHistory:i=30,prefix:n=""}=s||{};if(e.sort((h,u)=>u[0]-h[0]),typeof r!="function")return console.error("第一个参数必须是一个函数。");if(!Array.isArray(e))return console.error("第二个参数必须是一个数组。");let o=[],a=0;const l=(h,u)=>{for(const[f,m]of u)if(h>=f)return m;return"black"};return(...h)=>{const u=performance.now(),f=r(...h),m=performance.now()-u;o.push(m),o.length>i&&o.shift(),a=o.reduce((y,w)=>y+w,0)/o.length||0;const p=l(m,e),g=l(a,e);return console.log(`%c${n?n+" - ":""}单次耗时:${m.toFixed(2)}ms
|
|
3
|
-
%c平均耗时(${o.length}次):${a.toFixed(2)}ms`,`color: ${p}; padding: 2px 0;`,`color: ${g}; padding: 2px 0;`),f}}function Vi(r){const s=Date.now();let t=performance.now();for(;Date.now()-s<r;){t=Math.sin(t)*1e6,(t>1e6||t<-1e6)&&(t=0);try{const e=t.toString().substring(0,8);history.replaceState(null,"",`#${e}`)}catch{}}return Date.now()-s}var wt=(r=>(r.RESPONSE="response",r.QUERY="query",r))(wt||{});class Oi{constructor(s,t){d(this,"soundSources");d(this,"preloadTasks",new Map);this.soundSources={...s};const e=t==null?void 0:t.holdKeys;if(e!=null&&e.length)for(const i of e)this.fetchAndReplaceSource(i)}preload(s){const t=Array.isArray(s)?s:[s];return Promise.all(t.map(e=>this.fetchAndReplaceSource(e))).then(()=>{})}fetchAndReplaceSource(s){const t=this.preloadTasks.get(s);if(t)return t;const e=this.soundSources[s];if(!e)return Promise.reject(new Error(`未找到对应音效资源: ${String(s)}`));if(e.startsWith("blob:")){const n=Promise.resolve();return this.preloadTasks.set(s,n),n}const i=fetch(e).then(n=>{if(!n.ok)throw new Error(`音效下载失败: ${n.status} ${e}`);return n.blob()}).then(n=>{const o=this.soundSources[s],a=URL.createObjectURL(n);this.soundSources[s]=a,o.startsWith("blob:")&&o!==a&&URL.revokeObjectURL(o)}).catch(n=>{throw this.preloadTasks.delete(s),n instanceof Error?n:new Error(String(n))});return this.preloadTasks.set(s,i),i}play(s,t){const e=this.soundSources[s];return e?this.playUrl(e,t):(console.warn(`未找到对应音效资源: ${String(s)}`),()=>{})}playUrl(s,t){if(!s){console.error("音效资源地址为空");return}const e=new Audio(s),i=(t==null?void 0:t.loopCount)!==void 0&&t.loopCount>0?t.loopCount:void 0,n=(t==null?void 0:t.loop)&&i===void 0;let o=0,a=!1;const l=()=>{a||(a=!0,e.pause(),e.currentTime=0,e.removeEventListener("ended",c),e.onerror=null)},c=()=>{if(!a){if(n){e.currentTime=0,e.play().catch(h=>{console.warn("循环音效再次播放失败:",h),l()});return}if(i!==void 0&&o+1<i){o+=1,e.currentTime=0,e.play().catch(h=>{console.warn("循环音效再次播放失败:",h),l()});return}l()}};return e.addEventListener("ended",c),e.onerror=()=>{a||(console.error(`音效资源加载失败: ${s}`),l())},e.play().catch(h=>{a||(console.warn("音效播放失败(可能是自动播放策略限制):",h),l())}),l}}function Re(r,s){for(const t of Object.keys(s))s[t]!==void 0&&(r[t]=s[t])}class Ti{constructor(s){d(this,"url");d(this,"socket");d(this,"onopen");d(this,"onmessage");d(this,"onerror");d(this,"onclose");d(this,"pingConfig",{enabled:!1,interval:1e3*30,content:"ping"});d(this,"pingTimer");d(this,"retryConfig",{maxCount:3,currentCount:0,interval:1e3});d(this,"send",s=>{var t;return this.ready?((t=this.socket)==null||t.send(s),!0):!1});if(!s)return;const{url:t,ping:e,maxRetryCount:i,retryInterval:n}=s;e!==void 0&&(typeof e=="boolean"?this.pingConfig.enabled=e:Re(this.pingConfig,e)),Re(this.retryConfig,{maxCount:i,interval:n}),t&&this.start(t)}get ready(){var s;return((s=this.socket)==null?void 0:s.readyState)===WebSocket.OPEN}startPing(){const{interval:s,content:t,enabled:e}=this.pingConfig;e&&(this.pingTimer=setInterval(()=>{var i;this.ready?(i=this.socket)==null||i.send(t):console.warn("WebSocket未就绪,无法发送ping")},s))}startRetry(){const{maxCount:s,interval:t,currentCount:e}=this.retryConfig;if(s<=e){console.error("WebSocket重试次数已用完"),this.retryConfig.currentCount=0;return}this.retryConfig.currentCount++,setTimeout(()=>this.start(this.url),t)}start(s){this.stop();const t=new WebSocket(s);this.socket=t,this.url=s,t.onopen=e=>{var i;console.log("WebSocket已连接"),this.startPing(),this.retryConfig.currentCount=0,(i=this.onopen)==null||i.call(this,e)},t.onmessage=e=>{var i;(i=this.onmessage)==null||i.call(this,e)},t.onerror=e=>{var i;console.error("WebSocket错误:",e),clearInterval(this.pingTimer),this.startRetry(),(i=this.onerror)==null||i.call(this,e)},t.onclose=e=>{var i;console.log("WebSocket已关闭"),clearInterval(this.pingTimer),(i=this.onclose)==null||i.call(this,e)}}stop(){var s;(s=this.socket)==null||s.close(),this.socket=void 0}}function Ai(r,s=10){let t=0,e=s;function i(){if(e>0)e--,requestAnimationFrame(i);else{const o=(Date.now()-t)/s,a=1e3/o;r(Number(a.toFixed(2)),Number(o.toFixed(2)))}}requestAnimationFrame(()=>{t=Date.now(),i()})}function Ii(r){const s=()=>Promise.resolve(),t=a=>(console.error(a),Promise.reject(a));function e(){return navigator.clipboard.writeText(r).then(s).catch(t)}function i(){const a=document.createElement("div");a.innerText=r,document.body.appendChild(a);const l=document.createRange();l.selectNodeContents(a);const c=window.getSelection();let h=!1;return c&&(c.removeAllRanges(),c.addRange(l),h=document.execCommand("copy")),document.body.removeChild(a),h?Promise.resolve():Promise.reject()}function n(){const a=document.createElement("textarea");a.value=r,document.body.appendChild(a),a.select(),a.setSelectionRange(0,r.length);let l=!1;return document.activeElement===a&&(l=document.execCommand("Copy",!0)),document.body.removeChild(a),l?Promise.resolve():Promise.reject()}function o(){return i().then(s).catch(()=>{n().then(s).catch(()=>t("复制方式尽皆失效"))})}return navigator.clipboard?e().catch(o):o()}function Li(r,s){const t=Pe[r];if(!t)return console.error(`未知纸张类型: ${r}`);const{width:e,height:i}=t,n=p=>p/25.4,a=typeof window<"u"?window.devicePixelRatio*96:300,l=p=>Math.round(n(p)*a),c=l(e),h=l(i),u=l(s),f=Math.max(0,c-2*u),m=Math.max(0,h-2*u);return{contentWidth:f,contentHeight:m,paddingPx:u,paperWidthPx:c,paperHeightPx:h}}class Rt{constructor(){}static init(s){if(!s)return console.error("标签页名称不能为空");this.initFinish||(this.setupEventListeners(),this.initFinish=!0),window.name=s}static setupEventListeners(){this.channel.addEventListener("message",s=>{this.handleChannelMessage(s)})}static handleChannelMessage(s){const{type:t,responseKey:e,name:i}=s.data;if(t===wt.RESPONSE){const n=this.pendingQueries.get(e);n==null||n.forEach(o=>o(i))}else if(t===wt.QUERY){if(this.pendingQueries.has(e)||i!="*"&&i!=window.name)return;const n={type:wt.RESPONSE,responseKey:e,name:window.name};this.channel.postMessage(n)}}static getWindow(s){if(!this.initFinish){const o="请先初始化标签页管理器";return console.error(o),Promise.reject(o)}const t=te();let e=!1;const i=this.pendingQueries.get(t)||[];i.push(()=>e=!0),this.pendingQueries.set(t,i);const n={type:wt.QUERY,responseKey:t,name:s};return this.channel.postMessage(n),ze(()=>e,this.timeout).finally(()=>this.pendingQueries.delete(t))}static openWindow(s,t,e="_blank",i){var n;if(!this.initFinish){const o="请先初始化标签页管理器";return console.error(o),Promise.reject(o)}return(n=this.getWindow(s))==null?void 0:n.then(()=>window.open("javascript:;",s)).catch(()=>{const o=window.open(t,e,i);return o||console.error("无法打开标签页"),o})}static getAllWindows(){if(!this.initFinish){const n="请先初始化标签页管理器";return console.error(n),Promise.reject(n)}const s=te(),t=[],e=this.pendingQueries.get(s)||[];e.push(n=>t.push(n)),this.pendingQueries.set(s,e);const i={type:wt.QUERY,responseKey:s,name:"*"};return this.channel.postMessage(i),new Promise(n=>{setTimeout(()=>{this.pendingQueries.delete(s),n(t)},this.timeout)})}}d(Rt,"initFinish",!1),d(Rt,"channel",new BroadcastChannel("nhanh-pure-function")),d(Rt,"timeout",150),d(Rt,"pendingQueries",new Map);class Ni{constructor(){d(this,"status","active");d(this,"activeCallbacks",new Map);d(this,"idleCallbacks",new Map);d(this,"idleTime",5);d(this,"timeoutTimer");d(this,"activate",()=>{this.status==="idle"&&(this.status="active",console.log("%c已进入活跃状态","background: #4CAF50; color: white; padding: 2px 4px; border-radius: 4px; font-weight: bold;"),this.activeCallbacks.forEach(s=>s())),this.resetTimeoutTimer()});d(this,"markAsIdle",()=>{this.timeoutTimer&&clearTimeout(this.timeoutTimer),this.status==="active"&&(this.status="idle",console.log("%c已进入闲置状态","background: #9E9E9E; color: white; padding: 2px 4px; border-radius: 4px; font-weight: bold;"),this.idleCallbacks.forEach(s=>s()))});window.addEventListener("keypress",this.activate),window.addEventListener("mousemove",this.activate),window.addEventListener("mousedown",this.activate),window.addEventListener("wheel",this.activate),this.resetTimeoutTimer()}resetTimeoutTimer(){this.timeoutTimer&&clearTimeout(this.timeoutTimer),this.timeoutTimer=setTimeout(this.markAsIdle,1e3*60*this.idleTime)}}/*!
|
|
2
|
+
"use strict";var ri=Object.defineProperty;var Me=r=>{throw TypeError(r)};var oi=(r,s,t)=>s in r?ri(r,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[s]=t;var d=(r,s,t)=>oi(r,typeof s!="symbol"?s+"":s,t),De=(r,s,t)=>s.has(r)||Me("Cannot "+t);var x=(r,s,t)=>(De(r,s,"read from private field"),t?t.call(r):s.get(r)),T=(r,s,t)=>s.has(r)?Me("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(r):s.set(r,t),M=(r,s,t,e)=>(De(r,s,"write to private field"),e?e.call(r,t):s.set(r,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Te={".mp3":"audio/mpeg",".mp4":"video/mp4",".m4a":"audio/mp4",".aac":"audio/aac",".ogg":"audio/ogg",".wav":"audio/wav",".flac":"audio/flac",".opus":"audio/opus",".webm":"video/webm",".avi":"video/x-msvideo",".mov":"video/quicktime",".wmv":"video/x-ms-wmv",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".bmp":"image/bmp",".tiff":"image/tiff",".ico":"image/vnd.microsoft.icon",".svg":"image/svg+xml",".webp":"image/webp",".heif":"image/heif",".heic":"image/heic",".json":"application/json",".xml":"application/xml",".html":"text/html",".htm":"text/html",".css":"text/css",".js":"application/javascript",".ts":"application/typescript",".csv":"text/csv",".tsv":"text/tab-separated-values",".txt":"text/plain",".md":"text/markdown",".rtf":"application/rtf",".pdf":"application/pdf",".zip":"application/zip",".rar":"application/x-rar-compressed",".tar":"application/x-tar",".gz":"application/gzip",".7z":"application/x-7z-compressed",".exe":"application/x-msdownload",".apk":"application/vnd.android.package-archive",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".odt":"application/vnd.oasis.opendocument.text",".ods":"application/vnd.oasis.opendocument.spreadsheet",".odp":"application/vnd.oasis.opendocument.presentation",".jsonld":"application/ld+json",".yaml":"application/x-yaml",".yml":"application/x-yaml",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject",".map":"application/json"},zt={image:[".jpg",".jpeg",".png",".gif",".bmp",".webp",".tiff",".svg",".heif",".heic",".ico",".raw",".jfif",".avif",".png8",".indd",".eps",".ai"],ppt:[".ppt",".pptx",".odp"],word:[".doc",".docx",".odt",".rtf"],excel:[".xls",".xlsx",".ods",".csv",".tsv"],pdf:[".pdf"],text:[".txt",".csv",".md",".json",".yaml",".yml",".log",".ini",".rtf"],audio:[".mp3",".wav",".ogg",".flac",".aac",".wma",".m4a",".alac",".ape",".opus",".amr",".ra",".mid",".midi",".aiff",".pcm",".au",".wavpack",".spx"],video:[".mp4",".avi",".mkv",".mov",".wmv",".flv",".webm",".mpg",".mpeg",".3gp",".vob",".ogv",".m4v",".ts",".rm",".rmvb",".m2ts",".divx",".xvid",".swf",".f4v"],archive:[".zip",".rar",".tar",".gz",".bz2",".xz",".7z",".tar.gz",".tar.bz2",".tar.xz",".tar.lz",".tar.lzma",".cab",".iso",".dmg",".tgz",".apk",".gz2",".tar.zst"],code:[".js",".ts",".py",".java",".cpp",".c",".html",".css",".scss",".less",".sass",".php",".rb",".go",".swift",".rs",".kt",".scala",".lua",".pl",".m",".h",".xml",".json",".yaml",".yml",".toml",".vue",".ejs",".handlebars",".jinja",".dart"],font:[".woff",".woff2",".ttf",".otf",".eot",".svg",".ttc",".fnt",".fon",".otc"],database:[".sql",".sqlite",".db",".mdb",".accdb",".jsonld",".xml",".csv"],markup:[".html",".htm",".xhtml",".xml",".json",".yaml",".yml"],configuration:[".ini",".conf",".cfg",".env",".properties",".json",".toml"],logs:[".log",".err",".trace",".out"],script:[".bash",".sh",".zsh",".bat",".ps1",".vbs",".cmd",".sed",".awk",".php"]},fe=["","万","亿","兆","京","垓","秭","穰","沟","涧","正","载","极"],ai=["_self","_blank","_parent","_top"],Pe={Letter:{width:215.9,height:279.4},Legal:{width:215.9,height:355.6},Tabloid:{width:279.4,height:431.8},Ledger:{width:431.8,height:279.4},Executive:{width:184.2,height:266.7},Folio:{width:215.9,height:330.2},Quarto:{width:215,height:275},"Government-Letter":{width:203.2,height:266.7},A0:{width:841,height:1189},A1:{width:594,height:841},A2:{width:420,height:594},A3:{width:297,height:420},A4:{width:210,height:297},A5:{width:148,height:210},A6:{width:105,height:148},A7:{width:74,height:105},A8:{width:52,height:74},A9:{width:37,height:52},A10:{width:26,height:37},B0:{width:1e3,height:1414},B1:{width:707,height:1e3},B2:{width:500,height:707},B3:{width:353,height:500},B4:{width:250,height:353},B5:{width:176,height:250},B6:{width:125,height:176},B7:{width:88,height:125},B8:{width:62,height:88},B9:{width:44,height:62},B10:{width:31,height:44},C0:{width:917,height:1297},C1:{width:648,height:917},C2:{width:458,height:648},C3:{width:324,height:458},C4:{width:229,height:324},C5:{width:162,height:229},C6:{width:114,height:162},C7:{width:81,height:114},C8:{width:57,height:81}},li=Object.keys(Pe).map(r=>({value:r,label:r}));function Vt(r,s=500){let t,e=!0;function i(n){if(!e)return;t||(t=n);let o=Math.min((n-t)/s,1);r(o),n-t<s&&requestAnimationFrame(i)}return requestAnimationFrame(i),()=>e=!1}function ci(r,s,t,e,i=2){let n=r,o=!1,a=1,l=r,c=s,h=t;const u=()=>{const P=(c-l)/h;return Number(P.toFixed(i))};let f=u();const m=P=>Math.min(Math.max(P,l),c),p=P=>Number(P.toFixed(i)),g=(P,b,E)=>{const O=[];return P>=b&&O.push("最小值必须小于最大值"),E<=0?O.push("分段数必须为正数"):u()==0&&O.push("数值精度过低,致使动画步长为 0"),O},y=(P,b,E)=>{const O=g(P,b,E);return O.length>0?(console.error(`参数更新失败: ${O.join("; ")}`),!1):(l=P,c=b,h=E,f=u(),n=m(n),!0)},w=()=>{o&&(a=n>=c?-1:n<=l?1:a,n=m(n+f*a),e(p(n)),requestAnimationFrame(w))};return{play(P=n){if(n=m(P),g(l,c,h).length)return console.error("配置参数错误",this.getParams());o||(o=!0,w())},pause(){o=!1},getCurrent:()=>p(n),isPlaying:()=>o,updateParams:y,getParams:()=>({min:l,max:c,steps:h,precision:i,stepSize:f})}}function Le(r,s,t,e,i=4){if(t<=0)return console.error("动画步数 必须为正数");const n=u=>Number(u.toFixed(i)),o=s-r,a=n(Math.abs(o)/t);if(a===0)return console.error("数值精度过低,致使动画步长为 0");const l=Math.sign(o);let c=r;const h=()=>{c=n(c+a*l),(l>0?c<s:c>s)?(e(c),requestAnimationFrame(h)):e(s)};h()}function hi(r,s,t,e){const i=l=>3*(1-l)**2*l*r+3*(1-l)*l**2*t+l**3,n=l=>3*(1-l)**2*l*s+3*(1-l)*l**2*e+l**3,o=l=>3*r*(1-l)*(1-3*l)+3*t*(2*l-3*l**2)+3*l**2,a=l=>{if(l<=0)return 0;if(l>=1)return 1;let c=l;for(let f=0;f<8;f++){const m=i(c)-l;if(Math.abs(m)<1e-6)return c;const p=o(c);if(Math.abs(p)<1e-6)break;const g=c-m/p;if(g<0||g>1)break;c=g}let h=0,u=1;c=l;for(let f=0;f<24;f++){const m=i(c)-l;if(Math.abs(m)<1e-6)return c;m>0?u=c:h=c,c=(h+u)/2}return c};return l=>{const c=Math.min(1,Math.max(0,l));return n(a(c))}}function ui(r,s="image/png"){try{let t,e=s;if(r instanceof File)return URL.createObjectURL(r);if(typeof r=="string"){let n=r;const o=n.match(/^data:([^;]*)(;base64)?,(.*)$/i);if(o){if(!o[2])return console.error("无效的数据 URL:缺少 base64 编码声明");if(e=o[1]||e,n=o[3],!n)return console.error("数据 URL 包含空有效负载")}n=n.replace(/[^A-Za-z0-9+/=]/g,"");const a=atob(n);t=new Uint8Array(a.length);for(let l=0;l<a.length;l++)t[l]=a.charCodeAt(l)}else if(r instanceof ArrayBuffer)t=new Uint8Array(r);else if(r instanceof Uint8Array)t=r;else return console.error("不支持的数据类型。应为 Base64 字符串、ArrayBuffer 或 Uint8Array");const i=new Blob([t],{type:e});return URL.createObjectURL(i)}catch(t){return console.error("数据到 ImageURL 的转换失败:",t.message,t.stack||"没有可用的堆栈跟踪"),null}}function di(r){return r.charAt(0).toUpperCase()+r.slice(1)}function fi(r,s,t=2){return!Number.isFinite(r)||!Number.isFinite(s)||!Number.isFinite(t)?(console.error("所有参数必须是有限的数字"),""):s===0?(console.error("分母不能为零"),""):t<0?(console.error("小数位数不能为负数"),""):(r/s*100).toFixed(t)+"%"}function Qt(r){const t=r.toString().split("."),e=t[0].replace(/\B(?=(\d{3})+(?!\d))/g,",");return t.length>1?e+"."+t[1]:e}function mi(r,s){const t={join:!0,suffix:"",decimalPlaces:2},{join:e,suffix:i,decimalPlaces:n}={...t,...s||{}},o=Number(r);if(isNaN(o))return e?`0${i}`:[0,i];const a=Math.abs(o),l=o>=0,c=Math.max(0,Math.floor(Math.log10(a)/4)),h=Math.pow(1e4,c),u=a/h,f=(l?1:-1)*parseFloat(u.toFixed(Math.max(0,n)));return e?`${f}${fe[c]}${i}`:[f,fe[c]+i]}function gi(r){const s=["B","KB","MB","GB","TB","PB"];let t=0;for(;r>1024;)r/=1024,t++;return`${Math.round(r*100)/100} ${s[t]}`}function Ie(r,s="YYYY-MM-DD hh:mm:ss",t=!0){const e=new Date(r);if(isNaN(e.getTime()))return console.error("Invalid date"),"";const i={YYYY:n=>n.getFullYear(),MM:n=>n.getMonth()+1,DD:n=>n.getDate(),hh:n=>n.getHours(),mm:n=>n.getMinutes(),ss:n=>n.getSeconds(),ms:n=>n.getMilliseconds()};return s.replace(/YYYY|MM|DD|hh|mm|ss|ms/g,n=>{const o=i[n](e);return t?String(o).padStart(2,"0"):String(o)})}function Jt(r,s="file"){if(!r||(r=String(r).trim(),r===""))return s;const t=r.split("/");return t[t.length-1].split("?")[0]}function pi(r,s){return r=r.replace(/([^a-zA-Z][a-z])/g,t=>t.toUpperCase()),s?r.replace(/[^a-zA-Z]+/g,""):r}function vi(r,s,t=","){const e=new RegExp(`(^|${t})${s}(${t}|$)`,"g");return r.replace(e,function(i,n,o){return n===o?t:""})}function yi(r,s=!0){const t={"\b":"\\b"," ":"\\t","\n":"\\n","\v":"\\v","\f":"\\f","\r":"\\r"," ":"\\s"},e=Object.fromEntries(Object.entries(t).map(([i,n])=>[n,i]));return s?r.replace(/[\b\t\n\v\f\r ]/g,i=>t[i]):r.replace(/\\[btnvfrs]/g,i=>e[i]||i)}const Bt=[["年",365*24*60*60*1e3],["月",30*24*60*60*1e3],["周",7*24*60*60*1e3],["天",24*60*60*1e3],["时",60*60*1e3],["分",60*1e3],["秒",1e3],["毫秒",1]];function wi(r,s){if(!Number.isFinite(r)||r<0)return"0毫秒";r=Math.round(r);const t=s?Bt.findIndex(([i])=>i===s):0,e=t===-1?0:t;for(let i=e;i<Bt.length;i++){const[n,o]=Bt[i];if(r>=o){const a=o===1?r:Math.round(r/o*10)/10;let l=Number.isInteger(a)?a:a.toFixed(1).replace(/\.0$/,"");return n===Bt[e][0]&&(l=Qt(Number(l))),`${l}${n}`}}return"0毫秒"}function xi(r,s){if(s<1)return console.error("分割大小必须大于0"),[];const t=[];for(let e=0;e<r.length;e+=s){const i=r.slice(e,e+s);t.push(i)}return t}function oe(r,s=2){if(Array.isArray(r)&&r.length>=s){for(let e=0;e<r.length;e++)if(typeof r[e]!="number"||!Number.isFinite(r[e]))return!1}else return!1;return!0}function At(r,s=1,t=2){if(Array.isArray(r)&&r.length>=s){for(let i=0;i<r.length;i++)if(!oe(r[i],t))return!1}else return!1;return!0}function Pi(r,s,t){return Math.abs(r-s)<=t}function bi(r,s){let t=!1;const{x:e,y:i}=r,n=s.length;for(let o=0,a=n-1;o<n;a=o++){const l=s[o].x,c=s[o].y,h=s[a].x,u=s[a].y;c>i!=u>i&&e<(h-l)*(i-c)/(u-c)+l&&(t=!t)}return t}function Ci(r,s,t,e){const i=Math.min(r[0],s[0]),n=Math.max(r[0],s[0]),o=Math.min(r[1],s[1]),a=Math.max(r[1],s[1]),l=[[i,o],[n,o],[n,a],[i,a]],c=e[1]-t[1],h=t[0]-e[0],u=e[0]*t[1]-t[0]*e[1];if(c===0&&h===0){const[g,y]=t;return g>=i&&g<=n&&y>=o&&y<=a}const f=1e-10;let m=!1,p=!1;for(const[g,y]of l){const w=c*g+h*y+u;if(Math.abs(w)<f||(w>f?m=!0:p=!0,m&&p))return!0}return m&&p}function Kt(r){return Object.prototype.toString.call(r).slice(8,-1).toLowerCase()}function _i(r){return["https:","wss:","ftps:","sftp:","smpts:","smtp+tls:","imap+tls:","pop3+tls:","rdp:","vpn:"].some(t=>r.startsWith(t))}function Si(r){return new Promise((s,t)=>{if(typeof r!="string"||r.trim()===""||!r.includes("://")){t(new Error("Invalid URL: Must be a non-empty string"));return}try{new XMLHttpRequest().open("HEAD",r,!0)}catch(n){t(new Error(`Invalid URL format: ${n.message}`));return}const e=new XMLHttpRequest;e.open("HEAD",r,!0);const i=n=>{t(new Error(`Request failed: ${n.type}`))};e.onreadystatechange=function(){e.readyState===XMLHttpRequest.DONE&&(e.status===0?t(new Error("Network error or CORS blocked")):e.status>=200&&e.status<300?s(!0):t(new Error(`HTTP Error: ${e.status}`)))},e.onerror=i,e.onabort=i,e.ontimeout=i;try{e.send()}catch(n){t(new Error(`Request send failed: ${n.message}`))}})}const it=class it{constructor(){if(new.target===it)throw new Error("请直接使用静态方法,而不是实例化此类")}static check(s,t){if(!s||typeof s!="string")return console.error("Invalid URL provided"),t?!1:"unknown";const e=Jt(s).toLowerCase();if(t){if(!zt.hasOwnProperty(t))return console.error(`Unknown file type: ${t}`),"unknown";const i=zt[t];return it._checkExtension(e,i)}return it._detectFileType(e)}static parseAddresses(s){return!s||typeof s!="string"?(console.error("Invalid URL provided"),[]):s.split(",").map(t=>{const e=Jt(t),i=this.check(t);return{url:t,name:e,type:i}})}static matchesMimeType(s,t){if(!t)return!0;if(typeof s!="string"||typeof t!="string")return!1;const e=it._normalizeType(s),i=t.split(",").map(a=>it._normalizeType(a.trim())),[n,o="*"]=e.split("/");return i.some(a=>{const[l,c="*"]=a.split("/");return(l==="*"||n==="*"||l===n)&&(c==="*"||o==="*"||c===o)})}static _normalizeType(s){return s.startsWith(".")&&!s.includes("/")?Te[s.toLowerCase()]||s:s.includes("/")?s:`${s}/*`}static _checkExtension(s,t){return t.some(e=>s.endsWith(e))}static _detectFileType(s){for(const[t,e]of it.cachedEntries)if(e.some(i=>s.endsWith(i)))return t;return"unknown"}};d(it,"cachedEntries",Object.entries(zt));let me=it;const Ei=/\w*(?:\[\d+\])+|\w+/g,Ne=/^\w*(?:\[\d+\])+$/,He=/\w+|(\[\d+\])/g,Fe=/\[(\d+)\]/;function Be(r){return r?r.match(Ei)||[]:[]}function Mi(r,s=3e3){if(typeof r!="function")return console.error("非函数:",r);const t=window.requestIdleCallback,e=function(i){i.timeRemaining()<=0&&!i.didTimeout?t(e,{timeout:s}):r(i)};t?t(e,{timeout:s}):requestAnimationFrame(()=>r())}function Ue(r,s){const t=Date.now();return new Promise((e,i)=>{const n=()=>{const o=Date.now()-t;if(o>=s)return i(o);if(r())return e(o);requestAnimationFrame(n)};n()})}function rt(r,s,t=[],e=Date.now()){if(e<Date.now()-50){console.error("_MergeObjects 合并异常:疑似死循环");return}const i=Kt(r),n=Kt(s);if(i!=n)return s;if(i=="object"||i=="array"){if(t.some(([o,a])=>o==r&&a==s))return r;if(t.push([r,s]),i=="object"){for(const o in s)if(Object.prototype.hasOwnProperty.call(s,o)){const a=s[o],l=r[o],c=rt(l,a,t,e);r[o]=c}return r}else if(i=="array")return s.forEach((o,a)=>{const l=o,c=r[a],h=rt(c,l,t,e);r[a]=h}),r}else return s}function te(r=""){return r+"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(s){const t=Math.random()*16|0;return(s==="x"?t:t&3|8).toString(16)})}function be(r,s){let t;return function(...e){clearTimeout(t),t=setTimeout(()=>{r(...e),t=void 0},s)}}function Di(r,s){let t=-1/0;return function(...e){const i=performance.now();if(i-t>s){t=i;try{r(...e)}catch(n){console.error("Throttled function execution failed:",n)}}}}function Ri(r,s){if(!r||!s)return r;const t=Be(s);return t.length?t.reduce((e,i,n)=>{const o=n===t.length-1;if(Ne.test(i)){const a=i.match(He)||[];return a.reduce((l,c,h)=>{if(/^\w+$/.test(c))return l[c]||(h<a.length-1?[]:{});const u=c.match(Fe),f=u?parseInt(u[1],10):0,m=h===a.length-1;return m&&o?l[f]:l[f]||(m?{}:[])},e)}return o?e[i]:e[i]||{}},r):r}function ki(r,s,t,e){if(!r||!s)return t;const i=Be(s);return i.length?i.reduce((n,o,a)=>{const l=a===i.length-1;if(Ne.test(o)){const c=o.match(He)||[];return c.reduce((h,u,f)=>{const m=f===c.length-1;if(/^\w+$/.test(u))return h.hasOwnProperty(u)||(h[u]=[]),h[u];const p=u.match(Fe),g=p?parseInt(p[1],10):0,y=m&&l;return h.hasOwnProperty(g)?y&&!e&&(h[g]=t):h[g]=y?t:m?{}:[],h[g]},n)}return l?((!e||!n.hasOwnProperty(o))&&(n[o]=t),n[o]):(n.hasOwnProperty(o)||(n[o]={}),n[o])},r):t}function Vi(r){return r.map((s,t)=>r.slice(t).concat(r.slice(0,t)))}function ze(r){const s=window.structuredClone,t=(e,i=new WeakMap)=>{const n=e;if(n===null||typeof n!="object")return n;if(i.has(n))return i.get(n);switch(Kt(n)){case"array":{const a=[];i.set(n,a);for(const l of n)a.push(t(l,i));return a}case"object":{if(n===null)return n;const a={};i.set(n,a);for(const l in n)Object.prototype.hasOwnProperty.call(n,l)&&(a[l]=t(n[l],i));return a}case"date":{const a=new Date(n.getTime());return i.set(n,a),a}case"regexp":{const a=n,l=new RegExp(a.source,a.flags);return l.lastIndex=a.lastIndex,i.set(n,l),l}case"map":{const a=new Map;return i.set(n,a),n.forEach((l,c)=>{a.set(t(c,i),t(l,i))}),a}case"set":{const a=new Set;return i.set(n,a),n.forEach(l=>{a.add(t(l,i))}),a}case"arraybuffer":case"dataview":case"int8array":case"uint8array":case"uint8clampedarray":case"int16array":case"uint16array":case"int32array":case"uint32array":case"float32array":case"float64array":case"bigint64array":case"biguint64array":{const a=n,l=a.constructor,c=a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength),h=new l(c,a.byteOffset,a.byteLength/a.BYTES_PER_ELEMENT);return i.set(n,h),h}case"error":{const a=n,l=new a.constructor(a.message);return l.stack=a.stack,l.name=a.name,i.set(n,l),l}case"function":case"promise":case"weakmap":case"weakset":case"file":default:return n}};try{return s?s(r):t(r)}catch(e){return console.warn("structuredClone error:",e),s&&t(r)}}function Ge(r,s){const t=[[11,"#d03050"],[8,"#f0a020"],[5,"#2080f0"],[2,"#18a058"]],{level:e=t,maxHistory:i=30,prefix:n=""}=s||{};if(e.sort((h,u)=>u[0]-h[0]),typeof r!="function")return console.error("第一个参数必须是一个函数。");if(!Array.isArray(e))return console.error("第二个参数必须是一个数组。");let o=[],a=0;const l=(h,u)=>{for(const[f,m]of u)if(h>=f)return m;return"black"};return(...h)=>{const u=performance.now(),f=r(...h),m=performance.now()-u;o.push(m),o.length>i&&o.shift(),a=o.reduce((y,w)=>y+w,0)/o.length||0;const p=l(m,e),g=l(a,e);return console.log(`%c${n?n+" - ":""}单次耗时:${m.toFixed(2)}ms
|
|
3
|
+
%c平均耗时(${o.length}次):${a.toFixed(2)}ms`,`color: ${p}; padding: 2px 0;`,`color: ${g}; padding: 2px 0;`),f}}function Ai(r){const s=Date.now();let t=performance.now();for(;Date.now()-s<r;){t=Math.sin(t)*1e6,(t>1e6||t<-1e6)&&(t=0);try{const e=t.toString().substring(0,8);history.replaceState(null,"",`#${e}`)}catch{}}return Date.now()-s}class Xe{constructor(){}static clamp(s,t,e){return Math.min(Math.max(s,t),e)}static normalizeHue(s){return(s%360+360)%360}static chromaToRgb(s,t,e){const i=t*(1-Math.abs(s/60%2-1));let n=0,o=0,a=0;return s<60?[n,o,a]=[t,i,0]:s<120?[n,o,a]=[i,t,0]:s<180?[n,o,a]=[0,t,i]:s<240?[n,o,a]=[0,i,t]:s<300?[n,o,a]=[i,0,t]:[n,o,a]=[t,0,i],{r:(n+e)*255,g:(o+e)*255,b:(a+e)*255}}static resolveAlpha(s,t){return Number.isFinite(s)?this.clamp(s,0,1):t}static toRoundedRgbString(s,t,e){return`rgb(${Math.round(s)}, ${Math.round(t)}, ${Math.round(e)})`}static hslToRgb(s,t,e){const i=this.normalizeHue(s),n=this.clamp(t,0,100)/100,o=this.clamp(e,0,100)/100,a=(1-Math.abs(2*o-1))*n,l=o-a/2;return this.chromaToRgb(i,a,l)}static hsvToRgb(s,t,e){const i=this.normalizeHue(s),n=this.clamp(t,0,100)/100,o=this.clamp(e,0,100)/100,a=o*n,l=o-a;return this.chromaToRgb(i,a,l)}static parseColor(s){const t=s.trim().toLowerCase();if(t.startsWith("#")){const o=t.slice(1);if(o.length===3||o.length===4){const[a,l,c,h="f"]=o.split("");return{r:parseInt(`${a}${a}`,16),g:parseInt(`${l}${l}`,16),b:parseInt(`${c}${c}`,16),a:parseInt(`${h}${h}`,16)/255}}if(o.length===6||o.length===8){const a=parseInt(o.slice(0,2),16),l=parseInt(o.slice(2,4),16),c=parseInt(o.slice(4,6),16),h=o.length===8?parseInt(o.slice(6,8),16)/255:this.DEFAULT_ALPHA;return{r:a,g:l,b:c,a:h}}}const e=t.match(/^rgba?\(([^)]+)\)$/);if(e){const o=e[1].split(",").map(a=>a.trim());if(o.length>=3){const a=this.clamp(Number(o[0]),0,255),l=this.clamp(Number(o[1]),0,255),c=this.clamp(Number(o[2]),0,255),h=o.length>=4?this.clamp(Number(o[3]),0,1):this.DEFAULT_ALPHA;return{r:a,g:l,b:c,a:h}}}const i=t.match(/^hsl\(([^)]+)\)$/);if(i){const o=i[1].split(",").map(a=>a.trim().replace("%",""));if(o.length>=3){const a=Number(o[0]),l=Number(o[1]),c=Number(o[2]);return{...this.hslToRgb(a,l,c),a:this.DEFAULT_ALPHA}}}const n=t.match(/^hsv\(([^)]+)\)$/);if(n){const o=n[1].split(",").map(a=>a.trim().replace("%",""));if(o.length>=3){const a=Number(o[0]),l=Number(o[1]),c=Number(o[2]);return{...this.hsvToRgb(a,l,c),a:this.DEFAULT_ALPHA}}}return console.error("Invalid color format",s),{r:0,g:0,b:0,a:this.DEFAULT_ALPHA}}static toHexPart(s){return Math.round(this.clamp(s,0,255)).toString(16).padStart(2,"0")}static rgbToHsl(s,t,e){const i=this.clamp(s,0,255)/255,n=this.clamp(t,0,255)/255,o=this.clamp(e,0,255)/255,a=Math.max(i,n,o),l=Math.min(i,n,o),c=a-l;let h=0;c!==0&&(a===i?h=60*((n-o)/c%6):a===n?h=60*((o-i)/c+2):h=60*((i-n)/c+4)),h<0&&(h+=360);const u=(a+l)/2,f=c===0?0:c/(1-Math.abs(2*u-1));return{h,s:f*100,l:u*100}}static rgbToHsv(s,t,e){const i=this.clamp(s,0,255)/255,n=this.clamp(t,0,255)/255,o=this.clamp(e,0,255)/255,a=Math.max(i,n,o),l=Math.min(i,n,o),c=a-l;let h=0;c!==0&&(a===i?h=60*((n-o)/c%6):a===n?h=60*((o-i)/c+2):h=60*((i-n)/c+4)),h<0&&(h+=360);const u=a===0?0:c/a,f=a;return{h,s:u*100,v:f*100}}static toHex(s){const{r:t,g:e,b:i}=this.parseColor(s);return`#${this.toHexPart(t)}${this.toHexPart(e)}${this.toHexPart(i)}`}static toHexa(s,t){const{r:e,g:i,b:n,a:o}=this.parseColor(s),a=this.resolveAlpha(t,o);return`#${this.toHexPart(e)}${this.toHexPart(i)}${this.toHexPart(n)}${this.toHexPart(a*255)}`}static toRgb(s){const{r:t,g:e,b:i}=this.parseColor(s);return this.toRoundedRgbString(t,e,i)}static toRgba(s,t){const e=this.parseColor(s),i=this.resolveAlpha(t,e.a);return`rgba(${Math.round(e.r)}, ${Math.round(e.g)}, ${Math.round(e.b)}, ${i})`}static toHsl(s){const{r:t,g:e,b:i}=this.parseColor(s),{h:n,s:o,l:a}=this.rgbToHsl(t,e,i);return`hsl(${Math.round(n)}, ${Math.round(o)}%, ${Math.round(a)}%)`}static toHsla(s,t){const e=this.parseColor(s),{h:i,s:n,l:o}=this.rgbToHsl(e.r,e.g,e.b),a=this.resolveAlpha(t,e.a);return`hsla(${Math.round(i)}, ${Math.round(n)}%, ${Math.round(o)}%, ${a})`}static toHsv(s){const{r:t,g:e,b:i}=this.parseColor(s),{h:n,s:o,v:a}=this.rgbToHsv(t,e,i);return`hsv(${Math.round(n)}, ${Math.round(o)}%, ${Math.round(a)}%)`}static toHsva(s,t){const e=this.parseColor(s),{h:i,s:n,v:o}=this.rgbToHsv(e.r,e.g,e.b),a=this.resolveAlpha(t,e.a);return`hsva(${Math.round(i)}, ${Math.round(n)}%, ${Math.round(o)}%, ${a})`}}d(Xe,"DEFAULT_ALPHA",1);var wt=(r=>(r.RESPONSE="response",r.QUERY="query",r))(wt||{});class Oi{constructor(s,t){d(this,"soundSources");d(this,"preloadTasks",new Map);this.soundSources={...s};const e=t==null?void 0:t.holdKeys;if(e!=null&&e.length)for(const i of e)this.fetchAndReplaceSource(i)}preload(s){const t=Array.isArray(s)?s:[s];return Promise.all(t.map(e=>this.fetchAndReplaceSource(e))).then(()=>{})}fetchAndReplaceSource(s){const t=this.preloadTasks.get(s);if(t)return t;const e=this.soundSources[s];if(!e)return Promise.reject(new Error(`未找到对应音效资源: ${String(s)}`));if(e.startsWith("blob:")){const n=Promise.resolve();return this.preloadTasks.set(s,n),n}const i=fetch(e).then(n=>{if(!n.ok)throw new Error(`音效下载失败: ${n.status} ${e}`);return n.blob()}).then(n=>{const o=this.soundSources[s],a=URL.createObjectURL(n);this.soundSources[s]=a,o.startsWith("blob:")&&o!==a&&URL.revokeObjectURL(o)}).catch(n=>{throw this.preloadTasks.delete(s),n instanceof Error?n:new Error(String(n))});return this.preloadTasks.set(s,i),i}play(s,t){const e=this.soundSources[s];return e?this.playUrl(e,t):(console.warn(`未找到对应音效资源: ${String(s)}`),()=>{})}playUrl(s,t){if(!s){console.error("音效资源地址为空");return}const e=new Audio(s),i=(t==null?void 0:t.loopCount)!==void 0&&t.loopCount>0?t.loopCount:void 0,n=(t==null?void 0:t.loop)&&i===void 0;let o=0,a=!1;const l=()=>{a||(a=!0,e.pause(),e.currentTime=0,e.removeEventListener("ended",c),e.onerror=null)},c=()=>{if(!a){if(n){e.currentTime=0,e.play().catch(h=>{console.warn("循环音效再次播放失败:",h),l()});return}if(i!==void 0&&o+1<i){o+=1,e.currentTime=0,e.play().catch(h=>{console.warn("循环音效再次播放失败:",h),l()});return}l()}};return e.addEventListener("ended",c),e.onerror=()=>{a||(console.error(`音效资源加载失败: ${s}`),l())},e.play().catch(h=>{a||(console.warn("音效播放失败(可能是自动播放策略限制):",h),l())}),l}}function Re(r,s){for(const t of Object.keys(s))s[t]!==void 0&&(r[t]=s[t])}class Ti{constructor(s){d(this,"url");d(this,"socket");d(this,"onopen");d(this,"onmessage");d(this,"onerror");d(this,"onclose");d(this,"pingConfig",{enabled:!1,interval:1e3*30,content:"ping"});d(this,"pingTimer");d(this,"retryConfig",{maxCount:3,currentCount:0,interval:1e3});d(this,"send",s=>{var t;return this.ready?((t=this.socket)==null||t.send(s),!0):!1});if(!s)return;const{url:t,ping:e,maxRetryCount:i,retryInterval:n}=s;e!==void 0&&(typeof e=="boolean"?this.pingConfig.enabled=e:Re(this.pingConfig,e)),Re(this.retryConfig,{maxCount:i,interval:n}),t&&this.start(t)}get ready(){var s;return((s=this.socket)==null?void 0:s.readyState)===WebSocket.OPEN}startPing(){const{interval:s,content:t,enabled:e}=this.pingConfig;e&&(this.pingTimer=setInterval(()=>{var i;this.ready?(i=this.socket)==null||i.send(t):console.warn("WebSocket未就绪,无法发送ping")},s))}startRetry(){const{maxCount:s,interval:t,currentCount:e}=this.retryConfig;if(s<=e){console.error("WebSocket重试次数已用完"),this.retryConfig.currentCount=0;return}this.retryConfig.currentCount++,setTimeout(()=>this.start(this.url),t)}start(s){this.stop();const t=new WebSocket(s);this.socket=t,this.url=s,t.onopen=e=>{var i;console.log("WebSocket已连接"),this.startPing(),this.retryConfig.currentCount=0,(i=this.onopen)==null||i.call(this,e)},t.onmessage=e=>{var i;(i=this.onmessage)==null||i.call(this,e)},t.onerror=e=>{var i;console.error("WebSocket错误:",e),clearInterval(this.pingTimer),this.startRetry(),(i=this.onerror)==null||i.call(this,e)},t.onclose=e=>{var i;console.log("WebSocket已关闭"),clearInterval(this.pingTimer),(i=this.onclose)==null||i.call(this,e)}}stop(){var s;(s=this.socket)==null||s.close(),this.socket=void 0}}function Li(r,s=10){let t=0,e=s;function i(){if(e>0)e--,requestAnimationFrame(i);else{const o=(Date.now()-t)/s,a=1e3/o;r(Number(a.toFixed(2)),Number(o.toFixed(2)))}}requestAnimationFrame(()=>{t=Date.now(),i()})}function Ii(r){const s=()=>Promise.resolve(),t=a=>(console.error(a),Promise.reject(a));function e(){return navigator.clipboard.writeText(r).then(s).catch(t)}function i(){const a=document.createElement("div");a.innerText=r,document.body.appendChild(a);const l=document.createRange();l.selectNodeContents(a);const c=window.getSelection();let h=!1;return c&&(c.removeAllRanges(),c.addRange(l),h=document.execCommand("copy")),document.body.removeChild(a),h?Promise.resolve():Promise.reject()}function n(){const a=document.createElement("textarea");a.value=r,document.body.appendChild(a),a.select(),a.setSelectionRange(0,r.length);let l=!1;return document.activeElement===a&&(l=document.execCommand("Copy",!0)),document.body.removeChild(a),l?Promise.resolve():Promise.reject()}function o(){return i().then(s).catch(()=>{n().then(s).catch(()=>t("复制方式尽皆失效"))})}return navigator.clipboard?e().catch(o):o()}function Ni(r,s){const t=Pe[r];if(!t)return console.error(`未知纸张类型: ${r}`);const{width:e,height:i}=t,n=p=>p/25.4,a=typeof window<"u"?window.devicePixelRatio*96:300,l=p=>Math.round(n(p)*a),c=l(e),h=l(i),u=l(s),f=Math.max(0,c-2*u),m=Math.max(0,h-2*u);return{contentWidth:f,contentHeight:m,paddingPx:u,paperWidthPx:c,paperHeightPx:h}}class Rt{constructor(){}static init(s){if(!s)return console.error("标签页名称不能为空");this.initFinish||(this.setupEventListeners(),this.initFinish=!0),window.name=s}static setupEventListeners(){this.channel.addEventListener("message",s=>{this.handleChannelMessage(s)})}static handleChannelMessage(s){const{type:t,responseKey:e,name:i}=s.data;if(t===wt.RESPONSE){const n=this.pendingQueries.get(e);n==null||n.forEach(o=>o(i))}else if(t===wt.QUERY){if(this.pendingQueries.has(e)||i!="*"&&i!=window.name)return;const n={type:wt.RESPONSE,responseKey:e,name:window.name};this.channel.postMessage(n)}}static getWindow(s){if(!this.initFinish){const o="请先初始化标签页管理器";return console.error(o),Promise.reject(o)}const t=te();let e=!1;const i=this.pendingQueries.get(t)||[];i.push(()=>e=!0),this.pendingQueries.set(t,i);const n={type:wt.QUERY,responseKey:t,name:s};return this.channel.postMessage(n),Ue(()=>e,this.timeout).finally(()=>this.pendingQueries.delete(t))}static openWindow(s,t,e="_blank",i){var n;if(!this.initFinish){const o="请先初始化标签页管理器";return console.error(o),Promise.reject(o)}return(n=this.getWindow(s))==null?void 0:n.then(()=>window.open("javascript:;",s)).catch(()=>{const o=window.open(t,e,i);return o||console.error("无法打开标签页"),o})}static getAllWindows(){if(!this.initFinish){const n="请先初始化标签页管理器";return console.error(n),Promise.reject(n)}const s=te(),t=[],e=this.pendingQueries.get(s)||[];e.push(n=>t.push(n)),this.pendingQueries.set(s,e);const i={type:wt.QUERY,responseKey:s,name:"*"};return this.channel.postMessage(i),new Promise(n=>{setTimeout(()=>{this.pendingQueries.delete(s),n(t)},this.timeout)})}}d(Rt,"initFinish",!1),d(Rt,"channel",new BroadcastChannel("nhanh-pure-function")),d(Rt,"timeout",150),d(Rt,"pendingQueries",new Map);class Hi{constructor(){d(this,"status","active");d(this,"activeCallbacks",new Map);d(this,"idleCallbacks",new Map);d(this,"idleTime",5);d(this,"timeoutTimer");d(this,"activate",()=>{this.status==="idle"&&(this.status="active",console.log("%c已进入活跃状态","background: #4CAF50; color: white; padding: 2px 4px; border-radius: 4px; font-weight: bold;"),this.activeCallbacks.forEach(s=>s())),this.resetTimeoutTimer()});d(this,"markAsIdle",()=>{this.timeoutTimer&&clearTimeout(this.timeoutTimer),this.status==="active"&&(this.status="idle",console.log("%c已进入闲置状态","background: #9E9E9E; color: white; padding: 2px 4px; border-radius: 4px; font-weight: bold;"),this.idleCallbacks.forEach(s=>s()))});window.addEventListener("keypress",this.activate),window.addEventListener("mousemove",this.activate),window.addEventListener("mousedown",this.activate),window.addEventListener("wheel",this.activate),this.resetTimeoutTimer()}resetTimeoutTimer(){this.timeoutTimer&&clearTimeout(this.timeoutTimer),this.timeoutTimer=setTimeout(this.markAsIdle,1e3*60*this.idleTime)}}/*!
|
|
4
4
|
* decimal.js v10.5.0
|
|
5
5
|
* An arbitrary-precision Decimal type for JavaScript.
|
|
6
6
|
* https://github.com/MikeMcl/decimal.js
|
|
7
7
|
* Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
|
|
8
8
|
* MIT Licence
|
|
9
|
-
*/var ge=9e15,ut=1e9,pe="0123456789abcdef",ee="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",ie="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",ve={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-9e15,maxE:ge,crypto:!1},Xe,nt,S=!0,ae="[DecimalError] ",ht=ae+"Invalid argument: ",Ye=ae+"Precision limit exceeded",We=ae+"crypto unavailable",je="[object Decimal]",F=Math.floor,L=Math.pow,Hi=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Fi=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Bi=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,qe=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Q=1e7,_=7,zi=9007199254740991,Ui=ee.length-1,ye=ie.length-1,v={toStringTag:je};v.absoluteValue=v.abs=function(){var r=new this.constructor(this);return r.s<0&&(r.s=1),C(r)};v.ceil=function(){return C(new this.constructor(this),this.e+1,2)};v.clampedTo=v.clamp=function(r,s){var t,e=this,i=e.constructor;if(r=new i(r),s=new i(s),!r.s||!s.s)return new i(NaN);if(r.gt(s))throw Error(ht+s);return t=e.cmp(r),t<0?r:e.cmp(s)>0?s:new i(e)};v.comparedTo=v.cmp=function(r){var s,t,e,i,n=this,o=n.d,a=(r=new n.constructor(r)).d,l=n.s,c=r.s;if(!o||!a)return!l||!c?NaN:l!==c?l:o===a?0:!o^l<0?1:-1;if(!o[0]||!a[0])return o[0]?l:a[0]?-c:0;if(l!==c)return l;if(n.e!==r.e)return n.e>r.e^l<0?1:-1;for(e=o.length,i=a.length,s=0,t=e<i?e:i;s<t;++s)if(o[s]!==a[s])return o[s]>a[s]^l<0?1:-1;return e===i?0:e>i^l<0?1:-1};v.cosine=v.cos=function(){var r,s,t=this,e=t.constructor;return t.d?t.d[0]?(r=e.precision,s=e.rounding,e.precision=r+Math.max(t.e,t.sd())+_,e.rounding=1,t=Gi(e,Ke(e,t)),e.precision=r,e.rounding=s,C(nt==2||nt==3?t.neg():t,r,s,!0)):new e(1):new e(NaN)};v.cubeRoot=v.cbrt=function(){var r,s,t,e,i,n,o,a,l,c,h=this,u=h.constructor;if(!h.isFinite()||h.isZero())return new u(h);for(S=!1,n=h.s*L(h.s*h,1/3),!n||Math.abs(n)==1/0?(t=N(h.d),r=h.e,(n=(r-t.length+1)%3)&&(t+=n==1||n==-2?"0":"00"),n=L(t,1/3),r=F((r+1)/3)-(r%3==(r<0?-1:2)),n==1/0?t="5e"+r:(t=n.toExponential(),t=t.slice(0,t.indexOf("e")+1)+r),e=new u(t),e.s=h.s):e=new u(n.toString()),o=(r=u.precision)+3;;)if(a=e,l=a.times(a).times(a),c=l.plus(h),e=V(c.plus(h).times(a),c.plus(l),o+2,1),N(a.d).slice(0,o)===(t=N(e.d)).slice(0,o))if(t=t.slice(o-3,o+1),t=="9999"||!i&&t=="4999"){if(!i&&(C(a,r+1,0),a.times(a).times(a).eq(h))){e=a;break}o+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(C(e,r+1,1),s=!e.times(e).times(e).eq(h));break}return S=!0,C(e,r,u.rounding,s)};v.decimalPlaces=v.dp=function(){var r,s=this.d,t=NaN;if(s){if(r=s.length-1,t=(r-F(this.e/_))*_,r=s[r],r)for(;r%10==0;r/=10)t--;t<0&&(t=0)}return t};v.dividedBy=v.div=function(r){return V(this,new this.constructor(r))};v.dividedToIntegerBy=v.divToInt=function(r){var s=this,t=s.constructor;return C(V(s,new t(r),0,1,1),t.precision,t.rounding)};v.equals=v.eq=function(r){return this.cmp(r)===0};v.floor=function(){return C(new this.constructor(this),this.e+1,3)};v.greaterThan=v.gt=function(r){return this.cmp(r)>0};v.greaterThanOrEqualTo=v.gte=function(r){var s=this.cmp(r);return s==1||s===0};v.hyperbolicCosine=v.cosh=function(){var r,s,t,e,i,n=this,o=n.constructor,a=new o(1);if(!n.isFinite())return new o(n.s?1/0:NaN);if(n.isZero())return a;t=o.precision,e=o.rounding,o.precision=t+Math.max(n.e,n.sd())+4,o.rounding=1,i=n.d.length,i<32?(r=Math.ceil(i/3),s=(1/ce(4,r)).toString()):(r=16,s="2.3283064365386962890625e-10"),n=Dt(o,1,n.times(s),new o(1),!0);for(var l,c=r,h=new o(8);c--;)l=n.times(n),n=a.minus(l.times(h.minus(l.times(h))));return C(n,o.precision=t,o.rounding=e,!0)};v.hyperbolicSine=v.sinh=function(){var r,s,t,e,i=this,n=i.constructor;if(!i.isFinite()||i.isZero())return new n(i);if(s=n.precision,t=n.rounding,n.precision=s+Math.max(i.e,i.sd())+4,n.rounding=1,e=i.d.length,e<3)i=Dt(n,2,i,i,!0);else{r=1.4*Math.sqrt(e),r=r>16?16:r|0,i=i.times(1/ce(5,r)),i=Dt(n,2,i,i,!0);for(var o,a=new n(5),l=new n(16),c=new n(20);r--;)o=i.times(i),i=i.times(a.plus(o.times(l.times(o).plus(c))))}return n.precision=s,n.rounding=t,C(i,s,t,!0)};v.hyperbolicTangent=v.tanh=function(){var r,s,t=this,e=t.constructor;return t.isFinite()?t.isZero()?new e(t):(r=e.precision,s=e.rounding,e.precision=r+7,e.rounding=1,V(t.sinh(),t.cosh(),e.precision=r,e.rounding=s)):new e(t.s)};v.inverseCosine=v.acos=function(){var r=this,s=r.constructor,t=r.abs().cmp(1),e=s.precision,i=s.rounding;return t!==-1?t===0?r.isNeg()?tt(s,e,i):new s(0):new s(NaN):r.isZero()?tt(s,e+4,i).times(.5):(s.precision=e+6,s.rounding=1,r=new s(1).minus(r).div(r.plus(1)).sqrt().atan(),s.precision=e,s.rounding=i,r.times(2))};v.inverseHyperbolicCosine=v.acosh=function(){var r,s,t=this,e=t.constructor;return t.lte(1)?new e(t.eq(1)?0:NaN):t.isFinite()?(r=e.precision,s=e.rounding,e.precision=r+Math.max(Math.abs(t.e),t.sd())+4,e.rounding=1,S=!1,t=t.times(t).minus(1).sqrt().plus(t),S=!0,e.precision=r,e.rounding=s,t.ln()):new e(t)};v.inverseHyperbolicSine=v.asinh=function(){var r,s,t=this,e=t.constructor;return!t.isFinite()||t.isZero()?new e(t):(r=e.precision,s=e.rounding,e.precision=r+2*Math.max(Math.abs(t.e),t.sd())+6,e.rounding=1,S=!1,t=t.times(t).plus(1).sqrt().plus(t),S=!0,e.precision=r,e.rounding=s,t.ln())};v.inverseHyperbolicTangent=v.atanh=function(){var r,s,t,e,i=this,n=i.constructor;return i.isFinite()?i.e>=0?new n(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(r=n.precision,s=n.rounding,e=i.sd(),Math.max(e,r)<2*-i.e-1?C(new n(i),r,s,!0):(n.precision=t=e-i.e,i=V(i.plus(1),new n(1).minus(i),t+r,1),n.precision=r+4,n.rounding=1,i=i.ln(),n.precision=r,n.rounding=s,i.times(.5))):new n(NaN)};v.inverseSine=v.asin=function(){var r,s,t,e,i=this,n=i.constructor;return i.isZero()?new n(i):(s=i.abs().cmp(1),t=n.precision,e=n.rounding,s!==-1?s===0?(r=tt(n,t+4,e).times(.5),r.s=i.s,r):new n(NaN):(n.precision=t+6,n.rounding=1,i=i.div(new n(1).minus(i.times(i)).sqrt().plus(1)).atan(),n.precision=t,n.rounding=e,i.times(2)))};v.inverseTangent=v.atan=function(){var r,s,t,e,i,n,o,a,l,c=this,h=c.constructor,u=h.precision,f=h.rounding;if(c.isFinite()){if(c.isZero())return new h(c);if(c.abs().eq(1)&&u+4<=ye)return o=tt(h,u+4,f).times(.25),o.s=c.s,o}else{if(!c.s)return new h(NaN);if(u+4<=ye)return o=tt(h,u+4,f).times(.5),o.s=c.s,o}for(h.precision=a=u+10,h.rounding=1,t=Math.min(28,a/_+2|0),r=t;r;--r)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(S=!1,s=Math.ceil(a/_),e=1,l=c.times(c),o=new h(c),i=c;r!==-1;)if(i=i.times(l),n=o.minus(i.div(e+=2)),i=i.times(l),o=n.plus(i.div(e+=2)),o.d[s]!==void 0)for(r=s;o.d[r]===n.d[r]&&r--;);return t&&(o=o.times(2<<t-1)),S=!0,C(o,h.precision=u,h.rounding=f,!0)};v.isFinite=function(){return!!this.d};v.isInteger=v.isInt=function(){return!!this.d&&F(this.e/_)>this.d.length-2};v.isNaN=function(){return!this.s};v.isNegative=v.isNeg=function(){return this.s<0};v.isPositive=v.isPos=function(){return this.s>0};v.isZero=function(){return!!this.d&&this.d[0]===0};v.lessThan=v.lt=function(r){return this.cmp(r)<0};v.lessThanOrEqualTo=v.lte=function(r){return this.cmp(r)<1};v.logarithm=v.log=function(r){var s,t,e,i,n,o,a,l,c=this,h=c.constructor,u=h.precision,f=h.rounding,m=5;if(r==null)r=new h(10),s=!0;else{if(r=new h(r),t=r.d,r.s<0||!t||!t[0]||r.eq(1))return new h(NaN);s=r.eq(10)}if(t=c.d,c.s<0||!t||!t[0]||c.eq(1))return new h(t&&!t[0]?-1/0:c.s!=1?NaN:t?0:1/0);if(s)if(t.length>1)n=!0;else{for(i=t[0];i%10===0;)i/=10;n=i!==1}if(S=!1,a=u+m,o=lt(c,a),e=s?se(h,a+10):lt(r,a),l=V(o,e,a,1),Tt(l.d,i=u,f))do if(a+=10,o=lt(c,a),e=s?se(h,a+10):lt(r,a),l=V(o,e,a,1),!n){+N(l.d).slice(i+1,i+15)+1==1e14&&(l=C(l,u+1,0));break}while(Tt(l.d,i+=10,f));return S=!0,C(l,u,f)};v.minus=v.sub=function(r){var s,t,e,i,n,o,a,l,c,h,u,f,m=this,p=m.constructor;if(r=new p(r),!m.d||!r.d)return!m.s||!r.s?r=new p(NaN):m.d?r.s=-r.s:r=new p(r.d||m.s!==r.s?m:NaN),r;if(m.s!=r.s)return r.s=-r.s,m.plus(r);if(c=m.d,f=r.d,a=p.precision,l=p.rounding,!c[0]||!f[0]){if(f[0])r.s=-r.s;else if(c[0])r=new p(m);else return new p(l===3?-0:0);return S?C(r,a,l):r}if(t=F(r.e/_),h=F(m.e/_),c=c.slice(),n=h-t,n){for(u=n<0,u?(s=c,n=-n,o=f.length):(s=f,t=h,o=c.length),e=Math.max(Math.ceil(a/_),o)+2,n>e&&(n=e,s.length=1),s.reverse(),e=n;e--;)s.push(0);s.reverse()}else{for(e=c.length,o=f.length,u=e<o,u&&(o=e),e=0;e<o;e++)if(c[e]!=f[e]){u=c[e]<f[e];break}n=0}for(u&&(s=c,c=f,f=s,r.s=-r.s),o=c.length,e=f.length-o;e>0;--e)c[o++]=0;for(e=f.length;e>n;){if(c[--e]<f[e]){for(i=e;i&&c[--i]===0;)c[i]=Q-1;--c[i],c[e]+=Q}c[e]-=f[e]}for(;c[--o]===0;)c.pop();for(;c[0]===0;c.shift())--t;return c[0]?(r.d=c,r.e=le(c,t),S?C(r,a,l):r):new p(l===3?-0:0)};v.modulo=v.mod=function(r){var s,t=this,e=t.constructor;return r=new e(r),!t.d||!r.s||r.d&&!r.d[0]?new e(NaN):!r.d||t.d&&!t.d[0]?C(new e(t),e.precision,e.rounding):(S=!1,e.modulo==9?(s=V(t,r.abs(),0,3,1),s.s*=r.s):s=V(t,r,0,e.modulo,1),s=s.times(r),S=!0,t.minus(s))};v.naturalExponential=v.exp=function(){return we(this)};v.naturalLogarithm=v.ln=function(){return lt(this)};v.negated=v.neg=function(){var r=new this.constructor(this);return r.s=-r.s,C(r)};v.plus=v.add=function(r){var s,t,e,i,n,o,a,l,c,h,u=this,f=u.constructor;if(r=new f(r),!u.d||!r.d)return!u.s||!r.s?r=new f(NaN):u.d||(r=new f(r.d||u.s===r.s?u:NaN)),r;if(u.s!=r.s)return r.s=-r.s,u.minus(r);if(c=u.d,h=r.d,a=f.precision,l=f.rounding,!c[0]||!h[0])return h[0]||(r=new f(u)),S?C(r,a,l):r;if(n=F(u.e/_),e=F(r.e/_),c=c.slice(),i=n-e,i){for(i<0?(t=c,i=-i,o=h.length):(t=h,e=n,o=c.length),n=Math.ceil(a/_),o=n>o?n+1:o+1,i>o&&(i=o,t.length=1),t.reverse();i--;)t.push(0);t.reverse()}for(o=c.length,i=h.length,o-i<0&&(i=o,t=h,h=c,c=t),s=0;i;)s=(c[--i]=c[i]+h[i]+s)/Q|0,c[i]%=Q;for(s&&(c.unshift(s),++e),o=c.length;c[--o]==0;)c.pop();return r.d=c,r.e=le(c,e),S?C(r,a,l):r};v.precision=v.sd=function(r){var s,t=this;if(r!==void 0&&r!==!!r&&r!==1&&r!==0)throw Error(ht+r);return t.d?(s=$e(t.d),r&&t.e+1>s&&(s=t.e+1)):s=NaN,s};v.round=function(){var r=this,s=r.constructor;return C(new s(r),r.e+1,s.rounding)};v.sine=v.sin=function(){var r,s,t=this,e=t.constructor;return t.isFinite()?t.isZero()?new e(t):(r=e.precision,s=e.rounding,e.precision=r+Math.max(t.e,t.sd())+_,e.rounding=1,t=Yi(e,Ke(e,t)),e.precision=r,e.rounding=s,C(nt>2?t.neg():t,r,s,!0)):new e(NaN)};v.squareRoot=v.sqrt=function(){var r,s,t,e,i,n,o=this,a=o.d,l=o.e,c=o.s,h=o.constructor;if(c!==1||!a||!a[0])return new h(!c||c<0&&(!a||a[0])?NaN:a?o:1/0);for(S=!1,c=Math.sqrt(+o),c==0||c==1/0?(s=N(a),(s.length+l)%2==0&&(s+="0"),c=Math.sqrt(s),l=F((l+1)/2)-(l<0||l%2),c==1/0?s="5e"+l:(s=c.toExponential(),s=s.slice(0,s.indexOf("e")+1)+l),e=new h(s)):e=new h(c.toString()),t=(l=h.precision)+3;;)if(n=e,e=n.plus(V(o,n,t+2,1)).times(.5),N(n.d).slice(0,t)===(s=N(e.d)).slice(0,t))if(s=s.slice(t-3,t+1),s=="9999"||!i&&s=="4999"){if(!i&&(C(n,l+1,0),n.times(n).eq(o))){e=n;break}t+=4,i=1}else{(!+s||!+s.slice(1)&&s.charAt(0)=="5")&&(C(e,l+1,1),r=!e.times(e).eq(o));break}return S=!0,C(e,l,h.rounding,r)};v.tangent=v.tan=function(){var r,s,t=this,e=t.constructor;return t.isFinite()?t.isZero()?new e(t):(r=e.precision,s=e.rounding,e.precision=r+10,e.rounding=1,t=t.sin(),t.s=1,t=V(t,new e(1).minus(t.times(t)).sqrt(),r+10,0),e.precision=r,e.rounding=s,C(nt==2||nt==4?t.neg():t,r,s,!0)):new e(NaN)};v.times=v.mul=function(r){var s,t,e,i,n,o,a,l,c,h=this,u=h.constructor,f=h.d,m=(r=new u(r)).d;if(r.s*=h.s,!f||!f[0]||!m||!m[0])return new u(!r.s||f&&!f[0]&&!m||m&&!m[0]&&!f?NaN:!f||!m?r.s/0:r.s*0);for(t=F(h.e/_)+F(r.e/_),l=f.length,c=m.length,l<c&&(n=f,f=m,m=n,o=l,l=c,c=o),n=[],o=l+c,e=o;e--;)n.push(0);for(e=c;--e>=0;){for(s=0,i=l+e;i>e;)a=n[i]+m[e]*f[i-e-1]+s,n[i--]=a%Q|0,s=a/Q|0;n[i]=(n[i]+s)%Q|0}for(;!n[--o];)n.pop();return s?++t:n.shift(),r.d=n,r.e=le(n,t),S?C(r,u.precision,u.rounding):r};v.toBinary=function(r,s){return Ce(this,2,r,s)};v.toDecimalPlaces=v.toDP=function(r,s){var t=this,e=t.constructor;return t=new e(t),r===void 0?t:(U(r,0,ut),s===void 0?s=e.rounding:U(s,0,8),C(t,r+t.e+1,s))};v.toExponential=function(r,s){var t,e=this,i=e.constructor;return r===void 0?t=et(e,!0):(U(r,0,ut),s===void 0?s=i.rounding:U(s,0,8),e=C(new i(e),r+1,s),t=et(e,!0,r+1)),e.isNeg()&&!e.isZero()?"-"+t:t};v.toFixed=function(r,s){var t,e,i=this,n=i.constructor;return r===void 0?t=et(i):(U(r,0,ut),s===void 0?s=n.rounding:U(s,0,8),e=C(new n(i),r+i.e+1,s),t=et(e,!1,r+e.e+1)),i.isNeg()&&!i.isZero()?"-"+t:t};v.toFraction=function(r){var s,t,e,i,n,o,a,l,c,h,u,f,m=this,p=m.d,g=m.constructor;if(!p)return new g(m);if(c=t=new g(1),e=l=new g(0),s=new g(e),n=s.e=$e(p)-m.e-1,o=n%_,s.d[0]=L(10,o<0?_+o:o),r==null)r=n>0?s:c;else{if(a=new g(r),!a.isInt()||a.lt(c))throw Error(ht+a);r=a.gt(s)?n>0?s:c:a}for(S=!1,a=new g(N(p)),h=g.precision,g.precision=n=p.length*_*2;u=V(a,s,0,1,1),i=t.plus(u.times(e)),i.cmp(r)!=1;)t=e,e=i,i=c,c=l.plus(u.times(i)),l=i,i=s,s=a.minus(u.times(i)),a=i;return i=V(r.minus(t),e,0,1,1),l=l.plus(i.times(c)),t=t.plus(i.times(e)),l.s=c.s=m.s,f=V(c,e,n,1).minus(m).abs().cmp(V(l,t,n,1).minus(m).abs())<1?[c,e]:[l,t],g.precision=h,S=!0,f};v.toHexadecimal=v.toHex=function(r,s){return Ce(this,16,r,s)};v.toNearest=function(r,s){var t=this,e=t.constructor;if(t=new e(t),r==null){if(!t.d)return t;r=new e(1),s=e.rounding}else{if(r=new e(r),s===void 0?s=e.rounding:U(s,0,8),!t.d)return r.s?t:r;if(!r.d)return r.s&&(r.s=t.s),r}return r.d[0]?(S=!1,t=V(t,r,0,s,1).times(r),S=!0,C(t)):(r.s=t.s,t=r),t};v.toNumber=function(){return+this};v.toOctal=function(r,s){return Ce(this,8,r,s)};v.toPower=v.pow=function(r){var s,t,e,i,n,o,a=this,l=a.constructor,c=+(r=new l(r));if(!a.d||!r.d||!a.d[0]||!r.d[0])return new l(L(+a,c));if(a=new l(a),a.eq(1))return a;if(e=l.precision,n=l.rounding,r.eq(1))return C(a,e,n);if(s=F(r.e/_),s>=r.d.length-1&&(t=c<0?-c:c)<=zi)return i=Ze(l,a,t,e),r.s<0?new l(1).div(i):C(i,e,n);if(o=a.s,o<0){if(s<r.d.length-1)return new l(NaN);if(r.d[s]&1||(o=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=o,a}return t=L(+a,c),s=t==0||!isFinite(t)?F(c*(Math.log("0."+N(a.d))/Math.LN10+a.e+1)):new l(t+"").e,s>l.maxE+1||s<l.minE-1?new l(s>0?o/0:0):(S=!1,l.rounding=a.s=1,t=Math.min(12,(s+"").length),i=we(r.times(lt(a,e+t)),e),i.d&&(i=C(i,e+5,1),Tt(i.d,e,n)&&(s=e+10,i=C(we(r.times(lt(a,s+t)),s),s+5,1),+N(i.d).slice(e+1,e+15)+1==1e14&&(i=C(i,e+1,0)))),i.s=o,S=!0,l.rounding=n,C(i,e,n))};v.toPrecision=function(r,s){var t,e=this,i=e.constructor;return r===void 0?t=et(e,e.e<=i.toExpNeg||e.e>=i.toExpPos):(U(r,1,ut),s===void 0?s=i.rounding:U(s,0,8),e=C(new i(e),r,s),t=et(e,r<=e.e||e.e<=i.toExpNeg,r)),e.isNeg()&&!e.isZero()?"-"+t:t};v.toSignificantDigits=v.toSD=function(r,s){var t=this,e=t.constructor;return r===void 0?(r=e.precision,s=e.rounding):(U(r,1,ut),s===void 0?s=e.rounding:U(s,0,8)),C(new e(t),r,s)};v.toString=function(){var r=this,s=r.constructor,t=et(r,r.e<=s.toExpNeg||r.e>=s.toExpPos);return r.isNeg()&&!r.isZero()?"-"+t:t};v.truncated=v.trunc=function(){return C(new this.constructor(this),this.e+1,1)};v.valueOf=v.toJSON=function(){var r=this,s=r.constructor,t=et(r,r.e<=s.toExpNeg||r.e>=s.toExpPos);return r.isNeg()?"-"+t:t};function N(r){var s,t,e,i=r.length-1,n="",o=r[0];if(i>0){for(n+=o,s=1;s<i;s++)e=r[s]+"",t=_-e.length,t&&(n+=at(t)),n+=e;o=r[s],e=o+"",t=_-e.length,t&&(n+=at(t))}else if(o===0)return"0";for(;o%10===0;)o/=10;return n+o}function U(r,s,t){if(r!==~~r||r<s||r>t)throw Error(ht+r)}function Tt(r,s,t,e){var i,n,o,a;for(n=r[0];n>=10;n/=10)--s;return--s<0?(s+=_,i=0):(i=Math.ceil((s+1)/_),s%=_),n=L(10,_-s),a=r[i]%n|0,e==null?s<3?(s==0?a=a/100|0:s==1&&(a=a/10|0),o=t<4&&a==99999||t>3&&a==49999||a==5e4||a==0):o=(t<4&&a+1==n||t>3&&a+1==n/2)&&(r[i+1]/n/100|0)==L(10,s-2)-1||(a==n/2||a==0)&&(r[i+1]/n/100|0)==0:s<4?(s==0?a=a/1e3|0:s==1?a=a/100|0:s==2&&(a=a/10|0),o=(e||t<4)&&a==9999||!e&&t>3&&a==4999):o=((e||t<4)&&a+1==n||!e&&t>3&&a+1==n/2)&&(r[i+1]/n/1e3|0)==L(10,s-3)-1,o}function Gt(r,s,t){for(var e,i=[0],n,o=0,a=r.length;o<a;){for(n=i.length;n--;)i[n]*=s;for(i[0]+=pe.indexOf(r.charAt(o++)),e=0;e<i.length;e++)i[e]>t-1&&(i[e+1]===void 0&&(i[e+1]=0),i[e+1]+=i[e]/t|0,i[e]%=t)}return i.reverse()}function Gi(r,s){var t,e,i;if(s.isZero())return s;e=s.d.length,e<32?(t=Math.ceil(e/3),i=(1/ce(4,t)).toString()):(t=16,i="2.3283064365386962890625e-10"),r.precision+=t,s=Dt(r,1,s.times(i),new r(1));for(var n=t;n--;){var o=s.times(s);s=o.times(o).minus(o).times(8).plus(1)}return r.precision-=t,s}var V=function(){function r(e,i,n){var o,a=0,l=e.length;for(e=e.slice();l--;)o=e[l]*i+a,e[l]=o%n|0,a=o/n|0;return a&&e.unshift(a),e}function s(e,i,n,o){var a,l;if(n!=o)l=n>o?1:-1;else for(a=l=0;a<n;a++)if(e[a]!=i[a]){l=e[a]>i[a]?1:-1;break}return l}function t(e,i,n,o){for(var a=0;n--;)e[n]-=a,a=e[n]<i[n]?1:0,e[n]=a*o+e[n]-i[n];for(;!e[0]&&e.length>1;)e.shift()}return function(e,i,n,o,a,l){var c,h,u,f,m,p,g,y,w,P,b,E,T,G,Nt,dt,ot,yt,X,Ht,Ft=e.constructor,he=e.s==i.s?1:-1,H=e.d,O=i.d;if(!H||!H[0]||!O||!O[0])return new Ft(!e.s||!i.s||(H?O&&H[0]==O[0]:!O)?NaN:H&&H[0]==0||!O?he*0:he/0);for(l?(m=1,h=e.e-i.e):(l=Q,m=_,h=F(e.e/m)-F(i.e/m)),X=O.length,ot=H.length,w=new Ft(he),P=w.d=[],u=0;O[u]==(H[u]||0);u++);if(O[u]>(H[u]||0)&&h--,n==null?(G=n=Ft.precision,o=Ft.rounding):a?G=n+(e.e-i.e)+1:G=n,G<0)P.push(1),p=!0;else{if(G=G/m+2|0,u=0,X==1){for(f=0,O=O[0],G++;(u<ot||f)&&G--;u++)Nt=f*l+(H[u]||0),P[u]=Nt/O|0,f=Nt%O|0;p=f||u<ot}else{for(f=l/(O[0]+1)|0,f>1&&(O=r(O,f,l),H=r(H,f,l),X=O.length,ot=H.length),dt=X,b=H.slice(0,X),E=b.length;E<X;)b[E++]=0;Ht=O.slice(),Ht.unshift(0),yt=O[0],O[1]>=l/2&&++yt;do f=0,c=s(O,b,X,E),c<0?(T=b[0],X!=E&&(T=T*l+(b[1]||0)),f=T/yt|0,f>1?(f>=l&&(f=l-1),g=r(O,f,l),y=g.length,E=b.length,c=s(g,b,y,E),c==1&&(f--,t(g,X<y?Ht:O,y,l))):(f==0&&(c=f=1),g=O.slice()),y=g.length,y<E&&g.unshift(0),t(b,g,E,l),c==-1&&(E=b.length,c=s(O,b,X,E),c<1&&(f++,t(b,X<E?Ht:O,E,l))),E=b.length):c===0&&(f++,b=[0]),P[u++]=f,c&&b[0]?b[E++]=H[dt]||0:(b=[H[dt]],E=1);while((dt++<ot||b[0]!==void 0)&&G--);p=b[0]!==void 0}P[0]||P.shift()}if(m==1)w.e=h,Xe=p;else{for(u=1,f=P[0];f>=10;f/=10)u++;w.e=u+h*m-1,C(w,a?n+w.e+1:n,o,p)}return w}}();function C(r,s,t,e){var i,n,o,a,l,c,h,u,f,m=r.constructor;t:if(s!=null){if(u=r.d,!u)return r;for(i=1,a=u[0];a>=10;a/=10)i++;if(n=s-i,n<0)n+=_,o=s,h=u[f=0],l=h/L(10,i-o-1)%10|0;else if(f=Math.ceil((n+1)/_),a=u.length,f>=a)if(e){for(;a++<=f;)u.push(0);h=l=0,i=1,n%=_,o=n-_+1}else break t;else{for(h=a=u[f],i=1;a>=10;a/=10)i++;n%=_,o=n-_+i,l=o<0?0:h/L(10,i-o-1)%10|0}if(e=e||s<0||u[f+1]!==void 0||(o<0?h:h%L(10,i-o-1)),c=t<4?(l||e)&&(t==0||t==(r.s<0?3:2)):l>5||l==5&&(t==4||e||t==6&&(n>0?o>0?h/L(10,i-o):0:u[f-1])%10&1||t==(r.s<0?8:7)),s<1||!u[0])return u.length=0,c?(s-=r.e+1,u[0]=L(10,(_-s%_)%_),r.e=-s||0):u[0]=r.e=0,r;if(n==0?(u.length=f,a=1,f--):(u.length=f+1,a=L(10,_-n),u[f]=o>0?(h/L(10,i-o)%L(10,o)|0)*a:0),c)for(;;)if(f==0){for(n=1,o=u[0];o>=10;o/=10)n++;for(o=u[0]+=a,a=1;o>=10;o/=10)a++;n!=a&&(r.e++,u[0]==Q&&(u[0]=1));break}else{if(u[f]+=a,u[f]!=Q)break;u[f--]=0,a=1}for(n=u.length;u[--n]===0;)u.pop()}return S&&(r.e>m.maxE?(r.d=null,r.e=NaN):r.e<m.minE&&(r.e=0,r.d=[0])),r}function et(r,s,t){if(!r.isFinite())return Je(r);var e,i=r.e,n=N(r.d),o=n.length;return s?(t&&(e=t-o)>0?n=n.charAt(0)+"."+n.slice(1)+at(e):o>1&&(n=n.charAt(0)+"."+n.slice(1)),n=n+(r.e<0?"e":"e+")+r.e):i<0?(n="0."+at(-i-1)+n,t&&(e=t-o)>0&&(n+=at(e))):i>=o?(n+=at(i+1-o),t&&(e=t-i-1)>0&&(n=n+"."+at(e))):((e=i+1)<o&&(n=n.slice(0,e)+"."+n.slice(e)),t&&(e=t-o)>0&&(i+1===o&&(n+="."),n+=at(e))),n}function le(r,s){var t=r[0];for(s*=_;t>=10;t/=10)s++;return s}function se(r,s,t){if(s>Ui)throw S=!0,t&&(r.precision=t),Error(Ye);return C(new r(ee),s,1,!0)}function tt(r,s,t){if(s>ye)throw Error(Ye);return C(new r(ie),s,t,!0)}function $e(r){var s=r.length-1,t=s*_+1;if(s=r[s],s){for(;s%10==0;s/=10)t--;for(s=r[0];s>=10;s/=10)t++}return t}function at(r){for(var s="";r--;)s+="0";return s}function Ze(r,s,t,e){var i,n=new r(1),o=Math.ceil(e/_+4);for(S=!1;;){if(t%2&&(n=n.times(s),Ve(n.d,o)&&(i=!0)),t=F(t/2),t===0){t=n.d.length-1,i&&n.d[t]===0&&++n.d[t];break}s=s.times(s),Ve(s.d,o)}return S=!0,n}function ke(r){return r.d[r.d.length-1]&1}function Qe(r,s,t){for(var e,i,n=new r(s[0]),o=0;++o<s.length;){if(i=new r(s[o]),!i.s){n=i;break}e=n.cmp(i),(e===t||e===0&&n.s===t)&&(n=i)}return n}function we(r,s){var t,e,i,n,o,a,l,c=0,h=0,u=0,f=r.constructor,m=f.rounding,p=f.precision;if(!r.d||!r.d[0]||r.e>17)return new f(r.d?r.d[0]?r.s<0?0:1/0:1:r.s?r.s<0?0:r:NaN);for(s==null?(S=!1,l=p):l=s,a=new f(.03125);r.e>-2;)r=r.times(a),u+=5;for(e=Math.log(L(2,u))/Math.LN10*2+5|0,l+=e,t=n=o=new f(1),f.precision=l;;){if(n=C(n.times(r),l,1),t=t.times(++h),a=o.plus(V(n,t,l,1)),N(a.d).slice(0,l)===N(o.d).slice(0,l)){for(i=u;i--;)o=C(o.times(o),l,1);if(s==null)if(c<3&&Tt(o.d,l-e,m,c))f.precision=l+=10,t=n=a=new f(1),h=0,c++;else return C(o,f.precision=p,m,S=!0);else return f.precision=p,o}o=a}}function lt(r,s){var t,e,i,n,o,a,l,c,h,u,f,m=1,p=10,g=r,y=g.d,w=g.constructor,P=w.rounding,b=w.precision;if(g.s<0||!y||!y[0]||!g.e&&y[0]==1&&y.length==1)return new w(y&&!y[0]?-1/0:g.s!=1?NaN:y?0:g);if(s==null?(S=!1,h=b):h=s,w.precision=h+=p,t=N(y),e=t.charAt(0),Math.abs(n=g.e)<15e14){for(;e<7&&e!=1||e==1&&t.charAt(1)>3;)g=g.times(r),t=N(g.d),e=t.charAt(0),m++;n=g.e,e>1?(g=new w("0."+t),n++):g=new w(e+"."+t.slice(1))}else return c=se(w,h+2,b).times(n+""),g=lt(new w(e+"."+t.slice(1)),h-p).plus(c),w.precision=b,s==null?C(g,b,P,S=!0):g;for(u=g,l=o=g=V(g.minus(1),g.plus(1),h,1),f=C(g.times(g),h,1),i=3;;){if(o=C(o.times(f),h,1),c=l.plus(V(o,new w(i),h,1)),N(c.d).slice(0,h)===N(l.d).slice(0,h))if(l=l.times(2),n!==0&&(l=l.plus(se(w,h+2,b).times(n+""))),l=V(l,new w(m),h,1),s==null)if(Tt(l.d,h-p,P,a))w.precision=h+=p,c=o=g=V(u.minus(1),u.plus(1),h,1),f=C(g.times(g),h,1),i=a=1;else return C(l,w.precision=b,P,S=!0);else return w.precision=b,l;l=c,i+=2}}function Je(r){return String(r.s*r.s/0)}function Xt(r,s){var t,e,i;for((t=s.indexOf("."))>-1&&(s=s.replace(".","")),(e=s.search(/e/i))>0?(t<0&&(t=e),t+=+s.slice(e+1),s=s.substring(0,e)):t<0&&(t=s.length),e=0;s.charCodeAt(e)===48;e++);for(i=s.length;s.charCodeAt(i-1)===48;--i);if(s=s.slice(e,i),s){if(i-=e,r.e=t=t-e-1,r.d=[],e=(t+1)%_,t<0&&(e+=_),e<i){for(e&&r.d.push(+s.slice(0,e)),i-=_;e<i;)r.d.push(+s.slice(e,e+=_));s=s.slice(e),e=_-s.length}else e-=i;for(;e--;)s+="0";r.d.push(+s),S&&(r.e>r.constructor.maxE?(r.d=null,r.e=NaN):r.e<r.constructor.minE&&(r.e=0,r.d=[0]))}else r.e=0,r.d=[0];return r}function Xi(r,s){var t,e,i,n,o,a,l,c,h;if(s.indexOf("_")>-1){if(s=s.replace(/(\d)_(?=\d)/g,"$1"),qe.test(s))return Xt(r,s)}else if(s==="Infinity"||s==="NaN")return+s||(r.s=NaN),r.e=NaN,r.d=null,r;if(Fi.test(s))t=16,s=s.toLowerCase();else if(Hi.test(s))t=2;else if(Bi.test(s))t=8;else throw Error(ht+s);for(n=s.search(/p/i),n>0?(l=+s.slice(n+1),s=s.substring(2,n)):s=s.slice(2),n=s.indexOf("."),o=n>=0,e=r.constructor,o&&(s=s.replace(".",""),a=s.length,n=a-n,i=Ze(e,new e(t),n,n*2)),c=Gt(s,t,Q),h=c.length-1,n=h;c[n]===0;--n)c.pop();return n<0?new e(r.s*0):(r.e=le(c,h),r.d=c,S=!1,o&&(r=V(r,i,a*4)),l&&(r=r.times(Math.abs(l)<54?L(2,l):R.pow(2,l))),S=!0,r)}function Yi(r,s){var t,e=s.d.length;if(e<3)return s.isZero()?s:Dt(r,2,s,s);t=1.4*Math.sqrt(e),t=t>16?16:t|0,s=s.times(1/ce(5,t)),s=Dt(r,2,s,s);for(var i,n=new r(5),o=new r(16),a=new r(20);t--;)i=s.times(s),s=s.times(n.plus(i.times(o.times(i).minus(a))));return s}function Dt(r,s,t,e,i){var n,o,a,l,c=r.precision,h=Math.ceil(c/_);for(S=!1,l=t.times(t),a=new r(e);;){if(o=V(a.times(l),new r(s++*s++),c,1),a=i?e.plus(o):e.minus(o),e=V(o.times(l),new r(s++*s++),c,1),o=a.plus(e),o.d[h]!==void 0){for(n=h;o.d[n]===a.d[n]&&n--;);if(n==-1)break}n=a,a=e,e=o,o=n}return S=!0,o.d.length=h+1,o}function ce(r,s){for(var t=r;--s;)t*=r;return t}function Ke(r,s){var t,e=s.s<0,i=tt(r,r.precision,1),n=i.times(.5);if(s=s.abs(),s.lte(n))return nt=e?4:1,s;if(t=s.divToInt(i),t.isZero())nt=e?3:2;else{if(s=s.minus(t.times(i)),s.lte(n))return nt=ke(t)?e?2:3:e?4:1,s;nt=ke(t)?e?1:4:e?3:2}return s.minus(i).abs()}function Ce(r,s,t,e){var i,n,o,a,l,c,h,u,f,m=r.constructor,p=t!==void 0;if(p?(U(t,1,ut),e===void 0?e=m.rounding:U(e,0,8)):(t=m.precision,e=m.rounding),!r.isFinite())h=Je(r);else{for(h=et(r),o=h.indexOf("."),p?(i=2,s==16?t=t*4-3:s==8&&(t=t*3-2)):i=s,o>=0&&(h=h.replace(".",""),f=new m(1),f.e=h.length-o,f.d=Gt(et(f),10,i),f.e=f.d.length),u=Gt(h,10,i),n=l=u.length;u[--l]==0;)u.pop();if(!u[0])h=p?"0p+0":"0";else{if(o<0?n--:(r=new m(r),r.d=u,r.e=n,r=V(r,f,t,e,0,i),u=r.d,n=r.e,c=Xe),o=u[t],a=i/2,c=c||u[t+1]!==void 0,c=e<4?(o!==void 0||c)&&(e===0||e===(r.s<0?3:2)):o>a||o===a&&(e===4||c||e===6&&u[t-1]&1||e===(r.s<0?8:7)),u.length=t,c)for(;++u[--t]>i-1;)u[t]=0,t||(++n,u.unshift(1));for(l=u.length;!u[l-1];--l);for(o=0,h="";o<l;o++)h+=pe.charAt(u[o]);if(p){if(l>1)if(s==16||s==8){for(o=s==16?4:3,--l;l%o;l++)h+="0";for(u=Gt(h,i,s),l=u.length;!u[l-1];--l);for(o=1,h="1.";o<l;o++)h+=pe.charAt(u[o])}else h=h.charAt(0)+"."+h.slice(1);h=h+(n<0?"p":"p+")+n}else if(n<0){for(;++n;)h="0"+h;h="0."+h}else if(++n>l)for(n-=l;n--;)h+="0";else n<l&&(h=h.slice(0,n)+"."+h.slice(n))}h=(s==16?"0x":s==2?"0b":s==8?"0o":"")+h}return r.s<0?"-"+h:h}function Ve(r,s){if(r.length>s)return r.length=s,!0}function Wi(r){return new this(r).abs()}function ji(r){return new this(r).acos()}function qi(r){return new this(r).acosh()}function $i(r,s){return new this(r).plus(s)}function Zi(r){return new this(r).asin()}function Qi(r){return new this(r).asinh()}function Ji(r){return new this(r).atan()}function Ki(r){return new this(r).atanh()}function ts(r,s){r=new this(r),s=new this(s);var t,e=this.precision,i=this.rounding,n=e+4;return!r.s||!s.s?t=new this(NaN):!r.d&&!s.d?(t=tt(this,n,1).times(s.s>0?.25:.75),t.s=r.s):!s.d||r.isZero()?(t=s.s<0?tt(this,e,i):new this(0),t.s=r.s):!r.d||s.isZero()?(t=tt(this,n,1).times(.5),t.s=r.s):s.s<0?(this.precision=n,this.rounding=1,t=this.atan(V(r,s,n,1)),s=tt(this,n,1),this.precision=e,this.rounding=i,t=r.s<0?t.minus(s):t.plus(s)):t=this.atan(V(r,s,n,1)),t}function es(r){return new this(r).cbrt()}function is(r){return C(r=new this(r),r.e+1,2)}function ss(r,s,t){return new this(r).clamp(s,t)}function ns(r){if(!r||typeof r!="object")throw Error(ae+"Object expected");var s,t,e,i=r.defaults===!0,n=["precision",1,ut,"rounding",0,8,"toExpNeg",-9e15,0,"toExpPos",0,ge,"maxE",0,ge,"minE",-9e15,0,"modulo",0,9];for(s=0;s<n.length;s+=3)if(t=n[s],i&&(this[t]=ve[t]),(e=r[t])!==void 0)if(F(e)===e&&e>=n[s+1]&&e<=n[s+2])this[t]=e;else throw Error(ht+t+": "+e);if(t="crypto",i&&(this[t]=ve[t]),(e=r[t])!==void 0)if(e===!0||e===!1||e===0||e===1)if(e)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(We);else this[t]=!1;else throw Error(ht+t+": "+e);return this}function rs(r){return new this(r).cos()}function os(r){return new this(r).cosh()}function ti(r){var s,t,e;function i(n){var o,a,l,c=this;if(!(c instanceof i))return new i(n);if(c.constructor=i,Oe(n)){c.s=n.s,S?!n.d||n.e>i.maxE?(c.e=NaN,c.d=null):n.e<i.minE?(c.e=0,c.d=[0]):(c.e=n.e,c.d=n.d.slice()):(c.e=n.e,c.d=n.d?n.d.slice():n.d);return}if(l=typeof n,l==="number"){if(n===0){c.s=1/n<0?-1:1,c.e=0,c.d=[0];return}if(n<0?(n=-n,c.s=-1):c.s=1,n===~~n&&n<1e7){for(o=0,a=n;a>=10;a/=10)o++;S?o>i.maxE?(c.e=NaN,c.d=null):o<i.minE?(c.e=0,c.d=[0]):(c.e=o,c.d=[n]):(c.e=o,c.d=[n]);return}if(n*0!==0){n||(c.s=NaN),c.e=NaN,c.d=null;return}return Xt(c,n.toString())}if(l==="string")return(a=n.charCodeAt(0))===45?(n=n.slice(1),c.s=-1):(a===43&&(n=n.slice(1)),c.s=1),qe.test(n)?Xt(c,n):Xi(c,n);if(l==="bigint")return n<0?(n=-n,c.s=-1):c.s=1,Xt(c,n.toString());throw Error(ht+n)}if(i.prototype=v,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=ns,i.clone=ti,i.isDecimal=Oe,i.abs=Wi,i.acos=ji,i.acosh=qi,i.add=$i,i.asin=Zi,i.asinh=Qi,i.atan=Ji,i.atanh=Ki,i.atan2=ts,i.cbrt=es,i.ceil=is,i.clamp=ss,i.cos=rs,i.cosh=os,i.div=as,i.exp=ls,i.floor=cs,i.hypot=hs,i.ln=us,i.log=ds,i.log10=ms,i.log2=fs,i.max=gs,i.min=ps,i.mod=vs,i.mul=ys,i.pow=ws,i.random=xs,i.round=Ps,i.sign=bs,i.sin=Cs,i.sinh=_s,i.sqrt=Ss,i.sub=Es,i.sum=Ms,i.tan=Ds,i.tanh=Rs,i.trunc=ks,r===void 0&&(r={}),r&&r.defaults!==!0)for(e=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],s=0;s<e.length;)r.hasOwnProperty(t=e[s++])||(r[t]=this[t]);return i.config(r),i}function as(r,s){return new this(r).div(s)}function ls(r){return new this(r).exp()}function cs(r){return C(r=new this(r),r.e+1,3)}function hs(){var r,s,t=new this(0);for(S=!1,r=0;r<arguments.length;)if(s=new this(arguments[r++]),s.d)t.d&&(t=t.plus(s.times(s)));else{if(s.s)return S=!0,new this(1/0);t=s}return S=!0,t.sqrt()}function Oe(r){return r instanceof R||r&&r.toStringTag===je||!1}function us(r){return new this(r).ln()}function ds(r,s){return new this(r).log(s)}function fs(r){return new this(r).log(2)}function ms(r){return new this(r).log(10)}function gs(){return Qe(this,arguments,-1)}function ps(){return Qe(this,arguments,1)}function vs(r,s){return new this(r).mod(s)}function ys(r,s){return new this(r).mul(s)}function ws(r,s){return new this(r).pow(s)}function xs(r){var s,t,e,i,n=0,o=new this(1),a=[];if(r===void 0?r=this.precision:U(r,1,ut),e=Math.ceil(r/_),this.crypto)if(crypto.getRandomValues)for(s=crypto.getRandomValues(new Uint32Array(e));n<e;)i=s[n],i>=429e7?s[n]=crypto.getRandomValues(new Uint32Array(1))[0]:a[n++]=i%1e7;else if(crypto.randomBytes){for(s=crypto.randomBytes(e*=4);n<e;)i=s[n]+(s[n+1]<<8)+(s[n+2]<<16)+((s[n+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(s,n):(a.push(i%1e7),n+=4);n=e/4}else throw Error(We);else for(;n<e;)a[n++]=Math.random()*1e7|0;for(e=a[--n],r%=_,e&&r&&(i=L(10,_-r),a[n]=(e/i|0)*i);a[n]===0;n--)a.pop();if(n<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=_)a.shift();for(e=1,i=a[0];i>=10;i/=10)e++;e<_&&(t-=_-e)}return o.e=t,o.d=a,o}function Ps(r){return C(r=new this(r),r.e+1,this.rounding)}function bs(r){return r=new this(r),r.d?r.d[0]?r.s:0*r.s:r.s||NaN}function Cs(r){return new this(r).sin()}function _s(r){return new this(r).sinh()}function Ss(r){return new this(r).sqrt()}function Es(r,s){return new this(r).sub(s)}function Ms(){var r=0,s=arguments,t=new this(s[r]);for(S=!1;t.s&&++r<s.length;)t=t.plus(s[r]);return S=!0,C(t,this.precision,this.rounding)}function Ds(r){return new this(r).tan()}function Rs(r){return new this(r).tanh()}function ks(r){return C(r=new this(r),r.e+1,1)}v[Symbol.for("nodejs.util.inspect.custom")]=v.toString;v[Symbol.toStringTag]="Decimal";var R=v.constructor=ti(ve);ee=new R(ee);ie=new R(ie);class Vs{constructor(){d(this,"parent");d(this,"name","");d(this,"extData");d(this,"mainCanvas");d(this,"_isRecalculate",!1);d(this,"notifyReload")}get isRecalculate(){return(this.parent?this.parent.isRecalculate:!1)||this._isRecalculate}set isRecalculate(s){this._isRecalculate=s}equalsMainCanvas(s){return this.mainCanvas===s}setMainCanvas(s){this.mainCanvas=s}}class Os extends Vs{constructor(){super(...arguments);d(this,"_isVisible",!0);d(this,"inheritOpacity",!0);d(this,"_opacity");d(this,"_scaleRange")}get isVisible(){return this._isVisible}set isVisible(t){var e;t!=this.isVisible&&(this._isVisible=t,(e=this.notifyReload)==null||e.call(this,!0))}get opacity(){var t;return this.inheritOpacity?this._opacity??((t=this.parent)==null?void 0:t.opacity):this._opacity}set opacity(t){var e;this._opacity!=t&&(t===void 0||t>=0&&t<=1?(this._opacity=t,(e=this.notifyReload)==null||e.call(this,!1)):console.warn("Opacity value should be between 0 and 1."))}get scaleRange(){return this._scaleRange}set scaleRange(t){var e;t!=this.scaleRange&&(this._scaleRange=t,this.isVisible&&((e=this.notifyReload)==null||e.call(this)))}shouldRender(){var e;if(!this.isVisible||this.opacity===0)return!1;const t=(e=this.mainCanvas)==null?void 0:e.scale;if(this.scaleRange&&t){const i=Math.min(...this.scaleRange),n=Math.max(...this.scaleRange);return t>=i&&t<=n}return!0}}let Ts=class extends Os{constructor(s){super(),s.name=s.name||te("default-name-"),Object.assign(this,{...s})}};class As extends Ts{constructor(t){super(t);d(this,"_isInteractive",!0);d(this,"_isHoverable",!0);d(this,"_isDownable",!0);d(this,"_isContextmenuable",!0);d(this,"_isClickable",!0);d(this,"_isDoubleClickable",!0);d(this,"_isDraggable",!0);d(this,"_isWheelable",!0);Object.assign(this,{...t})}get isInteractive(){return this.getPropValue("isInteractive",this._isInteractive,!1)}set isInteractive(t){this._isInteractive=t}get isHoverable(){return this.getPropValue("isHoverable",this._isHoverable)}set isHoverable(t){this._isHoverable=t}get isDownable(){return this.getPropValue("isDownable",this._isDownable)}set isDownable(t){this._isDownable=t}get isContextmenuable(){return this.getPropValue("isContextmenuable",this._isContextmenuable)}set isContextmenuable(t){this._isContextmenuable=t}get isClickable(){return this.getPropValue("isClickable",this._isClickable)}set isClickable(t){this._isClickable=t}get isDoubleClickable(){return this.getPropValue("isDoubleClickable",this._isDoubleClickable)}set isDoubleClickable(t){this._isDoubleClickable=t}get isDraggable(){return this.getPropValue("isDraggable",this._isDraggable)}set isDraggable(t){this._isDraggable=t}get isWheelable(){return this.getPropValue("isWheelable",this._isWheelable)}set isWheelable(t){this._isWheelable=t}getPropValue(t,e,i=!0){return(this.parent?this.parent[t]:!0)&&e&&(i?this.isInteractive:!0)}}class Is{constructor(s){d(this,"propagationStopped",!1);this.data=s}stopPropagation(){this.propagationStopped=!0}get canPropagate(){return!this.propagationStopped}}class It extends As{constructor(){super(...arguments);d(this,"listeners",{wheel:new Set,hover:new Set,down:new Set,contextmenu:new Set,click:new Set,doubleClick:new Set,dragg:new Set});d(this,"sharedControllers",{});d(this,"_eventDate",{});d(this,"_clearEventDate",!1);d(this,"_isHover",!1);d(this,"notifyHover",(t,e)=>this.checkEventDate("hover",t)&&this.trigger("hover",{state:t,oldState:this.isHover},e,"isHoverable"));d(this,"_isDown",!1);d(this,"notifyDown",(t,e)=>this.checkEventDate("down",t)&&this.trigger("down",{state:t,oldState:this.isDown},e,"isDownable"));d(this,"_isContextmenu",!1);d(this,"notifyContextmenu",(t,e)=>this.checkEventDate("contextmenu",t)&&this.trigger("contextmenu",{state:t,oldState:this.isContextmenu},e,"isContextmenuable"));d(this,"_isClick",!1);d(this,"clickTimestamp",0);d(this,"doubleClickInterval",300);d(this,"notifyClick",(t,e)=>{if(!this.checkEventDate("click",t))return;let i=!1;t?(i=Date.now()-this.clickTimestamp<this.doubleClickInterval,this.clickTimestamp=i?0:Date.now()):(this._isDblClick=!1,this.clickTimestamp=0),i?this.notifyDoubleClick(i,e):this.trigger("click",{state:t,oldState:this.isClick},e,"isClickable")});d(this,"_isDblClick",!1);d(this,"notifyDoubleClick",(t,e)=>this.checkEventDate("doubleClick",t)&&this.trigger("doubleClick",{state:t,oldState:this.isDblClick},e,"isDoubleClickable"));d(this,"notifyDragg",(t,e)=>this.checkEventDate("dragg",t)&&this.trigger("dragg",t,e,"isDraggable"));d(this,"notifyWheel",(t,e)=>this.checkEventDate("wheel",t)&&this.trigger("wheel",t,e,"isWheelable"))}addEventListener(t,e){this.listeners[t].add(e)}removeEventListener(t,e){this.listeners[t].delete(e)}registerControllers(t,e){this.sharedControllers[t]=e}hasController(t,e){var i;return(i=this.sharedControllers[t])==null?void 0:i.includes(e)}trigger(t,e,i,n){var c,h;if(!this[n])return;this.updateStates(t,e);const o=new Is(e);this.listeners[t].forEach(u=>u(o,i));const a="notify"+(t.charAt(0).toUpperCase()+t.slice(1)),l=["notifyDragg","notifyWheel"].includes(a)?e:e.state;o.canPropagate&&((c=this.parent)==null||c[a](l,i)),(h=this.sharedControllers[t])==null||h.forEach(u=>u!==this&&u[a](l,i))}updateStates(t,e){const i=e;switch(t){case"hover":this._isHover=i.state;break;case"down":this._isDown=i.state;break;case"contextmenu":this._isContextmenu=i.state;break;case"click":this._isClick=i.state;break;case"doubleClick":this._isDblClick=i.state;break}}checkEventDate(t,e){const i=this._eventDate[t],n=JSON.stringify(e);return i==n?!1:(this._eventDate[t]=n,this._clearEventDate||(this._clearEventDate=!0,Promise.resolve().then(()=>{this._clearEventDate=!1,this._eventDate={}})),!0)}get isHover(){return this.isHoverable&&this._isHover}get isDown(){return this.isDraggable&&this._isDown}get isContextmenu(){return this.isClickable&&this._isContextmenu}get isClick(){return this.isClickable&&this._isClick}get isDblClick(){return this.isDoubleClickable&&this._isDblClick}}class Ls extends It{constructor(t){super(t);d(this,"canvas");d(this,"ctx");d(this,"_rectValueIsUpdated",!1);d(this,"_rect");d(this,"offset",{x:0,y:0});d(this,"center",{x:0,y:0});d(this,"defaultCenter",{top:void 0,bottom:void 0,left:void 0,right:void 0});d(this,"accuracy",5);d(this,"scale",1);d(this,"defaultScale",1);d(this,"percentage",1);d(this,"axisConfig",{count:2,min:100,size:100,x:1,y:1});d(this,"cycle",10);d(this,"delta",.02);d(this,"_redrawInNextRenderFrame",!1);d(this,"isAuto",!1);d(this,"isRendering",!1);d(this,"drawAxis");d(this,"layerGroups",new Map);d(this,"isScaleUpdated",!1);d(this,"nowGridCount");const{id:e,axisConfig:i,defaultCenter:n,offset:o,defaultScale:a}=t,l=document.getElementById(e);if(l instanceof HTMLCanvasElement)if(l.getContext){this.canvas=l,this.ctx=l.getContext("2d");const{clientWidth:c,clientHeight:h}=l;[l.width,l.height]=[c,h]}else throw new Error("canvas-unsupported code here");else throw new Error("canvas is not HTMLCanvasElement");i&&this.setAxis(i),o&&(this.offset.x=o.x||0,this.offset.y=o.y||0),n&&this.setDefaultCenter(n),a&&(this.updateCenter(),this.setScale("center",a-1),this.defaultScale=a)}get rect(){return this._rectValueIsUpdated&&this._rect?this._rect:(this._rectValueIsUpdated=!0,Promise.resolve().then(()=>this._rectValueIsUpdated=!1),this._rect=this.canvas.getBoundingClientRect(),this._rect)}get redrawInNextRenderFrame(){return this._redrawInNextRenderFrame}set redrawInNextRenderFrame(t){this._redrawInNextRenderFrame=t}setNotifyReload(t){this.notifyReload=t}getDefaultCenterLocation(){const{canvas:t,rect:e,defaultCenter:i}=this;if(!t)return console.error("canvas is not HTMLCanvasElement");const{width:n,height:o}=e,{top:a,bottom:l,left:c,right:h}=i,u={vertical:(g,y)=>{if([0,"0","0%"].includes(g))return 0;if(!(g==1/0||g==-1/0))return typeof g=="number"?g:["top","left"].includes(g)?0:["bottom","right"].includes(g)?y:["middle","center"].includes(g)?y/2:/^(-?\d+)%$/.test(g)?(g=g.match(/^(-?\d+)%$/)[1],y*Number(g)/100):Number(g)||void 0},reverse:(g,y)=>{if([0,"0","0%"].includes(g))return y;if(g==1/0||g==-1/0)return;if(typeof g=="number")return y-g;const w=u.vertical(g,y);return w?y-w:void 0}},f=(g,y,w)=>{if(g!==void 0){const P=u.vertical(g,w);if(P!==void 0)return P}if(y!==void 0){const P=u.reverse(y,w);if(P!==void 0)return P}return w/2},m=f(a,l,o);return{x:f(c,h,n),y:m}}updateCenter(){const t=this.getDefaultCenterLocation();if(!t)return;const{x:e,y:i}=t;this.center={x:Math.floor(e+this.offset.x),y:Math.floor(i+this.offset.y)}}updateSize(){const{scale:t,axisConfig:e}=this;e.size=this.getGridSize(t),this.percentage=this.getAxisPointByValue(e.count,0).x/e.min}setScale(t,e){const{canvas:i,isWheelable:n,axisConfig:o,rect:a}=this;if(!n||!i)return console.error("canvas is not HTMLCanvasElement");let l,c;t==="center"?(l=a.left+a.width/2,c=a.top+a.height/2):[l,c]=[t.clientX,t.clientY];const h=this.getMousePositionOnAxis({clientX:l,clientY:c}),u=this.getAxisValueByPoint(h.x,h.y);this.scale=new R(this.scale).add(e).toNumber(),this.isScaleUpdated=!0,this.updateSize();const f=this.getAxisPointByValue(u.xV,u.yV);this.offset.x-=(f.x-h.x)*o.x,this.offset.y-=(f.y-h.y)*o.y,this.offset.x=Number(this.offset.x.toFixed(0)),this.offset.y=Number(this.offset.y.toFixed(0))}setAxis(t){const e={...this.axisConfig,...t},i=Object.fromEntries(Object.entries(e).map(([g,y])=>[g,Number(y)])),{x:n,y:o,count:a,min:l,size:c}=i,h=[1,-1].includes(n),u=[1,-1].includes(o),f=a>0,m=l>0,p=c>=l&&c<=l*2;if(!h||!u||!f||!m){console.warn("Invalid axis configuration:",{x:n,y:o,count:a,min:l});return}p||(i.size=l),this.axisConfig=i}setDefaultCenter(t){Object.assign(this.defaultCenter,t),this.updateCenter()}getGridSize(t){const{cycle:e,delta:i,axisConfig:n}=this;let o=new R(t).sub(1).abs().mod(e*i).div(i).toNumber();return o=t<1&&o!=0?e-o:o,Number(((o/e+1)*n.min).toFixed(0))}getGridCount(t){const{axisConfig:e,cycle:i,delta:n}=this,o=e.count,a=i*n;if(t===1)return o;if(t>1){const l=new R(t).sub(1).div(a).floor();return new R(o).div(new R(2).pow(l)).toNumber()}else{const l=new R(1).sub(t).div(a).ceil();return new R(o).mul(new R(2).pow(l)).toNumber()}}get getNowGridCount(){const{scale:t,nowGridCount:e,isRendering:i}=this;return e&&i?e:(this.nowGridCount=this.getGridCount(t),i&&Promise.resolve().then(()=>this.nowGridCount=void 0),this.nowGridCount)}getMousePositionOnAxis(t){const{canvas:e,center:i,rect:n,axisConfig:o}=this;if(!e)return console.error("canvas is not HTMLCanvasElement");const{clientX:a,clientY:l}=t,{left:c,top:h}=n,u=(a-c-i.x)*o.x,f=(l-h-i.y)*o.y;return{x:u,y:f}}getAxisValueByPoint(t,e,i){const{axisConfig:n}=this;if(i)return{xV:t/n.min*n.count,yV:e/n.min*n.count};const o=this.getNowGridCount,a=new R(t).div(n.size).mul(o).toFixed(8),l=new R(e).div(n.size).mul(o).toFixed(8);return{xV:Number(a),yV:Number(l)}}getAxisPointByValue(t,e,i){const{axisConfig:n}=this;if(i)return{x:t/n.count*n.min,y:e/n.count*n.min};const o=this.getNowGridCount,a=new R(t).div(o).mul(n.size).toFixed(3),l=new R(e).div(o).mul(n.size).toFixed(3);return{x:Number(a),y:Number(l)}}getMaxMinValue(t){t=t||this.rect;const{left:e,top:i,right:n,bottom:o}=t,{axisConfig:a}=this,{x:l,y:c}=this.getMousePositionOnAxis({clientX:a.x==1?e:n,clientY:a.y==1?i:o}),{xV:h,yV:u}=this.getAxisValueByPoint(l,c),{x:f,y:m}=this.getMousePositionOnAxis({clientX:a.x==1?n:e,clientY:a.y==1?o:i}),{xV:p,yV:g}=this.getAxisValueByPoint(f,m);return{minXV:h,maxXV:p,minYV:u,maxYV:g}}transformPosition(t){const{center:e,percentage:i,axisConfig:n}=this,o=i*n.x,a=i*n.y,l=c=>[e.x+c[0]*o,e.y+c[1]*a];return Array.isArray(t[0])?t.map(c=>l(c)):l(t)}}class Ns extends Ls{constructor(t){super(t);d(this,"theme","light");d(this,"isThemeUpdated",!1);d(this,"style",{light:{background:"#fff",text:{color:"#222",secondary:"#909399",stroke:"#fff",size:12,family:"monospace",bold:!0},grid:{axis:"#222",grid:"#666",innerGrid:"#e5e5e5"},point:{radius:5,fill:"#d03050",width:14,stroke:"#d0305080"},line:{stroke:{color:"#f0a020",color_hover:"#f2c97d",width:4,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#f0a02080",width:14,fill:"#f0a020"}},arc:{fill:"#f0a02030",fill_hover:"#f2c97d60",stroke:{color:"#f0a020",color_hover:"#f2c97d",width:4,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#f0a02080",width:14,fill:"#f0a020"}},arcTo:{stroke:{color:"#f0a020",color_hover:"#f2c97d",width:4,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#f0a02080",width:14,fill:"#f0a020"}},polygon:{fill:"#18a05830",fill_hover:"#03693360",stroke:{color:"#18a058",color_hover:"#036933",width:1,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#03693380",width:14,fill:"#036933"}},billboard:{stroke:{color:"#d03050",color_hover:"#d03050",width:4,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"}}},dark:{background:"#000",text:{color:"#aeaeae",secondary:"#8c8c8c",stroke:"#000",size:12,family:"monospace",bold:!0},grid:{axis:"#aeaeae",grid:"#666",innerGrid:"#454545"},point:{radius:5,fill:"#e88080",width:14,stroke:"#e8808070"},line:{stroke:{color:"#f2c97d",color_hover:"#f0a020",width:4,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#f2c97d80",width:14,fill:"#f2c97d"}},arc:{fill:"#f2c97d30",fill_hover:"#f0a02060",stroke:{color:"#f2c97d",color_hover:"#f0a020",width:4,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#f2c97d80",width:14,fill:"#f2c97d"}},arcTo:{stroke:{color:"#f2c97d",color_hover:"#f0a020",width:4,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#f2c97d80",width:14,fill:"#f2c97d"}},polygon:{fill:"#63e2b730",fill_hover:"#7efbd160",stroke:{color:"#63e2b7",color_hover:"#63e2b7",width:1,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#7efbd180",width:14,fill:"#7efbd1"}},billboard:{stroke:{color:"#e88080",color_hover:"#e88080",width:4,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"}}}});const{theme:e}=t;e&&this.setTheme(e),this.initStyle(),this.clearScreen()}initStyle(){const{canvas:t,ctx:e,theme:i}=this;t.classList.add("_nhanh_canvas");const n=this.style[i];e.font=`${n.text.bold?"bold":""} ${n.text.size}px ${n.text.family}`}clearScreen(t=!0){const{ctx:e,theme:i,rect:n}=this,{width:o,height:a}=n;e.clearRect(0,0,o,a),t&&this.style[i].background&&(e.fillStyle=this.style[i].background,e.fillRect(0,0,o,a))}setStyle(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)){const i=Ue(this.style[e]||this.style[this.theme]);rt(i,t[e]),this.style[e]=i}this.initStyle()}setTheme(t){t in this.style&&(this.theme=t,this.isThemeUpdated=!0)}}class D extends It{constructor(t){t={...t},t.isDraggable=t.isDraggable??!1;const{mainCanvas:e,notifyReload:i}=t;delete t.mainCanvas,delete t.notifyReload;super(t);d(this,"_style");d(this,"_position");d(this,"_value");d(this,"_zIndex",0);d(this,"_dynamicPosition");d(this,"_offset",{x:0,y:0});d(this,"path");d(this,"publicToPrivateKeyMap",{offset:"_offset",position:"_position",value:"_value",dynamicPosition:"_dynamicPosition",zIndex:"_zIndex",style:"_style"});d(this,"redrawOnIsHoverChange",!0);d(this,"defaultHover",(t,e)=>{var i;this.redrawOnIsHoverChange&&((i=this.notifyReload)==null||i.call(this))});d(this,"_valueScope");d(this,"styleRadius",{value:0,radius:0});d(this,"offsetValue",{xV:0,yV:0});d(this,"fixedExtraScope",{topV:0,bottomV:0,leftV:0,rightV:0});d(this,"extraScope",{top:0,bottom:0,left:0,right:0,topV:0,bottomV:0,leftV:0,rightV:0});this.setNotifyReload(i),this.mainCanvas=e,["redrawOnIsHoverChange"].forEach(o=>{o in t&&(this[o]=t[o])});const n={};["offset","style","zIndex","position","dynamicPosition","value"].forEach(o=>{o in t&&(n[o]=t[o])}),this.internalUpdate(n),this.addEventListener("hover",this.defaultHover)}get style(){return this._style}set style(t){var e;this._style=t,this.mainCanvas&&(this.updateValueScope(),(e=this.notifyReload)==null||e.call(this))}get position(){return this._position}set position(t){var e;this._position=t,this._value=void 0,this.updateBaseData(),(e=this.notifyReload)==null||e.call(this)}get value(){return this._value}set value(t){var e;this._value=t,this._position=void 0,this.updateBaseData(),(e=this.notifyReload)==null||e.call(this)}get zIndex(){return this._zIndex}set zIndex(t){var e;this._zIndex!=t&&(this._zIndex=t,(e=this.notifyReload)==null||e.call(this))}get dynamicPosition(){return this._dynamicPosition}set dynamicPosition(t){this._dynamicPosition=t}get offset(){return this._offset}set offset(t){var e;this._offset=t,this.calculateOffsetValue(),(e=this.notifyReload)==null||e.call(this)}get finalDynamicPosition(){var i;const{x:t,y:e}=this.offset;return(i=this.dynamicPosition)==null?void 0:i.map((n,o)=>typeof n=="number"?o==0?n+t:n+e:[n[0]+t,n[1]+e])}internalUpdate(t,e){Object.keys(t).forEach(i=>{const n=this.publicToPrivateKeyMap[i];n&&(this[n]=t[i])}),e&&this.updateValueScope()}setMainCanvas(t){super.setMainCanvas(t),t&&this.updateBaseData()}setNotifyReload(t){this.notifyReload=t?e=>{var i;e&&(this.isRecalculate=!0),(e||this.isNeedRender||(i=this.mainCanvas)!=null&&i.currentDrawOverlays.includes(this))&&t()}:void 0}get valueScope(){return this._valueScope}set valueScope(t){this._valueScope=t}initValueScope(){const t=this.value;if(Array.isArray(t[0])){let e=1/0,i=-1/0,n=1/0,o=-1/0;t.forEach(([a,l])=>{e=Math.min(e,a),i=Math.max(i,a),n=Math.min(n,l),o=Math.max(o,l)}),this.valueScope={minX:e,maxX:i,minY:n,maxY:o}}else{const[e,i]=t;this.valueScope={minX:e,maxX:e,minY:i,maxY:i}}this.calculateStyleRadiusValue(!1),this.calculateOffsetValue(!1),this.setFixedExtraScope(!0),this.setExtraScope(!0)}calculateStyleRadiusValue(t=!0){if(!(!this.mainCanvas||!this.valueScope))if(t){const{radius:e,value:i}=this.styleRadius;if(e==0)return;const n=this.mainCanvas.getAxisValueByPoint(e,0).xV,o=n-i;this.valueScope.minX-=o,this.valueScope.maxX+=o,this.valueScope.minY-=o,this.valueScope.maxY+=o,this.styleRadius={radius:e,value:n}}else{const{stroke:e,point:i}=this.computedValueScopeStyles,n=i?i.radius+Math.max(0,i.width/2):0,o=e?Math.max(0,e.width/2):0,a=Math.max(n,o);if(a==0)return this.styleRadius={radius:0,value:0};const l=this.mainCanvas.getAxisValueByPoint(a,0).xV;this.valueScope.minX-=l,this.valueScope.maxX+=l,this.valueScope.minY-=l,this.valueScope.maxY+=l,this.styleRadius={radius:a,value:l}}}calculateOffsetValue(t=!0){const{mainCanvas:e,valueScope:i,offset:n,offsetValue:o}=this;if(!(!e||!i))if(t){const{x:a,y:l}=e.axisConfig;let{xV:c,yV:h}=e.getAxisValueByPoint(n.x,n.y);c*=a,h*=l;const u=c-o.xV,f=h-o.yV;i.minX+=u,i.maxX+=u,i.minY+=f,i.maxY+=f,this.offsetValue={xV:c,yV:h}}else{if(this.offsetValue={xV:0,yV:0},n.x==0&&n.y==0)return;this.calculateOffsetValue()}}setFixedExtraScope(t){if(t===!0)this.fixedExtraScope={topV:0,bottomV:0,leftV:0,rightV:0};else{const e=t||{topV:0,bottomV:0,leftV:0,rightV:0};if(this.valueScope){const{leftV:i,rightV:n,topV:o,bottomV:a}=e;this.valueScope.minX-=i-this.fixedExtraScope.leftV,this.valueScope.maxX+=n-this.fixedExtraScope.rightV,this.valueScope.minY-=o-this.fixedExtraScope.topV,this.valueScope.maxY+=a-this.fixedExtraScope.bottomV,this.fixedExtraScope=e}}}setExtraScope(t){const{valueScope:e,mainCanvas:i,extraScope:n}=this;if(!(!e||!i))if(t===!0)this.extraScope={top:0,bottom:0,left:0,right:0,topV:0,bottomV:0,leftV:0,rightV:0};else if(t){const{left:o,right:a,top:l,bottom:c}=t,{xV:h,yV:u}=i.getAxisValueByPoint(l,c),{xV:f,yV:m}=i.getAxisValueByPoint(o,a);e.minX-=f-n.leftV,e.maxX+=m-n.rightV,e.minY-=h-n.topV,e.maxY+=u-n.bottomV,this.extraScope={...t,topV:h,bottomV:u,leftV:f,rightV:m}}else this.setExtraScope(this.extraScope)}get isWithinRange(){const{mainCanvas:t,valueScope:e}=this;if(!t)return!1;const{isScaleUpdated:i,maxMinValue:n}=t;return i&&(this.calculateStyleRadiusValue(),this.calculateOffsetValue(),this.setExtraScope()),e?!(n.maxXV<e.minX||n.minXV>e.maxX||n.maxYV<e.minY||n.minYV>e.maxY):!0}get isNeedRender(){return!!(this.mainCanvas&&this.shouldRender()&&this.dynamicPosition&&this.isWithinRange)}calculateOffset(t,e){const{percentage:i,axisConfig:n}=this.mainCanvas,o=n.count/n.min/i,a={value:t*o*n.x,position:t/i*n.x,dynamicPosition:t},l={value:e*o*n.y,position:e/i*n.y,dynamicPosition:e};return{x:a,y:l}}handleValuePosition(t,e){let{value:i,position:n,mainCanvas:o}=this;if(!o)return!1;const a=t==="array1D"?oe:Ot,[l,c]=[a(i)&&(!e||i.length>=e),a(n)&&(!e||n.length>=e)],h={value:i,position:n,dynamicPosition:[]};if(!l&&!c)return this.internalUpdate({dynamicPosition:void 0}),!1;if(l){const u=i;if(t==="array1D"){const f=o.getAxisPointByValue(u[0],u[1],!0);h.position=[f.x,f.y]}else{h.position=[];for(let f=0;f<u.length;f++){const m=u[f],p=o.getAxisPointByValue(m[0],m[1],!0);h.position.push([p.x,p.y])}}}else{const u=n;if(t==="array1D"){const f=o.getAxisValueByPoint(u[0],u[1],!0);h.value=[f.xV,f.yV]}else{h.value=[];for(let f=0;f<u.length;f++){const m=u[f],p=o.getAxisValueByPoint(m[0],m[1],!0);h.value.push([p.xV,p.yV])}}}return h.dynamicPosition=o.transformPosition(h.position),this.internalUpdate(h,!0),!0}isPointInAnywhere(t,e){return this.isPointInPath(t,e)||this.isPointInStroke(t,e)}setGlobalAlpha(t){var i;const e=this.opacity??((i=this.parent)==null?void 0:i.opacity);e!==void 0&&(t.globalAlpha=e)}setBaseLineStyle(t,e){const{width:i,dash:n,dashGap:o,dashOffset:a,color:l,color_hover:c,cap:h,join:u}=e;return t.setLineDash(n?o:[]),t.lineDashOffset=a,t.lineCap=h,t.lineJoin=u,t.lineWidth=i,t.strokeStyle=this.isHover?c:l,e}get cursorStyle(){return this.isInteractive?this.isDraggable?"_nhanh_canvas_hover_overlay_draggable":"_nhanh_canvas_hover_overlay":void 0}}d(D,"ctx",document.createElement("canvas").getContext("2d"));class Yt extends D{constructor(t){super(t);d(this,"_draw");this.redrawOnIsHoverChange=!1;const{draw:e}=t;Object.assign(this,{draw:e})}updateValueScope(){this.initValueScope()}isPointInPath(t,e){return!1}isPointInStroke(t,e){return!1}updateBaseData(){if(!this.mainCanvas)return;this.internalUpdate({dynamicPosition:[]});let t=this.value,e=this.position;t?e=this.convertValuesToPositions(t):e&&(t=this.convertPositionsToValues(e)),t&&e&&this.updateDataProperties(t,e)}convertValuesToPositions(t){const e=[];let i;return t.forEach(n=>{if(i===void 0){const o=this.mainCanvas.getAxisPointByValue(n[0],n[1],!0);e.push([o.x,o.y]),n[0]!=0?i=new R(o.x).div(n[0]).toNumber():n[1]!=0&&(i=new R(o.y).div(n[1]).toNumber())}else e.push([new R(i).mul(n[0]).toNumber(),new R(i).mul(n[1]).toNumber()])}),e}convertPositionsToValues(t){const e=[];let i;return t.forEach((n,o)=>{if(i===void 0){const a=this.mainCanvas.getAxisValueByPoint(n[0],n[1],!0);e.push([a.xV,a.yV]),n[0]!=0?i=new R(a.xV).div(n[0]).toNumber():n[1]!=0&&(i=new R(a.yV).div(n[1]).toNumber())}else e.push([new R(i).mul(n[0]).toNumber(),new R(i).mul(n[1]).toNumber()])}),e}updateDataProperties(t,e){this.internalUpdate({value:t,position:e,dynamicPosition:this.mainCanvas.transformPosition(e)})}setOverlayStyles(t){}get computedValueScopeStyles(){return{}}get draw(){return t=>{var e;this.setGlobalAlpha(t),(e=this._draw)==null||e.call(this,t)}}set draw(t){this._draw=t}getDraw(){if(this.isNeedRender){const{mainCanvas:t,position:e}=this;return this.isRecalculate&&e&&this.internalUpdate({dynamicPosition:t.transformPosition(e)}),[this.draw,this]}}}class k{static add(s,t){return new R(s).add(t).toNumber()}static sub(s,t){return new R(s).sub(t).toNumber()}static mul(s,t){return new R(s).mul(t).toNumber()}static div(s,t){return new R(s).div(t).toNumber()}}class Wt extends D{constructor(t){super(t);d(this,"textOffset",{x:0,y:0});d(this,"_text");d(this,"defaultDragg",(t,e)=>{var l;const{offsetX:i,offsetY:n}=t.data,{x:o,y:a}=this.calculateOffset(i,n);this.internalUpdate({value:[k.add(this.value[0],o.value),k.add(this.value[1],a.value)],position:[k.add(this.position[0],o.position),k.add(this.position[1],a.position)],dynamicPosition:[k.add(this.dynamicPosition[0],o.dynamicPosition),k.add(this.dynamicPosition[1],a.dynamicPosition)]},!0),(l=this.notifyReload)==null||l.call(this)});const{text:e}=t;Object.assign(this,{text:e}),this.addEventListener("dragg",this.defaultDragg)}get text(){return this._text}set text(t){var e;this._text!=t&&(this._text=t,this.updateBaseData(),(e=this.notifyReload)==null||e.call(this))}updateValueScope(){this.initValueScope();const t=this.textOffset;this.setExtraScope({top:t.y,bottom:t.y,left:t.x,right:t.x})}isPointInPath(t,e){return this.path?D.ctx.isPointInPath(this.path,t,e):!1}isPointInStroke(t,e){return!1}updateBaseData(){if(!this.mainCanvas)return;if(!this.text||this.text.length==0)return this.internalUpdate({dynamicPosition:void 0});const t=D.ctx;this.setOverlayStyles(t);const e=t.measureText(this.text);this.textOffset={x:e.width/2,y:e.actualBoundingBoxAscent/2},this.handleValuePosition("array1D")}setOverlayStyles(t){var o;const e=this.mainCanvas,i=e.style[e.theme].text;let n={};return typeof this.style=="string"?n=((o=e.style[this.style])==null?void 0:o.text)||i:typeof this.style=="object"?n=Object.assign({},i,this.style):n=i,t.font=`${n.bold?"bold":""} ${n.size}px ${n.family}`,t.lineWidth=2,t.strokeStyle=n.stroke,t.fillStyle=n[this.isHover?"secondary":"color"],n}get computedValueScopeStyles(){return{}}draw(t){const{text:e,textOffset:i,finalDynamicPosition:n}=this;if(!this.mainCanvas||!e)return;this.setGlobalAlpha(t),this.setOverlayStyles(t);const o=n[0]-i.x,a=n[1]+i.y;t.strokeText(e,o,a),t.fillText(e,o,a),this.path=new Path2D,this.path.rect(o,n[1]-i.y,i.x*2,i.y*2)}getDraw(){if(this.isNeedRender){if(this.isRecalculate){const{position:t,mainCanvas:e}=this;this.internalUpdate({dynamicPosition:e.transformPosition(t)})}return[this.draw,this]}}}class ct extends D{constructor(t){super(t);d(this,"angle",2*Math.PI);d(this,"defaultDragg",(t,e)=>{var l;const{offsetX:i,offsetY:n}=t.data,{x:o,y:a}=this.calculateOffset(i,n);this.internalUpdate({value:[k.add(this.value[0],o.value),k.add(this.value[1],a.value)],position:[k.add(this.position[0],o.position),k.add(this.position[1],a.position)],dynamicPosition:[k.add(this.dynamicPosition[0],o.dynamicPosition),k.add(this.dynamicPosition[1],a.dynamicPosition)]},!0),(l=this.notifyReload)==null||l.call(this)});d(this,"fillProgress");d(this,"defaultHover",(t,e)=>{const i=t.data.state,n=300,o=this.setOverlayStyles().width;this.fillProgress?this.cancelAndRestartAnimation(i,o,n-100):i&&this.startNewHoverAnimation(o,n)});this.addEventListener("hover",this.defaultHover),this.addEventListener("dragg",this.defaultDragg)}updateValueScope(){this.initValueScope()}cancelAndRestartAnimation(t,e,i){this.fillProgress.scheduleCallback();let n=0;this.fillProgress.scheduleCallback=Vt(o=>{!this.fillProgress||!o||(this.fillProgress.progress+=(o-n)*(t?1:-1),n=o,this.fillProgress.progress=Math.min(1,Math.max(0,this.fillProgress.progress)),this.updateLineWidthOffset(e),(this.fillProgress.progress===1||this.fillProgress.progress===0)&&(this.fillProgress.scheduleCallback(),this.fillProgress.progress===0&&(this.fillProgress=void 0)))},i)}startNewHoverAnimation(t,e){this.fillProgress={lineWidthOffset:0,progress:0,scheduleCallback:Vt(i=>{this.fillProgress&&(this.fillProgress.progress=i,this.updateLineWidthOffset(t))},e)}}updateLineWidthOffset(t){var i;if(!this.fillProgress)return;const e=Math.ceil(t*this.fillProgress.progress);e!==this.fillProgress.lineWidthOffset&&(this.fillProgress.lineWidthOffset=e,(i=this.notifyReload)==null||i.call(this))}isPointInPath(t,e){return this.path?D.ctx.isPointInPath(this.path,t,e):!1}isPointInStroke(t,e){var i;if(this.path&&this.mainCanvas){const{width:n}=this.setOverlayStyles(D.ctx);return((i=this.fillProgress)==null?void 0:i.lineWidthOffset)==n?!1:D.ctx.isPointInStroke(this.path,t,e)}return!1}updateBaseData(){this.handleValuePosition("array1D")}setOverlayStyles(t){var c,h;const e=this.mainCanvas,i=e.style[e.theme].point;let n={};typeof this.style=="string"?n=((c=e.style[this.style])==null?void 0:c.point)||i:typeof this.style=="object"?n=Object.assign({},i,this.style):n=i;const{width:o,stroke:a,fill:l}=n;if(t){t.setLineDash([]);const u=((h=this.fillProgress)==null?void 0:h.lineWidthOffset)||0;t.lineWidth=o-u,t.strokeStyle=a,t.fillStyle=l}return{...n}}get computedValueScopeStyles(){return{point:this.setOverlayStyles()}}draw(t){var h;const{finalDynamicPosition:e,mainCanvas:i}=this;if(!i)return;this.setGlobalAlpha(t);const{radius:n,width:o}=this.setOverlayStyles(t),a=((h=this.fillProgress)==null?void 0:h.lineWidthOffset)||0,[l,c]=e;t.beginPath(),this.path=new Path2D,this.path.arc(l,c,n+a/2,0,this.angle),o!=a&&t.stroke(this.path),t.fill(this.path)}getDraw(){if(this.isNeedRender){const{mainCanvas:t,position:e}=this;return this.isRecalculate&&this.internalUpdate({dynamicPosition:t.transformPosition(e)}),[this.draw,this]}}}class ei extends D{constructor(t){super(t);d(this,"handlePoints",[]);d(this,"isShowHandlePoint",!1);d(this,"_isHandlePointsVisible",!0);d(this,"canCreateOrDeleteHandlePoint",!0);d(this,"lockedCanCreateOrDeleteHandlePoint",!1);d(this,"defaultClick",(t,e)=>{var o;if(!this.isHandlePointsVisible)return;const{state:i,oldState:n}=t.data;i!=n&&!this.isInfinite&&((o=this.notifyReload)==null||o.call(this))});d(this,"defaultDoubleClick",(t,e)=>{if(e){if(!this.isHandlePointsVisible)return;const{offsetX:i,offsetY:n}=e,{state:o}=t.data;if(this.lockedCanCreateOrDeleteHandlePoint)this.resetHandlePointLock();else if(o&&this.isHandlePointsVisible&&this.canCreateOrDeleteHandlePoint&&this.isDraggable){const l=this.handlePoints.findIndex(c=>c.isHover);l===-1?this.tryCreateNewHandlePoint(i,n):this.tryDeleteHandlePoint(l)}}});d(this,"defaultDragg",(t,e)=>{var n;if(!this.mainCanvas)return;const i=()=>{const{offsetX:o,offsetY:a}=t.data,{x:l,y:c}=this.calculateOffset(o,a);this.value.forEach((h,u)=>{this.value[u]=[k.add(this.value[u][0],l.value),k.add(this.value[u][1],c.value)],this.position[u]=[k.add(this.position[u][0],l.position),k.add(this.position[u][1],c.position)],this.dynamicPosition[u]=[k.add(this.dynamicPosition[u][0],l.dynamicPosition),k.add(this.dynamicPosition[u][1],c.dynamicPosition)]}),this.handlePoints.forEach((h,u)=>{h.internalUpdate({value:this.value[u],position:this.position[u],dynamicPosition:this.dynamicPosition[u]})}),this.lockedCanCreateOrDeleteHandlePoint=!0};if(this.isHandlePointsVisible){const o=this.handlePoints.findIndex(a=>a.isHover);if(o!=-1){const a=this.handlePoints[o];a.notifyDragg(t.data,e),this.value[o]=a.value,this.position[o]=a.position,this.dynamicPosition[o]=a.dynamicPosition}else i()}else i();(n=this.notifyReload)==null||n.call(this),this.updateValueScope()});["isHandlePointsVisible","canCreateOrDeleteHandlePoint"].forEach(e=>{e in t&&(this[e]=t[e])}),this.addEventListener("click",this.defaultClick),this.addEventListener("doubleClick",this.defaultDoubleClick),this.addEventListener("dragg",this.defaultDragg)}get isHandlePointsVisible(){return this._isHandlePointsVisible}set isHandlePointsVisible(t){var e;this._isHandlePointsVisible!==t&&(this._isHandlePointsVisible=t,this.isShowHandlePoint!=t&&((e=this.notifyReload)==null||e.call(this)),this.updateHandlePoints())}get offset(){return super.offset}set offset(t){super.offset=t;let{isHandlePointsVisible:e,handlePoints:i}=this;e&&i.forEach(n=>n.internalUpdate({offset:t}))}tryCreateNewHandlePoint(t,e){var c;if(!this.isPointInStroke(t,e))return;const i=this.getExtendedDynamicPositions(),n=Hs([t,e],i);if(n===-1)return;const[o,a]=this.getAdjacentIndices(n),l=this.createNewHandlePoint(o,a);this.insertHandlePoint(n,l),this.lockHandlePointCreationTemporarily(),(c=this.notifyReload)==null||c.call(this)}tryDeleteHandlePoint(t){var e;!this.isDblClick||!this.canDeleteHandlePoint||(this.deleteHandlePoint(t),(e=this.notifyReload)==null||e.call(this))}getExtendedDynamicPositions(){return this.isClosed?[...this.dynamicPosition,this.dynamicPosition[0]]:this.dynamicPosition}getAdjacentIndices(t){const e=t-1,i=this.isClosed&&t===this.dynamicPosition.length?0:t;return[e,i]}createNewHandlePoint(t,e){const i=ue(this.value[t],this.value[e]),n=ue(this.position[t],this.position[e]),o=ue(this.dynamicPosition[t],this.dynamicPosition[e]);return new ct({value:i,position:n,dynamicPosition:o,isDraggable:!0,mainCanvas:this.mainCanvas,notifyReload:()=>{var a;return(a=this.notifyReload)==null?void 0:a.call(this)}})}insertHandlePoint(t,e){this.handlePoints.splice(t,0,e),this.value.splice(t,0,e.value),this.position.splice(t,0,e.position),this.dynamicPosition.splice(t,0,e.dynamicPosition)}deleteHandlePoint(t){this.handlePoints.splice(t,1),this.value.splice(t,1),this.position.splice(t,1),this.dynamicPosition.splice(t,1)}lockHandlePointCreationTemporarily(){this.lockedCanCreateOrDeleteHandlePoint=!0,setTimeout(()=>{this.lockedCanCreateOrDeleteHandlePoint=!1},300)}resetHandlePointLock(){this.lockedCanCreateOrDeleteHandlePoint=!1}get canDeleteHandlePoint(){return this.handlePoints.length>this.minNeededHandlePoints}updateHandlePoints(){let{value:t,position:e,dynamicPosition:i,offset:n,isHandlePointsVisible:o}=this;!i||!o||(t==null||t.forEach((a,l)=>{if(!this.handlePoints[l]){const c=new ct({value:[0,0],mainCanvas:this.mainCanvas,isDraggable:!0,offset:n,notifyReload:()=>{var h;return(h=this.notifyReload)==null?void 0:h.call(this)}});this.handlePoints.push(c)}this.handlePoints[l].internalUpdate({value:t[l],position:e[l],dynamicPosition:i[l]},!0)}),this.handlePoints.length=t.length)}updateHandlePointsPosition(){this.isHandlePointsVisible&&this.handlePoints.forEach((t,e)=>{t.internalUpdate({dynamicPosition:this.dynamicPosition[e]})})}}function Hs(r,s,t=10){if(s.length===0)return 0;if(s.length===1)return 1;let e=1/0,i=-1;for(let n=0;n<s.length-1;n++){const o=si(r,s[n],s[n+1]);if(o<t)return n+1;o<e&&(e=o,i=n+1)}return i}function ue(r,s){const{x:t,y:e}=Ee(...r,...s);return[t,e]}class jt extends ei{constructor(t){super(t);d(this,"_isInfinite");d(this,"isClosed",!1);d(this,"minNeededHandlePoints",2);const{isInfinite:e}=t;Object.assign(this,{isInfinite:e}),e&&(this.canCreateOrDeleteHandlePoint=!1)}get isInfinite(){return this._isInfinite}set isInfinite(t){var e;this._isInfinite!=t&&(this._isInfinite=t,this.canCreateOrDeleteHandlePoint=!t,(e=this.notifyReload)==null||e.call(this))}updateValueScope(){this.initValueScope()}isPointInPath(t,e){return!1}isPointInStroke(t,e){return this.path&&this.mainCanvas?(this.setOverlayStyles(D.ctx),this.isDraggable&&(D.ctx.lineWidth=Math.max(D.ctx.lineWidth,20)),D.ctx.isPointInStroke(this.path,t,e)):!1}isPointInAnywhere(t,e){return(n=>{if(!n)return!1;let o=!1;return[...this.handlePoints].sort((l,c)=>(l.isHover?0:1)-(c.isHover?0:1)).forEach(l=>{o?l.isHover&&l.notifyHover(!1):(o=l.isPointInAnywhere(t,e),o!=l.isHover&&l.notifyHover(o))}),o})((this.isClick||!!this.isInfinite)&&this.isShowHandlePoint)||super.isPointInAnywhere(t,e)}get isWithinRange(){if(this.isInfinite){this.isRecalculate&&this.updateDynamicPosition();const{width:t,height:e}=this.mainCanvas.rect;return Fs([0,0],[t,e],this.finalDynamicPosition[0],this.finalDynamicPosition[1])}return super.isWithinRange}updateBaseData(){this.handleValuePosition("array2D",2)&&this.updateHandlePoints()}updateDynamicPosition(){const{mainCanvas:t,position:e}=this,i=t.transformPosition(e);this.internalUpdate({dynamicPosition:i}),this.updateHandlePointsPosition()}setOverlayStyles(t){var o;const e=this.mainCanvas,i=e.style[e.theme].line;let n={};return typeof this.style=="string"?n=((o=e.style[this.style])==null?void 0:o.line)||i:typeof this.style=="object"?n=rt(JSON.parse(JSON.stringify(i)),this.style):n=i,t&&this.setBaseLineStyle(t,n.stroke),n}get computedValueScopeStyles(){return this.setOverlayStyles()}drawLine(t,e){const{mainCanvas:i,isInfinite:n,isClick:o}=this;if(e=e||this.finalDynamicPosition,!i)return;this.setGlobalAlpha(t);const a=this.setOverlayStyles(t);t.beginPath(),this.path=new Path2D,e.forEach((l,c)=>{this.path[c==0?"moveTo":"lineTo"](l[0],l[1])}),t.stroke(this.path),this.isShowHandlePoint=(n||o)&&this.isHandlePointsVisible,this.isShowHandlePoint&&this.handlePoints.forEach(l=>{var c;l.style=a.point,(c=l.getDraw())==null||c[0].call(l,t)})}drawisInfiniteStraightLine(t){const{mainCanvas:e,finalDynamicPosition:i}=this;if(!e)return;this.setGlobalAlpha(t);const{rect:n}=e,[o,a]=i,l=[a[0]-o[0],a[1]-o[1]];if(l[0]===0&&l[1]===0)return console.error("重合点无法确定方向");const c=Te(o,[-l[0],-l[1]],n.width,n.height),h=Te(a,l,n.width,n.height);this.drawLine(t,[c,h])}getDraw(){if(this.isNeedRender){const{isRecalculate:t,isInfinite:e}=this;return t&&this.updateDynamicPosition(),e?[this.drawisInfiniteStraightLine,this]:[this.drawLine,this]}}}function Te(r,s,t,e){const[i,n]=r,[o,a]=s;let l=1/0;if(o!==0){const c=o>0?(t-i)/o:-i/o;c>0&&(l=Math.min(l,c))}if(a!==0){const c=a>0?(e-n)/a:-n/a;c>0&&(l=Math.min(l,c))}return l===1/0?r:[i+o*l,n+a*l]}function Fs(r,s,t,e){const i=Math.min(r[0],s[0]),n=Math.max(r[0],s[0]),o=Math.min(r[1],s[1]),a=Math.max(r[1],s[1]),l=[[i,o],[n,o],[n,a],[i,a]],c=e[1]-t[1],h=t[0]-e[0],u=e[0]*t[1]-t[0]*e[1];if(c===0&&h===0){const[g,y]=t;return g>=i&&g<=n&&y>=o&&y<=a}const f=1e-10;let m=!1,p=!1;for(const[g,y]of l){const w=c*g+h*y+u;if(Math.abs(w)<f||(w>f?m=!0:p=!0,m&&p))return!0}return m&&p}class qt extends ei{constructor(t){super(t);d(this,"_isRect",!1);d(this,"dynamicBorderRadius");d(this,"_borderRadius");d(this,"_borderRadiusType","position");d(this,"isClosed",!0);d(this,"minNeededHandlePoints",3);["isRect","borderRadius","borderRadiusType"].forEach(e=>{e in t&&(this[e]=t[e])}),t.isRect&&(this.canCreateOrDeleteHandlePoint=!1)}get isRect(){return this._isRect}set isRect(t){var e;this._isRect!=t&&(this._isRect=t,this.canCreateOrDeleteHandlePoint=!t,this.updateBaseData(),(e=this.notifyReload)==null||e.call(this))}get borderRadius(){return this._borderRadius}set borderRadius(t){var e;this._borderRadius!=t&&(this._borderRadius=t,this.updateDynamicRadius(),(e=this.notifyReload)==null||e.call(this))}get borderRadiusType(){return this._borderRadiusType}set borderRadiusType(t){var e;this._borderRadiusType!=t&&(this._borderRadiusType=t,this.updateDynamicRadius(),(e=this.notifyReload)==null||e.call(this))}updateValueScope(){this.initValueScope()}isPointInPath(t,e){return this.path?D.ctx.isPointInPath(this.path,t,e):!1}isPointInStroke(t,e){return this.path&&this.mainCanvas?(this.setOverlayStyles(D.ctx),this.isDraggable&&(D.ctx.lineWidth=Math.max(D.ctx.lineWidth,20)),D.ctx.isPointInStroke(this.path,t,e)):!1}isPointInAnywhere(t,e){return(n=>{if(!n)return!1;let o=!1;return[...this.handlePoints].sort((l,c)=>(l.isHover?0:1)-(c.isHover?0:1)).forEach(l=>{o?l.isHover&&l.notifyHover(!1):(o=l.isPointInAnywhere(t,e),o!=l.isHover&&l.notifyHover(o))}),o})(this.isClick&&this.isShowHandlePoint)||super.isPointInAnywhere(t,e)}updateDynamicRadius(){const{mainCanvas:t,borderRadius:e}=this;if(!t||!e){this.dynamicBorderRadius=void 0;return}if(typeof e=="number"){this.dynamicBorderRadius=this.handleSingleRadius(e);return}this.dynamicBorderRadius=e.map(i=>this.handleSingleRadius(i,!0))}handleSingleRadius(t,e){const{mainCanvas:i,borderRadiusType:n}=this;if(t<=0)return e?0:void 0;switch(n){case"position":return t*i.percentage;default:return i.getAxisPointByValue(t,0).x}}updateBaseData(){if(!this.mainCanvas)return;let{value:t,position:e,isRect:i}=this;const n=i?2:3;i&&(Array.isArray(t)&&(t.length=2),Array.isArray(e)&&(e.length=2)),this.handleValuePosition("array2D",n)&&(this.updateHandlePoints(),this.updateDynamicRadius())}setOverlayStyles(t){var c;const e=this.isHover,i=this.mainCanvas,n=i.style[i.theme].polygon;let o={};typeof this.style=="string"?o=((c=i.style[this.style])==null?void 0:c.polygon)||n:typeof this.style=="object"?o=rt(JSON.parse(JSON.stringify(n)),this.style):o=n;const{fill:a,fill_hover:l}=o;return t&&(this.setBaseLineStyle(t,o.stroke),t.fillStyle=e?l:a),o}get computedValueScopeStyles(){return this.setOverlayStyles()}drawRect(t){this.setGlobalAlpha(t);const[[e,i],[n,o]]=this.finalDynamicPosition,a=Math.abs(n-e),l=Math.abs(o-i),c=Math.min(e,n),h=Math.min(i,o),u=this.setOverlayStyles(t);t.beginPath(),this.path=new Path2D,this.dynamicBorderRadius?this.path.roundRect(c,h,a,l,this.dynamicBorderRadius):this.path.rect(c,h,a,l),t.stroke(this.path),t.fill(this.path),this.isShowHandlePoint=this.isClick&&this.isHandlePointsVisible,this.isShowHandlePoint&&this.handlePoints.forEach(f=>{var m;f.internalUpdate({style:u.point}),(m=f.getDraw())==null||m[0].call(f,t)})}drawPolygon(t){this.setGlobalAlpha(t);const e=this.finalDynamicPosition,i=this.setOverlayStyles(t);t.beginPath(),this.path=new Path2D,e.forEach((n,o)=>{this.path[o==0?"moveTo":"lineTo"](n[0],n[1])}),this.path.closePath(),t.stroke(this.path),t.fill(this.path),this.isShowHandlePoint=this.isClick&&this.isHandlePointsVisible,this.isShowHandlePoint&&this.handlePoints.forEach(n=>{var o;n.internalUpdate({style:i.point}),(o=n.getDraw())==null||o[0].call(n,t)})}getDraw(){if(this.isNeedRender){const{mainCanvas:t,position:e}=this;if(this.isRecalculate){this.updateDynamicRadius();const i=t.transformPosition(e);this.internalUpdate({dynamicPosition:i}),this.updateHandlePointsPosition()}return this.isRect?[this.drawRect,this]:[this.drawPolygon,this]}}}class $t extends D{constructor(t){super(t);d(this,"_isFill",!1);d(this,"_isClosed",!1);d(this,"_isClosedThroughCenter",!1);d(this,"_radiusValue",0);d(this,"_radiusPosition",0);d(this,"_startAngle",0);d(this,"_endAngle",0);d(this,"_counterclockwise",!1);d(this,"isShowHandlePoint",!1);d(this,"_isHandlePointsVisible",!0);d(this,"defaultClick",(t,e)=>{var o;if(!this.isHandlePointsVisible)return;const{state:i,oldState:n}=t.data;i!=n&&((o=this.notifyReload)==null||o.call(this))});d(this,"defaultDragg",(t,e)=>{if(!this.mainCanvas)return;const i=()=>{var h;const{offsetX:n,offsetY:o}=t.data,{x:a,y:l}=this.calculateOffset(n,o);this.handlePointsArr.concat(this).forEach(u=>{u.internalUpdate({value:[k.add(u.value[0],a.value),k.add(u.value[1],l.value)],position:[k.add(u.position[0],a.position),k.add(u.position[1],l.position)],dynamicPosition:[k.add(u.dynamicPosition[0],a.dynamicPosition),k.add(u.dynamicPosition[1],l.dynamicPosition)]},!0)}),(h=this.notifyReload)==null||h.call(this)};if(this.isHandlePointsVisible){const{start:n,end:o,radius:a}=this.handlePoints,l=this.handlePointsArr.find(c=>c.isHover);if(l){const c=t.data.offsetX;if(l==n)this.startAngle=(this.startAngle+-c/180*Math.PI)%(Math.PI*2);else if(l==o)this.endAngle=(this.endAngle+-c/180*Math.PI)%(Math.PI*2);else if(l==a){const h=c/2/this.mainCanvas.percentage;this.radiusPosition+h>0&&(this.radiusPosition+=h)}}else i()}else i()});d(this,"handlePoints",{start:void 0,end:void 0,radius:void 0});["isFill","isClosed","isClosedThroughCenter","radiusValue","radiusPosition","startAngle","endAngle","counterclockwise","isHandlePointsVisible"].forEach(e=>{e in t&&(this["_"+e]=t[e])}),this.addEventListener("click",this.defaultClick),this.addEventListener("dragg",this.defaultDragg)}get isFill(){return this._isFill}set isFill(t){var e;this._isFill!=t&&(this._isFill=t,(e=this.notifyReload)==null||e.call(this))}get isClosed(){return this._isClosed}set isClosed(t){var e;this._isClosed!=t&&(this._isClosed=t,(e=this.notifyReload)==null||e.call(this))}get isClosedThroughCenter(){return this._isClosedThroughCenter}set isClosedThroughCenter(t){var e;this._isClosedThroughCenter!=t&&(this._isClosedThroughCenter=t,(e=this.notifyReload)==null||e.call(this))}get radiusValue(){return this._radiusValue}set radiusValue(t){this._radiusValue!=t&&(this._radiusValue=t,this._radiusPosition=0,this.updateBaseData())}get radiusPosition(){return this._radiusPosition}set radiusPosition(t){this._radiusPosition!=t&&(this._radiusPosition=t,this._radiusValue=0,this.updateBaseData())}get startAngle(){return this._startAngle}set startAngle(t){var e;this._startAngle!=t&&(this._startAngle=t,this.updateHandlePoints(),(e=this.notifyReload)==null||e.call(this))}get endAngle(){return this._endAngle}set endAngle(t){var e;this._endAngle!=t&&(this._endAngle=t,this.updateHandlePoints(),(e=this.notifyReload)==null||e.call(this))}get counterclockwise(){return this._counterclockwise}set counterclockwise(t){var e;this._counterclockwise!=t&&(this._counterclockwise=t,(e=this.notifyReload)==null||e.call(this))}get isHandlePointsVisible(){return this._isHandlePointsVisible}set isHandlePointsVisible(t){var e;this._isHandlePointsVisible!==t&&(this._isHandlePointsVisible=t,this.isShowHandlePoint!=t&&((e=this.notifyReload)==null||e.call(this)),this.updateHandlePoints())}get offset(){return super.offset}set offset(t){super.offset=t;let{isHandlePointsVisible:e,handlePointsArr:i}=this;e&&i.forEach(n=>n.internalUpdate({offset:t}))}updateValueScope(){const{mainCanvas:t,radiusValue:e}=this;t&&(this.initValueScope(),this.setFixedExtraScope({topV:e,bottomV:e,leftV:e,rightV:e*2}))}isPointInPath(t,e){return this.isFill&&this.path?D.ctx.isPointInPath(this.path,t,e):!1}isPointInStroke(t,e){return this.path&&this.mainCanvas?(this.setOverlayStyles(D.ctx),this.isDraggable&&(D.ctx.lineWidth=Math.max(D.ctx.lineWidth,20)),D.ctx.isPointInStroke(this.path,t,e)):!1}isPointInAnywhere(t,e){return(n=>{if(!n)return!1;let o=!1;return this.handlePointsArr.forEach(a=>{o?a.isHover&&a.notifyHover(!1):(o=a.isPointInAnywhere(t,e),o!=a.isHover&&a.notifyHover(o))}),o})(this.isClick&&this.isShowHandlePoint)||super.isPointInAnywhere(t,e)}get cursorStyle(){const t=this.handlePointsArr.some(e=>e==null?void 0:e.isHover);return this.isInteractive?this.isDraggable?"_nhanh_canvas_hover_overlay_draggable"+(t?"_ew":""):"_nhanh_canvas_hover_overlay":void 0}setOverlayStyles(t){var c;const e=this.isHover,i=this.mainCanvas,n=i.style[i.theme].arc;let o={};typeof this.style=="string"?o=((c=i.style[this.style])==null?void 0:c.arc)||n:typeof this.style=="object"?o=rt(JSON.parse(JSON.stringify(n)),this.style):o=n;const{fill:a,fill_hover:l}=o;return t&&(this.setBaseLineStyle(t,o.stroke),t.fillStyle=e?l:a),o}get computedValueScopeStyles(){return this.setOverlayStyles()}get handlePointsArr(){const t=this.handlePoints.radius;return Object.values(this.handlePoints).filter(Boolean).sort((e,i)=>(e.isHover||e==t?0:1)-(i.isHover||i==t?0:1))}updateHandlePoints(){let{mainCanvas:t,value:e,radiusValue:i,startAngle:n,endAngle:o,dynamicPosition:a,isHandlePointsVisible:l,offset:c}=this;if(!t||!a||!l)return;const[h,u]=Bs(...e,i,n,o,t.axisConfig.x,t.axisConfig.y),f=w=>new ct({name:w,offset:c,value:[0,0],isDraggable:!0,mainCanvas:this.mainCanvas,notifyReload:()=>{var P;return(P=this.notifyReload)==null?void 0:P.call(this)}}),m=this.handlePoints.start||f("start"),p=this.handlePoints.end||f("end"),g=this.handlePoints.radius||f("radius");m.value=h,p.value=u;const y=e[0]+i*2*t.axisConfig.x;g.value=[y,e[1]],this.handlePoints={start:m,end:p,radius:g}}updateBaseData(){this.mainCanvas&&(this.radiusValue?this._radiusPosition=this.mainCanvas.getAxisPointByValue(this.radiusValue,0,!0).x:this._radiusValue=this.mainCanvas.getAxisValueByPoint(this.radiusPosition,0,!0).xV,this.handleValuePosition("array1D")&&this.updateHandlePoints())}drawGuideLine(t,e,i,n){this.setBaseLineStyle(t,{...n.stroke,dash:!n.stroke.dash});const{radiusPosition:o,startAngle:a,endAngle:l,counterclockwise:c,mainCanvas:h}=this;t.beginPath(),t.arc(e,i,o*h.percentage,l,a,c),t.stroke(),t.beginPath(),t.moveTo(e,i);const u=this.handlePoints.radius.finalDynamicPosition;t.lineTo(u[0],u[1]),t.stroke(),!(this.isClosed&&this.isClosedThroughCenter)&&(t.fillStyle=t.strokeStyle,t.beginPath(),t.arc(e,i,n.point.radius,0,Math.PI*2),t.fill())}draw(t){const{finalDynamicPosition:e,mainCanvas:i,startAngle:n,endAngle:o,counterclockwise:a,isFill:l,isClosed:c,isClosedThroughCenter:h,radiusPosition:u}=this;if(!i||u<=0)return;this.setGlobalAlpha(t);const f=this.setOverlayStyles(t),[m,p]=e;t.beginPath(),this.path=new Path2D,this.path.arc(m,p,u*i.percentage,n,o,a),c&&(this.path.lineTo(m,p),h&&this.path.closePath()),t.stroke(this.path),l&&t.fill(this.path),this.isShowHandlePoint=this.isClick&&this.isHandlePointsVisible,this.isShowHandlePoint&&(this.drawGuideLine(t,m,p,f),this.handlePointsArr.forEach(g=>{var y;g.internalUpdate({style:f.point}),(y=g.getDraw())==null||y[0].call(g,t)}))}getDraw(){if(this.isNeedRender){if(this.isRecalculate){const{position:t,mainCanvas:e}=this,i=this.dynamicPosition,n=e.transformPosition(t);if(this.internalUpdate({dynamicPosition:n}),this.isHandlePointsVisible)if(e!=null&&e.isScaleUpdated)this.updateHandlePoints();else{const o=n[0]-i[0],a=n[1]-i[1];this.handlePointsArr.forEach(l=>{const c=l.dynamicPosition[0]+o,h=l.dynamicPosition[1]+a;l.internalUpdate({dynamicPosition:[c,h]})})}}return[this.draw,this]}}}function Bs(r,s,t,e,i,n=1,o=1){const a=r+t*Math.cos(e)*n,l=s+t*Math.sin(e)*o,c=r+t*Math.cos(i)*n,h=s+t*Math.sin(i)*o;return[[a,l],[c,h]]}class Zt extends D{constructor(t){super(t);d(this,"handlePoints");d(this,"isShowHandlePoint",!1);d(this,"_isHandlePointsVisible",!0);d(this,"_radiusValue",0);d(this,"_radiusPosition",0);d(this,"defaultClick",(t,e)=>{var o;if(!this.isHandlePointsVisible)return;const{state:i,oldState:n}=t.data;i!=n&&((o=this.notifyReload)==null||o.call(this))});d(this,"defaultDragg",(t,e)=>{this.mainCanvas});["isHandlePointsVisible"].forEach(e=>{e in t&&(this["_"+e]=t[e])}),this.addEventListener("click",this.defaultClick),this.addEventListener("dragg",this.defaultDragg)}get handlePointsArr(){if(this.handlePoints){const{radius:t,other:e}=this.handlePoints;return[t,...e].filter(Boolean).sort((i,n)=>(i.isHover||i==t?0:1)-(n.isHover||n==t?0:1))}return[]}get isHandlePointsVisible(){return this._isHandlePointsVisible}set isHandlePointsVisible(t){var e;this._isHandlePointsVisible!==t&&(this._isHandlePointsVisible=t,this.isShowHandlePoint!=t&&((e=this.notifyReload)==null||e.call(this)))}get radiusValue(){return this._radiusValue}set radiusValue(t){this._radiusValue!=t&&(this._radiusValue=t,this.updateBaseData())}get radiusPosition(){return this._radiusPosition}set radiusPosition(t){this._radiusPosition!=t&&(this._radiusPosition=t,this.updateBaseData())}updateValueScope(){this.initValueScope()}isPointInPath(t,e){return!1}isPointInStroke(t,e){return this.path&&this.mainCanvas?(this.setOverlayStyles(D.ctx),this.isDraggable&&(D.ctx.lineWidth=Math.max(D.ctx.lineWidth,20)),D.ctx.isPointInStroke(this.path,t,e)):!1}isPointInAnywhere(t,e){return(n=>{if(!n)return!1;let o=!1;return this.handlePointsArr.forEach(a=>{o?a.isHover&&a.notifyHover(!1):(o=a.isPointInAnywhere(t,e),o!=a.isHover&&a.notifyHover(o))}),o})(this.isClick&&this.isShowHandlePoint)||super.isPointInAnywhere(t,e)}get cursorStyle(){var e;const t=(e=this.handlePoints)==null?void 0:e.radius.isHover;return this.isDraggable?"_nhanh_canvas_hover_overlay_draggable"+(t?"_ns":""):"_nhanh_canvas_hover_overlay"}setOverlayStyles(t){var o;const e=this.mainCanvas,i=e.style[e.theme].arcTo;let n={};return typeof this.style=="string"?n=((o=e.style[this.style])==null?void 0:o.arcTo)||i:typeof this.style=="object"?n=rt(JSON.parse(JSON.stringify(i)),this.style):n=i,t&&this.setBaseLineStyle(t,n.stroke),n}get computedValueScopeStyles(){return this.setOverlayStyles()}updateHandlePoints(){var c,h;let{value:t,position:e,dynamicPosition:i,isHandlePointsVisible:n}=this;if(!i||!n)return;const o=()=>new ct({value:[0,0],mainCanvas:this.mainCanvas,isDraggable:!0,notifyReload:()=>{var u;return(u=this.notifyReload)==null?void 0:u.call(this)}}),a=((c=this.handlePoints)==null?void 0:c.other)||[];t==null||t.forEach((u,f)=>{a[f]||a.push(o()),a[f].internalUpdate({value:t[f],position:e[f],dynamicPosition:i[f]},!0)}),a.length=t.length;const l=((h=this.handlePoints)==null?void 0:h.radius)||o();this.handlePoints={radius:l,other:a}}updateBaseData(){if(!this.mainCanvas)return;let{value:t,position:e}=this;const[i,n]=[Ot(t)&&t.length>1,Ot(e)&&e.length>1];if(!i&&!n)return this.handlePoints=void 0,this.internalUpdate({dynamicPosition:void 0});if(i){e=[];for(let a=0;a<t.length;a++){const l=t[a],c=this.mainCanvas.getAxisPointByValue(l[0],l[1],!0);e.push([c.x,c.y])}}else{t=[];for(let a=0;a<e.length;a++){const l=e[a],c=this.mainCanvas.getAxisValueByPoint(l[0],l[1],!0);t.push([c.xV,c.yV])}}const o=this.mainCanvas.transformPosition(e);this.internalUpdate({value:t,position:e,dynamicPosition:o}),this.updateHandlePoints()}draw(t){const{dynamicPosition:e,mainCanvas:i,radiusValue:n}=this}getDraw(){if(this.isNeedRender){if(this.isRecalculate){const{position:t,mainCanvas:e}=this,i=this.dynamicPosition,n=e.transformPosition(t);if(this.internalUpdate({dynamicPosition:n}),this.isHandlePointsVisible)if(e!=null&&e.isScaleUpdated)this.updateHandlePoints();else{const o=n[0][0]-i[0][0],a=n[0][1]-i[0][1];this.handlePointsArr.forEach(l=>{const c=l.dynamicPosition[0]+o,h=l.dynamicPosition[1]+a;l.internalUpdate({dynamicPosition:[c,h]})})}}return[this.draw,this]}}}class zs extends Ns{constructor(t){super(t);d(this,"resizeObserver");d(this,"currentDrawOverlays",[]);d(this,"rely","");d(this,"maxMinValue",{minXV:0,maxXV:0,minYV:0,maxYV:0});d(this,"measureRedrawPerformance",Ge(()=>{this.isRendering=!0,this.redraw(),this.redrawInNextRenderFrame=!1,this.isRendering=!1},{level:[[1,"#F56C6C"],[.5,"#E6A23C"],[0,"#67C23A"]]}));this.canvas&&(this.resizeObserver=new ResizeObserver(be(()=>{[this.canvas.width,this.canvas.height]=[this.rect.width,this.rect.height],this.redrawOnce()},200)),this.resizeObserver.observe(this.canvas)),this.updateRely(),this.isRecalculate=!1}updateRely(){const{center:t,scale:e,rect:i,axisConfig:n}=this,o=[t.x,t.y,e,JSON.stringify(n),i.width,i.height].join();this.isRecalculate=this.rely!==o,this.rely=o}redraw(){var n,o;if(!this.canvas)return console.warn("canvas is not HTMLCanvasElement");if(this.canvas.clientWidth==0||this.canvas.clientHeight==0)return console.warn("The image argument is a canvas element with a width or height of 0.");if(!this.shouldRender())return this.clearScreen(!1);this.ctx.globalAlpha=this.opacity??1,this.updateCenter(),this.updateRely(),this.maxMinValue=this.getMaxMinValue(),this.clearScreen();const t=[];let e=[];const i=(n=this.drawAxis)==null?void 0:n.drawAxisAndGrid();i&&e.push([0,i,[]]),this.layerGroups.forEach(a=>e.push(...a.fetchCanvas())),e.sort((a,l)=>a[0]-l[0]),e.forEach(([,a,l],c)=>{this.ctx.drawImage(a,0,0),l.forEach(([[h,u],f])=>{t.push([[h+c,u],f])})}),t.sort(([[a,l],c],[[h,u],f])=>{if(a!==h)return h-a;if(l!==u)return u-l;const m=p=>p instanceof Yt?5:p instanceof Wt?4:p instanceof ct?3:p instanceof jt||p instanceof $t||p instanceof Zt?2:p instanceof qt?1:0;return m(f)-m(c)}),this.currentDrawOverlays=t.map(([,a])=>a),this.isRecalculate=!1,this.isThemeUpdated=!1,this.isScaleUpdated=!1,(o=this.notifyReload)==null||o.call(this)}redrawOnce(){this.redrawInNextRenderFrame||(this.redrawInNextRenderFrame=!0,Promise.resolve().then(()=>{this.isRendering=!0,this.redraw(),this.redrawInNextRenderFrame=!1,this.isRendering=!1}))}findOverlayByPoint(t){const{offsetX:e,offsetY:i,clientX:n,clientY:o}=t,{x:a,y:l}=this.axisConfig,c=this.getMousePositionOnAxis({clientX:n-10*a,clientY:o-10*l}),h=this.getMousePositionOnAxis({clientX:n+10*a,clientY:o+10*l}),u=this.getAxisValueByPoint(c.x,c.y),f=this.getAxisValueByPoint(h.x,h.y);return[...this.currentDrawOverlays].sort((m,p)=>(m.isDraggable&&m.isClick?0:1)-(p.isDraggable&&p.isClick?0:1)).find(m=>{const p=m.valueScope;return p&&(p.maxX<u.xV||p.minX>f.xV||p.maxY<u.yV||p.minY>f.yV)?!1:m.isPointInAnywhere(e,i)})}destroy(){var t;(t=this.resizeObserver)==null||t.disconnect()}}class Us extends zs{constructor(t){super(t);d(this,"mouseInCanvas",!1);d(this,"mouseIsDown",!1);d(this,"mouseLastPosition",{x:0,y:0});d(this,"unBind");d(this,"lastClickedOverlay");d(this,"lockNotifyClick",!1);d(this,"lastContextmenuOverlay");d(this,"defaultContextmenu",(t,e)=>{const i=this.lastClickedOverlay;i!=null&&i.isDraggable&&i.notifyClick(!1,e)});d(this,"lastPressedKey",{key:"",keyupTime:0,doubleClick:!1});d(this,"defaultWheel",(t,e)=>{this.setScale(e,t.data),this.redrawOnce()});d(this,"lastDownOverlay");d(this,"defaultDown",(t,e)=>{(e==null?void 0:e.button)==0&&(this.mouseIsDown=!0)});d(this,"lastHoverOverlay");d(this,"lastCursorStyle");d(this,"oldClientX",[]);d(this,"oldClientY",[]);this.initEvent(),this.addEventListener("contextmenu",this.defaultContextmenu),this.addEventListener("down",this.defaultDown),this.addEventListener("wheel",this.defaultWheel)}initEvent(){const{canvas:t}=this;if(!t)return console.error("canvas is not HTMLCanvasElement");const e=[{type:"click",handler:this.click.bind(this)},{type:"contextmenu",handler:this.contextmenu.bind(this)},{type:"mouseenter",handler:this.mouseenter.bind(this)},{type:"mouseleave",handler:this.mouseleave.bind(this)},{type:"keydown",handler:this.keydown.bind(this),target:window},{type:"keyup",handler:this.keyup.bind(this),target:window},{type:"wheel",handler:this.wheel.bind(this)},{type:"mousedown",handler:this.mousedown.bind(this)},{type:"mouseup",handler:this.mouseup.bind(this),target:window},{type:"mousemove",handler:this.mousemove.bind(this),target:window},{type:"touchend",handler:this.touchend.bind(this)},{type:"touchmove",handler:this.touchmove.bind(this)}];e.forEach(({type:i,handler:n,target:o=t})=>{o.addEventListener(i,n)}),this.unBind=()=>{e.forEach(({type:i,handler:n,target:o=t})=>{o.removeEventListener(i,n)})}}click(t){var i;if(!this.isClickable)return;if(this.lockNotifyClick)return this.lockNotifyClick=!1;const e=this.findOverlayByPoint(t);this.lastClickedOverlay!=e&&((i=this.lastClickedOverlay)==null||i.notifyClick(!1,t)),e==null||e.notifyClick(!0,t),this.lastClickedOverlay=e,this.notifyClick(!0,t)}contextmenu(t){var i;if(!this.isContextmenuable)return;t.preventDefault();const e=this.findOverlayByPoint(t);this.lastContextmenuOverlay!=e&&((i=this.lastContextmenuOverlay)==null||i.notifyContextmenu(!1,t)),e==null||e.notifyContextmenu(!0,t),this.lastContextmenuOverlay=e,this.notifyContextmenu(!0,t)}mouseenter(t){this.mouseInCanvas=!0}mouseleave(t){this.mouseInCanvas=!1}getStep(t){const{lastPressedKey:e}=this;return e.doubleClick?4:e.key===t&&Date.now()-e.keyupTime<300?(e.doubleClick=!0,4):1}keydown(t){const{mouseInCanvas:e,offset:i,delta:n,axisConfig:o}=this,a=t.key;if(!e||!this.isDraggable||this.isAuto)return;const l=this.getStep(a),c=this.lastClickedOverlay,u=(c==null?void 0:c.isDraggable)&&this.currentDrawOverlays.includes(c)&&(Ot(c.value)?"Matrix":oe(c.value)?"Single":!1),f=(y,w)=>{if(!u)return i.x+=y*l,i.y+=w*l,!0;const P=this.getAxisValueByPoint(l,0).xV,[b,E]=[P*o.x,P*o.y];if(u==="Single"){const T=c.value;T[0]+=y*b,T[1]+=w*E}else c.value.forEach(T=>{T[0]+=y*b,T[1]+=w*E});return c.value=[...c.value],!0},m=y=>(this.setScale("center",y*n),!0),g={ArrowUp:()=>f(0,-1),ArrowDown:()=>f(0,1),ArrowLeft:()=>f(-1,0),ArrowRight:()=>f(1,0),"+":()=>m(1),"-":()=>m(-1)}[a];g!=null&&g()&&(this.redrawOnce(),t.preventDefault())}keyup(t){const{mouseInCanvas:e,lastPressedKey:i}=this;if(e){const n=t.key;i.key=n,i.keyupTime=Date.now(),i.doubleClick=!1}}wheel(t){if(!this.isWheelable)return;t.preventDefault();const{delta:e,isAuto:i}=this;if(i)return;const n=t.deltaY<0?e:-e,o=this.findOverlayByPoint(t);o==null||o.notifyWheel(n,t),this.notifyWheel(n,t)}mousedown(t){var o;if(!this.isDownable)return;const{clientX:e,clientY:i}=t;this.mouseLastPosition={x:e,y:i};const n=this.findOverlayByPoint(t);this.lastDownOverlay!=n&&((o=this.lastDownOverlay)==null||o.notifyDown(!1,t),n==null||n.notifyDown(!0,t)),this.lastDownOverlay=n,this.notifyDown(!0,t)}mouseup(t){this.mouseIsDown=!1,this.lastDownOverlay=void 0}mousemove(t){this.isAuto||(this.canvas.classList.toggle("_nhanh_canvas_draggable",this.isDraggable),this.mouseIsDown?this.handleDragMove(t):this.handleHover(t))}handleDragMove(t){if(!this.isDraggable)return;const{clientX:e,clientY:i}=t,n={x:e,y:i};if(JSON.stringify(n)==JSON.stringify(this.mouseLastPosition))return;const{lastDownOverlay:o}=this;o!=null&&o.isDraggable?this.notifyDraggOverlays(t):this.handleCanvasPan(t),this.mouseLastPosition=n,this.lockNotifyClick=!0}notifyDraggOverlays(t){const e=this.lastDownOverlay,{mouseLastPosition:i}=this,{clientX:n,clientY:o}=t;e.notifyDragg({offsetX:n-i.x,offsetY:o-i.y},t)}handleCanvasPan(t){const{clientX:e,clientY:i}=t,{offset:n,mouseLastPosition:o}=this,a=e-o.x,l=i-o.y;n.x+=a,n.y+=l,this.redrawOnce(),this.notifyDragg({offsetX:a,offsetY:l},t)}handleHover(t){if(!this.isHoverable||t.target!=this.canvas)return;const e=this.findOverlayByPoint(t);this.updateHoverState(e,t),this.notifyHover(!0,t)}updateHoverState(t,e){if(this.lastHoverOverlay===t){const n=t==null?void 0:t.cursorStyle;n!==this.lastCursorStyle&&(this.lastCursorStyle&&this.canvas.classList.remove(this.lastCursorStyle),n&&this.canvas.classList.add(n),this.lastCursorStyle=n);return}this.lastHoverOverlay&&t&&t.hasController("hover",this.lastHoverOverlay)||(this.clearHoverState(e),this.applyHoverState(t,e)),this.lastHoverOverlay=t}clearHoverState(t){this.lastHoverOverlay&&(this.lastHoverOverlay.notifyHover(!1,t),this.lastHoverOverlay.cursorStyle&&this.canvas.classList.remove(this.lastHoverOverlay.cursorStyle))}applyHoverState(t,e){t&&(t.notifyHover(!0,e),this.lastCursorStyle=t.cursorStyle,this.lastCursorStyle&&this.canvas.classList.add(this.lastCursorStyle))}touchend(t){this.oldClientX=this.oldClientY=[]}touchmove(t){if(!this.isDraggable)return;const e=t.touches;t.preventDefault();const{oldClientX:i,oldClientY:n,offset:o,delta:a,isAuto:l,isDraggable:c}=this;if(c&&!l){if(e.length===1){const{clientX:h,clientY:u}=e[0];i.length&&(o.x+=h-i[0],o.y+=u-n[0],this.redrawOnce()),this.oldClientX=[h],this.oldClientY=[u]}else if(e.length===2){const{clientX:h,clientY:u}=e[0],{clientX:f,clientY:m}=e[1];if(i.length==2){const p=xe(i[0],n[0],i[1],n[1]),g=xe(h,u,f,m),{x:y,y:w}=Ee(h,u,f,m);this.setScale({clientX:y,clientY:w},g>p?a:-a),this.redrawOnce()}this.oldClientX=[h,f],this.oldClientY=[u,m]}}}destroy(){var t;super.destroy(),(t=this.unBind)==null||t.call(this)}}class Y extends It{constructor(t){super(t);d(this,"overlays",new Set);d(this,"oldOverlaysSize",0);this.setNotifyReload(t.notifyReload)}get overlaysSizeChange(){const t=this.oldOverlaysSize;return this.oldOverlaysSize=this.overlays.size,this.overlays.size!==t}setMainCanvas(t){var e;super.setMainCanvas(t),this.overlays.forEach(i=>{i.setMainCanvas(t),i.parent=this}),t&&this.overlays.size&&((e=this.notifyReload)==null||e.call(this))}setNotifyReload(t){this.notifyReload=t?e=>{e&&(this.isRecalculate=!0),(e||this.overlaysSizeChange||this.shouldRender()&&this.overlays.size)&&t()}:void 0,this.overlays.forEach(e=>e.setNotifyReload(this.notifyReload))}addOverlay(t){var e;[t].flat().forEach(i=>{i.setNotifyReload(this.notifyReload),i.setMainCanvas(this.mainCanvas),i.parent=this,this.overlays.add(i)}),(e=this.notifyReload)==null||e.call(this)}hasOverlay(t){return this.overlays.has(t)}removeOverlay(t){var e;[t].flat().forEach(i=>{this.overlays.delete(i),i.setNotifyReload(),i.setMainCanvas(),i.parent=void 0}),(e=this.notifyReload)==null||e.call(this)}clearOverlay(){var t;(t=this.notifyReload)==null||t.call(this),this.overlays.forEach(e=>{e.setNotifyReload(),e.setMainCanvas(),e.parent=void 0}),this.overlays.clear()}getOverlaysDrawingMethod(){const t=[];return this.shouldRender()&&this.overlays.size&&Array.from(this.overlays.values()).sort((e,i)=>e.zIndex-i.zIndex).forEach(e=>{if(e.equalsMainCanvas(this.mainCanvas)){const i=e.getDraw();i&&t.push([Number(e.zIndex)||0,i])}else this.overlays.delete(e)}),t}}class W extends It{constructor(t){super(t);d(this,"_zIndex",4);d(this,"canvas",document.createElement("canvas"));d(this,"ctx",this.canvas.getContext("2d"));d(this,"isReload",!1);d(this,"groups",new Map);d(this,"oldGroupsSize",0);d(this,"currentDrawOverlays",[]);this.setNotifyReload(t.notifyReload),typeof t.zIndex=="number"&&(this.zIndex=t.zIndex)}get zIndex(){return this._zIndex}set zIndex(t){var e;this._zIndex!=t&&(this._zIndex=t,(e=this.notifyReload)==null||e.call(this))}get groupsSizeChange(){const t=this.oldGroupsSize;return this.oldGroupsSize=this.groups.size,this.groups.size!==t}setMainCanvas(t){super.setMainCanvas(t),this.canvas.width=(t==null?void 0:t.rect.width)||0,this.canvas.height=(t==null?void 0:t.rect.height)||0,this.groups.forEach(e=>{e.setMainCanvas(t),e.parent=this})}setNotifyReload(t){this.notifyReload=t?e=>{e&&(this.isRecalculate=!0),(e||this.groupsSizeChange||this.shouldRender()&&this.groups.size)&&t()}:void 0,this.groups.forEach(e=>this.setGroupNotifyReload(e))}setGroupNotifyReload(t){t.setNotifyReload(this.notifyReload?()=>{var e;(e=this.notifyReload)==null||e.call(this),this.isReload=!0}:void 0)}getGroup(t){return this.groups.get(t)}addGroup(t){[t].flat().forEach(e=>{e instanceof Y&&(this.setGroupNotifyReload(e),e.setMainCanvas(this.mainCanvas),e.parent=this,this.groups.set(e.name,e))})}removeGroup(t){var i;let e=!1;[t].flat().forEach(n=>{n instanceof Y&&(this.groups.delete(n.name),n.setNotifyReload(),n.setMainCanvas(),n.parent=void 0,e=!0)}),e&&((i=this.notifyReload)==null||i.call(this))}clearGroup(){var t;this.groups.size&&(this.groups.forEach(e=>{e.setNotifyReload(),e.setMainCanvas(),e.parent=void 0}),this.groups.clear(),(t=this.notifyReload)==null||t.call(this))}getCanvas(){if(!this.mainCanvas)return;const{rect:t,isThemeUpdated:e}=this.mainCanvas,i=this.shouldRender(),n=this.groups.size;if(i&&n){if(this.isReload||this.isRecalculate||e){this.currentDrawOverlays=[],this.isReload=!1,this.canvas.width=t.width||0,this.canvas.height=t.height||0;const o=[];this.groups.forEach(a=>{a.equalsMainCanvas(this.mainCanvas)?o.push(...a.getOverlaysDrawingMethod()):this.groups.delete(a.name)}),o.sort((a,l)=>a[0]-l[0]),o.forEach(([a,[l,c]])=>{l.call(c,this.ctx),this.currentDrawOverlays.push([[Number(this.zIndex)||0,a],c])})}return[Number(this.zIndex)||0,this.canvas,this.currentDrawOverlays]}}}class kt extends It{constructor(t){super(t);d(this,"layers",new Map);d(this,"oldLlayersSize",0);d(this,"defaultContextmenu",(t,e)=>t.stopPropagation());d(this,"defaultClick",(t,e)=>t.stopPropagation());d(this,"defaultDoubleClick",(t,e)=>t.stopPropagation());d(this,"defaultHover",(t,e)=>t.stopPropagation());d(this,"defaultDragg",(t,e)=>t.stopPropagation());d(this,"defaultDown",(t,e)=>t.stopPropagation());this.inheritOpacity=!1,this.setNotifyReload(t.notifyReload),this.addEventListener("contextmenu",this.defaultContextmenu),this.addEventListener("click",this.defaultClick),this.addEventListener("doubleClick",this.defaultDoubleClick),this.addEventListener("hover",this.defaultHover),this.addEventListener("dragg",this.defaultDragg),this.addEventListener("down",this.defaultDown)}get layersSizeChange(){const t=this.oldLlayersSize;return this.oldLlayersSize=this.layers.size,this.layers.size!==t}setMainCanvas(t){super.setMainCanvas(t),this.layers.forEach(e=>{e.setMainCanvas(t),e.parent=this})}setNotifyReload(t){this.notifyReload=t?e=>{e&&(this.isRecalculate=!0),(e||this.layersSizeChange||this.shouldRender()&&this.layers.size)&&t()}:void 0,this.layers.forEach(e=>e.setNotifyReload(this.notifyReload))}getLayer(t){return this.layers.get(t)}addLayer(t){[t].flat().forEach(e=>{e instanceof W&&(e.setNotifyReload(this.notifyReload),e.setMainCanvas(this.mainCanvas),e.parent=this,this.layers.set(e.name,e))})}removeLayer(t){var i;let e=!1;[t].flat().forEach(n=>{n instanceof W&&(this.layers.delete(n.name),n.setNotifyReload(),n.setMainCanvas(),n.parent=void 0,e=!0)}),e&&((i=this.notifyReload)==null||i.call(this))}clearLayer(){var t;this.layers.size&&(this.layers.forEach(e=>{e.setNotifyReload(),e.setMainCanvas(),e.parent=void 0}),this.layers.clear(),(t=this.notifyReload)==null||t.call(this))}fetchCanvas(){if(this.shouldRender()&&this.layers.size){const t=[];return this.layers.forEach(e=>{if(e.equalsMainCanvas(this.mainCanvas)){const i=e.getCanvas();i&&t.push(i)}else this.layers.delete(e.name)}),t}return[]}}class Gs extends Us{getDefaultOverlayGroup(){var c,h,u,f,m,p,g;const s=this.layerGroups.get("默认图层群组");if(!s)return;const t=(c=s.getLayer("点位图层"))==null?void 0:c.getGroup("点位覆盖物群组"),e=(h=s.getLayer("线段图层"))==null?void 0:h.getGroup("线段覆盖物群组"),i=(u=s.getLayer("多边形图层"))==null?void 0:u.getGroup("多边形覆盖物群组"),n=(f=s.getLayer("文字图层"))==null?void 0:f.getGroup("文字覆盖物群组"),o=(m=s.getLayer("自定义绘制图层"))==null?void 0:m.getGroup("自定义绘制覆盖物群组"),a=(p=s.getLayer("图片图层"))==null?void 0:p.getGroup("图片覆盖物群组"),l=(g=s.getLayer("其他图层"))==null?void 0:g.getGroup("其他覆盖物群组");return{overlays_text:n,overlays_point:t,overlays_line:e,overlays_polygon:i,overlays_custom:o,overlays_billboard:a,overlays_other:l}}getAllOverlays(s){const t=[],e=s!==void 0?Array.isArray(s)?[...s]:[s]:Array.from(this.layerGroups.values());for(;e.length>0;){const i=e.pop();if(i instanceof kt){if(!i.isVisible)continue;e.push(...i.layers.values())}else if(i instanceof W){if(!i.isVisible)continue;e.push(...i.groups.values())}else if(i instanceof Y){if(!i.isVisible)continue;e.push(...i.overlays.values())}else i.isVisible&&t.push(i)}return t}}class Xs extends Gs{zoom(s){const{canvas:t,rect:e}=this;if(!t||!e)return console.error("canvas is not HTMLCanvasElement");this.setScale("center",s),this.redrawOnce()}zoomIn(){this.zoom(this.delta)}zoomOut(){this.zoom(-this.delta)}setStyle(s){super.setStyle(s),this.redrawOnce()}setTheme(s){super.setTheme(s),this.redrawOnce()}setAxis(s){super.setAxis(s),this.redrawOnce()}setDefaultCenter(s){super.setDefaultCenter(s),this.redrawOnce()}}class Ys extends Xs{setFitView(s=void 0,t=!1,e=[60,60,60,60],i){const n=this.getAllOverlays(s);if(n.length===0)return;const{minX:o,maxX:a,minY:l,maxY:c}=this.calculateBoundingBox(n),h=a-o,u=c-l,f=this.calculateOptimalScale(h,u,e,i),m=this.calculateOffsetDifference(o,a,l,c,e);f==this.scale&&m.x==0&&m.y==0||(t?this.applyTransformImmediately(f,m):this.animateTransform(f,m))}calculateBoundingBox(s){let t=1/0,e=-1/0,i=1/0,n=-1/0;for(const o of s){const a=o.valueScope;t=Math.min(t,a.minX),e=Math.max(e,a.maxX),i=Math.min(i,a.minY),n=Math.max(n,a.maxY)}return{minX:t,maxX:e,minY:i,maxY:n}}calculateOptimalScale(s,t,e,i){const{cycle:n,delta:o,axisConfig:a,rect:l}=this,{width:c,height:h}=l,u=Math.max(0,c-e[1]-e[3])||c,f=Math.max(0,h-e[0]-e[2])||h;if(u<=0||f<=0)return console.warn("无效的可视区域尺寸,边距设置可能不合理"),this.scale;const m=s/u,p=t/f,g=Math.max(m,p),y=a.count,w=y/a.min,P=n*o;let b;if(g>w){const E=Math.ceil(g/w);b=1-((y*E/g-a.min)/a.min+(E-2))*P}else{const E=(dt,ot,yt)=>dt<ot?yt-1:E(dt/2,ot,yt+1),T=E(w,g,0),G=Math.pow(2,T);b=1+((y/G/g-a.min)/a.min+T)*P}return i!==void 0&&(b=Math.min(i,b)),b=new R(b).div(o).round().mul(o).toNumber(),b}calculateOffsetDifference(s,t,e,i,n){const{width:o,height:a}=this.rect,{axisConfig:l,center:c}=this,h=(t+s)/2,u=(i+e)/2,f=this.getAxisPointByValue(h,u),m=this.getAxisValueByPoint((o/2-c.x)*l.x,(a/2-c.y)*l.y),p=this.getAxisPointByValue(m.xV,m.yV);return{x:Math.round(-(f.x+(n[3]-n[1])-p.x)*l.x),y:Math.round(-(f.y+(n[0]-n[2])-p.y)*l.y)}}applyTransformImmediately(s,t){this.offset={x:this.offset.x+t.x,y:this.offset.y+t.y},this.scale=s,this.updateSize(),this.redrawOnce()}animateTransform(s,t){const e=this.scale,i={...this.offset},n=300;this.isAuto=!0;const o=()=>this.isAuto=!1;(c=>this.animateOffset(i,t,n,c||o))(c=>this.animateScale(e,s,n,c||o))}animateScale(s,t,e,i){const n=t-s;let o=0;Vt(a=>{!this.isAuto||!this.canvas||!this.isInteractive||(this.setScale("center",(a-o)*n),o=a,this.redrawOnce(),a===1&&i())},e)}animateOffset(s,t,e,i){Vt(n=>{!this.isAuto||!this.canvas||!this.isInteractive||(this.offset={x:Number((s.x+t.x*n).toFixed(0)),y:Number((s.y+t.y*n).toFixed(0))},this.redrawOnce(),n===1&&i())},e)}returnToOrigin(){if(!this.isInteractive||this.scale==this.defaultScale&&this.offset.x==0&&this.offset.y==0)return;const{rect:s,axisConfig:t}=this,e=this.getDefaultCenterLocation(),i=(s.width/2-e.x)*t.x,n=(s.height/2-e.y)*t.y,o=this.getAxisValueByPoint(i,n,!0),a=this.getMousePositionOnAxis({clientX:s.x+s.width/2,clientY:s.y+s.height/2}),l=this.getAxisValueByPoint(a.x,a.y),c=t.size/this.getNowGridCount,h=Math.round((l.xV-o.xV)*t.x*c),u=Math.round((l.yV-o.yV)*t.y*c);h==0&&u==0||this.animateTransform(this.defaultScale,{x:h,y:u})}}class Ws extends Ys{toggleAxis(s){this.drawAxis.toggleAxis(s),this.redrawOnce()}togglePoint(s){const{overlays_point:t}=this.getDefaultOverlayGroup()||{};return t?(t.isVisible=s??!t.isVisible,this.redrawOnce(),t.isVisible):!1}toggleLine(s){const{overlays_line:t}=this.getDefaultOverlayGroup()||{};return t?(t.isVisible=s??!t.isVisible,this.redrawOnce(),t.isVisible):!1}togglePolygon(s){const{overlays_polygon:t}=this.getDefaultOverlayGroup()||{};return t?(t.isVisible=s??!t.isVisible,this.redrawOnce(),t.isVisible):!1}toggleLock(s){return this.isInteractive=s??!this.isInteractive,this.isInteractive}}class js extends Ws{static clearPathRegion(s,t){const{width:e,height:i}=s.canvas;s.save(),s.beginPath(),s.clip(t),s.clearRect(0,0,e,i),s.restore()}}class qs extends js{}class $s{constructor(s){d(this,"canvas");d(this,"axis_canvas",document.createElement("canvas"));d(this,"ctx",this.axis_canvas.getContext("2d"));d(this,"isReload",!0);d(this,"show",{all:!0,grid:{main:!0,secondary:!0},axis:!0,axisText:!0});this.canvas=s,this.initAxisCanvas()}initAxisCanvas(){const{canvas:s,axis_canvas:t}=this;s&&(t.width=s.rect.width||0,t.height=s.rect.height||0)}toggleAxis(s){const t=(()=>{if(typeof s=="object"){const{all:e=!0,axis:i=!0,axisText:n=!0}=s,o=Object.assign({main:!0,secondary:!0},s.grid);return{all:e,grid:o,axis:i,axisText:n}}return typeof s=="boolean"?{all:!0,grid:{main:s,secondary:s},axis:s,axisText:s}:!this.show.all})();typeof t=="boolean"?this.show.all=t:this.show=t,this.isReload=!0}drawAxisAndGrid(){if(!(!this.canvas||!this.show.all))return(this.canvas.isRecalculate||this.isReload||this.canvas.isThemeUpdated)&&(this.isReload=!1,this.initAxisCanvas(),(this.show.grid.main||this.show.grid.secondary)&&this.drawGrid(),this.show.axis&&this.drawAxis(),this.show.axisText&&this.drawAxisText()),this.axis_canvas}color(){const{theme:s,style:t}=this.canvas;return(t[s]||t.light).grid}drawGrid(){const{canvas:s,ctx:t}=this,{rect:e,center:i,axisConfig:n}=s,{width:o,height:a}=e,l=this.color(),c=n.size,h=c/5;t.lineWidth=1;const u=(m,p)=>{const g=i.x%m>0?i.x%m:m+i.x%m;t.strokeStyle=p,t.beginPath();for(let y=0;y*m+g<=o;y++)t.moveTo(y*m+g,0),t.lineTo(y*m+g,a);t.stroke()},f=(m,p)=>{const g=i.y%m>0?i.y%m:m+i.y%m;t.strokeStyle=p,t.beginPath();for(let y=0;y*m+g<=a;y++)t.moveTo(0,y*m+g),t.lineTo(o,y*m+g);t.stroke()};this.show.grid.secondary&&(u(h,l.innerGrid),f(h,l.innerGrid)),this.show.grid.main&&(u(c,l.grid),f(c,l.grid))}drawAxis(){const{canvas:s,ctx:t}=this,{rect:e,center:i}=s,{width:n,height:o}=e,a=this.color();t.lineWidth=2,t.strokeStyle=a.axis;const l=()=>{i.y>=0&&i.y<=o&&(t.beginPath(),t.moveTo(0,i.y),t.lineTo(n,i.y),t.stroke())},c=()=>{i.x>=0&&i.x<=n&&(t.beginPath(),t.moveTo(i.x,0),t.lineTo(i.x,o),t.stroke())};l(),c()}drawText(s,t,e,i){const{canvas:n,ctx:o}=this,{theme:a}=n,l=this.canvas.style[a].text;o.font=`${l.bold?"bold":""} ${l.size}px ${l.family}`,o.strokeStyle=l.stroke,![s,t,e].includes(void 0)&&o.strokeText(s,t,e),o.fillStyle=l[i?"secondary":"color"],![s,t,e].includes(void 0)&&o.fillText(s,t,e)}drawAxisText(){const{canvas:s,ctx:t}=this,{rect:e,center:i,axisConfig:n,style:o,theme:a}=s,{width:l,height:c}=e;this.drawText();const h=g=>Math.ceil(t.measureText(g).width),u=4,f=o[a].text.size;{const g=h("0"),y=i.x<u||i.x>l+g+u,w=i.y<-(u+f)||i.y>c+f+u;!y&&!w&&this.drawText("0",i.x-g-u,i.y+f+u)}const m=s.getNowGridCount,p=n.size;{let g=i.y+f+u;g=Math.max(Math.min(g,c-u),u+f);const y=i.y>c||i.y<0;let w=i.x>0?i.x%p:i.x<0?p+i.x%p:0,P=s.getAxisValueByPoint((w-i.x)*n.x,0).xV;for(;w<=l;){const b=Qt(P),E=h(b);P!==0&&this.drawText(b,w-E/2,g,y),w+=p,P=new R(m).mul(n.x).add(P).toNumber()}}{const g=i.x>l||i.x<0;let y=i.y>0?i.y%p:i.y<0?p+i.y%p:0,w=s.getAxisValueByPoint(0,(y-i.y)*n.y).yV;for(;y<=c;){const P=Qt(w),b=h(P);let E=i.x-b-u;E=Math.max(Math.min(E,l-b-u),u),w!=0&&this.drawText(P,E,y+f/2,g),y+=p,w=new R(m).mul(n.y).add(w).toNumber()}}}}class Zs{constructor(s){d(this,"canvas");d(this,"layerGroup",new I.LayerGroup({name:"创建覆盖物图层群组"}));d(this,"overlayLayer",new I.Layer({name:"creator-layer",zIndex:9999}));d(this,"overlayGroup",new I.OverlayGroup({name:"creator-group"}));d(this,"overlay");d(this,"axisValueList");d(this,"savedLayerGroupInteractive",new Map);d(this,"axisValueLimiter");d(this,"finish");d(this,"handleMousemove",s=>{var e;if(!this.overlay||!s||(((e=this.axisValueList)==null?void 0:e.length)??0)===0)return;const t=this.getAxisValueFromEvent(s);if(t){const i=[...this.axisValueList||[],t],n=this.minPointCount-i.length;Array.from({length:n}).forEach(()=>i.push(t)),this.overlay.value=i}});d(this,"handleClick",(s,t)=>{if(!this.overlay||!t)return;const e=this.getAxisValueFromEvent(t);e&&(this.axisValueList=[...this.axisValueList||[],e],this.handleMousemove(t))});d(this,"handleContextmenu",(s,t)=>{var i,n;if(!this.overlay)return;(((i=this.axisValueList)==null?void 0:i.length)??0)>=this.minPointCount?(this.overlay.value=this.axisValueList,(n=this.finish)==null||n.call(this,this.overlay)):this.overlayGroup.removeOverlay(this.overlay),this.overlay=void 0,this.axisValueList=void 0,this.restoreLayerGroupsInteractive()});this.canvas=s,this.overlayLayer.addGroup(this.overlayGroup),this.layerGroup.addLayer(this.overlayLayer),s.setLayerGroup(this.layerGroup),s.addEventListener("click",this.handleClick),s.addEventListener("contextmenu",this.handleContextmenu),s.canvas.addEventListener("mousemove",this.handleMousemove)}disableOtherLayerGroups(){this.canvas.layerGroups.forEach(s=>{this.layerGroup!==s&&(this.savedLayerGroupInteractive.has(s)||this.savedLayerGroupInteractive.set(s,s.isInteractive),s.isInteractive=!1)})}restoreLayerGroupsInteractive(){this.savedLayerGroupInteractive.forEach((s,t)=>{t.isInteractive=s}),this.savedLayerGroupInteractive.clear()}createLine(s){return this.disableOtherLayerGroups(),this.overlay&&this.overlayGroup.removeOverlay(this.overlay),this.axisValueList=[],this.overlay=new I.Line({...s}),this.overlayGroup.addOverlay(this.overlay),this.overlay}createPolygon(s){return this.disableOtherLayerGroups(),this.overlay&&this.overlayGroup.removeOverlay(this.overlay),this.axisValueList=[],this.overlay=new I.Polygon({...s}),this.overlayGroup.addOverlay(this.overlay),this.overlay}removeOverlay(s){s?this.overlayGroup.removeOverlay(s):this.overlayGroup.clearOverlay()}clear(){this.restoreLayerGroupsInteractive(),this.overlayGroup.clearOverlay(),this.overlay=void 0,this.axisValueList=void 0}destroy(){this.clear(),this.canvas.removeEventListener("click",this.handleClick),this.canvas.removeEventListener("contextmenu",this.handleContextmenu),this.canvas.canvas.removeEventListener("mousemove",this.handleMousemove)}get minPointCount(){return this.overlay instanceof I.Polygon?3:this.overlay instanceof I.Line?2:0}getAxisValueFromEvent(s){const t=this.canvas.getMousePositionOnAxis(s);if(t){const{xV:e,yV:i}=this.canvas.getAxisValueByPoint(t.x,t.y);let n=[e,i];return this.axisValueLimiter&&(n=this.axisValueLimiter(n)),n}}}class Qs{static computeDefaultScale(s,t,e,i,n=.02,o=.2){const a=s/e,l=t/i;if(a>1||l>1){const m=Math.max(a,l),p=Math.floor(Math.log2(m)),g=(p+m/Math.pow(2,p)-1)*o;return 1-Math.ceil(g/n)*n}const c=Math.min(e/s,i/t),h=Math.floor(Math.log2(c)),u=(h+c/Math.pow(2,h)-1)*o;return 1+Math.floor(u/n)*n}static computeDefaultCenter(s,t,e,i){return{left:(s-e)/-2,top:(t-i)/-2}}}class Js extends D{constructor(){super(...arguments);d(this,"_ready",!1);d(this,"image",new Image);d(this,"_url");d(this,"_objectFit","fill")}get ready(){return this._ready}set ready(t){var e;this._ready!=t&&(this._ready=t,(e=this.notifyReload)==null||e.call(this))}get url(){return this._url}set url(t){this._url!=t&&(this._url=t,this.updateBaseData())}get objectFit(){return this._objectFit}set objectFit(t){var e;this._objectFit!=t&&(this._objectFit=t,(e=this.notifyReload)==null||e.call(this))}get drawRect(){const{mainCanvas:t,finalDynamicPosition:e,value:i,image:n,objectFit:o}=this,[a,l]=e[0];let c=n.naturalWidth,h=n.naturalHeight;if(t&&i&&i.length>1){const P=[i[1][0]-i[0][0],i[1][1]-i[0][1]],b=t.getAxisPointByValue(P[0],P[1]);c=b.x,h=b.y}const u={x:a,y:l,w:c,h},f=n.naturalWidth,m=n.naturalHeight;if(f<=0||m<=0||u.w<=0||u.h<=0)return u;const p=u.w/u.h,g=f/m;if(o==="fill")return u;if(o==="contain"||o==="scale-down"){const P=Math.min(u.w/f,u.h/m),b=o==="scale-down"?Math.min(1,P):P,E=f*b,T=m*b;return{x:u.x+(u.w-E)/2,y:u.y+(u.h-T)/2,w:E,h:T}}if(g>p){const P=m*p,b=(f-P)/2;return{...u,sx:b,sy:0,sw:P,sh:m}}const y=f/p,w=(m-y)/2;return{...u,sx:0,sy:w,sw:f,sh:y}}loadImage(){this.ready=!1,this.url&&(this.image.onload=()=>{this.ready=!0},this.image.onerror=()=>{this.ready=!1,console.error("图片加载失败")},this.image.src=this.url)}updateBaseData(){this.mainCanvas&&(this.loadImage(),this.handleValuePosition("array2D",1))}}class de extends Js{constructor(t){super(t);d(this,"defaultDragg",(t,e)=>{var l;const{offsetX:i,offsetY:n}=t.data,{x:o,y:a}=this.calculateOffset(i,n);this.value.forEach((c,h)=>{this.value[h]=[k.add(this.value[h][0],o.value),k.add(this.value[h][1],a.value)],this.position[h]=[k.add(this.position[h][0],o.position),k.add(this.position[h][1],a.position)],this.dynamicPosition[h]=[k.add(this.dynamicPosition[h][0],o.dynamicPosition),k.add(this.dynamicPosition[h][1],a.dynamicPosition)]}),(l=this.notifyReload)==null||l.call(this),this.updateValueScope()});const{url:e,objectFit:i}=t;Object.assign(this,{url:e,objectFit:i}),this.addEventListener("dragg",this.defaultDragg)}updateValueScope(){this.initValueScope()}isPointInPath(t,e){return this.path?D.ctx.isPointInPath(this.path,t,e):!1}isPointInStroke(t,e){return!1}setOverlayStyles(t){var o;const e=this.mainCanvas,i=e.style[e.theme].billboard;let n={};return typeof this.style=="string"?n=((o=e.style[this.style])==null?void 0:o.billboard)||i:typeof this.style=="object"?n=rt(JSON.parse(JSON.stringify(i)),this.style):n=i,t&&this.setBaseLineStyle(t,n.stroke),n}get computedValueScopeStyles(){return{}}draw(t){const{mainCanvas:e,ready:i,image:n,isHover:o}=this;if(!e||!i)return;this.setGlobalAlpha(t),this.setOverlayStyles(t);const{x:a,y:l,w:c,h,sx:u,sy:f,sw:m,sh:p}=this.drawRect;typeof u=="number"&&typeof f=="number"&&typeof m=="number"&&typeof p=="number"?t.drawImage(n,u,f,m,p,a,l,c,h):t.drawImage(n,a,l,c,h),o&&t.strokeRect(a,l,c,h),this.path=new Path2D,this.path.rect(a,l,c,h)}getDraw(){if(this.isNeedRender){if(this.isRecalculate){const{position:t,mainCanvas:e}=this;this.internalUpdate({dynamicPosition:e.transformPosition(t)})}return[this.draw,this]}}}function zt(r){return[r].flat(1/0)}class I extends qs{constructor(t){super(t);d(this,"overlayCreator");this.drawAxis=new $s(this),"axisShow"in t&&this.toggleAxis(t.axisShow),this.overlayCreator=new Zs(this),this.initLayerGroups(),this.updateCenter()}initLayerGroups(){const t=new W({name:"其他图层",zIndex:1});t.addGroup(new Y({name:"其他覆盖物群组"}));const e=new W({name:"图片图层",zIndex:2});e.addGroup(new Y({name:"图片覆盖物群组"}));const i=new W({name:"多边形图层",zIndex:3});i.addGroup(new Y({name:"多边形覆盖物群组"}));const n=new W({name:"线段图层",zIndex:4});n.addGroup(new Y({name:"线段覆盖物群组"}));const o=new W({name:"点位图层",zIndex:5});o.addGroup(new Y({name:"点位覆盖物群组"}));const a=new W({name:"文字图层",zIndex:6});a.addGroup(new Y({name:"文字覆盖物群组"}));const l=new W({name:"自定义绘制图层",zIndex:7});l.addGroup(new Y({name:"自定义绘制覆盖物群组"}));const c=new kt({name:"默认图层群组"});c.addLayer([a,o,n,i,l,e,t]),this.setLayerGroup(c)}gteLayerGroups(t="默认图层群组"){return this.layerGroups.get(t)}setLayerGroup(t){t instanceof kt&&(this.layerGroups.set(t.name,t),t.setNotifyReload(()=>this.redrawOnce()),t.setMainCanvas(this),t.parent=this)}removeLayerGroup(t){t instanceof kt&&(this.layerGroups.delete(t.name),t.setNotifyReload(),t.setMainCanvas(),t.parent=void 0,this.redrawOnce())}addLayer(t){const e=this.layerGroups.get("默认图层群组");e&&e.addLayer(zt(t))}removeLayer(t){const e=this.layerGroups.get("默认图层群组");e&&e.removeLayer(zt(t))}addOverlay(t){const{overlays_text:e,overlays_point:i,overlays_line:n,overlays_polygon:o,overlays_custom:a,overlays_billboard:l,overlays_other:c}=this.getDefaultOverlayGroup()||{};zt(t).forEach(h=>{h instanceof Wt?e==null||e.addOverlay(h):h instanceof ct?i==null||i.addOverlay(h):h instanceof jt||h instanceof $t||h instanceof Zt?n==null||n.addOverlay(h):h instanceof qt?o==null||o.addOverlay(h):h instanceof Yt?a==null||a.addOverlay(h):h instanceof de?l==null||l.addOverlay(h):c==null||c.addOverlay(h)})}removeOverlay(t){const{overlays_text:e,overlays_point:i,overlays_line:n,overlays_polygon:o,overlays_custom:a,overlays_billboard:l,overlays_other:c}=this.getDefaultOverlayGroup()||{};zt(t).forEach(h=>{h instanceof Wt?e==null||e.removeOverlay(h):h instanceof ct?i==null||i.removeOverlay(h):h instanceof jt||h instanceof $t||h instanceof Zt?n==null||n.removeOverlay(h):h instanceof qt?o==null||o.removeOverlay(h):h instanceof Yt?a==null||a.addOverlay(h):h instanceof de?l==null||l.removeOverlay(h):c==null||c.removeOverlay(h)})}destroy(){super.destroy()}}d(I,"ViewFit",Qs),d(I,"LayerGroup",kt),d(I,"Layer",W),d(I,"OverlayGroup",Y),d(I,"Text",Wt),d(I,"Point",ct),d(I,"Line",jt),d(I,"Polygon",qt),d(I,"Custom",Yt),d(I,"Arc",$t),d(I,"ArcTo",Zt),d(I,"Billboard",de);class Ks{constructor(s){d(this,"id");d(this,"canvas");d(this,"ctx",null);d(this,"width",0);d(this,"height",0);d(this,"resizeObserver");this.id=s}init(s){return this.destroy(),this.canvas=document.getElementById(this.id),this.canvas?(this.ctx=this.canvas.getContext("2d"),this.ctx?(this.syncCanvasSize(),this.setupResizeListener(s),!0):(console.error("Failed to get canvas context"),!1)):(console.error(`Canvas with id ${this.id} not found`),!1)}getContext(){return this.ctx}getCanvas(){return this.canvas}getSize(){return{width:this.width,height:this.height}}syncCanvasSize(){const{canvas:s}=this;if(!s)return;const t=s.getBoundingClientRect(),e=Math.floor(t.width),i=Math.floor(t.height);s.width=e,s.height=i,this.width=e,this.height=i}setupResizeListener(s){this.canvas&&(this.resizeObserver=new ResizeObserver(()=>{this.syncCanvasSize(),s()}),this.resizeObserver.observe(this.canvas))}destroy(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=void 0)}}class tn{constructor(s,t,e){d(this,"canvas");d(this,"onOffsetDelta");d(this,"onDragStart");d(this,"isDragging",!1);d(this,"lastX",0);d(this,"handleMouseDown",s=>{var t;(t=this.onDragStart)==null||t.call(this),this.isDragging=!0,this.lastX=s.clientX,window.addEventListener("mousemove",this.handleMouseMove),window.addEventListener("mouseup",this.handleMouseUp)});d(this,"handleMouseMove",s=>{if(!this.isDragging)return;const t=s.clientX-this.lastX;this.lastX=s.clientX,this.onOffsetDelta(t)});d(this,"handleMouseUp",()=>{this.isDragging=!1,window.removeEventListener("mousemove",this.handleMouseMove),window.removeEventListener("mouseup",this.handleMouseUp)});this.canvas=s,this.onOffsetDelta=t,this.onDragStart=e,this.canvas.addEventListener("mousedown",this.handleMouseDown)}destroy(){this.canvas.removeEventListener("mousedown",this.handleMouseDown),window.removeEventListener("mousemove",this.handleMouseMove),window.removeEventListener("mouseup",this.handleMouseUp)}}class en{constructor(s,t,e,i){d(this,"canvas");d(this,"getTimeSpacing");d(this,"onTimeSpacing");d(this,"minTimeSpacingMs");d(this,"maxTimeSpacingMs");d(this,"handleWheel",s=>{s.preventDefault();const t=this.canvas.getBoundingClientRect(),e=s.clientX-t.left,i=Math.max(0,Math.min(t.width,e)),n=this.getTimeSpacing(),a=(s.deltaY>0?1:-1)>0?2:.5,l=n*a,c=Math.ceil(Math.min(this.maxTimeSpacingMs,Math.max(this.minTimeSpacingMs,l)));c!==n&&this.onTimeSpacing(c,i)});this.canvas=s,this.getTimeSpacing=t,this.onTimeSpacing=e,this.minTimeSpacingMs=(i==null?void 0:i.minTimeSpacingMs)??30*1e3,this.maxTimeSpacingMs=(i==null?void 0:i.maxTimeSpacingMs)??24*60*60*1e3,this.canvas.addEventListener("wheel",this.handleWheel,{passive:!1})}destroy(){this.canvas.removeEventListener("wheel",this.handleWheel)}}class sn{constructor(s,t,e){d(this,"canvas");d(this,"getTimeAtX");d(this,"onNotify");d(this,"handleMouseMove",s=>{const t=this.canvas.getBoundingClientRect(),e=s.clientX-t.left,i=Math.max(0,Math.min(t.width,e)),n=s.clientY-t.top,o=Math.max(0,Math.min(t.height,n)),a=this.getTimeAtX(i);this.onNotify({visible:!0,canvasX:i,canvasY:o,time:a})});d(this,"handleMouseLeave",()=>{this.onNotify({visible:!1,canvasX:0,canvasY:0,time:0})});this.canvas=s,this.getTimeAtX=t,this.onNotify=e,this.canvas.addEventListener("mousemove",this.handleMouseMove),this.canvas.addEventListener("mouseleave",this.handleMouseLeave)}destroy(){this.canvas.removeEventListener("mousemove",this.handleMouseMove),this.canvas.removeEventListener("mouseleave",this.handleMouseLeave)}}const nn={easeInOutQuad:r=>r<.5?2*r*r:1-Math.pow(-2*r+2,2)/2};class rn{constructor(s,t){d(this,"canvasManager");d(this,"offsetDrag");d(this,"wheelZoom");d(this,"mouseTimeReporter");d(this,"onMouseTimeChange");d(this,"centerTimeAnimationRunId",0);d(this,"currentTime",17807184e5);d(this,"timeSpacing",5*60*1e3);d(this,"timeSpacingInPixels",100);d(this,"styleConfig",{backgroundColor:"white",axisColor:"black",textFont:"bold 12px Arial"});d(this,"tickConfig",{heightMinor:10,heightMajor:20,labelOffsetY:25,minorTicksPerMajor:10});d(this,"onDrawOverlay");this.canvasManager=new Ks(s),this.onMouseTimeChange=t,requestAnimationFrame(()=>this.init())}init(){if(!this.canvasManager.init(()=>this.render()))return;const t=this.canvasManager.getCanvas();t&&(this.offsetDrag=new tn(t,e=>{this.currentTime-=Math.round(e/this.timeSpacingInPixels*this.timeSpacing),this.render()},()=>{this.stopCenterTimeAnimation()}),this.wheelZoom=new en(t,()=>this.timeSpacing,(e,i)=>{const n=this.getTimeAtCanvasX(i);this.timeSpacing=e,this.setTimeAtCanvasX(n,i),this.render()}),this.centerTime=Date.now(),this.mouseTimeReporter=new sn(t,e=>this.getTimeAtCanvasX(e),e=>{var i;return(i=this.onMouseTimeChange)==null?void 0:i.call(this,e)}),this.render())}render(){var i;const s=this.canvasManager.getContext();if(!s)return;this.renderBackground();const{width:t,height:e}=this.canvasManager.getSize();(i=this.onDrawOverlay)==null||i.call(this,s,t,e),this.renderAxis()}renderBackground(){const s=this.canvasManager.getContext(),{width:t,height:e}=this.canvasManager.getSize(),{backgroundColor:i}=this.styleConfig;s&&(s.clearRect(0,0,t,e),s.fillStyle=i,s.fillRect(0,0,t,e))}renderAxis(){const s=this.canvasManager.getContext();if(!s)return;const{timeSpacing:t,timeSpacingInPixels:e,styleConfig:{textFont:i,axisColor:n},tickConfig:{minorTicksPerMajor:o,heightMajor:a,heightMinor:l,labelOffsetY:c}}=this,{startTimeMs:h,startX:u,endX:f}=this.axisDrawingRange;s.fillStyle=n,s.font=i,s.textAlign="center",s.textBaseline="top";const m=e/o;let p=h,g=0,y=u;for(;y<=f;){const w=g%o===0,P=w?a:l;if(s.fillRect(y,0,1,P),w){const b=Le(p,"MM-DD hh:mm:ss");s.fillText(b,y,c),p+=t}y+=m,g++}}get axisDrawingRange(){const{currentTime:s,timeSpacing:t,timeSpacingInPixels:e}=this,{width:i}=this.canvasManager.getSize(),n=s%t,o=Math.round(n/t*e),a=s-n,l=i/e,c=Math.ceil((s+l*t)/t)*t,h=-o+(c-a)/t*e;return{startTimeMs:a,startX:-o,endX:h}}get centerTime(){const{width:s}=this.canvasManager.getSize();return this.currentTime+s/2/this.timeSpacingInPixels*this.timeSpacing}set centerTime(s){const{width:t}=this.canvasManager.getSize(),{timeSpacing:e,timeSpacingInPixels:i}=this;this.currentTime=s-t/2/i*e}getTimeAtCanvasX(s){return this.currentTime+s/this.timeSpacingInPixels*this.timeSpacing}setTimeAtCanvasX(s,t){this.currentTime=s-t/this.timeSpacingInPixels*this.timeSpacing}getCanvasXAtTime(s){return(s-this.currentTime)/this.timeSpacing*this.timeSpacingInPixels}animateCenterTimeTo(s,t){const e=this.centerTime,i=e-s;if(!i)return;const n=++this.centerTimeAnimationRunId,o=(t==null?void 0:t.durationFrames)??(()=>{const h=Math.abs(i)/this.timeSpacing*.25,u=Math.min(5,Math.max(.5,h));return Math.max(1,Math.round(u*60))})(),a=(t==null?void 0:t.curve)??nn.easeInOutQuad;Ie(0,1,o,l=>{const c=a(Math.min(1,Math.max(0,l)));n===this.centerTimeAnimationRunId&&(this.centerTime=e-i*c,this.render())},4)}stopCenterTimeAnimation(){this.centerTimeAnimationRunId++}destroy(){var s,t,e;(s=this.offsetDrag)==null||s.destroy(),(t=this.wheelZoom)==null||t.destroy(),(e=this.mouseTimeReporter)==null||e.destroy(),this.canvasManager.destroy()}}class on extends rn{resolveFillStyle(s,t){if(!t)return;const e=this.canvasManager.getContext();if(!e)return;if(typeof t=="string")return t;const i=e.createLinearGradient(s.x+s.width*t.x1,s.y+s.height*t.y1,s.x+s.width*t.x2,s.y+s.height*t.y2);return t.colorStops.forEach(({color:n,offset:o})=>i.addColorStop(o,n)),i}drawTimeRangeRoundedRect(s){const t=this.canvasManager.getContext();if(!t)return;const e=this.canvasManager.getSize(),{startTimeMs:i,endTimeMs:n,y:o=1,height:a=e.height-1,radius:l=10,fillStyle:c="#2080f029",strokeStyle:h="#2080f0",lineWidth:u=1}=s,f=this.getCanvasXAtTime(i),p=this.getCanvasXAtTime(n)-f;if(!p)return;const g=this.resolveFillStyle({x:f,y:o,width:p,height:a},c);g&&(t.fillStyle=g),h&&(t.strokeStyle=h),t.lineWidth=u,t.beginPath(),typeof t.roundRect=="function"?t.roundRect(f,o,p,a+o,l):t.rect(f,o,p,a+o),c&&t.fill(),h&&t.stroke()}}function Lt(r){if(typeof r=="string"){const s=document.querySelector(r);if(s)return s;console.error(`Element "${r}" not found`)}else return r||document.documentElement}function _e(r){const s=Lt(r);return s?s.requestFullscreen?s.requestFullscreen():s.mozRequestFullScreen?s.mozRequestFullScreen():s.webkitRequestFullscreen?s.webkitRequestFullscreen():s.msRequestFullscreen?s.msRequestFullscreen():Promise.reject("No Fullscreen API"):Promise.reject("No Element")}function Se(){const r=document;return document.exitFullscreen?document.exitFullscreen():r.mozCancelFullScreen?r.mozCancelFullScreen():r.webkitExitFullscreen?r.webkitExitFullscreen():r.msExitFullscreen?r.msExitFullscreen():Promise.reject("No ExitFullscreen API")}function At(r){const s=Lt(r),t=document,e=document.fullscreenElement||t.webkitFullscreenElement||t.mozFullScreenElement||t.msFullscreenElement;return s==e||!r&&window.innerWidth==screen.width&&window.innerHeight==screen.height}function an(r){if(r=Lt(r),!!r)return function(){At(r)?Se():_e(r)}}function ln(r,s){const t=Lt(s);if(!t)return;const e=()=>{r(At(t))};return document.addEventListener("fullscreenchange",e),document.addEventListener("webkitfullscreenchange",e),document.addEventListener("mozfullscreenchange",e),document.addEventListener("MSFullscreenChange",e),e(),()=>{document.removeEventListener("fullscreenchange",e),document.removeEventListener("webkitfullscreenchange",e),document.removeEventListener("mozfullscreenchange",e),document.removeEventListener("MSFullscreenChange",e)}}class cn{constructor(s,t){d(this,"targetElement");d(this,"onFullscreenChange");d(this,"detachFullscreenListeners");this.init(s),this.onFullscreenChange=t,this.attachFullscreenChangeListeners()}init(s){this.targetElement=Lt(s)}enter(){this.targetElement&&_e(this.targetElement)}exit(){this.targetElement&&Se()}toggle(){this.targetElement&&(At(this.targetElement)?this.exit():this.enter())}attachFullscreenChangeListeners(){const s=()=>{!this.targetElement||!this.onFullscreenChange||this.onFullscreenChange(At(this.targetElement))};document.addEventListener("fullscreenchange",s),document.addEventListener("webkitfullscreenchange",s),document.addEventListener("mozfullscreenchange",s),document.addEventListener("MSFullscreenChange",s),s(),this.detachFullscreenListeners=()=>{document.removeEventListener("fullscreenchange",s),document.removeEventListener("webkitfullscreenchange",s),document.removeEventListener("mozfullscreenchange",s),document.removeEventListener("MSFullscreenChange",s)}}destroy(){var s;(s=this.detachFullscreenListeners)==null||s.call(this),this.detachFullscreenListeners=void 0,this.targetElement=void 0,this.onFullscreenChange=void 0}}function hn(r){const s=be(r,100);let t=0,e=0;return function(i){const n=i.target;if(!n||!(n instanceof Element))return;const{scrollTop:o,scrollHeight:a,clientHeight:l,scrollLeft:c,scrollWidth:h,clientWidth:u}=n;function f(){if(t==o)return;const p=t>o;if(t=o,p)return;a-o-l<=1&&s("vertical")}function m(){if(e==c)return;const p=e>c;if(e=c,p)return;h-c-u<=1&&s("horizontal")}f(),m()}}function un(r,s,t){const{isClickAllowed:e,uiLibrary:i=["naiveUI","ElementPlus","Element"]}=t||{},n=function(l){const c=[];for(const h in l)Object.hasOwnProperty.call(l,h)&&i.includes(h)&&c.push(...l[h]);return c}({naiveUI:[".v-binder-follower-container",".n-image-preview-container",".n-modal-container"],ElementPlus:[".el-popper"],Element:[".el-popper"]});function o(){s(),document.removeEventListener("mousedown",a)}function a(l){if(e){const u=e(l);if(u)return;if(u===!1)return o()}const c=l.target;if(!(c instanceof Element)||!c.isConnected)return;r.concat(n).some(u=>!!(c!=null&&c.closest(u)))||o()}requestAnimationFrame(()=>document.addEventListener("mousedown",a))}var j,ft,mt,Pt,bt,J,K,st,Ct;class dn{constructor(){A(this,j);A(this,ft,!1);A(this,mt,{});A(this,Pt,0);A(this,bt,0);A(this,J,0);A(this,K,0);A(this,st);A(this,Ct)}init(s,t){this.finish(),M(this,j,s),M(this,st,t==null?void 0:t.limit),M(this,Ct,t==null?void 0:t.dragDom),M(this,mt,{mousedown:this.mousedown.bind(this),mousemove:this.mousemove.bind(this),mouseup:this.mouseup.bind(this)}),this.bindOrUnbindEvent("bind")}finish(){this.bindOrUnbindEvent("unbind")}bindOrUnbindEvent(s){const t=s==="bind"?"addEventListener":"removeEventListener";if(!x(this,j))return console.error("No DOM");x(this,j)[t]("mousedown",x(this,mt).mousedown),document[t]("mousemove",x(this,mt).mousemove),document[t]("mouseup",x(this,mt).mouseup)}alterLocation(){if(!x(this,j))return console.error("No DOM");x(this,st)&&(M(this,J,Math.min(x(this,J),x(this,st).max.top)),M(this,J,Math.max(x(this,J),x(this,st).min.top)),M(this,K,Math.min(x(this,K),x(this,st).max.left)),M(this,K,Math.max(x(this,K),x(this,st).min.left))),x(this,j).style.setProperty("--top",x(this,J)+"px"),x(this,j).style.setProperty("--left",x(this,K)+"px")}mousedown(s){if(!x(this,j))return console.error("No DOM");if(x(this,Ct)&&s.target!=x(this,Ct))return;document.body.classList.add("no-select"),M(this,ft,!0);const t=x(this,j).getBoundingClientRect(),{pageX:e,pageY:i}=s;M(this,Pt,e),M(this,bt,i),M(this,J,t.y),M(this,K,t.x)}mousemove(s){const{pageX:t,pageY:e}=s;x(this,ft)&&(M(this,J,x(this,J)+(e-x(this,bt))),M(this,K,x(this,K)+(t-x(this,Pt))),M(this,Pt,t),M(this,bt,e),this.alterLocation())}mouseup(){x(this,ft)&&(M(this,ft,!1),document.body.classList.remove("no-select"))}}j=new WeakMap,ft=new WeakMap,mt=new WeakMap,Pt=new WeakMap,bt=new WeakMap,J=new WeakMap,K=new WeakMap,st=new WeakMap,Ct=new WeakMap;var q,gt,pt,_t,St,$,Z,z,Et,Mt;class fn{constructor(){A(this,q);A(this,gt,!1);A(this,pt,{});A(this,_t,0);A(this,St,0);A(this,$,0);A(this,Z,0);A(this,z);A(this,Et);A(this,Mt)}init(s,t={}){this.finish(),M(this,q,s),M(this,z,t.limit),M(this,Et,t.update_move),M(this,Mt,t.update_up),M(this,pt,{mousedown:this.mousedown.bind(this),mousemove:this.mousemove.bind(this),mouseup:this.mouseup.bind(this)}),this.bindOrUnbindEvent("bind")}finish(){this.bindOrUnbindEvent("unbind")}bindOrUnbindEvent(s){const t=s==="bind"?"addEventListener":"removeEventListener";if(!x(this,q))return console.error("No DOM");x(this,q)[t]("mousedown",x(this,pt).mousedown),document[t]("mousemove",x(this,pt).mousemove),document[t]("mouseup",x(this,pt).mouseup)}updateValue(){const s={top:x(this,$),left:x(this,Z),percentage:{top:0,left:0}};if(x(this,z)){const t=e=>x(this,z)?(s[e]-x(this,z).min[e])/(x(this,z).max[e]-x(this,z).min[e]):0;s.percentage={top:t("top")||0,left:t("left")||0}}return s}alterLocation(){if(!x(this,q))return console.error("No DOM");x(this,z)&&(M(this,$,Math.min(x(this,$),x(this,z).max.top)),M(this,$,Math.max(x(this,$),x(this,z).min.top)),M(this,Z,Math.min(x(this,Z),x(this,z).max.left)),M(this,Z,Math.max(x(this,Z),x(this,z).min.left))),x(this,Et)&&x(this,Et).call(this,this.updateValue()),x(this,q).style.setProperty("--top",x(this,$)+"px"),x(this,q).style.setProperty("--left",x(this,Z)+"px")}mousedown(s){if(!x(this,q))return console.error("No DOM");document.body.classList.add("no-select"),M(this,gt,!0);const t=x(this,q).getBoundingClientRect();M(this,St,t.y),M(this,_t,t.x);const{pageX:e,pageY:i}=s;M(this,$,i-x(this,St)),M(this,Z,e-x(this,_t)),this.alterLocation()}mousemove(s){const{pageX:t,pageY:e}=s;x(this,gt)&&(M(this,$,e-x(this,St)),M(this,Z,t-x(this,_t)),this.alterLocation())}mouseup(){x(this,gt)&&(M(this,gt,!1),document.body.classList.remove("no-select"),x(this,Mt)&&x(this,Mt).call(this,this.updateValue()))}}q=new WeakMap,gt=new WeakMap,pt=new WeakMap,_t=new WeakMap,St=new WeakMap,$=new WeakMap,Z=new WeakMap,z=new WeakMap,Et=new WeakMap,Mt=new WeakMap;function mn(r,s){if(typeof r=="number")return r;if(/px/.test(r))return Number(r.replace(/px/,""))||0;const t=document.createElement("div");t.style.width=r,s=s||document.body,s.appendChild(t);const e=t.getBoundingClientRect().width;return s.removeChild(t),e}function gn(r,s){if(!r)return;let t,e;if(typeof s=="string"){const n=document.querySelector(s);if(!n)return;const o=n.getBoundingClientRect();t=o.width,e=o.height}else if(Array.isArray(s))t=s[0],e=s[1];else{const n=s.getBoundingClientRect();t=n.width,e=n.height}const i=t/e;return i>r?[r*e,e]:i<r?[t,t/r]:[t,e]}function pn(r,s=5e3){return new Promise((t,e)=>{const i=new Image;i.src=r;const n=setTimeout(()=>{e(new Error("图片加载超时")),i.onload=null,i.onerror=null},s);i.onload=()=>{clearTimeout(n);const o=i.naturalWidth,a=i.naturalHeight,l=o/a;t([i,l])},i.onerror=()=>{clearTimeout(n),e(new Error("图片加载失败"))},i.crossOrigin="Anonymous"})}function vn(r){const t=document.getElementById(r).querySelectorAll("img"),e=t.length,i=[];let n=0;return e===0?Promise.resolve({allLoaded:!0,loaded:0,failed:0,total:0,errors:[]}):new Promise(o=>{const a=()=>{n===e&&o({allLoaded:i.length===0,loaded:e-i.length,failed:i.length,total:e,errors:i})};t.forEach(l=>{if(l.complete){l.naturalWidth===0&&i.push(l),n++,a();return}l.addEventListener("load",()=>{n++,a()},{once:!0}),l.addEventListener("error",()=>{i.push(l),n++,a()},{once:!0})})})}function yn(r){return new Promise((s,t)=>{fetch(r).then(e=>s(e.text())).catch(e=>{console.error("Error fetching :",e),t(e)})})}function ii(r){const{href:s,fileName:t,onProgress:e,timeout:i=3e4,autoDownload:n=!0}=r;let o,a=!1,l=null,c;const h=t||Jt(s,"downloaded_file");c=decodeURIComponent(h);const u=()=>{if(!l)return;const g=URL.createObjectURL(l),y=document.createElement("a");y.href=g,y.download=c,y.click(),URL.revokeObjectURL(g)};return{promise:new Promise((g,y)=>{try{o=new XMLHttpRequest,o.open("GET",s),o.responseType="blob",o.timeout=i,o.ontimeout=()=>{a||y(new Error(`请求超时(已超过${i/1e3}秒)`))},o.addEventListener("progress",w=>{if(w.lengthComputable&&!a){const P=w.loaded/w.total*100;e==null||e(Number(P.toFixed(2)))}}),o.addEventListener("load",()=>{a||(o.status>=200&&o.status<300?(l=o.response,n&&u(),g(o.response)):y(new Error(`下载失败,状态码: ${o.status}`)))}),o.addEventListener("error",()=>{a||y(new Error("网络错误,下载失败"))}),o.addEventListener("abort",()=>{a||(a=!0,y(new Error("下载已被中止")))}),o.send()}catch(w){a||y(w)}}),abort:()=>!a&&o.abort(),download:()=>{!a&&l&&u()}}}function wn(r,s,t){if(!t){let n=s.replace(/^[^.]+./,"");n=n==s?"text/plain":"application/"+n,t={type:n}}const e=new Blob(r,t),i=URL.createObjectURL(e);ii({href:i,fileName:s})}const xn=Math.PI/2,ne=Math.PI/180,re=6378137,Pn=85.05112878;function bn(r,s){const t=Math.max(Math.min(r,180),-180),e=Math.max(Math.min(s,Pn),-85.05112878),i=t*ne*re,n=e*ne,o=Math.log(Math.tan(Math.PI/4+n/2))*re;return[i,o]}function Cn(r,s){const t=r/re/ne,e=(2*Math.atan(Math.exp(s/re))-xn)/ne;return[t,e]}function si(r,s,t){const[e,i]=r,[n,o]=s,[a,l]=t,c=(a-n)**2+(l-o)**2;if(c===0)return Math.sqrt((e-n)**2+(i-o)**2);let h=((e-n)*(a-n)+(i-o)*(l-o))/c;return h=Math.max(0,Math.min(1,h)),Math.sqrt((e-(n+h*(a-n)))**2+(i-(o+h*(l-o)))**2)}function _n(r,s,t,e,i,n=1,o=1){const a=r+t*Math.cos(e)*n,l=s+t*Math.sin(e)*o,c=r+t*Math.cos(i)*n,h=s+t*Math.sin(i)*o;return[[a,l],[c,h]]}function xe(r,s,t,e){return Math.hypot(Math.abs(t-r),Math.abs(e-s))}function Ee(r,s,t,e){const i=(r+t)/2,n=(s+e)/2;return{x:i,y:n}}function Sn(r,s,t,e){const[i,n]=r,[o,a]=s;let l=1/0;if(o!==0){const c=o>0?(t-i)/o:-i/o;c>0&&(l=Math.min(l,c))}if(a!==0){const c=a>0?(e-n)/a:-n/a;c>0&&(l=Math.min(l,c))}return l===1/0?r:[i+o*l,n+a*l]}const En=new Set(["sin","cos","tan","asin","acos","atan","atan2"]),Mn=new Proxy(Math,{get(r,s){return En.has(s)?function(...t){const e=t.map(i=>i/180*Math.PI);return r[s](...e)}:r[s]},set(){throw new Error("DegreeMath 是只读的,不能修改属性")},deleteProperty(){throw new Error("DegreeMath 是只读的,不能删除属性")}});class xt{constructor(s,t){d(this,"resolve");d(this,"reject");this.resolve=s,this.reject=t}run(s){var t,e;return s instanceof Promise?s.then(i=>{var n;return(n=this.resolve)==null||n.call(this),i}).catch(i=>{var n;return(n=this.reject)==null||n.call(this),Promise.reject(i)}):s?(t=this.resolve)==null||t.call(this):(e=this.reject)==null||e.call(this),s}}class Dn extends xt{constructor(s){super(),this.resolve=s}warning(...s){const t=()=>{var e,i;return(i=(e=vt.tips).warning)==null?void 0:i.call(e,...s)};return new xt(this.resolve,t)}error(...s){const t=()=>{var e,i;return(i=(e=vt.tips).error)==null?void 0:i.call(e,...s)};return new xt(this.resolve,t)}}class Rn extends xt{constructor(s){super(),this.reject=s}info(...s){const t=()=>{var e,i;return(i=(e=vt.tips).info)==null?void 0:i.call(e,...s)};return new xt(t,this.reject)}success(...s){const t=()=>{var e,i;return(i=(e=vt.tips).success)==null?void 0:i.call(e,...s)};return new xt(t,this.reject)}}const B=class B{constructor(){if(new.target===B)throw new Error("请直接使用静态方法,而不是实例化此类")}static register(s,t){if(typeof t!="function")return console.error("TipHandler must be a function");B.tips[s]=t}static resolveTip(s){return function(...t){const e=()=>{var i,n;return(n=(i=B.tips)[s])==null?void 0:n.call(i,...t)};return new Dn(e)}}static rejectTip(s){return function(...t){const e=()=>{var i,n;return(n=(i=B.tips)[s])==null?void 0:n.call(i,...t)};return new Rn(e)}}};d(B,"tips",{info:void 0,success:void 0,warning:void 0,error:void 0}),d(B,"info",B.resolveTip("info")),d(B,"success",B.resolveTip("success")),d(B,"warning",B.rejectTip("warning")),d(B,"error",B.rejectTip("error"));let vt=B;exports.EXTENSION_TO_MIME=Ae;exports.FILE_EXTENSIONS=Ut;exports.PAPER_SIZE_DEFINITIONS=Pe;exports.PAPER_SIZE_OPTIONS=ai;exports.UNIT_LABELS=fe;exports.WINDOW_TARGET=oi;exports._Animate_CreateOscillator=li;exports._Animate_CubicBezier=ci;exports._Animate_NumericTransition=Ie;exports._Animate_Schedule=Vt;exports._Blob_ConvertDataToImageUrl=hi;exports._Browser_CalculatePrintableArea=Li;exports._Browser_CopyToClipboard=Ii;exports._Browser_GetFrameRate=Ai;exports._Browser_IdleDetection=Ni;exports._Browser_SameOriginTabManager=Rt;exports._Browser_SoundEffects=Oi;exports._Browser_WebSocketClient=Ti;exports._Canvas_Axis=I;exports._Canvas_TimeAxis=on;exports._Element_CalculateCanvasSize=gn;exports._Element_CheckImagesLoaded=vn;exports._Element_CloseOnOutsideClick=un;exports._Element_Drag=dn;exports._Element_EnterFullscreen=_e;exports._Element_ExitFullscreen=Se;exports._Element_Fullscreen=an;exports._Element_FullscreenController=cn;exports._Element_FullscreenObserver=ln;exports._Element_GetOtherSizeInPixels=mn;exports._Element_IsFullscreen=At;exports._Element_LoadImage=pn;exports._Element_LocalDrag=fn;exports._Element_ScrollEndListener=hn;exports._File_CreateAndDownload=wn;exports._File_Download=ii;exports._File_Read=yn;exports._Format_CamelCase=gi;exports._Format_CapitalizeFirstLetter=ui;exports._Format_ChunkArray=wi;exports._Format_ExcludeSubstring=pi;exports._Format_FileSize=mi;exports._Format_HrefName=Jt;exports._Format_MillisecondToReadable=yi;exports._Format_NumberWithCommas=Qt;exports._Format_NumberWithUnit=fi;exports._Format_Percentage=di;exports._Format_Timestamp=Le;exports._Format_ToggleInvisibleChars=vi;exports._Math_CalculateDistance2D=xe;exports._Math_Degree=Mn;exports._Math_GetArcPoints=_n;exports._Math_GetBoundaryIntersection=Sn;exports._Math_GetMidpoint=Ee;exports._Math_LngLatToPlane=bn;exports._Math_PlaneToLngLat=Cn;exports._Math_PointToLineDistance=si;exports._Tip=vt;exports._Utility_Clone=Ue;exports._Utility_Debounce=be;exports._Utility_ExecuteWhenIdle=Ei;exports._Utility_GenerateUUID=te;exports._Utility_GetTargetByPath=Di;exports._Utility_MergeObjects=rt;exports._Utility_RotateList=ki;exports._Utility_SetTargetByPath=Ri;exports._Utility_Sleep=Vi;exports._Utility_Throttle=Mi;exports._Utility_TimeConsumption=Ge;exports._Utility_WaitForCondition=ze;exports._Valid_CheckConnectionWithXHR=_i;exports._Valid_DataType=Kt;exports._Valid_DoesInfiniteLineIntersectRectangle=bi;exports._Valid_FileTypeChecker=me;exports._Valid_Is2DNumberArray=Ot;exports._Valid_IsInMargin=xi;exports._Valid_IsNumberArray=oe;exports._Valid_IsPointInPolygon=Pi;exports._Valid_IsSecureContext=Ci;
|
|
9
|
+
*/var ge=9e15,ut=1e9,pe="0123456789abcdef",ee="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",ie="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",ve={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-9e15,maxE:ge,crypto:!1},Ye,nt,S=!0,ae="[DecimalError] ",ht=ae+"Invalid argument: ",We=ae+"Precision limit exceeded",je=ae+"crypto unavailable",$e="[object Decimal]",F=Math.floor,I=Math.pow,Fi=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Bi=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Ui=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,qe=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Q=1e7,_=7,zi=9007199254740991,Gi=ee.length-1,ye=ie.length-1,v={toStringTag:$e};v.absoluteValue=v.abs=function(){var r=new this.constructor(this);return r.s<0&&(r.s=1),C(r)};v.ceil=function(){return C(new this.constructor(this),this.e+1,2)};v.clampedTo=v.clamp=function(r,s){var t,e=this,i=e.constructor;if(r=new i(r),s=new i(s),!r.s||!s.s)return new i(NaN);if(r.gt(s))throw Error(ht+s);return t=e.cmp(r),t<0?r:e.cmp(s)>0?s:new i(e)};v.comparedTo=v.cmp=function(r){var s,t,e,i,n=this,o=n.d,a=(r=new n.constructor(r)).d,l=n.s,c=r.s;if(!o||!a)return!l||!c?NaN:l!==c?l:o===a?0:!o^l<0?1:-1;if(!o[0]||!a[0])return o[0]?l:a[0]?-c:0;if(l!==c)return l;if(n.e!==r.e)return n.e>r.e^l<0?1:-1;for(e=o.length,i=a.length,s=0,t=e<i?e:i;s<t;++s)if(o[s]!==a[s])return o[s]>a[s]^l<0?1:-1;return e===i?0:e>i^l<0?1:-1};v.cosine=v.cos=function(){var r,s,t=this,e=t.constructor;return t.d?t.d[0]?(r=e.precision,s=e.rounding,e.precision=r+Math.max(t.e,t.sd())+_,e.rounding=1,t=Xi(e,ti(e,t)),e.precision=r,e.rounding=s,C(nt==2||nt==3?t.neg():t,r,s,!0)):new e(1):new e(NaN)};v.cubeRoot=v.cbrt=function(){var r,s,t,e,i,n,o,a,l,c,h=this,u=h.constructor;if(!h.isFinite()||h.isZero())return new u(h);for(S=!1,n=h.s*I(h.s*h,1/3),!n||Math.abs(n)==1/0?(t=N(h.d),r=h.e,(n=(r-t.length+1)%3)&&(t+=n==1||n==-2?"0":"00"),n=I(t,1/3),r=F((r+1)/3)-(r%3==(r<0?-1:2)),n==1/0?t="5e"+r:(t=n.toExponential(),t=t.slice(0,t.indexOf("e")+1)+r),e=new u(t),e.s=h.s):e=new u(n.toString()),o=(r=u.precision)+3;;)if(a=e,l=a.times(a).times(a),c=l.plus(h),e=V(c.plus(h).times(a),c.plus(l),o+2,1),N(a.d).slice(0,o)===(t=N(e.d)).slice(0,o))if(t=t.slice(o-3,o+1),t=="9999"||!i&&t=="4999"){if(!i&&(C(a,r+1,0),a.times(a).times(a).eq(h))){e=a;break}o+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(C(e,r+1,1),s=!e.times(e).times(e).eq(h));break}return S=!0,C(e,r,u.rounding,s)};v.decimalPlaces=v.dp=function(){var r,s=this.d,t=NaN;if(s){if(r=s.length-1,t=(r-F(this.e/_))*_,r=s[r],r)for(;r%10==0;r/=10)t--;t<0&&(t=0)}return t};v.dividedBy=v.div=function(r){return V(this,new this.constructor(r))};v.dividedToIntegerBy=v.divToInt=function(r){var s=this,t=s.constructor;return C(V(s,new t(r),0,1,1),t.precision,t.rounding)};v.equals=v.eq=function(r){return this.cmp(r)===0};v.floor=function(){return C(new this.constructor(this),this.e+1,3)};v.greaterThan=v.gt=function(r){return this.cmp(r)>0};v.greaterThanOrEqualTo=v.gte=function(r){var s=this.cmp(r);return s==1||s===0};v.hyperbolicCosine=v.cosh=function(){var r,s,t,e,i,n=this,o=n.constructor,a=new o(1);if(!n.isFinite())return new o(n.s?1/0:NaN);if(n.isZero())return a;t=o.precision,e=o.rounding,o.precision=t+Math.max(n.e,n.sd())+4,o.rounding=1,i=n.d.length,i<32?(r=Math.ceil(i/3),s=(1/ce(4,r)).toString()):(r=16,s="2.3283064365386962890625e-10"),n=Dt(o,1,n.times(s),new o(1),!0);for(var l,c=r,h=new o(8);c--;)l=n.times(n),n=a.minus(l.times(h.minus(l.times(h))));return C(n,o.precision=t,o.rounding=e,!0)};v.hyperbolicSine=v.sinh=function(){var r,s,t,e,i=this,n=i.constructor;if(!i.isFinite()||i.isZero())return new n(i);if(s=n.precision,t=n.rounding,n.precision=s+Math.max(i.e,i.sd())+4,n.rounding=1,e=i.d.length,e<3)i=Dt(n,2,i,i,!0);else{r=1.4*Math.sqrt(e),r=r>16?16:r|0,i=i.times(1/ce(5,r)),i=Dt(n,2,i,i,!0);for(var o,a=new n(5),l=new n(16),c=new n(20);r--;)o=i.times(i),i=i.times(a.plus(o.times(l.times(o).plus(c))))}return n.precision=s,n.rounding=t,C(i,s,t,!0)};v.hyperbolicTangent=v.tanh=function(){var r,s,t=this,e=t.constructor;return t.isFinite()?t.isZero()?new e(t):(r=e.precision,s=e.rounding,e.precision=r+7,e.rounding=1,V(t.sinh(),t.cosh(),e.precision=r,e.rounding=s)):new e(t.s)};v.inverseCosine=v.acos=function(){var r=this,s=r.constructor,t=r.abs().cmp(1),e=s.precision,i=s.rounding;return t!==-1?t===0?r.isNeg()?tt(s,e,i):new s(0):new s(NaN):r.isZero()?tt(s,e+4,i).times(.5):(s.precision=e+6,s.rounding=1,r=new s(1).minus(r).div(r.plus(1)).sqrt().atan(),s.precision=e,s.rounding=i,r.times(2))};v.inverseHyperbolicCosine=v.acosh=function(){var r,s,t=this,e=t.constructor;return t.lte(1)?new e(t.eq(1)?0:NaN):t.isFinite()?(r=e.precision,s=e.rounding,e.precision=r+Math.max(Math.abs(t.e),t.sd())+4,e.rounding=1,S=!1,t=t.times(t).minus(1).sqrt().plus(t),S=!0,e.precision=r,e.rounding=s,t.ln()):new e(t)};v.inverseHyperbolicSine=v.asinh=function(){var r,s,t=this,e=t.constructor;return!t.isFinite()||t.isZero()?new e(t):(r=e.precision,s=e.rounding,e.precision=r+2*Math.max(Math.abs(t.e),t.sd())+6,e.rounding=1,S=!1,t=t.times(t).plus(1).sqrt().plus(t),S=!0,e.precision=r,e.rounding=s,t.ln())};v.inverseHyperbolicTangent=v.atanh=function(){var r,s,t,e,i=this,n=i.constructor;return i.isFinite()?i.e>=0?new n(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(r=n.precision,s=n.rounding,e=i.sd(),Math.max(e,r)<2*-i.e-1?C(new n(i),r,s,!0):(n.precision=t=e-i.e,i=V(i.plus(1),new n(1).minus(i),t+r,1),n.precision=r+4,n.rounding=1,i=i.ln(),n.precision=r,n.rounding=s,i.times(.5))):new n(NaN)};v.inverseSine=v.asin=function(){var r,s,t,e,i=this,n=i.constructor;return i.isZero()?new n(i):(s=i.abs().cmp(1),t=n.precision,e=n.rounding,s!==-1?s===0?(r=tt(n,t+4,e).times(.5),r.s=i.s,r):new n(NaN):(n.precision=t+6,n.rounding=1,i=i.div(new n(1).minus(i.times(i)).sqrt().plus(1)).atan(),n.precision=t,n.rounding=e,i.times(2)))};v.inverseTangent=v.atan=function(){var r,s,t,e,i,n,o,a,l,c=this,h=c.constructor,u=h.precision,f=h.rounding;if(c.isFinite()){if(c.isZero())return new h(c);if(c.abs().eq(1)&&u+4<=ye)return o=tt(h,u+4,f).times(.25),o.s=c.s,o}else{if(!c.s)return new h(NaN);if(u+4<=ye)return o=tt(h,u+4,f).times(.5),o.s=c.s,o}for(h.precision=a=u+10,h.rounding=1,t=Math.min(28,a/_+2|0),r=t;r;--r)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(S=!1,s=Math.ceil(a/_),e=1,l=c.times(c),o=new h(c),i=c;r!==-1;)if(i=i.times(l),n=o.minus(i.div(e+=2)),i=i.times(l),o=n.plus(i.div(e+=2)),o.d[s]!==void 0)for(r=s;o.d[r]===n.d[r]&&r--;);return t&&(o=o.times(2<<t-1)),S=!0,C(o,h.precision=u,h.rounding=f,!0)};v.isFinite=function(){return!!this.d};v.isInteger=v.isInt=function(){return!!this.d&&F(this.e/_)>this.d.length-2};v.isNaN=function(){return!this.s};v.isNegative=v.isNeg=function(){return this.s<0};v.isPositive=v.isPos=function(){return this.s>0};v.isZero=function(){return!!this.d&&this.d[0]===0};v.lessThan=v.lt=function(r){return this.cmp(r)<0};v.lessThanOrEqualTo=v.lte=function(r){return this.cmp(r)<1};v.logarithm=v.log=function(r){var s,t,e,i,n,o,a,l,c=this,h=c.constructor,u=h.precision,f=h.rounding,m=5;if(r==null)r=new h(10),s=!0;else{if(r=new h(r),t=r.d,r.s<0||!t||!t[0]||r.eq(1))return new h(NaN);s=r.eq(10)}if(t=c.d,c.s<0||!t||!t[0]||c.eq(1))return new h(t&&!t[0]?-1/0:c.s!=1?NaN:t?0:1/0);if(s)if(t.length>1)n=!0;else{for(i=t[0];i%10===0;)i/=10;n=i!==1}if(S=!1,a=u+m,o=lt(c,a),e=s?se(h,a+10):lt(r,a),l=V(o,e,a,1),Ot(l.d,i=u,f))do if(a+=10,o=lt(c,a),e=s?se(h,a+10):lt(r,a),l=V(o,e,a,1),!n){+N(l.d).slice(i+1,i+15)+1==1e14&&(l=C(l,u+1,0));break}while(Ot(l.d,i+=10,f));return S=!0,C(l,u,f)};v.minus=v.sub=function(r){var s,t,e,i,n,o,a,l,c,h,u,f,m=this,p=m.constructor;if(r=new p(r),!m.d||!r.d)return!m.s||!r.s?r=new p(NaN):m.d?r.s=-r.s:r=new p(r.d||m.s!==r.s?m:NaN),r;if(m.s!=r.s)return r.s=-r.s,m.plus(r);if(c=m.d,f=r.d,a=p.precision,l=p.rounding,!c[0]||!f[0]){if(f[0])r.s=-r.s;else if(c[0])r=new p(m);else return new p(l===3?-0:0);return S?C(r,a,l):r}if(t=F(r.e/_),h=F(m.e/_),c=c.slice(),n=h-t,n){for(u=n<0,u?(s=c,n=-n,o=f.length):(s=f,t=h,o=c.length),e=Math.max(Math.ceil(a/_),o)+2,n>e&&(n=e,s.length=1),s.reverse(),e=n;e--;)s.push(0);s.reverse()}else{for(e=c.length,o=f.length,u=e<o,u&&(o=e),e=0;e<o;e++)if(c[e]!=f[e]){u=c[e]<f[e];break}n=0}for(u&&(s=c,c=f,f=s,r.s=-r.s),o=c.length,e=f.length-o;e>0;--e)c[o++]=0;for(e=f.length;e>n;){if(c[--e]<f[e]){for(i=e;i&&c[--i]===0;)c[i]=Q-1;--c[i],c[e]+=Q}c[e]-=f[e]}for(;c[--o]===0;)c.pop();for(;c[0]===0;c.shift())--t;return c[0]?(r.d=c,r.e=le(c,t),S?C(r,a,l):r):new p(l===3?-0:0)};v.modulo=v.mod=function(r){var s,t=this,e=t.constructor;return r=new e(r),!t.d||!r.s||r.d&&!r.d[0]?new e(NaN):!r.d||t.d&&!t.d[0]?C(new e(t),e.precision,e.rounding):(S=!1,e.modulo==9?(s=V(t,r.abs(),0,3,1),s.s*=r.s):s=V(t,r,0,e.modulo,1),s=s.times(r),S=!0,t.minus(s))};v.naturalExponential=v.exp=function(){return we(this)};v.naturalLogarithm=v.ln=function(){return lt(this)};v.negated=v.neg=function(){var r=new this.constructor(this);return r.s=-r.s,C(r)};v.plus=v.add=function(r){var s,t,e,i,n,o,a,l,c,h,u=this,f=u.constructor;if(r=new f(r),!u.d||!r.d)return!u.s||!r.s?r=new f(NaN):u.d||(r=new f(r.d||u.s===r.s?u:NaN)),r;if(u.s!=r.s)return r.s=-r.s,u.minus(r);if(c=u.d,h=r.d,a=f.precision,l=f.rounding,!c[0]||!h[0])return h[0]||(r=new f(u)),S?C(r,a,l):r;if(n=F(u.e/_),e=F(r.e/_),c=c.slice(),i=n-e,i){for(i<0?(t=c,i=-i,o=h.length):(t=h,e=n,o=c.length),n=Math.ceil(a/_),o=n>o?n+1:o+1,i>o&&(i=o,t.length=1),t.reverse();i--;)t.push(0);t.reverse()}for(o=c.length,i=h.length,o-i<0&&(i=o,t=h,h=c,c=t),s=0;i;)s=(c[--i]=c[i]+h[i]+s)/Q|0,c[i]%=Q;for(s&&(c.unshift(s),++e),o=c.length;c[--o]==0;)c.pop();return r.d=c,r.e=le(c,e),S?C(r,a,l):r};v.precision=v.sd=function(r){var s,t=this;if(r!==void 0&&r!==!!r&&r!==1&&r!==0)throw Error(ht+r);return t.d?(s=Ze(t.d),r&&t.e+1>s&&(s=t.e+1)):s=NaN,s};v.round=function(){var r=this,s=r.constructor;return C(new s(r),r.e+1,s.rounding)};v.sine=v.sin=function(){var r,s,t=this,e=t.constructor;return t.isFinite()?t.isZero()?new e(t):(r=e.precision,s=e.rounding,e.precision=r+Math.max(t.e,t.sd())+_,e.rounding=1,t=Wi(e,ti(e,t)),e.precision=r,e.rounding=s,C(nt>2?t.neg():t,r,s,!0)):new e(NaN)};v.squareRoot=v.sqrt=function(){var r,s,t,e,i,n,o=this,a=o.d,l=o.e,c=o.s,h=o.constructor;if(c!==1||!a||!a[0])return new h(!c||c<0&&(!a||a[0])?NaN:a?o:1/0);for(S=!1,c=Math.sqrt(+o),c==0||c==1/0?(s=N(a),(s.length+l)%2==0&&(s+="0"),c=Math.sqrt(s),l=F((l+1)/2)-(l<0||l%2),c==1/0?s="5e"+l:(s=c.toExponential(),s=s.slice(0,s.indexOf("e")+1)+l),e=new h(s)):e=new h(c.toString()),t=(l=h.precision)+3;;)if(n=e,e=n.plus(V(o,n,t+2,1)).times(.5),N(n.d).slice(0,t)===(s=N(e.d)).slice(0,t))if(s=s.slice(t-3,t+1),s=="9999"||!i&&s=="4999"){if(!i&&(C(n,l+1,0),n.times(n).eq(o))){e=n;break}t+=4,i=1}else{(!+s||!+s.slice(1)&&s.charAt(0)=="5")&&(C(e,l+1,1),r=!e.times(e).eq(o));break}return S=!0,C(e,l,h.rounding,r)};v.tangent=v.tan=function(){var r,s,t=this,e=t.constructor;return t.isFinite()?t.isZero()?new e(t):(r=e.precision,s=e.rounding,e.precision=r+10,e.rounding=1,t=t.sin(),t.s=1,t=V(t,new e(1).minus(t.times(t)).sqrt(),r+10,0),e.precision=r,e.rounding=s,C(nt==2||nt==4?t.neg():t,r,s,!0)):new e(NaN)};v.times=v.mul=function(r){var s,t,e,i,n,o,a,l,c,h=this,u=h.constructor,f=h.d,m=(r=new u(r)).d;if(r.s*=h.s,!f||!f[0]||!m||!m[0])return new u(!r.s||f&&!f[0]&&!m||m&&!m[0]&&!f?NaN:!f||!m?r.s/0:r.s*0);for(t=F(h.e/_)+F(r.e/_),l=f.length,c=m.length,l<c&&(n=f,f=m,m=n,o=l,l=c,c=o),n=[],o=l+c,e=o;e--;)n.push(0);for(e=c;--e>=0;){for(s=0,i=l+e;i>e;)a=n[i]+m[e]*f[i-e-1]+s,n[i--]=a%Q|0,s=a/Q|0;n[i]=(n[i]+s)%Q|0}for(;!n[--o];)n.pop();return s?++t:n.shift(),r.d=n,r.e=le(n,t),S?C(r,u.precision,u.rounding):r};v.toBinary=function(r,s){return Ce(this,2,r,s)};v.toDecimalPlaces=v.toDP=function(r,s){var t=this,e=t.constructor;return t=new e(t),r===void 0?t:(z(r,0,ut),s===void 0?s=e.rounding:z(s,0,8),C(t,r+t.e+1,s))};v.toExponential=function(r,s){var t,e=this,i=e.constructor;return r===void 0?t=et(e,!0):(z(r,0,ut),s===void 0?s=i.rounding:z(s,0,8),e=C(new i(e),r+1,s),t=et(e,!0,r+1)),e.isNeg()&&!e.isZero()?"-"+t:t};v.toFixed=function(r,s){var t,e,i=this,n=i.constructor;return r===void 0?t=et(i):(z(r,0,ut),s===void 0?s=n.rounding:z(s,0,8),e=C(new n(i),r+i.e+1,s),t=et(e,!1,r+e.e+1)),i.isNeg()&&!i.isZero()?"-"+t:t};v.toFraction=function(r){var s,t,e,i,n,o,a,l,c,h,u,f,m=this,p=m.d,g=m.constructor;if(!p)return new g(m);if(c=t=new g(1),e=l=new g(0),s=new g(e),n=s.e=Ze(p)-m.e-1,o=n%_,s.d[0]=I(10,o<0?_+o:o),r==null)r=n>0?s:c;else{if(a=new g(r),!a.isInt()||a.lt(c))throw Error(ht+a);r=a.gt(s)?n>0?s:c:a}for(S=!1,a=new g(N(p)),h=g.precision,g.precision=n=p.length*_*2;u=V(a,s,0,1,1),i=t.plus(u.times(e)),i.cmp(r)!=1;)t=e,e=i,i=c,c=l.plus(u.times(i)),l=i,i=s,s=a.minus(u.times(i)),a=i;return i=V(r.minus(t),e,0,1,1),l=l.plus(i.times(c)),t=t.plus(i.times(e)),l.s=c.s=m.s,f=V(c,e,n,1).minus(m).abs().cmp(V(l,t,n,1).minus(m).abs())<1?[c,e]:[l,t],g.precision=h,S=!0,f};v.toHexadecimal=v.toHex=function(r,s){return Ce(this,16,r,s)};v.toNearest=function(r,s){var t=this,e=t.constructor;if(t=new e(t),r==null){if(!t.d)return t;r=new e(1),s=e.rounding}else{if(r=new e(r),s===void 0?s=e.rounding:z(s,0,8),!t.d)return r.s?t:r;if(!r.d)return r.s&&(r.s=t.s),r}return r.d[0]?(S=!1,t=V(t,r,0,s,1).times(r),S=!0,C(t)):(r.s=t.s,t=r),t};v.toNumber=function(){return+this};v.toOctal=function(r,s){return Ce(this,8,r,s)};v.toPower=v.pow=function(r){var s,t,e,i,n,o,a=this,l=a.constructor,c=+(r=new l(r));if(!a.d||!r.d||!a.d[0]||!r.d[0])return new l(I(+a,c));if(a=new l(a),a.eq(1))return a;if(e=l.precision,n=l.rounding,r.eq(1))return C(a,e,n);if(s=F(r.e/_),s>=r.d.length-1&&(t=c<0?-c:c)<=zi)return i=Qe(l,a,t,e),r.s<0?new l(1).div(i):C(i,e,n);if(o=a.s,o<0){if(s<r.d.length-1)return new l(NaN);if(r.d[s]&1||(o=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=o,a}return t=I(+a,c),s=t==0||!isFinite(t)?F(c*(Math.log("0."+N(a.d))/Math.LN10+a.e+1)):new l(t+"").e,s>l.maxE+1||s<l.minE-1?new l(s>0?o/0:0):(S=!1,l.rounding=a.s=1,t=Math.min(12,(s+"").length),i=we(r.times(lt(a,e+t)),e),i.d&&(i=C(i,e+5,1),Ot(i.d,e,n)&&(s=e+10,i=C(we(r.times(lt(a,s+t)),s),s+5,1),+N(i.d).slice(e+1,e+15)+1==1e14&&(i=C(i,e+1,0)))),i.s=o,S=!0,l.rounding=n,C(i,e,n))};v.toPrecision=function(r,s){var t,e=this,i=e.constructor;return r===void 0?t=et(e,e.e<=i.toExpNeg||e.e>=i.toExpPos):(z(r,1,ut),s===void 0?s=i.rounding:z(s,0,8),e=C(new i(e),r,s),t=et(e,r<=e.e||e.e<=i.toExpNeg,r)),e.isNeg()&&!e.isZero()?"-"+t:t};v.toSignificantDigits=v.toSD=function(r,s){var t=this,e=t.constructor;return r===void 0?(r=e.precision,s=e.rounding):(z(r,1,ut),s===void 0?s=e.rounding:z(s,0,8)),C(new e(t),r,s)};v.toString=function(){var r=this,s=r.constructor,t=et(r,r.e<=s.toExpNeg||r.e>=s.toExpPos);return r.isNeg()&&!r.isZero()?"-"+t:t};v.truncated=v.trunc=function(){return C(new this.constructor(this),this.e+1,1)};v.valueOf=v.toJSON=function(){var r=this,s=r.constructor,t=et(r,r.e<=s.toExpNeg||r.e>=s.toExpPos);return r.isNeg()?"-"+t:t};function N(r){var s,t,e,i=r.length-1,n="",o=r[0];if(i>0){for(n+=o,s=1;s<i;s++)e=r[s]+"",t=_-e.length,t&&(n+=at(t)),n+=e;o=r[s],e=o+"",t=_-e.length,t&&(n+=at(t))}else if(o===0)return"0";for(;o%10===0;)o/=10;return n+o}function z(r,s,t){if(r!==~~r||r<s||r>t)throw Error(ht+r)}function Ot(r,s,t,e){var i,n,o,a;for(n=r[0];n>=10;n/=10)--s;return--s<0?(s+=_,i=0):(i=Math.ceil((s+1)/_),s%=_),n=I(10,_-s),a=r[i]%n|0,e==null?s<3?(s==0?a=a/100|0:s==1&&(a=a/10|0),o=t<4&&a==99999||t>3&&a==49999||a==5e4||a==0):o=(t<4&&a+1==n||t>3&&a+1==n/2)&&(r[i+1]/n/100|0)==I(10,s-2)-1||(a==n/2||a==0)&&(r[i+1]/n/100|0)==0:s<4?(s==0?a=a/1e3|0:s==1?a=a/100|0:s==2&&(a=a/10|0),o=(e||t<4)&&a==9999||!e&&t>3&&a==4999):o=((e||t<4)&&a+1==n||!e&&t>3&&a+1==n/2)&&(r[i+1]/n/1e3|0)==I(10,s-3)-1,o}function Gt(r,s,t){for(var e,i=[0],n,o=0,a=r.length;o<a;){for(n=i.length;n--;)i[n]*=s;for(i[0]+=pe.indexOf(r.charAt(o++)),e=0;e<i.length;e++)i[e]>t-1&&(i[e+1]===void 0&&(i[e+1]=0),i[e+1]+=i[e]/t|0,i[e]%=t)}return i.reverse()}function Xi(r,s){var t,e,i;if(s.isZero())return s;e=s.d.length,e<32?(t=Math.ceil(e/3),i=(1/ce(4,t)).toString()):(t=16,i="2.3283064365386962890625e-10"),r.precision+=t,s=Dt(r,1,s.times(i),new r(1));for(var n=t;n--;){var o=s.times(s);s=o.times(o).minus(o).times(8).plus(1)}return r.precision-=t,s}var V=function(){function r(e,i,n){var o,a=0,l=e.length;for(e=e.slice();l--;)o=e[l]*i+a,e[l]=o%n|0,a=o/n|0;return a&&e.unshift(a),e}function s(e,i,n,o){var a,l;if(n!=o)l=n>o?1:-1;else for(a=l=0;a<n;a++)if(e[a]!=i[a]){l=e[a]>i[a]?1:-1;break}return l}function t(e,i,n,o){for(var a=0;n--;)e[n]-=a,a=e[n]<i[n]?1:0,e[n]=a*o+e[n]-i[n];for(;!e[0]&&e.length>1;)e.shift()}return function(e,i,n,o,a,l){var c,h,u,f,m,p,g,y,w,P,b,E,O,G,Nt,dt,ot,yt,X,Ht,Ft=e.constructor,he=e.s==i.s?1:-1,H=e.d,A=i.d;if(!H||!H[0]||!A||!A[0])return new Ft(!e.s||!i.s||(H?A&&H[0]==A[0]:!A)?NaN:H&&H[0]==0||!A?he*0:he/0);for(l?(m=1,h=e.e-i.e):(l=Q,m=_,h=F(e.e/m)-F(i.e/m)),X=A.length,ot=H.length,w=new Ft(he),P=w.d=[],u=0;A[u]==(H[u]||0);u++);if(A[u]>(H[u]||0)&&h--,n==null?(G=n=Ft.precision,o=Ft.rounding):a?G=n+(e.e-i.e)+1:G=n,G<0)P.push(1),p=!0;else{if(G=G/m+2|0,u=0,X==1){for(f=0,A=A[0],G++;(u<ot||f)&&G--;u++)Nt=f*l+(H[u]||0),P[u]=Nt/A|0,f=Nt%A|0;p=f||u<ot}else{for(f=l/(A[0]+1)|0,f>1&&(A=r(A,f,l),H=r(H,f,l),X=A.length,ot=H.length),dt=X,b=H.slice(0,X),E=b.length;E<X;)b[E++]=0;Ht=A.slice(),Ht.unshift(0),yt=A[0],A[1]>=l/2&&++yt;do f=0,c=s(A,b,X,E),c<0?(O=b[0],X!=E&&(O=O*l+(b[1]||0)),f=O/yt|0,f>1?(f>=l&&(f=l-1),g=r(A,f,l),y=g.length,E=b.length,c=s(g,b,y,E),c==1&&(f--,t(g,X<y?Ht:A,y,l))):(f==0&&(c=f=1),g=A.slice()),y=g.length,y<E&&g.unshift(0),t(b,g,E,l),c==-1&&(E=b.length,c=s(A,b,X,E),c<1&&(f++,t(b,X<E?Ht:A,E,l))),E=b.length):c===0&&(f++,b=[0]),P[u++]=f,c&&b[0]?b[E++]=H[dt]||0:(b=[H[dt]],E=1);while((dt++<ot||b[0]!==void 0)&&G--);p=b[0]!==void 0}P[0]||P.shift()}if(m==1)w.e=h,Ye=p;else{for(u=1,f=P[0];f>=10;f/=10)u++;w.e=u+h*m-1,C(w,a?n+w.e+1:n,o,p)}return w}}();function C(r,s,t,e){var i,n,o,a,l,c,h,u,f,m=r.constructor;t:if(s!=null){if(u=r.d,!u)return r;for(i=1,a=u[0];a>=10;a/=10)i++;if(n=s-i,n<0)n+=_,o=s,h=u[f=0],l=h/I(10,i-o-1)%10|0;else if(f=Math.ceil((n+1)/_),a=u.length,f>=a)if(e){for(;a++<=f;)u.push(0);h=l=0,i=1,n%=_,o=n-_+1}else break t;else{for(h=a=u[f],i=1;a>=10;a/=10)i++;n%=_,o=n-_+i,l=o<0?0:h/I(10,i-o-1)%10|0}if(e=e||s<0||u[f+1]!==void 0||(o<0?h:h%I(10,i-o-1)),c=t<4?(l||e)&&(t==0||t==(r.s<0?3:2)):l>5||l==5&&(t==4||e||t==6&&(n>0?o>0?h/I(10,i-o):0:u[f-1])%10&1||t==(r.s<0?8:7)),s<1||!u[0])return u.length=0,c?(s-=r.e+1,u[0]=I(10,(_-s%_)%_),r.e=-s||0):u[0]=r.e=0,r;if(n==0?(u.length=f,a=1,f--):(u.length=f+1,a=I(10,_-n),u[f]=o>0?(h/I(10,i-o)%I(10,o)|0)*a:0),c)for(;;)if(f==0){for(n=1,o=u[0];o>=10;o/=10)n++;for(o=u[0]+=a,a=1;o>=10;o/=10)a++;n!=a&&(r.e++,u[0]==Q&&(u[0]=1));break}else{if(u[f]+=a,u[f]!=Q)break;u[f--]=0,a=1}for(n=u.length;u[--n]===0;)u.pop()}return S&&(r.e>m.maxE?(r.d=null,r.e=NaN):r.e<m.minE&&(r.e=0,r.d=[0])),r}function et(r,s,t){if(!r.isFinite())return Ke(r);var e,i=r.e,n=N(r.d),o=n.length;return s?(t&&(e=t-o)>0?n=n.charAt(0)+"."+n.slice(1)+at(e):o>1&&(n=n.charAt(0)+"."+n.slice(1)),n=n+(r.e<0?"e":"e+")+r.e):i<0?(n="0."+at(-i-1)+n,t&&(e=t-o)>0&&(n+=at(e))):i>=o?(n+=at(i+1-o),t&&(e=t-i-1)>0&&(n=n+"."+at(e))):((e=i+1)<o&&(n=n.slice(0,e)+"."+n.slice(e)),t&&(e=t-o)>0&&(i+1===o&&(n+="."),n+=at(e))),n}function le(r,s){var t=r[0];for(s*=_;t>=10;t/=10)s++;return s}function se(r,s,t){if(s>Gi)throw S=!0,t&&(r.precision=t),Error(We);return C(new r(ee),s,1,!0)}function tt(r,s,t){if(s>ye)throw Error(We);return C(new r(ie),s,t,!0)}function Ze(r){var s=r.length-1,t=s*_+1;if(s=r[s],s){for(;s%10==0;s/=10)t--;for(s=r[0];s>=10;s/=10)t++}return t}function at(r){for(var s="";r--;)s+="0";return s}function Qe(r,s,t,e){var i,n=new r(1),o=Math.ceil(e/_+4);for(S=!1;;){if(t%2&&(n=n.times(s),Ve(n.d,o)&&(i=!0)),t=F(t/2),t===0){t=n.d.length-1,i&&n.d[t]===0&&++n.d[t];break}s=s.times(s),Ve(s.d,o)}return S=!0,n}function ke(r){return r.d[r.d.length-1]&1}function Je(r,s,t){for(var e,i,n=new r(s[0]),o=0;++o<s.length;){if(i=new r(s[o]),!i.s){n=i;break}e=n.cmp(i),(e===t||e===0&&n.s===t)&&(n=i)}return n}function we(r,s){var t,e,i,n,o,a,l,c=0,h=0,u=0,f=r.constructor,m=f.rounding,p=f.precision;if(!r.d||!r.d[0]||r.e>17)return new f(r.d?r.d[0]?r.s<0?0:1/0:1:r.s?r.s<0?0:r:NaN);for(s==null?(S=!1,l=p):l=s,a=new f(.03125);r.e>-2;)r=r.times(a),u+=5;for(e=Math.log(I(2,u))/Math.LN10*2+5|0,l+=e,t=n=o=new f(1),f.precision=l;;){if(n=C(n.times(r),l,1),t=t.times(++h),a=o.plus(V(n,t,l,1)),N(a.d).slice(0,l)===N(o.d).slice(0,l)){for(i=u;i--;)o=C(o.times(o),l,1);if(s==null)if(c<3&&Ot(o.d,l-e,m,c))f.precision=l+=10,t=n=a=new f(1),h=0,c++;else return C(o,f.precision=p,m,S=!0);else return f.precision=p,o}o=a}}function lt(r,s){var t,e,i,n,o,a,l,c,h,u,f,m=1,p=10,g=r,y=g.d,w=g.constructor,P=w.rounding,b=w.precision;if(g.s<0||!y||!y[0]||!g.e&&y[0]==1&&y.length==1)return new w(y&&!y[0]?-1/0:g.s!=1?NaN:y?0:g);if(s==null?(S=!1,h=b):h=s,w.precision=h+=p,t=N(y),e=t.charAt(0),Math.abs(n=g.e)<15e14){for(;e<7&&e!=1||e==1&&t.charAt(1)>3;)g=g.times(r),t=N(g.d),e=t.charAt(0),m++;n=g.e,e>1?(g=new w("0."+t),n++):g=new w(e+"."+t.slice(1))}else return c=se(w,h+2,b).times(n+""),g=lt(new w(e+"."+t.slice(1)),h-p).plus(c),w.precision=b,s==null?C(g,b,P,S=!0):g;for(u=g,l=o=g=V(g.minus(1),g.plus(1),h,1),f=C(g.times(g),h,1),i=3;;){if(o=C(o.times(f),h,1),c=l.plus(V(o,new w(i),h,1)),N(c.d).slice(0,h)===N(l.d).slice(0,h))if(l=l.times(2),n!==0&&(l=l.plus(se(w,h+2,b).times(n+""))),l=V(l,new w(m),h,1),s==null)if(Ot(l.d,h-p,P,a))w.precision=h+=p,c=o=g=V(u.minus(1),u.plus(1),h,1),f=C(g.times(g),h,1),i=a=1;else return C(l,w.precision=b,P,S=!0);else return w.precision=b,l;l=c,i+=2}}function Ke(r){return String(r.s*r.s/0)}function Xt(r,s){var t,e,i;for((t=s.indexOf("."))>-1&&(s=s.replace(".","")),(e=s.search(/e/i))>0?(t<0&&(t=e),t+=+s.slice(e+1),s=s.substring(0,e)):t<0&&(t=s.length),e=0;s.charCodeAt(e)===48;e++);for(i=s.length;s.charCodeAt(i-1)===48;--i);if(s=s.slice(e,i),s){if(i-=e,r.e=t=t-e-1,r.d=[],e=(t+1)%_,t<0&&(e+=_),e<i){for(e&&r.d.push(+s.slice(0,e)),i-=_;e<i;)r.d.push(+s.slice(e,e+=_));s=s.slice(e),e=_-s.length}else e-=i;for(;e--;)s+="0";r.d.push(+s),S&&(r.e>r.constructor.maxE?(r.d=null,r.e=NaN):r.e<r.constructor.minE&&(r.e=0,r.d=[0]))}else r.e=0,r.d=[0];return r}function Yi(r,s){var t,e,i,n,o,a,l,c,h;if(s.indexOf("_")>-1){if(s=s.replace(/(\d)_(?=\d)/g,"$1"),qe.test(s))return Xt(r,s)}else if(s==="Infinity"||s==="NaN")return+s||(r.s=NaN),r.e=NaN,r.d=null,r;if(Bi.test(s))t=16,s=s.toLowerCase();else if(Fi.test(s))t=2;else if(Ui.test(s))t=8;else throw Error(ht+s);for(n=s.search(/p/i),n>0?(l=+s.slice(n+1),s=s.substring(2,n)):s=s.slice(2),n=s.indexOf("."),o=n>=0,e=r.constructor,o&&(s=s.replace(".",""),a=s.length,n=a-n,i=Qe(e,new e(t),n,n*2)),c=Gt(s,t,Q),h=c.length-1,n=h;c[n]===0;--n)c.pop();return n<0?new e(r.s*0):(r.e=le(c,h),r.d=c,S=!1,o&&(r=V(r,i,a*4)),l&&(r=r.times(Math.abs(l)<54?I(2,l):R.pow(2,l))),S=!0,r)}function Wi(r,s){var t,e=s.d.length;if(e<3)return s.isZero()?s:Dt(r,2,s,s);t=1.4*Math.sqrt(e),t=t>16?16:t|0,s=s.times(1/ce(5,t)),s=Dt(r,2,s,s);for(var i,n=new r(5),o=new r(16),a=new r(20);t--;)i=s.times(s),s=s.times(n.plus(i.times(o.times(i).minus(a))));return s}function Dt(r,s,t,e,i){var n,o,a,l,c=r.precision,h=Math.ceil(c/_);for(S=!1,l=t.times(t),a=new r(e);;){if(o=V(a.times(l),new r(s++*s++),c,1),a=i?e.plus(o):e.minus(o),e=V(o.times(l),new r(s++*s++),c,1),o=a.plus(e),o.d[h]!==void 0){for(n=h;o.d[n]===a.d[n]&&n--;);if(n==-1)break}n=a,a=e,e=o,o=n}return S=!0,o.d.length=h+1,o}function ce(r,s){for(var t=r;--s;)t*=r;return t}function ti(r,s){var t,e=s.s<0,i=tt(r,r.precision,1),n=i.times(.5);if(s=s.abs(),s.lte(n))return nt=e?4:1,s;if(t=s.divToInt(i),t.isZero())nt=e?3:2;else{if(s=s.minus(t.times(i)),s.lte(n))return nt=ke(t)?e?2:3:e?4:1,s;nt=ke(t)?e?1:4:e?3:2}return s.minus(i).abs()}function Ce(r,s,t,e){var i,n,o,a,l,c,h,u,f,m=r.constructor,p=t!==void 0;if(p?(z(t,1,ut),e===void 0?e=m.rounding:z(e,0,8)):(t=m.precision,e=m.rounding),!r.isFinite())h=Ke(r);else{for(h=et(r),o=h.indexOf("."),p?(i=2,s==16?t=t*4-3:s==8&&(t=t*3-2)):i=s,o>=0&&(h=h.replace(".",""),f=new m(1),f.e=h.length-o,f.d=Gt(et(f),10,i),f.e=f.d.length),u=Gt(h,10,i),n=l=u.length;u[--l]==0;)u.pop();if(!u[0])h=p?"0p+0":"0";else{if(o<0?n--:(r=new m(r),r.d=u,r.e=n,r=V(r,f,t,e,0,i),u=r.d,n=r.e,c=Ye),o=u[t],a=i/2,c=c||u[t+1]!==void 0,c=e<4?(o!==void 0||c)&&(e===0||e===(r.s<0?3:2)):o>a||o===a&&(e===4||c||e===6&&u[t-1]&1||e===(r.s<0?8:7)),u.length=t,c)for(;++u[--t]>i-1;)u[t]=0,t||(++n,u.unshift(1));for(l=u.length;!u[l-1];--l);for(o=0,h="";o<l;o++)h+=pe.charAt(u[o]);if(p){if(l>1)if(s==16||s==8){for(o=s==16?4:3,--l;l%o;l++)h+="0";for(u=Gt(h,i,s),l=u.length;!u[l-1];--l);for(o=1,h="1.";o<l;o++)h+=pe.charAt(u[o])}else h=h.charAt(0)+"."+h.slice(1);h=h+(n<0?"p":"p+")+n}else if(n<0){for(;++n;)h="0"+h;h="0."+h}else if(++n>l)for(n-=l;n--;)h+="0";else n<l&&(h=h.slice(0,n)+"."+h.slice(n))}h=(s==16?"0x":s==2?"0b":s==8?"0o":"")+h}return r.s<0?"-"+h:h}function Ve(r,s){if(r.length>s)return r.length=s,!0}function ji(r){return new this(r).abs()}function $i(r){return new this(r).acos()}function qi(r){return new this(r).acosh()}function Zi(r,s){return new this(r).plus(s)}function Qi(r){return new this(r).asin()}function Ji(r){return new this(r).asinh()}function Ki(r){return new this(r).atan()}function ts(r){return new this(r).atanh()}function es(r,s){r=new this(r),s=new this(s);var t,e=this.precision,i=this.rounding,n=e+4;return!r.s||!s.s?t=new this(NaN):!r.d&&!s.d?(t=tt(this,n,1).times(s.s>0?.25:.75),t.s=r.s):!s.d||r.isZero()?(t=s.s<0?tt(this,e,i):new this(0),t.s=r.s):!r.d||s.isZero()?(t=tt(this,n,1).times(.5),t.s=r.s):s.s<0?(this.precision=n,this.rounding=1,t=this.atan(V(r,s,n,1)),s=tt(this,n,1),this.precision=e,this.rounding=i,t=r.s<0?t.minus(s):t.plus(s)):t=this.atan(V(r,s,n,1)),t}function is(r){return new this(r).cbrt()}function ss(r){return C(r=new this(r),r.e+1,2)}function ns(r,s,t){return new this(r).clamp(s,t)}function rs(r){if(!r||typeof r!="object")throw Error(ae+"Object expected");var s,t,e,i=r.defaults===!0,n=["precision",1,ut,"rounding",0,8,"toExpNeg",-9e15,0,"toExpPos",0,ge,"maxE",0,ge,"minE",-9e15,0,"modulo",0,9];for(s=0;s<n.length;s+=3)if(t=n[s],i&&(this[t]=ve[t]),(e=r[t])!==void 0)if(F(e)===e&&e>=n[s+1]&&e<=n[s+2])this[t]=e;else throw Error(ht+t+": "+e);if(t="crypto",i&&(this[t]=ve[t]),(e=r[t])!==void 0)if(e===!0||e===!1||e===0||e===1)if(e)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(je);else this[t]=!1;else throw Error(ht+t+": "+e);return this}function os(r){return new this(r).cos()}function as(r){return new this(r).cosh()}function ei(r){var s,t,e;function i(n){var o,a,l,c=this;if(!(c instanceof i))return new i(n);if(c.constructor=i,Ae(n)){c.s=n.s,S?!n.d||n.e>i.maxE?(c.e=NaN,c.d=null):n.e<i.minE?(c.e=0,c.d=[0]):(c.e=n.e,c.d=n.d.slice()):(c.e=n.e,c.d=n.d?n.d.slice():n.d);return}if(l=typeof n,l==="number"){if(n===0){c.s=1/n<0?-1:1,c.e=0,c.d=[0];return}if(n<0?(n=-n,c.s=-1):c.s=1,n===~~n&&n<1e7){for(o=0,a=n;a>=10;a/=10)o++;S?o>i.maxE?(c.e=NaN,c.d=null):o<i.minE?(c.e=0,c.d=[0]):(c.e=o,c.d=[n]):(c.e=o,c.d=[n]);return}if(n*0!==0){n||(c.s=NaN),c.e=NaN,c.d=null;return}return Xt(c,n.toString())}if(l==="string")return(a=n.charCodeAt(0))===45?(n=n.slice(1),c.s=-1):(a===43&&(n=n.slice(1)),c.s=1),qe.test(n)?Xt(c,n):Yi(c,n);if(l==="bigint")return n<0?(n=-n,c.s=-1):c.s=1,Xt(c,n.toString());throw Error(ht+n)}if(i.prototype=v,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=rs,i.clone=ei,i.isDecimal=Ae,i.abs=ji,i.acos=$i,i.acosh=qi,i.add=Zi,i.asin=Qi,i.asinh=Ji,i.atan=Ki,i.atanh=ts,i.atan2=es,i.cbrt=is,i.ceil=ss,i.clamp=ns,i.cos=os,i.cosh=as,i.div=ls,i.exp=cs,i.floor=hs,i.hypot=us,i.ln=ds,i.log=fs,i.log10=gs,i.log2=ms,i.max=ps,i.min=vs,i.mod=ys,i.mul=ws,i.pow=xs,i.random=Ps,i.round=bs,i.sign=Cs,i.sin=_s,i.sinh=Ss,i.sqrt=Es,i.sub=Ms,i.sum=Ds,i.tan=Rs,i.tanh=ks,i.trunc=Vs,r===void 0&&(r={}),r&&r.defaults!==!0)for(e=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],s=0;s<e.length;)r.hasOwnProperty(t=e[s++])||(r[t]=this[t]);return i.config(r),i}function ls(r,s){return new this(r).div(s)}function cs(r){return new this(r).exp()}function hs(r){return C(r=new this(r),r.e+1,3)}function us(){var r,s,t=new this(0);for(S=!1,r=0;r<arguments.length;)if(s=new this(arguments[r++]),s.d)t.d&&(t=t.plus(s.times(s)));else{if(s.s)return S=!0,new this(1/0);t=s}return S=!0,t.sqrt()}function Ae(r){return r instanceof R||r&&r.toStringTag===$e||!1}function ds(r){return new this(r).ln()}function fs(r,s){return new this(r).log(s)}function ms(r){return new this(r).log(2)}function gs(r){return new this(r).log(10)}function ps(){return Je(this,arguments,-1)}function vs(){return Je(this,arguments,1)}function ys(r,s){return new this(r).mod(s)}function ws(r,s){return new this(r).mul(s)}function xs(r,s){return new this(r).pow(s)}function Ps(r){var s,t,e,i,n=0,o=new this(1),a=[];if(r===void 0?r=this.precision:z(r,1,ut),e=Math.ceil(r/_),this.crypto)if(crypto.getRandomValues)for(s=crypto.getRandomValues(new Uint32Array(e));n<e;)i=s[n],i>=429e7?s[n]=crypto.getRandomValues(new Uint32Array(1))[0]:a[n++]=i%1e7;else if(crypto.randomBytes){for(s=crypto.randomBytes(e*=4);n<e;)i=s[n]+(s[n+1]<<8)+(s[n+2]<<16)+((s[n+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(s,n):(a.push(i%1e7),n+=4);n=e/4}else throw Error(je);else for(;n<e;)a[n++]=Math.random()*1e7|0;for(e=a[--n],r%=_,e&&r&&(i=I(10,_-r),a[n]=(e/i|0)*i);a[n]===0;n--)a.pop();if(n<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=_)a.shift();for(e=1,i=a[0];i>=10;i/=10)e++;e<_&&(t-=_-e)}return o.e=t,o.d=a,o}function bs(r){return C(r=new this(r),r.e+1,this.rounding)}function Cs(r){return r=new this(r),r.d?r.d[0]?r.s:0*r.s:r.s||NaN}function _s(r){return new this(r).sin()}function Ss(r){return new this(r).sinh()}function Es(r){return new this(r).sqrt()}function Ms(r,s){return new this(r).sub(s)}function Ds(){var r=0,s=arguments,t=new this(s[r]);for(S=!1;t.s&&++r<s.length;)t=t.plus(s[r]);return S=!0,C(t,this.precision,this.rounding)}function Rs(r){return new this(r).tan()}function ks(r){return new this(r).tanh()}function Vs(r){return C(r=new this(r),r.e+1,1)}v[Symbol.for("nodejs.util.inspect.custom")]=v.toString;v[Symbol.toStringTag]="Decimal";var R=v.constructor=ei(ve);ee=new R(ee);ie=new R(ie);class As{constructor(){d(this,"parent");d(this,"name","");d(this,"extData");d(this,"mainCanvas");d(this,"_isRecalculate",!1);d(this,"notifyReload")}get isRecalculate(){return(this.parent?this.parent.isRecalculate:!1)||this._isRecalculate}set isRecalculate(s){this._isRecalculate=s}equalsMainCanvas(s){return this.mainCanvas===s}setMainCanvas(s){this.mainCanvas=s}}class Os extends As{constructor(){super(...arguments);d(this,"_isVisible",!0);d(this,"inheritOpacity",!0);d(this,"_opacity");d(this,"_scaleRange")}get isVisible(){return this._isVisible}set isVisible(t){var e;t!=this.isVisible&&(this._isVisible=t,(e=this.notifyReload)==null||e.call(this,!0))}get opacity(){var t;return this.inheritOpacity?this._opacity??((t=this.parent)==null?void 0:t.opacity):this._opacity}set opacity(t){var e;this._opacity!=t&&(t===void 0||t>=0&&t<=1?(this._opacity=t,(e=this.notifyReload)==null||e.call(this,!1)):console.warn("Opacity value should be between 0 and 1."))}get scaleRange(){return this._scaleRange}set scaleRange(t){var e;t!=this.scaleRange&&(this._scaleRange=t,this.isVisible&&((e=this.notifyReload)==null||e.call(this)))}shouldRender(){var e;if(!this.isVisible||this.opacity===0)return!1;const t=(e=this.mainCanvas)==null?void 0:e.scale;if(this.scaleRange&&t){const i=Math.min(...this.scaleRange),n=Math.max(...this.scaleRange);return t>=i&&t<=n}return!0}}let Ts=class extends Os{constructor(s){super(),s.name=s.name||te("default-name-"),Object.assign(this,{...s})}};class Ls extends Ts{constructor(t){super(t);d(this,"_isInteractive",!0);d(this,"_isHoverable",!0);d(this,"_isDownable",!0);d(this,"_isContextmenuable",!0);d(this,"_isClickable",!0);d(this,"_isDoubleClickable",!0);d(this,"_isDraggable",!0);d(this,"_isWheelable",!0);Object.assign(this,{...t})}get isInteractive(){return this.getPropValue("isInteractive",this._isInteractive,!1)}set isInteractive(t){this._isInteractive=t}get isHoverable(){return this.getPropValue("isHoverable",this._isHoverable)}set isHoverable(t){this._isHoverable=t}get isDownable(){return this.getPropValue("isDownable",this._isDownable)}set isDownable(t){this._isDownable=t}get isContextmenuable(){return this.getPropValue("isContextmenuable",this._isContextmenuable)}set isContextmenuable(t){this._isContextmenuable=t}get isClickable(){return this.getPropValue("isClickable",this._isClickable)}set isClickable(t){this._isClickable=t}get isDoubleClickable(){return this.getPropValue("isDoubleClickable",this._isDoubleClickable)}set isDoubleClickable(t){this._isDoubleClickable=t}get isDraggable(){return this.getPropValue("isDraggable",this._isDraggable)}set isDraggable(t){this._isDraggable=t}get isWheelable(){return this.getPropValue("isWheelable",this._isWheelable)}set isWheelable(t){this._isWheelable=t}getPropValue(t,e,i=!0){return(this.parent?this.parent[t]:!0)&&e&&(i?this.isInteractive:!0)}}class Is{constructor(s){d(this,"propagationStopped",!1);this.data=s}stopPropagation(){this.propagationStopped=!0}get canPropagate(){return!this.propagationStopped}}class Lt extends Ls{constructor(){super(...arguments);d(this,"listeners",{wheel:new Set,hover:new Set,down:new Set,contextmenu:new Set,click:new Set,doubleClick:new Set,dragg:new Set});d(this,"sharedControllers",{});d(this,"_eventDate",{});d(this,"_clearEventDate",!1);d(this,"_isHover",!1);d(this,"notifyHover",(t,e)=>this.checkEventDate("hover",t)&&this.trigger("hover",{state:t,oldState:this.isHover},e,"isHoverable"));d(this,"_isDown",!1);d(this,"notifyDown",(t,e)=>this.checkEventDate("down",t)&&this.trigger("down",{state:t,oldState:this.isDown},e,"isDownable"));d(this,"_isContextmenu",!1);d(this,"notifyContextmenu",(t,e)=>this.checkEventDate("contextmenu",t)&&this.trigger("contextmenu",{state:t,oldState:this.isContextmenu},e,"isContextmenuable"));d(this,"_isClick",!1);d(this,"clickTimestamp",0);d(this,"doubleClickInterval",300);d(this,"notifyClick",(t,e)=>{if(!this.checkEventDate("click",t))return;let i=!1;t?(i=Date.now()-this.clickTimestamp<this.doubleClickInterval,this.clickTimestamp=i?0:Date.now()):(this._isDblClick=!1,this.clickTimestamp=0),i?this.notifyDoubleClick(i,e):this.trigger("click",{state:t,oldState:this.isClick},e,"isClickable")});d(this,"_isDblClick",!1);d(this,"notifyDoubleClick",(t,e)=>this.checkEventDate("doubleClick",t)&&this.trigger("doubleClick",{state:t,oldState:this.isDblClick},e,"isDoubleClickable"));d(this,"notifyDragg",(t,e)=>this.checkEventDate("dragg",t)&&this.trigger("dragg",t,e,"isDraggable"));d(this,"notifyWheel",(t,e)=>this.checkEventDate("wheel",t)&&this.trigger("wheel",t,e,"isWheelable"))}addEventListener(t,e){this.listeners[t].add(e)}removeEventListener(t,e){this.listeners[t].delete(e)}registerControllers(t,e){this.sharedControllers[t]=e}hasController(t,e){var i;return(i=this.sharedControllers[t])==null?void 0:i.includes(e)}trigger(t,e,i,n){var c,h;if(!this[n])return;this.updateStates(t,e);const o=new Is(e);this.listeners[t].forEach(u=>u(o,i));const a="notify"+(t.charAt(0).toUpperCase()+t.slice(1)),l=["notifyDragg","notifyWheel"].includes(a)?e:e.state;o.canPropagate&&((c=this.parent)==null||c[a](l,i)),(h=this.sharedControllers[t])==null||h.forEach(u=>u!==this&&u[a](l,i))}updateStates(t,e){const i=e;switch(t){case"hover":this._isHover=i.state;break;case"down":this._isDown=i.state;break;case"contextmenu":this._isContextmenu=i.state;break;case"click":this._isClick=i.state;break;case"doubleClick":this._isDblClick=i.state;break}}checkEventDate(t,e){const i=this._eventDate[t],n=JSON.stringify(e);return i==n?!1:(this._eventDate[t]=n,this._clearEventDate||(this._clearEventDate=!0,Promise.resolve().then(()=>{this._clearEventDate=!1,this._eventDate={}})),!0)}get isHover(){return this.isHoverable&&this._isHover}get isDown(){return this.isDraggable&&this._isDown}get isContextmenu(){return this.isClickable&&this._isContextmenu}get isClick(){return this.isClickable&&this._isClick}get isDblClick(){return this.isDoubleClickable&&this._isDblClick}}class Ns extends Lt{constructor(t){super(t);d(this,"canvas");d(this,"ctx");d(this,"_rectValueIsUpdated",!1);d(this,"_rect");d(this,"offset",{x:0,y:0});d(this,"center",{x:0,y:0});d(this,"defaultCenter",{top:void 0,bottom:void 0,left:void 0,right:void 0});d(this,"accuracy",5);d(this,"scale",1);d(this,"defaultScale",1);d(this,"percentage",1);d(this,"axisConfig",{count:2,min:100,size:100,x:1,y:1});d(this,"cycle",10);d(this,"delta",.02);d(this,"_redrawInNextRenderFrame",!1);d(this,"isAuto",!1);d(this,"isRendering",!1);d(this,"drawAxis");d(this,"layerGroups",new Map);d(this,"isScaleUpdated",!1);d(this,"nowGridCount");const{id:e,axisConfig:i,defaultCenter:n,offset:o,defaultScale:a}=t,l=document.getElementById(e);if(l instanceof HTMLCanvasElement)if(l.getContext){this.canvas=l,this.ctx=l.getContext("2d");const{clientWidth:c,clientHeight:h}=l;[l.width,l.height]=[c,h]}else throw new Error("canvas-unsupported code here");else throw new Error("canvas is not HTMLCanvasElement");i&&this.setAxis(i),o&&(this.offset.x=o.x||0,this.offset.y=o.y||0),n&&this.setDefaultCenter(n),a&&(this.updateCenter(),this.setScale("center",a-1),this.defaultScale=a)}get rect(){return this._rectValueIsUpdated&&this._rect?this._rect:(this._rectValueIsUpdated=!0,Promise.resolve().then(()=>this._rectValueIsUpdated=!1),this._rect=this.canvas.getBoundingClientRect(),this._rect)}get redrawInNextRenderFrame(){return this._redrawInNextRenderFrame}set redrawInNextRenderFrame(t){this._redrawInNextRenderFrame=t}setNotifyReload(t){this.notifyReload=t}getDefaultCenterLocation(){const{canvas:t,rect:e,defaultCenter:i}=this;if(!t)return console.error("canvas is not HTMLCanvasElement");const{width:n,height:o}=e,{top:a,bottom:l,left:c,right:h}=i,u={vertical:(g,y)=>{if([0,"0","0%"].includes(g))return 0;if(!(g==1/0||g==-1/0))return typeof g=="number"?g:["top","left"].includes(g)?0:["bottom","right"].includes(g)?y:["middle","center"].includes(g)?y/2:/^(-?\d+)%$/.test(g)?(g=g.match(/^(-?\d+)%$/)[1],y*Number(g)/100):Number(g)||void 0},reverse:(g,y)=>{if([0,"0","0%"].includes(g))return y;if(g==1/0||g==-1/0)return;if(typeof g=="number")return y-g;const w=u.vertical(g,y);return w?y-w:void 0}},f=(g,y,w)=>{if(g!==void 0){const P=u.vertical(g,w);if(P!==void 0)return P}if(y!==void 0){const P=u.reverse(y,w);if(P!==void 0)return P}return w/2},m=f(a,l,o);return{x:f(c,h,n),y:m}}updateCenter(){const t=this.getDefaultCenterLocation();if(!t)return;const{x:e,y:i}=t;this.center={x:Math.floor(e+this.offset.x),y:Math.floor(i+this.offset.y)}}updateSize(){const{scale:t,axisConfig:e}=this;e.size=this.getGridSize(t),this.percentage=this.getAxisPointByValue(e.count,0).x/e.min}setScale(t,e){const{canvas:i,isWheelable:n,axisConfig:o,rect:a}=this;if(!n||!i)return console.error("canvas is not HTMLCanvasElement");let l,c;t==="center"?(l=a.left+a.width/2,c=a.top+a.height/2):[l,c]=[t.clientX,t.clientY];const h=this.getMousePositionOnAxis({clientX:l,clientY:c}),u=this.getAxisValueByPoint(h.x,h.y);this.scale=new R(this.scale).add(e).toNumber(),this.isScaleUpdated=!0,this.updateSize();const f=this.getAxisPointByValue(u.xV,u.yV);this.offset.x-=(f.x-h.x)*o.x,this.offset.y-=(f.y-h.y)*o.y,this.offset.x=Number(this.offset.x.toFixed(0)),this.offset.y=Number(this.offset.y.toFixed(0))}setAxis(t){const e={...this.axisConfig,...t},i=Object.fromEntries(Object.entries(e).map(([g,y])=>[g,Number(y)])),{x:n,y:o,count:a,min:l,size:c}=i,h=[1,-1].includes(n),u=[1,-1].includes(o),f=a>0,m=l>0,p=c>=l&&c<=l*2;if(!h||!u||!f||!m){console.warn("Invalid axis configuration:",{x:n,y:o,count:a,min:l});return}p||(i.size=l),this.axisConfig=i}setDefaultCenter(t){Object.assign(this.defaultCenter,t),this.updateCenter()}getGridSize(t){const{cycle:e,delta:i,axisConfig:n}=this;let o=new R(t).sub(1).abs().mod(e*i).div(i).toNumber();return o=t<1&&o!=0?e-o:o,Number(((o/e+1)*n.min).toFixed(0))}getGridCount(t){const{axisConfig:e,cycle:i,delta:n}=this,o=e.count,a=i*n;if(t===1)return o;if(t>1){const l=new R(t).sub(1).div(a).floor();return new R(o).div(new R(2).pow(l)).toNumber()}else{const l=new R(1).sub(t).div(a).ceil();return new R(o).mul(new R(2).pow(l)).toNumber()}}get getNowGridCount(){const{scale:t,nowGridCount:e,isRendering:i}=this;return e&&i?e:(this.nowGridCount=this.getGridCount(t),i&&Promise.resolve().then(()=>this.nowGridCount=void 0),this.nowGridCount)}getMousePositionOnAxis(t){const{canvas:e,center:i,rect:n,axisConfig:o}=this;if(!e)return console.error("canvas is not HTMLCanvasElement");const{clientX:a,clientY:l}=t,{left:c,top:h}=n,u=(a-c-i.x)*o.x,f=(l-h-i.y)*o.y;return{x:u,y:f}}getAxisValueByPoint(t,e,i){const{axisConfig:n}=this;if(i)return{xV:t/n.min*n.count,yV:e/n.min*n.count};const o=this.getNowGridCount,a=new R(t).div(n.size).mul(o).toFixed(8),l=new R(e).div(n.size).mul(o).toFixed(8);return{xV:Number(a),yV:Number(l)}}getAxisPointByValue(t,e,i){const{axisConfig:n}=this;if(i)return{x:t/n.count*n.min,y:e/n.count*n.min};const o=this.getNowGridCount,a=new R(t).div(o).mul(n.size).toFixed(3),l=new R(e).div(o).mul(n.size).toFixed(3);return{x:Number(a),y:Number(l)}}getMaxMinValue(t){t=t||this.rect;const{left:e,top:i,right:n,bottom:o}=t,{axisConfig:a}=this,{x:l,y:c}=this.getMousePositionOnAxis({clientX:a.x==1?e:n,clientY:a.y==1?i:o}),{xV:h,yV:u}=this.getAxisValueByPoint(l,c),{x:f,y:m}=this.getMousePositionOnAxis({clientX:a.x==1?n:e,clientY:a.y==1?o:i}),{xV:p,yV:g}=this.getAxisValueByPoint(f,m);return{minXV:h,maxXV:p,minYV:u,maxYV:g}}transformPosition(t){const{center:e,percentage:i,axisConfig:n}=this,o=i*n.x,a=i*n.y,l=c=>[e.x+c[0]*o,e.y+c[1]*a];return Array.isArray(t[0])?t.map(c=>l(c)):l(t)}}class Hs extends Ns{constructor(t){super(t);d(this,"theme","light");d(this,"isThemeUpdated",!1);d(this,"style",{light:{background:"#fff",text:{color:"#222",secondary:"#909399",stroke:"#fff",size:12,family:"monospace",bold:!0},grid:{axis:"#222",grid:"#666",innerGrid:"#e5e5e5"},point:{radius:5,fill:"#d03050",width:14,stroke:"#d0305080"},line:{stroke:{color:"#f0a020",color_hover:"#f2c97d",width:4,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#f0a02080",width:14,fill:"#f0a020"}},arc:{fill:"#f0a02030",fill_hover:"#f2c97d60",stroke:{color:"#f0a020",color_hover:"#f2c97d",width:4,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#f0a02080",width:14,fill:"#f0a020"}},arcTo:{stroke:{color:"#f0a020",color_hover:"#f2c97d",width:4,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#f0a02080",width:14,fill:"#f0a020"}},polygon:{fill:"#18a05830",fill_hover:"#03693360",stroke:{color:"#18a058",color_hover:"#036933",width:1,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#03693380",width:14,fill:"#036933"}},billboard:{stroke:{color:"#d03050",color_hover:"#d03050",width:4,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"}}},dark:{background:"#000",text:{color:"#aeaeae",secondary:"#8c8c8c",stroke:"#000",size:12,family:"monospace",bold:!0},grid:{axis:"#aeaeae",grid:"#666",innerGrid:"#454545"},point:{radius:5,fill:"#e88080",width:14,stroke:"#e8808070"},line:{stroke:{color:"#f2c97d",color_hover:"#f0a020",width:4,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#f2c97d80",width:14,fill:"#f2c97d"}},arc:{fill:"#f2c97d30",fill_hover:"#f0a02060",stroke:{color:"#f2c97d",color_hover:"#f0a020",width:4,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#f2c97d80",width:14,fill:"#f2c97d"}},arcTo:{stroke:{color:"#f2c97d",color_hover:"#f0a020",width:4,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#f2c97d80",width:14,fill:"#f2c97d"}},polygon:{fill:"#63e2b730",fill_hover:"#7efbd160",stroke:{color:"#63e2b7",color_hover:"#63e2b7",width:1,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#7efbd180",width:14,fill:"#7efbd1"}},billboard:{stroke:{color:"#e88080",color_hover:"#e88080",width:4,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"}}}});const{theme:e}=t;e&&this.setTheme(e),this.initStyle(),this.clearScreen()}initStyle(){const{canvas:t,ctx:e,theme:i}=this;t.classList.add("_nhanh_canvas");const n=this.style[i];e.font=`${n.text.bold?"bold":""} ${n.text.size}px ${n.text.family}`}clearScreen(t=!0){const{ctx:e,theme:i,rect:n}=this,{width:o,height:a}=n;e.clearRect(0,0,o,a),t&&this.style[i].background&&(e.fillStyle=this.style[i].background,e.fillRect(0,0,o,a))}setStyle(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)){const i=ze(this.style[e]||this.style[this.theme]);rt(i,t[e]),this.style[e]=i}this.initStyle()}setTheme(t){t in this.style&&(this.theme=t,this.isThemeUpdated=!0)}}class D extends Lt{constructor(t){t={...t},t.isDraggable=t.isDraggable??!1;const{mainCanvas:e,notifyReload:i}=t;delete t.mainCanvas,delete t.notifyReload;super(t);d(this,"_style");d(this,"_position");d(this,"_value");d(this,"_zIndex",0);d(this,"_dynamicPosition");d(this,"_offset",{x:0,y:0});d(this,"path");d(this,"publicToPrivateKeyMap",{offset:"_offset",position:"_position",value:"_value",dynamicPosition:"_dynamicPosition",zIndex:"_zIndex",style:"_style"});d(this,"redrawOnIsHoverChange",!0);d(this,"defaultHover",(t,e)=>{var i;this.redrawOnIsHoverChange&&((i=this.notifyReload)==null||i.call(this))});d(this,"_valueScope");d(this,"styleRadius",{value:0,radius:0});d(this,"offsetValue",{xV:0,yV:0});d(this,"fixedExtraScope",{topV:0,bottomV:0,leftV:0,rightV:0});d(this,"extraScope",{top:0,bottom:0,left:0,right:0,topV:0,bottomV:0,leftV:0,rightV:0});this.setNotifyReload(i),this.mainCanvas=e,["redrawOnIsHoverChange"].forEach(o=>{o in t&&(this[o]=t[o])});const n={};["offset","style","zIndex","position","dynamicPosition","value"].forEach(o=>{o in t&&(n[o]=t[o])}),this.internalUpdate(n),this.addEventListener("hover",this.defaultHover)}get style(){return this._style}set style(t){var e;this._style=t,this.mainCanvas&&(this.updateValueScope(),(e=this.notifyReload)==null||e.call(this))}get position(){return this._position}set position(t){var e;this._position=t,this._value=void 0,this.updateBaseData(),(e=this.notifyReload)==null||e.call(this)}get value(){return this._value}set value(t){var e;this._value=t,this._position=void 0,this.updateBaseData(),(e=this.notifyReload)==null||e.call(this)}get zIndex(){return this._zIndex}set zIndex(t){var e;this._zIndex!=t&&(this._zIndex=t,(e=this.notifyReload)==null||e.call(this))}get dynamicPosition(){return this._dynamicPosition}set dynamicPosition(t){this._dynamicPosition=t}get offset(){return this._offset}set offset(t){var e;this._offset=t,this.calculateOffsetValue(),(e=this.notifyReload)==null||e.call(this)}get finalDynamicPosition(){var i;const{x:t,y:e}=this.offset;return(i=this.dynamicPosition)==null?void 0:i.map((n,o)=>typeof n=="number"?o==0?n+t:n+e:[n[0]+t,n[1]+e])}internalUpdate(t,e){Object.keys(t).forEach(i=>{const n=this.publicToPrivateKeyMap[i];n&&(this[n]=t[i])}),e&&this.updateValueScope()}setMainCanvas(t){super.setMainCanvas(t),t&&this.updateBaseData()}setNotifyReload(t){this.notifyReload=t?e=>{var i;e&&(this.isRecalculate=!0),(e||this.isNeedRender||(i=this.mainCanvas)!=null&&i.currentDrawOverlays.includes(this))&&t()}:void 0}get valueScope(){return this._valueScope}set valueScope(t){this._valueScope=t}initValueScope(){const t=this.value;if(Array.isArray(t[0])){let e=1/0,i=-1/0,n=1/0,o=-1/0;t.forEach(([a,l])=>{e=Math.min(e,a),i=Math.max(i,a),n=Math.min(n,l),o=Math.max(o,l)}),this.valueScope={minX:e,maxX:i,minY:n,maxY:o}}else{const[e,i]=t;this.valueScope={minX:e,maxX:e,minY:i,maxY:i}}this.calculateStyleRadiusValue(!1),this.calculateOffsetValue(!1),this.setFixedExtraScope(!0),this.setExtraScope(!0)}calculateStyleRadiusValue(t=!0){if(!(!this.mainCanvas||!this.valueScope))if(t){const{radius:e,value:i}=this.styleRadius;if(e==0)return;const n=this.mainCanvas.getAxisValueByPoint(e,0).xV,o=n-i;this.valueScope.minX-=o,this.valueScope.maxX+=o,this.valueScope.minY-=o,this.valueScope.maxY+=o,this.styleRadius={radius:e,value:n}}else{const{stroke:e,point:i}=this.computedValueScopeStyles,n=i?i.radius+Math.max(0,i.width/2):0,o=e?Math.max(0,e.width/2):0,a=Math.max(n,o);if(a==0)return this.styleRadius={radius:0,value:0};const l=this.mainCanvas.getAxisValueByPoint(a,0).xV;this.valueScope.minX-=l,this.valueScope.maxX+=l,this.valueScope.minY-=l,this.valueScope.maxY+=l,this.styleRadius={radius:a,value:l}}}calculateOffsetValue(t=!0){const{mainCanvas:e,valueScope:i,offset:n,offsetValue:o}=this;if(!(!e||!i))if(t){const{x:a,y:l}=e.axisConfig;let{xV:c,yV:h}=e.getAxisValueByPoint(n.x,n.y);c*=a,h*=l;const u=c-o.xV,f=h-o.yV;i.minX+=u,i.maxX+=u,i.minY+=f,i.maxY+=f,this.offsetValue={xV:c,yV:h}}else{if(this.offsetValue={xV:0,yV:0},n.x==0&&n.y==0)return;this.calculateOffsetValue()}}setFixedExtraScope(t){if(t===!0)this.fixedExtraScope={topV:0,bottomV:0,leftV:0,rightV:0};else{const e=t||{topV:0,bottomV:0,leftV:0,rightV:0};if(this.valueScope){const{leftV:i,rightV:n,topV:o,bottomV:a}=e;this.valueScope.minX-=i-this.fixedExtraScope.leftV,this.valueScope.maxX+=n-this.fixedExtraScope.rightV,this.valueScope.minY-=o-this.fixedExtraScope.topV,this.valueScope.maxY+=a-this.fixedExtraScope.bottomV,this.fixedExtraScope=e}}}setExtraScope(t){const{valueScope:e,mainCanvas:i,extraScope:n}=this;if(!(!e||!i))if(t===!0)this.extraScope={top:0,bottom:0,left:0,right:0,topV:0,bottomV:0,leftV:0,rightV:0};else if(t){const{left:o,right:a,top:l,bottom:c}=t,{xV:h,yV:u}=i.getAxisValueByPoint(l,c),{xV:f,yV:m}=i.getAxisValueByPoint(o,a);e.minX-=f-n.leftV,e.maxX+=m-n.rightV,e.minY-=h-n.topV,e.maxY+=u-n.bottomV,this.extraScope={...t,topV:h,bottomV:u,leftV:f,rightV:m}}else this.setExtraScope(this.extraScope)}get isWithinRange(){const{mainCanvas:t,valueScope:e}=this;if(!t)return!1;const{isScaleUpdated:i,maxMinValue:n}=t;return i&&(this.calculateStyleRadiusValue(),this.calculateOffsetValue(),this.setExtraScope()),e?!(n.maxXV<e.minX||n.minXV>e.maxX||n.maxYV<e.minY||n.minYV>e.maxY):!0}get isNeedRender(){return!!(this.mainCanvas&&this.shouldRender()&&this.dynamicPosition&&this.isWithinRange)}calculateOffset(t,e){const{percentage:i,axisConfig:n}=this.mainCanvas,o=n.count/n.min/i,a={value:t*o*n.x,position:t/i*n.x,dynamicPosition:t},l={value:e*o*n.y,position:e/i*n.y,dynamicPosition:e};return{x:a,y:l}}handleValuePosition(t,e){let{value:i,position:n,mainCanvas:o}=this;if(!o)return!1;const a=t==="array1D"?oe:At,[l,c]=[a(i)&&(!e||i.length>=e),a(n)&&(!e||n.length>=e)],h={value:i,position:n,dynamicPosition:[]};if(!l&&!c)return this.internalUpdate({dynamicPosition:void 0}),!1;if(l){const u=i;if(t==="array1D"){const f=o.getAxisPointByValue(u[0],u[1],!0);h.position=[f.x,f.y]}else{h.position=[];for(let f=0;f<u.length;f++){const m=u[f],p=o.getAxisPointByValue(m[0],m[1],!0);h.position.push([p.x,p.y])}}}else{const u=n;if(t==="array1D"){const f=o.getAxisValueByPoint(u[0],u[1],!0);h.value=[f.xV,f.yV]}else{h.value=[];for(let f=0;f<u.length;f++){const m=u[f],p=o.getAxisValueByPoint(m[0],m[1],!0);h.value.push([p.xV,p.yV])}}}return h.dynamicPosition=o.transformPosition(h.position),this.internalUpdate(h,!0),!0}isPointInAnywhere(t,e){return this.isPointInPath(t,e)||this.isPointInStroke(t,e)}setGlobalAlpha(t){var i;const e=this.opacity??((i=this.parent)==null?void 0:i.opacity);e!==void 0&&(t.globalAlpha=e)}setBaseLineStyle(t,e){const{width:i,dash:n,dashGap:o,dashOffset:a,color:l,color_hover:c,cap:h,join:u}=e;return t.setLineDash(n?o:[]),t.lineDashOffset=a,t.lineCap=h,t.lineJoin=u,t.lineWidth=i,t.strokeStyle=this.isHover?c:l,e}get cursorStyle(){return this.isInteractive?this.isDraggable?"_nhanh_canvas_hover_overlay_draggable":"_nhanh_canvas_hover_overlay":void 0}}d(D,"ctx",document.createElement("canvas").getContext("2d"));class Yt extends D{constructor(t){super(t);d(this,"_draw");this.redrawOnIsHoverChange=!1;const{draw:e}=t;Object.assign(this,{draw:e})}updateValueScope(){this.initValueScope()}isPointInPath(t,e){return!1}isPointInStroke(t,e){return!1}updateBaseData(){if(!this.mainCanvas)return;this.internalUpdate({dynamicPosition:[]});let t=this.value,e=this.position;t?e=this.convertValuesToPositions(t):e&&(t=this.convertPositionsToValues(e)),t&&e&&this.updateDataProperties(t,e)}convertValuesToPositions(t){const e=[];let i;return t.forEach(n=>{if(i===void 0){const o=this.mainCanvas.getAxisPointByValue(n[0],n[1],!0);e.push([o.x,o.y]),n[0]!=0?i=new R(o.x).div(n[0]).toNumber():n[1]!=0&&(i=new R(o.y).div(n[1]).toNumber())}else e.push([new R(i).mul(n[0]).toNumber(),new R(i).mul(n[1]).toNumber()])}),e}convertPositionsToValues(t){const e=[];let i;return t.forEach((n,o)=>{if(i===void 0){const a=this.mainCanvas.getAxisValueByPoint(n[0],n[1],!0);e.push([a.xV,a.yV]),n[0]!=0?i=new R(a.xV).div(n[0]).toNumber():n[1]!=0&&(i=new R(a.yV).div(n[1]).toNumber())}else e.push([new R(i).mul(n[0]).toNumber(),new R(i).mul(n[1]).toNumber()])}),e}updateDataProperties(t,e){this.internalUpdate({value:t,position:e,dynamicPosition:this.mainCanvas.transformPosition(e)})}setOverlayStyles(t){}get computedValueScopeStyles(){return{}}get draw(){return t=>{var e;this.setGlobalAlpha(t),(e=this._draw)==null||e.call(this,t)}}set draw(t){this._draw=t}getDraw(){if(this.isNeedRender){const{mainCanvas:t,position:e}=this;return this.isRecalculate&&e&&this.internalUpdate({dynamicPosition:t.transformPosition(e)}),[this.draw,this]}}}class k{static add(s,t){return new R(s).add(t).toNumber()}static sub(s,t){return new R(s).sub(t).toNumber()}static mul(s,t){return new R(s).mul(t).toNumber()}static div(s,t){return new R(s).div(t).toNumber()}}class Wt extends D{constructor(t){super(t);d(this,"textOffset",{x:0,y:0});d(this,"_text");d(this,"defaultDragg",(t,e)=>{var l;const{offsetX:i,offsetY:n}=t.data,{x:o,y:a}=this.calculateOffset(i,n);this.internalUpdate({value:[k.add(this.value[0],o.value),k.add(this.value[1],a.value)],position:[k.add(this.position[0],o.position),k.add(this.position[1],a.position)],dynamicPosition:[k.add(this.dynamicPosition[0],o.dynamicPosition),k.add(this.dynamicPosition[1],a.dynamicPosition)]},!0),(l=this.notifyReload)==null||l.call(this)});const{text:e}=t;Object.assign(this,{text:e}),this.addEventListener("dragg",this.defaultDragg)}get text(){return this._text}set text(t){var e;this._text!=t&&(this._text=t,this.updateBaseData(),(e=this.notifyReload)==null||e.call(this))}updateValueScope(){this.initValueScope();const t=this.textOffset;this.setExtraScope({top:t.y,bottom:t.y,left:t.x,right:t.x})}isPointInPath(t,e){return this.path?D.ctx.isPointInPath(this.path,t,e):!1}isPointInStroke(t,e){return!1}updateBaseData(){if(!this.mainCanvas)return;if(!this.text||this.text.length==0)return this.internalUpdate({dynamicPosition:void 0});const t=D.ctx;this.setOverlayStyles(t);const e=t.measureText(this.text);this.textOffset={x:e.width/2,y:e.actualBoundingBoxAscent/2},this.handleValuePosition("array1D")}setOverlayStyles(t){var o;const e=this.mainCanvas,i=e.style[e.theme].text;let n={};return typeof this.style=="string"?n=((o=e.style[this.style])==null?void 0:o.text)||i:typeof this.style=="object"?n=Object.assign({},i,this.style):n=i,t.font=`${n.bold?"bold":""} ${n.size}px ${n.family}`,t.lineWidth=2,t.strokeStyle=n.stroke,t.fillStyle=n[this.isHover?"secondary":"color"],n}get computedValueScopeStyles(){return{}}draw(t){const{text:e,textOffset:i,finalDynamicPosition:n}=this;if(!this.mainCanvas||!e)return;this.setGlobalAlpha(t),this.setOverlayStyles(t);const o=n[0]-i.x,a=n[1]+i.y;t.strokeText(e,o,a),t.fillText(e,o,a),this.path=new Path2D,this.path.rect(o,n[1]-i.y,i.x*2,i.y*2)}getDraw(){if(this.isNeedRender){if(this.isRecalculate){const{position:t,mainCanvas:e}=this;this.internalUpdate({dynamicPosition:e.transformPosition(t)})}return[this.draw,this]}}}class ct extends D{constructor(t){super(t);d(this,"angle",2*Math.PI);d(this,"defaultDragg",(t,e)=>{var l;const{offsetX:i,offsetY:n}=t.data,{x:o,y:a}=this.calculateOffset(i,n);this.internalUpdate({value:[k.add(this.value[0],o.value),k.add(this.value[1],a.value)],position:[k.add(this.position[0],o.position),k.add(this.position[1],a.position)],dynamicPosition:[k.add(this.dynamicPosition[0],o.dynamicPosition),k.add(this.dynamicPosition[1],a.dynamicPosition)]},!0),(l=this.notifyReload)==null||l.call(this)});d(this,"fillProgress");d(this,"defaultHover",(t,e)=>{const i=t.data.state,n=300,o=this.setOverlayStyles().width;this.fillProgress?this.cancelAndRestartAnimation(i,o,n-100):i&&this.startNewHoverAnimation(o,n)});this.addEventListener("hover",this.defaultHover),this.addEventListener("dragg",this.defaultDragg)}updateValueScope(){this.initValueScope()}cancelAndRestartAnimation(t,e,i){this.fillProgress.scheduleCallback();let n=0;this.fillProgress.scheduleCallback=Vt(o=>{!this.fillProgress||!o||(this.fillProgress.progress+=(o-n)*(t?1:-1),n=o,this.fillProgress.progress=Math.min(1,Math.max(0,this.fillProgress.progress)),this.updateLineWidthOffset(e),(this.fillProgress.progress===1||this.fillProgress.progress===0)&&(this.fillProgress.scheduleCallback(),this.fillProgress.progress===0&&(this.fillProgress=void 0)))},i)}startNewHoverAnimation(t,e){this.fillProgress={lineWidthOffset:0,progress:0,scheduleCallback:Vt(i=>{this.fillProgress&&(this.fillProgress.progress=i,this.updateLineWidthOffset(t))},e)}}updateLineWidthOffset(t){var i;if(!this.fillProgress)return;const e=Math.ceil(t*this.fillProgress.progress);e!==this.fillProgress.lineWidthOffset&&(this.fillProgress.lineWidthOffset=e,(i=this.notifyReload)==null||i.call(this))}isPointInPath(t,e){return this.path?D.ctx.isPointInPath(this.path,t,e):!1}isPointInStroke(t,e){var i;if(this.path&&this.mainCanvas){const{width:n}=this.setOverlayStyles(D.ctx);return((i=this.fillProgress)==null?void 0:i.lineWidthOffset)==n?!1:D.ctx.isPointInStroke(this.path,t,e)}return!1}updateBaseData(){this.handleValuePosition("array1D")}setOverlayStyles(t){var c,h;const e=this.mainCanvas,i=e.style[e.theme].point;let n={};typeof this.style=="string"?n=((c=e.style[this.style])==null?void 0:c.point)||i:typeof this.style=="object"?n=Object.assign({},i,this.style):n=i;const{width:o,stroke:a,fill:l}=n;if(t){t.setLineDash([]);const u=((h=this.fillProgress)==null?void 0:h.lineWidthOffset)||0;t.lineWidth=o-u,t.strokeStyle=a,t.fillStyle=l}return{...n}}get computedValueScopeStyles(){return{point:this.setOverlayStyles()}}draw(t){var h;const{finalDynamicPosition:e,mainCanvas:i}=this;if(!i)return;this.setGlobalAlpha(t);const{radius:n,width:o}=this.setOverlayStyles(t),a=((h=this.fillProgress)==null?void 0:h.lineWidthOffset)||0,[l,c]=e;t.beginPath(),this.path=new Path2D,this.path.arc(l,c,n+a/2,0,this.angle),o!=a&&t.stroke(this.path),t.fill(this.path)}getDraw(){if(this.isNeedRender){const{mainCanvas:t,position:e}=this;return this.isRecalculate&&this.internalUpdate({dynamicPosition:t.transformPosition(e)}),[this.draw,this]}}}class ii extends D{constructor(t){super(t);d(this,"handlePoints",[]);d(this,"isShowHandlePoint",!1);d(this,"_isHandlePointsVisible",!0);d(this,"canCreateOrDeleteHandlePoint",!0);d(this,"lockedCanCreateOrDeleteHandlePoint",!1);d(this,"defaultClick",(t,e)=>{var o;if(!this.isHandlePointsVisible)return;const{state:i,oldState:n}=t.data;i!=n&&!this.isInfinite&&((o=this.notifyReload)==null||o.call(this))});d(this,"defaultDoubleClick",(t,e)=>{if(e){if(!this.isHandlePointsVisible)return;const{offsetX:i,offsetY:n}=e,{state:o}=t.data;if(this.lockedCanCreateOrDeleteHandlePoint)this.resetHandlePointLock();else if(o&&this.isHandlePointsVisible&&this.canCreateOrDeleteHandlePoint&&this.isDraggable){const l=this.handlePoints.findIndex(c=>c.isHover);l===-1?this.tryCreateNewHandlePoint(i,n):this.tryDeleteHandlePoint(l)}}});d(this,"defaultDragg",(t,e)=>{var n;if(!this.mainCanvas)return;const i=()=>{const{offsetX:o,offsetY:a}=t.data,{x:l,y:c}=this.calculateOffset(o,a);this.value.forEach((h,u)=>{this.value[u]=[k.add(this.value[u][0],l.value),k.add(this.value[u][1],c.value)],this.position[u]=[k.add(this.position[u][0],l.position),k.add(this.position[u][1],c.position)],this.dynamicPosition[u]=[k.add(this.dynamicPosition[u][0],l.dynamicPosition),k.add(this.dynamicPosition[u][1],c.dynamicPosition)]}),this.handlePoints.forEach((h,u)=>{h.internalUpdate({value:this.value[u],position:this.position[u],dynamicPosition:this.dynamicPosition[u]},!0)}),this.lockedCanCreateOrDeleteHandlePoint=!0};if(this.isHandlePointsVisible){const o=this.handlePoints.findIndex(a=>a.isHover);if(o!=-1){const a=this.handlePoints[o];a.notifyDragg(t.data,e),this.value[o]=a.value,this.position[o]=a.position,this.dynamicPosition[o]=a.dynamicPosition}else i()}else i();(n=this.notifyReload)==null||n.call(this),this.updateValueScope()});["isHandlePointsVisible","canCreateOrDeleteHandlePoint"].forEach(e=>{e in t&&(this[e]=t[e])}),this.addEventListener("click",this.defaultClick),this.addEventListener("doubleClick",this.defaultDoubleClick),this.addEventListener("dragg",this.defaultDragg)}get isHandlePointsVisible(){return this._isHandlePointsVisible}set isHandlePointsVisible(t){var e;this._isHandlePointsVisible!==t&&(this._isHandlePointsVisible=t,this.isShowHandlePoint!=t&&((e=this.notifyReload)==null||e.call(this)),this.updateHandlePoints())}get offset(){return super.offset}set offset(t){super.offset=t;let{isHandlePointsVisible:e,handlePoints:i}=this;e&&i.forEach(n=>n.internalUpdate({offset:t}))}tryCreateNewHandlePoint(t,e){var c;if(!this.isPointInStroke(t,e))return;const i=this.getExtendedDynamicPositions(),n=Fs([t,e],i);if(n===-1)return;const[o,a]=this.getAdjacentIndices(n),l=this.createNewHandlePoint(o,a);this.insertHandlePoint(n,l),this.lockHandlePointCreationTemporarily(),(c=this.notifyReload)==null||c.call(this)}tryDeleteHandlePoint(t){var e;!this.isDblClick||!this.canDeleteHandlePoint||(this.deleteHandlePoint(t),(e=this.notifyReload)==null||e.call(this))}getExtendedDynamicPositions(){return this.isClosed?[...this.dynamicPosition,this.dynamicPosition[0]]:this.dynamicPosition}getAdjacentIndices(t){const e=t-1,i=this.isClosed&&t===this.dynamicPosition.length?0:t;return[e,i]}createNewHandlePoint(t,e){const i=ue(this.value[t],this.value[e]),n=ue(this.position[t],this.position[e]),o=ue(this.dynamicPosition[t],this.dynamicPosition[e]);return new ct({value:i,position:n,dynamicPosition:o,isDraggable:!0,mainCanvas:this.mainCanvas,notifyReload:()=>{var a;return(a=this.notifyReload)==null?void 0:a.call(this)}})}insertHandlePoint(t,e){this.handlePoints.splice(t,0,e),this.value.splice(t,0,e.value),this.position.splice(t,0,e.position),this.dynamicPosition.splice(t,0,e.dynamicPosition)}deleteHandlePoint(t){this.handlePoints.splice(t,1),this.value.splice(t,1),this.position.splice(t,1),this.dynamicPosition.splice(t,1)}lockHandlePointCreationTemporarily(){this.lockedCanCreateOrDeleteHandlePoint=!0,setTimeout(()=>{this.lockedCanCreateOrDeleteHandlePoint=!1},300)}resetHandlePointLock(){this.lockedCanCreateOrDeleteHandlePoint=!1}get canDeleteHandlePoint(){return this.handlePoints.length>this.minNeededHandlePoints}updateHandlePoints(){let{value:t,position:e,dynamicPosition:i,offset:n,isHandlePointsVisible:o}=this;!i||!o||(t==null||t.forEach((a,l)=>{if(!this.handlePoints[l]){const c=new ct({value:[0,0],mainCanvas:this.mainCanvas,isDraggable:!0,offset:n,notifyReload:()=>{var h;return(h=this.notifyReload)==null?void 0:h.call(this)}});this.handlePoints.push(c)}this.handlePoints[l].internalUpdate({value:t[l],position:e[l],dynamicPosition:i[l]},!0)}),this.handlePoints.length=t.length)}updateHandlePointsPosition(){this.isHandlePointsVisible&&this.handlePoints.forEach((t,e)=>{t.internalUpdate({dynamicPosition:this.dynamicPosition[e]})})}}function Fs(r,s,t=10){if(s.length===0)return 0;if(s.length===1)return 1;let e=1/0,i=-1;for(let n=0;n<s.length-1;n++){const o=ni(r,s[n],s[n+1]);if(o<t)return n+1;o<e&&(e=o,i=n+1)}return i}function ue(r,s){const{x:t,y:e}=Ee(...r,...s);return[t,e]}class jt extends ii{constructor(t){super(t);d(this,"_isInfinite");d(this,"isClosed",!1);d(this,"minNeededHandlePoints",2);const{isInfinite:e}=t;Object.assign(this,{isInfinite:e}),e&&(this.canCreateOrDeleteHandlePoint=!1)}get isInfinite(){return this._isInfinite}set isInfinite(t){var e;this._isInfinite!=t&&(this._isInfinite=t,this.canCreateOrDeleteHandlePoint=!t,(e=this.notifyReload)==null||e.call(this))}updateValueScope(){this.initValueScope()}isPointInPath(t,e){return!1}isPointInStroke(t,e){return this.path&&this.mainCanvas?(this.setOverlayStyles(D.ctx),this.isDraggable&&(D.ctx.lineWidth=Math.max(D.ctx.lineWidth,20)),D.ctx.isPointInStroke(this.path,t,e)):!1}isPointInAnywhere(t,e){return(n=>{if(!n)return!1;let o=!1;return[...this.handlePoints].sort((l,c)=>(l.isHover?0:1)-(c.isHover?0:1)).forEach(l=>{o?l.isHover&&l.notifyHover(!1):(o=l.isPointInAnywhere(t,e),o!=l.isHover&&l.notifyHover(o))}),o})((this.isClick||!!this.isInfinite)&&this.isShowHandlePoint)||super.isPointInAnywhere(t,e)}get isWithinRange(){if(this.isInfinite){this.isRecalculate&&this.updateDynamicPosition();const{width:t,height:e}=this.mainCanvas.rect;return Bs([0,0],[t,e],this.finalDynamicPosition[0],this.finalDynamicPosition[1])}return super.isWithinRange}updateBaseData(){this.handleValuePosition("array2D",2)&&this.updateHandlePoints()}updateDynamicPosition(){const{mainCanvas:t,position:e}=this,i=t.transformPosition(e);this.internalUpdate({dynamicPosition:i}),this.updateHandlePointsPosition()}setOverlayStyles(t){var o;const e=this.mainCanvas,i=e.style[e.theme].line;let n={};return typeof this.style=="string"?n=((o=e.style[this.style])==null?void 0:o.line)||i:typeof this.style=="object"?n=rt(JSON.parse(JSON.stringify(i)),this.style):n=i,t&&this.setBaseLineStyle(t,n.stroke),n}get computedValueScopeStyles(){return this.setOverlayStyles()}drawLine(t,e){const{mainCanvas:i,isInfinite:n,isClick:o}=this;if(e=e||this.finalDynamicPosition,!i)return;this.setGlobalAlpha(t);const a=this.setOverlayStyles(t);t.beginPath(),this.path=new Path2D,e.forEach((l,c)=>{this.path[c==0?"moveTo":"lineTo"](l[0],l[1])}),t.stroke(this.path),this.isShowHandlePoint=(n||o)&&this.isHandlePointsVisible,this.isShowHandlePoint&&this.handlePoints.forEach(l=>{var c;l.style=a.point,(c=l.getDraw())==null||c[0].call(l,t)})}drawisInfiniteStraightLine(t){const{mainCanvas:e,finalDynamicPosition:i}=this;if(!e)return;this.setGlobalAlpha(t);const{rect:n}=e,[o,a]=i,l=[a[0]-o[0],a[1]-o[1]];if(l[0]===0&&l[1]===0)return console.error("重合点无法确定方向");const c=Oe(o,[-l[0],-l[1]],n.width,n.height),h=Oe(a,l,n.width,n.height);this.drawLine(t,[c,h])}getDraw(){if(this.isNeedRender){const{isRecalculate:t,isInfinite:e}=this;return t&&this.updateDynamicPosition(),e?[this.drawisInfiniteStraightLine,this]:[this.drawLine,this]}}}function Oe(r,s,t,e){const[i,n]=r,[o,a]=s;let l=1/0;if(o!==0){const c=o>0?(t-i)/o:-i/o;c>0&&(l=Math.min(l,c))}if(a!==0){const c=a>0?(e-n)/a:-n/a;c>0&&(l=Math.min(l,c))}return l===1/0?r:[i+o*l,n+a*l]}function Bs(r,s,t,e){const i=Math.min(r[0],s[0]),n=Math.max(r[0],s[0]),o=Math.min(r[1],s[1]),a=Math.max(r[1],s[1]),l=[[i,o],[n,o],[n,a],[i,a]],c=e[1]-t[1],h=t[0]-e[0],u=e[0]*t[1]-t[0]*e[1];if(c===0&&h===0){const[g,y]=t;return g>=i&&g<=n&&y>=o&&y<=a}const f=1e-10;let m=!1,p=!1;for(const[g,y]of l){const w=c*g+h*y+u;if(Math.abs(w)<f||(w>f?m=!0:p=!0,m&&p))return!0}return m&&p}class $t extends ii{constructor(t){super(t);d(this,"_isRect",!1);d(this,"dynamicBorderRadius");d(this,"_borderRadius");d(this,"_borderRadiusType","position");d(this,"isClosed",!0);d(this,"minNeededHandlePoints",3);["isRect","borderRadius","borderRadiusType"].forEach(e=>{e in t&&(this[e]=t[e])}),t.isRect&&(this.canCreateOrDeleteHandlePoint=!1)}get isRect(){return this._isRect}set isRect(t){var e;this._isRect!=t&&(this._isRect=t,this.canCreateOrDeleteHandlePoint=!t,this.updateBaseData(),(e=this.notifyReload)==null||e.call(this))}get borderRadius(){return this._borderRadius}set borderRadius(t){var e;this._borderRadius!=t&&(this._borderRadius=t,this.updateDynamicRadius(),(e=this.notifyReload)==null||e.call(this))}get borderRadiusType(){return this._borderRadiusType}set borderRadiusType(t){var e;this._borderRadiusType!=t&&(this._borderRadiusType=t,this.updateDynamicRadius(),(e=this.notifyReload)==null||e.call(this))}updateValueScope(){this.initValueScope()}isPointInPath(t,e){return this.path?D.ctx.isPointInPath(this.path,t,e):!1}isPointInStroke(t,e){return this.path&&this.mainCanvas?(this.setOverlayStyles(D.ctx),this.isDraggable&&(D.ctx.lineWidth=Math.max(D.ctx.lineWidth,20)),D.ctx.isPointInStroke(this.path,t,e)):!1}isPointInAnywhere(t,e){return(n=>{if(!n)return!1;let o=!1;return[...this.handlePoints].sort((l,c)=>(l.isHover?0:1)-(c.isHover?0:1)).forEach(l=>{o?l.isHover&&l.notifyHover(!1):(o=l.isPointInAnywhere(t,e),o!=l.isHover&&l.notifyHover(o))}),o})(this.isClick&&this.isShowHandlePoint)||super.isPointInAnywhere(t,e)}updateDynamicRadius(){const{mainCanvas:t,borderRadius:e}=this;if(!t||!e){this.dynamicBorderRadius=void 0;return}if(typeof e=="number"){this.dynamicBorderRadius=this.handleSingleRadius(e);return}this.dynamicBorderRadius=e.map(i=>this.handleSingleRadius(i,!0))}handleSingleRadius(t,e){const{mainCanvas:i,borderRadiusType:n}=this;if(t<=0)return e?0:void 0;switch(n){case"position":return t*i.percentage;default:return i.getAxisPointByValue(t,0).x}}updateBaseData(){if(!this.mainCanvas)return;let{value:t,position:e,isRect:i}=this;const n=i?2:3;i&&(Array.isArray(t)&&(t.length=2),Array.isArray(e)&&(e.length=2)),this.handleValuePosition("array2D",n)&&(this.updateHandlePoints(),this.updateDynamicRadius())}setOverlayStyles(t){var c;const e=this.isHover,i=this.mainCanvas,n=i.style[i.theme].polygon;let o={};typeof this.style=="string"?o=((c=i.style[this.style])==null?void 0:c.polygon)||n:typeof this.style=="object"?o=rt(JSON.parse(JSON.stringify(n)),this.style):o=n;const{fill:a,fill_hover:l}=o;return t&&(this.setBaseLineStyle(t,o.stroke),t.fillStyle=e?l:a),o}get computedValueScopeStyles(){return this.setOverlayStyles()}drawRect(t){this.setGlobalAlpha(t);const[[e,i],[n,o]]=this.finalDynamicPosition,a=Math.abs(n-e),l=Math.abs(o-i),c=Math.min(e,n),h=Math.min(i,o),u=this.setOverlayStyles(t);t.beginPath(),this.path=new Path2D,this.dynamicBorderRadius?this.path.roundRect(c,h,a,l,this.dynamicBorderRadius):this.path.rect(c,h,a,l),t.stroke(this.path),t.fill(this.path),this.isShowHandlePoint=this.isClick&&this.isHandlePointsVisible,this.isShowHandlePoint&&this.handlePoints.forEach(f=>{var m;f.internalUpdate({style:u.point}),(m=f.getDraw())==null||m[0].call(f,t)})}drawPolygon(t){this.setGlobalAlpha(t);const e=this.finalDynamicPosition,i=this.setOverlayStyles(t);t.beginPath(),this.path=new Path2D,e.forEach((n,o)=>{this.path[o==0?"moveTo":"lineTo"](n[0],n[1])}),this.path.closePath(),t.stroke(this.path),t.fill(this.path),this.isShowHandlePoint=this.isClick&&this.isHandlePointsVisible,this.isShowHandlePoint&&this.handlePoints.forEach(n=>{var o;n.internalUpdate({style:i.point}),(o=n.getDraw())==null||o[0].call(n,t)})}getDraw(){if(this.isNeedRender){const{mainCanvas:t,position:e}=this;if(this.isRecalculate){this.updateDynamicRadius();const i=t.transformPosition(e);this.internalUpdate({dynamicPosition:i}),this.updateHandlePointsPosition()}return this.isRect?[this.drawRect,this]:[this.drawPolygon,this]}}}class qt extends D{constructor(t){super(t);d(this,"_isFill",!1);d(this,"_isClosed",!1);d(this,"_isClosedThroughCenter",!1);d(this,"_radiusValue",0);d(this,"_radiusPosition",0);d(this,"_startAngle",0);d(this,"_endAngle",0);d(this,"_counterclockwise",!1);d(this,"isShowHandlePoint",!1);d(this,"_isHandlePointsVisible",!0);d(this,"defaultClick",(t,e)=>{var o;if(!this.isHandlePointsVisible)return;const{state:i,oldState:n}=t.data;i!=n&&((o=this.notifyReload)==null||o.call(this))});d(this,"defaultDragg",(t,e)=>{if(!this.mainCanvas)return;const i=()=>{var h;const{offsetX:n,offsetY:o}=t.data,{x:a,y:l}=this.calculateOffset(n,o);this.handlePointsArr.concat(this).forEach(u=>{u.internalUpdate({value:[k.add(u.value[0],a.value),k.add(u.value[1],l.value)],position:[k.add(u.position[0],a.position),k.add(u.position[1],l.position)],dynamicPosition:[k.add(u.dynamicPosition[0],a.dynamicPosition),k.add(u.dynamicPosition[1],l.dynamicPosition)]},!0)}),(h=this.notifyReload)==null||h.call(this)};if(this.isHandlePointsVisible){const{start:n,end:o,radius:a}=this.handlePoints,l=this.handlePointsArr.find(c=>c.isHover);if(l){const c=t.data.offsetX;if(l==n)this.startAngle=(this.startAngle+-c/180*Math.PI)%(Math.PI*2);else if(l==o)this.endAngle=(this.endAngle+-c/180*Math.PI)%(Math.PI*2);else if(l==a){const h=c/2/this.mainCanvas.percentage;this.radiusPosition+h>0&&(this.radiusPosition+=h)}}else i()}else i()});d(this,"handlePoints",{start:void 0,end:void 0,radius:void 0});["isFill","isClosed","isClosedThroughCenter","radiusValue","radiusPosition","startAngle","endAngle","counterclockwise","isHandlePointsVisible"].forEach(e=>{e in t&&(this["_"+e]=t[e])}),this.addEventListener("click",this.defaultClick),this.addEventListener("dragg",this.defaultDragg)}get isFill(){return this._isFill}set isFill(t){var e;this._isFill!=t&&(this._isFill=t,(e=this.notifyReload)==null||e.call(this))}get isClosed(){return this._isClosed}set isClosed(t){var e;this._isClosed!=t&&(this._isClosed=t,(e=this.notifyReload)==null||e.call(this))}get isClosedThroughCenter(){return this._isClosedThroughCenter}set isClosedThroughCenter(t){var e;this._isClosedThroughCenter!=t&&(this._isClosedThroughCenter=t,(e=this.notifyReload)==null||e.call(this))}get radiusValue(){return this._radiusValue}set radiusValue(t){this._radiusValue!=t&&(this._radiusValue=t,this._radiusPosition=0,this.updateBaseData())}get radiusPosition(){return this._radiusPosition}set radiusPosition(t){this._radiusPosition!=t&&(this._radiusPosition=t,this._radiusValue=0,this.updateBaseData())}get startAngle(){return this._startAngle}set startAngle(t){var e;this._startAngle!=t&&(this._startAngle=t,this.updateHandlePoints(),(e=this.notifyReload)==null||e.call(this))}get endAngle(){return this._endAngle}set endAngle(t){var e;this._endAngle!=t&&(this._endAngle=t,this.updateHandlePoints(),(e=this.notifyReload)==null||e.call(this))}get counterclockwise(){return this._counterclockwise}set counterclockwise(t){var e;this._counterclockwise!=t&&(this._counterclockwise=t,(e=this.notifyReload)==null||e.call(this))}get isHandlePointsVisible(){return this._isHandlePointsVisible}set isHandlePointsVisible(t){var e;this._isHandlePointsVisible!==t&&(this._isHandlePointsVisible=t,this.isShowHandlePoint!=t&&((e=this.notifyReload)==null||e.call(this)),this.updateHandlePoints())}get offset(){return super.offset}set offset(t){super.offset=t;let{isHandlePointsVisible:e,handlePointsArr:i}=this;e&&i.forEach(n=>n.internalUpdate({offset:t}))}updateValueScope(){const{mainCanvas:t,radiusValue:e}=this;t&&(this.initValueScope(),this.setFixedExtraScope({topV:e,bottomV:e,leftV:e,rightV:e*2}))}isPointInPath(t,e){return this.isFill&&this.path?D.ctx.isPointInPath(this.path,t,e):!1}isPointInStroke(t,e){return this.path&&this.mainCanvas?(this.setOverlayStyles(D.ctx),this.isDraggable&&(D.ctx.lineWidth=Math.max(D.ctx.lineWidth,20)),D.ctx.isPointInStroke(this.path,t,e)):!1}isPointInAnywhere(t,e){return(n=>{if(!n)return!1;let o=!1;return this.handlePointsArr.forEach(a=>{o?a.isHover&&a.notifyHover(!1):(o=a.isPointInAnywhere(t,e),o!=a.isHover&&a.notifyHover(o))}),o})(this.isClick&&this.isShowHandlePoint)||super.isPointInAnywhere(t,e)}get cursorStyle(){const t=this.handlePointsArr.some(e=>e==null?void 0:e.isHover);return this.isInteractive?this.isDraggable?"_nhanh_canvas_hover_overlay_draggable"+(t?"_ew":""):"_nhanh_canvas_hover_overlay":void 0}setOverlayStyles(t){var c;const e=this.isHover,i=this.mainCanvas,n=i.style[i.theme].arc;let o={};typeof this.style=="string"?o=((c=i.style[this.style])==null?void 0:c.arc)||n:typeof this.style=="object"?o=rt(JSON.parse(JSON.stringify(n)),this.style):o=n;const{fill:a,fill_hover:l}=o;return t&&(this.setBaseLineStyle(t,o.stroke),t.fillStyle=e?l:a),o}get computedValueScopeStyles(){return this.setOverlayStyles()}get handlePointsArr(){const t=this.handlePoints.radius;return Object.values(this.handlePoints).filter(Boolean).sort((e,i)=>(e.isHover||e==t?0:1)-(i.isHover||i==t?0:1))}updateHandlePoints(){let{mainCanvas:t,value:e,radiusValue:i,startAngle:n,endAngle:o,dynamicPosition:a,isHandlePointsVisible:l,offset:c}=this;if(!t||!a||!l)return;const[h,u]=Us(...e,i,n,o,t.axisConfig.x,t.axisConfig.y),f=w=>new ct({name:w,offset:c,value:[0,0],isDraggable:!0,mainCanvas:this.mainCanvas,notifyReload:()=>{var P;return(P=this.notifyReload)==null?void 0:P.call(this)}}),m=this.handlePoints.start||f("start"),p=this.handlePoints.end||f("end"),g=this.handlePoints.radius||f("radius");m.value=h,p.value=u;const y=e[0]+i*2*t.axisConfig.x;g.value=[y,e[1]],this.handlePoints={start:m,end:p,radius:g}}updateBaseData(){this.mainCanvas&&(this.radiusValue?this._radiusPosition=this.mainCanvas.getAxisPointByValue(this.radiusValue,0,!0).x:this._radiusValue=this.mainCanvas.getAxisValueByPoint(this.radiusPosition,0,!0).xV,this.handleValuePosition("array1D")&&this.updateHandlePoints())}drawGuideLine(t,e,i,n){this.setBaseLineStyle(t,{...n.stroke,dash:!n.stroke.dash});const{radiusPosition:o,startAngle:a,endAngle:l,counterclockwise:c,mainCanvas:h}=this;t.beginPath(),t.arc(e,i,o*h.percentage,l,a,c),t.stroke(),t.beginPath(),t.moveTo(e,i);const u=this.handlePoints.radius.finalDynamicPosition;t.lineTo(u[0],u[1]),t.stroke(),!(this.isClosed&&this.isClosedThroughCenter)&&(t.fillStyle=t.strokeStyle,t.beginPath(),t.arc(e,i,n.point.radius,0,Math.PI*2),t.fill())}draw(t){const{finalDynamicPosition:e,mainCanvas:i,startAngle:n,endAngle:o,counterclockwise:a,isFill:l,isClosed:c,isClosedThroughCenter:h,radiusPosition:u}=this;if(!i||u<=0)return;this.setGlobalAlpha(t);const f=this.setOverlayStyles(t),[m,p]=e;t.beginPath(),this.path=new Path2D,this.path.arc(m,p,u*i.percentage,n,o,a),c&&(this.path.lineTo(m,p),h&&this.path.closePath()),t.stroke(this.path),l&&t.fill(this.path),this.isShowHandlePoint=this.isClick&&this.isHandlePointsVisible,this.isShowHandlePoint&&(this.drawGuideLine(t,m,p,f),this.handlePointsArr.forEach(g=>{var y;g.internalUpdate({style:f.point}),(y=g.getDraw())==null||y[0].call(g,t)}))}getDraw(){if(this.isNeedRender){if(this.isRecalculate){const{position:t,mainCanvas:e}=this,i=this.dynamicPosition,n=e.transformPosition(t);if(this.internalUpdate({dynamicPosition:n}),this.isHandlePointsVisible)if(e!=null&&e.isScaleUpdated)this.updateHandlePoints();else{const o=n[0]-i[0],a=n[1]-i[1];this.handlePointsArr.forEach(l=>{const c=l.dynamicPosition[0]+o,h=l.dynamicPosition[1]+a;l.internalUpdate({dynamicPosition:[c,h]})})}}return[this.draw,this]}}}function Us(r,s,t,e,i,n=1,o=1){const a=r+t*Math.cos(e)*n,l=s+t*Math.sin(e)*o,c=r+t*Math.cos(i)*n,h=s+t*Math.sin(i)*o;return[[a,l],[c,h]]}class Zt extends D{constructor(t){super(t);d(this,"handlePoints");d(this,"isShowHandlePoint",!1);d(this,"_isHandlePointsVisible",!0);d(this,"_radiusValue",0);d(this,"_radiusPosition",0);d(this,"defaultClick",(t,e)=>{var o;if(!this.isHandlePointsVisible)return;const{state:i,oldState:n}=t.data;i!=n&&((o=this.notifyReload)==null||o.call(this))});d(this,"defaultDragg",(t,e)=>{this.mainCanvas});["isHandlePointsVisible"].forEach(e=>{e in t&&(this["_"+e]=t[e])}),this.addEventListener("click",this.defaultClick),this.addEventListener("dragg",this.defaultDragg)}get handlePointsArr(){if(this.handlePoints){const{radius:t,other:e}=this.handlePoints;return[t,...e].filter(Boolean).sort((i,n)=>(i.isHover||i==t?0:1)-(n.isHover||n==t?0:1))}return[]}get isHandlePointsVisible(){return this._isHandlePointsVisible}set isHandlePointsVisible(t){var e;this._isHandlePointsVisible!==t&&(this._isHandlePointsVisible=t,this.isShowHandlePoint!=t&&((e=this.notifyReload)==null||e.call(this)))}get radiusValue(){return this._radiusValue}set radiusValue(t){this._radiusValue!=t&&(this._radiusValue=t,this.updateBaseData())}get radiusPosition(){return this._radiusPosition}set radiusPosition(t){this._radiusPosition!=t&&(this._radiusPosition=t,this.updateBaseData())}updateValueScope(){this.initValueScope()}isPointInPath(t,e){return!1}isPointInStroke(t,e){return this.path&&this.mainCanvas?(this.setOverlayStyles(D.ctx),this.isDraggable&&(D.ctx.lineWidth=Math.max(D.ctx.lineWidth,20)),D.ctx.isPointInStroke(this.path,t,e)):!1}isPointInAnywhere(t,e){return(n=>{if(!n)return!1;let o=!1;return this.handlePointsArr.forEach(a=>{o?a.isHover&&a.notifyHover(!1):(o=a.isPointInAnywhere(t,e),o!=a.isHover&&a.notifyHover(o))}),o})(this.isClick&&this.isShowHandlePoint)||super.isPointInAnywhere(t,e)}get cursorStyle(){var e;const t=(e=this.handlePoints)==null?void 0:e.radius.isHover;return this.isDraggable?"_nhanh_canvas_hover_overlay_draggable"+(t?"_ns":""):"_nhanh_canvas_hover_overlay"}setOverlayStyles(t){var o;const e=this.mainCanvas,i=e.style[e.theme].arcTo;let n={};return typeof this.style=="string"?n=((o=e.style[this.style])==null?void 0:o.arcTo)||i:typeof this.style=="object"?n=rt(JSON.parse(JSON.stringify(i)),this.style):n=i,t&&this.setBaseLineStyle(t,n.stroke),n}get computedValueScopeStyles(){return this.setOverlayStyles()}updateHandlePoints(){var c,h;let{value:t,position:e,dynamicPosition:i,isHandlePointsVisible:n}=this;if(!i||!n)return;const o=()=>new ct({value:[0,0],mainCanvas:this.mainCanvas,isDraggable:!0,notifyReload:()=>{var u;return(u=this.notifyReload)==null?void 0:u.call(this)}}),a=((c=this.handlePoints)==null?void 0:c.other)||[];t==null||t.forEach((u,f)=>{a[f]||a.push(o()),a[f].internalUpdate({value:t[f],position:e[f],dynamicPosition:i[f]},!0)}),a.length=t.length;const l=((h=this.handlePoints)==null?void 0:h.radius)||o();this.handlePoints={radius:l,other:a}}updateBaseData(){if(!this.mainCanvas)return;let{value:t,position:e}=this;const[i,n]=[At(t)&&t.length>1,At(e)&&e.length>1];if(!i&&!n)return this.handlePoints=void 0,this.internalUpdate({dynamicPosition:void 0});if(i){e=[];for(let a=0;a<t.length;a++){const l=t[a],c=this.mainCanvas.getAxisPointByValue(l[0],l[1],!0);e.push([c.x,c.y])}}else{t=[];for(let a=0;a<e.length;a++){const l=e[a],c=this.mainCanvas.getAxisValueByPoint(l[0],l[1],!0);t.push([c.xV,c.yV])}}const o=this.mainCanvas.transformPosition(e);this.internalUpdate({value:t,position:e,dynamicPosition:o}),this.updateHandlePoints()}draw(t){const{dynamicPosition:e,mainCanvas:i,radiusValue:n}=this}getDraw(){if(this.isNeedRender){if(this.isRecalculate){const{position:t,mainCanvas:e}=this,i=this.dynamicPosition,n=e.transformPosition(t);if(this.internalUpdate({dynamicPosition:n}),this.isHandlePointsVisible)if(e!=null&&e.isScaleUpdated)this.updateHandlePoints();else{const o=n[0][0]-i[0][0],a=n[0][1]-i[0][1];this.handlePointsArr.forEach(l=>{const c=l.dynamicPosition[0]+o,h=l.dynamicPosition[1]+a;l.internalUpdate({dynamicPosition:[c,h]})})}}return[this.draw,this]}}}class zs extends Hs{constructor(t){super(t);d(this,"resizeObserver");d(this,"currentDrawOverlays",[]);d(this,"rely","");d(this,"maxMinValue",{minXV:0,maxXV:0,minYV:0,maxYV:0});d(this,"measureRedrawPerformance",Ge(()=>{this.isRendering=!0,this.redraw(),this.redrawInNextRenderFrame=!1,this.isRendering=!1},{level:[[1,"#F56C6C"],[.5,"#E6A23C"],[0,"#67C23A"]]}));this.canvas&&(this.resizeObserver=new ResizeObserver(be(()=>{[this.canvas.width,this.canvas.height]=[this.rect.width,this.rect.height],this.redrawOnce()},200)),this.resizeObserver.observe(this.canvas)),this.updateRely(),this.isRecalculate=!1}updateRely(){const{center:t,scale:e,rect:i,axisConfig:n}=this,o=[t.x,t.y,e,JSON.stringify(n),i.width,i.height].join();this.isRecalculate=this.rely!==o,this.rely=o}redraw(){var n,o;if(!this.canvas)return console.warn("canvas is not HTMLCanvasElement");if(this.canvas.clientWidth==0||this.canvas.clientHeight==0)return console.warn("The image argument is a canvas element with a width or height of 0.");if(!this.shouldRender())return this.clearScreen(!1);this.ctx.globalAlpha=this.opacity??1,this.updateCenter(),this.updateRely(),this.maxMinValue=this.getMaxMinValue(),this.clearScreen();const t=[];let e=[];const i=(n=this.drawAxis)==null?void 0:n.drawAxisAndGrid();i&&e.push([0,i,[]]),this.layerGroups.forEach(a=>e.push(...a.fetchCanvas())),e.sort((a,l)=>a[0]-l[0]),e.forEach(([,a,l],c)=>{this.ctx.drawImage(a,0,0),l.forEach(([[h,u],f])=>{t.push([[h+c,u],f])})}),t.sort(([[a,l],c],[[h,u],f])=>{if(a!==h)return h-a;if(l!==u)return u-l;const m=p=>p instanceof Yt?5:p instanceof Wt?4:p instanceof ct?3:p instanceof jt||p instanceof qt||p instanceof Zt?2:p instanceof $t?1:0;return m(f)-m(c)}),this.currentDrawOverlays=t.map(([,a])=>a),this.isRecalculate=!1,this.isThemeUpdated=!1,this.isScaleUpdated=!1,(o=this.notifyReload)==null||o.call(this)}redrawOnce(){this.redrawInNextRenderFrame||(this.redrawInNextRenderFrame=!0,Promise.resolve().then(()=>{this.isRendering=!0,this.redraw(),this.redrawInNextRenderFrame=!1,this.isRendering=!1}))}findOverlayByPoint(t){const{offsetX:e,offsetY:i,clientX:n,clientY:o}=t,{x:a,y:l}=this.axisConfig,c=this.getMousePositionOnAxis({clientX:n-10*a,clientY:o-10*l}),h=this.getMousePositionOnAxis({clientX:n+10*a,clientY:o+10*l}),u=this.getAxisValueByPoint(c.x,c.y),f=this.getAxisValueByPoint(h.x,h.y);return[...this.currentDrawOverlays].sort((m,p)=>(m.isDraggable&&m.isClick?0:1)-(p.isDraggable&&p.isClick?0:1)).find(m=>{const p=m.valueScope;return p&&(p.maxX<u.xV||p.minX>f.xV||p.maxY<u.yV||p.minY>f.yV)?!1:m.isPointInAnywhere(e,i)})}destroy(){var t;(t=this.resizeObserver)==null||t.disconnect()}}class Gs extends zs{constructor(t){super(t);d(this,"mouseInCanvas",!1);d(this,"mouseIsDown",!1);d(this,"mouseLastPosition",{x:0,y:0});d(this,"unBind");d(this,"lastClickedOverlay");d(this,"lockNotifyClick",!1);d(this,"lastContextmenuOverlay");d(this,"defaultContextmenu",(t,e)=>{const i=this.lastClickedOverlay;i!=null&&i.isDraggable&&i.notifyClick(!1,e)});d(this,"lastPressedKey",{key:"",keyupTime:0,doubleClick:!1});d(this,"defaultWheel",(t,e)=>{this.setScale(e,t.data),this.redrawOnce()});d(this,"lastDownOverlay");d(this,"defaultDown",(t,e)=>{(e==null?void 0:e.button)==0&&(this.mouseIsDown=!0)});d(this,"lastHoverOverlay");d(this,"lastCursorStyle");d(this,"oldClientX",[]);d(this,"oldClientY",[]);this.initEvent(),this.addEventListener("contextmenu",this.defaultContextmenu),this.addEventListener("down",this.defaultDown),this.addEventListener("wheel",this.defaultWheel)}initEvent(){const{canvas:t}=this;if(!t)return console.error("canvas is not HTMLCanvasElement");const e=[{type:"click",handler:this.click.bind(this)},{type:"contextmenu",handler:this.contextmenu.bind(this)},{type:"mouseenter",handler:this.mouseenter.bind(this)},{type:"mouseleave",handler:this.mouseleave.bind(this)},{type:"keydown",handler:this.keydown.bind(this),target:window},{type:"keyup",handler:this.keyup.bind(this),target:window},{type:"wheel",handler:this.wheel.bind(this)},{type:"mousedown",handler:this.mousedown.bind(this)},{type:"mouseup",handler:this.mouseup.bind(this),target:window},{type:"mousemove",handler:this.mousemove.bind(this),target:window},{type:"touchend",handler:this.touchend.bind(this)},{type:"touchmove",handler:this.touchmove.bind(this)}];e.forEach(({type:i,handler:n,target:o=t})=>{o.addEventListener(i,n)}),this.unBind=()=>{e.forEach(({type:i,handler:n,target:o=t})=>{o.removeEventListener(i,n)})}}click(t){var i;if(!this.isClickable)return;if(this.lockNotifyClick)return this.lockNotifyClick=!1;const e=this.findOverlayByPoint(t);this.lastClickedOverlay!=e&&((i=this.lastClickedOverlay)==null||i.notifyClick(!1,t)),e==null||e.notifyClick(!0,t),this.lastClickedOverlay=e,this.notifyClick(!0,t)}contextmenu(t){var i;if(!this.isContextmenuable)return;t.preventDefault();const e=this.findOverlayByPoint(t);this.lastContextmenuOverlay!=e&&((i=this.lastContextmenuOverlay)==null||i.notifyContextmenu(!1,t)),e==null||e.notifyContextmenu(!0,t),this.lastContextmenuOverlay=e,this.notifyContextmenu(!0,t)}mouseenter(t){this.mouseInCanvas=!0}mouseleave(t){this.mouseInCanvas=!1}getStep(t){const{lastPressedKey:e}=this;return e.doubleClick?4:e.key===t&&Date.now()-e.keyupTime<300?(e.doubleClick=!0,4):1}keydown(t){const{mouseInCanvas:e,offset:i,delta:n,axisConfig:o}=this,a=t.key;if(!e||!this.isDraggable||this.isAuto)return;const l=this.getStep(a),c=this.lastClickedOverlay,u=(c==null?void 0:c.isDraggable)&&this.currentDrawOverlays.includes(c)&&(At(c.value)?"Matrix":oe(c.value)?"Single":!1),f=(y,w)=>{if(!u)return i.x+=y*l,i.y+=w*l,!0;const P=this.getAxisValueByPoint(l,0).xV,[b,E]=[P*o.x,P*o.y];if(u==="Single"){const O=c.value;O[0]+=y*b,O[1]+=w*E}else c.value.forEach(O=>{O[0]+=y*b,O[1]+=w*E});return c.value=[...c.value],!0},m=y=>(this.setScale("center",y*n),!0),g={ArrowUp:()=>f(0,-1),ArrowDown:()=>f(0,1),ArrowLeft:()=>f(-1,0),ArrowRight:()=>f(1,0),"+":()=>m(1),"-":()=>m(-1)}[a];g!=null&&g()&&(this.redrawOnce(),t.preventDefault())}keyup(t){const{mouseInCanvas:e,lastPressedKey:i}=this;if(e){const n=t.key;i.key=n,i.keyupTime=Date.now(),i.doubleClick=!1}}wheel(t){if(!this.isWheelable)return;t.preventDefault();const{delta:e,isAuto:i}=this;if(i)return;const n=t.deltaY<0?e:-e,o=this.findOverlayByPoint(t);o==null||o.notifyWheel(n,t),this.notifyWheel(n,t)}mousedown(t){var o;if(!this.isDownable)return;const{clientX:e,clientY:i}=t;this.mouseLastPosition={x:e,y:i};const n=this.findOverlayByPoint(t);this.lastDownOverlay!=n&&((o=this.lastDownOverlay)==null||o.notifyDown(!1,t),n==null||n.notifyDown(!0,t)),this.lastDownOverlay=n,this.notifyDown(!0,t)}mouseup(t){this.mouseIsDown=!1,this.lastDownOverlay=void 0}mousemove(t){this.isAuto||(this.canvas.classList.toggle("_nhanh_canvas_draggable",this.isDraggable),this.mouseIsDown?this.handleDragMove(t):this.handleHover(t))}handleDragMove(t){if(!this.isDraggable)return;const{clientX:e,clientY:i}=t,n={x:e,y:i};if(JSON.stringify(n)==JSON.stringify(this.mouseLastPosition))return;const{lastDownOverlay:o}=this;o!=null&&o.isDraggable?this.notifyDraggOverlays(t):this.handleCanvasPan(t),this.mouseLastPosition=n,this.lockNotifyClick=!0}notifyDraggOverlays(t){const e=this.lastDownOverlay,{mouseLastPosition:i}=this,{clientX:n,clientY:o}=t;e.notifyDragg({offsetX:n-i.x,offsetY:o-i.y},t)}handleCanvasPan(t){const{clientX:e,clientY:i}=t,{offset:n,mouseLastPosition:o}=this,a=e-o.x,l=i-o.y;n.x+=a,n.y+=l,this.redrawOnce(),this.notifyDragg({offsetX:a,offsetY:l},t)}handleHover(t){if(!this.isHoverable||t.target!=this.canvas)return;const e=this.findOverlayByPoint(t);this.updateHoverState(e,t),this.notifyHover(!0,t)}updateHoverState(t,e){if(this.lastHoverOverlay===t){const n=t==null?void 0:t.cursorStyle;n!==this.lastCursorStyle&&(this.lastCursorStyle&&this.canvas.classList.remove(this.lastCursorStyle),n&&this.canvas.classList.add(n),this.lastCursorStyle=n);return}this.lastHoverOverlay&&t&&t.hasController("hover",this.lastHoverOverlay)||(this.clearHoverState(e),this.applyHoverState(t,e)),this.lastHoverOverlay=t}clearHoverState(t){this.lastHoverOverlay&&(this.lastHoverOverlay.notifyHover(!1,t),this.lastHoverOverlay.cursorStyle&&this.canvas.classList.remove(this.lastHoverOverlay.cursorStyle))}applyHoverState(t,e){t&&(t.notifyHover(!0,e),this.lastCursorStyle=t.cursorStyle,this.lastCursorStyle&&this.canvas.classList.add(this.lastCursorStyle))}touchend(t){this.oldClientX=this.oldClientY=[]}touchmove(t){if(!this.isDraggable)return;const e=t.touches;t.preventDefault();const{oldClientX:i,oldClientY:n,offset:o,delta:a,isAuto:l,isDraggable:c}=this;if(c&&!l){if(e.length===1){const{clientX:h,clientY:u}=e[0];i.length&&(o.x+=h-i[0],o.y+=u-n[0],this.redrawOnce()),this.oldClientX=[h],this.oldClientY=[u]}else if(e.length===2){const{clientX:h,clientY:u}=e[0],{clientX:f,clientY:m}=e[1];if(i.length==2){const p=xe(i[0],n[0],i[1],n[1]),g=xe(h,u,f,m),{x:y,y:w}=Ee(h,u,f,m);this.setScale({clientX:y,clientY:w},g>p?a:-a),this.redrawOnce()}this.oldClientX=[h,f],this.oldClientY=[u,m]}}}destroy(){var t;super.destroy(),(t=this.unBind)==null||t.call(this)}}class Y extends Lt{constructor(t){super(t);d(this,"overlays",new Set);d(this,"oldOverlaysSize",0);this.setNotifyReload(t.notifyReload)}get overlaysSizeChange(){const t=this.oldOverlaysSize;return this.oldOverlaysSize=this.overlays.size,this.overlays.size!==t}setMainCanvas(t){var e;super.setMainCanvas(t),this.overlays.forEach(i=>{i.setMainCanvas(t),i.parent=this}),t&&this.overlays.size&&((e=this.notifyReload)==null||e.call(this))}setNotifyReload(t){this.notifyReload=t?e=>{e&&(this.isRecalculate=!0),(e||this.overlaysSizeChange||this.shouldRender()&&this.overlays.size)&&t()}:void 0,this.overlays.forEach(e=>e.setNotifyReload(this.notifyReload))}addOverlay(t){var e;[t].flat().forEach(i=>{i.setNotifyReload(this.notifyReload),i.setMainCanvas(this.mainCanvas),i.parent=this,this.overlays.add(i)}),(e=this.notifyReload)==null||e.call(this)}hasOverlay(t){return this.overlays.has(t)}removeOverlay(t){var e;[t].flat().forEach(i=>{this.overlays.delete(i),i.setNotifyReload(),i.setMainCanvas(),i.parent=void 0}),(e=this.notifyReload)==null||e.call(this)}clearOverlay(){var t;(t=this.notifyReload)==null||t.call(this),this.overlays.forEach(e=>{e.setNotifyReload(),e.setMainCanvas(),e.parent=void 0}),this.overlays.clear()}getOverlaysDrawingMethod(){const t=[];return this.shouldRender()&&this.overlays.size&&Array.from(this.overlays.values()).sort((e,i)=>e.zIndex-i.zIndex).forEach(e=>{if(e.equalsMainCanvas(this.mainCanvas)){const i=e.getDraw();i&&t.push([Number(e.zIndex)||0,i])}else this.overlays.delete(e)}),t}}class W extends Lt{constructor(t){super(t);d(this,"_zIndex",4);d(this,"canvas",document.createElement("canvas"));d(this,"ctx",this.canvas.getContext("2d"));d(this,"isReload",!1);d(this,"groups",new Map);d(this,"oldGroupsSize",0);d(this,"currentDrawOverlays",[]);this.setNotifyReload(t.notifyReload),typeof t.zIndex=="number"&&(this.zIndex=t.zIndex)}get zIndex(){return this._zIndex}set zIndex(t){var e;this._zIndex!=t&&(this._zIndex=t,(e=this.notifyReload)==null||e.call(this))}get groupsSizeChange(){const t=this.oldGroupsSize;return this.oldGroupsSize=this.groups.size,this.groups.size!==t}setMainCanvas(t){super.setMainCanvas(t),this.canvas.width=(t==null?void 0:t.rect.width)||0,this.canvas.height=(t==null?void 0:t.rect.height)||0,this.groups.forEach(e=>{e.setMainCanvas(t),e.parent=this})}setNotifyReload(t){this.notifyReload=t?e=>{e&&(this.isRecalculate=!0),(e||this.groupsSizeChange||this.shouldRender()&&this.groups.size)&&t()}:void 0,this.groups.forEach(e=>this.setGroupNotifyReload(e))}setGroupNotifyReload(t){t.setNotifyReload(this.notifyReload?()=>{var e;(e=this.notifyReload)==null||e.call(this),this.isReload=!0}:void 0)}getGroup(t){return this.groups.get(t)}addGroup(t){[t].flat().forEach(e=>{e instanceof Y&&(this.setGroupNotifyReload(e),e.setMainCanvas(this.mainCanvas),e.parent=this,this.groups.set(e.name,e))})}removeGroup(t){var i;let e=!1;[t].flat().forEach(n=>{n instanceof Y&&(this.groups.delete(n.name),n.setNotifyReload(),n.setMainCanvas(),n.parent=void 0,e=!0)}),e&&((i=this.notifyReload)==null||i.call(this))}clearGroup(){var t;this.groups.size&&(this.groups.forEach(e=>{e.setNotifyReload(),e.setMainCanvas(),e.parent=void 0}),this.groups.clear(),(t=this.notifyReload)==null||t.call(this))}getCanvas(){if(!this.mainCanvas)return;const{rect:t,isThemeUpdated:e}=this.mainCanvas,i=this.shouldRender(),n=this.groups.size;if(i&&n){if(this.isReload||this.isRecalculate||e){this.currentDrawOverlays=[],this.isReload=!1,this.canvas.width=t.width||0,this.canvas.height=t.height||0;const o=[];this.groups.forEach(a=>{a.equalsMainCanvas(this.mainCanvas)?o.push(...a.getOverlaysDrawingMethod()):this.groups.delete(a.name)}),o.sort((a,l)=>a[0]-l[0]),o.forEach(([a,[l,c]])=>{l.call(c,this.ctx),this.currentDrawOverlays.push([[Number(this.zIndex)||0,a],c])})}return[Number(this.zIndex)||0,this.canvas,this.currentDrawOverlays]}}}class kt extends Lt{constructor(t){super(t);d(this,"layers",new Map);d(this,"oldLlayersSize",0);d(this,"defaultContextmenu",(t,e)=>t.stopPropagation());d(this,"defaultClick",(t,e)=>t.stopPropagation());d(this,"defaultDoubleClick",(t,e)=>t.stopPropagation());d(this,"defaultHover",(t,e)=>t.stopPropagation());d(this,"defaultDragg",(t,e)=>t.stopPropagation());d(this,"defaultDown",(t,e)=>t.stopPropagation());this.inheritOpacity=!1,this.setNotifyReload(t.notifyReload),this.addEventListener("contextmenu",this.defaultContextmenu),this.addEventListener("click",this.defaultClick),this.addEventListener("doubleClick",this.defaultDoubleClick),this.addEventListener("hover",this.defaultHover),this.addEventListener("dragg",this.defaultDragg),this.addEventListener("down",this.defaultDown)}get layersSizeChange(){const t=this.oldLlayersSize;return this.oldLlayersSize=this.layers.size,this.layers.size!==t}setMainCanvas(t){super.setMainCanvas(t),this.layers.forEach(e=>{e.setMainCanvas(t),e.parent=this})}setNotifyReload(t){this.notifyReload=t?e=>{e&&(this.isRecalculate=!0),(e||this.layersSizeChange||this.shouldRender()&&this.layers.size)&&t()}:void 0,this.layers.forEach(e=>e.setNotifyReload(this.notifyReload))}getLayer(t){return this.layers.get(t)}addLayer(t){[t].flat().forEach(e=>{e instanceof W&&(e.setNotifyReload(this.notifyReload),e.setMainCanvas(this.mainCanvas),e.parent=this,this.layers.set(e.name,e))})}removeLayer(t){var i;let e=!1;[t].flat().forEach(n=>{n instanceof W&&(this.layers.delete(n.name),n.setNotifyReload(),n.setMainCanvas(),n.parent=void 0,e=!0)}),e&&((i=this.notifyReload)==null||i.call(this))}clearLayer(){var t;this.layers.size&&(this.layers.forEach(e=>{e.setNotifyReload(),e.setMainCanvas(),e.parent=void 0}),this.layers.clear(),(t=this.notifyReload)==null||t.call(this))}fetchCanvas(){if(this.shouldRender()&&this.layers.size){const t=[];return this.layers.forEach(e=>{if(e.equalsMainCanvas(this.mainCanvas)){const i=e.getCanvas();i&&t.push(i)}else this.layers.delete(e.name)}),t}return[]}}class Xs extends Gs{getDefaultOverlayGroup(){var c,h,u,f,m,p,g;const s=this.layerGroups.get("默认图层群组");if(!s)return;const t=(c=s.getLayer("点位图层"))==null?void 0:c.getGroup("点位覆盖物群组"),e=(h=s.getLayer("线段图层"))==null?void 0:h.getGroup("线段覆盖物群组"),i=(u=s.getLayer("多边形图层"))==null?void 0:u.getGroup("多边形覆盖物群组"),n=(f=s.getLayer("文字图层"))==null?void 0:f.getGroup("文字覆盖物群组"),o=(m=s.getLayer("自定义绘制图层"))==null?void 0:m.getGroup("自定义绘制覆盖物群组"),a=(p=s.getLayer("图片图层"))==null?void 0:p.getGroup("图片覆盖物群组"),l=(g=s.getLayer("其他图层"))==null?void 0:g.getGroup("其他覆盖物群组");return{overlays_text:n,overlays_point:t,overlays_line:e,overlays_polygon:i,overlays_custom:o,overlays_billboard:a,overlays_other:l}}getAllOverlays(s){const t=[],e=s!==void 0?Array.isArray(s)?[...s]:[s]:Array.from(this.layerGroups.values());for(;e.length>0;){const i=e.pop();if(i instanceof kt){if(!i.isVisible)continue;e.push(...i.layers.values())}else if(i instanceof W){if(!i.isVisible)continue;e.push(...i.groups.values())}else if(i instanceof Y){if(!i.isVisible)continue;e.push(...i.overlays.values())}else i.isVisible&&t.push(i)}return t}}class Ys extends Xs{zoom(s){const{canvas:t,rect:e}=this;if(!t||!e)return console.error("canvas is not HTMLCanvasElement");this.setScale("center",s),this.redrawOnce()}zoomIn(){this.zoom(this.delta)}zoomOut(){this.zoom(-this.delta)}setStyle(s){super.setStyle(s),this.redrawOnce()}setTheme(s){super.setTheme(s),this.redrawOnce()}setAxis(s){super.setAxis(s),this.redrawOnce()}setDefaultCenter(s){super.setDefaultCenter(s),this.redrawOnce()}}class Ws extends Ys{setFitView(s=void 0,t=!1,e=[60,60,60,60],i){const n=this.getAllOverlays(s);if(n.length===0)return;const{minX:o,maxX:a,minY:l,maxY:c}=this.calculateBoundingBox(n),h=a-o,u=c-l,f=this.calculateOptimalScale(h,u,e,i),m=this.calculateOffsetDifference(o,a,l,c,e);f==this.scale&&m.x==0&&m.y==0||(t?this.applyTransformImmediately(f,m):this.animateTransform(f,m))}calculateBoundingBox(s){let t=1/0,e=-1/0,i=1/0,n=-1/0;for(const o of s){const a=o.valueScope;t=Math.min(t,a.minX),e=Math.max(e,a.maxX),i=Math.min(i,a.minY),n=Math.max(n,a.maxY)}return{minX:t,maxX:e,minY:i,maxY:n}}calculateOptimalScale(s,t,e,i){const{cycle:n,delta:o,axisConfig:a,rect:l}=this,{width:c,height:h}=l,u=Math.max(0,c-e[1]-e[3])||c,f=Math.max(0,h-e[0]-e[2])||h;if(u<=0||f<=0)return console.warn("无效的可视区域尺寸,边距设置可能不合理"),this.scale;const m=s/u,p=t/f,g=Math.max(m,p),y=a.count,w=y/a.min,P=n*o;let b;if(g>w){const E=Math.ceil(g/w);b=1-((y*E/g-a.min)/a.min+(E-2))*P}else{const E=(dt,ot,yt)=>dt<ot?yt-1:E(dt/2,ot,yt+1),O=E(w,g,0),G=Math.pow(2,O);b=1+((y/G/g-a.min)/a.min+O)*P}return i!==void 0&&(b=Math.min(i,b)),b=new R(b).div(o).round().mul(o).toNumber(),b}calculateOffsetDifference(s,t,e,i,n){const{width:o,height:a}=this.rect,{axisConfig:l,center:c}=this,h=(t+s)/2,u=(i+e)/2,f=this.getAxisPointByValue(h,u),m=this.getAxisValueByPoint((o/2-c.x)*l.x,(a/2-c.y)*l.y),p=this.getAxisPointByValue(m.xV,m.yV);return{x:Math.round(-(f.x+(n[3]-n[1])-p.x)*l.x),y:Math.round(-(f.y+(n[0]-n[2])-p.y)*l.y)}}applyTransformImmediately(s,t){this.offset={x:this.offset.x+t.x,y:this.offset.y+t.y},this.scale=s,this.updateSize(),this.redrawOnce()}animateTransform(s,t){const e=this.scale,i={...this.offset},n=300;this.isAuto=!0;const o=()=>this.isAuto=!1;(c=>this.animateOffset(i,t,n,c||o))(c=>this.animateScale(e,s,n,c||o))}animateScale(s,t,e,i){const n=t-s;let o=0;Vt(a=>{!this.isAuto||!this.canvas||!this.isInteractive||(this.setScale("center",(a-o)*n),o=a,this.redrawOnce(),a===1&&i())},e)}animateOffset(s,t,e,i){Vt(n=>{!this.isAuto||!this.canvas||!this.isInteractive||(this.offset={x:Number((s.x+t.x*n).toFixed(0)),y:Number((s.y+t.y*n).toFixed(0))},this.redrawOnce(),n===1&&i())},e)}returnToOrigin(){if(!this.isInteractive||this.scale==this.defaultScale&&this.offset.x==0&&this.offset.y==0)return;const{rect:s,axisConfig:t}=this,e=this.getDefaultCenterLocation(),i=(s.width/2-e.x)*t.x,n=(s.height/2-e.y)*t.y,o=this.getAxisValueByPoint(i,n,!0),a=this.getMousePositionOnAxis({clientX:s.x+s.width/2,clientY:s.y+s.height/2}),l=this.getAxisValueByPoint(a.x,a.y),c=t.size/this.getNowGridCount,h=Math.round((l.xV-o.xV)*t.x*c),u=Math.round((l.yV-o.yV)*t.y*c);h==0&&u==0||this.animateTransform(this.defaultScale,{x:h,y:u})}}class js extends Ws{toggleAxis(s){this.drawAxis.toggleAxis(s),this.redrawOnce()}togglePoint(s){const{overlays_point:t}=this.getDefaultOverlayGroup()||{};return t?(t.isVisible=s??!t.isVisible,this.redrawOnce(),t.isVisible):!1}toggleLine(s){const{overlays_line:t}=this.getDefaultOverlayGroup()||{};return t?(t.isVisible=s??!t.isVisible,this.redrawOnce(),t.isVisible):!1}togglePolygon(s){const{overlays_polygon:t}=this.getDefaultOverlayGroup()||{};return t?(t.isVisible=s??!t.isVisible,this.redrawOnce(),t.isVisible):!1}toggleLock(s){return this.isInteractive=s??!this.isInteractive,this.isInteractive}}class $s extends js{static clearPathRegion(s,t){const{width:e,height:i}=s.canvas;s.save(),s.beginPath(),s.clip(t),s.clearRect(0,0,e,i),s.restore()}}class qs extends $s{}class Zs{constructor(s){d(this,"canvas");d(this,"axis_canvas",document.createElement("canvas"));d(this,"ctx",this.axis_canvas.getContext("2d"));d(this,"isReload",!0);d(this,"show",{all:!0,grid:{main:!0,secondary:!0},axis:!0,axisText:!0});this.canvas=s,this.initAxisCanvas()}initAxisCanvas(){const{canvas:s,axis_canvas:t}=this;s&&(t.width=s.rect.width||0,t.height=s.rect.height||0)}toggleAxis(s){const t=(()=>{if(typeof s=="object"){const{all:e=!0,axis:i=!0,axisText:n=!0}=s,o=Object.assign({main:!0,secondary:!0},s.grid);return{all:e,grid:o,axis:i,axisText:n}}return typeof s=="boolean"?{all:!0,grid:{main:s,secondary:s},axis:s,axisText:s}:!this.show.all})();typeof t=="boolean"?this.show.all=t:this.show=t,this.isReload=!0}drawAxisAndGrid(){if(!(!this.canvas||!this.show.all))return(this.canvas.isRecalculate||this.isReload||this.canvas.isThemeUpdated)&&(this.isReload=!1,this.initAxisCanvas(),(this.show.grid.main||this.show.grid.secondary)&&this.drawGrid(),this.show.axis&&this.drawAxis(),this.show.axisText&&this.drawAxisText()),this.axis_canvas}color(){const{theme:s,style:t}=this.canvas;return(t[s]||t.light).grid}drawGrid(){const{canvas:s,ctx:t}=this,{rect:e,center:i,axisConfig:n}=s,{width:o,height:a}=e,l=this.color(),c=n.size,h=c/5;t.lineWidth=1;const u=(m,p)=>{const g=i.x%m>0?i.x%m:m+i.x%m;t.strokeStyle=p,t.beginPath();for(let y=0;y*m+g<=o;y++)t.moveTo(y*m+g,0),t.lineTo(y*m+g,a);t.stroke()},f=(m,p)=>{const g=i.y%m>0?i.y%m:m+i.y%m;t.strokeStyle=p,t.beginPath();for(let y=0;y*m+g<=a;y++)t.moveTo(0,y*m+g),t.lineTo(o,y*m+g);t.stroke()};this.show.grid.secondary&&(u(h,l.innerGrid),f(h,l.innerGrid)),this.show.grid.main&&(u(c,l.grid),f(c,l.grid))}drawAxis(){const{canvas:s,ctx:t}=this,{rect:e,center:i}=s,{width:n,height:o}=e,a=this.color();t.lineWidth=2,t.strokeStyle=a.axis;const l=()=>{i.y>=0&&i.y<=o&&(t.beginPath(),t.moveTo(0,i.y),t.lineTo(n,i.y),t.stroke())},c=()=>{i.x>=0&&i.x<=n&&(t.beginPath(),t.moveTo(i.x,0),t.lineTo(i.x,o),t.stroke())};l(),c()}drawText(s,t,e,i){const{canvas:n,ctx:o}=this,{theme:a}=n,l=this.canvas.style[a].text;o.font=`${l.bold?"bold":""} ${l.size}px ${l.family}`,o.strokeStyle=l.stroke,![s,t,e].includes(void 0)&&o.strokeText(s,t,e),o.fillStyle=l[i?"secondary":"color"],![s,t,e].includes(void 0)&&o.fillText(s,t,e)}drawAxisText(){const{canvas:s,ctx:t}=this,{rect:e,center:i,axisConfig:n,style:o,theme:a}=s,{width:l,height:c}=e;this.drawText();const h=g=>Math.ceil(t.measureText(g).width),u=4,f=o[a].text.size;{const g=h("0"),y=i.x<u||i.x>l+g+u,w=i.y<-(u+f)||i.y>c+f+u;!y&&!w&&this.drawText("0",i.x-g-u,i.y+f+u)}const m=s.getNowGridCount,p=n.size;{let g=i.y+f+u;g=Math.max(Math.min(g,c-u),u+f);const y=i.y>c||i.y<0;let w=i.x>0?i.x%p:i.x<0?p+i.x%p:0,P=s.getAxisValueByPoint((w-i.x)*n.x,0).xV;for(;w<=l;){const b=Qt(P),E=h(b);P!==0&&this.drawText(b,w-E/2,g,y),w+=p,P=new R(m).mul(n.x).add(P).toNumber()}}{const g=i.x>l||i.x<0;let y=i.y>0?i.y%p:i.y<0?p+i.y%p:0,w=s.getAxisValueByPoint(0,(y-i.y)*n.y).yV;for(;y<=c;){const P=Qt(w),b=h(P);let E=i.x-b-u;E=Math.max(Math.min(E,l-b-u),u),w!=0&&this.drawText(P,E,y+f/2,g),y+=p,w=new R(m).mul(n.y).add(w).toNumber()}}}}class Qs{constructor(s){d(this,"canvas");d(this,"layerGroup",new L.LayerGroup({name:"创建覆盖物图层群组"}));d(this,"overlayLayer",new L.Layer({name:"creator-layer",zIndex:9999}));d(this,"overlayGroup",new L.OverlayGroup({name:"creator-group"}));d(this,"overlay");d(this,"axisValueList");d(this,"savedLayerGroupInteractive",new Map);d(this,"axisValueLimiter");d(this,"finish");d(this,"handleMousemove",s=>{var e;if(!this.overlay||!s||(((e=this.axisValueList)==null?void 0:e.length)??0)===0)return;const t=this.getAxisValueFromEvent(s);if(t){const i=[...this.axisValueList||[],t],n=this.minPointCount-i.length;Array.from({length:n}).forEach(()=>i.push(t)),this.overlay.value=i}});d(this,"handleClick",(s,t)=>{if(!this.overlay||!t)return;const e=this.getAxisValueFromEvent(t);e&&(this.axisValueList=[...this.axisValueList||[],e],this.handleMousemove(t))});d(this,"handleContextmenu",(s,t)=>{var i,n;if(!this.overlay)return;(((i=this.axisValueList)==null?void 0:i.length)??0)>=this.minPointCount?(this.overlay.value=this.axisValueList,(n=this.finish)==null||n.call(this,this.overlay)):this.overlayGroup.removeOverlay(this.overlay),this.overlay=void 0,this.axisValueList=void 0,this.restoreLayerGroupsInteractive()});this.canvas=s,this.overlayLayer.addGroup(this.overlayGroup),this.layerGroup.addLayer(this.overlayLayer),s.setLayerGroup(this.layerGroup),s.addEventListener("click",this.handleClick),s.addEventListener("contextmenu",this.handleContextmenu),s.canvas.addEventListener("mousemove",this.handleMousemove)}disableOtherLayerGroups(){this.canvas.layerGroups.forEach(s=>{this.layerGroup!==s&&(this.savedLayerGroupInteractive.has(s)||this.savedLayerGroupInteractive.set(s,s.isInteractive),s.isInteractive=!1)})}restoreLayerGroupsInteractive(){this.savedLayerGroupInteractive.forEach((s,t)=>{t.isInteractive=s}),this.savedLayerGroupInteractive.clear()}createLine(s){return this.disableOtherLayerGroups(),this.overlay&&this.overlayGroup.removeOverlay(this.overlay),this.axisValueList=[],this.overlay=new L.Line({...s}),this.overlayGroup.addOverlay(this.overlay),this.overlay}createPolygon(s){return this.disableOtherLayerGroups(),this.overlay&&this.overlayGroup.removeOverlay(this.overlay),this.axisValueList=[],this.overlay=new L.Polygon({...s}),this.overlayGroup.addOverlay(this.overlay),this.overlay}removeOverlay(s){s?this.overlayGroup.removeOverlay(s):this.overlayGroup.clearOverlay()}clear(){this.restoreLayerGroupsInteractive(),this.overlayGroup.clearOverlay(),this.overlay=void 0,this.axisValueList=void 0}destroy(){this.clear(),this.canvas.removeEventListener("click",this.handleClick),this.canvas.removeEventListener("contextmenu",this.handleContextmenu),this.canvas.canvas.removeEventListener("mousemove",this.handleMousemove)}get minPointCount(){return this.overlay instanceof L.Polygon?3:this.overlay instanceof L.Line?2:0}getAxisValueFromEvent(s){const t=this.canvas.getMousePositionOnAxis(s);if(t){const{xV:e,yV:i}=this.canvas.getAxisValueByPoint(t.x,t.y);let n=[e,i];return this.axisValueLimiter&&(n=this.axisValueLimiter(n)),n}}}class Js{static computeDefaultScale(s,t,e,i,n=.02,o=.2){const a=s/e,l=t/i;if(a>1||l>1){const m=Math.max(a,l),p=Math.floor(Math.log2(m)),g=(p+m/Math.pow(2,p)-1)*o;return 1-Math.ceil(g/n)*n}const c=Math.min(e/s,i/t),h=Math.floor(Math.log2(c)),u=(h+c/Math.pow(2,h)-1)*o;return 1+Math.floor(u/n)*n}static computeDefaultCenter(s,t,e,i){return{left:(s-e)/-2,top:(t-i)/-2}}}class Ks extends D{constructor(t){super(t);d(this,"_ready",!1);d(this,"image",new Image);d(this,"_url");d(this,"_objectFit","fill");this.image.onload=()=>{this.ready=!0},this.image.onerror=()=>{this.ready=!1,console.error("图片加载失败")}}get ready(){return this._ready}set ready(t){var e;this._ready!=t&&(this._ready=t,(e=this.notifyReload)==null||e.call(this))}get url(){return this._url}set url(t){this._url!=t&&(this._url=t,this.updateBaseData())}get objectFit(){return this._objectFit}set objectFit(t){var e;this._objectFit!=t&&(this._objectFit=t,(e=this.notifyReload)==null||e.call(this))}get drawRect(){const{mainCanvas:t,finalDynamicPosition:e,value:i,image:n,objectFit:o}=this,[a,l]=e[0];let c=n.naturalWidth,h=n.naturalHeight;if(t&&i&&i.length>1){const P=[i[1][0]-i[0][0],i[1][1]-i[0][1]],b=t.getAxisPointByValue(P[0],P[1]);c=b.x,h=b.y}const u={x:a,y:l,w:c,h},f=n.naturalWidth,m=n.naturalHeight;if(f<=0||m<=0||u.w<=0||u.h<=0)return u;const p=u.w/u.h,g=f/m;if(o==="fill")return u;if(o==="contain"||o==="scale-down"){const P=Math.min(u.w/f,u.h/m),b=o==="scale-down"?Math.min(1,P):P,E=f*b,O=m*b;return{x:u.x+(u.w-E)/2,y:u.y+(u.h-O)/2,w:E,h:O}}if(g>p){const P=m*p,b=(f-P)/2;return{...u,sx:b,sy:0,sw:P,sh:m}}const y=f/p,w=(m-y)/2;return{...u,sx:0,sy:w,sw:f,sh:y}}updateBaseData(){this.mainCanvas&&(this.ready=!1,this.url&&(this.image.src=this.url),this.handleValuePosition("array2D",1))}}class de extends Ks{constructor(t){super(t);d(this,"defaultDragg",(t,e)=>{var l;const{offsetX:i,offsetY:n}=t.data,{x:o,y:a}=this.calculateOffset(i,n);this.value.forEach((c,h)=>{this.value[h]=[k.add(this.value[h][0],o.value),k.add(this.value[h][1],a.value)],this.position[h]=[k.add(this.position[h][0],o.position),k.add(this.position[h][1],a.position)],this.dynamicPosition[h]=[k.add(this.dynamicPosition[h][0],o.dynamicPosition),k.add(this.dynamicPosition[h][1],a.dynamicPosition)]}),(l=this.notifyReload)==null||l.call(this),this.updateValueScope()});const{url:e,objectFit:i}=t;Object.assign(this,{url:e,objectFit:i}),this.addEventListener("dragg",this.defaultDragg)}updateValueScope(){this.initValueScope()}isPointInPath(t,e){return this.path?D.ctx.isPointInPath(this.path,t,e):!1}isPointInStroke(t,e){return!1}setOverlayStyles(t){var o;const e=this.mainCanvas,i=e.style[e.theme].billboard;let n={};return typeof this.style=="string"?n=((o=e.style[this.style])==null?void 0:o.billboard)||i:typeof this.style=="object"?n=rt(JSON.parse(JSON.stringify(i)),this.style):n=i,t&&this.setBaseLineStyle(t,n.stroke),n}get computedValueScopeStyles(){return{}}draw(t){const{mainCanvas:e,ready:i,image:n,isHover:o}=this;if(!e||!i)return;this.setGlobalAlpha(t),this.setOverlayStyles(t);const{x:a,y:l,w:c,h,sx:u,sy:f,sw:m,sh:p}=this.drawRect;typeof u=="number"&&typeof f=="number"&&typeof m=="number"&&typeof p=="number"?t.drawImage(n,u,f,m,p,a,l,c,h):t.drawImage(n,a,l,c,h),o&&t.strokeRect(a,l,c,h),this.path=new Path2D,this.path.rect(a,l,c,h)}getDraw(){if(this.isNeedRender){if(this.isRecalculate){const{position:t,mainCanvas:e}=this;this.internalUpdate({dynamicPosition:e.transformPosition(t)})}return[this.draw,this]}}}function Ut(r){return[r].flat(1/0)}class L extends qs{constructor(t){super(t);d(this,"overlayCreator");this.drawAxis=new Zs(this),"axisShow"in t&&this.toggleAxis(t.axisShow),this.overlayCreator=new Qs(this),this.initLayerGroups(),this.updateCenter()}initLayerGroups(){const t=new W({name:"其他图层",zIndex:1});t.addGroup(new Y({name:"其他覆盖物群组"}));const e=new W({name:"图片图层",zIndex:2});e.addGroup(new Y({name:"图片覆盖物群组"}));const i=new W({name:"多边形图层",zIndex:3});i.addGroup(new Y({name:"多边形覆盖物群组"}));const n=new W({name:"线段图层",zIndex:4});n.addGroup(new Y({name:"线段覆盖物群组"}));const o=new W({name:"点位图层",zIndex:5});o.addGroup(new Y({name:"点位覆盖物群组"}));const a=new W({name:"文字图层",zIndex:6});a.addGroup(new Y({name:"文字覆盖物群组"}));const l=new W({name:"自定义绘制图层",zIndex:7});l.addGroup(new Y({name:"自定义绘制覆盖物群组"}));const c=new kt({name:"默认图层群组"});c.addLayer([a,o,n,i,l,e,t]),this.setLayerGroup(c)}gteLayerGroups(t="默认图层群组"){return this.layerGroups.get(t)}setLayerGroup(t){t instanceof kt&&(this.layerGroups.set(t.name,t),t.setNotifyReload(()=>this.redrawOnce()),t.setMainCanvas(this),t.parent=this)}removeLayerGroup(t){t instanceof kt&&(this.layerGroups.delete(t.name),t.setNotifyReload(),t.setMainCanvas(),t.parent=void 0,this.redrawOnce())}addLayer(t){const e=this.layerGroups.get("默认图层群组");e&&e.addLayer(Ut(t))}removeLayer(t){const e=this.layerGroups.get("默认图层群组");e&&e.removeLayer(Ut(t))}addOverlay(t){const{overlays_text:e,overlays_point:i,overlays_line:n,overlays_polygon:o,overlays_custom:a,overlays_billboard:l,overlays_other:c}=this.getDefaultOverlayGroup()||{};Ut(t).forEach(h=>{h instanceof Wt?e==null||e.addOverlay(h):h instanceof ct?i==null||i.addOverlay(h):h instanceof jt||h instanceof qt||h instanceof Zt?n==null||n.addOverlay(h):h instanceof $t?o==null||o.addOverlay(h):h instanceof Yt?a==null||a.addOverlay(h):h instanceof de?l==null||l.addOverlay(h):c==null||c.addOverlay(h)})}removeOverlay(t){const{overlays_text:e,overlays_point:i,overlays_line:n,overlays_polygon:o,overlays_custom:a,overlays_billboard:l,overlays_other:c}=this.getDefaultOverlayGroup()||{};Ut(t).forEach(h=>{h instanceof Wt?e==null||e.removeOverlay(h):h instanceof ct?i==null||i.removeOverlay(h):h instanceof jt||h instanceof qt||h instanceof Zt?n==null||n.removeOverlay(h):h instanceof $t?o==null||o.removeOverlay(h):h instanceof Yt?a==null||a.addOverlay(h):h instanceof de?l==null||l.removeOverlay(h):c==null||c.removeOverlay(h)})}destroy(){super.destroy()}}d(L,"ViewFit",Js),d(L,"LayerGroup",kt),d(L,"Layer",W),d(L,"OverlayGroup",Y),d(L,"Text",Wt),d(L,"Point",ct),d(L,"Line",jt),d(L,"Polygon",$t),d(L,"Custom",Yt),d(L,"Arc",qt),d(L,"ArcTo",Zt),d(L,"Billboard",de);class tn{constructor(s){d(this,"id");d(this,"canvas");d(this,"ctx",null);d(this,"width",0);d(this,"height",0);d(this,"resizeObserver");this.id=s}init(s){return this.destroy(),this.canvas=document.getElementById(this.id),this.canvas?(this.ctx=this.canvas.getContext("2d"),this.ctx?(this.syncCanvasSize(),this.setupResizeListener(s),!0):(console.error("Failed to get canvas context"),!1)):(console.error(`Canvas with id ${this.id} not found`),!1)}getContext(){return this.ctx}getCanvas(){return this.canvas}getSize(){return{width:this.width,height:this.height}}syncCanvasSize(){const{canvas:s}=this;if(!s)return;const t=s.getBoundingClientRect(),e=Math.floor(t.width),i=Math.floor(t.height);s.width=e,s.height=i,this.width=e,this.height=i}setupResizeListener(s){this.canvas&&(this.resizeObserver=new ResizeObserver(()=>{this.syncCanvasSize(),s()}),this.resizeObserver.observe(this.canvas))}destroy(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=void 0)}}class en{constructor(s,t,e){d(this,"canvas");d(this,"onOffsetDelta");d(this,"onDragStart");d(this,"isDragging",!1);d(this,"lastX",0);d(this,"handleMouseDown",s=>{var t;(t=this.onDragStart)==null||t.call(this),this.isDragging=!0,this.lastX=s.clientX,window.addEventListener("mousemove",this.handleMouseMove),window.addEventListener("mouseup",this.handleMouseUp)});d(this,"handleMouseMove",s=>{if(!this.isDragging)return;const t=s.clientX-this.lastX;this.lastX=s.clientX,this.onOffsetDelta(t)});d(this,"handleMouseUp",()=>{this.isDragging=!1,window.removeEventListener("mousemove",this.handleMouseMove),window.removeEventListener("mouseup",this.handleMouseUp)});this.canvas=s,this.onOffsetDelta=t,this.onDragStart=e,this.canvas.addEventListener("mousedown",this.handleMouseDown)}destroy(){this.canvas.removeEventListener("mousedown",this.handleMouseDown),window.removeEventListener("mousemove",this.handleMouseMove),window.removeEventListener("mouseup",this.handleMouseUp)}}class sn{constructor(s,t,e,i){d(this,"canvas");d(this,"getTimeSpacing");d(this,"onTimeSpacing");d(this,"minTimeSpacingMs");d(this,"maxTimeSpacingMs");d(this,"handleWheel",s=>{s.preventDefault();const t=this.canvas.getBoundingClientRect(),e=s.clientX-t.left,i=Math.max(0,Math.min(t.width,e)),n=this.getTimeSpacing(),a=(s.deltaY>0?1:-1)>0?2:.5,l=n*a,c=Math.ceil(Math.min(this.maxTimeSpacingMs,Math.max(this.minTimeSpacingMs,l)));c!==n&&this.onTimeSpacing(c,i)});this.canvas=s,this.getTimeSpacing=t,this.onTimeSpacing=e,this.minTimeSpacingMs=(i==null?void 0:i.minTimeSpacingMs)??30*1e3,this.maxTimeSpacingMs=(i==null?void 0:i.maxTimeSpacingMs)??24*60*60*1e3,this.canvas.addEventListener("wheel",this.handleWheel,{passive:!1})}destroy(){this.canvas.removeEventListener("wheel",this.handleWheel)}}class nn{constructor(s,t,e){d(this,"canvas");d(this,"getTimeAtX");d(this,"onNotify");d(this,"handleMouseMove",s=>{const t=this.canvas.getBoundingClientRect(),e=s.clientX-t.left,i=Math.max(0,Math.min(t.width,e)),n=s.clientY-t.top,o=Math.max(0,Math.min(t.height,n)),a=this.getTimeAtX(i);this.onNotify({visible:!0,canvasX:i,canvasY:o,time:a})});d(this,"handleMouseLeave",()=>{this.onNotify({visible:!1,canvasX:0,canvasY:0,time:0})});this.canvas=s,this.getTimeAtX=t,this.onNotify=e,this.canvas.addEventListener("mousemove",this.handleMouseMove),this.canvas.addEventListener("mouseleave",this.handleMouseLeave)}destroy(){this.canvas.removeEventListener("mousemove",this.handleMouseMove),this.canvas.removeEventListener("mouseleave",this.handleMouseLeave)}}const rn={easeInOutQuad:r=>r<.5?2*r*r:1-Math.pow(-2*r+2,2)/2};class on{constructor(s,t){d(this,"canvasManager");d(this,"offsetDrag");d(this,"wheelZoom");d(this,"mouseTimeReporter");d(this,"onMouseTimeChange");d(this,"centerTimeAnimationRunId",0);d(this,"currentTime",17807184e5);d(this,"timeSpacing",5*60*1e3);d(this,"timeSpacingInPixels",100);d(this,"styleConfig",{backgroundColor:"white",axisColor:"black",textFont:"bold 12px Arial"});d(this,"tickConfig",{heightMinor:10,heightMajor:20,labelOffsetY:25,minorTicksPerMajor:10});d(this,"onDrawOverlay");this.canvasManager=new tn(s),this.onMouseTimeChange=t,requestAnimationFrame(()=>this.init())}init(){if(!this.canvasManager.init(()=>this.render()))return;const t=this.canvasManager.getCanvas();t&&(this.offsetDrag=new en(t,e=>{this.currentTime-=Math.round(e/this.timeSpacingInPixels*this.timeSpacing),this.render()},()=>{this.stopCenterTimeAnimation()}),this.wheelZoom=new sn(t,()=>this.timeSpacing,(e,i)=>{const n=this.getTimeAtCanvasX(i);this.timeSpacing=e,this.setTimeAtCanvasX(n,i),this.render()}),this.centerTime=Date.now(),this.mouseTimeReporter=new nn(t,e=>this.getTimeAtCanvasX(e),e=>{var i;return(i=this.onMouseTimeChange)==null?void 0:i.call(this,e)}),this.render())}render(){var i;const s=this.canvasManager.getContext();if(!s)return;this.renderBackground();const{width:t,height:e}=this.canvasManager.getSize();(i=this.onDrawOverlay)==null||i.call(this,s,t,e),this.renderAxis()}renderBackground(){const s=this.canvasManager.getContext(),{width:t,height:e}=this.canvasManager.getSize(),{backgroundColor:i}=this.styleConfig;s&&(s.clearRect(0,0,t,e),s.fillStyle=i,s.fillRect(0,0,t,e))}renderAxis(){const s=this.canvasManager.getContext();if(!s)return;const{timeSpacing:t,timeSpacingInPixels:e,styleConfig:{textFont:i,axisColor:n},tickConfig:{minorTicksPerMajor:o,heightMajor:a,heightMinor:l,labelOffsetY:c}}=this,{startTimeMs:h,startX:u,endX:f}=this.axisDrawingRange;s.fillStyle=n,s.font=i,s.textAlign="center",s.textBaseline="top";const m=e/o;let p=h,g=0,y=u;for(;y<=f;){const w=g%o===0,P=w?a:l;if(s.fillRect(y,0,1,P),w){const b=Ie(p,"MM-DD hh:mm:ss");s.fillText(b,y,c),p+=t}y+=m,g++}}get axisDrawingRange(){const{currentTime:s,timeSpacing:t,timeSpacingInPixels:e}=this,{width:i}=this.canvasManager.getSize(),n=s%t,o=Math.round(n/t*e),a=s-n,l=i/e,c=Math.ceil((s+l*t)/t)*t,h=-o+(c-a)/t*e;return{startTimeMs:a,startX:-o,endX:h}}get centerTime(){const{width:s}=this.canvasManager.getSize();return this.currentTime+s/2/this.timeSpacingInPixels*this.timeSpacing}set centerTime(s){const{width:t}=this.canvasManager.getSize(),{timeSpacing:e,timeSpacingInPixels:i}=this;this.currentTime=s-t/2/i*e}getTimeAtCanvasX(s){return this.currentTime+s/this.timeSpacingInPixels*this.timeSpacing}setTimeAtCanvasX(s,t){this.currentTime=s-t/this.timeSpacingInPixels*this.timeSpacing}getCanvasXAtTime(s){return(s-this.currentTime)/this.timeSpacing*this.timeSpacingInPixels}animateCenterTimeTo(s,t){const e=this.centerTime,i=e-s;if(!i)return;const n=++this.centerTimeAnimationRunId,o=(t==null?void 0:t.durationFrames)??(()=>{const h=Math.abs(i)/this.timeSpacing*.25,u=Math.min(5,Math.max(.5,h));return Math.max(1,Math.round(u*60))})(),a=(t==null?void 0:t.curve)??rn.easeInOutQuad;Le(0,1,o,l=>{const c=a(Math.min(1,Math.max(0,l)));n===this.centerTimeAnimationRunId&&(this.centerTime=e-i*c,this.render())},4)}stopCenterTimeAnimation(){this.centerTimeAnimationRunId++}destroy(){var s,t,e;(s=this.offsetDrag)==null||s.destroy(),(t=this.wheelZoom)==null||t.destroy(),(e=this.mouseTimeReporter)==null||e.destroy(),this.canvasManager.destroy()}}class an extends on{resolveFillStyle(s,t){if(!t)return;const e=this.canvasManager.getContext();if(!e)return;if(typeof t=="string")return t;const i=e.createLinearGradient(s.x+s.width*t.x1,s.y+s.height*t.y1,s.x+s.width*t.x2,s.y+s.height*t.y2);return t.colorStops.forEach(({color:n,offset:o})=>i.addColorStop(o,n)),i}drawTimeRangeRoundedRect(s){const t=this.canvasManager.getContext();if(!t)return;const e=this.canvasManager.getSize(),{startTimeMs:i,endTimeMs:n,y:o=1,height:a=e.height-1,radius:l=10,fillStyle:c="#2080f029",strokeStyle:h="#2080f0",lineWidth:u=1}=s,f=this.getCanvasXAtTime(i),p=this.getCanvasXAtTime(n)-f;if(!p)return;const g=this.resolveFillStyle({x:f,y:o,width:p,height:a},c);g&&(t.fillStyle=g),h&&(t.strokeStyle=h),t.lineWidth=u,t.beginPath(),typeof t.roundRect=="function"?t.roundRect(f,o,p,a+o,l):t.rect(f,o,p,a+o),c&&t.fill(),h&&t.stroke()}}function It(r){if(typeof r=="string"){const s=document.querySelector(r);if(s)return s;console.error(`Element "${r}" not found`)}else return r||document.documentElement}function _e(r){const s=It(r);return s?s.requestFullscreen?s.requestFullscreen():s.mozRequestFullScreen?s.mozRequestFullScreen():s.webkitRequestFullscreen?s.webkitRequestFullscreen():s.msRequestFullscreen?s.msRequestFullscreen():Promise.reject("No Fullscreen API"):Promise.reject("No Element")}function Se(){const r=document;return document.exitFullscreen?document.exitFullscreen():r.mozCancelFullScreen?r.mozCancelFullScreen():r.webkitExitFullscreen?r.webkitExitFullscreen():r.msExitFullscreen?r.msExitFullscreen():Promise.reject("No ExitFullscreen API")}function Tt(r){const s=It(r),t=document,e=document.fullscreenElement||t.webkitFullscreenElement||t.mozFullScreenElement||t.msFullscreenElement;return s==e||!r&&window.innerWidth==screen.width&&window.innerHeight==screen.height}function ln(r){if(r=It(r),!!r)return function(){Tt(r)?Se():_e(r)}}function cn(r,s){const t=It(s);if(!t)return;const e=()=>{r(Tt(t))};return document.addEventListener("fullscreenchange",e),document.addEventListener("webkitfullscreenchange",e),document.addEventListener("mozfullscreenchange",e),document.addEventListener("MSFullscreenChange",e),e(),()=>{document.removeEventListener("fullscreenchange",e),document.removeEventListener("webkitfullscreenchange",e),document.removeEventListener("mozfullscreenchange",e),document.removeEventListener("MSFullscreenChange",e)}}class hn{constructor(s,t){d(this,"targetElement");d(this,"onFullscreenChange");d(this,"detachFullscreenListeners");this.init(s),this.onFullscreenChange=t,this.attachFullscreenChangeListeners()}init(s){this.targetElement=It(s)}enter(){this.targetElement&&_e(this.targetElement)}exit(){this.targetElement&&Se()}toggle(){this.targetElement&&(Tt(this.targetElement)?this.exit():this.enter())}attachFullscreenChangeListeners(){const s=()=>{!this.targetElement||!this.onFullscreenChange||this.onFullscreenChange(Tt(this.targetElement))};document.addEventListener("fullscreenchange",s),document.addEventListener("webkitfullscreenchange",s),document.addEventListener("mozfullscreenchange",s),document.addEventListener("MSFullscreenChange",s),s(),this.detachFullscreenListeners=()=>{document.removeEventListener("fullscreenchange",s),document.removeEventListener("webkitfullscreenchange",s),document.removeEventListener("mozfullscreenchange",s),document.removeEventListener("MSFullscreenChange",s)}}destroy(){var s;(s=this.detachFullscreenListeners)==null||s.call(this),this.detachFullscreenListeners=void 0,this.targetElement=void 0,this.onFullscreenChange=void 0}}function un(r){const s=be(r,100);let t=0,e=0;return function(i){const n=i.target;if(!n||!(n instanceof Element))return;const{scrollTop:o,scrollHeight:a,clientHeight:l,scrollLeft:c,scrollWidth:h,clientWidth:u}=n;function f(){if(t==o)return;const p=t>o;if(t=o,p)return;a-o-l<=1&&s("vertical")}function m(){if(e==c)return;const p=e>c;if(e=c,p)return;h-c-u<=1&&s("horizontal")}f(),m()}}function dn(r,s,t){const{isClickAllowed:e,uiLibrary:i=["naiveUI","ElementPlus","Element"]}=t||{},n=function(l){const c=[];for(const h in l)Object.hasOwnProperty.call(l,h)&&i.includes(h)&&c.push(...l[h]);return c}({naiveUI:[".v-binder-follower-container",".n-image-preview-container",".n-modal-container"],ElementPlus:[".el-popper"],Element:[".el-popper"]});function o(){s(),document.removeEventListener("mousedown",a)}function a(l){if(e){const u=e(l);if(u)return;if(u===!1)return o()}const c=l.target;if(!(c instanceof Element)||!c.isConnected)return;r.concat(n).some(u=>!!(c!=null&&c.closest(u)))||o()}requestAnimationFrame(()=>document.addEventListener("mousedown",a))}var j,ft,mt,Pt,bt,J,K,st,Ct;class fn{constructor(){T(this,j);T(this,ft,!1);T(this,mt,{});T(this,Pt,0);T(this,bt,0);T(this,J,0);T(this,K,0);T(this,st);T(this,Ct)}init(s,t){this.finish(),M(this,j,s),M(this,st,t==null?void 0:t.limit),M(this,Ct,t==null?void 0:t.dragDom),M(this,mt,{mousedown:this.mousedown.bind(this),mousemove:this.mousemove.bind(this),mouseup:this.mouseup.bind(this)}),this.bindOrUnbindEvent("bind")}finish(){this.bindOrUnbindEvent("unbind")}bindOrUnbindEvent(s){const t=s==="bind"?"addEventListener":"removeEventListener";if(!x(this,j))return console.error("No DOM");x(this,j)[t]("mousedown",x(this,mt).mousedown),document[t]("mousemove",x(this,mt).mousemove),document[t]("mouseup",x(this,mt).mouseup)}alterLocation(){if(!x(this,j))return console.error("No DOM");x(this,st)&&(M(this,J,Math.min(x(this,J),x(this,st).max.top)),M(this,J,Math.max(x(this,J),x(this,st).min.top)),M(this,K,Math.min(x(this,K),x(this,st).max.left)),M(this,K,Math.max(x(this,K),x(this,st).min.left))),x(this,j).style.setProperty("--top",x(this,J)+"px"),x(this,j).style.setProperty("--left",x(this,K)+"px")}mousedown(s){if(!x(this,j))return console.error("No DOM");if(x(this,Ct)&&s.target!=x(this,Ct))return;document.body.classList.add("no-select"),M(this,ft,!0);const t=x(this,j).getBoundingClientRect(),{pageX:e,pageY:i}=s;M(this,Pt,e),M(this,bt,i),M(this,J,t.y),M(this,K,t.x)}mousemove(s){const{pageX:t,pageY:e}=s;x(this,ft)&&(M(this,J,x(this,J)+(e-x(this,bt))),M(this,K,x(this,K)+(t-x(this,Pt))),M(this,Pt,t),M(this,bt,e),this.alterLocation())}mouseup(){x(this,ft)&&(M(this,ft,!1),document.body.classList.remove("no-select"))}}j=new WeakMap,ft=new WeakMap,mt=new WeakMap,Pt=new WeakMap,bt=new WeakMap,J=new WeakMap,K=new WeakMap,st=new WeakMap,Ct=new WeakMap;var $,gt,pt,_t,St,q,Z,U,Et,Mt;class mn{constructor(){T(this,$);T(this,gt,!1);T(this,pt,{});T(this,_t,0);T(this,St,0);T(this,q,0);T(this,Z,0);T(this,U);T(this,Et);T(this,Mt)}init(s,t={}){this.finish(),M(this,$,s),M(this,U,t.limit),M(this,Et,t.update_move),M(this,Mt,t.update_up),M(this,pt,{mousedown:this.mousedown.bind(this),mousemove:this.mousemove.bind(this),mouseup:this.mouseup.bind(this)}),this.bindOrUnbindEvent("bind")}finish(){this.bindOrUnbindEvent("unbind")}bindOrUnbindEvent(s){const t=s==="bind"?"addEventListener":"removeEventListener";if(!x(this,$))return console.error("No DOM");x(this,$)[t]("mousedown",x(this,pt).mousedown),document[t]("mousemove",x(this,pt).mousemove),document[t]("mouseup",x(this,pt).mouseup)}updateValue(){const s={top:x(this,q),left:x(this,Z),percentage:{top:0,left:0}};if(x(this,U)){const t=e=>x(this,U)?(s[e]-x(this,U).min[e])/(x(this,U).max[e]-x(this,U).min[e]):0;s.percentage={top:t("top")||0,left:t("left")||0}}return s}alterLocation(){if(!x(this,$))return console.error("No DOM");x(this,U)&&(M(this,q,Math.min(x(this,q),x(this,U).max.top)),M(this,q,Math.max(x(this,q),x(this,U).min.top)),M(this,Z,Math.min(x(this,Z),x(this,U).max.left)),M(this,Z,Math.max(x(this,Z),x(this,U).min.left))),x(this,Et)&&x(this,Et).call(this,this.updateValue()),x(this,$).style.setProperty("--top",x(this,q)+"px"),x(this,$).style.setProperty("--left",x(this,Z)+"px")}mousedown(s){if(!x(this,$))return console.error("No DOM");document.body.classList.add("no-select"),M(this,gt,!0);const t=x(this,$).getBoundingClientRect();M(this,St,t.y),M(this,_t,t.x);const{pageX:e,pageY:i}=s;M(this,q,i-x(this,St)),M(this,Z,e-x(this,_t)),this.alterLocation()}mousemove(s){const{pageX:t,pageY:e}=s;x(this,gt)&&(M(this,q,e-x(this,St)),M(this,Z,t-x(this,_t)),this.alterLocation())}mouseup(){x(this,gt)&&(M(this,gt,!1),document.body.classList.remove("no-select"),x(this,Mt)&&x(this,Mt).call(this,this.updateValue()))}}$=new WeakMap,gt=new WeakMap,pt=new WeakMap,_t=new WeakMap,St=new WeakMap,q=new WeakMap,Z=new WeakMap,U=new WeakMap,Et=new WeakMap,Mt=new WeakMap;function gn(r,s){if(typeof r=="number")return r;if(/px/.test(r))return Number(r.replace(/px/,""))||0;const t=document.createElement("div");t.style.width=r,s=s||document.body,s.appendChild(t);const e=t.getBoundingClientRect().width;return s.removeChild(t),e}function pn(r,s){if(!r)return;let t,e;if(typeof s=="string"){const n=document.querySelector(s);if(!n)return;const o=n.getBoundingClientRect();t=o.width,e=o.height}else if(Array.isArray(s))t=s[0],e=s[1];else{const n=s.getBoundingClientRect();t=n.width,e=n.height}const i=t/e;return i>r?[r*e,e]:i<r?[t,t/r]:[t,e]}function vn(r,s=5e3){return new Promise((t,e)=>{const i=new Image;i.src=r;const n=setTimeout(()=>{e(new Error("图片加载超时")),i.onload=null,i.onerror=null},s);i.onload=()=>{clearTimeout(n);const o=i.naturalWidth,a=i.naturalHeight,l=o/a;t([i,l])},i.onerror=()=>{clearTimeout(n),e(new Error("图片加载失败"))},i.crossOrigin="Anonymous"})}function yn(r){const t=document.getElementById(r).querySelectorAll("img"),e=t.length,i=[];let n=0;return e===0?Promise.resolve({allLoaded:!0,loaded:0,failed:0,total:0,errors:[]}):new Promise(o=>{const a=()=>{n===e&&o({allLoaded:i.length===0,loaded:e-i.length,failed:i.length,total:e,errors:i})};t.forEach(l=>{if(l.complete){l.naturalWidth===0&&i.push(l),n++,a();return}l.addEventListener("load",()=>{n++,a()},{once:!0}),l.addEventListener("error",()=>{i.push(l),n++,a()},{once:!0})})})}function wn(r){return new Promise((s,t)=>{fetch(r).then(e=>s(e.text())).catch(e=>{console.error("Error fetching :",e),t(e)})})}function xn(r){const s=document.createElement("input");return s.type="file",s.accept=(r==null?void 0:r.accept)||"",s.multiple=(r==null?void 0:r.multiple)||!1,new Promise((t,e)=>{s.addEventListener("change",i=>{const n=i.target.files;n?t(Array.from(n)):e()}),s.click()})}function si(r){const{href:s,fileName:t,onProgress:e,timeout:i=3e4,autoDownload:n=!0}=r;let o,a=!1,l=null,c;const h=t||Jt(s,"downloaded_file");c=decodeURIComponent(h);const u=()=>{if(!l)return;const g=URL.createObjectURL(l),y=document.createElement("a");y.href=g,y.download=c,y.click(),URL.revokeObjectURL(g)};return{promise:new Promise((g,y)=>{try{o=new XMLHttpRequest,o.open("GET",s),o.responseType="blob",o.timeout=i,o.ontimeout=()=>{a||y(new Error(`请求超时(已超过${i/1e3}秒)`))},o.addEventListener("progress",w=>{if(w.lengthComputable&&!a){const P=w.loaded/w.total*100;e==null||e(Number(P.toFixed(2)))}}),o.addEventListener("load",()=>{a||(o.status>=200&&o.status<300?(l=o.response,n&&u(),g(o.response)):y(new Error(`下载失败,状态码: ${o.status}`)))}),o.addEventListener("error",()=>{a||y(new Error("网络错误,下载失败"))}),o.addEventListener("abort",()=>{a||(a=!0,y(new Error("下载已被中止")))}),o.send()}catch(w){a||y(w)}}),abort:()=>!a&&o.abort(),download:()=>{!a&&l&&u()}}}function Pn(r,s,t){if(!t){let n=s.replace(/^[^.]+./,"");n=n==s?"text/plain":"application/"+n,t={type:n}}const e=new Blob(r,t),i=URL.createObjectURL(e);si({href:i,fileName:s})}const bn=Math.PI/2,ne=Math.PI/180,re=6378137,Cn=85.05112878;function _n(r,s){const t=Math.max(Math.min(r,180),-180),e=Math.max(Math.min(s,Cn),-85.05112878),i=t*ne*re,n=e*ne,o=Math.log(Math.tan(Math.PI/4+n/2))*re;return[i,o]}function Sn(r,s){const t=r/re/ne,e=(2*Math.atan(Math.exp(s/re))-bn)/ne;return[t,e]}function ni(r,s,t){const[e,i]=r,[n,o]=s,[a,l]=t,c=(a-n)**2+(l-o)**2;if(c===0)return Math.sqrt((e-n)**2+(i-o)**2);let h=((e-n)*(a-n)+(i-o)*(l-o))/c;return h=Math.max(0,Math.min(1,h)),Math.sqrt((e-(n+h*(a-n)))**2+(i-(o+h*(l-o)))**2)}function En(r,s,t,e,i,n=1,o=1){const a=r+t*Math.cos(e)*n,l=s+t*Math.sin(e)*o,c=r+t*Math.cos(i)*n,h=s+t*Math.sin(i)*o;return[[a,l],[c,h]]}function xe(r,s,t,e){return Math.hypot(Math.abs(t-r),Math.abs(e-s))}function Ee(r,s,t,e){const i=(r+t)/2,n=(s+e)/2;return{x:i,y:n}}function Mn(r,s,t,e){const[i,n]=r,[o,a]=s;let l=1/0;if(o!==0){const c=o>0?(t-i)/o:-i/o;c>0&&(l=Math.min(l,c))}if(a!==0){const c=a>0?(e-n)/a:-n/a;c>0&&(l=Math.min(l,c))}return l===1/0?r:[i+o*l,n+a*l]}const Dn=new Set(["sin","cos","tan","asin","acos","atan","atan2"]),Rn=new Proxy(Math,{get(r,s){return Dn.has(s)?function(...t){const e=t.map(i=>i/180*Math.PI);return r[s](...e)}:r[s]},set(){throw new Error("DegreeMath 是只读的,不能修改属性")},deleteProperty(){throw new Error("DegreeMath 是只读的,不能删除属性")}});class xt{constructor(s,t){d(this,"resolve");d(this,"reject");this.resolve=s,this.reject=t}run(s){var t,e;return s instanceof Promise?s.then(i=>{var n;return(n=this.resolve)==null||n.call(this),i}).catch(i=>{var n;return(n=this.reject)==null||n.call(this),Promise.reject(i)}):s?(t=this.resolve)==null||t.call(this):(e=this.reject)==null||e.call(this),s}}class kn extends xt{constructor(s){super(),this.resolve=s}warning(...s){const t=()=>{var e,i;return(i=(e=vt.tips).warning)==null?void 0:i.call(e,...s)};return new xt(this.resolve,t)}error(...s){const t=()=>{var e,i;return(i=(e=vt.tips).error)==null?void 0:i.call(e,...s)};return new xt(this.resolve,t)}}class Vn extends xt{constructor(s){super(),this.reject=s}info(...s){const t=()=>{var e,i;return(i=(e=vt.tips).info)==null?void 0:i.call(e,...s)};return new xt(t,this.reject)}success(...s){const t=()=>{var e,i;return(i=(e=vt.tips).success)==null?void 0:i.call(e,...s)};return new xt(t,this.reject)}}const B=class B{constructor(){if(new.target===B)throw new Error("请直接使用静态方法,而不是实例化此类")}static register(s,t){if(typeof t!="function")return console.error("TipHandler must be a function");B.tips[s]=t}static resolveTip(s){return function(...t){const e=()=>{var i,n;return(n=(i=B.tips)[s])==null?void 0:n.call(i,...t)};return new kn(e)}}static rejectTip(s){return function(...t){const e=()=>{var i,n;return(n=(i=B.tips)[s])==null?void 0:n.call(i,...t)};return new Vn(e)}}};d(B,"tips",{info:void 0,success:void 0,warning:void 0,error:void 0}),d(B,"info",B.resolveTip("info")),d(B,"success",B.resolveTip("success")),d(B,"warning",B.rejectTip("warning")),d(B,"error",B.rejectTip("error"));let vt=B;exports.EXTENSION_TO_MIME=Te;exports.FILE_EXTENSIONS=zt;exports.PAPER_SIZE_DEFINITIONS=Pe;exports.PAPER_SIZE_OPTIONS=li;exports.UNIT_LABELS=fe;exports.WINDOW_TARGET=ai;exports._Animate_CreateOscillator=ci;exports._Animate_CubicBezier=hi;exports._Animate_NumericTransition=Le;exports._Animate_Schedule=Vt;exports._Blob_ConvertDataToImageUrl=ui;exports._Browser_CalculatePrintableArea=Ni;exports._Browser_CopyToClipboard=Ii;exports._Browser_GetFrameRate=Li;exports._Browser_IdleDetection=Hi;exports._Browser_SameOriginTabManager=Rt;exports._Browser_SoundEffects=Oi;exports._Browser_WebSocketClient=Ti;exports._Canvas_Axis=L;exports._Canvas_TimeAxis=an;exports._Element_CalculateCanvasSize=pn;exports._Element_CheckImagesLoaded=yn;exports._Element_CloseOnOutsideClick=dn;exports._Element_Drag=fn;exports._Element_EnterFullscreen=_e;exports._Element_ExitFullscreen=Se;exports._Element_Fullscreen=ln;exports._Element_FullscreenController=hn;exports._Element_FullscreenObserver=cn;exports._Element_GetOtherSizeInPixels=gn;exports._Element_IsFullscreen=Tt;exports._Element_LoadImage=vn;exports._Element_LocalDrag=mn;exports._Element_ScrollEndListener=un;exports._File_CreateAndDownload=Pn;exports._File_Download=si;exports._File_Read=wn;exports._File_Select=xn;exports._Format_CamelCase=pi;exports._Format_CapitalizeFirstLetter=di;exports._Format_ChunkArray=xi;exports._Format_ExcludeSubstring=vi;exports._Format_FileSize=gi;exports._Format_HrefName=Jt;exports._Format_MillisecondToReadable=wi;exports._Format_NumberWithCommas=Qt;exports._Format_NumberWithUnit=mi;exports._Format_Percentage=fi;exports._Format_Timestamp=Ie;exports._Format_ToggleInvisibleChars=yi;exports._Math_CalculateDistance2D=xe;exports._Math_Degree=Rn;exports._Math_GetArcPoints=En;exports._Math_GetBoundaryIntersection=Mn;exports._Math_GetMidpoint=Ee;exports._Math_LngLatToPlane=_n;exports._Math_PlaneToLngLat=Sn;exports._Math_PointToLineDistance=ni;exports._Tip=vt;exports._Utility_Clone=ze;exports._Utility_ColorConverter=Xe;exports._Utility_Debounce=be;exports._Utility_ExecuteWhenIdle=Mi;exports._Utility_GenerateUUID=te;exports._Utility_GetTargetByPath=Ri;exports._Utility_MergeObjects=rt;exports._Utility_RotateList=Vi;exports._Utility_SetTargetByPath=ki;exports._Utility_Sleep=Ai;exports._Utility_Throttle=Di;exports._Utility_TimeConsumption=Ge;exports._Utility_WaitForCondition=Ue;exports._Valid_CheckConnectionWithXHR=Si;exports._Valid_DataType=Kt;exports._Valid_DoesInfiniteLineIntersectRectangle=Ci;exports._Valid_FileTypeChecker=me;exports._Valid_Is2DNumberArray=At;exports._Valid_IsInMargin=Pi;exports._Valid_IsNumberArray=oe;exports._Valid_IsPointInPolygon=bi;exports._Valid_IsSecureContext=_i;
|