@visactor/vtable-plugins 1.19.3 → 1.19.4-alpha.0
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.
|
@@ -107,7 +107,7 @@ class ExportGanttPlugin {
|
|
|
107
107
|
clonedContainer.style.width = `${totalWidth}px`, clonedContainer.style.height = `${totalHeight}px`,
|
|
108
108
|
tempContainer.appendChild(clonedContainer);
|
|
109
109
|
const clonedGantt = new VTableGantt.Gantt(clonedContainer, Object.assign(Object.assign({}, this._gantt.options), {
|
|
110
|
-
records:
|
|
110
|
+
records: this._gantt.records,
|
|
111
111
|
taskListTable: Object.assign(Object.assign({}, this._gantt.options.taskListTable), {
|
|
112
112
|
tableWidth: void 0,
|
|
113
113
|
minTableWidth: void 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["gantt-export-image.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oEAAsD;AAgBtD,MAAa,iBAAiB;IAA9B;QACE,OAAE,GAAG,qBAAqB,CAAC;QAC3B,SAAI,GAAG,qBAAqB,CAAC;QACrB,WAAM,GAA6B,IAAI,CAAC;IAyLlD,CAAC;IAtLC,GAAG,CAAC,GAAG,IAAW;QAChB,MAAM,aAAa,GAAG,IAAI,CAAC,CAAC,CAAsB,CAAC;QACnD,IAAI,CAAC,aAAa,EAAE;YAClB,OAAO,CAAC,KAAK,CAAC,+DAA+D,CAAC,CAAC;YAC/E,OAAO;SACR;QACD,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC;IAC9B,CAAC;IAQK,aAAa,CAAC,UAAyB,EAAE;;;YAC7C,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;gBAEhB,OAAO,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;gBAClE,OAAO,SAAS,CAAC;aAClB;YAED,MAAM,EACJ,QAAQ,GAAG,cAAc,EACzB,IAAI,GAAG,KAAK,EACZ,OAAO,GA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;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO;QACL,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACrB,CAAC;CACF;AA5LD,8CA4LC","file":"gantt-export-image.js","sourcesContent":["import * as VTableGantt from '@visactor/vtable-gantt';\r\n\r\n// 甘特图导出配置项接口\r\nexport interface ExportOptions {\r\n fileName?: string;\r\n type?: 'png' | 'jpeg';\r\n quality?: number;\r\n backgroundColor?: string;\r\n scale?: number;\r\n download?: boolean;\r\n}\r\n\r\n/**\r\n * 甘特图导出插件\r\n * @description 提供完整的甘特图导出功能,支持高分辨率输出和精准布局保留\r\n */\r\nexport class ExportGanttPlugin implements VTableGantt.plugins.IGanttPlugin {\r\n id = 'gantt-export-helper';\r\n name = 'Gantt Export Helper';\r\n private _gantt: VTableGantt.Gantt | null = null;\r\n\r\n // run 方法,在插件初始化时由 PluginManager调用\r\n run(...args: any[]): void {\r\n const ganttInstance = args[0] as VTableGantt.Gantt;\r\n if (!ganttInstance) {\r\n console.error('ExportGanttPlugin: Gantt instance not provided to run method.');\r\n return;\r\n }\r\n this._gantt = ganttInstance;\r\n }\r\n /**\r\n * 执行甘特图导出操作\r\n * @async\r\n * @param {ExportOptions} [options={}] 导出配置选项\r\n * @returns {Promise<string | undefined>} 返回Base64格式的图片数据,或在未初始化时返回 undefined\r\n * @throws {Error} 导出过程中发生错误时抛出异常\r\n */\r\n async exportToImage(options: ExportOptions = {}): Promise<string | undefined> {\r\n if (!this._gantt) {\r\n // 保留这个 error\r\n console.error('ExportGanttPlugin: Gantt instance not available.');\r\n return undefined;\r\n }\r\n\r\n const {\r\n fileName = 'gantt-export',\r\n type = 'png',\r\n quality = 1,\r\n backgroundColor = '#ffffff',\r\n scale = window.devicePixelRatio || 1,\r\n download = true // 默认执行下载\r\n } = options;\r\n\r\n try {\r\n const { tempContainer, clonedGantt } = this.createFullSizeContainer(scale);\r\n\r\n try {\r\n await new Promise(resolve => requestAnimationFrame(resolve));\r\n\r\n const totalWidth =\r\n (clonedGantt.taskListTableInstance.getAllColsWidth() + clonedGantt.getAllDateColsWidth()) * scale;\r\n const totalHeight = clonedGantt.getAllRowsHeight() * scale;\r\n\r\n const exportCanvas = document.createElement('canvas');\r\n exportCanvas.width = totalWidth;\r\n exportCanvas.height = totalHeight;\r\n const ctx = exportCanvas.getContext('2d')!;\r\n\r\n ctx.fillStyle = backgroundColor;\r\n ctx.fillRect(0, 0, totalWidth, totalHeight);\r\n\r\n if (clonedGantt.taskListTableInstance?.canvas) {\r\n ctx.drawImage(\r\n clonedGantt.taskListTableInstance.canvas,\r\n 0,\r\n 0,\r\n clonedGantt.taskListTableInstance.getAllColsWidth() * scale,\r\n totalHeight\r\n );\r\n }\r\n\r\n const splitLineWidth = 3 * scale;\r\n const splitLineX = clonedGantt.taskListTableInstance.getAllColsWidth() * scale;\r\n ctx.fillStyle = 'rgb(225, 228, 232)';\r\n ctx.fillRect(splitLineX - splitLineWidth / 2, 0, splitLineWidth, totalHeight);\r\n\r\n const sourceX = 4 * scale;\r\n const sourceWidth = clonedGantt.canvas.width - sourceX;\r\n\r\n if (clonedGantt.canvas) {\r\n ctx.drawImage(\r\n clonedGantt.canvas,\r\n sourceX,\r\n 0,\r\n sourceWidth,\r\n clonedGantt.canvas.height,\r\n (clonedGantt.taskListTableInstance.getAllColsWidth() + 1.5) * scale,\r\n 0,\r\n (clonedGantt.getAllDateColsWidth() - 1.5) * scale,\r\n totalHeight\r\n );\r\n }\r\n\r\n return this.finalizeExport(exportCanvas, fileName, type, quality, download);\r\n } finally {\r\n tempContainer.remove();\r\n // 确保克隆的甘特图实例被释放\r\n clonedGantt.release();\r\n }\r\n } catch (error) {\r\n console.error('[Gantt Export Plugin] Export failed:', error);\r\n throw new Error(`甘特图导出失败: ${error instanceof Error ? error.message : '未知错误'}`);\r\n }\r\n }\r\n\r\n /**\r\n * 获取甘特图的 Base64 图片数据,不触发下载\r\n * @async\r\n * @param {Omit<ExportOptions, 'download'>} [options={}] 导出配置选项(不包含 download 参数)\r\n * @returns {Promise<string | undefined>} 返回 Base64 格式的图片数据,或在未初始化时返回 undefined\r\n * @throws {Error} 导出过程中发生错误时抛出异常\r\n */\r\n async exportToBase64(options: Omit<ExportOptions, 'download'> = {}): Promise<string | undefined> {\r\n // 调用 exportToImage 方法,但设置 download 为 false\r\n return this.exportToImage({\r\n ...options,\r\n download: false\r\n });\r\n }\r\n\r\n private createFullSizeContainer(scale: number) {\r\n if (!this._gantt) {\r\n // 保留这个 error\r\n throw new Error('ExportGanttPlugin: Gantt instance not available to create container.');\r\n }\r\n\r\n const tempContainer = document.createElement('div');\r\n tempContainer.style.position = 'fixed';\r\n tempContainer.style.left = '-9999px';\r\n tempContainer.style.overflow = 'hidden';\r\n tempContainer.style.width = `${window.innerWidth + 100}px`;\r\n tempContainer.style.height = `${window.innerHeight + 100}px`;\r\n document.body.appendChild(tempContainer);\r\n\r\n const clonedContainer = document.createElement('div');\r\n\r\n const totalWidth = this._gantt.taskListTableInstance.getAllColsWidth() + this._gantt.getAllDateColsWidth();\r\n const totalHeight = this._gantt.getAllRowsHeight();\r\n\r\n clonedContainer.style.width = `${totalWidth}px`;\r\n clonedContainer.style.height = `${totalHeight}px`;\r\n tempContainer.appendChild(clonedContainer);\r\n\r\n const clonedGantt = new VTableGantt.Gantt(clonedContainer, {\r\n ...this._gantt.options,\r\n records: JSON.parse(JSON.stringify(this._gantt.records)),\r\n taskListTable: {\r\n ...this._gantt.options.taskListTable,\r\n tableWidth: undefined as unknown as number,\r\n minTableWidth: undefined as unknown as number,\r\n maxTableWidth: undefined as unknown as number\r\n },\r\n plugins: []\r\n });\r\n\r\n clonedGantt.setPixelRatio(scale);\r\n\r\n // 禁用裁剪\r\n if ((clonedGantt as any).scenegraph?.ganttGroup) {\r\n (clonedGantt as any).scenegraph.ganttGroup.setAttribute('clip', false);\r\n }\r\n if ((clonedGantt.taskListTableInstance as any)?.scenegraph?.tableGroup) {\r\n (clonedGantt.taskListTableInstance as any).scenegraph.tableGroup.setAttribute('clip', false);\r\n }\r\n\r\n clonedGantt.scenegraph.stage.render();\r\n\r\n return { tempContainer, clonedGantt };\r\n }\r\n private finalizeExport(\r\n canvas: HTMLCanvasElement,\r\n fileName: string,\r\n type: string,\r\n quality: number,\r\n download: boolean = true\r\n ): string {\r\n const base64 = canvas.toDataURL(`image/${type}`, quality);\r\n\r\n // 如果需要下载,则创建下载链接\r\n if (download) {\r\n const link = document.createElement('a');\r\n link.download = `${fileName}.${type}`;\r\n link.href = base64;\r\n document.body.appendChild(link);\r\n link.click();\r\n document.body.removeChild(link);\r\n }\r\n\r\n return base64;\r\n }\r\n\r\n release(): void {\r\n this._gantt = null;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"sources":["gantt-export-image.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oEAAsD;AAgBtD,MAAa,iBAAiB;IAA9B;QACE,OAAE,GAAG,qBAAqB,CAAC;QAC3B,SAAI,GAAG,qBAAqB,CAAC;QACrB,WAAM,GAA6B,IAAI,CAAC;IAyLlD,CAAC;IAtLC,GAAG,CAAC,GAAG,IAAW;QAChB,MAAM,aAAa,GAAG,IAAI,CAAC,CAAC,CAAsB,CAAC;QACnD,IAAI,CAAC,aAAa,EAAE;YAClB,OAAO,CAAC,KAAK,CAAC,+DAA+D,CAAC,CAAC;YAC/E,OAAO;SACR;QACD,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC;IAC9B,CAAC;IAQK,aAAa,CAAC,UAAyB,EAAE;;;YAC7C,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;gBAEhB,OAAO,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;gBAClE,OAAO,SAAS,CAAC;aAClB;YAED,MAAM,EACJ,QAAQ,GAAG,cAAc,EACzB,IAAI,GAAG,KAAK,EACZ,OAAO,GAAG,CAAC,EACX,eAAe,GAAG,SAAS,EAC3B,KAAK,GAAG,MAAM,CAAC,gBAAgB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-image.js","sourcesContent":["import * as VTableGantt from '@visactor/vtable-gantt';\r\n\r\n// 甘特图导出配置项接口\r\nexport interface ExportOptions {\r\n fileName?: string;\r\n type?: 'png' | 'jpeg';\r\n quality?: number;\r\n backgroundColor?: string;\r\n scale?: number;\r\n download?: boolean;\r\n}\r\n\r\n/**\r\n * 甘特图导出插件\r\n * @description 提供完整的甘特图导出功能,支持高分辨率输出和精准布局保留\r\n */\r\nexport class ExportGanttPlugin implements VTableGantt.plugins.IGanttPlugin {\r\n id = 'gantt-export-helper';\r\n name = 'Gantt Export Helper';\r\n private _gantt: VTableGantt.Gantt | null = null;\r\n\r\n // run 方法,在插件初始化时由 PluginManager调用\r\n run(...args: any[]): void {\r\n const ganttInstance = args[0] as VTableGantt.Gantt;\r\n if (!ganttInstance) {\r\n console.error('ExportGanttPlugin: Gantt instance not provided to run method.');\r\n return;\r\n }\r\n this._gantt = ganttInstance;\r\n }\r\n /**\r\n * 执行甘特图导出操作\r\n * @async\r\n * @param {ExportOptions} [options={}] 导出配置选项\r\n * @returns {Promise<string | undefined>} 返回Base64格式的图片数据,或在未初始化时返回 undefined\r\n * @throws {Error} 导出过程中发生错误时抛出异常\r\n */\r\n async exportToImage(options: ExportOptions = {}): Promise<string | undefined> {\r\n if (!this._gantt) {\r\n // 保留这个 error\r\n console.error('ExportGanttPlugin: Gantt instance not available.');\r\n return undefined;\r\n }\r\n\r\n const {\r\n fileName = 'gantt-export',\r\n type = 'png',\r\n quality = 1,\r\n backgroundColor = '#ffffff',\r\n scale = window.devicePixelRatio || 1,\r\n download = true // 默认执行下载\r\n } = options;\r\n\r\n try {\r\n const { tempContainer, clonedGantt } = this.createFullSizeContainer(scale);\r\n\r\n try {\r\n await new Promise(resolve => requestAnimationFrame(resolve));\r\n\r\n const totalWidth =\r\n (clonedGantt.taskListTableInstance.getAllColsWidth() + clonedGantt.getAllDateColsWidth()) * scale;\r\n const totalHeight = clonedGantt.getAllRowsHeight() * scale;\r\n\r\n const exportCanvas = document.createElement('canvas');\r\n exportCanvas.width = totalWidth;\r\n exportCanvas.height = totalHeight;\r\n const ctx = exportCanvas.getContext('2d')!;\r\n\r\n ctx.fillStyle = backgroundColor;\r\n ctx.fillRect(0, 0, totalWidth, totalHeight);\r\n\r\n if (clonedGantt.taskListTableInstance?.canvas) {\r\n ctx.drawImage(\r\n clonedGantt.taskListTableInstance.canvas,\r\n 0,\r\n 0,\r\n clonedGantt.taskListTableInstance.getAllColsWidth() * scale,\r\n totalHeight\r\n );\r\n }\r\n\r\n const splitLineWidth = 3 * scale;\r\n const splitLineX = clonedGantt.taskListTableInstance.getAllColsWidth() * scale;\r\n ctx.fillStyle = 'rgb(225, 228, 232)';\r\n ctx.fillRect(splitLineX - splitLineWidth / 2, 0, splitLineWidth, totalHeight);\r\n\r\n const sourceX = 4 * scale;\r\n const sourceWidth = clonedGantt.canvas.width - sourceX;\r\n\r\n if (clonedGantt.canvas) {\r\n ctx.drawImage(\r\n clonedGantt.canvas,\r\n sourceX,\r\n 0,\r\n sourceWidth,\r\n clonedGantt.canvas.height,\r\n (clonedGantt.taskListTableInstance.getAllColsWidth() + 1.5) * scale,\r\n 0,\r\n (clonedGantt.getAllDateColsWidth() - 1.5) * scale,\r\n totalHeight\r\n );\r\n }\r\n\r\n return this.finalizeExport(exportCanvas, fileName, type, quality, download);\r\n } finally {\r\n tempContainer.remove();\r\n // 确保克隆的甘特图实例被释放\r\n clonedGantt.release();\r\n }\r\n } catch (error) {\r\n console.error('[Gantt Export Plugin] Export failed:', error);\r\n throw new Error(`甘特图导出失败: ${error instanceof Error ? error.message : '未知错误'}`);\r\n }\r\n }\r\n\r\n /**\r\n * 获取甘特图的 Base64 图片数据,不触发下载\r\n * @async\r\n * @param {Omit<ExportOptions, 'download'>} [options={}] 导出配置选项(不包含 download 参数)\r\n * @returns {Promise<string | undefined>} 返回 Base64 格式的图片数据,或在未初始化时返回 undefined\r\n * @throws {Error} 导出过程中发生错误时抛出异常\r\n */\r\n async exportToBase64(options: Omit<ExportOptions, 'download'> = {}): Promise<string | undefined> {\r\n // 调用 exportToImage 方法,但设置 download 为 false\r\n return this.exportToImage({\r\n ...options,\r\n download: false\r\n });\r\n }\r\n\r\n private createFullSizeContainer(scale: number) {\r\n if (!this._gantt) {\r\n // 保留这个 error\r\n throw new Error('ExportGanttPlugin: Gantt instance not available to create container.');\r\n }\r\n\r\n const tempContainer = document.createElement('div');\r\n tempContainer.style.position = 'fixed';\r\n tempContainer.style.left = '-9999px';\r\n tempContainer.style.overflow = 'hidden';\r\n tempContainer.style.width = `${window.innerWidth + 100}px`;\r\n tempContainer.style.height = `${window.innerHeight + 100}px`;\r\n document.body.appendChild(tempContainer);\r\n\r\n const clonedContainer = document.createElement('div');\r\n\r\n const totalWidth = this._gantt.taskListTableInstance.getAllColsWidth() + this._gantt.getAllDateColsWidth();\r\n const totalHeight = this._gantt.getAllRowsHeight();\r\n\r\n clonedContainer.style.width = `${totalWidth}px`;\r\n clonedContainer.style.height = `${totalHeight}px`;\r\n tempContainer.appendChild(clonedContainer);\r\n\r\n const clonedGantt = new VTableGantt.Gantt(clonedContainer, {\r\n ...this._gantt.options,\r\n records: this._gantt.records,\r\n taskListTable: {\r\n ...this._gantt.options.taskListTable,\r\n tableWidth: undefined as unknown as number,\r\n minTableWidth: undefined as unknown as number,\r\n maxTableWidth: undefined as unknown as number\r\n },\r\n plugins: []\r\n });\r\n\r\n clonedGantt.setPixelRatio(scale);\r\n\r\n // 禁用裁剪\r\n if ((clonedGantt as any).scenegraph?.ganttGroup) {\r\n (clonedGantt as any).scenegraph.ganttGroup.setAttribute('clip', false);\r\n }\r\n if ((clonedGantt.taskListTableInstance as any)?.scenegraph?.tableGroup) {\r\n (clonedGantt.taskListTableInstance as any).scenegraph.tableGroup.setAttribute('clip', false);\r\n }\r\n\r\n clonedGantt.scenegraph.stage.render();\r\n\r\n return { tempContainer, clonedGantt };\r\n }\r\n private finalizeExport(\r\n canvas: HTMLCanvasElement,\r\n fileName: string,\r\n type: string,\r\n quality: number,\r\n download: boolean = true\r\n ): string {\r\n const base64 = canvas.toDataURL(`image/${type}`, quality);\r\n\r\n // 如果需要下载,则创建下载链接\r\n if (download) {\r\n const link = document.createElement('a');\r\n link.download = `${fileName}.${type}`;\r\n link.href = base64;\r\n document.body.appendChild(link);\r\n link.click();\r\n document.body.removeChild(link);\r\n }\r\n\r\n return base64;\r\n }\r\n\r\n release(): void {\r\n this._gantt = null;\r\n }\r\n}\r\n"]}
|
package/dist/vtable-plugins.js
CHANGED
|
@@ -21947,7 +21947,7 @@
|
|
|
21947
21947
|
tempContainer.appendChild(clonedContainer);
|
|
21948
21948
|
const clonedGantt = new Gantt(clonedContainer, {
|
|
21949
21949
|
...this._gantt.options,
|
|
21950
|
-
records:
|
|
21950
|
+
records: this._gantt.records,
|
|
21951
21951
|
taskListTable: {
|
|
21952
21952
|
...this._gantt.options.taskListTable,
|
|
21953
21953
|
tableWidth: undefined,
|
|
@@ -88,4 +88,4 @@ var QQ=d,JQ=XK,tJ=tZ,eJ=function(t){if(!(this instanceof eJ))return new eJ(t);"o
|
|
|
88
88
|
* Copyright (c) 2011-2017 KARASZI Istvan <github@spam.raszi.hu>
|
|
89
89
|
*
|
|
90
90
|
* MIT Licensed
|
|
91
|
-
*/!function(t){const e=i,n=p,s=h,o=r,a={fs:e.constants,os:n.constants},l="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",c=/XXXXXX/,u=3,d=(a.O_CREAT||a.fs.O_CREAT)|(a.O_EXCL||a.fs.O_EXCL)|(a.O_RDWR||a.fs.O_RDWR),f="win32"===n.platform(),m=a.EBADF||a.os.errno.EBADF,g=a.ENOENT||a.os.errno.ENOENT,y=[],v=e.rmdirSync.bind(e);let b=!1;function _(t,r){return e.rm(t,{recursive:!0},r)}function w(t){return e.rmSync(t,{recursive:!0})}function x(t,r){const i=R(t,r),n=i[0],s=i[1];try{P(n)}catch(t){return s(t)}let o=n.tries;!function t(){try{const r=L(n);e.stat(r,(function(e){if(!e)return o-- >0?t():s(new Error("Could not get a unique tmp filename, max tries reached "+r));s(null,r)}))}catch(t){s(t)}}()}function S(t){const r=R(t)[0];P(r);let i=r.tries;do{const t=L(r);try{e.statSync(t)}catch(e){return t}}while(i-- >0);throw new Error("Could not get a unique tmp filename, max tries reached")}function T(t,r){const i=function(t){if(t&&!I(t))return r(t);r()};0<=t[0]?e.close(t[0],(function(){e.unlink(t[1],i)})):e.unlink(t[1],i)}function k(t){let r=null;try{0<=t[0]&&e.closeSync(t[0])}catch(t){if(!function(t){return N(t,-m,"EBADF")}(t)&&!I(t))throw t}finally{try{e.unlinkSync(t[1])}catch(t){I(t)||(r=t)}}if(null!==r)throw r}function C(t,e,r,i){const n=A(k,[e,t],i),s=A(T,[e,t],i,n);return r.keep||y.unshift(n),i?n:s}function E(t,r,i){const n=r.unsafeCleanup?_:e.rmdir.bind(e),s=A(r.unsafeCleanup?w:v,t,i),o=A(n,t,i,s);return r.keep||y.unshift(s),i?s:o}function A(t,e,r,i){let n=!1;return function s(o){if(!n){const a=i||s,l=y.indexOf(a);return l>=0&&y.splice(l,1),n=!0,r||t===v||t===w?t(e):t(e,o||function(){})}}}function O(t){let e=[],r=null;try{r=o.randomBytes(t)}catch(e){r=o.pseudoRandomBytes(t)}for(var i=0;i<t;i++)e.push(l[r[i]%l.length]);return e.join("")}function B(t){return void 0===t}function R(t,e){if("function"==typeof t)return[{},t];if(B(t))return[{},e];const r={};for(const e of Object.getOwnPropertyNames(t))r[e]=t[e];return[r,e]}function L(t){const e=t.tmpdir;if(!B(t.name))return s.join(e,t.dir,t.name);if(!B(t.template))return s.join(e,t.dir,t.template).replace(c,O(6));const r=[t.prefix?t.prefix:"tmp","-",process.pid,"-",O(12),t.postfix?"-"+t.postfix:""].join("");return s.join(e,t.dir,r)}function P(t){t.tmpdir=F(t);const e=t.tmpdir;if(B(t.name)||M(t.name,"name",e),B(t.dir)||M(t.dir,"dir",e),!B(t.template)&&(M(t.template,"template",e),!t.template.match(c)))throw new Error(`Invalid template, found "${t.template}".`);if(!B(t.tries)&&isNaN(t.tries)||t.tries<0)throw new Error(`Invalid tries, found "${t.tries}".`);t.tries=B(t.name)?t.tries||u:1,t.keep=!!t.keep,t.detachDescriptor=!!t.detachDescriptor,t.discardDescriptor=!!t.discardDescriptor,t.unsafeCleanup=!!t.unsafeCleanup,t.dir=B(t.dir)?"":s.relative(e,D(t.dir,e)),t.template=B(t.template)?void 0:s.relative(e,D(t.template,e)),t.template=function(t){return null===t||B(t)||!t.trim()}(t.template)?void 0:s.relative(t.dir,t.template),t.name=B(t.name)?void 0:t.name,t.prefix=B(t.prefix)?"":t.prefix,t.postfix=B(t.postfix)?"":t.postfix}function D(t,e){return t.startsWith(e)?s.resolve(t):s.resolve(s.join(e,t))}function M(t,e,r){if("name"===e){if(s.isAbsolute(t))throw new Error(`${e} option must not contain an absolute path, found "${t}".`);let r=s.basename(t);if(".."===r||"."===r||r!==t)throw new Error(`${e} option must not contain a path, found "${t}".`)}else{if(s.isAbsolute(t)&&!t.startsWith(r))throw new Error(`${e} option must be relative to "${r}", found "${t}".`);let i=D(t,r);if(!i.startsWith(r))throw new Error(`${e} option must be relative to "${r}", found "${i}".`)}}function I(t){return N(t,-g,"ENOENT")}function N(t,e,r){return f?t.code===r:t.code===r&&t.errno===e}function F(t){return s.resolve(t&&t.tmpdir||n.tmpdir())}process.addListener("exit",(function(){if(b)for(;y.length;)try{y[0]()}catch(t){}})),Object.defineProperty(t.exports,"tmpdir",{enumerable:!0,configurable:!1,get:function(){return F()}}),t.exports.dir=function(t,r){const i=R(t,r),n=i[0],s=i[1];x(n,(function(t,r){if(t)return s(t);e.mkdir(r,n.mode||448,(function(t){if(t)return s(t);s(null,r,E(r,n,!1))}))}))},t.exports.dirSync=function(t){const r=R(t)[0],i=S(r);return e.mkdirSync(i,r.mode||448),{name:i,removeCallback:E(i,r,!0)}},t.exports.file=function(t,r){const i=R(t,r),n=i[0],s=i[1];x(n,(function(t,r){if(t)return s(t);e.open(r,d,n.mode||384,(function(t,i){if(t)return s(t);if(n.discardDescriptor)return e.close(i,(function(t){return s(t,r,void 0,C(r,-1,n,!1))}));{const t=n.discardDescriptor||n.detachDescriptor;s(null,r,i,C(r,t?-1:i,n,!1))}}))}))},t.exports.fileSync=function(t){const r=R(t)[0],i=r.discardDescriptor||r.detachDescriptor,n=S(r);var s=e.openSync(n,d,r.mode||384);return r.discardDescriptor&&(e.closeSync(s),s=void 0),{name:n,fd:s,removeCallback:C(n,i?-1:s,r,!0)}},t.exports.tmpName=x,t.exports.tmpNameSync=S,t.exports.setGracefulCleanup=function(){b=!0}}(W3);var U3=W3.exports;function $3(t,e){return new Promise((r=>{let i=!1;const n=()=>{i||(i=!0,t.removeListener(e,n),r())};t.addListener(e,n)}))}const{EventEmitter:V3}=s,G3=JA,X3=Mv,Y3=NE,q3=Fv,Z3=zv,K3=ob,Q3=cb;let J3=class extends V3{constructor({workbook:t,id:e,iterator:r,options:i}){super(),this.workbook=t,this.id=e,this.iterator=r,this.options=i||{},this.name=`Sheet${this.id}`,this._columns=null,this._keys={},this._dimensions=new Z3}destroy(){throw new Error("Invalid Operation: destroy")}get dimensions(){return this._dimensions}get columns(){return this._columns}getColumn(t){if("string"==typeof t){const e=this._keys[t];if(e)return e;t=q3.l2n(t)}if(this._columns||(this._columns=[]),t>this._columns.length){let e=this._columns.length+1;for(;e<=t;)this._columns.push(new Q3(this,e++))}return this._columns[t-1]}getColumnKey(t){return this._keys[t]}setColumnKey(t,e){this._keys[t]=e}deleteColumnKey(t){delete this._keys[t]}eachColumnKey(t){X3.each(this._keys,t)}async read(){try{for await(const t of this.parse())for(const{eventType:e,value:r}of t)this.emit(e,r);this.emit("finished")}catch(t){this.emit("error",t)}}async*[Symbol.asyncIterator](){for await(const t of this.parse())for(const{eventType:e,value:r}of t)"row"===e&&(yield r)}async*parse(){const{iterator:t,options:e}=this;let r=!1,i=!1,n=null;if("emit"===e.worksheets)r=!0;switch(e.hyperlinks){case"emit":i=!0;break;case"cache":this.hyperlinks=n={}}if(!r&&!i&&!n)return;const{sharedStrings:s,styles:o,properties:a}=this.workbook;let l=!1,h=!1,c=!1,u=null,d=null,p=null,f=null;for await(const e of G3(t)){const t=[];for(const{eventType:m,value:g}of e)if("opentag"===m){const e=g;if(r)switch(e.name){case"cols":l=!0,u=[];break;case"sheetData":h=!0;break;case"col":l&&u.push({min:parseInt(e.attributes.min,10),max:parseInt(e.attributes.max,10),width:parseFloat(e.attributes.width),styleId:parseInt(e.attributes.style||"0",10)});break;case"row":if(h){const t=parseInt(e.attributes.r,10);if(d=new K3(this,t),e.attributes.ht&&(d.height=parseFloat(e.attributes.ht)),e.attributes.s){const t=parseInt(e.attributes.s,10),r=o.getStyleModel(t);r&&(d.style=r)}}break;case"c":d&&(p={ref:e.attributes.r,s:parseInt(e.attributes.s,10),t:e.attributes.t});break;case"f":p&&(f=p.f={text:""});break;case"v":case"is":case"t":p&&(f=p.v={text:""})}if(i||n)switch(e.name){case"hyperlinks":c=!0;break;case"hyperlink":if(c){const r={ref:e.attributes.ref,rId:e.attributes["r:id"]};i?t.push({eventType:"hyperlink",value:r}):n[r.ref]=r}}}else if("text"===m)r&&f&&(f.text+=g);else if("closetag"===m){const e=g;if(r)switch(e.name){case"cols":l=!1,this._columns=Q3.fromModel(u);break;case"sheetData":h=!1;break;case"row":this._dimensions.expandRow(d),t.push({eventType:"row",value:d}),d=null;break;case"c":if(d&&p){const t=q3.decodeAddress(p.ref),e=d.getCell(t.col);if(p.s){const t=o.getStyleModel(p.s);t&&(e.style=t)}if(p.f){const t={formula:p.f.text};p.v&&("str"===p.t?t.result=Y3.xmlDecode(p.v.text):t.result=parseFloat(p.v.text)),e.value=t}else if(p.v)switch(p.t){case"s":{const t=parseInt(p.v.text,10);e.value=s?s[t]:{sharedString:t};break}case"inlineStr":case"str":e.value=Y3.xmlDecode(p.v.text);break;case"e":e.value={error:p.v.text};break;case"b":e.value=0!==parseInt(p.v.text,10);break;default:Y3.isDateFmt(e.numFmt)?e.value=Y3.excelToDate(parseFloat(p.v.text),a.model&&a.model.date1904):e.value=parseFloat(p.v.text)}if(n){const t=n[p.ref];t&&(e.text=e.value,e.value=void 0,e.hyperlink=t)}p=null}}if((i||n)&&"hyperlinks"===e.name)c=!1}t.length>0&&(yield t)}}};var t4=J3;const{EventEmitter:e4}=s,r4=JA,i4=Hv,n4=ZR;var s4=class extends e4{constructor({workbook:t,id:e,iterator:r,options:i}){super(),this.workbook=t,this.id=e,this.iterator=r,this.options=i}get count(){return this.hyperlinks&&this.hyperlinks.length||0}each(t){return this.hyperlinks.forEach(t)}async read(){const{iterator:t,options:e}=this;let r=!1,i=null;switch(e.hyperlinks){case"emit":r=!0;break;case"cache":this.hyperlinks=i={}}if(r||i)try{for await(const e of r4(t))for(const{eventType:t,value:n}of e)if("opentag"===t){const t=n;if("Relationship"===t.name){const e=t.attributes.Id;if(t.attributes.Type===n4.Hyperlink){const n={type:i4.RelationshipType.Styles,rId:e,target:t.attributes.Target,targetMode:t.attributes.TargetMode};r?this.emit("hyperlink",n):i[n.rId]=n}}}this.emit("finished")}catch(t){this.emit("error",t)}else this.emit("finished")}};const o4=i,{EventEmitter:a4}=s,{PassThrough:l4,Readable:h4}=PE,c4=n,u4=f0,d4=U3,p4=async function*(t){const e=[];let r;t.on("data",(t=>e.push(t)));const i=new Promise((t=>r=t));let n=!1;t.on("end",(()=>{n=!0,r()}));let s=!1;for(t.on("error",(t=>{s=t,r()}));!n||e.length>0;){if(0===e.length)t.resume(),await Promise.race([$3(t,"data"),i]);else{t.pause();const r=e.shift();yield r}if(s)throw s}r()},f4=JA,m4=kB,g4=qR,y4=aR,v4=t4,b4=s4;d4.setGracefulCleanup();class _4 extends a4{constructor(t,e={}){super(),this.input=t,this.options={worksheets:"emit",sharedStrings:"cache",hyperlinks:"ignore",styles:"ignore",entries:"ignore",...e},this.styles=new m4,this.styles.init()}_getStream(t){if(t instanceof c4.Readable||t instanceof h4)return t;if("string"==typeof t)return o4.createReadStream(t);throw new Error(`Could not recognise input: ${t}`)}async read(t,e){try{for await(const{eventType:r,value:i}of this.parse(t,e))switch(r){case"shared-strings":case"hyperlinks":this.emit(r,i);break;case"worksheet":this.emit(r,i),await i.read()}this.emit("end"),this.emit("finished")}catch(t){this.emit("error",t)}}async*[Symbol.asyncIterator](){for await(const{eventType:t,value:e}of this.parse())"worksheet"===t&&(yield e)}async*parse(t,e){e&&(this.options=e);const r=this.stream=this._getStream(t||this.input),i=u4.Parse({forceStream:!0});r.pipe(i);const n=[];for await(const t of p4(i)){let e,r;switch(t.path){case"_rels/.rels":break;case"xl/_rels/workbook.xml.rels":await this._parseRels(t);break;case"xl/workbook.xml":await this._parseWorkbook(t);break;case"xl/sharedStrings.xml":yield*this._parseSharedStrings(t);break;case"xl/styles.xml":await this._parseStyles(t);break;default:t.path.match(/xl\/worksheets\/sheet\d+[.]xml/)?(e=t.path.match(/xl\/worksheets\/sheet(\d+)[.]xml/),r=e[1],this.sharedStrings&&this.workbookRels?yield*this._parseWorksheet(p4(t),r):await new Promise(((e,i)=>{d4.file(((s,o,a,l)=>{if(s)return i(s);n.push({sheetNo:r,path:o,tempFileCleanupCallback:l});const h=o4.createWriteStream(o);return h.on("error",i),t.pipe(h),h.on("finish",(()=>e()))}))}))):t.path.match(/xl\/worksheets\/_rels\/sheet\d+[.]xml.rels/)&&(e=t.path.match(/xl\/worksheets\/_rels\/sheet(\d+)[.]xml.rels/),r=e[1],yield*this._parseHyperlinks(p4(t),r))}t.autodrain()}for(const{sheetNo:t,path:e,tempFileCleanupCallback:r}of n){let i=o4.createReadStream(e);i[Symbol.asyncIterator]||(i=i.pipe(new l4)),yield*this._parseWorksheet(i,t),r()}}_emitEntry(t){"emit"===this.options.entries&&this.emit("entry",t)}async _parseRels(t){const e=new y4;this.workbookRels=await e.parseStream(p4(t))}async _parseWorkbook(t){this._emitEntry({type:"workbook"});const e=new g4;await e.parseStream(p4(t)),this.properties=e.map.workbookPr,this.model=e.model}async*_parseSharedStrings(t){switch(this._emitEntry({type:"shared-strings"}),this.options.sharedStrings){case"cache":this.sharedStrings=[];break;case"emit":break;default:return}let e=null,r=[],i=0,n=null;for await(const s of f4(p4(t)))for(const{eventType:t,value:o}of s)if("opentag"===t){const t=o;switch(t.name){case"b":n=n||{},n.bold=!0;break;case"charset":n=n||{},n.charset=parseInt(t.attributes.charset,10);break;case"color":n=n||{},n.color={},t.attributes.rgb&&(n.color.argb=t.attributes.argb),t.attributes.val&&(n.color.argb=t.attributes.val),t.attributes.theme&&(n.color.theme=t.attributes.theme);break;case"family":n=n||{},n.family=parseInt(t.attributes.val,10);break;case"i":n=n||{},n.italic=!0;break;case"outline":n=n||{},n.outline=!0;break;case"rFont":n=n||{},n.name=t.value;break;case"si":n=null,r=[],e=null;break;case"sz":n=n||{},n.size=parseInt(t.attributes.val,10);break;case"strike":break;case"t":e=null;break;case"u":n=n||{},n.underline=!0;break;case"vertAlign":n=n||{},n.vertAlign=t.attributes.val}}else if("text"===t)e=e?e+o:o;else if("closetag"===t){switch(o.name){case"r":r.push({font:n,text:e}),n=null,e=null;break;case"si":"cache"===this.options.sharedStrings?this.sharedStrings.push(r.length?{richText:r}:e):"emit"===this.options.sharedStrings&&(yield{index:i++,text:r.length?{richText:r}:e}),r=[],n=null,e=null}}}async _parseStyles(t){this._emitEntry({type:"styles"}),"cache"===this.options.styles&&(this.styles=new m4,await this.styles.parseStream(p4(t)))}*_parseWorksheet(t,e){this._emitEntry({type:"worksheet",id:e});const r=new v4({workbook:this,id:e,iterator:t,options:this.options}),i=(this.workbookRels||[]).find((t=>t.Target===`worksheets/sheet${e}.xml`)),n=i&&(this.model.sheets||[]).find((t=>t.rId===i.Id));n&&(r.id=n.id,r.name=n.name,r.state=n.state),"emit"===this.options.worksheets&&(yield{eventType:"worksheet",value:r})}*_parseHyperlinks(t,e){this._emitEntry({type:"hyperlinks",id:e});const r=new b4({workbook:this,id:e,iterator:t,options:this.options});"emit"===this.options.hyperlinks&&(yield{eventType:"hyperlinks",value:r})}}_4.Options={worksheets:["emit","ignore"],sharedStrings:["cache","emit","ignore"],hyperlinks:["cache","emit","ignore"],styles:["cache","ignore"],entries:["emit","ignore"]};const w4={Workbook:AH,ModelContainer:BH,stream:{xlsx:{WorkbookWriter:p0,WorkbookReader:_4}}};Object.assign(w4,Hv);var x4=w4;if(parseInt(process.versions.node.split(".")[0],10)<10)throw new Error("For node versions older than 10, please use the ES5 Import: https://github.com/exceljs/exceljs#es5-imports");var S4=pt(x4);class T4{id=`excel-import-plugin-${Date.now()}`;name="ExcelImportPlugin";runTime=[m.TABLE_EVENT_TYPE.INITIALIZED];options;_tableInstance=null;constructor(t){this.options={autoTable:!0,autoColumns:!0,delimiter:",",exportData:!1,batchSize:1e3,enableBatchProcessing:!0,asyncDelay:5,...t},t?.id&&(this.id=t.id)}run(...t){const e=t[2];this._tableInstance=e}release(){this._tableInstance=null}async importFile(){return this.import("file")}async import(t,e,r){const i={...this.options,...r};if("file"===t)return this._importFromFileDialog(i);if("string"==typeof e)return this._importFromString(t,e,i);if(Array.isArray(e)||"object"==typeof e){if("json"!==t)throw new Error("只有JSON格式支持从对象导入");return this._importFromData("json",e,i)}throw new Error("Invalid import source")}async _importFromFileDialog(t){return new Promise(((e,r)=>{if(!this._tableInstance)return void r(new Error("表格实例不存在或已销毁,无法导入数据!"));const i=document.createElement("input");i.type="file",i.style.display="none",document.body.appendChild(i),i.addEventListener("change",(async n=>{try{const s=n.target.files?.[0];if(!s)return document.body.removeChild(i),void r(new Error("未选择文件"));const o=await this._parseFile(s,t);t.autoTable&&this._tableInstance&&(t.autoColumns&&this._tableInstance.updateOption({columns:o.columns,plugins:[this]}),this._tableInstance.setRecords(o.records)),i.value="",document.body.removeChild(i),e(o)}catch(t){document.body.removeChild(i),r(t)}})),i.click()}))}async _importFromString(t,e,r){let i;switch(t){case"csv":i=await this._parseCSVString(e,r);break;case"json":i=await this._parseJSONString(e,r);break;case"html":i=await this._parseHTMLString(e,r);break;default:throw new Error(`不支持的导入类型: ${t}`)}return r.autoTable&&this._tableInstance&&(r.autoColumns&&this._tableInstance.updateOption({columns:i.columns,plugins:[this]}),this._tableInstance.setRecords(i.records)),i}async _importFromData(t,e,r){let i;if("json"!==t)throw new Error(`不支持的数据类型: ${t}`);return i=await this._parseJSONData(e,r),r.autoTable&&this._tableInstance&&(r.autoColumns&&this._tableInstance.updateOption({columns:i.columns,plugins:[this]}),this._tableInstance.setRecords(i.records)),i}async _parseFile(t,e){const r={...this.options,...e},i=this._getFileExtension(t.name).toLowerCase();switch(i){case"xlsx":case"xls":return await this._parseExcelFile(t,r);case"csv":return await this._parseCsvFile(t,r);case"json":return await this._parseJsonFile(t,r);case"html":case"htm":return await this._parseHtmlFile(t,r);default:throw new Error(`不支持的文件类型: ${i}`)}}_getFileExtension(t){const e=t.split(".");return e.length>1?e[e.length-1]:""}async _parseExcelFile(t,e){const r={...this.options,...e};return await T4.importExcelToVTableData(t,r)}async _parseCsvFile(t,e){const r={...this.options,...e},i=await t.text();return this._parseCSVString(i,r)}async _parseJsonFile(t,e){const r={...this.options,...e},i=await t.text();return this._parseJSONString(i,r)}async _parseHtmlFile(t,e){const r={...this.options,...e},i=await t.text();return this._parseHTMLString(i,r)}_buildColumnsFromHeaders(t){return 1===t.length?t[0].map(((t,e)=>({field:`col${e}`,title:t||`列${e+1}`,cellType:"text",headerType:"text"}))):T4.buildColumns(t)}static async importExcelToVTableData(t,e){const r=new S4.Workbook;await r.xlsx.load(await t.arrayBuffer());const i=r.worksheets[0];if(!i)throw new Error("Excel 文件无有效工作表");const n=e?.headerRowCount??this.detectHeaderRowCount(i),s=[];for(let t=1;t<=n;t++){const e=i.getRow(t);s.push(Array.prototype.slice.call(e.values,1))}const o=T4.buildColumns(s),a=[],l=[];i.eachRow(((t,e)=>{if(e<=n)return;const r=Array.prototype.slice.call(t.values,1);l.push(r)}));const h=e?.batchSize||1e3;if(!1!==e?.enableBatchProcessing&&l.length>h)for(let t=0;t<l.length;t+=h){const r=l.slice(t,t+h).map((t=>{const e={};return t.forEach(((t,r)=>{e[`col${r}`]=t})),e}));a.push(...r),t+h<l.length&&await new Promise((t=>setTimeout(t,e?.asyncDelay||5)))}else l.forEach((t=>{const e={};t.forEach(((t,r)=>{e[`col${r}`]=t})),a.push(e)}));if(e?.exportData){const t=T4._generateJavaScriptExport(o,a),e=new Blob([t],{type:"text/javascript"}),r=URL.createObjectURL(e),i=document.createElement("a");i.href=r,i.download="vtable-data.js",document.body.appendChild(i),i.click(),setTimeout((()=>{document.body.removeChild(i),URL.revokeObjectURL(r)}),100)}return{columns:o,records:a}}static detectHeaderRowCount(t){let e=1,r=1;for(;;){const i=t.getRow(e),n=Array.prototype.slice.call(i.values,1);let s=!1;for(let t=1;t<n.length;t++)if(void 0!==n[t]&&""!==n[t]&&n[t]===n[t-1]){s=!0;break}if(!s)break;r++,e++}return r}static buildColumns(t,e=0,r,i=0){const n=t[i],s=[];r=r??n.length;let o=e;for(;o<r;){const e=String(n[o]||`列${o+1}`);let a=1;for(;o+a<r&&n[o+a]===e;)a++;if(i<t.length-1){const r=T4.buildColumns(t,o,o+a,i+1);1===r.length?s.push(r[0]):s.push({title:e,columns:r,hideColumnsSubHeader:!1})}else s.push({field:`col${o}`,title:e,cellType:"text",headerType:"text"});o+=a}return s}async _parseCSVString(t,e){const r=t.split("\n").filter((t=>t.trim()));if(0===r.length)throw new Error("CSV文件为空");const i=e.delimiter||",",n=t=>t.split(i).map((t=>t.trim().replace(/^"|"$/g,""))),s=r.slice(0,1).map(n),o=r.slice(1),a=this._buildColumnsFromHeaders(s),l=[];return await this._processBatchRecords(o,e,(async t=>{const e=t.map((t=>{const e=n(t),r={};return e.forEach(((t,e)=>{r[`col${e}`]=t||""})),r}));l.push(...e)})),e.exportData&&this._exportToJS(a,l),{columns:a,records:l}}async _parseJSONString(t,e){let r;try{r=JSON.parse(t)}catch(t){throw new Error("JSON文件格式错误")}const i=await this._parseJSONData(r,e);return e.exportData&&this._exportToJS(i.columns,i.records),i}async _parseHTMLString(t,e){const r=(new DOMParser).parseFromString(t,"text/html").querySelector("table");if(!r)throw new Error("HTML文件中未找到表格");const i=Array.from(r.querySelectorAll("tr"));if(0===i.length)throw new Error("表格中没有数据行");const n=i.slice(0,1).map((t=>Array.from(t.querySelectorAll("th, td")).map((t=>t.textContent?.trim()||"")))),s=i.slice(1),o=this._buildColumnsFromHeaders(n),a=[];return await this._processBatchRecords(s,e,(async t=>{const e=t.map((t=>{const e=Array.from(t.querySelectorAll("td")).map((t=>t.textContent?.trim()||"")),r={};return e.forEach(((t,e)=>{r[`col${e}`]=t||""})),r}));a.push(...e)})),e.exportData&&this._exportToJS(o,a),{columns:o,records:a}}async _parseJSONData(t,e){let r;if("object"==typeof t&&!Array.isArray(t)&&t&&"columns"in t&&"records"in t){const i=t,n=[];await this._processBatchRecords(i.records,e,(async t=>{const e=t.map((t=>({...t})));n.push(...e)})),r={columns:i.columns,records:n}}else{if(!(Array.isArray(t)&&t.length>0))throw new Error("不支持的JSON格式");{const i=t[0],n=Object.keys(i).map((t=>({field:t,title:t,cellType:"text",headerType:"text"}))),s=[];await this._processBatchRecords(t,e,(async t=>{const e=t.map((t=>({...t})));s.push(...e)})),r={columns:n,records:s}}}return e.exportData&&this._exportToJS(r.columns,r.records),r}static _generateJavaScriptExport(t,e){const r=(t,e="")=>{if(null==t)return"null";if("string"==typeof t)return`'${t.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}'`;if("number"==typeof t||"boolean"==typeof t)return String(t);if(Array.isArray(t)){if(0===t.length)return"[]";return`[${t.map((t=>r(t,e+" "))).join(", ")}]`}if("object"==typeof t){const i=Object.entries(t).map((([t,i])=>`${e} ${t}: ${r(i,e+" ")}`)).join(",\n");return`{\n${i}\n${e}}`}return String(t)},i=(t,e=" ")=>{const n=Object.entries(t).map((([t,n])=>{if("columns"===t&&Array.isArray(n)){const r=n.map((t=>i(t,e+" "))).join(",\n");return`${e} ${t}: [\n${r}\n${e} ]`}return`${e} ${t}: ${r(n)}`})).join(",\n");return`${e}{\n${n}\n${e}}`},n=t.map((t=>i(t))).join(",\n"),s=e.map((t=>{const e=Object.entries(t).map((([t,e])=>` ${t}: ${r(e)}`)).join(",\n");return` {\n${e}\n }`})).join(",\n");return`// VTable 数据导出 - JavaScript 对象字面量格式\n// 生成时间: ${(new Date).toLocaleString()}\n\nconst vtableData = {\n columns: [\n${n}\n ],\n records: [\n${s}\n ]\n};\n`}_exportToJS(t,e){const r=T4._generateJavaScriptExport(t,e),i=new Blob([r],{type:"text/javascript"}),n=URL.createObjectURL(i),s=document.createElement("a");s.href=n,s.download="vtable-data.js",document.body.appendChild(s),s.click(),setTimeout((()=>{document.body.removeChild(s),URL.revokeObjectURL(n)}),100)}async _processBatchRecords(t,e,r){if(!e.enableBatchProcessing||t.length<=(e.batchSize||1e3))return void await r(t,0);const i=e.batchSize||1e3,n=Math.ceil(t.length/i);for(let s=0;s<n;s++){const o=s*i,a=Math.min(o+i,t.length),l=t.slice(o,a);await r(l,s),s<n-1&&await new Promise((t=>setTimeout(t,e.asyncDelay||5)))}}}t.AddRowColumnPlugin=class{id=`add-row-column-${Date.now()}`;name="Add Row Column";runTime=[m.TABLE_EVENT_TYPE.MOUSEENTER_CELL,m.TABLE_EVENT_TYPE.MOUSELEAVE_CELL,m.TABLE_EVENT_TYPE.MOUSELEAVE_TABLE];pluginOptions;table;hoverCell;hideAllTimeoutId_addColumn;hideAllTimeoutId_addRow;leftDotForAddColumn;rightDotForAddColumn;addIconForAddColumn;addLineForAddColumn;topDotForAddRow;bottomDotForAddRow;addIconForAddRow;addLineForAddRow;constructor(t={addColumnEnable:!0,addRowEnable:!0}){this.id=t.id??this.id,this.pluginOptions=t,this.pluginOptions.addColumnEnable=this.pluginOptions.addColumnEnable??!0,this.pluginOptions.addRowEnable=this.pluginOptions.addRowEnable??!0,this.pluginOptions.addColumnEnable&&(this.initAddColumnDomElement(),this.bindEventForAddColumn()),this.pluginOptions.addRowEnable&&(this.initAddRowDomElement(),this.bindEventForAddRow())}run(...t){const e=t[0],r=t[1],i=t[2];if(this.table=i,r===m.TABLE_EVENT_TYPE.MOUSEENTER_CELL){clearTimeout(this.hideAllTimeoutId_addColumn),clearTimeout(this.hideAllTimeoutId_addRow);const t=i.canvas.getBoundingClientRect(),r=i.getCellAtRelativePosition(e.event.clientX-t.left,e.event.clientY-t.top);this.hoverCell=r;const n=i.getCellRelativeRect(r.col,r.row);if(this.pluginOptions.addColumnEnable){const e=i.isSeriesNumber(r.col,0);this.showDotForAddColumn(t.top-6,n.left+t.left,n.right+t.left,!e)}if(this.pluginOptions.addRowEnable){const e=i.isHeader(r.col,r.row);this.showDotForAddRow(n.top+t.top,t.left-6,n.bottom+t.top,!e,!e)}}else r===m.TABLE_EVENT_TYPE.MOUSELEAVE_CELL||r===m.TABLE_EVENT_TYPE.MOUSELEAVE_TABLE&&(this.pluginOptions.addColumnEnable&&this.delayHideAllForAddColumn(),this.pluginOptions.addRowEnable&&this.delayHideAllForAddRow())}initAddColumnDomElement(){this.leftDotForAddColumn=document.createElement("div"),this.leftDotForAddColumn.style.width="6px",this.leftDotForAddColumn.style.height="6px",this.leftDotForAddColumn.style.backgroundColor="#4A90E2",this.leftDotForAddColumn.style.position="absolute",this.leftDotForAddColumn.style.cursor="pointer",this.leftDotForAddColumn.style.zIndex="1000",this.leftDotForAddColumn.style.borderRadius="50%",this.leftDotForAddColumn.style.border="1px solid white",this.leftDotForAddColumn.style.boxShadow="0 1px 3px rgba(0,0,0,0.2)",document.body.appendChild(this.leftDotForAddColumn),this.rightDotForAddColumn=document.createElement("div"),this.rightDotForAddColumn.style.width="6px",this.rightDotForAddColumn.style.height="6px",this.rightDotForAddColumn.style.backgroundColor="#4A90E2",this.rightDotForAddColumn.style.position="absolute",this.rightDotForAddColumn.style.cursor="pointer",this.rightDotForAddColumn.style.zIndex="1000",this.rightDotForAddColumn.style.borderRadius="50%",this.rightDotForAddColumn.style.border="1px solid white",this.rightDotForAddColumn.style.boxShadow="0 1px 3px rgba(0,0,0,0.2)",document.body.appendChild(this.rightDotForAddColumn),this.addIconForAddColumn=document.createElement("div"),this.addIconForAddColumn.style.width="18px",this.addIconForAddColumn.style.height="18px",this.addIconForAddColumn.style.backgroundColor="#4A90E2",this.addIconForAddColumn.style.position="absolute",this.addIconForAddColumn.style.zIndex="1001",this.addIconForAddColumn.style.display="none",this.addIconForAddColumn.style.borderRadius="50%",this.addIconForAddColumn.style.boxShadow="0 2px 5px rgba(0,0,0,0.2)",this.addIconForAddColumn.style.display="flex",this.addIconForAddColumn.style.justifyContent="center",this.addIconForAddColumn.style.alignItems="center",this.addIconForAddColumn.style.border="1px solid white",document.body.appendChild(this.addIconForAddColumn);const t=document.createElement("div");t.textContent="+",t.style.color="white",t.style.fontSize="18px",t.style.fontWeight="bold",t.style.lineHeight="15px",t.style.userSelect="none",t.style.cursor="pointer",t.style.verticalAlign="top",t.style.textAlign="center",this.addIconForAddColumn.appendChild(t),this.addLineForAddColumn=document.createElement("div"),this.addLineForAddColumn.style.width="2px",this.addLineForAddColumn.style.height="10px",this.addLineForAddColumn.style.backgroundColor="#4A90E2",this.addLineForAddColumn.style.position="absolute",this.addLineForAddColumn.style.zIndex="1001",this.addLineForAddColumn.style.display="none",document.body.appendChild(this.addLineForAddColumn)}bindEventForAddColumn(){this.leftDotForAddColumn.addEventListener("mouseenter",(()=>{clearTimeout(this.hideAllTimeoutId_addColumn),this.addIconForAddColumn.style.display="block";const t=this.leftDotForAddColumn.offsetWidth,e=this.leftDotForAddColumn.offsetHeight;this.showAddIconForAddColumn(this.leftDotForAddColumn.offsetLeft+t/2,this.leftDotForAddColumn.offsetTop+e/2,!0),this.showSplitLineForAddColumn(this.leftDotForAddColumn.offsetLeft+t/2-1,this.leftDotForAddColumn.offsetTop+e/2+2,this.table.getDrawRange().height)})),this.rightDotForAddColumn.addEventListener("mouseenter",(()=>{clearTimeout(this.hideAllTimeoutId_addColumn),this.addIconForAddColumn.style.display="block";const t=this.rightDotForAddColumn.offsetWidth,e=this.rightDotForAddColumn.offsetHeight;this.showAddIconForAddColumn(this.rightDotForAddColumn.offsetLeft+t/2,this.rightDotForAddColumn.offsetTop+e/2,!1),this.showSplitLineForAddColumn(this.rightDotForAddColumn.offsetLeft+t/2-1,this.rightDotForAddColumn.offsetTop+e/2+2,this.table.getDrawRange().height)})),this.addIconForAddColumn.addEventListener("mouseleave",(()=>{this.addIconForAddColumn.style.display="none",this.addLineForAddColumn.style.display="none",this.delayHideAllForAddColumn()})),this.addIconForAddColumn.addEventListener("click",(t=>{const e="left"===this.addIconForAddColumn.dataset.addIconType,r=this.table.options.columns,i=this.hoverCell.col,n=e?i:i+1;this.pluginOptions.addColumnCallback?this.pluginOptions.addColumnCallback(n):(r.splice(n,0,{field:"",title:`New Column ${i}`,width:100}),this.table.updateColumns(r)),this.delayHideAllForAddColumn(0)}))}showDotForAddColumn(t,e,r,i=!0,n=!0){const s=this.leftDotForAddColumn.offsetWidth,o=this.leftDotForAddColumn.offsetHeight;this.leftDotForAddColumn.style.left=e-s/2+"px",this.leftDotForAddColumn.style.top=t-o/2+"px",this.rightDotForAddColumn.style.left=r-s/2+"px",this.rightDotForAddColumn.style.top=t-o/2+"px",this.leftDotForAddColumn.style.display=i?"block":"none",this.rightDotForAddColumn.style.display=n?"block":"none"}showAddIconForAddColumn(t,e,r){const i=this.addIconForAddColumn.offsetWidth,n=this.addIconForAddColumn.offsetHeight,s=this.leftDotForAddColumn.offsetHeight;this.addIconForAddColumn.style.left=t-i/2+"px",this.addIconForAddColumn.style.top=e-n/2-s/2+"px",this.addIconForAddColumn.dataset.addIconType=r?"left":"right"}showSplitLineForAddColumn(t,e,r){this.addLineForAddColumn.style.left=`${t}px`,this.addLineForAddColumn.style.top=`${e}px`,this.addLineForAddColumn.style.height=`${r}px`,this.addLineForAddColumn.style.display="block"}delayHideAllForAddColumn(t=1e3){this.hideAllTimeoutId_addColumn=setTimeout((()=>{this.addIconForAddColumn.style.display="none",this.addLineForAddColumn.style.display="none",this.leftDotForAddColumn.style.display="none",this.rightDotForAddColumn.style.display="none"}),t)}initAddRowDomElement(){this.topDotForAddRow=document.createElement("div"),this.topDotForAddRow.style.width="6px",this.topDotForAddRow.style.height="6px",this.topDotForAddRow.style.backgroundColor="#4A90E2",this.topDotForAddRow.style.position="absolute",this.topDotForAddRow.style.cursor="pointer",this.topDotForAddRow.style.zIndex="1000",this.topDotForAddRow.style.borderRadius="50%",this.topDotForAddRow.style.border="1px solid white",this.topDotForAddRow.style.boxShadow="0 1px 3px rgba(0,0,0,0.2)",document.body.appendChild(this.topDotForAddRow),this.bottomDotForAddRow=document.createElement("div"),this.bottomDotForAddRow.style.width="6px",this.bottomDotForAddRow.style.height="6px",this.bottomDotForAddRow.style.backgroundColor="#4A90E2",this.bottomDotForAddRow.style.position="absolute",this.bottomDotForAddRow.style.cursor="pointer",this.bottomDotForAddRow.style.zIndex="1000",this.bottomDotForAddRow.style.borderRadius="50%",this.bottomDotForAddRow.style.border="1px solid white",this.bottomDotForAddRow.style.boxShadow="0 1px 3px rgba(0,0,0,0.2)",document.body.appendChild(this.bottomDotForAddRow),this.addIconForAddRow=document.createElement("div"),this.addIconForAddRow.style.width="18px",this.addIconForAddRow.style.height="18px",this.addIconForAddRow.style.backgroundColor="#4A90E2",this.addIconForAddRow.style.position="absolute",this.addIconForAddRow.style.zIndex="1001",this.addIconForAddRow.style.display="none",this.addIconForAddRow.style.borderRadius="50%",this.addIconForAddRow.style.boxShadow="0 2px 5px rgba(0,0,0,0.2)",this.addIconForAddRow.style.display="flex",this.addIconForAddRow.style.justifyContent="center",this.addIconForAddRow.style.alignItems="center",this.addIconForAddRow.style.border="1px solid white",document.body.appendChild(this.addIconForAddRow);const t=document.createElement("div");t.textContent="+",t.style.color="white",t.style.fontSize="18px",t.style.fontWeight="bold",t.style.lineHeight="15px",t.style.userSelect="none",t.style.cursor="pointer",t.style.verticalAlign="top",t.style.textAlign="center",this.addIconForAddRow.appendChild(t),this.addLineForAddRow=document.createElement("div"),this.addLineForAddRow.style.width="10px",this.addLineForAddRow.style.height="2px",this.addLineForAddRow.style.backgroundColor="#4A90E2",this.addLineForAddRow.style.position="absolute",this.addLineForAddRow.style.zIndex="1001",this.addLineForAddRow.style.display="none",document.body.appendChild(this.addLineForAddRow)}bindEventForAddRow(){this.topDotForAddRow.addEventListener("mouseenter",(()=>{clearTimeout(this.hideAllTimeoutId_addRow),this.addIconForAddRow.style.display="block";const t=this.topDotForAddRow.offsetWidth,e=this.topDotForAddRow.offsetHeight;this.showAddIconForAddRow(this.topDotForAddRow.offsetLeft+t/2,this.topDotForAddRow.offsetTop+e/2,!0),this.showSplitLineForAddRow(this.topDotForAddRow.offsetLeft+t+2,this.topDotForAddRow.offsetTop+e/2-1,this.table.getDrawRange().width)})),this.bottomDotForAddRow.addEventListener("mouseenter",(()=>{clearTimeout(this.hideAllTimeoutId_addRow),this.addIconForAddRow.style.display="block";const t=this.bottomDotForAddRow.offsetWidth,e=this.bottomDotForAddRow.offsetHeight;this.showAddIconForAddRow(this.bottomDotForAddRow.offsetLeft+t/2,this.bottomDotForAddRow.offsetTop+e/2,!1),this.showSplitLineForAddRow(this.bottomDotForAddRow.offsetLeft+t+2,this.bottomDotForAddRow.offsetTop+e/2-1,this.table.getDrawRange().height)})),this.addIconForAddRow.addEventListener("mouseleave",(()=>{this.addIconForAddRow.style.display="none",this.addLineForAddRow.style.display="none",this.delayHideAllForAddRow()})),this.addIconForAddRow.addEventListener("click",(t=>{const e="top"===this.addIconForAddRow.dataset.addIconType,r=this.hoverCell.row,i=e?r:r+1;if(this.pluginOptions.addRowCallback)this.pluginOptions.addRowCallback(i);else{const t=this.table.getRecordIndexByCell(0,i);this.table.addRecord({},t)}this.delayHideAllForAddRow(0)}))}showDotForAddRow(t,e,r,i=!0,n=!0){const s=this.topDotForAddRow.offsetWidth,o=this.topDotForAddRow.offsetHeight;this.topDotForAddRow.style.left=e-s/2+"px",this.topDotForAddRow.style.top=t-o/2+"px",this.bottomDotForAddRow.style.left=e-s/2+"px",this.bottomDotForAddRow.style.top=r-o/2+"px",this.topDotForAddRow.style.display=i?"block":"none",this.bottomDotForAddRow.style.display=n?"block":"none"}showAddIconForAddRow(t,e,r){const i=this.addIconForAddRow.offsetWidth,n=this.addIconForAddRow.offsetHeight,s=this.topDotForAddRow.offsetWidth;this.addIconForAddRow.style.left=t-i/2-s/2+"px",this.addIconForAddRow.style.top=e-n/2+"px",this.addIconForAddRow.dataset.addIconType=r?"top":"bottom"}showSplitLineForAddRow(t,e,r){this.addLineForAddRow.style.left=`${t}px`,this.addLineForAddRow.style.top=`${e}px`,this.addLineForAddRow.style.width=`${r}px`,this.addLineForAddRow.style.display="block"}delayHideAllForAddRow(t=1e3){this.hideAllTimeoutId_addRow=setTimeout((()=>{this.addIconForAddRow.style.display="none",this.addLineForAddRow.style.display="none",this.topDotForAddRow.style.display="none",this.bottomDotForAddRow.style.display="none"}),t)}release(){this.leftDotForAddColumn.remove(),this.rightDotForAddColumn.remove(),this.addIconForAddColumn.remove(),this.addLineForAddColumn.remove(),this.topDotForAddRow.remove(),this.bottomDotForAddRow.remove(),this.addIconForAddRow.remove(),this.addLineForAddRow.remove()}},t.CarouselAnimationPlugin=class{table;rowCount;colCount;animationDuration;animationDelay;animationEasing;replaceScrollAction;playing;row;col;willUpdateRow=!1;willUpdateCol=!1;customDistRowFunction;customDistColFunction;constructor(t,e){this.table=t,this.rowCount=e?.rowCount??void 0,this.colCount=e?.colCount??void 0,this.animationDuration=e?.animationDuration??500,this.animationDelay=e?.animationDelay??1e3,this.animationEasing=e?.animationEasing??"linear",this.replaceScrollAction=e?.replaceScrollAction??!1,this.customDistColFunction=e.customDistColFunction,this.customDistRowFunction=e.customDistRowFunction,this.reset(),this.init()}init(){this.replaceScrollAction&&(this.table.disableScroll(),this.table.scenegraph.stage.addEventListener("wheel",this.onScrollEnd.bind(this)))}reset(){this.playing=!1,this.row=this.table.frozenRowCount,this.col=this.table.frozenColCount}onScrollEnd(t){this.rowCount?(t.deltaY>0?(this.row+=this.rowCount,this.row=Math.min(this.row,this.table.rowCount-this.table.frozenRowCount)):t.deltaY<0&&(this.row-=this.rowCount,this.row=Math.max(this.row,this.table.frozenRowCount)),this.table.scrollToRow(this.row,{duration:this.animationDuration,easing:this.animationEasing})):this.colCount&&(t.deltaX>0?(this.col+=this.colCount,this.col=Math.min(this.col,this.table.colCount-this.table.frozenColCount)):t.deltaX<0&&(this.col-=this.colCount,this.col=Math.max(this.col,this.table.frozenColCount)),this.table.scrollToCol(this.col,{duration:this.animationDuration,easing:this.animationEasing}))}play(){this.playing=!0,this.rowCount&&!this.willUpdateRow?this.updateRow():this.colCount&&!this.willUpdateCol&&this.updateCol()}pause(){this.playing=!1}updateRow(){if(!this.playing||this.table.isReleased)return;let t=!0;const e=this.customDistRowFunction&&this.customDistRowFunction(this.row,this.table);e?(this.row=e.distRow,t=e.animation??!0):g(this.row)&&this.table.scenegraph.proxy.screenTopRow!==this.row?(this.row=this.table.frozenRowCount,t=!1):g(this.row)||this.table.scenegraph.proxy.screenTopRow===Math.floor(this.row)?this.row+=this.rowCount:(this.row=this.table.frozenRowCount,t=!1),this.table.scrollToRow(this.row,t?{duration:this.animationDuration,easing:this.animationEasing}:void 0),this.willUpdateRow=!0,setTimeout((()=>{this.willUpdateRow=!1,this.updateRow()}),this.animationDuration+this.animationDelay)}updateCol(){if(!this.playing||this.table.isReleased)return;let t=!0;const e=this.customDistColFunction&&this.customDistColFunction(this.col,this.table);e?(this.col=e.distCol,t=e.animation??!0):g(this.col)&&this.table.scenegraph.proxy.screenLeftCol!==this.col?(this.col=this.table.frozenColCount,t=!1):g(this.col)||this.table.scenegraph.proxy.screenLeftCol===Math.floor(this.col)?this.col+=this.colCount:(this.col=this.table.frozenColCount,t=!1),this.table.scrollToCol(this.col,t?{duration:this.animationDuration,easing:this.animationEasing}:void 0),this.willUpdateCol=!0,setTimeout((()=>{this.willUpdateCol=!1,this.updateCol()}),this.animationDuration+this.animationDelay)}},t.ColumnSeriesPlugin=class{id=`column-series-${Date.now()}`;name="Column Series";runTime=[m.TABLE_EVENT_TYPE.BEFORE_INIT,m.TABLE_EVENT_TYPE.BEFORE_KEYDOWN];pluginOptions;table;columns=[];constructor(t){this.id=t.id??this.id,this.pluginOptions=Object.assign({columnCount:100},t)}run(...t){if(t[1]===m.TABLE_EVENT_TYPE.BEFORE_INIT){const e=t[0],r=t[2];this.table=r;const i=e.options;this.columns=this.generateColumns(this.pluginOptions.columnCount),i.columns=this.columns}else if(t[1]===m.TABLE_EVENT_TYPE.BEFORE_KEYDOWN){const e=t[0].event;this.pluginOptions.autoExtendColumnTriggerKeys?.includes(e.key)&&this.table.stateManager.select.cellPos.col===this.table.colCount-1&&this.table.addColumn(this.generateColumn(this.table.colCount-1))}}generateColumns(t){const e=[];for(let r=0;r<t;r++)e.push(this.generateColumn(r));return e}generateColumn(t){return{title:this.pluginOptions.generateColumnTitle?this.pluginOptions.generateColumnTitle(t):this.generateColumnField(t)}}generateColumnField(t){if(t<26)return String.fromCharCode(65+t);const e=[];for(t++;t>0;)t--,e.unshift(String.fromCharCode(65+t%26)),t=Math.floor(t/26);return e.join("")}resetColumnCount(t){this.pluginOptions.columnCount=t,this.columns=this.generateColumns(t),this.table.updateColumns(this.columns)}},t.ExcelEditCellKeyboardPlugin=class{id=`excel-edit-cell-keyboard-${Date.now()}`;name="Excel Edit Cell Keyboard";runTime=[m.TABLE_EVENT_TYPE.INITIALIZED];table;pluginOptions;constructor(t){this.id=t?.id??this.id,this.pluginOptions=t,this.bindEvent()}run(...t){const e=t[2];this.table=e}bindEvent(){document.addEventListener("keydown",this.handleKeyDown.bind(this),!0)}handleKeyDown(t){if(this.table.editorManager)if("keydown"===this.table.editorManager.beginTriggerEditCellMode){if(this.table.editorManager.editingEditor&&this.isExcelShortcutKey(t)){const{col:e,row:r}=this.table.editorManager.editCell;this.table.editorManager.completeEdit(),this.table.getElement().focus(),t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key?this.table.selectCell(e,r+1):"Tab"===t.key?this.table.selectCell(e+1,r):"ArrowLeft"===t.key?this.table.selectCell(e-1,r):"ArrowRight"===t.key?this.table.selectCell(e+1,r):"ArrowDown"===t.key?this.table.selectCell(e,r+1):"ArrowUp"===t.key&&this.table.selectCell(e,r-1),t.stopPropagation(),t.preventDefault())}}else{const{col:e,row:r}=this.table.stateManager.select.cellPos;if(!this.table.editorManager.editingEditor||"Enter"!==t.key&&"Tab"!==t.key){if("Delete"===t.key){const e=this.table.getSelectedCellInfos();e?.length>0&&function(t,e){for(let r=0;r<t.length;r++)for(let i=0;i<t[r].length;i++)e.changeCellValue(t[r][i].col,t[r][i].row,"")}(e,this.table),t.stopPropagation(),t.preventDefault()}}else this.table.editorManager.completeEdit(),this.table.getElement().focus(),"Enter"===t.key?this.table.selectCell(e,r+1):"Tab"===t.key&&this.table.selectCell(e+1,r),t.stopPropagation(),t.preventDefault()}}isExcelShortcutKey(t){return"Enter"===t.key||"Tab"===t.key||"ArrowLeft"===t.key||"ArrowRight"===t.key||"ArrowDown"===t.key||"ArrowUp"===t.key}release(){document.removeEventListener("keydown",this.handleKeyDown,!0)}},t.ExcelImportPlugin=T4,t.ExportGanttPlugin=class{id="gantt-export-helper";name="Gantt Export Helper";_gantt=null;run(...t){const e=t[0];e&&(this._gantt=e)}async exportToImage(t={}){if(!this._gantt)return;const{fileName:e="gantt-export",type:r="png",quality:i=1,backgroundColor:n="#ffffff",scale:s=window.devicePixelRatio||1,download:o=!0}=t;try{const{tempContainer:t,clonedGantt:a}=this.createFullSizeContainer(s);try{await new Promise((t=>requestAnimationFrame(t)));const t=(a.taskListTableInstance.getAllColsWidth()+a.getAllDateColsWidth())*s,l=a.getAllRowsHeight()*s,h=document.createElement("canvas");h.width=t,h.height=l;const c=h.getContext("2d");c.fillStyle=n,c.fillRect(0,0,t,l),a.taskListTableInstance?.canvas&&c.drawImage(a.taskListTableInstance.canvas,0,0,a.taskListTableInstance.getAllColsWidth()*s,l);const u=3*s,d=a.taskListTableInstance.getAllColsWidth()*s;c.fillStyle="rgb(225, 228, 232)",c.fillRect(d-u/2,0,u,l);const p=4*s,f=a.canvas.width-p;return a.canvas&&c.drawImage(a.canvas,p,0,f,a.canvas.height,(a.taskListTableInstance.getAllColsWidth()+1.5)*s,0,(a.getAllDateColsWidth()-1.5)*s,l),this.finalizeExport(h,e,r,i,o)}finally{t.remove(),a.release()}}catch(t){throw new Error(`甘特图导出失败: ${t instanceof Error?t.message:"未知错误"}`)}}async exportToBase64(t={}){return this.exportToImage({...t,download:!1})}createFullSizeContainer(t){if(!this._gantt)throw new Error("ExportGanttPlugin: Gantt instance not available to create container.");const e=document.createElement("div");e.style.position="fixed",e.style.left="-9999px",e.style.overflow="hidden",e.style.width=`${window.innerWidth+100}px`,e.style.height=`${window.innerHeight+100}px`,document.body.appendChild(e);const r=document.createElement("div"),i=this._gantt.taskListTableInstance.getAllColsWidth()+this._gantt.getAllDateColsWidth(),n=this._gantt.getAllRowsHeight();r.style.width=`${i}px`,r.style.height=`${n}px`,e.appendChild(r);const s=new Np(r,{...this._gantt.options,records:JSON.parse(JSON.stringify(this._gantt.records)),taskListTable:{...this._gantt.options.taskListTable,tableWidth:void 0,minTableWidth:void 0,maxTableWidth:void 0},plugins:[]});return s.setPixelRatio(t),s.scenegraph?.ganttGroup&&s.scenegraph.ganttGroup.setAttribute("clip",!1),s.taskListTableInstance?.scenegraph?.tableGroup&&s.taskListTableInstance.scenegraph.tableGroup.setAttribute("clip",!1),s.scenegraph.stage.render(),{tempContainer:e,clonedGantt:s}}finalizeExport(t,e,r,i,n=!0){const s=t.toDataURL(`image/${r}`,i);if(n){const t=document.createElement("a");t.download=`${e}.${r}`,t.href=s,document.body.appendChild(t),t.click(),document.body.removeChild(t)}return s}release(){this._gantt=null}},t.FocusHighlightPlugin=class{id=`focus-highlight-${Date.now()}`;name="Focus Highlight";runTime=[e.TABLE_EVENT_TYPE.INITIALIZED,e.TABLE_EVENT_TYPE.SELECTED_CELL,e.TABLE_EVENT_TYPE.SELECTED_CLEAR];table;range;pluginOptions;constructor(t={fill:"#000",opacity:.5,highlightRange:void 0}){this.id=t.id??this.id,this.pluginOptions=Object.assign({fill:"#000",opacity:.5},t)}run(...t){if(this.table||(this.table=t[2]),t[1]===e.TABLE_EVENT_TYPE.INITIALIZED)this.pluginOptions.highlightRange&&this.setFocusHighlightRange(this.pluginOptions.highlightRange);else if(t[1]===e.TABLE_EVENT_TYPE.SELECTED_CELL){const t=this.table.stateManager.select.cellPos;if(this.table.isHeader(t.col,t.row))this.setFocusHighlightRange(void 0);else{const t=this.table.stateManager.select.ranges,e=0,r=this.table.colCount-1,i=Math.min(t[0].start.row,t[0].end.row),n=Math.max(t[0].start.row,t[0].end.row);this.setFocusHighlightRange({start:{col:e,row:i},end:{col:r,row:n}})}}else t[1]===e.TABLE_EVENT_TYPE.SELECTED_CLEAR&&this.setFocusHighlightRange(void 0)}setFocusHighlightRange(t,e=!1){let r;t&&"start"in t&&"end"in t?r=t:t&&(r={start:t,end:t}),nd(this.range,r)&&!e||(this.range=r,t?this.updateCellGroupShadow():this.deleteAllCellGroupShadow(),this.table.scenegraph.updateNextFrame())}deleteAllCellGroupShadow(){this.table.isPivotTable()||(this.updateCellGroupShadowInContainer(this.table.scenegraph.rowHeaderGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.leftBottomCornerGroup)),this.updateCellGroupShadowInContainer(this.table.scenegraph.bodyGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.rightFrozenGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.bottomFrozenGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.rightBottomCornerGroup)}updateCellGroupShadow(){this.table.isPivotTable()||(this.updateCellGroupShadowInContainer(this.table.scenegraph.rowHeaderGroup,this.range),this.updateCellGroupShadowInContainer(this.table.scenegraph.leftBottomCornerGroup,this.range)),this.updateCellGroupShadowInContainer(this.table.scenegraph.bodyGroup,this.range),this.updateCellGroupShadowInContainer(this.table.scenegraph.rightFrozenGroup,this.range),this.updateCellGroupShadowInContainer(this.table.scenegraph.bottomFrozenGroup),this.range,this.updateCellGroupShadowInContainer(this.table.scenegraph.rightBottomCornerGroup,this.range)}updateCellGroupShadowInContainer(t,e){let r;e&&"start"in e&&"end"in e?r=e:e&&(r={start:e,end:e}),t.forEachChildrenSkipChild((t=>{const e=t;"column"===e.role&&e.forEachChildrenSkipChild((t=>{const e=t;if("cell"!==e.role)return;e.attachShadow(e.shadowRoot);const i=e.shadowRoot;if(r){if(ad(r,e.col,e.row))i.removeAllChild();else if(!i.firstChild){const t=Ya({x:0,y:0,width:e.attribute.width,height:e.attribute.height,fill:this.pluginOptions.fill,opacity:this.pluginOptions.opacity});t.name="shadow-rect",i.appendChild(t)}}else i.removeAllChild()}))}))}update(){this.setFocusHighlightRange(this.range,!0)}},t.HeaderHighlightPlugin=class{table;options;colHeaderRange;rowHeaderRange;constructor(t,e){this.table=t,this.options=e,this.registerStyle(),this.bindEvent()}registerStyle(){this.table.registerCustomCellStyle("col-highlight",{bgColor:this.options?.colHighlightBGColor??"#82b2f5",color:this.options?.colHighlightColor??"#FFF"}),this.table.registerCustomCellStyle("row-highlight",{bgColor:this.options?.rowHighlightBGColor??"#82b2f5",color:this.options?.rowHighlightColor??"#FFF"})}bindEvent(){this.table.on("selected_cell",(()=>{this.updateHighlight()})),this.table.on("selected_clear",(()=>{this.clearHighlight()})),this.table.on("mousemove_table",(()=>{this.table.stateManager.select.selecting&&this.updateHighlight()}))}clearHighlight(){this.colHeaderRange&&this.table.arrangeCustomCellStyle({range:this.colHeaderRange},void 0,!0),this.rowHeaderRange&&this.table.arrangeCustomCellStyle({range:this.rowHeaderRange},void 0,!0),this.colHeaderRange=void 0,this.rowHeaderRange=void 0}updateHighlight(){if(!1===this.options?.colHighlight&&!1===this.options?.rowHighlight)return;const t=this.table.getSelectedCellRanges();if(0===t.length)return void this.clearHighlight();const e=t[0],r=[e.start.row,e.end.row];r.sort(((t,e)=>t-e));const i=[e.start.col,e.end.col];let n,s;i.sort(((t,e)=>t-e)),this.table.isPivotTable()?(n={start:{col:i[0],row:0},end:{col:i[1],row:this.table.columnHeaderLevelCount-1}},s={start:{col:0,row:r[0]},end:{col:this.table.rowHeaderLevelCount-1,row:r[1]}}):this.table.internalProps.transpose?s={start:{col:0,row:r[0]},end:{col:this.table.rowHeaderLevelCount-1,row:r[1]}}:(n={start:{col:i[0],row:0},end:{col:i[1],row:this.table.columnHeaderLevelCount-1}},this.table.internalProps.rowSeriesNumber&&(s={start:{col:0,row:r[0]},end:{col:0,row:r[1]}})),!1===this.options?.colHighlight||ld(this.colHeaderRange,n)||(this.colHeaderRange&&this.table.arrangeCustomCellStyle({range:this.colHeaderRange},void 0),n&&this.table.arrangeCustomCellStyle({range:n},"col-highlight"),this.colHeaderRange=n),!1===this.options?.rowHighlight||ld(this.rowHeaderRange,s)||(this.rowHeaderRange&&this.table.arrangeCustomCellStyle({range:this.rowHeaderRange},void 0),s&&this.table.arrangeCustomCellStyle({range:s},"row-highlight"),this.rowHeaderRange=s)}},t.HighlightHeaderWhenSelectCellPlugin=class{id=`highlight-header-when-select-cell-${Date.now()}`;name="Highlight Header When Select Cell";runTime=[e.TABLE_EVENT_TYPE.INITIALIZED,e.TABLE_EVENT_TYPE.SELECTED_CLEAR,e.TABLE_EVENT_TYPE.SELECTED_CELL,e.TABLE_EVENT_TYPE.MOUSEMOVE_TABLE];table;pluginOptions;colHeaderRanges=[];rowHeaderRanges=[];constructor(t){this.id=t.id??this.id,this.pluginOptions=t}run(...t){const r=t[1],i=t[2];this.table=i,r===e.TABLE_EVENT_TYPE.SELECTED_CLEAR?this.clearHighlight():r===e.TABLE_EVENT_TYPE.SELECTED_CELL||r===e.TABLE_EVENT_TYPE.MOUSEMOVE_TABLE?this.updateHighlight():r===e.TABLE_EVENT_TYPE.INITIALIZED&&this.registerStyle()}registerStyle(){this.table.registerCustomCellStyle("col-highlight",{bgColor:this.pluginOptions?.colHighlightBGColor??"#82b2f5",color:this.pluginOptions?.colHighlightColor??"#FFF"}),this.table.registerCustomCellStyle("row-highlight",{bgColor:this.pluginOptions?.rowHighlightBGColor??"#82b2f5",color:this.pluginOptions?.rowHighlightColor??"yellow"})}clearHighlight(){this.colHeaderRanges&&this.colHeaderRanges.forEach((t=>{this.table.arrangeCustomCellStyle({range:t},void 0)})),this.rowHeaderRanges&&this.rowHeaderRanges.forEach((t=>{this.table.arrangeCustomCellStyle({range:t},void 0)})),this.colHeaderRanges=[],this.rowHeaderRanges=[]}updateHighlight(){if(!1===this.pluginOptions?.colHighlight&&!1===this.pluginOptions?.rowHighlight)return;const t=this.table.getSelectedCellRanges();t.length<2&&this.clearHighlight();for(let e=0;e<t.length;e++){const r=t[e],i=[r.start.row,r.end.row];i.sort(((t,e)=>t-e));const n=[r.start.col,r.end.col];let s,o;n.sort(((t,e)=>t-e)),this.table.isPivotTable()?(s={start:{col:n[0],row:0},end:{col:n[1],row:this.table.columnHeaderLevelCount-1}},o={start:{col:0,row:i[0]},end:{col:this.table.rowHeaderLevelCount-1,row:i[1]}}):this.table.internalProps.transpose?o={start:{col:0,row:i[0]},end:{col:this.table.rowHeaderLevelCount-1,row:i[1]}}:(s={start:{col:n[0],row:0},end:{col:n[1],row:this.table.columnHeaderLevelCount-1}},this.table.internalProps.rowSeriesNumber&&(o={start:{col:0,row:i[0]},end:{col:0,row:i[1]}})),!1===this.pluginOptions?.colHighlight||this.colHeaderRanges.find((t=>hd(t,s)))||(s&&this.table.arrangeCustomCellStyle({range:s},"col-highlight"),this.colHeaderRanges.push(s)),!1===this.pluginOptions?.rowHighlight||this.rowHeaderRanges.find((t=>hd(t,o)))||(o&&this.table.arrangeCustomCellStyle({range:o},"row-highlight"),this.rowHeaderRanges.push(o))}}update(){this.registerStyle(),this.updateHighlight()}release(){this.rowHeaderRanges=[],this.colHeaderRanges=[]}},t.InvertHighlightPlugin=class{table;range;_fill;_opacity;constructor(t,e){this.table=t,this._fill=e?.fill??"#000",this._opacity=e?.opacity??.5}setInvertHighlightRange(t){nd(this.range,t)||(this.range=t,t?this.updateCellGroupShadow():this.deleteAllCellGroupShadow(),this.table.scenegraph.updateNextFrame())}deleteAllCellGroupShadow(){this.table.isPivotTable()||(this.updateCellGroupShadowInContainer(this.table.scenegraph.rowHeaderGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.leftBottomCornerGroup)),this.updateCellGroupShadowInContainer(this.table.scenegraph.bodyGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.rightFrozenGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.bottomFrozenGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.rightBottomCornerGroup)}updateCellGroupShadow(){this.table.isPivotTable()||(this.updateCellGroupShadowInContainer(this.table.scenegraph.rowHeaderGroup,this.range),this.updateCellGroupShadowInContainer(this.table.scenegraph.leftBottomCornerGroup,this.range)),this.updateCellGroupShadowInContainer(this.table.scenegraph.bodyGroup,this.range),this.updateCellGroupShadowInContainer(this.table.scenegraph.rightFrozenGroup,this.range),this.updateCellGroupShadowInContainer(this.table.scenegraph.bottomFrozenGroup),this.range,this.updateCellGroupShadowInContainer(this.table.scenegraph.rightBottomCornerGroup,this.range)}updateCellGroupShadowInContainer(t,e){t.forEachChildrenSkipChild((t=>{const r=t;"column"===r.role&&r.forEachChildrenSkipChild((t=>{const r=t;if("cell"!==r.role)return;r.attachShadow(r.shadowRoot);const i=r.shadowRoot;if(e){if(ad(e,r.col,r.row))i.removeAllChild();else if(!i.firstChild){const t=Ya({x:0,y:0,width:r.attribute.width,height:r.attribute.height,fill:this._fill,opacity:this._opacity});t.name="shadow-rect",i.appendChild(t)}}else i.removeAllChild()}))}))}},t.RotateTablePlugin=class{id=`rotate-table-${Date.now()}`;name="Rotate Table";runTime=[m.TABLE_EVENT_TYPE.INITIALIZED];table;matrix;vglobal_mapToCanvasPoint;constructor(t){this.id=t?.id??this.id}run(...t){const e=t[2];this.table=e,this.table.rotate90WithTransform=ud.bind(this.table),this.table.cancelTransform=dd.bind(this.table)}release(){}},t.RowSeriesPlugin=class{id=`row-series-${Date.now()}`;name="Row Series";runTime=[e.TABLE_EVENT_TYPE.BEFORE_INIT,e.TABLE_EVENT_TYPE.BEFORE_KEYDOWN];pluginOptions;table;constructor(t){this.id=t.id??this.id,this.pluginOptions=Object.assign({rowCount:100},t)}run(...t){if(t[1]===e.TABLE_EVENT_TYPE.BEFORE_INIT){const e=t[0],r=t[2];this.table=r;const i=e.options,n=i.records??[];for(let t=n.length;t<this.pluginOptions.rowCount;t++)n.push(this.pluginOptions.fillRowRecord?this.pluginOptions.fillRowRecord(t):{});i.records=n,this.pluginOptions.rowSeriesNumber?(i.rowSeriesNumber=this.pluginOptions.rowSeriesNumber,this.pluginOptions.rowSeriesNumber.width||(i.rowSeriesNumber.width="auto")):i.rowSeriesNumber||(i.rowSeriesNumber={width:"auto"})}else if(t[1]===e.TABLE_EVENT_TYPE.BEFORE_KEYDOWN){const e=t[0].event;this.pluginOptions.autoExtendRowTriggerKeys?.includes(e.key)&&this.table.stateManager.select.cellPos.row===this.table.rowCount-1&&this.table.addRecord(this.pluginOptions.fillRowRecord?this.pluginOptions.fillRowRecord(this.table.rowCount-this.table.columnHeaderLevelCount):{})}}},t.TableCarouselAnimationPlugin=class{id=`table-carousel-animation-${Date.now()}`;name="Table Carousel Animation";runTime=[e.TABLE_EVENT_TYPE.INITIALIZED];table;rowCount;colCount;animationDuration;animationDelay;animationEasing;playing;row;col;willUpdateRow=!1;willUpdateCol=!1;autoPlay;autoPlayDelay;customDistRowFunction;customDistColFunction;constructor(t={}){this.id=t.id??this.id,this.rowCount=t?.rowCount??void 0,this.colCount=t?.colCount??void 0,this.animationDuration=t?.animationDuration??500,this.animationDelay=t?.animationDelay??1e3,this.animationEasing=t?.animationEasing??"linear",this.autoPlay=t?.autoPlay??!1,this.autoPlayDelay=t?.autoPlayDelay??0,this.customDistColFunction=t.customDistColFunction,this.customDistRowFunction=t.customDistRowFunction}run(...t){this.table||(this.table=t[2]),this.reset(),this.autoPlay&&setTimeout((()=>{this.play()}),this.autoPlayDelay)}reset(){this.playing=!1,this.row=this.table.frozenRowCount,this.col=this.table.frozenColCount}play(){if(!this.table)throw new Error("table is not initialized");this.playing=!0,this.rowCount&&!this.willUpdateRow?this.updateRow():this.colCount&&!this.willUpdateCol&&this.updateCol()}pause(){this.playing=!1}updateRow(){if(!this.playing||this.table.isReleased)return;let t=!0;const e=this.customDistRowFunction&&this.customDistRowFunction(this.row,this.table);e?(this.row=e.distRow,t=e.animation??!0):cd(this.row)&&this.table.scenegraph.proxy.screenTopRow!==this.row?(this.row=this.table.frozenRowCount,t=!1):cd(this.row)||this.table.scenegraph.proxy.screenTopRow===Math.floor(this.row)?this.row+=this.rowCount:(this.row=this.table.frozenRowCount,t=!1),this.table.scrollToRow(this.row,t?{duration:this.animationDuration,easing:this.animationEasing}:void 0),this.willUpdateRow=!0,setTimeout((()=>{this.willUpdateRow=!1,this.updateRow()}),this.animationDuration+this.animationDelay)}updateCol(){if(!this.playing||this.table.isReleased)return;let t=!0;const e=this.customDistColFunction&&this.customDistColFunction(this.col,this.table);e?(this.col=e.distCol,t=e.animation??!0):cd(this.col)&&this.table.scenegraph.proxy.screenLeftCol!==this.col?(this.col=this.table.frozenColCount,t=!1):cd(this.col)||this.table.scenegraph.proxy.screenLeftCol===Math.floor(this.col)?this.col+=this.colCount:(this.col=this.table.frozenColCount,t=!1),this.table.scrollToCol(this.col,t?{duration:this.animationDuration,easing:this.animationEasing}:void 0),this.willUpdateCol=!0,setTimeout((()=>{this.willUpdateCol=!1,this.updateCol()}),this.animationDuration+this.animationDelay)}release(){}},t.WpsFillHandlePlugin=class{id=`wps-fill-handle-${Date.now()}`;name="WPS Fill Handle";runTime=[m.TABLE_EVENT_TYPE.MOUSEDOWN_FILL_HANDLE,m.TABLE_EVENT_TYPE.DRAG_FILL_HANDLE_END];table;pluginOptions;beforeDragMinCol=0;beforeDragMinRow=0;beforeDragMaxCol=0;beforeDragMaxRow=0;constructor(t){this.id=t?.id??this.id,this.pluginOptions=t}run(...t){if(t[1]===m.TABLE_EVENT_TYPE.MOUSEDOWN_FILL_HANDLE){t[0];const e=t[2];this.table=e;const r=this.table?.getSelectedCellRanges()[0];if(!r)return;this.beforeDragMaxCol=Math.max(r.start.col,r.end.col),this.beforeDragMinCol=Math.min(r.start.col,r.end.col),this.beforeDragMaxRow=Math.max(r.start.row,r.end.row),this.beforeDragMinRow=Math.min(r.start.row,r.end.row)}else if(t[1]===m.TABLE_EVENT_TYPE.DRAG_FILL_HANDLE_END){const e=t[0].direction;let r,i;const n=this.table?.getSelectedCellRanges()[0];if(!n)return;"bottom"===e?(r=this.beforeDragMaxCol,i=n.end.row):"right"===e?(r=n.end.col,i=this.beforeDragMaxRow):"top"===e?(r=this.beforeDragMaxCol,i=n.end.row):"left"===e&&(r=n.end.col,i=this.beforeDragMaxRow);const s=this.table?.records,o=this.table?.getAllColumnHeaderCells()||[];let a=[];o?.length&&(a=o[o.length-1]);const l=Rv(s,a,{startRow:this.beforeDragMinRow-o.length,startCol:this.beforeDragMinCol,endRow:this.beforeDragMaxRow-o.length,endCol:this.beforeDragMaxCol},{row:i-o.length,col:r});this.table?.setRecords(l)}}handleKeyDown(){if(this.table.editorManager){const t=this.table?.getSelectedCellRanges()[0];if(!t)return;this.beforeDragMaxCol=Math.max(t.start.col,t.end.col),this.beforeDragMinCol=Math.min(t.start.col,t.end.col),this.beforeDragMaxRow=Math.max(t.start.row,t.end.row),this.beforeDragMinRow=Math.min(t.start.row,t.end.row)}}release(){this.beforeDragMinCol=0,this.beforeDragMinRow=0,this.beforeDragMaxCol=0,this.beforeDragMaxRow=0}},t.cancelTransform=dd,t.rotate90WithTransform=ud}));
|
|
91
|
+
*/!function(t){const e=i,n=p,s=h,o=r,a={fs:e.constants,os:n.constants},l="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",c=/XXXXXX/,u=3,d=(a.O_CREAT||a.fs.O_CREAT)|(a.O_EXCL||a.fs.O_EXCL)|(a.O_RDWR||a.fs.O_RDWR),f="win32"===n.platform(),m=a.EBADF||a.os.errno.EBADF,g=a.ENOENT||a.os.errno.ENOENT,y=[],v=e.rmdirSync.bind(e);let b=!1;function _(t,r){return e.rm(t,{recursive:!0},r)}function w(t){return e.rmSync(t,{recursive:!0})}function x(t,r){const i=R(t,r),n=i[0],s=i[1];try{P(n)}catch(t){return s(t)}let o=n.tries;!function t(){try{const r=L(n);e.stat(r,(function(e){if(!e)return o-- >0?t():s(new Error("Could not get a unique tmp filename, max tries reached "+r));s(null,r)}))}catch(t){s(t)}}()}function S(t){const r=R(t)[0];P(r);let i=r.tries;do{const t=L(r);try{e.statSync(t)}catch(e){return t}}while(i-- >0);throw new Error("Could not get a unique tmp filename, max tries reached")}function T(t,r){const i=function(t){if(t&&!I(t))return r(t);r()};0<=t[0]?e.close(t[0],(function(){e.unlink(t[1],i)})):e.unlink(t[1],i)}function k(t){let r=null;try{0<=t[0]&&e.closeSync(t[0])}catch(t){if(!function(t){return N(t,-m,"EBADF")}(t)&&!I(t))throw t}finally{try{e.unlinkSync(t[1])}catch(t){I(t)||(r=t)}}if(null!==r)throw r}function C(t,e,r,i){const n=A(k,[e,t],i),s=A(T,[e,t],i,n);return r.keep||y.unshift(n),i?n:s}function E(t,r,i){const n=r.unsafeCleanup?_:e.rmdir.bind(e),s=A(r.unsafeCleanup?w:v,t,i),o=A(n,t,i,s);return r.keep||y.unshift(s),i?s:o}function A(t,e,r,i){let n=!1;return function s(o){if(!n){const a=i||s,l=y.indexOf(a);return l>=0&&y.splice(l,1),n=!0,r||t===v||t===w?t(e):t(e,o||function(){})}}}function O(t){let e=[],r=null;try{r=o.randomBytes(t)}catch(e){r=o.pseudoRandomBytes(t)}for(var i=0;i<t;i++)e.push(l[r[i]%l.length]);return e.join("")}function B(t){return void 0===t}function R(t,e){if("function"==typeof t)return[{},t];if(B(t))return[{},e];const r={};for(const e of Object.getOwnPropertyNames(t))r[e]=t[e];return[r,e]}function L(t){const e=t.tmpdir;if(!B(t.name))return s.join(e,t.dir,t.name);if(!B(t.template))return s.join(e,t.dir,t.template).replace(c,O(6));const r=[t.prefix?t.prefix:"tmp","-",process.pid,"-",O(12),t.postfix?"-"+t.postfix:""].join("");return s.join(e,t.dir,r)}function P(t){t.tmpdir=F(t);const e=t.tmpdir;if(B(t.name)||M(t.name,"name",e),B(t.dir)||M(t.dir,"dir",e),!B(t.template)&&(M(t.template,"template",e),!t.template.match(c)))throw new Error(`Invalid template, found "${t.template}".`);if(!B(t.tries)&&isNaN(t.tries)||t.tries<0)throw new Error(`Invalid tries, found "${t.tries}".`);t.tries=B(t.name)?t.tries||u:1,t.keep=!!t.keep,t.detachDescriptor=!!t.detachDescriptor,t.discardDescriptor=!!t.discardDescriptor,t.unsafeCleanup=!!t.unsafeCleanup,t.dir=B(t.dir)?"":s.relative(e,D(t.dir,e)),t.template=B(t.template)?void 0:s.relative(e,D(t.template,e)),t.template=function(t){return null===t||B(t)||!t.trim()}(t.template)?void 0:s.relative(t.dir,t.template),t.name=B(t.name)?void 0:t.name,t.prefix=B(t.prefix)?"":t.prefix,t.postfix=B(t.postfix)?"":t.postfix}function D(t,e){return t.startsWith(e)?s.resolve(t):s.resolve(s.join(e,t))}function M(t,e,r){if("name"===e){if(s.isAbsolute(t))throw new Error(`${e} option must not contain an absolute path, found "${t}".`);let r=s.basename(t);if(".."===r||"."===r||r!==t)throw new Error(`${e} option must not contain a path, found "${t}".`)}else{if(s.isAbsolute(t)&&!t.startsWith(r))throw new Error(`${e} option must be relative to "${r}", found "${t}".`);let i=D(t,r);if(!i.startsWith(r))throw new Error(`${e} option must be relative to "${r}", found "${i}".`)}}function I(t){return N(t,-g,"ENOENT")}function N(t,e,r){return f?t.code===r:t.code===r&&t.errno===e}function F(t){return s.resolve(t&&t.tmpdir||n.tmpdir())}process.addListener("exit",(function(){if(b)for(;y.length;)try{y[0]()}catch(t){}})),Object.defineProperty(t.exports,"tmpdir",{enumerable:!0,configurable:!1,get:function(){return F()}}),t.exports.dir=function(t,r){const i=R(t,r),n=i[0],s=i[1];x(n,(function(t,r){if(t)return s(t);e.mkdir(r,n.mode||448,(function(t){if(t)return s(t);s(null,r,E(r,n,!1))}))}))},t.exports.dirSync=function(t){const r=R(t)[0],i=S(r);return e.mkdirSync(i,r.mode||448),{name:i,removeCallback:E(i,r,!0)}},t.exports.file=function(t,r){const i=R(t,r),n=i[0],s=i[1];x(n,(function(t,r){if(t)return s(t);e.open(r,d,n.mode||384,(function(t,i){if(t)return s(t);if(n.discardDescriptor)return e.close(i,(function(t){return s(t,r,void 0,C(r,-1,n,!1))}));{const t=n.discardDescriptor||n.detachDescriptor;s(null,r,i,C(r,t?-1:i,n,!1))}}))}))},t.exports.fileSync=function(t){const r=R(t)[0],i=r.discardDescriptor||r.detachDescriptor,n=S(r);var s=e.openSync(n,d,r.mode||384);return r.discardDescriptor&&(e.closeSync(s),s=void 0),{name:n,fd:s,removeCallback:C(n,i?-1:s,r,!0)}},t.exports.tmpName=x,t.exports.tmpNameSync=S,t.exports.setGracefulCleanup=function(){b=!0}}(W3);var U3=W3.exports;function $3(t,e){return new Promise((r=>{let i=!1;const n=()=>{i||(i=!0,t.removeListener(e,n),r())};t.addListener(e,n)}))}const{EventEmitter:V3}=s,G3=JA,X3=Mv,Y3=NE,q3=Fv,Z3=zv,K3=ob,Q3=cb;let J3=class extends V3{constructor({workbook:t,id:e,iterator:r,options:i}){super(),this.workbook=t,this.id=e,this.iterator=r,this.options=i||{},this.name=`Sheet${this.id}`,this._columns=null,this._keys={},this._dimensions=new Z3}destroy(){throw new Error("Invalid Operation: destroy")}get dimensions(){return this._dimensions}get columns(){return this._columns}getColumn(t){if("string"==typeof t){const e=this._keys[t];if(e)return e;t=q3.l2n(t)}if(this._columns||(this._columns=[]),t>this._columns.length){let e=this._columns.length+1;for(;e<=t;)this._columns.push(new Q3(this,e++))}return this._columns[t-1]}getColumnKey(t){return this._keys[t]}setColumnKey(t,e){this._keys[t]=e}deleteColumnKey(t){delete this._keys[t]}eachColumnKey(t){X3.each(this._keys,t)}async read(){try{for await(const t of this.parse())for(const{eventType:e,value:r}of t)this.emit(e,r);this.emit("finished")}catch(t){this.emit("error",t)}}async*[Symbol.asyncIterator](){for await(const t of this.parse())for(const{eventType:e,value:r}of t)"row"===e&&(yield r)}async*parse(){const{iterator:t,options:e}=this;let r=!1,i=!1,n=null;if("emit"===e.worksheets)r=!0;switch(e.hyperlinks){case"emit":i=!0;break;case"cache":this.hyperlinks=n={}}if(!r&&!i&&!n)return;const{sharedStrings:s,styles:o,properties:a}=this.workbook;let l=!1,h=!1,c=!1,u=null,d=null,p=null,f=null;for await(const e of G3(t)){const t=[];for(const{eventType:m,value:g}of e)if("opentag"===m){const e=g;if(r)switch(e.name){case"cols":l=!0,u=[];break;case"sheetData":h=!0;break;case"col":l&&u.push({min:parseInt(e.attributes.min,10),max:parseInt(e.attributes.max,10),width:parseFloat(e.attributes.width),styleId:parseInt(e.attributes.style||"0",10)});break;case"row":if(h){const t=parseInt(e.attributes.r,10);if(d=new K3(this,t),e.attributes.ht&&(d.height=parseFloat(e.attributes.ht)),e.attributes.s){const t=parseInt(e.attributes.s,10),r=o.getStyleModel(t);r&&(d.style=r)}}break;case"c":d&&(p={ref:e.attributes.r,s:parseInt(e.attributes.s,10),t:e.attributes.t});break;case"f":p&&(f=p.f={text:""});break;case"v":case"is":case"t":p&&(f=p.v={text:""})}if(i||n)switch(e.name){case"hyperlinks":c=!0;break;case"hyperlink":if(c){const r={ref:e.attributes.ref,rId:e.attributes["r:id"]};i?t.push({eventType:"hyperlink",value:r}):n[r.ref]=r}}}else if("text"===m)r&&f&&(f.text+=g);else if("closetag"===m){const e=g;if(r)switch(e.name){case"cols":l=!1,this._columns=Q3.fromModel(u);break;case"sheetData":h=!1;break;case"row":this._dimensions.expandRow(d),t.push({eventType:"row",value:d}),d=null;break;case"c":if(d&&p){const t=q3.decodeAddress(p.ref),e=d.getCell(t.col);if(p.s){const t=o.getStyleModel(p.s);t&&(e.style=t)}if(p.f){const t={formula:p.f.text};p.v&&("str"===p.t?t.result=Y3.xmlDecode(p.v.text):t.result=parseFloat(p.v.text)),e.value=t}else if(p.v)switch(p.t){case"s":{const t=parseInt(p.v.text,10);e.value=s?s[t]:{sharedString:t};break}case"inlineStr":case"str":e.value=Y3.xmlDecode(p.v.text);break;case"e":e.value={error:p.v.text};break;case"b":e.value=0!==parseInt(p.v.text,10);break;default:Y3.isDateFmt(e.numFmt)?e.value=Y3.excelToDate(parseFloat(p.v.text),a.model&&a.model.date1904):e.value=parseFloat(p.v.text)}if(n){const t=n[p.ref];t&&(e.text=e.value,e.value=void 0,e.hyperlink=t)}p=null}}if((i||n)&&"hyperlinks"===e.name)c=!1}t.length>0&&(yield t)}}};var t4=J3;const{EventEmitter:e4}=s,r4=JA,i4=Hv,n4=ZR;var s4=class extends e4{constructor({workbook:t,id:e,iterator:r,options:i}){super(),this.workbook=t,this.id=e,this.iterator=r,this.options=i}get count(){return this.hyperlinks&&this.hyperlinks.length||0}each(t){return this.hyperlinks.forEach(t)}async read(){const{iterator:t,options:e}=this;let r=!1,i=null;switch(e.hyperlinks){case"emit":r=!0;break;case"cache":this.hyperlinks=i={}}if(r||i)try{for await(const e of r4(t))for(const{eventType:t,value:n}of e)if("opentag"===t){const t=n;if("Relationship"===t.name){const e=t.attributes.Id;if(t.attributes.Type===n4.Hyperlink){const n={type:i4.RelationshipType.Styles,rId:e,target:t.attributes.Target,targetMode:t.attributes.TargetMode};r?this.emit("hyperlink",n):i[n.rId]=n}}}this.emit("finished")}catch(t){this.emit("error",t)}else this.emit("finished")}};const o4=i,{EventEmitter:a4}=s,{PassThrough:l4,Readable:h4}=PE,c4=n,u4=f0,d4=U3,p4=async function*(t){const e=[];let r;t.on("data",(t=>e.push(t)));const i=new Promise((t=>r=t));let n=!1;t.on("end",(()=>{n=!0,r()}));let s=!1;for(t.on("error",(t=>{s=t,r()}));!n||e.length>0;){if(0===e.length)t.resume(),await Promise.race([$3(t,"data"),i]);else{t.pause();const r=e.shift();yield r}if(s)throw s}r()},f4=JA,m4=kB,g4=qR,y4=aR,v4=t4,b4=s4;d4.setGracefulCleanup();class _4 extends a4{constructor(t,e={}){super(),this.input=t,this.options={worksheets:"emit",sharedStrings:"cache",hyperlinks:"ignore",styles:"ignore",entries:"ignore",...e},this.styles=new m4,this.styles.init()}_getStream(t){if(t instanceof c4.Readable||t instanceof h4)return t;if("string"==typeof t)return o4.createReadStream(t);throw new Error(`Could not recognise input: ${t}`)}async read(t,e){try{for await(const{eventType:r,value:i}of this.parse(t,e))switch(r){case"shared-strings":case"hyperlinks":this.emit(r,i);break;case"worksheet":this.emit(r,i),await i.read()}this.emit("end"),this.emit("finished")}catch(t){this.emit("error",t)}}async*[Symbol.asyncIterator](){for await(const{eventType:t,value:e}of this.parse())"worksheet"===t&&(yield e)}async*parse(t,e){e&&(this.options=e);const r=this.stream=this._getStream(t||this.input),i=u4.Parse({forceStream:!0});r.pipe(i);const n=[];for await(const t of p4(i)){let e,r;switch(t.path){case"_rels/.rels":break;case"xl/_rels/workbook.xml.rels":await this._parseRels(t);break;case"xl/workbook.xml":await this._parseWorkbook(t);break;case"xl/sharedStrings.xml":yield*this._parseSharedStrings(t);break;case"xl/styles.xml":await this._parseStyles(t);break;default:t.path.match(/xl\/worksheets\/sheet\d+[.]xml/)?(e=t.path.match(/xl\/worksheets\/sheet(\d+)[.]xml/),r=e[1],this.sharedStrings&&this.workbookRels?yield*this._parseWorksheet(p4(t),r):await new Promise(((e,i)=>{d4.file(((s,o,a,l)=>{if(s)return i(s);n.push({sheetNo:r,path:o,tempFileCleanupCallback:l});const h=o4.createWriteStream(o);return h.on("error",i),t.pipe(h),h.on("finish",(()=>e()))}))}))):t.path.match(/xl\/worksheets\/_rels\/sheet\d+[.]xml.rels/)&&(e=t.path.match(/xl\/worksheets\/_rels\/sheet(\d+)[.]xml.rels/),r=e[1],yield*this._parseHyperlinks(p4(t),r))}t.autodrain()}for(const{sheetNo:t,path:e,tempFileCleanupCallback:r}of n){let i=o4.createReadStream(e);i[Symbol.asyncIterator]||(i=i.pipe(new l4)),yield*this._parseWorksheet(i,t),r()}}_emitEntry(t){"emit"===this.options.entries&&this.emit("entry",t)}async _parseRels(t){const e=new y4;this.workbookRels=await e.parseStream(p4(t))}async _parseWorkbook(t){this._emitEntry({type:"workbook"});const e=new g4;await e.parseStream(p4(t)),this.properties=e.map.workbookPr,this.model=e.model}async*_parseSharedStrings(t){switch(this._emitEntry({type:"shared-strings"}),this.options.sharedStrings){case"cache":this.sharedStrings=[];break;case"emit":break;default:return}let e=null,r=[],i=0,n=null;for await(const s of f4(p4(t)))for(const{eventType:t,value:o}of s)if("opentag"===t){const t=o;switch(t.name){case"b":n=n||{},n.bold=!0;break;case"charset":n=n||{},n.charset=parseInt(t.attributes.charset,10);break;case"color":n=n||{},n.color={},t.attributes.rgb&&(n.color.argb=t.attributes.argb),t.attributes.val&&(n.color.argb=t.attributes.val),t.attributes.theme&&(n.color.theme=t.attributes.theme);break;case"family":n=n||{},n.family=parseInt(t.attributes.val,10);break;case"i":n=n||{},n.italic=!0;break;case"outline":n=n||{},n.outline=!0;break;case"rFont":n=n||{},n.name=t.value;break;case"si":n=null,r=[],e=null;break;case"sz":n=n||{},n.size=parseInt(t.attributes.val,10);break;case"strike":break;case"t":e=null;break;case"u":n=n||{},n.underline=!0;break;case"vertAlign":n=n||{},n.vertAlign=t.attributes.val}}else if("text"===t)e=e?e+o:o;else if("closetag"===t){switch(o.name){case"r":r.push({font:n,text:e}),n=null,e=null;break;case"si":"cache"===this.options.sharedStrings?this.sharedStrings.push(r.length?{richText:r}:e):"emit"===this.options.sharedStrings&&(yield{index:i++,text:r.length?{richText:r}:e}),r=[],n=null,e=null}}}async _parseStyles(t){this._emitEntry({type:"styles"}),"cache"===this.options.styles&&(this.styles=new m4,await this.styles.parseStream(p4(t)))}*_parseWorksheet(t,e){this._emitEntry({type:"worksheet",id:e});const r=new v4({workbook:this,id:e,iterator:t,options:this.options}),i=(this.workbookRels||[]).find((t=>t.Target===`worksheets/sheet${e}.xml`)),n=i&&(this.model.sheets||[]).find((t=>t.rId===i.Id));n&&(r.id=n.id,r.name=n.name,r.state=n.state),"emit"===this.options.worksheets&&(yield{eventType:"worksheet",value:r})}*_parseHyperlinks(t,e){this._emitEntry({type:"hyperlinks",id:e});const r=new b4({workbook:this,id:e,iterator:t,options:this.options});"emit"===this.options.hyperlinks&&(yield{eventType:"hyperlinks",value:r})}}_4.Options={worksheets:["emit","ignore"],sharedStrings:["cache","emit","ignore"],hyperlinks:["cache","emit","ignore"],styles:["cache","ignore"],entries:["emit","ignore"]};const w4={Workbook:AH,ModelContainer:BH,stream:{xlsx:{WorkbookWriter:p0,WorkbookReader:_4}}};Object.assign(w4,Hv);var x4=w4;if(parseInt(process.versions.node.split(".")[0],10)<10)throw new Error("For node versions older than 10, please use the ES5 Import: https://github.com/exceljs/exceljs#es5-imports");var S4=pt(x4);class T4{id=`excel-import-plugin-${Date.now()}`;name="ExcelImportPlugin";runTime=[m.TABLE_EVENT_TYPE.INITIALIZED];options;_tableInstance=null;constructor(t){this.options={autoTable:!0,autoColumns:!0,delimiter:",",exportData:!1,batchSize:1e3,enableBatchProcessing:!0,asyncDelay:5,...t},t?.id&&(this.id=t.id)}run(...t){const e=t[2];this._tableInstance=e}release(){this._tableInstance=null}async importFile(){return this.import("file")}async import(t,e,r){const i={...this.options,...r};if("file"===t)return this._importFromFileDialog(i);if("string"==typeof e)return this._importFromString(t,e,i);if(Array.isArray(e)||"object"==typeof e){if("json"!==t)throw new Error("只有JSON格式支持从对象导入");return this._importFromData("json",e,i)}throw new Error("Invalid import source")}async _importFromFileDialog(t){return new Promise(((e,r)=>{if(!this._tableInstance)return void r(new Error("表格实例不存在或已销毁,无法导入数据!"));const i=document.createElement("input");i.type="file",i.style.display="none",document.body.appendChild(i),i.addEventListener("change",(async n=>{try{const s=n.target.files?.[0];if(!s)return document.body.removeChild(i),void r(new Error("未选择文件"));const o=await this._parseFile(s,t);t.autoTable&&this._tableInstance&&(t.autoColumns&&this._tableInstance.updateOption({columns:o.columns,plugins:[this]}),this._tableInstance.setRecords(o.records)),i.value="",document.body.removeChild(i),e(o)}catch(t){document.body.removeChild(i),r(t)}})),i.click()}))}async _importFromString(t,e,r){let i;switch(t){case"csv":i=await this._parseCSVString(e,r);break;case"json":i=await this._parseJSONString(e,r);break;case"html":i=await this._parseHTMLString(e,r);break;default:throw new Error(`不支持的导入类型: ${t}`)}return r.autoTable&&this._tableInstance&&(r.autoColumns&&this._tableInstance.updateOption({columns:i.columns,plugins:[this]}),this._tableInstance.setRecords(i.records)),i}async _importFromData(t,e,r){let i;if("json"!==t)throw new Error(`不支持的数据类型: ${t}`);return i=await this._parseJSONData(e,r),r.autoTable&&this._tableInstance&&(r.autoColumns&&this._tableInstance.updateOption({columns:i.columns,plugins:[this]}),this._tableInstance.setRecords(i.records)),i}async _parseFile(t,e){const r={...this.options,...e},i=this._getFileExtension(t.name).toLowerCase();switch(i){case"xlsx":case"xls":return await this._parseExcelFile(t,r);case"csv":return await this._parseCsvFile(t,r);case"json":return await this._parseJsonFile(t,r);case"html":case"htm":return await this._parseHtmlFile(t,r);default:throw new Error(`不支持的文件类型: ${i}`)}}_getFileExtension(t){const e=t.split(".");return e.length>1?e[e.length-1]:""}async _parseExcelFile(t,e){const r={...this.options,...e};return await T4.importExcelToVTableData(t,r)}async _parseCsvFile(t,e){const r={...this.options,...e},i=await t.text();return this._parseCSVString(i,r)}async _parseJsonFile(t,e){const r={...this.options,...e},i=await t.text();return this._parseJSONString(i,r)}async _parseHtmlFile(t,e){const r={...this.options,...e},i=await t.text();return this._parseHTMLString(i,r)}_buildColumnsFromHeaders(t){return 1===t.length?t[0].map(((t,e)=>({field:`col${e}`,title:t||`列${e+1}`,cellType:"text",headerType:"text"}))):T4.buildColumns(t)}static async importExcelToVTableData(t,e){const r=new S4.Workbook;await r.xlsx.load(await t.arrayBuffer());const i=r.worksheets[0];if(!i)throw new Error("Excel 文件无有效工作表");const n=e?.headerRowCount??this.detectHeaderRowCount(i),s=[];for(let t=1;t<=n;t++){const e=i.getRow(t);s.push(Array.prototype.slice.call(e.values,1))}const o=T4.buildColumns(s),a=[],l=[];i.eachRow(((t,e)=>{if(e<=n)return;const r=Array.prototype.slice.call(t.values,1);l.push(r)}));const h=e?.batchSize||1e3;if(!1!==e?.enableBatchProcessing&&l.length>h)for(let t=0;t<l.length;t+=h){const r=l.slice(t,t+h).map((t=>{const e={};return t.forEach(((t,r)=>{e[`col${r}`]=t})),e}));a.push(...r),t+h<l.length&&await new Promise((t=>setTimeout(t,e?.asyncDelay||5)))}else l.forEach((t=>{const e={};t.forEach(((t,r)=>{e[`col${r}`]=t})),a.push(e)}));if(e?.exportData){const t=T4._generateJavaScriptExport(o,a),e=new Blob([t],{type:"text/javascript"}),r=URL.createObjectURL(e),i=document.createElement("a");i.href=r,i.download="vtable-data.js",document.body.appendChild(i),i.click(),setTimeout((()=>{document.body.removeChild(i),URL.revokeObjectURL(r)}),100)}return{columns:o,records:a}}static detectHeaderRowCount(t){let e=1,r=1;for(;;){const i=t.getRow(e),n=Array.prototype.slice.call(i.values,1);let s=!1;for(let t=1;t<n.length;t++)if(void 0!==n[t]&&""!==n[t]&&n[t]===n[t-1]){s=!0;break}if(!s)break;r++,e++}return r}static buildColumns(t,e=0,r,i=0){const n=t[i],s=[];r=r??n.length;let o=e;for(;o<r;){const e=String(n[o]||`列${o+1}`);let a=1;for(;o+a<r&&n[o+a]===e;)a++;if(i<t.length-1){const r=T4.buildColumns(t,o,o+a,i+1);1===r.length?s.push(r[0]):s.push({title:e,columns:r,hideColumnsSubHeader:!1})}else s.push({field:`col${o}`,title:e,cellType:"text",headerType:"text"});o+=a}return s}async _parseCSVString(t,e){const r=t.split("\n").filter((t=>t.trim()));if(0===r.length)throw new Error("CSV文件为空");const i=e.delimiter||",",n=t=>t.split(i).map((t=>t.trim().replace(/^"|"$/g,""))),s=r.slice(0,1).map(n),o=r.slice(1),a=this._buildColumnsFromHeaders(s),l=[];return await this._processBatchRecords(o,e,(async t=>{const e=t.map((t=>{const e=n(t),r={};return e.forEach(((t,e)=>{r[`col${e}`]=t||""})),r}));l.push(...e)})),e.exportData&&this._exportToJS(a,l),{columns:a,records:l}}async _parseJSONString(t,e){let r;try{r=JSON.parse(t)}catch(t){throw new Error("JSON文件格式错误")}const i=await this._parseJSONData(r,e);return e.exportData&&this._exportToJS(i.columns,i.records),i}async _parseHTMLString(t,e){const r=(new DOMParser).parseFromString(t,"text/html").querySelector("table");if(!r)throw new Error("HTML文件中未找到表格");const i=Array.from(r.querySelectorAll("tr"));if(0===i.length)throw new Error("表格中没有数据行");const n=i.slice(0,1).map((t=>Array.from(t.querySelectorAll("th, td")).map((t=>t.textContent?.trim()||"")))),s=i.slice(1),o=this._buildColumnsFromHeaders(n),a=[];return await this._processBatchRecords(s,e,(async t=>{const e=t.map((t=>{const e=Array.from(t.querySelectorAll("td")).map((t=>t.textContent?.trim()||"")),r={};return e.forEach(((t,e)=>{r[`col${e}`]=t||""})),r}));a.push(...e)})),e.exportData&&this._exportToJS(o,a),{columns:o,records:a}}async _parseJSONData(t,e){let r;if("object"==typeof t&&!Array.isArray(t)&&t&&"columns"in t&&"records"in t){const i=t,n=[];await this._processBatchRecords(i.records,e,(async t=>{const e=t.map((t=>({...t})));n.push(...e)})),r={columns:i.columns,records:n}}else{if(!(Array.isArray(t)&&t.length>0))throw new Error("不支持的JSON格式");{const i=t[0],n=Object.keys(i).map((t=>({field:t,title:t,cellType:"text",headerType:"text"}))),s=[];await this._processBatchRecords(t,e,(async t=>{const e=t.map((t=>({...t})));s.push(...e)})),r={columns:n,records:s}}}return e.exportData&&this._exportToJS(r.columns,r.records),r}static _generateJavaScriptExport(t,e){const r=(t,e="")=>{if(null==t)return"null";if("string"==typeof t)return`'${t.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}'`;if("number"==typeof t||"boolean"==typeof t)return String(t);if(Array.isArray(t)){if(0===t.length)return"[]";return`[${t.map((t=>r(t,e+" "))).join(", ")}]`}if("object"==typeof t){const i=Object.entries(t).map((([t,i])=>`${e} ${t}: ${r(i,e+" ")}`)).join(",\n");return`{\n${i}\n${e}}`}return String(t)},i=(t,e=" ")=>{const n=Object.entries(t).map((([t,n])=>{if("columns"===t&&Array.isArray(n)){const r=n.map((t=>i(t,e+" "))).join(",\n");return`${e} ${t}: [\n${r}\n${e} ]`}return`${e} ${t}: ${r(n)}`})).join(",\n");return`${e}{\n${n}\n${e}}`},n=t.map((t=>i(t))).join(",\n"),s=e.map((t=>{const e=Object.entries(t).map((([t,e])=>` ${t}: ${r(e)}`)).join(",\n");return` {\n${e}\n }`})).join(",\n");return`// VTable 数据导出 - JavaScript 对象字面量格式\n// 生成时间: ${(new Date).toLocaleString()}\n\nconst vtableData = {\n columns: [\n${n}\n ],\n records: [\n${s}\n ]\n};\n`}_exportToJS(t,e){const r=T4._generateJavaScriptExport(t,e),i=new Blob([r],{type:"text/javascript"}),n=URL.createObjectURL(i),s=document.createElement("a");s.href=n,s.download="vtable-data.js",document.body.appendChild(s),s.click(),setTimeout((()=>{document.body.removeChild(s),URL.revokeObjectURL(n)}),100)}async _processBatchRecords(t,e,r){if(!e.enableBatchProcessing||t.length<=(e.batchSize||1e3))return void await r(t,0);const i=e.batchSize||1e3,n=Math.ceil(t.length/i);for(let s=0;s<n;s++){const o=s*i,a=Math.min(o+i,t.length),l=t.slice(o,a);await r(l,s),s<n-1&&await new Promise((t=>setTimeout(t,e.asyncDelay||5)))}}}t.AddRowColumnPlugin=class{id=`add-row-column-${Date.now()}`;name="Add Row Column";runTime=[m.TABLE_EVENT_TYPE.MOUSEENTER_CELL,m.TABLE_EVENT_TYPE.MOUSELEAVE_CELL,m.TABLE_EVENT_TYPE.MOUSELEAVE_TABLE];pluginOptions;table;hoverCell;hideAllTimeoutId_addColumn;hideAllTimeoutId_addRow;leftDotForAddColumn;rightDotForAddColumn;addIconForAddColumn;addLineForAddColumn;topDotForAddRow;bottomDotForAddRow;addIconForAddRow;addLineForAddRow;constructor(t={addColumnEnable:!0,addRowEnable:!0}){this.id=t.id??this.id,this.pluginOptions=t,this.pluginOptions.addColumnEnable=this.pluginOptions.addColumnEnable??!0,this.pluginOptions.addRowEnable=this.pluginOptions.addRowEnable??!0,this.pluginOptions.addColumnEnable&&(this.initAddColumnDomElement(),this.bindEventForAddColumn()),this.pluginOptions.addRowEnable&&(this.initAddRowDomElement(),this.bindEventForAddRow())}run(...t){const e=t[0],r=t[1],i=t[2];if(this.table=i,r===m.TABLE_EVENT_TYPE.MOUSEENTER_CELL){clearTimeout(this.hideAllTimeoutId_addColumn),clearTimeout(this.hideAllTimeoutId_addRow);const t=i.canvas.getBoundingClientRect(),r=i.getCellAtRelativePosition(e.event.clientX-t.left,e.event.clientY-t.top);this.hoverCell=r;const n=i.getCellRelativeRect(r.col,r.row);if(this.pluginOptions.addColumnEnable){const e=i.isSeriesNumber(r.col,0);this.showDotForAddColumn(t.top-6,n.left+t.left,n.right+t.left,!e)}if(this.pluginOptions.addRowEnable){const e=i.isHeader(r.col,r.row);this.showDotForAddRow(n.top+t.top,t.left-6,n.bottom+t.top,!e,!e)}}else r===m.TABLE_EVENT_TYPE.MOUSELEAVE_CELL||r===m.TABLE_EVENT_TYPE.MOUSELEAVE_TABLE&&(this.pluginOptions.addColumnEnable&&this.delayHideAllForAddColumn(),this.pluginOptions.addRowEnable&&this.delayHideAllForAddRow())}initAddColumnDomElement(){this.leftDotForAddColumn=document.createElement("div"),this.leftDotForAddColumn.style.width="6px",this.leftDotForAddColumn.style.height="6px",this.leftDotForAddColumn.style.backgroundColor="#4A90E2",this.leftDotForAddColumn.style.position="absolute",this.leftDotForAddColumn.style.cursor="pointer",this.leftDotForAddColumn.style.zIndex="1000",this.leftDotForAddColumn.style.borderRadius="50%",this.leftDotForAddColumn.style.border="1px solid white",this.leftDotForAddColumn.style.boxShadow="0 1px 3px rgba(0,0,0,0.2)",document.body.appendChild(this.leftDotForAddColumn),this.rightDotForAddColumn=document.createElement("div"),this.rightDotForAddColumn.style.width="6px",this.rightDotForAddColumn.style.height="6px",this.rightDotForAddColumn.style.backgroundColor="#4A90E2",this.rightDotForAddColumn.style.position="absolute",this.rightDotForAddColumn.style.cursor="pointer",this.rightDotForAddColumn.style.zIndex="1000",this.rightDotForAddColumn.style.borderRadius="50%",this.rightDotForAddColumn.style.border="1px solid white",this.rightDotForAddColumn.style.boxShadow="0 1px 3px rgba(0,0,0,0.2)",document.body.appendChild(this.rightDotForAddColumn),this.addIconForAddColumn=document.createElement("div"),this.addIconForAddColumn.style.width="18px",this.addIconForAddColumn.style.height="18px",this.addIconForAddColumn.style.backgroundColor="#4A90E2",this.addIconForAddColumn.style.position="absolute",this.addIconForAddColumn.style.zIndex="1001",this.addIconForAddColumn.style.display="none",this.addIconForAddColumn.style.borderRadius="50%",this.addIconForAddColumn.style.boxShadow="0 2px 5px rgba(0,0,0,0.2)",this.addIconForAddColumn.style.display="flex",this.addIconForAddColumn.style.justifyContent="center",this.addIconForAddColumn.style.alignItems="center",this.addIconForAddColumn.style.border="1px solid white",document.body.appendChild(this.addIconForAddColumn);const t=document.createElement("div");t.textContent="+",t.style.color="white",t.style.fontSize="18px",t.style.fontWeight="bold",t.style.lineHeight="15px",t.style.userSelect="none",t.style.cursor="pointer",t.style.verticalAlign="top",t.style.textAlign="center",this.addIconForAddColumn.appendChild(t),this.addLineForAddColumn=document.createElement("div"),this.addLineForAddColumn.style.width="2px",this.addLineForAddColumn.style.height="10px",this.addLineForAddColumn.style.backgroundColor="#4A90E2",this.addLineForAddColumn.style.position="absolute",this.addLineForAddColumn.style.zIndex="1001",this.addLineForAddColumn.style.display="none",document.body.appendChild(this.addLineForAddColumn)}bindEventForAddColumn(){this.leftDotForAddColumn.addEventListener("mouseenter",(()=>{clearTimeout(this.hideAllTimeoutId_addColumn),this.addIconForAddColumn.style.display="block";const t=this.leftDotForAddColumn.offsetWidth,e=this.leftDotForAddColumn.offsetHeight;this.showAddIconForAddColumn(this.leftDotForAddColumn.offsetLeft+t/2,this.leftDotForAddColumn.offsetTop+e/2,!0),this.showSplitLineForAddColumn(this.leftDotForAddColumn.offsetLeft+t/2-1,this.leftDotForAddColumn.offsetTop+e/2+2,this.table.getDrawRange().height)})),this.rightDotForAddColumn.addEventListener("mouseenter",(()=>{clearTimeout(this.hideAllTimeoutId_addColumn),this.addIconForAddColumn.style.display="block";const t=this.rightDotForAddColumn.offsetWidth,e=this.rightDotForAddColumn.offsetHeight;this.showAddIconForAddColumn(this.rightDotForAddColumn.offsetLeft+t/2,this.rightDotForAddColumn.offsetTop+e/2,!1),this.showSplitLineForAddColumn(this.rightDotForAddColumn.offsetLeft+t/2-1,this.rightDotForAddColumn.offsetTop+e/2+2,this.table.getDrawRange().height)})),this.addIconForAddColumn.addEventListener("mouseleave",(()=>{this.addIconForAddColumn.style.display="none",this.addLineForAddColumn.style.display="none",this.delayHideAllForAddColumn()})),this.addIconForAddColumn.addEventListener("click",(t=>{const e="left"===this.addIconForAddColumn.dataset.addIconType,r=this.table.options.columns,i=this.hoverCell.col,n=e?i:i+1;this.pluginOptions.addColumnCallback?this.pluginOptions.addColumnCallback(n):(r.splice(n,0,{field:"",title:`New Column ${i}`,width:100}),this.table.updateColumns(r)),this.delayHideAllForAddColumn(0)}))}showDotForAddColumn(t,e,r,i=!0,n=!0){const s=this.leftDotForAddColumn.offsetWidth,o=this.leftDotForAddColumn.offsetHeight;this.leftDotForAddColumn.style.left=e-s/2+"px",this.leftDotForAddColumn.style.top=t-o/2+"px",this.rightDotForAddColumn.style.left=r-s/2+"px",this.rightDotForAddColumn.style.top=t-o/2+"px",this.leftDotForAddColumn.style.display=i?"block":"none",this.rightDotForAddColumn.style.display=n?"block":"none"}showAddIconForAddColumn(t,e,r){const i=this.addIconForAddColumn.offsetWidth,n=this.addIconForAddColumn.offsetHeight,s=this.leftDotForAddColumn.offsetHeight;this.addIconForAddColumn.style.left=t-i/2+"px",this.addIconForAddColumn.style.top=e-n/2-s/2+"px",this.addIconForAddColumn.dataset.addIconType=r?"left":"right"}showSplitLineForAddColumn(t,e,r){this.addLineForAddColumn.style.left=`${t}px`,this.addLineForAddColumn.style.top=`${e}px`,this.addLineForAddColumn.style.height=`${r}px`,this.addLineForAddColumn.style.display="block"}delayHideAllForAddColumn(t=1e3){this.hideAllTimeoutId_addColumn=setTimeout((()=>{this.addIconForAddColumn.style.display="none",this.addLineForAddColumn.style.display="none",this.leftDotForAddColumn.style.display="none",this.rightDotForAddColumn.style.display="none"}),t)}initAddRowDomElement(){this.topDotForAddRow=document.createElement("div"),this.topDotForAddRow.style.width="6px",this.topDotForAddRow.style.height="6px",this.topDotForAddRow.style.backgroundColor="#4A90E2",this.topDotForAddRow.style.position="absolute",this.topDotForAddRow.style.cursor="pointer",this.topDotForAddRow.style.zIndex="1000",this.topDotForAddRow.style.borderRadius="50%",this.topDotForAddRow.style.border="1px solid white",this.topDotForAddRow.style.boxShadow="0 1px 3px rgba(0,0,0,0.2)",document.body.appendChild(this.topDotForAddRow),this.bottomDotForAddRow=document.createElement("div"),this.bottomDotForAddRow.style.width="6px",this.bottomDotForAddRow.style.height="6px",this.bottomDotForAddRow.style.backgroundColor="#4A90E2",this.bottomDotForAddRow.style.position="absolute",this.bottomDotForAddRow.style.cursor="pointer",this.bottomDotForAddRow.style.zIndex="1000",this.bottomDotForAddRow.style.borderRadius="50%",this.bottomDotForAddRow.style.border="1px solid white",this.bottomDotForAddRow.style.boxShadow="0 1px 3px rgba(0,0,0,0.2)",document.body.appendChild(this.bottomDotForAddRow),this.addIconForAddRow=document.createElement("div"),this.addIconForAddRow.style.width="18px",this.addIconForAddRow.style.height="18px",this.addIconForAddRow.style.backgroundColor="#4A90E2",this.addIconForAddRow.style.position="absolute",this.addIconForAddRow.style.zIndex="1001",this.addIconForAddRow.style.display="none",this.addIconForAddRow.style.borderRadius="50%",this.addIconForAddRow.style.boxShadow="0 2px 5px rgba(0,0,0,0.2)",this.addIconForAddRow.style.display="flex",this.addIconForAddRow.style.justifyContent="center",this.addIconForAddRow.style.alignItems="center",this.addIconForAddRow.style.border="1px solid white",document.body.appendChild(this.addIconForAddRow);const t=document.createElement("div");t.textContent="+",t.style.color="white",t.style.fontSize="18px",t.style.fontWeight="bold",t.style.lineHeight="15px",t.style.userSelect="none",t.style.cursor="pointer",t.style.verticalAlign="top",t.style.textAlign="center",this.addIconForAddRow.appendChild(t),this.addLineForAddRow=document.createElement("div"),this.addLineForAddRow.style.width="10px",this.addLineForAddRow.style.height="2px",this.addLineForAddRow.style.backgroundColor="#4A90E2",this.addLineForAddRow.style.position="absolute",this.addLineForAddRow.style.zIndex="1001",this.addLineForAddRow.style.display="none",document.body.appendChild(this.addLineForAddRow)}bindEventForAddRow(){this.topDotForAddRow.addEventListener("mouseenter",(()=>{clearTimeout(this.hideAllTimeoutId_addRow),this.addIconForAddRow.style.display="block";const t=this.topDotForAddRow.offsetWidth,e=this.topDotForAddRow.offsetHeight;this.showAddIconForAddRow(this.topDotForAddRow.offsetLeft+t/2,this.topDotForAddRow.offsetTop+e/2,!0),this.showSplitLineForAddRow(this.topDotForAddRow.offsetLeft+t+2,this.topDotForAddRow.offsetTop+e/2-1,this.table.getDrawRange().width)})),this.bottomDotForAddRow.addEventListener("mouseenter",(()=>{clearTimeout(this.hideAllTimeoutId_addRow),this.addIconForAddRow.style.display="block";const t=this.bottomDotForAddRow.offsetWidth,e=this.bottomDotForAddRow.offsetHeight;this.showAddIconForAddRow(this.bottomDotForAddRow.offsetLeft+t/2,this.bottomDotForAddRow.offsetTop+e/2,!1),this.showSplitLineForAddRow(this.bottomDotForAddRow.offsetLeft+t+2,this.bottomDotForAddRow.offsetTop+e/2-1,this.table.getDrawRange().height)})),this.addIconForAddRow.addEventListener("mouseleave",(()=>{this.addIconForAddRow.style.display="none",this.addLineForAddRow.style.display="none",this.delayHideAllForAddRow()})),this.addIconForAddRow.addEventListener("click",(t=>{const e="top"===this.addIconForAddRow.dataset.addIconType,r=this.hoverCell.row,i=e?r:r+1;if(this.pluginOptions.addRowCallback)this.pluginOptions.addRowCallback(i);else{const t=this.table.getRecordIndexByCell(0,i);this.table.addRecord({},t)}this.delayHideAllForAddRow(0)}))}showDotForAddRow(t,e,r,i=!0,n=!0){const s=this.topDotForAddRow.offsetWidth,o=this.topDotForAddRow.offsetHeight;this.topDotForAddRow.style.left=e-s/2+"px",this.topDotForAddRow.style.top=t-o/2+"px",this.bottomDotForAddRow.style.left=e-s/2+"px",this.bottomDotForAddRow.style.top=r-o/2+"px",this.topDotForAddRow.style.display=i?"block":"none",this.bottomDotForAddRow.style.display=n?"block":"none"}showAddIconForAddRow(t,e,r){const i=this.addIconForAddRow.offsetWidth,n=this.addIconForAddRow.offsetHeight,s=this.topDotForAddRow.offsetWidth;this.addIconForAddRow.style.left=t-i/2-s/2+"px",this.addIconForAddRow.style.top=e-n/2+"px",this.addIconForAddRow.dataset.addIconType=r?"top":"bottom"}showSplitLineForAddRow(t,e,r){this.addLineForAddRow.style.left=`${t}px`,this.addLineForAddRow.style.top=`${e}px`,this.addLineForAddRow.style.width=`${r}px`,this.addLineForAddRow.style.display="block"}delayHideAllForAddRow(t=1e3){this.hideAllTimeoutId_addRow=setTimeout((()=>{this.addIconForAddRow.style.display="none",this.addLineForAddRow.style.display="none",this.topDotForAddRow.style.display="none",this.bottomDotForAddRow.style.display="none"}),t)}release(){this.leftDotForAddColumn.remove(),this.rightDotForAddColumn.remove(),this.addIconForAddColumn.remove(),this.addLineForAddColumn.remove(),this.topDotForAddRow.remove(),this.bottomDotForAddRow.remove(),this.addIconForAddRow.remove(),this.addLineForAddRow.remove()}},t.CarouselAnimationPlugin=class{table;rowCount;colCount;animationDuration;animationDelay;animationEasing;replaceScrollAction;playing;row;col;willUpdateRow=!1;willUpdateCol=!1;customDistRowFunction;customDistColFunction;constructor(t,e){this.table=t,this.rowCount=e?.rowCount??void 0,this.colCount=e?.colCount??void 0,this.animationDuration=e?.animationDuration??500,this.animationDelay=e?.animationDelay??1e3,this.animationEasing=e?.animationEasing??"linear",this.replaceScrollAction=e?.replaceScrollAction??!1,this.customDistColFunction=e.customDistColFunction,this.customDistRowFunction=e.customDistRowFunction,this.reset(),this.init()}init(){this.replaceScrollAction&&(this.table.disableScroll(),this.table.scenegraph.stage.addEventListener("wheel",this.onScrollEnd.bind(this)))}reset(){this.playing=!1,this.row=this.table.frozenRowCount,this.col=this.table.frozenColCount}onScrollEnd(t){this.rowCount?(t.deltaY>0?(this.row+=this.rowCount,this.row=Math.min(this.row,this.table.rowCount-this.table.frozenRowCount)):t.deltaY<0&&(this.row-=this.rowCount,this.row=Math.max(this.row,this.table.frozenRowCount)),this.table.scrollToRow(this.row,{duration:this.animationDuration,easing:this.animationEasing})):this.colCount&&(t.deltaX>0?(this.col+=this.colCount,this.col=Math.min(this.col,this.table.colCount-this.table.frozenColCount)):t.deltaX<0&&(this.col-=this.colCount,this.col=Math.max(this.col,this.table.frozenColCount)),this.table.scrollToCol(this.col,{duration:this.animationDuration,easing:this.animationEasing}))}play(){this.playing=!0,this.rowCount&&!this.willUpdateRow?this.updateRow():this.colCount&&!this.willUpdateCol&&this.updateCol()}pause(){this.playing=!1}updateRow(){if(!this.playing||this.table.isReleased)return;let t=!0;const e=this.customDistRowFunction&&this.customDistRowFunction(this.row,this.table);e?(this.row=e.distRow,t=e.animation??!0):g(this.row)&&this.table.scenegraph.proxy.screenTopRow!==this.row?(this.row=this.table.frozenRowCount,t=!1):g(this.row)||this.table.scenegraph.proxy.screenTopRow===Math.floor(this.row)?this.row+=this.rowCount:(this.row=this.table.frozenRowCount,t=!1),this.table.scrollToRow(this.row,t?{duration:this.animationDuration,easing:this.animationEasing}:void 0),this.willUpdateRow=!0,setTimeout((()=>{this.willUpdateRow=!1,this.updateRow()}),this.animationDuration+this.animationDelay)}updateCol(){if(!this.playing||this.table.isReleased)return;let t=!0;const e=this.customDistColFunction&&this.customDistColFunction(this.col,this.table);e?(this.col=e.distCol,t=e.animation??!0):g(this.col)&&this.table.scenegraph.proxy.screenLeftCol!==this.col?(this.col=this.table.frozenColCount,t=!1):g(this.col)||this.table.scenegraph.proxy.screenLeftCol===Math.floor(this.col)?this.col+=this.colCount:(this.col=this.table.frozenColCount,t=!1),this.table.scrollToCol(this.col,t?{duration:this.animationDuration,easing:this.animationEasing}:void 0),this.willUpdateCol=!0,setTimeout((()=>{this.willUpdateCol=!1,this.updateCol()}),this.animationDuration+this.animationDelay)}},t.ColumnSeriesPlugin=class{id=`column-series-${Date.now()}`;name="Column Series";runTime=[m.TABLE_EVENT_TYPE.BEFORE_INIT,m.TABLE_EVENT_TYPE.BEFORE_KEYDOWN];pluginOptions;table;columns=[];constructor(t){this.id=t.id??this.id,this.pluginOptions=Object.assign({columnCount:100},t)}run(...t){if(t[1]===m.TABLE_EVENT_TYPE.BEFORE_INIT){const e=t[0],r=t[2];this.table=r;const i=e.options;this.columns=this.generateColumns(this.pluginOptions.columnCount),i.columns=this.columns}else if(t[1]===m.TABLE_EVENT_TYPE.BEFORE_KEYDOWN){const e=t[0].event;this.pluginOptions.autoExtendColumnTriggerKeys?.includes(e.key)&&this.table.stateManager.select.cellPos.col===this.table.colCount-1&&this.table.addColumn(this.generateColumn(this.table.colCount-1))}}generateColumns(t){const e=[];for(let r=0;r<t;r++)e.push(this.generateColumn(r));return e}generateColumn(t){return{title:this.pluginOptions.generateColumnTitle?this.pluginOptions.generateColumnTitle(t):this.generateColumnField(t)}}generateColumnField(t){if(t<26)return String.fromCharCode(65+t);const e=[];for(t++;t>0;)t--,e.unshift(String.fromCharCode(65+t%26)),t=Math.floor(t/26);return e.join("")}resetColumnCount(t){this.pluginOptions.columnCount=t,this.columns=this.generateColumns(t),this.table.updateColumns(this.columns)}},t.ExcelEditCellKeyboardPlugin=class{id=`excel-edit-cell-keyboard-${Date.now()}`;name="Excel Edit Cell Keyboard";runTime=[m.TABLE_EVENT_TYPE.INITIALIZED];table;pluginOptions;constructor(t){this.id=t?.id??this.id,this.pluginOptions=t,this.bindEvent()}run(...t){const e=t[2];this.table=e}bindEvent(){document.addEventListener("keydown",this.handleKeyDown.bind(this),!0)}handleKeyDown(t){if(this.table.editorManager)if("keydown"===this.table.editorManager.beginTriggerEditCellMode){if(this.table.editorManager.editingEditor&&this.isExcelShortcutKey(t)){const{col:e,row:r}=this.table.editorManager.editCell;this.table.editorManager.completeEdit(),this.table.getElement().focus(),t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key?this.table.selectCell(e,r+1):"Tab"===t.key?this.table.selectCell(e+1,r):"ArrowLeft"===t.key?this.table.selectCell(e-1,r):"ArrowRight"===t.key?this.table.selectCell(e+1,r):"ArrowDown"===t.key?this.table.selectCell(e,r+1):"ArrowUp"===t.key&&this.table.selectCell(e,r-1),t.stopPropagation(),t.preventDefault())}}else{const{col:e,row:r}=this.table.stateManager.select.cellPos;if(!this.table.editorManager.editingEditor||"Enter"!==t.key&&"Tab"!==t.key){if("Delete"===t.key){const e=this.table.getSelectedCellInfos();e?.length>0&&function(t,e){for(let r=0;r<t.length;r++)for(let i=0;i<t[r].length;i++)e.changeCellValue(t[r][i].col,t[r][i].row,"")}(e,this.table),t.stopPropagation(),t.preventDefault()}}else this.table.editorManager.completeEdit(),this.table.getElement().focus(),"Enter"===t.key?this.table.selectCell(e,r+1):"Tab"===t.key&&this.table.selectCell(e+1,r),t.stopPropagation(),t.preventDefault()}}isExcelShortcutKey(t){return"Enter"===t.key||"Tab"===t.key||"ArrowLeft"===t.key||"ArrowRight"===t.key||"ArrowDown"===t.key||"ArrowUp"===t.key}release(){document.removeEventListener("keydown",this.handleKeyDown,!0)}},t.ExcelImportPlugin=T4,t.ExportGanttPlugin=class{id="gantt-export-helper";name="Gantt Export Helper";_gantt=null;run(...t){const e=t[0];e&&(this._gantt=e)}async exportToImage(t={}){if(!this._gantt)return;const{fileName:e="gantt-export",type:r="png",quality:i=1,backgroundColor:n="#ffffff",scale:s=window.devicePixelRatio||1,download:o=!0}=t;try{const{tempContainer:t,clonedGantt:a}=this.createFullSizeContainer(s);try{await new Promise((t=>requestAnimationFrame(t)));const t=(a.taskListTableInstance.getAllColsWidth()+a.getAllDateColsWidth())*s,l=a.getAllRowsHeight()*s,h=document.createElement("canvas");h.width=t,h.height=l;const c=h.getContext("2d");c.fillStyle=n,c.fillRect(0,0,t,l),a.taskListTableInstance?.canvas&&c.drawImage(a.taskListTableInstance.canvas,0,0,a.taskListTableInstance.getAllColsWidth()*s,l);const u=3*s,d=a.taskListTableInstance.getAllColsWidth()*s;c.fillStyle="rgb(225, 228, 232)",c.fillRect(d-u/2,0,u,l);const p=4*s,f=a.canvas.width-p;return a.canvas&&c.drawImage(a.canvas,p,0,f,a.canvas.height,(a.taskListTableInstance.getAllColsWidth()+1.5)*s,0,(a.getAllDateColsWidth()-1.5)*s,l),this.finalizeExport(h,e,r,i,o)}finally{t.remove(),a.release()}}catch(t){throw new Error(`甘特图导出失败: ${t instanceof Error?t.message:"未知错误"}`)}}async exportToBase64(t={}){return this.exportToImage({...t,download:!1})}createFullSizeContainer(t){if(!this._gantt)throw new Error("ExportGanttPlugin: Gantt instance not available to create container.");const e=document.createElement("div");e.style.position="fixed",e.style.left="-9999px",e.style.overflow="hidden",e.style.width=`${window.innerWidth+100}px`,e.style.height=`${window.innerHeight+100}px`,document.body.appendChild(e);const r=document.createElement("div"),i=this._gantt.taskListTableInstance.getAllColsWidth()+this._gantt.getAllDateColsWidth(),n=this._gantt.getAllRowsHeight();r.style.width=`${i}px`,r.style.height=`${n}px`,e.appendChild(r);const s=new Np(r,{...this._gantt.options,records:this._gantt.records,taskListTable:{...this._gantt.options.taskListTable,tableWidth:void 0,minTableWidth:void 0,maxTableWidth:void 0},plugins:[]});return s.setPixelRatio(t),s.scenegraph?.ganttGroup&&s.scenegraph.ganttGroup.setAttribute("clip",!1),s.taskListTableInstance?.scenegraph?.tableGroup&&s.taskListTableInstance.scenegraph.tableGroup.setAttribute("clip",!1),s.scenegraph.stage.render(),{tempContainer:e,clonedGantt:s}}finalizeExport(t,e,r,i,n=!0){const s=t.toDataURL(`image/${r}`,i);if(n){const t=document.createElement("a");t.download=`${e}.${r}`,t.href=s,document.body.appendChild(t),t.click(),document.body.removeChild(t)}return s}release(){this._gantt=null}},t.FocusHighlightPlugin=class{id=`focus-highlight-${Date.now()}`;name="Focus Highlight";runTime=[e.TABLE_EVENT_TYPE.INITIALIZED,e.TABLE_EVENT_TYPE.SELECTED_CELL,e.TABLE_EVENT_TYPE.SELECTED_CLEAR];table;range;pluginOptions;constructor(t={fill:"#000",opacity:.5,highlightRange:void 0}){this.id=t.id??this.id,this.pluginOptions=Object.assign({fill:"#000",opacity:.5},t)}run(...t){if(this.table||(this.table=t[2]),t[1]===e.TABLE_EVENT_TYPE.INITIALIZED)this.pluginOptions.highlightRange&&this.setFocusHighlightRange(this.pluginOptions.highlightRange);else if(t[1]===e.TABLE_EVENT_TYPE.SELECTED_CELL){const t=this.table.stateManager.select.cellPos;if(this.table.isHeader(t.col,t.row))this.setFocusHighlightRange(void 0);else{const t=this.table.stateManager.select.ranges,e=0,r=this.table.colCount-1,i=Math.min(t[0].start.row,t[0].end.row),n=Math.max(t[0].start.row,t[0].end.row);this.setFocusHighlightRange({start:{col:e,row:i},end:{col:r,row:n}})}}else t[1]===e.TABLE_EVENT_TYPE.SELECTED_CLEAR&&this.setFocusHighlightRange(void 0)}setFocusHighlightRange(t,e=!1){let r;t&&"start"in t&&"end"in t?r=t:t&&(r={start:t,end:t}),nd(this.range,r)&&!e||(this.range=r,t?this.updateCellGroupShadow():this.deleteAllCellGroupShadow(),this.table.scenegraph.updateNextFrame())}deleteAllCellGroupShadow(){this.table.isPivotTable()||(this.updateCellGroupShadowInContainer(this.table.scenegraph.rowHeaderGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.leftBottomCornerGroup)),this.updateCellGroupShadowInContainer(this.table.scenegraph.bodyGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.rightFrozenGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.bottomFrozenGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.rightBottomCornerGroup)}updateCellGroupShadow(){this.table.isPivotTable()||(this.updateCellGroupShadowInContainer(this.table.scenegraph.rowHeaderGroup,this.range),this.updateCellGroupShadowInContainer(this.table.scenegraph.leftBottomCornerGroup,this.range)),this.updateCellGroupShadowInContainer(this.table.scenegraph.bodyGroup,this.range),this.updateCellGroupShadowInContainer(this.table.scenegraph.rightFrozenGroup,this.range),this.updateCellGroupShadowInContainer(this.table.scenegraph.bottomFrozenGroup),this.range,this.updateCellGroupShadowInContainer(this.table.scenegraph.rightBottomCornerGroup,this.range)}updateCellGroupShadowInContainer(t,e){let r;e&&"start"in e&&"end"in e?r=e:e&&(r={start:e,end:e}),t.forEachChildrenSkipChild((t=>{const e=t;"column"===e.role&&e.forEachChildrenSkipChild((t=>{const e=t;if("cell"!==e.role)return;e.attachShadow(e.shadowRoot);const i=e.shadowRoot;if(r){if(ad(r,e.col,e.row))i.removeAllChild();else if(!i.firstChild){const t=Ya({x:0,y:0,width:e.attribute.width,height:e.attribute.height,fill:this.pluginOptions.fill,opacity:this.pluginOptions.opacity});t.name="shadow-rect",i.appendChild(t)}}else i.removeAllChild()}))}))}update(){this.setFocusHighlightRange(this.range,!0)}},t.HeaderHighlightPlugin=class{table;options;colHeaderRange;rowHeaderRange;constructor(t,e){this.table=t,this.options=e,this.registerStyle(),this.bindEvent()}registerStyle(){this.table.registerCustomCellStyle("col-highlight",{bgColor:this.options?.colHighlightBGColor??"#82b2f5",color:this.options?.colHighlightColor??"#FFF"}),this.table.registerCustomCellStyle("row-highlight",{bgColor:this.options?.rowHighlightBGColor??"#82b2f5",color:this.options?.rowHighlightColor??"#FFF"})}bindEvent(){this.table.on("selected_cell",(()=>{this.updateHighlight()})),this.table.on("selected_clear",(()=>{this.clearHighlight()})),this.table.on("mousemove_table",(()=>{this.table.stateManager.select.selecting&&this.updateHighlight()}))}clearHighlight(){this.colHeaderRange&&this.table.arrangeCustomCellStyle({range:this.colHeaderRange},void 0,!0),this.rowHeaderRange&&this.table.arrangeCustomCellStyle({range:this.rowHeaderRange},void 0,!0),this.colHeaderRange=void 0,this.rowHeaderRange=void 0}updateHighlight(){if(!1===this.options?.colHighlight&&!1===this.options?.rowHighlight)return;const t=this.table.getSelectedCellRanges();if(0===t.length)return void this.clearHighlight();const e=t[0],r=[e.start.row,e.end.row];r.sort(((t,e)=>t-e));const i=[e.start.col,e.end.col];let n,s;i.sort(((t,e)=>t-e)),this.table.isPivotTable()?(n={start:{col:i[0],row:0},end:{col:i[1],row:this.table.columnHeaderLevelCount-1}},s={start:{col:0,row:r[0]},end:{col:this.table.rowHeaderLevelCount-1,row:r[1]}}):this.table.internalProps.transpose?s={start:{col:0,row:r[0]},end:{col:this.table.rowHeaderLevelCount-1,row:r[1]}}:(n={start:{col:i[0],row:0},end:{col:i[1],row:this.table.columnHeaderLevelCount-1}},this.table.internalProps.rowSeriesNumber&&(s={start:{col:0,row:r[0]},end:{col:0,row:r[1]}})),!1===this.options?.colHighlight||ld(this.colHeaderRange,n)||(this.colHeaderRange&&this.table.arrangeCustomCellStyle({range:this.colHeaderRange},void 0),n&&this.table.arrangeCustomCellStyle({range:n},"col-highlight"),this.colHeaderRange=n),!1===this.options?.rowHighlight||ld(this.rowHeaderRange,s)||(this.rowHeaderRange&&this.table.arrangeCustomCellStyle({range:this.rowHeaderRange},void 0),s&&this.table.arrangeCustomCellStyle({range:s},"row-highlight"),this.rowHeaderRange=s)}},t.HighlightHeaderWhenSelectCellPlugin=class{id=`highlight-header-when-select-cell-${Date.now()}`;name="Highlight Header When Select Cell";runTime=[e.TABLE_EVENT_TYPE.INITIALIZED,e.TABLE_EVENT_TYPE.SELECTED_CLEAR,e.TABLE_EVENT_TYPE.SELECTED_CELL,e.TABLE_EVENT_TYPE.MOUSEMOVE_TABLE];table;pluginOptions;colHeaderRanges=[];rowHeaderRanges=[];constructor(t){this.id=t.id??this.id,this.pluginOptions=t}run(...t){const r=t[1],i=t[2];this.table=i,r===e.TABLE_EVENT_TYPE.SELECTED_CLEAR?this.clearHighlight():r===e.TABLE_EVENT_TYPE.SELECTED_CELL||r===e.TABLE_EVENT_TYPE.MOUSEMOVE_TABLE?this.updateHighlight():r===e.TABLE_EVENT_TYPE.INITIALIZED&&this.registerStyle()}registerStyle(){this.table.registerCustomCellStyle("col-highlight",{bgColor:this.pluginOptions?.colHighlightBGColor??"#82b2f5",color:this.pluginOptions?.colHighlightColor??"#FFF"}),this.table.registerCustomCellStyle("row-highlight",{bgColor:this.pluginOptions?.rowHighlightBGColor??"#82b2f5",color:this.pluginOptions?.rowHighlightColor??"yellow"})}clearHighlight(){this.colHeaderRanges&&this.colHeaderRanges.forEach((t=>{this.table.arrangeCustomCellStyle({range:t},void 0)})),this.rowHeaderRanges&&this.rowHeaderRanges.forEach((t=>{this.table.arrangeCustomCellStyle({range:t},void 0)})),this.colHeaderRanges=[],this.rowHeaderRanges=[]}updateHighlight(){if(!1===this.pluginOptions?.colHighlight&&!1===this.pluginOptions?.rowHighlight)return;const t=this.table.getSelectedCellRanges();t.length<2&&this.clearHighlight();for(let e=0;e<t.length;e++){const r=t[e],i=[r.start.row,r.end.row];i.sort(((t,e)=>t-e));const n=[r.start.col,r.end.col];let s,o;n.sort(((t,e)=>t-e)),this.table.isPivotTable()?(s={start:{col:n[0],row:0},end:{col:n[1],row:this.table.columnHeaderLevelCount-1}},o={start:{col:0,row:i[0]},end:{col:this.table.rowHeaderLevelCount-1,row:i[1]}}):this.table.internalProps.transpose?o={start:{col:0,row:i[0]},end:{col:this.table.rowHeaderLevelCount-1,row:i[1]}}:(s={start:{col:n[0],row:0},end:{col:n[1],row:this.table.columnHeaderLevelCount-1}},this.table.internalProps.rowSeriesNumber&&(o={start:{col:0,row:i[0]},end:{col:0,row:i[1]}})),!1===this.pluginOptions?.colHighlight||this.colHeaderRanges.find((t=>hd(t,s)))||(s&&this.table.arrangeCustomCellStyle({range:s},"col-highlight"),this.colHeaderRanges.push(s)),!1===this.pluginOptions?.rowHighlight||this.rowHeaderRanges.find((t=>hd(t,o)))||(o&&this.table.arrangeCustomCellStyle({range:o},"row-highlight"),this.rowHeaderRanges.push(o))}}update(){this.registerStyle(),this.updateHighlight()}release(){this.rowHeaderRanges=[],this.colHeaderRanges=[]}},t.InvertHighlightPlugin=class{table;range;_fill;_opacity;constructor(t,e){this.table=t,this._fill=e?.fill??"#000",this._opacity=e?.opacity??.5}setInvertHighlightRange(t){nd(this.range,t)||(this.range=t,t?this.updateCellGroupShadow():this.deleteAllCellGroupShadow(),this.table.scenegraph.updateNextFrame())}deleteAllCellGroupShadow(){this.table.isPivotTable()||(this.updateCellGroupShadowInContainer(this.table.scenegraph.rowHeaderGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.leftBottomCornerGroup)),this.updateCellGroupShadowInContainer(this.table.scenegraph.bodyGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.rightFrozenGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.bottomFrozenGroup),this.updateCellGroupShadowInContainer(this.table.scenegraph.rightBottomCornerGroup)}updateCellGroupShadow(){this.table.isPivotTable()||(this.updateCellGroupShadowInContainer(this.table.scenegraph.rowHeaderGroup,this.range),this.updateCellGroupShadowInContainer(this.table.scenegraph.leftBottomCornerGroup,this.range)),this.updateCellGroupShadowInContainer(this.table.scenegraph.bodyGroup,this.range),this.updateCellGroupShadowInContainer(this.table.scenegraph.rightFrozenGroup,this.range),this.updateCellGroupShadowInContainer(this.table.scenegraph.bottomFrozenGroup),this.range,this.updateCellGroupShadowInContainer(this.table.scenegraph.rightBottomCornerGroup,this.range)}updateCellGroupShadowInContainer(t,e){t.forEachChildrenSkipChild((t=>{const r=t;"column"===r.role&&r.forEachChildrenSkipChild((t=>{const r=t;if("cell"!==r.role)return;r.attachShadow(r.shadowRoot);const i=r.shadowRoot;if(e){if(ad(e,r.col,r.row))i.removeAllChild();else if(!i.firstChild){const t=Ya({x:0,y:0,width:r.attribute.width,height:r.attribute.height,fill:this._fill,opacity:this._opacity});t.name="shadow-rect",i.appendChild(t)}}else i.removeAllChild()}))}))}},t.RotateTablePlugin=class{id=`rotate-table-${Date.now()}`;name="Rotate Table";runTime=[m.TABLE_EVENT_TYPE.INITIALIZED];table;matrix;vglobal_mapToCanvasPoint;constructor(t){this.id=t?.id??this.id}run(...t){const e=t[2];this.table=e,this.table.rotate90WithTransform=ud.bind(this.table),this.table.cancelTransform=dd.bind(this.table)}release(){}},t.RowSeriesPlugin=class{id=`row-series-${Date.now()}`;name="Row Series";runTime=[e.TABLE_EVENT_TYPE.BEFORE_INIT,e.TABLE_EVENT_TYPE.BEFORE_KEYDOWN];pluginOptions;table;constructor(t){this.id=t.id??this.id,this.pluginOptions=Object.assign({rowCount:100},t)}run(...t){if(t[1]===e.TABLE_EVENT_TYPE.BEFORE_INIT){const e=t[0],r=t[2];this.table=r;const i=e.options,n=i.records??[];for(let t=n.length;t<this.pluginOptions.rowCount;t++)n.push(this.pluginOptions.fillRowRecord?this.pluginOptions.fillRowRecord(t):{});i.records=n,this.pluginOptions.rowSeriesNumber?(i.rowSeriesNumber=this.pluginOptions.rowSeriesNumber,this.pluginOptions.rowSeriesNumber.width||(i.rowSeriesNumber.width="auto")):i.rowSeriesNumber||(i.rowSeriesNumber={width:"auto"})}else if(t[1]===e.TABLE_EVENT_TYPE.BEFORE_KEYDOWN){const e=t[0].event;this.pluginOptions.autoExtendRowTriggerKeys?.includes(e.key)&&this.table.stateManager.select.cellPos.row===this.table.rowCount-1&&this.table.addRecord(this.pluginOptions.fillRowRecord?this.pluginOptions.fillRowRecord(this.table.rowCount-this.table.columnHeaderLevelCount):{})}}},t.TableCarouselAnimationPlugin=class{id=`table-carousel-animation-${Date.now()}`;name="Table Carousel Animation";runTime=[e.TABLE_EVENT_TYPE.INITIALIZED];table;rowCount;colCount;animationDuration;animationDelay;animationEasing;playing;row;col;willUpdateRow=!1;willUpdateCol=!1;autoPlay;autoPlayDelay;customDistRowFunction;customDistColFunction;constructor(t={}){this.id=t.id??this.id,this.rowCount=t?.rowCount??void 0,this.colCount=t?.colCount??void 0,this.animationDuration=t?.animationDuration??500,this.animationDelay=t?.animationDelay??1e3,this.animationEasing=t?.animationEasing??"linear",this.autoPlay=t?.autoPlay??!1,this.autoPlayDelay=t?.autoPlayDelay??0,this.customDistColFunction=t.customDistColFunction,this.customDistRowFunction=t.customDistRowFunction}run(...t){this.table||(this.table=t[2]),this.reset(),this.autoPlay&&setTimeout((()=>{this.play()}),this.autoPlayDelay)}reset(){this.playing=!1,this.row=this.table.frozenRowCount,this.col=this.table.frozenColCount}play(){if(!this.table)throw new Error("table is not initialized");this.playing=!0,this.rowCount&&!this.willUpdateRow?this.updateRow():this.colCount&&!this.willUpdateCol&&this.updateCol()}pause(){this.playing=!1}updateRow(){if(!this.playing||this.table.isReleased)return;let t=!0;const e=this.customDistRowFunction&&this.customDistRowFunction(this.row,this.table);e?(this.row=e.distRow,t=e.animation??!0):cd(this.row)&&this.table.scenegraph.proxy.screenTopRow!==this.row?(this.row=this.table.frozenRowCount,t=!1):cd(this.row)||this.table.scenegraph.proxy.screenTopRow===Math.floor(this.row)?this.row+=this.rowCount:(this.row=this.table.frozenRowCount,t=!1),this.table.scrollToRow(this.row,t?{duration:this.animationDuration,easing:this.animationEasing}:void 0),this.willUpdateRow=!0,setTimeout((()=>{this.willUpdateRow=!1,this.updateRow()}),this.animationDuration+this.animationDelay)}updateCol(){if(!this.playing||this.table.isReleased)return;let t=!0;const e=this.customDistColFunction&&this.customDistColFunction(this.col,this.table);e?(this.col=e.distCol,t=e.animation??!0):cd(this.col)&&this.table.scenegraph.proxy.screenLeftCol!==this.col?(this.col=this.table.frozenColCount,t=!1):cd(this.col)||this.table.scenegraph.proxy.screenLeftCol===Math.floor(this.col)?this.col+=this.colCount:(this.col=this.table.frozenColCount,t=!1),this.table.scrollToCol(this.col,t?{duration:this.animationDuration,easing:this.animationEasing}:void 0),this.willUpdateCol=!0,setTimeout((()=>{this.willUpdateCol=!1,this.updateCol()}),this.animationDuration+this.animationDelay)}release(){}},t.WpsFillHandlePlugin=class{id=`wps-fill-handle-${Date.now()}`;name="WPS Fill Handle";runTime=[m.TABLE_EVENT_TYPE.MOUSEDOWN_FILL_HANDLE,m.TABLE_EVENT_TYPE.DRAG_FILL_HANDLE_END];table;pluginOptions;beforeDragMinCol=0;beforeDragMinRow=0;beforeDragMaxCol=0;beforeDragMaxRow=0;constructor(t){this.id=t?.id??this.id,this.pluginOptions=t}run(...t){if(t[1]===m.TABLE_EVENT_TYPE.MOUSEDOWN_FILL_HANDLE){t[0];const e=t[2];this.table=e;const r=this.table?.getSelectedCellRanges()[0];if(!r)return;this.beforeDragMaxCol=Math.max(r.start.col,r.end.col),this.beforeDragMinCol=Math.min(r.start.col,r.end.col),this.beforeDragMaxRow=Math.max(r.start.row,r.end.row),this.beforeDragMinRow=Math.min(r.start.row,r.end.row)}else if(t[1]===m.TABLE_EVENT_TYPE.DRAG_FILL_HANDLE_END){const e=t[0].direction;let r,i;const n=this.table?.getSelectedCellRanges()[0];if(!n)return;"bottom"===e?(r=this.beforeDragMaxCol,i=n.end.row):"right"===e?(r=n.end.col,i=this.beforeDragMaxRow):"top"===e?(r=this.beforeDragMaxCol,i=n.end.row):"left"===e&&(r=n.end.col,i=this.beforeDragMaxRow);const s=this.table?.records,o=this.table?.getAllColumnHeaderCells()||[];let a=[];o?.length&&(a=o[o.length-1]);const l=Rv(s,a,{startRow:this.beforeDragMinRow-o.length,startCol:this.beforeDragMinCol,endRow:this.beforeDragMaxRow-o.length,endCol:this.beforeDragMaxCol},{row:i-o.length,col:r});this.table?.setRecords(l)}}handleKeyDown(){if(this.table.editorManager){const t=this.table?.getSelectedCellRanges()[0];if(!t)return;this.beforeDragMaxCol=Math.max(t.start.col,t.end.col),this.beforeDragMinCol=Math.min(t.start.col,t.end.col),this.beforeDragMaxRow=Math.max(t.start.row,t.end.row),this.beforeDragMinRow=Math.min(t.start.row,t.end.row)}}release(){this.beforeDragMinCol=0,this.beforeDragMinRow=0,this.beforeDragMaxCol=0,this.beforeDragMaxRow=0}},t.cancelTransform=dd,t.rotate90WithTransform=ud}));
|
package/es/gantt-export-image.js
CHANGED
|
@@ -78,7 +78,7 @@ export class ExportGanttPlugin {
|
|
|
78
78
|
clonedContainer.style.width = `${totalWidth}px`, clonedContainer.style.height = `${totalHeight}px`,
|
|
79
79
|
tempContainer.appendChild(clonedContainer);
|
|
80
80
|
const clonedGantt = new VTableGantt.Gantt(clonedContainer, Object.assign(Object.assign({}, this._gantt.options), {
|
|
81
|
-
records:
|
|
81
|
+
records: this._gantt.records,
|
|
82
82
|
taskListTable: Object.assign(Object.assign({}, this._gantt.options.taskListTable), {
|
|
83
83
|
tableWidth: void 0,
|
|
84
84
|
minTableWidth: void 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["gantt-export-image.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,WAAW,MAAM,wBAAwB,CAAC;AAgBtD,MAAM,OAAO,iBAAiB;IAA9B;QACE,OAAE,GAAG,qBAAqB,CAAC;QAC3B,SAAI,GAAG,qBAAqB,CAAC;QACrB,WAAM,GAA6B,IAAI,CAAC;IAyLlD,CAAC;IAtLC,GAAG,CAAC,GAAG,IAAW;QAChB,MAAM,aAAa,GAAG,IAAI,CAAC,CAAC,CAAsB,CAAC;QACnD,IAAI,CAAC,aAAa,EAAE;YAClB,OAAO,CAAC,KAAK,CAAC,+DAA+D,CAAC,CAAC;YAC/E,OAAO;SACR;QACD,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC;IAC9B,CAAC;IAQK,aAAa,CAAC,UAAyB,EAAE;;;YAC7C,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;gBAEhB,OAAO,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;gBAClE,OAAO,SAAS,CAAC;aAClB;YAED,MAAM,EACJ,QAAQ,GAAG,cAAc,EACzB,IAAI,GAAG,KAAK,EACZ,OAAO,GAAG,CAAC,EACX,eAAe,GAAG,SAAS,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AC;IAED,OAAO;QACL,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACrB,CAAC;CACF","file":"gantt-export-image.js","sourcesContent":["import * as VTableGantt from '@visactor/vtable-gantt';\r\n\r\n// 甘特图导出配置项接口\r\nexport interface ExportOptions {\r\n fileName?: string;\r\n type?: 'png' | 'jpeg';\r\n quality?: number;\r\n backgroundColor?: string;\r\n scale?: number;\r\n download?: boolean;\r\n}\r\n\r\n/**\r\n * 甘特图导出插件\r\n * @description 提供完整的甘特图导出功能,支持高分辨率输出和精准布局保留\r\n */\r\nexport class ExportGanttPlugin implements VTableGantt.plugins.IGanttPlugin {\r\n id = 'gantt-export-helper';\r\n name = 'Gantt Export Helper';\r\n private _gantt: VTableGantt.Gantt | null = null;\r\n\r\n // run 方法,在插件初始化时由 PluginManager调用\r\n run(...args: any[]): void {\r\n const ganttInstance = args[0] as VTableGantt.Gantt;\r\n if (!ganttInstance) {\r\n console.error('ExportGanttPlugin: Gantt instance not provided to run method.');\r\n return;\r\n }\r\n this._gantt = ganttInstance;\r\n }\r\n /**\r\n * 执行甘特图导出操作\r\n * @async\r\n * @param {ExportOptions} [options={}] 导出配置选项\r\n * @returns {Promise<string | undefined>} 返回Base64格式的图片数据,或在未初始化时返回 undefined\r\n * @throws {Error} 导出过程中发生错误时抛出异常\r\n */\r\n async exportToImage(options: ExportOptions = {}): Promise<string | undefined> {\r\n if (!this._gantt) {\r\n // 保留这个 error\r\n console.error('ExportGanttPlugin: Gantt instance not available.');\r\n return undefined;\r\n }\r\n\r\n const {\r\n fileName = 'gantt-export',\r\n type = 'png',\r\n quality = 1,\r\n backgroundColor = '#ffffff',\r\n scale = window.devicePixelRatio || 1,\r\n download = true // 默认执行下载\r\n } = options;\r\n\r\n try {\r\n const { tempContainer, clonedGantt } = this.createFullSizeContainer(scale);\r\n\r\n try {\r\n await new Promise(resolve => requestAnimationFrame(resolve));\r\n\r\n const totalWidth =\r\n (clonedGantt.taskListTableInstance.getAllColsWidth() + clonedGantt.getAllDateColsWidth()) * scale;\r\n const totalHeight = clonedGantt.getAllRowsHeight() * scale;\r\n\r\n const exportCanvas = document.createElement('canvas');\r\n exportCanvas.width = totalWidth;\r\n exportCanvas.height = totalHeight;\r\n const ctx = exportCanvas.getContext('2d')!;\r\n\r\n ctx.fillStyle = backgroundColor;\r\n ctx.fillRect(0, 0, totalWidth, totalHeight);\r\n\r\n if (clonedGantt.taskListTableInstance?.canvas) {\r\n ctx.drawImage(\r\n clonedGantt.taskListTableInstance.canvas,\r\n 0,\r\n 0,\r\n clonedGantt.taskListTableInstance.getAllColsWidth() * scale,\r\n totalHeight\r\n );\r\n }\r\n\r\n const splitLineWidth = 3 * scale;\r\n const splitLineX = clonedGantt.taskListTableInstance.getAllColsWidth() * scale;\r\n ctx.fillStyle = 'rgb(225, 228, 232)';\r\n ctx.fillRect(splitLineX - splitLineWidth / 2, 0, splitLineWidth, totalHeight);\r\n\r\n const sourceX = 4 * scale;\r\n const sourceWidth = clonedGantt.canvas.width - sourceX;\r\n\r\n if (clonedGantt.canvas) {\r\n ctx.drawImage(\r\n clonedGantt.canvas,\r\n sourceX,\r\n 0,\r\n sourceWidth,\r\n clonedGantt.canvas.height,\r\n (clonedGantt.taskListTableInstance.getAllColsWidth() + 1.5) * scale,\r\n 0,\r\n (clonedGantt.getAllDateColsWidth() - 1.5) * scale,\r\n totalHeight\r\n );\r\n }\r\n\r\n return this.finalizeExport(exportCanvas, fileName, type, quality, download);\r\n } finally {\r\n tempContainer.remove();\r\n // 确保克隆的甘特图实例被释放\r\n clonedGantt.release();\r\n }\r\n } catch (error) {\r\n console.error('[Gantt Export Plugin] Export failed:', error);\r\n throw new Error(`甘特图导出失败: ${error instanceof Error ? error.message : '未知错误'}`);\r\n }\r\n }\r\n\r\n /**\r\n * 获取甘特图的 Base64 图片数据,不触发下载\r\n * @async\r\n * @param {Omit<ExportOptions, 'download'>} [options={}] 导出配置选项(不包含 download 参数)\r\n * @returns {Promise<string | undefined>} 返回 Base64 格式的图片数据,或在未初始化时返回 undefined\r\n * @throws {Error} 导出过程中发生错误时抛出异常\r\n */\r\n async exportToBase64(options: Omit<ExportOptions, 'download'> = {}): Promise<string | undefined> {\r\n // 调用 exportToImage 方法,但设置 download 为 false\r\n return this.exportToImage({\r\n ...options,\r\n download: false\r\n });\r\n }\r\n\r\n private createFullSizeContainer(scale: number) {\r\n if (!this._gantt) {\r\n // 保留这个 error\r\n throw new Error('ExportGanttPlugin: Gantt instance not available to create container.');\r\n }\r\n\r\n const tempContainer = document.createElement('div');\r\n tempContainer.style.position = 'fixed';\r\n tempContainer.style.left = '-9999px';\r\n tempContainer.style.overflow = 'hidden';\r\n tempContainer.style.width = `${window.innerWidth + 100}px`;\r\n tempContainer.style.height = `${window.innerHeight + 100}px`;\r\n document.body.appendChild(tempContainer);\r\n\r\n const clonedContainer = document.createElement('div');\r\n\r\n const totalWidth = this._gantt.taskListTableInstance.getAllColsWidth() + this._gantt.getAllDateColsWidth();\r\n const totalHeight = this._gantt.getAllRowsHeight();\r\n\r\n clonedContainer.style.width = `${totalWidth}px`;\r\n clonedContainer.style.height = `${totalHeight}px`;\r\n tempContainer.appendChild(clonedContainer);\r\n\r\n const clonedGantt = new VTableGantt.Gantt(clonedContainer, {\r\n ...this._gantt.options,\r\n records: JSON.parse(JSON.stringify(this._gantt.records)),\r\n taskListTable: {\r\n ...this._gantt.options.taskListTable,\r\n tableWidth: undefined as unknown as number,\r\n minTableWidth: undefined as unknown as number,\r\n maxTableWidth: undefined as unknown as number\r\n },\r\n plugins: []\r\n });\r\n\r\n clonedGantt.setPixelRatio(scale);\r\n\r\n // 禁用裁剪\r\n if ((clonedGantt as any).scenegraph?.ganttGroup) {\r\n (clonedGantt as any).scenegraph.ganttGroup.setAttribute('clip', false);\r\n }\r\n if ((clonedGantt.taskListTableInstance as any)?.scenegraph?.tableGroup) {\r\n (clonedGantt.taskListTableInstance as any).scenegraph.tableGroup.setAttribute('clip', false);\r\n }\r\n\r\n clonedGantt.scenegraph.stage.render();\r\n\r\n return { tempContainer, clonedGantt };\r\n }\r\n private finalizeExport(\r\n canvas: HTMLCanvasElement,\r\n fileName: string,\r\n type: string,\r\n quality: number,\r\n download: boolean = true\r\n ): string {\r\n const base64 = canvas.toDataURL(`image/${type}`, quality);\r\n\r\n // 如果需要下载,则创建下载链接\r\n if (download) {\r\n const link = document.createElement('a');\r\n link.download = `${fileName}.${type}`;\r\n link.href = base64;\r\n document.body.appendChild(link);\r\n link.click();\r\n document.body.removeChild(link);\r\n }\r\n\r\n return base64;\r\n }\r\n\r\n release(): void {\r\n this._gantt = null;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"sources":["gantt-export-image.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,WAAW,MAAM,wBAAwB,CAAC;AAgBtD,MAAM,OAAO,iBAAiB;IAA9B;QACE,OAAE,GAAG,qBAAqB,CAAC;QAC3B,SAAI,GAAG,qBAAqB,CAAC;QACrB,WAAM,GAA6B,IAAI,CAAC;IAyLlD,CAAC;IAtLC,GAAG,CAAC,GAAG,IAAW;QAChB,MAAM,aAAa,GAAG,IAAI,CAAC,CAAC,CAAsB,CAAC;QACnD,IAAI,CAAC,aAAa,EAAE;YAClB,OAAO,CAAC,KAAK,CAAC,+DAA+D,CAAC,CAAC;YAC/E,OAAO;SACR;QACD,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC;IAC9B,CAAC;IAQK,aAAa,CAAC,UAAyB,EAAE;;;YAC7C,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;gBAEhB,OAAO,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;gBAClE,OAAO,SAAS,CAAC;aAClB;YAED,MAAM,EACJ,QAAQ,GAAG,cAAc,EACzB,IAAI,GAAG,KAAK,EACZ,OAAO,GAAG,CAAC,EACX,eAAe,GAAG,SAAS,EAC3B,KAAK,GAAG,MAAM,CAAC,gBAAgB,IAAI,CAAC,EACpC,QAAQ,GAAG,IAAI,EAChB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特图导出配置项接口\r\nexport interface ExportOptions {\r\n fileName?: string;\r\n type?: 'png' | 'jpeg';\r\n quality?: number;\r\n backgroundColor?: string;\r\n scale?: number;\r\n download?: boolean;\r\n}\r\n\r\n/**\r\n * 甘特图导出插件\r\n * @description 提供完整的甘特图导出功能,支持高分辨率输出和精准布局保留\r\n */\r\nexport class ExportGanttPlugin implements VTableGantt.plugins.IGanttPlugin {\r\n id = 'gantt-export-helper';\r\n name = 'Gantt Export Helper';\r\n private _gantt: VTableGantt.Gantt | null = null;\r\n\r\n // run 方法,在插件初始化时由 PluginManager调用\r\n run(...args: any[]): void {\r\n const ganttInstance = args[0] as VTableGantt.Gantt;\r\n if (!ganttInstance) {\r\n console.error('ExportGanttPlugin: Gantt instance not provided to run method.');\r\n return;\r\n }\r\n this._gantt = ganttInstance;\r\n }\r\n /**\r\n * 执行甘特图导出操作\r\n * @async\r\n * @param {ExportOptions} [options={}] 导出配置选项\r\n * @returns {Promise<string | undefined>} 返回Base64格式的图片数据,或在未初始化时返回 undefined\r\n * @throws {Error} 导出过程中发生错误时抛出异常\r\n */\r\n async exportToImage(options: ExportOptions = {}): Promise<string | undefined> {\r\n if (!this._gantt) {\r\n // 保留这个 error\r\n console.error('ExportGanttPlugin: Gantt instance not available.');\r\n return undefined;\r\n }\r\n\r\n const {\r\n fileName = 'gantt-export',\r\n type = 'png',\r\n quality = 1,\r\n backgroundColor = '#ffffff',\r\n scale = window.devicePixelRatio || 1,\r\n download = true // 默认执行下载\r\n } = options;\r\n\r\n try {\r\n const { tempContainer, clonedGantt } = this.createFullSizeContainer(scale);\r\n\r\n try {\r\n await new Promise(resolve => requestAnimationFrame(resolve));\r\n\r\n const totalWidth =\r\n (clonedGantt.taskListTableInstance.getAllColsWidth() + clonedGantt.getAllDateColsWidth()) * scale;\r\n const totalHeight = clonedGantt.getAllRowsHeight() * scale;\r\n\r\n const exportCanvas = document.createElement('canvas');\r\n exportCanvas.width = totalWidth;\r\n exportCanvas.height = totalHeight;\r\n const ctx = exportCanvas.getContext('2d')!;\r\n\r\n ctx.fillStyle = backgroundColor;\r\n ctx.fillRect(0, 0, totalWidth, totalHeight);\r\n\r\n if (clonedGantt.taskListTableInstance?.canvas) {\r\n ctx.drawImage(\r\n clonedGantt.taskListTableInstance.canvas,\r\n 0,\r\n 0,\r\n clonedGantt.taskListTableInstance.getAllColsWidth() * scale,\r\n totalHeight\r\n );\r\n }\r\n\r\n const splitLineWidth = 3 * scale;\r\n const splitLineX = clonedGantt.taskListTableInstance.getAllColsWidth() * scale;\r\n ctx.fillStyle = 'rgb(225, 228, 232)';\r\n ctx.fillRect(splitLineX - splitLineWidth / 2, 0, splitLineWidth, totalHeight);\r\n\r\n const sourceX = 4 * scale;\r\n const sourceWidth = clonedGantt.canvas.width - sourceX;\r\n\r\n if (clonedGantt.canvas) {\r\n ctx.drawImage(\r\n clonedGantt.canvas,\r\n sourceX,\r\n 0,\r\n sourceWidth,\r\n clonedGantt.canvas.height,\r\n (clonedGantt.taskListTableInstance.getAllColsWidth() + 1.5) * scale,\r\n 0,\r\n (clonedGantt.getAllDateColsWidth() - 1.5) * scale,\r\n totalHeight\r\n );\r\n }\r\n\r\n return this.finalizeExport(exportCanvas, fileName, type, quality, download);\r\n } finally {\r\n tempContainer.remove();\r\n // 确保克隆的甘特图实例被释放\r\n clonedGantt.release();\r\n }\r\n } catch (error) {\r\n console.error('[Gantt Export Plugin] Export failed:', error);\r\n throw new Error(`甘特图导出失败: ${error instanceof Error ? error.message : '未知错误'}`);\r\n }\r\n }\r\n\r\n /**\r\n * 获取甘特图的 Base64 图片数据,不触发下载\r\n * @async\r\n * @param {Omit<ExportOptions, 'download'>} [options={}] 导出配置选项(不包含 download 参数)\r\n * @returns {Promise<string | undefined>} 返回 Base64 格式的图片数据,或在未初始化时返回 undefined\r\n * @throws {Error} 导出过程中发生错误时抛出异常\r\n */\r\n async exportToBase64(options: Omit<ExportOptions, 'download'> = {}): Promise<string | undefined> {\r\n // 调用 exportToImage 方法,但设置 download 为 false\r\n return this.exportToImage({\r\n ...options,\r\n download: false\r\n });\r\n }\r\n\r\n private createFullSizeContainer(scale: number) {\r\n if (!this._gantt) {\r\n // 保留这个 error\r\n throw new Error('ExportGanttPlugin: Gantt instance not available to create container.');\r\n }\r\n\r\n const tempContainer = document.createElement('div');\r\n tempContainer.style.position = 'fixed';\r\n tempContainer.style.left = '-9999px';\r\n tempContainer.style.overflow = 'hidden';\r\n tempContainer.style.width = `${window.innerWidth + 100}px`;\r\n tempContainer.style.height = `${window.innerHeight + 100}px`;\r\n document.body.appendChild(tempContainer);\r\n\r\n const clonedContainer = document.createElement('div');\r\n\r\n const totalWidth = this._gantt.taskListTableInstance.getAllColsWidth() + this._gantt.getAllDateColsWidth();\r\n const totalHeight = this._gantt.getAllRowsHeight();\r\n\r\n clonedContainer.style.width = `${totalWidth}px`;\r\n clonedContainer.style.height = `${totalHeight}px`;\r\n tempContainer.appendChild(clonedContainer);\r\n\r\n const clonedGantt = new VTableGantt.Gantt(clonedContainer, {\r\n ...this._gantt.options,\r\n records: this._gantt.records,\r\n taskListTable: {\r\n ...this._gantt.options.taskListTable,\r\n tableWidth: undefined as unknown as number,\r\n minTableWidth: undefined as unknown as number,\r\n maxTableWidth: undefined as unknown as number\r\n },\r\n plugins: []\r\n });\r\n\r\n clonedGantt.setPixelRatio(scale);\r\n\r\n // 禁用裁剪\r\n if ((clonedGantt as any).scenegraph?.ganttGroup) {\r\n (clonedGantt as any).scenegraph.ganttGroup.setAttribute('clip', false);\r\n }\r\n if ((clonedGantt.taskListTableInstance as any)?.scenegraph?.tableGroup) {\r\n (clonedGantt.taskListTableInstance as any).scenegraph.tableGroup.setAttribute('clip', false);\r\n }\r\n\r\n clonedGantt.scenegraph.stage.render();\r\n\r\n return { tempContainer, clonedGantt };\r\n }\r\n private finalizeExport(\r\n canvas: HTMLCanvasElement,\r\n fileName: string,\r\n type: string,\r\n quality: number,\r\n download: boolean = true\r\n ): string {\r\n const base64 = canvas.toDataURL(`image/${type}`, quality);\r\n\r\n // 如果需要下载,则创建下载链接\r\n if (download) {\r\n const link = document.createElement('a');\r\n link.download = `${fileName}.${type}`;\r\n link.href = base64;\r\n document.body.appendChild(link);\r\n link.click();\r\n document.body.removeChild(link);\r\n }\r\n\r\n return base64;\r\n }\r\n\r\n release(): void {\r\n this._gantt = null;\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visactor/vtable-plugins",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.4-alpha.0",
|
|
4
4
|
"description": "The search util of VTable",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "VisActor",
|
|
@@ -36,9 +36,12 @@
|
|
|
36
36
|
"exceljs": "4.4.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@visactor/vtable": "1.19.
|
|
39
|
+
"@visactor/vtable": "1.19.4-alpha.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
+
"@visactor/vtable": "1.19.4-alpha.0",
|
|
43
|
+
"@visactor/vtable-editors": "1.19.4-alpha.0",
|
|
44
|
+
"@visactor/vtable-gantt": "1.19.4-alpha.0",
|
|
42
45
|
"@visactor/vchart": "2.0.0-alpha.1",
|
|
43
46
|
"@rushstack/eslint-patch": "~1.1.4",
|
|
44
47
|
"react": "^18.0.0",
|
|
@@ -81,12 +84,9 @@
|
|
|
81
84
|
"@types/react-is": "^17.0.3",
|
|
82
85
|
"rollup-plugin-node-resolve": "5.2.0",
|
|
83
86
|
"@types/lodash": "4.14.182",
|
|
84
|
-
"@visactor/vtable-editors": "1.19.3",
|
|
85
87
|
"@internal/bundler": "0.0.1",
|
|
86
88
|
"@internal/ts-config": "0.0.1",
|
|
87
|
-
"@
|
|
88
|
-
"@internal/eslint-config": "0.0.1",
|
|
89
|
-
"@visactor/vtable-gantt": "1.19.3"
|
|
89
|
+
"@internal/eslint-config": "0.0.1"
|
|
90
90
|
},
|
|
91
91
|
"scripts": {
|
|
92
92
|
"demo": "vite ./demo",
|