nhanh-pure-function 3.0.6-beta.11 → 3.0.6-beta.13
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/Browser/index.d.ts +31 -40
- package/dist/Valid/index.d.ts +2 -2
- package/dist/index.cjs.js +3 -3
- package/dist/index.es.js +2677 -2642
- 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 Ke=Object.defineProperty;var xe=r=>{throw TypeError(r)};var Qe=(r,s,t)=>s in r?Ke(r,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[s]=t;var f=(r,s,t)=>Qe(r,typeof s!="symbol"?s+"":s,t),be=(r,s,t)=>s.has(r)||xe("Cannot "+t);var P=(r,s,t)=>(be(r,s,"read from private field"),t?t.call(r):s.get(r)),A=(r,s,t)=>s.has(r)?xe("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(r):s.set(r,t),D=(r,s,t,e)=>(be(r,s,"write to private field"),e?e.call(r,t):s.set(r,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const De={".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"},Lt={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"]},oe=["","万","亿","兆","京","垓","秭","穰","沟","涧","正","载","极"],ti=["_self","_blank","_parent","_top"],ge={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}},ei=Object.keys(ge).map(r=>({value:r,label:r}));function Rt(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 ii(r,s,t,e,i=2){let n=r,o=!1,a=1,l=r,c=s,h=t;const u=()=>{const _=(c-l)/h;return Number(_.toFixed(i))};let d=u();const m=_=>Math.min(Math.max(_,l),c),g=_=>Number(_.toFixed(i)),p=(_,C,E)=>{const N=[];return _>=C&&N.push("最小值必须小于最大值"),E<=0?N.push("分段数必须为正数"):u()==0&&N.push("数值精度过低,致使动画步长为 0"),N},v=(_,C,E)=>{const N=p(_,C,E);return N.length>0?(console.error(`参数更新失败: ${N.join("; ")}`),!1):(l=_,c=C,h=E,d=u(),n=m(n),!0)},w=()=>{o&&(a=n>=c?-1:n<=l?1:a,n=m(n+d*a),e(g(n)),requestAnimationFrame(w))};return{play(_=n){if(n=m(_),p(l,c,h).length)return console.error("配置参数错误",this.getParams());o||(o=!0,w())},pause(){o=!1},getCurrent:()=>g(n),isPlaying:()=>o,updateParams:v,getParams:()=>({min:l,max:c,steps:h,precision:i,stepSize:d})}}function si(r,s,t,e,i=2){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 ni(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 ri(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 oi(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()}class Ve{constructor(){}static add(s,t){this.keys.set(s,t)}static open(s,t,e,i){const n=this.keys.get(s);if(n&&!n.closed)return n.focus(),n;{const o=window.open(t,e,i);if(o)return this.keys.set(s,o),o;console.error("window.open failed: 可能是浏览器阻止了弹出窗口"),this.keys.delete(s)}}static isOpen(s){const t=this.keys.get(s);return t!=null&&t.closed&&this.keys.delete(s),this.keys.has(s)}static getWindow(s){if(this.isOpen(s))return this.keys.get(s)}static close(s){const t=this.keys.get(s);t&&(t.close(),this.keys.delete(s))}static closeAll(){this.keys.forEach((s,t)=>s.close()),this.keys.clear()}}f(Ve,"keys",new Map);function ai(r,s){const t=ge[r];if(!t)return console.error(`未知纸张类型: ${r}`);const{width:e,height:i}=t,n=g=>g/25.4,a=typeof window<"u"?window.devicePixelRatio*96:300,l=g=>Math.round(n(g)*a),c=l(e),h=l(i),u=l(s),d=Math.max(0,c-2*u),m=Math.max(0,h-2*u);return{contentWidth:d,contentHeight:m,paddingPx:u,paperWidthPx:c,paperHeightPx:h}}/*!
|
|
2
|
+
"use strict";var Ke=Object.defineProperty;var _e=r=>{throw TypeError(r)};var ti=(r,n,t)=>n in r?Ke(r,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[n]=t;var f=(r,n,t)=>ti(r,typeof n!="symbol"?n+"":n,t),Ce=(r,n,t)=>n.has(r)||_e("Cannot "+t);var P=(r,n,t)=>(Ce(r,n,"read from private field"),t?t.call(r):n.get(r)),A=(r,n,t)=>n.has(r)?_e("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(r):n.set(r,t),D=(r,n,t,e)=>(Ce(r,n,"write to private field"),e?e.call(r,t):n.set(r,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Re={".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"},Ft={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"]},le=["","万","亿","兆","京","垓","秭","穰","沟","涧","正","载","极"],ei=["_self","_blank","_parent","_top"],ve={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}},ii=Object.keys(ve).map(r=>({value:r,label:r}));function kt(r,n=500){let t,e=!0;function i(s){if(!e)return;t||(t=s);let o=Math.min((s-t)/n,1);r(o),s-t<n&&requestAnimationFrame(i)}return requestAnimationFrame(i),()=>e=!1}function si(r,n,t,e,i=2){let s=r,o=!1,a=1,l=r,c=n,h=t;const u=()=>{const _=(c-l)/h;return Number(_.toFixed(i))};let d=u();const m=_=>Math.min(Math.max(_,l),c),g=_=>Number(_.toFixed(i)),p=(_,C,E)=>{const N=[];return _>=C&&N.push("最小值必须小于最大值"),E<=0?N.push("分段数必须为正数"):u()==0&&N.push("数值精度过低,致使动画步长为 0"),N},v=(_,C,E)=>{const N=p(_,C,E);return N.length>0?(console.error(`参数更新失败: ${N.join("; ")}`),!1):(l=_,c=C,h=E,d=u(),s=m(s),!0)},w=()=>{o&&(a=s>=c?-1:s<=l?1:a,s=m(s+d*a),e(g(s)),requestAnimationFrame(w))};return{play(_=s){if(s=m(_),p(l,c,h).length)return console.error("配置参数错误",this.getParams());o||(o=!0,w())},pause(){o=!1},getCurrent:()=>g(s),isPlaying:()=>o,updateParams:v,getParams:()=>({min:l,max:c,steps:h,precision:i,stepSize:d})}}function ni(r,n,t,e,i=2){if(t<=0)return console.error("动画步数 必须为正数");const s=u=>Number(u.toFixed(i)),o=n-r,a=s(Math.abs(o)/t);if(a===0)return console.error("数值精度过低,致使动画步长为 0");const l=Math.sign(o);let c=r;const h=()=>{c=s(c+a*l),(l>0?c<n:c>n)?(e(c),requestAnimationFrame(h)):e(n)};h()}function ri(r,n="image/png"){try{let t,e=n;if(r instanceof File)return URL.createObjectURL(r);if(typeof r=="string"){let s=r;const o=s.match(/^data:([^;]*)(;base64)?,(.*)$/i);if(o){if(!o[2])return console.error("无效的数据 URL:缺少 base64 编码声明");if(e=o[1]||e,s=o[3],!s)return console.error("数据 URL 包含空有效负载")}s=s.replace(/[^A-Za-z0-9+/=]/g,"");const a=atob(s);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 oi(r){return r.charAt(0).toUpperCase()+r.slice(1)}function ai(r,n,t=2){return!Number.isFinite(r)||!Number.isFinite(n)||!Number.isFinite(t)?(console.error("所有参数必须是有限的数字"),""):n===0?(console.error("分母不能为零"),""):t<0?(console.error("小数位数不能为负数"),""):(r/n*100).toFixed(t)+"%"}function Wt(r){const t=r.toString().split("."),e=t[0].replace(/\B(?=(\d{3})+(?!\d))/g,",");return t.length>1?e+"."+t[1]:e}function li(r,n){const t={join:!0,suffix:"",decimalPlaces:2},{join:e,suffix:i,decimalPlaces:s}={...t,...n||{}},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,d=(l?1:-1)*parseFloat(u.toFixed(Math.max(0,s)));return e?`${d}${le[c]}${i}`:[d,le[c]+i]}function ci(r){const n=["B","KB","MB","GB","TB","PB"];let t=0;for(;r>1024;)r/=1024,t++;return`${Math.round(r*100)/100} ${n[t]}`}function hi(r,n="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:s=>s.getFullYear(),MM:s=>s.getMonth()+1,DD:s=>s.getDate(),hh:s=>s.getHours(),mm:s=>s.getMinutes(),ss:s=>s.getSeconds(),ms:s=>s.getMilliseconds()};return n.replace(/YYYY|MM|DD|hh|mm|ss|ms/g,s=>{const o=i[s](e);return t?String(o).padStart(2,"0"):String(o)})}function qt(r,n="file"){if(!r||(r=String(r).trim(),r===""))return n;const t=r.split("/");return t[t.length-1].split("?")[0]}function ui(r,n){return r=r.replace(/([^a-zA-Z][a-z])/g,t=>t.toUpperCase()),n?r.replace(/[^a-zA-Z]+/g,""):r}function di(r,n,t=","){const e=new RegExp(`(^|${t})${n}(${t}|$)`,"g");return r.replace(e,function(i,s,o){return s===o?t:""})}function fi(r,n=!0){const t={"\b":"\\b"," ":"\\t","\n":"\\n","\v":"\\v","\f":"\\f","\r":"\\r"," ":"\\s"},e=Object.fromEntries(Object.entries(t).map(([i,s])=>[s,i]));return n?r.replace(/[\b\t\n\v\f\r ]/g,i=>t[i]):r.replace(/\\[btnvfrs]/g,i=>e[i]||i)}const Lt=[["年",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 mi(r,n){if(!Number.isInteger(r)||r<0)return"0毫秒";const t=n?Lt.findIndex(([i])=>i===n):0,e=t===-1?0:t;for(let i=e;i<Lt.length;i++){const[s,o]=Lt[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 s===Lt[e][0]&&(l=Wt(Number(l))),`${l}${s}`}}return"0毫秒"}function pi(r,n){if(n<1)return console.error("分割大小必须大于0"),[];const t=[];for(let e=0;e<r.length;e+=n){const i=r.slice(e,e+n);t.push(i)}return t}function ee(r,n=2){if(Array.isArray(r)&&r.length>=n){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 Mt(r,n=1,t=2){if(Array.isArray(r)&&r.length>=n){for(let i=0;i<r.length;i++)if(!ee(r[i],t))return!1}else return!1;return!0}function gi(r,n,t){return Math.abs(r-n)<=t}function yi(r,n){let t=!1;const{x:e,y:i}=r,s=n.length;for(let o=0,a=s-1;o<s;a=o++){const l=n[o].x,c=n[o].y,h=n[a].x,u=n[a].y;c>i!=u>i&&e<(h-l)*(i-c)/(u-c)+l&&(t=!t)}return t}function vi(r,n,t,e){const i=Math.min(r[0],n[0]),s=Math.max(r[0],n[0]),o=Math.min(r[1],n[1]),a=Math.max(r[1],n[1]),l=[[i,o],[s,o],[s,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[p,v]=t;return p>=i&&p<=s&&v>=o&&v<=a}const d=1e-10;let m=!1,g=!1;for(const[p,v]of l){const w=c*p+h*v+u;if(Math.abs(w)<d||(w>d?m=!0:g=!0,m&&g))return!0}return m&&g}function jt(r){return Object.prototype.toString.call(r).slice(8,-1).toLowerCase()}function wi(r){return["https:","wss:","ftps:","sftp:","smpts:","smtp+tls:","imap+tls:","pop3+tls:","rdp:","vpn:"].some(t=>r.startsWith(t))}function Pi(r){return new Promise((n,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(s){t(new Error(`Invalid URL format: ${s.message}`));return}const e=new XMLHttpRequest;e.open("HEAD",r,!0);const i=s=>{t(new Error(`Request failed: ${s.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?n(!0):t(new Error(`HTTP Error: ${e.status}`)))},e.onerror=i,e.onabort=i,e.ontimeout=i;try{e.send()}catch(s){t(new Error(`Request send failed: ${s.message}`))}})}const tt=class tt{constructor(){if(new.target===tt)throw new Error("请直接使用静态方法,而不是实例化此类")}static check(n,t){if(!n||typeof n!="string")return console.error("Invalid URL provided"),t?!1:"unknown";const e=qt(n).toLowerCase();if(t){if(!Ft.hasOwnProperty(t))return console.error(`Unknown file type: ${t}`),"unknown";const i=Ft[t];return tt._checkExtension(e,i)}return tt._detectFileType(e)}static parseAddresses(n){return!n||typeof n!="string"?(console.error("Invalid URL provided"),[]):n.split(",").map(t=>{const e=qt(t),i=this.check(t);return{url:t,name:e,type:i}})}static matchesMimeType(n,t){if(!t)return!0;if(typeof n!="string"||typeof t!="string")return!1;const e=tt._normalizeType(n),i=t.split(",").map(a=>tt._normalizeType(a.trim())),[s,o="*"]=e.split("/");return i.some(a=>{const[l,c="*"]=a.split("/");return(l==="*"||s==="*"||l===s)&&(c==="*"||o==="*"||c===o)})}static _normalizeType(n){return n.startsWith(".")&&!n.includes("/")?Re[n.toLowerCase()]||n:n.includes("/")?n:`${n}/*`}static _checkExtension(n,t){return t.some(e=>n.endsWith(e))}static _detectFileType(n){for(const[t,e]of tt.cachedEntries)if(e.some(i=>n.endsWith(i)))return t;return"unknown"}};f(tt,"cachedEntries",Object.entries(Ft));let ce=tt;const xi=/\w*(?:\[\d+\])+|\w+/g,ke=/^\w*(?:\[\d+\])+$/,Me=/\w+|(\[\d+\])/g,Oe=/\[(\d+)\]/;function Ne(r){return r?r.match(xi)||[]:[]}function bi(r,n=3e3){if(typeof r!="function")return console.error("非函数:",r);const t=window.requestIdleCallback,e=function(i){i.timeRemaining()<=0&&!i.didTimeout?t(e,{timeout:n}):r()};t?t(e,{timeout:n}):requestAnimationFrame(()=>r())}function Ae(r,n){const t=Date.now();return new Promise((e,i)=>{const s=()=>{const o=Date.now()-t;if(o>=n)return i(o);if(r())return e(o);requestAnimationFrame(s)};s()})}function ct(r,n,t=[],e=Date.now()){if(e<Date.now()-50){console.error("_MergeObjects 合并异常:疑似死循环");return}const i=jt(r),s=jt(n);if(i!=s)return n;if(i=="object"||i=="array"){if(t.some(([o,a])=>o==r&&a==n))return r;if(t.push([r,n]),i=="object"){for(const o in n)if(Object.prototype.hasOwnProperty.call(n,o)){const a=n[o],l=r[o],c=ct(l,a,t,e);r[o]=c}return r}else if(i=="array")return n.forEach((o,a)=>{const l=o,c=r[a],h=ct(c,l,t,e);r[a]=h}),r}else return n}function $t(r=""){return r+"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){const t=Math.random()*16|0;return(n==="x"?t:t&3|8).toString(16)})}function we(r,n){let t;return function(...e){clearTimeout(t),t=setTimeout(()=>{r(...e),t=void 0},n)}}function _i(r,n){let t=-1/0;return function(...e){const i=performance.now();if(i-t>n){t=i;try{r(...e)}catch(s){console.error("Throttled function execution failed:",s)}}}}function Ci(r,n){if(!r||!n)return r;const t=Ne(n);return t.length?t.reduce((e,i,s)=>{const o=s===t.length-1;if(ke.test(i)){const a=i.match(Me)||[];return a.reduce((l,c,h)=>{if(/^\w+$/.test(c))return l[c]||(h<a.length-1?[]:{});const u=c.match(Oe),d=u?parseInt(u[1],10):0,m=h===a.length-1;return m&&o?l[d]:l[d]||(m?{}:[])},e)}return o?e[i]:e[i]||{}},r):r}function Si(r,n,t,e){if(!r||!n)return t;const i=Ne(n);return i.length?i.reduce((s,o,a)=>{const l=a===i.length-1;if(ke.test(o)){const c=o.match(Me)||[];return c.reduce((h,u,d)=>{const m=d===c.length-1;if(/^\w+$/.test(u))return h.hasOwnProperty(u)||(h[u]=[]),h[u];const g=u.match(Oe),p=g?parseInt(g[1],10):0,v=m&&l;return h.hasOwnProperty(p)?v&&!e&&(h[p]=t):h[p]=v?t:m?{}:[],h[p]},s)}return l?((!e||!s.hasOwnProperty(o))&&(s[o]=t),s[o]):(s.hasOwnProperty(o)||(s[o]={}),s[o])},r):t}function Ei(r){return r.map((n,t)=>r.slice(t).concat(r.slice(0,t)))}function Ie(r){const n=window.structuredClone,t=(e,i=new WeakMap)=>{const s=e;if(s===null||typeof s!="object")return s;if(i.has(s))return i.get(s);switch(jt(s)){case"array":{const a=[];i.set(s,a);for(const l of s)a.push(t(l,i));return a}case"object":{if(s===null)return s;const a={};i.set(s,a);for(const l in s)Object.prototype.hasOwnProperty.call(s,l)&&(a[l]=t(s[l],i));return a}case"date":{const a=new Date(s.getTime());return i.set(s,a),a}case"regexp":{const a=s,l=new RegExp(a.source,a.flags);return l.lastIndex=a.lastIndex,i.set(s,l),l}case"map":{const a=new Map;return i.set(s,a),s.forEach((l,c)=>{a.set(t(c,i),t(l,i))}),a}case"set":{const a=new Set;return i.set(s,a),s.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=s,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(s,h),h}case"error":{const a=s,l=new a.constructor(a.message);return l.stack=a.stack,l.name=a.name,i.set(s,l),l}case"function":case"promise":case"weakmap":case"weakset":case"file":default:return s}};try{return n?n(r):t(r)}catch(e){return console.warn("structuredClone error:",e),n&&t(r)}}function He(r,n,t=30){if(typeof r!="function")return console.error("第一个参数必须是一个函数。");if(!Array.isArray(n))return console.error("第二个参数必须是一个数组。");let e=[],i=0;const s=(o,a)=>{for(const[l,c]of a)if(o>=l)return c;return"black"};return function(...o){const a=performance.now(),l=r(...o),c=performance.now()-a;e.push(c),e.length>t&&e.shift(),i=e.reduce((d,m)=>d+m,0)/e.length||0;const h=s(c,n),u=s(i,n);return console.log(`%c单次耗时:${c.toFixed(2)}ms
|
|
3
|
+
%c平均耗时(${e.length}次):${i.toFixed(2)}ms`,`color: ${h}; padding: 2px 0;`,`color: ${u}; padding: 2px 0;`),l}}function Di(r){const n=Date.now();let t=performance.now();for(;Date.now()-n<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()-n}function Vi(r,n=10){let t=0,e=n;function i(){if(e>0)e--,requestAnimationFrame(i);else{const o=(Date.now()-t)/n,a=1e3/o;r(Number(a.toFixed(2)),Number(o.toFixed(2)))}}requestAnimationFrame(()=>{t=Date.now(),i()})}function Ri(r){const n=()=>Promise.resolve(),t=a=>(console.error(a),Promise.reject(a));function e(){return navigator.clipboard.writeText(r).then(n).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 s(){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(n).catch(()=>{s().then(n).catch(()=>t("复制方式尽皆失效"))})}return navigator.clipboard?e().catch(o):o()}function ki(r,n){const t=ve[r];if(!t)return console.error(`未知纸张类型: ${r}`);const{width:e,height:i}=t,s=g=>g/25.4,a=typeof window<"u"?window.devicePixelRatio*96:300,l=g=>Math.round(s(g)*a),c=l(e),h=l(i),u=l(n),d=Math.max(0,c-2*u),m=Math.max(0,h-2*u);return{contentWidth:d,contentHeight:m,paddingPx:u,paperWidthPx:c,paperHeightPx:h}}class Vt{constructor(){}static init(n){if(!n)return console.error("标签页名称不能为空");this.initFinish||(this.setupEventListeners(),this.initFinish=!0),window.name=n}static setupEventListeners(){this.channel.addEventListener("message",n=>{this.handleChannelMessage(n)})}static handleChannelMessage(n){const{type:t,responseKey:e,name:i}=n.data;if(t==="response"){const s=this.pendingQueries.get(e);s==null||s.forEach(o=>o(i))}else if(t==="query"){if(this.pendingQueries.has(e)||i!="*"&&i!=window.name)return;const s={type:"response",responseKey:e,name:window.name};this.channel.postMessage(s)}}static getWindow(n){if(!this.initFinish){const o="请先初始化标签页管理器";return console.error(o),Promise.reject(o)}const t=$t();let e=!1;const i=this.pendingQueries.get(t)||[];i.push(()=>e=!0),this.pendingQueries.set(t,i);const s={type:"query",responseKey:t,name:n};return this.channel.postMessage(s),Ae(()=>e,this.timeout).finally(()=>this.pendingQueries.delete(t))}static openWindow(n,t,e="_blank",i){var s;if(!this.initFinish){const o="请先初始化标签页管理器";return console.error(o),Promise.reject(o)}return(s=this.getWindow(n))==null?void 0:s.then(()=>window.open("javascript:;",n)).catch(()=>{const o=window.open(t,e,i);return o||console.error("无法打开标签页"),o})}static getAllWindows(){if(!this.initFinish){const s="请先初始化标签页管理器";return console.error(s),Promise.reject(s)}const n=$t(),t=[],e=this.pendingQueries.get(n)||[];e.push(s=>t.push(s)),this.pendingQueries.set(n,e);const i={type:"query",responseKey:n,name:"*"};return this.channel.postMessage(i),new Promise(s=>{setTimeout(()=>{this.pendingQueries.delete(n),s(t)},this.timeout)})}}f(Vt,"initFinish",!1),f(Vt,"channel",new BroadcastChannel("nhanh-pure-function")),f(Vt,"timeout",150),f(Vt,"pendingQueries",new Map);/*!
|
|
3
4
|
* decimal.js v10.5.0
|
|
4
5
|
* An arbitrary-precision Decimal type for JavaScript.
|
|
5
6
|
* https://github.com/MikeMcl/decimal.js
|
|
6
7
|
* Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
|
|
7
8
|
* MIT Licence
|
|
8
|
-
*/var ae=9e15,ut=1e9,le="0123456789abcdef",zt="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Wt="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",ce={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-9e15,maxE:ae,crypto:!1},Re,nt,S=!0,Qt="[DecimalError] ",ct=Qt+"Invalid argument: ",ke=Qt+"Precision limit exceeded",Me=Qt+"crypto unavailable",Oe="[object Decimal]",L=Math.floor,I=Math.pow,li=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,ci=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,hi=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Ne=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,$=1e7,b=7,ui=9007199254740991,di=zt.length-1,he=Wt.length-1,y={toStringTag:Oe};y.absoluteValue=y.abs=function(){var r=new this.constructor(this);return r.s<0&&(r.s=1),x(r)};y.ceil=function(){return x(new this.constructor(this),this.e+1,2)};y.clampedTo=y.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(ct+s);return t=e.cmp(r),t<0?r:e.cmp(s)>0?s:new i(e)};y.comparedTo=y.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};y.cosine=y.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())+b,e.rounding=1,t=fi(e,Le(e,t)),e.precision=r,e.rounding=s,x(nt==2||nt==3?t.neg():t,r,s,!0)):new e(1):new e(NaN)};y.cubeRoot=y.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=H(h.d),r=h.e,(n=(r-t.length+1)%3)&&(t+=n==1||n==-2?"0":"00"),n=I(t,1/3),r=L((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=k(c.plus(h).times(a),c.plus(l),o+2,1),H(a.d).slice(0,o)===(t=H(e.d)).slice(0,o))if(t=t.slice(o-3,o+1),t=="9999"||!i&&t=="4999"){if(!i&&(x(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")&&(x(e,r+1,1),s=!e.times(e).times(e).eq(h));break}return S=!0,x(e,r,u.rounding,s)};y.decimalPlaces=y.dp=function(){var r,s=this.d,t=NaN;if(s){if(r=s.length-1,t=(r-L(this.e/b))*b,r=s[r],r)for(;r%10==0;r/=10)t--;t<0&&(t=0)}return t};y.dividedBy=y.div=function(r){return k(this,new this.constructor(r))};y.dividedToIntegerBy=y.divToInt=function(r){var s=this,t=s.constructor;return x(k(s,new t(r),0,1,1),t.precision,t.rounding)};y.equals=y.eq=function(r){return this.cmp(r)===0};y.floor=function(){return x(new this.constructor(this),this.e+1,3)};y.greaterThan=y.gt=function(r){return this.cmp(r)>0};y.greaterThanOrEqualTo=y.gte=function(r){var s=this.cmp(r);return s==1||s===0};y.hyperbolicCosine=y.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/ee(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 x(n,o.precision=t,o.rounding=e,!0)};y.hyperbolicSine=y.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/ee(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,x(i,s,t,!0)};y.hyperbolicTangent=y.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,k(t.sinh(),t.cosh(),e.precision=r,e.rounding=s)):new e(t.s)};y.inverseCosine=y.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()?K(s,e,i):new s(0):new s(NaN):r.isZero()?K(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))};y.inverseHyperbolicCosine=y.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)};y.inverseHyperbolicSine=y.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())};y.inverseHyperbolicTangent=y.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?x(new n(i),r,s,!0):(n.precision=t=e-i.e,i=k(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)};y.inverseSine=y.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=K(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)))};y.inverseTangent=y.atan=function(){var r,s,t,e,i,n,o,a,l,c=this,h=c.constructor,u=h.precision,d=h.rounding;if(c.isFinite()){if(c.isZero())return new h(c);if(c.abs().eq(1)&&u+4<=he)return o=K(h,u+4,d).times(.25),o.s=c.s,o}else{if(!c.s)return new h(NaN);if(u+4<=he)return o=K(h,u+4,d).times(.5),o.s=c.s,o}for(h.precision=a=u+10,h.rounding=1,t=Math.min(28,a/b+2|0),r=t;r;--r)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(S=!1,s=Math.ceil(a/b),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,x(o,h.precision=u,h.rounding=d,!0)};y.isFinite=function(){return!!this.d};y.isInteger=y.isInt=function(){return!!this.d&&L(this.e/b)>this.d.length-2};y.isNaN=function(){return!this.s};y.isNegative=y.isNeg=function(){return this.s<0};y.isPositive=y.isPos=function(){return this.s>0};y.isZero=function(){return!!this.d&&this.d[0]===0};y.lessThan=y.lt=function(r){return this.cmp(r)<0};y.lessThanOrEqualTo=y.lte=function(r){return this.cmp(r)<1};y.logarithm=y.log=function(r){var s,t,e,i,n,o,a,l,c=this,h=c.constructor,u=h.precision,d=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=at(c,a),e=s?qt(h,a+10):at(r,a),l=k(o,e,a,1),kt(l.d,i=u,d))do if(a+=10,o=at(c,a),e=s?qt(h,a+10):at(r,a),l=k(o,e,a,1),!n){+H(l.d).slice(i+1,i+15)+1==1e14&&(l=x(l,u+1,0));break}while(kt(l.d,i+=10,d));return S=!0,x(l,u,d)};y.minus=y.sub=function(r){var s,t,e,i,n,o,a,l,c,h,u,d,m=this,g=m.constructor;if(r=new g(r),!m.d||!r.d)return!m.s||!r.s?r=new g(NaN):m.d?r.s=-r.s:r=new g(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,d=r.d,a=g.precision,l=g.rounding,!c[0]||!d[0]){if(d[0])r.s=-r.s;else if(c[0])r=new g(m);else return new g(l===3?-0:0);return S?x(r,a,l):r}if(t=L(r.e/b),h=L(m.e/b),c=c.slice(),n=h-t,n){for(u=n<0,u?(s=c,n=-n,o=d.length):(s=d,t=h,o=c.length),e=Math.max(Math.ceil(a/b),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=d.length,u=e<o,u&&(o=e),e=0;e<o;e++)if(c[e]!=d[e]){u=c[e]<d[e];break}n=0}for(u&&(s=c,c=d,d=s,r.s=-r.s),o=c.length,e=d.length-o;e>0;--e)c[o++]=0;for(e=d.length;e>n;){if(c[--e]<d[e]){for(i=e;i&&c[--i]===0;)c[i]=$-1;--c[i],c[e]+=$}c[e]-=d[e]}for(;c[--o]===0;)c.pop();for(;c[0]===0;c.shift())--t;return c[0]?(r.d=c,r.e=te(c,t),S?x(r,a,l):r):new g(l===3?-0:0)};y.modulo=y.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]?x(new e(t),e.precision,e.rounding):(S=!1,e.modulo==9?(s=k(t,r.abs(),0,3,1),s.s*=r.s):s=k(t,r,0,e.modulo,1),s=s.times(r),S=!0,t.minus(s))};y.naturalExponential=y.exp=function(){return ue(this)};y.naturalLogarithm=y.ln=function(){return at(this)};y.negated=y.neg=function(){var r=new this.constructor(this);return r.s=-r.s,x(r)};y.plus=y.add=function(r){var s,t,e,i,n,o,a,l,c,h,u=this,d=u.constructor;if(r=new d(r),!u.d||!r.d)return!u.s||!r.s?r=new d(NaN):u.d||(r=new d(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=d.precision,l=d.rounding,!c[0]||!h[0])return h[0]||(r=new d(u)),S?x(r,a,l):r;if(n=L(u.e/b),e=L(r.e/b),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/b),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)/$|0,c[i]%=$;for(s&&(c.unshift(s),++e),o=c.length;c[--o]==0;)c.pop();return r.d=c,r.e=te(c,e),S?x(r,a,l):r};y.precision=y.sd=function(r){var s,t=this;if(r!==void 0&&r!==!!r&&r!==1&&r!==0)throw Error(ct+r);return t.d?(s=Ae(t.d),r&&t.e+1>s&&(s=t.e+1)):s=NaN,s};y.round=function(){var r=this,s=r.constructor;return x(new s(r),r.e+1,s.rounding)};y.sine=y.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())+b,e.rounding=1,t=pi(e,Le(e,t)),e.precision=r,e.rounding=s,x(nt>2?t.neg():t,r,s,!0)):new e(NaN)};y.squareRoot=y.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=H(a),(s.length+l)%2==0&&(s+="0"),c=Math.sqrt(s),l=L((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(k(o,n,t+2,1)).times(.5),H(n.d).slice(0,t)===(s=H(e.d)).slice(0,t))if(s=s.slice(t-3,t+1),s=="9999"||!i&&s=="4999"){if(!i&&(x(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")&&(x(e,l+1,1),r=!e.times(e).eq(o));break}return S=!0,x(e,l,h.rounding,r)};y.tangent=y.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=k(t,new e(1).minus(t.times(t)).sqrt(),r+10,0),e.precision=r,e.rounding=s,x(nt==2||nt==4?t.neg():t,r,s,!0)):new e(NaN)};y.times=y.mul=function(r){var s,t,e,i,n,o,a,l,c,h=this,u=h.constructor,d=h.d,m=(r=new u(r)).d;if(r.s*=h.s,!d||!d[0]||!m||!m[0])return new u(!r.s||d&&!d[0]&&!m||m&&!m[0]&&!d?NaN:!d||!m?r.s/0:r.s*0);for(t=L(h.e/b)+L(r.e/b),l=d.length,c=m.length,l<c&&(n=d,d=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]*d[i-e-1]+s,n[i--]=a%$|0,s=a/$|0;n[i]=(n[i]+s)%$|0}for(;!n[--o];)n.pop();return s?++t:n.shift(),r.d=n,r.e=te(n,t),S?x(r,u.precision,u.rounding):r};y.toBinary=function(r,s){return ye(this,2,r,s)};y.toDecimalPlaces=y.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),x(t,r+t.e+1,s))};y.toExponential=function(r,s){var t,e=this,i=e.constructor;return r===void 0?t=Q(e,!0):(U(r,0,ut),s===void 0?s=i.rounding:U(s,0,8),e=x(new i(e),r+1,s),t=Q(e,!0,r+1)),e.isNeg()&&!e.isZero()?"-"+t:t};y.toFixed=function(r,s){var t,e,i=this,n=i.constructor;return r===void 0?t=Q(i):(U(r,0,ut),s===void 0?s=n.rounding:U(s,0,8),e=x(new n(i),r+i.e+1,s),t=Q(e,!1,r+e.e+1)),i.isNeg()&&!i.isZero()?"-"+t:t};y.toFraction=function(r){var s,t,e,i,n,o,a,l,c,h,u,d,m=this,g=m.d,p=m.constructor;if(!g)return new p(m);if(c=t=new p(1),e=l=new p(0),s=new p(e),n=s.e=Ae(g)-m.e-1,o=n%b,s.d[0]=I(10,o<0?b+o:o),r==null)r=n>0?s:c;else{if(a=new p(r),!a.isInt()||a.lt(c))throw Error(ct+a);r=a.gt(s)?n>0?s:c:a}for(S=!1,a=new p(H(g)),h=p.precision,p.precision=n=g.length*b*2;u=k(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=k(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,d=k(c,e,n,1).minus(m).abs().cmp(k(l,t,n,1).minus(m).abs())<1?[c,e]:[l,t],p.precision=h,S=!0,d};y.toHexadecimal=y.toHex=function(r,s){return ye(this,16,r,s)};y.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=k(t,r,0,s,1).times(r),S=!0,x(t)):(r.s=t.s,t=r),t};y.toNumber=function(){return+this};y.toOctal=function(r,s){return ye(this,8,r,s)};y.toPower=y.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 x(a,e,n);if(s=L(r.e/b),s>=r.d.length-1&&(t=c<0?-c:c)<=ui)return i=Ie(l,a,t,e),r.s<0?new l(1).div(i):x(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)?L(c*(Math.log("0."+H(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=ue(r.times(at(a,e+t)),e),i.d&&(i=x(i,e+5,1),kt(i.d,e,n)&&(s=e+10,i=x(ue(r.times(at(a,s+t)),s),s+5,1),+H(i.d).slice(e+1,e+15)+1==1e14&&(i=x(i,e+1,0)))),i.s=o,S=!0,l.rounding=n,x(i,e,n))};y.toPrecision=function(r,s){var t,e=this,i=e.constructor;return r===void 0?t=Q(e,e.e<=i.toExpNeg||e.e>=i.toExpPos):(U(r,1,ut),s===void 0?s=i.rounding:U(s,0,8),e=x(new i(e),r,s),t=Q(e,r<=e.e||e.e<=i.toExpNeg,r)),e.isNeg()&&!e.isZero()?"-"+t:t};y.toSignificantDigits=y.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)),x(new e(t),r,s)};y.toString=function(){var r=this,s=r.constructor,t=Q(r,r.e<=s.toExpNeg||r.e>=s.toExpPos);return r.isNeg()&&!r.isZero()?"-"+t:t};y.truncated=y.trunc=function(){return x(new this.constructor(this),this.e+1,1)};y.valueOf=y.toJSON=function(){var r=this,s=r.constructor,t=Q(r,r.e<=s.toExpNeg||r.e>=s.toExpPos);return r.isNeg()?"-"+t:t};function H(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=b-e.length,t&&(n+=ot(t)),n+=e;o=r[s],e=o+"",t=b-e.length,t&&(n+=ot(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(ct+r)}function kt(r,s,t,e){var i,n,o,a;for(n=r[0];n>=10;n/=10)--s;return--s<0?(s+=b,i=0):(i=Math.ceil((s+1)/b),s%=b),n=I(10,b-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 Ft(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]+=le.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 fi(r,s){var t,e,i;if(s.isZero())return s;e=s.d.length,e<32?(t=Math.ceil(e/3),i=(1/ee(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 k=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,d,m,g,p,v,w,_,C,E,N,G,Nt,dt,rt,vt,X,At,It=e.constructor,ne=e.s==i.s?1:-1,T=e.d,M=i.d;if(!T||!T[0]||!M||!M[0])return new It(!e.s||!i.s||(T?M&&T[0]==M[0]:!M)?NaN:T&&T[0]==0||!M?ne*0:ne/0);for(l?(m=1,h=e.e-i.e):(l=$,m=b,h=L(e.e/m)-L(i.e/m)),X=M.length,rt=T.length,w=new It(ne),_=w.d=[],u=0;M[u]==(T[u]||0);u++);if(M[u]>(T[u]||0)&&h--,n==null?(G=n=It.precision,o=It.rounding):a?G=n+(e.e-i.e)+1:G=n,G<0)_.push(1),g=!0;else{if(G=G/m+2|0,u=0,X==1){for(d=0,M=M[0],G++;(u<rt||d)&&G--;u++)Nt=d*l+(T[u]||0),_[u]=Nt/M|0,d=Nt%M|0;g=d||u<rt}else{for(d=l/(M[0]+1)|0,d>1&&(M=r(M,d,l),T=r(T,d,l),X=M.length,rt=T.length),dt=X,C=T.slice(0,X),E=C.length;E<X;)C[E++]=0;At=M.slice(),At.unshift(0),vt=M[0],M[1]>=l/2&&++vt;do d=0,c=s(M,C,X,E),c<0?(N=C[0],X!=E&&(N=N*l+(C[1]||0)),d=N/vt|0,d>1?(d>=l&&(d=l-1),p=r(M,d,l),v=p.length,E=C.length,c=s(p,C,v,E),c==1&&(d--,t(p,X<v?At:M,v,l))):(d==0&&(c=d=1),p=M.slice()),v=p.length,v<E&&p.unshift(0),t(C,p,E,l),c==-1&&(E=C.length,c=s(M,C,X,E),c<1&&(d++,t(C,X<E?At:M,E,l))),E=C.length):c===0&&(d++,C=[0]),_[u++]=d,c&&C[0]?C[E++]=T[dt]||0:(C=[T[dt]],E=1);while((dt++<rt||C[0]!==void 0)&&G--);g=C[0]!==void 0}_[0]||_.shift()}if(m==1)w.e=h,Re=g;else{for(u=1,d=_[0];d>=10;d/=10)u++;w.e=u+h*m-1,x(w,a?n+w.e+1:n,o,g)}return w}}();function x(r,s,t,e){var i,n,o,a,l,c,h,u,d,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+=b,o=s,h=u[d=0],l=h/I(10,i-o-1)%10|0;else if(d=Math.ceil((n+1)/b),a=u.length,d>=a)if(e){for(;a++<=d;)u.push(0);h=l=0,i=1,n%=b,o=n-b+1}else break t;else{for(h=a=u[d],i=1;a>=10;a/=10)i++;n%=b,o=n-b+i,l=o<0?0:h/I(10,i-o-1)%10|0}if(e=e||s<0||u[d+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[d-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,(b-s%b)%b),r.e=-s||0):u[0]=r.e=0,r;if(n==0?(u.length=d,a=1,d--):(u.length=d+1,a=I(10,b-n),u[d]=o>0?(h/I(10,i-o)%I(10,o)|0)*a:0),c)for(;;)if(d==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]==$&&(u[0]=1));break}else{if(u[d]+=a,u[d]!=$)break;u[d--]=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 Q(r,s,t){if(!r.isFinite())return Te(r);var e,i=r.e,n=H(r.d),o=n.length;return s?(t&&(e=t-o)>0?n=n.charAt(0)+"."+n.slice(1)+ot(e):o>1&&(n=n.charAt(0)+"."+n.slice(1)),n=n+(r.e<0?"e":"e+")+r.e):i<0?(n="0."+ot(-i-1)+n,t&&(e=t-o)>0&&(n+=ot(e))):i>=o?(n+=ot(i+1-o),t&&(e=t-i-1)>0&&(n=n+"."+ot(e))):((e=i+1)<o&&(n=n.slice(0,e)+"."+n.slice(e)),t&&(e=t-o)>0&&(i+1===o&&(n+="."),n+=ot(e))),n}function te(r,s){var t=r[0];for(s*=b;t>=10;t/=10)s++;return s}function qt(r,s,t){if(s>di)throw S=!0,t&&(r.precision=t),Error(ke);return x(new r(zt),s,1,!0)}function K(r,s,t){if(s>he)throw Error(ke);return x(new r(Wt),s,t,!0)}function Ae(r){var s=r.length-1,t=s*b+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 ot(r){for(var s="";r--;)s+="0";return s}function Ie(r,s,t,e){var i,n=new r(1),o=Math.ceil(e/b+4);for(S=!1;;){if(t%2&&(n=n.times(s),Ce(n.d,o)&&(i=!0)),t=L(t/2),t===0){t=n.d.length-1,i&&n.d[t]===0&&++n.d[t];break}s=s.times(s),Ce(s.d,o)}return S=!0,n}function _e(r){return r.d[r.d.length-1]&1}function He(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 ue(r,s){var t,e,i,n,o,a,l,c=0,h=0,u=0,d=r.constructor,m=d.rounding,g=d.precision;if(!r.d||!r.d[0]||r.e>17)return new d(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=g):l=s,a=new d(.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 d(1),d.precision=l;;){if(n=x(n.times(r),l,1),t=t.times(++h),a=o.plus(k(n,t,l,1)),H(a.d).slice(0,l)===H(o.d).slice(0,l)){for(i=u;i--;)o=x(o.times(o),l,1);if(s==null)if(c<3&&kt(o.d,l-e,m,c))d.precision=l+=10,t=n=a=new d(1),h=0,c++;else return x(o,d.precision=g,m,S=!0);else return d.precision=g,o}o=a}}function at(r,s){var t,e,i,n,o,a,l,c,h,u,d,m=1,g=10,p=r,v=p.d,w=p.constructor,_=w.rounding,C=w.precision;if(p.s<0||!v||!v[0]||!p.e&&v[0]==1&&v.length==1)return new w(v&&!v[0]?-1/0:p.s!=1?NaN:v?0:p);if(s==null?(S=!1,h=C):h=s,w.precision=h+=g,t=H(v),e=t.charAt(0),Math.abs(n=p.e)<15e14){for(;e<7&&e!=1||e==1&&t.charAt(1)>3;)p=p.times(r),t=H(p.d),e=t.charAt(0),m++;n=p.e,e>1?(p=new w("0."+t),n++):p=new w(e+"."+t.slice(1))}else return c=qt(w,h+2,C).times(n+""),p=at(new w(e+"."+t.slice(1)),h-g).plus(c),w.precision=C,s==null?x(p,C,_,S=!0):p;for(u=p,l=o=p=k(p.minus(1),p.plus(1),h,1),d=x(p.times(p),h,1),i=3;;){if(o=x(o.times(d),h,1),c=l.plus(k(o,new w(i),h,1)),H(c.d).slice(0,h)===H(l.d).slice(0,h))if(l=l.times(2),n!==0&&(l=l.plus(qt(w,h+2,C).times(n+""))),l=k(l,new w(m),h,1),s==null)if(kt(l.d,h-g,_,a))w.precision=h+=g,c=o=p=k(u.minus(1),u.plus(1),h,1),d=x(p.times(p),h,1),i=a=1;else return x(l,w.precision=C,_,S=!0);else return w.precision=C,l;l=c,i+=2}}function Te(r){return String(r.s*r.s/0)}function Bt(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)%b,t<0&&(e+=b),e<i){for(e&&r.d.push(+s.slice(0,e)),i-=b;e<i;)r.d.push(+s.slice(e,e+=b));s=s.slice(e),e=b-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 mi(r,s){var t,e,i,n,o,a,l,c,h;if(s.indexOf("_")>-1){if(s=s.replace(/(\d)_(?=\d)/g,"$1"),Ne.test(s))return Bt(r,s)}else if(s==="Infinity"||s==="NaN")return+s||(r.s=NaN),r.e=NaN,r.d=null,r;if(ci.test(s))t=16,s=s.toLowerCase();else if(li.test(s))t=2;else if(hi.test(s))t=8;else throw Error(ct+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=Ie(e,new e(t),n,n*2)),c=Ft(s,t,$),h=c.length-1,n=h;c[n]===0;--n)c.pop();return n<0?new e(r.s*0):(r.e=te(c,h),r.d=c,S=!1,o&&(r=k(r,i,a*4)),l&&(r=r.times(Math.abs(l)<54?I(2,l):R.pow(2,l))),S=!0,r)}function pi(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/ee(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/b);for(S=!1,l=t.times(t),a=new r(e);;){if(o=k(a.times(l),new r(s++*s++),c,1),a=i?e.plus(o):e.minus(o),e=k(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 ee(r,s){for(var t=r;--s;)t*=r;return t}function Le(r,s){var t,e=s.s<0,i=K(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=_e(t)?e?2:3:e?4:1,s;nt=_e(t)?e?1:4:e?3:2}return s.minus(i).abs()}function ye(r,s,t,e){var i,n,o,a,l,c,h,u,d,m=r.constructor,g=t!==void 0;if(g?(U(t,1,ut),e===void 0?e=m.rounding:U(e,0,8)):(t=m.precision,e=m.rounding),!r.isFinite())h=Te(r);else{for(h=Q(r),o=h.indexOf("."),g?(i=2,s==16?t=t*4-3:s==8&&(t=t*3-2)):i=s,o>=0&&(h=h.replace(".",""),d=new m(1),d.e=h.length-o,d.d=Ft(Q(d),10,i),d.e=d.d.length),u=Ft(h,10,i),n=l=u.length;u[--l]==0;)u.pop();if(!u[0])h=g?"0p+0":"0";else{if(o<0?n--:(r=new m(r),r.d=u,r.e=n,r=k(r,d,t,e,0,i),u=r.d,n=r.e,c=Re),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+=le.charAt(u[o]);if(g){if(l>1)if(s==16||s==8){for(o=s==16?4:3,--l;l%o;l++)h+="0";for(u=Ft(h,i,s),l=u.length;!u[l-1];--l);for(o=1,h="1.";o<l;o++)h+=le.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 Ce(r,s){if(r.length>s)return r.length=s,!0}function gi(r){return new this(r).abs()}function yi(r){return new this(r).acos()}function vi(r){return new this(r).acosh()}function wi(r,s){return new this(r).plus(s)}function Pi(r){return new this(r).asin()}function xi(r){return new this(r).asinh()}function bi(r){return new this(r).atan()}function _i(r){return new this(r).atanh()}function Ci(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=K(this,n,1).times(s.s>0?.25:.75),t.s=r.s):!s.d||r.isZero()?(t=s.s<0?K(this,e,i):new this(0),t.s=r.s):!r.d||s.isZero()?(t=K(this,n,1).times(.5),t.s=r.s):s.s<0?(this.precision=n,this.rounding=1,t=this.atan(k(r,s,n,1)),s=K(this,n,1),this.precision=e,this.rounding=i,t=r.s<0?t.minus(s):t.plus(s)):t=this.atan(k(r,s,n,1)),t}function Si(r){return new this(r).cbrt()}function Ei(r){return x(r=new this(r),r.e+1,2)}function Di(r,s,t){return new this(r).clamp(s,t)}function Vi(r){if(!r||typeof r!="object")throw Error(Qt+"Object expected");var s,t,e,i=r.defaults===!0,n=["precision",1,ut,"rounding",0,8,"toExpNeg",-9e15,0,"toExpPos",0,ae,"maxE",0,ae,"minE",-9e15,0,"modulo",0,9];for(s=0;s<n.length;s+=3)if(t=n[s],i&&(this[t]=ce[t]),(e=r[t])!==void 0)if(L(e)===e&&e>=n[s+1]&&e<=n[s+2])this[t]=e;else throw Error(ct+t+": "+e);if(t="crypto",i&&(this[t]=ce[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(Me);else this[t]=!1;else throw Error(ct+t+": "+e);return this}function Ri(r){return new this(r).cos()}function ki(r){return new this(r).cosh()}function Fe(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,Se(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 Bt(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),Ne.test(n)?Bt(c,n):mi(c,n);if(l==="bigint")return n<0?(n=-n,c.s=-1):c.s=1,Bt(c,n.toString());throw Error(ct+n)}if(i.prototype=y,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=Vi,i.clone=Fe,i.isDecimal=Se,i.abs=gi,i.acos=yi,i.acosh=vi,i.add=wi,i.asin=Pi,i.asinh=xi,i.atan=bi,i.atanh=_i,i.atan2=Ci,i.cbrt=Si,i.ceil=Ei,i.clamp=Di,i.cos=Ri,i.cosh=ki,i.div=Mi,i.exp=Oi,i.floor=Ni,i.hypot=Ai,i.ln=Ii,i.log=Hi,i.log10=Li,i.log2=Ti,i.max=Fi,i.min=Bi,i.mod=Ui,i.mul=Gi,i.pow=Xi,i.random=Yi,i.round=zi,i.sign=Wi,i.sin=qi,i.sinh=ji,i.sqrt=$i,i.sub=Zi,i.sum=Ji,i.tan=Ki,i.tanh=Qi,i.trunc=ts,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 Mi(r,s){return new this(r).div(s)}function Oi(r){return new this(r).exp()}function Ni(r){return x(r=new this(r),r.e+1,3)}function Ai(){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 Se(r){return r instanceof R||r&&r.toStringTag===Oe||!1}function Ii(r){return new this(r).ln()}function Hi(r,s){return new this(r).log(s)}function Ti(r){return new this(r).log(2)}function Li(r){return new this(r).log(10)}function Fi(){return He(this,arguments,-1)}function Bi(){return He(this,arguments,1)}function Ui(r,s){return new this(r).mod(s)}function Gi(r,s){return new this(r).mul(s)}function Xi(r,s){return new this(r).pow(s)}function Yi(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/b),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(Me);else for(;n<e;)a[n++]=Math.random()*1e7|0;for(e=a[--n],r%=b,e&&r&&(i=I(10,b-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-=b)a.shift();for(e=1,i=a[0];i>=10;i/=10)e++;e<b&&(t-=b-e)}return o.e=t,o.d=a,o}function zi(r){return x(r=new this(r),r.e+1,this.rounding)}function Wi(r){return r=new this(r),r.d?r.d[0]?r.s:0*r.s:r.s||NaN}function qi(r){return new this(r).sin()}function ji(r){return new this(r).sinh()}function $i(r){return new this(r).sqrt()}function Zi(r,s){return new this(r).sub(s)}function Ji(){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,x(t,this.precision,this.rounding)}function Ki(r){return new this(r).tan()}function Qi(r){return new this(r).tanh()}function ts(r){return x(r=new this(r),r.e+1,1)}y[Symbol.for("nodejs.util.inspect.custom")]=y.toString;y[Symbol.toStringTag]="Decimal";var R=y.constructor=Fe(ce);zt=new R(zt);Wt=new R(Wt);class es{constructor(){f(this,"parent");f(this,"name","");f(this,"extData");f(this,"mainCanvas");f(this,"_isRecalculate",!1);f(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 is extends es{constructor(){super(...arguments);f(this,"_isVisible",!0);f(this,"inheritOpacity",!0);f(this,"_opacity");f(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 ss=class extends is{constructor(s){super(),s.name=s.name||ze("default-name-"),Object.assign(this,{...s})}};class ns extends ss{constructor(t){super(t);f(this,"_isInteractive",!0);f(this,"_isHoverable",!0);f(this,"_isDownable",!0);f(this,"_isContextmenuable",!0);f(this,"_isClickable",!0);f(this,"_isDoubleClickable",!0);f(this,"_isDraggable",!0);f(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 rs{constructor(s){f(this,"propagationStopped",!1);this.data=s}stopPropagation(){this.propagationStopped=!0}get canPropagate(){return!this.propagationStopped}}class Ot extends ns{constructor(){super(...arguments);f(this,"listeners",{wheel:new Set,hover:new Set,down:new Set,contextmenu:new Set,click:new Set,doubleClick:new Set,dragg:new Set});f(this,"sharedControllers",{});f(this,"_eventDate",{});f(this,"_clearEventDate",!1);f(this,"_isHover",!1);f(this,"notifyHover",(t,e)=>this.checkEventDate("hover",t)&&this.trigger("hover",{state:t,oldState:this.isHover},e,"isHoverable"));f(this,"_isDown",!1);f(this,"notifyDown",(t,e)=>this.checkEventDate("down",t)&&this.trigger("down",{state:t,oldState:this.isDown},e,"isDownable"));f(this,"_isContextmenu",!1);f(this,"notifyContextmenu",(t,e)=>this.checkEventDate("contextmenu",t)&&this.trigger("contextmenu",{state:t,oldState:this.isContextmenu},e,"isContextmenuable"));f(this,"_isClick",!1);f(this,"clickTimestamp",0);f(this,"doubleClickInterval",300);f(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")});f(this,"_isDblClick",!1);f(this,"notifyDoubleClick",(t,e)=>this.checkEventDate("doubleClick",t)&&this.trigger("doubleClick",{state:t,oldState:this.isDblClick},e,"isDoubleClickable"));f(this,"notifyDragg",(t,e)=>this.checkEventDate("dragg",t)&&this.trigger("dragg",t,e,"isDraggable"));f(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 rs(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 os extends Ot{constructor(t){super(t);f(this,"canvas");f(this,"ctx");f(this,"_rectValueIsUpdated",!1);f(this,"_rect");f(this,"offset",{x:0,y:0});f(this,"center",{x:0,y:0});f(this,"defaultCenter",{top:void 0,bottom:void 0,left:void 0,right:void 0});f(this,"accuracy",5);f(this,"scale",1);f(this,"defaultScale",1);f(this,"percentage",1);f(this,"axisConfig",{count:2,min:100,size:100,x:1,y:1});f(this,"cycle",10);f(this,"delta",.02);f(this,"_redrawInNextRenderFrame",!1);f(this,"isAuto",!1);f(this,"isRendering",!1);f(this,"drawAxis");f(this,"layerGroups",new Map);f(this,"isScaleUpdated",!1);f(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:(p,v)=>{if([0,"0","0%"].includes(p))return 0;if(!(p==1/0||p==-1/0))return typeof p=="number"?p:["top","left"].includes(p)?0:["bottom","right"].includes(p)?v:["middle","center"].includes(p)?v/2:/^(-?\d+)%$/.test(p)?(p=p.match(/^(-?\d+)%$/)[1],v*Number(p)/100):Number(p)||void 0},reverse:(p,v)=>{if([0,"0","0%"].includes(p))return v;if(p==1/0||p==-1/0)return;if(typeof p=="number")return v-p;const w=u.vertical(p,v);return w?v-w:void 0}},d=(p,v,w)=>{if(p!==void 0){const _=u.vertical(p,w);if(_!==void 0)return _}if(v!==void 0){const _=u.reverse(v,w);if(_!==void 0)return _}return w/2},m=d(a,l,o);return{x:d(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 d=this.getAxisPointByValue(u.xV,u.yV);this.offset.x-=(d.x-h.x)*o.x,this.offset.y-=(d.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(([p,v])=>[p,Number(v)])),{x:n,y:o,count:a,min:l,size:c}=i,h=[1,-1].includes(n),u=[1,-1].includes(o),d=a>0,m=l>0,g=c>=l&&c<=l*2;if(!h||!u||!d||!m||!g){console.warn("Invalid axis configuration:",{x:n,y:o,count:a,min:l,size:c});return}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,d=(l-h-i.y)*o.y;return{x:u,y:d}}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:d,y:m}=this.getMousePositionOnAxis({clientX:a.x==1?n:e,clientY:a.y==1?o:i}),{xV:g,yV:p}=this.getAxisValueByPoint(d,m);return{minXV:h,maxXV:g,minYV:u,maxYV:p}}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 as extends os{constructor(t){super(t);f(this,"theme","light");f(this,"isThemeUpdated",!1);f(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"}}},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"}}}});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=We(this.style[e]||this.style[this.theme]);ht(i,t[e]),this.style[e]=i}this.initStyle()}setTheme(t){t in this.style&&(this.theme=t,this.isThemeUpdated=!0)}}class V extends Ot{constructor(t){t={...t},t.isDraggable=t.isDraggable??!1;const{mainCanvas:e,notifyReload:i}=t;delete t.mainCanvas,delete t.notifyReload;super(t);f(this,"_style");f(this,"_position");f(this,"_value");f(this,"_zIndex",0);f(this,"_dynamicPosition");f(this,"_offset",{x:0,y:0});f(this,"path");f(this,"publicToPrivateKeyMap",{offset:"_offset",position:"_position",value:"_value",dynamicPosition:"_dynamicPosition",zIndex:"_zIndex",style:"_style"});f(this,"redrawOnIsHoverChange",!0);f(this,"defaultHover",(t,e)=>{var i;this.redrawOnIsHoverChange&&((i=this.notifyReload)==null||i.call(this))});f(this,"_valueScope");f(this,"styleRadius",{value:0,radius:0});f(this,"offsetValue",{xV:0,yV:0});f(this,"fixedExtraScope",{topV:0,bottomV:0,leftV:0,rightV:0});f(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,d=h-o.yV;i.minX+=u,i.maxX+=u,i.minY+=d,i.maxY+=d,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:d,yV:m}=i.getAxisValueByPoint(o,a);e.minX-=d-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:d,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"?ie:Mt,[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 d=o.getAxisPointByValue(u[0],u[1],!0);h.position=[d.x,d.y]}else{h.position=[];for(let d=0;d<u.length;d++){const m=u[d],g=o.getAxisPointByValue(m[0],m[1],!0);h.position.push([g.x,g.y])}}}else{const u=n;if(t==="array1D"){const d=o.getAxisValueByPoint(u[0],u[1],!0);h.value=[d.xV,d.yV]}else{h.value=[];for(let d=0;d<u.length;d++){const m=u[d],g=o.getAxisValueByPoint(m[0],m[1],!0);h.value.push([g.xV,g.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}}f(V,"ctx",document.createElement("canvas").getContext("2d"));class Ut extends V{constructor(t){super(t);f(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:void 0});let t=this.value,e=this.position;t?e=this.convertValuesToPositions(t):t=this.convertPositionsToValues(e),this.updateDataProperties(t,e)}convertValuesToPositions(t){const e=[];let i=1;return t.forEach((n,o)=>{if(o===0){const a=this.mainCanvas.getAxisPointByValue(n[0],n[1],!0);e.push([a.x,a.y]),i=new R(a.x).div(n[0]).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=1;return t.forEach((n,o)=>{if(o===0){const a=this.mainCanvas.getAxisValueByPoint(n[0],n[1],!0);e.push([a.xV,a.yV]),i=new R(a.xV).div(n[0]).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&&this.internalUpdate({dynamicPosition:t.transformPosition(e)}),[this.draw,this]}}}class O{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 Gt extends V{constructor(t){super(t);f(this,"textOffset",{x:0,y:0});f(this,"_text");f(this,"defaultDragg",(t,e)=>{var l;const{offsetX:i,offsetY:n}=t.data,{x:o,y:a}=this.calculateOffset(i,n);this.internalUpdate({value:[O.add(this.value[0],o.value),O.add(this.value[1],a.value)],position:[O.add(this.position[0],o.position),O.add(this.position[1],a.position)],dynamicPosition:[O.add(this.dynamicPosition[0],o.dynamicPosition),O.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?V.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=V.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 lt extends V{constructor(t){super(t);f(this,"angle",2*Math.PI);f(this,"defaultDragg",(t,e)=>{var l;const{offsetX:i,offsetY:n}=t.data,{x:o,y:a}=this.calculateOffset(i,n);this.internalUpdate({value:[O.add(this.value[0],o.value),O.add(this.value[1],a.value)],position:[O.add(this.position[0],o.position),O.add(this.position[1],a.position)],dynamicPosition:[O.add(this.dynamicPosition[0],o.dynamicPosition),O.add(this.dynamicPosition[1],a.dynamicPosition)]},!0),(l=this.notifyReload)==null||l.call(this)});f(this,"fillProgress");f(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=Rt(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:Rt(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?V.ctx.isPointInPath(this.path,t,e):!1}isPointInStroke(t,e){var i;if(this.path&&this.mainCanvas){const{width:n}=this.setOverlayStyles(V.ctx);return((i=this.fillProgress)==null?void 0:i.lineWidthOffset)==n?!1:V.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 Be extends V{constructor(t){super(t);f(this,"handlePoints",[]);f(this,"isShowHandlePoint",!1);f(this,"_isHandlePointsVisible",!0);f(this,"canCreateOrDeleteHandlePoint",!0);f(this,"lockedCanCreateOrDeleteHandlePoint",!1);f(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))});f(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)}}});f(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]=[O.add(this.value[u][0],l.value),O.add(this.value[u][1],c.value)],this.position[u]=[O.add(this.position[u][0],l.position),O.add(this.position[u][1],c.position)],this.dynamicPosition[u]=[O.add(this.dynamicPosition[u][0],l.dynamicPosition),O.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=ls([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=re(this.value[t],this.value[e]),n=re(this.position[t],this.position[e]),o=re(this.dynamicPosition[t],this.dynamicPosition[e]);return new lt({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 lt({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 ls(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=Je(r,s[n],s[n+1]);if(o<t)return n+1;o<e&&(e=o,i=n+1)}return i}function re(r,s){const{x:t,y:e}=Pe(...r,...s);return[t,e]}class Xt extends Be{constructor(t){super(t);f(this,"_isInfinite");f(this,"isClosed",!1);f(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(V.ctx),this.isDraggable&&(V.ctx.lineWidth=Math.max(V.ctx.lineWidth,20)),V.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 cs([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=ht(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=Ee(o,[-l[0],-l[1]],n.width,n.height),h=Ee(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 Ee(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 cs(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[p,v]=t;return p>=i&&p<=n&&v>=o&&v<=a}const d=1e-10;let m=!1,g=!1;for(const[p,v]of l){const w=c*p+h*v+u;if(Math.abs(w)<d||(w>d?m=!0:g=!0,m&&g))return!0}return m&&g}class Yt extends Be{constructor(t){super(t);f(this,"_isRect",!1);f(this,"dynamicBorderRadius");f(this,"_borderRadius");f(this,"_borderRadiusType","position");f(this,"isClosed",!0);f(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?V.ctx.isPointInPath(this.path,t,e):!1}isPointInStroke(t,e){return this.path&&this.mainCanvas?(this.setOverlayStyles(V.ctx),this.isDraggable&&(V.ctx.lineWidth=Math.max(V.ctx.lineWidth,20)),V.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=ht(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(d=>{var m;d.internalUpdate({style:u.point}),(m=d.getDraw())==null||m[0].call(d,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 de extends V{constructor(t){super(t);f(this,"_isFill",!1);f(this,"_isClosed",!1);f(this,"_isClosedThroughCenter",!1);f(this,"_radiusValue",0);f(this,"_radiusPosition",0);f(this,"_startAngle",0);f(this,"_endAngle",0);f(this,"_counterclockwise",!1);f(this,"isShowHandlePoint",!1);f(this,"_isHandlePointsVisible",!0);f(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))});f(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:[O.add(u.value[0],a.value),O.add(u.value[1],l.value)],position:[O.add(u.position[0],a.position),O.add(u.position[1],l.position)],dynamicPosition:[O.add(u.dynamicPosition[0],a.dynamicPosition),O.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()});f(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?V.ctx.isPointInPath(this.path,t,e):!1}isPointInStroke(t,e){return this.path&&this.mainCanvas?(this.setOverlayStyles(V.ctx),this.isDraggable&&(V.ctx.lineWidth=Math.max(V.ctx.lineWidth,20)),V.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=ht(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]=hs(...e,i,n,o,t.axisConfig.x,t.axisConfig.y),d=w=>new lt({name:w,offset:c,isDraggable:!0,mainCanvas:this.mainCanvas,notifyReload:()=>{var _;return(_=this.notifyReload)==null?void 0:_.call(this)}}),m=this.handlePoints.start||d("start"),g=this.handlePoints.end||d("end"),p=this.handlePoints.radius||d("radius");m.value=h,g.value=u;const v=e[0]+i*2*t.axisConfig.x;p.value=[v,e[1]],this.handlePoints={start:m,end:g,radius:p}}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 d=this.setOverlayStyles(t),[m,g]=e;t.beginPath(),this.path=new Path2D,this.path.arc(m,g,u*i.percentage,n,o,a),c&&(this.path.lineTo(m,g),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,g,d),this.handlePointsArr.forEach(p=>{var v;p.internalUpdate({style:d.point}),(v=p.getDraw())==null||v[0].call(p,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 hs(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 fe extends V{constructor(t){super(t);f(this,"handlePoints");f(this,"isShowHandlePoint",!1);f(this,"_isHandlePointsVisible",!0);f(this,"_radiusValue",0);f(this,"_radiusPosition",0);f(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))});f(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(V.ctx),this.isDraggable&&(V.ctx.lineWidth=Math.max(V.ctx.lineWidth,20)),V.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=ht(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 lt({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,d)=>{a[d]||a.push(o()),a[d].internalUpdate({value:t[d],position:e[d],dynamicPosition:i[d]},!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]=[Mt(t)&&t.length>1,Mt(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 us extends as{constructor(t){super(t);f(this,"resizeObserver");f(this,"currentDrawOverlays",[]);f(this,"rely","");f(this,"maxMinValue",{minXV:0,maxXV:0,minYV:0,maxYV:0});f(this,"measureRedrawPerformance",qe(()=>{this.isRendering=!0,this.redraw(),this.redrawInNextRenderFrame=!1,this.isRendering=!1},[[1,"#F56C6C"],[.5,"#E6A23C"],[0,"#67C23A"]]));this.canvas&&(this.resizeObserver=new ResizeObserver(ve(()=>{[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],d])=>{t.push([[h+c,u],d])})}),t.sort(([[a,l],c],[[h,u],d])=>{if(a!==h)return h-a;if(l!==u)return u-l;const m=g=>g instanceof Ut?5:g instanceof Gt?4:g instanceof lt?3:g instanceof Xt||g instanceof de||g instanceof fe?2:g instanceof Yt?1:0;return m(d)-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),d=this.getAxisValueByPoint(h.x,h.y);return[...this.currentDrawOverlays].sort((m,g)=>(m.isDraggable&&m.isClick?0:1)-(g.isDraggable&&g.isClick?0:1)).find(m=>{const g=m.valueScope;return g&&(g.maxX<u.xV||g.minX>d.xV||g.maxY<u.yV||g.minY>d.yV)?!1:m.isPointInAnywhere(e,i)})}destroy(){var t;(t=this.resizeObserver)==null||t.disconnect()}}class ds extends us{constructor(t){super(t);f(this,"mouseInCanvas",!1);f(this,"mouseIsDown",!1);f(this,"mouseLastPosition",{x:0,y:0});f(this,"unBind");f(this,"lastClickedOverlay");f(this,"lockNotifyClick",!1);f(this,"lastContextmenuOverlay");f(this,"defaultContextmenu",(t,e)=>{const i=this.lastClickedOverlay;i!=null&&i.isDraggable&&i.notifyClick(!1,e)});f(this,"lastPressedKey",{key:"",keyupTime:0,doubleClick:!1});f(this,"defaultWheel",(t,e)=>{this.setScale(e,t.data),this.redrawOnce()});f(this,"lastDownOverlay");f(this,"defaultDown",(t,e)=>{(e==null?void 0:e.button)==0&&(this.mouseIsDown=!0)});f(this,"lastHoverOverlay");f(this,"lastCursorStyle");f(this,"oldClientX",[]);f(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)&&(Mt(c.value)?"Matrix":ie(c.value)?"Single":!1),d=(v,w)=>{if(!u)return i.x+=v*l,i.y+=w*l,!0;const _=this.getAxisValueByPoint(l,0).xV,[C,E]=[_*o.x,_*o.y];if(u==="Single"){const N=c.value;N[0]+=v*C,N[1]+=w*E}else c.value.forEach(N=>{N[0]+=v*C,N[1]+=w*E});return c.value=[...c.value],!0},m=v=>(this.setScale("center",v*n),!0),p={ArrowUp:()=>d(0,-1),ArrowDown:()=>d(0,1),ArrowLeft:()=>d(-1,0),ArrowRight:()=>d(1,0),"+":()=>m(1),"-":()=>m(-1)}[a];p!=null&&p()&&(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{lastDownOverlay:e}=this;if(!this.isDraggable)return;e!=null&&e.isDraggable?this.notifyDraggOverlays(t):this.handleCanvasPan(t);const{clientX:i,clientY:n}=t;this.mouseLastPosition={x:i,y: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:d,clientY:m}=e[1];if(i.length==2){const g=pe(i[0],n[0],i[1],n[1]),p=pe(h,u,d,m),{x:v,y:w}=Pe(h,u,d,m);this.setScale({clientX:v,clientY:w},p>g?a:-a),this.redrawOnce()}this.oldClientX=[h,d],this.oldClientY=[u,m]}}}destroy(){var t;super.destroy(),(t=this.unBind)==null||t.call(this)}}class et extends Ot{constructor(t){super(t);f(this,"overlays",new Set);this.setNotifyReload(t.notifyReload)}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.shouldRender()&&this.overlays.size)&&t()}:void 0,this.overlays.forEach(e=>e.setNotifyReload(this.notifyReload))}addOverlays(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)}removeOverlays(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)}clearOverlays(){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 it extends Ot{constructor(t){super(t);f(this,"zIndex",4);f(this,"canvas",document.createElement("canvas"));f(this,"ctx",this.canvas.getContext("2d"));f(this,"isReload",!1);f(this,"groups",new Map);f(this,"currentDrawOverlays",[]);this.setNotifyReload(t.notifyReload)}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.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 et&&(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 et&&(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))}setzIndex(t){var e;t!=this.zIndex&&(this.zIndex=t,(e=this.notifyReload)==null||e.call(this,!1))}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 Vt extends Ot{constructor(t){super(t);f(this,"layers",new Map);f(this,"defaultContextmenu",(t,e)=>t.stopPropagation());f(this,"defaultClick",(t,e)=>t.stopPropagation());f(this,"defaultDoubleClick",(t,e)=>t.stopPropagation());f(this,"defaultHover",(t,e)=>t.stopPropagation());f(this,"defaultDragg",(t,e)=>t.stopPropagation());f(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)}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.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 it&&(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 it&&(this.layers.delete(n.name),n.setNotifyReload(),n.setMainCanvas(),n.parent=void 0,e=!0)}),e&&((i=this.notifyReload)==null||i.call(this))}clearLayers(){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 fs extends ds{getDefaultOverlayGroup(){var a,l,c,h,u;const s=this.layerGroups.get("默认图层群组");if(!s)return;const t=(a=s.getLayer("点位图层"))==null?void 0:a.getGroup("点位覆盖物群组"),e=(l=s.getLayer("线段图层"))==null?void 0:l.getGroup("线段覆盖物群组"),i=(c=s.getLayer("多边形图层"))==null?void 0:c.getGroup("多边形覆盖物群组"),n=(h=s.getLayer("文字图层"))==null?void 0:h.getGroup("文字覆盖物群组"),o=(u=s.getLayer("自定义绘制图层"))==null?void 0:u.getGroup("自定义绘制覆盖物群组");return{overlays_text:n,overlays_point:t,overlays_line:e,overlays_polygon:i,overlays_custom:o}}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 Vt){if(!i.isVisible)continue;e.push(...i.layers.values())}else if(i instanceof it){if(!i.isVisible)continue;e.push(...i.groups.values())}else if(i instanceof et){if(!i.isVisible)continue;e.push(...i.overlays.values())}else i.isVisible&&t.push(i)}return t}}class ms extends fs{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 ps extends ms{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,d=this.calculateOptimalScale(h,u,e,i),m=this.calculateOffsetDifference(o,a,l,c,e);d==this.scale&&m.x==0&&m.y==0||(t?this.applyTransformImmediately(d,m):this.animateTransform(d,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,d=Math.max(0,h-e[0]-e[2])||h;if(u<=0||d<=0)return console.warn("无效的可视区域尺寸,边距设置可能不合理"),this.scale;const m=s/u,g=t/d,p=Math.max(m,g),v=a.count,w=v/a.min,_=n*o;let C;if(p>w){const E=Math.ceil(p/w);C=1-((v*E/p-a.min)/a.min+(E-2))*_}else{const E=(dt,rt,vt)=>dt<rt?vt-1:E(dt/2,rt,vt+1),N=E(w,p,0),G=Math.pow(2,N);C=1+((v/G/p-a.min)/a.min+N)*_}return i!==void 0&&(C=Math.min(i,C)),C=new R(C).div(o).round().mul(o).toNumber(),C}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,d=this.getAxisPointByValue(h,u),m=this.getAxisValueByPoint((o/2-c.x)*l.x,(a/2-c.y)*l.y),g=this.getAxisPointByValue(m.xV,m.yV);return{x:Math.round(-(d.x+(n[3]-n[1])-g.x)*l.x),y:Math.round(-(d.y+(n[0]-n[2])-g.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;Rt(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){Rt(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 gs extends ps{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 ys extends gs{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 vs extends ys{}class ws{constructor(s){f(this,"canvas");f(this,"axis_canvas",document.createElement("canvas"));f(this,"ctx",this.axis_canvas.getContext("2d"));f(this,"isReload",!0);f(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,grid:i={main:!0,secondary:!0},axis:n=!0,axisText:o=!0}=s;return Object.assign({main:!0,secondary:!0},i),{all:e,grid:i,axis:n,axisText:o}}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,g)=>{const p=i.x%m>0?i.x%m:m+i.x%m;t.strokeStyle=g,t.beginPath();for(let v=0;v*m+p<=o;v++)t.moveTo(v*m+p,0),t.lineTo(v*m+p,a);t.stroke()},d=(m,g)=>{const p=i.y%m>0?i.y%m:m+i.y%m;t.strokeStyle=g,t.beginPath();for(let v=0;v*m+p<=a;v++)t.moveTo(0,v*m+p),t.lineTo(o,v*m+p);t.stroke()};this.show.grid.secondary&&(u(h,l.innerGrid),d(h,l.innerGrid)),this.show.grid.main&&(u(c,l.grid),d(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=p=>Math.ceil(t.measureText(p).width),u=4,d=o[a].text.size;{const p=h("0"),v=i.x<u||i.x>l+p+u,w=i.y<-(u+d)||i.y>c+d+u;!v&&!w&&this.drawText("0",i.x-p-u,i.y+d+u)}const m=s.getNowGridCount,g=n.size;{let p=i.y+d+u;p=Math.max(Math.min(p,c-u),u+d);const v=i.y>c||i.y<0;let w=i.x>0?i.x%g:i.x<0?g+i.x%g:0,_=s.getAxisValueByPoint((w-i.x)*n.x,0).xV;for(;w<=l;){const C=jt(_),E=h(C);_!==0&&this.drawText(C,w-E/2,p,v),w+=g,_=new R(m).mul(n.x).add(_).toNumber()}}{const p=i.x>l||i.x<0;let v=i.y>0?i.y%g:i.y<0?g+i.y%g:0,w=s.getAxisValueByPoint(0,(v-i.y)*n.y).yV;for(;v<=c;){const _=jt(w),C=h(_);let E=i.x-C-u;E=Math.max(Math.min(E,l-C-u),u),w!=0&&this.drawText(_,E,v+d/2,p),v+=g,w=new R(m).mul(n.y).add(w).toNumber()}}}}function Ht(r){return[r].flat(1/0)}class Y extends vs{constructor(s){super(s),this.drawAxis=new ws(this),"axisShow"in s&&this.toggleAxis(s.axisShow),this.initLayerGroups(),this.updateCenter()}initLayerGroups(){const s=new it({name:"多边形图层"});s.addGroup(new et({name:"多边形覆盖物群组"})),s.setzIndex(1);const t=new it({name:"线段图层"});t.addGroup(new et({name:"线段覆盖物群组"})),t.setzIndex(2);const e=new it({name:"点位图层"});e.addGroup(new et({name:"点位覆盖物群组"})),e.setzIndex(3);const i=new it({name:"文字图层"});i.addGroup(new et({name:"文字覆盖物群组"})),i.setzIndex(4);const n=new it({name:"自定义绘制图层"});n.addGroup(new et({name:"自定义绘制覆盖物群组"})),n.setzIndex(5);const o=new Vt({name:"默认图层群组"});o.addLayer([i,e,t,s,n]),this.setLayerGroup(o)}gteLayerGroups(s="默认图层群组"){return this.layerGroups.get(s)}setLayerGroup(s){s instanceof Vt&&(this.layerGroups.set(s.name,s),s.setNotifyReload(()=>this.redrawOnce()),s.setMainCanvas(this),s.parent=this)}removeLayerGroup(s){s instanceof Vt&&(this.layerGroups.delete(s.name),s.setNotifyReload(),s.setMainCanvas(),s.parent=void 0,this.redrawOnce())}addLayer(s){const t=this.layerGroups.get("默认图层群组");t&&t.addLayer(Ht(s))}removeLayer(s){const t=this.layerGroups.get("默认图层群组");t&&t.removeLayer(Ht(s))}addOverlay(s){const{overlays_text:t,overlays_point:e,overlays_line:i,overlays_polygon:n,overlays_custom:o}=this.getDefaultOverlayGroup()||{};Ht(s).forEach(a=>{a instanceof Gt?t==null||t.addOverlays(a):a instanceof lt?e==null||e.addOverlays(a):a instanceof Xt||a instanceof de||a instanceof fe?i==null||i.addOverlays(a):a instanceof Yt?n==null||n.addOverlays(a):a instanceof Ut&&(o==null||o.addOverlays(a))})}removeOverlay(s){const{overlays_text:t,overlays_point:e,overlays_line:i,overlays_polygon:n,overlays_custom:o}=this.getDefaultOverlayGroup()||{};Ht(s).forEach(a=>{a instanceof Gt?t==null||t.removeOverlays(a):a instanceof lt?e==null||e.removeOverlays(a):a instanceof Xt?i==null||i.removeOverlays(a):a instanceof Yt?n==null||n.removeOverlays(a):a instanceof Ut&&(o==null||o.addOverlays(a))})}destroy(){super.destroy()}}f(Y,"LayerGroup",Vt),f(Y,"Layer",it),f(Y,"OverlayGroup",et),f(Y,"Text",Gt),f(Y,"Point",lt),f(Y,"Line",Xt),f(Y,"Polygon",Yt),f(Y,"Custom",Ut),f(Y,"Arc",de),f(Y,"ArcTo",fe);function Ps(r){return r.charAt(0).toUpperCase()+r.slice(1)}function xs(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 jt(r){const t=r.toString().split("."),e=t[0].replace(/\B(?=(\d{3})+(?!\d))/g,",");return t.length>1?e+"."+t[1]:e}function bs(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,d=(l?1:-1)*parseFloat(u.toFixed(Math.max(0,n)));return e?`${d}${oe[c]}${i}`:[d,oe[c]+i]}function _s(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 Cs(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 $t(r,s="file"){if(!r||(r=String(r).trim(),r===""))return s;const t=r.split("/");return t[t.length-1].split("?")[0]}function Ss(r,s){return r=r.replace(/([^a-zA-Z][a-z])/g,t=>t.toUpperCase()),s?r.replace(/[^a-zA-Z]+/g,""):r}function Es(r,s,t=","){const e=new RegExp(`(^|${t})${s}(${t}|$)`,"g");return r.replace(e,function(i,n,o){return n===o?t:""})}function Ds(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 Tt=[["年",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 Vs(r,s){if(!Number.isInteger(r)||r<0)return"0毫秒";const t=s?Tt.findIndex(([i])=>i===s):0,e=t===-1?0:t;for(let i=e;i<Tt.length;i++){const[n,o]=Tt[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===Tt[e][0]&&(l=jt(Number(l))),`${l}${n}`}}return"0毫秒"}function Rs(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 ie(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 Mt(r,s=1,t=2){if(Array.isArray(r)&&r.length>=s){for(let i=0;i<r.length;i++)if(!ie(r[i],t))return!1}else return!1;return!0}function ks(r,s,t){return Math.abs(r-s)<=t}function Ms(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 Os(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[p,v]=t;return p>=i&&p<=n&&v>=o&&v<=a}const d=1e-10;let m=!1,g=!1;for(const[p,v]of l){const w=c*p+h*v+u;if(Math.abs(w)<d||(w>d?m=!0:g=!0,m&&g))return!0}return m&&g}function Zt(r){return Object.prototype.toString.call(r).slice(8,-1).toLowerCase()}function Ns(r){return["https:","wss:","ftps:","sftp:","smpts:","smtp+tls:","imap+tls:","pop3+tls:","rdp:","vpn:"].some(t=>r.startsWith(t))}function As(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 tt=class tt{constructor(){if(new.target===tt)throw new Error("请直接使用静态方法,而不是实例化此类")}static check(s,t){if(!s||typeof s!="string")return console.error("Invalid URL provided"),t?!1:"unknown";const e=$t(s).toLowerCase();if(t){if(!Lt.hasOwnProperty(t))return console.error(`Unknown file type: ${t}`),"unknown";const i=Lt[t];return tt._checkExtension(e,i)}return tt._detectFileType(e)}static parseAddresses(s){return!s||typeof s!="string"?(console.error("Invalid URL provided"),[]):s.split(",").map(t=>{const e=$t(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=tt._normalizeType(s),i=t.split(",").map(a=>tt._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("/")?De[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 tt.cachedEntries)if(e.some(i=>s.endsWith(i)))return t;return"unknown"}};f(tt,"cachedEntries",Object.entries(Lt));let me=tt;const Is=/\w*(?:\[\d+\])+|\w+/g,Ue=/^\w*(?:\[\d+\])+$/,Ge=/\w+|(\[\d+\])/g,Xe=/\[(\d+)\]/;function Ye(r){return r?r.match(Is)||[]:[]}function Hs(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()};t?t(e,{timeout:s}):requestAnimationFrame(()=>r())}function Ts(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 ht(r,s,t=[],e=Date.now()){if(e<Date.now()-50){console.error("_MergeObjects 合并异常:疑似死循环");return}const i=Zt(r),n=Zt(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=ht(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=ht(c,l,t,e);r[a]=h}),r}else return s}function ze(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 ve(r,s){let t;return function(...e){clearTimeout(t),t=setTimeout(()=>{r(...e),t=void 0},s)}}function Ls(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 Fs(r,s){if(!r||!s)return r;const t=Ye(s);return t.length?t.reduce((e,i,n)=>{const o=n===t.length-1;if(Ue.test(i)){const a=i.match(Ge)||[];return a.reduce((l,c,h)=>{if(/^\w+$/.test(c))return l[c]||(h<a.length-1?[]:{});const u=c.match(Xe),d=u?parseInt(u[1],10):0,m=h===a.length-1;return m&&o?l[d]:l[d]||(m?{}:[])},e)}return o?e[i]:e[i]||{}},r):r}function Bs(r,s,t,e){if(!r||!s)return t;const i=Ye(s);return i.length?i.reduce((n,o,a)=>{const l=a===i.length-1;if(Ue.test(o)){const c=o.match(Ge)||[];return c.reduce((h,u,d)=>{const m=d===c.length-1;if(/^\w+$/.test(u))return h.hasOwnProperty(u)||(h[u]=[]),h[u];const g=u.match(Xe),p=g?parseInt(g[1],10):0,v=m&&l;return h.hasOwnProperty(p)?v&&!e&&(h[p]=t):h[p]=v?t:m?{}:[],h[p]},n)}return l?((!e||!n.hasOwnProperty(o))&&(n[o]=t),n[o]):(n.hasOwnProperty(o)||(n[o]={}),n[o])},r):t}function Us(r){return r.map((s,t)=>r.slice(t).concat(r.slice(0,t)))}function We(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(Zt(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.error("structuredClone error:",e),s&&t(r)}}function qe(r,s,t=30){if(typeof r!="function")return console.error("第一个参数必须是一个函数。");if(!Array.isArray(s))return console.error("第二个参数必须是一个数组。");let e=[],i=0;const n=(o,a)=>{for(const[l,c]of a)if(o>=l)return c;return"black"};return function(...o){const a=performance.now(),l=r(...o),c=performance.now()-a;e.push(c),e.length>t&&e.shift(),i=e.reduce((d,m)=>d+m,0)/e.length||0;const h=n(c,s),u=n(i,s);return console.log(`%c单次耗时:${c.toFixed(2)}ms
|
|
9
|
-
%c平均耗时(${e.length}次):${i.toFixed(2)}ms`,`color: ${h}; padding: 2px 0;`,`color: ${u}; padding: 2px 0;`),l}}function Gs(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}function Xs(r){const s=ve(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 d(){if(t==o)return;const g=t>o;if(t=o,g)return;a-o-l<=1&&s("vertical")}function m(){if(e==c)return;const g=e>c;if(e=c,g)return;h-c-u<=1&&s("horizontal")}d(),m()}}function Ys(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 z,ft,mt,Pt,xt,Z,J,st,bt;class zs{constructor(){A(this,z);A(this,ft,!1);A(this,mt,{});A(this,Pt,0);A(this,xt,0);A(this,Z,0);A(this,J,0);A(this,st);A(this,bt)}init(s,t){D(this,z,s),D(this,st,t==null?void 0:t.limit),D(this,bt,t==null?void 0:t.dragDom),D(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(!P(this,z))return console.error("No DOM");P(this,z)[t]("mousedown",P(this,mt).mousedown),document[t]("mousemove",P(this,mt).mousemove),document[t]("mouseup",P(this,mt).mouseup)}alterLocation(){if(!P(this,z))return console.error("No DOM");P(this,st)&&(D(this,Z,Math.min(P(this,Z),P(this,st).max.top)),D(this,Z,Math.max(P(this,Z),P(this,st).min.top)),D(this,J,Math.min(P(this,J),P(this,st).max.left)),D(this,J,Math.max(P(this,J),P(this,st).min.left))),P(this,z).style.setProperty("--top",P(this,Z)+"px"),P(this,z).style.setProperty("--left",P(this,J)+"px")}mousedown(s){if(!P(this,z))return console.error("No DOM");if(P(this,bt)&&s.target!=P(this,bt))return;document.body.classList.add("no-select"),D(this,ft,!0);const t=P(this,z).getBoundingClientRect(),{pageX:e,pageY:i}=s;D(this,Pt,e),D(this,xt,i),D(this,Z,t.y),D(this,J,t.x)}mousemove(s){const{pageX:t,pageY:e}=s;P(this,ft)&&(D(this,Z,P(this,Z)+(e-P(this,xt))),D(this,J,P(this,J)+(t-P(this,Pt))),D(this,Pt,t),D(this,xt,e),this.alterLocation())}mouseup(){P(this,ft)&&(D(this,ft,!1),document.body.classList.remove("no-select"))}}z=new WeakMap,ft=new WeakMap,mt=new WeakMap,Pt=new WeakMap,xt=new WeakMap,Z=new WeakMap,J=new WeakMap,st=new WeakMap,bt=new WeakMap;var W,pt,gt,_t,Ct,q,j,B,St,Et;class Ws{constructor(){A(this,W);A(this,pt,!1);A(this,gt,{});A(this,_t,0);A(this,Ct,0);A(this,q,0);A(this,j,0);A(this,B);A(this,St);A(this,Et)}init(s,t={}){D(this,W,s),D(this,B,t.limit),D(this,St,t.update_move),D(this,Et,t.update_up),D(this,gt,{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(!P(this,W))return console.error("No DOM");P(this,W)[t]("mousedown",P(this,gt).mousedown),document[t]("mousemove",P(this,gt).mousemove),document[t]("mouseup",P(this,gt).mouseup)}updateValue(){const s={top:P(this,q),left:P(this,j),percentage:{top:0,left:0}};if(P(this,B)){const t=e=>P(this,B)?(s[e]-P(this,B).min[e])/(P(this,B).max[e]-P(this,B).min[e]):0;s.percentage={top:t("top")||0,left:t("left")||0}}return s}alterLocation(){if(!P(this,W))return console.error("No DOM");P(this,B)&&(D(this,q,Math.min(P(this,q),P(this,B).max.top)),D(this,q,Math.max(P(this,q),P(this,B).min.top)),D(this,j,Math.min(P(this,j),P(this,B).max.left)),D(this,j,Math.max(P(this,j),P(this,B).min.left))),P(this,St)&&P(this,St).call(this,this.updateValue()),P(this,W).style.setProperty("--top",P(this,q)+"px"),P(this,W).style.setProperty("--left",P(this,j)+"px")}mousedown(s){if(!P(this,W))return console.error("No DOM");document.body.classList.add("no-select"),D(this,pt,!0);const t=P(this,W).getBoundingClientRect();D(this,Ct,t.y),D(this,_t,t.x);const{pageX:e,pageY:i}=s;D(this,q,i-P(this,Ct)),D(this,j,e-P(this,_t)),this.alterLocation()}mousemove(s){const{pageX:t,pageY:e}=s;P(this,pt)&&(D(this,q,e-P(this,Ct)),D(this,j,t-P(this,_t)),this.alterLocation())}mouseup(){P(this,pt)&&(D(this,pt,!1),document.body.classList.remove("no-select"),P(this,Et)&&P(this,Et).call(this,this.updateValue()))}}W=new WeakMap,pt=new WeakMap,gt=new WeakMap,_t=new WeakMap,Ct=new WeakMap,q=new WeakMap,j=new WeakMap,B=new WeakMap,St=new WeakMap,Et=new WeakMap;function se(r){if(typeof r=="string"){const s=document.querySelector(r);if(!s)throw new Error(`Element "${r}" not found`);return s}else return r||document.documentElement}function je(r){const s=se(r);return s.requestFullscreen?s.requestFullscreen():s.mozRequestFullScreen?s.mozRequestFullScreen():s.webkitRequestFullscreen?s.webkitRequestFullscreen():s.msRequestFullscreen?s.msRequestFullscreen():Promise.reject("No Fullscreen API")}function $e(){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 we(r){const s=se(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 qs(r){return r=se(r),function(){we(r)?$e():je(r)}}function js(r,s){const t=se(s),e=()=>{r(we(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)}}function $s(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 Zs(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 Js(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 Ks(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 Qs(r){return new Promise((s,t)=>{fetch(r).then(e=>s(e.text())).catch(e=>{console.error("Error fetching :",e),t(e)})})}function Ze(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||$t(s,"downloaded_file");c=decodeURIComponent(h);const u=()=>{if(!l)return;const p=URL.createObjectURL(l),v=document.createElement("a");v.href=p,v.download=c,v.click(),URL.revokeObjectURL(p)};return{promise:new Promise((p,v)=>{try{o=new XMLHttpRequest,o.open("GET",s),o.responseType="blob",o.timeout=i,o.ontimeout=()=>{a||v(new Error(`请求超时(已超过${i/1e3}秒)`))},o.addEventListener("progress",w=>{if(w.lengthComputable&&!a){const _=w.loaded/w.total*100;e==null||e(Number(_.toFixed(2)))}}),o.addEventListener("load",()=>{a||(o.status>=200&&o.status<300?(l=o.response,n&&u(),p(o.response)):v(new Error(`下载失败,状态码: ${o.status}`)))}),o.addEventListener("error",()=>{a||v(new Error("网络错误,下载失败"))}),o.addEventListener("abort",()=>{a||(a=!0,v(new Error("下载已被中止")))}),o.send()}catch(w){a||v(w)}}),abort:()=>!a&&o.abort(),download:()=>{!a&&l&&u()}}}function tn(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);Ze({href:i,fileName:s})}const en=Math.PI/2,Jt=Math.PI/180,Kt=6378137,sn=85.05112878;function nn(r,s){const t=Math.max(Math.min(r,180),-180),e=Math.max(Math.min(s,sn),-85.05112878),i=t*Jt*Kt,n=e*Jt,o=Math.log(Math.tan(Math.PI/4+n/2))*Kt;return[i,o]}function rn(r,s){const t=r/Kt/Jt,e=(2*Math.atan(Math.exp(s/Kt))-en)/Jt;return[t,e]}function Je(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 on(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 pe(r,s,t,e){return Math.hypot(Math.abs(t-r),Math.abs(e-s))}function Pe(r,s,t,e){const i=(r+t)/2,n=(s+e)/2;return{x:i,y:n}}function an(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 ln=new Set(["sin","cos","tan","asin","acos","atan","atan2"]),cn=new Proxy(Math,{get(r,s){return ln.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 wt{constructor(s,t){f(this,"resolve");f(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 hn extends wt{constructor(s){super(),this.resolve=s}warning(...s){const t=()=>{var e,i;return(i=(e=yt.tips).warning)==null?void 0:i.call(e,...s)};return new wt(this.resolve,t)}error(...s){const t=()=>{var e,i;return(i=(e=yt.tips).error)==null?void 0:i.call(e,...s)};return new wt(this.resolve,t)}}class un extends wt{constructor(s){super(),this.reject=s}info(...s){const t=()=>{var e,i;return(i=(e=yt.tips).info)==null?void 0:i.call(e,...s)};return new wt(t,this.reject)}success(...s){const t=()=>{var e,i;return(i=(e=yt.tips).success)==null?void 0:i.call(e,...s)};return new wt(t,this.reject)}}const F=class F{constructor(){if(new.target===F)throw new Error("请直接使用静态方法,而不是实例化此类")}static register(s,t){if(typeof t!="function")return console.error("TipHandler must be a function");F.tips[s]=t}static resolveTip(s){return function(...t){const e=()=>{var i,n;return(n=(i=F.tips)[s])==null?void 0:n.call(i,...t)};return new hn(e)}}static rejectTip(s){return function(...t){const e=()=>{var i,n;return(n=(i=F.tips)[s])==null?void 0:n.call(i,...t)};return new un(e)}}};f(F,"tips",{info:void 0,success:void 0,warning:void 0,error:void 0}),f(F,"info",F.resolveTip("info")),f(F,"success",F.resolveTip("success")),f(F,"warning",F.rejectTip("warning")),f(F,"error",F.rejectTip("error"));let yt=F;exports.EXTENSION_TO_MIME=De;exports.FILE_EXTENSIONS=Lt;exports.PAPER_SIZE_DEFINITIONS=ge;exports.PAPER_SIZE_OPTIONS=ei;exports.UNIT_LABELS=oe;exports.WINDOW_TARGET=ti;exports._Animate_CreateOscillator=ii;exports._Animate_NumericTransition=si;exports._Animate_Schedule=Rt;exports._Blob_ConvertDataToImageUrl=ni;exports._Browser_CalculatePrintableArea=ai;exports._Browser_CopyToClipboard=oi;exports._Browser_GetFrameRate=ri;exports._Browser_KeyedWindowManager=Ve;exports._Canvas=Y;exports._Element_CalculateCanvasSize=Zs;exports._Element_CheckImagesLoaded=Ks;exports._Element_CloseOnOutsideClick=Ys;exports._Element_Drag=zs;exports._Element_EnterFullscreen=je;exports._Element_ExitFullscreen=$e;exports._Element_Fullscreen=qs;exports._Element_FullscreenObserver=js;exports._Element_GetOtherSizeInPixels=$s;exports._Element_IsFullscreen=we;exports._Element_LoadImage=Js;exports._Element_LocalDrag=Ws;exports._Element_ScrollEndListener=Xs;exports._File_CreateAndDownload=tn;exports._File_Download=Ze;exports._File_Read=Qs;exports._Format_CamelCase=Ss;exports._Format_CapitalizeFirstLetter=Ps;exports._Format_ChunkArray=Rs;exports._Format_ExcludeSubstring=Es;exports._Format_FileSize=_s;exports._Format_HrefName=$t;exports._Format_MillisecondToReadable=Vs;exports._Format_NumberWithCommas=jt;exports._Format_NumberWithUnit=bs;exports._Format_Percentage=xs;exports._Format_Timestamp=Cs;exports._Format_ToggleInvisibleChars=Ds;exports._Math_CalculateDistance2D=pe;exports._Math_Degree=cn;exports._Math_GetArcPoints=on;exports._Math_GetBoundaryIntersection=an;exports._Math_GetMidpoint=Pe;exports._Math_LngLatToPlane=nn;exports._Math_PlaneToLngLat=rn;exports._Math_PointToLineDistance=Je;exports._Tip=yt;exports._Utility_Clone=We;exports._Utility_Debounce=ve;exports._Utility_ExecuteWhenIdle=Hs;exports._Utility_GenerateUUID=ze;exports._Utility_GetTargetByPath=Fs;exports._Utility_MergeObjects=ht;exports._Utility_RotateList=Us;exports._Utility_SetTargetByPath=Bs;exports._Utility_Sleep=Gs;exports._Utility_Throttle=Ls;exports._Utility_TimeConsumption=qe;exports._Utility_WaitForCondition=Ts;exports._Valid_CheckConnectionWithXHR=As;exports._Valid_DataType=Zt;exports._Valid_DoesInfiniteLineIntersectRectangle=Os;exports._Valid_FileTypeChecker=me;exports._Valid_Is2DNumberArray=Mt;exports._Valid_IsInMargin=ks;exports._Valid_IsNumberArray=ie;exports._Valid_IsPointInPolygon=Ms;exports._Valid_IsSecureContext=Ns;
|
|
9
|
+
*/var he=9e15,ut=1e9,ue="0123456789abcdef",Zt="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Qt="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",de={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-9e15,maxE:he,crypto:!1},Le,nt,S=!0,ie="[DecimalError] ",ht=ie+"Invalid argument: ",Te=ie+"Precision limit exceeded",Fe=ie+"crypto unavailable",Be="[object Decimal]",T=Math.floor,I=Math.pow,Mi=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Oi=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Ni=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Ue=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,$=1e7,b=7,Ai=9007199254740991,Ii=Zt.length-1,fe=Qt.length-1,y={toStringTag:Be};y.absoluteValue=y.abs=function(){var r=new this.constructor(this);return r.s<0&&(r.s=1),x(r)};y.ceil=function(){return x(new this.constructor(this),this.e+1,2)};y.clampedTo=y.clamp=function(r,n){var t,e=this,i=e.constructor;if(r=new i(r),n=new i(n),!r.s||!n.s)return new i(NaN);if(r.gt(n))throw Error(ht+n);return t=e.cmp(r),t<0?r:e.cmp(n)>0?n:new i(e)};y.comparedTo=y.cmp=function(r){var n,t,e,i,s=this,o=s.d,a=(r=new s.constructor(r)).d,l=s.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(s.e!==r.e)return s.e>r.e^l<0?1:-1;for(e=o.length,i=a.length,n=0,t=e<i?e:i;n<t;++n)if(o[n]!==a[n])return o[n]>a[n]^l<0?1:-1;return e===i?0:e>i^l<0?1:-1};y.cosine=y.cos=function(){var r,n,t=this,e=t.constructor;return t.d?t.d[0]?(r=e.precision,n=e.rounding,e.precision=r+Math.max(t.e,t.sd())+b,e.rounding=1,t=Hi(e,We(e,t)),e.precision=r,e.rounding=n,x(nt==2||nt==3?t.neg():t,r,n,!0)):new e(1):new e(NaN)};y.cubeRoot=y.cbrt=function(){var r,n,t,e,i,s,o,a,l,c,h=this,u=h.constructor;if(!h.isFinite()||h.isZero())return new u(h);for(S=!1,s=h.s*I(h.s*h,1/3),!s||Math.abs(s)==1/0?(t=H(h.d),r=h.e,(s=(r-t.length+1)%3)&&(t+=s==1||s==-2?"0":"00"),s=I(t,1/3),r=T((r+1)/3)-(r%3==(r<0?-1:2)),s==1/0?t="5e"+r:(t=s.toExponential(),t=t.slice(0,t.indexOf("e")+1)+r),e=new u(t),e.s=h.s):e=new u(s.toString()),o=(r=u.precision)+3;;)if(a=e,l=a.times(a).times(a),c=l.plus(h),e=k(c.plus(h).times(a),c.plus(l),o+2,1),H(a.d).slice(0,o)===(t=H(e.d)).slice(0,o))if(t=t.slice(o-3,o+1),t=="9999"||!i&&t=="4999"){if(!i&&(x(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")&&(x(e,r+1,1),n=!e.times(e).times(e).eq(h));break}return S=!0,x(e,r,u.rounding,n)};y.decimalPlaces=y.dp=function(){var r,n=this.d,t=NaN;if(n){if(r=n.length-1,t=(r-T(this.e/b))*b,r=n[r],r)for(;r%10==0;r/=10)t--;t<0&&(t=0)}return t};y.dividedBy=y.div=function(r){return k(this,new this.constructor(r))};y.dividedToIntegerBy=y.divToInt=function(r){var n=this,t=n.constructor;return x(k(n,new t(r),0,1,1),t.precision,t.rounding)};y.equals=y.eq=function(r){return this.cmp(r)===0};y.floor=function(){return x(new this.constructor(this),this.e+1,3)};y.greaterThan=y.gt=function(r){return this.cmp(r)>0};y.greaterThanOrEqualTo=y.gte=function(r){var n=this.cmp(r);return n==1||n===0};y.hyperbolicCosine=y.cosh=function(){var r,n,t,e,i,s=this,o=s.constructor,a=new o(1);if(!s.isFinite())return new o(s.s?1/0:NaN);if(s.isZero())return a;t=o.precision,e=o.rounding,o.precision=t+Math.max(s.e,s.sd())+4,o.rounding=1,i=s.d.length,i<32?(r=Math.ceil(i/3),n=(1/ne(4,r)).toString()):(r=16,n="2.3283064365386962890625e-10"),s=Dt(o,1,s.times(n),new o(1),!0);for(var l,c=r,h=new o(8);c--;)l=s.times(s),s=a.minus(l.times(h.minus(l.times(h))));return x(s,o.precision=t,o.rounding=e,!0)};y.hyperbolicSine=y.sinh=function(){var r,n,t,e,i=this,s=i.constructor;if(!i.isFinite()||i.isZero())return new s(i);if(n=s.precision,t=s.rounding,s.precision=n+Math.max(i.e,i.sd())+4,s.rounding=1,e=i.d.length,e<3)i=Dt(s,2,i,i,!0);else{r=1.4*Math.sqrt(e),r=r>16?16:r|0,i=i.times(1/ne(5,r)),i=Dt(s,2,i,i,!0);for(var o,a=new s(5),l=new s(16),c=new s(20);r--;)o=i.times(i),i=i.times(a.plus(o.times(l.times(o).plus(c))))}return s.precision=n,s.rounding=t,x(i,n,t,!0)};y.hyperbolicTangent=y.tanh=function(){var r,n,t=this,e=t.constructor;return t.isFinite()?t.isZero()?new e(t):(r=e.precision,n=e.rounding,e.precision=r+7,e.rounding=1,k(t.sinh(),t.cosh(),e.precision=r,e.rounding=n)):new e(t.s)};y.inverseCosine=y.acos=function(){var r=this,n=r.constructor,t=r.abs().cmp(1),e=n.precision,i=n.rounding;return t!==-1?t===0?r.isNeg()?J(n,e,i):new n(0):new n(NaN):r.isZero()?J(n,e+4,i).times(.5):(n.precision=e+6,n.rounding=1,r=new n(1).minus(r).div(r.plus(1)).sqrt().atan(),n.precision=e,n.rounding=i,r.times(2))};y.inverseHyperbolicCosine=y.acosh=function(){var r,n,t=this,e=t.constructor;return t.lte(1)?new e(t.eq(1)?0:NaN):t.isFinite()?(r=e.precision,n=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=n,t.ln()):new e(t)};y.inverseHyperbolicSine=y.asinh=function(){var r,n,t=this,e=t.constructor;return!t.isFinite()||t.isZero()?new e(t):(r=e.precision,n=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=n,t.ln())};y.inverseHyperbolicTangent=y.atanh=function(){var r,n,t,e,i=this,s=i.constructor;return i.isFinite()?i.e>=0?new s(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(r=s.precision,n=s.rounding,e=i.sd(),Math.max(e,r)<2*-i.e-1?x(new s(i),r,n,!0):(s.precision=t=e-i.e,i=k(i.plus(1),new s(1).minus(i),t+r,1),s.precision=r+4,s.rounding=1,i=i.ln(),s.precision=r,s.rounding=n,i.times(.5))):new s(NaN)};y.inverseSine=y.asin=function(){var r,n,t,e,i=this,s=i.constructor;return i.isZero()?new s(i):(n=i.abs().cmp(1),t=s.precision,e=s.rounding,n!==-1?n===0?(r=J(s,t+4,e).times(.5),r.s=i.s,r):new s(NaN):(s.precision=t+6,s.rounding=1,i=i.div(new s(1).minus(i.times(i)).sqrt().plus(1)).atan(),s.precision=t,s.rounding=e,i.times(2)))};y.inverseTangent=y.atan=function(){var r,n,t,e,i,s,o,a,l,c=this,h=c.constructor,u=h.precision,d=h.rounding;if(c.isFinite()){if(c.isZero())return new h(c);if(c.abs().eq(1)&&u+4<=fe)return o=J(h,u+4,d).times(.25),o.s=c.s,o}else{if(!c.s)return new h(NaN);if(u+4<=fe)return o=J(h,u+4,d).times(.5),o.s=c.s,o}for(h.precision=a=u+10,h.rounding=1,t=Math.min(28,a/b+2|0),r=t;r;--r)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(S=!1,n=Math.ceil(a/b),e=1,l=c.times(c),o=new h(c),i=c;r!==-1;)if(i=i.times(l),s=o.minus(i.div(e+=2)),i=i.times(l),o=s.plus(i.div(e+=2)),o.d[n]!==void 0)for(r=n;o.d[r]===s.d[r]&&r--;);return t&&(o=o.times(2<<t-1)),S=!0,x(o,h.precision=u,h.rounding=d,!0)};y.isFinite=function(){return!!this.d};y.isInteger=y.isInt=function(){return!!this.d&&T(this.e/b)>this.d.length-2};y.isNaN=function(){return!this.s};y.isNegative=y.isNeg=function(){return this.s<0};y.isPositive=y.isPos=function(){return this.s>0};y.isZero=function(){return!!this.d&&this.d[0]===0};y.lessThan=y.lt=function(r){return this.cmp(r)<0};y.lessThanOrEqualTo=y.lte=function(r){return this.cmp(r)<1};y.logarithm=y.log=function(r){var n,t,e,i,s,o,a,l,c=this,h=c.constructor,u=h.precision,d=h.rounding,m=5;if(r==null)r=new h(10),n=!0;else{if(r=new h(r),t=r.d,r.s<0||!t||!t[0]||r.eq(1))return new h(NaN);n=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(n)if(t.length>1)s=!0;else{for(i=t[0];i%10===0;)i/=10;s=i!==1}if(S=!1,a=u+m,o=at(c,a),e=n?Jt(h,a+10):at(r,a),l=k(o,e,a,1),Ot(l.d,i=u,d))do if(a+=10,o=at(c,a),e=n?Jt(h,a+10):at(r,a),l=k(o,e,a,1),!s){+H(l.d).slice(i+1,i+15)+1==1e14&&(l=x(l,u+1,0));break}while(Ot(l.d,i+=10,d));return S=!0,x(l,u,d)};y.minus=y.sub=function(r){var n,t,e,i,s,o,a,l,c,h,u,d,m=this,g=m.constructor;if(r=new g(r),!m.d||!r.d)return!m.s||!r.s?r=new g(NaN):m.d?r.s=-r.s:r=new g(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,d=r.d,a=g.precision,l=g.rounding,!c[0]||!d[0]){if(d[0])r.s=-r.s;else if(c[0])r=new g(m);else return new g(l===3?-0:0);return S?x(r,a,l):r}if(t=T(r.e/b),h=T(m.e/b),c=c.slice(),s=h-t,s){for(u=s<0,u?(n=c,s=-s,o=d.length):(n=d,t=h,o=c.length),e=Math.max(Math.ceil(a/b),o)+2,s>e&&(s=e,n.length=1),n.reverse(),e=s;e--;)n.push(0);n.reverse()}else{for(e=c.length,o=d.length,u=e<o,u&&(o=e),e=0;e<o;e++)if(c[e]!=d[e]){u=c[e]<d[e];break}s=0}for(u&&(n=c,c=d,d=n,r.s=-r.s),o=c.length,e=d.length-o;e>0;--e)c[o++]=0;for(e=d.length;e>s;){if(c[--e]<d[e]){for(i=e;i&&c[--i]===0;)c[i]=$-1;--c[i],c[e]+=$}c[e]-=d[e]}for(;c[--o]===0;)c.pop();for(;c[0]===0;c.shift())--t;return c[0]?(r.d=c,r.e=se(c,t),S?x(r,a,l):r):new g(l===3?-0:0)};y.modulo=y.mod=function(r){var n,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]?x(new e(t),e.precision,e.rounding):(S=!1,e.modulo==9?(n=k(t,r.abs(),0,3,1),n.s*=r.s):n=k(t,r,0,e.modulo,1),n=n.times(r),S=!0,t.minus(n))};y.naturalExponential=y.exp=function(){return me(this)};y.naturalLogarithm=y.ln=function(){return at(this)};y.negated=y.neg=function(){var r=new this.constructor(this);return r.s=-r.s,x(r)};y.plus=y.add=function(r){var n,t,e,i,s,o,a,l,c,h,u=this,d=u.constructor;if(r=new d(r),!u.d||!r.d)return!u.s||!r.s?r=new d(NaN):u.d||(r=new d(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=d.precision,l=d.rounding,!c[0]||!h[0])return h[0]||(r=new d(u)),S?x(r,a,l):r;if(s=T(u.e/b),e=T(r.e/b),c=c.slice(),i=s-e,i){for(i<0?(t=c,i=-i,o=h.length):(t=h,e=s,o=c.length),s=Math.ceil(a/b),o=s>o?s+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),n=0;i;)n=(c[--i]=c[i]+h[i]+n)/$|0,c[i]%=$;for(n&&(c.unshift(n),++e),o=c.length;c[--o]==0;)c.pop();return r.d=c,r.e=se(c,e),S?x(r,a,l):r};y.precision=y.sd=function(r){var n,t=this;if(r!==void 0&&r!==!!r&&r!==1&&r!==0)throw Error(ht+r);return t.d?(n=Ge(t.d),r&&t.e+1>n&&(n=t.e+1)):n=NaN,n};y.round=function(){var r=this,n=r.constructor;return x(new n(r),r.e+1,n.rounding)};y.sine=y.sin=function(){var r,n,t=this,e=t.constructor;return t.isFinite()?t.isZero()?new e(t):(r=e.precision,n=e.rounding,e.precision=r+Math.max(t.e,t.sd())+b,e.rounding=1,t=Ti(e,We(e,t)),e.precision=r,e.rounding=n,x(nt>2?t.neg():t,r,n,!0)):new e(NaN)};y.squareRoot=y.sqrt=function(){var r,n,t,e,i,s,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?(n=H(a),(n.length+l)%2==0&&(n+="0"),c=Math.sqrt(n),l=T((l+1)/2)-(l<0||l%2),c==1/0?n="5e"+l:(n=c.toExponential(),n=n.slice(0,n.indexOf("e")+1)+l),e=new h(n)):e=new h(c.toString()),t=(l=h.precision)+3;;)if(s=e,e=s.plus(k(o,s,t+2,1)).times(.5),H(s.d).slice(0,t)===(n=H(e.d)).slice(0,t))if(n=n.slice(t-3,t+1),n=="9999"||!i&&n=="4999"){if(!i&&(x(s,l+1,0),s.times(s).eq(o))){e=s;break}t+=4,i=1}else{(!+n||!+n.slice(1)&&n.charAt(0)=="5")&&(x(e,l+1,1),r=!e.times(e).eq(o));break}return S=!0,x(e,l,h.rounding,r)};y.tangent=y.tan=function(){var r,n,t=this,e=t.constructor;return t.isFinite()?t.isZero()?new e(t):(r=e.precision,n=e.rounding,e.precision=r+10,e.rounding=1,t=t.sin(),t.s=1,t=k(t,new e(1).minus(t.times(t)).sqrt(),r+10,0),e.precision=r,e.rounding=n,x(nt==2||nt==4?t.neg():t,r,n,!0)):new e(NaN)};y.times=y.mul=function(r){var n,t,e,i,s,o,a,l,c,h=this,u=h.constructor,d=h.d,m=(r=new u(r)).d;if(r.s*=h.s,!d||!d[0]||!m||!m[0])return new u(!r.s||d&&!d[0]&&!m||m&&!m[0]&&!d?NaN:!d||!m?r.s/0:r.s*0);for(t=T(h.e/b)+T(r.e/b),l=d.length,c=m.length,l<c&&(s=d,d=m,m=s,o=l,l=c,c=o),s=[],o=l+c,e=o;e--;)s.push(0);for(e=c;--e>=0;){for(n=0,i=l+e;i>e;)a=s[i]+m[e]*d[i-e-1]+n,s[i--]=a%$|0,n=a/$|0;s[i]=(s[i]+n)%$|0}for(;!s[--o];)s.pop();return n?++t:s.shift(),r.d=s,r.e=se(s,t),S?x(r,u.precision,u.rounding):r};y.toBinary=function(r,n){return Pe(this,2,r,n)};y.toDecimalPlaces=y.toDP=function(r,n){var t=this,e=t.constructor;return t=new e(t),r===void 0?t:(U(r,0,ut),n===void 0?n=e.rounding:U(n,0,8),x(t,r+t.e+1,n))};y.toExponential=function(r,n){var t,e=this,i=e.constructor;return r===void 0?t=K(e,!0):(U(r,0,ut),n===void 0?n=i.rounding:U(n,0,8),e=x(new i(e),r+1,n),t=K(e,!0,r+1)),e.isNeg()&&!e.isZero()?"-"+t:t};y.toFixed=function(r,n){var t,e,i=this,s=i.constructor;return r===void 0?t=K(i):(U(r,0,ut),n===void 0?n=s.rounding:U(n,0,8),e=x(new s(i),r+i.e+1,n),t=K(e,!1,r+e.e+1)),i.isNeg()&&!i.isZero()?"-"+t:t};y.toFraction=function(r){var n,t,e,i,s,o,a,l,c,h,u,d,m=this,g=m.d,p=m.constructor;if(!g)return new p(m);if(c=t=new p(1),e=l=new p(0),n=new p(e),s=n.e=Ge(g)-m.e-1,o=s%b,n.d[0]=I(10,o<0?b+o:o),r==null)r=s>0?n:c;else{if(a=new p(r),!a.isInt()||a.lt(c))throw Error(ht+a);r=a.gt(n)?s>0?n:c:a}for(S=!1,a=new p(H(g)),h=p.precision,p.precision=s=g.length*b*2;u=k(a,n,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=n,n=a.minus(u.times(i)),a=i;return i=k(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,d=k(c,e,s,1).minus(m).abs().cmp(k(l,t,s,1).minus(m).abs())<1?[c,e]:[l,t],p.precision=h,S=!0,d};y.toHexadecimal=y.toHex=function(r,n){return Pe(this,16,r,n)};y.toNearest=function(r,n){var t=this,e=t.constructor;if(t=new e(t),r==null){if(!t.d)return t;r=new e(1),n=e.rounding}else{if(r=new e(r),n===void 0?n=e.rounding:U(n,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=k(t,r,0,n,1).times(r),S=!0,x(t)):(r.s=t.s,t=r),t};y.toNumber=function(){return+this};y.toOctal=function(r,n){return Pe(this,8,r,n)};y.toPower=y.pow=function(r){var n,t,e,i,s,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,s=l.rounding,r.eq(1))return x(a,e,s);if(n=T(r.e/b),n>=r.d.length-1&&(t=c<0?-c:c)<=Ai)return i=Xe(l,a,t,e),r.s<0?new l(1).div(i):x(i,e,s);if(o=a.s,o<0){if(n<r.d.length-1)return new l(NaN);if(r.d[n]&1||(o=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=o,a}return t=I(+a,c),n=t==0||!isFinite(t)?T(c*(Math.log("0."+H(a.d))/Math.LN10+a.e+1)):new l(t+"").e,n>l.maxE+1||n<l.minE-1?new l(n>0?o/0:0):(S=!1,l.rounding=a.s=1,t=Math.min(12,(n+"").length),i=me(r.times(at(a,e+t)),e),i.d&&(i=x(i,e+5,1),Ot(i.d,e,s)&&(n=e+10,i=x(me(r.times(at(a,n+t)),n),n+5,1),+H(i.d).slice(e+1,e+15)+1==1e14&&(i=x(i,e+1,0)))),i.s=o,S=!0,l.rounding=s,x(i,e,s))};y.toPrecision=function(r,n){var t,e=this,i=e.constructor;return r===void 0?t=K(e,e.e<=i.toExpNeg||e.e>=i.toExpPos):(U(r,1,ut),n===void 0?n=i.rounding:U(n,0,8),e=x(new i(e),r,n),t=K(e,r<=e.e||e.e<=i.toExpNeg,r)),e.isNeg()&&!e.isZero()?"-"+t:t};y.toSignificantDigits=y.toSD=function(r,n){var t=this,e=t.constructor;return r===void 0?(r=e.precision,n=e.rounding):(U(r,1,ut),n===void 0?n=e.rounding:U(n,0,8)),x(new e(t),r,n)};y.toString=function(){var r=this,n=r.constructor,t=K(r,r.e<=n.toExpNeg||r.e>=n.toExpPos);return r.isNeg()&&!r.isZero()?"-"+t:t};y.truncated=y.trunc=function(){return x(new this.constructor(this),this.e+1,1)};y.valueOf=y.toJSON=function(){var r=this,n=r.constructor,t=K(r,r.e<=n.toExpNeg||r.e>=n.toExpPos);return r.isNeg()?"-"+t:t};function H(r){var n,t,e,i=r.length-1,s="",o=r[0];if(i>0){for(s+=o,n=1;n<i;n++)e=r[n]+"",t=b-e.length,t&&(s+=ot(t)),s+=e;o=r[n],e=o+"",t=b-e.length,t&&(s+=ot(t))}else if(o===0)return"0";for(;o%10===0;)o/=10;return s+o}function U(r,n,t){if(r!==~~r||r<n||r>t)throw Error(ht+r)}function Ot(r,n,t,e){var i,s,o,a;for(s=r[0];s>=10;s/=10)--n;return--n<0?(n+=b,i=0):(i=Math.ceil((n+1)/b),n%=b),s=I(10,b-n),a=r[i]%s|0,e==null?n<3?(n==0?a=a/100|0:n==1&&(a=a/10|0),o=t<4&&a==99999||t>3&&a==49999||a==5e4||a==0):o=(t<4&&a+1==s||t>3&&a+1==s/2)&&(r[i+1]/s/100|0)==I(10,n-2)-1||(a==s/2||a==0)&&(r[i+1]/s/100|0)==0:n<4?(n==0?a=a/1e3|0:n==1?a=a/100|0:n==2&&(a=a/10|0),o=(e||t<4)&&a==9999||!e&&t>3&&a==4999):o=((e||t<4)&&a+1==s||!e&&t>3&&a+1==s/2)&&(r[i+1]/s/1e3|0)==I(10,n-3)-1,o}function Bt(r,n,t){for(var e,i=[0],s,o=0,a=r.length;o<a;){for(s=i.length;s--;)i[s]*=n;for(i[0]+=ue.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 Hi(r,n){var t,e,i;if(n.isZero())return n;e=n.d.length,e<32?(t=Math.ceil(e/3),i=(1/ne(4,t)).toString()):(t=16,i="2.3283064365386962890625e-10"),r.precision+=t,n=Dt(r,1,n.times(i),new r(1));for(var s=t;s--;){var o=n.times(n);n=o.times(o).minus(o).times(8).plus(1)}return r.precision-=t,n}var k=function(){function r(e,i,s){var o,a=0,l=e.length;for(e=e.slice();l--;)o=e[l]*i+a,e[l]=o%s|0,a=o/s|0;return a&&e.unshift(a),e}function n(e,i,s,o){var a,l;if(s!=o)l=s>o?1:-1;else for(a=l=0;a<s;a++)if(e[a]!=i[a]){l=e[a]>i[a]?1:-1;break}return l}function t(e,i,s,o){for(var a=0;s--;)e[s]-=a,a=e[s]<i[s]?1:0,e[s]=a*o+e[s]-i[s];for(;!e[0]&&e.length>1;)e.shift()}return function(e,i,s,o,a,l){var c,h,u,d,m,g,p,v,w,_,C,E,N,G,At,dt,rt,vt,X,It,Ht=e.constructor,oe=e.s==i.s?1:-1,L=e.d,M=i.d;if(!L||!L[0]||!M||!M[0])return new Ht(!e.s||!i.s||(L?M&&L[0]==M[0]:!M)?NaN:L&&L[0]==0||!M?oe*0:oe/0);for(l?(m=1,h=e.e-i.e):(l=$,m=b,h=T(e.e/m)-T(i.e/m)),X=M.length,rt=L.length,w=new Ht(oe),_=w.d=[],u=0;M[u]==(L[u]||0);u++);if(M[u]>(L[u]||0)&&h--,s==null?(G=s=Ht.precision,o=Ht.rounding):a?G=s+(e.e-i.e)+1:G=s,G<0)_.push(1),g=!0;else{if(G=G/m+2|0,u=0,X==1){for(d=0,M=M[0],G++;(u<rt||d)&&G--;u++)At=d*l+(L[u]||0),_[u]=At/M|0,d=At%M|0;g=d||u<rt}else{for(d=l/(M[0]+1)|0,d>1&&(M=r(M,d,l),L=r(L,d,l),X=M.length,rt=L.length),dt=X,C=L.slice(0,X),E=C.length;E<X;)C[E++]=0;It=M.slice(),It.unshift(0),vt=M[0],M[1]>=l/2&&++vt;do d=0,c=n(M,C,X,E),c<0?(N=C[0],X!=E&&(N=N*l+(C[1]||0)),d=N/vt|0,d>1?(d>=l&&(d=l-1),p=r(M,d,l),v=p.length,E=C.length,c=n(p,C,v,E),c==1&&(d--,t(p,X<v?It:M,v,l))):(d==0&&(c=d=1),p=M.slice()),v=p.length,v<E&&p.unshift(0),t(C,p,E,l),c==-1&&(E=C.length,c=n(M,C,X,E),c<1&&(d++,t(C,X<E?It:M,E,l))),E=C.length):c===0&&(d++,C=[0]),_[u++]=d,c&&C[0]?C[E++]=L[dt]||0:(C=[L[dt]],E=1);while((dt++<rt||C[0]!==void 0)&&G--);g=C[0]!==void 0}_[0]||_.shift()}if(m==1)w.e=h,Le=g;else{for(u=1,d=_[0];d>=10;d/=10)u++;w.e=u+h*m-1,x(w,a?s+w.e+1:s,o,g)}return w}}();function x(r,n,t,e){var i,s,o,a,l,c,h,u,d,m=r.constructor;t:if(n!=null){if(u=r.d,!u)return r;for(i=1,a=u[0];a>=10;a/=10)i++;if(s=n-i,s<0)s+=b,o=n,h=u[d=0],l=h/I(10,i-o-1)%10|0;else if(d=Math.ceil((s+1)/b),a=u.length,d>=a)if(e){for(;a++<=d;)u.push(0);h=l=0,i=1,s%=b,o=s-b+1}else break t;else{for(h=a=u[d],i=1;a>=10;a/=10)i++;s%=b,o=s-b+i,l=o<0?0:h/I(10,i-o-1)%10|0}if(e=e||n<0||u[d+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&&(s>0?o>0?h/I(10,i-o):0:u[d-1])%10&1||t==(r.s<0?8:7)),n<1||!u[0])return u.length=0,c?(n-=r.e+1,u[0]=I(10,(b-n%b)%b),r.e=-n||0):u[0]=r.e=0,r;if(s==0?(u.length=d,a=1,d--):(u.length=d+1,a=I(10,b-s),u[d]=o>0?(h/I(10,i-o)%I(10,o)|0)*a:0),c)for(;;)if(d==0){for(s=1,o=u[0];o>=10;o/=10)s++;for(o=u[0]+=a,a=1;o>=10;o/=10)a++;s!=a&&(r.e++,u[0]==$&&(u[0]=1));break}else{if(u[d]+=a,u[d]!=$)break;u[d--]=0,a=1}for(s=u.length;u[--s]===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 K(r,n,t){if(!r.isFinite())return ze(r);var e,i=r.e,s=H(r.d),o=s.length;return n?(t&&(e=t-o)>0?s=s.charAt(0)+"."+s.slice(1)+ot(e):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(r.e<0?"e":"e+")+r.e):i<0?(s="0."+ot(-i-1)+s,t&&(e=t-o)>0&&(s+=ot(e))):i>=o?(s+=ot(i+1-o),t&&(e=t-i-1)>0&&(s=s+"."+ot(e))):((e=i+1)<o&&(s=s.slice(0,e)+"."+s.slice(e)),t&&(e=t-o)>0&&(i+1===o&&(s+="."),s+=ot(e))),s}function se(r,n){var t=r[0];for(n*=b;t>=10;t/=10)n++;return n}function Jt(r,n,t){if(n>Ii)throw S=!0,t&&(r.precision=t),Error(Te);return x(new r(Zt),n,1,!0)}function J(r,n,t){if(n>fe)throw Error(Te);return x(new r(Qt),n,t,!0)}function Ge(r){var n=r.length-1,t=n*b+1;if(n=r[n],n){for(;n%10==0;n/=10)t--;for(n=r[0];n>=10;n/=10)t++}return t}function ot(r){for(var n="";r--;)n+="0";return n}function Xe(r,n,t,e){var i,s=new r(1),o=Math.ceil(e/b+4);for(S=!1;;){if(t%2&&(s=s.times(n),Ee(s.d,o)&&(i=!0)),t=T(t/2),t===0){t=s.d.length-1,i&&s.d[t]===0&&++s.d[t];break}n=n.times(n),Ee(n.d,o)}return S=!0,s}function Se(r){return r.d[r.d.length-1]&1}function Ye(r,n,t){for(var e,i,s=new r(n[0]),o=0;++o<n.length;){if(i=new r(n[o]),!i.s){s=i;break}e=s.cmp(i),(e===t||e===0&&s.s===t)&&(s=i)}return s}function me(r,n){var t,e,i,s,o,a,l,c=0,h=0,u=0,d=r.constructor,m=d.rounding,g=d.precision;if(!r.d||!r.d[0]||r.e>17)return new d(r.d?r.d[0]?r.s<0?0:1/0:1:r.s?r.s<0?0:r:NaN);for(n==null?(S=!1,l=g):l=n,a=new d(.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=s=o=new d(1),d.precision=l;;){if(s=x(s.times(r),l,1),t=t.times(++h),a=o.plus(k(s,t,l,1)),H(a.d).slice(0,l)===H(o.d).slice(0,l)){for(i=u;i--;)o=x(o.times(o),l,1);if(n==null)if(c<3&&Ot(o.d,l-e,m,c))d.precision=l+=10,t=s=a=new d(1),h=0,c++;else return x(o,d.precision=g,m,S=!0);else return d.precision=g,o}o=a}}function at(r,n){var t,e,i,s,o,a,l,c,h,u,d,m=1,g=10,p=r,v=p.d,w=p.constructor,_=w.rounding,C=w.precision;if(p.s<0||!v||!v[0]||!p.e&&v[0]==1&&v.length==1)return new w(v&&!v[0]?-1/0:p.s!=1?NaN:v?0:p);if(n==null?(S=!1,h=C):h=n,w.precision=h+=g,t=H(v),e=t.charAt(0),Math.abs(s=p.e)<15e14){for(;e<7&&e!=1||e==1&&t.charAt(1)>3;)p=p.times(r),t=H(p.d),e=t.charAt(0),m++;s=p.e,e>1?(p=new w("0."+t),s++):p=new w(e+"."+t.slice(1))}else return c=Jt(w,h+2,C).times(s+""),p=at(new w(e+"."+t.slice(1)),h-g).plus(c),w.precision=C,n==null?x(p,C,_,S=!0):p;for(u=p,l=o=p=k(p.minus(1),p.plus(1),h,1),d=x(p.times(p),h,1),i=3;;){if(o=x(o.times(d),h,1),c=l.plus(k(o,new w(i),h,1)),H(c.d).slice(0,h)===H(l.d).slice(0,h))if(l=l.times(2),s!==0&&(l=l.plus(Jt(w,h+2,C).times(s+""))),l=k(l,new w(m),h,1),n==null)if(Ot(l.d,h-g,_,a))w.precision=h+=g,c=o=p=k(u.minus(1),u.plus(1),h,1),d=x(p.times(p),h,1),i=a=1;else return x(l,w.precision=C,_,S=!0);else return w.precision=C,l;l=c,i+=2}}function ze(r){return String(r.s*r.s/0)}function Ut(r,n){var t,e,i;for((t=n.indexOf("."))>-1&&(n=n.replace(".","")),(e=n.search(/e/i))>0?(t<0&&(t=e),t+=+n.slice(e+1),n=n.substring(0,e)):t<0&&(t=n.length),e=0;n.charCodeAt(e)===48;e++);for(i=n.length;n.charCodeAt(i-1)===48;--i);if(n=n.slice(e,i),n){if(i-=e,r.e=t=t-e-1,r.d=[],e=(t+1)%b,t<0&&(e+=b),e<i){for(e&&r.d.push(+n.slice(0,e)),i-=b;e<i;)r.d.push(+n.slice(e,e+=b));n=n.slice(e),e=b-n.length}else e-=i;for(;e--;)n+="0";r.d.push(+n),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 Li(r,n){var t,e,i,s,o,a,l,c,h;if(n.indexOf("_")>-1){if(n=n.replace(/(\d)_(?=\d)/g,"$1"),Ue.test(n))return Ut(r,n)}else if(n==="Infinity"||n==="NaN")return+n||(r.s=NaN),r.e=NaN,r.d=null,r;if(Oi.test(n))t=16,n=n.toLowerCase();else if(Mi.test(n))t=2;else if(Ni.test(n))t=8;else throw Error(ht+n);for(s=n.search(/p/i),s>0?(l=+n.slice(s+1),n=n.substring(2,s)):n=n.slice(2),s=n.indexOf("."),o=s>=0,e=r.constructor,o&&(n=n.replace(".",""),a=n.length,s=a-s,i=Xe(e,new e(t),s,s*2)),c=Bt(n,t,$),h=c.length-1,s=h;c[s]===0;--s)c.pop();return s<0?new e(r.s*0):(r.e=se(c,h),r.d=c,S=!1,o&&(r=k(r,i,a*4)),l&&(r=r.times(Math.abs(l)<54?I(2,l):R.pow(2,l))),S=!0,r)}function Ti(r,n){var t,e=n.d.length;if(e<3)return n.isZero()?n:Dt(r,2,n,n);t=1.4*Math.sqrt(e),t=t>16?16:t|0,n=n.times(1/ne(5,t)),n=Dt(r,2,n,n);for(var i,s=new r(5),o=new r(16),a=new r(20);t--;)i=n.times(n),n=n.times(s.plus(i.times(o.times(i).minus(a))));return n}function Dt(r,n,t,e,i){var s,o,a,l,c=r.precision,h=Math.ceil(c/b);for(S=!1,l=t.times(t),a=new r(e);;){if(o=k(a.times(l),new r(n++*n++),c,1),a=i?e.plus(o):e.minus(o),e=k(o.times(l),new r(n++*n++),c,1),o=a.plus(e),o.d[h]!==void 0){for(s=h;o.d[s]===a.d[s]&&s--;);if(s==-1)break}s=a,a=e,e=o,o=s}return S=!0,o.d.length=h+1,o}function ne(r,n){for(var t=r;--n;)t*=r;return t}function We(r,n){var t,e=n.s<0,i=J(r,r.precision,1),s=i.times(.5);if(n=n.abs(),n.lte(s))return nt=e?4:1,n;if(t=n.divToInt(i),t.isZero())nt=e?3:2;else{if(n=n.minus(t.times(i)),n.lte(s))return nt=Se(t)?e?2:3:e?4:1,n;nt=Se(t)?e?1:4:e?3:2}return n.minus(i).abs()}function Pe(r,n,t,e){var i,s,o,a,l,c,h,u,d,m=r.constructor,g=t!==void 0;if(g?(U(t,1,ut),e===void 0?e=m.rounding:U(e,0,8)):(t=m.precision,e=m.rounding),!r.isFinite())h=ze(r);else{for(h=K(r),o=h.indexOf("."),g?(i=2,n==16?t=t*4-3:n==8&&(t=t*3-2)):i=n,o>=0&&(h=h.replace(".",""),d=new m(1),d.e=h.length-o,d.d=Bt(K(d),10,i),d.e=d.d.length),u=Bt(h,10,i),s=l=u.length;u[--l]==0;)u.pop();if(!u[0])h=g?"0p+0":"0";else{if(o<0?s--:(r=new m(r),r.d=u,r.e=s,r=k(r,d,t,e,0,i),u=r.d,s=r.e,c=Le),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||(++s,u.unshift(1));for(l=u.length;!u[l-1];--l);for(o=0,h="";o<l;o++)h+=ue.charAt(u[o]);if(g){if(l>1)if(n==16||n==8){for(o=n==16?4:3,--l;l%o;l++)h+="0";for(u=Bt(h,i,n),l=u.length;!u[l-1];--l);for(o=1,h="1.";o<l;o++)h+=ue.charAt(u[o])}else h=h.charAt(0)+"."+h.slice(1);h=h+(s<0?"p":"p+")+s}else if(s<0){for(;++s;)h="0"+h;h="0."+h}else if(++s>l)for(s-=l;s--;)h+="0";else s<l&&(h=h.slice(0,s)+"."+h.slice(s))}h=(n==16?"0x":n==2?"0b":n==8?"0o":"")+h}return r.s<0?"-"+h:h}function Ee(r,n){if(r.length>n)return r.length=n,!0}function Fi(r){return new this(r).abs()}function Bi(r){return new this(r).acos()}function Ui(r){return new this(r).acosh()}function Gi(r,n){return new this(r).plus(n)}function Xi(r){return new this(r).asin()}function Yi(r){return new this(r).asinh()}function zi(r){return new this(r).atan()}function Wi(r){return new this(r).atanh()}function qi(r,n){r=new this(r),n=new this(n);var t,e=this.precision,i=this.rounding,s=e+4;return!r.s||!n.s?t=new this(NaN):!r.d&&!n.d?(t=J(this,s,1).times(n.s>0?.25:.75),t.s=r.s):!n.d||r.isZero()?(t=n.s<0?J(this,e,i):new this(0),t.s=r.s):!r.d||n.isZero()?(t=J(this,s,1).times(.5),t.s=r.s):n.s<0?(this.precision=s,this.rounding=1,t=this.atan(k(r,n,s,1)),n=J(this,s,1),this.precision=e,this.rounding=i,t=r.s<0?t.minus(n):t.plus(n)):t=this.atan(k(r,n,s,1)),t}function ji(r){return new this(r).cbrt()}function $i(r){return x(r=new this(r),r.e+1,2)}function Zi(r,n,t){return new this(r).clamp(n,t)}function Qi(r){if(!r||typeof r!="object")throw Error(ie+"Object expected");var n,t,e,i=r.defaults===!0,s=["precision",1,ut,"rounding",0,8,"toExpNeg",-9e15,0,"toExpPos",0,he,"maxE",0,he,"minE",-9e15,0,"modulo",0,9];for(n=0;n<s.length;n+=3)if(t=s[n],i&&(this[t]=de[t]),(e=r[t])!==void 0)if(T(e)===e&&e>=s[n+1]&&e<=s[n+2])this[t]=e;else throw Error(ht+t+": "+e);if(t="crypto",i&&(this[t]=de[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(Fe);else this[t]=!1;else throw Error(ht+t+": "+e);return this}function Ji(r){return new this(r).cos()}function Ki(r){return new this(r).cosh()}function qe(r){var n,t,e;function i(s){var o,a,l,c=this;if(!(c instanceof i))return new i(s);if(c.constructor=i,De(s)){c.s=s.s,S?!s.d||s.e>i.maxE?(c.e=NaN,c.d=null):s.e<i.minE?(c.e=0,c.d=[0]):(c.e=s.e,c.d=s.d.slice()):(c.e=s.e,c.d=s.d?s.d.slice():s.d);return}if(l=typeof s,l==="number"){if(s===0){c.s=1/s<0?-1:1,c.e=0,c.d=[0];return}if(s<0?(s=-s,c.s=-1):c.s=1,s===~~s&&s<1e7){for(o=0,a=s;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=[s]):(c.e=o,c.d=[s]);return}if(s*0!==0){s||(c.s=NaN),c.e=NaN,c.d=null;return}return Ut(c,s.toString())}if(l==="string")return(a=s.charCodeAt(0))===45?(s=s.slice(1),c.s=-1):(a===43&&(s=s.slice(1)),c.s=1),Ue.test(s)?Ut(c,s):Li(c,s);if(l==="bigint")return s<0?(s=-s,c.s=-1):c.s=1,Ut(c,s.toString());throw Error(ht+s)}if(i.prototype=y,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=Qi,i.clone=qe,i.isDecimal=De,i.abs=Fi,i.acos=Bi,i.acosh=Ui,i.add=Gi,i.asin=Xi,i.asinh=Yi,i.atan=zi,i.atanh=Wi,i.atan2=qi,i.cbrt=ji,i.ceil=$i,i.clamp=Zi,i.cos=Ji,i.cosh=Ki,i.div=ts,i.exp=es,i.floor=is,i.hypot=ss,i.ln=ns,i.log=rs,i.log10=as,i.log2=os,i.max=ls,i.min=cs,i.mod=hs,i.mul=us,i.pow=ds,i.random=fs,i.round=ms,i.sign=ps,i.sin=gs,i.sinh=ys,i.sqrt=vs,i.sub=ws,i.sum=Ps,i.tan=xs,i.tanh=bs,i.trunc=_s,r===void 0&&(r={}),r&&r.defaults!==!0)for(e=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],n=0;n<e.length;)r.hasOwnProperty(t=e[n++])||(r[t]=this[t]);return i.config(r),i}function ts(r,n){return new this(r).div(n)}function es(r){return new this(r).exp()}function is(r){return x(r=new this(r),r.e+1,3)}function ss(){var r,n,t=new this(0);for(S=!1,r=0;r<arguments.length;)if(n=new this(arguments[r++]),n.d)t.d&&(t=t.plus(n.times(n)));else{if(n.s)return S=!0,new this(1/0);t=n}return S=!0,t.sqrt()}function De(r){return r instanceof R||r&&r.toStringTag===Be||!1}function ns(r){return new this(r).ln()}function rs(r,n){return new this(r).log(n)}function os(r){return new this(r).log(2)}function as(r){return new this(r).log(10)}function ls(){return Ye(this,arguments,-1)}function cs(){return Ye(this,arguments,1)}function hs(r,n){return new this(r).mod(n)}function us(r,n){return new this(r).mul(n)}function ds(r,n){return new this(r).pow(n)}function fs(r){var n,t,e,i,s=0,o=new this(1),a=[];if(r===void 0?r=this.precision:U(r,1,ut),e=Math.ceil(r/b),this.crypto)if(crypto.getRandomValues)for(n=crypto.getRandomValues(new Uint32Array(e));s<e;)i=n[s],i>=429e7?n[s]=crypto.getRandomValues(new Uint32Array(1))[0]:a[s++]=i%1e7;else if(crypto.randomBytes){for(n=crypto.randomBytes(e*=4);s<e;)i=n[s]+(n[s+1]<<8)+(n[s+2]<<16)+((n[s+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(n,s):(a.push(i%1e7),s+=4);s=e/4}else throw Error(Fe);else for(;s<e;)a[s++]=Math.random()*1e7|0;for(e=a[--s],r%=b,e&&r&&(i=I(10,b-r),a[s]=(e/i|0)*i);a[s]===0;s--)a.pop();if(s<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=b)a.shift();for(e=1,i=a[0];i>=10;i/=10)e++;e<b&&(t-=b-e)}return o.e=t,o.d=a,o}function ms(r){return x(r=new this(r),r.e+1,this.rounding)}function ps(r){return r=new this(r),r.d?r.d[0]?r.s:0*r.s:r.s||NaN}function gs(r){return new this(r).sin()}function ys(r){return new this(r).sinh()}function vs(r){return new this(r).sqrt()}function ws(r,n){return new this(r).sub(n)}function Ps(){var r=0,n=arguments,t=new this(n[r]);for(S=!1;t.s&&++r<n.length;)t=t.plus(n[r]);return S=!0,x(t,this.precision,this.rounding)}function xs(r){return new this(r).tan()}function bs(r){return new this(r).tanh()}function _s(r){return x(r=new this(r),r.e+1,1)}y[Symbol.for("nodejs.util.inspect.custom")]=y.toString;y[Symbol.toStringTag]="Decimal";var R=y.constructor=qe(de);Zt=new R(Zt);Qt=new R(Qt);class Cs{constructor(){f(this,"parent");f(this,"name","");f(this,"extData");f(this,"mainCanvas");f(this,"_isRecalculate",!1);f(this,"notifyReload")}get isRecalculate(){return(this.parent?this.parent.isRecalculate:!1)||this._isRecalculate}set isRecalculate(n){this._isRecalculate=n}equalsMainCanvas(n){return this.mainCanvas===n}setMainCanvas(n){this.mainCanvas=n}}class Ss extends Cs{constructor(){super(...arguments);f(this,"_isVisible",!0);f(this,"inheritOpacity",!0);f(this,"_opacity");f(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),s=Math.max(...this.scaleRange);return t>=i&&t<=s}return!0}}let Es=class extends Ss{constructor(n){super(),n.name=n.name||$t("default-name-"),Object.assign(this,{...n})}};class Ds extends Es{constructor(t){super(t);f(this,"_isInteractive",!0);f(this,"_isHoverable",!0);f(this,"_isDownable",!0);f(this,"_isContextmenuable",!0);f(this,"_isClickable",!0);f(this,"_isDoubleClickable",!0);f(this,"_isDraggable",!0);f(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 Vs{constructor(n){f(this,"propagationStopped",!1);this.data=n}stopPropagation(){this.propagationStopped=!0}get canPropagate(){return!this.propagationStopped}}class Nt extends Ds{constructor(){super(...arguments);f(this,"listeners",{wheel:new Set,hover:new Set,down:new Set,contextmenu:new Set,click:new Set,doubleClick:new Set,dragg:new Set});f(this,"sharedControllers",{});f(this,"_eventDate",{});f(this,"_clearEventDate",!1);f(this,"_isHover",!1);f(this,"notifyHover",(t,e)=>this.checkEventDate("hover",t)&&this.trigger("hover",{state:t,oldState:this.isHover},e,"isHoverable"));f(this,"_isDown",!1);f(this,"notifyDown",(t,e)=>this.checkEventDate("down",t)&&this.trigger("down",{state:t,oldState:this.isDown},e,"isDownable"));f(this,"_isContextmenu",!1);f(this,"notifyContextmenu",(t,e)=>this.checkEventDate("contextmenu",t)&&this.trigger("contextmenu",{state:t,oldState:this.isContextmenu},e,"isContextmenuable"));f(this,"_isClick",!1);f(this,"clickTimestamp",0);f(this,"doubleClickInterval",300);f(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")});f(this,"_isDblClick",!1);f(this,"notifyDoubleClick",(t,e)=>this.checkEventDate("doubleClick",t)&&this.trigger("doubleClick",{state:t,oldState:this.isDblClick},e,"isDoubleClickable"));f(this,"notifyDragg",(t,e)=>this.checkEventDate("dragg",t)&&this.trigger("dragg",t,e,"isDraggable"));f(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,s){var c,h;if(!this[s])return;this.updateStates(t,e);const o=new Vs(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],s=JSON.stringify(e);return i==s?!1:(this._eventDate[t]=s,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 Rs extends Nt{constructor(t){super(t);f(this,"canvas");f(this,"ctx");f(this,"_rectValueIsUpdated",!1);f(this,"_rect");f(this,"offset",{x:0,y:0});f(this,"center",{x:0,y:0});f(this,"defaultCenter",{top:void 0,bottom:void 0,left:void 0,right:void 0});f(this,"accuracy",5);f(this,"scale",1);f(this,"defaultScale",1);f(this,"percentage",1);f(this,"axisConfig",{count:2,min:100,size:100,x:1,y:1});f(this,"cycle",10);f(this,"delta",.02);f(this,"_redrawInNextRenderFrame",!1);f(this,"isAuto",!1);f(this,"isRendering",!1);f(this,"drawAxis");f(this,"layerGroups",new Map);f(this,"isScaleUpdated",!1);f(this,"nowGridCount");const{id:e,axisConfig:i,defaultCenter:s,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),s&&this.setDefaultCenter(s),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:s,height:o}=e,{top:a,bottom:l,left:c,right:h}=i,u={vertical:(p,v)=>{if([0,"0","0%"].includes(p))return 0;if(!(p==1/0||p==-1/0))return typeof p=="number"?p:["top","left"].includes(p)?0:["bottom","right"].includes(p)?v:["middle","center"].includes(p)?v/2:/^(-?\d+)%$/.test(p)?(p=p.match(/^(-?\d+)%$/)[1],v*Number(p)/100):Number(p)||void 0},reverse:(p,v)=>{if([0,"0","0%"].includes(p))return v;if(p==1/0||p==-1/0)return;if(typeof p=="number")return v-p;const w=u.vertical(p,v);return w?v-w:void 0}},d=(p,v,w)=>{if(p!==void 0){const _=u.vertical(p,w);if(_!==void 0)return _}if(v!==void 0){const _=u.reverse(v,w);if(_!==void 0)return _}return w/2},m=d(a,l,o);return{x:d(c,h,s),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:s,axisConfig:o,rect:a}=this;if(!s||!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 d=this.getAxisPointByValue(u.xV,u.yV);this.offset.x-=(d.x-h.x)*o.x,this.offset.y-=(d.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(([p,v])=>[p,Number(v)])),{x:s,y:o,count:a,min:l,size:c}=i,h=[1,-1].includes(s),u=[1,-1].includes(o),d=a>0,m=l>0,g=c>=l&&c<=l*2;if(!h||!u||!d||!m||!g){console.warn("Invalid axis configuration:",{x:s,y:o,count:a,min:l,size:c});return}this.axisConfig=i}setDefaultCenter(t){Object.assign(this.defaultCenter,t),this.updateCenter()}getGridSize(t){const{cycle:e,delta:i,axisConfig:s}=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)*s.min).toFixed(0))}getGridCount(t){const{axisConfig:e,cycle:i,delta:s}=this,o=e.count,a=i*s;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:s,axisConfig:o}=this;if(!e)return console.error("canvas is not HTMLCanvasElement");const{clientX:a,clientY:l}=t,{left:c,top:h}=s,u=(a-c-i.x)*o.x,d=(l-h-i.y)*o.y;return{x:u,y:d}}getAxisValueByPoint(t,e,i){const{axisConfig:s}=this;if(i)return{xV:t/s.min*s.count,yV:e/s.min*s.count};const o=this.getNowGridCount,a=new R(t).div(s.size).mul(o).toFixed(8),l=new R(e).div(s.size).mul(o).toFixed(8);return{xV:Number(a),yV:Number(l)}}getAxisPointByValue(t,e,i){const{axisConfig:s}=this;if(i)return{x:t/s.count*s.min,y:e/s.count*s.min};const o=this.getNowGridCount,a=new R(t).div(o).mul(s.size).toFixed(3),l=new R(e).div(o).mul(s.size).toFixed(3);return{x:Number(a),y:Number(l)}}getMaxMinValue(t){t=t||this.rect;const{left:e,top:i,right:s,bottom:o}=t,{axisConfig:a}=this,{x:l,y:c}=this.getMousePositionOnAxis({clientX:a.x==1?e:s,clientY:a.y==1?i:o}),{xV:h,yV:u}=this.getAxisValueByPoint(l,c),{x:d,y:m}=this.getMousePositionOnAxis({clientX:a.x==1?s:e,clientY:a.y==1?o:i}),{xV:g,yV:p}=this.getAxisValueByPoint(d,m);return{minXV:h,maxXV:g,minYV:u,maxYV:p}}transformPosition(t){const{center:e,percentage:i,axisConfig:s}=this,o=i*s.x,a=i*s.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 ks extends Rs{constructor(t){super(t);f(this,"theme","light");f(this,"isThemeUpdated",!1);f(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"}}},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"}}}});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 s=this.style[i];e.font=`${s.text.bold?"bold":""} ${s.text.size}px ${s.text.family}`}clearScreen(t=!0){const{ctx:e,theme:i,rect:s}=this,{width:o,height:a}=s;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=Ie(this.style[e]||this.style[this.theme]);ct(i,t[e]),this.style[e]=i}this.initStyle()}setTheme(t){t in this.style&&(this.theme=t,this.isThemeUpdated=!0)}}class V extends Nt{constructor(t){t={...t},t.isDraggable=t.isDraggable??!1;const{mainCanvas:e,notifyReload:i}=t;delete t.mainCanvas,delete t.notifyReload;super(t);f(this,"_style");f(this,"_position");f(this,"_value");f(this,"_zIndex",0);f(this,"_dynamicPosition");f(this,"_offset",{x:0,y:0});f(this,"path");f(this,"publicToPrivateKeyMap",{offset:"_offset",position:"_position",value:"_value",dynamicPosition:"_dynamicPosition",zIndex:"_zIndex",style:"_style"});f(this,"redrawOnIsHoverChange",!0);f(this,"defaultHover",(t,e)=>{var i;this.redrawOnIsHoverChange&&((i=this.notifyReload)==null||i.call(this))});f(this,"_valueScope");f(this,"styleRadius",{value:0,radius:0});f(this,"offsetValue",{xV:0,yV:0});f(this,"fixedExtraScope",{topV:0,bottomV:0,leftV:0,rightV:0});f(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 s={};["offset","style","zIndex","position","dynamicPosition","value"].forEach(o=>{o in t&&(s[o]=t[o])}),this.internalUpdate(s),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((s,o)=>typeof s=="number"?o==0?s+t:s+e:[s[0]+t,s[1]+e])}internalUpdate(t,e){Object.keys(t).forEach(i=>{const s=this.publicToPrivateKeyMap[i];s&&(this[s]=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,s=1/0,o=-1/0;t.forEach(([a,l])=>{e=Math.min(e,a),i=Math.max(i,a),s=Math.min(s,l),o=Math.max(o,l)}),this.valueScope={minX:e,maxX:i,minY:s,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 s=this.mainCanvas.getAxisValueByPoint(e,0).xV,o=s-i;this.valueScope.minX-=o,this.valueScope.maxX+=o,this.valueScope.minY-=o,this.valueScope.maxY+=o,this.styleRadius={radius:e,value:s}}else{const{stroke:e,point:i}=this.computedValueScopeStyles,s=i?i.radius+Math.max(0,i.width/2):0,o=e?Math.max(0,e.width/2):0,a=Math.max(s,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:s,offsetValue:o}=this;if(!(!e||!i))if(t){const{x:a,y:l}=e.axisConfig;let{xV:c,yV:h}=e.getAxisValueByPoint(s.x,s.y);c*=a,h*=l;const u=c-o.xV,d=h-o.yV;i.minX+=u,i.maxX+=u,i.minY+=d,i.maxY+=d,this.offsetValue={xV:c,yV:h}}else{if(this.offsetValue={xV:0,yV:0},s.x==0&&s.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:s,topV:o,bottomV:a}=e;this.valueScope.minX-=i-this.fixedExtraScope.leftV,this.valueScope.maxX+=s-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:s}=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:d,yV:m}=i.getAxisValueByPoint(o,a);e.minX-=d-s.leftV,e.maxX+=m-s.rightV,e.minY-=h-s.topV,e.maxY+=u-s.bottomV,this.extraScope={...t,topV:h,bottomV:u,leftV:d,rightV:m}}else this.setExtraScope(this.extraScope)}get isWithinRange(){const{mainCanvas:t,valueScope:e}=this;if(!t)return!1;const{isScaleUpdated:i,maxMinValue:s}=t;return i&&(this.calculateStyleRadiusValue(),this.calculateOffsetValue(),this.setExtraScope()),e?!(s.maxXV<e.minX||s.minXV>e.maxX||s.maxYV<e.minY||s.minYV>e.maxY):!0}get isNeedRender(){return!!(this.mainCanvas&&this.shouldRender()&&this.dynamicPosition&&this.isWithinRange)}calculateOffset(t,e){const{percentage:i,axisConfig:s}=this.mainCanvas,o=s.count/s.min/i,a={value:t*o*s.x,position:t/i*s.x,dynamicPosition:t},l={value:e*o*s.y,position:e/i*s.y,dynamicPosition:e};return{x:a,y:l}}handleValuePosition(t,e){let{value:i,position:s,mainCanvas:o}=this;if(!o)return!1;const a=t==="array1D"?ee:Mt,[l,c]=[a(i)&&(!e||i.length>=e),a(s)&&(!e||s.length>=e)],h={value:i,position:s,dynamicPosition:[]};if(!l&&!c)return this.internalUpdate({dynamicPosition:void 0}),!1;if(l){const u=i;if(t==="array1D"){const d=o.getAxisPointByValue(u[0],u[1],!0);h.position=[d.x,d.y]}else{h.position=[];for(let d=0;d<u.length;d++){const m=u[d],g=o.getAxisPointByValue(m[0],m[1],!0);h.position.push([g.x,g.y])}}}else{const u=s;if(t==="array1D"){const d=o.getAxisValueByPoint(u[0],u[1],!0);h.value=[d.xV,d.yV]}else{h.value=[];for(let d=0;d<u.length;d++){const m=u[d],g=o.getAxisValueByPoint(m[0],m[1],!0);h.value.push([g.xV,g.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:s,dashGap:o,dashOffset:a,color:l,color_hover:c,cap:h,join:u}=e;return t.setLineDash(s?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}}f(V,"ctx",document.createElement("canvas").getContext("2d"));class Gt extends V{constructor(t){super(t);f(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:void 0});let t=this.value,e=this.position;t?e=this.convertValuesToPositions(t):t=this.convertPositionsToValues(e),this.updateDataProperties(t,e)}convertValuesToPositions(t){const e=[];let i=1;return t.forEach((s,o)=>{if(o===0){const a=this.mainCanvas.getAxisPointByValue(s[0],s[1],!0);e.push([a.x,a.y]),i=new R(a.x).div(s[0]).toNumber()}else e.push([new R(i).mul(s[0]).toNumber(),new R(i).mul(s[1]).toNumber()])}),e}convertPositionsToValues(t){const e=[];let i=1;return t.forEach((s,o)=>{if(o===0){const a=this.mainCanvas.getAxisValueByPoint(s[0],s[1],!0);e.push([a.xV,a.yV]),i=new R(a.xV).div(s[0]).toNumber()}else e.push([new R(i).mul(s[0]).toNumber(),new R(i).mul(s[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&&this.internalUpdate({dynamicPosition:t.transformPosition(e)}),[this.draw,this]}}}class O{static add(n,t){return new R(n).add(t).toNumber()}static sub(n,t){return new R(n).sub(t).toNumber()}static mul(n,t){return new R(n).mul(t).toNumber()}static div(n,t){return new R(n).div(t).toNumber()}}class Xt extends V{constructor(t){super(t);f(this,"textOffset",{x:0,y:0});f(this,"_text");f(this,"defaultDragg",(t,e)=>{var l;const{offsetX:i,offsetY:s}=t.data,{x:o,y:a}=this.calculateOffset(i,s);this.internalUpdate({value:[O.add(this.value[0],o.value),O.add(this.value[1],a.value)],position:[O.add(this.position[0],o.position),O.add(this.position[1],a.position)],dynamicPosition:[O.add(this.dynamicPosition[0],o.dynamicPosition),O.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?V.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=V.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 s={};return typeof this.style=="string"?s=((o=e.style[this.style])==null?void 0:o.text)||i:typeof this.style=="object"?s=Object.assign({},i,this.style):s=i,t.font=`${s.bold?"bold":""} ${s.size}px ${s.family}`,t.lineWidth=2,t.strokeStyle=s.stroke,t.fillStyle=s[this.isHover?"secondary":"color"],s}get computedValueScopeStyles(){return{}}draw(t){const{text:e,textOffset:i,finalDynamicPosition:s}=this;if(!this.mainCanvas||!e)return;this.setGlobalAlpha(t),this.setOverlayStyles(t);const o=s[0]-i.x,a=s[1]+i.y;t.strokeText(e,o,a),t.fillText(e,o,a),this.path=new Path2D,this.path.rect(o,s[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 lt extends V{constructor(t){super(t);f(this,"angle",2*Math.PI);f(this,"defaultDragg",(t,e)=>{var l;const{offsetX:i,offsetY:s}=t.data,{x:o,y:a}=this.calculateOffset(i,s);this.internalUpdate({value:[O.add(this.value[0],o.value),O.add(this.value[1],a.value)],position:[O.add(this.position[0],o.position),O.add(this.position[1],a.position)],dynamicPosition:[O.add(this.dynamicPosition[0],o.dynamicPosition),O.add(this.dynamicPosition[1],a.dynamicPosition)]},!0),(l=this.notifyReload)==null||l.call(this)});f(this,"fillProgress");f(this,"defaultHover",(t,e)=>{const i=t.data.state,s=300,o=this.setOverlayStyles().width;this.fillProgress?this.cancelAndRestartAnimation(i,o,s-100):i&&this.startNewHoverAnimation(o,s)});this.addEventListener("hover",this.defaultHover),this.addEventListener("dragg",this.defaultDragg)}updateValueScope(){this.initValueScope()}cancelAndRestartAnimation(t,e,i){this.fillProgress.scheduleCallback();let s=0;this.fillProgress.scheduleCallback=kt(o=>{!this.fillProgress||!o||(this.fillProgress.progress+=(o-s)*(t?1:-1),s=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:kt(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?V.ctx.isPointInPath(this.path,t,e):!1}isPointInStroke(t,e){var i;if(this.path&&this.mainCanvas){const{width:s}=this.setOverlayStyles(V.ctx);return((i=this.fillProgress)==null?void 0:i.lineWidthOffset)==s?!1:V.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 s={};typeof this.style=="string"?s=((c=e.style[this.style])==null?void 0:c.point)||i:typeof this.style=="object"?s=Object.assign({},i,this.style):s=i;const{width:o,stroke:a,fill:l}=s;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{...s}}get computedValueScopeStyles(){return{point:this.setOverlayStyles()}}draw(t){var h;const{finalDynamicPosition:e,mainCanvas:i}=this;if(!i)return;this.setGlobalAlpha(t);const{radius:s,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,s+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 je extends V{constructor(t){super(t);f(this,"handlePoints",[]);f(this,"isShowHandlePoint",!1);f(this,"_isHandlePointsVisible",!0);f(this,"canCreateOrDeleteHandlePoint",!0);f(this,"lockedCanCreateOrDeleteHandlePoint",!1);f(this,"defaultClick",(t,e)=>{var o;if(!this.isHandlePointsVisible)return;const{state:i,oldState:s}=t.data;i!=s&&!this.isInfinite&&((o=this.notifyReload)==null||o.call(this))});f(this,"defaultDoubleClick",(t,e)=>{if(e){if(!this.isHandlePointsVisible)return;const{offsetX:i,offsetY:s}=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,s):this.tryDeleteHandlePoint(l)}}});f(this,"defaultDragg",(t,e)=>{var s;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]=[O.add(this.value[u][0],l.value),O.add(this.value[u][1],c.value)],this.position[u]=[O.add(this.position[u][0],l.position),O.add(this.position[u][1],c.position)],this.dynamicPosition[u]=[O.add(this.dynamicPosition[u][0],l.dynamicPosition),O.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();(s=this.notifyReload)==null||s.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(s=>s.internalUpdate({offset:t}))}tryCreateNewHandlePoint(t,e){var c;if(!this.isPointInStroke(t,e))return;const i=this.getExtendedDynamicPositions(),s=Ms([t,e],i);if(s===-1)return;const[o,a]=this.getAdjacentIndices(s),l=this.createNewHandlePoint(o,a);this.insertHandlePoint(s,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=ae(this.value[t],this.value[e]),s=ae(this.position[t],this.position[e]),o=ae(this.dynamicPosition[t],this.dynamicPosition[e]);return new lt({value:i,position:s,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:s,isHandlePointsVisible:o}=this;!i||!o||(t==null||t.forEach((a,l)=>{if(!this.handlePoints[l]){const c=new lt({mainCanvas:this.mainCanvas,isDraggable:!0,offset:s,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 Ms(r,n,t=10){if(n.length===0)return 0;if(n.length===1)return 1;let e=1/0,i=-1;for(let s=0;s<n.length-1;s++){const o=Je(r,n[s],n[s+1]);if(o<t)return s+1;o<e&&(e=o,i=s+1)}return i}function ae(r,n){const{x:t,y:e}=be(...r,...n);return[t,e]}class Yt extends je{constructor(t){super(t);f(this,"_isInfinite");f(this,"isClosed",!1);f(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(V.ctx),this.isDraggable&&(V.ctx.lineWidth=Math.max(V.ctx.lineWidth,20)),V.ctx.isPointInStroke(this.path,t,e)):!1}isPointInAnywhere(t,e){return(s=>{if(!s)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 Os([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 s={};return typeof this.style=="string"?s=((o=e.style[this.style])==null?void 0:o.line)||i:typeof this.style=="object"?s=ct(JSON.parse(JSON.stringify(i)),this.style):s=i,t&&this.setBaseLineStyle(t,s.stroke),s}get computedValueScopeStyles(){return this.setOverlayStyles()}drawLine(t,e){const{mainCanvas:i,isInfinite:s,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=(s||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:s}=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=Ve(o,[-l[0],-l[1]],s.width,s.height),h=Ve(a,l,s.width,s.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 Ve(r,n,t,e){const[i,s]=r,[o,a]=n;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-s)/a:-s/a;c>0&&(l=Math.min(l,c))}return l===1/0?r:[i+o*l,s+a*l]}function Os(r,n,t,e){const i=Math.min(r[0],n[0]),s=Math.max(r[0],n[0]),o=Math.min(r[1],n[1]),a=Math.max(r[1],n[1]),l=[[i,o],[s,o],[s,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[p,v]=t;return p>=i&&p<=s&&v>=o&&v<=a}const d=1e-10;let m=!1,g=!1;for(const[p,v]of l){const w=c*p+h*v+u;if(Math.abs(w)<d||(w>d?m=!0:g=!0,m&&g))return!0}return m&&g}class zt extends je{constructor(t){super(t);f(this,"_isRect",!1);f(this,"dynamicBorderRadius");f(this,"_borderRadius");f(this,"_borderRadiusType","position");f(this,"isClosed",!0);f(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?V.ctx.isPointInPath(this.path,t,e):!1}isPointInStroke(t,e){return this.path&&this.mainCanvas?(this.setOverlayStyles(V.ctx),this.isDraggable&&(V.ctx.lineWidth=Math.max(V.ctx.lineWidth,20)),V.ctx.isPointInStroke(this.path,t,e)):!1}isPointInAnywhere(t,e){return(s=>{if(!s)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:s}=this;if(t<=0)return e?0:void 0;switch(s){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 s=i?2:3;i&&(Array.isArray(t)&&(t.length=2),Array.isArray(e)&&(e.length=2)),this.handleValuePosition("array2D",s)&&(this.updateHandlePoints(),this.updateDynamicRadius())}setOverlayStyles(t){var c;const e=this.isHover,i=this.mainCanvas,s=i.style[i.theme].polygon;let o={};typeof this.style=="string"?o=((c=i.style[this.style])==null?void 0:c.polygon)||s:typeof this.style=="object"?o=ct(JSON.parse(JSON.stringify(s)),this.style):o=s;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],[s,o]]=this.finalDynamicPosition,a=Math.abs(s-e),l=Math.abs(o-i),c=Math.min(e,s),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(d=>{var m;d.internalUpdate({style:u.point}),(m=d.getDraw())==null||m[0].call(d,t)})}drawPolygon(t){this.setGlobalAlpha(t);const e=this.finalDynamicPosition,i=this.setOverlayStyles(t);t.beginPath(),this.path=new Path2D,e.forEach((s,o)=>{this.path[o==0?"moveTo":"lineTo"](s[0],s[1])}),this.path.closePath(),t.stroke(this.path),t.fill(this.path),this.isShowHandlePoint=this.isClick&&this.isHandlePointsVisible,this.isShowHandlePoint&&this.handlePoints.forEach(s=>{var o;s.internalUpdate({style:i.point}),(o=s.getDraw())==null||o[0].call(s,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 pe extends V{constructor(t){super(t);f(this,"_isFill",!1);f(this,"_isClosed",!1);f(this,"_isClosedThroughCenter",!1);f(this,"_radiusValue",0);f(this,"_radiusPosition",0);f(this,"_startAngle",0);f(this,"_endAngle",0);f(this,"_counterclockwise",!1);f(this,"isShowHandlePoint",!1);f(this,"_isHandlePointsVisible",!0);f(this,"defaultClick",(t,e)=>{var o;if(!this.isHandlePointsVisible)return;const{state:i,oldState:s}=t.data;i!=s&&((o=this.notifyReload)==null||o.call(this))});f(this,"defaultDragg",(t,e)=>{if(!this.mainCanvas)return;const i=()=>{var h;const{offsetX:s,offsetY:o}=t.data,{x:a,y:l}=this.calculateOffset(s,o);this.handlePointsArr.concat(this).forEach(u=>{u.internalUpdate({value:[O.add(u.value[0],a.value),O.add(u.value[1],l.value)],position:[O.add(u.position[0],a.position),O.add(u.position[1],l.position)],dynamicPosition:[O.add(u.dynamicPosition[0],a.dynamicPosition),O.add(u.dynamicPosition[1],l.dynamicPosition)]},!0)}),(h=this.notifyReload)==null||h.call(this)};if(this.isHandlePointsVisible){const{start:s,end:o,radius:a}=this.handlePoints,l=this.handlePointsArr.find(c=>c.isHover);if(l){const c=t.data.offsetX;if(l==s)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()});f(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(s=>s.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?V.ctx.isPointInPath(this.path,t,e):!1}isPointInStroke(t,e){return this.path&&this.mainCanvas?(this.setOverlayStyles(V.ctx),this.isDraggable&&(V.ctx.lineWidth=Math.max(V.ctx.lineWidth,20)),V.ctx.isPointInStroke(this.path,t,e)):!1}isPointInAnywhere(t,e){return(s=>{if(!s)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,s=i.style[i.theme].arc;let o={};typeof this.style=="string"?o=((c=i.style[this.style])==null?void 0:c.arc)||s:typeof this.style=="object"?o=ct(JSON.parse(JSON.stringify(s)),this.style):o=s;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:s,endAngle:o,dynamicPosition:a,isHandlePointsVisible:l,offset:c}=this;if(!t||!a||!l)return;const[h,u]=Ns(...e,i,s,o,t.axisConfig.x,t.axisConfig.y),d=w=>new lt({name:w,offset:c,isDraggable:!0,mainCanvas:this.mainCanvas,notifyReload:()=>{var _;return(_=this.notifyReload)==null?void 0:_.call(this)}}),m=this.handlePoints.start||d("start"),g=this.handlePoints.end||d("end"),p=this.handlePoints.radius||d("radius");m.value=h,g.value=u;const v=e[0]+i*2*t.axisConfig.x;p.value=[v,e[1]],this.handlePoints={start:m,end:g,radius:p}}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,s){this.setBaseLineStyle(t,{...s.stroke,dash:!s.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,s.point.radius,0,Math.PI*2),t.fill())}draw(t){const{finalDynamicPosition:e,mainCanvas:i,startAngle:s,endAngle:o,counterclockwise:a,isFill:l,isClosed:c,isClosedThroughCenter:h,radiusPosition:u}=this;if(!i||u<=0)return;this.setGlobalAlpha(t);const d=this.setOverlayStyles(t),[m,g]=e;t.beginPath(),this.path=new Path2D,this.path.arc(m,g,u*i.percentage,s,o,a),c&&(this.path.lineTo(m,g),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,g,d),this.handlePointsArr.forEach(p=>{var v;p.internalUpdate({style:d.point}),(v=p.getDraw())==null||v[0].call(p,t)}))}getDraw(){if(this.isNeedRender){if(this.isRecalculate){const{position:t,mainCanvas:e}=this,i=this.dynamicPosition,s=e.transformPosition(t);if(this.internalUpdate({dynamicPosition:s}),this.isHandlePointsVisible)if(e!=null&&e.isScaleUpdated)this.updateHandlePoints();else{const o=s[0]-i[0],a=s[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 Ns(r,n,t,e,i,s=1,o=1){const a=r+t*Math.cos(e)*s,l=n+t*Math.sin(e)*o,c=r+t*Math.cos(i)*s,h=n+t*Math.sin(i)*o;return[[a,l],[c,h]]}class ge extends V{constructor(t){super(t);f(this,"handlePoints");f(this,"isShowHandlePoint",!1);f(this,"_isHandlePointsVisible",!0);f(this,"_radiusValue",0);f(this,"_radiusPosition",0);f(this,"defaultClick",(t,e)=>{var o;if(!this.isHandlePointsVisible)return;const{state:i,oldState:s}=t.data;i!=s&&((o=this.notifyReload)==null||o.call(this))});f(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,s)=>(i.isHover||i==t?0:1)-(s.isHover||s==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(V.ctx),this.isDraggable&&(V.ctx.lineWidth=Math.max(V.ctx.lineWidth,20)),V.ctx.isPointInStroke(this.path,t,e)):!1}isPointInAnywhere(t,e){return(s=>{if(!s)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 s={};return typeof this.style=="string"?s=((o=e.style[this.style])==null?void 0:o.arcTo)||i:typeof this.style=="object"?s=ct(JSON.parse(JSON.stringify(i)),this.style):s=i,t&&this.setBaseLineStyle(t,s.stroke),s}get computedValueScopeStyles(){return this.setOverlayStyles()}updateHandlePoints(){var c,h;let{value:t,position:e,dynamicPosition:i,isHandlePointsVisible:s}=this;if(!i||!s)return;const o=()=>new lt({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,d)=>{a[d]||a.push(o()),a[d].internalUpdate({value:t[d],position:e[d],dynamicPosition:i[d]},!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,s]=[Mt(t)&&t.length>1,Mt(e)&&e.length>1];if(!i&&!s)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:s}=this}getDraw(){if(this.isNeedRender){if(this.isRecalculate){const{position:t,mainCanvas:e}=this,i=this.dynamicPosition,s=e.transformPosition(t);if(this.internalUpdate({dynamicPosition:s}),this.isHandlePointsVisible)if(e!=null&&e.isScaleUpdated)this.updateHandlePoints();else{const o=s[0][0]-i[0][0],a=s[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 As extends ks{constructor(t){super(t);f(this,"resizeObserver");f(this,"currentDrawOverlays",[]);f(this,"rely","");f(this,"maxMinValue",{minXV:0,maxXV:0,minYV:0,maxYV:0});f(this,"measureRedrawPerformance",He(()=>{this.isRendering=!0,this.redraw(),this.redrawInNextRenderFrame=!1,this.isRendering=!1},[[1,"#F56C6C"],[.5,"#E6A23C"],[0,"#67C23A"]]));this.canvas&&(this.resizeObserver=new ResizeObserver(we(()=>{[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:s}=this,o=[t.x,t.y,e,JSON.stringify(s),i.width,i.height].join();this.isRecalculate=this.rely!==o,this.rely=o}redraw(){var s,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=(s=this.drawAxis)==null?void 0:s.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],d])=>{t.push([[h+c,u],d])})}),t.sort(([[a,l],c],[[h,u],d])=>{if(a!==h)return h-a;if(l!==u)return u-l;const m=g=>g instanceof Gt?5:g instanceof Xt?4:g instanceof lt?3:g instanceof Yt||g instanceof pe||g instanceof ge?2:g instanceof zt?1:0;return m(d)-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:s,clientY:o}=t,{x:a,y:l}=this.axisConfig,c=this.getMousePositionOnAxis({clientX:s-10*a,clientY:o-10*l}),h=this.getMousePositionOnAxis({clientX:s+10*a,clientY:o+10*l}),u=this.getAxisValueByPoint(c.x,c.y),d=this.getAxisValueByPoint(h.x,h.y);return[...this.currentDrawOverlays].sort((m,g)=>(m.isDraggable&&m.isClick?0:1)-(g.isDraggable&&g.isClick?0:1)).find(m=>{const g=m.valueScope;return g&&(g.maxX<u.xV||g.minX>d.xV||g.maxY<u.yV||g.minY>d.yV)?!1:m.isPointInAnywhere(e,i)})}destroy(){var t;(t=this.resizeObserver)==null||t.disconnect()}}class Is extends As{constructor(t){super(t);f(this,"mouseInCanvas",!1);f(this,"mouseIsDown",!1);f(this,"mouseLastPosition",{x:0,y:0});f(this,"unBind");f(this,"lastClickedOverlay");f(this,"lockNotifyClick",!1);f(this,"lastContextmenuOverlay");f(this,"defaultContextmenu",(t,e)=>{const i=this.lastClickedOverlay;i!=null&&i.isDraggable&&i.notifyClick(!1,e)});f(this,"lastPressedKey",{key:"",keyupTime:0,doubleClick:!1});f(this,"defaultWheel",(t,e)=>{this.setScale(e,t.data),this.redrawOnce()});f(this,"lastDownOverlay");f(this,"defaultDown",(t,e)=>{(e==null?void 0:e.button)==0&&(this.mouseIsDown=!0)});f(this,"lastHoverOverlay");f(this,"lastCursorStyle");f(this,"oldClientX",[]);f(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:s,target:o=t})=>{o.addEventListener(i,s)}),this.unBind=()=>{e.forEach(({type:i,handler:s,target:o=t})=>{o.removeEventListener(i,s)})}}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:s,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)&&(Mt(c.value)?"Matrix":ee(c.value)?"Single":!1),d=(v,w)=>{if(!u)return i.x+=v*l,i.y+=w*l,!0;const _=this.getAxisValueByPoint(l,0).xV,[C,E]=[_*o.x,_*o.y];if(u==="Single"){const N=c.value;N[0]+=v*C,N[1]+=w*E}else c.value.forEach(N=>{N[0]+=v*C,N[1]+=w*E});return c.value=[...c.value],!0},m=v=>(this.setScale("center",v*s),!0),p={ArrowUp:()=>d(0,-1),ArrowDown:()=>d(0,1),ArrowLeft:()=>d(-1,0),ArrowRight:()=>d(1,0),"+":()=>m(1),"-":()=>m(-1)}[a];p!=null&&p()&&(this.redrawOnce(),t.preventDefault())}keyup(t){const{mouseInCanvas:e,lastPressedKey:i}=this;if(e){const s=t.key;i.key=s,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 s=t.deltaY<0?e:-e,o=this.findOverlayByPoint(t);o==null||o.notifyWheel(s,t),this.notifyWheel(s,t)}mousedown(t){var o;if(!this.isDownable)return;const{clientX:e,clientY:i}=t;this.mouseLastPosition={x:e,y:i};const s=this.findOverlayByPoint(t);this.lastDownOverlay!=s&&((o=this.lastDownOverlay)==null||o.notifyDown(!1,t),s==null||s.notifyDown(!0,t)),this.lastDownOverlay=s,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{lastDownOverlay:e}=this;if(!this.isDraggable)return;e!=null&&e.isDraggable?this.notifyDraggOverlays(t):this.handleCanvasPan(t);const{clientX:i,clientY:s}=t;this.mouseLastPosition={x:i,y:s},this.lockNotifyClick=!0}notifyDraggOverlays(t){const e=this.lastDownOverlay,{mouseLastPosition:i}=this,{clientX:s,clientY:o}=t;e.notifyDragg({offsetX:s-i.x,offsetY:o-i.y},t)}handleCanvasPan(t){const{clientX:e,clientY:i}=t,{offset:s,mouseLastPosition:o}=this,a=e-o.x,l=i-o.y;s.x+=a,s.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 s=t==null?void 0:t.cursorStyle;s!==this.lastCursorStyle&&(this.lastCursorStyle&&this.canvas.classList.remove(this.lastCursorStyle),s&&this.canvas.classList.add(s),this.lastCursorStyle=s);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:s,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-s[0],this.redrawOnce()),this.oldClientX=[h],this.oldClientY=[u]}else if(e.length===2){const{clientX:h,clientY:u}=e[0],{clientX:d,clientY:m}=e[1];if(i.length==2){const g=ye(i[0],s[0],i[1],s[1]),p=ye(h,u,d,m),{x:v,y:w}=be(h,u,d,m);this.setScale({clientX:v,clientY:w},p>g?a:-a),this.redrawOnce()}this.oldClientX=[h,d],this.oldClientY=[u,m]}}}destroy(){var t;super.destroy(),(t=this.unBind)==null||t.call(this)}}class et extends Nt{constructor(t){super(t);f(this,"overlays",new Set);this.setNotifyReload(t.notifyReload)}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.shouldRender()&&this.overlays.size)&&t()}:void 0,this.overlays.forEach(e=>e.setNotifyReload(this.notifyReload))}addOverlays(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)}removeOverlays(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)}clearOverlays(){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 it extends Nt{constructor(t){super(t);f(this,"zIndex",4);f(this,"canvas",document.createElement("canvas"));f(this,"ctx",this.canvas.getContext("2d"));f(this,"isReload",!1);f(this,"groups",new Map);f(this,"currentDrawOverlays",[]);this.setNotifyReload(t.notifyReload)}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.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 et&&(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(s=>{s instanceof et&&(this.groups.delete(s.name),s.setNotifyReload(),s.setMainCanvas(),s.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))}setzIndex(t){var e;t!=this.zIndex&&(this.zIndex=t,(e=this.notifyReload)==null||e.call(this,!1))}getCanvas(){if(!this.mainCanvas)return;const{rect:t,isThemeUpdated:e}=this.mainCanvas,i=this.shouldRender(),s=this.groups.size;if(i&&s){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 Rt extends Nt{constructor(t){super(t);f(this,"layers",new Map);f(this,"defaultContextmenu",(t,e)=>t.stopPropagation());f(this,"defaultClick",(t,e)=>t.stopPropagation());f(this,"defaultDoubleClick",(t,e)=>t.stopPropagation());f(this,"defaultHover",(t,e)=>t.stopPropagation());f(this,"defaultDragg",(t,e)=>t.stopPropagation());f(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)}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.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 it&&(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(s=>{s instanceof it&&(this.layers.delete(s.name),s.setNotifyReload(),s.setMainCanvas(),s.parent=void 0,e=!0)}),e&&((i=this.notifyReload)==null||i.call(this))}clearLayers(){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 Hs extends Is{getDefaultOverlayGroup(){var a,l,c,h,u;const n=this.layerGroups.get("默认图层群组");if(!n)return;const t=(a=n.getLayer("点位图层"))==null?void 0:a.getGroup("点位覆盖物群组"),e=(l=n.getLayer("线段图层"))==null?void 0:l.getGroup("线段覆盖物群组"),i=(c=n.getLayer("多边形图层"))==null?void 0:c.getGroup("多边形覆盖物群组"),s=(h=n.getLayer("文字图层"))==null?void 0:h.getGroup("文字覆盖物群组"),o=(u=n.getLayer("自定义绘制图层"))==null?void 0:u.getGroup("自定义绘制覆盖物群组");return{overlays_text:s,overlays_point:t,overlays_line:e,overlays_polygon:i,overlays_custom:o}}getAllOverlays(n){const t=[],e=n!==void 0?Array.isArray(n)?[...n]:[n]:Array.from(this.layerGroups.values());for(;e.length>0;){const i=e.pop();if(i instanceof Rt){if(!i.isVisible)continue;e.push(...i.layers.values())}else if(i instanceof it){if(!i.isVisible)continue;e.push(...i.groups.values())}else if(i instanceof et){if(!i.isVisible)continue;e.push(...i.overlays.values())}else i.isVisible&&t.push(i)}return t}}class Ls extends Hs{zoom(n){const{canvas:t,rect:e}=this;if(!t||!e)return console.error("canvas is not HTMLCanvasElement");this.setScale("center",n),this.redrawOnce()}zoomIn(){this.zoom(this.delta)}zoomOut(){this.zoom(-this.delta)}setStyle(n){super.setStyle(n),this.redrawOnce()}setTheme(n){super.setTheme(n),this.redrawOnce()}setAxis(n){super.setAxis(n),this.redrawOnce()}setDefaultCenter(n){super.setDefaultCenter(n),this.redrawOnce()}}class Ts extends Ls{setFitView(n=void 0,t=!1,e=[60,60,60,60],i){const s=this.getAllOverlays(n);if(s.length===0)return;const{minX:o,maxX:a,minY:l,maxY:c}=this.calculateBoundingBox(s),h=a-o,u=c-l,d=this.calculateOptimalScale(h,u,e,i),m=this.calculateOffsetDifference(o,a,l,c,e);d==this.scale&&m.x==0&&m.y==0||(t?this.applyTransformImmediately(d,m):this.animateTransform(d,m))}calculateBoundingBox(n){let t=1/0,e=-1/0,i=1/0,s=-1/0;for(const o of n){const a=o.valueScope;t=Math.min(t,a.minX),e=Math.max(e,a.maxX),i=Math.min(i,a.minY),s=Math.max(s,a.maxY)}return{minX:t,maxX:e,minY:i,maxY:s}}calculateOptimalScale(n,t,e,i){const{cycle:s,delta:o,axisConfig:a,rect:l}=this,{width:c,height:h}=l,u=Math.max(0,c-e[1]-e[3])||c,d=Math.max(0,h-e[0]-e[2])||h;if(u<=0||d<=0)return console.warn("无效的可视区域尺寸,边距设置可能不合理"),this.scale;const m=n/u,g=t/d,p=Math.max(m,g),v=a.count,w=v/a.min,_=s*o;let C;if(p>w){const E=Math.ceil(p/w);C=1-((v*E/p-a.min)/a.min+(E-2))*_}else{const E=(dt,rt,vt)=>dt<rt?vt-1:E(dt/2,rt,vt+1),N=E(w,p,0),G=Math.pow(2,N);C=1+((v/G/p-a.min)/a.min+N)*_}return i!==void 0&&(C=Math.min(i,C)),C=new R(C).div(o).round().mul(o).toNumber(),C}calculateOffsetDifference(n,t,e,i,s){const{width:o,height:a}=this.rect,{axisConfig:l,center:c}=this,h=(t+n)/2,u=(i+e)/2,d=this.getAxisPointByValue(h,u),m=this.getAxisValueByPoint((o/2-c.x)*l.x,(a/2-c.y)*l.y),g=this.getAxisPointByValue(m.xV,m.yV);return{x:Math.round(-(d.x+(s[3]-s[1])-g.x)*l.x),y:Math.round(-(d.y+(s[0]-s[2])-g.y)*l.y)}}applyTransformImmediately(n,t){this.offset={x:this.offset.x+t.x,y:this.offset.y+t.y},this.scale=n,this.updateSize(),this.redrawOnce()}animateTransform(n,t){const e=this.scale,i={...this.offset},s=300;this.isAuto=!0;const o=()=>this.isAuto=!1;(c=>this.animateOffset(i,t,s,c||o))(c=>this.animateScale(e,n,s,c||o))}animateScale(n,t,e,i){const s=t-n;let o=0;kt(a=>{!this.isAuto||!this.canvas||!this.isInteractive||(this.setScale("center",(a-o)*s),o=a,this.redrawOnce(),a===1&&i())},e)}animateOffset(n,t,e,i){kt(s=>{!this.isAuto||!this.canvas||!this.isInteractive||(this.offset={x:Number((n.x+t.x*s).toFixed(0)),y:Number((n.y+t.y*s).toFixed(0))},this.redrawOnce(),s===1&&i())},e)}returnToOrigin(){if(!this.isInteractive||this.scale==this.defaultScale&&this.offset.x==0&&this.offset.y==0)return;const{rect:n,axisConfig:t}=this,e=this.getDefaultCenterLocation(),i=(n.width/2-e.x)*t.x,s=(n.height/2-e.y)*t.y,o=this.getAxisValueByPoint(i,s,!0),a=this.getMousePositionOnAxis({clientX:n.x+n.width/2,clientY:n.y+n.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 Fs extends Ts{toggleAxis(n){this.drawAxis.toggleAxis(n),this.redrawOnce()}togglePoint(n){const{overlays_point:t}=this.getDefaultOverlayGroup()||{};return t?(t.isVisible=n??!t.isVisible,this.redrawOnce(),t.isVisible):!1}toggleLine(n){const{overlays_line:t}=this.getDefaultOverlayGroup()||{};return t?(t.isVisible=n??!t.isVisible,this.redrawOnce(),t.isVisible):!1}togglePolygon(n){const{overlays_polygon:t}=this.getDefaultOverlayGroup()||{};return t?(t.isVisible=n??!t.isVisible,this.redrawOnce(),t.isVisible):!1}toggleLock(n){return this.isInteractive=n??!this.isInteractive,this.isInteractive}}class Bs extends Fs{static clearPathRegion(n,t){const{width:e,height:i}=n.canvas;n.save(),n.beginPath(),n.clip(t),n.clearRect(0,0,e,i),n.restore()}}class Us extends Bs{}class Gs{constructor(n){f(this,"canvas");f(this,"axis_canvas",document.createElement("canvas"));f(this,"ctx",this.axis_canvas.getContext("2d"));f(this,"isReload",!0);f(this,"show",{all:!0,grid:{main:!0,secondary:!0},axis:!0,axisText:!0});this.canvas=n,this.initAxisCanvas()}initAxisCanvas(){const{canvas:n,axis_canvas:t}=this;n&&(t.width=n.rect.width||0,t.height=n.rect.height||0)}toggleAxis(n){const t=(()=>{if(typeof n=="object"){const{all:e=!0,grid:i={main:!0,secondary:!0},axis:s=!0,axisText:o=!0}=n;return Object.assign({main:!0,secondary:!0},i),{all:e,grid:i,axis:s,axisText:o}}return typeof n=="boolean"?{all:!0,grid:{main:n,secondary:n},axis:n,axisText:n}:!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:n,style:t}=this.canvas;return(t[n]||t.light).grid}drawGrid(){const{canvas:n,ctx:t}=this,{rect:e,center:i,axisConfig:s}=n,{width:o,height:a}=e,l=this.color(),c=s.size,h=c/5;t.lineWidth=1;const u=(m,g)=>{const p=i.x%m>0?i.x%m:m+i.x%m;t.strokeStyle=g,t.beginPath();for(let v=0;v*m+p<=o;v++)t.moveTo(v*m+p,0),t.lineTo(v*m+p,a);t.stroke()},d=(m,g)=>{const p=i.y%m>0?i.y%m:m+i.y%m;t.strokeStyle=g,t.beginPath();for(let v=0;v*m+p<=a;v++)t.moveTo(0,v*m+p),t.lineTo(o,v*m+p);t.stroke()};this.show.grid.secondary&&(u(h,l.innerGrid),d(h,l.innerGrid)),this.show.grid.main&&(u(c,l.grid),d(c,l.grid))}drawAxis(){const{canvas:n,ctx:t}=this,{rect:e,center:i}=n,{width:s,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(s,i.y),t.stroke())},c=()=>{i.x>=0&&i.x<=s&&(t.beginPath(),t.moveTo(i.x,0),t.lineTo(i.x,o),t.stroke())};l(),c()}drawText(n,t,e,i){const{canvas:s,ctx:o}=this,{theme:a}=s,l=this.canvas.style[a].text;o.font=`${l.bold?"bold":""} ${l.size}px ${l.family}`,o.strokeStyle=l.stroke,![n,t,e].includes(void 0)&&o.strokeText(n,t,e),o.fillStyle=l[i?"secondary":"color"],![n,t,e].includes(void 0)&&o.fillText(n,t,e)}drawAxisText(){const{canvas:n,ctx:t}=this,{rect:e,center:i,axisConfig:s,style:o,theme:a}=n,{width:l,height:c}=e;this.drawText();const h=p=>Math.ceil(t.measureText(p).width),u=4,d=o[a].text.size;{const p=h("0"),v=i.x<u||i.x>l+p+u,w=i.y<-(u+d)||i.y>c+d+u;!v&&!w&&this.drawText("0",i.x-p-u,i.y+d+u)}const m=n.getNowGridCount,g=s.size;{let p=i.y+d+u;p=Math.max(Math.min(p,c-u),u+d);const v=i.y>c||i.y<0;let w=i.x>0?i.x%g:i.x<0?g+i.x%g:0,_=n.getAxisValueByPoint((w-i.x)*s.x,0).xV;for(;w<=l;){const C=Wt(_),E=h(C);_!==0&&this.drawText(C,w-E/2,p,v),w+=g,_=new R(m).mul(s.x).add(_).toNumber()}}{const p=i.x>l||i.x<0;let v=i.y>0?i.y%g:i.y<0?g+i.y%g:0,w=n.getAxisValueByPoint(0,(v-i.y)*s.y).yV;for(;v<=c;){const _=Wt(w),C=h(_);let E=i.x-C-u;E=Math.max(Math.min(E,l-C-u),u),w!=0&&this.drawText(_,E,v+d/2,p),v+=g,w=new R(m).mul(s.y).add(w).toNumber()}}}}function Tt(r){return[r].flat(1/0)}class Y extends Us{constructor(n){super(n),this.drawAxis=new Gs(this),"axisShow"in n&&this.toggleAxis(n.axisShow),this.initLayerGroups(),this.updateCenter()}initLayerGroups(){const n=new it({name:"多边形图层"});n.addGroup(new et({name:"多边形覆盖物群组"})),n.setzIndex(1);const t=new it({name:"线段图层"});t.addGroup(new et({name:"线段覆盖物群组"})),t.setzIndex(2);const e=new it({name:"点位图层"});e.addGroup(new et({name:"点位覆盖物群组"})),e.setzIndex(3);const i=new it({name:"文字图层"});i.addGroup(new et({name:"文字覆盖物群组"})),i.setzIndex(4);const s=new it({name:"自定义绘制图层"});s.addGroup(new et({name:"自定义绘制覆盖物群组"})),s.setzIndex(5);const o=new Rt({name:"默认图层群组"});o.addLayer([i,e,t,n,s]),this.setLayerGroup(o)}gteLayerGroups(n="默认图层群组"){return this.layerGroups.get(n)}setLayerGroup(n){n instanceof Rt&&(this.layerGroups.set(n.name,n),n.setNotifyReload(()=>this.redrawOnce()),n.setMainCanvas(this),n.parent=this)}removeLayerGroup(n){n instanceof Rt&&(this.layerGroups.delete(n.name),n.setNotifyReload(),n.setMainCanvas(),n.parent=void 0,this.redrawOnce())}addLayer(n){const t=this.layerGroups.get("默认图层群组");t&&t.addLayer(Tt(n))}removeLayer(n){const t=this.layerGroups.get("默认图层群组");t&&t.removeLayer(Tt(n))}addOverlay(n){const{overlays_text:t,overlays_point:e,overlays_line:i,overlays_polygon:s,overlays_custom:o}=this.getDefaultOverlayGroup()||{};Tt(n).forEach(a=>{a instanceof Xt?t==null||t.addOverlays(a):a instanceof lt?e==null||e.addOverlays(a):a instanceof Yt||a instanceof pe||a instanceof ge?i==null||i.addOverlays(a):a instanceof zt?s==null||s.addOverlays(a):a instanceof Gt&&(o==null||o.addOverlays(a))})}removeOverlay(n){const{overlays_text:t,overlays_point:e,overlays_line:i,overlays_polygon:s,overlays_custom:o}=this.getDefaultOverlayGroup()||{};Tt(n).forEach(a=>{a instanceof Xt?t==null||t.removeOverlays(a):a instanceof lt?e==null||e.removeOverlays(a):a instanceof Yt?i==null||i.removeOverlays(a):a instanceof zt?s==null||s.removeOverlays(a):a instanceof Gt&&(o==null||o.addOverlays(a))})}destroy(){super.destroy()}}f(Y,"LayerGroup",Rt),f(Y,"Layer",it),f(Y,"OverlayGroup",et),f(Y,"Text",Xt),f(Y,"Point",lt),f(Y,"Line",Yt),f(Y,"Polygon",zt),f(Y,"Custom",Gt),f(Y,"Arc",pe),f(Y,"ArcTo",ge);function Xs(r){const n=we(r,100);let t=0,e=0;return function(i){const s=i.target;if(!s||!(s instanceof Element))return;const{scrollTop:o,scrollHeight:a,clientHeight:l,scrollLeft:c,scrollWidth:h,clientWidth:u}=s;function d(){if(t==o)return;const g=t>o;if(t=o,g)return;a-o-l<=1&&n("vertical")}function m(){if(e==c)return;const g=e>c;if(e=c,g)return;h-c-u<=1&&n("horizontal")}d(),m()}}function Ys(r,n,t){const{isClickAllowed:e,uiLibrary:i=["naiveUI","ElementPlus","Element"]}=t||{},s=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(){n(),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(s).some(u=>!!(c!=null&&c.closest(u)))||o()}requestAnimationFrame(()=>document.addEventListener("mousedown",a))}var z,ft,mt,Pt,xt,Z,Q,st,bt;class zs{constructor(){A(this,z);A(this,ft,!1);A(this,mt,{});A(this,Pt,0);A(this,xt,0);A(this,Z,0);A(this,Q,0);A(this,st);A(this,bt)}init(n,t){D(this,z,n),D(this,st,t==null?void 0:t.limit),D(this,bt,t==null?void 0:t.dragDom),D(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(n){const t=n==="bind"?"addEventListener":"removeEventListener";if(!P(this,z))return console.error("No DOM");P(this,z)[t]("mousedown",P(this,mt).mousedown),document[t]("mousemove",P(this,mt).mousemove),document[t]("mouseup",P(this,mt).mouseup)}alterLocation(){if(!P(this,z))return console.error("No DOM");P(this,st)&&(D(this,Z,Math.min(P(this,Z),P(this,st).max.top)),D(this,Z,Math.max(P(this,Z),P(this,st).min.top)),D(this,Q,Math.min(P(this,Q),P(this,st).max.left)),D(this,Q,Math.max(P(this,Q),P(this,st).min.left))),P(this,z).style.setProperty("--top",P(this,Z)+"px"),P(this,z).style.setProperty("--left",P(this,Q)+"px")}mousedown(n){if(!P(this,z))return console.error("No DOM");if(P(this,bt)&&n.target!=P(this,bt))return;document.body.classList.add("no-select"),D(this,ft,!0);const t=P(this,z).getBoundingClientRect(),{pageX:e,pageY:i}=n;D(this,Pt,e),D(this,xt,i),D(this,Z,t.y),D(this,Q,t.x)}mousemove(n){const{pageX:t,pageY:e}=n;P(this,ft)&&(D(this,Z,P(this,Z)+(e-P(this,xt))),D(this,Q,P(this,Q)+(t-P(this,Pt))),D(this,Pt,t),D(this,xt,e),this.alterLocation())}mouseup(){P(this,ft)&&(D(this,ft,!1),document.body.classList.remove("no-select"))}}z=new WeakMap,ft=new WeakMap,mt=new WeakMap,Pt=new WeakMap,xt=new WeakMap,Z=new WeakMap,Q=new WeakMap,st=new WeakMap,bt=new WeakMap;var W,pt,gt,_t,Ct,q,j,B,St,Et;class Ws{constructor(){A(this,W);A(this,pt,!1);A(this,gt,{});A(this,_t,0);A(this,Ct,0);A(this,q,0);A(this,j,0);A(this,B);A(this,St);A(this,Et)}init(n,t={}){D(this,W,n),D(this,B,t.limit),D(this,St,t.update_move),D(this,Et,t.update_up),D(this,gt,{mousedown:this.mousedown.bind(this),mousemove:this.mousemove.bind(this),mouseup:this.mouseup.bind(this)}),this.bindOrUnbindEvent("bind")}finish(){this.bindOrUnbindEvent("unbind")}bindOrUnbindEvent(n){const t=n==="bind"?"addEventListener":"removeEventListener";if(!P(this,W))return console.error("No DOM");P(this,W)[t]("mousedown",P(this,gt).mousedown),document[t]("mousemove",P(this,gt).mousemove),document[t]("mouseup",P(this,gt).mouseup)}updateValue(){const n={top:P(this,q),left:P(this,j),percentage:{top:0,left:0}};if(P(this,B)){const t=e=>P(this,B)?(n[e]-P(this,B).min[e])/(P(this,B).max[e]-P(this,B).min[e]):0;n.percentage={top:t("top")||0,left:t("left")||0}}return n}alterLocation(){if(!P(this,W))return console.error("No DOM");P(this,B)&&(D(this,q,Math.min(P(this,q),P(this,B).max.top)),D(this,q,Math.max(P(this,q),P(this,B).min.top)),D(this,j,Math.min(P(this,j),P(this,B).max.left)),D(this,j,Math.max(P(this,j),P(this,B).min.left))),P(this,St)&&P(this,St).call(this,this.updateValue()),P(this,W).style.setProperty("--top",P(this,q)+"px"),P(this,W).style.setProperty("--left",P(this,j)+"px")}mousedown(n){if(!P(this,W))return console.error("No DOM");document.body.classList.add("no-select"),D(this,pt,!0);const t=P(this,W).getBoundingClientRect();D(this,Ct,t.y),D(this,_t,t.x);const{pageX:e,pageY:i}=n;D(this,q,i-P(this,Ct)),D(this,j,e-P(this,_t)),this.alterLocation()}mousemove(n){const{pageX:t,pageY:e}=n;P(this,pt)&&(D(this,q,e-P(this,Ct)),D(this,j,t-P(this,_t)),this.alterLocation())}mouseup(){P(this,pt)&&(D(this,pt,!1),document.body.classList.remove("no-select"),P(this,Et)&&P(this,Et).call(this,this.updateValue()))}}W=new WeakMap,pt=new WeakMap,gt=new WeakMap,_t=new WeakMap,Ct=new WeakMap,q=new WeakMap,j=new WeakMap,B=new WeakMap,St=new WeakMap,Et=new WeakMap;function re(r){if(typeof r=="string"){const n=document.querySelector(r);if(!n)throw new Error(`Element "${r}" not found`);return n}else return r||document.documentElement}function $e(r){const n=re(r);return n.requestFullscreen?n.requestFullscreen():n.mozRequestFullScreen?n.mozRequestFullScreen():n.webkitRequestFullscreen?n.webkitRequestFullscreen():n.msRequestFullscreen?n.msRequestFullscreen():Promise.reject("No Fullscreen API")}function Ze(){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 xe(r){const n=re(r),t=document,e=document.fullscreenElement||t.webkitFullscreenElement||t.mozFullScreenElement||t.msFullscreenElement;return n==e||!r&&window.innerWidth==screen.width&&window.innerHeight==screen.height}function qs(r){return r=re(r),function(){xe(r)?Ze():$e(r)}}function js(r,n){const t=re(n),e=()=>{r(xe(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)}}function $s(r,n){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,n=n||document.body,n.appendChild(t);const e=t.getBoundingClientRect().width;return n.removeChild(t),e}function Zs(r,n){if(!r)return;let t,e;if(typeof n=="string"){const s=document.querySelector(n);if(!s)return;const o=s.getBoundingClientRect();t=o.width,e=o.height}else if(Array.isArray(n))t=n[0],e=n[1];else{const s=n.getBoundingClientRect();t=s.width,e=s.height}const i=t/e;return i>r?[r*e,e]:i<r?[t,t/r]:[t,e]}function Qs(r,n=5e3){return new Promise((t,e)=>{const i=new Image;i.src=r;const s=setTimeout(()=>{e(new Error("图片加载超时")),i.onload=null,i.onerror=null},n);i.onload=()=>{clearTimeout(s);const o=i.naturalWidth,a=i.naturalHeight,l=o/a;t([i,l])},i.onerror=()=>{clearTimeout(s),e(new Error("图片加载失败"))},i.crossOrigin="Anonymous"})}function Js(r){const t=document.getElementById(r).querySelectorAll("img"),e=t.length,i=[];let s=0;return e===0?Promise.resolve({allLoaded:!0,loaded:0,failed:0,total:0,errors:[]}):new Promise(o=>{const a=()=>{s===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),s++,a();return}l.addEventListener("load",()=>{s++,a()},{once:!0}),l.addEventListener("error",()=>{i.push(l),s++,a()},{once:!0})})})}function Ks(r){return new Promise((n,t)=>{fetch(r).then(e=>n(e.text())).catch(e=>{console.error("Error fetching :",e),t(e)})})}function Qe(r){const{href:n,fileName:t,onProgress:e,timeout:i=3e4,autoDownload:s=!0}=r;let o,a=!1,l=null,c;const h=t||qt(n,"downloaded_file");c=decodeURIComponent(h);const u=()=>{if(!l)return;const p=URL.createObjectURL(l),v=document.createElement("a");v.href=p,v.download=c,v.click(),URL.revokeObjectURL(p)};return{promise:new Promise((p,v)=>{try{o=new XMLHttpRequest,o.open("GET",n),o.responseType="blob",o.timeout=i,o.ontimeout=()=>{a||v(new Error(`请求超时(已超过${i/1e3}秒)`))},o.addEventListener("progress",w=>{if(w.lengthComputable&&!a){const _=w.loaded/w.total*100;e==null||e(Number(_.toFixed(2)))}}),o.addEventListener("load",()=>{a||(o.status>=200&&o.status<300?(l=o.response,s&&u(),p(o.response)):v(new Error(`下载失败,状态码: ${o.status}`)))}),o.addEventListener("error",()=>{a||v(new Error("网络错误,下载失败"))}),o.addEventListener("abort",()=>{a||(a=!0,v(new Error("下载已被中止")))}),o.send()}catch(w){a||v(w)}}),abort:()=>!a&&o.abort(),download:()=>{!a&&l&&u()}}}function tn(r,n,t){if(!t){let s=n.replace(/^[^.]+./,"");s=s==n?"text/plain":"application/"+s,t={type:s}}const e=new Blob(r,t),i=URL.createObjectURL(e);Qe({href:i,fileName:n})}const en=Math.PI/2,Kt=Math.PI/180,te=6378137,sn=85.05112878;function nn(r,n){const t=Math.max(Math.min(r,180),-180),e=Math.max(Math.min(n,sn),-85.05112878),i=t*Kt*te,s=e*Kt,o=Math.log(Math.tan(Math.PI/4+s/2))*te;return[i,o]}function rn(r,n){const t=r/te/Kt,e=(2*Math.atan(Math.exp(n/te))-en)/Kt;return[t,e]}function Je(r,n,t){const[e,i]=r,[s,o]=n,[a,l]=t,c=(a-s)**2+(l-o)**2;if(c===0)return Math.sqrt((e-s)**2+(i-o)**2);let h=((e-s)*(a-s)+(i-o)*(l-o))/c;return h=Math.max(0,Math.min(1,h)),Math.sqrt((e-(s+h*(a-s)))**2+(i-(o+h*(l-o)))**2)}function on(r,n,t,e,i,s=1,o=1){const a=r+t*Math.cos(e)*s,l=n+t*Math.sin(e)*o,c=r+t*Math.cos(i)*s,h=n+t*Math.sin(i)*o;return[[a,l],[c,h]]}function ye(r,n,t,e){return Math.hypot(Math.abs(t-r),Math.abs(e-n))}function be(r,n,t,e){const i=(r+t)/2,s=(n+e)/2;return{x:i,y:s}}function an(r,n,t,e){const[i,s]=r,[o,a]=n;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-s)/a:-s/a;c>0&&(l=Math.min(l,c))}return l===1/0?r:[i+o*l,s+a*l]}const ln=new Set(["sin","cos","tan","asin","acos","atan","atan2"]),cn=new Proxy(Math,{get(r,n){return ln.has(n)?function(...t){const e=t.map(i=>i/180*Math.PI);return r[n](...e)}:r[n]},set(){throw new Error("DegreeMath 是只读的,不能修改属性")},deleteProperty(){throw new Error("DegreeMath 是只读的,不能删除属性")}});class wt{constructor(n,t){f(this,"resolve");f(this,"reject");this.resolve=n,this.reject=t}run(n){var t,e;return n instanceof Promise?n.then(i=>{var s;return(s=this.resolve)==null||s.call(this),i}).catch(i=>{var s;return(s=this.reject)==null||s.call(this),Promise.reject(i)}):n?(t=this.resolve)==null||t.call(this):(e=this.reject)==null||e.call(this),n}}class hn extends wt{constructor(n){super(),this.resolve=n}warning(...n){const t=()=>{var e,i;return(i=(e=yt.tips).warning)==null?void 0:i.call(e,...n)};return new wt(this.resolve,t)}error(...n){const t=()=>{var e,i;return(i=(e=yt.tips).error)==null?void 0:i.call(e,...n)};return new wt(this.resolve,t)}}class un extends wt{constructor(n){super(),this.reject=n}info(...n){const t=()=>{var e,i;return(i=(e=yt.tips).info)==null?void 0:i.call(e,...n)};return new wt(t,this.reject)}success(...n){const t=()=>{var e,i;return(i=(e=yt.tips).success)==null?void 0:i.call(e,...n)};return new wt(t,this.reject)}}const F=class F{constructor(){if(new.target===F)throw new Error("请直接使用静态方法,而不是实例化此类")}static register(n,t){if(typeof t!="function")return console.error("TipHandler must be a function");F.tips[n]=t}static resolveTip(n){return function(...t){const e=()=>{var i,s;return(s=(i=F.tips)[n])==null?void 0:s.call(i,...t)};return new hn(e)}}static rejectTip(n){return function(...t){const e=()=>{var i,s;return(s=(i=F.tips)[n])==null?void 0:s.call(i,...t)};return new un(e)}}};f(F,"tips",{info:void 0,success:void 0,warning:void 0,error:void 0}),f(F,"info",F.resolveTip("info")),f(F,"success",F.resolveTip("success")),f(F,"warning",F.rejectTip("warning")),f(F,"error",F.rejectTip("error"));let yt=F;exports.EXTENSION_TO_MIME=Re;exports.FILE_EXTENSIONS=Ft;exports.PAPER_SIZE_DEFINITIONS=ve;exports.PAPER_SIZE_OPTIONS=ii;exports.UNIT_LABELS=le;exports.WINDOW_TARGET=ei;exports._Animate_CreateOscillator=si;exports._Animate_NumericTransition=ni;exports._Animate_Schedule=kt;exports._Blob_ConvertDataToImageUrl=ri;exports._Browser_CalculatePrintableArea=ki;exports._Browser_CopyToClipboard=Ri;exports._Browser_GetFrameRate=Vi;exports._Browser_SameOriginTabManager=Vt;exports._Canvas=Y;exports._Element_CalculateCanvasSize=Zs;exports._Element_CheckImagesLoaded=Js;exports._Element_CloseOnOutsideClick=Ys;exports._Element_Drag=zs;exports._Element_EnterFullscreen=$e;exports._Element_ExitFullscreen=Ze;exports._Element_Fullscreen=qs;exports._Element_FullscreenObserver=js;exports._Element_GetOtherSizeInPixels=$s;exports._Element_IsFullscreen=xe;exports._Element_LoadImage=Qs;exports._Element_LocalDrag=Ws;exports._Element_ScrollEndListener=Xs;exports._File_CreateAndDownload=tn;exports._File_Download=Qe;exports._File_Read=Ks;exports._Format_CamelCase=ui;exports._Format_CapitalizeFirstLetter=oi;exports._Format_ChunkArray=pi;exports._Format_ExcludeSubstring=di;exports._Format_FileSize=ci;exports._Format_HrefName=qt;exports._Format_MillisecondToReadable=mi;exports._Format_NumberWithCommas=Wt;exports._Format_NumberWithUnit=li;exports._Format_Percentage=ai;exports._Format_Timestamp=hi;exports._Format_ToggleInvisibleChars=fi;exports._Math_CalculateDistance2D=ye;exports._Math_Degree=cn;exports._Math_GetArcPoints=on;exports._Math_GetBoundaryIntersection=an;exports._Math_GetMidpoint=be;exports._Math_LngLatToPlane=nn;exports._Math_PlaneToLngLat=rn;exports._Math_PointToLineDistance=Je;exports._Tip=yt;exports._Utility_Clone=Ie;exports._Utility_Debounce=we;exports._Utility_ExecuteWhenIdle=bi;exports._Utility_GenerateUUID=$t;exports._Utility_GetTargetByPath=Ci;exports._Utility_MergeObjects=ct;exports._Utility_RotateList=Ei;exports._Utility_SetTargetByPath=Si;exports._Utility_Sleep=Di;exports._Utility_Throttle=_i;exports._Utility_TimeConsumption=He;exports._Utility_WaitForCondition=Ae;exports._Valid_CheckConnectionWithXHR=Pi;exports._Valid_DataType=jt;exports._Valid_DoesInfiniteLineIntersectRectangle=vi;exports._Valid_FileTypeChecker=ce;exports._Valid_Is2DNumberArray=Mt;exports._Valid_IsInMargin=gi;exports._Valid_IsNumberArray=ee;exports._Valid_IsPointInPolygon=yi;exports._Valid_IsSecureContext=wi;
|