@visactor/vtable 0.9.3-alpha.1 → 0.9.3-alpha.2

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.
@@ -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 jW(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 NW=Fw();class GW extends rC{type="chart";chartInstance;activeChartInstance;active;cacheCanvas;constructor(t){super(t),this.numberType=NW,t.chartInstance?this.chartInstance=t.chartInstance:(t.chartInstance=this.chartInstance=new t.ClassType(t.spec,{renderCanvas:t.canvas,mode:"desktop-browser",canvasControled:!1,viewBox:t.viewBox,interactive:!1,animation:!1}),this.chartInstance.renderSync())}activate(t){this.active=!0;const{x1:e,y1:i,x2:n,y2:r}=this.attribute.viewBox,o=t.scenegraph.tableGroup.globalAABBBounds,s=new je;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,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),GW.temp&&t.scenegraph.updateChartState(e?.datum)})),this.activeChartInstance.on("brushEnd",(e=>{console.log("brushEnd captured",e),t.scenegraph.updateChartState(e?.value?.inBrushData),GW.temp=0,setTimeout((()=>{GW.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}}const KW=Symbol.for("ChartRender");let UW=class{type;numberType=NW;drawShape(t,e,i,n,r,o,s,a){const l=Pv(t,o?.theme).group,{dataId:h,data:c,viewBox:u}=t.attribute,{width:d=l.width,height:p=l.height}=t.attribute,{chartInstance:f,active:g,cacheCanvas:y,activeChartInstance:m}=t;if(!g&&y)e.drawImage(y,i,n,d,p);else if(m)if("string"==typeof h)m.updateDataSync(h,c??[]);else for(const t in h){const e=h[t];m.updateDataSync(t,e?c?.filter((t=>t.hasOwnProperty(e)))??[]:c??[])}else{const{axes:e}=t.attribute;if(e.forEach(((t,e)=>{if("linear"===t.type){f._chart._components[e]._domain={min:t.range?.min??0,max:t.range?.max??0}}else if("band"===t.type){const i=f._chart._components[e];i._spec.domain=t.domain.slice(0),i.updateScaleDomain()}})),f.updateViewBox({x1:u.x1-t.getRootNode().table.scrollLeft,x2:u.x2-t.getRootNode().table.scrollLeft,y1:u.y1-t.getRootNode().table.scrollTop,y2:u.y2-t.getRootNode().table.scrollTop}),"string"==typeof h)f.updateDataSync(h,c??[]);else for(const t in h){const e=h[t];f.updateDataSync(t,e?c?.filter((t=>t.hasOwnProperty(e)))??[]:c??[])}const i=f.getStage();t.cacheCanvas=i.toCanvas()}}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);const s=Pv(t,n?.theme).group,{scrollX:a=s.scrollX,scrollY:l=s.scrollY}=t.attribute;let h;(a||l)&&r.translate(a,l),n&&n.drawingCb&&(h=n.drawingCb()),h&&h.then?h.then((()=>{o?r.restore():r.highPerformanceRestore()})):o?r.restore():r.highPerformanceRestore()}};UW=jW([jy()],UW);let VW=class{time=Tm.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()}}};VW=jW([jy()],VW);let $W=class{time=Tm.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 YW(t,e,n){const{highlightScope:r,disableHeader:o,cellPos:s}=t.hover;if(!t.table.isHeader(e,n)||!o){if(r===i.single&&s.col===e&&s.row===n)return"cellBgColor";if(r===i.column&&s.col===e)return"inlineColumnBgColor";if(r===i.row&&s.row===n)return"inlineRowBgColor";if(r===i.cross){if(s.col===e&&s.row===n)return"cellBgColor";if(s.col===e)return"inlineColumnBgColor";if(s.row===n)return"inlineRowBgColor"}}}$W=jW([jy()],$W);let XW=class{time=Tm.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)}};XW=jW([jy()],XW);let qW=class{time=Tm.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:y=l.strokeArrayWidth,lineWidth:m=l.lineWidth,strokeColor:b=l.stroke}=t.attribute;if(!f||!Array.isArray(y)&&0===m)return;let v,w;if(Array.isArray(g)||Array.isArray(y)){if("number"==typeof m&&1&m||Array.isArray(y)&&y.some((t=>1&t))){i=Math.floor(i)+.5,n=Math.floor(n)+.5;const{width:e,height:r}=rz(t,Math.ceil(d),Math.ceil(p));v=e,w=r}else v=Math.ceil(d),w=Math.ceil(p);ZW(t,e,i,n,l,f,y||m,g||b,v,w)}}};function ZW(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),y=Array.isArray(a)||d.isSplitDraw;e.setStrokeStyle(t,t.attribute,i,n,r);let m=!1;e.getLineDash().length&&(m=!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)),!y&&!m||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)),!y&&!m||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)),!y&&!m||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)),!y&&!m||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),y||m||(!p&&d.width&&(e.lineWidth=d.width),e.stroke())}qW=jW([jy()],qW);let JW=class{time=Tm.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:y=l.strokeArrayWidth}=t.attribute;f&&Array.isArray(p)&&p.length&&!Array.isArray(g)&&!Array.isArray(y)&&(d.doStroke=!1)}};JW=jW([jy()],JW);let QW=class{time=Tm.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:y=l.lineWidth}=t.attribute;if(!p||!Array.isArray(d)||!d.length||Array.isArray(f)||Array.isArray(g))return;let m,b,{width:v=l.width,height:w=l.height}=t.attribute;if(v=Math.ceil(v),w=Math.ceil(w),1&y){i=Math.floor(i)+.5,n=Math.floor(n)+.5;const{width:e,height:r}=rz(t,Math.ceil(v),Math.ceil(w));m=e,b=r}else m=Math.ceil(v),b=Math.ceil(w);e.setStrokeStyle(t,t.attribute,i,n,l),e.beginPath(),e.moveTo(i,n),e.lineTo(i+m,n),e.lineDashOffset=e.currentMatrix.e/e.currentMatrix.a,e.stroke(),e.beginPath(),e.moveTo(i+m,n),e.lineTo(i+m,n+b),e.lineDashOffset=e.currentMatrix.f/e.currentMatrix.d,e.stroke(),e.beginPath(),e.moveTo(i,n+b),e.lineTo(i+m,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()}};QW=jW([jy()],QW);let tz=class{time=Tm.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:y=l.strokeArrayWidth,strokeArrayColor:m=l.strokeArrayColor}=t.attribute;f&&Array.isArray(g)&&!g.length&&!Array.isArray(m)&&!Array.isArray(y)&&1&p&&(d.doStroke=!1)}};tz=jW([jy()],tz);let ez=class{time=Tm.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:y=l.strokeArrayColor}=t.attribute,{width:m=l.width,height:b=l.height}=t.attribute;if(p&&Array.isArray(f)&&!f.length&&!Array.isArray(y)&&!Array.isArray(g)&&1&d){const{width:r,height:o}=rz(t,Math.ceil(m),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()}}};ez=jW([jy()],ez);let iz=class{time=Tm.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=function(t,e){let i;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=YW(e.stateManeger,n,r);!t||i&&"cellBgColor"!==t||(i=t)}else"cell"===t.role&&(i=YW(e.stateManeger,t.col,t.row));if(!i)return;return nW(i,e.isHeader(t.col,t.row)?e.theme.headerStyle?.hover:e.theme.bodyStyle?.hover,t.col,t.row,e)}(t,t.stage.table);e&&(t.oldColor=t.attribute.fill,t.attribute.fill=e)}}};iz=jW([jy()],iz);let nz=class{time=Tm.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 rz(t,e,i){const n=t.stage.table;if("cell"===t.role){let r=t.col,o=t.row;const s=RH(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}}nz=jW([jy()],nz);let oz=class{time=Tm.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)}};oz=jW([jy()],oz);let sz=class{time=Tm.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:y=l.strokeArrayWidth,lineWidth:m=l.lineWidth,strokeColor:b=l.stroke}=t.attribute;f&&(Array.isArray(y)||0!==m)&&(Array.isArray(f)||Array.isArray(g)||Array.isArray(y))&&(("number"==typeof m&&1&m||Array.isArray(y)&&y.some((t=>1&t)))&&(i=Math.floor(i)+.5,n=Math.floor(n)+.5),ZW(t,e,i,n,l,f,y||m,g||b,Math.ceil(d),Math.ceil(p)))}};sz=jW([jy()],sz);var az=new Oy(((t,e,i,n)=>{i(QA)?n(QA).to(oz).inSingletonScope():(t(oz).toSelf().inSingletonScope(),t(jC).toService(oz)),i(tT)?n(tT).to(sz).inSingletonScope():(t(sz).toSelf().inSingletonScope(),t(jC).toService(sz)),t(qW).toSelf().inSingletonScope(),t(DC).toService(qW),t(XW).toSelf().inSingletonScope(),t(DC).toService(XW),t(UW).toSelf().inSingletonScope(),t(KW).to(UW),t(pA).to(UW),t(VW).toSelf().inSingletonScope(),t(FC).toService(VW),t($W).toSelf().inSingletonScope(),t(FC).toService($W),t(JW).toSelf().inSingletonScope(),t(DC).toService(JW),t(QW).toSelf().inSingletonScope(),t(DC).toService(QW),t(tz).toSelf().inSingletonScope(),t(DC).toService(tz),t(ez).toSelf().inSingletonScope(),t(DC).toService(ez),t(iz).toSelf().inSingletonScope(),t(DC).toService(iz),t(nz).toSelf().inSingletonScope(),t(DC).toService(nz)}));function lz(t,e,i,n){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=hz(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?hz(n,0,t.rowCount-1,t,!1):hz(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;let i=0;for(let e=0;e<t.colCount;e++)i+=t.getColWidth(e);const n=e/i;for(let i=0;i<t.colCount;i++){let r;r=i===t.colCount-1?e-t.getColsWidth(0,t.colCount-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&&(n+=r),i+=r}if(i<e&&i-n>0){const r=(e-n)/(i-n);for(let e=t.frozenColCount;e<t.colCount;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 hz(t,e,i,n,o){const{layoutMap:s,transpose:a}=n.internalProps,{width:l}=s?.getColumnWidthDefined(t)??{};if(a){if("standard"===n.widthMode){if(n.isRowHeader(t,0)||n.isCornerHeader(t,0))return Array.isArray(n.defaultHeaderColWidth)?n.defaultHeaderColWidth[t]??n.defaultColWidth:n.defaultHeaderColWidth;if("auto"!==l)return"string"==typeof l?NF(l,n.internalProps.calcWidthContext):l||n.defaultColWidth}else if("adaptive"===n.widthMode&&0===t&&"auto"!==l&&s?.showHeader){if("string"==typeof l)return NF(l,n.internalProps.calcWidthContext);if(l)return l}}else if("auto"!==l&&"autoWidth"!==n.widthMode&&!o)return"string"==typeof l?NF(l,n.internalProps.calcWidthContext):l||n.getColWidth(t);return function(t,e,i,n,o,s){let a=0,l=1;n-i>5e3&&(l=Math.ceil((n-i)/5e3));if(s.isPivotChart()&&e>=s.rowHeaderLevelCount){if(s.internalProps.layoutMap.indicatorsAsCol)return s.defaultColWidth;{const t=s.internalProps.layoutMap.getOptimunWidthForChart(e);if(t>0)return t}}for(let o=i;o<=n;o+=l){const i=cz(e,o,s);if("number"==typeof i){a=Math.max(i,a);continue}const n=t;if("number"==typeof n&&"standard"===s.widthMode){a=Math.max(n,a);continue}const l=s.isHeader(e,o)?s._getHeaderLayoutMap(e,o)?.headerType:s.getBodyColumnType(e,o);if("text"!==l&&"link"!==l&&"progressbar"!==l){a=Math.max(a,s.getColWidth(e)||0);continue}let h=0;const c=s.internalProps.layoutMap;if(c.isHeader(e,o)){const t=c.getHeader(e,o);if("only-body"===t?.define?.columnWidthComputeMode)continue;t?.hierarchyLevel&&(h=(t.hierarchyLevel??0)*(c.rowHierarchyIndent??0))}else{const t=s.getBodyColumnDefine(e,o);if(t?.tree){const t=s.dataSource.getIndexKey(s.getRecordIndexByRow(e,o));h=Array.isArray(t)&&s.getHierarchyState(e,o)!==r.none?(t.length-1)*(c.hierarchyIndent??0):0}}const u=uz(e,o,s);a=Math.max(u+h,a)}const h=s.getMinColWidth(e),c=s.getMaxColWidth(e);if(a<h)return h;if(a>c)return c;return a}(l,t,e,i,0,n)}function cz(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:dz(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 uz(t,e,i){let n=0;const r=i.getCellValue(t,e),o=i._getCellStyle(t,e);let s=0;const l=i.getBodyColumnDefine(t,e);if("body"!==i.getCellType(t,e)||(!!l?.icon||!!l?.tree)){const n=i.getCellIcons(t,e);n?.forEach((t=>{t.positionType!==a.absoluteRight&&(s+=(t.width??0)+(t.marginLeft??0)+(t.marginRight??0))}))}let h=1;if(i.isHeader(t,e)||i.getBodyColumnDefine(t,e).mergeCell){const n=i.getCellRange(t,e);h=n.end.col-n.start.col+1}const c=cF(nW("padding",o,t,e,i)),u=c[1]+c[3],d=nW("fontSize",o,t,e,i),p=nW("fontFamily",o,t,e,i),f=T(r).split("\n")||[];return f.length>=1?f.forEach((t=>{const e=i.measureText(t.slice(0,i.options.maxCharactersNumber||200),{fontSize:d,fontFamily:p}).width;n=Math.max((e+u+4+s)/h,n)})):n=Math.max((u+4+s)/h,n),!1!==i.internalProps.limitMaxAutoWidth&&(n=Math.min("number"==typeof i.internalProps.limitMaxAutoWidth?i.internalProps.limitMaxAutoWidth:450,n)),n}function dz(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 pz=new bW({autoWrapText:!0}),fz=new b_({width:0,height:0,textConfig:[]});function gz(t,e,i){const n="undefined"!=typeof window?window.performance.now():0;if("autoHeight"===t.heightMode){if(e=e??0,i=i??t.rowCount-1,0===e&&i===t.rowCount-1)t._clearRowRangeHeightsMap();else for(let n=e;n<=i;n++)t._clearRowRangeHeightsMap(n);for(let i=e;i<t.columnHeaderLevelCount;i++){const e=yz(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||!mz(t))if((t.internalProps.transpose||t.isPivotTable()&&!t.internalProps.layoutMap.indicatorsAsCol)&&mz(t))for(let n=Math.max(e,t.columnHeaderLevelCount);n<=i;n++){t._clearRowRangeHeightsMap(n);const e=yz(n,0,t.rowHeaderLevelCount,t);t.setRowHeight(n,e)}else for(let n=Math.max(e,t.columnHeaderLevelCount);n<=i;n++){t._clearRowRangeHeightsMap(n);const e=yz(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)}(yz(t.columnHeaderLevelCount,0,t.colCount-1,t),t.columnHeaderLevelCount,t.rowCount-1,t)}}else 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)}}console.log("computeRowsHeight time:",("undefined"!=typeof window?window.performance.now():0)-n)}function yz(t,e,i,n){let r=0;for(let o=e;o<=i;o++){const e=bz(o,t,n);if("number"==typeof e){r=Math.max(e,r);continue}const i=vz(o,t,n);r=Math.max(i,r)}return r}function mz(t){const{layoutMap:e}=t.internalProps,i=t.columnHeaderLevelCount;for(let n=0;n<t.colCount;n++){const r=e.isHeader(n,i),o=r?e.getHeader(n,i):e.getBody(n,i);if("function"==typeof o.style||"function"==typeof o.icon||"function"==typeof o.headerIcon||(r?o.define?.headerCustomRender:o.define?.customRender)||(r?"function"==typeof o.define?.headerIcon:"function"==typeof o.define?.icon))return!1;const s=t._getCellStyle(n,i);if("function"==typeof s.padding||"function"==typeof s.fontSize||"function"==typeof s.lineHeight||!0===s.autoWrapText)return!1}return!0}function bz(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:dz(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 vz(t,e,i){let n=0;const r=i.getCellValue(t,e),o=i._getCellStyle(t,e);let s=0,l=0;const h=[];let c=0;const u=[];let d=0;const p=i.getBodyColumnDefine(t,e);if("body"!==i.getCellType(t,e)||(!!p?.icon||!!p?.tree)){const n=i.getCellIcons(t,e);n?.forEach((t=>{t.positionType!==a.absoluteRight&&t.positionType!==a.inlineFront&&t.positionType!==a.inlineEnd?(l+=(t.width??0)+(t.marginLeft??0)+(t.marginRight??0),s=Math.max(s,t.height??0)):t.positionType===a.inlineFront?(h.push(t),c=Math.max(c,(t.height??0)+(t.marginLeft??0)+(t.marginRight??0))):t.positionType===a.inlineEnd&&(u.push(t),d=Math.max(d,(t.height??0)+(t.marginLeft??0)+(t.marginRight??0)))}))}let f=1;if(i.isHeader(t,e)||i.getBodyColumnDefine(t,e).mergeCell){const n=i.getCellRange(t,e);f=n.end.row-n.start.row+1}const g=cF(nW("padding",o,t,e,i)),y=nW("fontSize",o,t,e,i),m=nW("fontStyle",o,t,e,i),b=nW("fontWeight",o,t,e,i),v=nW("lineHeight",o,t,e,i)??y,w=nW("fontFamily",o,t,e,i),C=nW("autoWrapText",o,t,e,i),x=T(r).split("\n")||[];if(h.length||u.length){const e=Object.assign({text:r?.toString(),fontFamily:w,fontSize:y,fontStyle:m,fontWeight:b,lineHeight:v});e.textBaseline="middle";const o=[...h.map((t=>xW(t))),e,...u.map((t=>xW(t)))];fz.setAttributes({width:i.getColWidth(t)-(g[1]+g[3])-l,height:0,textConfig:o}),n=fz.AABBBounds.height()}else if(C){const e=i.getColWidth(t)-(g[1]+g[3])-l;pz.setAttributes({maxLineWidth:e,text:x,fontSize:y,fontStyle:m,fontWeight:b,fontFamily:w}),n=pz.AABBBounds.height()}else n=x.length*v;return(Math.max(n,s)+g[0]+g[2])/f}const wz=new BH({});wz.role="empty";const Cz={},xz={};function _z(t,e,i,n,r,o,s,a,l,h,c,u,d,p,f,g){const y=it(xz,Cz)[c],m=rW("padding",f._getCellStyle(r,o),r,o,f);A(m)&&(l=m),t||((t=new BH({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 GW({stroke:!1,x:l[3],y:l[0],canvas:f.canvas,spec:u,ClassType:y,width:s-l[3]-l[1],height:a-l[2]-l[0],chartInstance:d,dataId:p,data:f.getCellValue(r,o),cellPadding:l,viewBox:{x1:Math.ceil(t.globalAABBBounds.x1+l[3]+f.scrollLeft),x2:Math.ceil(t.globalAABBBounds.x1+s-l[1]+f.scrollLeft),y1:Math.ceil(t.globalAABBBounds.y1+l[0]+f.scrollTop),y2:Math.ceil(t.globalAABBBounds.y1+a-l[2]+f.scrollTop)},axes:f.internalProps.layoutMap.getChartAxes(r,o)});return t.appendChild(b),f.internalProps.layoutMap.setChartInstance(r,o,b.chartInstance),t}function Sz(t,e,i,n,r,o,s,l,h,c,u,d,p,f,g,y){const m=t._getCellStyle(r,o),b=rW("padding",m,r,o,t);A(b)&&(c=b),y?.text?.textAlign&&(u=y?.text?.textAlign),y?.text?.textBaseline&&(d=y?.text?.textBaseline);const v="auto"===s,C=m.autoWrapText??t.internalProps.autoWrapText,x=m.lineClamp,_=new BH({x:i,y:n,width:l,height:h,lineWidth:y?.group?.lineWidth??void 0,fill:y?.group?.fill??void 0,stroke:y?.group?.stroke??void 0,strokeArrayWidth:y?.group?.strokeArrayWidth??void 0,strokeArrayColor:y?.group?.strokeArrayColor??void 0,cursor:y?.group?.cursor??void 0,lineCap:"square",clip:!0});if(_.role="cell",_.col=r,_.row=o,e.addChild(_),f&&_.appendChild(f),g){const e=t.getCellValue(r,o);let i;if(p&&(i=t.getCellIcons(r,o)),function(t,e,i,n,r,o,s,l,h,c,u,d,p,f){const g=[],y=[],m=[],b=[],v=[],C=[],x=[],_=[];let S,A,T=0,B=0,R=0,M=0,P=0,E=0;if(Array.isArray(e)&&0!==e.length){let H;if(e.forEach((t=>{switch(t.positionType){case a.left:g.push(t);break;case a.right:y.push(t);break;case a.contentLeft:m.push(t);break;case a.contentRight:b.push(t);break;case a.absoluteRight:_.push(t);break;case a.inlineFront:v.push(t);break;case a.inlineEnd:C.push(t)}})),g.forEach((e=>{const i=CW(e,void 0,t.col,t.row,p);i.role="icon-left",i.name=e.name,i.setAttribute("x",T+(i.attribute.marginLeft??0)),T+=i.AABBBounds.width()+(i.attribute.marginLeft??0)+(i.attribute.marginRight??0),B=Math.max(B,i.AABBBounds.height()),t.appendChild(i)})),y.forEach((e=>{const i=CW(e,void 0,t.col,t.row,p);i.role="icon-right",i.name=e.name,i.setAttribute("x",R+(i.attribute.marginLeft??0)),R+=i.AABBBounds.width()+(i.attribute.marginLeft??0)+(i.attribute.marginRight??0),M=Math.max(M,i.AABBBounds.height()),t.appendChild(i)})),x.forEach((e=>{const i=CW(e,void 0,t.col,t.row,p);i.role="icon-absolute-left",i.name=e.name,i.setAttribute("x",P+(i.attribute.marginLeft??0)),P+=i.AABBBounds.width()+(i.attribute.marginLeft??0)+(i.attribute.marginRight??0),t.appendChild(i)})),_.forEach((e=>{const i=CW(e,void 0,t.col,t.row,p);i.role="icon-absolute-right",i.name=e.name,i.setAttribute("x",E+(i.attribute.marginLeft??0)),E+=i.AABBBounds.width()+(i.attribute.marginLeft??0)+(i.attribute.marginRight??0),t.appendChild(i)})),0===v.length&&0===C.length){const t=w(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:h-(n[1]+n[3])-T-R,textBaseline:"top",heightLimit:o?-1:c-(n[0]+n[2]),pickable:!1,autoWrapText:s,lineClamp:l},a=new bW(f.text?Object.assign({},f.text,e):e);a.name="text",H=a}else{const e=Object.assign({text:i?.toString()},t.parent?.theme?.userTheme?.text||{});f.text&&Object.assign(e,f.text),e.textBaseline="middle";const s=[...v.map((t=>xW(t))),e,...C.map((t=>xW(t)))];s[0].textAlign=u;const a=new b_({width:r?0:h-(n[1]+n[3])-T-R,height:o?0:c-(n[0]+n[2]),textConfig:s,verticalDirection:o?"top":d});a.name="text",H=a,a.bindIconEvent()}if(0!==m.length||0!==b.length){const e=new vW({x:0,y:0,fill:!1,stroke:!1});e.name="content",e.setCellContentOption({autoWidth:r,autoHeight:o,cellWidth:h-(n[1]+n[3])-T-R,cellHeight:c-(n[0]+n[2]),align:u,baseline:d}),m.forEach((i=>{const n=CW(i,void 0,t.col,t.row,p);n.role="icon-content-left",n.name=i.name,e.addLeftOccupyingIcon(n)})),b.forEach((i=>{const n=CW(i,void 0,t.col,t.row,p);n.role="icon-content-right",n.name=i.name,e.addRightOccupyingIcon(n)})),e.addContent(H),t.appendChild(e),e.layout(),S=e.AABBBounds.width(),A=e.AABBBounds.height()}else t.firstChild?t.insertBefore(H,t.firstChild):t.appendChild(H),S=H.AABBBounds.width(),A=H.AABBBounds.height()}else if(i){const e=w(i).replace(/\r?\n/g,"\n").replace(/\r/g,"\n").split("\n"),a=wW(t.col,t.row,p),u={text:1!==e.length||s?e:e[0],maxLineWidth:r?1/0:h-(n[1]+n[3]+a),textBaseline:"top",autoWrapText:s,lineClamp:l,heightLimit:o?-1:c-(n[0]+n[2]),pickable:!1,dx:a},d=new bW(f.text?Object.assign({},f.text,u):u);d.name="text",t.appendChild(d),S=d.AABBBounds.width(),A=d.AABBBounds.height()}const H=r?T+S+R:h-(n[1]+n[3]),L=o?Math.max(B,A,M):c-(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+H-R+n[3]):"icon-absolute-right"===t.role?t.setAttribute("x",t.attribute.x+H-E+n[3]+n[1]):"content"!==t.name&&"text"!==t.name||("center"===u&&"richtext"!==t.type?t.setAttribute("x",n[3]+T+(H-T-R)/2):"right"===u&&"richtext"!==t.type?t.setAttribute("x",n[3]+H-R):t.setAttribute("x",n[3]+T))})),t.forEachChildren((t=>{"middle"===d?t.setAttribute("y",n[0]+(L-t.AABBBounds.height())/2):"bottom"===d?t.setAttribute("y",n[0]+L-t.AABBBounds.height()):t.setAttribute("y",n[0])})),t.setAttributes({width:H+n[1]+n[3],height:L+n[0]+n[2]})}(_,i,e,c,v,!1,C,"number"==typeof x?x:void 0,l,h,u,d,t,y),y?._vtable?.marked){const t=rS({x:_.attribute.width,y:0,startAngle:Math.PI/2,endAngle:Math.PI,outerRadius:6,fill:"#3073F2",pickable:!1});t.name="mark",_.appendChild(t)}}return f&&_.setAttributes({width:Math.max(_.attribute.width,f.attribute.width),height:Math.max(_.attribute.height,f.attribute.height)}),_}const Az=tW();function Tz(t,e,i){t.then((()=>{i(),e.scenegraph.updateNextFrame()})).catch((t=>{console.error(t)}))}function Bz(t,e,i,n,r,o,s,a,l,h,c,u,d,p,f,g,y,m){let b;if("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||Pi.test(o))&&(m?(m.text.fill=nW("linkColor",s,n,r,i),m.group.cursor="pointer"):m={text:{fill:nW("linkColor",s,n,r,i)},group:{cursor:"pointer"}})}if(s){const t=i.getCellOriginValue(n,r),e=s(i,t);e&&(m?m.group.fill=e:m={group:{fill:e}})}let v,w,C,x=!0;if("body"!==i.getCellType(n,r)?(w=e?.headerCustomRender,C=e?.headerCustomLayout):(w=e?.customRender||i.customRender,C=e?.customLayout),C||w){const t=SW(C,w,n,r,i.getColWidth(n),i.getRowHeight(r),!1,"autoHeight"===i.heightMode,i);v=t.elementsGroup,x=t.renderDefault}b=Sz(i,h,0,c,n,r,o,a,l,u,d,p,f,v,x,m),g&&(b.mergeCol=y.end.col,b.mergeRow=y.end.row);const _=i.internalProps.layoutMap.getAxisConfigInPivotChart(n,r);if(_){const t=new KD(_,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=rW("padding",d._getCellStyle(n,r),n,r,d);A(f)&&(h=f),p?.text?.textAlign&&(c=p?.text?.textAlign),p?.text?.textBaseline&&(u=p?.text?.textBaseline);const g=new BH({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 y=d.getCellValue(n,r),m=dS({x:h[3],y:h[0],width:o-h[1]-h[3],height:s-h[0]-h[2],image:y??oW.damage_pic.svg,cursor:"pointer"});return m.name="image",m.keepAspectRatio=a,m.successCallback=a||l?()=>{const t=m.resources.get(m.attribute.image).data;if(l&&sW(n,r,t.width,t.height,d.scenegraph,h),a){const{width:e,height:i}=eW(t.width,t.height,g.attribute.width-h[1]-h[3],g.attribute.height-h[0]-h[2]),n=iW(0,0,g.attribute.width,g.attribute.height,e,i,c,u,h);m.setAttributes({x:n.x,y:n.y,width:e,height:i})}d.scenegraph.updateNextFrame()}:()=>{aW(g,n,r,d)},m.failCallback=()=>{const t=tW();m.image=t.damage_pic.svg},g.appendChild(m),g}(h,0,c,n,r,i.getColWidth(n),i.getRowHeight(r),e.keepAspectRatio,e.imageAutoSizing,u,d,p,i,m);else if("video"===t)b=function(t,e,i,n,r,o,s,a,l,h,c,u,d,p){const f=rW("padding",d._getCellStyle(n,r),n,r,d);A(f)&&(h=f),p?.text?.textAlign&&(c=p?.text?.textAlign),p?.text?.textBaseline&&(u=p?.text?.textBaseline);const g=new BH({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 y=d.getCellValue(n,r),m=document.createElement("video");m.addEventListener("loadeddata",(()=>{l&&sW(n,r,m.videoWidth,m.videoHeight,d.scenegraph,h);const t=g.attribute.width,e=g.attribute.height;if(a){const{width:i,height:n}=eW(m.videoWidth,m.videoHeight,t-h[1]-h[3],e-h[0]-h[2]),r=iW(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 pW({x:o-i/2,y:s-i/2,width:i,height:i,image:Az.play.svg,cursor:Az.play.cursor});p.name="play-icon",g.appendChild(p),d.scenegraph.updateNextFrame()})),m.onerror=()=>{b.image=Az.damage_pic.svg},m.src=y,m.setAttribute("preload","auto");const b=dS({x:h[3],y:h[0],width:o-h[1]-h[3],height:s-h[2]-h[0],image:m,cursor:"pointer"});return b.name="image",g.appendChild(b),g}(h,0,c,n,r,i.getColWidth(n),i.getRowHeight(r),e.keepAspectRatio,e.imageAutoSizing,u,d,p,i,m);else if("chart"===t){const t=i.internalProps.layoutMap.getChartInstance(n,r);b=_z(null,h,0,c,n,r,i.getColWidth(n),i.getRowHeight(r),u,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),s=i.getCellValue(n,r),f=i.getCellOriginValue(n,r);b=Sz(i,h,0,c,n,r,o,a,l,u,d,p,!1,null,!0,m);const g=lW(e,t,o,s,f,n,r,0,i);b.insertBefore(g,b.firstChild)}else"sparkline"===t&&(b=uW(null,h,0,c,n,r,a,l,u,i,m));return b}function Rz(t,e,i,n){const r=i.scenegraph.highPerformanceGetCell(t,e,!0),o=i.isHeader(t,e)?i._getHeaderLayoutMap(t,e).headerType:i.getBodyColumnType(t,e),s=i.getCellType(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=qF(i._getCellStyle(t,e),i,t,e,nW).theme,p=d._vtable.padding,f=d._vtable.textAlign,g=d._vtable.textBaseline;let y,m,b;i.internalProps?.dataConfig?.mappingRules&&"body"===s&&i.internalProps?.dataConfig?.mappingRules?.forEach(((t,e)=>{t.bgColor&&(y=t.bgColor.mapping)})),"body"!==s?(a?.headerCustomRender,a?.headerCustomLayout):(a?.customRender||i.customRender,a?.customLayout),h?(m=i.getColsWidth(h.start.col,h.end.col),b=i.getRowsHeight(h.start.row,h.end.row)):(m=i.getColWidth(t),b=i.getRowHeight(e));const v=i.getCellValue(t,e);st(v)?(r.removeAllChild(),Tz(v,i,Mz.bind(null,o,a,i,t,e,y,m,b,r,p,f,g,u,l,h,n,d))):c=Mz(o,a,i,t,e,y,m,b,r,p,f,g,u,l,h,n,d)}else c=new BH({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));return c}function Mz(t,e,i,n,r,o,s,a,l,h,c,u,d,p,f,g,y){const m=Bz(t,e,i,n,r,i.getColWidth(n),o,s,a,g?i.scenegraph.getColGroup(n):l.parent,g?0:l.attribute.y,h,c,u,d,p,f,y);return g||(l.parent.insertAfter(m,l),l.parent.removeChild(l),i.scenegraph?.proxy.cellCache.get(n)&&i.scenegraph?.proxy.cellCache.set(n,m)),m}function Pz(t,e,i,n,r,o,s,a,l,h){let c,u,d,p,f=0;a.internalProps?.dataConfig?.mappingRules&&"body"===l&&a.internalProps?.dataConfig?.mappingRules?.forEach(((t,e)=>{t.bgColor&&(p=t.bgColor.mapping)}));let g=0;t.colHeight&&(g=t.colHeight);for(let y=n;y<=r;y++){const n=y,r="body"!==l?a.getHeaderDefine(e,n):a.getBodyColumnDefine(e,n),m="body"!==l||(!!r?.icon||!!r?.tree),b=qF(a._getCellStyle(e,n),a,e,n,nW).theme;b.group.width=i,b.group.height=Array.isArray(s)?s[n]:s,b._vtable.padding&&(c=b._vtable.padding),b.text.textAlign&&(u=b.text.textAlign),b.text.textBaseline&&(d=b.text.textBaseline),"body"===l||b.group.fill||(b.group.fill="#fff");let v=i,w=a.getRowHeight(n);const C=(a.isHeader(e,n)?a._getHeaderLayoutMap(e,n).headerType:a.getBodyColumnType(e,n))||"text";let x,_,S;if(("body"!==l||r?.mergeCell)&&(_=a.getCellRange(e,n),S=_.start.col!==_.end.col||_.start.row!==_.end.row,S&&(v=0,w=0,x=o.get(`${_.start.col},${_.start.row};${_.end.col},${_.end.row}`),!x))){for(let t=_.start.col;t<=_.end.col;t++)v+=a.getColWidth(t);for(let t=_.start.row;t<=_.end.row;t++)w+=a.getRowHeight(t);o.set(`${_.start.col},${_.start.row};${_.end.col},${_.end.row}`,{x:0,y:g,cellWidth:v,cellHeight:w})}if(x){const i=x.cellHeight/(_.end.row-_.start.row+1),r=new BH({x:0,y:g,width:0,height:i,visible:!1,pickable:!1});r.role="shadow-cell",r.col=e,r.row=n,r.mergeCol=_.start.col,r.mergeRow=_.start.row,t.addChild(r),t.updateColumnRowNumber(n),t.updateColumnHeight(i),_=a.getCellRange(e,n),g+=i,f=Math.max(f,x.cellWidth)}else{const o=a.getCellValue(e,n);if(st(o)){Tz(o,a,Bz.bind(null,C,r,a,e,n,i,p,v,w,t,g,c,u,d,m,S,_,b)),t.updateColumnRowNumber(n);const s=S?a.getRowHeight(n)/(_.end.row-_.start.row+1):a.getRowHeight(n);t.updateColumnHeight(s),g+=s}else{const o=Bz(C,r,a,e,n,i,p,v,w,t,g,c,u,d,m,S,_,b);t.updateColumnRowNumber(n);const s=S?o.attribute.height/(_.end.row-_.start.row+1):o.attribute.height;t.updateColumnHeight(s),g+=s}}if(h&&n>h)break}return t.setAttribute("width",i),{width:i,height:g}}function Ez(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 BH({x:e+f,y:i,width:r,height:0,clip:!1,pickable:!1});p.role="column",p.col=c,t.addChild(p);const{width:y,height:m}=Pz(p,n,r,o,s,l.scenegraph.mergeMap,"columnHeader"===a?d??u:u,l,a,h);f+=y,g=Math.max(g,m)}t.setAttribute("width",f),t.setAttribute("height",g)}async function Hz(t,e,i,n){if("left"===e&&n.colEnd+t>n.bodyRightCol?t=n.bodyRightCol-n.colEnd:"right"===e&&n.colStart-t<n.bodyLeftCol&&(t=n.colStart-n.bodyLeftCol),n.table.scenegraph.bodyGroup,t<n.colEnd-n.colStart){const r="left"===e?n.colStart:n.colEnd-t+1,o="left"===e?n.colStart+t-1:n.colEnd,s="left"===e?n.colEnd+1:n.colStart-t,a="left"===e?n.colEnd+t:n.colStart-1;lz(n.table,s,a),function(t,e,i,n){for(let r=t;r<=e;r++)n.table.scenegraph.bodyGroup.childrenCount>0&&Iz(n.table.scenegraph.bodyGroup,i,n),n.table.scenegraph.colHeaderGroup.childrenCount>0&&Iz(n.table.scenegraph.bodyGroup,i,n),n.table.scenegraph.bottomFrozenGroup.childrenCount>0&&Iz(n.table.scenegraph.bodyGroup,i,n)}(r,o,e,n);const l=Math.max(n.bodyLeftCol,i-1*n.screenColCount),h=Math.min(n.bodyRightCol,i+2*n.screenColCount);n.colStart="left"===e?n.colStart+t:n.colStart-t,n.colEnd="left"===e?n.colEnd+t:n.colEnd-t,Dz(s,n),Oz(l,h,n),n.currentCol="left"===e?n.currentCol+t:n.currentCol-t,n.totalCol="left"===e?n.totalCol+t:n.totalCol-t,n.referenceCol=n.colStart+Math.floor((n.colEnd-n.colStart)/2),n.colUpdatePos=s,n.colUpdateDirection=e,n.table.scenegraph.stage.render(),await n.progress()}else{const r="left"===e?n.colStart+t:n.colStart-t,o="left"===e?n.colEnd+t:n.colEnd-t;lz(n.table,r,o);const s=n.table.getColsWidth(n.bodyLeftCol,r-1);console.log("distStartColY",n.bodyLeftCol,r-1,s),function(t,e,i,n){n.table.scenegraph.colHeaderGroup.forEachChildren(((r,o)=>{"group"===r.type&&Lz(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&&Lz(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&&Lz(r,"left"===i?r.col+e:r.col-e,0===o?t:r._prev.attribute.x+n.table.getColWidth(r._prev.col))}))}(s,t,e,n);const a=Math.max(n.bodyLeftCol,i-1*n.screenRowCount),l=Math.min(n.bodyRightCol,i+2*n.screenRowCount);n.colStart=r,n.colEnd=o,Dz(r,n),Oz(a,l,n),n.currentCol="left"===e?n.currentCol+t:n.currentCol-t,n.totalCol="left"===e?n.totalCol+t:n.totalCol-t,n.referenceCol=n.colStart+Math.floor((n.colEnd-n.colStart)/2),n.colUpdatePos=n.colStart,n.colUpdateDirection=o>n.bodyRightCol-(n.colEnd-n.colStart+1)?"right":"left",await n.progress()}}function Lz(t,e,i){t.col=e,t.forEachChildren((t=>{t.col=e,t.needUpdate=!0})),t.setAttribute("x",i),t.needUpdate=!0}function kz(t,e){let i=t.firstChild;for(;i;){i=e.updateCellGroupContent(i)._next}t.needUpdate=!1}function Iz(t,e,i){if("left"===e){const e=t.firstChild;Lz(e,t.lastChild.col+1,t.lastChild.attribute.x+t.lastChild.attribute.width),t.appendChild(e)}else{const e=t.lastChild;Lz(e,t.firstChild.col-1,t.firstChild.attribute.x-i.table.getColWidth(t.firstChild.col-1)),t.insertBefore(e,t.firstChild)}}function Oz(t,e,i){for(let n=t;n<=e;n++){kz(i.table.scenegraph.getColGroup(n),i);kz(i.table.scenegraph.getColGroup(n,!0),i);kz(i.table.scenegraph.getColGroupInBottom(n),i)}}function Dz(t,e){for(let i=0;i<e.table.rowCount;i++){if(i>=e.table.columnHeaderLevelCount&&i<e.rowStart||i>e.rowEnd&&i<e.table.rowCount-e.table.bottomFrozenRowCount)continue;const n=RH(e.table,t,i);if(n&&n.start.row!==i){const r=e.highPerformanceGetCell(t,i,!0),o=Rz(n.start.col,n.start.row,e.table,!0);o.col=t,o.row=i,o.setAttribute("x",e.table.getColsWidth(e.table.rowHeaderLevelCount,n.start.col-1)),r.parent.insertAfter(o,r),r.parent.removeChild(r),r.needUpdate=!1,o.needUpdate=!1,e.cellCache.get(t)&&e.cellCache.set(t,o)}}}function Fz(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.getCell(o,t);if(!e.row)continue;let i;i=e._prev?(e._prev?.attribute.y??0)+(e._prev?.attribute.height??0):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.getCell(o,t);if(!e.row)continue;let i;e._next?i=(e._next?.attribute.y??0)-(e.attribute.height??0):(i=r.getRowsHeight(r.columnHeaderLevelCount,e.row)-(e.attribute.height??0),console.log("估计位置",r.getRowsHeight(r.columnHeaderLevelCount,e.row))),e.setAttribute("y",i)}}async function Wz(t,e,i,n){if("up"===e&&n.rowEnd+t>n.bodyBottomRow?t=n.bodyBottomRow-n.rowEnd:"down"===e&&n.rowStart-t<n.bodyTopRow&&(t=n.rowStart-n.bodyTopRow),t<n.rowEnd-n.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++)zz(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++)zz(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++)zz(o,i,n)}}("up"===e?n.rowStart:n.rowEnd-t+1,"up"===e?n.rowStart+t-1:n.rowEnd,e,n);const r="up"===e?n.rowEnd+1:n.rowStart-t;"up"===e?n.rowEnd:n.rowStart;const o=Math.max(n.bodyTopRow,i-1*n.screenRowCount),s=Math.min(n.bodyBottomRow,i+2*n.screenRowCount);"autoHeight"===n.table.heightMode&&gz(n.table,o,s),n.rowStart="up"===e?n.rowStart+t:n.rowStart-t,n.rowEnd="up"===e?n.rowEnd+t:n.rowEnd-t,Nz(r,n),jz(o,s,n),"autoHeight"===n.table.heightMode&&Fz(n.bodyLeftCol,n.bodyRightCol,o,s,n.table,e),n.currentRow="up"===e?n.currentRow+t:n.currentRow-t,n.totalRow="up"===e?n.totalRow+t:n.totalRow-t,n.referenceRow=n.rowStart+Math.floor((n.rowEnd-n.rowStart)/2),n.rowUpdatePos=r,n.rowUpdateDirection=e,console.log("move end proxy",n.rowStart,n.rowEnd),console.log("move end cell",n.table.scenegraph.bodyGroup.firstChild.firstChild.row,n.table.scenegraph.bodyGroup.firstChild.lastChild.row),n.table.scenegraph.updateNextFrame(),await n.progress()}else{const r="up"===e?n.rowStart+t:n.rowStart-t,o="up"===e?n.rowEnd+t:n.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))}))}}(n.table.getRowsHeight(n.bodyTopRow,r-1),t,e,n),"autoHeight"===n.table.heightMode?(s=r,a=o):(s=Math.max(n.bodyTopRow,i-1*n.screenRowCount),a=Math.min(n.bodyBottomRow,i+2*n.screenRowCount)),console.log("更新同步范围",s,a),"autoHeight"===n.table.heightMode&&gz(n.table,s,a),n.rowStart=r,n.rowEnd=o,Nz(r,n),jz(s,a,n),console.log("updateAutoRow",o>n.bodyBottomRow-(n.rowEnd-n.rowStart+1)?"down":"up"),"autoHeight"===n.table.heightMode&&Fz(n.bodyLeftCol,n.bodyRightCol,s,a,n.table,o>n.bodyBottomRow-(n.rowEnd-n.rowStart+1)?"down":"up"),n.currentRow="up"===e?n.currentRow+t:n.currentRow-t,n.totalRow="up"===e?n.totalRow+t:n.totalRow-t,n.referenceRow=n.rowStart+Math.floor((n.rowEnd-n.rowStart)/2),n.rowUpdatePos=n.rowStart,n.rowUpdateDirection=o>n.bodyBottomRow-(n.rowEnd-n.rowStart+1)?"down":"up",console.log("move total end proxy",n.rowStart,n.rowEnd),console.log("move total end cell",n.table.scenegraph.bodyGroup.firstChild.firstChild.row,n.table.scenegraph.bodyGroup.firstChild.lastChild.row),n.table.scenegraph.updateNextFrame(),"autoHeight"!==n.table.heightMode&&await n.progress()}}function zz(t,e,i){if("up"===e){const e=t.firstChild;i.updateCellGroupPosition(e,t.lastChild.row+1,t.lastChild.attribute.y+t.lastChild.attribute.height),t.appendChild(e)}else{const e=t.lastChild;i.updateCellGroupPosition(e,t.firstChild.row-1,t.firstChild.attribute.y-e.attribute.height),t.insertBefore(e,t.firstChild)}}function jz(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)}}function Nz(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=RH(e.table,i,t);if(n&&n.start.row!==t){const r=e.highPerformanceGetCell(i,t,!0),o=Rz(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)}}}class Gz{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;colLimit=1e3;bodyLeftCol;bodyRightCol;totalCol;colStart;colEnd;taskColCount;xLimitLeft;xLimitRight;screenColCount;firstScreenColLimit;colUpdatePos;currentCol;referenceCol;screenLeftCol=0;colUpdateDirection;cellCache=new Map;constructor(t){this.table=t,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){l.setParamsForRow(),l.setParamsForColumn(),l.table.internalProps._colWidthsMap.clear(),l.table._clearColRangeWidthsMap(),lz(l.table,0,Math.min(l.firstScreenColLimit,l.table.colCount-1)),l.table.internalProps._rowHeightsMap.clear(),l.table._clearRowRangeHeightsMap(),gz(l.table,0,Math.min(l.firstScreenRowLimit,l.table.rowCount-1)),l.table.rightFrozenColCount>0&&l.table.colCount-1>l.firstScreenColLimit&&lz(l.table,l.table.colCount-1-l.table.rightFrozenColCount+1,l.table.colCount-1),l.table.bottomFrozenRowCount>0&&l.table.rowCount-1>l.firstScreenRowLimit&&lz(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()}),Ez(t,s,a,0,l.table.rowHeaderLevelCount-1,0,l.table.columnHeaderLevelCount-1,"cornerHeader",l.table),Ez(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),Ez(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&&Ez(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&&Ez(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),Ez(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 createColGroupForFirstScreen(t,e,i,n,r){this.setParamsForRow(),this.setParamsForColumn(),gz(r,this.table.columnHeaderLevelCount,Math.min(this.firstScreenRowLimit,r.rowCount-1)),Ez(t,i,n,0,r.rowHeaderLevelCount-1,r.columnHeaderLevelCount,r.rowCount-1,"rowHeader",r,this.firstScreenRowLimit),Ez(e,i,n,r.rowHeaderLevelCount,r.colCount-1,r.columnHeaderLevelCount,r.rowCount-1,"body",r,this.firstScreenRowLimit),e.firstChild?(this.currentRow=e.firstChild?.rowNumber??this.totalRow,this.rowEnd=this.currentRow,this.rowUpdatePos=this.rowEnd,this.referenceRow=Math.floor((this.rowEnd-this.rowStart)/2),await this.progress()):(this.currentRow=this.totalRow,this.rowEnd=this.currentRow,this.rowUpdatePos=this.rowEnd,this.referenceRow=Math.floor((this.rowEnd-this.rowStart)/2))}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(gz(this.table,this.currentRow+1,e),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}=Pz(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}=Pz(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}=Pz(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);if(lz(this.table,this.currentCol+1,e),this.table.columnHeaderLevelCount){const t=this.table.scenegraph.colHeaderGroup.lastChild instanceof BH?this.table.scenegraph.colHeaderGroup.lastChild:this.table.scenegraph.colHeaderGroup.lastChild._prev,i=t.attribute.x+t.attribute.width,n=t.attribute.y;Ez(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 BH?this.table.scenegraph.bottomFrozenGroup.lastChild:this.table.scenegraph.bottomFrozenGroup.lastChild._prev,i=t.attribute.x+t.attribute.width,n=t.attribute.y;Ez(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 BH?this.table.scenegraph.bodyGroup.lastChild:this.table.scenegraph.bodyGroup.lastChild._prev,n=i.attribute.x+i.attribute.width,r=i.attribute.y;Ez(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;e.screenTopRow=n;const r=n-e.referenceRow;r>0?(Wz(r,"up",n,e),e.updateBody(t)):r<0?(Wz(-r,"down",n,e),e.updateBody(t)):e.updateBody(t),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;e.screenLeftCol=i.col;const n=e.screenLeftCol-e.referenceCol;n>0?(e.table.scenegraph.setBodyAndColHeaderX(-t),await Hz(n,"left",e.screenLeftCol,e)):n<0?(e.table.scenegraph.setBodyAndColHeaderX(-t),await Hz(-n,"right",e.screenLeftCol,e)):e.table.scenegraph.setBodyAndColHeaderX(-t),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&&gz(this.table,this.rowUpdatePos,e),jz(this.rowUpdatePos,e,this),"autoHeight"===this.table.heightMode&&Fz(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);lz(this.table,this.colUpdatePos,e),Oz(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 sortCell(){for(let t=this.bodyLeftCol;t<=this.bodyRightCol;t++)for(let e=this.rowStart;e<=this.rowEnd;e++){this.highPerformanceGetCell(t,e).needUpdate=!0}let t,e;"autoHeight"===this.table.heightMode?(t=this.rowStart,e=this.rowEnd):(t=Math.max(this.bodyTopRow,this.screenTopRow-2*this.screenRowCount),e=Math.min(this.bodyBottomRow,this.screenTopRow+3*this.screenRowCount)),console.log("sort更新同步范围",t,e),"autoHeight"===this.table.heightMode&&gz(this.table,t,e);for(let i=this.bodyLeftCol;i<=this.bodyRightCol;i++)for(let n=t;n<=e;n++){const t=this.highPerformanceGetCell(i,n);this.updateCellGroupContent(t)}if(console.log("updateAutoRow",this.rowEnd>this.bodyBottomRow-(this.rowEnd-this.rowStart+1)?"down":"up"),"autoHeight"===this.table.heightMode&&Fz(this.bodyLeftCol,this.bodyRightCol,t,e,this.table,this.rowEnd>this.bodyBottomRow-(this.rowEnd-this.rowStart+1)?"down":"up"),this.rowUpdatePos=this.rowStart,this.rowUpdateDirection=this.rowEnd>this.bodyBottomRow-(this.rowEnd-this.rowStart+1)?"down":"up",this.rowEnd===this.table.scenegraph.proxy.bodyBottomRow&&this.rowStart===this.table.scenegraph.proxy.bodyTopRow);else if(this.rowEnd===this.table.scenegraph.proxy.bodyBottomRow){const t=this.table.getAllRowsHeight()-this.table.scenegraph.height;this.updateBody(t)}else this.rowStart===this.table.scenegraph.proxy.bodyTopRow&&this.updateBody(0);"autoHeight"!==this.table.heightMode&&await this.progress()}highPerformanceGetCell(t,e,i){if(e>=this.table.columnHeaderLevelCount&&e<this.table.rowCount-this.table.bottomFrozenRowCount&&(e<this.rowStart||e>this.rowEnd))return wz;if(t>=this.table.rowHeaderLevelCount&&t<this.table.colCount-this.table.rightFrozenColCount&&(t<this.colStart||t>this.colEnd))return wz;if(this.cellCache.get(t)){const n=this.cellCache.get(t);if((n._next||n._prev)&&Math.abs(n.row-e)<e){let r=Kz(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.row&&this.cellCache.set(t,r),r}const n=this.table.scenegraph.getCell(t,e,i);return n.row&&this.cellCache.set(t,n),n}}function Kz(t,e){return t?t.row===e?t:t.row>e?Kz(t._prev,e):Kz(t._next,e):null}function Uz(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 Vz(t,e,i){const n=i.scenegraph,r=$z(t.map((t=>t.row))).sort(((t,e)=>t-e)),o=$z(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=Rz(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 $z(t){const e=[];for(let i=0;i<t.length;i++)-1===e.indexOf(t[i])&&e.push(t[i]);return e}new rC({});const Yz=[];function Xz(t){Yz.forEach((e=>{t.scenegraph.getCell(e.col,e.row).forEachChildren((t=>{t.setAttributes({dy:0,dx:0})}))})),Yz.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){Zz(t.scenegraph.getCell(i,e),s+t.tableX,t.tableNoFrameWidth-t.getRightFrozenColsWidth()),Yz.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){qz(t.scenegraph.getCell(i,e),o+t.tableY,t.tableNoFrameHeight-t.getBottomFrozenRowsHeight()),Yz.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);qz(n,o+t.tableY,t.tableNoFrameHeight-t.getBottomFrozenRowsHeight()),Zz(n,s+t.tableX,t.tableNoFrameWidth-t.getRightFrozenColsWidth()),Yz.push({col:i,row:e})}}}function qz(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 Zz(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 Jz(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,t.addUpdateBoundTag())}))}))}}function Qz(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 KD(i,t.attribute.width,t.attribute.height,e);t.clear(),t.appendChild(n.component),n.overlap()}}}))}))}function tj(t){const e=t.bodyGroup.firstChild instanceof BH?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 ej(t){const e=t.colHeaderGroup.firstChild instanceof BH?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 ij(t){const e=t.rowHeaderGroup.lastChild instanceof BH?t.rowHeaderGroup.lastChild:t.rowHeaderGroup.lastChild?._prev;e&&(t.bodyGroup.firstChild?t.bodyGroup.insertBefore(e,t.bodyGroup.firstChild):t.bodyGroup.appendChild(e),t.bodyGroup.setAttribute("width",t.bodyGroup.attribute.width+e.attribute.width),t.rowHeaderGroup.setAttribute("width",t.rowHeaderGroup.attribute.width-e.attribute.width))}function nj(t){const e=t.cornerHeaderGroup.lastChild instanceof BH?t.cornerHeaderGroup.lastChild:t.cornerHeaderGroup.lastChild?._prev;e&&(t.colHeaderGroup.firstChild?t.colHeaderGroup.insertBefore(e,t.colHeaderGroup.firstChild):t.bodyGroup.appendChild(e),t.colHeaderGroup.setAttribute("width",t.colHeaderGroup.attribute.width+e.attribute.width),t.cornerHeaderGroup.setAttribute("width",t.cornerHeaderGroup.attribute.width-e.attribute.width))}function rj(t){const{bgColor:e,borderColor:i,borderLineWidth:n,borderLineDash:r}=t,o={x:0,y:0,width:0,height:0,visible:!1,pickable:!0,fill:e};o.stroke=WW(i,void 0),o.lineWidth=n,r&&(o.lineDash=r),o.lineCap="square",Array.isArray(i)&&(o.strokeArrayColor=cF(i)),Array.isArray(n)&&(o.strokeArrayWidth=cF(n),o.lineWidth=1);const s=new BH(o);return s.role="corner-frozen",s}Ob.load(az);class oj{proxy;tableGroup;colHeaderGroup;cornerHeaderGroup;rowHeaderGroup;bodyGroup;rightFrozenGroup;bottomFrozenGroup;rightTopCellGroup;leftBottomCellGroup;rightBottomCellGroup;componentGroup;selectedRangeComponents;selectingRangeComponents;lastSelectId;component;stage;table;isPivot;transpose;hasFrozen;frozenColCount;frozenRowCount;clear;mergeMap;constructor(t){this.table=t,this.hasFrozen=!1,this.clear=!0,this.mergeMap=new Map,this.stage=function(t){return new AH(t)}({canvas:t.canvas,width:t.canvas.width,height:t.canvas.height,disableDirtyBounds:!1,background:t.theme.underlayBackgroundColor,dpr:t.internalProps.pixelRatio}),this.stage.defaultLayer.setTheme({group:{boundsPadding:0,strokeBoundsBuffer:0,lineJoin:"round"}}),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;const t=this.table.tableNoFrameWidth,e=this.table.tableNoFrameHeight;this.tableGroup=new BH({x:0,y:0,width:t,height:e,clip:!0,pickable:!1}),this.tableGroup.role="table";const i=new BH({x:0,y:0,width:0,height:0,clip:!1,pickable:!1});i.role="col-header",this.colHeaderGroup=i;const n=new BH({x:0,y:0,width:0,height:0,clip:!1,pickable:!1});n.role="corner-header",this.cornerHeaderGroup=n;const r=new BH({x:0,y:0,width:0,height:0,clip:!1,pickable:!1});r.role="row-header",this.rowHeaderGroup=r;const o=new BH({x:0,y:0,width:t,height:0,clip:!1,pickable:!1});o.role="body",this.bodyGroup=o;const s=new BH({x:0,y:0,width:t,height:0,clip:!1,pickable:!1});s.role="right-frozen",this.rightFrozenGroup=s;const a=new BH({x:0,y:0,width:t,height:0,clip:!1,pickable:!1});a.role="bottom-frozen",this.bottomFrozenGroup=a;const l=new BH({x:0,y:0,width:0,height:0,clip:!1,pickable:!1,childrenPickable:!0});l.role="component",this.componentGroup=l,this.rightTopCellGroup=rj(this.table.theme.cornerRightTopCellStyle||this.table.theme.cornerHeaderStyle),this.leftBottomCellGroup=rj(this.table.theme.cornerLeftBottomCellStyle||this.table.theme.cornerHeaderStyle),this.rightBottomCellGroup=rj(this.table.theme.cornerRightBottomCellStyle||this.table.theme.cornerHeaderStyle),this.tableGroup.addChild(o),this.tableGroup.addChild(s),this.tableGroup.addChild(a),this.tableGroup.addChild(r),this.tableGroup.addChild(i),this.tableGroup.addChild(this.rightBottomCellGroup),this.tableGroup.addChild(this.rightTopCellGroup),this.tableGroup.addChild(this.leftBottomCellGroup),this.tableGroup.addChild(n),this.tableGroup.addChild(l)}clearCells(){this.clear=!0,this.hasFrozen=!1,this.mergeMap.clear(),this.colHeaderGroup.clear(),this.rowHeaderGroup.clear(),this.cornerHeaderGroup.clear(),this.bodyGroup.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.rightTopCellGroup.setAttributes({x:0,y:0,width:0,height:0,visible:!1}),this.leftBottomCellGroup.setAttributes({x:0,y:0,width:0,height:0,visible:!1}),this.rightTopCellGroup.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 OW(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 Gz(this.table),DW(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-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);n=this.getCell(i.start.col,i.start.row)}return n||wz}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)}getCellSize(t,e){const i=this.getCell(t,e),n=RH(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)=>{Uz(e,i,t)})),t.selectedRangeComponents.forEach(((e,i)=>{Uz(e,i,t)}))}hideHoverIcon(t,e){if(-1===t||-1===e)return;aj(this,this.getCell(t,e),"mouseenter_cell")}showHoverIcon(t,e){if(-1===t||-1===e)return;sj(this,this.getCell(t,e),"mouseenter_cell")}hideClickIcon(t,e){if(-1===t||-1===e)return;aj(this,this.getCell(t,e),"click_cell")}showClickIcon(t,e){if(-1===t||-1===e)return;sj(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,y=hS({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:y,role:o}),t.tableGroup.insertAfter(y,"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=RH(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=RH(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=RH(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=RH(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,vm.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=hS({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;let r=!1;const o=t.getColGroup(e,!0),s=o?.attribute.width;if(o?.setAttribute("width",s+i),o?.forEachChildren(((o,a)=>{if(BW(t,o,e,o.row,s,i,t.table.columnHeaderLevelCount,n)){const e=RH(t.table,o.col,o.row);if(e&&e.end.row-e.start.row)for(let i=e.start.row;i<=e.end.row;i++)RW(t,i);else RW(t,o.row);r=!0}})),r){let e=0;for(let i=0;i<t.table.colCount;i++){const n=t.getColGroup(i,!0);let r=0;n.forEachChildren((t=>{"cell"===t.role&&(t.setAttribute("y",r),r+=t.attribute.height)})),e=r}t.updateContainerHeight(0,e-t.colHeaderGroup.attribute.height)}r=!1;const a=t.getColGroup(e),l=a.attribute.width;if(a?.setAttribute("width",l+i),a?.forEachChildren(((e,o)=>{if(BW(t,e,e.col,e.row,l,i,t.table.rowHeaderLevelCount,n)){const i=RH(t.table,e.col,e.row);if(i&&i.end.row-i.start.row)for(let e=i.start.row;e<=i.end.row;e++)RW(t,e);else RW(t,e.row);r=!0}})),r){let e=0;for(let i=0;i<t.table.colCount;i++){const n=t.getColGroup(i,!1);let r=0;n.forEachChildren((t=>{"cell"===t.role&&(t.setAttribute("y",r),r+=t.attribute.height)})),e=r}t.updateContainerHeight(t.table.frozenRowCount,e-t.bodyGroup.attribute.height)}const h=t.getColGroupInBottom(e);if(h){const e=h.attribute.width;if(h?.setAttribute("width",e+i),h?.forEachChildren(((o,s)=>{if(BW(t,o,o.col,o.row,e,i,t.table.rowHeaderLevelCount,n)){const e=RH(t.table,o.col,o.row);if(e&&e.end.row-e.start.row)for(let i=e.start.row;i<=e.end.row;i++)RW(t,i);else RW(t,o.row);r=!0}})),r){let e=0;for(let i=0;i<t.table.colCount;i++){const n=t.getColGroup(i,!1);let r=0;n.forEachChildren((t=>{"cell"===t.role&&(t.setAttribute("y",r),r+=t.attribute.height)})),e=r}t.updateContainerHeight(t.table.frozenRowCount,e-t.bodyGroup.attribute.height)}}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)})),h&&t.bottomFrozenGroup.forEachChildrenSkipChild(((t,n)=>{t.col>e&&t.setAttribute("x",t.attribute.x+i)}))),t.table.setColWidth(e,a.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((r=>{"chart"===r.type&&(r.cacheCanvas=null,r.setAttribute("width",Math.ceil(i-r.attribute.cellPadding[3]-r.attribute.cellPadding[1])),r.setAttribute("height",Math.ceil(n-r.attribute.cellPadding[0]-r.attribute.cellPadding[2])),r.setAttribute("viewBox",{x1:Math.ceil(e.globalAABBBounds.x1+r.attribute.cellPadding[3]+t.table.scrollLeft),x2:Math.ceil(e.globalAABBBounds.x1+i-r.attribute.cellPadding[1]+t.table.scrollLeft),y1:Math.ceil(e.globalAABBBounds.y1+r.attribute.cellPadding[0]+t.table.scrollTop),y2:Math.ceil(e.globalAABBBounds.y1+n-r.attribute.cellPadding[2]+t.table.scrollTop)}))}))}))}(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;if(i._selectedDataItemsInChart=[],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]);i._selectedDataItemsInChart.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]);i._selectedDataItemsInChart.push(t)}if(0===i._selectedDataItemsInChart.length&&0===n)return;i.internalProps.layoutMap.updateDataStateToChartInstance(),Jz(t)}}(this,t)}updateAutoColWidth(t){const e=this.table.getColWidth(t),i=hz(t,0,this.table.rowCount-1,this.table,!0);i!==e&&this.updateColWidth(t,i-e)}recalculateColWidths(){lz(this.table,0,this.table.colCount-1,!0)}recalculateRowHeights(){gz(this.table,0,this.table.rowCount-1)}resize(){this.recalculateColWidths(),"autoHeight"===this.table.heightMode&&this.recalculateRowHeights(),this.dealWidthMode(),this.dealHeightMode(),this.dealFrozen(),this.updateTableSize(),this.updateBorderSizeAndPosition(),this.component.updateScrollBar(),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.rightBottomCellGroup.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.leftBottomCellGroup.setAttributes({visible:!0,y:this.tableGroup.attribute.height-this.bottomFrozenGroup.attribute.height,height:this.bottomFrozenGroup.attribute.height,width:this.table.getFrozenColsWidth()}),this.rightBottomCellGroup.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.rightTopCellGroup.setAttributes({visible:!0,x:this.tableGroup.attribute.width-this.rightFrozenGroup.attribute.width,width:this.rightFrozenGroup.attribute.width,height:this.table.getFrozenRowsHeight()}),this.rightBottomCellGroup.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=RH(t.table,n,e);o&&o.start.col!==n||(TW(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);for(let e=n;e<=r;e++)for(let n=0;n<t.table.colCount;n++){const r=t.getCell(n,e),o=RH(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.frozenRowCount?(this.colHeaderGroup.setDeltaHeight(e),this.cornerHeaderGroup.setDeltaHeight(e),this.rowHeaderGroup.setDeltaY(e),this.bodyGroup.setDeltaY(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)}setRowHeight(t,e){const i=this.table.getRowHeight(t);this.updateRowHeight(t,e-i)}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(),Xz(this.table),this.updateNextFrame()}dealWidthMode(){const t=this.table;if("adaptive"===t.widthMode){const e=t.tableNoFrameWidth;let i=0;for(let e=0;e<t.colCount;e++)i+=t.getColWidth(e);const n=e/i;for(let i=0;i<t.colCount;i++){let r;r=i===t.colCount-1?e-t.getColsWidth(0,t.colCount-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&&(n+=r),i+=r}if(i<e&&i-n>0){const r=(e-n)/(i-n);for(let e=t.frozenColCount;e<t.colCount;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++)tj(t),ej(t)}else if(t.table.frozenColCount<t.table.rowHeaderLevelCount)for(let e=0;e<t.table.rowHeaderLevelCount-t.table.frozenColCount;e++)ij(t),nj(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++)ij(t),nj(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++)tj(t),ej(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=RH(this.table,i,o);s?t=this.getCell(s.start.col,s.start.row):t.setAttribute("width",n);const a=cF(nW("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.getCellType(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=RH(r,t,e),s=RH(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=RH(r,t,e),s=RH(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 y=Math.min(l,d),m=Math.max(c,f),b=Math.min(h,p),v=Math.max(u,g);for(let t=y;t<=m;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=y;t<=m;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(){let t=0;this.cornerHeaderGroup.forEachChildrenSkipChild(((e,i)=>{e.setAttribute("x",t),t+=e.attribute.width}));let e=0;this.rowHeaderGroup.forEachChildrenSkipChild(((t,i)=>{t.setAttribute("x",e),e+=t.attribute.width}));let i=0;this.colHeaderGroup.forEachChildrenSkipChild(((t,e)=>{t.setAttribute("x",i),i+=t.attribute.width}));let n=0;this.bodyGroup.forEachChildrenSkipChild(((t,e)=>{t.setAttribute("x",n),n+=t.attribute.width})),this.cornerHeaderGroup.setDeltaWidth(t-this.cornerHeaderGroup.attribute.width),this.colHeaderGroup.setDeltaWidth(i-this.colHeaderGroup.attribute.width),this.rowHeaderGroup.setDeltaWidth(e-this.rowHeaderGroup.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 r=this.table.stateManeger.scroll.horizontalBarPos,o=this.table.stateManeger.scroll.verticalBarPos;this.component.updateScrollBar(),this.table.stateManeger.setScrollLeft(r),this.table.stateManeger.setScrollTop(o),this.updateNextFrame()}updateCellContentWhileResize(t,e){const i=this.table.getBodyColumnType(t,e),n=this.getCell(t,e);"image"!==i&&"video"!==i||aW(n,t,e,this.table)}createFrameBorder(){this.updateTableSize();const t=!this.isPivot;DW(this.bodyGroup,this.table.theme.bodyStyle.frameStyle,this.bodyGroup.role,t?[!0,!0,!0,!1]:void 0),DW(this.rowHeaderGroup,this.isPivot?this.table.theme.rowHeaderStyle.frameStyle:this.table.theme.bodyStyle.frameStyle,this.rowHeaderGroup.role,t?[!0,!1,!0,!0]:void 0),DW(this.colHeaderGroup,this.table.theme.headerStyle.frameStyle,this.colHeaderGroup.role,t?[!0,!0,!0,!1]:void 0),DW(this.cornerHeaderGroup,this.isPivot?this.table.theme.cornerHeaderStyle.frameStyle:this.table.theme.headerStyle.frameStyle,this.cornerHeaderGroup.role,t?[!0,!1,!0,!0]:void 0),DW(this.tableGroup,this.table.theme.frameStyle,this.tableGroup.role,void 0)}getResizeColAt(t,e,i,n=8){if(i){if(t<i.globalAABBBounds.x1+n)return{col:i.col-1,row:i.row,x:i.globalAABBBounds.x1};if(i.globalAABBBounds.x2-n<t)return{col:i.col,row:i.row,x:i.globalAABBBounds.x2}}else;return{col:-1,row:-1}}updateIcon(t,e){CW(e,t),t.name=e.name,this.updateNextFrame()}updateFrozen(){this.clear||(this.resetFrozen(),this.dealFrozen(),this.component.updateScrollBar())}updateBorderSizeAndPosition(){this.bodyGroup.border&&(this.bodyGroup.appendChild(this.bodyGroup.border),zW(this.bodyGroup),0===this.rowHeaderGroup.attribute.width?FW(this.bodyGroup,this.table.theme.bodyStyle.frameStyle,[!0,!0,!0,!0]):FW(this.bodyGroup,this.table.theme.bodyStyle.frameStyle,[!0,!0,!0,!1])),this.colHeaderGroup.border&&(this.colHeaderGroup.appendChild(this.colHeaderGroup.border),zW(this.colHeaderGroup),0===this.cornerHeaderGroup.attribute.width?FW(this.colHeaderGroup,this.table.theme.headerStyle.frameStyle,[!0,!0,!0,!0]):FW(this.colHeaderGroup,this.table.theme.headerStyle.frameStyle,[!0,!0,!0,!1])),this.rowHeaderGroup.border&&(this.rowHeaderGroup.appendChild(this.rowHeaderGroup.border),zW(this.rowHeaderGroup)),this.cornerHeaderGroup.border&&(this.cornerHeaderGroup.appendChild(this.cornerHeaderGroup.border),zW(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?setTimeout((()=>{this.clearCells(),this.createSceneGraph()}),10):this.proxy.sortCell())}getCellOverflowText(t,e){const i=this.getCell(t,e).getChildByName("text",!0);if(i){const t=Wt(i.attribute.text)?i.attribute.text.join(""):i.attribute.text;let e="";if(Ft(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 Rz(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,[l.collapse,l.expand],n)}updateRow(t,e){Vz(t,e,this.table),this.recalculateColWidths(),"autoHeight"===this.table.heightMode&&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 sj(t,e,i){e.forEachChildren((e=>{"group"===e.type?sj(t,e,i):e.attribute.visibleTime===i&&(e.attribute.visible=!0,t.updateNextFrame())}))}function aj(t,e,i){e.forEachChildren((e=>{"group"===e.type?aj(t,e,i):e.attribute.visibleTime===i&&(e.attribute.visible=!1,t.updateNextFrame())}))}function lj(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 hj(t,e,i,n,r){const o=t.table;for(let i=0;i<o.columnHeaderLevelCount;i++)lj(t,e,i);const s=t.getColGroup(e);return s?.addUpdateBoundTag(),!0}function cj(t,e,i,n,r,o){const s=t.table;for(let i=0;i<s.columnHeaderLevelCount;i++)lj(t,e,i);const a=t.getColGroup(e);return a?.addUpdateBoundTag(),!0}function uj(t,e,i,n,r){const o=t.table;for(let e=0;e<o.colCount;e++)lj(t,e,i);return!0}function dj(t,e,i,n,r,o){const s=t.table;for(let e=0;e<s.colCount;e++)lj(t,e,i);return!0}function pj(t,e,n){const{table:r}=t,{scenegraph:o}=r,{highlightScope:s,singleStyle:a,disableHeader:l,cellPos:h,cellPosContainHeader:c}=t.hover,u=h.col,d=h.row;if(s===i.none||l&&(c.col!==e||c.row!==n)){const t=c.col,i=c.row;o.hideHoverIcon(t,i),o.showHoverIcon(e,n),c.col=e,c.row=n}if((l&&r.isHeader(e,n)||s===i.none)&&(e=-1,n=-1),u===e&&d===n)return;o.deactivateChart(u,d),o.activateChart(e,n);let p=!1;const{ranges:f,highlightScope:g}=t.select;if(-1!==u&&-1!==d&&(p=function(t,e,n,r,o,s,a){let l=!1;s===i.single?l=!!function(t,e,i,n,r){return lj(t,e,i),!0}(t,e,n)||l:s===i.row?l=!!uj(t,0,n)||l:s===i.column?l=!!hj(t,e)||l:s===i.cross&&(l=!!uj(t,0,n)||l,l=!!hj(t,e)||l);return l}(o,u,d,0,0,s),l||o.hideHoverIcon(u,d)),-1===e||-1===n)return h.col=-1,h.row=-1,void(p&&t.table.scenegraph.updateNextFrame());s===i.single?p=!!function(t,e,i,n,r){return lj(t,e,i),!0}(o,e,n)||p:s===i.row?p=!!dj(o,0,n)||p:s===i.column?p=!!cj(o,e)||p:s===i.cross&&(p=!!dj(o,0,n)||p,p=!!cj(o,e)||p),s===i.none||l||o.showHoverIcon(e,n),h.col=e,h.row=n,p&&t.table.scenegraph.updateNextFrame()}function fj(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=gj(t,e,r.col,r.row,i)),!o);s++);else n=i.sortState,n&&(r=i._getHeaderCellBySortState(n)),r&&(o=gj(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.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",R)}(n,i,s),i.scenegraph.sortCell(),i.stateManeger.updateSelectPos(-1,-1),i.fireListeners(yt.SORT_CLICK,n)}function gj(t,e,i,n,r){return r._getLayoutCellId(t,e)===r._getLayoutCellId(i,n)}const yj=it(yt,{PIVOT_SORT_CLICK:"pivot_sort_click",DRILLMENU_CLICK:"drillmenu_click"}),mj=it(yt,{VCHART_EVENT_TYPE:"vchart_event_type"});function bj(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 vj(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}class wj{table;interactionState;select;hover;hoverIcon;residentHoverIcon;columnResize;columnMove;menu;sort;frozen;scroll;tablePosition;drill;sparkLine;_clearVerticalScrollBar;_clearHorizontalScrollBar;constructor(t){this.table=t,this.initState(),this.setHoverState(),this.setSelectState(),this.setFrozenState(),this.updateVerticalScrollBar=this.updateVerticalScrollBar.bind(this),this.updateHorizontalScrollBar=this.updateHorizontalScrollBar.bind(this)}initState(){this.interactionState=e.default,this.select={highlightScope:i.single,ranges:[],cellPos:{col:-1,row:-1},selecting:!1},this.hover={highlightScope:i.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 je,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:n}=this.table.options.hover??{highlightMode:"cell"};e?this.hover.highlightScope=i.none:"cross"===t?this.hover.highlightScope=i.cross:"row"===t?this.hover.highlightScope=i.row:"column"===t?this.hover.highlightScope=i.column:"cell"===t&&(this.hover.highlightScope=i.single),this.hover.singleStyle=!e,this.hover.disableHeader=n,(this.hover.highlightScope===i.none||n)&&(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?i.none:i.single,this.select.singleStyle=!t,this.select.disableHeader=e}isSelected(t,e){let i=!1;return this.select.ranges.forEach((n=>{at(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){pj(this,t,e)}updateSelectPos(t,i,n=!1,r=!1,o=!1){-1!==i&&-1!==i&&(this.select.selecting=!0),function(t,i,n,r,o,s){const{table:a,interactionState:l}=t,{scenegraph:h}=a,{highlightScope:c,disableHeader:u,cellPos:d}=t.select;if((u&&a.isHeader(i,n)||"none"===c)&&(i=-1,n=-1),d.col!==i||d.row!==n){if(-1!==i&&-1!==n&&t.select.ranges.length>0)if(l===e.grabing){const e=t.select.ranges[t.select.ranges.length-1];i>e.start.col&&i>e.end.col&&a._makeVisibleCell(i+1,n),n>e.start.row&&n>e.end.row&&a._makeVisibleCell(i,n+1),i<e.start.col&&i<e.end.col&&a._makeVisibleCell(i-1,n),n<e.start.row&&n<e.end.row&&a._makeVisibleCell(i,n-1)}else a._makeVisibleCell(i,n);if(s){t.select.ranges=[],h.deleteAllSelectBorder(),t.select.ranges.push({start:{col:0,row:0},end:{col:a.colCount-1,row:a.rowCount-1}});const e=t.select.ranges[t.select.ranges.length-1];h.updateCellSelectBorder(e.start.col,e.start.row,e.end.col,e.end.row)}else if(-1===d.col||-1===d.row||-1!==i&&-1!==n){if(l===e.default){const e=t.select.ranges[t.select.ranges.length-1];if(r&&e){if(a.isColumnHeader(i,n)){const t=Math.min(e.start.col,e.end.col,i),r=Math.max(e.start.col,e.end.col,i),o=Math.min(e.start.row,e.end.row,n),s=a.rowCount-1;e.start={col:t,row:o},e.end={col:r,row:s}}else if(a.isRowHeader(i,n)){const t=Math.min(e.start.col,e.end.col,i),r=a.colCount-1,o=Math.min(e.start.row,e.end.row,n),s=Math.max(e.start.row,e.end.row,n);e.start={col:t,row:o},e.end={col:r,row:s}}else e.end={col:i,row:n};h.deleteLastSelectedRangeComponents(),h.updateCellSelectBorder(e.start.col,e.start.row,e.end.col,e.end.row)}else{-1===d.col||-1===d.row||o||(t.select.ranges=[],h.deleteAllSelectBorder()),a.isColumnHeader(i,n)?t.select.ranges.push({start:{col:i,row:n},end:{col:i,row:a.rowCount-1}}):a.isRowHeader(i,n)?t.select.ranges.push({start:{col:i,row:n},end:{col:a.colCount-1,row:n}}):t.select.ranges.push({start:{col:i,row:n},end:{col:i,row:n}}),d.col=i,d.row=n;const e=t.select.ranges[t.select.ranges.length-1];h.updateCellSelectBorder(e.start.col,e.start.row,e.end.col,e.end.row)}}else if(l===e.grabing){-1===d.col&&(d.col=i),-1===d.row&&(d.row=n);const e=t.select.ranges[t.select.ranges.length-1];e.end={col:i,row:n},d.col=i,d.row=n,h.updateCellSelectBorder(e.start.col,e.start.row,i,n)}}else d.col=-1,d.row=-1,t.select.ranges=[],h.deleteAllSelectBorder();h.updateNextFrame()}}(this,t,i,n,r,o)}checkCellRangeInSelect(t,e){return function(t,e,i,n){for(let n=0;n<i.length;n++)if(ht(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=vj(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(yt.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){this.columnResize.resizing=!0,this.columnResize.col=t,this.columnResize.x=e,this.table.scenegraph.component.showResizeCol(t,i),this.table.stateManeger.updateSelectPos(-1,-1),this.table.scenegraph.updateNextFrame()}updateResizeCol(t,e){t=Math.ceil(t),e=Math.ceil(e);let i=t-this.columnResize.x;if(Math.abs(i)<1)return;let n=this.table.colWidthsMap.get(this.columnResize.col);"number"==typeof n||(n=this.table.getColWidth(this.columnResize.col));let r=n;r+=i;const o=this.table.getMinColWidth(this.columnResize.col),s=this.table.getMaxColWidth(this.columnResize.col);if(r<o||r>s){if(n===o||n===s)return;i=n-o>s-n?s-n:o-n}i=Math.ceil(i),this.table.scenegraph.updateColWidth(this.columnResize.col,i),"adaptive"===this.table.widthMode&&this.columnResize.col<this.table.colCount-1&&this.table.scenegraph.updateColWidth(this.columnResize.col+1,-i),this.columnResize.x=t,this.table.scenegraph.component.updateResizeCol(this.columnResize.col,e),this.columnResize.col<this.table.frozenColCount&&!this.table.isPivotTable()&&!this.table.transpose&&this.table.scenegraph.component.setFrozenColumnShadow(this.table.frozenColCount-1),this.table.scenegraph.updateNextFrame()}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.getCellType(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.getCellType(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(){bj(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(yt.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(yt.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(yt.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(yt.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,PW.contextmenu)),this.table.fireListeners(yt.SHOW_MENU,{x:i,y:n,col:t,row:e,type:"contextmenu"}))}triggerDropDownMenu(t,e,i,n){this.table.fireListeners(yt.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,PW.dropDown),this.menu.bounds=this.table.scenegraph.component.menu.bounds),this.table.fireListeners(yt.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===l.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(yt.DROPDOWN_MENU_CLEAR,null),this.table.fireListeners(yt.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(A(s)&&A(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(d(e)&&(e.menuKey||e.text)===(h||"")&&t===i)return!0;if(f(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(yj.PIVOT_SORT_CLICK,{col:t,row:e,order:i||"normal",dimensionInfo:this.table.internalProps.layoutMap.getPivotDimensionInfo(t,e),cellType:this.table.getCellType(t,e)})}const n=this.sort.col,r=this.sort.row;fj(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.dimensionTitle=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.getCellType(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=aS({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=uS({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),caption:r.getBodyColumnDefine(t,e).caption,cellRange:r.getCellRelativeRect(t,e),sparkline:{pointData:d.pointData},scaleRatio:r.canvas.getBoundingClientRect().width/r.canvas.offsetWidth};r.fireListeners(yt.MOUSEOVER_CHART_SYMBOL,i)}}(t,e,i,0,this.table),this.sparkLine.col=t,this.sparkLine.row=e}}function Cj(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}function xj(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&&(e.setScrollLeft(e.scroll.horizontalBarPos+r),e.showHorizontalScrollBar(!0)),o&&(e.setScrollTop(e.scroll.verticalBarPos+o),e.showVerticalScrollBar(!0)),t.cancelable&&(0!==n&&_j(n,e)||0!==i&&Sj(i,e))&&t.preventDefault()}function _j(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 Sj(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 Aj(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||!Tj(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;xj({deltaX:n,deltaY:r},i),e.cancelable&&(0!==r&&_j(r,i)||0!==n&&Sj(n,i))&&e.preventDefault()}),{passive:!1}),window.addEventListener("touchend",(e=>{if(t.touchEnd=!0,t.touchMove=!1,t.isTouchdown&&Tj(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),xj({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 Tj(t){return!!t.changedTouches}function Bj(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 Rj{table;isTouchdown;touchMovePoints;touchSetTimeout;touchEnd;touchMove;constructor(t){this.table=t,this.bindOuterEvent(),setTimeout((()=>{this.bindSelfEvent()}),0)}bindOuterEvent(){!function(t){const i=t.table,n=i.stateManeger;i.scenegraph.tableGroup.addEventListener("pointermove",(r=>{t.touchSetTimeout&&(clearTimeout(t.touchSetTimeout),t.touchSetTimeout=void 0);const o=Cj(r);if(n.interactionState!==e.scrolling)if(n.interactionState!==e.grabing){if(t.checkColumnResize(o)?n.updateCursor("col-resize"):n.updateCursor(),i.hasListeners(yt.MOUSELEAVE_CELL)){const t=o?.eventArgs?.target;"cell"!==t?.role||-1===i.stateManeger.hover.cellPos.col||-1===i.stateManeger.hover.cellPos.row||t.col===i.stateManeger.hover.cellPos.col&&t.row===i.stateManeger.hover.cellPos.row||i.fireListeners(yt.MOUSELEAVE_CELL,{col:i.stateManeger.hover.cellPos.col,row:i.stateManeger.hover.cellPos.row,cellRange:i.getCellRangeRelativeRect({col:i.stateManeger.hover.cellPos.col,row:i.stateManeger.hover.cellPos.row}),scaleRatio:i.canvas.getBoundingClientRect().width/i.canvas.offsetWidth,event:r.nativeEvent})}if(i.hasListeners(yt.MOUSEENTER_CELL)){const t=o?.eventArgs?.target;"cell"===t?.role&&kt(t.col)&&kt(t.row)&&(t.col!==i.stateManeger.hover.cellPos.col||t.row!==i.stateManeger.hover.cellPos.row)&&i.fireListeners(yt.MOUSEENTER_CELL,{col:t.col,row:t.row,cellRange:i.getCellRangeRelativeRect({col:t.col,row:t.row}),scaleRatio:i.canvas.getBoundingClientRect().width/i.canvas.offsetWidth,event:r.nativeEvent})}if(t.dealIconHover(o),t.dealTableHover(o),o.eventArgs&&i.hasListeners(yt.MOUSEMOVE_CELL)){let t,e;if(o.eventArgs?.target){const i=vj(o.eventArgs?.target);i&&(t=i.icon,e=i.position)}i.fireListeners(yt.MOUSEMOVE_CELL,{col:o.eventArgs.col,row:o.eventArgs.row,x:o.abstractPos.x,y:o.abstractPos.y,event:r.nativeEvent,targetIcon:t?{name:t.name,position:e,funcType:t.attribute.funcType}:void 0})}}else n.isResizeCol()?(t.dealColumnResize(o),o.eventArgs&&i.hasListeners(yt.RESIZE_COLUMN)&&i.fireListeners(yt.RESIZE_COLUMN,{col:i.stateManeger.columnResize.col,colWidth:i.getColWidth(i.stateManeger.columnResize.col)})):n.isMoveCol()?t.dealColumnMover(o):t.dealTableSelect(o)})),i.scenegraph.tableGroup.addEventListener("pointerout",(e=>{const i=Cj(e),n=i?.eventArgs?.target;"table"===n?.role&&t.dealTableHover()})),i.scenegraph.tableGroup.addEventListener("pointerover",(t=>{const e=Cj(t),n=e?.eventArgs?.target;if(i.hasListeners(yt.MOUSEOVER_CHART_SYMBOL)&&"symbol"===n.type){const e=t.composedPath().find((t=>"cell"===t.roll));if(e){const{col:n,row:r}=e,o={col:n,row:r,field:i.getHeaderField(n,r),value:i.getCellValue(n,r),dataValue:i.getCellOriginValue(n,r),cellHeaderPaths:i.internalProps.layoutMap.getCellHeaderPaths(n,r),caption:i.getBodyColumnDefine(n,r).caption,cellRange:i.getCellRelativeRect(n,r),event:t.nativeEvent,sparkline:{pointData:void 0},scaleRatio:i.canvas.getBoundingClientRect().width/i.canvas.offsetWidth};i.fireListeners(yt.MOUSEOVER_CHART_SYMBOL,o)}}})),i.scenegraph.tableGroup.addEventListener("pointerleave",(r=>{n.updateInteractionState(e.default),t.dealTableHover(),n.updateCursor();const o=r.target;o&&!o.isDescendantsOf(i.scenegraph.tableGroup)&&i.fireListeners(yt.MOUSELEAVE_TABLE,{col:-1,row:-1,event:r.nativeEvent})})),i.scenegraph.tableGroup.addEventListener("pointerupoutside",(i=>{console.log("pointerupoutside"),n.updateInteractionState(e.default),t.dealTableHover(),t.dealTableSelect()})),i.scenegraph.tableGroup.addEventListener("pointerdown",(r=>{if(0!==r.button)return;const o=Cj(r);if(n.interactionState===e.default){if(i.isPivotChart()&&"chart"!==o?.eventArgs?.target.type&&i.scenegraph.updateChartState(null),n.menu.isShow&&o.eventArgs&&o.eventArgs.target!==n.residentHoverIcon?.icon&&n.hideMenu(),!(o?.eventArgs?.target?.role?.startsWith("icon")?o.eventArgs.target:void 0))if("touch"===r.pointerType)t.touchEnd=!1,t.touchSetTimeout=setTimeout((()=>{t.isTouchdown=!1,t.touchMove=!0,(!t.touchEnd&&t.checkColumnResize(o,!0)||!t.touchEnd&&t.chechColumnMover(o)||t.dealTableSelect(o)&&!t.touchEnd)&&n.updateInteractionState(e.grabing)}),500);else{if(t.checkColumnResize(o,!0))return i.scenegraph.updateChartState(null),void n.updateInteractionState(e.grabing);if(t.chechColumnMover(o))return void n.updateInteractionState(e.grabing);t.dealTableSelect(o)&&n.updateInteractionState(e.grabing)}if(i.hasListeners(yt.MOUSEDOWN_CELL)){const t=Cj(r);t.eventArgs&&i.fireListeners(yt.MOUSEDOWN_CELL,{col:t.eventArgs.col,row:t.eventArgs.row,event:r.nativeEvent})}}})),i.scenegraph.tableGroup.addEventListener("pointerup",(t=>{if(0===t.button){if("grabing"===n.interactionState){if(n.updateInteractionState(e.default),n.isResizeCol()){if(i.stateManeger.endResizeCol(),i.hasListeners(yt.RESIZE_COLUMN_END)){const t=[];for(let e=0;e<i.colCount;e++)t.push(i.getColWidth(e));i.fireListeners(yt.RESIZE_COLUMN_END,{col:i.stateManeger.columnResize.col,columns:t})}}else if(n.isMoveCol()){i.stateManeger.endMoveCol();const e=Cj(t);e.eventArgs&&i.hasListeners(yt.CHANGE_HEADER_POSITION)&&i.fireListeners(yt.CHANGE_HEADER_POSITION,{target:{col:e.eventArgs.col,row:e.eventArgs.row},source:{col:i.stateManeger.columnMove.colSource,row:i.stateManeger.columnMove.colSource}})}else if(n.isSelecting()){i.stateManeger.endSelectCells();const e=Cj(t);if(e.eventArgs&&i.hasListeners(yt.DRAG_SELECT_END)){const n={event:t.nativeEvent,cells:[],col:e.eventArgs.target.col,row:e.eventArgs.target.row,scaleRatio:i.canvas.getBoundingClientRect().width/i.canvas.offsetWidth};n.cells=i.getSelectedCellInfos(),i.fireListeners(yt.DRAG_SELECT_END,n)}}}else n.interactionState===e.scrolling&&n.updateInteractionState(e.default);if(i.hasListeners(yt.MOUSEUP_CELL)){const e=Cj(t);e.eventArgs&&i.fireListeners(yt.MOUSEUP_CELL,{col:e.eventArgs.col,row:e.eventArgs.row,event:t.nativeEvent})}}})),i.scenegraph.tableGroup.addEventListener("rightdown",(t=>{const e=Cj(t);if(e.eventArgs){n.triggerContextMenu(e.eventArgs.col,e.eventArgs.row,e.abstractPos.x,e.abstractPos.y);const{col:r,row:o}=e.eventArgs;if(i.hasListeners(yt.CONTEXTMENU_CELL)){const n=i.getCellInfo(r,o);let s,a;if(e.eventArgs?.target){const t=vj(e.eventArgs?.target);t&&(s=t.icon,a=t.position)}const l={...n,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}(i.stateManeger.select.ranges,r,o)?l.cells=[[n]]:l.cells=i.getSelectedCellInfos(),i.fireListeners(yt.CONTEXTMENU_CELL,l)}}})),i.scenegraph.tableGroup.addEventListener("click",(e=>{if(console.log("click",e.clone()),i.stateManeger.columnResize.resizing||i.stateManeger.columnMove.moving)return;const n=Cj(e);if(t.dealIconClick(e,n),!n?.eventArgs)return;const{col:r,row:o}=n.eventArgs;if(i.hasListeners(yt.CLICK_CELL)){const t=i.getCellInfo(r,o);let s,a;if(n.eventArgs?.target){const t=vj(n.eventArgs?.target);t&&(s=t.icon,a=t.position)}const l={...t,event:e.nativeEvent,cells:[],targetIcon:s?{name:s.name,position:a,funcType:s.attribute.funcType}:void 0};i.fireListeners(yt.CLICK_CELL,l)}})),i.scenegraph.stage.addEventListener("click",(r=>{console.log("stage click");const o=r.target;o&&!o.isDescendantsOf(i.scenegraph.tableGroup)&&o!==i.scenegraph.tableGroup&&(console.log("pointerup outside table"),n.updateInteractionState(e.default),t.dealTableHover(),t.dealTableSelect(),n.updateCursor(),i.scenegraph.updateChartState(null))})),i.scenegraph.tableGroup.addEventListener("dblclick",(t=>{const e=Cj(t),n=e.eventArgs.targetCell.globalAABBBounds,{col:r,row:o}=e.eventArgs,s=i.getCellValue(r,o);if(i.internalProps.focusControl.setFocusRect(new xi(n.x1+i.scrollLeft,n.y1+i.scrollTop,n.x2-n.x1,n.y2-n.y1),s),i.hasListeners(yt.DBLCLICK_CELL)){const n=i.getCellInfo(r,o);let s,a;if(e.eventArgs?.target){const t=vj(e.eventArgs?.target);t&&(s=t.icon,a=t.position)}const l={...n,event:t.nativeEvent,cells:[],targetIcon:s?{name:s.name,position:a,funcType:s.attribute.funcType}:void 0};i.fireListeners(yt.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=>{xj(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(yt.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(yt.KEYDOWN,t)}})),n.on(e.getElement(),"copy",(t=>{if(e.keyboardOptions?.copySelected){const i=e.getCopyValue();kt(i)&&(t.preventDefault(),ct?window.clipboardData.setData("Text",i):t.clipboardData.setData("text/plain",i))}})),n.on(e.getElement(),"contextmenu",(t=>{t.preventDefault()})),n.on(e.getParentElement(),"resize",(()=>{e.resize()}))}(this),function(t){const i=t.table,n=i.stateManeger,r=i.scenegraph;r.component.vScrollBar.addEventListener("pointerover",(t=>{n.showVerticalScrollBar()})),r.component.hScrollBar.addEventListener("pointerover",(t=>{n.showHorizontalScrollBar()})),r.component.vScrollBar.addEventListener("pointerout",(t=>{n.interactionState!==e.scrolling&&n.hideVerticalScrollBar()})),r.component.hScrollBar.addEventListener("pointerout",(t=>{n.interactionState!==e.scrolling&&n.hideHorizontalScrollBar()})),r.component.vScrollBar._slider.addEventListener("pointerdown",(()=>{n.interactionState!==e.scrolling&&n.updateInteractionState(e.scrolling)})),r.component.vScrollBar.addEventListener("pointerup",(()=>{n.interactionState===e.scrolling&&n.updateInteractionState(e.default)})),r.component.vScrollBar.addEventListener("pointerupoutside",(()=>{n.interactionState===e.scrolling&&n.updateInteractionState(e.default)})),r.component.hScrollBar._slider.addEventListener("pointerdown",(()=>{n.interactionState!==e.scrolling&&n.updateInteractionState(e.scrolling)})),r.component.hScrollBar.addEventListener("pointerup",(()=>{n.interactionState===e.scrolling&&n.updateInteractionState(e.default)})),r.component.hScrollBar.addEventListener("pointerupoutside",(()=>{n.interactionState===e.scrolling&&n.updateInteractionState(e.default)}));const o=x(n.updateVerticalScrollBar,20),s=x(n.updateHorizontalScrollBar,20);r.component.vScrollBar.addEventListener("scroll",(t=>{const e=t.detail.value[0]/(1-t.detail.value[1]+t.detail.value[0]);o(e,t)})),r.component.hScrollBar.addEventListener("scroll",(t=>{const e=t.detail.value[0]/(1-t.detail.value[1]+t.detail.value[0]);s(e)}))}(this),Aj(this)}bindSelfEvent(){const t=this.table.stateManeger;var e;this.table.listen(yt.ICON_CLICK,(e=>{const{col:i,row:n,x:r,y:o,funcType:s,icon:a}=e;var h;s===l.dropDown?t.triggerDropDownMenu(i,n,r,o):s===l.sort?t.triggerSort(i,n,a):s===l.frozen?t.triggerFreeze(i,n,a):s===l.drillDown?(h=this.table).fireListeners(yj.DRILLMENU_CLICK,h.stateManeger.drill):s!==l.collapse&&s!==l.expand||this.table.toggleHierarchyState(i,n)})),this.table.listen(yt.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.listen(yt.SCROLL,(t=>{Xz(this.table)})),e=this.table,"browser"===vt.mode&&e.listen(yt.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.columnType){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(!Pi.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.listen(yt.DBLCLICK_CELL,(t=>{this.table._canResizeColumn(t.col,t.row)&&this.table.scenegraph.updateAutoColWidth(t.col)})),this.table.isPivotTable()&&function(t){t.listen(yt.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.dimensionTitle,r.drillDown,r.drillUp,i,n):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.columnType)):t.internalProps.layoutMap.columnObjects.some((t=>"sparkline"===t.columnType));e&&(t.listen(yt.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.listen(yt.MOUSELEAVE_TABLE,(e=>{t.stateManeger.updateSparklineHoverPose(-1,-1,0,0)})))}(this.table),function(t){t.isPivotChart()&&t.scenegraph.tableGroup.addEventListener("click",(e=>{if("axis-label"===e.target.name){const i=Cj(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(),Jz(t.scenegraph),t.scenegraph.updateNextFrame()}else t._selectedDimensionInChart&&(t._selectedDimensionInChart.length=0,t.internalProps.layoutMap.updateDataStateToChartInstance(),Jz(t.scenegraph),t.scenegraph.updateNextFrame())}))}(this.table),function(t){t.isPivotChart()&&(t.listen(yt.MOUSEENTER_CELL,(e=>{t.scenegraph.getCell(e.col,e.row).forEachChildren((i=>{if("axis"===i.name){const i=Bj(e.col,e.row,t.internalProps.layoutMap);e.axisPosition=i,t.fireListeners(yt.MOUSEENTER_AXIS,e)}}))})),t.listen(yt.MOUSELEAVE_CELL,(e=>{t.scenegraph.getCell(e.col,e.row).forEachChildren((i=>{if("axis"===i.name){const i=Bj(e.col,e.row,t.internalProps.layoutMap);e.axisPosition=i,t.fireListeners(yt.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),!0}return!1}dealColumnResize(t){this.table.stateManeger.updateResizeCol(t.abstractPos.x,t.abstractPos.y)}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(at(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(yt.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 b_){const t=n.pickIcon(r.global);if(t)return this.table.fireListeners(yt.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}}let Mj;const Pj=t=>{const e=t.value;return Number(e)>80?"#20a8d8":Number(e)>50?"#4dbd74":Number(e)>20?"#ffc107":"#f86c6b"};class Ej extends O{_showBar;_barColor;_barBgColor;_barPositiveColor;_barNegativeColor;_barAxisColor;_barHeight;_barBottom;_barPadding;_showBarMark;_barMarkPositiveColor;_barMarkNegativeColor;_barMarkWidth;_barMarkPosition;_barRightToLeft;static get DEFAULT(){return Mj||(Mj=new Ej)}constructor(t={},e={}){super(t,e),this._showBar=t.showBar??!0,this._barColor=t.barColor??Pj,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 Ej(this,null)}}const Hj=["type","content","font","color","width","height","marginRight","marginLeft","src","svg","name","path","positionType","tooltip","hover","cursor","shape","interactive"];class Lj{expandIcon;collapseIcon;_table;constructor(t){this._table=t;const e=tW();this.expandIcon=e[h.expandIconName],this.collapseIcon=e[h.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=tW(),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 F;case"image":case"video":return D;case"chart":case"sparkline":return O;case"progressbar":return Ej}}getCellIconFromRecordValue(t,e,i){if(Array.isArray(t))return t.map((t=>this.getCellIconFromRecordValue(t,e,i)));if(!ut.isObject(t)||"function"==typeof t)return this._table.getFieldData(t,e,i);const n={},r=t;return Hj.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===r.expand?this.expandIcon:i===r.collapse?this.collapseIcon:void 0}}function kj(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 Ij="vtable__menu-element",Oj=`${Ij}__item`,Dj=`${Ij}__content`,Fj=`${Ij}--hidden`,Wj=`${Ij}--shown`,zj=`${Ij}--normal`,jj=`${Ij}--select`,Nj=`${Ij}__icon`,Gj=`${Ij}__split`,Kj=`${Ij}__title`,Uj=`${Ij}__arrow`,Vj=`${Ij}__no-event`,$j=`${Ij}__item-text`;function Yj(){return kj("div",[Ij,Fj])}function Xj(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(A(o)&&A(a)&&at(s,o,a)&&i===h)return!0}return!1}class qj{_handler;_rootElement;_secondElement;_menuInstanceInfo;_showChildrenIndex;_mouseEnterSecondElement;constructor(t){this._handler=new xt,this._rootElement=Yj(),this._secondElement=Yj(),this._secondElement.sub=!0,this._showChildrenIndex=-1,this._rootElement?.addEventListener("mousedown",(t=>{t.stopPropagation(),t.preventDefault()})),this._rootElement?.addEventListener("touchend",(e=>{if(e.stopPropagation(),e.preventDefault(),this._rootElement.classList.contains(Fj))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(yt.DROPDOWNMENU_CLICK,{col:i,row:n,field:l,menuKey:o,text:s,highlight:h,cellType:t.getCellType(i,n)}),t.fireListeners(yt.DROPDOWN_MENU_CLEAR,null),t.fireListeners(yt.HIDE_MENU,null),e.stopPropagation()})),this._rootElement?.addEventListener("click",(e=>{if(e.stopPropagation(),e.preventDefault(),this._rootElement.classList.contains(Fj))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(yt.DROPDOWNMENU_CLICK,{col:i,row:n,field:l,menuKey:o,text:s,highlight:h,cellType:t.getCellType(i,n)}),t.fireListeners(yt.DROPDOWN_MENU_CLEAR,null),t.fireListeners(yt.HIDE_MENU,null),e.stopPropagation()})),this._rootElement?.addEventListener("mousemove",(e=>{if(this._rootElement.classList.contains(Fj))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(Fj),i?.classList.add(Wj),i.innerHTML="";const s=this._menuInstanceInfo.content[n]?.children;for(let e=0;e<s.length;e++){const n=s[e],a=Zj(n,!!t.stateManeger.menu.dropDownMenuHighlight&&Xj(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(Fj),t?.classList.add(Wj)}else!s&&this._secondElement?.classList.contains(Wj)&&setTimeout((()=>{if(!0!==this._mouseEnterSecondElement){this._showChildrenIndex=-1;const t=this._secondElement;t?.classList.remove(Wj),t?.classList.add(Fj)}}),300)})),this._secondElement?.addEventListener("mousemove",(t=>{this._rootElement.classList.contains(Fj)||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(Fj))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(Xj(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(yt.DROPDOWNMENU_CLICK,{col:i,row:n,field:l,cellHeaderPaths:t.isPivotTable()?t.getCellHeaderPaths(i,n):void 0,menuKey:o,text:s,highlight:h,cellType:t.getCellType(i,n)}),t.fireListeners(yt.DROPDOWN_MENU_CLEAR,null),t.fireListeners(yt.HIDE_MENU,null),e.stopPropagation()}))}get rootElement(){return this._rootElement}dispose(){this.unbindFromCell();const t=this._rootElement;t?.parentElement&&t.parentElement.removeChild(t),this._handler.dispose(),delete this._rootElement}bindToCell(t,e,i,n){const r=this._rootElement,o=this._secondElement;if(this._menuInstanceInfo=n,r?.classList.remove(Wj),r?.classList.add(Fj),o?.classList.remove(Wj),o?.classList.add(Fj),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&&Xj(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(Xj(t,t.stateManeger.menu.dropDownMenuHighlight,"object"==typeof r?r?.menuKey||r?.text:r,e,i)){a=!0;break}}const l=Zj(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(Wj),r?.classList.remove(Fj),!0}else this.unbindFromCell();return!1}unbindFromCell(){const t=this._rootElement,e=this._secondElement;this._menuInstanceInfo=void 0,t?.parentElement&&(t.classList.remove(Wj),t.classList.add(Fj)),e?.parentElement&&(e.classList.remove(Wj),e.classList.add(Fj))}_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 Zj(t,e){const i=kj("div",[Oj,e?jj:zj]);if("string"==typeof t){const e=kj("span",[Dj,Vj,$j]);e.innerHTML=t,i.appendChild(e)}else if("object"==typeof t){const n=t.type??"item";if("split"===n)return i?.classList.add(Gj),i;if(t?.icon?.svg)if(Pi.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=kj("span",[Nj,Vj]);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=kj("span",[Dj,Vj,$j]);if(r.innerHTML=t.text,i.appendChild(r),"title"===n)i?.classList.add(Vj,Kj);else if(t?.children?.length){const t=kj("span",[Dj,Vj,Uj]);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 Jj;class Qj extends j{static get DEFAULT(){return Jj||(Jj=new Qj)}constructor(t={},e={}){super(t,e),this.textAlign=(t.textAlign??e?.textAlign)||"center"}clone(){return new Qj(this)}}class tN{normalIcon;upIcon;downIcon;freezeIcon;frozenIcon;frozenCurrentIcon;dropDownAbsoluteIcon;expandIcon;collapseIcon;_table;constructor(t){this._table=t;const e=tW();this.freezeIcon=e[h.freezeIconName],this.frozenIcon=e[h.frozenIconName],this.frozenCurrentIcon=e[h.frozenCurrentIconName],this.normalIcon=e[h.normalIconName],this.upIcon=e[h.upwardIconName],this.downIcon=e[h.downwardIconName],this.dropDownAbsoluteIcon=e[h.dropdownIconName],this.expandIcon=e[h.expandIconName],this.collapseIcon=e[h.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&&at(o,i.col,i.row)){({order:r}=e);break}}else{const t=this._table._getHeaderCellBySortState(n);t&&at(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{captionIcon:r,headerIcon:o}=this._table._getHeaderLayoutMap(t,e);r&&i.push(r);const s=this.getHierarchyIcon(t,e);if(s&&i.push(s),o){let n;if("function"==typeof o){n=o({col:t,row:e,value:this._table.getCellValue(t,e),dataValue:this._table.getCellOriginValue(t,e),table:this._table})}else n=o;const r=tW(),s=t=>{let e;e="string"==typeof t?r[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,h=-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 a=s.children[n];if(t.stateManeger.menu?.dropDownMenuHighlight&&Xj(t,t.stateManeger.menu?.dropDownMenuHighlight,"object"==typeof a?a?.menuKey:a,e,i)){r=o,h=n;break}}if(t._dropDownMenuIsHighlight(e,i,o)){r=o;break}}if(-1!==r){let e;e=-1!==h?(o||t.globalDropDownMenu)[r].children[h]:(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:a.right,marginRight:0,funcType:l.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:a.right,marginRight:0,funcType:l.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===r.expand)return this.expandIcon;if(i===r.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 G;case"image":case"video":return Qj}}}class eN{_table;_tooltipElement;constructor(t){this._table=t}dispose(){this.unbindTooltipElement(),this._tooltipElement&&this._tooltipElement.dispose?.(),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 iN="vtable__bubble-tooltip-element",nN=`${iN}__content`,rN=`${iN}__triangle`,oN=`${iN}--hidden`,sN=`${iN}--shown`;class aN{_handler;_rootElement;_messageElement;_triangleElement;constructor(){this._handler=new xt;const t=this._rootElement=kj("div",[iN,oN]),e=kj("span",[nN]),i=kj("span",[rN]);t.appendChild(i),t.appendChild(e),this._messageElement=t.querySelector(`.${nN}`)||void 0,this._triangleElement=t.querySelector(`.${rN}`)||void 0}bindToCell(t,e,i,n,r){const o=this._rootElement,s=this._messageElement,a=this._triangleElement;if(o?.classList.remove(sN),o?.classList.add(oN),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(sN),o?.classList.remove(oN),!0}else this.unbindFromCell();return!1}dispose(){this.unbindFromCell();const t=this._rootElement;t?.parentElement&&t.parentElement.removeChild(t),this._handler?.dispose?.(),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(sN),o?.classList.remove(oN)):this.unbindFromCell()}unbindFromCell(){const t=this._rootElement;t?.parentElement&&(t.classList.remove(sN),t.classList.add(oN))}_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`,B()&&(a.style.fontSize="11px");const{x1:y,x2:m,y1:b,y2:v}=t.stateManeger.menu.bounds,w=d,C=w+f,x=l,_=w+g;return!(t.stateManeger.menu.isShow&&y<C&&m>w&&v>x&&b<_)}return!1}getComputedPosition(t,e,i,r,o,s,a){const l=this._rootElement,h=t.getCellRangeRelativeRect({col:e,row:i}),{width:c,height:u}=t.internalProps.element.getBoundingClientRect(),{width:d}=h;let p,f;const g=Math.min(.8*c,4*d);l.style.maxWidth=`${g}px`;const y=l.clientWidth,m=l.clientHeight,b=a?6:0;if(r)f=r.x,p=r.y+b,this._triangleElement.style.left="50%",this._triangleElement.style.marginLeft="-5px",this._triangleElement.style.top="-5px";else if(o){let e=o.placement??n.bottom;const i=o.rect.left+o.rect.width/2+t.tableX,r=o.rect.top+o.rect.height/2+t.tableY,a=o.rect.top+t.tableY,l=o.rect.bottom+t.tableY,h=o.rect.left+t.tableX,d=o.rect.right+t.tableX;let g=0;const v=()=>{g++,g>=4||(this.removeStyleFromTriangle(),e===n.top?(f=i-y/2,p=a-m-b,this._triangleElement.style.left="50%",this._triangleElement.style.marginLeft="-5px",this._triangleElement.style.bottom="-5px",s&&p<0&&(e=n.right,v())):e===n.bottom?(f=i-y/2,p=l+b,this._triangleElement.style.left="50%",this._triangleElement.style.marginLeft="-5px",this._triangleElement.style.top="-5px",s&&p+m>u&&(e=n.left,v())):e===n.left?(p=r-m/2,f=h-y-b,this._triangleElement.style.top="50%",this._triangleElement.style.marginTop="-5px",this._triangleElement.style.right="-5px",s&&f<0&&(e=n.top,v())):e===n.right&&(p=r-m/2,f=d+b,this._triangleElement.style.top="50%",this._triangleElement.style.marginTop="-5px",this._triangleElement.style.left="-5px",s&&f+y>c&&(e=n.bottom,v())))};v()}return s&&(f<0?f=0:f+l.offsetWidth>c&&(f=c-l.offsetWidth)),{x:f,y:p}}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 lN extends eN{createTooltipElementInternal(){return new aN}}const hN={"bubble-tooltip":function(t){return new lN(t)}};class cN{_table;_tooltipInstances;_attachInfo;confine;constructor(t,e){this._table=t,this._tooltipInstances={},this._bindTableEvent(t),this.confine=e}dispose(){const t=this._tooltipInstances;for(const e in t)t[e]?.dispose?.();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||!at(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||!at(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&&at(i.range,t,e)}_bindTableEvent(t){t.listen(yt.MOUSEENTER_CELL,(e=>{if(B())return;const{x1:i,x2:r,y1:o,y2:s}=t.stateManeger.menu.bounds;if(t.stateManeger.menu.isShow&&"number"==typeof e.x&&"number"==typeof e.y&&e.x>i&&e.x<r&&e.y>o&&e.y<s)return;const{col:a,row:l}=e;if((!e.related||!this._isBindCell(a,l))&&t.internalProps.tooltip?.isShowOverflowTextTooltip){const i=t.getCellOverflowText(a,l),r=t.getHeaderDescription(a,l),o=t.getCellRangeRelativeRect({col:a,row:l});let s;i&&(s={content:r?`${r}\n ${i}`:i,referencePosition:{placement:n.bottom,rect:o},style:{arrowMark:!1}}),r&&(s={content:r,referencePosition:{placement:n.bottom,rect:o},style:{arrowMark:!1}}),s&&this._bindToCell(e.col,e.row,s)}})),t.listen(yt.MOUSEMOVE_CELL,(e=>{if(!B()){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&&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.listen(yt.MOUSELEAVE_CELL,(t=>{t.related&&this._isBindCell(t.related.col,t.related.row)||this._unbindFromCell()})),t.listen(yt.SELECTED_CELL,(t=>{this._isBindCell(t.col,t.row)&&this._unbindFromCell()})),t.listen(yt.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]=hN[r](i))}isBinded(t){return JSON.stringify(t)===JSON.stringify(this._attachInfo?.tooltipOptions)}}class uN{_table;_menuElement;constructor(t){this._table=t}dispose(){this.unbindMenuElement(),this._menuElement&&this._menuElement.dispose(),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 dN="vtable__menu-element",pN=`${dN}--hidden`,fN=`${dN}--shown`;class gN{_handler;_rootElement;_menuInstanceInfo;constructor(t){this._handler=new xt,this._rootElement=kj("div",[dN,pN]),this._rootElement?.addEventListener("mousedown",(t=>{t.stopPropagation(),t.preventDefault()})),this._rootElement?.addEventListener("click",(e=>{if(e.stopPropagation(),e.preventDefault(),this._rootElement.classList.contains(pN))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(yt.DROPDOWNMENU_CLICK,{col:i,row:n,field:l,menuKey:o,text:s,highlight:h,cellType:t.getCellType(i,n)}),t.fireListeners(yt.DROPDOWN_MENU_CLEAR,null),t.fireListeners(yt.HIDE_MENU,null),e.stopPropagation()})),this._rootElement?.addEventListener("mousemove",(t=>{this._rootElement.classList.contains(pN)||t.stopPropagation()}))}get rootElement(){return this._rootElement}dispose(){this.unbindFromCell();const t=this._rootElement;t?.parentElement&&t.parentElement.removeChild(t),this._handler.dispose(),delete this._rootElement}bindToCell(t,e,i,n){const r=this._rootElement;if(this._menuInstanceInfo=n,r?.classList.remove(fN),r?.classList.add(pN),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(fN),r?.classList.remove(pN),!0}else this.unbindFromCell();return!1}unbindFromCell(){const t=this._rootElement;this._menuInstanceInfo=void 0,t?.parentElement&&(t.classList.remove(fN),t.classList.add(pN))}_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 yN extends uN{createMenuElementInternal(){return new qj(this._table)}}let mN=class extends uN{createMenuElementInternal(){return new gN(this._table)}};const bN={"dropdown-menu":function(t){return new yN(t)},"context-menu":function(t){return new yN(t)},container:t=>new mN(t)};class vN{_table;_menuInstances;_attachInfo;constructor(t){this._table=t,this._menuInstances={},this._bindTableEvent(t)}dispose(){const t=this._menuInstances;for(const e in t)t[e].dispose();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&&at(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.listen(yt.DROPDOWN_ICON_CLICK,(t=>{this._attachInfo&&this._isBindToCell(t.col,t.row)?this._unbindFromCell():this._bindToCell(t.col,t.row,"dropdown-menu")})),t.listen(yt.DROPDOWN_MENU_CLEAR,(t=>{this._unbindFromCell()})),t.listen(yt.CONTEXTMENU_CELL,(e=>{if("html"===t.internalProps.menu?.renderMode){const i=t._getMouseAbstractPoint(e.event,!1);let n=null;i&&"function"==typeof t.internalProps.menu?.contextMenuItems?n=t.internalProps.menu.contextMenuItems(t.getHeaderField(e.col,e.row),e.row):i&&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]=bN[i](r)),type:i,info:s}}}class wN extends EventTarget{_table;_input;constructor(t,e){if(super(),this._table=t,"node"===vt.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}dispose(){}}let CN=1;V?CN=1:(CN=Math.ceil(window.devicePixelRatio||1),CN>1&&CN%2!=0&&(CN+=1));const xN={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:!1,visible:!0};function _N(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:y,padding:m,...b}=ne({},xN,t),v=b;return i.visible&&(v.title=function(t){const e={...t};return Yt(t.style)||(e.textStyle=zL(t.style)),Yt(t.textStyle)||ne(e.textStyle,zL(t.textStyle)),t.shape?.style&&zL(e.shape.style),t.background?.style&&zL(e.background.style),e}(i)),Yt(n.focusIconStyle)||zL(n.focusIconStyle),jL(n.shape),jL(n.label),jL(n.value),jL(n.background),GF(n.maxWidth)&&(n.maxWidth=Number(n.maxWidth.substring(0,n.maxWidth.length-1))*e.width/100),GF(n.width)&&(n.width=Number(n.width.substring(0,n.width.length-1))*e.width/100),GF(n.height)&&(n.height=Number(n.height.substring(0,n.height.length-1))*e.width/100),v.item=n,Yt(r.textStyle)||zL(r.textStyle),jL(r.handler),v.pager=r,o.visible&&!Yt(o.style)&&(ne(v,o.style),kt(o.padding)&&(v.padding=o.padding)),v}class SN{table;option;orient;visible;position;selectedData;legendComponent;constructor(t,e){this.table=e,this.option=Qt(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 mL(ne({},t,{defaultSelected:this.selectedData}));e.name="legend",this.legendComponent=e,this.table.scenegraph.stage.defaultLayer.appendChild(e);let i=isFinite(this.legendComponent.AABBBounds.width())?this.legendComponent.AABBBounds.width():0,n=isFinite(this.legendComponent.AABBBounds.height())?this.legendComponent.AABBBounds.height():0;const r=this.table.tableNoFrameWidth,o=this.table.tableNoFrameHeight,s=cF(t.padding??this.option.padding??10);let a=0,l=0;"left"===this.orient?(a=s[3],l=0,i+=s[1]+s[3]):"top"===this.orient?(a=0,l=s[0],n+=s[0]+s[2]):"right"===this.orient?(a=r-i-s[1],l=0,i+=s[1]+s[3]):"bottom"===this.orient&&(a=0,l=o-n-s[2],n+=s[0]+s[2]);const h="bottom"===this.orient||"top"===this.orient?"horizontal":"vertical",c=this.position;let u=0,d=0;"horizontal"===h?u="middle"===c?(r-i)/2:"end"===c?r-i-s[1]:s[3]:d="middle"===c?(o-n)/2:"end"===c?o-n-s[2]:s[0],this.legendComponent.setAttributes({dx:u,dy:d,x:a,y:l}),"left"===this.orient?(this.table.tableNoFrameWidth=this.table.tableNoFrameWidth-Math.ceil(i),this.table.tableX=Math.ceil(i)):"top"===this.orient?(this.table.tableNoFrameHeight=this.table.tableNoFrameHeight-Math.ceil(n),this.table.tableY=Math.ceil(n)):"right"===this.orient?this.table.tableNoFrameWidth=this.table.tableNoFrameWidth-Math.ceil(i):"bottom"===this.orient&&(this.table.tableNoFrameHeight=this.table.tableNoFrameHeight-Math.ceil(n))}getLegendAttributes(t){return{layout:"bottom"===this.orient||"top"===this.orient?"horizontal":"vertical",items:this.getLegendItems(),maxWidth:t.width,maxHeight:t.height,..._N(this.option,t)}}getLegendItems(){return this.option.data}initEvent(){this.legendComponent&&(this.legendComponent.addEventListener(dL.legendItemClick,(t=>{const e=Xt(t,"detail.currentSelected");this.table.scenegraph.updateNextFrame(),this.table.fireListeners(yt.LEGEND_ITEM_CLICK,{model:this,value:e,event:t})})),this.legendComponent.addEventListener(dL.legendItemHover,(t=>{const e=Xt(t,"detail");this.table.scenegraph.updateNextFrame(),this.table.fireListeners(yt.LEGEND_ITEM_HOVER,{model:this,value:e,event:t})})),this.legendComponent.addEventListener(dL.legendItemUnHover,(t=>{const e=Xt(t,"detail");this.table.scenegraph.updateNextFrame(),this.table.fireListeners(yt.LEGEND_ITEM_UNHOVER,{model:this,value:e,event:t})})))}getLegendBounds(){return{width:isFinite(this.legendComponent.AABBBounds.width())?this.legendComponent.AABBBounds.width():0,height:isFinite(this.legendComponent.AABBBounds.height())?this.legendComponent.AABBBounds.height():0}}dispose(){this.legendComponent=null}}class AN{table;_titleOption;_titleComponent;_cacheAttrs;constructor(t,e){this.table=e,this._titleOption=t,this._titleComponent=this._createOrUpdateTitleComponent(this._getTitleAttrs())}_createOrUpdateTitleComponent(t){if(this._titleComponent)se(t,this._cacheAttrs)||this._titleComponent.setAttributes(t);else{const e=new WL(t);e.name="title",this.table.scenegraph.stage.defaultLayer.appendChild(e),this._titleComponent=e}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,cF(t.padding??this._titleOption.padding??10));return"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}),this._titleComponent}dispose(){this._titleComponent=null}_getTitleAttrs(){const t=cF(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:TN}=ft,{isTouchEvent:BN}=pt,RN=/^\$(\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 MN={};class PN extends E{internalProps;showFrozenIcon=!0;showSort=!0;padding;globalDropDownMenu;tableNoFrameWidth;tableNoFrameHeight;tableX;tableY;_widthMode;_heightMode;_autoFillWidth;customRender;canvasWidth;canvasHeight;dataSet;scenegraph;stateManeger;eventManeger;_pixelRatio;bottomFrozenRowCount=0;rightFrozenColCount=0;static get EVENT_TYPE(){return yt}options;version="0.9.3-alpha.1";pagerConf;id=`VTable${Date.now()}`;headerStyleCache;bodyStyleCache;constructor(t={}){super();const{frozenColCount:e=0,defaultRowHeight:i=40,defaultHeaderRowHeight:n,defaultColWidth:r=80,defaultHeaderColWidth:o,widthMode:s="standard",heightMode:a="standard",autoFillWidth:l=!1,keyboardOptions:h,parentElement:c,columnResizeMode:u,dragHeaderMode:d,showFrozenIcon:p,allowFrozenColCount:f,padding:g,hover:y,menu:m,select:b,customRender:v,pixelRatio:w=CN}=t;this.options=t,this._widthMode=s,this._heightMode=a,this._autoFillWidth=l,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 C=this.internalProps={};void 0!==p&&(this.showFrozenIcon=p),"number"==typeof f&&f<=0&&(this.showFrozenIcon=!1),C.handler=new xt,C.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),C.focusControl=new wN(this,C.element),C.pixelRatio=w,C.canvas=document.createElement("canvas"),C.element.appendChild(C.canvas),C.context=C.canvas.getContext("2d"),C.frozenColCount=e,C.defaultRowHeight=i,C.defaultHeaderRowHeight=n??i,C.defaultColWidth=r,C.defaultHeaderColWidth=o??r,C.keyboardOptions=h,C.columnResizeMode=u,C.dragHeaderMode=d,C._rowHeightsMap=new St,C._rowRangeHeightsMap=new Map,C._colRangeWidthsMap=new Map,this.colWidthsMap=new St,this.colContentWidthsMap=new St,this.colWidthsLimit={},C.calcWidthContext={_:C,get full(){return this._.canvas.width/(this._.context.pixelRatio??window.devicePixelRatio)}},C.cellTextOverflows={},C.focusedTable=!1,C.theme=Ui.of(t.theme??Ui.DEFAULT),c?(c.innerHTML="",c.appendChild(C.element),this._updateSize()):this._updateSize(),this.options=t,C.theme=Ui.of(t.theme??Ui.DEFAULT),C.bodyHelper=new Lj(this),C.headerHelper=new tN(this),C.autoWrapText=t.autoWrapText,C.allowFrozenColCount=t.allowFrozenColCount??C.colCount,C.limitMaxAutoWidth=t.limitMaxAutoWidth??450,this.dataSet=new xD,this.scenegraph=new oj(this),this.stateManeger=new wj(this),this.eventManeger=new Rj(this),t.legends&&(C.legends=new SN(t.legends,this),this.scenegraph.tableGroup.setAttributes({x:this.tableX,y:this.tableY})),t.title&&(C.title=new AN(t.title,this),this.scenegraph.tableGroup.setAttributes({x:this.tableX,y:this.tableY})),C.tooltip=Object.assign({renderMode:"html",isShowOverflowTextTooltip:!1,confine:!0},t.tooltip),"html"===C.tooltip.renderMode&&(C.tooltipHandler=new cN(this,C.tooltip.confine)),C.menu=Object.assign({renderMode:"html"},t.menu),Array.isArray(t.menu?.dropDownMenuHighlight)&&this.setDropDownMenuHighlight(t.menu?.dropDownMenuHighlight),Array.isArray(t.menu?.defaultHeaderMenuItems)&&(this.globalDropDownMenu=t.menu.defaultHeaderMenuItems),"html"===C.menu.renderMode&&(C.menuHandler=new vN(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.invalidate.bind(this),200);getParentElement(){return this.options.parentElement}getElement(){return this.internalProps.element}get canvas(){return this.internalProps.canvas}resize(){this._updateSize(),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 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)}get heightMode(){return this._heightMode}set heightMode(t){t!==this._heightMode&&(this._heightMode=t)}get autoFillWidth(){return this._autoFillWidth}set autoFillWidth(t){t!==this._autoFillWidth&&(this._autoFillWidth=t)}_colWidthDefineToPxWidth(t){return XF(t)?$F(this,this._calculateAutoColWidthExpr()):$F(this,t)}_calculateAutoColWidthExpr(){const t=this.internalProps.calcWidthContext.full;let e=0;const i=[];let n=0;const r=[];for(let o=0;o<this.internalProps.colCount;o++){const s=this.getColWidthDefine(o),a=this._getColWidthLimits(o);if(XF(s))a&&(r.push(a),a.min&&(e+=a.min)),n++;else{let t=s;if(a){const i=$F(this,t),n=YF(a,i);i!==n&&(t=`${n}px`),e+=n}i.push(t)}if(e>t)return"0px"}if(r.length&&i.length){const e=(t-$F(this,`calc(${i.map((t=>"number"==typeof t?`${t}px`:t)).join(" + ")})`))/n;if(r.forEach((t=>{t.min&&e<t.min?(i.push(t.minDef),n--):t.max&&t.max<e&&(i.push(t.maxDef),n--)})),n<=0)return`${e}px`}if(i.length){const t=[];let e=0;return i.forEach((i=>{"number"==typeof i?e+=i:t.push(i)})),t.push(`${e}px`),`calc((100% - (${t.join(" + ")})) / ${n})`}return 100/n+"%"}_getColWidthLimits(t){const e=this.colWidthsLimit[t];if(!e)return null;const i={};return e.min&&(i.min=$F(this,e.min),i.minDef=e.min),e.max&&(i.max=$F(this,e.max),i.maxDef=e.max),i}_adjustColWidth(t,e){const i=this._getColWidthLimits(t);return Math.max(YF(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"===vt.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"===vt.mode&&(e=this.canvasWidth-1,i=this.canvasHeight-1);const n=Math.floor(e-U(this.getTheme().scrollStyle)),r=Math.floor(i-U(this.getTheme().scrollStyle));if(this.internalProps.theme?.frameStyle){const t=TN(this.internalProps.theme.frameStyle?.borderLineWidth??[null]),e=TN(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=this.colWidthsMap.get(e);let r;r=i?"adaptive"===this.widthMode||this.transpose?Number(i):this._adjustColWidth(e,this._colWidthDefineToPxWidth(i)):this.isRowHeader(e,0)||this.isCornerHeader(e,0)?Array.isArray(this.defaultHeaderColWidth)?this.defaultHeaderColWidth[e]??this.internalProps.defaultColWidth:this.defaultHeaderColWidth:this.internalProps.defaultColWidth;const o=n+r;return t>=0&&e>=0&&!Number.isNaN(o)&&this._colRangeWidthsMap.set(`$${t}$${e}`,Math.round(o)),Math.round(o)}let r=0;for(let i=t;i<=e;i++)r+=this.isRowHeader(i,0)||this.isCornerHeader(i,0)?Array.isArray(this.defaultHeaderColWidth)?this.defaultHeaderColWidth[i]??this.internalProps.defaultColWidth:this.defaultHeaderColWidth:this.internalProps.defaultColWidth;this.colWidthsMap.each(t,e,((t,e)=>{r+=("adaptive"===this.widthMode||this.transpose?Number(t):this._adjustColWidth(e,this._colWidthDefineToPxWidth(t)))-(this.isRowHeader(e,0)||this.isCornerHeader(e,0)?Array.isArray(this.defaultHeaderColWidth)?this.defaultHeaderColWidth[e]??this.internalProps.defaultColWidth:this.defaultHeaderColWidth:this.internalProps.defaultColWidth)}));for(let i=t;i<=e;i++){if(this.colWidthsMap.has(i))continue;const t=this._adjustColWidth(i,this.internalProps.defaultColWidth);t!==this.internalProps.defaultColWidth&&(r+=t-this.internalProps.defaultColWidth)}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)}fillRowsHeight(t,e,i){for(let n=t;n<=e;n++)this.rowHeightsMap.put(n,Math.round(i)),this._rowRangeHeightsMap.set(`$0$${n}`,Math.round((this._rowRangeHeightsMap.get("$0$"+(n-1))??0)+i))}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){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)}getColWidthDefine(t){const e=this.colWidthsMap.get(t);return"number"==typeof e&&e<=0?0:e||(this.isRowHeader(t,0)||this.isCornerHeader(t,0)?Array.isArray(this.defaultHeaderColWidth)?this.defaultHeaderColWidth[t]??this.defaultColWidth:this.defaultHeaderColWidth:this.isRightFrozenColumn(t,this.columnHeaderLevelCount)?Array.isArray(this.defaultHeaderColWidth)?this.defaultHeaderColWidth[this.rowHeaderLevelCount-this.rightFrozenColCount]??this.defaultColWidth:this.defaultHeaderColWidth:this.defaultColWidth)}getColWidth(t){const e=this.getColWidthDefine(t);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=RN.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=RN.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=$F(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=$F(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 xi(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 xi(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 xi(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 xi(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))}}invalidate(){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 xi(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)}addDisposable(t){if(!t||!t.dispose||"function"!=typeof t.dispose)throw new Error("not disposable!");(this.internalProps.disposables=this.internalProps.disposables||[]).push(t)}dispose(){const t=this.internalProps;t.tooltipHandler?.dispose?.(),t.menuHandler?.dispose?.(),JF.clearAll(),super.dispose?.(),t.handler?.dispose?.(),t.focusControl?.dispose?.(),t.disposables&&(t.disposables.forEach((t=>t?.dispose?.())),t.disposables=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:y,heightMode:m,autoFillWidth:b,customRender:v}=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=y??"standard",this.heightMode=m??"standard",this.autoFillWidth=b??!1,this.customRender=v;const w=this.internalProps;"node"!==vt.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"}(w.element,this.padding),w.frozenColCount=e,w.defaultRowHeight=i,w.defaultHeaderRowHeight=n??i,w.defaultColWidth=r,w.defaultHeaderColWidth=o??r,w.keyboardOptions=s,w.columnResizeMode=a,w.dragHeaderMode=l,w.cellTextOverflows={},w._rowHeightsMap=new St,w._rowRangeHeightsMap=new Map,w._colRangeWidthsMap=new Map,this.colWidthsMap=new St,this.colContentWidthsMap=new St,this.colWidthsLimit={},w.theme=Ui.of(t.theme??Ui.DEFAULT),w.autoWrapText=t.autoWrapText,w.allowFrozenColCount=t.allowFrozenColCount??w.colCount,w.limitMaxAutoWidth=t.limitMaxAutoWidth??450,this.dataSet=new xD,this.scenegraph.clearCells(),this.stateManeger.initState(),t.legends&&(w.legends=new SN(t.legends,this),this.scenegraph.tableGroup.setAttributes({x:this.tableX,y:this.tableY})),t.title&&(w.title=new AN(t.title,this),this.scenegraph.tableGroup.setAttributes({x:this.tableX,y:this.tableY})),w.tooltip=Object.assign({renderMode:"html",isShowOverflowTextTooltip:!1,confine:!0},t.tooltip),"html"!==w.tooltip.renderMode||w.tooltipHandler||(w.tooltipHandler=new cN(this,w.tooltip.confine)),w.menu=Object.assign({renderMode:"html"},t.menu),"html"!==w.menu.renderMode||w.menuHandler||(w.menuHandler=new vN(this)),this.headerStyleCache=new Map,this.bodyStyleCache=new Map}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 xi(this.tableX,this.tableY,t,e)}_getMouseAbstractPoint(t,e=!0){const i=this;let n;if(!t)return null;n=BN(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();if(s.right<=r)return null;if(s.bottom<=o)return null;const a=s.width,l=a/(this.canvas.offsetWidth||a),h=s.height,c=h/(this.canvas.offsetHeight||h);return{x:(r-s.left)/l+(e?i.scrollLeft:0)-i.tableX,y:(o-s.top)/c+(e?i.scrollTop:0)-i.tableY}}_getCellEventArgsSet(t){const e=this._getMouseAbstractPoint(t);if(!e)return{};const i=this.getCellAt(e.x,e.y);if(i.col<0||i.row<0)return{abstractPos:e,cell:i};return{abstractPos:e,cell:i,eventArgs:{col:i.col,row:i.row,event:t,rect:i.rect}}}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()}updatePager(t){this.pagerConf&&("number"==typeof t.currentPage&&t.currentPage>=0&&(this.pagerConf.currentPage=t.currentPage),t.perPageCount&&(this.pagerConf.perPageCount=t.perPageCount||this.pagerConf.perPageCount),this.scenegraph.clearCells(),this.dataSource.updatePager(this.pagerConf),this.refreshRowColCount(),this.scenegraph.createSceneGraph(),this.invalidate())}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||null}get dataSource(){return this.internalProps.dataSource}set dataSource(t){this.scenegraph.clearCells(),VF(this,t),this.refreshRowColCount(),this.scenegraph.createSceneGraph(),this.invalidate()}get autoWrapText(){return this.internalProps.autoWrapText}set autoWrapText(t){this.internalProps.autoWrapText!==t&&(this.internalProps.autoWrapText=t,this.options.autoWrapText=t,this.internalProps.layoutMap&&(this.refreshHeader(),this.invalidate()))}get theme(){return this.internalProps.theme}set theme(t){const e=Ui.of(t);this.internalProps.theme=e||Ui.DEFAULT,this.options.theme=t,this.resize()}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).columnType}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}getCellType(t,e){return this.internalProps.layoutMap.getCellType(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.sortState=e,this.stateManeger.setSortState(this.sortState)),t){if(UF(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??R)}}this.refreshRowColCount()}else UF(this,t);this.scenegraph.createSceneGraph(),this.invalidate(),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),caption:i.caption,columnType:i.columnType?"string"==typeof i.columnType?i.columnType:"progressbar":"text",originData:this.getCellOriginRecord(t,e),cellRange:this.getCellRangeRelativeRect({col:t,row:e}),value:this.getCellValue(t,e),dataValue:this.getCellOriginValue(t,e),cellType:this.getCellType(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 MN;const o=this.internalProps.headerHelper.getStyleClass(r.headerType);if(i.isBottomFrozenRow(t,e)&&this.theme.bottomFrozenStyle)n=K({},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=K({},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=K(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.columnType),a=o?.style;return r=W(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),this.bodyStyleCache.set(n,r),r}clearCellStyleCache(){this.headerStyleCache.clear()}_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=qF(i,this,t,e,nW).theme,{autoWrapText:r,lineClamp:o,textOverflow:s}=i;return{textAlign:n.text.textAlign,textBaseline:n.text.textBaseline,bgColor:Et(n.group.fill)?nW("bgColor",i,t,e,this):n.group.fill,color:Et(n.text.fill)?nW("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:Et(n.group.stroke)?nW("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(A(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(A(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.invalidate()}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 yW.measureText(t,e)}measureTextBounds(t){const e=new bW(t);return{width:e.AABBBounds.width(),height:e.AABBBounds.height()}}getCustomRender(t,e){let i;if("body"!==this.getCellType(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.getCellType(t,e)){const n=this.getHeaderDefine(t,e);i=n?.headerCustomLayout}else{const n=this.getBodyColumnDefine(t,e);i=n?.customLayout}return i}}var EN=Object.freeze({__proto__:null,BaseTable:PN});function HN(t,e,i){const n=t[e];return t[e]=i,n}function LN(t){for(const e in t)delete t[e]}function kN(){LN(Ri),LN(ZF),LN(Cz)}var IN=Object.freeze({__proto__:null,chartModule:function(t,e){return null!=e?HN(Cz,t,e):Cz[t]},clearAll:kN,icon:function(t,e){return null!=e?HN(ZF,t,e):ZF[t]},theme:function(t,e){return null!=e?HN(Ri,t,e):Ri[t]}});var ON=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}`}}});function DN(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 FN(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 WN=0;class zN{_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}getCellType(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}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 t,e,i,n=0;return this.columnObjects.forEach(((r,o)=>{"number"==typeof r.width?n=Math.max(r.width,n):"auto"===r.width&&(i=!0),"number"==typeof r.minWidth&&(e=Math.max(r.minWidth,e)),"number"==typeof r.maxWidth&&(t=Math.max(r.maxWidth,t))})),n=n>0?n:i?"auto":void 0,{width:n,minWidth:e,maxWidth:t}}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=WN++,{captionIcon:l}=e,h={id:a,caption:e.caption,captionIcon:l,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]=h;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:WN++,field:i.field,fieldKey:i.fieldKey,fieldFormat:i.fieldFormat,width:i.width,minWidth:i.minWidth,maxWidth:i.maxWidth,icon:i.icon,columnType:i.columnType??"text",chartModule:"chartModule"in i?i.chartModule:null,chartSpec:"chartSpec"in i?i.chartSpec:null,sparklineSpec:"sparklineSpec"in i?i.sparklineSpec:Hi,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 FN(t,e,this)}}class jN{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 St;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 St,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?Ei:t.dimensionKey)&&this.dimensionKeys.put(t.level,t.indicatorKey?Ei:t.dimensionKey),t.id||(t.id=++NN));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===r.expand&&t.children?t.children.forEach((e=>{e.level=(t.level??0)+1,n+=this.setTreeNode(e,n,t)})):t.hierarchyState===r.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=r.expand,t.children.forEach((e=>{e.level=(t.level??0)+1,n+=this.setTreeNode(e,n,t)}))):t.children?(t.hierarchyState=r.collapse,t.children.forEach((e=>{e.level=(t.level??0)+1,this.setTreeNode(e,n,t)}))):(t.hierarchyState=r.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 NN=0,GN=0;class KN{_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=Ei;_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 jN(this.columnTree??[]),this.rowDimensionTree=new jN(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=++NN,e=Array(this.colCount-this.rowHeaderLevelCount).fill(t);this._columnHeaderCellIds.unshift(e);const i={id:t,caption:"string"==typeof this.columnHeaderTitle.title?this.columnHeaderTitle.title:this.columnsDefine.reduce(((t,e)=>"string"==typeof e?t:t+(t?`/${e.dimensionTitle}`:`${e.dimensionTitle}`)),""),field:void 0,headerType:this.columnHeaderTitle.headerType??"text",style:this.columnHeaderTitle.headerStyle,define:{id:t}};this.columnHeaderObjs.push(i),this._headerObjects[t]=i}if(GN=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=++NN,e=Array(this.rowCount-this.columnHeaderLevelCount).fill(t);this._rowHeaderCellIds.unshift(e);const i={id:t,caption:"string"==typeof this.rowHeaderTitle.title?this.rowHeaderTitle.title:this.rowsDefine.reduce(((t,e)=>"string"==typeof e?t:t+(t?`/${e.dimensionTitle}`:`${e.dimensionTitle}`)),""),field:void 0,headerType:this.rowHeaderTitle.headerType??"text",style:this.rowHeaderTitle.headerStyle,define:{id:t}};this.rowHeaderObjs.push(i),this._headerObjects[t]=i}GN=0,this.indicatorsAsCol=!A(this.rowDimensionKeys.find((t=>t===this.indicatorDimensionKey))),this._rowHeaderCellIds=C(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===GN)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.caption===i.value))),l={id:o,caption:i.value??a.caption,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),A(this._indicators.find((t=>t.indicatorKey===a.indicatorKey)))||this._indicators.push({id:++NN,indicatorKey:a.indicatorKey,field:a.indicatorKey,fieldFormat:a?.format,columnType: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&&(A(this._indicators.find((t=>t.indicatorKey===i.indicatorKey)))||this._indicators.push({id:++NN,indicatorKey:i.indicatorKey,field:i.indicatorKey,columnType:"text",define:Object.assign({},i)})),r[o]=l,this._headerObjects[o]=l,t[e][GN]=o;for(let i=e-1;i>=0;i--)t[i][GN]=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][GN]=o;GN++}})),r}_addHeadersForTreeMode(t,e,i,n,o,s){const a=[];return t[e]||function(e){const i=t[e]=[];if(0===GN)return i;const n=t[e-1];for(let t=0;t<n?.length;t++)i[t]=n[t]}(e),i.forEach((i=>{const l=i.id,h=this.rowsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.dimensionKey))??this.columnsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.dimensionKey)),c={id:l,caption:i.value,field:i.dimensionKey,style:i.level+1===o||"function"==typeof h?.headerStyle?h?.headerStyle:Object.assign({},h?.headerStyle,{textAlign:"left"}),headerType:h?.headerType??"text",headerIcon:h?.headerIcon,define:Object.assign(i,{linkJump:h?.linkJump,linkDetect:h?.linkDetect,templateLink:h?.templateLink,keepAspectRatio:h?.keepAspectRatio??!1,imageAutoSizing:h?.imageAutoSizing,headerCustomRender:h?.headerCustomRender,headerCustomLayout:h?.headerCustomLayout,dragHeader:h?.dragHeader}),fieldFormat:h?.headerFormat,dropDownMenu:h?.dropDownMenu,pivotInfo:{value:i.value,dimensionKey:i.dimensionKey,isPivotCorner:!1},hierarchyLevel:i.level,dimensionTotalLevel:o,hierarchyState:i.level+1===o?void 0:i.hierarchyState,width:h?.width,minWidth:h?.minWidth,maxWidth:h?.maxWidth};a[l]=c,this._headerObjects[l]=c,t[e][GN]=l;for(let i=e-1;i>=0;i--)t[i][GN]=n[i];if(i.hierarchyState===r.expand&&i.children)s&&GN++,this._addHeadersForTreeMode(t,e,i.children??[],[...n,l],o,s&&i.hierarchyState===r.expand).forEach((t=>a.push(t)));else{s&&GN++;for(let i=e+1;i<t.length;i++)t[i][GN]=l}})),a}_addCornerHeaders(t){const e=[];if(t)t.forEach(((t,i)=>{const n=++NN,r=this.rowsDefine?.find((e=>"string"!=typeof e&&e.dimensionKey===t))??this.columnsDefine?.find((e=>"string"!=typeof e&&e.dimensionKey===t)),o={id:n,caption:t===this.indicatorDimensionKey?this.indicatorTitle:r?.dimensionTitle??"",field:"维度名称",style:this.cornerSetting.headerStyle,headerType:this.cornerSetting.headerType??"text",define:{dimensionKey:"维度名称",id:n,value:t},dropDownMenu:r?.cornerDropDownMenu,pivotInfo:{value:r?.dimensionTitle??"",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=++NN,i={id:t,caption:"",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){}getCellType(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}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:this.getDimension(this.colDimensionKeys[this.colDimensionKeys.length-1],"column")?.multiDimension?1:0:0}get rightFrozenColCount(){return this.showHeader&&this.showColumnHeader?this.indicatorsAsCol||this.hideIndicatorName?this.getDimension(this.rowDimensionKeys[this.rowDimensionKeys.length-1],"row")?.multiDimension?1:0:this.indicatorsDefine.find((t=>t?.multiIndicator))?1:0: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,columnType: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,columnType: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)?.caption??"",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)?.caption??"",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]))),o=this.getHeader(t,e);if(o.define.hierarchyState=o.define.hierarchyState===r.collapse?r.expand:r.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=++NN,e=Array(this.rowCount-this.columnHeaderLevelCount).fill(t);this._rowHeaderCellIds.unshift(e);const i={id:t,caption:"string"==typeof this.rowHeaderTitle.title?this.rowHeaderTitle.title:this.rowsDefine.reduce(((t,e)=>"string"==typeof e?t:t+(t?`/${e.dimensionTitle}`:`${e.dimensionTitle}`)),""),field:void 0,headerType:this.rowHeaderTitle.headerType??"text",style:this.rowHeaderTitle.headerStyle,define:{field:"",headerType:"text",columnType:"text"}};this.rowHeaderObjs.push(i),this._headerObjects[t]=i}return GN=0,this._rowHeaderCellIds=C(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((A(s.dimensionKey)&&e.dimensionKey===s.dimensionKey||A(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((A(s.dimensionKey)&&i.dimensionKey===s.dimensionKey||A(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=v(this.getCellHeaderPathsWidthTreeNode(t.col,t.row).rowHeaderPaths),n=v(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(!A(i.indicatorKey)&&e.dimensionKey===i.dimensionKey&&e.value===i.value||A(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((!A(e.indicatorKey)&&i.dimensionKey===e.dimensionKey&&i.value===e.value||A(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 A(n)||A(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 DN(t,e,this)}getChartDataId(t,e){return FN(t,e,this)}}const UN={isEmpty:!0,id:void 0,field:void 0,headerType:void 0,define:void 0};class VN{_headerObjects=[];_headerObjectMap={};_indicatorObjects=[];_columnWidths=[];rowTree;columnTree;rowsDefine;columnsDefine;indicatorsDefine;indicatorKeys;_showRowHeader=!0;_showColumnHeader=!0;_rowHeaderTitle;_columnHeaderTitle;_indicatorShowType="column";indicatorsAsCol=!0;hideIndicatorName=!1;indicatorDimensionKey=Ei;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=C(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.dimensionTitle}`:`${e.dimensionTitle}`)),"");this._headerObjectMap[e]={id:e,caption:e,field:t,headerType:this.rowHeaderTitle.headerType??"text",style:this.rowHeaderTitle.headerStyle,define:{}},this._headerObjectMap[t]={id:t,caption:"",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.dimensionTitle}`:`${e.dimensionTitle}`)),"");this._headerObjectMap[e]={id:e,caption:e,field:t,headerType:this.columnHeaderTitle.headerType??"text",style:this.columnHeaderTitle.headerStyle,define:{}},this._headerObjectMap[t]={id:t,caption:"",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,caption:"",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.caption===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],caption:i[i.length-1],style:n?.headerStyle,define:{field:n?.dimensionKey??this.rows[i.length-1],headerType:n?.headerType??"text",columnType:"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],caption:i[i.length-1],style:n?.headerStyle,define:{field:n?.dimensionKey??this.columns[i.length-1],headerType:n?.headerType??"text",columnType:"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,caption:i.caption??e,style:i?.headerStyle,define:{field:this.indicatorDimensionKey,headerType:i?.headerType??"text",columnType:"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,caption:t===this.indicatorDimensionKey?this.indicatorTitle:e?.dimensionTitle??t,style:this.cornerSetting?.headerStyle,define:{field:t,headerType:this.cornerSetting?.headerType??"text",columnType:"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",columnType:e?.columnType??"text"},e),fieldFormat:e?.format,columnType:e?.columnType??"text",chartModule:e&&("chartModule"in e?e.chartModule:null),chartSpec:e&&("chartSpec"in e?e.chartSpec:null),sparklineSpec:"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}getCellType(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}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]??UN}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,columnType: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,columnType: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.caption: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.caption: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(!A(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(!A(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,A(r)||A(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=C(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)}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):n.push(i.yField),n):null}getAxisConfigInPivotChart(t,e){return function(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 e=i.getIndicatorKeyInChartSpec(t,i.columnHeaderLevelCount-1)[1];if(Wt(e)&&(e=e[0]),!e)return;const n=i.dataset.collectedValues[e+"_align"]?i.dataset.collectedValues[e+"_align"]:i.dataset.collectedValues[e],r=i.getRecordIndexByCol(t),o=n[i.getColKeysPath()[r][Math.max(0,i.columnHeaderLevelCount-1-i.topAxesCount)]],s=i._table.pivotChartAxes.find((t=>"top"===t.orient));if(!1===s?.visible)return;return ne({},s,{orient:"top",type:"linear",range:o,label:{flush:!0},title:{visible:!1}})}if(e===i.rowCount-i.bottomFrozenRowCount&&t>=i.rowHeaderLevelCount&&t<i.colCount-i.rightFrozenColCount){const n=i.getIndicatorKeyInChartSpec(t,e);let r=n[0];Wt(r)&&(r=r[0]);const o=i.dataset.collectedValues[r+"_align"]?i.dataset.collectedValues[r+"_align"]:i.dataset.collectedValues[r],s=i.getRecordIndexByCol(t),a=o[i.getColKeysPath()[s][Math.max(0,i.columnHeaderLevelCount-1-i.topAxesCount)]];let l=null;n.forEach((t=>{const e=i.getIndicatorInfo(t);e&&(l=e)}));const h=i._table.pivotChartAxes.find((t=>"bottom"===t.orient));if(!1===h?.visible)return;return ne({},h,{orient:"bottom",type:"linear",range:a,label:{flush:!0},title:{text:l?.caption,autoRotate:!0}})}if(t===i.rowHeaderLevelCount-1&&e>=i.rowHeaderLevelCount&&e<i.rowCount-i.bottomFrozenRowCount){let t=i.getDimensionKeyInChartSpec(i.rowHeaderLevelCount,e)[0];Wt(t)&&(t=t[0]);const n=i.dataset.collectedValues[t],r=i.getRecordIndexByRow(e),o=i.getRowKeysPath()[r],s=n[o[o.length-1]],a=i._table.pivotChartAxes.find((t=>"left"===t.orient));if(!1===a?.visible)return;return ne({},a,{orient:"left",type:"band",data:Array.from(s).reverse(),title:{visible:!1}})}}else{if(t===i.rowHeaderLevelCount-1&&e>=i.columnHeaderLevelCount&&e<i.rowCount-i.bottomFrozenRowCount){const n=i.getIndicatorKeyInChartSpec(t,e);let r=n[0];Wt(r)&&(r=r[0]);const o=i.dataset.collectedValues[r+"_align"]?i.dataset.collectedValues[r+"_align"]:i.dataset.collectedValues[r],s=i.getRecordIndexByRow(e),a=o[i.getRowKeysPath()[s][Math.max(0,i.rowHeaderLevelCount-1-i.leftAxesCount)]];let l=null;n.forEach((t=>{const e=i.getIndicatorInfo(t);e&&(l=e)}));const h=i._table.pivotChartAxes.find((t=>"left"===t.orient));if(!1===h?.visible)return;return ne({},h,{orient:"left",type:"linear",range:a,label:{flush:!0},title:{text:l?.caption,autoRotate:!0}})}if(t===i.colCount-i.rightFrozenColCount&&e>=i.columnHeaderLevelCount&&e<i.rowCount-i.bottomFrozenRowCount){let t=i.getIndicatorKeyInChartSpec(i.rowHeaderLevelCount-1,e)[1];if(Wt(t)&&(t=t[0]),!t)return;const n=i.dataset.collectedValues[t+"_align"]?i.dataset.collectedValues[t+"_align"]:i.dataset.collectedValues[t],r=i.getRecordIndexByRow(e),o=n[i.getRowKeysPath()[r][Math.max(0,i.rowHeaderLevelCount-1-i.leftAxesCount)]],s=i._table.pivotChartAxes.find((t=>"right"===t.orient));if(!1===s?.visible)return;return ne({},s,{orient:"right",type:"linear",range:o,label:{flush:!0},title:{visible:!1}})}if(e===i.rowCount-i.bottomFrozenRowCount&&t>=i.rowHeaderLevelCount&&t<i.colCount-i.rightFrozenColCount){let e=i.getDimensionKeyInChartSpec(t,i.columnHeaderLevelCount)[0];Wt(e)&&(e=e[0]);const n=i.dataset.collectedValues[e],r=i.getRecordIndexByCol(t),o=i.getColKeysPath()[r],s=n[o[o.length-1]],a=i._table.pivotChartAxes.find((t=>"bottom"===t.orient));if(!1===a?.visible)return;return ne({},a,{orient:"bottom",type:"band",data:Array.from(s),title:{visible:!1}})}}}(t,e,this)}getRawChartSpec(t,e){return DN(t,e,this)}getChartSpec(t,e){return function(t,e,i){let n=i.getRawChartSpec(t,e);return n?(n=Qt(n),n.axes=i.getChartAxes(t,e),n.padding=0,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(((t,e)=>{Wt(t)&&(t=t[0]);const r=(i.dataset.collectedValues[t+"_align"]?i.dataset.collectedValues[t+"_align"]:i.dataset.collectedValues[t])[i.getColKeysPath()[o][Math.max(0,i.columnHeaderLevelCount-1-i.topAxesCount)]],s=i._table.pivotChartAxes.find((t=>t.orient===(0===e?"bottom":"top")));n.push(ne({},s,{type:"linear",orient:0===e?"bottom":"top",label:{visible:!1},title:{visible:!1},range:r,seriesIndex:e}))}));let s=i.getDimensionKeyInChartSpec(i.rowHeaderLevelCount,t)[0];Wt(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=i._table.pivotChartAxes.find((t=>"left"===t.orient));n.push(ne({},u,{type:"band",orient:"left",label:{visible:!1,space:0},domainLine:{visible:!1},tick:{visible:!1},subTick:{visible:!1},title:{visible:!1},width:-1,domain:Array.from(c)}))}else{const r=i.getIndicatorKeyInChartSpec(t,e),o=i.getRecordIndexByRow(e);r.forEach(((t,e)=>{Wt(t)&&(t=t[0]);const r=(i.dataset.collectedValues[t+"_align"]?i.dataset.collectedValues[t+"_align"]:i.dataset.collectedValues[t])[i.getRowKeysPath()[o][Math.max(0,i.rowHeaderLevelCount-1-i.leftAxesCount)]],s=i._table.pivotChartAxes.find((t=>t.orient===(0===e?"left":"right")));n.push(ne({},s,{type:"linear",orient:0===e?"left":"right",label:{visible:!1},title:{visible:!1},range:r,seriesIndex:e}))}));let s=i.getDimensionKeyInChartSpec(t,i.columnHeaderLevelCount)[0];Wt(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=i._table.pivotChartAxes.find((t=>"bottom"===t.orient));n.push(ne({},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,domain:Array.from(c)}))}return n}(t,e,this)}getChartDataId(t,e){return FN(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))}}class $N{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 YN{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 XN extends YN{type=o.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 qN extends YN{type=o.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 ZN extends YN{type=o.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 JN extends YN{type=o.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===o.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 QN extends YN{type=o.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 tG extends YN{type=o.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 eG(t,e){return t&&e?t.toString().localeCompare(e.toString(),"zh"):t?1:-1}function iG(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 nG(t){return 2===t.length&&Gt(t[0])&&Gt(t[1])&&t[1]>=t[0]}function rG(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 oG(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 sG(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 aG(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 lG(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 hG(t,e){const i=[t.min,t.max],n=[e.min,e.max];if(!nG(i)||!nG(n))return;const r=rG(i),o=rG(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(!sG(r,o))return}else if(0===u&&0===d){if(!sG(o,r))return}else if(c||g)if(c&&!g){if(!oG(r,o))return}else if(g&&!c){if(!oG(o,r))return}else{if(a===d)return;if(a>d){if(!aG(r,o))return}else if(!aG(o,r))return}else{if(0===a&&0===u){if(!lG(r,o))return}else if(0===d&&0===s&&!lG(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 cG{dataConfig;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;constructor(t,e,i,n,r,o,s){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=e,this.columns=i,this.indicatorKeys=n,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??{230417170554008:{by:["230417171050031","230417171050028"]}},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(r){this.records=r;const t="undefined"!=typeof window?window.performance.now():0;this.setRecords(r),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 a="undefined"!=typeof window?window.performance.now():0;this.sortKeys();const l="undefined"!=typeof window?window.performance.now():0;console.log("sortKeys:",l-a);const h="undefined"!=typeof window?window.performance.now():0;this.rowKeysPath=s?this.TreeToArr2(s):this.TreeToArr(this.ArrToTree(this.rowKeys,this.rowsIsTotal,this?.totals?.row?.showGrandTotals,this.rowGrandTotalLabel,this.rowSubTotalLabel)),this.colKeysPath=o?this.TreeToArr2(o):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())}}registerAggregator(t,e){this.aggregators[t]=e}registerAggregators(){this.registerAggregator(o.RECORD,XN),this.registerAggregator(o.SUM,qN),this.registerAggregator(o.COUNT,ZN),this.registerAggregator(o.MAX,QN),this.registerAggregator(o.MIN,tG),this.registerAggregator(o.AVG,JN)}setRecords(t){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;this.dataConfig?.filterRules?.length>=1&&(t=!0);for(let e=0,i=this.records.length;e<i;e++){const i=this.records[e];t&&!this.filterRecord(i)||this.processRecord(i)}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){this.derivedFieldRules?.forEach(((e,i)=>{t[e.fieldName]=e.derivedFunc(t)}));const e=[],i=[];for(let e=0,n=this.rows.length;e<n;e++){const n=this.rows[e];i.push(t[n])}for(let i=0,n=this.columns.length;i<n;i++){const n=this.columns[i];e.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[o.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 n=i.join(this.stringJoinChar),r=e.join(this.stringJoinChar);0!==i.length&&(this.rowFlatKeys[n]||(this.rowKeys.push(i),this.rowFlatKeys[n]=1)),0!==e.length&&(this.colFlatKeys[r]||(this.colKeys.push(e),this.colFlatKeys[r]=1)),this.tree[n]||(this.tree[n]={}),this.tree[n]?.[r]||(this.tree[n][r]=[]);for(let e=0;e<this.indicatorKeys.length;e++){const i=this.getAggregatorRule(this.indicatorKeys[e]);if(this.tree[n]?.[r]?.[e]||(this.tree[n][r][e]=new this.aggregators[i?.aggregationType??o.SUM](i?.field??this.indicatorKeys[e],i?.formatFun)),i?.field)if("string"==typeof i?.field)A(t[i?.field])&&this.tree[n]?.[r]?.[e].push(t);else{const o=i?.field.find((e=>t[e]));o&&this.tree[n]?.[r]?.[e].push(t)}else A(t[this.indicatorKeys[e]])&&this.tree[n]?.[r]?.[e].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[o.MAX](this.indicatorKeys[e]),min:new this.aggregators[o.MIN](this.indicatorKeys[e]),total:new this.aggregators[t?.aggregationType??o.SUM](t?.field??this.indicatorKeys[e],t?.formatFun)}}this.indicatorStatistics[e].max.push(this.tree[n]?.[r]?.[e].value()),this.indicatorStatistics[e].min.push(this.tree[n]?.[r]?.[e].value()),this.indicatorStatistics[e].total.push(t)}}updateSortRules(t){this.sorted=!1,this.sortRules=t,this.sortKeys(),this.rowKeysPath=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.dataConfig.isPivotChart&&this.dealWithZeroAlign()}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 iG(e(t,[]),e(i,[]))}));break;case"value_z_to_a":this.rowKeys.sort((function(t,i){return-iG(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 iG(e([],t),e([],i))}));break;case"value_z_to_a":this.colKeys.sort((function(t,i){return-iG(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:iG})}return o}.call(this);return function(i,o){let a,l;for(let h=0;h<r.length;h++){if(l=r[h],l.sortRule?.sortByIndicator){let r=i,s=o;l.fieldIndex<t.length-1&&(r=i.slice(0,l.fieldIndex+1),r.push(e?n.totals?.row?.subTotalLabel:n.totals?.column?.subTotalLabel),s=o.slice(0,l.fieldIndex+1),s.push(e?n.totals?.row?.subTotalLabel:n.totals?.column?.subTotalLabel)),a=l.func(r,s)}else a=l.func(i[l.fieldIndex],o[l.fieldIndex]);if(0!==a)return a*(l.sortRule?.sortType===s.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?iG(o(n,t.query),o(r,t.query)):iG(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:iG(t,e)}}(t.sortBy):t.sortType?eG:t.sortFunc?t.sortFunc:iG}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,s=t.totals?.column?.subTotalsDimensions?.length;r<s;r++){const s=t.totals.column.subTotalsDimensions[r],a=t.columns.indexOf(s);if(a>=0){const r=n.slice(0,a+1);r.push(t.totals?.column?.subTotalLabel??"小计");const s=r.join(this.stringJoinChar);this.tree[e][s]||(this.tree[e][s]=[]);for(let n=0;n<this.indicatorKeys.length;n++){if(!this.tree[e][s][n]){const t=this.getAggregatorRule(this.indicatorKeys[n]);this.tree[e][s][n]=new this.aggregators[t?.aggregationType??o.SUM](t?.field??this.indicatorKeys[n],t?.formatFun)}this.tree[e][s][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??o.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((s=>{for(let i=0,a=t.totals?.row?.subTotalsDimensions?.length;i<a;i++){const a=t.totals.row.subTotalsDimensions[i],l=t.rows.indexOf(a);if(l>=0){const i=r.slice(0,l+1);i.push(t.totals?.row?.subTotalLabel??"小计");const a=i.join(this.stringJoinChar);if(this.tree[a]||(this.tree[a]={},e.push(a)),!this.tree[a][s]){this.tree[a][s]=[];for(let e=0;e<this.indicatorKeys.length;e++){if(!this.tree[a][s][e]){const t=this.getAggregatorRule(this.indicatorKeys[e]);this.tree[a][s][e]=new this.aggregators[t?.aggregationType??o.SUM](t?.field??this.indicatorKeys[e],t?.formatFun)}this.tree[a][s][e].push(t.tree[n]?.[s]?.[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][s]||(this.tree[i][s]=[]);for(let e=0;e<this.indicatorKeys.length;e++){if(!this.tree[i][s][e]){const t=this.getAggregatorRule(this.indicatorKeys[e]);this.tree[i][s][e]=new this.aggregators[t?.aggregationType??o.SUM](t?.field??this.indicatorKeys[e],t?.formatFun)}this.tree[i][s][e].push(t.tree[n]?.[s]?.[e])}}i(n,s)}))})),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];Wt(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"]={};for(const t in n){const o=n[t],s=r[t],a=hG(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]=uG(this.collectedValues[t],this.dataConfig.dimensionSortArray):this.cacheCollectedValues[t]=this.collectedValues[t])}}function uG(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 dG{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 pG={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 fG{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=pG[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 gG extends dG{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 yG=Object.freeze({__proto__:null,Circle:class extends dG{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 dG{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",g(t.width)?this.width=t.width:(this._widthObj=t.width,this.needCalcSize=!0),g(t.height)?this.height=t.height:(this._heightObj=t.height,this.needCalcSize=!0),this.directionKey=pG[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 fG(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 gG({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 gG({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 dG{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=pG[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 dG{type="icon";svg;iconName;cursor;cache;constructor(t){if(super(t),this.iconName=t.iconName,f(this.iconName)){const t=tW()[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 dG{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:gG,Sector:class extends dG{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 dG{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,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=yG,t.DataStatistics=ON,t.ListTable=class extends PN{showHeader=!0;constructor(t={}){super(t);const e=this.internalProps;this.pagerConf=t.pagerConf,e.sortState=t.sortState,e.columns=t.columns?v(t.columns):t.header?v(t.header):[],this.showHeader=t.showHeader??!0,this.transpose=t.transpose??!1,this.refreshHeader(),t.dataSource?VF(this,t.dataSource):t.records?this.setRecords(t.records,e.sortState):this.setRecords([])}isListTable(){return!0}isPivotTable(){return!1}isPivotChart(){return!1}get sortState(){return this.internalProps.sortState}set sortState(t){this.internalProps.sortState=t}get columns(){return this.internalProps.columns}set columns(t){this.internalProps.columns=t,this.options.columns=t,this.refreshHeader(),setTimeout((()=>{this.invalidate()}),0)}get header(){return this.internalProps.columns}set header(t){this.internalProps.columns=t,this.options.header=t,this.refreshHeader(),setTimeout((()=>{this.invalidate()}),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.invalidate()))}getCellValue(t,e){const i=this;if(i.internalProps.layoutMap.isHeader(t,e)){const{caption: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{caption: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.pagerConf=t.pagerConf,this.showHeader=t.showHeader??!0,i.columns=t.columns?v(t.columns):t.header?v(t.header):[],this.transpose=t.transpose??!1,this.refreshHeader(),i.disposables&&(i.disposables.forEach((t=>t?.dispose?.())),i.disposables=null),this._updateSize(),t.dataSource?VF(this,t.dataSource):t.records?this.setRecords(t.records,t.sortState):(this._resetFrozenColCount(),this.scenegraph.createSceneGraph(),this.invalidate()),new Promise((t=>{setTimeout(t,0)}))}refreshHeader(){const t=this,e=t.internalProps,i=t.transpose,n=t.showHeader;e.headerEvents&&e.headerEvents.forEach((e=>t.unlisten(e)));const r=e.layoutMap=new zN(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.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))}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.records.length;e++){const n=this.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(A(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 A(e)&&(r=i.getRecordStartRowByRecordIndex(e)),this.transpose?{start:{row:t.start.row,col:A(r)?r+t.start.col:void 0},end:{row:t.end.row,col:A(r)?r+t.end.col:void 0}}:{start:{col:t.start.col,row:A(r)?r+t.start.row:void 0},end:{col:t.end.col,row:A(r)?r+t.end.row:void 0}}}return null}getHierarchyState(t,e){if(!this.getBodyColumnDefine(t,e).tree)return r.none;const i=this.getRecordIndexByRow(t,e);return this.dataSource.getHierarchyState(i)}toggleHierarchyState(t,e){const i=this.getHierarchyState(t,e);i===r.expand?this.fireListeners(yt.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:r.collapse}):i===r.collapse&&this.fireListeners(yt.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:r.expand,originData:this.getCellOriginRecord(t,e)});const n=this.getRecordIndexByRow(t,e),o=this.dataSource.toggleHierarchyState(n),s=this.internalProps.layoutMap.toggleHierarchyState(o);this.refreshRowColCount(),this.clearCellStyleCache(),this.scenegraph.updateHierarchyIcon(t,e),this.scenegraph.updateRow(s.removeCellPositions,s.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),cellType:this.getCellType(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){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 e,i,n;if(Array.isArray(this.internalProps.sortState)?({order:e,field:i,fieldKey:n}=this.internalProps.sortState?.[0]):({order:e,field:i,fieldKey:n}=this.internalProps.sortState),i){const t=this._getSortFuncFromHeaderOption(this.internalProps.columns,i,n);let r;r=n?this.internalProps.layoutMap.headerObjects.find((t=>t&&t.fieldKey===n)):this.internalProps.layoutMap.headerObjects.find((t=>t&&t.field===i)),r?.define?.sort&&(this.dataSource.sort(r.field,e,t),this.scenegraph.sortCell())}this.stateManeger.updateSortState(t)}},t.PivotChart=class extends PN{pivotSortState;dataset;_selectedDataItemsInChart=[];_selectedDimensionInChart=[];_chartEventMap={};_axes;constructor(t){if(super(t),t.layout&&Object.assign(t,t.layout),this.setCustomStateNameToSpec(),this.internalProps.dataConfig={isPivotChart:!0},this.internalProps.enableDataAnalysis=!0,this._axes=Wt(t.axes)?t.axes:[],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)),[]),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.internalProps.dataConfig.dimensionSortArray=this._getDimensionSortArray(),this.dataset=new cG(this.internalProps.dataConfig,e,i,n,t.records,t.columnTree,t.rowTree)}this.refreshHeader(),t.dataSource?VF(this,t.dataSource):t.records?this.setRecords(t.records,this.internalProps.sortState):this.setRecords([])}static get EVENT_TYPE(){return mj}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.dataConfig={},this.internalProps.enableDataAnalysis=!0,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)),[]),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 cG(this.internalProps.dataConfig,e,i,n,t.records??this.internalProps.records,t.columnTree,t.rowTree)}return this.refreshHeader(),i.disposables&&(i.disposables.forEach((t=>t?.dispose?.())),i.disposables=null),this._updateSize(),t.dataSource?VF(this,t.dataSource):t.records?this.setRecords(t.records,void 0):(this._resetFrozenColCount(),this.scenegraph.createSceneGraph(),this.invalidate()),new Promise((t=>{setTimeout(t,0)}))}refreshHeader(){const t=this.internalProps;t.headerEvents&&t.headerEvents.forEach((t=>this.unlisten(t))),this.internalProps.enableDataAnalysis&&(t.layoutMap=new VN(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 XD({dataValue:s,...n.internalProps.layoutMap.getCellHeaderPaths(e,i)},t,gt)}return s}getCellValue(t,e){if(this.internalProps.layoutMap.isHeader(t,e)){const{caption: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{caption: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.invalidate()}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(at(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.records.length;t++){const e=this.records[t].splice(i.sourceIndex-this.rowHeaderLevelCount,i.moveSize);e.unshift(i.targetIndex-this.rowHeaderLevelCount,0),Array.prototype.splice.apply(this.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.records.splice(i.sourceIndex-this.columnHeaderLevelCount,i.moveSize);t.unshift(i.targetIndex-this.columnHeaderLevelCount,0),Array.prototype.splice.apply(this.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===r.expand?this.fireListeners(mj.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:r.collapse}):i===r.collapse&&this.fireListeners(mj.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:r.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),cellType:this.getCellType(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:o.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:o.RECORD})}else t.push({indicatorKey:e.indicatorKey,field:e.indicatorKey,aggregationType:o.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)}}))}_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}listenChart(t,e){this._chartEventMap[t]=e}unlistenChart(t){delete this._chartEventMap[t]}_bindChartEvent(t){if(t)for(const e in this._chartEventMap)t.on(e,this._chartEventMap[e])}updateFilterRules(t){this.internalProps.dataConfig.filterRules=t,this.dataset.updateFilterRules(t),Jz(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),t.addUpdateBoundTag()}}))}));Qz(t.rowHeaderGroup,t.table),Qz(t.colHeaderGroup,t.table),Qz(t.rightFrozenGroup,t.table),Qz(t.bottomFrozenGroup,t.table)}(this.scenegraph),this.invalidate()}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,viewBox:r,axes:a}=s.attribute;a.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:r.x1-s.getRootNode().table.scrollLeft,x2:r.x2-s.getRootNode().table.scrollLeft,y1:r.y1-s.getRootNode().table.scrollTop,y2:r.y2-s.getRootNode().table.scrollTop}),e.updateDataSync(i,n),o=e.convertDatumToPosition(t),this.invalidate()}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&&Wt(e.domain))return e.domain}}},t.PivotTable=class extends PN{pivotSortState;dataset;flatDataToObjects;constructor(t){if(super(t),t.layout&&Object.assign(t,t.layout),this.internalProps.dataConfig=t.dataConfig,this.internalProps.enableDataAnalysis=t.enableDataAnalysis,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)),[]),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.dataset=new cG(this.internalProps.dataConfig,e,i,n,t.records)}this.refreshHeader(),this.pivotSortState=[],t.pivotSortState&&this.updatePivotSortState(t.pivotSortState),t.dataSource?VF(this,t.dataSource):t.records?this.setRecords(t.records,this.internalProps.sortState):this.setRecords([])}static get EVENT_TYPE(){return yj}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),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 cG(i.dataConfig,e,n,r,t.records)}return this.refreshHeader(),i.disposables&&(i.disposables.forEach((t=>t?.dispose?.())),i.disposables=null),this._updateSize(),t.dataSource?VF(this,t.dataSource):t.records?this.setRecords(t.records,void 0):(this._resetFrozenColCount(),this.scenegraph.createSceneGraph(),this.invalidate()),this.pivotSortState=[],t.pivotSortState&&this.updatePivotSortState(t.pivotSortState),new Promise((t=>{setTimeout(t,0)}))}refreshHeader(){const t=this.internalProps;t.headerEvents&&t.headerEvents.forEach((t=>this.unlisten(t)));const e=this.options.records??this.internalProps.records;this.options.enableDataAnalysis?t.layoutMap=new VN(this,this.dataset):(Array.isArray(this.options.columnTree)||Array.isArray(this.options.rowTree))&&(t.layoutMap=new KN(this),e?.[0]?.constructor!==Array&&(this.flatDataToObjects=new $N({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=e?.bottomFrozenRowCount??0,t.rightFrozenColCount=e?.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 XD({dataValue:s,...n.internalProps.layoutMap.getCellHeaderPaths(e,i)},t,gt)}return s}getCellValue(t,e){if(this.internalProps.layoutMap.isHeader(t,e)){const{caption: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{caption: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.invalidate()}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(at(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.records.length;t++){const e=this.records[t].splice(i.sourceIndex-this.rowHeaderLevelCount,i.moveSize);e.unshift(i.targetIndex-this.rowHeaderLevelCount,0),Array.prototype.splice.apply(this.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.records.splice(i.sourceIndex-this.columnHeaderLevelCount,i.moveSize);t.unshift(i.targetIndex-this.columnHeaderLevelCount,0),Array.prototype.splice.apply(this.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===r.expand?this.fireListeners(yj.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:r.collapse}):i===r.collapse&&this.fireListeners(yj.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:r.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),cellType:this.getCellType(t,e),isPivotCorner:this.isCornerHeader(t,e)}}},t.TYPES=c,t.clearGlobal=function(){kN()},t.core=EN,t.data=QD,t.getIcons=function(){return tW()},t.register=IN,t.themes=Vi,t.version="0.9.3-alpha.1"}));
17
+ ***************************************************************************** */function jW(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 NW=Fw();class GW extends rC{type="chart";chartInstance;activeChartInstance;active;cacheCanvas;constructor(t){super(t),this.numberType=NW,t.chartInstance?this.chartInstance=t.chartInstance:(t.chartInstance=this.chartInstance=new t.ClassType(t.spec,{renderCanvas:t.canvas,mode:"desktop-browser",canvasControled:!1,viewBox:t.viewBox,interactive:!1,animation:!1}),this.chartInstance.renderSync())}activate(t){this.active=!0;const{x1:e,y1:i,x2:n,y2:r}=this.attribute.viewBox,o=t.scenegraph.tableGroup.globalAABBBounds,s=new je;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,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),GW.temp&&t.scenegraph.updateChartState(e?.datum)})),this.activeChartInstance.on("brushEnd",(e=>{console.log("brushEnd captured",e),t.scenegraph.updateChartState(e?.value?.inBrushData),GW.temp=0,setTimeout((()=>{GW.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}}const KW=Symbol.for("ChartRender");let UW=class{type;numberType=NW;drawShape(t,e,i,n,r,o,s,a){const l=Pv(t,o?.theme).group,{dataId:h,data:c,viewBox:u}=t.attribute,{width:d=l.width,height:p=l.height}=t.attribute,{chartInstance:f,active:g,cacheCanvas:y,activeChartInstance:m}=t;if(!g&&y)e.drawImage(y,i,n,d,p);else if(m)if("string"==typeof h)m.updateDataSync(h,c??[]);else for(const t in h){const e=h[t];m.updateDataSync(t,e?c?.filter((t=>t.hasOwnProperty(e)))??[]:c??[])}else{const{axes:e}=t.attribute;if(e.forEach(((t,e)=>{if("linear"===t.type){f._chart._components[e]._domain={min:t.range?.min??0,max:t.range?.max??0}}else if("band"===t.type){const i=f._chart._components[e];i._spec.domain=t.domain.slice(0),i.updateScaleDomain()}})),f.updateViewBox({x1:u.x1-t.getRootNode().table.scrollLeft,x2:u.x2-t.getRootNode().table.scrollLeft,y1:u.y1-t.getRootNode().table.scrollTop,y2:u.y2-t.getRootNode().table.scrollTop}),"string"==typeof h)f.updateDataSync(h,c??[]);else for(const t in h){const e=h[t];f.updateDataSync(t,e?c?.filter((t=>t.hasOwnProperty(e)))??[]:c??[])}const i=f.getStage();t.cacheCanvas=i.toCanvas()}}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);const s=Pv(t,n?.theme).group,{scrollX:a=s.scrollX,scrollY:l=s.scrollY}=t.attribute;let h;(a||l)&&r.translate(a,l),n&&n.drawingCb&&(h=n.drawingCb()),h&&h.then?h.then((()=>{o?r.restore():r.highPerformanceRestore()})):o?r.restore():r.highPerformanceRestore()}};UW=jW([jy()],UW);let VW=class{time=Tm.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()}}};VW=jW([jy()],VW);let $W=class{time=Tm.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 YW(t,e,n){const{highlightScope:r,disableHeader:o,cellPos:s}=t.hover;if(!t.table.isHeader(e,n)||!o){if(r===i.single&&s.col===e&&s.row===n)return"cellBgColor";if(r===i.column&&s.col===e)return"inlineColumnBgColor";if(r===i.row&&s.row===n)return"inlineRowBgColor";if(r===i.cross){if(s.col===e&&s.row===n)return"cellBgColor";if(s.col===e)return"inlineColumnBgColor";if(s.row===n)return"inlineRowBgColor"}}}$W=jW([jy()],$W);let XW=class{time=Tm.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)}};XW=jW([jy()],XW);let qW=class{time=Tm.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:y=l.strokeArrayWidth,lineWidth:m=l.lineWidth,strokeColor:b=l.stroke}=t.attribute;if(!f||!Array.isArray(y)&&0===m)return;let v,w;if(Array.isArray(g)||Array.isArray(y)){if("number"==typeof m&&1&m||Array.isArray(y)&&y.some((t=>1&t))){i=Math.floor(i)+.5,n=Math.floor(n)+.5;const{width:e,height:r}=rz(t,Math.ceil(d),Math.ceil(p));v=e,w=r}else v=Math.ceil(d),w=Math.ceil(p);ZW(t,e,i,n,l,f,y||m,g||b,v,w)}}};function ZW(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),y=Array.isArray(a)||d.isSplitDraw;e.setStrokeStyle(t,t.attribute,i,n,r);let m=!1;e.getLineDash().length&&(m=!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)),!y&&!m||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)),!y&&!m||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)),!y&&!m||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)),!y&&!m||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),y||m||(!p&&d.width&&(e.lineWidth=d.width),e.stroke())}qW=jW([jy()],qW);let JW=class{time=Tm.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:y=l.strokeArrayWidth}=t.attribute;f&&Array.isArray(p)&&p.length&&!Array.isArray(g)&&!Array.isArray(y)&&(d.doStroke=!1)}};JW=jW([jy()],JW);let QW=class{time=Tm.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:y=l.lineWidth}=t.attribute;if(!p||!Array.isArray(d)||!d.length||Array.isArray(f)||Array.isArray(g))return;let m,b,{width:v=l.width,height:w=l.height}=t.attribute;if(v=Math.ceil(v),w=Math.ceil(w),1&y){i=Math.floor(i)+.5,n=Math.floor(n)+.5;const{width:e,height:r}=rz(t,Math.ceil(v),Math.ceil(w));m=e,b=r}else m=Math.ceil(v),b=Math.ceil(w);e.setStrokeStyle(t,t.attribute,i,n,l),e.beginPath(),e.moveTo(i,n),e.lineTo(i+m,n),e.lineDashOffset=e.currentMatrix.e/e.currentMatrix.a,e.stroke(),e.beginPath(),e.moveTo(i+m,n),e.lineTo(i+m,n+b),e.lineDashOffset=e.currentMatrix.f/e.currentMatrix.d,e.stroke(),e.beginPath(),e.moveTo(i,n+b),e.lineTo(i+m,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()}};QW=jW([jy()],QW);let tz=class{time=Tm.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:y=l.strokeArrayWidth,strokeArrayColor:m=l.strokeArrayColor}=t.attribute;f&&Array.isArray(g)&&!g.length&&!Array.isArray(m)&&!Array.isArray(y)&&1&p&&(d.doStroke=!1)}};tz=jW([jy()],tz);let ez=class{time=Tm.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:y=l.strokeArrayColor}=t.attribute,{width:m=l.width,height:b=l.height}=t.attribute;if(p&&Array.isArray(f)&&!f.length&&!Array.isArray(y)&&!Array.isArray(g)&&1&d){const{width:r,height:o}=rz(t,Math.ceil(m),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()}}};ez=jW([jy()],ez);let iz=class{time=Tm.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=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=YW(e.stateManeger,n,r);!t||i&&"cellBgColor"!==t||(i=t)}else"cell"===t.role&&(i=YW(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),nW(i,n,t.col,t.row,e)}(t,t.stage.table);e&&(t.oldColor=t.attribute.fill,t.attribute.fill=e)}}};iz=jW([jy()],iz);let nz=class{time=Tm.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 rz(t,e,i){const n=t.stage.table;if("cell"===t.role){let r=t.col,o=t.row;const s=RH(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}}nz=jW([jy()],nz);let oz=class{time=Tm.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)}};oz=jW([jy()],oz);let sz=class{time=Tm.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:y=l.strokeArrayWidth,lineWidth:m=l.lineWidth,strokeColor:b=l.stroke}=t.attribute;f&&(Array.isArray(y)||0!==m)&&(Array.isArray(f)||Array.isArray(g)||Array.isArray(y))&&(("number"==typeof m&&1&m||Array.isArray(y)&&y.some((t=>1&t)))&&(i=Math.floor(i)+.5,n=Math.floor(n)+.5),ZW(t,e,i,n,l,f,y||m,g||b,Math.ceil(d),Math.ceil(p)))}};sz=jW([jy()],sz);var az=new Oy(((t,e,i,n)=>{i(QA)?n(QA).to(oz).inSingletonScope():(t(oz).toSelf().inSingletonScope(),t(jC).toService(oz)),i(tT)?n(tT).to(sz).inSingletonScope():(t(sz).toSelf().inSingletonScope(),t(jC).toService(sz)),t(qW).toSelf().inSingletonScope(),t(DC).toService(qW),t(XW).toSelf().inSingletonScope(),t(DC).toService(XW),t(UW).toSelf().inSingletonScope(),t(KW).to(UW),t(pA).to(UW),t(VW).toSelf().inSingletonScope(),t(FC).toService(VW),t($W).toSelf().inSingletonScope(),t(FC).toService($W),t(JW).toSelf().inSingletonScope(),t(DC).toService(JW),t(QW).toSelf().inSingletonScope(),t(DC).toService(QW),t(tz).toSelf().inSingletonScope(),t(DC).toService(tz),t(ez).toSelf().inSingletonScope(),t(DC).toService(ez),t(iz).toSelf().inSingletonScope(),t(DC).toService(iz),t(nz).toSelf().inSingletonScope(),t(DC).toService(nz)}));function lz(t,e,i,n){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=hz(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?hz(n,0,t.rowCount-1,t,!1):hz(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;let i=0;for(let e=0;e<t.colCount;e++)i+=t.getColWidth(e);const n=e/i;for(let i=0;i<t.colCount;i++){let r;r=i===t.colCount-1?e-t.getColsWidth(0,t.colCount-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&&(n+=r),i+=r}if(i<e&&i-n>0){const r=(e-n)/(i-n);for(let e=t.frozenColCount;e<t.colCount;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 hz(t,e,i,n,o){const{layoutMap:s,transpose:a}=n.internalProps,{width:l}=s?.getColumnWidthDefined(t)??{};if(a){if("standard"===n.widthMode){if(n.isRowHeader(t,0)||n.isCornerHeader(t,0))return Array.isArray(n.defaultHeaderColWidth)?n.defaultHeaderColWidth[t]??n.defaultColWidth:n.defaultHeaderColWidth;if("auto"!==l)return"string"==typeof l?NF(l,n.internalProps.calcWidthContext):l||n.defaultColWidth}else if("adaptive"===n.widthMode&&0===t&&"auto"!==l&&s?.showHeader){if("string"==typeof l)return NF(l,n.internalProps.calcWidthContext);if(l)return l}}else if("auto"!==l&&"autoWidth"!==n.widthMode&&!o)return"string"==typeof l?NF(l,n.internalProps.calcWidthContext):l||n.getColWidth(t);return function(t,e,i,n,o,s){let a=0,l=1;n-i>5e3&&(l=Math.ceil((n-i)/5e3));if(s.isPivotChart()&&e>=s.rowHeaderLevelCount){if(s.internalProps.layoutMap.indicatorsAsCol)return s.defaultColWidth;{const t=s.internalProps.layoutMap.getOptimunWidthForChart(e);if(t>0)return t}}for(let o=i;o<=n;o+=l){const i=cz(e,o,s);if("number"==typeof i){a=Math.max(i,a);continue}const n=t;if("number"==typeof n&&"standard"===s.widthMode){a=Math.max(n,a);continue}const l=s.isHeader(e,o)?s._getHeaderLayoutMap(e,o)?.headerType:s.getBodyColumnType(e,o);if("text"!==l&&"link"!==l&&"progressbar"!==l){a=Math.max(a,s.getColWidth(e)||0);continue}let h=0;const c=s.internalProps.layoutMap;if(c.isHeader(e,o)){const t=c.getHeader(e,o);if("only-body"===t?.define?.columnWidthComputeMode)continue;t?.hierarchyLevel&&(h=(t.hierarchyLevel??0)*(c.rowHierarchyIndent??0))}else{const t=s.getBodyColumnDefine(e,o);if(t?.tree){const t=s.dataSource.getIndexKey(s.getRecordIndexByRow(e,o));h=Array.isArray(t)&&s.getHierarchyState(e,o)!==r.none?(t.length-1)*(c.hierarchyIndent??0):0}}const u=uz(e,o,s);a=Math.max(u+h,a)}const h=s.getMinColWidth(e),c=s.getMaxColWidth(e);if(a<h)return h;if(a>c)return c;return a}(l,t,e,i,0,n)}function cz(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:dz(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 uz(t,e,i){let n=0;const r=i.getCellValue(t,e),o=i._getCellStyle(t,e);let s=0;const l=i.getBodyColumnDefine(t,e);if("body"!==i.getCellType(t,e)||(!!l?.icon||!!l?.tree)){const n=i.getCellIcons(t,e);n?.forEach((t=>{t.positionType!==a.absoluteRight&&(s+=(t.width??0)+(t.marginLeft??0)+(t.marginRight??0))}))}let h=1;if(i.isHeader(t,e)||i.getBodyColumnDefine(t,e).mergeCell){const n=i.getCellRange(t,e);h=n.end.col-n.start.col+1}const c=cF(nW("padding",o,t,e,i)),u=c[1]+c[3],d=nW("fontSize",o,t,e,i),p=nW("fontFamily",o,t,e,i),f=T(r).split("\n")||[];return f.length>=1?f.forEach((t=>{const e=i.measureText(t.slice(0,i.options.maxCharactersNumber||200),{fontSize:d,fontFamily:p}).width;n=Math.max((e+u+4+s)/h,n)})):n=Math.max((u+4+s)/h,n),!1!==i.internalProps.limitMaxAutoWidth&&(n=Math.min("number"==typeof i.internalProps.limitMaxAutoWidth?i.internalProps.limitMaxAutoWidth:450,n)),n}function dz(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 pz=new bW({autoWrapText:!0}),fz=new b_({width:0,height:0,textConfig:[]});function gz(t,e,i){const n="undefined"!=typeof window?window.performance.now():0;if("autoHeight"===t.heightMode){if(e=e??0,i=i??t.rowCount-1,0===e&&i===t.rowCount-1)t._clearRowRangeHeightsMap();else for(let n=e;n<=i;n++)t._clearRowRangeHeightsMap(n);for(let i=e;i<t.columnHeaderLevelCount;i++){const e=yz(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||!mz(t))if((t.internalProps.transpose||t.isPivotTable()&&!t.internalProps.layoutMap.indicatorsAsCol)&&mz(t))for(let n=Math.max(e,t.columnHeaderLevelCount);n<=i;n++){t._clearRowRangeHeightsMap(n);const e=yz(n,0,t.rowHeaderLevelCount,t);t.setRowHeight(n,e)}else for(let n=Math.max(e,t.columnHeaderLevelCount);n<=i;n++){t._clearRowRangeHeightsMap(n);const e=yz(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)}(yz(t.columnHeaderLevelCount,0,t.colCount-1,t),t.columnHeaderLevelCount,t.rowCount-1,t)}}else 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)}}console.log("computeRowsHeight time:",("undefined"!=typeof window?window.performance.now():0)-n)}function yz(t,e,i,n){let r=0;for(let o=e;o<=i;o++){const e=bz(o,t,n);if("number"==typeof e){r=Math.max(e,r);continue}const i=vz(o,t,n);r=Math.max(i,r)}return r}function mz(t){const{layoutMap:e}=t.internalProps,i=t.columnHeaderLevelCount;for(let n=0;n<t.colCount;n++){const r=e.isHeader(n,i),o=r?e.getHeader(n,i):e.getBody(n,i);if("function"==typeof o.style||"function"==typeof o.icon||"function"==typeof o.headerIcon||(r?o.define?.headerCustomRender:o.define?.customRender)||(r?"function"==typeof o.define?.headerIcon:"function"==typeof o.define?.icon))return!1;const s=t._getCellStyle(n,i);if("function"==typeof s.padding||"function"==typeof s.fontSize||"function"==typeof s.lineHeight||!0===s.autoWrapText)return!1}return!0}function bz(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:dz(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 vz(t,e,i){let n=0;const r=i.getCellValue(t,e),o=i._getCellStyle(t,e);let s=0,l=0;const h=[];let c=0;const u=[];let d=0;const p=i.getBodyColumnDefine(t,e);if("body"!==i.getCellType(t,e)||(!!p?.icon||!!p?.tree)){const n=i.getCellIcons(t,e);n?.forEach((t=>{t.positionType!==a.absoluteRight&&t.positionType!==a.inlineFront&&t.positionType!==a.inlineEnd?(l+=(t.width??0)+(t.marginLeft??0)+(t.marginRight??0),s=Math.max(s,t.height??0)):t.positionType===a.inlineFront?(h.push(t),c=Math.max(c,(t.height??0)+(t.marginLeft??0)+(t.marginRight??0))):t.positionType===a.inlineEnd&&(u.push(t),d=Math.max(d,(t.height??0)+(t.marginLeft??0)+(t.marginRight??0)))}))}let f=1;if(i.isHeader(t,e)||i.getBodyColumnDefine(t,e).mergeCell){const n=i.getCellRange(t,e);f=n.end.row-n.start.row+1}const g=cF(nW("padding",o,t,e,i)),y=nW("fontSize",o,t,e,i),m=nW("fontStyle",o,t,e,i),b=nW("fontWeight",o,t,e,i),v=nW("lineHeight",o,t,e,i)??y,w=nW("fontFamily",o,t,e,i),C=nW("autoWrapText",o,t,e,i),x=T(r).split("\n")||[];if(h.length||u.length){const e=Object.assign({text:r?.toString(),fontFamily:w,fontSize:y,fontStyle:m,fontWeight:b,lineHeight:v});e.textBaseline="middle";const o=[...h.map((t=>xW(t))),e,...u.map((t=>xW(t)))];fz.setAttributes({width:i.getColWidth(t)-(g[1]+g[3])-l,height:0,textConfig:o}),n=fz.AABBBounds.height()}else if(C){const e=i.getColWidth(t)-(g[1]+g[3])-l;pz.setAttributes({maxLineWidth:e,text:x,fontSize:y,fontStyle:m,fontWeight:b,fontFamily:w}),n=pz.AABBBounds.height()}else n=x.length*v;return(Math.max(n,s)+g[0]+g[2])/f}const wz=new BH({});wz.role="empty";const Cz={},xz={};function _z(t,e,i,n,r,o,s,a,l,h,c,u,d,p,f,g){const y=it(xz,Cz)[c],m=rW("padding",f._getCellStyle(r,o),r,o,f);A(m)&&(l=m),t||((t=new BH({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 GW({stroke:!1,x:l[3],y:l[0],canvas:f.canvas,spec:u,ClassType:y,width:s-l[3]-l[1],height:a-l[2]-l[0],chartInstance:d,dataId:p,data:f.getCellValue(r,o),cellPadding:l,viewBox:{x1:Math.ceil(t.globalAABBBounds.x1+l[3]+f.scrollLeft),x2:Math.ceil(t.globalAABBBounds.x1+s-l[1]+f.scrollLeft),y1:Math.ceil(t.globalAABBBounds.y1+l[0]+f.scrollTop),y2:Math.ceil(t.globalAABBBounds.y1+a-l[2]+f.scrollTop)},axes:f.internalProps.layoutMap.getChartAxes(r,o)});return t.appendChild(b),f.internalProps.layoutMap.setChartInstance(r,o,b.chartInstance),t}function Sz(t,e,i,n,r,o,s,l,h,c,u,d,p,f,g,y){const m=t._getCellStyle(r,o),b=rW("padding",m,r,o,t);A(b)&&(c=b),y?.text?.textAlign&&(u=y?.text?.textAlign),y?.text?.textBaseline&&(d=y?.text?.textBaseline);const v="auto"===s,C=m.autoWrapText??t.internalProps.autoWrapText,x=m.lineClamp,_=new BH({x:i,y:n,width:l,height:h,lineWidth:y?.group?.lineWidth??void 0,fill:y?.group?.fill??void 0,stroke:y?.group?.stroke??void 0,strokeArrayWidth:y?.group?.strokeArrayWidth??void 0,strokeArrayColor:y?.group?.strokeArrayColor??void 0,cursor:y?.group?.cursor??void 0,lineCap:"square",clip:!0});if(_.role="cell",_.col=r,_.row=o,e.addChild(_),f&&_.appendChild(f),g){const e=t.getCellValue(r,o);let i;if(p&&(i=t.getCellIcons(r,o)),function(t,e,i,n,r,o,s,l,h,c,u,d,p,f){const g=[],y=[],m=[],b=[],v=[],C=[],x=[],_=[];let S,A,T=0,B=0,R=0,M=0,P=0,E=0;if(Array.isArray(e)&&0!==e.length){let H;if(e.forEach((t=>{switch(t.positionType){case a.left:g.push(t);break;case a.right:y.push(t);break;case a.contentLeft:m.push(t);break;case a.contentRight:b.push(t);break;case a.absoluteRight:_.push(t);break;case a.inlineFront:v.push(t);break;case a.inlineEnd:C.push(t)}})),g.forEach((e=>{const i=CW(e,void 0,t.col,t.row,p);i.role="icon-left",i.name=e.name,i.setAttribute("x",T+(i.attribute.marginLeft??0)),T+=i.AABBBounds.width()+(i.attribute.marginLeft??0)+(i.attribute.marginRight??0),B=Math.max(B,i.AABBBounds.height()),t.appendChild(i)})),y.forEach((e=>{const i=CW(e,void 0,t.col,t.row,p);i.role="icon-right",i.name=e.name,i.setAttribute("x",R+(i.attribute.marginLeft??0)),R+=i.AABBBounds.width()+(i.attribute.marginLeft??0)+(i.attribute.marginRight??0),M=Math.max(M,i.AABBBounds.height()),t.appendChild(i)})),x.forEach((e=>{const i=CW(e,void 0,t.col,t.row,p);i.role="icon-absolute-left",i.name=e.name,i.setAttribute("x",P+(i.attribute.marginLeft??0)),P+=i.AABBBounds.width()+(i.attribute.marginLeft??0)+(i.attribute.marginRight??0),t.appendChild(i)})),_.forEach((e=>{const i=CW(e,void 0,t.col,t.row,p);i.role="icon-absolute-right",i.name=e.name,i.setAttribute("x",E+(i.attribute.marginLeft??0)),E+=i.AABBBounds.width()+(i.attribute.marginLeft??0)+(i.attribute.marginRight??0),t.appendChild(i)})),0===v.length&&0===C.length){const t=w(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:h-(n[1]+n[3])-T-R,textBaseline:"top",heightLimit:o?-1:c-(n[0]+n[2]),pickable:!1,autoWrapText:s,lineClamp:l},a=new bW(f.text?Object.assign({},f.text,e):e);a.name="text",H=a}else{const e=Object.assign({text:i?.toString()},t.parent?.theme?.userTheme?.text||{});f.text&&Object.assign(e,f.text),e.textBaseline="middle";const s=[...v.map((t=>xW(t))),e,...C.map((t=>xW(t)))];s[0].textAlign=u;const a=new b_({width:r?0:h-(n[1]+n[3])-T-R,height:o?0:c-(n[0]+n[2]),textConfig:s,verticalDirection:o?"top":d});a.name="text",H=a,a.bindIconEvent()}if(0!==m.length||0!==b.length){const e=new vW({x:0,y:0,fill:!1,stroke:!1});e.name="content",e.setCellContentOption({autoWidth:r,autoHeight:o,cellWidth:h-(n[1]+n[3])-T-R,cellHeight:c-(n[0]+n[2]),align:u,baseline:d}),m.forEach((i=>{const n=CW(i,void 0,t.col,t.row,p);n.role="icon-content-left",n.name=i.name,e.addLeftOccupyingIcon(n)})),b.forEach((i=>{const n=CW(i,void 0,t.col,t.row,p);n.role="icon-content-right",n.name=i.name,e.addRightOccupyingIcon(n)})),e.addContent(H),t.appendChild(e),e.layout(),S=e.AABBBounds.width(),A=e.AABBBounds.height()}else t.firstChild?t.insertBefore(H,t.firstChild):t.appendChild(H),S=H.AABBBounds.width(),A=H.AABBBounds.height()}else if(i){const e=w(i).replace(/\r?\n/g,"\n").replace(/\r/g,"\n").split("\n"),a=wW(t.col,t.row,p),u={text:1!==e.length||s?e:e[0],maxLineWidth:r?1/0:h-(n[1]+n[3]+a),textBaseline:"top",autoWrapText:s,lineClamp:l,heightLimit:o?-1:c-(n[0]+n[2]),pickable:!1,dx:a},d=new bW(f.text?Object.assign({},f.text,u):u);d.name="text",t.appendChild(d),S=d.AABBBounds.width(),A=d.AABBBounds.height()}const H=r?T+S+R:h-(n[1]+n[3]),L=o?Math.max(B,A,M):c-(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+H-R+n[3]):"icon-absolute-right"===t.role?t.setAttribute("x",t.attribute.x+H-E+n[3]+n[1]):"content"!==t.name&&"text"!==t.name||("center"===u&&"richtext"!==t.type?t.setAttribute("x",n[3]+T+(H-T-R)/2):"right"===u&&"richtext"!==t.type?t.setAttribute("x",n[3]+H-R):t.setAttribute("x",n[3]+T))})),t.forEachChildren((t=>{"middle"===d?t.setAttribute("y",n[0]+(L-t.AABBBounds.height())/2):"bottom"===d?t.setAttribute("y",n[0]+L-t.AABBBounds.height()):t.setAttribute("y",n[0])})),t.setAttributes({width:H+n[1]+n[3],height:L+n[0]+n[2]})}(_,i,e,c,v,!1,C,"number"==typeof x?x:void 0,l,h,u,d,t,y),y?._vtable?.marked){const t=rS({x:_.attribute.width,y:0,startAngle:Math.PI/2,endAngle:Math.PI,outerRadius:6,fill:"#3073F2",pickable:!1});t.name="mark",_.appendChild(t)}}return f&&_.setAttributes({width:Math.max(_.attribute.width,f.attribute.width),height:Math.max(_.attribute.height,f.attribute.height)}),_}const Az=tW();function Tz(t,e,i){t.then((()=>{i(),e.scenegraph.updateNextFrame()})).catch((t=>{console.error(t)}))}function Bz(t,e,i,n,r,o,s,a,l,h,c,u,d,p,f,g,y,m){let b;if("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||Pi.test(o))&&(m?(m.text.fill=nW("linkColor",s,n,r,i),m.group.cursor="pointer"):m={text:{fill:nW("linkColor",s,n,r,i)},group:{cursor:"pointer"}})}if(s){const t=i.getCellOriginValue(n,r),e=s(i,t);e&&(m?m.group.fill=e:m={group:{fill:e}})}let v,w,C,x=!0;if("body"!==i.getCellType(n,r)?(w=e?.headerCustomRender,C=e?.headerCustomLayout):(w=e?.customRender||i.customRender,C=e?.customLayout),C||w){const t=SW(C,w,n,r,i.getColWidth(n),i.getRowHeight(r),!1,"autoHeight"===i.heightMode,i);v=t.elementsGroup,x=t.renderDefault}b=Sz(i,h,0,c,n,r,o,a,l,u,d,p,f,v,x,m),g&&(b.mergeCol=y.end.col,b.mergeRow=y.end.row);const _=i.internalProps.layoutMap.getAxisConfigInPivotChart(n,r);if(_){const t=new KD(_,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=rW("padding",d._getCellStyle(n,r),n,r,d);A(f)&&(h=f),p?.text?.textAlign&&(c=p?.text?.textAlign),p?.text?.textBaseline&&(u=p?.text?.textBaseline);const g=new BH({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 y=d.getCellValue(n,r),m=dS({x:h[3],y:h[0],width:o-h[1]-h[3],height:s-h[0]-h[2],image:y??oW.damage_pic.svg,cursor:"pointer"});return m.name="image",m.keepAspectRatio=a,m.successCallback=a||l?()=>{const t=m.resources.get(m.attribute.image).data;if(l&&sW(n,r,t.width,t.height,d.scenegraph,h),a){const{width:e,height:i}=eW(t.width,t.height,g.attribute.width-h[1]-h[3],g.attribute.height-h[0]-h[2]),n=iW(0,0,g.attribute.width,g.attribute.height,e,i,c,u,h);m.setAttributes({x:n.x,y:n.y,width:e,height:i})}d.scenegraph.updateNextFrame()}:()=>{aW(g,n,r,d)},m.failCallback=()=>{const t=tW();m.image=t.damage_pic.svg},g.appendChild(m),g}(h,0,c,n,r,i.getColWidth(n),i.getRowHeight(r),e.keepAspectRatio,e.imageAutoSizing,u,d,p,i,m);else if("video"===t)b=function(t,e,i,n,r,o,s,a,l,h,c,u,d,p){const f=rW("padding",d._getCellStyle(n,r),n,r,d);A(f)&&(h=f),p?.text?.textAlign&&(c=p?.text?.textAlign),p?.text?.textBaseline&&(u=p?.text?.textBaseline);const g=new BH({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 y=d.getCellValue(n,r),m=document.createElement("video");m.addEventListener("loadeddata",(()=>{l&&sW(n,r,m.videoWidth,m.videoHeight,d.scenegraph,h);const t=g.attribute.width,e=g.attribute.height;if(a){const{width:i,height:n}=eW(m.videoWidth,m.videoHeight,t-h[1]-h[3],e-h[0]-h[2]),r=iW(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 pW({x:o-i/2,y:s-i/2,width:i,height:i,image:Az.play.svg,cursor:Az.play.cursor});p.name="play-icon",g.appendChild(p),d.scenegraph.updateNextFrame()})),m.onerror=()=>{b.image=Az.damage_pic.svg},m.src=y,m.setAttribute("preload","auto");const b=dS({x:h[3],y:h[0],width:o-h[1]-h[3],height:s-h[2]-h[0],image:m,cursor:"pointer"});return b.name="image",g.appendChild(b),g}(h,0,c,n,r,i.getColWidth(n),i.getRowHeight(r),e.keepAspectRatio,e.imageAutoSizing,u,d,p,i,m);else if("chart"===t){const t=i.internalProps.layoutMap.getChartInstance(n,r);b=_z(null,h,0,c,n,r,i.getColWidth(n),i.getRowHeight(r),u,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),s=i.getCellValue(n,r),f=i.getCellOriginValue(n,r);b=Sz(i,h,0,c,n,r,o,a,l,u,d,p,!1,null,!0,m);const g=lW(e,t,o,s,f,n,r,0,i);b.insertBefore(g,b.firstChild)}else"sparkline"===t&&(b=uW(null,h,0,c,n,r,a,l,u,i,m));return b}function Rz(t,e,i,n){const r=i.scenegraph.highPerformanceGetCell(t,e,!0),o=i.isHeader(t,e)?i._getHeaderLayoutMap(t,e).headerType:i.getBodyColumnType(t,e),s=i.getCellType(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=qF(i._getCellStyle(t,e),i,t,e,nW).theme,p=d._vtable.padding,f=d._vtable.textAlign,g=d._vtable.textBaseline;let y,m,b;i.internalProps?.dataConfig?.mappingRules&&"body"===s&&i.internalProps?.dataConfig?.mappingRules?.forEach(((t,e)=>{t.bgColor&&(y=t.bgColor.mapping)})),"body"!==s?(a?.headerCustomRender,a?.headerCustomLayout):(a?.customRender||i.customRender,a?.customLayout),h?(m=i.getColsWidth(h.start.col,h.end.col),b=i.getRowsHeight(h.start.row,h.end.row)):(m=i.getColWidth(t),b=i.getRowHeight(e));const v=i.getCellValue(t,e);st(v)?(r.removeAllChild(),Tz(v,i,Mz.bind(null,o,a,i,t,e,y,m,b,r,p,f,g,u,l,h,n,d))):c=Mz(o,a,i,t,e,y,m,b,r,p,f,g,u,l,h,n,d)}else c=new BH({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));return c}function Mz(t,e,i,n,r,o,s,a,l,h,c,u,d,p,f,g,y){const m=Bz(t,e,i,n,r,i.getColWidth(n),o,s,a,g?i.scenegraph.getColGroup(n):l.parent,g?0:l.attribute.y,h,c,u,d,p,f,y);return g||(l.parent.insertAfter(m,l),l.parent.removeChild(l),i.scenegraph?.proxy.cellCache.get(n)&&i.scenegraph?.proxy.cellCache.set(n,m)),m}function Pz(t,e,i,n,r,o,s,a,l,h){let c,u,d,p,f=0;a.internalProps?.dataConfig?.mappingRules&&"body"===l&&a.internalProps?.dataConfig?.mappingRules?.forEach(((t,e)=>{t.bgColor&&(p=t.bgColor.mapping)}));let g=0;t.colHeight&&(g=t.colHeight);for(let y=n;y<=r;y++){const n=y,r="body"!==l?a.getHeaderDefine(e,n):a.getBodyColumnDefine(e,n),m="body"!==l||(!!r?.icon||!!r?.tree),b=qF(a._getCellStyle(e,n),a,e,n,nW).theme;b.group.width=i,b.group.height=Array.isArray(s)?s[n]:s,b._vtable.padding&&(c=b._vtable.padding),b.text.textAlign&&(u=b.text.textAlign),b.text.textBaseline&&(d=b.text.textBaseline),"body"===l||b.group.fill||(b.group.fill="#fff");let v=i,w=a.getRowHeight(n);const C=(a.isHeader(e,n)?a._getHeaderLayoutMap(e,n).headerType:a.getBodyColumnType(e,n))||"text";let x,_,S;if(("body"!==l||r?.mergeCell)&&(_=a.getCellRange(e,n),S=_.start.col!==_.end.col||_.start.row!==_.end.row,S&&(v=0,w=0,x=o.get(`${_.start.col},${_.start.row};${_.end.col},${_.end.row}`),!x))){for(let t=_.start.col;t<=_.end.col;t++)v+=a.getColWidth(t);for(let t=_.start.row;t<=_.end.row;t++)w+=a.getRowHeight(t);o.set(`${_.start.col},${_.start.row};${_.end.col},${_.end.row}`,{x:0,y:g,cellWidth:v,cellHeight:w})}if(x){const i=x.cellHeight/(_.end.row-_.start.row+1),r=new BH({x:0,y:g,width:0,height:i,visible:!1,pickable:!1});r.role="shadow-cell",r.col=e,r.row=n,r.mergeCol=_.start.col,r.mergeRow=_.start.row,t.addChild(r),t.updateColumnRowNumber(n),t.updateColumnHeight(i),_=a.getCellRange(e,n),g+=i,f=Math.max(f,x.cellWidth)}else{const o=a.getCellValue(e,n);if(st(o)){Tz(o,a,Bz.bind(null,C,r,a,e,n,i,p,v,w,t,g,c,u,d,m,S,_,b)),t.updateColumnRowNumber(n);const s=S?a.getRowHeight(n)/(_.end.row-_.start.row+1):a.getRowHeight(n);t.updateColumnHeight(s),g+=s}else{const o=Bz(C,r,a,e,n,i,p,v,w,t,g,c,u,d,m,S,_,b);t.updateColumnRowNumber(n);const s=S?o.attribute.height/(_.end.row-_.start.row+1):o.attribute.height;t.updateColumnHeight(s),g+=s}}if(h&&n>h)break}return t.setAttribute("width",i),{width:i,height:g}}function Ez(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 BH({x:e+f,y:i,width:r,height:0,clip:!1,pickable:!1});p.role="column",p.col=c,t.addChild(p);const{width:y,height:m}=Pz(p,n,r,o,s,l.scenegraph.mergeMap,"columnHeader"===a?d??u:u,l,a,h);f+=y,g=Math.max(g,m)}t.setAttribute("width",f),t.setAttribute("height",g)}async function Hz(t,e,i,n){if("left"===e&&n.colEnd+t>n.bodyRightCol?t=n.bodyRightCol-n.colEnd:"right"===e&&n.colStart-t<n.bodyLeftCol&&(t=n.colStart-n.bodyLeftCol),n.table.scenegraph.bodyGroup,t<n.colEnd-n.colStart){const r="left"===e?n.colStart:n.colEnd-t+1,o="left"===e?n.colStart+t-1:n.colEnd,s="left"===e?n.colEnd+1:n.colStart-t,a="left"===e?n.colEnd+t:n.colStart-1;lz(n.table,s,a),function(t,e,i,n){for(let r=t;r<=e;r++)n.table.scenegraph.bodyGroup.childrenCount>0&&Iz(n.table.scenegraph.bodyGroup,i,n),n.table.scenegraph.colHeaderGroup.childrenCount>0&&Iz(n.table.scenegraph.bodyGroup,i,n),n.table.scenegraph.bottomFrozenGroup.childrenCount>0&&Iz(n.table.scenegraph.bodyGroup,i,n)}(r,o,e,n);const l=Math.max(n.bodyLeftCol,i-1*n.screenColCount),h=Math.min(n.bodyRightCol,i+2*n.screenColCount);n.colStart="left"===e?n.colStart+t:n.colStart-t,n.colEnd="left"===e?n.colEnd+t:n.colEnd-t,Dz(s,n),Oz(l,h,n),n.currentCol="left"===e?n.currentCol+t:n.currentCol-t,n.totalCol="left"===e?n.totalCol+t:n.totalCol-t,n.referenceCol=n.colStart+Math.floor((n.colEnd-n.colStart)/2),n.colUpdatePos=s,n.colUpdateDirection=e,n.table.scenegraph.stage.render(),await n.progress()}else{const r="left"===e?n.colStart+t:n.colStart-t,o="left"===e?n.colEnd+t:n.colEnd-t;lz(n.table,r,o);const s=n.table.getColsWidth(n.bodyLeftCol,r-1);console.log("distStartColY",n.bodyLeftCol,r-1,s),function(t,e,i,n){n.table.scenegraph.colHeaderGroup.forEachChildren(((r,o)=>{"group"===r.type&&Lz(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&&Lz(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&&Lz(r,"left"===i?r.col+e:r.col-e,0===o?t:r._prev.attribute.x+n.table.getColWidth(r._prev.col))}))}(s,t,e,n);const a=Math.max(n.bodyLeftCol,i-1*n.screenRowCount),l=Math.min(n.bodyRightCol,i+2*n.screenRowCount);n.colStart=r,n.colEnd=o,Dz(r,n),Oz(a,l,n),n.currentCol="left"===e?n.currentCol+t:n.currentCol-t,n.totalCol="left"===e?n.totalCol+t:n.totalCol-t,n.referenceCol=n.colStart+Math.floor((n.colEnd-n.colStart)/2),n.colUpdatePos=n.colStart,n.colUpdateDirection=o>n.bodyRightCol-(n.colEnd-n.colStart+1)?"right":"left",await n.progress()}}function Lz(t,e,i){t.col=e,t.forEachChildren((t=>{t.col=e,t.needUpdate=!0})),t.setAttribute("x",i),t.needUpdate=!0}function kz(t,e){let i=t.firstChild;for(;i;){i=e.updateCellGroupContent(i)._next}t.needUpdate=!1}function Iz(t,e,i){if("left"===e){const e=t.firstChild;Lz(e,t.lastChild.col+1,t.lastChild.attribute.x+t.lastChild.attribute.width),t.appendChild(e)}else{const e=t.lastChild;Lz(e,t.firstChild.col-1,t.firstChild.attribute.x-i.table.getColWidth(t.firstChild.col-1)),t.insertBefore(e,t.firstChild)}}function Oz(t,e,i){for(let n=t;n<=e;n++){kz(i.table.scenegraph.getColGroup(n),i);kz(i.table.scenegraph.getColGroup(n,!0),i);kz(i.table.scenegraph.getColGroupInBottom(n),i)}}function Dz(t,e){for(let i=0;i<e.table.rowCount;i++){if(i>=e.table.columnHeaderLevelCount&&i<e.rowStart||i>e.rowEnd&&i<e.table.rowCount-e.table.bottomFrozenRowCount)continue;const n=RH(e.table,t,i);if(n&&n.start.row!==i){const r=e.highPerformanceGetCell(t,i,!0),o=Rz(n.start.col,n.start.row,e.table,!0);o.col=t,o.row=i,o.setAttribute("x",e.table.getColsWidth(e.table.rowHeaderLevelCount,n.start.col-1)),r.parent.insertAfter(o,r),r.parent.removeChild(r),r.needUpdate=!1,o.needUpdate=!1,e.cellCache.get(t)&&e.cellCache.set(t,o)}}}function Fz(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.getCell(o,t);if(!e.row)continue;let i;i=e._prev?(e._prev?.attribute.y??0)+(e._prev?.attribute.height??0):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.getCell(o,t);if(!e.row)continue;let i;e._next?i=(e._next?.attribute.y??0)-(e.attribute.height??0):(i=r.getRowsHeight(r.columnHeaderLevelCount,e.row)-(e.attribute.height??0),console.log("估计位置",r.getRowsHeight(r.columnHeaderLevelCount,e.row))),e.setAttribute("y",i)}}async function Wz(t,e,i,n){if("up"===e&&n.rowEnd+t>n.bodyBottomRow?t=n.bodyBottomRow-n.rowEnd:"down"===e&&n.rowStart-t<n.bodyTopRow&&(t=n.rowStart-n.bodyTopRow),t<n.rowEnd-n.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++)zz(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++)zz(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++)zz(o,i,n)}}("up"===e?n.rowStart:n.rowEnd-t+1,"up"===e?n.rowStart+t-1:n.rowEnd,e,n);const r="up"===e?n.rowEnd+1:n.rowStart-t;"up"===e?n.rowEnd:n.rowStart;const o=Math.max(n.bodyTopRow,i-1*n.screenRowCount),s=Math.min(n.bodyBottomRow,i+2*n.screenRowCount);"autoHeight"===n.table.heightMode&&gz(n.table,o,s),n.rowStart="up"===e?n.rowStart+t:n.rowStart-t,n.rowEnd="up"===e?n.rowEnd+t:n.rowEnd-t,Nz(r,n),jz(o,s,n),"autoHeight"===n.table.heightMode&&Fz(n.bodyLeftCol,n.bodyRightCol,o,s,n.table,e),n.currentRow="up"===e?n.currentRow+t:n.currentRow-t,n.totalRow="up"===e?n.totalRow+t:n.totalRow-t,n.referenceRow=n.rowStart+Math.floor((n.rowEnd-n.rowStart)/2),n.rowUpdatePos=r,n.rowUpdateDirection=e,console.log("move end proxy",n.rowStart,n.rowEnd),console.log("move end cell",n.table.scenegraph.bodyGroup.firstChild.firstChild.row,n.table.scenegraph.bodyGroup.firstChild.lastChild.row),n.table.scenegraph.updateNextFrame(),await n.progress()}else{const r="up"===e?n.rowStart+t:n.rowStart-t,o="up"===e?n.rowEnd+t:n.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))}))}}(n.table.getRowsHeight(n.bodyTopRow,r-1),t,e,n),"autoHeight"===n.table.heightMode?(s=r,a=o):(s=Math.max(n.bodyTopRow,i-1*n.screenRowCount),a=Math.min(n.bodyBottomRow,i+2*n.screenRowCount)),console.log("更新同步范围",s,a),"autoHeight"===n.table.heightMode&&gz(n.table,s,a),n.rowStart=r,n.rowEnd=o,Nz(r,n),jz(s,a,n),console.log("updateAutoRow",o>n.bodyBottomRow-(n.rowEnd-n.rowStart+1)?"down":"up"),"autoHeight"===n.table.heightMode&&Fz(n.bodyLeftCol,n.bodyRightCol,s,a,n.table,o>n.bodyBottomRow-(n.rowEnd-n.rowStart+1)?"down":"up"),n.currentRow="up"===e?n.currentRow+t:n.currentRow-t,n.totalRow="up"===e?n.totalRow+t:n.totalRow-t,n.referenceRow=n.rowStart+Math.floor((n.rowEnd-n.rowStart)/2),n.rowUpdatePos=n.rowStart,n.rowUpdateDirection=o>n.bodyBottomRow-(n.rowEnd-n.rowStart+1)?"down":"up",console.log("move total end proxy",n.rowStart,n.rowEnd),console.log("move total end cell",n.table.scenegraph.bodyGroup.firstChild.firstChild.row,n.table.scenegraph.bodyGroup.firstChild.lastChild.row),n.table.scenegraph.updateNextFrame(),"autoHeight"!==n.table.heightMode&&await n.progress()}}function zz(t,e,i){if("up"===e){const e=t.firstChild;i.updateCellGroupPosition(e,t.lastChild.row+1,t.lastChild.attribute.y+t.lastChild.attribute.height),t.appendChild(e)}else{const e=t.lastChild;i.updateCellGroupPosition(e,t.firstChild.row-1,t.firstChild.attribute.y-e.attribute.height),t.insertBefore(e,t.firstChild)}}function jz(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)}}function Nz(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=RH(e.table,i,t);if(n&&n.start.row!==t){const r=e.highPerformanceGetCell(i,t,!0),o=Rz(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)}}}class Gz{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;colLimit=1e3;bodyLeftCol;bodyRightCol;totalCol;colStart;colEnd;taskColCount;xLimitLeft;xLimitRight;screenColCount;firstScreenColLimit;colUpdatePos;currentCol;referenceCol;screenLeftCol=0;colUpdateDirection;cellCache=new Map;constructor(t){this.table=t,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){l.setParamsForRow(),l.setParamsForColumn(),l.table.internalProps._colWidthsMap.clear(),l.table._clearColRangeWidthsMap(),lz(l.table,0,Math.min(l.firstScreenColLimit,l.table.colCount-1)),l.table.internalProps._rowHeightsMap.clear(),l.table._clearRowRangeHeightsMap(),gz(l.table,0,Math.min(l.firstScreenRowLimit,l.table.rowCount-1)),l.table.rightFrozenColCount>0&&l.table.colCount-1>l.firstScreenColLimit&&lz(l.table,l.table.colCount-1-l.table.rightFrozenColCount+1,l.table.colCount-1),l.table.bottomFrozenRowCount>0&&l.table.rowCount-1>l.firstScreenRowLimit&&lz(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()}),Ez(t,s,a,0,l.table.rowHeaderLevelCount-1,0,l.table.columnHeaderLevelCount-1,"cornerHeader",l.table),Ez(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),Ez(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&&Ez(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&&Ez(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),Ez(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 createColGroupForFirstScreen(t,e,i,n,r){this.setParamsForRow(),this.setParamsForColumn(),gz(r,this.table.columnHeaderLevelCount,Math.min(this.firstScreenRowLimit,r.rowCount-1)),Ez(t,i,n,0,r.rowHeaderLevelCount-1,r.columnHeaderLevelCount,r.rowCount-1,"rowHeader",r,this.firstScreenRowLimit),Ez(e,i,n,r.rowHeaderLevelCount,r.colCount-1,r.columnHeaderLevelCount,r.rowCount-1,"body",r,this.firstScreenRowLimit),e.firstChild?(this.currentRow=e.firstChild?.rowNumber??this.totalRow,this.rowEnd=this.currentRow,this.rowUpdatePos=this.rowEnd,this.referenceRow=Math.floor((this.rowEnd-this.rowStart)/2),await this.progress()):(this.currentRow=this.totalRow,this.rowEnd=this.currentRow,this.rowUpdatePos=this.rowEnd,this.referenceRow=Math.floor((this.rowEnd-this.rowStart)/2))}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(gz(this.table,this.currentRow+1,e),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}=Pz(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}=Pz(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}=Pz(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);if(lz(this.table,this.currentCol+1,e),this.table.columnHeaderLevelCount){const t=this.table.scenegraph.colHeaderGroup.lastChild instanceof BH?this.table.scenegraph.colHeaderGroup.lastChild:this.table.scenegraph.colHeaderGroup.lastChild._prev,i=t.attribute.x+t.attribute.width,n=t.attribute.y;Ez(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 BH?this.table.scenegraph.bottomFrozenGroup.lastChild:this.table.scenegraph.bottomFrozenGroup.lastChild._prev,i=t.attribute.x+t.attribute.width,n=t.attribute.y;Ez(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 BH?this.table.scenegraph.bodyGroup.lastChild:this.table.scenegraph.bodyGroup.lastChild._prev,n=i.attribute.x+i.attribute.width,r=i.attribute.y;Ez(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;e.screenTopRow=n;const r=n-e.referenceRow;r>0?(Wz(r,"up",n,e),e.updateBody(t)):r<0?(Wz(-r,"down",n,e),e.updateBody(t)):e.updateBody(t),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;e.screenLeftCol=i.col;const n=e.screenLeftCol-e.referenceCol;n>0?(e.table.scenegraph.setBodyAndColHeaderX(-t),await Hz(n,"left",e.screenLeftCol,e)):n<0?(e.table.scenegraph.setBodyAndColHeaderX(-t),await Hz(-n,"right",e.screenLeftCol,e)):e.table.scenegraph.setBodyAndColHeaderX(-t),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&&gz(this.table,this.rowUpdatePos,e),jz(this.rowUpdatePos,e,this),"autoHeight"===this.table.heightMode&&Fz(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);lz(this.table,this.colUpdatePos,e),Oz(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 sortCell(){for(let t=this.bodyLeftCol;t<=this.bodyRightCol;t++)for(let e=this.rowStart;e<=this.rowEnd;e++){this.highPerformanceGetCell(t,e).needUpdate=!0}let t,e;"autoHeight"===this.table.heightMode?(t=this.rowStart,e=this.rowEnd):(t=Math.max(this.bodyTopRow,this.screenTopRow-2*this.screenRowCount),e=Math.min(this.bodyBottomRow,this.screenTopRow+3*this.screenRowCount)),console.log("sort更新同步范围",t,e),"autoHeight"===this.table.heightMode&&gz(this.table,t,e);for(let i=this.bodyLeftCol;i<=this.bodyRightCol;i++)for(let n=t;n<=e;n++){const t=this.highPerformanceGetCell(i,n);this.updateCellGroupContent(t)}if(console.log("updateAutoRow",this.rowEnd>this.bodyBottomRow-(this.rowEnd-this.rowStart+1)?"down":"up"),"autoHeight"===this.table.heightMode&&Fz(this.bodyLeftCol,this.bodyRightCol,t,e,this.table,this.rowEnd>this.bodyBottomRow-(this.rowEnd-this.rowStart+1)?"down":"up"),this.rowUpdatePos=this.rowStart,this.rowUpdateDirection=this.rowEnd>this.bodyBottomRow-(this.rowEnd-this.rowStart+1)?"down":"up",this.rowEnd===this.table.scenegraph.proxy.bodyBottomRow&&this.rowStart===this.table.scenegraph.proxy.bodyTopRow);else if(this.rowEnd===this.table.scenegraph.proxy.bodyBottomRow){const t=this.table.getAllRowsHeight()-this.table.scenegraph.height;this.updateBody(t)}else this.rowStart===this.table.scenegraph.proxy.bodyTopRow&&this.updateBody(0);"autoHeight"!==this.table.heightMode&&await this.progress()}highPerformanceGetCell(t,e,i){if(e>=this.table.columnHeaderLevelCount&&e<this.table.rowCount-this.table.bottomFrozenRowCount&&(e<this.rowStart||e>this.rowEnd))return wz;if(t>=this.table.rowHeaderLevelCount&&t<this.table.colCount-this.table.rightFrozenColCount&&(t<this.colStart||t>this.colEnd))return wz;if(this.cellCache.get(t)){const n=this.cellCache.get(t);if((n._next||n._prev)&&Math.abs(n.row-e)<e){let r=Kz(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.row&&this.cellCache.set(t,r),r}const n=this.table.scenegraph.getCell(t,e,i);return n.row&&this.cellCache.set(t,n),n}}function Kz(t,e){return t?t.row===e?t:t.row>e?Kz(t._prev,e):Kz(t._next,e):null}function Uz(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 Vz(t,e,i){const n=i.scenegraph,r=$z(t.map((t=>t.row))).sort(((t,e)=>t-e)),o=$z(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=Rz(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 $z(t){const e=[];for(let i=0;i<t.length;i++)-1===e.indexOf(t[i])&&e.push(t[i]);return e}new rC({});const Yz=[];function Xz(t){Yz.forEach((e=>{t.scenegraph.getCell(e.col,e.row).forEachChildren((t=>{t.setAttributes({dy:0,dx:0})}))})),Yz.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){Zz(t.scenegraph.getCell(i,e),s+t.tableX,t.tableNoFrameWidth-t.getRightFrozenColsWidth()),Yz.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){qz(t.scenegraph.getCell(i,e),o+t.tableY,t.tableNoFrameHeight-t.getBottomFrozenRowsHeight()),Yz.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);qz(n,o+t.tableY,t.tableNoFrameHeight-t.getBottomFrozenRowsHeight()),Zz(n,s+t.tableX,t.tableNoFrameWidth-t.getRightFrozenColsWidth()),Yz.push({col:i,row:e})}}}function qz(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 Zz(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 Jz(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,t.addUpdateBoundTag())}))}))}}function Qz(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 KD(i,t.attribute.width,t.attribute.height,e);t.clear(),t.appendChild(n.component),n.overlap()}}}))}))}function tj(t){const e=t.bodyGroup.firstChild instanceof BH?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 ej(t){const e=t.colHeaderGroup.firstChild instanceof BH?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 ij(t){const e=t.rowHeaderGroup.lastChild instanceof BH?t.rowHeaderGroup.lastChild:t.rowHeaderGroup.lastChild?._prev;e&&(t.bodyGroup.firstChild?t.bodyGroup.insertBefore(e,t.bodyGroup.firstChild):t.bodyGroup.appendChild(e),t.bodyGroup.setAttribute("width",t.bodyGroup.attribute.width+e.attribute.width),t.rowHeaderGroup.setAttribute("width",t.rowHeaderGroup.attribute.width-e.attribute.width))}function nj(t){const e=t.cornerHeaderGroup.lastChild instanceof BH?t.cornerHeaderGroup.lastChild:t.cornerHeaderGroup.lastChild?._prev;e&&(t.colHeaderGroup.firstChild?t.colHeaderGroup.insertBefore(e,t.colHeaderGroup.firstChild):t.bodyGroup.appendChild(e),t.colHeaderGroup.setAttribute("width",t.colHeaderGroup.attribute.width+e.attribute.width),t.cornerHeaderGroup.setAttribute("width",t.cornerHeaderGroup.attribute.width-e.attribute.width))}function rj(t){const{bgColor:e,borderColor:i,borderLineWidth:n,borderLineDash:r}=t,o={x:0,y:0,width:0,height:0,visible:!1,pickable:!0,fill:e};o.stroke=WW(i,void 0),o.lineWidth=n,r&&(o.lineDash=r),o.lineCap="square",Array.isArray(i)&&(o.strokeArrayColor=cF(i)),Array.isArray(n)&&(o.strokeArrayWidth=cF(n),o.lineWidth=1);const s=new BH(o);return s.role="corner-frozen",s}Ob.load(az);class oj{proxy;tableGroup;colHeaderGroup;cornerHeaderGroup;rowHeaderGroup;bodyGroup;rightFrozenGroup;bottomFrozenGroup;rightTopCellGroup;leftBottomCellGroup;rightBottomCellGroup;componentGroup;selectedRangeComponents;selectingRangeComponents;lastSelectId;component;stage;table;isPivot;transpose;hasFrozen;frozenColCount;frozenRowCount;clear;mergeMap;constructor(t){this.table=t,this.hasFrozen=!1,this.clear=!0,this.mergeMap=new Map,this.stage=function(t){return new AH(t)}({canvas:t.canvas,width:t.canvas.width,height:t.canvas.height,disableDirtyBounds:!1,background:t.theme.underlayBackgroundColor,dpr:t.internalProps.pixelRatio}),this.stage.defaultLayer.setTheme({group:{boundsPadding:0,strokeBoundsBuffer:0,lineJoin:"round"}}),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;const t=this.table.tableNoFrameWidth,e=this.table.tableNoFrameHeight;this.tableGroup=new BH({x:0,y:0,width:t,height:e,clip:!0,pickable:!1}),this.tableGroup.role="table";const i=new BH({x:0,y:0,width:0,height:0,clip:!1,pickable:!1});i.role="col-header",this.colHeaderGroup=i;const n=new BH({x:0,y:0,width:0,height:0,clip:!1,pickable:!1});n.role="corner-header",this.cornerHeaderGroup=n;const r=new BH({x:0,y:0,width:0,height:0,clip:!1,pickable:!1});r.role="row-header",this.rowHeaderGroup=r;const o=new BH({x:0,y:0,width:t,height:0,clip:!1,pickable:!1});o.role="body",this.bodyGroup=o;const s=new BH({x:0,y:0,width:t,height:0,clip:!1,pickable:!1});s.role="right-frozen",this.rightFrozenGroup=s;const a=new BH({x:0,y:0,width:t,height:0,clip:!1,pickable:!1});a.role="bottom-frozen",this.bottomFrozenGroup=a;const l=new BH({x:0,y:0,width:0,height:0,clip:!1,pickable:!1,childrenPickable:!0});l.role="component",this.componentGroup=l,this.rightTopCellGroup=rj(this.table.theme.cornerRightTopCellStyle||this.table.theme.cornerHeaderStyle),this.leftBottomCellGroup=rj(this.table.theme.cornerLeftBottomCellStyle||this.table.theme.cornerHeaderStyle),this.rightBottomCellGroup=rj(this.table.theme.cornerRightBottomCellStyle||this.table.theme.cornerHeaderStyle),this.tableGroup.addChild(o),this.tableGroup.addChild(s),this.tableGroup.addChild(a),this.tableGroup.addChild(r),this.tableGroup.addChild(i),this.tableGroup.addChild(this.rightBottomCellGroup),this.tableGroup.addChild(this.rightTopCellGroup),this.tableGroup.addChild(this.leftBottomCellGroup),this.tableGroup.addChild(n),this.tableGroup.addChild(l)}clearCells(){this.clear=!0,this.hasFrozen=!1,this.mergeMap.clear(),this.colHeaderGroup.clear(),this.rowHeaderGroup.clear(),this.cornerHeaderGroup.clear(),this.bodyGroup.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.rightTopCellGroup.setAttributes({x:0,y:0,width:0,height:0,visible:!1}),this.leftBottomCellGroup.setAttributes({x:0,y:0,width:0,height:0,visible:!1}),this.rightTopCellGroup.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 OW(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 Gz(this.table),DW(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-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);n=this.getCell(i.start.col,i.start.row)}return n||wz}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)}getCellSize(t,e){const i=this.getCell(t,e),n=RH(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)=>{Uz(e,i,t)})),t.selectedRangeComponents.forEach(((e,i)=>{Uz(e,i,t)}))}hideHoverIcon(t,e){if(-1===t||-1===e)return;aj(this,this.getCell(t,e),"mouseenter_cell")}showHoverIcon(t,e){if(-1===t||-1===e)return;sj(this,this.getCell(t,e),"mouseenter_cell")}hideClickIcon(t,e){if(-1===t||-1===e)return;aj(this,this.getCell(t,e),"click_cell")}showClickIcon(t,e){if(-1===t||-1===e)return;sj(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,y=hS({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:y,role:o}),t.tableGroup.insertAfter(y,"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=RH(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=RH(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=RH(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=RH(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,vm.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=hS({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;let r=!1;const o=t.getColGroup(e,!0),s=o?.attribute.width;if(o?.setAttribute("width",s+i),o?.forEachChildren(((o,a)=>{if(BW(t,o,e,o.row,s,i,t.table.columnHeaderLevelCount,n)){const e=RH(t.table,o.col,o.row);if(e&&e.end.row-e.start.row)for(let i=e.start.row;i<=e.end.row;i++)RW(t,i);else RW(t,o.row);r=!0}})),r){let e=0;for(let i=0;i<t.table.colCount;i++){const n=t.getColGroup(i,!0);let r=0;n.forEachChildren((t=>{"cell"===t.role&&(t.setAttribute("y",r),r+=t.attribute.height)})),e=r}t.updateContainerHeight(0,e-t.colHeaderGroup.attribute.height)}r=!1;const a=t.getColGroup(e),l=a.attribute.width;if(a?.setAttribute("width",l+i),a?.forEachChildren(((e,o)=>{if(BW(t,e,e.col,e.row,l,i,t.table.rowHeaderLevelCount,n)){const i=RH(t.table,e.col,e.row);if(i&&i.end.row-i.start.row)for(let e=i.start.row;e<=i.end.row;e++)RW(t,e);else RW(t,e.row);r=!0}})),r){let e=0;for(let i=0;i<t.table.colCount;i++){const n=t.getColGroup(i,!1);let r=0;n.forEachChildren((t=>{"cell"===t.role&&(t.setAttribute("y",r),r+=t.attribute.height)})),e=r}t.updateContainerHeight(t.table.frozenRowCount,e-t.bodyGroup.attribute.height)}const h=t.getColGroupInBottom(e);if(h){const e=h.attribute.width;if(h?.setAttribute("width",e+i),h?.forEachChildren(((o,s)=>{if(BW(t,o,o.col,o.row,e,i,t.table.rowHeaderLevelCount,n)){const e=RH(t.table,o.col,o.row);if(e&&e.end.row-e.start.row)for(let i=e.start.row;i<=e.end.row;i++)RW(t,i);else RW(t,o.row);r=!0}})),r){let e=0;for(let i=0;i<t.table.colCount;i++){const n=t.getColGroup(i,!1);let r=0;n.forEachChildren((t=>{"cell"===t.role&&(t.setAttribute("y",r),r+=t.attribute.height)})),e=r}t.updateContainerHeight(t.table.frozenRowCount,e-t.bodyGroup.attribute.height)}}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)})),h&&t.bottomFrozenGroup.forEachChildrenSkipChild(((t,n)=>{t.col>e&&t.setAttribute("x",t.attribute.x+i)}))),t.table.setColWidth(e,a.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((r=>{"chart"===r.type&&(r.cacheCanvas=null,r.setAttribute("width",Math.ceil(i-r.attribute.cellPadding[3]-r.attribute.cellPadding[1])),r.setAttribute("height",Math.ceil(n-r.attribute.cellPadding[0]-r.attribute.cellPadding[2])),r.setAttribute("viewBox",{x1:Math.ceil(e.globalAABBBounds.x1+r.attribute.cellPadding[3]+t.table.scrollLeft),x2:Math.ceil(e.globalAABBBounds.x1+i-r.attribute.cellPadding[1]+t.table.scrollLeft),y1:Math.ceil(e.globalAABBBounds.y1+r.attribute.cellPadding[0]+t.table.scrollTop),y2:Math.ceil(e.globalAABBBounds.y1+n-r.attribute.cellPadding[2]+t.table.scrollTop)}))}))}))}(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;if(i._selectedDataItemsInChart=[],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]);i._selectedDataItemsInChart.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]);i._selectedDataItemsInChart.push(t)}if(0===i._selectedDataItemsInChart.length&&0===n)return;i.internalProps.layoutMap.updateDataStateToChartInstance(),Jz(t)}}(this,t)}updateAutoColWidth(t){const e=this.table.getColWidth(t),i=hz(t,0,this.table.rowCount-1,this.table,!0);i!==e&&this.updateColWidth(t,i-e)}recalculateColWidths(){lz(this.table,0,this.table.colCount-1,!0)}recalculateRowHeights(){gz(this.table,0,this.table.rowCount-1)}resize(){this.recalculateColWidths(),"autoHeight"===this.table.heightMode&&this.recalculateRowHeights(),this.dealWidthMode(),this.dealHeightMode(),this.dealFrozen(),this.updateTableSize(),this.updateBorderSizeAndPosition(),this.component.updateScrollBar(),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.rightBottomCellGroup.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.leftBottomCellGroup.setAttributes({visible:!0,y:this.tableGroup.attribute.height-this.bottomFrozenGroup.attribute.height,height:this.bottomFrozenGroup.attribute.height,width:this.table.getFrozenColsWidth()}),this.rightBottomCellGroup.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.rightTopCellGroup.setAttributes({visible:!0,x:this.tableGroup.attribute.width-this.rightFrozenGroup.attribute.width,width:this.rightFrozenGroup.attribute.width,height:this.table.getFrozenRowsHeight()}),this.rightBottomCellGroup.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=RH(t.table,n,e);o&&o.start.col!==n||(TW(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);for(let e=n;e<=r;e++)for(let n=0;n<t.table.colCount;n++){const r=t.getCell(n,e),o=RH(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.frozenRowCount?(this.colHeaderGroup.setDeltaHeight(e),this.cornerHeaderGroup.setDeltaHeight(e),this.rowHeaderGroup.setDeltaY(e),this.bodyGroup.setDeltaY(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)}setRowHeight(t,e){const i=this.table.getRowHeight(t);this.updateRowHeight(t,e-i)}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(),Xz(this.table),this.updateNextFrame()}dealWidthMode(){const t=this.table;if("adaptive"===t.widthMode){const e=t.tableNoFrameWidth;let i=0;for(let e=0;e<t.colCount;e++)i+=t.getColWidth(e);const n=e/i;for(let i=0;i<t.colCount;i++){let r;r=i===t.colCount-1?e-t.getColsWidth(0,t.colCount-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&&(n+=r),i+=r}if(i<e&&i-n>0){const r=(e-n)/(i-n);for(let e=t.frozenColCount;e<t.colCount;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++)tj(t),ej(t)}else if(t.table.frozenColCount<t.table.rowHeaderLevelCount)for(let e=0;e<t.table.rowHeaderLevelCount-t.table.frozenColCount;e++)ij(t),nj(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++)ij(t),nj(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++)tj(t),ej(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=RH(this.table,i,o);s?t=this.getCell(s.start.col,s.start.row):t.setAttribute("width",n);const a=cF(nW("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.getCellType(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=RH(r,t,e),s=RH(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=RH(r,t,e),s=RH(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 y=Math.min(l,d),m=Math.max(c,f),b=Math.min(h,p),v=Math.max(u,g);for(let t=y;t<=m;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=y;t<=m;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(){let t=0;this.cornerHeaderGroup.forEachChildrenSkipChild(((e,i)=>{e.setAttribute("x",t),t+=e.attribute.width}));let e=0;this.rowHeaderGroup.forEachChildrenSkipChild(((t,i)=>{t.setAttribute("x",e),e+=t.attribute.width}));let i=0;this.colHeaderGroup.forEachChildrenSkipChild(((t,e)=>{t.setAttribute("x",i),i+=t.attribute.width}));let n=0;this.bodyGroup.forEachChildrenSkipChild(((t,e)=>{t.setAttribute("x",n),n+=t.attribute.width})),this.cornerHeaderGroup.setDeltaWidth(t-this.cornerHeaderGroup.attribute.width),this.colHeaderGroup.setDeltaWidth(i-this.colHeaderGroup.attribute.width),this.rowHeaderGroup.setDeltaWidth(e-this.rowHeaderGroup.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 r=this.table.stateManeger.scroll.horizontalBarPos,o=this.table.stateManeger.scroll.verticalBarPos;this.component.updateScrollBar(),this.table.stateManeger.setScrollLeft(r),this.table.stateManeger.setScrollTop(o),this.updateNextFrame()}updateCellContentWhileResize(t,e){const i=this.table.getBodyColumnType(t,e),n=this.getCell(t,e);"image"!==i&&"video"!==i||aW(n,t,e,this.table)}createFrameBorder(){this.updateTableSize();const t=!this.isPivot;DW(this.bodyGroup,this.table.theme.bodyStyle.frameStyle,this.bodyGroup.role,t?[!0,!0,!0,!1]:void 0),DW(this.rowHeaderGroup,this.isPivot?this.table.theme.rowHeaderStyle.frameStyle:this.table.theme.bodyStyle.frameStyle,this.rowHeaderGroup.role,t?[!0,!1,!0,!0]:void 0),DW(this.colHeaderGroup,this.table.theme.headerStyle.frameStyle,this.colHeaderGroup.role,t?[!0,!0,!0,!1]:void 0),DW(this.cornerHeaderGroup,this.isPivot?this.table.theme.cornerHeaderStyle.frameStyle:this.table.theme.headerStyle.frameStyle,this.cornerHeaderGroup.role,t?[!0,!1,!0,!0]:void 0),DW(this.tableGroup,this.table.theme.frameStyle,this.tableGroup.role,void 0)}getResizeColAt(t,e,i,n=8){if(i){if(t<i.globalAABBBounds.x1+n)return{col:i.col-1,row:i.row,x:i.globalAABBBounds.x1};if(i.globalAABBBounds.x2-n<t)return{col:i.col,row:i.row,x:i.globalAABBBounds.x2}}else;return{col:-1,row:-1}}updateIcon(t,e){CW(e,t),t.name=e.name,this.updateNextFrame()}updateFrozen(){this.clear||(this.resetFrozen(),this.dealFrozen(),this.component.updateScrollBar())}updateBorderSizeAndPosition(){this.bodyGroup.border&&(this.bodyGroup.appendChild(this.bodyGroup.border),zW(this.bodyGroup),0===this.rowHeaderGroup.attribute.width?FW(this.bodyGroup,this.table.theme.bodyStyle.frameStyle,[!0,!0,!0,!0]):FW(this.bodyGroup,this.table.theme.bodyStyle.frameStyle,[!0,!0,!0,!1])),this.colHeaderGroup.border&&(this.colHeaderGroup.appendChild(this.colHeaderGroup.border),zW(this.colHeaderGroup),0===this.cornerHeaderGroup.attribute.width?FW(this.colHeaderGroup,this.table.theme.headerStyle.frameStyle,[!0,!0,!0,!0]):FW(this.colHeaderGroup,this.table.theme.headerStyle.frameStyle,[!0,!0,!0,!1])),this.rowHeaderGroup.border&&(this.rowHeaderGroup.appendChild(this.rowHeaderGroup.border),zW(this.rowHeaderGroup)),this.cornerHeaderGroup.border&&(this.cornerHeaderGroup.appendChild(this.cornerHeaderGroup.border),zW(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?setTimeout((()=>{this.clearCells(),this.createSceneGraph()}),10):this.proxy.sortCell())}getCellOverflowText(t,e){const i=this.getCell(t,e).getChildByName("text",!0);if(i){const t=Wt(i.attribute.text)?i.attribute.text.join(""):i.attribute.text;let e="";if(Ft(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 Rz(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,[l.collapse,l.expand],n)}updateRow(t,e){Vz(t,e,this.table),this.recalculateColWidths(),"autoHeight"===this.table.heightMode&&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 sj(t,e,i){e.forEachChildren((e=>{"group"===e.type?sj(t,e,i):e.attribute.visibleTime===i&&(e.attribute.visible=!0,t.updateNextFrame())}))}function aj(t,e,i){e.forEachChildren((e=>{"group"===e.type?aj(t,e,i):e.attribute.visibleTime===i&&(e.attribute.visible=!1,t.updateNextFrame())}))}function lj(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 hj(t,e,i,n,r){const o=t.table;for(let i=0;i<o.columnHeaderLevelCount;i++)lj(t,e,i);const s=t.getColGroup(e);return s?.addUpdateBoundTag(),!0}function cj(t,e,i,n,r,o){const s=t.table;for(let i=0;i<s.columnHeaderLevelCount;i++)lj(t,e,i);const a=t.getColGroup(e);return a?.addUpdateBoundTag(),!0}function uj(t,e,i,n,r){const o=t.table;for(let e=0;e<o.colCount;e++)lj(t,e,i);return!0}function dj(t,e,i,n,r,o){const s=t.table;for(let e=0;e<s.colCount;e++)lj(t,e,i);return!0}function pj(t,e,n){const{table:r}=t,{scenegraph:o}=r,{highlightScope:s,singleStyle:a,disableHeader:l,cellPos:h,cellPosContainHeader:c}=t.hover,u=h.col,d=h.row;if(s===i.none||l&&(c.col!==e||c.row!==n)){const t=c.col,i=c.row;o.hideHoverIcon(t,i),o.showHoverIcon(e,n),c.col=e,c.row=n}if((l&&r.isHeader(e,n)||s===i.none)&&(e=-1,n=-1),u===e&&d===n)return;o.deactivateChart(u,d),o.activateChart(e,n);let p=!1;const{ranges:f,highlightScope:g}=t.select;if(-1!==u&&-1!==d&&(p=function(t,e,n,r,o,s,a){let l=!1;s===i.single?l=!!function(t,e,i,n,r){return lj(t,e,i),!0}(t,e,n)||l:s===i.row?l=!!uj(t,0,n)||l:s===i.column?l=!!hj(t,e)||l:s===i.cross&&(l=!!uj(t,0,n)||l,l=!!hj(t,e)||l);return l}(o,u,d,0,0,s),l||o.hideHoverIcon(u,d)),-1===e||-1===n)return h.col=-1,h.row=-1,void(p&&t.table.scenegraph.updateNextFrame());s===i.single?p=!!function(t,e,i,n,r){return lj(t,e,i),!0}(o,e,n)||p:s===i.row?p=!!dj(o,0,n)||p:s===i.column?p=!!cj(o,e)||p:s===i.cross&&(p=!!dj(o,0,n)||p,p=!!cj(o,e)||p),s===i.none||l||o.showHoverIcon(e,n),h.col=e,h.row=n,p&&t.table.scenegraph.updateNextFrame()}function fj(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=gj(t,e,r.col,r.row,i)),!o);s++);else n=i.sortState,n&&(r=i._getHeaderCellBySortState(n)),r&&(o=gj(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.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",R)}(n,i,s),i.scenegraph.sortCell(),i.stateManeger.updateSelectPos(-1,-1),i.fireListeners(yt.SORT_CLICK,n)}function gj(t,e,i,n,r){return r._getLayoutCellId(t,e)===r._getLayoutCellId(i,n)}const yj=it(yt,{PIVOT_SORT_CLICK:"pivot_sort_click",DRILLMENU_CLICK:"drillmenu_click"}),mj=it(yt,{VCHART_EVENT_TYPE:"vchart_event_type"});function bj(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 vj(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}class wj{table;interactionState;select;hover;hoverIcon;residentHoverIcon;columnResize;columnMove;menu;sort;frozen;scroll;tablePosition;drill;sparkLine;_clearVerticalScrollBar;_clearHorizontalScrollBar;constructor(t){this.table=t,this.initState(),this.setHoverState(),this.setSelectState(),this.setFrozenState(),this.updateVerticalScrollBar=this.updateVerticalScrollBar.bind(this),this.updateHorizontalScrollBar=this.updateHorizontalScrollBar.bind(this)}initState(){this.interactionState=e.default,this.select={highlightScope:i.single,ranges:[],cellPos:{col:-1,row:-1},selecting:!1},this.hover={highlightScope:i.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 je,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:n}=this.table.options.hover??{highlightMode:"cell"};e?this.hover.highlightScope=i.none:"cross"===t?this.hover.highlightScope=i.cross:"row"===t?this.hover.highlightScope=i.row:"column"===t?this.hover.highlightScope=i.column:"cell"===t&&(this.hover.highlightScope=i.single),this.hover.singleStyle=!e,this.hover.disableHeader=n,(this.hover.highlightScope===i.none||n)&&(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?i.none:i.single,this.select.singleStyle=!t,this.select.disableHeader=e}isSelected(t,e){let i=!1;return this.select.ranges.forEach((n=>{at(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){pj(this,t,e)}updateSelectPos(t,i,n=!1,r=!1,o=!1){-1!==i&&-1!==i&&(this.select.selecting=!0),function(t,i,n,r,o,s){const{table:a,interactionState:l}=t,{scenegraph:h}=a,{highlightScope:c,disableHeader:u,cellPos:d}=t.select;if((u&&a.isHeader(i,n)||"none"===c)&&(i=-1,n=-1),d.col!==i||d.row!==n){if(-1!==i&&-1!==n&&t.select.ranges.length>0)if(l===e.grabing){const e=t.select.ranges[t.select.ranges.length-1];i>e.start.col&&i>e.end.col&&a._makeVisibleCell(i+1,n),n>e.start.row&&n>e.end.row&&a._makeVisibleCell(i,n+1),i<e.start.col&&i<e.end.col&&a._makeVisibleCell(i-1,n),n<e.start.row&&n<e.end.row&&a._makeVisibleCell(i,n-1)}else a._makeVisibleCell(i,n);if(s){t.select.ranges=[],h.deleteAllSelectBorder(),t.select.ranges.push({start:{col:0,row:0},end:{col:a.colCount-1,row:a.rowCount-1}});const e=t.select.ranges[t.select.ranges.length-1];h.updateCellSelectBorder(e.start.col,e.start.row,e.end.col,e.end.row)}else if(-1===d.col||-1===d.row||-1!==i&&-1!==n){if(l===e.default){const e=t.select.ranges[t.select.ranges.length-1];if(r&&e){if(a.isColumnHeader(i,n)){const t=Math.min(e.start.col,e.end.col,i),r=Math.max(e.start.col,e.end.col,i),o=Math.min(e.start.row,e.end.row,n),s=a.rowCount-1;e.start={col:t,row:o},e.end={col:r,row:s}}else if(a.isRowHeader(i,n)){const t=Math.min(e.start.col,e.end.col,i),r=a.colCount-1,o=Math.min(e.start.row,e.end.row,n),s=Math.max(e.start.row,e.end.row,n);e.start={col:t,row:o},e.end={col:r,row:s}}else e.end={col:i,row:n};h.deleteLastSelectedRangeComponents(),h.updateCellSelectBorder(e.start.col,e.start.row,e.end.col,e.end.row)}else{-1===d.col||-1===d.row||o||(t.select.ranges=[],h.deleteAllSelectBorder()),a.isColumnHeader(i,n)?t.select.ranges.push({start:{col:i,row:n},end:{col:i,row:a.rowCount-1}}):a.isRowHeader(i,n)?t.select.ranges.push({start:{col:i,row:n},end:{col:a.colCount-1,row:n}}):t.select.ranges.push({start:{col:i,row:n},end:{col:i,row:n}}),d.col=i,d.row=n;const e=t.select.ranges[t.select.ranges.length-1];h.updateCellSelectBorder(e.start.col,e.start.row,e.end.col,e.end.row)}}else if(l===e.grabing){-1===d.col&&(d.col=i),-1===d.row&&(d.row=n);const e=t.select.ranges[t.select.ranges.length-1];e.end={col:i,row:n},d.col=i,d.row=n,h.updateCellSelectBorder(e.start.col,e.start.row,i,n)}}else d.col=-1,d.row=-1,t.select.ranges=[],h.deleteAllSelectBorder();h.updateNextFrame()}}(this,t,i,n,r,o)}checkCellRangeInSelect(t,e){return function(t,e,i,n){for(let n=0;n<i.length;n++)if(ht(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=vj(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(yt.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){this.columnResize.resizing=!0,this.columnResize.col=t,this.columnResize.x=e,this.table.scenegraph.component.showResizeCol(t,i),this.table.stateManeger.updateSelectPos(-1,-1),this.table.scenegraph.updateNextFrame()}updateResizeCol(t,e){t=Math.ceil(t),e=Math.ceil(e);let i=t-this.columnResize.x;if(Math.abs(i)<1)return;let n=this.table.colWidthsMap.get(this.columnResize.col);"number"==typeof n||(n=this.table.getColWidth(this.columnResize.col));let r=n;r+=i;const o=this.table.getMinColWidth(this.columnResize.col),s=this.table.getMaxColWidth(this.columnResize.col);if(r<o||r>s){if(n===o||n===s)return;i=n-o>s-n?s-n:o-n}i=Math.ceil(i),this.table.scenegraph.updateColWidth(this.columnResize.col,i),"adaptive"===this.table.widthMode&&this.columnResize.col<this.table.colCount-1&&this.table.scenegraph.updateColWidth(this.columnResize.col+1,-i),this.columnResize.x=t,this.table.scenegraph.component.updateResizeCol(this.columnResize.col,e),this.columnResize.col<this.table.frozenColCount&&!this.table.isPivotTable()&&!this.table.transpose&&this.table.scenegraph.component.setFrozenColumnShadow(this.table.frozenColCount-1),this.table.scenegraph.updateNextFrame()}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.getCellType(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.getCellType(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(){bj(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(yt.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(yt.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(yt.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(yt.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,PW.contextmenu)),this.table.fireListeners(yt.SHOW_MENU,{x:i,y:n,col:t,row:e,type:"contextmenu"}))}triggerDropDownMenu(t,e,i,n){this.table.fireListeners(yt.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,PW.dropDown),this.menu.bounds=this.table.scenegraph.component.menu.bounds),this.table.fireListeners(yt.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===l.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(yt.DROPDOWN_MENU_CLEAR,null),this.table.fireListeners(yt.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(A(s)&&A(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(d(e)&&(e.menuKey||e.text)===(h||"")&&t===i)return!0;if(f(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(yj.PIVOT_SORT_CLICK,{col:t,row:e,order:i||"normal",dimensionInfo:this.table.internalProps.layoutMap.getPivotDimensionInfo(t,e),cellType:this.table.getCellType(t,e)})}const n=this.sort.col,r=this.sort.row;fj(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.dimensionTitle=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.getCellType(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=aS({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=uS({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),caption:r.getBodyColumnDefine(t,e).caption,cellRange:r.getCellRelativeRect(t,e),sparkline:{pointData:d.pointData},scaleRatio:r.canvas.getBoundingClientRect().width/r.canvas.offsetWidth};r.fireListeners(yt.MOUSEOVER_CHART_SYMBOL,i)}}(t,e,i,0,this.table),this.sparkLine.col=t,this.sparkLine.row=e}}function Cj(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}function xj(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&&(e.setScrollLeft(e.scroll.horizontalBarPos+r),e.showHorizontalScrollBar(!0)),o&&(e.setScrollTop(e.scroll.verticalBarPos+o),e.showVerticalScrollBar(!0)),t.cancelable&&(0!==n&&_j(n,e)||0!==i&&Sj(i,e))&&t.preventDefault()}function _j(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 Sj(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 Aj(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||!Tj(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;xj({deltaX:n,deltaY:r},i),e.cancelable&&(0!==r&&_j(r,i)||0!==n&&Sj(n,i))&&e.preventDefault()}),{passive:!1}),window.addEventListener("touchend",(e=>{if(t.touchEnd=!0,t.touchMove=!1,t.isTouchdown&&Tj(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),xj({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 Tj(t){return!!t.changedTouches}function Bj(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 Rj{table;isTouchdown;touchMovePoints;touchSetTimeout;touchEnd;touchMove;constructor(t){this.table=t,this.bindOuterEvent(),setTimeout((()=>{this.bindSelfEvent()}),0)}bindOuterEvent(){!function(t){const i=t.table,n=i.stateManeger;i.scenegraph.tableGroup.addEventListener("pointermove",(r=>{t.touchSetTimeout&&(clearTimeout(t.touchSetTimeout),t.touchSetTimeout=void 0);const o=Cj(r);if(n.interactionState!==e.scrolling)if(n.interactionState!==e.grabing){if(t.checkColumnResize(o)?n.updateCursor("col-resize"):n.updateCursor(),i.hasListeners(yt.MOUSELEAVE_CELL)){const t=o?.eventArgs?.target;"cell"!==t?.role||-1===i.stateManeger.hover.cellPos.col||-1===i.stateManeger.hover.cellPos.row||t.col===i.stateManeger.hover.cellPos.col&&t.row===i.stateManeger.hover.cellPos.row||i.fireListeners(yt.MOUSELEAVE_CELL,{col:i.stateManeger.hover.cellPos.col,row:i.stateManeger.hover.cellPos.row,cellRange:i.getCellRangeRelativeRect({col:i.stateManeger.hover.cellPos.col,row:i.stateManeger.hover.cellPos.row}),scaleRatio:i.canvas.getBoundingClientRect().width/i.canvas.offsetWidth,event:r.nativeEvent})}if(i.hasListeners(yt.MOUSEENTER_CELL)){const t=o?.eventArgs?.target;"cell"===t?.role&&kt(t.col)&&kt(t.row)&&(t.col!==i.stateManeger.hover.cellPos.col||t.row!==i.stateManeger.hover.cellPos.row)&&i.fireListeners(yt.MOUSEENTER_CELL,{col:t.col,row:t.row,cellRange:i.getCellRangeRelativeRect({col:t.col,row:t.row}),scaleRatio:i.canvas.getBoundingClientRect().width/i.canvas.offsetWidth,event:r.nativeEvent})}if(t.dealIconHover(o),t.dealTableHover(o),o.eventArgs&&i.hasListeners(yt.MOUSEMOVE_CELL)){let t,e;if(o.eventArgs?.target){const i=vj(o.eventArgs?.target);i&&(t=i.icon,e=i.position)}i.fireListeners(yt.MOUSEMOVE_CELL,{col:o.eventArgs.col,row:o.eventArgs.row,x:o.abstractPos.x,y:o.abstractPos.y,event:r.nativeEvent,targetIcon:t?{name:t.name,position:e,funcType:t.attribute.funcType}:void 0})}}else n.isResizeCol()?(t.dealColumnResize(o),o.eventArgs&&i.hasListeners(yt.RESIZE_COLUMN)&&i.fireListeners(yt.RESIZE_COLUMN,{col:i.stateManeger.columnResize.col,colWidth:i.getColWidth(i.stateManeger.columnResize.col)})):n.isMoveCol()?t.dealColumnMover(o):t.dealTableSelect(o)})),i.scenegraph.tableGroup.addEventListener("pointerout",(e=>{const i=Cj(e),n=i?.eventArgs?.target;"table"===n?.role&&t.dealTableHover()})),i.scenegraph.tableGroup.addEventListener("pointerover",(t=>{const e=Cj(t),n=e?.eventArgs?.target;if(i.hasListeners(yt.MOUSEOVER_CHART_SYMBOL)&&"symbol"===n.type){const e=t.composedPath().find((t=>"cell"===t.roll));if(e){const{col:n,row:r}=e,o={col:n,row:r,field:i.getHeaderField(n,r),value:i.getCellValue(n,r),dataValue:i.getCellOriginValue(n,r),cellHeaderPaths:i.internalProps.layoutMap.getCellHeaderPaths(n,r),caption:i.getBodyColumnDefine(n,r).caption,cellRange:i.getCellRelativeRect(n,r),event:t.nativeEvent,sparkline:{pointData:void 0},scaleRatio:i.canvas.getBoundingClientRect().width/i.canvas.offsetWidth};i.fireListeners(yt.MOUSEOVER_CHART_SYMBOL,o)}}})),i.scenegraph.tableGroup.addEventListener("pointerleave",(r=>{n.updateInteractionState(e.default),t.dealTableHover(),n.updateCursor();const o=r.target;o&&!o.isDescendantsOf(i.scenegraph.tableGroup)&&i.fireListeners(yt.MOUSELEAVE_TABLE,{col:-1,row:-1,event:r.nativeEvent})})),i.scenegraph.tableGroup.addEventListener("pointerupoutside",(i=>{console.log("pointerupoutside"),n.updateInteractionState(e.default),t.dealTableHover(),t.dealTableSelect()})),i.scenegraph.tableGroup.addEventListener("pointerdown",(r=>{if(0!==r.button)return;const o=Cj(r);if(n.interactionState===e.default){if(i.isPivotChart()&&"chart"!==o?.eventArgs?.target.type&&i.scenegraph.updateChartState(null),n.menu.isShow&&o.eventArgs&&o.eventArgs.target!==n.residentHoverIcon?.icon&&n.hideMenu(),!(o?.eventArgs?.target?.role?.startsWith("icon")?o.eventArgs.target:void 0))if("touch"===r.pointerType)t.touchEnd=!1,t.touchSetTimeout=setTimeout((()=>{t.isTouchdown=!1,t.touchMove=!0,(!t.touchEnd&&t.checkColumnResize(o,!0)||!t.touchEnd&&t.chechColumnMover(o)||t.dealTableSelect(o)&&!t.touchEnd)&&n.updateInteractionState(e.grabing)}),500);else{if(t.checkColumnResize(o,!0))return i.scenegraph.updateChartState(null),void n.updateInteractionState(e.grabing);if(t.chechColumnMover(o))return void n.updateInteractionState(e.grabing);t.dealTableSelect(o)&&n.updateInteractionState(e.grabing)}if(i.hasListeners(yt.MOUSEDOWN_CELL)){const t=Cj(r);t.eventArgs&&i.fireListeners(yt.MOUSEDOWN_CELL,{col:t.eventArgs.col,row:t.eventArgs.row,event:r.nativeEvent})}}})),i.scenegraph.tableGroup.addEventListener("pointerup",(t=>{if(0===t.button){if("grabing"===n.interactionState){if(n.updateInteractionState(e.default),n.isResizeCol()){if(i.stateManeger.endResizeCol(),i.hasListeners(yt.RESIZE_COLUMN_END)){const t=[];for(let e=0;e<i.colCount;e++)t.push(i.getColWidth(e));i.fireListeners(yt.RESIZE_COLUMN_END,{col:i.stateManeger.columnResize.col,columns:t})}}else if(n.isMoveCol()){i.stateManeger.endMoveCol();const e=Cj(t);e.eventArgs&&i.hasListeners(yt.CHANGE_HEADER_POSITION)&&i.fireListeners(yt.CHANGE_HEADER_POSITION,{target:{col:e.eventArgs.col,row:e.eventArgs.row},source:{col:i.stateManeger.columnMove.colSource,row:i.stateManeger.columnMove.colSource}})}else if(n.isSelecting()){i.stateManeger.endSelectCells();const e=Cj(t);if(e.eventArgs&&i.hasListeners(yt.DRAG_SELECT_END)){const n={event:t.nativeEvent,cells:[],col:e.eventArgs.target.col,row:e.eventArgs.target.row,scaleRatio:i.canvas.getBoundingClientRect().width/i.canvas.offsetWidth};n.cells=i.getSelectedCellInfos(),i.fireListeners(yt.DRAG_SELECT_END,n)}}}else n.interactionState===e.scrolling&&n.updateInteractionState(e.default);if(i.hasListeners(yt.MOUSEUP_CELL)){const e=Cj(t);e.eventArgs&&i.fireListeners(yt.MOUSEUP_CELL,{col:e.eventArgs.col,row:e.eventArgs.row,event:t.nativeEvent})}}})),i.scenegraph.tableGroup.addEventListener("rightdown",(t=>{const e=Cj(t);if(e.eventArgs){n.triggerContextMenu(e.eventArgs.col,e.eventArgs.row,e.abstractPos.x,e.abstractPos.y);const{col:r,row:o}=e.eventArgs;if(i.hasListeners(yt.CONTEXTMENU_CELL)){const n=i.getCellInfo(r,o);let s,a;if(e.eventArgs?.target){const t=vj(e.eventArgs?.target);t&&(s=t.icon,a=t.position)}const l={...n,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}(i.stateManeger.select.ranges,r,o)?l.cells=[[n]]:l.cells=i.getSelectedCellInfos(),i.fireListeners(yt.CONTEXTMENU_CELL,l)}}})),i.scenegraph.tableGroup.addEventListener("click",(e=>{if(console.log("click",e.clone()),i.stateManeger.columnResize.resizing||i.stateManeger.columnMove.moving)return;const n=Cj(e);if(t.dealIconClick(e,n),!n?.eventArgs)return;const{col:r,row:o}=n.eventArgs;if(i.hasListeners(yt.CLICK_CELL)){const t=i.getCellInfo(r,o);let s,a;if(n.eventArgs?.target){const t=vj(n.eventArgs?.target);t&&(s=t.icon,a=t.position)}const l={...t,event:e.nativeEvent,cells:[],targetIcon:s?{name:s.name,position:a,funcType:s.attribute.funcType}:void 0};i.fireListeners(yt.CLICK_CELL,l)}})),i.scenegraph.stage.addEventListener("click",(r=>{console.log("stage click");const o=r.target;o&&!o.isDescendantsOf(i.scenegraph.tableGroup)&&o!==i.scenegraph.tableGroup&&(console.log("pointerup outside table"),n.updateInteractionState(e.default),t.dealTableHover(),t.dealTableSelect(),n.updateCursor(),i.scenegraph.updateChartState(null))})),i.scenegraph.tableGroup.addEventListener("dblclick",(t=>{const e=Cj(t),n=e.eventArgs.targetCell.globalAABBBounds,{col:r,row:o}=e.eventArgs,s=i.getCellValue(r,o);if(i.internalProps.focusControl.setFocusRect(new xi(n.x1+i.scrollLeft,n.y1+i.scrollTop,n.x2-n.x1,n.y2-n.y1),s),i.hasListeners(yt.DBLCLICK_CELL)){const n=i.getCellInfo(r,o);let s,a;if(e.eventArgs?.target){const t=vj(e.eventArgs?.target);t&&(s=t.icon,a=t.position)}const l={...n,event:t.nativeEvent,cells:[],targetIcon:s?{name:s.name,position:a,funcType:s.attribute.funcType}:void 0};i.fireListeners(yt.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=>{xj(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(yt.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(yt.KEYDOWN,t)}})),n.on(e.getElement(),"copy",(t=>{if(e.keyboardOptions?.copySelected){const i=e.getCopyValue();kt(i)&&(t.preventDefault(),ct?window.clipboardData.setData("Text",i):t.clipboardData.setData("text/plain",i))}})),n.on(e.getElement(),"contextmenu",(t=>{t.preventDefault()})),n.on(e.getParentElement(),"resize",(()=>{e.resize()}))}(this),function(t){const i=t.table,n=i.stateManeger,r=i.scenegraph;r.component.vScrollBar.addEventListener("pointerover",(t=>{n.showVerticalScrollBar()})),r.component.hScrollBar.addEventListener("pointerover",(t=>{n.showHorizontalScrollBar()})),r.component.vScrollBar.addEventListener("pointerout",(t=>{n.interactionState!==e.scrolling&&n.hideVerticalScrollBar()})),r.component.hScrollBar.addEventListener("pointerout",(t=>{n.interactionState!==e.scrolling&&n.hideHorizontalScrollBar()})),r.component.vScrollBar._slider.addEventListener("pointerdown",(()=>{n.interactionState!==e.scrolling&&n.updateInteractionState(e.scrolling)})),r.component.vScrollBar.addEventListener("pointerup",(()=>{n.interactionState===e.scrolling&&n.updateInteractionState(e.default)})),r.component.vScrollBar.addEventListener("pointerupoutside",(()=>{n.interactionState===e.scrolling&&n.updateInteractionState(e.default)})),r.component.hScrollBar._slider.addEventListener("pointerdown",(()=>{n.interactionState!==e.scrolling&&n.updateInteractionState(e.scrolling)})),r.component.hScrollBar.addEventListener("pointerup",(()=>{n.interactionState===e.scrolling&&n.updateInteractionState(e.default)})),r.component.hScrollBar.addEventListener("pointerupoutside",(()=>{n.interactionState===e.scrolling&&n.updateInteractionState(e.default)}));const o=x(n.updateVerticalScrollBar,20),s=x(n.updateHorizontalScrollBar,20);r.component.vScrollBar.addEventListener("scroll",(t=>{const e=t.detail.value[0]/(1-t.detail.value[1]+t.detail.value[0]);o(e,t)})),r.component.hScrollBar.addEventListener("scroll",(t=>{const e=t.detail.value[0]/(1-t.detail.value[1]+t.detail.value[0]);s(e)}))}(this),Aj(this)}bindSelfEvent(){const t=this.table.stateManeger;var e;this.table.listen(yt.ICON_CLICK,(e=>{const{col:i,row:n,x:r,y:o,funcType:s,icon:a}=e;var h;s===l.dropDown?t.triggerDropDownMenu(i,n,r,o):s===l.sort?t.triggerSort(i,n,a):s===l.frozen?t.triggerFreeze(i,n,a):s===l.drillDown?(h=this.table).fireListeners(yj.DRILLMENU_CLICK,h.stateManeger.drill):s!==l.collapse&&s!==l.expand||this.table.toggleHierarchyState(i,n)})),this.table.listen(yt.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.listen(yt.SCROLL,(t=>{Xz(this.table)})),e=this.table,"browser"===vt.mode&&e.listen(yt.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.columnType){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(!Pi.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.listen(yt.DBLCLICK_CELL,(t=>{this.table._canResizeColumn(t.col,t.row)&&this.table.scenegraph.updateAutoColWidth(t.col)})),this.table.isPivotTable()&&function(t){t.listen(yt.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.dimensionTitle,r.drillDown,r.drillUp,i,n):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.columnType)):t.internalProps.layoutMap.columnObjects.some((t=>"sparkline"===t.columnType));e&&(t.listen(yt.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.listen(yt.MOUSELEAVE_TABLE,(e=>{t.stateManeger.updateSparklineHoverPose(-1,-1,0,0)})))}(this.table),function(t){t.isPivotChart()&&t.scenegraph.tableGroup.addEventListener("click",(e=>{if("axis-label"===e.target.name){const i=Cj(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(),Jz(t.scenegraph),t.scenegraph.updateNextFrame()}else t._selectedDimensionInChart&&(t._selectedDimensionInChart.length=0,t.internalProps.layoutMap.updateDataStateToChartInstance(),Jz(t.scenegraph),t.scenegraph.updateNextFrame())}))}(this.table),function(t){t.isPivotChart()&&(t.listen(yt.MOUSEENTER_CELL,(e=>{t.scenegraph.getCell(e.col,e.row).forEachChildren((i=>{if("axis"===i.name){const i=Bj(e.col,e.row,t.internalProps.layoutMap);e.axisPosition=i,t.fireListeners(yt.MOUSEENTER_AXIS,e)}}))})),t.listen(yt.MOUSELEAVE_CELL,(e=>{t.scenegraph.getCell(e.col,e.row).forEachChildren((i=>{if("axis"===i.name){const i=Bj(e.col,e.row,t.internalProps.layoutMap);e.axisPosition=i,t.fireListeners(yt.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),!0}return!1}dealColumnResize(t){this.table.stateManeger.updateResizeCol(t.abstractPos.x,t.abstractPos.y)}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(at(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(yt.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 b_){const t=n.pickIcon(r.global);if(t)return this.table.fireListeners(yt.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}}let Mj;const Pj=t=>{const e=t.value;return Number(e)>80?"#20a8d8":Number(e)>50?"#4dbd74":Number(e)>20?"#ffc107":"#f86c6b"};class Ej extends O{_showBar;_barColor;_barBgColor;_barPositiveColor;_barNegativeColor;_barAxisColor;_barHeight;_barBottom;_barPadding;_showBarMark;_barMarkPositiveColor;_barMarkNegativeColor;_barMarkWidth;_barMarkPosition;_barRightToLeft;static get DEFAULT(){return Mj||(Mj=new Ej)}constructor(t={},e={}){super(t,e),this._showBar=t.showBar??!0,this._barColor=t.barColor??Pj,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 Ej(this,null)}}const Hj=["type","content","font","color","width","height","marginRight","marginLeft","src","svg","name","path","positionType","tooltip","hover","cursor","shape","interactive"];class Lj{expandIcon;collapseIcon;_table;constructor(t){this._table=t;const e=tW();this.expandIcon=e[h.expandIconName],this.collapseIcon=e[h.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=tW(),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 F;case"image":case"video":return D;case"chart":case"sparkline":return O;case"progressbar":return Ej}}getCellIconFromRecordValue(t,e,i){if(Array.isArray(t))return t.map((t=>this.getCellIconFromRecordValue(t,e,i)));if(!ut.isObject(t)||"function"==typeof t)return this._table.getFieldData(t,e,i);const n={},r=t;return Hj.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===r.expand?this.expandIcon:i===r.collapse?this.collapseIcon:void 0}}function kj(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 Ij="vtable__menu-element",Oj=`${Ij}__item`,Dj=`${Ij}__content`,Fj=`${Ij}--hidden`,Wj=`${Ij}--shown`,zj=`${Ij}--normal`,jj=`${Ij}--select`,Nj=`${Ij}__icon`,Gj=`${Ij}__split`,Kj=`${Ij}__title`,Uj=`${Ij}__arrow`,Vj=`${Ij}__no-event`,$j=`${Ij}__item-text`;function Yj(){return kj("div",[Ij,Fj])}function Xj(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(A(o)&&A(a)&&at(s,o,a)&&i===h)return!0}return!1}class qj{_handler;_rootElement;_secondElement;_menuInstanceInfo;_showChildrenIndex;_mouseEnterSecondElement;constructor(t){this._handler=new xt,this._rootElement=Yj(),this._secondElement=Yj(),this._secondElement.sub=!0,this._showChildrenIndex=-1,this._rootElement?.addEventListener("mousedown",(t=>{t.stopPropagation(),t.preventDefault()})),this._rootElement?.addEventListener("touchend",(e=>{if(e.stopPropagation(),e.preventDefault(),this._rootElement.classList.contains(Fj))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(yt.DROPDOWNMENU_CLICK,{col:i,row:n,field:l,menuKey:o,text:s,highlight:h,cellType:t.getCellType(i,n)}),t.fireListeners(yt.DROPDOWN_MENU_CLEAR,null),t.fireListeners(yt.HIDE_MENU,null),e.stopPropagation()})),this._rootElement?.addEventListener("click",(e=>{if(e.stopPropagation(),e.preventDefault(),this._rootElement.classList.contains(Fj))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(yt.DROPDOWNMENU_CLICK,{col:i,row:n,field:l,menuKey:o,text:s,highlight:h,cellType:t.getCellType(i,n)}),t.fireListeners(yt.DROPDOWN_MENU_CLEAR,null),t.fireListeners(yt.HIDE_MENU,null),e.stopPropagation()})),this._rootElement?.addEventListener("mousemove",(e=>{if(this._rootElement.classList.contains(Fj))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(Fj),i?.classList.add(Wj),i.innerHTML="";const s=this._menuInstanceInfo.content[n]?.children;for(let e=0;e<s.length;e++){const n=s[e],a=Zj(n,!!t.stateManeger.menu.dropDownMenuHighlight&&Xj(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(Fj),t?.classList.add(Wj)}else!s&&this._secondElement?.classList.contains(Wj)&&setTimeout((()=>{if(!0!==this._mouseEnterSecondElement){this._showChildrenIndex=-1;const t=this._secondElement;t?.classList.remove(Wj),t?.classList.add(Fj)}}),300)})),this._secondElement?.addEventListener("mousemove",(t=>{this._rootElement.classList.contains(Fj)||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(Fj))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(Xj(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(yt.DROPDOWNMENU_CLICK,{col:i,row:n,field:l,cellHeaderPaths:t.isPivotTable()?t.getCellHeaderPaths(i,n):void 0,menuKey:o,text:s,highlight:h,cellType:t.getCellType(i,n)}),t.fireListeners(yt.DROPDOWN_MENU_CLEAR,null),t.fireListeners(yt.HIDE_MENU,null),e.stopPropagation()}))}get rootElement(){return this._rootElement}dispose(){this.unbindFromCell();const t=this._rootElement;t?.parentElement&&t.parentElement.removeChild(t),this._handler.dispose(),delete this._rootElement}bindToCell(t,e,i,n){const r=this._rootElement,o=this._secondElement;if(this._menuInstanceInfo=n,r?.classList.remove(Wj),r?.classList.add(Fj),o?.classList.remove(Wj),o?.classList.add(Fj),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&&Xj(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(Xj(t,t.stateManeger.menu.dropDownMenuHighlight,"object"==typeof r?r?.menuKey||r?.text:r,e,i)){a=!0;break}}const l=Zj(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(Wj),r?.classList.remove(Fj),!0}else this.unbindFromCell();return!1}unbindFromCell(){const t=this._rootElement,e=this._secondElement;this._menuInstanceInfo=void 0,t?.parentElement&&(t.classList.remove(Wj),t.classList.add(Fj)),e?.parentElement&&(e.classList.remove(Wj),e.classList.add(Fj))}_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 Zj(t,e){const i=kj("div",[Oj,e?jj:zj]);if("string"==typeof t){const e=kj("span",[Dj,Vj,$j]);e.innerHTML=t,i.appendChild(e)}else if("object"==typeof t){const n=t.type??"item";if("split"===n)return i?.classList.add(Gj),i;if(t?.icon?.svg)if(Pi.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=kj("span",[Nj,Vj]);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=kj("span",[Dj,Vj,$j]);if(r.innerHTML=t.text,i.appendChild(r),"title"===n)i?.classList.add(Vj,Kj);else if(t?.children?.length){const t=kj("span",[Dj,Vj,Uj]);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 Jj;class Qj extends j{static get DEFAULT(){return Jj||(Jj=new Qj)}constructor(t={},e={}){super(t,e),this.textAlign=(t.textAlign??e?.textAlign)||"center"}clone(){return new Qj(this)}}class tN{normalIcon;upIcon;downIcon;freezeIcon;frozenIcon;frozenCurrentIcon;dropDownAbsoluteIcon;expandIcon;collapseIcon;_table;constructor(t){this._table=t;const e=tW();this.freezeIcon=e[h.freezeIconName],this.frozenIcon=e[h.frozenIconName],this.frozenCurrentIcon=e[h.frozenCurrentIconName],this.normalIcon=e[h.normalIconName],this.upIcon=e[h.upwardIconName],this.downIcon=e[h.downwardIconName],this.dropDownAbsoluteIcon=e[h.dropdownIconName],this.expandIcon=e[h.expandIconName],this.collapseIcon=e[h.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&&at(o,i.col,i.row)){({order:r}=e);break}}else{const t=this._table._getHeaderCellBySortState(n);t&&at(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{captionIcon:r,headerIcon:o}=this._table._getHeaderLayoutMap(t,e);r&&i.push(r);const s=this.getHierarchyIcon(t,e);if(s&&i.push(s),o){let n;if("function"==typeof o){n=o({col:t,row:e,value:this._table.getCellValue(t,e),dataValue:this._table.getCellOriginValue(t,e),table:this._table})}else n=o;const r=tW(),s=t=>{let e;e="string"==typeof t?r[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,h=-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 a=s.children[n];if(t.stateManeger.menu?.dropDownMenuHighlight&&Xj(t,t.stateManeger.menu?.dropDownMenuHighlight,"object"==typeof a?a?.menuKey:a,e,i)){r=o,h=n;break}}if(t._dropDownMenuIsHighlight(e,i,o)){r=o;break}}if(-1!==r){let e;e=-1!==h?(o||t.globalDropDownMenu)[r].children[h]:(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:a.right,marginRight:0,funcType:l.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:a.right,marginRight:0,funcType:l.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===r.expand)return this.expandIcon;if(i===r.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 G;case"image":case"video":return Qj}}}class eN{_table;_tooltipElement;constructor(t){this._table=t}dispose(){this.unbindTooltipElement(),this._tooltipElement&&this._tooltipElement.dispose?.(),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 iN="vtable__bubble-tooltip-element",nN=`${iN}__content`,rN=`${iN}__triangle`,oN=`${iN}--hidden`,sN=`${iN}--shown`;class aN{_handler;_rootElement;_messageElement;_triangleElement;constructor(){this._handler=new xt;const t=this._rootElement=kj("div",[iN,oN]),e=kj("span",[nN]),i=kj("span",[rN]);t.appendChild(i),t.appendChild(e),this._messageElement=t.querySelector(`.${nN}`)||void 0,this._triangleElement=t.querySelector(`.${rN}`)||void 0}bindToCell(t,e,i,n,r){const o=this._rootElement,s=this._messageElement,a=this._triangleElement;if(o?.classList.remove(sN),o?.classList.add(oN),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(sN),o?.classList.remove(oN),!0}else this.unbindFromCell();return!1}dispose(){this.unbindFromCell();const t=this._rootElement;t?.parentElement&&t.parentElement.removeChild(t),this._handler?.dispose?.(),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(sN),o?.classList.remove(oN)):this.unbindFromCell()}unbindFromCell(){const t=this._rootElement;t?.parentElement&&(t.classList.remove(sN),t.classList.add(oN))}_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`,B()&&(a.style.fontSize="11px");const{x1:y,x2:m,y1:b,y2:v}=t.stateManeger.menu.bounds,w=d,C=w+f,x=l,_=w+g;return!(t.stateManeger.menu.isShow&&y<C&&m>w&&v>x&&b<_)}return!1}getComputedPosition(t,e,i,r,o,s,a){const l=this._rootElement,h=t.getCellRangeRelativeRect({col:e,row:i}),{width:c,height:u}=t.internalProps.element.getBoundingClientRect(),{width:d}=h;let p,f;const g=Math.min(.8*c,4*d);l.style.maxWidth=`${g}px`;const y=l.clientWidth,m=l.clientHeight,b=a?6:0;if(r)f=r.x,p=r.y+b,this._triangleElement.style.left="50%",this._triangleElement.style.marginLeft="-5px",this._triangleElement.style.top="-5px";else if(o){let e=o.placement??n.bottom;const i=o.rect.left+o.rect.width/2+t.tableX,r=o.rect.top+o.rect.height/2+t.tableY,a=o.rect.top+t.tableY,l=o.rect.bottom+t.tableY,h=o.rect.left+t.tableX,d=o.rect.right+t.tableX;let g=0;const v=()=>{g++,g>=4||(this.removeStyleFromTriangle(),e===n.top?(f=i-y/2,p=a-m-b,this._triangleElement.style.left="50%",this._triangleElement.style.marginLeft="-5px",this._triangleElement.style.bottom="-5px",s&&p<0&&(e=n.right,v())):e===n.bottom?(f=i-y/2,p=l+b,this._triangleElement.style.left="50%",this._triangleElement.style.marginLeft="-5px",this._triangleElement.style.top="-5px",s&&p+m>u&&(e=n.left,v())):e===n.left?(p=r-m/2,f=h-y-b,this._triangleElement.style.top="50%",this._triangleElement.style.marginTop="-5px",this._triangleElement.style.right="-5px",s&&f<0&&(e=n.top,v())):e===n.right&&(p=r-m/2,f=d+b,this._triangleElement.style.top="50%",this._triangleElement.style.marginTop="-5px",this._triangleElement.style.left="-5px",s&&f+y>c&&(e=n.bottom,v())))};v()}return s&&(f<0?f=0:f+l.offsetWidth>c&&(f=c-l.offsetWidth)),{x:f,y:p}}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 lN extends eN{createTooltipElementInternal(){return new aN}}const hN={"bubble-tooltip":function(t){return new lN(t)}};class cN{_table;_tooltipInstances;_attachInfo;confine;constructor(t,e){this._table=t,this._tooltipInstances={},this._bindTableEvent(t),this.confine=e}dispose(){const t=this._tooltipInstances;for(const e in t)t[e]?.dispose?.();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||!at(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||!at(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&&at(i.range,t,e)}_bindTableEvent(t){t.listen(yt.MOUSEENTER_CELL,(e=>{if(B())return;const{x1:i,x2:r,y1:o,y2:s}=t.stateManeger.menu.bounds;if(t.stateManeger.menu.isShow&&"number"==typeof e.x&&"number"==typeof e.y&&e.x>i&&e.x<r&&e.y>o&&e.y<s)return;const{col:a,row:l}=e;if((!e.related||!this._isBindCell(a,l))&&t.internalProps.tooltip?.isShowOverflowTextTooltip){const i=t.getCellOverflowText(a,l),r=t.getHeaderDescription(a,l),o=t.getCellRangeRelativeRect({col:a,row:l});let s;i&&(s={content:r?`${r}\n ${i}`:i,referencePosition:{placement:n.bottom,rect:o},style:{arrowMark:!1}}),r&&(s={content:r,referencePosition:{placement:n.bottom,rect:o},style:{arrowMark:!1}}),s&&this._bindToCell(e.col,e.row,s)}})),t.listen(yt.MOUSEMOVE_CELL,(e=>{if(!B()){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&&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.listen(yt.MOUSELEAVE_CELL,(t=>{t.related&&this._isBindCell(t.related.col,t.related.row)||this._unbindFromCell()})),t.listen(yt.SELECTED_CELL,(t=>{this._isBindCell(t.col,t.row)&&this._unbindFromCell()})),t.listen(yt.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]=hN[r](i))}isBinded(t){return JSON.stringify(t)===JSON.stringify(this._attachInfo?.tooltipOptions)}}class uN{_table;_menuElement;constructor(t){this._table=t}dispose(){this.unbindMenuElement(),this._menuElement&&this._menuElement.dispose(),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 dN="vtable__menu-element",pN=`${dN}--hidden`,fN=`${dN}--shown`;class gN{_handler;_rootElement;_menuInstanceInfo;constructor(t){this._handler=new xt,this._rootElement=kj("div",[dN,pN]),this._rootElement?.addEventListener("mousedown",(t=>{t.stopPropagation(),t.preventDefault()})),this._rootElement?.addEventListener("click",(e=>{if(e.stopPropagation(),e.preventDefault(),this._rootElement.classList.contains(pN))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(yt.DROPDOWNMENU_CLICK,{col:i,row:n,field:l,menuKey:o,text:s,highlight:h,cellType:t.getCellType(i,n)}),t.fireListeners(yt.DROPDOWN_MENU_CLEAR,null),t.fireListeners(yt.HIDE_MENU,null),e.stopPropagation()})),this._rootElement?.addEventListener("mousemove",(t=>{this._rootElement.classList.contains(pN)||t.stopPropagation()}))}get rootElement(){return this._rootElement}dispose(){this.unbindFromCell();const t=this._rootElement;t?.parentElement&&t.parentElement.removeChild(t),this._handler.dispose(),delete this._rootElement}bindToCell(t,e,i,n){const r=this._rootElement;if(this._menuInstanceInfo=n,r?.classList.remove(fN),r?.classList.add(pN),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(fN),r?.classList.remove(pN),!0}else this.unbindFromCell();return!1}unbindFromCell(){const t=this._rootElement;this._menuInstanceInfo=void 0,t?.parentElement&&(t.classList.remove(fN),t.classList.add(pN))}_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 yN extends uN{createMenuElementInternal(){return new qj(this._table)}}let mN=class extends uN{createMenuElementInternal(){return new gN(this._table)}};const bN={"dropdown-menu":function(t){return new yN(t)},"context-menu":function(t){return new yN(t)},container:t=>new mN(t)};class vN{_table;_menuInstances;_attachInfo;constructor(t){this._table=t,this._menuInstances={},this._bindTableEvent(t)}dispose(){const t=this._menuInstances;for(const e in t)t[e].dispose();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&&at(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.listen(yt.DROPDOWN_ICON_CLICK,(t=>{this._attachInfo&&this._isBindToCell(t.col,t.row)?this._unbindFromCell():this._bindToCell(t.col,t.row,"dropdown-menu")})),t.listen(yt.DROPDOWN_MENU_CLEAR,(t=>{this._unbindFromCell()})),t.listen(yt.CONTEXTMENU_CELL,(e=>{if("html"===t.internalProps.menu?.renderMode){const i=t._getMouseAbstractPoint(e.event,!1);let n=null;i&&"function"==typeof t.internalProps.menu?.contextMenuItems?n=t.internalProps.menu.contextMenuItems(t.getHeaderField(e.col,e.row),e.row):i&&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]=bN[i](r)),type:i,info:s}}}class wN extends EventTarget{_table;_input;constructor(t,e){if(super(),this._table=t,"node"===vt.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}dispose(){}}let CN=1;V?CN=1:(CN=Math.ceil(window.devicePixelRatio||1),CN>1&&CN%2!=0&&(CN+=1));const xN={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:!1,visible:!0};function _N(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:y,padding:m,...b}=ne({},xN,t),v=b;return i.visible&&(v.title=function(t){const e={...t};return Yt(t.style)||(e.textStyle=zL(t.style)),Yt(t.textStyle)||ne(e.textStyle,zL(t.textStyle)),t.shape?.style&&zL(e.shape.style),t.background?.style&&zL(e.background.style),e}(i)),Yt(n.focusIconStyle)||zL(n.focusIconStyle),jL(n.shape),jL(n.label),jL(n.value),jL(n.background),GF(n.maxWidth)&&(n.maxWidth=Number(n.maxWidth.substring(0,n.maxWidth.length-1))*e.width/100),GF(n.width)&&(n.width=Number(n.width.substring(0,n.width.length-1))*e.width/100),GF(n.height)&&(n.height=Number(n.height.substring(0,n.height.length-1))*e.width/100),v.item=n,Yt(r.textStyle)||zL(r.textStyle),jL(r.handler),v.pager=r,o.visible&&!Yt(o.style)&&(ne(v,o.style),kt(o.padding)&&(v.padding=o.padding)),v}class SN{table;option;orient;visible;position;selectedData;legendComponent;constructor(t,e){this.table=e,this.option=Qt(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 mL(ne({},t,{defaultSelected:this.selectedData}));e.name="legend",this.legendComponent=e,this.table.scenegraph.stage.defaultLayer.appendChild(e);let i=isFinite(this.legendComponent.AABBBounds.width())?this.legendComponent.AABBBounds.width():0,n=isFinite(this.legendComponent.AABBBounds.height())?this.legendComponent.AABBBounds.height():0;const r=this.table.tableNoFrameWidth,o=this.table.tableNoFrameHeight,s=cF(t.padding??this.option.padding??10);let a=0,l=0;"left"===this.orient?(a=s[3],l=0,i+=s[1]+s[3]):"top"===this.orient?(a=0,l=s[0],n+=s[0]+s[2]):"right"===this.orient?(a=r-i-s[1],l=0,i+=s[1]+s[3]):"bottom"===this.orient&&(a=0,l=o-n-s[2],n+=s[0]+s[2]);const h="bottom"===this.orient||"top"===this.orient?"horizontal":"vertical",c=this.position;let u=0,d=0;"horizontal"===h?u="middle"===c?(r-i)/2:"end"===c?r-i-s[1]:s[3]:d="middle"===c?(o-n)/2:"end"===c?o-n-s[2]:s[0],this.legendComponent.setAttributes({dx:u,dy:d,x:a,y:l}),"left"===this.orient?(this.table.tableNoFrameWidth=this.table.tableNoFrameWidth-Math.ceil(i),this.table.tableX=Math.ceil(i)):"top"===this.orient?(this.table.tableNoFrameHeight=this.table.tableNoFrameHeight-Math.ceil(n),this.table.tableY=Math.ceil(n)):"right"===this.orient?this.table.tableNoFrameWidth=this.table.tableNoFrameWidth-Math.ceil(i):"bottom"===this.orient&&(this.table.tableNoFrameHeight=this.table.tableNoFrameHeight-Math.ceil(n))}getLegendAttributes(t){return{layout:"bottom"===this.orient||"top"===this.orient?"horizontal":"vertical",items:this.getLegendItems(),maxWidth:t.width,maxHeight:t.height,..._N(this.option,t)}}getLegendItems(){return this.option.data}initEvent(){this.legendComponent&&(this.legendComponent.addEventListener(dL.legendItemClick,(t=>{const e=Xt(t,"detail.currentSelected");this.table.scenegraph.updateNextFrame(),this.table.fireListeners(yt.LEGEND_ITEM_CLICK,{model:this,value:e,event:t})})),this.legendComponent.addEventListener(dL.legendItemHover,(t=>{const e=Xt(t,"detail");this.table.scenegraph.updateNextFrame(),this.table.fireListeners(yt.LEGEND_ITEM_HOVER,{model:this,value:e,event:t})})),this.legendComponent.addEventListener(dL.legendItemUnHover,(t=>{const e=Xt(t,"detail");this.table.scenegraph.updateNextFrame(),this.table.fireListeners(yt.LEGEND_ITEM_UNHOVER,{model:this,value:e,event:t})})))}getLegendBounds(){return{width:isFinite(this.legendComponent.AABBBounds.width())?this.legendComponent.AABBBounds.width():0,height:isFinite(this.legendComponent.AABBBounds.height())?this.legendComponent.AABBBounds.height():0}}dispose(){this.legendComponent=null}}class AN{table;_titleOption;_titleComponent;_cacheAttrs;constructor(t,e){this.table=e,this._titleOption=t,this._titleComponent=this._createOrUpdateTitleComponent(this._getTitleAttrs())}_createOrUpdateTitleComponent(t){if(this._titleComponent)se(t,this._cacheAttrs)||this._titleComponent.setAttributes(t);else{const e=new WL(t);e.name="title",this.table.scenegraph.stage.defaultLayer.appendChild(e),this._titleComponent=e}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,cF(t.padding??this._titleOption.padding??10));return"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}),this._titleComponent}dispose(){this._titleComponent=null}_getTitleAttrs(){const t=cF(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:TN}=ft,{isTouchEvent:BN}=pt,RN=/^\$(\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 MN={};class PN extends E{internalProps;showFrozenIcon=!0;showSort=!0;padding;globalDropDownMenu;tableNoFrameWidth;tableNoFrameHeight;tableX;tableY;_widthMode;_heightMode;_autoFillWidth;customRender;canvasWidth;canvasHeight;dataSet;scenegraph;stateManeger;eventManeger;_pixelRatio;bottomFrozenRowCount=0;rightFrozenColCount=0;static get EVENT_TYPE(){return yt}options;version="0.9.3-alpha.2";pagerConf;id=`VTable${Date.now()}`;headerStyleCache;bodyStyleCache;constructor(t={}){super();const{frozenColCount:e=0,defaultRowHeight:i=40,defaultHeaderRowHeight:n,defaultColWidth:r=80,defaultHeaderColWidth:o,widthMode:s="standard",heightMode:a="standard",autoFillWidth:l=!1,keyboardOptions:h,parentElement:c,columnResizeMode:u,dragHeaderMode:d,showFrozenIcon:p,allowFrozenColCount:f,padding:g,hover:y,menu:m,select:b,customRender:v,pixelRatio:w=CN}=t;this.options=t,this._widthMode=s,this._heightMode=a,this._autoFillWidth=l,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 C=this.internalProps={};void 0!==p&&(this.showFrozenIcon=p),"number"==typeof f&&f<=0&&(this.showFrozenIcon=!1),C.handler=new xt,C.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),C.focusControl=new wN(this,C.element),C.pixelRatio=w,C.canvas=document.createElement("canvas"),C.element.appendChild(C.canvas),C.context=C.canvas.getContext("2d"),C.frozenColCount=e,C.defaultRowHeight=i,C.defaultHeaderRowHeight=n??i,C.defaultColWidth=r,C.defaultHeaderColWidth=o??r,C.keyboardOptions=h,C.columnResizeMode=u,C.dragHeaderMode=d,C._rowHeightsMap=new St,C._rowRangeHeightsMap=new Map,C._colRangeWidthsMap=new Map,this.colWidthsMap=new St,this.colContentWidthsMap=new St,this.colWidthsLimit={},C.calcWidthContext={_:C,get full(){return this._.canvas.width/(this._.context.pixelRatio??window.devicePixelRatio)}},C.cellTextOverflows={},C.focusedTable=!1,C.theme=Ui.of(t.theme??Ui.DEFAULT),c?(c.innerHTML="",c.appendChild(C.element),this._updateSize()):this._updateSize(),this.options=t,C.theme=Ui.of(t.theme??Ui.DEFAULT),C.bodyHelper=new Lj(this),C.headerHelper=new tN(this),C.autoWrapText=t.autoWrapText,C.allowFrozenColCount=t.allowFrozenColCount??C.colCount,C.limitMaxAutoWidth=t.limitMaxAutoWidth??450,this.dataSet=new xD,this.scenegraph=new oj(this),this.stateManeger=new wj(this),this.eventManeger=new Rj(this),t.legends&&(C.legends=new SN(t.legends,this),this.scenegraph.tableGroup.setAttributes({x:this.tableX,y:this.tableY})),t.title&&(C.title=new AN(t.title,this),this.scenegraph.tableGroup.setAttributes({x:this.tableX,y:this.tableY})),C.tooltip=Object.assign({renderMode:"html",isShowOverflowTextTooltip:!1,confine:!0},t.tooltip),"html"===C.tooltip.renderMode&&(C.tooltipHandler=new cN(this,C.tooltip.confine)),C.menu=Object.assign({renderMode:"html"},t.menu),Array.isArray(t.menu?.dropDownMenuHighlight)&&this.setDropDownMenuHighlight(t.menu?.dropDownMenuHighlight),Array.isArray(t.menu?.defaultHeaderMenuItems)&&(this.globalDropDownMenu=t.menu.defaultHeaderMenuItems),"html"===C.menu.renderMode&&(C.menuHandler=new vN(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.invalidate.bind(this),200);getParentElement(){return this.options.parentElement}getElement(){return this.internalProps.element}get canvas(){return this.internalProps.canvas}resize(){this._updateSize(),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 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)}get heightMode(){return this._heightMode}set heightMode(t){t!==this._heightMode&&(this._heightMode=t)}get autoFillWidth(){return this._autoFillWidth}set autoFillWidth(t){t!==this._autoFillWidth&&(this._autoFillWidth=t)}_colWidthDefineToPxWidth(t){return XF(t)?$F(this,this._calculateAutoColWidthExpr()):$F(this,t)}_calculateAutoColWidthExpr(){const t=this.internalProps.calcWidthContext.full;let e=0;const i=[];let n=0;const r=[];for(let o=0;o<this.internalProps.colCount;o++){const s=this.getColWidthDefine(o),a=this._getColWidthLimits(o);if(XF(s))a&&(r.push(a),a.min&&(e+=a.min)),n++;else{let t=s;if(a){const i=$F(this,t),n=YF(a,i);i!==n&&(t=`${n}px`),e+=n}i.push(t)}if(e>t)return"0px"}if(r.length&&i.length){const e=(t-$F(this,`calc(${i.map((t=>"number"==typeof t?`${t}px`:t)).join(" + ")})`))/n;if(r.forEach((t=>{t.min&&e<t.min?(i.push(t.minDef),n--):t.max&&t.max<e&&(i.push(t.maxDef),n--)})),n<=0)return`${e}px`}if(i.length){const t=[];let e=0;return i.forEach((i=>{"number"==typeof i?e+=i:t.push(i)})),t.push(`${e}px`),`calc((100% - (${t.join(" + ")})) / ${n})`}return 100/n+"%"}_getColWidthLimits(t){const e=this.colWidthsLimit[t];if(!e)return null;const i={};return e.min&&(i.min=$F(this,e.min),i.minDef=e.min),e.max&&(i.max=$F(this,e.max),i.maxDef=e.max),i}_adjustColWidth(t,e){const i=this._getColWidthLimits(t);return Math.max(YF(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"===vt.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"===vt.mode&&(e=this.canvasWidth-1,i=this.canvasHeight-1);const n=Math.floor(e-U(this.getTheme().scrollStyle)),r=Math.floor(i-U(this.getTheme().scrollStyle));if(this.internalProps.theme?.frameStyle){const t=TN(this.internalProps.theme.frameStyle?.borderLineWidth??[null]),e=TN(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=this.colWidthsMap.get(e);let r;r=i?"adaptive"===this.widthMode||this.transpose?Number(i):this._adjustColWidth(e,this._colWidthDefineToPxWidth(i)):this.isRowHeader(e,0)||this.isCornerHeader(e,0)?Array.isArray(this.defaultHeaderColWidth)?this.defaultHeaderColWidth[e]??this.internalProps.defaultColWidth:this.defaultHeaderColWidth:this.internalProps.defaultColWidth;const o=n+r;return t>=0&&e>=0&&!Number.isNaN(o)&&this._colRangeWidthsMap.set(`$${t}$${e}`,Math.round(o)),Math.round(o)}let r=0;for(let i=t;i<=e;i++)r+=this.isRowHeader(i,0)||this.isCornerHeader(i,0)?Array.isArray(this.defaultHeaderColWidth)?this.defaultHeaderColWidth[i]??this.internalProps.defaultColWidth:this.defaultHeaderColWidth:this.internalProps.defaultColWidth;this.colWidthsMap.each(t,e,((t,e)=>{r+=("adaptive"===this.widthMode||this.transpose?Number(t):this._adjustColWidth(e,this._colWidthDefineToPxWidth(t)))-(this.isRowHeader(e,0)||this.isCornerHeader(e,0)?Array.isArray(this.defaultHeaderColWidth)?this.defaultHeaderColWidth[e]??this.internalProps.defaultColWidth:this.defaultHeaderColWidth:this.internalProps.defaultColWidth)}));for(let i=t;i<=e;i++){if(this.colWidthsMap.has(i))continue;const t=this._adjustColWidth(i,this.internalProps.defaultColWidth);t!==this.internalProps.defaultColWidth&&(r+=t-this.internalProps.defaultColWidth)}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)}fillRowsHeight(t,e,i){for(let n=t;n<=e;n++)this.rowHeightsMap.put(n,Math.round(i)),this._rowRangeHeightsMap.set(`$0$${n}`,Math.round((this._rowRangeHeightsMap.get("$0$"+(n-1))??0)+i))}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){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)}getColWidthDefine(t){const e=this.colWidthsMap.get(t);return"number"==typeof e&&e<=0?0:e||(this.isRowHeader(t,0)||this.isCornerHeader(t,0)?Array.isArray(this.defaultHeaderColWidth)?this.defaultHeaderColWidth[t]??this.defaultColWidth:this.defaultHeaderColWidth:this.isRightFrozenColumn(t,this.columnHeaderLevelCount)?Array.isArray(this.defaultHeaderColWidth)?this.defaultHeaderColWidth[this.rowHeaderLevelCount-this.rightFrozenColCount]??this.defaultColWidth:this.defaultHeaderColWidth:this.defaultColWidth)}getColWidth(t){const e=this.getColWidthDefine(t);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=RN.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=RN.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=$F(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=$F(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 xi(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 xi(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 xi(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 xi(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))}}invalidate(){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 xi(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)}addDisposable(t){if(!t||!t.dispose||"function"!=typeof t.dispose)throw new Error("not disposable!");(this.internalProps.disposables=this.internalProps.disposables||[]).push(t)}dispose(){const t=this.internalProps;t.tooltipHandler?.dispose?.(),t.menuHandler?.dispose?.(),JF.clearAll(),super.dispose?.(),t.handler?.dispose?.(),t.focusControl?.dispose?.(),t.disposables&&(t.disposables.forEach((t=>t?.dispose?.())),t.disposables=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:y,heightMode:m,autoFillWidth:b,customRender:v}=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=y??"standard",this.heightMode=m??"standard",this.autoFillWidth=b??!1,this.customRender=v;const w=this.internalProps;"node"!==vt.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"}(w.element,this.padding),w.frozenColCount=e,w.defaultRowHeight=i,w.defaultHeaderRowHeight=n??i,w.defaultColWidth=r,w.defaultHeaderColWidth=o??r,w.keyboardOptions=s,w.columnResizeMode=a,w.dragHeaderMode=l,w.cellTextOverflows={},w._rowHeightsMap=new St,w._rowRangeHeightsMap=new Map,w._colRangeWidthsMap=new Map,this.colWidthsMap=new St,this.colContentWidthsMap=new St,this.colWidthsLimit={},w.theme=Ui.of(t.theme??Ui.DEFAULT),w.autoWrapText=t.autoWrapText,w.allowFrozenColCount=t.allowFrozenColCount??w.colCount,w.limitMaxAutoWidth=t.limitMaxAutoWidth??450,this.dataSet=new xD,this.scenegraph.clearCells(),this.stateManeger.initState(),t.legends&&(w.legends=new SN(t.legends,this),this.scenegraph.tableGroup.setAttributes({x:this.tableX,y:this.tableY})),t.title&&(w.title=new AN(t.title,this),this.scenegraph.tableGroup.setAttributes({x:this.tableX,y:this.tableY})),w.tooltip=Object.assign({renderMode:"html",isShowOverflowTextTooltip:!1,confine:!0},t.tooltip),"html"!==w.tooltip.renderMode||w.tooltipHandler||(w.tooltipHandler=new cN(this,w.tooltip.confine)),w.menu=Object.assign({renderMode:"html"},t.menu),"html"!==w.menu.renderMode||w.menuHandler||(w.menuHandler=new vN(this)),this.headerStyleCache=new Map,this.bodyStyleCache=new Map}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 xi(this.tableX,this.tableY,t,e)}_getMouseAbstractPoint(t,e=!0){const i=this;let n;if(!t)return null;n=BN(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();if(s.right<=r)return null;if(s.bottom<=o)return null;const a=s.width,l=a/(this.canvas.offsetWidth||a),h=s.height,c=h/(this.canvas.offsetHeight||h);return{x:(r-s.left)/l+(e?i.scrollLeft:0)-i.tableX,y:(o-s.top)/c+(e?i.scrollTop:0)-i.tableY}}_getCellEventArgsSet(t){const e=this._getMouseAbstractPoint(t);if(!e)return{};const i=this.getCellAt(e.x,e.y);if(i.col<0||i.row<0)return{abstractPos:e,cell:i};return{abstractPos:e,cell:i,eventArgs:{col:i.col,row:i.row,event:t,rect:i.rect}}}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()}updatePager(t){this.pagerConf&&("number"==typeof t.currentPage&&t.currentPage>=0&&(this.pagerConf.currentPage=t.currentPage),t.perPageCount&&(this.pagerConf.perPageCount=t.perPageCount||this.pagerConf.perPageCount),this.scenegraph.clearCells(),this.dataSource.updatePager(this.pagerConf),this.refreshRowColCount(),this.scenegraph.createSceneGraph(),this.invalidate())}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||null}get dataSource(){return this.internalProps.dataSource}set dataSource(t){this.scenegraph.clearCells(),VF(this,t),this.refreshRowColCount(),this.scenegraph.createSceneGraph(),this.invalidate()}get autoWrapText(){return this.internalProps.autoWrapText}set autoWrapText(t){this.internalProps.autoWrapText!==t&&(this.internalProps.autoWrapText=t,this.options.autoWrapText=t,this.internalProps.layoutMap&&(this.refreshHeader(),this.invalidate()))}get theme(){return this.internalProps.theme}set theme(t){const e=Ui.of(t);this.internalProps.theme=e||Ui.DEFAULT,this.options.theme=t,this.resize()}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).columnType}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}getCellType(t,e){return this.internalProps.layoutMap.getCellType(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.sortState=e,this.stateManeger.setSortState(this.sortState)),t){if(UF(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??R)}}this.refreshRowColCount()}else UF(this,t);this.scenegraph.createSceneGraph(),this.invalidate(),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),caption:i.caption,columnType:i.columnType?"string"==typeof i.columnType?i.columnType:"progressbar":"text",originData:this.getCellOriginRecord(t,e),cellRange:this.getCellRangeRelativeRect({col:t,row:e}),value:this.getCellValue(t,e),dataValue:this.getCellOriginValue(t,e),cellType:this.getCellType(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 MN;const o=this.internalProps.headerHelper.getStyleClass(r.headerType);if(i.isBottomFrozenRow(t,e)&&this.theme.bottomFrozenStyle)n=K({},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=K({},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=K(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.columnType),a=o?.style;return r=W(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),this.bodyStyleCache.set(n,r),r}clearCellStyleCache(){this.headerStyleCache.clear()}_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=qF(i,this,t,e,nW).theme,{autoWrapText:r,lineClamp:o,textOverflow:s}=i;return{textAlign:n.text.textAlign,textBaseline:n.text.textBaseline,bgColor:Et(n.group.fill)?nW("bgColor",i,t,e,this):n.group.fill,color:Et(n.text.fill)?nW("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:Et(n.group.stroke)?nW("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(A(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(A(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.invalidate()}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 yW.measureText(t,e)}measureTextBounds(t){const e=new bW(t);return{width:e.AABBBounds.width(),height:e.AABBBounds.height()}}getCustomRender(t,e){let i;if("body"!==this.getCellType(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.getCellType(t,e)){const n=this.getHeaderDefine(t,e);i=n?.headerCustomLayout}else{const n=this.getBodyColumnDefine(t,e);i=n?.customLayout}return i}}var EN=Object.freeze({__proto__:null,BaseTable:PN});function HN(t,e,i){const n=t[e];return t[e]=i,n}function LN(t){for(const e in t)delete t[e]}function kN(){LN(Ri),LN(ZF),LN(Cz)}var IN=Object.freeze({__proto__:null,chartModule:function(t,e){return null!=e?HN(Cz,t,e):Cz[t]},clearAll:kN,icon:function(t,e){return null!=e?HN(ZF,t,e):ZF[t]},theme:function(t,e){return null!=e?HN(Ri,t,e):Ri[t]}});var ON=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}`}}});function DN(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 FN(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 WN=0;class zN{_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}getCellType(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}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 t,e,i,n=0;return this.columnObjects.forEach(((r,o)=>{"number"==typeof r.width?n=Math.max(r.width,n):"auto"===r.width&&(i=!0),"number"==typeof r.minWidth&&(e=Math.max(r.minWidth,e)),"number"==typeof r.maxWidth&&(t=Math.max(r.maxWidth,t))})),n=n>0?n:i?"auto":void 0,{width:n,minWidth:e,maxWidth:t}}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=WN++,{captionIcon:l}=e,h={id:a,caption:e.caption,captionIcon:l,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]=h;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:WN++,field:i.field,fieldKey:i.fieldKey,fieldFormat:i.fieldFormat,width:i.width,minWidth:i.minWidth,maxWidth:i.maxWidth,icon:i.icon,columnType:i.columnType??"text",chartModule:"chartModule"in i?i.chartModule:null,chartSpec:"chartSpec"in i?i.chartSpec:null,sparklineSpec:"sparklineSpec"in i?i.sparklineSpec:Hi,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 FN(t,e,this)}}class jN{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 St;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 St,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?Ei:t.dimensionKey)&&this.dimensionKeys.put(t.level,t.indicatorKey?Ei:t.dimensionKey),t.id||(t.id=++NN));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===r.expand&&t.children?t.children.forEach((e=>{e.level=(t.level??0)+1,n+=this.setTreeNode(e,n,t)})):t.hierarchyState===r.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=r.expand,t.children.forEach((e=>{e.level=(t.level??0)+1,n+=this.setTreeNode(e,n,t)}))):t.children?(t.hierarchyState=r.collapse,t.children.forEach((e=>{e.level=(t.level??0)+1,this.setTreeNode(e,n,t)}))):(t.hierarchyState=r.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 NN=0,GN=0;class KN{_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=Ei;_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 jN(this.columnTree??[]),this.rowDimensionTree=new jN(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=++NN,e=Array(this.colCount-this.rowHeaderLevelCount).fill(t);this._columnHeaderCellIds.unshift(e);const i={id:t,caption:"string"==typeof this.columnHeaderTitle.title?this.columnHeaderTitle.title:this.columnsDefine.reduce(((t,e)=>"string"==typeof e?t:t+(t?`/${e.dimensionTitle}`:`${e.dimensionTitle}`)),""),field:void 0,headerType:this.columnHeaderTitle.headerType??"text",style:this.columnHeaderTitle.headerStyle,define:{id:t}};this.columnHeaderObjs.push(i),this._headerObjects[t]=i}if(GN=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=++NN,e=Array(this.rowCount-this.columnHeaderLevelCount).fill(t);this._rowHeaderCellIds.unshift(e);const i={id:t,caption:"string"==typeof this.rowHeaderTitle.title?this.rowHeaderTitle.title:this.rowsDefine.reduce(((t,e)=>"string"==typeof e?t:t+(t?`/${e.dimensionTitle}`:`${e.dimensionTitle}`)),""),field:void 0,headerType:this.rowHeaderTitle.headerType??"text",style:this.rowHeaderTitle.headerStyle,define:{id:t}};this.rowHeaderObjs.push(i),this._headerObjects[t]=i}GN=0,this.indicatorsAsCol=!A(this.rowDimensionKeys.find((t=>t===this.indicatorDimensionKey))),this._rowHeaderCellIds=C(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===GN)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.caption===i.value))),l={id:o,caption:i.value??a.caption,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),A(this._indicators.find((t=>t.indicatorKey===a.indicatorKey)))||this._indicators.push({id:++NN,indicatorKey:a.indicatorKey,field:a.indicatorKey,fieldFormat:a?.format,columnType: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&&(A(this._indicators.find((t=>t.indicatorKey===i.indicatorKey)))||this._indicators.push({id:++NN,indicatorKey:i.indicatorKey,field:i.indicatorKey,columnType:"text",define:Object.assign({},i)})),r[o]=l,this._headerObjects[o]=l,t[e][GN]=o;for(let i=e-1;i>=0;i--)t[i][GN]=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][GN]=o;GN++}})),r}_addHeadersForTreeMode(t,e,i,n,o,s){const a=[];return t[e]||function(e){const i=t[e]=[];if(0===GN)return i;const n=t[e-1];for(let t=0;t<n?.length;t++)i[t]=n[t]}(e),i.forEach((i=>{const l=i.id,h=this.rowsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.dimensionKey))??this.columnsDefine?.find((t=>"string"!=typeof t&&t.dimensionKey===i.dimensionKey)),c={id:l,caption:i.value,field:i.dimensionKey,style:i.level+1===o||"function"==typeof h?.headerStyle?h?.headerStyle:Object.assign({},h?.headerStyle,{textAlign:"left"}),headerType:h?.headerType??"text",headerIcon:h?.headerIcon,define:Object.assign(i,{linkJump:h?.linkJump,linkDetect:h?.linkDetect,templateLink:h?.templateLink,keepAspectRatio:h?.keepAspectRatio??!1,imageAutoSizing:h?.imageAutoSizing,headerCustomRender:h?.headerCustomRender,headerCustomLayout:h?.headerCustomLayout,dragHeader:h?.dragHeader}),fieldFormat:h?.headerFormat,dropDownMenu:h?.dropDownMenu,pivotInfo:{value:i.value,dimensionKey:i.dimensionKey,isPivotCorner:!1},hierarchyLevel:i.level,dimensionTotalLevel:o,hierarchyState:i.level+1===o?void 0:i.hierarchyState,width:h?.width,minWidth:h?.minWidth,maxWidth:h?.maxWidth};a[l]=c,this._headerObjects[l]=c,t[e][GN]=l;for(let i=e-1;i>=0;i--)t[i][GN]=n[i];if(i.hierarchyState===r.expand&&i.children)s&&GN++,this._addHeadersForTreeMode(t,e,i.children??[],[...n,l],o,s&&i.hierarchyState===r.expand).forEach((t=>a.push(t)));else{s&&GN++;for(let i=e+1;i<t.length;i++)t[i][GN]=l}})),a}_addCornerHeaders(t){const e=[];if(t)t.forEach(((t,i)=>{const n=++NN,r=this.rowsDefine?.find((e=>"string"!=typeof e&&e.dimensionKey===t))??this.columnsDefine?.find((e=>"string"!=typeof e&&e.dimensionKey===t)),o={id:n,caption:t===this.indicatorDimensionKey?this.indicatorTitle:r?.dimensionTitle??"",field:"维度名称",style:this.cornerSetting.headerStyle,headerType:this.cornerSetting.headerType??"text",define:{dimensionKey:"维度名称",id:n,value:t},dropDownMenu:r?.cornerDropDownMenu,pivotInfo:{value:r?.dimensionTitle??"",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=++NN,i={id:t,caption:"",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){}getCellType(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}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:this.getDimension(this.colDimensionKeys[this.colDimensionKeys.length-1],"column")?.multiDimension?1:0:0}get rightFrozenColCount(){return this.showHeader&&this.showColumnHeader?this.indicatorsAsCol||this.hideIndicatorName?this.getDimension(this.rowDimensionKeys[this.rowDimensionKeys.length-1],"row")?.multiDimension?1:0:this.indicatorsDefine.find((t=>t?.multiIndicator))?1:0: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,columnType: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,columnType: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)?.caption??"",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)?.caption??"",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]))),o=this.getHeader(t,e);if(o.define.hierarchyState=o.define.hierarchyState===r.collapse?r.expand:r.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=++NN,e=Array(this.rowCount-this.columnHeaderLevelCount).fill(t);this._rowHeaderCellIds.unshift(e);const i={id:t,caption:"string"==typeof this.rowHeaderTitle.title?this.rowHeaderTitle.title:this.rowsDefine.reduce(((t,e)=>"string"==typeof e?t:t+(t?`/${e.dimensionTitle}`:`${e.dimensionTitle}`)),""),field:void 0,headerType:this.rowHeaderTitle.headerType??"text",style:this.rowHeaderTitle.headerStyle,define:{field:"",headerType:"text",columnType:"text"}};this.rowHeaderObjs.push(i),this._headerObjects[t]=i}return GN=0,this._rowHeaderCellIds=C(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((A(s.dimensionKey)&&e.dimensionKey===s.dimensionKey||A(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((A(s.dimensionKey)&&i.dimensionKey===s.dimensionKey||A(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=v(this.getCellHeaderPathsWidthTreeNode(t.col,t.row).rowHeaderPaths),n=v(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(!A(i.indicatorKey)&&e.dimensionKey===i.dimensionKey&&e.value===i.value||A(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((!A(e.indicatorKey)&&i.dimensionKey===e.dimensionKey&&i.value===e.value||A(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 A(n)||A(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 DN(t,e,this)}getChartDataId(t,e){return FN(t,e,this)}}const UN={isEmpty:!0,id:void 0,field:void 0,headerType:void 0,define:void 0};class VN{_headerObjects=[];_headerObjectMap={};_indicatorObjects=[];_columnWidths=[];rowTree;columnTree;rowsDefine;columnsDefine;indicatorsDefine;indicatorKeys;_showRowHeader=!0;_showColumnHeader=!0;_rowHeaderTitle;_columnHeaderTitle;_indicatorShowType="column";indicatorsAsCol=!0;hideIndicatorName=!1;indicatorDimensionKey=Ei;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=C(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.dimensionTitle}`:`${e.dimensionTitle}`)),"");this._headerObjectMap[e]={id:e,caption:e,field:t,headerType:this.rowHeaderTitle.headerType??"text",style:this.rowHeaderTitle.headerStyle,define:{}},this._headerObjectMap[t]={id:t,caption:"",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.dimensionTitle}`:`${e.dimensionTitle}`)),"");this._headerObjectMap[e]={id:e,caption:e,field:t,headerType:this.columnHeaderTitle.headerType??"text",style:this.columnHeaderTitle.headerStyle,define:{}},this._headerObjectMap[t]={id:t,caption:"",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,caption:"",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.caption===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],caption:i[i.length-1],style:n?.headerStyle,define:{field:n?.dimensionKey??this.rows[i.length-1],headerType:n?.headerType??"text",columnType:"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],caption:i[i.length-1],style:n?.headerStyle,define:{field:n?.dimensionKey??this.columns[i.length-1],headerType:n?.headerType??"text",columnType:"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,caption:i.caption??e,style:i?.headerStyle,define:{field:this.indicatorDimensionKey,headerType:i?.headerType??"text",columnType:"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,caption:t===this.indicatorDimensionKey?this.indicatorTitle:e?.dimensionTitle??t,style:this.cornerSetting?.headerStyle,define:{field:t,headerType:this.cornerSetting?.headerType??"text",columnType:"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",columnType:e?.columnType??"text"},e),fieldFormat:e?.format,columnType:e?.columnType??"text",chartModule:e&&("chartModule"in e?e.chartModule:null),chartSpec:e&&("chartSpec"in e?e.chartSpec:null),sparklineSpec:"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}getCellType(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}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]??UN}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,columnType: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,columnType: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.caption: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.caption: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(!A(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(!A(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,A(r)||A(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=C(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)}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 function(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 e=i.getIndicatorKeyInChartSpec(t,i.columnHeaderLevelCount-1)[1];if(Wt(e)&&(e=e[0]),!e)return;const n=i.dataset.collectedValues[e+"_align"]?i.dataset.collectedValues[e+"_align"]:i.dataset.collectedValues[e],r=i.getRecordIndexByCol(t),o=n[i.getColKeysPath()[r][Math.max(0,i.columnHeaderLevelCount-1-i.topAxesCount)]],s=i._table.pivotChartAxes.find((t=>"top"===t.orient));if(!1===s?.visible)return;return ne({},s,{orient:"top",type:"linear",range:o,label:{flush:!0},title:{visible:!1}})}if(e===i.rowCount-i.bottomFrozenRowCount&&t>=i.rowHeaderLevelCount&&t<i.colCount-i.rightFrozenColCount){const n=i.getIndicatorKeyInChartSpec(t,e);let r=n[0];Wt(r)&&(r=r[0]);const o=i.dataset.collectedValues[r+"_align"]?i.dataset.collectedValues[r+"_align"]:i.dataset.collectedValues[r],s=i.getRecordIndexByCol(t),a=o[i.getColKeysPath()[s][Math.max(0,i.columnHeaderLevelCount-1-i.topAxesCount)]];let l=null;n.forEach((t=>{const e=i.getIndicatorInfo(t);e&&(l=e)}));const h=i._table.pivotChartAxes.find((t=>"bottom"===t.orient));if(!1===h?.visible)return;return ne({},h,{orient:"bottom",type:"linear",range:a,label:{flush:!0},title:{text:l?.caption,autoRotate:!0}})}if(t===i.rowHeaderLevelCount-1&&e>=i.rowHeaderLevelCount&&e<i.rowCount-i.bottomFrozenRowCount){let t=i.getDimensionKeyInChartSpec(i.rowHeaderLevelCount,e)[0];Wt(t)&&(t=t[0]);const n=i.dataset.collectedValues[t],r=i.getRecordIndexByRow(e),o=i.getRowKeysPath()[r],s=n[o[o.length-1]],a=i._table.pivotChartAxes.find((t=>"left"===t.orient));if(!1===a?.visible)return;return ne({},a,{orient:"left",type:"band",data:Array.from(s).reverse(),title:{visible:!1}})}}else{if(t===i.rowHeaderLevelCount-1&&e>=i.columnHeaderLevelCount&&e<i.rowCount-i.bottomFrozenRowCount){const n=i.getIndicatorKeyInChartSpec(t,e);let r=n[0];Wt(r)&&(r=r[0]);const o=i.dataset.collectedValues[r+"_align"]?i.dataset.collectedValues[r+"_align"]:i.dataset.collectedValues[r],s=i.getRecordIndexByRow(e),a=o[i.getRowKeysPath()[s][Math.max(0,i.rowHeaderLevelCount-1-i.leftAxesCount)]];let l=null;n.forEach((t=>{const e=i.getIndicatorInfo(t);e&&(l=e)}));const h=i._table.pivotChartAxes.find((t=>"left"===t.orient));if(!1===h?.visible)return;return ne({},h,{orient:"left",type:"linear",range:a,label:{flush:!0},title:{text:l?.caption,autoRotate:!0}})}if(t===i.colCount-i.rightFrozenColCount&&e>=i.columnHeaderLevelCount&&e<i.rowCount-i.bottomFrozenRowCount){let t=i.getIndicatorKeyInChartSpec(i.rowHeaderLevelCount-1,e)[1];if(Wt(t)&&(t=t[0]),!t)return;const n=i.dataset.collectedValues[t+"_align"]?i.dataset.collectedValues[t+"_align"]:i.dataset.collectedValues[t],r=i.getRecordIndexByRow(e),o=n[i.getRowKeysPath()[r][Math.max(0,i.rowHeaderLevelCount-1-i.leftAxesCount)]],s=i._table.pivotChartAxes.find((t=>"right"===t.orient));if(!1===s?.visible)return;return ne({},s,{orient:"right",type:"linear",range:o,label:{flush:!0},title:{visible:!1}})}if(e===i.rowCount-i.bottomFrozenRowCount&&t>=i.rowHeaderLevelCount&&t<i.colCount-i.rightFrozenColCount){let e=i.getDimensionKeyInChartSpec(t,i.columnHeaderLevelCount)[0];Wt(e)&&(e=e[0]);const n=i.dataset.collectedValues[e],r=i.getRecordIndexByCol(t),o=i.getColKeysPath()[r],s=n[o[o.length-1]],a=i._table.pivotChartAxes.find((t=>"bottom"===t.orient));if(!1===a?.visible)return;return ne({},a,{orient:"bottom",type:"band",data:Array.from(s),title:{visible:!1}})}}}(t,e,this)}getRawChartSpec(t,e){return DN(t,e,this)}getChartSpec(t,e){return function(t,e,i){let n=i.getRawChartSpec(t,e);return n?(n=Qt(n),n.axes=i.getChartAxes(t,e),n.padding=0,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(((t,e)=>{Wt(t)&&(t=t[0]);const r=(i.dataset.collectedValues[t+"_align"]?i.dataset.collectedValues[t+"_align"]:i.dataset.collectedValues[t])[i.getColKeysPath()[o][Math.max(0,i.columnHeaderLevelCount-1-i.topAxesCount)]],s=i._table.pivotChartAxes.find((t=>t.orient===(0===e?"bottom":"top")));n.push(ne({},s,{type:"linear",orient:0===e?"bottom":"top",label:{visible:!1},title:{visible:!1},range:r,seriesIndex:e}))}));let s=i.getDimensionKeyInChartSpec(i.rowHeaderLevelCount,t)[0];Wt(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=i._table.pivotChartAxes.find((t=>"left"===t.orient));n.push(ne({},u,{type:"band",orient:"left",label:{visible:!1,space:0},domainLine:{visible:!1},tick:{visible:!1},subTick:{visible:!1},title:{visible:!1},width:-1,domain:Array.from(c)}))}else{const r=i.getIndicatorKeyInChartSpec(t,e),o=i.getRecordIndexByRow(e);r.forEach(((t,e)=>{Wt(t)&&(t=t[0]);const r=(i.dataset.collectedValues[t+"_align"]?i.dataset.collectedValues[t+"_align"]:i.dataset.collectedValues[t])[i.getRowKeysPath()[o][Math.max(0,i.rowHeaderLevelCount-1-i.leftAxesCount)]],s=i._table.pivotChartAxes.find((t=>t.orient===(0===e?"left":"right")));n.push(ne({},s,{type:"linear",orient:0===e?"left":"right",label:{visible:!1},title:{visible:!1},range:r,seriesIndex:e}))}));let s=i.getDimensionKeyInChartSpec(t,i.columnHeaderLevelCount)[0];Wt(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=i._table.pivotChartAxes.find((t=>"bottom"===t.orient));n.push(ne({},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,domain:Array.from(c)}))}return n}(t,e,this)}getChartDataId(t,e){return FN(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))}}class $N{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 YN{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 XN extends YN{type=o.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 qN extends YN{type=o.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 ZN extends YN{type=o.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 JN extends YN{type=o.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===o.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 QN extends YN{type=o.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 tG extends YN{type=o.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 eG(t,e){return t&&e?t.toString().localeCompare(e.toString(),"zh"):t?1:-1}function iG(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 nG(t){return 2===t.length&&Gt(t[0])&&Gt(t[1])&&t[1]>=t[0]}function rG(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 oG(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 sG(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 aG(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 lG(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 hG(t,e){const i=[t.min,t.max],n=[e.min,e.max];if(!nG(i)||!nG(n))return;const r=rG(i),o=rG(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(!sG(r,o))return}else if(0===u&&0===d){if(!sG(o,r))return}else if(c||g)if(c&&!g){if(!oG(r,o))return}else if(g&&!c){if(!oG(o,r))return}else{if(a===d)return;if(a>d){if(!aG(r,o))return}else if(!aG(o,r))return}else{if(0===a&&0===u){if(!lG(r,o))return}else if(0===d&&0===s&&!lG(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 cG{dataConfig;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;constructor(t,e,i,n,r,o,s){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=e,this.columns=i,this.indicatorKeys=n,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??{230417170554008:{by:["230417171050031","230417171050028"]}},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(r){this.records=r;const t="undefined"!=typeof window?window.performance.now():0;this.setRecords(r),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 a="undefined"!=typeof window?window.performance.now():0;this.sortKeys();const l="undefined"!=typeof window?window.performance.now():0;console.log("sortKeys:",l-a);const h="undefined"!=typeof window?window.performance.now():0;this.rowKeysPath=s?this.TreeToArr2(s):this.TreeToArr(this.ArrToTree(this.rowKeys,this.rowsIsTotal,this?.totals?.row?.showGrandTotals,this.rowGrandTotalLabel,this.rowSubTotalLabel)),this.colKeysPath=o?this.TreeToArr2(o):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())}}registerAggregator(t,e){this.aggregators[t]=e}registerAggregators(){this.registerAggregator(o.RECORD,XN),this.registerAggregator(o.SUM,qN),this.registerAggregator(o.COUNT,ZN),this.registerAggregator(o.MAX,QN),this.registerAggregator(o.MIN,tG),this.registerAggregator(o.AVG,JN)}setRecords(t){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;this.dataConfig?.filterRules?.length>=1&&(t=!0);for(let e=0,i=this.records.length;e<i;e++){const i=this.records[e];t&&!this.filterRecord(i)||this.processRecord(i)}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){this.derivedFieldRules?.forEach(((e,i)=>{t[e.fieldName]=e.derivedFunc(t)}));const e=[],i=[];for(let e=0,n=this.rows.length;e<n;e++){const n=this.rows[e];i.push(t[n])}for(let i=0,n=this.columns.length;i<n;i++){const n=this.columns[i];e.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[o.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 n=i.join(this.stringJoinChar),r=e.join(this.stringJoinChar);0!==i.length&&(this.rowFlatKeys[n]||(this.rowKeys.push(i),this.rowFlatKeys[n]=1)),0!==e.length&&(this.colFlatKeys[r]||(this.colKeys.push(e),this.colFlatKeys[r]=1)),this.tree[n]||(this.tree[n]={}),this.tree[n]?.[r]||(this.tree[n][r]=[]);for(let e=0;e<this.indicatorKeys.length;e++){const i=this.getAggregatorRule(this.indicatorKeys[e]);if(this.tree[n]?.[r]?.[e]||(this.tree[n][r][e]=new this.aggregators[i?.aggregationType??o.SUM](i?.field??this.indicatorKeys[e],i?.formatFun)),i?.field)if("string"==typeof i?.field)A(t[i?.field])&&this.tree[n]?.[r]?.[e].push(t);else{const o=i?.field.find((e=>t[e]));o&&this.tree[n]?.[r]?.[e].push(t)}else A(t[this.indicatorKeys[e]])&&this.tree[n]?.[r]?.[e].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[o.MAX](this.indicatorKeys[e]),min:new this.aggregators[o.MIN](this.indicatorKeys[e]),total:new this.aggregators[t?.aggregationType??o.SUM](t?.field??this.indicatorKeys[e],t?.formatFun)}}this.indicatorStatistics[e].max.push(this.tree[n]?.[r]?.[e].value()),this.indicatorStatistics[e].min.push(this.tree[n]?.[r]?.[e].value()),this.indicatorStatistics[e].total.push(t)}}updateSortRules(t){this.sorted=!1,this.sortRules=t,this.sortKeys(),this.rowKeysPath=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.dataConfig.isPivotChart&&this.dealWithZeroAlign()}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 iG(e(t,[]),e(i,[]))}));break;case"value_z_to_a":this.rowKeys.sort((function(t,i){return-iG(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 iG(e([],t),e([],i))}));break;case"value_z_to_a":this.colKeys.sort((function(t,i){return-iG(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:iG})}return o}.call(this);return function(i,o){let a,l;for(let h=0;h<r.length;h++){if(l=r[h],l.sortRule?.sortByIndicator){let r=i,s=o;l.fieldIndex<t.length-1&&(r=i.slice(0,l.fieldIndex+1),r.push(e?n.totals?.row?.subTotalLabel:n.totals?.column?.subTotalLabel),s=o.slice(0,l.fieldIndex+1),s.push(e?n.totals?.row?.subTotalLabel:n.totals?.column?.subTotalLabel)),a=l.func(r,s)}else a=l.func(i[l.fieldIndex],o[l.fieldIndex]);if(0!==a)return a*(l.sortRule?.sortType===s.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?iG(o(n,t.query),o(r,t.query)):iG(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:iG(t,e)}}(t.sortBy):t.sortType?eG:t.sortFunc?t.sortFunc:iG}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,s=t.totals?.column?.subTotalsDimensions?.length;r<s;r++){const s=t.totals.column.subTotalsDimensions[r],a=t.columns.indexOf(s);if(a>=0){const r=n.slice(0,a+1);r.push(t.totals?.column?.subTotalLabel??"小计");const s=r.join(this.stringJoinChar);this.tree[e][s]||(this.tree[e][s]=[]);for(let n=0;n<this.indicatorKeys.length;n++){if(!this.tree[e][s][n]){const t=this.getAggregatorRule(this.indicatorKeys[n]);this.tree[e][s][n]=new this.aggregators[t?.aggregationType??o.SUM](t?.field??this.indicatorKeys[n],t?.formatFun)}this.tree[e][s][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??o.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((s=>{for(let i=0,a=t.totals?.row?.subTotalsDimensions?.length;i<a;i++){const a=t.totals.row.subTotalsDimensions[i],l=t.rows.indexOf(a);if(l>=0){const i=r.slice(0,l+1);i.push(t.totals?.row?.subTotalLabel??"小计");const a=i.join(this.stringJoinChar);if(this.tree[a]||(this.tree[a]={},e.push(a)),!this.tree[a][s]){this.tree[a][s]=[];for(let e=0;e<this.indicatorKeys.length;e++){if(!this.tree[a][s][e]){const t=this.getAggregatorRule(this.indicatorKeys[e]);this.tree[a][s][e]=new this.aggregators[t?.aggregationType??o.SUM](t?.field??this.indicatorKeys[e],t?.formatFun)}this.tree[a][s][e].push(t.tree[n]?.[s]?.[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][s]||(this.tree[i][s]=[]);for(let e=0;e<this.indicatorKeys.length;e++){if(!this.tree[i][s][e]){const t=this.getAggregatorRule(this.indicatorKeys[e]);this.tree[i][s][e]=new this.aggregators[t?.aggregationType??o.SUM](t?.field??this.indicatorKeys[e],t?.formatFun)}this.tree[i][s][e].push(t.tree[n]?.[s]?.[e])}}i(n,s)}))})),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];Wt(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"]={};for(const t in n){const o=n[t],s=r[t],a=hG(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]=uG(this.collectedValues[t],this.dataConfig.dimensionSortArray):this.cacheCollectedValues[t]=this.collectedValues[t])}}function uG(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 dG{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 pG={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 fG{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=pG[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 gG extends dG{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 yG=Object.freeze({__proto__:null,Circle:class extends dG{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 dG{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",g(t.width)?this.width=t.width:(this._widthObj=t.width,this.needCalcSize=!0),g(t.height)?this.height=t.height:(this._heightObj=t.height,this.needCalcSize=!0),this.directionKey=pG[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 fG(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 gG({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 gG({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 dG{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=pG[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 dG{type="icon";svg;iconName;cursor;cache;constructor(t){if(super(t),this.iconName=t.iconName,f(this.iconName)){const t=tW()[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 dG{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:gG,Sector:class extends dG{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 dG{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,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=yG,t.DataStatistics=ON,t.ListTable=class extends PN{showHeader=!0;constructor(t={}){super(t);const e=this.internalProps;this.pagerConf=t.pagerConf,e.sortState=t.sortState,e.columns=t.columns?v(t.columns):t.header?v(t.header):[],this.showHeader=t.showHeader??!0,this.transpose=t.transpose??!1,this.refreshHeader(),t.dataSource?VF(this,t.dataSource):t.records?this.setRecords(t.records,e.sortState):this.setRecords([])}isListTable(){return!0}isPivotTable(){return!1}isPivotChart(){return!1}get sortState(){return this.internalProps.sortState}set sortState(t){this.internalProps.sortState=t}get columns(){return this.internalProps.columns}set columns(t){this.internalProps.columns=t,this.options.columns=t,this.refreshHeader(),setTimeout((()=>{this.invalidate()}),0)}get header(){return this.internalProps.columns}set header(t){this.internalProps.columns=t,this.options.header=t,this.refreshHeader(),setTimeout((()=>{this.invalidate()}),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.invalidate()))}getCellValue(t,e){const i=this;if(i.internalProps.layoutMap.isHeader(t,e)){const{caption: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{caption: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.pagerConf=t.pagerConf,this.showHeader=t.showHeader??!0,i.columns=t.columns?v(t.columns):t.header?v(t.header):[],this.transpose=t.transpose??!1,this.refreshHeader(),i.disposables&&(i.disposables.forEach((t=>t?.dispose?.())),i.disposables=null),this._updateSize(),t.dataSource?VF(this,t.dataSource):t.records?this.setRecords(t.records,t.sortState):(this._resetFrozenColCount(),this.scenegraph.createSceneGraph(),this.invalidate()),new Promise((t=>{setTimeout(t,0)}))}refreshHeader(){const t=this,e=t.internalProps,i=t.transpose,n=t.showHeader;e.headerEvents&&e.headerEvents.forEach((e=>t.unlisten(e)));const r=e.layoutMap=new zN(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.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))}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.records.length;e++){const n=this.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(A(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 A(e)&&(r=i.getRecordStartRowByRecordIndex(e)),this.transpose?{start:{row:t.start.row,col:A(r)?r+t.start.col:void 0},end:{row:t.end.row,col:A(r)?r+t.end.col:void 0}}:{start:{col:t.start.col,row:A(r)?r+t.start.row:void 0},end:{col:t.end.col,row:A(r)?r+t.end.row:void 0}}}return null}getHierarchyState(t,e){if(!this.getBodyColumnDefine(t,e).tree)return r.none;const i=this.getRecordIndexByRow(t,e);return this.dataSource.getHierarchyState(i)}toggleHierarchyState(t,e){const i=this.getHierarchyState(t,e);i===r.expand?this.fireListeners(yt.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:r.collapse}):i===r.collapse&&this.fireListeners(yt.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:r.expand,originData:this.getCellOriginRecord(t,e)});const n=this.getRecordIndexByRow(t,e),o=this.dataSource.toggleHierarchyState(n),s=this.internalProps.layoutMap.toggleHierarchyState(o);this.refreshRowColCount(),this.clearCellStyleCache(),this.scenegraph.updateHierarchyIcon(t,e),this.scenegraph.updateRow(s.removeCellPositions,s.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),cellType:this.getCellType(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){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 e,i,n;if(Array.isArray(this.internalProps.sortState)?({order:e,field:i,fieldKey:n}=this.internalProps.sortState?.[0]):({order:e,field:i,fieldKey:n}=this.internalProps.sortState),i){const t=this._getSortFuncFromHeaderOption(this.internalProps.columns,i,n);let r;r=n?this.internalProps.layoutMap.headerObjects.find((t=>t&&t.fieldKey===n)):this.internalProps.layoutMap.headerObjects.find((t=>t&&t.field===i)),r?.define?.sort&&(this.dataSource.sort(r.field,e,t),this.scenegraph.sortCell())}this.stateManeger.updateSortState(t)}},t.PivotChart=class extends PN{pivotSortState;dataset;_selectedDataItemsInChart=[];_selectedDimensionInChart=[];_chartEventMap={};_axes;constructor(t){if(super(t),t.layout&&Object.assign(t,t.layout),this.setCustomStateNameToSpec(),this.internalProps.dataConfig={isPivotChart:!0},this.internalProps.enableDataAnalysis=!0,this._axes=Wt(t.axes)?t.axes:[],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)),[]),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.internalProps.dataConfig.dimensionSortArray=this._getDimensionSortArray(),this.dataset=new cG(this.internalProps.dataConfig,e,i,n,t.records,t.columnTree,t.rowTree)}this.refreshHeader(),t.dataSource?VF(this,t.dataSource):t.records?this.setRecords(t.records,this.internalProps.sortState):this.setRecords([])}static get EVENT_TYPE(){return mj}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.dataConfig={},this.internalProps.enableDataAnalysis=!0,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)),[]),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 cG(this.internalProps.dataConfig,e,i,n,t.records??this.internalProps.records,t.columnTree,t.rowTree)}return this.refreshHeader(),i.disposables&&(i.disposables.forEach((t=>t?.dispose?.())),i.disposables=null),this._updateSize(),t.dataSource?VF(this,t.dataSource):t.records?this.setRecords(t.records,void 0):(this._resetFrozenColCount(),this.scenegraph.createSceneGraph(),this.invalidate()),new Promise((t=>{setTimeout(t,0)}))}refreshHeader(){const t=this.internalProps;t.headerEvents&&t.headerEvents.forEach((t=>this.unlisten(t))),this.internalProps.enableDataAnalysis&&(t.layoutMap=new VN(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 XD({dataValue:s,...n.internalProps.layoutMap.getCellHeaderPaths(e,i)},t,gt)}return s}getCellValue(t,e){if(this.internalProps.layoutMap.isHeader(t,e)){const{caption: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{caption: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.invalidate()}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(at(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.records.length;t++){const e=this.records[t].splice(i.sourceIndex-this.rowHeaderLevelCount,i.moveSize);e.unshift(i.targetIndex-this.rowHeaderLevelCount,0),Array.prototype.splice.apply(this.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.records.splice(i.sourceIndex-this.columnHeaderLevelCount,i.moveSize);t.unshift(i.targetIndex-this.columnHeaderLevelCount,0),Array.prototype.splice.apply(this.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===r.expand?this.fireListeners(mj.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:r.collapse}):i===r.collapse&&this.fireListeners(mj.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:r.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),cellType:this.getCellType(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:o.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:o.RECORD})}else t.push({indicatorKey:e.indicatorKey,field:e.indicatorKey,aggregationType:o.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)}}))}_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}listenChart(t,e){this._chartEventMap[t]=e}unlistenChart(t){delete this._chartEventMap[t]}_bindChartEvent(t){if(t)for(const e in this._chartEventMap)t.on(e,this._chartEventMap[e])}updateFilterRules(t){this.internalProps.dataConfig.filterRules=t,this.dataset.updateFilterRules(t),Jz(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),t.addUpdateBoundTag()}}))}));Qz(t.rowHeaderGroup,t.table),Qz(t.colHeaderGroup,t.table),Qz(t.rightFrozenGroup,t.table),Qz(t.bottomFrozenGroup,t.table)}(this.scenegraph),this.invalidate()}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,viewBox:r,axes:a}=s.attribute;a.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:r.x1-s.getRootNode().table.scrollLeft,x2:r.x2-s.getRootNode().table.scrollLeft,y1:r.y1-s.getRootNode().table.scrollTop,y2:r.y2-s.getRootNode().table.scrollTop}),e.updateDataSync(i,n),o=e.convertDatumToPosition(t),this.invalidate()}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&&Wt(e.domain))return e.domain}}},t.PivotTable=class extends PN{pivotSortState;dataset;flatDataToObjects;constructor(t){if(super(t),t.layout&&Object.assign(t,t.layout),this.internalProps.dataConfig=t.dataConfig,this.internalProps.enableDataAnalysis=t.enableDataAnalysis,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)),[]),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.dataset=new cG(this.internalProps.dataConfig,e,i,n,t.records)}this.refreshHeader(),this.pivotSortState=[],t.pivotSortState&&this.updatePivotSortState(t.pivotSortState),t.dataSource?VF(this,t.dataSource):t.records?this.setRecords(t.records,this.internalProps.sortState):this.setRecords([])}static get EVENT_TYPE(){return yj}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),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 cG(i.dataConfig,e,n,r,t.records)}return this.refreshHeader(),i.disposables&&(i.disposables.forEach((t=>t?.dispose?.())),i.disposables=null),this._updateSize(),t.dataSource?VF(this,t.dataSource):t.records?this.setRecords(t.records,void 0):(this._resetFrozenColCount(),this.scenegraph.createSceneGraph(),this.invalidate()),this.pivotSortState=[],t.pivotSortState&&this.updatePivotSortState(t.pivotSortState),new Promise((t=>{setTimeout(t,0)}))}refreshHeader(){const t=this.internalProps;t.headerEvents&&t.headerEvents.forEach((t=>this.unlisten(t)));const e=this.options.records??this.internalProps.records;this.options.enableDataAnalysis?t.layoutMap=new VN(this,this.dataset):(Array.isArray(this.options.columnTree)||Array.isArray(this.options.rowTree))&&(t.layoutMap=new KN(this),e?.[0]?.constructor!==Array&&(this.flatDataToObjects=new $N({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=e?.bottomFrozenRowCount??0,t.rightFrozenColCount=e?.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 XD({dataValue:s,...n.internalProps.layoutMap.getCellHeaderPaths(e,i)},t,gt)}return s}getCellValue(t,e){if(this.internalProps.layoutMap.isHeader(t,e)){const{caption: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{caption: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.invalidate()}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(at(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.records.length;t++){const e=this.records[t].splice(i.sourceIndex-this.rowHeaderLevelCount,i.moveSize);e.unshift(i.targetIndex-this.rowHeaderLevelCount,0),Array.prototype.splice.apply(this.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.records.splice(i.sourceIndex-this.columnHeaderLevelCount,i.moveSize);t.unshift(i.targetIndex-this.columnHeaderLevelCount,0),Array.prototype.splice.apply(this.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===r.expand?this.fireListeners(yj.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:r.collapse}):i===r.collapse&&this.fireListeners(yj.TREE_HIERARCHY_STATE_CHANGE,{col:t,row:e,hierarchyState:r.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),cellType:this.getCellType(t,e),isPivotCorner:this.isCornerHeader(t,e)}}},t.TYPES=c,t.clearGlobal=function(){kN()},t.core=EN,t.data=QD,t.getIcons=function(){return tW()},t.register=IN,t.themes=Vi,t.version="0.9.3-alpha.2"}));