e-virt-table 1.2.20 → 1.2.21
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 +3 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +379 -363
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +3 -3
- package/dist/index.umd.js.map +1 -1
- package/dist/lib/Validator.js +3 -3
- package/dist/lib/Validator.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document<"u"){var o=document.createElement("style");o.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-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-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}.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}")),document.head.appendChild(o)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
|
|
2
|
-
"use strict";var
|
|
2
|
+
"use strict";var ee=Object.defineProperty;var ie=(c,t,e)=>t in c?ee(c,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):c[t]=e;var n=(c,t,e)=>ie(c,typeof t!="symbol"?t+"":t,e);class se{constructor(t){n(this,"rules");this.rules=t}validate(t){const e=[],{column:i,row:s,key:o,rowKey:r,colIndex:l,rowIndex:a,value:h,field:d,fieldValue:f}=t;Array.isArray(this.rules)||(this.rules=[this.rules]);for(const x of this.rules){if(x.validator){const u={field:d,fieldValue:f,value:h,column:i,colIndex:l,rowIndex:a,row:s,key:o,rowKey:r,...x};x.validator(u,h,p=>{p&&e.push({...u,message:p})})}if(!x.required&&(h==null||h===""))return e;x.pattern&&!x.pattern.test(h)&&e.push({value:h,column:i,row:s,key:o,rowKey:r,colIndex:l,rowIndex:a,field:d,fieldValue:f,message:x.message||`${o} is pattern validation error`}),x.required&&(h==null||h==="")&&e.push({value:h,column:i,row:s,key:o,rowKey:r,colIndex:l,rowIndex:a,field:d,fieldValue:f,message:x.message||`${o} is required`})}return e}}function Lt(){return"xxxxxxxxxxxxxxxxxx".replace(/[x]/g,function(c){const t=Math.random()*16|0;return(c==="x"?t:t&3|8).toString(16)})}function Tt(c,t){let e=0,i;return function(...s){const o=new Date().getTime(),r=o-e;!e||r>=t?(c.apply(this,s),e=o):i||(i=setTimeout(()=>{c.apply(this,s),e=new Date().getTime(),i=void 0},t-r))}}function At(c=[]){return c.length?c.map(t=>At(t.children)+1).sort((t,e)=>e-t)[0]:0}function oe(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 Mt(c=[],t=1,e=0){return c.map(i=>{if(i.children){let s=0,o=i.fixed;i.children.forEach(l=>{l.fixed=o});const r=Mt(i.children,t-1,e+1);return r&&r.forEach(l=>{s+=l.colspan??0}),{...i,width:i.width,level:e,rowspan:1,colspan:s,children:r}}return{...i,level:e,rowspan:t,colspan:1}})}function et(c=[]){let t=[];return c.forEach(e=>{e.children?t=t.concat(et(e.children)):t.push(e)}),t}const Et=/^(\r\n|\n\r|\r|\n)/,re=/^[^\t\r\n]+/,mt=/^\t/;function ne(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(mt))c=c.replace(mt,""),e+=1,t[i][e]="";else if(c.match(Et))c=c.replace(Et,""),e=0,i+=1,t[i]=[""];else{let o="";if(c.startsWith('"')){let r=0,l=!0;for(;l;){const a=c.slice(0,1);a==='"'&&(r+=1),o+=a,c=c.slice(1),(c.length===0||c.match(/^[\t\r\n]/)&&r%2===0)&&(l=!1)}o=o.replace(/^"/,"").replace(/"$/,"").replace(/["]*/g,a=>new Array(Math.floor(a.length/2)).fill('"').join(""))}else{const r=c.match(re);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 le(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 Mt(c,t,e=[]){let i=0;const s=[];return c.forEach((o,r)=>{if(r===0)s.push(1);else{const l=e.reduce((h,d)=>`${h}${o[d]??""}`,"")||o[t],a=e.reduce((h,d)=>`${h}${c[r-1][d]??""}`,"")||c[r-1][t];l===a?(s[i]+=1,s.push(0)):(s.push(1),i=r)}}),s}function Ht(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 re(c,t,e=[]){const{visibleRows:i,rowIndex:s,headIndex:o}=c,r=Mt(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 ne(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=Ht(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 le(c,t=document.documentElement){const e=c.startsWith("--")?c:`--${c}`;return getComputedStyle(t).getPropertyValue(e).trim()}class Dt{constructor(t,e,i,s,o,r,l){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=l,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 Dt{constructor(e,i,s,o,r,l,a,h,d,f="body"){super(e,o,r,l,a,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,"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,"drawImageX",0);n(this,"drawImageY",0);n(this,"drawImageWidth",0);n(this,"drawImageHeight",0);n(this,"drawImageName","");n(this,"drawImageSource");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");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||"center",this.verticalAlign=h.verticalAlign||"middle",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.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.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.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:l,mergeRow:a=!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(l)&&l.length>0?this.relationColKeys=l:this.relationColKeys=[this.key],this.mergeCol=h,this.mergeRow=a,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.style=this.getOverlayerViewsStyle()}updateTree(){const{CELL_PADDING:e=0}=this.ctx.config,{rowKey:i,cellType:s}=this;let o,r=0,l="";if(this.type==="tree"&&s==="body"){const a=this.ctx.database.getRowForRowKey(i),{expand:h=!1,hasChildren:d=!1,expandLoading:f=!1,level:x=0}=a||{};if(this.rowExpand=h,this.rowHasChildren=d,f){const g=this.ctx.icons.get("loading");l="loading",o=g,r=x*8}else if(d){const g=this.ctx.icons.get("expand"),w=this.ctx.icons.get("shrink");o=h?w:g,l=h?"shrink":"expand",r=x*8}else r=x*8;let u=20,p=20;if(o){let g=this.drawX+r+e,w=this.drawY+(this.visibleHeight-p)/2;this.ctx.paint.drawImage(o,g,w,u,p),this.drawImageX=g,this.drawImageY=w,this.drawImageWidth=u,this.drawImageHeight=p,this.drawImageName=l,this.drawImageSource=o}this.align="left",this.drawTextX=r+this.drawX+u-.5}}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:l,FOOTER_TEXT_COLOR:a,FOOTER_BG_COLOR:h,HIGHLIGHT_SELECTED_ROW:d,HIGHLIGHT_SELECTED_ROW_COLOR:f,HIGHLIGHT_HOVER_ROW:x,HIGHLIGHT_HOVER_ROW_COLOR:u,STRIPE:p,STRIPE_COLOR:g}=this.ctx.config;if(this.cellType==="footer"){let _=h,S=a;if(typeof o=="function"){const I=o,{backgroundColor:b,color:O}=I({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()})||{};b&&(_=b),O&&(S=O)}this.drawCellSkyBgColor="transparent",this.drawCellBgColor=_,this.drawTextColor=S;return}let w="transparent";const E=this.ctx.hoverCell,y=this.ctx.currentCell;let m=this.rowIndex,R=this.rowIndex;if(this.rowspan!==1&&(x||d)){const _=this.getSpanInfo(),{yArr:S}=_;m=S[0],R=S[1]}x&&E&&(E.rowKey===this.rowKey&&(w=u),E.rowIndex>=m&&E.rowIndex<=R&&(w=u)),d&&y&&(y.rowKey===this.rowKey&&(w=f),y.rowIndex>=m&&y.rowIndex<=R&&(w=f)),this.drawCellSkyBgColor=w;let C=e,v=l;if(this.ctx.database.getReadonly(this.rowKey,this.key)||(C=i,v=r),p&&(this.rowIndex%2?C=g:C=e),typeof s=="function"){const _=s,{backgroundColor:S,color:I}=_({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,isHasChanged:this.isHasChanged,value:this.getValue()})||{};S&&(C=S),I&&(v=I)}this.drawCellBgColor=C,this.drawTextColor=v}updateSelection(){const{visibleWidth:e,visibleHeight:i,rowspan:s,colspan:o,cellType:r,type:l,rowIndex:a,rowKey:h}=this;if(!(s===0||o===0)&&r!=="footer"&&["index-selection","selection"].includes(l)){const d=this.ctx.database.getRowSelection(h),f=this.ctx.database.getRowSelectable(h),{CHECKBOX_SIZE:x=0}=this.ctx.config,u=this.drawX+(e-x)/2,p=this.drawY+(i-x)/2;let g=this.ctx.icons.get("checkbox-uncheck"),w="checkbox-uncheck";d&&f?(g=this.ctx.icons.get("checkbox-check"),w="checkbox-check"):d&&f?(g=this.ctx.icons.get("checkbox-check-disabled"),w="checkbox-check-disabled"):!d&&f?(g=this.ctx.icons.get("checkbox-uncheck"),w="checkbox-uncheck"):(g=this.ctx.icons.get("checkbox-disabled"),w="checkbox-disabled"),g&&l=="index-selection"?(this.ctx.hoverCell&&this.ctx.hoverCell.rowIndex===a||["checkbox-disabled","checkbox-check"].includes(w))&&(this.drawImageX=u,this.drawImageY=p,this.drawImageWidth=x,this.drawImageHeight=x,this.drawImageName=w,this.drawImageSource=g):g&&l==="selection"&&(this.drawImageX=u,this.drawImageY=p,this.drawImageWidth=x,this.drawImageHeight=x,this.drawImageName=w,this.drawImageSource=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:l}=this.ctx;if(this.hoverIconName&&!this.ctx.editing&&l){let a=0,h=0;if(l.rowKey===this.rowKey&&(a=this.drawX+this.width-s-o,h=this.drawY+(this.height-s)/2),this.rowspan!==1&&r){const f=this.getSpanInfo(),{yArr:x}=f,u=x[0],p=x[1];if(l.rowIndex>=u&&l.rowIndex<=p){const{width:g,height:w,offsetTop:E,offsetLeft:y}=f;a=this.drawX-y+g-s-o,h=this.drawY-E+(w-s)/2}}const d=this.ctx.icons.get(this.hoverIconName);this.drawImageX=a,this.drawImageY=h,this.drawImageWidth=s,this.drawImageHeight=s,this.drawImageName=this.hoverIconName,this.drawImageSource=d}}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.drawImageName))||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`),{position:"absolute",overflow:"hidden",left:e,top:i,width:`${this.visibleWidth}px`,height:`${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:l}=this.ctx.selector,a=r[1],h=l[1],{colIndex:d,rowIndex:f,drawX:x,drawY:u}=this;if(d===a&&f===h){const g=d===this.ctx.maxColIndex||f===this.ctx.maxRowIndex||d===this.ctx.lastCenterColIndex?6:4;this.ctx.paint.drawRect(x+this.width-g,u+this.height-g,6,6,{borderColor:o,fillColor:e})}}draw(){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}=this.ctx.config;let o=this.visibleWidth;if(this.type==="tree"){const f=this.drawTextX-this.drawX;o=this.visibleWidth-f}const{ellipsis:r}=this.ctx.paint.handleEllipsis(this.displayText,o,e,i);this.ellipsis=r;const{placeholder:l}=this.column;let a=this.displayText,h=this.drawTextColor;return!this.ctx.database.getReadonly(this.rowKey,this.key)&&l&&["",null,void 0].includes(this.text)&&this.cellType==="body"&&!(this.rowspan===0||this.colspan===0)&&(a=l,h=s),this.ctx.paint.drawText(a,this.drawTextX,this.drawTextY,o,this.visibleHeight,{font:i,padding:e,align:this.align,verticalAlign:this.verticalAlign,color:h})}drawImage(){if(this.drawImageSource){if(this.hoverIconName){const{CELL_HOVER_ICON_BG_COLOR:e,CELL_HOVER_ICON_BORDER_COLOR:i}=this.ctx.config;this.ctx.paint.drawRect(this.drawImageX-2,this.drawImageY-2,this.drawImageWidth+4,this.drawImageHeight+4,{borderColor:i,radius:4,borderWidth:1,fillColor:e})}this.ctx.paint.drawImage(this.drawImageSource,this.drawImageX,this.drawImageY,this.drawImageWidth,this.drawImageHeight)}}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[l,a]=i,[h,d]=s;!(l===a&&h===d)&&this.colIndex>=l&&this.colIndex<=a&&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,l=[o+s-e-.5,r,o+s-.5,r,o+s-.5,r+e];this.ctx.paint.drawLine(l,{borderColor:i,fillColor:i,borderWidth:1,lineCap:"round",lineJoin:"round"})}drawBorder(e){const{drawX:i,drawY:s,rowIndex:o,colIndex:r,height:l,width:a}=this;let h=i,d=s;const{xArr:f,yArr:x,lineDash:u=[],borderWidth:p=1,borderColor:g,fillColor:w}=e,E=f[0],y=f[1],m=x[0],R=x[1];if(r>=E&&r<=y&&o===m){const C=r===y?1:0,v=r===E?1:0;this.ctx.paint.drawLine([h+v,d+1,h+a-C,d+1],{borderColor:g,fillColor:w,borderWidth:p,lineCap:"round",lineJoin:"round",lineDash:u})}if(r===y&&o>=m&&o<=R){const C=o===m?1:0,v=o===R?1:0;this.ctx.paint.drawLine([h+a-1,d+C,h+a-1,d+l-v],{borderColor:g,fillColor:w,borderWidth:p,lineCap:"round",lineJoin:"round",lineDash:u})}if(r>=E&&r<=y&&o===R){const C=r===y?1:0,v=r===E?1:0;this.ctx.paint.drawLine([h+v,d+l-1,h+a-C,d+l-1],{borderColor:g,fillColor:w,borderWidth:p,lineCap:"round",lineJoin:"round",lineDash:u})}if(r===E&&o>=m&&o<=R){const C=o===R?1:0,v=o===m?1:0;this.ctx.paint.drawLine([h+1,d+v,h+1,d+l-C],{borderColor:g,fillColor:w,borderWidth:p,lineCap:"round",lineJoin:"round",lineDash:u})}}}class ae{constructor(t,e){n(this,"loading",!1);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,"bufferCheckState",{buffer:!1,check:!1,indeterminate:!1,selectable:!0});n(this,"sumHeight",0);n(this,"filterMethod");n(this,"positions",[]);this.ctx=t;const{data:i=[],columns:s=[],footerData:o=[]}=e;this.data=i,this.footerData=o,this.columns=s,this.setLoading(!0),this.init()}init(t=!0){this.clearBufferData(),this.rowKeyMap.clear(),this.checkboxKeyMap.clear(),this.colIndexKeyMap.clear(),this.rowIndexRowKeyMap.clear(),this.rowKeyRowIndexMap.clear();const e=this.getColumns(),i=et(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=[]){t.forEach((s,o)=>{var E;const{ROW_KEY:r="",DEFAULT_EXPAND_ALL:l,CELL_HEIGHT:a,SELECTABLE_METHOD:h,CHECKBOX_KEY:d}=this.ctx.config,f=s[r],x=f!=null?`${f}`:St();this.itemRowKeyMap.set(s,x);const u=s._height||a,p=s._readonly;let g=!0;if(typeof h=="function"&&(g=h),d){const y=s[d];if(this.checkboxKeyMap.has(y)){const m=this.checkboxKeyMap.get(y)||[];m.push(x),this.checkboxKeyMap.set(y,m)}else this.checkboxKeyMap.set(y,[x])}this.selectionMap.set(x,{key:d?s[d]:x,row:s,check:((E=this.selectionMap.get(x))==null?void 0:E.check)||!1});const w=l||this.expandMap.get(x)||s._expand||!1;this.expandMap.set(x,w),this.rowKeyMap.set(x,{readonly:p,index:o,rowIndex:o,level:e,height:u,check:!1,selectable:g,expand:w,expandLazy:!1,hasChildren:s._hasChildren||(Array.isArray(s.children)?s.children.length>0:!1),expandLoading:!1,item:s,parentRowKeys:i}),Array.isArray(s.children)&&s.children.length&&this.initData(s.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()}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.columns.length&&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 l=this.itemRowKeyMap.get(r),{expand:a,hasChildren:h,height:d}=this.rowKeyMap.get(l),f=this.sumHeight;this.sumHeight+=d,this.rowIndexRowKeyMap.set(e,l),this.rowKeyRowIndexMap.set(l,e),this.positions.push({top:f,height:d,bottom:this.sumHeight}),e+=1,a&&h&&i(r.children)})};this.rowIndexRowKeyMap.clear(),this.rowKeyRowIndexMap.clear();let s=this.data;return typeof this.filterMethod=="function"&&(s=this.filterMethod(s)),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}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 l=new Set;let a=[],h=t.map(u=>{const{rowKey:p,key:g}=u;let w=u.value,E=w;const y=this.getRowDataItemForRowKey(p),m=this.getItemValue(p,g),R=this.getVirtualBodyCellByKey(p,g);return(R==null?void 0:R.type)==="number"&&(["",void 0,null].includes(w)?E=null:/^-?\d+(\.\d+)?$/.test(`${w}`)?E=Number(w):(E=m,a.push({...u,value:E,oldValue:m,row:y}))),{...u,value:E,oldValue:m,row:y}});if(h=h.filter(u=>!a.some(p=>u.rowKey===p.rowKey&&u.key===p.key)),a.length){const u={code:"ERR_BATCH_SET_NUMBER_VALUE",message:"Assignment failed, not a numeric type",data:a};this.ctx.emit("error",u)}if(!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(u=>{const{value:p,rowKey:g,key:w}=u,E=this.getItemValue(g,w);l.add(g),this.setItemValue(g,w,p,!1,!1,!1,r),o.push({rowKey:g,key:w,oldValue:E,newValue:p})});let f=[];l.forEach(u=>{f.push(this.ctx.database.getRowDataItemForRowKey(u))});const x=h.map(({rowKey:u,key:p})=>this.getValidator(u,p));Promise.all(x).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,l=!0){if(!this.rowKeyMap.has(t))return{};const{item:a}=this.rowKeyMap.get(t);let h=a[e],d=i;if(l&&this.ctx.database.getReadonly(t,e))return{oldValue:h,newValue:h};a[e]!==null&&typeof a[e]=="object"&&(h=JSON.parse(JSON.stringify(a[e])));const f=`${t}_${e}`;this.originalDataMap.has(f)||this.originalDataMap.set(f,h);const x=this.originalDataMap.get(f),u=this.getRowDataItemForRowKey(t);if(r){const p=this.getVirtualBodyCellByKey(t,e);if((p==null?void 0:p.type)==="number")if(["",void 0,null].includes(i))d=null;else if(/^-?\d+(\.\d+)?$/.test(`${i}`))d=Number(i);else{d=h;const w={code:"ERR_SET_NUMBER_VALUE",message:"Assignment failed, not a numeric type",data:[{rowKey:t,key:e,value:d,oldValue:h,row:u}]};this.ctx.emit("error",w)}if(d===h)return{oldValue:h,newValue:h};let g=[{rowKey:t,key:e,value:d,oldValue:h,row:u}];this.batchSetItemValue(g,s,!1),this.ctx.emit("editChange",{rowKey:t,key:e,oldValue:h,value:d,originalValue:x,row:u})}else this.changedDataMap.set(f,d),a[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:u}),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(l=>{const a=this.selectionMap.get(l);a&&(a.check=e)})}}toggleRowSelection(t){const e=this.rowKeyMap.get(t),i=this.selectionMap.get(t);if(!i)return;i.check=!i.check,this.setRowSelectionByCheckboxKey(t,i.check),this.ctx.emit("toggleRowSelection",e);const s=this.getSelectionRows();this.ctx.emit("selectionChange",s),this.bufferCheckState.buffer=!1,this.ctx.emit("draw")}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),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}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.rowKeyMap.forEach((e,i)=>{let s=e.selectable;typeof s=="function"&&(s=s({row:e.item,rowIndex:e.rowIndex})),s&&this.setRowSelection(i,!0,!1)});const t=this.getSelectionRows();this.ctx.emit("toggleAllSelection",t),this.ctx.emit("selectionChange",t),this.bufferCheckState.buffer=!1,this.ctx.emit("draw")}clearSelection(t=!1){t?this.rowKeyMap.forEach((i,s)=>{this.setRowSelection(s,!1,!1)}):(this.selectionMap.clear(),this.rowKeyMap.forEach((i,s)=>{this.selectionMap.set(s,{check:!1,row:i.item,key:s})}));const e=this.getSelectionRows();this.ctx.emit("clearSelection"),this.ctx.emit("selectionChange",e),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,l=Array.from(this.selectionMap.values()).some(x=>x.check);this.rowKeyMap.forEach((x,u)=>{var g;(g=this.selectionMap.get(u))!=null&&g.check&&(s+=1);let p=x.selectable;typeof p=="function"&&(p=p({row:x.item,rowIndex:x.rowIndex})),p&&(o+=1)});const a=r>i&&s===0&&l,h=o&&o>s&&s>0||a,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}}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,l=o.readonly,{BODY_CELL_READONLY_METHOD:a}=this.ctx.config;if(typeof a=="function"&&o){const d=a({row:s.item,rowIndex:s.rowIndex,colIndex:o.colIndex,column:o.column,value:this.getItemValue(t,e)});if(d!==void 0)return d}return l||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 l=o.column;let a=l.rules;if(typeof r=="function"){const d=r({row:s.item,rowIndex:s.rowIndex,colIndex:o.colIndex,column:l,value:this.getItemValue(t,e)});d&&(a=d)}if(a){const h={row:s.item,rowIndex:s.rowIndex,colIndex:o.colIndex,column:l,key:e,rowKey:t,value:this.getItemValue(t,e),field:e,fieldValue:this.getItemValue(t,e)},f=new te(a).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:l,relationRowKeys:a,relationColKeys:h,rowspan:d,height:f,width:x,colspan:u,mergeRow:p,mergeCol:g}=t;if(d===1&&u===1)return{xArr:[l,l],yArr:[e,e],rowspan:d,colspan:u,height:f,width:x,offsetTop:0,offsetLeft:0,dataList:[{rowKey:s,key:i,row:o,value:r}]};let w=e,E=e,y=l,m=l,R=[],C=0,v=0,_=0,S=0;if(d!==1&&p){S=x;const I=a.reduce((b,O)=>{const L=this.getItemValue(s,O)??"";return`${b}${L}`},"");for(let b=e-1;b>=0;b--){const O=this.rowIndexRowKeyMap.get(b)||"",L=a.reduce((M,T)=>{const k=this.getItemValue(O,T)??"";return`${M}${k}`},"");if(I===L)w=b;else break}for(let b=e;b<=this.ctx.maxRowIndex;b++){const O=this.rowIndexRowKeyMap.get(b)||"",L=a.reduce((M,T)=>{const k=this.getItemValue(O,T)??"";return`${M}${k}`},"");if(I===L)E=b;else break}for(let b=w;b<e;b++){const{height:O}=this.positions[b];C+=O}for(let b=w;b<=E;b++){const{height:O}=this.positions[b];_+=O;const L=this.rowIndexRowKeyMap.get(b)||"",{item:M}=this.rowKeyMap.get(L),T=this.getItemValue(L,i);R.push({rowKey:L,key:i,value:T,row:M})}}if(u!==1&&g){_=f;for(let I=l-1;I>=0;I--){const b=this.getColumnByColIndex(I);if(!b)break;const O=this.getItemValue(s,i),L=this.getItemValue(s,b.key);if(O===L&&h.includes(b.key))y=I;else break}for(let I=l;I<=this.ctx.maxColIndex;I++){const b=this.getColumnByColIndex(I);if(!b)break;const O=this.getItemValue(s,i),L=this.getItemValue(s,b.key);if(O===L&&h.includes(b.key))m=I;else break}for(let I=y;I<l;I++){const b=this.getColumnByColIndex(I);if(!b)break;v+=b.width||100}for(let I=y;I<=m;I++){const b=this.getColumnByColIndex(I);if(!b)break;S+=b.width||100,R.push({rowKey:s,key:b.key,value:this.getItemValue(s,b.key),row:o})}}return{xArr:[y,m],yArr:[w,E],rowspan:d,colspan:u,height:_,width:S,offsetTop:C,offsetLeft:v,dataList:R}}setLoading(t){this.loading=t,this.ctx.emit("loadingChange",t)}getLoading(){return this.loading}setValidationErrorByRowIndex(t,e,i){const s=this.rowIndexRowKeyMap.get(t),o=`${s}_${e}`,r=this.getRowForRowIndex(t),l=this.getColumnByKey(e);if(!s||!l||!r)return;const a=this.getItemValue(s,e),h=[{key:e,rowKey:s,rowIndex:t,colIndex:l.colIndex,column:l.column,row:r,value:a,message:i,field:e,fieldValue:a}];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}}class he{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 ce{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 de{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 fe{constructor(t){n(this,"ctx");const e=t.getContext("2d");if(!e)throw new Error("canvas context not found");this.ctx=e}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:l,shadowWidth:a,colorStart:h,colorEnd:d}=o;this.ctx.save(),r&&(this.ctx.fillStyle=r,this.ctx.fillRect(t,e,i,s));let f;switch(l){case"left":f=this.ctx.createLinearGradient(t-a,e,t,e),f.addColorStop(0,h),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t-a,e,a,s);break;case"right":f=this.ctx.createLinearGradient(t+i,e,t+i+a,e),f.addColorStop(0,h),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t+i,e,a,s);break;case"top":f=this.ctx.createLinearGradient(t,e-a,t,e),f.addColorStop(0,h),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t,e-a,i,a);break;case"bottom":f=this.ctx.createLinearGradient(t,e+s,t,e+s+a),f.addColorStop(0,h),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t,e+s,i,a);break;default:console.error("Invalid side specified for shadow");break}}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=4,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:l,radius:a=0}={}){if(this.ctx.save(),this.ctx.beginPath(),l!==void 0&&(this.ctx.fillStyle=l),r!==void 0&&(this.ctx.lineWidth=o,this.ctx.strokeStyle=r),a===0)this.ctx.rect(t-.5,e-.5,i,s);else{const[h,d,f,x]=typeof a=="number"?[a,a,a,a]:a;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-x,x),this.ctx.arcTo(t,e,t+h,e,h)}l!==void 0&&this.ctx.fill(),r!==void 0&&this.ctx.stroke(),this.ctx.restore()}drawText(t="",e,i,s,o,r={}){this.ctx.save();const{font:l="12px Arial",align:a="center",color:h="#495060",padding:d=0,verticalAlign:f="middle"}=r;this.ctx.font=l,this.ctx.fillStyle=h,this.ctx.textBaseline=f,this.ctx.textAlign=a;let x=0;f==="top"?x=i+d:f==="bottom"?x=i+o-d:x=i+(o+1)/2;let u=0;a==="left"?u=e+d:a==="right"?u=e+s-d:u=e+s/2;const{_text:p,ellipsis:g}=this.handleEllipsis(t,s,d,l);return this.ctx.fillText(p,u,x),this.ctx.restore(),g}handleEllipsis(t,e,i=0,s="12px Arial"){let o=!1,r=t;if(this.ctx.font=s,t==null||t==="")return{_text:"",ellipsis:o};const l=this.ctx.measureText("...").width,a=this.ctx.measureText(t).width;if(a&&a+l>=e-i*2){o=!0;let h=0;for(let d=0;d<t.length;d++)if(h+=this.ctx.measureText(t[d]).width,h>=e-i*2-l){r=t.slice(0,d)+"...";break}}return{_text:r,ellipsis:o}}}class Ct{constructor(t){n(this,"_config",{});n(this,"CSS_PREFIX","e-virt-table");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,"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,"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,"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_CHECK_SVG","");n(this,"CHECKBOX_UNCHECK_SVG","");n(this,"CHECKBOX_INDETERMINATE_SVG","");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,"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,"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=le(i);t[e]=s}}),Object.assign(this,t,this._config)}}const bt='<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>';class xe{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:"CHECKBOX_UNCHECK_SVG",configColorName:"SHRINK_ICON_COLOR",svg:bt,color:"#4E5969"},{name:"checkbox-uncheck",configName:"CHECKBOX_UNCHECK_SVG",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" fill="#DDE0EA" p-id="4709"></path></svg>',color:""},{name:"checkbox-check",configName:"CHECKBOX_CHECK_SVG",configColorName:"CHECKBOX_COLOR",svg:'<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>',color:"rgb(82,146,247)"},{name:"checkbox-hover",configName:"CHECKBOX_UNCHECK_SVG",configColorName:"CHECKBOX_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" fill="#DDE0EA" p-id="4709"></path></svg>',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_SVG",svg:'<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>',color:"#DDE0EA"},{name:"checkbox-disabled",configName:"CHECKBOX_DISABLED_SVG",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" fill="#F1F2F4" 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:""},{name:"icon-edit",configName:"CHECKBOX_DISABLED_SVG",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:"CHECKBOX_UNCHECK_SVG",configColorName:"SHRINK_ICON_COLOR",svg:bt,color:"#4E5969"}]);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 l=this.ctx.config[i.configColorName];l&&(s=l)}if(i.configName){const l=this.ctx.config[i.configName];l&&(o=l)}const r=this.createImageFromSVG(o,s).then(l=>{this.icons.set(i.name,l)});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=>{h.setAttribute("fill",e)});const l=new Image;let a="";if(i){const h=new Blob([new XMLSerializer().serializeToString(r)],{type:"image/svg+xml"});a=URL.createObjectURL(h)}else a="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(new XMLSerializer().serializeToString(r));return l.src=a,new Promise((h,d)=>{l.onerror=()=>d(new Error("Failed to load image")),l.onload=()=>{h(l)}})}get(t){return this.icons.get(t)}}class kt extends Dt{constructor(e,i,s,o,r,l,a){super(e,s,o,r,l,"header",a.fixed);n(this,"align");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,"visibleWidth",0);n(this,"visibleHeight",0);n(this,"drawCellBgColor","");n(this,"drawTextColor","");n(this,"drawImageX",0);n(this,"drawImageY",0);n(this,"drawImageWidth",0);n(this,"drawImageHeight",0);n(this,"drawImageName","");n(this,"drawImageSource");this.ctx=e,this.x=s,this.y=o,this.width=r,this.height=l,this.visibleWidth=r,this.visibleHeight=l,this.colIndex=i,this.key=a.key,this.minWidth=a.minWidth,this.maxWidth=a.maxWidth,this.type=a.type||"",this.editorType=a.editorType||"text",this.align=a.align||"center",this.verticalAlign=a.verticalAlign||"middle",this.fixed=a.fixed,this.level=a.level||0,this.operation=a.operation||!1,this.text=a.title,this.column=a,this.colspan=a.colspan||1,this.widthFillDisable=a.widthFillDisable||!1,this.rowspan=a.rowspan||1,this.rules=a.rules,this.readonly=a.readonly||!1,this.required=a.required||!1,this.rowKey=St(),this.overflowTooltipShow=a.overflowTooltipHeaderShow!==!1,this.hasChildren=a.children&&a.children.length>0||!1,this.render=a.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 l=e,{backgroundColor:a,color:h}=l({colIndex:this.colIndex,column:this.column})||{};a&&(o=a),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.updateStyle()}draw(){const{paint:e,config:{BORDER_COLOR:i,CELL_PADDING:s,HEADER_FONT:o,BORDER:r}}=this.ctx,{drawX:l,drawY:a,displayText:h}=this;e.drawRect(l,a,this.width,this.height,{borderColor:r?i:"transparent",fillColor:this.drawCellBgColor}),this.ellipsis=e.drawText(h,l,a,this.width,this.height,{font:o,padding:s,color:this.drawTextColor,align:this.align,verticalAlign:this.verticalAlign}),this.drawSelection(),this.drawSelector()}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(){const{width:e,height:i,type:s}=this;if(["index-selection","selection"].includes(s)){const{indeterminate:o,check:r,selectable:l}=this.ctx.database.getCheckedState(),{CHECKBOX_SIZE:a=0}=this.ctx.config,h=this.drawX+(e-a)/2,d=this.drawY+(i-a)/2;let f=this.ctx.icons.get("checkbox-uncheck"),x="checkbox-uncheck";o?(f=this.ctx.icons.get("checkbox-indeterminate"),x="checkbox-indeterminate"):r&&l?(f=this.ctx.icons.get("checkbox-check"),x="checkbox-check"):r&&l?(f=this.ctx.icons.get("checkbox-check-disabled"),x="checkbox-check-disabled"):!r&&l?(f=this.ctx.icons.get("checkbox-uncheck"),x="checkbox-uncheck"):(f=this.ctx.icons.get("checkbox-disabled"),x="checkbox-disabled"),f&&(this.drawImageX=h,this.drawImageY=d,this.drawImageWidth=a,this.drawImageHeight=a,this.drawImageName=x,this.drawImageSource=f,this.ctx.paint.drawImage(this.drawImageSource,this.drawImageX,this.drawImageY,this.drawImageWidth,this.drawImageHeight))}}getText(){return this.render?"":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 ue{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("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)}),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{this.ctx.clickCell=s,this.ctx.emit("cellClick",s,t),this.selectionClick(s),this.treeClick(s),this.hoverIconClick(s)})}),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.selectionEnterAndLeave(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){if(["selection","index-selection"].includes(t.type)&&this.ctx.isPointer)if(t instanceof kt)t.drawImageName==="checkbox-uncheck"||t.drawImageName==="checkbox-indeterminate"?this.ctx.database.toggleAllSelection():t.drawImageName==="checkbox-check"&&this.ctx.database.clearSelection(!0);else{if(!this.ctx.database.getRowSelectable(t.rowKey))return;this.ctx.database.toggleRowSelection(t.rowKey)}}treeClick(t){if(t.type==="tree"&&this.ctx.isPointer){const e=this.ctx.database.getRowForRowKey(t.rowKey),{expand:i=!1,expandLazy:s=!1}=e||{},{EXPAND_LAZY:o,EXPAND_LAZY_METHOD:r}=this.ctx.config;if(o&&r&&!i&&!s)typeof r=="function"&&(this.ctx.database.expandLoading(t.rowKey,!0),r({row:t.row,rowIndex:t.rowIndex,colIndex:t.colIndex,column:t.column,value:t.getValue()}).then(a=>{this.ctx.database.setExpandChildren(t.rowKey,a),this.ctx.database.expandLoading(t.rowKey,!1),this.ctx.emit("expandChange",this.ctx.database.getExpandRowKeys())}).catch(a=>{this.ctx.database.expandLoading(t.rowKey,!1),console.error(a)}));else{const l=this.ctx.database.getIsExpand(t.rowKey);this.ctx.database.expandItem(t.rowKey,!l),this.ctx.emit("expandChange",this.ctx.database.getExpandRowKeys())}}}imageEnterAndLeave(t,e){const{offsetY:i,offsetX:s}=this.ctx.getOffset(e),o=i,r=s;r>t.drawImageX&&r<t.drawImageX+t.drawImageWidth&&o>t.drawImageY&&o<t.drawImageY+t.drawImageHeight&&(this.ctx.stageElement.style.cursor="pointer",this.ctx.isPointer=!0)}selectionEnterAndLeave(t,e){const{offsetY:i,offsetX:s}=this.ctx.getOffset(e),o=i,r=s;r>t.drawImageX&&r<t.drawImageX+t.drawImageWidth&&o>t.drawImageY&&o<t.drawImageY+t.drawImageHeight&&t instanceof ut&&["selection","index-selection"].includes(t.type)&&(this.ctx.stageElement.style.cursor="pointer",this.ctx.isPointer=!0,this.ctx.database.getRowSelectable(t.rowKey)||(this.ctx.stageElement.style.cursor="not-allowed"))}isBusy(t){const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,o=i;if(!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 l=r.fixedCells.concat(r.noFixedCells);for(const a of l){const h=a.getDrawX(),d=a.getDrawY();if(o){if(t>h&&t<h+a.visibleWidth&&e>d&&e<d+a.visibleHeight){s(a);return}}else if(t>h&&t<h+a.width&&e>d&&e<d+a.height){s(a);return}}}}handleHeaderEvent(t,e,i,s){for(const o of i){const r=o.getDrawX(),l=o.getDrawY();if(t>r&&t<r+o.width&&e>l&&e<l+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 ge{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,"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,"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");const{containerElement:i,stageElement:s,canvasElement:o,overlayerElement:r,editorElement:l,emptyElement:a,contextMenuElement:h}=t;this.containerElement=i,s.tabIndex=0,this.stageElement=s,this.canvasElement=o,this.overlayerElement=r,this.editorElement=l,this.emptyElement=a,this.contextMenuElement=h,this.config=new Ct(e.config||{}),this.eventBus=new de,this.eventBrowser=new ce(this),this.eventTable=new ue(this),this.paint=new fe(this.canvasElement),this.database=new ae(this,e),this.history=new he(this),this.icons=new xe(this)}setConfig(t){this.config=new Ct(t)}setItemValueByEditor(t,e,i,s=!0,o=!0,r=!0){if(this.config.ENABLE_MERGE_CELL_LINK){const l=this.database.getVirtualBodyCellByKey(t,e);if(l&&(l.mergeRow||l.mergeCol)){const{dataList:a}=l.getSpanInfo(),h=a.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),l=this.database.getColIndexForKey(o.key);if(r===void 0||l===void 0)return;const a=this.database.getVirtualBodyCell(r,l);if(a){const{dataList:h}=a.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 l=0;l<=i[1]-i[0];l++){const a=o+e[0],h=l+i[0],d=this.database.getVirtualBodyCell(a,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 Rt{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 l=0;if(this.type==="horizontal"?l=s-this.clientX:l=o-this.clientY,this.isDragging&&l!==0){let a=0;this.type==="vertical"?a=this.dragStart+l/(this.visibleDistance-this.barHeight)*this.distance:a=this.dragStart+l/(this.visibleDistance-this.barWidth)*this.distance,this.scroll=Math.max(0,Math.min(a,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:l}}=this.ctx,a=s,h=i,d=e.height,f=e.width,x=t.height,u=this.ctx.footer.height;if(this.type==="vertical"){this.visibleDistance=h-o-d,this.distance=x-this.visibleDistance+u,this.trackX=a-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 p=this.distance?this.visibleDistance/(x+u):0;let g=Math.floor(p*this.visibleDistance);g<30?g=30:g>this.visibleDistance&&(g=0),this.barHeight=g,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=a-o,this.distance=f-this.visibleDistance,this.splitPoints=[a-o,h-o,a-o,h];const p=l?0:.5;this.trackX=0,this.trackY=h-o+p,this.trackWidth=a,this.trackHeight=o;const g=this.distance?this.visibleDistance/f:0;let w=Math.floor(g*this.visibleDistance);this.barY=this.trackY-1+(o-r)/2,w<30?w=30:w>=this.visibleDistance&&(w=0),this.barWidth=w,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 we{constructor(t){n(this,"ctx");n(this,"verticalScrollbar");n(this,"horizontalScrollbar");this.ctx=t,this.verticalScrollbar=new Rt(t,"vertical"),this.horizontalScrollbar=new Rt(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 pe{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",Lt(()=>{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=Tt(i),o=et(i);this.height=t*s,this.width=o.reduce((f,x)=>{const u=x.width||100,{maxWidth:p,minWidth:g}=x;return p&&u>p?f+p:g&&u<g?f+g:f+u},0),this.visibleHeight=this.height;const r=ee(At(i,s));this.columnIndex=0,this.resizeNum=0,this.render(r,0),this.ctx.database.updateColIndexKeyMap(this.leafCellHeaders);const l=this.ctx.containerElement.getBoundingClientRect();this.resizeNum>0?this.ctx.stageWidth=Math.floor(l.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 a=this.visibleWidth-this.width;if(this.resizeNum&&a>0){const f=Math.floor(a/this.resizeNum*100)/100;this.resizeAllColumn(f)}const h=this.fixedLeftCellHeaders.filter(f=>!f.hasChildren);this.ctx.fixedLeftWidth=h.reduce((f,x)=>f+x.width,0);const d=this.fixedRightCellHeaders.filter(f=>!f.hasChildren);this.ctx.fixedRightWidth=d.reduce((f,x)=>f+x.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(){const{config:{ENABLE_RESIZE_COLUMN:t}}=this.ctx;t&&(this.ctx.on("mousedown",e=>{this.ctx.isTarget(e)&&(this.clientX=e.clientX,this.resizeTarget?(this.isResizing=!0,this.ctx.columnResizing=!0):this.isResizing=!1,this.isMouseDown=!0)}),this.ctx.on("mouseup",()=>{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",e=>{if(this.ctx.editing)return;const{stageWidth:i,config:{RESIZE_COLUMN_MIN_WIDTH:s}}=this.ctx;if(this.isResizing&&this.resizeTarget){const o=this.resizeTarget.width,r=this.resizeTarget.minWidth,l=this.resizeTarget.maxWidth;let a=e.clientX-this.clientX;a+o<s&&(a=-(o-s)),r&&a+o<r&&(a=-(o-r)),l&&a+o>l&&(a=l-o),this.resizeDiff=a,this.ctx.emit("draw")}else{if(this.resizeTarget=null,this.isMouseDown)return;if(e.offsetX<0||e.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 o=[...this.renderFixedCellHeaders,...this.renderCenterCellHeaders];for(const r of o){const{offsetX:l,offsetY:a}=this.ctx.getOffset(e),h=l,d=r.getDrawX();h>d+r.width-5&&h<d+r.width+4&&h<i-4&&r.colspan<=1&&this.ctx.isTarget(e)&&a<=this.height&&(this.ctx.stageElement.style.cursor="col-resize",this.resizeTarget=r)}}}))}resizeColumn(t,e){const i=o=>{o.forEach(r=>{if(r.children&&r.children.length>0&&i(r.children),r.key===t.key){const l=r.width||100;r.width=l+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 l=t[r],a=o*(l.rowspan||0),h=o*(l.level||0);let{minWidth:d,maxWidth:f}=l,x=l.width||100;d&&x<d&&(x=d),f&&x>f&&(x=f),l.children&&(x=et(l.children).reduce((g,w)=>g+((w==null?void 0:w.width)||100),0));const u=new kt(this.ctx,this.columnIndex,s,h,x,a,l);this.ctx.database.setHeader(l.key,u),this.allCellHeaders.push(u),l.children||(this.leafCellHeaders.push(u),u.column.widthFillDisable||this.resizeNum++),l.fixed==="left"?this.fixedLeftCellHeaders.push(u):l.fixed==="right"?this.fixedRightCellHeaders.push(u):this.centerCellHeaders.push(u),!l.children&&this.columnIndex++,l.children&&this.render(l.children,s),s+=x}}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:l}}=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!==l){const a=s.width-(this.x+this.width)+o-e;this.ctx.paint.drawShadow(a,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 Xt{constructor(t,e,i=0,s=0,o=0,r=0,l,a="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,"rowIndex",0);n(this,"rowKey","");n(this,"rowType","body");n(this,"data");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=a,this.data=l,this.update()}update(){const{header:t}=this.ctx,e=[],i=[],s=[];t.renderLeafCellHeaders.forEach(o=>{const r=new ut(this.ctx,this.rowIndex,o.colIndex,o.x,this.y,o.width,this.height,o.column,this.data,this.rowType);r.fixed?i.push(r):s.push(r),e.push(r)}),this.cells=e,this.fixedCells=i,this.noFixedCells=s}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 Ee{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:l,EMPTY_BODY_HEIGHT:a=0,MAX_HEIGHT:h=0,ENABLE_OFFSET_HEIGHT:d=0,OFFSET_HEIGHT:f=0,FOOTER_POSITION:x}}=this.ctx;if(!e.width)return;this.x=0,x==="top"&&o?this.y=e.height+i.height:this.y=e.height;const{data:u,sumHeight:p}=s.getData();this.height=p,this.data=u,this.width=e.width,this.visibleWidth=this.ctx.stageWidth-r;const g=this.ctx.footer.height;!this.data.length&&!l?this.height=a:!this.data.length&&l&&(this.height=l-e.height-g-r);let w=this.height+e.height+r;w+=g;let E=w;const y=window.innerHeight,{top:m}=this.containerRect||this.ctx.containerElement.getBoundingClientRect();if(y>m&&d&&!l){const L=y-m-f;L>e.height+r?E=L:w>h&&(E=h)}else this.data.length&&l?E=l:this.data.length&&h&&w>h&&(E=h);E>0&&(this.ctx.stageHeight=Math.floor(E),this.ctx.stageElement.style.height=`${this.ctx.stageHeight}px`);let R=this.ctx.stageHeight-e.height-r;o?this.visibleHeight=R-g: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=u;const C=window.devicePixelRatio||1,v=this.ctx.stageWidth*C,_=this.ctx.stageHeight*C;t.width=Math.round(v),t.height=Math.round(_);const S=this.data.length?"not-empty":"empty";this.ctx.emit("emptyChange",{isEmpty:S,type:S,headerHeight:e.height,bodyHeight:this.height,footerHeight:g,width:this.width,height:this.data.length?0:a+g});const I=Math.round(t.width/C*1e4)/1e4,b=Math.round(t.height/C*1e4)/1e4;this.ctx.canvasElement.setAttribute("style",`height:${b}px;width:${I}px;`),this.ctx.paint.scale(C)}initResizeRow(){const{config:{ENABLE_RESIZE_ROW:t}}=this.ctx;t&&(this.ctx.on("resize",()=>{this.containerRect=this.ctx.containerElement.getBoundingClientRect()}),this.ctx.on("resizeObserver",()=>{this.containerRect=this.ctx.containerElement.getBoundingClientRect()}),this.ctx.on("mouseup",()=>{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",e=>{this.ctx.isTarget(e)&&(this.clientY=e.clientY,this.resizeTarget?(this.isResizing=!0,this.ctx.rowResizing=!0):(this.isResizing=!1,this.ctx.rowResizing=!1),this.isMouseDown=!0)}),this.ctx.on("mousemove",e=>{if(this.ctx.editing)return;const{offsetY:i,offsetX:s}=this.ctx.getOffset(e),o=i,r=s,l=e.clientY,{stageHeight:a,scrollY:h,config:{RESIZE_ROW_MIN_HEIGHT:d=0}}=this.ctx;if(this.isResizing&&this.resizeTarget){const f=this.resizeTarget.height;let x=l-this.clientY;x+f<d&&(x=-(f-d)),this.resizeDiff=x,this.ctx.emit("draw")}else{if(this.resizeTarget=null,this.isMouseDown)return;if(r<0||r>this.ctx.body.visibleWidth||o<0||o>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 f=0;f<this.renderRows.length;f++){const x=this.renderRows[f];if(o>x.y-h+x.height-1.5&&o<x.y-h+x.height+1.5&&o<a-4)for(let p=0;p<x.cells.length;p++){const g=x.cells[p];r>g.drawX+10&&r<g.drawX+g.width-10&&g.rowspan===1&&(this.ctx.stageElement.style.cursor="row-resize",this.resizeTarget=x)}}}}))}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,l=[0,r-.5,t,r-.5];this.ctx.paint.drawLine(l,{borderColor:i,borderWidth:1})}}drawFixedShadow(){const{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,stageWidth:o,config:{HEADER_BG_COLOR:r,SCROLLER_TRACK_SIZE:l}}=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!==l){const a=s.width-(this.x+this.width)+o-e;this.ctx.paint.drawShadow(a,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),l=t[r].bottom;if(l===e)return r;l<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:l}=e.getData();this.ctx.maxRowIndex=r.length-1;let a=this.binarySearch(l,o),h=this.binarySearch(l,o+this.visibleHeight);if(h===-1&&(h=this.ctx.maxRowIndex),a===-1&&h===this.ctx.maxRowIndex){const f=Math.floor(this.visibleHeight/s);a=this.ctx.maxRowIndex-f}this.headIndex=Math.max(0,a),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 x=this.headIndex+f,u=this.visibleRows[f],{height:p,top:g}=this.ctx.database.getPositionForRowIndex(x),w=new Xt(this.ctx,x,0,g+this.y,t.width,p,u);d.push(w)}this.renderRows=d,this.ctx.body.renderRows=d}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 me{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(l=>l+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:l}}=this.ctx;let a=this.y;if(this.ctx.config.FOOTER_FIXED||(a=this.y-this.ctx.scrollY),i>0&&t!==0&&this.ctx.paint.drawShadow(this.x,a,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!==l){const h=s.width-(this.x+this.width)+o-e;this.ctx.paint.drawShadow(h,a,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 Xt(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 ye{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",Lt(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[l]=r;r=[l,l]}if(!i){const[l]=o;o=[l,l]}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:l,SELECTOR_AREA_MAX_X:a,SELECTOR_AREA_MIN_Y:h,SELECTOR_AREA_MAX_Y:d,SELECTOR_AREA_MAX_X_OFFSET:f,SELECTOR_AREA_MAX_Y_OFFSET:x}=this.ctx.config,u=l,p=a||this.ctx.maxColIndex-f,g=h,w=d||this.ctx.maxRowIndex-x;let[E,y]=o,[m,R]=r;if(E<u||y>p||m<g||R>w)return;if(this.ctx.stageElement.focus({preventScroll:!0}),this.ctx.config.ENABLE_MERGE_CELL_LINK){const v=this.adjustMergeCells(o,r);m=v.yArr[0],R=v.yArr[1],E=v.xArr[0],y=v.xArr[1],this.ctx.onlyMergeCell=v.onlyMergeCell}E===y&&m===R?this.ctx.selectOnlyOne=!0:this.ctx.selectOnlyOne=!1,o=[Math.max(u,E),Math.min(p,y)],r=[Math.max(g,m),Math.min(w,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 p;const[i,s]=e,[o,r]=t;let l=[],a=[];for(let g=0;g<=e[1]-e[0];g++)for(let w=0;w<=t[1]-t[0];w++){const E=g+e[0],y=w+t[0],m=this.ctx.database.getVirtualBodyCell(E,y);m&&((E===i||E===s)&&l.push(m),(y===o||y===r)&&a.push(m))}const h=l.reduce((g,w)=>{const{yArr:E}=w.getSpanInfo(),[y,m]=E;return g.minY=Math.min(g.minY,y),g.maxY=Math.max(g.maxY,m),g},{minY:i,maxY:s}),d=a.reduce((g,w)=>{const{xArr:E}=w.getSpanInfo(),[y,m]=E;return g.minX=Math.min(g.minX,y),g.maxX=Math.max(g.maxX,m),g},{minX:o,maxX:r}),f=[d.minX,d.maxX],x=[h.minY,h.maxY];let u=!1;if(d.minX!==d.maxX||h.minY!==h.maxY){const g=JSON.stringify(f)+JSON.stringify(x),w=(p=this.ctx.focusCell)==null?void 0:p.getSpanInfo();u=(w&&JSON.stringify(w.xArr)+JSON.stringify(w.yArr))===g}return{xArr:f,yArr:x,onlyMergeCell:u}}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:l}=this.ctx.focusCellHeader;if(this.ctx.clearSelector(),t.colIndex>=l){const a=[l,t.colIndex+t.colspan-1],h=[o,r];this.setSelector(a,h)}else{const a=[t.colIndex,l],h=[o,r];this.setSelector(a,h)}}else{const l=[t.colIndex,t.colIndex+t.colspan-1],a=[o,r];this.setSelector(l,a)}}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:l,SELECTOR_AREA_MAX_Y_OFFSET:a}=this.ctx.config,h=i,d=s||this.ctx.maxColIndex-l,f=o,x=r||this.ctx.maxRowIndex-a,u=[h,d],p=[f,x];this.setSelector(u,p)}}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,l=i;if(e){this.ctx.setFocusCell(t);const a=[l,r],h=[t.rowIndex,t.rowIndex];this.setSelector(a,h)}if(this.ctx.focusCell&&this.ctx.mousedown){const{rowIndex:a}=this.ctx.focusCell;if(t.rowIndex>=a){const h=[l,r],d=[a,t.rowIndex];this.setSelector(h,d)}else{const h=[l,r],d=[t.rowIndex,a];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),l=Math.max(i.colIndex,o),a=Math.min(i.rowIndex,s),h=Math.max(i.rowIndex,s),d=[r,l],f=[a,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:l}=e,a=Math.min(r,s),h=Math.max(r,s),d=Math.min(l,o),f=Math.max(l,o),x=[a,h],u=[d,f];this.setSelector(x,u)}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 l=s({focusCell:this.ctx.focusCell,data:t,xArr:e,yArr:i});if(!l)return;t=l.data}const o=oe(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 a=0;a<=e[1]-e[0];a++)for(let h=0;h<=t[1]-t[0];h++){const d=a+e[0],f=h+t[0],x=this.ctx.database.getItemValueForRowIndexAndColIndex(d,f);if(x){const{rowKey:u,key:p}=x;this.ctx.database.getReadonly(u,p)||(r.add(u),o.push({rowKey:u,key:p,value:s,row:{}}))}}if(!o.length)return[];if(i)return o;this.ctx.database.batchSetItemValue(o,!0);let l=[];return r.forEach(a=>{l.push(this.ctx.database.getRowDataItemForRowKey(a))}),this.ctx.emit("clearSelectedDataChange",o,l),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=se(o);const l=[i,i+r[0].length-1],a=[e,e+r.length-1],[h,d]=a,[f,x]=l,u=d-this.ctx.maxRowIndex,p=x-this.ctx.maxColIndex;(u>0||p>0)&&this.ctx.emit("onPastedDataOverflow",{maxY:d,maxX:x,minY:h,minX:f,overflowRowCount:u,overflowColCount:p,textArr:r});const g=r.length===1&&r[0].length===1;if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.database.hasMergeCell(l,a)&&!g){const m={code:"ERR_MERGED_CELLS_PASTE",message:"Merged cells cannot span paste data"};this.ctx.hasEvent("error")?this.ctx.emit("error",m):alert(m.message);return}let w=[];for(let m=0;m<=r.length-1;m++){const R=r[m].length;for(let C=0;C<=R-1;C++){const v=m+e,_=C+i,S=r[m][C],I=this.ctx.database.getItemValueForRowIndexAndColIndex(v,_);if(I){const{rowKey:b,key:O}=I;this.ctx.database.getReadonly(b,O)||(s.add(b),w.push({rowKey:b,key:O,value:S,row:{}}))}}}if(this.isCut){const m=this.clearSelectedData(this.ctx.selector.xArrCopy,this.ctx.selector.yArrCopy,!0),R=w.map(C=>`${C.rowKey}-${C.key}`);m.forEach(C=>{R.includes(`${C.rowKey}-${C.key}`)||w.unshift(C)}),this.isCut=!1}if(!w.length)return;const{BEFORE_PASTE_DATA_METHOD:E}=this.ctx.config;if(typeof E=="function"){const m=E,R=w.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(w=await m(R,l,a,r),w&&!w.length)return}this.clearCopyLine(),this.ctx.batchSetItemValueByEditor(w,!0);let y=[];s.forEach(m=>{y.push(this.ctx.database.getRowDataItemForRowKey(m))}),this.ctx.emit("pasteChange",w,y)}).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,l=this.ctx.maxColIndex,a=this.ctx.maxRowIndex;switch(t){case"LEFT":i>o&&i--;break;case"TOP":s>r&&s--;break;case"RIGHT":i<l&&i++;break;case"BOTTOM":s<a&&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:l,SELECTOR_AREA_MAX_Y_OFFSET:a}=this.ctx.config,h=i,d=s||this.ctx.maxColIndex-l,f=o,x=r||this.ctx.maxRowIndex-a;return!(e<h||e>d||t<f||t>x)}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 l=10*(s==="left"?-1:1);this.timerX&&(clearInterval(this.timerX),this.timerX=0),this.timerX=setInterval(()=>{l*=1.5;const{scrollX:a}=this.ctx,h=a+l;(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 l=10*(o==="top"?-1:1);this.timerY&&(clearInterval(this.timerY),this.timerY=0),this.timerY=setInterval(()=>{l*=1.5;const{scrollY:a}=this.ctx,h=a+l;(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:l,body:a,scrollX:h,scrollY:d,config:{SCROLLER_TRACK_SIZE:f,FOOTER_FIXED:x,FOOTER_POSITION:u,ENABLE_MERGE_CELL_LINK:p}}=this.ctx;if(!i)return;p&&this.ctx.onlyMergeCell&&i.updateSpanInfo();const{drawX:g,drawY:w,width:E,height:y,fixed:m}=i,R=o-g+1,C=i.drawX+E-(e-s)+1;let v=r.height-w,_=y;_>a.visibleHeight&&(_=a.visibleHeight);let S=0;x&&(u==="top"?v=r.height+l.height-w:S=l.visibleHeight);const I=w+_-(t-S-f);let b=h,O=d;C>0&&!m?b=Math.floor(h+C):R>0&&!m&&(b=Math.floor(h-R)),v>0?O=Math.floor(d-v):I>0&&(O=Math.floor(d+I)),(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 Ce{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:l,width:a,height:h}=this.maxColRowCell,d=6,f=s===this.ctx.maxColIndex||o===this.ctx.maxRowIndex?0:2,x=r+a-d+f,u=l+h-d+f;e>x&&i>u&&e<x+d&&i<u+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:l}=t;this.ctx.config.ENABLE_AUTOFILL&&r===s&&l===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,l=e;if(!o){const[a]=l;l=[a,a]}if(!s){const[a]=r;r=[a,a]}if(JSON.stringify(this.ctx.autofill.xArr)!==JSON.stringify(r)||JSON.stringify(this.ctx.autofill.yArr)!==JSON.stringify(l)){const{SELECTOR_AREA_MIN_X:a,SELECTOR_AREA_MAX_X:h,SELECTOR_AREA_MIN_Y:d,SELECTOR_AREA_MAX_Y:f,SELECTOR_AREA_MAX_X_OFFSET:x,SELECTOR_AREA_MAX_Y_OFFSET:u}=this.ctx.config,p=a,g=h||this.ctx.maxColIndex-x,w=d,E=f||this.ctx.maxRowIndex-u;let[y,m]=r,[R,C]=l;if(y<p||R<w)return;r=[Math.max(p,y),Math.min(g,m)],l=[Math.max(w,R),Math.min(E,C)];const{BEFORE_SET_AUTOFILL_METHOD:v}=this.ctx.config;if(typeof v=="function"){const S=v({focusCell:this.ctx.focusCell,xArr:r,yArr:l});if(!S)return;r=S.xArr,l=S.yArr}this.ctx.autofill.xArr=r,this.ctx.autofill.yArr=l,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 u=0;u<=e.yArr[1]-e.yArr[0];u++)for(let p=0;p<=e.xArr[1]-e.xArr[0];p++){const g=u+e.yArr[0],w=p+e.xArr[0];i.set(`${g}-${w}`,!0)}const{value:s}=e,o=s[0].length,r=s.length,l=this.ctx.autofill.xArr,a=this.ctx.autofill.yArr,h=o===1&&r===1;if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.database.hasMergeCell(l,a)&&!h){const u={code:"ERR_MERGED_CELLS_AUTOFILL",message:"Merged cells cannot span autofill data"};this.ctx.hasEvent("error")?this.ctx.emit("error",u):alert(u.message);return}let d=[];for(let u=0;u<=a[1]-a[0];u++)for(let p=0;p<=l[1]-l[0];p++){const g=p+l[0],w=u+a[0],E=s[u%r][p%o],y=this.ctx.database.getItemValueForRowIndexAndColIndex(w,g),m=`${w}-${g}`;if(y&&!i.has(m)){const{rowKey:R,key:C}=y;this.ctx.database.getReadonly(R,C)||(t.add(R),d.push({rowKey:R,key:C,value:E,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 u=f,p=d.map(g=>({rowKey:g.rowKey,key:g.key,value:g.value,oldValue:this.ctx.database.getItemValue(g.rowKey,g.key),row:this.ctx.database.getRowDataItemForRowKey(g.rowKey)}));if(d=await u(p,l,a),d&&!d.length)return}this.ctx.batchSetItemValueByEditor(d,!0);let x=[];t.forEach(u=>{x.push(this.ctx.database.getRowDataItemForRowKey(u))}),this.ctx.emit("autofillChange",d,x)}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(),l=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]?l.splice(1,1,s):s<e.yArr[0]&&l.splice(0,1,s),this.setAutofill(r,l)}}destroy(){}}const Z=Math.min,z=Math.max,it=Math.round,W=c=>({x:c,y:c}),be={left:"right",right:"left",bottom:"top",top:"bottom"},Re={start:"end",end:"start"};function ht(c,t,e){return z(c,Z(t,e))}function J(c,t){return typeof c=="function"?c(t):c}function P(c){return c.split("-")[0]}function Q(c){return c.split("-")[1]}function Bt(c){return c==="x"?"y":"x"}function gt(c){return c==="y"?"height":"width"}function G(c){return["top","bottom"].includes(P(c))?"y":"x"}function wt(c){return Bt(G(c))}function Ie(c,t,e){e===void 0&&(e=!1);const i=Q(c),s=wt(c),o=gt(s);let r=s==="x"?i===(e?"end":"start")?"right":"left":i==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(r=st(r)),[r,st(r)]}function ve(c){const t=st(c);return[ct(c),t,ct(t)]}function ct(c){return c.replace(/start|end/g,t=>Re[t])}function _e(c,t,e){const i=["left","right"],s=["right","left"],o=["top","bottom"],r=["bottom","top"];switch(c){case"top":case"bottom":return e?t?s:i:t?i:s;case"left":case"right":return t?o:r;default:return[]}}function Oe(c,t,e,i){const s=Q(c);let o=_e(P(c),e==="start",i);return s&&(o=o.map(r=>r+"-"+s),t&&(o=o.concat(o.map(ct)))),o}function st(c){return c.replace(/left|right|bottom|top/g,t=>be[t])}function Se(c){return{top:0,right:0,bottom:0,left:0,...c}}function Kt(c){return typeof c!="number"?Se(c):{top:c,right:c,bottom:c,left:c}}function ot(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 It(c,t,e){let{reference:i,floating:s}=c;const o=G(t),r=wt(t),l=gt(r),a=P(t),h=o==="y",d=i.x+i.width/2-s.width/2,f=i.y+i.height/2-s.height/2,x=i[l]/2-s[l]/2;let u;switch(a){case"top":u={x:d,y:i.y-s.height};break;case"bottom":u={x:d,y:i.y+i.height};break;case"right":u={x:i.x+i.width,y:f};break;case"left":u={x:i.x-s.width,y:f};break;default:u={x:i.x,y:i.y}}switch(Q(t)){case"start":u[r]-=x*(e&&h?-1:1);break;case"end":u[r]+=x*(e&&h?-1:1);break}return u}const Le=async(c,t,e)=>{const{placement:i="bottom",strategy:s="absolute",middleware:o=[],platform:r}=e,l=o.filter(Boolean),a=await(r.isRTL==null?void 0:r.isRTL(t));let h=await r.getElementRects({reference:c,floating:t,strategy:s}),{x:d,y:f}=It(h,i,a),x=i,u={},p=0;for(let g=0;g<l.length;g++){const{name:w,fn:E}=l[g],{x:y,y:m,data:R,reset:C}=await E({x:d,y:f,initialPlacement:i,placement:x,strategy:s,middlewareData:u,rects:h,platform:r,elements:{reference:c,floating:t}});d=y??d,f=m??f,u={...u,[w]:{...u[w],...R}},C&&p<=50&&(p++,typeof C=="object"&&(C.placement&&(x=C.placement),C.rects&&(h=C.rects===!0?await r.getElementRects({reference:c,floating:t,strategy:s}):C.rects),{x:d,y:f}=It(h,x,a)),g=-1)}return{x:d,y:f,placement:x,strategy:s,middlewareData:u}};async function Nt(c,t){var e;t===void 0&&(t={});const{x:i,y:s,platform:o,rects:r,elements:l,strategy:a}=c,{boundary:h="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:x=!1,padding:u=0}=J(t,c),p=Kt(u),w=l[x?f==="floating"?"reference":"floating":f],E=ot(await o.getClippingRect({element:(e=await(o.isElement==null?void 0:o.isElement(w)))==null||e?w:w.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(l.floating)),boundary:h,rootBoundary:d,strategy:a})),y=f==="floating"?{x:i,y:s,width:r.floating.width,height:r.floating.height}:r.reference,m=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating)),R=await(o.isElement==null?void 0:o.isElement(m))?await(o.getScale==null?void 0:o.getScale(m))||{x:1,y:1}:{x:1,y:1},C=ot(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:y,offsetParent:m,strategy:a}):y);return{top:(E.top-C.top+p.top)/R.y,bottom:(C.bottom-E.bottom+p.bottom)/R.y,left:(E.left-C.left+p.left)/R.x,right:(C.right-E.right+p.right)/R.x}}const Te=c=>({name:"arrow",options:c,async fn(t){const{x:e,y:i,placement:s,rects:o,platform:r,elements:l,middlewareData:a}=t,{element:h,padding:d=0}=J(c,t)||{};if(h==null)return{};const f=Kt(d),x={x:e,y:i},u=wt(s),p=gt(u),g=await r.getDimensions(h),w=u==="y",E=w?"top":"left",y=w?"bottom":"right",m=w?"clientHeight":"clientWidth",R=o.reference[p]+o.reference[u]-x[u]-o.floating[p],C=x[u]-o.reference[u],v=await(r.getOffsetParent==null?void 0:r.getOffsetParent(h));let _=v?v[m]:0;(!_||!await(r.isElement==null?void 0:r.isElement(v)))&&(_=l.floating[m]||o.floating[p]);const S=R/2-C/2,I=_/2-g[p]/2-1,b=Z(f[E],I),O=Z(f[y],I),L=b,M=_-g[p]-O,T=_/2-g[p]/2+S,k=ht(L,T,M),K=!a.arrow&&Q(s)!=null&&T!==k&&o.reference[p]/2-(T<L?b:O)-g[p]/2<0,X=K?T<L?T-L:T-M:0;return{[u]:x[u]+X,data:{[u]:k,centerOffset:T-k-X,...K&&{alignmentOffset:X}},reset:K}}}),Ae=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:l,platform:a,elements:h}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:x,fallbackStrategy:u="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...w}=J(c,t);if((e=o.arrow)!=null&&e.alignmentOffset)return{};const E=P(s),y=G(l),m=P(l)===l,R=await(a.isRTL==null?void 0:a.isRTL(h.floating)),C=x||(m||!g?[st(l)]:ve(l)),v=p!=="none";!x&&v&&C.push(...Oe(l,g,p,R));const _=[l,...C],S=await Nt(t,w),I=[];let b=((i=o.flip)==null?void 0:i.overflows)||[];if(d&&I.push(S[E]),f){const T=Ie(s,r,R);I.push(S[T[0]],S[T[1]])}if(b=[...b,{placement:s,overflows:I}],!I.every(T=>T<=0)){var O,L;const T=(((O=o.flip)==null?void 0:O.index)||0)+1,k=_[T];if(k)return{data:{index:T,overflows:b},reset:{placement:k}};let K=(L=b.filter(X=>X.overflows[0]<=0).sort((X,Y)=>X.overflows[1]-Y.overflows[1])[0])==null?void 0:L.placement;if(!K)switch(u){case"bestFit":{var M;const X=(M=b.filter(Y=>{if(v){const F=G(Y.placement);return F===y||F==="y"}return!0}).map(Y=>[Y.placement,Y.overflows.filter(F=>F>0).reduce((F,qt)=>F+qt,0)]).sort((Y,F)=>Y[1]-F[1])[0])==null?void 0:M[0];X&&(K=X);break}case"initialPlacement":K=l;break}if(s!==K)return{reset:{placement:K}}}return{}}}};async function Me(c,t){const{placement:e,platform:i,elements:s}=c,o=await(i.isRTL==null?void 0:i.isRTL(s.floating)),r=P(e),l=Q(e),a=G(e)==="y",h=["left","top"].includes(r)?-1:1,d=o&&a?-1:1,f=J(t,c);let{mainAxis:x,crossAxis:u,alignmentAxis:p}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof p=="number"&&(u=l==="end"?p*-1:p),a?{x:u*d,y:x*h}:{x:x*h,y:u*d}}const He=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:l}=t,a=await Me(t,c);return r===((e=l.offset)==null?void 0:e.placement)&&(i=l.arrow)!=null&&i.alignmentOffset?{}:{x:s+a.x,y:o+a.y,data:{...a,placement:r}}}}},De=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:l={fn:w=>{let{x:E,y}=w;return{x:E,y}}},...a}=J(c,t),h={x:e,y:i},d=await Nt(t,a),f=G(P(s)),x=Bt(f);let u=h[x],p=h[f];if(o){const w=x==="y"?"top":"left",E=x==="y"?"bottom":"right",y=u+d[w],m=u-d[E];u=ht(y,u,m)}if(r){const w=f==="y"?"top":"left",E=f==="y"?"bottom":"right",y=p+d[w],m=p-d[E];p=ht(y,p,m)}const g=l.fn({...t,[x]:u,[f]:p});return{...g,data:{x:g.x-e,y:g.y-i,enabled:{[x]:o,[f]:r}}}}}};function rt(){return typeof window<"u"}function j(c){return Yt(c)?(c.nodeName||"").toLowerCase():"#document"}function A(c){var t;return(c==null||(t=c.ownerDocument)==null?void 0:t.defaultView)||window}function N(c){var t;return(t=(Yt(c)?c.ownerDocument:c.document)||window.document)==null?void 0:t.documentElement}function Yt(c){return rt()?c instanceof Node||c instanceof A(c).Node:!1}function H(c){return rt()?c instanceof Element||c instanceof A(c).Element:!1}function B(c){return rt()?c instanceof HTMLElement||c instanceof A(c).HTMLElement:!1}function vt(c){return!rt()||typeof ShadowRoot>"u"?!1:c instanceof ShadowRoot||c instanceof A(c).ShadowRoot}function tt(c){const{overflow:t,overflowX:e,overflowY:i,display:s}=D(c);return/auto|scroll|overlay|hidden|clip/.test(t+i+e)&&!["inline","contents"].includes(s)}function ke(c){return["table","td","th"].includes(j(c))}function nt(c){return[":popover-open",":modal"].some(t=>{try{return c.matches(t)}catch{return!1}})}function pt(c){const t=Et(),e=H(c)?D(c):c;return e.transform!=="none"||e.perspective!=="none"||(e.containerType?e.containerType!=="normal":!1)||!t&&(e.backdropFilter?e.backdropFilter!=="none":!1)||!t&&(e.filter?e.filter!=="none":!1)||["transform","perspective","filter"].some(i=>(e.willChange||"").includes(i))||["paint","layout","strict","content"].some(i=>(e.contain||"").includes(i))}function Xe(c){let t=V(c);for(;B(t)&&!U(t);){if(pt(t))return t;if(nt(t))return null;t=V(t)}return null}function Et(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function U(c){return["html","body","#document"].includes(j(c))}function D(c){return A(c).getComputedStyle(c)}function lt(c){return H(c)?{scrollLeft:c.scrollLeft,scrollTop:c.scrollTop}:{scrollLeft:c.scrollX,scrollTop:c.scrollY}}function V(c){if(j(c)==="html")return c;const t=c.assignedSlot||c.parentNode||vt(c)&&c.host||N(c);return vt(t)?t.host:t}function Ft(c){const t=V(c);return U(t)?c.ownerDocument?c.ownerDocument.body:c.body:B(t)&&tt(t)?t:Ft(t)}function dt(c,t,e){var i;t===void 0&&(t=[]),e===void 0&&(e=!0);const s=Ft(c),o=s===((i=c.ownerDocument)==null?void 0:i.body),r=A(s);if(o){const l=ft(r);return t.concat(r,r.visualViewport||[],tt(s)?s:[],l&&e?dt(l):[])}return t.concat(s,dt(s,[],e))}function ft(c){return c.parent&&Object.getPrototypeOf(c.parent)?c.frameElement:null}function Wt(c){const t=D(c);let e=parseFloat(t.width)||0,i=parseFloat(t.height)||0;const s=B(c),o=s?c.offsetWidth:e,r=s?c.offsetHeight:i,l=it(e)!==o||it(i)!==r;return l&&(e=o,i=r),{width:e,height:i,$:l}}function Vt(c){return H(c)?c:c.contextElement}function $(c){const t=Vt(c);if(!B(t))return W(1);const e=t.getBoundingClientRect(),{width:i,height:s,$:o}=Wt(t);let r=(o?it(e.width):e.width)/i,l=(o?it(e.height):e.height)/s;return(!r||!Number.isFinite(r))&&(r=1),(!l||!Number.isFinite(l))&&(l=1),{x:r,y:l}}const Be=W(0);function Pt(c){const t=A(c);return!Et()||!t.visualViewport?Be:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ke(c,t,e){return t===void 0&&(t=!1),!e||t&&e!==A(c)?!1:t}function q(c,t,e,i){t===void 0&&(t=!1),e===void 0&&(e=!1);const s=c.getBoundingClientRect(),o=Vt(c);let r=W(1);t&&(i?H(i)&&(r=$(i)):r=$(c));const l=Ke(o,e,i)?Pt(o):W(0);let a=(s.left+l.x)/r.x,h=(s.top+l.y)/r.y,d=s.width/r.x,f=s.height/r.y;if(o){const x=A(o),u=i&&H(i)?A(i):i;let p=x,g=ft(p);for(;g&&i&&u!==p;){const w=$(g),E=g.getBoundingClientRect(),y=D(g),m=E.left+(g.clientLeft+parseFloat(y.paddingLeft))*w.x,R=E.top+(g.clientTop+parseFloat(y.paddingTop))*w.y;a*=w.x,h*=w.y,d*=w.x,f*=w.y,a+=m,h+=R,p=A(g),g=ft(p)}}return ot({width:d,height:f,x:a,y:h})}function Ne(c){let{elements:t,rect:e,offsetParent:i,strategy:s}=c;const o=s==="fixed",r=N(i),l=t?nt(t.floating):!1;if(i===r||l&&o)return e;let a={scrollLeft:0,scrollTop:0},h=W(1);const d=W(0),f=B(i);if((f||!f&&!o)&&((j(i)!=="body"||tt(r))&&(a=lt(i)),B(i))){const x=q(i);h=$(i),d.x=x.x+i.clientLeft,d.y=x.y+i.clientTop}return{width:e.width*h.x,height:e.height*h.y,x:e.x*h.x-a.scrollLeft*h.x+d.x,y:e.y*h.y-a.scrollTop*h.y+d.y}}function Ye(c){return Array.from(c.getClientRects())}function xt(c,t){const e=lt(c).scrollLeft;return t?t.left+e:q(N(c)).left+e}function Fe(c){const t=N(c),e=lt(c),i=c.ownerDocument.body,s=z(t.scrollWidth,t.clientWidth,i.scrollWidth,i.clientWidth),o=z(t.scrollHeight,t.clientHeight,i.scrollHeight,i.clientHeight);let r=-e.scrollLeft+xt(c);const l=-e.scrollTop;return D(i).direction==="rtl"&&(r+=z(t.clientWidth,i.clientWidth)-s),{width:s,height:o,x:r,y:l}}function We(c,t){const e=A(c),i=N(c),s=e.visualViewport;let o=i.clientWidth,r=i.clientHeight,l=0,a=0;if(s){o=s.width,r=s.height;const h=Et();(!h||h&&t==="fixed")&&(l=s.offsetLeft,a=s.offsetTop)}return{width:o,height:r,x:l,y:a}}function Ve(c,t){const e=q(c,!0,t==="fixed"),i=e.top+c.clientTop,s=e.left+c.clientLeft,o=B(c)?$(c):W(1),r=c.clientWidth*o.x,l=c.clientHeight*o.y,a=s*o.x,h=i*o.y;return{width:r,height:l,x:a,y:h}}function _t(c,t,e){let i;if(t==="viewport")i=We(c,e);else if(t==="document")i=Fe(N(c));else if(H(t))i=Ve(t,e);else{const s=Pt(c);i={...t,x:t.x-s.x,y:t.y-s.y}}return ot(i)}function zt(c,t){const e=V(c);return e===t||!H(e)||U(e)?!1:D(e).position==="fixed"||zt(e,t)}function Pe(c,t){const e=t.get(c);if(e)return e;let i=dt(c,[],!1).filter(l=>H(l)&&j(l)!=="body"),s=null;const o=D(c).position==="fixed";let r=o?V(c):c;for(;H(r)&&!U(r);){const l=D(r),a=pt(r);!a&&l.position==="fixed"&&(s=null),(o?!a&&!s:!a&&l.position==="static"&&!!s&&["absolute","fixed"].includes(s.position)||tt(r)&&!a&&zt(c,r))?i=i.filter(d=>d!==r):s=l,r=V(r)}return t.set(c,i),i}function ze(c){let{element:t,boundary:e,rootBoundary:i,strategy:s}=c;const r=[...e==="clippingAncestors"?nt(t)?[]:Pe(t,this._c):[].concat(e),i],l=r[0],a=r.reduce((h,d)=>{const f=_t(t,d,s);return h.top=z(f.top,h.top),h.right=Z(f.right,h.right),h.bottom=Z(f.bottom,h.bottom),h.left=z(f.left,h.left),h},_t(t,l,s));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function $e(c){const{width:t,height:e}=Wt(c);return{width:t,height:e}}function Ge(c,t,e){const i=B(t),s=N(t),o=e==="fixed",r=q(c,!0,o,t);let l={scrollLeft:0,scrollTop:0};const a=W(0);if(i||!i&&!o)if((j(t)!=="body"||tt(s))&&(l=lt(t)),i){const u=q(t,!0,o,t);a.x=u.x+t.clientLeft,a.y=u.y+t.clientTop}else s&&(a.x=xt(s));let h=0,d=0;if(s&&!i&&!o){const u=s.getBoundingClientRect();d=u.top+l.scrollTop,h=u.left+l.scrollLeft-xt(s,u)}const f=r.left+l.scrollLeft-a.x-h,x=r.top+l.scrollTop-a.y-d;return{x:f,y:x,width:r.width,height:r.height}}function at(c){return D(c).position==="static"}function Ot(c,t){if(!B(c)||D(c).position==="fixed")return null;if(t)return t(c);let e=c.offsetParent;return N(c)===e&&(e=e.ownerDocument.body),e}function $t(c,t){const e=A(c);if(nt(c))return e;if(!B(c)){let s=V(c);for(;s&&!U(s);){if(H(s)&&!at(s))return s;s=V(s)}return e}let i=Ot(c,t);for(;i&&ke(i)&&at(i);)i=Ot(i,t);return i&&U(i)&&at(i)&&!pt(i)?e:i||Xe(c)||e}const Ue=async function(c){const t=this.getOffsetParent||$t,e=this.getDimensions,i=await e(c.floating);return{reference:Ge(c.reference,await t(c.floating),c.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function je(c){return D(c).direction==="rtl"}const Ze={convertOffsetParentRelativeRectToViewportRelativeRect:Ne,getDocumentElement:N,getClippingRect:ze,getOffsetParent:$t,getElementRects:Ue,getClientRects:Ye,getDimensions:$e,getScale:$,isElement:H,isRTL:je},Gt=He,Ut=De,jt=Ae,qe=Te,Zt=(c,t,e)=>{const i=new Map,s={platform:Ze,...e},o={...s.platform,_c:i};return Le(c,t,{...s,platform:o})};let Je=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 l={display:"none",position:"absolute",background:e,color:i,boxSizing:"border-box",zIndex:s,padding:"8px",borderRadius:"4px",fontSize:"12px",...o},a={position:"absolute",width:"10px",height:"10px",background:l.background,backgroundColor:l.backgroundColor,transform:"rotate(45deg)",zIndex:l.zIndex};Object.assign(this.arrowEl.style,a),Object.assign(this.floatingEl.style,l),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;Zt({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:[Ut(),jt(),Gt(6),qe({element:this.arrowEl})]}).then(l=>{const{x:a,y:h,placement:d,middlewareData:f}=l;if(Object.assign(this.floatingEl.style,{top:`${h}px`,left:`${a}px`}),f.arrow){const x=f.arrow;["left","left-start","left-end"].includes(d)?Object.assign(this.arrowEl.style,{top:`${x.y}px`,bottom:"",left:"",right:"-5px"}):["right","right-start","right-end"].includes(d)?Object.assign(this.arrowEl.style,{top:`${x.y}px`,bottom:"",left:"-5px",right:""}):["bottom","bottom-start","bottom-end"].includes(d)?Object.assign(this.arrowEl.style,{top:"-5px",bottom:"",left:`${x.x}px`,right:""}):["top","top-start","top-end"].includes(d)&&Object.assign(this.arrowEl.style,{top:"",bottom:"-5px",left:`${x.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 Qe{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:a}=this.ctx;a&&(this.ctx.emit("setSelectorCell",a),this.cellTarget=a),this.doneEdit();return}if((t.altKey||t.metaKey)&&t.code==="Enter"&&this.ctx.editing&&this.inputEl){t.preventDefault();const a=this.inputEl.selectionStart,h=this.inputEl.value.substring(0,a),d=this.inputEl.value.substring(a);this.inputEl.value=h+`
|
|
5
|
-
`+d,this.inputEl.selectionStart=this.inputEl.selectionEnd=a+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("adjustBoundaryPosition",t=>{this.cellTarget=t;const{xArr:e,yArr:i}=this.ctx.selector;this.selectorArrStr=JSON.stringify(e)+JSON.stringify(i)}),this.ctx.on("cellClick",t=>{if(this.ctx.adjustPositioning||!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,[l,a]=s;return!(e<o||e>r||t<l||t>a)}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,l=i-s.height-r;this.editorEl.style.bottom="auto",this.drawY<o.height&&(this.editorEl.style.top=`${o.height-1}px`),this.drawY+t>l&&(this.editorEl.style.left=`${this.drawX-1}px`,this.editorEl.style.top="auto",this.editorEl.style.bottom=`${i-l}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:l,drawX:a}=t;this.drawX=a,this.drawY=l;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 x=this.inputEl.value.length;this.inputEl.setSelectionRange(x,x)}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||(this.ctx.emit("drawView"),!(i.isVerticalVisible()&&i.isHorizontalVisible())))return;const{rowKey:o,key:r,editorType:l}=i;if(l==="none")return;const a=this.ctx.database.getReadonly(o,r);i&&!a&&(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:l}=o,a=this.ctx.database.getReadonly(r,l);o&&!a&&(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("drawView"))}clearEditor(){this.doneEdit(),this.cellTarget=null,this.selectorArrStr="",this.ctx.clearSelector(),this.ctx.focusCell=void 0,this.ctx.emit("drawView")}destroy(){var t;(t=this.editorEl)==null||t.remove()}}class ti{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:l})=>{const a=o+(r+l)/2,h={display:s==="empty"?"block":"none",position:"absolute",fontSize:"14px",color:"#666",left:"50%",top:`${a}px`,transform:"translate(-50%, -50%)",...i};Object.assign(this.emptyEl.style,h)})}destroy(){this.emptyEl.remove()}}class ei{constructor(t){n(this,"ctx");this.ctx=t}draw(){const t=this.getContainer();this.ctx.emit("overlayerChange",t)}destroy(){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:l}=this.ctx.header;let a=[],h=[],d=[];l.forEach(w=>{w.render&&(w.fixed==="left"?h.push(w):w.fixed==="right"?d.push(w):a.push(w))});const f=e-i,x={key:"left",style:{position:"absolute",top:"0px",left:"0px",overflow:"hidden",width:`${t}px`,height:`${r}px`},cells:h},u={key:"center",style:{position:"absolute",top:"0px",left:`${t}px`,overflow:"hidden",width:`${o-t-f+1}px`,height:`${r}px`},cells:a},p={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:[x,u,p]}}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(w=>{w.cells.forEach(E=>{E.cellType==="footer"&&(E.render=E.renderFooter),E.render&&(E.fixed==="left"?e.push(E):E.fixed==="right"?i.push(E):t.push(E))})});const{fixedLeftWidth:o,fixedRightWidth:r,config:{SCROLLER_TRACK_SIZE:l,CSS_PREFIX:a}}=this.ctx,{visibleWidth:h,visibleHeight:d}=this.ctx.body,f=r-l,x={key:"left",style:{position:"absolute",top:`${.5}px`,left:`${.5}px`,overflow:"hidden",width:`${o}px`,height:`${d}px`},cells:e},u={key:"center",style:{position:"absolute",top:`${.5}px`,left:`${o-.5}px`,overflow:"hidden",width:`${h-o-f}px`,height:`${d}px`},cells:t},p={key:"right",style:{position:"absolute",top:"0px",right:"0px",overflow:"hidden",width:`${f}px`,height:`${d}px`},cells:i};return{type:"body",class:`${a}-overlayer-body`,style:{position:"relative",overflow:"hidden",width:`${h}px`,height:`${d}px`},views:[x,u,p]}}getFooter(){const t=[],e=[],i=[];this.ctx.footer.renderRows.forEach(g=>{g.cells.forEach(w=>{w.cellType==="footer"&&w.renderFooter&&(w.render=w.renderFooter,w.fixed==="left"?e.push(w):w.fixed==="right"?i.push(w):t.push(w))})});const{fixedLeftWidth:s,fixedRightWidth:o,config:{SCROLLER_TRACK_SIZE:r,CSS_PREFIX:l}}=this.ctx,{visibleWidth:a,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},x={key:"center",style:{position:"absolute",top:`${.5}px`,left:`${s-.5}px`,overflow:"hidden",width:`${a-s-d}px`,height:`${h}px`},cells:t},u={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:`${l}-overlayer-footer`,style:{position:"relative",overflow:"hidden",width:`${a}px`,height:`${h}px`},views:[f,x,u]}}}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,[l,a]=s,{rowIndex:h,colIndex:d}=t;h>=l&&h<=a&&d>=o&&d<=r||this.ctx.emit("setSelectorCell",t,e);const x={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};Zt(x,this.contextMenuEl,{placement:"right-start",middleware:[Gt(),Ut(),jt()]}).then(({x:u,y:p})=>{this.show(u,p)})}),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 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,"ctx");this.options=e;const{overlayerElement:i,editorElement:s,emptyElement:o,contextMenuElement:r}=e,l=this.createContainer(t,i,s,o,r);this.ctx=new ge(l,this.options),this.header=new pe(this.ctx),this.footer=new me(this.ctx),this.body=new Ee(this.ctx),this.scroller=new we(this.ctx),this.selector=new ye(this.ctx),this.autofill=new Ce(this.ctx),this.tooltip=new Je(this.ctx),this.empty=new ti(this.ctx),this.editor=new Qe(this.ctx),this.overlayer=new ei(this.ctx),this.contextMenu=new ii(this.ctx),this.ctx.on("draw",()=>{this.draw()}),this.ctx.on("drawView",()=>{this.draw(!0)}),this.draw()}createContainer(t,e,i,s,o){t.className="e-virt-table-container";const r=document.createElement("div"),l=document.createElement("canvas"),a=e||document.createElement("div");r.className="e-virt-table-stage",t.tabIndex=0,l.className="e-virt-table-canvas",a.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(l),r.appendChild(a),t.appendChild(r),{containerElement:t,stageElement:r,canvasElement:l,overlayerElement:a,editorElement:h,emptyElement:d,contextMenuElement:f}}draw(t=!1){requestAnimationFrame(()=>{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()})}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.database.setLoading(t)}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:l,key:a}=t[r],h=await this.ctx.database.getValidator(l,a);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[l]=r,{rowKey:a,key:h}=l;this.scrollToRowkey(a),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:l,key:a}=r,h=this.ctx.database.getRowForRowKey(l);if(h){const{parentRowKeys:d=[]}=h;d&&d.length&&this.setExpandRowKeys(d,!0)}this.scrollToRowkey(l),this.scrollToColkey(a)}}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 l=0;l<s.length;l++){const a=this.ctx.database.getRowKeyByItem(i[r]),d=s[l].key,f=await this.ctx.database.getValidator(a,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)}contextMenuHide(){this.contextMenu.hide()}getUtils(){return{mergeColCell:ne,mergeRowCell:re,getSpanArrByRow:Mt,getSpanObjByColumn:Ht}}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.ctx.destroy(),this.ctx.containerElement.remove()}}module.exports=si;
|
|
4
|
+
`)}return o}function Ht(c,t,e=[]){let i=0;const s=[];return c.forEach((o,r)=>{if(r===0)s.push(1);else{const l=e.reduce((h,d)=>`${h}${o[d]??""}`,"")||o[t],a=e.reduce((h,d)=>`${h}${c[r-1][d]??""}`,"")||c[r-1][t];l===a?(s[i]+=1,s.push(0)):(s.push(1),i=r)}}),s}function Dt(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 ae(c,t,e=[]){const{visibleRows:i,rowIndex:s,headIndex:o}=c,r=Ht(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 he(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=Dt(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 ce(c,t=document.documentElement){const e=c.startsWith("--")?c:`--${c}`;return getComputedStyle(t).getPropertyValue(e).trim()}class kt{constructor(t,e,i,s,o,r,l){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=l,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 ft extends kt{constructor(e,i,s,o,r,l,a,h,d,f="body"){super(e,o,r,l,a,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,"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,"drawImageX",0);n(this,"drawImageY",0);n(this,"drawImageWidth",0);n(this,"drawImageHeight",0);n(this,"drawImageName","");n(this,"drawImageSource");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");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||"center",this.verticalAlign=h.verticalAlign||"middle",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.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.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.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:l,mergeRow:a=!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(l)&&l.length>0?this.relationColKeys=l:this.relationColKeys=[this.key],this.mergeCol=h,this.mergeRow=a,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.style=this.getOverlayerViewsStyle()}updateTree(){const{CELL_PADDING:e=0}=this.ctx.config,{rowKey:i,cellType:s}=this;let o,r=0,l="";if(this.type==="tree"&&s==="body"){const a=this.ctx.database.getRowForRowKey(i),{expand:h=!1,hasChildren:d=!1,expandLoading:f=!1,level:x=0}=a||{};if(this.rowExpand=h,this.rowHasChildren=d,f){const g=this.ctx.icons.get("loading");l="loading",o=g,r=x*8}else if(d){const g=this.ctx.icons.get("expand"),w=this.ctx.icons.get("shrink");o=h?w:g,l=h?"shrink":"expand",r=x*8}else r=x*8;let u=20,p=20;if(o){let g=this.drawX+r+e,w=this.drawY+(this.visibleHeight-p)/2;this.ctx.paint.drawImage(o,g,w,u,p),this.drawImageX=g,this.drawImageY=w,this.drawImageWidth=u,this.drawImageHeight=p,this.drawImageName=l,this.drawImageSource=o}this.align="left",this.drawTextX=r+this.drawX+u-.5}}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:l,FOOTER_TEXT_COLOR:a,FOOTER_BG_COLOR:h,HIGHLIGHT_SELECTED_ROW:d,HIGHLIGHT_SELECTED_ROW_COLOR:f,HIGHLIGHT_HOVER_ROW:x,HIGHLIGHT_HOVER_ROW_COLOR:u,STRIPE:p,STRIPE_COLOR:g}=this.ctx.config;if(this.cellType==="footer"){let _=h,S=a;if(typeof o=="function"){const v=o,{backgroundColor:b,color:O}=v({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()})||{};b&&(_=b),O&&(S=O)}this.drawCellSkyBgColor="transparent",this.drawCellBgColor=_,this.drawTextColor=S;return}let w="transparent";const E=this.ctx.hoverCell,y=this.ctx.currentCell;let m=this.rowIndex,R=this.rowIndex;if(this.rowspan!==1&&(x||d)){const _=this.getSpanInfo(),{yArr:S}=_;m=S[0],R=S[1]}x&&E&&(E.rowKey===this.rowKey&&(w=u),E.rowIndex>=m&&E.rowIndex<=R&&(w=u)),d&&y&&(y.rowKey===this.rowKey&&(w=f),y.rowIndex>=m&&y.rowIndex<=R&&(w=f)),this.drawCellSkyBgColor=w;let C=e,I=l;if(this.ctx.database.getReadonly(this.rowKey,this.key)||(C=i,I=r),p&&(this.rowIndex%2?C=g:C=e),typeof s=="function"){const _=s,{backgroundColor:S,color:v}=_({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,isHasChanged:this.isHasChanged,value:this.getValue()})||{};S&&(C=S),v&&(I=v)}this.drawCellBgColor=C,this.drawTextColor=I}updateSelection(){const{visibleWidth:e,visibleHeight:i,rowspan:s,colspan:o,cellType:r,type:l,rowIndex:a,rowKey:h}=this;if(!(s===0||o===0)&&r!=="footer"&&["index-selection","selection"].includes(l)){const d=this.ctx.database.getRowSelection(h),f=this.ctx.database.getRowSelectable(h),{CHECKBOX_SIZE:x=0}=this.ctx.config,u=this.drawX+(e-x)/2,p=this.drawY+(i-x)/2;let g=this.ctx.icons.get("checkbox-uncheck"),w="checkbox-uncheck";d&&f?(g=this.ctx.icons.get("checkbox-check"),w="checkbox-check"):d&&f?(g=this.ctx.icons.get("checkbox-check-disabled"),w="checkbox-check-disabled"):!d&&f?(g=this.ctx.icons.get("checkbox-uncheck"),w="checkbox-uncheck"):(g=this.ctx.icons.get("checkbox-disabled"),w="checkbox-disabled"),g&&l=="index-selection"?(this.ctx.hoverCell&&this.ctx.hoverCell.rowIndex===a||["checkbox-disabled","checkbox-check"].includes(w))&&(this.drawImageX=u,this.drawImageY=p,this.drawImageWidth=x,this.drawImageHeight=x,this.drawImageName=w,this.drawImageSource=g):g&&l==="selection"&&(this.drawImageX=u,this.drawImageY=p,this.drawImageWidth=x,this.drawImageHeight=x,this.drawImageName=w,this.drawImageSource=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:l}=this.ctx;if(this.hoverIconName&&!this.ctx.editing&&l){let a=0,h=0;if(l.rowKey===this.rowKey&&(a=this.drawX+this.width-s-o,h=this.drawY+(this.height-s)/2),this.rowspan!==1&&r){const f=this.getSpanInfo(),{yArr:x}=f,u=x[0],p=x[1];if(l.rowIndex>=u&&l.rowIndex<=p){const{width:g,height:w,offsetTop:E,offsetLeft:y}=f;a=this.drawX-y+g-s-o,h=this.drawY-E+(w-s)/2}}const d=this.ctx.icons.get(this.hoverIconName);this.drawImageX=a,this.drawImageY=h,this.drawImageWidth=s,this.drawImageHeight=s,this.drawImageName=this.hoverIconName,this.drawImageSource=d}}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.drawImageName))||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`),{position:"absolute",overflow:"hidden",left:e,top:i,width:`${this.visibleWidth}px`,height:`${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:l}=this.ctx.selector,a=r[1],h=l[1],{colIndex:d,rowIndex:f,drawX:x,drawY:u}=this;if(d===a&&f===h){const g=d===this.ctx.maxColIndex||f===this.ctx.maxRowIndex||d===this.ctx.lastCenterColIndex?6:4;this.ctx.paint.drawRect(x+this.width-g,u+this.height-g,6,6,{borderColor:o,fillColor:e})}}draw(){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}=this.ctx.config;let o=this.visibleWidth;if(this.type==="tree"){const f=this.drawTextX-this.drawX;o=this.visibleWidth-f}const{ellipsis:r}=this.ctx.paint.handleEllipsis(this.displayText,o,e,i);this.ellipsis=r;const{placeholder:l}=this.column;let a=this.displayText,h=this.drawTextColor;return!this.ctx.database.getReadonly(this.rowKey,this.key)&&l&&["",null,void 0].includes(this.text)&&this.cellType==="body"&&!(this.rowspan===0||this.colspan===0)&&(a=l,h=s),this.ctx.paint.drawText(a,this.drawTextX,this.drawTextY,o,this.visibleHeight,{font:i,padding:e,align:this.align,verticalAlign:this.verticalAlign,color:h})}drawImage(){if(this.drawImageSource){if(this.hoverIconName){const{CELL_HOVER_ICON_BG_COLOR:e,CELL_HOVER_ICON_BORDER_COLOR:i}=this.ctx.config;this.ctx.paint.drawRect(this.drawImageX-2,this.drawImageY-2,this.drawImageWidth+4,this.drawImageHeight+4,{borderColor:i,radius:4,borderWidth:1,fillColor:e})}this.ctx.paint.drawImage(this.drawImageSource,this.drawImageX,this.drawImageY,this.drawImageWidth,this.drawImageHeight)}}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[l,a]=i,[h,d]=s;!(l===a&&h===d)&&this.colIndex>=l&&this.colIndex<=a&&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,l=[o+s-e-.5,r,o+s-.5,r,o+s-.5,r+e];this.ctx.paint.drawLine(l,{borderColor:i,fillColor:i,borderWidth:1,lineCap:"round",lineJoin:"round"})}drawBorder(e){const{drawX:i,drawY:s,rowIndex:o,colIndex:r,height:l,width:a}=this;let h=i,d=s;const{xArr:f,yArr:x,lineDash:u=[],borderWidth:p=1,borderColor:g,fillColor:w}=e,E=f[0],y=f[1],m=x[0],R=x[1];if(r>=E&&r<=y&&o===m){const C=r===y?1:0,I=r===E?1:0;this.ctx.paint.drawLine([h+I,d+1,h+a-C,d+1],{borderColor:g,fillColor:w,borderWidth:p,lineCap:"round",lineJoin:"round",lineDash:u})}if(r===y&&o>=m&&o<=R){const C=o===m?1:0,I=o===R?1:0;this.ctx.paint.drawLine([h+a-1,d+C,h+a-1,d+l-I],{borderColor:g,fillColor:w,borderWidth:p,lineCap:"round",lineJoin:"round",lineDash:u})}if(r>=E&&r<=y&&o===R){const C=r===y?1:0,I=r===E?1:0;this.ctx.paint.drawLine([h+I,d+l-1,h+a-C,d+l-1],{borderColor:g,fillColor:w,borderWidth:p,lineCap:"round",lineJoin:"round",lineDash:u})}if(r===E&&o>=m&&o<=R){const C=o===R?1:0,I=o===m?1:0;this.ctx.paint.drawLine([h+1,d+I,h+1,d+l-C],{borderColor:g,fillColor:w,borderWidth:p,lineCap:"round",lineJoin:"round",lineDash:u})}}}class de{constructor(t,e){n(this,"loading",!1);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,"bufferCheckState",{buffer:!1,check:!1,indeterminate:!1,selectable:!0});n(this,"sumHeight",0);n(this,"filterMethod");n(this,"positions",[]);this.ctx=t;const{data:i=[],columns:s=[],footerData:o=[]}=e;this.data=i,this.footerData=o,this.columns=s,this.setLoading(!0),this.init()}init(t=!0){this.clearBufferData(),this.rowKeyMap.clear(),this.checkboxKeyMap.clear(),this.colIndexKeyMap.clear(),this.rowIndexRowKeyMap.clear(),this.rowKeyRowIndexMap.clear();const e=this.getColumns(),i=et(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=[]){t.forEach((s,o)=>{var E;const{ROW_KEY:r="",DEFAULT_EXPAND_ALL:l,CELL_HEIGHT:a,SELECTABLE_METHOD:h,CHECKBOX_KEY:d}=this.ctx.config,f=s[r],x=f!=null?`${f}`:Lt();this.itemRowKeyMap.set(s,x);const u=s._height||a,p=s._readonly;let g=!0;if(typeof h=="function"&&(g=h),d){const y=s[d];if(this.checkboxKeyMap.has(y)){const m=this.checkboxKeyMap.get(y)||[];m.push(x),this.checkboxKeyMap.set(y,m)}else this.checkboxKeyMap.set(y,[x])}this.selectionMap.set(x,{key:d?s[d]:x,row:s,check:((E=this.selectionMap.get(x))==null?void 0:E.check)||!1});const w=l||this.expandMap.get(x)||s._expand||!1;this.expandMap.set(x,w),this.rowKeyMap.set(x,{readonly:p,index:o,rowIndex:o,level:e,height:u,check:!1,selectable:g,expand:w,expandLazy:!1,hasChildren:s._hasChildren||(Array.isArray(s.children)?s.children.length>0:!1),expandLoading:!1,item:s,parentRowKeys:i}),Array.isArray(s.children)&&s.children.length&&this.initData(s.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()}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.columns.length&&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 l=this.itemRowKeyMap.get(r),{expand:a,hasChildren:h,height:d}=this.rowKeyMap.get(l),f=this.sumHeight;this.sumHeight+=d,this.rowIndexRowKeyMap.set(e,l),this.rowKeyRowIndexMap.set(l,e),this.positions.push({top:f,height:d,bottom:this.sumHeight}),e+=1,a&&h&&i(r.children)})};this.rowIndexRowKeyMap.clear(),this.rowKeyRowIndexMap.clear();let s=this.data;return typeof this.filterMethod=="function"&&(s=this.filterMethod(s)),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}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 l=new Set;let a=[],h=t.map(u=>{const{rowKey:p,key:g}=u;let w=u.value,E=w;const y=this.getRowDataItemForRowKey(p),m=this.getItemValue(p,g),R=this.getVirtualBodyCellByKey(p,g);return(R==null?void 0:R.type)==="number"&&(["",void 0,null].includes(w)?E=null:/^-?\d+(\.\d+)?$/.test(`${w}`)?E=Number(w):(E=m,a.push({...u,value:E,oldValue:m,row:y}))),{...u,value:E,oldValue:m,row:y}});if(h=h.filter(u=>!a.some(p=>u.rowKey===p.rowKey&&u.key===p.key)),a.length){const u={code:"ERR_BATCH_SET_NUMBER_VALUE",message:"Assignment failed, not a numeric type",data:a};this.ctx.emit("error",u)}if(!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(u=>{const{value:p,rowKey:g,key:w}=u,E=this.getItemValue(g,w);l.add(g),this.setItemValue(g,w,p,!1,!1,!1,r),o.push({rowKey:g,key:w,oldValue:E,newValue:p})});let f=[];l.forEach(u=>{f.push(this.ctx.database.getRowDataItemForRowKey(u))});const x=h.map(({rowKey:u,key:p})=>this.getValidator(u,p));Promise.all(x).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,l=!0){if(!this.rowKeyMap.has(t))return{};const{item:a}=this.rowKeyMap.get(t);let h=a[e],d=i;if(l&&this.ctx.database.getReadonly(t,e))return{oldValue:h,newValue:h};a[e]!==null&&typeof a[e]=="object"&&(h=JSON.parse(JSON.stringify(a[e])));const f=`${t}_${e}`;this.originalDataMap.has(f)||this.originalDataMap.set(f,h);const x=this.originalDataMap.get(f),u=this.getRowDataItemForRowKey(t);if(r){const p=this.getVirtualBodyCellByKey(t,e);if((p==null?void 0:p.type)==="number")if(["",void 0,null].includes(i))d=null;else if(/^-?\d+(\.\d+)?$/.test(`${i}`))d=Number(i);else{d=h;const w={code:"ERR_SET_NUMBER_VALUE",message:"Assignment failed, not a numeric type",data:[{rowKey:t,key:e,value:d,oldValue:h,row:u}]};this.ctx.emit("error",w)}if(d===h)return{oldValue:h,newValue:h};let g=[{rowKey:t,key:e,value:d,oldValue:h,row:u}];this.batchSetItemValue(g,s,!1),this.ctx.emit("editChange",{rowKey:t,key:e,oldValue:h,value:d,originalValue:x,row:u})}else this.changedDataMap.set(f,d),a[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:u}),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(l=>{const a=this.selectionMap.get(l);a&&(a.check=e)})}}toggleRowSelection(t){const e=this.rowKeyMap.get(t),i=this.selectionMap.get(t);if(!i)return;i.check=!i.check,this.setRowSelectionByCheckboxKey(t,i.check),this.ctx.emit("toggleRowSelection",e);const s=this.getSelectionRows();this.ctx.emit("selectionChange",s),this.bufferCheckState.buffer=!1,this.ctx.emit("draw")}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),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}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.rowKeyMap.forEach((e,i)=>{let s=e.selectable;typeof s=="function"&&(s=s({row:e.item,rowIndex:e.rowIndex})),s&&this.setRowSelection(i,!0,!1)});const t=this.getSelectionRows();this.ctx.emit("toggleAllSelection",t),this.ctx.emit("selectionChange",t),this.bufferCheckState.buffer=!1,this.ctx.emit("draw")}clearSelection(t=!1){t?this.rowKeyMap.forEach((i,s)=>{this.setRowSelection(s,!1,!1)}):(this.selectionMap.clear(),this.rowKeyMap.forEach((i,s)=>{this.selectionMap.set(s,{check:!1,row:i.item,key:s})}));const e=this.getSelectionRows();this.ctx.emit("clearSelection"),this.ctx.emit("selectionChange",e),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,l=Array.from(this.selectionMap.values()).some(x=>x.check);this.rowKeyMap.forEach((x,u)=>{var g;(g=this.selectionMap.get(u))!=null&&g.check&&(s+=1);let p=x.selectable;typeof p=="function"&&(p=p({row:x.item,rowIndex:x.rowIndex})),p&&(o+=1)});const a=r>i&&s===0&&l,h=o&&o>s&&s>0||a,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}}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,l=o.readonly,{BODY_CELL_READONLY_METHOD:a}=this.ctx.config;if(typeof a=="function"&&o){const d=a({row:s.item,rowIndex:s.rowIndex,colIndex:o.colIndex,column:o.column,value:this.getItemValue(t,e)});if(d!==void 0)return d}return l||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 l=o.column;let a=l.rules;if(typeof r=="function"){const d=r({row:s.item,rowIndex:s.rowIndex,colIndex:o.colIndex,column:l,value:this.getItemValue(t,e)});d&&(a=d)}if(a){const h={row:s.item,rowIndex:s.rowIndex,colIndex:o.colIndex,column:l,key:e,rowKey:t,value:this.getItemValue(t,e),field:e,fieldValue:this.getItemValue(t,e)},f=new se(a).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:l,relationRowKeys:a,relationColKeys:h,rowspan:d,height:f,width:x,colspan:u,mergeRow:p,mergeCol:g}=t;if(d===1&&u===1)return{xArr:[l,l],yArr:[e,e],rowspan:d,colspan:u,height:f,width:x,offsetTop:0,offsetLeft:0,dataList:[{rowKey:s,key:i,row:o,value:r}]};let w=e,E=e,y=l,m=l,R=[],C=0,I=0,_=0,S=0;if(d!==1&&p){S=x;const v=a.reduce((b,O)=>{const L=this.getItemValue(s,O)??"";return`${b}${L}`},"");for(let b=e-1;b>=0;b--){const O=this.rowIndexRowKeyMap.get(b)||"",L=a.reduce((M,T)=>{const H=this.getItemValue(O,T)??"";return`${M}${H}`},"");if(v===L)w=b;else break}for(let b=e;b<=this.ctx.maxRowIndex;b++){const O=this.rowIndexRowKeyMap.get(b)||"",L=a.reduce((M,T)=>{const H=this.getItemValue(O,T)??"";return`${M}${H}`},"");if(v===L)E=b;else break}for(let b=w;b<e;b++){const{height:O}=this.positions[b];C+=O}for(let b=w;b<=E;b++){const{height:O}=this.positions[b];_+=O;const L=this.rowIndexRowKeyMap.get(b)||"",{item:M}=this.rowKeyMap.get(L),T=this.getItemValue(L,i);R.push({rowKey:L,key:i,value:T,row:M})}}if(u!==1&&g){_=f;for(let v=l-1;v>=0;v--){const b=this.getColumnByColIndex(v);if(!b)break;const O=this.getItemValue(s,i),L=this.getItemValue(s,b.key);if(O===L&&h.includes(b.key))y=v;else break}for(let v=l;v<=this.ctx.maxColIndex;v++){const b=this.getColumnByColIndex(v);if(!b)break;const O=this.getItemValue(s,i),L=this.getItemValue(s,b.key);if(O===L&&h.includes(b.key))m=v;else break}for(let v=y;v<l;v++){const b=this.getColumnByColIndex(v);if(!b)break;I+=b.width||100}for(let v=y;v<=m;v++){const b=this.getColumnByColIndex(v);if(!b)break;S+=b.width||100,R.push({rowKey:s,key:b.key,value:this.getItemValue(s,b.key),row:o})}}return{xArr:[y,m],yArr:[w,E],rowspan:d,colspan:u,height:_,width:S,offsetTop:C,offsetLeft:I,dataList:R}}setLoading(t){this.loading=t,this.ctx.emit("loadingChange",t)}getLoading(){return this.loading}setValidationErrorByRowIndex(t,e,i){const s=this.rowIndexRowKeyMap.get(t),o=`${s}_${e}`,r=this.getRowForRowIndex(t),l=this.getColumnByKey(e);if(!s||!l||!r)return;const a=this.getItemValue(s,e),h=[{key:e,rowKey:s,rowIndex:t,colIndex:l.colIndex,column:l.column,row:r,value:a,message:i,field:e,fieldValue:a}];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 ft(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}}class fe{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 xe{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 ue{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 ge{constructor(t){n(this,"ctx");const e=t.getContext("2d");if(!e)throw new Error("canvas context not found");this.ctx=e}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:l,shadowWidth:a,colorStart:h,colorEnd:d}=o;this.ctx.save(),r&&(this.ctx.fillStyle=r,this.ctx.fillRect(t,e,i,s));let f;switch(l){case"left":f=this.ctx.createLinearGradient(t-a,e,t,e),f.addColorStop(0,h),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t-a,e,a,s);break;case"right":f=this.ctx.createLinearGradient(t+i,e,t+i+a,e),f.addColorStop(0,h),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t+i,e,a,s);break;case"top":f=this.ctx.createLinearGradient(t,e-a,t,e),f.addColorStop(0,h),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t,e-a,i,a);break;case"bottom":f=this.ctx.createLinearGradient(t,e+s,t,e+s+a),f.addColorStop(0,h),f.addColorStop(1,d),this.ctx.fillStyle=f,this.ctx.fillRect(t,e+s,i,a);break;default:console.error("Invalid side specified for shadow");break}}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=4,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:l,radius:a=0}={}){if(this.ctx.save(),this.ctx.beginPath(),l!==void 0&&(this.ctx.fillStyle=l),r!==void 0&&(this.ctx.lineWidth=o,this.ctx.strokeStyle=r),a===0)this.ctx.rect(t-.5,e-.5,i,s);else{const[h,d,f,x]=typeof a=="number"?[a,a,a,a]:a;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-x,x),this.ctx.arcTo(t,e,t+h,e,h)}l!==void 0&&this.ctx.fill(),r!==void 0&&this.ctx.stroke(),this.ctx.restore()}drawText(t="",e,i,s,o,r={}){this.ctx.save();const{font:l="12px Arial",align:a="center",color:h="#495060",padding:d=0,verticalAlign:f="middle"}=r;this.ctx.font=l,this.ctx.fillStyle=h,this.ctx.textBaseline=f,this.ctx.textAlign=a;let x=0;f==="top"?x=i+d:f==="bottom"?x=i+o-d:x=i+(o+1)/2;let u=0;a==="left"?u=e+d:a==="right"?u=e+s-d:u=e+s/2;const{_text:p,ellipsis:g}=this.handleEllipsis(t,s,d,l);return this.ctx.fillText(p,u,x),this.ctx.restore(),g}handleEllipsis(t,e,i=0,s="12px Arial"){let o=!1,r=t;if(this.ctx.font=s,t==null||t==="")return{_text:"",ellipsis:o};const l=this.ctx.measureText("...").width,a=this.ctx.measureText(t).width;if(a&&a+l>=e-i*2){o=!0;let h=0;for(let d=0;d<t.length;d++)if(h+=this.ctx.measureText(t[d]).width,h>=e-i*2-l){r=t.slice(0,d)+"...";break}}return{_text:r,ellipsis:o}}}class yt{constructor(t){n(this,"_config",{});n(this,"CSS_PREFIX","e-virt-table");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,"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,"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,"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_CHECK_SVG","");n(this,"CHECKBOX_UNCHECK_SVG","");n(this,"CHECKBOX_INDETERMINATE_SVG","");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,"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,"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=ce(i);t[e]=s}}),Object.assign(this,t,this._config)}}const Ct='<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>';class we{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:"CHECKBOX_UNCHECK_SVG",configColorName:"SHRINK_ICON_COLOR",svg:Ct,color:"#4E5969"},{name:"checkbox-uncheck",configName:"CHECKBOX_UNCHECK_SVG",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" fill="#DDE0EA" p-id="4709"></path></svg>',color:""},{name:"checkbox-check",configName:"CHECKBOX_CHECK_SVG",configColorName:"CHECKBOX_COLOR",svg:'<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>',color:"rgb(82,146,247)"},{name:"checkbox-hover",configName:"CHECKBOX_UNCHECK_SVG",configColorName:"CHECKBOX_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" fill="#DDE0EA" p-id="4709"></path></svg>',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_SVG",svg:'<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>',color:"#DDE0EA"},{name:"checkbox-disabled",configName:"CHECKBOX_DISABLED_SVG",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" fill="#F1F2F4" 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:""},{name:"icon-edit",configName:"CHECKBOX_DISABLED_SVG",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:"CHECKBOX_UNCHECK_SVG",configColorName:"SHRINK_ICON_COLOR",svg:Ct,color:"#4E5969"}]);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 l=this.ctx.config[i.configColorName];l&&(s=l)}if(i.configName){const l=this.ctx.config[i.configName];l&&(o=l)}const r=this.createImageFromSVG(o,s).then(l=>{this.icons.set(i.name,l)});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=>{h.setAttribute("fill",e)});const l=new Image;let a="";if(i){const h=new Blob([new XMLSerializer().serializeToString(r)],{type:"image/svg+xml"});a=URL.createObjectURL(h)}else a="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(new XMLSerializer().serializeToString(r));return l.src=a,new Promise((h,d)=>{l.onerror=()=>d(new Error("Failed to load image")),l.onload=()=>{h(l)}})}get(t){return this.icons.get(t)}}class Xt extends kt{constructor(e,i,s,o,r,l,a){super(e,s,o,r,l,"header",a.fixed);n(this,"align");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,"visibleWidth",0);n(this,"visibleHeight",0);n(this,"drawCellBgColor","");n(this,"drawTextColor","");n(this,"drawImageX",0);n(this,"drawImageY",0);n(this,"drawImageWidth",0);n(this,"drawImageHeight",0);n(this,"drawImageName","");n(this,"drawImageSource");this.ctx=e,this.x=s,this.y=o,this.width=r,this.height=l,this.visibleWidth=r,this.visibleHeight=l,this.colIndex=i,this.key=a.key,this.minWidth=a.minWidth,this.maxWidth=a.maxWidth,this.type=a.type||"",this.editorType=a.editorType||"text",this.align=a.align||"center",this.verticalAlign=a.verticalAlign||"middle",this.fixed=a.fixed,this.level=a.level||0,this.operation=a.operation||!1,this.text=a.title,this.column=a,this.colspan=a.colspan||1,this.widthFillDisable=a.widthFillDisable||!1,this.rowspan=a.rowspan||1,this.rules=a.rules,this.readonly=a.readonly||!1,this.required=a.required||!1,this.rowKey=Lt(),this.overflowTooltipShow=a.overflowTooltipHeaderShow!==!1,this.hasChildren=a.children&&a.children.length>0||!1,this.render=a.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 l=e,{backgroundColor:a,color:h}=l({colIndex:this.colIndex,column:this.column})||{};a&&(o=a),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.updateStyle()}draw(){const{paint:e,config:{BORDER_COLOR:i,CELL_PADDING:s,HEADER_FONT:o,BORDER:r}}=this.ctx,{drawX:l,drawY:a,displayText:h}=this;e.drawRect(l,a,this.width,this.height,{borderColor:r?i:"transparent",fillColor:this.drawCellBgColor}),this.ellipsis=e.drawText(h,l,a,this.width,this.height,{font:o,padding:s,color:this.drawTextColor,align:this.align,verticalAlign:this.verticalAlign}),this.drawSelection(),this.drawSelector()}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(){const{width:e,height:i,type:s}=this;if(["index-selection","selection"].includes(s)){const{indeterminate:o,check:r,selectable:l}=this.ctx.database.getCheckedState(),{CHECKBOX_SIZE:a=0}=this.ctx.config,h=this.drawX+(e-a)/2,d=this.drawY+(i-a)/2;let f=this.ctx.icons.get("checkbox-uncheck"),x="checkbox-uncheck";o?(f=this.ctx.icons.get("checkbox-indeterminate"),x="checkbox-indeterminate"):r&&l?(f=this.ctx.icons.get("checkbox-check"),x="checkbox-check"):r&&l?(f=this.ctx.icons.get("checkbox-check-disabled"),x="checkbox-check-disabled"):!r&&l?(f=this.ctx.icons.get("checkbox-uncheck"),x="checkbox-uncheck"):(f=this.ctx.icons.get("checkbox-disabled"),x="checkbox-disabled"),f&&(this.drawImageX=h,this.drawImageY=d,this.drawImageWidth=a,this.drawImageHeight=a,this.drawImageName=x,this.drawImageSource=f,this.ctx.paint.drawImage(this.drawImageSource,this.drawImageX,this.drawImageY,this.drawImageWidth,this.drawImageHeight))}}getText(){return this.render?"":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 pe{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("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)}),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{this.ctx.clickCell=s,this.ctx.emit("cellClick",s,t),this.selectionClick(s),this.treeClick(s),this.hoverIconClick(s)})}),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.selectionEnterAndLeave(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){if(["selection","index-selection"].includes(t.type)&&this.ctx.isPointer)if(t instanceof Xt)t.drawImageName==="checkbox-uncheck"||t.drawImageName==="checkbox-indeterminate"?this.ctx.database.toggleAllSelection():t.drawImageName==="checkbox-check"&&this.ctx.database.clearSelection(!0);else{if(!this.ctx.database.getRowSelectable(t.rowKey))return;this.ctx.database.toggleRowSelection(t.rowKey)}}treeClick(t){if(t.type==="tree"&&this.ctx.isPointer){const e=this.ctx.database.getRowForRowKey(t.rowKey),{expand:i=!1,expandLazy:s=!1}=e||{},{EXPAND_LAZY:o,EXPAND_LAZY_METHOD:r}=this.ctx.config;if(o&&r&&!i&&!s)typeof r=="function"&&(this.ctx.database.expandLoading(t.rowKey,!0),r({row:t.row,rowIndex:t.rowIndex,colIndex:t.colIndex,column:t.column,value:t.getValue()}).then(a=>{this.ctx.database.setExpandChildren(t.rowKey,a),this.ctx.database.expandLoading(t.rowKey,!1),this.ctx.emit("expandChange",this.ctx.database.getExpandRowKeys())}).catch(a=>{this.ctx.database.expandLoading(t.rowKey,!1),console.error(a)}));else{const l=this.ctx.database.getIsExpand(t.rowKey);this.ctx.database.expandItem(t.rowKey,!l),this.ctx.emit("expandChange",this.ctx.database.getExpandRowKeys())}}}imageEnterAndLeave(t,e){const{offsetY:i,offsetX:s}=this.ctx.getOffset(e),o=i,r=s;r>t.drawImageX&&r<t.drawImageX+t.drawImageWidth&&o>t.drawImageY&&o<t.drawImageY+t.drawImageHeight&&(this.ctx.stageElement.style.cursor="pointer",this.ctx.isPointer=!0)}selectionEnterAndLeave(t,e){const{offsetY:i,offsetX:s}=this.ctx.getOffset(e),o=i,r=s;r>t.drawImageX&&r<t.drawImageX+t.drawImageWidth&&o>t.drawImageY&&o<t.drawImageY+t.drawImageHeight&&t instanceof ft&&["selection","index-selection"].includes(t.type)&&(this.ctx.stageElement.style.cursor="pointer",this.ctx.isPointer=!0,this.ctx.database.getRowSelectable(t.rowKey)||(this.ctx.stageElement.style.cursor="not-allowed"))}isBusy(t){const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,o=i;if(!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 l=r.fixedCells.concat(r.noFixedCells);for(const a of l){const h=a.getDrawX(),d=a.getDrawY();if(o){if(t>h&&t<h+a.visibleWidth&&e>d&&e<d+a.visibleHeight){s(a);return}}else if(t>h&&t<h+a.width&&e>d&&e<d+a.height){s(a);return}}}}handleHeaderEvent(t,e,i,s){for(const o of i){const r=o.getDrawX(),l=o.getDrawY();if(t>r&&t<r+o.width&&e>l&&e<l+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 Ee{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,"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,"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");const{containerElement:i,stageElement:s,canvasElement:o,overlayerElement:r,editorElement:l,emptyElement:a,contextMenuElement:h}=t;this.containerElement=i,s.tabIndex=0,this.stageElement=s,this.canvasElement=o,this.overlayerElement=r,this.editorElement=l,this.emptyElement=a,this.contextMenuElement=h,this.config=new yt(e.config||{}),this.eventBus=new ue,this.eventBrowser=new xe(this),this.eventTable=new pe(this),this.paint=new ge(this.canvasElement),this.database=new de(this,e),this.history=new fe(this),this.icons=new we(this)}setConfig(t){this.config=new yt(t)}setItemValueByEditor(t,e,i,s=!0,o=!0,r=!0){if(this.config.ENABLE_MERGE_CELL_LINK){const l=this.database.getVirtualBodyCellByKey(t,e);if(l&&(l.mergeRow||l.mergeCol)){const{dataList:a}=l.getSpanInfo(),h=a.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),l=this.database.getColIndexForKey(o.key);if(r===void 0||l===void 0)return;const a=this.database.getVirtualBodyCell(r,l);if(a){const{dataList:h}=a.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 l=0;l<=i[1]-i[0];l++){const a=o+e[0],h=l+i[0],d=this.database.getVirtualBodyCell(a,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 bt{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 l=0;if(this.type==="horizontal"?l=s-this.clientX:l=o-this.clientY,this.isDragging&&l!==0){let a=0;this.type==="vertical"?a=this.dragStart+l/(this.visibleDistance-this.barHeight)*this.distance:a=this.dragStart+l/(this.visibleDistance-this.barWidth)*this.distance,this.scroll=Math.max(0,Math.min(a,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:l}}=this.ctx,a=s,h=i,d=e.height,f=e.width,x=t.height,u=this.ctx.footer.height;if(this.type==="vertical"){this.visibleDistance=h-o-d,this.distance=x-this.visibleDistance+u,this.trackX=a-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 p=this.distance?this.visibleDistance/(x+u):0;let g=Math.floor(p*this.visibleDistance);g<30?g=30:g>this.visibleDistance&&(g=0),this.barHeight=g,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=a-o,this.distance=f-this.visibleDistance,this.splitPoints=[a-o,h-o,a-o,h];const p=l?0:.5;this.trackX=0,this.trackY=h-o+p,this.trackWidth=a,this.trackHeight=o;const g=this.distance?this.visibleDistance/f:0;let w=Math.floor(g*this.visibleDistance);this.barY=this.trackY-1+(o-r)/2,w<30?w=30:w>=this.visibleDistance&&(w=0),this.barWidth=w,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 me{constructor(t){n(this,"ctx");n(this,"verticalScrollbar");n(this,"horizontalScrollbar");this.ctx=t,this.verticalScrollbar=new bt(t,"vertical"),this.horizontalScrollbar=new bt(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 ye{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",Tt(()=>{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=At(i),o=et(i);this.height=t*s,this.width=o.reduce((f,x)=>{const u=x.width||100,{maxWidth:p,minWidth:g}=x;return p&&u>p?f+p:g&&u<g?f+g:f+u},0),this.visibleHeight=this.height;const r=oe(Mt(i,s));this.columnIndex=0,this.resizeNum=0,this.render(r,0),this.ctx.database.updateColIndexKeyMap(this.leafCellHeaders);const l=this.ctx.containerElement.getBoundingClientRect();this.resizeNum>0?this.ctx.stageWidth=Math.floor(l.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 a=this.visibleWidth-this.width;if(this.resizeNum&&a>0){const f=Math.floor(a/this.resizeNum*100)/100;this.resizeAllColumn(f)}const h=this.fixedLeftCellHeaders.filter(f=>!f.hasChildren);this.ctx.fixedLeftWidth=h.reduce((f,x)=>f+x.width,0);const d=this.fixedRightCellHeaders.filter(f=>!f.hasChildren);this.ctx.fixedRightWidth=d.reduce((f,x)=>f+x.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(){const{config:{ENABLE_RESIZE_COLUMN:t}}=this.ctx;t&&(this.ctx.on("mousedown",e=>{this.ctx.isTarget(e)&&(this.clientX=e.clientX,this.resizeTarget?(this.isResizing=!0,this.ctx.columnResizing=!0):this.isResizing=!1,this.isMouseDown=!0)}),this.ctx.on("mouseup",()=>{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",e=>{if(this.ctx.editing)return;const{stageWidth:i,config:{RESIZE_COLUMN_MIN_WIDTH:s}}=this.ctx;if(this.isResizing&&this.resizeTarget){const o=this.resizeTarget.width,r=this.resizeTarget.minWidth,l=this.resizeTarget.maxWidth;let a=e.clientX-this.clientX;a+o<s&&(a=-(o-s)),r&&a+o<r&&(a=-(o-r)),l&&a+o>l&&(a=l-o),this.resizeDiff=a,this.ctx.emit("draw")}else{if(this.resizeTarget=null,this.isMouseDown)return;if(e.offsetX<0||e.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 o=[...this.renderFixedCellHeaders,...this.renderCenterCellHeaders];for(const r of o){const{offsetX:l,offsetY:a}=this.ctx.getOffset(e),h=l,d=r.getDrawX();h>d+r.width-5&&h<d+r.width+4&&h<i-4&&r.colspan<=1&&this.ctx.isTarget(e)&&a<=this.height&&(this.ctx.stageElement.style.cursor="col-resize",this.resizeTarget=r)}}}))}resizeColumn(t,e){const i=o=>{o.forEach(r=>{if(r.children&&r.children.length>0&&i(r.children),r.key===t.key){const l=r.width||100;r.width=l+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 l=t[r],a=o*(l.rowspan||0),h=o*(l.level||0);let{minWidth:d,maxWidth:f}=l,x=l.width||100;d&&x<d&&(x=d),f&&x>f&&(x=f),l.children&&(x=et(l.children).reduce((g,w)=>g+((w==null?void 0:w.width)||100),0));const u=new Xt(this.ctx,this.columnIndex,s,h,x,a,l);this.ctx.database.setHeader(l.key,u),this.allCellHeaders.push(u),l.children||(this.leafCellHeaders.push(u),u.column.widthFillDisable||this.resizeNum++),l.fixed==="left"?this.fixedLeftCellHeaders.push(u):l.fixed==="right"?this.fixedRightCellHeaders.push(u):this.centerCellHeaders.push(u),!l.children&&this.columnIndex++,l.children&&this.render(l.children,s),s+=x}}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:l}}=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!==l){const a=s.width-(this.x+this.width)+o-e;this.ctx.paint.drawShadow(a,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 Bt{constructor(t,e,i=0,s=0,o=0,r=0,l,a="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,"rowIndex",0);n(this,"rowKey","");n(this,"rowType","body");n(this,"data");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=a,this.data=l,this.update()}update(){const{header:t}=this.ctx,e=[],i=[],s=[];t.renderLeafCellHeaders.forEach(o=>{const r=new ft(this.ctx,this.rowIndex,o.colIndex,o.x,this.y,o.width,this.height,o.column,this.data,this.rowType);r.fixed?i.push(r):s.push(r),e.push(r)}),this.cells=e,this.fixedCells=i,this.noFixedCells=s}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 Ce{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:l,EMPTY_BODY_HEIGHT:a=0,MAX_HEIGHT:h=0,ENABLE_OFFSET_HEIGHT:d=0,OFFSET_HEIGHT:f=0,FOOTER_POSITION:x}}=this.ctx;if(!e.width)return;this.x=0,x==="top"&&o?this.y=e.height+i.height:this.y=e.height;const{data:u,sumHeight:p}=s.getData();this.height=p,this.data=u,this.width=e.width,this.visibleWidth=this.ctx.stageWidth-r;const g=this.ctx.footer.height;!this.data.length&&!l?this.height=a:!this.data.length&&l&&(this.height=l-e.height-g-r);let w=this.height+e.height+r;w+=g;let E=w;const y=window.innerHeight,{top:m}=this.containerRect||this.ctx.containerElement.getBoundingClientRect();if(y>m&&d&&!l){const L=y-m-f;L>e.height+r?E=L:w>h&&(E=h)}else this.data.length&&l?E=l:this.data.length&&h&&w>h&&(E=h);E>0&&(this.ctx.stageHeight=Math.floor(E),this.ctx.stageElement.style.height=`${this.ctx.stageHeight}px`);let R=this.ctx.stageHeight-e.height-r;o?this.visibleHeight=R-g: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=u;const C=window.devicePixelRatio||1,I=this.ctx.stageWidth*C,_=this.ctx.stageHeight*C;t.width=Math.round(I),t.height=Math.round(_);const S=this.data.length?"not-empty":"empty";this.ctx.emit("emptyChange",{isEmpty:S,type:S,headerHeight:e.height,bodyHeight:this.height,footerHeight:g,width:this.width,height:this.data.length?0:a+g});const v=Math.round(t.width/C*1e4)/1e4,b=Math.round(t.height/C*1e4)/1e4;this.ctx.canvasElement.setAttribute("style",`height:${b}px;width:${v}px;`),this.ctx.paint.scale(C)}initResizeRow(){const{config:{ENABLE_RESIZE_ROW:t}}=this.ctx;t&&(this.ctx.on("resize",()=>{this.containerRect=this.ctx.containerElement.getBoundingClientRect()}),this.ctx.on("resizeObserver",()=>{this.containerRect=this.ctx.containerElement.getBoundingClientRect()}),this.ctx.on("mouseup",()=>{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",e=>{this.ctx.isTarget(e)&&(this.clientY=e.clientY,this.resizeTarget?(this.isResizing=!0,this.ctx.rowResizing=!0):(this.isResizing=!1,this.ctx.rowResizing=!1),this.isMouseDown=!0)}),this.ctx.on("mousemove",e=>{if(this.ctx.editing)return;const{offsetY:i,offsetX:s}=this.ctx.getOffset(e),o=i,r=s,l=e.clientY,{stageHeight:a,scrollY:h,config:{RESIZE_ROW_MIN_HEIGHT:d=0}}=this.ctx;if(this.isResizing&&this.resizeTarget){const f=this.resizeTarget.height;let x=l-this.clientY;x+f<d&&(x=-(f-d)),this.resizeDiff=x,this.ctx.emit("draw")}else{if(this.resizeTarget=null,this.isMouseDown)return;if(r<0||r>this.ctx.body.visibleWidth||o<0||o>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 f=0;f<this.renderRows.length;f++){const x=this.renderRows[f];if(o>x.y-h+x.height-1.5&&o<x.y-h+x.height+1.5&&o<a-4)for(let p=0;p<x.cells.length;p++){const g=x.cells[p];r>g.drawX+10&&r<g.drawX+g.width-10&&g.rowspan===1&&(this.ctx.stageElement.style.cursor="row-resize",this.resizeTarget=x)}}}}))}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,l=[0,r-.5,t,r-.5];this.ctx.paint.drawLine(l,{borderColor:i,borderWidth:1})}}drawFixedShadow(){const{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,stageWidth:o,config:{HEADER_BG_COLOR:r,SCROLLER_TRACK_SIZE:l}}=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!==l){const a=s.width-(this.x+this.width)+o-e;this.ctx.paint.drawShadow(a,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),l=t[r].bottom;if(l===e)return r;l<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:l}=e.getData();this.ctx.maxRowIndex=r.length-1;let a=this.binarySearch(l,o),h=this.binarySearch(l,o+this.visibleHeight);if(h===-1&&(h=this.ctx.maxRowIndex),a===-1&&h===this.ctx.maxRowIndex){const f=Math.floor(this.visibleHeight/s);a=this.ctx.maxRowIndex-f}this.headIndex=Math.max(0,a),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 x=this.headIndex+f,u=this.visibleRows[f],{height:p,top:g}=this.ctx.database.getPositionForRowIndex(x),w=new Bt(this.ctx,x,0,g+this.y,t.width,p,u);d.push(w)}this.renderRows=d,this.ctx.body.renderRows=d}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 be{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(l=>l+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:l}}=this.ctx;let a=this.y;if(this.ctx.config.FOOTER_FIXED||(a=this.y-this.ctx.scrollY),i>0&&t!==0&&this.ctx.paint.drawShadow(this.x,a,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!==l){const h=s.width-(this.x+this.width)+o-e;this.ctx.paint.drawShadow(h,a,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 Bt(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 Re{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",Tt(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[l]=r;r=[l,l]}if(!i){const[l]=o;o=[l,l]}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:l,SELECTOR_AREA_MAX_X:a,SELECTOR_AREA_MIN_Y:h,SELECTOR_AREA_MAX_Y:d,SELECTOR_AREA_MAX_X_OFFSET:f,SELECTOR_AREA_MAX_Y_OFFSET:x}=this.ctx.config,u=l,p=a||this.ctx.maxColIndex-f,g=h,w=d||this.ctx.maxRowIndex-x;let[E,y]=o,[m,R]=r;if(E<u||y>p||m<g||R>w)return;if(this.ctx.stageElement.focus({preventScroll:!0}),this.ctx.config.ENABLE_MERGE_CELL_LINK){const I=this.adjustMergeCells(o,r);m=I.yArr[0],R=I.yArr[1],E=I.xArr[0],y=I.xArr[1],this.ctx.onlyMergeCell=I.onlyMergeCell}E===y&&m===R?this.ctx.selectOnlyOne=!0:this.ctx.selectOnlyOne=!1,o=[Math.max(u,E),Math.min(p,y)],r=[Math.max(g,m),Math.min(w,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 p;const[i,s]=e,[o,r]=t;let l=[],a=[];for(let g=0;g<=e[1]-e[0];g++)for(let w=0;w<=t[1]-t[0];w++){const E=g+e[0],y=w+t[0],m=this.ctx.database.getVirtualBodyCell(E,y);m&&((E===i||E===s)&&l.push(m),(y===o||y===r)&&a.push(m))}const h=l.reduce((g,w)=>{const{yArr:E}=w.getSpanInfo(),[y,m]=E;return g.minY=Math.min(g.minY,y),g.maxY=Math.max(g.maxY,m),g},{minY:i,maxY:s}),d=a.reduce((g,w)=>{const{xArr:E}=w.getSpanInfo(),[y,m]=E;return g.minX=Math.min(g.minX,y),g.maxX=Math.max(g.maxX,m),g},{minX:o,maxX:r}),f=[d.minX,d.maxX],x=[h.minY,h.maxY];let u=!1;if(d.minX!==d.maxX||h.minY!==h.maxY){const g=JSON.stringify(f)+JSON.stringify(x),w=(p=this.ctx.focusCell)==null?void 0:p.getSpanInfo();u=(w&&JSON.stringify(w.xArr)+JSON.stringify(w.yArr))===g}return{xArr:f,yArr:x,onlyMergeCell:u}}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:l}=this.ctx.focusCellHeader;if(this.ctx.clearSelector(),t.colIndex>=l){const a=[l,t.colIndex+t.colspan-1],h=[o,r];this.setSelector(a,h)}else{const a=[t.colIndex,l],h=[o,r];this.setSelector(a,h)}}else{const l=[t.colIndex,t.colIndex+t.colspan-1],a=[o,r];this.setSelector(l,a)}}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:l,SELECTOR_AREA_MAX_Y_OFFSET:a}=this.ctx.config,h=i,d=s||this.ctx.maxColIndex-l,f=o,x=r||this.ctx.maxRowIndex-a,u=[h,d],p=[f,x];this.setSelector(u,p)}}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,l=i;if(e){this.ctx.setFocusCell(t);const a=[l,r],h=[t.rowIndex,t.rowIndex];this.setSelector(a,h)}if(this.ctx.focusCell&&this.ctx.mousedown){const{rowIndex:a}=this.ctx.focusCell;if(t.rowIndex>=a){const h=[l,r],d=[a,t.rowIndex];this.setSelector(h,d)}else{const h=[l,r],d=[t.rowIndex,a];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),l=Math.max(i.colIndex,o),a=Math.min(i.rowIndex,s),h=Math.max(i.rowIndex,s),d=[r,l],f=[a,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:l}=e,a=Math.min(r,s),h=Math.max(r,s),d=Math.min(l,o),f=Math.max(l,o),x=[a,h],u=[d,f];this.setSelector(x,u)}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 l=s({focusCell:this.ctx.focusCell,data:t,xArr:e,yArr:i});if(!l)return;t=l.data}const o=le(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 a=0;a<=e[1]-e[0];a++)for(let h=0;h<=t[1]-t[0];h++){const d=a+e[0],f=h+t[0],x=this.ctx.database.getItemValueForRowIndexAndColIndex(d,f);if(x){const{rowKey:u,key:p}=x;this.ctx.database.getReadonly(u,p)||(r.add(u),o.push({rowKey:u,key:p,value:s,row:{}}))}}if(!o.length)return[];if(i)return o;this.ctx.database.batchSetItemValue(o,!0);let l=[];return r.forEach(a=>{l.push(this.ctx.database.getRowDataItemForRowKey(a))}),this.ctx.emit("clearSelectedDataChange",o,l),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=ne(o);const l=[i,i+r[0].length-1],a=[e,e+r.length-1],[h,d]=a,[f,x]=l,u=d-this.ctx.maxRowIndex,p=x-this.ctx.maxColIndex;(u>0||p>0)&&this.ctx.emit("onPastedDataOverflow",{maxY:d,maxX:x,minY:h,minX:f,overflowRowCount:u,overflowColCount:p,textArr:r});const g=r.length===1&&r[0].length===1;if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.database.hasMergeCell(l,a)&&!g){const m={code:"ERR_MERGED_CELLS_PASTE",message:"Merged cells cannot span paste data"};this.ctx.hasEvent("error")?this.ctx.emit("error",m):alert(m.message);return}let w=[];for(let m=0;m<=r.length-1;m++){const R=r[m].length;for(let C=0;C<=R-1;C++){const I=m+e,_=C+i,S=r[m][C],v=this.ctx.database.getItemValueForRowIndexAndColIndex(I,_);if(v){const{rowKey:b,key:O}=v;this.ctx.database.getReadonly(b,O)||(s.add(b),w.push({rowKey:b,key:O,value:S,row:{}}))}}}if(this.isCut){const m=this.clearSelectedData(this.ctx.selector.xArrCopy,this.ctx.selector.yArrCopy,!0),R=w.map(C=>`${C.rowKey}-${C.key}`);m.forEach(C=>{R.includes(`${C.rowKey}-${C.key}`)||w.unshift(C)}),this.isCut=!1}if(!w.length)return;const{BEFORE_PASTE_DATA_METHOD:E}=this.ctx.config;if(typeof E=="function"){const m=E,R=w.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(w=await m(R,l,a,r),w&&!w.length)return}this.clearCopyLine(),this.ctx.batchSetItemValueByEditor(w,!0);let y=[];s.forEach(m=>{y.push(this.ctx.database.getRowDataItemForRowKey(m))}),this.ctx.emit("pasteChange",w,y)}).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,l=this.ctx.maxColIndex,a=this.ctx.maxRowIndex;switch(t){case"LEFT":i>o&&i--;break;case"TOP":s>r&&s--;break;case"RIGHT":i<l&&i++;break;case"BOTTOM":s<a&&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:l,SELECTOR_AREA_MAX_Y_OFFSET:a}=this.ctx.config,h=i,d=s||this.ctx.maxColIndex-l,f=o,x=r||this.ctx.maxRowIndex-a;return!(e<h||e>d||t<f||t>x)}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 l=10*(s==="left"?-1:1);this.timerX&&(clearInterval(this.timerX),this.timerX=0),this.timerX=setInterval(()=>{l*=1.5;const{scrollX:a}=this.ctx,h=a+l;(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 l=10*(o==="top"?-1:1);this.timerY&&(clearInterval(this.timerY),this.timerY=0),this.timerY=setInterval(()=>{l*=1.5;const{scrollY:a}=this.ctx,h=a+l;(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:l,body:a,scrollX:h,scrollY:d,config:{SCROLLER_TRACK_SIZE:f,FOOTER_FIXED:x,FOOTER_POSITION:u,ENABLE_MERGE_CELL_LINK:p}}=this.ctx;if(!i)return;p&&this.ctx.onlyMergeCell&&i.updateSpanInfo();const{drawX:g,drawY:w,width:E,height:y,fixed:m}=i,R=o-g+1,C=i.drawX+E-(e-s)+1;let I=r.height-w,_=y;_>a.visibleHeight&&(_=a.visibleHeight);let S=0;x&&(u==="top"?I=r.height+l.height-w:S=l.visibleHeight);const v=w+_-(t-S-f);let b=h,O=d;C>0&&!m?b=Math.floor(h+C):R>0&&!m&&(b=Math.floor(h-R)),I>0?O=Math.floor(d-I):v>0&&(O=Math.floor(d+v)),(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 ve{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:l,width:a,height:h}=this.maxColRowCell,d=6,f=s===this.ctx.maxColIndex||o===this.ctx.maxRowIndex?0:2,x=r+a-d+f,u=l+h-d+f;e>x&&i>u&&e<x+d&&i<u+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:l}=t;this.ctx.config.ENABLE_AUTOFILL&&r===s&&l===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,l=e;if(!o){const[a]=l;l=[a,a]}if(!s){const[a]=r;r=[a,a]}if(JSON.stringify(this.ctx.autofill.xArr)!==JSON.stringify(r)||JSON.stringify(this.ctx.autofill.yArr)!==JSON.stringify(l)){const{SELECTOR_AREA_MIN_X:a,SELECTOR_AREA_MAX_X:h,SELECTOR_AREA_MIN_Y:d,SELECTOR_AREA_MAX_Y:f,SELECTOR_AREA_MAX_X_OFFSET:x,SELECTOR_AREA_MAX_Y_OFFSET:u}=this.ctx.config,p=a,g=h||this.ctx.maxColIndex-x,w=d,E=f||this.ctx.maxRowIndex-u;let[y,m]=r,[R,C]=l;if(y<p||R<w)return;r=[Math.max(p,y),Math.min(g,m)],l=[Math.max(w,R),Math.min(E,C)];const{BEFORE_SET_AUTOFILL_METHOD:I}=this.ctx.config;if(typeof I=="function"){const S=I({focusCell:this.ctx.focusCell,xArr:r,yArr:l});if(!S)return;r=S.xArr,l=S.yArr}this.ctx.autofill.xArr=r,this.ctx.autofill.yArr=l,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 u=0;u<=e.yArr[1]-e.yArr[0];u++)for(let p=0;p<=e.xArr[1]-e.xArr[0];p++){const g=u+e.yArr[0],w=p+e.xArr[0];i.set(`${g}-${w}`,!0)}const{value:s}=e,o=s[0].length,r=s.length,l=this.ctx.autofill.xArr,a=this.ctx.autofill.yArr,h=o===1&&r===1;if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.database.hasMergeCell(l,a)&&!h){const u={code:"ERR_MERGED_CELLS_AUTOFILL",message:"Merged cells cannot span autofill data"};this.ctx.hasEvent("error")?this.ctx.emit("error",u):alert(u.message);return}let d=[];for(let u=0;u<=a[1]-a[0];u++)for(let p=0;p<=l[1]-l[0];p++){const g=p+l[0],w=u+a[0],E=s[u%r][p%o],y=this.ctx.database.getItemValueForRowIndexAndColIndex(w,g),m=`${w}-${g}`;if(y&&!i.has(m)){const{rowKey:R,key:C}=y;this.ctx.database.getReadonly(R,C)||(t.add(R),d.push({rowKey:R,key:C,value:E,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 u=f,p=d.map(g=>({rowKey:g.rowKey,key:g.key,value:g.value,oldValue:this.ctx.database.getItemValue(g.rowKey,g.key),row:this.ctx.database.getRowDataItemForRowKey(g.rowKey)}));if(d=await u(p,l,a),d&&!d.length)return}this.ctx.batchSetItemValueByEditor(d,!0);let x=[];t.forEach(u=>{x.push(this.ctx.database.getRowDataItemForRowKey(u))}),this.ctx.emit("autofillChange",d,x)}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(),l=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]?l.splice(1,1,s):s<e.yArr[0]&&l.splice(0,1,s),this.setAutofill(r,l)}}destroy(){}}const Z=Math.min,$=Math.max,it=Math.round,K=c=>({x:c,y:c}),Ie={left:"right",right:"left",bottom:"top",top:"bottom"},_e={start:"end",end:"start"};function ht(c,t,e){return $(c,Z(t,e))}function J(c,t){return typeof c=="function"?c(t):c}function z(c){return c.split("-")[0]}function Q(c){return c.split("-")[1]}function Kt(c){return c==="x"?"y":"x"}function xt(c){return c==="y"?"height":"width"}const Oe=new Set(["top","bottom"]);function V(c){return Oe.has(z(c))?"y":"x"}function ut(c){return Kt(V(c))}function Se(c,t,e){e===void 0&&(e=!1);const i=Q(c),s=ut(c),o=xt(s);let r=s==="x"?i===(e?"end":"start")?"right":"left":i==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(r=st(r)),[r,st(r)]}function Le(c){const t=st(c);return[ct(c),t,ct(t)]}function ct(c){return c.replace(/start|end/g,t=>_e[t])}const Rt=["left","right"],vt=["right","left"],Te=["top","bottom"],Ae=["bottom","top"];function Me(c,t,e){switch(c){case"top":case"bottom":return e?t?vt:Rt:t?Rt:vt;case"left":case"right":return t?Te:Ae;default:return[]}}function He(c,t,e,i){const s=Q(c);let o=Me(z(c),e==="start",i);return s&&(o=o.map(r=>r+"-"+s),t&&(o=o.concat(o.map(ct)))),o}function st(c){return c.replace(/left|right|bottom|top/g,t=>Ie[t])}function De(c){return{top:0,right:0,bottom:0,left:0,...c}}function Nt(c){return typeof c!="number"?De(c):{top:c,right:c,bottom:c,left:c}}function ot(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 It(c,t,e){let{reference:i,floating:s}=c;const o=V(t),r=ut(t),l=xt(r),a=z(t),h=o==="y",d=i.x+i.width/2-s.width/2,f=i.y+i.height/2-s.height/2,x=i[l]/2-s[l]/2;let u;switch(a){case"top":u={x:d,y:i.y-s.height};break;case"bottom":u={x:d,y:i.y+i.height};break;case"right":u={x:i.x+i.width,y:f};break;case"left":u={x:i.x-s.width,y:f};break;default:u={x:i.x,y:i.y}}switch(Q(t)){case"start":u[r]-=x*(e&&h?-1:1);break;case"end":u[r]+=x*(e&&h?-1:1);break}return u}const ke=async(c,t,e)=>{const{placement:i="bottom",strategy:s="absolute",middleware:o=[],platform:r}=e,l=o.filter(Boolean),a=await(r.isRTL==null?void 0:r.isRTL(t));let h=await r.getElementRects({reference:c,floating:t,strategy:s}),{x:d,y:f}=It(h,i,a),x=i,u={},p=0;for(let g=0;g<l.length;g++){const{name:w,fn:E}=l[g],{x:y,y:m,data:R,reset:C}=await E({x:d,y:f,initialPlacement:i,placement:x,strategy:s,middlewareData:u,rects:h,platform:r,elements:{reference:c,floating:t}});d=y??d,f=m??f,u={...u,[w]:{...u[w],...R}},C&&p<=50&&(p++,typeof C=="object"&&(C.placement&&(x=C.placement),C.rects&&(h=C.rects===!0?await r.getElementRects({reference:c,floating:t,strategy:s}):C.rects),{x:d,y:f}=It(h,x,a)),g=-1)}return{x:d,y:f,placement:x,strategy:s,middlewareData:u}};async function Yt(c,t){var e;t===void 0&&(t={});const{x:i,y:s,platform:o,rects:r,elements:l,strategy:a}=c,{boundary:h="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:x=!1,padding:u=0}=J(t,c),p=Nt(u),w=l[x?f==="floating"?"reference":"floating":f],E=ot(await o.getClippingRect({element:(e=await(o.isElement==null?void 0:o.isElement(w)))==null||e?w:w.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(l.floating)),boundary:h,rootBoundary:d,strategy:a})),y=f==="floating"?{x:i,y:s,width:r.floating.width,height:r.floating.height}:r.reference,m=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating)),R=await(o.isElement==null?void 0:o.isElement(m))?await(o.getScale==null?void 0:o.getScale(m))||{x:1,y:1}:{x:1,y:1},C=ot(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:y,offsetParent:m,strategy:a}):y);return{top:(E.top-C.top+p.top)/R.y,bottom:(C.bottom-E.bottom+p.bottom)/R.y,left:(E.left-C.left+p.left)/R.x,right:(C.right-E.right+p.right)/R.x}}const Xe=c=>({name:"arrow",options:c,async fn(t){const{x:e,y:i,placement:s,rects:o,platform:r,elements:l,middlewareData:a}=t,{element:h,padding:d=0}=J(c,t)||{};if(h==null)return{};const f=Nt(d),x={x:e,y:i},u=ut(s),p=xt(u),g=await r.getDimensions(h),w=u==="y",E=w?"top":"left",y=w?"bottom":"right",m=w?"clientHeight":"clientWidth",R=o.reference[p]+o.reference[u]-x[u]-o.floating[p],C=x[u]-o.reference[u],I=await(r.getOffsetParent==null?void 0:r.getOffsetParent(h));let _=I?I[m]:0;(!_||!await(r.isElement==null?void 0:r.isElement(I)))&&(_=l.floating[m]||o.floating[p]);const S=R/2-C/2,v=_/2-g[p]/2-1,b=Z(f[E],v),O=Z(f[y],v),L=b,M=_-g[p]-O,T=_/2-g[p]/2+S,H=ht(L,T,M),Y=!a.arrow&&Q(s)!=null&&T!==H&&o.reference[p]/2-(T<L?b:O)-g[p]/2<0,D=Y?T<L?T-L:T-M:0;return{[u]:x[u]+D,data:{[u]:H,centerOffset:T-H-D,...Y&&{alignmentOffset:D}},reset:Y}}}),Be=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:l,platform:a,elements:h}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:x,fallbackStrategy:u="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...w}=J(c,t);if((e=o.arrow)!=null&&e.alignmentOffset)return{};const E=z(s),y=V(l),m=z(l)===l,R=await(a.isRTL==null?void 0:a.isRTL(h.floating)),C=x||(m||!g?[st(l)]:Le(l)),I=p!=="none";!x&&I&&C.push(...He(l,g,p,R));const _=[l,...C],S=await Yt(t,w),v=[];let b=((i=o.flip)==null?void 0:i.overflows)||[];if(d&&v.push(S[E]),f){const T=Se(s,r,R);v.push(S[T[0]],S[T[1]])}if(b=[...b,{placement:s,overflows:v}],!v.every(T=>T<=0)){var O,L;const T=(((O=o.flip)==null?void 0:O.index)||0)+1,H=_[T];if(H&&(!(f==="alignment"?y!==V(H):!1)||b.every(k=>V(k.placement)===y?k.overflows[0]>0:!0)))return{data:{index:T,overflows:b},reset:{placement:H}};let Y=(L=b.filter(D=>D.overflows[0]<=0).sort((D,k)=>D.overflows[1]-k.overflows[1])[0])==null?void 0:L.placement;if(!Y)switch(u){case"bestFit":{var M;const D=(M=b.filter(k=>{if(I){const W=V(k.placement);return W===y||W==="y"}return!0}).map(k=>[k.placement,k.overflows.filter(W=>W>0).reduce((W,te)=>W+te,0)]).sort((k,W)=>k[1]-W[1])[0])==null?void 0:M[0];D&&(Y=D);break}case"initialPlacement":Y=l;break}if(s!==Y)return{reset:{placement:Y}}}return{}}}},Ke=new Set(["left","top"]);async function Ne(c,t){const{placement:e,platform:i,elements:s}=c,o=await(i.isRTL==null?void 0:i.isRTL(s.floating)),r=z(e),l=Q(e),a=V(e)==="y",h=Ke.has(r)?-1:1,d=o&&a?-1:1,f=J(t,c);let{mainAxis:x,crossAxis:u,alignmentAxis:p}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof p=="number"&&(u=l==="end"?p*-1:p),a?{x:u*d,y:x*h}:{x:x*h,y:u*d}}const Ye=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:l}=t,a=await Ne(t,c);return r===((e=l.offset)==null?void 0:e.placement)&&(i=l.arrow)!=null&&i.alignmentOffset?{}:{x:s+a.x,y:o+a.y,data:{...a,placement:r}}}}},Fe=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:l={fn:w=>{let{x:E,y}=w;return{x:E,y}}},...a}=J(c,t),h={x:e,y:i},d=await Yt(t,a),f=V(z(s)),x=Kt(f);let u=h[x],p=h[f];if(o){const w=x==="y"?"top":"left",E=x==="y"?"bottom":"right",y=u+d[w],m=u-d[E];u=ht(y,u,m)}if(r){const w=f==="y"?"top":"left",E=f==="y"?"bottom":"right",y=p+d[w],m=p-d[E];p=ht(y,p,m)}const g=l.fn({...t,[x]:u,[f]:p});return{...g,data:{x:g.x-e,y:g.y-i,enabled:{[x]:o,[f]:r}}}}}};function rt(){return typeof window<"u"}function j(c){return Ft(c)?(c.nodeName||"").toLowerCase():"#document"}function A(c){var t;return(c==null||(t=c.ownerDocument)==null?void 0:t.defaultView)||window}function F(c){var t;return(t=(Ft(c)?c.ownerDocument:c.document)||window.document)==null?void 0:t.documentElement}function Ft(c){return rt()?c instanceof Node||c instanceof A(c).Node:!1}function X(c){return rt()?c instanceof Element||c instanceof A(c).Element:!1}function N(c){return rt()?c instanceof HTMLElement||c instanceof A(c).HTMLElement:!1}function _t(c){return!rt()||typeof ShadowRoot>"u"?!1:c instanceof ShadowRoot||c instanceof A(c).ShadowRoot}const We=new Set(["inline","contents"]);function tt(c){const{overflow:t,overflowX:e,overflowY:i,display:s}=B(c);return/auto|scroll|overlay|hidden|clip/.test(t+i+e)&&!We.has(s)}const Ve=new Set(["table","td","th"]);function Pe(c){return Ve.has(j(c))}const ze=[":popover-open",":modal"];function nt(c){return ze.some(t=>{try{return c.matches(t)}catch{return!1}})}const $e=["transform","translate","scale","rotate","perspective"],Ge=["transform","translate","scale","rotate","perspective","filter"],Ue=["paint","layout","strict","content"];function gt(c){const t=wt(),e=X(c)?B(c):c;return $e.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)||Ge.some(i=>(e.willChange||"").includes(i))||Ue.some(i=>(e.contain||"").includes(i))}function je(c){let t=P(c);for(;N(t)&&!U(t);){if(gt(t))return t;if(nt(t))return null;t=P(t)}return null}function wt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Ze=new Set(["html","body","#document"]);function U(c){return Ze.has(j(c))}function B(c){return A(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||_t(c)&&c.host||F(c);return _t(t)?t.host:t}function Wt(c){const t=P(c);return U(t)?c.ownerDocument?c.ownerDocument.body:c.body:N(t)&&tt(t)?t:Wt(t)}function Vt(c,t,e){var i;t===void 0&&(t=[]);const s=Wt(c),o=s===((i=c.ownerDocument)==null?void 0:i.body),r=A(s);return o?(dt(r),t.concat(r,r.visualViewport||[],tt(s)?s:[],[])):t.concat(s,Vt(s,[]))}function dt(c){return c.parent&&Object.getPrototypeOf(c.parent)?c.frameElement:null}function Pt(c){const t=B(c);let e=parseFloat(t.width)||0,i=parseFloat(t.height)||0;const s=N(c),o=s?c.offsetWidth:e,r=s?c.offsetHeight:i,l=it(e)!==o||it(i)!==r;return l&&(e=o,i=r),{width:e,height:i,$:l}}function zt(c){return X(c)?c:c.contextElement}function G(c){const t=zt(c);if(!N(t))return K(1);const e=t.getBoundingClientRect(),{width:i,height:s,$:o}=Pt(t);let r=(o?it(e.width):e.width)/i,l=(o?it(e.height):e.height)/s;return(!r||!Number.isFinite(r))&&(r=1),(!l||!Number.isFinite(l))&&(l=1),{x:r,y:l}}const qe=K(0);function $t(c){const t=A(c);return!wt()||!t.visualViewport?qe:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Je(c,t,e){return t===void 0&&(t=!1),!e||t&&e!==A(c)?!1:t}function q(c,t,e,i){t===void 0&&(t=!1),e===void 0&&(e=!1);const s=c.getBoundingClientRect(),o=zt(c);let r=K(1);t&&(i?X(i)&&(r=G(i)):r=G(c));const l=Je(o,e,i)?$t(o):K(0);let a=(s.left+l.x)/r.x,h=(s.top+l.y)/r.y,d=s.width/r.x,f=s.height/r.y;if(o){const x=A(o),u=i&&X(i)?A(i):i;let p=x,g=dt(p);for(;g&&i&&u!==p;){const w=G(g),E=g.getBoundingClientRect(),y=B(g),m=E.left+(g.clientLeft+parseFloat(y.paddingLeft))*w.x,R=E.top+(g.clientTop+parseFloat(y.paddingTop))*w.y;a*=w.x,h*=w.y,d*=w.x,f*=w.y,a+=m,h+=R,p=A(g),g=dt(p)}}return ot({width:d,height:f,x:a,y:h})}function pt(c,t){const e=lt(c).scrollLeft;return t?t.left+e:q(F(c)).left+e}function Gt(c,t,e){e===void 0&&(e=!1);const i=c.getBoundingClientRect(),s=i.left+t.scrollLeft-(e?0:pt(c,i)),o=i.top+t.scrollTop;return{x:s,y:o}}function Qe(c){let{elements:t,rect:e,offsetParent:i,strategy:s}=c;const o=s==="fixed",r=F(i),l=t?nt(t.floating):!1;if(i===r||l&&o)return e;let a={scrollLeft:0,scrollTop:0},h=K(1);const d=K(0),f=N(i);if((f||!f&&!o)&&((j(i)!=="body"||tt(r))&&(a=lt(i)),N(i))){const u=q(i);h=G(i),d.x=u.x+i.clientLeft,d.y=u.y+i.clientTop}const x=r&&!f&&!o?Gt(r,a,!0):K(0);return{width:e.width*h.x,height:e.height*h.y,x:e.x*h.x-a.scrollLeft*h.x+d.x+x.x,y:e.y*h.y-a.scrollTop*h.y+d.y+x.y}}function ti(c){return Array.from(c.getClientRects())}function ei(c){const t=F(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+pt(c);const l=-e.scrollTop;return B(i).direction==="rtl"&&(r+=$(t.clientWidth,i.clientWidth)-s),{width:s,height:o,x:r,y:l}}function ii(c,t){const e=A(c),i=F(c),s=e.visualViewport;let o=i.clientWidth,r=i.clientHeight,l=0,a=0;if(s){o=s.width,r=s.height;const h=wt();(!h||h&&t==="fixed")&&(l=s.offsetLeft,a=s.offsetTop)}return{width:o,height:r,x:l,y:a}}const si=new Set(["absolute","fixed"]);function oi(c,t){const e=q(c,!0,t==="fixed"),i=e.top+c.clientTop,s=e.left+c.clientLeft,o=N(c)?G(c):K(1),r=c.clientWidth*o.x,l=c.clientHeight*o.y,a=s*o.x,h=i*o.y;return{width:r,height:l,x:a,y:h}}function Ot(c,t,e){let i;if(t==="viewport")i=ii(c,e);else if(t==="document")i=ei(F(c));else if(X(t))i=oi(t,e);else{const s=$t(c);i={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return ot(i)}function Ut(c,t){const e=P(c);return e===t||!X(e)||U(e)?!1:B(e).position==="fixed"||Ut(e,t)}function ri(c,t){const e=t.get(c);if(e)return e;let i=Vt(c,[]).filter(l=>X(l)&&j(l)!=="body"),s=null;const o=B(c).position==="fixed";let r=o?P(c):c;for(;X(r)&&!U(r);){const l=B(r),a=gt(r);!a&&l.position==="fixed"&&(s=null),(o?!a&&!s:!a&&l.position==="static"&&!!s&&si.has(s.position)||tt(r)&&!a&&Ut(c,r))?i=i.filter(d=>d!==r):s=l,r=P(r)}return t.set(c,i),i}function ni(c){let{element:t,boundary:e,rootBoundary:i,strategy:s}=c;const r=[...e==="clippingAncestors"?nt(t)?[]:ri(t,this._c):[].concat(e),i],l=r[0],a=r.reduce((h,d)=>{const f=Ot(t,d,s);return h.top=$(f.top,h.top),h.right=Z(f.right,h.right),h.bottom=Z(f.bottom,h.bottom),h.left=$(f.left,h.left),h},Ot(t,l,s));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function li(c){const{width:t,height:e}=Pt(c);return{width:t,height:e}}function ai(c,t,e){const i=N(t),s=F(t),o=e==="fixed",r=q(c,!0,o,t);let l={scrollLeft:0,scrollTop:0};const a=K(0);function h(){a.x=pt(s)}if(i||!i&&!o)if((j(t)!=="body"||tt(s))&&(l=lt(t)),i){const u=q(t,!0,o,t);a.x=u.x+t.clientLeft,a.y=u.y+t.clientTop}else s&&h();o&&!i&&s&&h();const d=s&&!i&&!o?Gt(s,l):K(0),f=r.left+l.scrollLeft-a.x-d.x,x=r.top+l.scrollTop-a.y-d.y;return{x:f,y:x,width:r.width,height:r.height}}function at(c){return B(c).position==="static"}function St(c,t){if(!N(c)||B(c).position==="fixed")return null;if(t)return t(c);let e=c.offsetParent;return F(c)===e&&(e=e.ownerDocument.body),e}function jt(c,t){const e=A(c);if(nt(c))return e;if(!N(c)){let s=P(c);for(;s&&!U(s);){if(X(s)&&!at(s))return s;s=P(s)}return e}let i=St(c,t);for(;i&&Pe(i)&&at(i);)i=St(i,t);return i&&U(i)&&at(i)&&!gt(i)?e:i||je(c)||e}const hi=async function(c){const t=this.getOffsetParent||jt,e=this.getDimensions,i=await e(c.floating);return{reference:ai(c.reference,await t(c.floating),c.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function ci(c){return B(c).direction==="rtl"}const di={convertOffsetParentRelativeRectToViewportRelativeRect:Qe,getDocumentElement:F,getClippingRect:ni,getOffsetParent:jt,getElementRects:hi,getClientRects:ti,getDimensions:li,getScale:G,isElement:X,isRTL:ci},Zt=Ye,qt=Fe,Jt=Be,fi=Xe,Qt=(c,t,e)=>{const i=new Map,s={platform:di,...e},o={...s.platform,_c:i};return ke(c,t,{...s,platform:o})};let xi=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 l={display:"none",position:"absolute",background:e,color:i,boxSizing:"border-box",zIndex:s,padding:"8px",borderRadius:"4px",fontSize:"12px",...o},a={position:"absolute",width:"10px",height:"10px",background:l.background,backgroundColor:l.backgroundColor,transform:"rotate(45deg)",zIndex:l.zIndex};Object.assign(this.arrowEl.style,a),Object.assign(this.floatingEl.style,l),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;Qt({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:[qt(),Jt(),Zt(6),fi({element:this.arrowEl})]}).then(l=>{const{x:a,y:h,placement:d,middlewareData:f}=l;if(Object.assign(this.floatingEl.style,{top:`${h}px`,left:`${a}px`}),f.arrow){const x=f.arrow;["left","left-start","left-end"].includes(d)?Object.assign(this.arrowEl.style,{top:`${x.y}px`,bottom:"",left:"",right:"-5px"}):["right","right-start","right-end"].includes(d)?Object.assign(this.arrowEl.style,{top:`${x.y}px`,bottom:"",left:"-5px",right:""}):["bottom","bottom-start","bottom-end"].includes(d)?Object.assign(this.arrowEl.style,{top:"-5px",bottom:"",left:`${x.x}px`,right:""}):["top","top-start","top-end"].includes(d)&&Object.assign(this.arrowEl.style,{top:"",bottom:"-5px",left:`${x.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 ui{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:a}=this.ctx;a&&(this.ctx.emit("setSelectorCell",a),this.cellTarget=a),this.doneEdit();return}if((t.altKey||t.metaKey)&&t.code==="Enter"&&this.ctx.editing&&this.inputEl){t.preventDefault();const a=this.inputEl.selectionStart,h=this.inputEl.value.substring(0,a),d=this.inputEl.value.substring(a);this.inputEl.value=h+`
|
|
5
|
+
`+d,this.inputEl.selectionStart=this.inputEl.selectionEnd=a+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("adjustBoundaryPosition",t=>{this.cellTarget=t;const{xArr:e,yArr:i}=this.ctx.selector;this.selectorArrStr=JSON.stringify(e)+JSON.stringify(i)}),this.ctx.on("cellClick",t=>{if(this.ctx.adjustPositioning||!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,[l,a]=s;return!(e<o||e>r||t<l||t>a)}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,l=i-s.height-r;this.editorEl.style.bottom="auto",this.drawY<o.height&&(this.editorEl.style.top=`${o.height-1}px`),this.drawY+t>l&&(this.editorEl.style.left=`${this.drawX-1}px`,this.editorEl.style.top="auto",this.editorEl.style.bottom=`${i-l}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:l,drawX:a}=t;this.drawX=a,this.drawY=l;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 x=this.inputEl.value.length;this.inputEl.setSelectionRange(x,x)}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||(this.ctx.emit("drawView"),!(i.isVerticalVisible()&&i.isHorizontalVisible())))return;const{rowKey:o,key:r,editorType:l}=i;if(l==="none")return;const a=this.ctx.database.getReadonly(o,r);i&&!a&&(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:l}=o,a=this.ctx.database.getReadonly(r,l);o&&!a&&(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("drawView"))}clearEditor(){this.doneEdit(),this.cellTarget=null,this.selectorArrStr="",this.ctx.clearSelector(),this.ctx.focusCell=void 0,this.ctx.emit("drawView")}destroy(){var t;(t=this.editorEl)==null||t.remove()}}class gi{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:l})=>{const a=o+(r+l)/2,h={display:s==="empty"?"block":"none",position:"absolute",fontSize:"14px",color:"#666",left:"50%",top:`${a}px`,transform:"translate(-50%, -50%)",...i};Object.assign(this.emptyEl.style,h)})}destroy(){this.emptyEl.remove()}}class wi{constructor(t){n(this,"ctx");this.ctx=t}draw(){const t=this.getContainer();this.ctx.emit("overlayerChange",t)}destroy(){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:l}=this.ctx.header;let a=[],h=[],d=[];l.forEach(w=>{w.render&&(w.fixed==="left"?h.push(w):w.fixed==="right"?d.push(w):a.push(w))});const f=e-i,x={key:"left",style:{position:"absolute",top:"0px",left:"0px",overflow:"hidden",width:`${t}px`,height:`${r}px`},cells:h},u={key:"center",style:{position:"absolute",top:"0px",left:`${t}px`,overflow:"hidden",width:`${o-t-f+1}px`,height:`${r}px`},cells:a},p={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:[x,u,p]}}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(w=>{w.cells.forEach(E=>{E.cellType==="footer"&&(E.render=E.renderFooter),E.render&&(E.fixed==="left"?e.push(E):E.fixed==="right"?i.push(E):t.push(E))})});const{fixedLeftWidth:o,fixedRightWidth:r,config:{SCROLLER_TRACK_SIZE:l,CSS_PREFIX:a}}=this.ctx,{visibleWidth:h,visibleHeight:d}=this.ctx.body,f=r-l,x={key:"left",style:{position:"absolute",top:`${.5}px`,left:`${.5}px`,overflow:"hidden",width:`${o}px`,height:`${d}px`},cells:e},u={key:"center",style:{position:"absolute",top:`${.5}px`,left:`${o-.5}px`,overflow:"hidden",width:`${h-o-f}px`,height:`${d}px`},cells:t},p={key:"right",style:{position:"absolute",top:"0px",right:"0px",overflow:"hidden",width:`${f}px`,height:`${d}px`},cells:i};return{type:"body",class:`${a}-overlayer-body`,style:{position:"relative",overflow:"hidden",width:`${h}px`,height:`${d}px`},views:[x,u,p]}}getFooter(){const t=[],e=[],i=[];this.ctx.footer.renderRows.forEach(g=>{g.cells.forEach(w=>{w.cellType==="footer"&&w.renderFooter&&(w.render=w.renderFooter,w.fixed==="left"?e.push(w):w.fixed==="right"?i.push(w):t.push(w))})});const{fixedLeftWidth:s,fixedRightWidth:o,config:{SCROLLER_TRACK_SIZE:r,CSS_PREFIX:l}}=this.ctx,{visibleWidth:a,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},x={key:"center",style:{position:"absolute",top:`${.5}px`,left:`${s-.5}px`,overflow:"hidden",width:`${a-s-d}px`,height:`${h}px`},cells:t},u={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:`${l}-overlayer-footer`,style:{position:"relative",overflow:"hidden",width:`${a}px`,height:`${h}px`},views:[f,x,u]}}}class pi{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,[l,a]=s,{rowIndex:h,colIndex:d}=t;h>=l&&h<=a&&d>=o&&d<=r||this.ctx.emit("setSelectorCell",t,e);const x={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};Qt(x,this.contextMenuEl,{placement:"right-start",middleware:[Zt(),qt(),Jt()]}).then(({x:u,y:p})=>{this.show(u,p)})}),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 Ei{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,"ctx");this.options=e;const{overlayerElement:i,editorElement:s,emptyElement:o,contextMenuElement:r}=e,l=this.createContainer(t,i,s,o,r);this.ctx=new Ee(l,this.options),this.header=new ye(this.ctx),this.footer=new be(this.ctx),this.body=new Ce(this.ctx),this.scroller=new me(this.ctx),this.selector=new Re(this.ctx),this.autofill=new ve(this.ctx),this.tooltip=new xi(this.ctx),this.empty=new gi(this.ctx),this.editor=new ui(this.ctx),this.overlayer=new wi(this.ctx),this.contextMenu=new pi(this.ctx),this.ctx.on("draw",()=>{this.draw()}),this.ctx.on("drawView",()=>{this.draw(!0)}),this.draw()}createContainer(t,e,i,s,o){t.className="e-virt-table-container";const r=document.createElement("div"),l=document.createElement("canvas"),a=e||document.createElement("div");r.className="e-virt-table-stage",t.tabIndex=0,l.className="e-virt-table-canvas",a.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(l),r.appendChild(a),t.appendChild(r),{containerElement:t,stageElement:r,canvasElement:l,overlayerElement:a,editorElement:h,emptyElement:d,contextMenuElement:f}}draw(t=!1){requestAnimationFrame(()=>{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()})}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.database.setLoading(t)}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:l,key:a}=t[r],h=await this.ctx.database.getValidator(l,a);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[l]=r,{rowKey:a,key:h}=l;this.scrollToRowkey(a),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:l,key:a}=r,h=this.ctx.database.getRowForRowKey(l);if(h){const{parentRowKeys:d=[]}=h;d&&d.length&&this.setExpandRowKeys(d,!0)}this.scrollToRowkey(l),this.scrollToColkey(a)}}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 l=0;l<s.length;l++){const a=this.ctx.database.getRowKeyByItem(i[r]),d=s[l].key,f=await this.ctx.database.getValidator(a,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)}contextMenuHide(){this.contextMenu.hide()}getUtils(){return{mergeColCell:he,mergeRowCell:ae,getSpanArrByRow:Ht,getSpanObjByColumn:Dt}}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.ctx.destroy(),this.ctx.containerElement.remove()}}module.exports=Ei;
|
|
6
6
|
//# sourceMappingURL=index.cjs.js.map
|