UNPKG

nhanh-pure-function

Version:
1,502 lines (1,501 loc) 45 kB
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".no-select{-webkit-user-select:none;-ms-user-select:none;user-select:none}")),document.head.appendChild(e)}}catch(n){console.error("vite-plugin-css-injected-by-js",n)}})(); var at = Object.defineProperty; var et = (n) => { throw TypeError(n); }; var lt = (n, e, t) => e in n ? at(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t; var C = (n, e, t) => lt(n, typeof e != "symbol" ? e + "" : e, t), nt = (n, e, t) => e.has(n) || et("Cannot " + t); var u = (n, e, t) => (nt(n, e, "read from private field"), t ? t.call(n) : e.get(n)), f = (n, e, t) => e.has(n) ? et("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), m = (n, e, t, i) => (nt(n, e, "write to private field"), i ? i.call(n, t) : e.set(n, t), t); const ut = { ".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" }, Q = { 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" ] }, it = [ "", "万", "亿", "兆", "京", "垓", "秭", "穰", "沟", "涧", "正", "载", "极" ], _t = ["_self", "_blank", "_parent", "_top"], st = { // 北美标准尺寸 (毫米) Letter: { width: 215.9, height: 279.4 }, // 8.5 × 11 英寸 Legal: { width: 215.9, height: 355.6 }, // 8.5 × 14 英寸 Tabloid: { width: 279.4, height: 431.8 }, // 11 × 17 英寸 Ledger: { width: 431.8, height: 279.4 }, // 17 × 11 英寸 Executive: { width: 184.2, height: 266.7 }, // 7.25 × 10.5 英寸 // 其他常见尺寸 Folio: { width: 215.9, height: 330.2 }, // 8.5 × 13 英寸 Quarto: { width: 215, height: 275 }, // 8.46 × 10.83 英寸 "Government-Letter": { width: 203.2, height: 266.7 }, // 8 × 10.5 英寸 // ISO A系列 (毫米) 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 }, // ISO B系列 (毫米) 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 }, // ISO C系列 (信封尺寸,毫米) 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 } }, Et = Object.keys(st).map( (n) => ({ value: n, label: n }) ); function Mt(n, e = 500) { let t, i = !0; function o(r) { if (!i) return; t || (t = r); let c = Math.min((r - t) / e, 1); n(c), r - t < e && requestAnimationFrame(o); } return requestAnimationFrame(o), () => i = !1; } function Ct(n, e, t, i, o = 2) { let r = n, c = !1, s = 1, a = n, l = e, h = t; const d = () => { const v = (l - a) / h; return Number(v.toFixed(o)); }; let p = d(); const y = (v) => Math.min(Math.max(v, a), l), w = (v) => Number(v.toFixed(o)), P = (v, H, G) => { const I = []; return v >= H && I.push("最小值必须小于最大值"), G <= 0 ? I.push("分段数必须为正数") : d() == 0 && I.push("数值精度过低,致使动画步长为 0"), I; }, k = (v, H, G) => { const I = P(v, H, G); return I.length > 0 ? (console.error(`参数更新失败: ${I.join("; ")}`), !1) : (a = v, l = H, h = G, p = d(), r = y(r), !0); }, W = () => { c && (s = r >= l ? -1 : r <= a ? 1 : s, r = y(r + p * s), i(w(r)), requestAnimationFrame(W)); }; return { /** 启动/继续动画 */ play(v = r) { if (r = y(v), P(a, l, h).length) return console.error("配置参数错误", this.getParams()); c || (c = !0, W()); }, /** 暂停动画 */ pause() { c = !1; }, /** 获取当前值 */ getCurrent: () => w(r), /** 是否正在运行 */ isPlaying: () => c, /** 更新参数(不中断动画) */ updateParams: k, /** 获取当前参数 */ getParams: () => ({ min: a, max: l, steps: h, precision: o, stepSize: p }) }; } function Ft(n, e, t, i, o = 2) { if (t <= 0) return console.error("动画步数 必须为正数"); const r = (d) => Number(d.toFixed(o)), c = e - n, s = r(Math.abs(c) / t); if (s === 0) return console.error("数值精度过低,致使动画步长为 0"); const a = Math.sign(c); let l = n; const h = () => { l = r(l + s * a), (a > 0 ? l < e : l > e) ? (i(l), requestAnimationFrame(h)) : i(e); }; h(); } function Lt(n, e = "image/png") { try { let t, i = e; if (n instanceof File) return URL.createObjectURL(n); if (typeof n == "string") { let r = n; const c = r.match(/^data:([^;]*)(;base64)?,(.*)$/i); if (c) { if (!c[2]) return console.error("无效的数据 URL:缺少 base64 编码声明"); if (i = c[1] || i, r = c[3], !r) return console.error("数据 URL 包含空有效负载"); } r = r.replace(/[^A-Za-z0-9+/=]/g, ""); const s = atob(r); t = new Uint8Array(s.length); for (let a = 0; a < s.length; a++) t[a] = s.charCodeAt(a); } else if (n instanceof ArrayBuffer) t = new Uint8Array(n); else if (n instanceof Uint8Array) t = n; else return console.error( "不支持的数据类型。应为 Base64 字符串、ArrayBuffer 或 Uint8Array" ); const o = new Blob([t], { type: i }); return URL.createObjectURL(o); } catch (t) { return console.error( "数据到 ImageURL 的转换失败:", t.message, t.stack || "没有可用的堆栈跟踪" ), null; } } function Pt(n, e = 10) { let t = 0, i = e; function o() { if (i > 0) i--, requestAnimationFrame(o); else { const c = (+/* @__PURE__ */ new Date() - t) / e, s = 1e3 / c; n(Number(s.toFixed(2)), Number(c.toFixed(2))); } } requestAnimationFrame(() => { t = +/* @__PURE__ */ new Date(), o(); }); } function Tt(n) { const e = () => Promise.resolve(), t = (s) => (console.error(s), Promise.reject(s)); function i() { return navigator.clipboard.writeText(n).then(e).catch(t); } function o() { const s = document.createElement("div"); s.innerText = n, document.body.appendChild(s); const a = document.createRange(); a.selectNodeContents(s); const l = window.getSelection(); let h = !1; return l && (l.removeAllRanges(), l.addRange(a), h = document.execCommand("copy")), document.body.removeChild(s), h ? Promise.resolve() : Promise.reject(); } function r() { const s = document.createElement("textarea"); s.value = n, document.body.appendChild(s), s.select(), s.setSelectionRange(0, n.length); let a = !1; return document.activeElement === s && (a = document.execCommand("Copy", !0)), document.body.removeChild(s), a ? Promise.resolve() : Promise.reject(); } function c() { return o().then(e).catch(() => { r().then(e).catch(() => t("复制方式尽皆失效")); }); } return navigator.clipboard ? i().catch(c) : c(); } class ht { /** 请使用静态方法 */ constructor() { } /** 添加已有窗口 */ static add(e, t) { this.keys.set(e, t); } /** * 根据键打开或聚焦窗口 * @param key 窗口的唯一键 * @param url 要打开的URL * @param target 窗口的目标 * @param windowFeatures 新窗口的特性 * @returns 返回已打开或新打开的窗口 */ static open(e, t, i, o) { const r = this.keys.get(e); if (r && !r.closed) return r.focus(), r; { const c = window.open(t, i, o); if (c) return this.keys.set(e, c), c; console.error("window.open failed: 可能是浏览器阻止了弹出窗口"), this.keys.delete(e); } } /** * 检查指定键的窗口是否打开 * @param key 窗口的唯一键 * @returns 如果窗口打开则返回true,否则返回false */ static isOpen(e) { const t = this.keys.get(e); return t != null && t.closed && this.keys.delete(e), this.keys.has(e); } /** * 获取与指定键关联的窗口 * @param key 窗口的唯一键 * @returns 返回对应的窗口,如果窗口已关闭则返回undefined */ static getWindow(e) { if (this.isOpen(e)) return this.keys.get(e); } /** * 关闭与指定键关联的窗口 * @param key 窗口的唯一键 */ static close(e) { const t = this.keys.get(e); t && (t.close(), this.keys.delete(e)); } /** * 关闭所有打开的窗口并清空Map */ static closeAll() { this.keys.forEach((e, t) => e.close()), this.keys.clear(); } } // 存储键与对应窗口的Map C(ht, "keys", /* @__PURE__ */ new Map()); function At(n, e) { const t = st[n]; if (!t) throw new Error(`未知纸张类型: ${n}`); const { width: i, height: o } = t, r = (w) => w / 25.4, s = typeof window < "u" ? window.devicePixelRatio * 96 : 300, a = (w) => Math.round(r(w) * s), l = a(i), h = a(o), d = a(e), p = Math.max(0, l - 2 * d), y = Math.max(0, h - 2 * d); return { /** 内容宽度(像素) */ contentWidth: p, /** 内容高度(像素) */ contentHeight: y, /** 边距(像素) */ paddingPx: d, /** 纸张宽度(像素) */ paperWidthPx: l, /** 纸张高度(像素) */ paperHeightPx: h }; } function It(n) { return n.charAt(0).toUpperCase() + n.slice(1); } function Rt(n, e, t = 2) { return !Number.isFinite(n) || !Number.isFinite(e) || !Number.isFinite(t) ? (console.error("所有参数必须是有限的数字"), "") : e === 0 ? (console.error("分母不能为零"), "") : t < 0 ? (console.error("小数位数不能为负数"), "") : (n / e * 100).toFixed(t) + "%"; } function St(n) { const t = n.toString().split("."), i = t[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","); return t.length > 1 ? i + "." + t[1] : i; } function jt(n, e) { const t = { join: !0, suffix: "", decimalPlaces: 2 }, { join: i, suffix: o, decimalPlaces: r } = { ...t, ...e || {} }, c = Number(n); if (isNaN(c)) return i ? `0${o}` : [0, o]; const s = Math.abs(c), a = c >= 0, l = Math.max(0, Math.floor(Math.log10(s) / 4)), h = Math.pow(1e4, l), d = s / h, p = (a ? 1 : -1) * parseFloat(d.toFixed(Math.max(0, r))); return i ? `${p}${it[l]}${o}` : [p, it[l] + o]; } function Ut(n) { const e = ["B", "KB", "MB", "GB", "TB", "PB"]; let t = 0; for (; n > 1024; ) n /= 1024, t++; return `${Math.round(n * 100) / 100} ${e[t]}`; } function kt(n, e = "YYYY-MM-DD hh:mm:ss", t = !0) { const i = new Date(n); if (isNaN(i.getTime())) return console.error("Invalid date"), ""; const o = { YYYY: (r) => r.getFullYear(), MM: (r) => r.getMonth() + 1, // Adjust for 0-based month DD: (r) => r.getDate(), hh: (r) => r.getHours(), mm: (r) => r.getMinutes(), ss: (r) => r.getSeconds(), ms: (r) => r.getMilliseconds() }; return e.replace(/YYYY|MM|DD|hh|mm|ss|ms/g, (r) => { const c = o[r](i); return t ? String(c).padStart(2, "0") : String(c); }); } function J(n, e = "file") { if (!n || (n = String(n).trim(), n === "")) return e; const t = n.split("/"); return t[t.length - 1].split("?")[0]; } function Ot(n, e) { return n = n.replace(/([^a-zA-Z][a-z])/g, (t) => t.toUpperCase()), e ? n.replace(/[^a-zA-Z]+/g, "") : n; } function Dt(n, e, t = ",") { const i = new RegExp( `(^|${t})${e}(${t}|$)`, "g" ); return n.replace(i, function(o, r, c) { return r === c ? t : ""; }); } function zt(n) { return !(n === null || typeof n != "object" || Array.isArray(n)); } function mt(n, e = 2) { if (Array.isArray(n) && n.length >= e) { for (let i = 0; i < n.length; i++) if (typeof n[i] != "number" || !Number.isFinite(n[i])) return !1; } else return !1; return !0; } function Nt(n, e = 1, t = 2) { if (Array.isArray(n) && n.length >= e) { for (let o = 0; o < n.length; o++) if (!mt(n[o], t)) return !1; } else return !1; return !0; } function Bt(n, e, t) { return Math.abs(n - e) <= t; } function qt(n, e) { let t = !1; const { x: i, y: o } = n, r = e.length; for (let c = 0, s = r - 1; c < r; s = c++) { const a = e[c].x, l = e[c].y, h = e[s].x, d = e[s].y; l > o != d > o && i < (h - a) * (o - l) / (d - l) + a && (t = !t); } return t; } function $t(n, e, t, i) { const o = Math.min(n[0], e[0]), r = Math.max(n[0], e[0]), c = Math.min(n[1], e[1]), s = Math.max(n[1], e[1]), a = [ [o, c], // 左上 [r, c], // 右上 [r, s], // 右下 [o, s] // 左下 ], l = i[1] - t[1], h = t[0] - i[0], d = i[0] * t[1] - t[0] * i[1]; if (l === 0 && h === 0) { const [P, k] = t; return P >= o && P <= r && k >= c && k <= s; } const p = 1e-10; let y = !1, w = !1; for (const [P, k] of a) { const W = l * P + h * k + d; if (Math.abs(W) < p || (W > p ? y = !0 : w = !0, y && w)) return !0; } return y && w; } function tt(n) { return Object.prototype.toString.call(n).slice(8, -1).toLowerCase(); } function Yt(n) { return [ "https:", // HTTPS协议,用于安全地浏览网页 "wss:", // WebSocket Secure协议,用于安全的WebSocket通信 "ftps:", // FTP Secure协议,用于安全的文件传输 "sftp:", // SSH File Transfer Protocol,通过SSH安全地传输文件 "smpts:", // Secure SMTP协议,用于安全地发送邮件 "smtp+tls:", // SMTP协议结合STARTTLS扩展,用于升级到安全连接 "imap+tls:", // IMAP协议结合STARTTLS扩展,用于安全地访问邮件 "pop3+tls:", // POP3协议结合STARTTLS扩展,用于安全地接收邮件 "rdp:", // Remote Desktop Protocol,用于安全的远程桌面连接 "vpn:" // VPN协议,用于创建安全的网络连接 ].some((t) => n.startsWith(t)); } function Xt(n) { return new Promise((e, t) => { if (typeof n != "string" || n.trim() === "" || !n.includes("://")) { t(new Error("Invalid URL: Must be a non-empty string")); return; } try { new XMLHttpRequest().open("HEAD", n, !0); } catch (r) { t(new Error(`Invalid URL format: ${r.message}`)); return; } const i = new XMLHttpRequest(); i.open("HEAD", n, !0); const o = (r) => { t(new Error(`Request failed: ${r.type}`)); }; i.onreadystatechange = function() { i.readyState === XMLHttpRequest.DONE && (i.status === 0 ? t(new Error("Network error or CORS blocked")) : i.status >= 200 && i.status < 300 ? e(!0) : t(new Error(`HTTP Error: ${i.status}`))); }, i.onerror = o, i.onabort = o, i.ontimeout = o; try { i.send(); } catch (r) { t(new Error(`Request send failed: ${r.message}`)); } }); } const T = class T { constructor() { if (new.target === T) throw new Error("请直接使用静态方法,而不是实例化此类"); } static check(e, t) { if (!e || typeof e != "string") return console.error("Invalid URL provided"), t ? !1 : "unknown"; const i = J(e).toLowerCase(); if (t) { if (!Q.hasOwnProperty(t)) return console.error(`Unknown file type: ${t}`), "unknown"; const o = Q[t]; return T._checkExtension(i, o); } return T._detectFileType(i); } /** * 静态方法,用于解析地址信息 * 该方法接受一个URL字符串,将其解析为一个包含地址详情的对象数组 * 主要用于批量处理以逗号分隔的URL列表,为每个URL生成相应的名称和类型 * * @param {string} url - 以逗号分隔的URL字符串,每个URL代表一个资源的位置 * @returns {Array} - 包含每个URL及其相关信息(名称和类型)的对象数组 */ static parseAddresses(e) { return !e || typeof e != "string" ? (console.error("Invalid URL provided"), []) : e.split(",").map((t) => { const i = J(t), o = this.check(t); return { url: t, name: i, type: o }; }); } /** * 检查 MIME 类型是否与指定的模式匹配 * @param {string} type - 要检查的 MIME 类型(如 "image/png") * @param {string} [accept] - 可接受的 MIME 类型模式(如 "image/*, text/plain") * @returns {boolean} - 如果类型匹配,则返回 true,否则返回 false */ static matchesMimeType(e, t) { if (!t) return !0; if (typeof e != "string" || typeof t != "string") return !1; const i = T._normalizeType(e), o = t.split(",").map((s) => T._normalizeType(s.trim())), [r, c = "*"] = i.split("/"); return o.some((s) => { const [a, l = "*"] = s.split("/"); return (a === "*" || r === "*" || a === r) && (l === "*" || c === "*" || l === c); }); } /** * 类型标准化函数 * 该函数旨在将文件类型或MIME类型字符串转换为标准格式 * 主要处理三种情况:带扩展名的字符串、简写格式的类型以及已标准格式的类型 * * @param {string} type - 文件类型或MIME类型字符串 * @returns {string} 标准化的MIME类型字符串,如果无法识别则返回原始输入 */ static _normalizeType(e) { return e.startsWith(".") && !e.includes("/") ? ut[e.toLowerCase()] || e : e.includes("/") ? e : `${e}/*`; } /** * 检查URL是否具有任何指定的文件扩展名 * @param {string} url - 文件的URL * @param {string[]} validExtensions - 有效文件扩展名的数组 * @returns {boolean} - 如果URL具有任何指定的文件扩展名,则返回true,否则返回false */ static _checkExtension(e, t) { return t.some((i) => e.endsWith(i)); } /** * 检测文件URL的类型 * @param {string} url - 文件的URL * @returns {string} - 如果URL与任何已知类型匹配,则返回文件类型,否则返回"unknown" */ static _detectFileType(e) { for (const [t, i] of T.cachedEntries) if (i.some((o) => e.endsWith(o))) return t; return "unknown"; } }; // 缓存文件扩展名的条目,以提高性能 C(T, "cachedEntries", Object.entries(Q)); let rt = T; function Wt(n) { if (typeof n != "function") return console.error("非函数:", n); const e = function(t) { t.didTimeout || t.timeRemaining() <= 0 ? requestIdleCallback(e) : n(); }; requestIdleCallback(e); } function Ht(n, e) { const t = +/* @__PURE__ */ new Date(); return new Promise((i, o) => { const r = () => { if (+/* @__PURE__ */ new Date() - t >= e) return o("超时"); if (n()) return i("完成"); requestIdleCallback(r); }; r(); }); } function ot(n, e, t = [], i = +/* @__PURE__ */ new Date()) { if (i < +/* @__PURE__ */ new Date() - 50) { console.error("_MergeObjects 合并异常:疑似死循环"); return; } const o = tt(n), r = tt(e); if (o != r) return e; if (o == "object" || o == "array") { if (t.some(([c, s]) => c == n && s == e)) return n; if (t.push([n, e]), o == "object") { for (const c in e) if (Object.prototype.hasOwnProperty.call(e, c)) { const s = e[c], a = n[c], l = ot( a, s, t, i ); n[c] = l; } return n; } else if (o == "array") return e.forEach((c, s) => { const a = c, l = n[s], h = ot( l, a, t, i ); n[s] = h; }), n; } else return e; } function Gt(n = "") { return n + "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) { const t = Math.random() * 16 | 0; return (e === "x" ? t : t & 3 | 8).toString(16); }); } function dt(n, e) { let t; return function(...i) { clearTimeout(t), t = setTimeout(() => { n(...i), t = void 0; }, e); }; } function Vt(n, e) { let t = -1 / 0; return function(...i) { const o = performance.now(); if (o - t > e) { t = o; try { n(...i); } catch (r) { console.error("Throttled function execution failed:", r); } } }; } function Zt(n, e, t) { if (!n || !e) return n; const i = e.split("."); return i.reduce((o, r, c) => o.hasOwnProperty(r) ? o[r] : c === i.length - 1 ? o[r] = t : o[r] = {}, n); } function Kt(n, e) { if (!n || !e) return n; const t = e.split("."); return t.reduce((i, o, r) => i.hasOwnProperty(o) ? i[o] : r == t.length - 1 ? void 0 : {}, n); } function Qt(n, e, t) { if (!n || !e) return n; const i = e.split("."); return i.reduce((o, r, c) => (c === i.length - 1 && (o[r] = t), o.hasOwnProperty(r) ? o[r] : o[r] = {}), n); } function Jt(n) { return n.map((e, t) => n.slice(t).concat(n.slice(0, t))); } function te(n) { const e = window.structuredClone, t = (i, o = /* @__PURE__ */ new WeakMap()) => { const r = i; if (r === null || typeof r != "object") return r; if (o.has(r)) return o.get(r); switch (tt(r)) { case "array": { const s = []; o.set(r, s); for (const a of r) s.push(t(a, o)); return s; } case "object": { if (r === null) return r; const s = {}; o.set(r, s); for (const a in r) Object.prototype.hasOwnProperty.call(r, a) && (s[a] = t(r[a], o)); return s; } case "date": { const s = new Date(r.getTime()); return o.set(r, s), s; } case "regexp": { const s = r, a = new RegExp(s.source, s.flags); return a.lastIndex = s.lastIndex, o.set(r, a), a; } case "map": { const s = /* @__PURE__ */ new Map(); return o.set(r, s), r.forEach((a, l) => { s.set( t(l, o), t(a, o) ); }), s; } case "set": { const s = /* @__PURE__ */ new Set(); return o.set(r, s), r.forEach((a) => { s.add(t(a, o)); }), s; } // 处理其他可克隆对象类型 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 s = r, a = s.constructor, l = s.buffer.slice( s.byteOffset, s.byteOffset + s.byteLength ), h = new a( l, s.byteOffset, s.byteLength / s.BYTES_PER_ELEMENT ); return o.set(r, h), h; } // 处理特殊对象类型 case "error": { const s = r, a = new s.constructor(s.message); return a.stack = s.stack, a.name = s.name, o.set(r, a), a; } // 处理不可克隆对象(直接返回原值) case "function": case "promise": case "weakmap": case "weakset": default: return r; } }; try { return e ? e(n) : t(n); } catch (i) { return console.error("structuredClone error:", i), e && t(n); } } function ee(n, e, t = 30) { if (typeof n != "function") return console.error("第一个参数必须是一个函数。"); if (!Array.isArray(e)) return console.error("第二个参数必须是一个数组。"); let i = [], o = 0; const r = (c, s) => { for (const [a, l] of s) if (c >= a) return l; return "black"; }; return function(...c) { const s = performance.now(), a = n(...c), l = performance.now() - s; i.push(l), i.length > t && i.shift(), o = i.reduce((p, y) => p + y, 0) / i.length || 0; const h = r(l, e), d = r(o, e); return console.log( `%c单次耗时:${l.toFixed(2)}ms %c平均耗时(${i.length}次):${o.toFixed(2)}ms`, `color: ${h}; padding: 2px 0;`, `color: ${d}; padding: 2px 0;` ), a; }; } function ne(n) { const e = Date.now(); let t = performance.now(); for (; Date.now() - e < n; ) { t = Math.sin(t) * 1e6, (t > 1e6 || t < -1e6) && (t = 0); try { const i = t.toString().substring(0, 8); history.replaceState(null, "", `#${i}`); } catch { } } return Date.now() - e; } function ie(n) { const e = dt(n, 100); let t = 0, i = 0; return function(o) { const r = o.target; if (!r || !(r instanceof Element)) return; const { scrollTop: c, scrollHeight: s, clientHeight: a, scrollLeft: l, scrollWidth: h, clientWidth: d } = r; function p() { if (t == c) return; const w = t > c; if (t = c, w) return; s - c - a <= 1 && e("vertical"); } function y() { if (i == l) return; const w = i > l; if (i = l, w) return; h - l - d <= 1 && e("horizontal"); } p(), y(); }; } function re(n, e, t) { const { isClickAllowed: i, uiLibrary: o = ["naiveUI", "ElementPlus", "Element"] } = t || {}, r = function(a) { const l = []; for (const h in a) Object.hasOwnProperty.call(a, h) && o.includes(h) && l.push(...a[h]); return l; }({ naiveUI: [ ".v-binder-follower-container", ".n-image-preview-container", ".n-modal-container" ], ElementPlus: [".el-popper"], Element: [".el-popper"] }); function c() { e(), document.removeEventListener("mousedown", s); } function s(a) { if (i) { const d = i(a); if (d) return; if (d === !1) return c(); } const l = a.target; if (!(l instanceof Element) || !l.isConnected) return; n.concat(r).some((d) => !!(l != null && l.closest(d))) || c(); } requestAnimationFrame( () => document.addEventListener("mousedown", s) ); } var b, R, S, D, z, F, L, A, N; class oe { constructor() { f(this, b); f(this, R, !1); f(this, S, {}); f(this, D, 0); f(this, z, 0); f(this, F, 0); f(this, L, 0); f(this, A); f(this, N); } init(e, t) { m(this, b, e), m(this, A, t == null ? void 0 : t.limit), m(this, N, t == null ? void 0 : t.dragDom), m(this, S, { mousedown: this.mousedown.bind(this), mousemove: this.mousemove.bind(this), mouseup: this.mouseup.bind(this) }), this.bindOrUnbindEvent("bind"); } finish() { this.bindOrUnbindEvent("unbind"); } bindOrUnbindEvent(e) { const t = e === "bind" ? "addEventListener" : "removeEventListener"; if (!u(this, b)) return console.error("No DOM"); u(this, b)[t]("mousedown", u(this, S).mousedown), document[t]("mousemove", u(this, S).mousemove), document[t]("mouseup", u(this, S).mouseup); } alterLocation() { if (!u(this, b)) return console.error("No DOM"); u(this, A) && (m(this, F, Math.min(u(this, F), u(this, A).max.top)), m(this, F, Math.max(u(this, F), u(this, A).min.top)), m(this, L, Math.min(u(this, L), u(this, A).max.left)), m(this, L, Math.max(u(this, L), u(this, A).min.left))), u(this, b).style.setProperty("--top", u(this, F) + "px"), u(this, b).style.setProperty("--left", u(this, L) + "px"); } mousedown(e) { if (!u(this, b)) return console.error("No DOM"); if (u(this, N) && e.target != u(this, N)) return; document.body.classList.add("no-select"), m(this, R, !0); const t = u(this, b).getBoundingClientRect(), { pageX: i, pageY: o } = e; m(this, D, i), m(this, z, o), m(this, F, t.y), m(this, L, t.x); } mousemove(e) { const { pageX: t, pageY: i } = e; u(this, R) && (m(this, F, u(this, F) + (i - u(this, z))), m(this, L, u(this, L) + (t - u(this, D))), m(this, D, t), m(this, z, i), this.alterLocation()); } mouseup() { u(this, R) && (m(this, R, !1), document.body.classList.remove("no-select")); } } b = new WeakMap(), R = new WeakMap(), S = new WeakMap(), D = new WeakMap(), z = new WeakMap(), F = new WeakMap(), L = new WeakMap(), A = new WeakMap(), N = new WeakMap(); var _, j, U, B, q, E, M, x, $, Y; class se { constructor() { f(this, _); f(this, j, !1); f(this, U, {}); f(this, B, 0); f(this, q, 0); f(this, E, 0); f(this, M, 0); f(this, x); f(this, $); f(this, Y); } init(e, t = {}) { m(this, _, e), m(this, x, t.limit), m(this, $, t.update_move), m(this, Y, t.update_up), m(this, U, { mousedown: this.mousedown.bind(this), mousemove: this.mousemove.bind(this), mouseup: this.mouseup.bind(this) }), this.bindOrUnbindEvent("bind"); } finish() { this.bindOrUnbindEvent("unbind"); } bindOrUnbindEvent(e) { const t = e === "bind" ? "addEventListener" : "removeEventListener"; if (!u(this, _)) return console.error("No DOM"); u(this, _)[t]("mousedown", u(this, U).mousedown), document[t]("mousemove", u(this, U).mousemove), document[t]("mouseup", u(this, U).mouseup); } updateValue() { const e = { top: u(this, E), left: u(this, M), percentage: { top: 0, left: 0 } }; if (u(this, x)) { const t = (i) => u(this, x) ? (e[i] - u(this, x).min[i]) / (u(this, x).max[i] - u(this, x).min[i]) : 0; e.percentage = { top: t("top") || 0, left: t("left") || 0 }; } return e; } alterLocation() { if (!u(this, _)) return console.error("No DOM"); u(this, x) && (m(this, E, Math.min(u(this, E), u(this, x).max.top)), m(this, E, Math.max(u(this, E), u(this, x).min.top)), m(this, M, Math.min(u(this, M), u(this, x).max.left)), m(this, M, Math.max(u(this, M), u(this, x).min.left))), u(this, $) && u(this, $).call(this, this.updateValue()), u(this, _).style.setProperty("--top", u(this, E) + "px"), u(this, _).style.setProperty("--left", u(this, M) + "px"); } mousedown(e) { if (!u(this, _)) return console.error("No DOM"); document.body.classList.add("no-select"), m(this, j, !0); const t = u(this, _).getBoundingClientRect(); m(this, q, t.y), m(this, B, t.x); const { pageX: i, pageY: o } = e; m(this, E, o - u(this, q)), m(this, M, i - u(this, B)), this.alterLocation(); } mousemove(e) { const { pageX: t, pageY: i } = e; u(this, j) && (m(this, E, i - u(this, q)), m(this, M, t - u(this, B)), this.alterLocation()); } mouseup() { u(this, j) && (m(this, j, !1), document.body.classList.remove("no-select"), u(this, Y) && u(this, Y).call(this, this.updateValue())); } } _ = new WeakMap(), j = new WeakMap(), U = new WeakMap(), B = new WeakMap(), q = new WeakMap(), E = new WeakMap(), M = new WeakMap(), x = new WeakMap(), $ = new WeakMap(), Y = new WeakMap(); function K(n) { if (typeof n == "string") { const e = document.querySelector(n); if (!e) throw new Error(`Element "${n}" not found`); return e; } else return n || document.documentElement; } function ft(n) { const e = K(n); return e.requestFullscreen ? e.requestFullscreen() : e.mozRequestFullScreen ? e.mozRequestFullScreen() : e.webkitRequestFullscreen ? e.webkitRequestFullscreen() : e.msRequestFullscreen ? e.msRequestFullscreen() : Promise.reject("No Fullscreen API"); } function pt() { const n = document; return document.exitFullscreen ? document.exitFullscreen() : n.mozCancelFullScreen ? n.mozCancelFullScreen() : n.webkitExitFullscreen ? n.webkitExitFullscreen() : n.msExitFullscreen ? n.msExitFullscreen() : Promise.reject("No ExitFullscreen API"); } function ct(n) { const e = K(n), t = document, i = document.fullscreenElement || t.webkitFullscreenElement || t.mozFullScreenElement || t.msFullscreenElement; return e == i || !n && window.innerWidth == screen.width && window.innerHeight == screen.height; } function ce(n) { return n = K(n), function() { ct(n) ? pt() : ft(n); }; } function ae(n, e) { const t = K(e), i = () => { n(ct(t)); }; return document.addEventListener("fullscreenchange", i), document.addEventListener("webkitfullscreenchange", i), document.addEventListener("mozfullscreenchange", i), document.addEventListener("MSFullscreenChange", i), i(), () => { document.removeEventListener("fullscreenchange", i), document.removeEventListener("webkitfullscreenchange", i), document.removeEventListener("mozfullscreenchange", i), document.removeEventListener("MSFullscreenChange", i); }; } function le(n, e) { if (typeof n == "number") return n; if (/px/.test(n)) return Number(n.replace(/px/, "")) || 0; const t = document.createElement("div"); t.style.width = n, e = e || document.body, e.appendChild(t); const i = t.getBoundingClientRect().width; return e.removeChild(t), i; } function ue(n, e) { if (!n) return; let t, i; if (typeof e == "string") { const r = document.querySelector(e); if (!r) return; const c = r.getBoundingClientRect(); t = c.width, i = c.height; } else if (Array.isArray(e)) t = e[0], i = e[1]; else { const r = e.getBoundingClientRect(); t = r.width, i = r.height; } const o = t / i; return o > n ? [n * i, i] : o < n ? [t, t / n] : [t, i]; } function he(n, e = 5e3) { return new Promise((t, i) => { const o = new Image(); o.src = n; const r = setTimeout(() => { i(new Error("图片加载超时")), o.onload = null, o.onerror = null; }, e); o.onload = () => { clearTimeout(r); const c = o.naturalWidth, s = o.naturalHeight, a = c / s; t([o, a]); }, o.onerror = () => { clearTimeout(r), i(new Error("图片加载失败")); }, o.crossOrigin = "Anonymous"; }); } function me(n) { return new Promise((e, t) => { fetch(n).then((i) => e(i.text())).catch((i) => { console.error("Error fetching :", i), t(i); }); }); } function gt(n, e) { return new Promise((t, i) => { try { e = e || J(n, "downloaded_file"), fetch(n).then((o) => (o.ok || i(`文件下载失败,状态码: ${o.status}`), o.blob())).then((o) => { const r = URL.createObjectURL(o), c = document.createElement("a"); c.href = r, c.download = decodeURIComponent(e), document.body.appendChild(c), c.click(), document.body.removeChild(c), URL.revokeObjectURL(r), t(o); }).catch(i); } catch (o) { i(o); } }); } function de(n, e, t) { if (!t) { let r = e.replace(/^[^.]+./, ""); r = r == e ? "text/plain" : "application/" + r, t = { type: r }; } const i = new Blob(n, t), o = URL.createObjectURL(i); gt(o, e); } const wt = Math.PI / 2, V = Math.PI / 180, Z = 6378137, xt = 85.05112878; function fe(n, e) { const t = Math.max(Math.min(n, 180), -180), i = Math.max(Math.min(e, xt), -85.05112878), o = t * V * Z, r = i * V, c = Math.log(Math.tan(Math.PI / 4 + r / 2)) * Z; return [o, c]; } function pe(n, e) { const t = n / Z / V, i = (2 * Math.atan(Math.exp(e / Z)) - wt) / V; return [t, i]; } function ge(n, e, t) { const [i, o] = n, [r, c] = e, [s, a] = t, l = (s - r) ** 2 + (a - c) ** 2; if (l === 0) return Math.sqrt((i - r) ** 2 + (o - c) ** 2); let h = ((i - r) * (s - r) + (o - c) * (a - c)) / l; return h = Math.max(0, Math.min(1, h)), Math.sqrt( (i - (r + h * (s - r))) ** 2 + (o - (c + h * (a - c))) ** 2 ); } function we(n, e, t, i, o, r = 1, c = 1) { const s = n + t * Math.cos(i) * r, a = e + t * Math.sin(i) * c, l = n + t * Math.cos(o) * r, h = e + t * Math.sin(o) * c; return [ [s, a], [l, h] ]; } function xe(n, e, t, i) { return Math.hypot(Math.abs(t - n), Math.abs(i - e)); } function ye(n, e, t, i) { const o = (n + t) / 2, r = (e + i) / 2; return { x: o, y: r }; } function ve(n, e, t, i) { const [o, r] = n, [c, s] = e; let a = 1 / 0; if (c !== 0) { const l = c > 0 ? (t - o) / c : -o / c; l > 0 && (a = Math.min(a, l)); } if (s !== 0) { const l = s > 0 ? (i - r) / s : -r / s; l > 0 && (a = Math.min(a, l)); } return a === 1 / 0 ? n : [o + c * a, r + s * a]; } class O { constructor(e, t) { C(this, "resolve"); C(this, "reject"); this.resolve = e, this.reject = t; } run(e) { var t, i; return e instanceof Promise ? e.then((o) => { var r; return (r = this.resolve) == null || r.call(this), o; }).catch((o) => { var r; return (r = this.reject) == null || r.call(this), Promise.reject(o); }) : e ? (t = this.resolve) == null || t.call(this) : (i = this.reject) == null || i.call(this), e; } } class yt extends O { constructor(e) { super(), this.resolve = e; } warning(...e) { const t = () => { var i, o; return (o = (i = X.tips).warning) == null ? void 0 : o.call(i, ...e); }; return new O(this.resolve, t); } error(...e) { const t = () => { var i, o; return (o = (i = X.tips).error) == null ? void 0 : o.call(i, ...e); }; return new O(this.resolve, t); } } class vt extends O { constructor(e) { super(), this.reject = e; } info(...e) { const t = () => { var i, o; return (o = (i = X.tips).info) == null ? void 0 : o.call(i, ...e); }; return new O(t, this.reject); } success(...e) { const t = () => { var i, o; return (o = (i = X.tips).success) == null ? void 0 : o.call(i, ...e); }; return new O(t, this.reject); } } const g = class g { /** * 构造函数 * @throws 如果尝试实例化该类,则抛出错误,因为应该使用静态方法 */ constructor() { if (new.target === g) throw new Error("请直接使用静态方法,而不是实例化此类"); } static register(e, t) { if (typeof t != "function") return console.error("TipHandler must be a function"); g.tips[e] = t; } static resolveTip(e) { return function(...t) { const i = () => { var o, r; return (r = (o = g.tips)[e]) == null ? void 0 : r.call(o, ...t); }; return new yt(i); }; } static rejectTip(e) { return function(...t) { const i = () => { var o, r; return (r = (o = g.tips)[e]) == null ? void 0 : r.call(o, ...t); }; return new vt(i); }; } }; C(g, "tips", { info: void 0, success: void 0, warning: void 0, error: void 0 }), C(g, "info", g.resolveTip("info")), C(g, "success", g.resolveTip("success")), C(g, "warning", g.rejectTip("warning")), C(g, "error", g.rejectTip("error")); let X = g; export { ut as EXTENSION_TO_MIME, Q as FILE_EXTENSIONS, st as PAPER_SIZE_DEFINITIONS, Et as PAPER_SIZE_OPTIONS, it as UNIT_LABELS, _t as WINDOW_TARGET, Ct as _Animate_CreateOscillator, Ft as _Animate_NumericTransition, Mt as _Animate_Schedule, Lt as _Blob_ConvertDataToImageUrl, At as _Browser_CalculatePrintableArea, Tt as _Browser_CopyToClipboard, Pt as _Browser_GetFrameRate, ht as _Browser_KeyedWindowManager, ue as _Element_CalculateCanvasSize, re as _Element_CloseOnOutsideClick, oe as _Element_Drag, ft as _Element_EnterFullscreen, pt as _Element_ExitFullscreen, ce as _Element_Fullscreen, ae as _Element_FullscreenObserver, le as _Element_GetOtherSizeInPixels, ct as _Element_IsFullscreen, he as _Element_LoadImage, se as _Element_LocalDrag, ie as _Element_ScrollEndListener, de as _File_CreateAndDownload, gt as _File_Download, me as _File_Read, Ot as _Format_CamelCase, It as _Format_CapitalizeFirstLetter, Dt as _Format_ExcludeSubstring, Ut as _Format_FileSize, J as _Format_HrefName, St as _Format_NumberWithCommas, jt as _Format_NumberWithUnit, Rt as _Format_Percentage, kt as _Format_Timestamp, xe as _Math_CalculateDistance2D, we as _Math_GetArcPoints, ve as _Math_GetBoundaryIntersection, ye as _Math_GetMidpoint, fe as _Math_LngLatToPlane, pe as _Math_PlaneToLngLat, ge as _Math_PointToLineDistance, X as _Tip, te as _Utility_Clone, dt as _Utility_Debounce, Wt as _Utility_ExecuteWhenIdle, Gt as _Utility_GenerateUUID, Kt as _Utility_GetTargetByPath, Zt as _Utility_InitTargetByPath, ot as _Utility_MergeObjects, Jt as _Utility_RotateList, Qt as _Utility_SetTargetByPath, ne as _Utility_Sleep, Vt as _Utility_Throttle, ee as _Utility_TimeConsumption, Ht as _Utility_WaitForCondition, Xt as _Valid_CheckConnectionWithXHR, tt as _Valid_DataType, $t as _Valid_DoesInfiniteLineIntersectRectangle, rt as _Valid_FileTypeChecker, Nt as _Valid_Is2DNumberArray, Bt as _Valid_IsInMargin, mt as _Valid_IsNumberArray, zt as _Valid_IsObject, qt as _Valid_IsPointInPolygon, Yt as _Valid_IsSecureContext };