e-virt-table 1.2.32 → 1.2.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +4 -4
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +324 -315
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +4 -4
- package/dist/index.umd.js.map +1 -1
- package/dist/lib/Autofill.js +6 -0
- package/dist/lib/Autofill.js.map +1 -1
- package/dist/lib/CellHeader.d.ts +1 -1
- package/dist/lib/CellHeader.js +3 -2
- package/dist/lib/CellHeader.js.map +1 -1
- package/dist/lib/Config.d.ts +0 -2
- package/dist/lib/Config.js +0 -7
- package/dist/lib/Config.js.map +1 -1
- package/dist/lib/Context.d.ts +4 -0
- package/dist/lib/Context.js +18 -0
- package/dist/lib/Context.js.map +1 -1
- package/dist/lib/Paint.js +12 -22
- package/dist/lib/Paint.js.map +1 -1
- package/dist/lib/Scroller.d.ts +10 -0
- package/dist/lib/Scroller.js +125 -0
- package/dist/lib/Scroller.js.map +1 -1
- package/dist/lib/Selector.d.ts +0 -10
- package/dist/lib/Selector.js +27 -133
- package/dist/lib/Selector.js.map +1 -1
- package/dist/lib/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(":root{--evt-header-font: 12px normal Arial;--evt-body-font: 12px normal Arial;--evt-color-white: #fff;--evt-color-black: #000000;--evt-color-primary: rgb(82, 146, 247);--evt-text-color-primary: #333;--evt-text-color-regular: #666;--evt-text-color-secondary: #999;--evt-box-shadow: 0 2px 12px 0 #0000001a;--evt-editor-bg-color: #fff;--evt-editor-text-color: #333;--evt-border-color: #e1e6eb;--evt-stripe-color: #fafafa;--evt-placeholder-color: #cdd0dc;--evt-header-bg-color: #f8faff;--evt-body-bg-color: #fff;--evt-header-text-color: #1d2129;--evt-body-text-color: #4e5969;--evt-footer-text-color: #4e5969;--evt-loading-icon-color: #4e5969;--evt-expand-icon-color: #4e5969;--evt-shrink-icon-color: #4e5969;--evt-error-tip-icon-color: red;--evt-required-color: #F56C6C;--evt-cell-hover-icon-bg-color: #fff;--evt-cell-hover-icon-border-color: #dde0ea;--evt-scroller-color: #dee0e3;--evt-scroller-track-color: #fff;--evt-scroller-focus-color: #bbbec4;--evt-select-border-color: var(--evt-color-primary);--evt-select-area-color: rgba(82, 146, 247, .1);--evt-select-row-col-bg-color: transparent;--evt-autofill-point-border-color: #fff;--evt-edit-bg-color: #fcf6ed;--evt-checkbox-color: var(--evt-color-primary);--evt-checkbox-uncheck-color: #dde0ea;--evt-checkbox-disabled-color: #f1f2f4;--evt-checkbox-check-disabled-color: #dde0ea;--evt-icon-edit-color: #4e5969;--evt-icon-select-color: #4e5969;--evt-readonly-color: #fff;--evt-readonly-text-color: var(--evt-body-text-color);--evt-error-tip-color: #ed3f14;--evt-footer-bg-color: #fafafa;--evt-highlight-hover-row-color: rgba(186, 203, 231, .1);--evt-highlight-selected-row-color: rgba(82, 146, 247, .1);--evt-tooltip-bg-color: #303133;--evt-tooltip-text-color: #fff;--evt-resize-row-line-color: #e1e6eb;--evt-resize-column-line-color: #e1e6eb;--evt-tree-line-color: #e1e6eb;--evt-sort-icon-color: rgb(82, 146, 247)}.dark{--evt-border-color: #363637;--evt-header-bg-color: #141414;--evt-body-bg-color: #141414;--evt-header-text-color: #a3a6ad;--evt-scroller-color: #414243;--evt-scroller-track-color: #141414;--evt-scroller-focus-color: #a3a6ad;--evt-edit-bg-color: #141414;--evt-readonly-text-color: #cfd3dc;--evt-footer-bg-color: #262727;--evt-autofill-point-border-color: #fff;--evt-editor-bg-color: #434343;--evt-editor-text-color: #cfd3dc}.e-virt-table-container{position:relative;outline:none}.e-virt-table-stage{position:relative;overflow:hidden;outline:none;box-sizing:border-box;z-index:10;border-radius:8px;border:1px solid var(--evt-border-color)}.e-virt-table-canvas{position:absolute;left:0;top:0;box-sizing:border-box;border:none;outline:none;z-index:10}.e-virt-table-editor{position:absolute;top:-10000px;left:-10000px;text-align:left;height:auto;line-height:0;z-index:100;overflow:hidden;background-color:var(--evt-editor-bg-color);border:2px solid var(--evt-color-primary);box-sizing:border-box;box-shadow:var(--evt-box-shadow);display:flex;align-items:center}.e-virt-table-overlayer{position:absolute;left:0;top:0;overflow:hidden;z-index:100;pointer-events:none}.e-virt-table-editor-textarea{width:100%;box-sizing:border-box;outline:none;font-weight:400;padding:8px;font-size:12px;color:inherit;white-space:pre-wrap;word-wrap:break-word;word-break:break-all;line-height:1.5;margin:0;border:none;vertical-align:middle;background:var(--evt-editor-bg-color);color:var(--evt-editor-text-color);overflow-y:auto;resize:none}.e-virt-table-context-menu{position:absolute;font-size:14px;color:var(--evt-text-color-regular);background-color:var(--evt-color-white);border-radius:4px;border:1px solid #e4e7ed;box-shadow:var(--evt-box-shadow);width:fit-content;padding:6px 0;z-index:9999;left:-99999px;top:-99999px}.e-virt-table-context-menu-item{cursor:pointer;padding:8px 24px;color:var(--evt-text-color-regular)}.e-virt-table-context-menu-item:hover{color:var(--evt-color-primary);background-color:#f5f7fa}.e-virt-table-loading{display:none;position:absolute;left:0;top:0;right:0;bottom:0;width:100%;height:100%;z-index:2000;background-color:#fff6;display:flex;align-items:center;justify-content:center}.e-virt-table-loading-spinner{opacity:1;display:flex;flex-direction:column;align-items:center;justify-content:center}.e-virt-table-loading-spinner svg{color:var(--evt-text-color-regular);animation:rotate 1s linear infinite}@keyframes rotate{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.e-virt-table-loading-text{margin:0;font-size:12px;color:var(--evt-text-color-regular)}")),document.head.appendChild(e)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
|
|
2
|
-
"use strict";var oe=Object.defineProperty;var re=(c,t,e)=>t in c?oe(c,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):c[t]=e;var n=(c,t,e)=>re(c,typeof t!="symbol"?t+"":t,e);class ne{constructor(t){n(this,"rules");this.rules=t}validate(t){const e=[],{column:i,row:s,key:o,rowKey:r,colIndex:a,rowIndex:l,value:h,field:d,fieldValue:f}=t;Array.isArray(this.rules)||(this.rules=[this.rules]);for(const u of this.rules){if(u.validator){const x={field:d,fieldValue:f,value:h,column:i,colIndex:a,rowIndex:l,row:s,key:o,rowKey:r,...u};u.validator(x,h,w=>{w&&e.push({...x,message:w})})}if(!u.required&&(h==null||h===""))return e;u.pattern&&!u.pattern.test(h)&&e.push({value:h,column:i,row:s,key:o,rowKey:r,colIndex:a,rowIndex:l,field:d,fieldValue:f,message:u.message||`${o} is pattern validation error`}),u.required&&(h==null||h==="")&&e.push({value:h,column:i,row:s,key:o,rowKey:r,colIndex:a,rowIndex:l,field:d,fieldValue:f,message:u.message||`${o} is required`})}return e}}function Dt(){return"xxxxxxxxxxxxxxxxxx".replace(/[x]/g,function(c){const t=Math.random()*16|0;return(c==="x"?t:t&3|8).toString(16)})}function
|
|
2
|
+
"use strict";var oe=Object.defineProperty;var re=(c,t,e)=>t in c?oe(c,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):c[t]=e;var n=(c,t,e)=>re(c,typeof t!="symbol"?t+"":t,e);class ne{constructor(t){n(this,"rules");this.rules=t}validate(t){const e=[],{column:i,row:s,key:o,rowKey:r,colIndex:a,rowIndex:l,value:h,field:d,fieldValue:f}=t;Array.isArray(this.rules)||(this.rules=[this.rules]);for(const u of this.rules){if(u.validator){const x={field:d,fieldValue:f,value:h,column:i,colIndex:a,rowIndex:l,row:s,key:o,rowKey:r,...u};u.validator(x,h,w=>{w&&e.push({...x,message:w})})}if(!u.required&&(h==null||h===""))return e;u.pattern&&!u.pattern.test(h)&&e.push({value:h,column:i,row:s,key:o,rowKey:r,colIndex:a,rowIndex:l,field:d,fieldValue:f,message:u.message||`${o} is pattern validation error`}),u.required&&(h==null||h==="")&&e.push({value:h,column:i,row:s,key:o,rowKey:r,colIndex:a,rowIndex:l,field:d,fieldValue:f,message:u.message||`${o} is required`})}return e}}function Dt(){return"xxxxxxxxxxxxxxxxxx".replace(/[x]/g,function(c){const t=Math.random()*16|0;return(c==="x"?t:t&3|8).toString(16)})}function Z(c,t){let e=0,i;return function(...s){const o=new Date().getTime(),r=o-e,a=typeof t=="function"?t():t;!e||r>=a?(c.apply(this,s),e=o):i||(i=setTimeout(()=>{c.apply(this,s),e=new Date().getTime(),i=void 0},a-r))}}function Nt(c=[]){return c.length?c.map(t=>Nt(t.children)+1).sort((t,e)=>e-t)[0]:0}function ae(c=[]){let t=[],e=[],i=[];return c.forEach(s=>{s.fixed==="left"?t.push(s):s.fixed==="right"?i.push(s):e.push(s)}),[...t.sort((s,o)=>(s.sort??0)-(o.sort??0)),...e.sort((s,o)=>(s.sort??0)-(o.sort??0)),...i.sort((s,o)=>(s.sort??0)-(o.sort??0))]}function kt(c=[],t=1,e=0){return c.map(i=>{if(i.children){let s=0,o=i.fixed;i.children.forEach(a=>{a.fixed=o});const r=kt(i.children,t-1,e+1);return r&&r.forEach(a=>{s+=a.colspan??0}),{...i,width:i.width,level:e,rowspan:1,colspan:s,children:r}}return{...i,level:e,rowspan:t,colspan:1}})}function it(c=[]){let t=[];return c.forEach(e=>{e.children?t=t.concat(it(e.children)):t.push(e)}),t}const Ct=/^(\r\n|\n\r|\r|\n)/,le=/^[^\t\r\n]+/,bt=/^\t/;function he(c){let t=[[""]];if(c.length===0)return t;let e=0,i=0,s;for(;c.length>0&&s!==c.length;)if(s=c.length,c.match(bt))c=c.replace(bt,""),e+=1,t[i][e]="";else if(c.match(Ct))c=c.replace(Ct,""),e=0,i+=1,t[i]=[""];else{let o="";if(c.startsWith('"')){let r=0,a=!0;for(;a;){const l=c.slice(0,1);l==='"'&&(r+=1),o+=l,c=c.slice(1),(c.length===0||c.match(/^[\t\r\n]/)&&r%2===0)&&(a=!1)}o=o.replace(/^"/,"").replace(/"$/,"").replace(/["]*/g,l=>new Array(Math.floor(l.length/2)).fill('"').join(""))}else{const r=c.match(le);o=r?r[0]:"",c=c.slice(o.length)}t[i][e]=o}return Array.isArray(t)&&t.length>1&&t[t.length-1].length===1&&t[t.length-1][0]===""&&(t=t.slice(0,t.length-1)),t}function ce(c){let t,e,i,s,o="",r;for(t=0,e=c.length;t<e;t+=1){for(s=c[t].length,i=0;i<s;i+=1)i>0&&(o+=" "),r=c[t][i],typeof r=="string"?r.indexOf(`
|
|
3
3
|
`)>-1?o+=`"${r.replace(/"/g,'""')}"`:o+=r:r==null?o+="":o+=r;t!==e-1&&(o+=`
|
|
4
|
-
`)}return o}function Xt(c,t,e=[]){let i=0;const s=[];return c.forEach((o,r)=>{if(r===0)s.push(1);else{const a=e.reduce((h,d)=>`${h}${o[d]??""}`,"")||o[t],l=e.reduce((h,d)=>`${h}${c[r-1][d]??""}`,"")||c[r-1][t];a===l?(s[i]+=1,s.push(0)):(s.push(1),i=r)}}),s}function Yt(c,t){let e="",i="";const s={};return t.forEach((o,r)=>{r===0?(e=o.key,i=o.key,s[o.key]=1):c[o.key]===c[e]?(s[o.key]=0,s[i]+=1):(s[o.key]=1,e=o.key,i=o.key)}),s}function de(c,t,e=[]){const{visibleRows:i,rowIndex:s,headIndex:o}=c,r=Xt(i,t,e);return r[s-o]===0?{rowspan:0,colspan:0,relationRowKeys:e,mergeRow:!0}:{rowspan:r[s-o],colspan:1,relationRowKeys:e,mergeRow:!0}}function fe(c,t=[]){const{column:e,row:i,visibleLeafColumns:s}=c,o=s.filter(r=>t.includes(r.key));if(t.includes(e.key)){const r=Yt(i,o);return r[e.key]===0?{rowspan:0,colspan:0,relationColKeys:t,mergeCol:!0}:{rowspan:1,colspan:r[e.key],relationColKeys:t,mergeCol:!0}}}function xe(c,t=document.documentElement){const e=c.startsWith("--")?c:`--${c}`;return getComputedStyle(t).getPropertyValue(e).trim()}function Rt(c){if(!c)return new Date(0);if(typeof c=="number")return new Date(c);const t=String(c).trim(),e=new Date(t);if(!isNaN(e.getTime()))return e;const i=[/^(\d{4})-(\d{1,2})-(\d{1,2})$/,/^(\d{4})\/(\d{1,2})\/(\d{1,2})$/,/^(\d{4})\.(\d{1,2})\.(\d{1,2})$/,/^(\d{1,2})-(\d{1,2})-(\d{4})$/,/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/,/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/,/^(\d{1,2})-(\d{1,2})-(\d{4})$/,/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/,/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/,/^(\d{4})(\d{2})(\d{2})$/,/^(\d{4})-(\d{1,2})-(\d{1,2})\s+(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?$/,/^(\d{4})\/(\d{1,2})\/(\d{1,2})\s+(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?$/];for(const s of i){const o=t.match(s);if(o){const r=o.slice(1).map(Number);if(s.source.includes("YYYY-MM-DD")||s.source.includes("YYYY/MM/DD")||s.source.includes("YYYY.MM.DD")){const[a,l,h,d=0,f=0,u=0]=r;return new Date(a,l-1,h,d,f,u)}else if(s.source.includes("DD-MM-YYYY")||s.source.includes("DD/MM/YYYY")||s.source.includes("DD.MM.YYYY")){const[a,l,h,d=0,f=0,u=0]=r;return new Date(h,l-1,a,d,f,u)}else if(s.source.includes("MM-DD-YYYY")||s.source.includes("MM/DD/YYYY")||s.source.includes("MM.DD.YYYY")){const[a,l,h,d=0,f=0,u=0]=r;return new Date(h,a-1,l,d,f,u)}else if(s.source.includes("YYYYMMDD")){const[a,l,h]=r;return new Date(a,l-1,h)}}}return new Date(NaN)}function ue(c,t){const e=Rt(c),i=Rt(t);return isNaN(e.getTime())&&isNaN(i.getTime())?0:isNaN(e.getTime())?-1:isNaN(i.getTime())?1:e.getTime()-i.getTime()}class Bt{constructor(t,e,i,s,o,r,a){n(this,"ctx");n(this,"x",0);n(this,"y",0);n(this,"width",0);n(this,"height",0);n(this,"fixed");n(this,"cellType");this.ctx=t,this.x=e,this.y=i,this.width=s,this.height=o,this.fixed=a,this.cellType=r}isHorizontalVisible(){if(this.fixed)return!0;const{stageWidth:t,fixedLeftWidth:e,scrollX:i,fixedRightWidth:s}=this.ctx,o=t;return!(this.x+this.width-e-i<=0||this.x-i>=o-s)}isVerticalVisible(){const{stageHeight:t,scrollY:e}=this.ctx,i=t;return!(this.y+this.height-e<=0||this.y-e>=i)}getDrawX(){if(this.fixed==="left")return this.x;if(this.fixed==="right"){const{stageWidth:t,config:{SCROLLER_TRACK_SIZE:e}}=this.ctx;return t-(this.ctx.header.width-this.x)-e}return this.x-this.ctx.scrollX}getDrawY(){return this.cellType==="header"?this.y:this.cellType==="footer"&&this.ctx.config.FOOTER_FIXED?this.y:this.y-this.ctx.scrollY}getLeftFixedX(){return this.x-this.ctx.scrollX}getRightFixedX(){}}class ut extends Bt{constructor(e,i,s,o,r,a,l,h,d,f="body"){super(e,o,r,a,l,f,h.fixed);n(this,"formatter");n(this,"formatterFooter");n(this,"hoverIconName","");n(this,"operation",!1);n(this,"align");n(this,"verticalAlign");n(this,"fixed");n(this,"type");n(this,"editorType");n(this,"editorProps");n(this,"cellType");n(this,"level");n(this,"colspan",1);n(this,"rowspan",1);n(this,"mergeRow",!1);n(this,"mergeCol",!1);n(this,"relationRowKeys",[]);n(this,"relationColKeys",[]);n(this,"key");n(this,"column");n(this,"rowIndex");n(this,"colIndex");n(this,"rowKey");n(this,"row");n(this,"value");n(this,"render");n(this,"renderFooter");n(this,"style",{});n(this,"domDataset",{});n(this,"rules",[]);n(this,"message","");n(this,"text","");n(this,"displayText","");n(this,"visibleWidth",0);n(this,"visibleHeight",0);n(this,"isHasChanged",!1);n(this,"drawX",0);n(this,"drawY",0);n(this,"drawCellBgColor","");n(this,"drawCellSkyBgColor","");n(this,"drawTextColor","");n(this,"drawTextX",0);n(this,"drawTextY",0);n(this,"drawTextWidth",0);n(this,"drawTextHeight",0);n(this,"drawTreeImageX",0);n(this,"drawTreeImageY",0);n(this,"drawTreeImageWidth",0);n(this,"drawTreeImageHeight",0);n(this,"drawTreeImageName","");n(this,"drawTreeImageSource");n(this,"drawSelectionImageX",0);n(this,"drawSelectionImageY",0);n(this,"drawSelectionImageWidth",0);n(this,"drawSelectionImageHeight",0);n(this,"drawSelectionImageName","");n(this,"drawSelectionImageSource");n(this,"drawHoverImageX",0);n(this,"drawHoverImageY",0);n(this,"drawHoverImageWidth",0);n(this,"drawHoverImageHeight",0);n(this,"drawHoverImageName","");n(this,"drawHoverImageSource");n(this,"autoRowHeight",!1);n(this,"calculatedHeight",0);n(this,"ellipsis",!1);n(this,"rowExpand",!1);n(this,"rowHasChildren",!1);n(this,"overflowTooltipShow",!0);n(this,"selectorCellValueType","value");n(this,"overflowTooltipMaxWidth",500);n(this,"overflowTooltipPlacement","top");n(this,"maxLineClamp","auto");this.visibleWidth=this.width,this.visibleHeight=this.height,this.colIndex=s,this.rowIndex=i,this.key=h.key,this.type=h.type||"",this.editorType=h.editorType||"text",this.selectorCellValueType=h.selectorCellValueType||this.ctx.config.SELECTOR_CELL_VALUE_TYPE||"value",this.editorProps=h.editorProps||{},this.cellType=f,this.align=h.align||this.ctx.config.COLUMNS_ALIGN,this.verticalAlign=h.verticalAlign||this.ctx.config.COLUMNS_VERTICAL_ALIGN,this.fixed=h.fixed,this.level=h.level||0,this.operation=h.operation||!1,this.column=h,this.rules=h.rules||[],this.row=d,this.rowKey=this.cellType==="body"?this.ctx.database.getRowKeyForRowIndex(i):`${this.cellType}_${this.rowIndex}`,this.value=this.getValue(),this.render=h.render,this.overflowTooltipShow=h.overflowTooltipShow!==!1,this.autoRowHeight=h.autoRowHeight!==void 0?h.autoRowHeight:this.ctx.config.AUTO_ROW_HEIGHT,this.overflowTooltipMaxWidth=h.overflowTooltipMaxWidth||500,this.overflowTooltipPlacement=h.overflowTooltipPlacement||"top",this.renderFooter=h.renderFooter,this.hoverIconName=h.hoverIconName,this.formatter=h.formatter,this.formatterFooter=h.formatterFooter,this.maxLineClamp=h.maxLineClamp||"auto",this.update()}setWidthHeight(e,i){this.width=e,this.height=i}getValidationMessage(){const e=this.ctx.database.getValidationError(this.rowKey,this.key);if(Array.isArray(e)&&e.length){const[i]=e;this.message=i.message||""}return this.message}update(){this.drawX=this.getDrawX(),this.drawY=this.getDrawY(),this.drawTextX=this.drawX,this.drawTextY=this.drawY,this.isHasChanged=this.ctx.database.isHasChangedData(this.rowKey,this.key),this.updateSpan(),this.drawTextWidth=this.visibleWidth,this.drawTextHeight=this.visibleHeight,this.updateStyle(),this.updateType(),this.updateHoverIcon(),this.updateSelection(),this.updateTree(),this.updateEditor(),this.updateRender(),this.getValidationMessage(),this.updateContainer(),this.text=this.getText(),this.displayText=this.getDisplayText()}updateSpan(){if(this.cellType==="footer")return;const{SPAN_METHOD:e}=this.ctx.config;if(typeof e=="function"){const i=e,{colspan:s=1,rowspan:o=1,relationRowKeys:r,relationColKeys:a,mergeRow:l=!1,mergeCol:h=!1}=i({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue(),headIndex:this.ctx.body.headIndex,headPosition:this.ctx.database.getPositionForRowIndex(this.ctx.body.headIndex),visibleRows:this.ctx.body.visibleRows,visibleLeafColumns:this.ctx.header.visibleLeafColumns,rows:this.ctx.body.data})||{};Array.isArray(r)&&r.length>0?this.relationRowKeys=r:this.relationRowKeys=[this.key],Array.isArray(a)&&a.length>0?this.relationColKeys=a:this.relationColKeys=[this.key],this.mergeCol=h,this.mergeRow=l,this.colspan=s,this.rowspan=o,this.visibleWidth=this.getWidthByColIndexColSpan(this.colIndex,this.colspan),this.visibleHeight=this.ctx.database.getHeightByRowIndexRowSpan(this.rowIndex,this.rowspan)}}updateSpanInfo(){if(this.mergeRow||this.mergeCol){const e=this.getSpanInfo();this.height=e.height,this.width=e.width,this.drawX=this.getDrawX(),this.drawY=this.getDrawY(),this.drawY-=e.offsetTop,this.drawX-=e.offsetLeft}}updateType(){const{BODY_CELL_TYPE_METHOD:e}=this.ctx.config;if(typeof e=="function"){const s=e({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});s!==void 0&&(this.type=s)}}updateEditor(){const{BODY_CELL_EDITOR_METHOD:e}=this.ctx.config;if(typeof e=="function"){const s=e({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});if(s!==void 0){const{type:o,props:r={}}=s;this.editorType=o,this.editorProps=r}}}updateRender(){const{BODY_CELL_RENDER_METHOD:e}=this.ctx.config;if(typeof e=="function"){const s=e({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});s!==void 0&&(this.render=s)}}validate(){this.ctx.database.getValidator(this.rowKey,this.key).then(()=>{this.ctx.database.setValidationError(this.rowKey,this.key,[]),this.message=""}).catch(e=>{if(Array.isArray(e)&&e.length){const[i]=e;this.message=i.message,this.ctx.database.setValidationError(this.rowKey,this.key,e)}}).finally(()=>{this.ctx.emit("draw")})}updateStyle(){this.autoRowHeight&&(this.domDataset={"data-auto-height":!0,"data-row-index":this.rowIndex,"data-col-index":this.colIndex}),this.style=this.getOverlayerViewsStyle()}updateTree(){const{CELL_PADDING:e=0}=this.ctx.config,{rowKey:i,cellType:s}=this;let o,r=0,a="";if(!(["tree","selection-tree","tree-selection"].includes(this.type)&&s==="body"))return;const l=this.ctx.database.getRowForRowKey(i),{expand:h=!1,hasChildren:d=!1,expandLoading:f=!1,level:u=0}=l||{};this.rowExpand=h,this.rowHasChildren=d;const{TREE_INDENT:x=16,CHECKBOX_SIZE:w,TREE_ICON_SIZE:E}=this.ctx.config;if(r=u*x,f){const I=this.ctx.icons.get("loading");a="loading",o=I}else if(d){const I=this.ctx.icons.get("expand"),_=this.ctx.icons.get("shrink");o=h?_:I,a=h?"shrink":"expand"}let g=E,m=E,y=this.drawX;(this.align==="center"||this.align==="right")&&(y=this.drawX+(this.visibleWidth-g-2*e)/2,this.align="left");let p=y+r+e,R=this.drawY+(this.visibleHeight-m)/2,C=r+this.drawX+g-.5;this.type==="selection-tree"?(p=r+this.drawSelectionImageX+this.drawSelectionImageWidth,C=p+g-e/2):this.type==="tree-selection"?C=p+w+g-e/2:C=p+g-e/2,this.drawTextX=C,this.drawTextWidth=this.drawX+this.visibleWidth-C,!(p+g+e>this.drawX+this.visibleWidth)&&(R+m+e>this.drawY+this.visibleHeight||(this.drawTreeImageX=p,this.drawTreeImageY=R,this.drawTreeImageWidth=g,this.drawTreeImageHeight=m,o?(this.drawTreeImageName=a,this.drawTreeImageSource=o):(this.drawTreeImageName="",this.drawTreeImageSource=void 0)))}drawTreeLine(){const{TREE_LINE:e,TREE_INDENT:i=16,TREE_ICON_SIZE:s=16,TREE_LINE_COLOR:o="#e1e6eb"}=this.ctx.config;if(!e||this.cellType!=="body"||!["tree","selection-tree","tree-selection"].includes(this.type)||this.rowspan===0||this.colspan===0)return;const r=this.ctx.database.getRowForRowKey(this.rowKey)||{},a=r.level??0,l=this.drawTreeImageX+this.drawTreeImageWidth/2,h=this.drawTreeImageY+this.drawTreeImageHeight/2;let d=this.drawTreeImageX-a*i;const f=Array.isArray(r.parentRowKeys)?r.parentRowKeys:[];if(a>0){for(let g=0;g<a-1;g+=1){const m=f[g+1];if(!!(m?this.ctx.database.getRowForRowKey(m)||{}:{}).isLastChild)continue;const R=Math.round(this.drawTreeImageX-(a-g)*i+s/2);this.ctx.paint.drawLine([R,this.drawY,R,this.drawY+this.visibleHeight],{borderColor:o,borderWidth:1,lineDash:[4,4],lineDashOffset:0})}const u=Math.round(this.drawTreeImageX-i+s/2),w=!!r.isLastChild?h:this.drawY+this.visibleHeight;this.ctx.paint.drawLine([u,this.drawY,u,w],{borderColor:o,borderWidth:1,lineDash:[4,4],lineDashOffset:0});const E=Math.round(d+(a-1)*i+s/2);this.ctx.paint.drawLine([E,h,l,h],{borderColor:o,borderWidth:1,lineDash:[4,4],lineDashOffset:0})}if(r.hasChildren&&r.expand){const u=this.drawTreeImageY+this.drawTreeImageHeight,x=this.drawY+this.visibleHeight;this.ctx.paint.drawLine([l,u,l,x],{borderColor:o,borderWidth:1,lineDash:[4,4],lineDashOffset:0})}}updateContainer(){const{BODY_BG_COLOR:e,EDIT_BG_COLOR:i,BODY_CELL_STYLE_METHOD:s,FOOTER_CELL_STYLE_METHOD:o,READONLY_TEXT_COLOR:r,BODY_TEXT_COLOR:a,FOOTER_TEXT_COLOR:l,FOOTER_BG_COLOR:h,HIGHLIGHT_SELECTED_ROW:d,HIGHLIGHT_SELECTED_ROW_COLOR:f,HIGHLIGHT_HOVER_ROW:u,HIGHLIGHT_HOVER_ROW_COLOR:x,STRIPE:w,STRIPE_COLOR:E}=this.ctx.config;if(this.cellType==="footer"){let _=h,v=l;if(typeof o=="function"){const S=o,{backgroundColor:b,color:O}=S({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()})||{};b&&(_=b),O&&(v=O)}this.drawCellSkyBgColor="transparent",this.drawCellBgColor=_,this.drawTextColor=v;return}let g="transparent";const m=this.ctx.hoverCell,y=this.ctx.currentCell;let p=this.rowIndex,R=this.rowIndex;if(this.rowspan!==1&&(u||d)){const _=this.getSpanInfo(),{yArr:v}=_;p=v[0],R=v[1]}u&&m&&(m.rowKey===this.rowKey&&(g=x),m.rowIndex>=p&&m.rowIndex<=R&&(g=x)),d&&y&&(y.rowKey===this.rowKey&&(g=f),y.rowIndex>=p&&y.rowIndex<=R&&(g=f)),this.drawCellSkyBgColor=g;let C=e,I=a;if(this.ctx.database.getReadonly(this.rowKey,this.key)||(C=i,I=r),w&&(this.rowIndex%2?C=E:C=e),typeof s=="function"){const _=s,{backgroundColor:v,color:S}=_({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,isHasChanged:this.isHasChanged,value:this.getValue()})||{};v&&(C=v),S&&(I=S)}this.drawCellBgColor=C,this.drawTextColor=I}updateSelection(){const{visibleWidth:e,visibleHeight:i,rowspan:s,colspan:o,cellType:r,type:a,rowIndex:l,rowKey:h}=this;if(s===0||o===0||r==="footer"||!["index-selection","selection","selection-tree","tree-selection"].includes(a))return;const d=this.ctx.database.getRowSelectable(h),{CHECKBOX_SIZE:f=0,CELL_PADDING:u}=this.ctx.config;let x=this.drawX+u;(this.align==="center"||this.align==="right")&&(x=this.drawX+(e-f)/2);let w=x,E=this.drawY+(i-f)/2;if(a!=="selection-tree"){if(a==="tree-selection"){const{TREE_INDENT:y=16,TREE_ICON_SIZE:p}=this.ctx.config,R=this.ctx.database.getRowForRowKey(h),{level:C=0}=R||{},I=C*y;w=x+p+I}}let g=this.ctx.icons.get("checkbox-uncheck"),m="checkbox-uncheck";if(a==="selection-tree"||a==="tree-selection"){const y=this.ctx.database.getTreeSelectionState(h);y.indeterminate&&d?(g=this.ctx.icons.get("checkbox-indeterminate"),m="checkbox-indeterminate"):y.checked&&d?(g=this.ctx.icons.get("checkbox-check"),m="checkbox-check"):!y.checked&&d?(g=this.ctx.icons.get("checkbox-uncheck"),m="checkbox-uncheck"):(g=this.ctx.icons.get("checkbox-disabled"),m="checkbox-disabled")}else{const y=this.ctx.database.getRowSelection(h);y&&d?(g=this.ctx.icons.get("checkbox-check"),m="checkbox-check"):y&&!d?(g=this.ctx.icons.get("checkbox-check-disabled"),m="checkbox-check-disabled"):!y&&d?(g=this.ctx.icons.get("checkbox-uncheck"),m="checkbox-uncheck"):(g=this.ctx.icons.get("checkbox-disabled"),m="checkbox-disabled")}w+f+u>this.drawX+this.visibleWidth||E+f+u>this.drawY+this.visibleHeight||(a==="index-selection"?(this.ctx.hoverCell&&this.ctx.hoverCell.rowIndex===l||["checkbox-disabled","checkbox-check"].includes(m))&&(this.drawSelectionImageX=w,this.drawSelectionImageY=E,this.drawSelectionImageWidth=f,this.drawSelectionImageHeight=f,this.drawSelectionImageName=m,this.drawSelectionImageSource=g):(this.drawSelectionImageX=w,this.drawSelectionImageY=E,this.drawSelectionImageWidth=f,this.drawSelectionImageHeight=f,this.drawSelectionImageName=m,this.drawSelectionImageSource=g))}updateHoverIcon(){if(this.ctx.database.getReadonly(this.rowKey,this.key))return;const{BODY_CELL_HOVER_ICON_METHOD:i,CELL_HOVER_ICON_SIZE:s,CELL_PADDING:o,ENABLE_MERGE_CELL_LINK:r}=this.ctx.config;if(typeof i=="function"){const h=i({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});h!==void 0&&(this.hoverIconName=h)}const{hoverCell:a}=this.ctx;if(this.hoverIconName&&!this.ctx.editing&&a){let l=0,h=0;if(a.rowKey===this.rowKey&&(l=this.drawX+this.width-s-o,h=this.drawY+(this.height-s)/2),this.rowspan!==1&&r){const f=this.getSpanInfo(),{yArr:u}=f,x=u[0],w=u[1];if(a.rowIndex>=x&&a.rowIndex<=w){const{width:E,height:g,offsetTop:m,offsetLeft:y}=f;l=this.drawX-y+E-s-o,h=this.drawY-m+(g-s)/2}}const d=this.ctx.icons.get(this.hoverIconName);this.drawHoverImageX=l,this.drawHoverImageY=h,this.drawHoverImageWidth=s,this.drawHoverImageHeight=s,this.drawHoverImageName=this.hoverIconName,this.drawHoverImageSource=d}}getAutoHeight(){if(this.cellType!=="body"||!this.autoRowHeight||this.rowspan===0)return 0;if(this.render){const a=this.ctx.database.getOverlayerAutoHeight(this.rowIndex,this.colIndex);return this.rowspan>1?a<this.visibleHeight?0:Math.round(a-(this.visibleHeight-this.height)):Math.round(a)}if(!(this.displayText&&typeof this.displayText=="string"))return 0;const{BODY_FONT:e,CELL_PADDING:i,CELL_LINE_HEIGHT:s}=this.ctx.config,o=`${this.displayText}_${this.drawTextWidth}`,r=this.ctx.paint.calculateTextHeight(this.displayText,this.drawTextWidth,{font:e,padding:i,align:this.align,verticalAlign:this.verticalAlign,color:this.drawTextColor,autoRowHeight:this.autoRowHeight,lineHeight:s,maxLineClamp:this.maxLineClamp,cacheTextKey:o});return this.rowspan>1?r<this.visibleHeight?0:Math.round(r-(this.visibleHeight-this.height)):Math.round(r)}getSpanInfo(){return this.ctx.database.getSpanInfo(this)}getDisplayText(){return this.cellType==="footer"?this.renderFooter||this.text===null||this.text===void 0?"":this.text:this.rowspan===0||this.colspan===0||this.render||this.type==="index-selection"&&(this.ctx.hoverCell&&this.ctx.hoverCell.rowIndex===this.rowIndex||["checkbox-disabled","checkbox-check"].includes(this.drawSelectionImageName))||this.text===null||this.text===void 0?"":`${this.text}`}getText(){if(this.cellType==="footer")return typeof this.formatterFooter=="function"?this.formatterFooter({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.row[this.key]}):this.row[this.key];if(typeof this.formatter=="function")return this.formatter({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});const{BODY_CELL_FORMATTER_METHOD:e}=this.ctx.config;return typeof e=="function"?e({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()}):["index-selection","index"].includes(this.type)?`${this.rowIndex+1}`:(this.value=this.ctx.database.getItemValue(this.rowKey,this.key),this.value)}getValue(){return this.ctx.database.getItemValue(this.rowKey,this.key)}setValue(e){this.ctx.setItemValueByEditor(this.rowKey,this.key,e)}getOverlayerViewsStyle(){let e=`${this.drawX-this.ctx.fixedLeftWidth}px`,i=`${this.drawY-this.ctx.body.y}px`;return this.fixed==="left"?e=`${this.drawX}px`:this.fixed==="right"&&(e=`${this.drawX-(this.ctx.stageWidth-this.ctx.fixedRightWidth)}px`),this.cellType==="footer"&&this.ctx.config.FOOTER_FIXED&&(i=`${this.drawY-this.ctx.footer.y}px`),this.autoRowHeight&&this.ctx.database.getOverlayerAutoHeight(this.rowIndex,this.colIndex)===0&&(e="-99999px",i="-99999px"),{position:"absolute",overflow:"hidden",left:e,top:i,width:`${this.visibleWidth}px`,height:this.autoRowHeight?"auto":`${this.visibleHeight}px`,pointerEvents:"initial",userSelect:"none"}}drawContainer(){const{paint:e,config:{BORDER_COLOR:i,BORDER:s}}=this.ctx,{drawX:o,drawY:r}=this;e.drawRect(o,r,this.visibleWidth,this.visibleHeight,{borderColor:s?i:"transparent",fillColor:this.drawCellBgColor}),e.drawRect(o,r,this.width,this.height,{borderColor:"transparent",fillColor:this.drawCellSkyBgColor}),s||this.ctx.paint.drawLine([o,r+this.visibleHeight,o+this.visibleWidth,r+this.visibleHeight],{borderColor:i,fillColor:i,borderWidth:1,lineCap:"round",lineJoin:"round"})}drawAutofillPiont(){if(this.cellType==="footer")return;const{SELECT_BORDER_COLOR:e,ENABLE_AUTOFILL:i,ENABLE_SELECTOR:s,AUTOFILL_POINT_BORDER_COLOR:o}=this.ctx.config;if(!s||!i||this.ctx.editing)return;const{xArr:r,yArr:a}=this.ctx.selector,l=r[1],h=a[1],{colIndex:d,rowIndex:f,drawX:u,drawY:x}=this;if(d===l&&f===h){const E=d===this.ctx.maxColIndex||f===this.ctx.maxRowIndex||d===this.ctx.lastCenterColIndex?6:4;this.ctx.paint.drawRect(u+this.width-E,x+this.height-E,6,6,{borderColor:o,fillColor:e})}}draw(){this.drawTreeLine(),this.drawText(),this.drawImage(),this.drawSelector(),this.drawAutofillPiont(),this.drawErrorTip()}getWidthByColIndexColSpan(e,i){if(i===0)return 0;let s=0;for(let o=e;o<e+i;o++){const r=this.ctx.header.leafCellHeaders[o];s+=r.width}return s}drawText(){const{CELL_PADDING:e,BODY_FONT:i,PLACEHOLDER_COLOR:s,CELL_LINE_HEIGHT:o}=this.ctx.config,{placeholder:r}=this.column;let a=this.displayText,l=this.drawTextColor;if(!this.ctx.database.getReadonly(this.rowKey,this.key)&&r&&["",null,void 0].includes(this.text)&&this.cellType==="body"&&!(this.rowspan===0||this.colspan===0)&&(a=r,l=s),["",null,void 0].includes(a))return!1;typeof a!="string"&&(a=`${a}`);const d=`${a}_${this.drawTextWidth}`;return this.ellipsis=this.ctx.paint.drawText(a,this.drawTextX,this.drawTextY,this.drawTextWidth,this.drawTextHeight,{font:i,padding:e,align:this.align,verticalAlign:this.verticalAlign,color:l,autoRowHeight:this.autoRowHeight,lineHeight:o,maxLineClamp:this.maxLineClamp,cacheTextKey:d}),this.ellipsis}drawImage(){if(this.drawSelectionImageSource&&this.ctx.paint.drawImage(this.drawSelectionImageSource,this.drawSelectionImageX,this.drawSelectionImageY,this.drawSelectionImageWidth,this.drawSelectionImageHeight),this.drawTreeImageSource&&this.ctx.paint.drawImage(this.drawTreeImageSource,this.drawTreeImageX,this.drawTreeImageY,this.drawTreeImageWidth,this.drawTreeImageHeight),this.drawHoverImageSource){const{CELL_HOVER_ICON_BG_COLOR:e,CELL_HOVER_ICON_BORDER_COLOR:i}=this.ctx.config;this.ctx.paint.drawRect(this.drawHoverImageX-2,this.drawHoverImageY-2,this.drawHoverImageWidth+4,this.drawHoverImageHeight+4,{borderColor:i,radius:4,borderWidth:1,fillColor:e}),this.ctx.paint.drawImage(this.drawHoverImageSource,this.drawHoverImageX,this.drawHoverImageY,this.drawHoverImageWidth,this.drawHoverImageHeight)}}drawSelector(){if(this.cellType==="footer")return;const{ENABLE_SELECTOR:e}=this.ctx.config;if(!e)return;const{xArr:i,yArr:s,xArrCopy:o,yArrCopy:r}=this.ctx.selector;this.drawBorder({xArr:o,yArr:r,borderColor:this.ctx.config.SELECT_BORDER_COLOR||"rgb(82,146,247)",fillColor:"transparent",borderWidth:1,lineDash:[4,4]}),this.drawBorder({xArr:this.ctx.autofill.xArr,yArr:this.ctx.autofill.yArr,borderColor:this.ctx.config.SELECT_BORDER_COLOR||"rgb(82,146,247)",fillColor:"transparent",borderWidth:1,lineDash:[4,4]}),this.drawBorder({xArr:i,yArr:s,borderColor:this.ctx.config.SELECT_BORDER_COLOR||"rgb(82,146,247)",fillColor:"transparent",borderWidth:1});const[a,l]=i,[h,d]=s;!(a===l&&h===d)&&this.colIndex>=a&&this.colIndex<=l&&this.rowIndex>=h&&this.rowIndex<=d&&this.ctx.paint.drawRect(this.drawX,this.drawY,this.width,this.height,{borderColor:"transparent",fillColor:this.ctx.config.SELECT_AREA_COLOR||"rgba(82,146,247,0.1)"}),this.operation&&this.rowIndex>=h&&this.rowIndex<=d&&this.ctx.paint.drawRect(this.drawX,this.drawY,this.visibleWidth,this.visibleHeight,{borderColor:"transparent",fillColor:this.ctx.config.SELECT_ROW_COL_BG_COLOR||"transparent"})}drawErrorTip(){if(this.cellType==="footer"||!this.message||this.rowspan===0||this.colspan===0)return;const{ERROR_TIP_ICON_SIZE:e,ERROR_TIP_COLOR:i}=this.ctx.config,{width:s}=this,o=this.drawX,r=this.drawY,a=[o+s-e-.5,r,o+s-.5,r,o+s-.5,r+e];this.ctx.paint.drawLine(a,{borderColor:i,fillColor:i,borderWidth:1,lineCap:"round",lineJoin:"round"})}drawBorder(e){const{drawX:i,drawY:s,rowIndex:o,colIndex:r,height:a,width:l}=this;let h=i,d=s;const{xArr:f,yArr:u,lineDash:x=[],borderWidth:w=1,borderColor:E,fillColor:g}=e,m=f[0],y=f[1],p=u[0],R=u[1];if(r>=m&&r<=y&&o===p){const C=r===y?1:0,I=r===m?1:0;this.ctx.paint.drawLine([h+I,d+1,h+l-C,d+1],{borderColor:E,fillColor:g,borderWidth:w,lineCap:"round",lineJoin:"round",lineDash:x})}if(r===y&&o>=p&&o<=R){const C=o===p?1:0,I=o===R?1:0;this.ctx.paint.drawLine([h+l-1,d+C,h+l-1,d+a-I],{borderColor:E,fillColor:g,borderWidth:w,lineCap:"round",lineJoin:"round",lineDash:x})}if(r>=m&&r<=y&&o===R){const C=r===y?1:0,I=r===m?1:0;this.ctx.paint.drawLine([h+I,d+a-1,h+l-C,d+a-1],{borderColor:E,fillColor:g,borderWidth:w,lineCap:"round",lineJoin:"round",lineDash:x})}if(r===m&&o>=p&&o<=R){const C=o===R?1:0,I=o===p?1:0;this.ctx.paint.drawLine([h+1,d+I,h+1,d+a-C],{borderColor:E,fillColor:g,borderWidth:w,lineCap:"round",lineJoin:"round",lineDash:x})}}}class ge{constructor(t,e){n(this,"ctx");n(this,"data");n(this,"columns");n(this,"footerData",[]);n(this,"rowKeyMap",new Map);n(this,"colIndexKeyMap",new Map);n(this,"headerMap",new Map);n(this,"rowIndexRowKeyMap",new Map);n(this,"rowKeyRowIndexMap",new Map);n(this,"checkboxKeyMap",new Map);n(this,"selectionMap",new Map);n(this,"expandMap",new Map);n(this,"originalDataMap",new Map);n(this,"changedDataMap",new Map);n(this,"validationErrorMap",new Map);n(this,"itemRowKeyMap",new WeakMap);n(this,"bufferData",[]);n(this,"overlayerAutoHeightMap",new Map);n(this,"bufferCheckState",{buffer:!1,check:!1,indeterminate:!1,selectable:!0});n(this,"sumHeight",0);n(this,"filterMethod");n(this,"positions",[]);n(this,"sortState",new Map);this.ctx=t;const{data:i=[],columns:s=[],footerData:o=[]}=e;this.data=i,this.footerData=o,this.columns=s,this.init()}init(t=!0){this.ctx.paint.clearTextCache(),this.clearBufferData(),this.rowKeyMap.clear(),this.checkboxKeyMap.clear(),this.colIndexKeyMap.clear(),this.rowIndexRowKeyMap.clear(),this.rowKeyRowIndexMap.clear();const e=this.getColumns(),i=it(e);if(this.ctx.hasSelection=i.some(s=>s.type==="selection"),this.ctx.hasTree=i.some(s=>s.type==="tree"),t){this.originalDataMap.clear(),this.changedDataMap.clear(),this.validationErrorMap.clear();const{ROW_KEY:s}=this.ctx.config;s?(this.ctx.hasSelection||this.selectionMap.clear(),this.ctx.hasTree||this.expandMap.clear()):(this.selectionMap.clear(),this.expandMap.clear())}this.itemRowKeyMap=new WeakMap,this.initData(this.data),this.getData(),this.bufferCheckState.buffer=!1}clearBufferData(){this.bufferData=[]}initData(t,e=0,i=[]){const s=t.length;t.forEach((o,r)=>{var y;const{ROW_KEY:a="",DEFAULT_EXPAND_ALL:l,CELL_HEIGHT:h,SELECTABLE_METHOD:d,CHECKBOX_KEY:f}=this.ctx.config,u=o[a],x=u!=null?`${u}`:Dt();this.itemRowKeyMap.set(o,x);const w=o._height||h,E=o._readonly;let g=!0;if(typeof d=="function"&&(g=d),f){const p=o[f];if(this.checkboxKeyMap.has(p)){const R=this.checkboxKeyMap.get(p)||[];R.push(x),this.checkboxKeyMap.set(p,R)}else this.checkboxKeyMap.set(p,[x])}this.selectionMap.set(x,{key:f?o[f]:x,row:o,check:((y=this.selectionMap.get(x))==null?void 0:y.check)||!1});const m=l||this.expandMap.get(x)||o._expand||!1;this.expandMap.set(x,m),this.rowKeyMap.set(x,{readonly:E,index:r,rowIndex:r,level:e,height:w,calculatedHeight:-1,check:!1,selectable:g,expand:m,expandLazy:!1,hasChildren:o._hasChildren||(Array.isArray(o.children)?o.children.length>0:!1),expandLoading:!1,item:o,parentRowKeys:i,parentRowKey:i[i.length-1]||"",isLastChild:r===s-1}),Array.isArray(o.children)&&o.children.length&&this.initData(o.children,e+1,[...i,x])})}setRowHeight(t,e){const i=this.rowIndexRowKeyMap.get(t);if(i===void 0)return;const s=this.rowKeyMap.get(i);s.height=e,s.item._height=e,this.clearBufferData()}setBatchRowHeight(t){t.forEach(({rowIndex:e,height:i})=>{const s=this.rowIndexRowKeyMap.get(e);if(s){const o=this.rowKeyMap.get(s);o.height=i,o.item._height=i}}),this.clearBufferData()}setBatchCalculatedRowHeight(t){t.every(({height:i,rowIndex:s})=>this.getPositionForRowIndex(s).calculatedHeight===i)||(t.forEach(({rowIndex:i,height:s})=>{const o=this.rowIndexRowKeyMap.get(i);if(o){const r=this.rowKeyMap.get(o);r.calculatedHeight=s}}),this.clearBufferData(),this.getData(),this.ctx.emit("draw"))}getAllRowsData(){let t=[];const e=i=>{i.forEach(s=>{t.push(s),Array.isArray(s.children)&&e(s.children)})};return e(this.data),t}filterColumns(t){return t.reduce((e,i)=>{if(!(typeof i.hide=="function"?i.hide():i.hide)){const o={...i};o.children&&Array.isArray(o.children)&&(o.children=this.filterColumns(o.children)),e.push(o)}return e},[])}getColumns(){return this.filterColumns(this.columns)}setColumns(t){this.columns=t,this.clearBufferData()}setData(t){this.data=t,this.init()}getData(){if(this.bufferData.length>0)return{data:this.bufferData,sumHeight:this.sumHeight,positions:this.positions};let t=[],e=0;this.sumHeight=0,this.positions=[];const i=o=>{o.forEach(r=>{t.push(r);const a=this.itemRowKeyMap.get(r),{expand:l,hasChildren:h,height:d,calculatedHeight:f}=this.rowKeyMap.get(a),u=this.sumHeight,x=Math.max(f,d);this.sumHeight+=x,this.rowIndexRowKeyMap.set(e,a),this.rowKeyRowIndexMap.set(a,e),this.positions.push({top:u,height:x,bottom:this.sumHeight,calculatedHeight:f}),e+=1,l&&h&&i(r.children)})};this.rowIndexRowKeyMap.clear(),this.rowKeyRowIndexMap.clear();let s=this.data;if(typeof this.filterMethod=="function"&&(s=this.filterMethod(s)),this.sortState.size){const o=Array.from(this.sortState.entries()).sort((r,a)=>r[1].timestamp-a[1].timestamp);s=this.sortDataRecursive(s,o)}return i(s),this.bufferData=t,{data:t,sumHeight:this.sumHeight,positions:this.positions}}setFooterData(t){this.footerData=t}getFooterData(){return this.footerData}setFilterMethod(t){this.filterMethod=t}clearFilterMethod(){this.filterMethod=void 0}getSortState(t){return this.sortState.get(t)||{direction:"none",timestamp:0}}setSortState(t,e){const i=Date.now();this.ctx.config.SORT_STRICTLY&&this.sortState.clear(),e==="none"?this.sortState.delete(t):this.sortState.set(t,{direction:e,timestamp:i}),this.ctx.emit("sortChange",this.sortState),this.clearBufferData(),this.ctx.emit("draw")}clearSort(){this.sortState.clear(),this.ctx.emit("sortChange",this.sortState),this.clearBufferData(),this.ctx.emit("draw")}sortDataRecursive(t,e){let i=[...t];for(const[s,{direction:o}]of e){if(o==="none")continue;const r=this.getColumnByKey(s);!r||!r.column.sortBy||(i=this.applySingleColumnSort(i,s,o,r.column.sortBy))}return i.map(s=>(s.children&&Array.isArray(s.children)&&(s.children=this.sortDataRecursive(s.children,e)),s))}applySingleColumnSort(t,e,i,s){return t.sort((o,r)=>{const a=o[e],l=r[e];let h=0;if(typeof s=="function")h=s(o,r);else if(s==="number"){const d=Number(a)||0,f=Number(l)||0;h=d-f}else if(s==="string"){const d=String(a||""),f=String(l||"");h=d.localeCompare(f)}else s==="date"&&(h=ue(a,l));return i==="asc"?h:-h})}expandItem(t,e=!1){const i=this.rowKeyMap.get(t);i.expand=e,this.expandMap.set(t,e),this.clearBufferData(),this.ctx.emit("draw")}setExpandRowKeys(t,e=!0){this.expandMap.clear(),t.forEach(i=>{const s=this.rowKeyMap.get(i);this.expandMap.set(i,e),s.expand=e}),this.clearBufferData(),this.ctx.emit("draw")}getExpandRowKeys(){let t=[];return this.rowKeyMap.forEach((e,i)=>{e.expand&&t.push(i)}),t}expandAll(t){this.expandMap.clear(),this.rowKeyMap.forEach(e=>{e.expand=t,this.expandMap.set(e.key,t)}),this.clearBufferData(),this.ctx.emit("draw")}expandLoading(t,e=!1){const i=this.rowKeyMap.get(t);i.expandLoading=e,this.clearBufferData(),this.ctx.emit("draw")}setExpandChildren(t,e){const i=this.rowKeyMap.get(t);i.expand=!0,this.expandMap.set(t,!0),i.expandLazy=!0,i.item.children=e,this.initData(i.item.children,i.level+1),this.clearBufferData()}getIsExpandLoading(t){return this.rowKeyMap.get(t).expandLoading}getIsExpandLazy(t){return this.rowKeyMap.get(t).expandLazy}getIsExpand(t){return this.rowKeyMap.get(t).expand}getRowForRowKey(t){return this.rowKeyMap.get(t)}getRowForRowIndex(t){const e=this.getRowKeyForRowIndex(t);return this.rowKeyMap.get(e)}getRowKeyForRowIndex(t){return this.rowIndexRowKeyMap.get(t)||""}getRowKeyByItem(t){return this.itemRowKeyMap.get(t)}getRowIndexForRowKey(t){return this.rowKeyRowIndexMap.get(t)}getItemValueForRowIndexAndColIndex(t,e){if(!(this.rowIndexRowKeyMap.has(t)&&this.colIndexKeyMap.get(e)))return null;const s=this.rowIndexRowKeyMap.get(t),o=this.colIndexKeyMap.get(e);return s===void 0||o===void 0?null:{rowKey:s,key:o,value:this.getItemValue(s,o)}}getItemValue(t,e){const i=this.rowKeyMap.get(t);return i&&i.item?i.item[e]===void 0?null:i.item[e]:null}async batchSetItemValue(t,e=!1,i=!0,s="none"){let o=[],r=i;const a=new Set;let l=[],h=t.map(x=>{const{rowKey:w,key:E}=x;let g=x.value,m=g;const y=this.getRowDataItemForRowKey(w),p=this.getItemValue(w,E),R=this.getVirtualBodyCellByKey(w,E);return(R==null?void 0:R.type)==="number"&&(["",void 0,null].includes(g)?m=null:/^-?\d+(\.\d+)?$/.test(`${g}`)?m=Number(g):(m=p,l.push({...x,value:m,oldValue:p,row:y}))),{...x,value:m,oldValue:p,row:y}});if(h=h.filter(x=>!l.some(w=>x.rowKey===w.rowKey&&x.key===w.key)),l.length){const x={code:"ERR_BATCH_SET_NUMBER_VALUE",message:"Assignment failed, not a numeric type",data:l};this.ctx.emit("error",x)}if(h=h.filter(x=>x.oldValue!==x.value),!h.length)return;const{BEFORE_VALUE_CHANGE_METHOD:d}=this.ctx.config;s==="none"&&typeof d=="function"&&(h=await d(h),r=!1),h.forEach(x=>{const{value:w,rowKey:E,key:g}=x,m=this.getItemValue(E,g);a.add(E),this.setItemValue(E,g,w,!1,!1,!1,r),o.push({rowKey:E,key:g,oldValue:m,newValue:w})});let f=[];a.forEach(x=>{f.push(this.ctx.database.getRowDataItemForRowKey(x))});const u=h.map(({rowKey:x,key:w})=>this.getValidator(x,w));Promise.all(u).then(()=>{this.validationErrorMap.size===0&&this.changedDataMap.size>0&&this.ctx.emit("validateChangedData",this.getChangedData())}),this.ctx.emit("change",h,f),e&&this.ctx.history.pushState({changeList:o,scrollX:this.ctx.scrollX,scrollY:this.ctx.scrollY,type:"multiple"}),this.ctx.emit("draw")}async setItemValue(t,e,i,s=!1,o=!1,r=!1,a=!0){if(!this.rowKeyMap.has(t))return{};const{item:l}=this.rowKeyMap.get(t);let h=l[e],d=i;if(a&&this.ctx.database.getReadonly(t,e))return{oldValue:h,newValue:h};l[e]!==null&&typeof l[e]=="object"&&(h=JSON.parse(JSON.stringify(l[e])));const f=`${t}_${e}`;this.originalDataMap.has(f)||this.originalDataMap.set(f,h);const u=this.originalDataMap.get(f),x=this.getRowDataItemForRowKey(t);if(r){const w=this.getVirtualBodyCellByKey(t,e);if((w==null?void 0:w.type)==="number")if(["",void 0,null].includes(i))d=null;else if(/^-?\d+(\.\d+)?$/.test(`${i}`))d=Number(i);else{d=h;const g={code:"ERR_SET_NUMBER_VALUE",message:"Assignment failed, not a numeric type",data:[{rowKey:t,key:e,value:d,oldValue:h,row:x}]};this.ctx.emit("error",g)}if(d===h)return{oldValue:h,newValue:h};let E=[{rowKey:t,key:e,value:d,oldValue:h,row:x}];this.batchSetItemValue(E,s,!1),this.ctx.emit("editChange",{rowKey:t,key:e,oldValue:h,value:d,originalValue:u,row:x})}else this.changedDataMap.set(f,d),l[e]=d;return this.ctx.hasEvent("iterationChange")&&this.ctx.emit("iterationChange",{rowKey:t,key:e,oldValue:h,value:d,originalValue:this.originalDataMap.get(f),row:x}),o&&this.ctx.emit("draw"),{oldValue:h,newValue:d}}getRowDataItemForRowKey(t){if(!this.rowKeyMap.has(t))return{};const{item:e}=this.rowKeyMap.get(t);return e}setRowSelectionByCheckboxKey(t,e){const{CHECKBOX_KEY:i}=this.ctx.config;if(i){if(!this.rowKeyMap.has(t))return!1;const{item:s}=this.rowKeyMap.get(t),o=s[i];this.checkboxKeyMap.has(o)&&(this.checkboxKeyMap.get(o)||[]).forEach(a=>{const l=this.selectionMap.get(a);l&&(l.check=e)})}}toggleRowSelection(t,e){const i=this.rowKeyMap.get(t),s=this.selectionMap.get(t);if(!s)return;e==="selection-tree"||e==="tree-selection"?this.toggleTreeSelection(t):(s.check=!s.check,this.setRowSelectionByCheckboxKey(t,s.check)),this.ctx.emit("toggleRowSelection",i);const o=this.getSelectionRows();this.ctx.emit("selectionChange",o),this.bufferCheckState.buffer=!1,this.ctx.emit("draw")}toggleTreeSelection(t){const e=this.getTreeSelectionState(t),i=this.ctx.config.TREE_SELECT_MODE;if(i==="auto")e.checked&&!e.indeterminate?(this.setRowSelection(t,!1,!1),this.clearTreeSelectionRecursive(t)):(this.setRowSelection(t,!0,!1),this.selectTreeSelectionRecursive(t));else if(i==="cautious")e.checked&&!e.indeterminate?(this.setRowSelection(t,!1,!1),this.clearTreeSelectionRecursive(t)):(this.setRowSelection(t,!0,!1),this.selectTreeSelectionRecursive(t));else if(i==="strictly"){const s=this.selectionMap.get(t);s&&(s.check=!s.check,this.setRowSelectionByCheckboxKey(t,s.check))}this.ctx.emit("selectionChange",this.getSelectionRows()),this.ctx.emit("draw")}selectTreeSelectionRecursive(t){this.getTreeChildren(t).forEach(i=>{this.setRowSelection(i,!0,!1),this.selectTreeSelectionRecursive(i)})}clearTreeSelectionRecursive(t){this.getTreeChildren(t).forEach(i=>{this.setRowSelection(i,!1,!1),this.clearTreeSelectionRecursive(i)})}updateParentTreeSelection(t){const e=this.getTreeParent(t);if(!e)return;const s=this.getTreeChildren(e).map(h=>this.selectionMap.get(h)),o=s.filter(h=>h==null?void 0:h.check).length,r=s.length;let a=!1;r>0&&(o===0?a=!1:o===r||this.ctx.config.TREE_SELECT_MODE==="auto"?a=!0:this.ctx.config.TREE_SELECT_MODE==="cautious"&&(a=!1));const l=this.selectionMap.get(e);l&&l.check!==a&&(l.check=a,this.setRowSelectionByCheckboxKey(e,a),this.updateParentTreeSelection(e))}setRowSelection(t,e,i=!0){const s=this.selectionMap.get(t);s&&(s.check=e,this.setRowSelectionByCheckboxKey(t,s.check),this.ctx.emit("setRowSelection",e,s.row),(this.ctx.config.TREE_SELECT_MODE==="auto"||this.ctx.config.TREE_SELECT_MODE==="cautious")&&this.updateParentTreeSelection(t),i&&(this.bufferCheckState.buffer=!1,this.ctx.emit("draw")))}getSelectionRows(){let t=[];return this.selectionMap.forEach(e=>{e.check&&t.push(e.row)}),t}getRowSelection(t){const e=this.selectionMap.get(t);return e?e.check:!1}getTreeSelectionState(t){if(!this.getRowForRowKey(t))return{checked:!1,indeterminate:!1};const i=this.selectionMap.get(t),s=(i==null?void 0:i.check)||!1;if(this.getTreeChildren(t).length===0)return{checked:s,indeterminate:!1};let r=!1,a=s;if(this.ctx.config.TREE_SELECT_MODE==="auto"){const h=g=>{const m=this.getTreeChildren(g);let y=[];for(const p of m)y.push(p),y.push(...h(p));return y},f=h(t).map(g=>this.selectionMap.get(g)),u=f.filter(g=>g==null?void 0:g.check).length,x=f.length,w=u>0;r=w&&!(u===x),a=s||w,s&&x>0&&u===0&&(a=!1,r=!1)}else if(this.ctx.config.TREE_SELECT_MODE==="cautious"){const h=g=>{const m=this.getTreeChildren(g);let y=[];for(const p of m)y.push(p),y.push(...h(p));return y},f=h(t).map(g=>this.selectionMap.get(g)),u=f.filter(g=>g==null?void 0:g.check).length,x=f.length,w=u>0,E=u===x;r=w&&!E,a=s||E,s&&x>0&&u===0&&(a=!1,r=!1)}else this.ctx.config.TREE_SELECT_MODE==="strictly"&&(r=!1,a=s);return{checked:a,indeterminate:r}}getTreeChildren(t){const e=this.getRowForRowKey(t);if(!e||!e.item||!e.item.children)return[];const i=[],s=o=>{for(const r of o){const a=this.getRowKeyByItem(r);a&&i.push(a),r.children&&r.children.length>0&&s(r.children)}};return s(e.item.children),i}getTreeParent(t){const e=(i,s)=>{for(const o of i){const r=this.getRowKeyByItem(o);if(o.children)for(const a of o.children){if(this.getRowKeyByItem(a)===s)return r;const h=e(o.children,s);if(h)return h}}return null};return e(this.data,t)}getRowSelectable(t){const{selectable:e,item:i,rowIndex:s}=this.rowKeyMap.get(t);return typeof e=="function"?e({row:i,rowIndex:s}):e}toggleAllSelection(){this.ctx.config.TREE_SELECT_MODE==="auto"||this.ctx.config.TREE_SELECT_MODE==="cautious"?this.rowKeyMap.forEach((i,s)=>{let o=i.selectable;if(typeof o=="function"&&(o=o({row:i.item,rowIndex:i.rowIndex})),o){const r=this.selectionMap.get(s);r&&(r.check=!0,this.setRowSelectionByCheckboxKey(s,!0))}}):this.rowKeyMap.forEach((i,s)=>{let o=i.selectable;typeof o=="function"&&(o=o({row:i.item,rowIndex:i.rowIndex})),o&&this.setRowSelection(s,!0,!1)});const e=this.getSelectionRows();this.ctx.emit("toggleAllSelection",e),this.ctx.emit("selectionChange",e),this.bufferCheckState.buffer=!1,this.ctx.emit("draw")}clearSelection(t=!1){const e=this.ctx.config.TREE_SELECT_MODE==="auto"||this.ctx.config.TREE_SELECT_MODE==="cautious";t?e?this.rowKeyMap.forEach((s,o)=>{const r=this.selectionMap.get(o);r&&(r.check=!1,this.setRowSelectionByCheckboxKey(o,!1))}):this.rowKeyMap.forEach((s,o)=>{this.setRowSelection(o,!1,!1)}):(this.selectionMap.clear(),this.rowKeyMap.forEach((s,o)=>{this.selectionMap.set(o,{check:!1,row:s.item,key:o})}));const i=this.getSelectionRows();this.ctx.emit("clearSelection"),this.ctx.emit("selectionChange",i),this.bufferCheckState.buffer=!1,this.ctx.emit("draw")}getCheckedState(){const{buffer:t,...e}=this.bufferCheckState;if(t)return e;const i=this.rowKeyMap.size;let s=0,o=0;const r=this.selectionMap.size,a=Array.from(this.selectionMap.values()).some(u=>u.check);this.rowKeyMap.forEach((u,x)=>{var E;(E=this.selectionMap.get(x))!=null&&E.check&&(s+=1);let w=u.selectable;typeof w=="function"&&(w=w({row:u.item,rowIndex:u.rowIndex})),w&&(o+=1)});const l=r>i&&s===0&&a,h=o&&o>s&&s>0||l,d=o!==0,f=!!o&&o===s;return this.bufferCheckState={buffer:!0,check:f,indeterminate:h,selectable:d},{check:f,indeterminate:h,selectable:d}}updateColIndexKeyMap(t=[]){this.colIndexKeyMap.clear(),t.forEach(e=>{this.colIndexKeyMap.set(e.colIndex,e.key)})}getColumnByColIndex(t){var i;const e=this.colIndexKeyMap.get(t);if(e&&this.headerMap.has(e))return(i=this.headerMap.get(e))==null?void 0:i.column}getColumnByKey(t){const e=this.headerMap.get(t);if(e)return e}getColIndexForKey(t){var e;if(t&&this.headerMap.has(t))return(e=this.headerMap.get(t))==null?void 0:e.colIndex}getColHeaderByIndex(t){const e=this.colIndexKeyMap.get(t);if(e&&this.headerMap.has(e))return this.headerMap.get(e)}getChangedData(){let t=[];return this.changedDataMap.forEach((e,i)=>{const s=this.originalDataMap.get(i),o=i.split("_")[0],r=i.split("_")[1];s!==e&&t.push({rowKey:o,colKey:r,originalValue:s,row:this.ctx.database.getRowDataItemForRowKey(o),value:e})}),t}getChangedRows(){const t=new Set;this.changedDataMap.forEach((i,s)=>{const o=this.originalDataMap.get(s),r=s.split("_")[0];o!==i&&t.add(r)});let e=[];return t.forEach(i=>{e.push(this.ctx.database.getRowDataItemForRowKey(i))}),e}isHasChangedData(t,e){const i=`${t}_${e}`;if(!this.changedDataMap.has(i))return!1;const s=this.originalDataMap.get(i),o=this.changedDataMap.get(i);return s!==o}getPositionForRowIndex(t){return t<this.positions.length?this.positions[t]:{height:0,top:0,bottom:0,calculatedHeight:0}}setHeader(t,e){return t?(this.headerMap.set(t,e),!0):!1}getReadonly(t,e){const{DISABLED:i}=this.ctx.config;if(i)return!0;const s=this.rowKeyMap.get(t),o=this.headerMap.get(e);if(!s||!o)return!0;const r=s.readonly,a=o.readonly,{BODY_CELL_READONLY_METHOD:l}=this.ctx.config;if(typeof l=="function"&&o){const d=l({row:s.item,rowIndex:s.rowIndex,colIndex:o.colIndex,column:o.column,value:this.getItemValue(t,e)});if(d!==void 0)return d}return a||r}clearValidate(){this.validationErrorMap.clear()}hasValidationError(){return this.validationErrorMap.size!==0}getValidator(t,e){return new Promise(i=>{const s=this.rowKeyMap.get(t),o=this.headerMap.get(e),{BODY_CELL_RULES_METHOD:r}=this.ctx.config;if(o===void 0)return i([]);const a=o.column;let l=a.rules;if(typeof r=="function"){const d=r({row:s.item,rowIndex:s.rowIndex,colIndex:o.colIndex,column:a,value:this.getItemValue(t,e)});d&&(l=d)}if(l){const h={row:s.item,rowIndex:s.rowIndex,colIndex:o.colIndex,column:a,key:e,rowKey:t,value:this.getItemValue(t,e),field:e,fieldValue:this.getItemValue(t,e)},f=new ne(l).validate(h);this.setValidationError(t,e,f),i(f)}else this.clearValidationError(t,e),i([])})}getHeightByRowIndexRowSpan(t,e){let i=0;for(let s=0;s<e;s++){const o=this.positions[t+s];o&&(i+=o.height)}return i}getSpanInfo(t){const{rowIndex:e,key:i,rowKey:s,row:o,value:r,colIndex:a,relationRowKeys:l,relationColKeys:h,rowspan:d,height:f,width:u,colspan:x,mergeRow:w,mergeCol:E}=t;if(d===1&&x===1)return{xArr:[a,a],yArr:[e,e],rowspan:d,colspan:x,height:f,width:u,offsetTop:0,offsetLeft:0,dataList:[{rowKey:s,key:i,row:o,value:r}]};let g=e,m=e,y=a,p=a,R=[],C=0,I=0,_=0,v=0;if(d!==1&&w){v=u;const S=l.reduce((b,O)=>{const T=this.getItemValue(s,O)??"";return`${b}${T}`},"");for(let b=e-1;b>=0;b--){const O=this.rowIndexRowKeyMap.get(b)||"",T=l.reduce((M,L)=>{const A=this.getItemValue(O,L)??"";return`${M}${A}`},"");if(S===T)g=b;else break}for(let b=e;b<=this.ctx.maxRowIndex;b++){const O=this.rowIndexRowKeyMap.get(b)||"",T=l.reduce((M,L)=>{const A=this.getItemValue(O,L)??"";return`${M}${A}`},"");if(S===T)m=b;else break}for(let b=g;b<e;b++){const{height:O}=this.positions[b];C+=O}for(let b=g;b<=m;b++){const{height:O}=this.positions[b];_+=O;const T=this.rowIndexRowKeyMap.get(b)||"",{item:M}=this.rowKeyMap.get(T),L=this.getItemValue(T,i);R.push({rowKey:T,key:i,value:L,row:M})}}if(x!==1&&E){_=f;for(let S=a-1;S>=0;S--){const b=this.getColumnByColIndex(S);if(!b)break;const O=this.getItemValue(s,i),T=this.getItemValue(s,b.key);if(O===T&&h.includes(b.key))y=S;else break}for(let S=a;S<=this.ctx.maxColIndex;S++){const b=this.getColumnByColIndex(S);if(!b)break;const O=this.getItemValue(s,i),T=this.getItemValue(s,b.key);if(O===T&&h.includes(b.key))p=S;else break}for(let S=y;S<a;S++){const b=this.getColumnByColIndex(S);if(!b)break;I+=b.width||100}for(let S=y;S<=p;S++){const b=this.getColumnByColIndex(S);if(!b)break;v+=b.width||100,R.push({rowKey:s,key:b.key,value:this.getItemValue(s,b.key),row:o})}}return{xArr:[y,p],yArr:[g,m],rowspan:d,colspan:x,height:_,width:v,offsetTop:C,offsetLeft:I,dataList:R}}setValidationErrorByRowIndex(t,e,i){const s=this.rowIndexRowKeyMap.get(t),o=`${s}_${e}`,r=this.getRowForRowIndex(t),a=this.getColumnByKey(e);if(!s||!a||!r)return;const l=this.getItemValue(s,e),h=[{key:e,rowKey:s,rowIndex:t,colIndex:a.colIndex,column:a.column,row:r,value:l,message:i,field:e,fieldValue:l}];this.validationErrorMap.set(o,h)}setValidationError(t,e,i){const s=`${t}_${e}`;this.validationErrorMap.set(s,i)}clearValidationError(t,e){const i=`${t}_${e}`;this.validationErrorMap.has(i)&&this.validationErrorMap.delete(i)}getValidationError(t,e){const i=`${t}_${e}`;return this.validationErrorMap.get(i)||[]}getVirtualBodyCell(t,e){const i=this.getColumnByColIndex(e),s=this.getRowForRowIndex(t);return!i||!s?void 0:new ut(this.ctx,t,e,0,0,0,0,i,s.item,"body")}getVirtualBodyCellByKey(t,e){const i=this.getRowIndexForRowKey(t),s=this.getColIndexForKey(e);if(!(i===void 0||s===void 0))return this.getVirtualBodyCell(i,s)}hasMergeCell(t,e){let i=!1;for(let s=e[0];s<=e[1];s++)for(let o=t[0];o<=t[1];o++){const r=this.getVirtualBodyCell(s,o);if(r&&(r.rowspan!==1||r.colspan!==1)){i=!0;break}}return i}calculateMaxTreeDepth(t,e=0){let i=e;return t.forEach(s=>{if(Array.isArray(s.children)&&s.children.length>0){const o=this.calculateMaxTreeDepth(s.children,e+1);i=Math.max(i,o)}}),i}setOverlayerAutoHeightMap(t){this.overlayerAutoHeightMap=t}getOverlayerAutoHeightMap(){return this.overlayerAutoHeightMap}getOverlayerAutoHeight(t,e){const i=`${t}_${e}`;return this.overlayerAutoHeightMap.get(i)||0}}class we{constructor(t){n(this,"ctx");n(this,"history",[]);n(this,"historyIndex",-1);this.ctx=t,this.init()}init(){this.ctx.on("keydown",t=>{if(!this.ctx.editing){if(t.ctrlKey&&!t.shiftKey&&t.code==="KeyZ"||t.metaKey&&!t.shiftKey&&t.code==="KeyZ"){t.preventDefault(),this.ctx.clearSelector(),this.ctx.clearAutofill(),this.backState();return}if(t.ctrlKey&&t.code==="KeyY"||t.ctrlKey&&t.shiftKey&&t.code==="KeyZ"||t.metaKey&&t.shiftKey&&t.code==="KeyZ"){t.preventDefault(),this.ctx.clearSelector(),this.ctx.clearAutofill(),this.forwardState();return}}})}pushState(t){const{HISTORY_NUM:e=0,ENABLE_HISTORY:i}=this.ctx.config;i&&(this.history.push(t),this.history.length>e&&this.history.splice(0,1),this.historyIndex=this.history.length-1)}backState(){if(this.historyIndex>=0){const{changeList:t,scrollX:e,scrollY:i}=this.history[this.historyIndex],s=t.map(o=>({rowKey:o.rowKey,key:o.key,value:o.oldValue,row:{}}));this.ctx.setScroll(e,i),this.ctx.database.batchSetItemValue(s,!1,!1,"back"),this.historyIndex-=1}}forwardState(){if(this.historyIndex<this.history.length-1){this.historyIndex+=1;const{changeList:t}=this.history[this.historyIndex],e=t.map(i=>({rowKey:i.rowKey,key:i.key,value:i.newValue,row:{}}));this.ctx.database.batchSetItemValue(e,!1,!1,"forward")}}clear(){this.history=[],this.historyIndex=-1}}class Ee{constructor(t){n(this,"eventTasks",new Map);n(this,"ctx");this.ctx=t,this.init()}init(){this.bind(window,"resize",this.handleResize.bind(this)),this.bind(window,"mouseup",this.handleMouseUp.bind(this)),this.bind(window,"mousemove",this.handleMousemove.bind(this)),this.bind(window,"blur",this.handleOutsideMousedown.bind(this)),this.bind(window,"mousedown",this.handleOutsideMousedown.bind(this)),this.bind(this.ctx.stageElement,"click",this.handleClick.bind(this)),this.bind(window,"keydown",this.handleKeydown.bind(this)),this.bind(this.ctx.stageElement,"wheel",this.handleWheel.bind(this),{passive:!1}),this.bind(this.ctx.stageElement,"touchstart",this.handleTouchstart.bind(this),{passive:!1}),this.bind(this.ctx.stageElement,"touchend",this.handleTouchend.bind(this)),this.bind(this.ctx.stageElement,"touchmove",this.handleTouchmove.bind(this),{passive:!1}),this.bind(this.ctx.stageElement,"contextmenu",this.handleContextMenu.bind(this)),this.bind(this.ctx.stageElement,"mousedown",this.handleMouseDown.bind(this)),this.bind(this.ctx.stageElement,"dblclick",this.handleDblclick.bind(this)),this.bind(this.ctx.stageElement,"mouseover",this.handleMouseover.bind(this)),this.bind(this.ctx.stageElement,"mouseout",this.handleMouseout.bind(this)),document.addEventListener("selectionchange",this.selectionchange.bind(this))}selectionchange(){this.ctx.domSelectionStr="";const t=window.getSelection();t&&t.toString()&&(this.ctx.domSelectionStr=t.toString())}clearDomSelection(){const t=window.getSelection();t&&!t.isCollapsed&&t.removeAllRanges()}destroy(){this.eventTasks.forEach((t,e)=>{this.unbind(window,e,t)}),document.removeEventListener("selectionchange",this.selectionchange.bind(this)),this.eventTasks.clear()}handleResize(t){this.ctx.emit("resetHeader",t),this.ctx.emit("resize",t)}handleMouseDown(t){this.clearDomSelection(),t.button===0&&(this.ctx.mousedown=!0),this.ctx.containerElement.focus({preventScroll:!0}),this.ctx.emit("mousedown",t)}handleMousemove(t){this.ctx.emit("mousemove",t)}handleMouseUp(t){t.button===0&&(this.ctx.mousedown=!1),this.ctx.emit("mouseup",t)}handleClick(t){this.ctx.emit("click",t)}handleKeydown(t){const{ENABLE_KEYBOARD:e}=this.ctx.config;e&&this.ctx.isTarget(t)&&this.ctx.emit("keydown",t)}handleWheel(t){this.ctx.emit("wheel",t)}handleTouchstart(t){this.ctx.emit("touchstart",t)}handleTouchend(t){this.ctx.emit("touchend",t)}handleTouchmove(t){this.ctx.emit("touchmove",t)}handleContextMenu(t){t.preventDefault(),this.ctx.emit("contextMenu",t)}handleMouseover(t){this.ctx.isMouseoverTargetContainer=!0,this.ctx.emit("mouseover",t)}handleMouseout(t){this.ctx.isMouseoverTargetContainer=!1,this.ctx.emit("mouseout",t)}handleDblclick(t){this.ctx.emit("dblclick",t)}handleOutsideMousedown(t){this.ctx.selector.enable&&(t.target instanceof Window||t.target instanceof Node&&!this.ctx.containerElement.contains(t.target))&&this.ctx.emit("outsideMousedown",t)}bind(t,e,i,s){t.addEventListener(e,i,s),this.eventTasks.set(e,i)}unbind(t,e,i){t.removeEventListener(e,i),this.eventTasks.delete(e)}}class me{constructor(){n(this,"events",new Map)}has(t){return this.events.has(t)}on(t,e){const i=this.events.get(t)||[];i.push(e),this.events.set(t,i)}once(t,e){const i=(...s)=>{e(...s),this.off(t,i)};return this.on(t,i),this}off(t,e){const i=this.events.get(t);if(i){const s=i.indexOf(e);s>=0&&(i.splice(s,1),i.length===0?this.events.delete(t):this.events.set(t,i))}}emit(t,...e){const i=this.events.get(t);i&&i.forEach(s=>{s(...e)})}destroy(){this.events.clear()}}class pe{constructor(t){n(this,"ctx");n(this,"textCacheMap",new Map);const e=t.getContext("2d");if(!e)throw new Error("canvas context not found");this.ctx=e}clearTextCache(){this.textCacheMap.clear()}scale(t){this.ctx.setTransform(1,0,0,1,0,0),this.ctx.scale(t,t)}save(){this.ctx.save()}restore(){this.ctx.restore()}translate(t,e){this.ctx.translate(t,e)}setCursor(t="default"){this.ctx.canvas.style.cursor=t}clear(t=0,e=0,i,s){this.ctx.clearRect(t,e,i||this.ctx.canvas.width,s||this.ctx.canvas.height)}drawShadow(t,e,i,s,o){const{fillColor:r,side:a,shadowWidth:l,colorStart:h,colorEnd:d}=o;this.ctx.save(),r&&(this.ctx.fillStyle=r,this.ctx.fillRect(t,e,i,s));let f;switch(a){case"left":f=this.ctx.createLinearGradient(t-l,e,t,e),f.addColorStop(0,h),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t-l,e,l,s);break;case"right":f=this.ctx.createLinearGradient(t+i,e,t+i+l,e),f.addColorStop(0,h),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t+i,e,l,s);break;case"top":f=this.ctx.createLinearGradient(t,e-l,t,e),f.addColorStop(0,h),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t,e-l,i,l);break;case"bottom":f=this.ctx.createLinearGradient(t,e+s,t,e+s+l),f.addColorStop(0,h),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t,e+s,i,l);break;default:console.error("Invalid side specified for shadow");break}this.ctx.restore()}drawLine(t,e){if(t.length<4||t.length%2!==0)throw new Error("A valid array of points is required to draw a line");this.ctx.save();const{borderColor:i="black",borderWidth:s=1}=e;this.ctx.beginPath(),this.ctx.moveTo(t[0]-.5,t[1]-.5);for(let o=2;o<t.length;o+=2)this.ctx.lineTo(t[o]-.5,t[o+1]-.5);this.ctx.strokeStyle=i,this.ctx.lineWidth=s,e.lineDash&&(this.ctx.lineDashOffset=e.lineDashOffset??0,this.ctx.setLineDash(e.lineDash)),e.fillColor&&(this.ctx.fillStyle=e.fillColor,this.ctx.fill()),e.borderColor&&(this.ctx.strokeStyle=e.borderColor),this.ctx.stroke(),this.ctx.closePath(),this.ctx.restore()}drawImage(t,e,i,s,o){this.ctx.save(),this.ctx.drawImage(t,e,i,s,o),this.ctx.restore()}drawRect(t,e,i,s,{borderWidth:o=1,borderColor:r,fillColor:a,radius:l=0}={}){if(this.ctx.save(),this.ctx.beginPath(),a!==void 0&&(this.ctx.fillStyle=a),r!==void 0&&(this.ctx.lineWidth=o,this.ctx.strokeStyle=r),l===0)this.ctx.rect(t-.5,e-.5,i,s);else{const[h,d,f,u]=typeof l=="number"?[l,l,l,l]:l;this.ctx.moveTo(t+h,e),this.ctx.arcTo(t+i,e,t+i,e+d,d),this.ctx.arcTo(t+i,e+s,t+i-f,e+s,f),this.ctx.arcTo(t,e+s,t,e+s-u,u),this.ctx.arcTo(t,e,t+h,e,h)}a!==void 0&&this.ctx.fill(),r!==void 0&&this.ctx.stroke(),this.ctx.restore()}drawText(t="",e,i,s,o,r={}){var O;this.ctx.save();const{font:a="12px Arial",align:l="center",color:h="#495060",padding:d=0,verticalAlign:f="middle",maxLineClamp:u=1,autoRowHeight:x=!1,offsetLeft:w=0,offsetRight:E=0}=r;if(this.ctx.font=a,this.ctx.fillStyle=h,this.ctx.textAlign=l,["",null,void 0].includes(t))return this.ctx.restore(),!1;const m=parseInt(((O=a.match(/\d+/))==null?void 0:O[0])||"12")*(r.lineHeight||1.2),y=s-d*2-w-E,p=this.ctx.measureText("...").width;let R=!1;if(s<=p+d*2+w+E)return this.ctx.restore(),R=!0,R;const C=Math.round((o-2*d)/m);let I=this.wrapText(t,y,r.cacheTextKey),_=Math.min(I.length,Math.max(C,1));u==="auto"&&x?_=I.length:typeof u=="number"&&u<_?_=u:(u===1&&!x&&(I=[t],_=1),u==="auto"&&C===1&&(I=[t],_=1));let v=i+d;const S=Math.round(_*m);f==="middle"?v=i+(o-S)/2:f==="bottom"&&(v=i+o-S-d);let b=e+d+w;l==="center"?b=e+s/2:l==="right"&&(b=e+s-d-E);for(let T=0;T<I.length;T++){const M=I[T],L=v+T*m;if(this.ctx.textBaseline="top",T===_-1){const{_text:A,ellipsis:D}=this.handleEllipsis(M,s,d,a);this.ctx.fillText(A,b,L),R=D;break}this.ctx.fillText(M,b,L)}if(r.textCallback&&I.length){const T=Math.round(this.ctx.measureText(I[0]).width);let M=b,L=b+T;l==="center"?(M=b-T/2,L=b+T/2):l==="right"&&(M=b-T,L=b);const A={x:b,y:v,width:T,height:S,left:M,right:L,top:v,bottom:v+S};r.textCallback(A)}return this.ctx.restore(),R}wrapText(t,e,i=""){if(!t)return[""];if(i&&this.textCacheMap.has(i))return this.textCacheMap.get(i)||[""];const s=[],o=t.split(`
|
|
5
|
-
`);for(const a of o){if(a===""){s.push("");continue}const l=a.split("");let h="";for(const d of l){const f=h+d;this.ctx.measureText(f).width<=e?h=f:h?(s.push(h),h=d):(s.push(d),h="")}h&&s.push(h)}if(s.length>=1){const a=s[s.length-1],{ellipsis:l}=this.handleEllipsis(a,e,0,this.ctx.font);if(l){const h=a.slice(0,-1);s[s.length-1]=h,s.push(a.slice(-1))}}const r=s.length>0?s:[""];return i&&this.textCacheMap.set(i,r),r}calculateTextHeight(t="",e,i={}){var E;const{font:s="12px Arial",padding:o=0,align:r="center",color:a="#495060",maxLineClamp:l=1,cacheTextKey:h=""}=i;this.ctx.save(),this.ctx.font=s,this.ctx.fillStyle=a,this.ctx.textAlign=r;const d=parseInt(((E=s.match(/\d+/))==null?void 0:E[0])||"12"),f=d*(i.lineHeight||1.2),u=e-o*2,x=this.wrapText(t,u,h);let w=1;return l==="auto"?w=x.length:x.length>l?w=l:w=x.length,this.ctx.restore(),Math.max(Math.floor(w*f+o*2),Math.floor(d+o*2))}handleEllipsis(t,e,i=0,s="12px Arial"){this.ctx.save();let o=!1,r=t;if(this.ctx.font=s,t==null||t==="")return this.ctx.restore(),{_text:"",ellipsis:o};const a=this.ctx.measureText("...").width;if(e<=a+i*2)return this.ctx.restore(),{_text:"",ellipsis:!0};const l=this.ctx.measureText(t).width,h=e-i*2;if(l&&l+a>=h){o=!0;let d=0;for(let f=0;f<t.length;f++)if(d+=this.ctx.measureText(t[f]).width,d>=h-a){r=t.slice(0,f)+"...",o=!0;break}}return this.ctx.restore(),{_text:r,ellipsis:o}}}class It{constructor(t){n(this,"_config",{});n(this,"CSS_PREFIX","e-virt-table");n(this,"DRAW_TIME_MULTIPLIER",2);n(this,"ICONS",[]);n(this,"ROW_KEY","");n(this,"DISABLED",!1);n(this,"HEADER_FONT","12px normal Arial");n(this,"BODY_FONT","12px normal Arial");n(this,"BORDER",!0);n(this,"STRIPE",!1);n(this,"STRIPE_COLOR","#fafafa");n(this,"BORDER_COLOR","#e1e6eb");n(this,"WIDTH",0);n(this,"RESIZE_MIN_WIDTH",40);n(this,"HEIGHT",0);n(this,"PLACEHOLDER_COLOR","#CDD0DC");n(this,"EMPTY_BODY_HEIGHT",120);n(this,"EMPTY_CUSTOM_STYLE",{});n(this,"EMPTY_TEXT","暂无数据");n(this,"LOADING_TEXT","加载中...");n(this,"MAX_HEIGHT",1e3);n(this,"BORDER_RADIUS",8);n(this,"ENABLE_OFFSET_HEIGHT",!1);n(this,"OFFSET_HEIGHT",0);n(this,"HEADER_HEIGHT",36);n(this,"ENABLE_HEADER_STICKY",!1);n(this,"HEADER_BG_COLOR","#F8FAFF");n(this,"BODY_BG_COLOR","#FFF");n(this,"HEADER_TEXT_COLOR","#1D2129");n(this,"REQUIRED_COLOR","#F56C6C");n(this,"BODY_TEXT_COLOR","#4E5969");n(this,"FOOTER_TEXT_COLOR","#4E5969");n(this,"LOADING_ICON_SVG","");n(this,"LOADING_ICON_COLOR","#4E5969");n(this,"EXPAND_ICON_SVG","");n(this,"SHRINK_ICON_SVG","");n(this,"EXPAND_ICON_COLOR","#4E5969");n(this,"SHRINK_ICON_COLOR","#4E5969");n(this,"ERROR_TIP_ICON_COLOR","red");n(this,"ERROR_TIP_ICON_SIZE",6);n(this,"COLUMNS_ALIGN","left");n(this,"COLUMNS_VERTICAL_ALIGN","middle");n(this,"EXPAND_LAZY",!0);n(this,"DEFAULT_EXPAND_ALL",!1);n(this,"CELL_WIDTH",100);n(this,"CELL_HEIGHT",36);n(this,"CELL_PADDING",8);n(this,"CELL_HOVER_ICON_SIZE",14);n(this,"CELL_HOVER_ICON_BG_COLOR","#fff");n(this,"CELL_HOVER_ICON_BORDER_COLOR","#DDE0EA");n(this,"SCROLLER_TRACK_SIZE",14);n(this,"SCROLLER_SIZE",8);n(this,"SCROLLER_COLOR","#dee0e3");n(this,"SCROLLER_TRACK_COLOR","#fff");n(this,"SCROLLER_FOCUS_COLOR","#bbbec4");n(this,"SELECT_BORDER_COLOR","rgb(82,146,247)");n(this,"SELECT_AREA_COLOR","rgba(82,146,247,0.1)");n(this,"SELECT_ROW_COL_BG_COLOR","transparent");n(this,"AUTOFILL_POINT_BORDER_COLOR","#fff");n(this,"EDIT_BG_COLOR","#fcf6ed");n(this,"CHECKBOX_KEY","");n(this,"CHECKBOX_COLOR","rgb(82,146,247)");n(this,"CHECKBOX_SIZE",20);n(this,"CHECKBOX_DISABLED_SVG","");n(this,"CHECKBOX_DISABLED_COLOR","#F1F2F4");n(this,"CHECKBOX_CHECK_SVG","");n(this,"CHECKBOX_UNCHECK_SVG","");n(this,"CHECKBOX_UNCHECK_COLOR","#DDE0EA");n(this,"CHECKBOX_INDETERMINATE_SVG","");n(this,"CHECKBOX_CHECK_DISABLED_SVG","");n(this,"CHECKBOX_CHECK_DISABLED_COLOR","#DDE0EA");n(this,"ICON_EDIT_SVG","");n(this,"ICON_EDIT_COLOR","#4E5969");n(this,"ICON_SELECT_SVG","");n(this,"ICON_SELECT_COLOR","#4E5969");n(this,"SORT_STRICTLY",!0);n(this,"SORT_ASC_ICON_SVG","");n(this,"SORT_DESC_ICON_SVG","");n(this,"SORTABLE_ICON_SVG","");n(this,"SORT_ICON_COLOR","rgb(82,146,247)");n(this,"READONLY_COLOR","#fff");n(this,"READONLY_TEXT_COLOR","#4E5969");n(this,"ERROR_TIP_COLOR","#ED3F14");n(this,"FOOTER_BG_COLOR","#fafafa");n(this,"FOOTER_FIXED",!0);n(this,"FOOTER_POSITION","bottom");n(this,"CELL_FOOTER_HEIGHT",36);n(this,"ENABLE_SELECTOR",!0);n(this,"TREE_SELECT_MODE","auto");n(this,"TREE_INDENT",20);n(this,"TREE_ICON_SIZE",20);n(this,"TREE_LINE",!1);n(this,"TREE_LINE_COLOR","#e1e6eb");n(this,"ENABLE_EDIT_SINGLE_CLICK",!1);n(this,"ENABLE_EDIT_CLICK_SELECTOR",!0);n(this,"SELECTOR_AREA_MIN_X",0);n(this,"SELECTOR_AREA_MAX_X_OFFSET",0);n(this,"SELECTOR_AREA_MAX_X",0);n(this,"SELECTOR_AREA_MIN_Y",0);n(this,"SELECTOR_AREA_MAX_Y",0);n(this,"SELECTOR_AREA_MAX_Y_OFFSET",0);n(this,"SELECTOR_CELL_VALUE_TYPE","value");n(this,"ENABLE_AUTO_THEME",!0);n(this,"ENABLE_SELECTOR_SINGLE",!1);n(this,"ENABLE_SELECTOR_SPAN_COL",!0);n(this,"ENABLE_SELECTOR_SPAN_ROW",!0);n(this,"ENABLE_SELECTOR_ALL_ROWS",!0);n(this,"ENABLE_SELECTOR_ALL_COLS",!0);n(this,"ENABLE_MERGE_CELL_LINK",!1);n(this,"ENABLE_AUTOFILL",!1);n(this,"ENABLE_CONTEXT_MENU",!1);n(this,"ENABLE_COPY",!0);n(this,"ENABLE_PASTER",!0);n(this,"ENABLE_RESIZE_ROW",!0);n(this,"ENABLE_RESIZE_COLUMN",!0);n(this,"RESIZE_ROW_LINE_COLOR","#e1e6eb");n(this,"RESIZE_COLUMN_LINE_COLOR","#e1e6eb");n(this,"RESIZE_ROW_MIN_HEIGHT",36);n(this,"RESIZE_COLUMN_MIN_WIDTH",40);n(this,"ENABLE_KEYBOARD",!0);n(this,"ENABLE_HISTORY",!1);n(this,"ENABLE_VALIDATOR_IMMEDIATE",!0);n(this,"HISTORY_NUM",50);n(this,"HIGHLIGHT_HOVER_ROW",!1);n(this,"HIGHLIGHT_HOVER_ROW_COLOR","rgba(186,203,231,0.1)");n(this,"HIGHLIGHT_SELECTED_ROW",!1);n(this,"HIGHLIGHT_SELECTED_ROW_COLOR","rgba(82,146,247,0.1)");n(this,"TOOLTIP_BG_COLOR","#303133");n(this,"TOOLTIP_TEXT_COLOR","#fff");n(this,"TOOLTIP_ZINDEX",3e3);n(this,"TOOLTIP_CUSTOM_STYLE",{});n(this,"CONTEXT_MENU",[{label:"复制",value:"copy"},{label:"剪切",value:"cut"},{label:"粘贴",value:"paste"},{label:"清空选中内容",value:"clearSelected"}]);n(this,"CELL_LINE_HEIGHT",1.3);n(this,"AUTO_ROW_HEIGHT",!1);n(this,"HEADER_CELL_STYLE_METHOD");n(this,"BODY_CELL_STYLE_METHOD");n(this,"FOOTER_CELL_STYLE_METHOD");n(this,"BODY_CELL_READONLY_METHOD");n(this,"BODY_CELL_FORMATTER_METHOD");n(this,"BODY_CELL_RULES_METHOD");n(this,"BODY_CELL_TYPE_METHOD");n(this,"BODY_CELL_EDITOR_METHOD");n(this,"BODY_CELL_RENDER_METHOD");n(this,"BODY_CELL_HOVER_ICON_METHOD");n(this,"SPAN_METHOD");n(this,"SELECTABLE_METHOD");n(this,"EXPAND_LAZY_METHOD");n(this,"BEFORE_VALUE_CHANGE_METHOD");n(this,"BEFORE_PASTE_DATA_METHOD");n(this,"BEFORE_AUTOFILL_DATA_METHOD");n(this,"BEFORE_SET_SELECTOR_METHOD");n(this,"BEFORE_SET_AUTOFILL_METHOD");n(this,"BEFORE_COPY_METHOD");this._config=t,this.updateCssVar()}init(t){this._config=t,this.updateCssVar()}updateCssVar(){let t={};Object.keys(this).forEach(e=>{if(e.endsWith("_COLOR")||e.endsWith("_FONT")){const i=`--evt-${e.toLocaleLowerCase().replace(/_/g,"-")}`,s=xe(i);s&&(t[e]=s)}}),Object.assign(this,t,this._config)}}const St='<svg t="1722595535853" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4551" width="32" height="32"><path d="M640 128H384c-170.496 0-256 85.504-256 256v256c0 170.496 85.504 256 256 256h256c170.496 0 256-85.504 256-256V384c0-170.496-85.504-256-256-256z m67.584 302.592c-2.048 4.608-4.608 8.704-8.192 12.288L506.88 634.88c-3.584 3.584-7.68 6.144-12.288 8.192-4.608 2.048-9.728 3.072-14.848 3.072s-10.24-1.024-14.848-3.072c-4.608-2.048-8.704-4.608-12.288-8.192l-96.256-96.256c-3.584-3.584-6.144-7.68-8.192-12.288-2.048-4.608-3.072-9.728-3.072-14.848 0-2.56 0-5.12 1.024-7.68 0.512-2.56 1.024-5.12 2.048-7.168 1.024-2.56 2.048-4.608 3.584-6.656 1.536-2.048 3.072-4.096 4.608-5.632 1.536-2.048 3.584-3.584 5.632-4.608 2.048-1.536 4.096-2.56 6.656-3.584 2.56-1.024 4.608-1.536 7.168-2.048 2.56-0.512 5.12-0.512 7.68-0.512 5.12 0 10.24 1.024 14.848 3.072 4.608 2.048 8.704 4.608 12.288 8.192l69.12 68.608L645.12 389.12c3.584-3.584 7.68-6.144 12.288-8.192 4.608-2.048 9.728-3.072 14.848-3.072 2.56 0 5.12 0 7.68 0.512s5.12 1.024 7.168 2.048c2.56 1.024 4.608 2.048 6.656 3.584 2.048 1.536 4.096 3.072 5.632 4.608 1.536 1.536 3.584 3.584 4.608 5.632 1.536 2.048 2.56 4.096 3.584 6.656 1.024 2.56 1.536 4.608 2.048 7.168 0.512 2.56 1.024 5.12 1.024 7.68 0 5.12-1.024 10.24-3.072 14.848z" p-id="4552"></path></svg>',_t='<svg t="1724122044148" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4551" width="32" height="32"><path d="M707.648 401.28L489.28 560.704l22.656 30.976 22.656-30.976L316.16 401.216q-3.072-2.24-6.464-3.84-3.456-1.536-7.104-2.432-3.712-0.896-7.488-1.088-3.776-0.128-7.488 0.448-3.776 0.64-7.296 1.92-3.584 1.28-6.784 3.2-3.2 1.984-6.016 4.544-2.816 2.56-5.056 5.632-2.176 3.072-3.84 6.464-1.536 3.456-2.432 7.104-0.896 3.712-1.088 7.488-0.128 3.776 0.448 7.488 0.64 3.776 1.92 7.296 1.28 3.584 3.2 6.784 1.984 3.2 4.544 6.016 2.56 2.752 5.632 4.992l218.368 159.552q4.928 3.584 10.752 5.504 5.76 1.92 11.904 1.92 6.08 0 11.904-1.92 5.76-1.92 10.752-5.504l218.368-159.552q3.008-2.24 5.568-4.992 2.56-2.816 4.544-6.016 1.92-3.2 3.264-6.784 1.28-3.52 1.92-7.296 0.576-3.712 0.384-7.488-0.128-3.84-1.024-7.488-0.896-3.648-2.496-7.04-1.6-3.456-3.84-6.528-2.24-3.072-4.992-5.632-2.816-2.56-6.016-4.48-3.2-1.984-6.784-3.328-3.584-1.28-7.296-1.856-3.712-0.64-7.488-0.448-3.84 0.192-7.488 1.088-3.648 0.896-7.04 2.496-3.456 1.536-6.528 3.84z m61.056 30.976q0-3.84-0.768-7.488-0.704-3.712-2.176-7.232-1.472-3.456-3.52-6.656-2.112-3.136-4.8-5.76-2.688-2.688-5.76-4.8-3.2-2.112-6.72-3.584-3.456-1.408-7.168-2.176-3.712-0.704-7.488-0.704-3.84 0-7.488 0.704-3.712 0.768-7.232 2.176-3.456 1.472-6.656 3.584-3.136 2.112-5.76 4.8-2.688 2.624-4.8 5.76-2.112 3.2-3.584 6.656-1.408 3.52-2.176 7.232-0.704 3.712-0.704 7.488 0 3.776 0.704 7.488 0.768 3.712 2.176 7.168 1.472 3.52 3.584 6.656 2.112 3.2 4.8 5.824 2.624 2.688 5.76 4.8 3.2 2.112 6.656 3.52 3.52 1.472 7.232 2.176 3.712 0.768 7.488 0.768 3.776 0 7.488-0.768 3.712-0.704 7.168-2.176 3.52-1.408 6.656-3.52 3.2-2.112 5.824-4.8 2.688-2.688 4.8-5.76 2.048-3.2 3.52-6.72 1.472-3.456 2.176-7.168 0.768-3.712 0.768-7.488z m-436.736 0q0-3.84-0.768-7.488-0.704-3.712-2.176-7.232-1.408-3.456-3.52-6.656-2.112-3.136-4.8-5.76-2.688-2.688-5.76-4.8-3.2-2.112-6.656-3.584-3.52-1.408-7.232-2.176-3.712-0.704-7.488-0.704-3.84 0-7.488 0.704-3.712 0.768-7.232 2.176-3.456 1.472-6.592 3.584-3.2 2.112-5.824 4.8-2.688 2.624-4.8 5.76-2.112 3.2-3.52 6.656-1.472 3.52-2.24 7.232-0.704 3.712-0.704 7.488 0 3.776 0.704 7.488 0.768 3.712 2.24 7.168 1.408 3.52 3.52 6.656 2.112 3.2 4.8 5.824 2.624 2.688 5.76 4.8 3.2 2.112 6.656 3.52 3.52 1.472 7.232 2.176 3.712 0.768 7.488 0.768 3.776 0 7.488-0.768 3.712-0.704 7.232-2.176 3.456-1.408 6.592-3.52 3.2-2.112 5.824-4.8 2.688-2.688 4.8-5.76 2.112-3.2 3.52-6.72 1.472-3.456 2.176-7.168 0.768-3.712 0.768-7.488z" p-id="4552"></path></svg>',gt='<svg t="1755138507987" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5079" width="200" height="200"><path d="M512 938.688a42.688 42.688 0 0 1-35.072-18.432l-192-277.312A42.56 42.56 0 0 1 320 576h384a42.752 42.752 0 0 1 35.072 66.944l-192 277.312a42.688 42.688 0 0 1-35.072 18.432" fill="currentColor" p-id="2016"></path><path d="M704 448H320a42.752 42.752 0 0 1-35.072-66.944l192-277.312c16-23.04 54.208-23.04 70.144 0l192 277.312A42.56 42.56 0 0 1 704 448" fill="currentColor" p-id="2015"></path></svg>',ye=gt.replace('fill="currentColor" p-id="2016"','fill="#bec4c7" p-id="2016"'),Ce=gt.replace('fill="currentColor" p-id="2015"','fill="#bec4c7" p-id="2015"');class be{constructor(t){n(this,"ctx");n(this,"list",[{name:"loading",configName:"LOADING_ICON_SVG",configColorName:"LOADING_ICON_COLOR",svg:'<svg t="1724133395728" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2893" width="32" height="32"><path d="M512 226.8476541a19.82487759 19.82487759 0 0 1 14.66497778 5.70304692c3.80203107 3.82918865 5.70304692 8.71751457 5.70304693 14.66497779v122.20814825a19.82487759 19.82487759 0 0 1-5.70304693 14.66497778 19.82487759 19.82487759 0 0 1-14.66497778 5.70304691 19.82487759 19.82487759 0 0 1-14.66497778-5.70304691 19.82487759 19.82487759 0 0 1-5.70304693-14.66497778v-122.20814825a19.82487759 19.82487759 0 0 1 5.70304693-14.66497779 19.82487759 19.82487759 0 0 1 14.66497778-5.70304692z m0 407.36049415a19.82487759 19.82487759 0 0 1 14.66497778 5.70304691c3.80203107 3.82918865 5.70304692 8.71751457 5.70304693 14.66497778v122.20814827a19.82487759 19.82487759 0 0 1-5.70304693 14.66497776 19.82487759 19.82487759 0 0 1-14.66497778 5.70304693 19.82487759 19.82487759 0 0 1-14.66497778-5.70304693 19.82487759 19.82487759 0 0 1-5.70304693-14.66497776v-122.20814827a19.82487759 19.82487759 0 0 1 5.70304693-14.66497778 19.82487759 19.82487759 0 0 1 14.66497778-5.70304691zM797.1523459 512a19.82487759 19.82487759 0 0 1-5.70304692 14.66497778 19.82487759 19.82487759 0 0 1-14.66497779 5.70304693h-122.20814825a19.82487759 19.82487759 0 0 1-14.66497778-5.70304693 19.82487759 19.82487759 0 0 1-5.70304691-14.66497778 19.82487759 19.82487759 0 0 1 5.70304691-14.66497778 19.82487759 19.82487759 0 0 1 14.66497778-5.70304693h122.20814825a19.82487759 19.82487759 0 0 1 14.66497779 5.70304693c3.80203107 3.82918865 5.70304692 8.71751457 5.70304692 14.66497778z m-407.36049415 0a19.82487759 19.82487759 0 0 1-5.70304691 14.66497778 19.82487759 19.82487759 0 0 1-14.66497778 5.70304693h-122.20814827a19.82487759 19.82487759 0 0 1-14.66497776-5.70304693 19.82487759 19.82487759 0 0 1-5.70304693-14.66497778 19.82487759 19.82487759 0 0 1 5.70304693-14.66497778 19.82487759 19.82487759 0 0 1 14.66497776-5.70304693h122.20814827a19.82487759 19.82487759 0 0 1 14.66497778 5.70304693c3.80203107 3.82918865 5.70304692 8.71751457 5.70304691 14.66497778zM310.22076878 310.22076878a21.29137537 21.29137537 0 0 1 14.66497779-5.70304693c5.51294514 0 10.18401235 1.90101585 14.01320099 5.70304693l86.55052591 86.57768347a20.91117183 20.91117183 0 0 1 5.73020449 14.31193182 19.28172983 19.28172983 0 0 1-6.05609289 14.013201 19.11878565 19.11878565 0 0 1-14.013201 6.05609289 20.96548698 20.96548698 0 0 1-14.31193182-5.70304692L310.22076878 338.87178998a19.06447114 19.06447114 0 0 1-5.70304693-14.01320099c0-5.54010272 1.90101585-10.42842865 5.70304693-14.66497778z m288.32975775 288.32975775a19.79772001 19.79772001 0 0 1 14.3390894-6.35482371c5.29568642 0 10.04822572 2.11827457 14.31193182 6.38198066l86.57768347 86.55052651c3.80203107 3.80203107 5.70304692 8.47309828 5.70304691 14.01320102a19.55330372 19.55330372 0 0 1-6.05609225 14.31193182 19.66193339 19.66193339 0 0 1-14.31193245 6.05609288 19.01015661 19.01015661 0 0 1-14.01320099-5.70304692l-86.55052591-86.57768347a19.79772001 19.79772001 0 0 1-6.38198129-14.31193245c0-5.29568642 2.11827457-10.07538268 6.38198129-14.33908939zM713.77923122 310.22076878c3.80203107 4.26370672 5.70304692 9.15203265 5.70304693 14.66497779s-1.90101585 10.18401235-5.70304693 14.01320099l-86.57768347 86.55052591a20.91117183 20.91117183 0 0 1-14.31193182 5.73020449 19.28172983 19.28172983 0 0 1-14.013201-6.05609289 19.11878565 19.11878565 0 0 1-6.05609289-14.013201c0-5.29568642 1.90101585-10.07538268 5.70304692-14.31193182l86.57768348-86.57768347c3.80203107-3.80203107 8.50025585-5.70304692 14.01320099-5.70304693 5.54010272 0 10.40127108 1.90101585 14.66497779 5.70304693zM425.44947347 598.57768347a19.79772001 19.79772001 0 0 1 6.35482371 14.33908939c0 5.29568642-2.11827457 10.04822572-6.38198066 14.31193245L338.89894756 713.77923122a19.06447114 19.06447114 0 0 1-14.01320099 5.70304693 19.55330372 19.55330372 0 0 1-14.31193245-6.05609227 19.68909035 19.68909035 0 0 1-6.05609227-14.31193245 19.01015661 19.01015661 0 0 1 5.70304693-14.01320099l86.57768347-86.55052591a19.79772001 19.79772001 0 0 1 14.31193182-6.38198129c5.29568642 0 10.07538268 2.11827457 14.3390894 6.38198129z" fill="#000000" fill-opacity=".65" p-id="2894"></path></svg>',color:"#4E5969"},{name:"expand",configName:"EXPAND_ICON_SVG",configColorName:"EXPAND_ICON_COLOR",svg:'<svg t="1724122015492" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4237" width="32" height="32"><path d="M401.472 316.992l159.04 217.664L591.488 512l-30.976-22.656-159.04 217.728q-2.24 3.008-3.84 6.464-1.6 3.456-2.496 7.104-0.896 3.648-1.024 7.424-0.192 3.84 0.384 7.552 0.64 3.712 1.92 7.296 1.28 3.52 3.2 6.784 1.984 3.2 4.544 6.016 2.56 2.752 5.632 4.992 3.072 2.24 6.464 3.84 3.456 1.6 7.168 2.496 3.648 0.896 7.424 1.024 3.776 0.192 7.488-0.448 3.776-0.576 7.296-1.856 3.584-1.28 6.784-3.264 3.2-1.92 6.016-4.48 2.816-2.56 5.056-5.632l159.04-217.728q3.584-4.928 5.504-10.752 1.92-5.76 1.92-11.904 0-6.08-1.92-11.904-1.92-5.76-5.504-10.752L463.488 271.68q-2.24-3.072-5.056-5.632-2.752-2.56-6.016-4.48-3.2-1.984-6.784-3.328-3.52-1.28-7.296-1.856-3.712-0.576-7.488-0.448-3.84 0.192-7.424 1.088-3.712 0.896-7.168 2.496-3.392 1.6-6.4 3.84-3.136 2.176-5.696 4.992-2.56 2.752-4.48 6.016-1.984 3.2-3.264 6.784-1.28 3.52-1.92 7.296-0.576 3.712-0.384 7.488 0.128 3.84 1.024 7.488 0.896 3.648 2.496 7.04 1.6 3.456 3.84 6.528z m30.976-61.056q-3.776 0-7.488 0.704-3.712 0.768-7.168 2.24-3.52 1.408-6.656 3.52-3.2 2.112-5.824 4.8-2.688 2.624-4.8 5.76-2.112 3.2-3.52 6.656-1.472 3.52-2.176 7.232-0.768 3.712-0.768 7.488 0 3.776 0.768 7.488 0.704 3.712 2.176 7.232 1.408 3.456 3.52 6.592 2.112 3.2 4.8 5.824 2.688 2.688 5.76 4.8 3.2 2.112 6.72 3.52 3.456 1.472 7.168 2.176 3.712 0.768 7.488 0.768 3.84 0 7.488-0.768 3.712-0.704 7.232-2.176 3.456-1.408 6.592-3.52 3.2-2.112 5.824-4.8 2.688-2.688 4.8-5.76 2.112-3.2 3.52-6.656 1.472-3.52 2.24-7.232 0.704-3.712 0.704-7.488 0-3.84-0.704-7.488-0.768-3.712-2.24-7.232-1.408-3.456-3.52-6.592-2.112-3.2-4.8-5.824-2.624-2.688-5.76-4.8-3.2-2.112-6.656-3.52-3.52-1.472-7.232-2.24Q436.224 256 432.448 256z m0 435.392q-3.776 0-7.488 0.704-3.712 0.768-7.168 2.176-3.52 1.472-6.656 3.584-3.2 2.112-5.824 4.736-2.688 2.688-4.8 5.824-2.112 3.2-3.52 6.656-1.472 3.52-2.176 7.232-0.768 3.712-0.768 7.488 0 3.776 0.768 7.488 0.704 3.712 2.176 7.168 1.408 3.52 3.52 6.656 2.112 3.2 4.8 5.76 2.688 2.752 5.76 4.8 3.2 2.112 6.72 3.584 3.456 1.472 7.168 2.176 3.712 0.768 7.488 0.768 3.84 0 7.488-0.768 3.712-0.704 7.232-2.176 3.456-1.472 6.592-3.584 3.2-2.048 5.824-4.736 2.688-2.688 4.8-5.824 2.112-3.2 3.52-6.656 1.472-3.456 2.24-7.168 0.704-3.712 0.704-7.488 0-3.84-0.704-7.488-0.768-3.712-2.24-7.232-1.408-3.52-3.52-6.656-2.112-3.136-4.8-5.76-2.624-2.688-5.76-4.8-3.2-2.112-6.656-3.584-3.52-1.408-7.232-2.176-3.712-0.704-7.488-0.704z" p-id="4238"></path></svg>',color:"#4E5969"},{name:"shrink",configName:"SHRINK_ICON_SVG",configColorName:"SHRINK_ICON_COLOR",svg:_t,color:"#4E5969"},{name:"checkbox-uncheck",configName:"CHECKBOX_UNCHECK_SVG",configColorName:"CHECKBOX_UNCHECK_COLOR",svg:'<svg t="1722595639920" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4708" width="32" height="32"><path d="M128 640V384a256 256 0 0 1 256-256h256a256 256 0 0 1 256 256v256a256 256 0 0 1-256 256H384a256 256 0 0 1-256-256z m64 0q0 79.552 56.256 135.744Q304.448 832 384 832h256q79.552 0 135.744-56.256Q832 719.552 832 640V384q0-79.552-56.256-135.744Q719.552 192 640 192H384q-79.552 0-135.744 56.256Q192 304.448 192 384v256z" p-id="4709"></path></svg>',color:""},{name:"checkbox-check",configName:"CHECKBOX_CHECK_SVG",configColorName:"CHECKBOX_COLOR",svg:St,color:"rgb(82,146,247)"},{name:"checkbox-indeterminate",configName:"CHECKBOX_INDETERMINATE_SVG",configColorName:"CHECKBOX_COLOR",svg:'<svg t="1722595280953" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4394" width="32" height="32"><path d="M128 384v256q0 12.608 1.28 25.088 1.216 12.544 3.648 24.832 2.432 12.352 6.08 24.384t8.448 23.68q4.864 11.584 10.752 22.72 5.952 11.072 12.928 21.504 7.04 10.496 14.976 20.224 8 9.728 16.896 18.56 8.896 8.96 18.56 16.896 9.728 8 20.224 14.976 10.432 7.04 21.504 12.928 11.136 5.888 22.72 10.688 11.648 4.864 23.68 8.512 12.032 3.648 24.32 6.08 12.352 2.432 24.896 3.712Q371.392 896 384 896h256q12.608 0 25.088-1.28 12.544-1.216 24.832-3.648 12.352-2.432 24.384-6.08t23.68-8.512q11.584-4.8 22.72-10.688 11.072-5.952 21.504-12.928 10.496-7.04 20.224-14.976 9.728-8 18.56-16.896 8.96-8.832 16.896-18.56 8-9.728 14.976-20.224 7.04-10.432 12.928-21.504 5.888-11.136 10.688-22.72 4.864-11.648 8.512-23.68 3.648-12.032 6.08-24.32 2.432-12.352 3.712-24.896Q896 652.608 896 640V384q0-12.608-1.28-25.088-1.216-12.544-3.648-24.832-2.432-12.352-6.08-24.384t-8.512-23.68q-4.8-11.584-10.688-22.72-5.952-11.072-12.928-21.504-7.04-10.496-14.976-20.224-8-9.664-16.896-18.56-8.832-8.96-18.56-16.896-9.728-8-20.224-14.976-10.432-7.04-21.504-12.928-11.136-5.888-22.72-10.752-11.648-4.8-23.68-8.448-12.032-3.648-24.32-6.08-12.352-2.432-24.896-3.712Q652.608 128 640 128H384q-12.608 0-25.088 1.28-12.544 1.216-24.832 3.648-12.352 2.432-24.384 6.08t-23.68 8.448q-11.584 4.864-22.72 10.752-11.072 5.952-21.504 12.928-10.496 7.04-20.224 14.976-9.664 8-18.56 16.896-8.96 8.896-16.896 18.56-8 9.728-14.976 20.224-7.04 10.432-12.928 21.504-5.888 11.136-10.752 22.72-4.8 11.648-8.448 23.68-3.648 12.032-6.08 24.32-2.432 12.352-3.712 24.896Q128 371.392 128 384z m566.016 166.336H330.112a38.4 38.4 0 0 1 0-76.8h363.904a38.4 38.4 0 0 1 0 76.8z" p-id="4395"></path></svg>',color:"rgb(82,146,247)"},{name:"checkbox-check-disabled",configName:"CHECKBOX_CHECK_DISABLED_SVG",svg:St,color:"#DDE0EA"},{name:"checkbox-disabled",configName:"CHECKBOX_DISABLED_SVG",configColorName:"CHECKBOX_DISABLED_COLOR",svg:'<svg t="1722595946663" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4865" width="32" height="32"><path d="M128 640V384a256 256 0 0 1 256-256h256a256 256 0 0 1 256 256v256a256 256 0 0 1-256 256H384a256 256 0 0 1-256-256z" p-id="4866"></path><path d="M128 640V384a256 256 0 0 1 256-256h256a256 256 0 0 1 256 256v256a256 256 0 0 1-256 256H384a256 256 0 0 1-256-256z m64 0q0 79.552 56.256 135.744Q304.448 832 384 832h256q79.552 0 135.744-56.256Q832 719.552 832 640V384q0-79.552-56.256-135.744Q719.552 192 640 192H384q-79.552 0-135.744 56.256Q192 304.448 192 384v256z" fill="#DDE0EA" p-id="4867"></path></svg>',color:"#F1F2F4"},{name:"icon-edit",configName:"ICON_EDIT_SVG",configColorName:"ICON_EDIT_COLOR",svg:'<svg t="1744798692576" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6606" width="200" height="200"><path d="M855.296 894.528H168.768v-76.8h686.528v76.8z m38.4-38.4q0 3.84-0.768 7.488-0.704 3.712-2.176 7.232-1.472 3.52-3.52 6.656-2.112 3.136-4.8 5.76-2.688 2.688-5.824 4.8-3.2 2.112-6.656 3.584-3.456 1.408-7.168 2.176-3.712 0.704-7.488 0.704-3.84 0-7.488-0.704-3.712-0.768-7.232-2.176-3.52-1.472-6.656-3.584-3.136-2.112-5.76-4.736-2.688-2.688-4.8-5.824-2.112-3.2-3.584-6.656-1.408-3.52-2.176-7.232-0.704-3.648-0.704-7.488 0-3.776 0.704-7.488 0.768-3.712 2.176-7.168 1.472-3.52 3.584-6.656 2.112-3.136 4.736-5.76 2.688-2.752 5.824-4.8 3.2-2.112 6.656-3.584 3.52-1.472 7.232-2.176 3.712-0.768 7.488-0.768 3.776 0 7.488 0.768 3.712 0.704 7.168 2.176 3.52 1.472 6.656 3.584 3.2 2.048 5.76 4.736 2.752 2.688 4.864 5.824 2.048 3.2 3.52 6.656 1.472 3.456 2.176 7.168 0.768 3.712 0.768 7.488z m-686.528 0q0 3.84-0.768 7.488-0.704 3.712-2.176 7.232-1.472 3.52-3.52 6.656-2.112 3.136-4.8 5.76-2.688 2.688-5.76 4.8-3.2 2.112-6.72 3.584-3.456 1.408-7.168 2.176-3.712 0.704-7.488 0.704-3.84 0-7.488-0.704-3.712-0.768-7.232-2.176-3.456-1.472-6.656-3.584-3.136-2.112-5.76-4.736-2.688-2.688-4.8-5.824-2.112-3.2-3.584-6.656-1.408-3.52-2.176-7.232-0.704-3.648-0.704-7.488 0-3.776 0.704-7.488 0.768-3.712 2.176-7.168 1.472-3.52 3.584-6.656 2.112-3.136 4.736-5.76 2.688-2.752 5.824-4.8 3.2-2.112 6.656-3.584 3.52-1.472 7.232-2.176 3.712-0.768 7.488-0.768 3.776 0 7.488 0.768 3.712 0.704 7.168 2.176 3.52 1.472 6.656 3.584 3.2 2.048 5.824 4.736 2.688 2.688 4.8 5.824 2.048 3.2 3.52 6.656 1.472 3.456 2.176 7.168 0.768 3.712 0.768 7.488zM652.032 211.2l-369.92 370.368v89.344h90.048l369.664-369.856L652.032 211.2z m-54.4-54.272q22.528-22.528 54.4-22.528 31.808 0 54.336 22.528l89.792 89.856q22.464 22.464 22.464 54.272t-22.464 54.272l-369.664 369.856q-22.464 22.528-54.336 22.528H282.24q-31.808 0-54.336-22.528-22.464-22.464-22.464-54.272V581.568q0-31.808 22.4-54.272l369.92-370.368z" p-id="6607"></path></svg>',color:"#4E5969"},{name:"icon-select",configName:"ICON_SELECT_SVG",configColorName:"ICON_SELECT_COLOR",svg:_t,color:"#4E5969"},{name:"sort-asc",configName:"SORT_ASC_ICON_SVG",configColorName:"SORT_ICON_COLOR",svg:ye,color:"rgb(82,146,247)"},{name:"sort-desc",configName:"SORT_DESC_ICON_SVG",configColorName:"SORT_ICON_COLOR",svg:Ce,color:"rgb(82,146,247)"},{name:"sort-default",configName:"SORTABLE_ICON_SVG",svg:gt,color:"#bec4c7"}]);n(this,"icons",new Map);this.ctx=t,this.init()}async init(){const t=[];for(let e=0;e<this.list.length;e++){const i=this.list[e];let s=i.color,o=i.svg;if(i.configColorName){const a=this.ctx.config[i.configColorName];a&&(s=a)}if(i.configName){const a=this.ctx.config[i.configName];a&&(o=a)}const r=this.createImageFromSVG(o,s).then(a=>{this.icons.set(i.name,a)});t.push(r)}for(let e=0;e<this.ctx.config.ICONS.length;e++){const i=this.ctx.config.ICONS[e];let s=i.color;const o=this.createImageFromSVG(i.svg,s,i.isBlob).then(r=>{this.icons.set(i.name,r)});t.push(o)}await Promise.all(t),this.ctx.emit("draw")}async createImageFromSVG(t,e,i=!1){const r=new DOMParser().parseFromString(t,"image/svg+xml").documentElement;e&&r.querySelectorAll("*").forEach(h=>{const d=h.getAttribute("fill");(d==="currentColor"||d===null)&&h.setAttribute("fill",e)});const a=new Image;let l="";if(i){const h=new Blob([new XMLSerializer().serializeToString(r)],{type:"image/svg+xml"});l=URL.createObjectURL(h)}else l="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(new XMLSerializer().serializeToString(r));return a.src=l,new Promise((h,d)=>{a.onerror=()=>d(new Error("Failed to load image:"+t)),a.onload=()=>{h(a)}})}get(t){return this.icons.get(t)}getSvg(t){return this.list.find(e=>e.name===t)}}class ct extends Bt{constructor(e,i,s,o,r,a,l){super(e,s,o,r,a,"header",l.fixed);n(this,"align");n(this,"hideHeaderSelection",!1);n(this,"verticalAlign","middle");n(this,"fixed");n(this,"minWidth");n(this,"maxWidth");n(this,"widthFillDisable");n(this,"type");n(this,"operation",!1);n(this,"editorType");n(this,"level");n(this,"text");n(this,"displayText","");n(this,"colspan");n(this,"rowspan");n(this,"row");n(this,"key");n(this,"required",!1);n(this,"readonly",!1);n(this,"ellipsis",!1);n(this,"overflowTooltipShow",!0);n(this,"children",[]);n(this,"column");n(this,"colIndex");n(this,"rowKey");n(this,"rules");n(this,"hasChildren");n(this,"render");n(this,"style",{});n(this,"drawX",0);n(this,"drawY",0);n(this,"sortIconName","sort-default");n(this,"sortAscIconName","sort-asc");n(this,"sortDescIconName","sort-desc");n(this,"visibleWidth",0);n(this,"visibleHeight",0);n(this,"maxLineClamp","auto");n(this,"domDataset",{});n(this,"drawTextX",0);n(this,"drawTextY",0);n(this,"drawTextWidth",0);n(this,"drawTextHeight",0);n(this,"drawCellBgColor","");n(this,"drawTextColor","");n(this,"drawSelectionImageX",0);n(this,"drawSelectionImageY",0);n(this,"drawSelectionImageWidth",0);n(this,"drawSelectionImageHeight",0);n(this,"drawSelectionImageName","");n(this,"drawSelectionImageSource");n(this,"drawSortImageX",0);n(this,"drawSortImageY",0);n(this,"drawSortImageWidth",0);n(this,"drawSortImageHeight",0);n(this,"drawSortImageName","");n(this,"drawSortImageSource");this.ctx=e,this.x=s,this.y=o,this.width=r,this.height=a,this.visibleWidth=r,this.visibleHeight=a,this.colIndex=i,this.key=l.key,this.minWidth=l.minWidth,this.maxWidth=l.maxWidth,this.type=l.type||"",this.editorType=l.editorType||"text",this.hideHeaderSelection=l.hideHeaderSelection||!1,this.align=l.headerAlign||l.align||this.ctx.config.COLUMNS_ALIGN,this.verticalAlign=l.headerVerticalAlign||l.verticalAlign||this.ctx.config.COLUMNS_VERTICAL_ALIGN,this.fixed=l.fixed,this.level=l.level||0,this.operation=l.operation||!1,this.text=l.title,this.column=l,this.colspan=l.colspan||1,this.widthFillDisable=l.widthFillDisable||!1,this.rowspan=l.rowspan||1,this.rules=l.rules,this.readonly=l.readonly||!1,this.required=l.required||!1,this.sortIconName=l.sortIconName||"sort-default",this.sortAscIconName=l.sortAscIconName||"sort-asc",this.sortDescIconName=l.sortDescIconName||"sort-desc",this.rowKey=Dt(),this.overflowTooltipShow=l.overflowTooltipHeaderShow!==!1,this.hasChildren=l.children&&l.children.length>0||!1,this.render=l.renderHeader}isVerticalVisible(){const{stageHeight:e}=this.ctx,i=e;return!(this.y+this.height<=0||this.y>=i)}updateStyle(){this.style=this.getOverlayerViewsStyle()}updateContainer(){const{HEADER_CELL_STYLE_METHOD:e,HEADER_BG_COLOR:i,HEADER_TEXT_COLOR:s}=this.ctx.config;let o=i,r=s;if(typeof e=="function"){const a=e,{backgroundColor:l,color:h}=a({colIndex:this.colIndex,column:this.column})||{};l&&(o=l),h&&(r=h)}this.drawCellBgColor=o,this.drawTextColor=r}update(){this.updateContainer(),this.displayText=this.getText(),this.drawX=this.getDrawX(),this.drawY=this.getDrawY(),this.drawTextX=this.drawX,this.drawTextY=this.drawY,this.drawTextWidth=this.width,this.drawTextHeight=this.height,this.updateStyle()}draw(){this.drawEdge(),this.drawSelection(),this.drawText(),this.drawSelector(),this.drawSortIcon()}drawEdge(){const{paint:e,config:{BORDER_COLOR:i,BORDER:s}}=this.ctx;e.drawRect(this.drawX,this.drawY,this.width,this.height,{borderColor:s?i:"transparent",fillColor:this.drawCellBgColor})}drawText(){const{paint:e,config:{HEADER_FONT:i,CELL_PADDING:s,REQUIRED_COLOR:o}}=this.ctx,r=`${this.displayText}_${this.drawTextWidth}`;this.ellipsis=e.drawText(this.displayText,this.drawTextX,this.drawTextY,this.drawTextWidth,this.drawTextHeight,{font:i,padding:s,color:this.drawTextColor,align:this.align,verticalAlign:this.verticalAlign,maxLineClamp:this.maxLineClamp,offsetRight:this.column.sortBy?16:0,offsetLeft:this.required?12:0,cacheTextKey:r,textCallback:a=>{this.column.sortBy&&(this.drawSortImageX=a.right+4,this.drawSortImageY=a.top+(a.height-16)/2),this.required&&e.drawText("*",a.left-18,a.top+(a.height-12)/2,24,24,{color:o,font:"18px Arial",align:"center",verticalAlign:"middle",padding:0})}})}drawSelector(){const{ENABLE_SELECTOR:e}=this.ctx.config;if(!e)return;const{xArr:i}=this.ctx.selector,[s,o]=i;this.colIndex>=s&&this.colIndex<=o&&this.ctx.paint.drawRect(this.drawX,this.drawY,this.width,this.height,{borderColor:"transparent",fillColor:this.ctx.config.SELECT_ROW_COL_BG_COLOR||"transparent"})}drawSelection(){if(!this.hideHeaderSelection&&["index-selection","selection","selection-tree","tree-selection"].includes(this.type)){const{indeterminate:e,check:i,selectable:s}=this.ctx.database.getCheckedState(),{CHECKBOX_SIZE:o=0,CELL_PADDING:r}=this.ctx.config;let a=this.drawX+(this.width-o)/2,l=this.drawY+(this.height-o)/2;this.drawTextX=a+o-r/2,this.drawTextWidth=this.drawX+this.visibleWidth-this.drawTextX,(this.align==="left"||this.align==="right")&&(a=this.drawX+r,this.drawTextX=a+o-r/2,this.drawTextWidth=this.drawX+this.visibleWidth-this.drawTextX),this.verticalAlign==="top"?l=this.drawY+r/2:this.verticalAlign==="bottom"&&(l=this.drawY+this.height-o-r/2);let h=this.ctx.icons.get("checkbox-uncheck"),d="checkbox-uncheck";e?(h=this.ctx.icons.get("checkbox-indeterminate"),d="checkbox-indeterminate"):i&&s?(h=this.ctx.icons.get("checkbox-check"),d="checkbox-check"):i&&!s?(h=this.ctx.icons.get("checkbox-check-disabled"),d="checkbox-check-disabled"):!i&&s?(h=this.ctx.icons.get("checkbox-uncheck"),d="checkbox-uncheck"):(h=this.ctx.icons.get("checkbox-disabled"),d="checkbox-disabled"),h&&(this.drawSelectionImageX=a,this.drawSelectionImageY=l,this.drawSelectionImageWidth=o,this.drawSelectionImageHeight=o,this.drawSelectionImageName=d,this.drawSelectionImageSource=h,this.ctx.paint.drawImage(this.drawSelectionImageSource,this.drawSelectionImageX,this.drawSelectionImageY,this.drawSelectionImageWidth,this.drawSelectionImageHeight))}}drawSortIcon(){if(!this.column.sortBy)return;const e=16;let i=this.sortIconName;const s=this.ctx.database.getSortState(this.key);s.direction==="asc"?i=this.sortAscIconName:s.direction==="desc"&&(i=this.sortDescIconName);const o=this.ctx.icons.get(i);o&&(this.drawSortImageWidth=e,this.drawSortImageHeight=e,this.drawSortImageName=i,this.drawSortImageSource=o,this.ctx.paint.drawImage(this.drawSortImageSource,this.drawSortImageX,this.drawSortImageY,this.drawSortImageWidth,this.drawSortImageHeight))}getText(){return this.render||["",null,void 0].includes(this.text)?"":`${this.text}`}getOverlayerViewsStyle(){let e="";return this.fixed==="left"?e=`${this.drawX}px`:this.fixed==="right"?e=`${this.drawX-(this.ctx.stageWidth-this.ctx.fixedRightWidth)}px`:e=`${this.drawX-this.ctx.fixedLeftWidth}px`,{position:"absolute",overflow:"hidden",left:e,top:`${this.drawY+1}px`,width:`${this.width}px`,height:`${this.height-2}px`,pointerEvents:"initial",userSelect:"none"}}}class Re{constructor(t){n(this,"ctx");n(this,"visibleHoverCell");n(this,"resizeObserver");n(this,"mutationObserver");this.ctx=t,this.init()}init(){this.resizeObserver=new ResizeObserver(()=>{this.ctx.emit("resetHeader"),this.ctx.emit("resizeObserver")}),this.resizeObserver.observe(this.ctx.containerElement),this.mutationObserver=new MutationObserver(t=>{for(const e of t)e.type==="attributes"&&e.attributeName==="class"&&(this.ctx.config.updateCssVar(),this.ctx.emit("draw"))}),this.ctx.config.ENABLE_AUTO_THEME&&this.mutationObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),this.ctx.on("mousedown",t=>{if(t.button!==0||this.isBusy(t))return;const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,o=i;this.handleHeaderEvent(o,s,this.ctx.header.renderCellHeaders,r=>{this.ctx.focusCellHeader=r,this.ctx.emit("cellHeaderMousedown",r,t)}),this.handleBodyEvent(o,s,this.ctx.body.renderRows,r=>{this.ctx.setFocusCell(r),this.ctx.emit("cellMousedown",r,t)})}),this.ctx.on("mouseup",t=>{if(t.button!==0||this.isBusy(t))return;const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,o=i;this.handleHeaderEvent(o,s,this.ctx.header.renderCellHeaders,r=>{this.ctx.focusCellHeader=r,this.ctx.emit("cellHeaderMouseup",r,t)}),this.handleBodyEvent(o,s,this.ctx.body.renderRows,r=>{this.ctx.setFocusCell(r),this.ctx.emit("cellMouseup",r,t)})}),this.ctx.on("click",t=>{if(t.button!==0||this.isBusy(t))return;const e=this.ctx.getOffset(t).offsetY,i=this.ctx.getOffset(t).offsetX;this.handleHeaderEvent(i,e,this.ctx.header.renderCellHeaders,s=>{this.ctx.clickCellHeader=s,this.ctx.emit("cellHeaderClick",s,t),this.selectionClick(s,t),this.sortClick(s,t)}),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{this.ctx.clickCell=s,this.ctx.emit("cellClick",s,t),this.selectionClick(s,t),this.treeClick(s,t)},!0),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{this.hoverIconClick(s)},!1)}),this.ctx.on("dblclick",t=>{if(t.button!==0||this.isBusy(t))return;const e=this.ctx.getOffset(t).offsetY,i=this.ctx.getOffset(t).offsetX;this.handleHeaderEvent(i,e,this.ctx.header.renderCellHeaders,s=>{this.ctx.emit("cellHeaderDblclick",s,t)}),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{this.ctx.clickCell=s,this.ctx.emit("cellDblclick",s,t)})}),this.ctx.on("contextMenu",t=>{if(this.isBusy(t))return;const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,o=i;this.handleHeaderEvent(o,s,this.ctx.header.renderCellHeaders,r=>{this.ctx.emit("cellHeaderContextMenuClick",r,t)}),this.handleBodyEvent(o,s,this.ctx.body.renderRows,r=>{this.ctx.emit("cellContextMenuClick",r,t)})}),this.ctx.on("mouseout",t=>{!this.ctx.containerElement.contains(t.relatedTarget)&&this.ctx.hoverCell!==void 0&&(this.ctx.hoverRow=void 0,this.ctx.hoverCell=void 0,this.ctx.emit("draw"))}),this.ctx.on("mousemove",t=>{if(this.isBusy(t))return;this.ctx.isPointer=!1,this.ctx.stageElement.style.cursor==="pointer"&&(this.ctx.stageElement.style.cursor="default");const e=this.ctx.getOffset(t).offsetY,i=this.ctx.getOffset(t).offsetX;this.handleHeaderEvent(i,e,this.ctx.header.renderCellHeaders,s=>{this.ctx.emit("cellHeaderMouseenter",s,t),this.ctx.hoverCellHeader&&this.ctx.hoverCellHeader!==s&&this.ctx.emit("cellHeaderMouseleave",this.ctx.hoverCellHeader,t),this.imageEnterAndLeave(s,t),this.ctx.hoverCellHeader!==s&&(this.ctx.hoverCellHeader=s,this.visibleHoverCell=void 0,this.ctx.emit("cellHeaderHoverChange",s,t))}),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{this.imageEnterAndLeave(s,t),this.visibleHoverCell!==s&&(this.ctx.emit("visibleCellMouseleave",s,t),this.visibleHoverCell=s,this.ctx.hoverCellHeader=void 0,this.ctx.emit("visibleCellHoverChange",s,t))},!0),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{var o;this.imageEnterAndLeave(s,t),this.ctx.emit("cellMouseenter",s,t),this.ctx.hoverCell&&this.ctx.hoverCell!==s&&this.ctx.emit("cellMouseleave",s,t),this.ctx.hoverCell!==s&&(((o=this.ctx.hoverCell)==null?void 0:o.rowKey)!==s.rowKey&&(this.ctx.hoverCell=s,this.ctx.hoverRow=this.ctx.body.renderRows.find(r=>r.rowKey===s.rowKey),this.ctx.emit("rowHoverChange",this.ctx.hoverRow,s,t),this.ctx.emit("drawView")),this.ctx.hoverCell=s,this.ctx.emit("cellHoverChange",s,t))})})}hoverIconClick(t){t.hoverIconName&&this.ctx.isPointer&&this.ctx.emit("hoverIconClick",t)}selectionClick(t,e){if(!(["selection","index-selection","selection-tree","tree-selection"].includes(t.type)&&this.ctx.isPointer))return;const{offsetY:s,offsetX:o}=this.ctx.getOffset(e),r=s,a=o;if(this.isInsideElement(a,r,t.drawSelectionImageX,t.drawSelectionImageY,t.drawSelectionImageWidth,t.drawSelectionImageHeight))if(t instanceof ct)t.drawSelectionImageName==="checkbox-uncheck"||t.drawSelectionImageName==="checkbox-indeterminate"?this.ctx.database.toggleAllSelection():t.drawSelectionImageName==="checkbox-check"&&this.ctx.database.clearSelection(!0);else{if(!this.ctx.database.getRowSelectable(t.rowKey))return;this.ctx.database.toggleRowSelection(t.rowKey,t.type)}}treeClick(t,e){if(!(["tree","selection-tree","tree-selection"].includes(t.type)&&this.ctx.isPointer))return;const{offsetY:s,offsetX:o}=this.ctx.getOffset(e),r=s,a=o;if(!this.isInsideElement(a,r,t.drawTreeImageX,t.drawTreeImageY,t.drawTreeImageWidth,t.drawTreeImageHeight))return;const l=this.ctx.database.getRowForRowKey(t.rowKey),{expand:h=!1,expandLazy:d=!1}=l||{},{EXPAND_LAZY:f,EXPAND_LAZY_METHOD:u}=this.ctx.config;if(f&&u&&!h&&!d)typeof u=="function"&&(this.ctx.database.expandLoading(t.rowKey,!0),u({row:t.row,rowIndex:t.rowIndex,colIndex:t.colIndex,column:t.column,value:t.getValue()}).then(w=>{this.ctx.database.setExpandChildren(t.rowKey,w),this.ctx.database.expandLoading(t.rowKey,!1),this.ctx.emit("expandChange",this.ctx.database.getExpandRowKeys())}).catch(w=>{this.ctx.database.expandLoading(t.rowKey,!1),console.error(w)}));else{const x=this.ctx.database.getIsExpand(t.rowKey);this.ctx.database.expandItem(t.rowKey,!x),this.ctx.emit("expandChange",this.ctx.database.getExpandRowKeys())}}sortClick(t,e){const{offsetY:i,offsetX:s}=this.ctx.getOffset(e),o=i,r=s;if(!this.isInsideElement(r,o,t.drawSortImageX,t.drawSortImageY,t.drawSortImageWidth,t.drawSortImageHeight))return;const a=this.ctx.database.getSortState(t.key);let l;a.direction==="none"?l="asc":a.direction==="asc"?l="desc":l="none",this.ctx.database.setSortState(t.key,l)}imageEnterAndLeave(t,e){const{offsetY:i,offsetX:s}=this.ctx.getOffset(e),o=i,r=s;if(t instanceof ct){if(t.drawSelectionImageSource&&this.isInsideElement(r,o,t.drawSelectionImageX,t.drawSelectionImageY,t.drawSelectionImageWidth,t.drawSelectionImageHeight)){this.ctx.stageElement.style.cursor="pointer",this.ctx.isPointer=!0;return}if(t.drawSortImageSource&&this.isInsideElement(r,o,t.drawSortImageX,t.drawSortImageY,t.drawSortImageWidth,t.drawSortImageHeight)){this.ctx.stageElement.style.cursor="pointer",this.ctx.isPointer=!0;return}}if(t instanceof ut){if(t.drawSelectionImageSource&&this.isInsideElement(r,o,t.drawSelectionImageX,t.drawSelectionImageY,t.drawSelectionImageWidth,t.drawSelectionImageHeight)){this.ctx.stageElement.style.cursor="pointer",this.ctx.isPointer=!0,this.ctx.database.getRowSelectable(t.rowKey)||(this.ctx.stageElement.style.cursor="not-allowed");return}if(t.drawHoverImageSource&&this.isInsideElement(r,o,t.drawHoverImageX,t.drawHoverImageY,t.drawHoverImageWidth,t.drawHoverImageHeight)){this.ctx.stageElement.style.cursor="pointer",this.ctx.isPointer=!0;return}if(t.drawTreeImageSource&&this.isInsideElement(r,o,t.drawTreeImageX,t.drawTreeImageY,t.drawTreeImageWidth,t.drawTreeImageHeight)){this.ctx.stageElement.style.cursor="pointer",this.ctx.isPointer=!0;return}}}isInsideElement(t,e,i,s,o,r){return t>i&&t<i+o&&e>s&&e<s+r}isBusy(t){const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,o=i;if(this.ctx.loading||!this.ctx.isTarget(t)||this.ctx.stageElement.style.cursor==="row-resize"||this.ctx.stageElement.style.cursor==="col-resize"||this.ctx.columnResizing||this.ctx.rowResizing)return!0;const{SCROLLER_TRACK_SIZE:r}=this.ctx.config;return!!(this.ctx.scrollerMove||this.ctx.scrollerFocus||s>this.ctx.stageHeight-r||o>this.ctx.stageWidth-r)}handleBodyEvent(t,e,i,s,o=!1){if(this.isInsideBody(e))for(const r of i){const a=r.fixedCells.concat(r.noFixedCells);for(const l of a){const h=l.getDrawX(),d=l.getDrawY();if(o){if(t>h&&t<h+l.visibleWidth&&e>d&&e<d+l.visibleHeight){s(l);return}}else if(t>h&&t<h+l.width&&e>d&&e<d+l.height){s(l);return}}}}handleHeaderEvent(t,e,i,s){for(const o of i){const r=o.getDrawX(),a=o.getDrawY();if(t>r&&t<r+o.width&&e>a&&e<a+o.height){s(o);return}}}isInsideBody(t){return t>this.ctx.body.y&&t<this.ctx.body.y+this.ctx.body.visibleHeight}destroy(){this.resizeObserver.unobserve(this.ctx.stageElement),this.mutationObserver.disconnect()}}class Ie{constructor(t,e){n(this,"eventBus");n(this,"eventBrowser");n(this,"eventTable");n(this,"containerElement");n(this,"stageElement");n(this,"canvasElement");n(this,"overlayerElement");n(this,"editorElement");n(this,"emptyElement");n(this,"contextMenuElement");n(this,"loadingElement");n(this,"stageWidth",0);n(this,"stageHeight",0);n(this,"paint");n(this,"icons");n(this,"domSelectionStr","");n(this,"isMouseoverTargetContainer",!1);n(this,"mousedown",!1);n(this,"isPointer",!1);n(this,"rowResizing",!1);n(this,"columnResizing",!1);n(this,"scrollerMove",!1);n(this,"scrollerFocus",!1);n(this,"autofillMove",!1);n(this,"selectorMove",!1);n(this,"adjustPositioning",!1);n(this,"editing",!1);n(this,"loading",!1);n(this,"onlyMergeCell",!1);n(this,"selectOnlyOne",!1);n(this,"hasSelection",!1);n(this,"hasTree",!1);n(this,"scrollY",0);n(this,"scrollX",0);n(this,"fixedLeftWidth",0);n(this,"fixedRightWidth",0);n(this,"lastCenterColIndex",0);n(this,"maxColIndex",0);n(this,"maxRowIndex",0);n(this,"hoverRow");n(this,"clickCell");n(this,"focusCell");n(this,"currentCell");n(this,"hoverCell");n(this,"clickCellHeader");n(this,"focusCellHeader");n(this,"hoverCellHeader");n(this,"body",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,headIndex:0,tailIndex:0,visibleRows:[],renderRows:[],data:[]});n(this,"footer",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,renderRows:[]});n(this,"header",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,visibleLeafColumns:[],leafCellHeaders:[],renderLeafCellHeaders:[],renderCellHeaders:[],fixedLeftCellHeaders:[],fixedRightCellHeaders:[],renderCenterCellHeaders:[]});n(this,"selector",{enable:!1,xArr:[-1,-1],yArr:[-1,-1],xArrCopy:[-1,-1],yArrCopy:[-1,-1]});n(this,"autofill",{enable:!1,xArr:[-1,-1],yArr:[-1,-1]});n(this,"database");n(this,"history");n(this,"config");n(this,"drawTime",0);const{containerElement:i,stageElement:s,canvasElement:o,overlayerElement:r,editorElement:a,emptyElement:l,loadingElement:h,contextMenuElement:d}=t;this.containerElement=i,s.tabIndex=0,this.stageElement=s,this.canvasElement=o,this.overlayerElement=r,this.editorElement=a,this.emptyElement=l,this.loadingElement=h,this.contextMenuElement=d,this.config=new It(e.config||{}),this.eventBus=new me,this.eventBrowser=new Ee(this),this.eventTable=new Re(this),this.paint=new pe(this.canvasElement),this.database=new ge(this,e),this.history=new we(this),this.icons=new be(this)}setConfig(t){this.config=new It(t)}setItemValueByEditor(t,e,i,s=!0,o=!0,r=!0){if(this.config.ENABLE_MERGE_CELL_LINK){const a=this.database.getVirtualBodyCellByKey(t,e);if(a&&(a.mergeRow||a.mergeCol)){const{dataList:l}=a.getSpanInfo(),h=l.map(d=>({...d,value:i}));this.database.batchSetItemValue(h,s,r);return}}this.database.setItemValue(t,e,i,s,o,!0,r)}batchSetItemValueByEditor(t,e=!0,i=!0){if(this.config.ENABLE_MERGE_CELL_LINK){const s=[];t.forEach(o=>{const r=this.database.getRowIndexForRowKey(o.rowKey),a=this.database.getColIndexForKey(o.key);if(r===void 0||a===void 0)return;const l=this.database.getVirtualBodyCell(r,a);if(l){const{dataList:h}=l.getSpanInfo(),d=h.map(f=>({...f,value:o.value}));s.push(...d)}}),this.database.batchSetItemValue(s,e,i)}else this.database.batchSetItemValue(t,e,i)}setFocusCell(t){var e;if(this.focusCell!==t){if(((e=this.focusCell)==null?void 0:e.rowKey)!==t.rowKey){this.currentCell=t,this.emit("rowFocusChange",t);const i={rowIndex:t.rowIndex,rowKey:t.rowKey,row:t.row};this.emit("currentRowChange",i)}this.focusCell=t,this.emit("cellFocusChange",t)}}clearSelector(){this.selector.enable=!1,this.selector.xArr=[-1,-1],this.selector.yArr=[-1,-1],this.emit("clearSelector")}clearSelectorCopy(){this.selector.xArrCopy=[-1,-1],this.selector.yArrCopy=[-1,-1]}clearAutofill(){this.autofill={enable:!1,xArr:[-1,-1],yArr:[-1,-1]}}getSelectedData(){const t=[],e=this.selector.yArr,i=this.selector.xArr;let s="";for(let o=0;o<=e[1]-e[0];o++){const r=[];for(let a=0;a<=i[1]-i[0];a++){const l=o+e[0],h=a+i[0],d=this.database.getVirtualBodyCell(l,h);d&&(d.selectorCellValueType==="displayText"?r.push(d.displayText):r.push(d.getValue()))}s+=`${r.join(" ")}\r`,t.push(r)}return s=s?s.replace(/\r$/,""):" ",{xArr:i,yArr:e,text:s,value:t}}setScroll(t,e){let i=Math.floor(t);const s=this.body.width-this.body.visibleWidth;i<0?i=0:i>s&&(i=s);let o=Math.floor(e),r=this.body.height-this.body.visibleHeight;this.config.FOOTER_FIXED||(r=this.body.height+this.footer.height-this.body.visibleHeight),o<0?o=0:o>r&&(o=r),this.emit("setScroll",i,o)}setScrollX(t){let e=Math.floor(t);const i=this.body.width-this.body.visibleWidth;e<0?e=0:e>i&&(e=i),this.emit("setScrollX",e)}setScrollY(t){let e=Math.floor(t),i=0;this.config.FOOTER_FIXED||(i=this.footer.height);const s=this.body.height-this.body.visibleHeight+i;e<0?e=0:e>s&&(e=s),this.emit("setScrollY",e)}isTarget(t){return!!this.containerElement.contains(t.target)}getOffset(t){const{left:e,top:i}=this.containerElement.getBoundingClientRect();return{offsetX:t.clientX-e,offsetY:t.clientY-i}}hasEvent(t){return this.eventBus.has(t)}on(t,e){this.eventBus.on(t,e)}once(t,e){this.eventBus.once(t,e)}off(t,e){this.eventBus.off(t,e)}emit(t,...e){this.eventBus.emit(t,...e)}destroy(){this.eventTable.destroy(),this.eventBrowser.destroy(),this.eventBus.destroy()}}class vt{constructor(t,e){n(this,"ctx");n(this,"type");n(this,"isFocus",!1);n(this,"trackX",0);n(this,"trackY",0);n(this,"trackWidth",0);n(this,"trackHeight",0);n(this,"splitPoints",[]);n(this,"barX",0);n(this,"barY",0);n(this,"barWidth",0);n(this,"barHeight",0);n(this,"distance",0);n(this,"visibleDistance",0);n(this,"clientX",0);n(this,"clientY",0);n(this,"dragStart",0);n(this,"isDragging",!1);n(this,"scroll",0);this.ctx=t,this.type=e,this.type==="vertical"?this.scroll=this.ctx.scrollY:this.scroll=this.ctx.scrollX}onWheel(t){this.updateScroll(t)}onTouchmove(t){const{clientY:e,clientX:i}=t.touches[0],s=e-this.clientY,o=i-this.clientX;let r=0;this.type==="vertical"?(r=Math.max(0,Math.min(this.dragStart-s,this.distance)),this.hasScrollbar()&&!(r===0&&s>0||r===this.distance&&s<0)&&t.preventDefault()):this.type==="horizontal"&&(r=Math.max(0,Math.min(this.dragStart-o,this.distance))),this.scroll=r}onTouchstart(t){const{clientY:e,clientX:i}=t.touches[0];this.clientX=i,this.clientY=e,this.dragStart=this.scroll}onMouseDown(t){if(!(t.target instanceof Element)||!this.ctx.isTarget(t))return;if(this.ctx.stageElement.style.cursor==="row-resize"||this.ctx.stageElement.style.cursor==="col-resize")return!0;const{offsetX:e,offsetY:i,clientX:s,clientY:o}=t;if(!(s==this.clientX&&o==this.clientY)){if(this.isOnScrollbar(e,i))this.clientX=s,this.clientY=o,this.isDragging=!0,this.ctx.scrollerMove=!0,this.isFocus=!0,this.dragStart=this.scroll,t.preventDefault();else if(this.isOnTrack(e,i)){let r=0;this.type==="vertical"?r=(i-this.ctx.header.height-this.barHeight/2)/(this.visibleDistance-this.barHeight)*this.distance:r=(e-this.barWidth/2)/(this.visibleDistance-this.barWidth)*this.distance,this.scroll=Math.max(0,Math.min(r,this.distance))}}}onMouseUp(){this.isDragging=!1,this.isFocus=!1,this.clientX=0,this.clientY=0}onMouseMove(t){const{offsetX:e,offsetY:i,clientX:s,clientY:o,buttons:r}=t;if(this.isOnScrollbar(e,i)&&t.target===this.ctx.canvasElement?this.isFocus=!0:this.isFocus=!1,r===0||s==this.clientX&&o==this.clientY)return;let a=0;if(this.type==="horizontal"?a=s-this.clientX:a=o-this.clientY,this.isDragging&&a!==0){let l=0;this.type==="vertical"?l=this.dragStart+a/(this.visibleDistance-this.barHeight)*this.distance:l=this.dragStart+a/(this.visibleDistance-this.barWidth)*this.distance,this.scroll=Math.max(0,Math.min(l,this.distance))}}isPointInElement(t,e,i,s,o,r){return t>=i&&t<=i+o&&e>=s&&e<=s+r}hasScrollbar(){return this.type==="vertical"?this.barHeight>0:this.type==="horizontal"?this.barWidth>0:!1}isOnScrollbar(t,e){return this.isPointInElement(t,e,this.barX,this.barY,this.barWidth,this.barHeight)}isOnTrack(t,e){return this.isPointInElement(t,e,this.trackX,this.trackY,this.trackWidth,this.trackHeight)}updateScroll(t){const e=t.deltaX,i=t.deltaY;this.type==="vertical"&&t.shiftKey===!1?(this.hasScrollbar()&&!(this.scroll===0&&i<0||this.scroll===this.distance&&i>0)&&t.preventDefault(),this.scroll=Math.max(0,Math.min(this.scroll+i,this.distance))):this.type==="horizontal"&&(t.shiftKey?this.scroll=Math.max(0,Math.min(this.scroll+i,this.distance)):this.scroll=Math.max(0,Math.min(this.scroll+e,this.distance)))}updatedSize(){const{body:t,header:e,stageHeight:i,stageWidth:s,config:{SCROLLER_TRACK_SIZE:o=0,SCROLLER_SIZE:r=0,BORDER:a}}=this.ctx,l=s,h=i,d=e.height,f=e.width,u=t.height,x=this.ctx.footer.height;if(this.type==="vertical"){this.visibleDistance=h-o-d,this.distance=u-this.visibleDistance+x,this.trackX=l-o,this.trackY=0,this.splitPoints=[this.trackX,d,this.trackX+o,d],this.trackWidth=o,this.trackHeight=h,this.barX=this.trackX-1+(o-r)/2,this.barWidth=r;const w=this.distance?this.visibleDistance/(u+x):0;let E=Math.floor(w*this.visibleDistance);E<30?E=30:E>this.visibleDistance&&(E=0),this.barHeight=E,this.barY=d+this.scroll/this.distance*(this.visibleDistance-this.barHeight),this.scroll=Math.max(0,Math.min(this.scroll,this.distance))}else{this.visibleDistance=l-o,this.distance=f-this.visibleDistance,this.splitPoints=[l-o,h-o,l-o,h];const w=a?0:.5;this.trackX=0,this.trackY=h-o+w,this.trackWidth=l,this.trackHeight=o;const E=this.distance?this.visibleDistance/f:0;let g=Math.floor(E*this.visibleDistance);this.barY=this.trackY-1+(o-r)/2,g<30?g=30:g>=this.visibleDistance&&(g=0),this.barWidth=g,this.barHeight=r,this.barX=this.scroll/this.distance*(this.visibleDistance-this.barWidth),this.scroll=Math.max(0,Math.min(this.scroll,this.distance))}}draw(){const{config:{SCROLLER_FOCUS_COLOR:t,SCROLLER_COLOR:e,BORDER_COLOR:i,BORDER:s,SCROLLER_TRACK_COLOR:o}}=this.ctx;this.updatedSize();let r=i;s||(r="transparent"),this.ctx.paint.drawRect(this.trackX,this.trackY,this.trackWidth,this.trackHeight,{borderColor:r,fillColor:o}),this.ctx.paint.drawRect(this.barX,this.barY,this.barWidth,this.barHeight,{fillColor:this.isFocus||this.isDragging?t:e,radius:4}),this.splitPoints.length>0&&this.ctx.paint.drawLine(this.splitPoints,{borderColor:r,borderWidth:1}),this.ctx.scrollerFocus=this.isFocus}}class Se{constructor(t){n(this,"ctx");n(this,"verticalScrollbar");n(this,"horizontalScrollbar");this.ctx=t,this.verticalScrollbar=new vt(t,"vertical"),this.horizontalScrollbar=new vt(t,"horizontal"),this.ctx.on("wheel",e=>this.onWheel(e)),this.ctx.on("mousedown",e=>this.onMouseDown(e)),this.ctx.on("mousemove",e=>this.onMouseMove(e)),this.ctx.on("mouseup",()=>this.onMouseUp()),this.ctx.on("touchmove",e=>this.onTouchmove(e)),this.ctx.on("touchstart",e=>{this.onTouchstart(e)}),this.ctx.on("setScroll",(e,i)=>{this.setScroll(e,i)}),this.ctx.on("setScrollX",e=>{this.setScrollX(e)}),this.ctx.on("setScrollY",e=>{this.setScrollY(e)})}onWheel(t){this.verticalScrollbar.onWheel(t),this.horizontalScrollbar.onWheel(t),this.draw()}onTouchmove(t){this.verticalScrollbar.onTouchmove(t),this.horizontalScrollbar.onTouchmove(t),this.draw()}onTouchstart(t){this.verticalScrollbar.onTouchstart(t),this.horizontalScrollbar.onTouchstart(t),this.draw()}onMouseDown(t){this.verticalScrollbar.onMouseDown(t),this.horizontalScrollbar.onMouseDown(t),this.draw()}onMouseMove(t){this.verticalScrollbar.onMouseMove(t),this.horizontalScrollbar.onMouseMove(t),this.draw()}onMouseUp(){this.verticalScrollbar.onMouseUp(),this.horizontalScrollbar.onMouseUp(),this.ctx.scrollerMove=!1}draw(){this.verticalScrollbar.draw(),this.horizontalScrollbar.draw();const t=Math.floor(this.horizontalScrollbar.scroll),e=Math.floor(this.verticalScrollbar.scroll);(t!==this.ctx.scrollX||e!==this.ctx.scrollY)&&(this.ctx.emit("onScroll",t,e),t!==this.ctx.scrollX&&this.ctx.emit("onScrollX",t),e!==this.ctx.scrollY&&this.ctx.emit("onScrollY",e),this.ctx.scrollX=t,this.ctx.scrollY=e,this.ctx.emit("draw"))}setScroll(t,e){this.horizontalScrollbar.scroll=t,this.verticalScrollbar.scroll=e,this.ctx.emit("draw"),this.ctx.emit("onScroll",t,e)}setScrollX(t){this.horizontalScrollbar.scroll=t,this.ctx.emit("draw")}setScrollY(t){this.verticalScrollbar.scroll=t,this.ctx.emit("draw")}scrollToColkey(t){const{header:e}=this.ctx,i=e.leafCellHeaders.find(s=>s.key===t);i&&this.setScrollX(i.x-e.visibleWidth/2)}scrollToColIndex(t){const{header:e}=this.ctx,i=e.leafCellHeaders.find(s=>s.colIndex===t);i&&i.x>e.visibleWidth/2&&this.setScrollX(i.x-e.visibleWidth/2)}scrollToRowIndex(t){const{body:e,database:i}=this.ctx,{top:s}=i.getPositionForRowIndex(t);s>e.visibleHeight&&this.setScrollY(s-e.visibleHeight/2)}scrollToRowKey(t){const{body:e,database:i}=this.ctx,s=i.getRowIndexForRowKey(t);if(s===void 0)return;const{top:o}=i.getPositionForRowIndex(s);this.setScrollY(o-e.visibleHeight/2)}}class _e{constructor(t){n(this,"ctx");n(this,"x",0);n(this,"y",0);n(this,"width",0);n(this,"height",0);n(this,"resizeTarget",null);n(this,"resizeNum",0);n(this,"isResizing",!1);n(this,"clientX",0);n(this,"resizeDiff",0);n(this,"columnIndex",0);n(this,"isMouseDown",!1);n(this,"columns");n(this,"visibleLeafColumns",[]);n(this,"visibleHeight",0);n(this,"visibleWidth",0);n(this,"allCellHeaders",[]);n(this,"leafCellHeaders",[]);n(this,"renderLeafCellHeaders",[]);n(this,"fixedLeftCellHeaders",[]);n(this,"centerCellHeaders",[]);n(this,"fixedRightCellHeaders",[]);n(this,"renderCenterCellHeaders",[]);n(this,"renderFixedCellHeaders",[]);this.ctx=t,this.ctx.on("resetHeader",j(()=>{this.init(),this.ctx.emit("draw")},100)),this.init(),this.initResizeColumn()}init(){const{config:{HEADER_HEIGHT:t,SCROLLER_TRACK_SIZE:e}}=this.ctx,i=this.ctx.database.getColumns();this.columns=i,this.allCellHeaders=[],this.leafCellHeaders=[],this.fixedLeftCellHeaders=[],this.fixedRightCellHeaders=[],this.centerCellHeaders=[];const s=Nt(i),o=it(i);this.height=t*s,this.width=o.reduce((f,u)=>{const x=u.width||100,{maxWidth:w,minWidth:E}=u;return w&&x>w?f+w:E&&x<E?f+E:f+x},0),this.visibleHeight=this.height;const r=ae(kt(i,s));this.columnIndex=0,this.resizeNum=0,this.render(r,0),this.ctx.database.updateColIndexKeyMap(this.leafCellHeaders);const a=this.ctx.containerElement.getBoundingClientRect();this.resizeNum>0?this.ctx.stageWidth=Math.floor(a.width):this.ctx.stageWidth=Math.floor(this.width+e),this.ctx.stageElement.style.width=this.ctx.stageWidth+"px",this.visibleWidth=this.ctx.stageWidth-e;const l=this.visibleWidth-this.width;if(this.resizeNum&&l>0){const f=Math.floor(l/this.resizeNum*100)/100;this.resizeAllColumn(f)}const h=this.fixedLeftCellHeaders.filter(f=>!f.hasChildren);this.ctx.fixedLeftWidth=h.reduce((f,u)=>f+u.width,0);const d=this.fixedRightCellHeaders.filter(f=>!f.hasChildren);this.ctx.fixedRightWidth=d.reduce((f,u)=>f+u.width,e),this.ctx.maxColIndex=this.leafCellHeaders.length-1,this.ctx.header.x=this.x,this.ctx.header.y=this.y,this.ctx.header.width=this.width,this.ctx.header.height=this.height,this.ctx.header.visibleWidth=this.visibleWidth,this.ctx.header.visibleHeight=this.visibleHeight}initResizeColumn(){this.ctx.on("mousedown",t=>{this.ctx.config.ENABLE_RESIZE_COLUMN&&this.ctx.isTarget(t)&&(this.clientX=t.clientX,this.resizeTarget?(this.isResizing=!0,this.ctx.columnResizing=!0):this.isResizing=!1,this.isMouseDown=!0)}),this.ctx.on("mouseup",()=>{this.ctx.config.ENABLE_RESIZE_COLUMN&&(this.isMouseDown=!1,this.resizeDiff!==0&&this.resizeTarget&&this.resizeColumn(this.resizeTarget,this.resizeDiff),this.resizeTarget=null,this.isResizing=!1,this.isMouseDown=!1,this.ctx.columnResizing=!1,this.clientX=0,this.resizeDiff=0)}),this.ctx.on("mousemove",t=>{if(!this.ctx.config.ENABLE_RESIZE_COLUMN||this.ctx.editing)return;const{stageWidth:e,config:{RESIZE_COLUMN_MIN_WIDTH:i}}=this.ctx;if(this.isResizing&&this.resizeTarget){const s=this.resizeTarget.width,o=this.resizeTarget.minWidth,r=this.resizeTarget.maxWidth;let a=t.clientX-this.clientX;a+s<i&&(a=-(s-i)),o&&a+s<o&&(a=-(s-o)),r&&a+s>r&&(a=r-s),this.resizeDiff=a,this.ctx.emit("draw")}else{if(this.resizeTarget=null,this.isMouseDown)return;if(t.offsetX<0||t.offsetX>this.visibleWidth){this.ctx.stageElement.style.cursor==="col-resize"&&(this.ctx.stageElement.style.cursor="default");return}this.ctx.stageElement.style.cursor==="col-resize"&&(this.ctx.stageElement.style.cursor="default");const s=[...this.renderFixedCellHeaders,...this.renderCenterCellHeaders];for(const o of s){const{offsetX:r,offsetY:a}=this.ctx.getOffset(t),l=r,h=o.getDrawX();l>h+o.width-5&&l<h+o.width+4&&l<e-4&&o.colspan<=1&&this.ctx.isTarget(t)&&a<=this.height&&(this.ctx.stageElement.style.cursor="col-resize",this.resizeTarget=o)}}})}resizeColumn(t,e){const i=o=>{o.forEach(r=>{if(r.children&&r.children.length>0&&i(r.children),r.key===t.key){const a=r.width||100;r.width=a+e}})};i(this.columns),this.ctx.database.setColumns(this.columns),this.init(),this.ctx.emit("draw");let s=0;if(this.width<this.visibleWidth){const o=this.visibleWidth-this.width;s=Math.floor(o/this.resizeNum*100)/100,this.resizeAllColumn(s),this.ctx.emit("draw")}this.ctx.emit("resizeColumnChange",{colIndex:t.colIndex,key:t.key,oldWidth:t.width,width:t.width+e+s,column:t.column,columns:this.columns})}resizeAllColumn(t){if(t===0)return;const e=new Map;let i=!0;for(const o of this.allCellHeaders)if(o.widthFillDisable)e.set(o.key,o.width);else{const r=o.width+t*o.colspan;e.set(o.key,r),r<this.ctx.config.RESIZE_COLUMN_MIN_WIDTH&&(i=!1)}if(!i)return;const s=o=>{o.forEach(r=>{e.has(r.key)&&(r.width=e.get(r.key)),r.children&&r.children.length>0&&s(r.children)})};s(this.columns),this.ctx.database.setColumns(this.columns),this.init()}render(t,e){const i=t.length;let s=e;const{HEADER_HEIGHT:o=0}=this.ctx.config;for(let r=0;r<i;r++){const a=t[r],l=o*(a.rowspan||0),h=o*(a.level||0);let{minWidth:d,maxWidth:f}=a,u=a.width||100;d&&u<d&&(u=d),f&&u>f&&(u=f),a.children&&(u=it(a.children).reduce((E,g)=>E+((g==null?void 0:g.width)||100),0));const x=new ct(this.ctx,this.columnIndex,s,h,u,l,a);this.ctx.database.setHeader(a.key,x),this.allCellHeaders.push(x),a.children||(this.leafCellHeaders.push(x),x.column.widthFillDisable||this.resizeNum++),a.fixed==="left"?this.fixedLeftCellHeaders.push(x):a.fixed==="right"?this.fixedRightCellHeaders.push(x):this.centerCellHeaders.push(x),!a.children&&this.columnIndex++,a.children&&this.render(a.children,s),s+=u}}drawTipLine(){if(this.isResizing&&this.resizeTarget){const{stageHeight:t,config:{RESIZE_COLUMN_LINE_COLOR:e}}=this.ctx,i=this.resizeTarget.getDrawX(),s=this.resizeTarget.width,o=i+s+this.resizeDiff-.5,r=[o-.5,0,o-.5,t];this.ctx.paint.drawLine(r,{borderColor:e,borderWidth:1})}}drawFixedShadow(){const{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,stageWidth:o,config:{HEADER_BG_COLOR:r,SCROLLER_TRACK_SIZE:a}}=this.ctx;if(i>0&&t!==0&&this.ctx.paint.drawShadow(this.x,this.y,t,this.height,{fillColor:r,side:"right",shadowWidth:4,colorStart:"rgba(0,0,0,0.1)",colorEnd:"rgba(0,0,0,0)"}),i<Math.floor(s.width-o-1)&&e!==a){const l=s.width-(this.x+this.width)+o-e;this.ctx.paint.drawShadow(l,this.y,e,this.height,{fillColor:r,side:"left",shadowWidth:4,colorStart:"rgba(0,0,0,0)",colorEnd:"rgba(0,0,0,0.1)"})}}update(){const t=[],e=[],i=[];if(this.centerCellHeaders.length){const s=this.centerCellHeaders[this.centerCellHeaders.length-1];this.ctx.lastCenterColIndex=s.colIndex}this.centerCellHeaders.forEach(s=>{s.isHorizontalVisible()&&s.isVerticalVisible()&&(e.push(s),s.hasChildren||t.push(s))}),this.fixedLeftCellHeaders.forEach(s=>{i.push(s),s.hasChildren||t.push(s)}),this.fixedRightCellHeaders.forEach(s=>{i.push(s),s.hasChildren||t.push(s)}),this.renderCenterCellHeaders=e,this.renderFixedCellHeaders=i,this.renderLeafCellHeaders=t.sort((s,o)=>s.x-o.x),this.visibleLeafColumns=this.renderLeafCellHeaders.map(s=>s.column),this.ctx.header.visibleLeafColumns=this.visibleLeafColumns,this.ctx.header.leafCellHeaders=this.leafCellHeaders,this.ctx.header.renderLeafCellHeaders=this.renderLeafCellHeaders,this.ctx.header.renderCellHeaders=this.renderFixedCellHeaders.concat(this.renderCenterCellHeaders)}drawBottomLine(){const{stageWidth:t,config:{BORDER_COLOR:e}}=this.ctx,i=[0,this.height,t,this.height];this.ctx.paint.drawLine(i,{borderColor:e,borderWidth:1})}draw(){this.renderCenterCellHeaders.forEach(t=>{t.update(),t.draw()}),this.drawFixedShadow(),this.renderFixedCellHeaders.forEach(t=>{t.update(),t.draw()}),this.drawTipLine(),this.drawBottomLine()}}class Kt{constructor(t,e,i=0,s=0,o=0,r=0,a,l="body"){n(this,"ctx");n(this,"x",0);n(this,"y",0);n(this,"width",0);n(this,"height");n(this,"cells",[]);n(this,"fixedCells",[]);n(this,"noFixedCells",[]);n(this,"calculatedHeightCells",[]);n(this,"rowIndex",0);n(this,"rowKey","");n(this,"rowType","body");n(this,"data");n(this,"calculatedHeight",-1);this.ctx=t,this.x=i,this.y=s,this.width=o,this.height=r,this.rowIndex=e,this.rowKey=t.database.getRowKeyForRowIndex(e)||"",this.rowType=l,this.data=a,this.update()}update(){const{header:t}=this.ctx,e=[],i=[],s=[],o=[];t.renderLeafCellHeaders.forEach(r=>{const a=new ut(this.ctx,this.rowIndex,r.colIndex,r.x,this.y,r.width,this.height,r.column,this.data,this.rowType);a.fixed?i.push(a):s.push(a),e.push(a),a.autoRowHeight&&o.push(a)}),this.cells=e,this.calculatedHeightCells=o,this.fixedCells=i,this.noFixedCells=s}updateCalculatedHeight(){const t=this.calculatedHeightCells.map(e=>e.getAutoHeight());this.calculatedHeight=t.length?Math.max(...t):-1}drawCenter(){this.noFixedCells.forEach(t=>{t.draw()})}drawFixed(){this.fixedCells.forEach(t=>{t.draw()})}drawContainer(){this.noFixedCells.forEach(t=>{t.drawContainer()})}drawFixedContainer(){this.fixedCells.forEach(t=>{t.drawContainer()})}}class ve{constructor(t){n(this,"resizeTarget",null);n(this,"isMouseDown",!1);n(this,"resizeDiff",0);n(this,"clientY",0);n(this,"ctx");n(this,"x",0);n(this,"y",0);n(this,"width",0);n(this,"height",0);n(this,"headIndex",0);n(this,"tailIndex",0);n(this,"isResizing",!1);n(this,"renderRows",[]);n(this,"visibleRows",[]);n(this,"visibleHeight",0);n(this,"visibleWidth",0);n(this,"containerRect");n(this,"data",[]);this.ctx=t,this.init(),this.initResizeRow()}init(){const{canvasElement:t,header:e,footer:i,database:s,config:{FOOTER_FIXED:o,SCROLLER_TRACK_SIZE:r=0,HEIGHT:a,EMPTY_BODY_HEIGHT:l=0,MAX_HEIGHT:h=0,ENABLE_OFFSET_HEIGHT:d=0,OFFSET_HEIGHT:f=0,FOOTER_POSITION:u}}=this.ctx;if(!e.width)return;this.x=0,u==="top"&&o?this.y=e.height+i.height:this.y=e.height;const{data:x,sumHeight:w}=s.getData();this.height=w,this.data=x,this.width=e.width,this.visibleWidth=this.ctx.stageWidth-r;const E=this.ctx.footer.height;!this.data.length&&!a?this.height=l:!this.data.length&&a&&(this.height=a-e.height-E-r);let g=this.height+e.height+r;g+=E;let m=g;const y=window.innerHeight,{top:p}=this.containerRect||this.ctx.containerElement.getBoundingClientRect();if(y>p&&d&&!a){const T=y-p-f;T>e.height+r?m=T:g>h&&(m=h)}else this.data.length&&a?m=a:this.data.length&&h&&g>h&&(m=h);m>0&&(this.ctx.stageHeight=Math.floor(m),this.ctx.stageElement.style.height=`${this.ctx.stageHeight}px`);let R=this.ctx.stageHeight-e.height-r;o?this.visibleHeight=R-E:this.visibleHeight=R,this.data.length||(this.height=this.visibleHeight),this.ctx.body.x=this.x,this.ctx.body.y=this.y,this.ctx.body.width=this.width,this.ctx.body.height=this.height,this.ctx.body.visibleWidth=this.visibleWidth,this.ctx.body.visibleHeight=this.visibleHeight,this.ctx.body.data=x;const C=window.devicePixelRatio||1,I=this.ctx.stageWidth*C,_=this.ctx.stageHeight*C;t.width=Math.round(I),t.height=Math.round(_);const v=this.data.length?"not-empty":"empty";this.ctx.emit("emptyChange",{isEmpty:v,type:v,headerHeight:e.height,bodyHeight:this.height,footerHeight:E,width:this.width,height:this.data.length?0:l+E});const S=Math.round(t.width/C*1e4)/1e4,b=Math.round(t.height/C*1e4)/1e4;this.ctx.canvasElement.setAttribute("style",`height:${b}px;width:${S}px;`),this.ctx.paint.scale(C)}initResizeRow(){this.ctx.on("resize",()=>{this.ctx.config.ENABLE_RESIZE_ROW&&(this.containerRect=this.ctx.containerElement.getBoundingClientRect())}),this.ctx.on("resizeObserver",()=>{this.ctx.config.ENABLE_RESIZE_ROW&&(this.containerRect=this.ctx.containerElement.getBoundingClientRect())}),this.ctx.on("mouseup",()=>{this.ctx.config.ENABLE_RESIZE_ROW&&(this.isMouseDown=!1,this.resizeDiff!==0&&this.resizeTarget&&this.resizeRow(this.resizeTarget,this.resizeDiff),this.resizeTarget=null,this.resizeDiff=0,this.isResizing=!1,setTimeout(()=>{this.ctx.rowResizing=!1},0),this.clientY=0)}),this.ctx.on("mousedown",t=>{this.ctx.config.ENABLE_RESIZE_ROW&&this.ctx.isTarget(t)&&(this.clientY=t.clientY,this.resizeTarget?(this.isResizing=!0,this.ctx.rowResizing=!0):(this.isResizing=!1,this.ctx.rowResizing=!1),this.isMouseDown=!0)}),this.ctx.on("mousemove",t=>{if(!this.ctx.config.ENABLE_RESIZE_ROW||this.ctx.editing)return;const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,o=i,r=t.clientY,{stageHeight:a,scrollY:l,config:{RESIZE_ROW_MIN_HEIGHT:h=0}}=this.ctx;if(this.isResizing&&this.resizeTarget){const d=this.resizeTarget.height;let f=r-this.clientY;const{calculatedHeight:u}=this.resizeTarget,x=u===-1?h:u;f+d<x&&(f=-(d-x)),this.resizeDiff=f,this.ctx.emit("draw")}else{if(this.resizeTarget=null,this.isMouseDown)return;if(o<0||o>this.ctx.body.visibleWidth||s<0||s>this.ctx.header.visibleHeight+this.ctx.body.visibleHeight){this.ctx.stageElement.style.cursor==="row-resize"&&(this.ctx.stageElement.style.cursor="default");return}if(this.ctx.stageElement.style.cursor==="crosshair")return;this.ctx.stageElement.style.cursor==="row-resize"&&(this.ctx.stageElement.style.cursor="default");for(let d=0;d<this.renderRows.length;d++){const f=this.renderRows[d];if(s>f.y-l+f.height-1.5&&s<f.y-l+f.height+1.5&&s<a-4)for(let x=0;x<f.cells.length;x++){const w=f.cells[x];o>w.drawX+10&&o<w.drawX+w.width-10&&w.rowspan===1&&(this.ctx.stageElement.style.cursor="row-resize",this.resizeTarget=f)}}}})}resizeRow(t,e){const{rowIndex:i,height:s,rowKey:o,data:r}=t;this.ctx.database.setRowHeight(i,s+e),this.init(),this.ctx.emit("draw"),this.ctx.emit("resizeRowChange",{rowIndex:i,oldHeight:s,height:s+e,rowKey:o,row:r,data:this.data})}drawTipLine(){if(this.isResizing&&this.resizeTarget){const{stageWidth:t,scrollY:e,config:{RESIZE_ROW_LINE_COLOR:i}}=this.ctx,s=this.resizeTarget.y-e,o=this.resizeTarget.height,r=s+o+this.resizeDiff-.5,a=[0,r-.5,t,r-.5];this.ctx.paint.drawLine(a,{borderColor:i,borderWidth:1})}}drawFixedShadow(){const{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,stageWidth:o,config:{HEADER_BG_COLOR:r,SCROLLER_TRACK_SIZE:a}}=this.ctx;if(i>0&&t!==0&&this.ctx.paint.drawShadow(this.x,this.y,t,this.height,{fillColor:r,side:"right",shadowWidth:4,colorStart:"rgba(0,0,0,0.1)",colorEnd:"rgba(0,0,0,0)"}),i<Math.floor(s.width-o-1)&&e!==a){const l=s.width-(this.x+this.width)+o-e;this.ctx.paint.drawShadow(l,this.y,e,this.height,{fillColor:r,side:"left",shadowWidth:4,colorStart:"rgba(0,0,0,0)",colorEnd:"rgba(0,0,0,0.1)"})}}binarySearch(t,e){let i=0,s=t.length-1,o=-1;for(;i<=s;){let r=Math.floor((i+s)/2),a=t[r].bottom;if(a===e)return r;a<e?i=r+1:(o=r,s=r-1)}return o}update(){this.init();const{header:t,database:e,scrollY:i,config:{CELL_HEIGHT:s}}=this.ctx,o=i,{data:r,positions:a}=e.getData();this.ctx.maxRowIndex=r.length-1;let l=this.binarySearch(a,o),h=this.binarySearch(a,o+this.visibleHeight);if(h===-1&&(h=this.ctx.maxRowIndex),l===-1&&h===this.ctx.maxRowIndex){const f=Math.floor(this.visibleHeight/s);l=this.ctx.maxRowIndex-f}this.headIndex=Math.max(0,l),this.tailIndex=Math.min(this.ctx.maxRowIndex,h+1),this.visibleRows=r.slice(this.headIndex,this.tailIndex+1),this.ctx.body.headIndex=this.headIndex,this.ctx.body.tailIndex=this.tailIndex,this.ctx.body.visibleRows=this.visibleRows;const d=[];for(let f=0;f<this.visibleRows.length;f++){const u=this.headIndex+f,x=this.visibleRows[f],{height:w,top:E}=this.ctx.database.getPositionForRowIndex(u),g=new Kt(this.ctx,u,0,E+this.y,t.width,w,x);d.push(g)}this.renderRows=d,this.ctx.body.renderRows=d}updateAutoHeight(){const t=this.ctx.body.renderRows;if(!t.some(s=>s.calculatedHeightCells.length>0))return;t.forEach(s=>{s.updateCalculatedHeight()});const i=t.map(s=>({height:s.calculatedHeight,rowIndex:s.rowIndex}));this.ctx.database.setBatchCalculatedRowHeight(i)}draw(){this.renderRows.forEach(t=>{t.drawContainer()}),this.renderRows.forEach(t=>{t.drawCenter()}),this.drawFixedShadow(),this.renderRows.forEach(t=>{t.drawFixedContainer()}),this.renderRows.forEach(t=>{t.drawFixed()}),this.drawTipLine()}}class Te{constructor(t){n(this,"ctx");n(this,"renderRows",[]);n(this,"data",[]);n(this,"x",0);n(this,"y",0);n(this,"width",0);n(this,"height",0);n(this,"visibleWidth",0);n(this,"visibleHeight",0);this.ctx=t,this.init()}init(){this.data=this.ctx.database.getFooterData();const{header:t,body:e,config:{CELL_FOOTER_HEIGHT:i,FOOTER_FIXED:s,SCROLLER_TRACK_SIZE:o,FOOTER_POSITION:r}}=this.ctx;this.width=t.width,this.visibleWidth=t.visibleWidth,this.height=this.data.reduce(a=>a+i,0),this.visibleHeight=this.height,s?r==="top"?this.y=this.ctx.header.height:this.y=this.ctx.stageHeight-this.height-o:this.y=e.y+e.height,this.ctx.footer.x=this.x,this.ctx.footer.y=this.y,this.ctx.footer.height=this.height,this.ctx.footer.width=this.width,this.ctx.footer.visibleWidth=this.visibleWidth,this.ctx.footer.visibleHeight=this.visibleHeight}drawFixedShadow(){const{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,stageWidth:o,config:{HEADER_BG_COLOR:r,SCROLLER_TRACK_SIZE:a}}=this.ctx;let l=this.y;if(this.ctx.config.FOOTER_FIXED||(l=this.y-this.ctx.scrollY),i>0&&t!==0&&this.ctx.paint.drawShadow(this.x,l,t,this.height,{fillColor:r,side:"right",shadowWidth:4,colorStart:"rgba(0,0,0,0.1)",colorEnd:"rgba(0,0,0,0)"}),i<Math.floor(s.width-o-1)&&e!==a){const h=s.width-(this.x+this.width)+o-e;this.ctx.paint.drawShadow(h,l,e,this.height,{fillColor:r,side:"left",shadowWidth:4,colorStart:"rgba(0,0,0,0)",colorEnd:"rgba(0,0,0,0.1)"})}}update(){this.init();const{CELL_FOOTER_HEIGHT:t}=this.ctx.config;let e=this.y;const i=[];this.data.forEach((s,o)=>{const r=new Kt(this.ctx,o,0,e,this.width,t,s,"footer");e+=t,i.push(r)}),this.renderRows=i,this.ctx.footer.renderRows=this.renderRows}drawTopLine(){const{stageWidth:t,config:{BORDER_COLOR:e}}=this.ctx,i=[0,this.y,t,this.y];this.ctx.paint.drawLine(i,{borderColor:e,borderWidth:1})}draw(){this.renderRows.forEach(t=>{t.drawContainer()}),this.renderRows.forEach(t=>{t.drawCenter()}),this.drawFixedShadow(),this.renderRows.forEach(t=>{t.drawFixedContainer()}),this.renderRows.forEach(t=>{t.drawFixed()}),this.drawTopLine()}}class Oe{constructor(t){n(this,"isCut",!1);n(this,"isMultipleRow",!1);n(this,"mousedownHeader",!1);n(this,"ctx");n(this,"adjustPositionX","");n(this,"adjustPositionY","");n(this,"timerX",0);n(this,"timerY",0);this.ctx=t,this.init()}init(){this.ctx.on("setMoveFocus",t=>{this.moveFocus(t)}),this.ctx.on("mousemove",j(t=>{const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=this.ctx.isTarget(t)&&i>0&&i<this.ctx.body.visibleWidth&&e>this.ctx.header.visibleHeight&&e<this.ctx.header.visibleHeight+this.ctx.body.visibleHeight;(this.ctx.selectorMove||this.ctx.autofillMove)&&(!s&&!this.mousedownHeader?this.startAdjustPosition(t):this.stopAdjustPosition())},100)),this.ctx.on("cellHoverChange",t=>{if(!this.ctx.autofillMove){if(t.operation){this.selectRows(t,!1);return}this.isMultipleRow||this.mouseenter()}}),this.ctx.on("cellMousedown",(t,e)=>{if(!this.ctx.isTarget(e)||this.ctx.stageElement.style.cursor==="pointer"||this.ctx.isPointer||this.ctx.stageElement.style.cursor==="crosshair")return;if(t.operation){this.isMultipleRow=!0,this.selectRows(t);return}window.getComputedStyle(e.target).userSelect!=="text"&&e.preventDefault(),this.isMultipleRow=!1,this.click(e.shiftKey),this.ctx.emit("selectorClick",t)}),this.ctx.on("mouseup",()=>{this.mousedownHeader=!1;const t=setTimeout(()=>{this.ctx.adjustPositioning=!1,clearTimeout(t)},0)}),this.ctx.on("cellHeaderHoverChange",t=>{this.ctx.mousedown&&this.selectCols(t)}),this.ctx.on("cellHeaderMousedown",(t,e)=>{if(this.ctx.stageElement.style.cursor==="pointer"||this.ctx.isPointer)return;window.getComputedStyle(e.target).userSelect!=="text"&&e.preventDefault(),this.mousedownHeader=!0,this.selectCols(t)}),this.ctx.on("keydown",t=>{if(!this.ctx.editing){if(t.ctrlKey&&t.code==="KeyV"||t.metaKey&&t.code==="KeyV"){this.paste();return}if(t.ctrlKey&&t.code==="KeyC"||t.metaKey&&t.code==="KeyC"){this.copy(),this.isCut=!1;return}if(t.ctrlKey&&t.code==="KeyX"||t.metaKey&&t.code==="KeyX"){this.isCut=!0,this.copy();return}if((t.ctrlKey&&t.code==="KeyA"||t.metaKey&&t.code==="KeyA")&&(t.preventDefault(),this.selectAll()),t.code==="ArrowLeft"||t.shiftKey&&t.code==="Tab"){t.preventDefault(),this.moveFocus("LEFT");return}if(t.code==="ArrowUp"){t.preventDefault(),this.moveFocus("TOP");return}if(t.code==="ArrowRight"||t.code==="Tab"){t.preventDefault(),this.moveFocus("RIGHT");return}if(t.code==="ArrowDown"){t.preventDefault(),this.moveFocus("BOTTOM");return}if(t.code==="Delete"||t.code==="Backspace"){t.preventDefault();const{xArr:e,yArr:i}=this.ctx.selector;this.clearSelectedData(e,i);return}}}),this.ctx.on("contextMenuClearSelected",()=>{const{xArr:t,yArr:e}=this.ctx.selector;this.clearSelectedData(t,e)}),this.ctx.on("contextMenuCopy",()=>{this.copy()}),this.ctx.on("contextMenuPaste",()=>{this.paste()}),this.ctx.on("contextMenuCut",()=>{this.isCut=!0,this.copy()}),this.ctx.on("setSelectorCell",t=>{this.ctx.setFocusCell(t),this.click()}),this.ctx.on("mouseup",()=>{this.ctx.selectorMove=!1,this.stopAdjustPosition()})}setSelector(t,e){const{ENABLE_SELECTOR_SPAN_COL:i,ENABLE_SELECTOR_SPAN_ROW:s}=this.ctx.config;let o=t,r=e;if(!s){const[a]=r;r=[a,a]}if(!i){const[a]=o;o=[a,a]}if(JSON.stringify(this.ctx.selector.xArr)!==JSON.stringify(o)||JSON.stringify(this.ctx.selector.yArr)!==JSON.stringify(r)){this.ctx.mousedown&&(this.ctx.selectorMove=!0),this.ctx.selector.enable=!0;const{SELECTOR_AREA_MIN_X:a,SELECTOR_AREA_MAX_X:l,SELECTOR_AREA_MIN_Y:h,SELECTOR_AREA_MAX_Y:d,SELECTOR_AREA_MAX_X_OFFSET:f,SELECTOR_AREA_MAX_Y_OFFSET:u}=this.ctx.config,x=a,w=l||this.ctx.maxColIndex-f,E=h,g=d||this.ctx.maxRowIndex-u;let[m,y]=o,[p,R]=r;if(m<x||y>w||p<E||R>g)return;if(this.ctx.stageElement.focus({preventScroll:!0}),this.ctx.config.ENABLE_MERGE_CELL_LINK){const I=this.adjustMergeCells(o,r);p=I.yArr[0],R=I.yArr[1],m=I.xArr[0],y=I.xArr[1],this.ctx.onlyMergeCell=I.onlyMergeCell}m===y&&p===R?this.ctx.selectOnlyOne=!0:this.ctx.selectOnlyOne=!1,o=[Math.max(x,m),Math.min(w,y)],r=[Math.max(E,p),Math.min(g,R)];const{BEFORE_SET_SELECTOR_METHOD:C}=this.ctx.config;if(typeof C=="function"){const _=C({focusCell:this.ctx.focusCell,xArr:o,yArr:r});if(!_)return;o=_.xArr,r=_.yArr}this.ctx.selector.xArr=o,this.ctx.selector.yArr=r,this.ctx.emit("setSelector",this.ctx.selector),this.ctx.emit("drawView")}}adjustMergeCells(t,e){var w;const[i,s]=e,[o,r]=t;let a=[],l=[];for(let E=0;E<=e[1]-e[0];E++)for(let g=0;g<=t[1]-t[0];g++){const m=E+e[0],y=g+t[0],p=this.ctx.database.getVirtualBodyCell(m,y);p&&((m===i||m===s)&&a.push(p),(y===o||y===r)&&l.push(p))}const h=a.reduce((E,g)=>{const{yArr:m}=g.getSpanInfo(),[y,p]=m;return E.minY=Math.min(E.minY,y),E.maxY=Math.max(E.maxY,p),E},{minY:i,maxY:s}),d=l.reduce((E,g)=>{const{xArr:m}=g.getSpanInfo(),[y,p]=m;return E.minX=Math.min(E.minX,y),E.maxX=Math.max(E.maxX,p),E},{minX:o,maxX:r}),f=[d.minX,d.maxX],u=[h.minY,h.maxY];let x=!1;if(d.minX!==d.maxX||h.minY!==h.maxY){const E=JSON.stringify(f)+JSON.stringify(u),g=(w=this.ctx.focusCell)==null?void 0:w.getSpanInfo();x=(g&&JSON.stringify(g.xArr)+JSON.stringify(g.yArr))===E}return{xArr:f,yArr:u,onlyMergeCell:x}}selectCols(t){if(this.ctx.config.ENABLE_SELECTOR_SINGLE||!this.ctx.config.ENABLE_SELECTOR_ALL_ROWS||this.ctx.autofillMove||this.ctx.columnResizing||this.ctx.editing)return;if(t.operation){this.selectAll();return}const{SELECTOR_AREA_MIN_Y:e,SELECTOR_AREA_MAX_Y:i,SELECTOR_AREA_MAX_Y_OFFSET:s}=this.ctx.config,o=e,r=i||this.ctx.maxRowIndex-s;if(this.ctx.mousedown&&this.ctx.focusCellHeader){const{colIndex:a}=this.ctx.focusCellHeader;if(this.ctx.clearSelector(),t.colIndex>=a){const l=[a,t.colIndex+t.colspan-1],h=[o,r];this.setSelector(l,h)}else{const l=[t.colIndex,a],h=[o,r];this.setSelector(l,h)}}else{const a=[t.colIndex,t.colIndex+t.colspan-1],l=[o,r];this.setSelector(a,l)}}selectAll(){if(this.ctx.autofillMove||this.ctx.editing)return;const{ENABLE_SELECTOR_ALL_ROWS:t,ENABLE_SELECTOR_ALL_COLS:e}=this.ctx.config;if(t&&e){const{SELECTOR_AREA_MIN_X:i,SELECTOR_AREA_MAX_X:s,SELECTOR_AREA_MIN_Y:o,SELECTOR_AREA_MAX_Y:r,SELECTOR_AREA_MAX_X_OFFSET:a,SELECTOR_AREA_MAX_Y_OFFSET:l}=this.ctx.config,h=i,d=s||this.ctx.maxColIndex-a,f=o,u=r||this.ctx.maxRowIndex-l,x=[h,d],w=[f,u];this.setSelector(x,w)}}selectRows(t,e=!0){if(this.ctx.config.ENABLE_SELECTOR_SINGLE||!this.ctx.config.ENABLE_SELECTOR_ALL_COLS||this.ctx.autofillMove||this.ctx.editing)return;const{SELECTOR_AREA_MIN_X:i,SELECTOR_AREA_MAX_X:s,SELECTOR_AREA_MAX_X_OFFSET:o}=this.ctx.config,r=s||this.ctx.maxColIndex-o,a=i;if(e){this.ctx.setFocusCell(t);const l=[a,r],h=[t.rowIndex,t.rowIndex];this.setSelector(l,h)}if(this.ctx.focusCell&&this.ctx.mousedown){const{rowIndex:l}=this.ctx.focusCell;if(t.rowIndex>=l){const h=[a,r],d=[l,t.rowIndex];this.setSelector(h,d)}else{const h=[a,r],d=[t.rowIndex,l];this.setSelector(h,d)}}}mouseenter(){if(this.ctx.config.ENABLE_SELECTOR_SINGLE||this.ctx.editing)return;const{mousedown:t,focusCell:e,hoverCell:i}=this.ctx;if(t&&e&&i){const{rowIndex:s,colIndex:o}=e,r=Math.min(i.colIndex,o),a=Math.max(i.colIndex,o),l=Math.min(i.rowIndex,s),h=Math.max(i.rowIndex,s),d=[r,a],f=[l,h];this.setSelector(d,f)}}click(t=!1){const{focusCell:e,clickCell:i}=this.ctx;if(e&&this.isInSettingRange(e.rowIndex,e.colIndex))if(this.ctx.selector.enable=!0,i&&t){if(this.ctx.config.ENABLE_SELECTOR_SINGLE)return;const{colIndex:s,rowIndex:o}=i,{colIndex:r,rowIndex:a}=e,l=Math.min(r,s),h=Math.max(r,s),d=Math.min(a,o),f=Math.max(a,o),u=[l,h],x=[d,f];this.setSelector(u,x)}else{this.ctx.emit("cellSelectedClick",e);const s=[e.colIndex,e.colIndex],o=[e.rowIndex,e.rowIndex];this.setSelector(s,o),this.adjustBoundaryPosition()}}clearCopyLine(){this.ctx.selector.xArrCopy=[-1,-1],this.ctx.selector.yArrCopy=[-1,-1]}getCell(t,e){const i=this.ctx.body.renderRows.find(o=>o.rowIndex===t);return i==null?void 0:i.cells.find(o=>o.colIndex===e)}copy(){if(!this.ctx.config.ENABLE_COPY||this.ctx.domSelectionStr)return;let{value:t,xArr:e,yArr:i}=this.ctx.getSelectedData();if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.database.hasMergeCell(e,i))if(this.ctx.onlyMergeCell&&this.ctx.focusCell){const r=this.ctx.focusCell;t=[[r.getValue()]],e=[r.colIndex,r.colIndex],i=[r.rowIndex,r.rowIndex]}else{const r={code:"ERR_MERGED_CELLS_COPY",message:"Merged cells cannot span copy data"};this.ctx.hasEvent("error")?this.ctx.emit("error",r):alert(r.message);return}const{BEFORE_COPY_METHOD:s}=this.ctx.config;if(typeof s=="function"){const a=s({focusCell:this.ctx.focusCell,data:t,xArr:e,yArr:i});if(!a)return;t=a.data}const o=ce(t);navigator.clipboard?navigator.clipboard.writeText(o).then(()=>{this.ctx.selector.xArrCopy=this.ctx.selector.xArr.slice(),this.ctx.selector.yArrCopy=this.ctx.selector.yArr.slice(),this.ctx.emit("copyChange",{xArr:this.ctx.selector.xArrCopy,yArr:this.ctx.selector.yArrCopy,data:t}),this.ctx.emit("draw")}).catch(r=>console.error("Copy Failure:",r)):console.error("current browser does not support the Clipboard API")}clearSelectedData(t,e,i=!1,s=null){let o=[];const r=new Set;for(let l=0;l<=e[1]-e[0];l++)for(let h=0;h<=t[1]-t[0];h++){const d=l+e[0],f=h+t[0],u=this.ctx.database.getItemValueForRowIndexAndColIndex(d,f);if(u){const{rowKey:x,key:w}=u;this.ctx.database.getReadonly(x,w)||(r.add(x),o.push({rowKey:x,key:w,value:s,row:{}}))}}if(!o.length)return[];if(i)return o;this.ctx.database.batchSetItemValue(o,!0);let a=[];return r.forEach(l=>{a.push(this.ctx.database.getRowDataItemForRowKey(l))}),this.ctx.emit("clearSelectedDataChange",o,a),o}paste(){if(!navigator.clipboard){console.error("current browser does not support the Clipboard API");return}const{ENABLE_PASTER:t}=this.ctx.config;if(this.ctx.selector.enable&&t){const e=this.ctx.selector.yArr[0],i=this.ctx.selector.xArr[0],s=new Set;navigator.clipboard.readText().then(async o=>{let r=he(o);const a=[i,i+r[0].length-1],l=[e,e+r.length-1],[h,d]=l,[f,u]=a,x=d-this.ctx.maxRowIndex,w=u-this.ctx.maxColIndex;(x>0||w>0)&&this.ctx.emit("onPastedDataOverflow",{maxY:d,maxX:u,minY:h,minX:f,overflowRowCount:x,overflowColCount:w,textArr:r});const E=r.length===1&&r[0].length===1;if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.database.hasMergeCell(a,l)&&!E){const p={code:"ERR_MERGED_CELLS_PASTE",message:"Merged cells cannot span paste data"};this.ctx.hasEvent("error")?this.ctx.emit("error",p):alert(p.message);return}let g=[];for(let p=0;p<=r.length-1;p++){const R=r[p].length;for(let C=0;C<=R-1;C++){const I=p+e,_=C+i,v=r[p][C],S=this.ctx.database.getItemValueForRowIndexAndColIndex(I,_);if(S){const{rowKey:b,key:O}=S;this.ctx.database.getReadonly(b,O)||(s.add(b),g.push({rowKey:b,key:O,value:v,row:{}}))}}}if(this.isCut){const p=this.clearSelectedData(this.ctx.selector.xArrCopy,this.ctx.selector.yArrCopy,!0),R=g.map(C=>`${C.rowKey}-${C.key}`);p.forEach(C=>{R.includes(`${C.rowKey}-${C.key}`)||g.unshift(C)}),this.isCut=!1}if(!g.length)return;const{BEFORE_PASTE_DATA_METHOD:m}=this.ctx.config;if(typeof m=="function"){const p=m,R=g.map(C=>({rowKey:C.rowKey,key:C.key,value:C.value,oldValue:this.ctx.database.getItemValue(C.rowKey,C.key),row:this.ctx.database.getRowDataItemForRowKey(C.rowKey)}));if(g=await p(R,a,l,r),g&&!g.length)return}this.clearCopyLine(),this.ctx.batchSetItemValueByEditor(g,!0);let y=[];s.forEach(p=>{y.push(this.ctx.database.getRowDataItemForRowKey(p))}),this.ctx.emit("pasteChange",g,y),this.ctx.emit("draw")}).catch(o=>{console.error("Failed to get the clipboard content:",o)})}}moveFocus(t){if(this.ctx.editing)return;const{focusCell:e}=this.ctx;if(!e)return;let{colIndex:i=0,rowIndex:s=0}=e;const o=0,r=0,a=this.ctx.maxColIndex,l=this.ctx.maxRowIndex;switch(t){case"LEFT":i>o&&i--;break;case"TOP":s>r&&s--;break;case"RIGHT":i<a&&i++;break;case"BOTTOM":s<l&&s++;break}const h=[i,i],d=[s,s],f=this.getCell(s,i);f&&(f.operation||this.isInSettingRange(f.rowIndex,f.colIndex)&&(this.ctx.setFocusCell(f),this.setSelector(h,d),this.adjustBoundaryPosition(),this.ctx.emit("moveFocus",f),this.ctx.emit("draw")))}stopAdjustPosition(){this.adjustPositionX="",this.adjustPositionY="",this.timerX&&(clearInterval(this.timerX),this.timerX=0),this.timerY&&(clearInterval(this.timerY),this.timerY=0)}isInSettingRange(t,e){const{SELECTOR_AREA_MIN_X:i,SELECTOR_AREA_MAX_X:s,SELECTOR_AREA_MIN_Y:o,SELECTOR_AREA_MAX_Y:r,SELECTOR_AREA_MAX_X_OFFSET:a,SELECTOR_AREA_MAX_Y_OFFSET:l}=this.ctx.config,h=i,d=s||this.ctx.maxColIndex-a,f=o,u=r||this.ctx.maxRowIndex-l;return!(e<h||e>d||t<f||t>u)}startAdjustPosition(t){const{offsetX:e,offsetY:i}=this.ctx.getOffset(t);let s="",o="";if(e<0?s="left":e>this.ctx.body.visibleWidth&&(s="right"),i<this.ctx.header.visibleHeight?o="top":i>this.ctx.header.visibleHeight+this.ctx.body.visibleHeight&&(o="bottom"),s&&this.adjustPositionX!==s){this.adjustPositionX=s;let a=10*(s==="left"?-1:1);this.timerX&&(clearInterval(this.timerX),this.timerX=0),this.timerX=setInterval(()=>{a*=1.5;const{scrollX:l}=this.ctx,h=l+a;(h<0||h>this.ctx.body.width)&&(clearInterval(this.timerX),this.timerX=0),this.ctx.setScrollX(h)},100)}if(o&&this.adjustPositionY!==o){this.adjustPositionY=o;let a=10*(o==="top"?-1:1);this.timerY&&(clearInterval(this.timerY),this.timerY=0),this.timerY=setInterval(()=>{a*=1.5;const{scrollY:l}=this.ctx,h=l+a;(h<0||h>this.ctx.body.height)&&(clearInterval(this.timerY),this.timerY=0),this.ctx.setScrollY(h)},100)}}adjustBoundaryPosition(){const{stageHeight:t,stageWidth:e,focusCell:i,fixedRightWidth:s,fixedLeftWidth:o,header:r,footer:a,body:l,scrollX:h,scrollY:d,config:{SCROLLER_TRACK_SIZE:f,FOOTER_FIXED:u,FOOTER_POSITION:x,ENABLE_MERGE_CELL_LINK:w}}=this.ctx;if(!i)return;w&&this.ctx.onlyMergeCell&&i.updateSpanInfo();const{drawX:E,drawY:g,width:m,height:y,fixed:p}=i,R=o-E+1,C=i.drawX+m-(e-s)+1;let I=r.height-g,_=y;_>l.visibleHeight&&(_=l.visibleHeight);let v=0;u&&(x==="top"?I=r.height+a.height-g:v=a.visibleHeight);const S=g+_-(t-v-f);let b=h,O=d;C>0&&!p?b=Math.floor(h+C):R>0&&!p&&(b=Math.floor(h-R)),I>0?O=Math.floor(d-I):S>0&&(O=Math.floor(d+S)),(Math.abs(h-b)>2||Math.abs(d-O)>2)&&(this.ctx.adjustPositioning=!0,this.ctx.setScroll(b,O),this.ctx.emit("adjustBoundaryPosition",i))}destroy(){this.timerX&&(clearTimeout(this.timerX),this.timerX=0),this.timerY&&(clearTimeout(this.timerY),this.timerY=0)}}class Le{constructor(t){n(this,"ctx");n(this,"maxColRowCell");this.ctx=t,this.init()}init(){this.ctx.on("mousemove",t=>{if(this.ctx.stageElement.style.cursor==="crosshair"&&(this.ctx.stageElement.style.cursor="default"),this.ctx.editing||!this.ctx.focusCell||!this.maxColRowCell)return;const{offsetX:e,offsetY:i}=this.ctx.getOffset(t),{colIndex:s,rowIndex:o,drawX:r,drawY:a,width:l,height:h}=this.maxColRowCell,d=6,f=s===this.ctx.maxColIndex||o===this.ctx.maxRowIndex?0:2,u=r+l-d+f,x=a+h-d+f;e>u&&i>x&&e<u+d&&i<x+d&&(this.ctx.stageElement.style.cursor="crosshair")}),this.ctx.on("cellMouseenter",t=>{const{xArr:e,yArr:i}=this.ctx.selector,s=e[1],o=i[1],{colIndex:r,rowIndex:a}=t;this.ctx.config.ENABLE_AUTOFILL&&r===s&&a===o&&(this.maxColRowCell=t),this.mouseenter(t)}),this.ctx.on("mousedown",()=>{this.ctx.stageElement.style.cursor==="crosshair"&&this.setMousedown()}),this.ctx.on("mouseup",()=>{this.setMouseUp()})}isAutofillIng(){const{xArr:t,yArr:e}=this.ctx.selector;return!(JSON.stringify(this.ctx.autofill.xArr)===JSON.stringify(t)&&JSON.stringify(this.ctx.autofill.yArr)===JSON.stringify(e))}setMousedown(){this.ctx.autofill.enable=!0,this.ctx.autofillMove=!0}setMouseUp(){if(!this.ctx.autofill.enable)return;this.isAutofillIng()&&this.autofillData(),this.ctx.autofill.enable=!1,this.ctx.autofillMove=!1,this.ctx.autofill.xArr=[-1,-1],this.ctx.autofill.yArr=[-1,-1]}setAutofill(t,e){const{ENABLE_AUTOFILL:i,ENABLE_SELECTOR_SPAN_COL:s,ENABLE_SELECTOR_SPAN_ROW:o}=this.ctx.config;if(!i)return;let r=t,a=e;if(!o){const[l]=a;a=[l,l]}if(!s){const[l]=r;r=[l,l]}if(JSON.stringify(this.ctx.autofill.xArr)!==JSON.stringify(r)||JSON.stringify(this.ctx.autofill.yArr)!==JSON.stringify(a)){const{SELECTOR_AREA_MIN_X:l,SELECTOR_AREA_MAX_X:h,SELECTOR_AREA_MIN_Y:d,SELECTOR_AREA_MAX_Y:f,SELECTOR_AREA_MAX_X_OFFSET:u,SELECTOR_AREA_MAX_Y_OFFSET:x}=this.ctx.config,w=l,E=h||this.ctx.maxColIndex-u,g=d,m=f||this.ctx.maxRowIndex-x;let[y,p]=r,[R,C]=a;if(y<w||R<g)return;r=[Math.max(w,y),Math.min(E,p)],a=[Math.max(g,R),Math.min(m,C)];const{BEFORE_SET_AUTOFILL_METHOD:I}=this.ctx.config;if(typeof I=="function"){const v=I({focusCell:this.ctx.focusCell,xArr:r,yArr:a});if(!v)return;r=v.xArr,a=v.yArr}this.ctx.autofill.xArr=r,this.ctx.autofill.yArr=a,this.ctx.emit("setAutofill",this.ctx.autofill),this.ctx.emit("draw")}}async autofillData(){const t=new Set,e=this.ctx.getSelectedData(),i=new Map;for(let x=0;x<=e.yArr[1]-e.yArr[0];x++)for(let w=0;w<=e.xArr[1]-e.xArr[0];w++){const E=x+e.yArr[0],g=w+e.xArr[0];i.set(`${E}-${g}`,!0)}const{value:s}=e,o=s[0].length,r=s.length,a=this.ctx.autofill.xArr,l=this.ctx.autofill.yArr,h=o===1&&r===1;if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.database.hasMergeCell(a,l)&&!h){const x={code:"ERR_MERGED_CELLS_AUTOFILL",message:"Merged cells cannot span autofill data"};this.ctx.hasEvent("error")?this.ctx.emit("error",x):alert(x.message);return}let d=[];for(let x=0;x<=l[1]-l[0];x++)for(let w=0;w<=a[1]-a[0];w++){const E=w+a[0],g=x+l[0],m=s[x%r][w%o],y=this.ctx.database.getItemValueForRowIndexAndColIndex(g,E),p=`${g}-${E}`;if(y&&!i.has(p)){const{rowKey:R,key:C}=y;this.ctx.database.getReadonly(R,C)||(t.add(R),d.push({rowKey:R,key:C,value:m,row:{}}))}}if(!d.length)return;this.ctx.selector.xArr=this.ctx.autofill.xArr,this.ctx.selector.yArr=this.ctx.autofill.yArr;const{BEFORE_AUTOFILL_DATA_METHOD:f}=this.ctx.config;if(typeof f=="function"){const x=f,w=d.map(E=>({rowKey:E.rowKey,key:E.key,value:E.value,oldValue:this.ctx.database.getItemValue(E.rowKey,E.key),row:this.ctx.database.getRowDataItemForRowKey(E.rowKey)}));if(d=await x(w,a,l),d&&!d.length)return}this.ctx.batchSetItemValueByEditor(d,!0);let u=[];t.forEach(x=>{u.push(this.ctx.database.getRowDataItemForRowKey(x))}),this.ctx.emit("autofillChange",d,u),this.ctx.emit("draw")}mouseenter(t){if(["index","selection","index-selection"].includes(t.type))return;const{selector:e,autofill:i}=this.ctx;if(this.ctx.mousedown&&e.enable&&i.enable){const{rowIndex:s,colIndex:o}=t,r=e.xArr.slice(),a=e.yArr.slice();s>=e.yArr[0]&&s<=e.yArr[1]?o>e.xArr[1]?r.splice(1,1,o):o<e.xArr[0]&&r.splice(0,1,o):s>e.yArr[1]?a.splice(1,1,s):s<e.yArr[0]&&a.splice(0,1,s),this.setAutofill(r,a)}}destroy(){}}const q=Math.min,$=Math.max,st=Math.round,B=c=>({x:c,y:c}),Me={left:"right",right:"left",bottom:"top",top:"bottom"},Ae={start:"end",end:"start"};function dt(c,t,e){return $(c,q(t,e))}function Q(c,t){return typeof c=="function"?c(t):c}function z(c){return c.split("-")[0]}function tt(c){return c.split("-")[1]}function Wt(c){return c==="x"?"y":"x"}function wt(c){return c==="y"?"height":"width"}const He=new Set(["top","bottom"]);function V(c){return He.has(z(c))?"y":"x"}function Et(c){return Wt(V(c))}function De(c,t,e){e===void 0&&(e=!1);const i=tt(c),s=Et(c),o=wt(s);let r=s==="x"?i===(e?"end":"start")?"right":"left":i==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(r=ot(r)),[r,ot(r)]}function Ne(c){const t=ot(c);return[ft(c),t,ft(t)]}function ft(c){return c.replace(/start|end/g,t=>Ae[t])}const Tt=["left","right"],Ot=["right","left"],ke=["top","bottom"],Xe=["bottom","top"];function Ye(c,t,e){switch(c){case"top":case"bottom":return e?t?Ot:Tt:t?Tt:Ot;case"left":case"right":return t?ke:Xe;default:return[]}}function Be(c,t,e,i){const s=tt(c);let o=Ye(z(c),e==="start",i);return s&&(o=o.map(r=>r+"-"+s),t&&(o=o.concat(o.map(ft)))),o}function ot(c){return c.replace(/left|right|bottom|top/g,t=>Me[t])}function Ke(c){return{top:0,right:0,bottom:0,left:0,...c}}function Ft(c){return typeof c!="number"?Ke(c):{top:c,right:c,bottom:c,left:c}}function rt(c){const{x:t,y:e,width:i,height:s}=c;return{width:i,height:s,top:e,left:t,right:t+i,bottom:e+s,x:t,y:e}}function Lt(c,t,e){let{reference:i,floating:s}=c;const o=V(t),r=Et(t),a=wt(r),l=z(t),h=o==="y",d=i.x+i.width/2-s.width/2,f=i.y+i.height/2-s.height/2,u=i[a]/2-s[a]/2;let x;switch(l){case"top":x={x:d,y:i.y-s.height};break;case"bottom":x={x:d,y:i.y+i.height};break;case"right":x={x:i.x+i.width,y:f};break;case"left":x={x:i.x-s.width,y:f};break;default:x={x:i.x,y:i.y}}switch(tt(t)){case"start":x[r]-=u*(e&&h?-1:1);break;case"end":x[r]+=u*(e&&h?-1:1);break}return x}const We=async(c,t,e)=>{const{placement:i="bottom",strategy:s="absolute",middleware:o=[],platform:r}=e,a=o.filter(Boolean),l=await(r.isRTL==null?void 0:r.isRTL(t));let h=await r.getElementRects({reference:c,floating:t,strategy:s}),{x:d,y:f}=Lt(h,i,l),u=i,x={},w=0;for(let E=0;E<a.length;E++){const{name:g,fn:m}=a[E],{x:y,y:p,data:R,reset:C}=await m({x:d,y:f,initialPlacement:i,placement:u,strategy:s,middlewareData:x,rects:h,platform:r,elements:{reference:c,floating:t}});d=y??d,f=p??f,x={...x,[g]:{...x[g],...R}},C&&w<=50&&(w++,typeof C=="object"&&(C.placement&&(u=C.placement),C.rects&&(h=C.rects===!0?await r.getElementRects({reference:c,floating:t,strategy:s}):C.rects),{x:d,y:f}=Lt(h,u,l)),E=-1)}return{x:d,y:f,placement:u,strategy:s,middlewareData:x}};async function Vt(c,t){var e;t===void 0&&(t={});const{x:i,y:s,platform:o,rects:r,elements:a,strategy:l}=c,{boundary:h="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:u=!1,padding:x=0}=Q(t,c),w=Ft(x),g=a[u?f==="floating"?"reference":"floating":f],m=rt(await o.getClippingRect({element:(e=await(o.isElement==null?void 0:o.isElement(g)))==null||e?g:g.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(a.floating)),boundary:h,rootBoundary:d,strategy:l})),y=f==="floating"?{x:i,y:s,width:r.floating.width,height:r.floating.height}:r.reference,p=await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),R=await(o.isElement==null?void 0:o.isElement(p))?await(o.getScale==null?void 0:o.getScale(p))||{x:1,y:1}:{x:1,y:1},C=rt(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:y,offsetParent:p,strategy:l}):y);return{top:(m.top-C.top+w.top)/R.y,bottom:(C.bottom-m.bottom+w.bottom)/R.y,left:(m.left-C.left+w.left)/R.x,right:(C.right-m.right+w.right)/R.x}}const Fe=c=>({name:"arrow",options:c,async fn(t){const{x:e,y:i,placement:s,rects:o,platform:r,elements:a,middlewareData:l}=t,{element:h,padding:d=0}=Q(c,t)||{};if(h==null)return{};const f=Ft(d),u={x:e,y:i},x=Et(s),w=wt(x),E=await r.getDimensions(h),g=x==="y",m=g?"top":"left",y=g?"bottom":"right",p=g?"clientHeight":"clientWidth",R=o.reference[w]+o.reference[x]-u[x]-o.floating[w],C=u[x]-o.reference[x],I=await(r.getOffsetParent==null?void 0:r.getOffsetParent(h));let _=I?I[p]:0;(!_||!await(r.isElement==null?void 0:r.isElement(I)))&&(_=a.floating[p]||o.floating[w]);const v=R/2-C/2,S=_/2-E[w]/2-1,b=q(f[m],S),O=q(f[y],S),T=b,M=_-E[w]-O,L=_/2-E[w]/2+v,A=dt(T,L,M),D=!l.arrow&&tt(s)!=null&&L!==A&&o.reference[w]/2-(L<T?b:O)-E[w]/2<0,N=D?L<T?L-T:L-M:0;return{[x]:u[x]+N,data:{[x]:A,centerOffset:L-A-N,...D&&{alignmentOffset:N}},reset:D}}}),Ve=function(c){return c===void 0&&(c={}),{name:"flip",options:c,async fn(t){var e,i;const{placement:s,middlewareData:o,rects:r,initialPlacement:a,platform:l,elements:h}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:u,fallbackStrategy:x="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:E=!0,...g}=Q(c,t);if((e=o.arrow)!=null&&e.alignmentOffset)return{};const m=z(s),y=V(a),p=z(a)===a,R=await(l.isRTL==null?void 0:l.isRTL(h.floating)),C=u||(p||!E?[ot(a)]:Ne(a)),I=w!=="none";!u&&I&&C.push(...Be(a,E,w,R));const _=[a,...C],v=await Vt(t,g),S=[];let b=((i=o.flip)==null?void 0:i.overflows)||[];if(d&&S.push(v[m]),f){const L=De(s,r,R);S.push(v[L[0]],v[L[1]])}if(b=[...b,{placement:s,overflows:S}],!S.every(L=>L<=0)){var O,T;const L=(((O=o.flip)==null?void 0:O.index)||0)+1,A=_[L];if(A&&(!(f==="alignment"?y!==V(A):!1)||b.every(k=>V(k.placement)===y?k.overflows[0]>0:!0)))return{data:{index:L,overflows:b},reset:{placement:A}};let D=(T=b.filter(N=>N.overflows[0]<=0).sort((N,k)=>N.overflows[1]-k.overflows[1])[0])==null?void 0:T.placement;if(!D)switch(x){case"bestFit":{var M;const N=(M=b.filter(k=>{if(I){const F=V(k.placement);return F===y||F==="y"}return!0}).map(k=>[k.placement,k.overflows.filter(F=>F>0).reduce((F,se)=>F+se,0)]).sort((k,F)=>k[1]-F[1])[0])==null?void 0:M[0];N&&(D=N);break}case"initialPlacement":D=a;break}if(s!==D)return{reset:{placement:D}}}return{}}}},Pe=new Set(["left","top"]);async function ze(c,t){const{placement:e,platform:i,elements:s}=c,o=await(i.isRTL==null?void 0:i.isRTL(s.floating)),r=z(e),a=tt(e),l=V(e)==="y",h=Pe.has(r)?-1:1,d=o&&l?-1:1,f=Q(t,c);let{mainAxis:u,crossAxis:x,alignmentAxis:w}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof w=="number"&&(x=a==="end"?w*-1:w),l?{x:x*d,y:u*h}:{x:u*h,y:x*d}}const $e=function(c){return c===void 0&&(c=0),{name:"offset",options:c,async fn(t){var e,i;const{x:s,y:o,placement:r,middlewareData:a}=t,l=await ze(t,c);return r===((e=a.offset)==null?void 0:e.placement)&&(i=a.arrow)!=null&&i.alignmentOffset?{}:{x:s+l.x,y:o+l.y,data:{...l,placement:r}}}}},Ge=function(c){return c===void 0&&(c={}),{name:"shift",options:c,async fn(t){const{x:e,y:i,placement:s}=t,{mainAxis:o=!0,crossAxis:r=!1,limiter:a={fn:g=>{let{x:m,y}=g;return{x:m,y}}},...l}=Q(c,t),h={x:e,y:i},d=await Vt(t,l),f=V(z(s)),u=Wt(f);let x=h[u],w=h[f];if(o){const g=u==="y"?"top":"left",m=u==="y"?"bottom":"right",y=x+d[g],p=x-d[m];x=dt(y,x,p)}if(r){const g=f==="y"?"top":"left",m=f==="y"?"bottom":"right",y=w+d[g],p=w-d[m];w=dt(y,w,p)}const E=a.fn({...t,[u]:x,[f]:w});return{...E,data:{x:E.x-e,y:E.y-i,enabled:{[u]:o,[f]:r}}}}}};function nt(){return typeof window<"u"}function Z(c){return Pt(c)?(c.nodeName||"").toLowerCase():"#document"}function H(c){var t;return(c==null||(t=c.ownerDocument)==null?void 0:t.defaultView)||window}function W(c){var t;return(t=(Pt(c)?c.ownerDocument:c.document)||window.document)==null?void 0:t.documentElement}function Pt(c){return nt()?c instanceof Node||c instanceof H(c).Node:!1}function X(c){return nt()?c instanceof Element||c instanceof H(c).Element:!1}function K(c){return nt()?c instanceof HTMLElement||c instanceof H(c).HTMLElement:!1}function Mt(c){return!nt()||typeof ShadowRoot>"u"?!1:c instanceof ShadowRoot||c instanceof H(c).ShadowRoot}const Ue=new Set(["inline","contents"]);function et(c){const{overflow:t,overflowX:e,overflowY:i,display:s}=Y(c);return/auto|scroll|overlay|hidden|clip/.test(t+i+e)&&!Ue.has(s)}const Ze=new Set(["table","td","th"]);function je(c){return Ze.has(Z(c))}const qe=[":popover-open",":modal"];function at(c){return qe.some(t=>{try{return c.matches(t)}catch{return!1}})}const Je=["transform","translate","scale","rotate","perspective"],Qe=["transform","translate","scale","rotate","perspective","filter"],ti=["paint","layout","strict","content"];function mt(c){const t=pt(),e=X(c)?Y(c):c;return Je.some(i=>e[i]?e[i]!=="none":!1)||(e.containerType?e.containerType!=="normal":!1)||!t&&(e.backdropFilter?e.backdropFilter!=="none":!1)||!t&&(e.filter?e.filter!=="none":!1)||Qe.some(i=>(e.willChange||"").includes(i))||ti.some(i=>(e.contain||"").includes(i))}function ei(c){let t=P(c);for(;K(t)&&!U(t);){if(mt(t))return t;if(at(t))return null;t=P(t)}return null}function pt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const ii=new Set(["html","body","#document"]);function U(c){return ii.has(Z(c))}function Y(c){return H(c).getComputedStyle(c)}function lt(c){return X(c)?{scrollLeft:c.scrollLeft,scrollTop:c.scrollTop}:{scrollLeft:c.scrollX,scrollTop:c.scrollY}}function P(c){if(Z(c)==="html")return c;const t=c.assignedSlot||c.parentNode||Mt(c)&&c.host||W(c);return Mt(t)?t.host:t}function zt(c){const t=P(c);return U(t)?c.ownerDocument?c.ownerDocument.body:c.body:K(t)&&et(t)?t:zt(t)}function $t(c,t,e){var i;t===void 0&&(t=[]);const s=zt(c),o=s===((i=c.ownerDocument)==null?void 0:i.body),r=H(s);return o?(xt(r),t.concat(r,r.visualViewport||[],et(s)?s:[],[])):t.concat(s,$t(s,[]))}function xt(c){return c.parent&&Object.getPrototypeOf(c.parent)?c.frameElement:null}function Gt(c){const t=Y(c);let e=parseFloat(t.width)||0,i=parseFloat(t.height)||0;const s=K(c),o=s?c.offsetWidth:e,r=s?c.offsetHeight:i,a=st(e)!==o||st(i)!==r;return a&&(e=o,i=r),{width:e,height:i,$:a}}function Ut(c){return X(c)?c:c.contextElement}function G(c){const t=Ut(c);if(!K(t))return B(1);const e=t.getBoundingClientRect(),{width:i,height:s,$:o}=Gt(t);let r=(o?st(e.width):e.width)/i,a=(o?st(e.height):e.height)/s;return(!r||!Number.isFinite(r))&&(r=1),(!a||!Number.isFinite(a))&&(a=1),{x:r,y:a}}const si=B(0);function Zt(c){const t=H(c);return!pt()||!t.visualViewport?si:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function oi(c,t,e){return t===void 0&&(t=!1),!e||t&&e!==H(c)?!1:t}function J(c,t,e,i){t===void 0&&(t=!1),e===void 0&&(e=!1);const s=c.getBoundingClientRect(),o=Ut(c);let r=B(1);t&&(i?X(i)&&(r=G(i)):r=G(c));const a=oi(o,e,i)?Zt(o):B(0);let l=(s.left+a.x)/r.x,h=(s.top+a.y)/r.y,d=s.width/r.x,f=s.height/r.y;if(o){const u=H(o),x=i&&X(i)?H(i):i;let w=u,E=xt(w);for(;E&&i&&x!==w;){const g=G(E),m=E.getBoundingClientRect(),y=Y(E),p=m.left+(E.clientLeft+parseFloat(y.paddingLeft))*g.x,R=m.top+(E.clientTop+parseFloat(y.paddingTop))*g.y;l*=g.x,h*=g.y,d*=g.x,f*=g.y,l+=p,h+=R,w=H(E),E=xt(w)}}return rt({width:d,height:f,x:l,y:h})}function yt(c,t){const e=lt(c).scrollLeft;return t?t.left+e:J(W(c)).left+e}function jt(c,t,e){e===void 0&&(e=!1);const i=c.getBoundingClientRect(),s=i.left+t.scrollLeft-(e?0:yt(c,i)),o=i.top+t.scrollTop;return{x:s,y:o}}function ri(c){let{elements:t,rect:e,offsetParent:i,strategy:s}=c;const o=s==="fixed",r=W(i),a=t?at(t.floating):!1;if(i===r||a&&o)return e;let l={scrollLeft:0,scrollTop:0},h=B(1);const d=B(0),f=K(i);if((f||!f&&!o)&&((Z(i)!=="body"||et(r))&&(l=lt(i)),K(i))){const x=J(i);h=G(i),d.x=x.x+i.clientLeft,d.y=x.y+i.clientTop}const u=r&&!f&&!o?jt(r,l,!0):B(0);return{width:e.width*h.x,height:e.height*h.y,x:e.x*h.x-l.scrollLeft*h.x+d.x+u.x,y:e.y*h.y-l.scrollTop*h.y+d.y+u.y}}function ni(c){return Array.from(c.getClientRects())}function ai(c){const t=W(c),e=lt(c),i=c.ownerDocument.body,s=$(t.scrollWidth,t.clientWidth,i.scrollWidth,i.clientWidth),o=$(t.scrollHeight,t.clientHeight,i.scrollHeight,i.clientHeight);let r=-e.scrollLeft+yt(c);const a=-e.scrollTop;return Y(i).direction==="rtl"&&(r+=$(t.clientWidth,i.clientWidth)-s),{width:s,height:o,x:r,y:a}}function li(c,t){const e=H(c),i=W(c),s=e.visualViewport;let o=i.clientWidth,r=i.clientHeight,a=0,l=0;if(s){o=s.width,r=s.height;const h=pt();(!h||h&&t==="fixed")&&(a=s.offsetLeft,l=s.offsetTop)}return{width:o,height:r,x:a,y:l}}const hi=new Set(["absolute","fixed"]);function ci(c,t){const e=J(c,!0,t==="fixed"),i=e.top+c.clientTop,s=e.left+c.clientLeft,o=K(c)?G(c):B(1),r=c.clientWidth*o.x,a=c.clientHeight*o.y,l=s*o.x,h=i*o.y;return{width:r,height:a,x:l,y:h}}function At(c,t,e){let i;if(t==="viewport")i=li(c,e);else if(t==="document")i=ai(W(c));else if(X(t))i=ci(t,e);else{const s=Zt(c);i={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return rt(i)}function qt(c,t){const e=P(c);return e===t||!X(e)||U(e)?!1:Y(e).position==="fixed"||qt(e,t)}function di(c,t){const e=t.get(c);if(e)return e;let i=$t(c,[]).filter(a=>X(a)&&Z(a)!=="body"),s=null;const o=Y(c).position==="fixed";let r=o?P(c):c;for(;X(r)&&!U(r);){const a=Y(r),l=mt(r);!l&&a.position==="fixed"&&(s=null),(o?!l&&!s:!l&&a.position==="static"&&!!s&&hi.has(s.position)||et(r)&&!l&&qt(c,r))?i=i.filter(d=>d!==r):s=a,r=P(r)}return t.set(c,i),i}function fi(c){let{element:t,boundary:e,rootBoundary:i,strategy:s}=c;const r=[...e==="clippingAncestors"?at(t)?[]:di(t,this._c):[].concat(e),i],a=r[0],l=r.reduce((h,d)=>{const f=At(t,d,s);return h.top=$(f.top,h.top),h.right=q(f.right,h.right),h.bottom=q(f.bottom,h.bottom),h.left=$(f.left,h.left),h},At(t,a,s));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function xi(c){const{width:t,height:e}=Gt(c);return{width:t,height:e}}function ui(c,t,e){const i=K(t),s=W(t),o=e==="fixed",r=J(c,!0,o,t);let a={scrollLeft:0,scrollTop:0};const l=B(0);function h(){l.x=yt(s)}if(i||!i&&!o)if((Z(t)!=="body"||et(s))&&(a=lt(t)),i){const x=J(t,!0,o,t);l.x=x.x+t.clientLeft,l.y=x.y+t.clientTop}else s&&h();o&&!i&&s&&h();const d=s&&!i&&!o?jt(s,a):B(0),f=r.left+a.scrollLeft-l.x-d.x,u=r.top+a.scrollTop-l.y-d.y;return{x:f,y:u,width:r.width,height:r.height}}function ht(c){return Y(c).position==="static"}function Ht(c,t){if(!K(c)||Y(c).position==="fixed")return null;if(t)return t(c);let e=c.offsetParent;return W(c)===e&&(e=e.ownerDocument.body),e}function Jt(c,t){const e=H(c);if(at(c))return e;if(!K(c)){let s=P(c);for(;s&&!U(s);){if(X(s)&&!ht(s))return s;s=P(s)}return e}let i=Ht(c,t);for(;i&&je(i)&&ht(i);)i=Ht(i,t);return i&&U(i)&&ht(i)&&!mt(i)?e:i||ei(c)||e}const gi=async function(c){const t=this.getOffsetParent||Jt,e=this.getDimensions,i=await e(c.floating);return{reference:ui(c.reference,await t(c.floating),c.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function wi(c){return Y(c).direction==="rtl"}const Ei={convertOffsetParentRelativeRectToViewportRelativeRect:ri,getDocumentElement:W,getClippingRect:fi,getOffsetParent:Jt,getElementRects:gi,getClientRects:ni,getDimensions:xi,getScale:G,isElement:X,isRTL:wi},Qt=$e,te=Ge,ee=Ve,mi=Fe,ie=(c,t,e)=>{const i=new Map,s={platform:Ei,...e},o={...s.platform,_c:i};return We(c,t,{...s,platform:o})};let pi=class{constructor(t){n(this,"ctx");n(this,"enable",!1);n(this,"contentEl");n(this,"floatingEl");n(this,"arrowEl");this.ctx=t;const{TOOLTIP_BG_COLOR:e,TOOLTIP_TEXT_COLOR:i,TOOLTIP_ZINDEX:s,TOOLTIP_CUSTOM_STYLE:o,CSS_PREFIX:r}=this.ctx.config;this.contentEl=document.createElement("div"),this.arrowEl=document.createElement("div"),this.floatingEl=document.createElement("div"),this.floatingEl.className=`${r}-tooltip`,this.contentEl.className=`${r}-tooltip-content`,this.arrowEl.className=`${r}-tooltip-arrow`;const a={display:"none",position:"absolute",background:e,color:i,boxSizing:"border-box",zIndex:s,padding:"8px",borderRadius:"4px",fontSize:"12px",...o},l={position:"absolute",width:"10px",height:"10px",background:a.background,backgroundColor:a.backgroundColor,transform:"rotate(45deg)",zIndex:a.zIndex};Object.assign(this.arrowEl.style,l),Object.assign(this.floatingEl.style,a),this.floatingEl.appendChild(this.contentEl),this.floatingEl.appendChild(this.arrowEl),this.ctx.containerElement.appendChild(this.floatingEl),this.init()}init(){this.floatingEl.addEventListener("mouseleave",()=>{this.hide()}),this.ctx.on("mouseout",t=>{this.floatingEl.contains(t.relatedTarget)||this.hide()}),this.ctx.on("onScroll",()=>{this.hide()}),this.ctx.on("startEdit",()=>{this.hide()}),this.ctx.on("visibleCellHoverChange",(t,e)=>{this.floatingEl.contains(e.target)||(t.ellipsis||t.message)&&this.show(t)}),this.ctx.on("visibleCellMouseleave",(t,e)=>{this.floatingEl.contains(e.target)||this.hide()}),this.ctx.on("cellHeaderMouseleave",(t,e)=>{this.floatingEl.contains(e.target)||this.hide()}),this.ctx.on("cellHeaderHoverChange",(t,e)=>{this.floatingEl.contains(e.target)||t.ellipsis&&this.show(t)})}show(t){if(!t.overflowTooltipShow||this.ctx.mousedown)return;this.floatingEl.style.display="block";let e=t.getText();t.message&&(e=t.message);const i=this.ctx.containerElement.getBoundingClientRect();if(!i)return;this.enable=!0,this.contentEl.style.maxWidth=`${t.overflowTooltipMaxWidth||500}px`,this.contentEl.style.minWidth="100px",this.contentEl.style.width="100%",this.contentEl.style.display="inline-block",this.contentEl.style.wordBreak="break-all",this.contentEl.style.lineHeight="1.5",this.contentEl.innerText=e;const s=t.drawX+i.x,o=t.drawY+i.y;ie({getBoundingClientRect(){return{width:t.visibleWidth,height:t.visibleHeight,x:s,y:o,left:s,right:s+t.visibleWidth,top:o,bottom:o+t.visibleHeight}}},this.floatingEl,{placement:t.overflowTooltipPlacement,middleware:[te(),ee(),Qt(6),mi({element:this.arrowEl})]}).then(a=>{const{x:l,y:h,placement:d,middlewareData:f}=a;if(Object.assign(this.floatingEl.style,{top:`${h}px`,left:`${l}px`}),f.arrow){const u=f.arrow;["left","left-start","left-end"].includes(d)?Object.assign(this.arrowEl.style,{top:`${u.y}px`,bottom:"",left:"",right:"-5px"}):["right","right-start","right-end"].includes(d)?Object.assign(this.arrowEl.style,{top:`${u.y}px`,bottom:"",left:"-5px",right:""}):["bottom","bottom-start","bottom-end"].includes(d)?Object.assign(this.arrowEl.style,{top:"-5px",bottom:"",left:`${u.x}px`,right:""}):["top","top-start","top-end"].includes(d)&&Object.assign(this.arrowEl.style,{top:"",bottom:"-5px",left:`${u.x}px`,right:""})}})}hide(){this.enable&&(this.enable=!1,this.floatingEl.style.display="none")}destroy(){this.contentEl.remove(),this.arrowEl.remove(),this.floatingEl.remove()}};class yi{constructor(t){n(this,"editorEl");n(this,"inputEl");n(this,"enable",!1);n(this,"cellTarget",null);n(this,"selectorArrStr","");n(this,"ctx");n(this,"drawY",0);n(this,"drawX",0);n(this,"cancel",!1);this.ctx=t,this.initTextEditor(),this.init()}init(){this.ctx.on("outsideMousedown",()=>{this.cellTarget&&this.cellTarget.editorType==="text"&&this.clearEditor()}),this.ctx.on("moveFocus",t=>{this.cellTarget=t;const{xArr:e,yArr:i}=this.ctx.selector;this.selectorArrStr=JSON.stringify(e)+JSON.stringify(i)}),this.ctx.on("onScroll",()=>{this.enable&&this.doneEdit()}),this.ctx.on("cellHeaderMousedown",()=>{this.enable&&this.doneEdit(),this.cellTarget=null}),this.ctx.on("hoverIconClick",t=>{t.editorType!=="none"&&this.editCell(t.rowIndex,t.colIndex)}),this.ctx.on("keydown",t=>{if(!this.ctx.isTarget(t)||!this.ctx.focusCell)return;if(t.code==="Escape"&&this.ctx.editing){this.cancel=!0;const{focusCell:l}=this.ctx;l&&(this.ctx.emit("setSelectorCell",l),this.cellTarget=l),this.doneEdit();return}if((t.altKey||t.metaKey)&&t.code==="Enter"&&this.ctx.editing&&this.inputEl){t.preventDefault();const l=this.inputEl.selectionStart,h=this.inputEl.value.substring(0,l),d=this.inputEl.value.substring(l);this.inputEl.value=h+`
|
|
6
|
-
`+d,this.inputEl.selectionStart=this.inputEl.selectionEnd=l+1,this.autoSize();return}if(t.code==="Tab"&&this.ctx.editing){if(t.preventDefault(),this.doneEdit(),t.shiftKey){this.ctx.emit("setMoveFocus","LEFT");return}this.ctx.emit("setMoveFocus","RIGHT");return}if(t.code==="Enter"&&this.ctx.editing){if(t.preventDefault(),this.doneEdit(),t.shiftKey){this.ctx.emit("setMoveFocus","TOP");return}this.ctx.emit("setMoveFocus","BOTTOM");return}if(t.code==="Enter"&&!this.ctx.editing){t.preventDefault(),this.startEdit();return}const e=t.key,i=t.ctrlKey,s=t.altKey,o=t.shiftKey,r=t.metaKey;i||s||o||r||["Enter","Escape","Tab","Backspace","Delete","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown","Insert","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12"].includes(e)||this.startEdit(!0)}),this.ctx.on("cellMouseup",t=>{if(this.ctx.adjustPositioning||this.ctx.isPointer||!this.isInSelectorRange(t.rowIndex,t.colIndex))return;const{xArr:e,yArr:i}=this.ctx.selector,s=JSON.stringify(e)+JSON.stringify(i);if(this.selectorArrStr===s&&this.cellTarget){if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.onlyMergeCell){this.startEdit();return}if(this.ctx.selectOnlyOne&&t.rowKey===this.cellTarget.rowKey&&t.key===this.cellTarget.key){this.startEdit();return}}if(this.selectorArrStr=s,this.doneEdit(),this.cellTarget=t,this.ctx.config.ENABLE_EDIT_SINGLE_CLICK){if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.onlyMergeCell){this.startEdit();return}this.ctx.selectOnlyOne&&this.startEdit()}})}isInSelectorRange(t,e){const{xArr:i,yArr:s}=this.ctx.selector,[o,r]=i,[a,l]=s;return!(e<o||e>r||t<a||t>l)}initTextEditor(){this.inputEl=document.createElement("textarea"),this.inputEl.setAttribute("rows","1"),this.inputEl.addEventListener("input",this.autoSize.bind(this)),this.inputEl.addEventListener("blur",()=>{this.doneEdit()}),this.editorEl=this.ctx.editorElement,this.inputEl.className="e-virt-table-editor-textarea",this.editorEl.appendChild(this.inputEl),this.ctx.containerElement.appendChild(this.editorEl)}autoSize(){this.inputEl.style.height="auto";let t=this.inputEl.scrollHeight,e=this.ctx.body.visibleHeight;t>e&&(t=e);const{stageHeight:i,footer:s,header:o,config:{SCROLLER_TRACK_SIZE:r}}=this.ctx,a=i-s.height-r;this.editorEl.style.bottom="auto",this.drawY<o.height&&(this.editorEl.style.top=`${o.height-1}px`),this.drawY+t>a&&(this.editorEl.style.left=`${this.drawX-1}px`,this.editorEl.style.top="auto",this.editorEl.style.bottom=`${i-a}px`),this.inputEl.style.height=`${t}px`}startEditByInput(t,e=!1){const i=e?null:t.getValue(),{editorType:s}=t;t.update(),this.ctx.config.ENABLE_MERGE_CELL_LINK&&t.updateSpanInfo();let{height:o,width:r,drawY:a,drawX:l}=t;this.drawX=l,this.drawY=a;const{config:{CELL_PADDING:h},header:d}=this.ctx;let f=this.ctx.body.visibleHeight;if(o>f&&(o=f),this.editorEl.style.display="inline-block",this.editorEl.style.left=`${this.drawX-1}px`,this.editorEl.style.top=`${this.drawY-1}px`,this.editorEl.style.bottom="auto",this.editorEl.style.maxHeight=`${f}px`,s==="text"){this.inputEl.style.display="block",this.inputEl.style.minWidth=`${r-1}px`,this.inputEl.style.minHeight=`${o-1}px`,this.inputEl.style.maxHeight=`${f}px`,this.inputEl.style.width=`${r-1}px`,this.inputEl.style.height="auto",this.inputEl.style.padding=`${h}px`,i!==null&&(this.inputEl.value=i),this.inputEl.focus({preventScroll:!0});const u=this.inputEl.value.length;this.inputEl.setSelectionRange(u,u)}else this.inputEl.style.display="none";(this.inputEl.scrollHeight>o||this.drawY<d.height)&&this.autoSize()}doneEditByInput(){if(this.cellTarget&&this.cellTarget.editorType==="text"){const{rowKey:t,key:e}=this.cellTarget,i=this.cellTarget.getValue(),s=this.inputEl.value;s!==i&&!(s===""&&i===null)&&!this.cancel&&this.ctx.setItemValueByEditor(t,e,s,!0),this.inputEl.value=""}}startEdit(t=!1){this.cancel=!1;const{ENABLE_EDIT_CLICK_SELECTOR:e}=this.ctx.config;if(!e)return;const i=this.ctx.focusCell;if(!i||["index","index-selection","selection"].includes(i.type)||this.enable||!(i.isVerticalVisible()&&i.isHorizontalVisible()))return;const{rowKey:o,key:r,editorType:a}=i;if(a==="none")return;const l=this.ctx.database.getReadonly(o,r);i&&!l&&(this.enable=!0,this.ctx.editing=!0,this.cellTarget=i,this.startEditByInput(this.cellTarget,t),this.ctx.emit("startEdit",this.cellTarget))}editCell(t,e){const i=this.ctx.body.renderRows.find(h=>h.rowIndex===t);if(!i)return;const s=i.cells.find(h=>h.colIndex===e);if(!s)return;this.ctx.emit("setSelectorCell",s);const o=this.ctx.focusCell;if(!o||["index","index-selection","selection"].includes(o.type)||this.enable)return;const{rowKey:r,key:a}=o,l=this.ctx.database.getReadonly(r,a);o&&!l&&(this.enable=!0,this.ctx.editing=!0,this.cellTarget=o,this.startEditByInput(this.cellTarget),this.ctx.emit("startEdit",this.cellTarget))}doneEdit(){this.enable&&(this.doneEditByInput(),this.ctx.emit("doneEdit",this.cellTarget),this.enable=!1,this.ctx.editing=!1,this.ctx.containerElement.focus({preventScroll:!0}),this.editorEl.style.display="none",this.ctx.emit("draw"))}clearEditor(){this.doneEdit(),this.cellTarget=null,this.selectorArrStr="",this.ctx.clearSelector(),this.ctx.focusCell=void 0,this.ctx.emit("draw")}destroy(){var t;(t=this.editorEl)==null||t.remove()}}let Ci=class{constructor(t){n(this,"ctx");n(this,"emptyEl");this.ctx=t;const{EMPTY_TEXT:e,EMPTY_CUSTOM_STYLE:i}=this.ctx.config;this.ctx.emptyElement?this.emptyEl=this.ctx.emptyElement:(this.emptyEl=document.createElement("div"),this.emptyEl.innerText=e),this.emptyEl.className="e-virt-table-empty",this.emptyEl.style.display="none",this.ctx.containerElement.appendChild(this.emptyEl),this.ctx.on("emptyChange",({type:s,headerHeight:o,bodyHeight:r,footerHeight:a})=>{const l=o+(r+a)/2,h={display:s==="empty"?"block":"none",position:"absolute",fontSize:"14px",color:"#666",left:"50%",top:`${l}px`,transform:"translate(-50%, -50%)",...i};Object.assign(this.emptyEl.style,h)})}destroy(){this.emptyEl.remove()}};class bi{constructor(t){n(this,"ctx");n(this,"observer");this.ctx=t,this.observer=new MutationObserver(j(()=>{const e=this.ctx.overlayerElement.querySelectorAll('[data-auto-height="true"]'),i=new Map;e.forEach(r=>{const a=Number(r.getAttribute("data-row-index")),l=Number(r.getAttribute("data-col-index"));if(isNaN(a)||isNaN(l)||!(r instanceof HTMLElement)||r.offsetWidth===0)return;const h=`${a}_${l}`;i.set(h,Math.round(r.offsetHeight))});const s=this.ctx.database.getOverlayerAutoHeightMap();if(!this.arerMapsEqual(s,i)){if(this.ctx.database.setOverlayerAutoHeightMap(i),s.size===0&&i.size===0)return;this.ctx.emit("draw")}},16.67)),this.observer.observe(this.ctx.overlayerElement,{childList:!0,subtree:!0,attributes:!0})}arerMapsEqual(t,e){if(t.size!==e.size)return!1;for(let[i,s]of t)if(!e.has(i)||e.get(i)!==s)return!1;return!0}draw(){const t=this.getContainer();this.ctx.emit("overlayerChange",t)}destroy(){this.observer&&this.observer.disconnect(),this.ctx.emit("overlayerChange",{style:{},views:[]})}getContainer(){const t=this.getHeader(),e=this.getBody(),i=this.getFooter();let s=[];const{FOOTER_FIXED:o,FOOTER_POSITION:r}=this.ctx.config;return o?r==="top"?s=[t,i,e]:s=[t,e,i]:s=[t,e],{views:s}}getHeader(){const{fixedLeftWidth:t,fixedRightWidth:e,config:{SCROLLER_TRACK_SIZE:i,CSS_PREFIX:s}}=this.ctx,{visibleWidth:o,visibleHeight:r,renderCellHeaders:a}=this.ctx.header;let l=[],h=[],d=[];a.forEach(g=>{g.render&&(g.fixed==="left"?h.push(g):g.fixed==="right"?d.push(g):l.push(g))});const f=e-i,u={key:"left",style:{position:"absolute",top:"0px",left:"0px",overflow:"hidden",width:`${t}px`,height:`${r}px`},cells:h},x={key:"center",style:{position:"absolute",top:"0px",left:`${t}px`,overflow:"hidden",width:`${o-t-f+1}px`,height:`${r}px`},cells:l},w={key:"right",style:{position:"absolute",top:"0px",right:"0px",overflow:"hidden",width:`${f+1}px`,height:`${r}px`},cells:d};return{type:"header",class:`${s}-overlayer-header`,style:{position:"relative",overflow:"hidden",width:`${o}px`,height:`${r}px`},views:[u,x,w]}}getBody(){const t=[],e=[],i=[];let s=this.ctx.body.renderRows;this.ctx.config.FOOTER_FIXED||(s=s.concat(this.ctx.footer.renderRows)),s.forEach(g=>{g.cells.forEach(m=>{m.cellType==="footer"&&(m.render=m.renderFooter),m.render&&(m.fixed==="left"?e.push(m):m.fixed==="right"?i.push(m):t.push(m))})});const{fixedLeftWidth:o,fixedRightWidth:r,config:{SCROLLER_TRACK_SIZE:a,CSS_PREFIX:l}}=this.ctx,{visibleWidth:h,visibleHeight:d}=this.ctx.body,f=r-a,u={key:"left",style:{position:"absolute",top:`${.5}px`,left:`${.5}px`,overflow:"hidden",width:`${o}px`,height:`${d}px`},cells:e},x={key:"center",style:{position:"absolute",top:`${.5}px`,left:`${o-.5}px`,overflow:"hidden",width:`${h-o-f}px`,height:`${d}px`},cells:t},w={key:"right",style:{position:"absolute",top:"0px",right:"0px",overflow:"hidden",width:`${f}px`,height:`${d}px`},cells:i};return{type:"body",class:`${l}-overlayer-body`,style:{position:"relative",overflow:"hidden",width:`${h}px`,height:`${d}px`},views:[u,x,w]}}getFooter(){const t=[],e=[],i=[];this.ctx.footer.renderRows.forEach(E=>{E.cells.forEach(g=>{g.cellType==="footer"&&g.renderFooter&&(g.render=g.renderFooter,g.fixed==="left"?e.push(g):g.fixed==="right"?i.push(g):t.push(g))})});const{fixedLeftWidth:s,fixedRightWidth:o,config:{SCROLLER_TRACK_SIZE:r,CSS_PREFIX:a}}=this.ctx,{visibleWidth:l,visibleHeight:h}=this.ctx.footer,d=o-r,f={key:"left",style:{position:"absolute",top:`${.5}px`,left:`${.5}px`,overflow:"hidden",width:`${s}px`,height:`${h}px`},cells:e},u={key:"center",style:{position:"absolute",top:`${.5}px`,left:`${s-.5}px`,overflow:"hidden",width:`${l-s-d}px`,height:`${h}px`},cells:t},x={key:"right",style:{position:"absolute",top:`${.5}px`,right:`${.5}px`,overflow:"hidden",width:`${d}px`,height:`${h}px`},cells:i};return{type:"footer",class:`${a}-overlayer-footer`,style:{position:"relative",overflow:"hidden",width:`${l}px`,height:`${h}px`},views:[f,u,x]}}}class Ri{constructor(t){n(this,"ctx");n(this,"contextMenuEl");n(this,"custom",!1);this.ctx=t,this.ctx.contextMenuElement?(this.custom=!0,this.contextMenuEl=this.ctx.contextMenuElement):(this.custom=!1,this.contextMenuEl=document.createElement("div")),this.createContextMenu(),this.init()}init(){this.ctx.on("cellContextMenuClick",(t,e)=>{if(!this.ctx.config.ENABLE_CONTEXT_MENU)return;e.preventDefault();const{xArr:i,yArr:s}=this.ctx.selector,[o,r]=i,[a,l]=s,{rowIndex:h,colIndex:d}=t;h>=a&&h<=l&&d>=o&&d<=r||this.ctx.emit("setSelectorCell",t,e);const u={getBoundingClientRect:()=>({width:0,height:0,top:e.clientY,left:e.clientX,right:e.clientX,bottom:e.clientY,x:e.clientX,y:e.clientY}),contextElement:document.body};ie(u,this.contextMenuEl,{placement:"right-start",middleware:[Qt(),te(),ee()]}).then(({x,y:w})=>{this.show(x,w)})}),this.ctx.on("click",this.hide.bind(this)),this.ctx.on("onScroll",this.hide.bind(this)),this.ctx.on("resize",this.hide.bind(this))}createContextMenu(){if(this.contextMenuEl.className="e-virt-table-context-menu",this.contextMenuEl.addEventListener("contextmenu",function(e){e.preventDefault()}),this.ctx.containerElement.appendChild(this.contextMenuEl),this.custom)return;const{CONTEXT_MENU:t}=this.ctx.config;this.createContextMenuItems(t,e=>{switch(e.value){case"copy":this.ctx.emit("contextMenuCopy");break;case"paste":this.ctx.emit("contextMenuPaste");break;case"cut":this.ctx.emit("contextMenuCut");break;case"clearSelected":this.ctx.emit("contextMenuClearSelected");break}this.hide()})}createContextMenuItems(t,e){this.contextMenuEl.replaceChildren(),t.forEach(i=>{const s=document.createElement("div");s.className="e-virt-table-context-menu-item",s.innerText=i.label,i.event?s.onclick=()=>{i.event&&i.event(),e(i)}:s.onclick=()=>e(i),this.contextMenuEl.appendChild(s)})}show(t,e){Object.assign(this.contextMenuEl.style,{left:`${t}px`,top:`${e}px`})}hide(){Object.assign(this.contextMenuEl.style,{left:"-99999px",top:"-99999px"})}updated(){this.createContextMenu()}destroy(){this.contextMenuEl.remove()}}class Ii{constructor(t){n(this,"ctx");n(this,"loadingEl");if(this.ctx=t,this.ctx.loadingElement)this.loadingEl=this.ctx.loadingElement;else{this.loadingEl=document.createElement("div");const e=document.createElement("div");e.className="e-virt-table-loading-spinner";const i=this.ctx.icons.getSvg("loading");if(i){const a=new DOMParser().parseFromString(i.svg,"image/svg+xml").documentElement;e.appendChild(a)}const s=document.createElement("p");s.className="e-virt-table-loading-text",s.innerText=this.ctx.config.LOADING_TEXT,e.appendChild(s),this.loadingEl.appendChild(e)}this.loadingEl.className="e-virt-table-loading",this.loadingEl.style.display="none",this.ctx.containerElement.appendChild(this.loadingEl)}show(){this.loadingEl.style.display="flex"}hide(){this.loadingEl.style.display="none"}destroy(){this.loadingEl.remove()}}class Si{constructor(t,e){n(this,"options");n(this,"scroller");n(this,"header");n(this,"body");n(this,"footer");n(this,"selector");n(this,"autofill");n(this,"tooltip");n(this,"editor");n(this,"empty");n(this,"overlayer");n(this,"contextMenu");n(this,"loading");n(this,"ctx");this.options=e;const{overlayerElement:i,editorElement:s,emptyElement:o,contextMenuElement:r}=this.options,a=this.createContainer(t,i,s,o,r);this.ctx=new Ie(a,this.options),this.header=new _e(this.ctx),this.footer=new Te(this.ctx),this.body=new ve(this.ctx),this.scroller=new Se(this.ctx),this.selector=new Oe(this.ctx),this.autofill=new Le(this.ctx),this.tooltip=new pi(this.ctx),this.empty=new Ci(this.ctx),this.editor=new yi(this.ctx),this.overlayer=new bi(this.ctx),this.contextMenu=new Ri(this.ctx),this.loading=new Ii(this.ctx),this.ctx.on("draw",j(()=>{this.draw()},()=>this.ctx.drawTime)),this.ctx.on("drawView",j(()=>{this.draw(!0)},()=>this.ctx.drawTime)),this.draw()}createContainer(t,e,i,s,o){t.className="e-virt-table-container";const r=document.createElement("div"),a=document.createElement("canvas"),l=e||document.createElement("div");r.className="e-virt-table-stage",t.tabIndex=0,a.className="e-virt-table-canvas",l.className="e-virt-table-overlayer";const h=i||document.createElement("div");h.className="e-virt-table-editor";const d=s,f=o;return r.appendChild(a),r.appendChild(l),t.appendChild(r),{containerElement:t,stageElement:r,canvasElement:a,overlayerElement:l,editorElement:h,emptyElement:d,contextMenuElement:f}}draw(t=!1){requestAnimationFrame(()=>{const e=performance.now();this.header.update(),this.footer.update(),this.body.update(),this.ctx.paint.clear(),this.body.draw(),this.footer.draw(),this.header.draw(),this.scroller.draw(),t||this.overlayer.draw(),requestAnimationFrame(()=>{this.body.updateAutoHeight()});const i=performance.now(),s=Math.round(i-e);this.ctx.drawTime=s*this.ctx.config.DRAW_TIME_MULTIPLIER})}loadConfig(t){this.ctx.config.init(t),this.ctx.database.init(!1),this.header.init(),this.contextMenu.updated(),this.ctx.emit("draw")}loadColumns(t){this.editor.doneEdit(),this.ctx.database.setColumns(t),this.header.init(),this.ctx.emit("draw")}loadData(t){this.editor.doneEdit(),this.ctx.database.setData(t),this.header.init(),this.tooltip.hide(),this.ctx.emit("draw")}loadFooterData(t){this.ctx.database.setFooterData(t),this.ctx.emit("draw")}setLoading(t){this.ctx.loading=t,t?this.loading.show():this.loading.hide()}on(t,e){this.ctx.on(t,e)}emit(t,...e){this.ctx.emit(t,...e)}off(t,e){this.ctx.off(t,e)}filterMethod(t){this.ctx.database.setFilterMethod(t),this.ctx.database.init(!1),this.header.init(),this.ctx.emit("draw")}editCell(t,e){this.editor.editCell(t,e)}setItemValue(t,e,i,s=!0,o=!0,r=!1){this.ctx.database.setItemValue(t,e,i,s,o,r)}batchSetItemValue(t,e=!0){this.ctx.database.batchSetItemValue(t,e)}setItemValueByEditor(t,e,i,s=!0,o=!0){this.ctx.setItemValueByEditor(t,e,i,s,o),this.editor.doneEdit()}clearEditableData(t=null){const e=[0,this.ctx.maxColIndex],i=[0,this.ctx.maxRowIndex];return this.selector.clearSelectedData(e,i,!1,t)}clearEditor(){this.editor.clearEditor()}doLayout(){this.ctx.emit("draw")}getChangedData(){return this.ctx.database.getChangedData()}getChangedRows(){return this.ctx.database.getChangedRows()}setCurrentRowByRowIndex(t){this.ctx.currentCell=this.ctx.database.getVirtualBodyCell(t,0),this.ctx.emit("draw")}setCurrentRow(t){const e=this.ctx.database.getColumnByColIndex(0);e&&(this.ctx.currentCell=this.ctx.database.getVirtualBodyCellByKey(t,e.key),this.ctx.emit("draw"))}getCurrentRow(){const t=this.ctx.currentCell;return t?{row:t.row,rowIndex:t.rowIndex,rowKey:t.rowKey}:void 0}clearValidate(){this.ctx.database.clearValidate(),this.ctx.emit("draw")}validateFields(t,e=!0){return new Promise(async(i,s)=>{let o=[];for(let r=0;r<t.length;r++){const{rowKey:a,key:l}=t[r],h=await this.ctx.database.getValidator(a,l);Array.isArray(h)&&h.length&&o.push(h)}if(o.length){if(s(o),e){const[r]=o;if(Array.isArray(r)&&r.length){const[a]=r,{rowKey:l,key:h}=a;this.scrollToRowkey(l),this.scrollToColkey(h)}}this.ctx.emit("draw")}else i([]),this.ctx.emit("draw")})}async validate(t=!0){return new Promise(async(e,i)=>{try{const s=await this.getValidations();e(s)}catch(s){if(t&&Array.isArray(s)&&s.length){const[o]=s;if(Array.isArray(o)&&o.length){const[r]=o,{rowKey:a,key:l}=r,h=this.ctx.database.getRowForRowKey(a);if(h){const{parentRowKeys:d=[]}=h;d&&d.length&&this.setExpandRowKeys(d,!0)}this.scrollToRowkey(a),this.scrollToColkey(l)}}i(s)}})}setValidations(t){if(t.forEach(e=>{const{rowIndex:i,key:s,message:o}=e;this.ctx.database.setValidationErrorByRowIndex(i,s,o)}),t&&Array.isArray(t)&&t.length){const[e]=t;if(e&&e.rowIndex>=0&&e.key){const{rowIndex:i,key:s}=e;this.scrollToRowIndex(i),this.scrollToColkey(s)}}}getValidations(){return new Promise(async(t,e)=>{const i=this.ctx.database.getAllRowsData(),s=this.ctx.header.leafCellHeaders;let o=[];for(let r=0;r<i.length;r++)for(let a=0;a<s.length;a++){const l=this.ctx.database.getRowKeyByItem(i[r]),d=s[a].key,f=await this.ctx.database.getValidator(l,d);Array.isArray(f)&&f.length&&o.push(f)}o.length?(e(o),this.ctx.emit("draw")):(t([]),this.ctx.emit("draw"))})}hasValidationError(){return this.ctx.database.hasValidationError()}scrollTo(t,e){this.scroller.setScroll(t,e)}scrollXTo(t){this.scroller.setScrollX(t)}scrollToColkey(t){this.scroller.scrollToColkey(t)}scrollToRowkey(t){this.scroller.scrollToRowKey(t)}scrollToColIndex(t){this.scroller.scrollToColIndex(t)}scrollToRowIndex(t){this.scroller.scrollToRowIndex(t)}scrollYTo(t){this.scroller.setScrollY(t)}setExpandRowKeys(t,e=!0){this.ctx.database.setExpandRowKeys(t,e)}getExpandRowKeys(){return this.ctx.database.getExpandRowKeys()}clearSelection(){this.ctx.database.clearSelection(),this.ctx.emit("draw")}toggleRowSelection(t){const e=this.ctx.database.getRowKeyByItem(t);this.ctx.database.toggleRowSelection(e),this.ctx.emit("draw")}setSelectionByRows(t,e=!0){t.forEach(i=>{const s=this.ctx.database.getRowKeyByItem(i);this.ctx.database.setRowSelection(s,e,!1)}),this.ctx.emit("selectionChange",this.getSelectionRows()),this.ctx.emit("draw")}setSelectionByRowKeys(t,e=!0){t.forEach(i=>{this.ctx.database.setRowSelection(i,e,!1)}),this.ctx.emit("selectionChange",this.getSelectionRows()),this.ctx.emit("draw")}toggleAllSelection(){this.ctx.database.toggleAllSelection(),this.ctx.emit("draw")}toggleRowExpand(t,e){this.ctx.database.expandItem(t,e),this.ctx.emit("draw")}toggleExpandAll(t){this.ctx.database.expandAll(t),this.ctx.emit("draw")}getSelectionRows(){return this.ctx.database.getSelectionRows()}getPositionForRowIndex(t){return this.ctx.database.getPositionForRowIndex(t)}getCellValue(t,e){return this.ctx.database.getItemValue(t,e)}getCellValueByIndex(t,e){return this.ctx.database.getItemValueForRowIndexAndColIndex(t,e)}clearSort(){this.ctx.database.clearSort()}contextMenuHide(){this.contextMenu.hide()}getUtils(){return{mergeColCell:fe,mergeRowCell:de,getSpanArrByRow:Xt,getSpanObjByColumn:Yt}}getColumnByKey(t){var e;return(e=this.ctx.database.getColumnByKey(t))==null?void 0:e.column}destroy(){this.overlayer.destroy(),this.empty.destroy(),this.editor.destroy(),this.tooltip.destroy(),this.selector.destroy(),this.autofill.destroy(),this.contextMenu.destroy(),this.loading.destroy(),this.ctx.destroy(),this.ctx.containerElement.remove()}}module.exports=Si;
|
|
4
|
+
`)}return o}function Xt(c,t,e=[]){let i=0;const s=[];return c.forEach((o,r)=>{if(r===0)s.push(1);else{const a=e.reduce((h,d)=>`${h}${o[d]??""}`,"")||o[t],l=e.reduce((h,d)=>`${h}${c[r-1][d]??""}`,"")||c[r-1][t];a===l?(s[i]+=1,s.push(0)):(s.push(1),i=r)}}),s}function Yt(c,t){let e="",i="";const s={};return t.forEach((o,r)=>{r===0?(e=o.key,i=o.key,s[o.key]=1):c[o.key]===c[e]?(s[o.key]=0,s[i]+=1):(s[o.key]=1,e=o.key,i=o.key)}),s}function de(c,t,e=[]){const{visibleRows:i,rowIndex:s,headIndex:o}=c,r=Xt(i,t,e);return r[s-o]===0?{rowspan:0,colspan:0,relationRowKeys:e,mergeRow:!0}:{rowspan:r[s-o],colspan:1,relationRowKeys:e,mergeRow:!0}}function fe(c,t=[]){const{column:e,row:i,visibleLeafColumns:s}=c,o=s.filter(r=>t.includes(r.key));if(t.includes(e.key)){const r=Yt(i,o);return r[e.key]===0?{rowspan:0,colspan:0,relationColKeys:t,mergeCol:!0}:{rowspan:1,colspan:r[e.key],relationColKeys:t,mergeCol:!0}}}function xe(c,t=document.documentElement){const e=c.startsWith("--")?c:`--${c}`;return getComputedStyle(t).getPropertyValue(e).trim()}function It(c){if(!c)return new Date(0);if(typeof c=="number")return new Date(c);const t=String(c).trim(),e=new Date(t);if(!isNaN(e.getTime()))return e;const i=[/^(\d{4})-(\d{1,2})-(\d{1,2})$/,/^(\d{4})\/(\d{1,2})\/(\d{1,2})$/,/^(\d{4})\.(\d{1,2})\.(\d{1,2})$/,/^(\d{1,2})-(\d{1,2})-(\d{4})$/,/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/,/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/,/^(\d{1,2})-(\d{1,2})-(\d{4})$/,/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/,/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/,/^(\d{4})(\d{2})(\d{2})$/,/^(\d{4})-(\d{1,2})-(\d{1,2})\s+(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?$/,/^(\d{4})\/(\d{1,2})\/(\d{1,2})\s+(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?$/];for(const s of i){const o=t.match(s);if(o){const r=o.slice(1).map(Number);if(s.source.includes("YYYY-MM-DD")||s.source.includes("YYYY/MM/DD")||s.source.includes("YYYY.MM.DD")){const[a,l,h,d=0,f=0,u=0]=r;return new Date(a,l-1,h,d,f,u)}else if(s.source.includes("DD-MM-YYYY")||s.source.includes("DD/MM/YYYY")||s.source.includes("DD.MM.YYYY")){const[a,l,h,d=0,f=0,u=0]=r;return new Date(h,l-1,a,d,f,u)}else if(s.source.includes("MM-DD-YYYY")||s.source.includes("MM/DD/YYYY")||s.source.includes("MM.DD.YYYY")){const[a,l,h,d=0,f=0,u=0]=r;return new Date(h,a-1,l,d,f,u)}else if(s.source.includes("YYYYMMDD")){const[a,l,h]=r;return new Date(a,l-1,h)}}}return new Date(NaN)}function ue(c,t){const e=It(c),i=It(t);return isNaN(e.getTime())&&isNaN(i.getTime())?0:isNaN(e.getTime())?-1:isNaN(i.getTime())?1:e.getTime()-i.getTime()}class Bt{constructor(t,e,i,s,o,r,a){n(this,"ctx");n(this,"x",0);n(this,"y",0);n(this,"width",0);n(this,"height",0);n(this,"fixed");n(this,"cellType");this.ctx=t,this.x=e,this.y=i,this.width=s,this.height=o,this.fixed=a,this.cellType=r}isHorizontalVisible(){if(this.fixed)return!0;const{stageWidth:t,fixedLeftWidth:e,scrollX:i,fixedRightWidth:s}=this.ctx,o=t;return!(this.x+this.width-e-i<=0||this.x-i>=o-s)}isVerticalVisible(){const{stageHeight:t,scrollY:e}=this.ctx,i=t;return!(this.y+this.height-e<=0||this.y-e>=i)}getDrawX(){if(this.fixed==="left")return this.x;if(this.fixed==="right"){const{stageWidth:t,config:{SCROLLER_TRACK_SIZE:e}}=this.ctx;return t-(this.ctx.header.width-this.x)-e}return this.x-this.ctx.scrollX}getDrawY(){return this.cellType==="header"?this.y:this.cellType==="footer"&&this.ctx.config.FOOTER_FIXED?this.y:this.y-this.ctx.scrollY}getLeftFixedX(){return this.x-this.ctx.scrollX}getRightFixedX(){}}class ut extends Bt{constructor(e,i,s,o,r,a,l,h,d,f="body"){super(e,o,r,a,l,f,h.fixed);n(this,"formatter");n(this,"formatterFooter");n(this,"hoverIconName","");n(this,"operation",!1);n(this,"align");n(this,"verticalAlign");n(this,"fixed");n(this,"type");n(this,"editorType");n(this,"editorProps");n(this,"cellType");n(this,"level");n(this,"colspan",1);n(this,"rowspan",1);n(this,"mergeRow",!1);n(this,"mergeCol",!1);n(this,"relationRowKeys",[]);n(this,"relationColKeys",[]);n(this,"key");n(this,"column");n(this,"rowIndex");n(this,"colIndex");n(this,"rowKey");n(this,"row");n(this,"value");n(this,"render");n(this,"renderFooter");n(this,"style",{});n(this,"domDataset",{});n(this,"rules",[]);n(this,"message","");n(this,"text","");n(this,"displayText","");n(this,"visibleWidth",0);n(this,"visibleHeight",0);n(this,"isHasChanged",!1);n(this,"drawX",0);n(this,"drawY",0);n(this,"drawCellBgColor","");n(this,"drawCellSkyBgColor","");n(this,"drawTextColor","");n(this,"drawTextX",0);n(this,"drawTextY",0);n(this,"drawTextWidth",0);n(this,"drawTextHeight",0);n(this,"drawTreeImageX",0);n(this,"drawTreeImageY",0);n(this,"drawTreeImageWidth",0);n(this,"drawTreeImageHeight",0);n(this,"drawTreeImageName","");n(this,"drawTreeImageSource");n(this,"drawSelectionImageX",0);n(this,"drawSelectionImageY",0);n(this,"drawSelectionImageWidth",0);n(this,"drawSelectionImageHeight",0);n(this,"drawSelectionImageName","");n(this,"drawSelectionImageSource");n(this,"drawHoverImageX",0);n(this,"drawHoverImageY",0);n(this,"drawHoverImageWidth",0);n(this,"drawHoverImageHeight",0);n(this,"drawHoverImageName","");n(this,"drawHoverImageSource");n(this,"autoRowHeight",!1);n(this,"calculatedHeight",0);n(this,"ellipsis",!1);n(this,"rowExpand",!1);n(this,"rowHasChildren",!1);n(this,"overflowTooltipShow",!0);n(this,"selectorCellValueType","value");n(this,"overflowTooltipMaxWidth",500);n(this,"overflowTooltipPlacement","top");n(this,"maxLineClamp","auto");this.visibleWidth=this.width,this.visibleHeight=this.height,this.colIndex=s,this.rowIndex=i,this.key=h.key,this.type=h.type||"",this.editorType=h.editorType||"text",this.selectorCellValueType=h.selectorCellValueType||this.ctx.config.SELECTOR_CELL_VALUE_TYPE||"value",this.editorProps=h.editorProps||{},this.cellType=f,this.align=h.align||this.ctx.config.COLUMNS_ALIGN,this.verticalAlign=h.verticalAlign||this.ctx.config.COLUMNS_VERTICAL_ALIGN,this.fixed=h.fixed,this.level=h.level||0,this.operation=h.operation||!1,this.column=h,this.rules=h.rules||[],this.row=d,this.rowKey=this.cellType==="body"?this.ctx.database.getRowKeyForRowIndex(i):`${this.cellType}_${this.rowIndex}`,this.value=this.getValue(),this.render=h.render,this.overflowTooltipShow=h.overflowTooltipShow!==!1,this.autoRowHeight=h.autoRowHeight!==void 0?h.autoRowHeight:this.ctx.config.AUTO_ROW_HEIGHT,this.overflowTooltipMaxWidth=h.overflowTooltipMaxWidth||500,this.overflowTooltipPlacement=h.overflowTooltipPlacement||"top",this.renderFooter=h.renderFooter,this.hoverIconName=h.hoverIconName,this.formatter=h.formatter,this.formatterFooter=h.formatterFooter,this.maxLineClamp=h.maxLineClamp||"auto",this.update()}setWidthHeight(e,i){this.width=e,this.height=i}getValidationMessage(){const e=this.ctx.database.getValidationError(this.rowKey,this.key);if(Array.isArray(e)&&e.length){const[i]=e;this.message=i.message||""}return this.message}update(){this.drawX=this.getDrawX(),this.drawY=this.getDrawY(),this.drawTextX=this.drawX,this.drawTextY=this.drawY,this.isHasChanged=this.ctx.database.isHasChangedData(this.rowKey,this.key),this.updateSpan(),this.drawTextWidth=this.visibleWidth,this.drawTextHeight=this.visibleHeight,this.updateStyle(),this.updateType(),this.updateHoverIcon(),this.updateSelection(),this.updateTree(),this.updateEditor(),this.updateRender(),this.getValidationMessage(),this.updateContainer(),this.text=this.getText(),this.displayText=this.getDisplayText()}updateSpan(){if(this.cellType==="footer")return;const{SPAN_METHOD:e}=this.ctx.config;if(typeof e=="function"){const i=e,{colspan:s=1,rowspan:o=1,relationRowKeys:r,relationColKeys:a,mergeRow:l=!1,mergeCol:h=!1}=i({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue(),headIndex:this.ctx.body.headIndex,headPosition:this.ctx.database.getPositionForRowIndex(this.ctx.body.headIndex),visibleRows:this.ctx.body.visibleRows,visibleLeafColumns:this.ctx.header.visibleLeafColumns,rows:this.ctx.body.data})||{};Array.isArray(r)&&r.length>0?this.relationRowKeys=r:this.relationRowKeys=[this.key],Array.isArray(a)&&a.length>0?this.relationColKeys=a:this.relationColKeys=[this.key],this.mergeCol=h,this.mergeRow=l,this.colspan=s,this.rowspan=o,this.visibleWidth=this.getWidthByColIndexColSpan(this.colIndex,this.colspan),this.visibleHeight=this.ctx.database.getHeightByRowIndexRowSpan(this.rowIndex,this.rowspan)}}updateSpanInfo(){if(this.mergeRow||this.mergeCol){const e=this.getSpanInfo();this.height=e.height,this.width=e.width,this.drawX=this.getDrawX(),this.drawY=this.getDrawY(),this.drawY-=e.offsetTop,this.drawX-=e.offsetLeft}}updateType(){const{BODY_CELL_TYPE_METHOD:e}=this.ctx.config;if(typeof e=="function"){const s=e({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});s!==void 0&&(this.type=s)}}updateEditor(){const{BODY_CELL_EDITOR_METHOD:e}=this.ctx.config;if(typeof e=="function"){const s=e({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});if(s!==void 0){const{type:o,props:r={}}=s;this.editorType=o,this.editorProps=r}}}updateRender(){const{BODY_CELL_RENDER_METHOD:e}=this.ctx.config;if(typeof e=="function"){const s=e({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});s!==void 0&&(this.render=s)}}validate(){this.ctx.database.getValidator(this.rowKey,this.key).then(()=>{this.ctx.database.setValidationError(this.rowKey,this.key,[]),this.message=""}).catch(e=>{if(Array.isArray(e)&&e.length){const[i]=e;this.message=i.message,this.ctx.database.setValidationError(this.rowKey,this.key,e)}}).finally(()=>{this.ctx.emit("draw")})}updateStyle(){this.autoRowHeight&&(this.domDataset={"data-auto-height":!0,"data-row-index":this.rowIndex,"data-col-index":this.colIndex}),this.style=this.getOverlayerViewsStyle()}updateTree(){const{CELL_PADDING:e=0}=this.ctx.config,{rowKey:i,cellType:s}=this;let o,r=0,a="";if(!(["tree","selection-tree","tree-selection"].includes(this.type)&&s==="body"))return;const l=this.ctx.database.getRowForRowKey(i),{expand:h=!1,hasChildren:d=!1,expandLoading:f=!1,level:u=0}=l||{};this.rowExpand=h,this.rowHasChildren=d;const{TREE_INDENT:x=16,CHECKBOX_SIZE:w,TREE_ICON_SIZE:E}=this.ctx.config;if(r=u*x,f){const R=this.ctx.icons.get("loading");a="loading",o=R}else if(d){const R=this.ctx.icons.get("expand"),_=this.ctx.icons.get("shrink");o=h?_:R,a=h?"shrink":"expand"}let g=E,m=E,y=this.drawX;(this.align==="center"||this.align==="right")&&(y=this.drawX+(this.visibleWidth-g-2*e)/2,this.align="left");let p=y+r+e,b=this.drawY+(this.visibleHeight-m)/2,C=r+this.drawX+g-.5;this.type==="selection-tree"?(p=r+this.drawSelectionImageX+this.drawSelectionImageWidth,C=p+g-e/2):this.type==="tree-selection"?C=p+w+g-e/2:C=p+g-e/2,this.drawTextX=C,this.drawTextWidth=this.drawX+this.visibleWidth-C,!(p+g+e>this.drawX+this.visibleWidth)&&(b+m+e>this.drawY+this.visibleHeight||(this.drawTreeImageX=p,this.drawTreeImageY=b,this.drawTreeImageWidth=g,this.drawTreeImageHeight=m,o?(this.drawTreeImageName=a,this.drawTreeImageSource=o):(this.drawTreeImageName="",this.drawTreeImageSource=void 0)))}drawTreeLine(){const{TREE_LINE:e,TREE_INDENT:i=16,TREE_ICON_SIZE:s=16,TREE_LINE_COLOR:o="#e1e6eb"}=this.ctx.config;if(!e||this.cellType!=="body"||!["tree","selection-tree","tree-selection"].includes(this.type)||this.rowspan===0||this.colspan===0)return;const r=this.ctx.database.getRowForRowKey(this.rowKey)||{},a=r.level??0,l=this.drawTreeImageX+this.drawTreeImageWidth/2,h=this.drawTreeImageY+this.drawTreeImageHeight/2;let d=this.drawTreeImageX-a*i;const f=Array.isArray(r.parentRowKeys)?r.parentRowKeys:[];if(a>0){for(let g=0;g<a-1;g+=1){const m=f[g+1];if(!!(m?this.ctx.database.getRowForRowKey(m)||{}:{}).isLastChild)continue;const b=Math.round(this.drawTreeImageX-(a-g)*i+s/2);this.ctx.paint.drawLine([b,this.drawY,b,this.drawY+this.visibleHeight],{borderColor:o,borderWidth:1,lineDash:[4,4],lineDashOffset:0})}const u=Math.round(this.drawTreeImageX-i+s/2),w=!!r.isLastChild?h:this.drawY+this.visibleHeight;this.ctx.paint.drawLine([u,this.drawY,u,w],{borderColor:o,borderWidth:1,lineDash:[4,4],lineDashOffset:0});const E=Math.round(d+(a-1)*i+s/2);this.ctx.paint.drawLine([E,h,l,h],{borderColor:o,borderWidth:1,lineDash:[4,4],lineDashOffset:0})}if(r.hasChildren&&r.expand){const u=this.drawTreeImageY+this.drawTreeImageHeight,x=this.drawY+this.visibleHeight;this.ctx.paint.drawLine([l,u,l,x],{borderColor:o,borderWidth:1,lineDash:[4,4],lineDashOffset:0})}}updateContainer(){const{BODY_BG_COLOR:e,EDIT_BG_COLOR:i,BODY_CELL_STYLE_METHOD:s,FOOTER_CELL_STYLE_METHOD:o,READONLY_TEXT_COLOR:r,BODY_TEXT_COLOR:a,FOOTER_TEXT_COLOR:l,FOOTER_BG_COLOR:h,HIGHLIGHT_SELECTED_ROW:d,HIGHLIGHT_SELECTED_ROW_COLOR:f,HIGHLIGHT_HOVER_ROW:u,HIGHLIGHT_HOVER_ROW_COLOR:x,STRIPE:w,STRIPE_COLOR:E}=this.ctx.config;if(this.cellType==="footer"){let _=h,T=l;if(typeof o=="function"){const S=o,{backgroundColor:I,color:v}=S({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()})||{};I&&(_=I),v&&(T=v)}this.drawCellSkyBgColor="transparent",this.drawCellBgColor=_,this.drawTextColor=T;return}let g="transparent";const m=this.ctx.hoverCell,y=this.ctx.currentCell;let p=this.rowIndex,b=this.rowIndex;if(this.rowspan!==1&&(u||d)){const _=this.getSpanInfo(),{yArr:T}=_;p=T[0],b=T[1]}u&&m&&(m.rowKey===this.rowKey&&(g=x),m.rowIndex>=p&&m.rowIndex<=b&&(g=x)),d&&y&&(y.rowKey===this.rowKey&&(g=f),y.rowIndex>=p&&y.rowIndex<=b&&(g=f)),this.drawCellSkyBgColor=g;let C=e,R=a;if(this.ctx.database.getReadonly(this.rowKey,this.key)||(C=i,R=r),w&&(this.rowIndex%2?C=E:C=e),typeof s=="function"){const _=s,{backgroundColor:T,color:S}=_({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,isHasChanged:this.isHasChanged,value:this.getValue()})||{};T&&(C=T),S&&(R=S)}this.drawCellBgColor=C,this.drawTextColor=R}updateSelection(){const{visibleWidth:e,visibleHeight:i,rowspan:s,colspan:o,cellType:r,type:a,rowIndex:l,rowKey:h}=this;if(s===0||o===0||r==="footer"||!["index-selection","selection","selection-tree","tree-selection"].includes(a))return;const d=this.ctx.database.getRowSelectable(h),{CHECKBOX_SIZE:f=0,CELL_PADDING:u}=this.ctx.config;let x=this.drawX+u;(this.align==="center"||this.align==="right")&&(x=this.drawX+(e-f)/2);let w=x,E=this.drawY+(i-f)/2;if(a!=="selection-tree"){if(a==="tree-selection"){const{TREE_INDENT:y=16,TREE_ICON_SIZE:p}=this.ctx.config,b=this.ctx.database.getRowForRowKey(h),{level:C=0}=b||{},R=C*y;w=x+p+R}}let g=this.ctx.icons.get("checkbox-uncheck"),m="checkbox-uncheck";if(a==="selection-tree"||a==="tree-selection"){const y=this.ctx.database.getTreeSelectionState(h);y.indeterminate&&d?(g=this.ctx.icons.get("checkbox-indeterminate"),m="checkbox-indeterminate"):y.checked&&d?(g=this.ctx.icons.get("checkbox-check"),m="checkbox-check"):!y.checked&&d?(g=this.ctx.icons.get("checkbox-uncheck"),m="checkbox-uncheck"):(g=this.ctx.icons.get("checkbox-disabled"),m="checkbox-disabled")}else{const y=this.ctx.database.getRowSelection(h);y&&d?(g=this.ctx.icons.get("checkbox-check"),m="checkbox-check"):y&&!d?(g=this.ctx.icons.get("checkbox-check-disabled"),m="checkbox-check-disabled"):!y&&d?(g=this.ctx.icons.get("checkbox-uncheck"),m="checkbox-uncheck"):(g=this.ctx.icons.get("checkbox-disabled"),m="checkbox-disabled")}w+f+u>this.drawX+this.visibleWidth||E+f+u>this.drawY+this.visibleHeight||(a==="index-selection"?(this.ctx.hoverCell&&this.ctx.hoverCell.rowIndex===l||["checkbox-disabled","checkbox-check"].includes(m))&&(this.drawSelectionImageX=w,this.drawSelectionImageY=E,this.drawSelectionImageWidth=f,this.drawSelectionImageHeight=f,this.drawSelectionImageName=m,this.drawSelectionImageSource=g):(this.drawSelectionImageX=w,this.drawSelectionImageY=E,this.drawSelectionImageWidth=f,this.drawSelectionImageHeight=f,this.drawSelectionImageName=m,this.drawSelectionImageSource=g))}updateHoverIcon(){if(this.ctx.database.getReadonly(this.rowKey,this.key))return;const{BODY_CELL_HOVER_ICON_METHOD:i,CELL_HOVER_ICON_SIZE:s,CELL_PADDING:o,ENABLE_MERGE_CELL_LINK:r}=this.ctx.config;if(typeof i=="function"){const h=i({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});h!==void 0&&(this.hoverIconName=h)}const{hoverCell:a}=this.ctx;if(this.hoverIconName&&!this.ctx.editing&&a){let l=0,h=0;if(a.rowKey===this.rowKey&&(l=this.drawX+this.width-s-o,h=this.drawY+(this.height-s)/2),this.rowspan!==1&&r){const f=this.getSpanInfo(),{yArr:u}=f,x=u[0],w=u[1];if(a.rowIndex>=x&&a.rowIndex<=w){const{width:E,height:g,offsetTop:m,offsetLeft:y}=f;l=this.drawX-y+E-s-o,h=this.drawY-m+(g-s)/2}}const d=this.ctx.icons.get(this.hoverIconName);this.drawHoverImageX=l,this.drawHoverImageY=h,this.drawHoverImageWidth=s,this.drawHoverImageHeight=s,this.drawHoverImageName=this.hoverIconName,this.drawHoverImageSource=d}}getAutoHeight(){if(this.cellType!=="body"||!this.autoRowHeight||this.rowspan===0)return 0;if(this.render){const a=this.ctx.database.getOverlayerAutoHeight(this.rowIndex,this.colIndex);return this.rowspan>1?a<this.visibleHeight?0:Math.round(a-(this.visibleHeight-this.height)):Math.round(a)}if(!(this.displayText&&typeof this.displayText=="string"))return 0;const{BODY_FONT:e,CELL_PADDING:i,CELL_LINE_HEIGHT:s}=this.ctx.config,o=`${this.displayText}_${this.drawTextWidth}`,r=this.ctx.paint.calculateTextHeight(this.displayText,this.drawTextWidth,{font:e,padding:i,align:this.align,verticalAlign:this.verticalAlign,color:this.drawTextColor,autoRowHeight:this.autoRowHeight,lineHeight:s,maxLineClamp:this.maxLineClamp,cacheTextKey:o});return this.rowspan>1?r<this.visibleHeight?0:Math.round(r-(this.visibleHeight-this.height)):Math.round(r)}getSpanInfo(){return this.ctx.database.getSpanInfo(this)}getDisplayText(){return this.cellType==="footer"?this.renderFooter||this.text===null||this.text===void 0?"":this.text:this.rowspan===0||this.colspan===0||this.render||this.type==="index-selection"&&(this.ctx.hoverCell&&this.ctx.hoverCell.rowIndex===this.rowIndex||["checkbox-disabled","checkbox-check"].includes(this.drawSelectionImageName))||this.text===null||this.text===void 0?"":`${this.text}`}getText(){if(this.cellType==="footer")return typeof this.formatterFooter=="function"?this.formatterFooter({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.row[this.key]}):this.row[this.key];if(typeof this.formatter=="function")return this.formatter({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});const{BODY_CELL_FORMATTER_METHOD:e}=this.ctx.config;return typeof e=="function"?e({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()}):["index-selection","index"].includes(this.type)?`${this.rowIndex+1}`:(this.value=this.ctx.database.getItemValue(this.rowKey,this.key),this.value)}getValue(){return this.ctx.database.getItemValue(this.rowKey,this.key)}setValue(e){this.ctx.setItemValueByEditor(this.rowKey,this.key,e)}getOverlayerViewsStyle(){let e=`${this.drawX-this.ctx.fixedLeftWidth}px`,i=`${this.drawY-this.ctx.body.y}px`;return this.fixed==="left"?e=`${this.drawX}px`:this.fixed==="right"&&(e=`${this.drawX-(this.ctx.stageWidth-this.ctx.fixedRightWidth)}px`),this.cellType==="footer"&&this.ctx.config.FOOTER_FIXED&&(i=`${this.drawY-this.ctx.footer.y}px`),this.autoRowHeight&&this.ctx.database.getOverlayerAutoHeight(this.rowIndex,this.colIndex)===0&&(e="-99999px",i="-99999px"),{position:"absolute",overflow:"hidden",left:e,top:i,width:`${this.visibleWidth}px`,height:this.autoRowHeight?"auto":`${this.visibleHeight}px`,pointerEvents:"initial",userSelect:"none"}}drawContainer(){const{paint:e,config:{BORDER_COLOR:i,BORDER:s}}=this.ctx,{drawX:o,drawY:r}=this;e.drawRect(o,r,this.visibleWidth,this.visibleHeight,{borderColor:s?i:"transparent",fillColor:this.drawCellBgColor}),e.drawRect(o,r,this.width,this.height,{borderColor:"transparent",fillColor:this.drawCellSkyBgColor}),s||this.ctx.paint.drawLine([o,r+this.visibleHeight,o+this.visibleWidth,r+this.visibleHeight],{borderColor:i,fillColor:i,borderWidth:1,lineCap:"round",lineJoin:"round"})}drawAutofillPiont(){if(this.cellType==="footer")return;const{SELECT_BORDER_COLOR:e,ENABLE_AUTOFILL:i,ENABLE_SELECTOR:s,AUTOFILL_POINT_BORDER_COLOR:o}=this.ctx.config;if(!s||!i||this.ctx.editing)return;const{xArr:r,yArr:a}=this.ctx.selector,l=r[1],h=a[1],{colIndex:d,rowIndex:f,drawX:u,drawY:x}=this;if(d===l&&f===h){const E=d===this.ctx.maxColIndex||f===this.ctx.maxRowIndex||d===this.ctx.lastCenterColIndex?6:4;this.ctx.paint.drawRect(u+this.width-E,x+this.height-E,6,6,{borderColor:o,fillColor:e})}}draw(){this.drawTreeLine(),this.drawText(),this.drawImage(),this.drawSelector(),this.drawAutofillPiont(),this.drawErrorTip()}getWidthByColIndexColSpan(e,i){if(i===0)return 0;let s=0;for(let o=e;o<e+i;o++){const r=this.ctx.header.leafCellHeaders[o];s+=r.width}return s}drawText(){const{CELL_PADDING:e,BODY_FONT:i,PLACEHOLDER_COLOR:s,CELL_LINE_HEIGHT:o}=this.ctx.config,{placeholder:r}=this.column;let a=this.displayText,l=this.drawTextColor;if(!this.ctx.database.getReadonly(this.rowKey,this.key)&&r&&["",null,void 0].includes(this.text)&&this.cellType==="body"&&!(this.rowspan===0||this.colspan===0)&&(a=r,l=s),["",null,void 0].includes(a))return!1;typeof a!="string"&&(a=`${a}`);const d=`${a}_${this.drawTextWidth}`;return this.ellipsis=this.ctx.paint.drawText(a,this.drawTextX,this.drawTextY,this.drawTextWidth,this.drawTextHeight,{font:i,padding:e,align:this.align,verticalAlign:this.verticalAlign,color:l,autoRowHeight:this.autoRowHeight,lineHeight:o,maxLineClamp:this.maxLineClamp,cacheTextKey:d}),this.ellipsis}drawImage(){if(this.drawSelectionImageSource&&this.ctx.paint.drawImage(this.drawSelectionImageSource,this.drawSelectionImageX,this.drawSelectionImageY,this.drawSelectionImageWidth,this.drawSelectionImageHeight),this.drawTreeImageSource&&this.ctx.paint.drawImage(this.drawTreeImageSource,this.drawTreeImageX,this.drawTreeImageY,this.drawTreeImageWidth,this.drawTreeImageHeight),this.drawHoverImageSource){const{CELL_HOVER_ICON_BG_COLOR:e,CELL_HOVER_ICON_BORDER_COLOR:i}=this.ctx.config;this.ctx.paint.drawRect(this.drawHoverImageX-2,this.drawHoverImageY-2,this.drawHoverImageWidth+4,this.drawHoverImageHeight+4,{borderColor:i,radius:4,borderWidth:1,fillColor:e}),this.ctx.paint.drawImage(this.drawHoverImageSource,this.drawHoverImageX,this.drawHoverImageY,this.drawHoverImageWidth,this.drawHoverImageHeight)}}drawSelector(){if(this.cellType==="footer")return;const{ENABLE_SELECTOR:e}=this.ctx.config;if(!e)return;const{xArr:i,yArr:s,xArrCopy:o,yArrCopy:r}=this.ctx.selector;this.drawBorder({xArr:o,yArr:r,borderColor:this.ctx.config.SELECT_BORDER_COLOR||"rgb(82,146,247)",fillColor:"transparent",borderWidth:1,lineDash:[4,4]}),this.drawBorder({xArr:this.ctx.autofill.xArr,yArr:this.ctx.autofill.yArr,borderColor:this.ctx.config.SELECT_BORDER_COLOR||"rgb(82,146,247)",fillColor:"transparent",borderWidth:1,lineDash:[4,4]}),this.drawBorder({xArr:i,yArr:s,borderColor:this.ctx.config.SELECT_BORDER_COLOR||"rgb(82,146,247)",fillColor:"transparent",borderWidth:1});const[a,l]=i,[h,d]=s;!(a===l&&h===d)&&this.colIndex>=a&&this.colIndex<=l&&this.rowIndex>=h&&this.rowIndex<=d&&this.ctx.paint.drawRect(this.drawX,this.drawY,this.width,this.height,{borderColor:"transparent",fillColor:this.ctx.config.SELECT_AREA_COLOR||"rgba(82,146,247,0.1)"}),this.operation&&this.rowIndex>=h&&this.rowIndex<=d&&this.ctx.paint.drawRect(this.drawX,this.drawY,this.visibleWidth,this.visibleHeight,{borderColor:"transparent",fillColor:this.ctx.config.SELECT_ROW_COL_BG_COLOR||"transparent"})}drawErrorTip(){if(this.cellType==="footer"||!this.message||this.rowspan===0||this.colspan===0)return;const{ERROR_TIP_ICON_SIZE:e,ERROR_TIP_COLOR:i}=this.ctx.config,{width:s}=this,o=this.drawX,r=this.drawY,a=[o+s-e-.5,r,o+s-.5,r,o+s-.5,r+e];this.ctx.paint.drawLine(a,{borderColor:i,fillColor:i,borderWidth:1,lineCap:"round",lineJoin:"round"})}drawBorder(e){const{drawX:i,drawY:s,rowIndex:o,colIndex:r,height:a,width:l}=this;let h=i,d=s;const{xArr:f,yArr:u,lineDash:x=[],borderWidth:w=1,borderColor:E,fillColor:g}=e,m=f[0],y=f[1],p=u[0],b=u[1];if(r>=m&&r<=y&&o===p){const C=r===y?1:0,R=r===m?1:0;this.ctx.paint.drawLine([h+R,d+1,h+l-C,d+1],{borderColor:E,fillColor:g,borderWidth:w,lineCap:"round",lineJoin:"round",lineDash:x})}if(r===y&&o>=p&&o<=b){const C=o===p?1:0,R=o===b?1:0;this.ctx.paint.drawLine([h+l-1,d+C,h+l-1,d+a-R],{borderColor:E,fillColor:g,borderWidth:w,lineCap:"round",lineJoin:"round",lineDash:x})}if(r>=m&&r<=y&&o===b){const C=r===y?1:0,R=r===m?1:0;this.ctx.paint.drawLine([h+R,d+a-1,h+l-C,d+a-1],{borderColor:E,fillColor:g,borderWidth:w,lineCap:"round",lineJoin:"round",lineDash:x})}if(r===m&&o>=p&&o<=b){const C=o===b?1:0,R=o===p?1:0;this.ctx.paint.drawLine([h+1,d+R,h+1,d+a-C],{borderColor:E,fillColor:g,borderWidth:w,lineCap:"round",lineJoin:"round",lineDash:x})}}}class ge{constructor(t,e){n(this,"ctx");n(this,"data");n(this,"columns");n(this,"footerData",[]);n(this,"rowKeyMap",new Map);n(this,"colIndexKeyMap",new Map);n(this,"headerMap",new Map);n(this,"rowIndexRowKeyMap",new Map);n(this,"rowKeyRowIndexMap",new Map);n(this,"checkboxKeyMap",new Map);n(this,"selectionMap",new Map);n(this,"expandMap",new Map);n(this,"originalDataMap",new Map);n(this,"changedDataMap",new Map);n(this,"validationErrorMap",new Map);n(this,"itemRowKeyMap",new WeakMap);n(this,"bufferData",[]);n(this,"overlayerAutoHeightMap",new Map);n(this,"bufferCheckState",{buffer:!1,check:!1,indeterminate:!1,selectable:!0});n(this,"sumHeight",0);n(this,"filterMethod");n(this,"positions",[]);n(this,"sortState",new Map);this.ctx=t;const{data:i=[],columns:s=[],footerData:o=[]}=e;this.data=i,this.footerData=o,this.columns=s,this.init()}init(t=!0){this.ctx.paint.clearTextCache(),this.clearBufferData(),this.rowKeyMap.clear(),this.checkboxKeyMap.clear(),this.colIndexKeyMap.clear(),this.rowIndexRowKeyMap.clear(),this.rowKeyRowIndexMap.clear();const e=this.getColumns(),i=it(e);if(this.ctx.hasSelection=i.some(s=>s.type==="selection"),this.ctx.hasTree=i.some(s=>s.type==="tree"),t){this.originalDataMap.clear(),this.changedDataMap.clear(),this.validationErrorMap.clear();const{ROW_KEY:s}=this.ctx.config;s?(this.ctx.hasSelection||this.selectionMap.clear(),this.ctx.hasTree||this.expandMap.clear()):(this.selectionMap.clear(),this.expandMap.clear())}this.itemRowKeyMap=new WeakMap,this.initData(this.data),this.getData(),this.bufferCheckState.buffer=!1}clearBufferData(){this.bufferData=[]}initData(t,e=0,i=[]){const s=t.length;t.forEach((o,r)=>{var y;const{ROW_KEY:a="",DEFAULT_EXPAND_ALL:l,CELL_HEIGHT:h,SELECTABLE_METHOD:d,CHECKBOX_KEY:f}=this.ctx.config,u=o[a],x=u!=null?`${u}`:Dt();this.itemRowKeyMap.set(o,x);const w=o._height||h,E=o._readonly;let g=!0;if(typeof d=="function"&&(g=d),f){const p=o[f];if(this.checkboxKeyMap.has(p)){const b=this.checkboxKeyMap.get(p)||[];b.push(x),this.checkboxKeyMap.set(p,b)}else this.checkboxKeyMap.set(p,[x])}this.selectionMap.set(x,{key:f?o[f]:x,row:o,check:((y=this.selectionMap.get(x))==null?void 0:y.check)||!1});const m=l||this.expandMap.get(x)||o._expand||!1;this.expandMap.set(x,m),this.rowKeyMap.set(x,{readonly:E,index:r,rowIndex:r,level:e,height:w,calculatedHeight:-1,check:!1,selectable:g,expand:m,expandLazy:!1,hasChildren:o._hasChildren||(Array.isArray(o.children)?o.children.length>0:!1),expandLoading:!1,item:o,parentRowKeys:i,parentRowKey:i[i.length-1]||"",isLastChild:r===s-1}),Array.isArray(o.children)&&o.children.length&&this.initData(o.children,e+1,[...i,x])})}setRowHeight(t,e){const i=this.rowIndexRowKeyMap.get(t);if(i===void 0)return;const s=this.rowKeyMap.get(i);s.height=e,s.item._height=e,this.clearBufferData()}setBatchRowHeight(t){t.forEach(({rowIndex:e,height:i})=>{const s=this.rowIndexRowKeyMap.get(e);if(s){const o=this.rowKeyMap.get(s);o.height=i,o.item._height=i}}),this.clearBufferData()}setBatchCalculatedRowHeight(t){t.every(({height:i,rowIndex:s})=>this.getPositionForRowIndex(s).calculatedHeight===i)||(t.forEach(({rowIndex:i,height:s})=>{const o=this.rowIndexRowKeyMap.get(i);if(o){const r=this.rowKeyMap.get(o);r.calculatedHeight=s}}),this.clearBufferData(),this.getData(),this.ctx.emit("draw"))}getAllRowsData(){let t=[];const e=i=>{i.forEach(s=>{t.push(s),Array.isArray(s.children)&&e(s.children)})};return e(this.data),t}filterColumns(t){return t.reduce((e,i)=>{if(!(typeof i.hide=="function"?i.hide():i.hide)){const o={...i};o.children&&Array.isArray(o.children)&&(o.children=this.filterColumns(o.children)),e.push(o)}return e},[])}getColumns(){return this.filterColumns(this.columns)}setColumns(t){this.columns=t,this.clearBufferData()}setData(t){this.data=t,this.init()}getData(){if(this.bufferData.length>0)return{data:this.bufferData,sumHeight:this.sumHeight,positions:this.positions};let t=[],e=0;this.sumHeight=0,this.positions=[];const i=o=>{o.forEach(r=>{t.push(r);const a=this.itemRowKeyMap.get(r),{expand:l,hasChildren:h,height:d,calculatedHeight:f}=this.rowKeyMap.get(a),u=this.sumHeight,x=Math.max(f,d);this.sumHeight+=x,this.rowIndexRowKeyMap.set(e,a),this.rowKeyRowIndexMap.set(a,e),this.positions.push({top:u,height:x,bottom:this.sumHeight,calculatedHeight:f}),e+=1,l&&h&&i(r.children)})};this.rowIndexRowKeyMap.clear(),this.rowKeyRowIndexMap.clear();let s=this.data;if(typeof this.filterMethod=="function"&&(s=this.filterMethod(s)),this.sortState.size){const o=Array.from(this.sortState.entries()).sort((r,a)=>r[1].timestamp-a[1].timestamp);s=this.sortDataRecursive(s,o)}return i(s),this.bufferData=t,{data:t,sumHeight:this.sumHeight,positions:this.positions}}setFooterData(t){this.footerData=t}getFooterData(){return this.footerData}setFilterMethod(t){this.filterMethod=t}clearFilterMethod(){this.filterMethod=void 0}getSortState(t){return this.sortState.get(t)||{direction:"none",timestamp:0}}setSortState(t,e){const i=Date.now();this.ctx.config.SORT_STRICTLY&&this.sortState.clear(),e==="none"?this.sortState.delete(t):this.sortState.set(t,{direction:e,timestamp:i}),this.ctx.emit("sortChange",this.sortState),this.clearBufferData(),this.ctx.emit("draw")}clearSort(){this.sortState.clear(),this.ctx.emit("sortChange",this.sortState),this.clearBufferData(),this.ctx.emit("draw")}sortDataRecursive(t,e){let i=[...t];for(const[s,{direction:o}]of e){if(o==="none")continue;const r=this.getColumnByKey(s);!r||!r.column.sortBy||(i=this.applySingleColumnSort(i,s,o,r.column.sortBy))}return i.map(s=>(s.children&&Array.isArray(s.children)&&(s.children=this.sortDataRecursive(s.children,e)),s))}applySingleColumnSort(t,e,i,s){return t.sort((o,r)=>{const a=o[e],l=r[e];let h=0;if(typeof s=="function")h=s(o,r);else if(s==="number"){const d=Number(a)||0,f=Number(l)||0;h=d-f}else if(s==="string"){const d=String(a||""),f=String(l||"");h=d.localeCompare(f)}else s==="date"&&(h=ue(a,l));return i==="asc"?h:-h})}expandItem(t,e=!1){const i=this.rowKeyMap.get(t);i.expand=e,this.expandMap.set(t,e),this.clearBufferData(),this.ctx.emit("draw")}setExpandRowKeys(t,e=!0){this.expandMap.clear(),t.forEach(i=>{const s=this.rowKeyMap.get(i);this.expandMap.set(i,e),s.expand=e}),this.clearBufferData(),this.ctx.emit("draw")}getExpandRowKeys(){let t=[];return this.rowKeyMap.forEach((e,i)=>{e.expand&&t.push(i)}),t}expandAll(t){this.expandMap.clear(),this.rowKeyMap.forEach(e=>{e.expand=t,this.expandMap.set(e.key,t)}),this.clearBufferData(),this.ctx.emit("draw")}expandLoading(t,e=!1){const i=this.rowKeyMap.get(t);i.expandLoading=e,this.clearBufferData(),this.ctx.emit("draw")}setExpandChildren(t,e){const i=this.rowKeyMap.get(t);i.expand=!0,this.expandMap.set(t,!0),i.expandLazy=!0,i.item.children=e,this.initData(i.item.children,i.level+1),this.clearBufferData()}getIsExpandLoading(t){return this.rowKeyMap.get(t).expandLoading}getIsExpandLazy(t){return this.rowKeyMap.get(t).expandLazy}getIsExpand(t){return this.rowKeyMap.get(t).expand}getRowForRowKey(t){return this.rowKeyMap.get(t)}getRowForRowIndex(t){const e=this.getRowKeyForRowIndex(t);return this.rowKeyMap.get(e)}getRowKeyForRowIndex(t){return this.rowIndexRowKeyMap.get(t)||""}getRowKeyByItem(t){return this.itemRowKeyMap.get(t)}getRowIndexForRowKey(t){return this.rowKeyRowIndexMap.get(t)}getItemValueForRowIndexAndColIndex(t,e){if(!(this.rowIndexRowKeyMap.has(t)&&this.colIndexKeyMap.get(e)))return null;const s=this.rowIndexRowKeyMap.get(t),o=this.colIndexKeyMap.get(e);return s===void 0||o===void 0?null:{rowKey:s,key:o,value:this.getItemValue(s,o)}}getItemValue(t,e){const i=this.rowKeyMap.get(t);return i&&i.item?i.item[e]===void 0?null:i.item[e]:null}async batchSetItemValue(t,e=!1,i=!0,s="none"){let o=[],r=i;const a=new Set;let l=[],h=t.map(x=>{const{rowKey:w,key:E}=x;let g=x.value,m=g;const y=this.getRowDataItemForRowKey(w),p=this.getItemValue(w,E),b=this.getVirtualBodyCellByKey(w,E);return(b==null?void 0:b.type)==="number"&&(["",void 0,null].includes(g)?m=null:/^-?\d+(\.\d+)?$/.test(`${g}`)?m=Number(g):(m=p,l.push({...x,value:m,oldValue:p,row:y}))),{...x,value:m,oldValue:p,row:y}});if(h=h.filter(x=>!l.some(w=>x.rowKey===w.rowKey&&x.key===w.key)),l.length){const x={code:"ERR_BATCH_SET_NUMBER_VALUE",message:"Assignment failed, not a numeric type",data:l};this.ctx.emit("error",x)}if(h=h.filter(x=>x.oldValue!==x.value),!h.length)return;const{BEFORE_VALUE_CHANGE_METHOD:d}=this.ctx.config;s==="none"&&typeof d=="function"&&(h=await d(h),r=!1),h.forEach(x=>{const{value:w,rowKey:E,key:g}=x,m=this.getItemValue(E,g);a.add(E),this.setItemValue(E,g,w,!1,!1,!1,r),o.push({rowKey:E,key:g,oldValue:m,newValue:w})});let f=[];a.forEach(x=>{f.push(this.ctx.database.getRowDataItemForRowKey(x))});const u=h.map(({rowKey:x,key:w})=>this.getValidator(x,w));Promise.all(u).then(()=>{this.validationErrorMap.size===0&&this.changedDataMap.size>0&&this.ctx.emit("validateChangedData",this.getChangedData())}),this.ctx.emit("change",h,f),e&&this.ctx.history.pushState({changeList:o,scrollX:this.ctx.scrollX,scrollY:this.ctx.scrollY,type:"multiple"}),this.ctx.emit("draw")}async setItemValue(t,e,i,s=!1,o=!1,r=!1,a=!0){if(!this.rowKeyMap.has(t))return{};const{item:l}=this.rowKeyMap.get(t);let h=l[e],d=i;if(a&&this.ctx.database.getReadonly(t,e))return{oldValue:h,newValue:h};l[e]!==null&&typeof l[e]=="object"&&(h=JSON.parse(JSON.stringify(l[e])));const f=`${t}_${e}`;this.originalDataMap.has(f)||this.originalDataMap.set(f,h);const u=this.originalDataMap.get(f),x=this.getRowDataItemForRowKey(t);if(r){const w=this.getVirtualBodyCellByKey(t,e);if((w==null?void 0:w.type)==="number")if(["",void 0,null].includes(i))d=null;else if(/^-?\d+(\.\d+)?$/.test(`${i}`))d=Number(i);else{d=h;const g={code:"ERR_SET_NUMBER_VALUE",message:"Assignment failed, not a numeric type",data:[{rowKey:t,key:e,value:d,oldValue:h,row:x}]};this.ctx.emit("error",g)}if(d===h)return{oldValue:h,newValue:h};let E=[{rowKey:t,key:e,value:d,oldValue:h,row:x}];this.batchSetItemValue(E,s,!1),this.ctx.emit("editChange",{rowKey:t,key:e,oldValue:h,value:d,originalValue:u,row:x})}else this.changedDataMap.set(f,d),l[e]=d;return this.ctx.hasEvent("iterationChange")&&this.ctx.emit("iterationChange",{rowKey:t,key:e,oldValue:h,value:d,originalValue:this.originalDataMap.get(f),row:x}),o&&this.ctx.emit("draw"),{oldValue:h,newValue:d}}getRowDataItemForRowKey(t){if(!this.rowKeyMap.has(t))return{};const{item:e}=this.rowKeyMap.get(t);return e}setRowSelectionByCheckboxKey(t,e){const{CHECKBOX_KEY:i}=this.ctx.config;if(i){if(!this.rowKeyMap.has(t))return!1;const{item:s}=this.rowKeyMap.get(t),o=s[i];this.checkboxKeyMap.has(o)&&(this.checkboxKeyMap.get(o)||[]).forEach(a=>{const l=this.selectionMap.get(a);l&&(l.check=e)})}}toggleRowSelection(t,e){const i=this.rowKeyMap.get(t),s=this.selectionMap.get(t);if(!s)return;e==="selection-tree"||e==="tree-selection"?this.toggleTreeSelection(t):(s.check=!s.check,this.setRowSelectionByCheckboxKey(t,s.check)),this.ctx.emit("toggleRowSelection",i);const o=this.getSelectionRows();this.ctx.emit("selectionChange",o),this.bufferCheckState.buffer=!1,this.ctx.emit("draw")}toggleTreeSelection(t){const e=this.getTreeSelectionState(t),i=this.ctx.config.TREE_SELECT_MODE;if(i==="auto")e.checked&&!e.indeterminate?(this.setRowSelection(t,!1,!1),this.clearTreeSelectionRecursive(t)):(this.setRowSelection(t,!0,!1),this.selectTreeSelectionRecursive(t));else if(i==="cautious")e.checked&&!e.indeterminate?(this.setRowSelection(t,!1,!1),this.clearTreeSelectionRecursive(t)):(this.setRowSelection(t,!0,!1),this.selectTreeSelectionRecursive(t));else if(i==="strictly"){const s=this.selectionMap.get(t);s&&(s.check=!s.check,this.setRowSelectionByCheckboxKey(t,s.check))}this.ctx.emit("selectionChange",this.getSelectionRows()),this.ctx.emit("draw")}selectTreeSelectionRecursive(t){this.getTreeChildren(t).forEach(i=>{this.setRowSelection(i,!0,!1),this.selectTreeSelectionRecursive(i)})}clearTreeSelectionRecursive(t){this.getTreeChildren(t).forEach(i=>{this.setRowSelection(i,!1,!1),this.clearTreeSelectionRecursive(i)})}updateParentTreeSelection(t){const e=this.getTreeParent(t);if(!e)return;const s=this.getTreeChildren(e).map(h=>this.selectionMap.get(h)),o=s.filter(h=>h==null?void 0:h.check).length,r=s.length;let a=!1;r>0&&(o===0?a=!1:o===r||this.ctx.config.TREE_SELECT_MODE==="auto"?a=!0:this.ctx.config.TREE_SELECT_MODE==="cautious"&&(a=!1));const l=this.selectionMap.get(e);l&&l.check!==a&&(l.check=a,this.setRowSelectionByCheckboxKey(e,a),this.updateParentTreeSelection(e))}setRowSelection(t,e,i=!0){const s=this.selectionMap.get(t);s&&(s.check=e,this.setRowSelectionByCheckboxKey(t,s.check),this.ctx.emit("setRowSelection",e,s.row),(this.ctx.config.TREE_SELECT_MODE==="auto"||this.ctx.config.TREE_SELECT_MODE==="cautious")&&this.updateParentTreeSelection(t),i&&(this.bufferCheckState.buffer=!1,this.ctx.emit("draw")))}getSelectionRows(){let t=[];return this.selectionMap.forEach(e=>{e.check&&t.push(e.row)}),t}getRowSelection(t){const e=this.selectionMap.get(t);return e?e.check:!1}getTreeSelectionState(t){if(!this.getRowForRowKey(t))return{checked:!1,indeterminate:!1};const i=this.selectionMap.get(t),s=(i==null?void 0:i.check)||!1;if(this.getTreeChildren(t).length===0)return{checked:s,indeterminate:!1};let r=!1,a=s;if(this.ctx.config.TREE_SELECT_MODE==="auto"){const h=g=>{const m=this.getTreeChildren(g);let y=[];for(const p of m)y.push(p),y.push(...h(p));return y},f=h(t).map(g=>this.selectionMap.get(g)),u=f.filter(g=>g==null?void 0:g.check).length,x=f.length,w=u>0;r=w&&!(u===x),a=s||w,s&&x>0&&u===0&&(a=!1,r=!1)}else if(this.ctx.config.TREE_SELECT_MODE==="cautious"){const h=g=>{const m=this.getTreeChildren(g);let y=[];for(const p of m)y.push(p),y.push(...h(p));return y},f=h(t).map(g=>this.selectionMap.get(g)),u=f.filter(g=>g==null?void 0:g.check).length,x=f.length,w=u>0,E=u===x;r=w&&!E,a=s||E,s&&x>0&&u===0&&(a=!1,r=!1)}else this.ctx.config.TREE_SELECT_MODE==="strictly"&&(r=!1,a=s);return{checked:a,indeterminate:r}}getTreeChildren(t){const e=this.getRowForRowKey(t);if(!e||!e.item||!e.item.children)return[];const i=[],s=o=>{for(const r of o){const a=this.getRowKeyByItem(r);a&&i.push(a),r.children&&r.children.length>0&&s(r.children)}};return s(e.item.children),i}getTreeParent(t){const e=(i,s)=>{for(const o of i){const r=this.getRowKeyByItem(o);if(o.children)for(const a of o.children){if(this.getRowKeyByItem(a)===s)return r;const h=e(o.children,s);if(h)return h}}return null};return e(this.data,t)}getRowSelectable(t){const{selectable:e,item:i,rowIndex:s}=this.rowKeyMap.get(t);return typeof e=="function"?e({row:i,rowIndex:s}):e}toggleAllSelection(){this.ctx.config.TREE_SELECT_MODE==="auto"||this.ctx.config.TREE_SELECT_MODE==="cautious"?this.rowKeyMap.forEach((i,s)=>{let o=i.selectable;if(typeof o=="function"&&(o=o({row:i.item,rowIndex:i.rowIndex})),o){const r=this.selectionMap.get(s);r&&(r.check=!0,this.setRowSelectionByCheckboxKey(s,!0))}}):this.rowKeyMap.forEach((i,s)=>{let o=i.selectable;typeof o=="function"&&(o=o({row:i.item,rowIndex:i.rowIndex})),o&&this.setRowSelection(s,!0,!1)});const e=this.getSelectionRows();this.ctx.emit("toggleAllSelection",e),this.ctx.emit("selectionChange",e),this.bufferCheckState.buffer=!1,this.ctx.emit("draw")}clearSelection(t=!1){const e=this.ctx.config.TREE_SELECT_MODE==="auto"||this.ctx.config.TREE_SELECT_MODE==="cautious";t?e?this.rowKeyMap.forEach((s,o)=>{const r=this.selectionMap.get(o);r&&(r.check=!1,this.setRowSelectionByCheckboxKey(o,!1))}):this.rowKeyMap.forEach((s,o)=>{this.setRowSelection(o,!1,!1)}):(this.selectionMap.clear(),this.rowKeyMap.forEach((s,o)=>{this.selectionMap.set(o,{check:!1,row:s.item,key:o})}));const i=this.getSelectionRows();this.ctx.emit("clearSelection"),this.ctx.emit("selectionChange",i),this.bufferCheckState.buffer=!1,this.ctx.emit("draw")}getCheckedState(){const{buffer:t,...e}=this.bufferCheckState;if(t)return e;const i=this.rowKeyMap.size;let s=0,o=0;const r=this.selectionMap.size,a=Array.from(this.selectionMap.values()).some(u=>u.check);this.rowKeyMap.forEach((u,x)=>{var E;(E=this.selectionMap.get(x))!=null&&E.check&&(s+=1);let w=u.selectable;typeof w=="function"&&(w=w({row:u.item,rowIndex:u.rowIndex})),w&&(o+=1)});const l=r>i&&s===0&&a,h=o&&o>s&&s>0||l,d=o!==0,f=!!o&&o===s;return this.bufferCheckState={buffer:!0,check:f,indeterminate:h,selectable:d},{check:f,indeterminate:h,selectable:d}}updateColIndexKeyMap(t=[]){this.colIndexKeyMap.clear(),t.forEach(e=>{this.colIndexKeyMap.set(e.colIndex,e.key)})}getColumnByColIndex(t){var i;const e=this.colIndexKeyMap.get(t);if(e&&this.headerMap.has(e))return(i=this.headerMap.get(e))==null?void 0:i.column}getColumnByKey(t){const e=this.headerMap.get(t);if(e)return e}getColIndexForKey(t){var e;if(t&&this.headerMap.has(t))return(e=this.headerMap.get(t))==null?void 0:e.colIndex}getColHeaderByIndex(t){const e=this.colIndexKeyMap.get(t);if(e&&this.headerMap.has(e))return this.headerMap.get(e)}getChangedData(){let t=[];return this.changedDataMap.forEach((e,i)=>{const s=this.originalDataMap.get(i),o=i.split("_")[0],r=i.split("_")[1];s!==e&&t.push({rowKey:o,colKey:r,originalValue:s,row:this.ctx.database.getRowDataItemForRowKey(o),value:e})}),t}getChangedRows(){const t=new Set;this.changedDataMap.forEach((i,s)=>{const o=this.originalDataMap.get(s),r=s.split("_")[0];o!==i&&t.add(r)});let e=[];return t.forEach(i=>{e.push(this.ctx.database.getRowDataItemForRowKey(i))}),e}isHasChangedData(t,e){const i=`${t}_${e}`;if(!this.changedDataMap.has(i))return!1;const s=this.originalDataMap.get(i),o=this.changedDataMap.get(i);return s!==o}getPositionForRowIndex(t){return t<this.positions.length?this.positions[t]:{height:0,top:0,bottom:0,calculatedHeight:0}}setHeader(t,e){return t?(this.headerMap.set(t,e),!0):!1}getReadonly(t,e){const{DISABLED:i}=this.ctx.config;if(i)return!0;const s=this.rowKeyMap.get(t),o=this.headerMap.get(e);if(!s||!o)return!0;const r=s.readonly,a=o.readonly,{BODY_CELL_READONLY_METHOD:l}=this.ctx.config;if(typeof l=="function"&&o){const d=l({row:s.item,rowIndex:s.rowIndex,colIndex:o.colIndex,column:o.column,value:this.getItemValue(t,e)});if(d!==void 0)return d}return a||r}clearValidate(){this.validationErrorMap.clear()}hasValidationError(){return this.validationErrorMap.size!==0}getValidator(t,e){return new Promise(i=>{const s=this.rowKeyMap.get(t),o=this.headerMap.get(e),{BODY_CELL_RULES_METHOD:r}=this.ctx.config;if(o===void 0)return i([]);const a=o.column;let l=a.rules;if(typeof r=="function"){const d=r({row:s.item,rowIndex:s.rowIndex,colIndex:o.colIndex,column:a,value:this.getItemValue(t,e)});d&&(l=d)}if(l){const h={row:s.item,rowIndex:s.rowIndex,colIndex:o.colIndex,column:a,key:e,rowKey:t,value:this.getItemValue(t,e),field:e,fieldValue:this.getItemValue(t,e)},f=new ne(l).validate(h);this.setValidationError(t,e,f),i(f)}else this.clearValidationError(t,e),i([])})}getHeightByRowIndexRowSpan(t,e){let i=0;for(let s=0;s<e;s++){const o=this.positions[t+s];o&&(i+=o.height)}return i}getSpanInfo(t){const{rowIndex:e,key:i,rowKey:s,row:o,value:r,colIndex:a,relationRowKeys:l,relationColKeys:h,rowspan:d,height:f,width:u,colspan:x,mergeRow:w,mergeCol:E}=t;if(d===1&&x===1)return{xArr:[a,a],yArr:[e,e],rowspan:d,colspan:x,height:f,width:u,offsetTop:0,offsetLeft:0,dataList:[{rowKey:s,key:i,row:o,value:r}]};let g=e,m=e,y=a,p=a,b=[],C=0,R=0,_=0,T=0;if(d!==1&&w){T=u;const S=l.reduce((I,v)=>{const O=this.getItemValue(s,v)??"";return`${I}${O}`},"");for(let I=e-1;I>=0;I--){const v=this.rowIndexRowKeyMap.get(I)||"",O=l.reduce((A,L)=>{const M=this.getItemValue(v,L)??"";return`${A}${M}`},"");if(S===O)g=I;else break}for(let I=e;I<=this.ctx.maxRowIndex;I++){const v=this.rowIndexRowKeyMap.get(I)||"",O=l.reduce((A,L)=>{const M=this.getItemValue(v,L)??"";return`${A}${M}`},"");if(S===O)m=I;else break}for(let I=g;I<e;I++){const{height:v}=this.positions[I];C+=v}for(let I=g;I<=m;I++){const{height:v}=this.positions[I];_+=v;const O=this.rowIndexRowKeyMap.get(I)||"",{item:A}=this.rowKeyMap.get(O),L=this.getItemValue(O,i);b.push({rowKey:O,key:i,value:L,row:A})}}if(x!==1&&E){_=f;for(let S=a-1;S>=0;S--){const I=this.getColumnByColIndex(S);if(!I)break;const v=this.getItemValue(s,i),O=this.getItemValue(s,I.key);if(v===O&&h.includes(I.key))y=S;else break}for(let S=a;S<=this.ctx.maxColIndex;S++){const I=this.getColumnByColIndex(S);if(!I)break;const v=this.getItemValue(s,i),O=this.getItemValue(s,I.key);if(v===O&&h.includes(I.key))p=S;else break}for(let S=y;S<a;S++){const I=this.getColumnByColIndex(S);if(!I)break;R+=I.width||100}for(let S=y;S<=p;S++){const I=this.getColumnByColIndex(S);if(!I)break;T+=I.width||100,b.push({rowKey:s,key:I.key,value:this.getItemValue(s,I.key),row:o})}}return{xArr:[y,p],yArr:[g,m],rowspan:d,colspan:x,height:_,width:T,offsetTop:C,offsetLeft:R,dataList:b}}setValidationErrorByRowIndex(t,e,i){const s=this.rowIndexRowKeyMap.get(t),o=`${s}_${e}`,r=this.getRowForRowIndex(t),a=this.getColumnByKey(e);if(!s||!a||!r)return;const l=this.getItemValue(s,e),h=[{key:e,rowKey:s,rowIndex:t,colIndex:a.colIndex,column:a.column,row:r,value:l,message:i,field:e,fieldValue:l}];this.validationErrorMap.set(o,h)}setValidationError(t,e,i){const s=`${t}_${e}`;this.validationErrorMap.set(s,i)}clearValidationError(t,e){const i=`${t}_${e}`;this.validationErrorMap.has(i)&&this.validationErrorMap.delete(i)}getValidationError(t,e){const i=`${t}_${e}`;return this.validationErrorMap.get(i)||[]}getVirtualBodyCell(t,e){const i=this.getColumnByColIndex(e),s=this.getRowForRowIndex(t);return!i||!s?void 0:new ut(this.ctx,t,e,0,0,0,0,i,s.item,"body")}getVirtualBodyCellByKey(t,e){const i=this.getRowIndexForRowKey(t),s=this.getColIndexForKey(e);if(!(i===void 0||s===void 0))return this.getVirtualBodyCell(i,s)}hasMergeCell(t,e){let i=!1;for(let s=e[0];s<=e[1];s++)for(let o=t[0];o<=t[1];o++){const r=this.getVirtualBodyCell(s,o);if(r&&(r.rowspan!==1||r.colspan!==1)){i=!0;break}}return i}calculateMaxTreeDepth(t,e=0){let i=e;return t.forEach(s=>{if(Array.isArray(s.children)&&s.children.length>0){const o=this.calculateMaxTreeDepth(s.children,e+1);i=Math.max(i,o)}}),i}setOverlayerAutoHeightMap(t){this.overlayerAutoHeightMap=t}getOverlayerAutoHeightMap(){return this.overlayerAutoHeightMap}getOverlayerAutoHeight(t,e){const i=`${t}_${e}`;return this.overlayerAutoHeightMap.get(i)||0}}class we{constructor(t){n(this,"ctx");n(this,"history",[]);n(this,"historyIndex",-1);this.ctx=t,this.init()}init(){this.ctx.on("keydown",t=>{if(!this.ctx.editing){if(t.ctrlKey&&!t.shiftKey&&t.code==="KeyZ"||t.metaKey&&!t.shiftKey&&t.code==="KeyZ"){t.preventDefault(),this.ctx.clearSelector(),this.ctx.clearAutofill(),this.backState();return}if(t.ctrlKey&&t.code==="KeyY"||t.ctrlKey&&t.shiftKey&&t.code==="KeyZ"||t.metaKey&&t.shiftKey&&t.code==="KeyZ"){t.preventDefault(),this.ctx.clearSelector(),this.ctx.clearAutofill(),this.forwardState();return}}})}pushState(t){const{HISTORY_NUM:e=0,ENABLE_HISTORY:i}=this.ctx.config;i&&(this.history.push(t),this.history.length>e&&this.history.splice(0,1),this.historyIndex=this.history.length-1)}backState(){if(this.historyIndex>=0){const{changeList:t,scrollX:e,scrollY:i}=this.history[this.historyIndex],s=t.map(o=>({rowKey:o.rowKey,key:o.key,value:o.oldValue,row:{}}));this.ctx.setScroll(e,i),this.ctx.database.batchSetItemValue(s,!1,!1,"back"),this.historyIndex-=1}}forwardState(){if(this.historyIndex<this.history.length-1){this.historyIndex+=1;const{changeList:t}=this.history[this.historyIndex],e=t.map(i=>({rowKey:i.rowKey,key:i.key,value:i.newValue,row:{}}));this.ctx.database.batchSetItemValue(e,!1,!1,"forward")}}clear(){this.history=[],this.historyIndex=-1}}class Ee{constructor(t){n(this,"eventTasks",new Map);n(this,"ctx");this.ctx=t,this.init()}init(){this.bind(window,"resize",this.handleResize.bind(this)),this.bind(window,"mouseup",this.handleMouseUp.bind(this)),this.bind(window,"mousemove",this.handleMousemove.bind(this)),this.bind(window,"blur",this.handleOutsideMousedown.bind(this)),this.bind(window,"mousedown",this.handleOutsideMousedown.bind(this)),this.bind(this.ctx.stageElement,"click",this.handleClick.bind(this)),this.bind(window,"keydown",this.handleKeydown.bind(this)),this.bind(this.ctx.stageElement,"wheel",this.handleWheel.bind(this),{passive:!1}),this.bind(this.ctx.stageElement,"touchstart",this.handleTouchstart.bind(this),{passive:!1}),this.bind(this.ctx.stageElement,"touchend",this.handleTouchend.bind(this)),this.bind(this.ctx.stageElement,"touchmove",this.handleTouchmove.bind(this),{passive:!1}),this.bind(this.ctx.stageElement,"contextmenu",this.handleContextMenu.bind(this)),this.bind(this.ctx.stageElement,"mousedown",this.handleMouseDown.bind(this)),this.bind(this.ctx.stageElement,"dblclick",this.handleDblclick.bind(this)),this.bind(this.ctx.stageElement,"mouseover",this.handleMouseover.bind(this)),this.bind(this.ctx.stageElement,"mouseout",this.handleMouseout.bind(this)),document.addEventListener("selectionchange",this.selectionchange.bind(this))}selectionchange(){this.ctx.domSelectionStr="";const t=window.getSelection();t&&t.toString()&&(this.ctx.domSelectionStr=t.toString())}clearDomSelection(){const t=window.getSelection();t&&!t.isCollapsed&&t.removeAllRanges()}destroy(){this.eventTasks.forEach((t,e)=>{this.unbind(window,e,t)}),document.removeEventListener("selectionchange",this.selectionchange.bind(this)),this.eventTasks.clear()}handleResize(t){this.ctx.emit("resetHeader",t),this.ctx.emit("resize",t)}handleMouseDown(t){this.clearDomSelection(),t.button===0&&(this.ctx.mousedown=!0),this.ctx.containerElement.focus({preventScroll:!0}),this.ctx.emit("mousedown",t)}handleMousemove(t){this.ctx.emit("mousemove",t)}handleMouseUp(t){t.button===0&&(this.ctx.mousedown=!1),this.ctx.emit("mouseup",t)}handleClick(t){this.ctx.emit("click",t)}handleKeydown(t){const{ENABLE_KEYBOARD:e}=this.ctx.config;e&&this.ctx.isTarget(t)&&this.ctx.emit("keydown",t)}handleWheel(t){this.ctx.emit("wheel",t)}handleTouchstart(t){this.ctx.emit("touchstart",t)}handleTouchend(t){this.ctx.emit("touchend",t)}handleTouchmove(t){this.ctx.emit("touchmove",t)}handleContextMenu(t){t.preventDefault(),this.ctx.emit("contextMenu",t)}handleMouseover(t){this.ctx.isMouseoverTargetContainer=!0,this.ctx.emit("mouseover",t)}handleMouseout(t){this.ctx.isMouseoverTargetContainer=!1,this.ctx.emit("mouseout",t)}handleDblclick(t){this.ctx.emit("dblclick",t)}handleOutsideMousedown(t){this.ctx.selector.enable&&(t.target instanceof Window||t.target instanceof Node&&!this.ctx.containerElement.contains(t.target))&&this.ctx.emit("outsideMousedown",t)}bind(t,e,i,s){t.addEventListener(e,i,s),this.eventTasks.set(e,i)}unbind(t,e,i){t.removeEventListener(e,i),this.eventTasks.delete(e)}}class me{constructor(){n(this,"events",new Map)}has(t){return this.events.has(t)}on(t,e){const i=this.events.get(t)||[];i.push(e),this.events.set(t,i)}once(t,e){const i=(...s)=>{e(...s),this.off(t,i)};return this.on(t,i),this}off(t,e){const i=this.events.get(t);if(i){const s=i.indexOf(e);s>=0&&(i.splice(s,1),i.length===0?this.events.delete(t):this.events.set(t,i))}}emit(t,...e){const i=this.events.get(t);i&&i.forEach(s=>{s(...e)})}destroy(){this.events.clear()}}class pe{constructor(t){n(this,"ctx");n(this,"textCacheMap",new Map);const e=t.getContext("2d");if(!e)throw new Error("canvas context not found");this.ctx=e}clearTextCache(){this.textCacheMap.clear()}scale(t){this.ctx.setTransform(1,0,0,1,0,0),this.ctx.scale(t,t)}save(){this.ctx.save()}restore(){this.ctx.restore()}translate(t,e){this.ctx.translate(t,e)}setCursor(t="default"){this.ctx.canvas.style.cursor=t}clear(t=0,e=0,i,s){this.ctx.clearRect(t,e,i||this.ctx.canvas.width,s||this.ctx.canvas.height)}drawShadow(t,e,i,s,o){const{fillColor:r,side:a,shadowWidth:l,colorStart:h,colorEnd:d}=o;this.ctx.save(),r&&(this.ctx.fillStyle=r,this.ctx.fillRect(t,e,i,s));let f;switch(a){case"left":f=this.ctx.createLinearGradient(t-l,e,t,e),f.addColorStop(0,h),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t-l,e,l,s);break;case"right":f=this.ctx.createLinearGradient(t+i,e,t+i+l,e),f.addColorStop(0,h),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t+i,e,l,s);break;case"top":f=this.ctx.createLinearGradient(t,e-l,t,e),f.addColorStop(0,h),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t,e-l,i,l);break;case"bottom":f=this.ctx.createLinearGradient(t,e+s,t,e+s+l),f.addColorStop(0,h),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t,e+s,i,l);break;default:console.error("Invalid side specified for shadow");break}this.ctx.restore()}drawLine(t,e){if(t.length<4||t.length%2!==0)throw new Error("A valid array of points is required to draw a line");this.ctx.save();const{borderColor:i="black",borderWidth:s=1}=e;this.ctx.beginPath(),this.ctx.moveTo(t[0]-.5,t[1]-.5);for(let o=2;o<t.length;o+=2)this.ctx.lineTo(t[o]-.5,t[o+1]-.5);this.ctx.strokeStyle=i,this.ctx.lineWidth=s,e.lineDash&&(this.ctx.lineDashOffset=e.lineDashOffset??0,this.ctx.setLineDash(e.lineDash)),e.fillColor&&(this.ctx.fillStyle=e.fillColor,this.ctx.fill()),e.borderColor&&(this.ctx.strokeStyle=e.borderColor),this.ctx.stroke(),this.ctx.closePath(),this.ctx.restore()}drawImage(t,e,i,s,o){this.ctx.save(),this.ctx.drawImage(t,e,i,s,o),this.ctx.restore()}drawRect(t,e,i,s,{borderWidth:o=1,borderColor:r,fillColor:a,radius:l=0}={}){if(this.ctx.save(),this.ctx.beginPath(),a!==void 0&&(this.ctx.fillStyle=a),r!==void 0&&(this.ctx.lineWidth=o,this.ctx.strokeStyle=r),l===0)this.ctx.rect(t-.5,e-.5,i,s);else{const[h,d,f,u]=typeof l=="number"?[l,l,l,l]:l;this.ctx.moveTo(t+h,e),this.ctx.arcTo(t+i,e,t+i,e+d,d),this.ctx.arcTo(t+i,e+s,t+i-f,e+s,f),this.ctx.arcTo(t,e+s,t,e+s-u,u),this.ctx.arcTo(t,e,t+h,e,h)}a!==void 0&&this.ctx.fill(),r!==void 0&&this.ctx.stroke(),this.ctx.restore()}drawText(t="",e,i,s,o,r={}){var I;this.ctx.save();const{font:a="12px Arial",align:l="center",color:h="#495060",padding:d=0,verticalAlign:f="middle",maxLineClamp:u=1,autoRowHeight:x=!1,offsetLeft:w=0,offsetRight:E=0}=r;if(this.ctx.font=a,this.ctx.fillStyle=h,this.ctx.textAlign=l,["",null,void 0].includes(t))return this.ctx.restore(),!1;const m=parseInt(((I=a.match(/\d+/))==null?void 0:I[0])||"12")*(r.lineHeight||1.2),y=s-d*2-w-E;let p=!1;const b=Math.round((o-2*d)/m);let C=this.wrapText(t,y,r.cacheTextKey),R=Math.min(C.length,Math.max(b,1));u==="auto"&&x?R=C.length:typeof u=="number"&&u<R&&u!==1?R=u:(u===1&&(C=[t],R=1),u==="auto"&&b===1&&(C=[t],R=1));let _=i+d;const T=Math.round(R*m);f==="middle"?_=i+(o-T)/2:f==="bottom"&&(_=i+o-T-d);let S=e+d+w;l==="center"?S=e+s/2:l==="right"&&(S=e+s-d-E);for(let v=0;v<C.length;v++){const O=C[v],A=_+v*m;if(this.ctx.textBaseline="top",v===R-1){const M=C.slice(v).join(""),{_text:D,ellipsis:H}=this.handleEllipsis(M,s,d,a);this.ctx.fillText(D,S,A),p=H;break}this.ctx.fillText(O,S,A)}if(r.textCallback&&C.length){const v=C.reduce((D,H)=>Math.max(D,this.ctx.measureText(H).width),0),O=Math.round(v);let A=S,L=S+O;l==="center"?(A=S-O/2,L=S+O/2):l==="right"&&(A=S-O,L=S);const M={x:S,y:_,width:O,height:T,left:A,right:L,top:_,bottom:_+T};r.textCallback(M)}return this.ctx.restore(),p}wrapText(t,e,i=""){if(!t)return[""];if(i&&this.textCacheMap.has(i))return this.textCacheMap.get(i)||[""];const s=[],o=t.split(`
|
|
5
|
+
`);for(const a of o){if(a===""){s.push("");continue}const l=a.split("");let h="";for(const d of l){const f=h+d;this.ctx.measureText(f).width<=e?h=f:h?(s.push(h),h=d):(s.push(d),h="")}h&&s.push(h)}const r=s.length>0?s:[""];return i&&this.textCacheMap.set(i,r),r}calculateTextHeight(t="",e,i={}){var E;const{font:s="12px Arial",padding:o=0,align:r="center",color:a="#495060",maxLineClamp:l=1,cacheTextKey:h=""}=i;this.ctx.save(),this.ctx.font=s,this.ctx.fillStyle=a,this.ctx.textAlign=r;const d=parseInt(((E=s.match(/\d+/))==null?void 0:E[0])||"12"),f=d*(i.lineHeight||1.2),u=e-o*2,x=this.wrapText(t,u,h);let w=1;return l==="auto"?w=x.length:x.length>l?w=l:w=x.length,this.ctx.restore(),Math.max(Math.floor(w*f+o*2),Math.floor(d+o*2))}handleEllipsis(t,e,i=0,s="12px Arial"){this.ctx.save();let o=!1,r=t;if(this.ctx.font=s,t==null||t==="")return this.ctx.restore(),{_text:"",ellipsis:o};const a=this.ctx.measureText("...").width;if(e<=a+i*2)return this.ctx.restore(),{_text:"",ellipsis:!0};const l=this.ctx.measureText(t).width,h=e-i*2;if(l&&l>=h){o=!0;let d=0;for(let f=0;f<t.length;f++)if(d+=this.ctx.measureText(t[f]).width,d>=h-a){r=t.slice(0,f)+"...",o=!0;break}}return this.ctx.restore(),{_text:r,ellipsis:o}}}class Rt{constructor(t){n(this,"_config",{});n(this,"CSS_PREFIX","e-virt-table");n(this,"DRAW_TIME_MULTIPLIER",2);n(this,"ICONS",[]);n(this,"ROW_KEY","");n(this,"DISABLED",!1);n(this,"HEADER_FONT","12px normal Arial");n(this,"BODY_FONT","12px normal Arial");n(this,"BORDER",!0);n(this,"STRIPE",!1);n(this,"STRIPE_COLOR","#fafafa");n(this,"BORDER_COLOR","#e1e6eb");n(this,"WIDTH",0);n(this,"HEIGHT",0);n(this,"PLACEHOLDER_COLOR","#CDD0DC");n(this,"EMPTY_BODY_HEIGHT",120);n(this,"EMPTY_CUSTOM_STYLE",{});n(this,"EMPTY_TEXT","暂无数据");n(this,"LOADING_TEXT","加载中...");n(this,"MAX_HEIGHT",1e3);n(this,"BORDER_RADIUS",8);n(this,"ENABLE_OFFSET_HEIGHT",!1);n(this,"OFFSET_HEIGHT",0);n(this,"HEADER_HEIGHT",36);n(this,"ENABLE_HEADER_STICKY",!1);n(this,"HEADER_BG_COLOR","#F8FAFF");n(this,"BODY_BG_COLOR","#FFF");n(this,"HEADER_TEXT_COLOR","#1D2129");n(this,"REQUIRED_COLOR","#F56C6C");n(this,"BODY_TEXT_COLOR","#4E5969");n(this,"FOOTER_TEXT_COLOR","#4E5969");n(this,"LOADING_ICON_SVG","");n(this,"LOADING_ICON_COLOR","#4E5969");n(this,"EXPAND_ICON_SVG","");n(this,"SHRINK_ICON_SVG","");n(this,"EXPAND_ICON_COLOR","#4E5969");n(this,"SHRINK_ICON_COLOR","#4E5969");n(this,"ERROR_TIP_ICON_COLOR","red");n(this,"ERROR_TIP_ICON_SIZE",6);n(this,"COLUMNS_ALIGN","left");n(this,"COLUMNS_VERTICAL_ALIGN","middle");n(this,"EXPAND_LAZY",!0);n(this,"DEFAULT_EXPAND_ALL",!1);n(this,"CELL_WIDTH",100);n(this,"CELL_HEIGHT",36);n(this,"CELL_PADDING",8);n(this,"CELL_HOVER_ICON_SIZE",14);n(this,"CELL_HOVER_ICON_BG_COLOR","#fff");n(this,"CELL_HOVER_ICON_BORDER_COLOR","#DDE0EA");n(this,"SCROLLER_TRACK_SIZE",14);n(this,"SCROLLER_SIZE",8);n(this,"SCROLLER_COLOR","#dee0e3");n(this,"SCROLLER_TRACK_COLOR","#fff");n(this,"SCROLLER_FOCUS_COLOR","#bbbec4");n(this,"SELECT_BORDER_COLOR","rgb(82,146,247)");n(this,"SELECT_AREA_COLOR","rgba(82,146,247,0.1)");n(this,"SELECT_ROW_COL_BG_COLOR","transparent");n(this,"AUTOFILL_POINT_BORDER_COLOR","#fff");n(this,"EDIT_BG_COLOR","#fcf6ed");n(this,"CHECKBOX_KEY","");n(this,"CHECKBOX_COLOR","rgb(82,146,247)");n(this,"CHECKBOX_SIZE",20);n(this,"CHECKBOX_DISABLED_SVG","");n(this,"CHECKBOX_DISABLED_COLOR","#F1F2F4");n(this,"CHECKBOX_CHECK_SVG","");n(this,"CHECKBOX_UNCHECK_SVG","");n(this,"CHECKBOX_UNCHECK_COLOR","#DDE0EA");n(this,"CHECKBOX_INDETERMINATE_SVG","");n(this,"CHECKBOX_CHECK_DISABLED_SVG","");n(this,"CHECKBOX_CHECK_DISABLED_COLOR","#DDE0EA");n(this,"ICON_EDIT_SVG","");n(this,"ICON_EDIT_COLOR","#4E5969");n(this,"ICON_SELECT_SVG","");n(this,"ICON_SELECT_COLOR","#4E5969");n(this,"SORT_STRICTLY",!0);n(this,"SORT_ASC_ICON_SVG","");n(this,"SORT_DESC_ICON_SVG","");n(this,"SORTABLE_ICON_SVG","");n(this,"SORT_ICON_COLOR","rgb(82,146,247)");n(this,"READONLY_COLOR","#fff");n(this,"READONLY_TEXT_COLOR","#4E5969");n(this,"ERROR_TIP_COLOR","#ED3F14");n(this,"FOOTER_BG_COLOR","#fafafa");n(this,"FOOTER_FIXED",!0);n(this,"FOOTER_POSITION","bottom");n(this,"CELL_FOOTER_HEIGHT",36);n(this,"ENABLE_SELECTOR",!0);n(this,"TREE_SELECT_MODE","auto");n(this,"TREE_INDENT",20);n(this,"TREE_ICON_SIZE",20);n(this,"TREE_LINE",!1);n(this,"TREE_LINE_COLOR","#e1e6eb");n(this,"ENABLE_EDIT_SINGLE_CLICK",!1);n(this,"ENABLE_EDIT_CLICK_SELECTOR",!0);n(this,"SELECTOR_AREA_MIN_X",0);n(this,"SELECTOR_AREA_MAX_X_OFFSET",0);n(this,"SELECTOR_AREA_MAX_X",0);n(this,"SELECTOR_AREA_MIN_Y",0);n(this,"SELECTOR_AREA_MAX_Y",0);n(this,"SELECTOR_AREA_MAX_Y_OFFSET",0);n(this,"SELECTOR_CELL_VALUE_TYPE","value");n(this,"ENABLE_AUTO_THEME",!0);n(this,"ENABLE_SELECTOR_SINGLE",!1);n(this,"ENABLE_SELECTOR_SPAN_COL",!0);n(this,"ENABLE_SELECTOR_SPAN_ROW",!0);n(this,"ENABLE_SELECTOR_ALL_ROWS",!0);n(this,"ENABLE_SELECTOR_ALL_COLS",!0);n(this,"ENABLE_MERGE_CELL_LINK",!1);n(this,"ENABLE_AUTOFILL",!1);n(this,"ENABLE_CONTEXT_MENU",!1);n(this,"ENABLE_COPY",!0);n(this,"ENABLE_PASTER",!0);n(this,"ENABLE_RESIZE_ROW",!0);n(this,"ENABLE_RESIZE_COLUMN",!0);n(this,"RESIZE_ROW_LINE_COLOR","#e1e6eb");n(this,"RESIZE_COLUMN_LINE_COLOR","#e1e6eb");n(this,"RESIZE_ROW_MIN_HEIGHT",36);n(this,"RESIZE_COLUMN_MIN_WIDTH",40);n(this,"ENABLE_KEYBOARD",!0);n(this,"ENABLE_HISTORY",!1);n(this,"ENABLE_VALIDATOR_IMMEDIATE",!0);n(this,"HISTORY_NUM",50);n(this,"HIGHLIGHT_HOVER_ROW",!1);n(this,"HIGHLIGHT_HOVER_ROW_COLOR","rgba(186,203,231,0.1)");n(this,"HIGHLIGHT_SELECTED_ROW",!1);n(this,"HIGHLIGHT_SELECTED_ROW_COLOR","rgba(82,146,247,0.1)");n(this,"TOOLTIP_BG_COLOR","#303133");n(this,"TOOLTIP_TEXT_COLOR","#fff");n(this,"TOOLTIP_ZINDEX",3e3);n(this,"TOOLTIP_CUSTOM_STYLE",{});n(this,"CONTEXT_MENU",[{label:"复制",value:"copy"},{label:"剪切",value:"cut"},{label:"粘贴",value:"paste"},{label:"清空选中内容",value:"clearSelected"}]);n(this,"CELL_LINE_HEIGHT",1.3);n(this,"AUTO_ROW_HEIGHT",!1);n(this,"HEADER_CELL_STYLE_METHOD");n(this,"BODY_CELL_STYLE_METHOD");n(this,"FOOTER_CELL_STYLE_METHOD");n(this,"BODY_CELL_READONLY_METHOD");n(this,"BODY_CELL_FORMATTER_METHOD");n(this,"BODY_CELL_RULES_METHOD");n(this,"BODY_CELL_TYPE_METHOD");n(this,"BODY_CELL_EDITOR_METHOD");n(this,"BODY_CELL_RENDER_METHOD");n(this,"BODY_CELL_HOVER_ICON_METHOD");n(this,"SPAN_METHOD");n(this,"SELECTABLE_METHOD");n(this,"EXPAND_LAZY_METHOD");n(this,"BEFORE_VALUE_CHANGE_METHOD");n(this,"BEFORE_PASTE_DATA_METHOD");n(this,"BEFORE_AUTOFILL_DATA_METHOD");n(this,"BEFORE_SET_SELECTOR_METHOD");n(this,"BEFORE_SET_AUTOFILL_METHOD");n(this,"BEFORE_COPY_METHOD");this._config=t,this.updateCssVar()}init(t){this._config=t,this.updateCssVar()}updateCssVar(){let t={};Object.keys(this).forEach(e=>{if(e.endsWith("_COLOR")||e.endsWith("_FONT")){const i=`--evt-${e.toLocaleLowerCase().replace(/_/g,"-")}`,s=xe(i);s&&(t[e]=s)}}),Object.assign(this,t,this._config)}}const St='<svg t="1722595535853" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4551" width="32" height="32"><path d="M640 128H384c-170.496 0-256 85.504-256 256v256c0 170.496 85.504 256 256 256h256c170.496 0 256-85.504 256-256V384c0-170.496-85.504-256-256-256z m67.584 302.592c-2.048 4.608-4.608 8.704-8.192 12.288L506.88 634.88c-3.584 3.584-7.68 6.144-12.288 8.192-4.608 2.048-9.728 3.072-14.848 3.072s-10.24-1.024-14.848-3.072c-4.608-2.048-8.704-4.608-12.288-8.192l-96.256-96.256c-3.584-3.584-6.144-7.68-8.192-12.288-2.048-4.608-3.072-9.728-3.072-14.848 0-2.56 0-5.12 1.024-7.68 0.512-2.56 1.024-5.12 2.048-7.168 1.024-2.56 2.048-4.608 3.584-6.656 1.536-2.048 3.072-4.096 4.608-5.632 1.536-2.048 3.584-3.584 5.632-4.608 2.048-1.536 4.096-2.56 6.656-3.584 2.56-1.024 4.608-1.536 7.168-2.048 2.56-0.512 5.12-0.512 7.68-0.512 5.12 0 10.24 1.024 14.848 3.072 4.608 2.048 8.704 4.608 12.288 8.192l69.12 68.608L645.12 389.12c3.584-3.584 7.68-6.144 12.288-8.192 4.608-2.048 9.728-3.072 14.848-3.072 2.56 0 5.12 0 7.68 0.512s5.12 1.024 7.168 2.048c2.56 1.024 4.608 2.048 6.656 3.584 2.048 1.536 4.096 3.072 5.632 4.608 1.536 1.536 3.584 3.584 4.608 5.632 1.536 2.048 2.56 4.096 3.584 6.656 1.024 2.56 1.536 4.608 2.048 7.168 0.512 2.56 1.024 5.12 1.024 7.68 0 5.12-1.024 10.24-3.072 14.848z" p-id="4552"></path></svg>',_t='<svg t="1724122044148" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4551" width="32" height="32"><path d="M707.648 401.28L489.28 560.704l22.656 30.976 22.656-30.976L316.16 401.216q-3.072-2.24-6.464-3.84-3.456-1.536-7.104-2.432-3.712-0.896-7.488-1.088-3.776-0.128-7.488 0.448-3.776 0.64-7.296 1.92-3.584 1.28-6.784 3.2-3.2 1.984-6.016 4.544-2.816 2.56-5.056 5.632-2.176 3.072-3.84 6.464-1.536 3.456-2.432 7.104-0.896 3.712-1.088 7.488-0.128 3.776 0.448 7.488 0.64 3.776 1.92 7.296 1.28 3.584 3.2 6.784 1.984 3.2 4.544 6.016 2.56 2.752 5.632 4.992l218.368 159.552q4.928 3.584 10.752 5.504 5.76 1.92 11.904 1.92 6.08 0 11.904-1.92 5.76-1.92 10.752-5.504l218.368-159.552q3.008-2.24 5.568-4.992 2.56-2.816 4.544-6.016 1.92-3.2 3.264-6.784 1.28-3.52 1.92-7.296 0.576-3.712 0.384-7.488-0.128-3.84-1.024-7.488-0.896-3.648-2.496-7.04-1.6-3.456-3.84-6.528-2.24-3.072-4.992-5.632-2.816-2.56-6.016-4.48-3.2-1.984-6.784-3.328-3.584-1.28-7.296-1.856-3.712-0.64-7.488-0.448-3.84 0.192-7.488 1.088-3.648 0.896-7.04 2.496-3.456 1.536-6.528 3.84z m61.056 30.976q0-3.84-0.768-7.488-0.704-3.712-2.176-7.232-1.472-3.456-3.52-6.656-2.112-3.136-4.8-5.76-2.688-2.688-5.76-4.8-3.2-2.112-6.72-3.584-3.456-1.408-7.168-2.176-3.712-0.704-7.488-0.704-3.84 0-7.488 0.704-3.712 0.768-7.232 2.176-3.456 1.472-6.656 3.584-3.136 2.112-5.76 4.8-2.688 2.624-4.8 5.76-2.112 3.2-3.584 6.656-1.408 3.52-2.176 7.232-0.704 3.712-0.704 7.488 0 3.776 0.704 7.488 0.768 3.712 2.176 7.168 1.472 3.52 3.584 6.656 2.112 3.2 4.8 5.824 2.624 2.688 5.76 4.8 3.2 2.112 6.656 3.52 3.52 1.472 7.232 2.176 3.712 0.768 7.488 0.768 3.776 0 7.488-0.768 3.712-0.704 7.168-2.176 3.52-1.408 6.656-3.52 3.2-2.112 5.824-4.8 2.688-2.688 4.8-5.76 2.048-3.2 3.52-6.72 1.472-3.456 2.176-7.168 0.768-3.712 0.768-7.488z m-436.736 0q0-3.84-0.768-7.488-0.704-3.712-2.176-7.232-1.408-3.456-3.52-6.656-2.112-3.136-4.8-5.76-2.688-2.688-5.76-4.8-3.2-2.112-6.656-3.584-3.52-1.408-7.232-2.176-3.712-0.704-7.488-0.704-3.84 0-7.488 0.704-3.712 0.768-7.232 2.176-3.456 1.472-6.592 3.584-3.2 2.112-5.824 4.8-2.688 2.624-4.8 5.76-2.112 3.2-3.52 6.656-1.472 3.52-2.24 7.232-0.704 3.712-0.704 7.488 0 3.776 0.704 7.488 0.768 3.712 2.24 7.168 1.408 3.52 3.52 6.656 2.112 3.2 4.8 5.824 2.624 2.688 5.76 4.8 3.2 2.112 6.656 3.52 3.52 1.472 7.232 2.176 3.712 0.768 7.488 0.768 3.776 0 7.488-0.768 3.712-0.704 7.232-2.176 3.456-1.408 6.592-3.52 3.2-2.112 5.824-4.8 2.688-2.688 4.8-5.76 2.112-3.2 3.52-6.72 1.472-3.456 2.176-7.168 0.768-3.712 0.768-7.488z" p-id="4552"></path></svg>',gt='<svg t="1755138507987" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5079" width="200" height="200"><path d="M512 938.688a42.688 42.688 0 0 1-35.072-18.432l-192-277.312A42.56 42.56 0 0 1 320 576h384a42.752 42.752 0 0 1 35.072 66.944l-192 277.312a42.688 42.688 0 0 1-35.072 18.432" fill="currentColor" p-id="2016"></path><path d="M704 448H320a42.752 42.752 0 0 1-35.072-66.944l192-277.312c16-23.04 54.208-23.04 70.144 0l192 277.312A42.56 42.56 0 0 1 704 448" fill="currentColor" p-id="2015"></path></svg>',ye=gt.replace('fill="currentColor" p-id="2016"','fill="#bec4c7" p-id="2016"'),Ce=gt.replace('fill="currentColor" p-id="2015"','fill="#bec4c7" p-id="2015"');class be{constructor(t){n(this,"ctx");n(this,"list",[{name:"loading",configName:"LOADING_ICON_SVG",configColorName:"LOADING_ICON_COLOR",svg:'<svg t="1724133395728" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2893" width="32" height="32"><path d="M512 226.8476541a19.82487759 19.82487759 0 0 1 14.66497778 5.70304692c3.80203107 3.82918865 5.70304692 8.71751457 5.70304693 14.66497779v122.20814825a19.82487759 19.82487759 0 0 1-5.70304693 14.66497778 19.82487759 19.82487759 0 0 1-14.66497778 5.70304691 19.82487759 19.82487759 0 0 1-14.66497778-5.70304691 19.82487759 19.82487759 0 0 1-5.70304693-14.66497778v-122.20814825a19.82487759 19.82487759 0 0 1 5.70304693-14.66497779 19.82487759 19.82487759 0 0 1 14.66497778-5.70304692z m0 407.36049415a19.82487759 19.82487759 0 0 1 14.66497778 5.70304691c3.80203107 3.82918865 5.70304692 8.71751457 5.70304693 14.66497778v122.20814827a19.82487759 19.82487759 0 0 1-5.70304693 14.66497776 19.82487759 19.82487759 0 0 1-14.66497778 5.70304693 19.82487759 19.82487759 0 0 1-14.66497778-5.70304693 19.82487759 19.82487759 0 0 1-5.70304693-14.66497776v-122.20814827a19.82487759 19.82487759 0 0 1 5.70304693-14.66497778 19.82487759 19.82487759 0 0 1 14.66497778-5.70304691zM797.1523459 512a19.82487759 19.82487759 0 0 1-5.70304692 14.66497778 19.82487759 19.82487759 0 0 1-14.66497779 5.70304693h-122.20814825a19.82487759 19.82487759 0 0 1-14.66497778-5.70304693 19.82487759 19.82487759 0 0 1-5.70304691-14.66497778 19.82487759 19.82487759 0 0 1 5.70304691-14.66497778 19.82487759 19.82487759 0 0 1 14.66497778-5.70304693h122.20814825a19.82487759 19.82487759 0 0 1 14.66497779 5.70304693c3.80203107 3.82918865 5.70304692 8.71751457 5.70304692 14.66497778z m-407.36049415 0a19.82487759 19.82487759 0 0 1-5.70304691 14.66497778 19.82487759 19.82487759 0 0 1-14.66497778 5.70304693h-122.20814827a19.82487759 19.82487759 0 0 1-14.66497776-5.70304693 19.82487759 19.82487759 0 0 1-5.70304693-14.66497778 19.82487759 19.82487759 0 0 1 5.70304693-14.66497778 19.82487759 19.82487759 0 0 1 14.66497776-5.70304693h122.20814827a19.82487759 19.82487759 0 0 1 14.66497778 5.70304693c3.80203107 3.82918865 5.70304692 8.71751457 5.70304691 14.66497778zM310.22076878 310.22076878a21.29137537 21.29137537 0 0 1 14.66497779-5.70304693c5.51294514 0 10.18401235 1.90101585 14.01320099 5.70304693l86.55052591 86.57768347a20.91117183 20.91117183 0 0 1 5.73020449 14.31193182 19.28172983 19.28172983 0 0 1-6.05609289 14.013201 19.11878565 19.11878565 0 0 1-14.013201 6.05609289 20.96548698 20.96548698 0 0 1-14.31193182-5.70304692L310.22076878 338.87178998a19.06447114 19.06447114 0 0 1-5.70304693-14.01320099c0-5.54010272 1.90101585-10.42842865 5.70304693-14.66497778z m288.32975775 288.32975775a19.79772001 19.79772001 0 0 1 14.3390894-6.35482371c5.29568642 0 10.04822572 2.11827457 14.31193182 6.38198066l86.57768347 86.55052651c3.80203107 3.80203107 5.70304692 8.47309828 5.70304691 14.01320102a19.55330372 19.55330372 0 0 1-6.05609225 14.31193182 19.66193339 19.66193339 0 0 1-14.31193245 6.05609288 19.01015661 19.01015661 0 0 1-14.01320099-5.70304692l-86.55052591-86.57768347a19.79772001 19.79772001 0 0 1-6.38198129-14.31193245c0-5.29568642 2.11827457-10.07538268 6.38198129-14.33908939zM713.77923122 310.22076878c3.80203107 4.26370672 5.70304692 9.15203265 5.70304693 14.66497779s-1.90101585 10.18401235-5.70304693 14.01320099l-86.57768347 86.55052591a20.91117183 20.91117183 0 0 1-14.31193182 5.73020449 19.28172983 19.28172983 0 0 1-14.013201-6.05609289 19.11878565 19.11878565 0 0 1-6.05609289-14.013201c0-5.29568642 1.90101585-10.07538268 5.70304692-14.31193182l86.57768348-86.57768347c3.80203107-3.80203107 8.50025585-5.70304692 14.01320099-5.70304693 5.54010272 0 10.40127108 1.90101585 14.66497779 5.70304693zM425.44947347 598.57768347a19.79772001 19.79772001 0 0 1 6.35482371 14.33908939c0 5.29568642-2.11827457 10.04822572-6.38198066 14.31193245L338.89894756 713.77923122a19.06447114 19.06447114 0 0 1-14.01320099 5.70304693 19.55330372 19.55330372 0 0 1-14.31193245-6.05609227 19.68909035 19.68909035 0 0 1-6.05609227-14.31193245 19.01015661 19.01015661 0 0 1 5.70304693-14.01320099l86.57768347-86.55052591a19.79772001 19.79772001 0 0 1 14.31193182-6.38198129c5.29568642 0 10.07538268 2.11827457 14.3390894 6.38198129z" fill="#000000" fill-opacity=".65" p-id="2894"></path></svg>',color:"#4E5969"},{name:"expand",configName:"EXPAND_ICON_SVG",configColorName:"EXPAND_ICON_COLOR",svg:'<svg t="1724122015492" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4237" width="32" height="32"><path d="M401.472 316.992l159.04 217.664L591.488 512l-30.976-22.656-159.04 217.728q-2.24 3.008-3.84 6.464-1.6 3.456-2.496 7.104-0.896 3.648-1.024 7.424-0.192 3.84 0.384 7.552 0.64 3.712 1.92 7.296 1.28 3.52 3.2 6.784 1.984 3.2 4.544 6.016 2.56 2.752 5.632 4.992 3.072 2.24 6.464 3.84 3.456 1.6 7.168 2.496 3.648 0.896 7.424 1.024 3.776 0.192 7.488-0.448 3.776-0.576 7.296-1.856 3.584-1.28 6.784-3.264 3.2-1.92 6.016-4.48 2.816-2.56 5.056-5.632l159.04-217.728q3.584-4.928 5.504-10.752 1.92-5.76 1.92-11.904 0-6.08-1.92-11.904-1.92-5.76-5.504-10.752L463.488 271.68q-2.24-3.072-5.056-5.632-2.752-2.56-6.016-4.48-3.2-1.984-6.784-3.328-3.52-1.28-7.296-1.856-3.712-0.576-7.488-0.448-3.84 0.192-7.424 1.088-3.712 0.896-7.168 2.496-3.392 1.6-6.4 3.84-3.136 2.176-5.696 4.992-2.56 2.752-4.48 6.016-1.984 3.2-3.264 6.784-1.28 3.52-1.92 7.296-0.576 3.712-0.384 7.488 0.128 3.84 1.024 7.488 0.896 3.648 2.496 7.04 1.6 3.456 3.84 6.528z m30.976-61.056q-3.776 0-7.488 0.704-3.712 0.768-7.168 2.24-3.52 1.408-6.656 3.52-3.2 2.112-5.824 4.8-2.688 2.624-4.8 5.76-2.112 3.2-3.52 6.656-1.472 3.52-2.176 7.232-0.768 3.712-0.768 7.488 0 3.776 0.768 7.488 0.704 3.712 2.176 7.232 1.408 3.456 3.52 6.592 2.112 3.2 4.8 5.824 2.688 2.688 5.76 4.8 3.2 2.112 6.72 3.52 3.456 1.472 7.168 2.176 3.712 0.768 7.488 0.768 3.84 0 7.488-0.768 3.712-0.704 7.232-2.176 3.456-1.408 6.592-3.52 3.2-2.112 5.824-4.8 2.688-2.688 4.8-5.76 2.112-3.2 3.52-6.656 1.472-3.52 2.24-7.232 0.704-3.712 0.704-7.488 0-3.84-0.704-7.488-0.768-3.712-2.24-7.232-1.408-3.456-3.52-6.592-2.112-3.2-4.8-5.824-2.624-2.688-5.76-4.8-3.2-2.112-6.656-3.52-3.52-1.472-7.232-2.24Q436.224 256 432.448 256z m0 435.392q-3.776 0-7.488 0.704-3.712 0.768-7.168 2.176-3.52 1.472-6.656 3.584-3.2 2.112-5.824 4.736-2.688 2.688-4.8 5.824-2.112 3.2-3.52 6.656-1.472 3.52-2.176 7.232-0.768 3.712-0.768 7.488 0 3.776 0.768 7.488 0.704 3.712 2.176 7.168 1.408 3.52 3.52 6.656 2.112 3.2 4.8 5.76 2.688 2.752 5.76 4.8 3.2 2.112 6.72 3.584 3.456 1.472 7.168 2.176 3.712 0.768 7.488 0.768 3.84 0 7.488-0.768 3.712-0.704 7.232-2.176 3.456-1.472 6.592-3.584 3.2-2.048 5.824-4.736 2.688-2.688 4.8-5.824 2.112-3.2 3.52-6.656 1.472-3.456 2.24-7.168 0.704-3.712 0.704-7.488 0-3.84-0.704-7.488-0.768-3.712-2.24-7.232-1.408-3.52-3.52-6.656-2.112-3.136-4.8-5.76-2.624-2.688-5.76-4.8-3.2-2.112-6.656-3.584-3.52-1.408-7.232-2.176-3.712-0.704-7.488-0.704z" p-id="4238"></path></svg>',color:"#4E5969"},{name:"shrink",configName:"SHRINK_ICON_SVG",configColorName:"SHRINK_ICON_COLOR",svg:_t,color:"#4E5969"},{name:"checkbox-uncheck",configName:"CHECKBOX_UNCHECK_SVG",configColorName:"CHECKBOX_UNCHECK_COLOR",svg:'<svg t="1722595639920" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4708" width="32" height="32"><path d="M128 640V384a256 256 0 0 1 256-256h256a256 256 0 0 1 256 256v256a256 256 0 0 1-256 256H384a256 256 0 0 1-256-256z m64 0q0 79.552 56.256 135.744Q304.448 832 384 832h256q79.552 0 135.744-56.256Q832 719.552 832 640V384q0-79.552-56.256-135.744Q719.552 192 640 192H384q-79.552 0-135.744 56.256Q192 304.448 192 384v256z" p-id="4709"></path></svg>',color:""},{name:"checkbox-check",configName:"CHECKBOX_CHECK_SVG",configColorName:"CHECKBOX_COLOR",svg:St,color:"rgb(82,146,247)"},{name:"checkbox-indeterminate",configName:"CHECKBOX_INDETERMINATE_SVG",configColorName:"CHECKBOX_COLOR",svg:'<svg t="1722595280953" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4394" width="32" height="32"><path d="M128 384v256q0 12.608 1.28 25.088 1.216 12.544 3.648 24.832 2.432 12.352 6.08 24.384t8.448 23.68q4.864 11.584 10.752 22.72 5.952 11.072 12.928 21.504 7.04 10.496 14.976 20.224 8 9.728 16.896 18.56 8.896 8.96 18.56 16.896 9.728 8 20.224 14.976 10.432 7.04 21.504 12.928 11.136 5.888 22.72 10.688 11.648 4.864 23.68 8.512 12.032 3.648 24.32 6.08 12.352 2.432 24.896 3.712Q371.392 896 384 896h256q12.608 0 25.088-1.28 12.544-1.216 24.832-3.648 12.352-2.432 24.384-6.08t23.68-8.512q11.584-4.8 22.72-10.688 11.072-5.952 21.504-12.928 10.496-7.04 20.224-14.976 9.728-8 18.56-16.896 8.96-8.832 16.896-18.56 8-9.728 14.976-20.224 7.04-10.432 12.928-21.504 5.888-11.136 10.688-22.72 4.864-11.648 8.512-23.68 3.648-12.032 6.08-24.32 2.432-12.352 3.712-24.896Q896 652.608 896 640V384q0-12.608-1.28-25.088-1.216-12.544-3.648-24.832-2.432-12.352-6.08-24.384t-8.512-23.68q-4.8-11.584-10.688-22.72-5.952-11.072-12.928-21.504-7.04-10.496-14.976-20.224-8-9.664-16.896-18.56-8.832-8.96-18.56-16.896-9.728-8-20.224-14.976-10.432-7.04-21.504-12.928-11.136-5.888-22.72-10.752-11.648-4.8-23.68-8.448-12.032-3.648-24.32-6.08-12.352-2.432-24.896-3.712Q652.608 128 640 128H384q-12.608 0-25.088 1.28-12.544 1.216-24.832 3.648-12.352 2.432-24.384 6.08t-23.68 8.448q-11.584 4.864-22.72 10.752-11.072 5.952-21.504 12.928-10.496 7.04-20.224 14.976-9.664 8-18.56 16.896-8.96 8.896-16.896 18.56-8 9.728-14.976 20.224-7.04 10.432-12.928 21.504-5.888 11.136-10.752 22.72-4.8 11.648-8.448 23.68-3.648 12.032-6.08 24.32-2.432 12.352-3.712 24.896Q128 371.392 128 384z m566.016 166.336H330.112a38.4 38.4 0 0 1 0-76.8h363.904a38.4 38.4 0 0 1 0 76.8z" p-id="4395"></path></svg>',color:"rgb(82,146,247)"},{name:"checkbox-check-disabled",configName:"CHECKBOX_CHECK_DISABLED_SVG",svg:St,color:"#DDE0EA"},{name:"checkbox-disabled",configName:"CHECKBOX_DISABLED_SVG",configColorName:"CHECKBOX_DISABLED_COLOR",svg:'<svg t="1722595946663" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4865" width="32" height="32"><path d="M128 640V384a256 256 0 0 1 256-256h256a256 256 0 0 1 256 256v256a256 256 0 0 1-256 256H384a256 256 0 0 1-256-256z" p-id="4866"></path><path d="M128 640V384a256 256 0 0 1 256-256h256a256 256 0 0 1 256 256v256a256 256 0 0 1-256 256H384a256 256 0 0 1-256-256z m64 0q0 79.552 56.256 135.744Q304.448 832 384 832h256q79.552 0 135.744-56.256Q832 719.552 832 640V384q0-79.552-56.256-135.744Q719.552 192 640 192H384q-79.552 0-135.744 56.256Q192 304.448 192 384v256z" fill="#DDE0EA" p-id="4867"></path></svg>',color:"#F1F2F4"},{name:"icon-edit",configName:"ICON_EDIT_SVG",configColorName:"ICON_EDIT_COLOR",svg:'<svg t="1744798692576" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6606" width="200" height="200"><path d="M855.296 894.528H168.768v-76.8h686.528v76.8z m38.4-38.4q0 3.84-0.768 7.488-0.704 3.712-2.176 7.232-1.472 3.52-3.52 6.656-2.112 3.136-4.8 5.76-2.688 2.688-5.824 4.8-3.2 2.112-6.656 3.584-3.456 1.408-7.168 2.176-3.712 0.704-7.488 0.704-3.84 0-7.488-0.704-3.712-0.768-7.232-2.176-3.52-1.472-6.656-3.584-3.136-2.112-5.76-4.736-2.688-2.688-4.8-5.824-2.112-3.2-3.584-6.656-1.408-3.52-2.176-7.232-0.704-3.648-0.704-7.488 0-3.776 0.704-7.488 0.768-3.712 2.176-7.168 1.472-3.52 3.584-6.656 2.112-3.136 4.736-5.76 2.688-2.752 5.824-4.8 3.2-2.112 6.656-3.584 3.52-1.472 7.232-2.176 3.712-0.768 7.488-0.768 3.776 0 7.488 0.768 3.712 0.704 7.168 2.176 3.52 1.472 6.656 3.584 3.2 2.048 5.76 4.736 2.752 2.688 4.864 5.824 2.048 3.2 3.52 6.656 1.472 3.456 2.176 7.168 0.768 3.712 0.768 7.488z m-686.528 0q0 3.84-0.768 7.488-0.704 3.712-2.176 7.232-1.472 3.52-3.52 6.656-2.112 3.136-4.8 5.76-2.688 2.688-5.76 4.8-3.2 2.112-6.72 3.584-3.456 1.408-7.168 2.176-3.712 0.704-7.488 0.704-3.84 0-7.488-0.704-3.712-0.768-7.232-2.176-3.456-1.472-6.656-3.584-3.136-2.112-5.76-4.736-2.688-2.688-4.8-5.824-2.112-3.2-3.584-6.656-1.408-3.52-2.176-7.232-0.704-3.648-0.704-7.488 0-3.776 0.704-7.488 0.768-3.712 2.176-7.168 1.472-3.52 3.584-6.656 2.112-3.136 4.736-5.76 2.688-2.752 5.824-4.8 3.2-2.112 6.656-3.584 3.52-1.472 7.232-2.176 3.712-0.768 7.488-0.768 3.776 0 7.488 0.768 3.712 0.704 7.168 2.176 3.52 1.472 6.656 3.584 3.2 2.048 5.824 4.736 2.688 2.688 4.8 5.824 2.048 3.2 3.52 6.656 1.472 3.456 2.176 7.168 0.768 3.712 0.768 7.488zM652.032 211.2l-369.92 370.368v89.344h90.048l369.664-369.856L652.032 211.2z m-54.4-54.272q22.528-22.528 54.4-22.528 31.808 0 54.336 22.528l89.792 89.856q22.464 22.464 22.464 54.272t-22.464 54.272l-369.664 369.856q-22.464 22.528-54.336 22.528H282.24q-31.808 0-54.336-22.528-22.464-22.464-22.464-54.272V581.568q0-31.808 22.4-54.272l369.92-370.368z" p-id="6607"></path></svg>',color:"#4E5969"},{name:"icon-select",configName:"ICON_SELECT_SVG",configColorName:"ICON_SELECT_COLOR",svg:_t,color:"#4E5969"},{name:"sort-asc",configName:"SORT_ASC_ICON_SVG",configColorName:"SORT_ICON_COLOR",svg:ye,color:"rgb(82,146,247)"},{name:"sort-desc",configName:"SORT_DESC_ICON_SVG",configColorName:"SORT_ICON_COLOR",svg:Ce,color:"rgb(82,146,247)"},{name:"sort-default",configName:"SORTABLE_ICON_SVG",svg:gt,color:"#bec4c7"}]);n(this,"icons",new Map);this.ctx=t,this.init()}async init(){const t=[];for(let e=0;e<this.list.length;e++){const i=this.list[e];let s=i.color,o=i.svg;if(i.configColorName){const a=this.ctx.config[i.configColorName];a&&(s=a)}if(i.configName){const a=this.ctx.config[i.configName];a&&(o=a)}const r=this.createImageFromSVG(o,s).then(a=>{this.icons.set(i.name,a)});t.push(r)}for(let e=0;e<this.ctx.config.ICONS.length;e++){const i=this.ctx.config.ICONS[e];let s=i.color;const o=this.createImageFromSVG(i.svg,s,i.isBlob).then(r=>{this.icons.set(i.name,r)});t.push(o)}await Promise.all(t),this.ctx.emit("draw")}async createImageFromSVG(t,e,i=!1){const r=new DOMParser().parseFromString(t,"image/svg+xml").documentElement;e&&r.querySelectorAll("*").forEach(h=>{const d=h.getAttribute("fill");(d==="currentColor"||d===null)&&h.setAttribute("fill",e)});const a=new Image;let l="";if(i){const h=new Blob([new XMLSerializer().serializeToString(r)],{type:"image/svg+xml"});l=URL.createObjectURL(h)}else l="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(new XMLSerializer().serializeToString(r));return a.src=l,new Promise((h,d)=>{a.onerror=()=>d(new Error("Failed to load image:"+t)),a.onload=()=>{h(a)}})}get(t){return this.icons.get(t)}getSvg(t){return this.list.find(e=>e.name===t)}}class ct extends Bt{constructor(e,i,s,o,r,a,l){super(e,s,o,r,a,"header",l.fixed);n(this,"align");n(this,"hideHeaderSelection",!1);n(this,"verticalAlign","middle");n(this,"fixed");n(this,"minWidth");n(this,"maxWidth");n(this,"widthFillDisable");n(this,"type");n(this,"operation",!1);n(this,"editorType");n(this,"level");n(this,"text");n(this,"displayText","");n(this,"colspan");n(this,"rowspan");n(this,"row");n(this,"key");n(this,"required",!1);n(this,"readonly",!1);n(this,"ellipsis",!1);n(this,"overflowTooltipShow",!0);n(this,"children",[]);n(this,"column");n(this,"colIndex");n(this,"rowKey");n(this,"rules");n(this,"hasChildren");n(this,"render");n(this,"style",{});n(this,"drawX",0);n(this,"drawY",0);n(this,"sortIconName","sort-default");n(this,"sortAscIconName","sort-asc");n(this,"sortDescIconName","sort-desc");n(this,"visibleWidth",0);n(this,"visibleHeight",0);n(this,"maxLineClampHeader","auto");n(this,"domDataset",{});n(this,"drawTextX",0);n(this,"drawTextY",0);n(this,"drawTextWidth",0);n(this,"drawTextHeight",0);n(this,"drawCellBgColor","");n(this,"drawTextColor","");n(this,"drawSelectionImageX",0);n(this,"drawSelectionImageY",0);n(this,"drawSelectionImageWidth",0);n(this,"drawSelectionImageHeight",0);n(this,"drawSelectionImageName","");n(this,"drawSelectionImageSource");n(this,"drawSortImageX",0);n(this,"drawSortImageY",0);n(this,"drawSortImageWidth",0);n(this,"drawSortImageHeight",0);n(this,"drawSortImageName","");n(this,"drawSortImageSource");this.ctx=e,this.x=s,this.y=o,this.width=r,this.height=a,this.visibleWidth=r,this.visibleHeight=a,this.colIndex=i,this.key=l.key,this.minWidth=l.minWidth,this.maxWidth=l.maxWidth,this.type=l.type||"",this.editorType=l.editorType||"text",this.hideHeaderSelection=l.hideHeaderSelection||!1,this.align=l.headerAlign||l.align||this.ctx.config.COLUMNS_ALIGN,this.verticalAlign=l.headerVerticalAlign||l.verticalAlign||this.ctx.config.COLUMNS_VERTICAL_ALIGN,this.fixed=l.fixed,this.level=l.level||0,this.operation=l.operation||!1,this.text=l.title,this.column=l,this.colspan=l.colspan||1,this.widthFillDisable=l.widthFillDisable||!1,this.rowspan=l.rowspan||1,this.rules=l.rules,this.readonly=l.readonly||!1,this.required=l.required||!1,this.sortIconName=l.sortIconName||"sort-default",this.sortAscIconName=l.sortAscIconName||"sort-asc",this.sortDescIconName=l.sortDescIconName||"sort-desc",this.rowKey=Dt(),this.overflowTooltipShow=l.overflowTooltipHeaderShow!==!1,this.hasChildren=l.children&&l.children.length>0||!1,this.render=l.renderHeader,this.maxLineClampHeader=l.maxLineClampHeader||"auto"}isVerticalVisible(){const{stageHeight:e}=this.ctx,i=e;return!(this.y+this.height<=0||this.y>=i)}updateStyle(){this.style=this.getOverlayerViewsStyle()}updateContainer(){const{HEADER_CELL_STYLE_METHOD:e,HEADER_BG_COLOR:i,HEADER_TEXT_COLOR:s}=this.ctx.config;let o=i,r=s;if(typeof e=="function"){const a=e,{backgroundColor:l,color:h}=a({colIndex:this.colIndex,column:this.column})||{};l&&(o=l),h&&(r=h)}this.drawCellBgColor=o,this.drawTextColor=r}update(){this.updateContainer(),this.displayText=this.getText(),this.drawX=this.getDrawX(),this.drawY=this.getDrawY(),this.drawTextX=this.drawX,this.drawTextY=this.drawY,this.drawTextWidth=this.width,this.drawTextHeight=this.height,this.updateStyle()}draw(){this.drawEdge(),this.drawSelection(),this.drawText(),this.drawSelector(),this.drawSortIcon()}drawEdge(){const{paint:e,config:{BORDER_COLOR:i,BORDER:s}}=this.ctx;e.drawRect(this.drawX,this.drawY,this.width,this.height,{borderColor:s?i:"transparent",fillColor:this.drawCellBgColor})}drawText(){const{paint:e,config:{HEADER_FONT:i,CELL_PADDING:s,REQUIRED_COLOR:o}}=this.ctx,r=`${this.displayText}_${this.drawTextWidth}`;this.ellipsis=e.drawText(this.displayText,this.drawTextX,this.drawTextY,this.drawTextWidth,this.drawTextHeight,{font:i,padding:s,color:this.drawTextColor,align:this.align,verticalAlign:this.verticalAlign,maxLineClamp:this.maxLineClampHeader,offsetRight:this.column.sortBy?16:0,offsetLeft:this.required?12:0,cacheTextKey:r,textCallback:a=>{this.column.sortBy&&(this.drawSortImageX=a.right+4,this.drawSortImageY=a.top+(a.height-16)/2),this.required&&e.drawText("*",a.left-18,a.top+(a.height-12)/2,24,24,{color:o,font:"18px Arial",align:"center",verticalAlign:"middle",padding:0})}})}drawSelector(){const{ENABLE_SELECTOR:e}=this.ctx.config;if(!e)return;const{xArr:i}=this.ctx.selector,[s,o]=i;this.colIndex>=s&&this.colIndex<=o&&this.ctx.paint.drawRect(this.drawX,this.drawY,this.width,this.height,{borderColor:"transparent",fillColor:this.ctx.config.SELECT_ROW_COL_BG_COLOR||"transparent"})}drawSelection(){if(!this.hideHeaderSelection&&["index-selection","selection","selection-tree","tree-selection"].includes(this.type)){const{indeterminate:e,check:i,selectable:s}=this.ctx.database.getCheckedState(),{CHECKBOX_SIZE:o=0,CELL_PADDING:r}=this.ctx.config;let a=this.drawX+(this.width-o)/2,l=this.drawY+(this.height-o)/2;this.drawTextX=a+o-r/2,this.drawTextWidth=this.drawX+this.visibleWidth-this.drawTextX,(this.align==="left"||this.align==="right")&&(a=this.drawX+r,this.drawTextX=a+o-r/2,this.drawTextWidth=this.drawX+this.visibleWidth-this.drawTextX),this.verticalAlign==="top"?l=this.drawY+r/2:this.verticalAlign==="bottom"&&(l=this.drawY+this.height-o-r/2);let h=this.ctx.icons.get("checkbox-uncheck"),d="checkbox-uncheck";e?(h=this.ctx.icons.get("checkbox-indeterminate"),d="checkbox-indeterminate"):i&&s?(h=this.ctx.icons.get("checkbox-check"),d="checkbox-check"):i&&!s?(h=this.ctx.icons.get("checkbox-check-disabled"),d="checkbox-check-disabled"):!i&&s?(h=this.ctx.icons.get("checkbox-uncheck"),d="checkbox-uncheck"):(h=this.ctx.icons.get("checkbox-disabled"),d="checkbox-disabled"),h&&(this.drawSelectionImageX=a,this.drawSelectionImageY=l,this.drawSelectionImageWidth=o,this.drawSelectionImageHeight=o,this.drawSelectionImageName=d,this.drawSelectionImageSource=h,this.ctx.paint.drawImage(this.drawSelectionImageSource,this.drawSelectionImageX,this.drawSelectionImageY,this.drawSelectionImageWidth,this.drawSelectionImageHeight))}}drawSortIcon(){if(!this.column.sortBy)return;const e=16;let i=this.sortIconName;const s=this.ctx.database.getSortState(this.key);s.direction==="asc"?i=this.sortAscIconName:s.direction==="desc"&&(i=this.sortDescIconName);const o=this.ctx.icons.get(i);o&&(this.drawSortImageWidth=e,this.drawSortImageHeight=e,this.drawSortImageName=i,this.drawSortImageSource=o,this.ctx.paint.drawImage(this.drawSortImageSource,this.drawSortImageX,this.drawSortImageY,this.drawSortImageWidth,this.drawSortImageHeight))}getText(){return this.render||["",null,void 0].includes(this.text)?"":`${this.text}`}getOverlayerViewsStyle(){let e="";return this.fixed==="left"?e=`${this.drawX}px`:this.fixed==="right"?e=`${this.drawX-(this.ctx.stageWidth-this.ctx.fixedRightWidth)}px`:e=`${this.drawX-this.ctx.fixedLeftWidth}px`,{position:"absolute",overflow:"hidden",left:e,top:`${this.drawY+1}px`,width:`${this.width}px`,height:`${this.height-2}px`,pointerEvents:"initial",userSelect:"none"}}}class Ie{constructor(t){n(this,"ctx");n(this,"visibleHoverCell");n(this,"resizeObserver");n(this,"mutationObserver");this.ctx=t,this.init()}init(){this.resizeObserver=new ResizeObserver(()=>{this.ctx.emit("resetHeader"),this.ctx.emit("resizeObserver")}),this.resizeObserver.observe(this.ctx.containerElement),this.mutationObserver=new MutationObserver(t=>{for(const e of t)e.type==="attributes"&&e.attributeName==="class"&&(this.ctx.config.updateCssVar(),this.ctx.emit("draw"))}),this.ctx.config.ENABLE_AUTO_THEME&&this.mutationObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),this.ctx.on("mousedown",t=>{if(t.button!==0||this.isBusy(t))return;const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,o=i;this.handleHeaderEvent(o,s,this.ctx.header.renderCellHeaders,r=>{this.ctx.focusCellHeader=r,this.ctx.emit("cellHeaderMousedown",r,t)}),this.handleBodyEvent(o,s,this.ctx.body.renderRows,r=>{this.ctx.setFocusCell(r),this.ctx.emit("cellMousedown",r,t)})}),this.ctx.on("mouseup",t=>{if(t.button!==0||this.isBusy(t))return;const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,o=i;this.handleHeaderEvent(o,s,this.ctx.header.renderCellHeaders,r=>{this.ctx.focusCellHeader=r,this.ctx.emit("cellHeaderMouseup",r,t)}),this.handleBodyEvent(o,s,this.ctx.body.renderRows,r=>{this.ctx.setFocusCell(r),this.ctx.emit("cellMouseup",r,t)})}),this.ctx.on("click",t=>{if(t.button!==0||this.isBusy(t))return;const e=this.ctx.getOffset(t).offsetY,i=this.ctx.getOffset(t).offsetX;this.handleHeaderEvent(i,e,this.ctx.header.renderCellHeaders,s=>{this.ctx.clickCellHeader=s,this.ctx.emit("cellHeaderClick",s,t),this.selectionClick(s,t),this.sortClick(s,t)}),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{this.ctx.clickCell=s,this.ctx.emit("cellClick",s,t),this.selectionClick(s,t),this.treeClick(s,t)},!0),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{this.hoverIconClick(s)},!1)}),this.ctx.on("dblclick",t=>{if(t.button!==0||this.isBusy(t))return;const e=this.ctx.getOffset(t).offsetY,i=this.ctx.getOffset(t).offsetX;this.handleHeaderEvent(i,e,this.ctx.header.renderCellHeaders,s=>{this.ctx.emit("cellHeaderDblclick",s,t)}),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{this.ctx.clickCell=s,this.ctx.emit("cellDblclick",s,t)})}),this.ctx.on("contextMenu",t=>{if(this.isBusy(t))return;const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,o=i;this.handleHeaderEvent(o,s,this.ctx.header.renderCellHeaders,r=>{this.ctx.emit("cellHeaderContextMenuClick",r,t)}),this.handleBodyEvent(o,s,this.ctx.body.renderRows,r=>{this.ctx.emit("cellContextMenuClick",r,t)})}),this.ctx.on("mouseout",t=>{!this.ctx.containerElement.contains(t.relatedTarget)&&this.ctx.hoverCell!==void 0&&(this.ctx.hoverRow=void 0,this.ctx.hoverCell=void 0,this.ctx.emit("draw"))}),this.ctx.on("mousemove",t=>{if(this.isBusy(t))return;this.ctx.isPointer=!1,this.ctx.stageElement.style.cursor==="pointer"&&(this.ctx.stageElement.style.cursor="default");const e=this.ctx.getOffset(t).offsetY,i=this.ctx.getOffset(t).offsetX;this.handleHeaderEvent(i,e,this.ctx.header.renderCellHeaders,s=>{this.ctx.emit("cellHeaderMouseenter",s,t),this.ctx.hoverCellHeader&&this.ctx.hoverCellHeader!==s&&this.ctx.emit("cellHeaderMouseleave",this.ctx.hoverCellHeader,t),this.imageEnterAndLeave(s,t),this.ctx.hoverCellHeader!==s&&(this.ctx.hoverCellHeader=s,this.visibleHoverCell=void 0,this.ctx.emit("cellHeaderHoverChange",s,t))}),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{this.imageEnterAndLeave(s,t),this.visibleHoverCell!==s&&(this.ctx.emit("visibleCellMouseleave",s,t),this.visibleHoverCell=s,this.ctx.hoverCellHeader=void 0,this.ctx.emit("visibleCellHoverChange",s,t))},!0),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{var o;this.imageEnterAndLeave(s,t),this.ctx.emit("cellMouseenter",s,t),this.ctx.hoverCell&&this.ctx.hoverCell!==s&&this.ctx.emit("cellMouseleave",s,t),this.ctx.hoverCell!==s&&(((o=this.ctx.hoverCell)==null?void 0:o.rowKey)!==s.rowKey&&(this.ctx.hoverCell=s,this.ctx.hoverRow=this.ctx.body.renderRows.find(r=>r.rowKey===s.rowKey),this.ctx.emit("rowHoverChange",this.ctx.hoverRow,s,t),this.ctx.emit("drawView")),this.ctx.hoverCell=s,this.ctx.emit("cellHoverChange",s,t))})})}hoverIconClick(t){t.hoverIconName&&this.ctx.isPointer&&this.ctx.emit("hoverIconClick",t)}selectionClick(t,e){if(!(["selection","index-selection","selection-tree","tree-selection"].includes(t.type)&&this.ctx.isPointer))return;const{offsetY:s,offsetX:o}=this.ctx.getOffset(e),r=s,a=o;if(this.isInsideElement(a,r,t.drawSelectionImageX,t.drawSelectionImageY,t.drawSelectionImageWidth,t.drawSelectionImageHeight))if(t instanceof ct)t.drawSelectionImageName==="checkbox-uncheck"||t.drawSelectionImageName==="checkbox-indeterminate"?this.ctx.database.toggleAllSelection():t.drawSelectionImageName==="checkbox-check"&&this.ctx.database.clearSelection(!0);else{if(!this.ctx.database.getRowSelectable(t.rowKey))return;this.ctx.database.toggleRowSelection(t.rowKey,t.type)}}treeClick(t,e){if(!(["tree","selection-tree","tree-selection"].includes(t.type)&&this.ctx.isPointer))return;const{offsetY:s,offsetX:o}=this.ctx.getOffset(e),r=s,a=o;if(!this.isInsideElement(a,r,t.drawTreeImageX,t.drawTreeImageY,t.drawTreeImageWidth,t.drawTreeImageHeight))return;const l=this.ctx.database.getRowForRowKey(t.rowKey),{expand:h=!1,expandLazy:d=!1}=l||{},{EXPAND_LAZY:f,EXPAND_LAZY_METHOD:u}=this.ctx.config;if(f&&u&&!h&&!d)typeof u=="function"&&(this.ctx.database.expandLoading(t.rowKey,!0),u({row:t.row,rowIndex:t.rowIndex,colIndex:t.colIndex,column:t.column,value:t.getValue()}).then(w=>{this.ctx.database.setExpandChildren(t.rowKey,w),this.ctx.database.expandLoading(t.rowKey,!1),this.ctx.emit("expandChange",this.ctx.database.getExpandRowKeys())}).catch(w=>{this.ctx.database.expandLoading(t.rowKey,!1),console.error(w)}));else{const x=this.ctx.database.getIsExpand(t.rowKey);this.ctx.database.expandItem(t.rowKey,!x),this.ctx.emit("expandChange",this.ctx.database.getExpandRowKeys())}}sortClick(t,e){const{offsetY:i,offsetX:s}=this.ctx.getOffset(e),o=i,r=s;if(!this.isInsideElement(r,o,t.drawSortImageX,t.drawSortImageY,t.drawSortImageWidth,t.drawSortImageHeight))return;const a=this.ctx.database.getSortState(t.key);let l;a.direction==="none"?l="asc":a.direction==="asc"?l="desc":l="none",this.ctx.database.setSortState(t.key,l)}imageEnterAndLeave(t,e){const{offsetY:i,offsetX:s}=this.ctx.getOffset(e),o=i,r=s;if(t instanceof ct){if(t.drawSelectionImageSource&&this.isInsideElement(r,o,t.drawSelectionImageX,t.drawSelectionImageY,t.drawSelectionImageWidth,t.drawSelectionImageHeight)){this.ctx.stageElement.style.cursor="pointer",this.ctx.isPointer=!0;return}if(t.drawSortImageSource&&this.isInsideElement(r,o,t.drawSortImageX,t.drawSortImageY,t.drawSortImageWidth,t.drawSortImageHeight)){this.ctx.stageElement.style.cursor="pointer",this.ctx.isPointer=!0;return}}if(t instanceof ut){if(t.drawSelectionImageSource&&this.isInsideElement(r,o,t.drawSelectionImageX,t.drawSelectionImageY,t.drawSelectionImageWidth,t.drawSelectionImageHeight)){this.ctx.stageElement.style.cursor="pointer",this.ctx.isPointer=!0,this.ctx.database.getRowSelectable(t.rowKey)||(this.ctx.stageElement.style.cursor="not-allowed");return}if(t.drawHoverImageSource&&this.isInsideElement(r,o,t.drawHoverImageX,t.drawHoverImageY,t.drawHoverImageWidth,t.drawHoverImageHeight)){this.ctx.stageElement.style.cursor="pointer",this.ctx.isPointer=!0;return}if(t.drawTreeImageSource&&this.isInsideElement(r,o,t.drawTreeImageX,t.drawTreeImageY,t.drawTreeImageWidth,t.drawTreeImageHeight)){this.ctx.stageElement.style.cursor="pointer",this.ctx.isPointer=!0;return}}}isInsideElement(t,e,i,s,o,r){return t>i&&t<i+o&&e>s&&e<s+r}isBusy(t){const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,o=i;if(this.ctx.loading||!this.ctx.isTarget(t)||this.ctx.stageElement.style.cursor==="row-resize"||this.ctx.stageElement.style.cursor==="col-resize"||this.ctx.columnResizing||this.ctx.rowResizing)return!0;const{SCROLLER_TRACK_SIZE:r}=this.ctx.config;return!!(this.ctx.scrollerMove||this.ctx.scrollerFocus||s>this.ctx.stageHeight-r||o>this.ctx.stageWidth-r)}handleBodyEvent(t,e,i,s,o=!1){if(this.isInsideBody(e))for(const r of i){const a=r.fixedCells.concat(r.noFixedCells);for(const l of a){const h=l.getDrawX(),d=l.getDrawY();if(o){if(t>h&&t<h+l.visibleWidth&&e>d&&e<d+l.visibleHeight){s(l);return}}else if(t>h&&t<h+l.width&&e>d&&e<d+l.height){s(l);return}}}}handleHeaderEvent(t,e,i,s){for(const o of i){const r=o.getDrawX(),a=o.getDrawY();if(t>r&&t<r+o.width&&e>a&&e<a+o.height){s(o);return}}}isInsideBody(t){return t>this.ctx.body.y&&t<this.ctx.body.y+this.ctx.body.visibleHeight}destroy(){this.resizeObserver.unobserve(this.ctx.stageElement),this.mutationObserver.disconnect()}}class Re{constructor(t,e){n(this,"eventBus");n(this,"eventBrowser");n(this,"eventTable");n(this,"containerElement");n(this,"stageElement");n(this,"canvasElement");n(this,"overlayerElement");n(this,"editorElement");n(this,"emptyElement");n(this,"contextMenuElement");n(this,"loadingElement");n(this,"stageWidth",0);n(this,"stageHeight",0);n(this,"paint");n(this,"icons");n(this,"domSelectionStr","");n(this,"isMouseoverTargetContainer",!1);n(this,"mousedown",!1);n(this,"isPointer",!1);n(this,"rowResizing",!1);n(this,"columnResizing",!1);n(this,"scrollerMove",!1);n(this,"scrollerFocus",!1);n(this,"autofillMove",!1);n(this,"selectorMove",!1);n(this,"selectColsIng",!1);n(this,"selectRowsIng",!1);n(this,"adjustPositioning",!1);n(this,"editing",!1);n(this,"loading",!1);n(this,"onlyMergeCell",!1);n(this,"selectOnlyOne",!1);n(this,"hasSelection",!1);n(this,"hasTree",!1);n(this,"scrollY",0);n(this,"scrollX",0);n(this,"fixedLeftWidth",0);n(this,"fixedRightWidth",0);n(this,"lastCenterColIndex",0);n(this,"maxColIndex",0);n(this,"maxRowIndex",0);n(this,"hoverRow");n(this,"clickCell");n(this,"focusCell");n(this,"currentCell");n(this,"hoverCell");n(this,"clickCellHeader");n(this,"focusCellHeader");n(this,"hoverCellHeader");n(this,"body",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,headIndex:0,tailIndex:0,visibleRows:[],renderRows:[],data:[]});n(this,"footer",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,renderRows:[]});n(this,"header",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,visibleLeafColumns:[],leafCellHeaders:[],renderLeafCellHeaders:[],renderCellHeaders:[],fixedLeftCellHeaders:[],fixedRightCellHeaders:[],renderCenterCellHeaders:[]});n(this,"selector",{enable:!1,xArr:[-1,-1],yArr:[-1,-1],xArrCopy:[-1,-1],yArrCopy:[-1,-1]});n(this,"autofill",{enable:!1,xArr:[-1,-1],yArr:[-1,-1]});n(this,"database");n(this,"history");n(this,"config");n(this,"drawTime",0);const{containerElement:i,stageElement:s,canvasElement:o,overlayerElement:r,editorElement:a,emptyElement:l,loadingElement:h,contextMenuElement:d}=t;this.containerElement=i,s.tabIndex=0,this.stageElement=s,this.canvasElement=o,this.overlayerElement=r,this.editorElement=a,this.emptyElement=l,this.loadingElement=h,this.contextMenuElement=d,this.config=new Rt(e.config||{}),this.eventBus=new me,this.eventBrowser=new Ee(this),this.eventTable=new Ie(this),this.paint=new pe(this.canvasElement),this.database=new ge(this,e),this.history=new we(this),this.icons=new be(this)}setConfig(t){this.config=new Rt(t)}setItemValueByEditor(t,e,i,s=!0,o=!0,r=!0){if(this.config.ENABLE_MERGE_CELL_LINK){const a=this.database.getVirtualBodyCellByKey(t,e);if(a&&(a.mergeRow||a.mergeCol)){const{dataList:l}=a.getSpanInfo(),h=l.map(d=>({...d,value:i}));this.database.batchSetItemValue(h,s,r);return}}this.database.setItemValue(t,e,i,s,o,!0,r)}batchSetItemValueByEditor(t,e=!0,i=!0){if(this.config.ENABLE_MERGE_CELL_LINK){const s=[];t.forEach(o=>{const r=this.database.getRowIndexForRowKey(o.rowKey),a=this.database.getColIndexForKey(o.key);if(r===void 0||a===void 0)return;const l=this.database.getVirtualBodyCell(r,a);if(l){const{dataList:h}=l.getSpanInfo(),d=h.map(f=>({...f,value:o.value}));s.push(...d)}}),this.database.batchSetItemValue(s,e,i)}else this.database.batchSetItemValue(t,e,i)}setFocusCell(t){var e;if(this.focusCell!==t){if(((e=this.focusCell)==null?void 0:e.rowKey)!==t.rowKey){this.currentCell=t,this.emit("rowFocusChange",t);const i={rowIndex:t.rowIndex,rowKey:t.rowKey,row:t.row};this.emit("currentRowChange",i)}this.focusCell=t,this.emit("cellFocusChange",t)}}clearSelector(){this.selector.enable=!1,this.selector.xArr=[-1,-1],this.selector.yArr=[-1,-1],this.emit("clearSelector")}clearSelectorCopy(){this.selector.xArrCopy=[-1,-1],this.selector.yArrCopy=[-1,-1]}clearAutofill(){this.autofill={enable:!1,xArr:[-1,-1],yArr:[-1,-1]}}getSelectedData(){const t=[],e=this.selector.yArr,i=this.selector.xArr;let s="";for(let o=0;o<=e[1]-e[0];o++){const r=[];for(let a=0;a<=i[1]-i[0];a++){const l=o+e[0],h=a+i[0],d=this.database.getVirtualBodyCell(l,h);d&&(d.selectorCellValueType==="displayText"?r.push(d.displayText):r.push(d.getValue()))}s+=`${r.join(" ")}\r`,t.push(r)}return s=s?s.replace(/\r$/,""):" ",{xArr:i,yArr:e,text:s,value:t}}setScroll(t,e){let i=Math.floor(t);const s=this.body.width-this.body.visibleWidth;i<0?i=0:i>s&&(i=s);let o=Math.floor(e),r=this.body.height-this.body.visibleHeight;this.config.FOOTER_FIXED||(r=this.body.height+this.footer.height-this.body.visibleHeight),o<0?o=0:o>r&&(o=r),this.emit("setScroll",i,o)}setScrollX(t){let e=Math.floor(t);const i=this.body.width-this.body.visibleWidth;e<0?e=0:e>i&&(e=i),this.emit("setScrollX",e)}setScrollY(t){let e=Math.floor(t),i=0;this.config.FOOTER_FIXED||(i=this.footer.height);const s=this.body.height-this.body.visibleHeight+i;e<0?e=0:e>s&&(e=s),this.emit("setScrollY",e)}startAdjustPosition(t){this.emit("startAdjustPosition",t)}stopAdjustPosition(){this.emit("stopAdjustPosition")}isTarget(t){return!!this.containerElement.contains(t.target)}getOffset(t){const{left:e,top:i}=this.containerElement.getBoundingClientRect();return{offsetX:t.clientX-e,offsetY:t.clientY-i}}hasEvent(t){return this.eventBus.has(t)}on(t,e){this.eventBus.on(t,e)}once(t,e){this.eventBus.once(t,e)}off(t,e){this.eventBus.off(t,e)}emit(t,...e){this.eventBus.emit(t,...e)}destroy(){this.eventTable.destroy(),this.eventBrowser.destroy(),this.eventBus.destroy()}}class vt{constructor(t,e){n(this,"ctx");n(this,"type");n(this,"isFocus",!1);n(this,"trackX",0);n(this,"trackY",0);n(this,"trackWidth",0);n(this,"trackHeight",0);n(this,"splitPoints",[]);n(this,"barX",0);n(this,"barY",0);n(this,"barWidth",0);n(this,"barHeight",0);n(this,"distance",0);n(this,"visibleDistance",0);n(this,"clientX",0);n(this,"clientY",0);n(this,"dragStart",0);n(this,"isDragging",!1);n(this,"scroll",0);this.ctx=t,this.type=e,this.type==="vertical"?this.scroll=this.ctx.scrollY:this.scroll=this.ctx.scrollX}onWheel(t){this.updateScroll(t)}onTouchmove(t){const{clientY:e,clientX:i}=t.touches[0],s=e-this.clientY,o=i-this.clientX;let r=0;this.type==="vertical"?(r=Math.max(0,Math.min(this.dragStart-s,this.distance)),this.hasScrollbar()&&!(r===0&&s>0||r===this.distance&&s<0)&&t.preventDefault()):this.type==="horizontal"&&(r=Math.max(0,Math.min(this.dragStart-o,this.distance))),this.scroll=r}onTouchstart(t){const{clientY:e,clientX:i}=t.touches[0];this.clientX=i,this.clientY=e,this.dragStart=this.scroll}onMouseDown(t){if(!(t.target instanceof Element)||!this.ctx.isTarget(t))return;if(this.ctx.stageElement.style.cursor==="row-resize"||this.ctx.stageElement.style.cursor==="col-resize")return!0;const{offsetX:e,offsetY:i,clientX:s,clientY:o}=t;if(!(s==this.clientX&&o==this.clientY)){if(this.isOnScrollbar(e,i))this.clientX=s,this.clientY=o,this.isDragging=!0,this.ctx.scrollerMove=!0,this.isFocus=!0,this.dragStart=this.scroll,t.preventDefault();else if(this.isOnTrack(e,i)){let r=0;this.type==="vertical"?r=(i-this.ctx.header.height-this.barHeight/2)/(this.visibleDistance-this.barHeight)*this.distance:r=(e-this.barWidth/2)/(this.visibleDistance-this.barWidth)*this.distance,this.scroll=Math.max(0,Math.min(r,this.distance))}}}onMouseUp(){this.isDragging=!1,this.isFocus=!1,this.clientX=0,this.clientY=0}onMouseMove(t){const{offsetX:e,offsetY:i,clientX:s,clientY:o,buttons:r}=t;if(this.isOnScrollbar(e,i)&&t.target===this.ctx.canvasElement?this.isFocus=!0:this.isFocus=!1,r===0||s==this.clientX&&o==this.clientY)return;let a=0;if(this.type==="horizontal"?a=s-this.clientX:a=o-this.clientY,this.isDragging&&a!==0){let l=0;this.type==="vertical"?l=this.dragStart+a/(this.visibleDistance-this.barHeight)*this.distance:l=this.dragStart+a/(this.visibleDistance-this.barWidth)*this.distance,this.scroll=Math.max(0,Math.min(l,this.distance))}}isPointInElement(t,e,i,s,o,r){return t>=i&&t<=i+o&&e>=s&&e<=s+r}hasScrollbar(){return this.type==="vertical"?this.barHeight>0:this.type==="horizontal"?this.barWidth>0:!1}isOnScrollbar(t,e){return this.isPointInElement(t,e,this.barX,this.barY,this.barWidth,this.barHeight)}isOnTrack(t,e){return this.isPointInElement(t,e,this.trackX,this.trackY,this.trackWidth,this.trackHeight)}updateScroll(t){const e=t.deltaX,i=t.deltaY;this.type==="vertical"&&t.shiftKey===!1?(this.hasScrollbar()&&!(this.scroll===0&&i<0||this.scroll===this.distance&&i>0)&&t.preventDefault(),this.scroll=Math.max(0,Math.min(this.scroll+i,this.distance))):this.type==="horizontal"&&(t.shiftKey?this.scroll=Math.max(0,Math.min(this.scroll+i,this.distance)):this.scroll=Math.max(0,Math.min(this.scroll+e,this.distance)))}updatedSize(){const{body:t,header:e,stageHeight:i,stageWidth:s,config:{SCROLLER_TRACK_SIZE:o=0,SCROLLER_SIZE:r=0,BORDER:a}}=this.ctx,l=s,h=i,d=e.height,f=e.width,u=t.height,x=this.ctx.footer.height;if(this.type==="vertical"){this.visibleDistance=h-o-d,this.distance=u-this.visibleDistance+x,this.trackX=l-o,this.trackY=0,this.splitPoints=[this.trackX,d,this.trackX+o,d],this.trackWidth=o,this.trackHeight=h,this.barX=this.trackX-1+(o-r)/2,this.barWidth=r;const w=this.distance?this.visibleDistance/(u+x):0;let E=Math.floor(w*this.visibleDistance);E<30?E=30:E>this.visibleDistance&&(E=0),this.barHeight=E,this.barY=d+this.scroll/this.distance*(this.visibleDistance-this.barHeight),this.scroll=Math.max(0,Math.min(this.scroll,this.distance))}else{this.visibleDistance=l-o,this.distance=f-this.visibleDistance,this.splitPoints=[l-o,h-o,l-o,h];const w=a?0:.5;this.trackX=0,this.trackY=h-o+w,this.trackWidth=l,this.trackHeight=o;const E=this.distance?this.visibleDistance/f:0;let g=Math.floor(E*this.visibleDistance);this.barY=this.trackY-1+(o-r)/2,g<30?g=30:g>=this.visibleDistance&&(g=0),this.barWidth=g,this.barHeight=r,this.barX=this.scroll/this.distance*(this.visibleDistance-this.barWidth),this.scroll=Math.max(0,Math.min(this.scroll,this.distance))}}draw(){const{config:{SCROLLER_FOCUS_COLOR:t,SCROLLER_COLOR:e,BORDER_COLOR:i,BORDER:s,SCROLLER_TRACK_COLOR:o}}=this.ctx;this.updatedSize();let r=i;s||(r="transparent"),this.ctx.paint.drawRect(this.trackX,this.trackY,this.trackWidth,this.trackHeight,{borderColor:r,fillColor:o}),this.ctx.paint.drawRect(this.barX,this.barY,this.barWidth,this.barHeight,{fillColor:this.isFocus||this.isDragging?t:e,radius:4}),this.splitPoints.length>0&&this.ctx.paint.drawLine(this.splitPoints,{borderColor:r,borderWidth:1}),this.ctx.scrollerFocus=this.isFocus}}class Se{constructor(t){n(this,"ctx");n(this,"verticalScrollbar");n(this,"horizontalScrollbar");n(this,"mousedownHeader",!1);n(this,"adjustPositionX","");n(this,"adjustPositionY","");n(this,"timerX",0);n(this,"timerY",0);this.ctx=t,this.verticalScrollbar=new vt(t,"vertical"),this.horizontalScrollbar=new vt(t,"horizontal"),this.ctx.on("wheel",e=>this.onWheel(e)),this.ctx.on("mousedown",e=>this.onMouseDown(e)),this.ctx.on("mousemove",e=>this.onMouseMove(e)),this.ctx.on("mouseup",()=>this.onMouseUp()),this.ctx.on("touchmove",e=>this.onTouchmove(e)),this.ctx.on("touchstart",e=>{this.onTouchstart(e)}),this.ctx.on("setScroll",(e,i)=>{this.setScroll(e,i)}),this.ctx.on("setScrollX",e=>{this.setScrollX(e)}),this.ctx.on("setScrollY",e=>{this.setScrollY(e)}),this.ctx.on("cellHeaderMousedown",()=>{this.mousedownHeader=!0}),this.ctx.on("startAdjustPosition",e=>{this.startAdjustPosition(e)}),this.ctx.on("stopAdjustPosition",()=>{this.stopAdjustPosition()})}onWheel(t){this.verticalScrollbar.onWheel(t),this.horizontalScrollbar.onWheel(t),this.draw()}onTouchmove(t){this.verticalScrollbar.onTouchmove(t),this.horizontalScrollbar.onTouchmove(t),this.draw()}onTouchstart(t){this.verticalScrollbar.onTouchstart(t),this.horizontalScrollbar.onTouchstart(t),this.draw()}onMouseDown(t){this.verticalScrollbar.onMouseDown(t),this.horizontalScrollbar.onMouseDown(t),this.draw()}onMouseMove(t){this.verticalScrollbar.onMouseMove(t),this.horizontalScrollbar.onMouseMove(t),this.draw()}onMouseUp(){this.mousedownHeader=!1,this.verticalScrollbar.onMouseUp(),this.horizontalScrollbar.onMouseUp(),this.ctx.scrollerMove=!1}draw(){this.verticalScrollbar.draw(),this.horizontalScrollbar.draw();const t=Math.floor(this.horizontalScrollbar.scroll),e=Math.floor(this.verticalScrollbar.scroll);(t!==this.ctx.scrollX||e!==this.ctx.scrollY)&&(this.ctx.emit("onScroll",t,e),t!==this.ctx.scrollX&&this.ctx.emit("onScrollX",t),e!==this.ctx.scrollY&&this.ctx.emit("onScrollY",e),this.ctx.scrollX=t,this.ctx.scrollY=e,this.ctx.emit("draw"))}setScroll(t,e){this.horizontalScrollbar.scroll=t,this.verticalScrollbar.scroll=e,this.ctx.emit("draw"),this.ctx.emit("onScroll",t,e)}setScrollX(t){this.horizontalScrollbar.scroll=t,this.ctx.emit("draw")}setScrollY(t){this.verticalScrollbar.scroll=t,this.ctx.emit("draw")}scrollToColkey(t){const{header:e}=this.ctx,i=e.leafCellHeaders.find(s=>s.key===t);i&&this.setScrollX(i.x-e.visibleWidth/2)}scrollToColIndex(t){const{header:e}=this.ctx,i=e.leafCellHeaders.find(s=>s.colIndex===t);i&&i.x>e.visibleWidth/2&&this.setScrollX(i.x-e.visibleWidth/2)}scrollToRowIndex(t){const{body:e,database:i}=this.ctx,{top:s}=i.getPositionForRowIndex(t);s>e.visibleHeight&&this.setScrollY(s-e.visibleHeight/2)}scrollToRowKey(t){const{body:e,database:i}=this.ctx,s=i.getRowIndexForRowKey(t);if(s===void 0)return;const{top:o}=i.getPositionForRowIndex(s);this.setScrollY(o-e.visibleHeight/2)}startAdjustPosition(t){var r,a;const{offsetX:e,offsetY:i}=this.ctx.getOffset(t);let s="",o="";if(((r=this.ctx.focusCell)==null?void 0:r.fixed)!=="left"&&e<this.ctx.fixedLeftWidth?s="left":((a=this.ctx.focusCell)==null?void 0:a.fixed)!=="right"&&e>this.ctx.body.visibleWidth-this.ctx.fixedRightWidth?s="right":(s="",this.stopAdjustPosition(!0,!1)),!this.mousedownHeader&&i<this.ctx.header.visibleHeight?o="top":i>this.ctx.header.visibleHeight+this.ctx.body.visibleHeight?o="bottom":(o="",this.stopAdjustPosition(!1,!0)),s&&this.adjustPositionX!==s){this.adjustPositionX=s;let h=10*(s==="left"?-1:1);this.timerX&&(clearInterval(this.timerX),this.timerX=0),this.timerX=setInterval(()=>{h*=1.5;const{scrollX:d}=this.ctx,f=d+h;(f<0||f>this.ctx.body.width)&&(clearInterval(this.timerX),this.timerX=0),this.ctx.setScrollX(f)},100)}if(o&&this.adjustPositionY!==o){this.adjustPositionY=o;let h=10*(o==="top"?-1:1);this.timerY&&(clearInterval(this.timerY),this.timerY=0),this.timerY=setInterval(()=>{h*=1.5;const{scrollY:d}=this.ctx,f=d+h;(f<0||f>this.ctx.body.height)&&(clearInterval(this.timerY),this.timerY=0),this.ctx.setScrollY(f)},100)}}stopAdjustPosition(t=!0,e=!0){t&&(this.adjustPositionX="",this.timerX&&(clearInterval(this.timerX),this.timerX=0)),e&&(this.adjustPositionY="",this.timerY&&(clearInterval(this.timerY),this.timerY=0))}}class _e{constructor(t){n(this,"ctx");n(this,"x",0);n(this,"y",0);n(this,"width",0);n(this,"height",0);n(this,"resizeTarget",null);n(this,"resizeNum",0);n(this,"isResizing",!1);n(this,"clientX",0);n(this,"resizeDiff",0);n(this,"columnIndex",0);n(this,"isMouseDown",!1);n(this,"columns");n(this,"visibleLeafColumns",[]);n(this,"visibleHeight",0);n(this,"visibleWidth",0);n(this,"allCellHeaders",[]);n(this,"leafCellHeaders",[]);n(this,"renderLeafCellHeaders",[]);n(this,"fixedLeftCellHeaders",[]);n(this,"centerCellHeaders",[]);n(this,"fixedRightCellHeaders",[]);n(this,"renderCenterCellHeaders",[]);n(this,"renderFixedCellHeaders",[]);this.ctx=t,this.ctx.on("resetHeader",Z(()=>{this.init(),this.ctx.emit("draw")},100)),this.init(),this.initResizeColumn()}init(){const{config:{HEADER_HEIGHT:t,SCROLLER_TRACK_SIZE:e}}=this.ctx,i=this.ctx.database.getColumns();this.columns=i,this.allCellHeaders=[],this.leafCellHeaders=[],this.fixedLeftCellHeaders=[],this.fixedRightCellHeaders=[],this.centerCellHeaders=[];const s=Nt(i),o=it(i);this.height=t*s,this.width=o.reduce((f,u)=>{const x=u.width||100,{maxWidth:w,minWidth:E}=u;return w&&x>w?f+w:E&&x<E?f+E:f+x},0),this.visibleHeight=this.height;const r=ae(kt(i,s));this.columnIndex=0,this.resizeNum=0,this.render(r,0),this.ctx.database.updateColIndexKeyMap(this.leafCellHeaders);const a=this.ctx.containerElement.getBoundingClientRect();this.resizeNum>0?this.ctx.stageWidth=Math.floor(a.width):this.ctx.stageWidth=Math.floor(this.width+e),this.ctx.stageElement.style.width=this.ctx.stageWidth+"px",this.visibleWidth=this.ctx.stageWidth-e;const l=this.visibleWidth-this.width;if(this.resizeNum&&l>0){const f=Math.floor(l/this.resizeNum*100)/100;this.resizeAllColumn(f)}const h=this.fixedLeftCellHeaders.filter(f=>!f.hasChildren);this.ctx.fixedLeftWidth=h.reduce((f,u)=>f+u.width,0);const d=this.fixedRightCellHeaders.filter(f=>!f.hasChildren);this.ctx.fixedRightWidth=d.reduce((f,u)=>f+u.width,e),this.ctx.maxColIndex=this.leafCellHeaders.length-1,this.ctx.header.x=this.x,this.ctx.header.y=this.y,this.ctx.header.width=this.width,this.ctx.header.height=this.height,this.ctx.header.visibleWidth=this.visibleWidth,this.ctx.header.visibleHeight=this.visibleHeight}initResizeColumn(){this.ctx.on("mousedown",t=>{this.ctx.config.ENABLE_RESIZE_COLUMN&&this.ctx.isTarget(t)&&(this.clientX=t.clientX,this.resizeTarget?(this.isResizing=!0,this.ctx.columnResizing=!0):this.isResizing=!1,this.isMouseDown=!0)}),this.ctx.on("mouseup",()=>{this.ctx.config.ENABLE_RESIZE_COLUMN&&(this.isMouseDown=!1,this.resizeDiff!==0&&this.resizeTarget&&this.resizeColumn(this.resizeTarget,this.resizeDiff),this.resizeTarget=null,this.isResizing=!1,this.isMouseDown=!1,this.ctx.columnResizing=!1,this.clientX=0,this.resizeDiff=0)}),this.ctx.on("mousemove",t=>{if(!this.ctx.config.ENABLE_RESIZE_COLUMN||this.ctx.editing)return;const{stageWidth:e,config:{RESIZE_COLUMN_MIN_WIDTH:i}}=this.ctx;if(this.isResizing&&this.resizeTarget){const s=this.resizeTarget.width,o=this.resizeTarget.minWidth,r=this.resizeTarget.maxWidth;let a=t.clientX-this.clientX;a+s<i&&(a=-(s-i)),o&&a+s<o&&(a=-(s-o)),r&&a+s>r&&(a=r-s),this.resizeDiff=a,this.ctx.emit("draw")}else{if(this.resizeTarget=null,this.isMouseDown)return;if(t.offsetX<0||t.offsetX>this.visibleWidth){this.ctx.stageElement.style.cursor==="col-resize"&&(this.ctx.stageElement.style.cursor="default");return}this.ctx.stageElement.style.cursor==="col-resize"&&(this.ctx.stageElement.style.cursor="default");const s=[...this.renderFixedCellHeaders,...this.renderCenterCellHeaders];for(const o of s){const{offsetX:r,offsetY:a}=this.ctx.getOffset(t),l=r,h=o.getDrawX();l>h+o.width-5&&l<h+o.width+4&&l<e-4&&o.colspan<=1&&this.ctx.isTarget(t)&&a<=this.height&&(this.ctx.stageElement.style.cursor="col-resize",this.resizeTarget=o)}}})}resizeColumn(t,e){const i=o=>{o.forEach(r=>{if(r.children&&r.children.length>0&&i(r.children),r.key===t.key){const a=r.width||100;r.width=a+e}})};i(this.columns),this.ctx.database.setColumns(this.columns),this.init(),this.ctx.emit("draw");let s=0;if(this.width<this.visibleWidth){const o=this.visibleWidth-this.width;s=Math.floor(o/this.resizeNum*100)/100,this.resizeAllColumn(s),this.ctx.emit("draw")}this.ctx.emit("resizeColumnChange",{colIndex:t.colIndex,key:t.key,oldWidth:t.width,width:t.width+e+s,column:t.column,columns:this.columns})}resizeAllColumn(t){if(t===0)return;const e=new Map;let i=!0;for(const o of this.allCellHeaders)if(o.widthFillDisable)e.set(o.key,o.width);else{const r=o.width+t*o.colspan;e.set(o.key,r),r<this.ctx.config.RESIZE_COLUMN_MIN_WIDTH&&(i=!1)}if(!i)return;const s=o=>{o.forEach(r=>{e.has(r.key)&&(r.width=e.get(r.key)),r.children&&r.children.length>0&&s(r.children)})};s(this.columns),this.ctx.database.setColumns(this.columns),this.init()}render(t,e){const i=t.length;let s=e;const{HEADER_HEIGHT:o=0}=this.ctx.config;for(let r=0;r<i;r++){const a=t[r],l=o*(a.rowspan||0),h=o*(a.level||0);let{minWidth:d,maxWidth:f}=a,u=a.width||100;d&&u<d&&(u=d),f&&u>f&&(u=f),a.children&&(u=it(a.children).reduce((E,g)=>E+((g==null?void 0:g.width)||100),0));const x=new ct(this.ctx,this.columnIndex,s,h,u,l,a);this.ctx.database.setHeader(a.key,x),this.allCellHeaders.push(x),a.children||(this.leafCellHeaders.push(x),x.column.widthFillDisable||this.resizeNum++),a.fixed==="left"?this.fixedLeftCellHeaders.push(x):a.fixed==="right"?this.fixedRightCellHeaders.push(x):this.centerCellHeaders.push(x),!a.children&&this.columnIndex++,a.children&&this.render(a.children,s),s+=u}}drawTipLine(){if(this.isResizing&&this.resizeTarget){const{stageHeight:t,config:{RESIZE_COLUMN_LINE_COLOR:e}}=this.ctx,i=this.resizeTarget.getDrawX(),s=this.resizeTarget.width,o=i+s+this.resizeDiff-.5,r=[o-.5,0,o-.5,t];this.ctx.paint.drawLine(r,{borderColor:e,borderWidth:1})}}drawFixedShadow(){const{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,stageWidth:o,config:{HEADER_BG_COLOR:r,SCROLLER_TRACK_SIZE:a}}=this.ctx;if(i>0&&t!==0&&this.ctx.paint.drawShadow(this.x,this.y,t,this.height,{fillColor:r,side:"right",shadowWidth:4,colorStart:"rgba(0,0,0,0.1)",colorEnd:"rgba(0,0,0,0)"}),i<Math.floor(s.width-o-1)&&e!==a){const l=s.width-(this.x+this.width)+o-e;this.ctx.paint.drawShadow(l,this.y,e,this.height,{fillColor:r,side:"left",shadowWidth:4,colorStart:"rgba(0,0,0,0)",colorEnd:"rgba(0,0,0,0.1)"})}}update(){const t=[],e=[],i=[];if(this.centerCellHeaders.length){const s=this.centerCellHeaders[this.centerCellHeaders.length-1];this.ctx.lastCenterColIndex=s.colIndex}this.centerCellHeaders.forEach(s=>{s.isHorizontalVisible()&&s.isVerticalVisible()&&(e.push(s),s.hasChildren||t.push(s))}),this.fixedLeftCellHeaders.forEach(s=>{i.push(s),s.hasChildren||t.push(s)}),this.fixedRightCellHeaders.forEach(s=>{i.push(s),s.hasChildren||t.push(s)}),this.renderCenterCellHeaders=e,this.renderFixedCellHeaders=i,this.renderLeafCellHeaders=t.sort((s,o)=>s.x-o.x),this.visibleLeafColumns=this.renderLeafCellHeaders.map(s=>s.column),this.ctx.header.visibleLeafColumns=this.visibleLeafColumns,this.ctx.header.leafCellHeaders=this.leafCellHeaders,this.ctx.header.renderLeafCellHeaders=this.renderLeafCellHeaders,this.ctx.header.renderCellHeaders=this.renderFixedCellHeaders.concat(this.renderCenterCellHeaders)}drawBottomLine(){const{stageWidth:t,config:{BORDER_COLOR:e}}=this.ctx,i=[0,this.height,t,this.height];this.ctx.paint.drawLine(i,{borderColor:e,borderWidth:1})}draw(){this.renderCenterCellHeaders.forEach(t=>{t.update(),t.draw()}),this.drawFixedShadow(),this.renderFixedCellHeaders.forEach(t=>{t.update(),t.draw()}),this.drawTipLine(),this.drawBottomLine()}}class Kt{constructor(t,e,i=0,s=0,o=0,r=0,a,l="body"){n(this,"ctx");n(this,"x",0);n(this,"y",0);n(this,"width",0);n(this,"height");n(this,"cells",[]);n(this,"fixedCells",[]);n(this,"noFixedCells",[]);n(this,"calculatedHeightCells",[]);n(this,"rowIndex",0);n(this,"rowKey","");n(this,"rowType","body");n(this,"data");n(this,"calculatedHeight",-1);this.ctx=t,this.x=i,this.y=s,this.width=o,this.height=r,this.rowIndex=e,this.rowKey=t.database.getRowKeyForRowIndex(e)||"",this.rowType=l,this.data=a,this.update()}update(){const{header:t}=this.ctx,e=[],i=[],s=[],o=[];t.renderLeafCellHeaders.forEach(r=>{const a=new ut(this.ctx,this.rowIndex,r.colIndex,r.x,this.y,r.width,this.height,r.column,this.data,this.rowType);a.fixed?i.push(a):s.push(a),e.push(a),a.autoRowHeight&&o.push(a)}),this.cells=e,this.calculatedHeightCells=o,this.fixedCells=i,this.noFixedCells=s}updateCalculatedHeight(){const t=this.calculatedHeightCells.map(e=>e.getAutoHeight());this.calculatedHeight=t.length?Math.max(...t):-1}drawCenter(){this.noFixedCells.forEach(t=>{t.draw()})}drawFixed(){this.fixedCells.forEach(t=>{t.draw()})}drawContainer(){this.noFixedCells.forEach(t=>{t.drawContainer()})}drawFixedContainer(){this.fixedCells.forEach(t=>{t.drawContainer()})}}class ve{constructor(t){n(this,"resizeTarget",null);n(this,"isMouseDown",!1);n(this,"resizeDiff",0);n(this,"clientY",0);n(this,"ctx");n(this,"x",0);n(this,"y",0);n(this,"width",0);n(this,"height",0);n(this,"headIndex",0);n(this,"tailIndex",0);n(this,"isResizing",!1);n(this,"renderRows",[]);n(this,"visibleRows",[]);n(this,"visibleHeight",0);n(this,"visibleWidth",0);n(this,"containerRect");n(this,"data",[]);this.ctx=t,this.init(),this.initResizeRow()}init(){const{canvasElement:t,header:e,footer:i,database:s,config:{FOOTER_FIXED:o,SCROLLER_TRACK_SIZE:r=0,HEIGHT:a,EMPTY_BODY_HEIGHT:l=0,MAX_HEIGHT:h=0,ENABLE_OFFSET_HEIGHT:d=0,OFFSET_HEIGHT:f=0,FOOTER_POSITION:u}}=this.ctx;if(!e.width)return;this.x=0,u==="top"&&o?this.y=e.height+i.height:this.y=e.height;const{data:x,sumHeight:w}=s.getData();this.height=w,this.data=x,this.width=e.width,this.visibleWidth=this.ctx.stageWidth-r;const E=this.ctx.footer.height;!this.data.length&&!a?this.height=l:!this.data.length&&a&&(this.height=a-e.height-E-r);let g=this.height+e.height+r;g+=E;let m=g;const y=window.innerHeight,{top:p}=this.containerRect||this.ctx.containerElement.getBoundingClientRect();if(y>p&&d&&!a){const O=y-p-f;O>e.height+r?m=O:g>h&&(m=h)}else this.data.length&&a?m=a:this.data.length&&h&&g>h&&(m=h);m>0&&(this.ctx.stageHeight=Math.floor(m),this.ctx.stageElement.style.height=`${this.ctx.stageHeight}px`);let b=this.ctx.stageHeight-e.height-r;o?this.visibleHeight=b-E:this.visibleHeight=b,this.data.length||(this.height=this.visibleHeight),this.ctx.body.x=this.x,this.ctx.body.y=this.y,this.ctx.body.width=this.width,this.ctx.body.height=this.height,this.ctx.body.visibleWidth=this.visibleWidth,this.ctx.body.visibleHeight=this.visibleHeight,this.ctx.body.data=x;const C=window.devicePixelRatio||1,R=this.ctx.stageWidth*C,_=this.ctx.stageHeight*C;t.width=Math.round(R),t.height=Math.round(_);const T=this.data.length?"not-empty":"empty";this.ctx.emit("emptyChange",{isEmpty:T,type:T,headerHeight:e.height,bodyHeight:this.height,footerHeight:E,width:this.width,height:this.data.length?0:l+E});const S=Math.round(t.width/C*1e4)/1e4,I=Math.round(t.height/C*1e4)/1e4;this.ctx.canvasElement.setAttribute("style",`height:${I}px;width:${S}px;`),this.ctx.paint.scale(C)}initResizeRow(){this.ctx.on("resize",()=>{this.ctx.config.ENABLE_RESIZE_ROW&&(this.containerRect=this.ctx.containerElement.getBoundingClientRect())}),this.ctx.on("resizeObserver",()=>{this.ctx.config.ENABLE_RESIZE_ROW&&(this.containerRect=this.ctx.containerElement.getBoundingClientRect())}),this.ctx.on("mouseup",()=>{this.ctx.config.ENABLE_RESIZE_ROW&&(this.isMouseDown=!1,this.resizeDiff!==0&&this.resizeTarget&&this.resizeRow(this.resizeTarget,this.resizeDiff),this.resizeTarget=null,this.resizeDiff=0,this.isResizing=!1,setTimeout(()=>{this.ctx.rowResizing=!1},0),this.clientY=0)}),this.ctx.on("mousedown",t=>{this.ctx.config.ENABLE_RESIZE_ROW&&this.ctx.isTarget(t)&&(this.clientY=t.clientY,this.resizeTarget?(this.isResizing=!0,this.ctx.rowResizing=!0):(this.isResizing=!1,this.ctx.rowResizing=!1),this.isMouseDown=!0)}),this.ctx.on("mousemove",t=>{if(!this.ctx.config.ENABLE_RESIZE_ROW||this.ctx.editing)return;const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,o=i,r=t.clientY,{stageHeight:a,scrollY:l,config:{RESIZE_ROW_MIN_HEIGHT:h=0}}=this.ctx;if(this.isResizing&&this.resizeTarget){const d=this.resizeTarget.height;let f=r-this.clientY;const{calculatedHeight:u}=this.resizeTarget,x=u===-1?h:u;f+d<x&&(f=-(d-x)),this.resizeDiff=f,this.ctx.emit("draw")}else{if(this.resizeTarget=null,this.isMouseDown)return;if(o<0||o>this.ctx.body.visibleWidth||s<0||s>this.ctx.header.visibleHeight+this.ctx.body.visibleHeight){this.ctx.stageElement.style.cursor==="row-resize"&&(this.ctx.stageElement.style.cursor="default");return}if(this.ctx.stageElement.style.cursor==="crosshair")return;this.ctx.stageElement.style.cursor==="row-resize"&&(this.ctx.stageElement.style.cursor="default");for(let d=0;d<this.renderRows.length;d++){const f=this.renderRows[d];if(s>f.y-l+f.height-1.5&&s<f.y-l+f.height+1.5&&s<a-4)for(let x=0;x<f.cells.length;x++){const w=f.cells[x];o>w.drawX+10&&o<w.drawX+w.width-10&&w.rowspan===1&&(this.ctx.stageElement.style.cursor="row-resize",this.resizeTarget=f)}}}})}resizeRow(t,e){const{rowIndex:i,height:s,rowKey:o,data:r}=t;this.ctx.database.setRowHeight(i,s+e),this.init(),this.ctx.emit("draw"),this.ctx.emit("resizeRowChange",{rowIndex:i,oldHeight:s,height:s+e,rowKey:o,row:r,data:this.data})}drawTipLine(){if(this.isResizing&&this.resizeTarget){const{stageWidth:t,scrollY:e,config:{RESIZE_ROW_LINE_COLOR:i}}=this.ctx,s=this.resizeTarget.y-e,o=this.resizeTarget.height,r=s+o+this.resizeDiff-.5,a=[0,r-.5,t,r-.5];this.ctx.paint.drawLine(a,{borderColor:i,borderWidth:1})}}drawFixedShadow(){const{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,stageWidth:o,config:{HEADER_BG_COLOR:r,SCROLLER_TRACK_SIZE:a}}=this.ctx;if(i>0&&t!==0&&this.ctx.paint.drawShadow(this.x,this.y,t,this.height,{fillColor:r,side:"right",shadowWidth:4,colorStart:"rgba(0,0,0,0.1)",colorEnd:"rgba(0,0,0,0)"}),i<Math.floor(s.width-o-1)&&e!==a){const l=s.width-(this.x+this.width)+o-e;this.ctx.paint.drawShadow(l,this.y,e,this.height,{fillColor:r,side:"left",shadowWidth:4,colorStart:"rgba(0,0,0,0)",colorEnd:"rgba(0,0,0,0.1)"})}}binarySearch(t,e){let i=0,s=t.length-1,o=-1;for(;i<=s;){let r=Math.floor((i+s)/2),a=t[r].bottom;if(a===e)return r;a<e?i=r+1:(o=r,s=r-1)}return o}update(){this.init();const{header:t,database:e,scrollY:i,config:{CELL_HEIGHT:s}}=this.ctx,o=i,{data:r,positions:a}=e.getData();this.ctx.maxRowIndex=r.length-1;let l=this.binarySearch(a,o),h=this.binarySearch(a,o+this.visibleHeight);if(h===-1&&(h=this.ctx.maxRowIndex),l===-1&&h===this.ctx.maxRowIndex){const f=Math.floor(this.visibleHeight/s);l=this.ctx.maxRowIndex-f}this.headIndex=Math.max(0,l),this.tailIndex=Math.min(this.ctx.maxRowIndex,h+1),this.visibleRows=r.slice(this.headIndex,this.tailIndex+1),this.ctx.body.headIndex=this.headIndex,this.ctx.body.tailIndex=this.tailIndex,this.ctx.body.visibleRows=this.visibleRows;const d=[];for(let f=0;f<this.visibleRows.length;f++){const u=this.headIndex+f,x=this.visibleRows[f],{height:w,top:E}=this.ctx.database.getPositionForRowIndex(u),g=new Kt(this.ctx,u,0,E+this.y,t.width,w,x);d.push(g)}this.renderRows=d,this.ctx.body.renderRows=d}updateAutoHeight(){const t=this.ctx.body.renderRows;if(!t.some(s=>s.calculatedHeightCells.length>0))return;t.forEach(s=>{s.updateCalculatedHeight()});const i=t.map(s=>({height:s.calculatedHeight,rowIndex:s.rowIndex}));this.ctx.database.setBatchCalculatedRowHeight(i)}draw(){this.renderRows.forEach(t=>{t.drawContainer()}),this.renderRows.forEach(t=>{t.drawCenter()}),this.drawFixedShadow(),this.renderRows.forEach(t=>{t.drawFixedContainer()}),this.renderRows.forEach(t=>{t.drawFixed()}),this.drawTipLine()}}class Te{constructor(t){n(this,"ctx");n(this,"renderRows",[]);n(this,"data",[]);n(this,"x",0);n(this,"y",0);n(this,"width",0);n(this,"height",0);n(this,"visibleWidth",0);n(this,"visibleHeight",0);this.ctx=t,this.init()}init(){this.data=this.ctx.database.getFooterData();const{header:t,body:e,config:{CELL_FOOTER_HEIGHT:i,FOOTER_FIXED:s,SCROLLER_TRACK_SIZE:o,FOOTER_POSITION:r}}=this.ctx;this.width=t.width,this.visibleWidth=t.visibleWidth,this.height=this.data.reduce(a=>a+i,0),this.visibleHeight=this.height,s?r==="top"?this.y=this.ctx.header.height:this.y=this.ctx.stageHeight-this.height-o:this.y=e.y+e.height,this.ctx.footer.x=this.x,this.ctx.footer.y=this.y,this.ctx.footer.height=this.height,this.ctx.footer.width=this.width,this.ctx.footer.visibleWidth=this.visibleWidth,this.ctx.footer.visibleHeight=this.visibleHeight}drawFixedShadow(){const{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,stageWidth:o,config:{HEADER_BG_COLOR:r,SCROLLER_TRACK_SIZE:a}}=this.ctx;let l=this.y;if(this.ctx.config.FOOTER_FIXED||(l=this.y-this.ctx.scrollY),i>0&&t!==0&&this.ctx.paint.drawShadow(this.x,l,t,this.height,{fillColor:r,side:"right",shadowWidth:4,colorStart:"rgba(0,0,0,0.1)",colorEnd:"rgba(0,0,0,0)"}),i<Math.floor(s.width-o-1)&&e!==a){const h=s.width-(this.x+this.width)+o-e;this.ctx.paint.drawShadow(h,l,e,this.height,{fillColor:r,side:"left",shadowWidth:4,colorStart:"rgba(0,0,0,0)",colorEnd:"rgba(0,0,0,0.1)"})}}update(){this.init();const{CELL_FOOTER_HEIGHT:t}=this.ctx.config;let e=this.y;const i=[];this.data.forEach((s,o)=>{const r=new Kt(this.ctx,o,0,e,this.width,t,s,"footer");e+=t,i.push(r)}),this.renderRows=i,this.ctx.footer.renderRows=this.renderRows}drawTopLine(){const{stageWidth:t,config:{BORDER_COLOR:e}}=this.ctx,i=[0,this.y,t,this.y];this.ctx.paint.drawLine(i,{borderColor:e,borderWidth:1})}draw(){this.renderRows.forEach(t=>{t.drawContainer()}),this.renderRows.forEach(t=>{t.drawCenter()}),this.drawFixedShadow(),this.renderRows.forEach(t=>{t.drawFixedContainer()}),this.renderRows.forEach(t=>{t.drawFixed()}),this.drawTopLine()}}class Oe{constructor(t){n(this,"isCut",!1);n(this,"isMultipleRow",!1);n(this,"ctx");this.ctx=t,this.init()}init(){this.ctx.on("setMoveFocus",t=>{this.moveFocus(t)}),this.ctx.on("mousemove",Z(t=>{this.ctx.selectorMove&&this.ctx.startAdjustPosition(t)},100)),this.ctx.on("cellHoverChange",t=>{if(!this.ctx.autofillMove){if(t.operation){this.selectRows(t,!1);return}this.isMultipleRow||this.mouseenter()}}),this.ctx.on("cellMousedown",(t,e)=>{if(!this.ctx.isTarget(e)||this.ctx.stageElement.style.cursor==="pointer"||this.ctx.isPointer||this.ctx.stageElement.style.cursor==="crosshair")return;if(t.operation){this.isMultipleRow=!0,this.selectRows(t);return}window.getComputedStyle(e.target).userSelect!=="text"&&e.preventDefault(),this.isMultipleRow=!1,this.click(e.shiftKey),this.ctx.emit("selectorClick",t)}),this.ctx.on("mouseup",()=>{this.ctx.selectorMove=!1,this.ctx.stopAdjustPosition();const t=setTimeout(()=>{this.ctx.adjustPositioning=!1,clearTimeout(t)},0)}),this.ctx.on("cellHeaderHoverChange",t=>{this.ctx.mousedown&&this.selectCols(t)}),this.ctx.on("cellHeaderMousedown",(t,e)=>{if(this.ctx.stageElement.style.cursor==="pointer"||this.ctx.isPointer)return;window.getComputedStyle(e.target).userSelect!=="text"&&e.preventDefault(),this.selectCols(t)}),this.ctx.on("keydown",t=>{if(!this.ctx.editing){if(t.ctrlKey&&t.code==="KeyV"||t.metaKey&&t.code==="KeyV"){this.paste();return}if(t.ctrlKey&&t.code==="KeyC"||t.metaKey&&t.code==="KeyC"){this.copy(),this.isCut=!1;return}if(t.ctrlKey&&t.code==="KeyX"||t.metaKey&&t.code==="KeyX"){this.isCut=!0,this.copy();return}if((t.ctrlKey&&t.code==="KeyA"||t.metaKey&&t.code==="KeyA")&&(t.preventDefault(),this.selectAll()),t.code==="ArrowLeft"||t.shiftKey&&t.code==="Tab"){t.preventDefault(),this.moveFocus("LEFT");return}if(t.code==="ArrowUp"){t.preventDefault(),this.moveFocus("TOP");return}if(t.code==="ArrowRight"||t.code==="Tab"){t.preventDefault(),this.moveFocus("RIGHT");return}if(t.code==="ArrowDown"){t.preventDefault(),this.moveFocus("BOTTOM");return}if(t.code==="Delete"||t.code==="Backspace"){t.preventDefault();const{xArr:e,yArr:i}=this.ctx.selector;this.clearSelectedData(e,i);return}}}),this.ctx.on("contextMenuClearSelected",()=>{const{xArr:t,yArr:e}=this.ctx.selector;this.clearSelectedData(t,e)}),this.ctx.on("contextMenuCopy",()=>{this.copy()}),this.ctx.on("contextMenuPaste",()=>{this.paste()}),this.ctx.on("contextMenuCut",()=>{this.isCut=!0,this.copy()}),this.ctx.on("setSelectorCell",t=>{this.ctx.setFocusCell(t),this.click()})}setSelector(t,e){const{ENABLE_SELECTOR_SPAN_COL:i,ENABLE_SELECTOR_SPAN_ROW:s}=this.ctx.config;let o=t,r=e;if(!s){const[a]=r;r=[a,a]}if(!i){const[a]=o;o=[a,a]}if(JSON.stringify(this.ctx.selector.xArr)!==JSON.stringify(o)||JSON.stringify(this.ctx.selector.yArr)!==JSON.stringify(r)){this.ctx.mousedown&&(this.ctx.selectorMove=!0),this.ctx.selector.enable=!0;const{SELECTOR_AREA_MIN_X:a,SELECTOR_AREA_MAX_X:l,SELECTOR_AREA_MIN_Y:h,SELECTOR_AREA_MAX_Y:d,SELECTOR_AREA_MAX_X_OFFSET:f,SELECTOR_AREA_MAX_Y_OFFSET:u}=this.ctx.config,x=a,w=l||this.ctx.maxColIndex-f,E=h,g=d||this.ctx.maxRowIndex-u;let[m,y]=o,[p,b]=r;if(m<x||y>w||p<E||b>g)return;if(this.ctx.stageElement.focus({preventScroll:!0}),this.ctx.config.ENABLE_MERGE_CELL_LINK){const R=this.adjustMergeCells(o,r);p=R.yArr[0],b=R.yArr[1],m=R.xArr[0],y=R.xArr[1],this.ctx.onlyMergeCell=R.onlyMergeCell}m===y&&p===b?this.ctx.selectOnlyOne=!0:this.ctx.selectOnlyOne=!1,o=[Math.max(x,m),Math.min(w,y)],r=[Math.max(E,p),Math.min(g,b)];const{BEFORE_SET_SELECTOR_METHOD:C}=this.ctx.config;if(typeof C=="function"){const _=C({focusCell:this.ctx.focusCell,xArr:o,yArr:r});if(!_)return;o=_.xArr,r=_.yArr}this.ctx.selector.xArr=o,this.ctx.selector.yArr=r,b===this.ctx.maxRowIndex&&p===0?this.ctx.selectColsIng=!0:this.ctx.selectColsIng=!1,y===this.ctx.maxColIndex&&m===0?this.ctx.selectRowsIng=!0:this.ctx.selectRowsIng=!1,this.ctx.emit("setSelector",this.ctx.selector),this.ctx.emit("drawView")}}adjustMergeCells(t,e){var w;const[i,s]=e,[o,r]=t;if(s===this.ctx.maxRowIndex&&i===0||r===this.ctx.maxColIndex&&o===0)return{xArr:t,yArr:e,onlyMergeCell:!1};let a=[],l=[];for(let E=0;E<=e[1]-e[0];E++)for(let g=0;g<=t[1]-t[0];g++){const m=E+e[0],y=g+t[0],p=this.ctx.database.getVirtualBodyCell(m,y);p&&((m===i||m===s)&&a.push(p),(y===o||y===r)&&l.push(p))}const h=a.reduce((E,g)=>{const{yArr:m}=g.getSpanInfo(),[y,p]=m;return E.minY=Math.min(E.minY,y),E.maxY=Math.max(E.maxY,p),E},{minY:i,maxY:s}),d=l.reduce((E,g)=>{const{xArr:m}=g.getSpanInfo(),[y,p]=m;return E.minX=Math.min(E.minX,y),E.maxX=Math.max(E.maxX,p),E},{minX:o,maxX:r}),f=[d.minX,d.maxX],u=[h.minY,h.maxY];let x=!1;if(d.minX!==d.maxX||h.minY!==h.maxY){const E=JSON.stringify(f)+JSON.stringify(u),g=(w=this.ctx.focusCell)==null?void 0:w.getSpanInfo();x=(g&&JSON.stringify(g.xArr)+JSON.stringify(g.yArr))===E}return{xArr:f,yArr:u,onlyMergeCell:x}}selectCols(t){if(this.ctx.config.ENABLE_SELECTOR_SINGLE||!this.ctx.config.ENABLE_SELECTOR_ALL_ROWS||this.ctx.autofillMove||this.ctx.columnResizing||this.ctx.editing)return;if(t.operation){this.selectAll();return}const{SELECTOR_AREA_MIN_Y:e,SELECTOR_AREA_MAX_Y:i,SELECTOR_AREA_MAX_Y_OFFSET:s}=this.ctx.config,o=e,r=i||this.ctx.maxRowIndex-s;if(this.ctx.mousedown&&this.ctx.focusCellHeader){const{colIndex:a}=this.ctx.focusCellHeader;if(this.ctx.clearSelector(),t.colIndex>=a){const l=[a,t.colIndex+t.colspan-1],h=[o,r];this.setSelector(l,h)}else{const l=[t.colIndex,a],h=[o,r];this.setSelector(l,h)}}else{const a=[t.colIndex,t.colIndex+t.colspan-1],l=[o,r];this.setSelector(a,l)}}selectAll(){if(this.ctx.autofillMove||this.ctx.editing)return;const{ENABLE_SELECTOR_ALL_ROWS:t,ENABLE_SELECTOR_ALL_COLS:e}=this.ctx.config;if(t&&e){const{SELECTOR_AREA_MIN_X:i,SELECTOR_AREA_MAX_X:s,SELECTOR_AREA_MIN_Y:o,SELECTOR_AREA_MAX_Y:r,SELECTOR_AREA_MAX_X_OFFSET:a,SELECTOR_AREA_MAX_Y_OFFSET:l}=this.ctx.config,h=i,d=s||this.ctx.maxColIndex-a,f=o,u=r||this.ctx.maxRowIndex-l,x=[h,d],w=[f,u];this.setSelector(x,w)}}selectRows(t,e=!0){if(this.ctx.config.ENABLE_SELECTOR_SINGLE||!this.ctx.config.ENABLE_SELECTOR_ALL_COLS||this.ctx.autofillMove||this.ctx.editing)return;const{SELECTOR_AREA_MIN_X:i,SELECTOR_AREA_MAX_X:s,SELECTOR_AREA_MAX_X_OFFSET:o}=this.ctx.config,r=s||this.ctx.maxColIndex-o,a=i;if(e){this.ctx.setFocusCell(t);const l=[a,r],h=[t.rowIndex,t.rowIndex];this.setSelector(l,h)}if(this.ctx.focusCell&&this.ctx.mousedown){const{rowIndex:l}=this.ctx.focusCell;if(t.rowIndex>=l){const h=[a,r],d=[l,t.rowIndex];this.setSelector(h,d)}else{const h=[a,r],d=[t.rowIndex,l];this.setSelector(h,d)}}}mouseenter(){if(this.ctx.config.ENABLE_SELECTOR_SINGLE||this.ctx.editing)return;const{mousedown:t,focusCell:e,hoverCell:i}=this.ctx;if(t&&e&&i){const{rowIndex:s,colIndex:o}=e,r=Math.min(i.colIndex,o),a=Math.max(i.colIndex,o),l=Math.min(i.rowIndex,s),h=Math.max(i.rowIndex,s),d=[r,a],f=[l,h];this.setSelector(d,f)}}click(t=!1){const{focusCell:e,clickCell:i}=this.ctx;if(e&&this.isInSettingRange(e.rowIndex,e.colIndex))if(this.ctx.selector.enable=!0,i&&t){if(this.ctx.config.ENABLE_SELECTOR_SINGLE)return;const{colIndex:s,rowIndex:o}=i,{colIndex:r,rowIndex:a}=e,l=Math.min(r,s),h=Math.max(r,s),d=Math.min(a,o),f=Math.max(a,o),u=[l,h],x=[d,f];this.setSelector(u,x)}else{this.ctx.emit("cellSelectedClick",e);const s=[e.colIndex,e.colIndex],o=[e.rowIndex,e.rowIndex];this.setSelector(s,o),this.adjustBoundaryPosition()}}clearCopyLine(){this.ctx.selector.xArrCopy=[-1,-1],this.ctx.selector.yArrCopy=[-1,-1]}getCell(t,e){const i=this.ctx.body.renderRows.find(o=>o.rowIndex===t);return i==null?void 0:i.cells.find(o=>o.colIndex===e)}copy(){if(!this.ctx.config.ENABLE_COPY||this.ctx.domSelectionStr)return;let{value:t,xArr:e,yArr:i}=this.ctx.getSelectedData();if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.database.hasMergeCell(e,i))if(this.ctx.onlyMergeCell&&this.ctx.focusCell){const r=this.ctx.focusCell;t=[[r.getValue()]],e=[r.colIndex,r.colIndex],i=[r.rowIndex,r.rowIndex]}else{const r={code:"ERR_MERGED_CELLS_COPY",message:"Merged cells cannot span copy data"};this.ctx.hasEvent("error")?this.ctx.emit("error",r):alert(r.message);return}const{BEFORE_COPY_METHOD:s}=this.ctx.config;if(typeof s=="function"){const a=s({focusCell:this.ctx.focusCell,data:t,xArr:e,yArr:i});if(!a)return;t=a.data}const o=ce(t);navigator.clipboard?navigator.clipboard.writeText(o).then(()=>{this.ctx.selector.xArrCopy=this.ctx.selector.xArr.slice(),this.ctx.selector.yArrCopy=this.ctx.selector.yArr.slice(),this.ctx.emit("copyChange",{xArr:this.ctx.selector.xArrCopy,yArr:this.ctx.selector.yArrCopy,data:t}),this.ctx.emit("draw")}).catch(r=>console.error("Copy Failure:",r)):console.error("current browser does not support the Clipboard API")}clearSelectedData(t,e,i=!1,s=null){let o=[];const r=new Set;for(let l=0;l<=e[1]-e[0];l++)for(let h=0;h<=t[1]-t[0];h++){const d=l+e[0],f=h+t[0],u=this.ctx.database.getItemValueForRowIndexAndColIndex(d,f);if(u){const{rowKey:x,key:w}=u;this.ctx.database.getReadonly(x,w)||(r.add(x),o.push({rowKey:x,key:w,value:s,row:{}}))}}if(!o.length)return[];if(i)return o;this.ctx.database.batchSetItemValue(o,!0);let a=[];return r.forEach(l=>{a.push(this.ctx.database.getRowDataItemForRowKey(l))}),this.ctx.emit("clearSelectedDataChange",o,a),o}paste(){if(!navigator.clipboard){console.error("current browser does not support the Clipboard API");return}const{ENABLE_PASTER:t}=this.ctx.config;if(this.ctx.selector.enable&&t){const e=this.ctx.selector.yArr[0],i=this.ctx.selector.xArr[0],s=new Set;navigator.clipboard.readText().then(async o=>{let r=he(o);const a=[i,i+r[0].length-1],l=[e,e+r.length-1],[h,d]=l,[f,u]=a,x=d-this.ctx.maxRowIndex,w=u-this.ctx.maxColIndex;(x>0||w>0)&&this.ctx.emit("onPastedDataOverflow",{maxY:d,maxX:u,minY:h,minX:f,overflowRowCount:x,overflowColCount:w,textArr:r});const E=r.length===1&&r[0].length===1;if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.database.hasMergeCell(a,l)&&!E){const p={code:"ERR_MERGED_CELLS_PASTE",message:"Merged cells cannot span paste data"};this.ctx.hasEvent("error")?this.ctx.emit("error",p):alert(p.message);return}let g=[];for(let p=0;p<=r.length-1;p++){const b=r[p].length;for(let C=0;C<=b-1;C++){const R=p+e,_=C+i,T=r[p][C],S=this.ctx.database.getItemValueForRowIndexAndColIndex(R,_);if(S){const{rowKey:I,key:v}=S;this.ctx.database.getReadonly(I,v)||(s.add(I),g.push({rowKey:I,key:v,value:T,row:{}}))}}}if(this.isCut){const p=this.clearSelectedData(this.ctx.selector.xArrCopy,this.ctx.selector.yArrCopy,!0),b=g.map(C=>`${C.rowKey}-${C.key}`);p.forEach(C=>{b.includes(`${C.rowKey}-${C.key}`)||g.unshift(C)}),this.isCut=!1}if(!g.length)return;const{BEFORE_PASTE_DATA_METHOD:m}=this.ctx.config;if(typeof m=="function"){const p=m,b=g.map(C=>({rowKey:C.rowKey,key:C.key,value:C.value,oldValue:this.ctx.database.getItemValue(C.rowKey,C.key),row:this.ctx.database.getRowDataItemForRowKey(C.rowKey)}));if(g=await p(b,a,l,r),g&&!g.length)return}this.clearCopyLine(),this.ctx.batchSetItemValueByEditor(g,!0);let y=[];s.forEach(p=>{y.push(this.ctx.database.getRowDataItemForRowKey(p))}),this.ctx.emit("pasteChange",g,y),this.ctx.emit("draw")}).catch(o=>{console.error("Failed to get the clipboard content:",o)})}}moveFocus(t){if(this.ctx.editing)return;const{focusCell:e}=this.ctx;if(!e)return;let{colIndex:i=0,rowIndex:s=0}=e;const o=0,r=0,a=this.ctx.maxColIndex,l=this.ctx.maxRowIndex;switch(t){case"LEFT":i>o&&i--;break;case"TOP":s>r&&s--;break;case"RIGHT":i<a&&i++;break;case"BOTTOM":s<l&&s++;break}const h=[i,i],d=[s,s],f=this.getCell(s,i);f&&(f.operation||this.isInSettingRange(f.rowIndex,f.colIndex)&&(this.ctx.setFocusCell(f),this.setSelector(h,d),this.adjustBoundaryPosition(),this.ctx.emit("moveFocus",f),this.ctx.emit("draw")))}isInSettingRange(t,e){const{SELECTOR_AREA_MIN_X:i,SELECTOR_AREA_MAX_X:s,SELECTOR_AREA_MIN_Y:o,SELECTOR_AREA_MAX_Y:r,SELECTOR_AREA_MAX_X_OFFSET:a,SELECTOR_AREA_MAX_Y_OFFSET:l}=this.ctx.config,h=i,d=s||this.ctx.maxColIndex-a,f=o,u=r||this.ctx.maxRowIndex-l;return!(e<h||e>d||t<f||t>u)}adjustBoundaryPosition(){const{stageHeight:t,stageWidth:e,focusCell:i,fixedRightWidth:s,fixedLeftWidth:o,header:r,footer:a,body:l,scrollX:h,scrollY:d,config:{SCROLLER_TRACK_SIZE:f,FOOTER_FIXED:u,FOOTER_POSITION:x,ENABLE_MERGE_CELL_LINK:w}}=this.ctx;if(!i)return;w&&this.ctx.onlyMergeCell&&i.updateSpanInfo();const{drawX:E,drawY:g,width:m,height:y,fixed:p}=i,b=o-E+1,C=i.drawX+m-(e-s)+1;let R=r.height-g,_=y;_>l.visibleHeight&&(_=l.visibleHeight);let T=0;u&&(x==="top"?R=r.height+a.height-g:T=a.visibleHeight);const S=g+_-(t-T-f);let I=h,v=d;C>0&&!p?I=Math.floor(h+C):b>0&&!p&&(I=Math.floor(h-b)),R>0?v=Math.floor(d-R):S>0&&(v=Math.floor(d+S)),(Math.abs(h-I)>2||Math.abs(d-v)>2)&&(this.ctx.adjustPositioning=!0,this.ctx.setScroll(I,v),this.ctx.emit("adjustBoundaryPosition",i))}destroy(){}}class Le{constructor(t){n(this,"ctx");n(this,"maxColRowCell");this.ctx=t,this.init()}init(){this.ctx.on("mousemove",t=>{if(this.ctx.stageElement.style.cursor==="crosshair"&&(this.ctx.stageElement.style.cursor="default"),this.ctx.editing||!this.ctx.focusCell||!this.maxColRowCell)return;const{offsetX:e,offsetY:i}=this.ctx.getOffset(t),{colIndex:s,rowIndex:o,drawX:r,drawY:a,width:l,height:h}=this.maxColRowCell,d=6,f=s===this.ctx.maxColIndex||o===this.ctx.maxRowIndex?0:2,u=r+l-d+f,x=a+h-d+f;e>u&&i>x&&e<u+d&&i<x+d&&(this.ctx.stageElement.style.cursor="crosshair"),this.ctx.autofillMove&&this.ctx.startAdjustPosition(t)}),this.ctx.on("cellMouseenter",t=>{const{xArr:e,yArr:i}=this.ctx.selector,s=e[1],o=i[1],{colIndex:r,rowIndex:a}=t;this.ctx.config.ENABLE_AUTOFILL&&r===s&&a===o&&(this.maxColRowCell=t),this.mouseenter(t)}),this.ctx.on("mousedown",()=>{this.ctx.stageElement.style.cursor==="crosshair"&&this.setMousedown()}),this.ctx.on("mouseup",()=>{this.setMouseUp(),this.ctx.stopAdjustPosition()})}isAutofillIng(){const{xArr:t,yArr:e}=this.ctx.selector;return!(JSON.stringify(this.ctx.autofill.xArr)===JSON.stringify(t)&&JSON.stringify(this.ctx.autofill.yArr)===JSON.stringify(e))}setMousedown(){this.ctx.autofill.enable=!0,this.ctx.autofillMove=!0}setMouseUp(){if(!this.ctx.autofill.enable)return;this.isAutofillIng()&&this.autofillData(),this.ctx.autofill.enable=!1,this.ctx.autofillMove=!1,this.ctx.autofill.xArr=[-1,-1],this.ctx.autofill.yArr=[-1,-1]}setAutofill(t,e){const{ENABLE_AUTOFILL:i,ENABLE_SELECTOR_SPAN_COL:s,ENABLE_SELECTOR_SPAN_ROW:o}=this.ctx.config;if(!i)return;let r=t,a=e;if(!o){const[l]=a;a=[l,l]}if(!s){const[l]=r;r=[l,l]}if(JSON.stringify(this.ctx.autofill.xArr)!==JSON.stringify(r)||JSON.stringify(this.ctx.autofill.yArr)!==JSON.stringify(a)){const{SELECTOR_AREA_MIN_X:l,SELECTOR_AREA_MAX_X:h,SELECTOR_AREA_MIN_Y:d,SELECTOR_AREA_MAX_Y:f,SELECTOR_AREA_MAX_X_OFFSET:u,SELECTOR_AREA_MAX_Y_OFFSET:x}=this.ctx.config,w=l,E=h||this.ctx.maxColIndex-u,g=d,m=f||this.ctx.maxRowIndex-x;let[y,p]=r,[b,C]=a;if(y<w||b<g)return;r=[Math.max(w,y),Math.min(E,p)],a=[Math.max(g,b),Math.min(m,C)];const{BEFORE_SET_AUTOFILL_METHOD:R}=this.ctx.config;if(typeof R=="function"){const T=R({focusCell:this.ctx.focusCell,xArr:r,yArr:a});if(!T)return;r=T.xArr,a=T.yArr}this.ctx.autofill.xArr=r,this.ctx.autofill.yArr=a,this.ctx.emit("setAutofill",this.ctx.autofill),this.ctx.emit("draw")}}async autofillData(){const t=new Set,e=this.ctx.getSelectedData(),i=new Map;for(let x=0;x<=e.yArr[1]-e.yArr[0];x++)for(let w=0;w<=e.xArr[1]-e.xArr[0];w++){const E=x+e.yArr[0],g=w+e.xArr[0];i.set(`${E}-${g}`,!0)}const{value:s}=e,o=s[0].length,r=s.length,a=this.ctx.autofill.xArr,l=this.ctx.autofill.yArr,h=o===1&&r===1;if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.database.hasMergeCell(a,l)&&!h){const x={code:"ERR_MERGED_CELLS_AUTOFILL",message:"Merged cells cannot span autofill data"};this.ctx.hasEvent("error")?this.ctx.emit("error",x):alert(x.message);return}let d=[];for(let x=0;x<=l[1]-l[0];x++)for(let w=0;w<=a[1]-a[0];w++){const E=w+a[0],g=x+l[0],m=s[x%r][w%o],y=this.ctx.database.getItemValueForRowIndexAndColIndex(g,E),p=`${g}-${E}`;if(y&&!i.has(p)){const{rowKey:b,key:C}=y;this.ctx.database.getReadonly(b,C)||(t.add(b),d.push({rowKey:b,key:C,value:m,row:{}}))}}if(!d.length)return;this.ctx.selector.xArr=this.ctx.autofill.xArr,this.ctx.selector.yArr=this.ctx.autofill.yArr;const{BEFORE_AUTOFILL_DATA_METHOD:f}=this.ctx.config;if(typeof f=="function"){const x=f,w=d.map(E=>({rowKey:E.rowKey,key:E.key,value:E.value,oldValue:this.ctx.database.getItemValue(E.rowKey,E.key),row:this.ctx.database.getRowDataItemForRowKey(E.rowKey)}));if(d=await x(w,a,l),d&&!d.length)return}this.ctx.batchSetItemValueByEditor(d,!0);let u=[];t.forEach(x=>{u.push(this.ctx.database.getRowDataItemForRowKey(x))}),this.ctx.emit("autofillChange",d,u),this.ctx.emit("draw")}mouseenter(t){if(["index","selection","index-selection"].includes(t.type))return;const{selector:e,autofill:i}=this.ctx;if(this.ctx.mousedown&&e.enable&&i.enable){const{rowIndex:s,colIndex:o}=t,r=e.xArr.slice(),a=e.yArr.slice();s>=e.yArr[0]&&s<=e.yArr[1]?o>e.xArr[1]?r.splice(1,1,o):o<e.xArr[0]&&r.splice(0,1,o):s>e.yArr[1]?a.splice(1,1,s):s<e.yArr[0]&&a.splice(0,1,s),this.setAutofill(r,a)}}destroy(){}}const q=Math.min,$=Math.max,st=Math.round,B=c=>({x:c,y:c}),Ae={left:"right",right:"left",bottom:"top",top:"bottom"},Me={start:"end",end:"start"};function dt(c,t,e){return $(c,q(t,e))}function Q(c,t){return typeof c=="function"?c(t):c}function z(c){return c.split("-")[0]}function tt(c){return c.split("-")[1]}function Wt(c){return c==="x"?"y":"x"}function wt(c){return c==="y"?"height":"width"}const He=new Set(["top","bottom"]);function V(c){return He.has(z(c))?"y":"x"}function Et(c){return Wt(V(c))}function De(c,t,e){e===void 0&&(e=!1);const i=tt(c),s=Et(c),o=wt(s);let r=s==="x"?i===(e?"end":"start")?"right":"left":i==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(r=ot(r)),[r,ot(r)]}function Ne(c){const t=ot(c);return[ft(c),t,ft(t)]}function ft(c){return c.replace(/start|end/g,t=>Me[t])}const Tt=["left","right"],Ot=["right","left"],ke=["top","bottom"],Xe=["bottom","top"];function Ye(c,t,e){switch(c){case"top":case"bottom":return e?t?Ot:Tt:t?Tt:Ot;case"left":case"right":return t?ke:Xe;default:return[]}}function Be(c,t,e,i){const s=tt(c);let o=Ye(z(c),e==="start",i);return s&&(o=o.map(r=>r+"-"+s),t&&(o=o.concat(o.map(ft)))),o}function ot(c){return c.replace(/left|right|bottom|top/g,t=>Ae[t])}function Ke(c){return{top:0,right:0,bottom:0,left:0,...c}}function Ft(c){return typeof c!="number"?Ke(c):{top:c,right:c,bottom:c,left:c}}function rt(c){const{x:t,y:e,width:i,height:s}=c;return{width:i,height:s,top:e,left:t,right:t+i,bottom:e+s,x:t,y:e}}function Lt(c,t,e){let{reference:i,floating:s}=c;const o=V(t),r=Et(t),a=wt(r),l=z(t),h=o==="y",d=i.x+i.width/2-s.width/2,f=i.y+i.height/2-s.height/2,u=i[a]/2-s[a]/2;let x;switch(l){case"top":x={x:d,y:i.y-s.height};break;case"bottom":x={x:d,y:i.y+i.height};break;case"right":x={x:i.x+i.width,y:f};break;case"left":x={x:i.x-s.width,y:f};break;default:x={x:i.x,y:i.y}}switch(tt(t)){case"start":x[r]-=u*(e&&h?-1:1);break;case"end":x[r]+=u*(e&&h?-1:1);break}return x}const We=async(c,t,e)=>{const{placement:i="bottom",strategy:s="absolute",middleware:o=[],platform:r}=e,a=o.filter(Boolean),l=await(r.isRTL==null?void 0:r.isRTL(t));let h=await r.getElementRects({reference:c,floating:t,strategy:s}),{x:d,y:f}=Lt(h,i,l),u=i,x={},w=0;for(let E=0;E<a.length;E++){const{name:g,fn:m}=a[E],{x:y,y:p,data:b,reset:C}=await m({x:d,y:f,initialPlacement:i,placement:u,strategy:s,middlewareData:x,rects:h,platform:r,elements:{reference:c,floating:t}});d=y??d,f=p??f,x={...x,[g]:{...x[g],...b}},C&&w<=50&&(w++,typeof C=="object"&&(C.placement&&(u=C.placement),C.rects&&(h=C.rects===!0?await r.getElementRects({reference:c,floating:t,strategy:s}):C.rects),{x:d,y:f}=Lt(h,u,l)),E=-1)}return{x:d,y:f,placement:u,strategy:s,middlewareData:x}};async function Vt(c,t){var e;t===void 0&&(t={});const{x:i,y:s,platform:o,rects:r,elements:a,strategy:l}=c,{boundary:h="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:u=!1,padding:x=0}=Q(t,c),w=Ft(x),g=a[u?f==="floating"?"reference":"floating":f],m=rt(await o.getClippingRect({element:(e=await(o.isElement==null?void 0:o.isElement(g)))==null||e?g:g.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(a.floating)),boundary:h,rootBoundary:d,strategy:l})),y=f==="floating"?{x:i,y:s,width:r.floating.width,height:r.floating.height}:r.reference,p=await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),b=await(o.isElement==null?void 0:o.isElement(p))?await(o.getScale==null?void 0:o.getScale(p))||{x:1,y:1}:{x:1,y:1},C=rt(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:y,offsetParent:p,strategy:l}):y);return{top:(m.top-C.top+w.top)/b.y,bottom:(C.bottom-m.bottom+w.bottom)/b.y,left:(m.left-C.left+w.left)/b.x,right:(C.right-m.right+w.right)/b.x}}const Fe=c=>({name:"arrow",options:c,async fn(t){const{x:e,y:i,placement:s,rects:o,platform:r,elements:a,middlewareData:l}=t,{element:h,padding:d=0}=Q(c,t)||{};if(h==null)return{};const f=Ft(d),u={x:e,y:i},x=Et(s),w=wt(x),E=await r.getDimensions(h),g=x==="y",m=g?"top":"left",y=g?"bottom":"right",p=g?"clientHeight":"clientWidth",b=o.reference[w]+o.reference[x]-u[x]-o.floating[w],C=u[x]-o.reference[x],R=await(r.getOffsetParent==null?void 0:r.getOffsetParent(h));let _=R?R[p]:0;(!_||!await(r.isElement==null?void 0:r.isElement(R)))&&(_=a.floating[p]||o.floating[w]);const T=b/2-C/2,S=_/2-E[w]/2-1,I=q(f[m],S),v=q(f[y],S),O=I,A=_-E[w]-v,L=_/2-E[w]/2+T,M=dt(O,L,A),D=!l.arrow&&tt(s)!=null&&L!==M&&o.reference[w]/2-(L<O?I:v)-E[w]/2<0,H=D?L<O?L-O:L-A:0;return{[x]:u[x]+H,data:{[x]:M,centerOffset:L-M-H,...D&&{alignmentOffset:H}},reset:D}}}),Ve=function(c){return c===void 0&&(c={}),{name:"flip",options:c,async fn(t){var e,i;const{placement:s,middlewareData:o,rects:r,initialPlacement:a,platform:l,elements:h}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:u,fallbackStrategy:x="bestFit",fallbackAxisSideDirection:w="none",flipAlignment:E=!0,...g}=Q(c,t);if((e=o.arrow)!=null&&e.alignmentOffset)return{};const m=z(s),y=V(a),p=z(a)===a,b=await(l.isRTL==null?void 0:l.isRTL(h.floating)),C=u||(p||!E?[ot(a)]:Ne(a)),R=w!=="none";!u&&R&&C.push(...Be(a,E,w,b));const _=[a,...C],T=await Vt(t,g),S=[];let I=((i=o.flip)==null?void 0:i.overflows)||[];if(d&&S.push(T[m]),f){const L=De(s,r,b);S.push(T[L[0]],T[L[1]])}if(I=[...I,{placement:s,overflows:S}],!S.every(L=>L<=0)){var v,O;const L=(((v=o.flip)==null?void 0:v.index)||0)+1,M=_[L];if(M&&(!(f==="alignment"?y!==V(M):!1)||I.every(k=>V(k.placement)===y?k.overflows[0]>0:!0)))return{data:{index:L,overflows:I},reset:{placement:M}};let D=(O=I.filter(H=>H.overflows[0]<=0).sort((H,k)=>H.overflows[1]-k.overflows[1])[0])==null?void 0:O.placement;if(!D)switch(x){case"bestFit":{var A;const H=(A=I.filter(k=>{if(R){const F=V(k.placement);return F===y||F==="y"}return!0}).map(k=>[k.placement,k.overflows.filter(F=>F>0).reduce((F,se)=>F+se,0)]).sort((k,F)=>k[1]-F[1])[0])==null?void 0:A[0];H&&(D=H);break}case"initialPlacement":D=a;break}if(s!==D)return{reset:{placement:D}}}return{}}}},Pe=new Set(["left","top"]);async function ze(c,t){const{placement:e,platform:i,elements:s}=c,o=await(i.isRTL==null?void 0:i.isRTL(s.floating)),r=z(e),a=tt(e),l=V(e)==="y",h=Pe.has(r)?-1:1,d=o&&l?-1:1,f=Q(t,c);let{mainAxis:u,crossAxis:x,alignmentAxis:w}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof w=="number"&&(x=a==="end"?w*-1:w),l?{x:x*d,y:u*h}:{x:u*h,y:x*d}}const $e=function(c){return c===void 0&&(c=0),{name:"offset",options:c,async fn(t){var e,i;const{x:s,y:o,placement:r,middlewareData:a}=t,l=await ze(t,c);return r===((e=a.offset)==null?void 0:e.placement)&&(i=a.arrow)!=null&&i.alignmentOffset?{}:{x:s+l.x,y:o+l.y,data:{...l,placement:r}}}}},Ge=function(c){return c===void 0&&(c={}),{name:"shift",options:c,async fn(t){const{x:e,y:i,placement:s}=t,{mainAxis:o=!0,crossAxis:r=!1,limiter:a={fn:g=>{let{x:m,y}=g;return{x:m,y}}},...l}=Q(c,t),h={x:e,y:i},d=await Vt(t,l),f=V(z(s)),u=Wt(f);let x=h[u],w=h[f];if(o){const g=u==="y"?"top":"left",m=u==="y"?"bottom":"right",y=x+d[g],p=x-d[m];x=dt(y,x,p)}if(r){const g=f==="y"?"top":"left",m=f==="y"?"bottom":"right",y=w+d[g],p=w-d[m];w=dt(y,w,p)}const E=a.fn({...t,[u]:x,[f]:w});return{...E,data:{x:E.x-e,y:E.y-i,enabled:{[u]:o,[f]:r}}}}}};function nt(){return typeof window<"u"}function j(c){return Pt(c)?(c.nodeName||"").toLowerCase():"#document"}function N(c){var t;return(c==null||(t=c.ownerDocument)==null?void 0:t.defaultView)||window}function W(c){var t;return(t=(Pt(c)?c.ownerDocument:c.document)||window.document)==null?void 0:t.documentElement}function Pt(c){return nt()?c instanceof Node||c instanceof N(c).Node:!1}function X(c){return nt()?c instanceof Element||c instanceof N(c).Element:!1}function K(c){return nt()?c instanceof HTMLElement||c instanceof N(c).HTMLElement:!1}function At(c){return!nt()||typeof ShadowRoot>"u"?!1:c instanceof ShadowRoot||c instanceof N(c).ShadowRoot}const Ue=new Set(["inline","contents"]);function et(c){const{overflow:t,overflowX:e,overflowY:i,display:s}=Y(c);return/auto|scroll|overlay|hidden|clip/.test(t+i+e)&&!Ue.has(s)}const je=new Set(["table","td","th"]);function Ze(c){return je.has(j(c))}const qe=[":popover-open",":modal"];function at(c){return qe.some(t=>{try{return c.matches(t)}catch{return!1}})}const Je=["transform","translate","scale","rotate","perspective"],Qe=["transform","translate","scale","rotate","perspective","filter"],ti=["paint","layout","strict","content"];function mt(c){const t=pt(),e=X(c)?Y(c):c;return Je.some(i=>e[i]?e[i]!=="none":!1)||(e.containerType?e.containerType!=="normal":!1)||!t&&(e.backdropFilter?e.backdropFilter!=="none":!1)||!t&&(e.filter?e.filter!=="none":!1)||Qe.some(i=>(e.willChange||"").includes(i))||ti.some(i=>(e.contain||"").includes(i))}function ei(c){let t=P(c);for(;K(t)&&!U(t);){if(mt(t))return t;if(at(t))return null;t=P(t)}return null}function pt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const ii=new Set(["html","body","#document"]);function U(c){return ii.has(j(c))}function Y(c){return N(c).getComputedStyle(c)}function lt(c){return X(c)?{scrollLeft:c.scrollLeft,scrollTop:c.scrollTop}:{scrollLeft:c.scrollX,scrollTop:c.scrollY}}function P(c){if(j(c)==="html")return c;const t=c.assignedSlot||c.parentNode||At(c)&&c.host||W(c);return At(t)?t.host:t}function zt(c){const t=P(c);return U(t)?c.ownerDocument?c.ownerDocument.body:c.body:K(t)&&et(t)?t:zt(t)}function $t(c,t,e){var i;t===void 0&&(t=[]);const s=zt(c),o=s===((i=c.ownerDocument)==null?void 0:i.body),r=N(s);return o?(xt(r),t.concat(r,r.visualViewport||[],et(s)?s:[],[])):t.concat(s,$t(s,[]))}function xt(c){return c.parent&&Object.getPrototypeOf(c.parent)?c.frameElement:null}function Gt(c){const t=Y(c);let e=parseFloat(t.width)||0,i=parseFloat(t.height)||0;const s=K(c),o=s?c.offsetWidth:e,r=s?c.offsetHeight:i,a=st(e)!==o||st(i)!==r;return a&&(e=o,i=r),{width:e,height:i,$:a}}function Ut(c){return X(c)?c:c.contextElement}function G(c){const t=Ut(c);if(!K(t))return B(1);const e=t.getBoundingClientRect(),{width:i,height:s,$:o}=Gt(t);let r=(o?st(e.width):e.width)/i,a=(o?st(e.height):e.height)/s;return(!r||!Number.isFinite(r))&&(r=1),(!a||!Number.isFinite(a))&&(a=1),{x:r,y:a}}const si=B(0);function jt(c){const t=N(c);return!pt()||!t.visualViewport?si:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function oi(c,t,e){return t===void 0&&(t=!1),!e||t&&e!==N(c)?!1:t}function J(c,t,e,i){t===void 0&&(t=!1),e===void 0&&(e=!1);const s=c.getBoundingClientRect(),o=Ut(c);let r=B(1);t&&(i?X(i)&&(r=G(i)):r=G(c));const a=oi(o,e,i)?jt(o):B(0);let l=(s.left+a.x)/r.x,h=(s.top+a.y)/r.y,d=s.width/r.x,f=s.height/r.y;if(o){const u=N(o),x=i&&X(i)?N(i):i;let w=u,E=xt(w);for(;E&&i&&x!==w;){const g=G(E),m=E.getBoundingClientRect(),y=Y(E),p=m.left+(E.clientLeft+parseFloat(y.paddingLeft))*g.x,b=m.top+(E.clientTop+parseFloat(y.paddingTop))*g.y;l*=g.x,h*=g.y,d*=g.x,f*=g.y,l+=p,h+=b,w=N(E),E=xt(w)}}return rt({width:d,height:f,x:l,y:h})}function yt(c,t){const e=lt(c).scrollLeft;return t?t.left+e:J(W(c)).left+e}function Zt(c,t,e){e===void 0&&(e=!1);const i=c.getBoundingClientRect(),s=i.left+t.scrollLeft-(e?0:yt(c,i)),o=i.top+t.scrollTop;return{x:s,y:o}}function ri(c){let{elements:t,rect:e,offsetParent:i,strategy:s}=c;const o=s==="fixed",r=W(i),a=t?at(t.floating):!1;if(i===r||a&&o)return e;let l={scrollLeft:0,scrollTop:0},h=B(1);const d=B(0),f=K(i);if((f||!f&&!o)&&((j(i)!=="body"||et(r))&&(l=lt(i)),K(i))){const x=J(i);h=G(i),d.x=x.x+i.clientLeft,d.y=x.y+i.clientTop}const u=r&&!f&&!o?Zt(r,l,!0):B(0);return{width:e.width*h.x,height:e.height*h.y,x:e.x*h.x-l.scrollLeft*h.x+d.x+u.x,y:e.y*h.y-l.scrollTop*h.y+d.y+u.y}}function ni(c){return Array.from(c.getClientRects())}function ai(c){const t=W(c),e=lt(c),i=c.ownerDocument.body,s=$(t.scrollWidth,t.clientWidth,i.scrollWidth,i.clientWidth),o=$(t.scrollHeight,t.clientHeight,i.scrollHeight,i.clientHeight);let r=-e.scrollLeft+yt(c);const a=-e.scrollTop;return Y(i).direction==="rtl"&&(r+=$(t.clientWidth,i.clientWidth)-s),{width:s,height:o,x:r,y:a}}function li(c,t){const e=N(c),i=W(c),s=e.visualViewport;let o=i.clientWidth,r=i.clientHeight,a=0,l=0;if(s){o=s.width,r=s.height;const h=pt();(!h||h&&t==="fixed")&&(a=s.offsetLeft,l=s.offsetTop)}return{width:o,height:r,x:a,y:l}}const hi=new Set(["absolute","fixed"]);function ci(c,t){const e=J(c,!0,t==="fixed"),i=e.top+c.clientTop,s=e.left+c.clientLeft,o=K(c)?G(c):B(1),r=c.clientWidth*o.x,a=c.clientHeight*o.y,l=s*o.x,h=i*o.y;return{width:r,height:a,x:l,y:h}}function Mt(c,t,e){let i;if(t==="viewport")i=li(c,e);else if(t==="document")i=ai(W(c));else if(X(t))i=ci(t,e);else{const s=jt(c);i={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return rt(i)}function qt(c,t){const e=P(c);return e===t||!X(e)||U(e)?!1:Y(e).position==="fixed"||qt(e,t)}function di(c,t){const e=t.get(c);if(e)return e;let i=$t(c,[]).filter(a=>X(a)&&j(a)!=="body"),s=null;const o=Y(c).position==="fixed";let r=o?P(c):c;for(;X(r)&&!U(r);){const a=Y(r),l=mt(r);!l&&a.position==="fixed"&&(s=null),(o?!l&&!s:!l&&a.position==="static"&&!!s&&hi.has(s.position)||et(r)&&!l&&qt(c,r))?i=i.filter(d=>d!==r):s=a,r=P(r)}return t.set(c,i),i}function fi(c){let{element:t,boundary:e,rootBoundary:i,strategy:s}=c;const r=[...e==="clippingAncestors"?at(t)?[]:di(t,this._c):[].concat(e),i],a=r[0],l=r.reduce((h,d)=>{const f=Mt(t,d,s);return h.top=$(f.top,h.top),h.right=q(f.right,h.right),h.bottom=q(f.bottom,h.bottom),h.left=$(f.left,h.left),h},Mt(t,a,s));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function xi(c){const{width:t,height:e}=Gt(c);return{width:t,height:e}}function ui(c,t,e){const i=K(t),s=W(t),o=e==="fixed",r=J(c,!0,o,t);let a={scrollLeft:0,scrollTop:0};const l=B(0);function h(){l.x=yt(s)}if(i||!i&&!o)if((j(t)!=="body"||et(s))&&(a=lt(t)),i){const x=J(t,!0,o,t);l.x=x.x+t.clientLeft,l.y=x.y+t.clientTop}else s&&h();o&&!i&&s&&h();const d=s&&!i&&!o?Zt(s,a):B(0),f=r.left+a.scrollLeft-l.x-d.x,u=r.top+a.scrollTop-l.y-d.y;return{x:f,y:u,width:r.width,height:r.height}}function ht(c){return Y(c).position==="static"}function Ht(c,t){if(!K(c)||Y(c).position==="fixed")return null;if(t)return t(c);let e=c.offsetParent;return W(c)===e&&(e=e.ownerDocument.body),e}function Jt(c,t){const e=N(c);if(at(c))return e;if(!K(c)){let s=P(c);for(;s&&!U(s);){if(X(s)&&!ht(s))return s;s=P(s)}return e}let i=Ht(c,t);for(;i&&Ze(i)&&ht(i);)i=Ht(i,t);return i&&U(i)&&ht(i)&&!mt(i)?e:i||ei(c)||e}const gi=async function(c){const t=this.getOffsetParent||Jt,e=this.getDimensions,i=await e(c.floating);return{reference:ui(c.reference,await t(c.floating),c.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function wi(c){return Y(c).direction==="rtl"}const Ei={convertOffsetParentRelativeRectToViewportRelativeRect:ri,getDocumentElement:W,getClippingRect:fi,getOffsetParent:Jt,getElementRects:gi,getClientRects:ni,getDimensions:xi,getScale:G,isElement:X,isRTL:wi},Qt=$e,te=Ge,ee=Ve,mi=Fe,ie=(c,t,e)=>{const i=new Map,s={platform:Ei,...e},o={...s.platform,_c:i};return We(c,t,{...s,platform:o})};let pi=class{constructor(t){n(this,"ctx");n(this,"enable",!1);n(this,"contentEl");n(this,"floatingEl");n(this,"arrowEl");this.ctx=t;const{TOOLTIP_BG_COLOR:e,TOOLTIP_TEXT_COLOR:i,TOOLTIP_ZINDEX:s,TOOLTIP_CUSTOM_STYLE:o,CSS_PREFIX:r}=this.ctx.config;this.contentEl=document.createElement("div"),this.arrowEl=document.createElement("div"),this.floatingEl=document.createElement("div"),this.floatingEl.className=`${r}-tooltip`,this.contentEl.className=`${r}-tooltip-content`,this.arrowEl.className=`${r}-tooltip-arrow`;const a={display:"none",position:"absolute",background:e,color:i,boxSizing:"border-box",zIndex:s,padding:"8px",borderRadius:"4px",fontSize:"12px",...o},l={position:"absolute",width:"10px",height:"10px",background:a.background,backgroundColor:a.backgroundColor,transform:"rotate(45deg)",zIndex:a.zIndex};Object.assign(this.arrowEl.style,l),Object.assign(this.floatingEl.style,a),this.floatingEl.appendChild(this.contentEl),this.floatingEl.appendChild(this.arrowEl),this.ctx.containerElement.appendChild(this.floatingEl),this.init()}init(){this.floatingEl.addEventListener("mouseleave",()=>{this.hide()}),this.ctx.on("mouseout",t=>{this.floatingEl.contains(t.relatedTarget)||this.hide()}),this.ctx.on("onScroll",()=>{this.hide()}),this.ctx.on("startEdit",()=>{this.hide()}),this.ctx.on("visibleCellHoverChange",(t,e)=>{this.floatingEl.contains(e.target)||(t.ellipsis||t.message)&&this.show(t)}),this.ctx.on("visibleCellMouseleave",(t,e)=>{this.floatingEl.contains(e.target)||this.hide()}),this.ctx.on("cellHeaderMouseleave",(t,e)=>{this.floatingEl.contains(e.target)||this.hide()}),this.ctx.on("cellHeaderHoverChange",(t,e)=>{this.floatingEl.contains(e.target)||t.ellipsis&&this.show(t)})}show(t){if(!t.overflowTooltipShow||this.ctx.mousedown)return;this.floatingEl.style.display="block";let e=t.getText();t.message&&(e=t.message);const i=this.ctx.containerElement.getBoundingClientRect();if(!i)return;this.enable=!0,this.contentEl.style.maxWidth=`${t.overflowTooltipMaxWidth||500}px`,this.contentEl.style.minWidth="100px",this.contentEl.style.width="100%",this.contentEl.style.display="inline-block",this.contentEl.style.wordBreak="break-all",this.contentEl.style.lineHeight="1.5",this.contentEl.innerText=e;const s=t.drawX+i.x,o=t.drawY+i.y;ie({getBoundingClientRect(){return{width:t.visibleWidth,height:t.visibleHeight,x:s,y:o,left:s,right:s+t.visibleWidth,top:o,bottom:o+t.visibleHeight}}},this.floatingEl,{placement:t.overflowTooltipPlacement,middleware:[te(),ee(),Qt(6),mi({element:this.arrowEl})]}).then(a=>{const{x:l,y:h,placement:d,middlewareData:f}=a;if(Object.assign(this.floatingEl.style,{top:`${h}px`,left:`${l}px`}),f.arrow){const u=f.arrow;["left","left-start","left-end"].includes(d)?Object.assign(this.arrowEl.style,{top:`${u.y}px`,bottom:"",left:"",right:"-5px"}):["right","right-start","right-end"].includes(d)?Object.assign(this.arrowEl.style,{top:`${u.y}px`,bottom:"",left:"-5px",right:""}):["bottom","bottom-start","bottom-end"].includes(d)?Object.assign(this.arrowEl.style,{top:"-5px",bottom:"",left:`${u.x}px`,right:""}):["top","top-start","top-end"].includes(d)&&Object.assign(this.arrowEl.style,{top:"",bottom:"-5px",left:`${u.x}px`,right:""})}})}hide(){this.enable&&(this.enable=!1,this.floatingEl.style.display="none")}destroy(){this.contentEl.remove(),this.arrowEl.remove(),this.floatingEl.remove()}};class yi{constructor(t){n(this,"editorEl");n(this,"inputEl");n(this,"enable",!1);n(this,"cellTarget",null);n(this,"selectorArrStr","");n(this,"ctx");n(this,"drawY",0);n(this,"drawX",0);n(this,"cancel",!1);this.ctx=t,this.initTextEditor(),this.init()}init(){this.ctx.on("outsideMousedown",()=>{this.cellTarget&&this.cellTarget.editorType==="text"&&this.clearEditor()}),this.ctx.on("moveFocus",t=>{this.cellTarget=t;const{xArr:e,yArr:i}=this.ctx.selector;this.selectorArrStr=JSON.stringify(e)+JSON.stringify(i)}),this.ctx.on("onScroll",()=>{this.enable&&this.doneEdit()}),this.ctx.on("cellHeaderMousedown",()=>{this.enable&&this.doneEdit(),this.cellTarget=null}),this.ctx.on("hoverIconClick",t=>{t.editorType!=="none"&&this.editCell(t.rowIndex,t.colIndex)}),this.ctx.on("keydown",t=>{if(!this.ctx.isTarget(t)||!this.ctx.focusCell)return;if(t.code==="Escape"&&this.ctx.editing){this.cancel=!0;const{focusCell:l}=this.ctx;l&&(this.ctx.emit("setSelectorCell",l),this.cellTarget=l),this.doneEdit();return}if((t.altKey||t.metaKey)&&t.code==="Enter"&&this.ctx.editing&&this.inputEl){t.preventDefault();const l=this.inputEl.selectionStart,h=this.inputEl.value.substring(0,l),d=this.inputEl.value.substring(l);this.inputEl.value=h+`
|
|
6
|
+
`+d,this.inputEl.selectionStart=this.inputEl.selectionEnd=l+1,this.autoSize();return}if(t.code==="Tab"&&this.ctx.editing){if(t.preventDefault(),this.doneEdit(),t.shiftKey){this.ctx.emit("setMoveFocus","LEFT");return}this.ctx.emit("setMoveFocus","RIGHT");return}if(t.code==="Enter"&&this.ctx.editing){if(t.preventDefault(),this.doneEdit(),t.shiftKey){this.ctx.emit("setMoveFocus","TOP");return}this.ctx.emit("setMoveFocus","BOTTOM");return}if(t.code==="Enter"&&!this.ctx.editing){t.preventDefault(),this.startEdit();return}const e=t.key,i=t.ctrlKey,s=t.altKey,o=t.shiftKey,r=t.metaKey;i||s||o||r||["Enter","Escape","Tab","Backspace","Delete","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown","Insert","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12"].includes(e)||this.startEdit(!0)}),this.ctx.on("cellMouseup",t=>{if(this.ctx.adjustPositioning||this.ctx.isPointer||!this.isInSelectorRange(t.rowIndex,t.colIndex))return;const{xArr:e,yArr:i}=this.ctx.selector,s=JSON.stringify(e)+JSON.stringify(i);if(this.selectorArrStr===s&&this.cellTarget){if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.onlyMergeCell){this.startEdit();return}if(this.ctx.selectOnlyOne&&t.rowKey===this.cellTarget.rowKey&&t.key===this.cellTarget.key){this.startEdit();return}}if(this.selectorArrStr=s,this.doneEdit(),this.cellTarget=t,this.ctx.config.ENABLE_EDIT_SINGLE_CLICK){if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.onlyMergeCell){this.startEdit();return}this.ctx.selectOnlyOne&&this.startEdit()}})}isInSelectorRange(t,e){const{xArr:i,yArr:s}=this.ctx.selector,[o,r]=i,[a,l]=s;return!(e<o||e>r||t<a||t>l)}initTextEditor(){this.inputEl=document.createElement("textarea"),this.inputEl.setAttribute("rows","1"),this.inputEl.addEventListener("input",this.autoSize.bind(this)),this.inputEl.addEventListener("blur",()=>{this.doneEdit()}),this.editorEl=this.ctx.editorElement,this.inputEl.className="e-virt-table-editor-textarea",this.editorEl.appendChild(this.inputEl),this.ctx.containerElement.appendChild(this.editorEl)}autoSize(){this.inputEl.style.height="auto";let t=this.inputEl.scrollHeight,e=this.ctx.body.visibleHeight;t>e&&(t=e);const{stageHeight:i,footer:s,header:o,config:{SCROLLER_TRACK_SIZE:r}}=this.ctx,a=i-s.height-r;this.editorEl.style.bottom="auto",this.drawY<o.height&&(this.editorEl.style.top=`${o.height-1}px`),this.drawY+t>a&&(this.editorEl.style.left=`${this.drawX-1}px`,this.editorEl.style.top="auto",this.editorEl.style.bottom=`${i-a}px`),this.inputEl.style.height=`${t}px`}startEditByInput(t,e=!1){const i=e?null:t.getValue(),{editorType:s}=t;t.update(),this.ctx.config.ENABLE_MERGE_CELL_LINK&&t.updateSpanInfo();let{height:o,width:r,drawY:a,drawX:l}=t;this.drawX=l,this.drawY=a;const{config:{CELL_PADDING:h},header:d}=this.ctx;let f=this.ctx.body.visibleHeight;if(o>f&&(o=f),this.editorEl.style.display="inline-block",this.editorEl.style.left=`${this.drawX-1}px`,this.editorEl.style.top=`${this.drawY-1}px`,this.editorEl.style.bottom="auto",this.editorEl.style.maxHeight=`${f}px`,s==="text"){this.inputEl.style.display="block",this.inputEl.style.minWidth=`${r-1}px`,this.inputEl.style.minHeight=`${o-1}px`,this.inputEl.style.maxHeight=`${f}px`,this.inputEl.style.width=`${r-1}px`,this.inputEl.style.height="auto",this.inputEl.style.padding=`${h}px`,i!==null&&(this.inputEl.value=i),this.inputEl.focus({preventScroll:!0});const u=this.inputEl.value.length;this.inputEl.setSelectionRange(u,u)}else this.inputEl.style.display="none";(this.inputEl.scrollHeight>o||this.drawY<d.height)&&this.autoSize()}doneEditByInput(){if(this.cellTarget&&this.cellTarget.editorType==="text"){const{rowKey:t,key:e}=this.cellTarget,i=this.cellTarget.getValue(),s=this.inputEl.value;s!==i&&!(s===""&&i===null)&&!this.cancel&&this.ctx.setItemValueByEditor(t,e,s,!0),this.inputEl.value=""}}startEdit(t=!1){this.cancel=!1;const{ENABLE_EDIT_CLICK_SELECTOR:e}=this.ctx.config;if(!e)return;const i=this.ctx.focusCell;if(!i||["index","index-selection","selection"].includes(i.type)||this.enable||!(i.isVerticalVisible()&&i.isHorizontalVisible()))return;const{rowKey:o,key:r,editorType:a}=i;if(a==="none")return;const l=this.ctx.database.getReadonly(o,r);i&&!l&&(this.enable=!0,this.ctx.editing=!0,this.cellTarget=i,this.startEditByInput(this.cellTarget,t),this.ctx.emit("startEdit",this.cellTarget))}editCell(t,e){const i=this.ctx.body.renderRows.find(h=>h.rowIndex===t);if(!i)return;const s=i.cells.find(h=>h.colIndex===e);if(!s)return;this.ctx.emit("setSelectorCell",s);const o=this.ctx.focusCell;if(!o||["index","index-selection","selection"].includes(o.type)||this.enable)return;const{rowKey:r,key:a}=o,l=this.ctx.database.getReadonly(r,a);o&&!l&&(this.enable=!0,this.ctx.editing=!0,this.cellTarget=o,this.startEditByInput(this.cellTarget),this.ctx.emit("startEdit",this.cellTarget))}doneEdit(){this.enable&&(this.doneEditByInput(),this.ctx.emit("doneEdit",this.cellTarget),this.enable=!1,this.ctx.editing=!1,this.ctx.containerElement.focus({preventScroll:!0}),this.editorEl.style.display="none",this.ctx.emit("draw"))}clearEditor(){this.doneEdit(),this.cellTarget=null,this.selectorArrStr="",this.ctx.clearSelector(),this.ctx.focusCell=void 0,this.ctx.emit("draw")}destroy(){var t;(t=this.editorEl)==null||t.remove()}}let Ci=class{constructor(t){n(this,"ctx");n(this,"emptyEl");this.ctx=t;const{EMPTY_TEXT:e,EMPTY_CUSTOM_STYLE:i}=this.ctx.config;this.ctx.emptyElement?this.emptyEl=this.ctx.emptyElement:(this.emptyEl=document.createElement("div"),this.emptyEl.innerText=e),this.emptyEl.className="e-virt-table-empty",this.emptyEl.style.display="none",this.ctx.containerElement.appendChild(this.emptyEl),this.ctx.on("emptyChange",({type:s,headerHeight:o,bodyHeight:r,footerHeight:a})=>{const l=o+(r+a)/2,h={display:s==="empty"?"block":"none",position:"absolute",fontSize:"14px",color:"#666",left:"50%",top:`${l}px`,transform:"translate(-50%, -50%)",...i};Object.assign(this.emptyEl.style,h)})}destroy(){this.emptyEl.remove()}};class bi{constructor(t){n(this,"ctx");n(this,"observer");this.ctx=t,this.observer=new MutationObserver(Z(()=>{const e=this.ctx.overlayerElement.querySelectorAll('[data-auto-height="true"]'),i=new Map;e.forEach(r=>{const a=Number(r.getAttribute("data-row-index")),l=Number(r.getAttribute("data-col-index"));if(isNaN(a)||isNaN(l)||!(r instanceof HTMLElement)||r.offsetWidth===0)return;const h=`${a}_${l}`;i.set(h,Math.round(r.offsetHeight))});const s=this.ctx.database.getOverlayerAutoHeightMap();if(!this.arerMapsEqual(s,i)){if(this.ctx.database.setOverlayerAutoHeightMap(i),s.size===0&&i.size===0)return;this.ctx.emit("draw")}},16.67)),this.observer.observe(this.ctx.overlayerElement,{childList:!0,subtree:!0,attributes:!0})}arerMapsEqual(t,e){if(t.size!==e.size)return!1;for(let[i,s]of t)if(!e.has(i)||e.get(i)!==s)return!1;return!0}draw(){const t=this.getContainer();this.ctx.emit("overlayerChange",t)}destroy(){this.observer&&this.observer.disconnect(),this.ctx.emit("overlayerChange",{style:{},views:[]})}getContainer(){const t=this.getHeader(),e=this.getBody(),i=this.getFooter();let s=[];const{FOOTER_FIXED:o,FOOTER_POSITION:r}=this.ctx.config;return o?r==="top"?s=[t,i,e]:s=[t,e,i]:s=[t,e],{views:s}}getHeader(){const{fixedLeftWidth:t,fixedRightWidth:e,config:{SCROLLER_TRACK_SIZE:i,CSS_PREFIX:s}}=this.ctx,{visibleWidth:o,visibleHeight:r,renderCellHeaders:a}=this.ctx.header;let l=[],h=[],d=[];a.forEach(g=>{g.render&&(g.fixed==="left"?h.push(g):g.fixed==="right"?d.push(g):l.push(g))});const f=e-i,u={key:"left",style:{position:"absolute",top:"0px",left:"0px",overflow:"hidden",width:`${t}px`,height:`${r}px`},cells:h},x={key:"center",style:{position:"absolute",top:"0px",left:`${t}px`,overflow:"hidden",width:`${o-t-f+1}px`,height:`${r}px`},cells:l},w={key:"right",style:{position:"absolute",top:"0px",right:"0px",overflow:"hidden",width:`${f+1}px`,height:`${r}px`},cells:d};return{type:"header",class:`${s}-overlayer-header`,style:{position:"relative",overflow:"hidden",width:`${o}px`,height:`${r}px`},views:[u,x,w]}}getBody(){const t=[],e=[],i=[];let s=this.ctx.body.renderRows;this.ctx.config.FOOTER_FIXED||(s=s.concat(this.ctx.footer.renderRows)),s.forEach(g=>{g.cells.forEach(m=>{m.cellType==="footer"&&(m.render=m.renderFooter),m.render&&(m.fixed==="left"?e.push(m):m.fixed==="right"?i.push(m):t.push(m))})});const{fixedLeftWidth:o,fixedRightWidth:r,config:{SCROLLER_TRACK_SIZE:a,CSS_PREFIX:l}}=this.ctx,{visibleWidth:h,visibleHeight:d}=this.ctx.body,f=r-a,u={key:"left",style:{position:"absolute",top:`${.5}px`,left:`${.5}px`,overflow:"hidden",width:`${o}px`,height:`${d}px`},cells:e},x={key:"center",style:{position:"absolute",top:`${.5}px`,left:`${o-.5}px`,overflow:"hidden",width:`${h-o-f}px`,height:`${d}px`},cells:t},w={key:"right",style:{position:"absolute",top:"0px",right:"0px",overflow:"hidden",width:`${f}px`,height:`${d}px`},cells:i};return{type:"body",class:`${l}-overlayer-body`,style:{position:"relative",overflow:"hidden",width:`${h}px`,height:`${d}px`},views:[u,x,w]}}getFooter(){const t=[],e=[],i=[];this.ctx.footer.renderRows.forEach(E=>{E.cells.forEach(g=>{g.cellType==="footer"&&g.renderFooter&&(g.render=g.renderFooter,g.fixed==="left"?e.push(g):g.fixed==="right"?i.push(g):t.push(g))})});const{fixedLeftWidth:s,fixedRightWidth:o,config:{SCROLLER_TRACK_SIZE:r,CSS_PREFIX:a}}=this.ctx,{visibleWidth:l,visibleHeight:h}=this.ctx.footer,d=o-r,f={key:"left",style:{position:"absolute",top:`${.5}px`,left:`${.5}px`,overflow:"hidden",width:`${s}px`,height:`${h}px`},cells:e},u={key:"center",style:{position:"absolute",top:`${.5}px`,left:`${s-.5}px`,overflow:"hidden",width:`${l-s-d}px`,height:`${h}px`},cells:t},x={key:"right",style:{position:"absolute",top:`${.5}px`,right:`${.5}px`,overflow:"hidden",width:`${d}px`,height:`${h}px`},cells:i};return{type:"footer",class:`${a}-overlayer-footer`,style:{position:"relative",overflow:"hidden",width:`${l}px`,height:`${h}px`},views:[f,u,x]}}}class Ii{constructor(t){n(this,"ctx");n(this,"contextMenuEl");n(this,"custom",!1);this.ctx=t,this.ctx.contextMenuElement?(this.custom=!0,this.contextMenuEl=this.ctx.contextMenuElement):(this.custom=!1,this.contextMenuEl=document.createElement("div")),this.createContextMenu(),this.init()}init(){this.ctx.on("cellContextMenuClick",(t,e)=>{if(!this.ctx.config.ENABLE_CONTEXT_MENU)return;e.preventDefault();const{xArr:i,yArr:s}=this.ctx.selector,[o,r]=i,[a,l]=s,{rowIndex:h,colIndex:d}=t;h>=a&&h<=l&&d>=o&&d<=r||this.ctx.emit("setSelectorCell",t,e);const u={getBoundingClientRect:()=>({width:0,height:0,top:e.clientY,left:e.clientX,right:e.clientX,bottom:e.clientY,x:e.clientX,y:e.clientY}),contextElement:document.body};ie(u,this.contextMenuEl,{placement:"right-start",middleware:[Qt(),te(),ee()]}).then(({x,y:w})=>{this.show(x,w)})}),this.ctx.on("click",this.hide.bind(this)),this.ctx.on("onScroll",this.hide.bind(this)),this.ctx.on("resize",this.hide.bind(this))}createContextMenu(){if(this.contextMenuEl.className="e-virt-table-context-menu",this.contextMenuEl.addEventListener("contextmenu",function(e){e.preventDefault()}),this.ctx.containerElement.appendChild(this.contextMenuEl),this.custom)return;const{CONTEXT_MENU:t}=this.ctx.config;this.createContextMenuItems(t,e=>{switch(e.value){case"copy":this.ctx.emit("contextMenuCopy");break;case"paste":this.ctx.emit("contextMenuPaste");break;case"cut":this.ctx.emit("contextMenuCut");break;case"clearSelected":this.ctx.emit("contextMenuClearSelected");break}this.hide()})}createContextMenuItems(t,e){this.contextMenuEl.replaceChildren(),t.forEach(i=>{const s=document.createElement("div");s.className="e-virt-table-context-menu-item",s.innerText=i.label,i.event?s.onclick=()=>{i.event&&i.event(),e(i)}:s.onclick=()=>e(i),this.contextMenuEl.appendChild(s)})}show(t,e){Object.assign(this.contextMenuEl.style,{left:`${t}px`,top:`${e}px`})}hide(){Object.assign(this.contextMenuEl.style,{left:"-99999px",top:"-99999px"})}updated(){this.createContextMenu()}destroy(){this.contextMenuEl.remove()}}class Ri{constructor(t){n(this,"ctx");n(this,"loadingEl");if(this.ctx=t,this.ctx.loadingElement)this.loadingEl=this.ctx.loadingElement;else{this.loadingEl=document.createElement("div");const e=document.createElement("div");e.className="e-virt-table-loading-spinner";const i=this.ctx.icons.getSvg("loading");if(i){const a=new DOMParser().parseFromString(i.svg,"image/svg+xml").documentElement;e.appendChild(a)}const s=document.createElement("p");s.className="e-virt-table-loading-text",s.innerText=this.ctx.config.LOADING_TEXT,e.appendChild(s),this.loadingEl.appendChild(e)}this.loadingEl.className="e-virt-table-loading",this.loadingEl.style.display="none",this.ctx.containerElement.appendChild(this.loadingEl)}show(){this.loadingEl.style.display="flex"}hide(){this.loadingEl.style.display="none"}destroy(){this.loadingEl.remove()}}class Si{constructor(t,e){n(this,"options");n(this,"scroller");n(this,"header");n(this,"body");n(this,"footer");n(this,"selector");n(this,"autofill");n(this,"tooltip");n(this,"editor");n(this,"empty");n(this,"overlayer");n(this,"contextMenu");n(this,"loading");n(this,"ctx");this.options=e;const{overlayerElement:i,editorElement:s,emptyElement:o,contextMenuElement:r}=this.options,a=this.createContainer(t,i,s,o,r);this.ctx=new Re(a,this.options),this.header=new _e(this.ctx),this.footer=new Te(this.ctx),this.body=new ve(this.ctx),this.scroller=new Se(this.ctx),this.selector=new Oe(this.ctx),this.autofill=new Le(this.ctx),this.tooltip=new pi(this.ctx),this.empty=new Ci(this.ctx),this.editor=new yi(this.ctx),this.overlayer=new bi(this.ctx),this.contextMenu=new Ii(this.ctx),this.loading=new Ri(this.ctx),this.ctx.on("draw",Z(()=>{this.draw()},()=>this.ctx.drawTime)),this.ctx.on("drawView",Z(()=>{this.draw(!0)},()=>this.ctx.drawTime)),this.draw()}createContainer(t,e,i,s,o){t.className="e-virt-table-container";const r=document.createElement("div"),a=document.createElement("canvas"),l=e||document.createElement("div");r.className="e-virt-table-stage",t.tabIndex=0,a.className="e-virt-table-canvas",l.className="e-virt-table-overlayer";const h=i||document.createElement("div");h.className="e-virt-table-editor";const d=s,f=o;return r.appendChild(a),r.appendChild(l),t.appendChild(r),{containerElement:t,stageElement:r,canvasElement:a,overlayerElement:l,editorElement:h,emptyElement:d,contextMenuElement:f}}draw(t=!1){requestAnimationFrame(()=>{const e=performance.now();this.header.update(),this.footer.update(),this.body.update(),this.ctx.paint.clear(),this.body.draw(),this.footer.draw(),this.header.draw(),this.scroller.draw(),t||this.overlayer.draw(),requestAnimationFrame(()=>{this.body.updateAutoHeight()});const i=performance.now(),s=Math.round(i-e);this.ctx.drawTime=s*this.ctx.config.DRAW_TIME_MULTIPLIER})}loadConfig(t){this.ctx.config.init(t),this.ctx.database.init(!1),this.header.init(),this.contextMenu.updated(),this.ctx.emit("draw")}loadColumns(t){this.editor.doneEdit(),this.ctx.database.setColumns(t),this.header.init(),this.ctx.emit("draw")}loadData(t){this.editor.doneEdit(),this.ctx.database.setData(t),this.header.init(),this.tooltip.hide(),this.ctx.emit("draw")}loadFooterData(t){this.ctx.database.setFooterData(t),this.ctx.emit("draw")}setLoading(t){this.ctx.loading=t,t?this.loading.show():this.loading.hide()}on(t,e){this.ctx.on(t,e)}emit(t,...e){this.ctx.emit(t,...e)}off(t,e){this.ctx.off(t,e)}filterMethod(t){this.ctx.database.setFilterMethod(t),this.ctx.database.init(!1),this.header.init(),this.ctx.emit("draw")}editCell(t,e){this.editor.editCell(t,e)}setItemValue(t,e,i,s=!0,o=!0,r=!1){this.ctx.database.setItemValue(t,e,i,s,o,r)}batchSetItemValue(t,e=!0){this.ctx.database.batchSetItemValue(t,e)}setItemValueByEditor(t,e,i,s=!0,o=!0){this.ctx.setItemValueByEditor(t,e,i,s,o),this.editor.doneEdit()}clearEditableData(t=null){const e=[0,this.ctx.maxColIndex],i=[0,this.ctx.maxRowIndex];return this.selector.clearSelectedData(e,i,!1,t)}clearEditor(){this.editor.clearEditor()}doLayout(){this.ctx.emit("draw")}getChangedData(){return this.ctx.database.getChangedData()}getChangedRows(){return this.ctx.database.getChangedRows()}setCurrentRowByRowIndex(t){this.ctx.currentCell=this.ctx.database.getVirtualBodyCell(t,0),this.ctx.emit("draw")}setCurrentRow(t){const e=this.ctx.database.getColumnByColIndex(0);e&&(this.ctx.currentCell=this.ctx.database.getVirtualBodyCellByKey(t,e.key),this.ctx.emit("draw"))}getCurrentRow(){const t=this.ctx.currentCell;return t?{row:t.row,rowIndex:t.rowIndex,rowKey:t.rowKey}:void 0}clearValidate(){this.ctx.database.clearValidate(),this.ctx.emit("draw")}validateFields(t,e=!0){return new Promise(async(i,s)=>{let o=[];for(let r=0;r<t.length;r++){const{rowKey:a,key:l}=t[r],h=await this.ctx.database.getValidator(a,l);Array.isArray(h)&&h.length&&o.push(h)}if(o.length){if(s(o),e){const[r]=o;if(Array.isArray(r)&&r.length){const[a]=r,{rowKey:l,key:h}=a;this.scrollToRowkey(l),this.scrollToColkey(h)}}this.ctx.emit("draw")}else i([]),this.ctx.emit("draw")})}async validate(t=!0){return new Promise(async(e,i)=>{try{const s=await this.getValidations();e(s)}catch(s){if(t&&Array.isArray(s)&&s.length){const[o]=s;if(Array.isArray(o)&&o.length){const[r]=o,{rowKey:a,key:l}=r,h=this.ctx.database.getRowForRowKey(a);if(h){const{parentRowKeys:d=[]}=h;d&&d.length&&this.setExpandRowKeys(d,!0)}this.scrollToRowkey(a),this.scrollToColkey(l)}}i(s)}})}setValidations(t){if(t.forEach(e=>{const{rowIndex:i,key:s,message:o}=e;this.ctx.database.setValidationErrorByRowIndex(i,s,o)}),t&&Array.isArray(t)&&t.length){const[e]=t;if(e&&e.rowIndex>=0&&e.key){const{rowIndex:i,key:s}=e;this.scrollToRowIndex(i),this.scrollToColkey(s)}}}getValidations(){return new Promise(async(t,e)=>{const i=this.ctx.database.getAllRowsData(),s=this.ctx.header.leafCellHeaders;let o=[];for(let r=0;r<i.length;r++)for(let a=0;a<s.length;a++){const l=this.ctx.database.getRowKeyByItem(i[r]),d=s[a].key,f=await this.ctx.database.getValidator(l,d);Array.isArray(f)&&f.length&&o.push(f)}o.length?(e(o),this.ctx.emit("draw")):(t([]),this.ctx.emit("draw"))})}hasValidationError(){return this.ctx.database.hasValidationError()}scrollTo(t,e){this.scroller.setScroll(t,e)}scrollXTo(t){this.scroller.setScrollX(t)}scrollToColkey(t){this.scroller.scrollToColkey(t)}scrollToRowkey(t){this.scroller.scrollToRowKey(t)}scrollToColIndex(t){this.scroller.scrollToColIndex(t)}scrollToRowIndex(t){this.scroller.scrollToRowIndex(t)}scrollYTo(t){this.scroller.setScrollY(t)}setExpandRowKeys(t,e=!0){this.ctx.database.setExpandRowKeys(t,e)}getExpandRowKeys(){return this.ctx.database.getExpandRowKeys()}clearSelection(){this.ctx.database.clearSelection(),this.ctx.emit("draw")}toggleRowSelection(t){const e=this.ctx.database.getRowKeyByItem(t);this.ctx.database.toggleRowSelection(e),this.ctx.emit("draw")}setSelectionByRows(t,e=!0){t.forEach(i=>{const s=this.ctx.database.getRowKeyByItem(i);this.ctx.database.setRowSelection(s,e,!1)}),this.ctx.emit("selectionChange",this.getSelectionRows()),this.ctx.emit("draw")}setSelectionByRowKeys(t,e=!0){t.forEach(i=>{this.ctx.database.setRowSelection(i,e,!1)}),this.ctx.emit("selectionChange",this.getSelectionRows()),this.ctx.emit("draw")}toggleAllSelection(){this.ctx.database.toggleAllSelection(),this.ctx.emit("draw")}toggleRowExpand(t,e){this.ctx.database.expandItem(t,e),this.ctx.emit("draw")}toggleExpandAll(t){this.ctx.database.expandAll(t),this.ctx.emit("draw")}getSelectionRows(){return this.ctx.database.getSelectionRows()}getPositionForRowIndex(t){return this.ctx.database.getPositionForRowIndex(t)}getCellValue(t,e){return this.ctx.database.getItemValue(t,e)}getCellValueByIndex(t,e){return this.ctx.database.getItemValueForRowIndexAndColIndex(t,e)}clearSort(){this.ctx.database.clearSort()}contextMenuHide(){this.contextMenu.hide()}getUtils(){return{mergeColCell:fe,mergeRowCell:de,getSpanArrByRow:Xt,getSpanObjByColumn:Yt}}getColumnByKey(t){var e;return(e=this.ctx.database.getColumnByKey(t))==null?void 0:e.column}destroy(){this.overlayer.destroy(),this.empty.destroy(),this.editor.destroy(),this.tooltip.destroy(),this.selector.destroy(),this.autofill.destroy(),this.contextMenu.destroy(),this.loading.destroy(),this.ctx.destroy(),this.ctx.containerElement.remove()}}module.exports=Si;
|
|
7
7
|
//# sourceMappingURL=index.cjs.js.map
|