PageSourceSearch

https://elysiatools.com/_next/static/chunks/1731538a.dc09c86ab085291d.js

js elysiatools.com collected 2026-10-02 00:17:22 UTC 238,868 bytes, 16 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5538],{19760:(t,e,i)=>{let s;i.r(e),i.d(e,{default:()=>eg}),function(){try{if("u">typeof document){var t=document.createElement("style");t.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-body-bg-color: #fff;--evt-stripe-color: #fafafa;--evt-placeholder-color: #cdd0dc;--evt-header-bg-color: #f8faff;--evt-header-text-color: #1d2129;--evt-body-text-color: #4e5969;--evt-footer-text-color: #4e5969;--evt-loading-icon-color: #4e5969;--evt-expand-icon-color: #4e5969;--evt-shrink-icon-color: #4e5969;--evt-error-tip-icon-color: red;--evt-required-color: #f56c6c;--evt-cell-hover-icon-bg-color: #fff;--evt-cell-hover-icon-border-color: #dde0ea;--evt-scroller-color: #dee0e3;--evt-scroller-track-color: #fff;--evt-scroller-focus-color: #bbbec4;--evt-select-border-color: var(--evt-color-primary);--evt-select-area-color: rgba(82, 146, 247, .1);--evt-select-row-col-bg-color: rgba(82, 146, 247, .1);--evt-autofill-point-border-color: #fff;--evt-edit-bg-color: #fcf6ed;--evt-checkbox-color: var(--evt-color-primary);--evt-checkbox-uncheck-color: #dde0ea;--evt-checkbox-disabled-color: #f1f2f4;--evt-checkbox-check-disabled-color: #dde0ea;--evt-icon-edit-color: #4e5969;--evt-icon-select-color: #4e5969;--evt-readonly-color: #fff;--evt-readonly-text-color: var(--evt-body-text-color);--evt-error-tip-color: #ed3f14;--evt-footer-bg-color: #fafafa;--evt-highlight-hover-row-color: rgba(186, 203, 231, .1);--evt-highlight-selected-row-color: rgba(82, 146, 247, .1);--evt-tooltip-bg-color: #303133;--evt-tooltip-text-color: #fff;--evt-resize-row-line-color: #e1e6eb;--evt-resize-column-text-color: #fff;--evt-resize-column-text-bg-color: var(--evt-color-primary);--evt-resize-column-line-color: #e1e6eb;--evt-tree-line-color: #e1e6eb;--evt-sort-icon-color: var(--evt-color-primary);--evt-drag-tip-bg-color: rgba(82, 146, 247, .1);--evt-drag-tip-line-color: var(--evt-color-primary);--evt-context-menu-min-width: 150px;--evt-context-menu-max-width: 220px;--evt-context-menu-item-padding: 8px 12px;--evt-context-menu-bg-color: #fff;--evt-context-menu-text-color: #333;--evt-context-menu-item-hover-text-color: var(--evt-color-primary);--evt-context-menu-item-hover-bg-color: #f5f5f5;--evt-context-menu-text-size: 13px}.dark{--evt-border-color: #363637;--evt-header-bg-color: #141414;--evt-body-bg-color: #141414;--evt-header-text-color: #a3a6ad;--evt-body-text-color: #cfd3dc;--evt-readonly-text-color: #cfd3dc;--evt-footer-text-color: #cfd3dc;--evt-scroller-color: #414243;--evt-scroller-track-color: #141414;--evt-scroller-focus-color: #a3a6ad;--evt-edit-bg-color: #141414;--evt-footer-bg-color: #262727;--evt-autofill-point-border-color: #fff;--evt-editor-bg-color: #434343;--evt-editor-text-color: #cfd3dc;--evt-context-menu-bg-color: #141414;--evt-context-menu-text-color: #cfd3dc;--evt-context-menu-item-hover-text-color: var(--evt-color-primary);--evt-context-menu-item-hover-bg-color: #414243}.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;background-color:var(--evt-body-bg-color);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;
1left:-99999px;top:-99999px}.e-virt-table-context-menu-item{cursor:pointer;padding:6px 24px;color:var(--evt-text-color-regular)}.e-virt-table-context-menu-item:hover{color:var(--evt-color-primary);background-color:#f5f7fa}.e-virt-table-loading{display:none;position:absolute;left:0;top:0;right:0;bottom:0;width:100%;height:100%;z-index:2000;background-color:#fff6;display:flex;align-items:center;justify-content:center}.e-virt-table-loading-spinner{opacity:1;display:flex;flex-direction:column;align-items:center;justify-content:center}.e-virt-table-loading-spinner svg{color:var(--evt-text-color-regular);animation:rotate 1s linear infinite}@keyframes rotate{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.e-virt-table-loading-text{margin:0;font-size:12px;color:var(--evt-text-color-regular)}.e-virt-table-main-menu,.e-virt-table-submenu{position:absolute;background:var(--evt-context-menu-bg-color);border-radius:4px;box-shadow:0 2px 8px #0000001a;min-width:var(--evt-context-menu-min-width);max-width:var(--evt-context-menu-max-width);color:var(--evt-text-color-primary)}.e-virt-table-main-menu{border:1px solid var(--evt-border-color);z-index:3000;left:-99999px;top:-99999px;display:none;position:fixed;background-color:var(--evt-body-bg-color)}.e-virt-table-submenu{border:1px solid var(--evt-border-color);z-index:1000;max-height:350px;overflow-y:auto;opacity:0;visibility:hidden;transform:translate(-10px);transition:opacity .2s,visibility .2s,transform .2s;-ms-overflow-style:none;scrollbar-width:none}.e-virt-table-submenu::-webkit-scrollbar{display:none}.e-virt-table-submenu.show{opacity:1;visibility:visible;transform:translate(0)}.e-virt-table-submenu:not(.show){transition:none}.e-virt-table-menu-item,.e-virt-table-submenu-item{position:relative;-webkit-user-select:none;user-select:none;padding:var(--evt-context-menu-item-padding);cursor:pointer;display:flex;justify-content:space-between;align-items:center;transition:background .2s,color .2s;color:var(--evt-context-menu-text-color);font-size:var(--evt-context-menu-text-size)}.e-virt-table-menu-item:last-child,.e-virt-table-submenu-item:last-child{border-bottom:none}.e-virt-table-menu-item:has(.e-virt-table-menu-item-icon){padding-left:8px}.e-virt-table-menu-item-content{display:flex;align-items:center;flex:1;min-width:0}.e-virt-table-menu-item-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;margin-right:8px;flex-shrink:0}
1.e-virt-table-menu-item-icon svg{width:100%;height:100%;fill:currentColor}.e-virt-table-menu-item-text{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.e-virt-table-menu-arrow{display:inline-flex;align-items:center;justify-content:center;color:var(--evt-text-color-regular);transition:color .2s}.e-virt-table-menu-arrow svg{width:20px;height:20px;fill:currentColor}.e-virt-table-submenu-item:hover,.e-virt-table-menu-item:hover,.e-virt-table-menu-item.active{background:var(--evt-context-menu-item-hover-bg-color);color:var(--evt-context-menu-item-hover-text-color)}.e-virt-table-menu-item.disabled,.e-virt-table-submenu-item.disabled{cursor:not-allowed}.e-virt-table-finder-bar{position:absolute;top:8px;right:16px;display:none;z-index:10000;background:#fff;border:1px solid #dadce0;border-radius:12px;box-shadow:0 2px 6px #0003;padding:0 8px;height:48px;min-width:250px;align-items:center;font-size:12px}.e-virt-table-finder-bar.show{display:flex}.e-virt-table-finder-bar-input-wrapper{display:flex;align-items:center;flex:1;padding:0 8px;position:relative}.e-virt-table-finder-bar-input{border:none;outline:none;flex:1;font-size:12px;background:transparent;color:#333;min-width:150px;padding-left:0;position:relative}.e-virt-table-finder-bar-nav{display:flex;flex-direction:row;gap:8px;margin:0 8px;align-items:center}.e-virt-table-finder-bar-nav-btn{border:none;background:transparent;cursor:pointer;padding:0;color:#666;border-radius:50%;display:flex;align-items:center;justify-content:center}.e-virt-table-finder-bar-nav-btn svg{width:24px;height:24px}.e-virt-table-finder-bar-nav-btn.prev-btn{transform:rotate(-90deg)}.e-virt-table-finder-bar-nav-btn.next-btn{transform:rotate(90deg)}.e-virt-table-finder-bar-nav-btn.close-btn{font-size:24px;color:#666;line-height:1;width:24px;height:24px}.e-virt-table-finder-bar-nav-btn:hover{color:#666;background-color:#f0f0f0}.e-virt-table-finder-bar-count{color:#666;font-size:12px;margin:0 8px;white-space:nowrap;flex-shrink:0}
1.e-virt-table-finder-bar-count.no-results{color:#999}.e-virt-table-finder-bar-loading{display:none;position:absolute;left:8px;top:0;width:16px;height:16px;flex-shrink:0;pointer-events:none;z-index:0}.e-virt-table-finder-bar-loading.show{display:block}.e-virt-table-finder-bar-loading svg{width:100%;height:100%;color:#666;animation:rotate 1s linear infinite}.e-virt-table-empty{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);font-size:14px;color:#666;z-index:15}")),document.head.appendChild(t)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}}();var r=Object.defineProperty,l=(t,e,i)=>((t,e,i)=>e in t?r(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i)(t,"symbol"!=typeof e?e+"":e,i);class o{constructor(t){l(this,"rules"),this.rules=t}validate(t){let e=[],{column:i,row:s,key:r,rowKey:l,colIndex:o,rowIndex:h,value:n,field:a,fieldValue:c}=t;for(let t of(Array.isArray(this.rules)||(this.rules=[this.rules]),this.rules)){if(t.validator){let d={field:a,fieldValue:c,value:n,column:i,colIndex:o,rowIndex:h,row:s,key:r,rowKey:l,...t};t.validator(d,n,t=>{t&&e.push({...d,message:t})})}if(!t.required&&(null==n||""===n))break;t.pattern&&!t.pattern.test(n)&&e.push({value:n,column:i,row:s,key:r,rowKey:l,colIndex:o,rowIndex:h,field:a,fieldValue:c,message:t.message||`${r} is pattern validation error`}),t.required&&(null==n||""===n)&&e.push({value:n,column:i,row:s,key:r,rowKey:l,colIndex:o,rowIndex:h,field:a,fieldValue:c,message:t.message||`${r} is required`})}return e}}function h(){return"xxxxxxxxxxxxxxxxxx".replace(/[x]/g,function(t){let e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})}function n(t,e){let i=0,s;return function(...r){let l=new Date().getTime(),o=l-i,h="function"==typeof e?e():e;!i||o>=h?(t.apply(this,r),i=l):s||(s=setTimeout(()=>{t.apply(this,r),i=new Date().getTime(),s=void 0},h-o))}}function a(t=[]){return t.length?t.map(t=>a(t.children)+1).sort((t,e)=>e-t)[0]:0}function c(t=[],e=1,i=0,s=""){return t.sort((t,e)=>(t.sort??0)-(e.sort??0)).map(t=>{if(t.children){let r=0,l=t.fixed;t.children.forEach(t=>{t.fixed=l});let o=c(t.children,e-1,i+1,t.key);return o&&o.forEach(t=>{r+=t.colspan??0}),{...t,width:t.width,level:i,rowspan:1,colspan:r,parentKey:s,children:o.sort((t,e)=>(t.sort??0)-(e.sort??0))}}return{...t,level:i,rowspan:e,colspan:1,parentKey:s}})}function d(t=[]){let e=[];return t.forEach(t=>{t.children?e=e.concat(d(t.children)):e.push(t)}),e}let x=/^(\r\n|\n\r|\r|\n)/,u=/^[^\t\r\n]+/,g=/^\t/;function f(t,e,i=[]){let s=0,r=[];return t.forEach((l,o)=>{0===o?r.push(1):(i.reduce((t,e)=>`${t}${l[e]??""}`,"")||l[e])===(i.reduce((e,i)=>`${e}${t[o-1][i]??""}`,"")||t[o-1][e])?(r[s]+=1,r.push(0)):(r.push(1),s=o)}),r}function m(t,e){let i="",s="",r={};return e.forEach((e,l)=>{0===l?(i=e.key,s=e.key,r[e.key]=1):t[e.key]===t[i]?(r[e.key]=0,r[s]+=1):(r[e.key]=1,i=e.key,s=e.key)}),r}function p(t,e,i=[]){let{visibleRows:s,rowIndex:r,headIndex:l}=t,o=f(s,e,i);return 0===o[r-l]?{rowspan:0,colspan:0,relationRowKeys:i,mergeRow:!0}:{rowspan:o[r-l],colspan:1,relationRowKeys:i,mergeRow:!0}}function w(t,e=[]){let{column:i,row:s,visibleLeafColumns:r}=t,l=r.filter(t=>e.includes(t.key));if(e.includes(i.key)){let t=m(s,l);return 0===t[i.key]?{rowspan:0,colspan:0,relationColKeys:e,mergeCol:!0}:{rowspan:1,colspan:t[i.key],relationColKeys:e,mergeCol:!0}}}function E(t){if(!t)return new Date(0);if("number"==typeof t)return new Date(t);let e=String(t).trim(),i=new Date(e);if(!isNaN(i.getTime()))return i;for(let t of[/^(\d{4})-(\d{1,2})-(\d{1,2})$/,/^(\d{4})\/(\d{1,2})\/(\d{1,2})$/,/^(\d{4})\.(\d{1,2})\.(\d{1,2})$/,/^(\d{1,2})-(\d{1,2})-(\d{4})$/,/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/,/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/,/^(\d{1,2})-(\d{1,2})-(\d{4})$/,/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/,/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/,/^(\d{4})(\d{2})(\d{2})$/,/^(\d{4})-(\d{1,2})-(\d{1,2})\s+(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?$/,/^(\d{4})\/(\d{1,2})\/(\d{1,2})\s+(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?$/]){let i=e.match(t);if(i){let e=i.slice(1).map(Number);if(t.source.includes("YYYY-MM-DD")||t.source.includes("YYYY/MM/DD")||t.source.includes("YYYY.MM.DD")){let[t,i,s,r=0,l=0,o=0]=e;return new Date(t,i-1,s,r,l,o)}if(t.source.includes("DD-MM-YYYY")||t.source.includes("DD/MM/YYYY")||t.source.includes("DD.MM.YYYY")){let[t,i,s,r=0,l=0,o=0]=e;return new Date(s,i-1,t,r,l,o)}if(t.source.includes("MM-DD-YYYY")||t.source.includes("MM/DD/YYYY")||t.source.includes("MM.DD.YYYY")){let[t,i,s,r=0,l=0,o=0]=e;return new Date(s,t-1,i,r,l,o)}else if(t.source.includes("YYYYMMDD")){let[t,i,s]=e;return new Date(t,i-1,s)}}}return new Date(NaN)}class y{constructor(t,e,i,s,r,o,h){l(this,"ctx"),l(this,"x",0),l(this,"y",0),l(this,"width",0),l(this,"height",0),l(this,"visibleWidth",0),l(this,"visibleHeight",0),l(this,"fixed"),l(this,"cellType"),l(this,"drawX",0),l(this,"drawY",0),l(this,"cellImages",new Map),this.ctx=t,this.x=e,this.y=i,this.width=s,this.height=r,this.fixed=h,this.cellType=o}isHorizontalVisible(){if(this.fixed)return!0;let{stageWidth:t,fixedLeftWidth:e,scrollX:i,fixedRightWidth:s}=this.ctx;return!(this.x+this.width-e-i<=0||this.x-i>=t-s)}isVerticalVisible(){let{stageHeight:t,scrollY:e}=this.ctx;return!(this.y+this.height-e<=0||this.y-e>=t)}getDrawX(){if("left"===this.fixed)return this.x;
1if("right"===this.fixed){let{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"header"===this.cellType||"footer"===this.cellType&&this.ctx.config.FOOTER_FIXED?this.y:this.y-this.ctx.scrollY}getLeftFixedX(){return this.x-this.ctx.scrollX}isInside(t,e){return t>=this.drawX&&t<=this.drawX+this.width&&e>=this.drawY&&e<=this.drawY+this.height}isInsideVisible(t,e){return t>=this.drawX&&t<=this.drawX+this.visibleWidth&&e>=this.drawY&&e<=this.drawY+this.visibleHeight&&this.isInside(t,e)}setImage(t,e){this.cellImages.set(t,e)}getImages(){return this.cellImages}getImage(t){return this.cellImages.get(t)}isImageInside(t,e){let{offsetX:i,offsetY:s}=this.ctx.getOffset(e),r=this.getImage(t);return!!r&&r.isInside(i,s)}}class b{constructor(t,e,i,s,r,o){l(this,"source"),l(this,"name"),l(this,"x"),l(this,"y"),l(this,"width"),l(this,"height"),l(this,"visible",!0),this.source=o,this.name=t,this.x=e,this.y=i,this.width=s,this.height=r}drawWrapper(t,e){t.paint.drawRect(this.x-2,this.y-2,this.width+4,this.height+4,{radius:4,borderWidth:1,...e})}setVisible(t){this.visible=t}isInside(t,e){return!!this.visible&&!!(this.source&&t>this.x&&t<this.x+this.width&&e>this.y&&e<this.y+this.height)}}class v extends y{constructor(t,e,i,s,r,o,h,n,a,c="body",d=!0){super(t,s,r,o,h,c,n.fixed),l(this,"parentRowKey",""),l(this,"parentRowKeys",[]),l(this,"formatter"),l(this,"formatterFooter"),l(this,"hoverIconName",""),l(this,"operation",!1),l(this,"align"),l(this,"verticalAlign"),l(this,"fixed"),l(this,"type"),l(this,"editorType"),l(this,"editorProps"),l(this,"cellType"),l(this,"level"),l(this,"colspan",1),l(this,"rowspan",1),l(this,"mergeRow",!1),l(this,"mergeCol",!1),l(this,"relationRowKeys",[]),l(this,"relationColKeys",[]),l(this,"key"),l(this,"column"),l(this,"rowIndex"),l(this,"colIndex"),l(this,"rowKey"),l(this,"row"),l(this,"value"),l(this,"render"),l(this,"renderFooter"),l(this,"style",{}),l(this,"domDataset",{}),l(this,"rules",[]),l(this,"message",""),l(this,"text",""),l(this,"displayText",""),l(this,"visibleWidth",0),l(this,"visibleHeight",0),l(this,"isHasChanged",!1),l(this,"drawX",0),l(this,"drawY",0),l(this,"drawCellBgColor",""),l(this,"drawCellSkyBgColor",""),l(this,"drawTextColor",""),l(this,"drawTextFont",""),l(this,"drawTextX",0),l(this,"drawTextY",0),l(this,"drawTextWidth",0),l(this,"drawTextHeight",0),l(this,"autoRowHeight",!1),l(this,"calculatedHeight",0),l(this,"ellipsis",!1),l(this,"rowExpand",!1),l(this,"rowHasChildren",!1),l(this,"overflowTooltipShow",!0),l(this,"selectorCellValueType","value"),l(this,"overflowTooltipMaxWidth",500),l(this,"overflowTooltipPlacement","top"),l(this,"maxLineClamp","auto"),l(this,"precision"),l(this,"min"),l(this,"max"),l(this,"maxlength"),l(this,"mixedRender",!1),l(this,"renderType","default"),l(this,"renderFooterType","default"),this.visibleWidth=this.width,this.visibleHeight=this.height,this.colIndex=i,this.rowIndex=e,this.key=n.key,this.type=n.type||"",this.editorType=n.editorType||"text",this.selectorCellValueType=n.selectorCellValueType||this.ctx.config.SELECTOR_CELL_VALUE_TYPE||"value",this.editorProps=n.editorProps||{},this.cellType=c,this.align=n.align||this.ctx.config.COLUMNS_ALIGN,this.verticalAlign=n.verticalAlign||this.ctx.config.COLUMNS_VERTICAL_ALIGN,this.fixed=n.fixed||"",this.level=n.level||0,this.operation=n.operation||!1,this.column=n,this.rules=n.rules||[],this.row=a,this.rowKey="body"===this.cellType?this.ctx.database.getRowKeyForRowIndex(e):`${this.cellType}_${this.rowIndex}`,this.value=this.getValue(),this.render=n.render,this.overflowTooltipShow=!1!==n.overflowTooltipShow,this.autoRowHeight=void 0!==n.autoRowHeight?n.autoRowHeight:this.ctx.config.AUTO_ROW_HEIGHT,this.overflowTooltipMaxWidth=n.overflowTooltipMaxWidth||500,this.overflowTooltipPlacement=n.overflowTooltipPlacement||"top",this.renderFooter=n.renderFooter,this.hoverIconName=n.hoverIconName,this.formatter=n.formatter,this.formatterFooter=n.formatterFooter,this.maxLineClamp=n.maxLineClamp||"auto",this.precision=n.precision,this.min=n.min,this.max=n.max,this.maxlength=n.maxlength,this.mixedRender=n.mixedRender||!1,this.renderType=n.renderType||"default",this.renderFooterType=n.renderFooterType||"default";let x=this.ctx.database.getRowForRowKey(this.rowKey);"body"===this.cellType&&x&&(this.parentRowKey=x.parentRowKey,this.parentRowKeys=x.parentRowKeys),d&&this.update()}setWidthHeight(t,e){this.width=t,this.height=e}getValidationMessage(){let t=this.ctx.database.getValidationError(this.rowKey,this.key);if(Array.isArray(t)&&t.length){let[e]=t;this.message=e.message||""}return this.message}update(){this.drawX=this.getDrawX(),this.drawY=this.getDrawY(),this.updateSpan(),this.updateDragImage();let t=this.getImage("drag"),e=t?t.width:0;this.drawTextX=this.drawX+e,this.drawTextY=this.drawY,this.isHasChanged=this.ctx.database.isHasChangedData(this.rowKey,this.key),this.drawTextWidth=this.visibleWidth-e,this.drawTextHeight=this.visibleHeight,this.updateStyle(),this.updateType(),this.updateHoverIcon(),this.updateSelection(),this.updateTree(),this.updateEditor(),this.updateRender(),this.getValidationMessage(),this.updateContainer(),this.text=this.getText(),this.displayText=this.getDisplayText()}updateSpan(){if("footer"===this.cellType)return;let{SPAN_METHOD:t}=this.ctx.config;
1if("function"==typeof t){let{colspan:e=1,rowspan:i=1,relationRowKeys:s,relationColKeys:r,mergeRow:l=!1,mergeCol:o=!1}=t({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(s)&&s.length>0?this.relationRowKeys=s:this.relationRowKeys=[this.key],Array.isArray(r)&&r.length>0?this.relationColKeys=r:this.relationColKeys=[this.key],this.mergeCol=o,this.mergeRow=l,this.colspan=e,this.rowspan=i,this.visibleWidth=this.getWidthByColIndexColSpan(this.colIndex,this.colspan),this.visibleHeight=this.ctx.database.getHeightByRowIndexRowSpan(this.rowIndex,this.rowspan)}}updateSpanInfo(){if(this.mergeRow||this.mergeCol){let t=this.getSpanInfo();this.height=t.height,this.width=t.width,this.drawX=this.getDrawX(),this.drawY=this.getDrawY(),this.drawY-=t.offsetTop,this.drawX-=t.offsetLeft}}updateType(){let{BODY_CELL_TYPE_METHOD:t}=this.ctx.config;if("function"==typeof t){let e=t({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});void 0!==e&&(this.type=e)}}updateEditor(){let{BODY_CELL_EDITOR_METHOD:t}=this.ctx.config;if("function"==typeof t){let e=t({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});if(void 0!==e){let{type:t,props:i={}}=e;this.editorType=t,this.editorProps=i}}}updateRender(){let{BODY_CELL_RENDER_METHOD:t}=this.ctx.config;if("function"==typeof t){let e=t({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});void 0!==e&&(this.render=e)}}validate(){this.ctx.database.getValidator(this.rowKey,this.key).then(()=>{this.ctx.database.setValidationError(this.rowKey,this.key,[]),this.message=""}).catch(t=>{if(Array.isArray(t)&&t.length){let[e]=t;this.message=e.message,this.ctx.database.setValidationError(this.rowKey,this.key,t)}}).finally(()=>{this.ctx.emit("draw")})}updateStyle(){this.autoRowHeight&&(this.domDataset={"data-auto-height":!0,"data-row-index":this.rowIndex,"data-col-index":this.colIndex}),this.style=this.getOverlayerViewsStyle()}isInsideVisible(t,e){return t>=this.drawX&&t<=this.drawX+this.visibleWidth&&e>=this.drawY&&e<=this.drawY+this.visibleHeight}updateTree(){let{CELL_PADDING:t=0}=this.ctx.config,{rowKey:e,cellType:i}=this,s,r=0,l="";if(!(["tree","selection-tree","tree-selection"].includes(this.type)&&"body"===i))return;let{expand:o=!1,hasChildren:h=!1,expandLoading:n=!1,level:a=0}=this.ctx.database.getRowForRowKey(e)||{};this.rowExpand=o,this.rowHasChildren=h;let{TREE_INDENT:c=16,CHECKBOX_SIZE:d,TREE_ICON_SIZE:x}=this.ctx.config;if(r=a*c,n)l="loading",s=this.ctx.icons.get("loading");else if(h){let t=this.ctx.icons.get("expand"),e=this.ctx.icons.get("shrink");s=o?e:t,l=o?"shrink":"expand"}let u=this.drawX;("center"===this.align||"right"===this.align)&&(u=this.drawX+(this.visibleWidth-x-2*t)/2,this.align="left");let g=u+r+t,f=this.drawY+(this.visibleHeight-x)/2,m=r+this.drawX+x-.5,p=this.getImage("selection"),w=this.getImage("drag"),E=w?w.width:0;"selection-tree"===this.type&&p?m=(g=r+p.x+p.width)+x-t/2:"tree-selection"===this.type?(g+=E,m=g+d+x-t/2):(g+=E,m=g+x-t/2),this.drawTextX=m,this.drawTextWidth=this.drawX+this.visibleWidth-m,!(g+x+t>this.drawX+this.visibleWidth)&&(f+x+t>this.drawY+this.visibleHeight||this.setImage("tree",new b(l,g,f,x,x,s)))}updateDragImage(){if("body"===this.cellType&&this.column.dragRow){let{DRAG_ROW_ICON_SIZE:t,CELL_PADDING:e}=this.ctx.config,i=new b("drag",this.drawX+e/2,this.drawY+(this.visibleHeight-t)/2,t,t,this.ctx.icons.get("drag"));0===this.rowspan&&i.setVisible(!1),this.setImage("drag",i)}}drawTreeLine(){let{TREE_LINE:t,TREE_INDENT:e=16,TREE_ICON_SIZE:i=16,TREE_LINE_COLOR:s="#e1e6eb"}=this.ctx.config;if(!t||"body"!==this.cellType||!["tree","selection-tree","tree-selection"].includes(this.type)||0===this.rowspan||0===this.colspan)return;let r=this.ctx.database.getRowForRowKey(this.rowKey)||{},l=r.level??0,o=this.getImage("tree");if(!o)return;let h=o.x,n=o.y,a=o.width,c=o.height,d=h+a/2,x=n+c/2,u=Array.isArray(r.parentRowKeys)?r.parentRowKeys:[];if(l>0){for(let t=0;t<l-1;t+=1){let r=u[t+1];if((r&&this.ctx.database.getRowForRowKey(r)||{}).isLastChild)continue;let o=Math.round(h-(l-t)*e+i/2);this.ctx.paint.drawLine([o,this.drawY,o,this.drawY+this.visibleHeight],{borderColor:s,borderWidth:1,lineDash:[4,4],lineDashOffset:0})}let t=Math.round(h-e+i/2),o=r.isLastChild?x:this.drawY+this.visibleHeight;this.ctx.paint.drawLine([t,this.drawY,t,o],{borderColor:s,borderWidth:1,lineDash:[4,4],lineDashOffset:0});let n=Math.round(h-l*e+(l-1)*e+i/2);this.ctx.paint.drawLine([n,x,d,x],{borderColor:s,borderWidth:1,lineDash:[4,4],lineDashOffset:0})}if(r.hasChildren&&r.expand){let t=this.drawY+this.visibleHeight;this.ctx.paint.drawLine([d,n+c,d,t],{borderColor:s,borderWidth:1,lineDash:[4,4],lineDashOffset:0})}}updateContainer(){let{BODY_BG_COLOR:t,EDIT_BG_COLOR:e,BODY_CELL_STYLE_METHOD:i,FOOTER_CELL_STYLE_METHOD:s,READONLY_TEXT_COLOR:r,BODY_TEXT_COLOR:l,FOOTER_TEXT_COLOR:o,FOOTER_BG_COLOR:h,HIGHLIGHT_SELECTED_ROW:n,HIGHLIGHT_SELECTED_ROW_COLOR:a,HIGHLIGHT_HOVER_ROW:c,HIGHLIGHT_HOVER_ROW_COLOR:d,STRIPE:x,STRIPE_COLOR:u,FINDER_CELL_BG_COLOR:g}=this.ctx.config;if("footer"===this.cellType){let t=h,e=o;
1if("function"==typeof s){let{backgroundColor:i,color:r,font:l}=s({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()})||{};i&&(t=i),r&&(e=r),l&&(this.drawTextFont=l)}this.drawCellSkyBgColor="transparent",this.drawCellBgColor=t,this.drawTextColor=e;return}let f="transparent",m=this.ctx.hoverCell,p=this.ctx.currentCell,w=this.rowIndex,E=this.rowIndex;if(1!==this.rowspan&&(c||n)){let{yArr:t}=this.getSpanInfo();w=t[0],E=t[1]}c&&m&&!this.ctx.dragRowIng&&(m.rowKey===this.rowKey&&(f=d),m.rowIndex>=w&&m.rowIndex<=E&&(f=d)),n&&p&&!this.ctx.dragRowIng&&(p.rowKey===this.rowKey&&(f=a),p.rowIndex>=w&&p.rowIndex<=E&&(f=a)),this.drawCellSkyBgColor=f;let y=t,b=l;if(this.ctx.database.getReadonly(this.rowKey,this.key)||(y=e,b=r),x&&(y=this.rowIndex%2?u:t),"function"==typeof i){let{backgroundColor:t,color:e,font:s}=i({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,isHasChanged:this.isHasChanged,value:this.getValue()})||{};t&&(y=t),e&&(b=e),s&&(this.drawTextFont=s)}let{rowIndex:v,colIndex:C,type:R}=this.ctx.finderBar;v===this.rowIndex&&C===this.colIndex&&"body"===R&&(y=g),this.drawCellBgColor=y,this.drawTextColor=b}updateSelection(){let{visibleWidth:t,visibleHeight:e,rowspan:i,colspan:s,cellType:r,type:l,rowIndex:o,rowKey:h}=this;if(0===i||0===s||"footer"===r||!["index-selection","selection","selection-tree","tree-selection"].includes(l))return;let n=this.ctx.database.getRowSelectable(h),{CHECKBOX_SIZE:a=0,CELL_PADDING:c}=this.ctx.config,d=this.drawX+c;("center"===this.align||"right"===this.align)&&(d=this.drawX+(t-a)/2);let x=d,u=this.drawY+(e-a)/2;if("selection-tree"!==l&&"tree-selection"===l){let{TREE_INDENT:t=16,TREE_ICON_SIZE:e}=this.ctx.config,{level:i=0}=this.ctx.database.getRowForRowKey(h)||{};x=d+e+i*t}let g=this.ctx.icons.get("checkbox-uncheck"),f="checkbox-uncheck";if("selection-tree"===l||"tree-selection"===l){let t=this.ctx.database.getTreeSelectionState(h);t.indeterminate&&n?(g=this.ctx.icons.get("checkbox-indeterminate"),f="checkbox-indeterminate"):t.checked&&n?(g=this.ctx.icons.get("checkbox-check"),f="checkbox-check"):!t.checked&&n?(g=this.ctx.icons.get("checkbox-uncheck"),f="checkbox-uncheck"):(g=this.ctx.icons.get("checkbox-disabled"),f="checkbox-disabled")}else{let t=this.ctx.database.getRowSelection(h);t&&n?(g=this.ctx.icons.get("checkbox-check"),f="checkbox-check"):t&&!n?(g=this.ctx.icons.get("checkbox-check-disabled"),f="checkbox-check-disabled"):!t&&n?(g=this.ctx.icons.get("checkbox-uncheck"),f="checkbox-uncheck"):(g=this.ctx.icons.get("checkbox-disabled"),f="checkbox-disabled")}let m=this.getImage("drag");if((x+=m?m.width:0)+a+c>this.drawX+this.visibleWidth||u+a+c>this.drawY+this.visibleHeight)return;let p=new b(f,x,u,a,a,g);if("index-selection"===l){p.setVisible(!1),(this.ctx.hoverCell&&this.ctx.hoverCell.rowIndex===o||["checkbox-disabled","checkbox-check"].includes(f))&&p.setVisible(!0);let t=this.rowIndex,e=this.rowIndex,i=this.ctx.hoverCell,{yArr:s}=this.getSpanInfo();t=s[0],e=s[1],i&&i.rowIndex>=t&&i.rowIndex<=e&&p.setVisible(!0)}this.setImage("selection",p)}updateHoverIcon(){if(this.ctx.database.getReadonly(this.rowKey,this.key))return;let{BODY_CELL_HOVER_ICON_METHOD:t,CELL_HOVER_ICON_SIZE:e,CELL_PADDING:i,ENABLE_MERGE_CELL_LINK:s}=this.ctx.config;if("function"==typeof t){let e=t({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});void 0!==e&&(this.hoverIconName=e)}let{hoverCell:r}=this.ctx;if(this.hoverIconName&&!this.ctx.editing&&!this.ctx.dragRowIng&&r){let t=0,l=0;if(r.rowKey===this.rowKey&&(t=this.drawX+this.width-e-i,l=this.drawY+(this.height-e)/2),1!==this.rowspan&&s){let s=this.getSpanInfo(),{yArr:o}=s,h=o[0],n=o[1];if(r.rowIndex>=h&&r.rowIndex<=n){let{width:r,height:o,offsetTop:h,offsetLeft:n}=s;t=this.drawX-n+r-e-i,l=this.drawY-h+(o-e)/2}}let o=this.ctx.icons.get(this.hoverIconName),h=new b(this.hoverIconName,t,l,e,e,o);(0===this.rowspan||0===this.colspan)&&h.setVisible(!1),this.setImage("hover",h)}}getAutoHeight(){if("body"!==this.cellType||!this.autoRowHeight||0===this.rowspan)return 0;if(this.render){let t=this.ctx.database.getOverlayerAutoHeight(this.rowIndex,this.colIndex);return this.rowspan>1?t<this.visibleHeight?0:Math.round(t-(this.visibleHeight-this.height)):Math.round(t)}if(!(this.displayText&&"string"==typeof this.displayText))return 0;let{BODY_FONT:t,CELL_PADDING:e,CELL_LINE_HEIGHT:i}=this.ctx.config,s=`${this.displayText}_${this.drawTextWidth}_${this.drawTextFont}`,r=this.ctx.paint.calculateTextHeight(this.displayText,this.drawTextWidth,{font:this.drawTextFont||t,padding:e,align:this.align,verticalAlign:this.verticalAlign,color:this.drawTextColor,autoRowHeight:this.autoRowHeight,lineHeight:i,maxLineClamp:this.maxLineClamp,cacheTextKey:s});return this.rowspan>1?r<this.visibleHeight?0:Math.round(r-(this.visibleHeight-this.height)):Math.round(r)}getSpanInfo(){return this.ctx.database.getSpanInfo(this)}getDisplayText(){if("footer"===this.cellType)return this.renderFooter&&"default"===this.renderFooterType||null===this.text||void 0===this.text?"":this.text;{if(0===this.rowspan||0===this.colspan||this.render&&"default"===this.renderType&&!this.mixedRender)return"";let t=this.getImage("selection");return"index-selection"===this.type&&t&&t.visible||null===this.text||void 0===this.text?"":`${this.text}`}}getText(){if("footer"===this.cellType)return"function"==typeof this.formatterFooter?this.formatterFooter({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.row[this.key]}):this.row[this.key];if("function"==typeof this.formatter)return this.formatter({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});let{BODY_CELL_FORMATTER_METHOD:t}=this.ctx.config;return"function"==typeof t?t({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()}):["index-selection","index"].includes(this.type)?`${this.rowIndex+1}
1`:(this.value=this.ctx.database.getItemValue(this.rowKey,this.key),this.value)}getValue(){return this.ctx.database.getItemValue(this.rowKey,this.key)}setValue(t){this.ctx.setItemValueByEditor(this.rowKey,this.key,t)}getOverlayerViewsStyle(){let t=this.drawX-this.ctx.fixedLeftWidth,e=this.drawY-this.ctx.body.y;if("left"===this.fixed?t=this.drawX:"right"===this.fixed&&(t=this.drawX-(this.ctx.stageWidth-this.ctx.fixedRightWidth)),"footer"===this.cellType&&this.ctx.config.FOOTER_FIXED&&(e=this.drawY-this.ctx.footer.y),this.autoRowHeight&&this.render&&"middle"===this.verticalAlign){let t=this.ctx.database.getOverlayerAutoHeight(this.rowIndex,this.colIndex);t<this.visibleHeight&&t>0&&(e+=(this.visibleHeight-t)/2)}this.autoRowHeight&&0===this.ctx.database.getOverlayerAutoHeight(this.rowIndex,this.colIndex)&&(t=-99999,e=-99999);let i={};return 0===this.rowspan&&(i={display:"none"}),{position:"absolute",overflow:"hidden",left:`${Math.round(t-1)}px`,top:`${Math.round(e-1)}px`,width:`${this.visibleWidth}px`,height:this.autoRowHeight&&"default"===this.renderType?"auto":`${this.visibleHeight}px`,pointerEvents:"initial",userSelect:"none",...i}}drawContainer(){let{paint:t,config:{BORDER_COLOR:e,BORDER:i}}=this.ctx,{drawX:s,drawY:r}=this;t.drawRect(s,r,this.visibleWidth,this.visibleHeight,{borderColor:i?e:"transparent",fillColor:this.drawCellBgColor}),t.drawRect(s,r,this.width,this.height,{borderColor:"transparent",fillColor:this.drawCellSkyBgColor}),i||this.ctx.paint.drawLine([s,r+this.visibleHeight,s+this.visibleWidth,r+this.visibleHeight],{borderColor:e,fillColor:e,borderWidth:1,lineCap:"round",lineJoin:"round"})}drawAutofillPiont(){if("footer"===this.cellType)return;let{SELECT_BORDER_COLOR:t,ENABLE_AUTOFILL:e,ENABLE_SELECTOR:i,AUTOFILL_POINT_BORDER_COLOR:s}=this.ctx.config;if(!i||!e||this.ctx.editing)return;let{xArr:r,yArr:l}=this.ctx.selector,o=r[1],h=l[1],{colIndex:n,rowIndex:a,drawX:c,drawY:d}=this;if(n===o&&a===h){let e=n===this.ctx.maxColIndex||a===this.ctx.maxRowIndex||n===this.ctx.lastCenterColIndex?6:4;this.ctx.paint.drawRect(c+this.width-e,d+this.height-e,6,6,{borderColor:s,fillColor:t})}}draw(){this.drawTreeLine(),this.drawText(),this.drawImage(),this.drawSelector(),this.drawAutofillPiont(),this.drawErrorTip()}getWidthByColIndexColSpan(t,e){if(0===e)return 0;let i=0;for(let s=t;s<t+e;s++)i+=this.ctx.header.leafCellHeaders[s].width;return i}drawText(){let{CELL_PADDING:t,BODY_FONT:e,PLACEHOLDER_COLOR:i,CELL_LINE_HEIGHT:s}=this.ctx.config,{placeholder:r}=this.column,l=this.displayText,o=this.drawTextColor;if(!this.ctx.database.getReadonly(this.rowKey,this.key)&&r&&["",null,void 0].includes(this.text)&&"body"===this.cellType&&0!==this.rowspan&&0!==this.colspan&&(l=r,o=i),["",null,void 0].includes(l))return!1;"string"!=typeof l&&(l=`${l}`);let h=`${l}_${this.drawTextWidth}_${this.drawTextFont}`;return this.ellipsis=this.ctx.paint.drawText(l,this.drawTextX,this.drawTextY,this.drawTextWidth,this.drawTextHeight,{font:this.drawTextFont||e,padding:t,align:this.align,verticalAlign:this.verticalAlign,color:o,autoRowHeight:this.autoRowHeight,lineHeight:s,maxLineClamp:this.maxLineClamp,cacheTextKey:h,layoutCallback:t=>{this.ctx.emit("registerTextLayout",`${this.cellType}-${this.rowIndex}-${this.colIndex}`,t)}}),this.ellipsis}
1drawImage(){this.getImages().forEach((t,e)=>{if(t.visible&&t.source){if("hover"===e){let{CELL_HOVER_ICON_BG_COLOR:e,CELL_HOVER_ICON_BORDER_COLOR:i}=this.ctx.config;t.drawWrapper(this.ctx,{borderColor:i,fillColor:e})}this.ctx.paint.drawImage(t.source,t.x,t.y,t.width,t.height)}})}drawSelector(){if("footer"===this.cellType)return;let{ENABLE_SELECTOR:t}=this.ctx.config;if(!t)return;let{xArr:e,yArr:i,xArrCopy:s,yArrCopy:r}=this.ctx.selector;this.drawBorder({xArr:s,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:e,yArr:i,borderColor:this.ctx.config.SELECT_BORDER_COLOR||"rgb(82,146,247)",fillColor:"transparent",borderWidth:1});let[l,o]=e,[h,n]=i;(l!==o||h!==n)&&this.colIndex>=l&&this.colIndex<=o&&this.rowIndex>=h&&this.rowIndex<=n&&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<=n&&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("footer"===this.cellType||!this.message||0===this.rowspan||0===this.colspan)return;let{ERROR_TIP_ICON_SIZE:t,ERROR_TIP_COLOR:e}=this.ctx.config,{width:i}=this,s=this.drawX,r=this.drawY;this.ctx.paint.drawLine([s+i-t-.5,r,s+i-.5,r,s+i-.5,r+t],{borderColor:e,fillColor:e,borderWidth:1,lineCap:"round",lineJoin:"round"})}drawBorder(t){let{drawX:e,drawY:i,rowIndex:s,colIndex:r,height:l,width:o}=this,{xArr:h,yArr:n,lineDash:a=[],borderWidth:c=1,borderColor:d,fillColor:x}=t,u=h[0],g=h[1],f=n[0],m=n[1];r>=u&&r<=g&&s===f&&this.ctx.paint.drawLine([e+ +(r===u),i+1,e+o-(r===g),i+1],{borderColor:d,fillColor:x,borderWidth:c,lineCap:"round",lineJoin:"round",lineDash:a}),r===g&&s>=f&&s<=m&&this.ctx.paint.drawLine([e+o-1,i+ +(s===f),e+o-1,i+l-(s===m)],{borderColor:d,fillColor:x,borderWidth:c,lineCap:"round",lineJoin:"round",lineDash:a}),r>=u&&r<=g&&s===m&&this.ctx.paint.drawLine([e+ +(r===u),i+l-1,e+o-(r===g),i+l-1],{borderColor:d,fillColor:x,borderWidth:c,lineCap:"round",lineJoin:"round",lineDash:a}),r===u&&s>=f&&s<=m&&this.ctx.paint.drawLine([e+1,i+ +(s===f),e+1,i+l-(s===m)],{borderColor:d,fillColor:x,borderWidth:c,lineCap:"round",lineJoin:"round",lineDash:a})}}class C{constructor(t,e){l(this,"ctx"),l(this,"data"),l(this,"columns"),l(this,"footerData",[]),l(this,"rowKeyMap",new Map),l(this,"colIndexKeyMap",new Map),l(this,"headerMap",new Map),l(this,"rowIndexRowKeyMap",new Map),l(this,"rowKeyRowIndexMap",new Map),l(this,"checkboxKeyMap",new Map),l(this,"selectionMap",new Map),l(this,"expandMap",new Map),l(this,"originalDataMap",new Map),l(this,"changedDataMap",new Map),l(this,"validationErrorMap",new Map),l(this,"itemRowKeyMap",new WeakMap),l(this,"bufferData",[]),l(this,"customHeader",{fixedData:{},sortData:{},hideData:{},resizableData:{}}),l(this,"overlayerAutoHeightMap",new Map),l(this,"maxRowHeightCellMap",new Map),l(this,"bufferCheckState",{buffer:!1,check:!1,indeterminate:!1,selectable:!0}),l(this,"sumHeight",0),l(this,"filterMethod"),l(this,"positions",[]),l(this,"sortState",new Map),this.ctx=t;let{data:i=[],columns:s=[],footerData:r=[]}=e;this.data=i,this.footerData=r,this.columns=s,this.init()}init(t=!0){this.ctx.paint.clearTextCache(),this.clearBufferData(),this.rowKeyMap.clear(),this.checkboxKeyMap.clear(),this.colIndexKeyMap.clear(),this.rowIndexRowKeyMap.clear(),this.rowKeyRowIndexMap.clear(),this.maxRowHeightCellMap.clear();let e=d(this.getColumns());if(this.ctx.hasSelection=e.some(t=>"selection"===t.type),this.ctx.hasTree=e.some(t=>{var e;return null==(e=t.type)?void 0:e.includes("tree")}),t){this.originalDataMap.clear(),this.changedDataMap.clear(),this.validationErrorMap.clear();let{ROW_KEY:t}=this.ctx.config;t?(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=[]){let s=t.length,{ROW_KEY:r="",DEFAULT_EXPAND_ALL:l,CELL_HEIGHT:o,SELECTABLE_METHOD:n,CHECKBOX_KEY:a,TREE_CHILDREN_KEY:c}=this.ctx.config;t.forEach((t,d)=>{var x;"children"!==c&&(t.children=t[c]);let u=t[r]??h();this.itemRowKeyMap.set(t,u);let g=t._height||o,f=t._readonly,m=!0;if("function"==typeof n&&(m=n),a){let e=t[a];if(this.checkboxKeyMap.has(e)){let t=this.checkboxKeyMap.get(e)||[];t.push(u),this.checkboxKeyMap.set(e,t)}else this.checkboxKeyMap.set(e,[u])}this.selectionMap.set(u,{key:a?t[a]:u,row:t,check:(null==(x=this.selectionMap.get(u))?void 0:x.check)||!1});let p=l||this.expandMap.get(u)||t._expand||!1;this.expandMap.set(u,p),this.rowKeyMap.set(u,{readonly:f,index:d,rowIndex:d,level:e,height:g,calculatedHeight:-1,check:!1,selectable:m,expand:p,expandLazy:!1,hasChildren:t._hasChildren||!!Array.isArray(t.children)&&t.children.length>
10,expandLoading:!1,item:t,parentRowKeys:i,parentRowKey:i[i.length-1]||"",isLastChild:d===s-1}),Array.isArray(t.children)&&t.children.length&&this.initData(t.children,e+1,[...i,u])})}setRowHeight(t,e){let i=this.rowIndexRowKeyMap.get(t);if(void 0===i)return;let s=this.rowKeyMap.get(i);s.height=e,s.item._height=e,this.clearBufferData()}setBatchRowHeight(t){t.forEach(({rowIndex:t,height:e})=>{let i=this.rowIndexRowKeyMap.get(t);if(i){let t=this.rowKeyMap.get(i);t.height=e,t.item._height=e}}),this.clearBufferData()}setBatchCalculatedRowHeight(t){return!t.every(({height:t,rowIndex:e})=>this.getPositionForRowIndex(e).calculatedHeight===t)&&(t.forEach(({rowIndex:t,height:e})=>{let i=this.rowIndexRowKeyMap.get(t);if(i){let t=this.rowKeyMap.get(i),{height:s=-1}=this.getMaxRowHeightItem(i)||{};t.calculatedHeight=Math.max(e,s)}}),this.clearBufferData(),this.getData(),!0)}getAllRowsData(){let t=[],e=i=>{i.forEach(i=>{t.push(i),Array.isArray(i.children)&&e(i.children)})};return e(this.data),t}generateColumns(t){let e=t=>t.map(t=>{var i,s,r,l,o,h,n,a;let c=t.children&&Array.isArray(t.children)?e(t.children):void 0,d={hide:null==(s=null==(i=this.customHeader)?void 0:i.hideData)?void 0:s[t.key],fixed:null==(l=null==(r=this.customHeader)?void 0:r.fixedData)?void 0:l[t.key],sort:null==(h=null==(o=this.customHeader)?void 0:o.sortData)?void 0:h[t.key],width:null==(a=null==(n=this.customHeader)?void 0:n.resizableData)?void 0:a[t.key]},x={};for(let[t,e]of Object.entries(d))void 0!==e&&(x[t]=e);let u=c&&c.every(t=>t.hide);return{...t,children:c,hide:u||("function"==typeof t.hide?t.hide(t):t.hide),...x}});return e(t)}getColumns(){return this.generateColumns(this.columns)}setColumns(t){this.columns=t,this.clearBufferData()}setData(t){this.data=t,this.init()}getOriginalData(){return this.data}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=[];let i=s=>{null==s||s.forEach(s=>{t.push(s);let r=this.itemRowKeyMap.get(s),{expand:l,hasChildren:o,height:h,calculatedHeight:n}=this.rowKeyMap.get(r),a=this.sumHeight,c=Math.max(n,h);this.sumHeight+=c,this.rowIndexRowKeyMap.set(e,r),this.rowKeyRowIndexMap.set(r,e),this.positions.push({top:a,height:c,bottom:this.sumHeight,calculatedHeight:n}),e+=1,l&&o&&i(s.children)})};this.rowIndexRowKeyMap.clear(),this.rowKeyRowIndexMap.clear();let s=this.data;if("function"==typeof this.filterMethod&&(s=this.filterMethod(s)),this.sortState.size){let t=Array.from(this.sortState.entries()).sort((t,e)=>t[1].timestamp-e[1].timestamp);s=this.sortDataRecursive(s,t)}return i(s),this.bufferData=t,{data:t,sumHeight:this.sumHeight,positions:this.positions}}setFooterData(t){this.footerData=t}getFooterData(){return this.footerData}setFilterMethod(t){this.filterMethod=t}clearFilterMethod(){this.filterMethod=void 0}getSortState(t){return this.sortState.get(t)||{direction:"none",timestamp:0}}setSortState(t,e){let i=Date.now();this.ctx.config.SORT_STRICTLY&&this.sortState.clear(),"none"===e?this.sortState.delete(t):this.sortState.set(t,{direction:e,timestamp:i}),this.ctx.emit("sortChange",this.sortState),this.clearBufferData(),this.ctx.emit("draw")}clearSort(){this.sortState.clear(),this.ctx.emit("sortChange",this.sortState),this.clearBufferData(),this.ctx.emit("draw")}sortDataRecursive(t,e){let i=[...t];for(let[t,{direction:s}]of e){if("none"===s)continue;let e=this.getColumnByKey(t);e&&e.column.sortBy&&(i=this.applySingleColumnSort(i,t,s,e.column.sortBy))}return i.map(t=>(t.children&&Array.isArray(t.children)&&(t.children=this.sortDataRecursive(t.children,e)),t))}applySingleColumnSort(t,e,i,s){return t.sort((t,r)=>{let l=t[e],o=r[e],h=0;if("function"==typeof s)h=s(t,r);else if("number"===s)h=(Number(l)||0)-(Number(o)||0);else if("string"===s){let t=String(l||""),e=String(o||"");h=t.localeCompare(e)}else"date"===s&&(h=function(t,e){let i=E(t),s=E(e);return isNaN(i.getTime())&&isNaN(s.getTime())?0:isNaN(i.getTime())?-1:isNaN(s.getTime())?1:i.getTime()-s.getTime()}(l,o));return"asc"===i?h:-h})}expandItem(t,e=!1){this.rowKeyMap.get(t).expand=e,this.expandMap.set(t,e),this.clearBufferData(),this.ctx.emit("draw")}setExpandRowKeys(t,e=!0){this.expandMap.clear(),t.forEach(t=>{let i=this.rowKeyMap.get(t);this.expandMap.set(t,e),i.expand=e}),this.clearBufferData(),this.ctx.emit("draw")}getExpandRowKeys(){let t=[];
1return 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){this.rowKeyMap.get(t).expandLoading=e,this.clearBufferData(),this.ctx.emit("draw")}setExpandChildren(t,e){let 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){let 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;let i=this.rowIndexRowKeyMap.get(t),s=this.colIndexKeyMap.get(e);return void 0===i||void 0===s?null:{rowKey:i,key:s,value:this.getItemValue(i,s)}}getItemValue(t,e){let i=this.rowKeyMap.get(t);return i&&i.item?void 0===i.item[e]?null:i.item[e]:null}async batchSetItemValue(t,e=!1,i=!0,s="none"){let r=[],l=i,o=new Map,h=[],n=[];for(let e of t){let{rowKey:t,key:i}=e,s=e.value,r=this.getRowDataItemForRowKey(t),l=this.getItemValue(t,i),o=this.getVirtualBodyCellByKey(t,i),a={...e,oldValue:l,row:r};if((null==o?void 0:o.type)==="number")if(["",void 0,null].includes(s))s=null;else if(/^-?\d+(\.\d+)?$/.test(String(s))){let t=function(t){let e=String(t).match(/\.(\d+)/);return(null==e?void 0:e[1].length)??0}(s);if("number"==typeof o.precision&&o.precision>=0&&t>o.precision){let t=10**o.precision;s=Math.round(Number(s)*t)/t;let e=this.ctx.locale.getText("numberTruncated",{precision:o.precision});h.push({...a,column:null==o?void 0:o.column,code:"ERR_NUMBER_PRECISION",message:e})}else if("number"==typeof o.min&&Number(s)<o.min){let t=this.ctx.locale.getText("numberMin",{min:o.min});s=o.min,h.push({...a,column:null==o?void 0:o.column,code:"ERR_NUMBER_MIN",message:t})}else if("number"==typeof o.max&&Number(s)>o.max){let t=this.ctx.locale.getText("numberMax",{max:o.max});s=o.max,h.push({...a,column:null==o?void 0:o.column,code:"ERR_NUMBER_MAX",message:t})}else s=Number(s)}else s=l,h.push({...a,column:null==o?void 0:o.column,code:"ERR_INVALID_NUMBER",message:this.ctx.locale.getText("invalidNumber")});else if((null==o?void 0:o.editorType)==="text"&&"number"==typeof o.maxlength&&String(s).length>o.maxlength){s=String(s).slice(0,o.maxlength);let t=this.ctx.locale.getText("stringMaxlength",{maxlength:o.maxlength});h.push({...a,column:null==o?void 0:o.column,code:"ERR_STRING_MAXLENGTH",message:t})}s!==l&&n.push({...e,value:s,oldValue:l,row:r})}if(h.length){let t={code:"ERR_BATCH_SET_ITEM_VALUE",message:this.ctx.locale.getText("batchSetItemValueError"),data:h};this.ctx.emit("error",t)}if(!n.length)return;let{BEFORE_VALUE_CHANGE_METHOD:a}=this.ctx.config;"none"===s&&"function"==typeof a&&(n=await a(n),l=!1);let c=[];n.forEach(t=>{c.push(this.getValidator(t.rowKey,t.key));let{value:e,rowKey:i,key:s,row:h}=t,n=this.getItemValue(i,s);o.set(i,h),this.setItemValue(i,s,e,!1,!1,!1,l),r.push({rowKey:i,key:s,oldValue:n,newValue:e})});let d=Array.from(o.values());await Promise.all(c),0===this.validationErrorMap.size&&this.changedDataMap.size>0&&this.ctx.emit("validateChangedData",this.getChangedData());let x=n.map(t=>{let e=!!this.getValidationError(t.rowKey,t.key).length;return{...t,errorTip:e}});this.ctx.emit("change",x,d),e&&this.ctx.history.pushState({changeList:r,scrollX:this.ctx.scrollX,scrollY:this.ctx.scrollY,type:"multiple"}),this.ctx.emit("draw")}async setItemValue(t,e,i,s=!1,r=!1,l=!1,o=!0){if(!this.rowKeyMap.has(t))return{};let{item:h}=this.rowKeyMap.get(t),n=h[e];if(o&&this.ctx.database.getReadonly(t,e))return{oldValue:n,newValue:n};null!==h[e]&&"object"==typeof h[e]&&(n=JSON.parse(JSON.stringify(h[e])));let a=`${t}​_${e}`;this.originalDataMap.has(a)||this.originalDataMap.set(a,n);let c=this.originalDataMap.get(a),d=this.getRowDataItemForRowKey(t),x={rowKey:t,key:e,value:i,oldValue:n,row:d};if(l){if(i===n)return{oldValue:n,newValue:n};this.batchSetItemValue([x],s,!1),this.ctx.emit("editChange",{...x,originalValue:c})}else this.changedDataMap.set(a,i),h[e]=i;return this.ctx.hasEvent("iterationChange")&&this.ctx.emit("iterationChange",{...x,originalValue:c}),r&&this.ctx.emit("draw"),{oldValue:n,newValue:i}}getRowDataItemForRowKey(t){if(!this.rowKeyMap.has(t))return{};let{item:e}=this.rowKeyMap.get(t);return e}setRowSelectionByCheckboxKey(t,e){let{CHECKBOX_KEY:i}=this.ctx.config;if(i){if(!this.rowKeyMap.has(t))return!1;let{item:s}=this.rowKeyMap.get(t),r=s[i];this.checkboxKeyMap.has(r)&&(this.checkboxKeyMap.get(r)||[]).forEac
1h(t=>{let i=this.selectionMap.get(t);i&&(i.check=e)})}}toggleRowSelection(t,e){let i=this.rowKeyMap.get(t),s=this.selectionMap.get(t);if(!s)return;"selection-tree"===e||"tree-selection"===e?this.toggleTreeSelection(t):(s.check=!s.check,this.setRowSelectionByCheckboxKey(t,s.check)),this.ctx.emit("toggleRowSelection",i);let r=this.getSelectionRows();this.ctx.emit("selectionChange",r),this.bufferCheckState.buffer=!1,this.ctx.emit("draw")}toggleTreeSelection(t){let e=this.getTreeSelectionState(t),i=this.ctx.config.TREE_SELECT_MODE;if("auto"===i)e.checked&&!e.indeterminate?(this.clearTreeSelectionRecursive(t),this.setRowSelection(t,!1,!1)):(this.selectTreeSelectionRecursive(t),this.setRowSelection(t,!0,!1));else if("cautious"===i)e.checked&&!e.indeterminate?(this.clearTreeSelectionRecursive(t),this.setRowSelection(t,!1,!1)):(this.selectTreeSelectionRecursive(t),this.setRowSelection(t,!0,!1));else if("strictly"===i){let e=this.selectionMap.get(t);e&&(e.check=!e.check,this.setRowSelectionByCheckboxKey(t,e.check))}this.ctx.emit("selectionChange",this.getSelectionRows()),this.ctx.emit("draw")}selectTreeSelectionRecursive(t){this.getTreeChildren(t).forEach(t=>{this.setRowSelectionByParent(t,!0),this.selectTreeSelectionRecursive(t)})}clearTreeSelectionRecursive(t){this.getTreeChildren(t).forEach(t=>{this.setRowSelectionByParent(t,!1),this.clearTreeSelectionRecursive(t)})}updateParentTreeSelection(t){let e=this.getTreeParent(t);if(!e)return;let i=this.getTreeChildren(e).map(t=>this.selectionMap.get(t)),s=i.filter(t=>null==t?void 0:t.check).length,r=i.length,l=!1;r>0&&(0===s?l=!1:s===r||"auto"===this.ctx.config.TREE_SELECT_MODE?l=!0:"cautious"===this.ctx.config.TREE_SELECT_MODE&&(l=!1));let o=this.selectionMap.get(e);o&&o.check!==l&&(o.check=l,this.setRowSelectionByCheckboxKey(e,l),this.updateParentTreeSelection(e))}setRowSelection(t,e,i=!0){let s=this.selectionMap.get(t);s&&(s.check=e,this.setRowSelectionByCheckboxKey(t,s.check),this.ctx.emit("setRowSelection",e,s.row),("auto"===this.ctx.config.TREE_SELECT_MODE||"cautious"===this.ctx.config.TREE_SELECT_MODE)&&this.updateParentTreeSelection(t),i&&(this.bufferCheckState.buffer=!1,this.ctx.emit("draw")))}setRowSelectionByParent(t,e){let i=this.selectionMap.get(t);i&&(i.check=e,this.setRowSelectionByCheckboxKey(t,i.check))}getSelectionRows(){let t=[];return this.selectionMap.forEach(e=>{e.check&&t.push(e.row)}),t}getRowSelection(t){let e=this.selectionMap.get(t);return!!e&&e.check}getTreeSelectionState(t){if(!this.getRowForRowKey(t))return{checked:!1,indeterminate:!1};let e=this.selectionMap.get(t),i=(null==e?void 0:e.check)||!1;if(0===this.getTreeChildren(t).length)return{checked:i,indeterminate:!1};let s=!1,r=i;if("auto"===this.ctx.config.TREE_SELECT_MODE){let e=t=>{let i=this.getTreeChildren(t),s=[];for(let t of i)s.push(t),s.push(...e(t));return s},l=e(t).map(t=>this.selectionMap.get(t)),o=l.filter(t=>null==t?void 0:t.check).length,h=l.length,n=o>0;s=n&&o!==h,r=i||n,i&&h>0&&0===o&&(r=!1,s=!1)}else if("cautious"===this.ctx.config.TREE_SELECT_MODE){let e=t=>{let i=this.getTreeChildren(t),s=[];for(let t of i)s.push(t),s.push(...e(t));return s},l=e(t).map(t=>this.selectionMap.get(t)),o=l.filter(t=>null==t?void 0:t.check).length,h=l.length,n=o===h;s=o>0&&!n,r=i||n,i&&h>0&&0===o&&(r=!1,s=!1)}else"strictly"===this.ctx.config.TREE_SELECT_MODE&&(s=!1,r=i);return{checked:r,indeterminate:s}}getTreeChildren(t){let e=this.getRowForRowKey(t);if(!e||!e.item||!e.item.children)return[];let i=[],s=t=>{for(let e of t){let t=this.getRowKeyByItem(e);t&&i.push(t),e.children&&e.children.length>0&&s(e.children)}};return s(e.item.children),i}getTreeParent(t){let e=(t,i)=>{for(let s of t){let t=this.getRowKeyByItem(s);if(s.children)for(let r of s.children){if(this.getRowKeyByItem(r)===i)return t;let l=e(s.children,i);if(l)return l}}return null};return e(this.data,t)}getRowSelectable(t){let{selectable:e,item:i,rowIndex:s}=this.rowKeyMap.get(t);return"function"==typeof e?e({row:i,rowIndex:s}):e}toggleAllSelection(){"auto"===this.ctx.config.TREE_SELECT_MODE||"cautious"===this.ctx.config.TREE_SELECT_MODE?this.rowKeyMap.forEac
1h((t,e)=>{let i=t.selectable;if("function"==typeof i&&(i=i({row:t.item,rowIndex:t.rowIndex})),i){let t=this.selectionMap.get(e);t&&(t.check=!0,this.setRowSelectionByCheckboxKey(e,!0))}}):this.rowKeyMap.forEach((t,e)=>{let i=t.selectable;"function"==typeof i&&(i=i({row:t.item,rowIndex:t.rowIndex})),i&&this.setRowSelection(e,!0,!1)});let t=this.getSelectionRows();this.ctx.emit("toggleAllSelection",t),this.ctx.emit("selectionChange",t),this.bufferCheckState.buffer=!1,this.ctx.emit("draw")}clearSelection(t=!1){let e="auto"===this.ctx.config.TREE_SELECT_MODE||"cautious"===this.ctx.config.TREE_SELECT_MODE;t?e?this.rowKeyMap.forEach((t,e)=>{let i=this.selectionMap.get(e);i&&(i.check=!1,this.setRowSelectionByCheckboxKey(e,!1))}):this.rowKeyMap.forEach((t,e)=>{this.setRowSelection(e,!1,!1)}):(this.selectionMap.clear(),this.rowKeyMap.forEach((t,e)=>{this.selectionMap.set(e,{check:!1,row:t.item,key:e})}));let i=this.getSelectionRows();this.ctx.emit("clearSelection"),this.ctx.emit("selectionChange",i),this.bufferCheckState.buffer=!1,this.ctx.emit("draw")}getCheckedState(){let{buffer:t,...e}=this.bufferCheckState;if(t)return e;let i=this.rowKeyMap.size,s=0,r=0,l=this.selectionMap.size,o=Array.from(this.selectionMap.values()).some(t=>t.check);this.rowKeyMap.forEach((t,e)=>{var i;null!=(i=this.selectionMap.get(e))&&i.check&&(s+=1);let l=t.selectable;"function"==typeof l&&(l=l({row:t.item,rowIndex:t.rowIndex})),l&&(r+=1)});let h=l>i&&0===s&&o,n=r&&r>s&&s>0||h,a=0!==r,c=!!r&&r===s;return this.bufferCheckState={buffer:!0,check:c,indeterminate:n,selectable:a},{check:c,indeterminate:n,selectable:a}}updateColIndexKeyMap(t=[]){this.colIndexKeyMap.clear(),t.forEach(t=>{this.colIndexKeyMap.set(t.colIndex,t.key)})}getColumnByColIndex(t){var e;let i=this.colIndexKeyMap.get(t);if(i&&this.headerMap.has(i))return null==(e=this.headerMap.get(i))?void 0:e.column}getColumnByKey(t){let e=this.headerMap.get(t);if(e)return e}getColIndexForKey(t){var e;if(t&&this.headerMap.has(t))return null==(e=this.headerMap.get(t))?void 0:e.colIndex}getColHeaderByIndex(t){let 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)=>{let s=this.originalDataMap.get(i),r=i.split("​_")[0],l=i.split("​_")[1];s!==e&&t.push({rowKey:r,colKey:l,originalValue:s,row:this.ctx.database.getRowDataItemForRowKey(r),value:e})}),t}getChangedRows(){let t=new Set;this.changedDataMap.forEach((e,i)=>{let s=this.originalDataMap.get(i),r=i.split("​_")[0];s!==e&&t.add(r)});let e=[];return t.forEach(t=>{e.push(this.ctx.database.getRowDataItemForRowKey(t))}),e}isHasChangedData(t,e){let i=`${t}​_${e}`;return!!this.changedDataMap.has(i)&&this.originalDataMap.get(i)!==this.changedDataMap.get(i)}getPositionForRowIndex(t){return t<this.positions.length?this.positions[t]:{height:0,top:0,bottom:0,calculatedHeight:0}}setHeader(t,e){return!!t&&(this.headerMap.set(t,e),!0)}getReadonly(t,e){let{DISABLED:i}=this.ctx.config;if(i)return!0;let s=this.rowKeyMap.get(t),r=this.headerMap.get(e);if(!s||!r)return!0;let l=s.readonly,o=r.readonly,{BODY_CELL_READONLY_METHOD:h}=this.ctx.config;if("function"==typeof h&&r){let i=h({row:s.item,rowIndex:s.rowIndex,colIndex:r.colIndex,column:r.column,value:this.getItemValue(t,e)});if(void 0!==i)return i}return o||l}clearValidate(){this.validationErrorMap.clear()}hasValidationError(){return 0!==this.validationErrorMap.size}getValidator(t,e){return new Promise(this.ctx.database.getReadonly(t,e)?t=>{t([])}:i=>{let s=this.rowKeyMap.get(t),r=this.headerMap.get(e),{BODY_CELL_RULES_METHOD:l}=this.ctx.config;if(void 0===s||void 0===r)return i([]);let h=r.column,n=h.rules;if("function"==typeof l){let i=l({row:s.item,rowIndex:s.rowIndex,colIndex:r.colIndex,column:h,value:this.getItemValue(t,e)});i&&(n=i)}if(n){let l={row:s.item,rowIndex:s.rowIndex,colIndex:r.colIndex,column:h,key:e,rowKey:t,value:this.getItemValue(t,e),field:e,fieldValue:this.getItemValue(t,e)},a=new o(n).validate(l);this.setValidationError(t,e,a),i(a)}else this.clearValidationError(t,e),i([])})}getHeightByRowIndexRowSpan(t,e){let i=0;for(let s=0;s<e;s++){let e=this.positions[t+s];e&&(i+=e.height)}return i}getSpanInfo(t){let{rowIndex:e,key:i,rowKey:s,row:r,value:l,colIndex:o,relationRowKeys:h,relationColKeys:n,rowspan:a,height:c,width:d,colspan:x,mergeRow:u,mergeCol:g}=t;if(1===a&&1===x)return{xArr:[o,o],yArr:[e,e],rowspan:a,colspan:x,height:c,width:d,offsetTop:0,offsetLeft:0,dataList:[{rowKey:s,key:i,row:r,value:l}]};let f=e,m=e,p=o,w=o,E=[],y=0,b=0,v=0,C=0;if(1!==a&&u){C=d;let t=h.reduce((t,e)=>
1{let i=this.getItemValue(s,e)??"";return`${t}${i}`},"");for(let i=e-1;i>=0;i--){let e=this.rowIndexRowKeyMap.get(i)||"";if(t===h.reduce((t,i)=>{let s=this.getItemValue(e,i)??"";return`${t}${s}`},""))f=i;else break}for(let i=e;i<=this.ctx.maxRowIndex;i++){let e=this.rowIndexRowKeyMap.get(i)||"";if(t===h.reduce((t,i)=>{let s=this.getItemValue(e,i)??"";return`${t}${s}`},""))m=i;else break}for(let t=f;t<e;t++){let{height:e}=this.positions[t];y+=e}for(let t=f;t<=m;t++){let{height:e}=this.positions[t];v+=e;let s=this.rowIndexRowKeyMap.get(t)||"",{item:r}=this.rowKeyMap.get(s),l=this.getItemValue(s,i);E.push({rowKey:s,key:i,value:l,row:r})}}if(1!==x&&g){v=c;for(let t=o-1;t>=0;t--){let e=this.getColumnByColIndex(t);if(!e)break;if(this.getItemValue(s,i)===this.getItemValue(s,e.key)&&n.includes(e.key))p=t;else break}for(let t=o;t<=this.ctx.maxColIndex;t++){let e=this.getColumnByColIndex(t);if(!e)break;if(this.getItemValue(s,i)===this.getItemValue(s,e.key)&&n.includes(e.key))w=t;else break}for(let t=p;t<o;t++){let e=this.getColumnByColIndex(t);if(!e)break;b+=e.width||100}for(let t=p;t<=w;t++){let e=this.getColumnByColIndex(t);if(!e)break;C+=e.width||100,E.push({rowKey:s,key:e.key,value:this.getItemValue(s,e.key),row:r})}}return{xArr:[p,w],yArr:[f,m],rowspan:a,colspan:x,height:v,width:C,offsetTop:y,offsetLeft:b,dataList:E}}setValidationErrorByRowKey(t,e,i){let s=`${t}​_${e}`,r=this.getRowForRowKey(t),l=null==r?void 0:r.rowIndex,o=this.getColumnByKey(e);if(!t||!o||!r)return;let h=this.getItemValue(t,e),n=[{key:e,rowKey:t,rowIndex:l,colIndex:o.colIndex,column:o.column,row:r,value:h,message:i,field:e,fieldValue:h}];this.validationErrorMap.set(s,n)}setValidationError(t,e,i){let s=`${t}​_${e}`;this.validationErrorMap.set(s,i)}clearValidationError(t,e){let i=`${t}​_${e}`;this.validationErrorMap.has(i)&&this.validationErrorMap.delete(i)}getValidationError(t,e){let i=`${t}​_${e}`;return this.validationErrorMap.get(i)||[]}getVirtualBodyCell(t,e,i=!0){let s=this.getColumnByColIndex(e),r=this.getRowForRowIndex(t);return s&&r?new v(this.ctx,t,e,0,0,0,0,s,r.item,"body",i):void 0}getVirtualBodyCellByKey(t,e){let i=this.getRowIndexForRowKey(t),s=this.getColIndexForKey(e);if(void 0!==i&&void 0!==s)return this.getVirtualBodyCell(i,s)}hasMergeCell(t,e){let i=!1;for(let s=e[0];s<=e[1];s++)for(let e=t[0];e<=t[1];e++){let t=this.getVirtualBodyCell(s,e);if(t&&(1!==t.rowspan||1!==t.colspan)){i=!0;break}}return i}calculateMaxTreeDepth(t,e=0){let i=e;return t.forEach(t=>{if(Array.isArray(t.children)&&t.children.length>0){let s=this.calculateMaxTreeDepth(t.children,e+1);i=Math.max(i,s)}}),i}setOverlayerAutoHeightMap(t){this.overlayerAutoHeightMap=t}getOverlayerAutoHeightMap(){return this.overlayerAutoHeightMap}getOverlayerAutoHeight(t,e){let i=`${t}​_${e}`;return this.overlayerAutoHeightMap.get(i)||0}setCustomHeader(t,e=!1){if(["fixedData","sortData","hideData","resizableData"].forEach(e=>{let i=t[e];void 0!==i&&(this.customHeader[e]=i)}),!e){let t=this.clearCustomHeaderInvalidValues(this.columns);this.ctx.emit("customHeaderChange",t)}}resetCustomHeader(){this.customHeader={},this.ctx.emit("resetHeader"),this.ctx.emit("customHeaderChange",this.customHeader)}getCustomHeader(){return this.customHeader}setCustomHeaderResizableData(t,e){let{resizableData:i={}}=this.customHeader;i[t]=e,this.setCustomHeader({resizableData:i})}setCustomHeaderHideData(t,e){let{hideData:i={}}=this.customHeader;t.forEach(t=>{i[t]=e}),this.setCustomHeader({hideData:i}),this.ctx.emit("resetHeader")}setCustomHeaderFixedData(t,e){let{fixedData:i={}}=this.customHeader;t.forEach(t=>{i[t]=e}),this.setCustomHeader({fixedData:i}),this.ctx.emit("resetHeader")}clearCustomHeaderInvalidValues(t){let e=(t,i={})=>{t.forEach(t=>{t.children&&t.children.length>0&&e(t.children,i);let s=(e,s)=>{var r,l;let o=null==(r=this.customHeader[e])?void 0:r[t.key];void 0!==o&&o!==s&&(i[e]||(i[e]={}),i[e][t.key]=o,"fixedData"!==e||o||s||null==(l=i[e])||delete l[t.key])};s("fixedData",t.fixed),s("sortData",t.sort),s("hideData",t.hide),s("resizableData",t.width)})},i={};return e(t,i),i}setMaxRowHeightItem(t,e,i){this.maxRowHeightCellMap.set(t,{key:e,height:i})}getMaxRowHeightItem(t){return this.maxRowHeightCellMap.get(t)}clearChangeData(){this.changedDataMap.clear()}}class R{constructor(t){l(this,"ctx"),l(this,"history",[]),l(this,"historyIndex",-1),this.ctx=t,this.init()}init(){this.ctx.on("keydown",t=>{if(!this.ctx.editing){if(t.ctrlKey&&!t.shiftKey&&"KeyZ"===t.code||t.metaKey&&!t.shiftKey&&"KeyZ"===t.code){t.preventDefault(),this.ctx.clearSelector(),this.ctx.clearAutofill(),this.backState();return}if(t.ctrlKey&&"KeyY"===t.code||t.ctrlKey&&t.shiftKey&&"KeyZ"===t.code||t.metaKey&&t.shiftKey&&"KeyZ"===t.code){t.preventDefault(),this.ctx.clearSelector(),this.ctx.clearAutofill(),this.forwardState();return}}})}pushState(t){let{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){let{changeList:t,scrollX:e,scrollY:i}=this.history[this.historyIndex],s=t.map(t=>({rowKey:t.rowKey,key:t.key,value:t.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;let{changeList:t}=this.history[this.historyIndex],e=t.map(t=>({rowKey:t.rowKey,key:t.key,value:t.newValue,row:{}}));this.ctx.database.batchSetItemValue(e,!1,!1,"forward")}}clear(){this.history=[],this.historyIndex=-1}}class I{constructor(t){l(this,"eventTasks",new Set),l(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)),this.bind(document,"selectionchange",this.selectionchange.bind(this))}selectionchange(){this.ctx.domSelectionStr="";let t=window.getSelection();t&&t.toString()&&(this.ctx.domSelectionStr=t.toString())}clearDomSelection(){let t=window.getSelection();t&&!t.isCollapsed&&t.removeAllRanges()}
1destroy(){Array.from(this.eventTasks).forEach(({target:t,name:e,fn:i,options:s})=>{this.unbind(t,e,i,s)}),this.eventTasks.clear()}handleResize(t){this.ctx.emit("resetHeader",t),this.ctx.emit("resize",t)}handleMouseDown(t){this.clearDomSelection(),0===t.button&&(this.ctx.mousedown=!0),this.ctx.emit("mousedown",t)}handleMousemove(t){let e=this.ctx.containerElement.getBoundingClientRect(),i=t.clientX-e.left,s=t.clientY-e.top;this.ctx.mouseX=i,this.ctx.mouseY=s,this.ctx.emit("mousemove",t)}handleMouseUp(t){0===t.button&&(this.ctx.mousedown=!1),this.ctx.emit("mouseup",t)}handleClick(t){this.ctx.emit("click",t)}handleKeydown(t){let{ENABLE_KEYBOARD:e}=this.ctx.config;e&&this.ctx.isTarget(t)&&(this.ctx.dragHeaderIng||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.add({target:t,name:e,fn:i,options:s})}unbind(t,e,i,s){for(let r of(t.removeEventListener(e,i,s),this.eventTasks))if(r.target===t&&r.name===e&&r.fn===i){this.eventTasks.delete(r);break}}}class _{constructor(){l(this,"events",new Map)}has(t){return this.events.has(t)}on(t,e){let i=this.events.get(t)||[];i.push(e),this.events.set(t,i)}once(t,e){let i=(...s)=>{e(...s),this.off(t,i)};return this.on(t,i),this}off(t,e){let i=this.events.get(t);if(i){let s=i.indexOf(e);s>=0&&(i.splice(s,1),0===i.length?this.events.delete(t):this.events.set(t,i))}}emit(t,...e){let i=this.events.get(t);i&&i.forEach(t=>{t(...e)})}destroy(){this.events.clear()}}class T{constructor(t){l(this,"ctx"),l(this,"textCacheMap",new Map);let e=t.getContext("2d");if(!e)throw Error("canvas context not found");this.ctx=e}getCtx(){return this.ctx}clearTextCache(){this.textCacheMap.clear()}scale(t){this.ctx.setTransform(1,0,0,1,0,0),this.ctx.scale(t,t)}save(){this.ctx.save()}restore(){this.ctx.restore()}translate(t,e){this.ctx.translate(t,e)}setCursor(t="default"){this.ctx.canvas.style.cursor=t}clear(t=0,e=0,i,s){this.ctx.clearRect(t,e,i||this.ctx.canvas.width,s||this.ctx.canvas.height)}drawShadow(t,e,i,s,r){let l,{fillColor:o,side:h,shadowWidth:n,colorStart:a,colorEnd:c}=r;switch(this.ctx.save(),o&&(this.ctx.fillStyle=o,this.ctx.fillRect(t,e,i,s)),h){case"left":(l=this.ctx.createLinearGradient(t-n,e,t,e)).addColorStop(0,a),l.addColorStop(1,c),this.ctx.fillStyle=l,this.ctx.fillRect(t-n,e,n,s);break;case"right":(l=this.ctx.createLinearGradient(t+i,e,t+i+n,e)).addColorStop(0,a),l.addColorStop(1,c),this.ctx.fillStyle=l,this.ctx.fillRect(t+i,e,n,s);break;case"top":(l=this.ctx.createLinearGradient(t,e-n,t,e)).addColorStop(0,a),l.addColorStop(1,c),this.ctx.fillStyle=l,this.ctx.fillRect(t,e-n,i,n);break;case"bottom":(l=this.ctx.createLinearGradient(t,e+s,t,e+s+n)).addColorStop(0,a),l.addColorStop(1,c),this.ctx.fillStyle=l,this.ctx.fillRect(t,e+s,i,n);break;default:console.error("Invalid side specified for shadow")}this.ctx.restore()}drawLine(t,e){if(t.length<4||t.length%2!=0)throw Error("A valid array of points is required to draw a line");this.ctx.save();let{borderColor:i="black",borderWidth:s=1}=e;this.ctx.beginPath(),this.ctx.moveTo(t[0]-.5,t[1]-.5);for(let e=2;e<t.length;e+=2)this.ctx.lineTo(t[e]-.5,t[e+1]-.5);this.ctx.strokeStyle=i,this.ctx.lineWidth=s,e.lineDash&&(this.ctx.lineDashOffset=e.lineDashOffset??0,this.ctx.setLineDash(e.lineDash)),e.fillColor&&(this.ctx.fillStyle=e.fillColor,this.ctx.fill()),e.borderColor&&(this.ctx.strokeStyle=e.borderColor),this.ctx.stroke(),this.ctx.closePath(),this.ctx.restore()}drawImage(t,e,i,s,r){this.ctx.save(),this.ctx.drawImage(t,e,i,s,r),this.ctx.restore(
1)}drawRect(t,e,i,s,{borderWidth:r=1,borderColor:l,fillColor:o,radius:h=0}={}){if(this.ctx.save(),this.ctx.beginPath(),void 0!==o&&(this.ctx.fillStyle=o),void 0!==l&&(this.ctx.lineWidth=r,this.ctx.strokeStyle=l),0===h)this.ctx.rect(t-.5,e-.5,i,s);else{let[r,l,o,n]="number"==typeof h?[h,h,h,h]:h;this.ctx.moveTo(t+r,e),this.ctx.arcTo(t+i,e,t+i,e+l,l),this.ctx.arcTo(t+i,e+s,t+i-o,e+s,o),this.ctx.arcTo(t,e+s,t,e+s-n,n),this.ctx.arcTo(t,e,t+r,e,r)}void 0!==o&&this.ctx.fill(),void 0!==l&&this.ctx.stroke(),this.ctx.restore()}drawText(t="",e,i,s,r,l={}){var o,h,n;this.ctx.save();let{font:a="12px Arial",align:c="center",color:d="#495060",padding:x=0,verticalAlign:u="middle",maxLineClamp:g=1,autoRowHeight:f=!1,offsetLeft:m=0,offsetRight:p=0}=l;if(this.ctx.font=a,this.ctx.fillStyle=d,["",null,void 0].includes(t))return this.ctx.restore(),!1;let w=parseInt((null==(o=a.match(/\d+/))?void 0:o[0])||"12")*(l.lineHeight||1.2),E=this.buildTextLayout(t,e,i,s,r,{font:a,color:d,align:c,padding:x,verticalAlign:u,maxLineClamp:g,autoRowHeight:f,lineHeight:w,offsetLeft:m,offsetRight:p});if(this.ctx.textBaseline="top",this.ctx.textAlign="left",E.lines.forEach(t=>{this.ctx.fillText(t.text,t.drawX,t.drawY)}),l.textCallback&&E.lines.length){let t=Math.round(E.lines.reduce((t,e)=>Math.max(t,e.width),0)),i=(null==(h=E.lines[0])?void 0:h.drawX)??e+x+m,r=i+t;"center"===c?(i=e+s/2-t/2,r=e+s/2+t/2):"right"===c&&(i=e+s-x-p-t,r=e+s-x-p);let o={x:(null==(n=E.lines[0])?void 0:n.drawX)??i,y:E.contentY,width:t,height:E.lines.length*w,left:i,right:r,top:E.contentY,bottom:E.contentY+E.lines.length*w};l.textCallback(o)}return l.layoutCallback&&l.layoutCallback(E),this.ctx.restore(),E.ellipsis}buildTextLayout(t,e,i,s,r,l){let{font:o,color:h,align:n,padding:a,verticalAlign:c,maxLineClamp:d,autoRowHeight:x,lineHeight:u,offsetLeft:g,offsetRight:f}=l;this.ctx.save(),this.ctx.font=o;let m=s-2*a-g-f,p=r-2*a,w=Array.from(t),E=this.wrapTextToLines(t,m),y=Math.round(p/u),b=Math.min(E.length,Math.max(y,1));"auto"===d&&x?b=E.length:"number"==typeof d&&d<b&&1!==d?b=d:(1===d&&(E=[{items:w.map((t,e)=>({char:t,sourceIndex:e})),text:t,caretIndex:0,lineIndex:0,drawX:0,drawY:0,width:0,segments:[]}],b=1),"auto"===d&&1===y&&(E=[{items:w.map((t,e)=>({char:t,sourceIndex:e})),text:t,caretIndex:0,lineIndex:0,drawX:0,drawY:0,width:0,segments:[]}],b=1));let v=!1,C=E.slice(0,b);if(E.length>b){v=!0;let t=E.slice(b-1),e=this.buildEllipsisLine(t,s,a);e.lineIndex=b-1,C[b-1]=e}else if(b>0){let t=b-1,e=E.slice(t),i=e.map(t=>t.text).join(""),{ellipsis:r}=this.handleEllipsis(i,s,a,o);if(r){v=!0;let i=this.buildEllipsisLine(e,s,a);i.lineIndex=t,C[t]=i}}let R=C.length*u,I=i+a;"middle"===c?I=i+(r-R)/2:"bottom"===c&&(I=i+r-R-a);let _=[];
1return C.forEach((t,i)=>{t.lineIndex=i;let r=this.buildLineSegments(t),l=r.reduce((t,e)=>t+e.width,0),o=e+a+g;"center"===n?o=e+(s-l)/2:"right"===n&&(o=e+s-a-f-l);let h=I+i*u;t.drawX=o,t.drawY=h,t.width=l,t.segments=r,r.forEach(t=>{t.sourceIndex<0||_.push({char:t.char,index:t.sourceIndex,line:i,x:o+t.x,y:h,width:t.width,height:u})})}),this.ctx.restore(),{text:t,chars:w,glyphs:_,lines:C,box:{x:e,y:i,width:s,height:r},contentBox:{x:e+a+g,y:i+a,width:m,height:p},contentY:I,lineHeight:u,font:o,color:h,align:n,ellipsis:v}}wrapTextToLines(t,e){if(!t)return[{items:[],text:"",caretIndex:0,lineIndex:0,drawX:0,drawY:0,width:0,segments:[]}];let i=Array.from(t),s=[],r=[],l=0,o=0,h=t=>{let e=r.map(t=>t.char).join("");s.push({items:r,text:e,caretIndex:o,lineIndex:s.length,drawX:0,drawY:0,width:0,segments:[]}),r=[],l=0,o=t};for(let t=0;t<i.length;t++){let s=i[t];if(s===`
2`){h(t+1);continue}let o=this.ctx.measureText(s).width;if(l+o>e&&r.length>0){h(r[r.length-1].sourceIndex+1),r.push({char:s,sourceIndex:t}),l=o;continue}r.push({char:s,sourceIndex:t}),l+=o}return(r.length>0||0===s.length)&&h(i.length),s}buildEllipsisLine(t,e,i){var s;let r=t.flatMap(t=>t.items),l=r.map(t=>t.char).join(""),{_text:o,ellipsis:h}=this.handleEllipsis(l,e,i,this.ctx.font),n=h?o.slice(0,-3):o,a=[];for(let t=0;t<n.length;t++){let e=r[t];if(!e)break;a.push({char:e.char,sourceIndex:e.sourceIndex})}return h&&a.push({char:".",sourceIndex:-1,ellipsis:!0},{char:".",sourceIndex:-1,ellipsis:!0},{char:".",sourceIndex:-1,ellipsis:!0}),{items:a,text:o,caretIndex:(null==(s=t[0])?void 0:s.caretIndex)??0,lineIndex:0,drawX:0,drawY:0,width:0,segments:[]}}buildLineSegments(t){let e=[],i=0;return t.items.forEach((t,s)=>{let r=this.ctx.measureText(t.char).width;e.push({char:t.char,itemIndex:s,sourceIndex:t.sourceIndex,x:i,width:r}),i+=r}),e}wrapText(t,e,i=""){if(!t)return[""];if(i&&this.textCacheMap.has(i))return this.textCacheMap.get(i)||[""];let s=[];for(let i of t.split(`
3`)){if(""===i){s.push("");continue}let t=i.split(""),r="";for(let i of t){let t=r+i;this.ctx.measureText(t).width<=e?r=t:r?(s.push(r),r=i):(s.push(i),r="")}r&&s.push(r)}let r=s.length>0?s:[""];return i&&this.textCacheMap.set(i,r),r}calculateTextHeight(t="",e,i={}){var s;let{font:r="12px Arial",padding:l=0,align:o="center",color:h="#495060",maxLineClamp:n=1,cacheTextKey:a=""}=i;this.ctx.save(),this.ctx.font=r,this.ctx.fillStyle=h,this.ctx.textAlign=o;let c=parseInt((null==(s=r.match(/\d+/))?void 0:s[0])||"12"),d=c*(i.lineHeight||1.2),x=this.wrapText(t,e-2*l,a),u=1;return u="auto"===n?x.length:x.length>n?n:x.length,this.ctx.restore(),Math.max(Math.floor(u*d+2*l),Math.floor(c+2*l))}handleEllipsis(t,e,i=0,s="12px Arial"){this.ctx.save();let r=!1,l=t;if(this.ctx.font=s,null==t||""===t)return this.ctx.restore(),{_text:"",ellipsis:r};let o=this.ctx.measureText("...").width;if(e<=o+2*i)return this.ctx.restore(),{_text:"",ellipsis:!0};let h=this.ctx.measureText(t).width,n=e-2*i;if(h&&h>=n){r=!0;let e=0;for(let i=0;i<t.length;i++)if((e+=this.ctx.measureText(t[i]).width)>=n-o){l=t.slice(0,i)+"...",r=!0;break}}return this.ctx.restore(),{_text:l,ellipsis:r}}}class O{constructor(t){l(this,"_config",{}),l(this,"CSS_PREFIX","e-virt-table"),l(this,"ICONS",[]),l(this,"ROW_KEY",""),l(this,"DISABLED",!1),l(this,"HEADER_FONT","12px normal Arial"),l(this,"BODY_FONT","12px normal Arial"),l(this,"BORDER",!0),l(this,"STRIPE",!1),l(this,"STRIPE_COLOR","#fafafa"),l(this,"BORDER_COLOR","#e1e6eb"),l(this,"HEIGHT",0),l(this,"PLACEHOLDER_COLOR","#CDD0DC"),l(this,"EMPTY_BODY_HEIGHT",120),l(this,"EMPTY_CUSTOM_STYLE",{}),l(this,"EMPTY_TEXT",""),l(this,"LOADING_TEXT",""),l(this,"MAX_HEIGHT",1e3),l(this,"BORDER_RADIUS",8),l(this,"ENABLE_OFFSET_HEIGHT",!1),l(this,"OFFSET_HEIGHT",0),l(this,"HEADER_HEIGHT",36),l(this,"ENABLE_HEADER_STICKY",!1),l(this,"HEADER_BG_COLOR","#F8FAFF"),l(this,"BODY_BG_COLOR","#FFF"),l(this,"HEADER_TEXT_COLOR","#1D2129"),l(this,"REQUIRED_COLOR","#F56C6C"),l(this,"BODY_TEXT_COLOR","#4E5969"),l(this,"FOOTER_TEXT_COLOR","#4E5969"),l(this,"LOADING_ICON_SVG",""),l(this,"LOADING_ICON_COLOR","#4E5969"),l(this,"EXPAND_ICON_SVG",""),l(this,"SHRINK_ICON_SVG",""),l(this,"EXPAND_ICON_COLOR","#4E5969"),l(this,"SHRINK_ICON_COLOR","#4E5969"),l(this,"ERROR_TIP_ICON_COLOR","red"),l(this,"ERROR_TIP_ICON_SIZE",6),l(this,"COLUMNS_ALIGN","left"),l(this,"COLUMNS_VERTICAL_ALIGN","middle"),l(this,"EXPAND_LAZY",!0),l(this,"DEFAULT_EXPAND_ALL",!1),l(this,"CELL_WIDTH",100),l(this,"CELL_HEIGHT",36),l(this,"CELL_PADDING",8),l(this,"CELL_HOVER_ICON_SIZE",14),l(this,"CELL_HOVER_ICON_BG_COLOR","#fff"),l(this,"CELL_HOVER_ICON_BORDER_COLOR","#DDE0EA"),l(this,"SCROLLER_TRACK_SIZE",14),l(this,"SCROLLER_SIZE",8),l(this,"SCROLLER_COLOR","#dee0e3"),l(this,"SCROLLER_TRACK_COLOR","#fff"),l(this,"SCROLLER_FOCUS_COLOR","#bbbec4"),l(this,"SELECT_BORDER_COLOR","rgb(82,146,247)"),l(this,"SELECT_AREA_COLOR","rgba(82,146,247,0.1)"),l(this,"SELECT_ROW_COL_BG_COLOR","transparent"),l(this,"AUTOFILL_POINT_BORDER_COLOR","#fff"),l(this,"EDIT_BG_COLOR","#fcf6ed"),l(this,"CHECKBOX_KEY",""),l(this,"CHECKBOX_COLOR","rgb(82,146,247)"),l(this,"FINDER_CELL_BG_COLOR","rgb(255,229,144)"),l(this,"ENABLE_FINDER",!0),l(this,"CHECKBOX_SIZE",20),l(this,"CHECKBOX_DISABLED_SVG",""),l(this,"CHECKBOX_DISABLED_COLOR","#F1F2F4"),l(this,"CHECKBOX_CHECK_SVG",""),l(this,"CHECKBOX_UNCHECK_SVG",""),l(this,"CHECKBOX_UNCHECK_COLOR","#DDE0EA"),l(this,"CHECKBOX_INDETERMINATE_SVG",""),l(this,"CHECKBOX_CHECK_DISABLED_SVG",""),l(this,"CHECKBOX_CHECK_DISABLED_COLOR","#DDE0EA"),l(this,"ICON_EDIT_SVG",""),l(this,"ICON_EDIT_COLOR","#4E5969"),l(this,"ICON_SELECT_SVG",""),l(this,"ICON_SELECT_COLOR","#4E5969"),l(this,"SORT_STRICTLY",!0),l(this,"SORT_ASC_ICON_SVG",""),l(this,"SORT_DESC_ICON_SVG",""),l(this,"SORTABLE_ICON_SVG",""),l(this,"SORT_ICON_COLOR","rgb(82,146,247)"),l(this,"READONLY_COLOR","#fff"),l(this,"READONLY_TEXT_COLOR","#4E5969"),l(this,"ERROR_TIP_COLOR","#ED3F14"),l(this,"FOOTER_BG_COLOR","#fafafa"),l(this,"FOOTER_FIXED",!0),l(this,"FOOTER_POSITION","bottom"),l(this,"CELL_FOOTER_HEIGHT",36),l(this,"ENABLE_SELECTOR",!0),l(this,"TREE_SELECT_MODE","auto"),l(this,"TREE_CHILDREN_KEY","children"),l(this,"TREE_INDENT",20),l(this,"TREE_ICON_SIZE",20),l(this,"TREE_
3LINE",!1),l(this,"TREE_LINE_COLOR","#e1e6eb"),l(this,"ENABLE_EDIT_SINGLE_CLICK",!1),l(this,"ENABLE_EDIT_CLICK_SELECTOR",!0),l(this,"SELECTOR_AREA_MIN_X",0),l(this,"SELECTOR_AREA_MAX_X_OFFSET",0),l(this,"SELECTOR_AREA_MAX_X",0),l(this,"SELECTOR_AREA_MIN_Y",0),l(this,"SELECTOR_AREA_MAX_Y",0),l(this,"SELECTOR_AREA_MAX_Y_OFFSET",0),l(this,"SELECTOR_CELL_VALUE_TYPE","value"),l(this,"ENABLE_AUTO_THEME",!0),l(this,"ENABLE_SELECTOR_SINGLE",!1),l(this,"ENABLE_SELECTOR_SPAN_COL",!0),l(this,"ENABLE_SELECTOR_SPAN_ROW",!0),l(this,"ENABLE_SELECTOR_ALL_ROWS",!0),l(this,"ENABLE_SELECTOR_ALL_COLS",!0),l(this,"ENABLE_MERGE_CELL_LINK",!1),l(this,"ENABLE_AUTOFILL",!1),l(this,"ENABLE_AUTOFILL_SPAN_COL",!0),l(this,"ENABLE_AUTOFILL_SPAN_ROW",!0),l(this,"ENABLE_CONTEXT_MENU",!1),l(this,"ENABLE_HEADER_CONTEXT_MENU",!1),l(this,"ENABLE_TEXT_SELECTION",!0),l(this,"ENABLE_COPY",!0),l(this,"ENABLE_PASTER",!0),l(this,"ENABLE_RESIZE_ROW",!0),l(this,"ENABLE_RESIZE_COLUMN",!0),l(this,"RESIZE_ROW_LINE_COLOR","#e1e6eb"),l(this,"RESIZE_COLUMN_LINE_COLOR","#e1e6eb"),l(this,"ENABLE_RESIZE_COLUMN_TEXT",!0),l(this,"RESIZE_COLUMN_TEXT_COLOR","#fff"),l(this,"RESIZE_COLUMN_TEXT_BG_COLOR","rgb(82,146,247)"),l(this,"RESIZE_ROW_MIN_HEIGHT",36),l(this,"RESIZE_COLUMN_MIN_WIDTH",40),l(this,"DRAG_TIP_BG_COLOR","rgba(82,146,247,0.1)"),l(this,"DRAG_TIP_LINE_COLOR","rgb(82,146,247)"),l(this,"ENABLE_KEYBOARD",!0),l(this,"ENABLE_HISTORY",!1),l(this,"ENABLE_VALIDATOR_IMMEDIATE",!0),l(this,"HISTORY_NUM",50),l(this,"HIGHLIGHT_HOVER_ROW",!1),l(this,"HIGHLIGHT_HOVER_ROW_COLOR","rgba(186,203,231,0.1)"),l(this,"HIGHLIGHT_SELECTED_ROW",!1),l(this,"HIGHLIGHT_SELECTED_ROW_COLOR","rgba(82,146,247,0.1)"),l(this,"TOOLTIP_BG_COLOR","#303133"),l(this,"TOOLTIP_TEXT_COLOR","#fff"),l(this,"TOOLTIP_ZINDEX",3e3),l(this,"TOOLTIP_CUSTOM_STYLE",{}),l(this,"CONTEXT_MENU",[{value:"copy"},{value:"cut"},{value:"paste"},{value:"clearSelected"}]),l(this,"CUSTOM_BODY_CONTEXT_MENU",[]),l(this,"HEADER_CONTEXT_MENU",[{value:"fixedLeft"},{value:"fixedRight"},{value:"fixedNone"},{value:"hide"},{value:"visible"},{value:"resetHeader"}]),l(this,"CUSTOM_HEADER_CONTEXT_MENU",[]),l(this,"CELL_LINE_HEIGHT",1.2),l(this,"AUTO_ROW_HEIGHT",!1),l(this,"ENABLE_DRAG_COLUMN",!1),l(this,"ENABLE_DRAG_ROW",!1),l(this,"ENABLE_DRAG_ROW_CROSS_LEVEL",!1),l(this,"ENABLE_DRAG_ROW_CUSTOM",!1),l(this,"DRAG_ROW_TIP_LINE_COLOR","rgb(82,146,247)"),l(this,"DRAG_ROW_ICON_SVG",""),l(this,"DRAG_ROW_ICON_SIZE",18),l(this,"DRAG_ROW_ICON_COLOR","#bec4c7"),l(this,"HEADER_CELL_STYLE_METHOD"),l(this,"BODY_CELL_STYLE_METHOD"),l(this,"FOOTER_CELL_STYLE_METHOD"),l(this,"BODY_CELL_READONLY_METHOD"),l(this,"BODY_CELL_FORMATTER_METHOD"),l(this,"BODY_CELL_RULES_METHOD"),l(this,"BODY_CELL_TYPE_METHOD"),l(this,"BODY_CELL_EDITOR_METHOD"),l(this,"BODY_CELL_RENDER_METHOD"),l(this,"BODY_CELL_HOVER_ICON_METHOD"),l(this,"SPAN_METHOD"),l(this,"SELECTABLE_METHOD"),l(this,"EXPAND_LAZY_METHOD"),l(this,"BEFORE_VALUE_CHANGE_METHOD"),l(this,"BEFORE_PASTE_DATA_METHOD"),l(this,"BEFORE_AUTOFILL_DATA_METHOD"),l(this,"BEFORE_SET_SELECTOR_METHOD"),l(this,"BEFORE_SET_AUTOFILL_METHOD"),l(this,"BEFORE_HEADER_CONTEXT_MENU_METHOD"),l(this,"BEFORE_BODY_CONTEXT_MENU_METHOD"),l(this,"BEFORE_COPY_METHOD"),l(this,"BEFORE_DRAG_ROW_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")){let i=function(t,e=document.documentElement){let i=t.startsWith("--")?t:`--${t}`;return getComputedStyle(e).getPropertyValue(i).trim()}(`--evt-${e.toLocaleLowerCase().replace(/_/g,"-")}`);i&&(t[e]=i)}}),Object.assign(this,t,this._config)}}let S=`<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-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>\r
4`,L=`<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>
5`,M=`<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.
5168 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>
6`,A=`<svg t="1755138507987" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5079" width="200" height="200"><path d="M512 938.688a42.688 42.688 0 0 1-35.072-18.432l-192-277.312A42.56 42.56 0 0 1 320 576h384a42.752 42.752 0 0 1 35.072 66.944l-192 277.312a42.688 42.688 0 0 1-35.072 18.432" fill="currentColor" p-id="2016"></path><path d="M704 448H320a42.752 42.752 0 0 1-35.072-66.944l192-277.312c16-23.04 54.208-23.04 70.144 0l192 277.312A42.56 42.56 0 0 1 704 448" fill="currentColor" p-id="2015"></path></svg>
7`,H=`<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>
8`,D=`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewB
8ox="0 0 24 24"><path d="M11 18c0 1.1-.9 2-2 2s-2-.9-2-2s.9-2 2-2s2 .9 2 2zm-2-8c-1.1 0-2 .9-2 2s.9 2 2 2s2-.9 2-2s-.9-2-2-2zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2s2-.9 2-2s-.9-2-2-2zm6 4c1.1 0 2-.9 2-2s-.9-2-2-2s-2 .9-2 2s.9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2s2-.9 2-2s-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2s2-.9 2-2s-.9-2-2-2z" fill="currentColor"></path></svg>
9`,N=`<svg t="1722595639920" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4708" width="32" height="32"><path d="M128 640V384a256 256 0 0 1 256-256h256a256 256 0 0 1 256 256v256a256 256 0 0 1-256 256H384a256 256 0 0 1-256-256z m64 0q0 79.552 56.256 135.744Q304.448 832 384 832h256q79.552 0 135.744-56.256Q832 719.552 832 640V384q0-79.552-56.256-135.744Q719.552 192 640 192H384q-79.552 0-135.744 56.256Q192 304.448 192 384v256z" p-id="4709"></path></svg>
10`,k=`<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>
11`,B=`<svg t="1722595946663" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4865" width="32" height="32"><path d="M128 640V384a256 256 0 0 1 256-256h256a256 256 0 0 1 256 256v256a256 256 0 0 1-256 256H384a256 256 0 0 1-256-256z" p-id="4866"></path><path d="M128 640V384a256 256 0 0 1 256-256h256a256 256 0 0 1 256 256v256a256 256 0 0 1-256 256H384a256 256 0 0 1-256-256z m64 0q0 79.552 56.256 135.744Q304.448 832 384 832h256q79.552 0 135.744-56.256Q832 719.552 832 640V384q0-79.552-56.256-135.744Q719.552 192 640 192H384q-79.552 0-135.744 56.256Q192 304.448 192 384v256z" fill="#DDE0EA" p-id="4867"></path></svg>
12`,K=`<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>
13`,X=A.replace('fill="currentColor" p-id="2016"','fill="#bec4c7" p-id="2016"'),F=A.replace('fill="currentColor" p-id="2015"','fill="#bec4c7" p-id="2015"');class Y{constructor(t){l(this,"ctx"),l(this,"list",[{name:"loading",configName:"LOADING_ICON_SVG",configColorName:"LOADING_ICON_COLOR",svg:H,color:"#4E5969"},{name:"expand",configName:"EXPAND_ICON_SVG",configColorName:"EXPAND_ICON_COLOR",svg:S,color:"#4E5969"},{name:"shrink",configName:"SHRINK_ICON_SVG",configColorName:"SHRINK_ICON_COLOR",svg:M,color:"#4E5969"},{name:"checkbox-uncheck",configName:"CHECKBOX_UNCHECK_SVG",configColorName:"CHECKBOX_UNCHECK_COLOR",svg:N,color:""},{name:"checkbox-check",configName:"CHECKBOX_CHECK_SVG",configColorName:"CHECKBOX_COLOR",svg:L,color:"rgb(82,146,247)"},{name:"checkbox-indeterminate",configName:"CHECKBOX_INDETERMINATE_SVG",configColorName:"CHECKBOX_COLOR",svg:k,color:"rgb(82,146,247)"},{name:"checkbox-check-disabled",configName:"CHECKBOX_CHECK_DISABLED_SVG",svg:L,color:"#DDE0EA"},{name:"checkbox-disabled",configName:"CHECKBOX_DISABLED_SVG",configColorName:"CHECKBOX_DISABLED_COLOR",svg:B,color:"#F1F2F4"},{name:"icon-edit",configName:"ICON_EDIT_SVG",configColorName:"ICON_EDIT_COLOR",svg:K,color:"#4E5969"},{name:"icon-select",configName:"ICON_SELECT_SVG",configColorName:"ICON_SELECT_COLOR",svg:M,color:"#4E5969"},{name:"sort-asc",configName:"SORT_ASC_ICON_SVG",configColorName:"SORT_ICON_COLOR",svg:X,color:"rgb(82,146,247)"},{name:"sort-desc",configName:"SORT_DESC_ICON_SVG",configColorName:"SORT_ICON_COLOR",svg:F,color:"rgb(82,146,247)"},{name:"sort-default",configName:"SORTABLE_ICON_SVG",svg:A,color:"#bec4c7"},{name:"drag",configName:"DRAG_ROW_ICON_SVG",svg:D,color:"#4E5969"}]),l(this,"icons",new Map),this.ctx=t,this.init()}
13async init(){let t=[];for(let e=0;e<this.list.length;e++){let i=this.list[e],s=i.color,r=i.svg;if(i.configColorName){let t=this.ctx.config[i.configColorName];t&&(s=t)}if(i.configName){let t=this.ctx.config[i.configName];t&&(r=t)}let l=this.createImageFromSVG(r,s).then(t=>{this.icons.set(i.name,t)});t.push(l)}for(let e=0;e<this.ctx.config.ICONS.length;e++){let i=this.ctx.config.ICONS[e],s=i.color,r=this.createImageFromSVG(i.svg,s,i.isBlob).then(t=>{this.icons.set(i.name,t)});t.push(r)}await Promise.all(t),this.ctx.emit("draw")}async createImageFromSVG(t,e,i=!1){let s=new DOMParser().parseFromString(t,"image/svg+xml").documentElement;e&&s.querySelectorAll("*").forEach(t=>{let i=t.getAttribute("fill");("currentColor"===i||null===i)&&t.setAttribute("fill",e)});let r=new Image,l="";if(i){let t=new Blob([new XMLSerializer().serializeToString(s)],{type:"image/svg+xml"});l=URL.createObjectURL(t)}else l="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(new XMLSerializer().serializeToString(s));return r.src=l,new Promise((e,i)=>{r.onerror=()=>i(Error("Failed to load image:"+t)),r.onload=()=>{e(r)}})}get(t){return this.icons.get(t)}getSvg(t){return this.list.find(e=>e.name===t)}}class W{constructor(t){l(this,"ctx"),l(this,"visibleHoverCell"),l(this,"resizeObserver"),l(this,"mutationObserver"),this.ctx=t,this.init()}init(){this.resizeObserver=new ResizeObserver(t=>{this.ctx.emit("resetHeader"),this.ctx.emit("resizeObserver",t),this.ctx.emit("containerResize",this.ctx.containerElement)}),this.resizeObserver.observe(this.ctx.containerElement),this.mutationObserver=new MutationObserver(t=>{for(let e of t)"attributes"===e.type&&"class"===e.attributeName&&(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(this.isBusy(t))return;let{offsetY:e,offsetX:i}=this.ctx.getOffset(t);this.isInsideBody(i,e)||this.ctx.emit("mousedownBodyOutside",t),0===t.button&&(this.handleHeaderEvent(i,e,this.ctx.header.renderCellHeaders,e=>{this.ctx.focusCellHeader=e,this.ctx.focusCell=void 0,this.ctx.emit("cellHeaderMousedown",e,t)}),this.handleBodyEvent(i,e,this.ctx.body.renderRows,e=>{this.ctx.setFocusCell(e),this.ctx.focusCellHeader=void 0,this.ctx.emit("cellMousedown",e,t)},!0))}),this.ctx.on("mouseup",t=>{if(0!==t.button||this.isBusy(t))return;let{offsetY:e,offsetX:i}=this.ctx.getOffset(t);this.handleHeaderEvent(i,e,this.ctx.header.renderCellHeaders,e=>{this.ctx.emit("cellHeaderMouseup",e,t)}),this.handleBodyEvent(i,e,this.ctx.body.renderRows,e=>{this.ctx.emit("cellMouseup",e,t)})}),this.ctx.on("click",t=>{if(0!==t.button||this.isBusy(t))return;let e=this.ctx.getOffset(t).offsetY,i=this.ctx.getOffset(t).offsetX;this.handleHeaderEvent(i,e,this.ctx.header.renderCellHeaders,e=>{this.ctx.clickCellHeader=e,this.ctx.emit("cellHeaderClick",e,t)}),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>
13{this.ctx.clickCell=s,this.ctx.emit("cellClick",s,t);let r=s.getImage("hover");!this.ctx.disableHoverIconClick&&r&&r.isInside(i,e)&&this.ctx.emit("hoverIconClick",s)},!0)}),this.ctx.on("dblclick",t=>{if(0!==t.button||this.isBusy(t))return;let e=this.ctx.getOffset(t).offsetY,i=this.ctx.getOffset(t).offsetX;this.handleHeaderEvent(i,e,this.ctx.header.renderCellHeaders,e=>{this.ctx.emit("cellHeaderDblclick",e,t)}),this.handleBodyEvent(i,e,this.ctx.body.renderRows,e=>{this.ctx.clickCell=e,this.ctx.emit("cellDblclick",e,t)})}),this.ctx.on("contextMenu",t=>{if(this.isBusy(t))return;let{offsetY:e,offsetX:i}=this.ctx.getOffset(t);this.handleHeaderEvent(i,e,this.ctx.header.renderCellHeaders,e=>{this.ctx.emit("cellHeaderContextMenuClick",e,t)}),this.handleBodyEvent(i,e,this.ctx.body.renderRows,e=>{this.ctx.emit("cellContextMenuClick",e,t)})}),this.ctx.on("mouseout",t=>{this.ctx.containerElement.contains(t.relatedTarget)||void 0===this.ctx.hoverCell||(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.mousedown||"default"===this.ctx.stageElement.style.cursor||(this.ctx.stageElement.style.cursor="default");let e=this.ctx.getOffset(t).offsetY,i=this.ctx.getOffset(t).offsetX;this.handleHeaderEvent(i,e,this.ctx.header.renderCellHeaders,e=>{this.imageEnterAndLeave(e,t),this.ctx.emit("cellHeaderMouseenter",e,t),this.ctx.hoverCellHeader&&this.ctx.hoverCellHeader!==e&&this.ctx.emit("cellHeaderMouseleave",this.ctx.hoverCellHeader,t),this.ctx.hoverCellHeader!==e&&(this.ctx.hoverCellHeader=e,this.visibleHoverCell=void 0,this.ctx.emit("cellHeaderHoverChange",e,t))}),this.handleBodyEvent(i,e,this.ctx.body.renderRows,e=>{this.imageEnterAndLeave(e,t),this.visibleHoverCell!==e&&(this.ctx.emit("visibleCellMouseleave",e,t),this.visibleHoverCell=e,this.ctx.hoverCellHeader=void 0,this.ctx.emit("visibleCellHoverChange",e,t))},!0),this.handleBodyEvent(i,e,this.ctx.body.renderRows,e=>{var i;this.ctx.emit("cellMouseenter",e,t),this.ctx.hoverCell&&this.ctx.hoverCell!==e&&this.ctx.emit("cellMouseleave",e,t),this.ctx.hoverCell!==e&&((null==(i=this.ctx.hoverCell)?void 0:i.rowKey)!==e.rowKey&&(this.ctx.hoverCell=e,this.ctx.hoverRow=this.ctx.body.renderRows.find(t=>t.rowKey===e.rowKey),this.ctx.emit("rowHoverChange",this.ctx.hoverRow,e,t),this.ctx.emit("draw")),this.ctx.hoverCell=e,this.ctx.emit("cellHoverChange",e,t))}),this.handleFooterEvent(i,e,this.ctx.footer.renderRows,e=>{this.ctx.emit("cellFooterMouseenter",e,t),this.ctx.hoverCell&&this.ctx.hoverCell!==e&&this.ctx.emit("cellFooterMouseleave",e,t),this.ctx.emit("cellFooterHoverChange",e,t)})})}imageEnterAndLeave(t,e){if(this.ctx.dragRowIng||this.ctx.dragHeaderIng||this.ctx.selectColsIng||this.ctx.selectRowsIng||this.ctx.selectorMove||this.ctx.autofillMove)return;let{offsetY:i,offsetX:s}=this.ctx.getOffset(e);t.cellImages.forEach((t,e)=>{t.isInside(s,i)&&("drag"===e?this.ctx.stageElement.style.cursor="grab":this.ctx.stageElement.style.cursor="pointer")})}isBusy(t){let{offsetY:e,offsetX:i}=this.ctx.getOffset(t);if(this.ctx.loading||!this.ctx.isTarget(t)||"row-resize"===this.ctx.stageElement.style.cursor||"col-resize"===this.ctx.stageElement.style.cursor||this.ctx.columnResizing||this.ctx.rowResizing)return!0;let{SCROLLER_TRACK_SIZE:s}=this.ctx.config;return!!(this.ctx.scrollerMove||this.ctx.scrollerFocus||e>this.ctx.stageHeight-s||i>this.ctx.stageWidth-s)}handleBodyEvent(t,e,i,s,r=!1){if(this.isInsideBody(t,e)){for(let l of i)for(let i of l.fixedCells.concat(l.noFixedCells))if(r?i.isInsideVisible(t,e):i.isInside(t,e))return void s(i)}}handleHeaderEvent(t,e,i,s){for(let r of i)if(r.isInside(t,e))return void s(r)}handleFooterEvent(t,e,i,s){for(let r of i)for(let i of r.fixedCells.concat(r.noFixedCells))if(i.isInside(t,e))return void s(i)}isInsideBody(t,e){let{body:{y:i,visibleHeight:s,height:r,visibleWidth:l}}=this.ctx,o=Math.min(r,s);return t>0&&t<l&&e>i&&e<i+o}destroy(){this.resizeObserver.unobserve(this.ctx.stageElement),this.mutationObserver.disconnect()}}let V={numberErrorTip:"只允许输入数字",emptyText:"暂无数据",loadingText:"加载中...",copy:"复制",cut:"剪切",paste:"粘贴",clearSelected:"清空选中内容",fixedLeft:"左固定",fixedRight:"右固定",fixedNone:"取消固定",hide:"隐藏",visible:"显示",resetHeader:"恢复默认",invali
13dNumber:"请输入数字类型",mergeCellNoFill:"合并单元格不能填充",mergeCellNoCopy:"合并单元格不能复制",mergeCellNoPaste:"合并单元格不能粘贴",numberTruncated:"输入的数字已截取至小数点后{precision}位",batchSetItemValueError:"批量赋值错误",numberMin:"输入值小于{min},已自动调整为{min}",numberMax:"输入值大于{max},已自动调整为{max}",stringMaxlength:"输入值超过{maxlength}个字符,已自动截取"};class z{constructor(){l(this,"langConfig")}use(t){this.langConfig=t}getText(t,e){let i={...V};Object.assign(i,eg.locale,this.langConfig);let s=i[t];return s?s.replace(/{(\w+)}/g,(t,i)=>(null==e?void 0:e[i])||t):""}}class P{constructor(t,e){l(this,"eventBus"),l(this,"eventBrowser"),l(this,"eventTable"),l(this,"locale",new z),l(this,"containerElement"),l(this,"stageElement"),l(this,"canvasElement"),l(this,"overlayerElement"),l(this,"editorElement"),l(this,"emptyElement"),l(this,"contextMenuElement"),l(this,"loadingElement"),l(this,"stageWidth",0),l(this,"stageHeight",0),l(this,"paint"),l(this,"icons"),l(this,"domSelectionStr",""),l(this,"textSelectionStr",""),l(this,"textSelecting",!1),l(this,"isMouseoverTargetContainer",!1),l(this,"mousedown",!1),l(this,"isEmpty",!1),l(this,"rowResizing",!1),l(this,"columnResizing",!1),l(this,"scrollerMove",!1),l(this,"scrollerFocus",!1),l(this,"autofillMove",!1),l(this,"selectorMove",!1),l(this,"disableHoverIconClick",!1),l(this,"selectColsIng",!1),l(this,"selectRowsIng",!1),l(this,"dragHeaderIng",!1),l(this,"dragRowIng",!1),l(this,"finding",!1),l(this,"contextMenuIng",!1),l(this,"editing",!1),l(this,"loading",!1),l(this,"onlyMergeCell",!1),l(this,"selectOnlyOne",!1),l(this,"hasSelection",!1),l(this,"hasTree",!1),l(this,"scrollY",0),l(this,"scrollX",0),l(this,"fixedLeftWidth",0),l(this,"fixedRightWidth",0),l(this,"lastCenterColIndex",0),l(this,"maxColIndex",0),l(this,"maxRowIndex",0),l(this,"hoverRow"),l(this,"clickCell"),l(this,"focusCell"),l(this,"currentCell"),l(this,"hoverCell"),l(this,"clickCellHeader"),l(this,"focusCellHeader"),l(this,"hoverCellHeader"),l(this,"mouseX",0),l(this,"mouseY",0),l(this,"body",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,headIndex:0,tailIndex:0,visibleRows:[],renderRows:[],data:[]}),l(this,"footer",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,renderRows:[]}),l(this,"header",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,visibleLeafColumns:[],leafCellHeaders:[],allCellHeaders:[],renderLeafCellHeaders:[],renderCellHeaders:[],fixedLeftCellHeaders:[],fixedRightCellHeaders:[],renderCenterCellHeaders:[]}),l(this,"selector",{enable:!1,xArr:[-1,-1],yArr:[-1,-1],xArrCopy:[-1,-1],yArrCopy:[-1,-1]}),l(this,"autofill",{enable:!1,xArr:[-1,-1],yArr:[-1,-1]}),l(this,"finderBar",{text:"",rowIndex:-1,colIndex:-1,type:"body"}),l(this,"database"),l(this,"history"),l(this,"config");let{containerElement:i,stageElement:s,canvasElement:r,overlayerElement:o,editorElement:h,emptyElement:n,loadingElement:a,contextMenuElement:c}=t;this.containerElement=i,s.tabIndex=0,this.stageElement=s,this.canvasElement=r,this.overlayerElement=o,this.editorElement=h,this.emptyElement=n,this.loadingElement=a,this.contextMenuElement=c,this.config=new O(e.config||{}),this.eventBus=new _,this.eventBrowser=new I(this),this.eventTable=new W(this),this.paint=new T(this.canvasElement),this.database=new C(this,e),this.history=new R(this),this.icons=new Y(this)}setConfig(t){this.config=new O(t)}setItemValueByEditor(t,e,i,s=!0,r=!0,l=!0){if(this.config.ENABLE_MERGE_CELL_LINK){let r=this.database.getVirtualBodyCellByKey(t,e);if(r&&(r.mergeRow||r.mergeCol)){let{dataList:t}=r.getSpanInfo(),e=t.map(t=>({...t,value:i}));this.database.batchSetItemValue(e,s,l);return}}this.database.setItemValue(t,e,i,s,r,!0,l)}batchSetItemValueByEditor(t,e=!0,i=!0){if(this.config.ENABLE_MERGE_CELL_LINK){let s=[];t.forEach(t=>{let e=this.database.getRowIndexForRowKey(t.rowKey),i=this.database.getColIndexForKey(t.key);if(void 0===e||void 0===i)return;let r=this.database.getVirtualBodyCell(e,i);if(r){let{dataList:e}=r.getSpanInfo(),i=e.map(e=>({...e,value:t.value}));s.push(...i)}}),this.database.batchSetItemValue(s,e,i)}else this.database.batchSetItemValue(t,e,i)}setFocusCell(t){var e;if(this.focusCell!==t){if((null==(e=this.focusCell)?void 0:e.rowKey)!==t.rowKey
13){this.currentCell=t,this.emit("rowFocusChange",t);let e={rowIndex:t.rowIndex,rowKey:t.rowKey,row:t.row};this.emit("currentRowChange",e)}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(){let t=[],e=this.selector.yArr,i=this.selector.xArr,s="";for(let r=0;r<=e[1]-e[0];r++){let l=[];for(let t=0;t<=i[1]-i[0];t++){let s=r+e[0],o=t+i[0],h=this.database.getVirtualBodyCell(s,o);h&&("displayText"===h.selectorCellValueType?l.push(h.displayText):l.push(h.getValue()))}s+=`${l.join("	")}\r`,t.push(l)}return{xArr:i,yArr:e,text:s=s?s.replace(/\r$/,""):" ",value:t}}setScroll(t,e){let i=Math.floor(t),s=this.body.width-this.body.visibleWidth;i<0?i=0:i>s&&(i=s);let r=Math.floor(e),l=this.body.height-this.body.visibleHeight;this.config.FOOTER_FIXED||(l=this.body.height+this.footer.height-this.body.visibleHeight),r<0?r=0:r>l&&(r=l),this.emit("setScroll",i,r)}setScrollX(t){let e=Math.floor(t),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);let s=this.body.height-this.body.visibleHeight+i;e<0?e=0:e>s&&(e=s),this.emit("setScrollY",e)}startAdjustPosition(t){this.emit("startAdjustPosition",t)}stopAdjustPosition(){this.emit("stopAdjustPosition")}isTarget(t){return!!this.containerElement.contains(t.target)}getOffset(t){let{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 G{constructor(t,e){l(this,"ctx"),l(this,"type"),l(this,"isFocus",!1),l(this,"trackX",0),l(this,"trackY",0),l(this,"trackWidth",0),l(this,"trackHeight",0),l(this,"splitPoints",[]),l(this,"barX",0),l(this,"barY",0),l(this,"barWidth",0),l(this,"barHeight",0),l(this,"distance",0),l(this,"visibleDistance",0),l(this,"clientX",0),l(this,"clientY",0),l(this,"dragStart",0),l(this,"isDragging",!1),l(this,"scroll",0),this.ctx=t,this.type=e,"vertical"===this.type?this.scroll=this.ctx.scrollY:this.scroll=this.ctx.scrollX}onWheel(t){this.updateScroll(t)}onTouchmove(t){let{clientY:e,clientX:i}=t.touches[0],s=e-this.clientY,r=i-this.clientX,l=0;"vertical"===this.type?(l=Math.max(0,Math.min(this.dragStart-s,this.distance)),this.hasScrollbar()&&!(0===l&&s>0||l===this.distance&&s<0)&&t.preventDefault()):"horizontal"===this.type&&(l=Math.max(0,Math.min(this.dragStart-r,this.distance))),this.scroll=l}onTouchstart(t){let{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("row-resize"===this.ctx.stageElement.style.cursor||"col-resize"===this.ctx.stageElement.style.cursor)return!0;let{offsetX:e,offsetY:i,clientX:s,clientY:r}=t;if(s!=this.clientX||r!=this.clientY){if(this.isOnScrollbar(e,i))this.clientX=s,this.clientY=r,this.isDragging=!0,this.ctx.scrollerMove=!0,this.isFocus=!0,this.dragStart=this.scroll,t.preventDefault();else if(this.isOnTrack(e,i)){let t=0;t="vertical"===this.type?(i-this.ctx.header.height-this.barHeight/2)/(this.visibleDistance-this.barHeight)*this.distance:(e-this.barWidth/2)/(this.visibleDistance-this.barWidth)*this.distance,this.scroll=Math.max(0,Math.min(t,this.distance))}}}onMouseUp(){this.isDragging=!1,this.isFocus=!1,this.clientX=0,this.clientY=0}onMouseMove(t){let{offsetX:e,offsetY:i,clientX:s,clientY:r,buttons:l}=t;if(this.isOnScrollbar(e,i)&&t.target===this.ctx.canvasElement?this.isFocus=!0:this.isFocus=!1,0===l||s==this.clientX&&r==this.clientY)return;let o=0;if(o="horizontal"===this.type?s-this.clientX:r-this.clientY,this.isDragging&&0!==o){let t=0;t="vertical"===this.type?this.dragStart+o/(this.visibleDistance-this.barHeight)*this.distance:this.dragStart+o/(this.visibleDistance-this.barWidth)*this.distance,this.scroll=Math.max(0,Math.min(t,this.distance))}}isPointInElement(t,e,i,s,r,l){return t>=i&&t<=i+r&&e>=s&&e<=s+l}hasScrollbar(){return"vertical"===this.type?this.barHeight>0:"horizontal"===this.type&&this.barWidth>0}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){let e=t.deltaX,i=t.deltaY;"vertical"===this.type&&!1===t.shiftKey?(this.hasScrollbar()&&!(0===this.scroll&&i<0||this.scroll===this.distance&&i>0)&&t.preventDefault(),this.scroll=Math.max(0,Math.min(this.scroll+i,this.distance))):"horizontal"===this.type&&(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(){let{body:t,header:e,stageHeight:i,stageWidth:s,config:{SCROLLER_TRACK_SIZE:r=0,SCROLLER_SIZE:l=0,BORDER:o}}=this.ctx,h=e.height,n=e.width,a=t.height,c=this.ctx.footer.height;if("vertical"===this.type){this.visibleDistance=i-r-h,this.distance=a-this.visibleDistance+c,this.trackX=s-r,this.trackY=0,this.splitPoints=[this.trackX,h,this.trackX+r,h],this.trackWidth=r,this.trackHeight=i,this.barX=this.trackX-1+(r-l)/2,this.barWidth=l;let t=Math.floor((this.distance?this.visibleDistance/(a+c):0)*this.visibleDistance);t<30?t=30:t>this.visibleDistance&&(t=0),this.barHeight=t,this.barY=h+this.scroll/this.distance*(this.visibleDistance-this.barHeight),this.scroll=Math.max(0,Math.min(this.scroll,this.distance))}else{this.visibleDistance=s-r,this.distance=n-this.visibleDistance,this.splitPoints=[s-r,i-r,s-r,i],this.trackX=0,this.trackY=i-r+.5*!o,this.trackWidth=s,this.trackHeight=r;let t=Math.floor((this.distance?this.visibleDistance/n:0)*this.visibleDistance);this.barY=this.trackY-1+(r-l)/2,t<30?t=30:t>=this.visibleDistance&&(t=0),this.barWidth=t,this.barHeight=l,this.barX=this.scroll/this.distance*(this.visibleDistance-this.barWidth),this.scroll=Math.max(0,Math.min(this.scroll,this.distance))}}draw(){let{config:{SCROLLER_FOCUS_COLOR:t,SCROLLER_COLOR:e,BORDER_COLOR:i,BORDER:s,SCROLLER_TRACK_COLOR:r}}=this.ctx;this.updatedSize();let l=i;s||(l="transparent"),this.ctx.paint.drawRect(this.trackX,this.trackY,this.trackWidth,this.trackHeight,{borderColor:l,fillColor:r}),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:l,borderWidth:1}),this.ctx.scrollerFocus=this.isFocus}}class ${constructor(t){l(this,"ctx"),l(this,"verticalScrollbar"),l(this,"horizontalScrollbar"),l(this,"mousedownHeader",!1),l(this,"adjustPositionX",""),l(this,"adjustPositionY",""),l(this,"timerX",0),l(this,"timerY",0),this.ctx=t,this.verticalScrollbar=new G(t,"vertical"),this.horizontalScrollbar=new G(t,"horizontal"),this.ctx.on("wheel",t=>this.onWheel(t)),this.ctx.on("mousedown",t=>this.onMouseDown(t)),this.ctx.on("mousemove",t=>this.onMouseMove(t)),this.ctx.on("mouseup",()=>this.onMouseUp()),this.ctx.on("touchmove",t=>this.onTouchmove(t)),this.ctx.on("touchstart",t=>{this.onTouchstart(t)}),this.ctx.on("setScroll",(t,e)=>{this.setScroll(t,e)}),this.ctx.on("setScrollX",t=>{this.setScrollX(t)}),this.ctx.on("setScrollY",t=>{this.setScrollY(t)}),this.ctx.on("scrollToIndex",(t,e)=>{this.scrollToIndex(t,e)}),this.ctx.on("cellHeaderMousedown",()=>{this.mousedownHeader=!0}),this.ctx.on("startAdjustPosition",t=>{this.startAdjustPosition(t)}),this.ctx.on("stopAdjustPosition",()=>{this.stopAdjustPosition()})}onWheel(t){this.verticalScrollbar.onWheel(t),this.horizontalScrollbar.onWheel(t),this.draw()}onTouchmove(t){this.verticalScrollbar.onTouchmove(t),this.horizontalScrollbar.onTouchmove(t),this.draw()}onTouchstart(t){this.verticalScrollbar.onTouchstart(t),this.horizontalScrollbar.onTouchstart(t),this.draw()}onMouseDown(t){this.verticalScrollbar.onMouseDown(t),this.horizontalScrollbar.onMouseDown(t),this.draw()}onMouseMove(t){this.verticalScrollbar.onMouseMove(t),this.horizontalScrollbar.onMouseMove(t),this.draw()}onMouseUp(){this.mousedownHeader=!1,this.verticalScrollbar.onMouseUp(),this.horizontalScrollbar.onMouseUp(),this.ctx.scrollerMove=!1}draw(){this.verticalScrollbar.draw(),this.horizontalScrollbar.draw();let 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){let{header:e}=this.ctx,i=e.leafCellHeaders.find(e=>e.key===t);i&&this.setScrollX(i.x-e.visibleWidth/2)}scrollToColIndex(t){let{header:e}=this.ctx,i=e.leafCellHeaders.find(e=>e.colIndex===t);i&&this.setScrollX(i.x-e.visibleWidth/2)}scrollToRowIndex(t){let{body:e,database:i}=this.ctx,{top:s}=i.getPositionForRowIndex(t);this.setScrollY(s-e.visibleHeight/2)}scrollToIndex(t,e){this.scrollToRowIndex(t),this.scrollToColIndex(e)}scrollToRowKey(t){let{body:e,database:i}=this.ctx,s=i.getRowIndexForRowKey(t);if(void 0===s)return;let{top:r}=i.getPositionForRowIndex(s);this.setScrollY(r-e.visibleHeight/2)}startAdjustPosition(t){var e,i;let{offsetX:s,offsetY:r}=this.ctx.getOffset(t),l="",o="";if((null==(e=this.ctx.focusCell)?void 0:e.fixed)!=="left"&&s<this.ctx.fixedLeftWidth?l="left":(null==(i=this.ctx.focusCell)?void 0:i.fixed)!=="right"&&s>this.ctx.body.visibleWidth-this.ctx.fixedRightWidth?l="right":(l="",this.stopAdjustPosition(!0,!1)),!this.mousedownHeader&&r<this.ctx.header.visibleHeight?o="top":r>this.ctx.header.visibleHeight+this.ctx.body.visibleHeight?o="bottom":(o="",this.stopAdjustPosition(!1,!0)),l&&this.adjustPositionX!==l){this.adjustPositionX=l;let t=10*("left"===l?-1:1);this.timerX&&(clearInterval(this.timerX),this.timerX=0),this.timerX=setInterval(()=>{t*=1.5;let{scrollX:e}=this.ctx,i=e+t;(i<0||i>this.ctx.body.width)&&(clearInterval(this.timerX),this.timerX=0),this.ctx.setScrollX(i)},100)}if(o&&this.adjustPositionY!==o){this.adjustPositionY=o;let t=10*("top"===o?-1:1);this.timerY&&(clearInterval(this.timerY),this.timerY=0),this.timerY=setInterval(()=>{t*=1.5;let{scrollY:e}=this.ctx,i=e+t;(i<0||i>this.ctx.body.height)&&(clearInterval(this.timerY),this.timerY=0),this.ctx.setScrollY(i)},100)}}stopAdjustPosition(t=!0,e=!0){t&&(this.adjustPositionX="",this.timerX&&(clearInterval(this.timerX),this.timerX=0)),e&&(this.adjustPositionY="",this.timerY&&(clearInterval(this.timerY),this.timerY=0))}}class U extends y{constructor(t,e,i,s,r,o,n){super(t,i,s,r,o,"header",n.fixed),l(this,"align"),l(this,"hideHeaderSelection",!1),l(this,"verticalAlign","middle"),l(this,"fixed"),l(this,"minWidth"),l(this,"maxWidth"),l(this,"widthFillDisable"),l(this,"type"),l(this,"operation",!1),l(this,"editorType"),l(this,"level"),l(this,"text"),l(this,"hide",!1),l(this,"displayText",""),l(this,"colspan"),l(this,"rowspan"),l(this,"row"),l(this,"key"),l(this,"required",!1),l(this,"readonly",!1),l(this,"ellipsis",!1),l(this,"overflowTooltipShow",!0),l(this,"children",[]),l(this,"column"),l(this,"colIndex"),l(this,"rowKey"),l(this,"rules"),l(this,"hasChildren"),l(this,"render"),l(this,"style",{}),l(this,"drawX",0),l(this,"drawY",0),l(this,"sortIconName","sort-default"),l(this,"sortAscIconName","sort-asc"),l(this,"sortDescIconName","sort-desc"),l(this,"visibleWidth",0),l(this,"visibleHeight",0),l(this,"maxLineClampHeader","auto"),l(this,"domDataset",{}),l(this,"textOffsetRight",0),l(this,"textOffsetLeft",0),l(this,"textInfo"),l(this,"drawTextX",0),l(this,"drawTextY",0),l(this,"drawTextWidth",0),l(this,"drawTextHeight",0),l(this,"drawCellBgColor",""),l(this,"drawTextColor",""),l(this,"drawTextFont",""),l(this,"drawSelectionImageX",0),l(this,"drawSelectionImageY",0),l(this,"drawSelectionImageWidth",0),l(this,"drawSelectionImageHeight",0),l(this,"drawSelectionImageName",""),l(this,"drawSelectionImageSource"),l(this,"drawSortImageX",0),l(this,"drawSortImageY",0),l(this,"drawSortImageWidth",0),l(this,"drawSortImageHeight",0),l(this,"drawSortImageName",""),l(this,"drawSortImageSource"),l(this,"renderHeaderType","default"),this.ctx=t,this.x=i,this.y=s,this.width=r,this.height=o,this.visibleWidth=r,this.visibleHeight=o,this.colIndex=e,this.key=n.key,this.minWidth=n.minWidth,this.maxWidth=n.maxWidth,this.hide=("function"==typeof n.hide?n.hide(n):n.hide)||!1,this.type=n.type||"",this.editorType=n.editorType||"text",this.hideHeaderSelection=n.hideHeaderSelection||!1,this.align=n.headerAlign||n.align||this.ctx.config.COLUMNS_ALIGN,this.verticalAlign=n.headerVerticalAlign||n.verticalAlign||this.ctx.config.COLUMNS_VERTICAL_ALIGN,this.fixed=n.fixed||"",this.level=n.level||0,this.operation=n.operation||!1,this.text=n.title,this.column=n,this.colspan=n.colspan||1,this.widthFillDisable=n.widthFillDisable||!1,this.rowspan=n.rowspan||1,this.rules=n.rules,this.readonly=n.readonly||!1,this.required=n.required||!1,this.sortIconName=n.sortIconName||"sort-default",this.sortAscIconName=n.sortAscIconName||"sort-asc",this.sortDe
13scIconName=n.sortDescIconName||"sort-desc",this.rowKey=h(),this.overflowTooltipShow=!1!==n.overflowTooltipHeaderShow,this.hasChildren=n.children&&n.children.length>0||!1,this.render=n.renderHeader,this.maxLineClampHeader=n.maxLineClampHeader||"auto",this.renderHeaderType=n.renderHeaderType||"default"}isVerticalVisible(){let{stageHeight:t}=this.ctx;return!(this.y+this.height<=0||this.y>=t)}updateStyle(){this.style=this.getOverlayerViewsStyle()}updateContainer(){let{HEADER_CELL_STYLE_METHOD:t,HEADER_BG_COLOR:e,HEADER_TEXT_COLOR:i}=this.ctx.config,s=e,r=i;if("function"==typeof t){let{backgroundColor:e,color:i,font:l}=t({colIndex:this.colIndex,column:this.column})||{};e&&(s=e),i&&(r=i),l&&(this.drawTextFont=l)}let{colKey:l,type:o}=this.ctx.finderBar;"header"===o&&l===this.key&&(s=this.ctx.config.FINDER_CELL_BG_COLOR),this.drawCellBgColor=s,this.drawTextColor=r}updateOffset(){this.column.sortBy&&(this.textOffsetRight=16),this.required&&(this.textOffsetLeft=12)}update(){this.updateContainer(),this.updateOffset(),this.displayText=this.getText(),this.drawX=this.getDrawX(),this.drawY=this.getDrawY(),this.updateSelection(),this.drawTextX=this.drawX,this.drawTextY=this.drawY,this.drawTextWidth=this.width,this.drawTextHeight=this.height,this.updateStyle()}draw(){this.drawEdge(),this.drawText(),this.drawBg(),this.updateSortIcon(),this.drawImages(),this.drawRequired()}
13drawImages(){this.getImages().forEach(t=>{t.visible&&t.source&&this.ctx.paint.drawImage(t.source,t.x,t.y,t.width,t.height)})}drawEdge(){let{paint:t,config:{BORDER_COLOR:e,BORDER:i}}=this.ctx;t.drawRect(this.drawX,this.drawY,this.width,this.height,{borderColor:i?e:"transparent",fillColor:this.drawCellBgColor})}drawText(){let{paint:t,config:{HEADER_FONT:e,CELL_PADDING:i}}=this.ctx,s=`${this.displayText}_${this.drawTextWidth}_${this.drawTextFont}`;this.ellipsis=t.drawText(this.displayText,this.drawTextX,this.drawTextY,this.drawTextWidth,this.drawTextHeight,{font:this.drawTextFont||e,padding:i,color:this.drawTextColor,align:this.align,verticalAlign:this.verticalAlign,maxLineClamp:this.maxLineClampHeader,offsetRight:this.textOffsetRight,offsetLeft:this.textOffsetLeft,cacheTextKey:s,textCallback:t=>{this.textInfo=t},layoutCallback:t=>{this.ctx.emit("registerTextLayout",`${this.cellType}-${this.colIndex}-${this.level}`,t)}})}drawRequired(){if(!this.required||!this.textInfo)return;let{left:t,top:e,height:i}=this.textInfo,{paint:s,config:{REQUIRED_COLOR:r}}=this.ctx;s.drawText("*",t-18,e+(i-12)/2,24,24,{color:r,font:"18px Arial",align:"center",verticalAlign:"middle",padding:0})}drawBg(){if(this.ctx.dragHeaderIng)return;let{ENABLE_SELECTOR:t,ENABLE_SELECTOR_SINGLE:e}=this.ctx.config,i=-1,s=-1;if(this.ctx.focusCellHeader&&(i=this.ctx.focusCellHeader.colIndex,s=this.ctx.focusCellHeader.colIndex+this.ctx.focusCellHeader.colspan-1),t&&!e){let{xArr:t}=this.ctx.selector;i=t[0],s=t[1]}let r=this.colspan+this.colIndex-1;this.colIndex>=i&&this.colIndex<=s&&r<=s&&this.ctx.paint.drawRect(this.drawX,this.drawY,this.width,this.height,{borderColor:"transparent",fillColor:this.ctx.config.SELECT_ROW_COL_BG_COLOR||"transparent"})}updateSelection(){if(["index-selection","selection","selection-tree","tree-selection"].includes(this.type)){let{indeterminate:t,check:e,selectable:i}=this.ctx.database.getCheckedState(),{CHECKBOX_SIZE:s=0,CELL_PADDING:r}=this.ctx.config,l=this.drawX+(this.width-s)/2,o=this.drawY+(this.height-s)/2;this.drawTextX=l+s-r/2,this.drawTextWidth=this.drawX+this.visibleWidth-this.drawTextX,("left"===this.align||"right"===this.align)&&(l=this.drawX+r,this.drawTextX=l+s-r/2,this.drawTextWidth=this.drawX+this.visibleWidth-this.drawTextX),"top"===this.verticalAlign?o=this.drawY+r/2:"bottom"===this.verticalAlign&&(o=this.drawY+this.height-s-r/2),this.column.dragRow&&(l+=this.ctx.config.DRAG_ROW_ICON_SIZE,this.drawTextX+=this.ctx.config.DRAG_ROW_ICON_SIZE,this.drawTextWidth-=this.ctx.config.DRAG_ROW_ICON_SIZE);let h=this.ctx.icons.get("checkbox-uncheck"),n="checkbox-uncheck";t?(h=this.ctx.icons.get("checkbox-indeterminate"),n="checkbox-indeterminate"):e&&i?(h=this.ctx.icons.get("checkbox-check"),n="checkbox-check"):e&&!i?(h=this.ctx.icons.get("checkbox-check-disabled"),n="checkbox-check-disabled"):!e&&i?(h=this.ctx.icons.get("checkbox-uncheck"),n="checkbox-uncheck"):(h=this.ctx.icons.get("checkbox-disabled"),n="checkbox-disabled");let a=new b(n,l,o,s,s,h);a.setVisible(!this.hideHeaderSelection),this.setImage("selection",a)}}updateSortIcon(){if(!this.column.sortBy||!this.textInfo)return;let{right:t,top:e,height:i}=this.textInfo,s=this.sortIconName,r=this.ctx.database.getSortState(this.key);"asc"===r.direction?s=this.sortAscIconName:"desc"===r.direction&&(s=this.sortDescIconName);let l=this.ctx.icons.get(s),o=new b(s,t+4,e+(i-16)/2,16,16,l);this.setImage("sort",o)}getText(){return this.render&&"default"===this.renderHeaderType||["",null,void 0].includes(this.text)?"":`${this.text}`}getOverlayerViewsStyle(){return{position:"absolute",overflow:"hidden",left:"left"===this.fixed?`${this.drawX}px`:"right"===this.fixed?`${this.drawX-(this.ctx.stageWidth-this.ctx.fixedRightWidth)}px`:`${this.drawX-this.ctx.fixedLeftWidth}px`,top:`${this.drawY+1}px`,width:`${this.width}px`,height:`${this.height-2}px`,pointerEvents:"initial",userSelect:"none"}}}class j{constructor(t,e){l(this,"root"),l(this,"key"),l(this,"childrenKey"),this.root=t,this.key=(null==e?void 0:e.key)||"key",this.childrenKey=(null==e?void 0:e.childrenKey)||"children"}getTree(){return this.root}treeMove(t,e,i){if("none"===i||t===e)return;let s=this.findNodeWithParent(this.root,t);if(!s)return;let r=this.findNodeWithParent(this.root,e);if(!r)return;let{parent:l,index:o,node:h}=s,{parent:n,index:a,node:c}=r;if(this.isDescendant(h,e))return;let d=l?l[this.childrenKey]:this.root;if(d.splice(o,1),l&&0===d.length&&delete l[this.childrenKey],"inside"===i){Array.isArray(c[this.childrenKey])||(c[this.childrenKey]=[]),c[this.childrenKey].push(h);return}let x=n?n[this.childrenKey]:this.root,u=a;l===n&&o<a&&u--,"after"===i&&u++,x.splice(u,0,h)}findNodeWithParent(t,e,i=null){for(let s=0;s<t.length;s++){let r=t[s];if(r[this.key]===e)return{parent:i,index:s,node:r};let l=r[this.childrenKey];if(Array.isArray(l)){let t=this.findNodeWithParent(l,e,r);
13if(t)return t}}return null}isDescendant(t,e){let i=t[this.childrenKey];if(!Array.isArray(i))return!1;for(let t of i)if(t[this.key]===e||this.isDescendant(t,e))return!0;return!1}}class Z{constructor(t){l(this,"ctx"),l(this,"x",0),l(this,"y",0),l(this,"width",0),l(this,"height",0),l(this,"resizeTarget",null),l(this,"dragTarget",null),l(this,"dragingCell"),l(this,"dragCellDiff",0),l(this,"resizeNum",0),l(this,"isResizing",!1),l(this,"clientX",0),l(this,"resizeDiff",0),l(this,"columnIndex",0),l(this,"isMouseDown",!1),l(this,"columns"),l(this,"visibleColumns"),l(this,"visibleLeafColumns",[]),l(this,"visibleHeight",0),l(this,"visibleWidth",0),l(this,"allCellHeaders",[]),l(this,"leafCellHeaders",[]),l(this,"renderLeafCellHeaders",[]),l(this,"fixedLeftCellHeaders",[]),l(this,"centerCellHeaders",[]),l(this,"fixedRightCellHeaders",[]),l(this,"renderCenterCellHeaders",[]),l(this,"renderFixedCellHeaders",[]),this.ctx=t,this.ctx.on("resetHeader",n(()=>{this.init(),this.ctx.clearSelector(),this.ctx.emit("draw")},100)),this.init(),this.initSelection(),this.initSort(),this.initResizeColumn(),this.initDragColumn()}init(t=!1){let{config:{HEADER_HEIGHT:e,SCROLLER_TRACK_SIZE:i}}=this.ctx;if(!t){let t=this.ctx.database.getColumns();this.columns=t}this.allCellHeaders=[],this.leafCellHeaders=[],this.fixedLeftCellHeaders=[],this.fixedRightCellHeaders=[],this.centerCellHeaders=[],this.visibleColumns=function t(e){return e.filter(t=>!t.hide).map(e=>Array.isArray(e.children)&&e.children.length>0?{...e,children:t(e.children)}:{...e})}(this.columns);let s=a(this.visibleColumns),r=d(this.visibleColumns);this.height=e*s,this.visibleHeight=this.height,this.width=r.reduce((t,e)=>{let i=e.width||100,{maxWidth:s,minWidth:r}=e;return s&&i>s?t+s:r&&i<r?t+r:t+i},0),this.columnIndex=0,this.resizeNum=0;let l=function(t=[]){let e=[],i=[],s=[];return t.forEach(t=>{"left"===t.fixed?e.push(t):"right"===t.fixed?s.push(t):i.push(t)}),[...e.sort((t,e)=>(t.sort??0)-(e.sort??0)),...i.sort((t,e)=>(t.sort??0)-(e.sort??0)),...s.sort((t,e)=>(t.sort??0)-(e.sort??0))]}(c(this.visibleColumns,s));this.render(l,0),this.ctx.database.updateColIndexKeyMap(this.leafCellHeaders);let o=this.ctx.containerElement.getBoundingClientRect();this.resizeNum>0?this.ctx.stageWidth=Math.floor(o.width):this.ctx.stageWidth=Math.min(Math.floor(this.width+i),Math.floor(o.width)),this.ctx.stageElement.style.width=this.ctx.stageWidth+"px",this.visibleWidth=this.ctx.stageWidth-i;let h=this.visibleWidth-this.width;if(this.resizeNum&&h>0){let t=Math.floor(h/this.resizeNum*100)/100;this.resizeAllColumn(t)}let n=this.fixedLeftCellHeaders.filter(t=>!t.hasChildren);this.ctx.fixedLeftWidth=n.reduce((t,e)=>t+e.width,0);let x=this.fixedRightCellHeaders.filter(t=>!t.hasChildren);this.ctx.fixedRightWidth=x.reduce((t,e)=>t+e.width,i),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.allCellHeaders=this.allCellHeaders,this.ctx.header.visibleWidth=this.visibleWidth,this.ctx.header.visibleHeight=this.visibleHeight}initSort(){this.ctx.on("cellHeaderClick",(t,e)=>{let i;if(!t.isImageInside("sort",e))return;let s=this.ctx.database.getSortState(t.key);i="none"===s.direction?"asc":"asc"===s.direction?"desc":"none",this.ctx.database.setSortState(t.key,i)})}initSelection(){this.ctx.on("cellHeaderClick",(t,e)=>{if("pointer"!==this.ctx.stageElement.style.cursor||!t.isImageInside("selection",e))return;let i=t.getImage("selection");["checkbox-uncheck","checkbox-indeterminate"].includes(i.name)?this.ctx.database.toggleAllSelection():"checkbox-check"===i.name&&this.ctx.database.clearSelection(!0)})}initResizeColumn(){this.ctx.on("mousedown",t=>{this.ctx.config.ENABLE_RESIZE_COLUMN&&this.ctx.isTarget(t)&&(this.clientX=t.clientX,this.resizeTarget?(this.isResizing=!0,this.ctx.columnResizing=!0):this.isResizing=!1,this.isMouseDown=!0)}),this.ctx.on("mouseup",()=>{this.ctx.config.ENABLE_RESIZE_COLUMN&&(this.isMouseDown=!1,0!==this.resizeDiff&&this.resizeTarget&&this.resizeColumn(this.resizeTarget,this.resizeDiff),this.resizeTarget=null,this.isResizing=!1,this.isMouseDown=!1,this.ctx.columnResizing=!1,this.clientX=0,this.resizeDiff=0)}),this.ctx.on("mousemove",t=>{if(!this.ctx.config.ENABLE_RESIZE_COLUMN||this.ctx.editing)return;let{stageWidth:e,config:{RESIZE_COLUMN_MIN_WIDTH:i}}=this.ctx;if(this.isResizing&&this.resizeTarget){let e=this.resizeTarget.width,s=this.resizeTarget.minWidth,r=this.resizeTarget.maxWidth,l=t.clientX-this.clientX;l+e<i&&(l=-(e-i)),s&&l+e<s&&(l=-(e-s)),r&&l+e>r&&(l=r-e),this.resizeDiff=l,this.ctx.emit("draw")}else{if(this.resizeTarget=null,this.isMouseDown)return;if(t.offsetX<0||t.offsetX>this.visibleWidth){"col-resize"===this.ctx.stageElement.style.cursor&&(this.ctx.stageElement.style.cursor="default");return}for(let i of("col-resize"===this.ctx.stageElement.style.cursor&&(this.ctx.stageElement.style.cursor="default"),[...this.renderFixedCellHeaders,...this.renderCenterCellHeaders])){let{offsetX:s,offsetY:r}=this.ctx.getOffset(t),l=i.getDrawX(),o=i.getDrawY();if(s>l+i.width-5&&s<l+i.width+4&&s<e-4&&r>o){let e=i.colIndex+i.colspan-1,s=this.leafCellHeaders.find(t=>t.colIndex===e);if(!s||!s.fixed&&this.ctx.stageWidth-this.ctx.fixedRightWidth<l+i.width)return;this.ctx.isTarget(t)&&r<=this.height&&(this.ctx.stageElement.style.cursor="col-resize",this.resizeTarget=s)}}}})}initDragColumn(){this.ctx.on("cellHeaderMousedown",t=>{"default"===this.ctx.stageElement.style.cursor&&this.ctx.config.ENABLE_DRAG_COLUMN&&(t.column.dragDisabled||(this.dragTarget===t?(this.ctx.dragHeaderIng=!0,this.dragCellDiff=this.ctx.mouseX-t.drawX,this.ctx.stageElement.style.cursor="grabbing"):(this.dragTarget=t,this.ctx.dragHeaderIng=!1)))}),this.ctx.on("cellMousedown",()=>{this.ctx.config.ENABLE_DRAG_COLUMN&&(this.dragTarget=null,this.ctx.dragHeaderIng=!1)}),this.ctx.on("mouseup",()=>{if(this.ctx.config.ENABLE_DRAG_COLUMN){if(this.dragingCell&&this.dragTarget){let t=(e,i={})=>(e.forEach((e,s)=>{e.children&&t(e.children,i),i[e.key]=s}),i),e=this.ctx.database.getColumns(),i=c(e,a(e)),s=new j(i,{key:"key",childrenKey:"children"}),r=this.dragTarget.colIndex>this.dragingCell.colIndex?"before":"after";s.treeMove(this.dragTarget.column.key,this.dragingCell.column.key,r);let l=t(s.getTree());this.ctx.database.setCustomHeader({sortData:l}),this.init();let o={source:this.dragTarget,target:this.dragingCell,columns:i};this.ctx.emit("columnDragChange",o)}this.ctx.dragHeaderIng&&this.dragTarget&&("grabbing"===this.ctx.stageElement.style.cursor&&(this.ctx.stageElement.style.cursor="default"),this.ctx.dragHeaderIng=!1,this.dragTarget=null,this.dragingCell=void 0,this.dragCellDiff=0,this.ctx.clearSelector(),this.ctx.focusCellHeader=void 0,this.ctx.emit("draw"))}}),this.ctx.on("mousemove",t=>{this.ctx.config.ENABLE_DRAG_COLUMN&&this.ctx.dragHeaderIng&&this.dragTarget&&(this.dragTarget.fixed||this.ctx.startAdjustPosition(t),this.ctx.emit("draw"))}),this.ctx.on("cellHoverChange",t=>{this.ctx.config.ENABLE_DRAG_COLUMN&&(t.column.dragDisabled||(this.dragingCell=this.getDragCellHeader(t.colIndex)))}),this.ctx.on("cellHeaderHoverChange",t=>{this.ctx.config.ENABLE_DRAG_COLUMN&&(t.column.dragDisabled||(this.dragingCell=this.getDragCellHeader(t.colIndex)))})}getDragCellHeader(t){if(!this.dragTarget||!this.ctx.dragHeaderIng)return;let{column:{parentKey:e},key:i,level:s,fixed:r}=this.dragTarget,l=this.allCellHeaders.find(l=>l.key!==i&&l.fixed===r&&l.column.level===s&&l.column.parentKey===e&&l.colIndex<=t&&l.colIndex+l.colspan-1>=t);return this.ctx.dragHeaderIng&&(this.ctx.stageElement.style.cursor=l?"grabbing":"not-allowed"),l}resizeColumn(t,e){let i=s=>
13{s.forEach(s=>{if(s.children&&s.children.length>0&&i(s.children),s.key===t.key){let t=s.width||100;s.width=t+e}})};i(this.columns);let s=0;this.width<this.visibleWidth&&(s=Math.floor((this.visibleWidth-this.width)/this.resizeNum*100)/100,this.resizeAllColumn(s));let r=t.width+e+s;this.ctx.emit("resizeColumnChange",{colIndex:t.colIndex,key:t.key,oldWidth:t.width,width:r,column:t.column,columns:this.columns}),this.ctx.database.setCustomHeaderResizableData(t.key,r),this.init(!0),this.ctx.emit("draw")}resizeAllColumn(t){if(0===t)return;let e=new Map,i=!0;for(let s of this.allCellHeaders)if(s.widthFillDisable)e.set(s.key,s.width);else{let r=s.width+t*s.colspan;e.set(s.key,r),r<this.ctx.config.RESIZE_COLUMN_MIN_WIDTH&&(i=!1)}if(!i)return;let s=t=>{t.forEach(t=>{e.has(t.key)&&(t.width=e.get(t.key)),t.children&&t.children.length>0&&s(t.children)})};s(this.columns),this.init(!0),this.ctx.emit("draw")}getCustomHeader(){let t=this.ctx.database.getColumns(),e=this.ctx.database.getCustomHeader(),{sortData:i={}}=e;return 0===Object.keys(i).length?{columns:t,customHeader:e}:{columns:c(t,a(t)),customHeader:e}}render(t,e){let i=t.length,s=e,{HEADER_HEIGHT:r=0}=this.ctx.config;for(let e=0;e<i;e++){let i=t[e],l=r*(i.rowspan||0),o=r*(i.level||0),{minWidth:h,maxWidth:n}=i,a=i.width||100;h&&a<h&&(a=h),n&&a>n&&(a=n),i.children&&(a=d(i.children).reduce((t,e)=>t+((null==e?void 0:e.width)||100),0));let c=new U(this.ctx,this.columnIndex,s,o,a,l,i);this.ctx.database.setHeader(i.key,c),this.allCellHeaders.push(c),i.children||(this.leafCellHeaders.push(c),c.column.widthFillDisable||this.resizeNum++),"left"===i.fixed?this.fixedLeftCellHeaders.push(c):"right"===i.fixed?this.fixedRightCellHeaders.push(c):this.centerCellHeaders.push(c),!i.children&&this.columnIndex++,i.children&&this.render(i.children,s),s+=a}}drawTipLine(){if(this.isResizing&&this.resizeTarget){let{stageHeight:t,config:{RESIZE_COLUMN_LINE_COLOR:e,RESIZE_COLUMN_TEXT_COLOR:i,RESIZE_COLUMN_TEXT_BG_COLOR:s,ENABLE_RESIZE_COLUMN_TEXT:r}}=this.ctx,l=this.resizeTarget.getDrawX(),o=this.resizeTarget.width,h=l+o+this.resizeDiff-.5;if(this.ctx.paint.drawLine([h-.5,0,h-.5,t],{borderColor:e}),r){let t=`${Math.floor(o+this.resizeDiff)}px`;this.ctx.paint.drawRect(h+22.5,this.ctx.mouseY-12,45,24,{fillColor:s,borderWidth:0,borderColor:"transparent"}),this.ctx.paint.drawText(t,h+22.5,this.ctx.mouseY-12,45,26,{padding:0,color:i,align:"center",verticalAlign:"middle"})}}}drawDragTip(){if(this.dragTarget&&this.ctx.dragHeaderIng){let{DRAG_TIP_BG_COLOR:t,DRAG_TIP_LINE_COLOR:e}=this.ctx.config,i=this.dragTarget.width;if(this.ctx.paint.drawRect(this.ctx.mouseX-this.dragCellDiff,this.visibleHeight,i,this.ctx.body.visibleHeight,{fillColor:t,borderWidth:0,borderColor:"transparent"}),this.dragingCell){let{drawX:t,drawY:i,visibleWidth:s,colIndex:r}=this.dragingCell,l=t;r>this.dragTarget.colIndex&&(l=t+s),0===r&&(l+=1),r===this.ctx.maxColIndex&&(l-=1);let o=[l,i,l,this.ctx.stageHeight],h=[l-4,i,l+4,i,l,i+6,l-4,i];this.ctx.paint.drawLine(h,{borderColor:e,borderWidth:1.2,fillColor:e}),this.ctx.paint.drawLine(o,{borderColor:e,borderWidth:1.2})}}}drawFixedShadow(){let{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,stageWidth:r,config:{HEADER_BG_COLOR:l,SCROLLER_TRACK_SIZE:o}}=this.ctx;if(i>0&&0!==t&&this.ctx.paint.drawShadow(this.x,this.y,t,this.height,{fillColor:l,side:"right",shadowWidth:4,colorStart:"rgba(0,0,0,0.1)",colorEnd:"rgba(0,0,0,0)"}),i<Math.floor(s.width-r-1)&&e!==o){let t=s.width-(this.x+this.width)+r-e;this.ctx.paint.drawShadow(t,this.y,e,this.height,{fillColor:l,side:"left",shadowWidth:4,colorStart:"rgba(0,0,0,0)",colorEnd:"rgba(0,0,0,0.1)"})}}update(){let t=[],e=[],i=[];if(this.centerCellHeaders.length){let t=this.centerCellHeaders[this.centerCellHeaders.length-1];this.ctx.lastCenterColIndex=t.colIndex}this.centerCellHeaders.forEach(i=>{i.isHorizontalVisible()&&i.isVerticalVisible()&&(e.push(i),i.hasChildren||t.push(i))}),this.fixedLeftCellHeaders.forEach(e=>{i.push(e),e.hasChildren||t.push(e)}),this.fixedRightCellHeaders.forEach(e=>{i.push(e),e.hasChildren||t.push(e)}),this.renderCenterCellHeaders=e,this.renderFixedCellHeaders=i,this.renderLeafCellHeaders=t.sort((t,e)=>t.x-e.x),this.visibleLeafColumns=this.renderLeafCellHeaders.map(t=>t.column),this.ctx.header.visibleLeafColumns=this.visibleLeafColumns,this.ctx.header.leaf
13CellHeaders=this.leafCellHeaders,this.ctx.header.renderLeafCellHeaders=this.renderLeafCellHeaders,this.ctx.header.renderCellHeaders=this.renderFixedCellHeaders.concat(this.renderCenterCellHeaders)}drawBottomLine(){let{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.drawBottomLine(),this.drawTipLine(),this.drawDragTip()}}class q{constructor(t,e,i=0,s=0,r=0,o=0,h,n="body"){l(this,"ctx"),l(this,"x",0),l(this,"y",0),l(this,"width",0),l(this,"height"),l(this,"cells",[]),l(this,"fixedCells",[]),l(this,"noFixedCells",[]),l(this,"calculatedHeightCells",[]),l(this,"rowIndex",0),l(this,"rowKey",""),l(this,"rowType","body"),l(this,"data"),l(this,"calculatedHeight",-1),this.ctx=t,this.x=i,this.y=s,this.width=r,this.height=o,this.rowIndex=e,this.rowKey=t.database.getRowKeyForRowIndex(e)||"",this.rowType=n,this.data=h,this.update()}update(){let{header:t}=this.ctx,e=[],i=[],s=[],r=[];t.renderLeafCellHeaders.forEach(t=>{let l=new v(this.ctx,this.rowIndex,t.colIndex,t.x,this.y,t.width,this.height,t.column,this.data,this.rowType);l.fixed?i.push(l):s.push(l),e.push(l),l.autoRowHeight&&r.push(l)}),this.cells=e,this.calculatedHeightCells=r,this.fixedCells=i,this.noFixedCells=s}updateCalculatedHeight(){let t=this.calculatedHeightCells.map(t=>{let e=t.getAutoHeight(),{key:i,height:s=-1}=this.ctx.database.getMaxRowHeightItem(this.rowKey)||{};return e>s?this.ctx.database.setMaxRowHeightItem(this.rowKey,t.key,e):t.key===i&&e<s&&this.ctx.database.setMaxRowHeightItem(this.rowKey,t.key,e),e});return this.calculatedHeight=t.length?Math.max(...t):-1,this.calculatedHeight}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 J{constructor(t){l(this,"resizeTarget",null),l(this,"dragSource",null),l(this,"dragTarget",null),l(this,"dragRowDiff",0),l(this,"dragPosition","none"),l(this,"isMouseDown",!1),l(this,"resizeDiff",0),l(this,"clientY",0),l(this,"ctx"),l(this,"x",0),l(this,"y",0),l(this,"width",0),l(this,"height",0),l(this,"headIndex",0),l(this,"tailIndex",0),l(this,"isResizing",!1),l(this,"renderRows",[]),l(this,"visibleRows",[]),l(this,"visibleHeight",0),l(this,"visibleWidth",0),l(this,"containerRect"),l(this,"data",[]),this.ctx=t,this.init(),this.initTree(),this.initSelection(),this.initResizeRow(),this.initDragRow()}init(){let{canvasElement:t,header:e,footer:i,database:s,config:{FOOTER_FIXED:r,SCROLLER_TRACK_SIZE:l=0,HEIGHT:o,EMPTY_BODY_HEIGHT:h=0,MAX_HEIGHT:n=0,ENABLE_OFFSET_HEIGHT:a=0,OFFSET_HEIGHT:c=0,FOOTER_POSITION:d}}=this.ctx;if(!e.width)return;this.x=0,"top"===d&&r?this.y=e.height+i.height:this.y=e.height;let{data:x,sumHeight:u}=s.getData();this.height=u,this.data=x,this.width=e.width,this.visibleWidth=this.ctx.stageWidth-l;let g=this.ctx.footer.height;this.ctx.isEmpty=!this.data.length,this.data.length||o?!this.data.length&&o&&(this.height=o-e.height-g-l):this.height=h;let f=this.height+e.height+l,m=f+=g,p=window.innerHeight,{top:w}=this.containerRect||this.ctx.containerElement.getBoundingClientRect();if(p>w&&a&&!o){let t=p-w-c;t>e.height+l?m=t:f>n&&(m=n)}else this.data.length&&o?m=o:this.data.length&&n&&f>n&&(m=n);m>0&&(this.ctx.stageHeight=Math.floor(m),this.ctx.stageElement.style.height=`${this.ctx.stageHeight}px`);let E=this.ctx.stageHeight-e.height-l;r?this.visibleHeight=E-g:this.visibleHeight=E,this.data.length||(this.height=this.visibleHeight),this.ctx.body.x=this.x,this.ctx.body.y=this.y,this.ctx.body.width=this.width,this.ctx.body.height=this.height,this.ctx.body.visibleWidth=this.visibleWidth,this.ctx.body.visibleHeight=this.visibleHeight,this.ctx.body.data=x;let y=window.devicePixelRatio||1,b=this.ctx.stageWidth*y,v=this.ctx.stageHeight*y;t.width=Math.round(b),t.height=Math.round(v);let C=this.data.length?"not-empty":"empty";this.ctx.emit("emptyChange",{isEmpty:C,type:C,headerHeight:e.height,bodyHeight:this.height,footerHeight:g,width:this.width,height:this.data.length?0:h+g});let R=Math.round(t.width/y*1e4)/1e4,I=Math.round(t.height/y*1e4)/1e4;this.ctx.canvasElement.setAttribute("style",`height:${I}px;width:${R}px;`),this.ctx.paint.scale(y)}initTree(){this.ctx.on("cellClick",(t,e)=>{if("pointer"!==this.ctx.stageElement.style.cursor||!t.isImageInside("tree",e))return;let{expand:i=!1,expandLazy:s=!1}
13=this.ctx.database.getRowForRowKey(t.rowKey)||{},{EXPAND_LAZY:r,EXPAND_LAZY_METHOD:l}=this.ctx.config;if(r&&l&&!i&&!s)"function"==typeof l&&(this.ctx.database.expandLoading(t.rowKey,!0),l({row:t.row,rowIndex:t.rowIndex,colIndex:t.colIndex,column:t.column,value:t.getValue()}).then(e=>{this.ctx.database.setExpandChildren(t.rowKey,e),this.ctx.database.expandLoading(t.rowKey,!1),this.ctx.emit("expandChange",this.ctx.database.getExpandRowKeys())}).catch(e=>{this.ctx.database.expandLoading(t.rowKey,!1),console.error(e)}));else{let e=this.ctx.database.getIsExpand(t.rowKey);this.ctx.database.expandItem(t.rowKey,!e),this.ctx.emit("expandChange",this.ctx.database.getExpandRowKeys())}})}initSelection(){this.ctx.on("cellClick",(t,e)=>{"pointer"===this.ctx.stageElement.style.cursor&&t.isImageInside("selection",e)&&this.ctx.database.getRowSelectable(t.rowKey)&&this.ctx.database.toggleRowSelection(t.rowKey,t.type)})}initResizeRow(){this.ctx.on("resize",()=>{this.ctx.config.ENABLE_RESIZE_ROW&&(this.containerRect=this.ctx.containerElement.getBoundingClientRect())}),this.ctx.on("resizeObserver",()=>{this.ctx.config.ENABLE_RESIZE_ROW&&(this.containerRect=this.ctx.containerElement.getBoundingClientRect())}),this.ctx.on("mouseup",()=>{this.ctx.config.ENABLE_RESIZE_ROW&&(this.isMouseDown=!1,0!==this.resizeDiff&&this.resizeTarget&&this.resizeRow(this.resizeTarget,this.resizeDiff),this.resizeTarget=null,this.resizeDiff=0,this.isResizing=!1,setTimeout(()=>{this.ctx.rowResizing=!1},0),this.clientY=0)}),this.ctx.on("mousedown",t=>{this.ctx.config.ENABLE_RESIZE_ROW&&this.ctx.isTarget(t)&&(this.clientY=t.clientY,this.resizeTarget?(this.isResizing=!0,this.ctx.rowResizing=!0):(this.isResizing=!1,this.ctx.rowResizing=!1),this.isMouseDown=!0)}),this.ctx.on("mousemove",t=>{if(!this.ctx.config.ENABLE_RESIZE_ROW||this.ctx.editing)return;let{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=t.clientY,{stageHeight:r,scrollY:l,config:{RESIZE_ROW_MIN_HEIGHT:o=0}}=this.ctx;if(this.isResizing&&this.resizeTarget){let t=this.resizeTarget.height,e=s-this.clientY,{calculatedHeight:i}=this.resizeTarget,r=-1===i?o:i;e+t<r&&(e=-(t-r)),this.resizeDiff=e,this.ctx.emit("draw")}else{if(this.resizeTarget=null,this.isMouseDown)return;if(i<0||i>this.ctx.body.visibleWidth||e<0||e>this.ctx.header.visibleHeight+this.ctx.body.visibleHeight){"row-resize"===this.ctx.stageElement.style.cursor&&(this.ctx.stageElement.style.cursor="default");return}if("crosshair"===this.ctx.stageElement.style.cursor)return;"row-resize"===this.ctx.stageElement.style.cursor&&(this.ctx.stageElement.style.cursor="default");for(let t=0;t<this.renderRows.length;t++){let s=this.renderRows[t];if(e>s.y-l+s.height-1.5&&e<s.y-l+s.height+1.5&&e<r-4)for(let t=0;t<s.cells.length;t++){let e=s.cells[t];i>e.drawX+10&&i<e.drawX+e.width-10&&1===e.rowspan&&(this.ctx.stageElement.style.cursor="row-resize",this.resizeTarget=s)}}}})}initDragRow(){this.ctx.on("cellMousedown",(t,e)=>{this.ctx.config.ENABLE_DRAG_ROW&&t.isImageInside("drag",e)&&(this.dragSource=t,this.ctx.database.expandItem(t.rowKey,!1),this.ctx.dragRowIng=!0,this.dragRowDiff=this.ctx.mouseY-t.drawY,this.ctx.stageElement.style.cursor="grabbing",this.ctx.clearSelector(),this.ctx.emit("dragRowMouseDown",t),this.ctx.emit("draw"))}),this.ctx.on("mouseup",async()=>{if(this.ctx.dragRowIng){if(this.dragSource&&this.dragTarget&&"not-allowed"!==this.ctx.stageElement.style.cursor){let t=this.dragSource,e=this.dragTarget,i={source:t,target:e,position:this.dragPosition};this.ctx.emit("dragRowChange",i);let s=!0,{BEFORE_DRAG_ROW_METHOD:r}=this.ctx.config;if("function"==typeof r&&(s=await r(i)),s&&!this.ctx.config.ENABLE_DRAG_ROW_CUSTOM){let i=this.ctx.database.getOriginalData(),{TREE_CHILDREN_KEY:s,ROW_KEY:r}=this.ctx.config,l=new j(i,{key:r,childrenKey:s});l.treeMove(t.rowKey,e.rowKey,this.dragPosition),this.ctx.emit("loadData",l.getTree())}}this.dragTarget||(this.ctx.stageElement.style.cursor="grab"),this.ctx.dragRowIng=!1,this.dragSource=null,this.dragTarget=null,this.dragPosition="after",this.dragRowDiff=0,this.ctx.emit("draw")}}),this.ctx.on("mousemove",t=>{if(!this.ctx.dragRowIng)return;let{offsetY:e}=this.ctx.getOffset(t),{drawY:i}=this.dragTarget;i<e||i>e?this.ctx.startAdjustPosition(t):this.ctx.stopAdjustPosition()}),this.ctx.on("cellMouseenter",t=>{if(!this.ctx.dragRowIng)return;this.dragTarget=t;let{ENABLE_DRAG_ROW_CROSS_LEVEL:e}=this.ctx.config,i=this.dragSource,s=this.dragTarget;if(!e&&i&&s&&i.parentRowKey!==s.parentRowKey){this.ctx.stageElement.style.cursor="not-allowed";return}this.ctx.stageElement.style.cursor="grabbing",this.dragTarget=t;let{drawY:r,visibleHeight:l}=t,o=e?l/3:l/2;this.ctx.mouseY<=r+o?this.dragPosition="before":this.ctx.mouseY>r+l-o?this.dragPosition="after":this.dragPosition="inside";let h={dragSource:this.dragSource,dragTarget:this.dragTarget,dragPosition:this.dragPosition};this.ctx.emit("dragRowMove",h),this.ctx.emit("draw")})}resizeRow(t,e){let{rowIndex:i,height:s,rowKey:r,data:l}=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:r,row:l,data:this.data})}drawTipLine(){if(this.isResizing&&this.resizeTarget){let{stageWidth:t,scrollY:e,config:{RESIZE_ROW_LINE_COLOR:i}}=this.ctx,s=this.resizeTarget.y-e+this.resizeTarget.height+this.resizeDiff-.5;this.ctx.paint.drawLine([0,s-.5,t,s-.5],{borderColor:i,borderWidth:1})}}drawDragRowTip(){if(this.ctx.dragRowIng&&this.dragTarget&&this.dragSource){let{stageWidth:t,config:{DRAG_ROW_TIP_LINE_COLOR:e,DRAG_TIP_BG_COLOR:i}}=this.ctx,s=this.dragSource.visibleHeight;this.ctx.paint.drawRect(0,this.ctx.mouseY-this.dragRowDiff,this.visibleWidth,s,{fillColor:i,borderWidth:0,borderColor:"transparent"});let r=this.dragTarget.drawY,l=this.dragTarget.height,o=r;if(["before","after"].includes(this.dragPosition)){"after"===this.dragPosition&&(o=r+l);let i=[0,o-.5,t,o-.5];this.ctx.paint.drawLine(i,{borderColor:e,borderWidth:1.2})}["inside"].includes(this.dragPosition)&&(o=r+l/2);let h=[0,o-4,6,o,0,o+4,0,o-4];
13this.ctx.paint.drawLine(h,{borderColor:e,borderWidth:1.2,fillColor:e})}}drawFixedShadow(){let{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,stageWidth:r,config:{HEADER_BG_COLOR:l,SCROLLER_TRACK_SIZE:o}}=this.ctx;if(i>0&&0!==t&&!this.ctx.isEmpty&&this.ctx.paint.drawShadow(this.x,this.y,t,this.height,{fillColor:l,side:"right",shadowWidth:4,colorStart:"rgba(0,0,0,0.1)",colorEnd:"rgba(0,0,0,0)"}),i<Math.floor(s.width-r-1)&&e!==o&&!this.ctx.isEmpty){let t=s.width-(this.x+this.width)+r-e;this.ctx.paint.drawShadow(t,this.y,e,this.height,{fillColor:l,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,r=-1;for(;i<=s;){let l=Math.floor((i+s)/2),o=t[l].bottom;if(o===e)return l;o<e?i=l+1:(r=l,s=l-1)}return r}update(){this.init();let{header:t,database:e,scrollY:i,config:{CELL_HEIGHT:s}}=this.ctx,{data:r,positions:l}=e.getData();this.ctx.maxRowIndex=r.length-1;let o=this.binarySearch(l,i),h=this.binarySearch(l,i+this.visibleHeight);if(-1===h&&(h=this.ctx.maxRowIndex),-1===o&&h===this.ctx.maxRowIndex){let t=Math.floor(this.visibleHeight/s);o=this.ctx.maxRowIndex-t}this.headIndex=Math.max(0,o),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;let n=[];for(let e=0;e<this.visibleRows.length;e++){let i=this.headIndex+e,s=this.visibleRows[e],{height:r,top:l}=this.ctx.database.getPositionForRowIndex(i),o=new q(this.ctx,i,0,l+this.y,t.width,r,s);n.push(o)}this.renderRows=n,this.ctx.body.renderRows=n}updateAutoHeight(){let t=this.ctx.body.renderRows;if(!t.some(t=>t.calculatedHeightCells.length>0))return!1;t.forEach(t=>{t.updateCalculatedHeight()});let e=t.map(t=>({height:t.calculatedHeight,rowIndex:t.rowIndex}));return this.ctx.database.setBatchCalculatedRowHeight(e)}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 Q{constructor(t){l(this,"ctx"),l(this,"renderRows",[]),l(this,"data",[]),l(this,"x",0),l(this,"y",0),l(this,"width",0),l(this,"height",0),l(this,"visibleWidth",0),l(this,"visibleHeight",0),this.ctx=t,this.init()}init(){this.data=this.ctx.database.getFooterData();let{header:t,body:e,config:{CELL_FOOTER_HEIGHT:i,FOOTER_FIXED:s,SCROLLER_TRACK_SIZE:r,FOOTER_POSITION:l}}=this.ctx;this.width=t.width,this.visibleWidth=t.visibleWidth,this.height=this.data.reduce(t=>t+i,0),this.visibleHeight=this.height,s?"top"===l?this.y=this.ctx.header.height:this.y=this.ctx.stageHeight-this.height-r: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(){let{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,stageWidth:r,config:{HEADER_BG_COLOR:l,SCROLLER_TRACK_SIZE:o}}=this.ctx,h=this.y;if(this.ctx.config.FOOTER_FIXED||(h=this.y-this.ctx.scrollY),i>0&&0!==t&&this.ctx.paint.drawShadow(this.x,h,t,this.height,{fillColor:l,side:"right",shadowWidth:4,colorStart:"rgba(0,0,0,0.1)",colorEnd:"rgba(0,0,0,0)"}),i<Math.floor(s.width-r-1)&&e!==o){let t=s.width-(this.x+this.width)+r-e;this.ctx.paint.drawShadow(t,h,e,this.height,{fillColor:l,side:"left",shadowWidth:4,colorStart:"rgba(0,0,0,0)",colorEnd:"rgba(0,0,0,0.1)"})}}update(){this.init();let{CELL_FOOTER_HEIGHT:t}=this.ctx.config,e=this.y,i=[];this.data.forEach((s,r)=>{let l=new q(this.ctx,r,0,e,this.width,t,s,"footer");e+=t,i.push(l)}),this.renderRows=i,this.ctx.footer.renderRows=this.renderRows}drawTopLine(){let{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 tt{constructor(t){l(this,"isCut",!1),l(this,"isMultipleRow",!1),l(this,"ctx"),this.ctx=t,this.init()}init(){this.ctx.on("setMoveFocus",t=>{this.moveFocus(t)}),this.ctx.on("mousemove",n(t=>{var e;null!=(e=this.ctx.focusCellHeader)&&e.fixed||!this.ctx.dragHeaderIng&&this.ctx.selectorMove&&this.ctx.startAdjustPosition(t)},100)),this.ctx.on("cellHoverChange",t=>{if(!this.ctx.autofillMove){if(t.operation)return void this.selectRows(t,!1);this.isMultipleRow||this.mouseenter()}}),this.ctx.on("cellClick",()=>{this.adjustBoundaryPosition()}),this.ctx.on("cellMousedown",(t,e)=>{if(this.ctx.isTarget(e)&&"pointer"!==this.ctx.stageElement.style.cursor&&"crosshair"!==this.ctx.stageElement.style.cursor){if(t.operation){this.isMultipleRow=!0,this.selectRows(t);return}"text"!==window.getComputedStyle(e.target).userSelect&&e.preventDefault(),this.isMultipleRow=!1,this.click(e.shiftKey),this.ctx.emit("selectorClick",t)}}),this.ctx.on("mouseup",()=>{this.ctx.selectorMove=!1,this.ctx.stopAdjustPosition(),setTimeout(()=>{this.ctx.disableHoverIconClick=!1},0)}),this.ctx.on("cellHeaderHoverChange",t=>{this.ctx.textSelecting||this.ctx.mousedown&&this.selectCols(t)}),this.ctx.on("cellHoverChange",t=>{this.ctx.textSelecting||this.ctx.mousedown&&this.selectCols(t)}),this.ctx.on("cellHeaderMousedown",(t,e)=>{"pointer"!==this.ctx.stageElement.style.cursor&&("text"!==window.getComputedStyle(e.target).userSelect&&e.preventDefault(),this.ctx.clearSelector(),t.operation?this.selectAll():this.selectCols(t))}),this.ctx.on("keydown",t=>{if(!this.ctx.editing&&!this.ctx.finding){if(t.ctrlKey&&"KeyV"===t.code||t.metaKey&&"KeyV"===t.code)return void this.paste();if(t.ctrlKey&&"KeyC"===t.code||t.metaKey&&"KeyC"===t.code){this.copy(),this.isCut=!1;return}if(t.ctrlKey&&"KeyX"===t.code||t.metaKey&&"KeyX"===t.code){this.isCut=!0,this.copy();return}if((t.ctrlKey&&"KeyA"===t.code||t.metaKey&&"KeyA"===t.code)&&(t.preventDefault(),this.selectAll()),"ArrowLeft"===t.code||t.shiftKey&&"Tab"===t.code){t.preventDefault(),this.moveFocus("LEFT");return}if("ArrowUp"===t.code){t.preventDefault(),this.moveFocus("TOP");return}if("ArrowRight"===t.code||"Tab"===t.code){t.preventDefault(),this.moveFocus("RIGHT");return}if("ArrowDown"===t.code){t.preventDefault(),this.moveFocus("BOTTOM");return}if("Delete"===t.code||"Backspace"===t.code){t.preventDefault();let{xArr:e,yArr:i}=this.ctx.selector;this.clearSelectedData(e,i);return}}}),this.ctx.on("contextMenuClearSelected",()=>{let{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.adjustBoundaryPosition()}),this.ctx.on("selectCols",t=>{this.selectCols(t)})}setSelector(t,e){if(this.ctx.dragHeaderIng||this.ctx.dragRowIng)return;let{ENABLE_SELECTOR_SPAN_COL:i,ENABLE_SELECTOR_SPAN_ROW:s}=this.ctx.config,r=t,l=e;if(!s){let[t]=l;l=[t,t]}if(!i){let[t]=r;r=[t,t]}if(JSON.stringify(this.ctx.selector.xArr)!==JSON.stringify(r)||JSON.stringify(this.ctx.selector.yArr)!==JSON.stringify(l)){this.ctx.mousedown&&(this.ctx.selectorMove=!0,this.ctx.disableHoverIconClick=!0),this.ctx.selector.enable=!0;let{SELECTOR_AREA_MIN_X:t,SELECTOR_AREA_MAX_X:e,SELECTOR_AREA_MIN_Y:i,SELECTOR_AREA_MAX_Y:s,SELECTOR_AREA_MAX_X_OFFSET:o,SELECTOR_AREA_MAX_Y_OFFSET:h}=this.ctx.config,n=e||this.ctx.maxColIndex-o,a=s||this.ctx.maxRowIndex-h,[c,d]=r,[x,u]=l;if(c<t||d>n||x<i||u>a)return;if(this.ctx.config.ENABLE_MERGE_CELL_LINK){let t=this.adjustMergeCells(r,l);x=t.yArr[0],u=t.yArr[1],c=t.xArr[0],d=t.xArr[1],this.ctx.onlyMergeCell=t.onlyMergeCell}c===d&&x===u?this.ctx.selectOnlyOne=!0:this.ctx.selectOnlyOne=!1,r=[Math.max(t,c),Math.min(n,d)],l=[Math.max(i,x),Math.min(a,u)];let{BEFORE_SET_SELECTOR_METHOD:g}=this.ctx.config;if("function"==typeof g){let t=g({focusCell:this.ctx.focusCell,xArr:r,yArr:l});if(!t)return;r=t.xArr,l=t.yArr}this.ctx.selector.xArr=r,this.ctx.selector.yArr=l,u===this.ctx.maxRowIndex&&0===x?this.ctx.selectColsIng=!0:this.ctx.selectColsIng=!1,d===this.ctx.maxColIndex&&0===c?this.ctx.selectRowsIng=!0:this.ctx.selectRowsIng=!1,this.ctx.emit("setSelector",this.ctx.selector),this.ctx.emit("drawView")}}adjustMergeCells(t,e){var i;let[s,r]=e,[l,o]=t;if(r===this.ctx.maxRowIndex&&0===s||o===this.ctx.maxColIndex&&0===l)return{xArr:t,yArr:e,onlyMergeCell:!1};let h=[],n=[];for(let i=0;i<=e[1]-e[0];i++)for(let a=0;a<=t[1]-t[0];a++){let c=i+e[0],d=a+t[0],x=this.ctx.database.getVirtualBodyCell(c,d);x&&((c===s||c===r)&&h.push(x),(d===l||d===o)&&n.push(x))}let a=h.reduce((t,e)=>{let{yArr:i}=e.getSpanInfo(),[s,r]=i;return t.minY=Math.min(t.minY,s),t.maxY=Math.max(t.maxY,r),t},{minY:s,maxY:r}),c=n.reduce((t,e)=>{let{xArr:i}=e.getSpanInfo(),[s,r]=i;return t.minX=Math.min(t.minX,s),t.maxX=Math.max(t.maxX,r),t},{minX:l,maxX:o}),d=[c.minX,c.maxX],x=[a.minY,a.maxY],u=!1;if(c.minX!==c.maxX||a.minY!==a.maxY){let t=JSON.stringify(d)+JSON.stringify(x),e=null==(i=this.ctx.focusCell)?void 0:i.getSpanInfo();u=(e&&JSON.stringify(e.xArr)+JSON.stringify(e.yArr))===t}return{xArr:d,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;let{SELECTOR_AREA_MIN_Y:e,SELECTOR_AREA_MAX_Y:i,SELECTOR_AREA_MAX_Y_OFFSET:s}=this.ctx.config,r=i||this.ctx.maxRowIndex-s;
13if(this.ctx.focusCellHeader){let{colIndex:i}=this.ctx.focusCellHeader;if(this.ctx.clearSelector(),this.ctx.mousedown&&t.colIndex>=i){let s=[i,t.colIndex+t.colspan-1];this.setSelector(s,[e,r])}else{let s=[t.colIndex,i+t.colspan-1];this.setSelector(s,[e,r])}}}selectAll(){if(this.ctx.autofillMove||this.ctx.editing)return;let{ENABLE_SELECTOR_ALL_ROWS:t,ENABLE_SELECTOR_ALL_COLS:e}=this.ctx.config;if(t&&e){let{SELECTOR_AREA_MIN_X:t,SELECTOR_AREA_MAX_X:e,SELECTOR_AREA_MIN_Y:i,SELECTOR_AREA_MAX_Y:s,SELECTOR_AREA_MAX_X_OFFSET:r,SELECTOR_AREA_MAX_Y_OFFSET:l}=this.ctx.config,o=e||this.ctx.maxColIndex-r,h=s||this.ctx.maxRowIndex-l;this.setSelector([t,o],[i,h])}}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;let{SELECTOR_AREA_MIN_X:i,SELECTOR_AREA_MAX_X:s,SELECTOR_AREA_MAX_X_OFFSET:r}=this.ctx.config,l=s||this.ctx.maxColIndex-r;if(e){this.ctx.setFocusCell(t);let e=[t.rowIndex,t.rowIndex];this.setSelector([i,l],e)}if(this.ctx.focusCell&&this.ctx.mousedown){let{rowIndex:e}=this.ctx.focusCell;if(t.rowIndex>=e){let s=[e,t.rowIndex];this.setSelector([i,l],s)}else{let s=[t.rowIndex,e];this.setSelector([i,l],s)}}}mouseenter(){if(this.ctx.config.ENABLE_SELECTOR_SINGLE||this.ctx.editing)return;let{mousedown:t,focusCell:e,hoverCell:i}=this.ctx;if(t&&e&&i){let{rowIndex:t,colIndex:s}=e,r=Math.min(i.colIndex,s),l=Math.max(i.colIndex,s),o=Math.min(i.rowIndex,t),h=Math.max(i.rowIndex,t);this.setSelector([r,l],[o,h])}}click(t=!1){let{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;let{colIndex:t,rowIndex:s}=i,{colIndex:r,rowIndex:l}=e,o=Math.min(r,t),h=Math.max(r,t),n=Math.min(l,s),a=Math.max(l,s);this.setSelector([o,h],[n,a])}else{this.ctx.emit("cellSelectedClick",e);let t=[e.colIndex,e.colIndex],i=[e.rowIndex,e.rowIndex];this.setSelector(t,i)}}clearCopyLine(){this.ctx.selector.xArrCopy=[-1,-1],this.ctx.selector.yArrCopy=[-1,-1]}getCell(t,e){let i=this.ctx.body.renderRows.find(e=>e.rowIndex===t);return null==i?void 0:i.cells.find(t=>t.colIndex===e)}copy(){if(!this.ctx.config.ENABLE_COPY||this.ctx.domSelectionStr||this.ctx.textSelectionStr)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){let s=this.ctx.focusCell;t=[[s.getValue()]],e=[s.colIndex,s.colIndex],i=[s.rowIndex,s.rowIndex]}else{let t={code:"ERR_MERGED_CELLS_COPY",message:this.ctx.locale.getText("mergeCellNoCopy")};this.ctx.hasEvent("error")?this.ctx.emit("error",t):console.error(t.message);return}let{BEFORE_COPY_METHOD:s}=this.ctx.config;if("function"==typeof s){let r=s({focusCell:this.ctx.focusCell,data:t,xArr:e,yArr:i});if(!r)return;t=r.data}let r=function(t){let e,i,s,r,l="",o;for(e=0,i=t.length;e<i;e+=1){for(r=t[e].length,s=0;s<r;s+=1)s>0&&(l+="	"),"string"==typeof(o=t[e][s])?o.indexOf(`
14`)>-1?l+=`"${o.replace(/"/g,'""')}"`:l+=o:null==o?l+="":l+=o;e!==i-1&&(l+=`
15`)}return l}(t);navigator.clipboard?navigator.clipboard.writeText(r).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(t=>console.error("Copy Failure:",t)):console.error("current browser does not support the Clipboard API")}clearSelectedData(t,e,i=!1,s=null){let r=[],l=new Set;for(let i=0;i<=e[1]-e[0];i++)for(let o=0;o<=t[1]-t[0];o++){let h=i+e[0],n=o+t[0],a=this.ctx.database.getItemValueForRowIndexAndColIndex(h,n);if(a){let{rowKey:t,key:e}=a;this.ctx.database.getReadonly(t,e)||(l.add(t),r.push({rowKey:t,key:e,value:s,row:{}}))}}if(!r.length)return[];if(i)return r;this.ctx.database.batchSetItemValue(r,!0);let o=[];return l.forEach(t=>{o.push(this.ctx.database.getRowDataItemForRowKey(t))}),this.ctx.emit("clearSelectedDataChange",r,o),r}paste(){if(!navigator.clipboard)return void console.error("current browser does not support the Clipboard API");let{ENABLE_PASTER:t}=this.ctx.config;if(this.ctx.selector.enable&&t){let t=this.ctx.selector.yArr[0],e=this.ctx.selector.xArr[0],i=new Set;navigator.clipboard.readText().then(async s=>{let r=function(t){let e=[[""]];if(0===t.length)return e;let i=0,s=0,r;for(;t.length>0&&r!==t.length;)if(r=t.length,t.match(g))t=t.replace(g,""),i+=1,e[s][i]="";else if(t.match(x))t=t.replace(x,""),i=0,e[s+=1]=[""];else{let r="";if(t.startsWith('"')){let e=0,i=!0;for(;i;){let s=t.slice(0,1);'"'===s&&(e+=1),r+=s,(0===(t=t.slice(1)).length||t.match(/^[\t\r\n]/)&&e%2==0)&&(i=!1)}r=r.replace(/^"/,"").replace(/"$/,"").replace(/["]*/g,t=>Array(Math.floor(t.length/2)).fill('"').join(""))}else{let e=t.match(u);r=e?e[0]:"",t=t.slice(r.length)}e[s][i]=r}return Array.isArray(e)&&e.length>1&&1===e[e.length-1].length&&""===e[e.length-1][0]&&(e=e.slice(0,e.length-1)),e}(s),l=[e,e+r[0].length-1],o=[t,t+r.length-1],[h,n]=o,[a,c]=l,d=n-this.ctx.maxRowIndex,f=c-this.ctx.maxColIndex;(d>0||f>0)&&this.ctx.emit("onPastedDataOverflow",{maxY:n,maxX:c,minY:h,minX:a,overflowRowCount:d,overflowColCount:f,textArr:r});let m=1===r.length&&1===r[0].length;if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.database.hasMergeCell(l,o)&&!m){let t={code:"ERR_MERGED_CELLS_PASTE",message:this.ctx.locale.getText("mergeCellNoPaste"),data:[]};this.ctx.hasEvent("error")?this.ctx.emit("error",t):console.error(t.message);return}let p=[];for(let s=0;s<=r.length-1;s++){let l=r[s].length;for(let o=0;o<=l-1;
15o++){let l=s+t,h=o+e,n=r[s][o],a=this.ctx.database.getItemValueForRowIndexAndColIndex(l,h);if(a){let{rowKey:t,key:e}=a;this.ctx.database.getReadonly(t,e)||(i.add(t),p.push({rowKey:t,key:e,value:n,row:{}}))}}}if(this.isCut){let t=this.clearSelectedData(this.ctx.selector.xArrCopy,this.ctx.selector.yArrCopy,!0),e=p.map(t=>`${t.rowKey}-${t.key}`);t.forEach(t=>{e.includes(`${t.rowKey}-${t.key}`)||p.unshift(t)}),this.isCut=!1}if(!p.length)return;let{BEFORE_PASTE_DATA_METHOD:w}=this.ctx.config;if("function"==typeof w){let t=p.map(t=>({rowKey:t.rowKey,key:t.key,value:t.value,oldValue:this.ctx.database.getItemValue(t.rowKey,t.key),row:this.ctx.database.getRowDataItemForRowKey(t.rowKey)}));if((p=await w(t,l,o,r))&&!p.length)return}this.clearCopyLine(),this.ctx.batchSetItemValueByEditor(p,!0);let E=[];i.forEach(t=>{E.push(this.ctx.database.getRowDataItemForRowKey(t))}),this.ctx.emit("pasteChange",p,E),this.ctx.emit("draw")}).catch(t=>{console.error("Failed to get the clipboard content:",t)})}}moveFocus(t){if(this.ctx.editing)return;let{focusCell:e}=this.ctx;if(!e)return;let{colIndex:i=0,rowIndex:s=0}=e,r=this.ctx.maxColIndex,l=this.ctx.maxRowIndex;switch(t){case"LEFT":i>0&&i--;break;case"TOP":s>0&&s--;break;case"RIGHT":i<r&&i++;break;case"BOTTOM":s<l&&s++}let o=[i,i],h=[s,s],n=this.getCell(s,i);n&&(n.operation||this.isInSettingRange(n.rowIndex,n.colIndex)&&(this.ctx.setFocusCell(n),this.setSelector(o,h),this.adjustBoundaryPosition(),this.ctx.emit("moveFocus",n),this.ctx.emit("draw")))}isInSettingRange(t,e){let{SELECTOR_AREA_MIN_X:i,SELECTOR_AREA_MAX_X:s,SELECTOR_AREA_MIN_Y:r,SELECTOR_AREA_MAX_Y:l,SELECTOR_AREA_MAX_X_OFFSET:o,SELECTOR_AREA_MAX_Y_OFFSET:h}=this.ctx.config,n=s||this.ctx.maxColIndex-o,a=l||this.ctx.maxRowIndex-h;return!(e<i||e>n||t<r||t>a)}adjustBoundaryPosition(){let{stageHeight:t,stageWidth:e,focusCell:i,fixedRightWidth:s,fixedLeftWidth:r,header:l,footer:o,body:h,scrollX:n,scrollY:a,config:{SCROLLER_TRACK_SIZE:c,FOOTER_FIXED:d,FOOTER_POSITION:x,ENABLE_MERGE_CELL_LINK:u}}=this.ctx;if(!i)return;u&&this.ctx.onlyMergeCell&&i.updateSpanInfo();let{drawX:g,drawY:f,width:m,height:p,fixed:w}=i,E=r-g+1,y=i.drawX+m-(e-s)+1,b=l.height-f,v=p;v>h.visibleHeight&&(v=h.visibleHeight);let C=0;d&&("top"===x?b=l.height+o.height-f:C=o.visibleHeight);let R=f+v-(t-C-c),I=n,_=a;y>0&&!w?I=Math.floor(n+y):E>0&&!w&&(I=Math.floor(n-E)),b>0?_=Math.floor(a-b):R>0&&(_=Math.floor(a+R)),(Math.abs(n-I)>2.5||Math.abs(a-_)>2.5)&&this.ctx.setScroll(I,_)}destroy(){}}class te{constructor(t){l(this,"ctx"),l(this,"maxColRowCell"),this.ctx=t,this.init()}init(){this.ctx.on("mousemove",t=>{if("crosshair"===this.ctx.stageElement.style.cursor&&(this.ctx.stageElement.style.cursor="default"),this.ctx.editing||!this.ctx.focusCell||!this.maxColRowCell)return;let{offsetX:e,offsetY:i}=this.ctx.getOffset(t),{colIndex:s,rowIndex:r,drawX:l,drawY:o,width:h,height:n}=this.maxColRowCell,a=2*(s!==this.ctx.maxColIndex&&r!==this.ctx.maxRowIndex),c=l+h-6+a,d=o+n-6+a;e>c&&i>d&&e<c+6&&i<d+6&&(this.ctx.stageElement.style.cursor="crosshair"),this.ctx.autofillMove&&this.ctx.startAdjustPosition(t)}),this.ctx.on("cellMouseenter",t=>{let{xArr:e,yArr:i}=this.ctx.selector,s=e[1],r=i[1],{colIndex:l,rowIndex:o}=t;this.ctx.config.ENABLE_AUTOFILL&&l===s&&o===r&&(this.maxColRowCell=t),this.mouseenter(t)}),this.ctx.on("mousedown",()=>{"crosshair"===this.ctx.stageElement.style.cursor&&this.setMousedown()}),this.ctx.on("mouseup",()=>{this.setMouseUp(),this.ctx.stopAdjustPosition()})}isAutofillIng(){let{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,this.ctx.disableHoverIconClick=!0}setMouseUp(){this.ctx.autofill.enable&&(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],setTimeout(()=>{this.ctx.disableHoverIconClick=!1},0))}setAutofill(t,e){let{ENABLE_AUTOFILL:i,ENABLE_AUTOFILL_SPAN_COL:s,ENABLE_AUTOFILL_SPAN_ROW:r}=this.ctx.config;if(!i)return;let l=t,o=e,h=this.ctx.selector.xArr,n=this.ctx.selector.yArr;if(!(!r&&JSON.stringify(n)!==JSON.stringify(o))&&!(!s&&JSON.stringify(h)!==JSON.stringify(l))&&(JSON.stringify(this.ctx.autofill.xArr)!==JSON.stringify(l)||JSON.stringify(this.ctx.autofill.yArr)!==JSON.stringify(o))){let{SELECTOR_AREA_MIN_X:t,SELECTOR_AREA_MAX_X:e,SELECTOR_AREA_MIN_Y:i,SELECTOR_AREA_MAX_Y:s,SELECTOR_AREA_MAX_X_OFFSET:r,SELECTOR_AREA_MAX_Y_OFFSET:h}=this.ctx.config,n=e||this.ctx.maxColIndex-r,a=s||this.ctx.maxRowIndex-h,[c,d]=l,[x,u]=o;if(c<t||x<i)return;l=[Math.max(t,c),Math.min(n,d)],o=[Math.max(i,x),Math.min(a,u)];let{BEFORE_SET_AUTOFILL_METHOD:g}=this.ctx.config;if("function"==typeof g){let t=g({focusCell:this.ctx.focusCell,xArr:l,yArr:o});if(!t)return;l=t.xArr,o=t.yArr}this.ctx.autofill.xArr=l,this.ctx.autofill.yArr=o,this.ctx.emit("setAutofill",this.ctx.autofill),this.ctx.emit("draw")}}async autofillData(){let t=new Set,e=this.ctx.getSelectedData(),i=new Map;for(let t=0;t<=e.yArr[1]-e.yArr[0];t++)for(let s=0;s<=e.xArr[1]-e.xArr[0];s++){let r=t+e.yArr[0],l=s+e.xArr[0];i.set(`${r}-${l}`,!0)}let{value:s}=e,r=s[0].length,l=s.length,o=this.ctx.autofill.xArr,h=this.ctx.autofill.yArr;if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.database.hasMergeCell(o,h)&&(1!==r||1!==l)){let t={code:"ERR_MERGED_CELLS_AUTOFILL",message:this.ctx.locale.getText("mergeCellNoFill"),data:[]};this.ctx.hasEvent("error")?this.ctx.emit("error",t):console.error(t.message);return}let n=[];for(let e=0;e<=h[1]-h[0];e++)for(let a=0;a<=o[1]-o[0];a++){let c=a+o[0],d=e+h[0],x=s[e%l][a%r],u=this.ctx.database.getItemV
15alueForRowIndexAndColIndex(d,c),g=`${d}-${c}`;if(u&&!i.has(g)){let{rowKey:e,key:i}=u;this.ctx.database.getReadonly(e,i)||(t.add(e),n.push({rowKey:e,key:i,value:x,row:{}}))}}if(!n.length)return;this.ctx.selector.xArr=this.ctx.autofill.xArr,this.ctx.selector.yArr=this.ctx.autofill.yArr;let{BEFORE_AUTOFILL_DATA_METHOD:a}=this.ctx.config;if("function"==typeof a){let t=n.map(t=>({rowKey:t.rowKey,key:t.key,value:t.value,oldValue:this.ctx.database.getItemValue(t.rowKey,t.key),row:this.ctx.database.getRowDataItemForRowKey(t.rowKey)}));if((n=await a(t,o,h))&&!n.length)return}this.ctx.batchSetItemValueByEditor(n,!0);let c=[];t.forEach(t=>{c.push(this.ctx.database.getRowDataItemForRowKey(t))}),this.ctx.emit("autofillChange",n,c),this.ctx.emit("draw")}mouseenter(t){if(["index","selection","index-selection"].includes(t.type))return;let{selector:e,autofill:i}=this.ctx;if(this.ctx.mousedown&&e.enable&&i.enable){let{rowIndex:i,colIndex:s}=t,r=e.xArr.slice(),l=e.yArr.slice();i>=e.yArr[0]&&i<=e.yArr[1]?s>e.xArr[1]?r.splice(1,1,s):s<e.xArr[0]&&r.splice(0,1,s):i>e.yArr[1]?l.splice(1,1,i):i<e.yArr[0]&&l.splice(0,1,i),this.setAutofill(r,l)}}destroy(){}}let ti=Math.min,ts=Math.max,tr=Math.round,tl=Math.floor,to=t=>({x:t,y:t}),th={left:"right",right:"left",bottom:"top",top:"bottom"};function tn(t,e){return"function"==typeof t?t(e):t}function ta(t){return t.split("-")[0]}function tc(t){return t.split("-")[1]}function td(t){return"x"===t?"y":"x"}function tx(t){return"y"===t?"height":"width"}function tu(t){let e=t[0];return"t"===e||"b"===e?"y":"x"}function tg(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}let tf=["left","right"],tm=["right","left"],tp=["top","bottom"],tw=["bottom","top"];function tE(t){let e=ta(t);return th[e]+t.slice(e.length)}function ty(t){return"number"!=typeof t?{top:0,right:0,bottom:0,left:0,...t}:{top:t,right:t,bottom:t,left:t}}function tb(t){let{x:e,y:i,width:s,height:r}=t;return{width:s,height:r,top:i,left:e,right:e+s,bottom:i+r,x:e,y:i}}function tv(t,e,i){let s,{reference:r,floating:l}=t,o=tu(e),h=td(tu(e)),n=tx(h),a=ta(e),c="y"===o,d=r.x+r.width/2-l.width/2,x=r.y+r.height/2-l.height/2,u=r[n]/2-l[n]/2;switch(a){case"top":s={x:d,y:r.y-l.height};break;case"bottom":s={x:d,y:r.y+r.height};break;case"right":s={x:r.x+r.width,y:x};break;case"left":s={x:r.x-l.width,y:x};break;default:s={x:r.x,y:r.y}}switch(tc(e)){case"start":s[h]-=u*(i&&c?-1:1);break;case"end":s[h]+=u*(i&&c?-1:1)}return s}async function tC(t,e){var i;void 0===e&&(e={});let{x:s,y:r,platform:l,rects:o,elements:h,strategy:n}=t,{boundary:a="clippingAncestors",rootBoundary:c="viewport",elementContext:d="floating",altBoundary:x=!1,padding:u=0}=tn(e,t),g=ty(u),f=h[x?"floating"===d?"reference":"floating":d],m=tb(await l.getClippingRect({element:null==(i=await (null==l.isElement?void 0:l.isElement(f)))||i?f:f.contextElement||await (null==l.getDocumentElement?void 0:l.getDocumentElement(h.floating)),boundary:a,rootBoundary:c,strategy:n})),p="floating"===d?{x:s,y:r,width:o.floating.width,height:o.floating.height}:o.reference,w=await (null==l.getOffsetParent?void 0:l.getOffsetParent(h.floating)),E=await (null==l.isElement?void 0:l.isElement(w))&&await (null==l.getScale?void 0:l.getScale(w))||{x:1,y:1},y=tb(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({elements:h,rect:p,offsetParent:w,strategy:n}):p);return{top:(m.top-y.top+g.top)/E.y,bottom:(y.bottom-m.bottom+g.bottom)/E.y,left:(m.left-y.left+g.left)/E.x,right:(y.right-m.right+g.right)/E.x}}let tR=async(t,e,i)=>{let{placement:s="bottom",strategy:r="absolute",middleware:l=[],platform:o}=i,h=o.detectOverflow?o:{...o,detectOverflow:tC},n=await (null==o.isRTL?void 0:o.isRTL(e)),a=await o.getElementRects({reference:t,floating:e,strategy:r}),{x:c,y:d}=tv(a,s,n),x=s,u=0,g={};for(let i=0;i<l.length;i++){let f=l[i];if(!f)continue;let{name:m,fn:p}=f,{x:w,y:E,data:y,reset:b}=await p({x:c,y:d,initialPlacement:s,placement:x,strategy:r,middlewareData:g,rects:a,platform:h,elements:{reference:t,floating:e}});c=w??c,d=E??d,g[m]={...g[m],...y},b&&u<50&&(u++,"object"==typeof b&&(b.placement&&(x=b.placement),b.rects&&(a=!0===b.rects?await o.getElementRects({reference:t,floating:e,strategy:r}):b.rects),{x:c,y:d}=tv(a,x,n)),i=-1)}return{x:c,y:d,placement:x,strategy:r,middlewareData:g}},tI=new Set(["left","top"]);async function t_(t,e){let{placement:i,platform:s,elements:r}=t,l=await (null==s.isRTL?void 0:s.isRTL(r.floating)),o=ta(i),h=tc(i),n="y"===tu(i),a=tI.has(o)?-1:1,c=l&&n?-1:1,d=tn(e,t),{mainAxis:x,crossAxis:u,alignmentAxis:g}="number"==typeof d?{mainAxis:d,crossAxis:0,alignmentAxis:null}
15:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return h&&"number"==typeof g&&(u="end"===h?-1*g:g),n?{x:u*c,y:x*a}:{x:x*a,y:u*c}}function tT(){return"u">typeof window}function tO(t){return tM(t)?(t.nodeName||"").toLowerCase():"#document"}function tS(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function tL(t){var e;return null==(e=(tM(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function tM(t){return!!tT()&&(t instanceof Node||t instanceof tS(t).Node)}function tA(t){return!!tT()&&(t instanceof Element||t instanceof tS(t).Element)}function tH(t){return!!tT()&&(t instanceof HTMLElement||t instanceof tS(t).HTMLElement)}function tD(t){return!(!tT()||typeof ShadowRoot>"u")&&(t instanceof ShadowRoot||t instanceof tS(t).ShadowRoot)}function tN(t){let{overflow:e,overflowX:i,overflowY:s,display:r}=tV(t);return/auto|scroll|overlay|hidden|clip/.test(e+s+i)&&"inline"!==r&&"contents"!==r}function tk(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}let tB=/transform|translate|scale|rotate|perspective|filter/,tK=/paint|layout|strict|content/,tX=t=>!!t&&"none"!==t;function tF(t){let e=tA(t)?tV(t):t;return tX(e.transform)||tX(e.translate)||tX(e.scale)||tX(e.rotate)||tX(e.perspective)||!tY()&&(tX(e.backdropFilter)||tX(e.filter))||tB.test(e.willChange||"")||tK.test(e.contain||"")}function tY(){return null==s&&(s="u">typeof CSS&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),s}function tW(t){return/^(html|body|#document)$/.test(tO(t))}function tV(t){return tS(t).getComputedStyle(t)}function tz(t){return tA(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function tP(t){if("html"===tO(t))return t;let e=t.assignedSlot||t.parentNode||tD(t)&&t.host||tL(t);return tD(e)?e.host:e}function tG(t,e,i){var s;void 0===e&&(e=[]),void 0===i&&(i=!0);let r=function t(e){let i=tP(e);return tW(i)?e.ownerDocument?e.ownerDocument.body:e.body:tH(i)&&tN(i)?i:t(i)}(t),l=r===(null==(s=t.ownerDocument)?void 0:s.body),o=tS(r);if(!l)return e.concat(r,tG(r,[],i));{let t=t$(o);return e.concat(o,o.visualViewport||[],tN(r)?r:[],t&&i?tG(t):[])}}function t$(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function tU(t){let e=tV(t),i=parseFloat(e.width)||0,s=parseFloat(e.height)||0,r=tH(t),l=r?t.offsetWidth:i,o=r?t.offsetHeight:s,h=tr(i)!==l||tr(s)!==o;return h&&(i=l,s=o),{width:i,height:s,$:h}}function tj(t){return tA(t)?t:t.contextElement}function tZ(t){let e=tj(t);if(!tH(e))return to(1);let i=e.getBoundingClientRect(),{width:s,height:r,$:l}=tU(e),o=(l?tr(i.width):i.width)/s,h=(l?tr(i.height):i.height)/r;return o&&Number.isFinite(o)||(o=1),h&&Number.isFinite(h)||(h=1),{x:o,y:h}}let tq=to(0);function tJ(t){let e=tS(t);
15return tY()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:tq}function tQ(t,e,i,s){var r;void 0===e&&(e=!1),void 0===i&&(i=!1);let l=t.getBoundingClientRect(),o=tj(t),h=to(1);e&&(s?tA(s)&&(h=tZ(s)):h=tZ(t));let n=(void 0===(r=i)&&(r=!1),s&&(!r||s===tS(o))&&r)?tJ(o):to(0),a=(l.left+n.x)/h.x,c=(l.top+n.y)/h.y,d=l.width/h.x,x=l.height/h.y;if(o){let t=tS(o),e=s&&tA(s)?tS(s):s,i=t,r=t$(i);for(;r&&s&&e!==i;){let t=tZ(r),e=r.getBoundingClientRect(),s=tV(r),l=e.left+(r.clientLeft+parseFloat(s.paddingLeft))*t.x,o=e.top+(r.clientTop+parseFloat(s.paddingTop))*t.y;a*=t.x,c*=t.y,d*=t.x,x*=t.y,a+=l,c+=o,r=t$(i=tS(r))}}return tb({width:d,height:x,x:a,y:c})}function t0(t,e){let i=tz(t).scrollLeft;return e?e.left+i:tQ(tL(t)).left+i}function t1(t,e){let i=t.getBoundingClientRect();return{x:i.left+e.scrollLeft-t0(t,i),y:i.top+e.scrollTop}}function t2(t,e,i){let s;if("viewport"===e)s=function(t,e){let i=tS(t),s=tL(t),r=i.visualViewport,l=s.clientWidth,o=s.clientHeight,h=0,n=0;if(r){l=r.width,o=r.height;let t=tY();(!t||t&&"fixed"===e)&&(h=r.offsetLeft,n=r.offsetTop)}let a=t0(s);if(a<=0){let t=s.ownerDocument,e=t.body,i=getComputedStyle(e),r="CSS1Compat"===t.compatMode&&parseFloat(i.marginLeft)+parseFloat(i.marginRight)||0,o=Math.abs(s.clientWidth-e.clientWidth-r);o<=25&&(l-=o)}else a<=25&&(l+=a);return{width:l,height:o,x:h,y:n}}(t,i);else if("document"===e)s=function(t){let e=tL(t),i=tz(t),s=t.ownerDocument.body,r=ts(e.scrollWidth,e.clientWidth,s.scrollWidth,s.clientWidth),l=ts(e.scrollHeight,e.clientHeight,s.scrollHeight,s.clientHeight),o=-i.scrollLeft+t0(t),h=-i.scrollTop;return"rtl"===tV(s).direction&&(o+=ts(e.clientWidth,s.clientWidth)-r),{width:r,height:l,x:o,y:h}}(tL(t));else if(tA(e))s=function(t,e){let i=tQ(t,!0,"fixed"===e),s=i.top+t.clientTop,r=i.left+t.clientLeft,l=tH(t)?tZ(t):to(1),o=t.clientWidth*l.x,h=t.clientHeight*l.y;return{width:o,height:h,x:r*l.x,y:s*l.y}}(e,i);else{let i=tJ(t);s={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return tb(s)}function t4(t){return"static"===tV(t).position}function t6(t,e){if(!tH(t)||"fixed"===tV(t).position)return null;if(e)return e(t);let i=t.offsetParent;return tL(t)===i&&(i=i.ownerDocument.body),i}function t8(t,e){var i;let s=tS(t);if(tk(t))return s;if(!tH(t)){let e=tP(t);for(;e&&!tW(e);){if(tA(e)&&!t4(e))return e;e=tP(e)}return s}let r=t6(t,e);for(;r&&(i=r,/^(table|td|th)$/.test(tO(i)))&&t4(r);)r=t6(r,e);return r&&tW(r)&&t4(r)&&!tF(r)?s:r||function(t){let e=tP(t);for(;tH(e)&&!tW(e);){if(tF(e))return e;if(tk(e))break;e=tP(e)}return null}(t)||s}let t7=async function(t){let e=this.getOffsetParent||t8,i=this.getDimensions,s=await i(t.floating);return{reference:function(t,e,i){let s=tH(e),r=tL(e),l="fixed"===i,o=tQ(t,!0,l,e),h={scrollLeft:0,scrollTop:0},n=to(0);if(s||!s&&!l)if(("body"!==tO(e)||tN(r))&&(h=tz(e)),s){let t=tQ(e,!0,l,e);n.x=t.x+e.clientLeft,n.y=t.y+e.clientTop}else r&&(n.x=t0(r));l&&!s&&r&&(n.x=t0(r));let a=!r||s||l?to(0):t1(r,h);return{x:o.left+h.scrollLeft-n.x-a.x,y:o.top+h.scrollTop-n.y-a.y,width:o.width,height:o.height}}(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}},t5={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:e,rect:i,offsetParent:s,strategy:r}=t,l="fixed"===r,o=tL(s),h=!!e&&tk(e.floating);if(s===o||h&&l)return i;let n={scrollLeft:0,scrollTop:0},a=to(1),c=to(0),d=tH(s);if((d||!d&&!l)&&(("body"!==tO(s)||tN(o))&&(n=tz(s)),d)){let t=tQ(s);a=tZ(s),c.x=t.x+s.clientLeft,c.y=t.y+s.clientTop}let x=!o||d||l?to(0):t1(o,n);return{width:i.width*a.x,height:i.height*a.y,x:i.x*a.x-n.scrollLeft*a.x+c.x+x.x,y:i.y*a.y-n.scrollTop*a.y+c.y+x.y}},getDocumentElement:tL,getClippingRect:function(t){let{element:e,boundary:i,rootBoundary:s,strategy:r}=t,l=[..."clippingAncestors"===i?tk(e)?[]:function(t,e){let i=e.get(t);if(i)return i;let s=tG(t,[],!1).filter(t=>tA(t)&&"body"!==tO(t)),r=null,l="fixed"===tV(t).position,o=l?tP(t):t;for(;tA(o)&&!tW(o);){let e=tV(o),i=tF(o);i||"fixed"!==e.position||(r=null),(l?i||r:!(!i&&"static"===e.position&&r&&("absolute"===r.position||"fixed"===r.position)||tN(o)&&!i&&function t(e,i){let s=tP(e);return!(s===i||!tA(s)||tW(s))&&("fixed"===tV(s).position||t(s,i))}(t,o)))?r=e:s=s.filter(t=>t!==o),o=tP(o)}return e.set(t,s),s}(e,this._c):[].concat(i),s],o=t2(e,l[0],r),h=o.top,n=o.right,a=o.bottom,c=o.left;for(let t=1;t<l.length;t++){let i=t2(e,l[t],r);h=ts(i.top,h),n=ti(i.right,n),a=ti(i.bottom,a),c=ts(i.left,c)}return{width:n-c,height:a-h,x:c,y:h}},getOffsetParent:t8,getElementRects:t7,getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){let{width:e,height:i}=tU(t);return{width:e,height:i}},getScale:tZ,isElement:tA,isRTL:function(t){return"rtl"===tV(t).direction}};function t3(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function t9(t,e,i,s){void 0===s&&(s={});let{ancestorScroll:r=!0,ancestorResize:l=!0,elementResize:o="function"==typeof ResizeObserver,layoutShift:h="function"==typeof IntersectionObserver,animationFrame:n=!1}
15=s,a=tj(t),c=r||l?[...a?tG(a):[],...e?tG(e):[]]:[];c.forEach(t=>{r&&t.addEventListener("scroll",i,{passive:!0}),l&&t.addEventListener("resize",i)});let d=a&&h?function(t,e){let i=null,s,r=tL(t);function l(){var t;clearTimeout(s),null==(t=i)||t.disconnect(),i=null}return function o(h,n){void 0===h&&(h=!1),void 0===n&&(n=1),l();let a=t.getBoundingClientRect(),{left:c,top:d,width:x,height:u}=a;if(h||e(),!x||!u)return;let g=tl(d),f=tl(r.clientWidth-(c+x)),m={rootMargin:-g+"px "+-f+"px "+-tl(r.clientHeight-(d+u))+"px "+-tl(c)+"px",threshold:ts(0,ti(1,n))||1},p=!0;function w(e){let i=e[0].intersectionRatio;if(i!==n){if(!p)return o();i?o(!1,i):s=setTimeout(()=>{o(!1,1e-7)},1e3)}1!==i||t3(a,t.getBoundingClientRect())||o(),p=!1}try{i=new IntersectionObserver(w,{...m,root:r.ownerDocument})}catch{i=new IntersectionObserver(w,m)}i.observe(t)}(!0),l}(a,i):null,x=-1,u=null;o&&(u=new ResizeObserver(t=>{let[s]=t;s&&s.target===a&&u&&e&&(u.unobserve(e),cancelAnimationFrame(x),x=requestAnimationFrame(()=>{var t;null==(t=u)||t.observe(e)})),i()}),a&&!n&&u.observe(a),e&&u.observe(e));let g,f=n?tQ(t):null;return n&&function e(){let s=tQ(t);f&&!t3(f,s)&&i(),f=s,g=requestAnimationFrame(e)}(),i(),()=>{var t;c.forEach(t=>{r&&t.removeEventListener("scroll",i),l&&t.removeEventListener("resize",i)}),null==d||d(),null==(t=u)||t.disconnect(),u=null,n&&cancelAnimationFrame(g)}}let et=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){var i,s;let{x:r,y:l,placement:o,middlewareData:h}=e,n=await t_(e,t);return o===(null==(i=h.offset)?void 0:i.placement)&&null!=(s=h.arrow)&&s.alignmentOffset?{}:{x:r+n.x,y:l+n.y,data:{...n,placement:o}}}}},ee=function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(e){let{x:i,y:s,placement:r,platform:l}=e,{mainAxis:o=!0,crossAxis:h=!1,limiter:n={fn:t=>{let{x:e,y:i}=t;return{x:e,y:i}}},...a}=tn(t,e),c={x:i,y:s},d=await l.detectOverflow(e,a),x=tu(ta(r)),u=td(x),g=c[u],f=c[x];if(o){let t="y"===u?"top":"left",e="y"===u?"bottom":"right",i=g+d[t],s=g-d[e];g=ts(i,ti(g,s))}if(h){let t="y"===x?"top":"left",e="y"===x?"bottom":"right",i=f+d[t],s=f-d[e];f=ts(i,ti(f,s))}let m=n.fn({...e,[u]:g,[x]:f});return{...m,data:{x:m.x-i,y:m.y-s,enabled:{[u]:o,[x]:h}}}}}},ei=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var i,s,r,l,o;let{placement:h,middlewareData:n,rects:a,initialPlacement:c,platform:d,elements:x}=e,{mainAxis:u=!0,crossAxis:g=!0,fallbackPlacements:f,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:w=!0,...E}=tn(t,e);if(null!=(i=n.arrow)&&i.alignmentOffset)return{};
15let y=ta(h),b=tu(c),v=ta(c)===c,C=await (null==d.isRTL?void 0:d.isRTL(x.floating)),R=f||(v||!w?[tE(c)]:function(t){let e=tE(t);return[tg(t),e,tg(e)]}(c)),I="none"!==p;!f&&I&&R.push(...function(t,e,i,s){let r=tc(t),l=function(t,e,i){switch(t){case"top":case"bottom":return i?e?tm:tf:e?tf:tm;case"left":case"right":return e?tp:tw;default:return[]}}(ta(t),"start"===i,s);return r&&(l=l.map(t=>t+"-"+r),e&&(l=l.concat(l.map(tg)))),l}(c,w,p,C));let _=[c,...R],T=await d.detectOverflow(e,E),O=[],S=(null==(s=n.flip)?void 0:s.overflows)||[];if(u&&O.push(T[y]),g){let t=function(t,e,i){void 0===i&&(i=!1);let s=tc(t),r=td(tu(t)),l=tx(r),o="x"===r?s===(i?"end":"start")?"right":"left":"start"===s?"bottom":"top";return e.reference[l]>e.floating[l]&&(o=tE(o)),[o,tE(o)]}(h,a,C);O.push(T[t[0]],T[t[1]])}if(S=[...S,{placement:h,overflows:O}],!O.every(t=>t<=0)){let t=((null==(r=n.flip)?void 0:r.index)||0)+1,e=_[t];if(e&&("alignment"!==g||b===tu(e)||S.every(t=>tu(t.placement)!==b||t.overflows[0]>0)))return{data:{index:t,overflows:S},reset:{placement:e}};let i=null==(l=S.filter(t=>t.overflows[0]<=0).sort((t,e)=>t.overflows[1]-e.overflows[1])[0])?void 0:l.placement;if(!i)switch(m){case"bestFit":{let t=null==(o=S.filter(t=>{if(I){let e=tu(t.placement);return e===b||"y"===e}return!0}).map(t=>[t.placement,t.overflows.filter(t=>t>0).reduce((t,e)=>t+e,0)]).sort((t,e)=>t[1]-e[1])[0])?void 0:o[0];t&&(i=t);break}case"initialPlacement":i=c}if(h!==i)return{reset:{placement:i}}}return{}}}},es=(t,e,i)=>{let s=new Map,r={platform:t5,...i},l={...r.platform,_c:s};return tR(t,e,{...r,platform:l})},er=class{constructor(t){l(this,"ctx"),l(this,"enable",!1),l(this,"contentEl"),l(this,"floatingEl"),l(this,"arrowEl"),this.ctx=t;let{TOOLTIP_BG_COLOR:e,TOOLTIP_TEXT_COLOR:i,TOOLTIP_ZINDEX:s,TOOLTIP_CUSTOM_STYLE:r,CSS_PREFIX:o}=this.ctx.config;this.contentEl=document.createElement("div"),this.arrowEl=document.createElement("div"),this.floatingEl=document.createElement("div"),this.floatingEl.className=`${o}-tooltip`,this.contentEl.className=`${o}-tooltip-content`,this.arrowEl.className=`${o}-tooltip-arrow`;let h={display:"none",position:"absolute",background:e,color:i,boxSizing:"border-box",zIndex:s,padding:"8px",borderRadius:"4px",fontSize:"12px",...r},n={position:"absolute",width:"10px",height:"10px",background:h.background,backgroundColor:h.backgroundColor,transform:"rotate(45deg)",zIndex:h.zIndex};Object.assign(this.arrowEl.style,n),Object.assign(this.floatingEl.style,h),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)}),this.ctx.on("cellFooterMouseleave",(t,e)=>{this.floatingEl.contains(e.target)||this.hide()}),this.ctx.on("cellFooterHoverChange",(t,e)=>{this.floatingEl.contains(e.target)||t.ellipsis&&this.show(t)}),this.ctx.on("cellShowTooltip",(t,e)=>{this.show(t,e)}),this.ctx.on("cellHideTooltip",()=>{this.hide()})}show(t,e){let i;if(this.ctx.contextMenuIng||!t.overflowTooltipShow||this.ctx.mousedown)return;this.floatingEl.style.display="block";let s=t.getText();t.message&&(s=t.message),e&&(s=e);let r=this.ctx.containerElement.getBoundingClientRect();if(!r)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=s;let l=t.drawX+r.x,o=t.drawY+r.y;es({getBoundingClientRect:()=>({width:t.visibleWidth,height:t.visibleHeight,x:l,y:o,left:l,right:l+t.visibleWidth,top:o,bottom:o+t.visibleHeight})},this.floatingEl,{placement:t.overflowTooltipPlacement,middleware:[ee(),ei(),et(6),{name:"arrow",options:i={element:this.arrowEl},async fn(t){let{x:e,y:s,placement:r,rects:l,platform:o,elements:h,middlewareData:n}=t,{element:a,padding:c=0}=tn(i,t)||{};if(null==a)return{};let d=ty(c),x={x:e,y:s},u=td(tu(r)),g=tx(u),f=await o.getDimensions(a),m="y"===u,p=m?"clientHeight":"clientWidth",w=l.reference[g]+l.reference[u]-x[u]-l.floating[g],E=x[u]-l.reference[u],y=await (null==o.getOffsetParent?void 0:o.getOffsetParent(a)),b=y?y[p]:0;b&&await (null==o.isElement?void 0:o.isElement(y))||(b=h.floating[p]||l.floating[g]);let v=b/2-f[g]/2-1,C=ti(d[m?"top":"left"],v),R=ti(d[m?"bottom":"right"],v),I=b-f[g]-R,_=b/2-f[g]/2+(w/2-E/2),T=ts(C,ti(_,I)),O=!n.arrow&&null!=tc(r)&&_!==T&&l.reference[g]/2-(_<C?C:R)-f[g]/2<0,S=O?_<C?_-C:_-I:0;return{[u]:x[u]+S,data:{[u]:T,centerOffset:_-T-S,...O&&{alignmentOffset:S}},reset:O}}}]}).then(t=>{let{x:e,y:i,placement:s,middlewareData:r}=t;if(Object.assign(this.floatingEl.style,{top:`${i}px`,left:`${e}px`}),r.arrow){let t=r.arrow;["left","left-start","left-end"].includes(s)?Object.assign(this.arrowEl.style,{top:`${t.y}px`,bottom:"",left:"",right:"-5px"}):["right","right-start","right-end"].includes(s)?Object.assign(this.arrowEl.style,{top:`${t.y}px`,bottom:"",left:"-5px",right:""}):["bottom","bottom-start","bottom-end"].includes(s)?Object.assign(this.arrowEl.style,{top:"-5px",bottom:"",left:`${t.x}px`,right:""}
15):["top","top-start","top-end"].includes(s)&&Object.assign(this.arrowEl.style,{top:"",bottom:"-5px",left:`${t.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 el{constructor(t){l(this,"editorEl"),l(this,"inputEl"),l(this,"enable",!1),l(this,"cellTarget",null),l(this,"selectorArrStr",""),l(this,"ctx"),l(this,"drawY",0),l(this,"drawX",0),l(this,"cancel",!1),this.ctx=t,this.initTextEditor(),this.init()}init(){this.ctx.on("outsideMousedown",()=>{this.cellTarget&&"text"===this.cellTarget.editorType&&this.clearEditor()}),this.ctx.on("moveFocus",t=>{this.cellTarget=t,this.resetEditorStyle();let{xArr:e,yArr:i}=this.ctx.selector;this.selectorArrStr=JSON.stringify(e)+JSON.stringify(i),this.focusInput()}),this.ctx.on("onScroll",()=>{this.enable&&this.doneEdit()}),this.ctx.on("hoverIconClick",t=>{this.editCell(t.rowIndex,t.colIndex)}),this.ctx.on("keydown",t=>{if(!this.ctx.isTarget(t)||!this.ctx.focusCell||this.ctx.finding)return;let{focusCell:e}=this.ctx;if("Escape"===t.code&&this.ctx.editing){this.cancel=!0;let{focusCell:t}=this.ctx;t&&(this.ctx.emit("setSelectorCell",t),this.cellTarget=t),this.doneEdit();return}if((t.altKey||t.metaKey)&&"Enter"===t.key&&this.ctx.editing&&this.inputEl){t.preventDefault();let e=this.inputEl.selectionStart,i=this.inputEl.value.substring(0,e),s=this.inputEl.value.substring(e);this.inputEl.value=i+`
16`+s,this.inputEl.selectionStart=this.inputEl.selectionEnd=e+1,this.autoSize();return}if("Tab"===t.code&&this.ctx.editing)return(t.preventDefault(),this.doneEdit(),t.shiftKey)?void this.ctx.emit("setMoveFocus","LEFT"):void this.ctx.emit("setMoveFocus","RIGHT");if("Enter"===t.key&&this.ctx.editing)return(t.preventDefault(),this.doneEdit(),t.shiftKey)?void this.ctx.emit("setMoveFocus","TOP"):void this.ctx.emit("setMoveFocus","BOTTOM");if("Enter"===t.key&&!this.ctx.editing){t.preventDefault(),this.startEdit();return}let i=t.key,s=t.ctrlKey,r=t.altKey,l=t.shiftKey,o=t.metaKey;if(!(s||r||l||o||["Enter","CapsLock","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(i))){if(document.activeElement!==this.inputEl&&"text"===e.editorType)return void t.preventDefault();this.startEdit(!0)}}),this.ctx.on("cellClick",t=>{if("pointer"===this.ctx.stageElement.style.cursor||!this.isInSelectorRange(t.rowIndex,t.colIndex))return;let{xArr:e,yArr:i}=this.ctx.selector,s=JSON.stringify(e)+JSON.stringify(i);if(this.focusInput(),this.selectorArrStr===s&&this.cellTarget&&(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.onlyMergeCell||this.ctx.selectOnlyOne&&t.rowKey===this.cellTarget.rowKey&&t.key===this.cellTarget.key))return void this.startEdit();if(this.selectorArrStr=s,this.doneEdit(),this.cellTarget=t,this.resetEditorStyle(),this.ctx.config.ENABLE_EDIT_SINGLE_CLICK){if(this.ctx.config.ENABLE_MERGE_CELL_LINK&&this.ctx.onlyMergeCell)return void this.startEdit();this.ctx.selectOnlyOne&&this.startEdit()}})}isTextSelectionActive(){return this.ctx.config.ENABLE_TEXT_SELECTION&&(this.ctx.textSelecting||!!this.ctx.textSelectionStr)}isInSelectorRange(t,e){let{xArr:i,yArr:s}=this.ctx.selector,[r,l]=i,[o,h]=s;return!(e<r||e>l||t<o||t>h)}initTextEditor(){this.inputEl=document.createElement("textarea"),this.inputEl.id="e-virt-table-editor-textarea",this.inputEl.setAttribute("rows","1"),this.inputEl.setAttribute("tabindex","-1"),this.inputEl.addEventListener("input",this.autoSize.bind(this)),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(){if(!this.ctx.editing)return;let t=this.inputEl.value;if(this.cellTarget&&"number"===this.cellTarget.type&&""!==t&&(this.ctx.emit("cellHideTooltip"),!/^-?\d+(\.\d+)?$/.test(t))){let t=this.ctx.locale.getText("numberErrorTip");this.ctx.emit("cellShowTooltip",this.cellTarget,t)}this.inputEl.style.height="auto";let e=this.inputEl.scrollHeight,i=this.ctx.body.visibleHeight;e>i&&(e=i);let{stageHeight:s,footer:r,header:l,config:{SCROLLER_TRACK_SIZE:o}}=this.ctx,h=s-r.height-o;this.editorEl.style.bottom="auto",this.drawY<l.height&&(this.editorEl.style.top=`${l.height-1}px`),this.drawY+e>h&&(this.editorEl.style.left=`${this.drawX-1}px`,this.editorEl.style.top="auto",this.editorEl.style.bottom=`${s-h}px`),this.inputEl.style.height=`${e}px`}startEditByInput(t,e=!1){let i=e?null:t.getValue(),{editorType:s}=t;if("none"===s)return;
16t.update(),this.ctx.config.ENABLE_MERGE_CELL_LINK&&t.updateSpanInfo();let{height:r,width:l,drawY:o,drawX:h}=t;this.drawX=h,this.drawY=o;let{config:{CELL_PADDING:n},header:a}=this.ctx,c=this.ctx.body.visibleHeight;r>c&&(r=c),this.editorEl.style.zIndex="100",this.editorEl.style.left=`${this.drawX-1}px`,this.editorEl.style.top=`${this.drawY}px`,this.editorEl.style.bottom="auto",this.editorEl.style.maxWidth="none",this.editorEl.style.maxHeight=`${c}px`,["text"].includes(s)?(this.inputEl.style.opacity="1",this.inputEl.style.position="relative",this.inputEl.style.minWidth=`${l-1}px`,this.inputEl.style.minHeight=`${r-1}px`,this.inputEl.style.maxHeight=`${c}px`,this.inputEl.style.width=`${l}px`,this.inputEl.style.height="auto",this.inputEl.style.padding=`${n}px`,this.inputEl.value="",null!==i&&(this.inputEl.value=i),(this.inputEl.scrollHeight>r||this.drawY<a.height)&&this.autoSize()):(this.inputEl.style.opacity="0",this.inputEl.style.width="1px",this.inputEl.style.height="1px",this.inputEl.style.position="absolute",this.inputEl.style.left="0px",this.inputEl.style.top="0px")}doneEditByInput(){if(this.cellTarget&&"text"===this.cellTarget.editorType){let{rowKey:t,key:e}=this.cellTarget,i=this.cellTarget.getValue(),s=this.inputEl.value;s===i||""===s&&null===i||this.cancel||this.ctx.setItemValueByEditor(t,e,s,!0)}}focusInput(){document.activeElement!==this.inputEl&&this.inputEl.focus({preventScroll:!0})}startEdit(t=!1){if(this.isTextSelectionActive())return;this.cancel=!1;let{ENABLE_EDIT_CLICK_SELECTOR:e}=this.ctx.config;if(!e)return;let i=this.ctx.focusCell;i&&(i.isVerticalVisible()&&i.isHorizontalVisible()||this.ctx.emit("scrollToIndex",i.rowIndex,i.colIndex),this.editCell(i.rowIndex,i.colIndex,t))}editCell(t,e,i=!1){let s=this.ctx.body.renderRows.find(e=>e.rowIndex===t);if(!s)return;let r=s.cells.find(t=>t.colIndex===e);if(!r||!(r.isVerticalVisible()&&r.isHorizontalVisible()))return;this.ctx.emit("setSelectorCell",r);let l=this.ctx.focusCell;if(!l||["index","index-selection","selection"].includes(l.type)||this.enable)return;let{rowKey:o,key:h}=l,n=this.ctx.database.getReadonly(o,h);l&&!n&&(this.enable=!0,this.ctx.editing=!0,this.cellTarget=l,this.startEditByInput(this.cellTarget,i),this.ctx.emit("startEdit",this.cellTarget),this.ctx.emit("draw"))}doneEdit(){this.enable&&(this.doneEditByInput(),this.ctx.emit("cellHideTooltip"),this.ctx.emit("doneEdit",this.cellTarget),this.enable=!1,this.ctx.editing=!1,this.resetEditorStyle(),setTimeout(()=>{this.focusInput()},0),this.ctx.emit("draw"))}resetEditorStyle(){let t=this.cellTarget;t&&(this.editorEl.style.left=`${t.drawX}px`,this.editorEl.style.top=`${t.drawY}px`,this.editorEl.style.maxWidth="1px",this.editorEl.style.maxHeight="1px",this.editorEl.style.zIndex="-1")}clearEditor(){this.doneEdit(),this.cellTarget=null,this.selectorArrStr="",this.ctx.clearSelector(),this.ctx.focusCell=void 0,this.inputEl.blur(),this.ctx.emit("draw")}destroy(){var t;null==(t=this.editorEl)||t.remove()}}let eo=class{constructor(t){l(this,"ctx"),l(this,"emptyEl"),this.ctx=t;let{EMPTY_CUSTOM_STYLE:e}=this.ctx.config;this.ctx.emptyElement?this.emptyEl=this.ctx.emptyElement:(this.emptyEl=document.createElement("div"),this.emptyEl.innerText=this.getText()),this.emptyEl.className="e-virt-table-empty",this.emptyEl.style.display="none",this.ctx.containerElement.appendChild(this.emptyEl),this.ctx.on("emptyChange",({type:t,headerHeight:i,bodyHeight:s,footerHeight:r})=>{let l={display:"empty"===t?"block":"none",top:`${i+(s+r)/2}px`,...e};Object.assign(this.emptyEl.style,l)})}getText(){return this.ctx.config.EMPTY_TEXT||this.ctx.locale.getText("emptyText")}draw(){this.ctx.emptyElement||(this.emptyEl.innerText=this.getText())}destroy(){this.emptyEl.remove()}};class eh{constructor(t){l(this,"ctx"),l(this,"observer"),this.ctx=t,this.init()}arerMapsEqual(t,e){if(t.size!==e.size)return!1;for(let[i,s]of t)if(!e.has(i)||e.get(i)!==s)return!1;return!0}init(){this.observer=new MutationObserver(n(()=>{let t=this.ctx.overlayerElement.querySelectorAll('[data-auto-height="true"]'),e=new Map;t.forEach(t=>{let i=Number(t.getAttribute("data-row-index")),s=Number(t.getAttribute("data-col-index"));if(isNaN(i)||isNaN(s))return;let r=t.getBoundingClientRect(),l=`${i}​_${s}`;e.set(l,Math.round(r.height))});let i=this.ctx.database.getOverlayerAutoHeightMap();if(!this.arerMapsEqual(i,e)){if(this.ctx.database.setOverlayerAutoHeightMap(e),0===i.size&&0===e.size)return;this.ctx.emit("draw")}},16.67)),this.observer.observe(this.ctx.overlayerElement,{childList:!0,subtree:!0,attributes:!0,characterData:!0}
16),"default"===this.ctx.overlayerElement.getAttribute("data-overlayer")&&this.ctx.on("overlayerChange",t=>{let e=this.ctx.overlayerElement;e.replaceChildren(),Object.assign(e.style,t.style),t.views.forEach(t=>{let i=document.createElement("div");i.className=t.class,Object.assign(i.style,t.style),t.views.forEach(t=>{let e=document.createElement("div");Object.assign(e.style,t.style),t.cells.forEach(t=>{let i=document.createElement("div");Object.assign(i.style,t.style),Object.keys(t.domDataset).forEach(e=>{i.setAttribute(e,t.domDataset[e])}),"function"==typeof t.render&&t.render(i,t),e.appendChild(i)}),i.appendChild(e)}),e.appendChild(i)})})}draw(){let t=this.getContainer();this.ctx.emit("overlayerChange",t)}destroy(){this.observer&&this.observer.disconnect(),this.ctx.emit("overlayerChange",{style:{},views:[]})}getContainer(){let t=this.getHeader(),e=this.getBody(),i=this.getFooter(),{FOOTER_FIXED:s,FOOTER_POSITION:r}=this.ctx.config;return{views:s?"top"===r?[t,i,e]:[t,e,i]:[t,e]}}getHeader(){let{fixedLeftWidth:t,fixedRightWidth:e,config:{SCROLLER_TRACK_SIZE:i,CSS_PREFIX:s}}=this.ctx,{visibleWidth:r,visibleHeight:l,renderCellHeaders:o}=this.ctx.header,h=[],n=[],a=[];o.forEach(t=>{t.render&&("left"===t.fixed?n.push(t):"right"===t.fixed?a.push(t):h.push(t))});let c=e-i,d={key:"left",style:{position:"absolute",top:"0px",left:"0px",overflow:"hidden",width:`${t}px`,height:`${l}px`},cells:n},x={key:"center",style:{position:"absolute",top:"0px",left:`${t}px`,overflow:"hidden",width:`${r-t-c+1}px`,height:`${l}px`},cells:h},u={key:"right",style:{position:"absolute",top:"0px",right:"0px",overflow:"hidden",width:`${c+1}px`,height:`${l}px`},cells:a};return{type:"header",class:`${s}-overlayer-header`,style:{position:"relative",overflow:"hidden",width:`${r}px`,height:`${l}px`},views:[d,x,u]}}getBody(){let t=[],e=[],i=[],s=this.ctx.body.renderRows;this.ctx.config.FOOTER_FIXED||(s=s.concat(this.ctx.footer.renderRows)),s.forEach(s=>{s.cells.forEach(s=>{"footer"===s.cellType&&(s.render=s.renderFooter),s.render&&("left"===s.fixed?e.push(s):"right"===s.fixed?i.push(s):t.push(s))})});let{fixedLeftWidth:r,fixedRightWidth:l,config:{SCROLLER_TRACK_SIZE:o,CSS_PREFIX:h}}=this.ctx,{visibleWidth:n,visibleHeight:a}=this.ctx.body,c=l-o,d={key:"left",style:{position:"absolute",top:"0.5px",left:"0.5px",overflow:"hidden",width:`${r}px`,height:`${a}px`},cells:e},x={key:"center",style:{position:"absolute",top:"0.5px",left:`${r-.5}px`,overflow:"hidden",width:`${n-r-c}px`,height:`${a}px`},cells:t},u={key:"right",style:{position:"absolute",top:"0px",right:"0px",overflow:"hidden",width:`${c}px`,height:`${a}px`},cells:i};return{type:"body",class:`${h}-overlayer-body`,style:{position:"relative",overflow:"hidden",width:`${n}px`,height:`${a}px`},views:[d,x,u]}}getFooter(){let t=[],e=[],i=[];this.ctx.footer.renderRows.forEach(s=>{s.cells.forEach(s=>{"footer"===s.cellType&&s.renderFooter&&(s.render=s.renderFooter,"left"===s.fixed?e.push(s):"right"===s.fixed?i.push(s):t.push(s))})});let{fixedLeftWidth:s,fixedRightWidth:r,config:{SCROLLER_TRACK_SIZE:l,CSS_PREFIX:o}}=this.ctx,{visibleWidth:h,visibleHeight:n}=this.ctx.footer,a=r-l,c={key:"left",style:{position:"absolute",top:"0.5px",left:"0.5px",overflow:"hidden",width:`${s}px`,height:`${n}px`},cells:e},d={key:"center",style:{position:"absolute",top:"0.5px",left:`${s-.5}px`,overflow:"hidden",width:`${h-s-a}px`,height:`${n}px`},cells:t},x={key:"right",style:{position:"absolute",top:"0.5px",right:"0.5px",overflow:"hidden",width:`${a}px`,height:`${n}px`},cells:i};return{type:"footer",class:`${o}-overlayer-footer`,style:{position:"relative",overflow:"hidden",width:`${h}px`,height:`${n}px`},views:[c,d,x]}}}class en{constructor(t,e=[],i={}){l(this,"container"),l(this,"menuData"),l(this,"onClick"),l(this,"activeSubmenus",new Set),l(this,"boundMouseEnterHandler"),l(this,"boundMouseLeaveHandler"),l(this,"boundClickHandler"),this.container=t,this.menuData=e,this.onClick=i.onClick,this.boundMouseEnterHandler=t=>this.handleMouseEvent(t,"enter"),this.boundMouseLeaveHandler=t=>this.handleMouseEvent(t,"leave"),this.boundClickHandler=t=>this.handleClick(t),this.createMenu(),this.bindEvents()}createMenu(){this.container.className="e-virt-table-main-menu",this.container.style.display="block";let t=document.createDocumentFragment();
16this.menuData.forEach(e=>{t.appendChild(this.createMenuItem(e))}),this.container.appendChild(t)}createMenuItem(t,e=!1){var i;let s=this.createElement("div",e?"e-virt-table-submenu-item":"e-virt-table-menu-item");s.setAttribute(e?"data-submenu":"data-menu",t.value),t.disabled&&s.classList.add("disabled");let r=this.createElement("div","e-virt-table-menu-item-content");if(t.icon){let e=this.createElement("span","e-virt-table-menu-item-icon");e.innerHTML=t.icon,r.appendChild(e)}else r.classList.add("menu-item-no-icon");let l=this.createElement("span","e-virt-table-menu-item-text");if(l.textContent=t.label||"",r.appendChild(l),s.appendChild(r),null!=(i=t.children)&&i.length){let e=this.createElement("span","e-virt-table-menu-arrow");e.innerHTML=S,s.appendChild(e);let i=this.createSubmenu(t.children);s._submenu=i,this.container.appendChild(i)}return s}createSubmenu(t){let e=this.createElement("div","e-virt-table-submenu");return t.forEach(t=>{e.appendChild(this.createMenuItem(t,!0))}),e}createElement(t,e=""){let i=document.createElement(t);return e&&(i.className=e),i}bindEvents(){this.container.addEventListener("mouseenter",this.boundMouseEnterHandler,!0),this.container.addEventListener("mouseleave",this.boundMouseLeaveHandler,!0),this.container.addEventListener("click",this.boundClickHandler)}handleMouseEvent(t,e){t.stopPropagation();let i=t.target.closest(".e-virt-table-menu-item, .e-virt-table-submenu-item");i&&(this.container.contains(i)||i.classList.contains("e-virt-table-submenu-item"))&&("enter"===e?this.handleHover(i):this.handleLeave(i))}handleHover(t){t.classList.contains("e-virt-table-menu-item")&&(this.container.querySelectorAll(".e-virt-table-menu-item").forEach(t=>t.classList.remove("active")),t.classList.contains("disabled")||t.classList.add("active"));let e=t._submenu||t.querySelector(".e-virt-table-submenu");e&&(this.hideSiblingSubmenus(t),this.showSubmenu(t,e))}handleLeave(t){let e=t._submenu||t.querySelector(".e-virt-table-submenu");setTimeout(()=>{e&&!e.matches(":hover")&&!t.matches(":hover")&&(this.hideSubmenu(e),t.classList.contains("e-virt-table-menu-item")&&t.classList.remove("active"))},150)}hideSiblingSubmenus(t){let e;if(t.classList.contains("e-virt-table-menu-item"))e=this.container.querySelectorAll(".e-virt-table-menu-item");else{let i=t.closest(".e-virt-table-submenu");if(!i)return;e=i.querySelectorAll(".e-virt-table-submenu-item")}e.forEach(e=>{e!==t&&e._submenu&&this.hideSubmenu(e._submenu)})}async showSubmenu(t,e){if(this.activeSubmenus.has(e))return;this.activeSubmenus.add(e),e.classList.add("show");let i=t9(t,e,async()=>{let i=this.container.getBoundingClientRect(),s=window.innerWidth,r=e.offsetWidth||200,l=s-i.right,o=i.left,{x:h,y:n}=await es(t,e,{placement:l>=r||l>=o?"right-start":"left-start",middleware:[et(8),ee({padding:8})]});Object.assign(e.style,{left:`${h}px`,top:`${n}px`})});e._cleanup=i}hideSubmenu(t){this.activeSubmenus.has(t)&&(this.activeSubmenus.delete(t),t.classList.remove("show"),this.hideAllChildSubmenus(t),t._cleanup&&(t._cleanup(),delete t._cleanup))}hideAllChildSubmenus(t){t.querySelectorAll(".e-virt-table-submenu-item").forEach(t=>{if(t._submenu){let e=t._submenu;this.activeSubmenus.has(e)&&(this.activeSubmenus.delete(e),e.classList.remove("show"),e._cleanup&&(e._cleanup(),delete e._cleanup),this.hideAllChildSubmenus(e))}})}handleClick(t){t.stopPropagation();let e=t.target.closest(".e-virt-table-menu-item, .e-virt-table-submenu-item");if(!e||e.classList.contains("disabled"))return;if(e.classList.contains("e-virt-table-menu-item")){let t=e._submenu||e.querySelector(".e-virt-table-submenu");if(t)return void this.showSubmenu(e,t)}let i=e.getAttribute("data-menu")||(null==e?void 0:e.getAttribute("data-submenu")),s=this.findMenuItem(i||"");s&&this.onClick&&this.onClick(s,i||"")}findMenuItem(t,e=this.menuData){for(let i of e){if(i.value===t)return i;if(i.children){let e=this.findMenuItem(t,i.children);if(e)return e}}return null}positionMenu(t){let e={getBoundingClientRect:()=>({width:0,height:0,top:t.clientY,left:t.clientX,right:t.clientX,bottom:t.clientY,x:t.clientX,y:t.clientY}),contextElement:document.body};t9(e,this.container,()=>{es(e,this.container,{placement:"right-start",middleware:[et(),ee(),ei()]}).then(({x:t,y:e})=>
16{this.container&&Object.assign(this.container.style,{left:`${t}px`,top:`${e}px`})})})}destroy(){this.container.removeEventListener("mouseenter",this.boundMouseEnterHandler,!0),this.container.removeEventListener("mouseleave",this.boundMouseLeaveHandler,!0),this.container.removeEventListener("click",this.boundClickHandler),this.cleanupAllSubmenus(this.container),this.container.style.display="none",this.container.replaceChildren()}removeMenuItem(t){let e=this.container.querySelector(`[data-menu="${t}"]`);if(!e)return!1;let i=e.querySelector(".e-virt-table-submenu");return i&&this.cleanupSubmenuRecursively(i),e.remove(),!0}removeSubMenuItem(t){let e=this.container.querySelector(`[data-submenu="${t}"]`);if(!e)return!1;let i=e.closest(".e-virt-table-submenu"),s=e._submenu;if(s&&this.cleanupSubmenuRecursively(s),e.remove(),i&&0===i.querySelectorAll(".e-virt-table-submenu-item").length){let t=this.container.querySelector("[data-menu]");if(t&&t._submenu===i)this.removeMenuItem(t.getAttribute("data-menu")||"");else for(let t of this.container.querySelectorAll("[data-menu], [data-submenu]"))if(t._submenu===i){let e=t.getAttribute("data-menu")||t.getAttribute("data-submenu");e&&(t.hasAttribute("data-menu")?this.removeMenuItem(e):this.removeSubMenuItem(e));break}}return!0}cleanupAllSubmenus(t){t.querySelectorAll(".e-virt-table-menu-item").forEach(t=>{t._submenu&&(this.cleanupSubmenuRecursively(t._submenu),t._submenu=void 0)})}cleanupSubmenuRecursively(t){t._cleanup&&(t._cleanup(),delete t._cleanup),t.querySelectorAll(".e-virt-table-submenu-item").forEach(t=>{t._submenu&&this.cleanupSubmenuRecursively(t._submenu)}),t.remove()}}class ea{constructor(t){l(this,"ctx"),l(this,"contextMenuEl"),l(this,"currentDOMTreeMenu"),l(this,"isCustom",!1),this.ctx=t,this.ctx.contextMenuElement?(this.contextMenuEl=this.ctx.contextMenuElement,this.contextMenuEl.className="e-virt-table-main-menu",this.isCustom=!0):(this.contextMenuEl=document.createElement("div"),this.isCustom=!1),this.ctx.containerElement.appendChild(this.contextMenuEl),this.init()}init(){this.ctx.on("outsideMousedown",()=>{this.hide()}),this.ctx.on("cellContextMenuClick",async(t,e)=>{if(this.isCustom){this.contextMenuEl.style.display="block",this.positionMenu(e);return}let{ENABLE_CONTEXT_MENU:i,CUSTOM_BODY_CONTEXT_MENU:s,CONTEXT_MENU:r,BEFORE_BODY_CONTEXT_MENU_METHOD:l}=this.ctx.config,o=r.map(t=>({...t,label:t.label||this.ctx.locale.getText(t.value)}));if(o=[...o,...s],l&&(o=await l({list:o,cell:t,hide:this.hide.bind(this)})),!i||0===o.length)return;e.preventDefault();let{xArr:h,yArr:n}=this.ctx.selector,[a,c]=h,[d,x]=n,{rowIndex:u,colIndex:g}=t;u>=d&&u<=x&&g>=a&&g<=c||this.ctx.emit("setSelectorCell",t,e),this.currentDOMTreeMenu&&this.currentDOMTreeMenu.destroy(),this.ctx.contextMenuIng=!0,this.currentDOMTreeMenu=new en(this.contextMenuEl,o,{onClick:(i,s)=>{"copy"===s?(this.ctx.emit("contextMenuCopy"),this.hide()):"paste"===s?(this.ctx.emit("contextMenuPaste"),this.hide()):"cut"===s?(this.ctx.emit("contextMenuCut"),this.hide()):"clearSelected"===s?(this.ctx.emit("contextMenuClearSelected"),this.hide()):i.event&&i.event(e,{hide:this.hide.bind(this),cell:t})}}),this.currentDOMTreeMenu.positionMenu(e)}),this.ctx.on("cellHeaderContextMenuClick",async(t,e)=>{if(this.isCustom){this.contextMenuEl.style.display="block",this.positionMenu(e);return}let{SELECTOR_AREA_MIN_X:i,SELECTOR_AREA_MAX_X:s,SELECTOR_AREA_MAX_X_OFFSET:r,BEFORE_HEADER_CONTEXT_MENU_METHOD:l}=this.ctx.config,o=s||this.ctx.maxColIndex-r;if(t.colIndex<i||t.colIndex>o)return;let{HEADER_CONTEXT_MENU:h,CUSTOM_HEADER_CONTEXT_MENU:n,ENABLE_HEADER_CONTEXT_MENU:a}=this.ctx.config,c=h.map(t=>({...t,label:t.label||this.ctx.locale.getText(t.value)}));if(c=[...c,...n],l&&(c=await l({list:c,cell:t,hide:this.hide.bind(this)})),!a||0===c.length)return;e.preventDefault();let{xArr:x}=this.ctx.selector,[u,g]=x,{colIndex:f}=t;f>=u&&f<=g||(this.ctx.focusCellHeader=t,this.ctx.emit("selectCols",t)),this.currentDOMTreeMenu&&this.currentDOMTreeMenu.destroy();let m=this.ctx.database.getColumns(),p=c.map(t=>"visible"===t.value?{...t,children:this.filterColumns(m)}:t);this.ctx.contextMenuIng=!0,this.currentDOMTreeMenu=new en(this.contextMenuEl,p,{onClick:(i,s)=>{let{xArr:r}=this.ctx.selector,[l,o]=r;if("fixedLeft"===s||"fixedRight"===s||"fixedNone"===s){let t=this.ctx.header.allCellHeaders.filter(t=>t.colIndex>=l&&t.colIndex<=o).filter(t=>0===t.level).filter(t=>!t.column.fixedDisabled).map(t=>t.key);this.ctx.database.setCustomHeaderFixedData(t,"fixedLeft"===s?"left":"fixedRight"===s?"right":""),this.hide()}
16else if("hide"===s){let t=this.ctx.header.leafCellHeaders.filter(t=>t.colIndex>=l&&t.colIndex<=o).filter(t=>!t.children.length).filter(t=>!t.column.hideDisabled).map(t=>t.key);t.length>0&&this.ctx.database.setCustomHeaderHideData(t,!0),this.hide()}else if("visible"!==s)if(s.startsWith("visible_")){if(!i.key)return;if(i.children){let t=this.getLeafKeys(i.children);this.ctx.database.setCustomHeaderHideData(t,!1)}else this.ctx.database.setCustomHeaderHideData([i.key],!1);this.currentDOMTreeMenu&&this.currentDOMTreeMenu.removeSubMenuItem(s),0===d(this.ctx.database.getColumns()).filter(t=>t.hide).length&&this.hide()}else"resetHeader"===s?(this.ctx.database.resetCustomHeader(),this.hide()):i.event&&i.event(e,{hide:this.hide.bind(this),cell:t})}}),this.positionMenu(e)}),this.ctx.on("click",()=>{this.hide()}),this.ctx.on("onScroll",this.hide.bind(this)),this.ctx.on("resize",this.hide.bind(this))}positionMenu(t){let e={getBoundingClientRect:()=>({width:0,height:0,top:t.clientY,left:t.clientX,right:t.clientX,bottom:t.clientY,x:t.clientX,y:t.clientY}),contextElement:document.body};t9(e,this.contextMenuEl,()=>{es(e,this.contextMenuEl,{placement:"right-start",middleware:[et(),ee(),ei()]}).then(({x:t,y:e})=>{this.contextMenuEl&&Object.assign(this.contextMenuEl.style,{left:`${t}px`,top:`${e}px`})})})}filterColumns(t){let e=[];for(let i of t)if(i.children&&i.children.length>0){let t=this.filterColumns(i.children);t.length>0&&e.push({label:i.title,key:i.key,value:`visible_${i.key}`,children:t})}else i.hide&&e.push({label:i.title,value:`visible_${i.key}`,key:i.key});return e}getLeafKeys(t){return t.reduce((t,e)=>(e.children&&0!==e.children.length?t.push(...this.getLeafKeys(e.children)):t.push(String(e.key)),t),[])}hide(){this.currentDOMTreeMenu&&(this.currentDOMTreeMenu.destroy(),this.currentDOMTreeMenu=void 0),this.contextMenuEl.style.display="none",this.ctx.contextMenuIng=!1}destroy(){var t;this.hide(),null==(t=this.contextMenuEl)||t.remove()}}class ec{constructor(t){if(l(this,"ctx"),l(this,"loadingEl"),l(this,"textEl",document.createElement("p")),this.ctx=t,this.ctx.loadingElement)this.loadingEl=this.ctx.loadingElement;else{this.loadingEl=document.createElement("div");let t=document.createElement("div");t.className="e-virt-table-loading-spinner";let e=this.ctx.icons.getSvg("loading");if(e){let i=new DOMParser().parseFromString(e.svg,"image/svg+xml").documentElement;t.appendChild(i)}this.textEl.className="e-virt-table-loading-text",this.textEl.innerText=this.getText(),t.appendChild(this.textEl),this.loadingEl.appendChild(t)}this.loadingEl.className="e-virt-table-loading",this.loadingEl.style.display="none",this.ctx.containerElement.appendChild(this.loadingEl)}getText(){return this.ctx.config.LOADING_TEXT||this.ctx.locale.getText("loadingText")}show(){this.loadingEl.style.display="flex"}hide(){this.loadingEl.style.display="none"}draw(){this.ctx.loadingElement||(this.textEl.innerText=this.getText())}destroy(){this.loadingEl.remove()}}class ed{constructor(t){l(this,"ctx"),l(this,"container"),l(this,"input"),l(this,"prevBtn"),l(this,"nextBtn"),l(this,"closeBtn"),l(this,"countEl"),l(this,"loadingEl"),l(this,"isVisible",!1),l(this,"searchResults",[]),l(this,"currentIndex",-1),l(this,"searchData",[]),l(this,"isComposing",!1),this.ctx=t,this.container=this.createContainer(),this.ctx.containerElement.appendChild(this.container),this.bindEvents(),this.ctx.on("keydown",t=>{if(this.ctx.config.ENABLE_FINDER&&!this.ctx.editing){if((t.ctrlKey||t.metaKey)&&"KeyF"===t.code){t.preventDefault(),this.show();return}if(this.ctx.finding){if("Escape"===t.code){t.preventDefault(),this.hide();return}if("ArrowUp"===t.code||t.shiftKey&&"Enter"===t.key){t.preventDefault(),this.navigatePrevious();return}if("ArrowDown"===t.code||"Enter"===t.key){t.preventDefault(),this.navigateNext();return}}}}),this.ctx.on("setSelector",()=>{this.hide()}),this.ctx.on("outsideMousedown",()=>{this.hide()})}async initSearchData(){this.showLoading(),this.searchData=[],setTimeout(()=>{let{allCellHeaders:t}=this.ctx.header;for(let e=0;e<t.length;e++){let i=t[e];i&&["string","number"].includes(typeof i.text)&&this.searchData.push({rowIndex:0,colIndex:i.colIndex,text:`${i.text}`,type:"header",colKey:i.key})}let{maxColIndex:e,maxRowIndex:i}=this.ctx;for(let t=0;t<=i;t++)for(let i=0;i<=e;i++){let e=this.ctx.database.getVirtualBodyCell(t,i,!1),s=null==e?void 0:e.getText();["string","number"].includes(typeof s)&&this.searchData.push({rowIndex:t,colIndex:i,text:`${s}`,type:"body"})}this.hideLoading()},0)}createContainer(){let t=document.createElement("div");t.className="e-virt-table-finder-bar";let e=document.createElement("div");e.className="e-virt-table-finder-bar-input-wrapper",this.input=document.createElement("input"),this.input.type="text",this.input.className="e-virt-table-finder-bar-input",this.input.placeholder="",e.appendChild(this.input),this.loadingEl=document.createElement("div"),this.loadingEl.className="e-virt-table-finder-bar-loading",this.loadingEl.innerHTML=H,e.appendChild(this.loadingEl),this.countEl=document.createElement("span"),this.countEl.className="e-virt-table-finder-bar-count";let i=document.createElement("div");return i.className="e-virt-table-finder-bar-nav",this.prevBtn=document.createElement("button"),this.prevBtn.className="e-virt-table-finder-bar-nav-btn prev-btn",this.prevBtn.innerHTML=S,this.nextBtn=document.createElement("button"),this.nextBtn.className="e-virt-table-finder-bar-nav-btn next-btn",this.nextBtn.innerHTML=S,i.appendChild(this.prevBtn),i.appendChild(this.nextBtn),this.closeBtn=document.createElement("button"),this.closeBtn.className="e-virt-table-finder-bar-nav-btn close-btn",this.closeBtn.innerHTML="\xd7",t.appendChild(e),t.appendChild(this.countEl),t.appendChild(i),t.appendChild(this.closeBtn),t}bindEvents(){this.input.addEventListener("input",()=>{this.isComposing||this.performSearch()}),this.input.addEventListener("compositionstart",()=>{this.isComposing=!0}),this.input.addEventListener("compositionend",()=>{this.isComposing=!1,this.performSearch()}),this.prevBtn.addEventListener("click",()=>{this.navigatePrevious()}),this.nextBtn.addEventListener("click",()=>{this.navigateNext()}),this.closeBtn.addEventListener("click",()=>{this.hide()})}performSearch(){let t=this.input.value.trim();if(this.searchResults=[],this.currentIndex=-1,!t){this.cearFinderBar(),this.updateCount();return}this.showLoading(),setTimeout(()=>{this.searchResults=this.searchData.filter(e=>e.text.toLowerCase().includes(t.toLowerCase())),this.searchResults.length>0?(this.currentIndex=0,this.scrollToCurrentResult()):this.cearFinderBar(),this.updateCount(),this.hideLoading()},0)}
16scrollToCurrentResult(){if(this.currentIndex<0||this.currentIndex>=this.searchResults.length)return;let t=this.searchResults[this.currentIndex];this.ctx.finderBar=t;let{rowIndex:e,colIndex:i}=t;this.ctx.emit("scrollToIndex",e,i)}navigateNext(){0!==this.searchResults.length&&(this.currentIndex=(this.currentIndex+1)%this.searchResults.length,this.scrollToCurrentResult(),this.updateCount())}navigatePrevious(){0!==this.searchResults.length&&(this.currentIndex=this.currentIndex<=0?this.searchResults.length-1:this.currentIndex-1,this.scrollToCurrentResult(),this.updateCount())}updateCount(){if(0===this.searchResults.length)this.input.value.trim()?(this.countEl.textContent="0/0",this.countEl.classList.add("no-results")):(this.countEl.textContent="",this.countEl.classList.remove("no-results"));else{let t=this.currentIndex+1,e=this.searchResults.length;this.countEl.textContent=`${t}/${e}`,this.countEl.classList.remove("no-results")}}show(){this.isVisible||(this.isVisible=!0,this.ctx.finding=!0,this.container.classList.add("show"),this.input.focus(),this.initSearchData())}showLoading(){var t;this.loadingEl.classList.add("show"),null==(t=this.loadingEl.parentElement)||t.classList.add("loading"),this.input.readOnly=!0}hideLoading(){var t;this.loadingEl.classList.remove("show"),null==(t=this.loadingEl.parentElement)||t.classList.remove("loading"),this.input.readOnly=!1}cearFinderBar(){this.ctx.finderBar={rowIndex:-1,colIndex:-1,text:"",type:"header"},this.ctx.emit("draw")}hide(){this.isVisible&&(this.isVisible=!1,this.container.classList.remove("show"),this.ctx.finding=!1,this.input.value="",this.searchResults=[],this.searchData=[],this.currentIndex=-1,this.hideLoading(),this.ctx.finderBar={rowIndex:-1,colIndex:-1,text:"",type:"header"},this.updateCount(),this.ctx.emit("draw"))}destroy(){this.hide(),this.container.remove()}}class ex{constructor(t){l(this,"ctx"),l(this,"layouts",new Map),l(this,"activeCellKey",""),l(this,"selectionStart",null),l(this,"selectionEnd",null),l(this,"dragging",!1),this.ctx=t,this.init()}get canSelect(){return this.ctx.config.ENABLE_TEXT_SELECTION&&!this.ctx.editing&&!this.ctx.finding}hitTestLayouts(t){let{offsetX:e,offsetY:i}=this.ctx.getOffset(t),s=null;for(let[t,r]of this.layouts){let l=this.hitTestText(r,e,i);null!==l&&(s={cellKey:t,index:l})}return s}syncSelection(){this.ctx.textSelectionStr=this.getSelectedText(),this.ctx.emit("drawView")}init(){this.ctx.on("registerTextLayout",(t,e)=>{this.registerLayout(t,e)}),this.ctx.on("mousedown",t=>{if(!this.canSelect||!this.ctx.isTarget(t))return;this.ctx.containerElement.contains(document.activeElement)||this.ctx.containerElement.focus({preventScroll:!0});let e=this.hitTestLayouts(t);if(!e)return void this.clearSelection();this.activeCellKey=e.cellKey,this.selectionStart=e.index,this.selectionEnd=e.index,this.dragging=!0,this.ctx.textSelecting=!0,this.syncSelection()}),this.ctx.on("mousemove",t=>{if(!this.canSelect||!this.dragging)return;let e=this.layouts.get(this.activeCellKey);if(!e)return;let{offsetX:i,offsetY:s}=this.ctx.getOffset(t),r=this.hitTestText(e,i,s);null!==r&&(this.selectionEnd=r,this.syncSelection())}),this.ctx.on("mouseup",()=>{this.dragging=!1,this.ctx.textSelecting=!1,this.ctx.textSelectionStr=this.getSelectedText(),this.ctx.textSelectionStr&&this.ctx.emit("drawView")}),this.ctx.on("keydown",t=>{var e;if(console.log("keydown"),!this.canSelect||!((t.ctrlKey||t.metaKey)&&"KeyC"===t.code))return;let i=this.getSelectedText();i&&(t.preventDefault(),null==(e=navigator.clipboard)||e.writeText(i).catch(t=>console.error("Copy Failure:",t)))}),this.ctx.on("outsideMousedown",()=>{this.clearSelection()})}hitTestText(t,e,i){let{contentBox:s,lines:r,glyphs:l,contentY:o,lineHeight:h}=t;if(e<s.x||e>s.x+s.width||i<s.y||i>s.y+s.height)return null;let n=Math.max(0,Math.min(Math.floor((i-o)/h),r.length-1)),a=r[n],c=l.filter(t=>t.line===n);if(!c.length)return a.caretIndex;if(e<=c[0].x)return c[0].index;for(let t of c)if(e<t.x+t.width/2)return t.index;return c[c.length-1].index+1}registerLayout(t,e){this.layouts.set(t,e)}clearLayouts(){this.layouts.clear()}draw(){if(!this.ctx.config.ENABLE_TEXT_SELECTION)return;let t=this.getSelectionRange();if(!t)return;let e=this.layouts.get(this.activeCellKey);e&&this.drawTextSelection(e,t)}
16drawTextSelection(t,e,i="#fff",s="#3b82f6"){if(e.start>=e.end)return;let r=new Map;for(let i of t.glyphs){if(i.index<e.start||i.index>=e.end)continue;let t=r.get(i.line);t?t.push(i):r.set(i.line,[i])}if(!r.size)return;let l=this.ctx.paint.getCtx();l.save(),l.font=t.font,l.textBaseline="top",l.textAlign="left",r.forEach(t=>{let e=t[0],r=t[t.length-1];for(let o of(l.fillStyle=s,l.fillRect(e.x,e.y,r.x+r.width-e.x,e.height),l.fillStyle=i,t))l.fillText(o.char,o.x,o.y)}),l.restore()}getSelectionRange(){return null===this.selectionStart||null===this.selectionEnd?null:{start:Math.min(this.selectionStart,this.selectionEnd),end:Math.max(this.selectionStart,this.selectionEnd)}}getSelectedText(){let t=this.getSelectionRange();if(!t||t.start>=t.end)return"";let e=this.layouts.get(this.activeCellKey);return e?e.chars.slice(t.start,t.end).join(""):""}clearSelection(){this.activeCellKey="",this.selectionStart=null,this.selectionEnd=null,this.dragging=!1,this.ctx.textSelectionStr=""}destroy(){this.layouts.clear(),this.clearSelection()}}let eu=class t{constructor(t,e){l(this,"options"),l(this,"scroller"),l(this,"header"),l(this,"body"),l(this,"footer"),l(this,"selector"),l(this,"autofill"),l(this,"tooltip"),l(this,"editor"),l(this,"empty"),l(this,"overlayer"),l(this,"contextMenu"),l(this,"loading"),l(this,"finderBar"),l(this,"textSelector"),l(this,"animationFrameId"),l(this,"ctx"),this.options=e;let{overlayerElement:i,editorElement:s,emptyElement:r,contextMenuElement:o}=this.options,h=this.createContainer(t,i,s,r,o);this.ctx=new P(h,this.options),this.header=new Z(this.ctx),this.footer=new Q(this.ctx),this.body=new J(this.ctx),this.scroller=new $(this.ctx),this.selector=new tt(this.ctx),this.autofill=new te(this.ctx),this.tooltip=new er(this.ctx),this.empty=new eo(this.ctx),this.editor=new el(this.ctx),this.overlayer=new eh(this.ctx),this.contextMenu=new ea(this.ctx),this.loading=new ec(this.ctx),this.finderBar=new ed(this.ctx),this.ctx.on("loadData",t=>{this.loadData(t)}),this.textSelector=new ex(this.ctx),this.ctx.on("draw",()=>{this.draw()}),this.ctx.on("drawView",()=>{this.draw(!0)}),this.draw()}static useLocale(e){t.locale=e}createContainer(t,e,i,s,r){t.className="e-virt-table-container";let l=document.createElement("div"),o=document.createElement("canvas"),h=e||document.createElement("div");l.className="e-virt-table-stage",t.tabIndex=0,o.className="e-virt-table-canvas",h.className="e-virt-table-overlayer",h.setAttribute("data-overlayer",e?"custom"
16:"default");let n=i||document.createElement("div");return n.className="e-virt-table-editor",l.appendChild(o),l.appendChild(h),t.appendChild(l),{containerElement:t,stageElement:l,canvasElement:o,overlayerElement:h,editorElement:n,emptyElement:s,contextMenuElement:r}}doDraw(t=!1){this.header.update(),this.footer.update(),this.body.update(),this.ctx.paint.clear(),this.textSelector.clearLayouts(),this.body.draw(),this.footer.draw(),this.header.draw(),this.textSelector.draw(),this.body.drawDragRowTip(),this.scroller.draw(),this.empty.draw(),this.loading.draw(),t||this.overlayer.draw()}draw(t=!1){this.animationFrameId&&cancelAnimationFrame(this.animationFrameId),this.animationFrameId=requestAnimationFrame(()=>{this.doDraw(t),this.body.updateAutoHeight()&&this.doDraw(t)})}loadConfig(t){this.ctx.config.init(t),this.ctx.database.init(!1),this.header.init(),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")}setCustomHeader(t,e=!0){this.ctx.database.setCustomHeader(t,e),this.header.init(),this.ctx.emit("draw")}getCustomHeader(){return this.header.getCustomHeader()}showColumns(t,e=!0){this.ctx.database.setCustomHeaderHideData(t,!e),this.header.init(),this.ctx.emit("draw")}fixedColumns(t,e){this.ctx.database.setCustomHeaderFixedData(t,e),this.header.init(),this.ctx.emit("draw")}setLoading(t){this.ctx.loading=t,t?this.loading.show():this.loading.hide()}on(t,e){this.ctx.on(t,e)}emit(t,...e){this.ctx.emit(t,...e)}off(t,e){this.ctx.off(t,e)}filterMethod(t){this.ctx.database.setFilterMethod(t),this.ctx.database.init(!1),this.header.init(),this.ctx.emit("draw")}editCell(t,e){this.editor.editCell(t,e)}setItemValue(t,e,i,s=!0,r=!0,l=!1){this.ctx.database.setItemValue(t,e,i,s,r,l)}batchSetItemValue(t,e=!0){this.ctx.database.batchSetItemValue(t,e)}setItemValueByEditor(t,e,i,s=!0,r=!0){this.ctx.setItemValueByEditor(t,e,i,s,r),this.editor.doneEdit()}clearEditableData(t=null){let 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){let e=this.ctx.database.getColumnByColIndex(0);e&&(this.ctx.currentCell=this.ctx.database.getVirtualBodyCellByKey(t,e.key),this.ctx.emit("draw"))}getCurrentRow(){let 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 r=[];for(let e=0;e<t.length;e++){let{rowKey:i,key:s}=t[e],l=await this.ctx.database.getValidator(i,s);Array.isArray(l)&&l.length&&r.push(l)}if(r.length){if(s(r),e){let[t]=r;if(Array.isArray(t)&&t.length){let[e]=t,{rowKey:i,key:s}=e;this.scrollToRowkey(i),this.scrollToColkey(s)}}this.ctx.emit("draw")}else i([]),this.ctx.emit("draw")})}async validate(t=!0){return new Promise(async(e,i)=>{try{let t=await this.getValidations();e(t)}catch(e){if(t&&Array.isArray(e)&&e.length){let[t]=e;if(Array.isArray(t)&&t.length){let[e]=t,{rowKey:i,key:s}=e,r=this.ctx.database.getRowForRowKey(i);if(r){let{parentRowKeys:t=[]}=r;t&&t.length&&this.setExpandRowKeys(t,!0)}this.scrollToRowkey(i),this.scrollToColkey(s)}}i(e)}})}setValidations(t){if(t.forEach(t=>{let{rowIndex:e,key:i,message:s,rowKey:r}=t;if(void 0!==e&&void 0===r){let t=this.ctx.database.getRowKeyForRowIndex(e);this.ctx.database.setValidationErrorByRowKey(t,i,s)}r&&this.ctx.database.setValidationErrorByRowKey(r,i,s)}),t&&Array.isArray(t)&&t.length){let[e]=t;if(e&&e.rowKey)this.scrollToRowkey(e.rowKey),this.scrollToColkey(e.key);else if(e&&void 0!==e.rowIndex&&e.rowIndex>=0&&e.key){let{rowIndex:t,key:i}=e;this.scrollToRowIndex(t),this.scrollToColkey(i)}}}getValidations(){return new Promise(this.ctx.config.DISABLED?t=>{t([])}:async(t,e)=>{let i=this.ctx.database.getAllRowsData(),s=this.ctx.header.leaf
16CellHeaders,r=[];for(let t=0;t<i.length;t++)for(let e=0;e<s.length;e++){let l=this.ctx.database.getRowKeyByItem(i[t]),o=s[e].key,h=await this.ctx.database.getValidator(l,o);Array.isArray(h)&&h.length&&r.push(h)}r.length?e(r):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){let e=this.ctx.database.getRowKeyByItem(t);this.ctx.database.toggleRowSelection(e),this.ctx.emit("draw")}setSelectionByRows(t,e=!0){t.forEach(t=>{let i=this.ctx.database.getRowKeyByItem(t);this.ctx.database.setRowSelection(i,e,!1)}),this.ctx.emit("selectionChange",this.getSelectionRows()),this.ctx.emit("draw")}setSelectionByRowKeys(t,e=!0){t.forEach(t=>{this.ctx.database.setRowSelection(t,e,!1)}),this.ctx.emit("selectionChange",this.getSelectionRows()),this.ctx.emit("draw")}toggleAllSelection(){this.ctx.database.toggleAllSelection(),this.ctx.emit("draw")}toggleRowExpand(t,e){this.ctx.database.expandItem(t,e),this.ctx.emit("draw")}toggleExpandAll(t){this.ctx.database.expandAll(t),this.ctx.emit("draw")}getSelectionRows(){return this.ctx.database.getSelectionRows()}getPositionForRowIndex(t){return this.ctx.database.getPositionForRowIndex(t)}getCellValue(t,e){return this.ctx.database.getItemValue(t,e)}getCellValueByIndex(t,e){return this.ctx.database.getItemValueForRowIndexAndColIndex(t,e)}clearSort(){this.ctx.database.clearSort()}contextMenuHide(){this.contextMenu.hide()}getUtils(){return{mergeColCell:w,mergeRowCell:p,getSpanArrByRow:f,getSpanObjByColumn:m}}getColumnByKey(t){var e;return null==(e=this.ctx.database.getColumnByKey(t))?void 0:e.column}clearChangeData(){this.ctx.database.clearChangeData(),this.ctx.emit("draw")}getReadonly(t,e){return this.ctx.database.getReadonly(t,e)}useLocale(t){this.ctx.locale.use(t)}destroy(){this.overlayer.destroy(),this.empty.destroy(),this.editor.destroy(),this.tooltip.destroy(),this.selector.destroy(),this.autofill.destroy(),this.contextMenu.destroy(),this.loading.destroy(),this.finderBar.destroy(),this.textSelector.destroy(),this.ctx.destroy(),this.ctx.containerElement.remove()}};l(eu,"locale");let eg=eu}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.