@visactor/vtable 0.10.2 → 0.10.3-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/PivotChart.js +26 -25
- package/cjs/PivotChart.js.map +1 -1
- package/cjs/PivotTable.js +8 -8
- package/cjs/PivotTable.js.map +1 -1
- package/cjs/core/BaseTable.js +1 -1
- package/cjs/core/BaseTable.js.map +1 -1
- package/cjs/dataset/dataset-pivot-table.js.map +1 -1
- package/cjs/dataset/dataset.js +4 -5
- package/cjs/dataset/dataset.js.map +1 -1
- package/cjs/dataset/flatDataToObject.js +2 -1
- package/cjs/dataset/flatDataToObject.js.map +1 -1
- package/cjs/header-helper/header-helper.js +1 -0
- package/cjs/header-helper/header-helper.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/layout/chart-helper/get-axis-config.js +7 -7
- package/cjs/layout/chart-helper/get-axis-config.js.map +1 -1
- package/cjs/layout/chart-helper/get-chart-spec.js +4 -4
- package/cjs/layout/chart-helper/get-chart-spec.js.map +1 -1
- package/cjs/layout/pivot-header-layout.js +21 -19
- package/cjs/layout/pivot-header-layout.js.map +1 -1
- package/cjs/layout/pivot-layout.js +4 -3
- package/cjs/layout/pivot-layout.js.map +1 -1
- package/cjs/scenegraph/layout/frozen.js +18 -4
- package/cjs/scenegraph/layout/frozen.js.map +1 -1
- package/cjs/state/spark-line/index.js +3 -2
- package/cjs/state/spark-line/index.js.map +1 -1
- package/dist/vtable.js +103 -71
- package/dist/vtable.min.js +1 -1
- package/es/PivotChart.js +26 -25
- package/es/PivotChart.js.map +1 -1
- package/es/PivotTable.js +8 -8
- package/es/PivotTable.js.map +1 -1
- package/es/core/BaseTable.js +1 -1
- package/es/core/BaseTable.js.map +1 -1
- package/es/dataset/dataset-pivot-table.js.map +1 -1
- package/es/dataset/dataset.js +4 -4
- package/es/dataset/dataset.js.map +1 -1
- package/es/dataset/flatDataToObject.js +2 -1
- package/es/dataset/flatDataToObject.js.map +1 -1
- package/es/header-helper/header-helper.js +1 -0
- package/es/header-helper/header-helper.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/layout/chart-helper/get-axis-config.js +7 -7
- package/es/layout/chart-helper/get-axis-config.js.map +1 -1
- package/es/layout/chart-helper/get-chart-spec.js +4 -4
- package/es/layout/chart-helper/get-chart-spec.js.map +1 -1
- package/es/layout/pivot-header-layout.js +21 -19
- package/es/layout/pivot-header-layout.js.map +1 -1
- package/es/layout/pivot-layout.js +4 -3
- package/es/layout/pivot-layout.js.map +1 -1
- package/es/scenegraph/layout/frozen.js +18 -4
- package/es/scenegraph/layout/frozen.js.map +1 -1
- package/es/state/spark-line/index.js +3 -2
- package/es/state/spark-line/index.js.map +1 -1
- package/package.json +1 -1
package/dist/vtable.min.js
CHANGED
|
@@ -14,4 +14,4 @@ read:function(t,e,i,n,r){var o,s,a=8*r-n-1,l=(1<<a)-1,h=l>>1,c=-7,u=i?r-1:0,d=i?
|
|
|
14
14
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
15
15
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
16
16
|
PERFORMANCE OF THIS SOFTWARE.
|
|
17
|
-
***************************************************************************** */function Qj(t,e,i,n){var r,o=arguments.length,s=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(s=(o<3?r(s):o>3?r(e,i,s):r(e,i))||s);return o>3&&s&&Object.defineProperty(e,i,s),s}const tN=Cx();class eN extends Xx{type="chart";chartInstance;activeChartInstance;active;cacheCanvas;constructor(t){super(t),this.numberType=tN,t.chartInstance?this.chartInstance=t.chartInstance:(t.chartInstance=this.chartInstance=new t.ClassType(t.spec,{renderCanvas:t.canvas,mode:"desktop-browser",canvasControled:!1,viewBox:{x1:0,x2:0,y1:0,y2:0},interactive:!1,animation:!1,autoFit:!1}),this.chartInstance.renderSync())}activate(t){this.active=!0;const{x1:e,y1:i,x2:n,y2:r}=this.getViewBox(),o=t.scenegraph.tableGroup.globalAABBBounds,s=new ep;s.x1=o.x1+t.getFrozenColsWidth(),s.x2=o.x2-t.getRightFrozenColsWidth(),s.y1=o.y1+t.getFrozenRowsHeight(),s.y2=o.y2-t.getBottomFrozenRowsHeight();const a=s.intersect({x1:e-t.scrollLeft,x2:n-t.scrollLeft,y1:i-t.scrollTop,y2:r-t.scrollTop});this.activeChartInstance=new this.attribute.ClassType(this.attribute.spec,{renderCanvas:this.attribute.canvas,mode:"desktop-browser",canvasControled:!1,viewBox:{x1:e-t.scrollLeft,x2:n-t.scrollLeft,y1:i-t.scrollTop,y2:r-t.scrollTop},animation:!1,interactive:!0,autoFit:!1,beforeRender:t=>{const e=t.window.getContext();e.inuse=!0,e.clearMatrix(),e.setTransformForCurrent(!0),e.beginPath(),e.rect(a.x1,a.y1,a.x2-a.x1,a.y2-a.y1),e.clip()},afterRender(t){t.window.getContext().inuse=!1}}),this.activeChartInstance.renderSync(),t.internalProps.layoutMap?.updateDataStateToActiveChartInstance?.(this.activeChartInstance),this.activeChartInstance.on("click",(e=>{console.log("click captured",e),eN.temp&&t.scenegraph.updateChartState(e?.datum)})),this.activeChartInstance.on("brushEnd",(e=>{console.log("brushEnd captured",e),t.scenegraph.updateChartState(e?.value?.inBrushData),eN.temp=0,setTimeout((()=>{eN.temp=1}),0)})),t._bindChartEvent?.(this.activeChartInstance),console.log("active")}static temp=1;deactivate(){this.active=!1,this.activeChartInstance.release(),this.activeChartInstance=null,console.log("deactivate")}updateData(t){this.attribute.data=t}getViewBox(){const t=this.parent,e=this.attribute.cellPadding,i=this.stage.table;return{x1:Math.ceil(t.globalAABBBounds.x1+e[3]+i.scrollLeft),x2:Math.ceil(t.globalAABBBounds.x1+t.attribute.width-e[1]+i.scrollLeft),y1:Math.ceil(t.globalAABBBounds.y1+e[0]+i.scrollTop),y2:Math.ceil(t.globalAABBBounds.y1+t.attribute.height-e[2]+i.scrollTop)}}}const iN=[],nN=[];let rN=5,oN=!1;function sN(t){bu(t)&&(rN=t)}function aN(t){const{axes:e,dataId:i,data:n,spec:r}=t.attribute,{chartInstance:o}=t,s=t.getViewBox();if(e.forEach(((t,e)=>{if("linear"===t.type){o._chart._components[e]._domain={min:t.range?.min??0,max:t.range?.max??0}}else if("band"===t.type){const i=o._chart._components[e];i._spec.domain=t.domain.slice(0),i.updateScaleDomain()}})),o.updateViewBox({x1:s.x1-t.getRootNode().table.scrollLeft,x2:s.x2-t.getRootNode().table.scrollLeft,y1:s.y1-t.getRootNode().table.scrollTop,y2:s.y2-t.getRootNode().table.scrollTop},!1,!1),"string"==typeof i)o.updateDataSync(i,n??[]);else{const t=[];for(const e in i){const s=i[e],a=r.series.find((t=>t?.data?.id===e));t.push({id:e,values:s?n?.filter((t=>t.hasOwnProperty(s)))??[]:n??[],fields:a?.data?.fields}),o.updateFullDataSync||o.updateDataSync(e,s?n?.filter((t=>t.hasOwnProperty(s)))??[]:n??[])}o.updateFullDataSync?.(t)}const a=o.getStage();t.cacheCanvas=a.toCanvas()}function lN(t){oN=!0,nN.length>0?requestAnimationFrame((()=>{const e=nN.splice(0,rN);iN.splice(0,rN),e.forEach((t=>{aN(t),t.addUpdateBoundTag()})),t.render(),lN(t)})):oN=!1}const hN=Symbol.for("ChartRender");let cN=class{type;numberType=tN;drawShape(t,e,i,n,r,o,s,a){const l=Gv(t,o?.theme).group,{dataId:h,data:c,spec:u}=t.attribute;t.getViewBox();const{width:d=l.width,height:p=l.height}=t.attribute,{chartInstance:f,active:g,cacheCanvas:m,activeChartInstance:y}=t;if(!g&&m)e.drawImage(m,i,n,d,p);else if(y)if("string"==typeof h)y.updateDataSync(h,c??[]);else{const t=[];for(const e in h){const i=h[e],n=u.series.find((t=>t?.data?.id===e));t.push({id:e,values:i?c?.filter((t=>t.hasOwnProperty(i)))??[]:c??[],fields:n?.data?.fields}),f.updateFullDataSync||y.updateDataSync(e,i?c?.filter((t=>t.hasOwnProperty(i)))??[]:c??[])}y.updateFullDataSync?.(t)}else t.getRootNode().table.internalProps.renderChartAsync?(-1===iN.indexOf(`${t.parent.col}+${t.parent.row}`)&&(iN.push(`${t.parent.col}+${t.parent.row}`),nN.push(t)),oN||lN(t.getRootNode().table)):aN(t)}draw(t,e,i,n){const{context:r}=i;if(!r)return;const{clip:o}=t.attribute;o?r.save():r.highPerformanceSave(),r.transformFromMatrix(t.transMatrix,!0),r.beginPath(),n.skipDraw?this.drawShape(t,r,0,0,i,n,(()=>!1),(()=>!1)):this.drawShape(t,r,0,0,i),o?r.restore():r.highPerformanceRestore()}};cN=Qj([Vm()],cN);let uN=class{time=Ry.beforeFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,u,d){const{shape:p}=t.attribute;if("circle"===p){const{width:r=l.width,height:o=l.height}=t.attribute;e.beginPath(),e.arc(i+r/2,n+o/2,Math.min(r,o)/2,0,2*Math.PI),e.closePath(),e.save(),e.clip()}}};uN=Qj([Vm()],uN);let dN=class{time=Ry.afterFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,u,d){const{shape:p}=t.attribute;"circle"===p&&e.restore()}};function pN(t,e,i){const{highlightScope:n,disableHeader:r,cellPos:o}=t.hover;if(!t.table.isHeader(e,i)||!r){if(n===Kc.single&&o.col===e&&o.row===i)return"cellBgColor";if(n===Kc.column&&o.col===e)return"inlineColumnBgColor";if(n===Kc.row&&o.row===i)return"inlineRowBgColor";if(n===Kc.cross){if(o.col===e&&o.row===i)return"cellBgColor";if(o.col===e)return"inlineColumnBgColor";if(o.row===i)return"inlineRowBgColor"}}}dN=Qj([Vm()],dN);let fN=class{time=Ry.beforeFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,u,d){const{stroke:p=l.stroke,strokeArrayWidth:f=l.strokeArrayWidth,strokeArrayColor:g=l.strokeArrayColor}=t.attribute;p&&(Array.isArray(f)||Array.isArray(g))&&(d.doStroke=!1)}};fN=Qj([Vm()],fN);let gN=class{time=Ry.afterFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,u){const{width:d=l.width,height:p=l.height,stroke:f=l.stroke,strokeArrayColor:g=l.strokeArrayColor,strokeArrayWidth:m=l.strokeArrayWidth,lineWidth:y=l.lineWidth,strokeColor:b=l.stroke}=t.attribute;if(!f||!Array.isArray(m)&&0===y)return;let v,w;if(Array.isArray(g)||Array.isArray(m)){if("number"==typeof y&&1&y||Array.isArray(m)&&m.some((t=>1&t))){i=Math.floor(i)+.5,n=Math.floor(n)+.5;const{width:e,height:r}=_N(t,Math.ceil(d),Math.ceil(p));v=e,w=r}else v=Math.ceil(d),w=Math.ceil(p);mN(t,e,i,n,l,f,m||y,g||b,v,w)}}};function mN(t,e,i,n,r,o,s,a,l,h,c,u){const d=function(t){if(!Array.isArray(t))return{isSplitDraw:!1,width:t};let e;for(let i=0;i<t.length;i++){const n=t[i];if(n)if(e){if(n!==e)return{isSplitDraw:!0}}else e=n}return{isSplitDraw:!1,width:e}}(s),p=!Array.isArray(s),f=!Array.isArray(o),g=Array.isArray(u),m=Array.isArray(a)||d.isSplitDraw;e.setStrokeStyle(t,t.attribute,i,n,r);let y=!1;e.getLineDash().length&&(y=!0),e.beginPath(),e.moveTo(i,n),(f||o[0])&&(p||s[0])?(g&&Array.isArray(u[0])?(e.moveTo(i+l*u[0][0],n),e.lineTo(i+l*(u[0][1]-u[0][0]),n),e.moveTo(i+l,n)):(e.moveTo(i,n),e.lineTo(i+l,n)),!m&&!y||a&&!a[0]||(a&&(e.strokeStyle=a[0]),p||(e.lineWidth=s[0]),e.lineDashOffset=e.currentMatrix.e/e.currentMatrix.a,e.stroke(),e.beginPath(),e.moveTo(i+l,n))):e.moveTo(i+l,n),(f||o[1])&&(p||s[1])?(g&&Array.isArray(u[1])?(e.moveTo(i+l,n+h*u[1][0]),e.lineTo(i+l,n+h*(u[1][1]-u[1][0])),e.moveTo(i+l,n+h)):(e.moveTo(i+l,n),e.lineTo(i+l,n+h)),!m&&!y||a&&!a[1]||(a&&(e.strokeStyle=a[1]),p||(e.lineWidth=s[1]),e.lineDashOffset=e.currentMatrix.f/e.currentMatrix.d,e.stroke(),e.beginPath(),e.moveTo(i+l,n+h))):e.moveTo(i+l,n+h),(f||o[2])&&(p||s[2])?(g&&Array.isArray(u[2])?(e.moveTo(i+l*u[2][0],n+h),e.lineTo(i+l*(u[2][1]-u[2][0]),n+h),e.moveTo(i,n+h)):(e.moveTo(i,n+h),e.lineTo(i+l,n+h)),!m&&!y||a&&!a[2]||(a&&(e.strokeStyle=a[2]),p||(e.lineWidth=s[2]),e.lineDashOffset=e.currentMatrix.e/e.currentMatrix.a,e.stroke(),e.beginPath(),e.moveTo(i,n+h))):e.moveTo(i,n+h),(f||o[3])&&(p||s[3])?(g&&Array.isArray(u[3])?(e.moveTo(i,n+h*u[3][0]),e.lineTo(i,n+h*(u[3][1]-u[3][0])),e.moveTo(i,n)):(e.moveTo(i,n),e.lineTo(i,n+h)),!m&&!y||a&&!a[3]||(a&&(e.strokeStyle=a[3]),p||(e.lineWidth=s[3]),e.lineDashOffset=e.currentMatrix.f/e.currentMatrix.d,e.stroke(),e.beginPath(),e.moveTo(i,n))):e.moveTo(i,n),m||y||(!p&&d.width&&(e.lineWidth=d.width),e.stroke())}gN=Qj([Vm()],gN);let yN=class{time=Ry.beforeFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,u,d){const{lineDash:p=l.lineDash,stroke:f=l.stroke,strokeArrayColor:g=l.strokeArrayColor,strokeArrayWidth:m=l.strokeArrayWidth}=t.attribute;f&&Array.isArray(p)&&p.length&&!Array.isArray(g)&&!Array.isArray(m)&&(d.doStroke=!1)}};yN=Qj([Vm()],yN);let bN=class{time=Ry.afterFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,u){const{lineDash:d=l.lineDash,stroke:p=l.stroke,strokeArrayColor:f=l.strokeArrayColor,strokeArrayWidth:g=l.strokeArrayWidth,lineWidth:m=l.lineWidth}=t.attribute;if(!p||!Array.isArray(d)||!d.length||Array.isArray(f)||Array.isArray(g))return;let y,b,{width:v=l.width,height:w=l.height}=t.attribute;if(v=Math.ceil(v),w=Math.ceil(w),1&m){i=Math.floor(i)+.5,n=Math.floor(n)+.5;const{width:e,height:r}=_N(t,Math.ceil(v),Math.ceil(w));y=e,b=r}else y=Math.ceil(v),b=Math.ceil(w);e.setStrokeStyle(t,t.attribute,i,n,l),e.beginPath(),e.moveTo(i,n),e.lineTo(i+y,n),e.lineDashOffset=e.currentMatrix.e/e.currentMatrix.a,e.stroke(),e.beginPath(),e.moveTo(i+y,n),e.lineTo(i+y,n+b),e.lineDashOffset=e.currentMatrix.f/e.currentMatrix.d,e.stroke(),e.beginPath(),e.moveTo(i,n+b),e.lineTo(i+y,n+b),e.lineDashOffset=e.currentMatrix.e/e.currentMatrix.a,e.stroke(),e.beginPath(),e.moveTo(i,n),e.lineTo(i,n+b),e.lineDashOffset=e.currentMatrix.f/e.currentMatrix.d,e.stroke()}};bN=Qj([Vm()],bN);let vN=class{time=Ry.beforeFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,u,d){const{lineWidth:p=l.lineWidth,stroke:f=l.stroke,lineDash:g=l.lineDash,strokeArrayWidth:m=l.strokeArrayWidth,strokeArrayColor:y=l.strokeArrayColor}=t.attribute;f&&Array.isArray(g)&&!g.length&&!Array.isArray(y)&&!Array.isArray(m)&&1&p&&(d.doStroke=!1)}};vN=Qj([Vm()],vN);let wN=class{time=Ry.afterFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,u){const{lineWidth:d=l.lineWidth,stroke:p=l.stroke,lineDash:f=l.lineDash,strokeArrayWidth:g=l.strokeArrayWidth,strokeArrayColor:m=l.strokeArrayColor}=t.attribute,{width:y=l.width,height:b=l.height}=t.attribute;if(p&&Array.isArray(f)&&!f.length&&!Array.isArray(m)&&!Array.isArray(g)&&1&d){const{width:r,height:o}=_N(t,Math.ceil(y),Math.ceil(b));e.beginPath(),i=Math.floor(i)+.5,n=Math.floor(n)+.5,e.rect(i,n,r,o),e.setStrokeStyle(t,t.attribute,i,n,l),e.stroke()}}};wN=Qj([Vm()],wN);let CN=class{time=Ry.beforeFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,u,d){if("cell"===t.role){const e=t.stage.table;if(e.stateManeger.interactionState!==Uc.scrolling){const i=function(t,e){let i,n;if("cell"===t.role&&"number"==typeof t.mergeCol&&"number"==typeof t.mergeRow)for(let n=t.col;n<=t.mergeCol;n++)for(let r=t.row;r<=t.mergeRow;r++){const t=pN(e.stateManeger,n,r);!t||i&&"cellBgColor"!==t||(i=t)}else"cell"===t.role&&(i=pN(e.stateManeger,t.col,t.row));if(!i)return;const r=e.internalProps.layoutMap;return r.isCornerHeader(t.col,t.row)?n=e.theme.cornerHeaderStyle?.hover:r.isColumnHeader(t.col,t.row)?n=e.theme.headerStyle?.hover:r.isRowHeader(t.col,t.row)?n=e.theme.rowHeaderStyle?.hover:r.isBottomFrozenRow(t.col,t.row)?n=e.theme.bottomFrozenStyle?.hover||e.theme.headerStyle?.hover:r.isRightFrozenColumn(t.col,t.row)?n=e.theme.rightFrozenStyle?.hover||e.theme.rowHeaderStyle?.hover:e.isHeader(t.col,t.row)||(n=e.theme.bodyStyle?.hover),Cj(i,n,t.col,t.row,e)}(t,e);i&&(t.oldColor=t.attribute.fill,t.attribute.fill=i)}}}};CN=Qj([Vm()],CN);let xN=class{time=Ry.afterFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,u){"oldColor"in t&&(t.attribute.fill=t.oldColor,delete t.oldColor)}};function _N(t,e,i){const n=t.stage.table;if("cell"===t.role){let r=t.col,o=t.row;const s=Sk(n,r,o);s&&(r=s.end.col,o=s.end.row),(n&&r===n.colCount-1||n&&r===n.frozenColCount-1&&n.scrollLeft)&&(e-=1),(n&&o===n.rowCount-1||n&&o===n.frozenRowCount-1&&n.scrollTop)&&(i-=1)}else"corner-frozen"===t.role&&(n.scrollLeft&&(e-=1),n.scrollTop&&(i-=1));return{width:e,height:i}}xN=Qj([Vm()],xN);let SN=class{time=Ry.beforeFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,u,d){const{stroke:p=l.stroke,strokeArrayWidth:f=l.strokeArrayWidth,strokeArrayColor:g=l.strokeArrayColor}=t.attribute;p&&(Array.isArray(p)||Array.isArray(f)||Array.isArray(g))&&(d.doStroke=!1)}};SN=Qj([Vm()],SN);let AN=class{time=Ry.afterFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,u){const{width:d=l.width,height:p=l.height,stroke:f=l.stroke,strokeArrayColor:g=l.strokeArrayColor,strokeArrayWidth:m=l.strokeArrayWidth,lineWidth:y=l.lineWidth,strokeColor:b=l.stroke}=t.attribute;f&&(Array.isArray(m)||0!==y)&&(Array.isArray(f)||Array.isArray(g)||Array.isArray(m))&&(("number"==typeof y&&1&y||Array.isArray(m)&&m.some((t=>1&t)))&&(i=Math.floor(i)+.5,n=Math.floor(n)+.5),mN(t,e,i,n,l,f,m||y,g||b,Math.ceil(d),Math.ceil(p)))}};AN=Qj([Vm()],AN);var TN=new zm(((t,e,i,n)=>{i(KB)?n(KB).to(SN).inSingletonScope():(t(SN).toSelf().inSingletonScope(),t(E_).toService(SN)),i($B)?n($B).to(AN).inSingletonScope():(t(AN).toSelf().inSingletonScope(),t(E_).toService(AN)),t(gN).toSelf().inSingletonScope(),t(B_).toService(gN),t(fN).toSelf().inSingletonScope(),t(B_).toService(fN),t(cN).toSelf().inSingletonScope(),t(hN).to(cN),t(sB).to(cN),t(uN).toSelf().inSingletonScope(),t(M_).toService(uN),t(dN).toSelf().inSingletonScope(),t(M_).toService(dN),t(yN).toSelf().inSingletonScope(),t(B_).toService(yN),t(bN).toSelf().inSingletonScope(),t(B_).toService(bN),t(vN).toSelf().inSingletonScope(),t(B_).toService(vN),t(wN).toSelf().inSingletonScope(),t(B_).toService(wN),t(CN).toSelf().inSingletonScope(),t(B_).toService(CN),t(xN).toSelf().inSingletonScope(),t(B_).toService(xN)}));function BN(t,e,i){if(i._table.isPivotChart())if(i.indicatorsAsCol){if(i.hasTwoIndicatorAxes&&e===i.columnHeaderLevelCount-1&&t>=i.rowHeaderLevelCount&&t<i.colCount-i.rightFrozenColCount){let n=i.getIndicatorKeyInChartSpec(t,i.columnHeaderLevelCount-1)[1];if(qu(n)&&(n=n[0]),!n)return;const r=RN(t,e,"top",i),o=i.dataset.collectedValues[n+(r?"_align":"")]?i.dataset.collectedValues[n+(r?"_align":"")]:i.dataset.collectedValues[n],s=i.getRecordIndexByCol(t),a=o?o[i.getColKeysPath()[s][Math.max(0,i.columnHeaderLevelCount-1-i.topAxesCount)]]:{max:1,min:0},l=MN(t,e,"top",i);if(!1===l?.visible)return;return Qu(l?.min)&&(a.min=l.min),Qu(l?.max)&&(a.max=l.max),fd({range:a},l,{orient:"top",type:"linear",label:{flush:!0}})}if(e===i.rowCount-i.bottomFrozenRowCount&&t>=i.rowHeaderLevelCount&&t<i.colCount-i.rightFrozenColCount){const n=i.getIndicatorKeyInChartSpec(t,e);let r=n[0];qu(r)&&(r=r[0]);const o=RN(t,e,"bottom",i),s=i.dataset.collectedValues[r+(o?"_align":"")]?i.dataset.collectedValues[r+(o?"_align":"")]:i.dataset.collectedValues[r],a=i.getRecordIndexByCol(t),l=s?.[i.getColKeysPath()[a][Math.max(0,i.columnHeaderLevelCount-1-i.topAxesCount)]]??{min:0,max:1};let h=null;n.forEach((t=>{const e=i.getIndicatorInfo(t);e&&(h=e)}));const c=MN(t,e,"bottom",i);if(!1===c?.visible)return;return Qu(c?.min)&&(l.min=c.min),Qu(c?.max)&&(l.max=c.max),fd({title:{visible:!0,text:h?.title},range:l},c,{orient:"bottom",type:"linear",label:{flush:!0}})}if(t===i.rowHeaderLevelCount-1&&e>=i.columnHeaderLevelCount&&e<i.rowCount-i.bottomFrozenRowCount){let n=i.getDimensionKeyInChartSpec(i.rowHeaderLevelCount,e)[0];qu(n)&&(n=n[0]);const r=i.dataset.collectedValues[n]??[],o=i.getRecordIndexByRow(e),s=i.getRowKeysPath()[o],a=r[s[s.length-1]]??[],l=MN(t,e,"left",i);if(!1===l?.visible)return;return fd({domain:Array.from(a).reverse(),title:{autoRotate:!0}},l,{orient:"left",type:"band"})}}else{if(t===i.rowHeaderLevelCount-1&&e>=i.columnHeaderLevelCount&&e<i.rowCount-i.bottomFrozenRowCount){const n=i.getIndicatorKeyInChartSpec(t,e);let r=n[0];qu(r)&&(r=r[0]);const o=RN(t,e,"left",i),s=i.dataset.collectedValues[r+(o?"_align":"")]?i.dataset.collectedValues[r+(o?"_align":"")]:i.dataset.collectedValues[r],a=i.getRecordIndexByRow(e),l=s?.[i.getRowKeysPath()[a][Math.max(0,i.rowHeaderLevelCount-1-i.leftAxesCount)]]??{min:0,max:1};let h=null;n.forEach((t=>{const e=i.getIndicatorInfo(t);e&&(h=e)}));const c=MN(t,e,"left",i);if(!1===c?.visible)return;return Qu(c?.min)&&(l.min=c.min),Qu(c?.max)&&(l.max=c.max),fd({title:{visible:!0,text:h?.title,autoRotate:!0},range:l},c,{orient:"left",type:"linear",label:{flush:!0}})}if(t===i.colCount-i.rightFrozenColCount&&e>=i.columnHeaderLevelCount&&e<i.rowCount-i.bottomFrozenRowCount){let n=i.getIndicatorKeyInChartSpec(i.rowHeaderLevelCount-1,e)[1];if(qu(n)&&(n=n[0]),!n)return;const r=RN(t,e,"right",i),o=i.dataset.collectedValues[n+(r?"_align":"")]?i.dataset.collectedValues[n+(r?"_align":"")]:i.dataset.collectedValues[n],s=i.getRecordIndexByRow(e),a=o?.[i.getRowKeysPath()[s][Math.max(0,i.rowHeaderLevelCount-1-i.leftAxesCount)]]??{min:0,max:1},l=MN(t,e,"right",i);if(!1===l?.visible)return;return Qu(l?.min)&&(a.min=l.min),Qu(l?.max)&&(a.max=l.max),fd({range:a,title:{autoRotate:!0}},l,{orient:"right",type:"linear",label:{flush:!0}})}if(e===i.rowCount-i.bottomFrozenRowCount&&t>=i.rowHeaderLevelCount&&t<i.colCount-i.rightFrozenColCount){let n=i.getDimensionKeyInChartSpec(t,i.columnHeaderLevelCount)[0];qu(n)&&(n=n[0]);const r=i.dataset.collectedValues[n]??[],o=i.getRecordIndexByCol(t),s=i.getColKeysPath()[o],a=r?.[s[s.length-1]]??[],l=MN(t,e,"bottom",i);if(!1===l?.visible)return;return fd({domain:Array.from(a)},l,{orient:"bottom",type:"band"})}}}function MN(t,e,i,n){const r=n.getRawChartSpec(t,e);if(r&&qu(r.axes)){const t=r.axes.find((t=>t.orient===i));if(t)return t}return n._table.pivotChartAxes.find((t=>t.orient===i))}function RN(t,e,i,n){const r=[];"left"===i||"right"===i?r.push("left","right"):"top"!==i&&"bottom"!==i||r.push("top","bottom");const o=n.getRawChartSpec(t,e);let s;if(s=o&&qu(o.axes)?o.axes:n._table.pivotChartAxes,qu(s)){const t=[];s.forEach((e=>{r.includes(e.orient)&&t.push(e)}));for(let e=0;e<t.length;e++){const i=t[e];if(i.sync&&i.sync.zeroAlign&&i.sync.axisId&&t.find((t=>t.id===i.sync.axisId)))return!0}}return!1}function PN(t,e){const i=fd({},cO,t);let n=0;!1!==i.tick.visible&&(n=i.tick.width??4);let r=0;if(i.label.visible){if("band"===i.type){i.domain.forEach((t=>{i.label.formatMethod&&(t=i.label.formatMethod(t));const{width:n,height:o}=e.measureText(t,{fontSize:i.label?.style?.fontSize,fontWeight:i.label?.style?.fontWeight,fontFamily:i.label?.style?.fontFamily}),s=i.label?.style?.maxLineWidth||1/0;r=Math.max(r,LN(Math.min(n,s),o,i.label?.style?.angle).width)}))}else{const t=i.range,n=Math.abs(t.min)>1?Math.round(t.min):t.min,o=Math.abs(t.max)>1?Math.round(t.max):t.max;[HN(n),HN(o)].forEach((t=>{i.label.formatMethod&&(t=i.label.formatMethod(t));const{width:n,height:o}=e.measureText(t,{fontSize:i.label?.style?.fontSize,fontWeight:i.label?.style?.fontWeight,fontFamily:i.label?.style?.fontFamily}),s=i.label?.style?.maxLineWidth||1/0;r=Math.max(r,LN(Math.min(n,s),o,i.label?.style?.angle).width)}))}r+=i.label.space??4}let o=0;if(i.title.visible&&i.title.text){const{width:n,height:r}=e.measureText(i.title.text,{fontSize:i.title?.style?.fontSize,fontWeight:i.title?.style?.fontWeight,fontFamily:i.title?.style?.fontFamily}),s=i.label?.style?.maxLineWidth||1/0,a=LN(Math.min(n,s),r,i.title?.style?.angle);o="left"!==t.orient&&"right"!==t.orient||!i.title.autoRotate?a.width:a.height,o+=i.title.space??4}return n+r+o+2}function EN(t,e){const i=fd({},cO,t);let n=0;!1!==i.tick.visible&&(n=i.tick.width??4);let r=0;if(i.label.visible){if("band"===i.type){i.domain.forEach((t=>{i.label.formatMethod&&(t=i.label.formatMethod(t));const{width:n,height:o}=e.measureText(t,{fontSize:i.label?.style?.fontSize,fontWeight:i.label?.style?.fontWeight,fontFamily:i.label?.style?.fontFamily}),s=i.label?.style?.maxLineWidth||1/0;r=Math.max(r,LN(Math.min(n,s),o,i.label?.style?.angle).height)}))}else{const t=i.range,n=Math.abs(t.min)>1?Math.round(t.min):t.min,o=Math.abs(t.max)>1?Math.round(t.max):t.max;[HN(n),HN(o)].forEach((t=>{i.label.formatMethod&&(t=i.label.formatMethod(t));const{width:n,height:o}=e.measureText(t,{fontSize:i.label?.style?.fontSize,fontWeight:i.label?.style?.fontWeight,fontFamily:i.label?.style?.fontFamily}),s=i.label?.style?.maxLineWidth||1/0;r=Math.max(r,LN(Math.min(n,s),o,i.label?.style?.angle).height)}))}r+=i.label.space??4}let o=0;if(i.title.visible&&i.title.text){const{width:n,height:r}=e.measureText(i.title.text,{fontSize:i.title?.style?.fontSize,fontWeight:i.title?.style?.fontWeight,fontFamily:i.title?.style?.fontFamily}),s=i.label?.style?.maxLineWidth||1/0,a=LN(Math.min(n,s),r,i.title?.style?.angle);o="bottom"!==t.orient&&"top"!==t.orient||!i.title.autoRotate?a.height:a.width,o+=i.title.space??4}return n+r+o+2}function HN(t){return"number"!=typeof t&&(t=Number(t)),Number(t.toPrecision(1)).toString()}function LN(t,e,i=0){const n=i*Math.PI/180,r=-t/2,o=-e/2,s=t/2,a=-e/2,l=t/2,h=e/2,c=-t/2,u=e/2,d={x:r*Math.cos(n)-o*Math.sin(n),y:r*Math.sin(n)+o*Math.cos(n)},p={x:s*Math.cos(n)-a*Math.sin(n),y:s*Math.sin(n)+a*Math.cos(n)},f={x:l*Math.cos(n)-h*Math.sin(n),y:l*Math.sin(n)+h*Math.cos(n)},g={x:c*Math.cos(n)-u*Math.sin(n),y:c*Math.sin(n)+u*Math.cos(n)},m=Math.min(d.x,p.x,f.x,g.x),y=Math.max(d.x,p.x,f.x,g.x),b=Math.min(d.y,p.y,f.y,g.y);return{width:y-m,height:Math.max(d.y,p.y,f.y,g.y)-b}}function kN(t,e,i,n){"undefined"!=typeof window&&window.performance.now(),e=e??0,i=i??t.colCount-1,0===e&&i===t.colCount-1&&t._clearColRangeWidthsMap();const r=[];if(n)for(let e=0;e<t.colCount;e++)r.push(t.getColWidth(e));for(let n=e;n<=i;n++){let e;if(!t.internalProps.transpose&&"only-header"===t.internalProps.layoutMap.columnWidths?.[n]?.columnWidthComputeMode&&"showHeader"in t.internalProps.layoutMap){const i=t.internalProps.layoutMap.showHeader;t.internalProps.layoutMap.showHeader=!0,e=IN(n,0,t.internalProps.layoutMap.headerLevelCount,t,!1),t.internalProps.layoutMap.showHeader=i}else e=t.internalProps.transpose||"only-body"!==t.internalProps.layoutMap.columnWidths?.[n]?.columnWidthComputeMode?IN(n,0,t.rowCount-1,t,!1):IN(n,t.internalProps.layoutMap.getBodyRange().start.row,t.internalProps.layoutMap.getBodyRange().end.row,t,!1);t._setColContentWidth(n,e);t.getColWidth(n)!==e&&t._clearColRangeWidthsMap(n),t.setColWidth(n,e,!1,!0)}if("adaptive"===t.widthMode){t._clearColRangeWidthsMap();const e=t.tableNoFrameWidth-t.getFrozenColsWidth()-t.getRightFrozenColsWidth();let i=0;for(let e=t.frozenColCount;e<t.colCount-t.rightFrozenColCount;e++)i+=t.getColWidth(e);const n=e/i;for(let i=t.frozenColCount;i<t.colCount-t.rightFrozenColCount;i++){let r;r=i===t.colCount-t.rightFrozenColCount-1?e-t.getColsWidth(t.frozenColCount,t.colCount-t.rightFrozenColCount-2):Math.round(t.getColWidth(i)*n),t.setColWidth(i,r,!1,!0)}}else if(t.autoFillWidth){t._clearColRangeWidthsMap();const e=t.tableNoFrameWidth;let i=0,n=0;for(let e=0;e<t.colCount;e++){const r=t.getColWidth(e);(e<t.frozenColCount||e>=t.colCount-t.rightFrozenColCount)&&(n+=r),i+=r}if(i<e&&i-n>0){const r=(e-n)/(i-n);for(let e=t.frozenColCount;e<t.colCount-t.rightFrozenColCount;e++)t.setColWidth(e,t.getColWidth(e)*r,!1,!0)}}if(n)for(let e=0;e<t.colCount;e++){const i=t.getColWidth(e);i!==r[e]&&t.scenegraph.updateColWidth(e,i-r[e])}}function IN(t,e,i,n,r){const o=function(t,e){const i=e.getColWidthDefined(t);if(e.internalProps._widthResizedColMap.has(t))return e.getColWidth(t);return i}(t,n);return"number"==typeof o?o:"auto"!==o&&"string"==typeof o?aj(o,n.internalProps.calcWidthContext):function(t,e,i,n,r,o){let s=0,a=1;n-i>5e3&&(a=Math.ceil((n-i)/5e3));if(o.isPivotChart()&&e>=o.rowHeaderLevelCount){if(o.internalProps.layoutMap.indicatorsAsCol)return o.defaultColWidth;{const t=o.internalProps.layoutMap.getOptimunWidthForChart(e);if(t>0)return t}}for(let r=i;r<=n;r+=a){if(o.isPivotChart()){const t=o.internalProps.layoutMap,i=BN(e,r,t);if(i){const t=PN(i,o);if("number"==typeof t){s=Math.max(t,s);continue}}else if(t.isLeftBottomCorner(e,r)||t.isRightTopCorner(e,r)||t.isRightBottomCorner(e,r))continue}const i=ON(e,r,o);if("number"==typeof i){s=Math.max(i,s);continue}const n=t;if("number"==typeof n&&"standard"===o.widthMode){s=Math.max(n,s);continue}const a=o.isHeader(e,r)?o._getHeaderLayoutMap(e,r)?.headerType:o.getBodyColumnType(e,r);if("text"!==a&&"link"!==a&&"progressbar"!==a){s=Math.max(s,o.getColWidth(e)||0);continue}let l=0;const h=o.internalProps.layoutMap;if(h.isHeader(e,r)){const t=h.getHeader(e,r);if("only-body"===t?.define?.columnWidthComputeMode)continue;t?.hierarchyLevel&&(l=(t.hierarchyLevel??0)*(h.rowHierarchyIndent??0))}else{const t=o.getBodyColumnDefine(e,r);if(t?.tree){const t=o.dataSource.getIndexKey(o.getRecordIndexByRow(e,r));l=Array.isArray(t)&&o.getHierarchyState(e,r)!==Xc.none?(t.length-1)*(h.hierarchyIndent??0):0}}const c=DN(e,r,o);s=Math.max(c+l,s)}const l=o.getMinColWidth(e),h=o.getMaxColWidth(e);if(s<l)return l;if(s>h)return h;return s}(o,t,e,i,0,n)}function ON(t,e,i){const n=i.getCustomRender(t,e),r=i.getCustomLayout(t,e);if(n||r){let o=1,s=0;if(i.isHeader(t,e)||i.getBodyColumnDefine(t,e).mergeCell){const n=i.getCellRange(t,e);o=n.end.col-n.start.col+1}const a={col:t,row:e,dataValue:i.getCellOriginValue(t,e),value:i.getCellValue(t,e)||"",rect:FN(t,e,i),table:i};if(r){const t=r(a);t.rootContainer.isRoot=!0;s=t.rootContainer.getContentSize().width??0}else if("function"==typeof n){const t=n(a);s=t?.expectedWidth??0}else s=n?.expectedWidth??0;return s/o}}function DN(t,e,i){let n=0;const r=i.getCellValue(t,e),o=i._getCellStyle(t,e);let s=0;const a=i.getBodyColumnDefine(t,e);if("body"!==i.getCellLocation(t,e)||(!!a?.icon||!!a?.tree)){const n=i.getCellIcons(t,e);n?.forEach((t=>{t.positionType!==Zc.absoluteRight&&(s+=(t.width??0)+(t.marginLeft??0)+(t.marginRight??0))}))}let l=1;if(i.isHeader(t,e)||i.getBodyColumnDefine(t,e).mergeCell){const n=i.getCellRange(t,e);l=n.end.col-n.start.col+1}const h=RW(Cj("padding",o,t,e,i)),c=h[1]+h[3],u=Cj("fontSize",o,t,e,i),d=Cj("fontFamily",o,t,e,i),p=Cj("fontWeight",o,t,e,i),f=vu(r).split("\n")||[];return f.length>=1?f.forEach((t=>{const e=i.measureText(t.slice(0,i.options.maxCharactersNumber||200),{fontSize:u,fontFamily:d,fontWeight:p}).width;n=Math.max((e+c+4+s)/l,n)})):n=Math.max((c+4+s)/l,n),!1!==i.internalProps.limitMaxAutoWidth&&(n=Math.min("number"==typeof i.internalProps.limitMaxAutoWidth?i.internalProps.limitMaxAutoWidth:450,n)),n}function FN(t,e,i){return{left:0,top:0,right:i.getColWidth(t),bottom:i.getRowHeight(e),width:i.getColWidth(t),height:i.getRowHeight(e)}}const zN=new J_({ignoreBuf:!0}),WN=new dA({width:0,height:0,textConfig:[]});function jN(t,e,i,n=!0,r){"undefined"!=typeof window&&window.performance.now();const o=[];if(r)for(let e=0;e<t.rowCount;e++)o.push(t.getRowHeight(e));if("autoHeight"===t.heightMode||"adaptive"===t.heightMode){e=e??0,i=i??t.rowCount-1,(0===e&&i===t.rowCount-1||n)&&t._clearRowRangeHeightsMap();for(let i=e;i<t.columnHeaderLevelCount;i++){const e=NN(i,0,t.colCount-1,t);t.setRowHeight(i,e)}if(i<t.columnHeaderLevelCount)return;if(t.internalProps.transpose||t.isPivotTable()&&!t.internalProps.layoutMap.indicatorsAsCol||!function(t){const{layoutMap:e}=t.internalProps,i=t.columnHeaderLevelCount;if(t.internalProps.autoWrapText&&("autoHeight"===t.options.heightMode||"adaptive"===t.options.heightMode))return!1;for(let n=0;n<t.colCount;n++){const r=e.getBody(n,i);if("function"==typeof r.style||"function"==typeof r.icon||r.define?.customRender||"function"==typeof r.define?.icon)return!1;const o=t._getCellStyle(n,i);if("function"==typeof o.padding||"function"==typeof o.fontSize||"function"==typeof o.lineHeight||!0===o.autoWrapText)return!1}return!0}(t))if(t.internalProps.transpose||t.isPivotTable()&&!t.internalProps.layoutMap.indicatorsAsCol)for(let n=Math.max(e,t.columnHeaderLevelCount);n<=i;n++){let e;e=GN(t,n)?NN(n,0,t.rowHeaderLevelCount,t):NN(n,0,t.colCount-1,t),t.setRowHeight(n,e)}else for(let n=Math.max(e,t.columnHeaderLevelCount);n<=i;n++){const e=NN(n,0,t.colCount-1,t);t.setRowHeight(n,e)}else{!function(t,e,i,n){for(let r=e;r<=i;r++)n.setRowHeight(r,t)}(NN(t.columnHeaderLevelCount,0,t.colCount-1,t),t.columnHeaderLevelCount,t.rowCount-1-t.bottomFrozenRowCount,t);for(let e=t.rowCount-t.bottomFrozenRowCount;e<=i;e++){const i=NN(e,0,t.colCount-1,t);t.setRowHeight(e,i)}}}if("adaptive"===t.heightMode){t._clearRowRangeHeightsMap();const e=t.tableNoFrameHeight-t.getFrozenRowsHeight()-t.getBottomFrozenRowsHeight();let i=0;for(let e=t.frozenRowCount;e<t.rowCount-t.bottomFrozenRowCount;e++)i+=t.getRowHeight(e);const n=e/i;for(let i=t.frozenRowCount;i<t.rowCount-t.bottomFrozenRowCount;i++){let r;r=i===t.rowCount-t.bottomFrozenRowCount-1?e-t.getRowsHeight(t.frozenRowCount,t.rowCount-t.bottomFrozenRowCount-2):Math.round(t.getRowHeight(i)*n),t.setRowHeight(i,r,!1)}}if(r)for(let e=0;e<t.rowCount;e++){const i=t.getRowHeight(e);i!==o[e]&&t.scenegraph.updateRowHeight(e,i-o[e])}}function NN(t,e,i,n){let r=0;if(n.isPivotChart()&&t>=n.columnHeaderLevelCount&&t<n.rowCount-n.bottomFrozenRowCount){if(!n.internalProps.layoutMap.indicatorsAsCol)return n.getRowHeight(t);{const e=n.internalProps.layoutMap.getOptimunHeightForChart(t);if(e>0)return e}}for(let o=e;o<=i;o++){const e=VN(o,t,n);if("number"==typeof e){r=Math.max(e,r);continue}if(n.isPivotChart()){const e=BN(o,t,n.internalProps.layoutMap);if(e){const t=EN(e,n);if("number"==typeof t){r=Math.max(t,r);continue}}}const i=UN(o,t,n);r=Math.max(i,r)}return r}function GN(t,e){const{layoutMap:i}=t.internalProps;if(t.internalProps.autoWrapText&&("autoHeight"===t.options.heightMode||"adaptive"===t.options.heightMode))return!1;const n=i.getBody(t.rowHeaderLevelCount,e);if("function"==typeof n.style||"function"==typeof n.icon||n.define?.customRender||"function"==typeof n.define?.icon)return!1;const r=t._getCellStyle(t.rowHeaderLevelCount,e);return"function"!=typeof r.padding&&"function"!=typeof r.fontSize&&"function"!=typeof r.lineHeight&&!0!==r.autoWrapText}function VN(t,e,i){const n=i.getCustomRender(t,e),r=i.getCustomLayout(t,e);if(n||r){let o=1,s=0;if(i.isHeader(t,e)||i.getBodyColumnDefine(t,e).mergeCell){const n=i.getCellRange(t,e);o=n.end.col-n.start.col+1}const a={col:t,row:e,dataValue:i.getCellOriginValue(t,e),value:i.getCellValue(t,e)||"",rect:FN(t,e,i),table:i};if(r){const t=r(a);t.rootContainer.isRoot=!0;s=t.rootContainer.getContentSize().height??0}else if("function"==typeof n){const t=n(a);s=t?.expectedHeight??0}else s=n?.expectedHeight??0;return s/o}}function UN(t,e,i){let n=0;const r=i.getCellValue(t,e),o=i._getCellStyle(t,e);let s=0,a=0;const l=[];let h=0;const c=[];let u=0;const d=i.getBodyColumnDefine(t,e);if("body"!==i.getCellLocation(t,e)||(!!d?.icon||!!d?.tree)){const n=i.getCellIcons(t,e);n?.forEach((t=>{t.positionType!==Zc.absoluteRight&&t.positionType!==Zc.inlineFront&&t.positionType!==Zc.inlineEnd?(a+=(t.width??0)+(t.marginLeft??0)+(t.marginRight??0),s=Math.max(s,t.height??0)):t.positionType===Zc.inlineFront?(l.push(t),h=Math.max(h,(t.height??0)+(t.marginLeft??0)+(t.marginRight??0))):t.positionType===Zc.inlineEnd&&(c.push(t),u=Math.max(u,(t.height??0)+(t.marginLeft??0)+(t.marginRight??0)))}))}let p=1,f=t;if(i.isHeader(t,e)||i.getBodyColumnDefine(t,e).mergeCell){const n=i.getCellRange(t,e);p=n.end.row-n.start.row+1,t=n.start.col,f=n.end.col}const g=RW(Cj("padding",o,t,e,i)),m=Cj("fontSize",o,t,e,i),y=Cj("fontStyle",o,t,e,i),b=Cj("fontWeight",o,t,e,i),v=Cj("lineHeight",o,t,e,i)??m,w=Cj("fontFamily",o,t,e,i),C=Cj("autoWrapText",o,t,e,i),x=vu(r).split("\n")||[],_=i.getColsWidth(t,f);if(l.length||c.length){const t=Object.assign({text:r?.toString(),fontFamily:w,fontSize:m,fontStyle:y,fontWeight:b,lineHeight:v});t.textBaseline="middle";const e=[...l.map((t=>kj(t))),t,...c.map((t=>kj(t)))];WN.setAttributes({width:_-(g[1]+g[3])-a,height:0,textConfig:e}),n=WN.AABBBounds.height()}else if(C){const t=_-(g[1]+g[3])-a;zN.setAttributes({maxLineWidth:t,text:x,fontSize:m,fontStyle:y,fontWeight:b,fontFamily:w,lineHeight:v}),n=zN.AABBBounds.height()}else n=x.length*v;return(Math.max(n,s)+g[0]+g[2])/p}const KN=new bj({});KN.role="empty";const $N={},XN={};function YN(t,e,i,n,r,o,s,a,l,h,c,u,d,p,f,g){const m=Up(XN,$N)[c],y=xj("padding",f._getCellStyle(r,o),r,o,f);bu(y)&&(l=y),t||((t=new bj({x:i,y:n,width:s,height:a,lineWidth:g?.group?.lineWidth??void 0,fill:g?.group?.fill??void 0,stroke:g?.group?.stroke??void 0,strokeArrayWidth:g?.group?.strokeArrayWidth??void 0,strokeArrayColor:g?.group?.strokeArrayColor??void 0,cursor:g?.group?.cursor??void 0,lineCap:"square",clip:!0})).role="cell",t.col=r,t.row=o,e?.addChild(t)),t.AABBBounds.width();const b=new eN({stroke:!1,x:l[3],y:l[0],canvas:f.canvas,spec:u,ClassType:m,width:s-l[3]-l[1],height:a-l[2]-l[0],chartInstance:d,dataId:p,data:f.getCellValue(r,o),cellPadding:l,axes:f.internalProps.layoutMap.getChartAxes(r,o)});return t.appendChild(b),f.internalProps.layoutMap.setChartInstance(r,o,b.chartInstance),t}function qN(t,e,i,n,r,o,s,a,l,h,c,u,d,p,f,g){const m=t._getCellStyle(r,o),y=xj("padding",m,r,o,t);bu(y)&&(h=y),g?.text?.textAlign&&(c=g?.text?.textAlign),g?.text?.textBaseline&&(u=g?.text?.textBaseline);const b="autoHeight"===t.heightMode,v="auto"===s,w=m.autoWrapText??t.internalProps.autoWrapText,C=m.lineClamp,x=new bj({x:i,y:n,width:a,height:l,lineWidth:g?.group?.lineWidth??void 0,fill:g?.group?.fill??void 0,stroke:g?.group?.stroke??void 0,strokeArrayWidth:g?.group?.strokeArrayWidth??void 0,strokeArrayColor:g?.group?.strokeArrayColor??void 0,cursor:g?.group?.cursor??void 0,lineCap:"square",clip:!0});if(x.role="cell",x.col=r,x.row=o,e?.addChild(x),p&&x.appendChild(p),f){const e=t.getCellValue(r,o);let i;if(d&&(i=t.getCellIcons(r,o)),function(t,e,i,n,r,o,s,a,l,h,c,u,d,p){const f=[],g=[],m=[],y=[],b=[],v=[],w=[],C=[];let x,_=0,S=0,A=0,T=0,B=0,M=0;if(Array.isArray(e)&&0!==e.length){let R;if(e.forEach((t=>{switch(t.positionType){case Zc.left:f.push(t);break;case Zc.right:g.push(t);break;case Zc.contentLeft:m.push(t);break;case Zc.contentRight:y.push(t);break;case Zc.absoluteRight:C.push(t);break;case Zc.inlineFront:b.push(t);break;case Zc.inlineEnd:v.push(t)}})),f.forEach((e=>{const i=Lj(e,void 0,t.col,t.row,d);i.role="icon-left",i.name=e.name,i.setAttribute("x",_+(i.attribute.marginLeft??0)),_+=i.AABBBounds.width()+(i.attribute.marginLeft??0)+(i.attribute.marginRight??0),S=Math.max(S,i.AABBBounds.height()),t.appendChild(i)})),g.forEach((e=>{const i=Lj(e,void 0,t.col,t.row,d);i.role="icon-right",i.name=e.name,i.setAttribute("x",A+(i.attribute.marginLeft??0)),A+=i.AABBBounds.width()+(i.attribute.marginLeft??0)+(i.attribute.marginRight??0),T=Math.max(T,i.AABBBounds.height()),t.appendChild(i)})),w.forEach((e=>{const i=Lj(e,void 0,t.col,t.row,d);i.role="icon-absolute-left",i.name=e.name,i.setAttribute("x",B+(i.attribute.marginLeft??0)),B+=i.AABBBounds.width()+(i.attribute.marginLeft??0)+(i.attribute.marginRight??0),t.appendChild(i)})),C.forEach((e=>{const i=Lj(e,void 0,t.col,t.row,d);i.role="icon-absolute-right",i.name=e.name,i.setAttribute("x",M+(i.attribute.marginLeft??0)),M+=i.AABBBounds.width()+(i.attribute.marginLeft??0)+(i.attribute.marginRight??0),t.appendChild(i)})),0===b.length&&0===v.length){const t=pu(i).replace(/\r?\n/g,"\n").replace(/\r/g,"\n").split("\n"),e={text:1!==t.length||s?t:t[0],maxLineWidth:r?1/0:l-(n[1]+n[3])-_-A,textBaseline:"top",heightLimit:o?-1:h-(n[0]+n[2]),pickable:!1,autoWrapText:s,lineClamp:a,wordBreak:"break-word"},c=new J_(p.text?Object.assign({},p.text,e):e);c.name="text",R=c}else{const e=Object.assign({text:i?.toString()},t.parent?.theme?.userTheme?.text||{});p.text&&Object.assign(e,p.text),e.textBaseline="middle";const s=[...b.map((t=>kj(t))),e,...v.map((t=>kj(t)))];s[0].textAlign=c;const a=new dA({width:r?0:l-(n[1]+n[3])-_-A,height:o?0:h-(n[0]+n[2]),textConfig:s,verticalDirection:o?"top":u});a.name="text",R=a,a.bindIconEvent()}if(0!==m.length||0!==y.length){const e=new Ej({x:0,y:0,fill:!1,stroke:!1});e.name="content",e.setCellContentOption({autoWidth:r,autoHeight:o,cellWidth:l-(n[1]+n[3])-_-A,cellHeight:h-(n[0]+n[2]),align:c,baseline:u}),m.forEach((i=>{const n=Lj(i,void 0,t.col,t.row,d);n.role="icon-content-left",n.name=i.name,e.addLeftOccupyingIcon(n)})),y.forEach((i=>{const n=Lj(i,void 0,t.col,t.row,d);n.role="icon-content-right",n.name=i.name,e.addRightOccupyingIcon(n)})),e.addContent(R),t.appendChild(e),e.layout(),x=e.AABBBounds.width(),e.AABBBounds.height()}else t.firstChild?t.insertBefore(R,t.firstChild):t.appendChild(R),x=R.AABBBounds.width(),R.AABBBounds.height()}else if(i){const e=pu(i).replace(/\r?\n/g,"\n").replace(/\r/g,"\n").split("\n"),c=Hj(t.col,t.row,d),u={text:1!==e.length||s?e:e[0],maxLineWidth:r?1/0:l-(n[1]+n[3]+c),textBaseline:"top",autoWrapText:s,lineClamp:a,wordBreak:"break-word",heightLimit:o?-1:h-(n[0]+n[2]),pickable:!1,dx:c},f=new J_(p.text?Object.assign({},p.text,u):u);f.name="text",t.appendChild(f),x=f.AABBBounds.width(),f.AABBBounds.height()}const R=r?_+x+A:l-(n[1]+n[3]),P=h-(n[0]+n[2]);t.forEachChildren((t=>{"icon-left"===t.role?t.setAttribute("x",t.attribute.x+n[3]):"icon-right"===t.role?t.setAttribute("x",t.attribute.x+R-A+n[3]):"icon-absolute-right"===t.role?t.setAttribute("x",t.attribute.x+R-M+n[3]+n[1]):"content"!==t.name&&"text"!==t.name||("center"===c&&"richtext"!==t.type?t.setAttribute("x",n[3]+_+(R-_-A)/2):"right"===c&&"richtext"!==t.type?t.setAttribute("x",n[3]+R-A):t.setAttribute("x",n[3]+_))})),t.forEachChildren((t=>{"middle"===u?t.setAttribute("y",n[0]+(P-t.AABBBounds.height())/2):"bottom"===u?t.setAttribute("y",n[0]+P-t.AABBBounds.height()):t.setAttribute("y",n[0])})),t.setAttributes({width:R+n[1]+n[3],height:P+n[0]+n[2]})}(x,i,e,h,v,b,w,"number"==typeof C?C:void 0,a,l,c,u,t,g),g?._vtable?.marked){const t=qA({x:x.attribute.width,y:0,startAngle:Math.PI/2,endAngle:Math.PI,outerRadius:6,fill:"#3073F2",pickable:!1});t.name="mark",x.appendChild(t)}}return p&&x.setAttributes({width:Math.max(x.attribute.width,p.attribute.width),height:Math.max(x.attribute.height,p.attribute.height)}),x}const ZN=yj();function JN(t,e,i){t.then((()=>{i(),e.scenegraph.updateNextFrame()})).catch((t=>{console.error(t)}))}function QN(t,e,i,n,r,o,s,a,l,h,c,u,d,p,f,g,m){let y,b;if(i.internalProps?.dataConfig?.mappingRules&&!i.isHeader(n,r)&&i.internalProps?.dataConfig?.mappingRules?.forEach(((t,e)=>{t.bgColor&&i.internalProps.layoutMap.getIndicatorKey(n,r)===t.bgColor.indicatorKey&&(y=t.bgColor.mapping)})),"text"===t||"link"===t){if("link"===t){const o=i.getCellValue(n,r),s=i._getCellStyle(n,r);"link"===t&&("templateLink"in e&&e.templateLink||!("linkDetect"in e)||!e.linkDetect||_f.test(o))&&(m?(m.text.fill=Cj("linkColor",s,n,r,i),m.group.cursor="pointer"):m={text:{fill:Cj("linkColor",s,n,r,i)},group:{cursor:"pointer"}})}if(y){const t=i.getCellOriginValue(n,r),e=y(i,t);e&&(m?m.group.fill=e:m={group:{fill:e}})}let v,w,C,x=!0;if("body"!==i.getCellLocation(n,r)?(w=e?.headerCustomRender,C=e?.headerCustomLayout):(w=e?.customRender||i.customRender,C=e?.customLayout),C||w){const t=Oj(C,w,n,r,i.getColWidth(n),i.getRowHeight(r),!1,"autoHeight"===i.heightMode,i);v=t.elementsGroup,x=t.renderDefault}b=qN(i,l,0,h,n,r,o,s,a,c,u,d,p,v,x,m),f&&(b.mergeCol=g.end.col,b.mergeRow=g.end.row);const _=i.internalProps.layoutMap.getAxisConfigInPivotChart(n,r);if(_){const t=new hW(_,b.attribute.width,b.attribute.height,i);b.clear(),b.appendChild(t.component),t.overlap()}else i.internalProps.layoutMap.isEmpty(n,r)&&b.clear()}else if("image"===t)b=function(t,e,i,n,r,o,s,a,l,h,c,u,d,p){const f=xj("padding",d._getCellStyle(n,r),n,r,d);bu(f)&&(h=f),p?.text?.textAlign&&(c=p?.text?.textAlign),p?.text?.textBaseline&&(u=p?.text?.textBaseline);const g=new bj({x:e,y:i,width:o,height:s,lineWidth:p?.group?.lineWidth??void 0,fill:p?.group?.fill??void 0,stroke:p?.group?.stroke??void 0,strokeArrayWidth:p?.group?.strokeArrayWidth??void 0,strokeArrayColor:p?.group?.strokeArrayColor??void 0,cursor:p?.group?.cursor??void 0,lineCap:"square",clip:!0});g.role="cell",g.col=n,g.row=r,t?.addChild(g);const m=d.getCellValue(n,r),y=rT({x:h[3],y:h[0],width:o-h[1]-h[3],height:s-h[0]-h[2],image:m,cursor:"pointer"});return y.name="image",y.keepAspectRatio=a,y.successCallback=a||l?()=>{const t=y.resources.get(y.attribute.image).data;if(l&&_j(n,r,t.width,t.height,d.scenegraph,h),a){const{width:e,height:i}=vj(t.width,t.height,g.attribute.width-h[1]-h[3],g.attribute.height-h[0]-h[2]),n=wj(0,0,g.attribute.width,g.attribute.height,e,i,c,u,h);y.setAttributes({x:n.x,y:n.y,width:e,height:i})}d.scenegraph.updateNextFrame()}:()=>{Sj(g,n,r,d)},y.failCallback=()=>{const t=yj();y.image=t.damage_pic.svg},g.appendChild(y),g}(l,0,h,n,r,i.getColWidth(n),i.getRowHeight(r),e.keepAspectRatio,e.imageAutoSizing,c,u,d,i,m);else if("video"===t)b=function(t,e,i,n,r,o,s,a,l,h,c,u,d,p){const f=xj("padding",d._getCellStyle(n,r),n,r,d);bu(f)&&(h=f),p?.text?.textAlign&&(c=p?.text?.textAlign),p?.text?.textBaseline&&(u=p?.text?.textBaseline);const g=new bj({x:e,y:i,width:o,height:s,lineWidth:p?.group?.lineWidth??void 0,fill:p?.group?.fill??void 0,stroke:p?.group?.stroke??void 0,strokeArrayWidth:p?.group?.strokeArrayWidth??void 0,strokeArrayColor:p?.group?.strokeArrayColor??void 0,cursor:p?.group?.cursor??void 0,lineCap:"square",clip:!0});g.role="cell",g.col=n,g.row=r,t?.addChild(g);const m=d.getCellValue(n,r),y=document.createElement("video");y.addEventListener("loadeddata",(()=>{l&&_j(n,r,y.videoWidth,y.videoHeight,d.scenegraph,h);const t=g.attribute.width,e=g.attribute.height;if(a){const{width:i,height:n}=vj(y.videoWidth,y.videoHeight,t-h[1]-h[3],e-h[0]-h[2]),r=wj(0,0,t,e,i,n,c,u,h);b.setAttributes({width:i,height:n,x:r.x,y:r.y})}else b.setAttributes({x:h[3],y:h[0],width:t-h[1]-h[3],height:e-h[2]-h[0]});const i=Math.floor(Math.min(t-h[1]-h[3],e-h[2]-h[0])/2),o=0+(t>b.attribute.width?b.attribute.x-0+b.attribute.width/2:t/2),s=0+(e>b.attribute.height?b.attribute.y-0+b.attribute.height/2:e/2),p=new Pj({x:o-i/2,y:s-i/2,width:i,height:i,image:ZN.play.svg,cursor:ZN.play.cursor});p.name="play-icon",g.appendChild(p),d.scenegraph.updateNextFrame()})),y.onerror=()=>{b.image=ZN.damage_pic.svg},y.src=m,y.setAttribute("preload","auto");const b=rT({x:h[3],y:h[0],width:o-h[1]-h[3],height:s-h[2]-h[0],image:y,cursor:"pointer"});return b.name="image",g.appendChild(b),g}(l,0,h,n,r,i.getColWidth(n),i.getRowHeight(r),e.keepAspectRatio,e.imageAutoSizing,c,u,d,i,m);else if("chart"===t){const t=i.internalProps.layoutMap.getChartInstance(n,r);b=YN(null,l,0,h,n,r,i.getColWidth(n),i.getRowHeight(r),c,i.getCellValue(n,r),e.chartModule,i.isPivotChart()?i.internalProps.layoutMap.getChartSpec(n,r):e.chartSpec,t,i.internalProps.layoutMap?.getChartDataId(n,r)??"data",i,m)}else if("progressbar"===t){const t=i._getCellStyle(n,r),p=i.getCellValue(n,r),f=i.getCellOriginValue(n,r);b=qN(i,l,0,h,n,r,o,s,a,c,u,d,!1,null,!0,m);const g=Aj(e,t,o,p,f,n,r,0,i);b.firstChild?b.insertBefore(g,b.firstChild):b.appendChild(g)}else"sparkline"===t&&(b=Mj(null,l,0,h,n,r,s,a,c,i,m));return b}function tG(t,e,i,n){const r=i.scenegraph.highPerformanceGetCell(t,e,!0);if(!n&&"empty"===r.role)return;const o=i.isHeader(t,e)?i._getHeaderLayoutMap(t,e).headerType:i.getBodyColumnType(t,e),s=i.getCellLocation(t,e),a="body"!==s?i.getHeaderDefine(t,e):i.getBodyColumnDefine(t,e);let l,h,c;if(("body"!==s||a?.mergeCell)&&(h=i.getCellRange(t,e),l=h.start.col!==h.end.col||h.start.row!==h.end.row),!l||t===h.start.col&&e===h.start.row){const u="body"!==s||(!!a?.icon||!!a?.tree),d=pj(i._getCellStyle(t,e),i,t,e,Cj).theme,p=d._vtable.padding,f=d._vtable.textAlign,g=d._vtable.textBaseline;let m,y,b;i.internalProps?.dataConfig?.mappingRules&&!i.isHeader(t,e)&&i.internalProps?.dataConfig?.mappingRules?.forEach(((n,r)=>{n.bgColor&&i.internalProps.layoutMap.getIndicatorKey(t,e)===n.bgColor.indicatorKey&&(m=n.bgColor.mapping)})),"body"!==s?(a?.headerCustomRender,a?.headerCustomLayout):(a?.customRender||i.customRender,a?.customLayout),h?(y=i.getColsWidth(h.start.col,h.end.col),b=i.getRowsHeight(h.start.row,h.end.row)):(y=i.getColWidth(t),b=i.getRowHeight(e));const v=i.getCellValue(t,e);Yp(v)?(r.removeAllChild(),JN(v,i,eG.bind(null,o,a,i,t,e,m,y,b,r,p,f,g,u,l,h,n,d))):c=eG(o,a,i,t,e,m,y,b,r,p,f,g,u,l,h,n,d)}else c=new bj({x:0,y:n?0:r.attribute.y,width:0,height:0,visible:!1,pickable:!1}),c.role="shadow-cell",c.col=t,c.row=e,c.mergeCol=h.start.col,c.mergeRow=h.start.row,n||(r.parent.insertAfter(c,r),r.parent.removeChild(r),tG(h.start.col,h.start.row,i,!1));return c}function eG(t,e,i,n,r,o,s,a,l,h,c,u,d,p,f,g,m){const y=QN(t,e,i,n,r,i.getColWidth(n),s,a,g?i.scenegraph.getColGroup(n):l.parent,g?0:l.attribute.y,h,c,u,d,p,f,m);return g||(l.parent.insertAfter(y,l),l.parent.removeChild(l),i.scenegraph?.proxy.cellCache.get(n)&&i.scenegraph?.proxy.cellCache.set(n,y)),y}function iG(t,e,i,n,r,o,s,a,l,h){let c,u,d,p=0,f=0;t.colHeight&&(f=t.colHeight);for(let g=n;g<=r;g++){const n=g,r="body"!==l?a.getHeaderDefine(e,n):a.getBodyColumnDefine(e,n),m="body"!==l||(!!r?.icon||!!r?.tree),y=pj(a._getCellStyle(e,n),a,e,n,Cj).theme;y.group.width=i,y.group.height=Array.isArray(s)?s[n]:s,y._vtable.padding&&(c=y._vtable.padding),y.text.textAlign&&(u=y.text.textAlign),y.text.textBaseline&&(d=y.text.textBaseline),"body"===l||y.group.fill||(y.group.fill="#fff");let b=i,v=a.getRowHeight(n);const w=(a.isHeader(e,n)?a._getHeaderLayoutMap(e,n).headerType:a.getBodyColumnType(e,n))||"text";let C,x,_;if(("body"!==l||r?.mergeCell)&&(x=a.getCellRange(e,n),_=x.start.col!==x.end.col||x.start.row!==x.end.row,_&&(b=0,v=0,C=o.get(`${x.start.col},${x.start.row};${x.end.col},${x.end.row}`),!C))){for(let t=x.start.col;t<=x.end.col;t++)b+=a.getColWidth(t);for(let t=x.start.row;t<=x.end.row;t++)v+=a.getRowHeight(t);o.set(`${x.start.col},${x.start.row};${x.end.col},${x.end.row}`,{x:0,y:f,cellWidth:b,cellHeight:v})}if(C){const i=C.cellHeight/(x.end.row-x.start.row+1),r=new bj({x:0,y:f,width:0,height:i,visible:!1,pickable:!1});r.role="shadow-cell",r.col=e,r.row=n,r.mergeCol=x.start.col,r.mergeRow=x.start.row,t?.addChild(r),t.updateColumnRowNumber(n),t.updateColumnHeight(i),x=a.getCellRange(e,n),f+=i,p=Math.max(p,C.cellWidth)}else{const o=a.getCellValue(e,n);if(Yp(o)){JN(o,a,QN.bind(null,w,r,a,e,n,i,b,v,t,f,c,u,d,m,_,x,y)),t.updateColumnRowNumber(n);const s=_?a.getRowHeight(n)/(x.end.row-x.start.row+1):a.getRowHeight(n);t.updateColumnHeight(s),f+=s}else{const o=QN(w,r,a,e,n,i,b,v,t,f,c,u,d,m,_,x,y);t.updateColumnRowNumber(n);const s=_?o.attribute.height/(x.end.row-x.start.row+1):o.attribute.height;t.updateColumnHeight(s),f+=s}}if(h&&n>h)break}return t.setAttribute("width",i),{width:i,height:f}}function nG(t,e,i,n,r,o,s,a,l,h){if(n>r||o>s)return;const{layoutMap:c,defaultRowHeight:u,defaultHeaderRowHeight:d,defaultColWidth:p}=l.internalProps;let f=0,g=0;for(let c=n;c<=r;c++){const n=c,r=l.getColWidth(n),p=new bj({x:e+f,y:i,width:r,height:0,clip:!1,pickable:!1});p.role="column",p.col=c,t.addChild(p);const{width:m,height:y}=iG(p,n,r,o,s,l.scenegraph.mergeMap,"columnHeader"===a?d??u:u,l,a,h);f+=m,g=Math.max(g,y)}t.setAttribute("width",f),t.setAttribute("height",g)}function rG(t,e){for(let i=0;i<e.table.colCount;i++){if(i>=e.table.rowHeaderLevelCount&&i<e.colStart||i>e.colEnd&&i<e.table.colCount-e.table.rightFrozenColCount)continue;const n=Sk(e.table,i,t);if(n&&n.start.row!==t){const r=e.highPerformanceGetCell(i,t,!0),o=tG(n.start.col,n.start.row,e.table,!0);o.col=i,o.row=t,o.setAttribute("y",e.table.getRowsHeight(e.table.columnHeaderLevelCount,n.start.row-1)),r.parent.insertAfter(o,r),r.parent.removeChild(r),r.needUpdate=!1,o.needUpdate=!1,e.cellCache.get(i)&&e.cellCache.set(i,o)}}}function oG(t,e,i){for(let n=0;n<i.table.rowCount;n++){if(n>=i.table.columnHeaderLevelCount&&n<i.rowStart||n>i.rowEnd&&n<i.table.rowCount-i.table.bottomFrozenRowCount)continue;const r=Sk(i.table,t,n);if(r&&r.start.col!==t){if(e&&sG(r.start.col,r.end.col,n,i))continue;const o=i.highPerformanceGetCell(t,n,!0),s=tG(r.start.col,r.start.row,i.table,!0);s.col=t,s.row=n,s.setAttribute("x",i.table.getColsWidth(i.table.rowHeaderLevelCount,r.start.col-1)-o.parent.attribute.x),o.parent.insertAfter(s,o),o.parent.removeChild(o),o.needUpdate=!1,s.needUpdate=!1,i.cellCache.get(t)&&i.cellCache.set(t,s)}}}function sG(t,e,i,n){for(let r=t;r<=e;r++)if("shadow-cell"!==n.highPerformanceGetCell(r,i,!0).role&&"empty"!==n.highPerformanceGetCell(r,i,!0).role)return!0;return!1}function aG(t){let e=t.firstChild;for(;"group"!==e.type;)e=e._next;return e}function lG(t){let e=t.lastChild;for(;"group"!==e.type;)e=e._prev;return e}function hG(t,e,i,n="left"){for(let r=t;r<=e;r++){const t=i.scenegraph.getColGroup(r);t&&cG(t,i,n);const e=i.scenegraph.getColGroup(r,!0);e&&cG(e,i,n);const o=i.scenegraph.getColGroupInBottom(r);o&&cG(o,i,n)}const r=Math.min(i.scenegraph.proxy.colLimit,i.scenegraph.proxy.bodyRightCol-i.scenegraph.proxy.bodyLeftCol+1),o=i.getColsWidth(i.rowHeaderLevelCount,i.rowHeaderLevelCount+r),s=i.getColsWidth(i.rowHeaderLevelCount,i.colCount-1);i.scenegraph.proxy.xLimitLeft=o/2,i.scenegraph.proxy.xLimitRight=s-o/2}function cG(t,e,i="left"){if("left"===i){let i;const n=function(t){let e=t._prev;for(;e&&"group"!==e.type;)e=e._prev;return e}(t);i=n?n.attribute.x+e.getColWidth(t._prev.col):e.getColsWidth(e.rowHeaderLevelCount,t.col-1),t.setAttribute("x",i)}else{let i;const n=function(t){let e=t._next;for(;e&&"group"!==e.type;)e=e._next;return e}(t);i=n?n.attribute.x-e.getColWidth(t.col):e.getColsWidth(e.rowHeaderLevelCount,t.col-1),t.setAttribute("x",i)}}async function uG(t,e,i,n,r){if("left"===e&&r.colEnd+t>r.bodyRightCol?t=r.bodyRightCol-r.colEnd:"right"===e&&r.colStart-t<r.bodyLeftCol&&(t=r.colStart-r.bodyLeftCol),!(t<=0))if(t<r.colEnd-r.colStart){const o="left"===e?r.colStart:r.colEnd-t+1,s="left"===e?r.colStart+t-1:r.colEnd,a="left"===e?r.colEnd+1:r.colStart-t,l="left"===e?r.colEnd+t:r.colStart-1;kN(r.table,a,l),function(t,e,i,n){for(let r=t;r<=e;r++)n.table.scenegraph.bodyGroup.childrenCount>0&&fG(n.table.scenegraph.bodyGroup,i,n),n.table.scenegraph.colHeaderGroup.childrenCount>0&&fG(n.table.scenegraph.colHeaderGroup,i,n),n.table.scenegraph.bottomFrozenGroup.childrenCount>0&&fG(n.table.scenegraph.bottomFrozenGroup,i,n)}(o,s,e,r);const h=a,c=l;r.colStart="left"===e?r.colStart+t:r.colStart-t,r.colEnd="left"===e?r.colEnd+t:r.colEnd-t,oG(a,!0,r),gG(h,c,r),hG(h,c,r.table,e);const u=n-(r.table.scenegraph.getColGroup(i).attribute.x+r.table.getFrozenColsWidth()+r.table.scenegraph.proxy.deltaX);r.table.scenegraph.proxy.deltaX+=u,r.currentCol="left"===e?r.currentCol+t:r.currentCol-t,r.totalCol="left"===e?r.totalCol+t:r.totalCol-t,r.referenceCol=r.colStart+Math.floor((r.colEnd-r.colStart)/2),r.colUpdatePos=a,r.colUpdateDirection=e,r.table.scenegraph.updateNextFrame(),await r.progress()}else{const i="left"===e?r.colStart+t:r.colStart-t,n="left"===e?r.colEnd+t:r.colEnd-t;kN(r.table,i,n);!function(t,e,i,n){n.table.scenegraph.colHeaderGroup.forEachChildren(((r,o)=>{"group"===r.type&&dG(r,"left"===i?r.col+e:r.col-e,0===o?t:r._prev.attribute.x+n.table.getColWidth(r._prev.col))})),n.table.scenegraph.bottomFrozenGroup.forEachChildren(((r,o)=>{"group"===r.type&&dG(r,"left"===i?r.col+e:r.col-e,0===o?t:r._prev.attribute.x+n.table.getColWidth(r._prev.col))})),n.table.scenegraph.bodyGroup.forEachChildren(((r,o)=>{"group"===r.type&&dG(r,"left"===i?r.col+e:r.col-e,0===o?t:r._prev.attribute.x+n.table.getColWidth(r._prev.col))}))}(r.table.getColsWidth(r.bodyLeftCol,i-1),t,e,r);const o=i,s=n;r.colStart=i,r.colEnd=n,oG(i,!1,r),gG(o,s,r),hG(o,s,r.table,n>r.bodyRightCol-(r.colEnd-r.colStart+1)?"right":"left"),r.table.scenegraph.proxy.deltaX=0,r.currentCol="left"===e?r.currentCol+t:r.currentCol-t,r.totalCol="left"===e?r.totalCol+t:r.totalCol-t,r.referenceCol=r.colStart+Math.floor((r.colEnd-r.colStart)/2),r.colUpdatePos=r.colStart,r.colUpdateDirection=n>r.bodyRightCol-(r.colEnd-r.colStart+1)?"right":"left",r.table.scenegraph.updateNextFrame(),await r.progress()}}function dG(t,e,i){t.col=e,t.forEachChildren((t=>{t.col=e,t.needUpdate=!0})),t.setAttribute("x",i),t.needUpdate=!0}function pG(t,e){if(!t)return;let i=t.firstChild;for(;i;){i=e.updateCellGroupContent(i)._next}t.needUpdate=!1,t.setAttribute("width",e.table.getColWidth(t.col))}function fG(t,e,i){if("left"===e){const e=aG(t),n=lG(t);dG(e,n.col+1,n.attribute.x+i.table.getColWidth(n.col)),t.appendChild(e),t.border&&t.appendChild(t.border)}else{const e=lG(t),n=aG(t);dG(e,n.col-1,n.attribute.x-i.table.getColWidth(n.col-1)),t.insertBefore(e,t.firstChild)}}function gG(t,e,i){for(let n=t;n<=e;n++){const t=i.table.scenegraph.getColGroup(n);t&&pG(t,i);const e=i.table.scenegraph.getColGroup(n,!0);e&&pG(e,i);const r=i.table.scenegraph.getColGroupInBottom(n);r&&pG(r,i)}}function mG(t,e,i,n,r,o="up"){if("up"===o)for(let o=t;o<=e;o++)for(let t=i;t<=n;t++){const e=r.scenegraph.highPerformanceGetCell(o,t,!0);if(!e.row)continue;let i;i=e._prev?e._prev?.attribute.y+r.getRowHeight(e._prev.row):r.getRowsHeight(r.columnHeaderLevelCount,e.row-1),e.setAttribute("y",i)}else for(let o=t;o<=e;o++)for(let t=n;t>=i;t--){const e=r.scenegraph.highPerformanceGetCell(o,t,!0);if(!e.row)continue;let i;i=e._next?e._next?.attribute.y-r.getRowHeight(e.row):r.getRowsHeight(r.columnHeaderLevelCount,e.row-1),e.setAttribute("y",i)}const s=Math.min(r.scenegraph.proxy.rowLimit,r.scenegraph.proxy.bodyBottomRow-r.scenegraph.proxy.bodyTopRow+1),a=r.getRowsHeight(r.columnHeaderLevelCount,r.columnHeaderLevelCount+s),l=r.getRowsHeight(r.columnHeaderLevelCount,r.rowCount-1);r.scenegraph.proxy.yLimitTop=a/2,r.scenegraph.proxy.yLimitBottom=l-a/2}async function yG(t,e,i,n,r){if("up"===e&&r.rowEnd+t>r.bodyBottomRow?t=r.bodyBottomRow-r.rowEnd:"down"===e&&r.rowStart-t<r.bodyTopRow&&(t=r.rowStart-r.bodyTopRow),t<r.rowEnd-r.rowStart){!function(t,e,i,n){for(let r=0;r<n.table.rowHeaderLevelCount;r++){const o=n.table.scenegraph.getColGroup(r);for(let r=t;r<=e;r++)bG(o,i,n)}for(let r=n.table.colCount-n.table.rightFrozenColCount;r<n.table.colCount;r++){const o=n.table.scenegraph.getColGroup(r);for(let r=t;r<=e;r++)bG(o,i,n)}for(let r=n.bodyLeftCol;r<=n.bodyRightCol;r++){const o=n.table.scenegraph.getColGroup(r);for(let r=t;r<=e;r++)bG(o,i,n)}}("up"===e?r.rowStart:r.rowEnd-t+1,"up"===e?r.rowStart+t-1:r.rowEnd,e,r);const o="up"===e?r.rowEnd+1:r.rowStart-t,s="up"===e?r.rowEnd+t:r.rowStart-1;let a,l;if("autoHeight"===r.table.heightMode)a=o,l=s;else{const t=Math.max(r.bodyTopRow,i-1*r.screenRowCount),e=Math.min(r.bodyBottomRow,i+2*r.screenRowCount);a=Math.max(o,t),l=Math.min(s,e)}if(jN(r.table,a,l),r.rowStart="up"===e?r.rowStart+t:r.rowStart-t,r.rowEnd="up"===e?r.rowEnd+t:r.rowEnd-t,rG(a,r),vG(a,l,r),"autoHeight"===r.table.heightMode){mG(r.bodyLeftCol,r.bodyRightCol,a,l,r.table,e);const t=n-(r.table.scenegraph.highPerformanceGetCell(r.bodyLeftCol,i,!0).attribute.y+r.table.getFrozenRowsHeight()+r.table.scenegraph.proxy.deltaY);r.table.scenegraph.proxy.deltaY+=t}r.currentRow="up"===e?r.currentRow+t:r.currentRow-t,r.totalRow="up"===e?r.totalRow+t:r.totalRow-t,r.referenceRow=r.rowStart+Math.floor((r.rowEnd-r.rowStart)/2),r.rowUpdatePos=o,r.rowUpdateDirection=e,r.table.scenegraph.updateNextFrame(),"autoHeight"!==r.table.heightMode&&await r.progress()}else{const n="up"===e?r.rowStart+t:r.rowStart-t,o="up"===e?r.rowEnd+t:r.rowEnd-t;let s,a;!function(t,e,i,n){for(let r=0;r<n.table.rowHeaderLevelCount;r++){const o=n.table.scenegraph.getColGroup(r);o?.forEachChildren(((r,o)=>{n.updateCellGroupPosition(r,"up"===i?r.row+e:r.row-e,0===o?t:r._prev.attribute.y+n.table.getRowHeight(r._prev.row))}))}for(let r=n.table.colCount-n.table.rightFrozenColCount;r<n.table.colCount;r++){const o=n.table.scenegraph.getColGroup(r);o?.forEachChildren(((r,o)=>{n.updateCellGroupPosition(r,"up"===i?r.row+e:r.row-e,0===o?t:r._prev.attribute.y+n.table.getRowHeight(r._prev.row))}))}for(let r=n.bodyLeftCol;r<=n.bodyRightCol;r++){const o=n.table.scenegraph.getColGroup(r);o?.forEachChildren(((r,o)=>{n.updateCellGroupPosition(r,"up"===i?r.row+e:r.row-e,0===o?t:r._prev.attribute.y+n.table.getRowHeight(r._prev.row))}))}}(r.table.getRowsHeight(r.bodyTopRow,n-1),t,e,r),"autoHeight"===r.table.heightMode?(s=n,a=o):(s=Math.max(r.bodyTopRow,i-1*r.screenRowCount),a=Math.min(r.bodyBottomRow,i+2*r.screenRowCount)),jN(r.table,s,a),r.rowStart=n,r.rowEnd=o,rG(s,r),vG(s,a,r),"autoHeight"===r.table.heightMode&&mG(r.bodyLeftCol,r.bodyRightCol,s,a,r.table,o>r.bodyBottomRow-(r.rowEnd-r.rowStart+1)?"down":"up"),r.table.scenegraph.proxy.deltaY=0,r.currentRow="up"===e?r.currentRow+t:r.currentRow-t,r.totalRow="up"===e?r.totalRow+t:r.totalRow-t,r.referenceRow=r.rowStart+Math.floor((r.rowEnd-r.rowStart)/2),r.rowUpdatePos=r.rowStart,r.rowUpdateDirection=o>r.bodyBottomRow-(r.rowEnd-r.rowStart+1)?"down":"up",r.table.scenegraph.updateNextFrame(),"autoHeight"!==r.table.heightMode&&await r.progress()}}function bG(t,e,i){if("up"===e){const e=t.firstChild;i.updateCellGroupPosition(e,t.lastChild.row+1,t.lastChild.attribute.y+i.table.getRowHeight(t.lastChild.row)),t.appendChild(e)}else{const e=t.lastChild;i.updateCellGroupPosition(e,t.firstChild.row-1,t.firstChild.attribute.y-i.table.getRowHeight(e.row)),t.insertBefore(e,t.firstChild)}}function vG(t,e,i){for(let n=0;n<i.table.rowHeaderLevelCount;n++)for(let r=t;r<=e;r++){const t=i.highPerformanceGetCell(n,r,!0);i.updateCellGroupContent(t)}for(let n=i.table.colCount-i.table.rightFrozenColCount;n<i.table.colCount;n++)for(let r=t;r<=e;r++){const t=i.highPerformanceGetCell(n,r);i.updateCellGroupContent(t)}for(let n=i.bodyLeftCol;n<=i.bodyRightCol;n++)for(let r=t;r<=e;r++){const t=i.highPerformanceGetCell(n,r);i.updateCellGroupContent(t)}}class wG{table;mode="column";rowLimit=1e3;currentRow=0;totalRow;yLimitTop;yLimitBottom;rowStart=0;rowEnd=0;referenceRow=0;bodyTopRow;bodyBottomRow;screenRowCount;firstScreenRowLimit;taskRowCount;rowUpdatePos;rowUpdateDirection;screenTopRow=0;deltaY=0;colLimit=100;bodyLeftCol;bodyRightCol;totalCol;colStart;colEnd;taskColCount;xLimitLeft;xLimitRight;screenColCount;firstScreenColLimit;colUpdatePos;currentCol;referenceCol;screenLeftCol=0;colUpdateDirection;deltaX=0;cellCache=new Map;constructor(t){this.table=t,this.table.isPivotChart()?(this.rowLimit=100,this.colLimit=100):"autoHeight"===this.table.heightMode?this.rowLimit=100:"autoWidth"===this.table.widthMode&&(this.colLimit=100),this.table.internalProps.transpose?this.mode="row":this.table.isPivotTable()&&(this.mode="pivot"),this.table.options.maintainedDataCount&&(this.rowLimit=this.table.options.maintainedDataCount)}setParamsForColumn(){this.bodyLeftCol=this.table.rowHeaderLevelCount,this.bodyRightCol=this.table.colCount-1-this.table.rightFrozenColCount;const t=Math.min(this.colLimit,this.bodyRightCol-this.bodyLeftCol+1);this.totalCol=this.bodyLeftCol+t-1,this.colStart=this.bodyLeftCol;const e=this.table.defaultColWidth;this.taskColCount=1*Math.ceil(this.table.tableNoFrameWidth/e);const i=e*t,n=e*(this.bodyRightCol-this.bodyLeftCol+1);this.xLimitLeft=i/2,this.xLimitRight=n-i/2;const r=5*this.table.tableNoFrameWidth;this.screenColCount=Math.ceil(this.table.tableNoFrameWidth/e),this.firstScreenColLimit=this.bodyLeftCol+Math.ceil(r/e),this.colUpdatePos=this.bodyRightCol}setParamsForRow(){this.bodyTopRow=this.table.columnHeaderLevelCount,this.bodyBottomRow=this.table.rowCount-1-this.table.bottomFrozenRowCount;const t=Math.min(this.rowLimit,this.bodyBottomRow-this.bodyTopRow+1);this.totalRow=this.bodyTopRow+t-1,this.rowStart=this.bodyTopRow;const e=this.table.defaultRowHeight;this.taskRowCount=1*Math.ceil(this.table.tableNoFrameHeight/e);const i=e*t,n=e*(this.bodyBottomRow-this.bodyTopRow+1);this.yLimitTop=i/2,this.yLimitBottom=n-i/2;const r=5*this.table.tableNoFrameHeight;this.screenRowCount=Math.ceil(this.table.tableNoFrameHeight/e),this.firstScreenRowLimit=this.bodyTopRow+Math.ceil(r/e),this.rowUpdatePos=this.bodyBottomRow}async createGroupForFirstScreen(t,e,i,n,r,o,s,a){await async function(t,e,i,n,r,o,s,a,l){const{leftBottomCornerGroup:h,rightTopCornerGroup:c,rightBottomCornerGroup:u}=l.table.scenegraph;l.setParamsForRow(),l.setParamsForColumn(),kN(l.table,0,Math.min(l.firstScreenColLimit,l.table.colCount-1)),jN(l.table,0,Math.min(l.firstScreenRowLimit,l.table.rowCount-1)),l.table.rightFrozenColCount>0&&l.table.colCount-1>l.firstScreenColLimit&&kN(l.table,l.table.colCount-1-l.table.rightFrozenColCount+1,l.table.colCount-1),l.table.bottomFrozenRowCount>0&&l.table.rowCount-1>l.firstScreenRowLimit&&kN(l.table,l.table.rowCount-1-l.table.bottomFrozenRowCount+1,l.table.rowCount-1),l.table.scenegraph.colHeaderGroup.setAttribute("x",l.table.getFrozenColsWidth()),l.table.scenegraph.rowHeaderGroup.setAttribute("y",l.table.getFrozenRowsHeight()),l.table.scenegraph.bottomFrozenGroup.setAttribute("x",l.table.getFrozenColsWidth()),l.table.scenegraph.rightFrozenGroup.setAttribute("y",l.table.getFrozenRowsHeight()),l.table.scenegraph.bodyGroup.setAttributes({x:l.table.getFrozenColsWidth(),y:l.table.getFrozenRowsHeight()}),nG(t,s,a,0,l.table.rowHeaderLevelCount-1,0,l.table.columnHeaderLevelCount-1,"cornerHeader",l.table),nG(e,s,a,l.table.rowHeaderLevelCount,Math.min(l.firstScreenColLimit,l.table.colCount-1-l.table.rightFrozenColCount),0,l.table.columnHeaderLevelCount-1,"columnHeader",l.table),nG(i,s,a,0,l.table.rowHeaderLevelCount-1,l.table.columnHeaderLevelCount,Math.min(l.firstScreenRowLimit,l.table.rowCount-1-l.table.bottomFrozenRowCount),"rowHeader",l.table),l.table.bottomFrozenRowCount>0&&(l.table.isPivotChart()||nG(h,s,a,0,l.table.rowHeaderLevelCount-1,l.table.rowCount-1-l.table.bottomFrozenRowCount+1,l.table.rowCount-1,"rowHeader",l.table),nG(r,s,a,l.table.rowHeaderLevelCount,Math.min(l.firstScreenColLimit,l.table.colCount-1-l.table.rightFrozenColCount),l.table.rowCount-1-l.table.bottomFrozenRowCount+1,l.table.rowCount-1,"body",l.table)),l.table.rightFrozenColCount>0&&(l.table.isPivotChart()||nG(c,s,a,l.table.colCount-1-l.table.rightFrozenColCount+1,l.table.colCount-1,0,l.table.columnHeaderLevelCount-1,"columnHeader",l.table),nG(n,s,a,l.table.colCount-1-l.table.rightFrozenColCount+1,l.table.colCount-1,l.table.columnHeaderLevelCount,Math.min(l.firstScreenRowLimit,l.table.rowCount-1-l.table.bottomFrozenRowCount),"body",l.table)),l.table.bottomFrozenRowCount>0&&l.table.rightFrozenColCount>0&&!l.table.isPivotChart()&&nG(u,s,a,l.table.colCount-1-l.table.rightFrozenColCount+1,l.table.colCount-1,l.table.rowCount-1-l.table.bottomFrozenRowCount+1,l.table.rowCount-1,"body",l.table),nG(o,s,a,l.table.rowHeaderLevelCount,Math.min(l.firstScreenColLimit,l.table.colCount-1-l.table.rightFrozenColCount),l.table.columnHeaderLevelCount,Math.min(l.firstScreenRowLimit,l.table.rowCount-1-l.table.bottomFrozenRowCount),"body",l.table),o.firstChild?(l.currentRow=o.firstChild?.rowNumber??l.totalRow,l.rowEnd=l.currentRow,l.rowUpdatePos=l.rowEnd,l.referenceRow=l.rowStart+Math.floor((l.rowEnd-l.rowStart)/2),l.currentCol=o.lastChild?.col??l.totalCol,l.colEnd=l.currentCol,l.colUpdatePos=l.colEnd,l.referenceCol=l.colStart+Math.floor((l.colEnd-l.colStart)/2),await l.progress()):(l.currentRow=l.totalRow,l.rowEnd=l.currentRow,l.rowUpdatePos=l.rowEnd,l.referenceRow=l.rowStart+Math.floor((l.rowEnd-l.rowStart)/2),l.currentCol=l.totalCol,l.colEnd=l.currentCol,l.colUpdatePos=l.colEnd,l.referenceCol=l.colStart+Math.floor((l.colEnd-l.colStart)/2))}(t,e,i,n,r,o,s,a,this)}async progress(){return new Promise(((t,e)=>{setTimeout((async()=>{this.colUpdatePos<this.colEnd?(await this.updateColCellGroupsAsync(),await this.progress()):this.rowUpdatePos<this.rowEnd?(await this.updateRowCellGroupsAsync(),await this.progress()):this.currentCol<this.totalCol?(await this.createCol(),await this.progress()):this.currentRow<this.totalRow&&(await this.createRow(),await this.progress()),t()}),0)}))}async createRow(){this.taskRowCount&&(console.log("createRow",this.currentRow,this.currentRow+this.taskRowCount),this.createRowCellGroup(this.taskRowCount))}async createCol(){this.taskColCount&&(console.log("createCol",this.currentCol,this.currentCol+this.taskColCount),this.createColGroup(this.taskRowCount))}createRowCellGroup(t){const e=Math.min(this.totalRow,this.currentRow+t);if(jN(this.table,this.currentRow+1,e,!1),this.table.rowHeaderLevelCount){let t=0;for(let i=0;i<this.table.rowHeaderLevelCount;i++){const n=this.table.scenegraph.getColGroup(i),r="rowHeader",{height:o}=iG(n,i,n.attribute.width,this.currentRow+1,e,this.table.scenegraph.mergeMap,this.table.internalProps.defaultRowHeight,this.table,r);t=Math.max(t,o),this.table.scenegraph.rowHeaderGroup.setAttribute("height",t)}}if(this.table.rightFrozenColCount){let t=0;for(let i=this.table.colCount-this.table.rightFrozenColCount;i<this.table.colCount;i++){const n=this.table.scenegraph.getColGroup(i),r="rowHeader",{height:o}=iG(n,i,n.attribute.width,this.currentRow+1,e,this.table.scenegraph.mergeMap,this.table.internalProps.defaultRowHeight,this.table,r);t=Math.max(t,o),this.table.scenegraph.rightFrozenGroup.setAttribute("height",t)}}let i=0;for(let t=this.bodyLeftCol;t<=this.bodyRightCol;t++){const n=this.table.scenegraph.getColGroup(t),r="body",{height:o}=iG(n,t,n.attribute.width,this.currentRow+1,e,this.table.scenegraph.mergeMap,this.table.internalProps.defaultRowHeight,this.table,r);i=Math.max(i,o)}this.table.scenegraph.bodyGroup.setAttribute("height",i),this.currentRow=e,this.rowEnd=e,this.rowUpdatePos=this.rowEnd,this.referenceRow=this.rowStart+Math.floor((e-this.rowStart)/2),this.table.scenegraph.updateContainer(),this.table.scenegraph.updateBorderSizeAndPosition()}createColGroup(t){const e=Math.min(this.totalCol,this.currentCol+t);kN(this.table,this.currentCol+1,e);for(let t=0;t<this.table.rowCount;t++){const e=this.highPerformanceGetCell(this.currentCol,t);Qu(e.mergeCol)&&e.mergeCol>this.currentCol&&this.table.scenegraph.updateCellContent(e.col,e.row)}if(this.table.columnHeaderLevelCount){const t=this.table.scenegraph.colHeaderGroup.lastChild instanceof bj?this.table.scenegraph.colHeaderGroup.lastChild:this.table.scenegraph.colHeaderGroup.lastChild._prev,i=t.attribute.x+t.attribute.width,n=t.attribute.y;nG(this.table.scenegraph.colHeaderGroup,i,n,this.currentCol+1,e,0,this.table.columnHeaderLevelCount-1,"columnHeader",this.table)}if(this.table.bottomFrozenRowCount){const t=this.table.scenegraph.bottomFrozenGroup.lastChild instanceof bj?this.table.scenegraph.bottomFrozenGroup.lastChild:this.table.scenegraph.bottomFrozenGroup.lastChild._prev,i=t.attribute.x+t.attribute.width,n=t.attribute.y;nG(this.table.scenegraph.bottomFrozenGroup,i,n,this.currentCol+1,e,this.table.rowCount-this.table.bottomFrozenRowCount,this.table.rowCount-1,"columnHeader",this.table)}const i=this.table.scenegraph.bodyGroup.lastChild instanceof bj?this.table.scenegraph.bodyGroup.lastChild:this.table.scenegraph.bodyGroup.lastChild._prev,n=i.attribute.x+i.attribute.width,r=i.attribute.y;nG(this.table.scenegraph.bodyGroup,n,r,this.currentCol+1,e,this.rowStart,this.rowEnd,"body",this.table),this.currentCol=e,this.colEnd=e,this.colUpdatePos=this.colEnd,this.referenceCol=this.colStart+Math.floor((e-this.colStart)/2),console.log("async",this.referenceCol,this.colStart,this.colEnd),this.table.scenegraph.updateContainer(),this.table.scenegraph.updateBorderSizeAndPosition()}async setY(t){t<this.yLimitTop&&this.rowStart===this.bodyTopRow||t>this.yLimitBottom&&this.rowEnd===this.bodyBottomRow?this.table.scenegraph.setBodyAndRowHeaderY(-t):this.dynamicSetY(t)}async setX(t){t<this.xLimitLeft&&this.colStart===this.bodyLeftCol||t>this.xLimitRight&&this.colEnd===this.bodyRightCol?this.table.scenegraph.setBodyAndColHeaderX(-t):this.dynamicSetX(t)}async dynamicSetY(t){!async function(t,e){const i=e.table.getTargetRowAt(t+e.table.scenegraph.colHeaderGroup.attribute.height);if(!i)return;const n=i.row,r=i.top;e.screenTopRow=n;const o=n-e.referenceRow;o>0?(yG(o,"up",n,r,e),e.updateBody(t-e.deltaY)):o<0?(yG(-o,"down",n,r,e),e.updateBody(t-e.deltaY)):e.updateBody(t-e.deltaY),e.table.scenegraph.updateNextFrame()}(t,this)}async dynamicSetX(t){!async function(t,e){const i=e.table.getTargetColAt(t+e.table.scenegraph.rowHeaderGroup.attribute.width);if(!i)return;const n=i.col,r=i.left;e.screenLeftCol=n;const o=e.screenLeftCol-e.referenceCol;o>0?(uG(o,"left",e.screenLeftCol,r,e),e.table.scenegraph.setBodyAndColHeaderX(-t+e.deltaX)):o<0?(uG(-o,"right",e.screenLeftCol,r,e),e.table.scenegraph.setBodyAndColHeaderX(-t+e.deltaX)):e.table.scenegraph.setBodyAndColHeaderX(-t+e.deltaX),e.table.scenegraph.updateNextFrame()}(t,this)}updateBody(t){this.table.scenegraph.setBodyAndRowHeaderY(-t)}async updateRowCellGroupsAsync(){this.updateCellGroups(this.taskRowCount)}updateCellGroups(t){const e=Math.min(this.bodyBottomRow,this.rowUpdatePos+t);"autoHeight"===this.table.heightMode&&jN(this.table,this.rowUpdatePos,e,!1),vG(this.rowUpdatePos,e,this),"autoHeight"===this.table.heightMode&&mG(this.bodyLeftCol,this.bodyRightCol,this.rowUpdatePos,e,this.table,this.rowUpdateDirection),this.rowUpdatePos=e+1}async updateColCellGroupsAsync(){this.updateColGroups(this.taskRowCount)}updateColGroups(t){const e=Math.min(this.bodyRightCol,this.colUpdatePos+t);kN(this.table,this.colUpdatePos,e),gG(this.colUpdatePos,e,this),this.colUpdatePos=e+1}updateCellGroupPosition(t,e,i){t.row=e,t.setAttribute("y",i),t.needUpdate=!0,t.needUpdateForAutoRowHeight=!0}updateCellGroupContent(t){if(!t.needUpdate)return t;const e=this.table.scenegraph.updateCellContent(t.col,t.row);return t.needUpdate=!1,e||t}async sortCellVertical(){await async function(t){for(let e=t.bodyLeftCol;e<=t.bodyRightCol;e++)for(let i=t.rowStart;i<=t.rowEnd;i++)t.highPerformanceGetCell(e,i).needUpdate=!0;let e,i;"autoHeight"===t.table.heightMode?(e=t.rowStart,i=t.rowEnd):(e=Math.max(t.bodyTopRow,t.screenTopRow-1*t.screenRowCount),i=Math.min(t.bodyBottomRow,t.screenTopRow+2*t.screenRowCount)),jN(t.table,e,i),vG(e,i,t),"autoHeight"===t.table.heightMode&&mG(t.bodyLeftCol,t.bodyRightCol,e,i,t.table,t.rowEnd>t.bodyBottomRow-(t.rowEnd-t.rowStart+1)?"down":"up"),t.rowUpdatePos=t.rowStart,t.rowUpdateDirection=t.rowEnd>t.bodyBottomRow-(t.rowEnd-t.rowStart+1)?"down":"up",t.table.scenegraph.updateNextFrame(),"autoHeight"!==t.table.heightMode&&await t.progress()}(this)}async sortCellHorizontal(){await async function(t){for(let e=t.colStart;e<=t.colEnd;e++){const i=t.table.scenegraph.getColGroup(e);i.needUpdate=!0,i?.forEachChildren((t=>{t.needUpdate=!0}))}const e=Math.max(t.bodyLeftCol,t.screenLeftCol-1*t.screenColCount),i=Math.min(t.bodyRightCol,t.screenLeftCol+2*t.screenColCount);kN(t.table,e,i),gG(e,i,t),t.colUpdatePos=t.colStart,t.colUpdateDirection=t.colEnd>t.bodyRightCol-(t.colEnd-t.colStart+1)?"right":"left",t.table.scenegraph.updateNextFrame(),await t.progress()}(this)}highPerformanceGetCell(t,e,i){if(e>=this.table.columnHeaderLevelCount&&e<this.table.rowCount-this.table.bottomFrozenRowCount&&(e<this.rowStart||e>this.rowEnd))return KN;if(t>=this.table.rowHeaderLevelCount&&t<this.table.colCount-this.table.rightFrozenColCount&&(t<this.colStart||t>this.colEnd))return KN;if(this.cellCache.get(t)){const n=this.cellCache.get(t);if((n._next||n._prev)&&Math.abs(n.row-e)<e){let r=CG(n,e);return r&&(i||"shadow-cell"!==r.role)||(r=this.table.scenegraph.getCell(t,e,i)),r.row&&this.cellCache.set(t,r),r}const r=this.table.scenegraph.getCell(t,e,i);return r.col===t&&r.row&&this.cellCache.set(t,r),r}const n=this.table.scenegraph.getCell(t,e,i);return n.col===t&&n.row&&this.cellCache.set(t,n),n}}function CG(t,e){return t?t.row===e?t:t.row>e?CG(t._prev,e):CG(t._next,e):null}function xG(t,e,i){const[n,r,o,s]=e.split("-"),a=parseInt(n,10),l=parseInt(r,10),h=parseInt(o,10),c=parseInt(s,10);let u;for(let t=a;t<=h;t++)for(let e=l;e<=c;e++){const n=i.highPerformanceGetCell(t,e);if("cell"!==n.role)continue;n.AABBBounds.width();const r=n.globalAABBBounds;u?u.union(r):u=r}u?t.rect.setAttributes({x:u.x1-i.tableGroup.attribute.x,y:u.y1-i.tableGroup.attribute.y,width:u.width(),height:u.height(),visible:!0}):t.rect.setAttributes({visible:!1});const d=a===i.table.frozenColCount,p=l===i.table.frozenRowCount;d&&t.rect.attribute.stroke[3]||p&&t.rect.attribute.stroke[0]?(d&&i.tableGroup.insertAfter(t.rect,"columnHeader"===t.role?i.cornerHeaderGroup:i.rowHeaderGroup),p&&i.tableGroup.insertAfter(t.rect,"rowHeader"===t.role?i.cornerHeaderGroup:i.colHeaderGroup),t.rect.attribute.x<i.rowHeaderGroup.attribute.width&&i.table.scrollLeft>0&&("body"===t.role||"columnHeader"===t.role)&&t.rect.setAttributes({x:t.rect.attribute.x+(i.rowHeaderGroup.attribute.width-t.rect.attribute.x),width:t.rect.attribute.width-(i.rowHeaderGroup.attribute.width-t.rect.attribute.x)}),t.rect.attribute.y<i.colHeaderGroup.attribute.height&&i.table.scrollTop>0&&("body"===t.role||"rowHeader"===t.role)&&t.rect.setAttributes({y:t.rect.attribute.y+(i.colHeaderGroup.attribute.height-t.rect.attribute.y),height:t.rect.attribute.height-(i.colHeaderGroup.attribute.height-t.rect.attribute.y)})):i.tableGroup.insertAfter(t.rect,"body"===t.role?i.bodyGroup:"columnHeader"===t.role?i.colHeaderGroup:"rowHeader"===t.role?i.rowHeaderGroup:i.cornerHeaderGroup)}function _G(t,e,i){const n=i.scenegraph,r=SG(t.map((t=>t.row))).sort(((t,e)=>t-e)),o=SG(e.map((t=>t.row))).sort(((t,e)=>t-e));r.forEach((t=>{!function(t,e){for(let i=0;i<e.table.colCount;i++){const n=e.getColGroup(i,!1);let r;n.forEachChildren((e=>e.row===t&&(r=e,!0))),r&&n.removeChild(r)}}(t,n)})),r.length&&function(t){for(let e=0;e<t.table.colCount;e++){const i=t.getColGroup(e,!0),n=t.getColGroup(e,!1);let r=i.firstChild?.row;i.forEachChildren((t=>{t.row=r,r++})),r=n.firstChild?.row,n.forEachChildren((t=>{t.row=r,r++}))}}(n),o.forEach((t=>{!function(t,e){for(let i=0;i<e.table.colCount;i++){const n=tG(i,t,e.table,!0);if(!n)continue;const r=e.getColGroup(i);if(r.firstChild&&t<r.firstChild.row)r.insertBefore(n,r.firstChild);else if(r.lastChild&&t>r.lastChild.row)r.appendChild(n);else{let e;r.forEachChildren((i=>i.row===t&&(e=i,!0))),e!==n&&r.insertBefore(n,e)}let o=r.firstChild?.row;r.forEachChildren((t=>{t.row=o,o++}))}}(t,n)})),function(t){let e=0;for(let i=0;i<t.table.colCount;i++){const n=t.getColGroup(i,!0),r=t.getColGroup(i,!1);let o=n.firstChild?.row,s=0;o=r.firstChild?.row,s=0,r.forEachChildren((t=>{t.row=o,o++,"cell"===t.role&&(t.setAttribute("y",s),s+=t.attribute.height)})),e=s}t.updateContainerHeight(t.table.frozenRowCount,e-t.bodyGroup.attribute.height)}(n)}function SG(t){const e=[];for(let i=0;i<t.length;i++)-1===e.indexOf(t[i])&&e.push(t[i]);return e}new Xx({});const AG=[];function TG(t){AG.forEach((e=>{t.scenegraph.getCell(e.col,e.row).forEachChildren((t=>{t.setAttributes({dy:0,dx:0})}))})),AG.length=0;const{scrollTop:e,scrollLeft:i,frozenRowCount:n,frozenColCount:r}=t,o=t.getFrozenRowsHeight(),s=t.getFrozenColsWidth(),{row:a}=t.getRowAt(e+o+1),{col:l}=t.getColAt(i+s+1),h=t.getAllRowsHeight()>t.tableNoFrameHeight?t.getRowAt(e+t.tableNoFrameHeight-1).row:t.rowCount-1,c=t.getAllColsWidth()>t.tableNoFrameWidth?t.getColAt(i+t.tableNoFrameWidth-1).col:t.colCount-1;for(let e=0;e<n;e++)for(let i=l;i<=c;i++)if(t._getCellStyle(i,e)?.textStick){MG(t.scenegraph.getCell(i,e),s+t.tableX,t.tableNoFrameWidth-t.getRightFrozenColsWidth()),AG.push({col:i,row:e})}if(-1!==a){for(let e=a;e<=h;e++)for(let i=0;i<r;i++)if(t._getCellStyle(i,e)?.textStick&&"tree"!==t.internalProps.layoutMap.rowHierarchyType){BG(t.scenegraph.getCell(i,e),o+t.tableY,t.tableNoFrameHeight-t.getBottomFrozenRowsHeight()),AG.push({col:i,row:e})}for(let e=a;e<=h;e++)for(let i=l;i<=c;i++)if(t._getCellStyle(i,e)?.textStick){const n=t.scenegraph.getCell(i,e);BG(n,o+t.tableY,t.tableNoFrameHeight-t.getBottomFrozenRowsHeight()),MG(n,s+t.tableX,t.tableNoFrameWidth-t.getRightFrozenColsWidth()),AG.push({col:i,row:e})}}}function BG(t,e,i){const n=t.getChildByName("text",!0);if(!n)return;n.AABBBounds.width();const r=n.globalAABBBounds.y1,o=n.globalAABBBounds.y2;if(r<e){const i=r-e;t.forEachChildren((t=>{t.setAttribute("dy",2-i)}))}else if(o>i){const e=o-i;t.forEachChildren((t=>{t.setAttribute("dy",-e)}))}}function MG(t,e,i){const n=t.getChildByName("text",!0);if(!n)return;n.AABBBounds.width();const r=n.globalAABBBounds.x1,o=n.globalAABBBounds.x2;if(r<e){const i=r-e;t.forEachChildren((t=>{t.setAttribute("dx",2-i)}))}else if(o>i){const e=o-i;t.forEachChildren((t=>{t.setAttribute("dx",-e)}))}}function RG(t){const e=t.bodyGroup.firstChild instanceof bj?t.bodyGroup.firstChild:null;e&&(t.rowHeaderGroup.appendChild(e),t.rowHeaderGroup.setAttribute("width",t.rowHeaderGroup.attribute.width+e.attribute.width),t.bodyGroup.setAttribute("width",t.bodyGroup.attribute.width-e.attribute.width))}function PG(t){const e=t.colHeaderGroup.firstChild instanceof bj?t.colHeaderGroup.firstChild:null;e&&(t.cornerHeaderGroup.appendChild(e),t.cornerHeaderGroup.setAttribute("width",t.cornerHeaderGroup.attribute.width+e.attribute.width),t.colHeaderGroup.setAttribute("width",t.colHeaderGroup.attribute.width-e.attribute.width))}function EG(t){const e=t.rowHeaderGroup.lastChild instanceof bj?t.rowHeaderGroup.lastChild:t.rowHeaderGroup.lastChild?._prev;e&&(LG(t.bodyGroup,e,t.bodyGroup.firstChild),t.bodyGroup.setAttribute("width",t.bodyGroup.attribute.width+e.attribute.width),t.rowHeaderGroup.setAttribute("width",t.rowHeaderGroup.attribute.width-e.attribute.width))}function HG(t){const e=t.cornerHeaderGroup.lastChild instanceof bj?t.cornerHeaderGroup.lastChild:t.cornerHeaderGroup.lastChild?._prev;e&&(LG(t.colHeaderGroup,e,t.colHeaderGroup.firstChild),t.colHeaderGroup.setAttribute("width",t.colHeaderGroup.attribute.width+e.attribute.width),t.cornerHeaderGroup.setAttribute("width",t.cornerHeaderGroup.attribute.width-e.attribute.width))}function LG(t,e,i){e&&t&&(i?t.insertBefore(e,i):t.appendChild(e))}function kG(t){for(let e=t.proxy.colStart;e<=t.proxy.colEnd;e++){t.getColGroup(e).getChildren().forEach((t=>{t.children.forEach((t=>{"chart"===t.type&&(t.cacheCanvas=null)}))}))}}function IG(t,e){t.forEachChildren((t=>{"column"===t.role&&t.forEachChildren((t=>{if("cell"===t.role){let i=!1;if(t.forEachChildren((t=>"axis"===t.name&&(i=!0,!0))),i){const i=e.internalProps.layoutMap.getAxisConfigInPivotChart(t.col,t.row),n=new hW(i,t.attribute.width,t.attribute.height,e);t.clear(),t.appendChild(n.component),n.overlap()}}}))}))}function OG(t,e){const{bgColor:i,borderColor:n,borderLineWidth:r,borderLineDash:o}=e,s={x:0,y:0,width:0,height:0,visible:!1,pickable:!0,fill:i};return s.stroke=Zj(n,void 0),s.lineWidth=r,o&&(s.lineDash=o),s.lineCap="square",Array.isArray(n)&&(s.strokeArrayColor=RW(n)),Array.isArray(r)&&(s.strokeArrayWidth=RW(r),s.lineWidth=1),t.setAttributes(s),t.role="corner-frozen",t}function DG(t,e){return new bj({x:0,y:0,width:t,height:e,clip:!1,pickable:!1})}function FG(t){let e=0;return t.forEachChildrenSkipChild(((t,i)=>{t.setAttribute("x",e),e+=t.attribute.width})),e}qb.load(Uk),qb.load(TN);const zG={visible:!0,position:"auto",padding:8,titleStyle:{fontSize:12,fontWeight:"bold",fill:"#4E5969"},contentStyle:{fontSize:12,fill:"#4E5969"},panel:{visible:!0,fill:"#fff",stroke:"#ffffff",lineWidth:0,cornerRadius:3,shadowBlur:12,shadowOffsetX:0,shadowOffsetY:4,shadowColor:"rgba(0, 0, 0, 0.1)",size:0,space:12}};class WG{proxy;tableGroup;colHeaderGroup;cornerHeaderGroup;rowHeaderGroup;bodyGroup;rightFrozenGroup;bottomFrozenGroup;rightTopCornerGroup;leftBottomCornerGroup;rightBottomCornerGroup;componentGroup;selectedRangeComponents;selectingRangeComponents;lastSelectId;component;stage;table;isPivot;transpose;hasFrozen;frozenColCount;frozenRowCount;clear;mergeMap;constructor(t){var e;this.table=t,this.hasFrozen=!1,this.clear=!0,this.mergeMap=new Map,e=zG,fd(zk.poptip,Fk,e),this.stage=function(t){return new xk(t)}({canvas:t.canvas,width:t.canvas.width,height:t.canvas.height,disableDirtyBounds:!1,background:t.theme.underlayBackgroundColor,dpr:t.internalProps.pixelRatio,pluginList:t.isPivotChart()?["poptipForText"]:void 0}),this.stage.defaultLayer.setTheme({group:{boundsPadding:0,strokeBoundsBuffer:0,lineJoin:"round"},text:{ignoreBuf:!0}}),this.initSceneGraph(),this.stage.defaultLayer.add(this.tableGroup),this.stage.table=this.table,this.createComponent()}get width(){return this.tableGroup.attribute?.width??0}get height(){return this.tableGroup.attribute?.height??0}get x(){return this.tableGroup.attribute?.x??0}get y(){return this.tableGroup.attribute?.y??0}get bodyRowStart(){return this.transpose||this.isPivot?this.table.columnHeaderLevelCount:this.proxy.rowStart??0}get bodyRowEnd(){return this.transpose||this.isPivot?this.table.rowCount-1:this.proxy.rowEnd??0}initSceneGraph(){this.isPivot=this.table.isPivotTable(),this.transpose=this.table.options.transpose,function(t){const e=t.table.tableNoFrameWidth,i=t.table.tableNoFrameHeight;t.tableGroup=new bj({x:0,y:0,width:e,height:i,clip:!0,pickable:!1}),t.tableGroup.role="table";const n=DG(0,0);n.role="col-header",t.colHeaderGroup=n;const r=DG(0,0);r.role="corner-header",t.cornerHeaderGroup=r;const o=DG(0,0);o.role="row-header",t.rowHeaderGroup=o;const s=DG(e,0);s.role="body",t.bodyGroup=s;const a=DG(0,0);a.role="right-frozen",t.rightFrozenGroup=a;const l=DG(0,0);l.role="bottom-frozen",t.bottomFrozenGroup=l;const h=DG(0,0);h.role="component",t.componentGroup=h;const c=DG(0,0);c.role="corner-right-top-header",t.rightTopCornerGroup=c;const u=DG(0,0);u.role="corner-right-bottom-header",t.rightBottomCornerGroup=u;const d=DG(0,0);d.role="corner-left-bottom-header",t.leftBottomCornerGroup=d,t.table.isPivotChart()&&(OG(c,t.table.theme.cornerRightTopCellStyle||t.table.theme.cornerHeaderStyle),OG(d,t.table.theme.cornerLeftBottomCellStyle||t.table.theme.cornerHeaderStyle),OG(u,t.table.theme.cornerRightBottomCellStyle||t.table.theme.cornerHeaderStyle)),t.tableGroup.addChild(s),t.tableGroup.addChild(a),t.tableGroup.addChild(l),t.tableGroup.addChild(o),t.tableGroup.addChild(n),t.tableGroup.addChild(u),t.tableGroup.addChild(c),t.tableGroup.addChild(d),t.tableGroup.addChild(r),t.tableGroup.addChild(h)}(this)}clearCells(){this.clear=!0,this.hasFrozen=!1,this.mergeMap.clear(),this.colHeaderGroup.clear(),this.rowHeaderGroup.clear(),this.cornerHeaderGroup.clear(),this.bodyGroup.clear(),this.bottomFrozenGroup.clear(),this.rightFrozenGroup.clear(),this.rightTopCornerGroup.clear(),this.rightBottomCornerGroup.clear(),this.leftBottomCornerGroup.clear(),this.colHeaderGroup.setAttributes({x:0,y:0,width:0,height:0}),this.rowHeaderGroup.setAttributes({x:0,y:0,width:0,height:0}),this.cornerHeaderGroup.setAttributes({x:0,y:0,width:0,height:0}),this.bodyGroup.setAttributes({x:0,y:0,width:0,height:0}),this.rightFrozenGroup.setAttributes({x:0,y:0,width:0,height:0}),this.bottomFrozenGroup.setAttributes({x:0,y:0,width:0,height:0}),this.rightTopCornerGroup.setAttributes({x:0,y:0,width:0,height:0,visible:!1}),this.leftBottomCornerGroup.setAttributes({x:0,y:0,width:0,height:0,visible:!1}),this.rightBottomCornerGroup.setAttributes({x:0,y:0,width:0,height:0,visible:!1}),this.tableGroup.setAttributes({x:this.table.tableX,y:this.table.tableY,width:0,height:0}),this.tableGroup.border&&(this.tableGroup.parent.removeChild(this.tableGroup.border),delete this.tableGroup.border)}createComponent(){this.component=new Xj(this.table),this.component.addToGroup(this.componentGroup),this.selectedRangeComponents=new Map,this.selectingRangeComponents=new Map}createSceneGraph(){this.clear=!1,this.frozenColCount=this.table.rowHeaderLevelCount,this.frozenRowCount=this.table.columnHeaderLevelCount,this.proxy=new wG(this.table),Yj(this.tableGroup,this.table.theme.frameStyle,this.tableGroup.role,void 0,!0),this.proxy.createGroupForFirstScreen(this.cornerHeaderGroup,this.colHeaderGroup,this.rowHeaderGroup,this.rightFrozenGroup,this.bottomFrozenGroup,this.bodyGroup,0,0),this.afterScenegraphCreated()}renderSceneGraph(){this.stage.render()}getCellOld(t,e){let i;if(i=this.hasFrozen&&t<this.table.frozenColCount&&e<this.table.frozenRowCount?this.cornerHeaderGroup.getChildAt(t)?.getChildAt(e):e<this.table.frozenRowCount?this.colHeaderGroup.getChildAt(this.hasFrozen?t-this.table.frozenColCount:t)?.getChildAt(e):t<this.table.frozenColCount?this.rowHeaderGroup.getChildAt(t)?.getChildAt(e-this.table.frozenRowCount):this.bodyGroup.getChildAt(t-this.table.frozenColCount)?.getChildAt(e-this.table.frozenRowCount),i&&"shadow-cell"===i.role){const n=this.table.getCellRange(t,e);i=this.getCell(n.start.col,n.start.row)}return i||void 0}getColGroupOld(t,e=!1){let i;return i=t<this.frozenColCount&&e?this.cornerHeaderGroup.getChildAt(t):t<this.frozenColCount?this.rowHeaderGroup.getChildAt(t):e?this.rowHeaderGroup.getChildAt(t-this.frozenColCount):this.bodyGroup.getChildAt(t-this.frozenColCount),i||void 0}getCell(t,e,i){let n;if(n=this.table.rightFrozenColCount>0&&t>=this.table.colCount-this.table.rightFrozenColCount&&e<this.table.frozenRowCount?this.rightBottomCornerGroup.getColGroup(t)?.getRowGroup(e):this.table.bottomFrozenRowCount>0&&e>=this.table.rowCount-this.table.bottomFrozenRowCount&&t<this.table.frozenColCount?this.leftBottomCornerGroup.getColGroup(t)?.getRowGroup(e):this.table.rightFrozenColCount>0&&this.table.bottomFrozenRowCount>0&&t>=this.table.colCount-this.table.rightFrozenColCount&&e>=this.table.rowCount-this.table.bottomFrozenRowCount?this.rightBottomCornerGroup.getColGroup(t)?.getRowGroup(e):this.table.rightFrozenColCount>0&&t>this.table.colCount-1-this.table.rightFrozenColCount?this.rightFrozenGroup.getColGroup(t)?.getRowGroup(e):this.table.bottomFrozenRowCount>0&&e>this.table.rowCount-1-this.table.bottomFrozenRowCount?this.bottomFrozenGroup.getColGroup(t)?.getRowGroup(e):this.getColGroup(t,e<this.frozenRowCount)?.getRowGroup(e),n&&"shadow-cell"===n.role&&!i){const i=this.table.getCellRange(t,e);i.start.col===t&&i.start.row===e||(n=this.getCell(i.start.col,i.start.row))}return n||KN}highPerformanceGetCell(t,e,i){return this.proxy.highPerformanceGetCell(t,e,i)}getColGroup(t,e=!1){let i;return i=t<this.frozenColCount&&e?this.cornerHeaderGroup.getColGroup(t):t<this.frozenColCount?this.rowHeaderGroup.getColGroup(t):e?this.colHeaderGroup.getColGroup(t):!e&&this.table.rightFrozenColCount>0&&t>this.table.colCount-1-this.table.rightFrozenColCount?this.rightFrozenGroup.getColGroup(t):this.bodyGroup.getColGroup(t),i||void 0}getColGroupInBottom(t){if(this.table.bottomFrozenRowCount>0)return this.bottomFrozenGroup.getColGroup(t)}getColGroupInLeftBottomCorner(t){if(this.table.bottomFrozenRowCount>0)return this.leftBottomCornerGroup.getColGroup(t)}getColGroupInRightTopCorner(t){if(this.table.rightFrozenColCount>0)return this.rightTopCornerGroup.getColGroup(t)}getColGroupInRightBottomCorner(t){if(this.table.rightFrozenColCount>0&&this.table.bottomFrozenRowCount>0)return this.rightBottomCornerGroup.getColGroup(t)}getCellSize(t,e){const i=this.getCell(t,e),n=Sk(this.table,t,e);let r=i.attribute.width,o=i.attribute.height;return n&&(r/=n.end.col-n.start.col+1,o/=n.end.row-n.start.row+1),{width:r,height:o}}updateNextFrame(){this.resetAllSelectComponent(),this.stage.renderNextFrame()}resetAllSelectComponent(){var t;(t=this).selectingRangeComponents.forEach(((e,i)=>{xG(e,i,t)})),t.selectedRangeComponents.forEach(((e,i)=>{xG(e,i,t)}))}hideHoverIcon(t,e){if(-1===t||-1===e)return;NG(this,this.getCell(t,e),"mouseenter_cell")}showHoverIcon(t,e){if(-1===t||-1===e)return;jG(this,this.getCell(t,e),"mouseenter_cell")}hideClickIcon(t,e){if(-1===t||-1===e)return;NG(this,this.getCell(t,e),"click_cell")}showClickIcon(t,e){if(-1===t||-1===e)return;jG(this,this.getCell(t,e),"click_cell")}deactivateChart(t,e){if(-1===t||-1===e)return;const i=this.getCell(t,e);i?.firstChild?.deactivate?.()}activateChart(t,e){if(-1===t||-1===e)return;const i=this.getCell(t,e);i?.firstChild?.activate?.(this.table)}removeInteractionBorder(t,e){const i=this.getCell(t,e);i.setAttribute("highlightStroke",void 0),i.setAttribute("highlightStrokeArrayWidth",void 0),i.setAttribute("highlightStrokeArrayColor",void 0)}createCellSelectBorder(t,e,i,n,r,o,s){!function(t,e,i,n,r,o,s,a){const l=Math.min(e,n),h=Math.min(i,r),c=Math.max(e,n),u=Math.max(i,r);let d;for(let e=l;e<=c;e++)for(let i=h;i<=u;i++){const n=t.highPerformanceGetCell(e,i);if("shadow-cell"===n.role)continue;n.AABBBounds.width();const r=n.globalAABBBounds;d?d.union(r):d=r}const p=t.table.theme,f=p.selectionStyle?.cellBorderColor,g=p.selectionStyle?.cellBorderLineWidth,m=eT({pickable:!1,fill:p.selectionStyle?.cellBgColor??"rgba(0, 0, 255,0.1)",lineWidth:g,stroke:a.map((t=>!!t&&f)),x:d.x1-t.tableGroup.attribute.x,y:d.y1-t.tableGroup.attribute.y,width:d.width(),height:d.height(),visible:!0});t.lastSelectId=s,t.selectingRangeComponents.set(`${l}-${h}-${c}-${u}-${s}`,{rect:m,role:o}),t.tableGroup.insertAfter(m,"body"===o?t.bodyGroup:"columnHeader"===o?t.colHeaderGroup:"rowHeader"===o?t.rowHeaderGroup:t.cornerHeaderGroup)}(this,t,e,i,n,r,o,s)}moveSelectingRangeComponentsToSelectedRangeComponents(){var t;(t=this).selectingRangeComponents.forEach(((e,i)=>{t.selectedRangeComponents.get(i)&&t.selectedRangeComponents.get(i).rect.delete(),t.selectedRangeComponents.set(i,e)})),t.selectingRangeComponents=new Map,t.updateNextFrame()}deleteLastSelectedRangeComponents(){var t;(t=this).selectedRangeComponents.forEach(((e,i)=>{i.split("-")[4]===t.lastSelectId&&(e.rect.delete(),t.selectedRangeComponents.delete(i))}))}deleteAllSelectBorder(){var t;(t=this).selectedRangeComponents.forEach(((t,e)=>{t.rect.delete()})),t.selectedRangeComponents=new Map}updateCellSelectBorder(t,e,i,n){!function(t,e,i,n,r){let o=Math.min(n,e),s=Math.min(r,i),a=Math.max(n,e),l=Math.max(r,i);const h=()=>{let e=!1;for(let i=o;i<=a;i++){if(i===o)for(let n=s;n<=l;n++){const r=Sk(t.table,i,n);if(r&&r.start.col<o){o=r.start.col,e=!0;break}}if(!e&&i===a)for(let n=s;n<=l;n++){const r=Sk(t.table,i,n);if(r&&r.end.col>a){a=r.end.col,e=!0;break}}if(e)break}if(!e)for(let i=s;i<=l;i++){if(i===s)for(let n=o;n<=a;n++){const r=Sk(t.table,n,i);if(r&&r.start.row<s){s=r.start.row,e=!0;break}}if(!e&&i===l)for(let n=o;n<=a;n++){const r=Sk(t.table,n,i);if(r&&r.end.row>l){l=r.end.row,e=!0;break}}if(e)break}e&&h()};h(),t.selectingRangeComponents.forEach(((t,e)=>{t.rect.delete()})),t.selectingRangeComponents=new Map;let c=!1,u=!1,d=!1,p=!1;if(o<=t.table.frozenColCount-1&&s<=t.table.frozenRowCount-1&&(p=!0),o<=t.table.frozenColCount-1&&l>=t.table.frozenRowCount&&(c=!0),s<=t.table.frozenRowCount-1&&a>=t.table.frozenColCount&&(u=!0),a>=t.table.frozenColCount&&l>=t.table.frozenRowCount&&(d=!0),p){const e=Math.min(a,t.table.frozenColCount-1),i=Math.min(l,t.table.frozenRowCount-1),n=[!0,!u,!c,!0];t.createCellSelectBorder(o,s,e,i,"cornerHeader",`${o}${s}${a}${l}`,n)}if(u){const e=Math.max(o,t.table.frozenColCount),i=Math.min(l,t.table.frozenRowCount-1),n=[!0,!0,!d,!p];t.createCellSelectBorder(e,s,a,i,"columnHeader",`${o}${s}${a}${l}`,n)}if(c){const e=Math.max(s,t.table.frozenRowCount),i=Math.min(a,t.table.frozenColCount-1),n=[!p,!d,!0,!0];t.createCellSelectBorder(o,e,i,l,"rowHeader",`${o}${s}${a}${l}`,n)}if(d){const e=Math.max(o,t.table.frozenColCount),i=Math.max(s,t.table.frozenRowCount),n=[!u,!0,!0,!c];t.createCellSelectBorder(e,i,a,l,"body",`${o}${s}${a}${l}`,n)}}(this,t,e,i,n)}getIcon(t,e,i,n){let r;return this.getCell(t,e).forEachChildren((t=>{"icon"===t.role&&t.containsPoint(i,n,xy.GLOBAL)&&(r=t)})),r}setIconHoverStyle(t,e,i,n){if(t.attribute.backgroundColor){let e=t.parent.getChildByName("icon-back");e?e.setAttributes({x:(t.attribute.x??0)+(t.attribute.dx??0)+(t.AABBBounds.width()-t.backgroundWidth)/2,y:(t.attribute.y??0)+(t.AABBBounds.height()-t.backgroundHeight)/2,width:t.backgroundWidth,height:t.backgroundHeight,fill:t.attribute.backgroundColor,cornerRadius:5,visible:!0}):(e=eT({x:(t.attribute.x??0)+(t.attribute.dx??0)+(t.AABBBounds.width()-t.backgroundWidth)/2,y:(t.attribute.y??0)+(t.AABBBounds.height()-t.backgroundHeight)/2,width:t.backgroundWidth,height:t.backgroundHeight,fill:t.attribute.backgroundColor,cornerRadius:5,pickable:!1,visible:!0}),e.name="icon-back"),t.parent.insertBefore(e,t)}if(t.attribute.hoverImage&&t.attribute.image!==t.attribute.hoverImage&&(t.image=t.attribute.hoverImage),t.tooltip){const{x1:n,x2:r,y1:o,y2:s}=t.globalAABBBounds,a={content:t.tooltip.title,referencePosition:{rect:{left:n-this.table.tableX,right:r-this.table.tableX,top:o-this.table.tableY,bottom:s-this.table.tableY,width:t.globalAABBBounds.width(),height:t.globalAABBBounds.height()},placement:t.tooltip.placement},style:Object.assign({},this.table.internalProps.theme?.tooltipStyle,t.tooltip?.style)};this.table.internalProps.tooltipHandler.isBinded(a)||this.table.showTooltip(e,i,a)}}setIconNormalStyle(t,e,i){const n=t.parent.getChildByName("icon-back");n&&n.setAttribute("visible",!1),t.attribute.hoverImage&&t.attribute.image!==t.attribute.originImage&&(t.image=t.attribute.originImage)}updateColWidth(t,e){!function(t,e,i){const n="autoHeight"===t.table.heightMode,r=t.getColGroup(e,!0);r&&zj(r,i,n,"col-corner",t);const o=t.getColGroup(e);o&&zj(o,i,n,"row-body",t);const s=t.getColGroupInLeftBottomCorner(e);s&&zj(s,i,n,"left-bottom",t);const a=t.getColGroupInBottom(e);a&&zj(a,i,n,"bottom",t);const l=t.getColGroupInRightBottomCorner(e);l&&zj(a,i,n,"right-bottom",t),e<t.frozenColCount?(t.cornerHeaderGroup.forEachChildrenSkipChild(((t,n)=>{t.col>e&&t.setAttribute("x",t.attribute.x+i)})),t.rowHeaderGroup.forEachChildrenSkipChild(((t,n)=>{t.col>e&&t.setAttribute("x",t.attribute.x+i)}))):(t.colHeaderGroup.forEachChildrenSkipChild(((t,n)=>{t.col>e&&t.setAttribute("x",t.attribute.x+i)})),t.bodyGroup.forEachChildrenSkipChild(((t,n)=>{t.col>e&&t.setAttribute("x",t.attribute.x+i)}))),s&&t.leftBottomCornerGroup.forEachChildrenSkipChild(((t,n)=>{t.col>e&&t.setAttribute("x",t.attribute.x+i)})),a&&t.bottomFrozenGroup.forEachChildrenSkipChild(((t,n)=>{t.col>e&&t.setAttribute("x",t.attribute.x+i)})),l&&t.rightBottomCornerGroup.forEachChildrenSkipChild(((t,n)=>{t.col>e&&t.setAttribute("x",t.attribute.x+i)})),t.table.setColWidth(e,o.attribute.width,!0)}(this,t,e),this.updateContainer()}updateChartSize(t){!function(t,e){for(let i=e;i<=t.proxy.colEnd;i++)t.getColGroup(i).getChildren().forEach((e=>{const i=t.table.getColWidth(e.col),n=t.table.getRowHeight(e.row);e.children.forEach((t=>{"chart"===t.type&&(t.cacheCanvas=null,t.setAttribute("width",Math.ceil(i-t.attribute.cellPadding[3]-t.attribute.cellPadding[1])),t.setAttribute("height",Math.ceil(n-t.attribute.cellPadding[0]-t.attribute.cellPadding[2])))}))}))}(this,t)}updateChartState(t){this.table.isPivotChart()&&function(t,e){const i=t.table;if(i.isPivotChart()){const n=i._selectedDataItemsInChart.length;if((null===e||0===e?.length||0===Object.keys(e).length)&&0===n)return;const r=[];if(Array.isArray(e))e.forEach((t=>{if(t&&0!==t.key&&Object.keys(t).length>0){const e={};for(const i in t)i.startsWith("VGRAMMAR_")||i.startsWith("__VCHART")||(e[i]=t[i]);r.push(e)}}));else if(e&&0!==e.key&&Object.keys(e).length>0){const t={};for(const i in e)i.startsWith("VGRAMMAR_")||i.startsWith("__VCHART")||(t[i]=e[i]);r.push(t)}yd(i._selectedDataItemsInChart,r)||(i._selectedDataItemsInChart=r,i.internalProps.layoutMap.updateDataStateToChartInstance(),kG(t),i.scenegraph.updateNextFrame())}}(this,t)}updateAutoColWidth(t){this.table.internalProps._widthResizedColMap.delete(t);const e=this.table.getColWidth(t),i=IN(t,0,this.table.rowCount-1,this.table);i!==e&&this.updateColWidth(t,i-e)}recalculateColWidths(){kN(this.table,0,this.table.colCount-1,!0)}recalculateRowHeights(){jN(this.table,0,this.table.rowCount-1,!0,!0)}resize(){"adaptive"===this.table.widthMode&&this.recalculateColWidths(),"adaptive"===this.table.heightMode&&this.recalculateRowHeights(),this.dealWidthMode(),this.dealHeightMode(),this.dealFrozen(),this.updateTableSize(),this.updateBorderSizeAndPosition(),this.component.updateScrollBar(),"adaptive"!==this.table.widthMode&&"adaptive"!==this.table.heightMode||this.updateChartSize(this.table.rowHeaderLevelCount),this.updateNextFrame()}updateTableSize(){this.tableGroup.setAttributes({width:Math.min(this.table.tableNoFrameWidth,Math.max(this.colHeaderGroup.attribute.width,this.bodyGroup.attribute.width,0)+Math.max(this.cornerHeaderGroup.attribute.width,this.rowHeaderGroup.attribute.width,0)+this.rightBottomCornerGroup.attribute.width),height:Math.min(this.table.tableNoFrameHeight,(this.colHeaderGroup.attribute.height??0)+(this.bodyGroup.attribute.height??0)+this.bottomFrozenGroup.attribute.height)}),this.tableGroup.border&&this.tableGroup.border.setAttributes({width:this.tableGroup.attribute.width+this.tableGroup.border.attribute.lineWidth,height:this.tableGroup.attribute.height+this.tableGroup.border.attribute.lineWidth}),this.table.bottomFrozenRowCount>0&&(this.bottomFrozenGroup.setAttribute("y",this.tableGroup.attribute.height-this.bottomFrozenGroup.attribute.height),this.leftBottomCornerGroup.setAttributes({visible:!0,y:this.tableGroup.attribute.height-this.bottomFrozenGroup.attribute.height,height:this.bottomFrozenGroup.attribute.height,width:this.table.getFrozenColsWidth()}),this.rightBottomCornerGroup.setAttributes({visible:!0,y:this.tableGroup.attribute.height-this.bottomFrozenGroup.attribute.height,height:this.bottomFrozenGroup.attribute.height})),this.table.rightFrozenColCount>0&&(this.rightFrozenGroup.setAttribute("x",this.tableGroup.attribute.width-this.rightFrozenGroup.attribute.width),this.rightTopCornerGroup.setAttributes({visible:!0,x:this.tableGroup.attribute.width-this.rightFrozenGroup.attribute.width,width:this.rightFrozenGroup.attribute.width,height:this.table.getFrozenRowsHeight()}),this.rightBottomCornerGroup.setAttributes({visible:!0,x:this.tableGroup.attribute.width-this.rightFrozenGroup.attribute.width,width:this.rightFrozenGroup.attribute.width}))}updateRowHeight(t,e){!function(t,e,i){for(let n=0;n<t.table.colCount;n++){const r=t.getCell(n,e),o=Sk(t.table,n,e);o&&o.start.col!==n||(Fj(t,r,n,e,r.attribute.height,i,t.table.isHeader(n,e)),t.updateCellContentWhileResize(n,e))}let n=0,r=0;e<t.table.columnHeaderLevelCount?(t.colHeaderGroup.setAttribute("height",t.colHeaderGroup.attribute.height+i),t.rowHeaderGroup.setAttribute("y",t.colHeaderGroup.attribute.y+i),t.bodyGroup.setAttribute("y",t.bodyGroup.attribute.y+i),n=e+1,r=t.table.columnHeaderLevelCount-1):(n=e+1,r=t.bodyRowEnd-t.table.bottomFrozenRowCount);for(let e=n;e<=r;e++)for(let n=0;n<t.table.colCount;n++){const r=t.getCell(n,e),o=Sk(t.table,n,e);(!o||o.start.col===n&&o.start.row===e)&&r.setAttribute("y",r.attribute.y+i)}t.table.setRowHeight(e,t.table.getRowHeight(e)+i,!0)}(this,t,e),this.updateContainerHeight(t,e)}updateContainerWidth(t,e){t<this.frozenColCount?(this.rowHeaderGroup.setDeltaWidth(e),this.cornerHeaderGroup.setDeltaWidth(e),this.colHeaderGroup.setDeltaX(e),this.bodyGroup.setDeltaX(e)):(this.colHeaderGroup.setDeltaWidth(e),this.bodyGroup.setDeltaWidth(e)),this.updateTableSize(),this.component.updateScrollBar(),this.updateNextFrame()}updateContainerHeight(t,e){t<this.table.frozenRowCount?(this.colHeaderGroup.setDeltaHeight(e),this.cornerHeaderGroup.setDeltaHeight(e),this.rowHeaderGroup.setDeltaY(e),this.bodyGroup.setDeltaY(e)):t>=this.table.rowCount-this.table.bottomFrozenRowCount?(this.leftBottomCornerGroup.setDeltaHeight(e),this.bottomFrozenGroup.setDeltaHeight(e),this.rightBottomCornerGroup.setDeltaHeight(e)):(this.rowHeaderGroup.setDeltaHeight(e),this.bodyGroup.setDeltaHeight(e)),this.updateTableSize(),this.component.updateScrollBar(),this.updateNextFrame()}setColWidth(t,e){const i=this.table.getColWidth(t);i!==e&&(this.updateColWidth(t,e-i),this.table._clearColRangeWidthsMap(t))}setRowHeight(t,e){const i=this.table.getRowHeight(t);i!==e&&(this.updateRowHeight(t,e-i),this.table._clearRowRangeHeightsMap(t))}setX(t){this.table.scenegraph.proxy.setX(-t)}setY(t){this.table.scenegraph.proxy.setY(-t)}setBodyAndRowHeaderY(t){this.colHeaderGroup.attribute.height+t!==this.bodyGroup.attribute.y&&(this.bodyGroup.setAttribute("y",this.colHeaderGroup.attribute.height+t),this.rowHeaderGroup.setAttribute("y",this.colHeaderGroup.attribute.height+t),this.table.rightFrozenColCount>0&&this.rightFrozenGroup.setAttribute("y",this.colHeaderGroup.attribute.height+t),this.updateNextFrame())}setBodyAndColHeaderX(t){this.rowHeaderGroup.attribute.width+t!==this.bodyGroup.attribute.x&&(this.bodyGroup.setAttribute("x",this.rowHeaderGroup.attribute.width+t),this.colHeaderGroup.setAttribute("x",this.rowHeaderGroup.attribute.width+t),this.table.bottomFrozenRowCount>0&&this.bottomFrozenGroup.setAttribute("x",this.rowHeaderGroup.attribute.width+t),this.updateNextFrame())}afterScenegraphCreated(){this.dealWidthMode(),this.dealHeightMode(),this.dealFrozen(),this.createFrameBorder(),this.updateBorderSizeAndPosition(),this.component.updateScrollBar(),TG(this.table),this.updateNextFrame()}dealWidthMode(){const t=this.table;if("adaptive"===t.widthMode){const e=t.tableNoFrameWidth-t.getFrozenColsWidth()-t.getRightFrozenColsWidth();let i=0;for(let e=t.frozenColCount;e<t.colCount-t.rightFrozenColCount;e++)i+=t.getColWidth(e);const n=e/i;for(let i=t.frozenColCount;i<t.colCount-t.rightFrozenColCount;i++){let r;r=i===t.colCount-t.rightFrozenColCount-1?e-t.getColsWidth(t.frozenColCount,t.colCount-t.rightFrozenColCount-2):Math.round(t.getColWidth(i)*n),this.setColWidth(i,r)}}else if(t.autoFillWidth){const e=t.tableNoFrameWidth;let i=0,n=0;for(let e=0;e<t.colCount;e++){const r=t.getColWidth(e);(e<t.frozenColCount||e>=t.colCount-t.rightFrozenColCount)&&(n+=r),i+=r}if(i<e&&i-n>0){const r=(e-n)/(i-n);for(let e=t.frozenColCount;e<t.colCount-t.rightFrozenColCount;e++)this.setColWidth(e,t.getColWidth(e)*r)}}let e=0;this.bodyGroup.forEachChildrenSkipChild((t=>{e+=t.attribute.width})),this.bodyGroup.setAttribute("width",e);let i=0;this.colHeaderGroup.forEachChildrenSkipChild((t=>{i+=t.attribute.width})),this.colHeaderGroup.setAttribute("width",i);let n=0;this.rowHeaderGroup.forEachChildrenSkipChild((t=>{n+=t.attribute.width})),this.rowHeaderGroup.setAttribute("width",n);let r=0;this.cornerHeaderGroup.forEachChildrenSkipChild((t=>{r+=t.attribute.width})),this.cornerHeaderGroup.setAttribute("width",r),this.colHeaderGroup.setAttribute("x",this.cornerHeaderGroup.attribute.width),this.rowHeaderGroup.setAttribute("y",this.colHeaderGroup.attribute.height),this.bodyGroup.setAttributes({x:this.rowHeaderGroup.attribute.width,y:this.colHeaderGroup.attribute.height})}dealHeightMode(){const t=this.table;if("adaptive"===t.heightMode){t._clearRowRangeHeightsMap();const e=t.tableNoFrameHeight-t.getFrozenRowsHeight()-t.getBottomFrozenRowsHeight();let i=0;for(let e=t.frozenRowCount;e<t.rowCount-t.bottomFrozenRowCount;e++)i+=t.getRowHeight(e);const n=e/i;for(let i=t.frozenRowCount;i<t.rowCount-t.bottomFrozenRowCount;i++){let r;r=i===t.rowCount-t.bottomFrozenRowCount-1?e-t.getRowsHeight(t.frozenRowCount,t.rowCount-t.bottomFrozenRowCount-2):Math.round(t.getRowHeight(i)*n),this.setRowHeight(i,r)}}}dealFrozen(){!function(t){if(t.table.frozenColCount>t.table.rowHeaderLevelCount){t.rowHeaderGroup.setAttribute("height",t.bodyGroup.attribute.height),t.rowHeaderGroup.setAttribute("y",t.bodyGroup.attribute.y),t.cornerHeaderGroup.setAttribute("height",t.colHeaderGroup.attribute.height);for(let e=0;e<t.table.frozenColCount-t.table.rowHeaderLevelCount;e++)RG(t),PG(t)}else if(t.table.frozenColCount<t.table.rowHeaderLevelCount)for(let e=0;e<t.table.rowHeaderLevelCount-t.table.frozenColCount;e++)EG(t),HG(t);t.bodyGroup.setAttribute("x",t.rowHeaderGroup.attribute.width),t.colHeaderGroup.setAttribute("x",t.cornerHeaderGroup.attribute.width),t.updateContainer(),t.updateBorderSizeAndPosition(),t.isPivot||t.transpose||t.component.setFrozenColumnShadow(t.table.frozenColCount-1),t.hasFrozen=!0,t.frozenColCount=t.table.frozenColCount,t.frozenRowCount=t.colHeaderGroup.firstChild?.childrenCount??0}(this)}resetFrozen(){!function(t){if(t.frozenColCount>t.table.rowHeaderLevelCount)for(let e=0;e<t.frozenColCount-t.table.rowHeaderLevelCount;e++)EG(t),HG(t);else if(t.frozenColCount<t.table.rowHeaderLevelCount){t.rowHeaderGroup.setAttribute("height",t.bodyGroup.attribute.height),t.rowHeaderGroup.setAttribute("y",t.bodyGroup.attribute.y),t.cornerHeaderGroup.setAttribute("height",t.colHeaderGroup.attribute.height);for(let e=0;e<t.table.rowHeaderLevelCount-t.frozenColCount;e++)RG(t),PG(t)}t.bodyGroup.setAttribute("x",t.rowHeaderGroup.attribute.width),t.colHeaderGroup.setAttribute("x",t.cornerHeaderGroup.attribute.width),t.updateContainer(),t.updateBorderSizeAndPosition(),t.isPivot||t.transpose||t.component.setFrozenColumnShadow(t.table.frozenColCount-1),t.hasFrozen=!0,t.frozenColCount=t.table.rowHeaderLevelCount,t.frozenRowCount=t.colHeaderGroup.firstChild?.childrenCount??0}(this)}updateCellLayoutWidthCertainWidth(t,e,i){const n=t.attribute.width;let r=!1;return t.forEachChildren(((t,o)=>{o+=e;const s=Sk(this.table,i,o);s?t=this.getCell(s.start.col,s.start.row):t.setAttribute("width",n);const a=RW(Cj("padding",this.table._getCellStyle(i,o),i,o,this.table)),l=t.getChildByName("text");let h=0,c=0;if(l)h=l.AABBBounds.height()+(a[0]+a[2]),l.setAttribute("maxLineWidth",n-(a[1]+a[3])),c=l.AABBBounds.height()+(a[0]+a[2]);else{const e=t.getChildAt(1);h=e.AABBBounds.height()+(a[0]+a[2]),e._cellWidth=n-(a[1]+a[3]),e.layout(),c=e.AABBBounds.height()+(a[0]+a[2])}const u=this.table.getRowHeight(o);t.attribute.height!==c&&(t.setAttribute("height",c),(u===h||c>u)&&(r=!0))})),r}updateHeaderPosition(t,e,i,n){!function(t,e,i,n,r){const o=r.scenegraph,s=r.getCellLocation(i,n),a="columnHeader"===s?"column":"rowHeader"===s?"row":void 0;let l=0,h=0,c=0,u=0,d=0,p=0,f=0,g=0;if("column"===a){const o=Sk(r,t,e),s=Sk(r,i,n);o&&s?(l=o.start.col,c=o.end.col,d=s.start.col,f=s.end.col):(l=t,c=t,d=i,f=i),h=e,u=r.rowCount-1,p=n,g=r.rowCount-1}else if("row"===a){const o=Sk(r,t,e),s=Sk(r,i,n);o&&s?(h=o.start.row,u=o.end.row,p=s.start.row,g=s.end.row):(h=e,u=e,p=n,g=n),l=t,c=r.colCount-1,d=i,f=r.colCount-1}const m=Math.min(l,d),y=Math.max(c,f),b=Math.min(h,p),v=Math.max(u,g);for(let t=m;t<=y;t++){const e=r.scenegraph.getColGroup(t,!0),i=r.scenegraph.getColGroup(t);e&&e.setAttribute("width",r.getColWidth(t)),i&&i.setAttribute("width",r.getColWidth(t))}o.updateContainer();for(let t=m;t<=y;t++){const e=r.scenegraph.getColGroup(t);e?.setAttribute("chartInstance",void 0);for(let e=b;e<=v;e++)o.updateCellContent(t,e)}}(t,e,i,n,this.table)}updateContainer(){const t=FG(this.cornerHeaderGroup),e=FG(this.rowHeaderGroup),i=FG(this.colHeaderGroup),n=FG(this.bodyGroup),r=FG(this.rightFrozenGroup);FG(this.bottomFrozenGroup),FG(this.leftBottomCornerGroup),FG(this.rightTopCornerGroup),FG(this.rightBottomCornerGroup),this.cornerHeaderGroup.setDeltaWidth(t-this.cornerHeaderGroup.attribute.width),this.leftBottomCornerGroup.setDeltaWidth(t-this.leftBottomCornerGroup.attribute.width),this.colHeaderGroup.setDeltaWidth(i-this.colHeaderGroup.attribute.width),this.rightFrozenGroup.setDeltaWidth(i-this.rightFrozenGroup.attribute.width),this.rowHeaderGroup.setDeltaWidth(e-this.rowHeaderGroup.attribute.width),this.bottomFrozenGroup.setDeltaWidth(e-this.bottomFrozenGroup.attribute.width),this.rightFrozenGroup.setDeltaWidth(r-this.rightFrozenGroup.attribute.width),this.rightTopCornerGroup.setDeltaWidth(r-this.rightTopCornerGroup.attribute.width),this.rightBottomCornerGroup.setDeltaWidth(r-this.rightBottomCornerGroup.attribute.width),this.bodyGroup.setDeltaWidth(n-this.bodyGroup.attribute.width),this.colHeaderGroup.setAttribute("x",this.cornerHeaderGroup.attribute.width),this.bottomFrozenGroup.setAttribute("x",this.rowHeaderGroup.attribute.width),this.bodyGroup.setAttribute("x",this.rowHeaderGroup.attribute.width),this.updateTableSize();const o=this.table.stateManeger.scroll.horizontalBarPos,s=this.table.stateManeger.scroll.verticalBarPos;this.component.updateScrollBar(),this.table.stateManeger.setScrollLeft(o),this.table.stateManeger.setScrollTop(s),this.updateNextFrame()}updateCellContentWhileResize(t,e){const i=this.table.getBodyColumnType(t,e),n=this.getCell(t,e);"image"!==i&&"video"!==i||Sj(n,t,e,this.table)}createFrameBorder(){this.updateTableSize();const t=!this.isPivot;Yj(this.bodyGroup,this.table.theme.bodyStyle.frameStyle,this.bodyGroup.role,t?[!0,!0,!0,!1]:void 0),Yj(this.rowHeaderGroup,this.isPivot?this.table.theme.rowHeaderStyle.frameStyle:this.table.theme.bodyStyle.frameStyle,this.rowHeaderGroup.role,t?[!0,!1,!0,!0]:void 0),Yj(this.colHeaderGroup,this.table.theme.headerStyle.frameStyle,this.colHeaderGroup.role,t?[!0,!0,!0,!1]:void 0),Yj(this.cornerHeaderGroup,this.isPivot?this.table.theme.cornerHeaderStyle.frameStyle:this.table.theme.headerStyle.frameStyle,this.cornerHeaderGroup.role,t?[!0,!1,!0,!0]:void 0),Yj(this.tableGroup,this.table.theme.frameStyle,this.tableGroup.role,void 0)}getResizeColAt(t,e,i,n=8){if(i){let e;if(t<i.globalAABBBounds.x1+n?e={col:i.col-1,row:i.row,x:i.globalAABBBounds.x1}:i.globalAABBBounds.x2-n<t&&(e={col:i.col,row:i.row,x:i.globalAABBBounds.x2}),e&&this.table.rightFrozenColCount>0&&e.col===this.table.colCount-this.table.rightFrozenColCount-1&&this.table.tableNoFrameWidth-this.table.getFrozenColsWidth()-this.table.getRightFrozenColsWidth()+this.table.scrollLeft<this.bodyGroup.attribute.width&&(e.col=e.col+1,e.rightFrozen=!0),e)return e}else;return{col:-1,row:-1}}updateIcon(t,e){Lj(e,t),t.name=e.name,this.updateNextFrame()}updateFrozen(){this.clear||(this.resetFrozen(),this.dealFrozen(),this.component.updateScrollBar())}dealWidthRightFrozen(t){this.clear?this.table.internalProps.rightFrozenColCount=t:function(t,e){const{table:i,proxy:n,rightTopCornerGroup:r,rightFrozenGroup:o,rightBottomCornerGroup:s,bottomFrozenGroup:a,bodyGroup:l,colHeaderGroup:h}=e,c=e.table.rightFrozenColCount;if(t>c){for(let n=i.colCount-c-1;n>=i.colCount-t;n--)LG(o,e.getColGroup(n),o.firstChild),LG(r,e.getColGroup(n,!0),r.firstChild),LG(s,e.getColGroupInBottom(n),s.firstChild);let n=0;o.forEachChildren((t=>{t.setAttribute("x",n),n+=t.attribute.width})),n=0,r.forEachChildren((t=>{t.setAttribute("x",n),n+=t.attribute.width})),n=0,s.forEachChildren((t=>{t.setAttribute("x",n),n+=t.attribute.width}))}else if(t<c){for(let n=i.colCount-c;n<i.colCount-t;n++){const t=e.getColGroup(n);t.setAttribute("x",l.lastChild.attribute.x+i.getColWidth(l.lastChild.col)),l.appendChild(t);const r=e.getColGroupInRightTopCorner(n);r.setAttribute("x",h.lastChild.attribute.x+i.getColWidth(h.lastChild.col)),h.appendChild(r);const o=e.getColGroupInRightBottomCorner(n);o.setAttribute("x",a.lastChild.attribute.x+i.getColWidth(a.lastChild.col)),a.appendChild(o)}let n=0;o.forEachChildren((t=>{t.setAttribute("x",n),n+=t.attribute.width})),n=0,r.forEachChildren((t=>{t.setAttribute("x",n),n+=t.attribute.width})),n=0,s.forEachChildren((t=>{t.setAttribute("x",n),n+=t.attribute.width}))}o.setAttribute("width",i.getColsWidth(i.colCount-t,i.colCount-1)),r.setAttribute("width",i.getColsWidth(i.colCount-t,i.colCount-1)),s.setAttribute("width",i.getColsWidth(i.colCount-t,i.colCount-1)),i.internalProps.rightFrozenColCount=t,e.updateContainer(),e.component.updateScrollBar(),e.updateNextFrame()}(t,this)}dealWidthBottomFrozen(t){this.clear?this.table.internalProps.bottomFrozenRowCount=t:function(t,e){const{table:i,proxy:n,bottomFrozenGroup:r,leftBottomCornerGroup:o,rightBottomCornerGroup:s}=e;r.childrenCount||(n.table.isPivotChart()||(nG(o,0,0,0,i.rowHeaderLevelCount-1,0,-1,"rowHeader",i),nG(s,0,0,i.colCount-i.rightFrozenColCount,i.colCount-1,0,-1,"body",i)),nG(r,0,0,n.colStart,n.colEnd,0,-1,"body",i));const a=e.table.bottomFrozenRowCount;if(t>a){for(let n=0;n<i.rowHeaderLevelCount;n++){const r=e.getColGroupInLeftBottomCorner(n);for(let o=i.rowCount-a-1;o>=i.rowCount-t;o--)LG(r,e.getCell(n,o,!0),r.firstChild);let o=0;r.forEachChildren((t=>{t.setAttribute("y",o),o+=i.getRowHeight(t.row)}))}for(let r=n.colStart;r<=n.colEnd;r++){const n=e.getColGroupInBottom(r);for(let o=i.rowCount-a-1;o>=i.rowCount-t;o--)LG(n,e.getCell(r,o,!0),n.firstChild);let o=0;n.forEachChildren((t=>{t.setAttribute("y",o),o+=i.getRowHeight(t.row)}))}if(i.rightFrozenColCount>0)for(let n=i.colCount-i.rightFrozenColCount;n<i.colCount;n++){const r=e.getColGroupInRightBottomCorner(n);for(let o=i.rowCount-a-1;o>=i.rowCount-t;o--)LG(r,e.getCell(n,o,!0),r.firstChild);let o=0;r.forEachChildren((t=>{t.setAttribute("y",o),o+=i.getRowHeight(t.row)}))}}else if(t<a){for(let n=0;n<i.rowHeaderLevelCount;n++){const r=e.getColGroup(n);for(let o=i.rowCount-a;o<i.rowCount-t;o++){const t=e.getCell(n,o,!0);t.setAttribute("y",r.lastChild.attribute.y+i.getRowHeight(r.lastChild.row)),r.appendChild(t)}const o=e.getColGroupInLeftBottomCorner(n);let s=0;o.forEachChildren((t=>{t.setAttribute("y",s),s+=i.getRowHeight(t.row)}))}for(let r=n.colStart;r<=n.colEnd;r++){const n=e.getColGroup(r);for(let o=i.rowCount-a;o<i.rowCount-t;o++){const t=e.getCell(r,o,!0);t.setAttribute("y",n.lastChild.attribute.y+i.getRowHeight(n.lastChild.row)),n.appendChild(t)}const o=e.getColGroupInBottom(r);let s=0;o.forEachChildren((t=>{t.setAttribute("y",s),s+=i.getRowHeight(t.row)}))}if(i.rightFrozenColCount>0)for(let n=i.colCount-i.rightFrozenColCount;n<i.colCount;n++){const r=e.getColGroup(n);for(let o=i.rowCount-a;o<i.rowCount-t;o++){const t=e.getCell(n,o,!0);t.setAttribute("y",r.lastChild.attribute.y+i.getRowHeight(r.lastChild.row)),r.appendChild(t)}const o=e.getColGroupInRightBottomCorner(n);let s=0;o.forEachChildren((t=>{t.setAttribute("y",s),s+=i.getRowHeight(t.row)}))}}r.setAttribute("height",i.getRowsHeight(i.rowCount-t,i.rowCount-1)),o.setAttribute("height",i.getRowsHeight(i.rowCount-t,i.rowCount-1)),s.setAttribute("height",i.getRowsHeight(i.rowCount-t,i.rowCount-1)),i.internalProps.bottomFrozenRowCount=t,e.updateContainer(),e.component.updateScrollBar(),e.updateNextFrame()}(t,this)}updateBorderSizeAndPosition(){this.bodyGroup.border&&(this.bodyGroup.appendChild(this.bodyGroup.border),Jj(this.bodyGroup),0===this.rowHeaderGroup.attribute.width?qj(this.bodyGroup,this.table.theme.bodyStyle.frameStyle,[!0,!0,!0,!0]):qj(this.bodyGroup,this.table.theme.bodyStyle.frameStyle,[!0,!0,!0,!1])),this.colHeaderGroup.border&&(this.colHeaderGroup.appendChild(this.colHeaderGroup.border),Jj(this.colHeaderGroup),0===this.cornerHeaderGroup.attribute.width?qj(this.colHeaderGroup,this.table.theme.headerStyle.frameStyle,[!0,!0,!0,!0]):qj(this.colHeaderGroup,this.table.theme.headerStyle.frameStyle,[!0,!0,!0,!1])),this.rowHeaderGroup.border&&(this.rowHeaderGroup.appendChild(this.rowHeaderGroup.border),Jj(this.rowHeaderGroup)),this.cornerHeaderGroup.border&&(this.cornerHeaderGroup.appendChild(this.cornerHeaderGroup.border),Jj(this.cornerHeaderGroup))}updateSortIcon(t,e,i,n,r,o,s){const a=this.table.internalProps.headerHelper.getSortIcon(n,this.table,t,e);if(i&&this.updateIcon(i,a),s!==i){const t=this.table.internalProps.headerHelper.getSortIcon("normal",this.table,r,o);if(s)this.updateIcon(s,t);else{let e;this.getCell(r,o).forEachChildren((t=>"sort"===t.attribute.funcType&&(e=t,!0))),e&&this.updateIcon(e,t)}}}updateFrozenIcon(t,e){const i=Math.max(t,e);this.colHeaderGroup.forEachChildrenSkipChild((t=>!(t.col<=i)||(t.forEachChildren((t=>{t.forEachChildren((e=>{if("frozen"===e.attribute.funcType){const i=this.table.internalProps.headerHelper.getFrozenIcon(t.col,t.row);return this.updateIcon(e,i),!0}return!1}))})),!1))),this.cornerHeaderGroup.forEachChildrenSkipChild((t=>!(t.col<=i)||(t.forEachChildren((t=>{t.forEachChildren((e=>{if("frozen"===e.attribute.funcType){const i=this.table.internalProps.headerHelper.getFrozenIcon(t.col,t.row);return this.updateIcon(e,i),!0}return!1}))})),!1)))}sortCell(){this.isPivot||(this.transpose?this.proxy.sortCellHorizontal():this.proxy.sortCellVertical())}getCellOverflowText(t,e){const i=this.getCell(t,e).getChildByName("text",!0);if(i){const t=qu(i.attribute.text)?i.attribute.text.join(""):i.attribute.text;let e="";if(Yu(i.cache.clipedText)?e=i.cache.clipedText:i.cache.layoutData.lines.forEach((t=>{e+=t.str})),e!==t)return t}return null}updateDrill(t,e,i,n,r){this.component.drillIcon.update(t,e,i,n,r,this)}updateCellContent(t,e){if(!this.clear)return tG(t,e,this.table)}setPixelRatio(t){this.stage.disableDirtyBounds(),this.stage.window.setDpr(t),this.stage.render(),this.stage.enableDirtyBounds()}updateHierarchyIcon(t,e){const i=this.getCell(t,e);let n;n=this.table.isHeader(t,e)?this.table.internalProps.headerHelper.getHierarchyIcon(i.col,i.row):this.table.internalProps.bodyHelper.getHierarchyIcon(i.col,i.row),this.findAndUpdateIcon(i,[Jc.collapse,Jc.expand],n)}updateRow(t,e){_G(t,e,this.table),this.recalculateColWidths(),this.recalculateRowHeights(),this.table.stateManeger.checkFrozen(),this.updateNextFrame()}findAndUpdateIcon(t,e,i){t.forEachChildren((t=>{if("group"===t.type)this.findAndUpdateIcon(t,e,i);else if(-1!==e.indexOf(t.attribute.funcType))return this.updateIcon(t,i),!0;return!1}))}}function jG(t,e,i){e.forEachChildren((e=>{"group"===e.type?jG(t,e,i):e.attribute.visibleTime===i&&(e.attribute.visible=!0,t.updateNextFrame())}))}function NG(t,e,i){e.forEachChildren((e=>{"group"===e.type?NG(t,e,i):e.attribute.visibleTime===i&&(e.attribute.visible=!1,t.updateNextFrame())}))}function GG(t,e,i){const n=t.getCell(e,i);if("shadow-cell"===n.role){t.getCell(n.mergeCol,n.mergeRow).addUpdateBoundTag()}else n.addUpdateBoundTag()}function VG(t,e,i,n,r){const o=t.table;for(let i=0;i<o.columnHeaderLevelCount;i++)GG(t,e,i);const s=t.getColGroup(e);return s?.addUpdateBoundTag(),!0}function UG(t,e,i,n,r,o){const s=t.table;for(let i=0;i<s.columnHeaderLevelCount;i++)GG(t,e,i);const a=t.getColGroup(e);return a?.addUpdateBoundTag(),!0}function KG(t,e,i,n,r){const o=t.table;for(let e=0;e<o.colCount;e++)GG(t,e,i);return!0}function $G(t,e,i,n,r,o){const s=t.table;for(let e=0;e<s.colCount;e++)GG(t,e,i);return!0}function XG(t,e,i){const{table:n}=t,{scenegraph:r}=n,{highlightScope:o,singleStyle:s,disableHeader:a,cellPos:l,cellPosContainHeader:h}=t.hover,c=l.col,u=l.row;if(o===Kc.none||a&&(h.col!==e||h.row!==i)){const t=h.col,n=h.row;r.hideHoverIcon(t,n),r.showHoverIcon(e,i),h.col=e,h.row=i}if((a&&n.isHeader(e,i)||o===Kc.none)&&(e=-1,i=-1),c===e&&u===i)return;r.deactivateChart(c,u),r.activateChart(e,i);let d=!1;const{ranges:p,highlightScope:f}=t.select;if(-1!==c&&-1!==u&&(d=function(t,e,i,n,r,o,s){let a=!1;o===Kc.single?a=!!function(t,e,i,n,r){return GG(t,e,i),!0}(t,e,i)||a:o===Kc.row?a=!!KG(t,0,i)||a:o===Kc.column?a=!!VG(t,e)||a:o===Kc.cross&&(a=!!KG(t,0,i)||a,a=!!VG(t,e)||a);return a}(r,c,u,0,0,o),a||r.hideHoverIcon(c,u)),-1===e||-1===i)return l.col=-1,l.row=-1,void(!d||c===e&&u===i||t.table.scenegraph.updateNextFrame());o===Kc.single?d=!!function(t,e,i,n,r){return GG(t,e,i),!0}(r,e,i)||d:o===Kc.row?d=!!$G(r,0,i)||d:o===Kc.column?d=!!UG(r,e)||d:o===Kc.cross&&(d=!!$G(r,0,i)||d,d=!!UG(r,e)||d),o===Kc.none||a||r.showHoverIcon(e,i),l.col=e,l.row=i,d&&t.table.scenegraph.updateNextFrame()}function YG(t,e,i){let n,r=null,o=!1;if(Array.isArray(i.sortState))for(let s=0;s<i.sortState.length&&(n=i.sortState[s],n&&(r=i._getHeaderCellBySortState(n)),r&&(o=qG(t,e,r.col,r.row,i)),!o);s++);else n=i.sortState,n&&(r=i._getHeaderCellBySortState(n)),r&&(o=qG(t,e,r.col,r.row,i));const s=i.getHeaderDefine(t,e);n&&o&&s?.sort?n.order="asc"===n.order?"desc":"desc"===n.order?"normal":"asc":s?.sort?n={fieldKey:i.getHeaderFieldKey(t,e),field:i.getHeaderField(t,e),order:"asc"}:o&&s?.showSort||(n={fieldKey:i.getHeaderFieldKey(t,e),field:i.getHeaderField(t,e),order:"normal"});i.fireListeners(sf.SORT_CLICK,n).includes(!1)||(i.internalProps.sortState=n,i.stateManeger.setSortState(n),s?.sort&&function(t,e,i){let n;n=t.fieldKey?e.internalProps.layoutMap.headerObjects.find((e=>e&&e.fieldKey===t.fieldKey)):e.internalProps.layoutMap.headerObjects.find((e=>e&&e.field===t.field));if(!n)return;const{field:r}=n;if(null===r)return;"function"==typeof i.sort?e.dataSource.sort(r,t.order||"asc",i.sort):e.dataSource.sort(r,t.order||"asc",Cu)}(n,i,s),i.scenegraph.sortCell(),i.stateManeger.updateSelectPos(-1,-1))}function qG(t,e,i,n,r){return r._getLayoutCellId(t,e)===r._getLayoutCellId(i,n)}const ZG=Up(sf,{PIVOT_SORT_CLICK:"pivot_sort_click",DRILLMENU_CLICK:"drillmenu_click"}),JG=Up(sf,{VCHART_EVENT_TYPE:"vchart_event_type"});function QG(t){if(!("canMoveHeaderPosition"in t.table.internalProps.layoutMap))return;setTimeout((()=>{t.columnMove.moving=!1}),0);t.table.moveHeaderPosition({col:t.columnMove.colSource,row:t.columnMove.rowSource},{col:t.columnMove.colTarget,row:t.columnMove.rowTarget})&&(!function(t,e,i,n,r){const o=Math.min(t,i),s=Math.max(t,i),a=Math.min(e,n),l=Math.max(e,n);for(let t=o;t<=s;t++)r._clearColRangeWidthsMap(t);for(let t=a;t<=l;t++)r._clearRowRangeHeightsMap(t)}(t.columnMove.colSource,t.columnMove.rowSource,t.columnMove.colTarget,t.columnMove.rowTarget,t.table),t.table.clearCellStyleCache(),t.table.scenegraph.updateHeaderPosition(t.columnMove.colSource,t.columnMove.rowSource,t.columnMove.colTarget,t.columnMove.rowTarget)),t.updateCursor(),t.table.scenegraph.component.hideMoveCol(),t.table.scenegraph.updateNextFrame()}function tV(t){if(!t)return;const e=t.role?.startsWith("icon")?t:"richtext"===t.type?t._currentHoverIcon:void 0;return e?"richtext"===t.type?{icon:e,position:{left:t.globalAABBBounds.x1+e.globalAABBBounds.x1,right:t.globalAABBBounds.x1+e.globalAABBBounds.x2,top:t.globalAABBBounds.y1+e.globalAABBBounds.y1,bottom:t.globalAABBBounds.y1+e.globalAABBBounds.y2,width:e.globalAABBBounds.x2-e.globalAABBBounds.x1,height:e.globalAABBBounds.y2-e.globalAABBBounds.y1},type:"richtext-icon"}:{icon:e,position:{left:e.globalAABBBounds.x1,right:e.globalAABBBounds.x2,top:e.globalAABBBounds.y1,bottom:e.globalAABBBounds.y2,width:e.globalAABBBounds.x2-e.globalAABBBounds.x1,height:e.globalAABBBounds.y2-e.globalAABBBounds.y1},type:"icon"}:void 0}function eV(t,e){if("adaptive"===e.table.widthMode&&e.columnResize.col<e.table.colCount-1){const i=e.table.getColWidth(e.columnResize.col+1);i-t<0&&(t=i),e.table.scenegraph.updateColWidth(e.columnResize.col,t),e.table.scenegraph.updateColWidth(e.columnResize.col+1,-t),e.table.internalProps._widthResizedColMap.add(e.columnResize.col),e.table.internalProps._widthResizedColMap.add(e.columnResize.col+1)}else e.table.scenegraph.updateColWidth(e.columnResize.col,t),e.table.internalProps._widthResizedColMap.add(e.columnResize.col)}class iV{table;interactionState;select;hover;hoverIcon;residentHoverIcon;columnResize;columnMove;menu;sort;frozen;scroll;tablePosition;drill;sparkLine;_clearVerticalScrollBar;_clearHorizontalScrollBar;resetInteractionState=lf((()=>{this.updateInteractionState(Uc.default)}),100);constructor(t){this.table=t,this.initState(),this.updateVerticalScrollBar=this.updateVerticalScrollBar.bind(this),this.updateHorizontalScrollBar=this.updateHorizontalScrollBar.bind(this)}initState(){this._initState(),this.setHoverState(),this.setSelectState(),this.setFrozenState()}_initState(){this.interactionState=Uc.default,this.select={highlightScope:Kc.single,ranges:[],cellPos:{col:-1,row:-1},selecting:!1},this.hover={highlightScope:Kc.single,cellPos:{col:-1,row:-1}},this.hoverIcon={col:-1,row:-1,icon:null},this.columnResize={col:-1,x:0,resizing:!1},this.columnMove={colSource:-1,colTarget:-1,rowSource:-1,rowTarget:-1,x:0,y:0,moving:!1},this.menu={x:-1,y:-1,isShow:!1,itemList:[],bounds:new ep,highlightIndex:-1,dropDownMenuHighlight:[]},this.sort={col:-1,row:-1,order:"normal"},this.frozen={col:-1},this.scroll={horizontalBarPos:0,verticalBarPos:0},this.tablePosition={absoluteX:0,absoluteY:0},this.drill={col:-1,row:-1},this.sparkLine={col:-1,row:-1}}setHoverState(){const{highlightMode:t,disableHover:e,disableHeaderHover:i}=this.table.options.hover??{highlightMode:"cell"};e?this.hover.highlightScope=Kc.none:"cross"===t?this.hover.highlightScope=Kc.cross:"row"===t?this.hover.highlightScope=Kc.row:"column"===t?this.hover.highlightScope=Kc.column:"cell"===t&&(this.hover.highlightScope=Kc.single),this.hover.singleStyle=!e,this.hover.disableHeader=i,(this.hover.highlightScope===Kc.none||i)&&(this.hover.cellPosContainHeader={col:-1,row:-1})}setSelectState(){const{disableSelect:t,disableHeaderSelect:e}=this.table.options?.select??{disableSelect:!1,disableHeaderSelect:!1};this.select.highlightScope=t?Kc.none:Kc.single,this.select.singleStyle=!t,this.select.disableHeader=e}isSelected(t,e){let i=!1;return this.select.ranges.forEach((n=>{qp(n,t,e)&&(i=!0)})),i}setSortState(t){this.sort.field=t.field,this.sort.fieldKey=t.fieldKey,this.sort.order=t.order}setFrozenState(){this.frozen.col=this.table.frozenColCount-1}updateInteractionState(t){this.interactionState!==t&&(this.interactionState=t)}updateHoverhighlightScope(t){this.hover.highlightScope!==t&&(this.hover.highlightScope=t)}updateHoverPos(t,e){XG(this,t,e)}updateSelectPos(t,e,i=!1,n=!1,r=!1){-1!==e&&-1!==e&&(this.select.selecting=!0),function(t,e,i,n,r,o){const{table:s,interactionState:a}=t,{scenegraph:l}=s,{highlightScope:h,disableHeader:c,cellPos:u}=t.select;if((c&&s.isHeader(e,i)||"none"===h)&&(e=-1,i=-1),u.col!==e||u.row!==i){if(-1!==e&&-1!==i&&t.select.ranges.length>0)if(a===Uc.grabing){const n=t.select.ranges[t.select.ranges.length-1];e>n.start.col&&e>n.end.col&&s._makeVisibleCell(e+1,i),i>n.start.row&&i>n.end.row&&s._makeVisibleCell(e,i+1),e<n.start.col&&e<n.end.col&&s._makeVisibleCell(e-1,i),i<n.start.row&&i<n.end.row&&s._makeVisibleCell(e,i-1)}else s._makeVisibleCell(e,i);if(o){t.select.ranges=[],l.deleteAllSelectBorder(),t.select.ranges.push({start:{col:0,row:0},end:{col:s.colCount-1,row:s.rowCount-1}});const e=t.select.ranges[t.select.ranges.length-1];l.updateCellSelectBorder(e.start.col,e.start.row,e.end.col,e.end.row)}else if(-1===u.col||-1===u.row||-1!==e&&-1!==i){if(a===Uc.default){const o=t.select.ranges[t.select.ranges.length-1];if(n&&o){if(s.isColumnHeader(e,i)){const t=Math.min(o.start.col,o.end.col,e),n=Math.max(o.start.col,o.end.col,e),r=Math.min(o.start.row,o.end.row,i),a=s.rowCount-1;o.start={col:t,row:r},o.end={col:n,row:a}}else if(s.isRowHeader(e,i)){const t=Math.min(o.start.col,o.end.col,e),n=s.colCount-1,r=Math.min(o.start.row,o.end.row,i),a=Math.max(o.start.row,o.end.row,i);o.start={col:t,row:r},o.end={col:n,row:a}}else o.end={col:e,row:i};l.deleteLastSelectedRangeComponents(),l.updateCellSelectBorder(o.start.col,o.start.row,o.end.col,o.end.row)}else{-1===u.col||-1===u.row||r||(t.select.ranges=[],l.deleteAllSelectBorder()),s.isColumnHeader(e,i)?t.select.ranges.push({start:{col:e,row:i},end:{col:e,row:s.rowCount-1}}):s.isRowHeader(e,i)?t.select.ranges.push({start:{col:e,row:i},end:{col:s.colCount-1,row:i}}):t.select.ranges.push({start:{col:e,row:i},end:{col:e,row:i}}),u.col=e,u.row=i;const n=t.select.ranges[t.select.ranges.length-1];l.updateCellSelectBorder(n.start.col,n.start.row,n.end.col,n.end.row)}}else if(a===Uc.grabing){-1===u.col&&(u.col=e),-1===u.row&&(u.row=i);const n=t.select.ranges[t.select.ranges.length-1];n.end={col:e,row:i},u.col=e,u.row=i,l.updateCellSelectBorder(n.start.col,n.start.row,e,i)}}else u.col=-1,u.row=-1,t.select.ranges=[],l.deleteAllSelectBorder();l.updateNextFrame()}}(this,t,e,i,n,r)}checkCellRangeInSelect(t,e){return function(t,e,i,n){for(let n=0;n<i.length;n++)if(Jp(i[n],{start:t,end:e}))return!0;return!1}(t,e,this.select.ranges,this.select.highlightScope)}updateHoverIcon(t,e,i,n,r){if(i===this.residentHoverIcon?.icon)return;const o=tV(i);if(o)if("richtext-icon"===o.type){const i=o.icon;if(this.hoverIcon.icon&&this.hoverIcon.icon!==this.residentHoverIcon?.icon&&(this.table.scenegraph.setIconNormalStyle(this.hoverIcon.icon,this.hoverIcon.col,this.hoverIcon.row),this.hoverIcon.col=-1,this.hoverIcon.col=-1,this.hoverIcon.icon=null,this.table.scenegraph.updateNextFrame()),i.attribute.tooltip){const n={content:i.attribute.tooltip.title,referencePosition:{rect:o.position,placement:i.attribute.tooltip.placement},style:Object.assign({},this.table.internalProps.theme?.tooltipStyle,i.tooltip?.style)};this.table.internalProps.tooltipHandler.isBinded(n)||this.table.showTooltip(t,e,n)}}else{const i=o.icon;i!==this.hoverIcon.icon&&(this.hoverIcon.icon&&this.hoverIcon.icon!==this.residentHoverIcon?.icon&&this.table.scenegraph.setIconNormalStyle(this.hoverIcon.icon,this.hoverIcon.col,this.hoverIcon.row),this.hoverIcon.col=t,this.hoverIcon.col=e,this.hoverIcon.icon=i,this.table.scenegraph.setIconHoverStyle(i,t,e,n),this.table.scenegraph.updateNextFrame())}else this.hoverIcon.icon&&this.hoverIcon.icon!==this.residentHoverIcon?.icon&&(this.table.scenegraph.setIconNormalStyle(this.hoverIcon.icon,this.hoverIcon.col,this.hoverIcon.row),this.hoverIcon.col=-1,this.hoverIcon.col=-1,this.hoverIcon.icon=null,this.table.scenegraph.updateNextFrame())}isResizeCol(){return this.columnResize.resizing}isSelecting(){return this.select.selecting}endSelectCells(){if(this.select.selecting=!1,0===this.select.ranges.length)return;this.table.scenegraph.moveSelectingRangeComponentsToSelectedRangeComponents();const t=this.select.ranges[this.select.ranges.length-1].end.col,e=this.select.ranges[this.select.ranges.length-1].end.row;this.table.fireListeners(sf.SELECTED_CELL,{ranges:this.select.ranges,col:t,row:e})}endResizeCol(){setTimeout((()=>{this.columnResize.resizing=!1}),0),this.table.scenegraph.updateChartSize(this.columnResize.col),this.checkFrozen(),this.table.scenegraph.component.hideResizeCol(),this.table.scenegraph.updateNextFrame()}startResizeCol(t,e,i,n){this.columnResize.resizing=!0,this.columnResize.col=t,this.columnResize.x=e,this.columnResize.isRightFrozen=n,this.table.scenegraph.component.showResizeCol(t,i,n),this.table.stateManeger.updateSelectPos(-1,-1),this.table.scenegraph.updateNextFrame()}updateResizeCol(t,e){!function(t,e,i){t=Math.ceil(t),e=Math.ceil(e);let n=i.columnResize.isRightFrozen?i.columnResize.x-t:t-i.columnResize.x;if(Math.abs(n)<1)return;const r=i.table.getColWidth(i.columnResize.col);let o=r;o+=n;const s=i.table.getMinColWidth(i.columnResize.col),a=i.table.getMaxColWidth(i.columnResize.col);if(o<s||o>a){if(r===s||r===a)return;n=r-s>a-r?a-r:s-r}n=Math.ceil(n),i.columnResize.col<i.table.rowHeaderLevelCount||i.columnResize.col>=i.table.colCount-i.table.rightFrozenColCount?eV(n,i):"indicator"===i.table.internalProps.columnResizeType?function(t,e){const i=e.table.internalProps.layoutMap;let n,r,o;if(i.indicatorsAsCol)n=i.getIndicatorKey(e.columnResize.col,e.table.columnHeaderLevelCount);else{const t=i.getCellHeaderPaths(e.columnResize.col,e.table.columnHeaderLevelCount-1),n=t.colHeaderPaths[t.colHeaderPaths.length-1];r=n.dimensionKey,o=n.value}for(let s=e.table.rowHeaderLevelCount;s<e.table.colCount-e.table.rightFrozenColCount;s++){const a=i.getIndicatorKey(s,e.table.columnHeaderLevelCount);if(i.indicatorsAsCol&&a===n)e.table.scenegraph.updateColWidth(s,t),e.table.internalProps._widthResizedColMap.add(s);else if(!i.indicatorsAsCol){const n=i.getCellHeaderPaths(s,e.table.columnHeaderLevelCount-1),a=n?.colHeaderPaths[n.colHeaderPaths.length-1];a&&r===a.dimensionKey&&o===a.value&&(e.table.scenegraph.updateColWidth(s,t),e.table.internalProps._widthResizedColMap.add(s))}}}(n,i):"indicatorGroup"===i.table.internalProps.columnResizeType?function(t,e){const i=e.table.internalProps.layoutMap,n=i.getCellHeaderPaths(e.columnResize.col,e.table.columnHeaderLevelCount),r=i.getHeadNode(n.colHeaderPaths.slice(0,n.colHeaderPaths.length-1)),o=r.startInTotal+e.table.frozenColCount,s=r.startInTotal+e.table.frozenColCount+r.size-1,a=e.table.getColsWidth(o,s),l=t;for(let t=o;t<=s;t++){if(!(e.table.internalProps.transpose||e.table.isPivotTable()&&!i.indicatorsAsCol)){const n=i.getBody(t,e.table.columnHeaderLevelCount);if(n?.disableColumnResize)continue}const n=e.table.getColWidth(t);e.table.scenegraph.updateColWidth(t,n/a*l),e.table.internalProps._widthResizedColMap.add(t)}}(n,i):"all"===i.table.internalProps.columnResizeType?function(t,e){const i=e.table.internalProps.layoutMap;for(let n=e.table.options.frozenColCount;n<e.table.colCount-e.table.rightFrozenColCount;n++){if(!(e.table.internalProps.transpose||e.table.isPivotTable()&&!i.indicatorsAsCol)){const t=i.getBody(n,e.table.columnHeaderLevelCount);if(t?.disableColumnResize)continue}e.table.scenegraph.updateColWidth(n,t),e.table.internalProps._widthResizedColMap.add(n)}}(n,i):eV(n,i),i.columnResize.x=t,i.table.scenegraph.component.updateResizeCol(i.columnResize.col,e,i.columnResize.isRightFrozen),i.columnResize.col<i.table.frozenColCount&&!i.table.isPivotTable()&&!i.table.transpose&&i.table.scenegraph.component.setFrozenColumnShadow(i.table.frozenColCount-1,i.columnResize.isRightFrozen),i.table.scenegraph.updateNextFrame()}(t,e,this)}startMoveCol(t,e,i,n){!function(t,e,i,n,r){if(!("canMoveHeaderPosition"in r.table.internalProps.layoutMap))return;r.columnMove.moving=!0,r.columnMove.colSource=t,r.columnMove.rowSource=e,r.columnMove.x=i-r.table.tableX,r.columnMove.y=n-r.table.tableY;const o=r.table.getCellLocation(t,e),s="columnHeader"===o?r.columnMove.x:"rowHeader"===o?r.columnMove.y:0;r.table.scenegraph.component.showMoveCol(t,e,s),r.table.stateManeger.updateSelectPos(-1,-1),r.table.scenegraph.updateNextFrame()}(t,e,i,n,this)}updateMoveCol(t,e,i,n){!function(t,e,i,n,r){if(!("canMoveHeaderPosition"in r.table.internalProps.layoutMap))return;const o=function(t,e,i){const n=i.getCellRange(t.col,t.row);if(i.isColumnHeader(t.col,t.row)){const r=i.getCellRange(e.col,n.start.row);e.row>=i.columnHeaderLevelCount&&(e.row=i.columnHeaderLevelCount-1),e.col>=t.col?e.col=r.end.col:e.col=r.start.col}else if(i.isRowHeader(t.col,t.row)){const r=i.getCellRange(n.start.col,e.row);e.col>=i.rowHeaderLevelCount&&(e.col=i.rowHeaderLevelCount-1);const o=i.internalProps.layoutMap;if("tree"===o.rowHierarchyType){const n=o.getCellHeaderPathsWidthTreeNode(t.col,t.row).rowHeaderPaths,r=o.getCellHeaderPathsWidthTreeNode(e.col,e.row).rowHeaderPaths;if(n.length<=r.length){const o=r[n.length-1];o&&(e.row>=t.row?e.row=o.startInTotal+o.size-1+i.columnHeaderLevelCount:e.row=o.startInTotal+i.columnHeaderLevelCount)}}else e.row>=t.row?e.row=r.end.row:e.row=r.start.row}return e}({col:r.columnMove.colSource,row:r.columnMove.rowSource},{col:t,row:e},r.table);let s,a,l,h;r.columnMove.x=i-r.table.tableX,r.columnMove.y=n-r.table.tableY,r.columnMove.colTarget=o.col,r.columnMove.rowTarget=o.row,r.table.internalProps.layoutMap.canMoveHeaderPosition({col:r.columnMove.colSource,row:r.columnMove.rowSource},{col:r.columnMove.colTarget,row:r.columnMove.rowTarget})?r.updateCursor("grabbing"):r.updateCursor("not-allowed");const c=r.table.getCellLocation(t,e);"columnHeader"===c?(a=r.columnMove.x,s=r.columnMove.colTarget>=r.columnMove.colSource?r.table.getColsWidth(0,r.columnMove.colTarget):r.table.getColsWidth(0,r.columnMove.colTarget-1)):"rowHeader"===c&&(h=r.columnMove.y,l=r.columnMove.rowTarget>=r.columnMove.rowSource?r.table.getRowsHeight(0,r.columnMove.rowTarget):r.table.getRowsHeight(0,r.columnMove.rowTarget-1)),r.table.scenegraph.component.updateMoveCol(a,s,h,l),r.table.scenegraph.updateNextFrame()}(t,e,i,n,this)}isMoveCol(){return this.columnMove.moving}endMoveCol(){QG(this)}checkFrozen(){if(this.table.options.frozenColCount){if(this.table.tableNoFrameWidth-this.table.getColsWidth(0,this.table.options.frozenColCount-1)<=120)return this.table._setFrozenColCount(0),this.setFrozenCol(-1),!1;if(this.table.frozenColCount!==this.table.options.frozenColCount)return this.table._setFrozenColCount(this.table.options.frozenColCount),this.setFrozenCol(this.table.options.frozenColCount),!1}return!0}setFrozenCol(t){t!==this.frozen.col?(this.frozen.col=t,this.table.scenegraph.updateFrozen(),this.table.scenegraph.updateFrozenIcon(0,this.table.colCount-1)):this.table.scenegraph.updateFrozenIcon(0,this.table.colCount-1)}updateVerticalScrollBar(t){const e=this.table.getAllRowsHeight();this.scroll.verticalBarPos=Math.ceil(t*(e-this.table.scenegraph.height)),this.table.scenegraph.setY(-this.scroll.verticalBarPos),this.table.stateManeger.updateHoverPos(-1,-1),this.table.fireListeners(sf.SCROLL,{scrollTop:this.scroll.verticalBarPos,scrollLeft:this.scroll.horizontalBarPos,scrollHeight:this.table.theme.scrollStyle?.width,scrollWidth:this.table.theme.scrollStyle?.width,viewHeight:this.table.tableNoFrameHeight,viewWidth:this.table.tableNoFrameWidth})}updateHorizontalScrollBar(t){const e=this.table.getAllColsWidth();this.scroll.horizontalBarPos=Math.ceil(t*(e-this.table.scenegraph.width)),this.table.scenegraph.setX(-this.scroll.horizontalBarPos),this.table.stateManeger.updateHoverPos(-1,-1),this.table.fireListeners(sf.SCROLL,{scrollTop:this.scroll.verticalBarPos,scrollLeft:this.scroll.horizontalBarPos,scrollHeight:this.table.theme.scrollStyle?.width,scrollWidth:this.table.theme.scrollStyle?.width,viewHeight:this.table.tableNoFrameHeight,viewWidth:this.table.tableNoFrameWidth})}setScrollTop(t){const e=this.table.getAllRowsHeight();t=Math.max(0,Math.min(t,e-this.table.scenegraph.height)),t=Math.ceil(t),this.scroll.verticalBarPos=t,this.table.scenegraph.setY(-t),this.table.scenegraph.component.updateVerticalScrollBarPos(t/(e-this.table.scenegraph.height)),this.table.stateManeger.updateHoverPos(-1,-1),this.table.fireListeners(sf.SCROLL,{scrollTop:this.scroll.verticalBarPos,scrollLeft:this.scroll.horizontalBarPos,scrollHeight:this.table.theme.scrollStyle?.width,scrollWidth:this.table.theme.scrollStyle?.width,viewHeight:this.table.tableNoFrameHeight,viewWidth:this.table.tableNoFrameWidth})}setScrollLeft(t){const e=this.table.getAllColsWidth(),i=this.table.getFrozenColsWidth();t=Math.max(0,Math.min(t,e-this.table.scenegraph.width)),t=Math.ceil(t),this.scroll.horizontalBarPos=t,this.table.scenegraph.setX(-t),this.table.scenegraph.component.updateHorizontalScrollBarPos(t/(e-i)),this.table.stateManeger.updateHoverPos(-1,-1),this.table.fireListeners(sf.SCROLL,{scrollTop:this.scroll.verticalBarPos,scrollLeft:this.scroll.horizontalBarPos,scrollHeight:this.table.theme.scrollStyle?.width,scrollWidth:this.table.theme.scrollStyle?.width,viewHeight:this.table.tableNoFrameHeight,viewWidth:this.table.tableNoFrameWidth})}hideVerticalScrollBar(){this.table.scenegraph.component.hideVerticalScrollBar()}showVerticalScrollBar(t){this.table.scenegraph.component.showVerticalScrollBar(),t&&(clearTimeout(this._clearVerticalScrollBar),this._clearVerticalScrollBar=setTimeout((()=>{this.table.scenegraph.component.hideVerticalScrollBar()}),1e3))}hideHorizontalScrollBar(){this.table.scenegraph.component.hideHorizontalScrollBar()}showHorizontalScrollBar(t){this.table.scenegraph.component.showHorizontalScrollBar(),t&&(clearTimeout(this._clearHorizontalScrollBar),this._clearHorizontalScrollBar=setTimeout((()=>{this.table.scenegraph.component.hideHorizontalScrollBar()}),1e3))}triggerContextMenu(t,e,i,n){this.menu.isShow&&this.menu.x===i&&this.menu.y===n?this.hideMenu():this.showContextMenu(t,e,i,n)}showContextMenu(t,e,i,n){this.table.internalProps.menu?.contextMenuItems&&("html"===this.table.internalProps.menu.renderMode?this.menu.isShow=!0:(this.menu.isShow=!0,this.menu.x=i,this.menu.y=n,this.table.scenegraph.component.menu.attach(i,n,t,e,Nj.contextmenu)),this.table.fireListeners(sf.SHOW_MENU,{x:i,y:n,col:t,row:e,type:"contextmenu"}))}triggerDropDownMenu(t,e,i,n){this.table.fireListeners(sf.DROPDOWN_ICON_CLICK,{col:t,row:e}),this.menu.isShow?this.hideMenu():this.showDropDownMenu(t,e,i,n)}showDropDownMenu(t,e,i,n){"html"===this.table.internalProps.menu.renderMode?this.menu.isShow=!0:(this.menu.isShow=!0,this.table.scenegraph.component.menu.attach(i,n,t,e,Nj.dropDown),this.menu.bounds=this.table.scenegraph.component.menu.bounds),this.table.fireListeners(sf.SHOW_MENU,{x:i,y:n,col:t,row:e,type:"dropDown"}),this.residentHoverIcon&&this.table.scenegraph.setIconNormalStyle(this.residentHoverIcon.icon,this.residentHoverIcon.col,this.residentHoverIcon.row);const r=this.table.scenegraph.getCell(t,e);let o;r.forEachChildren((t=>t.attribute.funcType===Jc.dropDown&&(o=t,!0))),o&&(this.residentHoverIcon={col:t,row:e,icon:o},this.table.scenegraph.setIconHoverStyle(this.residentHoverIcon.icon,this.residentHoverIcon.col,this.residentHoverIcon.row,r),o.oldVisibleTime=o.attribute.visibleTime,o.setAttribute("visibleTime","always"),o.setAttribute("visible",!0))}hideMenu(){this.table.fireListeners(sf.DROPDOWN_MENU_CLEAR,null),this.table.fireListeners(sf.HIDE_MENU,null),this.menu.isShow=!1,this.table.scenegraph.component.menu.detach(),this.residentHoverIcon&&(this.table.scenegraph.setIconNormalStyle(this.residentHoverIcon.icon,this.residentHoverIcon.col,this.residentHoverIcon.row),this.residentHoverIcon.icon.setAttribute("visibleTime",this.residentHoverIcon.icon.oldVisibleTime),this.residentHoverIcon.icon.setAttribute("visible","always"===this.residentHoverIcon.icon.attribute.visibleTime),this.residentHoverIcon=null)}setDropDownMenuHighlight(t){this.menu.dropDownMenuHighlight=t;for(let e=0;e<t.length;e++){const{col:i,row:n}=t[e];this.table.scenegraph.updateCellContent(i,n)}}dropDownMenuIsHighlight(t,e,i){const n=this.menu.dropDownMenuHighlight;if(Array.isArray(n))for(let r=0;r<n.length;r++){const o=n[r];let{col:s,row:a}=o;const{field:l,menuKey:h}=o;if("number"!=typeof s||"number"!=typeof a)if(this.table.isPivotTable()&&(Array.isArray(l),1)){const t=this.table.internalProps.layoutMap.getPivotCellAdress(l);if(!t)continue;s=t.col,a=t.row}else{const t=this.table.internalProps.layoutMap.getHeaderCellAddressByField(l);if(!t)continue;s=t.col,a=t.row}if(bu(s)&&bu(a)&&this.table.isCellRangeEqual(t,e,s,a)){const n=this.table._getHeaderLayoutMap(s??t,a??e).dropDownMenu||this.table.globalDropDownMenu;if(n)for(let t=0;t<n.length;t++){const e=n[t];if(ou(e)&&(e.menuKey||e.text)===(h||"")&&t===i)return!0;if(au(e)&&e===h&&t===i)return!0}}}return!1}triggerSort(t,e,i){if(this.table.isPivotTable()){const i=this.table.getPivotSortState(t,e);return void this.table.fireListeners(ZG.PIVOT_SORT_CLICK,{col:t,row:e,order:i||"normal",dimensionInfo:this.table.internalProps.layoutMap.getPivotDimensionInfo(t,e),cellLocation:this.table.getCellLocation(t,e)})}const n=this.sort.col,r=this.sort.row;YG(t,e,this.table),this.sort.col=t,this.sort.row=e,this.table.scenegraph.updateSortIcon(this.sort.col,this.sort.row,i,this.sort.order,n,r,this.sort.icon),this.sort.icon=i}updateSortState(t){if(t.field===this.sort.field&&t.order===this.sort.order)return;const e=this.sort.col,i=this.sort.row,n="asc"===this.sort.order?"sort_downward":"desc"===this.sort.order?"sort_upward":"sort_normal";this.setSortState(t);const r=this.table.internalProps.layoutMap.getHeaderCellAddressByField(t.field);this.sort.col=r.col,this.sort.row=r.row;const o=this.table.scenegraph.getCell(this.sort.col,this.sort.row).getChildByName(n,!0);this.table.scenegraph.sortCell(),this.table.scenegraph.updateSortIcon(this.sort.col,this.sort.row,o,this.sort.order,e,i,this.sort.icon)}triggerFreeze(t,e,i){this.table.isPivotTable()||this.table.transpose||(!function(t,e,i){i.frozenColCount>0?t!==i.frozenColCount-1?i.setFrozenColCount(t+1):i.setFrozenColCount(0):i.setFrozenColCount(t+1)}(t,0,this.table),this.frozen.icon=i)}updateCursor(t="default"){this.table.getElement().style.cursor=t}updateDrillState(t,e,i,n,r,o){this.drill.dimensionKey=t,this.drill.title=e,this.drill.drillDown=i,this.drill.drillUp=n,this.drill.col=r,this.drill.row=o,function(t,e,i,n,r){const o=r.getCellLocation(t,e);let s=0,a=0,l=!1;"columnHeader"===o?(s=r.getColsWidth(0,r.rowHeaderLevelCount-1)-(0===r.frozenColCount?r.scrollLeft:0),a=r.getRowsHeight(0,e-1)+r.getRowHeight(e)/2,l=!0):"rowHeader"===o&&(a=r.getRowsHeight(0,r.columnHeaderLevelCount-1),s=r.getColsWidth(0,t-1)+r.getColWidth(t)/2,l=!0),r.scenegraph.updateDrill(l,s,a,i,n)}(r,o,i,n,this.table)}updateSparklineHoverPose(t,e,i,n){-1!==this.sparkLine.col&&-1!==this.sparkLine.row&&function(t,e,i){const n=i.scenegraph.getCell(t,e).getChildByName("sparkline"),r=n?.getChildByName("highlight-line"),o=n?.getChildByName("highlight-symbol");r&&r.setAttributes({visible:!1,pickable:!1}),o&&o.setAttributes({visible:!1,pickable:!1}),i.scenegraph.updateNextFrame()}(this.sparkLine.col,this.sparkLine.row,this.table),-1!==t&&-1!==e&&function(t,e,i,n,r){const o=r.scenegraph.getCell(t,e).getChildByName("sparkline"),s=o?.getChildByName("sparkline-line"),a=o?.getChildByName("sparkline-symbol-group");if(!s)return;const l=s.bandwidth,h=s.min,c=s.max,u=s.attribute.points;let d;i-=o.globalAABBBounds.x1,o.globalAABBBounds.y1;for(let t=0;t<u.length;t++){const{x:e,y:n,defined:r,rawData:p}=u[t];if(Math.abs(i-e)<l/2&&(d={point:u[t],points:u,pointsBandWidth:l,pointData:p},r)){const t=o.getChildByName("highlight-line");if(t)t.setAttributes({x:e,visible:!0,pickable:!0});else{const t=QA({x:e,y:0,points:[{x:0,y:c},{x:0,y:h}],lineWidth:s.hover.strokeWidth,stroke:s.hover.stroke});t.name="highlight-line",o.addChild(t)}const i=o.getChildByName("highlight-symbol");if(i)i.setAttributes({x:e,y:n,visible:!0,pickable:!0});else{const t=nT({x:e,y:n,stroke:a.hover.stroke,lineWidth:a.hover.strokeWidth,fill:a.hover.fill,size:2*a.hover.size,symbolType:"circle"});t.name="highlight-symbol",o.addChild(t)}break}}if(r.scenegraph.updateNextFrame(),d){const i={col:t,row:e,field:r.getHeaderField(t,e),value:r.getCellValue(t,e),dataValue:r.getCellOriginValue(t,e),cellHeaderPaths:r.internalProps.layoutMap.getCellHeaderPaths(t,e),title:r.getBodyColumnDefine(t,e).title,cellRange:r.getCellRelativeRect(t,e),sparkline:{pointData:d.pointData},scaleRatio:r.canvas.getBoundingClientRect().width/r.canvas.offsetWidth};r.fireListeners(sf.MOUSEOVER_CHART_SYMBOL,i)}}(t,e,i,0,this.table),this.sparkLine.col=t,this.sparkLine.row=e}}function nV(t){const e={abstractPos:{x:t.x,y:t.y}},i=function(t){for(;t&&t.parent;){if("cell"===t.role)return t;t=t.parent}return null}(t.target);return i&&(e.eventArgs={col:i.col,row:i.row,event:t,targetCell:i,target:t.target}),e}let rV,oV;function sV(t){if(t.stateManeger.endResizeCol(),t.hasListeners(sf.RESIZE_COLUMN_END)){const e=[];for(let i=0;i<t.colCount;i++)e.push(t.getColWidth(i));t.fireListeners(sf.RESIZE_COLUMN_END,{col:t.stateManeger.columnResize.col,columns:e})}}function aV(t,e){let{deltaX:i,deltaY:n}=t;t.shiftKey&&t.deltaY&&(i=n,n=0);const[r,o]=function(t,e,i){const n=2,r=Math.abs(t/e),o=r<=1/n?0:t,s=r>n?0:e;return[Math.ceil(o*(i.horizontal??0)),Math.ceil(s*(i.vertical??0))]}(i,n,{horizontal:1,vertical:1});(r||o)&&e.interactionState!==Uc.scrolling&&e.updateInteractionState(Uc.scrolling),r&&(e.setScrollLeft(e.scroll.horizontalBarPos+r),e.showHorizontalScrollBar(!0)),o&&(e.setScrollTop(e.scroll.verticalBarPos+o),e.showVerticalScrollBar(!0)),e.resetInteractionState(),t.cancelable&&(0!==n&&lV(n,e)||0!==i&&hV(i,e))&&t.preventDefault()}function lV(t,e){return 0!=e.table.getAllRowsHeight()-e.table.scenegraph.height&&(!function(t,e){const i=e.table.getAllRowsHeight()-e.table.scenegraph.height;return 0!==i&&t<=0&&e.scroll.verticalBarPos<1}(t,e)&&!function(t,e){const i=e.table.getAllRowsHeight()-e.table.scenegraph.height;return 0!==i&&t>=0&&Math.abs(e.scroll.verticalBarPos-i)<1}(t,e))}function hV(t,e){return 0!=e.table.getAllColsWidth()-e.table.scenegraph.width&&(!function(t,e){const i=e.table.getAllColsWidth()-e.table.scenegraph.width;return 0!==i&&t<=0&&e.scroll.horizontalBarPos<1}(t,e)&&!function(t,e){const i=e.table.getAllColsWidth()-e.table.scenegraph.width;return 0!==i&&t>=0&&Math.abs(e.scroll.horizontalBarPos-i)<1}(t,e))}function cV(t){const e=t.table,i=e.stateManeger,n=e.scenegraph;t.touchMovePoints=[],e.scenegraph.tableGroup.addEventListener("touchstart",(e=>{e.target.isChildOf(n.component.vScrollBar)||e.target.isChildOf(n.component.vScrollBar)||(t.isTouchdown=!0,t.touchMovePoints.push({x:e.page.x,y:e.page.y,timestamp:Date.now()}))})),window.addEventListener("touchmove",(e=>{if(t.touchMove&&e.preventDefault(),!t.isTouchdown||!uV(e))return;t.touchMovePoints.length>4&&t.touchMovePoints.shift(),t.touchMovePoints.push({x:e.changedTouches[0].pageX,y:e.changedTouches[0].pageY,timestamp:Date.now()});const n=-t.touchMovePoints[t.touchMovePoints.length-1].x+t.touchMovePoints[t.touchMovePoints.length-2].x,r=-t.touchMovePoints[t.touchMovePoints.length-1].y+t.touchMovePoints[t.touchMovePoints.length-2].y;aV({deltaX:n,deltaY:r},i),e.cancelable&&(0!==r&&lV(r,i)||0!==n&&hV(n,i))&&e.preventDefault()}),{passive:!1}),window.addEventListener("touchend",(e=>{if(t.touchEnd=!0,t.touchMove=!1,t.isTouchdown&&uV(e)){if(t.touchMovePoints?.length){t.touchMovePoints.length>4&&t.touchMovePoints.shift(),t.touchMovePoints.push({x:e.changedTouches[0].pageX,y:e.changedTouches[0].pageY,timestamp:Date.now()});const n=t.touchMovePoints[0],r=t.touchMovePoints[t.touchMovePoints?.length-1];!function(t,e,i){let n=Date.now();const r=.95,o=()=>{const s=Date.now(),a=s-n;let l=!0;const h=Math.pow(r,a/16),c=h*t,u=h*e;let d=0,p=0;Math.abs(c)>.05&&(l=!1,d=(t+c)/2*a),Math.abs(u)>.05&&(l=!1,p=(e+u)/2*a),aV({deltaX:-d,deltaY:-p},i),l||(n=s,t=c,e=u,requestAnimationFrame(o))};requestAnimationFrame(o)}((r.x-n.x)/(r.timestamp-n.timestamp),(r.y-n.y)/(r.timestamp-n.timestamp),i)}t.isTouchdown=!1,t.touchMovePoints=[]}})),window.addEventListener("touchcancel",(e=>{t.touchEnd=!0,t.touchMove=!1,t.isTouchdown&&(t.isTouchdown=!1,t.touchMovePoints=[])}))}function uV(t){return!!t.changedTouches}function dV(t,e,i){if(i.indicatorsAsCol){if(i.hasTwoIndicatorAxes&&e===i.columnHeaderLevelCount-1&&t>=i.rowHeaderLevelCount&&t<i.colCount-i.rightFrozenColCount)return"top";if(e===i.rowCount-i.bottomFrozenRowCount&&t>=i.rowHeaderLevelCount&&t<i.colCount-i.rightFrozenColCount)return"bottom";if(t===i.rowHeaderLevelCount-1&&e>=i.rowHeaderLevelCount&&e<i.rowCount-i.bottomFrozenRowCount)return"left"}else{if(t===i.rowHeaderLevelCount-1&&e>=i.columnHeaderLevelCount&&e<i.rowCount-i.bottomFrozenRowCount)return"left";if(t===i.colCount-i.rightFrozenColCount&&e>=i.columnHeaderLevelCount&&e<i.rowCount-i.bottomFrozenRowCount)return"right";if(e===i.rowCount-i.bottomFrozenRowCount&&t>=i.rowHeaderLevelCount&&t<i.colCount-i.rightFrozenColCount)return"bottom"}return"bottom"}class pV{table;isTouchdown;touchMovePoints;touchSetTimeout;touchEnd;touchMove;constructor(t){this.table=t,this.bindOuterEvent(),setTimeout((()=>{this.bindSelfEvent()}),0)}bindOuterEvent(){!function(t){const e=t.table,i=e.stateManeger;document.body.addEventListener("pointermove",(n=>{t.touchSetTimeout&&(clearTimeout(t.touchSetTimeout),t.touchSetTimeout=void 0);const{x:r,y:o}=e._getMouseAbstractPoint(n,!1);i.interactionState!==Uc.scrolling&&i.interactionState===Uc.grabing&&i.isResizeCol()&&(t.dealColumnResize(r,o),e.hasListeners(sf.RESIZE_COLUMN)&&e.fireListeners(sf.RESIZE_COLUMN,{col:e.stateManeger.columnResize.col,colWidth:e.getColWidth(e.stateManeger.columnResize.col)}))})),e.scenegraph.tableGroup.addEventListener("pointermove",(n=>{const r=rV?.x??n.x,o=rV?.y??n.y;rV={x:n.x,y:n.y},t.touchSetTimeout&&(clearTimeout(t.touchSetTimeout),t.touchSetTimeout=void 0);const s=nV(n);if(i.interactionState===Uc.scrolling)return;if(i.interactionState===Uc.grabing&&Math.abs(r-n.x)+Math.abs(o-n.y)>=1)return void(i.isResizeCol()||(i.isMoveCol()?t.dealColumnMover(s):t.dealTableSelect(s)));i.isResizeCol()||t.checkColumnResize(s)?i.updateCursor("col-resize"):i.updateCursor();const a=n.path.find((t=>"cell"===t.role));if(e.hasListeners(sf.MOUSELEAVE_CELL)&&("cell"!==a?.role||-1===e.stateManeger.hover.cellPos.col||-1===e.stateManeger.hover.cellPos.row||a.col===e.stateManeger.hover.cellPos.col&&a.row===e.stateManeger.hover.cellPos.row||e.fireListeners(sf.MOUSELEAVE_CELL,{col:e.stateManeger.hover.cellPos.col,row:e.stateManeger.hover.cellPos.row,cellRange:e.getCellRangeRelativeRect({col:e.stateManeger.hover.cellPos.col,row:e.stateManeger.hover.cellPos.row}),scaleRatio:e.canvas.getBoundingClientRect().width/e.canvas.offsetWidth,event:n.nativeEvent})),e.hasListeners(sf.MOUSEENTER_CELL)&&"cell"===a?.role&&Uu(a.col)&&Uu(a.row)&&(a.col!==e.stateManeger.hover.cellPos.col||a.row!==e.stateManeger.hover.cellPos.row)&&e.fireListeners(sf.MOUSEENTER_CELL,{col:a.col,row:a.row,cellRange:e.getCellRangeRelativeRect({col:a.col,row:a.row}),scaleRatio:e.canvas.getBoundingClientRect().width/e.canvas.offsetWidth,event:n.nativeEvent}),t.dealIconHover(s),t.dealTableHover(s),s.eventArgs&&e.hasListeners(sf.MOUSEMOVE_CELL)){let t,i;if(s.eventArgs?.target){const e=tV(s.eventArgs?.target);e&&(t=e.icon,i=e.position)}e.fireListeners(sf.MOUSEMOVE_CELL,{col:s.eventArgs.col,row:s.eventArgs.row,x:s.abstractPos.x,y:s.abstractPos.y,event:n.nativeEvent,targetIcon:t?{name:t.name,position:i,funcType:t.attribute.funcType}:void 0})}})),e.scenegraph.tableGroup.addEventListener("pointerout",(e=>{const i=nV(e),n=i?.eventArgs?.target;"table"===n?.role&&t.dealTableHover()})),e.scenegraph.tableGroup.addEventListener("pointerover",(t=>{const i=nV(t),n=i?.eventArgs?.target;if(e.hasListeners(sf.MOUSEOVER_CHART_SYMBOL)&&"symbol"===n.type){const i=t.composedPath().find((t=>"cell"===t.roll));if(i){const{col:n,row:r}=i,o={col:n,row:r,field:e.getHeaderField(n,r),value:e.getCellValue(n,r),dataValue:e.getCellOriginValue(n,r),cellHeaderPaths:e.internalProps.layoutMap.getCellHeaderPaths(n,r),title:e.getBodyColumnDefine(n,r).title,cellRange:e.getCellRelativeRect(n,r),event:t.nativeEvent,sparkline:{pointData:void 0},scaleRatio:e.canvas.getBoundingClientRect().width/e.canvas.offsetWidth};e.fireListeners(sf.MOUSEOVER_CHART_SYMBOL,o)}}})),e.scenegraph.tableGroup.addEventListener("pointerleave",(n=>{i.isResizeCol()||(i.updateInteractionState(Uc.default),i.updateCursor()),t.dealTableHover();const r=n.target;r&&!r.isDescendantsOf(e.scenegraph.tableGroup)&&e.fireListeners(sf.MOUSELEAVE_TABLE,{col:-1,row:-1,event:n.nativeEvent})})),e.scenegraph.tableGroup.addEventListener("pointerupoutside",(n=>{console.log("pointerupoutside"),i.isResizeCol()&&sV(e),i.updateInteractionState(Uc.default),t.dealTableHover(),t.dealTableSelect()})),e.scenegraph.tableGroup.addEventListener("pointerdown",(n=>{if(rV={x:n.x,y:n.y},0!==n.button)return;const r=nV(n);if(i.interactionState!==Uc.default)return;e.isPivotChart()&&"chart"!==r?.eventArgs?.target.type&&e.scenegraph.updateChartState(null),i.menu.isShow&&r.eventArgs&&r.eventArgs.target!==i.residentHoverIcon?.icon&&i.hideMenu();const o=r?.eventArgs?.target?.role?.startsWith("icon")?r.eventArgs.target:void 0;if(!o||!1===o.attribute.interactive)if("touch"===n.pointerType)t.touchEnd=!1,t.touchSetTimeout=setTimeout((()=>{t.isTouchdown=!1,t.touchMove=!0,(!t.touchEnd&&t.checkColumnResize(r,!0)||!t.touchEnd&&t.chechColumnMover(r)||t.dealTableSelect(r)&&!t.touchEnd)&&i.updateInteractionState(Uc.grabing)}),500);else{if(t.checkColumnResize(r,!0))return e.scenegraph.updateChartState(null),void i.updateInteractionState(Uc.grabing);if(t.chechColumnMover(r))return void i.updateInteractionState(Uc.grabing);t.dealTableSelect(r)&&i.updateInteractionState(Uc.grabing)}if(e.hasListeners(sf.MOUSEDOWN_CELL)){const t=nV(n);t.eventArgs&&e.fireListeners(sf.MOUSEDOWN_CELL,{col:t.eventArgs.col,row:t.eventArgs.row,event:n.nativeEvent})}})),e.scenegraph.tableGroup.addEventListener("pointerup",(t=>{if(0===t.button){if("grabing"===i.interactionState){if(i.updateInteractionState(Uc.default),i.isResizeCol())sV(e);else if(i.isMoveCol()){e.stateManeger.endMoveCol();const i=nV(t);i.eventArgs&&e.hasListeners(sf.CHANGE_HEADER_POSITION)&&e.fireListeners(sf.CHANGE_HEADER_POSITION,{target:{col:i.eventArgs.col,row:i.eventArgs.row},source:{col:e.stateManeger.columnMove.colSource,row:e.stateManeger.columnMove.colSource}})}else if(i.isSelecting()){e.stateManeger.endSelectCells();const i=nV(t);if(i.eventArgs&&e.hasListeners(sf.DRAG_SELECT_END)){const n={event:t.nativeEvent,cells:[],col:i.eventArgs.target.col,row:i.eventArgs.target.row,scaleRatio:e.canvas.getBoundingClientRect().width/e.canvas.offsetWidth};n.cells=e.getSelectedCellInfos(),e.fireListeners(sf.DRAG_SELECT_END,n)}}}else i.interactionState===Uc.scrolling&&i.updateInteractionState(Uc.default);if(e.hasListeners(sf.MOUSEUP_CELL)){const i=nV(t);i.eventArgs&&e.fireListeners(sf.MOUSEUP_CELL,{col:i.eventArgs.col,row:i.eventArgs.row,event:t.nativeEvent})}}})),e.scenegraph.tableGroup.addEventListener("rightdown",(t=>{const n=nV(t);if(n.eventArgs){i.triggerContextMenu(n.eventArgs.col,n.eventArgs.row,n.abstractPos.x,n.abstractPos.y);const{col:r,row:o}=n.eventArgs;if(e.hasListeners(sf.CONTEXTMENU_CELL)){const i=e.getCellInfo(r,o);let s,a;if(n.eventArgs?.target){const t=tV(n.eventArgs?.target);t&&(s=t.icon,a=t.position)}const l={...i,event:t.nativeEvent,cells:[],targetIcon:s?{name:s.name,position:a,funcType:s.attribute.funcType}:void 0};!function(t,e,i){for(let n=0;n<t.length;n++){const r=t[n];if(r.start.col<=e&&e<=r.end.col&&r.start.row<=i&&i<=r.end.row||r.end.col<=e&&e<=r.start.col&&r.end.row<=i&&i<=r.start.row)return!0}return!1}(e.stateManeger.select.ranges,r,o)?l.cells=[[i]]:l.cells=e.getSelectedCellInfos(),e.fireListeners(sf.CONTEXTMENU_CELL,l)}}})),e.scenegraph.tableGroup.addEventListener("click",(i=>{if(console.log("click",i.clone()),e.stateManeger.columnResize.resizing||e.stateManeger.columnMove.moving)return;const n=nV(i);if(t.dealIconClick(i,n),!n?.eventArgs)return;const{col:r,row:o}=n.eventArgs;if(e.hasListeners(sf.CLICK_CELL)){const t=e.getCellInfo(r,o);let s,a;if(n.eventArgs?.target){const t=tV(n.eventArgs?.target);t&&(s=t.icon,a=t.position)}const l={...t,event:i.nativeEvent,cells:[],targetIcon:s?{name:s.name,position:a,funcType:s.attribute.funcType}:void 0};e.fireListeners(sf.CLICK_CELL,l)}})),e.scenegraph.stage.addEventListener("click",(n=>{console.log("stage click");const r=n.target;r&&!r.isDescendantsOf(e.scenegraph.tableGroup)&&r!==e.scenegraph.tableGroup&&(console.log("pointerup outside table"),i.updateInteractionState(Uc.default),t.dealTableHover(),t.dealTableSelect(),i.updateCursor(),e.scenegraph.updateChartState(null))})),e.scenegraph.tableGroup.addEventListener("dblclick",(t=>{const i=nV(t),n=i.eventArgs.targetCell.globalAABBBounds,{col:r,row:o}=i.eventArgs,s=e.getCellValue(r,o);if(e.internalProps.focusControl.setFocusRect(new gf(n.x1+e.scrollLeft,n.y1+e.scrollTop,n.x2-n.x1,n.y2-n.y1),s),e.hasListeners(sf.DBLCLICK_CELL)){const n=e.getCellInfo(r,o);let s,a;if(i.eventArgs?.target){const t=tV(i.eventArgs?.target);t&&(s=t.icon,a=t.position)}const l={...n,event:t.nativeEvent,federatedEvent:t,cells:[],targetIcon:s?{name:s.name,position:a,funcType:s.attribute.funcType}:void 0};e.fireListeners(sf.DBLCLICK_CELL,l)}}))}(this),function(t){const e=t.table,i=e.stateManeger,n=e.internalProps.handler;n.on(e.getElement(),"blur",(e=>{console.log("blur"),t.dealTableHover()})),n.on(e.getElement(),"wheel",(t=>{aV(t,i)})),n.on(e.getElement(),"keydown",(i=>{if(e.keyboardOptions?.selectAllOnCtrlA&&"a"===i.key&&(i.ctrlKey||i.metaKey)&&(i.preventDefault(),t.deelTableSelectAll()),e.hasListeners(sf.KEYDOWN)){const t={keyCode:i.keyCode??i.which,code:i.code,event:i,cells:e.getSelectedCellInfos(),scaleRatio:e.canvas.getBoundingClientRect().width/e.canvas.offsetWidth};e.fireListeners(sf.KEYDOWN,t)}})),n.on(e.getElement(),"copy",(t=>{if(e.keyboardOptions?.copySelected){const i=e.getCopyValue();Uu(i)&&(t.preventDefault(),Qp?window.clipboardData.setData("Text",i):t.clipboardData.setData("text/plain",i))}})),n.on(e.getElement(),"contextmenu",(t=>{t.preventDefault()})),n.on(e.getContainer(),"resize",(()=>{e.resize()}))}(this),function(t){const e=t.table,i=e.stateManeger,n=e.scenegraph;n.component.vScrollBar.addEventListener("pointerover",(t=>{i.showVerticalScrollBar()})),n.component.hScrollBar.addEventListener("pointerover",(t=>{i.showHorizontalScrollBar()})),n.component.vScrollBar.addEventListener("pointerout",(t=>{i.interactionState!==Uc.scrolling&&i.hideVerticalScrollBar()})),n.component.hScrollBar.addEventListener("pointerout",(t=>{i.interactionState!==Uc.scrolling&&i.hideHorizontalScrollBar()})),n.component.vScrollBar._slider.addEventListener("pointerdown",(()=>{i.interactionState!==Uc.scrolling&&i.updateInteractionState(Uc.scrolling)})),n.component.vScrollBar.addEventListener("pointerup",(()=>{i.interactionState===Uc.scrolling&&i.updateInteractionState(Uc.default)})),n.component.vScrollBar.addEventListener("pointerupoutside",(()=>{i.interactionState===Uc.scrolling&&i.updateInteractionState(Uc.default)})),n.component.hScrollBar._slider.addEventListener("pointerdown",(()=>{i.interactionState!==Uc.scrolling&&i.updateInteractionState(Uc.scrolling)})),n.component.hScrollBar.addEventListener("pointerup",(()=>{i.interactionState===Uc.scrolling&&i.updateInteractionState(Uc.default)})),n.component.hScrollBar.addEventListener("pointerupoutside",(()=>{i.interactionState===Uc.scrolling&&i.updateInteractionState(Uc.default)}));const r=gu(i.updateVerticalScrollBar,20),o=gu(i.updateHorizontalScrollBar,20);n.component.vScrollBar.addEventListener("scroll",(t=>{i.interactionState!==Uc.scrolling&&i.updateInteractionState(Uc.scrolling);const e=t.detail.value[0]/(1-t.detail.value[1]+t.detail.value[0]);r(e,t)})),n.component.hScrollBar.addEventListener("scroll",(t=>{i.interactionState!==Uc.scrolling&&i.updateInteractionState(Uc.scrolling);const e=t.detail.value[0]/(1-t.detail.value[1]+t.detail.value[0]);o(e)}))}(this),cV(this)}bindSelfEvent(){const t=this.table.stateManeger;var e;this.table.on(sf.ICON_CLICK,(e=>{const{col:i,row:n,x:r,y:o,funcType:s,icon:a}=e;var l;s===Jc.dropDown?t.triggerDropDownMenu(i,n,r,o):s===Jc.sort?t.triggerSort(i,n,a):s===Jc.frozen?t.triggerFreeze(i,n,a):s===Jc.drillDown?(l=this.table).fireListeners(ZG.DRILLMENU_CLICK,l.stateManeger.drill):s!==Jc.collapse&&s!==Jc.expand||this.table.toggleHierarchyState(i,n)})),this.table.on(sf.DROPDOWNMENU_CLICK,(()=>{t.hideMenu()})),function(t){const e=t.internalProps.layoutMap.headerObjects,i=t.internalProps.layoutMap.columnObjects;for(let t=0;t<e.length;t++){const i=e[t];if(i&&i.style?.textStick)return console.log("checkHaveTextStick",!0),!0}for(let t=0;t<i.length;t++){const e=i[t];if(e&&e.style?.textStick)return console.log("checkHaveTextStick",!0),!0}return console.log("checkHaveTextStick",!1),!1}(this.table)&&this.table.on(sf.SCROLL,(t=>{TG(this.table)})),e=this.table,"browser"===hf.mode&&e.on(sf.CLICK_CELL,(t=>{const{col:i,row:n}=t;let r;r=e.internalProps.layoutMap.isHeader(i,n)?e.isPivotTable()?e._getHeaderLayoutMap(i,n).headerType:e.getHeaderDefine(i,n).headerType:e.getBodyColumnType(i,n);const o=e.isHeader(i,n)?e.getHeaderDefine(i,n):e.getBodyColumnDefine(i,n),s=e.getCellValue(i,n),a=e.getCellOriginValue(i,n);if("link"===o.cellType){if(!1===o.linkJump)return;const t=o.templateLink,r=!1!==o.linkDetect;let l;if(t){const r=e.getCellOriginRecord(i,n),o=Object.assign({__value:s,__dataValue:a},r),h=/\{\s*(\S+?)\s*\}/g;l=t.replace(h,((t,e)=>o[e]))}else if(r){if(!_f.test(s))return;l=s}else l=s;window.open(l)}else if("image"===r){const t=document.createElement("div");t.style.width="100%",t.style.height="100%",t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.backgroundColor="rgba(30, 30, 30, 0.4)",t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center",t.style.overflow="hidden",t.style.zIndex="9999",t.addEventListener("click",(e=>{e.target===t&&document.body.removeChild(t)}));const e=new Image;e.src=s,e.style.maxWidth="80%",e.style.maxHeight="80%",t.appendChild(e),document.body.appendChild(t)}else if("video"===r){const t=document.createElement("div");t.style.width="100%",t.style.height="100%",t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.backgroundColor="rgba(30, 30, 30, 0.4)",t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center",t.style.overflow="hidden",t.style.zIndex="9999",t.addEventListener("click",(e=>{e.target===t&&document.body.removeChild(t)}));const e=document.createElement("video");e.src=s,e.style.maxWidth="80%",e.style.maxHeight="80%",e.setAttribute("preload","auto"),e.setAttribute("controls","true"),t.appendChild(e),document.body.appendChild(t)}})),this.table.on(sf.DBLCLICK_CELL,(t=>{if(t.federatedEvent){const e=nV(t.federatedEvent),i=this.table.scenegraph.getResizeColAt(e.abstractPos.x,e.abstractPos.y,e.eventArgs?.targetCell);this.table._canResizeColumn(i.col,i.row)&&i.col>=0&&this.table.scenegraph.updateAutoColWidth(i.col)}})),this.table.isPivotTable()&&function(t){const e=t.internalProps.layoutMap.rowsDefine,i=t.internalProps.layoutMap.columnsDefine;for(let t=0;t<e.length;t++){const i=e[t];if("string"!=typeof i&&(i.drillDown||i.drillUp))return!0}for(let t=0;t<i.length;t++){const e=i[t];if("string"!=typeof e&&(e.drillDown||e.drillUp))return!0}return!1}(this.table)&&function(t){t.on(sf.MOUSEENTER_CELL,(e=>{const{col:i,row:n}=e;if(-1===i||-1===n)return;const r=t.internalProps.layoutMap.getHeaderDimension(i,n);r?.drillDown||r?.drillUp?t.stateManeger.updateDrillState(r.dimensionKey,r.title,r.drillDown,r.drillUp,i,n):t.stateManeger.updateDrillState(void 0,void 0,!1,!1,-1,-1)})),t.on(sf.MOUSELEAVE_TABLE,(e=>{t.stateManeger.updateDrillState(void 0,void 0,!1,!1,-1,-1)}))}(this.table),function(t){let e=!1;e=t.isPivotTable()?t.internalProps.layoutMap.indicatorsDefine.some((t=>"string"!=typeof t&&"sparkline"===t.cellType)):t.internalProps.layoutMap.columnObjects.some((t=>"sparkline"===t.cellType));e&&(t.on(sf.MOUSEMOVE_CELL,(e=>{const{col:i,row:n,x:r,y:o}=e;"sparkline"!==t.getBodyColumnType(i,n)&&t.stateManeger.updateSparklineHoverPose(-1,-1,0,0),t.stateManeger.updateSparklineHoverPose(i,n,r,o)})),t.on(sf.MOUSELEAVE_TABLE,(e=>{t.stateManeger.updateSparklineHoverPose(-1,-1,0,0)})))}(this.table),function(t){t.isPivotChart()&&t.scenegraph.tableGroup.addEventListener("click",(e=>{if(!t.stateManeger.columnMove.moving&&!t.stateManeger.columnResize.resizing)if("axis-label"===e.target.name){const i=nV(e),{col:n,row:r}=i.eventArgs,o=t.internalProps.layoutMap;let s,a;o.indicatorsAsCol?(s=o.getDimensionKeyInChartSpec(o.rowHeaderLevelCount,r)[0],a=o.getCellHeaderPaths(o.rowHeaderLevelCount-2,r).rowHeaderPaths):(s=o.getDimensionKeyInChartSpec(n,o.columnHeaderLevelCount)[0],a=o.getCellHeaderPaths(n,o.columnHeaderLevelCount-1).colHeaderPaths);const l=a.map((t=>({key:t.dimensionKey,value:t.value}))).filter((t=>t.key));if(l.push({key:s,value:e.target.attribute.text}),t._selectedDimensionInChart.length&&function(t,e){if(t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(t[i].key!==e[i].key||t[i].value!==e[i].value)return!1;return!0}(t._selectedDimensionInChart,l))return;t._selectedDimensionInChart=l,o.updateDataStateToChartInstance(),kG(t.scenegraph),t.scenegraph.updateNextFrame()}else t._selectedDimensionInChart?.length&&(t._selectedDimensionInChart.length=0,t.internalProps.layoutMap.updateDataStateToChartInstance(),kG(t.scenegraph),t.scenegraph.updateNextFrame())}))}(this.table),function(t){t.isPivotChart()&&(t.on(sf.MOUSEENTER_CELL,(e=>{t.scenegraph.getCell(e.col,e.row).forEachChildren((i=>{if("axis"===i.name){const i=dV(e.col,e.row,t.internalProps.layoutMap);e.axisPosition=i,t.fireListeners(sf.MOUSEENTER_AXIS,e)}}))})),t.on(sf.MOUSELEAVE_CELL,(e=>{t.scenegraph.getCell(e.col,e.row).forEachChildren((i=>{if("axis"===i.name){const i=dV(e.col,e.row,t.internalProps.layoutMap);e.axisPosition=i,t.fireListeners(sf.MOUSELEAVE_AXIS,e)}}))})))}(this.table)}dealTableHover(t){if(!t)return void this.table.stateManeger.updateHoverPos(-1,-1);const{eventArgs:e}=t;e?this.table.stateManeger.updateHoverPos(e.col,e.row):this.table.stateManeger.updateHoverPos(-1,-1)}dealIconHover(t){const{eventArgs:e}=t;e?this.table.stateManeger.updateHoverIcon(e.col,e.row,e.target,e.targetCell,e.event):this.table.stateManeger.updateHoverIcon(-1,-1,void 0,void 0)}dealMenuHover(t){}dealTableSelect(t){if(!t)return this.table.stateManeger.updateSelectPos(-1,-1),!1;const{eventArgs:e}=t;return!!e&&(this.table.isPivotChart()||"chart"===t?.eventArgs?.target.type||this.table.stateManeger.updateHoverPos(-1,-1),!this.table.isPivotChart()||"axis-label"!==t?.eventArgs?.target.name&&"chart"!==t?.eventArgs?.target.type?(this.table.stateManeger.updateSelectPos(e.col,e.row,e.event.shiftKey,e.event.ctrlKey||e.event.metaKey),!0):(this.table.stateManeger.updateSelectPos(-1,-1),!1))}deelTableSelectAll(){this.table.stateManeger.updateSelectPos(-1,-1,!1,!1,!0)}dealMenuSelect(t){}checkColumnResize(t,e){const{eventArgs:i}=t;if(i){const n=this.table.scenegraph.getResizeColAt(t.abstractPos.x,t.abstractPos.y,i.targetCell);if(this.table._canResizeColumn(n.col,n.row)&&n.col>=0)return e&&this.table.stateManeger.startResizeCol(n.col,t.abstractPos.x,t.abstractPos.y,n.rightFrozen),!0}return!1}dealColumnResize(t,e){this.table.stateManeger.updateResizeCol(t,e)}chechColumnMover(t){const{eventArgs:e}=t;return!!(e&&this.table.isHeader(e.col,e.row)&&function(t,e,i){for(let n=0;n<i.length;n++)if(qp(i[n],t,e))return!0;return!1}(e.col,e.row,this.table.stateManeger.select.ranges)&&this.table._canDragHeaderPosition(e.col,e.row))&&(this.table.stateManeger.startMoveCol(e.col,e.row,t.abstractPos.x,t.abstractPos.y),!0)}dealColumnMover(t){const{eventArgs:e}=t;this.table.stateManeger.updateMoveCol(e.col,e.row,t.abstractPos.x,t.abstractPos.y)}startColumnResize(t){}dealIconClick(t,e){const{eventArgs:i}=e,{target:n,event:r,col:o,row:s}=i||{target:t.target,event:t,col:-1,row:-1},a=n;if(a.role&&a.role.startsWith("icon-"))return this.table.fireListeners(sf.ICON_CLICK,{name:a.name,x:(a.globalAABBBounds.x1+a.globalAABBBounds.x2)/2,y:a.globalAABBBounds.y2,col:o,row:s,funcType:a.attribute.funcType,icon:a}),!0;if(n instanceof dA){const t=n.pickIcon(r.global);if(t)return this.table.fireListeners(sf.ICON_CLICK,{name:t.attribute.id,x:t.globalX+t.globalAABBBounds.width()/2,y:t.globalY+t.AABBBounds.height(),col:o,row:s,funcType:t.attribute.funcType,icon:t}),!0}return!1}}const fV=t=>{const e=t.value;return Number(e)>80?"#20a8d8":Number(e)>50?"#4dbd74":Number(e)>20?"#ffc107":"#f86c6b"};class gV extends Ru{_showBar;_barColor;_barBgColor;_barPositiveColor;_barNegativeColor;_barAxisColor;_barHeight;_barBottom;_barPadding;_showBarMark;_barMarkPositiveColor;_barMarkNegativeColor;_barMarkWidth;_barMarkPosition;_barRightToLeft;static get DEFAULT(){return oV||(oV=new gV)}constructor(t={},e={}){super(t,e),this._showBar=t.showBar??!0,this._barColor=t.barColor??fV,this._barPositiveColor=t.barPositiveColor??"#4dbd74",this._barNegativeColor=t.barNegativeColor??"#f86c6b",this._barAxisColor=t.barAxisColor??"black",this._barBgColor=t.barBgColor,this._barHeight=t.barHeight??3,this._barHeight=t.barHeight??3,this._barBottom=t.barBottom??0,this._barPadding=t.barPadding??[1,1,1,1],this._showBarMark=t.showBarMark??!1,this._barMarkPositiveColor=t.barMarkPositiveColor??"#4dbd74",this._barMarkNegativeColor=t.barMarkNegativeColor??"#f86c6b",this._barMarkWidth=t.barMarkWidth??2,this._barMarkPosition=t.barMarkPosition??"right",this._barRightToLeft=t.barRightToLeft??!1}get showBar(){return this._showBar}set showBar(t){this._showBar=t}get barColor(){return this._barColor}set barColor(t){this._barColor=t}get barBgColor(){return this._barBgColor}set barBgColor(t){this._barBgColor=t}get barHeight(){return this._barHeight}set barHeight(t){this._barHeight=t}get barBottom(){return this._barBottom}set barBottom(t){this._barBottom=t}get barPositiveColor(){return this._barPositiveColor}set barPositiveColor(t){this._barPositiveColor=t}get barNegativeColor(){return this._barNegativeColor}set barNegativeColor(t){this._barNegativeColor=t}get barAxisColor(){return this._barAxisColor}set barAxisColor(t){this._barAxisColor=t}get barPadding(){return this._barPadding}set barPadding(t){this._barPadding=t}get showBarMark(){return this._showBarMark}set showBarMark(t){this._showBarMark=t}get barMarkPositiveColor(){return this._barMarkPositiveColor}set barMarkPositiveColor(t){this._barMarkPositiveColor=t}get barMarkNegativeColor(){return this._barMarkNegativeColor}set barMarkNegativeColor(t){this._barMarkNegativeColor=t}get barMarkWidth(){return this._barMarkWidth}set barMarkWidth(t){this._barMarkWidth=t}get barMarkPosition(){return this._barMarkPosition}set barMarkPosition(t){this._barMarkPosition=t}get barRightToLeft(){return this._barRightToLeft}set barRightToLeft(t){this._barRightToLeft=t}clone(){return new gV(this,null)}}const mV=["type","content","font","color","width","height","marginRight","marginLeft","src","svg","name","path","positionType","tooltip","hover","cursor","shape","interactive"];class yV{expandIcon;collapseIcon;_table;constructor(t){this._table=t;const e=yj();this.expandIcon=e[Qc.expandIconName],this.collapseIcon=e[Qc.collapseIconName]}getIcons(t,e,i,n,r){const o=[],{icon:s}=this._table.getBodyColumnDefine(t,e);if(s){let r;if("function"==typeof s){r=s({col:t,row:e,value:i,dataValue:n,table:this._table})}else r=s;const a=yj(),l=t=>{let e;e="string"==typeof t?a[t]:t,e&&o.push(e)};Array.isArray(r)?r.forEach(((t,e)=>{l(t)})):l(r)}const a=this.getHierarchyIcon(t,e);return a&&o.push(a),r&&o.forEach(((i,n)=>{(i.content||i.src)&&(o[n]=this.getCellIconFromRecordValue(i,t,e))})),o}getStyleClass(t){switch(t){case"text":case"link":return Eu;case"image":case"video":return Pu;case"chart":case"sparkline":return Ru;case"progressbar":return gV}}getCellIconFromRecordValue(t,e,i){if(Array.isArray(t))return t.map((t=>this.getCellIconFromRecordValue(t,e,i)));if(!tf.isObject(t)||"function"==typeof t)return this._table.getFieldData(t,e,i);const n={},r=t;return mV.forEach((t=>{if(void 0!==r[t]){const o=this._table.getFieldData(r[t],e,i);null!=o?n[t]=o:this._table._hasField(r[t],e,i)||(n[t]=r[t])}})),n}getHierarchyIcon(t,e){const i=this._table.getHierarchyState(t,e);return i===Xc.expand?this.expandIcon:i===Xc.collapse?this.collapseIcon:void 0}}function bV(t,e){const i=document.createElement(t);return e&&i.classList.add(...e),i}!function(){const t=document.createElement("style");t.id="vtable-menu-styleSheet",t.textContent="\n@keyframes vtable__menu-element--shown-animation {\n\t0% {\n\t\topacity: 0;\n\t}\n\t100% {\n\t\topacity: 1;\n\t}\n}\n.vtable__menu-element {\n\tposition: absolute;\n\tbox-sizing: border-box;\n\tborder-radius: 4px;\n\tbackground-color: #fff;\n\tpadding: 6px 0;\n\t/* pointer-events: none; */\n\tuser-select: none;\n\tcolor: #000;\n\tmax-width: 300px;\n\tz-index: 99999;\n\tborder: #CCC 0.5px solid;\n\tcursor: default;\n\twidth: max-content;\n\tbox-shadow: 0px 8px 16px rgba(27, 31, 35, 0.12);\n}\n.vtable__menu-element--hidden {\n\topacity: 0;\n\t/* transform: translate(-50%, -50%); */\n\ttransition: opacity 75ms linear;\n\tz-index: -9999;\n}\n.vtable__menu-element--shown {\n\topacity: 1;\n\t/* transform: translate(-50%, -50%); */\n\tanimation: vtable__menu-element--shown-animation 150ms ease-out;\n}\n.vtable__menu-element__content {\n\tfont-family: Roboto;\n\tfont-size: 12px;\n\toverflow: hidden;\n\tdisplay: inline-block;\n\t/* height: 100%; */\n\tline-height: 30px;\n}\n.vtable__menu-element__item {\n\theight: 32px;\n\tpadding: 0px 12px;\n\tcursor: pointer;\n\tposition: relative;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: flex-start;\n}\n.vtable__menu-element__item:hover {\n\tbackground-color: rgba(27, 31, 35, 0.06);\n}\n.vtable__menu-element__icon{\n\t/* vertical-align: top; */\n\tdisplay: flex;\n\t/* line-height: 30px; */\n\tmargin-right: 6px;\n}\n.vtable__menu-element__no-event {\n\tpointer-events: none;\n}\n.vtable__menu-element--select {\n\tcolor: #2E68CF;\n}.vtable__menu-element--normal {\n\tcolor: rgba(20, 20, 20, 0.9);;\n}\n.vtable__menu-element__split {\n\theight: 0px;\n\tborder: 1px solid rgb(209, 213, 218);\n\tmargin: 5px 0;\n}\n.vtable__menu-element__title {\n\tcolor: rgb(149, 149, 149);\n}\n.vtable__menu-element__arrow {\n\tposition: absolute;\n\tright: 3px;\n\tfont-weight: bold;\n\tmargin-top: 1px;\n}\n.vtable__menu-element__item-text {\n\tmargin-right: 15px;\n}\n",document.body.appendChild(t)}();const vV="vtable__menu-element",wV=`${vV}__item`,CV=`${vV}__content`,xV=`${vV}--hidden`,_V=`${vV}--shown`,SV=`${vV}--normal`,AV=`${vV}--select`,TV=`${vV}__icon`,BV=`${vV}__split`,MV=`${vV}__title`,RV=`${vV}__arrow`,PV=`${vV}__no-event`,EV=`${vV}__item-text`;function HV(){return bV("div",[vV,xV])}function LV(t,e,i,n,r,o){const s=t.getCellRange(n,r);for(let n=0;n<e.length;n++){const r=e[n];let{col:o,row:a}=r;const{field:l,menuKey:h}=r;if("number"!=typeof o||"number"!=typeof a)if(t.isPivotTable()&&(Array.isArray(l),1)){const e=t.internalProps.layoutMap.getPivotCellAdress(l);if(!e)continue;o=e.col,a=e.row}else{const e=t.internalProps.layoutMap.getHeaderCellAddressByField(l);if(!e)continue;o=e.col,a=e.row}if(bu(o)&&bu(a)&&qp(s,o,a)&&i===h)return!0}return!1}class kV{_handler;_rootElement;_secondElement;_menuInstanceInfo;_showChildrenIndex;_mouseEnterSecondElement;constructor(t){this._handler=new df,this._rootElement=HV(),this._secondElement=HV(),this._secondElement.sub=!0,this._showChildrenIndex=-1,this._rootElement.addEventListener("wheel",(t=>{t.stopPropagation()})),this._rootElement?.addEventListener("mousedown",(t=>{t.stopPropagation(),t.preventDefault()})),this._rootElement?.addEventListener("touchend",(e=>{if(e.stopPropagation(),e.preventDefault(),this._rootElement.classList.contains(xV))return;const{col:i,row:n,dropDownIndex:r,menuKey:o,text:s,hasChildren:a}=e.target;if("number"!=typeof r||a)return void e.stopPropagation();const l=t.isPivotTable()?t.internalProps.layoutMap.getPivotDimensionInfo(i,n):t.getHeaderField(i,n),h=t._dropDownMenuIsHighlight(i,n,r);t.fireListeners(sf.DROPDOWNMENU_CLICK,{col:i,row:n,field:l,menuKey:o,text:s,highlight:h,cellLocation:t.getCellLocation(i,n)}),t.fireListeners(sf.DROPDOWN_MENU_CLEAR,null),t.fireListeners(sf.HIDE_MENU,null),e.stopPropagation()})),this._rootElement?.addEventListener("click",(e=>{if(e.stopPropagation(),e.preventDefault(),this._rootElement.classList.contains(xV))return;const{col:i,row:n,dropDownIndex:r,menuKey:o,text:s,hasChildren:a}=e.target;if("number"!=typeof r||a)return void e.stopPropagation();const l=t.isPivotTable()?t.internalProps.layoutMap.getPivotDimensionInfo(i,n):t.getHeaderField(i,n),h=t._dropDownMenuIsHighlight(i,n,r);t.fireListeners(sf.DROPDOWNMENU_CLICK,{col:i,row:n,field:l,menuKey:o,text:s,highlight:h,cellLocation:t.getCellLocation(i,n)}),t.fireListeners(sf.DROPDOWN_MENU_CLEAR,null),t.fireListeners(sf.HIDE_MENU,null),e.stopPropagation()})),this._rootElement?.addEventListener("mousemove",(e=>{if(this._rootElement.classList.contains(xV))return;e.stopPropagation();const{hasChildren:i,dropDownIndex:n,col:r,row:o,sub:s}=e.target;if(i){this._showChildrenIndex=n;const i=this._secondElement;i?.classList.remove(xV),i?.classList.add(_V),i.innerHTML="";const s=this._menuInstanceInfo.content[n]?.children;for(let e=0;e<s.length;e++){const n=s[e],a=IV(n,!!t.stateManeger.menu.dropDownMenuHighlight&&LV(t,t.stateManeger.menu.dropDownMenuHighlight,"object"==typeof n?n?.menuKey||n?.text:n,r,o));a.col=r,a.row=o,a.dropDownIndex=e,"string"==typeof n?(a.text=n,a.menuKey=n):"object"==typeof n&&(a.text=n.text,a.menuKey=n.menuKey||n.text),a.sub=!0,a.sub=!0,i.appendChild(a)}const a=e.target.getBoundingClientRect();this._bindSecondElement(t,r,o,a.right,a.top)}else if(i&&this._showChildrenIndex===n){const t=this._secondElement;t?.classList.remove(xV),t?.classList.add(_V)}else!s&&this._secondElement?.classList.contains(_V)&&setTimeout((()=>{if(!0!==this._mouseEnterSecondElement){this._showChildrenIndex=-1;const t=this._secondElement;t?.classList.remove(_V),t?.classList.add(xV)}}),300)})),this._secondElement?.addEventListener("wheel",(t=>{t.stopPropagation()})),this._secondElement?.addEventListener("mousemove",(t=>{this._rootElement.classList.contains(xV)||t.stopPropagation()})),this._secondElement?.addEventListener("mouseenter",(t=>{this._mouseEnterSecondElement=!0})),this._secondElement?.addEventListener("mouseleave",(t=>{this._mouseEnterSecondElement=!1})),this._secondElement?.addEventListener("mousedown",(t=>{t.stopPropagation(),t.preventDefault()})),this._secondElement?.addEventListener("click",(e=>{if(e.stopPropagation(),e.preventDefault(),this._secondElement.classList.contains(xV))return;const{col:i,row:n,dropDownIndex:r,menuKey:o,text:s,hasChildren:a}=e.target;if("number"!=typeof r||a)return void e.stopPropagation();const l=t.isPivotTable()?t.internalProps.layoutMap.getPivotDimensionInfo(i,n):t.getHeaderField(i,n);let h=!1;this._menuInstanceInfo.content.forEach(((e,r)=>{if("object"==typeof e&&e.children&&e.children.length)for(let r=0;r<e.children.length;r++){const s=e.children[r];if(LV(t,t.stateManeger.menu.dropDownMenuHighlight,"object"==typeof s?s?.menuKey:s,i,n)&&o===("object"==typeof s?s?.menuKey:s))return void(h=!0)}})),t.fireListeners(sf.DROPDOWNMENU_CLICK,{col:i,row:n,field:l,cellHeaderPaths:t.isPivotTable()?t.getCellHeaderPaths(i,n):void 0,menuKey:o,text:s,highlight:h,cellLocation:t.getCellLocation(i,n)}),t.fireListeners(sf.DROPDOWN_MENU_CLEAR,null),t.fireListeners(sf.HIDE_MENU,null),e.stopPropagation()}))}get rootElement(){return this._rootElement}release(){this.unbindFromCell();const t=this._rootElement;t?.parentElement&&t.parentElement.removeChild(t),this._handler.release(),delete this._rootElement}bindToCell(t,e,i,n){const r=this._rootElement,o=this._secondElement;if(this._menuInstanceInfo=n,r?.classList.remove(_V),r?.classList.add(xV),o?.classList.remove(_V),o?.classList.add(xV),this._canBindToCell(t,e,i)){if(r.innerHTML="",Array.isArray(n.content)){const o=n.content;for(let n=0;n<o?.length;n++){const s=o[n];let a=!!t.stateManeger.menu.dropDownMenuHighlight&&LV(t,t.stateManeger.menu.dropDownMenuHighlight,"object"==typeof s?s?.menuKey||s?.text:s,e,i);if(t.stateManeger.menu.dropDownMenuHighlight&&"object"==typeof s&&Array.isArray(s.children)&&s.children.length)for(let n=0;n<s.children.length;n++){const r=s.children[n];if(LV(t,t.stateManeger.menu.dropDownMenuHighlight,"object"==typeof r?r?.menuKey||r?.text:r,e,i)){a=!0;break}}const l=IV(s,a);l.col=e,l.row=i,l.dropDownIndex=n,"string"==typeof s?(l.text=s,l.menuKey=s):"object"==typeof s&&(l.text=s.text,l.menuKey=s.menuKey||s.text,s.children?.length&&(l.hasChildren=!0)),r.appendChild(l)}}if(this._bindToCell(t,e,i,n.position,n.referencePosition))return r?.classList.add(_V),r?.classList.remove(xV),!0}else this.unbindFromCell();return!1}unbindFromCell(){const t=this._rootElement,e=this._secondElement;this._menuInstanceInfo=void 0,t?.parentElement&&(t.classList.remove(_V),t.classList.add(xV)),e?.parentElement&&(e.classList.remove(_V),e.classList.add(xV))}_canBindToCell(t,e,i){const n=t.getCellRangeRelativeRect({col:e,row:i}),r=t.getElement(),{top:o,bottom:s,left:a,right:l}=n,{frozenRowCount:h,frozenColCount:c}=t;if(i>=h&&h>0){if(s<t.getCellRangeRelativeRect({col:e,row:h-1}).bottom)return!1}else if(s<0)return!1;if(e>=c&&c>0){if(l<t.getCellRangeRelativeRect({col:c-1,row:i}).right)return!1}else if(l<0)return!1;const{offsetHeight:u,offsetWidth:d}=r;return!(u<o)&&!(d<a)}_bindToCell(t,e,i,n,r){const o=this._rootElement,s=t.getElement(),{width:a,height:l}=t.internalProps.element.getBoundingClientRect();if(o){o.parentElement!==s&&s.appendChild(o),o.style.left="0px";const e=.8*a;o.style.maxWidth=`${e}px`;const i=o.clientWidth,h=o.clientHeight;let c,u;return n?(c=n.x+t.tableX,u=n.y+t.tableY):r&&(c=r.rect.right-i+t.tableX,u=r.rect.bottom+t.tableY),u+h>l&&(u=l-h,c+=i-2),u<0&&(u/=2),o.style.top=`${u}px`,c<0?c=0:c+i>a&&(c=a-i),o.style.left=`${c}px`,!0}return!1}_bindSecondElement(t,e,i,n,r){const o=this._secondElement,s=this._rootElement,a=t.getElement(),{width:l,left:h,top:c}=t.internalProps.element.getBoundingClientRect(),{x:u,y:d,width:p}=s.getBoundingClientRect();if(o){o.parentElement!==a&&a.appendChild(o),o.style.left="0px";const t=.8*l;o.style.maxWidth=`${t}px`;const e=o.clientWidth,i=r-4-c,s=n-h;o.style.top=`${i}px`;let u=s;return u+e>l?u=u-e-p:u+=4,o.style.left=`${u}px`,!0}return!1}pointInMenuElement(t,e){const i=this._rootElement,{x:n,y:r,width:o,height:s}=i.getBoundingClientRect();if(t>n-5&&t<n+o+5&&e>r-5&&e<r+s+5)return!0;if(this._secondElement){const{x:n,y:r,width:o,height:s}=i.getBoundingClientRect();if(t>n-5&&t<n+o+5&&e>r-5&&e<r+s+5)return!0}return!1}}function IV(t,e){const i=bV("div",[wV,e?AV:SV]);if("string"==typeof t){const e=bV("span",[CV,PV,EV]);e.innerHTML=t,i.appendChild(e)}else if("object"==typeof t){const n=t.type??"item";if("split"===n)return i?.classList.add(BV),i;if(t?.icon?.svg)if(_f.test(t.icon.svg)){const e=new Image;t.icon.width?e.style.width=t.icon.width.toString()+"px":e.style.width="16px",t.icon.height?e.style.height=t.icon.height.toString()+"px":e.style.height="16px",e.src=t.icon.svg,i.appendChild(e)}else{const n=bV("span",[TV,PV]);n.innerHTML=e&&t.selectedIcon&&t.selectedIcon.svg?t.selectedIcon.svg:t.icon.svg,t.icon.width&&n.children[0].setAttribute("width",t.icon.width.toString()),t.icon.height&&n.children[0].setAttribute("height",t.icon.height.toString()),i.appendChild(n)}const r=bV("span",[CV,PV,EV]);if(r.innerHTML=t.text,i.appendChild(r),"title"===n)i?.classList.add(PV,MV);else if(t?.children?.length){const t=bV("span",[CV,PV,RV]);t.innerHTML=e?'<svg width="8" height="12" viewBox="0 0 10 17" fill="none" xmlns="http://www.w3.org/2000/svg" style="vertical-align: baseline"><path d="M1.78186 16.7729L0.300378 15.2915L6.8189 8.77295L0.300377 2.25443L1.78186 0.77295L9.78186 8.77295L1.78186 16.7729Z" fill="#2E68CF" fill-opacity="0.65"></path></svg>':'<svg width="8" height="12" viewBox="0 0 10 17" fill="none" xmlns="http://www.w3.org/2000/svg" style="vertical-align: baseline"><path d="M1.78186 16.7729L0.300378 15.2915L6.8189 8.77295L0.300377 2.25443L1.78186 0.77295L9.78186 8.77295L1.78186 16.7729Z" fill="#141414" fill-opacity="0.65"></path></svg>',i.appendChild(t)}}return i}let OV;class DV extends ku{static get DEFAULT(){return OV||(OV=new DV)}constructor(t={},e={}){super(t,e),this.textAlign=(t.textAlign??e?.textAlign)||"center"}clone(){return new DV(this)}}class FV{normalIcon;upIcon;downIcon;freezeIcon;frozenIcon;frozenCurrentIcon;dropDownAbsoluteIcon;expandIcon;collapseIcon;_table;constructor(t){this._table=t;const e=yj();this.freezeIcon=e[Qc.freezeIconName],this.frozenIcon=e[Qc.frozenIconName],this.frozenCurrentIcon=e[Qc.frozenCurrentIconName],this.normalIcon=e[Qc.normalIconName],this.upIcon=e[Qc.upwardIconName],this.downIcon=e[Qc.downwardIconName],this.dropDownAbsoluteIcon=e[Qc.dropdownIconName],this.expandIcon=e[Qc.expandIconName],this.collapseIcon=e[Qc.collapseIconName]}getIcons(t,e){const i=[];if(this._table.isPivotTable()){const{showSort:n}=this._table.internalProps.layoutMap.getHeader(t,e);if(n){const n=this._table.getPivotSortState(t,e),r="asc"===n?this.downIcon:"desc"===n?this.upIcon:this.normalIcon;r&&i.push(r)}}else{const n=this._table.sortState;let r;r=void 0;const o=this._table.getCellRange(t,e);if(n)if(Array.isArray(n))for(let t=0;t<n.length;t++){const e=n[t],i=this._table._getHeaderCellBySortState(e);if(i&&qp(o,i.col,i.row)){({order:r}=e);break}}else{const t=this._table._getHeaderCellBySortState(n);t&&qp(o,t.col,t.row)&&({order:r}=n)}const s=this.getSortIcon(r,this._table,t,e);s&&i.push(s)}if(this._table.showFrozenIcon&&t<this._table.allowFrozenColCount){const n=this.getFrozenIcon(t,e);n&&i.push(n)}if(this.checkDropDownIcon(this._table,t,e)){const t=this.dropDownAbsoluteIcon;i.push(t)}const n=this.getDropDownStateIcons(this._table,t,e);n.length&&i.push(...n);const{headerIcon:r}=this._table._getHeaderLayoutMap(t,e),o=this.getHierarchyIcon(t,e);if(o&&i.push(o),r){let n;if("function"==typeof r){n=r({col:t,row:e,value:this._table.getCellValue(t,e),dataValue:this._table.getCellOriginValue(t,e),table:this._table})}else n=r;const o=yj(),s=t=>{let e;e="string"==typeof t?o[t]:t,e&&i.push(e)};Array.isArray(n)?n.forEach(((t,e)=>{s(t)})):s(n)}return i}getFrozenIcon(t,e){if(this._table.isPivotTable()||this._table.transpose)return null;const i=this._table.getHeaderDefine(t,e);if(i.columns&&i.columns.length>0)return null;let n=this.freezeIcon;return this._table.options.frozenColCount-1>t?n=this.frozenIcon:this._table.options.frozenColCount-1===t&&(n=this.frozenCurrentIcon),n}getSortIcon(t,e,i,n){const r="asc"===t?this.downIcon:"desc"===t?this.upIcon:this.normalIcon,o=e.getHeaderDefine(i,n);return!o||!o.showSort&&!o.sort||o.columns&&o.columns.length>0?null:r}getDropDownStateIcons(t,e,i){const n=t.getHeaderDefine(e,i),r=t._getHeaderLayoutMap(e,i),{dropDownMenu:o}=r,s=[];if(Array.isArray(o)&&o.length||Array.isArray(t.globalDropDownMenu)&&t.globalDropDownMenu.length&&!n?.columns?.length){const n=o||t.globalDropDownMenu;let r=-1,a=-1;for(let o=0;o<n.length;o++){const s=n[o];if("object"==typeof s&&s.children&&s.children.length)for(let n=0;n<s.children.length;n++){const l=s.children[n];if(t.stateManeger.menu?.dropDownMenuHighlight&&LV(t,t.stateManeger.menu?.dropDownMenuHighlight,"object"==typeof l?l?.menuKey:l,e,i)){r=o,a=n;break}}if(t._dropDownMenuIsHighlight(e,i,o)){r=o;break}}if(-1!==r){let e;e=-1!==a?(o||t.globalDropDownMenu)[r].children[a]:(o||t.globalDropDownMenu)[r],e.stateIcon&&(e.stateIcon.svg?s.push({type:"svg",name:e.stateIcon.src||e.stateIcon.svg,width:e.stateIcon.width||22,height:e.stateIcon.height||22,svg:e.stateIcon.svg,positionType:Zc.right,marginRight:0,funcType:Jc.dropDownState,interactive:!1}):e.stateIcon.src&&s.push({type:"image",name:e.stateIcon.src||e.stateIcon.svg,width:e.stateIcon.width||22,height:e.stateIcon.height||22,src:e.stateIcon.src,positionType:Zc.right,marginRight:0,funcType:Jc.dropDownState,interactive:!1}))}}return s}getDropDownIconRect(t,e,i){const n=this.downIcon.hover?.width??this.downIcon?.width??0,r=this.downIcon.hover?.height??this.downIcon?.height??0,o=t.right-2-n,s=t.right-2;let a;a="middle"===i?t.top+t.height/2-n/2:"top"===i?t.top+e/2:"bottom"===i?t.bottom-2*e:t.top;return{left:o,right:s,top:a,bottom:r+a,width:n,height:r}}getHierarchyIcon(t,e){const{hierarchyState:i}=this._table._getHeaderLayoutMap(t,e);if(i){if(i===Xc.expand)return this.expandIcon;if(i===Xc.collapse)return this.collapseIcon}}checkDropDownIcon(t,e,i){if(t.isPivotTable()){const n=t._getHeaderLayoutMap(e,i);if(Array.isArray(n.dropDownMenu)&&n.dropDownMenu.length)return!0}else{const n=t.getHeaderDefine(e,i);if(Array.isArray(n.dropDownMenu)&&n.dropDownMenu.length||(!Array.isArray(n.dropDownMenu)||0!==n.dropDownMenu.length)&&Array.isArray(t.globalDropDownMenu)&&t.globalDropDownMenu.length&&!n?.columns?.length)return!0}return!1}getStyleClass(t){switch(t){case"text":case"link":return Ou;case"image":case"video":return DV}}}class zV{_table;_tooltipElement;constructor(t){this._table=t}release(){this.unbindTooltipElement(),this._tooltipElement&&this._tooltipElement.release?.(),this._tooltipElement=void 0}_getTooltipElement(){return this._tooltipElement||(this._tooltipElement=this.createTooltipElementInternal()),this._tooltipElement}bindTooltipElement(t,e,i,n){return this._getTooltipElement().bindToCell(this._table,t,e,i,n)}moveTooltipElement(t,e,i,n){this._getTooltipElement().move(this._table,t,e,i,n)}unbindTooltipElement(){this._getTooltipElement().unbindFromCell()}locateTooltipElement(t,e,i,n,r){this._getTooltipElement()._locate(this._table,t,e,i,n,r)}}!function(){const t=document.createElement("style");t.id="vtable-tooltip-styleSheet",t.textContent="\n@keyframes vtable__bubble-tooltip-element--shown-animation {\n\t0% {\n\t\topacity: 0;\n\t}\n\t100% {\n\t\topacity: 1;\n\t}\n}\n.vtable__bubble-tooltip-element {\n\tposition: absolute;\n\t\n\tpointer-events: none;\n\tuser-select: none;\n\tmax-width: 300px;\n\tz-index: 99999;\n\n\tbackground: #FFFFFF;\n border: 1px solid #E6E8ED;\n box-sizing: border-box;\n border-radius: 4px;\n box-shadow: 0px 2px 4px rgb(27 31 35 / 8%);\n color: #141414;\n font-size: 13px;\n}\n.vtable__bubble-tooltip-element--hidden {\n\topacity: 0;\n\t/* transform: translate(-50%, -50%); */\n\ttransition: opacity 75ms linear;\n}\n.vtable__bubble-tooltip-element--shown {\n\topacity: 1;\n\t/* transform: translate(-50%, -50%); */\n\tanimation: vtable__bubble-tooltip-element--shown-animation 150ms ease-out;\n}\n.vtable__bubble-tooltip-element__content {\n\t/* font-size: .75rem; */\n\tpadding: 6px 8px;\n\tmin-height: 1em;\n\tline-height: 1.5;\n\twidth: 100%;\n\tdisplay: block;\n\twhite-space: pre-wrap;\n\tmargin: 0;\n\tbox-sizing: border-box;\n\toverflow: hidden;\n\tword-wrap: break-word;\n\tposition: relative;\n\tbackground-color: #FFF;\n\tz-index: 2;\n\tborder-radius: 4px\n}\n.vtable__bubble-tooltip-element__triangle {\n\t/* font-size: .75rem; */\n\tposition: absolute;\n\twidth: 10px;\n\theight: 10px;\n\tdisplay: block;\n\ttransform: rotate(45deg);\n transform-origin: 50% 50% 0;\n\tz-index: 1;\n\tbackground-color: #FFF;\n\tborder: 1px solid #E6E8ED;\n}\n",document.body.appendChild(t)}();const WV="vtable__bubble-tooltip-element",jV=`${WV}__content`,NV=`${WV}__triangle`,GV=`${WV}--hidden`,VV=`${WV}--shown`;class UV{_handler;_rootElement;_messageElement;_triangleElement;constructor(){this._handler=new df;const t=this._rootElement=bV("div",[WV,GV]),e=bV("span",[jV]),i=bV("span",[NV]);t.appendChild(i),t.appendChild(e),this._messageElement=t.querySelector(`.${jV}`)||void 0,this._triangleElement=t.querySelector(`.${NV}`)||void 0}bindToCell(t,e,i,n,r){const o=this._rootElement,s=this._messageElement,a=this._triangleElement;if(o?.classList.remove(VV),o?.classList.add(GV),this._canBindToCell(t,e,i)){s.setAttribute("style",""),a.setAttribute("style",""),n?.className&&o.classList.add(n.className),n?.style?.bgColor&&(s.style.backgroundColor=n?.style?.bgColor),n?.style?.bgColor&&(a.style.backgroundColor=n?.style?.bgColor),a.style.display=!0===n?.style?.arrowMark?"block":"none",n?.style?.font&&(s.style.font=n?.style?.font),n?.style?.color&&(s.style.color=n?.style?.color),n?.style?.padding&&(s.style.padding=`${n?.style?.padding.join("px ")}px`),s&&(s.textContent=n?.content);if(this._bindToCell(t,e,i,n?.position,n?.referencePosition,r,n?.style?.arrowMark))return o?.classList.add(VV),o?.classList.remove(GV),!0}else this.unbindFromCell();return!1}release(){this.unbindFromCell();const t=this._rootElement;t?.parentElement&&t.parentElement.removeChild(t),this._handler?.release?.(),delete this._rootElement,delete this._messageElement}move(t,e,i,n,r){const o=this._rootElement;this._canBindToCell(t,e,i)?(this._bindToCell(t,e,i,n?.position,n?.referencePosition,r),o?.classList.add(VV),o?.classList.remove(GV)):this.unbindFromCell()}unbindFromCell(){const t=this._rootElement;t?.parentElement&&(t.classList.remove(VV),t.classList.add(GV))}_canBindToCell(t,e,i){const n=t.getCellRangeRelativeRect({col:e,row:i}),r=t.getElement(),{bottom:o,left:s,right:a}=n,{frozenRowCount:l,frozenColCount:h}=t;if(i>=l&&l>0){if(o<t.getCellRangeRelativeRect({col:e,row:l-1}).bottom)return!1}else if(o<0)return!1;if(e>=h&&h>0){if(a<t.getCellRangeRelativeRect({col:h-1,row:i}).right)return!1}else if(s<0)return!1;const{offsetHeight:c,offsetWidth:u}=r;return!(c<o)&&!(u<s)}_bindToCell(t,e,i,n,r,o,s){const a=this._rootElement,l=t.getCellRangeRelativeRect({col:e,row:i}),h=t.getElement(),c=t.internalProps.element.offsetWidth,{width:u}=l;if(a){let l,d;a.parentElement!==h&&h.appendChild(a),a.style.left="0px";const p=Math.min(.8*c,4*u);a.style.maxWidth=`${p}px`;const f=a.clientWidth,g=a.clientHeight;if(!n&&!r)return!1;{const a=this.getComputedPosition(t,e,i,n,r,o,s);d=a.x,l=a.y}a.style.left=`${d}px`,a.style.top=`${l}px`,wu()&&(a.style.fontSize="11px");const{x1:m,x2:y,y1:b,y2:v}=t.stateManeger.menu.bounds,w=d,C=w+f,x=l,_=w+g;return!(t.stateManeger.menu.isShow&&m<C&&y>w&&v>x&&b<_)}return!1}getComputedPosition(t,e,i,n,r,o,s){const a=this._rootElement,l=t.getCellRangeRelativeRect({col:e,row:i}),{width:h,height:c}=t.internalProps.element.getBoundingClientRect(),{width:u}=l;let d,p;const f=Math.min(.8*h,4*u);a.style.maxWidth=`${f}px`;const g=a.clientWidth,m=a.clientHeight,y=s?6:0;if(n)p=n.x,d=n.y+y,this._triangleElement.style.left="50%",this._triangleElement.style.marginLeft="-5px",this._triangleElement.style.top="-5px";else if(r){let e=r.placement??$c.bottom;const i=r.rect.left+r.rect.width/2+t.tableX,n=r.rect.top+r.rect.height/2+t.tableY,s=r.rect.top+t.tableY,a=r.rect.bottom+t.tableY,l=r.rect.left+t.tableX,u=r.rect.right+t.tableX;let f=0;const b=()=>{f++,f>=4||(this.removeStyleFromTriangle(),e===$c.top?(p=i-g/2,d=s-m-y,this._triangleElement.style.left="50%",this._triangleElement.style.marginLeft="-5px",this._triangleElement.style.bottom="-5px",o&&d<0&&(e=$c.right,b())):e===$c.bottom?(p=i-g/2,d=a+y,this._triangleElement.style.left="50%",this._triangleElement.style.marginLeft="-5px",this._triangleElement.style.top="-5px",o&&d+m>c&&(e=$c.left,b())):e===$c.left?(d=n-m/2,p=l-g-y,this._triangleElement.style.top="50%",this._triangleElement.style.marginTop="-5px",this._triangleElement.style.right="-5px",o&&p<0&&(e=$c.top,b())):e===$c.right&&(d=n-m/2,p=u+y,this._triangleElement.style.top="50%",this._triangleElement.style.marginTop="-5px",this._triangleElement.style.left="-5px",o&&p+g>h&&(e=$c.bottom,b())))};b()}return o&&(p<0?p=0:p+a.offsetWidth>h&&(p=h-a.offsetWidth)),{x:p,y:d}}removeStyleFromTriangle(){this._triangleElement.style.left="",this._triangleElement.style.right="",this._triangleElement.style.top="",this._triangleElement.style.bottom="",this._triangleElement.style.marginLeft="",this._triangleElement.style.marginTop=""}_locate(t,e,i,n,r,o){const s=this.getComputedPosition(t,e,i,n,r,o),a=s.x,l=s.y;this._rootElement.style.left=`${a}px`,this._rootElement.style.top=`${l}px`}}class KV extends zV{createTooltipElementInternal(){return new UV}}const $V={"bubble-tooltip":function(t){return new KV(t)}};class XV{_table;_tooltipInstances;_attachInfo;confine;constructor(t,e){this._table=t,this._tooltipInstances={},this._bindTableEvent(t),this.confine=e}release(){const t=this._tooltipInstances;for(const e in t)t[e]?.release?.();delete this._tooltipInstances,this._attachInfo=null}_bindToCell(t,e,i){const n=this._attachInfo,r=this._getTooltipInstanceInfo(t,e);if(!n||r&&n.instance===r||(n.instance?.unbindTooltipElement(),this._attachInfo=null),!r)return;if(r&&r.bindTooltipElement(t,e,i,this.confine)){const n=this._table.getCellRange(t,e);this._attachInfo={range:n,instance:r,tooltipOptions:i}}}_move(t,e,i){const n=this._attachInfo;if(!n||!qp(n.range,t,e))return;const{instance:r}=n;r?.moveTooltipElement(t,e,i,this.confine)}moveToPosition(t,e,i,n){const r=this._attachInfo;if(!r||!qp(r.range,t,e))return;const{instance:o}=r;this._attachInfo.tooltipOptions.position=i,this._attachInfo.tooltipOptions.referencePosition=n,o?.locateTooltipElement(t,e,i,n,this.confine)}_unbindFromCell(){const t=this._attachInfo;if(!t)return;const{instance:e}=t;e?.unbindTooltipElement(),this._attachInfo=null}_isBindCell(t,e){const i=this._attachInfo;return!!i&&qp(i.range,t,e)}_bindTableEvent(t){t.on(sf.MOUSEENTER_CELL,(e=>{if(wu())return;const{x1:i,x2:n,y1:r,y2:o}=t.stateManeger.menu.bounds;if(t.stateManeger.menu.isShow&&"number"==typeof e.x&&"number"==typeof e.y&&e.x>i&&e.x<n&&e.y>r&&e.y<o)return;const{col:s,row:a}=e;if((!e.related||!this._isBindCell(s,a))&&t.internalProps.tooltip?.isShowOverflowTextTooltip){const i=t.getCellOverflowText(s,a),n=t.getHeaderDescription(s,a),r=t.getCellRangeRelativeRect({col:s,row:a});let o;i&&(o={content:n?`${n}\n ${i}`:i,referencePosition:{placement:$c.bottom,rect:r},style:{arrowMark:!1}}),n&&(o={content:n,referencePosition:{placement:$c.bottom,rect:r},style:{arrowMark:!1}}),o&&this._bindToCell(e.col,e.row,o)}})),t.on(sf.MOUSEMOVE_CELL,(e=>{if(!wu()){if(this._attachInfo?.tooltipOptions?.referencePosition){const i=this._attachInfo.tooltipOptions.referencePosition,{event:n}=e,{left:r,right:o,top:s,bottom:a}=i.rect,l=t._getMouseAbstractPoint(n,!1);l.inTable&&l.x>=r-5&&l.x<=o+5&&l.y>=s-5&&l.y<=a+5||this._unbindFromCell()}this._attachInfo&&t.stateManeger.menu.isShow&&this._bindToCell(e.col,e.row)}})),t.on(sf.MOUSELEAVE_CELL,(t=>{t.related&&this._isBindCell(t.related.col,t.related.row)||this._unbindFromCell()})),t.on(sf.SELECTED_CELL,(t=>{this._isBindCell(t.col,t.row)&&this._unbindFromCell()})),t.on(sf.MOUSELEAVE_TABLE,(t=>{this._unbindFromCell()})),t.on(sf.SCROLL,(e=>{const i=this._attachInfo;if(i?.tooltipOptions&&i?.range?.start){const{col:e,row:n}=i.range.start,r=t.getCellRangeRelativeRect({col:e,row:n});i.tooltipOptions.referencePosition.rect=r,this._move(i.range.start.col,i.range.start.row,i.tooltipOptions)}}))}_getTooltipInstanceInfo(t,e){const i=this._table,n=this._tooltipInstances,r="bubble-tooltip";return n&&n[r]||n&&(n[r]=$V[r](i))}isBinded(t){return JSON.stringify(t)===JSON.stringify(this._attachInfo?.tooltipOptions)}}const YV=new Map;function qV(t,e,i){const n=`${t}-${e}-${i}`,r=YV.get(n);if(r)return r;const o=(s={fontSize:t,fontFamily:i,fontWeight:e},new Lp({defaultFontParams:{fontFamily:"PingFang SC,Microsoft Yahei,system-ui,-apple-system,segoe ui,Roboto,Helvetica,Arial,sans-serif, apple color emoji,segoe ui emoji,segoe ui symbol",fontSize:11},getTextBounds:l?void 0:lT,specialCharSet:`{}()//&-/: .,@%'"~${Lp.ALPHABET_CHAR_SET}${Lp.ALPHABET_CHAR_SET.toUpperCase()}`,...a??{}},s));var s,a,l;return YV.set(n,o),o}const ZV=new class{measureText(t,e){const{fontSize:i,fontFamily:n,fontWeight:r}=e;return qV(i,r,n).measure(t)}measureTextWidth(t,e){const{fontSize:i,fontFamily:n="sans-serif",fontWeight:r="normal"}=e;return qV(i,r,n).measure(t).width}clipText(t,e,i){if(0===t.length)return{str:"",width:0};let n=this.measureTextWidth(t,e);return n<=i?{str:t,width:n}:(n=this.measureTextWidth(t[0],e),n>i?{str:"",width:0}:this._clipText(t,e,i,0,t.length-1))}_clipText(t,e,i,n,r){const o=Math.floor((n+r)/2),s=t.substring(0,o+1),a=this.measureTextWidth(s,e);let l;if(a>i){if(s.length<=1)return{str:"",width:0};const r=t.substring(0,o);return l=this.measureTextWidth(r,e),l<=i?{str:r,width:l}:this._clipText(t,e,i,n,o)}if(a<i){if(o>=t.length-1)return{str:t,width:this.measureTextWidth(t,e)};const n=t.substring(0,o+2);return l=this.measureTextWidth(n,e),l>=i?{str:s,width:a}:this._clipText(t,e,i,o,r)}return{str:s,width:a}}clipTextWithSuffix(t,e,i,n){if(""===n)return this.clipText(t,e,i);if(0===t.length)return{str:"",width:0};const r=this.measureTextWidth(t,e);if(r<=i)return{str:t,width:r};const o=this.measureTextWidth(n,e);if(o>i)return{str:"",width:0};i-=o;const s=this._clipText(t,e,i,0,t.length-1);return s.str+=n,s.width+=o,s}};class JV{_table;_menuElement;constructor(t){this._table=t}release(){this.unbindMenuElement(),this._menuElement&&this._menuElement.release(),this._menuElement=void 0}_getMenuElement(){return this._menuElement||(this._menuElement=this.createMenuElementInternal()),this._menuElement}bindMenuElement(t,e,i){return this._getMenuElement().bindToCell(this._table,t,e,i)}unbindMenuElement(){this._getMenuElement().unbindFromCell()}pointInMenuElement(t,e){return this._getMenuElement().pointInMenuElement(t,e)}}const QV="vtable__menu-element",tU=`${QV}--hidden`,eU=`${QV}--shown`;class iU{_handler;_rootElement;_menuInstanceInfo;constructor(t){this._handler=new df,this._rootElement=bV("div",[QV,tU]),this._rootElement.addEventListener("wheel",(t=>{t.stopPropagation()})),this._rootElement?.addEventListener("mousedown",(t=>{t.stopPropagation(),t.preventDefault()})),this._rootElement?.addEventListener("click",(e=>{if(e.stopPropagation(),e.preventDefault(),this._rootElement.classList.contains(tU))return;const{col:i,row:n,dropDownIndex:r,menuKey:o,text:s,hasChildren:a}=e.target;if("number"!=typeof r||a)return void e.stopPropagation();const l=t.isPivotTable()?t.internalProps.layoutMap.getPivotDimensionInfo(i,n):t.getHeaderField(i,n),h=t._dropDownMenuIsHighlight(i,n,r);t.fireListeners(sf.DROPDOWNMENU_CLICK,{col:i,row:n,field:l,menuKey:o,text:s,highlight:h,cellLocation:t.getCellLocation(i,n)}),t.fireListeners(sf.DROPDOWN_MENU_CLEAR,null),t.fireListeners(sf.HIDE_MENU,null),e.stopPropagation()})),this._rootElement?.addEventListener("mousemove",(t=>{this._rootElement.classList.contains(tU)||t.stopPropagation()}))}get rootElement(){return this._rootElement}release(){this.unbindFromCell();const t=this._rootElement;t?.parentElement&&t.parentElement.removeChild(t),this._handler.release(),delete this._rootElement}bindToCell(t,e,i,n){const r=this._rootElement;if(this._menuInstanceInfo=n,r?.classList.remove(eU),r?.classList.add(tU),this._canBindToCell(t,e,i)){r.innerHTML="",r.appendChild(n.content);if(this._bindCell(t,e,i,n.position,n.referencePosition))return r?.classList.add(eU),r?.classList.remove(tU),!0}else this.unbindFromCell();return!1}unbindFromCell(){const t=this._rootElement;this._menuInstanceInfo=void 0,t?.parentElement&&(t.classList.remove(eU),t.classList.add(tU))}_canBindToCell(t,e,i){const n=t.getCellRangeRelativeRect({col:e,row:i}),r=t.getElement(),{top:o,bottom:s,left:a,right:l}=n,{frozenRowCount:h,frozenColCount:c}=t;if(i>=h&&h>0){if(s<t.getCellRangeRelativeRect({col:e,row:h-1}).bottom)return!1}else if(s<0)return!1;if(e>=c&&c>0){if(l<t.getCellRangeRelativeRect({col:c-1,row:i}).right)return!1}else if(l<0)return!1;const{offsetHeight:u,offsetWidth:d}=r;return!(u<o)&&!(d<a)}_bindCell(t,e,i,n,r){const o=this._rootElement,s=t.getElement(),{width:a,height:l}=t.internalProps.element.getBoundingClientRect();if(o){o.parentElement!==s&&s.appendChild(o),o.style.left="0px";const t=.8*a;o.style.maxWidth=`${t}px`;const e=o.clientWidth,i=o.clientHeight;let h,c;return n&&(h=n.x,c=n.y),r&&(h=r.rect.right-e,c=r.rect.bottom),c+i>l&&(c=l-i,h+=e-2),c<0&&(c/=2),o.style.top=`${c}px`,h<0?h=0:h+e>a&&(h=a-e),o.style.left=`${h}px`,!0}return!1}pointInMenuElement(t,e){const i=this._rootElement,{x:n,y:r,width:o,height:s}=i.getBoundingClientRect();return t>n-5&&t<n+o+5&&e>r-5&&e<r+s+5}}class nU extends JV{createMenuElementInternal(){return new kV(this._table)}}let rU=class extends JV{createMenuElementInternal(){return new iU(this._table)}};const oU={"dropdown-menu":function(t){return new nU(t)},"context-menu":function(t){return new nU(t)},container:t=>new rU(t)};class sU{_table;_menuInstances;_attachInfo;constructor(t){this._table=t,this._menuInstances={},this._bindTableEvent(t)}release(){const t=this._menuInstances;for(const e in t)t[e].release();delete this._menuInstances,this._attachInfo=null}_bindToCell(t,e,i,n){const r=this._attachInfo,o=this._getMenuInstanceInfo(t,e,i,n);if(!r||o&&r.instance===o.instance||(r.instance?.unbindMenuElement(),this._attachInfo=null),!o)return;const{instance:s,info:a}=o;if(s&&s.bindMenuElement(t,e,a)){const i=this._table.getCellRange(t,e);this._attachInfo={range:i,instance:s}}}_unbindFromCell(){const t=this._attachInfo;if(!t)return;const{instance:e}=t;e?.unbindMenuElement(),this._attachInfo=null}_isBindToCell(t,e){const i=this._attachInfo;return!!i&&qp(i.range,t,e)}pointInMenuElement(t,e){if(!this._attachInfo)return!1;const i=this._attachInfo,{instance:n}=i;return n.pointInMenuElement(t,e)}_bindTableEvent(t){t.on(sf.DROPDOWN_ICON_CLICK,(t=>{this._attachInfo&&this._isBindToCell(t.col,t.row)?this._unbindFromCell():this._bindToCell(t.col,t.row,"dropdown-menu")})),t.on(sf.DROPDOWN_MENU_CLEAR,(t=>{this._unbindFromCell()})),t.on(sf.CONTEXTMENU_CELL,(e=>{if("html"===t.internalProps.menu?.renderMode){const i=t._getMouseAbstractPoint(e.event,!1);let n=null;i.inTable&&"function"==typeof t.internalProps.menu?.contextMenuItems?n=t.internalProps.menu.contextMenuItems(t.getHeaderField(e.col,e.row),e.row):i.inTable&&Array.isArray(t.internalProps.menu?.contextMenuItems)&&(n=t.internalProps.menu?.contextMenuItems),this._bindToCell(e.col,e.row,"context-menu",{content:n,position:{x:i.x,y:i.y}})}}))}_getMenuInstanceInfo(t,e,i,n){const r=this._table,o=this._menuInstances,s=function(t,e,i,n,r){const{lineHeight:o,textBaseline:s,textStick:a}=t._getCellStyle(e,i);let l=t.getCellRangeRelativeRect(t.getCellRange(e,i));a&&(l=t.getVisibleCellRangeRelativeRect({col:e,row:i}));let{left:h,right:c,bottom:u,top:d,width:p,height:f}=l;if(t.isHeader(e,i)&&({left:h,right:c,bottom:u,top:d,width:p,height:f}=t.internalProps.headerHelper.getDropDownIconRect(l,o,s||"middle")),r?.content)return{type:n,position:r.position,referencePosition:r.referencePosition??{rect:{left:h,right:c,top:d,bottom:u,width:p,height:f}},content:r.content};if("dropdown-menu"===n){const{dropDownMenu:r=t.globalDropDownMenu,pivotInfo:o}=t._getHeaderLayoutMap(e,i);return{type:n,referencePosition:{rect:{left:h,right:c,top:d,bottom:u,width:p,height:f}},content:r,pivotInfo:o}}return null}(r,t,e,i,n);if(!s)return null;return{instance:o&&o[i]||o&&(o[i]=oU[i](r)),type:i,info:s}}}class aU extends EventTarget{_table;_input;constructor(t,e){if(super(),this._table=t,"node"===hf.mode)return;const i=document.createElement("div");i.style.opacity="0",i.dataset.vtable="vtable",i.style.pointerEvents="none",i.classList.add("input-container");const n=this._input=document.createElement("input");i.appendChild(n),n.classList.add("table-focus-control"),n.dataset.vtable="vtable",n.readOnly=!0,e.appendChild(i)}focus(){this._input.focus({preventScroll:!0})}setFocusRect(t,e){const i=this._input;i.value=e,i.select();const n=t.top-this._table.scrollTop,r=t.left-this._table.scrollLeft;i.style.top=`${n.toFixed()}px`,i.style.left=`${r.toFixed()}px`,i.style.width=`${t.width.toFixed()}px`,i.style.height=`${t.height.toFixed()}px`}get input(){return this._input}release(){}}let lU=1;Op?lU=1:(lU=Math.ceil(window.devicePixelRatio||1),lU>1&&lU%2!=0&&(lU+=1));const hU={orient:"bottom",position:"middle",padding:30,title:{visible:!1,padding:0,textStyle:{fontSize:14,fill:"#000000",fontWeight:"normal"},space:12},item:{visible:!0,spaceCol:10,spaceRow:10,padding:2,background:{state:{selectedHover:{fill:"gray",fillOpacity:.7},unSelectedHover:{fill:"gray",fillOpacity:.2}}},shape:{space:4,state:{unSelected:{fillOpacity:.5}}},label:{space:4,style:{fill:"#89909D",fontSize:14},state:{unSelected:{fillOpacity:.5}}}},allowAllCanceled:!0,visible:!0};function cU(t,e){const{title:i={},item:n={},pager:r={},background:o={},type:s,id:a,visible:l,orient:h,position:c,data:u,filter:d,regionId:p,regionIndex:f,seriesIndex:g,seriesId:m,padding:y,...b}=fd({},hU,t),v=b;return i.visible&&(v.title=nO(i)),od(n.focusIconStyle)||rO(n.focusIconStyle),oO(n.shape),oO(n.label),oO(n.value),oO(n.background),lj(n.maxWidth)&&(n.maxWidth=Number(n.maxWidth.substring(0,n.maxWidth.length-1))*e.width/100),lj(n.width)&&(n.width=Number(n.width.substring(0,n.width.length-1))*e.width/100),lj(n.height)&&(n.height=Number(n.height.substring(0,n.height.length-1))*e.width/100),v.item=n,od(r.textStyle)||rO(r.textStyle),oO(r.handler),v.pager=r,o.visible&&!od(o.style)&&(fd(v,o.style),Uu(o.padding)&&(v.padding=o.padding)),v}class uU{table;option;orient;visible;position;selectedData;legendComponent;constructor(t,e){this.table=e,this.option=cd(t),this.orient=t.orient??"left",this.visible=t.visible??!0,this.position=t.position??"middle",this.selectedData=t.defaultSelected??[],this.createComponent(),this.initEvent()}createComponent(){const t=this.getLegendAttributes({width:this.table.tableNoFrameWidth,height:this.table.tableNoFrameHeight}),e=new CI(fd({},t,{defaultSelected:this.selectedData}));e.name="legend",this.legendComponent=e,this.table.scenegraph.stage.defaultLayer.appendChild(e),this.adjustTableSize(t)}resize(){this.legendComponent&&(this.legendComponent.setAttributes({width:this.table.tableNoFrameWidth,height:this.table.tableNoFrameHeight}),this.adjustTableSize(this.legendComponent.attribute))}adjustTableSize(t){let e=isFinite(this.legendComponent.AABBBounds.width())?this.legendComponent.AABBBounds.width():0,i=isFinite(this.legendComponent.AABBBounds.height())?this.legendComponent.AABBBounds.height():0;const n=this.table.tableNoFrameWidth,r=this.table.tableNoFrameHeight,o=RW(t.padding??this.option.padding??10);let s=0,a=0;"left"===this.orient?(s=o[3],a=0,e+=o[1]+o[3]):"top"===this.orient?(s=0,a=o[0],i+=o[0]+o[2]):"right"===this.orient?(s=n-e-o[1],a=0,e+=o[1]+o[3]):"bottom"===this.orient&&(s=0,a=r-i-o[2],i+=o[0]+o[2]);const l="bottom"===this.orient||"top"===this.orient?"horizontal":"vertical",h=this.position;let c=0,u=0;"horizontal"===l?c="middle"===h?(n-e)/2:"end"===h?n-e-o[1]:o[3]:u="middle"===h?(r-i)/2:"end"===h?r-i-o[2]:o[0],this.legendComponent.setAttributes({dx:c,dy:u,x:s,y:a}),"left"===this.orient?(this.table.tableNoFrameWidth=this.table.tableNoFrameWidth-Math.ceil(e),this.table.tableX+=Math.ceil(e)):"top"===this.orient?(this.table.tableNoFrameHeight=this.table.tableNoFrameHeight-Math.ceil(i),this.table.tableY+=Math.ceil(i)):"right"===this.orient?this.table.tableNoFrameWidth=this.table.tableNoFrameWidth-Math.ceil(e):"bottom"===this.orient&&(this.table.tableNoFrameHeight=this.table.tableNoFrameHeight-Math.ceil(i))}getLegendAttributes(t){return{layout:"bottom"===this.orient||"top"===this.orient?"horizontal":"vertical",items:this.getLegendItems(),maxWidth:t.width,maxHeight:t.height,...cU(this.option,t)}}getLegendItems(){return this.option.data}initEvent(){this.legendComponent&&(this.legendComponent.addEventListener(mI.legendItemClick,(t=>{const e=sd(t,"detail.currentSelected");this.table.fireListeners(sf.LEGEND_ITEM_CLICK,{model:this,value:e,event:t})})),this.legendComponent.addEventListener(mI.legendItemHover,(t=>{const e=sd(t,"detail");this.table.fireListeners(sf.LEGEND_ITEM_HOVER,{model:this,value:e,event:t})})),this.legendComponent.addEventListener(mI.legendItemUnHover,(t=>{const e=sd(t,"detail");this.table.fireListeners(sf.LEGEND_ITEM_UNHOVER,{model:this,value:e,event:t})})),this.legendComponent.addEventListener("legendItemAttributeUpdate",(t=>{this.table.scenegraph.updateNextFrame()})))}getLegendBounds(){return{width:isFinite(this.legendComponent.AABBBounds.width())?this.legendComponent.AABBBounds.width():0,height:isFinite(this.legendComponent.AABBBounds.height())?this.legendComponent.AABBBounds.height():0}}release(){this.legendComponent&&this.table.scenegraph.stage.defaultLayer.removeChild(this.legendComponent),this.legendComponent=null}}const dU={orient:"right",position:"middle",padding:30,title:{visible:!1,padding:0,textStyle:{fontSize:14,fontWeight:"normal",fill:{type:"palette",key:"titleFontColor"}},space:12},handler:{visible:!0},startText:{style:{fontSize:14,fontWeight:"normal",fill:{type:"palette",key:"labelFontColor"}}},endText:{style:{fontSize:14,fontWeight:"normal",fill:{type:"palette",key:"labelFontColor"}}},handlerText:{style:{fontSize:14,fontWeight:"normal",fill:{type:"palette",key:"labelFontColor"}}}},pU={horizontal:{...dU,rail:{width:200,height:8,style:{fill:"rgba(0,0,0,0.04)"}}},vertical:{...dU,rail:{width:8,height:200,style:{fill:"rgba(0,0,0,0.04)"}}}},fU={horizontal:{sizeBackground:{fill:"#cdcdcd"},track:{style:{fill:"rgba(20,20,20,0.1)"}},rail:{width:200,height:4,style:{fill:"rgba(0,0,0,0.04)"}},...dU},vertical:{sizeBackground:{fill:"#cdcdcd"},track:{style:{fill:"rgba(20,20,20,0.1)"}},rail:{width:4,height:200,style:{fill:"rgba(0,0,0,0.04)"}},...dU}};function gU(t,e){const{title:i={},handler:n={},rail:r={},track:o={},startText:s,endText:a,handlerText:l,sizeBackground:h,background:c={},type:u,id:d,visible:p,orient:f,position:g,data:m,defaultSelected:y,field:b,filter:v,regionId:w,regionIndex:C,seriesIndex:x,seriesId:_,padding:S,...A}=fd({},("color"===t.type?pU:fU)["bottom"===t.orient||"top"===t.orient?"horizontal":"vertical"],t),T=A;return i.visible&&(T.title=nO(i)),T.showHandler=!1!==n.visible,od(n.style)||(T.handlerStyle=rO(n.style)),Uu(r.width)&&(T.railWidth=r.width),Uu(r.height)&&(T.railHeight=r.height),od(r.style)||(T.railStyle=rO(r.style)),od(o.style)||(T.trackStyle=rO(o.style)),T.startText=oO(s),T.endText=oO(a),T.handlerText=oO(l),od(h)||(T.sizeBackground=rO(h)),c.visible&&!od(c.style)&&(fd(T,c.style),Uu(c.padding)&&(T.padding=c.padding)),T}class mU{table;option;orient;visible;position;selectedData;legendComponent;constructor(t,e){this.table=e,this.option=cd(t),this.orient=t.orient??"left",this.visible=t.visible??!0,this.position=t.position??"middle",this.selectedData=t.defaultSelected??[],this.createComponent(),this.initEvent()}createComponent(){const t=this.getLegendAttributes({width:this.table.tableNoFrameWidth,height:this.table.tableNoFrameHeight});let e;e="color"===this.option.type?new QI(fd({},t,{slidable:!0})):new eO(fd({},t,{slidable:!0})),e.name="legend",this.legendComponent=e,this.table.scenegraph.stage.defaultLayer.appendChild(e),this.adjustTableSize(t)}resize(){this.legendComponent&&(this.legendComponent.setAttributes({width:this.table.tableNoFrameWidth,height:this.table.tableNoFrameHeight}),this.adjustTableSize(this.legendComponent.attribute))}adjustTableSize(t){let e=isFinite(this.legendComponent.AABBBounds.width())?this.legendComponent.AABBBounds.width():0,i=isFinite(this.legendComponent.AABBBounds.height())?this.legendComponent.AABBBounds.height():0;const n=this.table.tableNoFrameWidth,r=this.table.tableNoFrameHeight,o=RW(t.padding??this.option.padding??10);let s=0,a=0;"left"===this.orient?(s=o[3],a=0,e+=o[1]+o[3]):"top"===this.orient?(s=0,a=o[0],i+=o[0]+o[2]):"right"===this.orient?(s=n-e-o[1],a=0,e+=o[1]+o[3]):"bottom"===this.orient&&(s=0,a=r-i-o[2],i+=o[0]+o[2]);const l="bottom"===this.orient||"top"===this.orient?"horizontal":"vertical",h=this.position;let c=0,u=0;"horizontal"===l?c="middle"===h?(n-e)/2:"end"===h?n-e-o[1]:o[3]:u="middle"===h?(r-i)/2:"end"===h?r-i-o[2]:o[0],this.legendComponent.setAttributes({dx:c,dy:u,x:s,y:a}),"left"===this.orient?(this.table.tableNoFrameWidth=this.table.tableNoFrameWidth-Math.ceil(e),this.table.tableX+=Math.ceil(e)):"top"===this.orient?(this.table.tableNoFrameHeight=this.table.tableNoFrameHeight-Math.ceil(i),this.table.tableY+=Math.ceil(i)):"right"===this.orient?this.table.tableNoFrameWidth=this.table.tableNoFrameWidth-Math.ceil(e):"bottom"===this.orient&&(this.table.tableNoFrameHeight=this.table.tableNoFrameHeight-Math.ceil(i))}getLegendAttributes(t){const e="bottom"===this.orient||"top"===this.orient?"horizontal":"vertical",i="horizontal"===e?"bottom":this.orient;return{...gU(this.option),layout:e,align:i,min:this.option.min,max:this.option.max,value:this.option.value,["color"===this.option.type?"colors":"sizeRange"]:"color"===this.option.type?this.option.colors:this.option.sizeRange}}initEvent(){this.legendComponent&&this.legendComponent.addEventListener("change",(t=>{const e=sd(t,"detail.value");this.table.fireListeners(sf.LEGEND_CHANGE,{model:this,value:e,event:t}),this.table.scenegraph.updateNextFrame()}))}getLegendBounds(){return{width:isFinite(this.legendComponent.AABBBounds.width())?this.legendComponent.AABBBounds.width():0,height:isFinite(this.legendComponent.AABBBounds.height())?this.legendComponent.AABBBounds.height():0}}release(){this.legendComponent&&this.table.scenegraph.stage.defaultLayer.removeChild(this.legendComponent),this.legendComponent=null}}function yU(t,e){return"color"===t.type||"size"===t.type?new mU(t,e):new uU(t,e)}class bU{table;_titleOption;_titleComponent;_cacheAttrs;constructor(t,e){this.table=e,this._titleOption=t,this._titleComponent=this._createOrUpdateTitleComponent(this._getTitleAttrs())}_createOrUpdateTitleComponent(t){if(this._titleComponent)yd(t,this._cacheAttrs)||this._titleComponent.setAttributes(t);else{const e=new iO(t);e.name="title",this.table.scenegraph.stage.defaultLayer.appendChild(e),this._titleComponent=e}return this._adjustTableSize(this._titleComponent.attribute),this._titleComponent}resize(){if(!this._titleComponent)return;const t=RW(this._titleOption.padding??10),e=this._titleOption.width??this.table.tableNoFrameWidth-t[1]-t[3];this._titleComponent.setAttributes({x:this._titleOption.x??"right"===this._titleOption.orient?this.table.tableX+this.table.tableNoFrameWidth:this.table.tableX,y:this._titleOption.y??"bottom"===this._titleOption.orient?this.table.tableY+this.table.tableNoFrameHeight:this.table.tableY,width:e,textStyle:{width:e,...this._titleOption.textStyle},subtextStyle:{width:e,...this._titleOption.subtextStyle}}),this._adjustTableSize(this._titleComponent.attribute)}_adjustTableSize(t){let e=isFinite(this._titleComponent.AABBBounds.width())?this._titleComponent.AABBBounds.width():0;const i=isFinite(this._titleComponent.AABBBounds.height())?this._titleComponent.AABBBounds.height():0,n=(this.table.tableNoFrameWidth,this.table.tableNoFrameHeight,RW(t.padding??this._titleOption.padding??10));"left"===this._titleOption.orient?n[3]:"top"===this._titleOption.orient?n[0]:"right"===this._titleOption.orient?(n[1],e+=n[1]+n[3]):"bottom"===this._titleOption.orient&&n[2],"left"===this._titleOption.orient?(this.table.tableNoFrameWidth=this.table.tableNoFrameWidth-Math.ceil(e),this.table.tableX+=Math.ceil(e)):"top"===this._titleOption.orient?(this.table.tableNoFrameHeight=this.table.tableNoFrameHeight-Math.ceil(i),this.table.tableY+=Math.ceil(i)):"right"===this._titleOption.orient?this.table.tableNoFrameWidth=this.table.tableNoFrameWidth-Math.ceil(e):"bottom"===this._titleOption.orient&&(this.table.tableNoFrameHeight=this.table.tableNoFrameHeight-Math.ceil(i)),this._cacheAttrs=t,"right"!==this._titleOption.orient&&"bottom"!==this._titleOption.orient||this._titleComponent.setAttributes({x:this._titleOption.x??"right"===this._titleOption.orient?this.table.tableX+this.table.tableNoFrameWidth:this.table.tableX,y:this._titleOption.y??"bottom"===this._titleOption.orient?this.table.tableY+this.table.tableNoFrameHeight:this.table.tableY})}release(){this.table.scenegraph.stage.defaultLayer.removeChild(this._titleComponent),this._titleComponent=null}_getTitleAttrs(){const t=RW(this._titleOption.padding??10),e=this._titleOption.width??this.table.tableNoFrameWidth-t[1]-t[3];return{text:this._titleOption.text??"",subtext:this._titleOption.subtext??"",x:this._titleOption.x??"right"===this._titleOption.orient?this.table.tableX+this.table.tableNoFrameWidth:this.table.tableX,y:this._titleOption.y??"bottom"===this._titleOption.orient?this.table.tableY+this.table.tableNoFrameHeight:this.table.tableY,width:e,height:this._titleOption.height,minWidth:this._titleOption.minWidth,maxWidth:this._titleOption.maxWidth,minHeight:this._titleOption.minHeight,maxHeight:this._titleOption.maxHeight,padding:this._titleOption.padding,align:this._titleOption.align??"left",verticalAlign:this._titleOption.verticalAlign??"top",textStyle:{width:e,...this._titleOption.textStyle},subtextStyle:{width:e,...this._titleOption.subtextStyle}}}}const{toBoxArray:vU}=rf,{isTouchEvent:wU}=nf,CU=/^\$(\d+)\$(\d+)$/;!function(){const t=document.createElement("style");t.id="vtable-style-styleSheet",t.textContent="\n.vtable .input-container {\n\tposition: absolute;\n\ttop:0px;\n}\n.vtable .table-scrollable {\n\tposition: absolute;\n\toverflow: scroll;\n}\n.vtable .table-scrollable::-webkit-scrollbar-button{\n\tbackground-color: transparent;\n}\n.vtable .table-scrollable::-webkit-scrollbar-track-piece{\n\tbackground-color: transparent;\n}\n.vtable .table-scrollable::-webkit-scrollbar-corner {\n\tbackground-color: transparent;\n}\n.vtable .table-scrollable::-webkit-scrollbar-thumb {\n\tborder-radius : 4px;\n\tbackground-color : rgba(100, 100, 100, .5);\n}\n\n.vtable .table-scroll-end-point {\n\topacity: 0;\n\tposition: relative;\n}\n.vtable {\n\t/* 设置overflow: auto 应该是为了滚动条的某个问题 但设置了auto之后 dom的下拉菜单只能显示在vtable节点中 超出会截断;现在去掉auto 暂时滚动条的问题没有发现 */\n\t/* overflow: auto; */\n\tposition: relative;\n\twidth: 100%;\n\theight: 100%;\n\ttext-align: left;\n -webkit-font-smoothing:auto;\n}\n.vtable > canvas {\n\tposition: absolute;\n\twidth: 0;\n\theight: 0;\n}\n.vtable .table-focus-control {\n\tposition: relative !important;\n\twidth: 1px;\n\theight: 1px;\n\topacity: 0;\n\tpadding: 0;\n\tmargin: 0;\n\tbox-sizing: border-box;\n\tpointer-events: none;\n\tmax-width: 500px;\n\tmax-height: 500px;\n\tfloat: none !important;\n}\n.vtable input.table-focus-control::-ms-clear {\n\tvisibility: hidden;\n}\n.vtable input.table-focus-control.composition {\n\topacity: 1;\n\tmax-width: none;\n\tmax-height: none;\n}\n",document.body.appendChild(t)}();const xU={};class _U extends Su{internalProps;showFrozenIcon=!0;showSort=!0;padding;globalDropDownMenu;tableNoFrameWidth;tableNoFrameHeight;tableX;tableY;_widthMode;_heightMode;_autoFillWidth;customRender;canvasWidth;canvasHeight;_vDataSet;scenegraph;stateManeger;eventManeger;_pixelRatio;static get EVENT_TYPE(){return sf}options;version="0.10.2";pagination;id=`VTable${Date.now()}`;headerStyleCache;bodyStyleCache;container;constructor(t,e={}){if(super(),!t)throw new Error("vtable's container is undefined");const{frozenColCount:i=0,defaultRowHeight:n=40,defaultHeaderRowHeight:r,defaultColWidth:o=80,defaultHeaderColWidth:s,widthMode:a="standard",heightMode:l="standard",autoFillWidth:h=!1,keyboardOptions:c,columnResizeMode:u,dragHeaderMode:d,showFrozenIcon:p,allowFrozenColCount:f,padding:g,hover:m,menu:y,select:b,customRender:v,pixelRatio:w=lU,renderChartAsync:C,renderChartAsyncBatchCount:x}=e;this.container=t,this.options=e,this.options.container=t,this._widthMode=a,this._heightMode=l,this._autoFillWidth=h,this.customRender=v,this.padding={top:0,right:0,left:0,bottom:0},g&&("number"==typeof g?(this.padding.top=g,this.padding.left=g,this.padding.bottom=g,this.padding.right=g):(g.top&&(this.padding.top=g.top),g.bottom&&(this.padding.bottom=g.bottom),g.left&&(this.padding.left=g.left),g.right&&(this.padding.right=g.right))),this.tableNoFrameWidth=0,this.tableNoFrameHeight=0;const _=this.internalProps={};void 0!==p&&(this.showFrozenIcon=p),"number"==typeof f&&f<=0&&(this.showFrozenIcon=!1),_.handler=new df,_.element=function(t){const e=document.createElement("div");e.setAttribute("tabindex","0"),e.classList.add("vtable"),e.style.outline="none",e.style.margin=`${t.top}px ${t.right}px ${t.bottom}px ${t.left}px`;const i=(e.offsetWidth||e.parentElement?.offsetWidth||1)-1,n=(e.offsetHeight||e.parentElement?.offsetHeight||1)-1;return e.style.width=i&&i-t.left-t.right+"px"||"0px",e.style.height=n&&n-t.top-t.bottom+"px"||"0px",e}(this.padding),_.focusControl=new aU(this,_.element),_.pixelRatio=w,_.canvas=document.createElement("canvas"),_.element.appendChild(_.canvas),_.context=_.canvas.getContext("2d"),_.frozenColCount=i,_.defaultRowHeight=n,_.defaultHeaderRowHeight=r??n,_.defaultColWidth=o,_.defaultHeaderColWidth=s??o,_.keyboardOptions=c,_.columnResizeMode=u,_.dragHeaderMode=d,_.renderChartAsync=C,sN(x),_._rowHeightsMap=new ff,_._rowRangeHeightsMap=new Map,_._colRangeWidthsMap=new Map,_._widthResizedColMap=new Set,this.colWidthsMap=new ff,this.colContentWidthsMap=new ff,this.colWidthsLimit={},_.calcWidthContext={_:_,get full(){return this._.canvas.width/(this._.context.pixelRatio??window.devicePixelRatio)}},_.cellTextOverflows={},_.focusedTable=!1,_.theme=Ff.of(e.theme??Ff.DEFAULT),t?(t.innerHTML="",t.appendChild(_.element),this._updateSize()):this._updateSize(),this.options=e,_.theme=Ff.of(e.theme??Ff.DEFAULT),_.bodyHelper=new yV(this),_.headerHelper=new FV(this),_.autoWrapText=e.autoWrapText,_.allowFrozenColCount=e.allowFrozenColCount??_.colCount,_.limitMaxAutoWidth=e.limitMaxAutoWidth??450,this._vDataSet=new jz,this.scenegraph=new WG(this),this.stateManeger=new iV(this),this.eventManeger=new pV(this),e.legends&&(_.legends=yU(e.legends,this),this.scenegraph.tableGroup.setAttributes({x:this.tableX,y:this.tableY})),e.title&&(_.title=new bU(e.title,this),this.scenegraph.tableGroup.setAttributes({x:this.tableX,y:this.tableY})),_.tooltip=Object.assign({renderMode:"html",isShowOverflowTextTooltip:!1,confine:!0},e.tooltip),"html"===_.tooltip.renderMode&&(_.tooltipHandler=new XV(this,_.tooltip.confine)),_.menu=Object.assign({renderMode:"html"},e.menu),Array.isArray(e.menu?.dropDownMenuHighlight)&&this.setDropDownMenuHighlight(e.menu?.dropDownMenuHighlight),Array.isArray(e.menu?.defaultHeaderMenuItems)&&(this.globalDropDownMenu=e.menu.defaultHeaderMenuItems),"html"===_.menu.renderMode&&(_.menuHandler=new sU(this)),this.headerStyleCache=new Map,this.bodyStyleCache=new Map}throttleInvalidate=function(t,e){let i=null;return function(...n){i||(i=setTimeout((()=>{t.apply(this,n),i=null}),e))}}(this.render.bind(this),200);getContainer(){return this.container}getElement(){return this.internalProps.element}get canvas(){return this.internalProps.canvas}resize(){this._updateSize(),this.internalProps.legends&&this.internalProps.legends.resize(),this.internalProps.title&&this.internalProps.title.resize(),this.scenegraph.resize()}get rowCount(){return this.internalProps.rowCount}set rowCount(t){this.internalProps.rowCount=t}get colCount(){return this.internalProps.colCount??0}set colCount(t){this.internalProps.colCount=t}get frozenColCount(){return this.internalProps.frozenColCount??0}set frozenColCount(t){t>=this.colCount&&(t=0),this.internalProps.frozenColCount=t,this.options.frozenColCount=t,this.tableNoFrameWidth-this.getColsWidth(0,t-1)<=120&&(this.internalProps.frozenColCount=0),this.stateManeger.setFrozenCol(this.internalProps.frozenColCount)}setFrozenColCount(t){t>=this.colCount&&(t=0),this.internalProps.frozenColCount=t,this.options.frozenColCount=t,this.tableNoFrameWidth-this.getColsWidth(0,t-1)<=120&&(this.internalProps.frozenColCount=0),this.stateManeger.setFrozenCol(this.internalProps.frozenColCount)}_setFrozenColCount(t){t>=this.colCount&&(t=0),this.internalProps.frozenColCount=t}_resetFrozenColCount(){this.options.frozenColCount&&(this.tableNoFrameWidth-this.getColsWidth(0,this.options.frozenColCount-1)<=120?this._setFrozenColCount(0):this.frozenColCount!==this.options.frozenColCount&&this._setFrozenColCount(this.options.frozenColCount))}get frozenRowCount(){return this.internalProps.frozenRowCount??0}set frozenRowCount(t){this.internalProps.frozenRowCount=t}get rightFrozenColCount(){return this.internalProps.rightFrozenColCount??0}set rightFrozenColCount(t){this.scenegraph.dealWidthRightFrozen(t)}get bottomFrozenRowCount(){return this.internalProps.bottomFrozenRowCount??0}set bottomFrozenRowCount(t){this.scenegraph.dealWidthBottomFrozen(t)}get defaultRowHeight(){return this.internalProps.defaultRowHeight}set defaultRowHeight(t){this.internalProps.defaultRowHeight=t,this.options.defaultRowHeight=t}get defaultHeaderRowHeight(){return this.internalProps.defaultHeaderRowHeight}set defaultHeaderRowHeight(t){this.internalProps.defaultHeaderRowHeight=t,this.options.defaultHeaderRowHeight=t}get defaultColWidth(){return this.internalProps.defaultColWidth}set defaultColWidth(t){this.internalProps.defaultColWidth=t,this.options.defaultColWidth=t}get defaultHeaderColWidth(){return this.internalProps.defaultHeaderColWidth}set defaultHeaderColWidth(t){this.internalProps.defaultHeaderColWidth=t,this.options.defaultHeaderColWidth=t}get colWidthsMap(){return this.internalProps._colWidthsMap}set colWidthsMap(t){this.internalProps._colWidthsMap=t}get colContentWidthsMap(){return this.internalProps._colContentWidthsMap}set colContentWidthsMap(t){this.internalProps._colContentWidthsMap=t}get _colRangeWidthsMap(){return this.internalProps._colRangeWidthsMap}set _colRangeWidthsMap(t){this.internalProps._colRangeWidthsMap=t}get _rowRangeHeightsMap(){return this.internalProps._rowRangeHeightsMap}set _rowRangeHeightsMap(t){this.internalProps._rowRangeHeightsMap=t}get rowHeightsMap(){return this.internalProps._rowHeightsMap}set rowHeightsMap(t){this.internalProps._rowHeightsMap=t}get colWidthsLimit(){return this.internalProps._colWidthsLimit}set colWidthsLimit(t){this.internalProps._colWidthsLimit=t}get keyboardOptions(){return this.internalProps.keyboardOptions??null}set keyboardOptions(t){this.internalProps.keyboardOptions=t??void 0}get widthMode(){return this._widthMode}set widthMode(t){t!==this._widthMode&&(this._widthMode=t,this.options.widthMode=t)}get heightMode(){return this._heightMode}set heightMode(t){t!==this._heightMode&&(this._heightMode=t,this.options.heightMode=t)}get autoFillWidth(){return this._autoFillWidth}set autoFillWidth(t){t!==this._autoFillWidth&&(this._autoFillWidth=t)}_colWidthDefineToPxWidth(t){return"auto"===t?0:dj(this,t)}_getColWidthLimits(t){const e=this.colWidthsLimit[t];if(!e)return null;const i={};return e.min&&(i.min=dj(this,e.min),i.minDef=e.min),e.max&&(i.max=dj(this,e.max),i.maxDef=e.max),i}_adjustColWidth(t,e){const i=this._getColWidthLimits(t);return Math.max(function(t,e){return t?t.min&&t.min>e?t.min:t.max&&t.max<e?t.max:e:e}(i,e),0)}setPixelRatio(t){this.internalProps.pixelRatio=t,this.scenegraph.setPixelRatio(t)}_updateSize(){const{padding:t}=this;let e=0,i=0;if("browser"===hf.mode){const n=this.getElement(),r=n.parentElement?.offsetWidth??0,o=n.parentElement?.offsetHeight??0;n.style.width=r&&r-t.left-t.right+"px"||"0px",n.style.height=o&&o-t.top-t.bottom+"px"||"0px";const{canvas:s}=this.internalProps;e=s.parentElement?.offsetWidth??0,i=s.parentElement?.offsetHeight??0,this?.scenegraph?.stage?this.scenegraph.stage.resize(e,i):(s.style.width="",s.style.height="",s.width=e,s.height=i,s.style.width=`${e}px`,s.style.height=`${i}px`)}else"node"===hf.mode&&(e=this.canvasWidth-1,i=this.canvasHeight-1);const n=Math.floor(e-Fu(this.getTheme().scrollStyle)),r=Math.floor(i-Fu(this.getTheme().scrollStyle));if(this.internalProps.theme?.frameStyle){const t=vU(this.internalProps.theme.frameStyle?.borderLineWidth??[null]),e=vU(this.internalProps.theme.frameStyle?.shadowBlur??[0]);this.tableX=(t[3]??0)+(e[3]??0),this.tableY=(t[0]??0)+(e[0]??0),this.tableNoFrameWidth=n-((t[1]??0)+(e[1]??0))-((t[3]??0)+(e[3]??0)),this.tableNoFrameHeight=r-((t[0]??0)+(e[0]??0))-((t[2]??0)+(e[2]??0))}}get rowHierarchyType(){return"grid"}setColWidths(t){t.forEach(((t,e)=>this.setColWidth(e,t)))}getColsWidth(t,e){e=Math.min(e,this.colCount-1);const i=this._colRangeWidthsMap.get(`$${t}$${e}`);if(null!=i)return i;const n=this._colRangeWidthsMap.get(`$${t}$${e-1}`);if(null!=n){const i=n+this.getColWidth(e);return t>=0&&e>=0&&!Number.isNaN(i)&&this._colRangeWidthsMap.set(`$${t}$${e}`,Math.round(i)),Math.round(i)}let r=0;for(let i=t;i<=e;i++)r+=this.getColWidth(i);return t>=0&&e>=0&&this._colRangeWidthsMap.set(`$${t}$${e}`,Math.round(r)),Math.round(r)}getRowHeight(t){return this.rowHeightsMap.get(t)?this.rowHeightsMap.get(t):this.isColumnHeader(0,t)||this.isCornerHeader(0,t)?Array.isArray(this.defaultHeaderRowHeight)?this.defaultHeaderRowHeight[t]??this.internalProps.defaultRowHeight:this.defaultHeaderRowHeight:this.isBottomFrozenRow(this.rowHeaderLevelCount,t)?Array.isArray(this.defaultHeaderRowHeight)?this.defaultHeaderRowHeight[this.columnHeaderLevelCount-this.bottomFrozenRowCount]??this.internalProps.defaultRowHeight:this.defaultHeaderRowHeight:this.internalProps.defaultRowHeight}setRowHeight(t,e,i){this.rowHeightsMap.put(t,Math.round(e)),i&&this._clearRowRangeHeightsMap(t)}getRowsHeight(t,e){const i=this._rowRangeHeightsMap.get(`$${t}$${e}`);if(null!=i)return i;const n=this._rowRangeHeightsMap.get(`$${t}$${e-1}`);if(null!=n){const i=Math.round(n+(this.rowHeightsMap.get(e)??(this.isColumnHeader(0,e)||this.isCornerHeader(0,e)?Array.isArray(this.defaultHeaderRowHeight)?this.defaultHeaderRowHeight[e]??this.internalProps.defaultRowHeight:this.defaultHeaderRowHeight:this.internalProps.defaultRowHeight)));return t>=0&&e>=0&&this._rowRangeHeightsMap.set(`$${t}$${e}`,Math.round(i)),i}let r=0;if("standard"===this.heightMode&&this.internalProps.layoutMap&&e>=this.columnHeaderLevelCount&&!this.bottomFrozenRowCount&&!this.hasAutoImageColumn()){for(let e=t;e<this.columnHeaderLevelCount;e++)r+=this.getRowHeight(e);r+=this.defaultRowHeight*(e-Math.max(this.columnHeaderLevelCount,t)+1)}else for(let i=t;i<=e;i++)r+=this.getRowHeight(i);return t>=0&&e>=0&&r>0&&this._rowRangeHeightsMap.set(`$${t}$${e}`,Math.round(r)),Math.round(r)}getColWidthDefined(t){const{layoutMap:e}=this.internalProps;if("autoWidth"===this.widthMode)return"auto";const{width:i}=e?.getColumnWidthDefined(t)??{};return"number"==typeof i&&i<=0?0:i||(this.isRowHeader(t,0)||this.isCornerHeader(t,0)?Array.isArray(this.defaultHeaderColWidth)?this.defaultHeaderColWidth[t]??this.defaultColWidth:this.defaultHeaderColWidth:this.isRightFrozenColumn(t,this.columnHeaderLevelCount)&&this.isPivotTable()?Array.isArray(this.defaultHeaderColWidth)?this.defaultHeaderColWidth[this.rowHeaderLevelCount-this.rightFrozenColCount]??this.defaultColWidth:this.defaultHeaderColWidth:this.defaultColWidth)}getColWidth(t){const e=this.colWidthsMap.get(t)??0;return"adaptive"===this.widthMode&&"number"==typeof e||this.transpose&&"number"==typeof e?this._colWidthDefineToPxWidth(e):this._adjustColWidth(t,this._colWidthDefineToPxWidth(e))}setColWidth(t,e,i,n){this.colWidthsMap.put(t,"number"==typeof e?Math.round(e):e),i&&this._clearColRangeWidthsMap(t),n||this.stateManeger.checkFrozen()}_clearColRangeWidthsMap(t){if("number"!=typeof t)this._colRangeWidthsMap.clear();else{const e=this._colRangeWidthsMap.keys();for(const i of e){const e=CU.exec(i);if(e){const n=Number(e[1]),r=Number(e[2]);t>=n&&t<=r&&this._colRangeWidthsMap.delete(i)}}}}_clearRowRangeHeightsMap(t){if("number"!=typeof t)this._rowRangeHeightsMap.clear();else{const e=this._rowRangeHeightsMap.keys();for(const i of e){const e=CU.exec(i);if(e){const n=Number(e[1]),r=Number(e[2]);t>=n&&t<=r&&this._rowRangeHeightsMap.delete(i)}}}}_getColContentWidth(t){return Number(this.colContentWidthsMap.get(t))}_setColContentWidth(t,e){this.colContentWidthsMap.put(t,e)}getAllRowsHeight(){if(this.internalProps.rowCount<=0)return 0;return this.getRowsHeight(0,this.internalProps.rowCount-1)}getAllColsWidth(){if(this.internalProps.colCount<=0)return 0;return this.getColsWidth(0,this.internalProps.colCount-1)}getMaxColWidth(t){const e=this.colWidthsLimit[t];let i=(e&&e.max)??1/0;return"string"==typeof i&&(i=dj(this,i)),i}setMaxColWidth(t,e){(this.colWidthsLimit[t]||(this.colWidthsLimit[t]={})).max=e}getMinColWidth(t){const e=this.colWidthsLimit[t];let i=(e&&e.min)??0;return"string"==typeof i&&(i=dj(this,i)),i}setMinColWidth(t,e){(this.colWidthsLimit[t]||(this.colWidthsLimit[t]={})).min=e}getCellRect(t,e){const i=this.isFrozenCell(t,e);let n=this.getColsWidth(0,t-1)||0;const r=this.getColWidth(t);i&&i.col&&(n+=this.scrollLeft);let o=this.getRowsHeight(0,e-1);const s=this.getRowHeight(e);return i&&i.row&&(o+=this.scrollTop),new gf(Math.round(n),Math.round(o),Math.round(r),Math.round(s))}getMergeCellRect(t,e){const i=this.getCellRange(t,e),n=this.getColsWidth(0,i.start.col-1)||0,r=this.getColsWidth(i.start.col,i.end.col),o=this.getRowsHeight(0,i.start.row-1)||0,s=this.getRowsHeight(i.start.row,i.end.row);return new gf(Math.round(n),Math.round(o),Math.round(r),Math.round(s))}getCellRelativeRect(t,e){return this._toRelativeRect(this.getCellRect(t,e))}getCellRangeRelativeRect(t){if(t.start)return this._toRelativeRect(this.getCellsRect(t.start.col,t.start.row,t.end.col,t.end.row));const e=this.getCellRange(t.col,t.row);return this._toRelativeRect(this.getCellsRect(e.start.col,e.start.row,e.end.col,e.end.row))}getVisibleCellRangeRelativeRect(t){let e;return e=t.start?t:this.getCellRange(t.col,t.row),this._getVisiableRect(this.getCellRangeRelativeRect(t),e)}_getVisiableRect(t,e){const i=e.start.col>=this.frozenColCount?Math.max(t.left,this.frozenColCount>=1?this.getColsWidth(0,this.frozenColCount-1):0):t.left,n=Math.min(t.right,this.tableNoFrameWidth),r=t.copy();r.left=i,r.right=n;const o=e.start.row>=this.frozenRowCount?Math.max(t.top,this.frozenRowCount>=1?this.getRowsHeight(0,this.frozenRowCount-1):0):t.top,s=Math.min(t.bottom,this.tableNoFrameHeight);return r.top=o,r.bottom=s,r}getCellsRect(t,e,i,n){const r=this.isFrozenCell(t,e),o=this.isFrozenCell(i,n);let s=this.getColsWidth(0,t-1)||0,a=this.getColsWidth(t,i);if(r&&r.col){const e=this.scrollLeft;s+=e,o&&o.col||(a-=e,a=Math.max(a,this.getColsWidth(t,this.frozenColCount-1)))}let l=this.getRowsHeight(0,e-1),h=this.getRowsHeight(e,n);if(r&&r.row){const t=this.scrollTop;l+=t,o&&o.row||(h-=t,h=Math.max(h,this.getRowsHeight(e,this.frozenRowCount-1)))}return new gf(Math.round(s),Math.round(l),Math.round(a),Math.round(h))}getCellsRectWidth(t,e,i,n){const r=this.isFrozenCell(t,e),o=this.isFrozenCell(i,n);let s=this.getColsWidth(t,i);if(r&&r.col){const e=this.scrollLeft;o&&o.col||(s-=e,s=Math.max(s,this.getColsWidth(t,this.frozenColCount-1)))}return s}getCellRangeRect(t){if(t.start)return this.getCellsRect(t.start.col,t.start.row,t.end.col,t.end.row);const e=this.getCellRange(t.col,t.row);return this.getCellsRect(e.start.col,e.start.row,e.end.col,e.end.row)}getCellRangeRectWidth(t){if(t.start)return this.getCellsRectWidth(t.start.col,t.start.row,t.end.col,t.end.row);const e=this.getCellRange(t.col,t.row);return this.getCellsRectWidth(e.start.col,e.start.row,e.end.col,e.end.row)}isFrozenCell(t,e){const{frozenRowCount:i,frozenColCount:n}=this.internalProps,r=i>0&&e<i||this.isBottomFrozenRow(t,e),o=n>0&&t<n||this.isRightFrozenColumn(t,e);return r||o?{row:r,col:o}:null}getRowAt(t){const e=function(t,e){if(!t.internalProps.frozenRowCount)return null;let{scrollTop:i}=t;const n=t.internalProps.frozenRowCount;for(let r=0;r<n;r++){const n=t.getRowHeight(r),o=i+n;if(o>e)return{top:i,row:r,bottom:o,height:n};i=o}return null}(this,t);if(e)return e;let i=this.getTargetRowAt(t);return i||(i={top:-1,row:-1,bottom:-1,height:-1}),i}getColAt(t){const e=function(t,e){if(!t.internalProps.frozenColCount)return null;let{scrollLeft:i}=t;const n=t.internalProps.frozenColCount;for(let r=0;r<n;r++){const n=t.getColWidth(r),o=i+n;if(o>e)return{left:i,col:r,right:o,width:n};i=o}return null}(this,t);if(e)return e;let i=this.getTargetColAt(t);return i||(i={left:-1,col:-1,right:-1,width:1}),i}getCellAt(t,e){const i=this.getRowAt(e),{row:n,top:r,bottom:o,height:s}=i,a=this.getColAt(t),{col:l,left:h,right:c,width:u}=a;return{row:n,col:l,rect:{left:h,right:c,top:r,bottom:o,width:u,height:s}}}_checkRowCol(t,e){return t>=0&&t<this.colCount&&e>=0&&e<this.rowCount}_makeVisibleCell(t,e){if(this._checkRowCol(t,e)){const i=this.isFrozenCell(t,e);if(i&&i.col&&i.row)return;const n=this.getCellRect(t,e),r=function(t){let e=0;t.internalProps.frozenColCount>0&&(e=t.getFrozenColsWidth());let i=0;return t.internalProps.frozenRowCount>0&&(i=t.getFrozenRowsHeight()),new gf(t.scrollLeft+e,t.scrollTop+i,t.tableNoFrameWidth-e,t.tableNoFrameHeight-i)}(this);if(r.contains(n))return;i&&i.col||this.getColsWidth(0,this.frozenColCount-1)+n.width>this.canvas.width||(n.left<r.left?this.scrollLeft-=r.left-n.left:r.right<n.right&&(this.scrollLeft-=r.right-n.right)),i&&i.row||this.getRowsHeight(0,this.frozenRowCount-1)+n.height>this.canvas.height||(n.top<r.top?this.scrollTop-=r.top-n.top:r.bottom<n.bottom&&(this.scrollTop-=r.bottom-n.bottom))}}render(){this.scenegraph.renderSceneGraph()}_toRelativeRect(t){const e=t.copy(),i=this.getVisibleRect();return e.offsetLeft(-i.left),e.offsetTop(-i.top),e}getVisibleRect(){const{scrollTop:t,scrollLeft:e}=this,i=this.tableNoFrameWidth,n=this.tableNoFrameHeight;return new gf(e,t,i,n)}get visibleRowCount(){const{frozenRowCount:t}=this,e=this.getVisibleRect(),i=t>0?e.top+this.getRowsHeight(0,t-1):e.top,n=this.getTargetRowAt(i);if(!n)return 0;const r=Math.max(n.top>=i?n.row:n.row+1,t);let o=this.getRowsHeight(0,r-1),s=0;const{rowCount:a}=this;for(let t=r;t<a;t++){const i=o+this.getRowHeight(t);if(e.bottom<i)break;s++,o=i}return s}get visibleColCount(){const{frozenColCount:t}=this,e=this.getVisibleRect(),i=t>0?e.left+this.getColsWidth(0,t-1):e.left,n=this.getTargetColAt(i);if(!n)return 0;const r=Math.max(n.left>=i?n.col:n.col+1,t);let o=this.getColsWidth(0,r-1),s=0;const{colCount:a}=this;for(let t=r;t<a;t++){const i=o+this.getColWidth(t);if(e.right<i)break;s++,o=i}return s}get scrollTop(){return this.stateManeger.scroll.verticalBarPos}set scrollTop(t){this.stateManeger.setScrollTop(t)}get scrollLeft(){return this.stateManeger.scroll.horizontalBarPos}set scrollLeft(t){this.stateManeger.setScrollLeft(t)}getScrollLeft(){return this.scrollLeft}getScrollTop(){return this.scrollTop}setScrollLeft(t){this.scrollLeft=Math.ceil(t)}setScrollTop(t){this.scrollTop=Math.ceil(t)}getCellOverflowText(t,e){return this.scenegraph.getCellOverflowText(t,e)}addReleaseObj(t){if(!t||!t.release||"function"!=typeof t.release)throw new Error("not releaseObj!");(this.internalProps.releaseList=this.internalProps.releaseList||[]).push(t)}dispose(){this.release()}release(){const t=this.internalProps;t.tooltipHandler?.release?.(),t.menuHandler?.release?.(),gj.clearAll(),super.release?.(),t.handler?.release?.(),t.focusControl?.release?.(),t.releaseList&&(t.releaseList.forEach((t=>t?.release?.())),t.releaseList=null),this.scenegraph.stage.release();const{parentElement:e}=t.element;e&&e.removeChild(t.element)}fireListeners(t,e){return super.fireListeners(t,e)}updateOption(t){this.options=t;const{frozenColCount:e=0,defaultRowHeight:i=40,defaultHeaderRowHeight:n,defaultColWidth:r=80,defaultHeaderColWidth:o=80,keyboardOptions:s,columnResizeMode:a,dragHeaderMode:l,showFrozenIcon:h,allowFrozenColCount:c,padding:u,hover:d,menu:p,select:f,pixelRatio:g,widthMode:m,heightMode:y,autoFillWidth:b,customRender:v,renderChartAsync:w,renderChartAsyncBatchCount:C}=t;g&&g!==this.internalProps.pixelRatio&&(this.internalProps.pixelRatio=g),u&&("number"==typeof u?(this.padding.top=u,this.padding.left=u,this.padding.bottom=u,this.padding.right=u):(u.top&&(this.padding.top=u.top),u.bottom&&(this.padding.bottom=u.bottom),u.left&&(this.padding.left=u.left),u.right&&(this.padding.right=u.right))),this.showFrozenIcon="boolean"!=typeof h||h,"number"==typeof c&&c<=0&&(this.showFrozenIcon=!1),this.widthMode=m??"standard",this.heightMode=y??"standard",this.autoFillWidth=b??!1,this.customRender=v;const x=this.internalProps;"node"!==hf.mode&&function(t,e){t.style.margin=`${e.top}px ${e.right}px ${e.bottom}px ${e.left}px`;const i=(t.offsetWidth||t.parentElement?.offsetWidth||1)-1,n=(t.offsetHeight||t.parentElement?.offsetHeight||1)-1;t.style.width=i&&i-e.left-e.right+"px"||"0px",t.style.height=n&&n-e.top-e.bottom+"px"||"0px"}(x.element,this.padding),x.frozenColCount=e,x.defaultRowHeight=i,x.defaultHeaderRowHeight=n??i,x.defaultColWidth=r,x.defaultHeaderColWidth=o??r,x.keyboardOptions=s,x.columnResizeMode=a,x.dragHeaderMode=l,x.renderChartAsync=w,sN(C),x.cellTextOverflows={},x._rowHeightsMap=new ff,x._rowRangeHeightsMap=new Map,x._colRangeWidthsMap=new Map,x._widthResizedColMap=new Set,this.colWidthsMap=new ff,this.colContentWidthsMap=new ff,this.colWidthsLimit={},x.theme=Ff.of(t.theme??Ff.DEFAULT),x.autoWrapText=t.autoWrapText,x.allowFrozenColCount=t.allowFrozenColCount??x.colCount,x.limitMaxAutoWidth=t.limitMaxAutoWidth??450,this._vDataSet=new jz,x.legends?.release(),x.title?.release(),x.layoutMap.release(),this.scenegraph.clearCells(),this.stateManeger.initState(),this._updateSize(),t.legends&&(x.legends=yU(t.legends,this),this.scenegraph.tableGroup.setAttributes({x:this.tableX,y:this.tableY})),t.title&&(x.title=new bU(t.title,this),this.scenegraph.tableGroup.setAttributes({x:this.tableX,y:this.tableY})),x.tooltip=Object.assign({renderMode:"html",isShowOverflowTextTooltip:!1,confine:!0},t.tooltip),"html"!==x.tooltip.renderMode||x.tooltipHandler||(x.tooltipHandler=new XV(this,x.tooltip.confine)),x.menu=Object.assign({renderMode:"html"},t.menu),"html"!==x.menu.renderMode||x.menuHandler||(x.menuHandler=new sU(this)),this.headerStyleCache=new Map,this.bodyStyleCache=new Map,this.clearColWidthCache(),this.clearRowHeightCache()}renderWithRecreateCells(){this.refreshHeader(),this.scenegraph.clearCells(),this.headerStyleCache=new Map,this.bodyStyleCache=new Map,this.scenegraph.createSceneGraph(),this.render()}getFrozenRowsHeight(){return this.getRowsHeight(0,this.frozenRowCount-1)}getFrozenColsWidth(){return this.getColsWidth(0,this.frozenColCount-1)}getBottomFrozenRowsHeight(){if(this.bottomFrozenRowCount>0){return this.getRowsHeight(this.rowCount-this.bottomFrozenRowCount,this.rowCount-1)}return 0}getRightFrozenColsWidth(){if(this.rightFrozenColCount>0){return this.getColsWidth(this.colCount-this.rightFrozenColCount,this.colCount-1)}return 0}getDrawRange(){const t=Math.min(this.tableNoFrameWidth,this.getAllColsWidth()),e=Math.min(this.tableNoFrameHeight,this.getAllRowsHeight());return new gf(this.tableX,this.tableY,t,e)}_getMouseAbstractPoint(t,e=!0){const i=this;let n;if(!t)return{inTable:!1,x:void 0,y:void 0};n=wU(t)?t.changedTouches[0]:t;const r=n.clientX||n.pageX+window.scrollX,o=n.clientY||n.pageY+window.scrollY,s=i.internalProps.canvas.getBoundingClientRect();let a=!0;s.right<=r&&(a=!1),s.bottom<=o&&(a=!1);const l=s.width,h=l/(this.canvas.offsetWidth||l),c=s.height,u=c/(this.canvas.offsetHeight||c);return{x:(r-s.left)/h+(e?i.scrollLeft:0)-i.tableX,y:(o-s.top)/u+(e?i.scrollTop:0)-i.tableY,inTable:a}}getTheme(){return this.internalProps.theme}getTargetColAt(t){if(0===t)return{left:0,col:0,right:0,width:0};const e=(e,i)=>{let n=i-this.getColWidth(e);const{colCount:r}=this.internalProps;for(let i=e;i<r;i++){const e=this.getColWidth(i),r=n+e;if(Math.round(n)<=Math.round(t)&&Math.round(t)<Math.round(r))return{left:n,col:i,right:r,width:e};n=r}return null},i=this.computeTargetColByX(t),n=this.getColsWidth(0,i);return t>=n?e(i,n):((e,i)=>{let n=i;for(let i=e;i>=0;i--){const e=this.getColWidth(i),r=n-e;if(Math.round(r)<=Math.round(t)&&Math.round(t)<Math.round(n))return{left:r,col:i,right:n,width:e};n=r}return null})(i,n)}getTargetRowAt(t){if(0===t)return{top:0,row:0,bottom:0,height:0};const e=(e,i)=>{let n=i-this.getRowHeight(e);const{rowCount:r}=this.internalProps;for(let i=e;i<r;i++){const e=this.getRowHeight(i),r=n+e;if(Math.round(n)<=Math.round(t)&&Math.round(t)<Math.round(r))return{top:n,row:i,bottom:r,height:e};n=r}return null},i=this.computeTargetRowByY(t),n=this.getRowsHeight(0,i);return t>=n?e(i,n):((e,i)=>{let n=i;for(let i=e;i>=0;i--){const e=this.getRowHeight(i),r=n-e;if(Math.round(r)<=Math.round(t)&&Math.round(t)<Math.round(n))return{top:r,row:i,bottom:n,height:e};n=r}return null})(i,n)}computeTargetRowByY(t){if(this._rowRangeHeightsMap.get("$0$"+(this.rowCount-1))){let e=0,i=this.rowCount-1;for(;i-e>1;){const n=Math.floor((e+i)/2);if(t<this._rowRangeHeightsMap.get(`$0$${n}`))i=n;else{if(!(t>this._rowRangeHeightsMap.get(`$0$${n}`)))return n;e=n}}return i}return Math.min(Math.ceil(t/this.internalProps.defaultRowHeight),this.rowCount-1)}computeTargetColByX(t){if(this._colRangeWidthsMap.get("$0$"+(this.colCount-1))){let e=0,i=this.colCount-1;for(;i-e>1;){const n=Math.floor((e+i)/2);if(t<this._colRangeWidthsMap.get(`$0$${n}`))i=n;else{if(!(t>this._colRangeWidthsMap.get(`$0$${n}`)))return n;e=n}}return i}return Math.min(Math.ceil(t/this.internalProps.defaultColWidth),this.colCount-1)}clearSelected(){this.stateManeger.updateSelectPos(-1,-1)}selectCell(t,e){this.stateManeger.updateSelectPos(t,e),this.stateManeger.endSelectCells()}get allowFrozenColCount(){return this.internalProps.allowFrozenColCount}get rowHeaderLevelCount(){return this.internalProps.layoutMap.rowHeaderLevelCount}get columnHeaderLevelCount(){return this.internalProps.layoutMap.columnHeaderLevelCount}get records(){return this.internalProps.records}get dataSource(){return this.internalProps.dataSource}set dataSource(t){this.scenegraph.clearCells(),uj(this,t),this.refreshRowColCount(),this.scenegraph.createSceneGraph(),this.render()}get autoWrapText(){return this.internalProps.autoWrapText}set autoWrapText(t){this.internalProps.autoWrapText=t,this.options.autoWrapText=t}updateAutoWrapText(t){this.internalProps.autoWrapText!==t&&(this.internalProps.autoWrapText=t,this.options.autoWrapText=t,this.scenegraph.clearCells(),this.headerStyleCache=new Map,this.bodyStyleCache=new Map,this.scenegraph.createSceneGraph(),this.render())}get theme(){return this.internalProps.theme}set theme(t){this.internalProps.theme=Ff.of(t??Ff.DEFAULT),this.options.theme=t}updateTheme(t){this.internalProps.theme=Ff.of(t??Ff.DEFAULT),this.options.theme=t,this.scenegraph.clearCells(),this.headerStyleCache=new Map,this.bodyStyleCache=new Map,this.scenegraph.createSceneGraph(),this.render()}getBodyField(t,e){return this.internalProps.layoutMap.getBody(t,e).field}getBodyColumnDefine(t,e){const i=this.internalProps.layoutMap.getBody(t,e);return i?.define}getBodyColumnType(t,e){return this.internalProps.layoutMap.getBody(t,e).cellType}getHeaderField(t,e){return this.internalProps.layoutMap.getHeaderField(t,e)}getHeaderFieldKey(t,e){return this.internalProps.layoutMap.getHeaderFieldKey(t,e)}getHeaderDefine(t,e){const i=this.internalProps.layoutMap.getHeader(t,e);return i?.define}getCellLocation(t,e){return this.internalProps.layoutMap.getCellLocation(t,e)}getCellHeaderPaths(t,e){return this.internalProps.layoutMap.getCellHeaderPaths(t,e)}getHeadersDefine(t,e){const i=[];for(;;){const n=this.getHeaderDefine(t,e);if(!n||!n.field&&!n.columns)break;i.push(n),e++}return i}_getHeaderLayoutMap(t,e){return this.internalProps.layoutMap.getHeader(t,e)}_getBodyLayoutMap(t,e){return this.internalProps.layoutMap.getBody(t,e)}getContext(){return this.internalProps.context}getRecordByRowCol(t,e){if(!this.internalProps.layoutMap.isHeader(t,e))return this.internalProps.dataSource?.get(this.getRecordIndexByRow(t,e))}getRecordStartRowByRecordIndex(t){return this.internalProps.layoutMap.getRecordStartRowByRecordIndex(t)}_getHeaderCellBySortState(t){const{layoutMap:e}=this.internalProps;let i;if(i=t.fieldKey?e.headerObjects.find((e=>e&&e.fieldKey===t.fieldKey)):e.headerObjects.find((e=>e&&e.field===t.field)),i){return e.getHeaderCellAdress(i.id)}}getCellRange(t,e){return this.internalProps.layoutMap.getCellRange(t,e)}isCellRangeEqual(t,e,i,n){return this.internalProps.layoutMap.isCellRangeEqual(t,e,i,n)}_getLayoutCellId(t,e){return this.internalProps.layoutMap.getCellId(t,e)}getHeaderDescription(t,e){const i=this._getHeaderLayoutMap(t,e),n=i?.define,r=n?.description??i?.description;if("function"==typeof r){return r({col:t,row:e,value:this.getCellValue(t,e),dataValue:this.getCellOriginValue(t,e)})}return r}setRecords(t,e){const i="undefined"!=typeof window?window.performance.now():0;if(this.scenegraph.clearCells(),void 0!==e&&(this.internalProps.sortState=e,this.stateManeger.setSortState(this.sortState)),t){if(cj(this,t),this.sortState){let t,e,i;if(Array.isArray(this.sortState)?0!==this.sortState.length&&({order:t,field:e,fieldKey:i}=this.sortState?.[0]):({order:t,field:e,fieldKey:i}=this.sortState),t&&e&&"normal"!==t){const n=this._getSortFuncFromHeaderOption(void 0,e,i);let r;r=i?this.internalProps.layoutMap.headerObjects.find((t=>t&&t.fieldKey===i)):this.internalProps.layoutMap.headerObjects.find((t=>t&&t.field===e)),r?.define?.sort&&this.dataSource.sort(r.field,t,n??Cu)}}this.refreshRowColCount()}else cj(this,t);this.scenegraph.createSceneGraph(),this.render(),console.log("setRecords cost time:",("undefined"!=typeof window?window.performance.now():0)-i)}setRecord(t,e,i){const n=this.getRecordIndexByRow(e,i);this.dataSource.setRecord(t,n)}setDropDownMenuHighlight(t){this.stateManeger.setDropDownMenuHighlight(t)}_dropDownMenuIsHighlight(t,e,i){return this.stateManeger.dropDownMenuIsHighlight(t,e,i)}isHeader(t,e){return this.internalProps.layoutMap&&this.internalProps.layoutMap.isHeader(t,e)}isColumnHeader(t,e){return this.internalProps.layoutMap?.isColumnHeader(t,e)}isRowHeader(t,e){return this.internalProps.layoutMap?.isRowHeader(t,e)}isCornerHeader(t,e){return this.internalProps.layoutMap?.isCornerHeader(t,e)}isRightFrozenColumn(t,e){return this.internalProps.layoutMap?.isRightFrozenColumn(t,e)}isBottomFrozenRow(t,e){return this.internalProps.layoutMap?.isBottomFrozenRow(t,e)}getCellInfo(t,e){const i=this.isHeader(t,e)?this.getHeaderDefine(t,e):this.getBodyColumnDefine(t,e);return{col:t,row:e,field:this.getHeaderField(t,e),cellHeaderPaths:this.internalProps.layoutMap.getCellHeaderPaths(t,e),title:i.title,cellType:i.cellType?"string"==typeof i.cellType?i.cellType:"progressbar":"text",originData:this.getCellOriginRecord(t,e),cellRange:this.getCellRangeRelativeRect({col:t,row:e}),value:this.getCellValue(t,e),dataValue:this.getCellOriginValue(t,e),cellLocation:this.getCellLocation(t,e),scaleRatio:this.canvas.getBoundingClientRect().width/this.canvas.offsetWidth}}_hasField(t,e,i){if(null==t)return!1;const n=this;if(n.internalProps.layoutMap.isHeader(e,i))return!1;const r=n.getRecordIndexByRow(e,i);return n.internalProps.dataSource.hasField(r,t)}_getCellStyle(t,e){const{layoutMap:i}=this.internalProps;if(i.isHeader(t,e)){let n=this.headerStyleCache.get(`${t}-${e}`);if(n)return n;const r=i.getHeader(t,e);if(!r||r.isEmpty)return xU;const o=this.internalProps.headerHelper.getStyleClass(r.headerType);if(i.isBottomFrozenRow(t,e)&&this.theme.bottomFrozenStyle)n=Du({},this.theme.bottomFrozenStyle,{col:t,row:e,table:this,value:this.getCellValue(t,e),dataValue:this.getCellOriginValue(t,e),cellHeaderPaths:this.getCellHeaderPaths(t,e)},o,this.options.autoWrapText);else if(i.isRightFrozenColumn(t,e)&&this.theme.rightFrozenStyle)n=Du({},this.theme.rightFrozenStyle,{col:t,row:e,table:this,value:this.getCellValue(t,e),dataValue:this.getCellOriginValue(t,e),cellHeaderPaths:this.getCellHeaderPaths(t,e)},o,this.options.autoWrapText);else{const{style:s}=r;n=Du(s,i.isColumnHeader(t,e)||i.isBottomFrozenRow(t,e)?this.theme.headerStyle:i.isRowHeader(t,e)||i.isRightFrozenColumn(t,e)?this.theme.rowHeaderStyle:this.theme.cornerHeaderStyle,{col:t,row:e,table:this,value:this.getCellValue(t,e),dataValue:this.getCellOriginValue(t,e),cellHeaderPaths:this.getCellHeaderPaths(t,e)},o,this.options.autoWrapText)}return this.headerStyleCache.set(`${t}-${e}`,n),n}let n;n=this.isListTable()&&!this.transpose||this.isPivotTable()&&this.internalProps.layoutMap.indicatorsAsCol?t:e;let r=this.bodyStyleCache.get(n);if(r)return r;const o=i.getBody(t,e),s=this.internalProps.bodyHelper.getStyleClass(o.cellType),a=o?.style;return r=Hu(a,this.theme.bodyStyle,{col:t,row:e,table:this,value:this.getCellValue(t,e),dataValue:this.getCellOriginValue(t,e),cellHeaderPaths:this.getCellHeaderPaths(t,e)},s,this.options.autoWrapText),Gu(a)||this.bodyStyleCache.set(n,r),r}clearCellStyleCache(){this.headerStyleCache.clear()}clearRowHeightCache(){this.internalProps._rowHeightsMap.clear(),this._clearRowRangeHeightsMap()}clearColWidthCache(){this.internalProps._colWidthsMap.clear(),this._clearColRangeWidthsMap()}_canResizeColumn(t,e){if(!(t>=0&&e>=0))return!1;if(this.isCellRangeEqual(t,e,t+1,e))return!1;if("none"===this.internalProps.columnResizeMode)return!1;if("header"===this.internalProps.columnResizeMode){if(!this.isHeader(t,e))return!1}else if("body"===this.internalProps.columnResizeMode&&this.isHeader(t,e))return!1;const i=this.colWidthsLimit[t];return!(i&&i.min&&i.max)||i.max!==i.min}_canDragHeaderPosition(t,e){if(this.isHeader(t,e)&&this.stateManeger.isSelected(t,e)){const i=this.stateManeger.select.ranges[0];if(this.isColumnHeader(t,e)){if(i.end.row!==this.rowCount-1)return!1}else{if(!this.isRowHeader(t,e))return!1;if(i.end.col!==this.colCount-1)return!1}const n=this.getHeaderDefine(t,e);if(void 0===n.dragHeader){if("all"===this.internalProps.dragHeaderMode)return!0;if("column"===this.internalProps.dragHeaderMode){if(this.isColumnHeader(t,e))return!0}else if("row"===this.internalProps.dragHeaderMode&&this.isRowHeader(t,e))return!0;return!1}return n.dragHeader}return!1}getCellIcons(t,e){let i;if(this.isHeader(t,e))i=this.internalProps.headerHelper.getIcons(t,e);else{const n=this.getCellValue(t,e),r=this.getCellOriginValue(t,e),o=this.internalProps.context;i=this.internalProps.bodyHelper.getIcons(t,e,n,r,o)}return i}showDropDownMenu(t,e,i){let n="dropdown-menu";i&&(n=Array.isArray(i.content)?"dropdown-menu":"container"),"html"===this.internalProps.menu.renderMode&&(this.stateManeger.menu.isShow=!0,this.internalProps.menuHandler._bindToCell(t,e,n,i))}showTooltip(t,e,i){"html"===this.internalProps.tooltip.renderMode&&this.internalProps.tooltipHandler._bindToCell(t,e,i)}getCellStyle(t,e){const i=this._getCellStyle(t,e),n=pj(i,this,t,e,Cj).theme,{autoWrapText:r,lineClamp:o,textOverflow:s}=i;return{textAlign:n.text.textAlign,textBaseline:n.text.textBaseline,bgColor:Nu(n.group.fill)?Cj("bgColor",i,t,e,this):n.group.fill,color:Nu(n.text.fill)?Cj("color",i,t,e,this):n.text.fill,fontFamily:n.text.fontFamily,fontSize:n.text.fontSize,fontWeight:n.text.fontWeight,fontVariant:n.text.fontVariant,fontStyle:n.text.fontStyle,lineHeight:n.text.lineHeight,autoWrapText:r??!1,lineClamp:o??"auto",textOverflow:s,borderColor:Nu(n.group.stroke)?Cj("borderColor",i,t,e,this):n.group.stroke,borderLineWidth:n.group.lineWidth,borderLineDash:n.group.lineDash,underline:!!n.text.underline,lineThrough:!!n.text.lineThrough,padding:n._vtable.padding,underlineWidth:n.text.underline,lineThroughLineWidth:n.text.lineThrough}}getAllBodyCells(t,e){const i=this.rowHeaderLevelCount,n=this.columnHeaderLevelCount,r=this.colCount-1,o=this.rowCount-1;return Array(Math.min(e??2e3,o-n+1,this.rowCount)).fill(0).map(((e,o)=>Array(Math.min(t??2e3,r-i+1,this.colCount)).fill(0).map(((t,e)=>this.getCellInfo(e+i,o+n)))))}getAllCells(t,e){const i=0,n=0,r=this.colCount-1,o=this.rowCount-1;return Array(Math.min(e??2e3,o-n+1,this.rowCount)).fill(0).map(((e,o)=>Array(Math.min(t??2e3,r-i+1,this.colCount)).fill(0).map(((t,e)=>this.getCellInfo(e+i,o+n)))))}getAllColumnHeaderCells(){const t=this.rowHeaderLevelCount,e=0,i=this.colCount-1,n=this.columnHeaderLevelCount-1;return Array(n-e+1).fill(0).map(((n,r)=>Array(i-t+1).fill(0).map(((i,n)=>this.getCellInfo(n+t,r+e)))))}getAllRowHeaderCells(){const t=0,e=this.columnHeaderLevelCount,i=this.rowHeaderLevelCount-1,n=this.rowCount-1;return Array(n-e+1).fill(0).map(((n,r)=>Array(i-t+1).fill(0).map(((i,n)=>this.getCellInfo(n+t,r+e)))))}scrollToCell(t){const e=this.getDrawRange();if(bu(t.col)&&t.col>=this.frozenColCount){const i=this.getFrozenColsWidth(),n=this.getColsWidth(0,t.col-1);this.scrollLeft=Math.min(n-i,this.getAllColsWidth()-e.width)}if(bu(t.row)&&t.row>=this.frozenRowCount){const i=this.getFrozenRowsHeight(),n=this.getRowsHeight(0,t.row-1);this.scrollTop=Math.min(n-i,this.getAllRowsHeight()-e.height)}this.render()}getCopyValue(){const t=this.stateManeger.select.ranges;let e=Math.min(t[0].start.col,t[0].end.col),i=Math.max(t[0].start.col,t[0].end.col),n=Math.min(t[0].start.row,t[0].end.row),r=Math.max(t[0].start.row,t[0].end.row);t.forEach((t=>{e=Math.min(e,t.start.col,t.end.col),i=Math.max(i,t.start.col,t.end.col),n=Math.min(n,t.start.row,t.end.row),r=Math.max(r,t.start.row,t.end.row)}));const o=e=>{let i=!1;return t.forEach((t=>{const n=Math.min(t.start.row,t.end.row),r=Math.max(t.start.row,t.end.row);n<=e&&r>=e&&(i=!0)})),i},s=e=>{let i=!1;return t.forEach((t=>{const n=Math.min(t.start.col,t.end.col),r=Math.max(t.start.col,t.end.col);n<=e&&r>=e&&(i=!0)})),i},a=(e,i)=>{let n;return t.forEach((t=>{const r=Math.min(t.start.row,t.end.row),o=Math.max(t.start.row,t.end.row),s=Math.min(t.start.col,t.end.col),a=Math.max(t.start.col,t.end.col);s<=e&&a>=e&&r<=i&&o>=i&&(n=t)})),n},l=(t,e,i)=>{const n=this.getCellRange(t,e);let r=n.start.col,o=n.start.row;if(i){const t=Math.min(i.start.col,i.end.col),e=Math.min(i.start.row,i.end.row);r=Math.max(t,n.start.col),o=Math.max(e,n.start.row)}if(r!==t||o!==e)return"";return this.getCellValue(t,e)};let h="";for(let t=n;t<=r;t++){if(o(t)){for(let n=e;n<=i;n++){if(s(n)){const e=a(n,t);if(e){const r=l(n,t,e);if("undefined"!=typeof Promise&&r instanceof Promise);else{const t=`${r}`;/^\[object .*\]$/.exec(t)||(h+=t)}(n<e.end.col||n<i)&&(h+="\t")}else h+="\t"}}h+="\n"}}return h}getSelectedCellInfos(){const t=this.stateManeger.select.ranges;let e=Math.min(t[0].start.col,t[0].end.col),i=Math.max(t[0].start.col,t[0].end.col),n=Math.min(t[0].start.row,t[0].end.row),r=Math.max(t[0].start.row,t[0].end.row);t.forEach((t=>{e=Math.min(e,t.start.col,t.end.col),i=Math.max(i,t.start.col,t.end.col),n=Math.min(n,t.start.row,t.end.row),r=Math.max(r,t.start.row,t.end.row)}));const o=e=>{let i=!1;return t.forEach((t=>{const n=Math.min(t.start.row,t.end.row),r=Math.max(t.start.row,t.end.row);n<=e&&r>=e&&(i=!0)})),i},s=e=>{let i=!1;return t.forEach((t=>{const n=Math.min(t.start.col,t.end.col),r=Math.max(t.start.col,t.end.col);n<=e&&r>=e&&(i=!0)})),i},a=(e,i)=>{let n;return t.forEach((t=>{const r=Math.min(t.start.row,t.end.row),o=Math.max(t.start.row,t.end.row),s=Math.min(t.start.col,t.end.col),a=Math.max(t.start.col,t.end.col);s<=e&&a>=e&&r<=i&&o>=i&&(n=t)})),n},l=[];for(let t=n;t<=r;t++){if(o(t)){const n=[];for(let r=e;r<=i;r++){if(s(r)){if(a(r,t)){const e=this.getCellInfo(r,t);n.push(e)}}}l.push(n)}}return l}measureText(t,e){return ZV.measureText(t,e)}getCustomRender(t,e){let i;if("body"!==this.getCellLocation(t,e)){const n=this.getHeaderDefine(t,e);i=n?.headerCustomRender}else{const n=this.getBodyColumnDefine(t,e);i=n?.customRender||this.customRender}return i}getCustomLayout(t,e){let i;if("body"!==this.getCellLocation(t,e)){const n=this.getHeaderDefine(t,e);i=n?.headerCustomLayout}else{const n=this.getBodyColumnDefine(t,e);i=n?.customLayout}return i}hasAutoImageColumn(){return this.internalProps.layoutMap.columnObjects.find((t=>!("image"!==t.cellType||!t.define.imageAutoSizing)))}_getActiveChartInstance(){const t=this.scenegraph.getCell(this.stateManeger.hover?.cellPos?.col,this.stateManeger.hover?.cellPos?.row);return"chart"===t?.getChildren()?.[0]?.type?t.getChildren()[0].activeChartInstance:null}cellIsInVisualView(t,e){const i=this.getDrawRange(),n=this.getCellRelativeRect(t,e);return t<this.frozenColCount&&e<this.frozenRowCount||n.top>=i.top&&n.bottom<=i.bottom&&n.left>=i.left&&n.right<=i.right}exportImg(){return this.scenegraph.stage.toCanvas().toDataURL()}exportCellImg(t,e){this.cellIsInVisualView(t,e)||this.scrollToCell({col:t,row:e});const i=this.getCellRelativeRect(t,e);return this.scenegraph.stage.toCanvas(!1,(new ip).set(i.left+this.tableX+1,i.top+this.tableY+1,i.right+this.tableX,i.bottom+this.tableY)).toDataURL()}}var SU=Object.freeze({__proto__:null,BaseTable:_U});function AU(t,e,i){const n=t[e];return t[e]=i,n}function TU(t){for(const e in t)delete t[e]}function BU(){TU(Cf),TU(fj),TU($N)}var MU=Object.freeze({__proto__:null,chartModule:function(t,e){return null!=e?AU($N,t,e):$N[t]},clearAll:BU,icon:function(t,e){return null!=e?AU(fj,t,e):fj[t]},theme:function(t,e){return null!=e?AU(Cf,t,e):Cf[t]}});var RU=Object.freeze({__proto__:null,dateFormat:function(t,e,i,n,r){null==i&&(i=!1),null==n&&(n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]),null==r&&(r=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]);const o=i?"UTC":"",s=function(t){return`0${t}`.substring(0,2)};return function(i){const a=new Date(Date.parse(i[t]));return e.replace(/%(.)/g,(function(t,e){switch(e){case"y":return a[`get${o}FullYear`]();case"m":return s(a[`get${o}Month`]()+1);case"n":return n[a[`get${o}Month`]()];case"d":return s(a[`get${o}Date`]());case"w":return r[a[`get${o}Day`]()];case"x":return a[`get${o}Day`]();case"H":return s(a[`get${o}Hours`]());case"M":return s(a[`get${o}Minutes`]());case"S":return s(a[`get${o}Seconds`]());default:return`%${e}`}}))}},numberFormat:function(t){return t=Object.assign({},{digitsAfterDecimal:2,scaler:1,thousandsSep:",",decimalSep:".",prefix:"",suffix:""},t),function(e){if(isNaN(e)||!isFinite(e))return"";const i=function(t,e,i){const n=(t+="").split(".");let r=n[0];const o=n.length>1?i+n[1]:"";return r=function(t,e){return t.replace(/\d+/,(function(t){return t.replace(/(\d)(?=(\d{3})+$)/g,(function(t){return`${t}${e}`}))}))}(r,e),r+o}((t.scaler*e).toFixed(t.digitsAfterDecimal),t.thousandsSep,t.decimalSep);return`${t.prefix}${i}${t.suffix}`}}});const PU="NO_AXISID_FRO_VTABLE";function EU(t,e,i){const n=i.getCellHeaderPaths(t,e);let r;if(i.indicatorsAsCol){const t=n.colHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;r=i.columnObjects.find((e=>e.indicatorKey===t))}else{const t=n.rowHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;r=i.columnObjects.find((e=>e.indicatorKey===t))}const o=r?.chartSpec;return o}function HU(t,e,i){const n=i.getRawChartSpec(t,e);if(n?.series){const t={};return n.data?.id&&(t[n.data.id]=void 0),n?.series.forEach((e=>{if(!e.data?.fromDataId)if(e.data?.transforms)t[e.data?.id??n.data?.id??"data"]=void 0;else{const i="horizontal"===e.direction?e.xField:e.yField;t[e.data?.id??n.data?.id??"data"]=e.data?.id?i:void 0}})),t}return n.data.id}let LU=0;class kU{_headerObjects;_headerObjectMap;_headerCellIds;_columns;bodyRowCount=1;hierarchyIndent;_transpose=!1;_showHeader=!0;_recordsCount=0;_table;_cellRangeMap;constructor(t,e,i,n){this._cellRangeMap=new Map,this._showHeader=i,this._table=t,this._columns=[],this._headerCellIds=[],this.hierarchyIndent=n??20,this._headerObjects=this._addHeaders(0,e,[]),this._headerObjectMap=this._headerObjects.reduce(((t,e)=>(t[e.id]=e,t)),{})}get transpose(){return this._transpose}set transpose(t){this._transpose=t}get showHeader(){return this._showHeader}set showHeader(t){this._showHeader=t}isHeader(t,e){return!!(this.transpose&&t<this.headerLevelCount)||!this.transpose&&e<this.headerLevelCount}getCellLocation(t,e){return this.isHeader(t,e)?this.transpose?"rowHeader":"columnHeader":"body"}isColumnHeader(t,e){return!this.transpose&&e<this.headerLevelCount}isRightFrozenColumn(t,e){return t>=this.colCount-this.rightFrozenColCount&&e>=this.columnHeaderLevelCount&&e<this.rowCount-this.bottomFrozenRowCount}isBottomFrozenRow(t,e){return t>=this.rowHeaderLevelCount&&e>=this.rowCount-this.bottomFrozenRowCount&&t<this.colCount-this.rightFrozenColCount}isLeftBottomCorner(t,e){return t<this.rowHeaderLevelCount&&e>=this.rowCount-this.bottomFrozenRowCount}isRightTopCorner(t,e){return t>=this.colCount-this.rightFrozenColCount&&e<this.columnHeaderLevelCount}isRightBottomCorner(t,e){return t>=this.colCount-this.rightFrozenColCount&&e>=this.rowCount-this.bottomFrozenRowCount}isCornerHeader(t,e){return!1}isRowHeader(t,e){return!!(this.transpose&&t<this.headerLevelCount)}getColumnHeaderRange(){return this.transpose?{start:{col:0,row:0},end:{col:this._headerCellIds.length-1,row:(this.rowCount??0)-1}}:{start:{col:0,row:0},end:{col:(this.colCount??0)-1,row:this._headerCellIds.length-1}}}getRowHeaderRange(){return this.transpose?{start:{col:0,row:0},end:{col:this._headerCellIds.length-1,row:(this.rowCount??0)-1}}:{start:{col:0,row:0},end:{col:(this.colCount??0)-1,row:this._headerCellIds.length-1}}}getCornerHeaderRange(){}getBodyRange(){return this.transpose?{start:{col:this.headerLevelCount,row:0},end:{col:(this.colCount??0)-1,row:(this.rowCount??0)-1}}:{start:{col:0,row:this.headerLevelCount},end:{col:(this.colCount??0)-1,row:(this.rowCount??0)-1}}}get headerLevelCount(){return this.showHeader?this._headerCellIds.length:0}get columnHeaderLevelCount(){return this.transpose?0:this.headerLevelCount}get rowHeaderLevelCount(){return this.transpose?this.headerLevelCount:0}get bottomFrozenRowCount(){return 0}get rightFrozenColCount(){return 0}get colCount(){return this.transpose?this.headerLevelCount+this.recordsCount:this._columns.length}get rowCount(){return this.transpose?this._columns.length:this.headerLevelCount+this.recordsCount}get recordsCount(){return this._recordsCount}set recordsCount(t){this._recordsCount=t}get headerObjects(){return this._headerObjects}get columnObjects(){return this._columns}get columnWidths(){return this._columns}getColumnWidthDefined(t){if(this.transpose){let e,i,n=0;if(t>=this.rowHeaderLevelCount){let t;return this.columnObjects.forEach(((r,o)=>{"number"==typeof r.width?n=Math.max(r.width,n):"auto"===r.width&&(t=!0),"number"==typeof r.minWidth&&(i=Math.max(r.minWidth,i)),"number"==typeof r.maxWidth&&(e=Math.max(r.maxWidth,e))})),n=n>0?n:t?"auto":void 0,{width:n,minWidth:i,maxWidth:e}}if(this.isRowHeader(t,0)){const e=Array.isArray(this._table.defaultHeaderColWidth)?this._table.defaultHeaderColWidth[t]??this._table.defaultColWidth:this._table.defaultHeaderColWidth;return"auto"===e?{width:"auto"}:{width:e}}}return this._columns[t]}getCellId(t,e){return this.transpose?this.headerLevelCount<=t?this._columns[e]?.id:this._headerCellIds[t]?.[e]:this.headerLevelCount<=e?this._columns[t]?.id:this._headerCellIds[e]?.[t]}getHeader(t,e){const i=this.getCellId(t,e);return this._headerObjectMap[i]}getHeaderFieldKey(t,e){const i=this.getCellId(t,e);return this._headerObjectMap[i]?.fieldKey||(this.transpose?this._columns[e]?.fieldKey:this._columns[t]?.fieldKey)}getHeaderField(t,e){const i=this.getCellId(t,e);return this._headerObjectMap[i]?.field||(this.transpose?this._columns[e]&&this._columns[e].field:this._columns[t]&&this._columns[t].field)}getHeaderCellAdress(t){for(let e=0;e<this._headerCellIds.length;e++){const i=this._headerCellIds[e];for(let n=0;n<i.length;n++)if(i[n]===t)return this.transpose?{col:e,row:n}:{col:n,row:e}}}getHeaderCellAddressByField(t){const e=this.headerObjects.find((e=>e&&e.field===t));return this.getHeaderCellAdress(e.id)}getBody(t,e){return this.transpose?this._columns[e]:this._columns[t]}getBodyLayoutRangeById(t){if(this.transpose){for(let e=0;e<(this.rowCount??0);e++)if(t===this._columns[e].id)return{start:{col:0,row:e},end:{col:0,row:e}}}else for(let e=0;e<(this.colCount??0);e++)if(t===this._columns[e].id)return{start:{col:e,row:0},end:{col:e,row:0}};throw new Error(`can not found body layout @id=${t}`)}getBodyCellValue(t,e){if(this.isHeader(t,e))return null;const{field:i,fieldFormat:n}=this.getBody(t,e);return this._table.getFieldData(n||i,t,e)}getCellRange(t,e){if(-1===t||-1===e)return{start:{col:t,row:e},end:{col:t,row:e}};if(this._cellRangeMap.has(`$${t}$${e}`))return this._cellRangeMap.get(`$${t}$${e}`);let i={start:{col:t,row:e},end:{col:t,row:e}};if(this.transpose)i=this.getCellRangeTranspose(t,e);else if(this.headerLevelCount<=e){if(this.headerLevelCount<=e&&this.columnObjects[t]?.define?.mergeCell){const n=this.getBodyCellValue(t,e);for(let r=e-1;r>=this.headerLevelCount&&n===this.getBodyCellValue(t,r);r--)i.start.row=r;for(let r=e+1;r<this.rowCount&&n===this.getBodyCellValue(t,r);r++)i.end.row=r}}else{const n=this.getCellId(t,e);for(let r=t-1;r>=0&&n===this.getCellId(r,e);r--)i.start.col=r;for(let r=t+1;r<(this.colCount??0)&&n===this.getCellId(r,e);r++)i.end.col=r;for(let r=e-1;r>=0&&n===this.getCellId(t,r);r--)i.start.row=r;for(let r=e+1;r<this.headerLevelCount&&n===this.getCellId(t,r);r++)i.end.row=r}return this._cellRangeMap.set(`$${t}$${e}`,i),i}getCellRangeTranspose(t,e){const i={start:{col:t,row:e},end:{col:t,row:e}};if(this.headerLevelCount<=t||-1===t&&-1===e){if(this.headerLevelCount<=t&&this.columnObjects[e]?.define?.mergeCell){const n=this.getBodyCellValue(t,e);for(let r=t-1;r>=this.headerLevelCount&&n===this.getBodyCellValue(r,e);r--)i.start.col=r;for(let r=t+1;r<(this.colCount??0)&&n===this.getBodyCellValue(r,e);r++)i.end.col=r}return i}const n=this.getCellId(t,e);for(let r=e-1;r>=0&&n===this.getCellId(t,r);r--)i.start.row=r;for(let r=e+1;r<(this.rowCount??0)&&n===this.getCellId(t,r);r++)i.end.row=r;for(let r=t-1;r>=0&&n===this.getCellId(r,e);r--)i.start.col=r;for(let r=t+1;r<this.headerLevelCount&&n===this.getCellId(r,e);r++)i.end.col=r;return i}isCellRangeEqual(t,e,i,n){const r=this.getCellRange(t,e),o=this.getCellRange(i,n);return r.start.col===o.start.col&&r.end.col===o.end.col&&r.start.row===o.start.row&&r.end.row===o.end.row}getRecordIndexByRow(t,e){return this.transpose?t<this.headerLevelCount?-1:t-this.headerLevelCount:e<this.headerLevelCount?-1:e-this.headerLevelCount}getRecordStartRowByRecordIndex(t){return this.headerLevelCount+t}_addHeaders(t,e,i,n){const r=[],o=this._newRow(t,n);return e.forEach((e=>{const s=this._columns.length,a=LU++,l={id:a,title:e.title??e.caption,headerIcon:e.headerIcon,field:e.field,fieldKey:e?.fieldKey,fieldFormat:e.fieldFormat,style:e.headerStyle,headerType:e.headerType??"text",dropDownMenu:e.dropDownMenu,define:e,columnWidthComputeMode:e.columnWidthComputeMode};r[a]=l;for(let e=t-1;e>=0;e--)this._headerCellIds[e][s]=i[e];if(o[s]=n?this._headerCellIds[t-1][s]:a,e.columns)this._addHeaders(t+1,e.columns,[...i,a],e.hideColumnsSubHeader).forEach((t=>r.push(t)));else{const i=e;this._columns.push({id:LU++,field:i.field,fieldKey:i.fieldKey,fieldFormat:i.fieldFormat,width:i.width,minWidth:i.minWidth,maxWidth:i.maxWidth,icon:i.icon,cellType:i.cellType??i.columnType??"text",chartModule:"chartModule"in i?i.chartModule:null,chartSpec:"chartSpec"in i?i.chartSpec:null,sparklineSpec:"sparklineSpec"in i?i.sparklineSpec:Af,style:i.style,define:i,columnWidthComputeMode:i.columnWidthComputeMode,disableColumnResize:i?.disableColumnResize});for(let e=t+1;e<this._headerCellIds.length;e++)this._headerCellIds[e][s]=a}})),r}_newRow(t,e=!1){if(this._headerCellIds[t]){const e=this._headerCellIds[t-1];if(e.length>this._headerCellIds[t].length)for(let i=this._headerCellIds[t].length;i<e.length;i++)this._headerCellIds[t][i]=e[i];return this._headerCellIds[t]}if(e)return[];const i=this._headerCellIds[t]=[];if(!this._columns.length)return i;const n=this._headerCellIds[t-1];for(let t=0;t<n.length;t++)i[t]=n[t];return i}getCellHeaderPaths(t,e){let i=[],n=[];return this.transpose?n=[{field:this._columns[e].field}]:i=[{field:this._columns[t].field}],{colHeaderPaths:i,rowHeaderPaths:n}}getParentCellId(t,e){if(0!==e)return this.isColumnHeader(t,e)?this.getCellId(t,e-1):this.isRowHeader(t,e)?this.getCellId(t-1,e):void 0}canMoveHeaderPosition(t,e){const i=this.getCellRange(t.col,t.row);if(this.isColumnHeader(t.col,t.row)){return this.getParentCellId(t.col,i.start.row)===this.getParentCellId(e.col,i.start.row)}if(this.isRowHeader(t.col,t.row)){return this.getParentCellId(i.start.col,t.row)===this.getParentCellId(i.start.col,e.row)}return!1}moveHeaderPosition(t,e){if(this.canMoveHeaderPosition(t,e)){const i=this.getCellRange(t.col,t.row);if(this.isColumnHeader(t.col,t.row)){const n=i.end.col-i.start.col+1;let r;const o=this.getCellRange(e.col,i.start.row);if(r=e.col>=t.col?o.end.col-n+1:o.start.col,r===i.start.col)return null;for(let t=0;t<this._headerCellIds.length;t++){const e=this._headerCellIds[t].splice(i.start.col,n);e.unshift(r,0),Array.prototype.splice.apply(this._headerCellIds[t],e)}const s=this._columns.splice(i.start.col,n);return s.unshift(r,0),Array.prototype.splice.apply(this._columns,s),this._cellRangeMap=new Map,{sourceIndex:i.start.col,targetIndex:r,moveSize:n,moveType:"column"}}if(this.isRowHeader(t.col,t.row)){const n=i.end.row-i.start.row+1;let r;const o=this.getCellRange(i.start.col,e.row);if(r=e.row>=t.row?o.end.row-n+1:o.start.row,r===i.start.row)return null;for(let t=0;t<this._headerCellIds.length;t++){const e=this._headerCellIds[t].splice(i.start.row,n);e.unshift(r,0),Array.prototype.splice.apply(this._headerCellIds[t],e)}const s=this._columns.splice(i.start.row,n);return s.unshift(r,0),Array.prototype.splice.apply(this._columns,s),this._cellRangeMap=new Map,{sourceIndex:i.start.row,targetIndex:r,moveSize:n,moveType:"row"}}}return null}toggleHierarchyState(t){const e=t.add.map((t=>({col:0,row:this._table.frozenRowCount+t}))),i=t.remove.map((t=>({col:0,row:this._table.frozenRowCount+t})));return{addCellPositions:e,removeCellPositions:i}}setChartInstance(t,e,i){(this.transpose?this._columns[e]:this._columns[t]).chartInstance=i}getChartInstance(t,e){return(this.transpose?this._columns[e]:this._columns[t]).chartInstance}getAxisConfigInPivotChart(t,e){}isEmpty(t,e){return!1}getChartAxes(t,e){return[]}getRawChartSpec(t,e){const i=this.getBody(t,e);return i?.chartSpec}getChartDataId(t,e){return HU(t,e,this)}release(){const t=this._table._getActiveChartInstance();t?.release(),this.columnObjects.forEach((t=>{t.chartInstance?.release()}))}}class IU{sizeIncludeParent=!1;rowExpandLevel;hierarchyType;tree={id:0,dimensionKey:"",value:"",children:[],level:-1,startIndex:0,size:0,startInTotal:0,hierarchyState:void 0};totalLevel=0;dimensionKeys=new ff;constructor(t,e="grid",i=void 0){this.sizeIncludeParent=null!=i,this.rowExpandLevel=i,this.hierarchyType=e,this.reset(t)}reset(t,e=!1){this.dimensionKeys=new ff,this.tree.children=t,this.setTreeNode(this.tree,0,this.tree),this.totalLevel=this.dimensionKeys.count()}setTreeNode(t,e,i){t.startIndex=e,t.startInTotal=(i.startInTotal??0)+t.startIndex,(t.dimensionKey??t.indicatorKey)&&(!this.dimensionKeys.contain(t.indicatorKey?Sf:t.dimensionKey)&&this.dimensionKeys.put(t.level,t.indicatorKey?Sf:t.dimensionKey),t.id||(t.id=++OU));let n=t.dimensionKey&&this.sizeIncludeParent?1:0;return"grid"===this.hierarchyType?t.children?t.children.forEach((e=>{e.level=(t.level??0)+1,n+=this.setTreeNode(e,n,t)})):n=1:t.hierarchyState===Xc.expand&&t.children?t.children.forEach((e=>{e.level=(t.level??0)+1,n+=this.setTreeNode(e,n,t)})):t.hierarchyState===Xc.collapse&&t.children?t.children.forEach((e=>{e.level=(t.level??0)+1,this.setTreeNode(e,n,t)})):!t.hierarchyState&&t.level+1<this.rowExpandLevel&&t.children?(t.hierarchyState=Xc.expand,t.children.forEach((e=>{e.level=(t.level??0)+1,n+=this.setTreeNode(e,n,t)}))):t.children?(t.hierarchyState=Xc.collapse,t.children.forEach((e=>{e.level=(t.level??0)+1,this.setTreeNode(e,n,t)}))):(t.hierarchyState=Xc.none,n=1),t.size=n,n}getTreePath(t,e=30){const i=[];return this.searchPath(t,this.tree,i,e),i.shift(),i}searchPath(t,e,i,n){if(!e)return!1;if(t<e.startIndex||t>=e.startIndex+e.size)return!1;if(i.push(e),!e.children||0===e.children.length)return!0;if(e.level>=n)return!0;const r=t-e.startIndex;return e.children.some((t=>this.searchPath(r,t,i,n))),!0}movePosition(t,e,i){let n,r,o;const s=(a,l)=>{if((void 0===r||void 0===o)&&(a.level===t&&(a.startInTotal===e&&(r=l),a.startInTotal<=i&&i<=a.startInTotal+a.size-1&&(o=l)),a.children&&a.level<t)){n=a;for(let t=0;t<a.children.length;t++)(e>=a.children[t].startInTotal&&e<=a.children[t].startInTotal+a.children[t].size||i>=a.children[t].startInTotal&&i<=a.children[t].startInTotal+a.children[t].size)&&s(a.children[t],t)}};s(this.tree,0);const a=n.children.splice(r,1);a.unshift(o,0),Array.prototype.splice.apply(n.children,a)}}let OU=0,DU=0;class FU{_showHeader=!0;rowDimensionTree;columnDimensionTree;rowTree;columnTree;cornerHeaderObjs;columnHeaderObjs=[];rowHeaderObjs=[];_cornerHeaderCellIds=[];_columnHeaderCellIds=[];_rowHeaderCellIds=[];_columnWidths=[];rowsDefine;columnsDefine;indicatorsDefine;columnPaths=[];_headerObjects=[];_headerObjectMap={};_indicators=[];indicatorTitle;indicatorsAsCol=!0;hideIndicatorName=!1;_showRowHeader=!0;_showColumnHeader=!0;_rowHeaderTitle;_columnHeaderTitle;cornerSetting;_indicatorShowType="column";rowHierarchyType;rowExpandLevel;rowHierarchyIndent;rowDimensionKeys=[];colDimensionKeys=[];indicatorKeys=[];indicatorDimensionKey=Sf;_cellRangeMap;_CellHeaderPathMap;_table;constructor(t){if(this._table=t,this._cellRangeMap=new Map,this._CellHeaderPathMap=new Map,this.rowTree=t.options.rowTree,this.columnTree=t.options.columnTree,this.rowsDefine=t.options.rows??[],this.columnsDefine=t.options.columns??[],this.indicatorsDefine=t.options.indicators??[],this.indicatorTitle=t.options.indicatorTitle,this.hideIndicatorName=t.options.hideIndicatorName??!1,this.showRowHeader=t.options.showRowHeader??!0,this.showColumnHeader=t.options.showColumnHeader??!0,this.rowHeaderTitle=t.options.rowHeaderTitle,this.columnHeaderTitle=t.options.columnHeaderTitle,this.rowHierarchyType=t.options.rowHierarchyType??"grid",this.rowExpandLevel=t.options.rowExpandLevel??1,this.rowHierarchyIndent=t.options.rowHierarchyIndent??20,this.cornerSetting=t.options.corner??{titleOnDimension:"column"},this.indicatorsDefine?.forEach((t=>{"string"==typeof t?this.indicatorKeys.push(t):this.indicatorKeys.push(t.indicatorKey)})),this.columnDimensionTree=new IU(this.columnTree??[]),this.rowDimensionTree=new IU(this.rowTree??[],this.rowHierarchyType,"tree"===this.rowHierarchyType?this.rowExpandLevel:void 0),this.colDimensionKeys=this.columnDimensionTree.dimensionKeys.valueArr(),this.rowDimensionKeys=this.rowDimensionTree.dimensionKeys.valueArr(),this.cornerHeaderObjs="column"===this.cornerSetting.titleOnDimension?this._addCornerHeaders(this.columnHeaderTitle?[""].concat(this.colDimensionKeys):this.colDimensionKeys):"row"===this.cornerSetting.titleOnDimension?this._addCornerHeaders(this.rowHeaderTitle?[""].concat(this.rowDimensionKeys):this.rowDimensionKeys):this._addCornerHeaders(null),this.columnDimensionTree.tree.children&&(this.columnHeaderObjs=this._addHeaders(this._columnHeaderCellIds,0,this.columnDimensionTree.tree.children,[]),this.columnHeaderTitle)){const t=++OU,e=Array(this.colCount-this.rowHeaderLevelCount).fill(t);this._columnHeaderCellIds.unshift(e);const i={id:t,title:"string"==typeof this.columnHeaderTitle.title?this.columnHeaderTitle.title:this.columnsDefine.reduce(((t,e)=>"string"==typeof e?t:t+(t?`/${e.title}`:`${e.title}`)),""),field:void 0,headerType:this.columnHeaderTitle.headerType??"text",style:this.columnHeaderTitle.headerStyle,define:{id:t}};this.columnHeaderObjs.push(i),this._headerObjects[t]=i}if(DU=0,this.rowDimensionTree.tree.children&&(this.rowHeaderObjs="tree"===this.rowHierarchyType?this._addHeadersForTreeMode(this._rowHeaderCellIds,0,this.rowDimensionTree.tree.children,[],this.rowDimensionTree.totalLevel,!0):this._addHeaders(this._rowHeaderCellIds,0,this.rowDimensionTree.tree.children,[])),this.rowHeaderTitle){const t=++OU,e=Array(this.rowCount-this.columnHeaderLevelCount).fill(t);this._rowHeaderCellIds.unshift(e);const i={id:t,title:"string"==typeof this.rowHeaderTitle.title?this.rowHeaderTitle.title:this.rowsDefine.reduce(((t,e)=>"string"==typeof e?t:t+(t?`/${e.title}`:`${e.title}`)),""),field:void 0,headerType:this.rowHeaderTitle.headerType??"text",style:this.rowHeaderTitle.headerStyle,define:{id:t}};this.rowHeaderObjs.push(i),this._headerObjects[t]=i}DU=0,this.indicatorsAsCol=!bu(this.rowDimensionKeys.find((t=>t===this.indicatorDimensionKey))),this._rowHeaderCellIds=fu(this._rowHeaderCellIds),this._headerObjectMap=this._headerObjects.reduce(((t,e)=>(t[e.id]=e,t)),{}),this.indicatorsAsCol&&!this.hideIndicatorName?this._indicatorShowType="column":this.indicatorsAsCol||this.hideIndicatorName?this._indicatorShowType="none":this._indicatorShowType="row",this.setColumnWidths()}_addHeaders(t,e,i,n){const r=[];return t[e]||function(e){const i=t[e]=[];if(0===DU)return i;const n=t[e-1];for(let t=0;t<n?.length;t++)i[t]=n[t]}(e),i.forEach((i=>{const o=i.id,s=this.rowsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.dimensionKey))??this.columnsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.dimensionKey)),a=this.indicatorsDefine?.find((t=>"string"!=typeof t&&(i.indicatorKey?t.indicatorKey===i.indicatorKey:t.title===i.value))),l={id:o,title:i.value??a.title,field:i.dimensionKey,style:"function"==typeof(a??s)?.headerStyle?(a??s)?.headerStyle:Object.assign({},(a??s)?.headerStyle),headerType:a?.headerType??s?.headerType??"text",headerIcon:a?.headerIcon??s?.headerIcon,define:Object.assign({},i,a??s),fieldFormat:a?.headerFormat??s?.headerFormat,dropDownMenu:a?.dropDownMenu??s?.dropDownMenu,pivotInfo:{value:i.value,dimensionKey:i.dimensionKey,isPivotCorner:!1},width:s?.width,minWidth:s?.minWidth,maxWidth:s?.maxWidth,showSort:a?.showSort??s?.showSort,description:s?.description};a?(a.customRender&&(i.customRender=a.customRender),bu(this._indicators.find((t=>t.indicatorKey===a.indicatorKey)))||this._indicators.push({id:++OU,indicatorKey:a.indicatorKey,field:a.indicatorKey,fieldFormat:a?.format,cellType:a?.cellType??a?.columnType??"text",chartModule:"chartModule"in a?a.chartModule:null,chartSpec:"chartSpec"in a?a.chartSpec:null,sparklineSpec:"sparklineSpec"in a?a.sparklineSpec:null,style:a?.style,icon:a?.icon,define:Object.assign({},i,a,{dragHeader:s?.dragHeader}),width:a?.width,minWidth:a?.minWidth,maxWidth:a?.maxWidth,disableColumnResize:a?.disableColumnResize})):i.indicatorKey&&(bu(this._indicators.find((t=>t.indicatorKey===i.indicatorKey)))||this._indicators.push({id:++OU,indicatorKey:i.indicatorKey,field:i.indicatorKey,cellType:"text",define:Object.assign({},i)})),r[o]=l,this._headerObjects[o]=l,t[e][DU]=o;for(let i=e-1;i>=0;i--)t[i][DU]=n[i];if(i.children)this._addHeaders(t,e+1,i.children??[],[...n,o]).forEach((t=>r.push(t)));else{for(let i=e+1;i<t.length;i++)t[i][DU]=o;DU++}})),r}_addHeadersForTreeMode(t,e,i,n,r,o){const s=[];return t[e]||function(e){const i=t[e]=[];if(0===DU)return i;const n=t[e-1];for(let t=0;t<n?.length;t++)i[t]=n[t]}(e),i.forEach((i=>{const a=i.id,l=this.rowsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.dimensionKey))??this.columnsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.dimensionKey)),h={id:a,title:i.value,field:i.dimensionKey,style:i.level+1===r||"function"==typeof l?.headerStyle?l?.headerStyle:Object.assign({},l?.headerStyle,{textAlign:"left"}),headerType:l?.headerType??"text",headerIcon:l?.headerIcon,define:Object.assign(i,{linkJump:l?.linkJump,linkDetect:l?.linkDetect,templateLink:l?.templateLink,keepAspectRatio:l?.keepAspectRatio??!1,imageAutoSizing:l?.imageAutoSizing,headerCustomRender:l?.headerCustomRender,headerCustomLayout:l?.headerCustomLayout,dragHeader:l?.dragHeader}),fieldFormat:l?.headerFormat,dropDownMenu:l?.dropDownMenu,pivotInfo:{value:i.value,dimensionKey:i.dimensionKey,isPivotCorner:!1},hierarchyLevel:i.level,dimensionTotalLevel:r,hierarchyState:i.level+1===r?void 0:i.hierarchyState,width:l?.width,minWidth:l?.minWidth,maxWidth:l?.maxWidth};s[a]=h,this._headerObjects[a]=h,t[e][DU]=a;for(let i=e-1;i>=0;i--)t[i][DU]=n[i];if(i.hierarchyState===Xc.expand&&i.children)o&&DU++,this._addHeadersForTreeMode(t,e,i.children??[],[...n,a],r,o&&i.hierarchyState===Xc.expand).forEach((t=>s.push(t)));else{o&&DU++;for(let i=e+1;i<t.length;i++)t[i][DU]=a}})),s}_addCornerHeaders(t){const e=[];if(t)t.forEach(((t,i)=>{const n=++OU,r=this.rowsDefine?.find((e=>"string"!=typeof e&&e.dimensionKey===t))??this.columnsDefine?.find((e=>"string"!=typeof e&&e.dimensionKey===t)),o={id:n,title:t===this.indicatorDimensionKey?this.indicatorTitle:r?.title??"",field:"维度名称",style:this.cornerSetting.headerStyle,headerType:this.cornerSetting.headerType??"text",define:{dimensionKey:"维度名称",id:n,value:t},dropDownMenu:r?.cornerDropDownMenu,pivotInfo:{value:r?.title??"",dimensionKey:t,isPivotCorner:!0},description:r?.cornerDescription};if(e[n]=o,this._headerObjects[n]=o,"column"===this.cornerSetting.titleOnDimension){this._cornerHeaderCellIds[i]||(this._cornerHeaderCellIds[i]=[]);for(let t=0;t<this.rowHeaderLevelCount;t++)this._cornerHeaderCellIds[i][t]=n}else if("row"===this.cornerSetting.titleOnDimension)for(let t=0;t<this.columnHeaderLevelCount;t++)this._cornerHeaderCellIds[t]||(this._cornerHeaderCellIds[t]=[]),this._cornerHeaderCellIds[t][i]=n}));else{const t=++OU,i={id:t,title:"",field:"维度名称",style:this.cornerSetting.headerStyle,headerType:this.cornerSetting.headerType??"text",define:{dimensionKey:"维度名称",id:t,value:""}};e[t]=i,this._headerObjects[t]=i;for(let e=0;e<this.columnHeaderLevelCount;e++)for(let i=0;i<this.rowHeaderLevelCount;i++)this._cornerHeaderCellIds[e]||(this._cornerHeaderCellIds[e]=[]),this._cornerHeaderCellIds[e][i]=t}return e}setColumnWidths(){const t=new Array(this.colCount).fill(void 0);if(this.showHeader&&this.showRowHeader&&(this.rowHeaderTitle&&(t[0]={}),this.rowDimensionKeys.forEach(((e,i)=>{const n=this.rowsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===e));n&&(t[i+(this.rowHeaderTitle?1:0)]={width:n.width,minWidth:n.minWidth,maxWidth:n.maxWidth})}))),this.indicatorsAsCol)for(let e=this.rowHeaderLevelCount;e<this.colCount;e++){const i=this.getBody(e,this.columnHeaderLevelCount);t[e]={width:i?.width,minWidth:i?.minWidth,maxWidth:i?.maxWidth}}else{let e,i,n,r=0;this._indicators.forEach(((t,o)=>{"number"==typeof t.width?r=Math.max(t.width,r):"auto"===t.width&&(n=!0),"number"==typeof t.minWidth&&(i=Math.max(t.minWidth,i)),"number"==typeof t.maxWidth&&(e=Math.max(t.maxWidth,e))})),r=r>0?r:n?"auto":void 0,t.fill({width:r,minWidth:i,maxWidth:e},this.rowHeaderLevelCount,this.colCount)}this._columnWidths=t}get columnWidths(){return this._columnWidths}getColumnWidthDefined(t){return this._columnWidths[t]}get showHeader(){return this._showHeader}set showHeader(t){this._showHeader=t}get showColumnHeader(){return this._showColumnHeader}set showColumnHeader(t){this._showColumnHeader=t}get showRowHeader(){return this._showRowHeader}set showRowHeader(t){this._showRowHeader=t}get columnHeaderTitle(){return this._columnHeaderTitle}set columnHeaderTitle(t){this._columnHeaderTitle=t}get rowHeaderTitle(){return this._rowHeaderTitle}set rowHeaderTitle(t){this._rowHeaderTitle=t}getHeaderFieldKey(t,e){}getCellLocation(t,e){return this.isCornerHeader(t,e)?"cornerHeader":this.isColumnHeader(t,e)?"columnHeader":this.isRowHeader(t,e)?"rowHeader":"body"}isHeader(t,e){return t<this.rowHeaderLevelCount||(e<this.columnHeaderLevelCount||(t>=this.colCount-this.rightFrozenColCount||e>=this.rowCount-this.bottomFrozenRowCount))}isCornerHeader(t,e){return t<this.rowHeaderLevelCount&&e<this.columnHeaderLevelCount}isColumnHeader(t,e){return t>=this.rowHeaderLevelCount&&e<this.columnHeaderLevelCount}isRowHeader(t,e){return t<this.rowHeaderLevelCount&&e>=this.columnHeaderLevelCount}isRightFrozenColumn(t,e){return t>=this.colCount-this.rightFrozenColCount&&e>=this.columnHeaderLevelCount&&e<this.rowCount-this.bottomFrozenRowCount}isBottomFrozenRow(t,e){return t>=this.rowHeaderLevelCount&&e>=this.rowCount-this.bottomFrozenRowCount&&t<this.colCount-this.rightFrozenColCount}isLeftBottomCorner(t,e){return t<this.rowHeaderLevelCount&&e>=this.rowCount-this.bottomFrozenRowCount}isRightTopCorner(t,e){return t>=this.colCount-this.rightFrozenColCount&&e<this.columnHeaderLevelCount}isRightBottomCorner(t,e){return t>=this.colCount-this.rightFrozenColCount&&e>=this.rowCount-this.bottomFrozenRowCount}getColumnHeaderRange(){return{start:{col:this.rowHeaderLevelCount,row:0},end:{col:this.colCount-1,row:this.columnHeaderLevelCount-1}}}getRowHeaderRange(){return{start:{col:0,row:this.columnHeaderLevelCount},end:{col:this.rowHeaderLevelCount-1,row:this.rowCount-1}}}getCornerHeaderRange(){return{start:{col:0,row:0},end:{col:this.rowHeaderLevelCount-1,row:this.columnHeaderLevelCount-1}}}getBodyRange(){return{start:{col:this.rowHeaderLevelCount,row:this.columnHeaderLevelCount},end:{col:this.colCount-1,row:this.rowCount-1}}}resetCellIds(){}get headerLevelCount(){return this.columnHeaderLevelCount}get columnHeaderLevelCount(){if(this.showHeader&&this.showColumnHeader){let t=this.indicatorsAsCol&&this.hideIndicatorName&&this.colDimensionKeys[this.colDimensionKeys.length-1]===this.indicatorDimensionKey?this.columnDimensionTree.totalLevel-1:this.columnDimensionTree.totalLevel;return this.columnHeaderTitle&&(t+=1),t}return 0}get rowHeaderLevelCount(){if(this.showHeader&&this.showRowHeader){if("tree"===this.rowHierarchyType)return this.rowHeaderTitle?2:1;let t=this.indicatorsAsCol?this.rowDimensionTree.totalLevel:this.hideIndicatorName&&this.rowDimensionKeys[this.rowDimensionKeys.length-1]===this.indicatorDimensionKey?this.rowDimensionTree.totalLevel-1:this.rowDimensionTree.totalLevel;return this.rowHeaderTitle&&(t+=1),t}return 0}get colCount(){return this.columnDimensionTree.tree.size+this.rowHeaderLevelCount+this.rightFrozenColCount}get rowCount(){return this.rowDimensionTree.tree.size+this.columnHeaderLevelCount+this.bottomFrozenRowCount}get bodyRowCount(){return this.rowDimensionTree.tree.size}get bottomFrozenRowCount(){return this.showHeader&&this.showColumnHeader&&this.indicatorsAsCol&&!this.hideIndicatorName&&this.indicatorsDefine.find((t=>t?.multiIndicator))?1:0}get rightFrozenColCount(){return this.showHeader&&this.showColumnHeader&&!this.indicatorsAsCol&&!this.hideIndicatorName&&this.indicatorsDefine.find((t=>t?.multiIndicator))?1:0}get headerObjects(){return this._headerObjects}get columnObjects(){return this._indicators}getCellId(t,e){if(e>=0&&t>=0){if(this.isCornerHeader(t,e))return this._cornerHeaderCellIds[e][t];if(this.isColumnHeader(t,e))return this._columnHeaderCellIds[e][t-this.rowHeaderLevelCount];if(this.isRowHeader(t,e))return this._rowHeaderCellIds[e-this.columnHeaderLevelCount]?.[t];if(this.isRightFrozenColumn(t,e))return this._rowHeaderCellIds[e-this.columnHeaderLevelCount][this.rowHeaderLevelCount-1];if(this.isBottomFrozenRow(t,e))return this._columnHeaderCellIds[this.columnHeaderLevelCount-1]?.[t-this.rowHeaderLevelCount]}}getHeader(t,e){const i=this.getCellId(t,e);return this._headerObjectMap[i]}getHeaderField(t,e){const i=this.getCellId(t,e);return this._headerObjectMap[i]?.field||this.getBody(t,e)?.field}getHeaderCellAdress(t){for(let e=0;e<this._columnHeaderCellIds.length;e++){const i=this._columnHeaderCellIds[e];for(let n=0;n<i.length;n++)if(i[n]===t)return{col:n+this._table.frozenColCount,row:e}}for(let e=0;e<this._rowHeaderCellIds.length;e++){const i=this._rowHeaderCellIds[e];for(let n=0;n<i.length;n++)if(i[n]===t)return{col:n,row:e+this._table.frozenRowCount}}for(let e=0;e<this._cornerHeaderCellIds.length;e++){const i=this._cornerHeaderCellIds[e];for(let n=0;n<i.length;n++)if(i[n]===t)return{col:n,row:e}}}getHeaderCellAddressByField(t){const e=this.headerObjects.find((e=>e&&e.field===t));return this.getHeaderCellAdress(e.id)}getBody(t,e){const i=this.getCellHeaderPaths(t,e);if(this.indicatorsAsCol){const t=i.colHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;return this._indicators.find((e=>e.indicatorKey===t))??this._indicators[0]??{id:"",field:void 0,indicatorKey:void 0,cellType:void 0,define:void 0}}const n=i.rowHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;return this._indicators.find((t=>t.indicatorKey===n))??this._indicators[0]??{id:"",field:void 0,indicatorKey:void 0,cellType:void 0,define:void 0}}getBodyLayoutRangeById(t){for(let e=0;e<(this.colCount??0);e++)if(t===this.columnObjects[e].id)return{start:{col:e,row:0},end:{col:e,row:0}};throw new Error(`can not found body layout @id=${t}`)}getCellRange(t,e){if(-1===t||-1===e)return{start:{col:t,row:e},end:{col:t,row:e}};if(this._cellRangeMap.has(`${t}-${e}`))return this._cellRangeMap.get(`${t}-${e}`);const i={start:{col:t,row:e},end:{col:t,row:e}};if(this.isHeader(t,e)&&-1!==t&&-1!==e){const n=this.getCellId(t,e);for(let r=t-1;r>=0&&n===this.getCellId(r,e);r--)i.start.col=r;for(let r=t+1;r<(this.colCount??0)&&n===this.getCellId(r,e);r++)i.end.col=r;for(let r=e-1;r>=0&&n===this.getCellId(t,r);r--)i.start.row=r;for(let r=e+1;r<(this.rowCount??0)&&n===this.getCellId(t,r);r++)i.end.row=r}return this._cellRangeMap.set(`${t}-${e}`,i),i}isCellRangeEqual(t,e,i,n){const r=this.getCellRange(t,e),o=this.getCellRange(i,n);return r.start.col===o.start.col&&r.end.col===o.end.col&&r.start.row===o.start.row&&r.end.row===o.end.row}getRecordIndexByRow(t){return t<this.columnHeaderLevelCount||t>=this.rowCount-this.bottomFrozenRowCount?-1:t-this.columnHeaderLevelCount}getRecordIndexByCol(t){return t<this.rowHeaderLevelCount||t>=this.colCount-this.rightFrozenColCount?-1:t-this.rowHeaderLevelCount}getRecordStartRowByRecordIndex(t){return this.columnHeaderLevelCount+t}getCellHeaderPathsWidthTreeNode(t,e){if(this._CellHeaderPathMap.has(`${t}-${e}`))return this._CellHeaderPathMap.get(`${t}-${e}`);const i=this.getRecordIndexByCol(t),n=this.getRecordIndexByRow(e);let r,o;if(t>=0&&(r=this.columnDimensionTree.getTreePath(i,this.showHeader&&this.showColumnHeader?e-(this.columnHeaderTitle?1:0):this.columnDimensionTree.totalLevel)),e>=0)if("tree"===this.rowHierarchyType)if(t>=this.rowHeaderLevelCount)o=this.rowDimensionTree.getTreePath(n,t+this.rowDimensionTree.totalLevel);else{const i=this.getHeader(t,e);o=this.rowDimensionTree.getTreePath(n,t+i.hierarchyLevel)}else o=this.rowDimensionTree.getTreePath(n,this.showHeader&&this.showRowHeader?t-(this.rowHeaderTitle?1:0):this.rowDimensionTree.totalLevel);const s={colHeaderPaths:r,rowHeaderPaths:o};return this._CellHeaderPathMap.set(`${t}-${e}`,s),s}getCellHeaderPaths(t,e){const i=this.getCellHeaderPathsWidthTreeNode(t,e),n={colHeaderPaths:[],rowHeaderPaths:[]};return i.colHeaderPaths.forEach((t=>{const e={};e.dimensionKey=t.dimensionKey,e.indicatorKey=t.indicatorKey,e.value=t.value??this.getIndicatorInfoByIndicatorKey(t.indicatorKey)?.title??"",n.colHeaderPaths.push(e)})),i.rowHeaderPaths.forEach((t=>{const e={};e.dimensionKey=t.dimensionKey,e.indicatorKey=t.indicatorKey,e.value=t.value??this.getIndicatorInfoByIndicatorKey(t.indicatorKey)?.title??"",n.rowHeaderPaths.push(e)})),n}getIndicatorInfoByIndicatorKey(t){const e=this.indicatorsDefine?.find((e=>"string"!=typeof e&&(!!t&&e.indicatorKey===t)));return e}getHeaderDimension(t,e){if(this.isHeader(t,e)){const i=this.getHeader(t,e);return this.rowsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.field))??this.columnsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.field))}}isColumnIndicatorHeader(t,e){return"column"===this._indicatorShowType&&e===this.columnHeaderLevelCount-1&&t>=this.rowHeaderLevelCount}isRowIndicatorHeader(t,e){return"row"===this._indicatorShowType&&t===this.rowHeaderLevelCount-1&&e>=this.columnHeaderLevelCount}isIndicatorHeader(t,e){return this.isColumnIndicatorHeader(t,e)||this.isRowIndicatorHeader(t,e)}toggleHierarchyState(t,e){const i=this._rowHeaderCellIds.slice(0),n=i.map((t=>this.getHeaderCellAdress(t[0]))),r=this.getHeader(t,e);if(r.define.hierarchyState=r.define.hierarchyState===Xc.collapse?Xc.expand:Xc.collapse,this.rowDimensionTree.reset(this.rowDimensionTree.tree.children,!0),this._rowHeaderCellIds=[],this.rowHeaderObjs=this._addHeadersForTreeMode(this._rowHeaderCellIds,0,this.rowDimensionTree.tree.children,[],this.rowDimensionTree.totalLevel,!0),this.rowHeaderTitle){const t=++OU,e=Array(this.rowCount-this.columnHeaderLevelCount).fill(t);this._rowHeaderCellIds.unshift(e);const i={id:t,title:"string"==typeof this.rowHeaderTitle.title?this.rowHeaderTitle.title:this.rowsDefine.reduce(((t,e)=>"string"==typeof e?t:t+(t?`/${e.title}`:`${e.title}`)),""),field:void 0,headerType:this.rowHeaderTitle.headerType??"text",style:this.rowHeaderTitle.headerStyle,define:{field:"",headerType:"text",cellType:"text"}};this.rowHeaderObjs.push(i),this._headerObjects[t]=i}return DU=0,this._rowHeaderCellIds=fu(this._rowHeaderCellIds),this._headerObjectMap=this._headerObjects.reduce(((t,e)=>(t[e.id]=e,t)),{}),this._CellHeaderPathMap=new Map,function(t,e,i,n){const r=t.map((t=>t[0])),o=e.map((t=>t[0])),s=[],a=[];for(let t=0;t<r.length;t++)o.includes(r[t])||a.push(i[t]);for(let t=0;t<o.length;t++)r.includes(o[t])||s.push(n.getHeaderCellAdress(o[t]));return{addCellPositions:s,removeCellPositions:a}}(i,this._rowHeaderCellIds,n,this)}isHeaderForColWidth(t,e){return this.isHeader(t,e)}getHeaderForColWidth(t,e){return this.getHeader(t,e)}getPivotCellAdress(t){if(!Array.isArray(t))return;let e,i,n=this.rowTree,r=this.columnTree;for(let o=0;o<t.length;o++){const s=t[o];if((s.isPivotCorner||!s.value)&&o===t.length-1){if("row"===this?.cornerSetting?.titleOnDimension){let t=0;return"grid"===this.rowHierarchyType&&(t=this.rowDimensionKeys.indexOf(s.dimensionKey)),-1===t?void 0:{col:this.rowHeaderTitle?t+1:t,row:0}}const t=this.colDimensionKeys.indexOf(s.dimensionKey);return-1===t?void 0:{col:0,row:this.columnHeaderTitle?t+1:t}}let a=!1;for(let t=0;t<r.length;t++){const e=r[t];if((bu(s.dimensionKey)&&e.dimensionKey===s.dimensionKey||bu(s.indicatorKey)&&e.indicatorKey===s.indicatorKey)&&e.value===s.value){r=e.children,i=e,a=!0;break}}if(!a)for(let t=0;t<n.length;t++){const i=n[t];if((bu(s.dimensionKey)&&i.dimensionKey===s.dimensionKey||bu(s.indicatorKey)&&i.indicatorKey===s.indicatorKey)&&i.value===s.value){n=i.children,e=i;break}}}let o=0,s=0;if(e){s=this.columnHeaderLevelCount;const{startInTotal:t,level:i}=e;return s+=t,o="grid"===this.rowHierarchyType?this.rowHeaderTitle?i+1:i:0,{col:o,row:s}}if(i){o=this.rowHeaderLevelCount;const{startInTotal:t,level:e}=i;return o+=t,s=this.columnHeaderTitle?e+1:e,{col:o,row:s}}}getPivotDimensionInfo(t,e){const{colHeaderPaths:i,rowHeaderPaths:n}=this.getCellHeaderPaths(t,e),r=[];return i.length?i.forEach(((t,e)=>{r.push({dimensionKey:t.dimensionKey,value:t.value,isPivotCorner:!1,indicatorKey:t.indicatorKey})})):n.length?n.forEach(((t,e)=>{r.push({dimensionKey:t.dimensionKey,value:t.value,isPivotCorner:!1,indicatorKey:t.indicatorKey})})):this.isCornerHeader(t,e)&&("row"===this?.cornerSetting?.titleOnDimension?r.push({dimensionKey:this.rowDimensionKeys[this.rowHeaderTitle?t-1:t],isPivotCorner:!0}):r.push({dimensionKey:this.colDimensionKeys[this.columnHeaderTitle?e-1:e],isPivotCorner:!0})),r}getIndicatorKey(t,e){return this.getBody(t,e)?.indicatorKey}getParentCellId(t,e){if(0!==e)return this.isColumnHeader(t,e)?this.getCellId(t,e-1):this.isRowHeader(t,e)?this.getCellId(t-1,e):void 0}canMoveHeaderPosition(t,e){const i=this.getCellRange(t.col,t.row);if(this.isColumnHeader(t.col,t.row)){return this.getParentCellId(t.col,i.start.row)===this.getParentCellId(e.col,i.start.row)}if(this.isRowHeader(t.col,t.row)){if("tree"!==this.rowHierarchyType){return this.getParentCellId(i.start.col,t.row)===this.getParentCellId(i.start.col,e.row)}{const i=du(this.getCellHeaderPathsWidthTreeNode(t.col,t.row).rowHeaderPaths),n=du(this.getCellHeaderPathsWidthTreeNode(e.col,e.row).rowHeaderPaths);if(i.pop(),n.pop(),i.length<=n.length)return i.length!==n.length||!i.find(((t,e)=>t.dimensionKey!==n[e].dimensionKey||t.value!==n[e].value))}}return!1}moveHeaderPosition(t,e){if(this.canMoveHeaderPosition(t,e)&&!this.isCellRangeEqual(t.col,t.row,e.col,e.row)){const i=this.getCellRange(t.col,t.row);if(this.isColumnHeader(t.col,t.row)){const n=i.end.col-i.start.col+1;let r;const o=this.getCellRange(e.col,i.start.row);if(r=e.col>=t.col?o.end.col-n+1:o.start.col,r===i.end.col)return null;for(let t=0;t<this._columnHeaderCellIds.length;t++){const e=this._columnHeaderCellIds[t].splice(i.start.col-this.rowHeaderLevelCount,n);e.unshift(r-this.rowHeaderLevelCount,0),Array.prototype.splice.apply(this._columnHeaderCellIds[t],e)}const s=this._columnWidths.splice(i.start.col,n);return s.unshift(r,0),Array.prototype.splice.apply(this._columnWidths,s),this.columnDimensionTree.movePosition(t.row,i.start.col-this.rowHeaderLevelCount,r-this.rowHeaderLevelCount),this.columnDimensionTree.reset(this.columnDimensionTree.tree.children,!0),this._CellHeaderPathMap=new Map,this._cellRangeMap=new Map,{sourceIndex:i.start.col,targetIndex:r,moveSize:n,moveType:"column"}}if(this.isRowHeader(t.col,t.row)){let n;const r=this.getCellHeaderPathsWidthTreeNode(t.col,t.row).rowHeaderPaths,o=this.getCellHeaderPathsWidthTreeNode(e.col,e.row).rowHeaderPaths,s=r[r.length-1],a=o[r.length-1],l=s.size;if(n=e.row>=t.row?a.startInTotal+a.size-l:a.startInTotal,n===t.row||n===i.end.row)return null;const h=this._rowHeaderCellIds.splice(i.start.row-this.columnHeaderLevelCount,l);return h.unshift(n,0),Array.prototype.splice.apply(this._rowHeaderCellIds,h),this.rowDimensionTree.movePosition(this.getCellHeaderPathsWidthTreeNode(t.col,t.row).rowHeaderPaths.length-1,i.start.row-this.columnHeaderLevelCount,n+(e.row>t.row?s.size-1:0)),this.rowDimensionTree.reset(this.rowDimensionTree.tree.children,!0),this._CellHeaderPathMap=new Map,this._cellRangeMap=new Map,{sourceIndex:i.start.row,targetIndex:n+this.columnHeaderLevelCount,moveSize:l,moveType:"row"}}}return null}getCellAdressByHeaderPath(t){let e,i;if(Array.isArray(t)){if(t.length>this.rowDimensionKeys.length+this.colDimensionKeys.length)return;e=t.filter((t=>this.colDimensionKeys.indexOf(t.dimensionKey)>=0)),i=t.filter((t=>this.rowDimensionKeys.indexOf(t.dimensionKey)>=0))}else e=t.colHeaderPaths,i=t.rowHeaderPaths;if(!Array.isArray(e)&&!Array.isArray(i))return;e?.sort(((t,e)=>this.colDimensionKeys.indexOf(t.dimensionKey??this.indicatorDimensionKey)-this.colDimensionKeys.indexOf(e.dimensionKey??this.indicatorDimensionKey))),i?.sort(((t,e)=>this.rowDimensionKeys.indexOf(t.dimensionKey??this.indicatorDimensionKey)-this.rowDimensionKeys.indexOf(e.dimensionKey??this.indicatorDimensionKey)));let n,r,o,s,a=!1;e?.length>=1&&i?.length>=1&&(a=!0);let l,h,c=this.rowTree,u=this.columnTree;if(e)for(let t=0;t<e.length;t++){const i=e[t];for(let t=0;t<u.length;t++){const e=u[t];if(!bu(i.indicatorKey)&&e.dimensionKey===i.dimensionKey&&e.value===i.value||bu(i.indicatorKey)&&e.indicatorKey===i.indicatorKey){u=e.children,a&&!u?h=e:a||(h=e);break}}}if(i)for(let t=0;t<i.length;t++){const e=i[t];for(let t=0;t<c.length;t++){const i=c[t];if((!bu(e.indicatorKey)&&i.dimensionKey===e.dimensionKey&&i.value===e.value||bu(e.indicatorKey)&&i.indicatorKey===e.indicatorKey)&&i.value===e.value){c=i.children,a&&!c?l=i:a||(l=i);break}}}if(!a||l&&h){if(l){r=this.columnHeaderLevelCount;const{startInTotal:t,level:e}=l;r+=t,o="grid"===this.rowHierarchyType?this.rowHeaderTitle?e+1:e:0}if(h){n=this.rowHeaderLevelCount;const{startInTotal:t,level:e}=h;n+=t,s=this.columnHeaderTitle?e+1:e}return bu(n)||bu(r)?{col:n??o,row:r??s}:void 0}}setChartInstance(t,e,i){const n=this.getCellHeaderPaths(t,e);let r;if(this.indicatorsAsCol){const t=n.colHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;r=this._indicators.find((e=>e.indicatorKey===t))}else{const t=n.rowHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;r=this._indicators.find((e=>e.indicatorKey===t))}r&&(r.chartInstance=i)}getChartInstance(t,e){const i=this.getCellHeaderPaths(t,e);let n;if(this.indicatorsAsCol){const t=i.colHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;n=this._indicators.find((e=>e.indicatorKey===t))}else{const t=i.rowHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;n=this._indicators.find((e=>e.indicatorKey===t))}return n?.chartInstance}getDimension(t,e){return"column"===e?this.columnsDefine?.find((e=>"string"!=typeof e&&e.dimensionKey===t)):"row"===e?this.rowsDefine?.find((e=>"string"!=typeof e&&e.dimensionKey===t)):void 0}getAxisConfigInPivotChart(t,e){}isEmpty(t,e){return!1}getChartAxes(t,e){return[]}getRawChartSpec(t,e){return EU(t,e,this)}getChartDataId(t,e){return HU(t,e,this)}release(){const t=this._table._getActiveChartInstance();t?.release(),this._indicators.forEach((t=>{t.chartInstance?.release()}))}getHeadNode(t){if(!Array.isArray(t))return;let e,i,n=this.rowTree,r=this.columnTree;for(let o=0;o<t.length;o++){const s=t[o];if((s.isPivotCorner||!s.value)&&o===t.length-1)return;let a=!1;for(let t=0;t<r.length;t++){const e=r[t];if((bu(s.dimensionKey)&&e.dimensionKey===s.dimensionKey||bu(s.indicatorKey)&&e.indicatorKey===s.indicatorKey)&&e.value===s.value){r=e.children,i=e,a=!0;break}}if(!a)for(let t=0;t<n.length;t++){const i=n[t];if((bu(s.dimensionKey)&&i.dimensionKey===s.dimensionKey||bu(s.indicatorKey)&&i.indicatorKey===s.indicatorKey)&&i.value===s.value){n=i.children,e=i;break}}}return e||(i||void 0)}}const zU={isEmpty:!0,id:void 0,field:void 0,headerType:void 0,define:void 0};class WU{_headerObjects=[];_headerObjectMap={};_indicatorObjects=[];_columnWidths=[];rowTree;columnTree;rowsDefine;columnsDefine;indicatorsDefine;indicatorKeys;_showRowHeader=!0;_showColumnHeader=!0;_rowHeaderTitle;_columnHeaderTitle;_indicatorShowType="column";indicatorsAsCol=!0;hideIndicatorName=!1;indicatorDimensionKey=Sf;indicatorTitle;rowKeysPath;colKeysPath;convertColKeys;rows;columns;rowShowAttrs;colShowAttrs;tree;dataset;dataConfig;_rowCount;_colCount;_bodyRowCount;cornerSetting;_table;hasTwoIndicatorAxes;_chartItemSpanSize;constructor(t,e){this._table=t,this._chartItemSpanSize=0,this.rowTree=t.options.rowTree,this.columnTree=t.options.columnTree,this.rowsDefine=t.options.rows??[],this.columnsDefine=t.options.columns??[],this.indicatorsDefine=t.options.indicators??[],this.indicatorTitle=t.options.indicatorTitle,this.dataset=e,this.dataConfig=e.dataConfig,this.indicatorKeys=e.indicatorKeys,this.indicatorsAsCol=t.options.indicatorsAsCol??!0,this.hideIndicatorName=t.options.hideIndicatorName??!1,this.showRowHeader=t.options.showRowHeader??!0,this.showColumnHeader=t.options.showColumnHeader??!0,this.rowHeaderTitle=t.options.rowHeaderTitle,this.columnHeaderTitle=t.options.columnHeaderTitle,this.cornerSetting=t.options.corner??{titleOnDimension:"column"},this.columns=e.columns,this.rows=e.rows,this.rowKeysPath=e.rowKeysPath,this.colKeysPath=e.colKeysPath,this.tree=e.tree,this.initState(),this.convertColKeys=fu(this.colKeysPath)}initState(){if(this.indicatorsAsCol&&!this.hideIndicatorName?this._indicatorShowType="column":this.indicatorsAsCol||this.hideIndicatorName?this._indicatorShowType="none":this._indicatorShowType="row",this.colShowAttrs="column"===this._indicatorShowType?this.columns.concat(this.indicatorDimensionKey):Array.from(this.columns),this.rowShowAttrs="row"===this._indicatorShowType?this.rows.concat(this.indicatorDimensionKey):Array.from(this.rows),this._bodyRowCount=this.rowKeysPath.length*(this.indicatorsAsCol?1:this.indicatorKeys.length),this.initHeaderObjects(),this.initIndicatorObjects(),this.rowHeaderTitle){const t="rowHeaderTitle",e="string"==typeof this.rowHeaderTitle.title?this.rowHeaderTitle.title:this.rowsDefine.reduce(((t,e)=>"string"==typeof e?t:t+(t?`/${e.title}`:`${e.title}`)),"");this._headerObjectMap[e]={id:e,title:e,field:t,headerType:this.rowHeaderTitle.headerType??"text",style:this.rowHeaderTitle.headerStyle,define:{}},this._headerObjectMap[t]={id:t,title:"",field:t,headerType:this.cornerSetting.headerType??"text",style:this.cornerSetting.headerStyle,define:{}},this._headerObjects.push(this._headerObjectMap[e]),this._headerObjects.push(this._headerObjectMap[t]),this.rowShowAttrs.unshift(t),this.rowKeysPath.forEach(((t,i)=>{t.unshift(e)}))}if(this.columnHeaderTitle){const t="columnHeaderTitleCell",e="string"==typeof this.columnHeaderTitle.title?this.columnHeaderTitle.title:this.columnsDefine.reduce(((t,e)=>"string"==typeof e?t:t+(t?`/${e.title}`:`${e.title}`)),"");this._headerObjectMap[e]={id:e,title:e,field:t,headerType:this.columnHeaderTitle.headerType??"text",style:this.columnHeaderTitle.headerStyle,define:{}},this._headerObjectMap[t]={id:t,title:"",field:t,headerType:this.cornerSetting.headerType??"text",style:this.cornerSetting.headerStyle,define:{}},this._headerObjects.push(this._headerObjectMap[e]),this._headerObjects.push(this._headerObjectMap[t]),this.colShowAttrs.unshift(t),this.colKeysPath.forEach(((t,i)=>{t.unshift(e)}))}if(this._table.isPivotChart())if(this.hasTwoIndicatorAxes=this._indicatorObjects.some((t=>!!(t.chartSpec&&t.chartSpec.series&&t.chartSpec.series.length>1))),this._chartItemSpanSize=0,this._indicatorObjects.find((t=>(t.chartSpec?.barWidth&&(this._chartItemSpanSize=t.chartSpec?.barWidth),this._chartItemSpanSize>0||(t.chartSpec.series?.find((t=>(t.barWidth&&(this._chartItemSpanSize=t.barWidth),this._chartItemSpanSize>0))),this._chartItemSpanSize>0)))),this.indicatorsAsCol){const t="rowHeaderEmpty";this._headerObjectMap[t]={id:t,title:"",field:t,headerType:this.cornerSetting.headerType??"text",style:this.cornerSetting.headerStyle,define:{}},this._headerObjects.push(this._headerObjectMap[t]),this.rowShowAttrs.push(t),this.hasTwoIndicatorAxes||this.colShowAttrs.pop()}else{const t=this._table.pivotChartAxes.find((t=>"left"===t.orient));!1===t?.visible&&this.rowShowAttrs.pop()}this._colCount=(0===this.colKeysPath.length?1:this.colKeysPath.length)*(this.indicatorsAsCol?this.indicatorKeys.length:1)+this.rowHeaderLevelCount+this.rightFrozenColCount,this._rowCount=(0===this.rowKeysPath.length?1:this.rowKeysPath.length)*(this.indicatorsAsCol?1:this.indicatorKeys.length)+this.columnHeaderLevelCount+this.bottomFrozenRowCount,this.setColumnWidths()}setColumnWidths(){const t=new Array(this.colCount).fill(void 0);if(this.showRowHeader&&(this.rowHeaderTitle&&(t[0]={}),this.rowShowAttrs.forEach(((e,i)=>{const n=this.rowsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===e));n&&(t[i+(this.rowHeaderTitle?1:0)]={width:n.width,minWidth:n.minWidth,maxWidth:n.maxWidth})}))),this.indicatorsAsCol)for(let e=this.rowHeaderLevelCount;e<this.colCount;e++){const i=this.getBody(e,this.columnHeaderLevelCount);t[e]={width:i?.width,minWidth:i?.minWidth,maxWidth:i?.maxWidth}}else{let e,i,n,r=0;this._indicatorObjects.forEach(((t,o)=>{"number"==typeof t.width?r=Math.max(t.width,r):"auto"===t.width&&(n=!0),"number"==typeof t.minWidth&&(i=Math.max(t.minWidth,i)),"number"==typeof t.maxWidth&&(e=Math.max(t.maxWidth,e))})),r=r>0?r:n?"auto":void 0,t.fill({width:r,minWidth:i,maxWidth:e},this.rowHeaderLevelCount,this.colCount-this.rightFrozenColCount)}this._columnWidths=t}get columnWidths(){return this._columnWidths}getColumnWidthDefined(t){return this._columnWidths[t]}getDimensionInfo(t){return this.rowsDefine?.find((e=>"string"!=typeof e&&e.dimensionKey===t))??this.columnsDefine?.find((e=>"string"!=typeof e&&e.dimensionKey===t))}getIndicatorInfo(t,e=""){const i=this.indicatorsDefine?.find((i=>"string"!=typeof i&&(t?i.indicatorKey===t:!!e&&i.title===e)));return i}getColKeysPath(){return this.colKeysPath}getRowKeysPath(){return this.rowKeysPath}initHeaderObjects(){for(let t=0,e=this.rowKeysPath.length;t<=e-1;t++){const e=this.rowKeysPath[t];for(let t=0,i=e.length;t<=i-1;t++)if(!this._headerObjectMap[e[t]]){const i=e[t].split(this.dataset.stringJoinChar),n=this.getDimensionInfo(this.rows[i.length-1]);this._headerObjectMap[e[t]]={id:e[t],field:n?.dimensionKey??this.rows[i.length-1],title:i[i.length-1],style:n?.headerStyle,define:{field:n?.dimensionKey??this.rows[i.length-1],headerType:n?.headerType??"text",cellType:"text"},fieldFormat:n?.headerFormat,dropDownMenu:n?.dropDownMenu,headerType:n?.headerType??"text",width:n?.width},this._headerObjects.push(this._headerObjectMap[e[t]])}}for(let t=0,e=this.colKeysPath.length;t<=e-1;t++){const e=this.colKeysPath[t];for(let t=0,i=e.length;t<=i-1;t++)if(!this._headerObjectMap[e[t]]){const i=e[t].split(this.dataset.stringJoinChar),n=this.getDimensionInfo(this.columns[i.length-1]);this._headerObjectMap[e[t]]={id:e[t],field:n?.dimensionKey??this.columns[i.length-1],title:i[i.length-1],style:n?.headerStyle,define:{field:n?.dimensionKey??this.columns[i.length-1],headerType:n?.headerType??"text",cellType:"text"},fieldFormat:n?.headerFormat,dropDownMenu:n?.dropDownMenu,headerType:n?.headerType??"text",width:n?.width},this._headerObjects.push(this._headerObjectMap[e[t]])}}let t;this.indicatorsDefine.forEach((t=>{const e="string"==typeof t?t:t.indicatorKey,i="string"==typeof t?void 0:t;this._headerObjectMap[e]||(this._headerObjectMap[e]={id:e,field:this.indicatorDimensionKey,title:i?.title??e,style:i?.headerStyle,define:{field:this.indicatorDimensionKey,headerType:i?.headerType??"text",cellType:"text"},dropDownMenu:i?.dropDownMenu,headerType:i?.headerType??"text",width:i?.width},this._headerObjects.push(this._headerObjectMap[e]))})),"column"===this.cornerSetting.titleOnDimension?t=this.colShowAttrs:"row"===this.cornerSetting.titleOnDimension&&(t=this.rowShowAttrs),t?.forEach((t=>{if(!this._headerObjectMap[t]){const e=this.getDimensionInfo(t);this._headerObjectMap[t]={id:t,field:t,title:t===this.indicatorDimensionKey?this.indicatorTitle:e?.title??t,style:this.cornerSetting?.headerStyle,define:{field:t,headerType:this.cornerSetting?.headerType??"text",cellType:"text"},dropDownMenu:e?.dropDownMenu,headerType:this.cornerSetting?.headerType??"text",width:e?.width},this._headerObjects.push(this._headerObjectMap[t])}}))}initIndicatorObjects(){this.indicatorKeys.forEach((t=>{const e=this.indicatorsDefine?.find((e=>"string"!=typeof e&&e.indicatorKey===t));this._indicatorObjects.push({id:t,indicatorKey:t,field:t,define:Object.assign({field:t,headerType:"text",cellType:e?.cellType??e?.columnType??"text"},e),fieldFormat:e?.format,cellType:e?.cellType??e?.columnType??"text",chartModule:e&&("chartModule"in e?e?.chartModule:null),chartSpec:e&&("chartSpec"in e?e?.chartSpec:null),sparklineSpec:e&&("sparklineSpec"in e?e?.sparklineSpec:null),style:e?.style,icon:e?.icon,width:e?.width,minWidth:e?.minWidth,maxWidth:e?.maxWidth,disableColumnResize:e?.disableColumnResize})}))}get showColumnHeader(){return this._showColumnHeader}set showColumnHeader(t){this._showColumnHeader=t}get showRowHeader(){return this._showRowHeader}set showRowHeader(t){this._showRowHeader=t}get columnHeaderTitle(){return this._columnHeaderTitle}set columnHeaderTitle(t){this._columnHeaderTitle=t}get rowHeaderTitle(){return this._rowHeaderTitle}set rowHeaderTitle(t){this._rowHeaderTitle=t}getCellLocation(t,e){return this.isCornerHeader(t,e)?"cornerHeader":this.isColumnHeader(t,e)?"columnHeader":this.isRowHeader(t,e)?"rowHeader":"body"}isHeader(t,e){return t<this.rowHeaderLevelCount||(e<this.columnHeaderLevelCount||(t>=this.colCount-this.rightFrozenColCount||e>=this.rowCount-this.bottomFrozenRowCount))}isCornerHeader(t,e){return t<this.rowHeaderLevelCount&&e<this.columnHeaderLevelCount}isColumnHeader(t,e){return t>=this.rowHeaderLevelCount&&e<this.columnHeaderLevelCount}isRightFrozenColumn(t,e){return t>=this.colCount-this.rightFrozenColCount&&e>=this.columnHeaderLevelCount&&e<this.rowCount-this.bottomFrozenRowCount}isBottomFrozenRow(t,e){return t>=this.rowHeaderLevelCount&&e>=this.rowCount-this.bottomFrozenRowCount&&t<this.colCount-this.rightFrozenColCount}isLeftBottomCorner(t,e){return t<this.rowHeaderLevelCount&&e>=this.rowCount-this.bottomFrozenRowCount}isRightTopCorner(t,e){return t>=this.colCount-this.rightFrozenColCount&&e<this.columnHeaderLevelCount}isRightBottomCorner(t,e){return t>=this.colCount-this.rightFrozenColCount&&e>=this.rowCount-this.bottomFrozenRowCount}isRowHeader(t,e){return t<this.rowHeaderLevelCount&&e>=this.columnHeaderLevelCount}isColumnIndicatorHeader(t,e){return"column"===this._indicatorShowType&&e===this.columnHeaderLevelCount-1&&t>=this.rowHeaderLevelCount}isRowIndicatorHeader(t,e){return"row"===this._indicatorShowType&&t===this.rowHeaderLevelCount-1&&e>=this.columnHeaderLevelCount}isIndicatorHeader(t,e){return this.isColumnIndicatorHeader(t,e)||this.isRowIndicatorHeader(t,e)}getColumnHeaderRange(){return{start:{col:this.rowHeaderLevelCount,row:0},end:{col:this.colCount-1,row:this.columnHeaderLevelCount-1}}}getRowHeaderRange(){return{start:{col:0,row:this.columnHeaderLevelCount},end:{col:this.rowHeaderLevelCount-1,row:this.rowCount-1}}}getCornerHeaderRange(){return{start:{col:0,row:0},end:{col:this.rowHeaderLevelCount-1,row:this.columnHeaderLevelCount-1}}}getBodyRange(){return{start:{col:this.rowHeaderLevelCount,row:this.columnHeaderLevelCount},end:{col:this.colCount-1,row:this.rowCount-1}}}resetCellIds(){}get headerLevelCount(){return this.columnHeaderLevelCount}get columnHeaderLevelCount(){const t=this.colShowAttrs.length;if(this.showColumnHeader){return this.indicatorsAsCol&&this.hideIndicatorName&&this.colShowAttrs[this.colShowAttrs.length-1]===this.indicatorDimensionKey?t-1:t}return this.indicatorsAsCol?this.hideIndicatorName?0:1:0}get rowHeaderLevelCount(){const t=this.rowShowAttrs.length;if(this.showRowHeader){return this.indicatorsAsCol?t:this.hideIndicatorName&&this.rowShowAttrs[this.rowShowAttrs.length-1]===this.indicatorDimensionKey?t-1:t}return this.indicatorsAsCol||this.hideIndicatorName?0:1}get colCount(){return this._colCount}get rowCount(){return this._rowCount}get bodyRowCount(){return this._bodyRowCount}get bottomFrozenRowCount(){if(!this._table.isPivotChart())return 0;const t=this._table.pivotChartAxes.find((t=>"bottom"===t.orient));return!1===t?.visible?0:(this.indicatorsAsCol,1)}get rightFrozenColCount(){if(!this._table.isPivotChart())return 0;const t=this._table.pivotChartAxes.find((t=>"right"===t.orient));return!1===t?.visible||this.indicatorsAsCol?0:this.hasTwoIndicatorAxes?1:0}get leftAxesCount(){if(!this._table.isPivotChart())return 0;const t=this._table.pivotChartAxes.find((t=>"left"===t.orient));return!1===t?.visible?0:(this.indicatorsAsCol,1)}get topAxesCount(){if(!this._table.isPivotChart())return 0;const t=this._table.pivotChartAxes.find((t=>"top"===t.orient));return!1===t?.visible?0:this.indicatorsAsCol&&this.hasTwoIndicatorAxes?1:0}get rightAxesCount(){return this.rightFrozenColCount}get bottomAxesCount(){return this.bottomFrozenRowCount}get headerObjects(){return this._headerObjects}get columnObjects(){return this._indicatorObjects}getCellId(t,e){if(t<this.rowHeaderLevelCount&&e>=this.rowCount-this.bottomFrozenRowCount||e<this.columnHeaderLevelCount&&t>=this.colCount-this.rightFrozenColCount)return 0;if(e>=0&&t>=0)if(this.isCornerHeader(t,e)){if("column"===this.cornerSetting.titleOnDimension)return this.colShowAttrs[e];if("row"===this.cornerSetting.titleOnDimension)return this.rowShowAttrs[t]}else{if(this.isColumnHeader(t,e))return e<this.columns.length+(this.columnHeaderTitle?1:0)?this.convertColKeys[e][this.indicatorsAsCol?Math.floor((t-this.rowHeaderLevelCount)/this.indicatorKeys.length):t-this.rowHeaderLevelCount]:this.indicatorKeys[(t-this.rowHeaderLevelCount)%this.indicatorKeys.length];if(this.isRowHeader(t,e))return t<this.rows.length+(this.rowHeaderTitle?1:0)?this.rowKeysPath[this.indicatorsAsCol?e-this.columnHeaderLevelCount:Math.floor((e-this.columnHeaderLevelCount)/this.indicatorKeys.length)][t]:this.indicatorKeys[(e-this.columnHeaderLevelCount)%this.indicatorKeys.length];if(this.isRightFrozenColumn(t,e))return this.indicatorsAsCol?this.rowKeysPath[e-this.columnHeaderLevelCount][this.rowHeaderLevelCount-1]:this.indicatorKeys[(e-this.columnHeaderLevelCount)%this.indicatorKeys.length];if(this.isBottomFrozenRow(t,e))return this.indicatorsAsCol?this.indicatorKeys[(t-this.rowHeaderLevelCount)%this.indicatorKeys.length]:this.convertColKeys[this.convertColKeys.length-1][Math.floor((t-this.rowHeaderLevelCount)/this.indicatorKeys.length)]}return 0}getIndicatorKey(t,e){if(this.isHeader(t,e))return"";if(this.indicatorsAsCol){const e=t-this.rowHeaderLevelCount;return this.indicatorKeys[e%this.indicatorKeys.length]}const i=e-this.columnHeaderLevelCount;return this.indicatorKeys[i%this.indicatorKeys.length]}getHeader(t,e){const i=this.getCellId(t,e);return this._headerObjectMap[i]??zU}getHeaderField(t,e){const i=this.getCellId(t,e);return this._headerObjectMap[i]?.field||this.getBody(t,e)?.field}getHeaderFieldKey(t,e){}getHeaderCellAdress(t){}getHeaderCellAddressByField(t){throw new Error(`Method not implemented.${t}`)}getBody(t,e){const i=this.getCellHeaderPaths(t,e);if(this.indicatorsAsCol){const t=i.colHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;return this._indicatorObjects.find((e=>e.indicatorKey===t))??this._indicatorObjects[0]??{id:"",field:void 0,indicatorKey:void 0,cellType:void 0,define:void 0}}const n=i.rowHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;return this._indicatorObjects.find((t=>t.indicatorKey===n))??this._indicatorObjects[0]??{id:"",field:void 0,indicatorKey:void 0,cellType:void 0,define:void 0}}getBodyLayoutRangeById(t){for(let e=0;e<(this.colCount??0);e++)if(t===this.columnObjects[e].id)return{start:{col:e,row:0},end:{col:e,row:0}};throw new Error(`can not found body layout @id=${t}`)}getCellRange(t,e){const i={start:{col:t,row:e},end:{col:t,row:e}};if(!this.isHeader(t,e)||-1===t||-1===e||this.isIndicatorHeader(t,e))return i;if(this.isRightFrozenColumn(t,e)||this.isBottomFrozenRow(t,e))return i;const n=this.getCellId(t,e);for(let r=t-1;r>=0&&n===this.getCellId(r,e);r--)i.start.col=r;for(let r=t+1;r<(this.colCount??0)&&n===this.getCellId(r,e);r++)i.end.col=r;for(let r=e-1;r>=0&&n===this.getCellId(t,r);r--)i.start.row=r;for(let r=e+1;r<(this.rowCount??0)&&n===this.getCellId(t,r);r++)i.end.row=r;return i}isCellRangeEqual(t,e,i,n){const r=this.getCellRange(t,e),o=this.getCellRange(i,n);return r.start.col===o.start.col&&r.end.col===o.end.col&&r.start.row===o.start.row&&r.end.row===o.end.row}getRecordIndexByRow(t){return t<this.columnHeaderLevelCount?-1:this.indicatorsAsCol?t-this.columnHeaderLevelCount:Math.floor((t-this.columnHeaderLevelCount)/this.indicatorKeys.length)}getRecordIndexByCol(t){return t<this.rowHeaderLevelCount?-1:this.indicatorsAsCol?Math.floor((t-this.rowHeaderLevelCount)/this.indicatorKeys.length):t-this.rowHeaderLevelCount}getRecordStartRowByRecordIndex(t){return this.columnHeaderLevelCount+t}getCellHeaderPaths(t,e){const i=this.getRecordIndexByCol(t),n=this.getRecordIndexByRow(e);let r,o,s,a;return i>=0&&(r=this.colKeysPath[i],s=r?.[r.length-1]?.split(this.dataset.stringJoinChar),s&&this.showColumnHeader&&e<this.columns.length-1&&(s=s.slice(0,e+1))),n>=0&&(o=this.rowKeysPath[n],a=o?.[o.length-1]?.split(this.dataset.stringJoinChar),a&&this.showRowHeader&&t<this.rows.length-1&&(a=a.slice(0,t+1))),s&&this.indicatorsAsCol&&t>=this.rowHeaderLevelCount?s.push(this.indicatorKeys[(t-this.rowHeaderLevelCount)%this.indicatorKeys.length]):a&&e>=this.columnHeaderLevelCount&&a.push(this.indicatorKeys[(e-this.columnHeaderLevelCount)%this.indicatorKeys.length]),{colHeaderPaths:s?.map(((t,e)=>{const i=this._indicatorObjects.find((e=>e.indicatorKey===t));return{dimensionKey:i?void 0:this.colShowAttrs[e],indicatorKey:i?t:void 0,value:i?i.define.title:t}}))??[],rowHeaderPaths:a?.map(((t,e)=>{const i=this._indicatorObjects.find((e=>e.indicatorKey===t));return{dimensionKey:i?void 0:this.rowShowAttrs[e],indicatorKey:i?t:void 0,value:i?i.define.title:t}}))??[]}}getCellAdressByHeaderPath(t){let e,i;if(Array.isArray(t)){if(t.length>this.rowShowAttrs.length+this.colShowAttrs.length)return;e=t.filter((t=>this.colShowAttrs.indexOf(t.dimensionKey)>=0)),i=t.filter((t=>this.rowShowAttrs.indexOf(t.dimensionKey)>=0))}else e=t.colHeaderPaths,i=t.rowHeaderPaths;if(!Array.isArray(e)&&!Array.isArray(i))return;e?.sort(((t,e)=>this.colShowAttrs.indexOf(t.dimensionKey??this.indicatorDimensionKey)-this.colShowAttrs.indexOf(e.dimensionKey??this.indicatorDimensionKey))),i?.sort(((t,e)=>this.rowShowAttrs.indexOf(t.dimensionKey??this.indicatorDimensionKey)-this.rowShowAttrs.indexOf(e.dimensionKey??this.indicatorDimensionKey))),e?.length>=1&&i?.length;let n,r=0,o=0,s=this.rowTree,a=this.columnTree;if(e)for(let t=0;t<e.length;t++){const i=e[t];if(i.indicatorKey){n=i.indicatorKey;break}for(let t=0;t<a.length;t++){const e=a[t];if(!bu(i.indicatorKey)&&e.dimensionKey===i.dimensionKey&&e.value===i.value){a=e.children,a&&0!==a.length&&!a?.[0]?.indicatorKey||(r+=t);break}r+=e.children?.[0]?.indicatorKey?0:e.children?.length??0}}if(i)for(let t=0;t<i.length;t++){const e=i[t];if(e.indicatorKey){n=e.indicatorKey;break}for(let t=0;t<s.length;t++){const i=s[t];if(!bu(e.indicatorKey)&&i.dimensionKey===e.dimensionKey&&i.value===e.value){s=i.children,s&&0!==s.length&&!s?.[0]?.indicatorKey||(o+=t);break}o+=i.children?.[0]?.indicatorKey?0:i.children?.length??0}}return r=(this.indicatorsAsCol?r*this.indicatorKeys.length+this.indicatorKeys.indexOf(n):r)+this.rowHeaderLevelCount,o=(this.indicatorsAsCol?o:o*this.indicatorKeys.length+this.indicatorKeys.indexOf(n))+this.columnHeaderLevelCount,bu(r)||bu(o)?{col:r??undefined,row:o??undefined}:void 0}getHeaderDimension(t,e){if(this.isHeader(t,e)){const i=this.getHeader(t,e);return this.rowsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.field))??this.columnsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.field))}}updateDataset(t){this.dataset=t,this.dataConfig=t.dataConfig,this.rowKeysPath=t.rowKeysPath,this.colKeysPath=t.colKeysPath,this.tree=t.tree,this._indicatorObjects=[],this._headerObjects=[],this._headerObjectMap={},this.initState(),this.convertColKeys=fu(this.colKeysPath)}isHeaderForColWidth(t,e){return this.isHeader(t,e)}getHeaderForColWidth(t,e){return this.getHeader(t,e)}setChartInstance(t,e,i){const n=this.getCellHeaderPaths(t,e);let r;if(this.indicatorsAsCol){const t=n.colHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;r=this._indicatorObjects.find((e=>e.indicatorKey===t))}else{const t=n.rowHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;r=this._indicatorObjects.find((e=>e.indicatorKey===t))}r&&(r.chartInstance=i)}getChartInstance(t,e){const i=this.getCellHeaderPaths(t,e);let n;if(this.indicatorsAsCol){const t=i.colHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;n=this._indicatorObjects.find((e=>e.indicatorKey===t))}else{const t=i.rowHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;n=this._indicatorObjects.find((e=>e.indicatorKey===t))}return n?.chartInstance}_generateChartState(){return{vtable_selected:{filter:t=>{if(this._table._selectedDataItemsInChart.length>=1){return!!this._table._selectedDataItemsInChart.find((e=>{for(const i in e)if(e[i]!==t[i])return!1;return!0}))}if(this._table._selectedDimensionInChart?.length){return!!this._table._selectedDimensionInChart.every((e=>t[e.key]===e.value))}return!1}},vtable_selected_reverse:{filter:t=>{if(this._table._selectedDataItemsInChart.length>=1){return!this._table._selectedDataItemsInChart.find((e=>{for(const i in e)if(e[i]!==t[i])return!1;return!0}))}if(this._table._selectedDimensionInChart?.length){return!this._table._selectedDimensionInChart.every((e=>t[e.key]===e.value))}return!1}}}}updateDataStateToChartInstance(t){t||(t=this._table._getActiveChartInstance());const e=this._generateChartState();this._indicatorObjects.forEach((t=>{t.chartInstance.updateState(e)})),t?.updateState(e)}updateDataStateToActiveChartInstance(t){t||(t=this._table._getActiveChartInstance());const e=this._generateChartState();t?.updateState(e)}getOptimunWidthForChart(t){const e=this.getCellHeaderPaths(t,this.columnHeaderLevelCount).colHeaderPaths;let i;for(const t in this.dataset.collectValuesBy)if("xField"===this.dataset.collectValuesBy[t].type&&!this.dataset.collectValuesBy[t].range){i=this.dataset.collectedValues[t][e.map((t=>t.value)).join(this.dataset.stringJoinChar)];break}const n=this._chartItemSpanSize||25;return(i?.length??0)*(n+n/3)}getOptimunHeightForChart(t){const e=this.getCellHeaderPaths(this.rowHeaderLevelCount,t).rowHeaderPaths;let i;for(const t in this.dataset.collectValuesBy)if("yField"===this.dataset.collectValuesBy[t].type&&!this.dataset.collectValuesBy[t].range){i=this.dataset.collectedValues[t][e.map((t=>t.value)).join(this.dataset.stringJoinChar)];break}const n=this._chartItemSpanSize||25;return(i?.length??0)*(n+n/3)}getIndicatorKeyInChartSpec(t,e){const i=this.getRawChartSpec(t,e),n=[];return i?(!1===this.indicatorsAsCol?i.series?i.series.forEach((t=>{const e=t.yField;n.push(e)})):n.push(i.yField):i.series?i.series.forEach((t=>{const e=t.xField;n.push(e)})):n.push(i.xField),n):null}getDimensionKeyInChartSpec(t,e){const i=this.getRawChartSpec(t,e),n=[];return i?(!1===this.indicatorsAsCol?n.push(i.xField??i?.series[0]?.xField):n.push(i.yField??i?.series[0]?.yField),n):null}getAxisConfigInPivotChart(t,e){return BN(t,e,this)}getRawChartSpec(t,e){return EU(t,e,this)}getChartSpec(t,e){return function(t,e,i){let n=i.getRawChartSpec(t,e);return n?(n=cd(n),n.axes=i.getChartAxes(t,e),n.padding=0,n.dataZoom=[],n):null}(t,e,this)}getChartAxes(t,e){return function(t,e,i){const n=[];if(i.indicatorsAsCol){const r=i.getIndicatorKeyInChartSpec(t,e),o=i.getRecordIndexByCol(t);r.forEach(((r,s)=>{qu(r)&&(r=r[0]);const a=RN(t,e,0===s?"bottom":"top",i),l=i.dataset.collectedValues[r+(a?"_align":"")]?i.dataset.collectedValues[r+(a?"_align":"")]:i.dataset.collectedValues[r],h=l?.[i.getColKeysPath()[o][Math.max(0,i.columnHeaderLevelCount-1-i.topAxesCount)]]??{min:0,max:1},c=MN(t,e,0===s?"bottom":"top",i);c?.zero&&(h.min=Math.min(h.min,0),h.max=Math.max(h.max,0)),n.push(fd({range:h},c,{type:"linear",orient:0===s?"bottom":"top",label:{visible:!1},title:{visible:!1},domainLine:{visible:!1},seriesIndex:s,height:-1,sync:{axisId:PU}}))}));let s=i.getDimensionKeyInChartSpec(i.rowHeaderLevelCount,t)[0];qu(s)&&(s=s[0]);const a=i.dataset.cacheCollectedValues[s]||i.dataset.collectedValues[s]||[],l=i.getRecordIndexByRow(e),h=i.getRowKeysPath()[l],c=a[h[h.length-1]],u=MN(t,e,"left",i);n.push(fd({domain:Array.from(c)},u,{type:"band",orient:"left",label:{visible:!1,space:0},domainLine:{visible:!1},tick:{visible:!1},subTick:{visible:!1},title:{visible:!1},width:-1}))}else{const r=i.getIndicatorKeyInChartSpec(t,e),o=i.getRecordIndexByRow(e);r.forEach(((r,s)=>{qu(r)&&(r=r[0]);const a=RN(t,e,0===s?"left":"right",i),l=i.dataset.collectedValues[r+(a?"_align":"")]?i.dataset.collectedValues[r+(a?"_align":"")]:i.dataset.collectedValues[r],h=l?.[i.getRowKeysPath()[o][Math.max(0,i.rowHeaderLevelCount-1-i.leftAxesCount)]]??{min:0,max:1},c=MN(t,e,0===s?"left":"right",i);c?.zero&&(h.min=Math.min(h.min,0),h.max=Math.max(h.max,0)),n.push(fd({range:h},c,{type:"linear",orient:0===s?"left":"right",label:{visible:!1},title:{visible:!1},domainLine:{visible:!1},seriesIndex:s,width:-1,sync:{axisId:PU}}))}));let s=i.getDimensionKeyInChartSpec(t,i.columnHeaderLevelCount)[0];qu(s)&&(s=s[0]);const a=i.dataset.cacheCollectedValues[s]||i.dataset.collectedValues[s]||[],l=i.getRecordIndexByCol(t),h=i.getColKeysPath()[l],c=a?.[h[h.length-1]]??[],u=MN(t,e,"bottom",i);n.push(fd({domain:Array.from(c)},u,{type:"band",orient:"bottom",visible:!0,label:{visible:!1,space:0},domainLine:{visible:!1},tick:{visible:!1},subTick:{visible:!1},title:{visible:!1},height:-1}))}return n}(t,e,this)}getChartDataId(t,e){return HU(t,e,this)}isEmpty(t,e){return!!this._table.isPivotChart()&&(t>this.colCount-this.rightFrozenColCount-1||e>this.rowCount-this.bottomFrozenRowCount-1||!(!this.hasTwoIndicatorAxes||!this.indicatorsAsCol||e!==this.columnHeaderLevelCount-1))}release(){const t=this._table._getActiveChartInstance();t?.release(),this._indicatorObjects.forEach((t=>{t.chartInstance?.release()}))}}class jU{dataConfig;records;tree={};colFlatKeys={};rowFlatKeys={};stringJoinChar=String.fromCharCode(0);rowsIsTotal=[];colsIsTotal=[];colGrandTotalLabel;colSubTotalLabel;rowGrandTotalLabel;rowSubTotalLabel;constructor(t,e){if(this.dataConfig=t,e){this.records=e;const t="undefined"!=typeof window?window.performance.now():0;this.setRecords(e);const i="undefined"!=typeof window?window.performance.now():0;console.log("processRecords:",i-t)}delete this.rowFlatKeys,delete this.colFlatKeys}setRecords(t){this.processRecords()}processRecords(){for(let t=0,e=this.records.length;t<e;t++){const e=this.records[t];this.processRecord(e)}}processRecord(t){const e=[],i=[];for(let e=0,n=this.dataConfig.rows.length;e<n;e++){const n=this.dataConfig.rows[e];void 0!==t[n]&&n!==this.dataConfig.indicatorDimensionKey&&i.push(t[n])}for(let i=0,n=this.dataConfig.columns.length;i<n;i++){const n=this.dataConfig.columns[i];void 0!==t[n]&&n!==this.dataConfig.indicatorDimensionKey&&e.push(t[n])}this.dataConfig.indicators.forEach((n=>{const r=t[n];void 0!==r&&(this.dataConfig.indicatorsAsCol?e.push(n):i.push(n));const o=i.join(this.stringJoinChar),s=e.join(this.stringJoinChar);0!==i.length&&(this.rowFlatKeys[o]||(this.rowFlatKeys[o]=1)),0!==e.length&&(this.colFlatKeys[s]||(this.colFlatKeys[s]=1)),0===e.length&&0===i.length||(this.tree[o]||(this.tree[o]={}),void 0!==r&&(this.tree[o][s]={value:r,record:t},this.dataConfig.indicatorsAsCol?e.pop():i.pop()))}))}getTreeNode(t=[],e=[],i){let n,r;if("string"==typeof t)n=t;else{let e=!1;t.map(((n,r)=>{n===i&&(t.splice(r,1),e=!0)})),e&&t.push(i),n=t.join(this.stringJoinChar)}if("string"==typeof e)r=e;else{let t=!1;e.map(((n,r)=>{n===i&&(e.splice(r,1),t=!0)})),t&&e.push(i),r=e.join(this.stringJoinChar)}return this.tree?.[n]?.[r]??void 0}}class NU{className="Aggregator";isRecord=!0;records=[];type;field;formatFun;_formatedValue;constructor(t,e,i){this.field=t,this.formatFun=e,this.isRecord=i??this.isRecord}formatValue(){return this._formatedValue||(this.formatFun?this._formatedValue=this.formatFun(this.value()):this._formatedValue=this.value()),this._formatedValue}reset(){this.records=[]}}class GU extends NU{type=Yc.RECORD;isRecord=!0;push(t){this.isRecord&&("Aggregator"===t.className?this.records.push(...t.records):this.records.push(t))}value(){return this.records}reset(){this.records=[]}}class VU extends NU{type=Yc.SUM;sum=0;push(t){this.isRecord&&("Aggregator"===t.className?this.records.push(...t.records):this.records.push(t)),"Aggregator"===t.className?this.sum+=t.value():isNaN(parseFloat(t[this.field]))||(this.sum+=parseFloat(t[this.field]))}value(){return this.sum}reset(){this.records=[],this.sum=0}}class UU extends NU{type=Yc.COUNT;count=0;push(t){this.isRecord&&("Aggregator"===t.className?this.records.push(...t.records):this.records.push(t)),"Aggregator"===t.className?this.count+=t.value():this.count++}value(){return this.count}reset(){this.records=[],this.count=0}}class KU extends NU{type=Yc.AVG;sum=0;count=0;push(t){this.isRecord&&("Aggregator"===t.className?this.records.push(...t.records):this.records.push(t)),"Aggregator"===t.className&&t.type===Yc.AVG?(this.sum+=t.sum,this.count+=t.count):isNaN(parseFloat(t[this.field]))||(this.sum+=parseFloat(t[this.field]),this.count++)}value(){return this.sum/this.count}reset(){this.records=[],this.sum=0,this.count=0}}class $U extends NU{type=Yc.MAX;max=Number.MIN_SAFE_INTEGER;push(t){this.isRecord&&("Aggregator"===t.className?this.records.push(...t.records):this.records.push(t)),"Aggregator"===t.className?this.max=t.max>this.max?t.max:this.max:"number"==typeof t?this.max=t>this.max?t:this.max:"number"==typeof t[this.field]?this.max=t[this.field]>this.max?t[this.field]:this.max:isNaN(t[this.field])||(this.max=parseFloat(t[this.field])>this.max?parseFloat(t[this.field]):this.max)}value(){return this.max}reset(){this.records=[],this.max=Number.MIN_SAFE_INTEGER}}class XU extends NU{type=Yc.MIN;min=Number.MAX_SAFE_INTEGER;isRecord=!1;push(t){this.isRecord&&("Aggregator"===t.className?this.records.push(...t.records):this.records.push(t)),"Aggregator"===t.className?this.min=t.min<this.min?t.min:this.min:"number"==typeof t?this.min=t<this.min?t:this.min:"number"==typeof t[this.field]&&(this.min=t[this.field]<this.min?t[this.field]:this.min)}value(){return this.min}reset(){this.records=[],this.min=Number.MAX_SAFE_INTEGER}}function YU(t,e){return t&&e?t.toString().localeCompare(e.toString(),"zh"):t?1:-1}function qU(t,e){const i=/(\d+)|(\D+)/g,n=/\d/,r=/^0/;let o,s,a,l,h=0,c=0;if(null!==e&&null===t)return-1;if(null!==t&&null===e)return 1;if("number"==typeof t&&isNaN(t))return-1;if("number"==typeof e&&isNaN(e))return 1;if(h=+t,c=+e,h<c)return-1;if(h>c)return 1;if("number"==typeof t&&"number"!=typeof e)return-1;if("number"==typeof e&&"number"!=typeof t)return 1;if("number"==typeof t&&"number"==typeof e)return 0;if(isNaN(c)&&!isNaN(h))return-1;if(isNaN(h)&&!isNaN(c))return 1;if(o=String(t),a=String(e),o===a)return 0;if(!n.test(o)||!n.test(a))return o>a?1:-1;for(o=o.match(i),a=a.match(i);o.length&&a.length;)if(s=o.shift(),l=a.shift(),s!==l)return n.test(s)&&n.test(l)?s.replace(r,".0")-l.replace(r,".0"):s>l?1:-1;return o.length-a.length}function ZU(t){return 2===t.length&&td(t[0])&&td(t[1])&&t[1]>=t[0]}function JU(t){const e=t[1]-t[0],i=t[1]*t[0]<0;let n=t[0]<=0?0-t[0]:0,r=t[1]>0?t[1]-0:0;return 0===e?t[0]<0?(n=1,r=0):t[0]>0&&(n=0,r=1):(n/=e,r/=e),{total:e,negative:n,positive:r,includeZero:i,domain:t,extendable_min:!0,extendable_max:!0}}function QU(t,e){const{positive:i,negative:n,extendable_min:r,extendable_max:o,domain:s}=t,{positive:a,negative:l,extendable_min:h,extendable_max:c,domain:u}=e;if(a>0){if(!h)return!1;let t=n/i;o&&(t=n/Math.max(i,a),s[1]=-s[0]/t),u[0]=-u[1]*t}else if(l>0){if(!c)return!1;let t=i/n;r&&(t=i/Math.max(n,n),s[0]=-s[1]/t),u[1]=-u[0]*t}return!0}function tK(t,e){const{extendable_min:i,extendable_max:n,domain:r}=t,{positive:o,negative:s,domain:a}=e;return(0!==o||0!==s)&&(!(o>0&&!n)&&(!(s>0&&!i)&&(r[0]=a[0],r[1]=a[1],!0)))}function eK(t,e){const{positive:i,negative:n,extendable_max:r,domain:o}=t,{positive:s,negative:a,extendable_min:l,domain:h}=e;if(r&&l){const t=Math.max(n,a)/Math.max(i,s);o[1]=-o[0]/t,h[0]=-h[1]*t}else if(l){const t=n/i;h[0]=-h[1]*t}else{if(!r)return!1;{const t=a/s;o[1]=-o[0]/t}}return!0}function iK(t,e){const{extendable_min:i,domain:n}=t,{extendable_max:r,domain:o}=e;return!(!i||!r)&&(n[0]=-n[1],o[1]=-o[0],!0)}function nK(t,e){const i=[t.min,t.max],n=[e.min,e.max];if(!ZU(i)||!ZU(n))return;const r=JU(i),o=JU(n),{positive:s,negative:a,extendable_min:l,extendable_max:h,includeZero:c}=r,{positive:u,negative:d,extendable_min:p,extendable_max:f,includeZero:g}=o;if(0===s&&0===a){if(!tK(r,o))return}else if(0===u&&0===d){if(!tK(o,r))return}else if(c||g)if(c&&!g){if(!QU(r,o))return}else if(g&&!c){if(!QU(o,r))return}else{if(a===d)return;if(a>d){if(!eK(r,o))return}else if(!eK(o,r))return}else{if(0===a&&0===u){if(!iK(r,o))return}else if(0===d&&0===s&&!iK(o,r))return;if(0===a&&0===d)if(0===i[0]&&n[0]>0){if(!p)return;n[0]=0}else{if(!(0===n[0]&&i[0]>0))return;if(!l)return;i[0]=0}if(0===s&&0===u)if(0===i[1]&&n[1]>0){if(!f)return;n[1]=0}else{if(!(0===n[1]&&i[1]>0))return;if(!h)return;i[1]=0}}return{range1:i,range2:n}}class rK{dataConfig;pagination;records;tree={};colFlatKeys={};rowFlatKeys={};colKeys=[];rowKeys=[];rowKeysPath;colKeysPath;rowOrder="key_a_to_z";colOrder="key_a_to_z";sorted=!1;sortRules;filterRules;aggregationRules;derivedFieldRules;mappingRules;totals;indicatorStatistics=[];aggregators={};stringJoinChar=String.fromCharCode(0);rowsIsTotal=[];colsIsTotal=[];colGrandTotalLabel;colSubTotalLabel;rowGrandTotalLabel;rowSubTotalLabel;collectValuesBy;collectedValues={};cacheCollectedValues={};rows;columns;indicatorKeys;rowKeysPath_FULL;constructor(t,e,i,n,r,o,s,a){this.registerAggregators(),this.dataConfig=t,this.sortRules=this.dataConfig?.sortRules,this.aggregationRules=this.dataConfig?.aggregationRules,this.derivedFieldRules=this.dataConfig?.derivedFieldRules,this.mappingRules=this.dataConfig?.mappingRules,this.totals=this.dataConfig?.totals,this.rows=i,this.columns=n,this.indicatorKeys=r,this.colGrandTotalLabel=this.totals?.column?.grandTotalLabel??"总计",this.colSubTotalLabel=this.totals?.column?.subTotalLabel??"小计",this.rowGrandTotalLabel=this.totals?.row?.grandTotalLabel??"总计",this.rowSubTotalLabel=this.totals?.row?.subTotalLabel??"小计",this.collectValuesBy=this.dataConfig?.collectValuesBy,this.rowsIsTotal=new Array(this.rows.length).fill(!1),this.colsIsTotal=new Array(this.columns.length).fill(!1);for(let t=0,e=this.totals?.row?.subTotalsDimensions?.length;t<e;t++){const e=this.totals.row.subTotalsDimensions[t],i=this.rows.indexOf(e);this.rowsIsTotal[i]=!0}for(let t=0,e=this.totals?.column?.subTotalsDimensions?.length;t<e;t++){const e=this.totals.column.subTotalsDimensions[t],i=this.columns.indexOf(e);this.colsIsTotal[i]=!0}if(o){this.records=o;const t="undefined"!=typeof window?window.performance.now():0;this.setRecords(),this.processCollectedValuesWithSumBy(),this.processCollectedValuesWithSortBy();const e="undefined"!=typeof window?window.performance.now():0;console.log("processRecords:",e-t);const i="undefined"!=typeof window?window.performance.now():0;this.totalStatistics();const n="undefined"!=typeof window?window.performance.now():0;console.log("totalStatistics:",n-i);const r="undefined"!=typeof window?window.performance.now():0;this.sortKeys();const l="undefined"!=typeof window?window.performance.now():0;console.log("sortKeys:",l-r);const h="undefined"!=typeof window?window.performance.now():0;this.rowKeysPath_FULL=a?this.TreeToArr2(a):this.TreeToArr(this.ArrToTree(this.rowKeys,this.rowsIsTotal,this?.totals?.row?.showGrandTotals,this.rowGrandTotalLabel,this.rowSubTotalLabel)),this.colKeysPath=s?this.TreeToArr2(s):this.TreeToArr(this.ArrToTree(this.colKeys,this.colsIsTotal,this.totals?.column?.showGrandTotals,this.colGrandTotalLabel,this.colSubTotalLabel));const c="undefined"!=typeof window?window.performance.now():0;console.log("TreeToArr:",c-h),this.dataConfig?.isPivotChart&&(this.dealWithZeroAlign(),this.cacheDeminsionCollectedValues())}this.updatePagination(e)}registerAggregator(t,e){this.aggregators[t]=e}registerAggregators(){this.registerAggregator(Yc.RECORD,GU),this.registerAggregator(Yc.SUM,VU),this.registerAggregator(Yc.COUNT,UU),this.registerAggregator(Yc.MAX,$U),this.registerAggregator(Yc.MIN,XU),this.registerAggregator(Yc.AVG,KU)}setRecords(){this.processRecords()}processCollectedValuesWithSumBy(){for(const t in this.collectedValues)if(this.collectValuesBy[t]?.sumBy)for(const e in this.collectedValues[t]){const i=Object.values(this.collectedValues[t][e]).reduce(((t,e)=>e.value()>t?e.value():t),Number.MIN_SAFE_INTEGER),n=Object.values(this.collectedValues[t][e]).reduce(((t,e)=>e.value()<t?e.value():t),Number.MAX_SAFE_INTEGER);this.collectedValues[t][e]={},this.collectedValues[t][e].max=i,this.collectedValues[t][e].min=n}}processCollectedValuesWithSortBy(){for(const t in this.collectedValues)if(this.collectValuesBy[t]?.sortBy)for(const e in this.collectedValues[t])this.collectedValues[t][e]=this.collectedValues[t][e].sort(((e,i)=>this.collectValuesBy[t]?.sortBy.indexOf(e)-this.collectValuesBy[t]?.sortBy.indexOf(i)))}processRecords(){let t=!1;if(this.dataConfig?.filterRules?.length>=1&&(t=!0),Array.isArray(this.records))for(let e=0,i=this.records.length;e<i;e++){const i=this.records[e];t&&!this.filterRecord(i)||this.processRecord(i)}else for(const e in this.records)for(let i=0,n=this.records[e].length;i<n;i++){const n=this.records[e][i];t&&!this.filterRecord(n)||this.processRecord(n,e)}this.rowFlatKeys={},this.colFlatKeys={}}filterRecord(t){let e=!0;for(let i=0;i<this.dataConfig.filterRules.length;i++){const n=this.dataConfig?.filterRules[i];if(n.filterKey){const i=t[n.filterKey];if(-1===n.filteredValues.indexOf(i)){e=!1;break}}else if(!n.filterFunc?.(t)){e=!1;break}}return e}processRecord(t,e){this.derivedFieldRules?.forEach(((e,i)=>{t[e.fieldName]=e.derivedFunc(t)}));const i=[],n=[];for(let e=0,i=this.rows.length;e<i;e++){const i=this.rows[e];n.push(t[i])}for(let e=0,n=this.columns.length;e<n;e++){const n=this.columns[e];i.push(t[n])}for(const e in this.collectValuesBy)if(t[e]){this.collectedValues[e]||(this.collectedValues[e]={});const i=this.collectValuesBy[e].by.map((e=>t[e])).join(this.stringJoinChar);if(this.collectedValues[e][i]||(this.collectValuesBy[e].sumBy?this.collectedValues[e][i]={}:this.collectValuesBy[e].range?this.collectedValues[e][i]={min:Number.MAX_SAFE_INTEGER,max:Number.MIN_SAFE_INTEGER}:this.collectedValues[e][i]=[]),this.collectValuesBy[e].sumBy){const n=this.collectValuesBy[e].sumBy.map((e=>t[e])).join(this.stringJoinChar);this.collectedValues[e][i][n]||(this.collectedValues[e][i][n]=new this.aggregators[Yc.SUM](e)),this.collectedValues[e][i][n].push(t)}else if(this.collectValuesBy[e].range){const n=this.collectedValues[e][i];n.max=Math.max(t[e],n.max),n.min=Math.min(t[e],n.min)}else{const n=this.collectedValues[e][i];-1===n.indexOf(t[e])&&n.push(t[e])}}const r=n.join(this.stringJoinChar),o=i.join(this.stringJoinChar);0!==n.length&&(this.rowFlatKeys[r]||(this.rowKeys.push(n),this.rowFlatKeys[r]=1)),0!==i.length&&(this.colFlatKeys[o]||(this.colKeys.push(i),this.colFlatKeys[o]=1)),this.tree[r]||(this.tree[r]={}),this.tree[r]?.[o]||(this.tree[r][o]=[]);for(let i=0;i<this.indicatorKeys.length;i++){const n=this.getAggregatorRule(this.indicatorKeys[i]);if(this.tree[r]?.[o]?.[i]||(this.tree[r][o][i]=new this.aggregators[n?.aggregationType??Yc.SUM](n?.field??this.indicatorKeys[i],n?.formatFun)),e)this.indicatorKeys[i]===e&&this.tree[r]?.[o]?.[i].push(t);else if(n?.field)if("string"==typeof n?.field)bu(t[n?.field])&&this.tree[r]?.[o]?.[i].push(t);else{const e=n?.field.find((e=>t[e]));e&&this.tree[r]?.[o]?.[i].push(t)}else bu(t[this.indicatorKeys[i]])&&this.tree[r]?.[o]?.[i].push(t)}if(this.mappingRules)for(let e=0;e<this.indicatorKeys.length;e++){if(!this.indicatorStatistics[e]){const t=this.getAggregatorRule(this.indicatorKeys[e]);this.indicatorStatistics[e]={max:new this.aggregators[Yc.MAX](this.indicatorKeys[e]),min:new this.aggregators[Yc.MIN](this.indicatorKeys[e]),total:new this.aggregators[t?.aggregationType??Yc.SUM](t?.field??this.indicatorKeys[e],t?.formatFun)}}this.indicatorStatistics[e].max.push(this.tree[r]?.[o]?.[e].value()),this.indicatorStatistics[e].min.push(this.tree[r]?.[o]?.[e].value()),this.indicatorStatistics[e].total.push(t)}}updateSortRules(t){this.sorted=!1,this.sortRules=t,this.sortKeys(),this.rowKeysPath_FULL=this.TreeToArr(this.ArrToTree(this.rowKeys,this.rowsIsTotal,this?.totals?.row?.showGrandTotals||0===this.columns.length,this.rowGrandTotalLabel,this.rowSubTotalLabel)),this.colKeysPath=this.TreeToArr(this.ArrToTree(this.colKeys,this.colsIsTotal,this.totals?.column?.showGrandTotals||0===this.rows.length,this.colGrandTotalLabel,this.colSubTotalLabel))}updateFilterRules(t,e=!1){if(this.filterRules=t,e)this.tree={};else for(const t in this.tree)for(const e in this.tree[t])for(let i=0;i<this.tree[t][e].length;i++)this.tree[t][e][i].reset();this.collectedValues={},this.processRecords(),this.processCollectedValuesWithSumBy(),this.processCollectedValuesWithSortBy(),this.dataConfig?.isPivotChart&&this.dealWithZeroAlign()}updatePagination(t){if(this.pagination=t,bu(this.pagination?.perPageCount)&&bu(this.pagination?.currentPage)){this.pagination.perPageCount=Math.ceil(this.pagination.perPageCount/this.indicatorKeys.length)*this.indicatorKeys.length;const{perPageCount:t,currentPage:e}=this.pagination,i=Math.ceil(t*(e||0)/this.indicatorKeys.length),n=i+Math.ceil(t/this.indicatorKeys.length);this.rowKeysPath=this.rowKeysPath_FULL?.slice(i,n)}else this.rowKeysPath=this.rowKeysPath_FULL;this.pagination&&(this.pagination.totalCount=this.rowKeysPath_FULL?.length)}getAggregatorRule(t){return this.aggregationRules?.find(((e,i)=>t===e.indicatorKey))}getAggregator(t=[],e=[],i){const n=this.indicatorKeys.indexOf(i);let r,o,s;return o="string"==typeof t?t:t.join(this.stringJoinChar),s="string"==typeof e?e:e.join(this.stringJoinChar),r=this.tree[o]?.[s]?.[n],r||{className:"",push(){},value:()=>null,formatValue:()=>"",reset(){}}}sortKeys(){const t=this;if(!this.sorted){this.sorted=!0;const e=function(e,i){return t.getAggregator(e,i,"").value()};switch(this.rowOrder){case"value_a_to_z":this.rowKeys.sort((function(t,i){return qU(e(t,[]),e(i,[]))}));break;case"value_z_to_a":this.rowKeys.sort((function(t,i){return-qU(e(t,[]),e(i,[]))}));break;default:this.rowKeys.sort(this.arrSort(this.rows,!0))}switch(this.colOrder){case"value_a_to_z":this.colKeys.sort((function(t,i){return qU(e([],t),e([],i))}));break;case"value_z_to_a":this.colKeys.sort((function(t,i){return-qU(e([],t),e([],i))}));break;default:const t=this.arrSort(this.columns,!1);this.colKeys.sort(t)}}}arrSort(t,e){let i;const n=this,r=function(r){const o=[];for(let r=0,s=t.length;r<s;r++){i=t[r];let s=!1;if(n.sortRules)for(let t=0,a=n.sortRules.length;t<a;t++)n.sortRules[t].sortField===i&&(s=!0,o.push({field:i,fieldIndex:r,sortRule:n.sortRules[t],func:n.getSort(n.sortRules[t],e)}));s||o.push({field:i,fieldIndex:r,func:qU})}return o}.call(this);return function(i,o){let s,a;for(let l=0;l<r.length;l++){if(a=r[l],a.sortRule?.sortByIndicator){let r=i,l=o;a.fieldIndex<t.length-1&&(r=i.slice(0,a.fieldIndex+1),r.push(e?n.totals?.row?.subTotalLabel:n.totals?.column?.subTotalLabel),l=o.slice(0,a.fieldIndex+1),l.push(e?n.totals?.row?.subTotalLabel:n.totals?.column?.subTotalLabel)),s=a.func(r,l)}else s=a.func(i[a.fieldIndex],o[a.fieldIndex]);if(0!==s)return s*(a.sortRule?.sortType===qc.DESC?-1:1)}return 0}}getSort(t,e){const i=this;return t.sortByIndicator?(n,r)=>{const o=function(e,n){return e.length<i.rows.length&&e[e.length-1]!==i.rowSubTotalLabel&&e[e.length-1]!==i.rowGrandTotalLabel&&e.push(i.rowSubTotalLabel),n.length<i.columns.length&&n[n.length-1]!==i.colSubTotalLabel&&n[n.length-1]!==i.colGrandTotalLabel&&n.push(i.colSubTotalLabel),i.getAggregator(e,n,t.sortByIndicator).value()};return e?qU(o(n,t.query),o(r,t.query)):qU(o(t.query,n),o(t.query,r))}:t.sortBy?function(t){let e;const i={},n={};for(let r=0;r<t.length;r++)e=t[r],i[e]=r,"string"==typeof e&&(n[e.toLowerCase()]=r);return function(t,e){return null!==i[t]&&void 0!==i[t]&&null!==i[e]&&void 0!==i[e]?i[t]-i[e]:null!==i[t]&&void 0!==i[t]?-1:null!==i[e]&&void 0!==i[e]?1:null!==n[t]&&void 0!==i[t]&&null!==n[e]&&void 0!==i[e]?n[t]-n[e]:null===n[t]||void 0===i[t]||null===n[e]||void 0===i[e]?0:null!==n[t]&&void 0!==i[t]?-1:null!==n[e]&&void 0!==i[e]?1:qU(t,e)}}(t.sortBy):t.sortType?YU:t.sortFunc?t.sortFunc:qU}totalStatistics(){const t=this;if(t?.totals?.column?.showSubTotals&&t?.totals?.column?.subTotalsDimensions?.length>=1||t?.totals?.row?.showSubTotals&&t?.totals?.row?.subTotalsDimensions?.length>=1||t?.totals?.column?.showGrandTotals||t?.totals?.row?.showGrandTotals){const e=[],i=(e,i)=>{const n=i.split(this.stringJoinChar);for(let r=0,o=t.totals?.column?.subTotalsDimensions?.length;r<o;r++){const o=t.totals.column.subTotalsDimensions[r],s=t.columns.indexOf(o);if(s>=0){const r=n.slice(0,s+1);r.push(t.totals?.column?.subTotalLabel??"小计");const o=r.join(this.stringJoinChar);this.tree[e][o]||(this.tree[e][o]=[]);for(let n=0;n<this.indicatorKeys.length;n++){if(!this.tree[e][o][n]){const t=this.getAggregatorRule(this.indicatorKeys[n]);this.tree[e][o][n]=new this.aggregators[t?.aggregationType??Yc.SUM](t?.field??this.indicatorKeys[n],t?.formatFun)}this.tree[e][o][n].push(t.tree[e]?.[i]?.[n])}}}if(t.totals?.column?.showGrandTotals||0===this.rows.length){const n=t.colGrandTotalLabel;this.tree[e][n]||(this.tree[e][n]=[]);for(let r=0;r<this.indicatorKeys.length;r++){if(!this.tree[e][n][r]){const t=this.getAggregatorRule(this.indicatorKeys[r]);this.tree[e][n][r]=new this.aggregators[t?.aggregationType??Yc.SUM](t?.field??this.indicatorKeys[r],t?.formatFun)}this.tree[e][n][r].push(t.tree[e]?.[i]?.[r])}}};Object.keys(t.tree).forEach((n=>{const r=n.split(this.stringJoinChar);Object.keys(t.tree[n]).forEach((o=>{for(let i=0,s=t.totals?.row?.subTotalsDimensions?.length;i<s;i++){const s=t.totals.row.subTotalsDimensions[i],a=t.rows.indexOf(s);if(a>=0){const i=r.slice(0,a+1);i.push(t.totals?.row?.subTotalLabel??"小计");const s=i.join(this.stringJoinChar);if(this.tree[s]||(this.tree[s]={},e.push(s)),!this.tree[s][o]){this.tree[s][o]=[];for(let e=0;e<this.indicatorKeys.length;e++){if(!this.tree[s][o][e]){const t=this.getAggregatorRule(this.indicatorKeys[e]);this.tree[s][o][e]=new this.aggregators[t?.aggregationType??Yc.SUM](t?.field??this.indicatorKeys[e],t?.formatFun)}this.tree[s][o][e].push(t.tree[n]?.[o]?.[e])}}}}if(t.totals?.row?.showGrandTotals||0===this.columns.length){const i=t.rowGrandTotalLabel;this.tree[i]||(this.tree[i]={},e.push(i)),this.tree[i][o]||(this.tree[i][o]=[]);for(let e=0;e<this.indicatorKeys.length;e++){if(!this.tree[i][o][e]){const t=this.getAggregatorRule(this.indicatorKeys[e]);this.tree[i][o][e]=new this.aggregators[t?.aggregationType??Yc.SUM](t?.field??this.indicatorKeys[e],t?.formatFun)}this.tree[i][o][e].push(t.tree[n]?.[o]?.[e])}}i(n,o)}))})),e.forEach((e=>{Object.keys(t.tree[e]).forEach((t=>{i(e,t)}))}))}}ArrToTree(t,e,i,n,r){const o=[],s=this.stringJoinChar,a=new Map;if(t.forEach((t=>function(t){const i=[];let n;t.forEach(((l,h)=>{i.push(l);const c=i.join(s);let u=a.get(c);if(!u){if(u={id:c,children:[]},e[h]){let e=u.children;for(let i=h;i<t.length-1;i++){const t={id:`${c}${s}${r}`,children:[]};e.push(t),e=t.children}}a.set(c,u),n?e[h-1]?n.children.splice(n.children.length-1,0,u):n.children.push(u):o.push(u)}n=u}))}(t))),i){const t={id:n,children:[]};let i=t.children;for(let t=1;t<e.length;t++){const t={id:n,children:[]};i.push(t),i=t.children}o.push(t)}return o}TreeToArr(t){const e=[];function i(t,n){n.push(t.id),t.children.length>0?t.children?.forEach((t=>i(t,[...n]))):e.push(n)}return t.forEach((t=>i(t,[]))),e}TreeToArr2(t){const e=[];function i(t,n){n.push(n.length>0?[n[n.length-1],t.value].join(String.fromCharCode(0)):t.value),t.children?.length>0&&!t.children[0].indicatorKey?t.children?.forEach((t=>i(t,[...n]))):e.push(n)}return t.forEach((t=>i(t,[]))),e}dealWithZeroAlign(){const t=[];for(let e=0;e<this.aggregationRules.length;e++){const i=this.aggregationRules[e];qu(i.field)&&2===i.field.length&&t.push(i.field)}t.forEach((t=>{const e=t[0],i=t[1],n=this.collectedValues[e],r=this.collectedValues[i];this.collectedValues[e+"_align"]={},this.collectedValues[i+"_align"]={};const o=n||r;for(const t in o){const o=n?.[t]??{min:0,max:1},s=r?.[t]??{min:0,max:1},a=nK(o,s);if(a){const{range1:n,range2:r}=a;this.collectedValues[e+"_align"][t]={min:n[0],max:n[1]},this.collectedValues[i+"_align"][t]={min:r[0],max:r[1]}}else this.collectedValues[e+"_align"][t]={min:o.min,max:o.max},this.collectedValues[i+"_align"][t]={min:s.min,max:s.max}}}))}cacheDeminsionCollectedValues(){for(const t in this.collectValuesBy)"xField"!==this.collectValuesBy[t].type&&"yField"!==this.collectValuesBy[t].type||(this.dataConfig.dimensionSortArray?this.cacheCollectedValues[t]=oK(this.collectedValues[t],this.dataConfig.dimensionSortArray):this.cacheCollectedValues[t]=this.collectedValues[t])}}function oK(t,e){return t.sort(((t,i)=>{const n=e.indexOf(t),r=e.indexOf(i);return n<r?-1:n>r?1:0}))}class sK{type;id;x=0;y=0;width=0;height=0;marginLeft;marginRight;marginTop;marginBottom;layoutWidth;layoutHeight;dx=0;dy=0;background;constructor(t){this.id=t.id,this.marginLeft=t.marginLeft??0,this.marginRight=t.marginRight??0,this.marginTop=t.marginTop??0,this.marginBottom=t.marginBottom??0,this.background=t.background||void 0}getSize(t){this.initLayoutSize()}initLayoutSize(){this.layoutWidth=this.width+this.marginLeft+this.marginRight,this.layoutHeight=this.height+this.marginTop+this.marginBottom,this.background&&(this.layoutWidth+=2*(this.background.expandX||0),this.layoutHeight+=2*(this.background.expandY||0)),this.dx=this.marginLeft,this.dy=this.marginTop}}const aK={row:{x:"x",y:"y",width:"width",height:"height",layoutWidth:"layoutWidth",layoutHeight:"layoutHeight",widthLimit:"widthLimit",heightLimit:"heightLimit",parentX:"parentX",parentY:"parentY",dx:"dx",dy:"dy"},column:{x:"y",y:"x",width:"height",height:"width",layoutWidth:"layoutHeight",layoutHeight:"layoutWidth",widthLimit:"heightLimit",heightLimit:"widthLimit",parentX:"parentY",parentY:"parentX",dx:"dy",dy:"dx"}};class lK{width=0;height=0;y=0;x=0;children=[];addAble=!0;widthLimit=0;heightLimit=0;direction;directionKey;offsetX=0;justifyContent;alignItems;constructor(t,e,i,n){this.direction=e,this.directionKey=aK[this.direction],this.justifyContent=i,this.alignItems=n,this[this.directionKey.widthLimit]=t}add(t){t[this.directionKey.x]=this[this.directionKey.width],this[this.directionKey.width]+=t[this.directionKey.layoutWidth],this.children.push(t),this.updateHeight(t)}canAdd(t){return!(this[this.directionKey.width]+t[this.directionKey.layoutWidth]>this[this.directionKey.widthLimit])}updateHeight(t){t[this.directionKey.layoutHeight]>this[this.directionKey.height]&&(this[this.directionKey.height]=t[this.directionKey.layoutHeight])}lineFinish(){this.updateXAlign()}updateXAlign(){const t=this[this.directionKey.widthLimit]-this[this.directionKey.width];"center"===this.justifyContent?this.offsetX=t/2:"start"===this.justifyContent?this.offsetX=0:this.offsetX=t}getOffsetY(t){switch(this.alignItems){case"start":default:return 0;case"center":return(this[this.directionKey.height]-t[this.directionKey.layoutHeight])/2;case"end":return this[this.directionKey.height]-t[this.directionKey.layoutHeight]}}getContentSize(){const t={width:0,height:0};for(let e=0;e<this.children.length;e++){const i=this.children[e];let n;n="container"===i.type?i.getContentSize():{width:i.layoutWidth,height:i.layoutHeight},t[this.directionKey.height]<n[this.directionKey.height]&&(t[this.directionKey.height]=n[this.directionKey.height]),t[this.directionKey.width]+=n[this.directionKey.width]}return t}getElements(t={parentX:0,parentY:0},e=!1,i=!1){const n=[];for(let r=0;r<this.children.length;r++){const o=this.children[r];if("container"===o.type||"group-element"===o.type){const r=o.getElements({[this.directionKey.parentX]:this.offsetX+this[this.directionKey.x]+t.parentX,[this.directionKey.parentY]:this.getOffsetY(o)+this[this.directionKey.y]+t.parentY},e,i);n.push(...r)}else{if("icon"===o.type&&("mouseenter_cell"===o.cache?.visibleTime&&!e||"click_cell"===o.cache?.visibleTime&&!i))continue;o[this.directionKey.x]+=this.offsetX+this[this.directionKey.x]+t.parentX,o[this.directionKey.y]+=this.getOffsetY(o)+this[this.directionKey.y]+t.parentY,n.push(o)}}return n}}class hK extends sK{type="rect";lineWidth;cornerRadius;radius;fill;stroke;constructor(t){super(t),this.width=t.width,this.height=t.height,this.lineWidth=t.lineWidth||0,this.cornerRadius=t.cornerRadius||0,this.radius=this.cornerRadius,this.fill=t.fill||"#777",this.stroke=t.stroke||void 0,this.initLayoutSize()}}var cK=Object.freeze({__proto__:null,Circle:class extends sK{type="circle";radius;radian;lineWidth;fill;stroke;constructor(t){super(t),this.radius=t.radius,this.radian=t.radian,this.lineWidth=t.lineWidth,this.fill=t.fill,this.stroke=t.stroke,this.width=2*this.radius,this.height=2*this.radius,this.initLayoutSize(),this.dx+=this.radius,this.dy+=this.radius}},Container:class extends sK{type="container";_widthObj;_heightObj;needCalcSize=!1;direction;justifyContent;alignItems;alignContent;lines=[];currentLine;currentLineY=0;table;directionKey;showBounds;offsetY=0;isRoot;constructor(t){super(t),this.direction=t.direction||"row",this.justifyContent=t.justifyContent||"start",this.alignItems=t.alignItems||"start",this.alignContent=t.alignContent||"start",lu(t.width)?this.width=t.width:(this._widthObj=t.width,this.needCalcSize=!0),lu(t.height)?this.height=t.height:(this._heightObj=t.height,this.needCalcSize=!0),this.directionKey=aK[this.direction],this.showBounds=t.showBounds||!1,this.initLayoutSize()}add(t){if(this.needCalcSize)throw new Error("Need to specify a parent element before adding a child element when use percent size!");"container"===t.type&&t.calcSize(this.width,this.height),this.currentLine&&this.currentLine.canAdd(t)?this.currentLine.add(t):(this.currentLine&&(this.currentLine.addAble=!1,this.currentLineY+=this.currentLine[this.directionKey.height],this.currentLine.lineFinish()),this.currentLine=new lK(this[this.directionKey.width],this.direction,this.justifyContent,this.alignItems),this.currentLine[this.directionKey.y]=this.currentLineY,this.currentLine.add(t),this.lines.push(this.currentLine))}updateYAlign(){const t=this[this.directionKey.height]-this.currentLineY;"center"===this.alignContent?this.offsetY=t/2:"start"===this.alignContent?this.offsetY=0:this.offsetY=t}getSize(){const t={width:0,height:0};this.currentLine&&this.currentLine.addAble?t[this.directionKey.height]=this.currentLineY+this.currentLine[this.directionKey.height]:t[this.directionKey.height]=this.currentLineY;for(let e=0;e<this.lines.length;e++){const i=this.lines[e];t[this.directionKey.width]<i[this.directionKey.width]&&(t[this.directionKey.width]=i[this.directionKey.width])}return t}getContentSize(){const t={width:0,height:0},e={width:!0,height:!0};this.isRoot||this._heightObj||(e.height=!1,t.height=this.height),this.isRoot||this._widthObj||(e.width=!1,t.width=this.width);for(let i=0;i<this.lines.length;i++){const n=this.lines[i].getContentSize();e[this.directionKey.width]&&t[this.directionKey.width]<n[this.directionKey.width]&&(t[this.directionKey.width]=n[this.directionKey.width]),e[this.directionKey.height]&&(t[this.directionKey.height]+=n[this.directionKey.height])}return t}calcSize(t,e){this._heightObj&&(this.height=e*this._heightObj.percent/100+this._heightObj.delta,this.needCalcSize=!1,this.initLayoutSize()),this._widthObj&&(this.width=t*this._widthObj.percent/100+this._widthObj.delta,this.needCalcSize=!1,this.initLayoutSize())}getElements(t={parentX:0,parentY:0},e=!1,i=!1){this.currentLine&&this.currentLine.addAble&&(this.currentLine.addAble=!1,this.currentLineY+=this.currentLine[this.directionKey.height],this.currentLine.lineFinish()),this.updateYAlign();const n=[];if(this.background&&this.background.fill){const e=new hK({width:this.width,height:this.height,stroke:this.background.stroke??!1,fill:this.background.fill,cornerRadius:this.background.cornerRadius??0,lineWidth:this.background.lineWidth??1});e.x+=this.x+t.parentX,e.y+=this.y+t.parentY,n.push(e)}if(this.showBounds){const e=new hK({width:this.width,height:this.height,cornerRadius:0,stroke:"red",fill:"rgba(255, 0, 0, 0.2)",lineWidth:4});e.x+=this.x+t.parentX,e.y+=this.y+t.parentY,n.push(e)}for(let r=0;r<this.lines.length;r++){const o=this.lines[r];o[this.directionKey.y]+=this.offsetY;const s=o.getElements({[this.directionKey.parentX]:this.x+t.parentX,[this.directionKey.parentY]:this.y+t.parentY},e,i);n.push(...s)}return n}},GroupElement:class extends sK{type="group-element";direction;alignItems;width=0;height=0;children=[];directionKey;constructor(t){super(t),this.direction=t.direction||"row",this.alignItems=t.alignItems||"start",this.directionKey=aK[this.direction]}add(t){t.x=this.width,this.width+=t.layoutWidth,this.children.push(t),this.updateHeight(t),this.initLayoutSize()}updateHeight(t){t.layoutHeight>this.height&&(this.height=t.layoutHeight)}getOffsetY(t){switch(this.alignItems){case"start":default:return 0;case"center":return(this[this.directionKey.height]-t[this.directionKey.layoutHeight])/2;case"end":return this[this.directionKey.height]-t[this.directionKey.layoutHeight]}}getElements(t={parentX:0,parentY:0},e=!1,i=!1){const n=[];for(let r=0;r<this.children.length;r++){const o=this.children[r];"icon"===o.type&&("mouseenter_cell"===o.cache?.visibleTime&&!e||"click_cell"===o.cache?.visibleTime&&!i)||(o[this.directionKey.x]+=this[this.directionKey.dx]+this[this.directionKey.x]+t.parentX,o[this.directionKey.y]+=this.getOffsetY(o)+this[this.directionKey.dy]+this[this.directionKey.y]+t.parentY,n.push(o))}return n}},Icon:class extends sK{type="icon";svg;iconName;cursor;cache;constructor(t){if(super(t),this.iconName=t.iconName,au(this.iconName)){const t=yj()[this.iconName];t&&(this.cache=t,this.width=t.width,this.height=t.height,this.svg=t.svg,this.cursor=t.cursor)}this.width=t.width??this.width,this.height=t.height??this.height,this.svg=t.svg??this.svg,this.initLayoutSize()}},Image:class extends sK{type="image";src;cursor;cache;shape;constructor(t){super(t),this.width=t.width??this.width,this.height=t.height??this.height,this.src=t.src??this.src,this.shape=t.shape??this.shape,this.initLayoutSize()}},Rect:hK,Sector:class extends sK{type="arc";radius;startDegree=0;endDegree=360;clockWise=!0;lineWidth;fill;stroke;constructor(t){super(t),this.radius=t.radius,this.startDegree=t.startDegree,this.endDegree=t.endDegree,this.clockWise=t.clockWise,this.lineWidth=t.lineWidth,this.fill=t.fill,this.stroke=t.stroke,this.width=2*this.radius,this.height=2*this.radius,this.initLayoutSize(),this.dx+=this.radius,this.dy+=this.radius}},Text:class extends sK{type="text";text;fill;color;stroke;lineWidth;fontSize;fontFamily;fontWeight;fontVariant;fontStyle;ellipsis;maxLineWidth;textAlign;textBaseline;lineHeight;underline;lineThrough;heightLimit;lineClamp;constructor(t){super(t),this.text=t.text,this.fontSize=t.fontSize||12,this.fontFamily=t.fontFamily||"sans-serif",this.fill=t.color||t.fill||"black",this.textBaseline=t.textBaseline||"top",this.textAlign=t.textAlign||"left",t.stroke&&(this.stroke=t.stroke),t.lineWidth&&(this.lineWidth=t.lineWidth),t.fontWeight&&(this.fontWeight=t.fontWeight),t.fontVariant&&(this.fontVariant=t.fontVariant),t.fontStyle&&(this.fontStyle=t.fontStyle),t.ellipsis&&(this.ellipsis=t.ellipsis),t.maxLineWidth&&(this.maxLineWidth=t.maxLineWidth),t.lineHeight&&(this.lineHeight=t.lineHeight),t.underline&&(this.underline=t.underline),t.lineThrough&&(this.lineThrough=t.lineThrough),t.heightLimit&&(this.heightLimit=t.heightLimit),t.lineClamp&&(this.lineClamp=t.lineClamp)}getSize(t){const{width:e,height:i}=t.measureText(this.text,{fontSize:this.fontSize,fontWeight:this.fontWeight,fontFamily:this.fontFamily});this.width=e,this.height=i,this.initLayoutSize(),this.background&&(this.dx+=this.background.expandX||0,this.dy+=this.background.expandY||0)}},percentCalc:function(t,e=0){return{percent:t,delta:e}}});t.CustomLayout=cK,t.DataStatistics=RU,t.ListTable=class extends _U{showHeader=!0;constructor(t,e){t instanceof HTMLElement||(e=t,t=t.container?t.container:null),super(t,e);const i=this.internalProps;this.pagination=e.pagination,i.sortState=e.sortState,i.columns=e.columns?du(e.columns):e.header?du(e.header):[],this.showHeader=e.showHeader??!0,this.transpose=e.transpose??!1,this.refreshHeader(),e.dataSource?uj(this,e.dataSource):e.records?this.setRecords(e.records,i.sortState):this.setRecords([])}isListTable(){return!0}isPivotTable(){return!1}isPivotChart(){return!1}get sortState(){return this.internalProps.sortState}get columns(){return this.internalProps.columns}set columns(t){this.internalProps.columns=t,this.options.columns=t}updateColumns(t){this.internalProps.columns=t,this.options.columns=t,this.refreshHeader(),this.scenegraph.clearCells(),this.headerStyleCache=new Map,this.bodyStyleCache=new Map,this.scenegraph.createSceneGraph(),this.render()}get header(){return this.internalProps.columns}set header(t){this.internalProps.columns=t,this.options.header=t,this.refreshHeader(),setTimeout((()=>{this.render()}),0)}get transpose(){return this.internalProps.transpose??!1}set transpose(t){this.internalProps.transpose!==t&&(this.internalProps.transpose=t,this.options.transpose=t,this.internalProps.layoutMap&&(this.internalProps.layoutMap.transpose=t,this.refreshRowColCount(),this._resetFrozenColCount(),this.render()))}getCellValue(t,e){const i=this;if(i.internalProps.layoutMap.isHeader(t,e)){const{title:n}=i.internalProps.layoutMap.getHeader(t,e);return"function"==typeof n?n():n}const{field:n,fieldFormat:r}=i.internalProps.layoutMap.getBody(t,e);return i.getFieldData(r||n,t,e)}getCellOriginValue(t,e){const i=this;if(i.internalProps.layoutMap.isHeader(t,e)){const{title:n}=i.internalProps.layoutMap.getHeader(t,e);return"function"==typeof n?n():n}const{field:n}=i.internalProps.layoutMap.getBody(t,e);return i.getFieldData(n,t,e)}getRecordIndexByRow(t,e){const{layoutMap:i}=this.internalProps;return i.getRecordIndexByRow(t,e)}getCellOriginRecord(t,e){const i=this,n=i.getRecordIndexByRow(t,e);if(n>-1)return i.dataSource.get(n)}_canResizeColumn(t,e){const i=super._canResizeColumn(t,e);if(i&&!this.transpose){const e=this.internalProps.layoutMap.getBody(t,this.columnHeaderLevelCount);if(e?.disableColumnResize)return!1}return i}updateOption(t,e=!1){const i=this.internalProps;return super.updateOption(t),this.pagination=t.pagination,this.showHeader=t.showHeader??!0,i.columns=t.columns?du(t.columns):t.header?du(t.header):[],this.transpose=t.transpose??!1,this.refreshHeader(),i.releaseList&&(i.releaseList.forEach((t=>t?.release?.())),i.releaseList=null),t.dataSource?uj(this,t.dataSource):t.records?this.setRecords(t.records,t.sortState):(this._resetFrozenColCount(),this.scenegraph.createSceneGraph(),this.render()),new Promise((t=>{setTimeout(t,0)}))}updatePagination(t){this.pagination&&("number"==typeof t.currentPage&&t.currentPage>=0&&(this.pagination.currentPage=t.currentPage),t.perPageCount&&(this.pagination.perPageCount=t.perPageCount||this.pagination.perPageCount),this.scenegraph.clearCells(),this.dataSource.updatePagination(this.pagination),this.refreshRowColCount(),this.scenegraph.createSceneGraph(),this.render())}refreshHeader(){const t=this,e=t.internalProps,i=t.transpose,n=t.showHeader;e.headerEvents&&e.headerEvents.forEach((e=>t.off(e)));const r=e.layoutMap=new kU(this,e.columns??[],n,t.options.hierarchyIndent);if(r.transpose=i,!i)for(let e=0;e<r.columnWidths.length;e++){const{width:i,minWidth:n,maxWidth:o}=r.columnWidths?.[e]??{};i&&("string"==typeof i&&"auto"!==i||"number"==typeof i&&i>0)&&t.setColWidth(e,i),n&&("number"==typeof n&&n>0||"string"==typeof n)&&t.setMinColWidth(e,n),o&&("number"==typeof o&&o>0||"string"==typeof o)&&t.setMaxColWidth(e,o)}this.refreshRowColCount()}refreshRowColCount(){const t=this,{layoutMap:e}=t.internalProps;e&&(e.recordsCount=t.internalProps.dataSource?.length??0,t.transpose?(t.rowCount=e.rowCount??0,t.colCount=(t.internalProps.dataSource?.length??0)*e.bodyRowCount+e.headerLevelCount,t.frozenRowCount=0,t.frozenColCount=e.headerLevelCount,t.rightFrozenColCount=this.options.rightFrozenColCount??0):(t.colCount=e.colCount??0,t.rowCount=(t.internalProps.dataSource?.length??0)*e.bodyRowCount+e.headerLevelCount,t.frozenColCount=t.options.frozenColCount??0,t.frozenRowCount=e.headerLevelCount,t.bottomFrozenRowCount=this.options.bottomFrozenRowCount??0,t.rightFrozenColCount=this.options.rightFrozenColCount??0))}getFieldData(t,e,i){if(null===t)return null;const n=this;if(n.internalProps.layoutMap.isHeader(e,i))return null;const r=n.getRecordIndexByRow(e,i);return n.internalProps.dataSource.getField(r,t)}moveHeaderPosition(t,e){const i=this.internalProps.layoutMap.moveHeaderPosition(t,e);if(i){if("column"===i.moveType){if(this.colWidthsMap.adjustOrder(i.sourceIndex,i.targetIndex,i.moveSize),!this.transpose){this.colWidthsLimit={};for(let t=0;t<this.internalProps.layoutMap.columnWidths.length;t++){const{minWidth:e,maxWidth:i}=this.internalProps.layoutMap.columnWidths?.[t]??{};e&&("number"==typeof e&&e>0||"string"==typeof e)&&this.setMinColWidth(t,e),i&&("number"==typeof i&&i>0||"string"==typeof i)&&this.setMaxColWidth(t,i)}}const t=Math.min(i.sourceIndex,i.targetIndex),e=Math.max(i.sourceIndex,i.targetIndex);for(let i=t;i<=e;i++)this._clearColRangeWidthsMap(i)}else{const t=Math.min(i.sourceIndex,i.targetIndex),e=Math.max(i.sourceIndex,i.targetIndex);for(let i=t;i<=e;i++)this._clearRowRangeHeightsMap(i)}return!0}return!1}getCellAddress(t,e){let i;for(let e=0;e<this.internalProps.records.length;e++){const n=this.internalProps.records[e];if("function"==typeof t)t(n)&&(i=e);else{let r=!0;for(const e in t)if(n[e]!==t[e]){r=!1;break}r&&(i=e)}if(bu(i))break}const n=this.getCellRangeByField(e,i);if(n)return{row:n.start.row,col:n.start.col}}getCellRangeByField(t,e){const{layoutMap:i}=this.internalProps,n=i.columnObjects.find((e=>e.field===t));if(n){const t=i.getBodyLayoutRangeById(n.id);let r;return bu(e)&&(r=i.getRecordStartRowByRecordIndex(e)),this.transpose?{start:{row:t.start.row,col:bu(r)?r+t.start.col:void 0},end:{row:t.end.row,col:bu(r)?r+t.end.col:void 0}}:{start:{col:t.start.col,row:bu(r)?r+t.start.row:void 0},end:{col:t.end.col,row:bu(r)?r+t.end.row:void 0}}}return null}getHierarchyState(t,e){if(!this.getBodyColumnDefine(t,e).tree)return Xc.none;const i=this.getRecordIndexByRow(t,e);return this.dataSource.getHierarchyState(i)}toggleHierarchyState(t,e){const i=this.getHierarchyState(t,e);i===Xc.expand?this.fireListeners(sf.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:Xc.collapse}):i===Xc.collapse&&this.fireListeners(sf.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:Xc.expand,originData:this.getCellOriginRecord(t,e)});const n=this.getRecordIndexByRow(t,e),r=this.dataSource.toggleHierarchyState(n),o=this.internalProps.layoutMap.toggleHierarchyState(r);this.refreshRowColCount(),this.clearCellStyleCache(),this.scenegraph.updateHierarchyIcon(t,e),this.scenegraph.updateRow(o.removeCellPositions,o.addCellPositions)}hasHierarchyTreeHeader(){return(this.options.columns??this.options.header)?.some(((t,e)=>t.tree))}getMenuInfo(t,e,i){return{field:this.getHeaderField(t,e),value:this.getCellValue(t,e),cellLocation:this.getCellLocation(t,e)}}_getSortFuncFromHeaderOption(t,e,i){if(t||(t=this.internalProps.columns),e&&t&&t.length>0)for(let n=0;n<t.length;n++){const r=t[n];if((i&&i===r.fieldKey||!i&&r.field===e)&&r.sort&&"function"==typeof r.sort)return r.sort;if(r.columns){const t=this._getSortFuncFromHeaderOption(r.columns,e,i);if(t)return t}}}updateSortState(t,e=!0){if(t)this.internalProps.sortState=t;else if(this.internalProps.sortState)if(Array.isArray(this.internalProps.sortState))for(let t=0;t<this.internalProps.sortState.length;t++){this.internalProps.sortState[t].order="normal"}else this.internalProps.sortState.order="normal";let i,n,r;if(Array.isArray(this.internalProps.sortState)?({order:i,field:n,fieldKey:r}=this.internalProps.sortState?.[0]):({order:i,field:n,fieldKey:r}=this.internalProps.sortState),n&&e){const t=this._getSortFuncFromHeaderOption(this.internalProps.columns,n,r);let e;e=r?this.internalProps.layoutMap.headerObjects.find((t=>t&&t.fieldKey===r)):this.internalProps.layoutMap.headerObjects.find((t=>t&&t.field===n)),e?.define?.sort&&(this.dataSource.sort(e.field,i,t),this.scenegraph.sortCell())}this.stateManeger.updateSortState(t)}},t.PivotChart=class extends _U{pivotSortState;dataset;_selectedDataItemsInChart=[];_selectedDimensionInChart=[];_chartEventMap={};_axes;constructor(t,e){if(t instanceof HTMLElement||(e=t,t=t.container?t.container:null),super(t,e),e.layout&&Object.assign(e,e.layout),this.setCustomStateNameToSpec(),this.internalProps.columnResizeType=e.columnResizeType??"column",this.internalProps.dataConfig={isPivotChart:!0},this._axes=qu(e.axes)?e.axes:[],e.rows||e.columns){const t=e.rows.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[]),i=e.columns.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[]),n=e.indicators?.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.indicatorKey),t)),[])??[];this.internalProps.dataConfig.collectValuesBy=this._generateCollectValuesConfig(i,t),this.internalProps.dataConfig.aggregationRules=this._generateAggregationRules(),this.internalProps.dataConfig.dimensionSortArray=this._getDimensionSortArray(),this.dataset=new rK(this.internalProps.dataConfig,null,t,i,n,e.records,e.columnTree,e.rowTree)}this.refreshHeader(),e.dataSource?uj(this,e.dataSource):e.records?this.setRecords(e.records,this.internalProps.sortState):this.setRecords([])}static get EVENT_TYPE(){return JG}get pivotChartAxes(){return this._axes}isListTable(){return!1}isPivotTable(){return!0}isPivotChart(){return!0}_canResizeColumn(t,e){const i=super._canResizeColumn(t,e);if(i&&!this.internalProps.layoutMap.indicatorsAsCol){const e=this.internalProps.layoutMap.getBody(t,this.columnHeaderLevelCount);if(e?.disableColumnResize)return!1}return i}updateOption(t,e=!1){const i=this.internalProps;if(super.updateOption(t),this.setCustomStateNameToSpec(),i.columnResizeType=t.columnResizeType??"column",i.dataConfig={},this._axes=qu(t.axes)?t.axes:[],t.rows||t.columns){const e=t.rows.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[]),i=t.columns.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[]),n=t.indicators.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.indicatorKey),t)),[]);this.internalProps.dataConfig.collectValuesBy=this._generateCollectValuesConfig(i,e),this.internalProps.dataConfig.aggregationRules=this._generateAggregationRules(),this.dataset=new rK(this.internalProps.dataConfig,null,e,i,n,t.records??this.internalProps.records,t.columnTree,t.rowTree)}return this.refreshHeader(),i.releaseList&&(i.releaseList.forEach((t=>t?.release?.())),i.releaseList=null),t.dataSource?uj(this,t.dataSource):t.records?this.setRecords(t.records,void 0):(this._resetFrozenColCount(),this.scenegraph.createSceneGraph(),this.render()),new Promise((t=>{setTimeout(t,0)}))}updatePagination(){}refreshHeader(){const t=this.internalProps;t.headerEvents&&t.headerEvents.forEach((t=>this.off(t))),t.layoutMap=new WU(this,this.dataset);for(let e=0;e<t.layoutMap.columnWidths.length;e++){const{width:i,minWidth:n,maxWidth:r}=t.layoutMap.columnWidths?.[e]??{};i&&("string"==typeof i&&"auto"!==i||"number"==typeof i&&i>0)&&this.setColWidth(e,i),n&&("number"==typeof n&&n>0||"string"==typeof n)&&this.setMinColWidth(e,n),r&&("number"==typeof r&&r>0||"string"==typeof r)&&this.setMaxColWidth(e,r)}this.refreshRowColCount()}refreshRowColCount(){const t=this,{layoutMap:e}=t.internalProps;e&&(t.colCount=e.colCount??0,t.rowCount=e.rowCount??0,t.frozenColCount=e.rowHeaderLevelCount,t.frozenRowCount=e.headerLevelCount,t.bottomFrozenRowCount=e?.bottomFrozenRowCount??0,t.rightFrozenColCount=e?.rightFrozenColCount??0)}_getSortFuncFromHeaderOption(t,e,i){}syncHierarchyState(t,e){t.value===e.value&&t.dimensionKey===e.dimensionKey&&(e.hierarchyState=e.hierarchyState??(e?.children?t.hierarchyState:void 0),e?.children?.forEach(((e,i)=>{t?.children?.[i]&&e&&this.syncHierarchyState(t.children[i],e)})))}getRecordIndexByRow(t){const{layoutMap:e}=this.internalProps;return e.getRecordIndexByRow(t)}getRecordIndexByCol(t){const{layoutMap:e}=this.internalProps;return e.getRecordIndexByCol(t)}getFieldData(t,e,i){if(null==t)return null;const n=this;if(n.internalProps.layoutMap.isHeader(e,i))return null;const r=this.getRecordIndexByRow(i),o=this.getRecordIndexByCol(e),s=n.dataSource?.getField(r,o);if("string"!=typeof t){return fW({dataValue:s,...n.internalProps.layoutMap.getCellHeaderPaths(e,i)},t,of)}return s}getCellValue(t,e){if(this.internalProps.layoutMap.isHeader(t,e)){const{title:i,fieldFormat:n}=this.internalProps.layoutMap.getHeader(t,e);return"function"==typeof n?n(i):i}if(this.dataset){const i=this.dataset.colKeysPath[this.internalProps.layoutMap.getRecordIndexByCol(t)]??[],n=this.dataset.rowKeysPath[this.internalProps.layoutMap.getRecordIndexByRow(e)]??[],r=this.dataset.getAggregator(n[n.length-1],i[i.length-1],this.internalProps.layoutMap.getIndicatorKey(t,e));return r.value?r.value():void 0}const{field:i,fieldFormat:n}=this.internalProps.layoutMap.getBody(t,e);return this.getFieldData(n||i,t,e)}getCellOriginValue(t,e){const i=this;if(i.internalProps.layoutMap.isHeader(t,e)){const{title:n}=i.internalProps.layoutMap.getHeader(t,e);return"function"==typeof n?n():n}if(this.dataset){const i=this.dataset.colKeysPath[this.internalProps.layoutMap.getRecordIndexByCol(t)]??[],n=this.dataset.rowKeysPath[this.internalProps.layoutMap.getRecordIndexByRow(e)]??[],r=this.dataset.getAggregator(n[n.length-1],i[i.length-1],this.internalProps.layoutMap.getIndicatorKey(t,e));return r.value?r.value():void 0}const{field:n}=i.internalProps.layoutMap.getBody(t,e);return i.getFieldData(n,t,e)}getCellOriginRecord(t,e){if(!this.internalProps.layoutMap.isHeader(t,e)&&this.dataset){const i=this.dataset.colKeysPath[this.internalProps.layoutMap.getRecordIndexByCol(t)]??[],n=this.dataset.rowKeysPath[this.internalProps.layoutMap.getRecordIndexByRow(e)]??[];return this.dataset.getAggregator(n[n.length-1],i[i.length-1],this.internalProps.layoutMap.getIndicatorKey(t,e)).records}}updateSortRules(t){this.internalProps.dataConfig.sortRules=t,this.dataset.updateSortRules(t),this.internalProps.layoutMap.updateDataset(this.dataset),this.render()}updatePivotSortState(t){for(let e=0;e<t.length;e++){const{dimensions:i,order:n}=t[e],r=this.internalProps.layoutMap.getPivotCellAdress(i);r&&this.pivotSortState.push({col:r.col,row:r.row,order:n})}}getPivotSortState(t,e){if(!this.pivotSortState)return;const i=this.getCellRange(t,e);for(let t=0;t<this.pivotSortState.length;t++){const{col:e,row:n,order:r}=this.pivotSortState[t];if(qp(i,e,n))return r}}moveHeaderPosition(t,e){const i=this.internalProps.layoutMap.moveHeaderPosition(t,e);if(i){if("column"===i.moveType){if(this.options.records?.[0]?.constructor===Array)for(let t=0;t<this.internalProps.records.length;t++){const e=this.internalProps.records[t].splice(i.sourceIndex-this.rowHeaderLevelCount,i.moveSize);e.unshift(i.targetIndex-this.rowHeaderLevelCount,0),Array.prototype.splice.apply(this.internalProps.records[t],e)}this.colWidthsMap.adjustOrder(i.sourceIndex,i.targetIndex,i.moveSize);for(let t=0;t<this.internalProps.layoutMap.columnWidths.length;t++){const{minWidth:e,maxWidth:i}=this.internalProps.layoutMap.columnWidths?.[t]??{};e&&("number"==typeof e&&e>0||"string"==typeof e)&&this.setMinColWidth(t,e),i&&("number"==typeof i&&i>0||"string"==typeof i)&&this.setMaxColWidth(t,i)}}else if("row"===i.moveType){if(this.options.records?.[0]?.constructor===Array){const t=this.internalProps.records.splice(i.sourceIndex-this.columnHeaderLevelCount,i.moveSize);t.unshift(i.targetIndex-this.columnHeaderLevelCount,0),Array.prototype.splice.apply(this.internalProps.records,t)}this.rowHeightsMap.adjustOrder(i.sourceIndex,i.targetIndex,i.moveSize)}return!0}return!1}toggleHierarchyState(t,e){const i=this.getHierarchyState(t,e);i===Xc.expand?this.fireListeners(JG.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:Xc.collapse}):i===Xc.collapse&&this.fireListeners(JG.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:Xc.expand,originData:this.getCellOriginRecord(t,e)});const n=this.internalProps.layoutMap.toggleHierarchyState(t,e);this.refreshRowColCount(),this.clearCellStyleCache(),this.scenegraph.updateHierarchyIcon(t,e),this.scenegraph.updateRow(n.removeCellPositions,n.addCellPositions)}getHeaderCellAddressByPath(t){return this.internalProps.layoutMap.getPivotCellAdress(t)}getCellAddressByHeaderPaths(t){return this.internalProps.layoutMap.getCellAdressByHeaderPath(t)}getHeaderPathByXY(t){let e;e=t?this.getCellAt(t.x+this.getFrozenColsWidth()+this.scrollLeft+1,t.y+this.getFrozenRowsHeight()+this.scrollTop+1):this.getCellAt(this.getFrozenColsWidth()+this.scrollLeft+1,this.getFrozenRowsHeight()+this.scrollTop+1);return this.internalProps.layoutMap.getCellHeaderPaths(e.col,e.row)}getHierarchyState(t,e){return this._getHeaderLayoutMap(t,e)?.hierarchyState}hasHierarchyTreeHeader(){return"tree"===this.internalProps.layoutMap.rowHierarchyType}getMenuInfo(t,e,i){const n=this.internalProps.layoutMap.getPivotDimensionInfo(t,e);return{dimensionKey:n[n.length-1].dimensionKey,value:this.getCellValue(t,e),cellLocation:this.getCellLocation(t,e),isPivotCorner:this.isCornerHeader(t,e)}}_generateCollectValuesConfig(t,e){const i=this.options,n={};for(let r=0,o=i.indicators.length;r<o;r++)if("string"!=typeof i.indicators[r]&&i.indicators[r].chartSpec)if(!1===i.indicatorsAsCol){const o=i.indicators[r];if(n[o.indicatorKey]={by:e,range:!0,sumBy:!1!==o.chartSpec?.stack&&t.concat(o.chartSpec?.xField)},o.chartSpec.series)o.chartSpec.series.forEach((i=>{const r="string"==typeof i.xField?i.xField:i.xField[0];n[r]={by:t,type:"horizontal"!==i.direction?"xField":void 0,range:"horizontal"===i.direction,sortBy:"horizontal"!==i.direction?i?.data?.fields?.[r]?.domain??o.chartSpec?.data?.fields?.[r]?.domain:void 0};const s=i.yField;n[s]={by:e,range:"horizontal"!==i.direction,sumBy:!1!==i.stack&&t.concat(r),sortBy:"horizontal"===i.direction?i?.data?.fields?.[s]?.domain??o.chartSpec?.data?.fields?.[s]?.domain:void 0}}));else{const s="string"==typeof o.chartSpec.xField?o.chartSpec.xField:o.chartSpec.xField[0];n[s]={by:t,type:"horizontal"!==o.chartSpec.direction?"xField":void 0,range:"horizontal"===o.chartSpec.direction,sortBy:"horizontal"!==o.chartSpec.direction?o.chartSpec?.data?.fields?.[s]?.domain:void 0};const a=o.chartSpec.yField;n[a]={by:e,range:"horizontal"!==i.indicators[r].chartSpec.direction,sumBy:!1!==o.chartSpec.stack&&t.concat(s),sortBy:"horizontal"===o.chartSpec.direction?o.chartSpec?.data?.fields?.[a]?.domain:void 0}}}else{const o=i.indicators[r];if(n[o.indicatorKey]={by:t,range:!0,sumBy:!1!==o.chartSpec?.stack&&e.concat(o.chartSpec?.yField)},o.chartSpec.series)o.chartSpec.series.forEach((i=>{const r="string"==typeof i.yField?i.yField:i.yField[0];n[r]={by:e,type:"horizontal"===i.direction?"yField":void 0,range:"horizontal"!==i.direction,sortBy:"horizontal"===i.direction?i?.data?.fields?.[r]?.domain??o.chartSpec?.data?.fields?.[r]?.domain:void 0};const s=i.xField;n[s]={by:t,range:"horizontal"===i.direction,sumBy:!1!==i.stack&&e.concat(r),sortBy:"horizontal"!==i.direction?i?.data?.fields?.[s]?.domain??o.chartSpec?.data?.fields?.[s]?.domain:void 0}}));else{const s="string"==typeof o.chartSpec.yField?o.chartSpec.yField:o.chartSpec.yField[0];n[s]={by:e,type:"horizontal"===o.chartSpec.direction?"yField":void 0,range:"horizontal"!==o.chartSpec.direction,sortBy:"horizontal"===o.chartSpec.direction?o.chartSpec?.data?.fields?.[s]?.domain:void 0};const a=o.chartSpec.xField;n[a]={by:t,range:"horizontal"===i.indicators[r].chartSpec.direction,sumBy:!1!==o.chartSpec.stack&&e.concat(s),sortBy:"horizontal"!==o.chartSpec.direction?o.chartSpec?.data?.fields?.[a]?.domain:void 0}}}return n}_generateAggregationRules(){const t=[];return this.options.indicators.forEach((e=>{if("string"==typeof e)t.push({indicatorKey:e,field:e,aggregationType:Yc.RECORD});else if(e.chartSpec?.series){const i=[];e.chartSpec?.series.forEach((t=>{const e=!1===this.options.indicatorsAsCol?t.yField:t.xField;-1===i.indexOf(e)&&i.push(e)})),t.push({indicatorKey:e.indicatorKey,field:i,aggregationType:Yc.RECORD})}else{const i=!1===this.options.indicatorsAsCol?e.chartSpec.yField:e.chartSpec.xField;t.push({indicatorKey:e.indicatorKey,field:i??e.indicatorKey,aggregationType:Yc.RECORD})}})),t}setCustomStateNameToSpec(){const t=t=>{t.bar?.state?.selected&&(t.bar.state.vtable_selected=t.bar.state.selected,t.bar.state.vtable_selected_reverse=t.bar.state.selected_reverse,delete t.bar.state.selected,delete t.bar.state.selected_reverse),t.point?.state?.selected&&(t.point.state.vtable_selected=t.point.state.selected,t.point.state.vtable_selected_reverse=t.point.state.selected_reverse,delete t.point.state.selected,delete t.point.state.selected_reverse),t.line?.state?.selected&&(t.line.state.vtable_selected=t.line.state.selected,t.line.state.vtable_selected_reverse=t.line.state.selected_reverse,delete t.line.state.selected,delete t.line.state.selected_reverse),t.area?.state?.selected&&(t.area.state.vtable_selected=t.area.state.selected,t.area.state.vtable_selected_reverse=t.area.state.selected_reverse,delete t.area.state.selected,delete t.area.state.selected_reverse)};this.options.indicators.forEach((e=>{if(e.chartSpec){const i=e.chartSpec;i.series?i.series.forEach((e=>{t(e)})):t(i)}}))}onVChartEvent(t,e,i){this._chartEventMap[t]="function"==typeof e?{callback:e}:{callback:i,query:e}}offVChartEvent(t){delete this._chartEventMap[t]}_bindChartEvent(t){if(t)for(const e in this._chartEventMap)this._chartEventMap[e].query?t.on(e,this._chartEventMap[e].query,this._chartEventMap[e].callback):t.on(e,this._chartEventMap[e].callback)}updateFilterRules(t){this.internalProps.dataConfig.filterRules=t,this.dataset.updateFilterRules(t),kG(this.scenegraph),function(t){const e=t.table;for(let i=t.proxy.colStart;i<=t.proxy.colEnd;i++)t.getColGroup(i).getChildren().forEach((t=>{const i=t.col,n=t.row;t.children.forEach((t=>{if("chart"===t.type){t.updateData(e.getCellValue(i,n));const r=e.internalProps.layoutMap.getChartAxes(i,n);t.setAttribute("axes",r);const o=t.attribute.spec;o.axes=r,t.setAttribute("spec",o)}}))}));IG(t.rowHeaderGroup,t.table),IG(t.colHeaderGroup,t.table),IG(t.rightFrozenGroup,t.table),IG(t.bottomFrozenGroup,t.table)}(this.scenegraph),this.render()}setLegendSelected(t){this.internalProps.legends.legendComponent.setSelected(t)}getChartDatumPosition(t,e){const i=this.getCellAddressByHeaderPaths(e),n=this.getCellRelativeRect(i.col,i.row);console.log(n);const r=this.scenegraph.getCell(i.col,i.row);let o;const s=r?.getChildren()?.[0];if(s.attribute.chartInstance){const e=s.attribute.chartInstance,{dataId:i,data:n,axes:r}=s.attribute,a=s.getViewBox();r.forEach(((t,i)=>{if("linear"===t.type){e._chart._components[i]._domain={min:t.range?.min??0,max:t.range?.max??0}}else if("band"===t.type){const n=e._chart._components[i];n._spec.domain=t.domain.slice(0),n.updateScaleDomain()}})),e.updateViewBox({x1:a.x1-s.getRootNode().table.scrollLeft,x2:a.x2-s.getRootNode().table.scrollLeft,y1:a.y1-s.getRootNode().table.scrollTop,y2:a.y2-s.getRootNode().table.scrollTop},!1),e.updateDataSync(i,n),o=e.convertDatumToPosition(t),this.render()}return o?{x:Math.round(o.x+n.bounds.x1),y:Math.round(o.y+n.bounds.y1)}:null}_getDimensionSortArray(){if(this.options?.axes?.length){const t=this.options.indicatorsAsCol?"left":"bottom",e=this.options.axes.find((e=>e.orient===t));if(e&&qu(e.domain))return e.domain}}},t.PivotTable=class extends _U{pivotSortState;dataset;flatDataToObjects;constructor(t,e){if(t instanceof HTMLElement||(e=t,t=t.container?t.container:null),super(t,e),e.layout&&Object.assign(e,e.layout),this.pagination=e.pagination,this.internalProps.columnResizeType=e.columnResizeType??"column",this.internalProps.dataConfig=e.dataConfig,this.internalProps.enableDataAnalysis=e.enableDataAnalysis,this.internalProps.enableDataAnalysis&&(e.rows||e.columns)){const t=e.rows.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[]),i=e.columns.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[]),n=e.indicators?.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.indicatorKey),t)),[])??[];this.dataset=new rK(this.internalProps.dataConfig,this.pagination,t,i,n,e.records)}this.refreshHeader(),this.pivotSortState=[],e.pivotSortState&&this.updatePivotSortState(e.pivotSortState),e.dataSource?uj(this,e.dataSource):e.records?this.setRecords(e.records,this.internalProps.sortState):this.setRecords([])}static get EVENT_TYPE(){return ZG}isListTable(){return!1}isPivotTable(){return!0}isPivotChart(){return!1}_canResizeColumn(t,e){const i=super._canResizeColumn(t,e);if(i&&!this.internalProps.layoutMap.indicatorsAsCol){const e=this.internalProps.layoutMap.getBody(t,this.columnHeaderLevelCount);if(e?.disableColumnResize)return!1}return i}updateOption(t,e=!1){const i=this.internalProps;if(super.updateOption(t),this.pagination=t.pagination,i.columnResizeType=t.columnResizeType??"column",i.dataConfig=t.dataConfig,i.enableDataAnalysis=t.enableDataAnalysis,"tree"===t?.rowHierarchyType&&"tree"===this.internalProps.layoutMap.rowHierarchyType&&this.internalProps.layoutMap.rowExpandLevel===t?.rowExpandLevel){const t=this.internalProps.layoutMap.rowDimensionTree.tree.children;this.internalProps.layoutMap.rowTree.forEach(((e,i)=>{this.syncHierarchyState(t[i],e)}))}if(this.internalProps.enableDataAnalysis&&(t.rows||t.columns)){const e=t.rows.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[]),n=t.columns.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[]),r=t.indicators.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.indicatorKey),t)),[]);this.dataset=new rK(i.dataConfig,this.pagination,e,n,r,t.records)}return this.refreshHeader(),i.releaseList&&(i.releaseList.forEach((t=>t?.release?.())),i.releaseList=null),t.dataSource?uj(this,t.dataSource):t.records?this.setRecords(t.records,void 0):(this._resetFrozenColCount(),this.scenegraph.createSceneGraph(),this.render()),this.pivotSortState=[],t.pivotSortState&&this.updatePivotSortState(t.pivotSortState),new Promise((t=>{setTimeout(t,0)}))}updatePagination(t){this.pagination&&("number"==typeof t.currentPage&&t.currentPage>=0&&(this.pagination.currentPage=t.currentPage),t.perPageCount&&(this.pagination.perPageCount=t.perPageCount||this.pagination.perPageCount),this.scenegraph.clearCells(),this.dataset.updatePagination(this.pagination),this.refreshHeader(),this.scenegraph.createSceneGraph(),this.render())}refreshHeader(){const t=this.internalProps;t.headerEvents&&t.headerEvents.forEach((t=>this.off(t)));const e=this.options.records??this.internalProps.records;this.options.enableDataAnalysis?t.layoutMap=new WU(this,this.dataset):(Array.isArray(this.options.columnTree)||Array.isArray(this.options.rowTree))&&(t.layoutMap=new FU(this),e?.[0]?.constructor!==Array&&(this.flatDataToObjects=new jU({rows:t.layoutMap.rowDimensionKeys,columns:t.layoutMap.colDimensionKeys,indicators:t.layoutMap.indicatorKeys,indicatorsAsCol:t.layoutMap.indicatorsAsCol,indicatorDimensionKey:t.layoutMap.indicatorDimensionKey},e)));for(let e=0;e<t.layoutMap.columnWidths.length;e++){const{width:i,minWidth:n,maxWidth:r}=t.layoutMap.columnWidths?.[e]??{};i&&("string"==typeof i&&"auto"!==i||"number"==typeof i&&i>0)&&this.setColWidth(e,i),n&&("number"==typeof n&&n>0||"string"==typeof n)&&this.setMinColWidth(e,n),r&&("number"==typeof r&&r>0||"string"==typeof r)&&this.setMaxColWidth(e,r)}this.refreshRowColCount()}refreshRowColCount(){const t=this,{layoutMap:e}=t.internalProps;e&&(t.colCount=e.colCount??0,t.rowCount=e.rowCount??0,t.frozenColCount=e.rowHeaderLevelCount,t.frozenRowCount=e.headerLevelCount,t.bottomFrozenRowCount=this.options.bottomFrozenRowCount??0,t.rightFrozenColCount=this.options.rightFrozenColCount??0)}_getSortFuncFromHeaderOption(t,e,i){}get rowHierarchyType(){return this.internalProps.layoutMap.rowHierarchyType}syncHierarchyState(t,e){t.value===e.value&&t.dimensionKey===e.dimensionKey&&(e.hierarchyState=e.hierarchyState??(e?.children?t.hierarchyState:void 0),e?.children?.forEach(((e,i)=>{t?.children?.[i]&&e&&this.syncHierarchyState(t.children[i],e)})))}getRecordIndexByRow(t){const{layoutMap:e}=this.internalProps;return e.getRecordIndexByRow(t)}getRecordIndexByCol(t){const{layoutMap:e}=this.internalProps;return e.getRecordIndexByCol(t)}getFieldData(t,e,i){if(null==t)return null;const n=this;if(n.internalProps.layoutMap.isHeader(e,i))return null;const r=this.getRecordIndexByRow(i),o=this.getRecordIndexByCol(e),s=n.dataSource?.getField(r,o);if("string"!=typeof t){return fW({dataValue:s,...n.internalProps.layoutMap.getCellHeaderPaths(e,i)},t,of)}return s}getCellValue(t,e){if(this.internalProps.layoutMap.isHeader(t,e)){const{title:i,fieldFormat:n}=this.internalProps.layoutMap.getHeader(t,e);return"function"==typeof n?n(i):i}if(this.dataset){const i=this.dataset.colKeysPath[this.internalProps.layoutMap.getRecordIndexByCol(t)]??[],n=this.dataset.rowKeysPath[this.internalProps.layoutMap.getRecordIndexByRow(e)]??[],r=this.dataset.getAggregator(n[n.length-1],i[i.length-1],this.internalProps.layoutMap.getIndicatorKey(t,e));return r.formatValue?r.formatValue():""}if(this.flatDataToObjects){const i=this.internalProps.layoutMap.getCellHeaderPaths(t,e),n=i.colHeaderPaths.map((t=>t.indicatorKey??t.value)),r=i.rowHeaderPaths.map((t=>t.indicatorKey??t.value)),o=this.flatDataToObjects.getTreeNode(r,n,this.internalProps.layoutMap.getBody(t,e).indicatorKey),{fieldFormat:s}=this.internalProps.layoutMap.getBody(t,e);return"function"==typeof s?s(o?.record):o?.value??""}const{field:i,fieldFormat:n}=this.internalProps.layoutMap.getBody(t,e);return this.getFieldData(n||i,t,e)}getCellOriginValue(t,e){const i=this;if(i.internalProps.layoutMap.isHeader(t,e)){const{title:n}=i.internalProps.layoutMap.getHeader(t,e);return"function"==typeof n?n():n}if(this.dataset){const i=this.dataset.colKeysPath[this.internalProps.layoutMap.getRecordIndexByCol(t)]??[],n=this.dataset.rowKeysPath[this.internalProps.layoutMap.getRecordIndexByRow(e)]??[],r=this.dataset.getAggregator(n[n.length-1],i[i.length-1],this.internalProps.layoutMap.getIndicatorKey(t,e));return r.value?r.value():void 0}if(this.flatDataToObjects){const i=this.internalProps.layoutMap.getCellHeaderPaths(t,e),n=i.colHeaderPaths.map((t=>t.indicatorKey??t.value)),r=i.rowHeaderPaths.map((t=>t.indicatorKey??t.value)),o=this.flatDataToObjects.getTreeNode(r,n,this.internalProps.layoutMap.getBody(t,e).indicatorKey);return o?.value}const{field:n}=i.internalProps.layoutMap.getBody(t,e);return i.getFieldData(n,t,e)}getCellOriginRecord(t,e){if(!this.internalProps.layoutMap.isHeader(t,e)){if(this.dataset){const i=this.dataset.colKeysPath[this.internalProps.layoutMap.getRecordIndexByCol(t)]??[],n=this.dataset.rowKeysPath[this.internalProps.layoutMap.getRecordIndexByRow(e)]??[];return this.dataset.getAggregator(n[n.length-1],i[i.length-1],this.internalProps.layoutMap.getIndicatorKey(t,e)).records}if(this.flatDataToObjects){const i=this.internalProps.layoutMap.getCellHeaderPaths(t,e),n=i.colHeaderPaths.map((t=>t.indicatorKey??t.value)),r=i.rowHeaderPaths.map((t=>t.indicatorKey??t.value)),o=this.flatDataToObjects.getTreeNode(r,n,this.internalProps.layoutMap.getBody(t,e).indicatorKey);return o?.record}}}updateSortRules(t){this.internalProps.dataConfig.sortRules=t,this.dataset.updateSortRules(t),this.internalProps.layoutMap.updateDataset(this.dataset),this.render()}updatePivotSortState(t){for(let e=0;e<t.length;e++){const{dimensions:i,order:n}=t[e],r=this.internalProps.layoutMap.getPivotCellAdress(i);r&&this.pivotSortState.push({col:r.col,row:r.row,order:n})}}getPivotSortState(t,e){if(!this.pivotSortState)return;const i=this.getCellRange(t,e);for(let t=0;t<this.pivotSortState.length;t++){const{col:e,row:n,order:r}=this.pivotSortState[t];if(qp(i,e,n))return r}}moveHeaderPosition(t,e){const i=this.internalProps.layoutMap.moveHeaderPosition(t,e);if(i){if("column"===i.moveType){if(this.options.records?.[0]?.constructor===Array)for(let t=0;t<this.internalProps.records.length;t++){const e=this.internalProps.records[t].splice(i.sourceIndex-this.rowHeaderLevelCount,i.moveSize);e.unshift(i.targetIndex-this.rowHeaderLevelCount,0),Array.prototype.splice.apply(this.internalProps.records[t],e)}this.colWidthsMap.adjustOrder(i.sourceIndex,i.targetIndex,i.moveSize);for(let t=0;t<this.internalProps.layoutMap.columnWidths.length;t++){const{minWidth:e,maxWidth:i}=this.internalProps.layoutMap.columnWidths?.[t]??{};e&&("number"==typeof e&&e>0||"string"==typeof e)&&this.setMinColWidth(t,e),i&&("number"==typeof i&&i>0||"string"==typeof i)&&this.setMaxColWidth(t,i)}}else if("row"===i.moveType){if(this.options.records?.[0]?.constructor===Array){const t=this.internalProps.records.splice(i.sourceIndex-this.columnHeaderLevelCount,i.moveSize);t.unshift(i.targetIndex-this.columnHeaderLevelCount,0),Array.prototype.splice.apply(this.internalProps.records,t)}this.rowHeightsMap.adjustOrder(i.sourceIndex,i.targetIndex,i.moveSize)}return!0}return!1}toggleHierarchyState(t,e){const i=this.getHierarchyState(t,e);i===Xc.expand?this.fireListeners(ZG.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:Xc.collapse}):i===Xc.collapse&&this.fireListeners(ZG.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:Xc.expand,originData:this.getCellOriginRecord(t,e)});const n=this.internalProps.layoutMap.toggleHierarchyState(t,e);this.refreshRowColCount(),this.clearCellStyleCache(),this.scenegraph.updateHierarchyIcon(t,e),this.scenegraph.updateRow(n.removeCellPositions,n.addCellPositions)}getHeaderCellAddressByPath(t){return this.internalProps.layoutMap.getPivotCellAdress(t)}getCellAddressByHeaderPaths(t){return this.internalProps.layoutMap.getCellAdressByHeaderPath(t)}getHeaderPathByXY(t){let e;e=t?this.getCellAt(t.x+this.getFrozenColsWidth()+this.scrollLeft+1,t.y+this.getFrozenRowsHeight()+this.scrollTop+1):this.getCellAt(this.getFrozenColsWidth()+this.scrollLeft+1,this.getFrozenRowsHeight()+this.scrollTop+1);return this.internalProps.layoutMap.getCellHeaderPaths(e.col,e.row)}getHierarchyState(t,e){return this._getHeaderLayoutMap(t,e)?.hierarchyState}hasHierarchyTreeHeader(){return"tree"===this.internalProps.layoutMap.rowHierarchyType}getMenuInfo(t,e,i){const n=this.internalProps.layoutMap.getPivotDimensionInfo(t,e);return{dimensionKey:n[n.length-1].dimensionKey,value:this.getCellValue(t,e),cellLocation:this.getCellLocation(t,e),isPivotCorner:this.isCornerHeader(t,e)}}},t.TYPES=nu,t.clearGlobal=function(){BU()},t.core=SU,t.data=bW,t.getIcons=function(){return yj()},t.register=MU,t.themes=zf,t.version="0.10.2"}));
|
|
17
|
+
***************************************************************************** */function Qj(t,e,i,n){var r,o=arguments.length,s=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(s=(o<3?r(s):o>3?r(e,i,s):r(e,i))||s);return o>3&&s&&Object.defineProperty(e,i,s),s}const tN=Cx();class eN extends Xx{type="chart";chartInstance;activeChartInstance;active;cacheCanvas;constructor(t){super(t),this.numberType=tN,t.chartInstance?this.chartInstance=t.chartInstance:(t.chartInstance=this.chartInstance=new t.ClassType(t.spec,{renderCanvas:t.canvas,mode:"desktop-browser",canvasControled:!1,viewBox:{x1:0,x2:0,y1:0,y2:0},interactive:!1,animation:!1,autoFit:!1}),this.chartInstance.renderSync())}activate(t){this.active=!0;const{x1:e,y1:i,x2:n,y2:r}=this.getViewBox(),o=t.scenegraph.tableGroup.globalAABBBounds,s=new ep;s.x1=o.x1+t.getFrozenColsWidth(),s.x2=o.x2-t.getRightFrozenColsWidth(),s.y1=o.y1+t.getFrozenRowsHeight(),s.y2=o.y2-t.getBottomFrozenRowsHeight();const a=s.intersect({x1:e-t.scrollLeft,x2:n-t.scrollLeft,y1:i-t.scrollTop,y2:r-t.scrollTop});this.activeChartInstance=new this.attribute.ClassType(this.attribute.spec,{renderCanvas:this.attribute.canvas,mode:"desktop-browser",canvasControled:!1,viewBox:{x1:e-t.scrollLeft,x2:n-t.scrollLeft,y1:i-t.scrollTop,y2:r-t.scrollTop},animation:!1,interactive:!0,autoFit:!1,beforeRender:t=>{const e=t.window.getContext();e.inuse=!0,e.clearMatrix(),e.setTransformForCurrent(!0),e.beginPath(),e.rect(a.x1,a.y1,a.x2-a.x1,a.y2-a.y1),e.clip()},afterRender(t){t.window.getContext().inuse=!1}}),this.activeChartInstance.renderSync(),t.internalProps.layoutMap?.updateDataStateToActiveChartInstance?.(this.activeChartInstance),this.activeChartInstance.on("click",(e=>{console.log("click captured",e),eN.temp&&t.scenegraph.updateChartState(e?.datum)})),this.activeChartInstance.on("brushEnd",(e=>{console.log("brushEnd captured",e),t.scenegraph.updateChartState(e?.value?.inBrushData),eN.temp=0,setTimeout((()=>{eN.temp=1}),0)})),t._bindChartEvent?.(this.activeChartInstance),console.log("active")}static temp=1;deactivate(){this.active=!1,this.activeChartInstance.release(),this.activeChartInstance=null,console.log("deactivate")}updateData(t){this.attribute.data=t}getViewBox(){const t=this.parent,e=this.attribute.cellPadding,i=this.stage.table;return{x1:Math.ceil(t.globalAABBBounds.x1+e[3]+i.scrollLeft),x2:Math.ceil(t.globalAABBBounds.x1+t.attribute.width-e[1]+i.scrollLeft),y1:Math.ceil(t.globalAABBBounds.y1+e[0]+i.scrollTop),y2:Math.ceil(t.globalAABBBounds.y1+t.attribute.height-e[2]+i.scrollTop)}}}const iN=[],nN=[];let rN=5,oN=!1;function sN(t){bu(t)&&(rN=t)}function aN(t){const{axes:e,dataId:i,data:n,spec:r}=t.attribute,{chartInstance:o}=t,s=t.getViewBox();if(e.forEach(((t,e)=>{if("linear"===t.type){o._chart._components[e]._domain={min:t.range?.min??0,max:t.range?.max??0}}else if("band"===t.type){const i=o._chart._components[e];i._spec.domain=t.domain.slice(0),i.updateScaleDomain()}})),o.updateViewBox({x1:s.x1-t.getRootNode().table.scrollLeft,x2:s.x2-t.getRootNode().table.scrollLeft,y1:s.y1-t.getRootNode().table.scrollTop,y2:s.y2-t.getRootNode().table.scrollTop},!1,!1),"string"==typeof i)o.updateDataSync(i,n??[]);else{const t=[];for(const e in i){const s=i[e],a=r.series.find((t=>t?.data?.id===e));t.push({id:e,values:s?n?.filter((t=>t.hasOwnProperty(s)))??[]:n??[],fields:a?.data?.fields}),o.updateFullDataSync||o.updateDataSync(e,s?n?.filter((t=>t.hasOwnProperty(s)))??[]:n??[])}o.updateFullDataSync?.(t)}const a=o.getStage();t.cacheCanvas=a.toCanvas()}function lN(t){oN=!0,nN.length>0?requestAnimationFrame((()=>{const e=nN.splice(0,rN);iN.splice(0,rN),e.forEach((t=>{aN(t),t.addUpdateBoundTag()})),t.render(),lN(t)})):oN=!1}const hN=Symbol.for("ChartRender");let cN=class{type;numberType=tN;drawShape(t,e,i,n,r,o,s,a){const l=Gv(t,o?.theme).group,{dataId:h,data:c,spec:u}=t.attribute;t.getViewBox();const{width:d=l.width,height:p=l.height}=t.attribute,{chartInstance:f,active:g,cacheCanvas:m,activeChartInstance:y}=t;if(!g&&m)e.drawImage(m,i,n,d,p);else if(y)if("string"==typeof h)y.updateDataSync(h,c??[]);else{const t=[];for(const e in h){const i=h[e],n=u.series.find((t=>t?.data?.id===e));t.push({id:e,values:i?c?.filter((t=>t.hasOwnProperty(i)))??[]:c??[],fields:n?.data?.fields}),f.updateFullDataSync||y.updateDataSync(e,i?c?.filter((t=>t.hasOwnProperty(i)))??[]:c??[])}y.updateFullDataSync?.(t)}else t.getRootNode().table.internalProps.renderChartAsync?(-1===iN.indexOf(`${t.parent.col}+${t.parent.row}`)&&(iN.push(`${t.parent.col}+${t.parent.row}`),nN.push(t)),oN||lN(t.getRootNode().table)):aN(t)}draw(t,e,i,n){const{context:r}=i;if(!r)return;const{clip:o}=t.attribute;o?r.save():r.highPerformanceSave(),r.transformFromMatrix(t.transMatrix,!0),r.beginPath(),n.skipDraw?this.drawShape(t,r,0,0,i,n,(()=>!1),(()=>!1)):this.drawShape(t,r,0,0,i),o?r.restore():r.highPerformanceRestore()}};cN=Qj([Vm()],cN);let uN=class{time=Ry.beforeFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,u,d){const{shape:p}=t.attribute;if("circle"===p){const{width:r=l.width,height:o=l.height}=t.attribute;e.beginPath(),e.arc(i+r/2,n+o/2,Math.min(r,o)/2,0,2*Math.PI),e.closePath(),e.save(),e.clip()}}};uN=Qj([Vm()],uN);let dN=class{time=Ry.afterFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,u,d){const{shape:p}=t.attribute;"circle"===p&&e.restore()}};function pN(t,e,i){const{highlightScope:n,disableHeader:r,cellPos:o}=t.hover;if(!t.table.isHeader(e,i)||!r){if(n===Kc.single&&o.col===e&&o.row===i)return"cellBgColor";if(n===Kc.column&&o.col===e)return"inlineColumnBgColor";if(n===Kc.row&&o.row===i)return"inlineRowBgColor";if(n===Kc.cross){if(o.col===e&&o.row===i)return"cellBgColor";if(o.col===e)return"inlineColumnBgColor";if(o.row===i)return"inlineRowBgColor"}}}dN=Qj([Vm()],dN);let fN=class{time=Ry.beforeFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,u,d){const{stroke:p=l.stroke,strokeArrayWidth:f=l.strokeArrayWidth,strokeArrayColor:g=l.strokeArrayColor}=t.attribute;p&&(Array.isArray(f)||Array.isArray(g))&&(d.doStroke=!1)}};fN=Qj([Vm()],fN);let gN=class{time=Ry.afterFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,u){const{width:d=l.width,height:p=l.height,stroke:f=l.stroke,strokeArrayColor:g=l.strokeArrayColor,strokeArrayWidth:m=l.strokeArrayWidth,lineWidth:y=l.lineWidth,strokeColor:b=l.stroke}=t.attribute;if(!f||!Array.isArray(m)&&0===y)return;let v,w;if(Array.isArray(g)||Array.isArray(m)){if("number"==typeof y&&1&y||Array.isArray(m)&&m.some((t=>1&t))){i=Math.floor(i)+.5,n=Math.floor(n)+.5;const{width:e,height:r}=_N(t,Math.ceil(d),Math.ceil(p));v=e,w=r}else v=Math.ceil(d),w=Math.ceil(p);mN(t,e,i,n,l,f,m||y,g||b,v,w)}}};function mN(t,e,i,n,r,o,s,a,l,h,c,u){const d=function(t){if(!Array.isArray(t))return{isSplitDraw:!1,width:t};let e;for(let i=0;i<t.length;i++){const n=t[i];if(n)if(e){if(n!==e)return{isSplitDraw:!0}}else e=n}return{isSplitDraw:!1,width:e}}(s),p=!Array.isArray(s),f=!Array.isArray(o),g=Array.isArray(u),m=Array.isArray(a)||d.isSplitDraw;e.setStrokeStyle(t,t.attribute,i,n,r);let y=!1;e.getLineDash().length&&(y=!0),e.beginPath(),e.moveTo(i,n),(f||o[0])&&(p||s[0])?(g&&Array.isArray(u[0])?(e.moveTo(i+l*u[0][0],n),e.lineTo(i+l*(u[0][1]-u[0][0]),n),e.moveTo(i+l,n)):(e.moveTo(i,n),e.lineTo(i+l,n)),!m&&!y||a&&!a[0]||(a&&(e.strokeStyle=a[0]),p||(e.lineWidth=s[0]),e.lineDashOffset=e.currentMatrix.e/e.currentMatrix.a,e.stroke(),e.beginPath(),e.moveTo(i+l,n))):e.moveTo(i+l,n),(f||o[1])&&(p||s[1])?(g&&Array.isArray(u[1])?(e.moveTo(i+l,n+h*u[1][0]),e.lineTo(i+l,n+h*(u[1][1]-u[1][0])),e.moveTo(i+l,n+h)):(e.moveTo(i+l,n),e.lineTo(i+l,n+h)),!m&&!y||a&&!a[1]||(a&&(e.strokeStyle=a[1]),p||(e.lineWidth=s[1]),e.lineDashOffset=e.currentMatrix.f/e.currentMatrix.d,e.stroke(),e.beginPath(),e.moveTo(i+l,n+h))):e.moveTo(i+l,n+h),(f||o[2])&&(p||s[2])?(g&&Array.isArray(u[2])?(e.moveTo(i+l*u[2][0],n+h),e.lineTo(i+l*(u[2][1]-u[2][0]),n+h),e.moveTo(i,n+h)):(e.moveTo(i,n+h),e.lineTo(i+l,n+h)),!m&&!y||a&&!a[2]||(a&&(e.strokeStyle=a[2]),p||(e.lineWidth=s[2]),e.lineDashOffset=e.currentMatrix.e/e.currentMatrix.a,e.stroke(),e.beginPath(),e.moveTo(i,n+h))):e.moveTo(i,n+h),(f||o[3])&&(p||s[3])?(g&&Array.isArray(u[3])?(e.moveTo(i,n+h*u[3][0]),e.lineTo(i,n+h*(u[3][1]-u[3][0])),e.moveTo(i,n)):(e.moveTo(i,n),e.lineTo(i,n+h)),!m&&!y||a&&!a[3]||(a&&(e.strokeStyle=a[3]),p||(e.lineWidth=s[3]),e.lineDashOffset=e.currentMatrix.f/e.currentMatrix.d,e.stroke(),e.beginPath(),e.moveTo(i,n))):e.moveTo(i,n),m||y||(!p&&d.width&&(e.lineWidth=d.width),e.stroke())}gN=Qj([Vm()],gN);let yN=class{time=Ry.beforeFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,u,d){const{lineDash:p=l.lineDash,stroke:f=l.stroke,strokeArrayColor:g=l.strokeArrayColor,strokeArrayWidth:m=l.strokeArrayWidth}=t.attribute;f&&Array.isArray(p)&&p.length&&!Array.isArray(g)&&!Array.isArray(m)&&(d.doStroke=!1)}};yN=Qj([Vm()],yN);let bN=class{time=Ry.afterFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,u){const{lineDash:d=l.lineDash,stroke:p=l.stroke,strokeArrayColor:f=l.strokeArrayColor,strokeArrayWidth:g=l.strokeArrayWidth,lineWidth:m=l.lineWidth}=t.attribute;if(!p||!Array.isArray(d)||!d.length||Array.isArray(f)||Array.isArray(g))return;let y,b,{width:v=l.width,height:w=l.height}=t.attribute;if(v=Math.ceil(v),w=Math.ceil(w),1&m){i=Math.floor(i)+.5,n=Math.floor(n)+.5;const{width:e,height:r}=_N(t,Math.ceil(v),Math.ceil(w));y=e,b=r}else y=Math.ceil(v),b=Math.ceil(w);e.setStrokeStyle(t,t.attribute,i,n,l),e.beginPath(),e.moveTo(i,n),e.lineTo(i+y,n),e.lineDashOffset=e.currentMatrix.e/e.currentMatrix.a,e.stroke(),e.beginPath(),e.moveTo(i+y,n),e.lineTo(i+y,n+b),e.lineDashOffset=e.currentMatrix.f/e.currentMatrix.d,e.stroke(),e.beginPath(),e.moveTo(i,n+b),e.lineTo(i+y,n+b),e.lineDashOffset=e.currentMatrix.e/e.currentMatrix.a,e.stroke(),e.beginPath(),e.moveTo(i,n),e.lineTo(i,n+b),e.lineDashOffset=e.currentMatrix.f/e.currentMatrix.d,e.stroke()}};bN=Qj([Vm()],bN);let vN=class{time=Ry.beforeFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,u,d){const{lineWidth:p=l.lineWidth,stroke:f=l.stroke,lineDash:g=l.lineDash,strokeArrayWidth:m=l.strokeArrayWidth,strokeArrayColor:y=l.strokeArrayColor}=t.attribute;f&&Array.isArray(g)&&!g.length&&!Array.isArray(y)&&!Array.isArray(m)&&1&p&&(d.doStroke=!1)}};vN=Qj([Vm()],vN);let wN=class{time=Ry.afterFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,u){const{lineWidth:d=l.lineWidth,stroke:p=l.stroke,lineDash:f=l.lineDash,strokeArrayWidth:g=l.strokeArrayWidth,strokeArrayColor:m=l.strokeArrayColor}=t.attribute,{width:y=l.width,height:b=l.height}=t.attribute;if(p&&Array.isArray(f)&&!f.length&&!Array.isArray(m)&&!Array.isArray(g)&&1&d){const{width:r,height:o}=_N(t,Math.ceil(y),Math.ceil(b));e.beginPath(),i=Math.floor(i)+.5,n=Math.floor(n)+.5,e.rect(i,n,r,o),e.setStrokeStyle(t,t.attribute,i,n,l),e.stroke()}}};wN=Qj([Vm()],wN);let CN=class{time=Ry.beforeFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,u,d){if("cell"===t.role){const e=t.stage.table;if(e.stateManeger.interactionState!==Uc.scrolling){const i=function(t,e){let i,n;if("cell"===t.role&&"number"==typeof t.mergeCol&&"number"==typeof t.mergeRow)for(let n=t.col;n<=t.mergeCol;n++)for(let r=t.row;r<=t.mergeRow;r++){const t=pN(e.stateManeger,n,r);!t||i&&"cellBgColor"!==t||(i=t)}else"cell"===t.role&&(i=pN(e.stateManeger,t.col,t.row));if(!i)return;const r=e.internalProps.layoutMap;return r.isCornerHeader(t.col,t.row)?n=e.theme.cornerHeaderStyle?.hover:r.isColumnHeader(t.col,t.row)?n=e.theme.headerStyle?.hover:r.isRowHeader(t.col,t.row)?n=e.theme.rowHeaderStyle?.hover:r.isBottomFrozenRow(t.col,t.row)?n=e.theme.bottomFrozenStyle?.hover||e.theme.headerStyle?.hover:r.isRightFrozenColumn(t.col,t.row)?n=e.theme.rightFrozenStyle?.hover||e.theme.rowHeaderStyle?.hover:e.isHeader(t.col,t.row)||(n=e.theme.bodyStyle?.hover),Cj(i,n,t.col,t.row,e)}(t,e);i&&(t.oldColor=t.attribute.fill,t.attribute.fill=i)}}}};CN=Qj([Vm()],CN);let xN=class{time=Ry.afterFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,u){"oldColor"in t&&(t.attribute.fill=t.oldColor,delete t.oldColor)}};function _N(t,e,i){const n=t.stage.table;if("cell"===t.role){let r=t.col,o=t.row;const s=Sk(n,r,o);s&&(r=s.end.col,o=s.end.row),(n&&r===n.colCount-1||n&&r===n.frozenColCount-1&&n.scrollLeft)&&(e-=1),(n&&o===n.rowCount-1||n&&o===n.frozenRowCount-1&&n.scrollTop)&&(i-=1)}else"corner-frozen"===t.role&&(n.scrollLeft&&(e-=1),n.scrollTop&&(i-=1));return{width:e,height:i}}xN=Qj([Vm()],xN);let SN=class{time=Ry.beforeFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,u,d){const{stroke:p=l.stroke,strokeArrayWidth:f=l.strokeArrayWidth,strokeArrayColor:g=l.strokeArrayColor}=t.attribute;p&&(Array.isArray(p)||Array.isArray(f)||Array.isArray(g))&&(d.doStroke=!1)}};SN=Qj([Vm()],SN);let AN=class{time=Ry.afterFillStroke;useStyle=!0;order=0;drawShape(t,e,i,n,r,o,s,a,l,h,c,u){const{width:d=l.width,height:p=l.height,stroke:f=l.stroke,strokeArrayColor:g=l.strokeArrayColor,strokeArrayWidth:m=l.strokeArrayWidth,lineWidth:y=l.lineWidth,strokeColor:b=l.stroke}=t.attribute;f&&(Array.isArray(m)||0!==y)&&(Array.isArray(f)||Array.isArray(g)||Array.isArray(m))&&(("number"==typeof y&&1&y||Array.isArray(m)&&m.some((t=>1&t)))&&(i=Math.floor(i)+.5,n=Math.floor(n)+.5),mN(t,e,i,n,l,f,m||y,g||b,Math.ceil(d),Math.ceil(p)))}};AN=Qj([Vm()],AN);var TN=new zm(((t,e,i,n)=>{i(KB)?n(KB).to(SN).inSingletonScope():(t(SN).toSelf().inSingletonScope(),t(E_).toService(SN)),i($B)?n($B).to(AN).inSingletonScope():(t(AN).toSelf().inSingletonScope(),t(E_).toService(AN)),t(gN).toSelf().inSingletonScope(),t(B_).toService(gN),t(fN).toSelf().inSingletonScope(),t(B_).toService(fN),t(cN).toSelf().inSingletonScope(),t(hN).to(cN),t(sB).to(cN),t(uN).toSelf().inSingletonScope(),t(M_).toService(uN),t(dN).toSelf().inSingletonScope(),t(M_).toService(dN),t(yN).toSelf().inSingletonScope(),t(B_).toService(yN),t(bN).toSelf().inSingletonScope(),t(B_).toService(bN),t(vN).toSelf().inSingletonScope(),t(B_).toService(vN),t(wN).toSelf().inSingletonScope(),t(B_).toService(wN),t(CN).toSelf().inSingletonScope(),t(B_).toService(CN),t(xN).toSelf().inSingletonScope(),t(B_).toService(xN)}));function BN(t,e,i){if(i._table.isPivotChart())if(i.indicatorsAsCol){if(i.hasTwoIndicatorAxes&&e===i.columnHeaderLevelCount-1&&t>=i.rowHeaderLevelCount&&t<i.colCount-i.rightFrozenColCount){let n=i.getIndicatorKeyInChartSpec(t,i.columnHeaderLevelCount-1)[1];if(qu(n)&&(n=n[0]),!n)return;const r=RN(t,e,"top",i),o=i.dataset.collectedValues[n+(r?"_align":"")]?i.dataset.collectedValues[n+(r?"_align":"")]:i.dataset.collectedValues[n],s=i.getRecordIndexByCol(t),a=o?o[i.getColKeysPath()[s][Math.max(0,i.columnHeaderLevelCount-1-i.topAxesCount)]]:{max:1,min:0},l=MN(t,e,"top",i);if(!1===l?.visible)return;return Qu(l?.min)&&(a.min=l.min),Qu(l?.max)&&(a.max=l.max),fd({range:a},l,{orient:"top",type:"linear",label:{flush:!0}})}if(e===i.rowCount-i.bottomFrozenRowCount&&t>=i.rowHeaderLevelCount&&t<i.colCount-i.rightFrozenColCount){const n=i.getIndicatorKeyInChartSpec(t,e);let r=n[0];qu(r)&&(r=r[0]);const o=RN(t,e,"bottom",i),s=i.dataset.collectedValues[r+(o?"_align":"")]?i.dataset.collectedValues[r+(o?"_align":"")]:i.dataset.collectedValues[r],a=i.getRecordIndexByCol(t),l=s?.[i.getColKeysPath()[a][Math.max(0,i.columnHeaderLevelCount-1-i.topAxesCount)]]??{min:0,max:1};let h=null;n.forEach((t=>{const e=i.getIndicatorInfo(t);e&&(h=e)}));const c=MN(t,e,"bottom",i);if(!1===c?.visible)return;return Qu(c?.min)&&(l.min=c.min),Qu(c?.max)&&(l.max=c.max),fd({title:{visible:!0,text:h?.title},range:l},c,{orient:"bottom",type:"linear",label:{flush:!0}})}if(t===i.rowHeaderLevelCount-1&&e>=i.columnHeaderLevelCount&&e<i.rowCount-i.bottomFrozenRowCount){let n=i.getDimensionKeyInChartSpec(i.rowHeaderLevelCount,e)?.[0];qu(n)&&(n=n[0]);const r=i.dataset.collectedValues[n]??[],o=i.getRecordIndexByRow(e),s=i.getRowKeysPath()[o],a=r[s[s.length-1]]??[],l=MN(t,e,"left",i);if(!1===l?.visible)return;return fd({domain:Array.from(a).reverse(),title:{autoRotate:!0}},l,{orient:"left",type:"band"})}}else{if(t===i.rowHeaderLevelCount-1&&e>=i.columnHeaderLevelCount&&e<i.rowCount-i.bottomFrozenRowCount){const n=i.getIndicatorKeyInChartSpec(t,e);let r=n[0];qu(r)&&(r=r[0]);const o=RN(t,e,"left",i),s=i.dataset.collectedValues[r+(o?"_align":"")]?i.dataset.collectedValues[r+(o?"_align":"")]:i.dataset.collectedValues[r],a=i.getRecordIndexByRow(e),l=s?.[i.getRowKeysPath()[a]?.[Math.max(0,i.rowHeaderLevelCount-1-i.leftAxesCount)]??""]??{min:0,max:1};let h=null;n.forEach((t=>{const e=i.getIndicatorInfo(t);e&&(h=e)}));const c=MN(t,e,"left",i);if(!1===c?.visible)return;return Qu(c?.min)&&(l.min=c.min),Qu(c?.max)&&(l.max=c.max),fd({title:{visible:!0,text:h?.title,autoRotate:!0},range:l},c,{orient:"left",type:"linear",label:{flush:!0}})}if(t===i.colCount-i.rightFrozenColCount&&e>=i.columnHeaderLevelCount&&e<i.rowCount-i.bottomFrozenRowCount){let n=i.getIndicatorKeyInChartSpec(i.rowHeaderLevelCount-1,e)[1];if(qu(n)&&(n=n[0]),!n)return;const r=RN(t,e,"right",i),o=i.dataset.collectedValues[n+(r?"_align":"")]?i.dataset.collectedValues[n+(r?"_align":"")]:i.dataset.collectedValues[n],s=i.getRecordIndexByRow(e),a=o?.[i.getRowKeysPath()[s]?.[Math.max(0,i.rowHeaderLevelCount-1-i.leftAxesCount)]??""]??{min:0,max:1},l=MN(t,e,"right",i);if(!1===l?.visible)return;return Qu(l?.min)&&(a.min=l.min),Qu(l?.max)&&(a.max=l.max),fd({range:a,title:{autoRotate:!0}},l,{orient:"right",type:"linear",label:{flush:!0}})}if(e===i.rowCount-i.bottomFrozenRowCount&&t>=i.rowHeaderLevelCount&&t<i.colCount-i.rightFrozenColCount){let n=i.getDimensionKeyInChartSpec(t,i.columnHeaderLevelCount)?.[0];qu(n)&&(n=n[0]);const r=i.dataset.collectedValues[n]??[],o=i.getRecordIndexByCol(t),s=i.getColKeysPath()[o],a=r?.[s?.[s?.length-1]]??[],l=MN(t,e,"bottom",i);if(!1===l?.visible)return;return fd({domain:Array.from(a)},l,{orient:"bottom",type:"band"})}}}function MN(t,e,i,n){const r=n.getRawChartSpec(t,e);if(r&&qu(r.axes)){const t=r.axes.find((t=>t.orient===i));if(t)return t}return n._table.pivotChartAxes.find((t=>t.orient===i))}function RN(t,e,i,n){const r=[];"left"===i||"right"===i?r.push("left","right"):"top"!==i&&"bottom"!==i||r.push("top","bottom");const o=n.getRawChartSpec(t,e);let s;if(s=o&&qu(o.axes)?o.axes:n._table.pivotChartAxes,qu(s)){const t=[];s.forEach((e=>{r.includes(e.orient)&&t.push(e)}));for(let e=0;e<t.length;e++){const i=t[e];if(i.sync&&i.sync.zeroAlign&&i.sync.axisId&&t.find((t=>t.id===i.sync.axisId)))return!0}}return!1}function PN(t,e){const i=fd({},cO,t);let n=0;!1!==i.tick.visible&&(n=i.tick.width??4);let r=0;if(i.label.visible){if("band"===i.type){i.domain.forEach((t=>{i.label.formatMethod&&(t=i.label.formatMethod(t));const{width:n,height:o}=e.measureText(t,{fontSize:i.label?.style?.fontSize,fontWeight:i.label?.style?.fontWeight,fontFamily:i.label?.style?.fontFamily}),s=i.label?.style?.maxLineWidth||1/0;r=Math.max(r,LN(Math.min(n,s),o,i.label?.style?.angle).width)}))}else{const t=i.range,n=Math.abs(t.min)>1?Math.round(t.min):t.min,o=Math.abs(t.max)>1?Math.round(t.max):t.max;[HN(n),HN(o)].forEach((t=>{i.label.formatMethod&&(t=i.label.formatMethod(t));const{width:n,height:o}=e.measureText(t,{fontSize:i.label?.style?.fontSize,fontWeight:i.label?.style?.fontWeight,fontFamily:i.label?.style?.fontFamily}),s=i.label?.style?.maxLineWidth||1/0;r=Math.max(r,LN(Math.min(n,s),o,i.label?.style?.angle).width)}))}r+=i.label.space??4}let o=0;if(i.title.visible&&i.title.text){const{width:n,height:r}=e.measureText(i.title.text,{fontSize:i.title?.style?.fontSize,fontWeight:i.title?.style?.fontWeight,fontFamily:i.title?.style?.fontFamily}),s=i.label?.style?.maxLineWidth||1/0,a=LN(Math.min(n,s),r,i.title?.style?.angle);o="left"!==t.orient&&"right"!==t.orient||!i.title.autoRotate?a.width:a.height,o+=i.title.space??4}return n+r+o+2}function EN(t,e){const i=fd({},cO,t);let n=0;!1!==i.tick.visible&&(n=i.tick.width??4);let r=0;if(i.label.visible){if("band"===i.type){i.domain.forEach((t=>{i.label.formatMethod&&(t=i.label.formatMethod(t));const{width:n,height:o}=e.measureText(t,{fontSize:i.label?.style?.fontSize,fontWeight:i.label?.style?.fontWeight,fontFamily:i.label?.style?.fontFamily}),s=i.label?.style?.maxLineWidth||1/0;r=Math.max(r,LN(Math.min(n,s),o,i.label?.style?.angle).height)}))}else{const t=i.range,n=Math.abs(t.min)>1?Math.round(t.min):t.min,o=Math.abs(t.max)>1?Math.round(t.max):t.max;[HN(n),HN(o)].forEach((t=>{i.label.formatMethod&&(t=i.label.formatMethod(t));const{width:n,height:o}=e.measureText(t,{fontSize:i.label?.style?.fontSize,fontWeight:i.label?.style?.fontWeight,fontFamily:i.label?.style?.fontFamily}),s=i.label?.style?.maxLineWidth||1/0;r=Math.max(r,LN(Math.min(n,s),o,i.label?.style?.angle).height)}))}r+=i.label.space??4}let o=0;if(i.title.visible&&i.title.text){const{width:n,height:r}=e.measureText(i.title.text,{fontSize:i.title?.style?.fontSize,fontWeight:i.title?.style?.fontWeight,fontFamily:i.title?.style?.fontFamily}),s=i.label?.style?.maxLineWidth||1/0,a=LN(Math.min(n,s),r,i.title?.style?.angle);o="bottom"!==t.orient&&"top"!==t.orient||!i.title.autoRotate?a.height:a.width,o+=i.title.space??4}return n+r+o+2}function HN(t){return"number"!=typeof t&&(t=Number(t)),Number(t.toPrecision(1)).toString()}function LN(t,e,i=0){const n=i*Math.PI/180,r=-t/2,o=-e/2,s=t/2,a=-e/2,l=t/2,h=e/2,c=-t/2,u=e/2,d={x:r*Math.cos(n)-o*Math.sin(n),y:r*Math.sin(n)+o*Math.cos(n)},p={x:s*Math.cos(n)-a*Math.sin(n),y:s*Math.sin(n)+a*Math.cos(n)},f={x:l*Math.cos(n)-h*Math.sin(n),y:l*Math.sin(n)+h*Math.cos(n)},g={x:c*Math.cos(n)-u*Math.sin(n),y:c*Math.sin(n)+u*Math.cos(n)},m=Math.min(d.x,p.x,f.x,g.x),y=Math.max(d.x,p.x,f.x,g.x),b=Math.min(d.y,p.y,f.y,g.y);return{width:y-m,height:Math.max(d.y,p.y,f.y,g.y)-b}}function kN(t,e,i,n){"undefined"!=typeof window&&window.performance.now(),e=e??0,i=i??t.colCount-1,0===e&&i===t.colCount-1&&t._clearColRangeWidthsMap();const r=[];if(n)for(let e=0;e<t.colCount;e++)r.push(t.getColWidth(e));for(let n=e;n<=i;n++){let e;if(!t.internalProps.transpose&&"only-header"===t.internalProps.layoutMap.columnWidths?.[n]?.columnWidthComputeMode&&"showHeader"in t.internalProps.layoutMap){const i=t.internalProps.layoutMap.showHeader;t.internalProps.layoutMap.showHeader=!0,e=IN(n,0,t.internalProps.layoutMap.headerLevelCount,t,!1),t.internalProps.layoutMap.showHeader=i}else e=t.internalProps.transpose||"only-body"!==t.internalProps.layoutMap.columnWidths?.[n]?.columnWidthComputeMode?IN(n,0,t.rowCount-1,t,!1):IN(n,t.internalProps.layoutMap.getBodyRange().start.row,t.internalProps.layoutMap.getBodyRange().end.row,t,!1);t._setColContentWidth(n,e);t.getColWidth(n)!==e&&t._clearColRangeWidthsMap(n),t.setColWidth(n,e,!1,!0)}if("adaptive"===t.widthMode){t._clearColRangeWidthsMap();const e=t.tableNoFrameWidth-t.getFrozenColsWidth()-t.getRightFrozenColsWidth();let i=0;for(let e=t.frozenColCount;e<t.colCount-t.rightFrozenColCount;e++)i+=t.getColWidth(e);const n=e/i;for(let i=t.frozenColCount;i<t.colCount-t.rightFrozenColCount;i++){let r;r=i===t.colCount-t.rightFrozenColCount-1?e-t.getColsWidth(t.frozenColCount,t.colCount-t.rightFrozenColCount-2):Math.round(t.getColWidth(i)*n),t.setColWidth(i,r,!1,!0)}}else if(t.autoFillWidth){t._clearColRangeWidthsMap();const e=t.tableNoFrameWidth;let i=0,n=0;for(let e=0;e<t.colCount;e++){const r=t.getColWidth(e);(e<t.frozenColCount||e>=t.colCount-t.rightFrozenColCount)&&(n+=r),i+=r}if(i<e&&i-n>0){const r=(e-n)/(i-n);for(let e=t.frozenColCount;e<t.colCount-t.rightFrozenColCount;e++)t.setColWidth(e,t.getColWidth(e)*r,!1,!0)}}if(n)for(let e=0;e<t.colCount;e++){const i=t.getColWidth(e);i!==r[e]&&t.scenegraph.updateColWidth(e,i-r[e])}}function IN(t,e,i,n,r){const o=function(t,e){const i=e.getColWidthDefined(t);if(e.internalProps._widthResizedColMap.has(t))return e.getColWidth(t);return i}(t,n);return"number"==typeof o?o:"auto"!==o&&"string"==typeof o?aj(o,n.internalProps.calcWidthContext):function(t,e,i,n,r,o){let s=0,a=1;n-i>5e3&&(a=Math.ceil((n-i)/5e3));if(o.isPivotChart()&&e>=o.rowHeaderLevelCount){if(o.internalProps.layoutMap.indicatorsAsCol)return o.defaultColWidth;{const t=o.internalProps.layoutMap.getOptimunWidthForChart(e);if(t>0)return t}}for(let r=i;r<=n;r+=a){if(o.isPivotChart()){const t=o.internalProps.layoutMap,i=BN(e,r,t);if(i){const t=PN(i,o);if("number"==typeof t){s=Math.max(t,s);continue}}else if(t.isLeftBottomCorner(e,r)||t.isRightTopCorner(e,r)||t.isRightBottomCorner(e,r))continue}const i=ON(e,r,o);if("number"==typeof i){s=Math.max(i,s);continue}const n=t;if("number"==typeof n&&"standard"===o.widthMode){s=Math.max(n,s);continue}const a=o.isHeader(e,r)?o._getHeaderLayoutMap(e,r)?.headerType:o.getBodyColumnType(e,r);if("text"!==a&&"link"!==a&&"progressbar"!==a){s=Math.max(s,o.getColWidth(e)||0);continue}let l=0;const h=o.internalProps.layoutMap;if(h.isHeader(e,r)){const t=h.getHeader(e,r);if("only-body"===t?.define?.columnWidthComputeMode)continue;t?.hierarchyLevel&&(l=(t.hierarchyLevel??0)*(h.rowHierarchyIndent??0))}else{const t=o.getBodyColumnDefine(e,r);if(t?.tree){const t=o.dataSource.getIndexKey(o.getRecordIndexByRow(e,r));l=Array.isArray(t)&&o.getHierarchyState(e,r)!==Xc.none?(t.length-1)*(h.hierarchyIndent??0):0}}const c=DN(e,r,o);s=Math.max(c+l,s)}const l=o.getMinColWidth(e),h=o.getMaxColWidth(e);if(s<l)return l;if(s>h)return h;return s}(o,t,e,i,0,n)}function ON(t,e,i){const n=i.getCustomRender(t,e),r=i.getCustomLayout(t,e);if(n||r){let o=1,s=0;if(i.isHeader(t,e)||i.getBodyColumnDefine(t,e).mergeCell){const n=i.getCellRange(t,e);o=n.end.col-n.start.col+1}const a={col:t,row:e,dataValue:i.getCellOriginValue(t,e),value:i.getCellValue(t,e)||"",rect:FN(t,e,i),table:i};if(r){const t=r(a);t.rootContainer.isRoot=!0;s=t.rootContainer.getContentSize().width??0}else if("function"==typeof n){const t=n(a);s=t?.expectedWidth??0}else s=n?.expectedWidth??0;return s/o}}function DN(t,e,i){let n=0;const r=i.getCellValue(t,e),o=i._getCellStyle(t,e);let s=0;const a=i.getBodyColumnDefine(t,e);if("body"!==i.getCellLocation(t,e)||(!!a?.icon||!!a?.tree)){const n=i.getCellIcons(t,e);n?.forEach((t=>{t.positionType!==Zc.absoluteRight&&(s+=(t.width??0)+(t.marginLeft??0)+(t.marginRight??0))}))}let l=1;if(i.isHeader(t,e)||i.getBodyColumnDefine(t,e).mergeCell){const n=i.getCellRange(t,e);l=n.end.col-n.start.col+1}const h=RW(Cj("padding",o,t,e,i)),c=h[1]+h[3],u=Cj("fontSize",o,t,e,i),d=Cj("fontFamily",o,t,e,i),p=Cj("fontWeight",o,t,e,i),f=vu(r).split("\n")||[];return f.length>=1?f.forEach((t=>{const e=i.measureText(t.slice(0,i.options.maxCharactersNumber||200),{fontSize:u,fontFamily:d,fontWeight:p}).width;n=Math.max((e+c+4+s)/l,n)})):n=Math.max((c+4+s)/l,n),!1!==i.internalProps.limitMaxAutoWidth&&(n=Math.min("number"==typeof i.internalProps.limitMaxAutoWidth?i.internalProps.limitMaxAutoWidth:450,n)),n}function FN(t,e,i){return{left:0,top:0,right:i.getColWidth(t),bottom:i.getRowHeight(e),width:i.getColWidth(t),height:i.getRowHeight(e)}}const zN=new J_({ignoreBuf:!0}),WN=new dA({width:0,height:0,textConfig:[]});function jN(t,e,i,n=!0,r){"undefined"!=typeof window&&window.performance.now();const o=[];if(r)for(let e=0;e<t.rowCount;e++)o.push(t.getRowHeight(e));if("autoHeight"===t.heightMode||"adaptive"===t.heightMode){e=e??0,i=i??t.rowCount-1,(0===e&&i===t.rowCount-1||n)&&t._clearRowRangeHeightsMap();for(let i=e;i<t.columnHeaderLevelCount;i++){const e=NN(i,0,t.colCount-1,t);t.setRowHeight(i,e)}if(i<t.columnHeaderLevelCount)return;if(t.internalProps.transpose||t.isPivotTable()&&!t.internalProps.layoutMap.indicatorsAsCol||!function(t){const{layoutMap:e}=t.internalProps,i=t.columnHeaderLevelCount;if(t.internalProps.autoWrapText&&("autoHeight"===t.options.heightMode||"adaptive"===t.options.heightMode))return!1;for(let n=0;n<t.colCount;n++){const r=e.getBody(n,i);if("function"==typeof r.style||"function"==typeof r.icon||r.define?.customRender||"function"==typeof r.define?.icon)return!1;const o=t._getCellStyle(n,i);if("function"==typeof o.padding||"function"==typeof o.fontSize||"function"==typeof o.lineHeight||!0===o.autoWrapText)return!1}return!0}(t))if(t.internalProps.transpose||t.isPivotTable()&&!t.internalProps.layoutMap.indicatorsAsCol)for(let n=Math.max(e,t.columnHeaderLevelCount);n<=i;n++){let e;e=GN(t,n)?NN(n,0,t.rowHeaderLevelCount,t):NN(n,0,t.colCount-1,t),t.setRowHeight(n,e)}else for(let n=Math.max(e,t.columnHeaderLevelCount);n<=i;n++){const e=NN(n,0,t.colCount-1,t);t.setRowHeight(n,e)}else{!function(t,e,i,n){for(let r=e;r<=i;r++)n.setRowHeight(r,t)}(NN(t.columnHeaderLevelCount,0,t.colCount-1,t),t.columnHeaderLevelCount,t.rowCount-1-t.bottomFrozenRowCount,t);for(let e=t.rowCount-t.bottomFrozenRowCount;e<=i;e++){const i=NN(e,0,t.colCount-1,t);t.setRowHeight(e,i)}}}if("adaptive"===t.heightMode){t._clearRowRangeHeightsMap();const e=t.tableNoFrameHeight-t.getFrozenRowsHeight()-t.getBottomFrozenRowsHeight();let i=0;for(let e=t.frozenRowCount;e<t.rowCount-t.bottomFrozenRowCount;e++)i+=t.getRowHeight(e);const n=e/i;for(let i=t.frozenRowCount;i<t.rowCount-t.bottomFrozenRowCount;i++){let r;r=i===t.rowCount-t.bottomFrozenRowCount-1?e-t.getRowsHeight(t.frozenRowCount,t.rowCount-t.bottomFrozenRowCount-2):Math.round(t.getRowHeight(i)*n),t.setRowHeight(i,r,!1)}}if(r)for(let e=0;e<t.rowCount;e++){const i=t.getRowHeight(e);i!==o[e]&&t.scenegraph.updateRowHeight(e,i-o[e])}}function NN(t,e,i,n){let r=0;if(n.isPivotChart()&&t>=n.columnHeaderLevelCount&&t<n.rowCount-n.bottomFrozenRowCount){if(!n.internalProps.layoutMap.indicatorsAsCol)return n.getRowHeight(t);{const e=n.internalProps.layoutMap.getOptimunHeightForChart(t);if(e>0)return e}}for(let o=e;o<=i;o++){const e=VN(o,t,n);if("number"==typeof e){r=Math.max(e,r);continue}if(n.isPivotChart()){const e=BN(o,t,n.internalProps.layoutMap);if(e){const t=EN(e,n);if("number"==typeof t){r=Math.max(t,r);continue}}}const i=UN(o,t,n);r=Math.max(i,r)}return r}function GN(t,e){const{layoutMap:i}=t.internalProps;if(t.internalProps.autoWrapText&&("autoHeight"===t.options.heightMode||"adaptive"===t.options.heightMode))return!1;const n=i.getBody(t.rowHeaderLevelCount,e);if("function"==typeof n.style||"function"==typeof n.icon||n.define?.customRender||"function"==typeof n.define?.icon)return!1;const r=t._getCellStyle(t.rowHeaderLevelCount,e);return"function"!=typeof r.padding&&"function"!=typeof r.fontSize&&"function"!=typeof r.lineHeight&&!0!==r.autoWrapText}function VN(t,e,i){const n=i.getCustomRender(t,e),r=i.getCustomLayout(t,e);if(n||r){let o=1,s=0;if(i.isHeader(t,e)||i.getBodyColumnDefine(t,e).mergeCell){const n=i.getCellRange(t,e);o=n.end.col-n.start.col+1}const a={col:t,row:e,dataValue:i.getCellOriginValue(t,e),value:i.getCellValue(t,e)||"",rect:FN(t,e,i),table:i};if(r){const t=r(a);t.rootContainer.isRoot=!0;s=t.rootContainer.getContentSize().height??0}else if("function"==typeof n){const t=n(a);s=t?.expectedHeight??0}else s=n?.expectedHeight??0;return s/o}}function UN(t,e,i){let n=0;const r=i.getCellValue(t,e),o=i._getCellStyle(t,e);let s=0,a=0;const l=[];let h=0;const c=[];let u=0;const d=i.getBodyColumnDefine(t,e);if("body"!==i.getCellLocation(t,e)||(!!d?.icon||!!d?.tree)){const n=i.getCellIcons(t,e);n?.forEach((t=>{t.positionType!==Zc.absoluteRight&&t.positionType!==Zc.inlineFront&&t.positionType!==Zc.inlineEnd?(a+=(t.width??0)+(t.marginLeft??0)+(t.marginRight??0),s=Math.max(s,t.height??0)):t.positionType===Zc.inlineFront?(l.push(t),h=Math.max(h,(t.height??0)+(t.marginLeft??0)+(t.marginRight??0))):t.positionType===Zc.inlineEnd&&(c.push(t),u=Math.max(u,(t.height??0)+(t.marginLeft??0)+(t.marginRight??0)))}))}let p=1,f=t;if(i.isHeader(t,e)||i.getBodyColumnDefine(t,e).mergeCell){const n=i.getCellRange(t,e);p=n.end.row-n.start.row+1,t=n.start.col,f=n.end.col}const g=RW(Cj("padding",o,t,e,i)),m=Cj("fontSize",o,t,e,i),y=Cj("fontStyle",o,t,e,i),b=Cj("fontWeight",o,t,e,i),v=Cj("lineHeight",o,t,e,i)??m,w=Cj("fontFamily",o,t,e,i),C=Cj("autoWrapText",o,t,e,i),x=vu(r).split("\n")||[],_=i.getColsWidth(t,f);if(l.length||c.length){const t=Object.assign({text:r?.toString(),fontFamily:w,fontSize:m,fontStyle:y,fontWeight:b,lineHeight:v});t.textBaseline="middle";const e=[...l.map((t=>kj(t))),t,...c.map((t=>kj(t)))];WN.setAttributes({width:_-(g[1]+g[3])-a,height:0,textConfig:e}),n=WN.AABBBounds.height()}else if(C){const t=_-(g[1]+g[3])-a;zN.setAttributes({maxLineWidth:t,text:x,fontSize:m,fontStyle:y,fontWeight:b,fontFamily:w,lineHeight:v}),n=zN.AABBBounds.height()}else n=x.length*v;return(Math.max(n,s)+g[0]+g[2])/p}const KN=new bj({});KN.role="empty";const $N={},XN={};function YN(t,e,i,n,r,o,s,a,l,h,c,u,d,p,f,g){const m=Up(XN,$N)[c],y=xj("padding",f._getCellStyle(r,o),r,o,f);bu(y)&&(l=y),t||((t=new bj({x:i,y:n,width:s,height:a,lineWidth:g?.group?.lineWidth??void 0,fill:g?.group?.fill??void 0,stroke:g?.group?.stroke??void 0,strokeArrayWidth:g?.group?.strokeArrayWidth??void 0,strokeArrayColor:g?.group?.strokeArrayColor??void 0,cursor:g?.group?.cursor??void 0,lineCap:"square",clip:!0})).role="cell",t.col=r,t.row=o,e?.addChild(t)),t.AABBBounds.width();const b=new eN({stroke:!1,x:l[3],y:l[0],canvas:f.canvas,spec:u,ClassType:m,width:s-l[3]-l[1],height:a-l[2]-l[0],chartInstance:d,dataId:p,data:f.getCellValue(r,o),cellPadding:l,axes:f.internalProps.layoutMap.getChartAxes(r,o)});return t.appendChild(b),f.internalProps.layoutMap.setChartInstance(r,o,b.chartInstance),t}function qN(t,e,i,n,r,o,s,a,l,h,c,u,d,p,f,g){const m=t._getCellStyle(r,o),y=xj("padding",m,r,o,t);bu(y)&&(h=y),g?.text?.textAlign&&(c=g?.text?.textAlign),g?.text?.textBaseline&&(u=g?.text?.textBaseline);const b="autoHeight"===t.heightMode,v="auto"===s,w=m.autoWrapText??t.internalProps.autoWrapText,C=m.lineClamp,x=new bj({x:i,y:n,width:a,height:l,lineWidth:g?.group?.lineWidth??void 0,fill:g?.group?.fill??void 0,stroke:g?.group?.stroke??void 0,strokeArrayWidth:g?.group?.strokeArrayWidth??void 0,strokeArrayColor:g?.group?.strokeArrayColor??void 0,cursor:g?.group?.cursor??void 0,lineCap:"square",clip:!0});if(x.role="cell",x.col=r,x.row=o,e?.addChild(x),p&&x.appendChild(p),f){const e=t.getCellValue(r,o);let i;if(d&&(i=t.getCellIcons(r,o)),function(t,e,i,n,r,o,s,a,l,h,c,u,d,p){const f=[],g=[],m=[],y=[],b=[],v=[],w=[],C=[];let x,_=0,S=0,A=0,T=0,B=0,M=0;if(Array.isArray(e)&&0!==e.length){let R;if(e.forEach((t=>{switch(t.positionType){case Zc.left:f.push(t);break;case Zc.right:g.push(t);break;case Zc.contentLeft:m.push(t);break;case Zc.contentRight:y.push(t);break;case Zc.absoluteRight:C.push(t);break;case Zc.inlineFront:b.push(t);break;case Zc.inlineEnd:v.push(t)}})),f.forEach((e=>{const i=Lj(e,void 0,t.col,t.row,d);i.role="icon-left",i.name=e.name,i.setAttribute("x",_+(i.attribute.marginLeft??0)),_+=i.AABBBounds.width()+(i.attribute.marginLeft??0)+(i.attribute.marginRight??0),S=Math.max(S,i.AABBBounds.height()),t.appendChild(i)})),g.forEach((e=>{const i=Lj(e,void 0,t.col,t.row,d);i.role="icon-right",i.name=e.name,i.setAttribute("x",A+(i.attribute.marginLeft??0)),A+=i.AABBBounds.width()+(i.attribute.marginLeft??0)+(i.attribute.marginRight??0),T=Math.max(T,i.AABBBounds.height()),t.appendChild(i)})),w.forEach((e=>{const i=Lj(e,void 0,t.col,t.row,d);i.role="icon-absolute-left",i.name=e.name,i.setAttribute("x",B+(i.attribute.marginLeft??0)),B+=i.AABBBounds.width()+(i.attribute.marginLeft??0)+(i.attribute.marginRight??0),t.appendChild(i)})),C.forEach((e=>{const i=Lj(e,void 0,t.col,t.row,d);i.role="icon-absolute-right",i.name=e.name,i.setAttribute("x",M+(i.attribute.marginLeft??0)),M+=i.AABBBounds.width()+(i.attribute.marginLeft??0)+(i.attribute.marginRight??0),t.appendChild(i)})),0===b.length&&0===v.length){const t=pu(i).replace(/\r?\n/g,"\n").replace(/\r/g,"\n").split("\n"),e={text:1!==t.length||s?t:t[0],maxLineWidth:r?1/0:l-(n[1]+n[3])-_-A,textBaseline:"top",heightLimit:o?-1:h-(n[0]+n[2]),pickable:!1,autoWrapText:s,lineClamp:a,wordBreak:"break-word"},c=new J_(p.text?Object.assign({},p.text,e):e);c.name="text",R=c}else{const e=Object.assign({text:i?.toString()},t.parent?.theme?.userTheme?.text||{});p.text&&Object.assign(e,p.text),e.textBaseline="middle";const s=[...b.map((t=>kj(t))),e,...v.map((t=>kj(t)))];s[0].textAlign=c;const a=new dA({width:r?0:l-(n[1]+n[3])-_-A,height:o?0:h-(n[0]+n[2]),textConfig:s,verticalDirection:o?"top":u});a.name="text",R=a,a.bindIconEvent()}if(0!==m.length||0!==y.length){const e=new Ej({x:0,y:0,fill:!1,stroke:!1});e.name="content",e.setCellContentOption({autoWidth:r,autoHeight:o,cellWidth:l-(n[1]+n[3])-_-A,cellHeight:h-(n[0]+n[2]),align:c,baseline:u}),m.forEach((i=>{const n=Lj(i,void 0,t.col,t.row,d);n.role="icon-content-left",n.name=i.name,e.addLeftOccupyingIcon(n)})),y.forEach((i=>{const n=Lj(i,void 0,t.col,t.row,d);n.role="icon-content-right",n.name=i.name,e.addRightOccupyingIcon(n)})),e.addContent(R),t.appendChild(e),e.layout(),x=e.AABBBounds.width(),e.AABBBounds.height()}else t.firstChild?t.insertBefore(R,t.firstChild):t.appendChild(R),x=R.AABBBounds.width(),R.AABBBounds.height()}else if(i){const e=pu(i).replace(/\r?\n/g,"\n").replace(/\r/g,"\n").split("\n"),c=Hj(t.col,t.row,d),u={text:1!==e.length||s?e:e[0],maxLineWidth:r?1/0:l-(n[1]+n[3]+c),textBaseline:"top",autoWrapText:s,lineClamp:a,wordBreak:"break-word",heightLimit:o?-1:h-(n[0]+n[2]),pickable:!1,dx:c},f=new J_(p.text?Object.assign({},p.text,u):u);f.name="text",t.appendChild(f),x=f.AABBBounds.width(),f.AABBBounds.height()}const R=r?_+x+A:l-(n[1]+n[3]),P=h-(n[0]+n[2]);t.forEachChildren((t=>{"icon-left"===t.role?t.setAttribute("x",t.attribute.x+n[3]):"icon-right"===t.role?t.setAttribute("x",t.attribute.x+R-A+n[3]):"icon-absolute-right"===t.role?t.setAttribute("x",t.attribute.x+R-M+n[3]+n[1]):"content"!==t.name&&"text"!==t.name||("center"===c&&"richtext"!==t.type?t.setAttribute("x",n[3]+_+(R-_-A)/2):"right"===c&&"richtext"!==t.type?t.setAttribute("x",n[3]+R-A):t.setAttribute("x",n[3]+_))})),t.forEachChildren((t=>{"middle"===u?t.setAttribute("y",n[0]+(P-t.AABBBounds.height())/2):"bottom"===u?t.setAttribute("y",n[0]+P-t.AABBBounds.height()):t.setAttribute("y",n[0])})),t.setAttributes({width:R+n[1]+n[3],height:P+n[0]+n[2]})}(x,i,e,h,v,b,w,"number"==typeof C?C:void 0,a,l,c,u,t,g),g?._vtable?.marked){const t=qA({x:x.attribute.width,y:0,startAngle:Math.PI/2,endAngle:Math.PI,outerRadius:6,fill:"#3073F2",pickable:!1});t.name="mark",x.appendChild(t)}}return p&&x.setAttributes({width:Math.max(x.attribute.width,p.attribute.width),height:Math.max(x.attribute.height,p.attribute.height)}),x}const ZN=yj();function JN(t,e,i){t.then((()=>{i(),e.scenegraph.updateNextFrame()})).catch((t=>{console.error(t)}))}function QN(t,e,i,n,r,o,s,a,l,h,c,u,d,p,f,g,m){let y,b;if(i.internalProps?.dataConfig?.mappingRules&&!i.isHeader(n,r)&&i.internalProps?.dataConfig?.mappingRules?.forEach(((t,e)=>{t.bgColor&&i.internalProps.layoutMap.getIndicatorKey(n,r)===t.bgColor.indicatorKey&&(y=t.bgColor.mapping)})),"text"===t||"link"===t){if("link"===t){const o=i.getCellValue(n,r),s=i._getCellStyle(n,r);"link"===t&&("templateLink"in e&&e.templateLink||!("linkDetect"in e)||!e.linkDetect||_f.test(o))&&(m?(m.text.fill=Cj("linkColor",s,n,r,i),m.group.cursor="pointer"):m={text:{fill:Cj("linkColor",s,n,r,i)},group:{cursor:"pointer"}})}if(y){const t=i.getCellOriginValue(n,r),e=y(i,t);e&&(m?m.group.fill=e:m={group:{fill:e}})}let v,w,C,x=!0;if("body"!==i.getCellLocation(n,r)?(w=e?.headerCustomRender,C=e?.headerCustomLayout):(w=e?.customRender||i.customRender,C=e?.customLayout),C||w){const t=Oj(C,w,n,r,i.getColWidth(n),i.getRowHeight(r),!1,"autoHeight"===i.heightMode,i);v=t.elementsGroup,x=t.renderDefault}b=qN(i,l,0,h,n,r,o,s,a,c,u,d,p,v,x,m),f&&(b.mergeCol=g.end.col,b.mergeRow=g.end.row);const _=i.internalProps.layoutMap.getAxisConfigInPivotChart(n,r);if(_){const t=new hW(_,b.attribute.width,b.attribute.height,i);b.clear(),b.appendChild(t.component),t.overlap()}else i.internalProps.layoutMap.isEmpty(n,r)&&b.clear()}else if("image"===t)b=function(t,e,i,n,r,o,s,a,l,h,c,u,d,p){const f=xj("padding",d._getCellStyle(n,r),n,r,d);bu(f)&&(h=f),p?.text?.textAlign&&(c=p?.text?.textAlign),p?.text?.textBaseline&&(u=p?.text?.textBaseline);const g=new bj({x:e,y:i,width:o,height:s,lineWidth:p?.group?.lineWidth??void 0,fill:p?.group?.fill??void 0,stroke:p?.group?.stroke??void 0,strokeArrayWidth:p?.group?.strokeArrayWidth??void 0,strokeArrayColor:p?.group?.strokeArrayColor??void 0,cursor:p?.group?.cursor??void 0,lineCap:"square",clip:!0});g.role="cell",g.col=n,g.row=r,t?.addChild(g);const m=d.getCellValue(n,r),y=rT({x:h[3],y:h[0],width:o-h[1]-h[3],height:s-h[0]-h[2],image:m,cursor:"pointer"});return y.name="image",y.keepAspectRatio=a,y.successCallback=a||l?()=>{const t=y.resources.get(y.attribute.image).data;if(l&&_j(n,r,t.width,t.height,d.scenegraph,h),a){const{width:e,height:i}=vj(t.width,t.height,g.attribute.width-h[1]-h[3],g.attribute.height-h[0]-h[2]),n=wj(0,0,g.attribute.width,g.attribute.height,e,i,c,u,h);y.setAttributes({x:n.x,y:n.y,width:e,height:i})}d.scenegraph.updateNextFrame()}:()=>{Sj(g,n,r,d)},y.failCallback=()=>{const t=yj();y.image=t.damage_pic.svg},g.appendChild(y),g}(l,0,h,n,r,i.getColWidth(n),i.getRowHeight(r),e.keepAspectRatio,e.imageAutoSizing,c,u,d,i,m);else if("video"===t)b=function(t,e,i,n,r,o,s,a,l,h,c,u,d,p){const f=xj("padding",d._getCellStyle(n,r),n,r,d);bu(f)&&(h=f),p?.text?.textAlign&&(c=p?.text?.textAlign),p?.text?.textBaseline&&(u=p?.text?.textBaseline);const g=new bj({x:e,y:i,width:o,height:s,lineWidth:p?.group?.lineWidth??void 0,fill:p?.group?.fill??void 0,stroke:p?.group?.stroke??void 0,strokeArrayWidth:p?.group?.strokeArrayWidth??void 0,strokeArrayColor:p?.group?.strokeArrayColor??void 0,cursor:p?.group?.cursor??void 0,lineCap:"square",clip:!0});g.role="cell",g.col=n,g.row=r,t?.addChild(g);const m=d.getCellValue(n,r),y=document.createElement("video");y.addEventListener("loadeddata",(()=>{l&&_j(n,r,y.videoWidth,y.videoHeight,d.scenegraph,h);const t=g.attribute.width,e=g.attribute.height;if(a){const{width:i,height:n}=vj(y.videoWidth,y.videoHeight,t-h[1]-h[3],e-h[0]-h[2]),r=wj(0,0,t,e,i,n,c,u,h);b.setAttributes({width:i,height:n,x:r.x,y:r.y})}else b.setAttributes({x:h[3],y:h[0],width:t-h[1]-h[3],height:e-h[2]-h[0]});const i=Math.floor(Math.min(t-h[1]-h[3],e-h[2]-h[0])/2),o=0+(t>b.attribute.width?b.attribute.x-0+b.attribute.width/2:t/2),s=0+(e>b.attribute.height?b.attribute.y-0+b.attribute.height/2:e/2),p=new Pj({x:o-i/2,y:s-i/2,width:i,height:i,image:ZN.play.svg,cursor:ZN.play.cursor});p.name="play-icon",g.appendChild(p),d.scenegraph.updateNextFrame()})),y.onerror=()=>{b.image=ZN.damage_pic.svg},y.src=m,y.setAttribute("preload","auto");const b=rT({x:h[3],y:h[0],width:o-h[1]-h[3],height:s-h[2]-h[0],image:y,cursor:"pointer"});return b.name="image",g.appendChild(b),g}(l,0,h,n,r,i.getColWidth(n),i.getRowHeight(r),e.keepAspectRatio,e.imageAutoSizing,c,u,d,i,m);else if("chart"===t){const t=i.internalProps.layoutMap.getChartInstance(n,r);b=YN(null,l,0,h,n,r,i.getColWidth(n),i.getRowHeight(r),c,i.getCellValue(n,r),e.chartModule,i.isPivotChart()?i.internalProps.layoutMap.getChartSpec(n,r):e.chartSpec,t,i.internalProps.layoutMap?.getChartDataId(n,r)??"data",i,m)}else if("progressbar"===t){const t=i._getCellStyle(n,r),p=i.getCellValue(n,r),f=i.getCellOriginValue(n,r);b=qN(i,l,0,h,n,r,o,s,a,c,u,d,!1,null,!0,m);const g=Aj(e,t,o,p,f,n,r,0,i);b.firstChild?b.insertBefore(g,b.firstChild):b.appendChild(g)}else"sparkline"===t&&(b=Mj(null,l,0,h,n,r,s,a,c,i,m));return b}function tG(t,e,i,n){const r=i.scenegraph.highPerformanceGetCell(t,e,!0);if(!n&&"empty"===r.role)return;const o=i.isHeader(t,e)?i._getHeaderLayoutMap(t,e).headerType:i.getBodyColumnType(t,e),s=i.getCellLocation(t,e),a="body"!==s?i.getHeaderDefine(t,e):i.getBodyColumnDefine(t,e);let l,h,c;if(("body"!==s||a?.mergeCell)&&(h=i.getCellRange(t,e),l=h.start.col!==h.end.col||h.start.row!==h.end.row),!l||t===h.start.col&&e===h.start.row){const u="body"!==s||(!!a?.icon||!!a?.tree),d=pj(i._getCellStyle(t,e),i,t,e,Cj).theme,p=d._vtable.padding,f=d._vtable.textAlign,g=d._vtable.textBaseline;let m,y,b;i.internalProps?.dataConfig?.mappingRules&&!i.isHeader(t,e)&&i.internalProps?.dataConfig?.mappingRules?.forEach(((n,r)=>{n.bgColor&&i.internalProps.layoutMap.getIndicatorKey(t,e)===n.bgColor.indicatorKey&&(m=n.bgColor.mapping)})),"body"!==s?(a?.headerCustomRender,a?.headerCustomLayout):(a?.customRender||i.customRender,a?.customLayout),h?(y=i.getColsWidth(h.start.col,h.end.col),b=i.getRowsHeight(h.start.row,h.end.row)):(y=i.getColWidth(t),b=i.getRowHeight(e));const v=i.getCellValue(t,e);Yp(v)?(r.removeAllChild(),JN(v,i,eG.bind(null,o,a,i,t,e,m,y,b,r,p,f,g,u,l,h,n,d))):c=eG(o,a,i,t,e,m,y,b,r,p,f,g,u,l,h,n,d)}else c=new bj({x:0,y:n?0:r.attribute.y,width:0,height:0,visible:!1,pickable:!1}),c.role="shadow-cell",c.col=t,c.row=e,c.mergeCol=h.start.col,c.mergeRow=h.start.row,n||(r.parent.insertAfter(c,r),r.parent.removeChild(r),tG(h.start.col,h.start.row,i,!1));return c}function eG(t,e,i,n,r,o,s,a,l,h,c,u,d,p,f,g,m){const y=QN(t,e,i,n,r,i.getColWidth(n),s,a,g?i.scenegraph.getColGroup(n):l.parent,g?0:l.attribute.y,h,c,u,d,p,f,m);return g||(l.parent.insertAfter(y,l),l.parent.removeChild(l),i.scenegraph?.proxy.cellCache.get(n)&&i.scenegraph?.proxy.cellCache.set(n,y)),y}function iG(t,e,i,n,r,o,s,a,l,h){let c,u,d,p=0,f=0;t.colHeight&&(f=t.colHeight);for(let g=n;g<=r;g++){const n=g,r="body"!==l?a.getHeaderDefine(e,n):a.getBodyColumnDefine(e,n),m="body"!==l||(!!r?.icon||!!r?.tree),y=pj(a._getCellStyle(e,n),a,e,n,Cj).theme;y.group.width=i,y.group.height=Array.isArray(s)?s[n]:s,y._vtable.padding&&(c=y._vtable.padding),y.text.textAlign&&(u=y.text.textAlign),y.text.textBaseline&&(d=y.text.textBaseline),"body"===l||y.group.fill||(y.group.fill="#fff");let b=i,v=a.getRowHeight(n);const w=(a.isHeader(e,n)?a._getHeaderLayoutMap(e,n).headerType:a.getBodyColumnType(e,n))||"text";let C,x,_;if(("body"!==l||r?.mergeCell)&&(x=a.getCellRange(e,n),_=x.start.col!==x.end.col||x.start.row!==x.end.row,_&&(b=0,v=0,C=o.get(`${x.start.col},${x.start.row};${x.end.col},${x.end.row}`),!C))){for(let t=x.start.col;t<=x.end.col;t++)b+=a.getColWidth(t);for(let t=x.start.row;t<=x.end.row;t++)v+=a.getRowHeight(t);o.set(`${x.start.col},${x.start.row};${x.end.col},${x.end.row}`,{x:0,y:f,cellWidth:b,cellHeight:v})}if(C){const i=C.cellHeight/(x.end.row-x.start.row+1),r=new bj({x:0,y:f,width:0,height:i,visible:!1,pickable:!1});r.role="shadow-cell",r.col=e,r.row=n,r.mergeCol=x.start.col,r.mergeRow=x.start.row,t?.addChild(r),t.updateColumnRowNumber(n),t.updateColumnHeight(i),x=a.getCellRange(e,n),f+=i,p=Math.max(p,C.cellWidth)}else{const o=a.getCellValue(e,n);if(Yp(o)){JN(o,a,QN.bind(null,w,r,a,e,n,i,b,v,t,f,c,u,d,m,_,x,y)),t.updateColumnRowNumber(n);const s=_?a.getRowHeight(n)/(x.end.row-x.start.row+1):a.getRowHeight(n);t.updateColumnHeight(s),f+=s}else{const o=QN(w,r,a,e,n,i,b,v,t,f,c,u,d,m,_,x,y);t.updateColumnRowNumber(n);const s=_?o.attribute.height/(x.end.row-x.start.row+1):o.attribute.height;t.updateColumnHeight(s),f+=s}}if(h&&n>h)break}return t.setAttribute("width",i),{width:i,height:f}}function nG(t,e,i,n,r,o,s,a,l,h){if(n>r||o>s)return;const{layoutMap:c,defaultRowHeight:u,defaultHeaderRowHeight:d,defaultColWidth:p}=l.internalProps;let f=0,g=0;for(let c=n;c<=r;c++){const n=c,r=l.getColWidth(n),p=new bj({x:e+f,y:i,width:r,height:0,clip:!1,pickable:!1});p.role="column",p.col=c,t.addChild(p);const{width:m,height:y}=iG(p,n,r,o,s,l.scenegraph.mergeMap,"columnHeader"===a?d??u:u,l,a,h);f+=m,g=Math.max(g,y)}t.setAttribute("width",f),t.setAttribute("height",g)}function rG(t,e){for(let i=0;i<e.table.colCount;i++){if(i>=e.table.rowHeaderLevelCount&&i<e.colStart||i>e.colEnd&&i<e.table.colCount-e.table.rightFrozenColCount)continue;const n=Sk(e.table,i,t);if(n&&n.start.row!==t){const r=e.highPerformanceGetCell(i,t,!0),o=tG(n.start.col,n.start.row,e.table,!0);o.col=i,o.row=t,o.setAttribute("y",e.table.getRowsHeight(e.table.columnHeaderLevelCount,n.start.row-1)),r.parent.insertAfter(o,r),r.parent.removeChild(r),r.needUpdate=!1,o.needUpdate=!1,e.cellCache.get(i)&&e.cellCache.set(i,o)}}}function oG(t,e,i){for(let n=0;n<i.table.rowCount;n++){if(n>=i.table.columnHeaderLevelCount&&n<i.rowStart||n>i.rowEnd&&n<i.table.rowCount-i.table.bottomFrozenRowCount)continue;const r=Sk(i.table,t,n);if(r&&r.start.col!==t){if(e&&sG(r.start.col,r.end.col,n,i))continue;const o=i.highPerformanceGetCell(t,n,!0),s=tG(r.start.col,r.start.row,i.table,!0);s.col=t,s.row=n,s.setAttribute("x",i.table.getColsWidth(i.table.rowHeaderLevelCount,r.start.col-1)-o.parent.attribute.x),o.parent.insertAfter(s,o),o.parent.removeChild(o),o.needUpdate=!1,s.needUpdate=!1,i.cellCache.get(t)&&i.cellCache.set(t,s)}}}function sG(t,e,i,n){for(let r=t;r<=e;r++)if("shadow-cell"!==n.highPerformanceGetCell(r,i,!0).role&&"empty"!==n.highPerformanceGetCell(r,i,!0).role)return!0;return!1}function aG(t){let e=t.firstChild;for(;"group"!==e.type;)e=e._next;return e}function lG(t){let e=t.lastChild;for(;"group"!==e.type;)e=e._prev;return e}function hG(t,e,i,n="left"){for(let r=t;r<=e;r++){const t=i.scenegraph.getColGroup(r);t&&cG(t,i,n);const e=i.scenegraph.getColGroup(r,!0);e&&cG(e,i,n);const o=i.scenegraph.getColGroupInBottom(r);o&&cG(o,i,n)}const r=Math.min(i.scenegraph.proxy.colLimit,i.scenegraph.proxy.bodyRightCol-i.scenegraph.proxy.bodyLeftCol+1),o=i.getColsWidth(i.rowHeaderLevelCount,i.rowHeaderLevelCount+r),s=i.getColsWidth(i.rowHeaderLevelCount,i.colCount-1);i.scenegraph.proxy.xLimitLeft=o/2,i.scenegraph.proxy.xLimitRight=s-o/2}function cG(t,e,i="left"){if("left"===i){let i;const n=function(t){let e=t._prev;for(;e&&"group"!==e.type;)e=e._prev;return e}(t);i=n?n.attribute.x+e.getColWidth(t._prev.col):e.getColsWidth(e.rowHeaderLevelCount,t.col-1),t.setAttribute("x",i)}else{let i;const n=function(t){let e=t._next;for(;e&&"group"!==e.type;)e=e._next;return e}(t);i=n?n.attribute.x-e.getColWidth(t.col):e.getColsWidth(e.rowHeaderLevelCount,t.col-1),t.setAttribute("x",i)}}async function uG(t,e,i,n,r){if("left"===e&&r.colEnd+t>r.bodyRightCol?t=r.bodyRightCol-r.colEnd:"right"===e&&r.colStart-t<r.bodyLeftCol&&(t=r.colStart-r.bodyLeftCol),!(t<=0))if(t<r.colEnd-r.colStart){const o="left"===e?r.colStart:r.colEnd-t+1,s="left"===e?r.colStart+t-1:r.colEnd,a="left"===e?r.colEnd+1:r.colStart-t,l="left"===e?r.colEnd+t:r.colStart-1;kN(r.table,a,l),function(t,e,i,n){for(let r=t;r<=e;r++)n.table.scenegraph.bodyGroup.childrenCount>0&&fG(n.table.scenegraph.bodyGroup,i,n),n.table.scenegraph.colHeaderGroup.childrenCount>0&&fG(n.table.scenegraph.colHeaderGroup,i,n),n.table.scenegraph.bottomFrozenGroup.childrenCount>0&&fG(n.table.scenegraph.bottomFrozenGroup,i,n)}(o,s,e,r);const h=a,c=l;r.colStart="left"===e?r.colStart+t:r.colStart-t,r.colEnd="left"===e?r.colEnd+t:r.colEnd-t,oG(a,!0,r),gG(h,c,r),hG(h,c,r.table,e);const u=n-(r.table.scenegraph.getColGroup(i).attribute.x+r.table.getFrozenColsWidth()+r.table.scenegraph.proxy.deltaX);r.table.scenegraph.proxy.deltaX+=u,r.currentCol="left"===e?r.currentCol+t:r.currentCol-t,r.totalCol="left"===e?r.totalCol+t:r.totalCol-t,r.referenceCol=r.colStart+Math.floor((r.colEnd-r.colStart)/2),r.colUpdatePos=a,r.colUpdateDirection=e,r.table.scenegraph.updateNextFrame(),await r.progress()}else{const i="left"===e?r.colStart+t:r.colStart-t,n="left"===e?r.colEnd+t:r.colEnd-t;kN(r.table,i,n);!function(t,e,i,n){n.table.scenegraph.colHeaderGroup.forEachChildren(((r,o)=>{"group"===r.type&&dG(r,"left"===i?r.col+e:r.col-e,0===o?t:r._prev.attribute.x+n.table.getColWidth(r._prev.col))})),n.table.scenegraph.bottomFrozenGroup.forEachChildren(((r,o)=>{"group"===r.type&&dG(r,"left"===i?r.col+e:r.col-e,0===o?t:r._prev.attribute.x+n.table.getColWidth(r._prev.col))})),n.table.scenegraph.bodyGroup.forEachChildren(((r,o)=>{"group"===r.type&&dG(r,"left"===i?r.col+e:r.col-e,0===o?t:r._prev.attribute.x+n.table.getColWidth(r._prev.col))}))}(r.table.getColsWidth(r.bodyLeftCol,i-1),t,e,r);const o=i,s=n;r.colStart=i,r.colEnd=n,oG(i,!1,r),gG(o,s,r),hG(o,s,r.table,n>r.bodyRightCol-(r.colEnd-r.colStart+1)?"right":"left"),r.table.scenegraph.proxy.deltaX=0,r.currentCol="left"===e?r.currentCol+t:r.currentCol-t,r.totalCol="left"===e?r.totalCol+t:r.totalCol-t,r.referenceCol=r.colStart+Math.floor((r.colEnd-r.colStart)/2),r.colUpdatePos=r.colStart,r.colUpdateDirection=n>r.bodyRightCol-(r.colEnd-r.colStart+1)?"right":"left",r.table.scenegraph.updateNextFrame(),await r.progress()}}function dG(t,e,i){t.col=e,t.forEachChildren((t=>{t.col=e,t.needUpdate=!0})),t.setAttribute("x",i),t.needUpdate=!0}function pG(t,e){if(!t)return;let i=t.firstChild;for(;i;){i=e.updateCellGroupContent(i)._next}t.needUpdate=!1,t.setAttribute("width",e.table.getColWidth(t.col))}function fG(t,e,i){if("left"===e){const e=aG(t),n=lG(t);dG(e,n.col+1,n.attribute.x+i.table.getColWidth(n.col)),t.appendChild(e),t.border&&t.appendChild(t.border)}else{const e=lG(t),n=aG(t);dG(e,n.col-1,n.attribute.x-i.table.getColWidth(n.col-1)),t.insertBefore(e,t.firstChild)}}function gG(t,e,i){for(let n=t;n<=e;n++){const t=i.table.scenegraph.getColGroup(n);t&&pG(t,i);const e=i.table.scenegraph.getColGroup(n,!0);e&&pG(e,i);const r=i.table.scenegraph.getColGroupInBottom(n);r&&pG(r,i)}}function mG(t,e,i,n,r,o="up"){if("up"===o)for(let o=t;o<=e;o++)for(let t=i;t<=n;t++){const e=r.scenegraph.highPerformanceGetCell(o,t,!0);if(!e.row)continue;let i;i=e._prev?e._prev?.attribute.y+r.getRowHeight(e._prev.row):r.getRowsHeight(r.columnHeaderLevelCount,e.row-1),e.setAttribute("y",i)}else for(let o=t;o<=e;o++)for(let t=n;t>=i;t--){const e=r.scenegraph.highPerformanceGetCell(o,t,!0);if(!e.row)continue;let i;i=e._next?e._next?.attribute.y-r.getRowHeight(e.row):r.getRowsHeight(r.columnHeaderLevelCount,e.row-1),e.setAttribute("y",i)}const s=Math.min(r.scenegraph.proxy.rowLimit,r.scenegraph.proxy.bodyBottomRow-r.scenegraph.proxy.bodyTopRow+1),a=r.getRowsHeight(r.columnHeaderLevelCount,r.columnHeaderLevelCount+s),l=r.getRowsHeight(r.columnHeaderLevelCount,r.rowCount-1);r.scenegraph.proxy.yLimitTop=a/2,r.scenegraph.proxy.yLimitBottom=l-a/2}async function yG(t,e,i,n,r){if("up"===e&&r.rowEnd+t>r.bodyBottomRow?t=r.bodyBottomRow-r.rowEnd:"down"===e&&r.rowStart-t<r.bodyTopRow&&(t=r.rowStart-r.bodyTopRow),t<r.rowEnd-r.rowStart){!function(t,e,i,n){for(let r=0;r<n.table.rowHeaderLevelCount;r++){const o=n.table.scenegraph.getColGroup(r);for(let r=t;r<=e;r++)bG(o,i,n)}for(let r=n.table.colCount-n.table.rightFrozenColCount;r<n.table.colCount;r++){const o=n.table.scenegraph.getColGroup(r);for(let r=t;r<=e;r++)bG(o,i,n)}for(let r=n.bodyLeftCol;r<=n.bodyRightCol;r++){const o=n.table.scenegraph.getColGroup(r);for(let r=t;r<=e;r++)bG(o,i,n)}}("up"===e?r.rowStart:r.rowEnd-t+1,"up"===e?r.rowStart+t-1:r.rowEnd,e,r);const o="up"===e?r.rowEnd+1:r.rowStart-t,s="up"===e?r.rowEnd+t:r.rowStart-1;let a,l;if("autoHeight"===r.table.heightMode)a=o,l=s;else{const t=Math.max(r.bodyTopRow,i-1*r.screenRowCount),e=Math.min(r.bodyBottomRow,i+2*r.screenRowCount);a=Math.max(o,t),l=Math.min(s,e)}if(jN(r.table,a,l),r.rowStart="up"===e?r.rowStart+t:r.rowStart-t,r.rowEnd="up"===e?r.rowEnd+t:r.rowEnd-t,rG(a,r),vG(a,l,r),"autoHeight"===r.table.heightMode){mG(r.bodyLeftCol,r.bodyRightCol,a,l,r.table,e);const t=n-(r.table.scenegraph.highPerformanceGetCell(r.bodyLeftCol,i,!0).attribute.y+r.table.getFrozenRowsHeight()+r.table.scenegraph.proxy.deltaY);r.table.scenegraph.proxy.deltaY+=t}r.currentRow="up"===e?r.currentRow+t:r.currentRow-t,r.totalRow="up"===e?r.totalRow+t:r.totalRow-t,r.referenceRow=r.rowStart+Math.floor((r.rowEnd-r.rowStart)/2),r.rowUpdatePos=o,r.rowUpdateDirection=e,r.table.scenegraph.updateNextFrame(),"autoHeight"!==r.table.heightMode&&await r.progress()}else{const n="up"===e?r.rowStart+t:r.rowStart-t,o="up"===e?r.rowEnd+t:r.rowEnd-t;let s,a;!function(t,e,i,n){for(let r=0;r<n.table.rowHeaderLevelCount;r++){const o=n.table.scenegraph.getColGroup(r);o?.forEachChildren(((r,o)=>{n.updateCellGroupPosition(r,"up"===i?r.row+e:r.row-e,0===o?t:r._prev.attribute.y+n.table.getRowHeight(r._prev.row))}))}for(let r=n.table.colCount-n.table.rightFrozenColCount;r<n.table.colCount;r++){const o=n.table.scenegraph.getColGroup(r);o?.forEachChildren(((r,o)=>{n.updateCellGroupPosition(r,"up"===i?r.row+e:r.row-e,0===o?t:r._prev.attribute.y+n.table.getRowHeight(r._prev.row))}))}for(let r=n.bodyLeftCol;r<=n.bodyRightCol;r++){const o=n.table.scenegraph.getColGroup(r);o?.forEachChildren(((r,o)=>{n.updateCellGroupPosition(r,"up"===i?r.row+e:r.row-e,0===o?t:r._prev.attribute.y+n.table.getRowHeight(r._prev.row))}))}}(r.table.getRowsHeight(r.bodyTopRow,n-1),t,e,r),"autoHeight"===r.table.heightMode?(s=n,a=o):(s=Math.max(r.bodyTopRow,i-1*r.screenRowCount),a=Math.min(r.bodyBottomRow,i+2*r.screenRowCount)),jN(r.table,s,a),r.rowStart=n,r.rowEnd=o,rG(s,r),vG(s,a,r),"autoHeight"===r.table.heightMode&&mG(r.bodyLeftCol,r.bodyRightCol,s,a,r.table,o>r.bodyBottomRow-(r.rowEnd-r.rowStart+1)?"down":"up"),r.table.scenegraph.proxy.deltaY=0,r.currentRow="up"===e?r.currentRow+t:r.currentRow-t,r.totalRow="up"===e?r.totalRow+t:r.totalRow-t,r.referenceRow=r.rowStart+Math.floor((r.rowEnd-r.rowStart)/2),r.rowUpdatePos=r.rowStart,r.rowUpdateDirection=o>r.bodyBottomRow-(r.rowEnd-r.rowStart+1)?"down":"up",r.table.scenegraph.updateNextFrame(),"autoHeight"!==r.table.heightMode&&await r.progress()}}function bG(t,e,i){if("up"===e){const e=t.firstChild;i.updateCellGroupPosition(e,t.lastChild.row+1,t.lastChild.attribute.y+i.table.getRowHeight(t.lastChild.row)),t.appendChild(e)}else{const e=t.lastChild;i.updateCellGroupPosition(e,t.firstChild.row-1,t.firstChild.attribute.y-i.table.getRowHeight(e.row)),t.insertBefore(e,t.firstChild)}}function vG(t,e,i){for(let n=0;n<i.table.rowHeaderLevelCount;n++)for(let r=t;r<=e;r++){const t=i.highPerformanceGetCell(n,r,!0);i.updateCellGroupContent(t)}for(let n=i.table.colCount-i.table.rightFrozenColCount;n<i.table.colCount;n++)for(let r=t;r<=e;r++){const t=i.highPerformanceGetCell(n,r);i.updateCellGroupContent(t)}for(let n=i.bodyLeftCol;n<=i.bodyRightCol;n++)for(let r=t;r<=e;r++){const t=i.highPerformanceGetCell(n,r);i.updateCellGroupContent(t)}}class wG{table;mode="column";rowLimit=1e3;currentRow=0;totalRow;yLimitTop;yLimitBottom;rowStart=0;rowEnd=0;referenceRow=0;bodyTopRow;bodyBottomRow;screenRowCount;firstScreenRowLimit;taskRowCount;rowUpdatePos;rowUpdateDirection;screenTopRow=0;deltaY=0;colLimit=100;bodyLeftCol;bodyRightCol;totalCol;colStart;colEnd;taskColCount;xLimitLeft;xLimitRight;screenColCount;firstScreenColLimit;colUpdatePos;currentCol;referenceCol;screenLeftCol=0;colUpdateDirection;deltaX=0;cellCache=new Map;constructor(t){this.table=t,this.table.isPivotChart()?(this.rowLimit=100,this.colLimit=100):"autoHeight"===this.table.heightMode?this.rowLimit=100:"autoWidth"===this.table.widthMode&&(this.colLimit=100),this.table.internalProps.transpose?this.mode="row":this.table.isPivotTable()&&(this.mode="pivot"),this.table.options.maintainedDataCount&&(this.rowLimit=this.table.options.maintainedDataCount)}setParamsForColumn(){this.bodyLeftCol=this.table.rowHeaderLevelCount,this.bodyRightCol=this.table.colCount-1-this.table.rightFrozenColCount;const t=Math.min(this.colLimit,this.bodyRightCol-this.bodyLeftCol+1);this.totalCol=this.bodyLeftCol+t-1,this.colStart=this.bodyLeftCol;const e=this.table.defaultColWidth;this.taskColCount=1*Math.ceil(this.table.tableNoFrameWidth/e);const i=e*t,n=e*(this.bodyRightCol-this.bodyLeftCol+1);this.xLimitLeft=i/2,this.xLimitRight=n-i/2;const r=5*this.table.tableNoFrameWidth;this.screenColCount=Math.ceil(this.table.tableNoFrameWidth/e),this.firstScreenColLimit=this.bodyLeftCol+Math.ceil(r/e),this.colUpdatePos=this.bodyRightCol}setParamsForRow(){this.bodyTopRow=this.table.columnHeaderLevelCount,this.bodyBottomRow=this.table.rowCount-1-this.table.bottomFrozenRowCount;const t=Math.min(this.rowLimit,this.bodyBottomRow-this.bodyTopRow+1);this.totalRow=this.bodyTopRow+t-1,this.rowStart=this.bodyTopRow;const e=this.table.defaultRowHeight;this.taskRowCount=1*Math.ceil(this.table.tableNoFrameHeight/e);const i=e*t,n=e*(this.bodyBottomRow-this.bodyTopRow+1);this.yLimitTop=i/2,this.yLimitBottom=n-i/2;const r=5*this.table.tableNoFrameHeight;this.screenRowCount=Math.ceil(this.table.tableNoFrameHeight/e),this.firstScreenRowLimit=this.bodyTopRow+Math.ceil(r/e),this.rowUpdatePos=this.bodyBottomRow}async createGroupForFirstScreen(t,e,i,n,r,o,s,a){await async function(t,e,i,n,r,o,s,a,l){const{leftBottomCornerGroup:h,rightTopCornerGroup:c,rightBottomCornerGroup:u}=l.table.scenegraph;l.setParamsForRow(),l.setParamsForColumn(),kN(l.table,0,Math.min(l.firstScreenColLimit,l.table.colCount-1)),jN(l.table,0,Math.min(l.firstScreenRowLimit,l.table.rowCount-1)),l.table.rightFrozenColCount>0&&l.table.colCount-1>l.firstScreenColLimit&&kN(l.table,l.table.colCount-1-l.table.rightFrozenColCount+1,l.table.colCount-1),l.table.bottomFrozenRowCount>0&&l.table.rowCount-1>l.firstScreenRowLimit&&kN(l.table,l.table.rowCount-1-l.table.bottomFrozenRowCount+1,l.table.rowCount-1),l.table.scenegraph.colHeaderGroup.setAttribute("x",l.table.getFrozenColsWidth()),l.table.scenegraph.rowHeaderGroup.setAttribute("y",l.table.getFrozenRowsHeight()),l.table.scenegraph.bottomFrozenGroup.setAttribute("x",l.table.getFrozenColsWidth()),l.table.scenegraph.rightFrozenGroup.setAttribute("y",l.table.getFrozenRowsHeight()),l.table.scenegraph.bodyGroup.setAttributes({x:l.table.getFrozenColsWidth(),y:l.table.getFrozenRowsHeight()}),nG(t,s,a,0,l.table.rowHeaderLevelCount-1,0,l.table.columnHeaderLevelCount-1,"cornerHeader",l.table),nG(e,s,a,l.table.rowHeaderLevelCount,Math.min(l.firstScreenColLimit,l.table.colCount-1-l.table.rightFrozenColCount),0,l.table.columnHeaderLevelCount-1,"columnHeader",l.table),nG(i,s,a,0,l.table.rowHeaderLevelCount-1,l.table.columnHeaderLevelCount,Math.min(l.firstScreenRowLimit,l.table.rowCount-1-l.table.bottomFrozenRowCount),"rowHeader",l.table),l.table.bottomFrozenRowCount>0&&(l.table.isPivotChart()||nG(h,s,a,0,l.table.rowHeaderLevelCount-1,l.table.rowCount-1-l.table.bottomFrozenRowCount+1,l.table.rowCount-1,"rowHeader",l.table),nG(r,s,a,l.table.rowHeaderLevelCount,Math.min(l.firstScreenColLimit,l.table.colCount-1-l.table.rightFrozenColCount),l.table.rowCount-1-l.table.bottomFrozenRowCount+1,l.table.rowCount-1,"body",l.table)),l.table.rightFrozenColCount>0&&(l.table.isPivotChart()||nG(c,s,a,l.table.colCount-1-l.table.rightFrozenColCount+1,l.table.colCount-1,0,l.table.columnHeaderLevelCount-1,"columnHeader",l.table),nG(n,s,a,l.table.colCount-1-l.table.rightFrozenColCount+1,l.table.colCount-1,l.table.columnHeaderLevelCount,Math.min(l.firstScreenRowLimit,l.table.rowCount-1-l.table.bottomFrozenRowCount),"body",l.table)),l.table.bottomFrozenRowCount>0&&l.table.rightFrozenColCount>0&&!l.table.isPivotChart()&&nG(u,s,a,l.table.colCount-1-l.table.rightFrozenColCount+1,l.table.colCount-1,l.table.rowCount-1-l.table.bottomFrozenRowCount+1,l.table.rowCount-1,"body",l.table),nG(o,s,a,l.table.rowHeaderLevelCount,Math.min(l.firstScreenColLimit,l.table.colCount-1-l.table.rightFrozenColCount),l.table.columnHeaderLevelCount,Math.min(l.firstScreenRowLimit,l.table.rowCount-1-l.table.bottomFrozenRowCount),"body",l.table),o.firstChild?(l.currentRow=o.firstChild?.rowNumber??l.totalRow,l.rowEnd=l.currentRow,l.rowUpdatePos=l.rowEnd,l.referenceRow=l.rowStart+Math.floor((l.rowEnd-l.rowStart)/2),l.currentCol=o.lastChild?.col??l.totalCol,l.colEnd=l.currentCol,l.colUpdatePos=l.colEnd,l.referenceCol=l.colStart+Math.floor((l.colEnd-l.colStart)/2),await l.progress()):(l.currentRow=l.totalRow,l.rowEnd=l.currentRow,l.rowUpdatePos=l.rowEnd,l.referenceRow=l.rowStart+Math.floor((l.rowEnd-l.rowStart)/2),l.currentCol=l.totalCol,l.colEnd=l.currentCol,l.colUpdatePos=l.colEnd,l.referenceCol=l.colStart+Math.floor((l.colEnd-l.colStart)/2))}(t,e,i,n,r,o,s,a,this)}async progress(){return new Promise(((t,e)=>{setTimeout((async()=>{this.colUpdatePos<this.colEnd?(await this.updateColCellGroupsAsync(),await this.progress()):this.rowUpdatePos<this.rowEnd?(await this.updateRowCellGroupsAsync(),await this.progress()):this.currentCol<this.totalCol?(await this.createCol(),await this.progress()):this.currentRow<this.totalRow&&(await this.createRow(),await this.progress()),t()}),0)}))}async createRow(){this.taskRowCount&&(console.log("createRow",this.currentRow,this.currentRow+this.taskRowCount),this.createRowCellGroup(this.taskRowCount))}async createCol(){this.taskColCount&&(console.log("createCol",this.currentCol,this.currentCol+this.taskColCount),this.createColGroup(this.taskRowCount))}createRowCellGroup(t){const e=Math.min(this.totalRow,this.currentRow+t);if(jN(this.table,this.currentRow+1,e,!1),this.table.rowHeaderLevelCount){let t=0;for(let i=0;i<this.table.rowHeaderLevelCount;i++){const n=this.table.scenegraph.getColGroup(i),r="rowHeader",{height:o}=iG(n,i,n.attribute.width,this.currentRow+1,e,this.table.scenegraph.mergeMap,this.table.internalProps.defaultRowHeight,this.table,r);t=Math.max(t,o),this.table.scenegraph.rowHeaderGroup.setAttribute("height",t)}}if(this.table.rightFrozenColCount){let t=0;for(let i=this.table.colCount-this.table.rightFrozenColCount;i<this.table.colCount;i++){const n=this.table.scenegraph.getColGroup(i),r="rowHeader",{height:o}=iG(n,i,n.attribute.width,this.currentRow+1,e,this.table.scenegraph.mergeMap,this.table.internalProps.defaultRowHeight,this.table,r);t=Math.max(t,o),this.table.scenegraph.rightFrozenGroup.setAttribute("height",t)}}let i=0;for(let t=this.bodyLeftCol;t<=this.bodyRightCol;t++){const n=this.table.scenegraph.getColGroup(t),r="body",{height:o}=iG(n,t,n.attribute.width,this.currentRow+1,e,this.table.scenegraph.mergeMap,this.table.internalProps.defaultRowHeight,this.table,r);i=Math.max(i,o)}this.table.scenegraph.bodyGroup.setAttribute("height",i),this.currentRow=e,this.rowEnd=e,this.rowUpdatePos=this.rowEnd,this.referenceRow=this.rowStart+Math.floor((e-this.rowStart)/2),this.table.scenegraph.updateContainer(),this.table.scenegraph.updateBorderSizeAndPosition()}createColGroup(t){const e=Math.min(this.totalCol,this.currentCol+t);kN(this.table,this.currentCol+1,e);for(let t=0;t<this.table.rowCount;t++){const e=this.highPerformanceGetCell(this.currentCol,t);Qu(e.mergeCol)&&e.mergeCol>this.currentCol&&this.table.scenegraph.updateCellContent(e.col,e.row)}if(this.table.columnHeaderLevelCount){const t=this.table.scenegraph.colHeaderGroup.lastChild instanceof bj?this.table.scenegraph.colHeaderGroup.lastChild:this.table.scenegraph.colHeaderGroup.lastChild._prev,i=t.attribute.x+t.attribute.width,n=t.attribute.y;nG(this.table.scenegraph.colHeaderGroup,i,n,this.currentCol+1,e,0,this.table.columnHeaderLevelCount-1,"columnHeader",this.table)}if(this.table.bottomFrozenRowCount){const t=this.table.scenegraph.bottomFrozenGroup.lastChild instanceof bj?this.table.scenegraph.bottomFrozenGroup.lastChild:this.table.scenegraph.bottomFrozenGroup.lastChild._prev,i=t.attribute.x+t.attribute.width,n=t.attribute.y;nG(this.table.scenegraph.bottomFrozenGroup,i,n,this.currentCol+1,e,this.table.rowCount-this.table.bottomFrozenRowCount,this.table.rowCount-1,"columnHeader",this.table)}const i=this.table.scenegraph.bodyGroup.lastChild instanceof bj?this.table.scenegraph.bodyGroup.lastChild:this.table.scenegraph.bodyGroup.lastChild._prev,n=i.attribute.x+i.attribute.width,r=i.attribute.y;nG(this.table.scenegraph.bodyGroup,n,r,this.currentCol+1,e,this.rowStart,this.rowEnd,"body",this.table),this.currentCol=e,this.colEnd=e,this.colUpdatePos=this.colEnd,this.referenceCol=this.colStart+Math.floor((e-this.colStart)/2),console.log("async",this.referenceCol,this.colStart,this.colEnd),this.table.scenegraph.updateContainer(),this.table.scenegraph.updateBorderSizeAndPosition()}async setY(t){t<this.yLimitTop&&this.rowStart===this.bodyTopRow||t>this.yLimitBottom&&this.rowEnd===this.bodyBottomRow?this.table.scenegraph.setBodyAndRowHeaderY(-t):this.dynamicSetY(t)}async setX(t){t<this.xLimitLeft&&this.colStart===this.bodyLeftCol||t>this.xLimitRight&&this.colEnd===this.bodyRightCol?this.table.scenegraph.setBodyAndColHeaderX(-t):this.dynamicSetX(t)}async dynamicSetY(t){!async function(t,e){const i=e.table.getTargetRowAt(t+e.table.scenegraph.colHeaderGroup.attribute.height);if(!i)return;const n=i.row,r=i.top;e.screenTopRow=n;const o=n-e.referenceRow;o>0?(yG(o,"up",n,r,e),e.updateBody(t-e.deltaY)):o<0?(yG(-o,"down",n,r,e),e.updateBody(t-e.deltaY)):e.updateBody(t-e.deltaY),e.table.scenegraph.updateNextFrame()}(t,this)}async dynamicSetX(t){!async function(t,e){const i=e.table.getTargetColAt(t+e.table.scenegraph.rowHeaderGroup.attribute.width);if(!i)return;const n=i.col,r=i.left;e.screenLeftCol=n;const o=e.screenLeftCol-e.referenceCol;o>0?(uG(o,"left",e.screenLeftCol,r,e),e.table.scenegraph.setBodyAndColHeaderX(-t+e.deltaX)):o<0?(uG(-o,"right",e.screenLeftCol,r,e),e.table.scenegraph.setBodyAndColHeaderX(-t+e.deltaX)):e.table.scenegraph.setBodyAndColHeaderX(-t+e.deltaX),e.table.scenegraph.updateNextFrame()}(t,this)}updateBody(t){this.table.scenegraph.setBodyAndRowHeaderY(-t)}async updateRowCellGroupsAsync(){this.updateCellGroups(this.taskRowCount)}updateCellGroups(t){const e=Math.min(this.bodyBottomRow,this.rowUpdatePos+t);"autoHeight"===this.table.heightMode&&jN(this.table,this.rowUpdatePos,e,!1),vG(this.rowUpdatePos,e,this),"autoHeight"===this.table.heightMode&&mG(this.bodyLeftCol,this.bodyRightCol,this.rowUpdatePos,e,this.table,this.rowUpdateDirection),this.rowUpdatePos=e+1}async updateColCellGroupsAsync(){this.updateColGroups(this.taskRowCount)}updateColGroups(t){const e=Math.min(this.bodyRightCol,this.colUpdatePos+t);kN(this.table,this.colUpdatePos,e),gG(this.colUpdatePos,e,this),this.colUpdatePos=e+1}updateCellGroupPosition(t,e,i){t.row=e,t.setAttribute("y",i),t.needUpdate=!0,t.needUpdateForAutoRowHeight=!0}updateCellGroupContent(t){if(!t.needUpdate)return t;const e=this.table.scenegraph.updateCellContent(t.col,t.row);return t.needUpdate=!1,e||t}async sortCellVertical(){await async function(t){for(let e=t.bodyLeftCol;e<=t.bodyRightCol;e++)for(let i=t.rowStart;i<=t.rowEnd;i++)t.highPerformanceGetCell(e,i).needUpdate=!0;let e,i;"autoHeight"===t.table.heightMode?(e=t.rowStart,i=t.rowEnd):(e=Math.max(t.bodyTopRow,t.screenTopRow-1*t.screenRowCount),i=Math.min(t.bodyBottomRow,t.screenTopRow+2*t.screenRowCount)),jN(t.table,e,i),vG(e,i,t),"autoHeight"===t.table.heightMode&&mG(t.bodyLeftCol,t.bodyRightCol,e,i,t.table,t.rowEnd>t.bodyBottomRow-(t.rowEnd-t.rowStart+1)?"down":"up"),t.rowUpdatePos=t.rowStart,t.rowUpdateDirection=t.rowEnd>t.bodyBottomRow-(t.rowEnd-t.rowStart+1)?"down":"up",t.table.scenegraph.updateNextFrame(),"autoHeight"!==t.table.heightMode&&await t.progress()}(this)}async sortCellHorizontal(){await async function(t){for(let e=t.colStart;e<=t.colEnd;e++){const i=t.table.scenegraph.getColGroup(e);i.needUpdate=!0,i?.forEachChildren((t=>{t.needUpdate=!0}))}const e=Math.max(t.bodyLeftCol,t.screenLeftCol-1*t.screenColCount),i=Math.min(t.bodyRightCol,t.screenLeftCol+2*t.screenColCount);kN(t.table,e,i),gG(e,i,t),t.colUpdatePos=t.colStart,t.colUpdateDirection=t.colEnd>t.bodyRightCol-(t.colEnd-t.colStart+1)?"right":"left",t.table.scenegraph.updateNextFrame(),await t.progress()}(this)}highPerformanceGetCell(t,e,i){if(e>=this.table.columnHeaderLevelCount&&e<this.table.rowCount-this.table.bottomFrozenRowCount&&(e<this.rowStart||e>this.rowEnd))return KN;if(t>=this.table.rowHeaderLevelCount&&t<this.table.colCount-this.table.rightFrozenColCount&&(t<this.colStart||t>this.colEnd))return KN;if(this.cellCache.get(t)){const n=this.cellCache.get(t);if((n._next||n._prev)&&Math.abs(n.row-e)<e){let r=CG(n,e);return r&&(i||"shadow-cell"!==r.role)||(r=this.table.scenegraph.getCell(t,e,i)),r.row&&this.cellCache.set(t,r),r}const r=this.table.scenegraph.getCell(t,e,i);return r.col===t&&r.row&&this.cellCache.set(t,r),r}const n=this.table.scenegraph.getCell(t,e,i);return n.col===t&&n.row&&this.cellCache.set(t,n),n}}function CG(t,e){return t?t.row===e?t:t.row>e?CG(t._prev,e):CG(t._next,e):null}function xG(t,e,i){const[n,r,o,s]=e.split("-"),a=parseInt(n,10),l=parseInt(r,10),h=parseInt(o,10),c=parseInt(s,10);let u;for(let t=a;t<=h;t++)for(let e=l;e<=c;e++){const n=i.highPerformanceGetCell(t,e);if("cell"!==n.role)continue;n.AABBBounds.width();const r=n.globalAABBBounds;u?u.union(r):u=r}u?t.rect.setAttributes({x:u.x1-i.tableGroup.attribute.x,y:u.y1-i.tableGroup.attribute.y,width:u.width(),height:u.height(),visible:!0}):t.rect.setAttributes({visible:!1});const d=a===i.table.frozenColCount,p=l===i.table.frozenRowCount;d&&t.rect.attribute.stroke[3]||p&&t.rect.attribute.stroke[0]?(d&&i.tableGroup.insertAfter(t.rect,"columnHeader"===t.role?i.cornerHeaderGroup:i.rowHeaderGroup),p&&i.tableGroup.insertAfter(t.rect,"rowHeader"===t.role?i.cornerHeaderGroup:i.colHeaderGroup),t.rect.attribute.x<i.rowHeaderGroup.attribute.width&&i.table.scrollLeft>0&&("body"===t.role||"columnHeader"===t.role)&&t.rect.setAttributes({x:t.rect.attribute.x+(i.rowHeaderGroup.attribute.width-t.rect.attribute.x),width:t.rect.attribute.width-(i.rowHeaderGroup.attribute.width-t.rect.attribute.x)}),t.rect.attribute.y<i.colHeaderGroup.attribute.height&&i.table.scrollTop>0&&("body"===t.role||"rowHeader"===t.role)&&t.rect.setAttributes({y:t.rect.attribute.y+(i.colHeaderGroup.attribute.height-t.rect.attribute.y),height:t.rect.attribute.height-(i.colHeaderGroup.attribute.height-t.rect.attribute.y)})):i.tableGroup.insertAfter(t.rect,"body"===t.role?i.bodyGroup:"columnHeader"===t.role?i.colHeaderGroup:"rowHeader"===t.role?i.rowHeaderGroup:i.cornerHeaderGroup)}function _G(t,e,i){const n=i.scenegraph,r=SG(t.map((t=>t.row))).sort(((t,e)=>t-e)),o=SG(e.map((t=>t.row))).sort(((t,e)=>t-e));r.forEach((t=>{!function(t,e){for(let i=0;i<e.table.colCount;i++){const n=e.getColGroup(i,!1);let r;n.forEachChildren((e=>e.row===t&&(r=e,!0))),r&&n.removeChild(r)}}(t,n)})),r.length&&function(t){for(let e=0;e<t.table.colCount;e++){const i=t.getColGroup(e,!0),n=t.getColGroup(e,!1);let r=i.firstChild?.row;i.forEachChildren((t=>{t.row=r,r++})),r=n.firstChild?.row,n.forEachChildren((t=>{t.row=r,r++}))}}(n),o.forEach((t=>{!function(t,e){for(let i=0;i<e.table.colCount;i++){const n=tG(i,t,e.table,!0);if(!n)continue;const r=e.getColGroup(i);if(r.firstChild&&t<r.firstChild.row)r.insertBefore(n,r.firstChild);else if(r.lastChild&&t>r.lastChild.row)r.appendChild(n);else{let e;r.forEachChildren((i=>i.row===t&&(e=i,!0))),e!==n&&r.insertBefore(n,e)}let o=r.firstChild?.row;r.forEachChildren((t=>{t.row=o,o++}))}}(t,n)})),function(t){let e=0;for(let i=0;i<t.table.colCount;i++){const n=t.getColGroup(i,!0),r=t.getColGroup(i,!1);let o=n.firstChild?.row,s=0;o=r.firstChild?.row,s=0,r.forEachChildren((t=>{t.row=o,o++,"cell"===t.role&&(t.setAttribute("y",s),s+=t.attribute.height)})),e=s}t.updateContainerHeight(t.table.frozenRowCount,e-t.bodyGroup.attribute.height)}(n)}function SG(t){const e=[];for(let i=0;i<t.length;i++)-1===e.indexOf(t[i])&&e.push(t[i]);return e}new Xx({});const AG=[];function TG(t){AG.forEach((e=>{t.scenegraph.getCell(e.col,e.row).forEachChildren((t=>{t.setAttributes({dy:0,dx:0})}))})),AG.length=0;const{scrollTop:e,scrollLeft:i,frozenRowCount:n,frozenColCount:r}=t,o=t.getFrozenRowsHeight(),s=t.getFrozenColsWidth(),{row:a}=t.getRowAt(e+o+1),{col:l}=t.getColAt(i+s+1),h=t.getAllRowsHeight()>t.tableNoFrameHeight?t.getRowAt(e+t.tableNoFrameHeight-1).row:t.rowCount-1,c=t.getAllColsWidth()>t.tableNoFrameWidth?t.getColAt(i+t.tableNoFrameWidth-1).col:t.colCount-1;for(let e=0;e<n;e++)for(let i=l;i<=c;i++)if(t._getCellStyle(i,e)?.textStick){MG(t.scenegraph.getCell(i,e),s+t.tableX,t.tableNoFrameWidth-t.getRightFrozenColsWidth()),AG.push({col:i,row:e})}if(-1!==a){for(let e=a;e<=h;e++)for(let i=0;i<r;i++)if(t._getCellStyle(i,e)?.textStick&&"tree"!==t.internalProps.layoutMap.rowHierarchyType){BG(t.scenegraph.getCell(i,e),o+t.tableY,t.tableNoFrameHeight-t.getBottomFrozenRowsHeight()),AG.push({col:i,row:e})}for(let e=a;e<=h;e++)for(let i=l;i<=c;i++)if(t._getCellStyle(i,e)?.textStick){const n=t.scenegraph.getCell(i,e);BG(n,o+t.tableY,t.tableNoFrameHeight-t.getBottomFrozenRowsHeight()),MG(n,s+t.tableX,t.tableNoFrameWidth-t.getRightFrozenColsWidth()),AG.push({col:i,row:e})}}}function BG(t,e,i){const n=t.getChildByName("text",!0);if(!n)return;n.AABBBounds.width();const r=n.globalAABBBounds.y1,o=n.globalAABBBounds.y2;if(r<e){const i=r-e;t.forEachChildren((t=>{t.setAttribute("dy",2-i)}))}else if(o>i){const e=o-i;t.forEachChildren((t=>{t.setAttribute("dy",-e)}))}}function MG(t,e,i){const n=t.getChildByName("text",!0);if(!n)return;n.AABBBounds.width();const r=n.globalAABBBounds.x1,o=n.globalAABBBounds.x2;if(r<e){const i=r-e;t.forEachChildren((t=>{t.setAttribute("dx",2-i)}))}else if(o>i){const e=o-i;t.forEachChildren((t=>{t.setAttribute("dx",-e)}))}}function RG(t){const e=t.bodyGroup.firstChild instanceof bj?t.bodyGroup.firstChild:null;e&&(t.rowHeaderGroup.appendChild(e),t.rowHeaderGroup.setAttribute("width",t.rowHeaderGroup.attribute.width+e.attribute.width),t.bodyGroup.setAttribute("width",t.bodyGroup.attribute.width-e.attribute.width))}function PG(t){const e=t.colHeaderGroup.firstChild instanceof bj?t.colHeaderGroup.firstChild:null;e&&(t.cornerHeaderGroup.appendChild(e),t.cornerHeaderGroup.setAttribute("width",t.cornerHeaderGroup.attribute.width+e.attribute.width),t.colHeaderGroup.setAttribute("width",t.colHeaderGroup.attribute.width-e.attribute.width))}function EG(t){const e=t.rowHeaderGroup.lastChild instanceof bj?t.rowHeaderGroup.lastChild:t.rowHeaderGroup.lastChild?._prev;e&&(IG(t.bodyGroup,e,t.bodyGroup.firstChild),t.bodyGroup.setAttribute("width",t.bodyGroup.attribute.width+e.attribute.width),t.rowHeaderGroup.setAttribute("width",t.rowHeaderGroup.attribute.width-e.attribute.width))}function HG(t){const e=t.cornerHeaderGroup.lastChild instanceof bj?t.cornerHeaderGroup.lastChild:t.cornerHeaderGroup.lastChild?._prev;e&&(IG(t.colHeaderGroup,e,t.colHeaderGroup.firstChild),t.colHeaderGroup.setAttribute("width",t.colHeaderGroup.attribute.width+e.attribute.width),t.cornerHeaderGroup.setAttribute("width",t.cornerHeaderGroup.attribute.width-e.attribute.width))}function LG(t){const e=t.bottomFrozenGroup.firstChild instanceof bj?t.bottomFrozenGroup.firstChild:null;e&&(t.leftBottomCornerGroup.appendChild(e),t.leftBottomCornerGroup.setAttribute("width",t.leftBottomCornerGroup.attribute.width+e.attribute.width),t.bottomFrozenGroup.setAttribute("width",t.bottomFrozenGroup.attribute.width-e.attribute.width))}function kG(t){const e=t.leftBottomCornerGroup.lastChild instanceof bj?t.leftBottomCornerGroup.lastChild:t.leftBottomCornerGroup.lastChild?._prev;e&&(IG(t.bottomFrozenGroup,e,t.bottomFrozenGroup.firstChild),t.bottomFrozenGroup.setAttribute("width",t.bottomFrozenGroup.attribute.width+e.attribute.width),t.leftBottomCornerGroup.setAttribute("width",t.leftBottomCornerGroup.attribute.width-e.attribute.width))}function IG(t,e,i){e&&t&&(i?t.insertBefore(e,i):t.appendChild(e))}function OG(t){for(let e=t.proxy.colStart;e<=t.proxy.colEnd;e++){t.getColGroup(e).getChildren().forEach((t=>{t.children.forEach((t=>{"chart"===t.type&&(t.cacheCanvas=null)}))}))}}function DG(t,e){t.forEachChildren((t=>{"column"===t.role&&t.forEachChildren((t=>{if("cell"===t.role){let i=!1;if(t.forEachChildren((t=>"axis"===t.name&&(i=!0,!0))),i){const i=e.internalProps.layoutMap.getAxisConfigInPivotChart(t.col,t.row),n=new hW(i,t.attribute.width,t.attribute.height,e);t.clear(),t.appendChild(n.component),n.overlap()}}}))}))}function FG(t,e){const{bgColor:i,borderColor:n,borderLineWidth:r,borderLineDash:o}=e,s={x:0,y:0,width:0,height:0,visible:!1,pickable:!0,fill:i};return s.stroke=Zj(n,void 0),s.lineWidth=r,o&&(s.lineDash=o),s.lineCap="square",Array.isArray(n)&&(s.strokeArrayColor=RW(n)),Array.isArray(r)&&(s.strokeArrayWidth=RW(r),s.lineWidth=1),t.setAttributes(s),t.role="corner-frozen",t}function zG(t,e){return new bj({x:0,y:0,width:t,height:e,clip:!1,pickable:!1})}function WG(t){let e=0;return t.forEachChildrenSkipChild(((t,i)=>{t.setAttribute("x",e),e+=t.attribute.width})),e}qb.load(Uk),qb.load(TN);const jG={visible:!0,position:"auto",padding:8,titleStyle:{fontSize:12,fontWeight:"bold",fill:"#4E5969"},contentStyle:{fontSize:12,fill:"#4E5969"},panel:{visible:!0,fill:"#fff",stroke:"#ffffff",lineWidth:0,cornerRadius:3,shadowBlur:12,shadowOffsetX:0,shadowOffsetY:4,shadowColor:"rgba(0, 0, 0, 0.1)",size:0,space:12}};class NG{proxy;tableGroup;colHeaderGroup;cornerHeaderGroup;rowHeaderGroup;bodyGroup;rightFrozenGroup;bottomFrozenGroup;rightTopCornerGroup;leftBottomCornerGroup;rightBottomCornerGroup;componentGroup;selectedRangeComponents;selectingRangeComponents;lastSelectId;component;stage;table;isPivot;transpose;hasFrozen;frozenColCount;frozenRowCount;clear;mergeMap;constructor(t){var e;this.table=t,this.hasFrozen=!1,this.clear=!0,this.mergeMap=new Map,e=jG,fd(zk.poptip,Fk,e),this.stage=function(t){return new xk(t)}({canvas:t.canvas,width:t.canvas.width,height:t.canvas.height,disableDirtyBounds:!1,background:t.theme.underlayBackgroundColor,dpr:t.internalProps.pixelRatio,pluginList:t.isPivotChart()?["poptipForText"]:void 0}),this.stage.defaultLayer.setTheme({group:{boundsPadding:0,strokeBoundsBuffer:0,lineJoin:"round"},text:{ignoreBuf:!0}}),this.initSceneGraph(),this.stage.defaultLayer.add(this.tableGroup),this.stage.table=this.table,this.createComponent()}get width(){return this.tableGroup.attribute?.width??0}get height(){return this.tableGroup.attribute?.height??0}get x(){return this.tableGroup.attribute?.x??0}get y(){return this.tableGroup.attribute?.y??0}get bodyRowStart(){return this.transpose||this.isPivot?this.table.columnHeaderLevelCount:this.proxy.rowStart??0}get bodyRowEnd(){return this.transpose||this.isPivot?this.table.rowCount-1:this.proxy.rowEnd??0}initSceneGraph(){this.isPivot=this.table.isPivotTable(),this.transpose=this.table.options.transpose,function(t){const e=t.table.tableNoFrameWidth,i=t.table.tableNoFrameHeight;t.tableGroup=new bj({x:0,y:0,width:e,height:i,clip:!0,pickable:!1}),t.tableGroup.role="table";const n=zG(0,0);n.role="col-header",t.colHeaderGroup=n;const r=zG(0,0);r.role="corner-header",t.cornerHeaderGroup=r;const o=zG(0,0);o.role="row-header",t.rowHeaderGroup=o;const s=zG(e,0);s.role="body",t.bodyGroup=s;const a=zG(0,0);a.role="right-frozen",t.rightFrozenGroup=a;const l=zG(0,0);l.role="bottom-frozen",t.bottomFrozenGroup=l;const h=zG(0,0);h.role="component",t.componentGroup=h;const c=zG(0,0);c.role="corner-right-top-header",t.rightTopCornerGroup=c;const u=zG(0,0);u.role="corner-right-bottom-header",t.rightBottomCornerGroup=u;const d=zG(0,0);d.role="corner-left-bottom-header",t.leftBottomCornerGroup=d,t.table.isPivotChart()&&(FG(c,t.table.theme.cornerRightTopCellStyle||t.table.theme.cornerHeaderStyle),FG(d,t.table.theme.cornerLeftBottomCellStyle||t.table.theme.cornerHeaderStyle),FG(u,t.table.theme.cornerRightBottomCellStyle||t.table.theme.cornerHeaderStyle)),t.tableGroup.addChild(s),t.tableGroup.addChild(a),t.tableGroup.addChild(l),t.tableGroup.addChild(o),t.tableGroup.addChild(n),t.tableGroup.addChild(u),t.tableGroup.addChild(c),t.tableGroup.addChild(d),t.tableGroup.addChild(r),t.tableGroup.addChild(h)}(this)}clearCells(){this.clear=!0,this.hasFrozen=!1,this.mergeMap.clear(),this.colHeaderGroup.clear(),this.rowHeaderGroup.clear(),this.cornerHeaderGroup.clear(),this.bodyGroup.clear(),this.bottomFrozenGroup.clear(),this.rightFrozenGroup.clear(),this.rightTopCornerGroup.clear(),this.rightBottomCornerGroup.clear(),this.leftBottomCornerGroup.clear(),this.colHeaderGroup.setAttributes({x:0,y:0,width:0,height:0}),this.rowHeaderGroup.setAttributes({x:0,y:0,width:0,height:0}),this.cornerHeaderGroup.setAttributes({x:0,y:0,width:0,height:0}),this.bodyGroup.setAttributes({x:0,y:0,width:0,height:0}),this.rightFrozenGroup.setAttributes({x:0,y:0,width:0,height:0}),this.bottomFrozenGroup.setAttributes({x:0,y:0,width:0,height:0}),this.rightTopCornerGroup.setAttributes({x:0,y:0,width:0,height:0,visible:!1}),this.leftBottomCornerGroup.setAttributes({x:0,y:0,width:0,height:0,visible:!1}),this.rightBottomCornerGroup.setAttributes({x:0,y:0,width:0,height:0,visible:!1}),this.tableGroup.setAttributes({x:this.table.tableX,y:this.table.tableY,width:0,height:0}),this.tableGroup.border&&(this.tableGroup.parent.removeChild(this.tableGroup.border),delete this.tableGroup.border)}createComponent(){this.component=new Xj(this.table),this.component.addToGroup(this.componentGroup),this.selectedRangeComponents=new Map,this.selectingRangeComponents=new Map}createSceneGraph(){this.clear=!1,this.frozenColCount=this.table.rowHeaderLevelCount,this.frozenRowCount=this.table.columnHeaderLevelCount,this.proxy=new wG(this.table),Yj(this.tableGroup,this.table.theme.frameStyle,this.tableGroup.role,void 0,!0),this.proxy.createGroupForFirstScreen(this.cornerHeaderGroup,this.colHeaderGroup,this.rowHeaderGroup,this.rightFrozenGroup,this.bottomFrozenGroup,this.bodyGroup,0,0),this.afterScenegraphCreated()}renderSceneGraph(){this.stage.render()}getCellOld(t,e){let i;if(i=this.hasFrozen&&t<this.table.frozenColCount&&e<this.table.frozenRowCount?this.cornerHeaderGroup.getChildAt(t)?.getChildAt(e):e<this.table.frozenRowCount?this.colHeaderGroup.getChildAt(this.hasFrozen?t-this.table.frozenColCount:t)?.getChildAt(e):t<this.table.frozenColCount?this.rowHeaderGroup.getChildAt(t)?.getChildAt(e-this.table.frozenRowCount):this.bodyGroup.getChildAt(t-this.table.frozenColCount)?.getChildAt(e-this.table.frozenRowCount),i&&"shadow-cell"===i.role){const n=this.table.getCellRange(t,e);i=this.getCell(n.start.col,n.start.row)}return i||void 0}getColGroupOld(t,e=!1){let i;return i=t<this.frozenColCount&&e?this.cornerHeaderGroup.getChildAt(t):t<this.frozenColCount?this.rowHeaderGroup.getChildAt(t):e?this.rowHeaderGroup.getChildAt(t-this.frozenColCount):this.bodyGroup.getChildAt(t-this.frozenColCount),i||void 0}getCell(t,e,i){let n;if(n=this.table.rightFrozenColCount>0&&t>=this.table.colCount-this.table.rightFrozenColCount&&e<this.table.frozenRowCount?this.rightBottomCornerGroup.getColGroup(t)?.getRowGroup(e):this.table.bottomFrozenRowCount>0&&e>=this.table.rowCount-this.table.bottomFrozenRowCount&&t<this.table.frozenColCount?this.leftBottomCornerGroup.getColGroup(t)?.getRowGroup(e):this.table.rightFrozenColCount>0&&this.table.bottomFrozenRowCount>0&&t>=this.table.colCount-this.table.rightFrozenColCount&&e>=this.table.rowCount-this.table.bottomFrozenRowCount?this.rightBottomCornerGroup.getColGroup(t)?.getRowGroup(e):this.table.rightFrozenColCount>0&&t>this.table.colCount-1-this.table.rightFrozenColCount?this.rightFrozenGroup.getColGroup(t)?.getRowGroup(e):this.table.bottomFrozenRowCount>0&&e>this.table.rowCount-1-this.table.bottomFrozenRowCount?this.bottomFrozenGroup.getColGroup(t)?.getRowGroup(e):this.getColGroup(t,e<this.frozenRowCount)?.getRowGroup(e),n&&"shadow-cell"===n.role&&!i){const i=this.table.getCellRange(t,e);i.start.col===t&&i.start.row===e||(n=this.getCell(i.start.col,i.start.row))}return n||KN}highPerformanceGetCell(t,e,i){return this.proxy.highPerformanceGetCell(t,e,i)}getColGroup(t,e=!1){let i;return i=t<this.frozenColCount&&e?this.cornerHeaderGroup.getColGroup(t):t<this.frozenColCount?this.rowHeaderGroup.getColGroup(t):e?this.colHeaderGroup.getColGroup(t):!e&&this.table.rightFrozenColCount>0&&t>this.table.colCount-1-this.table.rightFrozenColCount?this.rightFrozenGroup.getColGroup(t):this.bodyGroup.getColGroup(t),i||void 0}getColGroupInBottom(t){if(this.table.bottomFrozenRowCount>0)return this.bottomFrozenGroup.getColGroup(t)}getColGroupInLeftBottomCorner(t){if(this.table.bottomFrozenRowCount>0)return this.leftBottomCornerGroup.getColGroup(t)}getColGroupInRightTopCorner(t){if(this.table.rightFrozenColCount>0)return this.rightTopCornerGroup.getColGroup(t)}getColGroupInRightBottomCorner(t){if(this.table.rightFrozenColCount>0&&this.table.bottomFrozenRowCount>0)return this.rightBottomCornerGroup.getColGroup(t)}getCellSize(t,e){const i=this.getCell(t,e),n=Sk(this.table,t,e);let r=i.attribute.width,o=i.attribute.height;return n&&(r/=n.end.col-n.start.col+1,o/=n.end.row-n.start.row+1),{width:r,height:o}}updateNextFrame(){this.resetAllSelectComponent(),this.stage.renderNextFrame()}resetAllSelectComponent(){var t;(t=this).selectingRangeComponents.forEach(((e,i)=>{xG(e,i,t)})),t.selectedRangeComponents.forEach(((e,i)=>{xG(e,i,t)}))}hideHoverIcon(t,e){if(-1===t||-1===e)return;VG(this,this.getCell(t,e),"mouseenter_cell")}showHoverIcon(t,e){if(-1===t||-1===e)return;GG(this,this.getCell(t,e),"mouseenter_cell")}hideClickIcon(t,e){if(-1===t||-1===e)return;VG(this,this.getCell(t,e),"click_cell")}showClickIcon(t,e){if(-1===t||-1===e)return;GG(this,this.getCell(t,e),"click_cell")}deactivateChart(t,e){if(-1===t||-1===e)return;const i=this.getCell(t,e);i?.firstChild?.deactivate?.()}activateChart(t,e){if(-1===t||-1===e)return;const i=this.getCell(t,e);i?.firstChild?.activate?.(this.table)}removeInteractionBorder(t,e){const i=this.getCell(t,e);i.setAttribute("highlightStroke",void 0),i.setAttribute("highlightStrokeArrayWidth",void 0),i.setAttribute("highlightStrokeArrayColor",void 0)}createCellSelectBorder(t,e,i,n,r,o,s){!function(t,e,i,n,r,o,s,a){const l=Math.min(e,n),h=Math.min(i,r),c=Math.max(e,n),u=Math.max(i,r);let d;for(let e=l;e<=c;e++)for(let i=h;i<=u;i++){const n=t.highPerformanceGetCell(e,i);if("shadow-cell"===n.role)continue;n.AABBBounds.width();const r=n.globalAABBBounds;d?d.union(r):d=r}const p=t.table.theme,f=p.selectionStyle?.cellBorderColor,g=p.selectionStyle?.cellBorderLineWidth,m=eT({pickable:!1,fill:p.selectionStyle?.cellBgColor??"rgba(0, 0, 255,0.1)",lineWidth:g,stroke:a.map((t=>!!t&&f)),x:d.x1-t.tableGroup.attribute.x,y:d.y1-t.tableGroup.attribute.y,width:d.width(),height:d.height(),visible:!0});t.lastSelectId=s,t.selectingRangeComponents.set(`${l}-${h}-${c}-${u}-${s}`,{rect:m,role:o}),t.tableGroup.insertAfter(m,"body"===o?t.bodyGroup:"columnHeader"===o?t.colHeaderGroup:"rowHeader"===o?t.rowHeaderGroup:t.cornerHeaderGroup)}(this,t,e,i,n,r,o,s)}moveSelectingRangeComponentsToSelectedRangeComponents(){var t;(t=this).selectingRangeComponents.forEach(((e,i)=>{t.selectedRangeComponents.get(i)&&t.selectedRangeComponents.get(i).rect.delete(),t.selectedRangeComponents.set(i,e)})),t.selectingRangeComponents=new Map,t.updateNextFrame()}deleteLastSelectedRangeComponents(){var t;(t=this).selectedRangeComponents.forEach(((e,i)=>{i.split("-")[4]===t.lastSelectId&&(e.rect.delete(),t.selectedRangeComponents.delete(i))}))}deleteAllSelectBorder(){var t;(t=this).selectedRangeComponents.forEach(((t,e)=>{t.rect.delete()})),t.selectedRangeComponents=new Map}updateCellSelectBorder(t,e,i,n){!function(t,e,i,n,r){let o=Math.min(n,e),s=Math.min(r,i),a=Math.max(n,e),l=Math.max(r,i);const h=()=>{let e=!1;for(let i=o;i<=a;i++){if(i===o)for(let n=s;n<=l;n++){const r=Sk(t.table,i,n);if(r&&r.start.col<o){o=r.start.col,e=!0;break}}if(!e&&i===a)for(let n=s;n<=l;n++){const r=Sk(t.table,i,n);if(r&&r.end.col>a){a=r.end.col,e=!0;break}}if(e)break}if(!e)for(let i=s;i<=l;i++){if(i===s)for(let n=o;n<=a;n++){const r=Sk(t.table,n,i);if(r&&r.start.row<s){s=r.start.row,e=!0;break}}if(!e&&i===l)for(let n=o;n<=a;n++){const r=Sk(t.table,n,i);if(r&&r.end.row>l){l=r.end.row,e=!0;break}}if(e)break}e&&h()};h(),t.selectingRangeComponents.forEach(((t,e)=>{t.rect.delete()})),t.selectingRangeComponents=new Map;let c=!1,u=!1,d=!1,p=!1;if(o<=t.table.frozenColCount-1&&s<=t.table.frozenRowCount-1&&(p=!0),o<=t.table.frozenColCount-1&&l>=t.table.frozenRowCount&&(c=!0),s<=t.table.frozenRowCount-1&&a>=t.table.frozenColCount&&(u=!0),a>=t.table.frozenColCount&&l>=t.table.frozenRowCount&&(d=!0),p){const e=Math.min(a,t.table.frozenColCount-1),i=Math.min(l,t.table.frozenRowCount-1),n=[!0,!u,!c,!0];t.createCellSelectBorder(o,s,e,i,"cornerHeader",`${o}${s}${a}${l}`,n)}if(u){const e=Math.max(o,t.table.frozenColCount),i=Math.min(l,t.table.frozenRowCount-1),n=[!0,!0,!d,!p];t.createCellSelectBorder(e,s,a,i,"columnHeader",`${o}${s}${a}${l}`,n)}if(c){const e=Math.max(s,t.table.frozenRowCount),i=Math.min(a,t.table.frozenColCount-1),n=[!p,!d,!0,!0];t.createCellSelectBorder(o,e,i,l,"rowHeader",`${o}${s}${a}${l}`,n)}if(d){const e=Math.max(o,t.table.frozenColCount),i=Math.max(s,t.table.frozenRowCount),n=[!u,!0,!0,!c];t.createCellSelectBorder(e,i,a,l,"body",`${o}${s}${a}${l}`,n)}}(this,t,e,i,n)}getIcon(t,e,i,n){let r;return this.getCell(t,e).forEachChildren((t=>{"icon"===t.role&&t.containsPoint(i,n,xy.GLOBAL)&&(r=t)})),r}setIconHoverStyle(t,e,i,n){if(t.attribute.backgroundColor){let e=t.parent.getChildByName("icon-back");e?e.setAttributes({x:(t.attribute.x??0)+(t.attribute.dx??0)+(t.AABBBounds.width()-t.backgroundWidth)/2,y:(t.attribute.y??0)+(t.AABBBounds.height()-t.backgroundHeight)/2,width:t.backgroundWidth,height:t.backgroundHeight,fill:t.attribute.backgroundColor,cornerRadius:5,visible:!0}):(e=eT({x:(t.attribute.x??0)+(t.attribute.dx??0)+(t.AABBBounds.width()-t.backgroundWidth)/2,y:(t.attribute.y??0)+(t.AABBBounds.height()-t.backgroundHeight)/2,width:t.backgroundWidth,height:t.backgroundHeight,fill:t.attribute.backgroundColor,cornerRadius:5,pickable:!1,visible:!0}),e.name="icon-back"),t.parent.insertBefore(e,t)}if(t.attribute.hoverImage&&t.attribute.image!==t.attribute.hoverImage&&(t.image=t.attribute.hoverImage),t.tooltip){const{x1:n,x2:r,y1:o,y2:s}=t.globalAABBBounds,a={content:t.tooltip.title,referencePosition:{rect:{left:n-this.table.tableX,right:r-this.table.tableX,top:o-this.table.tableY,bottom:s-this.table.tableY,width:t.globalAABBBounds.width(),height:t.globalAABBBounds.height()},placement:t.tooltip.placement},style:Object.assign({},this.table.internalProps.theme?.tooltipStyle,t.tooltip?.style)};this.table.internalProps.tooltipHandler.isBinded(a)||this.table.showTooltip(e,i,a)}}setIconNormalStyle(t,e,i){const n=t.parent.getChildByName("icon-back");n&&n.setAttribute("visible",!1),t.attribute.hoverImage&&t.attribute.image!==t.attribute.originImage&&(t.image=t.attribute.originImage)}updateColWidth(t,e){!function(t,e,i){const n="autoHeight"===t.table.heightMode,r=t.getColGroup(e,!0);r&&zj(r,i,n,"col-corner",t);const o=t.getColGroup(e);o&&zj(o,i,n,"row-body",t);const s=t.getColGroupInLeftBottomCorner(e);s&&zj(s,i,n,"left-bottom",t);const a=t.getColGroupInBottom(e);a&&zj(a,i,n,"bottom",t);const l=t.getColGroupInRightBottomCorner(e);l&&zj(a,i,n,"right-bottom",t),e<t.frozenColCount?(t.cornerHeaderGroup.forEachChildrenSkipChild(((t,n)=>{t.col>e&&t.setAttribute("x",t.attribute.x+i)})),t.rowHeaderGroup.forEachChildrenSkipChild(((t,n)=>{t.col>e&&t.setAttribute("x",t.attribute.x+i)}))):(t.colHeaderGroup.forEachChildrenSkipChild(((t,n)=>{t.col>e&&t.setAttribute("x",t.attribute.x+i)})),t.bodyGroup.forEachChildrenSkipChild(((t,n)=>{t.col>e&&t.setAttribute("x",t.attribute.x+i)}))),s&&t.leftBottomCornerGroup.forEachChildrenSkipChild(((t,n)=>{t.col>e&&t.setAttribute("x",t.attribute.x+i)})),a&&t.bottomFrozenGroup.forEachChildrenSkipChild(((t,n)=>{t.col>e&&t.setAttribute("x",t.attribute.x+i)})),l&&t.rightBottomCornerGroup.forEachChildrenSkipChild(((t,n)=>{t.col>e&&t.setAttribute("x",t.attribute.x+i)})),t.table.setColWidth(e,o.attribute.width,!0)}(this,t,e),this.updateContainer()}updateChartSize(t){!function(t,e){for(let i=e;i<=t.proxy.colEnd;i++)t.getColGroup(i).getChildren().forEach((e=>{const i=t.table.getColWidth(e.col),n=t.table.getRowHeight(e.row);e.children.forEach((t=>{"chart"===t.type&&(t.cacheCanvas=null,t.setAttribute("width",Math.ceil(i-t.attribute.cellPadding[3]-t.attribute.cellPadding[1])),t.setAttribute("height",Math.ceil(n-t.attribute.cellPadding[0]-t.attribute.cellPadding[2])))}))}))}(this,t)}updateChartState(t){this.table.isPivotChart()&&function(t,e){const i=t.table;if(i.isPivotChart()){const n=i._selectedDataItemsInChart.length;if((null===e||0===e?.length||0===Object.keys(e).length)&&0===n)return;const r=[];if(Array.isArray(e))e.forEach((t=>{if(t&&0!==t.key&&Object.keys(t).length>0){const e={};for(const i in t)i.startsWith("VGRAMMAR_")||i.startsWith("__VCHART")||(e[i]=t[i]);r.push(e)}}));else if(e&&0!==e.key&&Object.keys(e).length>0){const t={};for(const i in e)i.startsWith("VGRAMMAR_")||i.startsWith("__VCHART")||(t[i]=e[i]);r.push(t)}yd(i._selectedDataItemsInChart,r)||(i._selectedDataItemsInChart=r,i.internalProps.layoutMap.updateDataStateToChartInstance(),OG(t),i.scenegraph.updateNextFrame())}}(this,t)}updateAutoColWidth(t){this.table.internalProps._widthResizedColMap.delete(t);const e=this.table.getColWidth(t),i=IN(t,0,this.table.rowCount-1,this.table);i!==e&&this.updateColWidth(t,i-e)}recalculateColWidths(){kN(this.table,0,this.table.colCount-1,!0)}recalculateRowHeights(){jN(this.table,0,this.table.rowCount-1,!0,!0)}resize(){"adaptive"===this.table.widthMode&&this.recalculateColWidths(),"adaptive"===this.table.heightMode&&this.recalculateRowHeights(),this.dealWidthMode(),this.dealHeightMode(),this.dealFrozen(),this.updateTableSize(),this.updateBorderSizeAndPosition(),this.component.updateScrollBar(),"adaptive"!==this.table.widthMode&&"adaptive"!==this.table.heightMode||this.updateChartSize(this.table.rowHeaderLevelCount),this.updateNextFrame()}updateTableSize(){this.tableGroup.setAttributes({width:Math.min(this.table.tableNoFrameWidth,Math.max(this.colHeaderGroup.attribute.width,this.bodyGroup.attribute.width,0)+Math.max(this.cornerHeaderGroup.attribute.width,this.rowHeaderGroup.attribute.width,0)+this.rightBottomCornerGroup.attribute.width),height:Math.min(this.table.tableNoFrameHeight,(this.colHeaderGroup.attribute.height??0)+(this.bodyGroup.attribute.height??0)+this.bottomFrozenGroup.attribute.height)}),this.tableGroup.border&&this.tableGroup.border.setAttributes({width:this.tableGroup.attribute.width+this.tableGroup.border.attribute.lineWidth,height:this.tableGroup.attribute.height+this.tableGroup.border.attribute.lineWidth}),this.table.bottomFrozenRowCount>0&&(this.bottomFrozenGroup.setAttribute("y",this.tableGroup.attribute.height-this.bottomFrozenGroup.attribute.height),this.leftBottomCornerGroup.setAttributes({visible:!0,y:this.tableGroup.attribute.height-this.bottomFrozenGroup.attribute.height,height:this.bottomFrozenGroup.attribute.height,width:this.table.getFrozenColsWidth()}),this.rightBottomCornerGroup.setAttributes({visible:!0,y:this.tableGroup.attribute.height-this.bottomFrozenGroup.attribute.height,height:this.bottomFrozenGroup.attribute.height})),this.table.rightFrozenColCount>0&&(this.rightFrozenGroup.setAttribute("x",this.tableGroup.attribute.width-this.rightFrozenGroup.attribute.width),this.rightTopCornerGroup.setAttributes({visible:!0,x:this.tableGroup.attribute.width-this.rightFrozenGroup.attribute.width,width:this.rightFrozenGroup.attribute.width,height:this.table.getFrozenRowsHeight()}),this.rightBottomCornerGroup.setAttributes({visible:!0,x:this.tableGroup.attribute.width-this.rightFrozenGroup.attribute.width,width:this.rightFrozenGroup.attribute.width}))}updateRowHeight(t,e){!function(t,e,i){for(let n=0;n<t.table.colCount;n++){const r=t.getCell(n,e),o=Sk(t.table,n,e);o&&o.start.col!==n||(Fj(t,r,n,e,r.attribute.height,i,t.table.isHeader(n,e)),t.updateCellContentWhileResize(n,e))}let n=0,r=0;e<t.table.columnHeaderLevelCount?(t.colHeaderGroup.setAttribute("height",t.colHeaderGroup.attribute.height+i),t.rowHeaderGroup.setAttribute("y",t.colHeaderGroup.attribute.y+i),t.bodyGroup.setAttribute("y",t.bodyGroup.attribute.y+i),n=e+1,r=t.table.columnHeaderLevelCount-1):(n=e+1,r=t.bodyRowEnd-t.table.bottomFrozenRowCount);for(let e=n;e<=r;e++)for(let n=0;n<t.table.colCount;n++){const r=t.getCell(n,e),o=Sk(t.table,n,e);(!o||o.start.col===n&&o.start.row===e)&&r.setAttribute("y",r.attribute.y+i)}t.table.setRowHeight(e,t.table.getRowHeight(e)+i,!0)}(this,t,e),this.updateContainerHeight(t,e)}updateContainerWidth(t,e){t<this.frozenColCount?(this.rowHeaderGroup.setDeltaWidth(e),this.cornerHeaderGroup.setDeltaWidth(e),this.colHeaderGroup.setDeltaX(e),this.bodyGroup.setDeltaX(e)):(this.colHeaderGroup.setDeltaWidth(e),this.bodyGroup.setDeltaWidth(e)),this.updateTableSize(),this.component.updateScrollBar(),this.updateNextFrame()}updateContainerHeight(t,e){t<this.table.frozenRowCount?(this.colHeaderGroup.setDeltaHeight(e),this.cornerHeaderGroup.setDeltaHeight(e),this.rowHeaderGroup.setDeltaY(e),this.bodyGroup.setDeltaY(e)):t>=this.table.rowCount-this.table.bottomFrozenRowCount?(this.leftBottomCornerGroup.setDeltaHeight(e),this.bottomFrozenGroup.setDeltaHeight(e),this.rightBottomCornerGroup.setDeltaHeight(e)):(this.rowHeaderGroup.setDeltaHeight(e),this.bodyGroup.setDeltaHeight(e)),this.updateTableSize(),this.component.updateScrollBar(),this.updateNextFrame()}setColWidth(t,e){const i=this.table.getColWidth(t);i!==e&&(this.updateColWidth(t,e-i),this.table._clearColRangeWidthsMap(t))}setRowHeight(t,e){const i=this.table.getRowHeight(t);i!==e&&(this.updateRowHeight(t,e-i),this.table._clearRowRangeHeightsMap(t))}setX(t){this.table.scenegraph.proxy.setX(-t)}setY(t){this.table.scenegraph.proxy.setY(-t)}setBodyAndRowHeaderY(t){this.colHeaderGroup.attribute.height+t!==this.bodyGroup.attribute.y&&(this.bodyGroup.setAttribute("y",this.colHeaderGroup.attribute.height+t),this.rowHeaderGroup.setAttribute("y",this.colHeaderGroup.attribute.height+t),this.table.rightFrozenColCount>0&&this.rightFrozenGroup.setAttribute("y",this.colHeaderGroup.attribute.height+t),this.updateNextFrame())}setBodyAndColHeaderX(t){this.rowHeaderGroup.attribute.width+t!==this.bodyGroup.attribute.x&&(this.bodyGroup.setAttribute("x",this.rowHeaderGroup.attribute.width+t),this.colHeaderGroup.setAttribute("x",this.rowHeaderGroup.attribute.width+t),this.table.bottomFrozenRowCount>0&&this.bottomFrozenGroup.setAttribute("x",this.rowHeaderGroup.attribute.width+t),this.updateNextFrame())}afterScenegraphCreated(){this.dealWidthMode(),this.dealHeightMode(),this.dealFrozen(),this.createFrameBorder(),this.updateBorderSizeAndPosition(),this.component.updateScrollBar(),TG(this.table),this.updateNextFrame()}dealWidthMode(){const t=this.table;if("adaptive"===t.widthMode){const e=t.tableNoFrameWidth-t.getFrozenColsWidth()-t.getRightFrozenColsWidth();let i=0;for(let e=t.frozenColCount;e<t.colCount-t.rightFrozenColCount;e++)i+=t.getColWidth(e);const n=e/i;for(let i=t.frozenColCount;i<t.colCount-t.rightFrozenColCount;i++){let r;r=i===t.colCount-t.rightFrozenColCount-1?e-t.getColsWidth(t.frozenColCount,t.colCount-t.rightFrozenColCount-2):Math.round(t.getColWidth(i)*n),this.setColWidth(i,r)}}else if(t.autoFillWidth){const e=t.tableNoFrameWidth;let i=0,n=0;for(let e=0;e<t.colCount;e++){const r=t.getColWidth(e);(e<t.frozenColCount||e>=t.colCount-t.rightFrozenColCount)&&(n+=r),i+=r}if(i<e&&i-n>0){const r=(e-n)/(i-n);for(let e=t.frozenColCount;e<t.colCount-t.rightFrozenColCount;e++)this.setColWidth(e,t.getColWidth(e)*r)}}let e=0;this.bodyGroup.forEachChildrenSkipChild((t=>{e+=t.attribute.width})),this.bodyGroup.setAttribute("width",e);let i=0;this.colHeaderGroup.forEachChildrenSkipChild((t=>{i+=t.attribute.width})),this.colHeaderGroup.setAttribute("width",i);let n=0;this.rowHeaderGroup.forEachChildrenSkipChild((t=>{n+=t.attribute.width})),this.rowHeaderGroup.setAttribute("width",n);let r=0;this.cornerHeaderGroup.forEachChildrenSkipChild((t=>{r+=t.attribute.width})),this.cornerHeaderGroup.setAttribute("width",r),this.colHeaderGroup.setAttribute("x",this.cornerHeaderGroup.attribute.width),this.rowHeaderGroup.setAttribute("y",this.colHeaderGroup.attribute.height),this.bodyGroup.setAttributes({x:this.rowHeaderGroup.attribute.width,y:this.colHeaderGroup.attribute.height})}dealHeightMode(){const t=this.table;if("adaptive"===t.heightMode){t._clearRowRangeHeightsMap();const e=t.tableNoFrameHeight-t.getFrozenRowsHeight()-t.getBottomFrozenRowsHeight();let i=0;for(let e=t.frozenRowCount;e<t.rowCount-t.bottomFrozenRowCount;e++)i+=t.getRowHeight(e);const n=e/i;for(let i=t.frozenRowCount;i<t.rowCount-t.bottomFrozenRowCount;i++){let r;r=i===t.rowCount-t.bottomFrozenRowCount-1?e-t.getRowsHeight(t.frozenRowCount,t.rowCount-t.bottomFrozenRowCount-2):Math.round(t.getRowHeight(i)*n),this.setRowHeight(i,r)}}}dealFrozen(){!function(t){if(t.table.frozenColCount>t.table.rowHeaderLevelCount){t.rowHeaderGroup.setAttribute("height",t.bodyGroup.attribute.height),t.rowHeaderGroup.setAttribute("y",t.bodyGroup.attribute.y),t.cornerHeaderGroup.setAttribute("height",t.colHeaderGroup.attribute.height);for(let e=0;e<t.table.frozenColCount-t.table.rowHeaderLevelCount;e++)RG(t),PG(t),LG(t)}else if(t.table.frozenColCount<t.table.rowHeaderLevelCount)for(let e=0;e<t.table.rowHeaderLevelCount-t.table.frozenColCount;e++)EG(t),HG(t),kG(t);t.bodyGroup.setAttribute("x",t.rowHeaderGroup.attribute.width),t.colHeaderGroup.setAttribute("x",t.cornerHeaderGroup.attribute.width),t.updateContainer(),t.updateBorderSizeAndPosition(),t.isPivot||t.transpose||t.component.setFrozenColumnShadow(t.table.frozenColCount-1),t.hasFrozen=!0,t.frozenColCount=t.table.frozenColCount,t.frozenRowCount=t.colHeaderGroup.firstChild?.childrenCount??0}(this)}resetFrozen(){!function(t){if(t.frozenColCount>t.table.rowHeaderLevelCount)for(let e=0;e<t.frozenColCount-t.table.rowHeaderLevelCount;e++)EG(t),HG(t),kG(t);else if(t.frozenColCount<t.table.rowHeaderLevelCount){t.rowHeaderGroup.setAttribute("height",t.bodyGroup.attribute.height),t.rowHeaderGroup.setAttribute("y",t.bodyGroup.attribute.y),t.cornerHeaderGroup.setAttribute("height",t.colHeaderGroup.attribute.height);for(let e=0;e<t.table.rowHeaderLevelCount-t.frozenColCount;e++)RG(t),PG(t),LG(t)}t.bodyGroup.setAttribute("x",t.rowHeaderGroup.attribute.width),t.colHeaderGroup.setAttribute("x",t.cornerHeaderGroup.attribute.width),t.updateContainer(),t.updateBorderSizeAndPosition(),t.isPivot||t.transpose||t.component.setFrozenColumnShadow(t.table.frozenColCount-1),t.hasFrozen=!0,t.frozenColCount=t.table.rowHeaderLevelCount,t.frozenRowCount=t.colHeaderGroup.firstChild?.childrenCount??0}(this)}updateCellLayoutWidthCertainWidth(t,e,i){const n=t.attribute.width;let r=!1;return t.forEachChildren(((t,o)=>{o+=e;const s=Sk(this.table,i,o);s?t=this.getCell(s.start.col,s.start.row):t.setAttribute("width",n);const a=RW(Cj("padding",this.table._getCellStyle(i,o),i,o,this.table)),l=t.getChildByName("text");let h=0,c=0;if(l)h=l.AABBBounds.height()+(a[0]+a[2]),l.setAttribute("maxLineWidth",n-(a[1]+a[3])),c=l.AABBBounds.height()+(a[0]+a[2]);else{const e=t.getChildAt(1);h=e.AABBBounds.height()+(a[0]+a[2]),e._cellWidth=n-(a[1]+a[3]),e.layout(),c=e.AABBBounds.height()+(a[0]+a[2])}const u=this.table.getRowHeight(o);t.attribute.height!==c&&(t.setAttribute("height",c),(u===h||c>u)&&(r=!0))})),r}updateHeaderPosition(t,e,i,n){!function(t,e,i,n,r){const o=r.scenegraph,s=r.getCellLocation(i,n),a="columnHeader"===s?"column":"rowHeader"===s?"row":void 0;let l=0,h=0,c=0,u=0,d=0,p=0,f=0,g=0;if("column"===a){const o=Sk(r,t,e),s=Sk(r,i,n);o&&s?(l=o.start.col,c=o.end.col,d=s.start.col,f=s.end.col):(l=t,c=t,d=i,f=i),h=e,u=r.rowCount-1,p=n,g=r.rowCount-1}else if("row"===a){const o=Sk(r,t,e),s=Sk(r,i,n);o&&s?(h=o.start.row,u=o.end.row,p=s.start.row,g=s.end.row):(h=e,u=e,p=n,g=n),l=t,c=r.colCount-1,d=i,f=r.colCount-1}const m=Math.min(l,d),y=Math.max(c,f),b=Math.min(h,p),v=Math.max(u,g);for(let t=m;t<=y;t++){const e=r.scenegraph.getColGroup(t,!0),i=r.scenegraph.getColGroup(t);e&&e.setAttribute("width",r.getColWidth(t)),i&&i.setAttribute("width",r.getColWidth(t))}o.updateContainer();for(let t=m;t<=y;t++){const e=r.scenegraph.getColGroup(t);e?.setAttribute("chartInstance",void 0);for(let e=b;e<=v;e++)o.updateCellContent(t,e)}}(t,e,i,n,this.table)}updateContainer(){const t=WG(this.cornerHeaderGroup),e=WG(this.rowHeaderGroup),i=WG(this.colHeaderGroup),n=WG(this.bodyGroup),r=WG(this.rightFrozenGroup);WG(this.bottomFrozenGroup),WG(this.leftBottomCornerGroup),WG(this.rightTopCornerGroup),WG(this.rightBottomCornerGroup),this.cornerHeaderGroup.setDeltaWidth(t-this.cornerHeaderGroup.attribute.width),this.leftBottomCornerGroup.setDeltaWidth(t-this.leftBottomCornerGroup.attribute.width),this.colHeaderGroup.setDeltaWidth(i-this.colHeaderGroup.attribute.width),this.rightFrozenGroup.setDeltaWidth(i-this.rightFrozenGroup.attribute.width),this.rowHeaderGroup.setDeltaWidth(e-this.rowHeaderGroup.attribute.width),this.bottomFrozenGroup.setDeltaWidth(e-this.bottomFrozenGroup.attribute.width),this.rightFrozenGroup.setDeltaWidth(r-this.rightFrozenGroup.attribute.width),this.rightTopCornerGroup.setDeltaWidth(r-this.rightTopCornerGroup.attribute.width),this.rightBottomCornerGroup.setDeltaWidth(r-this.rightBottomCornerGroup.attribute.width),this.bodyGroup.setDeltaWidth(n-this.bodyGroup.attribute.width),this.colHeaderGroup.setAttribute("x",this.cornerHeaderGroup.attribute.width),this.bottomFrozenGroup.setAttribute("x",this.rowHeaderGroup.attribute.width),this.bodyGroup.setAttribute("x",this.rowHeaderGroup.attribute.width),this.updateTableSize();const o=this.table.stateManeger.scroll.horizontalBarPos,s=this.table.stateManeger.scroll.verticalBarPos;this.component.updateScrollBar(),this.table.stateManeger.setScrollLeft(o),this.table.stateManeger.setScrollTop(s),this.updateNextFrame()}updateCellContentWhileResize(t,e){const i=this.table.getBodyColumnType(t,e),n=this.getCell(t,e);"image"!==i&&"video"!==i||Sj(n,t,e,this.table)}createFrameBorder(){this.updateTableSize();const t=!this.isPivot;Yj(this.bodyGroup,this.table.theme.bodyStyle.frameStyle,this.bodyGroup.role,t?[!0,!0,!0,!1]:void 0),Yj(this.rowHeaderGroup,this.isPivot?this.table.theme.rowHeaderStyle.frameStyle:this.table.theme.bodyStyle.frameStyle,this.rowHeaderGroup.role,t?[!0,!1,!0,!0]:void 0),Yj(this.colHeaderGroup,this.table.theme.headerStyle.frameStyle,this.colHeaderGroup.role,t?[!0,!0,!0,!1]:void 0),Yj(this.cornerHeaderGroup,this.isPivot?this.table.theme.cornerHeaderStyle.frameStyle:this.table.theme.headerStyle.frameStyle,this.cornerHeaderGroup.role,t?[!0,!1,!0,!0]:void 0),Yj(this.tableGroup,this.table.theme.frameStyle,this.tableGroup.role,void 0)}getResizeColAt(t,e,i,n=8){if(i){let e;if(t<i.globalAABBBounds.x1+n?e={col:i.col-1,row:i.row,x:i.globalAABBBounds.x1}:i.globalAABBBounds.x2-n<t&&(e={col:i.col,row:i.row,x:i.globalAABBBounds.x2}),e&&this.table.rightFrozenColCount>0&&e.col===this.table.colCount-this.table.rightFrozenColCount-1&&this.table.tableNoFrameWidth-this.table.getFrozenColsWidth()-this.table.getRightFrozenColsWidth()+this.table.scrollLeft<this.bodyGroup.attribute.width&&(e.col=e.col+1,e.rightFrozen=!0),e)return e}else;return{col:-1,row:-1}}updateIcon(t,e){Lj(e,t),t.name=e.name,this.updateNextFrame()}updateFrozen(){this.clear||(this.resetFrozen(),this.dealFrozen(),this.component.updateScrollBar())}dealWidthRightFrozen(t){this.clear?this.table.internalProps.rightFrozenColCount=t:function(t,e){const{table:i,proxy:n,rightTopCornerGroup:r,rightFrozenGroup:o,rightBottomCornerGroup:s,bottomFrozenGroup:a,bodyGroup:l,colHeaderGroup:h}=e,c=e.table.rightFrozenColCount;if(t>c){for(let n=i.colCount-c-1;n>=i.colCount-t;n--)IG(o,e.getColGroup(n),o.firstChild),IG(r,e.getColGroup(n,!0),r.firstChild),IG(s,e.getColGroupInBottom(n),s.firstChild);let n=0;o.forEachChildren((t=>{t.setAttribute("x",n),n+=t.attribute.width})),n=0,r.forEachChildren((t=>{t.setAttribute("x",n),n+=t.attribute.width})),n=0,s.forEachChildren((t=>{t.setAttribute("x",n),n+=t.attribute.width}))}else if(t<c){for(let n=i.colCount-c;n<i.colCount-t;n++){const t=e.getColGroup(n);t.setAttribute("x",l.lastChild.attribute.x+i.getColWidth(l.lastChild.col)),l.appendChild(t);const r=e.getColGroupInRightTopCorner(n);r.setAttribute("x",h.lastChild.attribute.x+i.getColWidth(h.lastChild.col)),h.appendChild(r);const o=e.getColGroupInRightBottomCorner(n);o.setAttribute("x",a.lastChild.attribute.x+i.getColWidth(a.lastChild.col)),a.appendChild(o)}let n=0;o.forEachChildren((t=>{t.setAttribute("x",n),n+=t.attribute.width})),n=0,r.forEachChildren((t=>{t.setAttribute("x",n),n+=t.attribute.width})),n=0,s.forEachChildren((t=>{t.setAttribute("x",n),n+=t.attribute.width}))}o.setAttribute("width",i.getColsWidth(i.colCount-t,i.colCount-1)),r.setAttribute("width",i.getColsWidth(i.colCount-t,i.colCount-1)),s.setAttribute("width",i.getColsWidth(i.colCount-t,i.colCount-1)),i.internalProps.rightFrozenColCount=t,e.updateContainer(),e.component.updateScrollBar(),e.updateNextFrame()}(t,this)}dealWidthBottomFrozen(t){this.clear?this.table.internalProps.bottomFrozenRowCount=t:function(t,e){const{table:i,proxy:n,bottomFrozenGroup:r,leftBottomCornerGroup:o,rightBottomCornerGroup:s}=e;r.childrenCount||(n.table.isPivotChart()||(nG(o,0,0,0,i.rowHeaderLevelCount-1,0,-1,"rowHeader",i),nG(s,0,0,i.colCount-i.rightFrozenColCount,i.colCount-1,0,-1,"body",i)),nG(r,0,0,n.colStart,n.colEnd,0,-1,"body",i));const a=e.table.bottomFrozenRowCount;if(t>a){for(let n=0;n<i.rowHeaderLevelCount;n++){const r=e.getColGroupInLeftBottomCorner(n);for(let o=i.rowCount-a-1;o>=i.rowCount-t;o--)IG(r,e.getCell(n,o,!0),r.firstChild);let o=0;r.forEachChildren((t=>{t.setAttribute("y",o),o+=i.getRowHeight(t.row)}))}for(let r=n.colStart;r<=n.colEnd;r++){const n=e.getColGroupInBottom(r);for(let o=i.rowCount-a-1;o>=i.rowCount-t;o--)IG(n,e.getCell(r,o,!0),n.firstChild);let o=0;n.forEachChildren((t=>{t.setAttribute("y",o),o+=i.getRowHeight(t.row)}))}if(i.rightFrozenColCount>0)for(let n=i.colCount-i.rightFrozenColCount;n<i.colCount;n++){const r=e.getColGroupInRightBottomCorner(n);for(let o=i.rowCount-a-1;o>=i.rowCount-t;o--)IG(r,e.getCell(n,o,!0),r.firstChild);let o=0;r.forEachChildren((t=>{t.setAttribute("y",o),o+=i.getRowHeight(t.row)}))}}else if(t<a){for(let n=0;n<i.rowHeaderLevelCount;n++){const r=e.getColGroup(n);for(let o=i.rowCount-a;o<i.rowCount-t;o++){const t=e.getCell(n,o,!0);t.setAttribute("y",r.lastChild.attribute.y+i.getRowHeight(r.lastChild.row)),r.appendChild(t)}const o=e.getColGroupInLeftBottomCorner(n);let s=0;o.forEachChildren((t=>{t.setAttribute("y",s),s+=i.getRowHeight(t.row)}))}for(let r=n.colStart;r<=n.colEnd;r++){const n=e.getColGroup(r);for(let o=i.rowCount-a;o<i.rowCount-t;o++){const t=e.getCell(r,o,!0);t.setAttribute("y",n.lastChild.attribute.y+i.getRowHeight(n.lastChild.row)),n.appendChild(t)}const o=e.getColGroupInBottom(r);let s=0;o.forEachChildren((t=>{t.setAttribute("y",s),s+=i.getRowHeight(t.row)}))}if(i.rightFrozenColCount>0)for(let n=i.colCount-i.rightFrozenColCount;n<i.colCount;n++){const r=e.getColGroup(n);for(let o=i.rowCount-a;o<i.rowCount-t;o++){const t=e.getCell(n,o,!0);t.setAttribute("y",r.lastChild.attribute.y+i.getRowHeight(r.lastChild.row)),r.appendChild(t)}const o=e.getColGroupInRightBottomCorner(n);let s=0;o.forEachChildren((t=>{t.setAttribute("y",s),s+=i.getRowHeight(t.row)}))}}r.setAttribute("height",i.getRowsHeight(i.rowCount-t,i.rowCount-1)),o.setAttribute("height",i.getRowsHeight(i.rowCount-t,i.rowCount-1)),s.setAttribute("height",i.getRowsHeight(i.rowCount-t,i.rowCount-1)),i.internalProps.bottomFrozenRowCount=t,e.updateContainer(),e.component.updateScrollBar(),e.updateNextFrame()}(t,this)}updateBorderSizeAndPosition(){this.bodyGroup.border&&(this.bodyGroup.appendChild(this.bodyGroup.border),Jj(this.bodyGroup),0===this.rowHeaderGroup.attribute.width?qj(this.bodyGroup,this.table.theme.bodyStyle.frameStyle,[!0,!0,!0,!0]):qj(this.bodyGroup,this.table.theme.bodyStyle.frameStyle,[!0,!0,!0,!1])),this.colHeaderGroup.border&&(this.colHeaderGroup.appendChild(this.colHeaderGroup.border),Jj(this.colHeaderGroup),0===this.cornerHeaderGroup.attribute.width?qj(this.colHeaderGroup,this.table.theme.headerStyle.frameStyle,[!0,!0,!0,!0]):qj(this.colHeaderGroup,this.table.theme.headerStyle.frameStyle,[!0,!0,!0,!1])),this.rowHeaderGroup.border&&(this.rowHeaderGroup.appendChild(this.rowHeaderGroup.border),Jj(this.rowHeaderGroup)),this.cornerHeaderGroup.border&&(this.cornerHeaderGroup.appendChild(this.cornerHeaderGroup.border),Jj(this.cornerHeaderGroup))}updateSortIcon(t,e,i,n,r,o,s){const a=this.table.internalProps.headerHelper.getSortIcon(n,this.table,t,e);if(i&&this.updateIcon(i,a),s!==i){const t=this.table.internalProps.headerHelper.getSortIcon("normal",this.table,r,o);if(s)this.updateIcon(s,t);else{let e;this.getCell(r,o).forEachChildren((t=>"sort"===t.attribute.funcType&&(e=t,!0))),e&&this.updateIcon(e,t)}}}updateFrozenIcon(t,e){const i=Math.max(t,e);this.colHeaderGroup.forEachChildrenSkipChild((t=>!(t.col<=i)||(t.forEachChildren((t=>{t.forEachChildren((e=>{if("frozen"===e.attribute.funcType){const i=this.table.internalProps.headerHelper.getFrozenIcon(t.col,t.row);return this.updateIcon(e,i),!0}return!1}))})),!1))),this.cornerHeaderGroup.forEachChildrenSkipChild((t=>!(t.col<=i)||(t.forEachChildren((t=>{t.forEachChildren((e=>{if("frozen"===e.attribute.funcType){const i=this.table.internalProps.headerHelper.getFrozenIcon(t.col,t.row);return this.updateIcon(e,i),!0}return!1}))})),!1)))}sortCell(){this.isPivot||(this.transpose?this.proxy.sortCellHorizontal():this.proxy.sortCellVertical())}getCellOverflowText(t,e){const i=this.getCell(t,e).getChildByName("text",!0);if(i){const t=qu(i.attribute.text)?i.attribute.text.join(""):i.attribute.text;let e="";if(Yu(i.cache.clipedText)?e=i.cache.clipedText:i.cache.layoutData.lines.forEach((t=>{e+=t.str})),e!==t)return t}return null}updateDrill(t,e,i,n,r){this.component.drillIcon.update(t,e,i,n,r,this)}updateCellContent(t,e){if(!this.clear)return tG(t,e,this.table)}setPixelRatio(t){this.stage.disableDirtyBounds(),this.stage.window.setDpr(t),this.stage.render(),this.stage.enableDirtyBounds()}updateHierarchyIcon(t,e){const i=this.getCell(t,e);let n;n=this.table.isHeader(t,e)?this.table.internalProps.headerHelper.getHierarchyIcon(i.col,i.row):this.table.internalProps.bodyHelper.getHierarchyIcon(i.col,i.row),this.findAndUpdateIcon(i,[Jc.collapse,Jc.expand],n)}updateRow(t,e){_G(t,e,this.table),this.recalculateColWidths(),this.recalculateRowHeights(),this.table.stateManeger.checkFrozen(),this.updateNextFrame()}findAndUpdateIcon(t,e,i){t.forEachChildren((t=>{if("group"===t.type)this.findAndUpdateIcon(t,e,i);else if(-1!==e.indexOf(t.attribute.funcType))return this.updateIcon(t,i),!0;return!1}))}}function GG(t,e,i){e.forEachChildren((e=>{"group"===e.type?GG(t,e,i):e.attribute.visibleTime===i&&(e.attribute.visible=!0,t.updateNextFrame())}))}function VG(t,e,i){e.forEachChildren((e=>{"group"===e.type?VG(t,e,i):e.attribute.visibleTime===i&&(e.attribute.visible=!1,t.updateNextFrame())}))}function UG(t,e,i){const n=t.getCell(e,i);if("shadow-cell"===n.role){t.getCell(n.mergeCol,n.mergeRow).addUpdateBoundTag()}else n.addUpdateBoundTag()}function KG(t,e,i,n,r){const o=t.table;for(let i=0;i<o.columnHeaderLevelCount;i++)UG(t,e,i);const s=t.getColGroup(e);return s?.addUpdateBoundTag(),!0}function $G(t,e,i,n,r,o){const s=t.table;for(let i=0;i<s.columnHeaderLevelCount;i++)UG(t,e,i);const a=t.getColGroup(e);return a?.addUpdateBoundTag(),!0}function XG(t,e,i,n,r){const o=t.table;for(let e=0;e<o.colCount;e++)UG(t,e,i);return!0}function YG(t,e,i,n,r,o){const s=t.table;for(let e=0;e<s.colCount;e++)UG(t,e,i);return!0}function qG(t,e,i){const{table:n}=t,{scenegraph:r}=n,{highlightScope:o,singleStyle:s,disableHeader:a,cellPos:l,cellPosContainHeader:h}=t.hover,c=l.col,u=l.row;if(o===Kc.none||a&&(h.col!==e||h.row!==i)){const t=h.col,n=h.row;r.hideHoverIcon(t,n),r.showHoverIcon(e,i),h.col=e,h.row=i}if((a&&n.isHeader(e,i)||o===Kc.none)&&(e=-1,i=-1),c===e&&u===i)return;r.deactivateChart(c,u),r.activateChart(e,i);let d=!1;const{ranges:p,highlightScope:f}=t.select;if(-1!==c&&-1!==u&&(d=function(t,e,i,n,r,o,s){let a=!1;o===Kc.single?a=!!function(t,e,i,n,r){return UG(t,e,i),!0}(t,e,i)||a:o===Kc.row?a=!!XG(t,0,i)||a:o===Kc.column?a=!!KG(t,e)||a:o===Kc.cross&&(a=!!XG(t,0,i)||a,a=!!KG(t,e)||a);return a}(r,c,u,0,0,o),a||r.hideHoverIcon(c,u)),-1===e||-1===i)return l.col=-1,l.row=-1,void(!d||c===e&&u===i||t.table.scenegraph.updateNextFrame());o===Kc.single?d=!!function(t,e,i,n,r){return UG(t,e,i),!0}(r,e,i)||d:o===Kc.row?d=!!YG(r,0,i)||d:o===Kc.column?d=!!$G(r,e)||d:o===Kc.cross&&(d=!!YG(r,0,i)||d,d=!!$G(r,e)||d),o===Kc.none||a||r.showHoverIcon(e,i),l.col=e,l.row=i,d&&t.table.scenegraph.updateNextFrame()}function ZG(t,e,i){let n,r=null,o=!1;if(Array.isArray(i.sortState))for(let s=0;s<i.sortState.length&&(n=i.sortState[s],n&&(r=i._getHeaderCellBySortState(n)),r&&(o=JG(t,e,r.col,r.row,i)),!o);s++);else n=i.sortState,n&&(r=i._getHeaderCellBySortState(n)),r&&(o=JG(t,e,r.col,r.row,i));const s=i.getHeaderDefine(t,e);n&&o&&s?.sort?n.order="asc"===n.order?"desc":"desc"===n.order?"normal":"asc":s?.sort?n={fieldKey:i.getHeaderFieldKey(t,e),field:i.getHeaderField(t,e),order:"asc"}:o&&s?.showSort||(n={fieldKey:i.getHeaderFieldKey(t,e),field:i.getHeaderField(t,e),order:"normal"});i.fireListeners(sf.SORT_CLICK,n).includes(!1)||(i.internalProps.sortState=n,i.stateManeger.setSortState(n),s?.sort&&function(t,e,i){let n;n=t.fieldKey?e.internalProps.layoutMap.headerObjects.find((e=>e&&e.fieldKey===t.fieldKey)):e.internalProps.layoutMap.headerObjects.find((e=>e&&e.field===t.field));if(!n)return;const{field:r}=n;if(null===r)return;"function"==typeof i.sort?e.dataSource.sort(r,t.order||"asc",i.sort):e.dataSource.sort(r,t.order||"asc",Cu)}(n,i,s),i.scenegraph.sortCell(),i.stateManeger.updateSelectPos(-1,-1))}function JG(t,e,i,n,r){return r._getLayoutCellId(t,e)===r._getLayoutCellId(i,n)}const QG=Up(sf,{PIVOT_SORT_CLICK:"pivot_sort_click",DRILLMENU_CLICK:"drillmenu_click"}),tV=Up(sf,{VCHART_EVENT_TYPE:"vchart_event_type"});function eV(t){if(!("canMoveHeaderPosition"in t.table.internalProps.layoutMap))return;setTimeout((()=>{t.columnMove.moving=!1}),0);t.table.moveHeaderPosition({col:t.columnMove.colSource,row:t.columnMove.rowSource},{col:t.columnMove.colTarget,row:t.columnMove.rowTarget})&&(!function(t,e,i,n,r){const o=Math.min(t,i),s=Math.max(t,i),a=Math.min(e,n),l=Math.max(e,n);for(let t=o;t<=s;t++)r._clearColRangeWidthsMap(t);for(let t=a;t<=l;t++)r._clearRowRangeHeightsMap(t)}(t.columnMove.colSource,t.columnMove.rowSource,t.columnMove.colTarget,t.columnMove.rowTarget,t.table),t.table.clearCellStyleCache(),t.table.scenegraph.updateHeaderPosition(t.columnMove.colSource,t.columnMove.rowSource,t.columnMove.colTarget,t.columnMove.rowTarget)),t.updateCursor(),t.table.scenegraph.component.hideMoveCol(),t.table.scenegraph.updateNextFrame()}function iV(t){if(!t)return;const e=t.role?.startsWith("icon")?t:"richtext"===t.type?t._currentHoverIcon:void 0;return e?"richtext"===t.type?{icon:e,position:{left:t.globalAABBBounds.x1+e.globalAABBBounds.x1,right:t.globalAABBBounds.x1+e.globalAABBBounds.x2,top:t.globalAABBBounds.y1+e.globalAABBBounds.y1,bottom:t.globalAABBBounds.y1+e.globalAABBBounds.y2,width:e.globalAABBBounds.x2-e.globalAABBBounds.x1,height:e.globalAABBBounds.y2-e.globalAABBBounds.y1},type:"richtext-icon"}:{icon:e,position:{left:e.globalAABBBounds.x1,right:e.globalAABBBounds.x2,top:e.globalAABBBounds.y1,bottom:e.globalAABBBounds.y2,width:e.globalAABBBounds.x2-e.globalAABBBounds.x1,height:e.globalAABBBounds.y2-e.globalAABBBounds.y1},type:"icon"}:void 0}function nV(t,e){if("adaptive"===e.table.widthMode&&e.columnResize.col<e.table.colCount-1){const i=e.table.getColWidth(e.columnResize.col+1);i-t<0&&(t=i),e.table.scenegraph.updateColWidth(e.columnResize.col,t),e.table.scenegraph.updateColWidth(e.columnResize.col+1,-t),e.table.internalProps._widthResizedColMap.add(e.columnResize.col),e.table.internalProps._widthResizedColMap.add(e.columnResize.col+1)}else e.table.scenegraph.updateColWidth(e.columnResize.col,t),e.table.internalProps._widthResizedColMap.add(e.columnResize.col)}class rV{table;interactionState;select;hover;hoverIcon;residentHoverIcon;columnResize;columnMove;menu;sort;frozen;scroll;tablePosition;drill;sparkLine;_clearVerticalScrollBar;_clearHorizontalScrollBar;resetInteractionState=lf((()=>{this.updateInteractionState(Uc.default)}),100);constructor(t){this.table=t,this.initState(),this.updateVerticalScrollBar=this.updateVerticalScrollBar.bind(this),this.updateHorizontalScrollBar=this.updateHorizontalScrollBar.bind(this)}initState(){this._initState(),this.setHoverState(),this.setSelectState(),this.setFrozenState()}_initState(){this.interactionState=Uc.default,this.select={highlightScope:Kc.single,ranges:[],cellPos:{col:-1,row:-1},selecting:!1},this.hover={highlightScope:Kc.single,cellPos:{col:-1,row:-1}},this.hoverIcon={col:-1,row:-1,icon:null},this.columnResize={col:-1,x:0,resizing:!1},this.columnMove={colSource:-1,colTarget:-1,rowSource:-1,rowTarget:-1,x:0,y:0,moving:!1},this.menu={x:-1,y:-1,isShow:!1,itemList:[],bounds:new ep,highlightIndex:-1,dropDownMenuHighlight:[]},this.sort={col:-1,row:-1,order:"normal"},this.frozen={col:-1},this.scroll={horizontalBarPos:0,verticalBarPos:0},this.tablePosition={absoluteX:0,absoluteY:0},this.drill={col:-1,row:-1},this.sparkLine={col:-1,row:-1}}setHoverState(){const{highlightMode:t,disableHover:e,disableHeaderHover:i}=this.table.options.hover??{highlightMode:"cell"};e?this.hover.highlightScope=Kc.none:"cross"===t?this.hover.highlightScope=Kc.cross:"row"===t?this.hover.highlightScope=Kc.row:"column"===t?this.hover.highlightScope=Kc.column:"cell"===t&&(this.hover.highlightScope=Kc.single),this.hover.singleStyle=!e,this.hover.disableHeader=i,(this.hover.highlightScope===Kc.none||i)&&(this.hover.cellPosContainHeader={col:-1,row:-1})}setSelectState(){const{disableSelect:t,disableHeaderSelect:e}=this.table.options?.select??{disableSelect:!1,disableHeaderSelect:!1};this.select.highlightScope=t?Kc.none:Kc.single,this.select.singleStyle=!t,this.select.disableHeader=e}isSelected(t,e){let i=!1;return this.select.ranges.forEach((n=>{qp(n,t,e)&&(i=!0)})),i}setSortState(t){this.sort.field=t.field,this.sort.fieldKey=t.fieldKey,this.sort.order=t.order}setFrozenState(){this.frozen.col=this.table.frozenColCount-1}updateInteractionState(t){this.interactionState!==t&&(this.interactionState=t)}updateHoverhighlightScope(t){this.hover.highlightScope!==t&&(this.hover.highlightScope=t)}updateHoverPos(t,e){qG(this,t,e)}updateSelectPos(t,e,i=!1,n=!1,r=!1){-1!==e&&-1!==e&&(this.select.selecting=!0),function(t,e,i,n,r,o){const{table:s,interactionState:a}=t,{scenegraph:l}=s,{highlightScope:h,disableHeader:c,cellPos:u}=t.select;if((c&&s.isHeader(e,i)||"none"===h)&&(e=-1,i=-1),u.col!==e||u.row!==i){if(-1!==e&&-1!==i&&t.select.ranges.length>0)if(a===Uc.grabing){const n=t.select.ranges[t.select.ranges.length-1];e>n.start.col&&e>n.end.col&&s._makeVisibleCell(e+1,i),i>n.start.row&&i>n.end.row&&s._makeVisibleCell(e,i+1),e<n.start.col&&e<n.end.col&&s._makeVisibleCell(e-1,i),i<n.start.row&&i<n.end.row&&s._makeVisibleCell(e,i-1)}else s._makeVisibleCell(e,i);if(o){t.select.ranges=[],l.deleteAllSelectBorder(),t.select.ranges.push({start:{col:0,row:0},end:{col:s.colCount-1,row:s.rowCount-1}});const e=t.select.ranges[t.select.ranges.length-1];l.updateCellSelectBorder(e.start.col,e.start.row,e.end.col,e.end.row)}else if(-1===u.col||-1===u.row||-1!==e&&-1!==i){if(a===Uc.default){const o=t.select.ranges[t.select.ranges.length-1];if(n&&o){if(s.isColumnHeader(e,i)){const t=Math.min(o.start.col,o.end.col,e),n=Math.max(o.start.col,o.end.col,e),r=Math.min(o.start.row,o.end.row,i),a=s.rowCount-1;o.start={col:t,row:r},o.end={col:n,row:a}}else if(s.isRowHeader(e,i)){const t=Math.min(o.start.col,o.end.col,e),n=s.colCount-1,r=Math.min(o.start.row,o.end.row,i),a=Math.max(o.start.row,o.end.row,i);o.start={col:t,row:r},o.end={col:n,row:a}}else o.end={col:e,row:i};l.deleteLastSelectedRangeComponents(),l.updateCellSelectBorder(o.start.col,o.start.row,o.end.col,o.end.row)}else{-1===u.col||-1===u.row||r||(t.select.ranges=[],l.deleteAllSelectBorder()),s.isColumnHeader(e,i)?t.select.ranges.push({start:{col:e,row:i},end:{col:e,row:s.rowCount-1}}):s.isRowHeader(e,i)?t.select.ranges.push({start:{col:e,row:i},end:{col:s.colCount-1,row:i}}):t.select.ranges.push({start:{col:e,row:i},end:{col:e,row:i}}),u.col=e,u.row=i;const n=t.select.ranges[t.select.ranges.length-1];l.updateCellSelectBorder(n.start.col,n.start.row,n.end.col,n.end.row)}}else if(a===Uc.grabing){-1===u.col&&(u.col=e),-1===u.row&&(u.row=i);const n=t.select.ranges[t.select.ranges.length-1];n.end={col:e,row:i},u.col=e,u.row=i,l.updateCellSelectBorder(n.start.col,n.start.row,e,i)}}else u.col=-1,u.row=-1,t.select.ranges=[],l.deleteAllSelectBorder();l.updateNextFrame()}}(this,t,e,i,n,r)}checkCellRangeInSelect(t,e){return function(t,e,i,n){for(let n=0;n<i.length;n++)if(Jp(i[n],{start:t,end:e}))return!0;return!1}(t,e,this.select.ranges,this.select.highlightScope)}updateHoverIcon(t,e,i,n,r){if(i===this.residentHoverIcon?.icon)return;const o=iV(i);if(o)if("richtext-icon"===o.type){const i=o.icon;if(this.hoverIcon.icon&&this.hoverIcon.icon!==this.residentHoverIcon?.icon&&(this.table.scenegraph.setIconNormalStyle(this.hoverIcon.icon,this.hoverIcon.col,this.hoverIcon.row),this.hoverIcon.col=-1,this.hoverIcon.col=-1,this.hoverIcon.icon=null,this.table.scenegraph.updateNextFrame()),i.attribute.tooltip){const n={content:i.attribute.tooltip.title,referencePosition:{rect:o.position,placement:i.attribute.tooltip.placement},style:Object.assign({},this.table.internalProps.theme?.tooltipStyle,i.tooltip?.style)};this.table.internalProps.tooltipHandler.isBinded(n)||this.table.showTooltip(t,e,n)}}else{const i=o.icon;i!==this.hoverIcon.icon&&(this.hoverIcon.icon&&this.hoverIcon.icon!==this.residentHoverIcon?.icon&&this.table.scenegraph.setIconNormalStyle(this.hoverIcon.icon,this.hoverIcon.col,this.hoverIcon.row),this.hoverIcon.col=t,this.hoverIcon.col=e,this.hoverIcon.icon=i,this.table.scenegraph.setIconHoverStyle(i,t,e,n),this.table.scenegraph.updateNextFrame())}else this.hoverIcon.icon&&this.hoverIcon.icon!==this.residentHoverIcon?.icon&&(this.table.scenegraph.setIconNormalStyle(this.hoverIcon.icon,this.hoverIcon.col,this.hoverIcon.row),this.hoverIcon.col=-1,this.hoverIcon.col=-1,this.hoverIcon.icon=null,this.table.scenegraph.updateNextFrame())}isResizeCol(){return this.columnResize.resizing}isSelecting(){return this.select.selecting}endSelectCells(){if(this.select.selecting=!1,0===this.select.ranges.length)return;this.table.scenegraph.moveSelectingRangeComponentsToSelectedRangeComponents();const t=this.select.ranges[this.select.ranges.length-1].end.col,e=this.select.ranges[this.select.ranges.length-1].end.row;this.table.fireListeners(sf.SELECTED_CELL,{ranges:this.select.ranges,col:t,row:e})}endResizeCol(){setTimeout((()=>{this.columnResize.resizing=!1}),0),this.table.scenegraph.updateChartSize(this.columnResize.col),this.checkFrozen(),this.table.scenegraph.component.hideResizeCol(),this.table.scenegraph.updateNextFrame()}startResizeCol(t,e,i,n){this.columnResize.resizing=!0,this.columnResize.col=t,this.columnResize.x=e,this.columnResize.isRightFrozen=n,this.table.scenegraph.component.showResizeCol(t,i,n),this.table.stateManeger.updateSelectPos(-1,-1),this.table.scenegraph.updateNextFrame()}updateResizeCol(t,e){!function(t,e,i){t=Math.ceil(t),e=Math.ceil(e);let n=i.columnResize.isRightFrozen?i.columnResize.x-t:t-i.columnResize.x;if(Math.abs(n)<1)return;const r=i.table.getColWidth(i.columnResize.col);let o=r;o+=n;const s=i.table.getMinColWidth(i.columnResize.col),a=i.table.getMaxColWidth(i.columnResize.col);if(o<s||o>a){if(r===s||r===a)return;n=r-s>a-r?a-r:s-r}n=Math.ceil(n),i.columnResize.col<i.table.rowHeaderLevelCount||i.columnResize.col>=i.table.colCount-i.table.rightFrozenColCount?nV(n,i):"indicator"===i.table.internalProps.columnResizeType?function(t,e){const i=e.table.internalProps.layoutMap;let n,r,o;if(i.indicatorsAsCol)n=i.getIndicatorKey(e.columnResize.col,e.table.columnHeaderLevelCount);else{const t=i.getCellHeaderPaths(e.columnResize.col,e.table.columnHeaderLevelCount-1),n=t.colHeaderPaths[t.colHeaderPaths.length-1];r=n.dimensionKey,o=n.value}for(let s=e.table.rowHeaderLevelCount;s<e.table.colCount-e.table.rightFrozenColCount;s++){const a=i.getIndicatorKey(s,e.table.columnHeaderLevelCount);if(i.indicatorsAsCol&&a===n)e.table.scenegraph.updateColWidth(s,t),e.table.internalProps._widthResizedColMap.add(s);else if(!i.indicatorsAsCol){const n=i.getCellHeaderPaths(s,e.table.columnHeaderLevelCount-1),a=n?.colHeaderPaths[n.colHeaderPaths.length-1];a&&r===a.dimensionKey&&o===a.value&&(e.table.scenegraph.updateColWidth(s,t),e.table.internalProps._widthResizedColMap.add(s))}}}(n,i):"indicatorGroup"===i.table.internalProps.columnResizeType?function(t,e){const i=e.table.internalProps.layoutMap,n=i.getCellHeaderPaths(e.columnResize.col,e.table.columnHeaderLevelCount),r=i.getHeadNode(n.colHeaderPaths.slice(0,n.colHeaderPaths.length-1)),o=r.startInTotal+e.table.frozenColCount,s=r.startInTotal+e.table.frozenColCount+r.size-1,a=e.table.getColsWidth(o,s),l=t;for(let t=o;t<=s;t++){if(!(e.table.internalProps.transpose||e.table.isPivotTable()&&!i.indicatorsAsCol)){const n=i.getBody(t,e.table.columnHeaderLevelCount);if(n?.disableColumnResize)continue}const n=e.table.getColWidth(t);e.table.scenegraph.updateColWidth(t,n/a*l),e.table.internalProps._widthResizedColMap.add(t)}}(n,i):"all"===i.table.internalProps.columnResizeType?function(t,e){const i=e.table.internalProps.layoutMap;for(let n=e.table.options.frozenColCount;n<e.table.colCount-e.table.rightFrozenColCount;n++){if(!(e.table.internalProps.transpose||e.table.isPivotTable()&&!i.indicatorsAsCol)){const t=i.getBody(n,e.table.columnHeaderLevelCount);if(t?.disableColumnResize)continue}e.table.scenegraph.updateColWidth(n,t),e.table.internalProps._widthResizedColMap.add(n)}}(n,i):nV(n,i),i.columnResize.x=t,i.table.scenegraph.component.updateResizeCol(i.columnResize.col,e,i.columnResize.isRightFrozen),i.columnResize.col<i.table.frozenColCount&&!i.table.isPivotTable()&&!i.table.transpose&&i.table.scenegraph.component.setFrozenColumnShadow(i.table.frozenColCount-1,i.columnResize.isRightFrozen),i.table.scenegraph.updateNextFrame()}(t,e,this)}startMoveCol(t,e,i,n){!function(t,e,i,n,r){if(!("canMoveHeaderPosition"in r.table.internalProps.layoutMap))return;r.columnMove.moving=!0,r.columnMove.colSource=t,r.columnMove.rowSource=e,r.columnMove.x=i-r.table.tableX,r.columnMove.y=n-r.table.tableY;const o=r.table.getCellLocation(t,e),s="columnHeader"===o?r.columnMove.x:"rowHeader"===o?r.columnMove.y:0;r.table.scenegraph.component.showMoveCol(t,e,s),r.table.stateManeger.updateSelectPos(-1,-1),r.table.scenegraph.updateNextFrame()}(t,e,i,n,this)}updateMoveCol(t,e,i,n){!function(t,e,i,n,r){if(!("canMoveHeaderPosition"in r.table.internalProps.layoutMap))return;const o=function(t,e,i){const n=i.getCellRange(t.col,t.row);if(i.isColumnHeader(t.col,t.row)){const r=i.getCellRange(e.col,n.start.row);e.row>=i.columnHeaderLevelCount&&(e.row=i.columnHeaderLevelCount-1),e.col>=t.col?e.col=r.end.col:e.col=r.start.col}else if(i.isRowHeader(t.col,t.row)){const r=i.getCellRange(n.start.col,e.row);e.col>=i.rowHeaderLevelCount&&(e.col=i.rowHeaderLevelCount-1);const o=i.internalProps.layoutMap;if("tree"===o.rowHierarchyType){const n=o.getCellHeaderPathsWidthTreeNode(t.col,t.row).rowHeaderPaths,r=o.getCellHeaderPathsWidthTreeNode(e.col,e.row).rowHeaderPaths;if(n.length<=r.length){const o=r[n.length-1];o&&(e.row>=t.row?e.row=o.startInTotal+o.size-1+i.columnHeaderLevelCount:e.row=o.startInTotal+i.columnHeaderLevelCount)}}else e.row>=t.row?e.row=r.end.row:e.row=r.start.row}return e}({col:r.columnMove.colSource,row:r.columnMove.rowSource},{col:t,row:e},r.table);let s,a,l,h;r.columnMove.x=i-r.table.tableX,r.columnMove.y=n-r.table.tableY,r.columnMove.colTarget=o.col,r.columnMove.rowTarget=o.row,r.table.internalProps.layoutMap.canMoveHeaderPosition({col:r.columnMove.colSource,row:r.columnMove.rowSource},{col:r.columnMove.colTarget,row:r.columnMove.rowTarget})?r.updateCursor("grabbing"):r.updateCursor("not-allowed");const c=r.table.getCellLocation(t,e);"columnHeader"===c?(a=r.columnMove.x,s=r.columnMove.colTarget>=r.columnMove.colSource?r.table.getColsWidth(0,r.columnMove.colTarget):r.table.getColsWidth(0,r.columnMove.colTarget-1)):"rowHeader"===c&&(h=r.columnMove.y,l=r.columnMove.rowTarget>=r.columnMove.rowSource?r.table.getRowsHeight(0,r.columnMove.rowTarget):r.table.getRowsHeight(0,r.columnMove.rowTarget-1)),r.table.scenegraph.component.updateMoveCol(a,s,h,l),r.table.scenegraph.updateNextFrame()}(t,e,i,n,this)}isMoveCol(){return this.columnMove.moving}endMoveCol(){eV(this)}checkFrozen(){if(this.table.options.frozenColCount){if(this.table.tableNoFrameWidth-this.table.getColsWidth(0,this.table.options.frozenColCount-1)<=120)return this.table._setFrozenColCount(0),this.setFrozenCol(-1),!1;if(this.table.frozenColCount!==this.table.options.frozenColCount)return this.table._setFrozenColCount(this.table.options.frozenColCount),this.setFrozenCol(this.table.options.frozenColCount),!1}return!0}setFrozenCol(t){t!==this.frozen.col?(this.frozen.col=t,this.table.scenegraph.updateFrozen(),this.table.scenegraph.updateFrozenIcon(0,this.table.colCount-1)):this.table.scenegraph.updateFrozenIcon(0,this.table.colCount-1)}updateVerticalScrollBar(t){const e=this.table.getAllRowsHeight();this.scroll.verticalBarPos=Math.ceil(t*(e-this.table.scenegraph.height)),this.table.scenegraph.setY(-this.scroll.verticalBarPos),this.table.stateManeger.updateHoverPos(-1,-1),this.table.fireListeners(sf.SCROLL,{scrollTop:this.scroll.verticalBarPos,scrollLeft:this.scroll.horizontalBarPos,scrollHeight:this.table.theme.scrollStyle?.width,scrollWidth:this.table.theme.scrollStyle?.width,viewHeight:this.table.tableNoFrameHeight,viewWidth:this.table.tableNoFrameWidth})}updateHorizontalScrollBar(t){const e=this.table.getAllColsWidth();this.scroll.horizontalBarPos=Math.ceil(t*(e-this.table.scenegraph.width)),this.table.scenegraph.setX(-this.scroll.horizontalBarPos),this.table.stateManeger.updateHoverPos(-1,-1),this.table.fireListeners(sf.SCROLL,{scrollTop:this.scroll.verticalBarPos,scrollLeft:this.scroll.horizontalBarPos,scrollHeight:this.table.theme.scrollStyle?.width,scrollWidth:this.table.theme.scrollStyle?.width,viewHeight:this.table.tableNoFrameHeight,viewWidth:this.table.tableNoFrameWidth})}setScrollTop(t){const e=this.table.getAllRowsHeight();t=Math.max(0,Math.min(t,e-this.table.scenegraph.height)),t=Math.ceil(t),this.scroll.verticalBarPos=t,this.table.scenegraph.setY(-t),this.table.scenegraph.component.updateVerticalScrollBarPos(t/(e-this.table.scenegraph.height)),this.table.stateManeger.updateHoverPos(-1,-1),this.table.fireListeners(sf.SCROLL,{scrollTop:this.scroll.verticalBarPos,scrollLeft:this.scroll.horizontalBarPos,scrollHeight:this.table.theme.scrollStyle?.width,scrollWidth:this.table.theme.scrollStyle?.width,viewHeight:this.table.tableNoFrameHeight,viewWidth:this.table.tableNoFrameWidth})}setScrollLeft(t){const e=this.table.getAllColsWidth(),i=this.table.getFrozenColsWidth();t=Math.max(0,Math.min(t,e-this.table.scenegraph.width)),t=Math.ceil(t),this.scroll.horizontalBarPos=t,this.table.scenegraph.setX(-t),this.table.scenegraph.component.updateHorizontalScrollBarPos(t/(e-i)),this.table.stateManeger.updateHoverPos(-1,-1),this.table.fireListeners(sf.SCROLL,{scrollTop:this.scroll.verticalBarPos,scrollLeft:this.scroll.horizontalBarPos,scrollHeight:this.table.theme.scrollStyle?.width,scrollWidth:this.table.theme.scrollStyle?.width,viewHeight:this.table.tableNoFrameHeight,viewWidth:this.table.tableNoFrameWidth})}hideVerticalScrollBar(){this.table.scenegraph.component.hideVerticalScrollBar()}showVerticalScrollBar(t){this.table.scenegraph.component.showVerticalScrollBar(),t&&(clearTimeout(this._clearVerticalScrollBar),this._clearVerticalScrollBar=setTimeout((()=>{this.table.scenegraph.component.hideVerticalScrollBar()}),1e3))}hideHorizontalScrollBar(){this.table.scenegraph.component.hideHorizontalScrollBar()}showHorizontalScrollBar(t){this.table.scenegraph.component.showHorizontalScrollBar(),t&&(clearTimeout(this._clearHorizontalScrollBar),this._clearHorizontalScrollBar=setTimeout((()=>{this.table.scenegraph.component.hideHorizontalScrollBar()}),1e3))}triggerContextMenu(t,e,i,n){this.menu.isShow&&this.menu.x===i&&this.menu.y===n?this.hideMenu():this.showContextMenu(t,e,i,n)}showContextMenu(t,e,i,n){this.table.internalProps.menu?.contextMenuItems&&("html"===this.table.internalProps.menu.renderMode?this.menu.isShow=!0:(this.menu.isShow=!0,this.menu.x=i,this.menu.y=n,this.table.scenegraph.component.menu.attach(i,n,t,e,Nj.contextmenu)),this.table.fireListeners(sf.SHOW_MENU,{x:i,y:n,col:t,row:e,type:"contextmenu"}))}triggerDropDownMenu(t,e,i,n){this.table.fireListeners(sf.DROPDOWN_ICON_CLICK,{col:t,row:e}),this.menu.isShow?this.hideMenu():this.showDropDownMenu(t,e,i,n)}showDropDownMenu(t,e,i,n){"html"===this.table.internalProps.menu.renderMode?this.menu.isShow=!0:(this.menu.isShow=!0,this.table.scenegraph.component.menu.attach(i,n,t,e,Nj.dropDown),this.menu.bounds=this.table.scenegraph.component.menu.bounds),this.table.fireListeners(sf.SHOW_MENU,{x:i,y:n,col:t,row:e,type:"dropDown"}),this.residentHoverIcon&&this.table.scenegraph.setIconNormalStyle(this.residentHoverIcon.icon,this.residentHoverIcon.col,this.residentHoverIcon.row);const r=this.table.scenegraph.getCell(t,e);let o;r.forEachChildren((t=>t.attribute.funcType===Jc.dropDown&&(o=t,!0))),o&&(this.residentHoverIcon={col:t,row:e,icon:o},this.table.scenegraph.setIconHoverStyle(this.residentHoverIcon.icon,this.residentHoverIcon.col,this.residentHoverIcon.row,r),o.oldVisibleTime=o.attribute.visibleTime,o.setAttribute("visibleTime","always"),o.setAttribute("visible",!0))}hideMenu(){this.table.fireListeners(sf.DROPDOWN_MENU_CLEAR,null),this.table.fireListeners(sf.HIDE_MENU,null),this.menu.isShow=!1,this.table.scenegraph.component.menu.detach(),this.residentHoverIcon&&(this.table.scenegraph.setIconNormalStyle(this.residentHoverIcon.icon,this.residentHoverIcon.col,this.residentHoverIcon.row),this.residentHoverIcon.icon.setAttribute("visibleTime",this.residentHoverIcon.icon.oldVisibleTime),this.residentHoverIcon.icon.setAttribute("visible","always"===this.residentHoverIcon.icon.attribute.visibleTime),this.residentHoverIcon=null)}setDropDownMenuHighlight(t){this.menu.dropDownMenuHighlight=t;for(let e=0;e<t.length;e++){const{col:i,row:n}=t[e];this.table.scenegraph.updateCellContent(i,n)}}dropDownMenuIsHighlight(t,e,i){const n=this.menu.dropDownMenuHighlight;if(Array.isArray(n))for(let r=0;r<n.length;r++){const o=n[r];let{col:s,row:a}=o;const{field:l,menuKey:h}=o;if("number"!=typeof s||"number"!=typeof a)if(this.table.isPivotTable()&&(Array.isArray(l),1)){const t=this.table.internalProps.layoutMap.getPivotCellAdress(l);if(!t)continue;s=t.col,a=t.row}else{const t=this.table.internalProps.layoutMap.getHeaderCellAddressByField(l);if(!t)continue;s=t.col,a=t.row}if(bu(s)&&bu(a)&&this.table.isCellRangeEqual(t,e,s,a)){const n=this.table._getHeaderLayoutMap(s??t,a??e).dropDownMenu||this.table.globalDropDownMenu;if(n)for(let t=0;t<n.length;t++){const e=n[t];if(ou(e)&&(e.menuKey||e.text)===(h||"")&&t===i)return!0;if(au(e)&&e===h&&t===i)return!0}}}return!1}triggerSort(t,e,i){if(this.table.isPivotTable()){const i=this.table.getPivotSortState(t,e);return void this.table.fireListeners(QG.PIVOT_SORT_CLICK,{col:t,row:e,order:i||"normal",dimensionInfo:this.table.internalProps.layoutMap.getPivotDimensionInfo(t,e),cellLocation:this.table.getCellLocation(t,e)})}const n=this.sort.col,r=this.sort.row;ZG(t,e,this.table),this.sort.col=t,this.sort.row=e,this.table.scenegraph.updateSortIcon(this.sort.col,this.sort.row,i,this.sort.order,n,r,this.sort.icon),this.sort.icon=i}updateSortState(t){if(t.field===this.sort.field&&t.order===this.sort.order)return;const e=this.sort.col,i=this.sort.row,n="asc"===this.sort.order?"sort_downward":"desc"===this.sort.order?"sort_upward":"sort_normal";this.setSortState(t);const r=this.table.internalProps.layoutMap.getHeaderCellAddressByField(t.field);this.sort.col=r.col,this.sort.row=r.row;const o=this.table.scenegraph.getCell(this.sort.col,this.sort.row).getChildByName(n,!0);this.table.scenegraph.sortCell(),this.table.scenegraph.updateSortIcon(this.sort.col,this.sort.row,o,this.sort.order,e,i,this.sort.icon)}triggerFreeze(t,e,i){this.table.isPivotTable()||this.table.transpose||(!function(t,e,i){i.frozenColCount>0?t!==i.frozenColCount-1?i.setFrozenColCount(t+1):i.setFrozenColCount(0):i.setFrozenColCount(t+1)}(t,0,this.table),this.frozen.icon=i)}updateCursor(t="default"){this.table.getElement().style.cursor=t}updateDrillState(t,e,i,n,r,o){this.drill.dimensionKey=t,this.drill.title=e,this.drill.drillDown=i,this.drill.drillUp=n,this.drill.col=r,this.drill.row=o,function(t,e,i,n,r){const o=r.getCellLocation(t,e);let s=0,a=0,l=!1;"columnHeader"===o?(s=r.getColsWidth(0,r.rowHeaderLevelCount-1)-(0===r.frozenColCount?r.scrollLeft:0),a=r.getRowsHeight(0,e-1)+r.getRowHeight(e)/2,l=!0):"rowHeader"===o&&(a=r.getRowsHeight(0,r.columnHeaderLevelCount-1),s=r.getColsWidth(0,t-1)+r.getColWidth(t)/2,l=!0),r.scenegraph.updateDrill(l,s,a,i,n)}(r,o,i,n,this.table)}updateSparklineHoverPose(t,e,i,n){-1!==this.sparkLine.col&&-1!==this.sparkLine.row&&function(t,e,i){const n=i.scenegraph.getCell(t,e).getChildByName("sparkline"),r=n?.getChildByName("highlight-line"),o=n?.getChildByName("highlight-symbol");r&&r.setAttributes({visible:!1,pickable:!1}),o&&o.setAttributes({visible:!1,pickable:!1}),i.scenegraph.updateNextFrame()}(this.sparkLine.col,this.sparkLine.row,this.table),-1!==t&&-1!==e&&function(t,e,i,n,r){const o=r.scenegraph.getCell(t,e).getChildByName("sparkline"),s=o?.getChildByName("sparkline-line"),a=o?.getChildByName("sparkline-symbol-group");if(!s)return;const l=s.bandwidth,h=s.min,c=s.max,u=s.attribute.points;let d;i-=o.globalAABBBounds.x1,o.globalAABBBounds.y1;for(let t=0;t<u.length;t++){const{x:e,y:n,defined:r,rawData:p}=u[t];if(Math.abs(i-e)<l/2&&(d={point:u[t],points:u,pointsBandWidth:l,pointData:p},r)){const t=o.getChildByName("highlight-line");if(t)t.setAttributes({x:e,visible:!0,pickable:!0});else{const t=QA({x:e,y:0,points:[{x:0,y:c},{x:0,y:h}],lineWidth:s.hover?.strokeWidth,stroke:s.hover?.stroke});t.name="highlight-line",o.addChild(t)}const i=o.getChildByName("highlight-symbol");if(i)i.setAttributes({x:e,y:n,visible:!0,pickable:!0});else{const t=nT({x:e,y:n,stroke:a.hover.stroke,lineWidth:a.hover.strokeWidth,fill:a.hover.fill,size:2*a.hover.size,symbolType:"circle"});t.name="highlight-symbol",o.addChild(t)}break}}if(r.scenegraph.updateNextFrame(),d){const i={col:t,row:e,field:r.getHeaderField(t,e),value:r.getCellValue(t,e),dataValue:r.getCellOriginValue(t,e),cellHeaderPaths:r.internalProps.layoutMap.getCellHeaderPaths(t,e),title:r.getBodyColumnDefine(t,e).title,cellRange:r.getCellRelativeRect(t,e),sparkline:{pointData:d.pointData},scaleRatio:r.canvas.getBoundingClientRect().width/r.canvas.offsetWidth};r.fireListeners(sf.MOUSEOVER_CHART_SYMBOL,i)}}(t,e,i,0,this.table),this.sparkLine.col=t,this.sparkLine.row=e}}function oV(t){const e={abstractPos:{x:t.x,y:t.y}},i=function(t){for(;t&&t.parent;){if("cell"===t.role)return t;t=t.parent}return null}(t.target);return i&&(e.eventArgs={col:i.col,row:i.row,event:t,targetCell:i,target:t.target}),e}let sV,aV;function lV(t){if(t.stateManeger.endResizeCol(),t.hasListeners(sf.RESIZE_COLUMN_END)){const e=[];for(let i=0;i<t.colCount;i++)e.push(t.getColWidth(i));t.fireListeners(sf.RESIZE_COLUMN_END,{col:t.stateManeger.columnResize.col,columns:e})}}function hV(t,e){let{deltaX:i,deltaY:n}=t;t.shiftKey&&t.deltaY&&(i=n,n=0);const[r,o]=function(t,e,i){const n=2,r=Math.abs(t/e),o=r<=1/n?0:t,s=r>n?0:e;return[Math.ceil(o*(i.horizontal??0)),Math.ceil(s*(i.vertical??0))]}(i,n,{horizontal:1,vertical:1});(r||o)&&e.interactionState!==Uc.scrolling&&e.updateInteractionState(Uc.scrolling),r&&(e.setScrollLeft(e.scroll.horizontalBarPos+r),e.showHorizontalScrollBar(!0)),o&&(e.setScrollTop(e.scroll.verticalBarPos+o),e.showVerticalScrollBar(!0)),e.resetInteractionState(),t.cancelable&&(0!==n&&cV(n,e)||0!==i&&uV(i,e))&&t.preventDefault()}function cV(t,e){return 0!=e.table.getAllRowsHeight()-e.table.scenegraph.height&&(!function(t,e){const i=e.table.getAllRowsHeight()-e.table.scenegraph.height;return 0!==i&&t<=0&&e.scroll.verticalBarPos<1}(t,e)&&!function(t,e){const i=e.table.getAllRowsHeight()-e.table.scenegraph.height;return 0!==i&&t>=0&&Math.abs(e.scroll.verticalBarPos-i)<1}(t,e))}function uV(t,e){return 0!=e.table.getAllColsWidth()-e.table.scenegraph.width&&(!function(t,e){const i=e.table.getAllColsWidth()-e.table.scenegraph.width;return 0!==i&&t<=0&&e.scroll.horizontalBarPos<1}(t,e)&&!function(t,e){const i=e.table.getAllColsWidth()-e.table.scenegraph.width;return 0!==i&&t>=0&&Math.abs(e.scroll.horizontalBarPos-i)<1}(t,e))}function dV(t){const e=t.table,i=e.stateManeger,n=e.scenegraph;t.touchMovePoints=[],e.scenegraph.tableGroup.addEventListener("touchstart",(e=>{e.target.isChildOf(n.component.vScrollBar)||e.target.isChildOf(n.component.vScrollBar)||(t.isTouchdown=!0,t.touchMovePoints.push({x:e.page.x,y:e.page.y,timestamp:Date.now()}))})),window.addEventListener("touchmove",(e=>{if(t.touchMove&&e.preventDefault(),!t.isTouchdown||!pV(e))return;t.touchMovePoints.length>4&&t.touchMovePoints.shift(),t.touchMovePoints.push({x:e.changedTouches[0].pageX,y:e.changedTouches[0].pageY,timestamp:Date.now()});const n=-t.touchMovePoints[t.touchMovePoints.length-1].x+t.touchMovePoints[t.touchMovePoints.length-2].x,r=-t.touchMovePoints[t.touchMovePoints.length-1].y+t.touchMovePoints[t.touchMovePoints.length-2].y;hV({deltaX:n,deltaY:r},i),e.cancelable&&(0!==r&&cV(r,i)||0!==n&&uV(n,i))&&e.preventDefault()}),{passive:!1}),window.addEventListener("touchend",(e=>{if(t.touchEnd=!0,t.touchMove=!1,t.isTouchdown&&pV(e)){if(t.touchMovePoints?.length){t.touchMovePoints.length>4&&t.touchMovePoints.shift(),t.touchMovePoints.push({x:e.changedTouches[0].pageX,y:e.changedTouches[0].pageY,timestamp:Date.now()});const n=t.touchMovePoints[0],r=t.touchMovePoints[t.touchMovePoints?.length-1];!function(t,e,i){let n=Date.now();const r=.95,o=()=>{const s=Date.now(),a=s-n;let l=!0;const h=Math.pow(r,a/16),c=h*t,u=h*e;let d=0,p=0;Math.abs(c)>.05&&(l=!1,d=(t+c)/2*a),Math.abs(u)>.05&&(l=!1,p=(e+u)/2*a),hV({deltaX:-d,deltaY:-p},i),l||(n=s,t=c,e=u,requestAnimationFrame(o))};requestAnimationFrame(o)}((r.x-n.x)/(r.timestamp-n.timestamp),(r.y-n.y)/(r.timestamp-n.timestamp),i)}t.isTouchdown=!1,t.touchMovePoints=[]}})),window.addEventListener("touchcancel",(e=>{t.touchEnd=!0,t.touchMove=!1,t.isTouchdown&&(t.isTouchdown=!1,t.touchMovePoints=[])}))}function pV(t){return!!t.changedTouches}function fV(t,e,i){if(i.indicatorsAsCol){if(i.hasTwoIndicatorAxes&&e===i.columnHeaderLevelCount-1&&t>=i.rowHeaderLevelCount&&t<i.colCount-i.rightFrozenColCount)return"top";if(e===i.rowCount-i.bottomFrozenRowCount&&t>=i.rowHeaderLevelCount&&t<i.colCount-i.rightFrozenColCount)return"bottom";if(t===i.rowHeaderLevelCount-1&&e>=i.rowHeaderLevelCount&&e<i.rowCount-i.bottomFrozenRowCount)return"left"}else{if(t===i.rowHeaderLevelCount-1&&e>=i.columnHeaderLevelCount&&e<i.rowCount-i.bottomFrozenRowCount)return"left";if(t===i.colCount-i.rightFrozenColCount&&e>=i.columnHeaderLevelCount&&e<i.rowCount-i.bottomFrozenRowCount)return"right";if(e===i.rowCount-i.bottomFrozenRowCount&&t>=i.rowHeaderLevelCount&&t<i.colCount-i.rightFrozenColCount)return"bottom"}return"bottom"}class gV{table;isTouchdown;touchMovePoints;touchSetTimeout;touchEnd;touchMove;constructor(t){this.table=t,this.bindOuterEvent(),setTimeout((()=>{this.bindSelfEvent()}),0)}bindOuterEvent(){!function(t){const e=t.table,i=e.stateManeger;document.body.addEventListener("pointermove",(n=>{t.touchSetTimeout&&(clearTimeout(t.touchSetTimeout),t.touchSetTimeout=void 0);const{x:r,y:o}=e._getMouseAbstractPoint(n,!1);i.interactionState!==Uc.scrolling&&i.interactionState===Uc.grabing&&i.isResizeCol()&&(t.dealColumnResize(r,o),e.hasListeners(sf.RESIZE_COLUMN)&&e.fireListeners(sf.RESIZE_COLUMN,{col:e.stateManeger.columnResize.col,colWidth:e.getColWidth(e.stateManeger.columnResize.col)}))})),e.scenegraph.tableGroup.addEventListener("pointermove",(n=>{const r=sV?.x??n.x,o=sV?.y??n.y;sV={x:n.x,y:n.y},t.touchSetTimeout&&(clearTimeout(t.touchSetTimeout),t.touchSetTimeout=void 0);const s=oV(n);if(i.interactionState===Uc.scrolling)return;if(i.interactionState===Uc.grabing&&Math.abs(r-n.x)+Math.abs(o-n.y)>=1)return void(i.isResizeCol()||(i.isMoveCol()?t.dealColumnMover(s):t.dealTableSelect(s)));i.isResizeCol()||t.checkColumnResize(s)?i.updateCursor("col-resize"):i.updateCursor();const a=n.path.find((t=>"cell"===t.role));if(e.hasListeners(sf.MOUSELEAVE_CELL)&&("cell"!==a?.role||-1===e.stateManeger.hover.cellPos.col||-1===e.stateManeger.hover.cellPos.row||a.col===e.stateManeger.hover.cellPos.col&&a.row===e.stateManeger.hover.cellPos.row||e.fireListeners(sf.MOUSELEAVE_CELL,{col:e.stateManeger.hover.cellPos.col,row:e.stateManeger.hover.cellPos.row,cellRange:e.getCellRangeRelativeRect({col:e.stateManeger.hover.cellPos.col,row:e.stateManeger.hover.cellPos.row}),scaleRatio:e.canvas.getBoundingClientRect().width/e.canvas.offsetWidth,event:n.nativeEvent})),e.hasListeners(sf.MOUSEENTER_CELL)&&"cell"===a?.role&&Uu(a.col)&&Uu(a.row)&&(a.col!==e.stateManeger.hover.cellPos.col||a.row!==e.stateManeger.hover.cellPos.row)&&e.fireListeners(sf.MOUSEENTER_CELL,{col:a.col,row:a.row,cellRange:e.getCellRangeRelativeRect({col:a.col,row:a.row}),scaleRatio:e.canvas.getBoundingClientRect().width/e.canvas.offsetWidth,event:n.nativeEvent}),t.dealIconHover(s),t.dealTableHover(s),s.eventArgs&&e.hasListeners(sf.MOUSEMOVE_CELL)){let t,i;if(s.eventArgs?.target){const e=iV(s.eventArgs?.target);e&&(t=e.icon,i=e.position)}e.fireListeners(sf.MOUSEMOVE_CELL,{col:s.eventArgs.col,row:s.eventArgs.row,x:s.abstractPos.x,y:s.abstractPos.y,event:n.nativeEvent,targetIcon:t?{name:t.name,position:i,funcType:t.attribute.funcType}:void 0})}})),e.scenegraph.tableGroup.addEventListener("pointerout",(e=>{const i=oV(e),n=i?.eventArgs?.target;"table"===n?.role&&t.dealTableHover()})),e.scenegraph.tableGroup.addEventListener("pointerover",(t=>{const i=oV(t),n=i?.eventArgs?.target;if(e.hasListeners(sf.MOUSEOVER_CHART_SYMBOL)&&"symbol"===n.type){const i=t.composedPath().find((t=>"cell"===t.roll));if(i){const{col:n,row:r}=i,o={col:n,row:r,field:e.getHeaderField(n,r),value:e.getCellValue(n,r),dataValue:e.getCellOriginValue(n,r),cellHeaderPaths:e.internalProps.layoutMap.getCellHeaderPaths(n,r),title:e.getBodyColumnDefine(n,r).title,cellRange:e.getCellRelativeRect(n,r),event:t.nativeEvent,sparkline:{pointData:void 0},scaleRatio:e.canvas.getBoundingClientRect().width/e.canvas.offsetWidth};e.fireListeners(sf.MOUSEOVER_CHART_SYMBOL,o)}}})),e.scenegraph.tableGroup.addEventListener("pointerleave",(n=>{i.isResizeCol()||(i.updateInteractionState(Uc.default),i.updateCursor()),t.dealTableHover();const r=n.target;r&&!r.isDescendantsOf(e.scenegraph.tableGroup)&&e.fireListeners(sf.MOUSELEAVE_TABLE,{col:-1,row:-1,event:n.nativeEvent})})),e.scenegraph.tableGroup.addEventListener("pointerupoutside",(n=>{console.log("pointerupoutside"),i.isResizeCol()&&lV(e),i.updateInteractionState(Uc.default),t.dealTableHover(),t.dealTableSelect()})),e.scenegraph.tableGroup.addEventListener("pointerdown",(n=>{if(sV={x:n.x,y:n.y},0!==n.button)return;const r=oV(n);if(i.interactionState!==Uc.default)return;e.isPivotChart()&&"chart"!==r?.eventArgs?.target.type&&e.scenegraph.updateChartState(null),i.menu.isShow&&r.eventArgs&&r.eventArgs.target!==i.residentHoverIcon?.icon&&i.hideMenu();const o=r?.eventArgs?.target?.role?.startsWith("icon")?r.eventArgs.target:void 0;if(!o||!1===o.attribute.interactive)if("touch"===n.pointerType)t.touchEnd=!1,t.touchSetTimeout=setTimeout((()=>{t.isTouchdown=!1,t.touchMove=!0,(!t.touchEnd&&t.checkColumnResize(r,!0)||!t.touchEnd&&t.chechColumnMover(r)||t.dealTableSelect(r)&&!t.touchEnd)&&i.updateInteractionState(Uc.grabing)}),500);else{if(t.checkColumnResize(r,!0))return e.scenegraph.updateChartState(null),void i.updateInteractionState(Uc.grabing);if(t.chechColumnMover(r))return void i.updateInteractionState(Uc.grabing);t.dealTableSelect(r)&&i.updateInteractionState(Uc.grabing)}if(e.hasListeners(sf.MOUSEDOWN_CELL)){const t=oV(n);t.eventArgs&&e.fireListeners(sf.MOUSEDOWN_CELL,{col:t.eventArgs.col,row:t.eventArgs.row,event:n.nativeEvent})}})),e.scenegraph.tableGroup.addEventListener("pointerup",(t=>{if(0===t.button){if("grabing"===i.interactionState){if(i.updateInteractionState(Uc.default),i.isResizeCol())lV(e);else if(i.isMoveCol()){e.stateManeger.endMoveCol();const i=oV(t);i.eventArgs&&e.hasListeners(sf.CHANGE_HEADER_POSITION)&&e.fireListeners(sf.CHANGE_HEADER_POSITION,{target:{col:i.eventArgs.col,row:i.eventArgs.row},source:{col:e.stateManeger.columnMove.colSource,row:e.stateManeger.columnMove.colSource}})}else if(i.isSelecting()){e.stateManeger.endSelectCells();const i=oV(t);if(i.eventArgs&&e.hasListeners(sf.DRAG_SELECT_END)){const n={event:t.nativeEvent,cells:[],col:i.eventArgs.target.col,row:i.eventArgs.target.row,scaleRatio:e.canvas.getBoundingClientRect().width/e.canvas.offsetWidth};n.cells=e.getSelectedCellInfos(),e.fireListeners(sf.DRAG_SELECT_END,n)}}}else i.interactionState===Uc.scrolling&&i.updateInteractionState(Uc.default);if(e.hasListeners(sf.MOUSEUP_CELL)){const i=oV(t);i.eventArgs&&e.fireListeners(sf.MOUSEUP_CELL,{col:i.eventArgs.col,row:i.eventArgs.row,event:t.nativeEvent})}}})),e.scenegraph.tableGroup.addEventListener("rightdown",(t=>{const n=oV(t);if(n.eventArgs){i.triggerContextMenu(n.eventArgs.col,n.eventArgs.row,n.abstractPos.x,n.abstractPos.y);const{col:r,row:o}=n.eventArgs;if(e.hasListeners(sf.CONTEXTMENU_CELL)){const i=e.getCellInfo(r,o);let s,a;if(n.eventArgs?.target){const t=iV(n.eventArgs?.target);t&&(s=t.icon,a=t.position)}const l={...i,event:t.nativeEvent,cells:[],targetIcon:s?{name:s.name,position:a,funcType:s.attribute.funcType}:void 0};!function(t,e,i){for(let n=0;n<t.length;n++){const r=t[n];if(r.start.col<=e&&e<=r.end.col&&r.start.row<=i&&i<=r.end.row||r.end.col<=e&&e<=r.start.col&&r.end.row<=i&&i<=r.start.row)return!0}return!1}(e.stateManeger.select.ranges,r,o)?l.cells=[[i]]:l.cells=e.getSelectedCellInfos(),e.fireListeners(sf.CONTEXTMENU_CELL,l)}}})),e.scenegraph.tableGroup.addEventListener("click",(i=>{if(console.log("click",i.clone()),e.stateManeger.columnResize.resizing||e.stateManeger.columnMove.moving)return;const n=oV(i);if(t.dealIconClick(i,n),!n?.eventArgs)return;const{col:r,row:o}=n.eventArgs;if(e.hasListeners(sf.CLICK_CELL)){const t=e.getCellInfo(r,o);let s,a;if(n.eventArgs?.target){const t=iV(n.eventArgs?.target);t&&(s=t.icon,a=t.position)}const l={...t,event:i.nativeEvent,cells:[],targetIcon:s?{name:s.name,position:a,funcType:s.attribute.funcType}:void 0};e.fireListeners(sf.CLICK_CELL,l)}})),e.scenegraph.stage.addEventListener("click",(n=>{console.log("stage click");const r=n.target;r&&!r.isDescendantsOf(e.scenegraph.tableGroup)&&r!==e.scenegraph.tableGroup&&(console.log("pointerup outside table"),i.updateInteractionState(Uc.default),t.dealTableHover(),t.dealTableSelect(),i.updateCursor(),e.scenegraph.updateChartState(null))})),e.scenegraph.tableGroup.addEventListener("dblclick",(t=>{const i=oV(t),n=i.eventArgs.targetCell.globalAABBBounds,{col:r,row:o}=i.eventArgs,s=e.getCellValue(r,o);if(e.internalProps.focusControl.setFocusRect(new gf(n.x1+e.scrollLeft,n.y1+e.scrollTop,n.x2-n.x1,n.y2-n.y1),s),e.hasListeners(sf.DBLCLICK_CELL)){const n=e.getCellInfo(r,o);let s,a;if(i.eventArgs?.target){const t=iV(i.eventArgs?.target);t&&(s=t.icon,a=t.position)}const l={...n,event:t.nativeEvent,federatedEvent:t,cells:[],targetIcon:s?{name:s.name,position:a,funcType:s.attribute.funcType}:void 0};e.fireListeners(sf.DBLCLICK_CELL,l)}}))}(this),function(t){const e=t.table,i=e.stateManeger,n=e.internalProps.handler;n.on(e.getElement(),"blur",(e=>{console.log("blur"),t.dealTableHover()})),n.on(e.getElement(),"wheel",(t=>{hV(t,i)})),n.on(e.getElement(),"keydown",(i=>{if(e.keyboardOptions?.selectAllOnCtrlA&&"a"===i.key&&(i.ctrlKey||i.metaKey)&&(i.preventDefault(),t.deelTableSelectAll()),e.hasListeners(sf.KEYDOWN)){const t={keyCode:i.keyCode??i.which,code:i.code,event:i,cells:e.getSelectedCellInfos(),scaleRatio:e.canvas.getBoundingClientRect().width/e.canvas.offsetWidth};e.fireListeners(sf.KEYDOWN,t)}})),n.on(e.getElement(),"copy",(t=>{if(e.keyboardOptions?.copySelected){const i=e.getCopyValue();Uu(i)&&(t.preventDefault(),Qp?window.clipboardData.setData("Text",i):t.clipboardData.setData("text/plain",i))}})),n.on(e.getElement(),"contextmenu",(t=>{t.preventDefault()})),n.on(e.getContainer(),"resize",(()=>{e.resize()}))}(this),function(t){const e=t.table,i=e.stateManeger,n=e.scenegraph;n.component.vScrollBar.addEventListener("pointerover",(t=>{i.showVerticalScrollBar()})),n.component.hScrollBar.addEventListener("pointerover",(t=>{i.showHorizontalScrollBar()})),n.component.vScrollBar.addEventListener("pointerout",(t=>{i.interactionState!==Uc.scrolling&&i.hideVerticalScrollBar()})),n.component.hScrollBar.addEventListener("pointerout",(t=>{i.interactionState!==Uc.scrolling&&i.hideHorizontalScrollBar()})),n.component.vScrollBar._slider.addEventListener("pointerdown",(()=>{i.interactionState!==Uc.scrolling&&i.updateInteractionState(Uc.scrolling)})),n.component.vScrollBar.addEventListener("pointerup",(()=>{i.interactionState===Uc.scrolling&&i.updateInteractionState(Uc.default)})),n.component.vScrollBar.addEventListener("pointerupoutside",(()=>{i.interactionState===Uc.scrolling&&i.updateInteractionState(Uc.default)})),n.component.hScrollBar._slider.addEventListener("pointerdown",(()=>{i.interactionState!==Uc.scrolling&&i.updateInteractionState(Uc.scrolling)})),n.component.hScrollBar.addEventListener("pointerup",(()=>{i.interactionState===Uc.scrolling&&i.updateInteractionState(Uc.default)})),n.component.hScrollBar.addEventListener("pointerupoutside",(()=>{i.interactionState===Uc.scrolling&&i.updateInteractionState(Uc.default)}));const r=gu(i.updateVerticalScrollBar,20),o=gu(i.updateHorizontalScrollBar,20);n.component.vScrollBar.addEventListener("scroll",(t=>{i.interactionState!==Uc.scrolling&&i.updateInteractionState(Uc.scrolling);const e=t.detail.value[0]/(1-t.detail.value[1]+t.detail.value[0]);r(e,t)})),n.component.hScrollBar.addEventListener("scroll",(t=>{i.interactionState!==Uc.scrolling&&i.updateInteractionState(Uc.scrolling);const e=t.detail.value[0]/(1-t.detail.value[1]+t.detail.value[0]);o(e)}))}(this),dV(this)}bindSelfEvent(){const t=this.table.stateManeger;var e;this.table.on(sf.ICON_CLICK,(e=>{const{col:i,row:n,x:r,y:o,funcType:s,icon:a}=e;var l;s===Jc.dropDown?t.triggerDropDownMenu(i,n,r,o):s===Jc.sort?t.triggerSort(i,n,a):s===Jc.frozen?t.triggerFreeze(i,n,a):s===Jc.drillDown?(l=this.table).fireListeners(QG.DRILLMENU_CLICK,l.stateManeger.drill):s!==Jc.collapse&&s!==Jc.expand||this.table.toggleHierarchyState(i,n)})),this.table.on(sf.DROPDOWNMENU_CLICK,(()=>{t.hideMenu()})),function(t){const e=t.internalProps.layoutMap.headerObjects,i=t.internalProps.layoutMap.columnObjects;for(let t=0;t<e.length;t++){const i=e[t];if(i&&i.style?.textStick)return console.log("checkHaveTextStick",!0),!0}for(let t=0;t<i.length;t++){const e=i[t];if(e&&e.style?.textStick)return console.log("checkHaveTextStick",!0),!0}return console.log("checkHaveTextStick",!1),!1}(this.table)&&this.table.on(sf.SCROLL,(t=>{TG(this.table)})),e=this.table,"browser"===hf.mode&&e.on(sf.CLICK_CELL,(t=>{const{col:i,row:n}=t;let r;r=e.internalProps.layoutMap.isHeader(i,n)?e.isPivotTable()?e._getHeaderLayoutMap(i,n).headerType:e.getHeaderDefine(i,n).headerType:e.getBodyColumnType(i,n);const o=e.isHeader(i,n)?e.getHeaderDefine(i,n):e.getBodyColumnDefine(i,n),s=e.getCellValue(i,n),a=e.getCellOriginValue(i,n);if("link"===o.cellType){if(!1===o.linkJump)return;const t=o.templateLink,r=!1!==o.linkDetect;let l;if(t){const r=e.getCellOriginRecord(i,n),o=Object.assign({__value:s,__dataValue:a},r),h=/\{\s*(\S+?)\s*\}/g;l=t.replace(h,((t,e)=>o[e]))}else if(r){if(!_f.test(s))return;l=s}else l=s;window.open(l)}else if("image"===r){const t=document.createElement("div");t.style.width="100%",t.style.height="100%",t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.backgroundColor="rgba(30, 30, 30, 0.4)",t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center",t.style.overflow="hidden",t.style.zIndex="9999",t.addEventListener("click",(e=>{e.target===t&&document.body.removeChild(t)}));const e=new Image;e.src=s,e.style.maxWidth="80%",e.style.maxHeight="80%",t.appendChild(e),document.body.appendChild(t)}else if("video"===r){const t=document.createElement("div");t.style.width="100%",t.style.height="100%",t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.backgroundColor="rgba(30, 30, 30, 0.4)",t.style.display="flex",t.style.justifyContent="center",t.style.alignItems="center",t.style.overflow="hidden",t.style.zIndex="9999",t.addEventListener("click",(e=>{e.target===t&&document.body.removeChild(t)}));const e=document.createElement("video");e.src=s,e.style.maxWidth="80%",e.style.maxHeight="80%",e.setAttribute("preload","auto"),e.setAttribute("controls","true"),t.appendChild(e),document.body.appendChild(t)}})),this.table.on(sf.DBLCLICK_CELL,(t=>{if(t.federatedEvent){const e=oV(t.federatedEvent),i=this.table.scenegraph.getResizeColAt(e.abstractPos.x,e.abstractPos.y,e.eventArgs?.targetCell);this.table._canResizeColumn(i.col,i.row)&&i.col>=0&&this.table.scenegraph.updateAutoColWidth(i.col)}})),this.table.isPivotTable()&&function(t){const e=t.internalProps.layoutMap.rowsDefine,i=t.internalProps.layoutMap.columnsDefine;for(let t=0;t<e.length;t++){const i=e[t];if("string"!=typeof i&&(i.drillDown||i.drillUp))return!0}for(let t=0;t<i.length;t++){const e=i[t];if("string"!=typeof e&&(e.drillDown||e.drillUp))return!0}return!1}(this.table)&&function(t){t.on(sf.MOUSEENTER_CELL,(e=>{const{col:i,row:n}=e;if(-1===i||-1===n)return;const r=t.internalProps.layoutMap.getHeaderDimension(i,n);r?.drillDown||r?.drillUp?t.stateManeger.updateDrillState(r.dimensionKey,r.title,r.drillDown,r.drillUp,i,n):t.stateManeger.updateDrillState(void 0,void 0,!1,!1,-1,-1)})),t.on(sf.MOUSELEAVE_TABLE,(e=>{t.stateManeger.updateDrillState(void 0,void 0,!1,!1,-1,-1)}))}(this.table),function(t){let e=!1;e=t.isPivotTable()?t.internalProps.layoutMap.indicatorsDefine.some((t=>"string"!=typeof t&&"sparkline"===t.cellType)):t.internalProps.layoutMap.columnObjects.some((t=>"sparkline"===t.cellType));e&&(t.on(sf.MOUSEMOVE_CELL,(e=>{const{col:i,row:n,x:r,y:o}=e;"sparkline"!==t.getBodyColumnType(i,n)&&t.stateManeger.updateSparklineHoverPose(-1,-1,0,0),t.stateManeger.updateSparklineHoverPose(i,n,r,o)})),t.on(sf.MOUSELEAVE_TABLE,(e=>{t.stateManeger.updateSparklineHoverPose(-1,-1,0,0)})))}(this.table),function(t){t.isPivotChart()&&t.scenegraph.tableGroup.addEventListener("click",(e=>{if(!t.stateManeger.columnMove.moving&&!t.stateManeger.columnResize.resizing)if("axis-label"===e.target.name){const i=oV(e),{col:n,row:r}=i.eventArgs,o=t.internalProps.layoutMap;let s,a;o.indicatorsAsCol?(s=o.getDimensionKeyInChartSpec(o.rowHeaderLevelCount,r)[0],a=o.getCellHeaderPaths(o.rowHeaderLevelCount-2,r).rowHeaderPaths):(s=o.getDimensionKeyInChartSpec(n,o.columnHeaderLevelCount)[0],a=o.getCellHeaderPaths(n,o.columnHeaderLevelCount-1).colHeaderPaths);const l=a.map((t=>({key:t.dimensionKey,value:t.value}))).filter((t=>t.key));if(l.push({key:s,value:e.target.attribute.text}),t._selectedDimensionInChart.length&&function(t,e){if(t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(t[i].key!==e[i].key||t[i].value!==e[i].value)return!1;return!0}(t._selectedDimensionInChart,l))return;t._selectedDimensionInChart=l,o.updateDataStateToChartInstance(),OG(t.scenegraph),t.scenegraph.updateNextFrame()}else t._selectedDimensionInChart?.length&&(t._selectedDimensionInChart.length=0,t.internalProps.layoutMap.updateDataStateToChartInstance(),OG(t.scenegraph),t.scenegraph.updateNextFrame())}))}(this.table),function(t){t.isPivotChart()&&(t.on(sf.MOUSEENTER_CELL,(e=>{t.scenegraph.getCell(e.col,e.row).forEachChildren((i=>{if("axis"===i.name){const i=fV(e.col,e.row,t.internalProps.layoutMap);e.axisPosition=i,t.fireListeners(sf.MOUSEENTER_AXIS,e)}}))})),t.on(sf.MOUSELEAVE_CELL,(e=>{t.scenegraph.getCell(e.col,e.row).forEachChildren((i=>{if("axis"===i.name){const i=fV(e.col,e.row,t.internalProps.layoutMap);e.axisPosition=i,t.fireListeners(sf.MOUSELEAVE_AXIS,e)}}))})))}(this.table)}dealTableHover(t){if(!t)return void this.table.stateManeger.updateHoverPos(-1,-1);const{eventArgs:e}=t;e?this.table.stateManeger.updateHoverPos(e.col,e.row):this.table.stateManeger.updateHoverPos(-1,-1)}dealIconHover(t){const{eventArgs:e}=t;e?this.table.stateManeger.updateHoverIcon(e.col,e.row,e.target,e.targetCell,e.event):this.table.stateManeger.updateHoverIcon(-1,-1,void 0,void 0)}dealMenuHover(t){}dealTableSelect(t){if(!t)return this.table.stateManeger.updateSelectPos(-1,-1),!1;const{eventArgs:e}=t;return!!e&&(this.table.isPivotChart()||"chart"===t?.eventArgs?.target.type||this.table.stateManeger.updateHoverPos(-1,-1),!this.table.isPivotChart()||"axis-label"!==t?.eventArgs?.target.name&&"chart"!==t?.eventArgs?.target.type?(this.table.stateManeger.updateSelectPos(e.col,e.row,e.event.shiftKey,e.event.ctrlKey||e.event.metaKey),!0):(this.table.stateManeger.updateSelectPos(-1,-1),!1))}deelTableSelectAll(){this.table.stateManeger.updateSelectPos(-1,-1,!1,!1,!0)}dealMenuSelect(t){}checkColumnResize(t,e){const{eventArgs:i}=t;if(i){const n=this.table.scenegraph.getResizeColAt(t.abstractPos.x,t.abstractPos.y,i.targetCell);if(this.table._canResizeColumn(n.col,n.row)&&n.col>=0)return e&&this.table.stateManeger.startResizeCol(n.col,t.abstractPos.x,t.abstractPos.y,n.rightFrozen),!0}return!1}dealColumnResize(t,e){this.table.stateManeger.updateResizeCol(t,e)}chechColumnMover(t){const{eventArgs:e}=t;return!!(e&&this.table.isHeader(e.col,e.row)&&function(t,e,i){for(let n=0;n<i.length;n++)if(qp(i[n],t,e))return!0;return!1}(e.col,e.row,this.table.stateManeger.select.ranges)&&this.table._canDragHeaderPosition(e.col,e.row))&&(this.table.stateManeger.startMoveCol(e.col,e.row,t.abstractPos.x,t.abstractPos.y),!0)}dealColumnMover(t){const{eventArgs:e}=t;this.table.stateManeger.updateMoveCol(e.col,e.row,t.abstractPos.x,t.abstractPos.y)}startColumnResize(t){}dealIconClick(t,e){const{eventArgs:i}=e,{target:n,event:r,col:o,row:s}=i||{target:t.target,event:t,col:-1,row:-1},a=n;if(a.role&&a.role.startsWith("icon-"))return this.table.fireListeners(sf.ICON_CLICK,{name:a.name,x:(a.globalAABBBounds.x1+a.globalAABBBounds.x2)/2,y:a.globalAABBBounds.y2,col:o,row:s,funcType:a.attribute.funcType,icon:a}),!0;if(n instanceof dA){const t=n.pickIcon(r.global);if(t)return this.table.fireListeners(sf.ICON_CLICK,{name:t.attribute.id,x:t.globalX+t.globalAABBBounds.width()/2,y:t.globalY+t.AABBBounds.height(),col:o,row:s,funcType:t.attribute.funcType,icon:t}),!0}return!1}}const mV=t=>{const e=t.value;return Number(e)>80?"#20a8d8":Number(e)>50?"#4dbd74":Number(e)>20?"#ffc107":"#f86c6b"};class yV extends Ru{_showBar;_barColor;_barBgColor;_barPositiveColor;_barNegativeColor;_barAxisColor;_barHeight;_barBottom;_barPadding;_showBarMark;_barMarkPositiveColor;_barMarkNegativeColor;_barMarkWidth;_barMarkPosition;_barRightToLeft;static get DEFAULT(){return aV||(aV=new yV)}constructor(t={},e={}){super(t,e),this._showBar=t.showBar??!0,this._barColor=t.barColor??mV,this._barPositiveColor=t.barPositiveColor??"#4dbd74",this._barNegativeColor=t.barNegativeColor??"#f86c6b",this._barAxisColor=t.barAxisColor??"black",this._barBgColor=t.barBgColor,this._barHeight=t.barHeight??3,this._barHeight=t.barHeight??3,this._barBottom=t.barBottom??0,this._barPadding=t.barPadding??[1,1,1,1],this._showBarMark=t.showBarMark??!1,this._barMarkPositiveColor=t.barMarkPositiveColor??"#4dbd74",this._barMarkNegativeColor=t.barMarkNegativeColor??"#f86c6b",this._barMarkWidth=t.barMarkWidth??2,this._barMarkPosition=t.barMarkPosition??"right",this._barRightToLeft=t.barRightToLeft??!1}get showBar(){return this._showBar}set showBar(t){this._showBar=t}get barColor(){return this._barColor}set barColor(t){this._barColor=t}get barBgColor(){return this._barBgColor}set barBgColor(t){this._barBgColor=t}get barHeight(){return this._barHeight}set barHeight(t){this._barHeight=t}get barBottom(){return this._barBottom}set barBottom(t){this._barBottom=t}get barPositiveColor(){return this._barPositiveColor}set barPositiveColor(t){this._barPositiveColor=t}get barNegativeColor(){return this._barNegativeColor}set barNegativeColor(t){this._barNegativeColor=t}get barAxisColor(){return this._barAxisColor}set barAxisColor(t){this._barAxisColor=t}get barPadding(){return this._barPadding}set barPadding(t){this._barPadding=t}get showBarMark(){return this._showBarMark}set showBarMark(t){this._showBarMark=t}get barMarkPositiveColor(){return this._barMarkPositiveColor}set barMarkPositiveColor(t){this._barMarkPositiveColor=t}get barMarkNegativeColor(){return this._barMarkNegativeColor}set barMarkNegativeColor(t){this._barMarkNegativeColor=t}get barMarkWidth(){return this._barMarkWidth}set barMarkWidth(t){this._barMarkWidth=t}get barMarkPosition(){return this._barMarkPosition}set barMarkPosition(t){this._barMarkPosition=t}get barRightToLeft(){return this._barRightToLeft}set barRightToLeft(t){this._barRightToLeft=t}clone(){return new yV(this,null)}}const bV=["type","content","font","color","width","height","marginRight","marginLeft","src","svg","name","path","positionType","tooltip","hover","cursor","shape","interactive"];class vV{expandIcon;collapseIcon;_table;constructor(t){this._table=t;const e=yj();this.expandIcon=e[Qc.expandIconName],this.collapseIcon=e[Qc.collapseIconName]}getIcons(t,e,i,n,r){const o=[],{icon:s}=this._table.getBodyColumnDefine(t,e);if(s){let r;if("function"==typeof s){r=s({col:t,row:e,value:i,dataValue:n,table:this._table})}else r=s;const a=yj(),l=t=>{let e;e="string"==typeof t?a[t]:t,e&&o.push(e)};Array.isArray(r)?r.forEach(((t,e)=>{l(t)})):l(r)}const a=this.getHierarchyIcon(t,e);return a&&o.push(a),r&&o.forEach(((i,n)=>{(i.content||i.src)&&(o[n]=this.getCellIconFromRecordValue(i,t,e))})),o}getStyleClass(t){switch(t){case"text":case"link":return Eu;case"image":case"video":return Pu;case"chart":case"sparkline":return Ru;case"progressbar":return yV}}getCellIconFromRecordValue(t,e,i){if(Array.isArray(t))return t.map((t=>this.getCellIconFromRecordValue(t,e,i)));if(!tf.isObject(t)||"function"==typeof t)return this._table.getFieldData(t,e,i);const n={},r=t;return bV.forEach((t=>{if(void 0!==r[t]){const o=this._table.getFieldData(r[t],e,i);null!=o?n[t]=o:this._table._hasField(r[t],e,i)||(n[t]=r[t])}})),n}getHierarchyIcon(t,e){const i=this._table.getHierarchyState(t,e);return i===Xc.expand?this.expandIcon:i===Xc.collapse?this.collapseIcon:void 0}}function wV(t,e){const i=document.createElement(t);return e&&i.classList.add(...e),i}!function(){const t=document.createElement("style");t.id="vtable-menu-styleSheet",t.textContent="\n@keyframes vtable__menu-element--shown-animation {\n\t0% {\n\t\topacity: 0;\n\t}\n\t100% {\n\t\topacity: 1;\n\t}\n}\n.vtable__menu-element {\n\tposition: absolute;\n\tbox-sizing: border-box;\n\tborder-radius: 4px;\n\tbackground-color: #fff;\n\tpadding: 6px 0;\n\t/* pointer-events: none; */\n\tuser-select: none;\n\tcolor: #000;\n\tmax-width: 300px;\n\tz-index: 99999;\n\tborder: #CCC 0.5px solid;\n\tcursor: default;\n\twidth: max-content;\n\tbox-shadow: 0px 8px 16px rgba(27, 31, 35, 0.12);\n}\n.vtable__menu-element--hidden {\n\topacity: 0;\n\t/* transform: translate(-50%, -50%); */\n\ttransition: opacity 75ms linear;\n\tz-index: -9999;\n}\n.vtable__menu-element--shown {\n\topacity: 1;\n\t/* transform: translate(-50%, -50%); */\n\tanimation: vtable__menu-element--shown-animation 150ms ease-out;\n}\n.vtable__menu-element__content {\n\tfont-family: Roboto;\n\tfont-size: 12px;\n\toverflow: hidden;\n\tdisplay: inline-block;\n\t/* height: 100%; */\n\tline-height: 30px;\n}\n.vtable__menu-element__item {\n\theight: 32px;\n\tpadding: 0px 12px;\n\tcursor: pointer;\n\tposition: relative;\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: flex-start;\n}\n.vtable__menu-element__item:hover {\n\tbackground-color: rgba(27, 31, 35, 0.06);\n}\n.vtable__menu-element__icon{\n\t/* vertical-align: top; */\n\tdisplay: flex;\n\t/* line-height: 30px; */\n\tmargin-right: 6px;\n}\n.vtable__menu-element__no-event {\n\tpointer-events: none;\n}\n.vtable__menu-element--select {\n\tcolor: #2E68CF;\n}.vtable__menu-element--normal {\n\tcolor: rgba(20, 20, 20, 0.9);;\n}\n.vtable__menu-element__split {\n\theight: 0px;\n\tborder: 1px solid rgb(209, 213, 218);\n\tmargin: 5px 0;\n}\n.vtable__menu-element__title {\n\tcolor: rgb(149, 149, 149);\n}\n.vtable__menu-element__arrow {\n\tposition: absolute;\n\tright: 3px;\n\tfont-weight: bold;\n\tmargin-top: 1px;\n}\n.vtable__menu-element__item-text {\n\tmargin-right: 15px;\n}\n",document.body.appendChild(t)}();const CV="vtable__menu-element",xV=`${CV}__item`,_V=`${CV}__content`,SV=`${CV}--hidden`,AV=`${CV}--shown`,TV=`${CV}--normal`,BV=`${CV}--select`,MV=`${CV}__icon`,RV=`${CV}__split`,PV=`${CV}__title`,EV=`${CV}__arrow`,HV=`${CV}__no-event`,LV=`${CV}__item-text`;function kV(){return wV("div",[CV,SV])}function IV(t,e,i,n,r,o){const s=t.getCellRange(n,r);for(let n=0;n<e.length;n++){const r=e[n];let{col:o,row:a}=r;const{field:l,menuKey:h}=r;if("number"!=typeof o||"number"!=typeof a)if(t.isPivotTable()&&(Array.isArray(l),1)){const e=t.internalProps.layoutMap.getPivotCellAdress(l);if(!e)continue;o=e.col,a=e.row}else{const e=t.internalProps.layoutMap.getHeaderCellAddressByField(l);if(!e)continue;o=e.col,a=e.row}if(bu(o)&&bu(a)&&qp(s,o,a)&&i===h)return!0}return!1}class OV{_handler;_rootElement;_secondElement;_menuInstanceInfo;_showChildrenIndex;_mouseEnterSecondElement;constructor(t){this._handler=new df,this._rootElement=kV(),this._secondElement=kV(),this._secondElement.sub=!0,this._showChildrenIndex=-1,this._rootElement.addEventListener("wheel",(t=>{t.stopPropagation()})),this._rootElement?.addEventListener("mousedown",(t=>{t.stopPropagation(),t.preventDefault()})),this._rootElement?.addEventListener("touchend",(e=>{if(e.stopPropagation(),e.preventDefault(),this._rootElement.classList.contains(SV))return;const{col:i,row:n,dropDownIndex:r,menuKey:o,text:s,hasChildren:a}=e.target;if("number"!=typeof r||a)return void e.stopPropagation();const l=t.isPivotTable()?t.internalProps.layoutMap.getPivotDimensionInfo(i,n):t.getHeaderField(i,n),h=t._dropDownMenuIsHighlight(i,n,r);t.fireListeners(sf.DROPDOWNMENU_CLICK,{col:i,row:n,field:l,menuKey:o,text:s,highlight:h,cellLocation:t.getCellLocation(i,n)}),t.fireListeners(sf.DROPDOWN_MENU_CLEAR,null),t.fireListeners(sf.HIDE_MENU,null),e.stopPropagation()})),this._rootElement?.addEventListener("click",(e=>{if(e.stopPropagation(),e.preventDefault(),this._rootElement.classList.contains(SV))return;const{col:i,row:n,dropDownIndex:r,menuKey:o,text:s,hasChildren:a}=e.target;if("number"!=typeof r||a)return void e.stopPropagation();const l=t.isPivotTable()?t.internalProps.layoutMap.getPivotDimensionInfo(i,n):t.getHeaderField(i,n),h=t._dropDownMenuIsHighlight(i,n,r);t.fireListeners(sf.DROPDOWNMENU_CLICK,{col:i,row:n,field:l,menuKey:o,text:s,highlight:h,cellLocation:t.getCellLocation(i,n)}),t.fireListeners(sf.DROPDOWN_MENU_CLEAR,null),t.fireListeners(sf.HIDE_MENU,null),e.stopPropagation()})),this._rootElement?.addEventListener("mousemove",(e=>{if(this._rootElement.classList.contains(SV))return;e.stopPropagation();const{hasChildren:i,dropDownIndex:n,col:r,row:o,sub:s}=e.target;if(i){this._showChildrenIndex=n;const i=this._secondElement;i?.classList.remove(SV),i?.classList.add(AV),i.innerHTML="";const s=this._menuInstanceInfo.content[n]?.children;for(let e=0;e<s.length;e++){const n=s[e],a=DV(n,!!t.stateManeger.menu.dropDownMenuHighlight&&IV(t,t.stateManeger.menu.dropDownMenuHighlight,"object"==typeof n?n?.menuKey||n?.text:n,r,o));a.col=r,a.row=o,a.dropDownIndex=e,"string"==typeof n?(a.text=n,a.menuKey=n):"object"==typeof n&&(a.text=n.text,a.menuKey=n.menuKey||n.text),a.sub=!0,a.sub=!0,i.appendChild(a)}const a=e.target.getBoundingClientRect();this._bindSecondElement(t,r,o,a.right,a.top)}else if(i&&this._showChildrenIndex===n){const t=this._secondElement;t?.classList.remove(SV),t?.classList.add(AV)}else!s&&this._secondElement?.classList.contains(AV)&&setTimeout((()=>{if(!0!==this._mouseEnterSecondElement){this._showChildrenIndex=-1;const t=this._secondElement;t?.classList.remove(AV),t?.classList.add(SV)}}),300)})),this._secondElement?.addEventListener("wheel",(t=>{t.stopPropagation()})),this._secondElement?.addEventListener("mousemove",(t=>{this._rootElement.classList.contains(SV)||t.stopPropagation()})),this._secondElement?.addEventListener("mouseenter",(t=>{this._mouseEnterSecondElement=!0})),this._secondElement?.addEventListener("mouseleave",(t=>{this._mouseEnterSecondElement=!1})),this._secondElement?.addEventListener("mousedown",(t=>{t.stopPropagation(),t.preventDefault()})),this._secondElement?.addEventListener("click",(e=>{if(e.stopPropagation(),e.preventDefault(),this._secondElement.classList.contains(SV))return;const{col:i,row:n,dropDownIndex:r,menuKey:o,text:s,hasChildren:a}=e.target;if("number"!=typeof r||a)return void e.stopPropagation();const l=t.isPivotTable()?t.internalProps.layoutMap.getPivotDimensionInfo(i,n):t.getHeaderField(i,n);let h=!1;this._menuInstanceInfo.content.forEach(((e,r)=>{if("object"==typeof e&&e.children&&e.children.length)for(let r=0;r<e.children.length;r++){const s=e.children[r];if(IV(t,t.stateManeger.menu.dropDownMenuHighlight,"object"==typeof s?s?.menuKey:s,i,n)&&o===("object"==typeof s?s?.menuKey:s))return void(h=!0)}})),t.fireListeners(sf.DROPDOWNMENU_CLICK,{col:i,row:n,field:l,cellHeaderPaths:t.isPivotTable()?t.getCellHeaderPaths(i,n):void 0,menuKey:o,text:s,highlight:h,cellLocation:t.getCellLocation(i,n)}),t.fireListeners(sf.DROPDOWN_MENU_CLEAR,null),t.fireListeners(sf.HIDE_MENU,null),e.stopPropagation()}))}get rootElement(){return this._rootElement}release(){this.unbindFromCell();const t=this._rootElement;t?.parentElement&&t.parentElement.removeChild(t),this._handler.release(),delete this._rootElement}bindToCell(t,e,i,n){const r=this._rootElement,o=this._secondElement;if(this._menuInstanceInfo=n,r?.classList.remove(AV),r?.classList.add(SV),o?.classList.remove(AV),o?.classList.add(SV),this._canBindToCell(t,e,i)){if(r.innerHTML="",Array.isArray(n.content)){const o=n.content;for(let n=0;n<o?.length;n++){const s=o[n];let a=!!t.stateManeger.menu.dropDownMenuHighlight&&IV(t,t.stateManeger.menu.dropDownMenuHighlight,"object"==typeof s?s?.menuKey||s?.text:s,e,i);if(t.stateManeger.menu.dropDownMenuHighlight&&"object"==typeof s&&Array.isArray(s.children)&&s.children.length)for(let n=0;n<s.children.length;n++){const r=s.children[n];if(IV(t,t.stateManeger.menu.dropDownMenuHighlight,"object"==typeof r?r?.menuKey||r?.text:r,e,i)){a=!0;break}}const l=DV(s,a);l.col=e,l.row=i,l.dropDownIndex=n,"string"==typeof s?(l.text=s,l.menuKey=s):"object"==typeof s&&(l.text=s.text,l.menuKey=s.menuKey||s.text,s.children?.length&&(l.hasChildren=!0)),r.appendChild(l)}}if(this._bindToCell(t,e,i,n.position,n.referencePosition))return r?.classList.add(AV),r?.classList.remove(SV),!0}else this.unbindFromCell();return!1}unbindFromCell(){const t=this._rootElement,e=this._secondElement;this._menuInstanceInfo=void 0,t?.parentElement&&(t.classList.remove(AV),t.classList.add(SV)),e?.parentElement&&(e.classList.remove(AV),e.classList.add(SV))}_canBindToCell(t,e,i){const n=t.getCellRangeRelativeRect({col:e,row:i}),r=t.getElement(),{top:o,bottom:s,left:a,right:l}=n,{frozenRowCount:h,frozenColCount:c}=t;if(i>=h&&h>0){if(s<t.getCellRangeRelativeRect({col:e,row:h-1}).bottom)return!1}else if(s<0)return!1;if(e>=c&&c>0){if(l<t.getCellRangeRelativeRect({col:c-1,row:i}).right)return!1}else if(l<0)return!1;const{offsetHeight:u,offsetWidth:d}=r;return!(u<o)&&!(d<a)}_bindToCell(t,e,i,n,r){const o=this._rootElement,s=t.getElement(),{width:a,height:l}=t.internalProps.element.getBoundingClientRect();if(o){o.parentElement!==s&&s.appendChild(o),o.style.left="0px";const e=.8*a;o.style.maxWidth=`${e}px`;const i=o.clientWidth,h=o.clientHeight;let c,u;return n?(c=n.x+t.tableX,u=n.y+t.tableY):r&&(c=r.rect.right-i+t.tableX,u=r.rect.bottom+t.tableY),u+h>l&&(u=l-h,c+=i-2),u<0&&(u/=2),o.style.top=`${u}px`,c<0?c=0:c+i>a&&(c=a-i),o.style.left=`${c}px`,!0}return!1}_bindSecondElement(t,e,i,n,r){const o=this._secondElement,s=this._rootElement,a=t.getElement(),{width:l,left:h,top:c}=t.internalProps.element.getBoundingClientRect(),{x:u,y:d,width:p}=s.getBoundingClientRect();if(o){o.parentElement!==a&&a.appendChild(o),o.style.left="0px";const t=.8*l;o.style.maxWidth=`${t}px`;const e=o.clientWidth,i=r-4-c,s=n-h;o.style.top=`${i}px`;let u=s;return u+e>l?u=u-e-p:u+=4,o.style.left=`${u}px`,!0}return!1}pointInMenuElement(t,e){const i=this._rootElement,{x:n,y:r,width:o,height:s}=i.getBoundingClientRect();if(t>n-5&&t<n+o+5&&e>r-5&&e<r+s+5)return!0;if(this._secondElement){const{x:n,y:r,width:o,height:s}=i.getBoundingClientRect();if(t>n-5&&t<n+o+5&&e>r-5&&e<r+s+5)return!0}return!1}}function DV(t,e){const i=wV("div",[xV,e?BV:TV]);if("string"==typeof t){const e=wV("span",[_V,HV,LV]);e.innerHTML=t,i.appendChild(e)}else if("object"==typeof t){const n=t.type??"item";if("split"===n)return i?.classList.add(RV),i;if(t?.icon?.svg)if(_f.test(t.icon.svg)){const e=new Image;t.icon.width?e.style.width=t.icon.width.toString()+"px":e.style.width="16px",t.icon.height?e.style.height=t.icon.height.toString()+"px":e.style.height="16px",e.src=t.icon.svg,i.appendChild(e)}else{const n=wV("span",[MV,HV]);n.innerHTML=e&&t.selectedIcon&&t.selectedIcon.svg?t.selectedIcon.svg:t.icon.svg,t.icon.width&&n.children[0].setAttribute("width",t.icon.width.toString()),t.icon.height&&n.children[0].setAttribute("height",t.icon.height.toString()),i.appendChild(n)}const r=wV("span",[_V,HV,LV]);if(r.innerHTML=t.text,i.appendChild(r),"title"===n)i?.classList.add(HV,PV);else if(t?.children?.length){const t=wV("span",[_V,HV,EV]);t.innerHTML=e?'<svg width="8" height="12" viewBox="0 0 10 17" fill="none" xmlns="http://www.w3.org/2000/svg" style="vertical-align: baseline"><path d="M1.78186 16.7729L0.300378 15.2915L6.8189 8.77295L0.300377 2.25443L1.78186 0.77295L9.78186 8.77295L1.78186 16.7729Z" fill="#2E68CF" fill-opacity="0.65"></path></svg>':'<svg width="8" height="12" viewBox="0 0 10 17" fill="none" xmlns="http://www.w3.org/2000/svg" style="vertical-align: baseline"><path d="M1.78186 16.7729L0.300378 15.2915L6.8189 8.77295L0.300377 2.25443L1.78186 0.77295L9.78186 8.77295L1.78186 16.7729Z" fill="#141414" fill-opacity="0.65"></path></svg>',i.appendChild(t)}}return i}let FV;class zV extends ku{static get DEFAULT(){return FV||(FV=new zV)}constructor(t={},e={}){super(t,e),this.textAlign=(t.textAlign??e?.textAlign)||"center"}clone(){return new zV(this)}}class WV{normalIcon;upIcon;downIcon;freezeIcon;frozenIcon;frozenCurrentIcon;dropDownAbsoluteIcon;expandIcon;collapseIcon;_table;constructor(t){this._table=t;const e=yj();this.freezeIcon=e[Qc.freezeIconName],this.frozenIcon=e[Qc.frozenIconName],this.frozenCurrentIcon=e[Qc.frozenCurrentIconName],this.normalIcon=e[Qc.normalIconName],this.upIcon=e[Qc.upwardIconName],this.downIcon=e[Qc.downwardIconName],this.dropDownAbsoluteIcon=e[Qc.dropdownIconName],this.expandIcon=e[Qc.expandIconName],this.collapseIcon=e[Qc.collapseIconName]}getIcons(t,e){const i=[];if(this._table.isPivotTable()){const{showSort:n}=this._table.internalProps.layoutMap.getHeader(t,e);if(n){const n=this._table.getPivotSortState(t,e),r="asc"===n?this.downIcon:"desc"===n?this.upIcon:this.normalIcon;r&&i.push(r)}}else{const n=this._table.sortState;let r;r=void 0;const o=this._table.getCellRange(t,e);if(n)if(Array.isArray(n))for(let t=0;t<n.length;t++){const e=n[t],i=this._table._getHeaderCellBySortState(e);if(i&&qp(o,i.col,i.row)){({order:r}=e);break}}else{const t=this._table._getHeaderCellBySortState(n);t&&qp(o,t.col,t.row)&&({order:r}=n)}const s=this.getSortIcon(r,this._table,t,e);s&&i.push(s)}if(this._table.showFrozenIcon&&t<this._table.allowFrozenColCount){const n=this.getFrozenIcon(t,e);n&&i.push(n)}if(this.checkDropDownIcon(this._table,t,e)){const t=this.dropDownAbsoluteIcon;i.push(t)}const n=this.getDropDownStateIcons(this._table,t,e);n.length&&i.push(...n);const{headerIcon:r}=this._table._getHeaderLayoutMap(t,e),o=this.getHierarchyIcon(t,e);if(o&&i.push(o),r){let n;if("function"==typeof r){n=r({col:t,row:e,value:this._table.getCellValue(t,e),dataValue:this._table.getCellOriginValue(t,e),table:this._table})}else n=r;const o=yj(),s=t=>{let e;e="string"==typeof t?o[t]:t,e&&i.push(e)};Array.isArray(n)?n.forEach(((t,e)=>{s(t)})):s(n)}return i}getFrozenIcon(t,e){if(this._table.isPivotTable()||this._table.transpose)return null;if(this._table.rightFrozenColCount&&t>=this._table.colCount-this._table.rightFrozenColCount)return null;const i=this._table.getHeaderDefine(t,e);if(i.columns&&i.columns.length>0)return null;let n=this.freezeIcon;return this._table.options.frozenColCount-1>t?n=this.frozenIcon:this._table.options.frozenColCount-1===t&&(n=this.frozenCurrentIcon),n}getSortIcon(t,e,i,n){const r="asc"===t?this.downIcon:"desc"===t?this.upIcon:this.normalIcon,o=e.getHeaderDefine(i,n);return!o||!o.showSort&&!o.sort||o.columns&&o.columns.length>0?null:r}getDropDownStateIcons(t,e,i){const n=t.getHeaderDefine(e,i),r=t._getHeaderLayoutMap(e,i),{dropDownMenu:o}=r,s=[];if(Array.isArray(o)&&o.length||Array.isArray(t.globalDropDownMenu)&&t.globalDropDownMenu.length&&!n?.columns?.length){const n=o||t.globalDropDownMenu;let r=-1,a=-1;for(let o=0;o<n.length;o++){const s=n[o];if("object"==typeof s&&s.children&&s.children.length)for(let n=0;n<s.children.length;n++){const l=s.children[n];if(t.stateManeger.menu?.dropDownMenuHighlight&&IV(t,t.stateManeger.menu?.dropDownMenuHighlight,"object"==typeof l?l?.menuKey:l,e,i)){r=o,a=n;break}}if(t._dropDownMenuIsHighlight(e,i,o)){r=o;break}}if(-1!==r){let e;e=-1!==a?(o||t.globalDropDownMenu)[r].children[a]:(o||t.globalDropDownMenu)[r],e.stateIcon&&(e.stateIcon.svg?s.push({type:"svg",name:e.stateIcon.src||e.stateIcon.svg,width:e.stateIcon.width||22,height:e.stateIcon.height||22,svg:e.stateIcon.svg,positionType:Zc.right,marginRight:0,funcType:Jc.dropDownState,interactive:!1}):e.stateIcon.src&&s.push({type:"image",name:e.stateIcon.src||e.stateIcon.svg,width:e.stateIcon.width||22,height:e.stateIcon.height||22,src:e.stateIcon.src,positionType:Zc.right,marginRight:0,funcType:Jc.dropDownState,interactive:!1}))}}return s}getDropDownIconRect(t,e,i){const n=this.downIcon.hover?.width??this.downIcon?.width??0,r=this.downIcon.hover?.height??this.downIcon?.height??0,o=t.right-2-n,s=t.right-2;let a;a="middle"===i?t.top+t.height/2-n/2:"top"===i?t.top+e/2:"bottom"===i?t.bottom-2*e:t.top;return{left:o,right:s,top:a,bottom:r+a,width:n,height:r}}getHierarchyIcon(t,e){const{hierarchyState:i}=this._table._getHeaderLayoutMap(t,e);if(i){if(i===Xc.expand)return this.expandIcon;if(i===Xc.collapse)return this.collapseIcon}}checkDropDownIcon(t,e,i){if(t.isPivotTable()){const n=t._getHeaderLayoutMap(e,i);if(Array.isArray(n.dropDownMenu)&&n.dropDownMenu.length)return!0}else{const n=t.getHeaderDefine(e,i);if(Array.isArray(n.dropDownMenu)&&n.dropDownMenu.length||(!Array.isArray(n.dropDownMenu)||0!==n.dropDownMenu.length)&&Array.isArray(t.globalDropDownMenu)&&t.globalDropDownMenu.length&&!n?.columns?.length)return!0}return!1}getStyleClass(t){switch(t){case"text":case"link":return Ou;case"image":case"video":return zV}}}class jV{_table;_tooltipElement;constructor(t){this._table=t}release(){this.unbindTooltipElement(),this._tooltipElement&&this._tooltipElement.release?.(),this._tooltipElement=void 0}_getTooltipElement(){return this._tooltipElement||(this._tooltipElement=this.createTooltipElementInternal()),this._tooltipElement}bindTooltipElement(t,e,i,n){return this._getTooltipElement().bindToCell(this._table,t,e,i,n)}moveTooltipElement(t,e,i,n){this._getTooltipElement().move(this._table,t,e,i,n)}unbindTooltipElement(){this._getTooltipElement().unbindFromCell()}locateTooltipElement(t,e,i,n,r){this._getTooltipElement()._locate(this._table,t,e,i,n,r)}}!function(){const t=document.createElement("style");t.id="vtable-tooltip-styleSheet",t.textContent="\n@keyframes vtable__bubble-tooltip-element--shown-animation {\n\t0% {\n\t\topacity: 0;\n\t}\n\t100% {\n\t\topacity: 1;\n\t}\n}\n.vtable__bubble-tooltip-element {\n\tposition: absolute;\n\t\n\tpointer-events: none;\n\tuser-select: none;\n\tmax-width: 300px;\n\tz-index: 99999;\n\n\tbackground: #FFFFFF;\n border: 1px solid #E6E8ED;\n box-sizing: border-box;\n border-radius: 4px;\n box-shadow: 0px 2px 4px rgb(27 31 35 / 8%);\n color: #141414;\n font-size: 13px;\n}\n.vtable__bubble-tooltip-element--hidden {\n\topacity: 0;\n\t/* transform: translate(-50%, -50%); */\n\ttransition: opacity 75ms linear;\n}\n.vtable__bubble-tooltip-element--shown {\n\topacity: 1;\n\t/* transform: translate(-50%, -50%); */\n\tanimation: vtable__bubble-tooltip-element--shown-animation 150ms ease-out;\n}\n.vtable__bubble-tooltip-element__content {\n\t/* font-size: .75rem; */\n\tpadding: 6px 8px;\n\tmin-height: 1em;\n\tline-height: 1.5;\n\twidth: 100%;\n\tdisplay: block;\n\twhite-space: pre-wrap;\n\tmargin: 0;\n\tbox-sizing: border-box;\n\toverflow: hidden;\n\tword-wrap: break-word;\n\tposition: relative;\n\tbackground-color: #FFF;\n\tz-index: 2;\n\tborder-radius: 4px\n}\n.vtable__bubble-tooltip-element__triangle {\n\t/* font-size: .75rem; */\n\tposition: absolute;\n\twidth: 10px;\n\theight: 10px;\n\tdisplay: block;\n\ttransform: rotate(45deg);\n transform-origin: 50% 50% 0;\n\tz-index: 1;\n\tbackground-color: #FFF;\n\tborder: 1px solid #E6E8ED;\n}\n",document.body.appendChild(t)}();const NV="vtable__bubble-tooltip-element",GV=`${NV}__content`,VV=`${NV}__triangle`,UV=`${NV}--hidden`,KV=`${NV}--shown`;class $V{_handler;_rootElement;_messageElement;_triangleElement;constructor(){this._handler=new df;const t=this._rootElement=wV("div",[NV,UV]),e=wV("span",[GV]),i=wV("span",[VV]);t.appendChild(i),t.appendChild(e),this._messageElement=t.querySelector(`.${GV}`)||void 0,this._triangleElement=t.querySelector(`.${VV}`)||void 0}bindToCell(t,e,i,n,r){const o=this._rootElement,s=this._messageElement,a=this._triangleElement;if(o?.classList.remove(KV),o?.classList.add(UV),this._canBindToCell(t,e,i)){s.setAttribute("style",""),a.setAttribute("style",""),n?.className&&o.classList.add(n.className),n?.style?.bgColor&&(s.style.backgroundColor=n?.style?.bgColor),n?.style?.bgColor&&(a.style.backgroundColor=n?.style?.bgColor),a.style.display=!0===n?.style?.arrowMark?"block":"none",n?.style?.font&&(s.style.font=n?.style?.font),n?.style?.color&&(s.style.color=n?.style?.color),n?.style?.padding&&(s.style.padding=`${n?.style?.padding.join("px ")}px`),s&&(s.textContent=n?.content);if(this._bindToCell(t,e,i,n?.position,n?.referencePosition,r,n?.style?.arrowMark))return o?.classList.add(KV),o?.classList.remove(UV),!0}else this.unbindFromCell();return!1}release(){this.unbindFromCell();const t=this._rootElement;t?.parentElement&&t.parentElement.removeChild(t),this._handler?.release?.(),delete this._rootElement,delete this._messageElement}move(t,e,i,n,r){const o=this._rootElement;this._canBindToCell(t,e,i)?(this._bindToCell(t,e,i,n?.position,n?.referencePosition,r),o?.classList.add(KV),o?.classList.remove(UV)):this.unbindFromCell()}unbindFromCell(){const t=this._rootElement;t?.parentElement&&(t.classList.remove(KV),t.classList.add(UV))}_canBindToCell(t,e,i){const n=t.getCellRangeRelativeRect({col:e,row:i}),r=t.getElement(),{bottom:o,left:s,right:a}=n,{frozenRowCount:l,frozenColCount:h}=t;if(i>=l&&l>0){if(o<t.getCellRangeRelativeRect({col:e,row:l-1}).bottom)return!1}else if(o<0)return!1;if(e>=h&&h>0){if(a<t.getCellRangeRelativeRect({col:h-1,row:i}).right)return!1}else if(s<0)return!1;const{offsetHeight:c,offsetWidth:u}=r;return!(c<o)&&!(u<s)}_bindToCell(t,e,i,n,r,o,s){const a=this._rootElement,l=t.getCellRangeRelativeRect({col:e,row:i}),h=t.getElement(),c=t.internalProps.element.offsetWidth,{width:u}=l;if(a){let l,d;a.parentElement!==h&&h.appendChild(a),a.style.left="0px";const p=Math.min(.8*c,4*u);a.style.maxWidth=`${p}px`;const f=a.clientWidth,g=a.clientHeight;if(!n&&!r)return!1;{const a=this.getComputedPosition(t,e,i,n,r,o,s);d=a.x,l=a.y}a.style.left=`${d}px`,a.style.top=`${l}px`,wu()&&(a.style.fontSize="11px");const{x1:m,x2:y,y1:b,y2:v}=t.stateManeger.menu.bounds,w=d,C=w+f,x=l,_=w+g;return!(t.stateManeger.menu.isShow&&m<C&&y>w&&v>x&&b<_)}return!1}getComputedPosition(t,e,i,n,r,o,s){const a=this._rootElement,l=t.getCellRangeRelativeRect({col:e,row:i}),{width:h,height:c}=t.internalProps.element.getBoundingClientRect(),{width:u}=l;let d,p;const f=Math.min(.8*h,4*u);a.style.maxWidth=`${f}px`;const g=a.clientWidth,m=a.clientHeight,y=s?6:0;if(n)p=n.x,d=n.y+y,this._triangleElement.style.left="50%",this._triangleElement.style.marginLeft="-5px",this._triangleElement.style.top="-5px";else if(r){let e=r.placement??$c.bottom;const i=r.rect.left+r.rect.width/2+t.tableX,n=r.rect.top+r.rect.height/2+t.tableY,s=r.rect.top+t.tableY,a=r.rect.bottom+t.tableY,l=r.rect.left+t.tableX,u=r.rect.right+t.tableX;let f=0;const b=()=>{f++,f>=4||(this.removeStyleFromTriangle(),e===$c.top?(p=i-g/2,d=s-m-y,this._triangleElement.style.left="50%",this._triangleElement.style.marginLeft="-5px",this._triangleElement.style.bottom="-5px",o&&d<0&&(e=$c.right,b())):e===$c.bottom?(p=i-g/2,d=a+y,this._triangleElement.style.left="50%",this._triangleElement.style.marginLeft="-5px",this._triangleElement.style.top="-5px",o&&d+m>c&&(e=$c.left,b())):e===$c.left?(d=n-m/2,p=l-g-y,this._triangleElement.style.top="50%",this._triangleElement.style.marginTop="-5px",this._triangleElement.style.right="-5px",o&&p<0&&(e=$c.top,b())):e===$c.right&&(d=n-m/2,p=u+y,this._triangleElement.style.top="50%",this._triangleElement.style.marginTop="-5px",this._triangleElement.style.left="-5px",o&&p+g>h&&(e=$c.bottom,b())))};b()}return o&&(p<0?p=0:p+a.offsetWidth>h&&(p=h-a.offsetWidth)),{x:p,y:d}}removeStyleFromTriangle(){this._triangleElement.style.left="",this._triangleElement.style.right="",this._triangleElement.style.top="",this._triangleElement.style.bottom="",this._triangleElement.style.marginLeft="",this._triangleElement.style.marginTop=""}_locate(t,e,i,n,r,o){const s=this.getComputedPosition(t,e,i,n,r,o),a=s.x,l=s.y;this._rootElement.style.left=`${a}px`,this._rootElement.style.top=`${l}px`}}class XV extends jV{createTooltipElementInternal(){return new $V}}const YV={"bubble-tooltip":function(t){return new XV(t)}};class qV{_table;_tooltipInstances;_attachInfo;confine;constructor(t,e){this._table=t,this._tooltipInstances={},this._bindTableEvent(t),this.confine=e}release(){const t=this._tooltipInstances;for(const e in t)t[e]?.release?.();delete this._tooltipInstances,this._attachInfo=null}_bindToCell(t,e,i){const n=this._attachInfo,r=this._getTooltipInstanceInfo(t,e);if(!n||r&&n.instance===r||(n.instance?.unbindTooltipElement(),this._attachInfo=null),!r)return;if(r&&r.bindTooltipElement(t,e,i,this.confine)){const n=this._table.getCellRange(t,e);this._attachInfo={range:n,instance:r,tooltipOptions:i}}}_move(t,e,i){const n=this._attachInfo;if(!n||!qp(n.range,t,e))return;const{instance:r}=n;r?.moveTooltipElement(t,e,i,this.confine)}moveToPosition(t,e,i,n){const r=this._attachInfo;if(!r||!qp(r.range,t,e))return;const{instance:o}=r;this._attachInfo.tooltipOptions.position=i,this._attachInfo.tooltipOptions.referencePosition=n,o?.locateTooltipElement(t,e,i,n,this.confine)}_unbindFromCell(){const t=this._attachInfo;if(!t)return;const{instance:e}=t;e?.unbindTooltipElement(),this._attachInfo=null}_isBindCell(t,e){const i=this._attachInfo;return!!i&&qp(i.range,t,e)}_bindTableEvent(t){t.on(sf.MOUSEENTER_CELL,(e=>{if(wu())return;const{x1:i,x2:n,y1:r,y2:o}=t.stateManeger.menu.bounds;if(t.stateManeger.menu.isShow&&"number"==typeof e.x&&"number"==typeof e.y&&e.x>i&&e.x<n&&e.y>r&&e.y<o)return;const{col:s,row:a}=e;if((!e.related||!this._isBindCell(s,a))&&t.internalProps.tooltip?.isShowOverflowTextTooltip){const i=t.getCellOverflowText(s,a),n=t.getHeaderDescription(s,a),r=t.getCellRangeRelativeRect({col:s,row:a});let o;i&&(o={content:n?`${n}\n ${i}`:i,referencePosition:{placement:$c.bottom,rect:r},style:{arrowMark:!1}}),n&&(o={content:n,referencePosition:{placement:$c.bottom,rect:r},style:{arrowMark:!1}}),o&&this._bindToCell(e.col,e.row,o)}})),t.on(sf.MOUSEMOVE_CELL,(e=>{if(!wu()){if(this._attachInfo?.tooltipOptions?.referencePosition){const i=this._attachInfo.tooltipOptions.referencePosition,{event:n}=e,{left:r,right:o,top:s,bottom:a}=i.rect,l=t._getMouseAbstractPoint(n,!1);l.inTable&&l.x>=r-5&&l.x<=o+5&&l.y>=s-5&&l.y<=a+5||this._unbindFromCell()}this._attachInfo&&t.stateManeger.menu.isShow&&this._bindToCell(e.col,e.row)}})),t.on(sf.MOUSELEAVE_CELL,(t=>{t.related&&this._isBindCell(t.related.col,t.related.row)||this._unbindFromCell()})),t.on(sf.SELECTED_CELL,(t=>{this._isBindCell(t.col,t.row)&&this._unbindFromCell()})),t.on(sf.MOUSELEAVE_TABLE,(t=>{this._unbindFromCell()})),t.on(sf.SCROLL,(e=>{const i=this._attachInfo;if(i?.tooltipOptions&&i?.range?.start){const{col:e,row:n}=i.range.start,r=t.getCellRangeRelativeRect({col:e,row:n});i.tooltipOptions.referencePosition.rect=r,this._move(i.range.start.col,i.range.start.row,i.tooltipOptions)}}))}_getTooltipInstanceInfo(t,e){const i=this._table,n=this._tooltipInstances,r="bubble-tooltip";return n&&n[r]||n&&(n[r]=YV[r](i))}isBinded(t){return JSON.stringify(t)===JSON.stringify(this._attachInfo?.tooltipOptions)}}const ZV=new Map;function JV(t,e,i){const n=`${t}-${e}-${i}`,r=ZV.get(n);if(r)return r;const o=(s={fontSize:t,fontFamily:i,fontWeight:e},new Lp({defaultFontParams:{fontFamily:"PingFang SC,Microsoft Yahei,system-ui,-apple-system,segoe ui,Roboto,Helvetica,Arial,sans-serif, apple color emoji,segoe ui emoji,segoe ui symbol",fontSize:11},getTextBounds:l?void 0:lT,specialCharSet:`{}()//&-/: .,@%'"~${Lp.ALPHABET_CHAR_SET}${Lp.ALPHABET_CHAR_SET.toUpperCase()}`,...a??{}},s));var s,a,l;return ZV.set(n,o),o}const QV=new class{measureText(t,e){const{fontSize:i,fontFamily:n,fontWeight:r}=e;return JV(i,r,n).measure(t)}measureTextWidth(t,e){const{fontSize:i,fontFamily:n="sans-serif",fontWeight:r="normal"}=e;return JV(i,r,n).measure(t).width}clipText(t,e,i){if(0===t.length)return{str:"",width:0};let n=this.measureTextWidth(t,e);return n<=i?{str:t,width:n}:(n=this.measureTextWidth(t[0],e),n>i?{str:"",width:0}:this._clipText(t,e,i,0,t.length-1))}_clipText(t,e,i,n,r){const o=Math.floor((n+r)/2),s=t.substring(0,o+1),a=this.measureTextWidth(s,e);let l;if(a>i){if(s.length<=1)return{str:"",width:0};const r=t.substring(0,o);return l=this.measureTextWidth(r,e),l<=i?{str:r,width:l}:this._clipText(t,e,i,n,o)}if(a<i){if(o>=t.length-1)return{str:t,width:this.measureTextWidth(t,e)};const n=t.substring(0,o+2);return l=this.measureTextWidth(n,e),l>=i?{str:s,width:a}:this._clipText(t,e,i,o,r)}return{str:s,width:a}}clipTextWithSuffix(t,e,i,n){if(""===n)return this.clipText(t,e,i);if(0===t.length)return{str:"",width:0};const r=this.measureTextWidth(t,e);if(r<=i)return{str:t,width:r};const o=this.measureTextWidth(n,e);if(o>i)return{str:"",width:0};i-=o;const s=this._clipText(t,e,i,0,t.length-1);return s.str+=n,s.width+=o,s}};class tU{_table;_menuElement;constructor(t){this._table=t}release(){this.unbindMenuElement(),this._menuElement&&this._menuElement.release(),this._menuElement=void 0}_getMenuElement(){return this._menuElement||(this._menuElement=this.createMenuElementInternal()),this._menuElement}bindMenuElement(t,e,i){return this._getMenuElement().bindToCell(this._table,t,e,i)}unbindMenuElement(){this._getMenuElement().unbindFromCell()}pointInMenuElement(t,e){return this._getMenuElement().pointInMenuElement(t,e)}}const eU="vtable__menu-element",iU=`${eU}--hidden`,nU=`${eU}--shown`;class rU{_handler;_rootElement;_menuInstanceInfo;constructor(t){this._handler=new df,this._rootElement=wV("div",[eU,iU]),this._rootElement.addEventListener("wheel",(t=>{t.stopPropagation()})),this._rootElement?.addEventListener("mousedown",(t=>{t.stopPropagation(),t.preventDefault()})),this._rootElement?.addEventListener("click",(e=>{if(e.stopPropagation(),e.preventDefault(),this._rootElement.classList.contains(iU))return;const{col:i,row:n,dropDownIndex:r,menuKey:o,text:s,hasChildren:a}=e.target;if("number"!=typeof r||a)return void e.stopPropagation();const l=t.isPivotTable()?t.internalProps.layoutMap.getPivotDimensionInfo(i,n):t.getHeaderField(i,n),h=t._dropDownMenuIsHighlight(i,n,r);t.fireListeners(sf.DROPDOWNMENU_CLICK,{col:i,row:n,field:l,menuKey:o,text:s,highlight:h,cellLocation:t.getCellLocation(i,n)}),t.fireListeners(sf.DROPDOWN_MENU_CLEAR,null),t.fireListeners(sf.HIDE_MENU,null),e.stopPropagation()})),this._rootElement?.addEventListener("mousemove",(t=>{this._rootElement.classList.contains(iU)||t.stopPropagation()}))}get rootElement(){return this._rootElement}release(){this.unbindFromCell();const t=this._rootElement;t?.parentElement&&t.parentElement.removeChild(t),this._handler.release(),delete this._rootElement}bindToCell(t,e,i,n){const r=this._rootElement;if(this._menuInstanceInfo=n,r?.classList.remove(nU),r?.classList.add(iU),this._canBindToCell(t,e,i)){r.innerHTML="",r.appendChild(n.content);if(this._bindCell(t,e,i,n.position,n.referencePosition))return r?.classList.add(nU),r?.classList.remove(iU),!0}else this.unbindFromCell();return!1}unbindFromCell(){const t=this._rootElement;this._menuInstanceInfo=void 0,t?.parentElement&&(t.classList.remove(nU),t.classList.add(iU))}_canBindToCell(t,e,i){const n=t.getCellRangeRelativeRect({col:e,row:i}),r=t.getElement(),{top:o,bottom:s,left:a,right:l}=n,{frozenRowCount:h,frozenColCount:c}=t;if(i>=h&&h>0){if(s<t.getCellRangeRelativeRect({col:e,row:h-1}).bottom)return!1}else if(s<0)return!1;if(e>=c&&c>0){if(l<t.getCellRangeRelativeRect({col:c-1,row:i}).right)return!1}else if(l<0)return!1;const{offsetHeight:u,offsetWidth:d}=r;return!(u<o)&&!(d<a)}_bindCell(t,e,i,n,r){const o=this._rootElement,s=t.getElement(),{width:a,height:l}=t.internalProps.element.getBoundingClientRect();if(o){o.parentElement!==s&&s.appendChild(o),o.style.left="0px";const t=.8*a;o.style.maxWidth=`${t}px`;const e=o.clientWidth,i=o.clientHeight;let h,c;return n&&(h=n.x,c=n.y),r&&(h=r.rect.right-e,c=r.rect.bottom),c+i>l&&(c=l-i,h+=e-2),c<0&&(c/=2),o.style.top=`${c}px`,h<0?h=0:h+e>a&&(h=a-e),o.style.left=`${h}px`,!0}return!1}pointInMenuElement(t,e){const i=this._rootElement,{x:n,y:r,width:o,height:s}=i.getBoundingClientRect();return t>n-5&&t<n+o+5&&e>r-5&&e<r+s+5}}class oU extends tU{createMenuElementInternal(){return new OV(this._table)}}let sU=class extends tU{createMenuElementInternal(){return new rU(this._table)}};const aU={"dropdown-menu":function(t){return new oU(t)},"context-menu":function(t){return new oU(t)},container:t=>new sU(t)};class lU{_table;_menuInstances;_attachInfo;constructor(t){this._table=t,this._menuInstances={},this._bindTableEvent(t)}release(){const t=this._menuInstances;for(const e in t)t[e].release();delete this._menuInstances,this._attachInfo=null}_bindToCell(t,e,i,n){const r=this._attachInfo,o=this._getMenuInstanceInfo(t,e,i,n);if(!r||o&&r.instance===o.instance||(r.instance?.unbindMenuElement(),this._attachInfo=null),!o)return;const{instance:s,info:a}=o;if(s&&s.bindMenuElement(t,e,a)){const i=this._table.getCellRange(t,e);this._attachInfo={range:i,instance:s}}}_unbindFromCell(){const t=this._attachInfo;if(!t)return;const{instance:e}=t;e?.unbindMenuElement(),this._attachInfo=null}_isBindToCell(t,e){const i=this._attachInfo;return!!i&&qp(i.range,t,e)}pointInMenuElement(t,e){if(!this._attachInfo)return!1;const i=this._attachInfo,{instance:n}=i;return n.pointInMenuElement(t,e)}_bindTableEvent(t){t.on(sf.DROPDOWN_ICON_CLICK,(t=>{this._attachInfo&&this._isBindToCell(t.col,t.row)?this._unbindFromCell():this._bindToCell(t.col,t.row,"dropdown-menu")})),t.on(sf.DROPDOWN_MENU_CLEAR,(t=>{this._unbindFromCell()})),t.on(sf.CONTEXTMENU_CELL,(e=>{if("html"===t.internalProps.menu?.renderMode){const i=t._getMouseAbstractPoint(e.event,!1);let n=null;i.inTable&&"function"==typeof t.internalProps.menu?.contextMenuItems?n=t.internalProps.menu.contextMenuItems(t.getHeaderField(e.col,e.row),e.row):i.inTable&&Array.isArray(t.internalProps.menu?.contextMenuItems)&&(n=t.internalProps.menu?.contextMenuItems),this._bindToCell(e.col,e.row,"context-menu",{content:n,position:{x:i.x,y:i.y}})}}))}_getMenuInstanceInfo(t,e,i,n){const r=this._table,o=this._menuInstances,s=function(t,e,i,n,r){const{lineHeight:o,textBaseline:s,textStick:a}=t._getCellStyle(e,i);let l=t.getCellRangeRelativeRect(t.getCellRange(e,i));a&&(l=t.getVisibleCellRangeRelativeRect({col:e,row:i}));let{left:h,right:c,bottom:u,top:d,width:p,height:f}=l;if(t.isHeader(e,i)&&({left:h,right:c,bottom:u,top:d,width:p,height:f}=t.internalProps.headerHelper.getDropDownIconRect(l,o,s||"middle")),r?.content)return{type:n,position:r.position,referencePosition:r.referencePosition??{rect:{left:h,right:c,top:d,bottom:u,width:p,height:f}},content:r.content};if("dropdown-menu"===n){const{dropDownMenu:r=t.globalDropDownMenu,pivotInfo:o}=t._getHeaderLayoutMap(e,i);return{type:n,referencePosition:{rect:{left:h,right:c,top:d,bottom:u,width:p,height:f}},content:r,pivotInfo:o}}return null}(r,t,e,i,n);if(!s)return null;return{instance:o&&o[i]||o&&(o[i]=aU[i](r)),type:i,info:s}}}class hU extends EventTarget{_table;_input;constructor(t,e){if(super(),this._table=t,"node"===hf.mode)return;const i=document.createElement("div");i.style.opacity="0",i.dataset.vtable="vtable",i.style.pointerEvents="none",i.classList.add("input-container");const n=this._input=document.createElement("input");i.appendChild(n),n.classList.add("table-focus-control"),n.dataset.vtable="vtable",n.readOnly=!0,e.appendChild(i)}focus(){this._input.focus({preventScroll:!0})}setFocusRect(t,e){const i=this._input;i.value=e,i.select();const n=t.top-this._table.scrollTop,r=t.left-this._table.scrollLeft;i.style.top=`${n.toFixed()}px`,i.style.left=`${r.toFixed()}px`,i.style.width=`${t.width.toFixed()}px`,i.style.height=`${t.height.toFixed()}px`}get input(){return this._input}release(){}}let cU=1;Op?cU=1:(cU=Math.ceil(window.devicePixelRatio||1),cU>1&&cU%2!=0&&(cU+=1));const uU={orient:"bottom",position:"middle",padding:30,title:{visible:!1,padding:0,textStyle:{fontSize:14,fill:"#000000",fontWeight:"normal"},space:12},item:{visible:!0,spaceCol:10,spaceRow:10,padding:2,background:{state:{selectedHover:{fill:"gray",fillOpacity:.7},unSelectedHover:{fill:"gray",fillOpacity:.2}}},shape:{space:4,state:{unSelected:{fillOpacity:.5}}},label:{space:4,style:{fill:"#89909D",fontSize:14},state:{unSelected:{fillOpacity:.5}}}},allowAllCanceled:!0,visible:!0};function dU(t,e){const{title:i={},item:n={},pager:r={},background:o={},type:s,id:a,visible:l,orient:h,position:c,data:u,filter:d,regionId:p,regionIndex:f,seriesIndex:g,seriesId:m,padding:y,...b}=fd({},uU,t),v=b;return i.visible&&(v.title=nO(i)),od(n.focusIconStyle)||rO(n.focusIconStyle),oO(n.shape),oO(n.label),oO(n.value),oO(n.background),lj(n.maxWidth)&&(n.maxWidth=Number(n.maxWidth.substring(0,n.maxWidth.length-1))*e.width/100),lj(n.width)&&(n.width=Number(n.width.substring(0,n.width.length-1))*e.width/100),lj(n.height)&&(n.height=Number(n.height.substring(0,n.height.length-1))*e.width/100),v.item=n,od(r.textStyle)||rO(r.textStyle),oO(r.handler),v.pager=r,o.visible&&!od(o.style)&&(fd(v,o.style),Uu(o.padding)&&(v.padding=o.padding)),v}class pU{table;option;orient;visible;position;selectedData;legendComponent;constructor(t,e){this.table=e,this.option=cd(t),this.orient=t.orient??"left",this.visible=t.visible??!0,this.position=t.position??"middle",this.selectedData=t.defaultSelected??[],this.createComponent(),this.initEvent()}createComponent(){const t=this.getLegendAttributes({width:this.table.tableNoFrameWidth,height:this.table.tableNoFrameHeight}),e=new CI(fd({},t,{defaultSelected:this.selectedData}));e.name="legend",this.legendComponent=e,this.table.scenegraph.stage.defaultLayer.appendChild(e),this.adjustTableSize(t)}resize(){this.legendComponent&&(this.legendComponent.setAttributes({width:this.table.tableNoFrameWidth,height:this.table.tableNoFrameHeight}),this.adjustTableSize(this.legendComponent.attribute))}adjustTableSize(t){let e=isFinite(this.legendComponent.AABBBounds.width())?this.legendComponent.AABBBounds.width():0,i=isFinite(this.legendComponent.AABBBounds.height())?this.legendComponent.AABBBounds.height():0;const n=this.table.tableNoFrameWidth,r=this.table.tableNoFrameHeight,o=RW(t.padding??this.option.padding??10);let s=0,a=0;"left"===this.orient?(s=o[3],a=0,e+=o[1]+o[3]):"top"===this.orient?(s=0,a=o[0],i+=o[0]+o[2]):"right"===this.orient?(s=n-e-o[1],a=0,e+=o[1]+o[3]):"bottom"===this.orient&&(s=0,a=r-i-o[2],i+=o[0]+o[2]);const l="bottom"===this.orient||"top"===this.orient?"horizontal":"vertical",h=this.position;let c=0,u=0;"horizontal"===l?c="middle"===h?(n-e)/2:"end"===h?n-e-o[1]:o[3]:u="middle"===h?(r-i)/2:"end"===h?r-i-o[2]:o[0],this.legendComponent.setAttributes({dx:c,dy:u,x:s,y:a}),"left"===this.orient?(this.table.tableNoFrameWidth=this.table.tableNoFrameWidth-Math.ceil(e),this.table.tableX+=Math.ceil(e)):"top"===this.orient?(this.table.tableNoFrameHeight=this.table.tableNoFrameHeight-Math.ceil(i),this.table.tableY+=Math.ceil(i)):"right"===this.orient?this.table.tableNoFrameWidth=this.table.tableNoFrameWidth-Math.ceil(e):"bottom"===this.orient&&(this.table.tableNoFrameHeight=this.table.tableNoFrameHeight-Math.ceil(i))}getLegendAttributes(t){return{layout:"bottom"===this.orient||"top"===this.orient?"horizontal":"vertical",items:this.getLegendItems(),maxWidth:t.width,maxHeight:t.height,...dU(this.option,t)}}getLegendItems(){return this.option.data}initEvent(){this.legendComponent&&(this.legendComponent.addEventListener(mI.legendItemClick,(t=>{const e=sd(t,"detail.currentSelected");this.table.fireListeners(sf.LEGEND_ITEM_CLICK,{model:this,value:e,event:t})})),this.legendComponent.addEventListener(mI.legendItemHover,(t=>{const e=sd(t,"detail");this.table.fireListeners(sf.LEGEND_ITEM_HOVER,{model:this,value:e,event:t})})),this.legendComponent.addEventListener(mI.legendItemUnHover,(t=>{const e=sd(t,"detail");this.table.fireListeners(sf.LEGEND_ITEM_UNHOVER,{model:this,value:e,event:t})})),this.legendComponent.addEventListener("legendItemAttributeUpdate",(t=>{this.table.scenegraph.updateNextFrame()})))}getLegendBounds(){return{width:isFinite(this.legendComponent.AABBBounds.width())?this.legendComponent.AABBBounds.width():0,height:isFinite(this.legendComponent.AABBBounds.height())?this.legendComponent.AABBBounds.height():0}}release(){this.legendComponent&&this.table.scenegraph.stage.defaultLayer.removeChild(this.legendComponent),this.legendComponent=null}}const fU={orient:"right",position:"middle",padding:30,title:{visible:!1,padding:0,textStyle:{fontSize:14,fontWeight:"normal",fill:{type:"palette",key:"titleFontColor"}},space:12},handler:{visible:!0},startText:{style:{fontSize:14,fontWeight:"normal",fill:{type:"palette",key:"labelFontColor"}}},endText:{style:{fontSize:14,fontWeight:"normal",fill:{type:"palette",key:"labelFontColor"}}},handlerText:{style:{fontSize:14,fontWeight:"normal",fill:{type:"palette",key:"labelFontColor"}}}},gU={horizontal:{...fU,rail:{width:200,height:8,style:{fill:"rgba(0,0,0,0.04)"}}},vertical:{...fU,rail:{width:8,height:200,style:{fill:"rgba(0,0,0,0.04)"}}}},mU={horizontal:{sizeBackground:{fill:"#cdcdcd"},track:{style:{fill:"rgba(20,20,20,0.1)"}},rail:{width:200,height:4,style:{fill:"rgba(0,0,0,0.04)"}},...fU},vertical:{sizeBackground:{fill:"#cdcdcd"},track:{style:{fill:"rgba(20,20,20,0.1)"}},rail:{width:4,height:200,style:{fill:"rgba(0,0,0,0.04)"}},...fU}};function yU(t,e){const{title:i={},handler:n={},rail:r={},track:o={},startText:s,endText:a,handlerText:l,sizeBackground:h,background:c={},type:u,id:d,visible:p,orient:f,position:g,data:m,defaultSelected:y,field:b,filter:v,regionId:w,regionIndex:C,seriesIndex:x,seriesId:_,padding:S,...A}=fd({},("color"===t.type?gU:mU)["bottom"===t.orient||"top"===t.orient?"horizontal":"vertical"],t),T=A;return i.visible&&(T.title=nO(i)),T.showHandler=!1!==n.visible,od(n.style)||(T.handlerStyle=rO(n.style)),Uu(r.width)&&(T.railWidth=r.width),Uu(r.height)&&(T.railHeight=r.height),od(r.style)||(T.railStyle=rO(r.style)),od(o.style)||(T.trackStyle=rO(o.style)),T.startText=oO(s),T.endText=oO(a),T.handlerText=oO(l),od(h)||(T.sizeBackground=rO(h)),c.visible&&!od(c.style)&&(fd(T,c.style),Uu(c.padding)&&(T.padding=c.padding)),T}class bU{table;option;orient;visible;position;selectedData;legendComponent;constructor(t,e){this.table=e,this.option=cd(t),this.orient=t.orient??"left",this.visible=t.visible??!0,this.position=t.position??"middle",this.selectedData=t.defaultSelected??[],this.createComponent(),this.initEvent()}createComponent(){const t=this.getLegendAttributes({width:this.table.tableNoFrameWidth,height:this.table.tableNoFrameHeight});let e;e="color"===this.option.type?new QI(fd({},t,{slidable:!0})):new eO(fd({},t,{slidable:!0})),e.name="legend",this.legendComponent=e,this.table.scenegraph.stage.defaultLayer.appendChild(e),this.adjustTableSize(t)}resize(){this.legendComponent&&(this.legendComponent.setAttributes({width:this.table.tableNoFrameWidth,height:this.table.tableNoFrameHeight}),this.adjustTableSize(this.legendComponent.attribute))}adjustTableSize(t){let e=isFinite(this.legendComponent.AABBBounds.width())?this.legendComponent.AABBBounds.width():0,i=isFinite(this.legendComponent.AABBBounds.height())?this.legendComponent.AABBBounds.height():0;const n=this.table.tableNoFrameWidth,r=this.table.tableNoFrameHeight,o=RW(t.padding??this.option.padding??10);let s=0,a=0;"left"===this.orient?(s=o[3],a=0,e+=o[1]+o[3]):"top"===this.orient?(s=0,a=o[0],i+=o[0]+o[2]):"right"===this.orient?(s=n-e-o[1],a=0,e+=o[1]+o[3]):"bottom"===this.orient&&(s=0,a=r-i-o[2],i+=o[0]+o[2]);const l="bottom"===this.orient||"top"===this.orient?"horizontal":"vertical",h=this.position;let c=0,u=0;"horizontal"===l?c="middle"===h?(n-e)/2:"end"===h?n-e-o[1]:o[3]:u="middle"===h?(r-i)/2:"end"===h?r-i-o[2]:o[0],this.legendComponent.setAttributes({dx:c,dy:u,x:s,y:a}),"left"===this.orient?(this.table.tableNoFrameWidth=this.table.tableNoFrameWidth-Math.ceil(e),this.table.tableX+=Math.ceil(e)):"top"===this.orient?(this.table.tableNoFrameHeight=this.table.tableNoFrameHeight-Math.ceil(i),this.table.tableY+=Math.ceil(i)):"right"===this.orient?this.table.tableNoFrameWidth=this.table.tableNoFrameWidth-Math.ceil(e):"bottom"===this.orient&&(this.table.tableNoFrameHeight=this.table.tableNoFrameHeight-Math.ceil(i))}getLegendAttributes(t){const e="bottom"===this.orient||"top"===this.orient?"horizontal":"vertical",i="horizontal"===e?"bottom":this.orient;return{...yU(this.option),layout:e,align:i,min:this.option.min,max:this.option.max,value:this.option.value,["color"===this.option.type?"colors":"sizeRange"]:"color"===this.option.type?this.option.colors:this.option.sizeRange}}initEvent(){this.legendComponent&&this.legendComponent.addEventListener("change",(t=>{const e=sd(t,"detail.value");this.table.fireListeners(sf.LEGEND_CHANGE,{model:this,value:e,event:t}),this.table.scenegraph.updateNextFrame()}))}getLegendBounds(){return{width:isFinite(this.legendComponent.AABBBounds.width())?this.legendComponent.AABBBounds.width():0,height:isFinite(this.legendComponent.AABBBounds.height())?this.legendComponent.AABBBounds.height():0}}release(){this.legendComponent&&this.table.scenegraph.stage.defaultLayer.removeChild(this.legendComponent),this.legendComponent=null}}function vU(t,e){return"color"===t.type||"size"===t.type?new bU(t,e):new pU(t,e)}class wU{table;_titleOption;_titleComponent;_cacheAttrs;constructor(t,e){this.table=e,this._titleOption=t,this._titleComponent=this._createOrUpdateTitleComponent(this._getTitleAttrs())}_createOrUpdateTitleComponent(t){if(this._titleComponent)yd(t,this._cacheAttrs)||this._titleComponent.setAttributes(t);else{const e=new iO(t);e.name="title",this.table.scenegraph.stage.defaultLayer.appendChild(e),this._titleComponent=e}return this._adjustTableSize(this._titleComponent.attribute),this._titleComponent}resize(){if(!this._titleComponent)return;const t=RW(this._titleOption.padding??10),e=this._titleOption.width??this.table.tableNoFrameWidth-t[1]-t[3];this._titleComponent.setAttributes({x:this._titleOption.x??"right"===this._titleOption.orient?this.table.tableX+this.table.tableNoFrameWidth:this.table.tableX,y:this._titleOption.y??"bottom"===this._titleOption.orient?this.table.tableY+this.table.tableNoFrameHeight:this.table.tableY,width:e,textStyle:{width:e,...this._titleOption.textStyle},subtextStyle:{width:e,...this._titleOption.subtextStyle}}),this._adjustTableSize(this._titleComponent.attribute)}_adjustTableSize(t){let e=isFinite(this._titleComponent.AABBBounds.width())?this._titleComponent.AABBBounds.width():0;const i=isFinite(this._titleComponent.AABBBounds.height())?this._titleComponent.AABBBounds.height():0,n=(this.table.tableNoFrameWidth,this.table.tableNoFrameHeight,RW(t.padding??this._titleOption.padding??10));"left"===this._titleOption.orient?n[3]:"top"===this._titleOption.orient?n[0]:"right"===this._titleOption.orient?(n[1],e+=n[1]+n[3]):"bottom"===this._titleOption.orient&&n[2],"left"===this._titleOption.orient?(this.table.tableNoFrameWidth=this.table.tableNoFrameWidth-Math.ceil(e),this.table.tableX+=Math.ceil(e)):"top"===this._titleOption.orient?(this.table.tableNoFrameHeight=this.table.tableNoFrameHeight-Math.ceil(i),this.table.tableY+=Math.ceil(i)):"right"===this._titleOption.orient?this.table.tableNoFrameWidth=this.table.tableNoFrameWidth-Math.ceil(e):"bottom"===this._titleOption.orient&&(this.table.tableNoFrameHeight=this.table.tableNoFrameHeight-Math.ceil(i)),this._cacheAttrs=t,"right"!==this._titleOption.orient&&"bottom"!==this._titleOption.orient||this._titleComponent.setAttributes({x:this._titleOption.x??"right"===this._titleOption.orient?this.table.tableX+this.table.tableNoFrameWidth:this.table.tableX,y:this._titleOption.y??"bottom"===this._titleOption.orient?this.table.tableY+this.table.tableNoFrameHeight:this.table.tableY})}release(){this.table.scenegraph.stage.defaultLayer.removeChild(this._titleComponent),this._titleComponent=null}_getTitleAttrs(){const t=RW(this._titleOption.padding??10),e=this._titleOption.width??this.table.tableNoFrameWidth-t[1]-t[3];return{text:this._titleOption.text??"",subtext:this._titleOption.subtext??"",x:this._titleOption.x??"right"===this._titleOption.orient?this.table.tableX+this.table.tableNoFrameWidth:this.table.tableX,y:this._titleOption.y??"bottom"===this._titleOption.orient?this.table.tableY+this.table.tableNoFrameHeight:this.table.tableY,width:e,height:this._titleOption.height,minWidth:this._titleOption.minWidth,maxWidth:this._titleOption.maxWidth,minHeight:this._titleOption.minHeight,maxHeight:this._titleOption.maxHeight,padding:this._titleOption.padding,align:this._titleOption.align??"left",verticalAlign:this._titleOption.verticalAlign??"top",textStyle:{width:e,...this._titleOption.textStyle},subtextStyle:{width:e,...this._titleOption.subtextStyle}}}}const{toBoxArray:CU}=rf,{isTouchEvent:xU}=nf,_U=/^\$(\d+)\$(\d+)$/;!function(){const t=document.createElement("style");t.id="vtable-style-styleSheet",t.textContent="\n.vtable .input-container {\n\tposition: absolute;\n\ttop:0px;\n}\n.vtable .table-scrollable {\n\tposition: absolute;\n\toverflow: scroll;\n}\n.vtable .table-scrollable::-webkit-scrollbar-button{\n\tbackground-color: transparent;\n}\n.vtable .table-scrollable::-webkit-scrollbar-track-piece{\n\tbackground-color: transparent;\n}\n.vtable .table-scrollable::-webkit-scrollbar-corner {\n\tbackground-color: transparent;\n}\n.vtable .table-scrollable::-webkit-scrollbar-thumb {\n\tborder-radius : 4px;\n\tbackground-color : rgba(100, 100, 100, .5);\n}\n\n.vtable .table-scroll-end-point {\n\topacity: 0;\n\tposition: relative;\n}\n.vtable {\n\t/* 设置overflow: auto 应该是为了滚动条的某个问题 但设置了auto之后 dom的下拉菜单只能显示在vtable节点中 超出会截断;现在去掉auto 暂时滚动条的问题没有发现 */\n\t/* overflow: auto; */\n\tposition: relative;\n\twidth: 100%;\n\theight: 100%;\n\ttext-align: left;\n -webkit-font-smoothing:auto;\n}\n.vtable > canvas {\n\tposition: absolute;\n\twidth: 0;\n\theight: 0;\n}\n.vtable .table-focus-control {\n\tposition: relative !important;\n\twidth: 1px;\n\theight: 1px;\n\topacity: 0;\n\tpadding: 0;\n\tmargin: 0;\n\tbox-sizing: border-box;\n\tpointer-events: none;\n\tmax-width: 500px;\n\tmax-height: 500px;\n\tfloat: none !important;\n}\n.vtable input.table-focus-control::-ms-clear {\n\tvisibility: hidden;\n}\n.vtable input.table-focus-control.composition {\n\topacity: 1;\n\tmax-width: none;\n\tmax-height: none;\n}\n",document.body.appendChild(t)}();const SU={};class AU extends Su{internalProps;showFrozenIcon=!0;showSort=!0;padding;globalDropDownMenu;tableNoFrameWidth;tableNoFrameHeight;tableX;tableY;_widthMode;_heightMode;_autoFillWidth;customRender;canvasWidth;canvasHeight;_vDataSet;scenegraph;stateManeger;eventManeger;_pixelRatio;static get EVENT_TYPE(){return sf}options;version="0.10.3-alpha.0";pagination;id=`VTable${Date.now()}`;headerStyleCache;bodyStyleCache;container;constructor(t,e={}){if(super(),!t)throw new Error("vtable's container is undefined");const{frozenColCount:i=0,defaultRowHeight:n=40,defaultHeaderRowHeight:r,defaultColWidth:o=80,defaultHeaderColWidth:s,widthMode:a="standard",heightMode:l="standard",autoFillWidth:h=!1,keyboardOptions:c,columnResizeMode:u,dragHeaderMode:d,showFrozenIcon:p,allowFrozenColCount:f,padding:g,hover:m,menu:y,select:b,customRender:v,pixelRatio:w=cU,renderChartAsync:C,renderChartAsyncBatchCount:x}=e;this.container=t,this.options=e,this.options.container=t,this._widthMode=a,this._heightMode=l,this._autoFillWidth=h,this.customRender=v,this.padding={top:0,right:0,left:0,bottom:0},g&&("number"==typeof g?(this.padding.top=g,this.padding.left=g,this.padding.bottom=g,this.padding.right=g):(g.top&&(this.padding.top=g.top),g.bottom&&(this.padding.bottom=g.bottom),g.left&&(this.padding.left=g.left),g.right&&(this.padding.right=g.right))),this.tableNoFrameWidth=0,this.tableNoFrameHeight=0;const _=this.internalProps={};void 0!==p&&(this.showFrozenIcon=p),"number"==typeof f&&f<=0&&(this.showFrozenIcon=!1),_.handler=new df,_.element=function(t){const e=document.createElement("div");e.setAttribute("tabindex","0"),e.classList.add("vtable"),e.style.outline="none",e.style.margin=`${t.top}px ${t.right}px ${t.bottom}px ${t.left}px`;const i=(e.offsetWidth||e.parentElement?.offsetWidth||1)-1,n=(e.offsetHeight||e.parentElement?.offsetHeight||1)-1;return e.style.width=i&&i-t.left-t.right+"px"||"0px",e.style.height=n&&n-t.top-t.bottom+"px"||"0px",e}(this.padding),_.focusControl=new hU(this,_.element),_.pixelRatio=w,_.canvas=document.createElement("canvas"),_.element.appendChild(_.canvas),_.context=_.canvas.getContext("2d"),_.frozenColCount=i,_.defaultRowHeight=n,_.defaultHeaderRowHeight=r??n,_.defaultColWidth=o,_.defaultHeaderColWidth=s??o,_.keyboardOptions=c,_.columnResizeMode=u,_.dragHeaderMode=d,_.renderChartAsync=C,sN(x),_._rowHeightsMap=new ff,_._rowRangeHeightsMap=new Map,_._colRangeWidthsMap=new Map,_._widthResizedColMap=new Set,this.colWidthsMap=new ff,this.colContentWidthsMap=new ff,this.colWidthsLimit={},_.calcWidthContext={_:_,get full(){return this._.canvas.width/(this._.context.pixelRatio??window.devicePixelRatio)}},_.cellTextOverflows={},_.focusedTable=!1,_.theme=Ff.of(e.theme??Ff.DEFAULT),t?(t.innerHTML="",t.appendChild(_.element),this._updateSize()):this._updateSize(),this.options=e,_.theme=Ff.of(e.theme??Ff.DEFAULT),_.bodyHelper=new vV(this),_.headerHelper=new WV(this),_.autoWrapText=e.autoWrapText,_.allowFrozenColCount=e.allowFrozenColCount??_.colCount,_.limitMaxAutoWidth=e.limitMaxAutoWidth??450,this._vDataSet=new jz,this.scenegraph=new NG(this),this.stateManeger=new rV(this),this.eventManeger=new gV(this),e.legends&&(_.legends=vU(e.legends,this),this.scenegraph.tableGroup.setAttributes({x:this.tableX,y:this.tableY})),e.title&&(_.title=new wU(e.title,this),this.scenegraph.tableGroup.setAttributes({x:this.tableX,y:this.tableY})),_.tooltip=Object.assign({renderMode:"html",isShowOverflowTextTooltip:!1,confine:!0},e.tooltip),"html"===_.tooltip.renderMode&&(_.tooltipHandler=new qV(this,_.tooltip.confine)),_.menu=Object.assign({renderMode:"html"},e.menu),Array.isArray(e.menu?.dropDownMenuHighlight)&&this.setDropDownMenuHighlight(e.menu?.dropDownMenuHighlight),Array.isArray(e.menu?.defaultHeaderMenuItems)&&(this.globalDropDownMenu=e.menu.defaultHeaderMenuItems),"html"===_.menu.renderMode&&(_.menuHandler=new lU(this)),this.headerStyleCache=new Map,this.bodyStyleCache=new Map}throttleInvalidate=function(t,e){let i=null;return function(...n){i||(i=setTimeout((()=>{t.apply(this,n),i=null}),e))}}(this.render.bind(this),200);getContainer(){return this.container}getElement(){return this.internalProps.element}get canvas(){return this.internalProps.canvas}resize(){this._updateSize(),this.internalProps.legends&&this.internalProps.legends.resize(),this.internalProps.title&&this.internalProps.title.resize(),this.scenegraph.resize()}get rowCount(){return this.internalProps.rowCount}set rowCount(t){this.internalProps.rowCount=t}get colCount(){return this.internalProps.colCount??0}set colCount(t){this.internalProps.colCount=t}get frozenColCount(){return this.internalProps.frozenColCount??0}set frozenColCount(t){t>=this.colCount&&(t=0),this.internalProps.frozenColCount=t,this.options.frozenColCount=t,this.tableNoFrameWidth-this.getColsWidth(0,t-1)<=120&&(this.internalProps.frozenColCount=0),this.stateManeger.setFrozenCol(this.internalProps.frozenColCount)}setFrozenColCount(t){t>=this.colCount&&(t=0),this.internalProps.frozenColCount=t,this.options.frozenColCount=t,this.tableNoFrameWidth-this.getColsWidth(0,t-1)<=120&&(this.internalProps.frozenColCount=0),this.stateManeger.setFrozenCol(this.internalProps.frozenColCount)}_setFrozenColCount(t){t>=this.colCount&&(t=0),this.internalProps.frozenColCount=t}_resetFrozenColCount(){this.options.frozenColCount&&(this.tableNoFrameWidth-this.getColsWidth(0,this.options.frozenColCount-1)<=120?this._setFrozenColCount(0):this.frozenColCount!==this.options.frozenColCount&&this._setFrozenColCount(this.options.frozenColCount))}get frozenRowCount(){return this.internalProps.frozenRowCount??0}set frozenRowCount(t){this.internalProps.frozenRowCount=t}get rightFrozenColCount(){return this.internalProps.rightFrozenColCount??0}set rightFrozenColCount(t){this.scenegraph.dealWidthRightFrozen(t)}get bottomFrozenRowCount(){return this.internalProps.bottomFrozenRowCount??0}set bottomFrozenRowCount(t){this.scenegraph.dealWidthBottomFrozen(t)}get defaultRowHeight(){return this.internalProps.defaultRowHeight}set defaultRowHeight(t){this.internalProps.defaultRowHeight=t,this.options.defaultRowHeight=t}get defaultHeaderRowHeight(){return this.internalProps.defaultHeaderRowHeight}set defaultHeaderRowHeight(t){this.internalProps.defaultHeaderRowHeight=t,this.options.defaultHeaderRowHeight=t}get defaultColWidth(){return this.internalProps.defaultColWidth}set defaultColWidth(t){this.internalProps.defaultColWidth=t,this.options.defaultColWidth=t}get defaultHeaderColWidth(){return this.internalProps.defaultHeaderColWidth}set defaultHeaderColWidth(t){this.internalProps.defaultHeaderColWidth=t,this.options.defaultHeaderColWidth=t}get colWidthsMap(){return this.internalProps._colWidthsMap}set colWidthsMap(t){this.internalProps._colWidthsMap=t}get colContentWidthsMap(){return this.internalProps._colContentWidthsMap}set colContentWidthsMap(t){this.internalProps._colContentWidthsMap=t}get _colRangeWidthsMap(){return this.internalProps._colRangeWidthsMap}set _colRangeWidthsMap(t){this.internalProps._colRangeWidthsMap=t}get _rowRangeHeightsMap(){return this.internalProps._rowRangeHeightsMap}set _rowRangeHeightsMap(t){this.internalProps._rowRangeHeightsMap=t}get rowHeightsMap(){return this.internalProps._rowHeightsMap}set rowHeightsMap(t){this.internalProps._rowHeightsMap=t}get colWidthsLimit(){return this.internalProps._colWidthsLimit}set colWidthsLimit(t){this.internalProps._colWidthsLimit=t}get keyboardOptions(){return this.internalProps.keyboardOptions??null}set keyboardOptions(t){this.internalProps.keyboardOptions=t??void 0}get widthMode(){return this._widthMode}set widthMode(t){t!==this._widthMode&&(this._widthMode=t,this.options.widthMode=t)}get heightMode(){return this._heightMode}set heightMode(t){t!==this._heightMode&&(this._heightMode=t,this.options.heightMode=t)}get autoFillWidth(){return this._autoFillWidth}set autoFillWidth(t){t!==this._autoFillWidth&&(this._autoFillWidth=t)}_colWidthDefineToPxWidth(t){return"auto"===t?0:dj(this,t)}_getColWidthLimits(t){const e=this.colWidthsLimit[t];if(!e)return null;const i={};return e.min&&(i.min=dj(this,e.min),i.minDef=e.min),e.max&&(i.max=dj(this,e.max),i.maxDef=e.max),i}_adjustColWidth(t,e){const i=this._getColWidthLimits(t);return Math.max(function(t,e){return t?t.min&&t.min>e?t.min:t.max&&t.max<e?t.max:e:e}(i,e),0)}setPixelRatio(t){this.internalProps.pixelRatio=t,this.scenegraph.setPixelRatio(t)}_updateSize(){const{padding:t}=this;let e=0,i=0;if("browser"===hf.mode){const n=this.getElement(),r=n.parentElement?.offsetWidth??0,o=n.parentElement?.offsetHeight??0;n.style.width=r&&r-t.left-t.right+"px"||"0px",n.style.height=o&&o-t.top-t.bottom+"px"||"0px";const{canvas:s}=this.internalProps;e=s.parentElement?.offsetWidth??0,i=s.parentElement?.offsetHeight??0,this?.scenegraph?.stage?this.scenegraph.stage.resize(e,i):(s.style.width="",s.style.height="",s.width=e,s.height=i,s.style.width=`${e}px`,s.style.height=`${i}px`)}else"node"===hf.mode&&(e=this.canvasWidth-1,i=this.canvasHeight-1);const n=Math.floor(e-Fu(this.getTheme().scrollStyle)),r=Math.floor(i-Fu(this.getTheme().scrollStyle));if(this.internalProps.theme?.frameStyle){const t=CU(this.internalProps.theme.frameStyle?.borderLineWidth??[null]),e=CU(this.internalProps.theme.frameStyle?.shadowBlur??[0]);this.tableX=(t[3]??0)+(e[3]??0),this.tableY=(t[0]??0)+(e[0]??0),this.tableNoFrameWidth=n-((t[1]??0)+(e[1]??0))-((t[3]??0)+(e[3]??0)),this.tableNoFrameHeight=r-((t[0]??0)+(e[0]??0))-((t[2]??0)+(e[2]??0))}}get rowHierarchyType(){return"grid"}setColWidths(t){t.forEach(((t,e)=>this.setColWidth(e,t)))}getColsWidth(t,e){e=Math.min(e,this.colCount-1);const i=this._colRangeWidthsMap.get(`$${t}$${e}`);if(null!=i)return i;const n=this._colRangeWidthsMap.get(`$${t}$${e-1}`);if(null!=n){const i=n+this.getColWidth(e);return t>=0&&e>=0&&!Number.isNaN(i)&&this._colRangeWidthsMap.set(`$${t}$${e}`,Math.round(i)),Math.round(i)}let r=0;for(let i=t;i<=e;i++)r+=this.getColWidth(i);return t>=0&&e>=0&&this._colRangeWidthsMap.set(`$${t}$${e}`,Math.round(r)),Math.round(r)}getRowHeight(t){return this.rowHeightsMap.get(t)?this.rowHeightsMap.get(t):this.isColumnHeader(0,t)||this.isCornerHeader(0,t)?Array.isArray(this.defaultHeaderRowHeight)?this.defaultHeaderRowHeight[t]??this.internalProps.defaultRowHeight:this.defaultHeaderRowHeight:this.isBottomFrozenRow(this.rowHeaderLevelCount,t)?Array.isArray(this.defaultHeaderRowHeight)?this.defaultHeaderRowHeight[this.columnHeaderLevelCount-this.bottomFrozenRowCount]??this.internalProps.defaultRowHeight:this.defaultHeaderRowHeight:this.internalProps.defaultRowHeight}setRowHeight(t,e,i){this.rowHeightsMap.put(t,Math.round(e)),i&&this._clearRowRangeHeightsMap(t)}getRowsHeight(t,e){const i=this._rowRangeHeightsMap.get(`$${t}$${e}`);if(null!=i)return i;const n=this._rowRangeHeightsMap.get(`$${t}$${e-1}`);if(null!=n){const i=Math.round(n+(this.rowHeightsMap.get(e)??(this.isColumnHeader(0,e)||this.isCornerHeader(0,e)?Array.isArray(this.defaultHeaderRowHeight)?this.defaultHeaderRowHeight[e]??this.internalProps.defaultRowHeight:this.defaultHeaderRowHeight:this.internalProps.defaultRowHeight)));return t>=0&&e>=0&&this._rowRangeHeightsMap.set(`$${t}$${e}`,Math.round(i)),i}let r=0;if("standard"===this.heightMode&&this.internalProps.layoutMap&&e>=this.columnHeaderLevelCount&&!this.bottomFrozenRowCount&&!this.hasAutoImageColumn()){for(let e=t;e<this.columnHeaderLevelCount;e++)r+=this.getRowHeight(e);r+=this.defaultRowHeight*(e-Math.max(this.columnHeaderLevelCount,t)+1)}else for(let i=t;i<=e;i++)r+=this.getRowHeight(i);return t>=0&&e>=0&&r>0&&this._rowRangeHeightsMap.set(`$${t}$${e}`,Math.round(r)),Math.round(r)}getColWidthDefined(t){const{layoutMap:e}=this.internalProps;if("autoWidth"===this.widthMode)return"auto";const{width:i}=e?.getColumnWidthDefined(t)??{};return"number"==typeof i&&i<=0?0:i||(this.isRowHeader(t,0)||this.isCornerHeader(t,0)?Array.isArray(this.defaultHeaderColWidth)?this.defaultHeaderColWidth[t]??this.defaultColWidth:this.defaultHeaderColWidth:this.isRightFrozenColumn(t,this.columnHeaderLevelCount)&&this.isPivotTable()?Array.isArray(this.defaultHeaderColWidth)?this.defaultHeaderColWidth[this.rowHeaderLevelCount-this.rightFrozenColCount]??this.defaultColWidth:this.defaultHeaderColWidth:this.defaultColWidth)}getColWidth(t){const e=this.colWidthsMap.get(t)??0;return"adaptive"===this.widthMode&&"number"==typeof e||this.transpose&&"number"==typeof e?this._colWidthDefineToPxWidth(e):this._adjustColWidth(t,this._colWidthDefineToPxWidth(e))}setColWidth(t,e,i,n){this.colWidthsMap.put(t,"number"==typeof e?Math.round(e):e),i&&this._clearColRangeWidthsMap(t),n||this.stateManeger.checkFrozen()}_clearColRangeWidthsMap(t){if("number"!=typeof t)this._colRangeWidthsMap.clear();else{const e=this._colRangeWidthsMap.keys();for(const i of e){const e=_U.exec(i);if(e){const n=Number(e[1]),r=Number(e[2]);t>=n&&t<=r&&this._colRangeWidthsMap.delete(i)}}}}_clearRowRangeHeightsMap(t){if("number"!=typeof t)this._rowRangeHeightsMap.clear();else{const e=this._rowRangeHeightsMap.keys();for(const i of e){const e=_U.exec(i);if(e){const n=Number(e[1]),r=Number(e[2]);t>=n&&t<=r&&this._rowRangeHeightsMap.delete(i)}}}}_getColContentWidth(t){return Number(this.colContentWidthsMap.get(t))}_setColContentWidth(t,e){this.colContentWidthsMap.put(t,e)}getAllRowsHeight(){if(this.internalProps.rowCount<=0)return 0;return this.getRowsHeight(0,this.internalProps.rowCount-1)}getAllColsWidth(){if(this.internalProps.colCount<=0)return 0;return this.getColsWidth(0,this.internalProps.colCount-1)}getMaxColWidth(t){const e=this.colWidthsLimit[t];let i=(e&&e.max)??1/0;return"string"==typeof i&&(i=dj(this,i)),i}setMaxColWidth(t,e){(this.colWidthsLimit[t]||(this.colWidthsLimit[t]={})).max=e}getMinColWidth(t){const e=this.colWidthsLimit[t];let i=(e&&e.min)??0;return"string"==typeof i&&(i=dj(this,i)),i}setMinColWidth(t,e){(this.colWidthsLimit[t]||(this.colWidthsLimit[t]={})).min=e}getCellRect(t,e){const i=this.isFrozenCell(t,e);let n=this.getColsWidth(0,t-1)||0;const r=this.getColWidth(t);i&&i.col&&(n+=this.scrollLeft);let o=this.getRowsHeight(0,e-1);const s=this.getRowHeight(e);return i&&i.row&&(o+=this.scrollTop),new gf(Math.round(n),Math.round(o),Math.round(r),Math.round(s))}getMergeCellRect(t,e){const i=this.getCellRange(t,e),n=this.getColsWidth(0,i.start.col-1)||0,r=this.getColsWidth(i.start.col,i.end.col),o=this.getRowsHeight(0,i.start.row-1)||0,s=this.getRowsHeight(i.start.row,i.end.row);return new gf(Math.round(n),Math.round(o),Math.round(r),Math.round(s))}getCellRelativeRect(t,e){return this._toRelativeRect(this.getCellRect(t,e))}getCellRangeRelativeRect(t){if(t.start)return this._toRelativeRect(this.getCellsRect(t.start.col,t.start.row,t.end.col,t.end.row));const e=this.getCellRange(t.col,t.row);return this._toRelativeRect(this.getCellsRect(e.start.col,e.start.row,e.end.col,e.end.row))}getVisibleCellRangeRelativeRect(t){let e;return e=t.start?t:this.getCellRange(t.col,t.row),this._getVisiableRect(this.getCellRangeRelativeRect(t),e)}_getVisiableRect(t,e){const i=e.start.col>=this.frozenColCount?Math.max(t.left,this.frozenColCount>=1?this.getColsWidth(0,this.frozenColCount-1):0):t.left,n=Math.min(t.right,this.tableNoFrameWidth),r=t.copy();r.left=i,r.right=n;const o=e.start.row>=this.frozenRowCount?Math.max(t.top,this.frozenRowCount>=1?this.getRowsHeight(0,this.frozenRowCount-1):0):t.top,s=Math.min(t.bottom,this.tableNoFrameHeight);return r.top=o,r.bottom=s,r}getCellsRect(t,e,i,n){const r=this.isFrozenCell(t,e),o=this.isFrozenCell(i,n);let s=this.getColsWidth(0,t-1)||0,a=this.getColsWidth(t,i);if(r&&r.col){const e=this.scrollLeft;s+=e,o&&o.col||(a-=e,a=Math.max(a,this.getColsWidth(t,this.frozenColCount-1)))}let l=this.getRowsHeight(0,e-1),h=this.getRowsHeight(e,n);if(r&&r.row){const t=this.scrollTop;l+=t,o&&o.row||(h-=t,h=Math.max(h,this.getRowsHeight(e,this.frozenRowCount-1)))}return new gf(Math.round(s),Math.round(l),Math.round(a),Math.round(h))}getCellsRectWidth(t,e,i,n){const r=this.isFrozenCell(t,e),o=this.isFrozenCell(i,n);let s=this.getColsWidth(t,i);if(r&&r.col){const e=this.scrollLeft;o&&o.col||(s-=e,s=Math.max(s,this.getColsWidth(t,this.frozenColCount-1)))}return s}getCellRangeRect(t){if(t.start)return this.getCellsRect(t.start.col,t.start.row,t.end.col,t.end.row);const e=this.getCellRange(t.col,t.row);return this.getCellsRect(e.start.col,e.start.row,e.end.col,e.end.row)}getCellRangeRectWidth(t){if(t.start)return this.getCellsRectWidth(t.start.col,t.start.row,t.end.col,t.end.row);const e=this.getCellRange(t.col,t.row);return this.getCellsRectWidth(e.start.col,e.start.row,e.end.col,e.end.row)}isFrozenCell(t,e){const{frozenRowCount:i,frozenColCount:n}=this.internalProps,r=i>0&&e<i||this.isBottomFrozenRow(t,e),o=n>0&&t<n||this.isRightFrozenColumn(t,e);return r||o?{row:r,col:o}:null}getRowAt(t){const e=function(t,e){if(!t.internalProps.frozenRowCount)return null;let{scrollTop:i}=t;const n=t.internalProps.frozenRowCount;for(let r=0;r<n;r++){const n=t.getRowHeight(r),o=i+n;if(o>e)return{top:i,row:r,bottom:o,height:n};i=o}return null}(this,t);if(e)return e;let i=this.getTargetRowAt(t);return i||(i={top:-1,row:-1,bottom:-1,height:-1}),i}getColAt(t){const e=function(t,e){if(!t.internalProps.frozenColCount)return null;let{scrollLeft:i}=t;const n=t.internalProps.frozenColCount;for(let r=0;r<n;r++){const n=t.getColWidth(r),o=i+n;if(o>e)return{left:i,col:r,right:o,width:n};i=o}return null}(this,t);if(e)return e;let i=this.getTargetColAt(t);return i||(i={left:-1,col:-1,right:-1,width:1}),i}getCellAt(t,e){const i=this.getRowAt(e),{row:n,top:r,bottom:o,height:s}=i,a=this.getColAt(t),{col:l,left:h,right:c,width:u}=a;return{row:n,col:l,rect:{left:h,right:c,top:r,bottom:o,width:u,height:s}}}_checkRowCol(t,e){return t>=0&&t<this.colCount&&e>=0&&e<this.rowCount}_makeVisibleCell(t,e){if(this._checkRowCol(t,e)){const i=this.isFrozenCell(t,e);if(i&&i.col&&i.row)return;const n=this.getCellRect(t,e),r=function(t){let e=0;t.internalProps.frozenColCount>0&&(e=t.getFrozenColsWidth());let i=0;return t.internalProps.frozenRowCount>0&&(i=t.getFrozenRowsHeight()),new gf(t.scrollLeft+e,t.scrollTop+i,t.tableNoFrameWidth-e,t.tableNoFrameHeight-i)}(this);if(r.contains(n))return;i&&i.col||this.getColsWidth(0,this.frozenColCount-1)+n.width>this.canvas.width||(n.left<r.left?this.scrollLeft-=r.left-n.left:r.right<n.right&&(this.scrollLeft-=r.right-n.right)),i&&i.row||this.getRowsHeight(0,this.frozenRowCount-1)+n.height>this.canvas.height||(n.top<r.top?this.scrollTop-=r.top-n.top:r.bottom<n.bottom&&(this.scrollTop-=r.bottom-n.bottom))}}render(){this.scenegraph.renderSceneGraph()}_toRelativeRect(t){const e=t.copy(),i=this.getVisibleRect();return e.offsetLeft(-i.left),e.offsetTop(-i.top),e}getVisibleRect(){const{scrollTop:t,scrollLeft:e}=this,i=this.tableNoFrameWidth,n=this.tableNoFrameHeight;return new gf(e,t,i,n)}get visibleRowCount(){const{frozenRowCount:t}=this,e=this.getVisibleRect(),i=t>0?e.top+this.getRowsHeight(0,t-1):e.top,n=this.getTargetRowAt(i);if(!n)return 0;const r=Math.max(n.top>=i?n.row:n.row+1,t);let o=this.getRowsHeight(0,r-1),s=0;const{rowCount:a}=this;for(let t=r;t<a;t++){const i=o+this.getRowHeight(t);if(e.bottom<i)break;s++,o=i}return s}get visibleColCount(){const{frozenColCount:t}=this,e=this.getVisibleRect(),i=t>0?e.left+this.getColsWidth(0,t-1):e.left,n=this.getTargetColAt(i);if(!n)return 0;const r=Math.max(n.left>=i?n.col:n.col+1,t);let o=this.getColsWidth(0,r-1),s=0;const{colCount:a}=this;for(let t=r;t<a;t++){const i=o+this.getColWidth(t);if(e.right<i)break;s++,o=i}return s}get scrollTop(){return this.stateManeger.scroll.verticalBarPos}set scrollTop(t){this.stateManeger.setScrollTop(t)}get scrollLeft(){return this.stateManeger.scroll.horizontalBarPos}set scrollLeft(t){this.stateManeger.setScrollLeft(t)}getScrollLeft(){return this.scrollLeft}getScrollTop(){return this.scrollTop}setScrollLeft(t){this.scrollLeft=Math.ceil(t)}setScrollTop(t){this.scrollTop=Math.ceil(t)}getCellOverflowText(t,e){return this.scenegraph.getCellOverflowText(t,e)}addReleaseObj(t){if(!t||!t.release||"function"!=typeof t.release)throw new Error("not releaseObj!");(this.internalProps.releaseList=this.internalProps.releaseList||[]).push(t)}dispose(){this.release()}release(){const t=this.internalProps;t.tooltipHandler?.release?.(),t.menuHandler?.release?.(),gj.clearAll(),super.release?.(),t.handler?.release?.(),t.focusControl?.release?.(),t.releaseList&&(t.releaseList.forEach((t=>t?.release?.())),t.releaseList=null),this.scenegraph.stage.release();const{parentElement:e}=t.element;e&&e.removeChild(t.element)}fireListeners(t,e){return super.fireListeners(t,e)}updateOption(t){this.options=t;const{frozenColCount:e=0,defaultRowHeight:i=40,defaultHeaderRowHeight:n,defaultColWidth:r=80,defaultHeaderColWidth:o=80,keyboardOptions:s,columnResizeMode:a,dragHeaderMode:l,showFrozenIcon:h,allowFrozenColCount:c,padding:u,hover:d,menu:p,select:f,pixelRatio:g,widthMode:m,heightMode:y,autoFillWidth:b,customRender:v,renderChartAsync:w,renderChartAsyncBatchCount:C}=t;g&&g!==this.internalProps.pixelRatio&&(this.internalProps.pixelRatio=g),u&&("number"==typeof u?(this.padding.top=u,this.padding.left=u,this.padding.bottom=u,this.padding.right=u):(u.top&&(this.padding.top=u.top),u.bottom&&(this.padding.bottom=u.bottom),u.left&&(this.padding.left=u.left),u.right&&(this.padding.right=u.right))),this.showFrozenIcon="boolean"!=typeof h||h,"number"==typeof c&&c<=0&&(this.showFrozenIcon=!1),this.widthMode=m??"standard",this.heightMode=y??"standard",this.autoFillWidth=b??!1,this.customRender=v;const x=this.internalProps;"node"!==hf.mode&&function(t,e){t.style.margin=`${e.top}px ${e.right}px ${e.bottom}px ${e.left}px`;const i=(t.offsetWidth||t.parentElement?.offsetWidth||1)-1,n=(t.offsetHeight||t.parentElement?.offsetHeight||1)-1;t.style.width=i&&i-e.left-e.right+"px"||"0px",t.style.height=n&&n-e.top-e.bottom+"px"||"0px"}(x.element,this.padding),x.frozenColCount=e,x.defaultRowHeight=i,x.defaultHeaderRowHeight=n??i,x.defaultColWidth=r,x.defaultHeaderColWidth=o??r,x.keyboardOptions=s,x.columnResizeMode=a,x.dragHeaderMode=l,x.renderChartAsync=w,sN(C),x.cellTextOverflows={},x._rowHeightsMap=new ff,x._rowRangeHeightsMap=new Map,x._colRangeWidthsMap=new Map,x._widthResizedColMap=new Set,this.colWidthsMap=new ff,this.colContentWidthsMap=new ff,this.colWidthsLimit={},x.theme=Ff.of(t.theme??Ff.DEFAULT),x.autoWrapText=t.autoWrapText,x.allowFrozenColCount=t.allowFrozenColCount??x.colCount,x.limitMaxAutoWidth=t.limitMaxAutoWidth??450,this._vDataSet=new jz,x.legends?.release(),x.title?.release(),x.layoutMap.release(),this.scenegraph.clearCells(),this.stateManeger.initState(),this._updateSize(),t.legends&&(x.legends=vU(t.legends,this),this.scenegraph.tableGroup.setAttributes({x:this.tableX,y:this.tableY})),t.title&&(x.title=new wU(t.title,this),this.scenegraph.tableGroup.setAttributes({x:this.tableX,y:this.tableY})),x.tooltip=Object.assign({renderMode:"html",isShowOverflowTextTooltip:!1,confine:!0},t.tooltip),"html"!==x.tooltip.renderMode||x.tooltipHandler||(x.tooltipHandler=new qV(this,x.tooltip.confine)),x.menu=Object.assign({renderMode:"html"},t.menu),"html"!==x.menu.renderMode||x.menuHandler||(x.menuHandler=new lU(this)),this.headerStyleCache=new Map,this.bodyStyleCache=new Map,this.clearColWidthCache(),this.clearRowHeightCache()}renderWithRecreateCells(){this.refreshHeader(),this.scenegraph.clearCells(),this.headerStyleCache=new Map,this.bodyStyleCache=new Map,this.scenegraph.createSceneGraph(),this.render()}getFrozenRowsHeight(){return this.getRowsHeight(0,this.frozenRowCount-1)}getFrozenColsWidth(){return this.getColsWidth(0,this.frozenColCount-1)}getBottomFrozenRowsHeight(){if(this.bottomFrozenRowCount>0){return this.getRowsHeight(this.rowCount-this.bottomFrozenRowCount,this.rowCount-1)}return 0}getRightFrozenColsWidth(){if(this.rightFrozenColCount>0){return this.getColsWidth(this.colCount-this.rightFrozenColCount,this.colCount-1)}return 0}getDrawRange(){const t=Math.min(this.tableNoFrameWidth,this.getAllColsWidth()),e=Math.min(this.tableNoFrameHeight,this.getAllRowsHeight());return new gf(this.tableX,this.tableY,t,e)}_getMouseAbstractPoint(t,e=!0){const i=this;let n;if(!t)return{inTable:!1,x:void 0,y:void 0};n=xU(t)?t.changedTouches[0]:t;const r=n.clientX||n.pageX+window.scrollX,o=n.clientY||n.pageY+window.scrollY,s=i.internalProps.canvas.getBoundingClientRect();let a=!0;s.right<=r&&(a=!1),s.bottom<=o&&(a=!1);const l=s.width,h=l/(this.canvas.offsetWidth||l),c=s.height,u=c/(this.canvas.offsetHeight||c);return{x:(r-s.left)/h+(e?i.scrollLeft:0)-i.tableX,y:(o-s.top)/u+(e?i.scrollTop:0)-i.tableY,inTable:a}}getTheme(){return this.internalProps.theme}getTargetColAt(t){if(0===t)return{left:0,col:0,right:0,width:0};const e=(e,i)=>{let n=i-this.getColWidth(e);const{colCount:r}=this.internalProps;for(let i=e;i<r;i++){const e=this.getColWidth(i),r=n+e;if(Math.round(n)<=Math.round(t)&&Math.round(t)<Math.round(r))return{left:n,col:i,right:r,width:e};n=r}return null},i=this.computeTargetColByX(t),n=this.getColsWidth(0,i);return t>=n?e(i,n):((e,i)=>{let n=i;for(let i=e;i>=0;i--){const e=this.getColWidth(i),r=n-e;if(Math.round(r)<=Math.round(t)&&Math.round(t)<Math.round(n))return{left:r,col:i,right:n,width:e};n=r}return null})(i,n)}getTargetRowAt(t){if(0===t)return{top:0,row:0,bottom:0,height:0};const e=(e,i)=>{let n=i-this.getRowHeight(e);const{rowCount:r}=this.internalProps;for(let i=e;i<r;i++){const e=this.getRowHeight(i),r=n+e;if(Math.round(n)<=Math.round(t)&&Math.round(t)<Math.round(r))return{top:n,row:i,bottom:r,height:e};n=r}return null},i=this.computeTargetRowByY(t),n=this.getRowsHeight(0,i);return t>=n?e(i,n):((e,i)=>{let n=i;for(let i=e;i>=0;i--){const e=this.getRowHeight(i),r=n-e;if(Math.round(r)<=Math.round(t)&&Math.round(t)<Math.round(n))return{top:r,row:i,bottom:n,height:e};n=r}return null})(i,n)}computeTargetRowByY(t){if(this._rowRangeHeightsMap.get("$0$"+(this.rowCount-1))){let e=0,i=this.rowCount-1;for(;i-e>1;){const n=Math.floor((e+i)/2);if(t<this._rowRangeHeightsMap.get(`$0$${n}`))i=n;else{if(!(t>this._rowRangeHeightsMap.get(`$0$${n}`)))return n;e=n}}return i}return Math.min(Math.ceil(t/this.internalProps.defaultRowHeight),this.rowCount-1)}computeTargetColByX(t){if(this._colRangeWidthsMap.get("$0$"+(this.colCount-1))){let e=0,i=this.colCount-1;for(;i-e>1;){const n=Math.floor((e+i)/2);if(t<this._colRangeWidthsMap.get(`$0$${n}`))i=n;else{if(!(t>this._colRangeWidthsMap.get(`$0$${n}`)))return n;e=n}}return i}return Math.min(Math.ceil(t/this.internalProps.defaultColWidth),this.colCount-1)}clearSelected(){this.stateManeger.updateSelectPos(-1,-1)}selectCell(t,e){this.stateManeger.updateSelectPos(t,e),this.stateManeger.endSelectCells()}get allowFrozenColCount(){return this.internalProps.allowFrozenColCount}get rowHeaderLevelCount(){return this.internalProps.layoutMap.rowHeaderLevelCount}get columnHeaderLevelCount(){return this.internalProps.layoutMap.columnHeaderLevelCount}get records(){return this.internalProps.records}get dataSource(){return this.internalProps.dataSource}set dataSource(t){this.scenegraph.clearCells(),uj(this,t),this.refreshRowColCount(),this.scenegraph.createSceneGraph(),this.render()}get autoWrapText(){return this.internalProps.autoWrapText}set autoWrapText(t){this.internalProps.autoWrapText=t,this.options.autoWrapText=t}updateAutoWrapText(t){this.internalProps.autoWrapText!==t&&(this.internalProps.autoWrapText=t,this.options.autoWrapText=t,this.scenegraph.clearCells(),this.headerStyleCache=new Map,this.bodyStyleCache=new Map,this.scenegraph.createSceneGraph(),this.render())}get theme(){return this.internalProps.theme}set theme(t){this.internalProps.theme=Ff.of(t??Ff.DEFAULT),this.options.theme=t}updateTheme(t){this.internalProps.theme=Ff.of(t??Ff.DEFAULT),this.options.theme=t,this.scenegraph.clearCells(),this.headerStyleCache=new Map,this.bodyStyleCache=new Map,this.scenegraph.createSceneGraph(),this.render()}getBodyField(t,e){return this.internalProps.layoutMap.getBody(t,e).field}getBodyColumnDefine(t,e){const i=this.internalProps.layoutMap.getBody(t,e);return i?.define}getBodyColumnType(t,e){return this.internalProps.layoutMap.getBody(t,e).cellType}getHeaderField(t,e){return this.internalProps.layoutMap.getHeaderField(t,e)}getHeaderFieldKey(t,e){return this.internalProps.layoutMap.getHeaderFieldKey(t,e)}getHeaderDefine(t,e){const i=this.internalProps.layoutMap.getHeader(t,e);return i?.define}getCellLocation(t,e){return this.internalProps.layoutMap.getCellLocation(t,e)}getCellHeaderPaths(t,e){return this.internalProps.layoutMap.getCellHeaderPaths(t,e)}getHeadersDefine(t,e){const i=[];for(;;){const n=this.getHeaderDefine(t,e);if(!n||!n.field&&!n.columns)break;i.push(n),e++}return i}_getHeaderLayoutMap(t,e){return this.internalProps.layoutMap.getHeader(t,e)}_getBodyLayoutMap(t,e){return this.internalProps.layoutMap.getBody(t,e)}getContext(){return this.internalProps.context}getRecordByRowCol(t,e){if(!this.internalProps.layoutMap.isHeader(t,e))return this.internalProps.dataSource?.get(this.getRecordIndexByRow(t,e))}getRecordStartRowByRecordIndex(t){return this.internalProps.layoutMap.getRecordStartRowByRecordIndex(t)}_getHeaderCellBySortState(t){const{layoutMap:e}=this.internalProps;let i;if(i=t.fieldKey?e.headerObjects.find((e=>e&&e.fieldKey===t.fieldKey)):e.headerObjects.find((e=>e&&e.field===t.field)),i){return e.getHeaderCellAdress(i.id)}}getCellRange(t,e){return this.internalProps.layoutMap.getCellRange(t,e)}isCellRangeEqual(t,e,i,n){return this.internalProps.layoutMap.isCellRangeEqual(t,e,i,n)}_getLayoutCellId(t,e){return this.internalProps.layoutMap.getCellId(t,e)}getHeaderDescription(t,e){const i=this._getHeaderLayoutMap(t,e),n=i?.define,r=n?.description??i?.description;if("function"==typeof r){return r({col:t,row:e,value:this.getCellValue(t,e),dataValue:this.getCellOriginValue(t,e)})}return r}setRecords(t,e){const i="undefined"!=typeof window?window.performance.now():0;if(this.scenegraph.clearCells(),void 0!==e&&(this.internalProps.sortState=e,this.stateManeger.setSortState(this.sortState)),t){if(cj(this,t),this.sortState){let t,e,i;if(Array.isArray(this.sortState)?0!==this.sortState.length&&({order:t,field:e,fieldKey:i}=this.sortState?.[0]):({order:t,field:e,fieldKey:i}=this.sortState),t&&e&&"normal"!==t){const n=this._getSortFuncFromHeaderOption(void 0,e,i);let r;r=i?this.internalProps.layoutMap.headerObjects.find((t=>t&&t.fieldKey===i)):this.internalProps.layoutMap.headerObjects.find((t=>t&&t.field===e)),r?.define?.sort&&this.dataSource.sort(r.field,t,n??Cu)}}this.refreshRowColCount()}else cj(this,t);this.scenegraph.createSceneGraph(),this.render(),console.log("setRecords cost time:",("undefined"!=typeof window?window.performance.now():0)-i)}setRecord(t,e,i){const n=this.getRecordIndexByRow(e,i);this.dataSource.setRecord(t,n)}setDropDownMenuHighlight(t){this.stateManeger.setDropDownMenuHighlight(t)}_dropDownMenuIsHighlight(t,e,i){return this.stateManeger.dropDownMenuIsHighlight(t,e,i)}isHeader(t,e){return this.internalProps.layoutMap&&this.internalProps.layoutMap.isHeader(t,e)}isColumnHeader(t,e){return this.internalProps.layoutMap?.isColumnHeader(t,e)}isRowHeader(t,e){return this.internalProps.layoutMap?.isRowHeader(t,e)}isCornerHeader(t,e){return this.internalProps.layoutMap?.isCornerHeader(t,e)}isRightFrozenColumn(t,e){return this.internalProps.layoutMap?.isRightFrozenColumn(t,e)}isBottomFrozenRow(t,e){return this.internalProps.layoutMap?.isBottomFrozenRow(t,e)}getCellInfo(t,e){const i=this.isHeader(t,e)?this.getHeaderDefine(t,e):this.getBodyColumnDefine(t,e);return{col:t,row:e,field:this.getHeaderField(t,e),cellHeaderPaths:this.internalProps.layoutMap.getCellHeaderPaths(t,e),title:i.title,cellType:i.cellType?"string"==typeof i.cellType?i.cellType:"progressbar":"text",originData:this.getCellOriginRecord(t,e),cellRange:this.getCellRangeRelativeRect({col:t,row:e}),value:this.getCellValue(t,e),dataValue:this.getCellOriginValue(t,e),cellLocation:this.getCellLocation(t,e),scaleRatio:this.canvas.getBoundingClientRect().width/this.canvas.offsetWidth}}_hasField(t,e,i){if(null==t)return!1;const n=this;if(n.internalProps.layoutMap.isHeader(e,i))return!1;const r=n.getRecordIndexByRow(e,i);return n.internalProps.dataSource.hasField(r,t)}_getCellStyle(t,e){const{layoutMap:i}=this.internalProps;if(i.isHeader(t,e)){let n=this.headerStyleCache.get(`${t}-${e}`);if(n)return n;const r=i.getHeader(t,e);if(!r||r.isEmpty)return SU;const o=this.internalProps.headerHelper.getStyleClass(r.headerType);if(i.isBottomFrozenRow(t,e)&&this.theme.bottomFrozenStyle)n=Du({},this.theme.bottomFrozenStyle,{col:t,row:e,table:this,value:this.getCellValue(t,e),dataValue:this.getCellOriginValue(t,e),cellHeaderPaths:this.getCellHeaderPaths(t,e)},o,this.options.autoWrapText);else if(i.isRightFrozenColumn(t,e)&&this.theme.rightFrozenStyle)n=Du({},this.theme.rightFrozenStyle,{col:t,row:e,table:this,value:this.getCellValue(t,e),dataValue:this.getCellOriginValue(t,e),cellHeaderPaths:this.getCellHeaderPaths(t,e)},o,this.options.autoWrapText);else{const{style:s}=r;n=Du(s,i.isColumnHeader(t,e)||i.isBottomFrozenRow(t,e)?this.theme.headerStyle:i.isRowHeader(t,e)||i.isRightFrozenColumn(t,e)?this.theme.rowHeaderStyle:this.theme.cornerHeaderStyle,{col:t,row:e,table:this,value:this.getCellValue(t,e),dataValue:this.getCellOriginValue(t,e),cellHeaderPaths:this.getCellHeaderPaths(t,e)},o,this.options.autoWrapText)}return this.headerStyleCache.set(`${t}-${e}`,n),n}let n;n=this.isListTable()&&!this.transpose||this.isPivotTable()&&this.internalProps.layoutMap.indicatorsAsCol?t:e;let r=this.bodyStyleCache.get(n);if(r)return r;const o=i.getBody(t,e),s=this.internalProps.bodyHelper.getStyleClass(o.cellType),a=o?.style;return r=Hu(a,this.theme.bodyStyle,{col:t,row:e,table:this,value:this.getCellValue(t,e),dataValue:this.getCellOriginValue(t,e),cellHeaderPaths:this.getCellHeaderPaths(t,e)},s,this.options.autoWrapText),Gu(a)||this.bodyStyleCache.set(n,r),r}clearCellStyleCache(){this.headerStyleCache.clear()}clearRowHeightCache(){this.internalProps._rowHeightsMap.clear(),this._clearRowRangeHeightsMap()}clearColWidthCache(){this.internalProps._colWidthsMap.clear(),this._clearColRangeWidthsMap()}_canResizeColumn(t,e){if(!(t>=0&&e>=0))return!1;if(this.isCellRangeEqual(t,e,t+1,e))return!1;if("none"===this.internalProps.columnResizeMode)return!1;if("header"===this.internalProps.columnResizeMode){if(!this.isHeader(t,e))return!1}else if("body"===this.internalProps.columnResizeMode&&this.isHeader(t,e))return!1;const i=this.colWidthsLimit[t];return!(i&&i.min&&i.max)||i.max!==i.min}_canDragHeaderPosition(t,e){if(this.isHeader(t,e)&&this.stateManeger.isSelected(t,e)){const i=this.stateManeger.select.ranges[0];if(this.isColumnHeader(t,e)){if(i.end.row!==this.rowCount-1)return!1}else{if(!this.isRowHeader(t,e))return!1;if(i.end.col!==this.colCount-1)return!1}const n=this.getHeaderDefine(t,e);if(void 0===n.dragHeader){if("all"===this.internalProps.dragHeaderMode)return!0;if("column"===this.internalProps.dragHeaderMode){if(this.isColumnHeader(t,e))return!0}else if("row"===this.internalProps.dragHeaderMode&&this.isRowHeader(t,e))return!0;return!1}return n.dragHeader}return!1}getCellIcons(t,e){let i;if(this.isHeader(t,e))i=this.internalProps.headerHelper.getIcons(t,e);else{const n=this.getCellValue(t,e),r=this.getCellOriginValue(t,e),o=this.internalProps.context;i=this.internalProps.bodyHelper.getIcons(t,e,n,r,o)}return i}showDropDownMenu(t,e,i){let n="dropdown-menu";i&&(n=Array.isArray(i.content)?"dropdown-menu":"container"),"html"===this.internalProps.menu.renderMode&&(this.stateManeger.menu.isShow=!0,this.internalProps.menuHandler._bindToCell(t,e,n,i))}showTooltip(t,e,i){"html"===this.internalProps.tooltip.renderMode&&this.internalProps.tooltipHandler._bindToCell(t,e,i)}getCellStyle(t,e){const i=this._getCellStyle(t,e),n=pj(i,this,t,e,Cj).theme,{autoWrapText:r,lineClamp:o,textOverflow:s}=i;return{textAlign:n.text.textAlign,textBaseline:n.text.textBaseline,bgColor:Nu(n.group.fill)?Cj("bgColor",i,t,e,this):n.group.fill,color:Nu(n.text.fill)?Cj("color",i,t,e,this):n.text.fill,fontFamily:n.text.fontFamily,fontSize:n.text.fontSize,fontWeight:n.text.fontWeight,fontVariant:n.text.fontVariant,fontStyle:n.text.fontStyle,lineHeight:n.text.lineHeight,autoWrapText:r??!1,lineClamp:o??"auto",textOverflow:s,borderColor:Nu(n.group.stroke)?Cj("borderColor",i,t,e,this):n.group.stroke,borderLineWidth:n.group.lineWidth,borderLineDash:n.group.lineDash,underline:!!n.text.underline,lineThrough:!!n.text.lineThrough,padding:n._vtable.padding,underlineWidth:n.text.underline,lineThroughLineWidth:n.text.lineThrough}}getAllBodyCells(t,e){const i=this.rowHeaderLevelCount,n=this.columnHeaderLevelCount,r=this.colCount-1,o=this.rowCount-1;return Array(Math.min(e??2e3,o-n+1,this.rowCount)).fill(0).map(((e,o)=>Array(Math.min(t??2e3,r-i+1,this.colCount)).fill(0).map(((t,e)=>this.getCellInfo(e+i,o+n)))))}getAllCells(t,e){const i=0,n=0,r=this.colCount-1,o=this.rowCount-1;return Array(Math.min(e??2e3,o-n+1,this.rowCount)).fill(0).map(((e,o)=>Array(Math.min(t??2e3,r-i+1,this.colCount)).fill(0).map(((t,e)=>this.getCellInfo(e+i,o+n)))))}getAllColumnHeaderCells(){const t=this.rowHeaderLevelCount,e=0,i=this.colCount-1,n=this.columnHeaderLevelCount-1;return Array(n-e+1).fill(0).map(((n,r)=>Array(i-t+1).fill(0).map(((i,n)=>this.getCellInfo(n+t,r+e)))))}getAllRowHeaderCells(){const t=0,e=this.columnHeaderLevelCount,i=this.rowHeaderLevelCount-1,n=this.rowCount-1;return Array(n-e+1).fill(0).map(((n,r)=>Array(i-t+1).fill(0).map(((i,n)=>this.getCellInfo(n+t,r+e)))))}scrollToCell(t){const e=this.getDrawRange();if(bu(t.col)&&t.col>=this.frozenColCount){const i=this.getFrozenColsWidth(),n=this.getColsWidth(0,t.col-1);this.scrollLeft=Math.min(n-i,this.getAllColsWidth()-e.width)}if(bu(t.row)&&t.row>=this.frozenRowCount){const i=this.getFrozenRowsHeight(),n=this.getRowsHeight(0,t.row-1);this.scrollTop=Math.min(n-i,this.getAllRowsHeight()-e.height)}this.render()}getCopyValue(){const t=this.stateManeger.select.ranges;let e=Math.min(t[0].start.col,t[0].end.col),i=Math.max(t[0].start.col,t[0].end.col),n=Math.min(t[0].start.row,t[0].end.row),r=Math.max(t[0].start.row,t[0].end.row);t.forEach((t=>{e=Math.min(e,t.start.col,t.end.col),i=Math.max(i,t.start.col,t.end.col),n=Math.min(n,t.start.row,t.end.row),r=Math.max(r,t.start.row,t.end.row)}));const o=e=>{let i=!1;return t.forEach((t=>{const n=Math.min(t.start.row,t.end.row),r=Math.max(t.start.row,t.end.row);n<=e&&r>=e&&(i=!0)})),i},s=e=>{let i=!1;return t.forEach((t=>{const n=Math.min(t.start.col,t.end.col),r=Math.max(t.start.col,t.end.col);n<=e&&r>=e&&(i=!0)})),i},a=(e,i)=>{let n;return t.forEach((t=>{const r=Math.min(t.start.row,t.end.row),o=Math.max(t.start.row,t.end.row),s=Math.min(t.start.col,t.end.col),a=Math.max(t.start.col,t.end.col);s<=e&&a>=e&&r<=i&&o>=i&&(n=t)})),n},l=(t,e,i)=>{const n=this.getCellRange(t,e);let r=n.start.col,o=n.start.row;if(i){const t=Math.min(i.start.col,i.end.col),e=Math.min(i.start.row,i.end.row);r=Math.max(t,n.start.col),o=Math.max(e,n.start.row)}if(r!==t||o!==e)return"";return this.getCellValue(t,e)};let h="";for(let t=n;t<=r;t++){if(o(t)){for(let n=e;n<=i;n++){if(s(n)){const e=a(n,t);if(e){const r=l(n,t,e);if("undefined"!=typeof Promise&&r instanceof Promise);else{const t=`${r}`;/^\[object .*\]$/.exec(t)||(h+=t)}(n<e.end.col||n<i)&&(h+="\t")}else h+="\t"}}h+="\n"}}return h}getSelectedCellInfos(){const t=this.stateManeger.select.ranges;let e=Math.min(t[0].start.col,t[0].end.col),i=Math.max(t[0].start.col,t[0].end.col),n=Math.min(t[0].start.row,t[0].end.row),r=Math.max(t[0].start.row,t[0].end.row);t.forEach((t=>{e=Math.min(e,t.start.col,t.end.col),i=Math.max(i,t.start.col,t.end.col),n=Math.min(n,t.start.row,t.end.row),r=Math.max(r,t.start.row,t.end.row)}));const o=e=>{let i=!1;return t.forEach((t=>{const n=Math.min(t.start.row,t.end.row),r=Math.max(t.start.row,t.end.row);n<=e&&r>=e&&(i=!0)})),i},s=e=>{let i=!1;return t.forEach((t=>{const n=Math.min(t.start.col,t.end.col),r=Math.max(t.start.col,t.end.col);n<=e&&r>=e&&(i=!0)})),i},a=(e,i)=>{let n;return t.forEach((t=>{const r=Math.min(t.start.row,t.end.row),o=Math.max(t.start.row,t.end.row),s=Math.min(t.start.col,t.end.col),a=Math.max(t.start.col,t.end.col);s<=e&&a>=e&&r<=i&&o>=i&&(n=t)})),n},l=[];for(let t=n;t<=r;t++){if(o(t)){const n=[];for(let r=e;r<=i;r++){if(s(r)){if(a(r,t)){const e=this.getCellInfo(r,t);n.push(e)}}}l.push(n)}}return l}measureText(t,e){return QV.measureText(t,e)}getCustomRender(t,e){let i;if("body"!==this.getCellLocation(t,e)){const n=this.getHeaderDefine(t,e);i=n?.headerCustomRender}else{const n=this.getBodyColumnDefine(t,e);i=n?.customRender||this.customRender}return i}getCustomLayout(t,e){let i;if("body"!==this.getCellLocation(t,e)){const n=this.getHeaderDefine(t,e);i=n?.headerCustomLayout}else{const n=this.getBodyColumnDefine(t,e);i=n?.customLayout}return i}hasAutoImageColumn(){return this.internalProps.layoutMap.columnObjects.find((t=>!("image"!==t.cellType||!t.define.imageAutoSizing)))}_getActiveChartInstance(){const t=this.scenegraph.getCell(this.stateManeger.hover?.cellPos?.col,this.stateManeger.hover?.cellPos?.row);return"chart"===t?.getChildren()?.[0]?.type?t.getChildren()[0].activeChartInstance:null}cellIsInVisualView(t,e){const i=this.getDrawRange(),n=this.getCellRelativeRect(t,e);return t<this.frozenColCount&&e<this.frozenRowCount||n.top>=i.top&&n.bottom<=i.bottom&&n.left>=i.left&&n.right<=i.right}exportImg(){return this.scenegraph.stage.toCanvas().toDataURL()}exportCellImg(t,e){this.cellIsInVisualView(t,e)||this.scrollToCell({col:t,row:e});const i=this.getCellRelativeRect(t,e);return this.scenegraph.stage.toCanvas(!1,(new ip).set(i.left+this.tableX+1,i.top+this.tableY+1,i.right+this.tableX,i.bottom+this.tableY)).toDataURL()}}var TU=Object.freeze({__proto__:null,BaseTable:AU});function BU(t,e,i){const n=t[e];return t[e]=i,n}function MU(t){for(const e in t)delete t[e]}function RU(){MU(Cf),MU(fj),MU($N)}var PU=Object.freeze({__proto__:null,chartModule:function(t,e){return null!=e?BU($N,t,e):$N[t]},clearAll:RU,icon:function(t,e){return null!=e?BU(fj,t,e):fj[t]},theme:function(t,e){return null!=e?BU(Cf,t,e):Cf[t]}});var EU=Object.freeze({__proto__:null,dateFormat:function(t,e,i,n,r){null==i&&(i=!1),null==n&&(n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]),null==r&&(r=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]);const o=i?"UTC":"",s=function(t){return`0${t}`.substring(0,2)};return function(i){const a=new Date(Date.parse(i[t]));return e.replace(/%(.)/g,(function(t,e){switch(e){case"y":return a[`get${o}FullYear`]();case"m":return s(a[`get${o}Month`]()+1);case"n":return n[a[`get${o}Month`]()];case"d":return s(a[`get${o}Date`]());case"w":return r[a[`get${o}Day`]()];case"x":return a[`get${o}Day`]();case"H":return s(a[`get${o}Hours`]());case"M":return s(a[`get${o}Minutes`]());case"S":return s(a[`get${o}Seconds`]());default:return`%${e}`}}))}},numberFormat:function(t){return t=Object.assign({},{digitsAfterDecimal:2,scaler:1,thousandsSep:",",decimalSep:".",prefix:"",suffix:""},t),function(e){if(isNaN(e)||!isFinite(e))return"";const i=function(t,e,i){const n=(t+="").split(".");let r=n[0];const o=n.length>1?i+n[1]:"";return r=function(t,e){return t.replace(/\d+/,(function(t){return t.replace(/(\d)(?=(\d{3})+$)/g,(function(t){return`${t}${e}`}))}))}(r,e),r+o}((t.scaler*e).toFixed(t.digitsAfterDecimal),t.thousandsSep,t.decimalSep);return`${t.prefix}${i}${t.suffix}`}}});const HU="NO_AXISID_FRO_VTABLE";function LU(t,e,i){const n=i.getCellHeaderPaths(t,e);let r;if(i.indicatorsAsCol){const t=n.colHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;r=i.columnObjects.find((e=>e.indicatorKey===t))}else{const t=n.rowHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;r=i.columnObjects.find((e=>e.indicatorKey===t))}const o=r?.chartSpec;return o}function kU(t,e,i){const n=i.getRawChartSpec(t,e);if(n?.series){const t={};return n.data?.id&&(t[n.data.id]=void 0),n?.series.forEach((e=>{if(!e.data?.fromDataId)if(e.data?.transforms)t[e.data?.id??n.data?.id??"data"]=void 0;else{const i="horizontal"===e.direction?e.xField:e.yField;t[e.data?.id??n.data?.id??"data"]=e.data?.id?i:void 0}})),t}return n.data.id}let IU=0;class OU{_headerObjects;_headerObjectMap;_headerCellIds;_columns;bodyRowCount=1;hierarchyIndent;_transpose=!1;_showHeader=!0;_recordsCount=0;_table;_cellRangeMap;constructor(t,e,i,n){this._cellRangeMap=new Map,this._showHeader=i,this._table=t,this._columns=[],this._headerCellIds=[],this.hierarchyIndent=n??20,this._headerObjects=this._addHeaders(0,e,[]),this._headerObjectMap=this._headerObjects.reduce(((t,e)=>(t[e.id]=e,t)),{})}get transpose(){return this._transpose}set transpose(t){this._transpose=t}get showHeader(){return this._showHeader}set showHeader(t){this._showHeader=t}isHeader(t,e){return!!(this.transpose&&t<this.headerLevelCount)||!this.transpose&&e<this.headerLevelCount}getCellLocation(t,e){return this.isHeader(t,e)?this.transpose?"rowHeader":"columnHeader":"body"}isColumnHeader(t,e){return!this.transpose&&e<this.headerLevelCount}isRightFrozenColumn(t,e){return t>=this.colCount-this.rightFrozenColCount&&e>=this.columnHeaderLevelCount&&e<this.rowCount-this.bottomFrozenRowCount}isBottomFrozenRow(t,e){return t>=this.rowHeaderLevelCount&&e>=this.rowCount-this.bottomFrozenRowCount&&t<this.colCount-this.rightFrozenColCount}isLeftBottomCorner(t,e){return t<this.rowHeaderLevelCount&&e>=this.rowCount-this.bottomFrozenRowCount}isRightTopCorner(t,e){return t>=this.colCount-this.rightFrozenColCount&&e<this.columnHeaderLevelCount}isRightBottomCorner(t,e){return t>=this.colCount-this.rightFrozenColCount&&e>=this.rowCount-this.bottomFrozenRowCount}isCornerHeader(t,e){return!1}isRowHeader(t,e){return!!(this.transpose&&t<this.headerLevelCount)}getColumnHeaderRange(){return this.transpose?{start:{col:0,row:0},end:{col:this._headerCellIds.length-1,row:(this.rowCount??0)-1}}:{start:{col:0,row:0},end:{col:(this.colCount??0)-1,row:this._headerCellIds.length-1}}}getRowHeaderRange(){return this.transpose?{start:{col:0,row:0},end:{col:this._headerCellIds.length-1,row:(this.rowCount??0)-1}}:{start:{col:0,row:0},end:{col:(this.colCount??0)-1,row:this._headerCellIds.length-1}}}getCornerHeaderRange(){}getBodyRange(){return this.transpose?{start:{col:this.headerLevelCount,row:0},end:{col:(this.colCount??0)-1,row:(this.rowCount??0)-1}}:{start:{col:0,row:this.headerLevelCount},end:{col:(this.colCount??0)-1,row:(this.rowCount??0)-1}}}get headerLevelCount(){return this.showHeader?this._headerCellIds.length:0}get columnHeaderLevelCount(){return this.transpose?0:this.headerLevelCount}get rowHeaderLevelCount(){return this.transpose?this.headerLevelCount:0}get bottomFrozenRowCount(){return 0}get rightFrozenColCount(){return 0}get colCount(){return this.transpose?this.headerLevelCount+this.recordsCount:this._columns.length}get rowCount(){return this.transpose?this._columns.length:this.headerLevelCount+this.recordsCount}get recordsCount(){return this._recordsCount}set recordsCount(t){this._recordsCount=t}get headerObjects(){return this._headerObjects}get columnObjects(){return this._columns}get columnWidths(){return this._columns}getColumnWidthDefined(t){if(this.transpose){let e,i,n=0;if(t>=this.rowHeaderLevelCount){let t;return this.columnObjects.forEach(((r,o)=>{"number"==typeof r.width?n=Math.max(r.width,n):"auto"===r.width&&(t=!0),"number"==typeof r.minWidth&&(i=Math.max(r.minWidth,i)),"number"==typeof r.maxWidth&&(e=Math.max(r.maxWidth,e))})),n=n>0?n:t?"auto":void 0,{width:n,minWidth:i,maxWidth:e}}if(this.isRowHeader(t,0)){const e=Array.isArray(this._table.defaultHeaderColWidth)?this._table.defaultHeaderColWidth[t]??this._table.defaultColWidth:this._table.defaultHeaderColWidth;return"auto"===e?{width:"auto"}:{width:e}}}return this._columns[t]}getCellId(t,e){return this.transpose?this.headerLevelCount<=t?this._columns[e]?.id:this._headerCellIds[t]?.[e]:this.headerLevelCount<=e?this._columns[t]?.id:this._headerCellIds[e]?.[t]}getHeader(t,e){const i=this.getCellId(t,e);return this._headerObjectMap[i]}getHeaderFieldKey(t,e){const i=this.getCellId(t,e);return this._headerObjectMap[i]?.fieldKey||(this.transpose?this._columns[e]?.fieldKey:this._columns[t]?.fieldKey)}getHeaderField(t,e){const i=this.getCellId(t,e);return this._headerObjectMap[i]?.field||(this.transpose?this._columns[e]&&this._columns[e].field:this._columns[t]&&this._columns[t].field)}getHeaderCellAdress(t){for(let e=0;e<this._headerCellIds.length;e++){const i=this._headerCellIds[e];for(let n=0;n<i.length;n++)if(i[n]===t)return this.transpose?{col:e,row:n}:{col:n,row:e}}}getHeaderCellAddressByField(t){const e=this.headerObjects.find((e=>e&&e.field===t));return this.getHeaderCellAdress(e.id)}getBody(t,e){return this.transpose?this._columns[e]:this._columns[t]}getBodyLayoutRangeById(t){if(this.transpose){for(let e=0;e<(this.rowCount??0);e++)if(t===this._columns[e].id)return{start:{col:0,row:e},end:{col:0,row:e}}}else for(let e=0;e<(this.colCount??0);e++)if(t===this._columns[e].id)return{start:{col:e,row:0},end:{col:e,row:0}};throw new Error(`can not found body layout @id=${t}`)}getBodyCellValue(t,e){if(this.isHeader(t,e))return null;const{field:i,fieldFormat:n}=this.getBody(t,e);return this._table.getFieldData(n||i,t,e)}getCellRange(t,e){if(-1===t||-1===e)return{start:{col:t,row:e},end:{col:t,row:e}};if(this._cellRangeMap.has(`$${t}$${e}`))return this._cellRangeMap.get(`$${t}$${e}`);let i={start:{col:t,row:e},end:{col:t,row:e}};if(this.transpose)i=this.getCellRangeTranspose(t,e);else if(this.headerLevelCount<=e){if(this.headerLevelCount<=e&&this.columnObjects[t]?.define?.mergeCell){const n=this.getBodyCellValue(t,e);for(let r=e-1;r>=this.headerLevelCount&&n===this.getBodyCellValue(t,r);r--)i.start.row=r;for(let r=e+1;r<this.rowCount&&n===this.getBodyCellValue(t,r);r++)i.end.row=r}}else{const n=this.getCellId(t,e);for(let r=t-1;r>=0&&n===this.getCellId(r,e);r--)i.start.col=r;for(let r=t+1;r<(this.colCount??0)&&n===this.getCellId(r,e);r++)i.end.col=r;for(let r=e-1;r>=0&&n===this.getCellId(t,r);r--)i.start.row=r;for(let r=e+1;r<this.headerLevelCount&&n===this.getCellId(t,r);r++)i.end.row=r}return this._cellRangeMap.set(`$${t}$${e}`,i),i}getCellRangeTranspose(t,e){const i={start:{col:t,row:e},end:{col:t,row:e}};if(this.headerLevelCount<=t||-1===t&&-1===e){if(this.headerLevelCount<=t&&this.columnObjects[e]?.define?.mergeCell){const n=this.getBodyCellValue(t,e);for(let r=t-1;r>=this.headerLevelCount&&n===this.getBodyCellValue(r,e);r--)i.start.col=r;for(let r=t+1;r<(this.colCount??0)&&n===this.getBodyCellValue(r,e);r++)i.end.col=r}return i}const n=this.getCellId(t,e);for(let r=e-1;r>=0&&n===this.getCellId(t,r);r--)i.start.row=r;for(let r=e+1;r<(this.rowCount??0)&&n===this.getCellId(t,r);r++)i.end.row=r;for(let r=t-1;r>=0&&n===this.getCellId(r,e);r--)i.start.col=r;for(let r=t+1;r<this.headerLevelCount&&n===this.getCellId(r,e);r++)i.end.col=r;return i}isCellRangeEqual(t,e,i,n){const r=this.getCellRange(t,e),o=this.getCellRange(i,n);return r.start.col===o.start.col&&r.end.col===o.end.col&&r.start.row===o.start.row&&r.end.row===o.end.row}getRecordIndexByRow(t,e){return this.transpose?t<this.headerLevelCount?-1:t-this.headerLevelCount:e<this.headerLevelCount?-1:e-this.headerLevelCount}getRecordStartRowByRecordIndex(t){return this.headerLevelCount+t}_addHeaders(t,e,i,n){const r=[],o=this._newRow(t,n);return e.forEach((e=>{const s=this._columns.length,a=IU++,l={id:a,title:e.title??e.caption,headerIcon:e.headerIcon,field:e.field,fieldKey:e?.fieldKey,fieldFormat:e.fieldFormat,style:e.headerStyle,headerType:e.headerType??"text",dropDownMenu:e.dropDownMenu,define:e,columnWidthComputeMode:e.columnWidthComputeMode};r[a]=l;for(let e=t-1;e>=0;e--)this._headerCellIds[e][s]=i[e];if(o[s]=n?this._headerCellIds[t-1][s]:a,e.columns)this._addHeaders(t+1,e.columns,[...i,a],e.hideColumnsSubHeader).forEach((t=>r.push(t)));else{const i=e;this._columns.push({id:IU++,field:i.field,fieldKey:i.fieldKey,fieldFormat:i.fieldFormat,width:i.width,minWidth:i.minWidth,maxWidth:i.maxWidth,icon:i.icon,cellType:i.cellType??i.columnType??"text",chartModule:"chartModule"in i?i.chartModule:null,chartSpec:"chartSpec"in i?i.chartSpec:null,sparklineSpec:"sparklineSpec"in i?i.sparklineSpec:Af,style:i.style,define:i,columnWidthComputeMode:i.columnWidthComputeMode,disableColumnResize:i?.disableColumnResize});for(let e=t+1;e<this._headerCellIds.length;e++)this._headerCellIds[e][s]=a}})),r}_newRow(t,e=!1){if(this._headerCellIds[t]){const e=this._headerCellIds[t-1];if(e.length>this._headerCellIds[t].length)for(let i=this._headerCellIds[t].length;i<e.length;i++)this._headerCellIds[t][i]=e[i];return this._headerCellIds[t]}if(e)return[];const i=this._headerCellIds[t]=[];if(!this._columns.length)return i;const n=this._headerCellIds[t-1];for(let t=0;t<n.length;t++)i[t]=n[t];return i}getCellHeaderPaths(t,e){let i=[],n=[];return this.transpose?n=[{field:this._columns[e].field}]:i=[{field:this._columns[t].field}],{colHeaderPaths:i,rowHeaderPaths:n}}getParentCellId(t,e){if(0!==e)return this.isColumnHeader(t,e)?this.getCellId(t,e-1):this.isRowHeader(t,e)?this.getCellId(t-1,e):void 0}canMoveHeaderPosition(t,e){const i=this.getCellRange(t.col,t.row);if(this.isColumnHeader(t.col,t.row)){return this.getParentCellId(t.col,i.start.row)===this.getParentCellId(e.col,i.start.row)}if(this.isRowHeader(t.col,t.row)){return this.getParentCellId(i.start.col,t.row)===this.getParentCellId(i.start.col,e.row)}return!1}moveHeaderPosition(t,e){if(this.canMoveHeaderPosition(t,e)){const i=this.getCellRange(t.col,t.row);if(this.isColumnHeader(t.col,t.row)){const n=i.end.col-i.start.col+1;let r;const o=this.getCellRange(e.col,i.start.row);if(r=e.col>=t.col?o.end.col-n+1:o.start.col,r===i.start.col)return null;for(let t=0;t<this._headerCellIds.length;t++){const e=this._headerCellIds[t].splice(i.start.col,n);e.unshift(r,0),Array.prototype.splice.apply(this._headerCellIds[t],e)}const s=this._columns.splice(i.start.col,n);return s.unshift(r,0),Array.prototype.splice.apply(this._columns,s),this._cellRangeMap=new Map,{sourceIndex:i.start.col,targetIndex:r,moveSize:n,moveType:"column"}}if(this.isRowHeader(t.col,t.row)){const n=i.end.row-i.start.row+1;let r;const o=this.getCellRange(i.start.col,e.row);if(r=e.row>=t.row?o.end.row-n+1:o.start.row,r===i.start.row)return null;for(let t=0;t<this._headerCellIds.length;t++){const e=this._headerCellIds[t].splice(i.start.row,n);e.unshift(r,0),Array.prototype.splice.apply(this._headerCellIds[t],e)}const s=this._columns.splice(i.start.row,n);return s.unshift(r,0),Array.prototype.splice.apply(this._columns,s),this._cellRangeMap=new Map,{sourceIndex:i.start.row,targetIndex:r,moveSize:n,moveType:"row"}}}return null}toggleHierarchyState(t){const e=t.add.map((t=>({col:0,row:this._table.frozenRowCount+t}))),i=t.remove.map((t=>({col:0,row:this._table.frozenRowCount+t})));return{addCellPositions:e,removeCellPositions:i}}setChartInstance(t,e,i){(this.transpose?this._columns[e]:this._columns[t]).chartInstance=i}getChartInstance(t,e){return(this.transpose?this._columns[e]:this._columns[t]).chartInstance}getAxisConfigInPivotChart(t,e){}isEmpty(t,e){return!1}getChartAxes(t,e){return[]}getRawChartSpec(t,e){const i=this.getBody(t,e);return i?.chartSpec}getChartDataId(t,e){return kU(t,e,this)}release(){const t=this._table._getActiveChartInstance();t?.release(),this.columnObjects.forEach((t=>{t.chartInstance?.release()}))}}class DU{sizeIncludeParent=!1;rowExpandLevel;hierarchyType;tree={id:0,dimensionKey:"",value:"",children:[],level:-1,startIndex:0,size:0,startInTotal:0,hierarchyState:void 0};totalLevel=0;dimensionKeys=new ff;constructor(t,e="grid",i=void 0){this.sizeIncludeParent=null!=i,this.rowExpandLevel=i,this.hierarchyType=e,this.reset(t)}reset(t,e=!1){this.dimensionKeys=new ff,this.tree.children=t,this.setTreeNode(this.tree,0,this.tree),this.totalLevel=this.dimensionKeys.count()}setTreeNode(t,e,i){t.startIndex=e,t.startInTotal=(i.startInTotal??0)+t.startIndex,(t.dimensionKey??t.indicatorKey)&&(!this.dimensionKeys.contain(t.indicatorKey?Sf:t.dimensionKey)&&this.dimensionKeys.put(t.level,t.indicatorKey?Sf:t.dimensionKey),t.id||(t.id=++FU));let n=t.dimensionKey&&this.sizeIncludeParent?1:0;return"grid"===this.hierarchyType?t.children?t.children.forEach((e=>{e.level=(t.level??0)+1,n+=this.setTreeNode(e,n,t)})):n=1:t.hierarchyState===Xc.expand&&t.children?t.children.forEach((e=>{e.level=(t.level??0)+1,n+=this.setTreeNode(e,n,t)})):t.hierarchyState===Xc.collapse&&t.children?t.children.forEach((e=>{e.level=(t.level??0)+1,this.setTreeNode(e,n,t)})):!t.hierarchyState&&t.level+1<this.rowExpandLevel&&t.children?(t.hierarchyState=Xc.expand,t.children.forEach((e=>{e.level=(t.level??0)+1,n+=this.setTreeNode(e,n,t)}))):t.children?(t.hierarchyState=Xc.collapse,t.children.forEach((e=>{e.level=(t.level??0)+1,this.setTreeNode(e,n,t)}))):(t.hierarchyState=Xc.none,n=1),t.size=n,n}getTreePath(t,e=30){const i=[];return this.searchPath(t,this.tree,i,e),i.shift(),i}searchPath(t,e,i,n){if(!e)return!1;if(t<e.startIndex||t>=e.startIndex+e.size)return!1;if(i.push(e),!e.children||0===e.children.length)return!0;if(e.level>=n)return!0;const r=t-e.startIndex;return e.children.some((t=>this.searchPath(r,t,i,n))),!0}movePosition(t,e,i){let n,r,o;const s=(a,l)=>{if((void 0===r||void 0===o)&&(a.level===t&&(a.startInTotal===e&&(r=l),a.startInTotal<=i&&i<=a.startInTotal+a.size-1&&(o=l)),a.children&&a.level<t)){n=a;for(let t=0;t<a.children.length;t++)(e>=a.children[t].startInTotal&&e<=a.children[t].startInTotal+a.children[t].size||i>=a.children[t].startInTotal&&i<=a.children[t].startInTotal+a.children[t].size)&&s(a.children[t],t)}};s(this.tree,0);const a=n.children.splice(r,1);a.unshift(o,0),Array.prototype.splice.apply(n.children,a)}}let FU=0,zU=0;class WU{_showHeader=!0;rowDimensionTree;columnDimensionTree;rowTree;columnTree;cornerHeaderObjs;columnHeaderObjs=[];rowHeaderObjs=[];_cornerHeaderCellIds=[];_columnHeaderCellIds=[];_rowHeaderCellIds=[];_columnWidths=[];rowsDefine;columnsDefine;indicatorsDefine;columnPaths=[];_headerObjects=[];_headerObjectMap={};_indicators=[];indicatorTitle;indicatorsAsCol=!0;hideIndicatorName=!1;_showRowHeader=!0;_showColumnHeader=!0;_rowHeaderTitle;_columnHeaderTitle;cornerSetting;_indicatorShowType="column";rowHierarchyType;rowExpandLevel;rowHierarchyIndent;rowDimensionKeys=[];colDimensionKeys=[];indicatorKeys=[];indicatorDimensionKey=Sf;_cellRangeMap;_CellHeaderPathMap;_table;constructor(t){if(this._table=t,this._cellRangeMap=new Map,this._CellHeaderPathMap=new Map,this.rowTree=t.options.rowTree,this.columnTree=t.options.columnTree,this.rowsDefine=t.options.rows??[],this.columnsDefine=t.options.columns??[],this.indicatorsDefine=t.options.indicators??[],this.indicatorTitle=t.options.indicatorTitle,this.hideIndicatorName=t.options.hideIndicatorName??!1,this.showRowHeader=t.options.showRowHeader??!0,this.showColumnHeader=t.options.showColumnHeader??!0,this.rowHeaderTitle=t.options.rowHeaderTitle,this.columnHeaderTitle=t.options.columnHeaderTitle,this.rowHierarchyType=t.options.rowHierarchyType??"grid",this.rowExpandLevel=t.options.rowExpandLevel??1,this.rowHierarchyIndent=t.options.rowHierarchyIndent??20,this.cornerSetting=t.options.corner??{titleOnDimension:"column"},this.indicatorsDefine?.forEach((t=>{"string"==typeof t?this.indicatorKeys.push(t):this.indicatorKeys.push(t.indicatorKey)})),this.columnDimensionTree=new DU(this.columnTree??[]),this.rowDimensionTree=new DU(this.rowTree??[],this.rowHierarchyType,"tree"===this.rowHierarchyType?this.rowExpandLevel:void 0),this.colDimensionKeys=this.columnDimensionTree.dimensionKeys.valueArr(),this.rowDimensionKeys=this.rowDimensionTree.dimensionKeys.valueArr(),this.cornerHeaderObjs="column"===this.cornerSetting.titleOnDimension?this._addCornerHeaders(this.columnHeaderTitle?[""].concat(this.colDimensionKeys):this.colDimensionKeys):"row"===this.cornerSetting.titleOnDimension?this._addCornerHeaders(this.rowHeaderTitle?[""].concat(this.rowDimensionKeys):this.rowDimensionKeys):this._addCornerHeaders(null),this.columnDimensionTree.tree.children&&(this.columnHeaderObjs=this._addHeaders(this._columnHeaderCellIds,0,this.columnDimensionTree.tree.children,[]),this.columnHeaderTitle)){const t=++FU,e=Array(this.colCount-this.rowHeaderLevelCount).fill(t);this._columnHeaderCellIds.unshift(e);const i={id:t,title:"string"==typeof this.columnHeaderTitle.title?this.columnHeaderTitle.title:this.columnsDefine.reduce(((t,e)=>"string"==typeof e?t:t+(t?`/${e.title}`:`${e.title}`)),""),field:void 0,headerType:this.columnHeaderTitle.headerType??"text",style:this.columnHeaderTitle.headerStyle,define:{id:t}};this.columnHeaderObjs.push(i),this._headerObjects[t]=i}if(zU=0,this.rowDimensionTree.tree.children&&(this.rowHeaderObjs="tree"===this.rowHierarchyType?this._addHeadersForTreeMode(this._rowHeaderCellIds,0,this.rowDimensionTree.tree.children,[],this.rowDimensionTree.totalLevel,!0):this._addHeaders(this._rowHeaderCellIds,0,this.rowDimensionTree.tree.children,[])),this.rowHeaderTitle){const t=++FU,e=Array(this.rowCount-this.columnHeaderLevelCount).fill(t);this._rowHeaderCellIds.unshift(e);const i={id:t,title:"string"==typeof this.rowHeaderTitle.title?this.rowHeaderTitle.title:this.rowsDefine.reduce(((t,e)=>"string"==typeof e?t:t+(t?`/${e.title}`:`${e.title}`)),""),field:void 0,headerType:this.rowHeaderTitle.headerType??"text",style:this.rowHeaderTitle.headerStyle,define:{id:t}};this.rowHeaderObjs.push(i),this._headerObjects[t]=i}zU=0,this.indicatorsAsCol=!bu(this.rowDimensionKeys.find((t=>t===this.indicatorDimensionKey))),this._rowHeaderCellIds=fu(this._rowHeaderCellIds),this._headerObjectMap=this._headerObjects.reduce(((t,e)=>(t[e.id]=e,t)),{}),this.indicatorsAsCol&&!this.hideIndicatorName?this._indicatorShowType="column":this.indicatorsAsCol||this.hideIndicatorName?this._indicatorShowType="none":this._indicatorShowType="row",this.setColumnWidths()}_addHeaders(t,e,i,n){const r=[];return t[e]||function(e){const i=t[e]=[];if(0===zU)return i;const n=t[e-1];for(let t=0;t<n?.length;t++)i[t]=n[t]}(e),i.forEach((i=>{const o=i.id,s=this.rowsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.dimensionKey))??this.columnsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.dimensionKey)),a=this.indicatorsDefine?.find((t=>"string"!=typeof t&&(i.indicatorKey?t.indicatorKey===i.indicatorKey:t.title===i.value))),l={id:o,title:i.value??a.title,field:i.dimensionKey,style:"function"==typeof(a??s)?.headerStyle?(a??s)?.headerStyle:Object.assign({},(a??s)?.headerStyle),headerType:a?.headerType??s?.headerType??"text",headerIcon:a?.headerIcon??s?.headerIcon,define:Object.assign({},i,a??s),fieldFormat:a?.headerFormat??s?.headerFormat,dropDownMenu:a?.dropDownMenu??s?.dropDownMenu,pivotInfo:{value:i.value,dimensionKey:i.dimensionKey,isPivotCorner:!1},width:s?.width,minWidth:s?.minWidth,maxWidth:s?.maxWidth,showSort:a?.showSort??s?.showSort,description:s?.description};a?(a.customRender&&(i.customRender=a.customRender),bu(this._indicators?.find((t=>t.indicatorKey===a.indicatorKey)))||this._indicators?.push({id:++FU,indicatorKey:a.indicatorKey,field:a.indicatorKey,fieldFormat:a?.format,cellType:a?.cellType??a?.columnType??"text",chartModule:"chartModule"in a?a.chartModule:null,chartSpec:"chartSpec"in a?a.chartSpec:null,sparklineSpec:"sparklineSpec"in a?a.sparklineSpec:null,style:a?.style,icon:a?.icon,define:Object.assign({},i,a,{dragHeader:s?.dragHeader}),width:a?.width,minWidth:a?.minWidth,maxWidth:a?.maxWidth,disableColumnResize:a?.disableColumnResize})):i.indicatorKey&&(bu(this._indicators?.find((t=>t.indicatorKey===i.indicatorKey)))||this._indicators?.push({id:++FU,indicatorKey:i.indicatorKey,field:i.indicatorKey,cellType:"text",define:Object.assign({},i)})),r[o]=l,this._headerObjects[o]=l,t[e][zU]=o;for(let i=e-1;i>=0;i--)t[i][zU]=n[i];if(i.children)this._addHeaders(t,e+1,i.children??[],[...n,o]).forEach((t=>r.push(t)));else{for(let i=e+1;i<t.length;i++)t[i][zU]=o;zU++}})),r}_addHeadersForTreeMode(t,e,i,n,r,o){const s=[];return t[e]||function(e){const i=t[e]=[];if(0===zU)return i;const n=t[e-1];for(let t=0;t<n?.length;t++)i[t]=n[t]}(e),i.forEach((i=>{const a=i.id,l=this.rowsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.dimensionKey))??this.columnsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.dimensionKey)),h={id:a,title:i.value,field:i.dimensionKey,style:i.level+1===r||"function"==typeof l?.headerStyle?l?.headerStyle:Object.assign({},l?.headerStyle,{textAlign:"left"}),headerType:l?.headerType??"text",headerIcon:l?.headerIcon,define:Object.assign(i,{linkJump:l?.linkJump,linkDetect:l?.linkDetect,templateLink:l?.templateLink,keepAspectRatio:l?.keepAspectRatio??!1,imageAutoSizing:l?.imageAutoSizing,headerCustomRender:l?.headerCustomRender,headerCustomLayout:l?.headerCustomLayout,dragHeader:l?.dragHeader}),fieldFormat:l?.headerFormat,dropDownMenu:l?.dropDownMenu,pivotInfo:{value:i.value,dimensionKey:i.dimensionKey,isPivotCorner:!1},hierarchyLevel:i.level,dimensionTotalLevel:r,hierarchyState:i.level+1===r?void 0:i.hierarchyState,width:l?.width,minWidth:l?.minWidth,maxWidth:l?.maxWidth};s[a]=h,this._headerObjects[a]=h,t[e][zU]=a;for(let i=e-1;i>=0;i--)t[i][zU]=n[i];if(i.hierarchyState===Xc.expand&&i.children)o&&zU++,this._addHeadersForTreeMode(t,e,i.children??[],[...n,a],r,o&&i.hierarchyState===Xc.expand).forEach((t=>s.push(t)));else{o&&zU++;for(let i=e+1;i<t.length;i++)t[i][zU]=a}})),s}_addCornerHeaders(t){const e=[];if(t)t.forEach(((t,i)=>{const n=++FU,r=this.rowsDefine?.find((e=>"string"!=typeof e&&e.dimensionKey===t))??this.columnsDefine?.find((e=>"string"!=typeof e&&e.dimensionKey===t)),o={id:n,title:t===this.indicatorDimensionKey?this.indicatorTitle:r?.title??"",field:"维度名称",style:this.cornerSetting.headerStyle,headerType:this.cornerSetting.headerType??"text",define:{dimensionKey:"维度名称",id:n,value:t},dropDownMenu:r?.cornerDropDownMenu,pivotInfo:{value:r?.title??"",dimensionKey:t,isPivotCorner:!0},description:r?.cornerDescription};if(e[n]=o,this._headerObjects[n]=o,"column"===this.cornerSetting.titleOnDimension){this._cornerHeaderCellIds[i]||(this._cornerHeaderCellIds[i]=[]);for(let t=0;t<this.rowHeaderLevelCount;t++)this._cornerHeaderCellIds[i][t]=n}else if("row"===this.cornerSetting.titleOnDimension)for(let t=0;t<this.columnHeaderLevelCount;t++)this._cornerHeaderCellIds[t]||(this._cornerHeaderCellIds[t]=[]),this._cornerHeaderCellIds[t][i]=n}));else{const t=++FU,i={id:t,title:"",field:"维度名称",style:this.cornerSetting.headerStyle,headerType:this.cornerSetting.headerType??"text",define:{dimensionKey:"维度名称",id:t,value:""}};e[t]=i,this._headerObjects[t]=i;for(let e=0;e<this.columnHeaderLevelCount;e++)for(let i=0;i<this.rowHeaderLevelCount;i++)this._cornerHeaderCellIds[e]||(this._cornerHeaderCellIds[e]=[]),this._cornerHeaderCellIds[e][i]=t}return e}setColumnWidths(){const t=new Array(this.colCount).fill(void 0);if(this.showHeader&&this.showRowHeader&&(this.rowHeaderTitle&&(t[0]={}),this.rowDimensionKeys.forEach(((e,i)=>{const n=this.rowsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===e));n&&(t[i+(this.rowHeaderTitle?1:0)]={width:n.width,minWidth:n.minWidth,maxWidth:n.maxWidth})}))),this.indicatorsAsCol)for(let e=this.rowHeaderLevelCount;e<this.colCount;e++){const i=this.getBody(e,this.columnHeaderLevelCount);t[e]={width:i?.width,minWidth:i?.minWidth,maxWidth:i?.maxWidth}}else{let e,i,n,r=0;this._indicators?.forEach(((t,o)=>{"number"==typeof t.width?r=Math.max(t.width,r):"auto"===t.width&&(n=!0),"number"==typeof t.minWidth&&(i=Math.max(t.minWidth,i)),"number"==typeof t.maxWidth&&(e=Math.max(t.maxWidth,e))})),r=r>0?r:n?"auto":void 0,t.fill({width:r,minWidth:i,maxWidth:e},this.rowHeaderLevelCount,this.colCount)}this._columnWidths=t}get columnWidths(){return this._columnWidths}getColumnWidthDefined(t){return this._columnWidths[t]}get showHeader(){return this._showHeader}set showHeader(t){this._showHeader=t}get showColumnHeader(){return this._showColumnHeader}set showColumnHeader(t){this._showColumnHeader=t}get showRowHeader(){return this._showRowHeader}set showRowHeader(t){this._showRowHeader=t}get columnHeaderTitle(){return this._columnHeaderTitle}set columnHeaderTitle(t){this._columnHeaderTitle=t}get rowHeaderTitle(){return this._rowHeaderTitle}set rowHeaderTitle(t){this._rowHeaderTitle=t}getHeaderFieldKey(t,e){}getCellLocation(t,e){return this.isCornerHeader(t,e)?"cornerHeader":this.isColumnHeader(t,e)?"columnHeader":this.isRowHeader(t,e)?"rowHeader":"body"}isHeader(t,e){return t<this.rowHeaderLevelCount||(e<this.columnHeaderLevelCount||(t>=this.colCount-this.rightFrozenColCount||e>=this.rowCount-this.bottomFrozenRowCount))}isCornerHeader(t,e){return t<this.rowHeaderLevelCount&&e<this.columnHeaderLevelCount}isColumnHeader(t,e){return t>=this.rowHeaderLevelCount&&e<this.columnHeaderLevelCount}isRowHeader(t,e){return t<this.rowHeaderLevelCount&&e>=this.columnHeaderLevelCount}isRightFrozenColumn(t,e){return t>=this.colCount-this.rightFrozenColCount&&e>=this.columnHeaderLevelCount&&e<this.rowCount-this.bottomFrozenRowCount}isBottomFrozenRow(t,e){return t>=this.rowHeaderLevelCount&&e>=this.rowCount-this.bottomFrozenRowCount&&t<this.colCount-this.rightFrozenColCount}isLeftBottomCorner(t,e){return t<this.rowHeaderLevelCount&&e>=this.rowCount-this.bottomFrozenRowCount}isRightTopCorner(t,e){return t>=this.colCount-this.rightFrozenColCount&&e<this.columnHeaderLevelCount}isRightBottomCorner(t,e){return t>=this.colCount-this.rightFrozenColCount&&e>=this.rowCount-this.bottomFrozenRowCount}getColumnHeaderRange(){return{start:{col:this.rowHeaderLevelCount,row:0},end:{col:this.colCount-1,row:this.columnHeaderLevelCount-1}}}getRowHeaderRange(){return{start:{col:0,row:this.columnHeaderLevelCount},end:{col:this.rowHeaderLevelCount-1,row:this.rowCount-1}}}getCornerHeaderRange(){return{start:{col:0,row:0},end:{col:this.rowHeaderLevelCount-1,row:this.columnHeaderLevelCount-1}}}getBodyRange(){return{start:{col:this.rowHeaderLevelCount,row:this.columnHeaderLevelCount},end:{col:this.colCount-1,row:this.rowCount-1}}}resetCellIds(){}get headerLevelCount(){return this.columnHeaderLevelCount}get columnHeaderLevelCount(){if(this.showHeader&&this.showColumnHeader){let t=this.indicatorsAsCol&&this.hideIndicatorName&&this.colDimensionKeys[this.colDimensionKeys.length-1]===this.indicatorDimensionKey?this.columnDimensionTree.totalLevel-1:this.columnDimensionTree.totalLevel;return this.columnHeaderTitle&&(t+=1),t}return 0}get rowHeaderLevelCount(){if(this.showHeader&&this.showRowHeader){if("tree"===this.rowHierarchyType)return this.rowHeaderTitle?2:1;let t=this.indicatorsAsCol?this.rowDimensionTree.totalLevel:this.hideIndicatorName&&this.rowDimensionKeys[this.rowDimensionKeys.length-1]===this.indicatorDimensionKey?this.rowDimensionTree.totalLevel-1:this.rowDimensionTree.totalLevel;return this.rowHeaderTitle&&(t+=1),t}return 0}get colCount(){return this.columnDimensionTree.tree.size+this.rowHeaderLevelCount+this.rightFrozenColCount}get rowCount(){return this.rowDimensionTree.tree.size+this.columnHeaderLevelCount+this.bottomFrozenRowCount}get bodyRowCount(){return this.rowDimensionTree.tree.size}get bottomFrozenRowCount(){return this.showHeader&&this.showColumnHeader&&this.indicatorsAsCol&&!this.hideIndicatorName&&this.indicatorsDefine.find((t=>t?.multiIndicator))?1:0}get rightFrozenColCount(){return this.showHeader&&this.showColumnHeader&&!this.indicatorsAsCol&&!this.hideIndicatorName&&this.indicatorsDefine.find((t=>t?.multiIndicator))?1:0}get headerObjects(){return this._headerObjects}get columnObjects(){return this._indicators}getCellId(t,e){if(e>=0&&t>=0){if(this.isCornerHeader(t,e))return this._cornerHeaderCellIds[e][t];if(this.isColumnHeader(t,e))return this._columnHeaderCellIds[e][t-this.rowHeaderLevelCount];if(this.isRowHeader(t,e))return this._rowHeaderCellIds[e-this.columnHeaderLevelCount]?.[t];if(this.isRightFrozenColumn(t,e))return this._rowHeaderCellIds[e-this.columnHeaderLevelCount][this.rowHeaderLevelCount-1];if(this.isBottomFrozenRow(t,e))return this._columnHeaderCellIds[this.columnHeaderLevelCount-1]?.[t-this.rowHeaderLevelCount]}}getHeader(t,e){const i=this.getCellId(t,e);return this._headerObjectMap[i]}getHeaderField(t,e){const i=this.getCellId(t,e);return this._headerObjectMap[i]?.field||this.getBody(t,e)?.field}getHeaderCellAdress(t){for(let e=0;e<this._columnHeaderCellIds.length;e++){const i=this._columnHeaderCellIds[e];for(let n=0;n<i.length;n++)if(i[n]===t)return{col:n+this._table.frozenColCount,row:e}}for(let e=0;e<this._rowHeaderCellIds.length;e++){const i=this._rowHeaderCellIds[e];for(let n=0;n<i.length;n++)if(i[n]===t)return{col:n,row:e+this._table.frozenRowCount}}for(let e=0;e<this._cornerHeaderCellIds.length;e++){const i=this._cornerHeaderCellIds[e];for(let n=0;n<i.length;n++)if(i[n]===t)return{col:n,row:e}}}getHeaderCellAddressByField(t){const e=this.headerObjects.find((e=>e&&e.field===t));return this.getHeaderCellAdress(e.id)}getBody(t,e){const i=this.getCellHeaderPaths(t,e);if(this.indicatorsAsCol){const t=i.colHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;return this._indicators?.find((e=>e.indicatorKey===t))??this._indicators[0]??{id:"",field:void 0,indicatorKey:void 0,cellType:void 0,define:void 0}}const n=i.rowHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;return this._indicators?.find((t=>t.indicatorKey===n))??this._indicators[0]??{id:"",field:void 0,indicatorKey:void 0,cellType:void 0,define:void 0}}getBodyLayoutRangeById(t){for(let e=0;e<(this.colCount??0);e++)if(t===this.columnObjects[e].id)return{start:{col:e,row:0},end:{col:e,row:0}};throw new Error(`can not found body layout @id=${t}`)}getCellRange(t,e){if(-1===t||-1===e)return{start:{col:t,row:e},end:{col:t,row:e}};if(this._cellRangeMap.has(`${t}-${e}`))return this._cellRangeMap.get(`${t}-${e}`);const i={start:{col:t,row:e},end:{col:t,row:e}};if(this.isHeader(t,e)&&-1!==t&&-1!==e){const n=this.getCellId(t,e);for(let r=t-1;r>=0&&n===this.getCellId(r,e);r--)i.start.col=r;for(let r=t+1;r<(this.colCount??0)&&n===this.getCellId(r,e);r++)i.end.col=r;for(let r=e-1;r>=0&&n===this.getCellId(t,r);r--)i.start.row=r;for(let r=e+1;r<(this.rowCount??0)&&n===this.getCellId(t,r);r++)i.end.row=r}return this._cellRangeMap.set(`${t}-${e}`,i),i}isCellRangeEqual(t,e,i,n){const r=this.getCellRange(t,e),o=this.getCellRange(i,n);return r.start.col===o.start.col&&r.end.col===o.end.col&&r.start.row===o.start.row&&r.end.row===o.end.row}getRecordIndexByRow(t){return t<this.columnHeaderLevelCount||t>=this.rowCount-this.bottomFrozenRowCount?-1:t-this.columnHeaderLevelCount}getRecordIndexByCol(t){return t<this.rowHeaderLevelCount||t>=this.colCount-this.rightFrozenColCount?-1:t-this.rowHeaderLevelCount}getRecordStartRowByRecordIndex(t){return this.columnHeaderLevelCount+t}getCellHeaderPathsWidthTreeNode(t,e){if(this._CellHeaderPathMap.has(`${t}-${e}`))return this._CellHeaderPathMap.get(`${t}-${e}`);const i=this.getRecordIndexByCol(t),n=this.getRecordIndexByRow(e);let r,o;if(t>=0&&(r=this.columnDimensionTree.getTreePath(i,this.showHeader&&this.showColumnHeader?e-(this.columnHeaderTitle?1:0):this.columnDimensionTree.totalLevel)),e>=0)if("tree"===this.rowHierarchyType)if(t>=this.rowHeaderLevelCount)o=this.rowDimensionTree.getTreePath(n,t+this.rowDimensionTree.totalLevel);else{const i=this.getHeader(t,e);o=this.rowDimensionTree.getTreePath(n,t+i.hierarchyLevel)}else o=this.rowDimensionTree.getTreePath(n,this.showHeader&&this.showRowHeader?t-(this.rowHeaderTitle?1:0):this.rowDimensionTree.totalLevel);const s={colHeaderPaths:r,rowHeaderPaths:o};return this._CellHeaderPathMap.set(`${t}-${e}`,s),s}getCellHeaderPaths(t,e){const i=this.getCellHeaderPathsWidthTreeNode(t,e),n={colHeaderPaths:[],rowHeaderPaths:[]};return i.colHeaderPaths.forEach((t=>{const e={};e.dimensionKey=t.dimensionKey,e.indicatorKey=t.indicatorKey,e.value=t.value??this.getIndicatorInfoByIndicatorKey(t.indicatorKey)?.title??"",n.colHeaderPaths.push(e)})),i.rowHeaderPaths.forEach((t=>{const e={};e.dimensionKey=t.dimensionKey,e.indicatorKey=t.indicatorKey,e.value=t.value??this.getIndicatorInfoByIndicatorKey(t.indicatorKey)?.title??"",n.rowHeaderPaths.push(e)})),n}getIndicatorInfoByIndicatorKey(t){const e=this.indicatorsDefine?.find((e=>"string"!=typeof e&&(!!t&&e.indicatorKey===t)));return e}getHeaderDimension(t,e){if(this.isHeader(t,e)){const i=this.getHeader(t,e);return this.rowsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.field))??this.columnsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.field))}}isColumnIndicatorHeader(t,e){return"column"===this._indicatorShowType&&e===this.columnHeaderLevelCount-1&&t>=this.rowHeaderLevelCount}isRowIndicatorHeader(t,e){return"row"===this._indicatorShowType&&t===this.rowHeaderLevelCount-1&&e>=this.columnHeaderLevelCount}isIndicatorHeader(t,e){return this.isColumnIndicatorHeader(t,e)||this.isRowIndicatorHeader(t,e)}toggleHierarchyState(t,e){const i=this._rowHeaderCellIds.slice(0),n=i.map((t=>this.getHeaderCellAdress(t[0]))),r=this.getHeader(t,e);if(r.define.hierarchyState=r.define.hierarchyState===Xc.collapse?Xc.expand:Xc.collapse,this.rowDimensionTree.reset(this.rowDimensionTree.tree.children,!0),this._rowHeaderCellIds=[],this.rowHeaderObjs=this._addHeadersForTreeMode(this._rowHeaderCellIds,0,this.rowDimensionTree.tree.children,[],this.rowDimensionTree.totalLevel,!0),this.rowHeaderTitle){const t=++FU,e=Array(this.rowCount-this.columnHeaderLevelCount).fill(t);this._rowHeaderCellIds.unshift(e);const i={id:t,title:"string"==typeof this.rowHeaderTitle.title?this.rowHeaderTitle.title:this.rowsDefine.reduce(((t,e)=>"string"==typeof e?t:t+(t?`/${e.title}`:`${e.title}`)),""),field:void 0,headerType:this.rowHeaderTitle.headerType??"text",style:this.rowHeaderTitle.headerStyle,define:{field:"",headerType:"text",cellType:"text"}};this.rowHeaderObjs.push(i),this._headerObjects[t]=i}return zU=0,this._rowHeaderCellIds=fu(this._rowHeaderCellIds),this._headerObjectMap=this._headerObjects.reduce(((t,e)=>(t[e.id]=e,t)),{}),this._CellHeaderPathMap=new Map,function(t,e,i,n){const r=t.map((t=>t[0])),o=e.map((t=>t[0])),s=[],a=[];for(let t=0;t<r.length;t++)o.includes(r[t])||a.push(i[t]);for(let t=0;t<o.length;t++)r.includes(o[t])||s.push(n.getHeaderCellAdress(o[t]));return{addCellPositions:s,removeCellPositions:a}}(i,this._rowHeaderCellIds,n,this)}isHeaderForColWidth(t,e){return this.isHeader(t,e)}getHeaderForColWidth(t,e){return this.getHeader(t,e)}getPivotCellAdress(t){if(!Array.isArray(t))return;let e,i,n=this.rowTree,r=this.columnTree;for(let o=0;o<t.length;o++){const s=t[o];if((s.isPivotCorner||!s.value)&&o===t.length-1){if("row"===this?.cornerSetting?.titleOnDimension){let t=0;return"grid"===this.rowHierarchyType&&(t=this.rowDimensionKeys.indexOf(s.dimensionKey)),-1===t?void 0:{col:this.rowHeaderTitle?t+1:t,row:0}}const t=this.colDimensionKeys.indexOf(s.dimensionKey);return-1===t?void 0:{col:0,row:this.columnHeaderTitle?t+1:t}}let a=!1;for(let t=0;t<r.length;t++){const e=r[t];if((bu(s.dimensionKey)&&e.dimensionKey===s.dimensionKey||bu(s.indicatorKey)&&e.indicatorKey===s.indicatorKey)&&e.value===s.value){r=e.children,i=e,a=!0;break}}if(!a)for(let t=0;t<n.length;t++){const i=n[t];if((bu(s.dimensionKey)&&i.dimensionKey===s.dimensionKey||bu(s.indicatorKey)&&i.indicatorKey===s.indicatorKey)&&i.value===s.value){n=i.children,e=i;break}}}let o=0,s=0;if(e){s=this.columnHeaderLevelCount;const{startInTotal:t,level:i}=e;return s+=t,o="grid"===this.rowHierarchyType?this.rowHeaderTitle?i+1:i:0,{col:o,row:s}}if(i){o=this.rowHeaderLevelCount;const{startInTotal:t,level:e}=i;return o+=t,s=this.columnHeaderTitle?e+1:e,{col:o,row:s}}}getPivotDimensionInfo(t,e){const{colHeaderPaths:i,rowHeaderPaths:n}=this.getCellHeaderPaths(t,e),r=[];return i.length?i.forEach(((t,e)=>{r.push({dimensionKey:t.dimensionKey,value:t.value,isPivotCorner:!1,indicatorKey:t.indicatorKey})})):n.length?n.forEach(((t,e)=>{r.push({dimensionKey:t.dimensionKey,value:t.value,isPivotCorner:!1,indicatorKey:t.indicatorKey})})):this.isCornerHeader(t,e)&&("row"===this?.cornerSetting?.titleOnDimension?r.push({dimensionKey:this.rowDimensionKeys[this.rowHeaderTitle?t-1:t],isPivotCorner:!0}):r.push({dimensionKey:this.colDimensionKeys[this.columnHeaderTitle?e-1:e],isPivotCorner:!0})),r}getIndicatorKey(t,e){return this.getBody(t,e)?.indicatorKey}getParentCellId(t,e){if(0!==e)return this.isColumnHeader(t,e)?this.getCellId(t,e-1):this.isRowHeader(t,e)?this.getCellId(t-1,e):void 0}canMoveHeaderPosition(t,e){const i=this.getCellRange(t.col,t.row);if(this.isColumnHeader(t.col,t.row)){return this.getParentCellId(t.col,i.start.row)===this.getParentCellId(e.col,i.start.row)}if(this.isRowHeader(t.col,t.row)){if("tree"!==this.rowHierarchyType){return this.getParentCellId(i.start.col,t.row)===this.getParentCellId(i.start.col,e.row)}{const i=du(this.getCellHeaderPathsWidthTreeNode(t.col,t.row).rowHeaderPaths),n=du(this.getCellHeaderPathsWidthTreeNode(e.col,e.row).rowHeaderPaths);if(i.pop(),n.pop(),i.length<=n.length)return i.length!==n.length||!i.find(((t,e)=>t.dimensionKey!==n[e].dimensionKey||t.value!==n[e].value))}}return!1}moveHeaderPosition(t,e){if(this.canMoveHeaderPosition(t,e)&&!this.isCellRangeEqual(t.col,t.row,e.col,e.row)){const i=this.getCellRange(t.col,t.row);if(this.isColumnHeader(t.col,t.row)){const n=i.end.col-i.start.col+1;let r;const o=this.getCellRange(e.col,i.start.row);if(r=e.col>=t.col?o.end.col-n+1:o.start.col,r===i.end.col)return null;for(let t=0;t<this._columnHeaderCellIds.length;t++){const e=this._columnHeaderCellIds[t].splice(i.start.col-this.rowHeaderLevelCount,n);e.unshift(r-this.rowHeaderLevelCount,0),Array.prototype.splice.apply(this._columnHeaderCellIds[t],e)}const s=this._columnWidths.splice(i.start.col,n);return s.unshift(r,0),Array.prototype.splice.apply(this._columnWidths,s),this.columnDimensionTree.movePosition(t.row,i.start.col-this.rowHeaderLevelCount,r-this.rowHeaderLevelCount),this.columnDimensionTree.reset(this.columnDimensionTree.tree.children,!0),this._CellHeaderPathMap=new Map,this._cellRangeMap=new Map,{sourceIndex:i.start.col,targetIndex:r,moveSize:n,moveType:"column"}}if(this.isRowHeader(t.col,t.row)){let n;const r=this.getCellHeaderPathsWidthTreeNode(t.col,t.row).rowHeaderPaths,o=this.getCellHeaderPathsWidthTreeNode(e.col,e.row).rowHeaderPaths,s=r[r.length-1],a=o[r.length-1],l=s.size;if(n=e.row>=t.row?a.startInTotal+a.size-l:a.startInTotal,n===t.row||n===i.end.row)return null;const h=this._rowHeaderCellIds.splice(i.start.row-this.columnHeaderLevelCount,l);return h.unshift(n,0),Array.prototype.splice.apply(this._rowHeaderCellIds,h),this.rowDimensionTree.movePosition(this.getCellHeaderPathsWidthTreeNode(t.col,t.row).rowHeaderPaths.length-1,i.start.row-this.columnHeaderLevelCount,n+(e.row>t.row?s.size-1:0)),this.rowDimensionTree.reset(this.rowDimensionTree.tree.children,!0),this._CellHeaderPathMap=new Map,this._cellRangeMap=new Map,{sourceIndex:i.start.row,targetIndex:n+this.columnHeaderLevelCount,moveSize:l,moveType:"row"}}}return null}getCellAdressByHeaderPath(t){let e,i;if(Array.isArray(t)){if(t.length>this.rowDimensionKeys.length+this.colDimensionKeys.length)return;e=t.filter((t=>this.colDimensionKeys.indexOf(t.dimensionKey)>=0)),i=t.filter((t=>this.rowDimensionKeys.indexOf(t.dimensionKey)>=0))}else e=t.colHeaderPaths,i=t.rowHeaderPaths;if(!Array.isArray(e)&&!Array.isArray(i))return;e?.sort(((t,e)=>this.colDimensionKeys.indexOf(t.dimensionKey??this.indicatorDimensionKey)-this.colDimensionKeys.indexOf(e.dimensionKey??this.indicatorDimensionKey))),i?.sort(((t,e)=>this.rowDimensionKeys.indexOf(t.dimensionKey??this.indicatorDimensionKey)-this.rowDimensionKeys.indexOf(e.dimensionKey??this.indicatorDimensionKey)));let n,r,o,s,a=!1;e?.length>=1&&i?.length>=1&&(a=!0);let l,h,c=this.rowTree,u=this.columnTree;if(e)for(let t=0;t<e.length;t++){const i=e[t];for(let t=0;t<u.length;t++){const e=u[t];if(!bu(i.indicatorKey)&&e.dimensionKey===i.dimensionKey&&e.value===i.value||bu(i.indicatorKey)&&e.indicatorKey===i.indicatorKey){u=e.children,a&&!u?h=e:a||(h=e);break}}}if(i)for(let t=0;t<i.length;t++){const e=i[t];for(let t=0;t<c.length;t++){const i=c[t];if((!bu(e.indicatorKey)&&i.dimensionKey===e.dimensionKey&&i.value===e.value||bu(e.indicatorKey)&&i.indicatorKey===e.indicatorKey)&&i.value===e.value){c=i.children,a&&!c?l=i:a||(l=i);break}}}if(!a||l&&h){if(l){r=this.columnHeaderLevelCount;const{startInTotal:t,level:e}=l;r+=t,o="grid"===this.rowHierarchyType?this.rowHeaderTitle?e+1:e:0}if(h){n=this.rowHeaderLevelCount;const{startInTotal:t,level:e}=h;n+=t,s=this.columnHeaderTitle?e+1:e}return bu(n)||bu(r)?{col:n??o,row:r??s}:void 0}}setChartInstance(t,e,i){const n=this.getCellHeaderPaths(t,e);let r;if(this.indicatorsAsCol){const t=n.colHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;r=this._indicators?.find((e=>e.indicatorKey===t))}else{const t=n.rowHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;r=this._indicators?.find((e=>e.indicatorKey===t))}r&&(r.chartInstance=i)}getChartInstance(t,e){const i=this.getCellHeaderPaths(t,e);let n;if(this.indicatorsAsCol){const t=i.colHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;n=this._indicators?.find((e=>e.indicatorKey===t))}else{const t=i.rowHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;n=this._indicators?.find((e=>e.indicatorKey===t))}return n?.chartInstance}getDimension(t,e){return"column"===e?this.columnsDefine?.find((e=>"string"!=typeof e&&e.dimensionKey===t)):"row"===e?this.rowsDefine?.find((e=>"string"!=typeof e&&e.dimensionKey===t)):void 0}getAxisConfigInPivotChart(t,e){}isEmpty(t,e){return!1}getChartAxes(t,e){return[]}getRawChartSpec(t,e){return LU(t,e,this)}getChartDataId(t,e){return kU(t,e,this)}release(){const t=this._table._getActiveChartInstance();t?.release(),this._indicators?.forEach((t=>{t.chartInstance?.release()}))}getHeadNode(t){if(!Array.isArray(t))return;let e,i,n=this.rowTree,r=this.columnTree;for(let o=0;o<t.length;o++){const s=t[o];if((s.isPivotCorner||!s.value)&&o===t.length-1)return;let a=!1;for(let t=0;t<r.length;t++){const e=r[t];if((bu(s.dimensionKey)&&e.dimensionKey===s.dimensionKey||bu(s.indicatorKey)&&e.indicatorKey===s.indicatorKey)&&e.value===s.value){r=e.children,i=e,a=!0;break}}if(!a)for(let t=0;t<n.length;t++){const i=n[t];if((bu(s.dimensionKey)&&i.dimensionKey===s.dimensionKey||bu(s.indicatorKey)&&i.indicatorKey===s.indicatorKey)&&i.value===s.value){n=i.children,e=i;break}}}return e||(i||void 0)}}const jU={isEmpty:!0,id:void 0,field:void 0,headerType:void 0,define:void 0};class NU{_headerObjects=[];_headerObjectMap={};_indicatorObjects=[];_columnWidths=[];rowTree;columnTree;rowsDefine;columnsDefine;indicatorsDefine;indicatorKeys;_showRowHeader=!0;_showColumnHeader=!0;_rowHeaderTitle;_columnHeaderTitle;_indicatorShowType="column";indicatorsAsCol=!0;hideIndicatorName=!1;indicatorDimensionKey=Sf;indicatorTitle;rowKeysPath;colKeysPath;convertColKeys;rows;columns;rowShowAttrs;colShowAttrs;tree;dataset;dataConfig;_rowCount;_colCount;_bodyRowCount;cornerSetting;_table;hasTwoIndicatorAxes;_chartItemSpanSize;constructor(t,e){this._table=t,this._chartItemSpanSize=0,this.rowTree=t.options.rowTree,this.columnTree=t.options.columnTree,this.rowsDefine=t.options.rows??[],this.columnsDefine=t.options.columns??[],this.indicatorsDefine=t.options.indicators??[],this.indicatorTitle=t.options.indicatorTitle,this.dataset=e,this.dataConfig=e.dataConfig,this.indicatorKeys=e.indicatorKeys,this.indicatorsAsCol=t.options.indicatorsAsCol??!0,this.hideIndicatorName=t.options.hideIndicatorName??!1,this.showRowHeader=t.options.showRowHeader??!0,this.showColumnHeader=t.options.showColumnHeader??!0,this.rowHeaderTitle=t.options.rowHeaderTitle,this.columnHeaderTitle=t.options.columnHeaderTitle,this.cornerSetting=t.options.corner??{titleOnDimension:"column"},this.columns=e.columns,this.rows=e.rows,this.rowKeysPath=e.rowKeysPath,this.colKeysPath=e.colKeysPath,this.tree=e.tree,this.initState(),this.convertColKeys=fu(this.colKeysPath)}initState(){if(this.indicatorsAsCol&&!this.hideIndicatorName?this._indicatorShowType="column":this.indicatorsAsCol||this.hideIndicatorName?this._indicatorShowType="none":this._indicatorShowType="row",this.colShowAttrs="column"===this._indicatorShowType?this.columns.concat(this.indicatorDimensionKey):Array.from(this.columns),this.rowShowAttrs="row"===this._indicatorShowType?this.rows.concat(this.indicatorDimensionKey):Array.from(this.rows),this._bodyRowCount=this.rowKeysPath.length*(this.indicatorsAsCol?1:this.indicatorKeys.length),this.initHeaderObjects(),this.initIndicatorObjects(),this.rowHeaderTitle){const t="rowHeaderTitle",e="string"==typeof this.rowHeaderTitle.title?this.rowHeaderTitle.title:this.rowsDefine.reduce(((t,e)=>"string"==typeof e?t:t+(t?`/${e.title}`:`${e.title}`)),"");this._headerObjectMap[e]={id:e,title:e,field:t,headerType:this.rowHeaderTitle.headerType??"text",style:this.rowHeaderTitle.headerStyle,define:{}},this._headerObjectMap[t]={id:t,title:"",field:t,headerType:this.cornerSetting.headerType??"text",style:this.cornerSetting.headerStyle,define:{}},this._headerObjects.push(this._headerObjectMap[e]),this._headerObjects.push(this._headerObjectMap[t]),this.rowShowAttrs.unshift(t),this.rowKeysPath.forEach(((t,i)=>{t.unshift(e)}))}if(this.columnHeaderTitle){const t="columnHeaderTitleCell",e="string"==typeof this.columnHeaderTitle.title?this.columnHeaderTitle.title:this.columnsDefine.reduce(((t,e)=>"string"==typeof e?t:t+(t?`/${e.title}`:`${e.title}`)),"");this._headerObjectMap[e]={id:e,title:e,field:t,headerType:this.columnHeaderTitle.headerType??"text",style:this.columnHeaderTitle.headerStyle,define:{}},this._headerObjectMap[t]={id:t,title:"",field:t,headerType:this.cornerSetting.headerType??"text",style:this.cornerSetting.headerStyle,define:{}},this._headerObjects.push(this._headerObjectMap[e]),this._headerObjects.push(this._headerObjectMap[t]),this.colShowAttrs.unshift(t),this.colKeysPath.forEach(((t,i)=>{t.unshift(e)}))}if(this._table.isPivotChart())if(this.hasTwoIndicatorAxes=this._indicatorObjects.some((t=>!!(t.chartSpec&&t.chartSpec.series&&t.chartSpec.series.length>1))),this._chartItemSpanSize=0,this._indicatorObjects.find((t=>(t.chartSpec?.barWidth&&(this._chartItemSpanSize=t.chartSpec?.barWidth),this._chartItemSpanSize>0||(t.chartSpec.series?.find((t=>(t.barWidth&&(this._chartItemSpanSize=t.barWidth),this._chartItemSpanSize>0))),this._chartItemSpanSize>0)))),this.indicatorsAsCol){const t="rowHeaderEmpty";this._headerObjectMap[t]={id:t,title:"",field:t,headerType:this.cornerSetting.headerType??"text",style:this.cornerSetting.headerStyle,define:{}},this._headerObjects.push(this._headerObjectMap[t]),this.rowShowAttrs.push(t),this.hasTwoIndicatorAxes||this.colShowAttrs.pop()}else{const t=this._table.pivotChartAxes.find((t=>"left"===t.orient));!1===t?.visible&&this.rowShowAttrs.pop()}this._colCount=(0===this.colKeysPath.length?1:this.colKeysPath.length)*(this.indicatorsAsCol?this.indicatorKeys.length:1)+this.rowHeaderLevelCount+this.rightFrozenColCount,this._rowCount=(0===this.rowKeysPath.length?1:this.rowKeysPath.length)*(this.indicatorsAsCol?1:this.indicatorKeys.length)+this.columnHeaderLevelCount+this.bottomFrozenRowCount,this.setColumnWidths()}setColumnWidths(){const t=new Array(this.colCount).fill(void 0);if(this.showRowHeader&&(this.rowHeaderTitle&&(t[0]={}),this.rowShowAttrs.forEach(((e,i)=>{const n=this.rowsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===e));n&&(t[i+(this.rowHeaderTitle?1:0)]={width:n.width,minWidth:n.minWidth,maxWidth:n.maxWidth})}))),this.indicatorsAsCol)for(let e=this.rowHeaderLevelCount;e<this.colCount;e++){const i=this.getBody(e,this.columnHeaderLevelCount);t[e]={width:i?.width,minWidth:i?.minWidth,maxWidth:i?.maxWidth}}else{let e,i,n,r=0;this._indicatorObjects.forEach(((t,o)=>{"number"==typeof t.width?r=Math.max(t.width,r):"auto"===t.width&&(n=!0),"number"==typeof t.minWidth&&(i=Math.max(t.minWidth,i)),"number"==typeof t.maxWidth&&(e=Math.max(t.maxWidth,e))})),r=r>0?r:n?"auto":void 0,t.fill({width:r,minWidth:i,maxWidth:e},this.rowHeaderLevelCount,this.colCount-this.rightFrozenColCount)}this._columnWidths=t}get columnWidths(){return this._columnWidths}getColumnWidthDefined(t){return this._columnWidths[t]}getDimensionInfo(t){return this.rowsDefine?.find((e=>"string"!=typeof e&&e.dimensionKey===t))??this.columnsDefine?.find((e=>"string"!=typeof e&&e.dimensionKey===t))}getIndicatorInfo(t,e=""){const i=this.indicatorsDefine?.find((i=>"string"!=typeof i&&(t?i.indicatorKey===t:!!e&&i.title===e)));return i}getColKeysPath(){return this.colKeysPath}getRowKeysPath(){return this.rowKeysPath}initHeaderObjects(){for(let t=0,e=this.rowKeysPath.length;t<=e-1;t++){const e=this.rowKeysPath[t];for(let t=0,i=e.length;t<=i-1;t++)if(!this._headerObjectMap[e[t]]){const i=e[t].split(this.dataset.stringJoinChar),n=this.getDimensionInfo(this.rows[i.length-1]);this._headerObjectMap[e[t]]={id:e[t],field:n?.dimensionKey??this.rows[i.length-1],title:i[i.length-1],style:n?.headerStyle,define:{field:n?.dimensionKey??this.rows[i.length-1],headerType:n?.headerType??"text",cellType:"text"},fieldFormat:n?.headerFormat,dropDownMenu:n?.dropDownMenu,headerType:n?.headerType??"text",width:n?.width},this._headerObjects.push(this._headerObjectMap[e[t]])}}for(let t=0,e=this.colKeysPath.length;t<=e-1;t++){const e=this.colKeysPath[t];for(let t=0,i=e.length;t<=i-1;t++)if(!this._headerObjectMap[e[t]]){const i=e[t].split(this.dataset.stringJoinChar),n=this.getDimensionInfo(this.columns[i.length-1]);this._headerObjectMap[e[t]]={id:e[t],field:n?.dimensionKey??this.columns[i.length-1],title:i[i.length-1],style:n?.headerStyle,define:{field:n?.dimensionKey??this.columns[i.length-1],headerType:n?.headerType??"text",cellType:"text"},fieldFormat:n?.headerFormat,dropDownMenu:n?.dropDownMenu,headerType:n?.headerType??"text",width:n?.width},this._headerObjects.push(this._headerObjectMap[e[t]])}}let t;this.indicatorsDefine.forEach((t=>{const e="string"==typeof t?t:t.indicatorKey,i="string"==typeof t?void 0:t;this._headerObjectMap[e]||(this._headerObjectMap[e]={id:e,field:this.indicatorDimensionKey,title:i?.title??e,style:i?.headerStyle,define:{field:this.indicatorDimensionKey,headerType:i?.headerType??"text",cellType:"text"},dropDownMenu:i?.dropDownMenu,headerType:i?.headerType??"text",width:i?.width},this._headerObjects.push(this._headerObjectMap[e]))})),"column"===this.cornerSetting.titleOnDimension?t=this.colShowAttrs:"row"===this.cornerSetting.titleOnDimension&&(t=this.rowShowAttrs),t?.forEach((t=>{if(!this._headerObjectMap[t]){const e=this.getDimensionInfo(t);this._headerObjectMap[t]={id:t,field:t,title:t===this.indicatorDimensionKey?this.indicatorTitle:e?.title??t,style:this.cornerSetting?.headerStyle,define:{field:t,headerType:this.cornerSetting?.headerType??"text",cellType:"text"},dropDownMenu:e?.dropDownMenu,headerType:this.cornerSetting?.headerType??"text",width:e?.width},this._headerObjects.push(this._headerObjectMap[t])}}))}initIndicatorObjects(){this.indicatorKeys.forEach((t=>{const e=this.indicatorsDefine?.find((e=>"string"!=typeof e&&e.indicatorKey===t));this._indicatorObjects.push({id:t,indicatorKey:t,field:t,define:Object.assign({field:t,headerType:"text",cellType:e?.cellType??e?.columnType??"text"},e),fieldFormat:e?.format,cellType:e?.cellType??e?.columnType??"text",chartModule:e&&("chartModule"in e?e?.chartModule:null),chartSpec:e&&("chartSpec"in e?e?.chartSpec:null),sparklineSpec:e&&("sparklineSpec"in e?e?.sparklineSpec:null),style:e?.style,icon:e?.icon,width:e?.width,minWidth:e?.minWidth,maxWidth:e?.maxWidth,disableColumnResize:e?.disableColumnResize})}))}get showColumnHeader(){return this._showColumnHeader}set showColumnHeader(t){this._showColumnHeader=t}get showRowHeader(){return this._showRowHeader}set showRowHeader(t){this._showRowHeader=t}get columnHeaderTitle(){return this._columnHeaderTitle}set columnHeaderTitle(t){this._columnHeaderTitle=t}get rowHeaderTitle(){return this._rowHeaderTitle}set rowHeaderTitle(t){this._rowHeaderTitle=t}getCellLocation(t,e){return this.isCornerHeader(t,e)?"cornerHeader":this.isColumnHeader(t,e)?"columnHeader":this.isRowHeader(t,e)?"rowHeader":"body"}isHeader(t,e){return t<this.rowHeaderLevelCount||(e<this.columnHeaderLevelCount||(t>=this.colCount-this.rightFrozenColCount||e>=this.rowCount-this.bottomFrozenRowCount))}isCornerHeader(t,e){return t<this.rowHeaderLevelCount&&e<this.columnHeaderLevelCount}isColumnHeader(t,e){return t>=this.rowHeaderLevelCount&&e<this.columnHeaderLevelCount}isRightFrozenColumn(t,e){return t>=this.colCount-this.rightFrozenColCount&&e>=this.columnHeaderLevelCount&&e<this.rowCount-this.bottomFrozenRowCount}isBottomFrozenRow(t,e){return t>=this.rowHeaderLevelCount&&e>=this.rowCount-this.bottomFrozenRowCount&&t<this.colCount-this.rightFrozenColCount}isLeftBottomCorner(t,e){return t<this.rowHeaderLevelCount&&e>=this.rowCount-this.bottomFrozenRowCount}isRightTopCorner(t,e){return t>=this.colCount-this.rightFrozenColCount&&e<this.columnHeaderLevelCount}isRightBottomCorner(t,e){return t>=this.colCount-this.rightFrozenColCount&&e>=this.rowCount-this.bottomFrozenRowCount}isRowHeader(t,e){return t<this.rowHeaderLevelCount&&e>=this.columnHeaderLevelCount}isColumnIndicatorHeader(t,e){return"column"===this._indicatorShowType&&e===this.columnHeaderLevelCount-1&&t>=this.rowHeaderLevelCount}isRowIndicatorHeader(t,e){return"row"===this._indicatorShowType&&t===this.rowHeaderLevelCount-1&&e>=this.columnHeaderLevelCount}isIndicatorHeader(t,e){return this.isColumnIndicatorHeader(t,e)||this.isRowIndicatorHeader(t,e)}getColumnHeaderRange(){return{start:{col:this.rowHeaderLevelCount,row:0},end:{col:this.colCount-1,row:this.columnHeaderLevelCount-1}}}getRowHeaderRange(){return{start:{col:0,row:this.columnHeaderLevelCount},end:{col:this.rowHeaderLevelCount-1,row:this.rowCount-1}}}getCornerHeaderRange(){return{start:{col:0,row:0},end:{col:this.rowHeaderLevelCount-1,row:this.columnHeaderLevelCount-1}}}getBodyRange(){return{start:{col:this.rowHeaderLevelCount,row:this.columnHeaderLevelCount},end:{col:this.colCount-1,row:this.rowCount-1}}}resetCellIds(){}get headerLevelCount(){return this.columnHeaderLevelCount}get columnHeaderLevelCount(){const t=this.colShowAttrs.length;if(this.showColumnHeader){return this.indicatorsAsCol&&this.hideIndicatorName&&this.colShowAttrs[this.colShowAttrs.length-1]===this.indicatorDimensionKey?t-1:t}return this.indicatorsAsCol?this.hideIndicatorName?0:1:0}get rowHeaderLevelCount(){const t=this.rowShowAttrs.length;if(this.showRowHeader){return this.indicatorsAsCol?t:this.hideIndicatorName&&this.rowShowAttrs[this.rowShowAttrs.length-1]===this.indicatorDimensionKey?t-1:t}return this.indicatorsAsCol||this.hideIndicatorName?0:1}get colCount(){return this._colCount}get rowCount(){return this._rowCount}get bodyRowCount(){return this._bodyRowCount}get bottomFrozenRowCount(){if(!this._table.isPivotChart())return 0;const t=this._table.pivotChartAxes.find((t=>"bottom"===t.orient));return!1===t?.visible?0:(this.indicatorsAsCol,1)}get rightFrozenColCount(){if(!this._table.isPivotChart())return 0;const t=this._table.pivotChartAxes.find((t=>"right"===t.orient));return!1===t?.visible||this.indicatorsAsCol?0:this.hasTwoIndicatorAxes?1:0}get leftAxesCount(){if(!this._table.isPivotChart())return 0;const t=this._table.pivotChartAxes.find((t=>"left"===t.orient));return!1===t?.visible?0:(this.indicatorsAsCol,1)}get topAxesCount(){if(!this._table.isPivotChart())return 0;const t=this._table.pivotChartAxes.find((t=>"top"===t.orient));return!1===t?.visible?0:this.indicatorsAsCol&&this.hasTwoIndicatorAxes?1:0}get rightAxesCount(){return this.rightFrozenColCount}get bottomAxesCount(){return this.bottomFrozenRowCount}get headerObjects(){return this._headerObjects}get columnObjects(){return this._indicatorObjects}getCellId(t,e){if(t<this.rowHeaderLevelCount&&e>=this.rowCount-this.bottomFrozenRowCount||e<this.columnHeaderLevelCount&&t>=this.colCount-this.rightFrozenColCount)return 0;if(e>=0&&t>=0)if(this.isCornerHeader(t,e)){if("column"===this.cornerSetting.titleOnDimension)return this.colShowAttrs[e];if("row"===this.cornerSetting.titleOnDimension)return this.rowShowAttrs[t]}else{if(this.isColumnHeader(t,e))return e<this.columns.length+(this.columnHeaderTitle?1:0)?this.convertColKeys[e][this.indicatorsAsCol?Math.floor((t-this.rowHeaderLevelCount)/this.indicatorKeys.length):t-this.rowHeaderLevelCount]:this.indicatorKeys[(t-this.rowHeaderLevelCount)%this.indicatorKeys.length];if(this.isRowHeader(t,e))return t<this.rows.length+(this.rowHeaderTitle?1:0)?this.rowKeysPath[this.indicatorsAsCol?e-this.columnHeaderLevelCount:Math.floor((e-this.columnHeaderLevelCount)/this.indicatorKeys.length)][t]:this.indicatorKeys[(e-this.columnHeaderLevelCount)%this.indicatorKeys.length];if(this.isRightFrozenColumn(t,e))return this.indicatorsAsCol?this.rowKeysPath[e-this.columnHeaderLevelCount][this.rowHeaderLevelCount-1]:this.indicatorKeys[(e-this.columnHeaderLevelCount)%this.indicatorKeys.length];if(this.isBottomFrozenRow(t,e))return this.indicatorsAsCol?this.indicatorKeys[(t-this.rowHeaderLevelCount)%this.indicatorKeys.length]:this.convertColKeys[this.convertColKeys.length-1]?.[Math.floor((t-this.rowHeaderLevelCount)/this.indicatorKeys.length)]}return 0}getIndicatorKey(t,e){if(this.isHeader(t,e))return"";if(this.indicatorsAsCol){const e=t-this.rowHeaderLevelCount;return this.indicatorKeys[e%this.indicatorKeys.length]}const i=e-this.columnHeaderLevelCount;return this.indicatorKeys[i%this.indicatorKeys.length]}getHeader(t,e){const i=this.getCellId(t,e);return this._headerObjectMap[i]??jU}getHeaderField(t,e){const i=this.getCellId(t,e);return this._headerObjectMap[i]?.field||this.getBody(t,e)?.field}getHeaderFieldKey(t,e){}getHeaderCellAdress(t){}getHeaderCellAddressByField(t){throw new Error(`Method not implemented.${t}`)}getBody(t,e){const i=this.getCellHeaderPaths(t,e);if(this.indicatorsAsCol){const t=i.colHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;return this._indicatorObjects.find((e=>e.indicatorKey===t))??this._indicatorObjects[0]??{id:"",field:void 0,indicatorKey:void 0,cellType:void 0,define:void 0}}const n=i.rowHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;return this._indicatorObjects.find((t=>t.indicatorKey===n))??this._indicatorObjects[0]??{id:"",field:void 0,indicatorKey:void 0,cellType:void 0,define:void 0}}getBodyLayoutRangeById(t){for(let e=0;e<(this.colCount??0);e++)if(t===this.columnObjects[e].id)return{start:{col:e,row:0},end:{col:e,row:0}};throw new Error(`can not found body layout @id=${t}`)}getCellRange(t,e){const i={start:{col:t,row:e},end:{col:t,row:e}};if(!this.isHeader(t,e)||-1===t||-1===e||this.isIndicatorHeader(t,e))return i;if(this.isRightFrozenColumn(t,e)||this.isBottomFrozenRow(t,e))return i;const n=this.getCellId(t,e);for(let r=t-1;r>=0&&n===this.getCellId(r,e);r--)i.start.col=r;for(let r=t+1;r<(this.colCount??0)&&n===this.getCellId(r,e);r++)i.end.col=r;for(let r=e-1;r>=0&&n===this.getCellId(t,r);r--)i.start.row=r;for(let r=e+1;r<(this.rowCount??0)&&n===this.getCellId(t,r);r++)i.end.row=r;return i}isCellRangeEqual(t,e,i,n){const r=this.getCellRange(t,e),o=this.getCellRange(i,n);return r.start.col===o.start.col&&r.end.col===o.end.col&&r.start.row===o.start.row&&r.end.row===o.end.row}getRecordIndexByRow(t){return t<this.columnHeaderLevelCount?-1:this.indicatorsAsCol?t-this.columnHeaderLevelCount:Math.floor((t-this.columnHeaderLevelCount)/this.indicatorKeys.length)}getRecordIndexByCol(t){return t<this.rowHeaderLevelCount?-1:this.indicatorsAsCol?Math.floor((t-this.rowHeaderLevelCount)/this.indicatorKeys.length):t-this.rowHeaderLevelCount}getRecordStartRowByRecordIndex(t){return this.columnHeaderLevelCount+t}getCellHeaderPaths(t,e){const i=this.getRecordIndexByCol(t),n=this.getRecordIndexByRow(e);let r,o,s,a;return i>=0&&(r=this.colKeysPath[i],s=r?.[r.length-1]?.split(this.dataset.stringJoinChar),s&&this.showColumnHeader&&e<this.columns.length-1?s=s.slice(0,e+1):s||(s=[])),n>=0&&(o=this.rowKeysPath[n],a=o?.[o.length-1]?.split(this.dataset.stringJoinChar),a&&this.showRowHeader&&t<this.rows.length-1?a=a.slice(0,t+1):a||(a=[])),s&&this.indicatorsAsCol&&t>=this.rowHeaderLevelCount?s.push(this.indicatorKeys[(t-this.rowHeaderLevelCount)%this.indicatorKeys.length]):a&&e>=this.columnHeaderLevelCount&&a.push(this.indicatorKeys[(e-this.columnHeaderLevelCount)%this.indicatorKeys.length]),{colHeaderPaths:s?.map(((t,e)=>{const i=this._indicatorObjects.find((e=>e.indicatorKey===t));return{dimensionKey:i?void 0:this.colShowAttrs[e],indicatorKey:i?t:void 0,value:i?i.define.title:t}}))??[],rowHeaderPaths:a?.map(((t,e)=>{const i=this._indicatorObjects.find((e=>e.indicatorKey===t));return{dimensionKey:i?void 0:this.rowShowAttrs[e],indicatorKey:i?t:void 0,value:i?i.define.title:t}}))??[]}}getCellAdressByHeaderPath(t){let e,i;if(Array.isArray(t)){if(t.length>this.rowShowAttrs.length+this.colShowAttrs.length)return;e=t.filter((t=>this.colShowAttrs.indexOf(t.dimensionKey)>=0)),i=t.filter((t=>this.rowShowAttrs.indexOf(t.dimensionKey)>=0))}else e=t.colHeaderPaths,i=t.rowHeaderPaths;if(!Array.isArray(e)&&!Array.isArray(i))return;e?.sort(((t,e)=>this.colShowAttrs.indexOf(t.dimensionKey??this.indicatorDimensionKey)-this.colShowAttrs.indexOf(e.dimensionKey??this.indicatorDimensionKey))),i?.sort(((t,e)=>this.rowShowAttrs.indexOf(t.dimensionKey??this.indicatorDimensionKey)-this.rowShowAttrs.indexOf(e.dimensionKey??this.indicatorDimensionKey))),e?.length>=1&&i?.length;let n,r=0,o=0,s=this.rowTree,a=this.columnTree;if(e)for(let t=0;t<e.length;t++){const i=e[t];if(i.indicatorKey){n=i.indicatorKey;break}for(let t=0;t<a.length;t++){const e=a[t];if(!bu(i.indicatorKey)&&e.dimensionKey===i.dimensionKey&&e.value===i.value){a=e.children,a&&0!==a.length&&!a?.[0]?.indicatorKey||(r+=t);break}r+=e.children?.[0]?.indicatorKey?0:e.children?.length??0}}if(i)for(let t=0;t<i.length;t++){const e=i[t];if(e.indicatorKey){n=e.indicatorKey;break}for(let t=0;t<s.length;t++){const i=s[t];if(!bu(e.indicatorKey)&&i.dimensionKey===e.dimensionKey&&i.value===e.value){s=i.children,s&&0!==s.length&&!s?.[0]?.indicatorKey||(o+=t);break}o+=i.children?.[0]?.indicatorKey?0:i.children?.length??0}}return r=(this.indicatorsAsCol?r*this.indicatorKeys.length+this.indicatorKeys.indexOf(n):r)+this.rowHeaderLevelCount,o=(this.indicatorsAsCol?o:o*this.indicatorKeys.length+this.indicatorKeys.indexOf(n))+this.columnHeaderLevelCount,bu(r)||bu(o)?{col:r??undefined,row:o??undefined}:void 0}getHeaderDimension(t,e){if(this.isHeader(t,e)){const i=this.getHeader(t,e);return this.rowsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.field))??this.columnsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.field))}}updateDataset(t){this.dataset=t,this.dataConfig=t.dataConfig,this.rowKeysPath=t.rowKeysPath,this.colKeysPath=t.colKeysPath,this.tree=t.tree,this._indicatorObjects=[],this._headerObjects=[],this._headerObjectMap={},this.initState(),this.convertColKeys=fu(this.colKeysPath)}isHeaderForColWidth(t,e){return this.isHeader(t,e)}getHeaderForColWidth(t,e){return this.getHeader(t,e)}setChartInstance(t,e,i){const n=this.getCellHeaderPaths(t,e);let r;if(this.indicatorsAsCol){const t=n.colHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;r=this._indicatorObjects.find((e=>e.indicatorKey===t))}else{const t=n.rowHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;r=this._indicatorObjects.find((e=>e.indicatorKey===t))}r&&(r.chartInstance=i)}getChartInstance(t,e){const i=this.getCellHeaderPaths(t,e);let n;if(this.indicatorsAsCol){const t=i.colHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;n=this._indicatorObjects.find((e=>e.indicatorKey===t))}else{const t=i.rowHeaderPaths.find((t=>t.indicatorKey))?.indicatorKey;n=this._indicatorObjects.find((e=>e.indicatorKey===t))}return n?.chartInstance}_generateChartState(){return{vtable_selected:{filter:t=>{if(this._table._selectedDataItemsInChart.length>=1){return!!this._table._selectedDataItemsInChart.find((e=>{for(const i in e)if(e[i]!==t[i])return!1;return!0}))}if(this._table._selectedDimensionInChart?.length){return!!this._table._selectedDimensionInChart.every((e=>t[e.key]===e.value))}return!1}},vtable_selected_reverse:{filter:t=>{if(this._table._selectedDataItemsInChart.length>=1){return!this._table._selectedDataItemsInChart.find((e=>{for(const i in e)if(e[i]!==t[i])return!1;return!0}))}if(this._table._selectedDimensionInChart?.length){return!this._table._selectedDimensionInChart.every((e=>t[e.key]===e.value))}return!1}}}}updateDataStateToChartInstance(t){t||(t=this._table._getActiveChartInstance());const e=this._generateChartState();this._indicatorObjects.forEach((t=>{t.chartInstance.updateState(e)})),t?.updateState(e)}updateDataStateToActiveChartInstance(t){t||(t=this._table._getActiveChartInstance());const e=this._generateChartState();t?.updateState(e)}getOptimunWidthForChart(t){const e=this.getCellHeaderPaths(t,this.columnHeaderLevelCount).colHeaderPaths;let i;for(const t in this.dataset.collectValuesBy)if("xField"===this.dataset.collectValuesBy[t].type&&!this.dataset.collectValuesBy[t].range){i=this.dataset.collectedValues[t][e.map((t=>t.value)).join(this.dataset.stringJoinChar)];break}const n=this._chartItemSpanSize||25;return(i?.length??0)*(n+n/3)}getOptimunHeightForChart(t){const e=this.getCellHeaderPaths(this.rowHeaderLevelCount,t).rowHeaderPaths;let i;for(const t in this.dataset.collectValuesBy)if("yField"===this.dataset.collectValuesBy[t].type&&!this.dataset.collectValuesBy[t].range){i=this.dataset.collectedValues[t][e.map((t=>t.value)).join(this.dataset.stringJoinChar)];break}const n=this._chartItemSpanSize||25;return(i?.length??0)*(n+n/3)}getIndicatorKeyInChartSpec(t,e){const i=this.getRawChartSpec(t,e),n=[];return i?(!1===this.indicatorsAsCol?i.series?i.series.forEach((t=>{const e=t.yField;n.push(e)})):n.push(i.yField):i.series?i.series.forEach((t=>{const e=t.xField;n.push(e)})):n.push(i.xField),n):null}getDimensionKeyInChartSpec(t,e){const i=this.getRawChartSpec(t,e),n=[];return i?(!1===this.indicatorsAsCol?n.push(i.xField??i?.series[0]?.xField):n.push(i.yField??i?.series[0]?.yField),n):null}getAxisConfigInPivotChart(t,e){return BN(t,e,this)}getRawChartSpec(t,e){return LU(t,e,this)}getChartSpec(t,e){return function(t,e,i){let n=i.getRawChartSpec(t,e);return n?(n=cd(n),n.axes=i.getChartAxes(t,e),n.padding=0,n.dataZoom=[],n):null}(t,e,this)}getChartAxes(t,e){return function(t,e,i){const n=[];if(i.indicatorsAsCol){const r=i.getIndicatorKeyInChartSpec(t,e),o=i.getRecordIndexByCol(t);r.forEach(((r,s)=>{qu(r)&&(r=r[0]);const a=RN(t,e,0===s?"bottom":"top",i),l=i.dataset.collectedValues[r+(a?"_align":"")]?i.dataset.collectedValues[r+(a?"_align":"")]:i.dataset.collectedValues[r],h=l?.[i.getColKeysPath()[o][Math.max(0,i.columnHeaderLevelCount-1-i.topAxesCount)]]??{min:0,max:1},c=MN(t,e,0===s?"bottom":"top",i);c?.zero&&(h.min=Math.min(h.min,0),h.max=Math.max(h.max,0)),n.push(fd({range:h},c,{type:"linear",orient:0===s?"bottom":"top",label:{visible:!1},title:{visible:!1},domainLine:{visible:!1},seriesIndex:s,height:-1,sync:{axisId:HU}}))}));let s=i.getDimensionKeyInChartSpec(i.rowHeaderLevelCount,t)[0];qu(s)&&(s=s[0]);const a=i.dataset.cacheCollectedValues[s]||i.dataset.collectedValues[s]||[],l=i.getRecordIndexByRow(e),h=i.getRowKeysPath()[l],c=a[h[h.length-1]],u=MN(t,e,"left",i);n.push(fd({domain:Array.from(c)},u,{type:"band",orient:"left",label:{visible:!1,space:0},domainLine:{visible:!1},tick:{visible:!1},subTick:{visible:!1},title:{visible:!1},width:-1}))}else{const r=i.getIndicatorKeyInChartSpec(t,e),o=i.getRecordIndexByRow(e);r.forEach(((r,s)=>{qu(r)&&(r=r[0]);const a=RN(t,e,0===s?"left":"right",i),l=i.dataset.collectedValues[r+(a?"_align":"")]?i.dataset.collectedValues[r+(a?"_align":"")]:i.dataset.collectedValues[r],h=l?.[i.getRowKeysPath()[o]?.[Math.max(0,i.rowHeaderLevelCount-1-i.leftAxesCount)]??""]??{min:0,max:1},c=MN(t,e,0===s?"left":"right",i);c?.zero&&(h.min=Math.min(h.min,0),h.max=Math.max(h.max,0)),n.push(fd({range:h},c,{type:"linear",orient:0===s?"left":"right",label:{visible:!1},title:{visible:!1},domainLine:{visible:!1},seriesIndex:s,width:-1,sync:{axisId:HU}}))}));let s=i.getDimensionKeyInChartSpec(t,i.columnHeaderLevelCount)[0];qu(s)&&(s=s[0]);const a=i.dataset.cacheCollectedValues[s]||i.dataset.collectedValues[s]||[],l=i.getRecordIndexByCol(t),h=i.getColKeysPath()[l],c=a?.[h?.[h?.length-1]??""]??[],u=MN(t,e,"bottom",i);n.push(fd({domain:Array.from(c)},u,{type:"band",orient:"bottom",visible:!0,label:{visible:!1,space:0},domainLine:{visible:!1},tick:{visible:!1},subTick:{visible:!1},title:{visible:!1},height:-1}))}return n}(t,e,this)}getChartDataId(t,e){return kU(t,e,this)}isEmpty(t,e){return!!this._table.isPivotChart()&&(t>this.colCount-this.rightFrozenColCount-1||e>this.rowCount-this.bottomFrozenRowCount-1||!(!this.hasTwoIndicatorAxes||!this.indicatorsAsCol||e!==this.columnHeaderLevelCount-1))}release(){const t=this._table._getActiveChartInstance();t?.release(),this._indicatorObjects.forEach((t=>{t.chartInstance?.release()}))}}class GU{dataConfig;records;tree={};colFlatKeys={};rowFlatKeys={};stringJoinChar=String.fromCharCode(0);rowsIsTotal=[];colsIsTotal=[];colGrandTotalLabel;colSubTotalLabel;rowGrandTotalLabel;rowSubTotalLabel;constructor(t,e){if(this.dataConfig=t,e){this.records=e;const t="undefined"!=typeof window?window.performance.now():0;this.setRecords(e);const i="undefined"!=typeof window?window.performance.now():0;console.log("processRecords:",i-t)}delete this.rowFlatKeys,delete this.colFlatKeys}setRecords(t){this.processRecords()}processRecords(){for(let t=0,e=this.records.length;t<e;t++){const e=this.records[t];this.processRecord(e)}}processRecord(t){const e=[],i=[];for(let e=0,n=this.dataConfig.rows.length;e<n;e++){const n=this.dataConfig.rows[e];void 0!==t[n]&&n!==this.dataConfig.indicatorDimensionKey&&i.push(t[n])}for(let i=0,n=this.dataConfig.columns.length;i<n;i++){const n=this.dataConfig.columns[i];void 0!==t[n]&&n!==this.dataConfig.indicatorDimensionKey&&e.push(t[n])}this.dataConfig.indicators?.forEach((n=>{const r=t[n];void 0!==r&&(this.dataConfig.indicatorsAsCol?e.push(n):i.push(n));const o=i.join(this.stringJoinChar),s=e.join(this.stringJoinChar);0!==i.length&&(this.rowFlatKeys[o]||(this.rowFlatKeys[o]=1)),0!==e.length&&(this.colFlatKeys[s]||(this.colFlatKeys[s]=1)),0===e.length&&0===i.length||(this.tree[o]||(this.tree[o]={}),void 0!==r&&(this.tree[o][s]={value:r,record:t},this.dataConfig.indicatorsAsCol?e.pop():i.pop()))}))}getTreeNode(t=[],e=[],i){let n,r;if("string"==typeof t)n=t;else{let e=!1;t.map(((n,r)=>{n===i&&(t.splice(r,1),e=!0)})),e&&t.push(i),n=t.join(this.stringJoinChar)}if("string"==typeof e)r=e;else{let t=!1;e.map(((n,r)=>{n===i&&(e.splice(r,1),t=!0)})),t&&e.push(i),r=e.join(this.stringJoinChar)}return this.tree?.[n]?.[r]??void 0}}class VU{className="Aggregator";isRecord=!0;records=[];type;field;formatFun;_formatedValue;constructor(t,e,i){this.field=t,this.formatFun=e,this.isRecord=i??this.isRecord}formatValue(){return this._formatedValue||(this.formatFun?this._formatedValue=this.formatFun(this.value()):this._formatedValue=this.value()),this._formatedValue}reset(){this.records=[]}}class UU extends VU{type=Yc.RECORD;isRecord=!0;push(t){this.isRecord&&("Aggregator"===t.className?this.records.push(...t.records):this.records.push(t))}value(){return this.records}reset(){this.records=[]}}class KU extends VU{type=Yc.SUM;sum=0;push(t){this.isRecord&&("Aggregator"===t.className?this.records.push(...t.records):this.records.push(t)),"Aggregator"===t.className?this.sum+=t.value():isNaN(parseFloat(t[this.field]))||(this.sum+=parseFloat(t[this.field]))}value(){return this.sum}reset(){this.records=[],this.sum=0}}class $U extends VU{type=Yc.COUNT;count=0;push(t){this.isRecord&&("Aggregator"===t.className?this.records.push(...t.records):this.records.push(t)),"Aggregator"===t.className?this.count+=t.value():this.count++}value(){return this.count}reset(){this.records=[],this.count=0}}class XU extends VU{type=Yc.AVG;sum=0;count=0;push(t){this.isRecord&&("Aggregator"===t.className?this.records.push(...t.records):this.records.push(t)),"Aggregator"===t.className&&t.type===Yc.AVG?(this.sum+=t.sum,this.count+=t.count):isNaN(parseFloat(t[this.field]))||(this.sum+=parseFloat(t[this.field]),this.count++)}value(){return this.sum/this.count}reset(){this.records=[],this.sum=0,this.count=0}}class YU extends VU{type=Yc.MAX;max=Number.MIN_SAFE_INTEGER;push(t){this.isRecord&&("Aggregator"===t.className?this.records.push(...t.records):this.records.push(t)),"Aggregator"===t.className?this.max=t.max>this.max?t.max:this.max:"number"==typeof t?this.max=t>this.max?t:this.max:"number"==typeof t[this.field]?this.max=t[this.field]>this.max?t[this.field]:this.max:isNaN(t[this.field])||(this.max=parseFloat(t[this.field])>this.max?parseFloat(t[this.field]):this.max)}value(){return this.max}reset(){this.records=[],this.max=Number.MIN_SAFE_INTEGER}}class qU extends VU{type=Yc.MIN;min=Number.MAX_SAFE_INTEGER;isRecord=!1;push(t){this.isRecord&&("Aggregator"===t.className?this.records.push(...t.records):this.records.push(t)),"Aggregator"===t.className?this.min=t.min<this.min?t.min:this.min:"number"==typeof t?this.min=t<this.min?t:this.min:"number"==typeof t[this.field]&&(this.min=t[this.field]<this.min?t[this.field]:this.min)}value(){return this.min}reset(){this.records=[],this.min=Number.MAX_SAFE_INTEGER}}function ZU(t,e){return t&&e?t.toString().localeCompare(e.toString(),"zh"):t?1:-1}function JU(t,e){const i=/(\d+)|(\D+)/g,n=/\d/,r=/^0/;let o,s,a,l,h=0,c=0;if(null!==e&&null===t)return-1;if(null!==t&&null===e)return 1;if("number"==typeof t&&isNaN(t))return-1;if("number"==typeof e&&isNaN(e))return 1;if(h=+t,c=+e,h<c)return-1;if(h>c)return 1;if("number"==typeof t&&"number"!=typeof e)return-1;if("number"==typeof e&&"number"!=typeof t)return 1;if("number"==typeof t&&"number"==typeof e)return 0;if(isNaN(c)&&!isNaN(h))return-1;if(isNaN(h)&&!isNaN(c))return 1;if(o=String(t),a=String(e),o===a)return 0;if(!n.test(o)||!n.test(a))return o>a?1:-1;for(o=o.match(i),a=a.match(i);o.length&&a.length;)if(s=o.shift(),l=a.shift(),s!==l)return n.test(s)&&n.test(l)?s.replace(r,".0")-l.replace(r,".0"):s>l?1:-1;return o.length-a.length}function QU(t){return 2===t.length&&td(t[0])&&td(t[1])&&t[1]>=t[0]}function tK(t){const e=t[1]-t[0],i=t[1]*t[0]<0;let n=t[0]<=0?0-t[0]:0,r=t[1]>0?t[1]-0:0;return 0===e?t[0]<0?(n=1,r=0):t[0]>0&&(n=0,r=1):(n/=e,r/=e),{total:e,negative:n,positive:r,includeZero:i,domain:t,extendable_min:!0,extendable_max:!0}}function eK(t,e){const{positive:i,negative:n,extendable_min:r,extendable_max:o,domain:s}=t,{positive:a,negative:l,extendable_min:h,extendable_max:c,domain:u}=e;if(a>0){if(!h)return!1;let t=n/i;o&&(t=n/Math.max(i,a),s[1]=-s[0]/t),u[0]=-u[1]*t}else if(l>0){if(!c)return!1;let t=i/n;r&&(t=i/Math.max(n,n),s[0]=-s[1]/t),u[1]=-u[0]*t}return!0}function iK(t,e){const{extendable_min:i,extendable_max:n,domain:r}=t,{positive:o,negative:s,domain:a}=e;return(0!==o||0!==s)&&(!(o>0&&!n)&&(!(s>0&&!i)&&(r[0]=a[0],r[1]=a[1],!0)))}function nK(t,e){const{positive:i,negative:n,extendable_max:r,domain:o}=t,{positive:s,negative:a,extendable_min:l,domain:h}=e;if(r&&l){const t=Math.max(n,a)/Math.max(i,s);o[1]=-o[0]/t,h[0]=-h[1]*t}else if(l){const t=n/i;h[0]=-h[1]*t}else{if(!r)return!1;{const t=a/s;o[1]=-o[0]/t}}return!0}function rK(t,e){const{extendable_min:i,domain:n}=t,{extendable_max:r,domain:o}=e;return!(!i||!r)&&(n[0]=-n[1],o[1]=-o[0],!0)}function oK(t,e){const i=[t.min,t.max],n=[e.min,e.max];if(!QU(i)||!QU(n))return;const r=tK(i),o=tK(n),{positive:s,negative:a,extendable_min:l,extendable_max:h,includeZero:c}=r,{positive:u,negative:d,extendable_min:p,extendable_max:f,includeZero:g}=o;if(0===s&&0===a){if(!iK(r,o))return}else if(0===u&&0===d){if(!iK(o,r))return}else if(c||g)if(c&&!g){if(!eK(r,o))return}else if(g&&!c){if(!eK(o,r))return}else{if(a===d)return;if(a>d){if(!nK(r,o))return}else if(!nK(o,r))return}else{if(0===a&&0===u){if(!rK(r,o))return}else if(0===d&&0===s&&!rK(o,r))return;if(0===a&&0===d)if(0===i[0]&&n[0]>0){if(!p)return;n[0]=0}else{if(!(0===n[0]&&i[0]>0))return;if(!l)return;i[0]=0}if(0===s&&0===u)if(0===i[1]&&n[1]>0){if(!f)return;n[1]=0}else{if(!(0===n[1]&&i[1]>0))return;if(!h)return;i[1]=0}}return{range1:i,range2:n}}class sK{dataConfig;pagination;records;tree={};colFlatKeys={};rowFlatKeys={};colKeys=[];rowKeys=[];rowKeysPath;colKeysPath;rowOrder="key_a_to_z";colOrder="key_a_to_z";sorted=!1;sortRules;filterRules;aggregationRules;derivedFieldRules;mappingRules;totals;indicatorStatistics=[];aggregators={};stringJoinChar=String.fromCharCode(0);rowsIsTotal=[];colsIsTotal=[];colGrandTotalLabel;colSubTotalLabel;rowGrandTotalLabel;rowSubTotalLabel;collectValuesBy;collectedValues={};cacheCollectedValues={};rows;columns;indicatorKeys;rowKeysPath_FULL;constructor(t,e,i,n,r,o,s,a){this.registerAggregators(),this.dataConfig=t,this.sortRules=this.dataConfig?.sortRules,this.aggregationRules=this.dataConfig?.aggregationRules,this.derivedFieldRules=this.dataConfig?.derivedFieldRules,this.mappingRules=this.dataConfig?.mappingRules,this.totals=this.dataConfig?.totals,this.rows=i,this.columns=n,this.indicatorKeys=r,this.colGrandTotalLabel=this.totals?.column?.grandTotalLabel??"总计",this.colSubTotalLabel=this.totals?.column?.subTotalLabel??"小计",this.rowGrandTotalLabel=this.totals?.row?.grandTotalLabel??"总计",this.rowSubTotalLabel=this.totals?.row?.subTotalLabel??"小计",this.collectValuesBy=this.dataConfig?.collectValuesBy,this.rowsIsTotal=new Array(this.rows.length).fill(!1),this.colsIsTotal=new Array(this.columns.length).fill(!1);for(let t=0,e=this.totals?.row?.subTotalsDimensions?.length;t<e;t++){const e=this.totals.row.subTotalsDimensions[t],i=this.rows.indexOf(e);this.rowsIsTotal[i]=!0}for(let t=0,e=this.totals?.column?.subTotalsDimensions?.length;t<e;t++){const e=this.totals.column.subTotalsDimensions[t],i=this.columns.indexOf(e);this.colsIsTotal[i]=!0}if(this.rowKeysPath=[],this.rowKeysPath_FULL=[],this.colKeysPath=[],o){this.records=o;const t="undefined"!=typeof window?window.performance.now():0;this.setRecords(),this.processCollectedValuesWithSumBy(),this.processCollectedValuesWithSortBy();const e="undefined"!=typeof window?window.performance.now():0;console.log("processRecords:",e-t);const i="undefined"!=typeof window?window.performance.now():0;this.totalStatistics();const n="undefined"!=typeof window?window.performance.now():0;console.log("totalStatistics:",n-i);const r="undefined"!=typeof window?window.performance.now():0;this.sortKeys();const l="undefined"!=typeof window?window.performance.now():0;console.log("sortKeys:",l-r);const h="undefined"!=typeof window?window.performance.now():0;this.rowKeysPath_FULL=a?this.TreeToArr2(a):this.TreeToArr(this.ArrToTree(this.rowKeys,this.rowsIsTotal,this?.totals?.row?.showGrandTotals,this.rowGrandTotalLabel,this.rowSubTotalLabel)),this.colKeysPath=s?this.TreeToArr2(s):this.TreeToArr(this.ArrToTree(this.colKeys,this.colsIsTotal,this.totals?.column?.showGrandTotals,this.colGrandTotalLabel,this.colSubTotalLabel));const c="undefined"!=typeof window?window.performance.now():0;console.log("TreeToArr:",c-h),this.dataConfig?.isPivotChart&&(this.dealWithZeroAlign(),this.cacheDeminsionCollectedValues())}this.updatePagination(e)}registerAggregator(t,e){this.aggregators[t]=e}registerAggregators(){this.registerAggregator(Yc.RECORD,UU),this.registerAggregator(Yc.SUM,KU),this.registerAggregator(Yc.COUNT,$U),this.registerAggregator(Yc.MAX,YU),this.registerAggregator(Yc.MIN,qU),this.registerAggregator(Yc.AVG,XU)}setRecords(){this.processRecords()}processCollectedValuesWithSumBy(){for(const t in this.collectedValues)if(this.collectValuesBy[t]?.sumBy)for(const e in this.collectedValues[t]){const i=Object.values(this.collectedValues[t][e]).reduce(((t,e)=>e.value()>t?e.value():t),Number.MIN_SAFE_INTEGER),n=Object.values(this.collectedValues[t][e]).reduce(((t,e)=>e.value()<t?e.value():t),Number.MAX_SAFE_INTEGER);this.collectedValues[t][e]={},this.collectedValues[t][e].max=i,this.collectedValues[t][e].min=n}}processCollectedValuesWithSortBy(){for(const t in this.collectedValues)if(this.collectValuesBy[t]?.sortBy)for(const e in this.collectedValues[t])this.collectedValues[t][e]=this.collectedValues[t][e].sort(((e,i)=>this.collectValuesBy[t]?.sortBy.indexOf(e)-this.collectValuesBy[t]?.sortBy.indexOf(i)))}processRecords(){let t=!1;if(this.dataConfig?.filterRules?.length>=1&&(t=!0),Array.isArray(this.records))for(let e=0,i=this.records.length;e<i;e++){const i=this.records[e];t&&!this.filterRecord(i)||this.processRecord(i)}else for(const e in this.records)for(let i=0,n=this.records[e].length;i<n;i++){const n=this.records[e][i];t&&!this.filterRecord(n)||this.processRecord(n,e)}this.rowFlatKeys={},this.colFlatKeys={}}filterRecord(t){let e=!0;for(let i=0;i<this.dataConfig.filterRules.length;i++){const n=this.dataConfig?.filterRules[i];if(n.filterKey){const i=t[n.filterKey];if(-1===n.filteredValues.indexOf(i)){e=!1;break}}else if(!n.filterFunc?.(t)){e=!1;break}}return e}processRecord(t,e){this.derivedFieldRules?.forEach(((e,i)=>{t[e.fieldName]=e.derivedFunc(t)}));const i=[],n=[];for(let e=0,i=this.rows.length;e<i;e++){const i=this.rows[e];n.push(t[i])}for(let e=0,n=this.columns.length;e<n;e++){const n=this.columns[e];i.push(t[n])}for(const e in this.collectValuesBy)if(t[e]){this.collectedValues[e]||(this.collectedValues[e]={});const i=this.collectValuesBy[e].by.map((e=>t[e])).join(this.stringJoinChar);if(this.collectedValues[e][i]||(this.collectValuesBy[e].sumBy?this.collectedValues[e][i]={}:this.collectValuesBy[e].range?this.collectedValues[e][i]={min:Number.MAX_SAFE_INTEGER,max:Number.MIN_SAFE_INTEGER}:this.collectedValues[e][i]=[]),this.collectValuesBy[e].sumBy){const n=this.collectValuesBy[e].sumBy.map((e=>t[e])).join(this.stringJoinChar);this.collectedValues[e][i][n]||(this.collectedValues[e][i][n]=new this.aggregators[Yc.SUM](e)),this.collectedValues[e][i][n].push(t)}else if(this.collectValuesBy[e].range){const n=this.collectedValues[e][i];n.max=Math.max(t[e],n.max),n.min=Math.min(t[e],n.min)}else{const n=this.collectedValues[e][i];-1===n.indexOf(t[e])&&n.push(t[e])}}const r=n.join(this.stringJoinChar),o=i.join(this.stringJoinChar);0!==n.length&&(this.rowFlatKeys[r]||(this.rowKeys.push(n),this.rowFlatKeys[r]=1)),0!==i.length&&(this.colFlatKeys[o]||(this.colKeys.push(i),this.colFlatKeys[o]=1)),this.tree[r]||(this.tree[r]={}),this.tree[r]?.[o]||(this.tree[r][o]=[]);for(let i=0;i<this.indicatorKeys.length;i++){const n=this.getAggregatorRule(this.indicatorKeys[i]);if(this.tree[r]?.[o]?.[i]||(this.tree[r][o][i]=new this.aggregators[n?.aggregationType??Yc.SUM](n?.field??this.indicatorKeys[i],n?.formatFun)),e)this.indicatorKeys[i]===e&&this.tree[r]?.[o]?.[i].push(t);else if(n?.field)if("string"==typeof n?.field)n?.field in t&&this.tree[r]?.[o]?.[i].push(t);else{const e=n?.field.find((e=>e in t));e&&this.tree[r]?.[o]?.[i].push(t)}else this.indicatorKeys[i]in t&&this.tree[r]?.[o]?.[i].push(t)}if(this.mappingRules)for(let e=0;e<this.indicatorKeys.length;e++){if(!this.indicatorStatistics[e]){const t=this.getAggregatorRule(this.indicatorKeys[e]);this.indicatorStatistics[e]={max:new this.aggregators[Yc.MAX](this.indicatorKeys[e]),min:new this.aggregators[Yc.MIN](this.indicatorKeys[e]),total:new this.aggregators[t?.aggregationType??Yc.SUM](t?.field??this.indicatorKeys[e],t?.formatFun)}}this.indicatorStatistics[e].max.push(this.tree[r]?.[o]?.[e].value()),this.indicatorStatistics[e].min.push(this.tree[r]?.[o]?.[e].value()),this.indicatorStatistics[e].total.push(t)}}updateSortRules(t){this.sorted=!1,this.sortRules=t,this.sortKeys(),this.rowKeysPath_FULL=this.TreeToArr(this.ArrToTree(this.rowKeys,this.rowsIsTotal,this?.totals?.row?.showGrandTotals||0===this.columns.length,this.rowGrandTotalLabel,this.rowSubTotalLabel)),this.colKeysPath=this.TreeToArr(this.ArrToTree(this.colKeys,this.colsIsTotal,this.totals?.column?.showGrandTotals||0===this.rows.length,this.colGrandTotalLabel,this.colSubTotalLabel))}updateFilterRules(t,e=!1){if(this.filterRules=t,e)this.tree={};else for(const t in this.tree)for(const e in this.tree[t])for(let i=0;i<this.tree[t][e].length;i++)this.tree[t][e][i].reset();this.collectedValues={},this.processRecords(),this.processCollectedValuesWithSumBy(),this.processCollectedValuesWithSortBy(),this.dataConfig?.isPivotChart&&this.dealWithZeroAlign()}updatePagination(t){if(this.pagination=t,bu(this.pagination?.perPageCount)&&bu(this.pagination?.currentPage)){this.pagination.perPageCount=Math.ceil(this.pagination.perPageCount/this.indicatorKeys.length)*this.indicatorKeys.length;const{perPageCount:t,currentPage:e}=this.pagination,i=Math.ceil(t*(e||0)/this.indicatorKeys.length),n=i+Math.ceil(t/this.indicatorKeys.length);this.rowKeysPath=this.rowKeysPath_FULL?.slice(i,n)}else this.rowKeysPath=this.rowKeysPath_FULL;this.pagination&&(this.pagination.totalCount=this.rowKeysPath_FULL?.length)}getAggregatorRule(t){return this.aggregationRules?.find(((e,i)=>t===e.indicatorKey))}getAggregator(t=[],e=[],i){const n=this.indicatorKeys.indexOf(i);let r,o,s;return o="string"==typeof t?t:t.join(this.stringJoinChar),s="string"==typeof e?e:e.join(this.stringJoinChar),r=this.tree[o]?.[s]?.[n],r||{className:"",push(){},value:()=>null,formatValue:()=>"",reset(){}}}sortKeys(){const t=this;if(!this.sorted){this.sorted=!0;const e=function(e,i){return t.getAggregator(e,i,"").value()};switch(this.rowOrder){case"value_a_to_z":this.rowKeys.sort((function(t,i){return JU(e(t,[]),e(i,[]))}));break;case"value_z_to_a":this.rowKeys.sort((function(t,i){return-JU(e(t,[]),e(i,[]))}));break;default:this.rowKeys.sort(this.arrSort(this.rows,!0))}switch(this.colOrder){case"value_a_to_z":this.colKeys.sort((function(t,i){return JU(e([],t),e([],i))}));break;case"value_z_to_a":this.colKeys.sort((function(t,i){return-JU(e([],t),e([],i))}));break;default:const t=this.arrSort(this.columns,!1);this.colKeys.sort(t)}}}arrSort(t,e){let i;const n=this,r=function(r){const o=[];for(let r=0,s=t.length;r<s;r++){i=t[r];let s=!1;if(n.sortRules)for(let t=0,a=n.sortRules.length;t<a;t++)n.sortRules[t].sortField===i&&(s=!0,o.push({field:i,fieldIndex:r,sortRule:n.sortRules[t],func:n.getSort(n.sortRules[t],e)}));s||o.push({field:i,fieldIndex:r,func:JU})}return o}.call(this);return function(i,o){let s,a;for(let l=0;l<r.length;l++){if(a=r[l],a.sortRule?.sortByIndicator){let r=i,l=o;a.fieldIndex<t.length-1&&(r=i.slice(0,a.fieldIndex+1),r.push(e?n.totals?.row?.subTotalLabel:n.totals?.column?.subTotalLabel),l=o.slice(0,a.fieldIndex+1),l.push(e?n.totals?.row?.subTotalLabel:n.totals?.column?.subTotalLabel)),s=a.func(r,l)}else s=a.func(i[a.fieldIndex],o[a.fieldIndex]);if(0!==s)return s*(a.sortRule?.sortType===qc.DESC?-1:1)}return 0}}getSort(t,e){const i=this;return t.sortByIndicator?(n,r)=>{const o=function(e,n){return e.length<i.rows.length&&e[e.length-1]!==i.rowSubTotalLabel&&e[e.length-1]!==i.rowGrandTotalLabel&&e.push(i.rowSubTotalLabel),n.length<i.columns.length&&n[n.length-1]!==i.colSubTotalLabel&&n[n.length-1]!==i.colGrandTotalLabel&&n.push(i.colSubTotalLabel),i.getAggregator(e,n,t.sortByIndicator).value()};return e?JU(o(n,t.query),o(r,t.query)):JU(o(t.query,n),o(t.query,r))}:t.sortBy?function(t){let e;const i={},n={};for(let r=0;r<t.length;r++)e=t[r],i[e]=r,"string"==typeof e&&(n[e.toLowerCase()]=r);return function(t,e){return null!==i[t]&&void 0!==i[t]&&null!==i[e]&&void 0!==i[e]?i[t]-i[e]:null!==i[t]&&void 0!==i[t]?-1:null!==i[e]&&void 0!==i[e]?1:null!==n[t]&&void 0!==i[t]&&null!==n[e]&&void 0!==i[e]?n[t]-n[e]:null===n[t]||void 0===i[t]||null===n[e]||void 0===i[e]?0:null!==n[t]&&void 0!==i[t]?-1:null!==n[e]&&void 0!==i[e]?1:JU(t,e)}}(t.sortBy):t.sortType?ZU:t.sortFunc?t.sortFunc:JU}totalStatistics(){const t=this;if(t?.totals?.column?.showSubTotals&&t?.totals?.column?.subTotalsDimensions?.length>=1||t?.totals?.row?.showSubTotals&&t?.totals?.row?.subTotalsDimensions?.length>=1||t?.totals?.column?.showGrandTotals||t?.totals?.row?.showGrandTotals){const e=[],i=(e,i)=>{const n=i.split(this.stringJoinChar);for(let r=0,o=t.totals?.column?.subTotalsDimensions?.length;r<o;r++){const o=t.totals.column.subTotalsDimensions[r],s=t.columns.indexOf(o);if(s>=0){const r=n.slice(0,s+1);r.push(t.totals?.column?.subTotalLabel??"小计");const o=r.join(this.stringJoinChar);this.tree[e][o]||(this.tree[e][o]=[]);for(let n=0;n<this.indicatorKeys.length;n++){if(!this.tree[e][o][n]){const t=this.getAggregatorRule(this.indicatorKeys[n]);this.tree[e][o][n]=new this.aggregators[t?.aggregationType??Yc.SUM](t?.field??this.indicatorKeys[n],t?.formatFun)}this.tree[e][o][n].push(t.tree[e]?.[i]?.[n])}}}if(t.totals?.column?.showGrandTotals||0===this.rows.length){const n=t.colGrandTotalLabel;this.tree[e][n]||(this.tree[e][n]=[]);for(let r=0;r<this.indicatorKeys.length;r++){if(!this.tree[e][n][r]){const t=this.getAggregatorRule(this.indicatorKeys[r]);this.tree[e][n][r]=new this.aggregators[t?.aggregationType??Yc.SUM](t?.field??this.indicatorKeys[r],t?.formatFun)}this.tree[e][n][r].push(t.tree[e]?.[i]?.[r])}}};Object.keys(t.tree).forEach((n=>{const r=n.split(this.stringJoinChar);Object.keys(t.tree[n]).forEach((o=>{for(let i=0,s=t.totals?.row?.subTotalsDimensions?.length;i<s;i++){const s=t.totals.row.subTotalsDimensions[i],a=t.rows.indexOf(s);if(a>=0){const i=r.slice(0,a+1);i.push(t.totals?.row?.subTotalLabel??"小计");const s=i.join(this.stringJoinChar);if(this.tree[s]||(this.tree[s]={},e.push(s)),!this.tree[s][o]){this.tree[s][o]=[];for(let e=0;e<this.indicatorKeys.length;e++){if(!this.tree[s][o][e]){const t=this.getAggregatorRule(this.indicatorKeys[e]);this.tree[s][o][e]=new this.aggregators[t?.aggregationType??Yc.SUM](t?.field??this.indicatorKeys[e],t?.formatFun)}this.tree[s][o][e].push(t.tree[n]?.[o]?.[e])}}}}if(t.totals?.row?.showGrandTotals||0===this.columns.length){const i=t.rowGrandTotalLabel;this.tree[i]||(this.tree[i]={},e.push(i)),this.tree[i][o]||(this.tree[i][o]=[]);for(let e=0;e<this.indicatorKeys.length;e++){if(!this.tree[i][o][e]){const t=this.getAggregatorRule(this.indicatorKeys[e]);this.tree[i][o][e]=new this.aggregators[t?.aggregationType??Yc.SUM](t?.field??this.indicatorKeys[e],t?.formatFun)}this.tree[i][o][e].push(t.tree[n]?.[o]?.[e])}}i(n,o)}))})),e.forEach((e=>{Object.keys(t.tree[e]).forEach((t=>{i(e,t)}))}))}}ArrToTree(t,e,i,n,r){const o=[],s=this.stringJoinChar,a=new Map;if(t.forEach((t=>function(t){const i=[];let n;t.forEach(((l,h)=>{i.push(l);const c=i.join(s);let u=a.get(c);if(!u){if(u={id:c,children:[]},e[h]){let e=u.children;for(let i=h;i<t.length-1;i++){const t={id:`${c}${s}${r}`,children:[]};e.push(t),e=t.children}}a.set(c,u),n?e[h-1]?n.children.splice(n.children.length-1,0,u):n.children.push(u):o.push(u)}n=u}))}(t))),i){const t={id:n,children:[]};let i=t.children;for(let t=1;t<e.length;t++){const t={id:n,children:[]};i.push(t),i=t.children}o.push(t)}return o}TreeToArr(t){const e=[];function i(t,n){n.push(t.id),t.children.length>0?t.children?.forEach((t=>i(t,[...n]))):e.push(n)}return t.forEach((t=>i(t,[]))),e}TreeToArr2(t){const e=[];function i(t,n){n.push(n.length>0?[n[n.length-1],t.value].join(String.fromCharCode(0)):t.value),t.children?.length>0&&!t.children[0].indicatorKey?t.children?.forEach((t=>i(t,[...n]))):e.push(n)}return t.forEach((t=>i(t,[]))),e}dealWithZeroAlign(){const t=[];for(let e=0;e<this.aggregationRules.length;e++){const i=this.aggregationRules[e];qu(i.field)&&2===i.field.length&&t.push(i.field)}t.forEach((t=>{const e=t[0],i=t[1],n=this.collectedValues[e],r=this.collectedValues[i];this.collectedValues[e+"_align"]={},this.collectedValues[i+"_align"]={};const o=n||r;for(const t in o){const o=n?.[t]??{min:0,max:1},s=r?.[t]??{min:0,max:1},a=oK(o,s);if(a){const{range1:n,range2:r}=a;this.collectedValues[e+"_align"][t]={min:n[0],max:n[1]},this.collectedValues[i+"_align"][t]={min:r[0],max:r[1]}}else this.collectedValues[e+"_align"][t]={min:o.min,max:o.max},this.collectedValues[i+"_align"][t]={min:s.min,max:s.max}}}))}cacheDeminsionCollectedValues(){for(const t in this.collectValuesBy)"xField"!==this.collectValuesBy[t].type&&"yField"!==this.collectValuesBy[t].type||(this.dataConfig.dimensionSortArray?this.cacheCollectedValues[t]=aK(this.collectedValues[t],this.dataConfig.dimensionSortArray):this.cacheCollectedValues[t]=this.collectedValues[t])}}function aK(t,e){return t.sort(((t,i)=>{const n=e.indexOf(t),r=e.indexOf(i);return n<r?-1:n>r?1:0}))}class lK{type;id;x=0;y=0;width=0;height=0;marginLeft;marginRight;marginTop;marginBottom;layoutWidth;layoutHeight;dx=0;dy=0;background;constructor(t){this.id=t.id,this.marginLeft=t.marginLeft??0,this.marginRight=t.marginRight??0,this.marginTop=t.marginTop??0,this.marginBottom=t.marginBottom??0,this.background=t.background||void 0}getSize(t){this.initLayoutSize()}initLayoutSize(){this.layoutWidth=this.width+this.marginLeft+this.marginRight,this.layoutHeight=this.height+this.marginTop+this.marginBottom,this.background&&(this.layoutWidth+=2*(this.background.expandX||0),this.layoutHeight+=2*(this.background.expandY||0)),this.dx=this.marginLeft,this.dy=this.marginTop}}const hK={row:{x:"x",y:"y",width:"width",height:"height",layoutWidth:"layoutWidth",layoutHeight:"layoutHeight",widthLimit:"widthLimit",heightLimit:"heightLimit",parentX:"parentX",parentY:"parentY",dx:"dx",dy:"dy"},column:{x:"y",y:"x",width:"height",height:"width",layoutWidth:"layoutHeight",layoutHeight:"layoutWidth",widthLimit:"heightLimit",heightLimit:"widthLimit",parentX:"parentY",parentY:"parentX",dx:"dy",dy:"dx"}};class cK{width=0;height=0;y=0;x=0;children=[];addAble=!0;widthLimit=0;heightLimit=0;direction;directionKey;offsetX=0;justifyContent;alignItems;constructor(t,e,i,n){this.direction=e,this.directionKey=hK[this.direction],this.justifyContent=i,this.alignItems=n,this[this.directionKey.widthLimit]=t}add(t){t[this.directionKey.x]=this[this.directionKey.width],this[this.directionKey.width]+=t[this.directionKey.layoutWidth],this.children.push(t),this.updateHeight(t)}canAdd(t){return!(this[this.directionKey.width]+t[this.directionKey.layoutWidth]>this[this.directionKey.widthLimit])}updateHeight(t){t[this.directionKey.layoutHeight]>this[this.directionKey.height]&&(this[this.directionKey.height]=t[this.directionKey.layoutHeight])}lineFinish(){this.updateXAlign()}updateXAlign(){const t=this[this.directionKey.widthLimit]-this[this.directionKey.width];"center"===this.justifyContent?this.offsetX=t/2:"start"===this.justifyContent?this.offsetX=0:this.offsetX=t}getOffsetY(t){switch(this.alignItems){case"start":default:return 0;case"center":return(this[this.directionKey.height]-t[this.directionKey.layoutHeight])/2;case"end":return this[this.directionKey.height]-t[this.directionKey.layoutHeight]}}getContentSize(){const t={width:0,height:0};for(let e=0;e<this.children.length;e++){const i=this.children[e];let n;n="container"===i.type?i.getContentSize():{width:i.layoutWidth,height:i.layoutHeight},t[this.directionKey.height]<n[this.directionKey.height]&&(t[this.directionKey.height]=n[this.directionKey.height]),t[this.directionKey.width]+=n[this.directionKey.width]}return t}getElements(t={parentX:0,parentY:0},e=!1,i=!1){const n=[];for(let r=0;r<this.children.length;r++){const o=this.children[r];if("container"===o.type||"group-element"===o.type){const r=o.getElements({[this.directionKey.parentX]:this.offsetX+this[this.directionKey.x]+t.parentX,[this.directionKey.parentY]:this.getOffsetY(o)+this[this.directionKey.y]+t.parentY},e,i);n.push(...r)}else{if("icon"===o.type&&("mouseenter_cell"===o.cache?.visibleTime&&!e||"click_cell"===o.cache?.visibleTime&&!i))continue;o[this.directionKey.x]+=this.offsetX+this[this.directionKey.x]+t.parentX,o[this.directionKey.y]+=this.getOffsetY(o)+this[this.directionKey.y]+t.parentY,n.push(o)}}return n}}class uK extends lK{type="rect";lineWidth;cornerRadius;radius;fill;stroke;constructor(t){super(t),this.width=t.width,this.height=t.height,this.lineWidth=t.lineWidth||0,this.cornerRadius=t.cornerRadius||0,this.radius=this.cornerRadius,this.fill=t.fill||"#777",this.stroke=t.stroke||void 0,this.initLayoutSize()}}var dK=Object.freeze({__proto__:null,Circle:class extends lK{type="circle";radius;radian;lineWidth;fill;stroke;constructor(t){super(t),this.radius=t.radius,this.radian=t.radian,this.lineWidth=t.lineWidth,this.fill=t.fill,this.stroke=t.stroke,this.width=2*this.radius,this.height=2*this.radius,this.initLayoutSize(),this.dx+=this.radius,this.dy+=this.radius}},Container:class extends lK{type="container";_widthObj;_heightObj;needCalcSize=!1;direction;justifyContent;alignItems;alignContent;lines=[];currentLine;currentLineY=0;table;directionKey;showBounds;offsetY=0;isRoot;constructor(t){super(t),this.direction=t.direction||"row",this.justifyContent=t.justifyContent||"start",this.alignItems=t.alignItems||"start",this.alignContent=t.alignContent||"start",lu(t.width)?this.width=t.width:(this._widthObj=t.width,this.needCalcSize=!0),lu(t.height)?this.height=t.height:(this._heightObj=t.height,this.needCalcSize=!0),this.directionKey=hK[this.direction],this.showBounds=t.showBounds||!1,this.initLayoutSize()}add(t){if(this.needCalcSize)throw new Error("Need to specify a parent element before adding a child element when use percent size!");"container"===t.type&&t.calcSize(this.width,this.height),this.currentLine&&this.currentLine.canAdd(t)?this.currentLine.add(t):(this.currentLine&&(this.currentLine.addAble=!1,this.currentLineY+=this.currentLine[this.directionKey.height],this.currentLine.lineFinish()),this.currentLine=new cK(this[this.directionKey.width],this.direction,this.justifyContent,this.alignItems),this.currentLine[this.directionKey.y]=this.currentLineY,this.currentLine.add(t),this.lines.push(this.currentLine))}updateYAlign(){const t=this[this.directionKey.height]-this.currentLineY;"center"===this.alignContent?this.offsetY=t/2:"start"===this.alignContent?this.offsetY=0:this.offsetY=t}getSize(){const t={width:0,height:0};this.currentLine&&this.currentLine.addAble?t[this.directionKey.height]=this.currentLineY+this.currentLine[this.directionKey.height]:t[this.directionKey.height]=this.currentLineY;for(let e=0;e<this.lines.length;e++){const i=this.lines[e];t[this.directionKey.width]<i[this.directionKey.width]&&(t[this.directionKey.width]=i[this.directionKey.width])}return t}getContentSize(){const t={width:0,height:0},e={width:!0,height:!0};this.isRoot||this._heightObj||(e.height=!1,t.height=this.height),this.isRoot||this._widthObj||(e.width=!1,t.width=this.width);for(let i=0;i<this.lines.length;i++){const n=this.lines[i].getContentSize();e[this.directionKey.width]&&t[this.directionKey.width]<n[this.directionKey.width]&&(t[this.directionKey.width]=n[this.directionKey.width]),e[this.directionKey.height]&&(t[this.directionKey.height]+=n[this.directionKey.height])}return t}calcSize(t,e){this._heightObj&&(this.height=e*this._heightObj.percent/100+this._heightObj.delta,this.needCalcSize=!1,this.initLayoutSize()),this._widthObj&&(this.width=t*this._widthObj.percent/100+this._widthObj.delta,this.needCalcSize=!1,this.initLayoutSize())}getElements(t={parentX:0,parentY:0},e=!1,i=!1){this.currentLine&&this.currentLine.addAble&&(this.currentLine.addAble=!1,this.currentLineY+=this.currentLine[this.directionKey.height],this.currentLine.lineFinish()),this.updateYAlign();const n=[];if(this.background&&this.background.fill){const e=new uK({width:this.width,height:this.height,stroke:this.background.stroke??!1,fill:this.background.fill,cornerRadius:this.background.cornerRadius??0,lineWidth:this.background.lineWidth??1});e.x+=this.x+t.parentX,e.y+=this.y+t.parentY,n.push(e)}if(this.showBounds){const e=new uK({width:this.width,height:this.height,cornerRadius:0,stroke:"red",fill:"rgba(255, 0, 0, 0.2)",lineWidth:4});e.x+=this.x+t.parentX,e.y+=this.y+t.parentY,n.push(e)}for(let r=0;r<this.lines.length;r++){const o=this.lines[r];o[this.directionKey.y]+=this.offsetY;const s=o.getElements({[this.directionKey.parentX]:this.x+t.parentX,[this.directionKey.parentY]:this.y+t.parentY},e,i);n.push(...s)}return n}},GroupElement:class extends lK{type="group-element";direction;alignItems;width=0;height=0;children=[];directionKey;constructor(t){super(t),this.direction=t.direction||"row",this.alignItems=t.alignItems||"start",this.directionKey=hK[this.direction]}add(t){t.x=this.width,this.width+=t.layoutWidth,this.children.push(t),this.updateHeight(t),this.initLayoutSize()}updateHeight(t){t.layoutHeight>this.height&&(this.height=t.layoutHeight)}getOffsetY(t){switch(this.alignItems){case"start":default:return 0;case"center":return(this[this.directionKey.height]-t[this.directionKey.layoutHeight])/2;case"end":return this[this.directionKey.height]-t[this.directionKey.layoutHeight]}}getElements(t={parentX:0,parentY:0},e=!1,i=!1){const n=[];for(let r=0;r<this.children.length;r++){const o=this.children[r];"icon"===o.type&&("mouseenter_cell"===o.cache?.visibleTime&&!e||"click_cell"===o.cache?.visibleTime&&!i)||(o[this.directionKey.x]+=this[this.directionKey.dx]+this[this.directionKey.x]+t.parentX,o[this.directionKey.y]+=this.getOffsetY(o)+this[this.directionKey.dy]+this[this.directionKey.y]+t.parentY,n.push(o))}return n}},Icon:class extends lK{type="icon";svg;iconName;cursor;cache;constructor(t){if(super(t),this.iconName=t.iconName,au(this.iconName)){const t=yj()[this.iconName];t&&(this.cache=t,this.width=t.width,this.height=t.height,this.svg=t.svg,this.cursor=t.cursor)}this.width=t.width??this.width,this.height=t.height??this.height,this.svg=t.svg??this.svg,this.initLayoutSize()}},Image:class extends lK{type="image";src;cursor;cache;shape;constructor(t){super(t),this.width=t.width??this.width,this.height=t.height??this.height,this.src=t.src??this.src,this.shape=t.shape??this.shape,this.initLayoutSize()}},Rect:uK,Sector:class extends lK{type="arc";radius;startDegree=0;endDegree=360;clockWise=!0;lineWidth;fill;stroke;constructor(t){super(t),this.radius=t.radius,this.startDegree=t.startDegree,this.endDegree=t.endDegree,this.clockWise=t.clockWise,this.lineWidth=t.lineWidth,this.fill=t.fill,this.stroke=t.stroke,this.width=2*this.radius,this.height=2*this.radius,this.initLayoutSize(),this.dx+=this.radius,this.dy+=this.radius}},Text:class extends lK{type="text";text;fill;color;stroke;lineWidth;fontSize;fontFamily;fontWeight;fontVariant;fontStyle;ellipsis;maxLineWidth;textAlign;textBaseline;lineHeight;underline;lineThrough;heightLimit;lineClamp;constructor(t){super(t),this.text=t.text,this.fontSize=t.fontSize||12,this.fontFamily=t.fontFamily||"sans-serif",this.fill=t.color||t.fill||"black",this.textBaseline=t.textBaseline||"top",this.textAlign=t.textAlign||"left",t.stroke&&(this.stroke=t.stroke),t.lineWidth&&(this.lineWidth=t.lineWidth),t.fontWeight&&(this.fontWeight=t.fontWeight),t.fontVariant&&(this.fontVariant=t.fontVariant),t.fontStyle&&(this.fontStyle=t.fontStyle),t.ellipsis&&(this.ellipsis=t.ellipsis),t.maxLineWidth&&(this.maxLineWidth=t.maxLineWidth),t.lineHeight&&(this.lineHeight=t.lineHeight),t.underline&&(this.underline=t.underline),t.lineThrough&&(this.lineThrough=t.lineThrough),t.heightLimit&&(this.heightLimit=t.heightLimit),t.lineClamp&&(this.lineClamp=t.lineClamp)}getSize(t){const{width:e,height:i}=t.measureText(this.text,{fontSize:this.fontSize,fontWeight:this.fontWeight,fontFamily:this.fontFamily});this.width=e,this.height=i,this.initLayoutSize(),this.background&&(this.dx+=this.background.expandX||0,this.dy+=this.background.expandY||0)}},percentCalc:function(t,e=0){return{percent:t,delta:e}}});t.CustomLayout=dK,t.DataStatistics=EU,t.ListTable=class extends AU{showHeader=!0;constructor(t,e){t instanceof HTMLElement||(e=t,t=t.container?t.container:null),super(t,e);const i=this.internalProps;this.pagination=e.pagination,i.sortState=e.sortState,i.columns=e.columns?du(e.columns):e.header?du(e.header):[],this.showHeader=e.showHeader??!0,this.transpose=e.transpose??!1,this.refreshHeader(),e.dataSource?uj(this,e.dataSource):e.records?this.setRecords(e.records,i.sortState):this.setRecords([])}isListTable(){return!0}isPivotTable(){return!1}isPivotChart(){return!1}get sortState(){return this.internalProps.sortState}get columns(){return this.internalProps.columns}set columns(t){this.internalProps.columns=t,this.options.columns=t}updateColumns(t){this.internalProps.columns=t,this.options.columns=t,this.refreshHeader(),this.scenegraph.clearCells(),this.headerStyleCache=new Map,this.bodyStyleCache=new Map,this.scenegraph.createSceneGraph(),this.render()}get header(){return this.internalProps.columns}set header(t){this.internalProps.columns=t,this.options.header=t,this.refreshHeader(),setTimeout((()=>{this.render()}),0)}get transpose(){return this.internalProps.transpose??!1}set transpose(t){this.internalProps.transpose!==t&&(this.internalProps.transpose=t,this.options.transpose=t,this.internalProps.layoutMap&&(this.internalProps.layoutMap.transpose=t,this.refreshRowColCount(),this._resetFrozenColCount(),this.render()))}getCellValue(t,e){const i=this;if(i.internalProps.layoutMap.isHeader(t,e)){const{title:n}=i.internalProps.layoutMap.getHeader(t,e);return"function"==typeof n?n():n}const{field:n,fieldFormat:r}=i.internalProps.layoutMap.getBody(t,e);return i.getFieldData(r||n,t,e)}getCellOriginValue(t,e){const i=this;if(i.internalProps.layoutMap.isHeader(t,e)){const{title:n}=i.internalProps.layoutMap.getHeader(t,e);return"function"==typeof n?n():n}const{field:n}=i.internalProps.layoutMap.getBody(t,e);return i.getFieldData(n,t,e)}getRecordIndexByRow(t,e){const{layoutMap:i}=this.internalProps;return i.getRecordIndexByRow(t,e)}getCellOriginRecord(t,e){const i=this,n=i.getRecordIndexByRow(t,e);if(n>-1)return i.dataSource.get(n)}_canResizeColumn(t,e){const i=super._canResizeColumn(t,e);if(i&&!this.transpose){const e=this.internalProps.layoutMap.getBody(t,this.columnHeaderLevelCount);if(e?.disableColumnResize)return!1}return i}updateOption(t,e=!1){const i=this.internalProps;return super.updateOption(t),this.pagination=t.pagination,this.showHeader=t.showHeader??!0,i.columns=t.columns?du(t.columns):t.header?du(t.header):[],this.transpose=t.transpose??!1,this.refreshHeader(),i.releaseList&&(i.releaseList.forEach((t=>t?.release?.())),i.releaseList=null),t.dataSource?uj(this,t.dataSource):t.records?this.setRecords(t.records,t.sortState):(this._resetFrozenColCount(),this.scenegraph.createSceneGraph(),this.render()),new Promise((t=>{setTimeout(t,0)}))}updatePagination(t){this.pagination&&("number"==typeof t.currentPage&&t.currentPage>=0&&(this.pagination.currentPage=t.currentPage),t.perPageCount&&(this.pagination.perPageCount=t.perPageCount||this.pagination.perPageCount),this.scenegraph.clearCells(),this.dataSource.updatePagination(this.pagination),this.refreshRowColCount(),this.scenegraph.createSceneGraph(),this.render())}refreshHeader(){const t=this,e=t.internalProps,i=t.transpose,n=t.showHeader;e.headerEvents&&e.headerEvents.forEach((e=>t.off(e)));const r=e.layoutMap=new OU(this,e.columns??[],n,t.options.hierarchyIndent);if(r.transpose=i,!i)for(let e=0;e<r.columnWidths.length;e++){const{width:i,minWidth:n,maxWidth:o}=r.columnWidths?.[e]??{};i&&("string"==typeof i&&"auto"!==i||"number"==typeof i&&i>0)&&t.setColWidth(e,i),n&&("number"==typeof n&&n>0||"string"==typeof n)&&t.setMinColWidth(e,n),o&&("number"==typeof o&&o>0||"string"==typeof o)&&t.setMaxColWidth(e,o)}this.refreshRowColCount()}refreshRowColCount(){const t=this,{layoutMap:e}=t.internalProps;e&&(e.recordsCount=t.internalProps.dataSource?.length??0,t.transpose?(t.rowCount=e.rowCount??0,t.colCount=(t.internalProps.dataSource?.length??0)*e.bodyRowCount+e.headerLevelCount,t.frozenRowCount=0,t.frozenColCount=e.headerLevelCount,t.rightFrozenColCount=this.options.rightFrozenColCount??0):(t.colCount=e.colCount??0,t.rowCount=(t.internalProps.dataSource?.length??0)*e.bodyRowCount+e.headerLevelCount,t.frozenColCount=t.options.frozenColCount??0,t.frozenRowCount=e.headerLevelCount,t.bottomFrozenRowCount=this.options.bottomFrozenRowCount??0,t.rightFrozenColCount=this.options.rightFrozenColCount??0))}getFieldData(t,e,i){if(null===t)return null;const n=this;if(n.internalProps.layoutMap.isHeader(e,i))return null;const r=n.getRecordIndexByRow(e,i);return n.internalProps.dataSource.getField(r,t)}moveHeaderPosition(t,e){const i=this.internalProps.layoutMap.moveHeaderPosition(t,e);if(i){if("column"===i.moveType){if(this.colWidthsMap.adjustOrder(i.sourceIndex,i.targetIndex,i.moveSize),!this.transpose){this.colWidthsLimit={};for(let t=0;t<this.internalProps.layoutMap.columnWidths.length;t++){const{minWidth:e,maxWidth:i}=this.internalProps.layoutMap.columnWidths?.[t]??{};e&&("number"==typeof e&&e>0||"string"==typeof e)&&this.setMinColWidth(t,e),i&&("number"==typeof i&&i>0||"string"==typeof i)&&this.setMaxColWidth(t,i)}}const t=Math.min(i.sourceIndex,i.targetIndex),e=Math.max(i.sourceIndex,i.targetIndex);for(let i=t;i<=e;i++)this._clearColRangeWidthsMap(i)}else{const t=Math.min(i.sourceIndex,i.targetIndex),e=Math.max(i.sourceIndex,i.targetIndex);for(let i=t;i<=e;i++)this._clearRowRangeHeightsMap(i)}return!0}return!1}getCellAddress(t,e){let i;for(let e=0;e<this.internalProps.records.length;e++){const n=this.internalProps.records[e];if("function"==typeof t)t(n)&&(i=e);else{let r=!0;for(const e in t)if(n[e]!==t[e]){r=!1;break}r&&(i=e)}if(bu(i))break}const n=this.getCellRangeByField(e,i);if(n)return{row:n.start.row,col:n.start.col}}getCellRangeByField(t,e){const{layoutMap:i}=this.internalProps,n=i.columnObjects.find((e=>e.field===t));if(n){const t=i.getBodyLayoutRangeById(n.id);let r;return bu(e)&&(r=i.getRecordStartRowByRecordIndex(e)),this.transpose?{start:{row:t.start.row,col:bu(r)?r+t.start.col:void 0},end:{row:t.end.row,col:bu(r)?r+t.end.col:void 0}}:{start:{col:t.start.col,row:bu(r)?r+t.start.row:void 0},end:{col:t.end.col,row:bu(r)?r+t.end.row:void 0}}}return null}getHierarchyState(t,e){if(!this.getBodyColumnDefine(t,e).tree)return Xc.none;const i=this.getRecordIndexByRow(t,e);return this.dataSource.getHierarchyState(i)}toggleHierarchyState(t,e){const i=this.getHierarchyState(t,e);i===Xc.expand?this.fireListeners(sf.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:Xc.collapse}):i===Xc.collapse&&this.fireListeners(sf.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:Xc.expand,originData:this.getCellOriginRecord(t,e)});const n=this.getRecordIndexByRow(t,e),r=this.dataSource.toggleHierarchyState(n),o=this.internalProps.layoutMap.toggleHierarchyState(r);this.refreshRowColCount(),this.clearCellStyleCache(),this.scenegraph.updateHierarchyIcon(t,e),this.scenegraph.updateRow(o.removeCellPositions,o.addCellPositions)}hasHierarchyTreeHeader(){return(this.options.columns??this.options.header)?.some(((t,e)=>t.tree))}getMenuInfo(t,e,i){return{field:this.getHeaderField(t,e),value:this.getCellValue(t,e),cellLocation:this.getCellLocation(t,e)}}_getSortFuncFromHeaderOption(t,e,i){if(t||(t=this.internalProps.columns),e&&t&&t.length>0)for(let n=0;n<t.length;n++){const r=t[n];if((i&&i===r.fieldKey||!i&&r.field===e)&&r.sort&&"function"==typeof r.sort)return r.sort;if(r.columns){const t=this._getSortFuncFromHeaderOption(r.columns,e,i);if(t)return t}}}updateSortState(t,e=!0){if(t)this.internalProps.sortState=t;else if(this.internalProps.sortState)if(Array.isArray(this.internalProps.sortState))for(let t=0;t<this.internalProps.sortState.length;t++){this.internalProps.sortState[t].order="normal"}else this.internalProps.sortState.order="normal";let i,n,r;if(Array.isArray(this.internalProps.sortState)?({order:i,field:n,fieldKey:r}=this.internalProps.sortState?.[0]):({order:i,field:n,fieldKey:r}=this.internalProps.sortState),n&&e){const t=this._getSortFuncFromHeaderOption(this.internalProps.columns,n,r);let e;e=r?this.internalProps.layoutMap.headerObjects.find((t=>t&&t.fieldKey===r)):this.internalProps.layoutMap.headerObjects.find((t=>t&&t.field===n)),e?.define?.sort&&(this.dataSource.sort(e.field,i,t),this.scenegraph.sortCell())}this.stateManeger.updateSortState(t)}},t.PivotChart=class extends AU{pivotSortState;dataset;_selectedDataItemsInChart=[];_selectedDimensionInChart=[];_chartEventMap={};_axes;constructor(t,e){t instanceof HTMLElement||(e=t,t=t.container?t.container:null),super(t,e),e.layout&&Object.assign(e,e.layout),this.setCustomStateNameToSpec(),this.internalProps.columnResizeType=e.columnResizeType??"column",this.internalProps.dataConfig={isPivotChart:!0},this._axes=qu(e.axes)?e.axes:[];const i=e.rows?.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[])??[],n=e.columns?.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[])??[],r=e.indicators?.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.indicatorKey),t)),[])??[];this.internalProps.dataConfig.collectValuesBy=this._generateCollectValuesConfig(n,i),this.internalProps.dataConfig.aggregationRules=this._generateAggregationRules(),this.internalProps.dataConfig.dimensionSortArray=this._getDimensionSortArray(),this.dataset=new sK(this.internalProps.dataConfig,null,i,n,r,e.records,e.columnTree,e.rowTree),this.refreshHeader(),e.dataSource?uj(this,e.dataSource):e.records?this.setRecords(e.records,this.internalProps.sortState):this.setRecords([])}static get EVENT_TYPE(){return tV}get pivotChartAxes(){return this._axes}isListTable(){return!1}isPivotTable(){return!0}isPivotChart(){return!0}_canResizeColumn(t,e){const i=super._canResizeColumn(t,e);if(i&&!this.internalProps.layoutMap.indicatorsAsCol){const e=this.internalProps.layoutMap.getBody(t,this.columnHeaderLevelCount);if(e?.disableColumnResize)return!1}return i}updateOption(t,e=!1){const i=this.internalProps;if(super.updateOption(t),this.setCustomStateNameToSpec(),i.columnResizeType=t.columnResizeType??"column",i.dataConfig={},this._axes=qu(t.axes)?t.axes:[],t.rows||t.columns){const e=t.rows.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[]),i=t.columns.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[]),n=t.indicators?.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.indicatorKey),t)),[]);this.internalProps.dataConfig.collectValuesBy=this._generateCollectValuesConfig(i,e),this.internalProps.dataConfig.aggregationRules=this._generateAggregationRules(),this.dataset=new sK(this.internalProps.dataConfig,null,e,i,n,t.records??this.internalProps.records,t.columnTree,t.rowTree)}return this.refreshHeader(),i.releaseList&&(i.releaseList.forEach((t=>t?.release?.())),i.releaseList=null),t.dataSource?uj(this,t.dataSource):t.records?this.setRecords(t.records,void 0):(this._resetFrozenColCount(),this.scenegraph.createSceneGraph(),this.render()),new Promise((t=>{setTimeout(t,0)}))}updatePagination(){}refreshHeader(){const t=this.internalProps;t.headerEvents&&t.headerEvents.forEach((t=>this.off(t))),t.layoutMap=new NU(this,this.dataset);for(let e=0;e<t.layoutMap.columnWidths.length;e++){const{width:i,minWidth:n,maxWidth:r}=t.layoutMap.columnWidths?.[e]??{};i&&("string"==typeof i&&"auto"!==i||"number"==typeof i&&i>0)&&this.setColWidth(e,i),n&&("number"==typeof n&&n>0||"string"==typeof n)&&this.setMinColWidth(e,n),r&&("number"==typeof r&&r>0||"string"==typeof r)&&this.setMaxColWidth(e,r)}this.refreshRowColCount()}refreshRowColCount(){const t=this,{layoutMap:e}=t.internalProps;e&&(t.colCount=e.colCount??0,t.rowCount=e.rowCount??0,t.frozenColCount=e.rowHeaderLevelCount,t.frozenRowCount=e.headerLevelCount,t.bottomFrozenRowCount=e?.bottomFrozenRowCount??0,t.rightFrozenColCount=e?.rightFrozenColCount??0)}_getSortFuncFromHeaderOption(t,e,i){}syncHierarchyState(t,e){t.value===e.value&&t.dimensionKey===e.dimensionKey&&(e.hierarchyState=e.hierarchyState??(e?.children?t.hierarchyState:void 0),e?.children?.forEach(((e,i)=>{t?.children?.[i]&&e&&this.syncHierarchyState(t.children[i],e)})))}getRecordIndexByRow(t){const{layoutMap:e}=this.internalProps;return e.getRecordIndexByRow(t)}getRecordIndexByCol(t){const{layoutMap:e}=this.internalProps;return e.getRecordIndexByCol(t)}getFieldData(t,e,i){if(null==t)return null;const n=this;if(n.internalProps.layoutMap.isHeader(e,i))return null;const r=this.getRecordIndexByRow(i),o=this.getRecordIndexByCol(e),s=n.dataSource?.getField(r,o);if("string"!=typeof t){return fW({dataValue:s,...n.internalProps.layoutMap.getCellHeaderPaths(e,i)},t,of)}return s}getCellValue(t,e){if(this.internalProps.layoutMap.isHeader(t,e)){const{title:i,fieldFormat:n}=this.internalProps.layoutMap.getHeader(t,e);return"function"==typeof n?n(i):i}if(this.dataset){const i=this.dataset.colKeysPath[this.internalProps.layoutMap.getRecordIndexByCol(t)]??[],n=this.dataset.rowKeysPath[this.internalProps.layoutMap.getRecordIndexByRow(e)]??[],r=this.dataset.getAggregator(n[n.length-1],i[i.length-1],this.internalProps.layoutMap.getIndicatorKey(t,e));return r.value?r.value():void 0}const{field:i,fieldFormat:n}=this.internalProps.layoutMap.getBody(t,e);return this.getFieldData(n||i,t,e)}getCellOriginValue(t,e){const i=this;if(i.internalProps.layoutMap.isHeader(t,e)){const{title:n}=i.internalProps.layoutMap.getHeader(t,e);return"function"==typeof n?n():n}if(this.dataset){const i=this.dataset.colKeysPath[this.internalProps.layoutMap.getRecordIndexByCol(t)]??[],n=this.dataset.rowKeysPath[this.internalProps.layoutMap.getRecordIndexByRow(e)]??[],r=this.dataset.getAggregator(n[n.length-1],i[i.length-1],this.internalProps.layoutMap.getIndicatorKey(t,e));return r.value?r.value():void 0}const{field:n}=i.internalProps.layoutMap.getBody(t,e);return i.getFieldData(n,t,e)}getCellOriginRecord(t,e){if(!this.internalProps.layoutMap.isHeader(t,e)&&this.dataset){const i=this.dataset.colKeysPath[this.internalProps.layoutMap.getRecordIndexByCol(t)]??[],n=this.dataset.rowKeysPath[this.internalProps.layoutMap.getRecordIndexByRow(e)]??[];return this.dataset.getAggregator(n[n.length-1],i[i.length-1],this.internalProps.layoutMap.getIndicatorKey(t,e)).records}}updateSortRules(t){this.internalProps.dataConfig.sortRules=t,this.dataset.updateSortRules(t),this.internalProps.layoutMap.updateDataset(this.dataset),this.render()}updatePivotSortState(t){for(let e=0;e<t.length;e++){const{dimensions:i,order:n}=t[e],r=this.internalProps.layoutMap.getPivotCellAdress(i);r&&this.pivotSortState.push({col:r.col,row:r.row,order:n})}}getPivotSortState(t,e){if(!this.pivotSortState)return;const i=this.getCellRange(t,e);for(let t=0;t<this.pivotSortState.length;t++){const{col:e,row:n,order:r}=this.pivotSortState[t];if(qp(i,e,n))return r}}moveHeaderPosition(t,e){const i=this.internalProps.layoutMap.moveHeaderPosition(t,e);if(i){if("column"===i.moveType){if(this.options.records?.[0]?.constructor===Array)for(let t=0;t<this.internalProps.records.length;t++){const e=this.internalProps.records[t].splice(i.sourceIndex-this.rowHeaderLevelCount,i.moveSize);e.unshift(i.targetIndex-this.rowHeaderLevelCount,0),Array.prototype.splice.apply(this.internalProps.records[t],e)}this.colWidthsMap.adjustOrder(i.sourceIndex,i.targetIndex,i.moveSize);for(let t=0;t<this.internalProps.layoutMap.columnWidths.length;t++){const{minWidth:e,maxWidth:i}=this.internalProps.layoutMap.columnWidths?.[t]??{};e&&("number"==typeof e&&e>0||"string"==typeof e)&&this.setMinColWidth(t,e),i&&("number"==typeof i&&i>0||"string"==typeof i)&&this.setMaxColWidth(t,i)}}else if("row"===i.moveType){if(this.options.records?.[0]?.constructor===Array){const t=this.internalProps.records.splice(i.sourceIndex-this.columnHeaderLevelCount,i.moveSize);t.unshift(i.targetIndex-this.columnHeaderLevelCount,0),Array.prototype.splice.apply(this.internalProps.records,t)}this.rowHeightsMap.adjustOrder(i.sourceIndex,i.targetIndex,i.moveSize)}return!0}return!1}toggleHierarchyState(t,e){const i=this.getHierarchyState(t,e);i===Xc.expand?this.fireListeners(tV.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:Xc.collapse}):i===Xc.collapse&&this.fireListeners(tV.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:Xc.expand,originData:this.getCellOriginRecord(t,e)});const n=this.internalProps.layoutMap.toggleHierarchyState(t,e);this.refreshRowColCount(),this.clearCellStyleCache(),this.scenegraph.updateHierarchyIcon(t,e),this.scenegraph.updateRow(n.removeCellPositions,n.addCellPositions)}getHeaderCellAddressByPath(t){return this.internalProps.layoutMap.getPivotCellAdress(t)}getCellAddressByHeaderPaths(t){return this.internalProps.layoutMap.getCellAdressByHeaderPath(t)}getHeaderPathByXY(t){let e;e=t?this.getCellAt(t.x+this.getFrozenColsWidth()+this.scrollLeft+1,t.y+this.getFrozenRowsHeight()+this.scrollTop+1):this.getCellAt(this.getFrozenColsWidth()+this.scrollLeft+1,this.getFrozenRowsHeight()+this.scrollTop+1);return this.internalProps.layoutMap.getCellHeaderPaths(e.col,e.row)}getHierarchyState(t,e){return this._getHeaderLayoutMap(t,e)?.hierarchyState}hasHierarchyTreeHeader(){return"tree"===this.internalProps.layoutMap.rowHierarchyType}getMenuInfo(t,e,i){const n=this.internalProps.layoutMap.getPivotDimensionInfo(t,e);return{dimensionKey:n[n.length-1].dimensionKey,value:this.getCellValue(t,e),cellLocation:this.getCellLocation(t,e),isPivotCorner:this.isCornerHeader(t,e)}}_generateCollectValuesConfig(t,e){const i=this.options,n={};for(let r=0,o=i.indicators?.length;r<o;r++)if("string"!=typeof i.indicators[r]&&i.indicators[r].chartSpec)if(!1===i.indicatorsAsCol){const o=i.indicators[r];if(n[o.indicatorKey]={by:e,range:!0,sumBy:!1!==o.chartSpec?.stack&&t.concat(o.chartSpec?.xField)},o.chartSpec.series)o.chartSpec.series.forEach((i=>{const r="string"==typeof i.xField?i.xField:i.xField[0];n[r]={by:t,type:"horizontal"!==i.direction?"xField":void 0,range:"horizontal"===i.direction,sortBy:"horizontal"!==i.direction?i?.data?.fields?.[r]?.domain??o.chartSpec?.data?.fields?.[r]?.domain:void 0};const s=i.yField;n[s]={by:e,range:"horizontal"!==i.direction,sumBy:!1!==i.stack&&t.concat(r),sortBy:"horizontal"===i.direction?i?.data?.fields?.[s]?.domain??o.chartSpec?.data?.fields?.[s]?.domain:void 0}}));else{const s="string"==typeof o.chartSpec.xField?o.chartSpec.xField:o.chartSpec.xField[0];n[s]={by:t,type:"horizontal"!==o.chartSpec.direction?"xField":void 0,range:"horizontal"===o.chartSpec.direction,sortBy:"horizontal"!==o.chartSpec.direction?o.chartSpec?.data?.fields?.[s]?.domain:void 0};const a=o.chartSpec.yField;n[a]={by:e,range:"horizontal"!==i.indicators[r].chartSpec.direction,sumBy:!1!==o.chartSpec.stack&&t.concat(s),sortBy:"horizontal"===o.chartSpec.direction?o.chartSpec?.data?.fields?.[a]?.domain:void 0}}}else{const o=i.indicators[r];if(n[o.indicatorKey]={by:t,range:!0,sumBy:!1!==o.chartSpec?.stack&&e.concat(o.chartSpec?.yField)},o.chartSpec.series)o.chartSpec.series.forEach((i=>{const r="string"==typeof i.yField?i.yField:i.yField[0];n[r]={by:e,type:"horizontal"===i.direction?"yField":void 0,range:"horizontal"!==i.direction,sortBy:"horizontal"===i.direction?i?.data?.fields?.[r]?.domain??o.chartSpec?.data?.fields?.[r]?.domain:void 0};const s=i.xField;n[s]={by:t,range:"horizontal"===i.direction,sumBy:!1!==i.stack&&e.concat(r),sortBy:"horizontal"!==i.direction?i?.data?.fields?.[s]?.domain??o.chartSpec?.data?.fields?.[s]?.domain:void 0}}));else{const s="string"==typeof o.chartSpec.yField?o.chartSpec.yField:o.chartSpec.yField[0];n[s]={by:e,type:"horizontal"===o.chartSpec.direction?"yField":void 0,range:"horizontal"!==o.chartSpec.direction,sortBy:"horizontal"===o.chartSpec.direction?o.chartSpec?.data?.fields?.[s]?.domain:void 0};const a=o.chartSpec.xField;n[a]={by:t,range:"horizontal"===i.indicators[r].chartSpec.direction,sumBy:!1!==o.chartSpec.stack&&e.concat(s),sortBy:"horizontal"!==o.chartSpec.direction?o.chartSpec?.data?.fields?.[a]?.domain:void 0}}}return n}_generateAggregationRules(){const t=[];return this.options.indicators?.forEach((e=>{if("string"==typeof e)t.push({indicatorKey:e,field:e,aggregationType:Yc.RECORD});else if(e.chartSpec?.series){const i=[];e.chartSpec?.series.forEach((t=>{const e=!1===this.options.indicatorsAsCol?t.yField:t.xField;-1===i.indexOf(e)&&i.push(e)})),t.push({indicatorKey:e.indicatorKey,field:i,aggregationType:Yc.RECORD})}else{const i=!1===this.options.indicatorsAsCol?e.chartSpec.yField:e.chartSpec.xField;t.push({indicatorKey:e.indicatorKey,field:i??e.indicatorKey,aggregationType:Yc.RECORD})}})),t}setCustomStateNameToSpec(){const t=t=>{t.bar?.state?.selected&&(t.bar.state.vtable_selected=t.bar.state.selected,t.bar.state.vtable_selected_reverse=t.bar.state.selected_reverse,delete t.bar.state.selected,delete t.bar.state.selected_reverse),t.point?.state?.selected&&(t.point.state.vtable_selected=t.point.state.selected,t.point.state.vtable_selected_reverse=t.point.state.selected_reverse,delete t.point.state.selected,delete t.point.state.selected_reverse),t.line?.state?.selected&&(t.line.state.vtable_selected=t.line.state.selected,t.line.state.vtable_selected_reverse=t.line.state.selected_reverse,delete t.line.state.selected,delete t.line.state.selected_reverse),t.area?.state?.selected&&(t.area.state.vtable_selected=t.area.state.selected,t.area.state.vtable_selected_reverse=t.area.state.selected_reverse,delete t.area.state.selected,delete t.area.state.selected_reverse)};this.options.indicators?.forEach((e=>{if(e.chartSpec){const i=e.chartSpec;i.series?i.series.forEach((e=>{t(e)})):t(i)}}))}onVChartEvent(t,e,i){this._chartEventMap[t]="function"==typeof e?{callback:e}:{callback:i,query:e}}offVChartEvent(t){delete this._chartEventMap[t]}_bindChartEvent(t){if(t)for(const e in this._chartEventMap)this._chartEventMap[e].query?t.on(e,this._chartEventMap[e].query,this._chartEventMap[e].callback):t.on(e,this._chartEventMap[e].callback)}updateFilterRules(t){this.internalProps.dataConfig.filterRules=t,this.dataset.updateFilterRules(t),OG(this.scenegraph),function(t){const e=t.table;for(let i=t.proxy.colStart;i<=t.proxy.colEnd;i++)t.getColGroup(i).getChildren().forEach((t=>{const i=t.col,n=t.row;t.children.forEach((t=>{if("chart"===t.type){t.updateData(e.getCellValue(i,n));const r=e.internalProps.layoutMap.getChartAxes(i,n);t.setAttribute("axes",r);const o=t.attribute.spec;o.axes=r,t.setAttribute("spec",o)}}))}));DG(t.rowHeaderGroup,t.table),DG(t.colHeaderGroup,t.table),DG(t.rightFrozenGroup,t.table),DG(t.bottomFrozenGroup,t.table)}(this.scenegraph),this.render()}setLegendSelected(t){this.internalProps.legends.legendComponent.setSelected(t)}getChartDatumPosition(t,e){const i=this.getCellAddressByHeaderPaths(e),n=this.getCellRelativeRect(i.col,i.row);console.log(n);const r=this.scenegraph.getCell(i.col,i.row);let o;const s=r?.getChildren()?.[0];if(s.attribute.chartInstance){const e=s.attribute.chartInstance,{dataId:i,data:n,axes:r}=s.attribute,a=s.getViewBox();r.forEach(((t,i)=>{if("linear"===t.type){e._chart._components[i]._domain={min:t.range?.min??0,max:t.range?.max??0}}else if("band"===t.type){const n=e._chart._components[i];n._spec.domain=t.domain.slice(0),n.updateScaleDomain()}})),e.updateViewBox({x1:a.x1-s.getRootNode().table.scrollLeft,x2:a.x2-s.getRootNode().table.scrollLeft,y1:a.y1-s.getRootNode().table.scrollTop,y2:a.y2-s.getRootNode().table.scrollTop},!1),e.updateDataSync(i,n),o=e.convertDatumToPosition(t),this.render()}return o?{x:Math.round(o.x+n.bounds.x1),y:Math.round(o.y+n.bounds.y1)}:null}_getDimensionSortArray(){if(this.options?.axes?.length){const t=this.options.indicatorsAsCol?"left":"bottom",e=this.options.axes.find((e=>e.orient===t));if(e&&qu(e.domain))return e.domain}}},t.PivotTable=class extends AU{pivotSortState;dataset;flatDataToObjects;constructor(t,e){if(t instanceof HTMLElement||(e=t,t=t.container?t.container:null),super(t,e),e.layout&&Object.assign(e,e.layout),this.pagination=e.pagination,this.internalProps.columnResizeType=e.columnResizeType??"column",this.internalProps.dataConfig=e.dataConfig,this.internalProps.enableDataAnalysis=e.enableDataAnalysis,this.internalProps.enableDataAnalysis){const t=e.rows?.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[])??[],i=e.columns?.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[])??[],n=e.indicators?.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.indicatorKey),t)),[])??[];this.dataset=new sK(this.internalProps.dataConfig,this.pagination,t,i,n,e.records)}this.refreshHeader(),this.pivotSortState=[],e.pivotSortState&&this.updatePivotSortState(e.pivotSortState),e.dataSource?uj(this,e.dataSource):e.records?this.setRecords(e.records,this.internalProps.sortState):this.setRecords([])}static get EVENT_TYPE(){return QG}isListTable(){return!1}isPivotTable(){return!0}isPivotChart(){return!1}_canResizeColumn(t,e){const i=super._canResizeColumn(t,e);if(i&&!this.internalProps.layoutMap.indicatorsAsCol){const e=this.internalProps.layoutMap.getBody(t,this.columnHeaderLevelCount);if(e?.disableColumnResize)return!1}return i}updateOption(t,e=!1){const i=this.internalProps;if(super.updateOption(t),this.pagination=t.pagination,i.columnResizeType=t.columnResizeType??"column",i.dataConfig=t.dataConfig,i.enableDataAnalysis=t.enableDataAnalysis,"tree"===t?.rowHierarchyType&&"tree"===this.internalProps.layoutMap.rowHierarchyType&&this.internalProps.layoutMap.rowExpandLevel===t?.rowExpandLevel){const t=this.internalProps.layoutMap.rowDimensionTree.tree.children;this.internalProps.layoutMap.rowTree.forEach(((e,i)=>{this.syncHierarchyState(t[i],e)}))}if(this.internalProps.enableDataAnalysis&&(t.rows||t.columns)){const e=t.rows.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[]),n=t.columns.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.dimensionKey),t)),[]),r=t.indicators?.reduce(((t,e)=>("string"==typeof e?t.push(e):t.push(e.indicatorKey),t)),[]);this.dataset=new sK(i.dataConfig,this.pagination,e,n,r,t.records)}return this.refreshHeader(),i.releaseList&&(i.releaseList.forEach((t=>t?.release?.())),i.releaseList=null),t.dataSource?uj(this,t.dataSource):t.records?this.setRecords(t.records,void 0):(this._resetFrozenColCount(),this.scenegraph.createSceneGraph(),this.render()),this.pivotSortState=[],t.pivotSortState&&this.updatePivotSortState(t.pivotSortState),new Promise((t=>{setTimeout(t,0)}))}updatePagination(t){this.pagination&&("number"==typeof t.currentPage&&t.currentPage>=0&&(this.pagination.currentPage=t.currentPage),t.perPageCount&&(this.pagination.perPageCount=t.perPageCount||this.pagination.perPageCount),this.scenegraph.clearCells(),this.dataset.updatePagination(this.pagination),this.refreshHeader(),this.scenegraph.createSceneGraph(),this.render())}refreshHeader(){const t=this.internalProps;t.headerEvents&&t.headerEvents.forEach((t=>this.off(t)));const e=this.options.records??this.internalProps.records;this.options.enableDataAnalysis?t.layoutMap=new NU(this,this.dataset):(Array.isArray(this.options.columnTree)||Array.isArray(this.options.rowTree))&&(t.layoutMap=new WU(this),e?.[0]?.constructor!==Array&&(this.flatDataToObjects=new GU({rows:t.layoutMap.rowDimensionKeys,columns:t.layoutMap.colDimensionKeys,indicators:t.layoutMap.indicatorKeys,indicatorsAsCol:t.layoutMap.indicatorsAsCol,indicatorDimensionKey:t.layoutMap.indicatorDimensionKey},e)));for(let e=0;e<t.layoutMap.columnWidths.length;e++){const{width:i,minWidth:n,maxWidth:r}=t.layoutMap.columnWidths?.[e]??{};i&&("string"==typeof i&&"auto"!==i||"number"==typeof i&&i>0)&&this.setColWidth(e,i),n&&("number"==typeof n&&n>0||"string"==typeof n)&&this.setMinColWidth(e,n),r&&("number"==typeof r&&r>0||"string"==typeof r)&&this.setMaxColWidth(e,r)}this.refreshRowColCount()}refreshRowColCount(){const t=this,{layoutMap:e}=t.internalProps;e&&(t.colCount=e.colCount??0,t.rowCount=e.rowCount??0,t.frozenColCount=e.rowHeaderLevelCount,t.frozenRowCount=e.headerLevelCount,t.bottomFrozenRowCount=this.options.bottomFrozenRowCount??0,t.rightFrozenColCount=this.options.rightFrozenColCount??0)}_getSortFuncFromHeaderOption(t,e,i){}get rowHierarchyType(){return this.internalProps.layoutMap.rowHierarchyType}syncHierarchyState(t,e){t.value===e.value&&t.dimensionKey===e.dimensionKey&&(e.hierarchyState=e.hierarchyState??(e?.children?t.hierarchyState:void 0),e?.children?.forEach(((e,i)=>{t?.children?.[i]&&e&&this.syncHierarchyState(t.children[i],e)})))}getRecordIndexByRow(t){const{layoutMap:e}=this.internalProps;return e.getRecordIndexByRow(t)}getRecordIndexByCol(t){const{layoutMap:e}=this.internalProps;return e.getRecordIndexByCol(t)}getFieldData(t,e,i){if(null==t)return null;const n=this;if(n.internalProps.layoutMap.isHeader(e,i))return null;const r=this.getRecordIndexByRow(i),o=this.getRecordIndexByCol(e),s=n.dataSource?.getField(r,o);if("string"!=typeof t){return fW({dataValue:s,...n.internalProps.layoutMap.getCellHeaderPaths(e,i)},t,of)}return s}getCellValue(t,e){if(this.internalProps.layoutMap.isHeader(t,e)){const{title:i,fieldFormat:n}=this.internalProps.layoutMap.getHeader(t,e);return"function"==typeof n?n(i):i}if(this.dataset){const i=this.dataset.colKeysPath[this.internalProps.layoutMap.getRecordIndexByCol(t)]??[],n=this.dataset.rowKeysPath[this.internalProps.layoutMap.getRecordIndexByRow(e)]??[],r=this.dataset.getAggregator(n[n.length-1],i[i.length-1],this.internalProps.layoutMap.getIndicatorKey(t,e));return r.formatValue?r.formatValue():""}if(this.flatDataToObjects){const i=this.internalProps.layoutMap.getCellHeaderPaths(t,e),n=i.colHeaderPaths.map((t=>t.indicatorKey??t.value)),r=i.rowHeaderPaths.map((t=>t.indicatorKey??t.value)),o=this.flatDataToObjects.getTreeNode(r,n,this.internalProps.layoutMap.getBody(t,e).indicatorKey),{fieldFormat:s}=this.internalProps.layoutMap.getBody(t,e);return"function"==typeof s?s(o?.record):o?.value??""}const{field:i,fieldFormat:n}=this.internalProps.layoutMap.getBody(t,e);return this.getFieldData(n||i,t,e)}getCellOriginValue(t,e){const i=this;if(i.internalProps.layoutMap.isHeader(t,e)){const{title:n}=i.internalProps.layoutMap.getHeader(t,e);return"function"==typeof n?n():n}if(this.dataset){const i=this.dataset.colKeysPath[this.internalProps.layoutMap.getRecordIndexByCol(t)]??[],n=this.dataset.rowKeysPath[this.internalProps.layoutMap.getRecordIndexByRow(e)]??[],r=this.dataset.getAggregator(n[n.length-1],i[i.length-1],this.internalProps.layoutMap.getIndicatorKey(t,e));return r.value?r.value():void 0}if(this.flatDataToObjects){const i=this.internalProps.layoutMap.getCellHeaderPaths(t,e),n=i.colHeaderPaths.map((t=>t.indicatorKey??t.value)),r=i.rowHeaderPaths.map((t=>t.indicatorKey??t.value)),o=this.flatDataToObjects.getTreeNode(r,n,this.internalProps.layoutMap.getBody(t,e).indicatorKey);return o?.value}const{field:n}=i.internalProps.layoutMap.getBody(t,e);return i.getFieldData(n,t,e)}getCellOriginRecord(t,e){if(!this.internalProps.layoutMap.isHeader(t,e)){if(this.dataset){const i=this.dataset.colKeysPath[this.internalProps.layoutMap.getRecordIndexByCol(t)]??[],n=this.dataset.rowKeysPath[this.internalProps.layoutMap.getRecordIndexByRow(e)]??[];return this.dataset.getAggregator(n[n.length-1],i[i.length-1],this.internalProps.layoutMap.getIndicatorKey(t,e)).records}if(this.flatDataToObjects){const i=this.internalProps.layoutMap.getCellHeaderPaths(t,e),n=i.colHeaderPaths.map((t=>t.indicatorKey??t.value)),r=i.rowHeaderPaths.map((t=>t.indicatorKey??t.value)),o=this.flatDataToObjects.getTreeNode(r,n,this.internalProps.layoutMap.getBody(t,e).indicatorKey);return o?.record}}}updateSortRules(t){this.internalProps.dataConfig.sortRules=t,this.dataset.updateSortRules(t),this.internalProps.layoutMap.updateDataset(this.dataset),this.render()}updatePivotSortState(t){for(let e=0;e<t.length;e++){const{dimensions:i,order:n}=t[e],r=this.internalProps.layoutMap.getPivotCellAdress(i);r&&this.pivotSortState.push({col:r.col,row:r.row,order:n})}}getPivotSortState(t,e){if(!this.pivotSortState)return;const i=this.getCellRange(t,e);for(let t=0;t<this.pivotSortState.length;t++){const{col:e,row:n,order:r}=this.pivotSortState[t];if(qp(i,e,n))return r}}moveHeaderPosition(t,e){const i=this.internalProps.layoutMap.moveHeaderPosition(t,e);if(i){if("column"===i.moveType){if(this.options.records?.[0]?.constructor===Array)for(let t=0;t<this.internalProps.records.length;t++){const e=this.internalProps.records[t].splice(i.sourceIndex-this.rowHeaderLevelCount,i.moveSize);e.unshift(i.targetIndex-this.rowHeaderLevelCount,0),Array.prototype.splice.apply(this.internalProps.records[t],e)}this.colWidthsMap.adjustOrder(i.sourceIndex,i.targetIndex,i.moveSize);for(let t=0;t<this.internalProps.layoutMap.columnWidths.length;t++){const{minWidth:e,maxWidth:i}=this.internalProps.layoutMap.columnWidths?.[t]??{};e&&("number"==typeof e&&e>0||"string"==typeof e)&&this.setMinColWidth(t,e),i&&("number"==typeof i&&i>0||"string"==typeof i)&&this.setMaxColWidth(t,i)}}else if("row"===i.moveType){if(this.options.records?.[0]?.constructor===Array){const t=this.internalProps.records.splice(i.sourceIndex-this.columnHeaderLevelCount,i.moveSize);t.unshift(i.targetIndex-this.columnHeaderLevelCount,0),Array.prototype.splice.apply(this.internalProps.records,t)}this.rowHeightsMap.adjustOrder(i.sourceIndex,i.targetIndex,i.moveSize)}return!0}return!1}toggleHierarchyState(t,e){const i=this.getHierarchyState(t,e);i===Xc.expand?this.fireListeners(QG.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:Xc.collapse}):i===Xc.collapse&&this.fireListeners(QG.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:Xc.expand,originData:this.getCellOriginRecord(t,e)});const n=this.internalProps.layoutMap.toggleHierarchyState(t,e);this.refreshRowColCount(),this.clearCellStyleCache(),this.scenegraph.updateHierarchyIcon(t,e),this.scenegraph.updateRow(n.removeCellPositions,n.addCellPositions)}getHeaderCellAddressByPath(t){return this.internalProps.layoutMap.getPivotCellAdress(t)}getCellAddressByHeaderPaths(t){return this.internalProps.layoutMap.getCellAdressByHeaderPath(t)}getHeaderPathByXY(t){let e;e=t?this.getCellAt(t.x+this.getFrozenColsWidth()+this.scrollLeft+1,t.y+this.getFrozenRowsHeight()+this.scrollTop+1):this.getCellAt(this.getFrozenColsWidth()+this.scrollLeft+1,this.getFrozenRowsHeight()+this.scrollTop+1);return this.internalProps.layoutMap.getCellHeaderPaths(e.col,e.row)}getHierarchyState(t,e){return this._getHeaderLayoutMap(t,e)?.hierarchyState}hasHierarchyTreeHeader(){return"tree"===this.internalProps.layoutMap.rowHierarchyType}getMenuInfo(t,e,i){const n=this.internalProps.layoutMap.getPivotDimensionInfo(t,e);return{dimensionKey:n[n.length-1].dimensionKey,value:this.getCellValue(t,e),cellLocation:this.getCellLocation(t,e),isPivotCorner:this.isCornerHeader(t,e)}}},t.TYPES=nu,t.clearGlobal=function(){RU()},t.core=TU,t.data=bW,t.getIcons=function(){return yj()},t.register=PU,t.themes=zf,t.version="0.10.3-alpha.0"}));
|