@taocompany/magic-grid 0.13.6 → 0.13.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./validation-CD6lt5wS.cjs"),t=require("./getRowDragCommitHierarchy-DoMf_SY8.cjs");let n=require("vue");var r={class:`mg-status-bar__panels`},i=(0,n.defineComponent)({__name:`StatusBarDefaultPanels`,props:{context:{}},setup(e){let t=e,i=(0,n.computed)(()=>{let{context:e}=t,n=[];return n.push(`共 ${e.totalRowCount} 行`),e.isFiltered&&n.push(`显示 ${e.displayedRowCount} 行`),e.rowSelectionEnabled&&e.selectedRowCount>0&&n.push(`已选 ${e.selectedRowCount} 行`),n});return(e,t)=>((0,n.openBlock)(),(0,n.createElementBlock)(`div`,r,[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)(i.value,(e,t)=>((0,n.openBlock)(),(0,n.createElementBlock)(`span`,{key:t,class:`mg-status-bar__panel`},(0,n.toDisplayString)(e),1))),128))]))}}),a=2;function o(e){if(typeof e==`number`){let t=s(e);return{average:t,sum:t}}return{average:s(e?.average??2),sum:s(e?.sum??2)}}function s(e){return Number.isFinite(e)?Math.max(0,Math.min(10,Math.trunc(e))):2}function c(e,t,n=2){if(t===`count`)return String(Math.trunc(e));let r=s(n),i=10**r,a=Math.round(e*i)/i;return r===0?String(Math.round(a)):a.toFixed(r).replace(/\.?0+$/,``)}function l(e){return e!=null&&e.count>0}var u={key:0,class:`mg-status-bar__panels mg-status-bar__panels--aggregation`},d=(0,n.defineComponent)({__name:`StatusBarRangeAggregationPanels`,props:{context:{}},setup(e){let t=e,r=(0,n.computed)(()=>l(t.context.cellSelectionAggregation)),i=(0,n.computed)(()=>{let e=t.context.cellSelectionAggregation;if(!l(e))return[];let n=t.context.statusBarRangeAggregationPrecision,r=[];return e.average!=null&&r.push({label:`平均值`,value:c(e.average,`average`,n.average)}),r.push({label:`计数`,value:c(e.count,`count`)}),e.sum!=null&&r.push({label:`求和`,value:c(e.sum,`sum`,n.sum)}),r});return(e,t)=>r.value&&i.value.length?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,u,[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)(i.value,(e,t)=>((0,n.openBlock)(),(0,n.createElementBlock)(`span`,{key:t,class:`mg-status-bar__panel`},(0,n.toDisplayString)(e.label)+`: `+(0,n.toDisplayString)(e.value),1))),128))])):(0,n.createCommentVNode)(``,!0)}}),f={key:0,class:`mg-status-bar__region mg-status-bar__region--left`},p={key:1,class:`mg-status-bar__separator`,role:`separator`,"aria-orientation":`vertical`},m={key:3,class:`mg-status-bar__separator`,role:`separator`,"aria-orientation":`vertical`},h={key:4,class:`mg-status-bar__separator`,role:`separator`,"aria-orientation":`vertical`},g={key:6,class:`mg-status-bar__separator`,role:`separator`,"aria-orientation":`vertical`},_={key:7,class:`mg-status-bar__region mg-status-bar__region--right`},v=(0,n.defineComponent)({__name:`MagicGridStatusBar`,props:{context:{},barStyle:{},showDefaultPanels:{type:Boolean},showStatusBarRangeAggregation:{type:Boolean},statusBarRangeAggregationPosition:{},hasCustomStatusBarSlot:{type:Boolean},hasLeftSlot:{type:Boolean},hasRightSlot:{type:Boolean}},setup(e,{expose:t}){let r=e,a=(0,n.ref)();t({get statusBarEl(){return a.value}});let o=(0,n.computed)(()=>r.showDefaultPanels||r.hasLeftSlot),s=(0,n.computed)(()=>r.hasRightSlot),c=(0,n.computed)(()=>r.showStatusBarRangeAggregation?l(r.context.cellSelectionAggregation):!1),u=(0,n.computed)(()=>r.statusBarRangeAggregationPosition===`left`&&c.value),v=(0,n.computed)(()=>r.statusBarRangeAggregationPosition===`right`&&c.value),y=(0,n.computed)(()=>o.value),b=(0,n.computed)(()=>u.value),x=(0,n.computed)(()=>v.value||s.value),S=(0,n.computed)(()=>v.value&&s.value);return(t,r)=>((0,n.openBlock)(),(0,n.createElementBlock)(`div`,{ref_key:`statusBarEl`,ref:a,class:`mg-status-bar`,style:(0,n.normalizeStyle)(e.barStyle),role:`status`,"aria-live":`polite`},[e.hasCustomStatusBarSlot?(0,n.renderSlot)(t.$slots,`status-bar`,(0,n.normalizeProps)((0,n.guardReactiveProps)(e.context)),void 0,void 0,0):((0,n.openBlock)(),(0,n.createElementBlock)(n.Fragment,{key:1},[o.value?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,f,[e.showDefaultPanels?((0,n.openBlock)(),(0,n.createBlock)(i,{key:0,context:e.context},null,8,[`context`])):(0,n.createCommentVNode)(``,!0),(0,n.renderSlot)(t.$slots,`status-bar-left`,(0,n.normalizeProps)((0,n.guardReactiveProps)(e.context)))])):(0,n.createCommentVNode)(``,!0),y.value?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,p)):(0,n.createCommentVNode)(``,!0),u.value?((0,n.openBlock)(),(0,n.createBlock)(d,{key:2,context:e.context},null,8,[`context`])):(0,n.createCommentVNode)(``,!0),b.value?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,m)):(0,n.createCommentVNode)(``,!0),r[0]||=(0,n.createElementVNode)(`div`,{class:`mg-status-bar__stretch`,"aria-hidden":`true`},null,-1),x.value?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,h)):(0,n.createCommentVNode)(``,!0),v.value?((0,n.openBlock)(),(0,n.createBlock)(d,{key:5,context:e.context},null,8,[`context`])):(0,n.createCommentVNode)(``,!0),S.value?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,g)):(0,n.createCommentVNode)(``,!0),s.value?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,_,[(0,n.renderSlot)(t.$slots,`status-bar-right`,(0,n.normalizeProps)((0,n.guardReactiveProps)(e.context)))])):(0,n.createCommentVNode)(``,!0)],64))],4))}}),y={columns:{type:Array,required:!0},data:{type:Array,default:()=>[]},rowModelType:{type:String,default:`clientSide`},infiniteDatasource:{type:Object,default:void 0},blockSize:{type:Number,default:void 0},maxBlocksInCache:{type:Number,default:void 0},infiniteInitialRowCount:{type:Number,default:void 0},infiniteMaxRetries:{type:Number,default:void 0},infiniteLoadingRowVisible:{type:Boolean,default:void 0},cellEditorRegistry:{type:Object,default:void 0},rowKey:{type:String,default:`id`},stripe:{type:Boolean,default:!1},cellColor:{type:Object,default:void 0},border:{type:String,default:`border`},theme:{type:String,default:`light`},size:{type:String,default:`default`},rounded:{type:[Boolean,Number],default:!1},rowHeight:{type:Number,default:void 0},headerHeight:{type:Number,default:void 0},showIndexColumn:{type:Boolean,default:!1},indexColumn:{type:Object,default:void 0},selectionColumn:{type:Object,default:void 0},showSummary:{type:Boolean,default:!1},navigateHeader:{type:Boolean,default:!1},navigateFooter:{type:Boolean,default:!1},summaryScope:{type:String,default:`displayed`},summaryRowHeight:{type:Number,default:void 0},summaryMethod:{type:Function,default:void 0},headerAlign:{type:String,default:void 0},headerValign:{type:String,default:void 0},align:{type:String,default:void 0},valign:{type:String,default:void 0},footerAlign:{type:String,default:void 0},footerValign:{type:String,default:void 0},rowBuffer:{type:Number,default:10},scrollEndFlushMs:{type:Number,default:0},frameBudgetMs:{type:Number,default:void 0},scrollEndFrameBudgetMs:{type:Number,default:void 0},cellRendererDefer:{type:String,default:`always`},deferRowDestroyOnScroll:{type:Boolean,default:!1},rendererFrameBudgetMs:{type:Number,default:void 0},cellRendererPresentation:{type:String,default:`deferred`},rowSelection:{type:[String,Boolean,Object],default:`single`},selectable:{type:Function,default:void 0},isRowDisabled:{type:[Boolean,Function],default:void 0},rowStyle:{type:[Object,Function],default:void 0},editableCellStyle:{type:Object,default:void 0},showEditableCellIcon:{type:Boolean,default:!1},disabledCellStyle:{type:Object,default:void 0},showDisabledCellIcon:{type:Boolean,default:!1},reserveSelection:{type:Boolean,default:!1},preserveScrollOnSetData:{type:Boolean,default:!0},defaultSelectedRows:{type:[Array,Function],default:void 0},editBehavior:{type:String,default:`cell`},editType:{type:String,default:`singleClick`},editorOptions:{type:Object,default:void 0},invalidEditValueMode:{type:String,default:`block`},rowValidator:{type:Function,default:void 0},asyncRowMutation:{type:Object,default:void 0},height:{type:[String,Number],default:`100%`},width:{type:[String,Number],default:`100%`},defaultSort:{type:Array,default:void 0},sortable:{type:Boolean,default:!1},enableHeaderSortClick:{type:Boolean,default:!0},columnMovable:{type:Boolean,default:!0},resizable:{type:Boolean,default:!0},colResizeDefault:{type:String,default:void 0},skipHeaderOnAutoSize:{type:Boolean,default:!1},autoSizePadding:{type:Number,default:void 0},autoSizeStrategy:{type:Object,default:void 0},suppressMoveWhenColumnDragging:{type:Boolean,default:!1},suppressColumnMoveAnimation:{type:Boolean,default:!1},allowCrossLaneColumnMove:{type:Boolean,default:!1},showUnsortedSortHintOnHover:{type:Boolean,default:!1},quickFilterText:{type:String,default:``},filterable:{type:Boolean,default:!1},floatingFilter:{type:Boolean,default:!1},filterSetValueMode:{type:String,default:`current`},filterSetDateLayoutMode:{type:String,default:`tree`},showStatusBar:{type:Boolean,default:!0},showDefaultStatusBarPanels:{type:Boolean,default:!0},statusBarHeight:{type:[String,Number],default:`auto`},showStatusBarRangeAggregation:{type:Boolean,default:!0},statusBarRangeAggregationPosition:{type:String,default:`right`},statusBarRangeAggregationPrecision:{type:[Number,Object],default:void 0},rowDragManaged:{type:Boolean,default:!0},getRowHeight:{type:Function,default:void 0},rowHeightMin:{type:Number,default:void 0},rowHeightMax:{type:Number,default:void 0},enableCellSpan:{type:Boolean,default:!1},enableCellEditorCache:{type:Boolean,default:!1},cellEditorCacheMaxEntries:{type:Number,default:void 0},masterDetail:{type:Boolean,default:!1},isRowMaster:{type:Function,default:void 0},masterDefaultExpanded:{type:Number,default:void 0},detailRowHeight:{type:[Number,Function],default:void 0},detailRowAutoHeight:{type:Boolean,default:void 0},embedFullWidthRows:{type:Boolean,default:void 0},showExpandColumn:{type:Boolean,default:void 0},getDetailRowData:{type:Function,default:void 0},detailCellRenderer:{type:Function,default:void 0},loadMoreRow:{type:Object,default:void 0},loadMoreRowRenderer:{type:Function,default:void 0},rowGrouping:{type:Boolean,default:!1},groupDefaultExpanded:{type:Number,default:void 0},showGroupHeader:{type:Boolean,default:!1},showGroupFooter:{type:Boolean,default:!1},groupDisplayType:{type:String,default:void 0},showGroupColumn:{type:Boolean,default:!1},autoGroupColumnDef:{type:Object,default:void 0},groupKeyCreator:{type:Function,default:void 0},groupComparator:{type:Function,default:void 0},groupSortKey:{type:String,default:void 0},groupFooterLabel:{type:String,default:void 0},groupCellRenderer:{type:Function,default:void 0},tree:{type:Boolean,default:!1},getDataPath:{type:Function,default:void 0},showTreeColumn:{type:Boolean,default:void 0},autoTreeColumnDef:{type:Object,default:void 0},treeValueGetter:{type:Function,default:void 0},treeDisplayType:{type:String,default:void 0},treeDragScope:{type:String,default:void 0},treeHierarchyActions:{type:Boolean,default:void 0},setDataPath:{type:Function,default:void 0},treeLazyLoad:{type:Boolean,default:!1},hasTreeChildren:{type:Function,default:void 0},loadTreeChildren:{type:Function,default:void 0},cellCommentsDataSource:{type:Object,default:void 0},suppressCellComments:{type:Boolean,default:!1},cellCommentTrigger:{type:String,default:`click`},cellCommentShowDelay:{type:Number,default:void 0},cellCommentHideDelay:{type:Number,default:void 0},cellSelection:{type:[Boolean,Object],default:!0},enableCellCopy:{type:Boolean,default:void 0},enableCellPaste:{type:Boolean,default:void 0},enableHeaderHighlight:{type:Boolean,default:!0},enableIndexColumnHighlight:{type:Boolean,default:!0},processCellForClipboard:{type:Function,default:void 0},processCellFromClipboard:{type:Function,default:void 0},processDataFromClipboard:{type:Function,default:void 0},enableTooltips:{type:Boolean,default:void 0},tooltipShowMode:{type:String,default:void 0},tooltipShowDelay:{type:Number,default:void 0},tooltipSwitchShowDelay:{type:Number,default:void 0},tooltipHideDelay:{type:Number,default:void 0},tooltipInteraction:{type:Boolean,default:void 0},tooltipMouseTrack:{type:Boolean,default:void 0},tooltipComponent:{type:Function,default:void 0},tooltipComponentParams:{type:Object,default:void 0},loading:{type:Boolean,default:void 0},suppressOverlays:{type:Array,default:void 0},suppressLoadingOverlay:{type:Boolean,default:void 0},suppressNoRowsOverlay:{type:Boolean,default:void 0},suppressNoMatchingRowsOverlay:{type:Boolean,default:void 0},overlayLoadingTemplate:{type:String,default:void 0},overlayNoRowsTemplate:{type:String,default:void 0},overlayNoMatchingRowsTemplate:{type:String,default:void 0},overlayInteraction:{type:Boolean,default:void 0},loadingOverlayComponent:{type:Function,default:void 0},loadingOverlayComponentParams:{type:Object,default:void 0},noRowsOverlayComponent:{type:Function,default:void 0},noRowsOverlayComponentParams:{type:Object,default:void 0},noMatchingRowsOverlayComponent:{type:Function,default:void 0},noMatchingRowsOverlayComponentParams:{type:Object,default:void 0},overlayComponent:{type:Function,default:void 0},overlayComponentParams:{type:Object,default:void 0}},b=`__expand__`,x=`__detail`,S=`mg-cell__row-expand`,C=`mg-cell__row-expand--expanded`,w=`mg-full-width-rows-container`,T=`mg-full-width-row`,E=`mg-full-width-row__content`,D=`mg-full-width-row--last`;function O(e){return!0}function k(e={}){return{masterDetail:e.masterDetail??!1,isRowMaster:e.isRowMaster??O,masterDefaultExpanded:e.masterDefaultExpanded??0,detailRowHeight:e.detailRowHeight??200,detailRowAutoHeight:e.detailRowAutoHeight??!1,embedFullWidthRows:e.embedFullWidthRows??!1,showExpandColumn:e.showExpandColumn??!1,getDetailRowData:e.getDetailRowData,detailCellRenderer:e.detailCellRenderer}}function A(e){return e===b}function j(e){return A(e.colId)||e.rowExpand}function M(e,n){return t.it(n)||t.X(n)||A(n)?!1:e??!1}function ee(e,t){return M(e.rowExpand,t)}function N(e){return e??`BUSINESS`}function P(e){return`${e}${x}`}function F(e){return e.endsWith(x)}function I(e){return N(e.rowKind)===`DETAIL`||F(e.id)}function te(e){return N(e.rowKind)===`BUSINESS`&&!F(e.id)}function ne(e,t){let n=typeof e==`function`?e(t):e;return!Number.isFinite(n)||n<1?200:Math.floor(n)}function re(e,t){return{rowId:e,expanded:!0,source:t}}function ie(e,t){return{rowId:e,expanded:!1,source:t}}function ae(e){return e.available!==!1}function oe(e){return e.filter(ae)}var se=`__group__`,ce=`group::`,le=`__header`,ue=`__footer`,de=`(Blanks)`,fe=`mg-cell__group-expand`,pe=`mg-cell__group-expand--expanded`,me=`mg-cell__group-indent-`,he=`mg-row--group-header`,ge=`mg-row--group-footer`,_e=`mg-cell--group-auto`;function ve(e={}){return{rowGrouping:e.rowGrouping??!1,groupDefaultExpanded:e.groupDefaultExpanded??-1,showGroupHeader:e.showGroupHeader??!1,showGroupFooter:e.showGroupFooter??!1,groupDisplayType:e.groupDisplayType??`singleColumn`,showGroupColumn:e.showGroupColumn??!1,autoGroupColumnDef:e.autoGroupColumnDef,groupKeyCreator:e.groupKeyCreator,groupComparator:e.groupComparator,groupSortKey:e.groupSortKey,groupFooterLabel:e.groupFooterLabel??`小计`,groupCellRenderer:e.groupCellRenderer}}function L(e){return e===se}function ye(e){return L(e.colId)}function be(e,n){return t.it(n)||t.X(n)||A(n)||L(n)?!1:e??!1}function xe(e,t){return be(e.rowGroup,t)}function Se(e,t){if(xe(e,t))return e.rowGroupIndex}function Ce(e,n){if(!(t.it(n)||t.X(n)||A(n)||L(n)))return e.groupAgg}function we(e,n){return t.it(n)||t.X(n)||A(n)||L(n)?!1:e.showGroupHeaderCell??!1}function Te(e,n){return t.it(n)||t.X(n)||A(n)||L(n)?!1:e.showGroupFooterCell??!1}function Ee(e,n){if(!(t.it(n)||t.X(n)||A(n)||L(n)))return e.groupFooterLabel}function De(e){return ye(e)||e.showGroupHeaderCell}function Oe(e){return ye(e)||e.showGroupFooterCell}function ke(e,t){return Ue(t)?Ve(t)?De(e):He(t)?Oe(e):!1:!1}function Ae(e){let n=oe(e).map((e,n)=>{let r=t.at(e,n);return{colId:r,rowGroup:xe(e,r),rowGroupIndex:e.rowGroupIndex,index:n}}).filter(e=>e.rowGroup);return n.sort((e,t)=>{let n=e.rowGroupIndex??e.index,r=t.rowGroupIndex??t.index;return n===r?e.index-t.index:n-r}),n.map(e=>e.colId)}function je(e,t){return e&&t}function Me(e,t){return e&&t.length>0}function Ne(e){if(e==null||e===``)return de;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);if(e instanceof Date)return Number.isNaN(e.getTime())?de:e.toISOString();try{return JSON.stringify(e)}catch{return de}}function Pe(e,t,n,r){let i=`${ce}L${e}::${encodeURIComponent(t)}::${encodeURIComponent(n)}`;return r?`${r}::${i}`:i}function Fe(e){return e.join(`/`)}function Ie(e){return`${e}${le}`}function Le(e){return`${e}${ue}`}function Re(e){return e.endsWith(le)}function ze(e){return e.endsWith(ue)}function Be(e){return Re(e)||ze(e)?e.slice(0,-8):null}function Ve(e){return e.rowKind===`GROUP_HEADER`||Re(e.id)}function He(e){return e.rowKind===`GROUP_FOOTER`||ze(e.id)}function Ue(e){return e.group===!0||Ve(e)||He(e)}function R(e){return Ue(e)?!1:e.rowKind===void 0||e.rowKind===`BUSINESS`}function We(e){return{groupId:e.groupId,expanded:e.expanded,field:e.field,key:e.key,level:e.level,source:e.source}}function Ge(e,t){return{columns:[...e],source:t}}var Ke=`__tree__`,qe=`mg-cell__tree-expand`,Je=`mg-cell__tree-expand--expanded`,Ye=`mg-cell__tree-expand--loading`,Xe=`mg-cell__tree-indent-`,Ze=`mg-cell__tree-hierarchy-trigger`,Qe=`mg-cell__tree-hierarchy-actions`,$e=`mg-cell--tree-auto`;function et(e){return e||(({data:e,dataPath:t})=>{Array.isArray(e.pathSegments)&&(e.pathSegments=[...t])})}function tt(e={}){let t=e.treeLazyLoad??!1,n=e.loadTreeChildren;return t&&typeof n!=`function`&&console.warn(`[magic-grid] treeLazyLoad: true requires loadTreeChildren callback.`),{tree:e.tree??!1,getDataPath:e.getDataPath,treeDragScope:e.treeDragScope??`siblings`,setDataPath:et(e.setDataPath),treeHierarchyActions:e.treeHierarchyActions??!0,showTreeColumn:e.showTreeColumn??!0,autoTreeColumnDef:e.autoTreeColumnDef,treeValueGetter:e.treeValueGetter,treeDisplayType:e.treeDisplayType??`singleColumn`,treeLazyLoad:t,hasTreeChildren:e.hasTreeChildren,loadTreeChildren:n}}function z(e){return e===Ke}function nt(e,t){return e===!0&&typeof t==`function`}function rt(e,t,n){return nt(e,n)&&t!==!1}function B(e){return e.dataPath!=null&&e.dataPath.length>0}function it(e){e.forEach((e,n)=>{let r=t.at(e,n);(r===`__tree__`||t.it(r)||t.X(r)||A(r)||L(r))&&console.warn(`[magic-grid] Column colId "${r}" is reserved for system columns and will be ignored.`)})}function at(e,t,n,r,i){return{rowId:e,expanded:t,level:n,dataPath:r,source:i}}function ot(e,t){if(e&&typeof t!=`function`)throw Error(`[magic-grid] tree: true requires getDataPath callback.`)}var st=`__mg_summary__`;function ct(e={}){return{showSummary:e.showSummary??!1,summaryScope:e.summaryScope??`displayed`,summaryRowHeight:e.summaryRowHeight,summaryMethod:e.summaryMethod}}function lt(e,t){return e??t}var ut=`mg-cell--disabled`,dt=`data-disabled`,ft=`mg-cell--disabled-icon-hint`,pt=`mg-cell__disabled-indicator`;function mt(e={}){return{isRowDisabled:e.isRowDisabled}}function ht(e){return t.it(e)||t.X(e)||A(e)||z(e)||L(e)}function gt(e,t,n,r){return!((t??`BUSINESS`)!==`BUSINESS`||r===`__mg_summary__`||!n||ht(e))}function _t(e,t){return t==null||t===!1?!1:t===!0||t(e)}function vt(e){let{column:t,rowNode:n,isRowDisabled:r}=e;if(!gt(t.colId,n.rowKind,t.prop,n.id))return!1;if(_t({data:n.data,rowId:n.id,rowIndex:n.rowIndex},r)||t.disabled===!0)return!0;let{cellDisabled:i}=t;return i===!0||typeof i==`function`&&i({data:n.data,rowId:n.id,colId:t.colId})}function yt(e={}){return mt(e)}function bt(e,t,n){return vt({column:e,rowNode:t,isRowDisabled:n?.isRowDisabled})}function xt(e,t){return{...e,isRowDisabled:t}}var St=`data-custom-bg`,Ct=`mg-cell--editable`,wt=`mg-cell--editable-hint`,Tt=`mg-cell__editable-indicator`;function Et(e){return e.backgroundColor===void 0&&e.color===void 0}function Dt(e,t,n){console.warn(`[magic-grid] setCellStyle: ignored (${n}).`,{rowId:e,colId:t})}function Ot(e){return t.it(e)||A(e)||z(e)||L(e)}function kt(e,n,r,i){return(n??`BUSINESS`)!==`BUSINESS`||i===`__mg_summary__`?!1:t.X(e)?!0:!(!r||Ot(e))}function At(e,t){return kt(e.colId,t.rowKind,e.prop,t.id)}function jt(e){return typeof e==`function`}function Mt(e){let{cellStyle:t}=e;return t==null||jt(t)?null:t}function Nt(e){return e.backgroundColor!==void 0&&e.backgroundColor!==``}function Pt(e,t){let n=e.cellEditorParams;if(n!=null)return typeof n==`function`?n(t):n}function Ft(e,t){let n=e.cellEditorParams;if(n!=null)return typeof n==`function`?t?Pt(e,t):void 0:n}function It(e,t){return Ft(e,t)}function Lt(e){if(!e)return;let{checkedValue:t,uncheckedValue:n}=e;if(t!==void 0||n!==void 0)return{checkedValue:t,uncheckedValue:n}}function Rt(e){if(!e)return;let{onValue:t,offValue:n}=e;if(t!==void 0||n!==void 0)return{onValue:t,offValue:n}}function zt(e,t){return Lt(It(e,t))}function Bt(e,t){return Rt(It(e,t))}function Vt(e){return{rowId:e.rowId,rowIndex:e.rowIndex,colId:e.colId,value:e.value,data:e.data,formattedValue:e.formattedValue,size:e.size,context:e.context,inline:e.inline,autoFocus:e.autoFocus}}function Ht(e,t){let n=It(e,Vt(t)),r=n==null?t.cellEditorParams:{...t.cellEditorParams,...n};return{...t,cellEditorParams:r}}var Ut=Symbol(`TOGGLE_EDITOR_RAW_VALUE_REJECTED`);function Wt(e){return e?{onValue:e.checkedValue,offValue:e.uncheckedValue}:null}function Gt(e){return{onValue:e?.onValue??!0,offValue:e?.offValue??!1}}function Kt(e){return e?.onValue!==void 0||e?.offValue!==void 0}function qt(e,t){return Object.is(e,t)}function Jt(e,t){let{onValue:n,offValue:r}=Gt(t);return qt(e,n)?!0:qt(e,r)||Kt(t)||e==null||e===``||e===!1||e===`false`||e===0||e===`0`?!1:e===!0||e===`true`||e===1||e===`1`||!!e}function Yt(e){return JSON.stringify(e)}function Xt(e,t){let{onValue:n,offValue:r}=Gt(t);return Yt(e?n:r)}function Zt(e,t){return Xt(e.checked,t)}function Qt(e,t){let{onValue:n,offValue:r}=Gt(t),i=Yt(n),a=Yt(r);if(e===i)return n;if(e===a)return r;if(!Kt(t)){if(e===`true`)return!0;if(e===`false`)return!1}return Ut}var $t=Ut;function en(e){let t=Gt(Wt(e));return{checkedValue:t.onValue,uncheckedValue:t.offValue}}function tn(e,t){return Jt(e,Wt(t))}function nn(e,t){return Xt(e,Wt(t))}function rn(e,t){return Zt(e,Wt(t))}function an(e,t){return Qt(e,Wt(t))}function on(e){return e.cellEditor===`checkbox`?Wt(zt(e)):e.cellEditor===`switch`?Bt(e)??null:null}var sn=Symbol(`CELL_EDIT_REJECTED`);function cn(e){return e===sn}function ln(e){return t.it(e.colId)||t.X(e.colId)||j({colId:e.colId,rowExpand:!1})}function un(e,t){let{editable:n}=e;return n===void 0||n===!1?!1:n===!0||n(t)}function V(e,t,n){return!R(t)||ln(e)||!e.prop||bt(e,t,n)?!1:un(e,t.data)}function dn(e,t=`singleClick`){return e.editType??t}function fn(e){return{editBehavior:e.editBehavior??`cell`,editType:e.editType??`singleClick`}}function pn(e){return e===`row`}function mn(e){let t=e.trim();if(t===``)return sn;let n=Number(t);return Number.isFinite(n)?n:sn}function hn(e,t){let n=an(e,t);return n===$t?sn:n}function gn(e,t){let n=Qt(e,t);return n===Ut?sn:n}function _n(e,t,n){try{return t.valueParser?t.valueParser(e,n):t.cellEditor===`number`?mn(e):t.cellEditor===`checkbox`?hn(e,Lt(n.cellEditorParams)??zt(t)):t.cellEditor===`switch`?gn(e,Rt(n.cellEditorParams)??Bt(t)):e}catch{return sn}}function vn(e,t,n){if(e.valueSetter){let r=e.valueSetter({...t,newValue:n,signal:new AbortController().signal});if(r instanceof Promise)throw Error(`Async valueSetter requires applyCellEditValue / commitRowEditCells`);return r}let r=e.prop;return r?(t.data[r]=n,!0):!1}async function yn(t,n,r,i){let a=i??new AbortController().signal;if(e.l(a),t.valueSetter)try{let i=await t.valueSetter({...n,newValue:r,signal:a});return e.l(a),i}catch(t){if(e.c(t))throw t;return!1}let o=t.prop;return o?(n.data[o]=r,!0):!1}var bn=Symbol.for(`magic-grid.vueCellEditor`);function xn(e){return Object.defineProperty(e,bn,{value:!0,configurable:!0}),e}function Sn(e){return e?Reflect.get(e,bn)===!0:!1}var Cn=[`text`,`number`,`checkbox`,`switch`];function wn(e){return Cn.includes(e)}function Tn(e){let t={};for(let n of[e.row,e.column,e.cell,e.override,e.editable,e.disabled])n&&(n.backgroundColor!==void 0&&(t.backgroundColor=n.backgroundColor),n.color!==void 0&&(t.color=n.color));return t}function En(e,t){return{data:t.data,rowId:t.id,colId:e.colId,rowIndex:t.rowIndex,column:{colId:e.colId,prop:e.prop}}}function Dn(e,t){let n=t?.rowStyle;return n==null?null:typeof n==`function`?n({data:e.data,rowId:e.id,rowIndex:e.rowIndex,rowKind:e.rowKind})??null:n}function On(e,t){let{cellStyle:n}=e;return n==null||!jt(n)?null:n(En(e,t))??null}function kn(e,t,n){return At(e,t)?V(e,t,n?.getCellDisableContext?.()):!1}function An(e,t,n){return At(e,t)?bt(e,t,n?.getCellDisableContext?.()):!1}function jn(e,t){return e==null||Et(e)||!t?null:e}function Mn(e,t,n){return e??t?n:!1}function Nn(e,n,r,i){return!t.V(e)&&Mn(n,r,i)}function Pn(e,t,n){return jn(n?.editableCellStyle,kn(e,t,n))}function Fn(e,t,n){return Nn(e,n?.showEditableCellIcon,!1,kn(e,t,n))}function In(e,t,n){return jn(n?.disabledCellStyle,An(e,t,n))}function Ln(e,t,n){return Nn(e,n?.showDisabledCellIcon,!1,An(e,t,n))}function Rn(e,t,n){if(!At(e,t))return{};let r=n?.getCellStyleOverride?.(t.id,e.colId);return Tn({row:Dn(t,n),column:Mt(e),cell:On(e,t),override:r??null,editable:Pn(e,t,n),disabled:In(e,t,n)})}function zn(){return{key:b,label:``,width:40,minWidth:40,fixed:`left`,sortable:!1,filterable:!1,editable:!1,resizable:!1,headerAlign:`center`,align:`center`,valign:`center`}}function Bn(e={}){return{key:se,label:`分组`,width:200,minWidth:120,fixed:`left`,sortable:!1,filterable:!1,editable:!1,resizable:!0,headerAlign:`left`,align:`left`,valign:`center`,...e}}function Vn(e={}){return{key:Ke,label:`树`,width:200,minWidth:120,fixed:`left`,sortable:!1,filterable:!1,editable:!1,resizable:!0,headerAlign:`left`,align:`left`,valign:`center`,...e}}function Hn(e){return{key:t.tt,label:e.label,width:e.width,minWidth:40,fixed:`left`,sortable:!1,filterable:!1,editable:!1,resizable:!1,headerAlign:e.headerAlign,headerValign:e.headerValign,align:e.align,valign:e.valign,footerAlign:e.footerAlign,footerValign:e.footerValign}}function Un(e){return{key:t.J,label:``,width:e.width,minWidth:40,fixed:`left`,sortable:!1,filterable:!1,editable:!1,resizable:!1,headerAlign:e.headerAlign,headerValign:e.headerValign,align:e.align,valign:e.valign,footerAlign:e.footerAlign,footerValign:e.footerValign}}function Wn(e,n,r=t.Z(),i={}){let a=[];n.showIndexColumn&&a.push(Hn(n.indexColumn)),r.enabled&&a.push(Un(r.selectionColumn));let o=i.rowExpansion;o?.masterDetail&&o.showExpandColumn&&a.push(zn());let s=i.treeTable;if(s&&rt(s.tree,s.showTreeColumn,s.getDataPath))a.push(Vn(s.autoTreeColumnDef??{}));else{let e=i.rowGrouping;e&&je(e.rowGrouping,e.showGroupColumn)&&a.push(Bn(e.autoGroupColumnDef??{}))}return[...a,...e]}function H(e,t){let n=t.prop??t.colId,r=n?e.data[n]:void 0;return t.valueGetter&&(r=t.valueGetter(e.data,r)),r}var Gn=`default`,Kn={mini:{spacing:4,fontSize:12,borderRadius:4,rowHeight:20,headerHeight:20,statusBarHeight:20,checkboxSize:12},small:{spacing:8,fontSize:12,borderRadius:8,rowHeight:24,headerHeight:24,statusBarHeight:24,checkboxSize:12},default:{spacing:8,fontSize:12,borderRadius:8,rowHeight:32,headerHeight:32,statusBarHeight:32,checkboxSize:14},large:{spacing:12,fontSize:14,borderRadius:8,rowHeight:40,headerHeight:40,statusBarHeight:40,checkboxSize:14}};function qn(e){let{rounded:t=!1,sizeBorderRadius:n}=e;return t===!0?n:typeof t==`number`?Math.max(0,t):0}function Jn(e={}){let t=e.size??`default`,n=Kn[t],r=e.rowHeight!=null,i=e.headerHeight!=null;return{size:t,spacing:n.spacing,fontSize:n.fontSize,borderRadius:n.borderRadius,rowHeight:r?e.rowHeight:n.rowHeight,headerHeight:i?e.headerHeight:n.headerHeight,statusBarHeight:n.statusBarHeight,checkboxSize:n.checkboxSize,rowHeightOverridden:r,headerHeightOverridden:i}}function Yn(e,t){return e==null||e===`auto`||!Number.isFinite(e)?t:Math.max(12,Math.trunc(e))}function Xn(e){return Math.max(12,e-6)}function Zn(e){return e+16}function Qn(e){return Math.max(12,e-16)}function $n(e=Gn){return Zn(Kn[e].statusBarHeight)}function er(e){return Math.max(12,e-8)}function tr(e){return Kn[e].statusBarHeight}var nr={mini:12,small:14,default:16,large:18};function rr(e){return nr[e]}function ir(e=Gn){return{"--mg-column-settings-button-size":`${tr(e)}px`,"--mg-column-settings-button-icon-size":`${rr(e)}px`}}function ar(e,t,n){let r=n??e.rowHeight,i=Xn(e.statusBarHeight),a=Zn(e.statusBarHeight),o=Qn(a),s=tr(e.size);return{"--mg-row-height":`${e.rowHeight}px`,"--mg-header-height":`${e.headerHeight}px`,"--mg-summary-row-height":`${r}px`,"--mg-status-bar-height":`${e.statusBarHeight}px`,"--mg-status-bar-control-height":`${i}px`,"--mg-load-more-row-height":`${a}px`,"--mg-load-more-control-height":`${o}px`,"--mg-column-settings-button-size":`${s}px`,"--mg-column-settings-button-icon-size":`${rr(e.size)}px`,"--mg-status-bar-font-size":`${e.fontSize}px`,"--mg-font-size":`${e.fontSize}px`,"--mg-spacing":`${e.spacing}px`,"--mg-cell-padding-x":`${e.spacing}px`,"--mg-border-radius":`${t}px`,"--mg-checkbox-size":`${e.checkboxSize}px`,"--mg-cell-control-size":`${er(e.rowHeight)}px`}}var or=Kn.default.rowHeight,sr=Kn.default.headerHeight;function cr(e,t){let n=e.__autoHeights;if(!n)return null;let r=Object.values(n);return r.length===0?null:Math.max(t,...r)}function lr(e,t,n){if(e.rowHeightPinned&&e.rowHeight>0)return{height:e.rowHeight,estimated:!1};if(n){let t=n(e);if(t!=null&&t>0)return{height:t,estimated:!1}}let r=cr(e,t);return r==null?e.rowHeight>0?{height:e.rowHeight,estimated:e.estimated??!1}:{height:t,estimated:!1}:{height:r,estimated:e.estimated??!1}}function ur(e,t){let n=0;for(let r=0;r<e.length;r++){let i=e[r];i.rowIndex=r,i.rowTop=n,i.rowHeight=t,i.estimated=!1,n+=t}}function dr(e,t){let n=0;for(let r=0;r<e.length;r++){let i=e[r],{height:a,estimated:o}=lr(i,t.defaultRowHeight,t.getRowHeight);i.rowIndex=r,i.rowTop=n,i.rowHeight=a,i.estimated=o,n+=a}}function fr(e,t){if(typeof t==`number`){ur(e,t);return}dr(e,t)}function pr(e){if(e.length===0)return 0;let t=e[e.length-1];return t.rowTop+t.rowHeight}var mr=[`group`,`filter`,`sort`,`aggregate`,`map`],hr=[`tree`,`filter`,`sort`,`map`],gr=[`sort`,`filter`,`map`];function _r(e){switch(e){case`tree`:return hr;case`group`:return mr;default:return gr}}function vr(e){return`predicate`in e}function yr(e){for(let t=0;t<e.length;t+=1)e[t].sourceIndex=t}function br(e,t){let n=e.data[t];if(typeof n==`number`&&Number.isFinite(n))return n;if(typeof n==`string`&&n!==``){let e=Number(n);if(Number.isFinite(e))return e}return 1/0}function xr(e,t){return[...e].sort((e,n)=>br(e,t)-br(n,t))}function Sr(e,t){let n=0;for(let r of e)R(r)&&(r.data[t]=n,n+=1)}function Cr(e,t){return e===t?0:e===`(Blanks)`?1:t===`(Blanks)`?-1:e.localeCompare(t)}function wr(e){return e?(t,n,r)=>e({valueA:t,valueB:n,colId:r.colId,field:r.field,level:r.level}):(e,t)=>Cr(e,t)}function Tr(e){let{sourceRows:t,rowGroupColumns:n}=e;return n.length===0||t.length===0?[...t]:Er({rows:t,level:0,parentGroupId:void 0,parentPathIds:[],rowGroupColumns:n,getCellValue:e.getCellValue,groupKeyCreator:e.groupKeyCreator,groupComparator:e.groupComparator,groupSortKey:e.groupSortKey,getColumnField:e.getColumnField})}function Er(e){let{rows:t,level:n,parentGroupId:r,parentPathIds:i,rowGroupColumns:a,getCellValue:o,groupKeyCreator:s,groupComparator:c,groupSortKey:l,getColumnField:u}=e;if(t.length===0)return[];if(n>=a.length)return kr(t,Fe(i)),l?xr(t,l):[...t];let d=a[n],f=u?.(d)??d,p=Dr(t,d,f,o,s),m=wr(c),h={colId:d,field:f,level:n};return[...p.keys()].sort((e,t)=>m(e,t,h)).map(e=>{let t=p.get(e),m=Pe(n,f,e,r),h=[...i,m],g=Er({rows:t,level:n+1,parentGroupId:m,parentPathIds:h,rowGroupColumns:a,getCellValue:o,groupKeyCreator:s,groupComparator:c,groupSortKey:l,getColumnField:u});return Ar({colId:d,field:f,key:e,level:n,groupId:m,groupPathKey:Fe(h),children:g})})}function Dr(e,t,n,r,i){let a=new Map;for(let o of e){let e=Or(o,t,n,r,i),s=a.get(e);if(s){s.push(o);continue}a.set(e,[o])}return a}function Or(e,t,n,r,i){let a=r(e,t);return Ne(i?i({field:n,colId:t,value:a,data:e.data}):a)}function kr(e,t){for(let n of e)n.leafGroupPathKey=t}function Ar(e){let t=jr(e.children);return{id:e.groupId,data:{},rowTop:0,rowHeight:0,estimated:!1,rowIndex:-1,sourceIndex:-1,group:!0,groupField:e.colId,groupKey:e.key,groupLevel:e.level,groupId:e.groupId,groupPathKey:e.groupPathKey,groupLeafCount:t,childrenAfterGroup:e.children}}function jr(e){let t=0;for(let n of e){if(n.group){let e=n.childrenAfterSort??n.childrenAfterFilter??n.childrenAfterGroup??[];t+=jr(e);continue}t+=1}return t}function Mr(e){let t=[];for(let n of e){if(n.group){t.push(...Mr(n.childrenAfterGroup??[]));continue}t.push(n)}return t}function Nr(e){return e.some(e=>e.group===!0)}function Pr(e){return e.childrenAfterGroup??[]}function Fr(e){return e.childrenAfterFilter??e.childrenAfterGroup??[]}function Ir(e){return e.childrenAfterSort??Fr(e)}function Lr(e){return Ir(e)}function Rr(e){let t=[];for(let n of e){if(n.group){t.push(...Rr(Ir(n)));continue}t.push(n)}return t}function zr(e){for(let t of e){if(!t.group)continue;let e=zr(Pr(t));t.childrenAfterFilter=e,t.groupLeafCount=jr(e)}return[...e]}function Br(e){for(let t of e){if(!t.group)continue;let e=t.childrenAfterSort??Fr(t);Br(e),t.groupLeafCount=jr(e)}}function Vr(e){return Hr(e??``)!==``}function Hr(e){return e.trim()}function Ur(e){let t=Hr(e.quickFilterText).toLowerCase();if(t===``)return!0;for(let n of e.filterableColIds){let r=e.getFilterValue(e.row,n,e.getCellValue);if(String(r??``).toLowerCase().includes(t))return!0}return!1}function Wr(e){return e.some(e=>e.dataPath!=null&&e.dataPath.length>0&&e.group!==!0)}function Gr(e){return e.childrenAfterFilter??e.childrenAfterTree??[]}function Kr(e){return e.childrenAfterSort??Gr(e)}function qr(e){let t=[];function n(e){for(let r of e){let e=Kr(r);e.length!==0&&(t.push(r.id),n(e))}}return n(e),t}function Jr(e){for(let t of e){let e=t.childrenAfterTree??[];t.childrenAfterFilter=e.length>0?Jr(e):[]}return[...e]}function Yr(e){return e!=null&&e.trim()!==``}function Xr(e){return ai(e.type)?!0:e.type===`inRange`?Yr(e.filter)&&Yr(e.filterTo):Yr(e.filter)}function Zr(e){return e?e.conditions&&e.conditions.length>0?e.conditions:[{type:e.type,filter:e.filter,filterTo:e.filterTo}]:[]}function Qr(e){return e.operator??`AND`}function $r(e){return e?.setValues}function ei(e){return Zr(e).some(Xr)}function ti(e){return e.setValues!==void 0}function ni(e){return e??`text`}function ri(e){return{caseSensitive:e?.caseSensitive??!0,locale:e?.locale}}function ii(e){return e!=null&&e.trim()!==``}function ai(e){return e===`blank`||e===`notBlank`}function oi(e){return e?vr(e)?!0:ei(e)||ti(e):!1}function si(e,t){return oi(t[e])}function ci(e,t){if(ii(t))return!0;for(let t of Object.values(e))if(oi(t))return!0;return!1}var li=`__mg_blank__`,ui=/^\d{4}-\d{2}-\d{2}$/;function di(e){return!!(e==null||typeof e==`number`&&Number.isNaN(e)||typeof e==`string`&&e.trim()===``)}function fi(e){return e.toISOString().slice(0,10)}function pi(e){if(di(e))return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:fi(e);if(typeof e==`number`){let t=new Date(e);return Number.isNaN(t.getTime())?null:fi(t)}let t=String(e).trim();if(t===``)return null;if(ui.test(t))return t;let n=Date.parse(t);return Number.isNaN(n)?null:fi(new Date(n))}function mi(e){if(di(e))return null;let t=Number(e);return Number.isNaN(t)?null:t}function hi(e,t){if(di(e))return li;switch(t){case`number`:{let t=mi(e);return t===null?li:String(t)}case`date`:return pi(e)??`__mg_blank__`;default:return String(e)}}function gi(e,t){return e===`__mg_blank__`?`(空白)`:e}function _i(e,t){return e===`__mg_blank__`?-1:t===`__mg_blank__`?1:e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`})}function vi(e){let t=new Map;for(let n of e.rows){let r=hi(e.getFilterValue(n),e.filterType);t.set(r,(t.get(r)??0)+1)}return[...t.keys()].sort(_i).map(t=>({key:t,label:gi(t,e.filterType),blank:t===li}))}var yi=/^\d{4}-\d{2}-\d{2}$/;function bi(e){return!!(e==null||typeof e==`number`&&Number.isNaN(e)||typeof e==`string`&&e.trim()===``)}function xi(e,t){let n=String(e??``);return t?n:n.toLowerCase()}function Si(e,t){return t?e:e.toLowerCase()}function Ci(e){return e.toISOString().slice(0,10)}function wi(e){if(bi(e))return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:Ci(e);if(typeof e==`number`){let t=new Date(e);return Number.isNaN(t.getTime())?null:Ci(t)}let t=String(e).trim();if(t===``)return null;if(yi.test(t))return t;let n=Date.parse(t);return Number.isNaN(n)?null:Ci(new Date(n))}function Ti(e){if(bi(e))return null;let t=Number(e);return Number.isNaN(t)?null:t}function Ei(e,t,n){let r=n(e);return t===`blank`?r:!r}function Di(e,t,n){if(ai(t.type))return Ei(e,t.type,bi);let r=t.filter??``,i=xi(e,n.caseSensitive),a=Si(r,n.caseSensitive);switch(t.type){case`contains`:return i.includes(a);case`notContains`:return!i.includes(a);case`equals`:return i===a;case`notEqual`:return i!==a;case`startsWith`:return i.startsWith(a);case`endsWith`:return i.endsWith(a);default:return!1}}function Oi(e,t){if(ai(t.type))return Ei(e,t.type,e=>Ti(e)===null);let n=Ti(e),r=Ti(t.filter);if(n===null||r===null)return!1;switch(t.type){case`equals`:return n===r;case`notEqual`:return n!==r;case`lessThan`:return n<r;case`lessThanOrEqual`:return n<=r;case`greaterThan`:return n>r;case`greaterThanOrEqual`:return n>=r;default:return Di(e,t,{caseSensitive:!0})}}function ki(e,t){if(ai(t.type))return Ei(e,t.type,bi);let n=wi(e),r=t.filter?.trim()??``;if(r===``)return!1;switch(t.type){case`equals`:return n!==null&&n===r;case`notEqual`:return n===null||n!==r;case`lessThan`:return n!==null&&n<r;case`greaterThan`:return n!==null&&n>r;case`inRange`:{let e=t.filterTo?.trim()??``;return e===``||n===null?!1:n>=r&&n<=e}default:return!1}}function Ai(e,t,n){if(t.length===0)return!1;let r=hi(e,n);return t.includes(r)}function ji(e,t,n,r){switch(n){case`number`:return Oi(e,t);case`date`:return ki(e,t);default:return Di(e,t,r)}}function Mi(e,t,n,r){let i=Qr(t),a=Zr(t).filter(Xr);if(a.length===0)return!0;let o=a.map(t=>ji(e,t,n,r));return i===`OR`?o.some(Boolean):o.every(Boolean)}function Ni(e,t,n,r){let i=ei(t),a=ti(t);return!(i&&!Mi(e,t,n,r)||a&&!Ai(e,$r(t)??[],n))}var Pi=`mg-column-handle-menu`,Fi=`mg-column-handle-menu-portal`,Ii=`mg-column-handle-menu__section`,Li=`mg-column-handle-menu__item`,Ri=`mg-column-handle-menu__item-content`,zi=`mg-column-handle-menu__item-label`,Bi=`mg-column-handle-menu__item--submenu-trigger`,Vi=`mg-column-handle-menu__submenu`,Hi=`mg-column-handle-menu__submenu-panel`,Ui=`mg-column-handle-menu__divider`,Wi=`mg-column-handle-menu__filter-panel`,Gi=`mg-column-handle-menu__section--sort`,Ki=`mg-column-handle-menu__section--pin`,qi=`mg-column-handle-menu__section--filter`,Ji=`mg-column-handle-menu__section--visibility`;function Yi(e){return!t.it(e)&&!t.X(e)}function Xi(e,t=`full`){return Yi(e.colId)?t===`filter-only`?{sort:!1,pin:!1,filter:e.filterable,visibility:!1}:{sort:e.sortable,pin:!0,filter:e.filterable,visibility:!0}:{sort:!1,pin:!1,filter:!1,visibility:!1}}function Zi(e){return e.sort||e.pin||e.filter||e.visibility}function Qi(e){return e.length===0?[]:[e[0]]}function $i(e={}){return Qi(e.defaultSort??[])}function ea(e={}){return{defaultSort:$i(e),sortable:e.sortable??!1,enableHeaderSortClick:e.enableHeaderSortClick??!0,showUnsortedSortHintOnHover:e.showUnsortedSortHintOnHover??!1}}function ta(e,n,r){return t.it(r)||t.X(r)?!1:e??n}var na=`mg-column-dragging`,ra=`mg-column-dragging--drop-forbidden`,ia=5,aa=50;function oa(e={}){return{columnMovable:e.columnMovable??!0,suppressMoveWhenColumnDragging:e.suppressMoveWhenColumnDragging??!1,suppressColumnMoveAnimation:e.suppressColumnMoveAnimation??!1,allowCrossLaneColumnMove:e.allowCrossLaneColumnMove??!1}}function sa(e,t){return e!==!1&&t}var ca=`current`,la=`tree`;function ua(e={}){return{filterable:e.filterable??!1,filterSetValueMode:e.filterSetValueMode??`current`,filterSetDateLayoutMode:e.filterSetDateLayoutMode??`tree`}}function da(e,n,r){return t.it(r)||t.X(r)||A(r)||L(r)?!1:e??n}var fa=Symbol.for(`magic-grid.vueCellRenderer`);function pa(e){return Object.defineProperty(e,fa,{value:!0,configurable:!0}),e}function ma(e){return e?Reflect.get(e,fa)===!0:!1}function ha(e,t,n){return!t||e===`never`?!1:e===`always`||n===`vue`||n!==`sync`&&ma(t)}function ga(e,t,n,r){return e!==`immediate`&&ha(t,n,r)}var _a=[`immediate`,`deferred`,`placeholder-then-vue`];function va(e){return e&&_a.includes(e)?e:`deferred`}function ya(e={}){return{scrollEndFlushMs:Math.max(0,e.scrollEndFlushMs??0),frameBudgetMs:Math.max(1,e.frameBudgetMs??60),scrollEndFrameBudgetMs:e.scrollEndFrameBudgetMs??-1,cellRendererDefer:e.cellRendererDefer??`always`,deferRowDestroyOnScroll:e.deferRowDestroyOnScroll??!1,rendererFrameBudgetMs:Math.max(0,e.rendererFrameBudgetMs??20),cellRendererPresentation:va(e.cellRendererPresentation)}}var ba=`mg-cell__row-drag-handle`,xa=`mg-cell--row-dragging`,Sa=`mg-row-drop-indicator`,Ca=`mg-row-drag-ghost`,wa=`mg-row-dragging--drop-forbidden`,Ta=`magic-grid--row-drag-committing`;function Ea(e={}){return{rowDragManaged:e.rowDragManaged??!0}}function Da(e,n){return t.it(n)||t.X(n)?!1:e??!1}function Oa(e,t){return Da(e.rowDrag,t)}var ka=`row move is not allowed while sort or filter is active`;function Aa(e,t){return t&&e}function ja(e,t,n){return e?!Aa(t,n):!1}function Ma(e,t,n,r,i=!0,a){let o={rowId:e,fromIndex:t,toIndex:n,source:r,finished:i};return a?.displayIndex!==void 0&&(o.displayIndex=a.displayIndex),a?.parentRowId!==void 0&&(o.parentRowId=a.parentRowId),a?.siblingIndex!==void 0&&(o.siblingIndex=a.siblingIndex),a?.treeLevel!==void 0&&(o.treeLevel=a.treeLevel),o}function Na(e,t,n,r,i){return{rowId:e,rowIds:r&&r.length>1?[...r]:void 0,displayIndex:t,finished:n,...i?{parentRowId:i.parentRowId,siblingIndex:i.siblingIndex,treeLevel:i.treeLevel}:{}}}function Pa(e){return{rowId:e.leaderRowId,rowIds:[...e.rowIds],leaderRowId:e.leaderRowId,displayIndex:e.displayIndex,parentRowId:e.treeDrop?.parentRowId,siblingIndex:e.treeDrop?.siblingIndex,treeLevel:e.treeDrop?.treeLevel}}function Fa(e){return{commitId:e.commitId,rowId:e.leaderRowId,leaderRowId:e.leaderRowId,committed:e.committed,aborted:e.aborted,reason:e.reason}}function Ia(e,t,n){let r=e.hierarchyChanges?[...e.hierarchyChanges]:[],i=r.find(t=>t.rowId===e.leaderRowId),a=e.treeDrop?.parentRowId,o=a===void 0?i?.parentRowId:a===null?null:String(a);return{signal:n.signal,commitId:n.commitId,rowIds:[...e.rowIds],leaderRowId:e.leaderRowId,moves:[...e.moves],hierarchyChanges:r,displayIndex:e.displayIndex,parentRowId:o,siblingIndex:e.treeDrop?.siblingIndex??i?.siblingIndex,treeLevel:e.treeDrop?.treeLevel??i?.treeLevel,nestUnderRowId:t??void 0}}var La=`mg-cell__row-resize-handle`,Ra=`mg-cell--row-resizing`,za=`mg-cell--auto-height`;function Ba(e={},t){let n=e.rowHeightMin??t,r=e.rowHeightMax??null;return{getRowHeight:e.getRowHeight,rowHeightMin:Math.max(1,n),rowHeightMax:r==null?null:Math.max(n,r)}}function Va(e,n){return t.it(n)||t.X(n)?!1:e??!1}function Ha(e,t){return Va(e.autoHeight,t)}function Ua(e,t,n){let r=Math.max(t,e);return n==null?r:Math.min(n,r)}function Wa(e,t,n){return{rows:e.map(e=>({...e})),finished:t,source:n}}var Ga=`mg-cell--row-span`,Ka=`mg-cell--row-span-ends-table`,qa=`mg-row--span-top`,Ja=`mg-row--pinned-span-covered`;function Ya(e={}){return{enableCellSpan:e.enableCellSpan??!1}}function Xa(e){return e}function Za(e){return e.fixed===`left`||e.fixed===`right`}function Qa(e){return R(e)}function $a(e){return!Number.isFinite(e)||e<1?1:Math.floor(e)}function eo(e,n){if(!(t.it(n)||t.X(n)))return e}function to(e,n){if(!(t.it(n)||t.X(n)))return e}function no(e,n){if(!(t.it(n)||t.X(n)))return e}function ro(e,t){return eo(e.colSpan,t)}function io(e,t){return to(e.rowSpan,t)}function ao(e,t){return no(e.spanRows,t)}function oo(e,t){return e?`rowSpan`:t===!0||typeof t==`function`?`spanRows`:`none`}function so(e){return e===!0||typeof e==`function`}var co=`__MG_LOAD_MORE__`,lo=$n(Gn),uo=`mg-full-width-row--load-more`,fo=`mg-full-width-row__load-more-anchor`;function po(e={}){return{loadMore:e.loadMore?.trim()||`加载更多`,loading:e.loading?.trim()||`加载中...`,exhausted:e.exhausted?.trim()||`没有更多`}}function mo(e={},t=Gn){let n=e.loadMoreRowHeight??$n(t);return{enabled:e.loadMoreRowEnabled===!0,height:Number.isFinite(n)&&n>0?Math.floor(n):lo,loading:e.loadMoreRowLoading===!0,hasMore:e.loadMoreRowHasMore!==!1,labels:po(e.loadMoreRowLabels),loadMoreRowRenderer:e.loadMoreRowRenderer}}function ho(e){return e===co}function go(e){return e.rowKind===`LOAD_MORE`||ho(e.id)}var _o=[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`}]],vo=[[`path`,{d:`M20 6 9 17l-5-5`}]],yo=[[`path`,{d:`m7 6 5 5 5-5`}],[`path`,{d:`m7 13 5 5 5-5`}]];function bo(e,t){let n=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);n.setAttribute(`class`,e),n.setAttribute(`viewBox`,`0 0 24 24`),n.setAttribute(`fill`,`none`),n.setAttribute(`stroke`,`currentColor`),n.setAttribute(`stroke-width`,`2`),n.setAttribute(`stroke-linecap`,`round`),n.setAttribute(`stroke-linejoin`,`round`),n.setAttribute(`aria-hidden`,`true`);for(let[e,r]of t){let t=document.createElementNS(`http://www.w3.org/2000/svg`,e);for(let[e,n]of Object.entries(r))t.setAttribute(e,String(n));n.appendChild(t)}return n}function xo(){return bo(`mg-load-more-row__icon-svg mg-load-more-row__icon-svg--loader-circle`,_o)}function So(){return bo(`mg-load-more-row__icon-svg mg-load-more-row__icon-svg--check`,vo)}function Co(){return bo(`mg-load-more-row__icon-svg mg-load-more-row__icon-svg--chevrons-down`,yo)}function wo(e,t,n=!1){let r=document.createElement(`span`);r.className=n?`mg-load-more-row__icon mg-load-more-row__icon--spin`:`mg-load-more-row__icon`,r.setAttribute(`aria-hidden`,`true`),r.append(t),e.append(r)}function To(e){let t=document.createElement(`button`);t.type=`button`,t.className=`mg-load-more-row__button`;let n=document.createElement(`span`);return n.className=`mg-load-more-row__label`,e.loading?(t.disabled=!0,wo(t,xo(),!0),n.textContent=e.labels.loading):e.hasMore?(t.disabled=!1,wo(t,Co()),n.textContent=e.labels.loadMore):(t.disabled=!1,wo(t,So()),n.textContent=e.labels.exhausted),t.append(n),t.addEventListener(`click`,()=>{e.loading||e.onLoadMore()}),t}function Eo(){return(e,t)=>{t.clear(),t.mountEl.append(To(e))}}function Do(e,t,n,r={}){let i=()=>{r.onUnmountRenderer?.(e),e.replaceChildren();let i={mountEl:e,clear:()=>{r.onUnmountRenderer?.(e),e.replaceChildren()}},a=(n??Eo())(t,i);if(typeof a==`string`){i.clear(),e.textContent=a;return}a instanceof HTMLElement&&(i.clear(),e.appendChild(a))},a=r.rowIndex??0;if(r.frameService){r.frameService.createTask(i,a,`p2`);return}i()}var Oo=`mg-cell--has-comment`,ko=`mg-cell--comment-empty`,Ao=`mg-cell-comment-popup`,jo=`mg-cell-comment-popup--readonly`,Mo=`mg-cell-comment-popup--committing`,No=`mg-cell-comment-context-menu`,Po=`mg-cell-comment-context-menu--committing`;function Fo(e={}){return{cellCommentsDataSource:e.cellCommentsDataSource,suppressCellComments:e.suppressCellComments??!1,cellCommentTrigger:e.cellCommentTrigger??`click`,cellCommentShowDelay:e.cellCommentShowDelay??180,cellCommentHideDelay:e.cellCommentHideDelay??220}}function Io(e){return e!=null&&typeof e.getComment==`function`&&typeof e.setComment==`function`}function Lo(e){return t.it(e)||t.X(e)||A(e)||z(e)||L(e)}function Ro(e,t,n){return!(t!==`BUSINESS`||n!=null&&String(n)===`__mg_summary__`||Lo(e))}function zo(e,t){return e==null?!1:typeof e==`function`?e(t):e}function Bo(e){let t={canView:!1,canCreate:!1,canEdit:!1,canDelete:!1};if(!Ro(e.colId,e.rowKind,e.rowId))return t;let n=zo(e.columnSuppress,{data:e.data,rowId:e.rowId,colId:e.colId});return e.gridSuppress===!0||n?{canView:e.hasExistingComment,canCreate:!1,canEdit:!1,canDelete:!1}:{canView:!0,canCreate:!e.hasExistingComment,canEdit:e.hasExistingComment,canDelete:e.hasExistingComment}}function Vo(e,t){return t?.readOnly?{canView:e.canView,canCreate:!1,canEdit:!1,canDelete:!1}:e}function Ho(e){return typeof e?.text==`string`&&e.text.length>0}function Uo(e,t,n,r){return{rowId:e,colId:t,comment:n,source:r}}function Wo(e,t){return`${e}::${t}`}function Go(e,t){e&&(t||console.warn(`[magic-grid] cellCommentsDataSource requires rowKey for stable (rowId, colId) keys; cell comment interactions are disabled.`))}var Ko=`copy`,qo=`mg-cell--range-selected`,Jo=`mg-cell--range-anchor`,Yo=`mg-cell-range-border`,Xo=`mg-cell-range-border--edge-top`,Zo=`mg-cell-range-border--edge-right`,Qo=`mg-cell-range-border--edge-bottom`,$o=`mg-cell-range-border--edge-left`,es=`mg-cell-range-border--fill-h`,ts=`mg-cell-range-border--fill-v`,ns=`mg-cell-range-overlay`,rs=`mg-cell--range-copy-flash`,is=`mg-cell-range-overlay--copy-flash`,as=`mg-cell--range-paste-flash`,os=`mg-cell--range-paste-blocked-flash`,ss=`mg-cell-range-paste-overlay`,cs=`mg-cell-range-paste-overlay--applied`,ls=`mg-cell-range-paste-overlay--blocked`,us=`mg-cell-range-paste-flash-layer`,ds=`mg-fill-handle`,fs=`mg-range-handle`,ps=`mg-header-cell--range-highlight`,ms=`mg-cell--index-range-highlight`;function hs(e){return t.it(e)||t.X(e)||A(e)||z(e)||L(e)}function gs(e){return hs(e)}function _s(e){let t=N(e);return t===`BUSINESS`||t===`GROUP_HEADER`||t===`GROUP_FOOTER`}function vs(e){return N(e)===`BUSINESS`}function ys(e,n){return t.it(e)||t.X(e)||A(e)?!1:_s(n)}function bs(e,t){return!gs(e)&&vs(t)}function xs(e={}){let t=e.handleMode??`off`;return t===`off`?null:t===`range`?{mode:`range`}:{mode:`fill`,direction:e.direction??`xy`,fillStrategy:e.fillStrategy??`copy`,fillReverseStrategy:e.fillReverseStrategy??`default`,setFillValue:e.setFillValue}}function Ss(e){return!e.enabled||!e.handle?null:e.handle.mode}function Cs(e){return Ss(e)===`fill`}function ws(e){return Ss(e)===`range`}function Ts(e={}){return{enableHeaderHighlight:e.enableHeaderHighlight??!0,enableIndexColumnHighlight:e.enableIndexColumnHighlight??!0}}function Es(e={}){let t=e.cellSelection;if(t===!1||t==null)return{enabled:!1,suppressMultiRanges:!0,enableColumnSelection:!1,enableCellCopy:!1,enableCellPaste:!1,handle:null};let n=t===!0?{}:t,r=e.enableCellCopy??!0,i=e.enableCellPaste??!1;return{enabled:!0,suppressMultiRanges:n.suppressMultiRanges??!0,enableColumnSelection:n.enableColumnSelection??!1,enableCellCopy:r,enableCellPaste:i,handle:xs(n)}}function Ds(e,t){return{startRowIndex:Math.min(e.rowIndex,t.rowIndex),endRowIndex:Math.max(e.rowIndex,t.rowIndex),startColId:e.colId,endColId:t.colId}}function Os(e){return e.serviceRanges.length>0?[...e.serviceRanges]:!e.enableHeaderHighlight&&!e.enableIndexColumnHighlight?[]:e.editingRanges&&e.editingRanges.length>0?[...e.editingRanges]:!e.focus||!e.focusEligible?[]:[Ds(e.focus,e.focus)]}function U(e,t){let n=Math.min(e.startRowIndex,e.endRowIndex),r=Math.max(e.startRowIndex,e.endRowIndex),i=t.indexOf(e.startColId),a=t.indexOf(e.endColId);if(i<0||a<0)return null;let o=Math.min(i,a),s=Math.max(i,a);return{top:n,bottom:r,leftColId:t[o],rightColId:t[s]}}function ks(e){return{startRowIndex:e.top,endRowIndex:e.bottom,startColId:e.leftColId,endColId:e.rightColId}}function As(e,t,n,r){if(e<n.top||e>n.bottom)return!1;let i=r.indexOf(t);if(i<0)return!1;let a=r.indexOf(n.leftColId),o=r.indexOf(n.rightColId);return a<0||o<0?!1:i>=a&&i<=o}function js(e,t){return e.startRowIndex===t.startRowIndex&&e.endRowIndex===t.endRowIndex&&e.startColId===t.startColId&&e.endColId===t.endColId}function Ms(e,t){let n=Math.min(e.startRowIndex,e.endRowIndex),r=Math.max(e.startRowIndex,e.endRowIndex);return[{rowIndex:n,colId:e.startColId},{rowIndex:n,colId:e.endColId},{rowIndex:r,colId:e.startColId},{rowIndex:r,colId:e.endColId}].every(e=>ys(e.colId,t(e.rowIndex)))}function Ns(e,t,n){if(hs(e)||t<=0)return null;let r=-1,i=-1;for(let a=0;a<t;a++)ys(e,n(a))&&(r<0&&(r=a),i=a);return r<0||i<0?null:{startRowIndex:r,endRowIndex:i,startColId:e,endColId:e}}function Ps(e,t,n){let r=null,i=null;for(let a of e)ys(a,t(n))&&(r??=a,i=a);return r==null||i==null?null:{startColId:r,endColId:i}}function Fs(e){if(e.length===0)return[];let t=[...e].sort((e,t)=>e-t),n=[],r=t[0],i=t[0];for(let e=1;e<t.length;e++){let a=t[e];if(a===i+1){i=a;continue}n.push({top:r,bottom:i}),r=a,i=a}return n.push({top:r,bottom:i}),n}function Is(e){let{focusedRowIndices:t,displayedColIds:n,rowKindAt:r,suppressMultiRanges:i,currentRowIndex:a}=e,o=[...t].filter(e=>_s(r(e))).sort((e,t)=>e-t);if(o.length===0)return[];let s=Ps(n,r,o[0]);if(!s)return[];if(i){if(o.length===1||o.every((e,t)=>t===0||e===o[t-1]+1))return[{startRowIndex:o[0],endRowIndex:o[o.length-1],startColId:s.startColId,endColId:s.endColId}];let e=a??o[o.length-1];return _s(r(e))?[{startRowIndex:e,endRowIndex:e,startColId:s.startColId,endColId:s.endColId}]:[]}return Fs(o).map(({top:e,bottom:t})=>({startRowIndex:e,endRowIndex:t,startColId:s.startColId,endColId:s.endColId}))}function Ls(e){let t=new Set(e.rangeRowIndices);for(let n of e.indexFocusedRowIds){let r=e.rowIndexById(n);r>=0&&t.add(r)}for(let n of e.selectedRowIds){let r=e.rowIndexById(n);r>=0&&t.add(r)}return t}function Rs(e,t){console.warn(`[magic-grid] addCellRange: ignored invalid range (${t}).`,e)}function zs(e){return t.it(e)||t.X(e)||A(e)||z(e)||L(e)}function Bs(e,t){return!zs(e)&&t.hidden===!0}function Vs(e){return!e.hidden}function Hs(e){return e.filter(e=>Vs(e))}function Us(e){return Hs(e).length}function Ws(e){let t=[];for(let n of e)!n.hidden||zs(n.colId)||t.push({colId:n.colId,label:n.label??n.prop??n.colId});return t}var Gs=`mg-column-settings`,Ks=`mg-column-settings__header`,qs=`mg-column-settings__body`,Js=`mg-column-settings-button`,Ys=`mg-column-settings-portal`,Xs=`mg-column-settings-popover`,Zs=`mg-column-settings-menu`,Qs=`mg-column-settings-menu__item`,$s=`mg-column-settings-menu__item-icon`,ec=`mg-column-settings-menu__item-label`,tc=`mg-column-settings-menu__divider`,nc=`mg-column-settings-menu__submenu`,rc=`mg-column-settings-menu__submenu-panel`,ic=`mg-column-settings-menu__item--submenu-trigger`,ac=`mg-column-settings__clear-filters`,oc=`mg-column-settings__group`,sc=`mg-column-settings__group-heading`,cc=`mg-column-settings__row`,lc=`mg-column-settings__row--filtered`,uc=`mg-column-settings__hidden-section`;function dc(e){return!zs(e)}function fc(e){return e===`left`?`left`:e===`right`?`right`:`center`}function pc(e){return e.label??e.prop??e.colId}function mc(e){let t=new Map,n={left:0,center:0,right:0};for(let r of e){if(r.hidden||!dc(r.colId))continue;let e=fc(r.fixed);t.set(r.colId,n[e]),n[e]++}return t}function hc(e){let t=e.sortModel[0],n=t?.colId,r=t?.sort??null,i=e.includeHidden??!0,a=e.columns.filter(e=>!(!dc(e.colId)||!i&&e.hidden)),o=mc(a);return a.map(t=>{let i=fc(t.fixed),a=t.hidden?-1:o.get(t.colId)??-1;return{colId:t.colId,label:pc(t),movable:t.movable,sortable:t.sortable,filterable:t.filterable,fixed:t.fixed??null,hidden:t.hidden,sortDirection:t.colId===n?r:null,filterActive:e.isColumnFilterActive(t.colId),displayIndex:a,lane:i}})}function gc(e){let t=e.filter(e=>!e.hidden),n=e.filter(e=>e.hidden);return{left:t.filter(e=>e.lane===`left`),center:t.filter(e=>e.lane===`center`),right:t.filter(e=>e.lane===`right`),hidden:n}}var _c=`.mg-cell__text:not([hidden])`,vc=`.mg-cell__renderer:not([hidden])`,yc=`.mg-header-cell__text`,bc=`.mg-footer-cell__text:not([hidden])`,xc=[`.mg-status-bar__panel`,`[data-mg-tooltip-anchor]`].join(`, `),Sc=[_c,vc,yc,bc].join(`, `),Cc=`mg-tooltip`;function wc(e){return t.it(e)||t.X(e)||A(e)||z(e)||L(e)}function Tc(e,t){return wc(e)?!0:t.suppressTooltip===!0}function Ec(e={}){let t=e.enableTooltips??!0;return{enableTooltips:t,tooltipShowMode:e.tooltipShowMode??(t?`whenTruncated`:`never`),tooltipShowDelay:e.tooltipShowDelay??500,tooltipSwitchShowDelay:e.tooltipSwitchShowDelay??200,tooltipHideDelay:e.tooltipHideDelay??3e3,tooltipInteraction:e.tooltipInteraction??!1,tooltipMouseTrack:e.tooltipMouseTrack??!1,tooltipComponent:e.tooltipComponent,tooltipComponentParams:e.tooltipComponentParams}}function Dc(e){return e.scrollWidth-e.clientWidth>1||e.scrollHeight-e.clientHeight>1}function Oc(e){try{return e.matches(vc)}catch{return!1}}function kc(e){if(e.children.length!==1)return e;let t=e.children[0];if(!(t instanceof HTMLElement))return e;let n=t;for(;n.childElementCount===1;){let e=n.firstElementChild;if(!(e instanceof HTMLElement)||!e.textContent?.trim())break;n=e}return n}function Ac(e,t){if(!e||typeof document>`u`)return 0;if(typeof getComputedStyle==`function`){let n=getComputedStyle(t),r=document.createElement(`canvas`).getContext(`2d`);if(r){r.font=(n.font||`${n.fontStyle} ${n.fontVariant} ${n.fontWeight} ${n.fontSize} ${n.fontFamily}`).trim()||`12px sans-serif`;let t=Number.parseFloat(n.paddingLeft)||0,i=Number.parseFloat(n.paddingRight)||0,a=r.measureText(e).width+t+i;if(a>0)return a}}let n=document.createElement(`span`);if(n.textContent=e,n.style.cssText=`position:fixed;left:-9999px;top:0;visibility:hidden;white-space:nowrap;pointer-events:none;max-width:none;width:max-content;`,typeof getComputedStyle==`function`){let e=getComputedStyle(t);n.style.font=e.font,n.style.letterSpacing=e.letterSpacing,n.style.textTransform=e.textTransform}document.body.appendChild(n);let r=Math.max(n.getBoundingClientRect().width,n.offsetWidth,n.scrollWidth);return document.body.removeChild(n),r}function jc(e,t,n){let r=Ac(t,kc(e));return r<=0?null:r>n+1}function Mc(e,t){let n=e.clientWidth;if(n<=0)return!1;let r=Nc(e),i=t?.trim(),a=e.textContent?.trim()??``;if(i&&a&&i!==a)return jc(e,a,n)??r;if(i){let t=jc(e,i,n);if(t!=null)return t}return r}function Nc(e){let t=e.clientWidth;if(t<=0)return!1;if(e.children.length===0)return e.scrollWidth-t>1;if(e.children.length===1){let n=e.children[0];if(!(n instanceof HTMLElement)||n.hidden)return!1;if(n.scrollWidth-t>1||Dc(n))return!0;if(n.clientWidth>=t-1){for(let e of n.children)if(!(!(e instanceof HTMLElement)||e.hidden||!e.textContent?.trim())&&Dc(e))return!0}return!1}if(Dc(e))return!0;for(let t of e.children)if(!(!(t instanceof HTMLElement)||t.hidden)&&t.textContent?.trim()&&Dc(t))return!0;return!1}function Pc(e){return!e.enableTooltips||e.mode===`never`||!e.text?!1:e.mode===`always`?!0:e.isAutoHeight?!1:Oc(e.anchorEl)?Mc(e.anchorEl,e.text):Dc(e.anchorEl)}var Fc=`加载中…`,Ic=`暂无数据`,Lc=`没有匹配的行`,Rc=`mg-overlay`,zc=`mg-overlay__wrapper`,Bc=`mg-overlay--masked`,Vc=`mg-overlay__content`,Hc=`mg-overlay__panel--loading`,Uc=`mg-overlay__panel--no-rows`,Wc=`mg-overlay__panel--no-matching-rows`,Gc=`mg-overlay__spinner`;function Kc(e){switch(e){case`loading`:return Fc;case`noRows`:return Ic;case`noMatchingRows`:return Lc;default:return e}}function qc(e={}){let t=new Set(e.suppressOverlays??[]);return e.suppressLoadingOverlay&&t.add(`loading`),e.suppressNoRowsOverlay&&t.add(`noRows`),e.suppressNoMatchingRowsOverlay&&t.add(`noMatchingRows`),t}function Jc(e={}){return{loading:e.loading,suppressOverlays:qc(e),overlayLoadingTemplate:e.overlayLoadingTemplate,overlayNoRowsTemplate:e.overlayNoRowsTemplate,overlayNoMatchingRowsTemplate:e.overlayNoMatchingRowsTemplate,loadingOverlayComponent:e.loadingOverlayComponent,loadingOverlayComponentParams:e.loadingOverlayComponentParams,noRowsOverlayComponent:e.noRowsOverlayComponent,noRowsOverlayComponentParams:e.noRowsOverlayComponentParams,noMatchingRowsOverlayComponent:e.noMatchingRowsOverlayComponent,noMatchingRowsOverlayComponentParams:e.noMatchingRowsOverlayComponentParams,overlayComponent:e.overlayComponent,overlayComponentParams:e.overlayComponentParams,overlayInteraction:e.overlayInteraction??!1}}function Yc(e,t){return t.has(e)}function Xc(e){let{rows:t,filterModel:n,getCellValue:r,columnContext:i,quickFilterText:a,quickFilterColIds:o=[]}=e,s=Object.entries(n).filter(([,e])=>oi(e)),c=Vr(a),l=Nr(t),u=!l&&Wr(t);if(l)return s.length===0&&!c?zr(t):Zc(t,s,c,{getCellValue:r,context:i??el,quickFilterText:a??``,quickFilterColIds:o});if(u)return s.length===0&&!c?Jr(t):Qc(t,s,c,{getCellValue:r,context:i??el,quickFilterText:a??``,quickFilterColIds:o});if(s.length===0&&!c)return[...t];let d=i??el;return t.filter(e=>$c(e,s,r,d,c,{quickFilterText:a??``,quickFilterColIds:o}))}function Zc(e,t,n,r){let i=[];for(let a of e){if(a.group){let e=Zc(a.childrenAfterGroup??[],t,n,r);if(e.length===0)continue;a.childrenAfterFilter=e,a.groupLeafCount=jr(e),i.push(a);continue}$c(a,t,r.getCellValue,r.context,n,{quickFilterText:r.quickFilterText,quickFilterColIds:r.quickFilterColIds})&&i.push(a)}return i}function Qc(e,t,n,r){let i=[];for(let a of e){let e=Qc(a.childrenAfterTree??[],t,n,r);!$c(a,t,r.getCellValue,r.context,n,{quickFilterText:r.quickFilterText,quickFilterColIds:r.quickFilterColIds})&&e.length===0||(a.childrenAfterFilter=e,i.push(a))}return i}function $c(e,t,n,r,i,a){return tl(e,t,n,r)&&(!i||Ur({row:e,quickFilterText:a.quickFilterText,filterableColIds:a.quickFilterColIds,getCellValue:n,getFilterValue:(e,t,n)=>r.getFilterValue(e,t,n)}))}var el={getFilterType:()=>`text`,getFilterParams:()=>({caseSensitive:!0}),getFilterValue:(e,t,n)=>n(e,t)};function tl(e,t,n,r){for(let[i,a]of t){let t=r.getFilterValue(e,i,n);if(vr(a)){if(!a.predicate(t,e.data))return!1;continue}if(!Ni(t,a,r.getFilterType(i),r.getFilterParams(i)))return!1}return!0}var nl=`合计`;function rl(e){return typeof e==`number`&&Number.isFinite(e)}function il(e,t){let n=[];for(let r of e){let e=H(r,t);rl(e)&&n.push(e)}return n}function al(e,t,n){if(e===`count`)return t.length;let r=il(t,n);if(r.length===0)return null;switch(e){case`sum`:return r.reduce((e,t)=>e+t,0);case`avg`:return r.reduce((e,t)=>e+t,0)/r.length;case`min`:return Math.min(...r);case`max`:return Math.max(...r);default:return null}}function ol(e,t,n){return typeof e==`function`?e(t,n):al(e,t,n)}function sl(e){return e.summary===!1?!1:e.summaryAgg!=null||e.summary===!0}function cl(e,t){return t==null?``:e.summaryFormatter?e.summaryFormatter(t):e.formatter?e.formatter({},t):String(t)}function ll(e,t){return{value:t,formattedValue:cl(e,t)}}function ul(e,t,n){if(!n)return null;try{let r=n({columns:e,data:t.map(e=>e.data),rows:t}),i=new Map;for(let[e,t]of Object.entries(r))t!==void 0&&i.set(e,t);return i}catch(e){return console.warn(`[magic-grid] summaryMethod failed:`,e),new Map}}function dl(e){return e.find(e=>!t.it(e.colId)&&!t.X(e.colId))}function fl(e){let{columns:n,rows:r,summaryMethod:i}=e,a=new Map,o=ul(n,r,i);for(let e of n){if(t.it(e.colId)||t.X(e.colId)){a.set(e.colId,ll(e,null));continue}let n=o?.get(e.colId);if(o?.has(e.colId)){a.set(e.colId,ll(e,n??null));continue}if(sl(e)&&e.summaryAgg!=null){let t=ol(e.summaryAgg,r,e);a.set(e.colId,ll(e,t))}}let s=dl(n);return s&&!a.has(s.colId)&&a.set(s.colId,ll(s,nl)),a}function pl(e){return Nr(e.rows)&&ml(e.rows,e.columns),[...e.rows]}function ml(e,t){for(let n of e){if(!n.group)continue;let e=Ir(n);ml(e,t),n.__groupAggValues=hl(t,Rr(e))}}function hl(e,n){let r={};for(let i of e){if(!i.groupAgg||t.it(i.colId)||t.X(i.colId)||A(i.colId)||L(i.colId))continue;let e=ol(i.groupAgg,n,i);r[i.colId]={value:e,formattedValue:cl(i,e)}}return r}function gl(e,t={}){let n=e.groupId??e.id,r=t.rowHeight??or;return{id:Ie(n),data:{},rowTop:0,rowHeight:r,estimated:!1,rowIndex:-1,sourceIndex:-1,rowKind:`GROUP_HEADER`,sourceGroupId:n,groupField:e.groupField,groupKey:e.groupKey,groupLevel:e.groupLevel,groupLeafCount:e.groupLeafCount,groupId:n,groupPathKey:e.groupPathKey}}function _l(e,t={}){let n=e.groupId??e.id,r=t.rowHeight??or;return{id:Le(n),data:{},rowTop:0,rowHeight:r,estimated:!1,rowIndex:-1,sourceIndex:-1,rowKind:`GROUP_FOOTER`,sourceGroupId:n,groupField:e.groupField,groupKey:e.groupKey,groupLevel:e.groupLevel,groupLeafCount:e.groupLeafCount,groupId:n,groupPathKey:e.groupPathKey,__groupAggValues:vl(e.__groupAggValues)}}function vl(e){if(e)return{...e}}function yl(e,t){return Nr(e)?xl(e,{expandedGroupIds:t?.expandedGroupIds??new Set,showGroupHeader:t?.showGroupHeader??!1,showGroupFooter:t?.showGroupFooter??!1,defaultRowHeight:t?.defaultRowHeight}):Wr(e)?bl(e,{expandedRowIds:t?.expandedRowIds??new Set}):[...e]}function bl(e,t){let n=[];function r(e){for(let i of e)n.push(i),t.expandedRowIds.has(i.id)&&r(Kr(i))}return r(e),n}function xl(e,t){let n=[];for(let r of e){if(!r.group){n.push(r);continue}let e=r.groupId??r.id,i=!t.showGroupHeader||t.expandedGroupIds.has(e);t.showGroupHeader&&n.push(gl(r,{rowHeight:t.defaultRowHeight})),i&&(n.push(...xl(Ir(r),t)),t.showGroupFooter&&n.push(_l(r,{rowHeight:t.defaultRowHeight})))}return n}function Sl(e,t,n){let{colId:r,sort:i}=e;return n?(e,a)=>{let o=n(t(e,r),t(a,r),i,e.data,a.data);return o===0?e.id.localeCompare(a.id):i===`desc`?-o:o}:(e,n)=>{let a=Cl(t(e,r),t(n,r),i);return a===0?e.id.localeCompare(n.id):a}}function Cl(e,t,n){let r=0;return r=e==null&&t==null?0:e==null?-1:t==null?1:typeof e==`number`&&typeof t==`number`?e-t:String(e).localeCompare(String(t)),n===`desc`?-r:r}function wl(e,t,n,r){if(t.length<4)return[...r??e].sort(n);let i=new Set(t.map(e=>e.id));return Tl(e.filter(e=>!i.has(e.id)),[...t].sort(n),n)}function Tl(e,t,n){let r=[],i=0,a=0;for(;i<e.length&&a<t.length;)n(e[i],t[a])<=0?(r.push(e[i]),i++):(r.push(t[a]),a++);for(;i<e.length;)r.push(e[i]),i++;for(;a<t.length;)r.push(t[a]),a++;return r}function El(e){let t=e.rows??e.sourceRows;if(Nr(t))return Dl({rows:t,sortModel:e.sortModel,getCellValue:e.getCellValue,getColumnComparator:e.getColumnComparator,groupComparator:e.groupComparator,groupSortKey:e.groupSortKey});if(Wr(t))return jl({rows:t,sortModel:e.sortModel,getCellValue:e.getCellValue,getColumnComparator:e.getColumnComparator});let{sourceRows:n,currentDisplayRows:r,sortModel:i,touchedRowIds:a,getCellValue:o,getColumnComparator:s}=e;if(i.length===0)return[...t];let c=i[0],l=Sl(c,o,s?.(c.colId));if(a&&a.size>0){let e=n.filter(e=>a.has(e.id));if(e.length>0&&r.length>0)return wl(r,e,l,n)}return[...t].sort(l)}function Dl(e){let t=Ol(e.rows,e);return Br(t),t}function Ol(e,t){if(e.length===0)return[];if(e[0]?.group){let n=wr(t.groupComparator);return e.map(e=>kl(e,t)).sort((e,t)=>{let r=e.groupLevel??t.groupLevel??0,i=e.groupField??t.groupField??``;return n(e.groupKey??``,t.groupKey??``,{colId:i,field:i,level:r})})}return Al(e,t)}function kl(e,t){return e.childrenAfterSort=Ol(e.childrenAfterFilter??e.childrenAfterGroup??[],t),e}function Al(e,t){if(t.sortModel.length===0)return t.groupSortKey?xr(e,t.groupSortKey):[...e];let n=t.sortModel[0],r=Sl(n,t.getCellValue,t.getColumnComparator?.(n.colId));return[...e].sort(r)}function jl(e){return Ml(e.rows,e)}function Ml(e,t){let n=Al(e,t);for(let e of n){let n=Gr(e);e.childrenAfterSort=n.length>0?Ml(n,t):[]}return n}var Nl=`\0`;function Pl(e){return e.join(Nl)}var Fl=class extends Error{constructor(e){super(e),this.name=`TreeBuildError`}};function Il(e){let{sourceRows:t,getDataPath:n}=e,r=new Map,i=t.map((e,t)=>({node:e,path:n({data:e.data}),sourceIndex:t})).sort((e,t)=>e.path.length===t.path.length?e.sourceIndex-t.sourceIndex:e.path.length-t.path.length);for(let{path:e}of i)if(!Array.isArray(e)||e.length===0)throw new Fl(`[TreeBuildStage] getDataPath must return a non-empty string[]`);for(let{node:e,path:t}of i){let n=Pl(t);if(r.has(n))throw new Fl(`[TreeBuildStage] duplicate dataPath: ${t.join(`/`)}`);e.dataPath=[...t],e.treeLevel=t.length-1,e.treeLeaf=!0,e.childrenAfterTree=[],r.set(n,e)}let a=[];for(let{node:e,path:t}of i){if(t.length===1){e.parentRowId=void 0,a.push(e);continue}let n=t.slice(0,-1),i=r.get(Pl(n));if(!i)throw new Fl(`[TreeBuildStage] missing parent path: ${n.join(`/`)}`);e.parentRowId=i.id,i.treeLeaf=!1,i.childrenAfterTree.push(e)}return{roots:a,nodeByPath:r}}function Ll(e){function t(e){for(let n of e){let e=n.childrenAfterTree??[];e.length===0?n.treeLeaf=!0:(n.treeLeaf=!1,t(e))}}t(e)}function Rl(e){let{sourceRows:t,getDataPath:n}=e;if(t.length===0)return[];let{roots:r}=Il({sourceRows:t,getDataPath:n});return Ll(r),r}var zl=[...gr];function Bl(e,t){return e.length===1&&e[0]===`map`&&t!=null&&t.groupedTreeRoots!=null&&t.groupedTreeRoots.length>0&&Nr(t.groupedTreeRoots)}function Vl(e,t){return e.length===1&&e[0]===`map`&&t!=null&&t.treeTreeRoots!=null&&t.treeTreeRoots.length>0&&Wr(t.treeTreeRoots)}function Hl(e,t){if(t)return t.getMapStageOptions?.()??t.mapStageOptions;if(e)return e.getMapStageOptions?.()??e.mapStageOptions}function Ul(e){let t=e.stages??zl,n=e.grouping,r=e.tree,i=[...e.sourceRows];if(Bl(t,n)&&n?.groupedTreeRoots)i=yl(n.groupedTreeRoots,Hl(n,void 0));else if(Vl(t,r)&&r?.treeTreeRoots)i=yl(r.treeTreeRoots,Hl(void 0,r));else for(let a of t)switch(a){case`tree`:i=r?.getDataPath?Rl({sourceRows:e.sourceRows,getDataPath:r.getDataPath}):[...e.sourceRows];break;case`group`:i=n&&n.rowGroupColumns.length>0?Tr({sourceRows:e.sourceRows,rowGroupColumns:n.rowGroupColumns,getCellValue:e.getCellValue,groupKeyCreator:n.groupKeyCreator,groupComparator:n.groupComparator,groupSortKey:n.groupSortKey,getColumnField:n.getColumnField}):[...e.sourceRows];break;case`filter`:i=Xc({rows:i,filterModel:e.filterModel,getCellValue:e.getCellValue,columnContext:e.filterColumnContext,quickFilterText:e.quickFilterText,quickFilterColIds:e.getQuickFilterColIds?.()??[]}),r&&Wr(i)&&Vr(e.quickFilterText)&&r.applyQuickFilterExpand&&r.applyQuickFilterExpand(i);break;case`sort`:i=El({sourceRows:e.sourceRows,rows:i,currentDisplayRows:e.currentDisplayRows,sortModel:e.sortModel,touchedRowIds:e.touchedRowIds,getCellValue:e.getCellValue,getColumnComparator:e.getColumnComparator,groupComparator:n?.groupComparator,groupSortKey:n?.groupSortKey});break;case`aggregate`:n&&Nr(i)&&(i=pl({rows:i,columns:n.columns}));break;case`map`:n?.prepareGroupedTree&&Nr(i)&&n.prepareGroupedTree(i),r?.prepareTreeTree&&Wr(i)&&r.prepareTreeTree(i),i=yl(i,Hl(n,r))}return e.afterMap&&(i=e.afterMap(i)),e.positionRowsOptions?fr(i,e.positionRowsOptions):fr(i,e.rowHeight),i}function Wl(e){return[..._r(e)]}var Gl=class{refreshing=!1;pendingRun=null;refresh(e){if(this.refreshing){this.pendingRun=e;return}this.refreshing=!0;try{let t=e;for(;t;){let e=t;t=null,e(),t=this.pendingRun,this.pendingRun=null}}finally{this.refreshing=!1}}reset(){this.refreshing=!1,this.pendingRun=null}};function Kl(e,t){for(let n of e)n.group&&(t(n),Kl(Lr(n),t))}function ql(e){let t=[];return Kl(e,e=>{e.groupId&&t.push(e.groupId)}),t}function Jl(e,t){let n;return Kl(e,e=>{e.groupId===t&&(n=e)}),n}function Yl(e,t){return t===0?!1:t===-1||e<t}var Xl=class extends Error{constructor(e){super(e),this.name=`RowModelError`}};function Zl(e,n){let{rowKey:r,rowHeight:i=or,allowTransient:a=!1}=n;if(!r)throw new Xl(`rowKey is required`);let o=new Set,s=[];for(let n=0;n<e.length;n++){let c=e[n],l=c[r];if(t.A(l)){if(!a)throw new Xl(`Missing rowKey "${r}" at index ${n}`);let e=t.k();if(o.has(e))throw new Xl(`Duplicate transient row id "${e}" at index ${n}`);o.add(e),s.push({id:e,data:c,isTransient:!0,rowTop:0,rowHeight:i,estimated:!1,rowIndex:s.length,sourceIndex:s.length});continue}let u=String(l);o.has(u)||(o.add(u),s.push({id:u,data:c,isTransient:!1,rowTop:0,rowHeight:i,estimated:!1,rowIndex:s.length,sourceIndex:s.length}))}return yr(s),s}function Ql(e,t,n){if(t.length===0)return[...e];let r=n??e.length,i=Math.max(0,Math.min(r,e.length));return[...e.slice(0,i),...t,...e.slice(i)]}function $l(e,t){return Math.max(0,Math.min(e,t))}function eu(e,t){if(typeof e==`string`)return e;let n=e[t];if(n==null)throw new Xl(`Missing rowKey "${t}" in remove item`);return String(n)}function tu(e,t){if(typeof e!=`object`||!e||!(`data`in e))return!1;let n=e;return n[t]!==void 0&&n[t]!==null&&n[t]!==``?!1:typeof e.data==`object`&&e.data!==null}function nu(e,t){return tu(e,t)?e.data:e}function ru(e,t){if(tu(e,t))return e.index}function iu(e){return typeof e!=`object`||!e||!(`data`in e)||!(`rowId`in e)?!1:typeof e.rowId==`string`}function au(e,t,n){let r=n.rowKey,i=n.rowHeight??or,a=new Map(e.map(e=>[e.id,e])),o={add:[],remove:[],update:[]},s=new Set;if(t.remove?.length)for(let e of t.remove){let t=eu(e,r),n=a.get(t);n&&(o.remove.push(n),a.delete(t),s.add(t))}if(t.update?.length)for(let e of t.update){let t,n;if(iu(e))n=a.get(e.rowId),t=e.data;else{t=e;let i=t[r];if(i==null){if(n=[...a.values()].find(e=>e.data===t&&e.isTransient),!n)throw new Xl(`Missing rowKey "${r}" in update item`)}else n=a.get(String(i))}n&&(n.data!==t&&Object.assign(n.data,t),o.update.push(n),s.add(n.id))}let c=new Set(o.remove.map(e=>e.id)),l=e.filter(e=>!c.has(e.id));if(t.add?.length)for(let e of t.add){let t=nu(e,r),n=ru(e,r),[c]=Zl([t],{rowKey:r,rowHeight:i,allowTransient:!0});if(c){if(a.has(c.id))throw new Xl(`Duplicate rowKey on add: "${c.id}"`);a.set(c.id,c),o.add.push(c),s.add(c.id),l=Ql(l,[c],n)}}return{sourceRows:l,transaction:o,touchedRowIds:[...s]}}function ou(e,t){if(t<0||t>=e.length)return null;let n=e[t];return{rowTop:n.rowTop,rowHeight:n.rowHeight}}function su(e,t){let n=e.length;if(n===0||t<=0)return 0;let r=0,i=n-1;for(;r<=i;){let n=r+i>>1,a=e[n],o=a.rowTop+a.rowHeight;if(t<a.rowTop)i=n-1;else if(t>=o)r=n+1;else return n}return n-1}function cu(e,t){return t.rowGroupColumns.length===0||e.length===0?[...e]:Mr(Tr({sourceRows:e,...t}))}function lu(e,t,n){return!t||!n||n.rowGroupColumns.length===0?[...e]:cu(e,n)}var uu=class{sourceRows=[];displayRows=[];baseDisplayRows=[];sortModel=[];filterModel={};quickFilterText=``;touchedRowIds=null;rowKey;defaultRowHeight;getCellValue;getColumnComparator;filterColumnContext;getQuickFilterColIds;refreshScheduler=new Gl;positionGetRowHeight;rowExpansionService=null;loadMoreRowService=null;rowGroupingDeps=null;treeTableDeps=null;groupedTreeRoots=[];treeTreeRoots=[];constructor(e){this.rowKey=e.rowKey,this.defaultRowHeight=e.rowHeight??or,this.getCellValue=e.getCellValue??du,this.getColumnComparator=e.getColumnComparator,this.filterColumnContext=e.filterColumnContext,this.getQuickFilterColIds=e.getQuickFilterColIds,this.quickFilterText=e.quickFilterText??``}get rowsToDisplay(){return this.displayRows}getBaseDisplayRows(){return this.baseDisplayRows}setRowExpansionService(e){this.rowExpansionService=e}getRowExpansionService(){return this.rowExpansionService}setLoadMoreRowService(e){this.loadMoreRowService=e}setRowGroupingDeps(e){this.rowGroupingDeps=e,e?.active()||(this.groupedTreeRoots=[])}setTreeTableDeps(e){this.treeTableDeps=e,e?.active()||(this.treeTreeRoots=[])}getTreeTreeRoots(){return this.treeTreeRoots}getGroupedTreeRoots(){return this.groupedTreeRoots}setPositionGetRowHeight(e){this.positionGetRowHeight=e}resolvePositionRowsOptions(){return{defaultRowHeight:this.defaultRowHeight,getRowHeight:this.positionGetRowHeight}}setData(e){this.sourceRows=Zl(e,{rowKey:this.rowKey,rowHeight:this.defaultRowHeight,allowTransient:!0}),this.touchedRowIds=null,this.rowExpansionService?.clearExpanded(),this.rowGroupingDeps?.clearExpanded(),this.treeTableDeps?.clearExpanded(),this.groupedTreeRoots=[],this.treeTreeRoots=[],this.refreshModel({applyDefaultExpanded:!0})}setSortModel(e){this.sortModel=[...e],this.touchedRowIds=null,this.refreshModel()}setFilterModel(e){this.filterModel={...e},this.refreshModel()}getSortModel(){return[...this.sortModel]}getFilterModel(){return{...this.filterModel}}getQuickFilterText(){return this.quickFilterText}setQuickFilterText(e){this.quickFilterText!==e&&(this.quickFilterText=e,this.refreshModel())}markTouchedRowIds(e){this.touchedRowIds=new Set(e)}applyTransaction(e){let{sourceRows:t,transaction:n,touchedRowIds:r}=au(this.sourceRows,e,{rowKey:this.rowKey,rowHeight:this.defaultRowHeight});return this.sourceRows=t,yr(this.sourceRows),this.markTouchedRowIds(r),this.maybeSyncGroupSortKeyOnSourceRows(),this.refreshModel(),n}rebuildDisplayProjection(){if(this.treeTableDeps?.active()){this.rebuildTreeMapProjection();return}if(this.rowGroupingDeps?.active()){this.rebuildGroupedMapProjection();return}this.displayRows=this.buildProjectedDisplayRows(!1),fr(this.displayRows,this.resolvePositionRowsOptions())}rebuildTreeMapProjection(){if(this.treeTableDeps?.active()){if(this.treeTreeRoots.length===0||!Wr(this.treeTreeRoots)){this.refreshModel();return}this.refreshModel({stages:[`map`]})}}rebuildGroupedMapProjection(){if(this.rowGroupingDeps?.active()){if(this.groupedTreeRoots.length===0||!this.groupedTreeRoots.some(e=>e.group)){this.refreshModel();return}this.refreshModel({stages:[`map`]})}}getRowById(e){return this.sourceRows.find(t=>t.id===e)}resolveRowById(e){return this.getRowById(e)??this.getDisplayRowById(e)}getDisplayRowById(e){return this.displayRows.find(t=>t.id===e)}setDefaultRowHeight(e){this.defaultRowHeight=Math.max(1,e)}repositionDisplayRows(e){fr(this.displayRows,{defaultRowHeight:this.defaultRowHeight,getRowHeight:e?.getRowHeight??this.positionGetRowHeight})}getRowIndexById(e){return this.displayRows.findIndex(t=>t.id===e)}refreshModel(e={}){let t=typeof e==`boolean`?{applyDefaultExpanded:e}:e,n=t.applyDefaultExpanded??!1,r=this.rowGroupingDeps?.active()??!1,i=this.treeTableDeps?.active()??!1,a=i?`tree`:r?`group`:`flat`,o=t.stages??Wl(a);(o.length!==1||o[0]!==`map`)&&this.normalizeGroupedSourceRowsIfNeeded(),this.refreshScheduler.refresh(()=>{let e=this.rowGroupingDeps,t=this.treeTableDeps,s=n;this.displayRows=Ul({sourceRows:this.sourceRows,currentDisplayRows:this.displayRows,sortModel:this.sortModel,filterModel:this.filterModel,touchedRowIds:this.touchedRowIds??void 0,getCellValue:this.getCellValue,getColumnComparator:this.getColumnComparator,filterColumnContext:this.filterColumnContext,quickFilterText:this.quickFilterText,getQuickFilterColIds:this.getQuickFilterColIds,rowHeight:this.defaultRowHeight,positionRowsOptions:this.resolvePositionRowsOptions(),stages:o,hierarchyMode:a,grouping:r&&e?{rowGroupColumns:e.getRowGroupColumns(),groupKeyCreator:e.getGroupKeyCreator(),groupComparator:e.getGroupComparator(),groupSortKey:e.getGroupSortKey(),getColumnField:e.getColumnField,columns:e.getColumns(),getMapStageOptions:()=>({...e.getMapStageOptions(),defaultRowHeight:this.defaultRowHeight}),groupedTreeRoots:this.groupedTreeRoots,prepareGroupedTree:t=>{this.groupedTreeRoots=[...t],e.pruneExpanded(new Set(ql(t))),s&&=(e.applyDefaultExpanded(t),!1)}}:void 0,tree:i&&t?{getDataPath:t.getDataPath(),getMapStageOptions:()=>({...t.getMapStageOptions(),defaultRowHeight:this.defaultRowHeight}),treeTreeRoots:this.treeTreeRoots,prepareTreeTree:e=>{this.treeTreeRoots=[...e],t.prepareTreeTree(e),s&&=(t.applyDefaultExpanded(e),!1)},applyQuickFilterExpand:e=>{t.expandForQuickFilterDisplay(e)}}:void 0,afterMap:e=>this.buildProjectedDisplayRows(n,e)}),this.touchedRowIds=null})}buildProjectedDisplayRows(e,t=this.baseDisplayRows){this.baseDisplayRows=t;let n;return this.rowExpansionService?.active?(e&&this.rowExpansionService.applyDefaultExpanded(t),this.rowExpansionService.pruneExpanded(new Set(this.sourceRows.map(e=>e.id))),n=this.rowExpansionService.injectDetailRows(t)):n=t.slice(),this.loadMoreRowService?.injectTrailingRow(n)??n}getRow(e){return this.displayRows[e]}getRowCount(){return this.displayRows.length}getSourceRowCount(){return this.sourceRows.length}getSourceRows(){return this.sourceRows}getSourceRowIndexById(e){return this.sourceRows.findIndex(t=>t.id===e)}setSourceRows(e){this.sourceRows=e,yr(this.sourceRows),this.maybeSyncGroupSortKeyOnSourceRows(),this.touchedRowIds=null,this.refreshModel()}maybeSyncGroupSortKeyOnSourceRows(){let e=this.rowGroupingDeps;if(!e?.active())return;let t=e.getGroupSortKey();t&&Sr(this.sourceRows,t)}normalizeGroupedSourceRowsIfNeeded(){let e=this.rowGroupingDeps;if(!e?.active())return;let t=e.getRowGroupColumns();t.length!==0&&(this.sourceRows=lu(this.sourceRows,!0,{rowGroupColumns:t,getCellValue:this.getCellValue,groupKeyCreator:e.getGroupKeyCreator(),groupComparator:e.getGroupComparator(),groupSortKey:e.getGroupSortKey(),getColumnField:e.getColumnField}),yr(this.sourceRows),this.maybeSyncGroupSortKeyOnSourceRows())}getRowKey(){return this.rowKey}promoteRowId(e,n){let r=this.getRowById(e);if(!r)return{ok:!1,reason:`Row "${e}" not found`};if(!r.isTransient)return{ok:!1,reason:`Row "${e}" is not transient`};if(t.A(n))return{ok:!1,reason:`businessId is required`};let i=String(n);return this.sourceRows.some(e=>e!==r&&e.id===i)?{ok:!1,reason:`Duplicate row id "${i}"`}:(r.data[this.rowKey]=n,r.id=i,r.isTransient=!1,this.markTouchedRowIds([i]),this.refreshModel(),{ok:!0,rowId:i})}getRowIndexAtPixel(e){return su(this.displayRows,e)}getRowBounds(e){return ou(this.displayRows,e)}getTotalHeight(){return pr(this.displayRows)}ensureRowHeightsValid(e,t){return!1}};function du(e,t){return e.data[t]}var fu=`__MG_INF_STUB__::`;function pu(e){return`${fu}${e}`}function mu(e){return e.startsWith(fu)}function hu(e){let t=e.rowHeight??or,n=e.index;return{id:pu(n),data:{},rowTop:n*t,rowHeight:t,estimated:!1,rowIndex:n,sourceIndex:n,__infiniteBlockState:e.blockState??`idle`}}function gu(e,n,r){let i=n[e];return t.A(i)?r?.isTransient?{id:r.id,isTransient:!0}:{id:t.k(),isTransient:!0}:{id:String(i),isTransient:!1}}function _u(e){let{index:t,rowHeight:n,rowKey:r,data:i}=e,{id:a,isTransient:o}=gu(r,i);return{id:a,data:i,isTransient:o,rowTop:t*n,rowHeight:n,estimated:!1,rowIndex:t,sourceIndex:t,__infiniteBlockState:e.blockState??`loaded`}}function vu(e){let{index:t,rowHeight:n,rowKey:r,data:i,existing:a}=e,{id:o,isTransient:s}=gu(r,i,a);return a&&a.id===o?(a.data=i,a.isTransient=s,a.rowTop=t*n,a.rowHeight=n,a.rowIndex=t,a.sourceIndex=t,a.__infiniteBlockState=e.blockState??`loaded`,a):_u(e)}var yu=class{displayRows=[];virtualRowCount=0;knownLastRow=null;rowKey;defaultRowHeight;sortModel=[];filterModel={};quickFilterText=``;constructor(e){this.rowKey=e.rowKey,this.defaultRowHeight=e.rowHeight??or,this.setVirtualRowCount(e.initialRowCount??0,{preserveLoaded:!1})}get rowsToDisplay(){return this.displayRows}getRow(e){return this.displayRows[e]}getRowCount(){return this.virtualRowCount}getRowIndexAtPixel(e){if(this.virtualRowCount===0)return 0;let t=Math.floor(Math.max(0,e)/this.defaultRowHeight);return Math.min(t,this.virtualRowCount-1)}getRowBounds(e){let t=this.displayRows[e];return t?{rowTop:t.rowTop,rowHeight:t.rowHeight}:null}getTotalHeight(){return this.virtualRowCount*this.defaultRowHeight}ensureRowHeightsValid(e,t){return!1}getKnownLastRow(){return this.knownLastRow}getVirtualRowCount(){return this.virtualRowCount}setVirtualRowCount(e,t){let n=Math.max(0,Math.floor(e)),r=t?.preserveLoaded??!0;if(n===this.virtualRowCount&&this.displayRows.length===n)return;let i=this.displayRows;this.virtualRowCount=n,this.displayRows=Array(n);for(let e=0;e<n;e++){let t=r?i[e]:void 0;t&&t.__infiniteBlockState===`loaded`?(t.rowIndex=e,t.sourceIndex=e,t.rowTop=e*this.defaultRowHeight,this.displayRows[e]=t):this.displayRows[e]=hu({index:e,rowHeight:this.defaultRowHeight,blockState:`idle`})}}updateLastRow(e,t,n){if(e!==void 0){this.knownLastRow=Math.max(0,Math.floor(e)),this.setVirtualRowCount(this.knownLastRow,{preserveLoaded:!0});return}this.knownLastRow=null,n>=this.virtualRowCount&&this.setVirtualRowCount(n+t,{preserveLoaded:!0})}applyBlock(e,t){let n=[],r=[],i=this.defaultRowHeight;for(let a=0;a<t.length;a++){let o=e+a;if(o>=this.virtualRowCount)break;let s=this.displayRows[o];s&&mu(s.id)&&r.push(s.id);let c=vu({existing:s,index:o,rowHeight:i,rowKey:this.rowKey,data:t[a],blockState:`loaded`});this.displayRows[o]=c,n.push(c.id)}return{rowIds:n,replacedStubIds:r,virtualRowCount:this.virtualRowCount}}markBlockRange(e,t,n){for(let r=e;r<t&&r<this.virtualRowCount;r++){let e=this.displayRows[r];e&&(n!==`loaded`||e.__infiniteBlockState!==`loaded`)&&(n===`idle`||n===`loading`||n===`failed`?this.displayRows[r]=hu({index:r,rowHeight:this.defaultRowHeight,blockState:n}):e.__infiniteBlockState=n)}}evictBlockRange(e,t){this.markBlockRange(e,t,`idle`)}resetForPurge(e){this.knownLastRow=null,this.setVirtualRowCount(e,{preserveLoaded:!1})}getRowKey(){return this.rowKey}resolveRowById(e){return this.displayRows.find(t=>t.id===e)}getRowById(e){return this.resolveRowById(e)}getRowIndexById(e){return this.displayRows.findIndex(t=>t.id===e)}getBaseDisplayRows(){return this.displayRows}getSourceRows(){return this.displayRows.filter(e=>e.__infiniteBlockState===`loaded`)}getSourceRowCount(){return this.getSourceRows().length}getLoadedRowData(){return this.getSourceRows().map(e=>({...e.data}))}getSortModel(){return[...this.sortModel]}setSortModel(e){this.sortModel=[...e]}getFilterModel(){return{...this.filterModel}}setFilterModel(e){this.filterModel={...e}}getQuickFilterText(){return this.quickFilterText}setQuickFilterText(e){this.quickFilterText=e}setDefaultRowHeight(e){this.defaultRowHeight=Math.max(1,e);for(let e=0;e<this.displayRows.length;e++){let t=this.displayRows[e];t.rowTop=e*this.defaultRowHeight,t.rowHeight=this.defaultRowHeight}}getGroupedTreeRoots(){return[]}getTreeTreeRoots(){return[]}setRowExpansionService(e){}setLoadMoreRowService(e){}setRowGroupingDeps(e){}setTreeTableDeps(e){}setPositionGetRowHeight(e){}repositionDisplayRows(e){}};function bu(e){return e instanceof uu}function W(e){return e instanceof yu}function xu(e){let n=t.R(e);return t.L({rowModelType:n.rowModelType,infiniteDatasource:e.infiniteDatasource,rowGrouping:{rowGroupColumns:Array(e.rowGroupingColumnCount??0)},treeTable:{getDataPath:e.hasTreeTable?()=>[]:void 0},masterDetail:{detailCellRenderer:e.hasMasterDetail?()=>null:void 0},rowDragManaged:e.rowDragManaged,treeLazyLoad:e.hasTreeLazyLoad},n),n.rowModelType===`infinite`?{rowModel:new yu({rowKey:e.rowKey,rowHeight:e.rowHeight,initialRowCount:n.infiniteInitialRowCount}),resolvedInfinite:n}:{rowModel:new uu({rowKey:e.rowKey,rowHeight:e.rowHeight,getCellValue:e.getCellValue,getColumnComparator:e.getColumnComparator,filterColumnContext:e.filterColumnContext,quickFilterText:e.quickFilterText,getQuickFilterColIds:e.getQuickFilterColIds}),resolvedInfinite:n}}function G(e,t){if(W(e))throw Error(`[MagicGrid] ${t}() is not supported when rowModelType is "infinite"`)}var Su=!1;function Cu(){Su||(Su=!0,console.warn(`[MagicGrid] getData() in infinite mode returns loaded blocks only; use getLoadedRowData() instead.`))}function wu(e,t){let n={internalRowId:t.internalRowId,columnCellEditorCache:t.columnCellEditorCache};return{getCellCache:r=>e.get(t.rowId,t.colId,r,n),setCellCache:(r,i)=>e.set(t.rowId,t.colId,r,i,n),clearCellCache:r=>{if(r===void 0){e.clearCell(t.rowId,t.colId,t.internalRowId);return}e.clear(t.rowId,t.colId,r,n)}}}function Tu(e,n){let{enableCellEditorCache:r,rowNode:i,column:a,rowKey:o}=n;if(t.l({enableCellEditorCache:r,colId:a.colId,cellEditorMode:a.cellEditorMode,cellEditor:a.cellEditor,columnCellEditorCache:a.cellEditorCache}))return wu(e,{rowId:t.T(i,o),colId:a.colId,internalRowId:i.isTransient?i.id:void 0,columnCellEditorCache:a.cellEditorCache})}var Eu=class{store=new Map;bucketKeys=new Map;bucketAccessOrder=[];maxEntries;constructor(e={}){this.maxEntries=e.maxEntries}get(e,n,r,i){let a=t.c({userKey:r,columnCellEditorCache:i?.columnCellEditorCache}),o=t.a(e,n,a,{internalRowId:i?.internalRowId});if(this.store.has(o))return this.touchBucket(e,n,i?.internalRowId),this.store.get(o)}set(e,n,r,i,a){let o=t.c({userKey:i,columnCellEditorCache:a?.columnCellEditorCache}),s=t.a(e,n,o,{internalRowId:a?.internalRowId}),c=t.r(e,n,{internalRowId:a?.internalRowId});this.bucketKeys.has(c)||this.bucketKeys.set(c,new Set),this.bucketKeys.get(c).add(s),this.store.set(s,r),this.touchBucket(e,n,a?.internalRowId),this.evictIfNeeded()}clear(e,n,r,i){if(e==null&&n==null&&r==null){this.clearAll();return}if(e!=null&&n==null){let n=t.i(e,i?.internalRowId);for(let e of[...this.bucketKeys.keys()])e.startsWith(`${n}::`)&&this.clearCellByBucketKey(e);return}if(e==null||n==null)return;if(r==null){this.clearCell(e,n,i?.internalRowId);return}let a=t.c({userKey:r,columnCellEditorCache:i?.columnCellEditorCache}),o=t.a(e,n,a,{internalRowId:i?.internalRowId});this.deleteStorageKey(o)}clearCell(e,n,r){let i=t.r(e,n,{internalRowId:r}),a=this.bucketKeys.get(i);if(a){for(let e of[...a])this.store.delete(e);this.bucketKeys.delete(i),this.removeBucketFromAccessOrder(i)}}clearAll(){this.store.clear(),this.bucketKeys.clear(),this.bucketAccessOrder.length=0}removeByRowIds(e,n){let r=new Set;for(let n of e)r.add(t.i(n));for(let e of n?.internalRowIds??[])r.add(t.i(null,e));if(r.size!==0)for(let e of[...this.bucketKeys.keys()]){let t=e.slice(0,e.indexOf(`::`));r.has(t)&&this.clearCellByBucketKey(e)}}promoteRowId(e,n){let r=t.i(null,e),i=String(n),a=`${r}::`,o=[];for(let[e,t]of this.store)e.startsWith(a)&&o.push([e,t]);if(o.length!==0)for(let[e,r]of o){let o=e.slice(a.length),s=`${i}::${o}`,c=o.slice(0,o.indexOf(`::`));this.store.delete(e),this.removeStorageKeyFromBucket(e);let l=t.r(n,c);this.bucketKeys.has(l)||this.bucketKeys.set(l,new Set),this.bucketKeys.get(l).add(s),this.store.set(s,r),this.touchBucket(n,c)}}get size(){return this.store.size}get bucketCount(){return this.bucketKeys.size}deleteStorageKey(e){this.store.delete(e),this.removeStorageKeyFromBucket(e)}removeStorageKeyFromBucket(e){for(let[t,n]of this.bucketKeys)if(n.has(e)){n.delete(e),n.size===0&&(this.bucketKeys.delete(t),this.removeBucketFromAccessOrder(t));return}}clearCellByBucketKey(e){let t=this.bucketKeys.get(e);if(t){for(let e of t)this.store.delete(e);this.bucketKeys.delete(e),this.removeBucketFromAccessOrder(e)}}touchBucket(e,n,r){let i=t.r(e,n,{internalRowId:r});this.bucketKeys.has(i)&&(this.removeBucketFromAccessOrder(i),this.bucketAccessOrder.push(i))}removeBucketFromAccessOrder(e){let t=this.bucketAccessOrder.indexOf(e);t>=0&&this.bucketAccessOrder.splice(t,1)}evictIfNeeded(){if(this.maxEntries!=null)for(;this.bucketKeys.size>this.maxEntries&&this.bucketAccessOrder.length>0;){let e=this.bucketAccessOrder.shift();e&&this.clearCellByBucketKey(e)}}};function Du(e,n){let r=[],i=[];for(let a of e){if(t.j(a)){i.push(a);continue}let e=t.D(a,n);e===null?i.push(a):r.push(e)}return{businessRowIds:r,transientInternalRowIds:i}}function Ou(e={}){let t=`autoSizeStrategy`in e&&e.autoSizeStrategy!==void 0?e.autoSizeStrategy??null:null;return{skipHeaderOnAutoSize:e.skipHeaderOnAutoSize??!1,autoSizePadding:e.autoSizePadding??16,autoSizeStrategy:t}}function ku(e,t,n){let r=new Set(n);return r.size<=1||!r.has(t)?[t]:e.filter(e=>r.has(e.id)).map(e=>e.id)}function Au(e,t){if(t.length===0)return``;let n=new Set(t);for(let t of e)if(n.has(t.id))return t.id;return t[0]}function ju(e,t,n,r){let i=t.indexOf(n);if(i<0)return Math.max(0,Math.min(r,e-1));let a=r-i,o=Math.max(0,e-t.length);return Math.max(0,Math.min(a,o))}function Mu(e,n){let r=t.m(e),i=n.resolveRowById(r);if(i)return i;for(let e of n.displayRows){if(e.isTransient)continue;let i=e.data[n.rowKey];if(i!=null&&t.m(i)===r)return e}}function Nu(e,t){let n=Mu(e,t);if(!n)return null;let r=t.displayRows.findIndex(e=>e.id===n.id);return r>=0?r:null}function Pu(e,t){return Ru(e,t.sourceRows,t.rowKey)}function Fu(e,t,n){let r=Pu(e,t);if(r==null)return null;let i=t.sourceRows[r],a=i.leafGroupPathKey;if(!a)return null;let o=n.type===`display`&&n.hasSortOrFilter;return n.type===`display`&&Nu(e,t)==null?null:o?Lu(i.id,a,t):Iu(i.id,a,t)}function Iu(e,t,n){let r=0;for(let i of n.sourceRows)if(i.leafGroupPathKey===t){if(i.id===e)return r;r+=1}return null}function Lu(e,t,n){let r=0;for(let i of n.displayRows)if(R(i)&&n.sourceRows.find(e=>e.id===i.id)?.leafGroupPathKey===t){if(i.id===e)return r;r+=1}return null}function Ru(e,n,r){let i=t.m(e),a=n.findIndex(e=>e.id===i);if(a>=0)return a;for(let e=0;e<n.length;e+=1){let a=n[e];if(a.isTransient)continue;let o=a.data[r];if(o!=null&&t.m(o)===i)return e}return null}function zu(e,n){let[r]=t.v([e.id],{rowKey:n.rowKey,getRowById:n.resolveRowById});return r}function Bu(e,t){let n=Mu(e,t);if(!n)return null;let r=t.displayRows.findIndex(e=>e.id===n.id);if(r<0)return null;let i=zu(n,t);return i?{anchorSnapshot:i,startIndex:r}:null}function Vu(e,t,n){if(!e)return`continue`;let r=!1,i=`stop`;return e({currentRow:t,row:n,next:(e=!0)=>{r||(r=!0,i=e===!1?`stop`:`continue`)}}),i}function Hu(e,t,n,r){let i=n===`prev`?-1:1;for(let n=t.startIndex+i;n>=0&&n<e.displayRows.length;n+=i){let t=e.displayRows[n],i=zu(t,e);if(i&&r(i)===!1)break}}function Uu(e,t,n){let r=Bu(e,n);if(!r)return[];let i=t.length??1,a=t.includeStop??!1,o=[];return Hu(n,r,t.direction,e=>Vu(t.iterator,e,r.anchorSnapshot)===`continue`?(o.push(e),i>=0&&o.length>=i?!1:void 0):(a&&o.push(e),!1)),o}function Wu(e,t,n){let r=Bu(e,n);if(!r)return null;let i=null;return Hu(n,r,t.direction,e=>{if(Vu(t.iterator,e,r.anchorSnapshot)===`stop`)return i=e,!1}),i}function Gu(e,t){return!Number.isInteger(e)||e<0||e>=t.displayRows.length?null:zu(t.displayRows[e],t)??null}function Ku(e,t){return Gu(e,t)}function qu(e,t){let n=[];for(let r of e){let e=Gu(r,t);e&&n.push(e)}return n}function Ju(e,t){if(t==null)return qu(e.displayRows.map((e,t)=>t),e);let n=[];for(let r=0;r<e.displayRows.length;r+=1){let i=Gu(r,e);i!=null&&t(i)&&n.push(i)}return n}function Yu(e,n){return Ju(e,n).map(t.b)}function Xu(e){return{sourceRows:e.sourceRows,displayRows:e.displayRows,hasSortOrFilter:e.sortModelLength>0||e.filterModelKeyCount>0}}function Zu(e,t,n){if(e===void 0)return;if(t===`source`||!n.hasSortOrFilter)return $l(e,n.sourceRows.length);if(n.displayRows.length===0)return 0;let r=$l(e,n.displayRows.length),i=n.displayRows[r];if(!i)return n.sourceRows.length;let a=n.sourceRows.findIndex(e=>e.id===i.id);return a<0?n.sourceRows.length:a}function Qu(e,t,n){let r=t===`display`||n.hasSortOrFilter?n.displayRows:n.sourceRows,i=[];for(let t of e){if(r.length===0)continue;let e=r[$l(t,r.length)];e&&i.push(e.id)}return i}function $u(e,t){return t<=0?0:Math.max(0,Math.min(e,t-1))}function ed(e,t,n,r){if(t===`display`&&r)return null;if(t===`source`||!n.hasSortOrFilter)return $u(e,n.sourceRows.length);let i=$u(e,n.displayRows.length),a=n.displayRows[i];if(!a)return $u(n.sourceRows.length-1,n.sourceRows.length);let o=n.sourceRows.findIndex(e=>e.id===a.id);return o<0?$u(n.sourceRows.length-1,n.sourceRows.length):o}function td(e,t){let n=null;for(let r of t){let t=e.find(e=>e.id===r);if(!t||Ue(t))return`missing`;let i=t.leafGroupPathKey??null;if(!i)return null;if(n==null){n=i;continue}if(n!==i)return`mixed`}return n}function nd(e,t,n,r){let i=0,a=Math.max(0,Math.min(t,e.length));for(let t=0;t<a;t+=1){let a=e[t];R(a)&&a.leafGroupPathKey===n&&!r.has(a.id)&&(i+=1)}return i}function rd(e,t,n,r){let i=new Set(t),a=0,o=$u(n,e.length);for(let t=0;t<o;t+=1){let n=e[t];n.leafGroupPathKey===r&&!i.has(n.id)&&(a+=1)}if(t.length===1){let n=e.findIndex(e=>e.id===t[0]);n>=0&&n<o&&--a}return Math.max(0,a)}function id(e){let{sourceRows:t,rowIds:n,groupPath:r,withinGroupInsertIndex:i}=e,a=new Set(n);if(td(t,n)!==r)return null;let o=[],s=[];for(let e=0;e<t.length;e+=1){let n=t[e];n.leafGroupPathKey===r&&(o.push(e),s.push(n))}let c=s.filter(e=>a.has(e.id));if(c.length!==n.length)return null;let l=s.filter(e=>!a.has(e.id)),u=Math.max(0,Math.min(i,l.length)),d=[...l.slice(0,u),...c,...l.slice(u)];if(d.every((e,t)=>e.id===s[t].id))return null;let f=[...t];for(let e=0;e<o.length;e+=1)f[o[e]]=d[e];let p=[];for(let e of c){let n=t.findIndex(t=>t.id===e.id),r=f.findIndex(t=>t.id===e.id);n>=0&&r>=0&&n!==r&&p.push({rowId:e.id,fromIndex:n,toIndex:r})}return p.length===0?null:{rows:f,moves:p}}function ad(e){let{sourceRows:t,displayRows:n,rowIds:r,displayInsertIndex:i,groupPath:a}=e,o=new Set(r);return sd(n,e=>t.find(t=>t.id===e),r,i,a)?id({sourceRows:t,rowIds:r,groupPath:a,withinGroupInsertIndex:nd(n,i,a,o)}):null}function od(e,t,n,r){let i=new Set(t),a=e.filter(e=>e.leafGroupPathKey===r).length,o=rd(e,t,n,r),s=a-i.size;return o>=0&&o<=s}function sd(e,t,n,r,i){let a=[];for(let n=0;n<e.length;n+=1){let r=e[n];R(r)&&(t(r.id)??r).leafGroupPathKey===i&&a.push(n)}if(a.length===0)return!1;let o=Math.min(...a),s=Math.max(...a)+1;return r>=o&&r<=s}function cd(e){if(!e.active)return{allowed:!0};let t=td(e.sourceRows,e.rowIds);return t===null?{allowed:!0}:t===`missing`?{allowed:!1,reason:`cannot move non-leaf rows while row grouping is active`}:t===`mixed`?{allowed:!1,reason:`selected rows must belong to the same group`}:od(e.sourceRows,e.rowIds,e.targetSourceIndex,t)?{allowed:!0}:{allowed:!1,reason:`cannot move rows across groups`}}function ld(e,t,n){return{rowId:e,fromIndex:t,toIndex:n}}function ud(e,t,n){let r=K(e,t);if(!(!r&&n===void 0))return{...n===void 0?{}:{displayIndex:n},...r??{}}}function dd(e,t){let n=null;for(let r of t){let t=e.find(e=>e.id===r);if(!t||!B(t))return`missing`;let i=t.parentRowId??null;if(n==null){n=i;continue}if(n!==i)return`mixed`}return n}function fd(e,t,n,r){let i=0,a=Math.max(0,Math.min(t,e.length));for(let t=0;t<a;t+=1){let a=e[t];B(a)&&(a.parentRowId??null)===n&&!r.has(a.id)&&(i+=1)}return i}function K(e,t){let n=e.findIndex(e=>e.id===t);if(n<0)return null;let r=e[n];if(!B(r))return null;let i=r.parentRowId??null,a=0;for(let t=0;t<n;t+=1)(e[t].parentRowId??null)===i&&(a+=1);return{parentRowId:i,siblingIndex:a,treeLevel:r.treeLevel??Math.max(0,(r.dataPath?.length??1)-1)}}function pd(e,t,n,r){let i=new Set(t),a=0,o=$u(n,e.length);for(let t=0;t<o;t+=1){let n=e[t];B(n)&&(n.parentRowId??null)===r&&!i.has(n.id)&&(a+=1)}return a}function md(e){if(!e.active)return{allowed:!0};let t=dd(e.sourceRows,e.rowIds);return t===`mixed`?{allowed:!1,reason:`selected rows must belong to the same tree parent`}:t===`missing`?{allowed:!1,reason:`cannot move non-tree rows while tree mode is active`}:t!=null&&!hd(e.sourceRows,e.rowIds,e.targetSourceIndex,t)?{allowed:!1,reason:`tree drag target must stay within the same parent siblings`}:{allowed:!0,parentRowId:t}}function hd(e,t,n,r){let i=new Set(t),a=e.filter(e=>B(e)&&(e.parentRowId??null)===r).length,o=pd(e,t,n,r),s=a-i.size;return o>=0&&o<=s}function gd(e,t,n,r,i){for(let e of n){let n=t(e);if(!n||!B(n)||(n.parentRowId??null)!==i)return!1}let a=[];for(let t=0;t<e.length;t+=1){let n=e[t];B(n)&&(n.parentRowId??null)===i&&a.push(t)}if(a.length===0)return!1;let o=Math.min(...a),s=Math.max(...a)+1,c=Math.max(0,Math.min(r,e.length));return c>=o&&c<=s}function _d(e){let t=new Set(e.rowIds),n=[],r=[];for(let t=0;t<e.sourceRows.length;t+=1){let i=e.sourceRows[t];!B(i)||(i.parentRowId??null)!==e.parentRowId||(n.push(t),r.push(i))}let i=e.rowIds.map(e=>r.find(t=>t.id===e)).filter(e=>e!=null);if(i.length!==e.rowIds.length)return null;let a=r.filter(e=>!t.has(e.id)),o=Math.max(0,Math.min(e.withinSiblingInsertIndex,a.length)),s=[...a.slice(0,o),...i,...a.slice(o)];if(s.every((e,t)=>e.id===r[t].id))return null;let c=[...e.sourceRows];for(let e=0;e<n.length;e+=1)c[n[e]]=s[e];let l=[];for(let t of i){let n=e.sourceRows.findIndex(e=>e.id===t.id),r=c.findIndex(e=>e.id===t.id);n>=0&&r>=0&&n!==r&&l.push(ld(t.id,n,r))}return l.length===0?null:{rows:c,moves:l}}function vd(e){let t=new Set(e.rowIds);if(!gd(e.displayRows,t=>e.sourceRows.find(e=>e.id===t),e.rowIds,e.displayInsertIndex,e.parentRowId))return null;let n=fd(e.displayRows,e.displayInsertIndex,e.parentRowId,t);return _d({sourceRows:e.sourceRows,rowIds:e.rowIds,withinSiblingInsertIndex:n,parentRowId:e.parentRowId})}function yd(e,t,n){return n===`up`?t>0?{indexMode:`source`,toIndex:t-1}:null:t<e.length-1?{indexMode:`source`,toIndex:t+1}:null}function bd(e,t,n,r){let i=[];for(let t=0;t<e.length;t+=1)r(e[t])&&i.push(t);let a=i.findIndex(n=>e[n].id===t);return a<0?null:n===`up`?a===0?null:{indexMode:`source`,toIndex:i[a-1]}:a===i.length-1?null:{indexMode:`source`,toIndex:i[a+1]}}function xd(e,t,n,r){let i=e.findIndex(e=>e.id===t);if(i<0)return null;let a=n===`up`?-1:1;for(let t=i+a;t>=0&&t<e.length;t+=a){let n=e[t];if(r(n))return{indexMode:`display`,toIndex:t}}return null}function Sd(e,t,n){let r=t.map(t=>e.findIndex(e=>e.id===t));if(r.some(e=>e<0))return null;let i=Math.min(...r),a=Math.max(...r);return n===`up`?i>0?{indexMode:`source`,toIndex:i-1}:null:a<e.length-1?{indexMode:`source`,toIndex:i+1}:null}function Cd(e,t,n){let r=[];for(let t=0;t<e.length;t+=1)n(e[t])&&r.push(t);let i=[];for(let n of t){let t=e.findIndex(e=>e.id===n);if(t<0)return null;let a=r.indexOf(t);if(a<0)return null;i.push(a)}return{siblingIndices:r,positions:i}}function wd(e,t,n,r){let i=Cd(e,t,r);if(!i)return null;let{siblingIndices:a,positions:o}=i,s=Math.min(...o),c=Math.max(...o);return n===`up`?s===0?null:{indexMode:`source`,toIndex:a[s-1]}:c===a.length-1?null:{indexMode:`source`,toIndex:a[c+1]}}function Td(e,t,n,r){let i=Cd(e,t,r);if(!i)return null;let{siblingIndices:a,positions:o}=i,s=Math.min(...o),c=Math.max(...o);return n===`up`?s===0?null:{indexMode:`display`,toIndex:a[s-1]}:c===a.length-1?null:{indexMode:`display`,toIndex:a[c+1]}}function Ed(e){let{sourceRows:t,displayRows:n,rowIds:r,direction:i,isRowGroupingActive:a,isTreeActive:o}=e;if(r.length===0)return null;if(r.length===1)return Dd({sourceRows:t,displayRows:n,rowId:r[0],direction:i,isRowGroupingActive:a,isTreeActive:o});if(a){let e=td(t,r);if(typeof e==`string`)return wd(t,r,i,t=>t.leafGroupPathKey===e);if(e===`missing`)return null}if(o){let e=dd(t,r);if(e===`mixed`||e===`missing`)return null;if(typeof e==`string`||e===null)return Td(n,r,i,t=>B(t)&&(t.parentRowId??null)===e)}return Sd(t,r,i)}function Dd(e){let{sourceRows:t,displayRows:n,rowId:r,direction:i,isRowGroupingActive:a,isTreeActive:o}=e,s=t.findIndex(e=>e.id===r);if(s<0)return null;if(a){let e=td(t,[r]);if(typeof e==`string`)return bd(t,r,i,t=>t.leafGroupPathKey===e);if(e===`missing`)return null}if(o){let e=dd(t,[r]);if(e===`mixed`||e===`missing`)return null;if(typeof e==`string`||e===null)return xd(n,r,i,t=>B(t)&&(t.parentRowId??null)===e)}return yd(t,s,i)}function Od(e,t,n={}){let r=n.type??`source`;return n.group?Fu(e,t,{type:r,hasSortOrFilter:t.hasSortOrFilter??!1}):r===`display`?Nu(e,t):Pu(e,t)}function kd(e,t,n={}){let r={};for(let i of e)r[i]=Od(i,t,n);return r}function Ad(e){return Ve(e)?`GROUP_HEADER`:He(e)?`GROUP_FOOTER`:I(e)?`DETAIL`:go(e)?`LOAD_MORE`:N(e.rowKind)}function jd(e,t){let n=Mu(e,t);return n?Ad(n):null}function Md(e){return typeof e==`function`}function Nd(e,n){let r=t.M(e,n);return e.map((e,i)=>{let a=e.data[n],o=e.isTransient||t.A(a)?null:a;return{data:r[i],internalRowId:e.id,businessRowId:o}})}function Pd(e,n,r){return{rows:t.M(e,n),rowKey:n,api:r,targets:Nd(e,n)}}function Fd(e,t){return[...Md(e)?e(t):e]}var Id=class{requestFrame;cancelFrame;now;frameBudgetMs;rendererFrameBudgetMs;scrollActive=!1;p1=[];p2=[];f1=[];destroyTasks=[];scrollGridIfNeeded=null;scrollGoingDown=!0;ticking=!1;rafId=null;createOrderSeed=0;constructor(e={}){this.requestFrame=e.requestFrame??(e=>requestAnimationFrame(e)),this.cancelFrame=e.cancelFrame??(e=>cancelAnimationFrame(e)),this.now=e.now??(()=>performance.now()),this.frameBudgetMs=Math.max(1,e.frameBudgetMs??60),this.rendererFrameBudgetMs=Math.max(0,e.rendererFrameBudgetMs??20)}setRendererFrameBudgetMs(e){this.rendererFrameBudgetMs=Math.max(0,e)}getRendererFrameBudgetMs(){return this.rendererFrameBudgetMs}setScrollActive(e){this.scrollActive=e}isScrollActive(){return this.scrollActive}setFrameBudgetMs(e){this.frameBudgetMs=Math.max(1,e)}getFrameBudgetMs(){return this.frameBudgetMs}setScrollGridIfNeeded(e){this.scrollGridIfNeeded=e}setScrollDirection(e){this.scrollGoingDown=e}schedule(){this.ticking||(this.ticking=!0,this.rafId=this.requestFrame(()=>{this.ticking=!1,this.rafId=null,this.executeFrame(this.frameBudgetMs)}))}createTask(e,t,n){this.getTaskList(n).push({task:e,index:t,createOrder:this.createOrderSeed++,deferred:!1}),this.schedule()}addDestroyTask(e){this.destroyTasks.push(e),this.schedule()}flushAllFrames(e){this.rafId!=null&&(this.cancelFrame(this.rafId),this.rafId=null,this.ticking=!1);let t=e??-1,n=!0;for(;n||this.hasPendingWork();)n=!1,this.executeFrame(t)}destroy(){this.rafId!=null&&(this.cancelFrame(this.rafId),this.rafId=null),this.ticking=!1,this.p1=[],this.p2=[],this.f1=[],this.destroyTasks=[]}getPendingTaskCount(){return this.p1.length+this.p2.length+this.f1.length+this.destroyTasks.length}getPendingRendererTaskCount(){return this.f1.length}executeFrame(e){let t=this.now(),n=e<0,r=!n&&this.scrollActive&&this.rendererFrameBudgetMs>0&&this.f1.length>0,i=r?Math.max(0,e-this.rendererFrameBudgetMs):e,a=r?this.rendererFrameBudgetMs:e;for(this.runTaskPhase({start:t,budgetMs:i,unlimited:n,queues:r?[`p1`,`p2`]:[`p1`,`p2`,`f1`]}),r&&this.runTaskPhase({start:this.now(),budgetMs:a,unlimited:!1,queues:[`f1`]});n||this.now()-t<e;){let e=this.destroyTasks.shift();if(!e)break;e()}this.hasPendingWork()&&this.schedule()}runTaskPhase(e){for(;e.unlimited||this.now()-e.start<e.budgetMs;){if(this.scrollGridIfNeeded?.())continue;let t=this.popNextTask(e.queues);if(!t)break;t.task()}}hasPendingWork(){return this.p1.length>0||this.p2.length>0||this.f1.length>0||this.destroyTasks.length>0}popNextTask(e=[`p1`,`p2`,`f1`]){for(let t of e){let e=this.getTaskList(t);if(e.length!==0)return this.sortTaskList(e),e.shift()}}sortTaskList(e){e.sort((e,t)=>e.index===t.index?e.createOrder-t.createOrder:this.scrollGoingDown?e.index-t.index:t.index-e.index)}getTaskList(e){switch(e){case`p1`:return this.p1;case`p2`:return this.p2;case`f1`:return this.f1}}},Ld=class{depth=0;beginDeferred(){this.depth++}endDeferred(e){this.depth<=0||(this.depth--,this.depth===0&&e())}isDeferred(){return this.depth>0}reset(){this.depth=0}};function Rd(e){return{setData:t=>e.setData(t),applyTransaction:t=>e.applyTransaction(t),addRows:t=>e.addRows(t),addRowsByArray:(t,n)=>e.addRowsByArray(t,n),addGroupRows:t=>e.addGroupRows(t),addGroupRowsByArray:(t,n)=>e.addGroupRowsByArray(t,n),removeRows:t=>e.removeRows(t),updateRows:t=>e.updateRows(t),patchRow:t=>e.patchRow(t),removeSelectedRows:t=>e.removeSelectedRows(t),getData:t=>e.getData(t),promoteRowId:t=>e.promoteRowId(t),moveRow:(t,n,r)=>e.moveRow(t,n,r),moveRows:t=>e.moveRows(t),moveUp:t=>e.moveUp(t),moveDown:t=>e.moveDown(t),moveUps:t=>e.moveUps(t),moveDowns:t=>e.moveDowns(t),setSortModel:t=>e.setSortModel(t),getSortModel:()=>e.getSortModel(),setFilterModel:t=>e.setFilterModel(t),getFilterModel:()=>e.getFilterModel(),refreshInfiniteCache:()=>e.refreshInfiniteCache(),setInfiniteDatasource:t=>e.setInfiniteDatasource(t),retryInfiniteBlock:t=>e.retryInfiniteBlock(t),getLoadedRowData:()=>e.getLoadedRowData(),getInfiniteRowCount:()=>e.getInfiniteRowCount(),getColumnFilter:t=>e.getColumnFilter(t),isColumnFilterActive:t=>e.isColumnFilterActive(t),isAnyFilterActive:()=>e.isAnyFilterActive(),setQuickFilterText:t=>e.setQuickFilterText(t),getQuickFilterText:()=>e.getQuickFilterText(),clearAllFilters:()=>e.clearAllFilters(),setColumnFilter:(t,n)=>e.setColumnFilter(t,n),refreshCells:t=>e.refreshCells(t),refreshCellSpans:()=>e.refreshCellSpans(),getCellSpan:(t,n)=>e.getCellSpan(t,n),ensureIndexVisible:(t,n)=>e.ensureIndexVisible(t,n),getRowNode:t=>e.getRowNode(t),getSiblingRowsByRowId:(t,n)=>e.getSiblingRowsByRowId(t,n),getSiblingRowByIterator:(t,n)=>e.getSiblingRowByIterator(t,n),getRowKind:t=>e.getRowKind(t),getRowIndex:(t,n)=>e.getRowIndex(t,n),getRowIndexes:(t,n)=>e.getRowIndexes(t,n),getRowByIndex:t=>e.getRowByIndex(t),getRowsByIndexes:t=>e.getRowsByIndexes(t),getRowSnapshots:t=>e.getRowSnapshots(t),getRowIds:t=>e.getRowIds(t),getMetrics:()=>e.getMetrics(),getPendingFrameTaskCount:()=>e.getPendingFrameTaskCount(),getPendingRendererTaskCount:()=>e.getPendingRendererTaskCount(),beginUpdate:()=>e.beginUpdate(),endUpdate:()=>e.endUpdate(),scrollTo:(t,n)=>e.scrollTo(t,n),moveColumn:(t,n)=>e.moveColumn(t,n),resetColumnOrder:()=>e.resetColumnOrder(),resetColumnWidths:()=>e.resetColumnWidths(),setColumnFixed:(t,n)=>e.setColumnFixed(t,n),setColumnsHidden:(t,n)=>e.setColumnsHidden(t,n),isColumnHidden:t=>e.isColumnHidden(t),getDisplayedColumnIds:()=>e.getDisplayedColumnIds(),getColumns:()=>e.getColumns(),getDisplayedColumns:()=>e.getDisplayedColumns(),getColumnDistinctFilterValues:t=>e.getColumnDistinctFilterValues(t),setColumnWidths:(t,n,r)=>e.setColumnWidths(t,n,r),setColumnWidth:(t,n,r,i)=>e.setColumnWidth(t,n,r,i),getColumnWidth:t=>e.getColumnWidth(t),autoSizeColumn:(t,n)=>e.autoSizeColumn(t,n),autoSizeColumns:(t,n)=>e.autoSizeColumns(t,n),sizeColumnsToFit:t=>e.sizeColumnsToFit(t),setRowHeight:(t,n,r)=>e.setRowHeight(t,n,r),setRowHeights:(t,n)=>e.setRowHeights(t,n),getRowHeight:t=>e.getRowHeight(t),resetRowHeights:t=>e.resetRowHeights(t),updateDimensions:t=>e.updateDimensions(t),expandRow:t=>e.expandRow(t),collapseRow:t=>e.collapseRow(t),isRowExpanded:t=>e.isRowExpanded(t),setDetailRowData:(t,n)=>e.setDetailRowData(t,n),reloadDetailRowData:t=>e.reloadDetailRowData(t),expandAll:()=>e.expandAll(),collapseAll:()=>e.collapseAll(),setRowGroupColumns:t=>e.setRowGroupColumns(t),getRowGroupColumns:()=>e.getRowGroupColumns(),expandGroup:t=>e.expandGroup(t),collapseGroup:t=>e.collapseGroup(t),isGroupExpanded:t=>e.isGroupExpanded(t),expandNode:t=>e.expandNode(t),collapseNode:t=>e.collapseNode(t),isNodeExpanded:t=>e.isNodeExpanded(t),getDataPath:t=>e.getDataPath(t),getCellComment:(t,n)=>e.getCellComment(t,n),setCellComment:(t,n,r)=>e.setCellComment(t,n,r),refreshCellComments:t=>e.refreshCellComments(t),getCellRanges:()=>e.getCellRanges(),getCellSelectionAggregation:()=>e.getCellSelectionAggregation(),clearCellSelection:()=>e.clearCellSelection(),addCellRange:t=>e.addCellRange(t),copySelectedRangeToClipboard:()=>e.copySelectedRangeToClipboard(),pasteFromClipboard:()=>e.pasteFromClipboard(),showLoadingOverlay:()=>e.showLoadingOverlay(),showNoRowsOverlay:()=>e.showNoRowsOverlay(),hideOverlay:()=>e.hideOverlay(),isOverlayShowing:()=>e.isOverlayShowing(),getOverlayType:()=>e.getOverlayType(),refreshDisabledState:t=>e.refreshDisabledState(t),setRowStyle:t=>e.setRowStyle(t),setEditableCellStyle:t=>e.setEditableCellStyle(t),setShowEditableCellIcon:t=>e.setShowEditableCellIcon(t),setDisabledCellStyle:t=>e.setDisabledCellStyle(t),setShowDisabledCellIcon:t=>e.setShowDisabledCellIcon(t),setCellStyle:(t,n,r)=>e.setCellStyle(t,n,r),getCellStyle:(t,n)=>e.getCellStyle(t,n),getCellStyleOverride:(t,n)=>e.getCellStyleOverride(t,n),clearCellStyles:t=>e.clearCellStyles(t),refreshCellStyles:t=>e.refreshCellStyles(t),startEditingCell:t=>e.startEditingCell(t),stopEditing:t=>e.stopEditing(t),commit:t=>e.commit(t),isEditing:()=>e.isEditing(),isCommitting:()=>e.isCommitting(),awaitCommitIdle:()=>e.awaitCommitIdle(),cancelCommit:()=>e.cancelCommit(),getEditSessionPhase:()=>e.getEditSessionPhase(),getEditingCell:()=>e.getEditingCell(),getEditingCells:()=>e.getEditingCells(),registerCellEditor:(t,n)=>e.registerCellEditor(t,n),unregisterCellEditor:t=>e.unregisterCellEditor(t),getCellEditorCache:(t,n,r)=>e.getCellEditorCache(t,n,r),setCellEditorCache:(t,n,r,i)=>e.setCellEditorCache(t,n,r,i),clearCellEditorCache:(t,n,r)=>e.clearCellEditorCache(t,n,r),clearAllCellEditorCache:()=>e.clearAllCellEditorCache(),validate:t=>e.validate(t),validateRows:t=>e.validateRows(t),validateCells:t=>e.validateCells(t),clearValidation:t=>e.clearValidation(t),clearRowValidation:t=>e.clearRowValidation(t),clearCellValidation:t=>e.clearCellValidation(t),toggleRowSelection:(t,n,r)=>e.toggleRowSelection(t,n,r),toggleAllSelection:t=>e.toggleAllSelection(t),clearRowSelection:t=>e.clearRowSelection(t),setDefaultSelectedRows:(t,n)=>e.setDefaultSelectedRows(t,n),clearPendingDefaultSelectedRows:()=>e.clearPendingDefaultSelectedRows(),reconcileDefaultSelectedRows:()=>e.reconcileDefaultSelectedRows(),getSelectedRowIds:()=>e.getSelectedRowIds(),getSelectedRows:()=>e.getSelectedRows(),getIndexFocusedRowIds:t=>e.getIndexFocusedRowIds(t),getIndexFocusedRows:t=>e.getIndexFocusedRows(t),setIndexFocus:(t,n)=>e.setIndexFocus(t,n),destroy:()=>e.destroy(),on:(t,n)=>e.on(t,n)}}var zd=[`.mg-cell-editor-host`],Bd=[];function Vd(e){Bd.push(...e)}function Hd(){Bd.length=0}function Ud(e){return e instanceof Element?e:e instanceof Text?e.parentElement:null}function Wd(){return[...zd,...Bd]}function Gd(e){let t=Ud(e);return t?Wd().some(e=>t.closest(e)!=null):!1}function Kd(e=document.activeElement){return Gd(e)}var qd=[`mg-cell-editor-host--align-h-left`,`mg-cell-editor-host--align-h-center`,`mg-cell-editor-host--align-h-right`];function Jd(e,t){for(let t of qd)e.classList.remove(t);e.classList.add(`mg-cell-editor-host--align-h-${t}`)}function Yd(e,n,r){Jd(e,t.d(n,r))}var Xd=`mg-inline-checkbox`,Zd=`mg-inline-switch`,Qd=`mg-switch-editor`,$d=[Xd,Zd];function ef(e,t){let n=document.createElement(`input`);return n.className=`mg-cell-editor`,n.type=e,n.value=t,n.style.width=`100%`,n.style.height=`100%`,n.style.boxSizing=`border-box`,n}function tf(e,t){let n=document.createElement(`input`);return n.type=`checkbox`,n.className=t.inline?[`mg-cell-editor`,t.inlineClass,t.extraClasses].filter(Boolean).join(` `):[`mg-cell-editor`,t.extraClasses].filter(Boolean).join(` `),n.checked=t.checked,t.role&&n.setAttribute(`role`,t.role),t.params.setGetValue?.(()=>t.readValue(n)),t.inline&&(n.addEventListener(`click`,e=>{e.stopPropagation()}),n.addEventListener(`change`,()=>{t.params.commit?.()})),e.mountEl.appendChild(n),n}var nf=(e,t)=>{let n=ef(`text`,e.formattedValue);return t.mountEl.appendChild(n),n},rf=(e,t)=>{let n=ef(`number`,e.value==null||e.value===``?``:String(e.value));return t.mountEl.appendChild(n),n},af=(e,t)=>{let n=Lt(e.cellEditorParams)??null;return tf(t,{inline:e.inline===!0,inlineClass:Xd,checked:tn(e.value,n),readValue:e=>rn(e,n),params:e})},of=(e,t)=>{let n=Rt(e.cellEditorParams)??null;return tf(t,{inline:e.inline===!0,inlineClass:Zd,extraClasses:Qd,role:`switch`,checked:Jt(e.value,n),readValue:e=>Zt(e,n),params:e})};function sf(e){return e===`checkbox`||e===`switch`}function cf(e){return e instanceof Element&&$d.some(t=>e.closest(`input.${t}`))}function lf(e,t){return e instanceof HTMLInputElement&&e.type===`checkbox`?Zt(e,on(t??{})):e.value}var uf=new Map;function df(e,t){if(!e||wn(e))throw Error(`Invalid cell editor name "${e}"`);uf.set(e,t)}function ff(e){return uf.delete(e)}function pf(e){return uf.get(e)}function mf(e){return uf.has(e)}function hf(){return[...uf.keys()]}function gf(e,t={}){return t[e]??uf.get(e)}function _f(e,t={}){return e===void 0?nf:typeof e==`function`?e:wn(e)?e===`number`?rf:e===`checkbox`?af:e===`switch`?of:nf:gf(e,t.byName)||(console.warn(`[magic-grid] Cell editor "${e}" is not registered; falling back to text editor.`),nf)}var vf=class{onUnmountEditor;instanceEditors;editorOptions;constructor(e={}){this.onUnmountEditor=e.onUnmountEditor,this.instanceEditors={...e.byName??{}},this.editorOptions=e.editorOptions??t.f()}register(e,t){if(!e||wn(e))throw Error(`Invalid cell editor name "${e}"`);this.instanceEditors[e]=t}unregister(e){return delete this.instanceEditors[e]}has(e){return e in this.instanceEditors||gf(e,this.instanceEditors)!==void 0}mount(e,t,n,r){let i=e.querySelector(`.mg-cell[data-col-id="${t.colId}"]`),a=i??e,o=document.createElement(`div`);o.className=`mg-cell-editor-host`,Yd(o,t.align,this.editorOptions),o.style.position=`absolute`,o.style.top=`0`,o.style.boxSizing=`border-box`,i?(o.style.left=`0`,o.style.width=`100%`,o.style.height=`100%`,i.classList.add(`mg-cell--editing`)):(o.style.left=`${t.left}px`,o.style.width=`${t.width}px`,o.style.height=`100%`),a.appendChild(o);let s=null,c={mountEl:o,clear:()=>{this.onUnmountEditor?.(o),o.replaceChildren()}},l={...Ht(t,n),setGetValue:e=>{s=e}},u=_f(r,{byName:this.instanceEditors})(l,c);return u instanceof HTMLElement&&!o.contains(u)&&o.appendChild(u),{mountEl:o,getValue:()=>{if(s)return s();let e=o.querySelector(`input:not([type="hidden"]).mg-cell-editor, select.mg-cell-editor, textarea.mg-cell-editor`);if(e)return lf(e,t);let r=o.querySelector(`input:not([type="hidden"]), select, textarea`);return r?lf(r,t):n.formattedValue},getFocusTarget:()=>u instanceof HTMLElement?u:o.querySelector(`input:not([type="hidden"]), select, textarea, [tabindex]`)??o.firstElementChild,destroy:()=>{o.parentElement?.classList.remove(`mg-cell--editing`),c.clear(),o.remove()}}}},yf=class{editing=null;mountedEditor=null;listenerTarget=null;onCommit=null;onCancel=null;onEditingStopped=null;onTab=null;onEditingInput=null;onCommitLifecycle=null;oldValue=void 0;blurCommitAfterClickListener=null;blurCommitFallbackTimer=null;pinnedRowIds=new Set;editorHost;keyboardPolicy={};phase=`idle`;commitController=null;inflightCommit=null;nextCommitId=0;handleEditorKeyDown=e=>{if(this.phase===`committing`){e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this.cancelCommit());return}if(e.key===`Enter`){if(this.shouldDeferEnterCommit())return;e.preventDefault(),e.stopPropagation(),this.stopEditing(!0)}else if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),this.stopEditing(!1);else if(e.key===`Tab`){e.preventDefault(),e.stopPropagation();let t=this.onTab,n=e.shiftKey;this.stopEditing(!0).then(e=>{e?.committed&&t?.(n)})}else e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&this.onEditingInput?.()};handleEditorFocusOut=e=>{let t=e,n=this.editing;requestAnimationFrame(()=>{this.isEditing()&&this.editing===n&&this.phase!==`committing`&&(this.isFocusWithinEditorSurface(t)||(this.clearPendingBlurCommit(),this.scheduleBlurCommitAfterClick()))})};constructor(e){this.editorHost=e??new vf}getEditingCell(){return this.editing}isEditing(){return this.editing!==null}isCommitting(){return this.phase===`committing`}getEditSessionPhase(){return this.phase}getEditorValue(){return this.mountedEditor?.getValue()??null}getEditorMountEl(){return this.mountedEditor?.mountEl??null}awaitCommitIdle(){return(this.inflightCommit??Promise.resolve()).then(()=>void 0)}isPinnedRow(e){return this.pinnedRowIds.has(e)}getPinnedRowIds(){return this.pinnedRowIds}cancelCommit(){this.phase===`committing`&&(this.commitController?.abort(),this.finishCommittingVisual(),this.phase=`editing`,this.commitController=null,this.onCommitLifecycle?.onAborted?.())}startEditing(e,t,n,r,i,a){this.stopEditing(!1),this.editing={rowId:t.id,colId:n.colId,rowIndex:t.rowIndex},this.oldValue=i,this.phase=`editing`,this.pinnedRowIds.add(t.id),this.onCommit=a.onCommit,this.onCancel=a.onCancel,this.onEditingStopped=a.onEditingStopped??null,this.onTab=a.onTab??null,this.onEditingInput=a.onEditingInput??null,this.onCommitLifecycle=a.onCommitLifecycle??null;let o={};this.keyboardPolicy=o;let{editorParams:s}=a,c={...s,rowId:t.id,rowIndex:t.rowIndex,colId:n.colId,value:i,data:t.data,formattedValue:r,size:s.size??`default`,stopEditing:(e=!0)=>this.stopEditing(e).then(e=>e?{committed:e.committed}:null),cancelCommit:()=>this.cancelCommit(),getEditPhase:()=>this.phase,validate:s.validate??(async()=>({valid:!0})),setKeyboardPolicy:e=>{Object.assign(o,e),this.keyboardPolicy=o}};this.mountedEditor=this.editorHost.mount(e,n,c,n.cellEditor),this.attachEditorListeners(this.mountedEditor),requestAnimationFrame(()=>{this.mountedEditor&&this.isEditing()&&this.keyboardPolicy.suppressInitialAutoFocus!==!0&&this.focusEditor(this.mountedEditor)})}async stopEditing(e){if(!this.editing||!this.mountedEditor)return null;if(this.phase===`committing`)return e||this.cancelCommit(),this.inflightCommit;if(this.clearPendingBlurCommit(),!e)return this.cancelEditingSession();let t=this.commitEditingSession();this.inflightCommit=t;try{return await t}finally{this.inflightCommit===t&&(this.inflightCommit=null)}}destroy(){this.clearPendingBlurCommit(),this.cancelCommit(),this.mountedEditor&&(this.detachEditorListeners(),this.mountedEditor.destroy()),this.mountedEditor=null,this.editing=null,this.onCommit=null,this.onCancel=null,this.onEditingStopped=null,this.onTab=null,this.onEditingInput=null,this.onCommitLifecycle=null,this.oldValue=void 0,this.keyboardPolicy={},this.phase=`idle`,this.commitController=null,this.inflightCommit=null,this.pinnedRowIds.clear()}async commitEditingSession(){if(!this.editing||!this.mountedEditor)return null;let t=this.editing,n=this.mountedEditor,r=n.getValue(),i=this.onCommit,a=this.oldValue,o=++this.nextCommitId;this.phase=`committing`,this.setCommittingVisual(!0),this.onCommitLifecycle?.onStarted?.();let s=e.s(o,this.commitController);this.commitController=s;let c={ok:!1};try{let e=await i?.(r,s.context);if(s.context.commitId!==o)return null;c=e??{ok:!0}}catch(t){if(e.c(t))c={ok:`aborted`};else throw t}finally{this.commitController===s&&(this.commitController=null),this.finishCommittingVisual()}if(s.context.commitId!==o||this.editing!==t)return null;if(this.onCommitLifecycle?.onFinished?.(c),c.ok===`aborted`)return this.phase=`editing`,this.onCommitLifecycle?.onAborted?.(),null;if(c.ok===!1){if(c.revert){let e=this.onEditingStopped;this.teardownEditorSession(n);let r={committed:!1,oldValue:a,newValue:void 0,rowId:t.rowId,colId:t.colId,rowIndex:t.rowIndex};return e?.(r),r}return this.phase=`editing`,this.focusEditor(n),null}let l=c.newValue===void 0?r:c.newValue;return this.finalizeSuccessfulCommit(t,n,a,l)}cancelEditingSession(){if(!this.editing||!this.mountedEditor)return null;let e=this.editing,t=this.mountedEditor,n=this.onCancel,r=this.onEditingStopped,i=this.oldValue;this.teardownEditorSession(t),n?.();let a={committed:!1,oldValue:i,newValue:void 0,rowId:e.rowId,colId:e.colId,rowIndex:e.rowIndex};return r?.(a),a}finalizeSuccessfulCommit(e,t,n,r){let i=this.onEditingStopped;this.teardownEditorSession(t);let a={committed:!0,oldValue:n,newValue:r,rowId:e.rowId,colId:e.colId,rowIndex:e.rowIndex};return i?.(a),a}teardownEditorSession(e){let t=this.editing;this.detachEditorListeners(),this.mountedEditor=null,this.editing=null,this.onCommit=null,this.onCancel=null,this.onEditingStopped=null,this.onTab=null,this.onEditingInput=null,this.onCommitLifecycle=null,this.oldValue=void 0,this.keyboardPolicy={},this.phase=`idle`,this.commitController=null,t&&this.pinnedRowIds.delete(t.rowId),e.destroy()}setCommittingVisual(e){if(!this.editing||!this.mountedEditor)return;let t=this.mountedEditor.mountEl.parentElement;((t?.classList.contains(`mg-cell`)?t.parentElement:t)?.querySelector(`.mg-cell[data-col-id="${this.editing.colId}"]`))?.classList.toggle(`mg-cell--committing`,e),this.mountedEditor.mountEl.classList.toggle(`mg-cell-editor-host--committing`,e)}finishCommittingVisual(){this.setCommittingVisual(!1)}attachEditorListeners(e){this.listenerTarget=e.mountEl,this.listenerTarget.addEventListener(`keydown`,this.handleEditorKeyDown,!0),this.listenerTarget.addEventListener(`focusout`,this.handleEditorFocusOut)}detachEditorListeners(){this.listenerTarget&&=(this.listenerTarget.removeEventListener(`keydown`,this.handleEditorKeyDown,!0),this.listenerTarget.removeEventListener(`focusout`,this.handleEditorFocusOut),null)}resolveFocusTarget(e){let t=e.getFocusTarget();return t?t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement?t:t.querySelector(`input:not([type="hidden"]), select, textarea`)??t:null}shouldDeferEnterCommit(){return this.keyboardPolicy.deferEnterCommit===!0}isFocusWithinEditorSurface(e){return!!(Kd()||e?.relatedTarget instanceof Node&&Gd(e.relatedTarget))}focusEditor(e){let t=this.resolveFocusTarget(e);t&&t.focus()}scheduleBlurCommitAfterClick(){let e=()=>{this.clearPendingBlurCommit(),!(!this.isEditing()||this.phase===`committing`)&&this.stopEditing(!0).then(e=>{e===null&&this.isEditing()&&this.mountedEditor&&this.focusEditor(this.mountedEditor)})};this.blurCommitAfterClickListener=t=>{Gd(t.target)||e()},window.addEventListener(`click`,this.blurCommitAfterClickListener,!1),this.blurCommitFallbackTimer=window.setTimeout(()=>{e()},300)}clearPendingBlurCommit(){this.blurCommitAfterClickListener&&=(window.removeEventListener(`click`,this.blurCommitAfterClickListener,!1),null),this.blurCommitFallbackTimer!==null&&(clearTimeout(this.blurCommitFallbackTimer),this.blurCommitFallbackTimer=null)}};function bf(e){return[...e.getLeftFixedColumnIndices(),...e.getCenterColumnIndices(),...e.getRightFixedColumnIndices()]}function xf(e,t){let n=t.indexOf(e);return n>=0?n:0}function Sf(e,t){return t[e]}function Cf(e){return e[0]??0}function wf(e){return e[e.length-1]??0}var Tf=`__header__`,Ef=`__footer__`;function Df(e){return e.rowIndex===-1}function Of(e){return e.rowIndex===-2}function q(e){return Df(e)||Of(e)}function kf(e={}){return{headerEnabled:e.headerEnabled??!1,footerEnabled:e.footerEnabled??!1}}function Af(e,t){return e===-1?Tf:e===-2?Ef:t(e)}var jf=class{focus=null;getFocusedCell(){return this.focus}setFocusedCell(e){this.focus=e}clear(){this.focus=null}move(e,t,n,r,i,a={}){let o=this.focus??Lf(t,n,r,i);if(!o)return null;let s=Mf(o,e,t,n,r,i,a);return this.focus=s,s}moveTab(e,t,n,r,i,a={}){let o=this.focus??Lf(t,n,r,i);if(!o)return null;let s=Nf(o,e,t,n,r,i,a);return this.focus=s,s}moveToEdge(e,t,n,r,i,a={}){let o=this.focus??Lf(t,n,r,i);if(!o)return null;let s=Pf(o,e,t,n,r,i,a);return this.focus=s,s}};function Mf(e,t,n,r,i,a,o={}){let{headerEnabled:s,footerEnabled:c}=kf(o),l=r.length;if(n<=0||l<=0)return null;let u=e.rowIndex,d=xf(e.colIndex,r);t===`up`?u===-2?u=n-1:u===-1||(u===0?s&&(u=-1):--u):t===`down`?u=s&&u===-1?0:c&&u===n-1?-2:Math.min(n-1,u+1):t===`left`?d=Math.max(0,d-1):t===`right`&&(d=Math.min(l-1,d+1));let f=Sf(d,r),p=Af(u,i),m=f===void 0?void 0:a(f);return f===void 0||!p||!m||u===e.rowIndex&&f===e.colIndex?e:{rowId:p,colId:m,rowIndex:u,colIndex:f}}function Nf(e,t,n,r,i,a,o={}){let{headerEnabled:s,footerEnabled:c}=kf(o),l=r.length;if(n<=0||l<=0)return null;let u=e.rowIndex,d=xf(e.colIndex,r);t?c&&u===-2&&d===0?(u=n-1,d=l-1):u===-2&&d>0?--d:s&&u===0&&d===0?(u=-1,d=l-1):s&&u===-1?d>0&&--d:d>0?--d:u>0&&(--u,d=l-1):s&&u===-1?d<l-1?d+=1:(u=0,d=0):u===-2?d<l-1&&(d+=1):d<l-1?d+=1:u<n-1?(u+=1,d=0):c&&u===n-1&&(u=-2,d=0);let f=Sf(d,r),p=Af(u,i),m=f===void 0?void 0:a(f);return f===void 0||!p||!m||u===e.rowIndex&&f===e.colIndex?e:{rowId:p,colId:m,rowIndex:u,colIndex:f}}function Pf(e,t,n,r,i,a,o={}){let{headerEnabled:s,footerEnabled:c}=kf(o),l=r.length;if(n<=0||l<=0)return null;let u=e.rowIndex,d=e.colIndex;t===`up`?u=s?-1:0:t===`down`?u=c?-2:n-1:t===`left`?d=Cf(r):t===`right`&&(d=wf(r));let f=Af(u,i),p=a(d);return!f||!p||u===e.rowIndex&&d===e.colIndex?e:{rowId:f,colId:p,rowIndex:u,colIndex:d}}function Ff(e,t,n,r,i,a,o,s={}){let c=r.length;if(n<=0||c<=0)return null;let l=e,u=n*c;for(let e=0;e<u;e++){let e=Nf(l,t,n,r,i,a,s);if(!e||e.rowIndex===l.rowIndex&&e.colIndex===l.colIndex)return null;if(l=e,e.rowIndex!==-1&&e.rowIndex!==-2&&o(e.rowIndex,e.colId))return e}return null}function If(e,t,n){if(t.length===0)return null;if(t.length===1)return t[0]??null;let r=t.indexOf(e),i=r>=0?r:0;return t[n?(i-1+t.length)%t.length:(i+1)%t.length]??null}function Lf(e,t,n,r){let i=Cf(t),a=n(0),o=r(i);return!a||!o||e<=0||t.length===0?null:{rowId:a,colId:o,rowIndex:0,colIndex:i}}var Rf=class{editing=null;onCommitRow=null;onFocusColChange=null;activeColId=null;onCancel=null;onRowEditingStopped=null;onCommitLifecycle=null;blurCommitAfterClickListener=null;blurCommitFallbackTimer=null;attachedListeners=[];pinnedRowIds=new Set;editorHost;phase=`idle`;commitController=null;inflightCommit=null;nextCommitId=0;handleEditorKeyDown=e=>{if(this.phase===`committing`){e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this.cancelCommit());return}if(e.key===`Tab`){e.preventDefault(),e.stopPropagation(),this.navigateRowTab(e.shiftKey,this.resolveColIdFromEvent(e));return}if(e.key===`Enter`){let t=this.resolveColIdFromEvent(e);if((t?this.editing?.cells.get(t):void 0)?.keyboardPolicy.deferEnterCommit)return;e.preventDefault(),e.stopPropagation(),this.stopRowEditing(!0);return}e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this.stopRowEditing(!1))};handleEditorBlur=e=>{let t=e,n=this.editing;requestAnimationFrame(()=>{this.isEditing()&&this.editing===n&&this.phase!==`committing`&&(this.isFocusWithinRowEditors(t.relatedTarget)||(this.clearPendingBlurCommit(),this.scheduleBlurCommitAfterClick()))})};constructor(e){this.editorHost=e??new vf}getEditingRow(){return this.editing?{rowId:this.editing.rowId,rowIndex:this.editing.rowIndex}:null}getActiveColId(){return this.editing?this.activeColId&&this.editing.cells.has(this.activeColId)?this.activeColId:this.editing.focusColId&&this.editing.cells.has(this.editing.focusColId)?this.editing.focusColId:this.editing.cells.keys().next().value??null:null}focusEditingColumn(e){return this.editing?.cells.has(e)?(this.focusRowEditor(e),!0):!1}getEditingCells(){return this.editing?[...this.editing.cells.values()].map(e=>({rowId:this.editing.rowId,rowIndex:this.editing.rowIndex,colId:e.colId})):[]}getEditorValue(e){return this.editing?.cells.get(e)?.mountedEditor.getValue()??null}getEditorMountEl(e){return this.editing?.cells.get(e)?.mountedEditor.mountEl??null}isEditing(){return this.editing!==null}isCommitting(){return this.phase===`committing`}getEditSessionPhase(){return this.phase}awaitCommitIdle(){return(this.inflightCommit??Promise.resolve()).then(()=>void 0)}cancelCommit(){this.phase===`committing`&&(this.commitController?.abort(),this.finishCommittingVisual(),this.phase=`editing`,this.commitController=null,this.onCommitLifecycle?.onAborted?.())}isPinnedRow(e){return this.pinnedRowIds.has(e)}getPinnedRowIds(){return this.pinnedRowIds}startRowEditing(e){if(e.columns.length===0)return!1;this.stopRowEditing(!1);let{rowElement:t,rowNode:n,columns:r,focusColId:i}=e,a=new Map;for(let e of r){let n={},r={...e.params,autoFocus:i==null||e.column.colId===i,stopEditing:(e=!0)=>this.stopRowEditing(e).then(e=>e?{committed:e.committed}:null),cancelCommit:()=>this.cancelCommit(),getEditPhase:()=>this.phase,setKeyboardPolicy:t=>{Object.assign(n,t);let r=a.get(e.column.colId);r&&(r.keyboardPolicy=n)}},o=this.editorHost.mount(t,e.column,r,e.column.cellEditor);a.set(e.column.colId,{colId:e.column.colId,column:e.column,oldValue:e.oldValue,mountedEditor:o,keyboardPolicy:n}),this.attachEditorListeners(o)}return this.editing={rowId:n.id,rowIndex:n.rowIndex,rowElement:t,focusColId:i,cells:a},this.phase=`editing`,this.onCommitRow=e.onCommitRow,this.onFocusColChange=e.onFocusColChange??null,this.onCancel=e.onCancel??null,this.onRowEditingStopped=e.onRowEditingStopped??null,this.onCommitLifecycle=e.onCommitLifecycle??null,this.pinnedRowIds.add(n.id),queueMicrotask(()=>{let e=i??(this.editing?.focusColId&&this.editing.cells.has(this.editing.focusColId)?this.editing.focusColId:this.editing?.cells.keys().next().value);if((e?this.editing?.cells.get(e):void 0)?.keyboardPolicy.suppressInitialAutoFocus===!0){e&&(this.activeColId=e,this.editing.focusColId=e,this.onFocusColChange?.(e));return}this.focusRowEditor(i)}),!0}async stopRowEditing(e){if(!this.editing)return null;if(this.phase===`committing`)return e||this.cancelCommit(),this.inflightCommit;if(this.clearPendingBlurCommit(),!e)return this.cancelRowEditingSession();let t=this.commitRowEditingSession();this.inflightCommit=t;try{return await t}finally{this.inflightCommit===t&&(this.inflightCommit=null)}}destroy(){this.clearPendingBlurCommit(),this.cancelCommit(),this.teardownEditingState(),this.onCommitRow=null,this.onFocusColChange=null,this.activeColId=null,this.onCancel=null,this.onRowEditingStopped=null,this.onCommitLifecycle=null,this.phase=`idle`,this.commitController=null,this.inflightCommit=null,this.pinnedRowIds.clear()}async commitRowEditingSession(){if(!this.editing)return null;let t=this.editing,n=new Map;for(let e of t.cells.values())n.set(e.colId,e.mountedEditor.getValue());let r=this.onCommitRow;if(!r)return null;let i=++this.nextCommitId;this.phase=`committing`,this.setCommittingVisual(!0),this.onCommitLifecycle?.onStarted?.();let a=e.s(i,this.commitController);this.commitController=a;let o={ok:!1,failedColId:``};try{let e=await r(n,a.context);if(a.context.commitId!==i)return null;o=e}catch(t){if(e.c(t))o={ok:`aborted`};else throw t}finally{this.commitController===a&&(this.commitController=null),this.finishCommittingVisual()}return a.context.commitId!==i||this.editing!==t?null:(this.onCommitLifecycle?.onFinished?.(o),o.ok===`aborted`?(this.phase=`editing`,this.onCommitLifecycle?.onAborted?.(),null):o.ok===!1?o.revert?this.revertRowEditingSession(t):(this.phase=`editing`,this.focusRowEditor(o.failedColId),null):this.finalizeSuccessfulCommit(t,o.cells))}revertRowEditingSession(e){let t=this.onRowEditingStopped,n=[];for(let t of e.cells.values())n.push({colId:t.colId,committed:!1,oldValue:t.oldValue,newValue:void 0});this.teardownEditingState(),this.onCommitRow=null,this.onFocusColChange=null,this.activeColId=null,this.onCancel=null,this.onRowEditingStopped=null,this.onCommitLifecycle=null;let r={rowId:e.rowId,rowIndex:e.rowIndex,committed:!1,cells:n};return t?.(r),r}cancelRowEditingSession(){if(!this.editing)return null;let e=this.editing,t=this.onCancel,n=this.onRowEditingStopped,r=[];for(let t of e.cells.values())r.push({colId:t.colId,committed:!1,oldValue:t.oldValue,newValue:void 0});this.teardownEditingState(),t?.(),this.onCommitRow=null,this.onFocusColChange=null,this.activeColId=null,this.onCancel=null,this.onRowEditingStopped=null,this.onCommitLifecycle=null;let i={rowId:e.rowId,rowIndex:e.rowIndex,committed:!1,cells:r};return n?.(i),i}finalizeSuccessfulCommit(e,t){let n=this.onRowEditingStopped;this.teardownEditingState(),this.onCommitRow=null,this.onFocusColChange=null,this.activeColId=null,this.onCancel=null,this.onRowEditingStopped=null,this.onCommitLifecycle=null;let r={rowId:e.rowId,rowIndex:e.rowIndex,committed:!0,cells:t};return n?.(r),r}teardownEditingState(){if(this.editing){for(let e of this.editing.cells.values())e.mountedEditor.destroy();this.detachEditorListeners(),this.editing=null,this.phase=`idle`,this.commitController=null,this.pinnedRowIds.clear()}}setCommittingVisual(e){if(this.editing){this.editing.rowElement.classList.toggle(`mg-row--committing`,e);for(let t of this.editing.cells.values())t.mountedEditor.mountEl.classList.toggle(`mg-cell-editor-host--committing`,e)}}finishCommittingVisual(){this.setCommittingVisual(!1)}attachEditorListeners(e){let t=e.getFocusTarget();if(e.mountEl.addEventListener(`keydown`,this.handleEditorKeyDown,!0),t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement){t.addEventListener(`blur`,this.handleEditorBlur),this.attachedListeners.push({mountEl:e.mountEl,blurTarget:t});return}this.attachedListeners.push({mountEl:e.mountEl,blurTarget:null})}detachEditorListeners(){for(let e of this.attachedListeners)e.mountEl.removeEventListener(`keydown`,this.handleEditorKeyDown,!0),e.blurTarget&&e.blurTarget.removeEventListener(`blur`,this.handleEditorBlur);this.attachedListeners.length=0}focusRowEditor(e){if(!this.editing)return;let t=e&&this.editing.cells.has(e)?e:this.editing.focusColId&&this.editing.cells.has(this.editing.focusColId)?this.editing.focusColId:this.editing.cells.keys().next().value;t&&((this.editing.cells.get(t)?.mountedEditor.getFocusTarget())?.focus(),this.activeColId=t,this.editing.focusColId=t,this.onFocusColChange?.(t))}getOrderedEditableColIds(){return this.editing?[...this.editing.cells.values()].sort((e,t)=>e.column.left-t.column.left).map(e=>e.colId):[]}navigateRowTab(e,t){if(!this.editing)return;let n=this.getOrderedEditableColIds(),r=t??this.activeColId??n[0];if(!r)return;let i=If(r,n,e);i&&this.focusRowEditor(i)}resolveColIdFromEvent(e){if(!this.editing)return;let t=e.target;if(t instanceof Node){for(let e of this.editing.cells.values())if(e.mountedEditor.mountEl.contains(t))return e.colId}}isFocusWithinRowEditors(e){if(!this.editing)return!1;if(e instanceof Node){for(let t of this.editing.cells.values())if(t.mountedEditor.mountEl.contains(e))return!0;if(Gd(e))return!0}return Kd()}scheduleBlurCommitAfterClick(){let e=()=>{this.clearPendingBlurCommit(),!(!this.isEditing()||this.phase===`committing`)&&this.stopRowEditing(!0).then(e=>{e===null&&this.isEditing()&&this.focusRowEditor()})};this.blurCommitAfterClickListener=t=>{Gd(t.target)||e()},window.addEventListener(`click`,this.blurCommitAfterClickListener,!1),this.blurCommitFallbackTimer=window.setTimeout(()=>{e()},300)}clearPendingBlurCommit(){this.blurCommitAfterClickListener&&=(window.removeEventListener(`click`,this.blurCommitAfterClickListener,!1),null),this.blurCommitFallbackTimer!==null&&(clearTimeout(this.blurCommitFallbackTimer),this.blurCommitFallbackTimer=null)}};function zf(e,t){return`${e}::${t}`}function Bf(e,t){return e?.backgroundColor===t.backgroundColor&&e?.color===t.color}var Vf=class{overrides=new Map;get(e,t){return this.overrides.get(zf(e,t))}set(e,t,n){let r=zf(e,t);return!Bf(this.overrides.get(r),n)&&(this.overrides.set(r,{...n}),!0)}delete(e,t){return this.overrides.delete(zf(e,t))}clear(e){if(!e?.rowIds?.length&&!e?.colIds?.length){this.overrides.clear();return}let t=e.rowIds?.length?new Set(e.rowIds.map(e=>String(e))):null,n=e.colIds?.length?new Set(e.colIds):null;for(let e of[...this.overrides.keys()]){let r=e.indexOf(`::`);if(r<0){this.overrides.delete(e);continue}let i=e.slice(0,r),a=e.slice(r+2);t&&!t.has(i)||n&&!n.has(a)||this.overrides.delete(e)}}};function Hf(e){if(e==null||!Array.isArray(e))return null;let t=e.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean);return t.length>0?t:null}function Uf(e){if(e==null)return null;if(Array.isArray(e)){let t=Hf(e);return t?{errors:t}:null}if(typeof e==`object`&&Array.isArray(e.errors)){let t=Hf(e.errors);if(!t)return null;let n=e.colIds?.filter(e=>typeof e==`string`&&e.length>0);return n?.length?{errors:t,colIds:n}:{errors:t}}return null}function Wf(e,t){return e.length===0||t.length===0?[]:t.length===1?e.map(e=>({colId:e,errors:[t[0]]})):t.length===e.length?e.map((e,n)=>({colId:e,errors:[t[n]]})):e.map(e=>({colId:e,errors:[...t]}))}function Gf(e,t){if(t?.length)return[...t];let n=new Set(e);return n.has(`min`)&&n.has(`max`)?[`min`,`max`]:e.length>0?[e[0]]:[]}async function Kf(t,n,r,i){e.l(i);let a=t.cellValidator;if(!a)return null;try{let t=await a({...n,parsedValue:r,signal:i});return e.l(i),Hf(t)}catch(t){throw e.c(t),t}}async function qf(t,n){if(!t)return null;e.l(n.signal);try{let r=await t(n);return e.l(n.signal),Uf(r)}catch(t){throw e.c(t),t}}async function Jf(e,t,n,r){let i=await Kf(e,t,n,r??new AbortController().signal);return i?{valid:!1,errors:i}:{valid:!0}}function Yf(e,t){return t.index?String(t.index(e)):String(e+t.start)}function Xf(e,n,r){if(t.it(n.colId))return r?Yf(e.rowIndex,r):String(e.rowIndex+1);if(t.X(n.colId)||A(n.colId)||n.rowExpand||L(n.colId))return``;if(He(e)&&n.groupAgg)return e.__groupAggValues?.[n.colId]?.formattedValue??``;let i=n.prop??n.colId,a=i?e.data[i]:void 0;return n.valueGetter&&(a=n.valueGetter(e.data,a)),n.formatter?n.formatter(e.data,a):a==null?``:String(a)}function Zf(e){return{api:e.getApi(),size:e.gridSize}}var Qf=new AbortController().signal;async function $f(t,n,r,i,a){let o=t.cellCommitted;if(!o)return;let s=i.buildRowSnapshot(n);if(!s)return;let c=a.signal??Qf,l=Xf(n,t,i.getIndexColumnOptions?.());try{await o({row:s,colId:t.colId,value:r.newValue,oldValue:r.oldValue,newValue:r.newValue,formattedValue:l,source:a.source,signal:c,context:Zf(i)})}catch(n){if(e.c(n))throw n;console.error(`[magic-grid] cellCommitted failed`,{colId:t.colId,rowId:s.rowId,internalRowId:s.internalRowId,source:a.source,error:n})}}async function ep(e,t){e.beginUpdate();try{await t()}finally{e.endUpdate()}}var tp=class{pending=new Map;batchSeq=0;record(e){if(Object.is(e.oldValue,e.newValue))return;let t=this.pending.get(e.rowNode.id);t||(t={rowNode:e.rowNode,changes:new Map,sources:new Set},this.pending.set(e.rowNode.id,t));let n=t.changes.get(e.field);n?t.changes.set(e.field,{field:e.field,colId:n.colId??e.colId,oldValue:n.oldValue,newValue:e.newValue}):t.changes.set(e.field,{field:e.field,colId:e.colId,oldValue:e.oldValue,newValue:e.newValue}),t.sources.add(e.source)}flush(e){if(this.pending.size===0)return;let t=[],n=new Set;for(let r of this.pending.values()){let i=[...r.changes.values()].map(t=>({...t,colId:t.colId??e.resolveColIdByField?.(t.field)}));if(i.length===0)continue;let a=e.buildRowSnapshot(r.rowNode);if(!a)continue;let o=Object.fromEntries(i.map(e=>[e.field,e.newValue])),s=[...r.sources];for(let e of s)n.add(e);let c={rowId:r.rowNode.id,row:a,data:o,changes:i,source:s[0],sources:s.length>1?s:void 0};t.push(c),e.eventBus.emit(`rowDataChanged`,{...c,rowNode:r.rowNode})}t.length>0&&e.eventBus.emit(`rowsDataChanged`,{batchId:++this.batchSeq,rows:t,sources:[...n]}),this.pending.clear()}clear(){this.pending.clear()}peekPendingColIdsByRow(e){let t=new Map;for(let[n,r]of this.pending){let i=new Set;for(let t of r.changes.values()){let n=t.colId??e?.(t.field);n&&i.add(n)}i.size>0&&t.set(n,[...i])}return t}};function np(e,t,n,r,i,a){e({rowNode:t,field:n.prop??n.colId,colId:n.colId,oldValue:r,newValue:i,source:a})}async function rp(t,n,r,i,a,o,s){if(!r.prop)return{ok:!0,newValue:o};try{let e=_n(i,r,a);if(cn(e))return{ok:!1,revert:!0};let c=await Kf(r,a,e,s),l=t.invalidEditValueMode;return c&&l!==`keep`?{ok:!1,revert:!0}:o===e?{ok:!0,newValue:e}:await yn(r,a,e,s)?(await ep(t,async()=>{np(t.recordRowDataChange,n,r,o,e,`inlineEdit`),t.applyTransaction({update:[n.data]}),t.eventBus.emit(`cellValueChanged`,{rowId:n.id,colId:r.colId,oldValue:o,newValue:e,rowNode:n}),await $f(r,n,{oldValue:o,newValue:e},t,{source:`inlineEdit`,signal:s}),t.syncPinnedRows()}),{ok:!0,newValue:e}):{ok:!1,revert:!0}}catch(t){if(e.c(t))return{ok:`aborted`};throw t}}var ip=Symbol.for(`magic-grid.vueUserComp`);function ap(e){return e[ip]}function op(e,t){let n=e;if(t){n[ip]=t;return}delete n[ip]}function sp(e,t){if(t){op(e,t);return}op(e,void 0)}function cp(e){op(e,void 0)}function lp(e,t){let n=ap(e);return n?.refresh?n.refresh(t)!==!1:!1}function up(e){if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.refresh==`function`)return t;let n=e.exposed;if(n&&typeof n.refresh==`function`)return n;let r=e.$?.exposed;return r&&typeof r.refresh==`function`?r:null}function dp(e){return t=>{sp(e,up(t))}}function fp(e){return dp(e)}function pp(e){if(!e)return null;let t=e.component;if(t)return(up(t.exposed)??up(t.proxy))||pp(t.subTree);let{children:n}=e;if(Array.isArray(n))for(let e of n){if(!e||typeof e!=`object`||!(`type`in e))continue;let t=pp(e);if(t)return t}return null}function mp(e){let t=e._vnode,n=pp(t??null);if(n){sp(e,n);return}ap(e)&&cp(e)}var hp=class{onUnmountEditor;instanceEditors;editorOptions;constructor(e={}){this.onUnmountEditor=e.onUnmountEditor,this.instanceEditors={...e.byName??{}},this.editorOptions=e.editorOptions??t.f()}mount(e,t,n,r={}){r.patch||(this.onUnmountEditor?.(e),e.replaceChildren()),Yd(e,t.align,this.editorOptions);let i=null,a=null,o={mountEl:e,clear:()=>{this.onUnmountEditor?.(e),e.replaceChildren()}},s={...Ht(t,n),inline:!0,setGetValue:e=>{i=e}},c=_f(t.cellEditor,{byName:this.instanceEditors})(s,o);return c instanceof HTMLElement&&(a=c,e.contains(c)||e.appendChild(c)),{mountEl:e,getValue:()=>{if(i)return i();let r=e.querySelector(`input:not([type="hidden"]).mg-cell-editor, select.mg-cell-editor, textarea.mg-cell-editor`);if(r)return lf(r,t);let a=e.querySelector(`input:not([type="hidden"]), select, textarea`);return a?lf(a,t):n.formattedValue},getFocusTarget:()=>a||(e.querySelector(`input:not([type="hidden"]), select, textarea, [tabindex]`)??e.firstElementChild),destroy(){o.clear()}}}patch(e,t,n){lp(e,n)||this.mount(e,t,n,{patch:!0})}isVueEditorColumn(e){return Sn(_f(e.cellEditor,{byName:this.instanceEditors}))}},gp=0,_p=new WeakMap,vp=new WeakMap;function yp(e){let t=_p.get(e);return t===void 0&&(t=++gp,_p.set(e,t)),t}function bp(e){let t=vp.get(e);return t===void 0&&(t=++gp,vp.set(e,t)),t}function xp(e){return e===void 0?`default`:typeof e==`function`?`fn#${yp(e)}`:e}function Sp(e,t,n,r,i){return`${e}:${t}:${n}:${r}:${xp(i)}`}function Cp(e,t,n){return n?`${e}:${t}:fn#${bp(n)}`:`${e}:${t}:none`}var wp=class{permanent;constructor(e={}){this.permanent=new hp(e)}mount(e,t,n,r){return this.permanent.mount(e,t,n,r)}patch(e,t,n){this.permanent.patch(e,t,n)}isVueEditorColumn(e){return this.permanent.isVueEditorColumn(e)}},Tp=class{host;commits=new Map;inFlight=new Map;deps;constructor(e){this.deps=e,this.host=new wp({onUnmountEditor:e.onUnmountEditor,byName:e.byName,editorOptions:e.editorOptions})}getRefreshContext(){return{host:this.host,createParams:(e,t)=>this.createParams(e,t),commit:(e,t,n,r)=>this.commit(e,t,n,r)}}isCommitting(){return this.commits.size>0}async awaitCommitIdle(){this.inFlight.size!==0&&await Promise.all([...this.inFlight.values()])}cancelCommit(e,t){if(e&&t){this.abortCommit(`${e}:${t}`,!0);return}for(let e of[...this.commits.keys()])this.abortCommit(e,!0)}createParams(e,t){let n=Zf(this.deps),r={rowId:e.id,rowIndex:e.rowIndex,colId:t.colId,value:H(e,t),data:e.data,formattedValue:Xf(e,t),size:this.deps.gridSize,context:n,inline:!0},i=It(t,r),a={...r,cellEditorParams:i,stopEditing:async()=>null,cancelCommit:()=>this.cancelCommit(e.id,t.colId),getEditPhase:()=>this.isCellCommitting(e.id,t.colId)?`committing`:`idle`};return{...a,validate:async n=>{let r={...a,validate:async()=>({valid:!0})},i;try{if(i=_n(Ep(H(e,t),t),t,r),cn(i))return{valid:!1,errors:[`Invalid value`]}}catch(e){return{valid:!1,errors:[e instanceof Error?e.message:`Invalid value`]}}return Jf(t,r,i,n?.signal)}}}isCellCommitting(e,t){return this.commits.has(`${e}:${t}`)}abortCommit(t,n){let r=this.commits.get(t);r&&(r.userCancelled=n,r.controller.abort(new e.o))}async commit(e,t,n,r){let i=`${e.id}:${t.colId}`,a=this.runCommit(e,t,n,r,i);this.inFlight.set(i,a);try{return await a}finally{this.inFlight.get(i)===a&&this.inFlight.delete(i)}}async runCommit(e,t,n,r,i){this.abortCommit(i,!1);let a=new AbortController,o={controller:a,rowId:e.id,colId:t.colId,rowIndex:e.rowIndex,userCancelled:!1};this.commits.set(i,o),this.deps.eventBus.emit(`cellCommitStarted`,{rowId:e.id,colId:t.colId,rowIndex:e.rowIndex});let s=this.createParams(e,t),c=await rp(this.deps,e,t,n,s,r,a.signal);return this.commits.get(i)===o&&this.commits.delete(i),c.ok===`aborted`?(o.userCancelled&&this.deps.eventBus.emit(`editCommitAborted`,{rowId:e.id,colId:t.colId,rowIndex:e.rowIndex}),this.deps.eventBus.emit(`cellCommitFinished`,{rowId:e.id,colId:t.colId,rowIndex:e.rowIndex,committed:!1,aborted:o.userCancelled}),!1):(this.deps.eventBus.emit(`cellCommitFinished`,{rowId:e.id,colId:t.colId,rowIndex:e.rowIndex,committed:c.ok===!0,aborted:!1}),c.ok===!0)}};function Ep(e,t){if(t.cellEditor===`checkbox`){let n=zt(t);return nn(tn(e,n),n)}if(t.cellEditor===`switch`){let n=Bt(t);return Xt(Jt(e,n),n)}return e==null?``:String(e)}var Dp=`mg-selection-checkbox`,Op=`mg-selection-checkbox--header`;function kp(e){let t=document.createElement(`input`);return t.type=`checkbox`,t.className=Dp,t.setAttribute(`aria-label`,e.ariaLabel),Ap(t,e),t}function Ap(e,t){e.checked=t.checked,e.indeterminate=!!t.indeterminate,e.disabled=!!t.disabled,e.classList.toggle(`mg-selection-checkbox--disabled`,!!t.disabled),e.setAttribute(`aria-checked`,t.indeterminate?`mixed`:String(t.checked))}function jp(e){return e.querySelector(`input.${Dp}`)}function Mp(e,t){return t.rowLabel?.(e)??`选择第 ${e+1} 行`}function Np(e,t,n=new Set){let r=e.getRowCount();if(r===0)return{checked:!1,indeterminate:!1};let i=0,a=0;for(let o=0;o<r;o+=1){let r=e.getRow(o);r&&(Ue(r)||I(r)||(i++,t.has(r.id)&&!n.has(r.id)&&a++))}return a===0?{checked:!1,indeterminate:!1}:a===i?{checked:!0,indeterminate:!1}:{checked:!1,indeterminate:!0}}function Pp(e,n){let{selectionColumnOptions:r,selectedIds:i,indeterminateIds:a,rowModel:o}=n;if(!r.enabled||r.mode!==`multiple`)return;let s=e.querySelector(`.mg-header-cell[data-col-id="${t.J}"]`);if(!s)return;let c=jp(s);c&&Ap(c,Np(o,i,a??new Set))}function Fp(e,t){let n=[...e.getLeftFixedColumnIndices()],r=[...e.getRightFixedColumnIndices()],i=[];if(t.lastCol>=t.firstCol)for(let n of e.getCenterColumnIndices())n>=t.firstCol&&n<=t.lastCol&&i.push(n);return{left:n,center:i,right:r}}function Ip(e,t){let n=t.getLeftFixedWidth(),r=t.getLeftFixedColumnIndices(),i=t.getRightFixedColumnIndices(),a=n+t.getCenterTotalWidth(),o=zp(t,e.colId),s=o>=0&&o===t.getColumnCount()-1;if(e.fixed===`left`){let t=r[r.length-1];return{left:e.left,width:e.width,fixed:`left`,isLastLeftFixed:t!==void 0&&t===o,isLastColumn:s}}if(e.fixed===`right`){let t=i[0];return{left:e.left-a,width:e.width,fixed:`right`,isFirstRightFixed:t!==void 0&&t===o,isLastColumn:s}}let c=t.getCenterColumnIndices(),l=c[c.length-1];return{left:e.left,width:e.width,fixed:null,isLastCenter:i.length>0&&l!==void 0&&l===o,isLastColumn:s}}function Lp(e,t,n){e.style.width=`${t.width}px`,e.style.left=`${t.left}px`,e.style.removeProperty(`right`),e.style.removeProperty(`transform`),e.classList.remove(`${n}--fixed-left`,`${n}--fixed-right`,`${n}--fixed-left-last`,`${n}--center-last`,`${n}--column-last`,`${n}--fixed-right-first`),t.fixed===`left`?(e.classList.add(`${n}--fixed-left`),t.isLastLeftFixed&&e.classList.add(`${n}--fixed-left-last`)):t.fixed===`right`?(e.classList.add(`${n}--fixed-right`),t.isFirstRightFixed&&e.classList.add(`${n}--fixed-right-first`)):t.isLastCenter&&e.classList.add(`${n}--center-last`),t.isLastColumn&&e.classList.add(`${n}--column-last`)}function Rp(e,t,n){e.querySelectorAll(`[data-col-id]`).forEach(e=>{if(!(e instanceof HTMLElement))return;let r=e.dataset.colId;if(!r)return;let i=t.getColumnById(r);i&&Lp(e,Ip(i,t),n)})}function zp(e,t){for(let n=0;n<e.getColumnCount();n++)if(e.getColumn(n)?.colId===t)return n;return-1}var Bp={left:`--align-h-left`,center:`--align-h-center`,right:`--align-h-right`},Vp={top:`--align-v-top`,center:`--align-v-center`,bottom:`--align-v-bottom`},Hp=[...Object.values(Bp),...Object.values(Vp)];function Up(e={}){return{headerAlign:e.headerAlign,headerValign:e.headerValign,align:e.align,valign:e.valign,footerAlign:e.footerAlign,footerValign:e.footerValign}}function Wp(e,t={}){return{headerAlign:e.headerAlign??t.headerAlign??`center`,headerValign:e.headerValign??t.headerValign??`center`,align:e.align??t.align??`center`,valign:e.valign??t.valign??`center`,footerAlign:e.footerAlign??t.footerAlign??`center`,footerValign:e.footerValign??t.footerValign??`center`}}function Gp(e,t,n,r){for(let t of Hp)e.classList.remove(`${r}${t}`);e.classList.add(`${r}${Bp[t]}`),e.classList.add(`${r}${Vp[n]}`)}var Kp=[[`circle`,{cx:`12`,cy:`12`,r:`1`}],[`circle`,{cx:`12`,cy:`5`,r:`1`}],[`circle`,{cx:`12`,cy:`19`,r:`1`}]],qp=[[`path`,{d:`m5 12 7-7 7 7`}],[`path`,{d:`M12 19V5`}]],Jp=[[`path`,{d:`M12 5v14`}],[`path`,{d:`m19 12-7 7-7-7`}]],Yp=[[`path`,{d:`M12 2v20`}],[`path`,{d:`m15 19-3 3-3-3`}],[`path`,{d:`m19 9 3 3-3 3`}],[`path`,{d:`M2 12h20`}],[`path`,{d:`m5 9-3 3 3 3`}],[`path`,{d:`m9 5 3-3 3 3`}]],Xp=[[`path`,{d:`m3 16 4 4 4-4`}],[`path`,{d:`M7 20V4`}],[`path`,{d:`M11 4h10`}],[`path`,{d:`M11 8h7`}],[`path`,{d:`M11 12h4`}]],Zp=[[`path`,{d:`m3 8 4-4 4 4`}],[`path`,{d:`M7 4v16`}],[`path`,{d:`M11 12h10`}],[`path`,{d:`M11 16h7`}],[`path`,{d:`M11 20h4`}]],Qp=[[`path`,{d:`M3 6h18`}],[`path`,{d:`M7 12h10`}],[`path`,{d:`M10 18h4`}]],$p=[[`path`,{d:`M12 17v5`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v3.76`}]],em=[[`path`,{d:`M12 17v5`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v3.76`}],[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`}]],tm=[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`}],[`path`,{d:`M9 3v18`}]],nm=[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`}],[`path`,{d:`M15 3v18`}]],rm=[[`path`,{d:`m9 18 6-6-6-6`}]],im=[[`path`,{d:`M13.5 10.5 22 2`}],[`path`,{d:`M14.734 13.841a2 2 0 0 0-.314-2.42L12.58 9.58a2 2 0 0 0-2.421-.314l-7.657 4.461A1 1 0 0 0 2.3 15.3l6.403 6.403a1 1 0 0 0 1.571-.204z`}],[`path`,{d:`m5 18 2-2`}],[`path`,{d:`m7.699 10.7 5.602 5.601`}]],am=[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`}],[`path`,{d:`M9 3v18`}],[`path`,{d:`M15 3v18`}]],om=[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`}]],sm=[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`}],[`path`,{d:`m2 2 20 20`}]],cm=[[`path`,{d:`M12 2v4`}],[`path`,{d:`m16.2 7.8 2.9-2.9`}],[`path`,{d:`M18 12h4`}],[`path`,{d:`m16.2 16.2 2.9 2.9`}],[`path`,{d:`M12 18v4`}],[`path`,{d:`m7.8 16.2-2.9 2.9`}],[`path`,{d:`M2 12h4`}],[`path`,{d:`m7.8 7.8-2.9-2.9`}]],lm=[[`polyline`,{points:`15 10 20 15 15 20`}],[`path`,{d:`M4 4v7a4 4 0 0 0 4 4h12`}]],um=[[`polyline`,{points:`9 14 4 9 9 4`}],[`path`,{d:`M20 20v-7a4 4 0 0 0-4-4H4`}]],dm=[[`path`,{d:`M14 17H5`}],[`path`,{d:`M19 7h-9`}],[`circle`,{cx:`17`,cy:`17`,r:`3`}],[`circle`,{cx:`7`,cy:`7`,r:`3`}]];function J(e,t,n){let r=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);r.setAttribute(`class`,e),n!=null&&(r.setAttribute(`width`,String(n)),r.setAttribute(`height`,String(n))),r.setAttribute(`viewBox`,`0 0 24 24`),r.setAttribute(`fill`,`none`),r.setAttribute(`stroke`,`currentColor`),r.setAttribute(`stroke-width`,`2`),r.setAttribute(`stroke-linecap`,`round`),r.setAttribute(`stroke-linejoin`,`round`),r.setAttribute(`aria-hidden`,`true`);for(let[e,n]of t){let t=document.createElementNS(`http://www.w3.org/2000/svg`,e);for(let[e,r]of Object.entries(n))t.setAttribute(e,String(r));r.appendChild(t)}return r}function fm(){return J(`mg-header-icon mg-header-icon--column-handle`,Kp,14)}function pm(e){let t=e===`asc`?qp:Jp;return J(`mg-sort-icon mg-sort-icon--${e}`,t,14)}function mm(){return J(`mg-header-indicator-icon mg-header-indicator-icon--filter`,Qp,14)}function hm(){return J(`mg-header-indicator-icon mg-header-indicator-icon--sort-filter-asc`,Zp,14)}function gm(){return J(`mg-header-indicator-icon mg-header-indicator-icon--sort-filter-desc`,Xp,14)}function _m(){let e=document.createDocumentFragment();return e.append(pm(`asc`),pm(`desc`)),e}function vm(){return J(`mg-column-drag-ghost__move-icon`,Yp,16)}function ym(){return J(`mg-header-icon mg-header-icon--floating-filter`,Qp,14)}function bm(){return pm(`asc`)}function xm(){return pm(`desc`)}function Sm(){return J(`mg-column-handle-menu__icon mg-column-handle-menu__icon--sort-clear`,im,14)}function Cm(){return J(`mg-column-handle-menu__icon mg-column-handle-menu__icon--pin`,$p,14)}function wm(){return J(`mg-column-handle-menu__icon mg-column-handle-menu__icon--pin-off`,em,14)}function Tm(){return J(`mg-column-handle-menu__icon mg-column-handle-menu__icon--pin-left`,tm,14)}function Em(){return J(`mg-column-handle-menu__icon mg-column-handle-menu__icon--pin-right`,nm,14)}function Dm(){return J(`mg-column-handle-menu__icon mg-column-handle-menu__icon--chevron`,rm,14)}function Om(){return J(`mg-column-handle-menu__icon mg-column-handle-menu__icon--visibility`,am,14)}function km(){return J(`mg-column-handle-menu__icon mg-column-handle-menu__icon--hide-column`,sm,14)}function Am(){return J(`mg-column-handle-menu__icon mg-column-handle-menu__icon--show-column`,om,14)}function jm(){return J(`mg-cell__row-expand__icon`,rm,16)}function Mm(){return J(`mg-cell__tree-expand__loading-icon`,cm,16)}function Nm(){return J(`mg-column-settings-menu__icon-svg`,lm)}function Pm(){return J(`mg-column-settings-menu__icon-svg`,um)}function Fm(){return J(`mg-cell__tree-hierarchy-trigger__icon`,dm,14)}var Im=[[`path`,{d:`M13 21h8`}],[`path`,{d:`m15 5 4 4`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`}]];function Lm(){return J(`mg-cell__editable-indicator-icon`,Im,14)}var Rm=[[`path`,{d:`m10 10-6.157 6.162a2 2 0 0 0-.5.833l-1.322 4.36a.5.5 0 0 0 .622.624l4.358-1.323a2 2 0 0 0 .83-.5L14 13.982`}],[`path`,{d:`m12.829 7.172 4.359-4.346a1 1 0 1 1 3.986 3.986l-4.353 4.353`}],[`path`,{d:`m15 5 4 4`}],[`path`,{d:`m2 2 20 20`}]];function zm(){return J(`mg-cell__disabled-indicator-icon`,Rm,14)}function Bm(e){let{current:t,colId:n,sortable:r}=e;if(!r)return Qi(t);let i=Qi(t).find(e=>e.colId===n);return i?i.sort===`asc`?[{colId:n,sort:`desc`}]:[]:[{colId:n,sort:`asc`}]}function Vm(e,t){return t.find(t=>t.colId===e)?.sort??null}function Hm(e){return e===`asc`?`ascending`:e===`desc`?`descending`:`none`}var Um=class{deps;constructor(e){this.deps=e}toggleSort(e){if(!this.deps.getColumnById(e)?.sortable)return;let t=Bm({current:this.deps.getSortModel(),colId:e,sortable:!0});this.deps.setSortModel(t)}getSortState(e){return Vm(e,this.deps.getSortModel())}},Wm=`mg-header-cell--filtered`,Gm=`.mg-header-cell__column-handle`;function Km(e){return e??`center`}function qm(e,t,n,r){let i=t.sortable?Vm(e,n):null,a=t.filterable?si(e,r):!1;return i&&a?i===`asc`?`sort-filter-asc`:`sort-filter-desc`:i?i===`asc`?`sort-asc`:`sort-desc`:a?`filter`:null}function Jm(e){switch(e){case`sort-asc`:return pm(`asc`);case`sort-desc`:return pm(`desc`);case`filter`:return mm();case`sort-filter-asc`:return hm();case`sort-filter-desc`:return gm()}}function Ym(e,t,n){let r=e.querySelector(`.mg-header-cell__sort`);return r||(r=document.createElement(`span`),r.className=`mg-header-cell__sort`,r.setAttribute(`aria-hidden`,`true`),n?e.insertBefore(r,t):e.append(r)),r}function Xm(e){e.querySelector(`.mg-header-cell__sort`)?.remove()}function Zm(e,t,n,r,i){let a=e.querySelector(`.mg-header-cell__label`);if(!a)return;let o=a.querySelector(`.mg-header-cell__text`);if(!o)return;let s=Km(t.headerAlign)===`right`,c=qm(t.colId,t,n,r);if(e.classList.remove(`mg-header-cell--sort-hint`),c){Ym(a,o,s).replaceChildren(Jm(c));return}if(t.sortable&&i){Ym(a,o,s).replaceChildren(_m()),e.classList.add(`mg-header-cell--sort-hint`);return}Xm(a)}function Qm(e,t,n){let r=si(t,n);e.classList.toggle(Wm,r);let i=e.querySelector(Gm);i&&(r?i.setAttribute(`aria-pressed`,`true`):i.removeAttribute(`aria-pressed`))}function $m(e,t,n,r,i){if(Qm(e,t.colId,r),!t.sortable)e.classList.remove(`mg-header-cell--sortable`,`mg-header-cell--sorted`,`mg-header-cell--sorted-asc`,`mg-header-cell--sorted-desc`,`mg-header-cell--sort-hint`),e.removeAttribute(`aria-sort`);else{e.classList.toggle(`mg-header-cell--sortable`,i.enableHeaderSortClick),e.setAttribute(`role`,`columnheader`);let r=Vm(t.colId,n);e.setAttribute(`aria-sort`,Hm(r)),e.classList.remove(`mg-header-cell--sorted-asc`,`mg-header-cell--sorted-desc`,`mg-header-cell--sorted`),r===`asc`?e.classList.add(`mg-header-cell--sorted`,`mg-header-cell--sorted-asc`):r===`desc`&&e.classList.add(`mg-header-cell--sorted`,`mg-header-cell--sorted-desc`)}Zm(e,t,n,r,t.sortable&&i.showUnsortedSortHintOnHover&&i.enableHeaderSortClick)}function eh(e,t){let n=Array.isArray(e)?e:[e],r={showUnsortedSortHintOnHover:t.showUnsortedSortHintOnHover,enableHeaderSortClick:t.enableHeaderSortClick};for(let e of n){let n=Array.from(e.querySelectorAll(`.mg-header-cell[data-col-id]`));for(let e of n){let n=e.dataset.colId;if(!n)continue;let i=t.getColumnById(n);i&&$m(e,i,t.sortModel,t.filterModel,r)}}}var th=`mg-cell__group-content`,nh=`mg-cell__group-label`,rh=`mg-cell__group-count`;function ih(e,t,n){let r=n>0?`,${n} 条`:``;return t?`折叠分组 ${e}${r}`:`展开分组 ${e}${r}`}function ah(e,t){return e.groupFooterLabel??t.getGroupFooterLabel?.()??`小计`}function oh(e,t){return He(t)&&e.showGroupFooterCell&&!ye(e)}function sh(e,t,n){let r={visible:!1,showChevron:!1,expanded:!1,indentLevel:0,label:``,showCount:!1,count:0,ariaLabel:``};if(!t.active())return r;if(Ve(e)){if(n&&!De(n))return r;let i=e.sourceGroupId??Be(e.id)??e.groupId??``,a=e.groupKey??``,o=e.groupLeafCount??0,s=i?t.isExpanded(i):!1;return{visible:!0,showChevron:!!i,expanded:s,indentLevel:e.groupLevel??0,label:a,showCount:o>0,count:o,ariaLabel:ih(a,s,o)}}if(He(e)){if(n&&!Oe(n))return r;let i=n?ah(n,t):t.getGroupFooterLabel?.()??`小计`;return{visible:!0,showChevron:!1,expanded:!1,indentLevel:e.groupLevel??0,label:i,showCount:!1,count:0,ariaLabel:i}}return R(e),r}function ch(e){return`(${e})`}function lh(){let e=document.createElement(`button`);return e.type=`button`,e.className=fe,e.setAttribute(`aria-expanded`,`false`),e.appendChild(jm()),e}function uh(e,t){if(!t.showChevron){e.hidden=!0,e.classList.remove(pe),e.setAttribute(`aria-expanded`,`false`);return}e.hidden=!1,e.setAttribute(`aria-label`,t.ariaLabel),e.setAttribute(`aria-expanded`,String(t.expanded)),e.classList.toggle(pe,t.expanded)}function dh(e,t){for(let t=e.classList.length-1;t>=0;--t){let n=e.classList.item(t);n?.startsWith(`mg-cell__group-indent-`)&&e.classList.remove(n)}e.classList.add(`${me}${Math.max(0,t)}`),e.style.paddingLeft=`${Math.max(0,t)*16}px`}function fh(e,t,n,r,i){e.classList.toggle(_e,i.visible),dh(e,i.indentLevel),t&&uh(t,i),n.textContent=i.label,n.hidden=i.label.length===0,i.showCount&&i.count>0?(r.textContent=ch(i.count),r.hidden=!1):(r.textContent=``,r.hidden=!0)}function ph(e,t,n,r){if(r){if(t)return t;let r=lh();return e.insertBefore(r,n),r}return t&&t.remove(),null}function mh(e,t){return z(e.colId)&&B(t)}function hh(e,t){return t?`折叠 ${e}`:`展开 ${e}`}function gh(e,t){let n={visible:!1,showChevron:!1,expanded:!1,indentLevel:0,label:``,showCount:!1,count:0,ariaLabel:``};if(!t.active()||!B(e))return n;let r=t.getTreeValue?.(e)??e.dataPath?.[e.dataPath.length-1]??``,i=t.isExpanded(e.id),a=t.isTreeNodeLoading?.(e.id)??!1;return{visible:!0,showChevron:t.isTreeNodeExpandable?.(e)??e.treeLeaf!==!0,expanded:i,loading:a,indentLevel:e.treeLevel??0,label:r,showCount:!1,count:0,ariaLabel:hh(r,i),hierarchyActions:t.getTreeHierarchyActions?.(e)}}function _h(){let e=lh();return e.className=qe,e}function vh(e,t){if(yh(e,!!t.loading),!t.showChevron){e.hidden=!0,e.classList.remove(Je,Ye),e.disabled=!1,e.setAttribute(`aria-expanded`,`false`),e.setAttribute(`aria-busy`,`false`),e.setAttribute(`aria-hidden`,`true`),e.setAttribute(`tabindex`,`-1`);return}e.hidden=!1,e.removeAttribute(`aria-hidden`),e.removeAttribute(`tabindex`),e.setAttribute(`aria-label`,t.ariaLabel),e.setAttribute(`aria-expanded`,String(t.expanded&&!t.loading)),e.classList.toggle(Je,t.expanded&&!t.loading),e.classList.toggle(Ye,!!t.loading),e.disabled=!!t.loading,e.setAttribute(`aria-busy`,t.loading?`true`:`false`)}function yh(e,t){let n=e.querySelector(`.mg-cell__row-expand__icon`),r=e.querySelector(`.mg-cell__tree-expand__loading-icon`);if(t){if(n instanceof SVGElement&&n.setAttribute(`hidden`,`hidden`),!(r instanceof SVGElement)){e.appendChild(Mm());return}r.removeAttribute(`hidden`);return}if(r instanceof SVGElement&&r.remove(),n instanceof SVGElement){n.removeAttribute(`hidden`);return}e.appendChild(jm())}function bh(e,t){let n=Math.max(0,e);return t||n<=1?n:n-1}function xh(e){return Math.max(0,e)>1}function Sh(e,t,n){let r=n?.isExpandable===void 0?t:bh(t,n.isExpandable);for(let t=e.classList.length-1;t>=0;--t){let n=e.classList.item(t);(n?.startsWith(`mg-cell__tree-indent-`)||n?.startsWith(`mg-cell__group-indent-`))&&e.classList.remove(n)}e.classList.add(`${Xe}${Math.max(0,r)}`),e.style.paddingLeft=`${Math.max(0,r)*16}px`}function Ch(){let e=document.createElement(`button`);return e.type=`button`,e.className=Ze,e.setAttribute(`aria-label`,`层级操作`),e.setAttribute(`aria-haspopup`,`menu`),e.title=`层级操作`,e.appendChild(Fm()),e}function wh(e){e.setAttribute(`aria-label`,`层级操作`),e.title=`层级操作`,e.disabled=!1}function Th(e,t,n){if(!n?.visible)return t?.remove(),null;let r=t;r||(r=document.createElement(`div`),r.className=Qe,r.append(Ch()),e.append(r));let i=r.querySelector(`button.${Ze}`);return i&&wh(i),r}function Eh(e){return e instanceof Element?e.closest(`button.${Ze}`):null}function Dh(e,t,n,r,i){return e.classList.toggle($e,r.visible),e.classList.toggle(_e,r.visible),Sh(e,r.indentLevel,{isExpandable:r.showChevron}),t&&vh(t,r),n.textContent=r.label,n.hidden=r.label.length===0,Th(e,i??null,r.hierarchyActions)}function Oh(e,t,n,r,i=0){if(r){if(t)return t;let r=_h();return e.insertBefore(r,n),r}if(!xh(i))return t&&t.remove(),null;if(t)return t.hidden=!0,t.classList.remove(Je,Ye),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`tabindex`,`-1`),t;let a=_h();return a.hidden=!0,a.setAttribute(`aria-hidden`,`true`),a.setAttribute(`tabindex`,`-1`),e.insertBefore(a,n),a}function kh(e){return e?`全部收起`:`全部展开`}function Ah(e,t,n=!1){let r=document.createElement(`div`);r.className=`mg-header-cell__label`;let i=_h();jh(i,n);let a=document.createElement(`span`);a.className=`mg-header-cell__text`,a.textContent=t.label??t.prop??`树`,r.append(i,a),e.append(r),e.classList.add(`mg-header-cell--tree`)}function jh(e,t){vh(e,{showChevron:!0,expanded:t,loading:!1,ariaLabel:kh(t)})}function Mh(e,t){for(let n of e){let e=n.querySelector(`.mg-header-cell--tree .${qe}`);if(e){jh(e,t);return}}}var Nh=`mg-header-cell__required-mark`,Ph=`mg-header-cell__text-content`;function Fh(){let e=document.createElement(`span`);return e.className=Nh,e.textContent=`*`,e.setAttribute(`aria-hidden`,`true`),e}function Ih(e){if(e.querySelector(`.${Ph}`))return;let t=document.createElement(`span`);t.className=Ph,t.textContent=e.textContent??``,e.textContent=``,e.append(t)}function Lh(e){let t=e.querySelector(`.${Ph}`);t&&(e.textContent=t.textContent??``)}function Rh(e,t){e.classList.toggle(`mg-header-cell--required`,t);let n=e.querySelector(`.mg-header-cell__text`);if(!n)return;let r=n.querySelector(`.${Nh}`);if(!t){r?.remove(),Lh(n);return}Ih(n);let i=r??Fh();(i.parentElement!==n||i!==n.firstElementChild)&&n.insertBefore(i,n.firstChild)}function zh(e){return e??`center`}function Bh(){let e=document.createElement(`div`);return e.className=`mg-header-cell__label`,e}function Vh(e){let n=document.createElement(`span`);return n.className=`mg-header-cell__text`,n.textContent=t.it(e.colId)?e.label??``:e.label??e.prop??e.colId,n}function Hh(e){return t.it(e.colId)||t.X(e.colId)||A(e.colId)||z(e.colId)?!1:e.sortable||e.movable||e.filterable}function Uh(e){let t=document.createElement(`span`);return t.className=`mg-header-cell__column-handle`,t.title=`列操作`,t.setAttribute(`aria-haspopup`,`menu`),t.setAttribute(`aria-expanded`,`false`),t.tabIndex=-1,t.dataset.columnHandleMovable=e.movable?`true`:`false`,t.dataset.columnHandleSortable=e.sortable?`true`:`false`,t.dataset.columnHandleFilterable=e.filterable?`true`:`false`,t.append(fm()),t}function Wh(e){if(!Hh(e))return null;let t=document.createElement(`div`);return t.className=`mg-header-cell__chrome`,t.append(Uh({movable:e.movable,sortable:e.sortable,filterable:e.filterable})),t}function Gh(){let e=document.createElement(`div`);return e.className=`mg-header-cell__resize-handle`,e.setAttribute(`role`,`presentation`),e.dataset.resizable=`true`,e}function Kh(e,t){t&&e.append(Gh())}function qh(e,t){let n=zh(t.headerAlign),r=Bh(),i=Vh(t);r.append(i);let a=Wh(t);n===`right`&&a?e.append(a,r):a?e.append(r,a):e.append(r)}function Jh(e,n){let r=Hh(n),i=!t.it(n.colId)&&!t.X(n.colId)&&!A(n.colId)&&!z(n.colId);e.classList.toggle(`mg-header-cell--has-column-handle`,r),e.classList.toggle(`mg-header-cell--movable`,i&&n.movable),e.classList.toggle(`mg-header-cell--filterable`,i&&n.filterable)}function Yh(e,t){e.classList.toggle(`mg-header-cell--resizable`,t.resizable)}function Xh(e,n,r){let i=document.createElement(`div`);if(i.className=`mg-header-cell`,i.dataset.colId=e.colId,t.X(e.colId))if(i.classList.add(`mg-header-cell--selection`),r.selectionColumnOptions?.enabled&&r.selectionColumnOptions.mode===`multiple`){let e=kp({checked:!1,ariaLabel:r.selectionColumnOptions.selectionColumn.selectAllLabel});e.classList.add(Op),i.append(e)}else{let e=document.createElement(`span`);e.className=`mg-header-cell__text`,e.textContent=``,i.append(e)}else if(t.it(e.colId)){let t=Vh(e);i.append(t),i.classList.add(`mg-header-cell--index`)}else if(A(e.colId)){let e=document.createElement(`span`);e.className=`mg-header-cell__text`,e.textContent=``,i.append(e),i.classList.add(`mg-header-cell--expand`)}else if(L(e.colId)){let t=document.createElement(`span`);t.className=`mg-header-cell__text`,t.textContent=e.label??`分组`,i.append(t),i.classList.add(`mg-header-cell--group`)}else z(e.colId)?(Ah(i,e,r.getTreeHeaderExpanded?.()??!1),Kh(i,e.resizable)):(qh(i,e),Kh(i,e.resizable));return $m(i,e,r.sortModel,r.filterModel,{showUnsortedSortHintOnHover:r.showUnsortedSortHintOnHover,enableHeaderSortClick:r.enableHeaderSortClick}),Jh(i,e),Yh(i,e),Lp(i,Ip(e,n),`mg-header-cell`),Gp(i,e.headerAlign,e.headerValign,`mg-header-cell`),Rh(i,e.validationRequired===!0),r.validationFeedback.hasColErrors(e.colId)&&i.classList.add(`mg-header-cell--invalid`),i}function Zh(e,t,n,r,i,a,o,s,c={},l){e.replaceChildren();let u={sortModel:r,validationFeedback:i,showUnsortedSortHintOnHover:a,enableHeaderSortClick:o,selectionColumnOptions:s,filterModel:c,getTreeHeaderExpanded:l};for(let r of t){let t=n.getColumn(r);t&&e.appendChild(Xh(t,n,u))}}function Qh(e){let{headerLeftLaneEl:t,headerCenterLaneEl:n,headerRightLaneEl:r,columnModel:i,centerWindow:a,sortModel:o,validationFeedback:s,selectionColumnOptions:c,showUnsortedSortHintOnHover:l=!1,enableHeaderSortClick:u=!0,filterModel:d={},getTreeHeaderExpanded:f}=e,p=Fp(i,a);t.style.width=`${i.getLeftFixedWidth()}px`,n.style.width=`${i.getCenterTotalWidth()}px`,r.style.width=`${i.getRightFixedWidth()}px`,Zh(t,p.left,i,o,s,l,u,c,d,f),Zh(n,p.center,i,o,s,l,u,c,d,f),Zh(r,p.right,i,o,s,l,u,c,d,f)}function $h(e,t,n,r){e.style.width=`${r.getLeftFixedWidth()}px`,t.style.width=`${r.getCenterTotalWidth()}px`,n.style.width=`${r.getRightFixedWidth()}px`}function eg(e,t,n,r){Rp(e,r,`mg-header-cell`),Rp(t,r,`mg-header-cell`),Rp(n,r,`mg-header-cell`)}function tg(e){let t=new Map;for(let n of e)for(let e of n.querySelectorAll(`.mg-header-cell[data-col-id]`)){if(!(e instanceof HTMLElement))continue;let n=e.dataset.colId;n&&t.set(n,e)}return t}function ng(e,t,n,r,i){let a=new Set;for(let o of t){let t=n.getColumn(o);if(!t||t.hidden)continue;a.add(t.colId);let s=r.get(t.colId);!s&&i&&(s=Xh(t,n,i),r.set(t.colId,s)),s&&e.appendChild(s)}if(i)for(let t of[...e.children]){if(!(t instanceof HTMLElement))continue;let e=t.dataset.colId;e&&!a.has(e)&&t.remove()}}function rg(e){let{headerLeftLaneEl:t,headerCenterLaneEl:n,headerRightLaneEl:r,columnModel:i,centerWindow:a,fillColumnWindowGaps:o=!1,sortModel:s,validationFeedback:c,selectionColumnOptions:l,showUnsortedSortHintOnHover:u=!1,enableHeaderSortClick:d=!0,filterModel:f={},getTreeHeaderExpanded:p}=e,m=Fp(i,a),h=o&&s&&c?{sortModel:s,validationFeedback:c,showUnsortedSortHintOnHover:u,enableHeaderSortClick:d,selectionColumnOptions:l,filterModel:f,getTreeHeaderExpanded:p}:void 0;$h(t,n,r,i);let g=tg([t,n,r]);ng(t,m.left,i,g,h),ng(n,m.center,i,g,h),ng(r,m.right,i,g,h)}var ig=class{registry=new Map;invalidColIds=new Set;domStates=[];showCellInvalid(e){this.setRowCellInvalid(e.rowId,e.rowElement,{colId:e.colId,errors:e.errors,editorMountEl:e.editorMountEl})}showCellsInvalid(e){this.setRowInvalid(e.rowId,e.rowElement,e.cells)}setRowInvalid(e,t,n){this.clearRowDom(e,t);let r=new Map;for(let i of n)i.errors.length&&(r.set(i.colId,i.errors),t&&this.applyCellDom(e,t,i));r.size===0?this.registry.delete(e):this.registry.set(e,r),this.rebuildInvalidColIds()}applyGridValidationFeedback(e,t){let n=new Set(t.map(e=>e.rowId));for(let t of[...this.registry.keys()])if(!n.has(t)){let n=this.findRowElement(e,t);this.clearRow(t,n)}for(let n of t){let t=this.findRowElement(e,n.rowId);this.setRowInvalid(n.rowId,t,n.cells)}}applyRowsValidationFeedback(e,t){for(let n of t){let t=this.findRowElement(e,n.rowId);this.setRowInvalid(n.rowId,t,n.cells)}}clearRow(e,t){this.clearRowDom(e,t??null),this.registry.delete(e),this.rebuildInvalidColIds()}clearRowCell(e,t,n){let r=this.registry.get(e);if(r?.delete(n),r?.size===0&&this.registry.delete(e),t){let e=t.querySelector(`.mg-cell[data-col-id="${n}"]`);e?.classList.remove(`mg-cell--invalid`),e?.removeAttribute(`title`)}let i=[];for(let t of this.domStates)(t.rowId!==e||t.colId!==n)&&i.push(t);this.domStates=i,this.rebuildInvalidColIds()}setRowCellInvalid(e,t,n){if(!n.errors.length){this.clearRowCell(e,t,n.colId);return}if(t){for(let r of this.domStates)r.rowId===e&&r.colId===n.colId&&this.removeCellDom(r,t);this.domStates=this.domStates.filter(t=>t.rowId!==e||t.colId!==n.colId)}let r=this.registry.get(e);r||(r=new Map,this.registry.set(e,r)),r.set(n.colId,n.errors),t&&this.applyCellDom(e,t,n),this.rebuildInvalidColIds()}clear(e){e&&this.removeRegistryDom(e),this.domStates=[],this.registry.clear(),this.rebuildInvalidColIds()}syncDom(e){for(let t of e.querySelectorAll(`.mg-cell--invalid`)){let e=t.closest(`.mg-row[data-row-id]`)?.getAttribute(`data-row-id`),n=t.getAttribute(`data-col-id`);(e&&n?this.registry.get(e)?.get(n):void 0)?.length||(t.classList.remove(`mg-cell--invalid`),t.removeAttribute(`title`))}for(let[t,n]of this.registry){let r=this.findRowElement(e,t);if(r)for(let[e,t]of n){if(!t.length)continue;let n=t.join(`
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./validation-CD6lt5wS.cjs"),t=require("./getRowDragCommitHierarchy-DoMf_SY8.cjs");let n=require("vue");var r={class:`mg-status-bar__panels`},i=(0,n.defineComponent)({__name:`StatusBarDefaultPanels`,props:{context:{}},setup(e){let t=e,i=(0,n.computed)(()=>{let{context:e}=t,n=[];return n.push(`共 ${e.totalRowCount} 行`),e.isFiltered&&n.push(`显示 ${e.displayedRowCount} 行`),e.rowSelectionEnabled&&e.selectedRowCount>0&&n.push(`已选 ${e.selectedRowCount} 行`),n});return(e,t)=>((0,n.openBlock)(),(0,n.createElementBlock)(`div`,r,[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)(i.value,(e,t)=>((0,n.openBlock)(),(0,n.createElementBlock)(`span`,{key:t,class:`mg-status-bar__panel`},(0,n.toDisplayString)(e),1))),128))]))}}),a=2;function o(e){if(typeof e==`number`){let t=s(e);return{average:t,sum:t}}return{average:s(e?.average??2),sum:s(e?.sum??2)}}function s(e){return Number.isFinite(e)?Math.max(0,Math.min(10,Math.trunc(e))):2}function c(e,t,n=2){if(t===`count`)return String(Math.trunc(e));let r=s(n),i=10**r,a=Math.round(e*i)/i;return r===0?String(Math.round(a)):a.toFixed(r).replace(/\.?0+$/,``)}function l(e){return e!=null&&e.count>0}var u={key:0,class:`mg-status-bar__panels mg-status-bar__panels--aggregation`},d=(0,n.defineComponent)({__name:`StatusBarRangeAggregationPanels`,props:{context:{}},setup(e){let t=e,r=(0,n.computed)(()=>l(t.context.cellSelectionAggregation)),i=(0,n.computed)(()=>{let e=t.context.cellSelectionAggregation;if(!l(e))return[];let n=t.context.statusBarRangeAggregationPrecision,r=[];return e.average!=null&&r.push({label:`平均值`,value:c(e.average,`average`,n.average)}),r.push({label:`计数`,value:c(e.count,`count`)}),e.sum!=null&&r.push({label:`求和`,value:c(e.sum,`sum`,n.sum)}),r});return(e,t)=>r.value&&i.value.length?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,u,[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)(i.value,(e,t)=>((0,n.openBlock)(),(0,n.createElementBlock)(`span`,{key:t,class:`mg-status-bar__panel`},(0,n.toDisplayString)(e.label)+`: `+(0,n.toDisplayString)(e.value),1))),128))])):(0,n.createCommentVNode)(``,!0)}}),f={key:0,class:`mg-status-bar__region mg-status-bar__region--left`},p={key:1,class:`mg-status-bar__separator`,role:`separator`,"aria-orientation":`vertical`},m={key:3,class:`mg-status-bar__separator`,role:`separator`,"aria-orientation":`vertical`},h={key:4,class:`mg-status-bar__separator`,role:`separator`,"aria-orientation":`vertical`},g={key:6,class:`mg-status-bar__separator`,role:`separator`,"aria-orientation":`vertical`},_={key:7,class:`mg-status-bar__region mg-status-bar__region--right`},v=(0,n.defineComponent)({__name:`MagicGridStatusBar`,props:{context:{},barStyle:{},showDefaultPanels:{type:Boolean},showStatusBarRangeAggregation:{type:Boolean},statusBarRangeAggregationPosition:{},hasCustomStatusBarSlot:{type:Boolean},hasLeftSlot:{type:Boolean},hasRightSlot:{type:Boolean}},setup(e,{expose:t}){let r=e,a=(0,n.ref)();t({get statusBarEl(){return a.value}});let o=(0,n.computed)(()=>r.showDefaultPanels||r.hasLeftSlot),s=(0,n.computed)(()=>r.hasRightSlot),c=(0,n.computed)(()=>r.showStatusBarRangeAggregation?l(r.context.cellSelectionAggregation):!1),u=(0,n.computed)(()=>r.statusBarRangeAggregationPosition===`left`&&c.value),v=(0,n.computed)(()=>r.statusBarRangeAggregationPosition===`right`&&c.value),y=(0,n.computed)(()=>o.value),b=(0,n.computed)(()=>u.value),x=(0,n.computed)(()=>v.value||s.value),S=(0,n.computed)(()=>v.value&&s.value);return(t,r)=>((0,n.openBlock)(),(0,n.createElementBlock)(`div`,{ref_key:`statusBarEl`,ref:a,class:`mg-status-bar`,style:(0,n.normalizeStyle)(e.barStyle),role:`status`,"aria-live":`polite`},[e.hasCustomStatusBarSlot?(0,n.renderSlot)(t.$slots,`status-bar`,(0,n.normalizeProps)((0,n.guardReactiveProps)(e.context)),void 0,void 0,0):((0,n.openBlock)(),(0,n.createElementBlock)(n.Fragment,{key:1},[o.value?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,f,[e.showDefaultPanels?((0,n.openBlock)(),(0,n.createBlock)(i,{key:0,context:e.context},null,8,[`context`])):(0,n.createCommentVNode)(``,!0),(0,n.renderSlot)(t.$slots,`status-bar-left`,(0,n.normalizeProps)((0,n.guardReactiveProps)(e.context)))])):(0,n.createCommentVNode)(``,!0),y.value?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,p)):(0,n.createCommentVNode)(``,!0),u.value?((0,n.openBlock)(),(0,n.createBlock)(d,{key:2,context:e.context},null,8,[`context`])):(0,n.createCommentVNode)(``,!0),b.value?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,m)):(0,n.createCommentVNode)(``,!0),r[0]||=(0,n.createElementVNode)(`div`,{class:`mg-status-bar__stretch`,"aria-hidden":`true`},null,-1),x.value?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,h)):(0,n.createCommentVNode)(``,!0),v.value?((0,n.openBlock)(),(0,n.createBlock)(d,{key:5,context:e.context},null,8,[`context`])):(0,n.createCommentVNode)(``,!0),S.value?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,g)):(0,n.createCommentVNode)(``,!0),s.value?((0,n.openBlock)(),(0,n.createElementBlock)(`div`,_,[(0,n.renderSlot)(t.$slots,`status-bar-right`,(0,n.normalizeProps)((0,n.guardReactiveProps)(e.context)))])):(0,n.createCommentVNode)(``,!0)],64))],4))}}),y={columns:{type:Array,required:!0},data:{type:Array,default:()=>[]},rowModelType:{type:String,default:`clientSide`},infiniteDatasource:{type:Object,default:void 0},blockSize:{type:Number,default:void 0},maxBlocksInCache:{type:Number,default:void 0},infiniteInitialRowCount:{type:Number,default:void 0},infiniteMaxRetries:{type:Number,default:void 0},infiniteLoadingRowVisible:{type:Boolean,default:void 0},cellEditorRegistry:{type:Object,default:void 0},rowKey:{type:String,default:`id`},stripe:{type:Boolean,default:!1},cellColor:{type:Object,default:void 0},border:{type:String,default:`border`},theme:{type:String,default:`light`},size:{type:String,default:`default`},rounded:{type:[Boolean,Number],default:!1},rowHeight:{type:Number,default:void 0},headerHeight:{type:Number,default:void 0},showIndexColumn:{type:Boolean,default:!1},indexColumn:{type:Object,default:void 0},selectionColumn:{type:Object,default:void 0},showSummary:{type:Boolean,default:!1},navigateHeader:{type:Boolean,default:!1},navigateFooter:{type:Boolean,default:!1},summaryScope:{type:String,default:`displayed`},summaryRowHeight:{type:Number,default:void 0},summaryMethod:{type:Function,default:void 0},headerAlign:{type:String,default:void 0},headerValign:{type:String,default:void 0},align:{type:String,default:void 0},valign:{type:String,default:void 0},footerAlign:{type:String,default:void 0},footerValign:{type:String,default:void 0},rowBuffer:{type:Number,default:10},scrollEndFlushMs:{type:Number,default:0},frameBudgetMs:{type:Number,default:void 0},scrollEndFrameBudgetMs:{type:Number,default:void 0},cellRendererDefer:{type:String,default:`always`},deferRowDestroyOnScroll:{type:Boolean,default:!1},rendererFrameBudgetMs:{type:Number,default:void 0},cellRendererPresentation:{type:String,default:`deferred`},rowSelection:{type:[String,Boolean,Object],default:`single`},selectable:{type:Function,default:void 0},isRowDisabled:{type:[Boolean,Function],default:void 0},rowStyle:{type:[Object,Function],default:void 0},editableCellStyle:{type:Object,default:void 0},showEditableCellIcon:{type:Boolean,default:!1},disabledCellStyle:{type:Object,default:void 0},showDisabledCellIcon:{type:Boolean,default:!1},reserveSelection:{type:Boolean,default:!1},preserveScrollOnSetData:{type:Boolean,default:!0},defaultSelectedRows:{type:[Array,Function],default:void 0},editBehavior:{type:String,default:`cell`},editType:{type:String,default:`singleClick`},editorOptions:{type:Object,default:void 0},invalidEditValueMode:{type:String,default:`block`},rowValidator:{type:Function,default:void 0},asyncRowMutation:{type:Object,default:void 0},height:{type:[String,Number],default:`100%`},width:{type:[String,Number],default:`100%`},defaultSort:{type:Array,default:void 0},sortable:{type:Boolean,default:!1},enableHeaderSortClick:{type:Boolean,default:!0},columnMovable:{type:Boolean,default:!0},resizable:{type:Boolean,default:!0},colResizeDefault:{type:String,default:void 0},skipHeaderOnAutoSize:{type:Boolean,default:!1},autoSizePadding:{type:Number,default:void 0},autoSizeStrategy:{type:Object,default:void 0},suppressMoveWhenColumnDragging:{type:Boolean,default:!1},suppressColumnMoveAnimation:{type:Boolean,default:!1},allowCrossLaneColumnMove:{type:Boolean,default:!1},showUnsortedSortHintOnHover:{type:Boolean,default:!1},quickFilterText:{type:String,default:``},filterable:{type:Boolean,default:!1},floatingFilter:{type:Boolean,default:!1},filterSetValueMode:{type:String,default:`current`},filterSetDateLayoutMode:{type:String,default:`tree`},showStatusBar:{type:Boolean,default:!0},showDefaultStatusBarPanels:{type:Boolean,default:!0},statusBarHeight:{type:[String,Number],default:`auto`},showStatusBarRangeAggregation:{type:Boolean,default:!0},statusBarRangeAggregationPosition:{type:String,default:`right`},statusBarRangeAggregationPrecision:{type:[Number,Object],default:void 0},rowDragManaged:{type:Boolean,default:!0},getRowHeight:{type:Function,default:void 0},rowHeightMin:{type:Number,default:void 0},rowHeightMax:{type:Number,default:void 0},enableCellSpan:{type:Boolean,default:!1},enableCellEditorCache:{type:Boolean,default:!1},cellEditorCacheMaxEntries:{type:Number,default:void 0},masterDetail:{type:Boolean,default:!1},isRowMaster:{type:Function,default:void 0},masterDefaultExpanded:{type:Number,default:void 0},detailRowHeight:{type:[Number,Function],default:void 0},detailRowAutoHeight:{type:Boolean,default:void 0},embedFullWidthRows:{type:Boolean,default:void 0},showExpandColumn:{type:Boolean,default:void 0},getDetailRowData:{type:Function,default:void 0},detailCellRenderer:{type:Function,default:void 0},loadMoreRow:{type:Object,default:void 0},loadMoreRowRenderer:{type:Function,default:void 0},rowGrouping:{type:Boolean,default:!1},groupDefaultExpanded:{type:Number,default:void 0},showGroupHeader:{type:Boolean,default:!1},showGroupFooter:{type:Boolean,default:!1},groupDisplayType:{type:String,default:void 0},showGroupColumn:{type:Boolean,default:!1},autoGroupColumnDef:{type:Object,default:void 0},groupKeyCreator:{type:Function,default:void 0},groupComparator:{type:Function,default:void 0},groupSortKey:{type:String,default:void 0},groupFooterLabel:{type:String,default:void 0},groupCellRenderer:{type:Function,default:void 0},tree:{type:Boolean,default:!1},getDataPath:{type:Function,default:void 0},showTreeColumn:{type:Boolean,default:void 0},autoTreeColumnDef:{type:Object,default:void 0},treeValueGetter:{type:Function,default:void 0},treeDisplayType:{type:String,default:void 0},treeDragScope:{type:String,default:void 0},treeHierarchyActions:{type:Boolean,default:void 0},setDataPath:{type:Function,default:void 0},treeLazyLoad:{type:Boolean,default:!1},hasTreeChildren:{type:Function,default:void 0},loadTreeChildren:{type:Function,default:void 0},cellCommentsDataSource:{type:Object,default:void 0},suppressCellComments:{type:Boolean,default:!1},cellCommentTrigger:{type:String,default:`click`},cellCommentShowDelay:{type:Number,default:void 0},cellCommentHideDelay:{type:Number,default:void 0},cellSelection:{type:[Boolean,Object],default:!0},enableCellCopy:{type:Boolean,default:void 0},enableCellPaste:{type:Boolean,default:void 0},enableHeaderHighlight:{type:Boolean,default:!0},enableIndexColumnHighlight:{type:Boolean,default:!0},processCellForClipboard:{type:Function,default:void 0},processCellFromClipboard:{type:Function,default:void 0},processDataFromClipboard:{type:Function,default:void 0},enableTooltips:{type:Boolean,default:void 0},tooltipShowMode:{type:String,default:void 0},tooltipShowDelay:{type:Number,default:void 0},tooltipSwitchShowDelay:{type:Number,default:void 0},tooltipHideDelay:{type:Number,default:void 0},tooltipInteraction:{type:Boolean,default:void 0},tooltipMouseTrack:{type:Boolean,default:void 0},tooltipComponent:{type:Function,default:void 0},tooltipComponentParams:{type:Object,default:void 0},loading:{type:Boolean,default:void 0},suppressOverlays:{type:Array,default:void 0},suppressLoadingOverlay:{type:Boolean,default:void 0},suppressNoRowsOverlay:{type:Boolean,default:void 0},suppressNoMatchingRowsOverlay:{type:Boolean,default:void 0},overlayLoadingTemplate:{type:String,default:void 0},overlayNoRowsTemplate:{type:String,default:void 0},overlayNoMatchingRowsTemplate:{type:String,default:void 0},overlayInteraction:{type:Boolean,default:void 0},loadingOverlayComponent:{type:Function,default:void 0},loadingOverlayComponentParams:{type:Object,default:void 0},noRowsOverlayComponent:{type:Function,default:void 0},noRowsOverlayComponentParams:{type:Object,default:void 0},noMatchingRowsOverlayComponent:{type:Function,default:void 0},noMatchingRowsOverlayComponentParams:{type:Object,default:void 0},overlayComponent:{type:Function,default:void 0},overlayComponentParams:{type:Object,default:void 0}},b=`__expand__`,x=`__detail`,S=`mg-cell__row-expand`,C=`mg-cell__row-expand--expanded`,w=`mg-full-width-rows-container`,T=`mg-full-width-row`,E=`mg-full-width-row__content`,D=`mg-full-width-row--last`;function O(e){return!0}function k(e={}){return{masterDetail:e.masterDetail??!1,isRowMaster:e.isRowMaster??O,masterDefaultExpanded:e.masterDefaultExpanded??0,detailRowHeight:e.detailRowHeight??200,detailRowAutoHeight:e.detailRowAutoHeight??!1,embedFullWidthRows:e.embedFullWidthRows??!1,showExpandColumn:e.showExpandColumn??!1,getDetailRowData:e.getDetailRowData,detailCellRenderer:e.detailCellRenderer}}function A(e){return e===b}function j(e){return A(e.colId)||e.rowExpand}function M(e,n){return t.it(n)||t.X(n)||A(n)?!1:e??!1}function ee(e,t){return M(e.rowExpand,t)}function N(e){return e??`BUSINESS`}function P(e){return`${e}${x}`}function F(e){return e.endsWith(x)}function I(e){return N(e.rowKind)===`DETAIL`||F(e.id)}function te(e){return N(e.rowKind)===`BUSINESS`&&!F(e.id)}function ne(e,t){let n=typeof e==`function`?e(t):e;return!Number.isFinite(n)||n<1?200:Math.floor(n)}function re(e,t){return{rowId:e,expanded:!0,source:t}}function ie(e,t){return{rowId:e,expanded:!1,source:t}}function ae(e){return e.available!==!1}function oe(e){return e.filter(ae)}var se=`__group__`,ce=`group::`,le=`__header`,ue=`__footer`,de=`(Blanks)`,fe=`mg-cell__group-expand`,pe=`mg-cell__group-expand--expanded`,me=`mg-cell__group-indent-`,he=`mg-row--group-header`,ge=`mg-row--group-footer`,_e=`mg-cell--group-auto`;function ve(e={}){return{rowGrouping:e.rowGrouping??!1,groupDefaultExpanded:e.groupDefaultExpanded??-1,showGroupHeader:e.showGroupHeader??!1,showGroupFooter:e.showGroupFooter??!1,groupDisplayType:e.groupDisplayType??`singleColumn`,showGroupColumn:e.showGroupColumn??!1,autoGroupColumnDef:e.autoGroupColumnDef,groupKeyCreator:e.groupKeyCreator,groupComparator:e.groupComparator,groupSortKey:e.groupSortKey,groupFooterLabel:e.groupFooterLabel??`小计`,groupCellRenderer:e.groupCellRenderer}}function L(e){return e===se}function ye(e){return L(e.colId)}function be(e,n){return t.it(n)||t.X(n)||A(n)||L(n)?!1:e??!1}function xe(e,t){return be(e.rowGroup,t)}function Se(e,t){if(xe(e,t))return e.rowGroupIndex}function Ce(e,n){if(!(t.it(n)||t.X(n)||A(n)||L(n)))return e.groupAgg}function we(e,n){return t.it(n)||t.X(n)||A(n)||L(n)?!1:e.showGroupHeaderCell??!1}function Te(e,n){return t.it(n)||t.X(n)||A(n)||L(n)?!1:e.showGroupFooterCell??!1}function Ee(e,n){if(!(t.it(n)||t.X(n)||A(n)||L(n)))return e.groupFooterLabel}function De(e){return ye(e)||e.showGroupHeaderCell}function Oe(e){return ye(e)||e.showGroupFooterCell}function ke(e,t){return Ue(t)?Ve(t)?De(e):He(t)?Oe(e):!1:!1}function Ae(e){let n=oe(e).map((e,n)=>{let r=t.at(e,n);return{colId:r,rowGroup:xe(e,r),rowGroupIndex:e.rowGroupIndex,index:n}}).filter(e=>e.rowGroup);return n.sort((e,t)=>{let n=e.rowGroupIndex??e.index,r=t.rowGroupIndex??t.index;return n===r?e.index-t.index:n-r}),n.map(e=>e.colId)}function je(e,t){return e&&t}function Me(e,t){return e&&t.length>0}function Ne(e){if(e==null||e===``)return de;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);if(e instanceof Date)return Number.isNaN(e.getTime())?de:e.toISOString();try{return JSON.stringify(e)}catch{return de}}function Pe(e,t,n,r){let i=`${ce}L${e}::${encodeURIComponent(t)}::${encodeURIComponent(n)}`;return r?`${r}::${i}`:i}function Fe(e){return e.join(`/`)}function Ie(e){return`${e}${le}`}function Le(e){return`${e}${ue}`}function Re(e){return e.endsWith(le)}function ze(e){return e.endsWith(ue)}function Be(e){return Re(e)||ze(e)?e.slice(0,-8):null}function Ve(e){return e.rowKind===`GROUP_HEADER`||Re(e.id)}function He(e){return e.rowKind===`GROUP_FOOTER`||ze(e.id)}function Ue(e){return e.group===!0||Ve(e)||He(e)}function R(e){return Ue(e)?!1:e.rowKind===void 0||e.rowKind===`BUSINESS`}function We(e){return{groupId:e.groupId,expanded:e.expanded,field:e.field,key:e.key,level:e.level,source:e.source}}function Ge(e,t){return{columns:[...e],source:t}}var Ke=`__tree__`,qe=`mg-cell__tree-expand`,Je=`mg-cell__tree-expand--expanded`,Ye=`mg-cell__tree-expand--loading`,Xe=`mg-cell__tree-indent-`,Ze=`mg-cell__tree-hierarchy-trigger`,Qe=`mg-cell__tree-hierarchy-actions`,$e=`mg-cell--tree-auto`;function et(e){return e||(({data:e,dataPath:t})=>{Array.isArray(e.pathSegments)&&(e.pathSegments=[...t])})}function tt(e={}){let t=e.treeLazyLoad??!1,n=e.loadTreeChildren;return t&&typeof n!=`function`&&console.warn(`[magic-grid] treeLazyLoad: true requires loadTreeChildren callback.`),{tree:e.tree??!1,getDataPath:e.getDataPath,treeDragScope:e.treeDragScope??`siblings`,setDataPath:et(e.setDataPath),treeHierarchyActions:e.treeHierarchyActions??!0,showTreeColumn:e.showTreeColumn??!0,autoTreeColumnDef:e.autoTreeColumnDef,treeValueGetter:e.treeValueGetter,treeDisplayType:e.treeDisplayType??`singleColumn`,treeLazyLoad:t,hasTreeChildren:e.hasTreeChildren,loadTreeChildren:n}}function z(e){return e===Ke}function nt(e,t){return e===!0&&typeof t==`function`}function rt(e,t,n){return nt(e,n)&&t!==!1}function B(e){return e.dataPath!=null&&e.dataPath.length>0}function it(e){e.forEach((e,n)=>{let r=t.at(e,n);(r===`__tree__`||t.it(r)||t.X(r)||A(r)||L(r))&&console.warn(`[magic-grid] Column colId "${r}" is reserved for system columns and will be ignored.`)})}function at(e,t,n,r,i){return{rowId:e,expanded:t,level:n,dataPath:r,source:i}}function ot(e,t){if(e&&typeof t!=`function`)throw Error(`[magic-grid] tree: true requires getDataPath callback.`)}var st=`__mg_summary__`;function ct(e={}){return{showSummary:e.showSummary??!1,summaryScope:e.summaryScope??`displayed`,summaryRowHeight:e.summaryRowHeight,summaryMethod:e.summaryMethod}}function lt(e,t){return e??t}var ut=`mg-cell--disabled`,dt=`data-disabled`,ft=`mg-cell--disabled-icon-hint`,pt=`mg-cell__disabled-indicator`;function mt(e={}){return{isRowDisabled:e.isRowDisabled}}function ht(e){return t.it(e)||t.X(e)||A(e)||z(e)||L(e)}function gt(e,t,n,r){return!((t??`BUSINESS`)!==`BUSINESS`||r===`__mg_summary__`||!n||ht(e))}function _t(e,t){return t==null||t===!1?!1:t===!0||t(e)}function vt(e){let{column:t,rowNode:n,isRowDisabled:r}=e;if(!gt(t.colId,n.rowKind,t.prop,n.id))return!1;if(_t({data:n.data,rowId:n.id,rowIndex:n.rowIndex},r)||t.disabled===!0)return!0;let{cellDisabled:i}=t;return i===!0||typeof i==`function`&&i({data:n.data,rowId:n.id,colId:t.colId})}function yt(e={}){return mt(e)}function bt(e,t,n){return vt({column:e,rowNode:t,isRowDisabled:n?.isRowDisabled})}function xt(e,t){return{...e,isRowDisabled:t}}var St=`data-custom-bg`,Ct=`mg-cell--editable`,wt=`mg-cell--editable-hint`,Tt=`mg-cell__editable-indicator`;function Et(e){return e.backgroundColor===void 0&&e.color===void 0}function Dt(e,t,n){console.warn(`[magic-grid] setCellStyle: ignored (${n}).`,{rowId:e,colId:t})}function Ot(e){return t.it(e)||A(e)||z(e)||L(e)}function kt(e,n,r,i){return(n??`BUSINESS`)!==`BUSINESS`||i===`__mg_summary__`?!1:t.X(e)?!0:!(!r||Ot(e))}function At(e,t){return kt(e.colId,t.rowKind,e.prop,t.id)}function jt(e){return typeof e==`function`}function Mt(e){let{cellStyle:t}=e;return t==null||jt(t)?null:t}function Nt(e){return e.backgroundColor!==void 0&&e.backgroundColor!==``}function Pt(e,t){let n=e.cellEditorParams;if(n!=null)return typeof n==`function`?n(t):n}function Ft(e,t){let n=e.cellEditorParams;if(n!=null)return typeof n==`function`?t?Pt(e,t):void 0:n}function It(e,t){return Ft(e,t)}function Lt(e){if(!e)return;let{checkedValue:t,uncheckedValue:n}=e;if(t!==void 0||n!==void 0)return{checkedValue:t,uncheckedValue:n}}function Rt(e){if(!e)return;let{onValue:t,offValue:n}=e;if(t!==void 0||n!==void 0)return{onValue:t,offValue:n}}function zt(e,t){return Lt(It(e,t))}function Bt(e,t){return Rt(It(e,t))}function Vt(e){return{rowId:e.rowId,rowIndex:e.rowIndex,colId:e.colId,value:e.value,data:e.data,formattedValue:e.formattedValue,size:e.size,context:e.context,inline:e.inline,autoFocus:e.autoFocus}}function Ht(e,t){let n=It(e,Vt(t)),r=n==null?t.cellEditorParams:{...t.cellEditorParams,...n};return{...t,cellEditorParams:r}}var Ut=Symbol(`TOGGLE_EDITOR_RAW_VALUE_REJECTED`);function Wt(e){return e?{onValue:e.checkedValue,offValue:e.uncheckedValue}:null}function Gt(e){return{onValue:e?.onValue??!0,offValue:e?.offValue??!1}}function Kt(e){return e?.onValue!==void 0||e?.offValue!==void 0}function qt(e,t){return Object.is(e,t)}function Jt(e,t){let{onValue:n,offValue:r}=Gt(t);return qt(e,n)?!0:qt(e,r)||Kt(t)||e==null||e===``||e===!1||e===`false`||e===0||e===`0`?!1:e===!0||e===`true`||e===1||e===`1`||!!e}function Yt(e){return JSON.stringify(e)}function Xt(e,t){let{onValue:n,offValue:r}=Gt(t);return Yt(e?n:r)}function Zt(e,t){return Xt(e.checked,t)}function Qt(e,t){let{onValue:n,offValue:r}=Gt(t),i=Yt(n),a=Yt(r);if(e===i)return n;if(e===a)return r;if(!Kt(t)){if(e===`true`)return!0;if(e===`false`)return!1}return Ut}var $t=Ut;function en(e){let t=Gt(Wt(e));return{checkedValue:t.onValue,uncheckedValue:t.offValue}}function tn(e,t){return Jt(e,Wt(t))}function nn(e,t){return Xt(e,Wt(t))}function rn(e,t){return Zt(e,Wt(t))}function an(e,t){return Qt(e,Wt(t))}function on(e){return e.cellEditor===`checkbox`?Wt(zt(e)):e.cellEditor===`switch`?Bt(e)??null:null}var sn=Symbol(`CELL_EDIT_REJECTED`);function cn(e){return e===sn}function ln(e){return t.it(e.colId)||t.X(e.colId)||j({colId:e.colId,rowExpand:!1})}function un(e,t){let{editable:n}=e;return n===void 0||n===!1?!1:n===!0||n(t)}function V(e,t,n){return!R(t)||ln(e)||!e.prop||bt(e,t,n)?!1:un(e,t.data)}function dn(e,t=`singleClick`){return e.editType??t}function fn(e){return{editBehavior:e.editBehavior??`cell`,editType:e.editType??`singleClick`}}function pn(e){return e===`row`}function mn(e){let t=e.trim();if(t===``)return sn;let n=Number(t);return Number.isFinite(n)?n:sn}function hn(e,t){let n=an(e,t);return n===$t?sn:n}function gn(e,t){let n=Qt(e,t);return n===Ut?sn:n}function _n(e,t,n){try{return t.valueParser?t.valueParser(e,n):t.cellEditor===`number`?mn(e):t.cellEditor===`checkbox`?hn(e,Lt(n.cellEditorParams)??zt(t)):t.cellEditor===`switch`?gn(e,Rt(n.cellEditorParams)??Bt(t)):e}catch{return sn}}function vn(e,t,n){if(e.valueSetter){let r=e.valueSetter({...t,newValue:n,signal:new AbortController().signal});if(r instanceof Promise)throw Error(`Async valueSetter requires applyCellEditValue / commitRowEditCells`);return r}let r=e.prop;return r?(t.data[r]=n,!0):!1}async function yn(t,n,r,i){let a=i??new AbortController().signal;if(e.l(a),t.valueSetter)try{let i=await t.valueSetter({...n,newValue:r,signal:a});return e.l(a),i}catch(t){if(e.c(t))throw t;return!1}let o=t.prop;return o?(n.data[o]=r,!0):!1}var bn=Symbol.for(`magic-grid.vueCellEditor`);function xn(e){return Object.defineProperty(e,bn,{value:!0,configurable:!0}),e}function Sn(e){return e?Reflect.get(e,bn)===!0:!1}var Cn=[`text`,`number`,`checkbox`,`switch`];function wn(e){return Cn.includes(e)}function Tn(e){let t={};for(let n of[e.row,e.column,e.cell,e.override,e.editable,e.disabled])n&&(n.backgroundColor!==void 0&&(t.backgroundColor=n.backgroundColor),n.color!==void 0&&(t.color=n.color));return t}function En(e,t){return{data:t.data,rowId:t.id,colId:e.colId,rowIndex:t.rowIndex,column:{colId:e.colId,prop:e.prop}}}function Dn(e,t){let n=t?.rowStyle;return n==null?null:typeof n==`function`?n({data:e.data,rowId:e.id,rowIndex:e.rowIndex,rowKind:e.rowKind})??null:n}function On(e,t){let{cellStyle:n}=e;return n==null||!jt(n)?null:n(En(e,t))??null}function kn(e,t,n){return At(e,t)?V(e,t,n?.getCellDisableContext?.()):!1}function An(e,t,n){return At(e,t)?bt(e,t,n?.getCellDisableContext?.()):!1}function jn(e,t){return e==null||Et(e)||!t?null:e}function Mn(e,t,n){return e??t?n:!1}function Nn(e,n,r,i){return!t.V(e)&&Mn(n,r,i)}function Pn(e,t,n){return jn(n?.editableCellStyle,kn(e,t,n))}function Fn(e,t,n){return Nn(e,n?.showEditableCellIcon,!1,kn(e,t,n))}function In(e,t,n){return jn(n?.disabledCellStyle,An(e,t,n))}function Ln(e,t,n){return Nn(e,n?.showDisabledCellIcon,!1,An(e,t,n))}function Rn(e,t,n){if(!At(e,t))return{};let r=n?.getCellStyleOverride?.(t.id,e.colId);return Tn({row:Dn(t,n),column:Mt(e),cell:On(e,t),override:r??null,editable:Pn(e,t,n),disabled:In(e,t,n)})}function zn(){return{key:b,label:``,width:40,minWidth:40,fixed:`left`,sortable:!1,filterable:!1,editable:!1,resizable:!1,headerAlign:`center`,align:`center`,valign:`center`}}function Bn(e={}){return{key:se,label:`分组`,width:200,minWidth:120,fixed:`left`,sortable:!1,filterable:!1,editable:!1,resizable:!0,headerAlign:`left`,align:`left`,valign:`center`,...e}}function Vn(e={}){return{key:Ke,label:`树`,width:200,minWidth:120,fixed:`left`,sortable:!1,filterable:!1,editable:!1,resizable:!0,headerAlign:`left`,align:`left`,valign:`center`,...e}}function Hn(e){return{key:t.tt,label:e.label,width:e.width,minWidth:40,fixed:`left`,sortable:!1,filterable:!1,editable:!1,resizable:!1,headerAlign:e.headerAlign,headerValign:e.headerValign,align:e.align,valign:e.valign,footerAlign:e.footerAlign,footerValign:e.footerValign}}function Un(e){return{key:t.J,label:``,width:e.width,minWidth:40,fixed:`left`,sortable:!1,filterable:!1,editable:!1,resizable:!1,headerAlign:e.headerAlign,headerValign:e.headerValign,align:e.align,valign:e.valign,footerAlign:e.footerAlign,footerValign:e.footerValign}}function Wn(e,n,r=t.Z(),i={}){let a=[];n.showIndexColumn&&a.push(Hn(n.indexColumn)),r.enabled&&a.push(Un(r.selectionColumn));let o=i.rowExpansion;o?.masterDetail&&o.showExpandColumn&&a.push(zn());let s=i.treeTable;if(s&&rt(s.tree,s.showTreeColumn,s.getDataPath))a.push(Vn(s.autoTreeColumnDef??{}));else{let e=i.rowGrouping;e&&je(e.rowGrouping,e.showGroupColumn)&&a.push(Bn(e.autoGroupColumnDef??{}))}return[...a,...e]}function H(e,t){let n=t.prop??t.colId,r=n?e.data[n]:void 0;return t.valueGetter&&(r=t.valueGetter(e.data,r)),r}var Gn=`default`,Kn={mini:{spacing:4,fontSize:12,borderRadius:4,rowHeight:20,headerHeight:20,statusBarHeight:20,checkboxSize:12},small:{spacing:8,fontSize:12,borderRadius:8,rowHeight:24,headerHeight:24,statusBarHeight:24,checkboxSize:12},default:{spacing:8,fontSize:12,borderRadius:8,rowHeight:32,headerHeight:32,statusBarHeight:32,checkboxSize:14},large:{spacing:12,fontSize:14,borderRadius:8,rowHeight:40,headerHeight:40,statusBarHeight:40,checkboxSize:14}};function qn(e){let{rounded:t=!1,sizeBorderRadius:n}=e;return t===!0?n:typeof t==`number`?Math.max(0,t):0}function Jn(e={}){let t=e.size??`default`,n=Kn[t],r=e.rowHeight!=null,i=e.headerHeight!=null;return{size:t,spacing:n.spacing,fontSize:n.fontSize,borderRadius:n.borderRadius,rowHeight:r?e.rowHeight:n.rowHeight,headerHeight:i?e.headerHeight:n.headerHeight,statusBarHeight:n.statusBarHeight,checkboxSize:n.checkboxSize,rowHeightOverridden:r,headerHeightOverridden:i}}function Yn(e,t){return e==null||e===`auto`||!Number.isFinite(e)?t:Math.max(12,Math.trunc(e))}function Xn(e){return Math.max(12,e-6)}function Zn(e){return e+16}function Qn(e){return Math.max(12,e-16)}function $n(e=Gn){return Zn(Kn[e].statusBarHeight)}function er(e){return Math.max(12,e-8)}function tr(e){return Kn[e].statusBarHeight}var nr={mini:12,small:14,default:16,large:18};function rr(e){return nr[e]}function ir(e=Gn){return{"--mg-column-settings-button-size":`${tr(e)}px`,"--mg-column-settings-button-icon-size":`${rr(e)}px`}}function ar(e,t,n){let r=n??e.rowHeight,i=Xn(e.statusBarHeight),a=Zn(e.statusBarHeight),o=Qn(a),s=tr(e.size);return{"--mg-row-height":`${e.rowHeight}px`,"--mg-header-height":`${e.headerHeight}px`,"--mg-summary-row-height":`${r}px`,"--mg-status-bar-height":`${e.statusBarHeight}px`,"--mg-status-bar-control-height":`${i}px`,"--mg-load-more-row-height":`${a}px`,"--mg-load-more-control-height":`${o}px`,"--mg-column-settings-button-size":`${s}px`,"--mg-column-settings-button-icon-size":`${rr(e.size)}px`,"--mg-status-bar-font-size":`${e.fontSize}px`,"--mg-font-size":`${e.fontSize}px`,"--mg-spacing":`${e.spacing}px`,"--mg-cell-padding-x":`${e.spacing}px`,"--mg-border-radius":`${t}px`,"--mg-checkbox-size":`${e.checkboxSize}px`,"--mg-cell-control-size":`${er(e.rowHeight)}px`}}var or=Kn.default.rowHeight,sr=Kn.default.headerHeight;function cr(e,t){let n=e.__autoHeights;if(!n)return null;let r=Object.values(n);return r.length===0?null:Math.max(t,...r)}function lr(e,t,n){if(e.rowHeightPinned&&e.rowHeight>0)return{height:e.rowHeight,estimated:!1};if(n){let t=n(e);if(t!=null&&t>0)return{height:t,estimated:!1}}let r=cr(e,t);return r==null?e.rowHeight>0?{height:e.rowHeight,estimated:e.estimated??!1}:{height:t,estimated:!1}:{height:r,estimated:e.estimated??!1}}function ur(e,t){let n=0;for(let r=0;r<e.length;r++){let i=e[r];i.rowIndex=r,i.rowTop=n,i.rowHeight=t,i.estimated=!1,n+=t}}function dr(e,t){let n=0;for(let r=0;r<e.length;r++){let i=e[r],{height:a,estimated:o}=lr(i,t.defaultRowHeight,t.getRowHeight);i.rowIndex=r,i.rowTop=n,i.rowHeight=a,i.estimated=o,n+=a}}function fr(e,t){if(typeof t==`number`){ur(e,t);return}dr(e,t)}function pr(e){if(e.length===0)return 0;let t=e[e.length-1];return t.rowTop+t.rowHeight}var mr=[`group`,`filter`,`sort`,`aggregate`,`map`],hr=[`tree`,`filter`,`sort`,`map`],gr=[`sort`,`filter`,`map`];function _r(e){switch(e){case`tree`:return hr;case`group`:return mr;default:return gr}}function vr(e){return`predicate`in e}function yr(e){for(let t=0;t<e.length;t+=1)e[t].sourceIndex=t}function br(e,t){let n=e.data[t];if(typeof n==`number`&&Number.isFinite(n))return n;if(typeof n==`string`&&n!==``){let e=Number(n);if(Number.isFinite(e))return e}return 1/0}function xr(e,t){return[...e].sort((e,n)=>br(e,t)-br(n,t))}function Sr(e,t){let n=0;for(let r of e)R(r)&&(r.data[t]=n,n+=1)}function Cr(e,t){return e===t?0:e===`(Blanks)`?1:t===`(Blanks)`?-1:e.localeCompare(t)}function wr(e){return e?(t,n,r)=>e({valueA:t,valueB:n,colId:r.colId,field:r.field,level:r.level}):(e,t)=>Cr(e,t)}function Tr(e){let{sourceRows:t,rowGroupColumns:n}=e;return n.length===0||t.length===0?[...t]:Er({rows:t,level:0,parentGroupId:void 0,parentPathIds:[],rowGroupColumns:n,getCellValue:e.getCellValue,groupKeyCreator:e.groupKeyCreator,groupComparator:e.groupComparator,groupSortKey:e.groupSortKey,getColumnField:e.getColumnField})}function Er(e){let{rows:t,level:n,parentGroupId:r,parentPathIds:i,rowGroupColumns:a,getCellValue:o,groupKeyCreator:s,groupComparator:c,groupSortKey:l,getColumnField:u}=e;if(t.length===0)return[];if(n>=a.length)return kr(t,Fe(i)),l?xr(t,l):[...t];let d=a[n],f=u?.(d)??d,p=Dr(t,d,f,o,s),m=wr(c),h={colId:d,field:f,level:n};return[...p.keys()].sort((e,t)=>m(e,t,h)).map(e=>{let t=p.get(e),m=Pe(n,f,e,r),h=[...i,m],g=Er({rows:t,level:n+1,parentGroupId:m,parentPathIds:h,rowGroupColumns:a,getCellValue:o,groupKeyCreator:s,groupComparator:c,groupSortKey:l,getColumnField:u});return Ar({colId:d,field:f,key:e,level:n,groupId:m,groupPathKey:Fe(h),children:g})})}function Dr(e,t,n,r,i){let a=new Map;for(let o of e){let e=Or(o,t,n,r,i),s=a.get(e);if(s){s.push(o);continue}a.set(e,[o])}return a}function Or(e,t,n,r,i){let a=r(e,t);return Ne(i?i({field:n,colId:t,value:a,data:e.data}):a)}function kr(e,t){for(let n of e)n.leafGroupPathKey=t}function Ar(e){let t=jr(e.children);return{id:e.groupId,data:{},rowTop:0,rowHeight:0,estimated:!1,rowIndex:-1,sourceIndex:-1,group:!0,groupField:e.colId,groupKey:e.key,groupLevel:e.level,groupId:e.groupId,groupPathKey:e.groupPathKey,groupLeafCount:t,childrenAfterGroup:e.children}}function jr(e){let t=0;for(let n of e){if(n.group){let e=n.childrenAfterSort??n.childrenAfterFilter??n.childrenAfterGroup??[];t+=jr(e);continue}t+=1}return t}function Mr(e){let t=[];for(let n of e){if(n.group){t.push(...Mr(n.childrenAfterGroup??[]));continue}t.push(n)}return t}function Nr(e){return e.some(e=>e.group===!0)}function Pr(e){return e.childrenAfterGroup??[]}function Fr(e){return e.childrenAfterFilter??e.childrenAfterGroup??[]}function Ir(e){return e.childrenAfterSort??Fr(e)}function Lr(e){return Ir(e)}function Rr(e){let t=[];for(let n of e){if(n.group){t.push(...Rr(Ir(n)));continue}t.push(n)}return t}function zr(e){for(let t of e){if(!t.group)continue;let e=zr(Pr(t));t.childrenAfterFilter=e,t.groupLeafCount=jr(e)}return[...e]}function Br(e){for(let t of e){if(!t.group)continue;let e=t.childrenAfterSort??Fr(t);Br(e),t.groupLeafCount=jr(e)}}function Vr(e){return Hr(e??``)!==``}function Hr(e){return e.trim()}function Ur(e){let t=Hr(e.quickFilterText).toLowerCase();if(t===``)return!0;for(let n of e.filterableColIds){let r=e.getFilterValue(e.row,n,e.getCellValue);if(String(r??``).toLowerCase().includes(t))return!0}return!1}function Wr(e){return e.some(e=>e.dataPath!=null&&e.dataPath.length>0&&e.group!==!0)}function Gr(e){return e.childrenAfterFilter??e.childrenAfterTree??[]}function Kr(e){return e.childrenAfterSort??Gr(e)}function qr(e){let t=[];function n(e){for(let r of e){let e=Kr(r);e.length!==0&&(t.push(r.id),n(e))}}return n(e),t}function Jr(e){for(let t of e){let e=t.childrenAfterTree??[];t.childrenAfterFilter=e.length>0?Jr(e):[]}return[...e]}function Yr(e){return e!=null&&e.trim()!==``}function Xr(e){return ai(e.type)?!0:e.type===`inRange`?Yr(e.filter)&&Yr(e.filterTo):Yr(e.filter)}function Zr(e){return e?e.conditions&&e.conditions.length>0?e.conditions:[{type:e.type,filter:e.filter,filterTo:e.filterTo}]:[]}function Qr(e){return e.operator??`AND`}function $r(e){return e?.setValues}function ei(e){return Zr(e).some(Xr)}function ti(e){return e.setValues!==void 0}function ni(e){return e??`text`}function ri(e){return{caseSensitive:e?.caseSensitive??!0,locale:e?.locale}}function ii(e){return e!=null&&e.trim()!==``}function ai(e){return e===`blank`||e===`notBlank`}function oi(e){return e?vr(e)?!0:ei(e)||ti(e):!1}function si(e,t){return oi(t[e])}function ci(e,t){if(ii(t))return!0;for(let t of Object.values(e))if(oi(t))return!0;return!1}var li=`__mg_blank__`,ui=/^\d{4}-\d{2}-\d{2}$/;function di(e){return!!(e==null||typeof e==`number`&&Number.isNaN(e)||typeof e==`string`&&e.trim()===``)}function fi(e){return e.toISOString().slice(0,10)}function pi(e){if(di(e))return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:fi(e);if(typeof e==`number`){let t=new Date(e);return Number.isNaN(t.getTime())?null:fi(t)}let t=String(e).trim();if(t===``)return null;if(ui.test(t))return t;let n=Date.parse(t);return Number.isNaN(n)?null:fi(new Date(n))}function mi(e){if(di(e))return null;let t=Number(e);return Number.isNaN(t)?null:t}function hi(e,t){if(di(e))return li;switch(t){case`number`:{let t=mi(e);return t===null?li:String(t)}case`date`:return pi(e)??`__mg_blank__`;default:return String(e)}}function gi(e,t){return e===`__mg_blank__`?`(空白)`:e}function _i(e,t){return e===`__mg_blank__`?-1:t===`__mg_blank__`?1:e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`})}function vi(e){let t=new Map;for(let n of e.rows){let r=hi(e.getFilterValue(n),e.filterType);t.set(r,(t.get(r)??0)+1)}return[...t.keys()].sort(_i).map(t=>({key:t,label:gi(t,e.filterType),blank:t===li}))}var yi=/^\d{4}-\d{2}-\d{2}$/;function bi(e){return!!(e==null||typeof e==`number`&&Number.isNaN(e)||typeof e==`string`&&e.trim()===``)}function xi(e,t){let n=String(e??``);return t?n:n.toLowerCase()}function Si(e,t){return t?e:e.toLowerCase()}function Ci(e){return e.toISOString().slice(0,10)}function wi(e){if(bi(e))return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:Ci(e);if(typeof e==`number`){let t=new Date(e);return Number.isNaN(t.getTime())?null:Ci(t)}let t=String(e).trim();if(t===``)return null;if(yi.test(t))return t;let n=Date.parse(t);return Number.isNaN(n)?null:Ci(new Date(n))}function Ti(e){if(bi(e))return null;let t=Number(e);return Number.isNaN(t)?null:t}function Ei(e,t,n){let r=n(e);return t===`blank`?r:!r}function Di(e,t,n){if(ai(t.type))return Ei(e,t.type,bi);let r=t.filter??``,i=xi(e,n.caseSensitive),a=Si(r,n.caseSensitive);switch(t.type){case`contains`:return i.includes(a);case`notContains`:return!i.includes(a);case`equals`:return i===a;case`notEqual`:return i!==a;case`startsWith`:return i.startsWith(a);case`endsWith`:return i.endsWith(a);default:return!1}}function Oi(e,t){if(ai(t.type))return Ei(e,t.type,e=>Ti(e)===null);let n=Ti(e),r=Ti(t.filter);if(n===null||r===null)return!1;switch(t.type){case`equals`:return n===r;case`notEqual`:return n!==r;case`lessThan`:return n<r;case`lessThanOrEqual`:return n<=r;case`greaterThan`:return n>r;case`greaterThanOrEqual`:return n>=r;default:return Di(e,t,{caseSensitive:!0})}}function ki(e,t){if(ai(t.type))return Ei(e,t.type,bi);let n=wi(e),r=t.filter?.trim()??``;if(r===``)return!1;switch(t.type){case`equals`:return n!==null&&n===r;case`notEqual`:return n===null||n!==r;case`lessThan`:return n!==null&&n<r;case`greaterThan`:return n!==null&&n>r;case`inRange`:{let e=t.filterTo?.trim()??``;return e===``||n===null?!1:n>=r&&n<=e}default:return!1}}function Ai(e,t,n){if(t.length===0)return!1;let r=hi(e,n);return t.includes(r)}function ji(e,t,n,r){switch(n){case`number`:return Oi(e,t);case`date`:return ki(e,t);default:return Di(e,t,r)}}function Mi(e,t,n,r){let i=Qr(t),a=Zr(t).filter(Xr);if(a.length===0)return!0;let o=a.map(t=>ji(e,t,n,r));return i===`OR`?o.some(Boolean):o.every(Boolean)}function Ni(e,t,n,r){let i=ei(t),a=ti(t);return!(i&&!Mi(e,t,n,r)||a&&!Ai(e,$r(t)??[],n))}var Pi=`mg-column-handle-menu`,Fi=`mg-column-handle-menu-portal`,Ii=`mg-column-handle-menu__section`,Li=`mg-column-handle-menu__item`,Ri=`mg-column-handle-menu__item-content`,zi=`mg-column-handle-menu__item-label`,Bi=`mg-column-handle-menu__item--submenu-trigger`,Vi=`mg-column-handle-menu__submenu`,Hi=`mg-column-handle-menu__submenu-panel`,Ui=`mg-column-handle-menu__divider`,Wi=`mg-column-handle-menu__filter-panel`,Gi=`mg-column-handle-menu__section--sort`,Ki=`mg-column-handle-menu__section--pin`,qi=`mg-column-handle-menu__section--filter`,Ji=`mg-column-handle-menu__section--visibility`;function Yi(e){return!t.it(e)&&!t.X(e)}function Xi(e,t=`full`){return Yi(e.colId)?t===`filter-only`?{sort:!1,pin:!1,filter:e.filterable,visibility:!1}:{sort:e.sortable,pin:!0,filter:e.filterable,visibility:!0}:{sort:!1,pin:!1,filter:!1,visibility:!1}}function Zi(e){return e.sort||e.pin||e.filter||e.visibility}function Qi(e){return e.length===0?[]:[e[0]]}function $i(e={}){return Qi(e.defaultSort??[])}function ea(e={}){return{defaultSort:$i(e),sortable:e.sortable??!1,enableHeaderSortClick:e.enableHeaderSortClick??!0,showUnsortedSortHintOnHover:e.showUnsortedSortHintOnHover??!1}}function ta(e,n,r){return t.it(r)||t.X(r)?!1:e??n}var na=`mg-column-dragging`,ra=`mg-column-dragging--drop-forbidden`,ia=5,aa=50;function oa(e={}){return{columnMovable:e.columnMovable??!0,suppressMoveWhenColumnDragging:e.suppressMoveWhenColumnDragging??!1,suppressColumnMoveAnimation:e.suppressColumnMoveAnimation??!1,allowCrossLaneColumnMove:e.allowCrossLaneColumnMove??!1}}function sa(e,t){return e!==!1&&t}var ca=`current`,la=`tree`;function ua(e={}){return{filterable:e.filterable??!1,filterSetValueMode:e.filterSetValueMode??`current`,filterSetDateLayoutMode:e.filterSetDateLayoutMode??`tree`}}function da(e,n,r){return t.it(r)||t.X(r)||A(r)||L(r)?!1:e??n}var fa=Symbol.for(`magic-grid.vueCellRenderer`);function pa(e){return Object.defineProperty(e,fa,{value:!0,configurable:!0}),e}function ma(e){return e?Reflect.get(e,fa)===!0:!1}function ha(e,t,n){return!t||e===`never`?!1:e===`always`||n===`vue`||n!==`sync`&&ma(t)}function ga(e,t,n,r){return e!==`immediate`&&ha(t,n,r)}var _a=[`immediate`,`deferred`,`placeholder-then-vue`];function va(e){return e&&_a.includes(e)?e:`deferred`}function ya(e={}){return{scrollEndFlushMs:Math.max(0,e.scrollEndFlushMs??0),frameBudgetMs:Math.max(1,e.frameBudgetMs??60),scrollEndFrameBudgetMs:e.scrollEndFrameBudgetMs??-1,cellRendererDefer:e.cellRendererDefer??`always`,deferRowDestroyOnScroll:e.deferRowDestroyOnScroll??!1,rendererFrameBudgetMs:Math.max(0,e.rendererFrameBudgetMs??20),cellRendererPresentation:va(e.cellRendererPresentation)}}var ba=`mg-cell__row-drag-handle`,xa=`mg-cell--row-dragging`,Sa=`mg-row-drop-indicator`,Ca=`mg-row-drag-ghost`,wa=`mg-row-dragging--drop-forbidden`,Ta=`magic-grid--row-drag-committing`;function Ea(e={}){return{rowDragManaged:e.rowDragManaged??!0}}function Da(e,n){return t.it(n)||t.X(n)?!1:e??!1}function Oa(e,t){return Da(e.rowDrag,t)}var ka=`row move is not allowed while sort or filter is active`;function Aa(e,t){return t&&e}function ja(e,t,n){return e?!Aa(t,n):!1}function Ma(e,t,n,r,i=!0,a){let o={rowId:e,fromIndex:t,toIndex:n,source:r,finished:i};return a?.displayIndex!==void 0&&(o.displayIndex=a.displayIndex),a?.parentRowId!==void 0&&(o.parentRowId=a.parentRowId),a?.siblingIndex!==void 0&&(o.siblingIndex=a.siblingIndex),a?.treeLevel!==void 0&&(o.treeLevel=a.treeLevel),o}function Na(e,t,n,r,i){return{rowId:e,rowIds:r&&r.length>1?[...r]:void 0,displayIndex:t,finished:n,...i?{parentRowId:i.parentRowId,siblingIndex:i.siblingIndex,treeLevel:i.treeLevel}:{}}}function Pa(e){return{rowId:e.leaderRowId,rowIds:[...e.rowIds],leaderRowId:e.leaderRowId,displayIndex:e.displayIndex,parentRowId:e.treeDrop?.parentRowId,siblingIndex:e.treeDrop?.siblingIndex,treeLevel:e.treeDrop?.treeLevel}}function Fa(e){return{commitId:e.commitId,rowId:e.leaderRowId,leaderRowId:e.leaderRowId,committed:e.committed,aborted:e.aborted,reason:e.reason}}function Ia(e,t,n){let r=e.hierarchyChanges?[...e.hierarchyChanges]:[],i=r.find(t=>t.rowId===e.leaderRowId),a=e.treeDrop?.parentRowId,o=a===void 0?i?.parentRowId:a===null?null:String(a);return{signal:n.signal,commitId:n.commitId,rowIds:[...e.rowIds],leaderRowId:e.leaderRowId,moves:[...e.moves],hierarchyChanges:r,displayIndex:e.displayIndex,parentRowId:o,siblingIndex:e.treeDrop?.siblingIndex??i?.siblingIndex,treeLevel:e.treeDrop?.treeLevel??i?.treeLevel,nestUnderRowId:t??void 0}}var La=`mg-cell__row-resize-handle`,Ra=`mg-cell--row-resizing`,za=`mg-cell--auto-height`;function Ba(e={},t){let n=e.rowHeightMin??t,r=e.rowHeightMax??null;return{getRowHeight:e.getRowHeight,rowHeightMin:Math.max(1,n),rowHeightMax:r==null?null:Math.max(n,r)}}function Va(e,n){return t.it(n)||t.X(n)?!1:e??!1}function Ha(e,t){return Va(e.autoHeight,t)}function Ua(e,t,n){let r=Math.max(t,e);return n==null?r:Math.min(n,r)}function Wa(e,t,n){return{rows:e.map(e=>({...e})),finished:t,source:n}}var Ga=`mg-cell--row-span`,Ka=`mg-cell--row-span-ends-table`,qa=`mg-row--span-top`,Ja=`mg-row--pinned-span-covered`;function Ya(e={}){return{enableCellSpan:e.enableCellSpan??!1}}function Xa(e){return e}function Za(e){return e.fixed===`left`||e.fixed===`right`}function Qa(e){return R(e)}function $a(e){return!Number.isFinite(e)||e<1?1:Math.floor(e)}function eo(e,n){if(!(t.it(n)||t.X(n)))return e}function to(e,n){if(!(t.it(n)||t.X(n)))return e}function no(e,n){if(!(t.it(n)||t.X(n)))return e}function ro(e,t){return eo(e.colSpan,t)}function io(e,t){return to(e.rowSpan,t)}function ao(e,t){return no(e.spanRows,t)}function oo(e,t){return e?`rowSpan`:t===!0||typeof t==`function`?`spanRows`:`none`}function so(e){return e===!0||typeof e==`function`}var co=`__MG_LOAD_MORE__`,lo=$n(Gn),uo=`mg-full-width-row--load-more`,fo=`mg-full-width-row__load-more-anchor`;function po(e={}){return{loadMore:e.loadMore?.trim()||`加载更多`,loading:e.loading?.trim()||`加载中...`,exhausted:e.exhausted?.trim()||`没有更多`}}function mo(e={},t=Gn){let n=e.loadMoreRowHeight??$n(t);return{enabled:e.loadMoreRowEnabled===!0,height:Number.isFinite(n)&&n>0?Math.floor(n):lo,loading:e.loadMoreRowLoading===!0,hasMore:e.loadMoreRowHasMore!==!1,labels:po(e.loadMoreRowLabels),loadMoreRowRenderer:e.loadMoreRowRenderer}}function ho(e){return e===co}function go(e){return e.rowKind===`LOAD_MORE`||ho(e.id)}var _o=[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`}]],vo=[[`path`,{d:`M20 6 9 17l-5-5`}]],yo=[[`path`,{d:`m7 6 5 5 5-5`}],[`path`,{d:`m7 13 5 5 5-5`}]];function bo(e,t){let n=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);n.setAttribute(`class`,e),n.setAttribute(`viewBox`,`0 0 24 24`),n.setAttribute(`fill`,`none`),n.setAttribute(`stroke`,`currentColor`),n.setAttribute(`stroke-width`,`2`),n.setAttribute(`stroke-linecap`,`round`),n.setAttribute(`stroke-linejoin`,`round`),n.setAttribute(`aria-hidden`,`true`);for(let[e,r]of t){let t=document.createElementNS(`http://www.w3.org/2000/svg`,e);for(let[e,n]of Object.entries(r))t.setAttribute(e,String(n));n.appendChild(t)}return n}function xo(){return bo(`mg-load-more-row__icon-svg mg-load-more-row__icon-svg--loader-circle`,_o)}function So(){return bo(`mg-load-more-row__icon-svg mg-load-more-row__icon-svg--check`,vo)}function Co(){return bo(`mg-load-more-row__icon-svg mg-load-more-row__icon-svg--chevrons-down`,yo)}function wo(e,t,n=!1){let r=document.createElement(`span`);r.className=n?`mg-load-more-row__icon mg-load-more-row__icon--spin`:`mg-load-more-row__icon`,r.setAttribute(`aria-hidden`,`true`),r.append(t),e.append(r)}function To(e){let t=document.createElement(`button`);t.type=`button`,t.className=`mg-load-more-row__button`;let n=document.createElement(`span`);return n.className=`mg-load-more-row__label`,e.loading?(t.disabled=!0,wo(t,xo(),!0),n.textContent=e.labels.loading):e.hasMore?(t.disabled=!1,wo(t,Co()),n.textContent=e.labels.loadMore):(t.disabled=!1,wo(t,So()),n.textContent=e.labels.exhausted),t.append(n),t.addEventListener(`click`,()=>{e.loading||e.onLoadMore()}),t}function Eo(){return(e,t)=>{t.clear(),t.mountEl.append(To(e))}}function Do(e,t,n,r={}){let i=()=>{r.onUnmountRenderer?.(e),e.replaceChildren();let i={mountEl:e,clear:()=>{r.onUnmountRenderer?.(e),e.replaceChildren()}},a=(n??Eo())(t,i);if(typeof a==`string`){i.clear(),e.textContent=a;return}a instanceof HTMLElement&&(i.clear(),e.appendChild(a))},a=r.rowIndex??0;if(r.frameService){r.frameService.createTask(i,a,`p2`);return}i()}var Oo=`mg-cell--has-comment`,ko=`mg-cell--comment-empty`,Ao=`mg-cell-comment-popup`,jo=`mg-cell-comment-popup--readonly`,Mo=`mg-cell-comment-popup--committing`,No=`mg-cell-comment-context-menu`,Po=`mg-cell-comment-context-menu--committing`;function Fo(e={}){return{cellCommentsDataSource:e.cellCommentsDataSource,suppressCellComments:e.suppressCellComments??!1,cellCommentTrigger:e.cellCommentTrigger??`click`,cellCommentShowDelay:e.cellCommentShowDelay??180,cellCommentHideDelay:e.cellCommentHideDelay??220}}function Io(e){return e!=null&&typeof e.getComment==`function`&&typeof e.setComment==`function`}function Lo(e){return t.it(e)||t.X(e)||A(e)||z(e)||L(e)}function Ro(e,t,n){return!(t!==`BUSINESS`||n!=null&&String(n)===`__mg_summary__`||Lo(e))}function zo(e,t){return e==null?!1:typeof e==`function`?e(t):e}function Bo(e){let t={canView:!1,canCreate:!1,canEdit:!1,canDelete:!1};if(!Ro(e.colId,e.rowKind,e.rowId))return t;let n=zo(e.columnSuppress,{data:e.data,rowId:e.rowId,colId:e.colId});return e.gridSuppress===!0||n?{canView:e.hasExistingComment,canCreate:!1,canEdit:!1,canDelete:!1}:{canView:!0,canCreate:!e.hasExistingComment,canEdit:e.hasExistingComment,canDelete:e.hasExistingComment}}function Vo(e,t){return t?.readOnly?{canView:e.canView,canCreate:!1,canEdit:!1,canDelete:!1}:e}function Ho(e){return typeof e?.text==`string`&&e.text.length>0}function Uo(e,t,n,r){return{rowId:e,colId:t,comment:n,source:r}}function Wo(e,t){return`${e}::${t}`}function Go(e,t){e&&(t||console.warn(`[magic-grid] cellCommentsDataSource requires rowKey for stable (rowId, colId) keys; cell comment interactions are disabled.`))}var Ko=`copy`,qo=`mg-cell--range-selected`,Jo=`mg-cell--range-anchor`,Yo=`mg-cell-range-border`,Xo=`mg-cell-range-border--edge-top`,Zo=`mg-cell-range-border--edge-right`,Qo=`mg-cell-range-border--edge-bottom`,$o=`mg-cell-range-border--edge-left`,es=`mg-cell-range-border--fill-h`,ts=`mg-cell-range-border--fill-v`,ns=`mg-cell-range-overlay`,rs=`mg-cell--range-copy-flash`,is=`mg-cell-range-overlay--copy-flash`,as=`mg-cell--range-paste-flash`,os=`mg-cell--range-paste-blocked-flash`,ss=`mg-cell-range-paste-overlay`,cs=`mg-cell-range-paste-overlay--applied`,ls=`mg-cell-range-paste-overlay--blocked`,us=`mg-cell-range-paste-flash-layer`,ds=`mg-fill-handle`,fs=`mg-range-handle`,ps=`mg-header-cell--range-highlight`,ms=`mg-cell--index-range-highlight`;function hs(e){return t.it(e)||t.X(e)||A(e)||z(e)||L(e)}function gs(e){return hs(e)}function _s(e){let t=N(e);return t===`BUSINESS`||t===`GROUP_HEADER`||t===`GROUP_FOOTER`}function vs(e){return N(e)===`BUSINESS`}function ys(e,n){return t.it(e)||t.X(e)||A(e)?!1:_s(n)}function bs(e,t){return!gs(e)&&vs(t)}function xs(e={}){let t=e.handleMode??`off`;return t===`off`?null:t===`range`?{mode:`range`}:{mode:`fill`,direction:e.direction??`xy`,fillStrategy:e.fillStrategy??`copy`,fillReverseStrategy:e.fillReverseStrategy??`default`,setFillValue:e.setFillValue}}function Ss(e){return!e.enabled||!e.handle?null:e.handle.mode}function Cs(e){return Ss(e)===`fill`}function ws(e){return Ss(e)===`range`}function Ts(e={}){return{enableHeaderHighlight:e.enableHeaderHighlight??!0,enableIndexColumnHighlight:e.enableIndexColumnHighlight??!0}}function Es(e={}){let t=e.cellSelection;if(t===!1||t==null)return{enabled:!1,suppressMultiRanges:!0,enableColumnSelection:!1,enableCellCopy:!1,enableCellPaste:!1,handle:null};let n=t===!0?{}:t,r=e.enableCellCopy??!0,i=e.enableCellPaste??!1;return{enabled:!0,suppressMultiRanges:n.suppressMultiRanges??!0,enableColumnSelection:n.enableColumnSelection??!1,enableCellCopy:r,enableCellPaste:i,handle:xs(n)}}function Ds(e,t){return{startRowIndex:Math.min(e.rowIndex,t.rowIndex),endRowIndex:Math.max(e.rowIndex,t.rowIndex),startColId:e.colId,endColId:t.colId}}function Os(e){return e.serviceRanges.length>0?[...e.serviceRanges]:!e.enableHeaderHighlight&&!e.enableIndexColumnHighlight?[]:e.editingRanges&&e.editingRanges.length>0?[...e.editingRanges]:!e.focus||!e.focusEligible?[]:[Ds(e.focus,e.focus)]}function U(e,t){let n=Math.min(e.startRowIndex,e.endRowIndex),r=Math.max(e.startRowIndex,e.endRowIndex),i=t.indexOf(e.startColId),a=t.indexOf(e.endColId);if(i<0||a<0)return null;let o=Math.min(i,a),s=Math.max(i,a);return{top:n,bottom:r,leftColId:t[o],rightColId:t[s]}}function ks(e){return{startRowIndex:e.top,endRowIndex:e.bottom,startColId:e.leftColId,endColId:e.rightColId}}function As(e,t,n,r){if(e<n.top||e>n.bottom)return!1;let i=r.indexOf(t);if(i<0)return!1;let a=r.indexOf(n.leftColId),o=r.indexOf(n.rightColId);return a<0||o<0?!1:i>=a&&i<=o}function js(e,t){return e.startRowIndex===t.startRowIndex&&e.endRowIndex===t.endRowIndex&&e.startColId===t.startColId&&e.endColId===t.endColId}function Ms(e,t){let n=Math.min(e.startRowIndex,e.endRowIndex),r=Math.max(e.startRowIndex,e.endRowIndex);return[{rowIndex:n,colId:e.startColId},{rowIndex:n,colId:e.endColId},{rowIndex:r,colId:e.startColId},{rowIndex:r,colId:e.endColId}].every(e=>ys(e.colId,t(e.rowIndex)))}function Ns(e,t,n){if(hs(e)||t<=0)return null;let r=-1,i=-1;for(let a=0;a<t;a++)ys(e,n(a))&&(r<0&&(r=a),i=a);return r<0||i<0?null:{startRowIndex:r,endRowIndex:i,startColId:e,endColId:e}}function Ps(e,t,n){let r=null,i=null;for(let a of e)ys(a,t(n))&&(r??=a,i=a);return r==null||i==null?null:{startColId:r,endColId:i}}function Fs(e){if(e.length===0)return[];let t=[...e].sort((e,t)=>e-t),n=[],r=t[0],i=t[0];for(let e=1;e<t.length;e++){let a=t[e];if(a===i+1){i=a;continue}n.push({top:r,bottom:i}),r=a,i=a}return n.push({top:r,bottom:i}),n}function Is(e){let{focusedRowIndices:t,displayedColIds:n,rowKindAt:r,suppressMultiRanges:i,currentRowIndex:a}=e,o=[...t].filter(e=>_s(r(e))).sort((e,t)=>e-t);if(o.length===0)return[];let s=Ps(n,r,o[0]);if(!s)return[];if(i){if(o.length===1||o.every((e,t)=>t===0||e===o[t-1]+1))return[{startRowIndex:o[0],endRowIndex:o[o.length-1],startColId:s.startColId,endColId:s.endColId}];let e=a??o[o.length-1];return _s(r(e))?[{startRowIndex:e,endRowIndex:e,startColId:s.startColId,endColId:s.endColId}]:[]}return Fs(o).map(({top:e,bottom:t})=>({startRowIndex:e,endRowIndex:t,startColId:s.startColId,endColId:s.endColId}))}function Ls(e){let t=new Set(e.rangeRowIndices);for(let n of e.indexFocusedRowIds){let r=e.rowIndexById(n);r>=0&&t.add(r)}for(let n of e.selectedRowIds){let r=e.rowIndexById(n);r>=0&&t.add(r)}return t}function Rs(e,t){console.warn(`[magic-grid] addCellRange: ignored invalid range (${t}).`,e)}function zs(e){return t.it(e)||t.X(e)||A(e)||z(e)||L(e)}function Bs(e,t){return!zs(e)&&t.hidden===!0}function Vs(e){return!e.hidden}function Hs(e){return e.filter(e=>Vs(e))}function Us(e){return Hs(e).length}function Ws(e){let t=[];for(let n of e)!n.hidden||zs(n.colId)||t.push({colId:n.colId,label:n.label??n.prop??n.colId});return t}var Gs=`mg-column-settings`,Ks=`mg-column-settings__header`,qs=`mg-column-settings__body`,Js=`mg-column-settings-button`,Ys=`mg-column-settings-portal`,Xs=`mg-column-settings-popover`,Zs=`mg-column-settings-menu`,Qs=`mg-column-settings-menu__item`,$s=`mg-column-settings-menu__item-icon`,ec=`mg-column-settings-menu__item-label`,tc=`mg-column-settings-menu__divider`,nc=`mg-column-settings-menu__submenu`,rc=`mg-column-settings-menu__submenu-panel`,ic=`mg-column-settings-menu__item--submenu-trigger`,ac=`mg-column-settings__clear-filters`,oc=`mg-column-settings__group`,sc=`mg-column-settings__group-heading`,cc=`mg-column-settings__row`,lc=`mg-column-settings__row--filtered`,uc=`mg-column-settings__hidden-section`;function dc(e){return!zs(e)}function fc(e){return e===`left`?`left`:e===`right`?`right`:`center`}function pc(e){return e.label??e.prop??e.colId}function mc(e){let t=new Map,n={left:0,center:0,right:0};for(let r of e){if(r.hidden||!dc(r.colId))continue;let e=fc(r.fixed);t.set(r.colId,n[e]),n[e]++}return t}function hc(e){let t=e.sortModel[0],n=t?.colId,r=t?.sort??null,i=e.includeHidden??!0,a=e.columns.filter(e=>!(!dc(e.colId)||!i&&e.hidden)),o=mc(a);return a.map(t=>{let i=fc(t.fixed),a=t.hidden?-1:o.get(t.colId)??-1;return{colId:t.colId,label:pc(t),movable:t.movable,sortable:t.sortable,filterable:t.filterable,fixed:t.fixed??null,hidden:t.hidden,sortDirection:t.colId===n?r:null,filterActive:e.isColumnFilterActive(t.colId),displayIndex:a,lane:i}})}function gc(e){let t=e.filter(e=>!e.hidden),n=e.filter(e=>e.hidden);return{left:t.filter(e=>e.lane===`left`),center:t.filter(e=>e.lane===`center`),right:t.filter(e=>e.lane===`right`),hidden:n}}var _c=`.mg-cell__text:not([hidden])`,vc=`.mg-cell__renderer:not([hidden])`,yc=`.mg-header-cell__text`,bc=`.mg-footer-cell__text:not([hidden])`,xc=[`.mg-status-bar__panel`,`[data-mg-tooltip-anchor]`].join(`, `),Sc=[_c,vc,yc,bc].join(`, `),Cc=`mg-tooltip`;function wc(e){return t.it(e)||t.X(e)||A(e)||z(e)||L(e)}function Tc(e,t){return wc(e)?!0:t.suppressTooltip===!0}function Ec(e={}){let t=e.enableTooltips??!0;return{enableTooltips:t,tooltipShowMode:e.tooltipShowMode??(t?`whenTruncated`:`never`),tooltipShowDelay:e.tooltipShowDelay??500,tooltipSwitchShowDelay:e.tooltipSwitchShowDelay??200,tooltipHideDelay:e.tooltipHideDelay??3e3,tooltipInteraction:e.tooltipInteraction??!1,tooltipMouseTrack:e.tooltipMouseTrack??!1,tooltipComponent:e.tooltipComponent,tooltipComponentParams:e.tooltipComponentParams}}function Dc(e){return e.scrollWidth-e.clientWidth>1||e.scrollHeight-e.clientHeight>1}function Oc(e){try{return e.matches(vc)}catch{return!1}}function kc(e){if(e.children.length!==1)return e;let t=e.children[0];if(!(t instanceof HTMLElement))return e;let n=t;for(;n.childElementCount===1;){let e=n.firstElementChild;if(!(e instanceof HTMLElement)||!e.textContent?.trim())break;n=e}return n}function Ac(e,t){if(!e||typeof document>`u`)return 0;if(typeof getComputedStyle==`function`){let n=getComputedStyle(t),r=document.createElement(`canvas`).getContext(`2d`);if(r){r.font=(n.font||`${n.fontStyle} ${n.fontVariant} ${n.fontWeight} ${n.fontSize} ${n.fontFamily}`).trim()||`12px sans-serif`;let t=Number.parseFloat(n.paddingLeft)||0,i=Number.parseFloat(n.paddingRight)||0,a=r.measureText(e).width+t+i;if(a>0)return a}}let n=document.createElement(`span`);if(n.textContent=e,n.style.cssText=`position:fixed;left:-9999px;top:0;visibility:hidden;white-space:nowrap;pointer-events:none;max-width:none;width:max-content;`,typeof getComputedStyle==`function`){let e=getComputedStyle(t);n.style.font=e.font,n.style.letterSpacing=e.letterSpacing,n.style.textTransform=e.textTransform}document.body.appendChild(n);let r=Math.max(n.getBoundingClientRect().width,n.offsetWidth,n.scrollWidth);return document.body.removeChild(n),r}function jc(e,t,n){let r=Ac(t,kc(e));return r<=0?null:r>n+1}function Mc(e,t){let n=e.clientWidth;if(n<=0)return!1;let r=Nc(e),i=t?.trim(),a=e.textContent?.trim()??``;if(i&&a&&i!==a)return jc(e,a,n)??r;if(i){let t=jc(e,i,n);if(t!=null)return t}return r}function Nc(e){let t=e.clientWidth;if(t<=0)return!1;if(e.children.length===0)return e.scrollWidth-t>1;if(e.children.length===1){let n=e.children[0];if(!(n instanceof HTMLElement)||n.hidden)return!1;if(n.scrollWidth-t>1||Dc(n))return!0;if(n.clientWidth>=t-1){for(let e of n.children)if(!(!(e instanceof HTMLElement)||e.hidden||!e.textContent?.trim())&&Dc(e))return!0}return!1}if(Dc(e))return!0;for(let t of e.children)if(!(!(t instanceof HTMLElement)||t.hidden)&&t.textContent?.trim()&&Dc(t))return!0;return!1}function Pc(e){return!e.enableTooltips||e.mode===`never`||!e.text?!1:e.mode===`always`?!0:e.isAutoHeight?!1:Oc(e.anchorEl)?Mc(e.anchorEl,e.text):Dc(e.anchorEl)}var Fc=`加载中…`,Ic=`暂无数据`,Lc=`没有匹配的行`,Rc=`mg-overlay`,zc=`mg-overlay__wrapper`,Bc=`mg-overlay--masked`,Vc=`mg-overlay__content`,Hc=`mg-overlay__panel--loading`,Uc=`mg-overlay__panel--no-rows`,Wc=`mg-overlay__panel--no-matching-rows`,Gc=`mg-overlay__spinner`;function Kc(e){switch(e){case`loading`:return Fc;case`noRows`:return Ic;case`noMatchingRows`:return Lc;default:return e}}function qc(e={}){let t=new Set(e.suppressOverlays??[]);return e.suppressLoadingOverlay&&t.add(`loading`),e.suppressNoRowsOverlay&&t.add(`noRows`),e.suppressNoMatchingRowsOverlay&&t.add(`noMatchingRows`),t}function Jc(e={}){return{loading:e.loading,suppressOverlays:qc(e),overlayLoadingTemplate:e.overlayLoadingTemplate,overlayNoRowsTemplate:e.overlayNoRowsTemplate,overlayNoMatchingRowsTemplate:e.overlayNoMatchingRowsTemplate,loadingOverlayComponent:e.loadingOverlayComponent,loadingOverlayComponentParams:e.loadingOverlayComponentParams,noRowsOverlayComponent:e.noRowsOverlayComponent,noRowsOverlayComponentParams:e.noRowsOverlayComponentParams,noMatchingRowsOverlayComponent:e.noMatchingRowsOverlayComponent,noMatchingRowsOverlayComponentParams:e.noMatchingRowsOverlayComponentParams,overlayComponent:e.overlayComponent,overlayComponentParams:e.overlayComponentParams,overlayInteraction:e.overlayInteraction??!1}}function Yc(e,t){return t.has(e)}function Xc(e){let{rows:t,filterModel:n,getCellValue:r,columnContext:i,quickFilterText:a,quickFilterColIds:o=[]}=e,s=Object.entries(n).filter(([,e])=>oi(e)),c=Vr(a),l=Nr(t),u=!l&&Wr(t);if(l)return s.length===0&&!c?zr(t):Zc(t,s,c,{getCellValue:r,context:i??el,quickFilterText:a??``,quickFilterColIds:o});if(u)return s.length===0&&!c?Jr(t):Qc(t,s,c,{getCellValue:r,context:i??el,quickFilterText:a??``,quickFilterColIds:o});if(s.length===0&&!c)return[...t];let d=i??el;return t.filter(e=>$c(e,s,r,d,c,{quickFilterText:a??``,quickFilterColIds:o}))}function Zc(e,t,n,r){let i=[];for(let a of e){if(a.group){let e=Zc(a.childrenAfterGroup??[],t,n,r);if(e.length===0)continue;a.childrenAfterFilter=e,a.groupLeafCount=jr(e),i.push(a);continue}$c(a,t,r.getCellValue,r.context,n,{quickFilterText:r.quickFilterText,quickFilterColIds:r.quickFilterColIds})&&i.push(a)}return i}function Qc(e,t,n,r){let i=[];for(let a of e){let e=Qc(a.childrenAfterTree??[],t,n,r);!$c(a,t,r.getCellValue,r.context,n,{quickFilterText:r.quickFilterText,quickFilterColIds:r.quickFilterColIds})&&e.length===0||(a.childrenAfterFilter=e,i.push(a))}return i}function $c(e,t,n,r,i,a){return tl(e,t,n,r)&&(!i||Ur({row:e,quickFilterText:a.quickFilterText,filterableColIds:a.quickFilterColIds,getCellValue:n,getFilterValue:(e,t,n)=>r.getFilterValue(e,t,n)}))}var el={getFilterType:()=>`text`,getFilterParams:()=>({caseSensitive:!0}),getFilterValue:(e,t,n)=>n(e,t)};function tl(e,t,n,r){for(let[i,a]of t){let t=r.getFilterValue(e,i,n);if(vr(a)){if(!a.predicate(t,e.data))return!1;continue}if(!Ni(t,a,r.getFilterType(i),r.getFilterParams(i)))return!1}return!0}var nl=`合计`;function rl(e){return typeof e==`number`&&Number.isFinite(e)}function il(e,t){let n=[];for(let r of e){let e=H(r,t);rl(e)&&n.push(e)}return n}function al(e,t,n){if(e===`count`)return t.length;let r=il(t,n);if(r.length===0)return null;switch(e){case`sum`:return r.reduce((e,t)=>e+t,0);case`avg`:return r.reduce((e,t)=>e+t,0)/r.length;case`min`:return Math.min(...r);case`max`:return Math.max(...r);default:return null}}function ol(e,t,n){return typeof e==`function`?e(t,n):al(e,t,n)}function sl(e){return e.summary===!1?!1:e.summaryAgg!=null||e.summary===!0}function cl(e,t){return t==null?``:e.summaryFormatter?e.summaryFormatter(t):e.formatter?e.formatter({},t):String(t)}function ll(e,t){return{value:t,formattedValue:cl(e,t)}}function ul(e,t,n){if(!n)return null;try{let r=n({columns:e,data:t.map(e=>e.data),rows:t}),i=new Map;for(let[e,t]of Object.entries(r))t!==void 0&&i.set(e,t);return i}catch(e){return console.warn(`[magic-grid] summaryMethod failed:`,e),new Map}}function dl(e){return e.find(e=>!t.it(e.colId)&&!t.X(e.colId))}function fl(e){let{columns:n,rows:r,summaryMethod:i}=e,a=new Map,o=ul(n,r,i);for(let e of n){if(t.it(e.colId)||t.X(e.colId)){a.set(e.colId,ll(e,null));continue}let n=o?.get(e.colId);if(o?.has(e.colId)){a.set(e.colId,ll(e,n??null));continue}if(sl(e)&&e.summaryAgg!=null){let t=ol(e.summaryAgg,r,e);a.set(e.colId,ll(e,t))}}let s=dl(n);return s&&!a.has(s.colId)&&a.set(s.colId,ll(s,nl)),a}function pl(e){return Nr(e.rows)&&ml(e.rows,e.columns),[...e.rows]}function ml(e,t){for(let n of e){if(!n.group)continue;let e=Ir(n);ml(e,t),n.__groupAggValues=hl(t,Rr(e))}}function hl(e,n){let r={};for(let i of e){if(!i.groupAgg||t.it(i.colId)||t.X(i.colId)||A(i.colId)||L(i.colId))continue;let e=ol(i.groupAgg,n,i);r[i.colId]={value:e,formattedValue:cl(i,e)}}return r}function gl(e,t={}){let n=e.groupId??e.id,r=t.rowHeight??or;return{id:Ie(n),data:{},rowTop:0,rowHeight:r,estimated:!1,rowIndex:-1,sourceIndex:-1,rowKind:`GROUP_HEADER`,sourceGroupId:n,groupField:e.groupField,groupKey:e.groupKey,groupLevel:e.groupLevel,groupLeafCount:e.groupLeafCount,groupId:n,groupPathKey:e.groupPathKey}}function _l(e,t={}){let n=e.groupId??e.id,r=t.rowHeight??or;return{id:Le(n),data:{},rowTop:0,rowHeight:r,estimated:!1,rowIndex:-1,sourceIndex:-1,rowKind:`GROUP_FOOTER`,sourceGroupId:n,groupField:e.groupField,groupKey:e.groupKey,groupLevel:e.groupLevel,groupLeafCount:e.groupLeafCount,groupId:n,groupPathKey:e.groupPathKey,__groupAggValues:vl(e.__groupAggValues)}}function vl(e){if(e)return{...e}}function yl(e,t){return Nr(e)?xl(e,{expandedGroupIds:t?.expandedGroupIds??new Set,showGroupHeader:t?.showGroupHeader??!1,showGroupFooter:t?.showGroupFooter??!1,defaultRowHeight:t?.defaultRowHeight}):Wr(e)?bl(e,{expandedRowIds:t?.expandedRowIds??new Set}):[...e]}function bl(e,t){let n=[];function r(e){for(let i of e)n.push(i),t.expandedRowIds.has(i.id)&&r(Kr(i))}return r(e),n}function xl(e,t){let n=[];for(let r of e){if(!r.group){n.push(r);continue}let e=r.groupId??r.id,i=!t.showGroupHeader||t.expandedGroupIds.has(e);t.showGroupHeader&&n.push(gl(r,{rowHeight:t.defaultRowHeight})),i&&(n.push(...xl(Ir(r),t)),t.showGroupFooter&&n.push(_l(r,{rowHeight:t.defaultRowHeight})))}return n}function Sl(e,t,n){let{colId:r,sort:i}=e;return n?(e,a)=>{let o=n(t(e,r),t(a,r),i,e.data,a.data);return o===0?e.id.localeCompare(a.id):i===`desc`?-o:o}:(e,n)=>{let a=Cl(t(e,r),t(n,r),i);return a===0?e.id.localeCompare(n.id):a}}function Cl(e,t,n){let r=0;return r=e==null&&t==null?0:e==null?-1:t==null?1:typeof e==`number`&&typeof t==`number`?e-t:String(e).localeCompare(String(t)),n===`desc`?-r:r}function wl(e,t,n,r){if(t.length<4)return[...r??e].sort(n);let i=new Set(t.map(e=>e.id));return Tl(e.filter(e=>!i.has(e.id)),[...t].sort(n),n)}function Tl(e,t,n){let r=[],i=0,a=0;for(;i<e.length&&a<t.length;)n(e[i],t[a])<=0?(r.push(e[i]),i++):(r.push(t[a]),a++);for(;i<e.length;)r.push(e[i]),i++;for(;a<t.length;)r.push(t[a]),a++;return r}function El(e){let t=e.rows??e.sourceRows;if(Nr(t))return Dl({rows:t,sortModel:e.sortModel,getCellValue:e.getCellValue,getColumnComparator:e.getColumnComparator,groupComparator:e.groupComparator,groupSortKey:e.groupSortKey});if(Wr(t))return jl({rows:t,sortModel:e.sortModel,getCellValue:e.getCellValue,getColumnComparator:e.getColumnComparator});let{sourceRows:n,currentDisplayRows:r,sortModel:i,touchedRowIds:a,getCellValue:o,getColumnComparator:s}=e;if(i.length===0)return[...t];let c=i[0],l=Sl(c,o,s?.(c.colId));if(a&&a.size>0){let e=n.filter(e=>a.has(e.id));if(e.length>0&&r.length>0)return wl(r,e,l,n)}return[...t].sort(l)}function Dl(e){let t=Ol(e.rows,e);return Br(t),t}function Ol(e,t){if(e.length===0)return[];if(e[0]?.group){let n=wr(t.groupComparator);return e.map(e=>kl(e,t)).sort((e,t)=>{let r=e.groupLevel??t.groupLevel??0,i=e.groupField??t.groupField??``;return n(e.groupKey??``,t.groupKey??``,{colId:i,field:i,level:r})})}return Al(e,t)}function kl(e,t){return e.childrenAfterSort=Ol(e.childrenAfterFilter??e.childrenAfterGroup??[],t),e}function Al(e,t){if(t.sortModel.length===0)return t.groupSortKey?xr(e,t.groupSortKey):[...e];let n=t.sortModel[0],r=Sl(n,t.getCellValue,t.getColumnComparator?.(n.colId));return[...e].sort(r)}function jl(e){return Ml(e.rows,e)}function Ml(e,t){let n=Al(e,t);for(let e of n){let n=Gr(e);e.childrenAfterSort=n.length>0?Ml(n,t):[]}return n}var Nl=`\0`;function Pl(e){return e.join(Nl)}var Fl=class extends Error{constructor(e){super(e),this.name=`TreeBuildError`}};function Il(e){let{sourceRows:t,getDataPath:n}=e,r=new Map,i=t.map((e,t)=>({node:e,path:n({data:e.data}),sourceIndex:t})).sort((e,t)=>e.path.length===t.path.length?e.sourceIndex-t.sourceIndex:e.path.length-t.path.length);for(let{path:e}of i)if(!Array.isArray(e)||e.length===0)throw new Fl(`[TreeBuildStage] getDataPath must return a non-empty string[]`);for(let{node:e,path:t}of i){let n=Pl(t);if(r.has(n))throw new Fl(`[TreeBuildStage] duplicate dataPath: ${t.join(`/`)}`);e.dataPath=[...t],e.treeLevel=t.length-1,e.treeLeaf=!0,e.childrenAfterTree=[],r.set(n,e)}let a=[];for(let{node:e,path:t}of i){if(t.length===1){e.parentRowId=void 0,a.push(e);continue}let n=t.slice(0,-1),i=r.get(Pl(n));if(!i)throw new Fl(`[TreeBuildStage] missing parent path: ${n.join(`/`)}`);e.parentRowId=i.id,i.treeLeaf=!1,i.childrenAfterTree.push(e)}return{roots:a,nodeByPath:r}}function Ll(e){function t(e){for(let n of e){let e=n.childrenAfterTree??[];e.length===0?n.treeLeaf=!0:(n.treeLeaf=!1,t(e))}}t(e)}function Rl(e){let{sourceRows:t,getDataPath:n}=e;if(t.length===0)return[];let{roots:r}=Il({sourceRows:t,getDataPath:n});return Ll(r),r}var zl=[...gr];function Bl(e,t){return e.length===1&&e[0]===`map`&&t!=null&&t.groupedTreeRoots!=null&&t.groupedTreeRoots.length>0&&Nr(t.groupedTreeRoots)}function Vl(e,t){return e.length===1&&e[0]===`map`&&t!=null&&t.treeTreeRoots!=null&&t.treeTreeRoots.length>0&&Wr(t.treeTreeRoots)}function Hl(e,t){if(t)return t.getMapStageOptions?.()??t.mapStageOptions;if(e)return e.getMapStageOptions?.()??e.mapStageOptions}function Ul(e){let t=e.stages??zl,n=e.grouping,r=e.tree,i=[...e.sourceRows];if(Bl(t,n)&&n?.groupedTreeRoots)i=yl(n.groupedTreeRoots,Hl(n,void 0));else if(Vl(t,r)&&r?.treeTreeRoots)i=yl(r.treeTreeRoots,Hl(void 0,r));else for(let a of t)switch(a){case`tree`:i=r?.getDataPath?Rl({sourceRows:e.sourceRows,getDataPath:r.getDataPath}):[...e.sourceRows];break;case`group`:i=n&&n.rowGroupColumns.length>0?Tr({sourceRows:e.sourceRows,rowGroupColumns:n.rowGroupColumns,getCellValue:e.getCellValue,groupKeyCreator:n.groupKeyCreator,groupComparator:n.groupComparator,groupSortKey:n.groupSortKey,getColumnField:n.getColumnField}):[...e.sourceRows];break;case`filter`:i=Xc({rows:i,filterModel:e.filterModel,getCellValue:e.getCellValue,columnContext:e.filterColumnContext,quickFilterText:e.quickFilterText,quickFilterColIds:e.getQuickFilterColIds?.()??[]}),r&&Wr(i)&&Vr(e.quickFilterText)&&r.applyQuickFilterExpand&&r.applyQuickFilterExpand(i);break;case`sort`:i=El({sourceRows:e.sourceRows,rows:i,currentDisplayRows:e.currentDisplayRows,sortModel:e.sortModel,touchedRowIds:e.touchedRowIds,getCellValue:e.getCellValue,getColumnComparator:e.getColumnComparator,groupComparator:n?.groupComparator,groupSortKey:n?.groupSortKey});break;case`aggregate`:n&&Nr(i)&&(i=pl({rows:i,columns:n.columns}));break;case`map`:n?.prepareGroupedTree&&Nr(i)&&n.prepareGroupedTree(i),r?.prepareTreeTree&&Wr(i)&&r.prepareTreeTree(i),i=yl(i,Hl(n,r))}return e.afterMap&&(i=e.afterMap(i)),e.positionRowsOptions?fr(i,e.positionRowsOptions):fr(i,e.rowHeight),i}function Wl(e){return[..._r(e)]}var Gl=class{refreshing=!1;pendingRun=null;refresh(e){if(this.refreshing){this.pendingRun=e;return}this.refreshing=!0;try{let t=e;for(;t;){let e=t;t=null,e(),t=this.pendingRun,this.pendingRun=null}}finally{this.refreshing=!1}}reset(){this.refreshing=!1,this.pendingRun=null}};function Kl(e,t){for(let n of e)n.group&&(t(n),Kl(Lr(n),t))}function ql(e){let t=[];return Kl(e,e=>{e.groupId&&t.push(e.groupId)}),t}function Jl(e,t){let n;return Kl(e,e=>{e.groupId===t&&(n=e)}),n}function Yl(e,t){return t===0?!1:t===-1||e<t}var Xl=class extends Error{constructor(e){super(e),this.name=`RowModelError`}};function Zl(e,n){let{rowKey:r,rowHeight:i=or,allowTransient:a=!1}=n;if(!r)throw new Xl(`rowKey is required`);let o=new Set,s=[];for(let n=0;n<e.length;n++){let c=e[n],l=c[r];if(t.A(l)){if(!a)throw new Xl(`Missing rowKey "${r}" at index ${n}`);let e=t.k();if(o.has(e))throw new Xl(`Duplicate transient row id "${e}" at index ${n}`);o.add(e),s.push({id:e,data:c,isTransient:!0,rowTop:0,rowHeight:i,estimated:!1,rowIndex:s.length,sourceIndex:s.length});continue}let u=String(l);o.has(u)||(o.add(u),s.push({id:u,data:c,isTransient:!1,rowTop:0,rowHeight:i,estimated:!1,rowIndex:s.length,sourceIndex:s.length}))}return yr(s),s}function Ql(e,t,n){if(t.length===0)return[...e];let r=n??e.length,i=Math.max(0,Math.min(r,e.length));return[...e.slice(0,i),...t,...e.slice(i)]}function $l(e,t){return Math.max(0,Math.min(e,t))}function eu(e,t){if(typeof e==`string`)return e;let n=e[t];if(n==null)throw new Xl(`Missing rowKey "${t}" in remove item`);return String(n)}function tu(e,t){if(typeof e!=`object`||!e||!(`data`in e))return!1;let n=e;return n[t]!==void 0&&n[t]!==null&&n[t]!==``?!1:typeof e.data==`object`&&e.data!==null}function nu(e,t){return tu(e,t)?e.data:e}function ru(e,t){if(tu(e,t))return e.index}function iu(e){return typeof e!=`object`||!e||!(`data`in e)||!(`rowId`in e)?!1:typeof e.rowId==`string`}function au(e,t,n){let r=n.rowKey,i=n.rowHeight??or,a=new Map(e.map(e=>[e.id,e])),o={add:[],remove:[],update:[]},s=new Set;if(t.remove?.length)for(let e of t.remove){let t=eu(e,r),n=a.get(t);n&&(o.remove.push(n),a.delete(t),s.add(t))}if(t.update?.length)for(let e of t.update){let t,n;if(iu(e))n=a.get(e.rowId),t=e.data;else{t=e;let i=t[r];if(i==null){if(n=[...a.values()].find(e=>e.data===t&&e.isTransient),!n)throw new Xl(`Missing rowKey "${r}" in update item`)}else n=a.get(String(i))}n&&(n.data!==t&&Object.assign(n.data,t),o.update.push(n),s.add(n.id))}let c=new Set(o.remove.map(e=>e.id)),l=e.filter(e=>!c.has(e.id));if(t.add?.length)for(let e of t.add){let t=nu(e,r),n=ru(e,r),[c]=Zl([t],{rowKey:r,rowHeight:i,allowTransient:!0});if(c){if(a.has(c.id))throw new Xl(`Duplicate rowKey on add: "${c.id}"`);a.set(c.id,c),o.add.push(c),s.add(c.id),l=Ql(l,[c],n)}}return{sourceRows:l,transaction:o,touchedRowIds:[...s]}}function ou(e,t){if(t<0||t>=e.length)return null;let n=e[t];return{rowTop:n.rowTop,rowHeight:n.rowHeight}}function su(e,t){let n=e.length;if(n===0||t<=0)return 0;let r=0,i=n-1;for(;r<=i;){let n=r+i>>1,a=e[n],o=a.rowTop+a.rowHeight;if(t<a.rowTop)i=n-1;else if(t>=o)r=n+1;else return n}return n-1}function cu(e,t){return t.rowGroupColumns.length===0||e.length===0?[...e]:Mr(Tr({sourceRows:e,...t}))}function lu(e,t,n){return!t||!n||n.rowGroupColumns.length===0?[...e]:cu(e,n)}var uu=class{sourceRows=[];displayRows=[];baseDisplayRows=[];sortModel=[];filterModel={};quickFilterText=``;touchedRowIds=null;rowKey;defaultRowHeight;getCellValue;getColumnComparator;filterColumnContext;getQuickFilterColIds;refreshScheduler=new Gl;positionGetRowHeight;rowExpansionService=null;loadMoreRowService=null;rowGroupingDeps=null;treeTableDeps=null;groupedTreeRoots=[];treeTreeRoots=[];constructor(e){this.rowKey=e.rowKey,this.defaultRowHeight=e.rowHeight??or,this.getCellValue=e.getCellValue??du,this.getColumnComparator=e.getColumnComparator,this.filterColumnContext=e.filterColumnContext,this.getQuickFilterColIds=e.getQuickFilterColIds,this.quickFilterText=e.quickFilterText??``}get rowsToDisplay(){return this.displayRows}getBaseDisplayRows(){return this.baseDisplayRows}setRowExpansionService(e){this.rowExpansionService=e}getRowExpansionService(){return this.rowExpansionService}setLoadMoreRowService(e){this.loadMoreRowService=e}setRowGroupingDeps(e){this.rowGroupingDeps=e,e?.active()||(this.groupedTreeRoots=[])}setTreeTableDeps(e){this.treeTableDeps=e,e?.active()||(this.treeTreeRoots=[])}getTreeTreeRoots(){return this.treeTreeRoots}getGroupedTreeRoots(){return this.groupedTreeRoots}setPositionGetRowHeight(e){this.positionGetRowHeight=e}resolvePositionRowsOptions(){return{defaultRowHeight:this.defaultRowHeight,getRowHeight:this.positionGetRowHeight}}setData(e){this.sourceRows=Zl(e,{rowKey:this.rowKey,rowHeight:this.defaultRowHeight,allowTransient:!0}),this.touchedRowIds=null,this.rowExpansionService?.clearExpanded(),this.rowGroupingDeps?.clearExpanded(),this.treeTableDeps?.clearExpanded(),this.groupedTreeRoots=[],this.treeTreeRoots=[],this.refreshModel({applyDefaultExpanded:!0})}setSortModel(e){this.sortModel=[...e],this.touchedRowIds=null,this.refreshModel()}setFilterModel(e){this.filterModel={...e},this.refreshModel()}getSortModel(){return[...this.sortModel]}getFilterModel(){return{...this.filterModel}}getQuickFilterText(){return this.quickFilterText}setQuickFilterText(e){this.quickFilterText!==e&&(this.quickFilterText=e,this.refreshModel())}markTouchedRowIds(e){this.touchedRowIds=new Set(e)}applyTransaction(e){let{sourceRows:t,transaction:n,touchedRowIds:r}=au(this.sourceRows,e,{rowKey:this.rowKey,rowHeight:this.defaultRowHeight});return this.sourceRows=t,yr(this.sourceRows),this.markTouchedRowIds(r),this.maybeSyncGroupSortKeyOnSourceRows(),this.refreshModel(),n}rebuildDisplayProjection(){if(this.treeTableDeps?.active()){this.rebuildTreeMapProjection();return}if(this.rowGroupingDeps?.active()){this.rebuildGroupedMapProjection();return}this.displayRows=this.buildProjectedDisplayRows(!1),fr(this.displayRows,this.resolvePositionRowsOptions())}rebuildTreeMapProjection(){if(this.treeTableDeps?.active()){if(this.treeTreeRoots.length===0||!Wr(this.treeTreeRoots)){this.refreshModel();return}this.refreshModel({stages:[`map`]})}}rebuildGroupedMapProjection(){if(this.rowGroupingDeps?.active()){if(this.groupedTreeRoots.length===0||!this.groupedTreeRoots.some(e=>e.group)){this.refreshModel();return}this.refreshModel({stages:[`map`]})}}getRowById(e){return this.sourceRows.find(t=>t.id===e)}resolveRowById(e){return this.getRowById(e)??this.getDisplayRowById(e)}getDisplayRowById(e){return this.displayRows.find(t=>t.id===e)}setDefaultRowHeight(e){this.defaultRowHeight=Math.max(1,e)}repositionDisplayRows(e){fr(this.displayRows,{defaultRowHeight:this.defaultRowHeight,getRowHeight:e?.getRowHeight??this.positionGetRowHeight})}getRowIndexById(e){return this.displayRows.findIndex(t=>t.id===e)}refreshModel(e={}){let t=typeof e==`boolean`?{applyDefaultExpanded:e}:e,n=t.applyDefaultExpanded??!1,r=this.rowGroupingDeps?.active()??!1,i=this.treeTableDeps?.active()??!1,a=i?`tree`:r?`group`:`flat`,o=t.stages??Wl(a);(o.length!==1||o[0]!==`map`)&&this.normalizeGroupedSourceRowsIfNeeded(),this.refreshScheduler.refresh(()=>{let e=this.rowGroupingDeps,t=this.treeTableDeps,s=n;this.displayRows=Ul({sourceRows:this.sourceRows,currentDisplayRows:this.displayRows,sortModel:this.sortModel,filterModel:this.filterModel,touchedRowIds:this.touchedRowIds??void 0,getCellValue:this.getCellValue,getColumnComparator:this.getColumnComparator,filterColumnContext:this.filterColumnContext,quickFilterText:this.quickFilterText,getQuickFilterColIds:this.getQuickFilterColIds,rowHeight:this.defaultRowHeight,positionRowsOptions:this.resolvePositionRowsOptions(),stages:o,hierarchyMode:a,grouping:r&&e?{rowGroupColumns:e.getRowGroupColumns(),groupKeyCreator:e.getGroupKeyCreator(),groupComparator:e.getGroupComparator(),groupSortKey:e.getGroupSortKey(),getColumnField:e.getColumnField,columns:e.getColumns(),getMapStageOptions:()=>({...e.getMapStageOptions(),defaultRowHeight:this.defaultRowHeight}),groupedTreeRoots:this.groupedTreeRoots,prepareGroupedTree:t=>{this.groupedTreeRoots=[...t],e.pruneExpanded(new Set(ql(t))),s&&=(e.applyDefaultExpanded(t),!1)}}:void 0,tree:i&&t?{getDataPath:t.getDataPath(),getMapStageOptions:()=>({...t.getMapStageOptions(),defaultRowHeight:this.defaultRowHeight}),treeTreeRoots:this.treeTreeRoots,prepareTreeTree:e=>{this.treeTreeRoots=[...e],t.prepareTreeTree(e),s&&=(t.applyDefaultExpanded(e),!1)},applyQuickFilterExpand:e=>{t.expandForQuickFilterDisplay(e)}}:void 0,afterMap:e=>this.buildProjectedDisplayRows(n,e)}),this.touchedRowIds=null})}buildProjectedDisplayRows(e,t=this.baseDisplayRows){this.baseDisplayRows=t;let n;return this.rowExpansionService?.active?(e&&this.rowExpansionService.applyDefaultExpanded(t),this.rowExpansionService.pruneExpanded(new Set(this.sourceRows.map(e=>e.id))),n=this.rowExpansionService.injectDetailRows(t)):n=t.slice(),this.loadMoreRowService?.injectTrailingRow(n)??n}getRow(e){return this.displayRows[e]}getRowCount(){return this.displayRows.length}getSourceRowCount(){return this.sourceRows.length}getSourceRows(){return this.sourceRows}getSourceRowIndexById(e){return this.sourceRows.findIndex(t=>t.id===e)}setSourceRows(e){this.sourceRows=e,yr(this.sourceRows),this.maybeSyncGroupSortKeyOnSourceRows(),this.touchedRowIds=null,this.refreshModel()}maybeSyncGroupSortKeyOnSourceRows(){let e=this.rowGroupingDeps;if(!e?.active())return;let t=e.getGroupSortKey();t&&Sr(this.sourceRows,t)}normalizeGroupedSourceRowsIfNeeded(){let e=this.rowGroupingDeps;if(!e?.active())return;let t=e.getRowGroupColumns();t.length!==0&&(this.sourceRows=lu(this.sourceRows,!0,{rowGroupColumns:t,getCellValue:this.getCellValue,groupKeyCreator:e.getGroupKeyCreator(),groupComparator:e.getGroupComparator(),groupSortKey:e.getGroupSortKey(),getColumnField:e.getColumnField}),yr(this.sourceRows),this.maybeSyncGroupSortKeyOnSourceRows())}getRowKey(){return this.rowKey}promoteRowId(e,n){let r=this.getRowById(e);if(!r)return{ok:!1,reason:`Row "${e}" not found`};if(!r.isTransient)return{ok:!1,reason:`Row "${e}" is not transient`};if(t.A(n))return{ok:!1,reason:`businessId is required`};let i=String(n);return this.sourceRows.some(e=>e!==r&&e.id===i)?{ok:!1,reason:`Duplicate row id "${i}"`}:(r.data[this.rowKey]=n,r.id=i,r.isTransient=!1,this.markTouchedRowIds([i]),this.refreshModel(),{ok:!0,rowId:i})}getRowIndexAtPixel(e){return su(this.displayRows,e)}getRowBounds(e){return ou(this.displayRows,e)}getTotalHeight(){return pr(this.displayRows)}ensureRowHeightsValid(e,t){return!1}};function du(e,t){return e.data[t]}var fu=`__MG_INF_STUB__::`;function pu(e){return`${fu}${e}`}function mu(e){return e.startsWith(fu)}function hu(e){let t=e.rowHeight??or,n=e.index;return{id:pu(n),data:{},rowTop:n*t,rowHeight:t,estimated:!1,rowIndex:n,sourceIndex:n,__infiniteBlockState:e.blockState??`idle`}}function gu(e,n,r){let i=n[e];return t.A(i)?r?.isTransient?{id:r.id,isTransient:!0}:{id:t.k(),isTransient:!0}:{id:String(i),isTransient:!1}}function _u(e){let{index:t,rowHeight:n,rowKey:r,data:i}=e,{id:a,isTransient:o}=gu(r,i);return{id:a,data:i,isTransient:o,rowTop:t*n,rowHeight:n,estimated:!1,rowIndex:t,sourceIndex:t,__infiniteBlockState:e.blockState??`loaded`}}function vu(e){let{index:t,rowHeight:n,rowKey:r,data:i,existing:a}=e,{id:o,isTransient:s}=gu(r,i,a);return a&&a.id===o?(a.data=i,a.isTransient=s,a.rowTop=t*n,a.rowHeight=n,a.rowIndex=t,a.sourceIndex=t,a.__infiniteBlockState=e.blockState??`loaded`,a):_u(e)}var yu=class{displayRows=[];virtualRowCount=0;knownLastRow=null;rowKey;defaultRowHeight;sortModel=[];filterModel={};quickFilterText=``;constructor(e){this.rowKey=e.rowKey,this.defaultRowHeight=e.rowHeight??or,this.setVirtualRowCount(e.initialRowCount??0,{preserveLoaded:!1})}get rowsToDisplay(){return this.displayRows}getRow(e){return this.displayRows[e]}getRowCount(){return this.virtualRowCount}getRowIndexAtPixel(e){if(this.virtualRowCount===0)return 0;let t=Math.floor(Math.max(0,e)/this.defaultRowHeight);return Math.min(t,this.virtualRowCount-1)}getRowBounds(e){let t=this.displayRows[e];return t?{rowTop:t.rowTop,rowHeight:t.rowHeight}:null}getTotalHeight(){return this.virtualRowCount*this.defaultRowHeight}ensureRowHeightsValid(e,t){return!1}getKnownLastRow(){return this.knownLastRow}getVirtualRowCount(){return this.virtualRowCount}setVirtualRowCount(e,t){let n=Math.max(0,Math.floor(e)),r=t?.preserveLoaded??!0;if(n===this.virtualRowCount&&this.displayRows.length===n)return;let i=this.displayRows;this.virtualRowCount=n,this.displayRows=Array(n);for(let e=0;e<n;e++){let t=r?i[e]:void 0;t&&t.__infiniteBlockState===`loaded`?(t.rowIndex=e,t.sourceIndex=e,t.rowTop=e*this.defaultRowHeight,this.displayRows[e]=t):this.displayRows[e]=hu({index:e,rowHeight:this.defaultRowHeight,blockState:`idle`})}}updateLastRow(e,t,n){if(e!==void 0){this.knownLastRow=Math.max(0,Math.floor(e)),this.setVirtualRowCount(this.knownLastRow,{preserveLoaded:!0});return}this.knownLastRow=null,n>=this.virtualRowCount&&this.setVirtualRowCount(n+t,{preserveLoaded:!0})}applyBlock(e,t){let n=[],r=[],i=this.defaultRowHeight;for(let a=0;a<t.length;a++){let o=e+a;if(o>=this.virtualRowCount)break;let s=this.displayRows[o];s&&mu(s.id)&&r.push(s.id);let c=vu({existing:s,index:o,rowHeight:i,rowKey:this.rowKey,data:t[a],blockState:`loaded`});this.displayRows[o]=c,n.push(c.id)}return{rowIds:n,replacedStubIds:r,virtualRowCount:this.virtualRowCount}}markBlockRange(e,t,n){for(let r=e;r<t&&r<this.virtualRowCount;r++){let e=this.displayRows[r];e&&(n!==`loaded`||e.__infiniteBlockState!==`loaded`)&&(n===`idle`||n===`loading`||n===`failed`?this.displayRows[r]=hu({index:r,rowHeight:this.defaultRowHeight,blockState:n}):e.__infiniteBlockState=n)}}evictBlockRange(e,t){this.markBlockRange(e,t,`idle`)}resetForPurge(e){this.knownLastRow=null,this.setVirtualRowCount(e,{preserveLoaded:!1})}getRowKey(){return this.rowKey}resolveRowById(e){return this.displayRows.find(t=>t.id===e)}getRowById(e){return this.resolveRowById(e)}getRowIndexById(e){return this.displayRows.findIndex(t=>t.id===e)}getBaseDisplayRows(){return this.displayRows}getSourceRows(){return this.displayRows.filter(e=>e.__infiniteBlockState===`loaded`)}getSourceRowCount(){return this.getSourceRows().length}getLoadedRowData(){return this.getSourceRows().map(e=>({...e.data}))}getSortModel(){return[...this.sortModel]}setSortModel(e){this.sortModel=[...e]}getFilterModel(){return{...this.filterModel}}setFilterModel(e){this.filterModel={...e}}getQuickFilterText(){return this.quickFilterText}setQuickFilterText(e){this.quickFilterText=e}setDefaultRowHeight(e){this.defaultRowHeight=Math.max(1,e);for(let e=0;e<this.displayRows.length;e++){let t=this.displayRows[e];t.rowTop=e*this.defaultRowHeight,t.rowHeight=this.defaultRowHeight}}getGroupedTreeRoots(){return[]}getTreeTreeRoots(){return[]}setRowExpansionService(e){}setLoadMoreRowService(e){}setRowGroupingDeps(e){}setTreeTableDeps(e){}setPositionGetRowHeight(e){}repositionDisplayRows(e){}};function bu(e){return e instanceof uu}function W(e){return e instanceof yu}function xu(e){let n=t.R(e);return t.L({rowModelType:n.rowModelType,infiniteDatasource:e.infiniteDatasource,rowGrouping:{rowGroupColumns:Array(e.rowGroupingColumnCount??0)},treeTable:{getDataPath:e.hasTreeTable?()=>[]:void 0},masterDetail:{detailCellRenderer:e.hasMasterDetail?()=>null:void 0},rowDragManaged:e.rowDragManaged,treeLazyLoad:e.hasTreeLazyLoad},n),n.rowModelType===`infinite`?{rowModel:new yu({rowKey:e.rowKey,rowHeight:e.rowHeight,initialRowCount:n.infiniteInitialRowCount}),resolvedInfinite:n}:{rowModel:new uu({rowKey:e.rowKey,rowHeight:e.rowHeight,getCellValue:e.getCellValue,getColumnComparator:e.getColumnComparator,filterColumnContext:e.filterColumnContext,quickFilterText:e.quickFilterText,getQuickFilterColIds:e.getQuickFilterColIds}),resolvedInfinite:n}}function G(e,t){if(W(e))throw Error(`[MagicGrid] ${t}() is not supported when rowModelType is "infinite"`)}var Su=!1;function Cu(){Su||(Su=!0,console.warn(`[MagicGrid] getData() in infinite mode returns loaded blocks only; use getLoadedRowData() instead.`))}function wu(e,t){let n={internalRowId:t.internalRowId,columnCellEditorCache:t.columnCellEditorCache};return{getCellCache:r=>e.get(t.rowId,t.colId,r,n),setCellCache:(r,i)=>e.set(t.rowId,t.colId,r,i,n),clearCellCache:r=>{if(r===void 0){e.clearCell(t.rowId,t.colId,t.internalRowId);return}e.clear(t.rowId,t.colId,r,n)}}}function Tu(e,n){let{enableCellEditorCache:r,rowNode:i,column:a,rowKey:o}=n;if(t.l({enableCellEditorCache:r,colId:a.colId,cellEditorMode:a.cellEditorMode,cellEditor:a.cellEditor,columnCellEditorCache:a.cellEditorCache}))return wu(e,{rowId:t.T(i,o),colId:a.colId,internalRowId:i.isTransient?i.id:void 0,columnCellEditorCache:a.cellEditorCache})}var Eu=class{store=new Map;bucketKeys=new Map;bucketAccessOrder=[];maxEntries;constructor(e={}){this.maxEntries=e.maxEntries}get(e,n,r,i){let a=t.c({userKey:r,columnCellEditorCache:i?.columnCellEditorCache}),o=t.a(e,n,a,{internalRowId:i?.internalRowId});if(this.store.has(o))return this.touchBucket(e,n,i?.internalRowId),this.store.get(o)}set(e,n,r,i,a){let o=t.c({userKey:i,columnCellEditorCache:a?.columnCellEditorCache}),s=t.a(e,n,o,{internalRowId:a?.internalRowId}),c=t.r(e,n,{internalRowId:a?.internalRowId});this.bucketKeys.has(c)||this.bucketKeys.set(c,new Set),this.bucketKeys.get(c).add(s),this.store.set(s,r),this.touchBucket(e,n,a?.internalRowId),this.evictIfNeeded()}clear(e,n,r,i){if(e==null&&n==null&&r==null){this.clearAll();return}if(e!=null&&n==null){let n=t.i(e,i?.internalRowId);for(let e of[...this.bucketKeys.keys()])e.startsWith(`${n}::`)&&this.clearCellByBucketKey(e);return}if(e==null||n==null)return;if(r==null){this.clearCell(e,n,i?.internalRowId);return}let a=t.c({userKey:r,columnCellEditorCache:i?.columnCellEditorCache}),o=t.a(e,n,a,{internalRowId:i?.internalRowId});this.deleteStorageKey(o)}clearCell(e,n,r){let i=t.r(e,n,{internalRowId:r}),a=this.bucketKeys.get(i);if(a){for(let e of[...a])this.store.delete(e);this.bucketKeys.delete(i),this.removeBucketFromAccessOrder(i)}}clearAll(){this.store.clear(),this.bucketKeys.clear(),this.bucketAccessOrder.length=0}removeByRowIds(e,n){let r=new Set;for(let n of e)r.add(t.i(n));for(let e of n?.internalRowIds??[])r.add(t.i(null,e));if(r.size!==0)for(let e of[...this.bucketKeys.keys()]){let t=e.slice(0,e.indexOf(`::`));r.has(t)&&this.clearCellByBucketKey(e)}}promoteRowId(e,n){let r=t.i(null,e),i=String(n),a=`${r}::`,o=[];for(let[e,t]of this.store)e.startsWith(a)&&o.push([e,t]);if(o.length!==0)for(let[e,r]of o){let o=e.slice(a.length),s=`${i}::${o}`,c=o.slice(0,o.indexOf(`::`));this.store.delete(e),this.removeStorageKeyFromBucket(e);let l=t.r(n,c);this.bucketKeys.has(l)||this.bucketKeys.set(l,new Set),this.bucketKeys.get(l).add(s),this.store.set(s,r),this.touchBucket(n,c)}}get size(){return this.store.size}get bucketCount(){return this.bucketKeys.size}deleteStorageKey(e){this.store.delete(e),this.removeStorageKeyFromBucket(e)}removeStorageKeyFromBucket(e){for(let[t,n]of this.bucketKeys)if(n.has(e)){n.delete(e),n.size===0&&(this.bucketKeys.delete(t),this.removeBucketFromAccessOrder(t));return}}clearCellByBucketKey(e){let t=this.bucketKeys.get(e);if(t){for(let e of t)this.store.delete(e);this.bucketKeys.delete(e),this.removeBucketFromAccessOrder(e)}}touchBucket(e,n,r){let i=t.r(e,n,{internalRowId:r});this.bucketKeys.has(i)&&(this.removeBucketFromAccessOrder(i),this.bucketAccessOrder.push(i))}removeBucketFromAccessOrder(e){let t=this.bucketAccessOrder.indexOf(e);t>=0&&this.bucketAccessOrder.splice(t,1)}evictIfNeeded(){if(this.maxEntries!=null)for(;this.bucketKeys.size>this.maxEntries&&this.bucketAccessOrder.length>0;){let e=this.bucketAccessOrder.shift();e&&this.clearCellByBucketKey(e)}}};function Du(e,n){let r=[],i=[];for(let a of e){if(t.j(a)){i.push(a);continue}let e=t.D(a,n);e===null?i.push(a):r.push(e)}return{businessRowIds:r,transientInternalRowIds:i}}function Ou(e={}){let t=`autoSizeStrategy`in e&&e.autoSizeStrategy!==void 0?e.autoSizeStrategy??null:null;return{skipHeaderOnAutoSize:e.skipHeaderOnAutoSize??!1,autoSizePadding:e.autoSizePadding??16,autoSizeStrategy:t}}function ku(e,t,n){let r=new Set(n);return r.size<=1||!r.has(t)?[t]:e.filter(e=>r.has(e.id)).map(e=>e.id)}function Au(e,t){if(t.length===0)return``;let n=new Set(t);for(let t of e)if(n.has(t.id))return t.id;return t[0]}function ju(e,t,n,r){let i=t.indexOf(n);if(i<0)return Math.max(0,Math.min(r,e-1));let a=r-i,o=Math.max(0,e-t.length);return Math.max(0,Math.min(a,o))}function Mu(e,n){let r=t.m(e),i=n.resolveRowById(r);if(i)return i;for(let e of n.displayRows){if(e.isTransient)continue;let i=e.data[n.rowKey];if(i!=null&&t.m(i)===r)return e}}function Nu(e,t){let n=Mu(e,t);if(!n)return null;let r=t.displayRows.findIndex(e=>e.id===n.id);return r>=0?r:null}function Pu(e,t){return Ru(e,t.sourceRows,t.rowKey)}function Fu(e,t,n){let r=Pu(e,t);if(r==null)return null;let i=t.sourceRows[r],a=i.leafGroupPathKey;if(!a)return null;let o=n.type===`display`&&n.hasSortOrFilter;return n.type===`display`&&Nu(e,t)==null?null:o?Lu(i.id,a,t):Iu(i.id,a,t)}function Iu(e,t,n){let r=0;for(let i of n.sourceRows)if(i.leafGroupPathKey===t){if(i.id===e)return r;r+=1}return null}function Lu(e,t,n){let r=0;for(let i of n.displayRows)if(R(i)&&n.sourceRows.find(e=>e.id===i.id)?.leafGroupPathKey===t){if(i.id===e)return r;r+=1}return null}function Ru(e,n,r){let i=t.m(e),a=n.findIndex(e=>e.id===i);if(a>=0)return a;for(let e=0;e<n.length;e+=1){let a=n[e];if(a.isTransient)continue;let o=a.data[r];if(o!=null&&t.m(o)===i)return e}return null}function zu(e,n){let[r]=t.v([e.id],{rowKey:n.rowKey,getRowById:n.resolveRowById});return r}function Bu(e,t){let n=Mu(e,t);if(!n)return null;let r=t.displayRows.findIndex(e=>e.id===n.id);if(r<0)return null;let i=zu(n,t);return i?{anchorSnapshot:i,startIndex:r}:null}function Vu(e,t,n){if(!e)return`continue`;let r=!1,i=`stop`;return e({currentRow:t,row:n,next:(e=!0)=>{r||(r=!0,i=e===!1?`stop`:`continue`)}}),i}function Hu(e,t,n,r){let i=n===`prev`?-1:1;for(let n=t.startIndex+i;n>=0&&n<e.displayRows.length;n+=i){let t=e.displayRows[n],i=zu(t,e);if(i&&r(i)===!1)break}}function Uu(e,t,n){let r=Bu(e,n);if(!r)return[];let i=t.length??1,a=t.includeStop??!1,o=[];return Hu(n,r,t.direction,e=>Vu(t.iterator,e,r.anchorSnapshot)===`continue`?(o.push(e),i>=0&&o.length>=i?!1:void 0):(a&&o.push(e),!1)),o}function Wu(e,t,n){let r=Bu(e,n);if(!r)return null;let i=null;return Hu(n,r,t.direction,e=>{if(Vu(t.iterator,e,r.anchorSnapshot)===`stop`)return i=e,!1}),i}function Gu(e,t){return!Number.isInteger(e)||e<0||e>=t.displayRows.length?null:zu(t.displayRows[e],t)??null}function Ku(e,t){return Gu(e,t)}function qu(e,t){let n=[];for(let r of e){let e=Gu(r,t);e&&n.push(e)}return n}function Ju(e,t){if(t==null)return qu(e.displayRows.map((e,t)=>t),e);let n=[];for(let r=0;r<e.displayRows.length;r+=1){let i=Gu(r,e);i!=null&&t(i)&&n.push(i)}return n}function Yu(e,n){return Ju(e,n).map(t.b)}function Xu(e){return{sourceRows:e.sourceRows,displayRows:e.displayRows,hasSortOrFilter:e.sortModelLength>0||e.filterModelKeyCount>0}}function Zu(e,t,n){if(e===void 0)return;if(t===`source`||!n.hasSortOrFilter)return $l(e,n.sourceRows.length);if(n.displayRows.length===0)return 0;let r=$l(e,n.displayRows.length),i=n.displayRows[r];if(!i)return n.sourceRows.length;let a=n.sourceRows.findIndex(e=>e.id===i.id);return a<0?n.sourceRows.length:a}function Qu(e,t,n){let r=t===`display`||n.hasSortOrFilter?n.displayRows:n.sourceRows,i=[];for(let t of e){if(r.length===0)continue;let e=r[$l(t,r.length)];e&&i.push(e.id)}return i}function $u(e,t){return t<=0?0:Math.max(0,Math.min(e,t-1))}function ed(e,t,n,r){if(t===`display`&&r)return null;if(t===`source`||!n.hasSortOrFilter)return $u(e,n.sourceRows.length);let i=$u(e,n.displayRows.length),a=n.displayRows[i];if(!a)return $u(n.sourceRows.length-1,n.sourceRows.length);let o=n.sourceRows.findIndex(e=>e.id===a.id);return o<0?$u(n.sourceRows.length-1,n.sourceRows.length):o}function td(e,t){let n=null;for(let r of t){let t=e.find(e=>e.id===r);if(!t||Ue(t))return`missing`;let i=t.leafGroupPathKey??null;if(!i)return null;if(n==null){n=i;continue}if(n!==i)return`mixed`}return n}function nd(e,t,n,r){let i=0,a=Math.max(0,Math.min(t,e.length));for(let t=0;t<a;t+=1){let a=e[t];R(a)&&a.leafGroupPathKey===n&&!r.has(a.id)&&(i+=1)}return i}function rd(e,t,n,r){let i=new Set(t),a=0,o=$u(n,e.length);for(let t=0;t<o;t+=1){let n=e[t];n.leafGroupPathKey===r&&!i.has(n.id)&&(a+=1)}if(t.length===1){let n=e.findIndex(e=>e.id===t[0]);n>=0&&n<o&&--a}return Math.max(0,a)}function id(e){let{sourceRows:t,rowIds:n,groupPath:r,withinGroupInsertIndex:i}=e,a=new Set(n);if(td(t,n)!==r)return null;let o=[],s=[];for(let e=0;e<t.length;e+=1){let n=t[e];n.leafGroupPathKey===r&&(o.push(e),s.push(n))}let c=s.filter(e=>a.has(e.id));if(c.length!==n.length)return null;let l=s.filter(e=>!a.has(e.id)),u=Math.max(0,Math.min(i,l.length)),d=[...l.slice(0,u),...c,...l.slice(u)];if(d.every((e,t)=>e.id===s[t].id))return null;let f=[...t];for(let e=0;e<o.length;e+=1)f[o[e]]=d[e];let p=[];for(let e of c){let n=t.findIndex(t=>t.id===e.id),r=f.findIndex(t=>t.id===e.id);n>=0&&r>=0&&n!==r&&p.push({rowId:e.id,fromIndex:n,toIndex:r})}return p.length===0?null:{rows:f,moves:p}}function ad(e){let{sourceRows:t,displayRows:n,rowIds:r,displayInsertIndex:i,groupPath:a}=e,o=new Set(r);return sd(n,e=>t.find(t=>t.id===e),r,i,a)?id({sourceRows:t,rowIds:r,groupPath:a,withinGroupInsertIndex:nd(n,i,a,o)}):null}function od(e,t,n,r){let i=new Set(t),a=e.filter(e=>e.leafGroupPathKey===r).length,o=rd(e,t,n,r),s=a-i.size;return o>=0&&o<=s}function sd(e,t,n,r,i){let a=[];for(let n=0;n<e.length;n+=1){let r=e[n];R(r)&&(t(r.id)??r).leafGroupPathKey===i&&a.push(n)}if(a.length===0)return!1;let o=Math.min(...a),s=Math.max(...a)+1;return r>=o&&r<=s}function cd(e){if(!e.active)return{allowed:!0};let t=td(e.sourceRows,e.rowIds);return t===null?{allowed:!0}:t===`missing`?{allowed:!1,reason:`cannot move non-leaf rows while row grouping is active`}:t===`mixed`?{allowed:!1,reason:`selected rows must belong to the same group`}:od(e.sourceRows,e.rowIds,e.targetSourceIndex,t)?{allowed:!0}:{allowed:!1,reason:`cannot move rows across groups`}}function ld(e,t,n){return{rowId:e,fromIndex:t,toIndex:n}}function ud(e,t,n){let r=K(e,t);if(!(!r&&n===void 0))return{...n===void 0?{}:{displayIndex:n},...r??{}}}function dd(e,t){let n=null;for(let r of t){let t=e.find(e=>e.id===r);if(!t||!B(t))return`missing`;let i=t.parentRowId??null;if(n==null){n=i;continue}if(n!==i)return`mixed`}return n}function fd(e,t,n,r){let i=0,a=Math.max(0,Math.min(t,e.length));for(let t=0;t<a;t+=1){let a=e[t];B(a)&&(a.parentRowId??null)===n&&!r.has(a.id)&&(i+=1)}return i}function K(e,t){let n=e.findIndex(e=>e.id===t);if(n<0)return null;let r=e[n];if(!B(r))return null;let i=r.parentRowId??null,a=0;for(let t=0;t<n;t+=1)(e[t].parentRowId??null)===i&&(a+=1);return{parentRowId:i,siblingIndex:a,treeLevel:r.treeLevel??Math.max(0,(r.dataPath?.length??1)-1)}}function pd(e,t,n,r){let i=new Set(t),a=0,o=$u(n,e.length);for(let t=0;t<o;t+=1){let n=e[t];B(n)&&(n.parentRowId??null)===r&&!i.has(n.id)&&(a+=1)}return a}function md(e){if(!e.active)return{allowed:!0};let t=dd(e.sourceRows,e.rowIds);return t===`mixed`?{allowed:!1,reason:`selected rows must belong to the same tree parent`}:t===`missing`?{allowed:!1,reason:`cannot move non-tree rows while tree mode is active`}:t!=null&&!hd(e.sourceRows,e.rowIds,e.targetSourceIndex,t)?{allowed:!1,reason:`tree drag target must stay within the same parent siblings`}:{allowed:!0,parentRowId:t}}function hd(e,t,n,r){let i=new Set(t),a=e.filter(e=>B(e)&&(e.parentRowId??null)===r).length,o=pd(e,t,n,r),s=a-i.size;return o>=0&&o<=s}function gd(e,t,n,r,i){for(let e of n){let n=t(e);if(!n||!B(n)||(n.parentRowId??null)!==i)return!1}let a=[];for(let t=0;t<e.length;t+=1){let n=e[t];B(n)&&(n.parentRowId??null)===i&&a.push(t)}if(a.length===0)return!1;let o=Math.min(...a),s=Math.max(...a)+1,c=Math.max(0,Math.min(r,e.length));return c>=o&&c<=s}function _d(e){let t=new Set(e.rowIds),n=[],r=[];for(let t=0;t<e.sourceRows.length;t+=1){let i=e.sourceRows[t];!B(i)||(i.parentRowId??null)!==e.parentRowId||(n.push(t),r.push(i))}let i=e.rowIds.map(e=>r.find(t=>t.id===e)).filter(e=>e!=null);if(i.length!==e.rowIds.length)return null;let a=r.filter(e=>!t.has(e.id)),o=Math.max(0,Math.min(e.withinSiblingInsertIndex,a.length)),s=[...a.slice(0,o),...i,...a.slice(o)];if(s.every((e,t)=>e.id===r[t].id))return null;let c=[...e.sourceRows];for(let e=0;e<n.length;e+=1)c[n[e]]=s[e];let l=[];for(let t of i){let n=e.sourceRows.findIndex(e=>e.id===t.id),r=c.findIndex(e=>e.id===t.id);n>=0&&r>=0&&n!==r&&l.push(ld(t.id,n,r))}return l.length===0?null:{rows:c,moves:l}}function vd(e){let t=new Set(e.rowIds);if(!gd(e.displayRows,t=>e.sourceRows.find(e=>e.id===t),e.rowIds,e.displayInsertIndex,e.parentRowId))return null;let n=fd(e.displayRows,e.displayInsertIndex,e.parentRowId,t);return _d({sourceRows:e.sourceRows,rowIds:e.rowIds,withinSiblingInsertIndex:n,parentRowId:e.parentRowId})}function yd(e,t,n){return n===`up`?t>0?{indexMode:`source`,toIndex:t-1}:null:t<e.length-1?{indexMode:`source`,toIndex:t+1}:null}function bd(e,t,n,r){let i=[];for(let t=0;t<e.length;t+=1)r(e[t])&&i.push(t);let a=i.findIndex(n=>e[n].id===t);return a<0?null:n===`up`?a===0?null:{indexMode:`source`,toIndex:i[a-1]}:a===i.length-1?null:{indexMode:`source`,toIndex:i[a+1]}}function xd(e,t,n,r){let i=e.findIndex(e=>e.id===t);if(i<0)return null;let a=n===`up`?-1:1;for(let t=i+a;t>=0&&t<e.length;t+=a){let n=e[t];if(r(n))return{indexMode:`display`,toIndex:t}}return null}function Sd(e,t,n){let r=t.map(t=>e.findIndex(e=>e.id===t));if(r.some(e=>e<0))return null;let i=Math.min(...r),a=Math.max(...r);return n===`up`?i>0?{indexMode:`source`,toIndex:i-1}:null:a<e.length-1?{indexMode:`source`,toIndex:i+1}:null}function Cd(e,t,n){let r=[];for(let t=0;t<e.length;t+=1)n(e[t])&&r.push(t);let i=[];for(let n of t){let t=e.findIndex(e=>e.id===n);if(t<0)return null;let a=r.indexOf(t);if(a<0)return null;i.push(a)}return{siblingIndices:r,positions:i}}function wd(e,t,n,r){let i=Cd(e,t,r);if(!i)return null;let{siblingIndices:a,positions:o}=i,s=Math.min(...o),c=Math.max(...o);return n===`up`?s===0?null:{indexMode:`source`,toIndex:a[s-1]}:c===a.length-1?null:{indexMode:`source`,toIndex:a[c+1]}}function Td(e,t,n,r){let i=Cd(e,t,r);if(!i)return null;let{siblingIndices:a,positions:o}=i,s=Math.min(...o),c=Math.max(...o);return n===`up`?s===0?null:{indexMode:`display`,toIndex:a[s-1]}:c===a.length-1?null:{indexMode:`display`,toIndex:a[c+1]}}function Ed(e){let{sourceRows:t,displayRows:n,rowIds:r,direction:i,isRowGroupingActive:a,isTreeActive:o}=e;if(r.length===0)return null;if(r.length===1)return Dd({sourceRows:t,displayRows:n,rowId:r[0],direction:i,isRowGroupingActive:a,isTreeActive:o});if(a){let e=td(t,r);if(typeof e==`string`)return wd(t,r,i,t=>t.leafGroupPathKey===e);if(e===`missing`)return null}if(o){let e=dd(t,r);if(e===`mixed`||e===`missing`)return null;if(typeof e==`string`||e===null)return Td(n,r,i,t=>B(t)&&(t.parentRowId??null)===e)}return Sd(t,r,i)}function Dd(e){let{sourceRows:t,displayRows:n,rowId:r,direction:i,isRowGroupingActive:a,isTreeActive:o}=e,s=t.findIndex(e=>e.id===r);if(s<0)return null;if(a){let e=td(t,[r]);if(typeof e==`string`)return bd(t,r,i,t=>t.leafGroupPathKey===e);if(e===`missing`)return null}if(o){let e=dd(t,[r]);if(e===`mixed`||e===`missing`)return null;if(typeof e==`string`||e===null)return xd(n,r,i,t=>B(t)&&(t.parentRowId??null)===e)}return yd(t,s,i)}function Od(e,t,n={}){let r=n.type??`source`;return n.group?Fu(e,t,{type:r,hasSortOrFilter:t.hasSortOrFilter??!1}):r===`display`?Nu(e,t):Pu(e,t)}function kd(e,t,n={}){let r={};for(let i of e)r[i]=Od(i,t,n);return r}function Ad(e){return Ve(e)?`GROUP_HEADER`:He(e)?`GROUP_FOOTER`:I(e)?`DETAIL`:go(e)?`LOAD_MORE`:N(e.rowKind)}function jd(e,t){let n=Mu(e,t);return n?Ad(n):null}function Md(e){return typeof e==`function`}function Nd(e,n){let r=t.M(e,n);return e.map((e,i)=>{let a=e.data[n],o=e.isTransient||t.A(a)?null:a;return{data:r[i],internalRowId:e.id,businessRowId:o}})}function Pd(e,n,r){return{rows:t.M(e,n),rowKey:n,api:r,targets:Nd(e,n)}}function Fd(e,t){return[...Md(e)?e(t):e]}var Id=class{requestFrame;cancelFrame;now;frameBudgetMs;rendererFrameBudgetMs;scrollActive=!1;p1=[];p2=[];f1=[];destroyTasks=[];scrollGridIfNeeded=null;scrollGoingDown=!0;ticking=!1;rafId=null;createOrderSeed=0;constructor(e={}){this.requestFrame=e.requestFrame??(e=>requestAnimationFrame(e)),this.cancelFrame=e.cancelFrame??(e=>cancelAnimationFrame(e)),this.now=e.now??(()=>performance.now()),this.frameBudgetMs=Math.max(1,e.frameBudgetMs??60),this.rendererFrameBudgetMs=Math.max(0,e.rendererFrameBudgetMs??20)}setRendererFrameBudgetMs(e){this.rendererFrameBudgetMs=Math.max(0,e)}getRendererFrameBudgetMs(){return this.rendererFrameBudgetMs}setScrollActive(e){this.scrollActive=e}isScrollActive(){return this.scrollActive}setFrameBudgetMs(e){this.frameBudgetMs=Math.max(1,e)}getFrameBudgetMs(){return this.frameBudgetMs}setScrollGridIfNeeded(e){this.scrollGridIfNeeded=e}setScrollDirection(e){this.scrollGoingDown=e}schedule(){this.ticking||(this.ticking=!0,this.rafId=this.requestFrame(()=>{this.ticking=!1,this.rafId=null,this.executeFrame(this.frameBudgetMs)}))}createTask(e,t,n){this.getTaskList(n).push({task:e,index:t,createOrder:this.createOrderSeed++,deferred:!1}),this.schedule()}addDestroyTask(e){this.destroyTasks.push(e),this.schedule()}flushAllFrames(e){this.rafId!=null&&(this.cancelFrame(this.rafId),this.rafId=null,this.ticking=!1);let t=e??-1,n=!0;for(;n||this.hasPendingWork();)n=!1,this.executeFrame(t)}destroy(){this.rafId!=null&&(this.cancelFrame(this.rafId),this.rafId=null),this.ticking=!1,this.p1=[],this.p2=[],this.f1=[],this.destroyTasks=[]}getPendingTaskCount(){return this.p1.length+this.p2.length+this.f1.length+this.destroyTasks.length}getPendingRendererTaskCount(){return this.f1.length}executeFrame(e){let t=this.now(),n=e<0,r=!n&&this.scrollActive&&this.rendererFrameBudgetMs>0&&this.f1.length>0,i=r?Math.max(0,e-this.rendererFrameBudgetMs):e,a=r?this.rendererFrameBudgetMs:e;for(this.runTaskPhase({start:t,budgetMs:i,unlimited:n,queues:r?[`p1`,`p2`]:[`p1`,`p2`,`f1`]}),r&&this.runTaskPhase({start:this.now(),budgetMs:a,unlimited:!1,queues:[`f1`]});n||this.now()-t<e;){let e=this.destroyTasks.shift();if(!e)break;e()}this.hasPendingWork()&&this.schedule()}runTaskPhase(e){for(;e.unlimited||this.now()-e.start<e.budgetMs;){if(this.scrollGridIfNeeded?.())continue;let t=this.popNextTask(e.queues);if(!t)break;t.task()}}hasPendingWork(){return this.p1.length>0||this.p2.length>0||this.f1.length>0||this.destroyTasks.length>0}popNextTask(e=[`p1`,`p2`,`f1`]){for(let t of e){let e=this.getTaskList(t);if(e.length!==0)return this.sortTaskList(e),e.shift()}}sortTaskList(e){e.sort((e,t)=>e.index===t.index?e.createOrder-t.createOrder:this.scrollGoingDown?e.index-t.index:t.index-e.index)}getTaskList(e){switch(e){case`p1`:return this.p1;case`p2`:return this.p2;case`f1`:return this.f1}}},Ld=class{depth=0;beginDeferred(){this.depth++}endDeferred(e){this.depth<=0||(this.depth--,this.depth===0&&e())}isDeferred(){return this.depth>0}reset(){this.depth=0}};function Rd(e){return{setData:t=>e.setData(t),applyTransaction:t=>e.applyTransaction(t),addRows:t=>e.addRows(t),addRowsByArray:(t,n)=>e.addRowsByArray(t,n),addGroupRows:t=>e.addGroupRows(t),addGroupRowsByArray:(t,n)=>e.addGroupRowsByArray(t,n),removeRows:t=>e.removeRows(t),updateRows:t=>e.updateRows(t),patchRow:t=>e.patchRow(t),removeSelectedRows:t=>e.removeSelectedRows(t),getData:t=>e.getData(t),promoteRowId:t=>e.promoteRowId(t),moveRow:(t,n,r)=>e.moveRow(t,n,r),moveRows:t=>e.moveRows(t),moveUp:t=>e.moveUp(t),moveDown:t=>e.moveDown(t),moveUps:t=>e.moveUps(t),moveDowns:t=>e.moveDowns(t),setSortModel:t=>e.setSortModel(t),getSortModel:()=>e.getSortModel(),setFilterModel:t=>e.setFilterModel(t),getFilterModel:()=>e.getFilterModel(),refreshInfiniteCache:()=>e.refreshInfiniteCache(),setInfiniteDatasource:t=>e.setInfiniteDatasource(t),retryInfiniteBlock:t=>e.retryInfiniteBlock(t),getLoadedRowData:()=>e.getLoadedRowData(),getInfiniteRowCount:()=>e.getInfiniteRowCount(),getColumnFilter:t=>e.getColumnFilter(t),isColumnFilterActive:t=>e.isColumnFilterActive(t),isAnyFilterActive:()=>e.isAnyFilterActive(),setQuickFilterText:t=>e.setQuickFilterText(t),getQuickFilterText:()=>e.getQuickFilterText(),clearAllFilters:()=>e.clearAllFilters(),setColumnFilter:(t,n)=>e.setColumnFilter(t,n),refreshCells:t=>e.refreshCells(t),refreshCellSpans:()=>e.refreshCellSpans(),getCellSpan:(t,n)=>e.getCellSpan(t,n),ensureIndexVisible:(t,n)=>e.ensureIndexVisible(t,n),getRowNode:t=>e.getRowNode(t),getSiblingRowsByRowId:(t,n)=>e.getSiblingRowsByRowId(t,n),getSiblingRowByIterator:(t,n)=>e.getSiblingRowByIterator(t,n),getRowKind:t=>e.getRowKind(t),getRowIndex:(t,n)=>e.getRowIndex(t,n),getRowIndexes:(t,n)=>e.getRowIndexes(t,n),getRowByIndex:t=>e.getRowByIndex(t),getRowsByIndexes:t=>e.getRowsByIndexes(t),getRowSnapshots:t=>e.getRowSnapshots(t),getRowIds:t=>e.getRowIds(t),getMetrics:()=>e.getMetrics(),getPendingFrameTaskCount:()=>e.getPendingFrameTaskCount(),getPendingRendererTaskCount:()=>e.getPendingRendererTaskCount(),beginUpdate:()=>e.beginUpdate(),endUpdate:()=>e.endUpdate(),scrollTo:(t,n)=>e.scrollTo(t,n),moveColumn:(t,n)=>e.moveColumn(t,n),resetColumnOrder:()=>e.resetColumnOrder(),resetColumnWidths:()=>e.resetColumnWidths(),setColumnFixed:(t,n)=>e.setColumnFixed(t,n),setColumnsHidden:(t,n)=>e.setColumnsHidden(t,n),isColumnHidden:t=>e.isColumnHidden(t),getDisplayedColumnIds:()=>e.getDisplayedColumnIds(),getColumns:()=>e.getColumns(),getDisplayedColumns:()=>e.getDisplayedColumns(),getColumnDistinctFilterValues:t=>e.getColumnDistinctFilterValues(t),setColumnWidths:(t,n,r)=>e.setColumnWidths(t,n,r),setColumnWidth:(t,n,r,i)=>e.setColumnWidth(t,n,r,i),getColumnWidth:t=>e.getColumnWidth(t),autoSizeColumn:(t,n)=>e.autoSizeColumn(t,n),autoSizeColumns:(t,n)=>e.autoSizeColumns(t,n),sizeColumnsToFit:t=>e.sizeColumnsToFit(t),setRowHeight:(t,n,r)=>e.setRowHeight(t,n,r),setRowHeights:(t,n)=>e.setRowHeights(t,n),getRowHeight:t=>e.getRowHeight(t),resetRowHeights:t=>e.resetRowHeights(t),updateDimensions:t=>e.updateDimensions(t),expandRow:t=>e.expandRow(t),collapseRow:t=>e.collapseRow(t),isRowExpanded:t=>e.isRowExpanded(t),setDetailRowData:(t,n)=>e.setDetailRowData(t,n),reloadDetailRowData:t=>e.reloadDetailRowData(t),expandAll:()=>e.expandAll(),collapseAll:()=>e.collapseAll(),setRowGroupColumns:t=>e.setRowGroupColumns(t),getRowGroupColumns:()=>e.getRowGroupColumns(),expandGroup:t=>e.expandGroup(t),collapseGroup:t=>e.collapseGroup(t),isGroupExpanded:t=>e.isGroupExpanded(t),expandNode:t=>e.expandNode(t),collapseNode:t=>e.collapseNode(t),isNodeExpanded:t=>e.isNodeExpanded(t),getDataPath:t=>e.getDataPath(t),getCellComment:(t,n)=>e.getCellComment(t,n),setCellComment:(t,n,r)=>e.setCellComment(t,n,r),refreshCellComments:t=>e.refreshCellComments(t),getCellRanges:()=>e.getCellRanges(),getCellSelectionAggregation:()=>e.getCellSelectionAggregation(),clearCellSelection:()=>e.clearCellSelection(),addCellRange:t=>e.addCellRange(t),copySelectedRangeToClipboard:()=>e.copySelectedRangeToClipboard(),pasteFromClipboard:()=>e.pasteFromClipboard(),showLoadingOverlay:()=>e.showLoadingOverlay(),showNoRowsOverlay:()=>e.showNoRowsOverlay(),hideOverlay:()=>e.hideOverlay(),isOverlayShowing:()=>e.isOverlayShowing(),getOverlayType:()=>e.getOverlayType(),refreshDisabledState:t=>e.refreshDisabledState(t),setRowStyle:t=>e.setRowStyle(t),setEditableCellStyle:t=>e.setEditableCellStyle(t),setShowEditableCellIcon:t=>e.setShowEditableCellIcon(t),setDisabledCellStyle:t=>e.setDisabledCellStyle(t),setShowDisabledCellIcon:t=>e.setShowDisabledCellIcon(t),setCellStyle:(t,n,r)=>e.setCellStyle(t,n,r),getCellStyle:(t,n)=>e.getCellStyle(t,n),getCellStyleOverride:(t,n)=>e.getCellStyleOverride(t,n),clearCellStyles:t=>e.clearCellStyles(t),refreshCellStyles:t=>e.refreshCellStyles(t),startEditingCell:t=>e.startEditingCell(t),stopEditing:t=>e.stopEditing(t),commit:t=>e.commit(t),isEditing:()=>e.isEditing(),isCommitting:()=>e.isCommitting(),awaitCommitIdle:()=>e.awaitCommitIdle(),cancelCommit:()=>e.cancelCommit(),getEditSessionPhase:()=>e.getEditSessionPhase(),getEditingCell:()=>e.getEditingCell(),getEditingCells:()=>e.getEditingCells(),registerCellEditor:(t,n)=>e.registerCellEditor(t,n),unregisterCellEditor:t=>e.unregisterCellEditor(t),getCellEditorCache:(t,n,r)=>e.getCellEditorCache(t,n,r),setCellEditorCache:(t,n,r,i)=>e.setCellEditorCache(t,n,r,i),clearCellEditorCache:(t,n,r)=>e.clearCellEditorCache(t,n,r),clearAllCellEditorCache:()=>e.clearAllCellEditorCache(),validate:t=>e.validate(t),validateRows:t=>e.validateRows(t),validateCells:t=>e.validateCells(t),clearValidation:t=>e.clearValidation(t),clearRowValidation:t=>e.clearRowValidation(t),clearCellValidation:t=>e.clearCellValidation(t),toggleRowSelection:(t,n,r)=>e.toggleRowSelection(t,n,r),toggleAllSelection:t=>e.toggleAllSelection(t),clearRowSelection:t=>e.clearRowSelection(t),setDefaultSelectedRows:(t,n)=>e.setDefaultSelectedRows(t,n),clearPendingDefaultSelectedRows:()=>e.clearPendingDefaultSelectedRows(),reconcileDefaultSelectedRows:()=>e.reconcileDefaultSelectedRows(),getSelectedRowIds:()=>e.getSelectedRowIds(),getSelectedRows:()=>e.getSelectedRows(),getIndexFocusedRowIds:t=>e.getIndexFocusedRowIds(t),getIndexFocusedRows:t=>e.getIndexFocusedRows(t),setIndexFocus:(t,n)=>e.setIndexFocus(t,n),destroy:()=>e.destroy(),on:(t,n)=>e.on(t,n)}}var zd=[`.mg-cell-editor-host`],Bd=[];function Vd(e){Bd.push(...e)}function Hd(){Bd.length=0}function Ud(e){return e instanceof Element?e:e instanceof Text?e.parentElement:null}function Wd(){return[...zd,...Bd]}function Gd(e){let t=Ud(e);return t?Wd().some(e=>t.closest(e)!=null):!1}function Kd(e=document.activeElement){return Gd(e)}var qd=[`mg-cell-editor-host--align-h-left`,`mg-cell-editor-host--align-h-center`,`mg-cell-editor-host--align-h-right`];function Jd(e,t){for(let t of qd)e.classList.remove(t);e.classList.add(`mg-cell-editor-host--align-h-${t}`)}function Yd(e,n,r){Jd(e,t.d(n,r))}var Xd=`mg-inline-checkbox`,Zd=`mg-inline-switch`,Qd=`mg-switch-editor`,$d=[Xd,Zd];function ef(e,t){let n=document.createElement(`input`);return n.className=`mg-cell-editor`,n.type=e,n.value=t,n.style.width=`100%`,n.style.height=`100%`,n.style.boxSizing=`border-box`,n}function tf(e,t){let n=document.createElement(`input`);return n.type=`checkbox`,n.className=t.inline?[`mg-cell-editor`,t.inlineClass,t.extraClasses].filter(Boolean).join(` `):[`mg-cell-editor`,t.extraClasses].filter(Boolean).join(` `),n.checked=t.checked,t.role&&n.setAttribute(`role`,t.role),t.params.setGetValue?.(()=>t.readValue(n)),t.inline&&(n.addEventListener(`click`,e=>{e.stopPropagation()}),n.addEventListener(`change`,()=>{t.params.commit?.()})),e.mountEl.appendChild(n),n}var nf=(e,t)=>{let n=ef(`text`,e.formattedValue);return t.mountEl.appendChild(n),n},rf=(e,t)=>{let n=ef(`number`,e.value==null||e.value===``?``:String(e.value));return t.mountEl.appendChild(n),n},af=(e,t)=>{let n=Lt(e.cellEditorParams)??null;return tf(t,{inline:e.inline===!0,inlineClass:Xd,checked:tn(e.value,n),readValue:e=>rn(e,n),params:e})},of=(e,t)=>{let n=Rt(e.cellEditorParams)??null;return tf(t,{inline:e.inline===!0,inlineClass:Zd,extraClasses:Qd,role:`switch`,checked:Jt(e.value,n),readValue:e=>Zt(e,n),params:e})};function sf(e){return e===`checkbox`||e===`switch`}function cf(e){return e instanceof Element&&$d.some(t=>e.closest(`input.${t}`))}function lf(e,t){return e instanceof HTMLInputElement&&e.type===`checkbox`?Zt(e,on(t??{})):e.value}var uf=new Map;function df(e,t){if(!e||wn(e))throw Error(`Invalid cell editor name "${e}"`);uf.set(e,t)}function ff(e){return uf.delete(e)}function pf(e){return uf.get(e)}function mf(e){return uf.has(e)}function hf(){return[...uf.keys()]}function gf(e,t={}){return t[e]??uf.get(e)}function _f(e,t={}){return e===void 0?nf:typeof e==`function`?e:wn(e)?e===`number`?rf:e===`checkbox`?af:e===`switch`?of:nf:gf(e,t.byName)||(console.warn(`[magic-grid] Cell editor "${e}" is not registered; falling back to text editor.`),nf)}var vf=class{onUnmountEditor;instanceEditors;editorOptions;constructor(e={}){this.onUnmountEditor=e.onUnmountEditor,this.instanceEditors={...e.byName??{}},this.editorOptions=e.editorOptions??t.f()}register(e,t){if(!e||wn(e))throw Error(`Invalid cell editor name "${e}"`);this.instanceEditors[e]=t}unregister(e){return delete this.instanceEditors[e]}has(e){return e in this.instanceEditors||gf(e,this.instanceEditors)!==void 0}mount(e,t,n,r){let i=e.querySelector(`.mg-cell[data-col-id="${t.colId}"]`),a=i??e,o=document.createElement(`div`);o.className=`mg-cell-editor-host`,Yd(o,t.align,this.editorOptions),o.style.position=`absolute`,o.style.top=`0`,o.style.boxSizing=`border-box`,i?(o.style.left=`0`,o.style.width=`100%`,o.style.height=`100%`,i.classList.add(`mg-cell--editing`)):(o.style.left=`${t.left}px`,o.style.width=`${t.width}px`,o.style.height=`100%`),a.appendChild(o);let s=null,c={mountEl:o,clear:()=>{this.onUnmountEditor?.(o),o.replaceChildren()}},l={...Ht(t,n),setGetValue:e=>{s=e}},u=_f(r,{byName:this.instanceEditors})(l,c);return u instanceof HTMLElement&&!o.contains(u)&&o.appendChild(u),{mountEl:o,getValue:()=>{if(s)return s();let e=o.querySelector(`input:not([type="hidden"]).mg-cell-editor, select.mg-cell-editor, textarea.mg-cell-editor`);if(e)return lf(e,t);let r=o.querySelector(`input:not([type="hidden"]), select, textarea`);return r?lf(r,t):n.formattedValue},getFocusTarget:()=>u instanceof HTMLElement?u:o.querySelector(`input:not([type="hidden"]), select, textarea, [tabindex]`)??o.firstElementChild,destroy:()=>{o.parentElement?.classList.remove(`mg-cell--editing`),c.clear(),o.remove()}}}},yf=class{editing=null;mountedEditor=null;listenerTarget=null;onCommit=null;onCancel=null;onEditingStopped=null;onTab=null;onEditingInput=null;onCommitLifecycle=null;oldValue=void 0;blurCommitAfterClickListener=null;blurCommitFallbackTimer=null;pinnedRowIds=new Set;editorHost;keyboardPolicy={};phase=`idle`;commitController=null;inflightCommit=null;nextCommitId=0;handleEditorKeyDown=e=>{if(this.phase===`committing`){e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this.cancelCommit());return}if(e.key===`Enter`){if(this.shouldDeferEnterCommit())return;e.preventDefault(),e.stopPropagation(),this.stopEditing(!0)}else if(e.key===`Escape`)e.preventDefault(),e.stopPropagation(),this.stopEditing(!1);else if(e.key===`Tab`){if(this.keyboardPolicy.suppressTabNavigation===!0)return;e.preventDefault(),e.stopPropagation();let t=this.onTab,n=e.shiftKey;this.stopEditing(!0).then(e=>{e?.committed&&t?.(n)})}else e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&this.onEditingInput?.()};handleEditorFocusOut=e=>{let t=e,n=this.editing;requestAnimationFrame(()=>{this.isEditing()&&this.editing===n&&this.phase!==`committing`&&(this.isFocusWithinEditorSurface(t)||(this.clearPendingBlurCommit(),this.scheduleBlurCommitAfterClick()))})};constructor(e){this.editorHost=e??new vf}getEditingCell(){return this.editing}isEditing(){return this.editing!==null}isCommitting(){return this.phase===`committing`}getEditSessionPhase(){return this.phase}getEditorValue(){return this.mountedEditor?.getValue()??null}getEditorMountEl(){return this.mountedEditor?.mountEl??null}awaitCommitIdle(){return(this.inflightCommit??Promise.resolve()).then(()=>void 0)}isPinnedRow(e){return this.pinnedRowIds.has(e)}getPinnedRowIds(){return this.pinnedRowIds}cancelCommit(){this.phase===`committing`&&(this.commitController?.abort(),this.finishCommittingVisual(),this.phase=`editing`,this.commitController=null,this.onCommitLifecycle?.onAborted?.())}startEditing(e,t,n,r,i,a){this.stopEditing(!1),this.editing={rowId:t.id,colId:n.colId,rowIndex:t.rowIndex},this.oldValue=i,this.phase=`editing`,this.pinnedRowIds.add(t.id),this.onCommit=a.onCommit,this.onCancel=a.onCancel,this.onEditingStopped=a.onEditingStopped??null,this.onTab=a.onTab??null,this.onEditingInput=a.onEditingInput??null,this.onCommitLifecycle=a.onCommitLifecycle??null;let o={};this.keyboardPolicy=o;let{editorParams:s}=a,c={...s,rowId:t.id,rowIndex:t.rowIndex,colId:n.colId,value:i,data:t.data,formattedValue:r,size:s.size??`default`,stopEditing:(e=!0)=>this.stopEditing(e).then(e=>e?{committed:e.committed}:null),cancelCommit:()=>this.cancelCommit(),getEditPhase:()=>this.phase,validate:s.validate??(async()=>({valid:!0})),setKeyboardPolicy:e=>{Object.assign(o,e),this.keyboardPolicy=o}};this.mountedEditor=this.editorHost.mount(e,n,c,n.cellEditor),this.attachEditorListeners(this.mountedEditor),requestAnimationFrame(()=>{this.mountedEditor&&this.isEditing()&&this.keyboardPolicy.suppressInitialAutoFocus!==!0&&this.focusEditor(this.mountedEditor)})}async stopEditing(e){if(!this.editing||!this.mountedEditor)return null;if(this.phase===`committing`)return e||this.cancelCommit(),this.inflightCommit;if(this.clearPendingBlurCommit(),!e)return this.cancelEditingSession();let t=this.commitEditingSession();this.inflightCommit=t;try{return await t}finally{this.inflightCommit===t&&(this.inflightCommit=null)}}destroy(){this.clearPendingBlurCommit(),this.cancelCommit(),this.mountedEditor&&(this.detachEditorListeners(),this.mountedEditor.destroy()),this.mountedEditor=null,this.editing=null,this.onCommit=null,this.onCancel=null,this.onEditingStopped=null,this.onTab=null,this.onEditingInput=null,this.onCommitLifecycle=null,this.oldValue=void 0,this.keyboardPolicy={},this.phase=`idle`,this.commitController=null,this.inflightCommit=null,this.pinnedRowIds.clear()}async commitEditingSession(){if(!this.editing||!this.mountedEditor)return null;let t=this.editing,n=this.mountedEditor,r=n.getValue(),i=this.onCommit,a=this.oldValue,o=++this.nextCommitId;this.phase=`committing`,this.setCommittingVisual(!0),this.onCommitLifecycle?.onStarted?.();let s=e.s(o,this.commitController);this.commitController=s;let c={ok:!1};try{let e=await i?.(r,s.context);if(s.context.commitId!==o)return null;c=e??{ok:!0}}catch(t){if(e.c(t))c={ok:`aborted`};else throw t}finally{this.commitController===s&&(this.commitController=null),this.finishCommittingVisual()}if(s.context.commitId!==o||this.editing!==t)return null;if(this.onCommitLifecycle?.onFinished?.(c),c.ok===`aborted`)return this.phase=`editing`,this.onCommitLifecycle?.onAborted?.(),null;if(c.ok===!1){if(c.revert){let e=this.onEditingStopped;this.teardownEditorSession(n);let r={committed:!1,oldValue:a,newValue:void 0,rowId:t.rowId,colId:t.colId,rowIndex:t.rowIndex};return e?.(r),r}return this.phase=`editing`,this.focusEditor(n),null}let l=c.newValue===void 0?r:c.newValue;return this.finalizeSuccessfulCommit(t,n,a,l)}cancelEditingSession(){if(!this.editing||!this.mountedEditor)return null;let e=this.editing,t=this.mountedEditor,n=this.onCancel,r=this.onEditingStopped,i=this.oldValue;this.teardownEditorSession(t),n?.();let a={committed:!1,oldValue:i,newValue:void 0,rowId:e.rowId,colId:e.colId,rowIndex:e.rowIndex};return r?.(a),a}finalizeSuccessfulCommit(e,t,n,r){let i=this.onEditingStopped;this.teardownEditorSession(t);let a={committed:!0,oldValue:n,newValue:r,rowId:e.rowId,colId:e.colId,rowIndex:e.rowIndex};return i?.(a),a}teardownEditorSession(e){let t=this.editing;this.detachEditorListeners(),this.mountedEditor=null,this.editing=null,this.onCommit=null,this.onCancel=null,this.onEditingStopped=null,this.onTab=null,this.onEditingInput=null,this.onCommitLifecycle=null,this.oldValue=void 0,this.keyboardPolicy={},this.phase=`idle`,this.commitController=null,t&&this.pinnedRowIds.delete(t.rowId),e.destroy()}setCommittingVisual(e){if(!this.editing||!this.mountedEditor)return;let t=this.mountedEditor.mountEl.parentElement;((t?.classList.contains(`mg-cell`)?t.parentElement:t)?.querySelector(`.mg-cell[data-col-id="${this.editing.colId}"]`))?.classList.toggle(`mg-cell--committing`,e),this.mountedEditor.mountEl.classList.toggle(`mg-cell-editor-host--committing`,e)}finishCommittingVisual(){this.setCommittingVisual(!1)}attachEditorListeners(e){this.listenerTarget=e.mountEl,this.listenerTarget.addEventListener(`keydown`,this.handleEditorKeyDown,!0),this.listenerTarget.addEventListener(`focusout`,this.handleEditorFocusOut)}detachEditorListeners(){this.listenerTarget&&=(this.listenerTarget.removeEventListener(`keydown`,this.handleEditorKeyDown,!0),this.listenerTarget.removeEventListener(`focusout`,this.handleEditorFocusOut),null)}resolveFocusTarget(e){let t=e.getFocusTarget();return t?t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement?t:t.querySelector(`input:not([type="hidden"]), select, textarea`)??t:null}shouldDeferEnterCommit(){return this.keyboardPolicy.deferEnterCommit===!0}isFocusWithinEditorSurface(e){return!!(Kd()||e?.relatedTarget instanceof Node&&Gd(e.relatedTarget))}focusEditor(e){let t=this.resolveFocusTarget(e);t&&t.focus()}scheduleBlurCommitAfterClick(){let e=()=>{this.clearPendingBlurCommit(),!(!this.isEditing()||this.phase===`committing`)&&this.stopEditing(!0).then(e=>{e===null&&this.isEditing()&&this.mountedEditor&&this.focusEditor(this.mountedEditor)})};this.blurCommitAfterClickListener=t=>{Gd(t.target)||e()},window.addEventListener(`click`,this.blurCommitAfterClickListener,!1),this.blurCommitFallbackTimer=window.setTimeout(()=>{e()},300)}clearPendingBlurCommit(){this.blurCommitAfterClickListener&&=(window.removeEventListener(`click`,this.blurCommitAfterClickListener,!1),null),this.blurCommitFallbackTimer!==null&&(clearTimeout(this.blurCommitFallbackTimer),this.blurCommitFallbackTimer=null)}};function bf(e){return[...e.getLeftFixedColumnIndices(),...e.getCenterColumnIndices(),...e.getRightFixedColumnIndices()]}function xf(e,t){let n=t.indexOf(e);return n>=0?n:0}function Sf(e,t){return t[e]}function Cf(e){return e[0]??0}function wf(e){return e[e.length-1]??0}var Tf=`__header__`,Ef=`__footer__`;function Df(e){return e.rowIndex===-1}function Of(e){return e.rowIndex===-2}function q(e){return Df(e)||Of(e)}function kf(e={}){return{headerEnabled:e.headerEnabled??!1,footerEnabled:e.footerEnabled??!1}}function Af(e,t){return e===-1?Tf:e===-2?Ef:t(e)}var jf=class{focus=null;getFocusedCell(){return this.focus}setFocusedCell(e){this.focus=e}clear(){this.focus=null}move(e,t,n,r,i,a={}){let o=this.focus??Lf(t,n,r,i);if(!o)return null;let s=Mf(o,e,t,n,r,i,a);return this.focus=s,s}moveTab(e,t,n,r,i,a={}){let o=this.focus??Lf(t,n,r,i);if(!o)return null;let s=Nf(o,e,t,n,r,i,a);return this.focus=s,s}moveToEdge(e,t,n,r,i,a={}){let o=this.focus??Lf(t,n,r,i);if(!o)return null;let s=Pf(o,e,t,n,r,i,a);return this.focus=s,s}};function Mf(e,t,n,r,i,a,o={}){let{headerEnabled:s,footerEnabled:c}=kf(o),l=r.length;if(n<=0||l<=0)return null;let u=e.rowIndex,d=xf(e.colIndex,r);t===`up`?u===-2?u=n-1:u===-1||(u===0?s&&(u=-1):--u):t===`down`?u=s&&u===-1?0:c&&u===n-1?-2:Math.min(n-1,u+1):t===`left`?d=Math.max(0,d-1):t===`right`&&(d=Math.min(l-1,d+1));let f=Sf(d,r),p=Af(u,i),m=f===void 0?void 0:a(f);return f===void 0||!p||!m||u===e.rowIndex&&f===e.colIndex?e:{rowId:p,colId:m,rowIndex:u,colIndex:f}}function Nf(e,t,n,r,i,a,o={}){let{headerEnabled:s,footerEnabled:c}=kf(o),l=r.length;if(n<=0||l<=0)return null;let u=e.rowIndex,d=xf(e.colIndex,r);t?c&&u===-2&&d===0?(u=n-1,d=l-1):u===-2&&d>0?--d:s&&u===0&&d===0?(u=-1,d=l-1):s&&u===-1?d>0&&--d:d>0?--d:u>0&&(--u,d=l-1):s&&u===-1?d<l-1?d+=1:(u=0,d=0):u===-2?d<l-1&&(d+=1):d<l-1?d+=1:u<n-1?(u+=1,d=0):c&&u===n-1&&(u=-2,d=0);let f=Sf(d,r),p=Af(u,i),m=f===void 0?void 0:a(f);return f===void 0||!p||!m||u===e.rowIndex&&f===e.colIndex?e:{rowId:p,colId:m,rowIndex:u,colIndex:f}}function Pf(e,t,n,r,i,a,o={}){let{headerEnabled:s,footerEnabled:c}=kf(o),l=r.length;if(n<=0||l<=0)return null;let u=e.rowIndex,d=e.colIndex;t===`up`?u=s?-1:0:t===`down`?u=c?-2:n-1:t===`left`?d=Cf(r):t===`right`&&(d=wf(r));let f=Af(u,i),p=a(d);return!f||!p||u===e.rowIndex&&d===e.colIndex?e:{rowId:f,colId:p,rowIndex:u,colIndex:d}}function Ff(e,t,n,r,i,a,o,s={}){let c=r.length;if(n<=0||c<=0)return null;let l=e,u=n*c;for(let e=0;e<u;e++){let e=Nf(l,t,n,r,i,a,s);if(!e||e.rowIndex===l.rowIndex&&e.colIndex===l.colIndex)return null;if(l=e,e.rowIndex!==-1&&e.rowIndex!==-2&&o(e.rowIndex,e.colId))return e}return null}function If(e,t,n){if(t.length===0)return null;if(t.length===1)return t[0]??null;let r=t.indexOf(e),i=r>=0?r:0;return t[n?(i-1+t.length)%t.length:(i+1)%t.length]??null}function Lf(e,t,n,r){let i=Cf(t),a=n(0),o=r(i);return!a||!o||e<=0||t.length===0?null:{rowId:a,colId:o,rowIndex:0,colIndex:i}}var Rf=class{editing=null;onCommitRow=null;onFocusColChange=null;activeColId=null;onCancel=null;onRowEditingStopped=null;onCommitLifecycle=null;blurCommitAfterClickListener=null;blurCommitFallbackTimer=null;attachedListeners=[];pinnedRowIds=new Set;editorHost;phase=`idle`;commitController=null;inflightCommit=null;nextCommitId=0;handleEditorKeyDown=e=>{if(this.phase===`committing`){e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this.cancelCommit());return}if(e.key===`Tab`){let t=this.resolveColIdFromEvent(e);if((t?this.editing?.cells.get(t):void 0)?.keyboardPolicy.suppressTabNavigation===!0)return;e.preventDefault(),e.stopPropagation(),this.navigateRowTab(e.shiftKey,t);return}if(e.key===`Enter`){let t=this.resolveColIdFromEvent(e);if((t?this.editing?.cells.get(t):void 0)?.keyboardPolicy.deferEnterCommit)return;e.preventDefault(),e.stopPropagation(),this.stopRowEditing(!0);return}e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this.stopRowEditing(!1))};handleEditorBlur=e=>{let t=e,n=this.editing;requestAnimationFrame(()=>{this.isEditing()&&this.editing===n&&this.phase!==`committing`&&(this.isFocusWithinRowEditors(t.relatedTarget)||(this.clearPendingBlurCommit(),this.scheduleBlurCommitAfterClick()))})};constructor(e){this.editorHost=e??new vf}getEditingRow(){return this.editing?{rowId:this.editing.rowId,rowIndex:this.editing.rowIndex}:null}getActiveColId(){return this.editing?this.activeColId&&this.editing.cells.has(this.activeColId)?this.activeColId:this.editing.focusColId&&this.editing.cells.has(this.editing.focusColId)?this.editing.focusColId:this.editing.cells.keys().next().value??null:null}focusEditingColumn(e){return this.editing?.cells.has(e)?(this.focusRowEditor(e),!0):!1}getEditingCells(){return this.editing?[...this.editing.cells.values()].map(e=>({rowId:this.editing.rowId,rowIndex:this.editing.rowIndex,colId:e.colId})):[]}getEditorValue(e){return this.editing?.cells.get(e)?.mountedEditor.getValue()??null}getEditorMountEl(e){return this.editing?.cells.get(e)?.mountedEditor.mountEl??null}isEditing(){return this.editing!==null}isCommitting(){return this.phase===`committing`}getEditSessionPhase(){return this.phase}awaitCommitIdle(){return(this.inflightCommit??Promise.resolve()).then(()=>void 0)}cancelCommit(){this.phase===`committing`&&(this.commitController?.abort(),this.finishCommittingVisual(),this.phase=`editing`,this.commitController=null,this.onCommitLifecycle?.onAborted?.())}isPinnedRow(e){return this.pinnedRowIds.has(e)}getPinnedRowIds(){return this.pinnedRowIds}startRowEditing(e){if(e.columns.length===0)return!1;this.stopRowEditing(!1);let{rowElement:t,rowNode:n,columns:r,focusColId:i}=e,a=new Map;for(let e of r){let n={},r={...e.params,autoFocus:i==null||e.column.colId===i,stopEditing:(e=!0)=>this.stopRowEditing(e).then(e=>e?{committed:e.committed}:null),cancelCommit:()=>this.cancelCommit(),getEditPhase:()=>this.phase,setKeyboardPolicy:t=>{Object.assign(n,t);let r=a.get(e.column.colId);r&&(r.keyboardPolicy=n)}},o=this.editorHost.mount(t,e.column,r,e.column.cellEditor);a.set(e.column.colId,{colId:e.column.colId,column:e.column,oldValue:e.oldValue,mountedEditor:o,keyboardPolicy:n}),this.attachEditorListeners(o)}return this.editing={rowId:n.id,rowIndex:n.rowIndex,rowElement:t,focusColId:i,cells:a},this.phase=`editing`,this.onCommitRow=e.onCommitRow,this.onFocusColChange=e.onFocusColChange??null,this.onCancel=e.onCancel??null,this.onRowEditingStopped=e.onRowEditingStopped??null,this.onCommitLifecycle=e.onCommitLifecycle??null,this.pinnedRowIds.add(n.id),queueMicrotask(()=>{let e=i??(this.editing?.focusColId&&this.editing.cells.has(this.editing.focusColId)?this.editing.focusColId:this.editing?.cells.keys().next().value);if((e?this.editing?.cells.get(e):void 0)?.keyboardPolicy.suppressInitialAutoFocus===!0){e&&(this.activeColId=e,this.editing.focusColId=e,this.onFocusColChange?.(e));return}this.focusRowEditor(i)}),!0}async stopRowEditing(e){if(!this.editing)return null;if(this.phase===`committing`)return e||this.cancelCommit(),this.inflightCommit;if(this.clearPendingBlurCommit(),!e)return this.cancelRowEditingSession();let t=this.commitRowEditingSession();this.inflightCommit=t;try{return await t}finally{this.inflightCommit===t&&(this.inflightCommit=null)}}destroy(){this.clearPendingBlurCommit(),this.cancelCommit(),this.teardownEditingState(),this.onCommitRow=null,this.onFocusColChange=null,this.activeColId=null,this.onCancel=null,this.onRowEditingStopped=null,this.onCommitLifecycle=null,this.phase=`idle`,this.commitController=null,this.inflightCommit=null,this.pinnedRowIds.clear()}async commitRowEditingSession(){if(!this.editing)return null;let t=this.editing,n=new Map;for(let e of t.cells.values())n.set(e.colId,e.mountedEditor.getValue());let r=this.onCommitRow;if(!r)return null;let i=++this.nextCommitId;this.phase=`committing`,this.setCommittingVisual(!0),this.onCommitLifecycle?.onStarted?.();let a=e.s(i,this.commitController);this.commitController=a;let o={ok:!1,failedColId:``};try{let e=await r(n,a.context);if(a.context.commitId!==i)return null;o=e}catch(t){if(e.c(t))o={ok:`aborted`};else throw t}finally{this.commitController===a&&(this.commitController=null),this.finishCommittingVisual()}return a.context.commitId!==i||this.editing!==t?null:(this.onCommitLifecycle?.onFinished?.(o),o.ok===`aborted`?(this.phase=`editing`,this.onCommitLifecycle?.onAborted?.(),null):o.ok===!1?o.revert?this.revertRowEditingSession(t):(this.phase=`editing`,this.focusRowEditor(o.failedColId),null):this.finalizeSuccessfulCommit(t,o.cells))}revertRowEditingSession(e){let t=this.onRowEditingStopped,n=[];for(let t of e.cells.values())n.push({colId:t.colId,committed:!1,oldValue:t.oldValue,newValue:void 0});this.teardownEditingState(),this.onCommitRow=null,this.onFocusColChange=null,this.activeColId=null,this.onCancel=null,this.onRowEditingStopped=null,this.onCommitLifecycle=null;let r={rowId:e.rowId,rowIndex:e.rowIndex,committed:!1,cells:n};return t?.(r),r}cancelRowEditingSession(){if(!this.editing)return null;let e=this.editing,t=this.onCancel,n=this.onRowEditingStopped,r=[];for(let t of e.cells.values())r.push({colId:t.colId,committed:!1,oldValue:t.oldValue,newValue:void 0});this.teardownEditingState(),t?.(),this.onCommitRow=null,this.onFocusColChange=null,this.activeColId=null,this.onCancel=null,this.onRowEditingStopped=null,this.onCommitLifecycle=null;let i={rowId:e.rowId,rowIndex:e.rowIndex,committed:!1,cells:r};return n?.(i),i}finalizeSuccessfulCommit(e,t){let n=this.onRowEditingStopped;this.teardownEditingState(),this.onCommitRow=null,this.onFocusColChange=null,this.activeColId=null,this.onCancel=null,this.onRowEditingStopped=null,this.onCommitLifecycle=null;let r={rowId:e.rowId,rowIndex:e.rowIndex,committed:!0,cells:t};return n?.(r),r}teardownEditingState(){if(this.editing){for(let e of this.editing.cells.values())e.mountedEditor.destroy();this.detachEditorListeners(),this.editing=null,this.phase=`idle`,this.commitController=null,this.pinnedRowIds.clear()}}setCommittingVisual(e){if(this.editing){this.editing.rowElement.classList.toggle(`mg-row--committing`,e);for(let t of this.editing.cells.values())t.mountedEditor.mountEl.classList.toggle(`mg-cell-editor-host--committing`,e)}}finishCommittingVisual(){this.setCommittingVisual(!1)}attachEditorListeners(e){let t=e.getFocusTarget();if(e.mountEl.addEventListener(`keydown`,this.handleEditorKeyDown,!0),t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement){t.addEventListener(`blur`,this.handleEditorBlur),this.attachedListeners.push({mountEl:e.mountEl,blurTarget:t});return}this.attachedListeners.push({mountEl:e.mountEl,blurTarget:null})}detachEditorListeners(){for(let e of this.attachedListeners)e.mountEl.removeEventListener(`keydown`,this.handleEditorKeyDown,!0),e.blurTarget&&e.blurTarget.removeEventListener(`blur`,this.handleEditorBlur);this.attachedListeners.length=0}focusRowEditor(e){if(!this.editing)return;let t=e&&this.editing.cells.has(e)?e:this.editing.focusColId&&this.editing.cells.has(this.editing.focusColId)?this.editing.focusColId:this.editing.cells.keys().next().value;t&&((this.editing.cells.get(t)?.mountedEditor.getFocusTarget())?.focus(),this.activeColId=t,this.editing.focusColId=t,this.onFocusColChange?.(t))}getOrderedEditableColIds(){return this.editing?[...this.editing.cells.values()].sort((e,t)=>e.column.left-t.column.left).map(e=>e.colId):[]}navigateRowTab(e,t){if(!this.editing)return;let n=this.getOrderedEditableColIds(),r=t??this.activeColId??n[0];if(!r)return;let i=If(r,n,e);i&&this.focusRowEditor(i)}resolveColIdFromEvent(e){if(!this.editing)return;let t=e.target;if(t instanceof Node){for(let e of this.editing.cells.values())if(e.mountedEditor.mountEl.contains(t))return e.colId}}isFocusWithinRowEditors(e){if(!this.editing)return!1;if(e instanceof Node){for(let t of this.editing.cells.values())if(t.mountedEditor.mountEl.contains(e))return!0;if(Gd(e))return!0}return Kd()}scheduleBlurCommitAfterClick(){let e=()=>{this.clearPendingBlurCommit(),!(!this.isEditing()||this.phase===`committing`)&&this.stopRowEditing(!0).then(e=>{e===null&&this.isEditing()&&this.focusRowEditor()})};this.blurCommitAfterClickListener=t=>{Gd(t.target)||e()},window.addEventListener(`click`,this.blurCommitAfterClickListener,!1),this.blurCommitFallbackTimer=window.setTimeout(()=>{e()},300)}clearPendingBlurCommit(){this.blurCommitAfterClickListener&&=(window.removeEventListener(`click`,this.blurCommitAfterClickListener,!1),null),this.blurCommitFallbackTimer!==null&&(clearTimeout(this.blurCommitFallbackTimer),this.blurCommitFallbackTimer=null)}};function zf(e,t){return`${e}::${t}`}function Bf(e,t){return e?.backgroundColor===t.backgroundColor&&e?.color===t.color}var Vf=class{overrides=new Map;get(e,t){return this.overrides.get(zf(e,t))}set(e,t,n){let r=zf(e,t);return!Bf(this.overrides.get(r),n)&&(this.overrides.set(r,{...n}),!0)}delete(e,t){return this.overrides.delete(zf(e,t))}clear(e){if(!e?.rowIds?.length&&!e?.colIds?.length){this.overrides.clear();return}let t=e.rowIds?.length?new Set(e.rowIds.map(e=>String(e))):null,n=e.colIds?.length?new Set(e.colIds):null;for(let e of[...this.overrides.keys()]){let r=e.indexOf(`::`);if(r<0){this.overrides.delete(e);continue}let i=e.slice(0,r),a=e.slice(r+2);t&&!t.has(i)||n&&!n.has(a)||this.overrides.delete(e)}}};function Hf(e){if(e==null||!Array.isArray(e))return null;let t=e.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean);return t.length>0?t:null}function Uf(e){if(e==null)return null;if(Array.isArray(e)){let t=Hf(e);return t?{errors:t}:null}if(typeof e==`object`&&Array.isArray(e.errors)){let t=Hf(e.errors);if(!t)return null;let n=e.colIds?.filter(e=>typeof e==`string`&&e.length>0);return n?.length?{errors:t,colIds:n}:{errors:t}}return null}function Wf(e,t){return e.length===0||t.length===0?[]:t.length===1?e.map(e=>({colId:e,errors:[t[0]]})):t.length===e.length?e.map((e,n)=>({colId:e,errors:[t[n]]})):e.map(e=>({colId:e,errors:[...t]}))}function Gf(e,t){if(t?.length)return[...t];let n=new Set(e);return n.has(`min`)&&n.has(`max`)?[`min`,`max`]:e.length>0?[e[0]]:[]}async function Kf(t,n,r,i){e.l(i);let a=t.cellValidator;if(!a)return null;try{let t=await a({...n,parsedValue:r,signal:i});return e.l(i),Hf(t)}catch(t){throw e.c(t),t}}async function qf(t,n){if(!t)return null;e.l(n.signal);try{let r=await t(n);return e.l(n.signal),Uf(r)}catch(t){throw e.c(t),t}}async function Jf(e,t,n,r){let i=await Kf(e,t,n,r??new AbortController().signal);return i?{valid:!1,errors:i}:{valid:!0}}function Yf(e,t){return t.index?String(t.index(e)):String(e+t.start)}function Xf(e,n,r){if(t.it(n.colId))return r?Yf(e.rowIndex,r):String(e.rowIndex+1);if(t.X(n.colId)||A(n.colId)||n.rowExpand||L(n.colId))return``;if(He(e)&&n.groupAgg)return e.__groupAggValues?.[n.colId]?.formattedValue??``;let i=n.prop??n.colId,a=i?e.data[i]:void 0;return n.valueGetter&&(a=n.valueGetter(e.data,a)),n.formatter?n.formatter(e.data,a):a==null?``:String(a)}function Zf(e){return{api:e.getApi(),size:e.gridSize}}var Qf=new AbortController().signal;async function $f(t,n,r,i,a){let o=t.cellCommitted;if(!o)return;let s=i.buildRowSnapshot(n);if(!s)return;let c=a.signal??Qf,l=Xf(n,t,i.getIndexColumnOptions?.());try{await o({row:s,colId:t.colId,value:r.newValue,oldValue:r.oldValue,newValue:r.newValue,formattedValue:l,source:a.source,signal:c,context:Zf(i)})}catch(n){if(e.c(n))throw n;console.error(`[magic-grid] cellCommitted failed`,{colId:t.colId,rowId:s.rowId,internalRowId:s.internalRowId,source:a.source,error:n})}}async function ep(e,t){e.beginUpdate();try{await t()}finally{e.endUpdate()}}var tp=class{pending=new Map;batchSeq=0;record(e){if(Object.is(e.oldValue,e.newValue))return;let t=this.pending.get(e.rowNode.id);t||(t={rowNode:e.rowNode,changes:new Map,sources:new Set},this.pending.set(e.rowNode.id,t));let n=t.changes.get(e.field);n?t.changes.set(e.field,{field:e.field,colId:n.colId??e.colId,oldValue:n.oldValue,newValue:e.newValue}):t.changes.set(e.field,{field:e.field,colId:e.colId,oldValue:e.oldValue,newValue:e.newValue}),t.sources.add(e.source)}flush(e){if(this.pending.size===0)return;let t=[],n=new Set;for(let r of this.pending.values()){let i=[...r.changes.values()].map(t=>({...t,colId:t.colId??e.resolveColIdByField?.(t.field)}));if(i.length===0)continue;let a=e.buildRowSnapshot(r.rowNode);if(!a)continue;let o=Object.fromEntries(i.map(e=>[e.field,e.newValue])),s=[...r.sources];for(let e of s)n.add(e);let c={rowId:r.rowNode.id,row:a,data:o,changes:i,source:s[0],sources:s.length>1?s:void 0};t.push(c),e.eventBus.emit(`rowDataChanged`,{...c,rowNode:r.rowNode})}t.length>0&&e.eventBus.emit(`rowsDataChanged`,{batchId:++this.batchSeq,rows:t,sources:[...n]}),this.pending.clear()}clear(){this.pending.clear()}peekPendingColIdsByRow(e){let t=new Map;for(let[n,r]of this.pending){let i=new Set;for(let t of r.changes.values()){let n=t.colId??e?.(t.field);n&&i.add(n)}i.size>0&&t.set(n,[...i])}return t}};function np(e,t,n,r,i,a){e({rowNode:t,field:n.prop??n.colId,colId:n.colId,oldValue:r,newValue:i,source:a})}async function rp(t,n,r,i,a,o,s){if(!r.prop)return{ok:!0,newValue:o};try{let e=_n(i,r,a);if(cn(e))return{ok:!1,revert:!0};let c=await Kf(r,a,e,s),l=t.invalidEditValueMode;return c&&l!==`keep`?{ok:!1,revert:!0}:o===e?{ok:!0,newValue:e}:await yn(r,a,e,s)?(await ep(t,async()=>{np(t.recordRowDataChange,n,r,o,e,`inlineEdit`),t.applyTransaction({update:[n.data]}),t.eventBus.emit(`cellValueChanged`,{rowId:n.id,colId:r.colId,oldValue:o,newValue:e,rowNode:n}),await $f(r,n,{oldValue:o,newValue:e},t,{source:`inlineEdit`,signal:s}),t.syncPinnedRows()}),{ok:!0,newValue:e}):{ok:!1,revert:!0}}catch(t){if(e.c(t))return{ok:`aborted`};throw t}}var ip=Symbol.for(`magic-grid.vueUserComp`);function ap(e){return e[ip]}function op(e,t){let n=e;if(t){n[ip]=t;return}delete n[ip]}function sp(e,t){if(t){op(e,t);return}op(e,void 0)}function cp(e){op(e,void 0)}function lp(e,t){let n=ap(e);return n?.refresh?n.refresh(t)!==!1:!1}function up(e){if(!e||typeof e!=`object`)return null;let t=e;if(typeof t.refresh==`function`)return t;let n=e.exposed;if(n&&typeof n.refresh==`function`)return n;let r=e.$?.exposed;return r&&typeof r.refresh==`function`?r:null}function dp(e){return t=>{sp(e,up(t))}}function fp(e){return dp(e)}function pp(e){if(!e)return null;let t=e.component;if(t)return(up(t.exposed)??up(t.proxy))||pp(t.subTree);let{children:n}=e;if(Array.isArray(n))for(let e of n){if(!e||typeof e!=`object`||!(`type`in e))continue;let t=pp(e);if(t)return t}return null}function mp(e){let t=e._vnode,n=pp(t??null);if(n){sp(e,n);return}ap(e)&&cp(e)}var hp=class{onUnmountEditor;instanceEditors;editorOptions;constructor(e={}){this.onUnmountEditor=e.onUnmountEditor,this.instanceEditors={...e.byName??{}},this.editorOptions=e.editorOptions??t.f()}mount(e,t,n,r={}){r.patch||(this.onUnmountEditor?.(e),e.replaceChildren()),Yd(e,t.align,this.editorOptions);let i=null,a=null,o={mountEl:e,clear:()=>{this.onUnmountEditor?.(e),e.replaceChildren()}},s={...Ht(t,n),inline:!0,setGetValue:e=>{i=e}},c=_f(t.cellEditor,{byName:this.instanceEditors})(s,o);return c instanceof HTMLElement&&(a=c,e.contains(c)||e.appendChild(c)),{mountEl:e,getValue:()=>{if(i)return i();let r=e.querySelector(`input:not([type="hidden"]).mg-cell-editor, select.mg-cell-editor, textarea.mg-cell-editor`);if(r)return lf(r,t);let a=e.querySelector(`input:not([type="hidden"]), select, textarea`);return a?lf(a,t):n.formattedValue},getFocusTarget:()=>a||(e.querySelector(`input:not([type="hidden"]), select, textarea, [tabindex]`)??e.firstElementChild),destroy(){o.clear()}}}patch(e,t,n){lp(e,n)||this.mount(e,t,n,{patch:!0})}isVueEditorColumn(e){return Sn(_f(e.cellEditor,{byName:this.instanceEditors}))}},gp=0,_p=new WeakMap,vp=new WeakMap;function yp(e){let t=_p.get(e);return t===void 0&&(t=++gp,_p.set(e,t)),t}function bp(e){let t=vp.get(e);return t===void 0&&(t=++gp,vp.set(e,t)),t}function xp(e){return e===void 0?`default`:typeof e==`function`?`fn#${yp(e)}`:e}function Sp(e,t,n,r,i){return`${e}:${t}:${n}:${r}:${xp(i)}`}function Cp(e,t,n){return n?`${e}:${t}:fn#${bp(n)}`:`${e}:${t}:none`}var wp=class{permanent;constructor(e={}){this.permanent=new hp(e)}mount(e,t,n,r){return this.permanent.mount(e,t,n,r)}patch(e,t,n){this.permanent.patch(e,t,n)}isVueEditorColumn(e){return this.permanent.isVueEditorColumn(e)}},Tp=class{host;commits=new Map;inFlight=new Map;deps;constructor(e){this.deps=e,this.host=new wp({onUnmountEditor:e.onUnmountEditor,byName:e.byName,editorOptions:e.editorOptions})}getRefreshContext(){return{host:this.host,createParams:(e,t)=>this.createParams(e,t),commit:(e,t,n,r)=>this.commit(e,t,n,r)}}isCommitting(){return this.commits.size>0}async awaitCommitIdle(){this.inFlight.size!==0&&await Promise.all([...this.inFlight.values()])}cancelCommit(e,t){if(e&&t){this.abortCommit(`${e}:${t}`,!0);return}for(let e of[...this.commits.keys()])this.abortCommit(e,!0)}createParams(e,t){let n=Zf(this.deps),r={rowId:e.id,rowIndex:e.rowIndex,colId:t.colId,value:H(e,t),data:e.data,formattedValue:Xf(e,t),size:this.deps.gridSize,context:n,inline:!0},i=It(t,r),a={...r,cellEditorParams:i,stopEditing:async()=>null,cancelCommit:()=>this.cancelCommit(e.id,t.colId),getEditPhase:()=>this.isCellCommitting(e.id,t.colId)?`committing`:`idle`};return{...a,validate:async n=>{let r={...a,validate:async()=>({valid:!0})},i;try{if(i=_n(Ep(H(e,t),t),t,r),cn(i))return{valid:!1,errors:[`Invalid value`]}}catch(e){return{valid:!1,errors:[e instanceof Error?e.message:`Invalid value`]}}return Jf(t,r,i,n?.signal)}}}isCellCommitting(e,t){return this.commits.has(`${e}:${t}`)}abortCommit(t,n){let r=this.commits.get(t);r&&(r.userCancelled=n,r.controller.abort(new e.o))}async commit(e,t,n,r){let i=`${e.id}:${t.colId}`,a=this.runCommit(e,t,n,r,i);this.inFlight.set(i,a);try{return await a}finally{this.inFlight.get(i)===a&&this.inFlight.delete(i)}}async runCommit(e,t,n,r,i){this.abortCommit(i,!1);let a=new AbortController,o={controller:a,rowId:e.id,colId:t.colId,rowIndex:e.rowIndex,userCancelled:!1};this.commits.set(i,o),this.deps.eventBus.emit(`cellCommitStarted`,{rowId:e.id,colId:t.colId,rowIndex:e.rowIndex});let s=this.createParams(e,t),c=await rp(this.deps,e,t,n,s,r,a.signal);return this.commits.get(i)===o&&this.commits.delete(i),c.ok===`aborted`?(o.userCancelled&&this.deps.eventBus.emit(`editCommitAborted`,{rowId:e.id,colId:t.colId,rowIndex:e.rowIndex}),this.deps.eventBus.emit(`cellCommitFinished`,{rowId:e.id,colId:t.colId,rowIndex:e.rowIndex,committed:!1,aborted:o.userCancelled}),!1):(this.deps.eventBus.emit(`cellCommitFinished`,{rowId:e.id,colId:t.colId,rowIndex:e.rowIndex,committed:c.ok===!0,aborted:!1}),c.ok===!0)}};function Ep(e,t){if(t.cellEditor===`checkbox`){let n=zt(t);return nn(tn(e,n),n)}if(t.cellEditor===`switch`){let n=Bt(t);return Xt(Jt(e,n),n)}return e==null?``:String(e)}var Dp=`mg-selection-checkbox`,Op=`mg-selection-checkbox--header`;function kp(e){let t=document.createElement(`input`);return t.type=`checkbox`,t.className=Dp,t.setAttribute(`aria-label`,e.ariaLabel),Ap(t,e),t}function Ap(e,t){e.checked=t.checked,e.indeterminate=!!t.indeterminate,e.disabled=!!t.disabled,e.classList.toggle(`mg-selection-checkbox--disabled`,!!t.disabled),e.setAttribute(`aria-checked`,t.indeterminate?`mixed`:String(t.checked))}function jp(e){return e.querySelector(`input.${Dp}`)}function Mp(e,t){return t.rowLabel?.(e)??`选择第 ${e+1} 行`}function Np(e,t,n=new Set){let r=e.getRowCount();if(r===0)return{checked:!1,indeterminate:!1};let i=0,a=0;for(let o=0;o<r;o+=1){let r=e.getRow(o);r&&(Ue(r)||I(r)||(i++,t.has(r.id)&&!n.has(r.id)&&a++))}return a===0?{checked:!1,indeterminate:!1}:a===i?{checked:!0,indeterminate:!1}:{checked:!1,indeterminate:!0}}function Pp(e,n){let{selectionColumnOptions:r,selectedIds:i,indeterminateIds:a,rowModel:o}=n;if(!r.enabled||r.mode!==`multiple`)return;let s=e.querySelector(`.mg-header-cell[data-col-id="${t.J}"]`);if(!s)return;let c=jp(s);c&&Ap(c,Np(o,i,a??new Set))}function Fp(e,t){let n=[...e.getLeftFixedColumnIndices()],r=[...e.getRightFixedColumnIndices()],i=[];if(t.lastCol>=t.firstCol)for(let n of e.getCenterColumnIndices())n>=t.firstCol&&n<=t.lastCol&&i.push(n);return{left:n,center:i,right:r}}function Ip(e,t){let n=t.getLeftFixedWidth(),r=t.getLeftFixedColumnIndices(),i=t.getRightFixedColumnIndices(),a=n+t.getCenterTotalWidth(),o=zp(t,e.colId),s=o>=0&&o===t.getColumnCount()-1;if(e.fixed===`left`){let t=r[r.length-1];return{left:e.left,width:e.width,fixed:`left`,isLastLeftFixed:t!==void 0&&t===o,isLastColumn:s}}if(e.fixed===`right`){let t=i[0];return{left:e.left-a,width:e.width,fixed:`right`,isFirstRightFixed:t!==void 0&&t===o,isLastColumn:s}}let c=t.getCenterColumnIndices(),l=c[c.length-1];return{left:e.left,width:e.width,fixed:null,isLastCenter:i.length>0&&l!==void 0&&l===o,isLastColumn:s}}function Lp(e,t,n){e.style.width=`${t.width}px`,e.style.left=`${t.left}px`,e.style.removeProperty(`right`),e.style.removeProperty(`transform`),e.classList.remove(`${n}--fixed-left`,`${n}--fixed-right`,`${n}--fixed-left-last`,`${n}--center-last`,`${n}--column-last`,`${n}--fixed-right-first`),t.fixed===`left`?(e.classList.add(`${n}--fixed-left`),t.isLastLeftFixed&&e.classList.add(`${n}--fixed-left-last`)):t.fixed===`right`?(e.classList.add(`${n}--fixed-right`),t.isFirstRightFixed&&e.classList.add(`${n}--fixed-right-first`)):t.isLastCenter&&e.classList.add(`${n}--center-last`),t.isLastColumn&&e.classList.add(`${n}--column-last`)}function Rp(e,t,n){e.querySelectorAll(`[data-col-id]`).forEach(e=>{if(!(e instanceof HTMLElement))return;let r=e.dataset.colId;if(!r)return;let i=t.getColumnById(r);i&&Lp(e,Ip(i,t),n)})}function zp(e,t){for(let n=0;n<e.getColumnCount();n++)if(e.getColumn(n)?.colId===t)return n;return-1}var Bp={left:`--align-h-left`,center:`--align-h-center`,right:`--align-h-right`},Vp={top:`--align-v-top`,center:`--align-v-center`,bottom:`--align-v-bottom`},Hp=[...Object.values(Bp),...Object.values(Vp)];function Up(e={}){return{headerAlign:e.headerAlign,headerValign:e.headerValign,align:e.align,valign:e.valign,footerAlign:e.footerAlign,footerValign:e.footerValign}}function Wp(e,t={}){return{headerAlign:e.headerAlign??t.headerAlign??`center`,headerValign:e.headerValign??t.headerValign??`center`,align:e.align??t.align??`center`,valign:e.valign??t.valign??`center`,footerAlign:e.footerAlign??t.footerAlign??`center`,footerValign:e.footerValign??t.footerValign??`center`}}function Gp(e,t,n,r){for(let t of Hp)e.classList.remove(`${r}${t}`);e.classList.add(`${r}${Bp[t]}`),e.classList.add(`${r}${Vp[n]}`)}var Kp=[[`circle`,{cx:`12`,cy:`12`,r:`1`}],[`circle`,{cx:`12`,cy:`5`,r:`1`}],[`circle`,{cx:`12`,cy:`19`,r:`1`}]],qp=[[`path`,{d:`m5 12 7-7 7 7`}],[`path`,{d:`M12 19V5`}]],Jp=[[`path`,{d:`M12 5v14`}],[`path`,{d:`m19 12-7 7-7-7`}]],Yp=[[`path`,{d:`M12 2v20`}],[`path`,{d:`m15 19-3 3-3-3`}],[`path`,{d:`m19 9 3 3-3 3`}],[`path`,{d:`M2 12h20`}],[`path`,{d:`m5 9-3 3 3 3`}],[`path`,{d:`m9 5 3-3 3 3`}]],Xp=[[`path`,{d:`m3 16 4 4 4-4`}],[`path`,{d:`M7 20V4`}],[`path`,{d:`M11 4h10`}],[`path`,{d:`M11 8h7`}],[`path`,{d:`M11 12h4`}]],Zp=[[`path`,{d:`m3 8 4-4 4 4`}],[`path`,{d:`M7 4v16`}],[`path`,{d:`M11 12h10`}],[`path`,{d:`M11 16h7`}],[`path`,{d:`M11 20h4`}]],Qp=[[`path`,{d:`M3 6h18`}],[`path`,{d:`M7 12h10`}],[`path`,{d:`M10 18h4`}]],$p=[[`path`,{d:`M12 17v5`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v3.76`}]],em=[[`path`,{d:`M12 17v5`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v3.76`}],[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`}]],tm=[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`}],[`path`,{d:`M9 3v18`}]],nm=[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`}],[`path`,{d:`M15 3v18`}]],rm=[[`path`,{d:`m9 18 6-6-6-6`}]],im=[[`path`,{d:`M13.5 10.5 22 2`}],[`path`,{d:`M14.734 13.841a2 2 0 0 0-.314-2.42L12.58 9.58a2 2 0 0 0-2.421-.314l-7.657 4.461A1 1 0 0 0 2.3 15.3l6.403 6.403a1 1 0 0 0 1.571-.204z`}],[`path`,{d:`m5 18 2-2`}],[`path`,{d:`m7.699 10.7 5.602 5.601`}]],am=[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`}],[`path`,{d:`M9 3v18`}],[`path`,{d:`M15 3v18`}]],om=[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`}]],sm=[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`}],[`path`,{d:`m2 2 20 20`}]],cm=[[`path`,{d:`M12 2v4`}],[`path`,{d:`m16.2 7.8 2.9-2.9`}],[`path`,{d:`M18 12h4`}],[`path`,{d:`m16.2 16.2 2.9 2.9`}],[`path`,{d:`M12 18v4`}],[`path`,{d:`m7.8 16.2-2.9 2.9`}],[`path`,{d:`M2 12h4`}],[`path`,{d:`m7.8 7.8-2.9-2.9`}]],lm=[[`polyline`,{points:`15 10 20 15 15 20`}],[`path`,{d:`M4 4v7a4 4 0 0 0 4 4h12`}]],um=[[`polyline`,{points:`9 14 4 9 9 4`}],[`path`,{d:`M20 20v-7a4 4 0 0 0-4-4H4`}]],dm=[[`path`,{d:`M14 17H5`}],[`path`,{d:`M19 7h-9`}],[`circle`,{cx:`17`,cy:`17`,r:`3`}],[`circle`,{cx:`7`,cy:`7`,r:`3`}]];function J(e,t,n){let r=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);r.setAttribute(`class`,e),n!=null&&(r.setAttribute(`width`,String(n)),r.setAttribute(`height`,String(n))),r.setAttribute(`viewBox`,`0 0 24 24`),r.setAttribute(`fill`,`none`),r.setAttribute(`stroke`,`currentColor`),r.setAttribute(`stroke-width`,`2`),r.setAttribute(`stroke-linecap`,`round`),r.setAttribute(`stroke-linejoin`,`round`),r.setAttribute(`aria-hidden`,`true`);for(let[e,n]of t){let t=document.createElementNS(`http://www.w3.org/2000/svg`,e);for(let[e,r]of Object.entries(n))t.setAttribute(e,String(r));r.appendChild(t)}return r}function fm(){return J(`mg-header-icon mg-header-icon--column-handle`,Kp,14)}function pm(e){let t=e===`asc`?qp:Jp;return J(`mg-sort-icon mg-sort-icon--${e}`,t,14)}function mm(){return J(`mg-header-indicator-icon mg-header-indicator-icon--filter`,Qp,14)}function hm(){return J(`mg-header-indicator-icon mg-header-indicator-icon--sort-filter-asc`,Zp,14)}function gm(){return J(`mg-header-indicator-icon mg-header-indicator-icon--sort-filter-desc`,Xp,14)}function _m(){let e=document.createDocumentFragment();return e.append(pm(`asc`),pm(`desc`)),e}function vm(){return J(`mg-column-drag-ghost__move-icon`,Yp,16)}function ym(){return J(`mg-header-icon mg-header-icon--floating-filter`,Qp,14)}function bm(){return pm(`asc`)}function xm(){return pm(`desc`)}function Sm(){return J(`mg-column-handle-menu__icon mg-column-handle-menu__icon--sort-clear`,im,14)}function Cm(){return J(`mg-column-handle-menu__icon mg-column-handle-menu__icon--pin`,$p,14)}function wm(){return J(`mg-column-handle-menu__icon mg-column-handle-menu__icon--pin-off`,em,14)}function Tm(){return J(`mg-column-handle-menu__icon mg-column-handle-menu__icon--pin-left`,tm,14)}function Em(){return J(`mg-column-handle-menu__icon mg-column-handle-menu__icon--pin-right`,nm,14)}function Dm(){return J(`mg-column-handle-menu__icon mg-column-handle-menu__icon--chevron`,rm,14)}function Om(){return J(`mg-column-handle-menu__icon mg-column-handle-menu__icon--visibility`,am,14)}function km(){return J(`mg-column-handle-menu__icon mg-column-handle-menu__icon--hide-column`,sm,14)}function Am(){return J(`mg-column-handle-menu__icon mg-column-handle-menu__icon--show-column`,om,14)}function jm(){return J(`mg-cell__row-expand__icon`,rm,16)}function Mm(){return J(`mg-cell__tree-expand__loading-icon`,cm,16)}function Nm(){return J(`mg-column-settings-menu__icon-svg`,lm)}function Pm(){return J(`mg-column-settings-menu__icon-svg`,um)}function Fm(){return J(`mg-cell__tree-hierarchy-trigger__icon`,dm,14)}var Im=[[`path`,{d:`M13 21h8`}],[`path`,{d:`m15 5 4 4`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`}]];function Lm(){return J(`mg-cell__editable-indicator-icon`,Im,14)}var Rm=[[`path`,{d:`m10 10-6.157 6.162a2 2 0 0 0-.5.833l-1.322 4.36a.5.5 0 0 0 .622.624l4.358-1.323a2 2 0 0 0 .83-.5L14 13.982`}],[`path`,{d:`m12.829 7.172 4.359-4.346a1 1 0 1 1 3.986 3.986l-4.353 4.353`}],[`path`,{d:`m15 5 4 4`}],[`path`,{d:`m2 2 20 20`}]];function zm(){return J(`mg-cell__disabled-indicator-icon`,Rm,14)}function Bm(e){let{current:t,colId:n,sortable:r}=e;if(!r)return Qi(t);let i=Qi(t).find(e=>e.colId===n);return i?i.sort===`asc`?[{colId:n,sort:`desc`}]:[]:[{colId:n,sort:`asc`}]}function Vm(e,t){return t.find(t=>t.colId===e)?.sort??null}function Hm(e){return e===`asc`?`ascending`:e===`desc`?`descending`:`none`}var Um=class{deps;constructor(e){this.deps=e}toggleSort(e){if(!this.deps.getColumnById(e)?.sortable)return;let t=Bm({current:this.deps.getSortModel(),colId:e,sortable:!0});this.deps.setSortModel(t)}getSortState(e){return Vm(e,this.deps.getSortModel())}},Wm=`mg-header-cell--filtered`,Gm=`.mg-header-cell__column-handle`;function Km(e){return e??`center`}function qm(e,t,n,r){let i=t.sortable?Vm(e,n):null,a=t.filterable?si(e,r):!1;return i&&a?i===`asc`?`sort-filter-asc`:`sort-filter-desc`:i?i===`asc`?`sort-asc`:`sort-desc`:a?`filter`:null}function Jm(e){switch(e){case`sort-asc`:return pm(`asc`);case`sort-desc`:return pm(`desc`);case`filter`:return mm();case`sort-filter-asc`:return hm();case`sort-filter-desc`:return gm()}}function Ym(e,t,n){let r=e.querySelector(`.mg-header-cell__sort`);return r||(r=document.createElement(`span`),r.className=`mg-header-cell__sort`,r.setAttribute(`aria-hidden`,`true`),n?e.insertBefore(r,t):e.append(r)),r}function Xm(e){e.querySelector(`.mg-header-cell__sort`)?.remove()}function Zm(e,t,n,r,i){let a=e.querySelector(`.mg-header-cell__label`);if(!a)return;let o=a.querySelector(`.mg-header-cell__text`);if(!o)return;let s=Km(t.headerAlign)===`right`,c=qm(t.colId,t,n,r);if(e.classList.remove(`mg-header-cell--sort-hint`),c){Ym(a,o,s).replaceChildren(Jm(c));return}if(t.sortable&&i){Ym(a,o,s).replaceChildren(_m()),e.classList.add(`mg-header-cell--sort-hint`);return}Xm(a)}function Qm(e,t,n){let r=si(t,n);e.classList.toggle(Wm,r);let i=e.querySelector(Gm);i&&(r?i.setAttribute(`aria-pressed`,`true`):i.removeAttribute(`aria-pressed`))}function $m(e,t,n,r,i){if(Qm(e,t.colId,r),!t.sortable)e.classList.remove(`mg-header-cell--sortable`,`mg-header-cell--sorted`,`mg-header-cell--sorted-asc`,`mg-header-cell--sorted-desc`,`mg-header-cell--sort-hint`),e.removeAttribute(`aria-sort`);else{e.classList.toggle(`mg-header-cell--sortable`,i.enableHeaderSortClick),e.setAttribute(`role`,`columnheader`);let r=Vm(t.colId,n);e.setAttribute(`aria-sort`,Hm(r)),e.classList.remove(`mg-header-cell--sorted-asc`,`mg-header-cell--sorted-desc`,`mg-header-cell--sorted`),r===`asc`?e.classList.add(`mg-header-cell--sorted`,`mg-header-cell--sorted-asc`):r===`desc`&&e.classList.add(`mg-header-cell--sorted`,`mg-header-cell--sorted-desc`)}Zm(e,t,n,r,t.sortable&&i.showUnsortedSortHintOnHover&&i.enableHeaderSortClick)}function eh(e,t){let n=Array.isArray(e)?e:[e],r={showUnsortedSortHintOnHover:t.showUnsortedSortHintOnHover,enableHeaderSortClick:t.enableHeaderSortClick};for(let e of n){let n=Array.from(e.querySelectorAll(`.mg-header-cell[data-col-id]`));for(let e of n){let n=e.dataset.colId;if(!n)continue;let i=t.getColumnById(n);i&&$m(e,i,t.sortModel,t.filterModel,r)}}}var th=`mg-cell__group-content`,nh=`mg-cell__group-label`,rh=`mg-cell__group-count`;function ih(e,t,n){let r=n>0?`,${n} 条`:``;return t?`折叠分组 ${e}${r}`:`展开分组 ${e}${r}`}function ah(e,t){return e.groupFooterLabel??t.getGroupFooterLabel?.()??`小计`}function oh(e,t){return He(t)&&e.showGroupFooterCell&&!ye(e)}function sh(e,t,n){let r={visible:!1,showChevron:!1,expanded:!1,indentLevel:0,label:``,showCount:!1,count:0,ariaLabel:``};if(!t.active())return r;if(Ve(e)){if(n&&!De(n))return r;let i=e.sourceGroupId??Be(e.id)??e.groupId??``,a=e.groupKey??``,o=e.groupLeafCount??0,s=i?t.isExpanded(i):!1;return{visible:!0,showChevron:!!i,expanded:s,indentLevel:e.groupLevel??0,label:a,showCount:o>0,count:o,ariaLabel:ih(a,s,o)}}if(He(e)){if(n&&!Oe(n))return r;let i=n?ah(n,t):t.getGroupFooterLabel?.()??`小计`;return{visible:!0,showChevron:!1,expanded:!1,indentLevel:e.groupLevel??0,label:i,showCount:!1,count:0,ariaLabel:i}}return R(e),r}function ch(e){return`(${e})`}function lh(){let e=document.createElement(`button`);return e.type=`button`,e.className=fe,e.setAttribute(`aria-expanded`,`false`),e.appendChild(jm()),e}function uh(e,t){if(!t.showChevron){e.hidden=!0,e.classList.remove(pe),e.setAttribute(`aria-expanded`,`false`);return}e.hidden=!1,e.setAttribute(`aria-label`,t.ariaLabel),e.setAttribute(`aria-expanded`,String(t.expanded)),e.classList.toggle(pe,t.expanded)}function dh(e,t){for(let t=e.classList.length-1;t>=0;--t){let n=e.classList.item(t);n?.startsWith(`mg-cell__group-indent-`)&&e.classList.remove(n)}e.classList.add(`${me}${Math.max(0,t)}`),e.style.paddingLeft=`${Math.max(0,t)*16}px`}function fh(e,t,n,r,i){e.classList.toggle(_e,i.visible),dh(e,i.indentLevel),t&&uh(t,i),n.textContent=i.label,n.hidden=i.label.length===0,i.showCount&&i.count>0?(r.textContent=ch(i.count),r.hidden=!1):(r.textContent=``,r.hidden=!0)}function ph(e,t,n,r){if(r){if(t)return t;let r=lh();return e.insertBefore(r,n),r}return t&&t.remove(),null}function mh(e,t){return z(e.colId)&&B(t)}function hh(e,t){return t?`折叠 ${e}`:`展开 ${e}`}function gh(e,t){let n={visible:!1,showChevron:!1,expanded:!1,indentLevel:0,label:``,showCount:!1,count:0,ariaLabel:``};if(!t.active()||!B(e))return n;let r=t.getTreeValue?.(e)??e.dataPath?.[e.dataPath.length-1]??``,i=t.isExpanded(e.id),a=t.isTreeNodeLoading?.(e.id)??!1;return{visible:!0,showChevron:t.isTreeNodeExpandable?.(e)??e.treeLeaf!==!0,expanded:i,loading:a,indentLevel:e.treeLevel??0,label:r,showCount:!1,count:0,ariaLabel:hh(r,i),hierarchyActions:t.getTreeHierarchyActions?.(e)}}function _h(){let e=lh();return e.className=qe,e}function vh(e,t){if(yh(e,!!t.loading),!t.showChevron){e.hidden=!0,e.classList.remove(Je,Ye),e.disabled=!1,e.setAttribute(`aria-expanded`,`false`),e.setAttribute(`aria-busy`,`false`),e.setAttribute(`aria-hidden`,`true`),e.setAttribute(`tabindex`,`-1`);return}e.hidden=!1,e.removeAttribute(`aria-hidden`),e.removeAttribute(`tabindex`),e.setAttribute(`aria-label`,t.ariaLabel),e.setAttribute(`aria-expanded`,String(t.expanded&&!t.loading)),e.classList.toggle(Je,t.expanded&&!t.loading),e.classList.toggle(Ye,!!t.loading),e.disabled=!!t.loading,e.setAttribute(`aria-busy`,t.loading?`true`:`false`)}function yh(e,t){let n=e.querySelector(`.mg-cell__row-expand__icon`),r=e.querySelector(`.mg-cell__tree-expand__loading-icon`);if(t){if(n instanceof SVGElement&&n.setAttribute(`hidden`,`hidden`),!(r instanceof SVGElement)){e.appendChild(Mm());return}r.removeAttribute(`hidden`);return}if(r instanceof SVGElement&&r.remove(),n instanceof SVGElement){n.removeAttribute(`hidden`);return}e.appendChild(jm())}function bh(e,t){let n=Math.max(0,e);return t||n<=1?n:n-1}function xh(e){return Math.max(0,e)>1}function Sh(e,t,n){let r=n?.isExpandable===void 0?t:bh(t,n.isExpandable);for(let t=e.classList.length-1;t>=0;--t){let n=e.classList.item(t);(n?.startsWith(`mg-cell__tree-indent-`)||n?.startsWith(`mg-cell__group-indent-`))&&e.classList.remove(n)}e.classList.add(`${Xe}${Math.max(0,r)}`),e.style.paddingLeft=`${Math.max(0,r)*16}px`}function Ch(){let e=document.createElement(`button`);return e.type=`button`,e.className=Ze,e.setAttribute(`aria-label`,`层级操作`),e.setAttribute(`aria-haspopup`,`menu`),e.title=`层级操作`,e.appendChild(Fm()),e}function wh(e){e.setAttribute(`aria-label`,`层级操作`),e.title=`层级操作`,e.disabled=!1}function Th(e,t,n){if(!n?.visible)return t?.remove(),null;let r=t;r||(r=document.createElement(`div`),r.className=Qe,r.append(Ch()),e.append(r));let i=r.querySelector(`button.${Ze}`);return i&&wh(i),r}function Eh(e){return e instanceof Element?e.closest(`button.${Ze}`):null}function Dh(e,t,n,r,i){return e.classList.toggle($e,r.visible),e.classList.toggle(_e,r.visible),Sh(e,r.indentLevel,{isExpandable:r.showChevron}),t&&vh(t,r),n.textContent=r.label,n.hidden=r.label.length===0,Th(e,i??null,r.hierarchyActions)}function Oh(e,t,n,r,i=0){if(r){if(t)return t;let r=_h();return e.insertBefore(r,n),r}if(!xh(i))return t&&t.remove(),null;if(t)return t.hidden=!0,t.classList.remove(Je,Ye),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`tabindex`,`-1`),t;let a=_h();return a.hidden=!0,a.setAttribute(`aria-hidden`,`true`),a.setAttribute(`tabindex`,`-1`),e.insertBefore(a,n),a}function kh(e){return e?`全部收起`:`全部展开`}function Ah(e,t,n=!1){let r=document.createElement(`div`);r.className=`mg-header-cell__label`;let i=_h();jh(i,n);let a=document.createElement(`span`);a.className=`mg-header-cell__text`,a.textContent=t.label??t.prop??`树`,r.append(i,a),e.append(r),e.classList.add(`mg-header-cell--tree`)}function jh(e,t){vh(e,{showChevron:!0,expanded:t,loading:!1,ariaLabel:kh(t)})}function Mh(e,t){for(let n of e){let e=n.querySelector(`.mg-header-cell--tree .${qe}`);if(e){jh(e,t);return}}}var Nh=`mg-header-cell__required-mark`,Ph=`mg-header-cell__text-content`;function Fh(){let e=document.createElement(`span`);return e.className=Nh,e.textContent=`*`,e.setAttribute(`aria-hidden`,`true`),e}function Ih(e){if(e.querySelector(`.${Ph}`))return;let t=document.createElement(`span`);t.className=Ph,t.textContent=e.textContent??``,e.textContent=``,e.append(t)}function Lh(e){let t=e.querySelector(`.${Ph}`);t&&(e.textContent=t.textContent??``)}function Rh(e,t){e.classList.toggle(`mg-header-cell--required`,t);let n=e.querySelector(`.mg-header-cell__text`);if(!n)return;let r=n.querySelector(`.${Nh}`);if(!t){r?.remove(),Lh(n);return}Ih(n);let i=r??Fh();(i.parentElement!==n||i!==n.firstElementChild)&&n.insertBefore(i,n.firstChild)}function zh(e){return e??`center`}function Bh(){let e=document.createElement(`div`);return e.className=`mg-header-cell__label`,e}function Vh(e){let n=document.createElement(`span`);return n.className=`mg-header-cell__text`,n.textContent=t.it(e.colId)?e.label??``:e.label??e.prop??e.colId,n}function Hh(e){return t.it(e.colId)||t.X(e.colId)||A(e.colId)||z(e.colId)?!1:e.sortable||e.movable||e.filterable}function Uh(e){let t=document.createElement(`span`);return t.className=`mg-header-cell__column-handle`,t.title=`列操作`,t.setAttribute(`aria-haspopup`,`menu`),t.setAttribute(`aria-expanded`,`false`),t.tabIndex=-1,t.dataset.columnHandleMovable=e.movable?`true`:`false`,t.dataset.columnHandleSortable=e.sortable?`true`:`false`,t.dataset.columnHandleFilterable=e.filterable?`true`:`false`,t.append(fm()),t}function Wh(e){if(!Hh(e))return null;let t=document.createElement(`div`);return t.className=`mg-header-cell__chrome`,t.append(Uh({movable:e.movable,sortable:e.sortable,filterable:e.filterable})),t}function Gh(){let e=document.createElement(`div`);return e.className=`mg-header-cell__resize-handle`,e.setAttribute(`role`,`presentation`),e.dataset.resizable=`true`,e}function Kh(e,t){t&&e.append(Gh())}function qh(e,t){let n=zh(t.headerAlign),r=Bh(),i=Vh(t);r.append(i);let a=Wh(t);n===`right`&&a?e.append(a,r):a?e.append(r,a):e.append(r)}function Jh(e,n){let r=Hh(n),i=!t.it(n.colId)&&!t.X(n.colId)&&!A(n.colId)&&!z(n.colId);e.classList.toggle(`mg-header-cell--has-column-handle`,r),e.classList.toggle(`mg-header-cell--movable`,i&&n.movable),e.classList.toggle(`mg-header-cell--filterable`,i&&n.filterable)}function Yh(e,t){e.classList.toggle(`mg-header-cell--resizable`,t.resizable)}function Xh(e,n,r){let i=document.createElement(`div`);if(i.className=`mg-header-cell`,i.dataset.colId=e.colId,t.X(e.colId))if(i.classList.add(`mg-header-cell--selection`),r.selectionColumnOptions?.enabled&&r.selectionColumnOptions.mode===`multiple`){let e=kp({checked:!1,ariaLabel:r.selectionColumnOptions.selectionColumn.selectAllLabel});e.classList.add(Op),i.append(e)}else{let e=document.createElement(`span`);e.className=`mg-header-cell__text`,e.textContent=``,i.append(e)}else if(t.it(e.colId)){let t=Vh(e);i.append(t),i.classList.add(`mg-header-cell--index`)}else if(A(e.colId)){let e=document.createElement(`span`);e.className=`mg-header-cell__text`,e.textContent=``,i.append(e),i.classList.add(`mg-header-cell--expand`)}else if(L(e.colId)){let t=document.createElement(`span`);t.className=`mg-header-cell__text`,t.textContent=e.label??`分组`,i.append(t),i.classList.add(`mg-header-cell--group`)}else z(e.colId)?(Ah(i,e,r.getTreeHeaderExpanded?.()??!1),Kh(i,e.resizable)):(qh(i,e),Kh(i,e.resizable));return $m(i,e,r.sortModel,r.filterModel,{showUnsortedSortHintOnHover:r.showUnsortedSortHintOnHover,enableHeaderSortClick:r.enableHeaderSortClick}),Jh(i,e),Yh(i,e),Lp(i,Ip(e,n),`mg-header-cell`),Gp(i,e.headerAlign,e.headerValign,`mg-header-cell`),Rh(i,e.validationRequired===!0),r.validationFeedback.hasColErrors(e.colId)&&i.classList.add(`mg-header-cell--invalid`),i}function Zh(e,t,n,r,i,a,o,s,c={},l){e.replaceChildren();let u={sortModel:r,validationFeedback:i,showUnsortedSortHintOnHover:a,enableHeaderSortClick:o,selectionColumnOptions:s,filterModel:c,getTreeHeaderExpanded:l};for(let r of t){let t=n.getColumn(r);t&&e.appendChild(Xh(t,n,u))}}function Qh(e){let{headerLeftLaneEl:t,headerCenterLaneEl:n,headerRightLaneEl:r,columnModel:i,centerWindow:a,sortModel:o,validationFeedback:s,selectionColumnOptions:c,showUnsortedSortHintOnHover:l=!1,enableHeaderSortClick:u=!0,filterModel:d={},getTreeHeaderExpanded:f}=e,p=Fp(i,a);t.style.width=`${i.getLeftFixedWidth()}px`,n.style.width=`${i.getCenterTotalWidth()}px`,r.style.width=`${i.getRightFixedWidth()}px`,Zh(t,p.left,i,o,s,l,u,c,d,f),Zh(n,p.center,i,o,s,l,u,c,d,f),Zh(r,p.right,i,o,s,l,u,c,d,f)}function $h(e,t,n,r){e.style.width=`${r.getLeftFixedWidth()}px`,t.style.width=`${r.getCenterTotalWidth()}px`,n.style.width=`${r.getRightFixedWidth()}px`}function eg(e,t,n,r){Rp(e,r,`mg-header-cell`),Rp(t,r,`mg-header-cell`),Rp(n,r,`mg-header-cell`)}function tg(e){let t=new Map;for(let n of e)for(let e of n.querySelectorAll(`.mg-header-cell[data-col-id]`)){if(!(e instanceof HTMLElement))continue;let n=e.dataset.colId;n&&t.set(n,e)}return t}function ng(e,t,n,r,i){let a=new Set;for(let o of t){let t=n.getColumn(o);if(!t||t.hidden)continue;a.add(t.colId);let s=r.get(t.colId);!s&&i&&(s=Xh(t,n,i),r.set(t.colId,s)),s&&e.appendChild(s)}if(i)for(let t of[...e.children]){if(!(t instanceof HTMLElement))continue;let e=t.dataset.colId;e&&!a.has(e)&&t.remove()}}function rg(e){let{headerLeftLaneEl:t,headerCenterLaneEl:n,headerRightLaneEl:r,columnModel:i,centerWindow:a,fillColumnWindowGaps:o=!1,sortModel:s,validationFeedback:c,selectionColumnOptions:l,showUnsortedSortHintOnHover:u=!1,enableHeaderSortClick:d=!0,filterModel:f={},getTreeHeaderExpanded:p}=e,m=Fp(i,a),h=o&&s&&c?{sortModel:s,validationFeedback:c,showUnsortedSortHintOnHover:u,enableHeaderSortClick:d,selectionColumnOptions:l,filterModel:f,getTreeHeaderExpanded:p}:void 0;$h(t,n,r,i);let g=tg([t,n,r]);ng(t,m.left,i,g,h),ng(n,m.center,i,g,h),ng(r,m.right,i,g,h)}var ig=class{registry=new Map;invalidColIds=new Set;domStates=[];showCellInvalid(e){this.setRowCellInvalid(e.rowId,e.rowElement,{colId:e.colId,errors:e.errors,editorMountEl:e.editorMountEl})}showCellsInvalid(e){this.setRowInvalid(e.rowId,e.rowElement,e.cells)}setRowInvalid(e,t,n){this.clearRowDom(e,t);let r=new Map;for(let i of n)i.errors.length&&(r.set(i.colId,i.errors),t&&this.applyCellDom(e,t,i));r.size===0?this.registry.delete(e):this.registry.set(e,r),this.rebuildInvalidColIds()}applyGridValidationFeedback(e,t){let n=new Set(t.map(e=>e.rowId));for(let t of[...this.registry.keys()])if(!n.has(t)){let n=this.findRowElement(e,t);this.clearRow(t,n)}for(let n of t){let t=this.findRowElement(e,n.rowId);this.setRowInvalid(n.rowId,t,n.cells)}}applyRowsValidationFeedback(e,t){for(let n of t){let t=this.findRowElement(e,n.rowId);this.setRowInvalid(n.rowId,t,n.cells)}}clearRow(e,t){this.clearRowDom(e,t??null),this.registry.delete(e),this.rebuildInvalidColIds()}clearRowCell(e,t,n){let r=this.registry.get(e);if(r?.delete(n),r?.size===0&&this.registry.delete(e),t){let e=t.querySelector(`.mg-cell[data-col-id="${n}"]`);e?.classList.remove(`mg-cell--invalid`),e?.removeAttribute(`title`)}let i=[];for(let t of this.domStates)(t.rowId!==e||t.colId!==n)&&i.push(t);this.domStates=i,this.rebuildInvalidColIds()}setRowCellInvalid(e,t,n){if(!n.errors.length){this.clearRowCell(e,t,n.colId);return}if(t){for(let r of this.domStates)r.rowId===e&&r.colId===n.colId&&this.removeCellDom(r,t);this.domStates=this.domStates.filter(t=>t.rowId!==e||t.colId!==n.colId)}let r=this.registry.get(e);r||(r=new Map,this.registry.set(e,r)),r.set(n.colId,n.errors),t&&this.applyCellDom(e,t,n),this.rebuildInvalidColIds()}clear(e){e&&this.removeRegistryDom(e),this.domStates=[],this.registry.clear(),this.rebuildInvalidColIds()}syncDom(e){for(let t of e.querySelectorAll(`.mg-cell--invalid`)){let e=t.closest(`.mg-row[data-row-id]`)?.getAttribute(`data-row-id`),n=t.getAttribute(`data-col-id`);(e&&n?this.registry.get(e)?.get(n):void 0)?.length||(t.classList.remove(`mg-cell--invalid`),t.removeAttribute(`title`))}for(let[t,n]of this.registry){let r=this.findRowElement(e,t);if(r)for(let[e,t]of n){if(!t.length)continue;let n=t.join(`
2
2
  `),i=r.querySelector(`.mg-cell[data-col-id="${e}"]`);i&&(i.classList.add(`mg-cell--invalid`),i.getAttribute(`title`)!==n&&i.setAttribute(`title`,n))}}this.rebuildDomStatesFromRegistry(e)}hasInvalidCells(){return this.registry.size>0}hasColErrors(e){return this.invalidColIds.has(e)}getInvalidColIds(){return this.invalidColIds}syncHeaderDom(e,t){for(let n of t){let t=e.querySelector(`.mg-header-cell[data-col-id="${n.colId}"]`);t&&(Rh(t,n.validationRequired===!0),t.classList.toggle(`mg-header-cell--invalid`,this.invalidColIds.has(n.colId)))}}getRegistry(){return this.registry}migrateRowId(e,t,n){let r=this.registry.get(e);r&&(this.registry.delete(e),this.registry.set(t,r));for(let n of this.domStates)n.rowId===e&&(n.rowId=t);let i=this.findRowElement(n,e);i&&(i.dataset.rowId=t)}rebuildDomStatesFromRegistry(e){let t=new Map;for(let e of this.domStates)t.set(`${e.rowId}:${e.colId}`,e.editorMountEl);let n=[];for(let[r,i]of this.registry)if(this.findRowElement(e,r))for(let[e,a]of i)a.length&&n.push({rowId:r,colId:e,editorMountEl:t.get(`${r}:${e}`)??null});this.domStates=n}rebuildInvalidColIds(){let e=new Set;for(let t of this.registry.values())for(let n of t.keys())e.add(n);this.invalidColIds=e}findRowElement(e,t){return e.querySelector(`.mg-row[data-row-id="${t}"]`)}clearRowDom(e,t){let n=[];for(let r of this.domStates){if(r.rowId!==e){n.push(r);continue}t&&this.removeCellDom(r,t)}this.domStates=n}applyCellDom(e,t,n){let r=n.errors.join(`
3
3
  `),i=t.querySelector(`.mg-cell[data-col-id="${n.colId}"]`);i?.classList.add(`mg-cell--invalid`),i?.setAttribute(`title`,r),this.domStates.push({rowId:e,colId:n.colId,editorMountEl:n.editorMountEl??null})}removeCellDom(e,t){let n=t.querySelector(`.mg-cell[data-col-id="${e.colId}"]`);n?.classList.remove(`mg-cell--invalid`),n?.removeAttribute(`title`)}removeRegistryDom(e){for(let[t,n]of this.registry){let r=this.findRowElement(e,t);if(r)for(let e of n.keys()){let t=r.querySelector(`.mg-cell[data-col-id="${e}"]`);t?.classList.remove(`mg-cell--invalid`),t?.removeAttribute(`title`)}}}};function Y(e,t){return t.fromInternal(e)}function ag(e,t){return t.fromInternalList(e)}function og(e,n,r){let{rowNode:i,...a}=e;return{...a,rowId:Y(e.rowId,n),data:i?t.N(i,r.rowKey):{}}}function sg(e,n,r){let i=t.S(r);switch(e){case`cellFocused`:{let e=n;return{...e,rowId:Y(e.rowId,i),data:t.N(e.rowNode,r.rowKey)}}case`cellClicked`:{let e=n;return{...e,rowId:Y(e.rowId,i),data:t.N(e.rowNode,r.rowKey)}}case`rowClicked`:case`rowDoubleClicked`:{let e=n;return{...e,rowId:Y(e.rowId,i),data:t.N(e.rowNode,r.rowKey)}}case`selectionChanged`:{let e=n;return{selectedRowIds:ag(e.selectedRowIds,i),selectedRows:t.v(e.selectedRowIds,r),source:e.source}}case`indexFocusChanged`:{let e=n;return{focusedRowIds:ag(e.focusedRowIds,i),focusedRows:t.v(e.focusedRowIds,r)}}case`cellValueChanged`:{let e=n;return{...e,rowId:Y(e.rowId,i),data:t.N(e.rowNode,r.rowKey)}}case`rowDataChanged`:{let e=n,{rowNode:t,...r}=e;return{...r,rowId:Y(e.rowId,i)}}case`rowsDataChanged`:{let e=n;return{batchId:e.batchId,sources:e.sources,rows:e.rows.map(e=>({...e,rowId:Y(e.rowId,i)}))}}case`cellEditingStarted`:{let e=n,{rowNode:a,...o}=e;return{...o,rowId:Y(e.rowId,i),data:t.N(a,r.rowKey)}}case`cellEditingStopped`:{let e=n,{rowNode:a,...o}=e;return{...o,rowId:Y(e.rowId,i),data:a?t.N(a,r.rowKey):{}}}case`rowEditingStarted`:case`rowEditingStopped`:case`rowCommitStarted`:case`rowCommitFinished`:case`rowValidationFailed`:return og(n,i,r);case`rowValueChanged`:{let e=n,{rowNode:a,...o}=e;return{...o,rowId:Y(e.rowId,i),rowNode:a,data:t.N(a,r.rowKey)}}case`cellCommitStarted`:case`cellCommitFinished`:{let e=n;return{...e,rowId:Y(e.rowId,i)}}case`editCommitAborted`:{let e=n;return{...e,rowId:e.rowId==null?e.rowId:Y(e.rowId,i)}}case`cellValidationFailed`:{let e=n;return{...e,rowId:Y(e.rowId,i)}}case`rowsAdded`:return{rows:n.rows.map(e=>({...e,rowId:t.E(e.data,r.rowKey,String(e.rowId),{isTransient:e.isTransient})}))};case`rowsRemoved`:return{rows:n.rows.map(e=>({...e,rowId:t.E(e.data,r.rowKey,String(e.rowId))}))};case`rowIdPromoted`:{let e=n,r=t.j(e.oldRowId)?null:Y(e.oldRowId,i);return{...e,oldRowId:r,newRowId:Y(e.newRowId,i)}}case`rowMoved`:{let e=n;return{...e,rowId:Y(e.rowId,i),parentRowId:e.parentRowId===void 0?void 0:e.parentRowId===null?null:Y(e.parentRowId,i)}}case`rowDragEnd`:{let e=n;return{...e,rowId:Y(e.rowId,i),rowIds:e.rowIds?ag(e.rowIds,i):void 0,parentRowId:e.parentRowId===void 0?void 0:e.parentRowId===null?null:Y(e.parentRowId,i)}}case`rowDragCommitStarted`:{let e=n;return{...e,rowId:Y(e.rowId,i),rowIds:ag(e.rowIds,i),leaderRowId:Y(e.leaderRowId,i),parentRowId:e.parentRowId===void 0?void 0:e.parentRowId===null?null:Y(e.parentRowId,i)}}case`rowDragCommitFinished`:{let e=n;return{...e,rowId:Y(e.rowId,i),leaderRowId:Y(e.leaderRowId,i)}}case`rowHeightChanged`:{let e=n;return{...e,rows:e.rows.map(e=>({...e,rowId:Y(e.rowId,i)}))}}case`rowExpanded`:case`rowCollapsed`:{let e=n;return{...e,rowId:Y(e.rowId,i)}}case`treeNodeOpened`:{let e=n;return{...e,rowId:Y(e.rowId,i)}}case`treeChildrenLoading`:case`treeChildrenLoaded`:case`treeChildrenLoadFailed`:{let e=n;return{...e,parentRowId:Y(e.parentRowId,i)}}case`cellCommentChanged`:{let e=n;return{...e,rowId:Y(e.rowId,i)}}default:return n}}var cg=class{listeners=new Map;destroyed=!1;projector=null;setProjector(e){this.projector=e}on(e,t){if(this.destroyed)return()=>void 0;let n=this.listeners.get(e);n||(n=new Set,this.listeners.set(e,n));let r=t;return n.add(r),()=>{n?.delete(r)}}emit(e,t){if(this.destroyed)return;let n=this.listeners.get(e);if(!n)return;let r=this.projector?this.projector(e,t):t;for(let e of n)e(r)}destroy(){this.destroyed=!0,this.listeners.clear(),this.projector=null}};function lg(e){return(t,n)=>sg(t,n,e)}var ug=class{mode;selectedIds=new Set;anchorIndex=-1;constructor(e=`single`){this.mode=e===`multiple`?`multiple`:`single`}getSelectedRowIds(){return[...this.selectedIds]}isSelected(e){return this.selectedIds.has(e)}clear(){this.selectedIds.clear(),this.anchorIndex=-1}removeRowIds(e){let t=!1;for(let n of e)this.selectedIds.delete(n)&&(t=!0);return t}migrateRowId(e,t){return this.selectedIds.has(e)?(this.selectedIds.delete(e),this.selectedIds.add(t),!0):!1}getAnchorIndex(){return this.anchorIndex}isMultiple(){return this.mode===`multiple`}setAnchorIndex(e){this.anchorIndex=e}selectRow(e,t,n,r={}){let{ctrlKey:i=!1,shiftKey:a=!1,toggleOnReselect:o=!1}=r;if(this.mode===`multiple`&&a&&this.anchorIndex>=0&&t>=0)return this.selectRangeBetween(this.anchorIndex,t,n,r.rangeSelection);if(this.mode===`multiple`&&i)return this.selectedIds.has(e)?this.selectedIds.delete(e):this.selectedIds.add(e),this.anchorIndex=t,!0;if(o&&this.selectedIds.has(e))return this.selectedIds.delete(e),this.anchorIndex===t&&(this.anchorIndex=-1),!0;if(this.mode===`multiple`&&o){let n=!this.selectedIds.has(e);return this.selectedIds.add(e),this.anchorIndex=t,n}let s=this.selectedIds.size!==1||!this.selectedIds.has(e);return this.selectedIds.clear(),this.selectedIds.add(e),this.anchorIndex=t,s}selectRangeBetween(e,t,n,r){let i=Math.min(e,t),a=Math.max(e,t),o=new Set;if(r){let{rowCount:e,getAllRowIdAt:t}=r;for(let r=0;r<e;r++){let e=t(r);if(!e)continue;let s=n(r),c=r>=i&&r<=a;if(s){c&&o.add(s);continue}this.selectedIds.has(e)&&o.add(e)}}else for(let e=i;e<=a;e++){let t=n(e);t&&o.add(t)}let s=o.size!==this.selectedIds.size||[...o].some(e=>!this.selectedIds.has(e));return this.selectedIds=o,s}addRangeToSelection(e,t,n,r){let i=Math.min(e,t),a=Math.max(e,t),o=new Set(r);for(let e=i;e<=a;e++){let t=n(e);t&&o.add(t)}let s=o.size!==this.selectedIds.size||[...o].some(e=>!this.selectedIds.has(e));return this.selectedIds=o,s}removeRangeFromSelection(e,t,n,r,i){let a=Math.min(e,t),o=Math.max(e,t),s=new Set(r);if(i){let{getAllRowIdAt:e}=i;for(let t=a;t<=o;t++){let r=e(t);if(!r)continue;let i=n(t);i?s.delete(i):s.has(r)&&s.delete(r)}}else for(let e=a;e<=o;e++){let t=n(e);t&&s.delete(t)}let c=s.size!==this.selectedIds.size||[...s].some(e=>!this.selectedIds.has(e));return this.selectedIds=s,c}isAllVisibleRowsSelected(e,t){if(e===0)return!1;for(let n=0;n<e;n++){let e=t(n);if(e&&!this.selectedIds.has(e))return!1}return!0}selectAllVisibleRows(e,t){let n=!1;for(let r=0;r<e;r++){let e=t(r);e&&!this.selectedIds.has(e)&&(this.selectedIds.add(e),n=!0)}return n&&e>0&&(this.anchorIndex=0),n}deselectAllVisibleRows(e,t){let n=!1;for(let r=0;r<e;r++){let e=t(r);e&&this.selectedIds.delete(e)&&(n=!0)}return n}replaceSelectionWithVisibleRows(e,t){return this.selectAllVisibleRows(e,t)}toggleSelectAllVisibleRows(e,t){return this.isAllVisibleRowsSelected(e,t)?this.deselectAllVisibleRows(e,t):this.selectAllVisibleRows(e,t)}replaceWithRowIds(e,t=-1){let n=new Set(e),r=n.size!==this.selectedIds.size||[...n].some(e=>!this.selectedIds.has(e));return this.selectedIds=n,this.anchorIndex=t,r}addRowId(e,t=-1){if(this.mode===`single`){let n=this.selectedIds.size!==1||!this.selectedIds.has(e);return this.selectedIds.clear(),this.selectedIds.add(e),this.anchorIndex=t,n}return!this.selectedIds.has(e)&&(this.selectedIds.add(e),t>=0&&(this.anchorIndex=t),!0)}toggleRowId(e,t){return this.selectedIds.has(e)?this.removeRowIds([e]):this.addRowId(e,t)}},dg=()=>!0;function fg(e){return e??dg}function pg(e,n,r){return e({data:n.data,rowId:t.T(n,r),rowIndex:n.rowIndex,isTransient:n.isTransient??!1})}var mg=class extends ug{getFocusedRowIds(){return this.getSelectedRowIds()}};function hg(e){let t=[],n=[],r=[];return e.forEach((e,i)=>{let a=e.fixed??null;a===`left`?t.push(i):a===`right`?r.push(i):n.push(i)}),{left:t,center:n,right:r}}function gg(e){let t=[],n=[],r=[];return e.forEach((e,i)=>{if(e.hidden)return;let a=e.fixed??null;a===`left`?t.push(i):a===`right`?r.push(i):n.push(i)}),{left:t,center:n,right:r}}function _g(e){return t.it(e)||t.X(e)}function X(e){return e.fixed??null}function vg(e){for(let t=0;t<e.length;t++){let n=e[t];if(!(!n||X(n)!==`left`)&&!_g(n.colId))return t}return e.length}function yg(e){for(let t=0;t<e.length;t++){let n=e[t];if(!n||X(n)!==`left`||!_g(n.colId))return t}let t=0;for(let n of e){if(X(n)!==`left`)break;t+=1}return t}function bg(e,t,n){let r=e[t];return r?X(r)===n:!1}function xg(e,t,n){if(n!==void 0)return n;if(t>=e.length)return`right`;let r=e[t];return r?X(r):null}function Sg(e,t,n){return n===`left`?yg(e):n===`right`?e.length:t.center.length>0?t.center[0]:t.left.length>0?t.left[t.left.length-1]+1:vg(e)}function Cg(e,t,n){if(n===`left`)return t.center.length>0?t.center[0]:t.right.length>0?t.right[0]:e.length;if(n===`right`)return e.length;if(t.center.length>0){let n=t.center[t.center.length-1];if(t.right.length>0){let r=t.right[0];return r>n?r:Math.min(n+1,e.length-1)}return e.length}return t.right.length>0?t.right[0]:e.length}function wg(e){let{columns:t,colId:n,toGlobalIndex:r,toFixed:i}=e;if(r<0||r>t.length)return!1;let a=t.findIndex(e=>e.colId===n);if(a<0||a===r||_g(n))return!1;let o=t[a];if(!o?.movable)return!1;let s=X(o),c=xg(t,r,i);if(r<t.length){let e=t[r];if(!e||_g(e.colId))return!1}else if(i===void 0)return!1;if(s===c)return r===t.length||s===`left`&&r<vg(t)?!1:bg(t,r,s);if(e.allowCrossLaneColumnMove!==!0)return!1;if(c===`left`){let e=s===c?vg(t):yg(t);if(r<t.length&&r<e)return!1}return!0}function Tg(e,t,n,r){return e.findIndex(e=>e.colId===t)<0?null:xg(e,n,r)}function Eg(e){if(!wg(e))return null;let t=e.columns.map(e=>e.colId),n=t.indexOf(e.colId);return n<0?null:e.toGlobalIndex===e.columns.length?(t.splice(n,1),t.push(e.colId),t):(t.splice(n,1),t.splice(e.toGlobalIndex,0,e.colId),t)}function Dg(e){let t=e.columns.findIndex(t=>t.colId===e.colId);if(t<0)return null;let n=e.direction===`right`?t+1:t-1;if(!wg({...e,toGlobalIndex:n}))return null;let r=e.columns[t],i=e.columns[n];return!r||!i||X(r)!==X(i)?null:n}function Og(e,t){return e===0?t:e>0?`right`:`left`}function kg(e,t){for(let n of t)if(e>=n.left&&e<n.left+n.width)return n;return null}function Ag(e,t){return t<=e?e:e+1}function jg(e,t){return t<e?e-1:e}function Mg(e,t,n,r,i){let a=kg(e,t);if(a)return n===`right`?Ag(a.globalIndex,i):jg(a.globalIndex,i);if(t.length===0)return r;let o=t[0],s=t[t.length-1];if(e<o.left)return n===`right`?jg(o.globalIndex,i):o.globalIndex;if(e>=s.left+s.width)return r;for(let r=0;r<t.length-1;r+=1){let a=t[r],o=t[r+1];if(e>=a.left+a.width&&e<o.left)return n===`right`?Ag(a.globalIndex,i):jg(o.globalIndex,i)}return r}function Ng(e){let t=e.leftFixedWidth+e.centerTotalWidth;return e.laneIndices.map(n=>{let r=e.columns[n];if(!r||_g(r.colId)||r.colId===e.sourceColId)return null;let i=e.targetFixed===`right`?r.left-t:r.left;return{colId:r.colId,globalIndex:n,left:i,width:r.width}}).filter(e=>e!=null)}function Pg(e){if(e.dragDirection!=null&&e.sourceGlobalIndex!=null&&e.sourceGlobalIndex>=0)return Mg(e.position,e.laneColumns,e.dragDirection,e.endIndex,e.sourceGlobalIndex);for(let t of e.laneColumns){let n=t.left+t.width/2;if(e.position<n)return t.globalIndex}return e.endIndex}function Fg(e){let t=e.laneHeaderCells.filter(t=>{let n=e.columns[t.globalIndex];return n&&t.colId!==e.sourceColId&&!_g(t.colId)&&X(n)===e.targetFixed});if(t.length===0)return e.clientX<e.laneRectLeft||e.clientX>e.laneRectRight?null:{globalIndex:Sg(e.columns,e.fixedGroups,e.targetFixed),toFixed:e.targetFixed};let n=Cg(e.columns,e.fixedGroups,e.targetFixed),r=t.map(e=>({globalIndex:e.globalIndex,left:e.rectLeft,width:e.rectWidth})),i=e.sourceColId?e.columns.findIndex(t=>t.colId===e.sourceColId):-1,a=Pg({position:e.clientX,laneColumns:r,dragDirection:e.dragDirection,endIndex:n,sourceGlobalIndex:i});return e.targetFixed===`right`&&a===e.columns.length&&e.fixedGroups.right.length===0?{globalIndex:a,toFixed:`right`}:{globalIndex:a}}function Ig(e){let t=e.targetFixed===`left`?e.fixedGroups.left:e.targetFixed===`right`?e.fixedGroups.right:e.fixedGroups.center,n=Ng({columns:e.columns,laneIndices:t,targetFixed:e.targetFixed,leftFixedWidth:e.leftFixedWidth,centerTotalWidth:e.centerTotalWidth,sourceColId:e.sourceColId});if(n.length===0)return e.clientX<e.laneRectLeft||e.clientX>e.laneRectRight?null:{globalIndex:Sg(e.columns,e.fixedGroups,e.targetFixed),toFixed:e.targetFixed};let r=Cg(e.columns,e.fixedGroups,e.targetFixed),i=e.sourceColId?e.columns.findIndex(t=>t.colId===e.sourceColId):-1,a=Pg({position:e.sectionX,laneColumns:n,dragDirection:e.dragDirection,endIndex:r,sourceGlobalIndex:i});return e.targetFixed===`right`&&a===e.columns.length&&e.fixedGroups.right.length===0?{globalIndex:a,toFixed:`right`}:{globalIndex:a}}function Lg(e){return!t.it(e)&&!t.X(e)}function Rg(e,t){return e.center.length>0?e.center[0]:e.right.length>0?e.right[0]:e.left.length>0?e.left[e.left.length-1]+1:t}function zg(e){if(!Lg(e.colId))return null;let t=e.columns.find(t=>t.colId===e.colId);if(!t)return null;let n=X(t);return n===e.fixed?null:e.fixed===`left`?{toGlobalIndex:Cg(e.columns,e.fixedGroups,`left`),toFixed:`left`}:e.fixed===`right`?{toGlobalIndex:e.columns.length,toFixed:`right`}:n===`right`?{toGlobalIndex:e.fixedGroups.right[0]??e.columns.length,toFixed:null}:{toGlobalIndex:Rg(e.fixedGroups,e.columns.length),toFixed:null}}function Bg(e={}){return{resizable:e.resizable??!0,colResizeDefault:e.colResizeDefault??null}}function Vg(e,n,r){return t.it(r)||t.X(r)?!1:e??n}function Hg(e,t){return t===`shift`?!e:e}function Ug(e,t,n,r,i){let a=e.map(e=>({colId:e.colId,width:t.getColumnWidth(e.colId)})),o=i&&i.length>0?i.map(e=>({colId:e,width:t.getColumnWidth(e)})):null;return{columns:a,column:a.length===1?a[0]??null:null,finished:n,flexColumns:o,source:r}}var Wg={left:[],center:[],right:[]};function Gg(e,t){return e.key??e.prop??`col_${t}`}function Kg(e,t){let n=new Map(t.map(e=>[e.colId,e])),r=[],i=new Set;for(let t of e){let e=n.get(t);e&&(r.push(e),i.add(t))}for(let e of t)i.has(e.colId)||(r.push(e),i.add(e.colId));return r}var qg=class{columns=[];totalWidth=0;fixedGroups=Wg;leftFixedWidth=0;rightFixedWidth=0;centerTotalWidth=0;gridAlignDefaults={};columnMovableDefault=!0;allowCrossLaneColumnMove=!1;gridResizableDefault=!0;gridSortableDefault=!1;gridFilterableDefault=!1;constructor(e=[],t={},n={},r={},i,a,o,s){this.gridAlignDefaults=r;let c=oa(i);this.columnMovableDefault=c.columnMovable,this.allowCrossLaneColumnMove=c.allowCrossLaneColumnMove;let l=Bg(a);this.gridResizableDefault=l.resizable,this.gridSortableDefault=ea(o).sortable,this.gridFilterableDefault=ua(s).filterable,this.setColumns(e,t,n)}setColumns(e,t={},n={},r,i,a,o,s){if(r!==void 0&&(this.gridAlignDefaults=r),i!==void 0){let e=oa(i);this.columnMovableDefault=e.columnMovable,this.allowCrossLaneColumnMove=e.allowCrossLaneColumnMove}a!==void 0&&(this.gridResizableDefault=Bg(a).resizable),o!==void 0&&(this.gridSortableDefault=ea(o).sortable),s!==void 0&&(this.gridFilterableDefault=ua(s).filterable);let c=oe(e),l=this.columns.map(e=>e.colId),u=new Map(this.columns.map(e=>[e.colId,e])),d=new Set(c.map((e,t)=>Gg(e,t))),f=c.map((e,r)=>{let i=this.parseColumn(e,r,t,n),a=u.get(i.colId);return a&&(a.defHidden===i.defHidden&&(i.hidden=a.hidden),a.defWidth===i.defWidth&&a.defFlex===i.defFlex&&(i.width=a.width,i.flex=a.flex),a.defFixed===i.defFixed&&(i.fixed=a.fixed)),i}),p=l.length>0&&(d.size!==l.length||l.some(e=>!d.has(e)));this.columns=l.length===0||p?f:Kg(l,f),this.rebuildDisplayedLayout()}setColumnsHidden(e,t){let n=[];for(let r of e){if(zs(r))continue;let e=this.columns.find(e=>e.colId===r);!e||e.hidden===t||(e.hidden=t,n.push(r))}return n.length>0&&this.rebuildDisplayedLayout(),n}isColumnHidden(e){return this.getColumnById(e)?.hidden}getDisplayedColumnIds(){return Hs(this.columns).map(e=>e.colId)}getDisplayedColumnIdsInLaneOrder(){let e=[],t=new Set,{left:n,center:r,right:i}=this.fixedGroups;for(let a of[...n,...r,...i]){let n=this.columns[a];!n||n.hidden||t.has(n.colId)||(t.add(n.colId),e.push(n.colId))}return e}rebuildDisplayedLayout(){this.fixedGroups=gg(this.columns),this.positionColumns()}setColumnMoveGridOptions(e){this.columnMovableDefault=e.columnMovable,this.allowCrossLaneColumnMove=e.allowCrossLaneColumnMove;for(let e of this.columns){if(t.it(e.colId)||t.X(e.colId)||A(e.colId)){e.movable=!1;continue}e.movable=sa(e.defMovable,this.columnMovableDefault)}}setColumnResizeGridOptions(e){this.gridResizableDefault=e.resizable;for(let e of this.columns){if(t.it(e.colId)||t.X(e.colId)||A(e.colId)){e.resizable=!1;continue}e.resizable=Vg(e.defResizable,this.gridResizableDefault,e.colId)}}setColumnSortGridOptions(e){this.gridSortableDefault=e.sortable;for(let e of this.columns){if(t.it(e.colId)||t.X(e.colId)||A(e.colId)||L(e.colId)){e.sortable=!1;continue}e.sortable=ta(e.defSortable,this.gridSortableDefault,e.colId)}}setColumnFilterGridOptions(e){this.gridFilterableDefault=e.filterable;for(let e of this.columns){if(t.it(e.colId)||t.X(e.colId)||A(e.colId)||L(e.colId)){e.filterable=!1;continue}e.filterable=da(e.defFilterable,this.gridFilterableDefault,e.colId)}}getColumnCount(){return this.columns.length}getColumn(e){return this.columns[e]}getColumnById(e){return this.columns.find(t=>t.colId===e)}getColAfter(e){let t=Hs(this.columns),n=t.findIndex(t=>t.colId===e);if(!(n<0||n>=t.length-1))return t[n+1]}getColumnWidth(e){return this.getColumnById(e)?.width??100}getColumnInitialWidth(e){return this.getColumnById(e)?.initialWidth??100}getTotalWidth(){return this.totalWidth}getColumns(){return this.columns}getDisplayedColumns(){return Hs(this.columns)}getDisplayedColumnCount(){return Us(this.columns)}getFixedColumnGroups(){return this.fixedGroups}getLeftFixedColumnIndices(){return this.fixedGroups.left}getRightFixedColumnIndices(){return this.fixedGroups.right}getCenterColumnIndices(){return this.fixedGroups.center}getLeftFixedWidth(){return this.leftFixedWidth}getRightFixedWidth(){return this.rightFixedWidth}getCenterTotalWidth(){return this.centerTotalWidth}isFixedColumn(e){let t=this.columns[e];return t?.fixed===`left`||t?.fixed===`right`}setColumnWidth(e,t){this.applyColumnWidthChanges([{colId:e,width:t}])}applyColumnWidthChanges(e,t){let n=!1,r=t?.widthSource!==`flex`;for(let t of e){let e=this.columns.find(e=>e.colId===t.colId);if(!e)continue;r&&e.flex!=null&&(e.flex=null);let i=Jg(t.width,e.minWidth,e.maxWidth);e.width!==i&&(e.width=i,n=!0)}return n&&this.positionColumns(),n}hasFlexColumns(){return this.columns.some(e=>!e.hidden&&e.flex!=null&&e.flex>0&&e.fixed!==`left`&&e.fixed!==`right`)}reorderColumns(e){if(e.length!==this.columns.length)return!1;let t=new Map(this.columns.map(e=>[e.colId,e])),n=[];for(let r of e){let e=t.get(r);if(!e)return!1;n.push(e)}return this.columns=n,this.rebuildDisplayedLayout(),!0}resetColumnsOrder(e){return this.reorderColumns(e)}resetColumnsWidth(){let e=[];for(let t of this.columns){if(zs(t.colId))continue;let n=!1,r=Jg(t.defWidth,t.minWidth,t.maxWidth);t.width!==r&&(t.width=r,n=!0),t.flex!==t.defFlex&&(t.flex=t.defFlex,n=!0),n&&e.push(t.colId)}return e.length>0&&this.positionColumns(),e}moveColumn(e,t,n){let r=Tg(this.columns,e,t,n),i=Eg({columns:this.columns,colId:e,toGlobalIndex:t,fixedGroups:this.fixedGroups,toFixed:n,allowCrossLaneColumnMove:this.allowCrossLaneColumnMove});if(!i)return!1;let a=this.columns.find(t=>t.colId===e);return a&&X(a)!==r&&(a.fixed=r),this.reorderColumns(i)}setColumnFixed(e,t){let n=zg({columns:this.columns,fixedGroups:this.fixedGroups,colId:e,fixed:t});if(!n)return!1;let r=this.columns.findIndex(t=>t.colId===e);if(r<0)return!1;let i=this.columns[r];if(r===n.toGlobalIndex)return i.fixed=n.toFixed,this.rebuildDisplayedLayout(),!0;let a=Eg({columns:this.columns,colId:e,toGlobalIndex:n.toGlobalIndex,fixedGroups:this.fixedGroups,toFixed:n.toFixed,allowCrossLaneColumnMove:!0});return a?(i.fixed=Tg(this.columns,e,n.toGlobalIndex,n.toFixed),this.reorderColumns(a)):!1}parseColumn(e,n,r,i){let a=Gg(e,n),o=e.minWidth??50,s=Jg(e.width??100,o,e.maxWidth),c=Wp(e,this.gridAlignDefaults),l=t.it(a)||t.X(a)||A(a)||L(a),u=e.fixed===`left`||e.fixed===`right`,d=!l&&!u&&e.flex!=null&&e.flex>0?e.flex:null;return e.cellEditorMode,e.cellEditor??i[a],e.cellEditorMode,e.cellEditor??i[a],{colId:a,prop:e.prop,label:e.label,width:s,initialWidth:s,minWidth:o,maxWidth:e.maxWidth,flex:d,suppressSizeToFit:l?!0:e.suppressSizeToFit??!1,left:0,fixed:e.fixed??null,sortable:!l&&ta(e.sortable,this.gridSortableDefault,a),filterable:!l&&da(e.filterable,this.gridFilterableDefault,a),filterType:ni(l?void 0:e.filterType),filterParams:ri(l?void 0:e.filterParams),filterFormatter:l?void 0:e.filterFormatter,comparator:e.comparator,defMovable:l?void 0:e.movable,movable:!l&&sa(e.movable,this.columnMovableDefault),defResizable:l?void 0:e.resizable,defSortable:l?void 0:e.sortable,defFilterable:l?void 0:e.filterable,resizable:Vg(!l&&e.resizable,this.gridResizableDefault,a),suppressAutoSize:l?!0:e.suppressAutoSize??!1,valueGetter:e.valueGetter,formatter:e.formatter,editable:e.editable,cellRenderer:e.cellRenderer??r[a],cellRendererMount:l?void 0:e.cellRendererMount,cellEditor:e.cellEditor??i[a],cellEditorMode:t.U(a,e.cellEditorMode),cellEditorCache:l?void 0:e.cellEditorCache,cellEditorParams:e.cellEditorParams,valueParser:e.valueParser,valueSetter:e.valueSetter,editType:e.editType,cellValidator:e.cellValidator,cellCommitted:e.cellCommitted,suppressPaste:l?!0:e.suppressPaste,useParserForClipboard:e.useParserForClipboard,useFormatterForClipboard:e.useFormatterForClipboard,validationRequired:e.validationRequired,summary:e.summary,summaryAgg:e.summaryAgg,summaryFormatter:e.summaryFormatter,autoHeight:Ha(e,a),rowDrag:Oa(e,a),rowExpand:ee(e,a),rowGroup:xe(e,a),rowGroupIndex:Se(e,a),groupAgg:Ce(e,a),showGroupHeaderCell:we(e,a),showGroupFooterCell:Te(e,a),groupFooterLabel:Ee(e,a),suppressCellComments:l?!0:e.suppressCellComments,disabled:!l&&e.disabled,cellDisabled:l?void 0:e.cellDisabled,cellStyle:l?void 0:e.cellStyle,defWidth:s,defFlex:d,defFixed:l?null:e.fixed??null,defHidden:!l&&e.hidden===!0,defOrder:n,hidden:Bs(a,e),tooltipField:l?void 0:e.tooltipField,tooltipValueGetter:l?void 0:e.tooltipValueGetter,headerTooltip:l?void 0:e.headerTooltip,headerTooltipValueGetter:l?void 0:e.headerTooltipValueGetter,suppressTooltip:Tc(a,e),tooltipComponent:l?void 0:e.tooltipComponent,tooltipComponentParams:l?void 0:e.tooltipComponentParams,colSpan:ro(e,a),rowSpan:io(e,a),spanRows:ao(e,a),...c}}hasAutoHeightColumns(){return this.columns.some(e=>e.autoHeight)}isColumnAutoHeight(e){return this.getColumnById(e)?.autoHeight??!1}getAutoHeightColumnIds(){return this.columns.filter(e=>e.autoHeight).map(e=>e.colId)}positionColumns(){this.leftFixedWidth=0,this.centerTotalWidth=0,this.rightFixedWidth=0;for(let e of this.fixedGroups.left){let t=this.columns[e];!t||t.hidden||(t.left=this.leftFixedWidth,t.rightOffset=void 0,this.leftFixedWidth+=t.width)}let e=0;for(let t of this.fixedGroups.center){let n=this.columns[t];!n||n.hidden||(n.left=e,n.rightOffset=void 0,e+=n.width)}this.centerTotalWidth=e;let t=this.leftFixedWidth+this.centerTotalWidth;for(let e of this.fixedGroups.right){let n=this.columns[e];!n||n.hidden||(n.left=t,t+=n.width,this.rightFixedWidth+=n.width)}let n=0;for(let e=this.fixedGroups.right.length-1;e>=0;e--){let t=this.fixedGroups.right[e],r=t===void 0?void 0:this.columns[t];!r||r.hidden||(r.rightOffset=n,n+=r.width)}this.totalWidth=this.leftFixedWidth+this.centerTotalWidth+this.rightFixedWidth}};function Jg(e,t,n){let r=Math.max(e,t);return n!==void 0&&(r=Math.min(r,n)),r}function Yg(e,t,n){if(e.length===0)return-1;let r=document.createElement(`form`);r.style.position=`fixed`,r.style.visibility=`hidden`,r.style.pointerEvents=`none`,r.style.top=`0`,r.style.left=`0`;for(let t of e)$g(t,r);t.appendChild(r);let i=r.offsetWidth+n;return r.remove(),i}function Xg(e,t,n){let r=[];if(!n){let n=e.querySelector(`.mg-header-cell[data-col-id="${Zg(t)}"]`);n&&r.push(n)}return e.querySelectorAll(`.mg-cell[data-col-id="${Zg(t)}"]`).forEach(e=>{e instanceof HTMLElement&&r.push(e)}),r}function Zg(e){return typeof CSS<`u`&&typeof CSS.escape==`function`?CSS.escape(e):e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}function Qg(e,t,n,r){let i=e.querySelector(`.mg-viewport`);if(!i)return-1;let a=Xg(e,t,n);return a.length===0?-1:Yg(a,i,r)}function $g(e,t){let n=e.cloneNode(!0);n.style.width=``,n.style.minWidth=``,n.style.maxWidth=``,n.style.left=``,n.style.right=``,n.style.position=`static`;let r=document.createElement(`div`);e_(e,r),r.append(n),t.append(r)}function e_(e,t){(e.classList.contains(`mg-header-cell`)||e.classList.contains(`mg-cell`)||e.classList.contains(`mg-footer-cell`))&&t.classList.add(`mg-row`);let n=e.parentElement;for(;n;){if(n.classList.contains(`mg-row`)||n.classList.contains(`mg-header-row`)||n.classList.contains(`mg-header-lane`)||n.classList.contains(`mg-body-lane`)){for(let e of n.classList)e!==`mg-row-position-absolute`&&t.classList.add(e);break}n=n.parentElement}}function t_(e){return e.reduce((e,t)=>e+t.width,0)}function n_(e,n,r={}){if(n<=0)return[];let i=Object.fromEntries((r.columnLimits??[]).map(({colId:e,minWidth:t,maxWidth:n})=>[e,{minWidth:t,maxWidth:n}])),a=r.colIds?new Set(r.colIds):null,o=[],s=[];for(let n of e.getColumns()){if(n.hidden){s.push({colId:n.colId,width:n.width,minWidth:n.minWidth,maxWidth:n.maxWidth??2**53-1});continue}if(t.it(n.colId)||t.X(n.colId)){s.push({colId:n.colId,width:n.width,minWidth:n.minWidth,maxWidth:n.maxWidth??2**53-1});continue}let c=i[n.colId]??{},l=Math.max(n.minWidth,c.minWidth??r.defaultMinWidth??n.minWidth),u=Math.min(n.maxWidth??2**53-1,c.maxWidth??r.defaultMaxWidth??n.maxWidth??2**53-1),d={colId:n.colId,width:e.getColumnInitialWidth(n.colId),minWidth:l,maxWidth:u};if(n.suppressSizeToFit){d.width=n.width,s.push(d);continue}if(a&&!a.has(n.colId)){d.width=n.width,s.push(d);continue}o.push(d)}if(o.length===0||r.onlyScaleUp&&t_(o)+t_(s)>=n)return[];let c=new Map(o.map(t=>[t.colId,e.getColumnWidth(t.colId)])),l=o.map(e=>e.colId),u=!1;for(;!u;){u=!0;let e=n-t_(s);if(e<=0){for(let e of o)e.width=e.minWidth;break}let t=t_(o);if(t<=0)break;let r=e/t,i=e;for(let e=o.length-1;e>=0;e--){let t=o[e],n=e===0?i:Math.round(t.width*r);n<t.minWidth?(n=t.minWidth,s.push(t),o.splice(e,1),u=!1):n>t.maxWidth&&(n=t.maxWidth,s.push(t),o.splice(e,1),u=!1),t.width=n,i-=n}}let d=e=>o.find(t=>t.colId===e)?.width??s.find(t=>t.colId===e)?.width,f=[];for(let t of l){let n=d(t);n!=null&&(c.get(t)??e.getColumnWidth(t))!==n&&f.push({colId:t,newWidth:n})}return f}var r_=class{mountEl;columnModel;autosizeOptions;constructor(e,t,n){this.mountEl=e,this.columnModel=t,this.autosizeOptions=n}setAutosizeOptions(e){this.autosizeOptions=e}getAutoSizeStrategy(){return this.autosizeOptions.autoSizeStrategy}autoSizeColumn(e,n){let r=this.columnModel.getColumnById(e);if(!r?.resizable||r.suppressAutoSize||t.it(e)||t.X(e))return null;let i=n??this.autosizeOptions.skipHeaderOnAutoSize,a=Qg(this.mountEl,e,i,this.autosizeOptions.autoSizePadding);return a<=0?null:{colId:e,newWidth:i_(r.minWidth,r.maxWidth,a)}}autoSizeColumns(e,t){let n=[];for(let r of e){let e=this.autoSizeColumn(r,t);e&&n.push(e)}return n}autoSizeAllColumns(e){let n=this.columnModel.getColumns().filter(e=>e.resizable&&!e.suppressAutoSize&&!t.it(e.colId)&&!t.X(e.colId)).map(e=>e.colId);return this.autoSizeColumns(n,e)}sizeColumnsToFit(e,t={}){return n_(this.columnModel,e,t)}buildFitWidthStrategyParams(e,t){return{gridWidth:e.type===`fitProvidedWidth`?e.width:t,defaultMinWidth:e.defaultMinWidth,defaultMaxWidth:e.defaultMaxWidth,columnLimits:e.columnLimits}}buildFitCellContentsChanges(e){let n=e.skipHeader??this.autosizeOptions.skipHeaderOnAutoSize,r=e.colIds??this.columnModel.getColumns().filter(e=>e.resizable&&!e.suppressAutoSize&&!t.it(e.colId)&&!t.X(e.colId)).map(e=>e.colId),i=Object.fromEntries((e.columnLimits??[]).map(({colId:e,minWidth:t,maxWidth:n})=>[e,{minWidth:t,maxWidth:n}])),a=[];for(let t of r){let r=this.columnModel.getColumnById(t);if(!r)continue;let o=i[t]??{},s=this.autoSizeColumn(t,n);if(!s)continue;let c=Math.max(r.minWidth,o.minWidth??e.defaultMinWidth??r.minWidth),l=Math.min(r.maxWidth??2**53-1,o.maxWidth??e.defaultMaxWidth??r.maxWidth??2**53-1);a.push({colId:t,newWidth:i_(c,l===2**53-1?void 0:l,s.newWidth)})}return!e.scaleUpToFitGridWidth||a.length===0?{contentChanges:a}:{contentChanges:a,scaleUpParams:{colIds:a.map(e=>e.colId),defaultMinWidth:e.defaultMinWidth,defaultMaxWidth:e.defaultMaxWidth,columnLimits:e.columnLimits,onlyScaleUp:!0}}}};function i_(e,t,n){let r=Math.max(n,e);return t!==void 0&&(r=Math.min(r,t)),r}function a_(e,t){if(e.length===0||t<=0)return 0;let n=e[e.length-1];if(t>=n.left+n.width)return e.length-1;let r=0,i=e.length-1;for(;r<i;){let n=Math.ceil((r+i)/2);e[n].left<=t?r=n:i=n-1}return r}function o_(e,t){if(e.length===0)return 0;let n=0,r=e.length-1;for(;n<r;){let i=Math.floor((n+r)/2),a=e[i];a.left+a.width<=t?n=i+1:r=i}return n}function s_(e,t){return Math.max(0,e-t)}function c_(e,t,n){let r=Math.max(0,t-n);return Math.max(0,Math.min(e,r))}function l_(e,t,n){return Math.max(0,e-t-n)}function u_(e,t,n){let r=e-t.getBoundingClientRect().left,i=n.getLeftFixedWidth(),a=n.getRightFixedWidth(),o=n.getCenterTotalWidth(),s=l_(t.clientWidth,i,a);return c_(t.scrollLeft,o,s)+(r-i)}function d_(e,t,n){let r=t.getBoundingClientRect(),i=n.getLeftFixedWidth(),a=n.getRightFixedWidth(),o=n.getCenterTotalWidth(),s=l_(t.clientWidth,i,a),c=c_(t.scrollLeft,o,s);return r.left+i+(e-c)}function f_(e){let t=e.getCenterColumnIndices(),n=e.getColumns();return{centerIndices:t,centerColumns:t.map(e=>n[e]).filter(e=>e!==void 0)}}function p_(e){let{scrollLeft:t,viewportWidth:n,columnModel:r,margin:i=200}=e,{centerIndices:a,centerColumns:o}=f_(r),s=r.getLeftFixedWidth(),c=r.getRightFixedWidth();if(o.length===0)return{window:{firstCol:0,lastCol:-1},centerScrollLeft:s_(t,s)};let l=r.getCenterTotalWidth(),u=l_(n,s,c),d=c_(t,l,u),f=Math.max(0,d-i),p=Math.min(d+u+i,l+i),m=o_(o,f),h=a_(o,p);return h=Math.min(h,o.length-1),h<m?{window:{firstCol:0,lastCol:-1},centerScrollLeft:d}:{window:{firstCol:a[m],lastCol:a[h]},centerScrollLeft:d}}var m_=class{columnModel;flexViewportWidth=0;constructor(e){this.columnModel=e}resolveCenterViewportWidth(e){return l_(e,this.columnModel.getLeftFixedWidth(),this.columnModel.getRightFixedWidth())}refreshFlexedColumns(e){let t=e.viewportWidth;this.flexViewportWidth=t;let n=this.getCenterColumns();if(n.length===0||t<=0)return{changed:!1,changedColIds:[],flexColIds:[]};let r=-1;if(e.resizingColIds&&e.resizingColIds.length>0){let t=new Set(e.resizingColIds);for(let e=n.length-1;e>=0;e--){let i=n[e];if(i&&t.has(i.colId)){r=e;break}}}let i=!1,a=n.map((e,t)=>{let n=e.flex??0,a=n>0&&t>r;return i||=a,{colId:e.colId,column:e,isFlex:a,flex:Math.max(0,n),initialSize:e.width,min:e.minWidth,max:e.maxWidth??2**53-1,targetSize:0}});if(!i)return{changed:!1,changedColIds:[],flexColIds:[]};let o=a.length,s=a.reduce((e,t)=>e+t.flex,0),c=t,l=(e,t)=>{e.frozenSize=t,c-=t,s-=e.flex,--o},u=e=>e.frozenSize!=null;for(let e of a)e.isFlex||l(e,e.initialSize);for(;o>0;){let e=Math.round(s<1?c*s:c),t,n=0,r=0;for(let i of a){if(u(i))continue;t=i,r+=e*(i.flex/s);let a=r-n,o=Math.round(a);i.targetSize=o,n+=o}t&&(t.targetSize+=e-n);let i=0;for(let e of a){if(u(e))continue;let t=e.targetSize,n=Math.min(Math.max(t,e.min),e.max);i+=n-t,e.violationType=n===t?void 0:n<t?`max`:`min`,e.targetSize=n}let o=i===0?`all`:i>0?`min`:`max`;for(let e of a)u(e)||(o===`all`||e.violationType===o)&&l(e,e.targetSize)}let d=[],f=[],p=[];for(let e of a){let t=e.frozenSize;t!=null&&t!==e.initialSize&&(d.push({colId:e.colId,width:t}),f.push(e.colId),e.isFlex&&p.push(e.colId))}return d.length===0?{changed:!1,changedColIds:[],flexColIds:[]}:(this.columnModel.applyColumnWidthChanges(d,{widthSource:`flex`}),{changed:!0,changedColIds:f,flexColIds:p})}getStoredViewportWidth(){return this.flexViewportWidth}getCenterColumns(){let e=this.columnModel.getCenterColumnIndices(),t=this.columnModel.getColumns();return e.map(e=>t[e]).filter(e=>e!==void 0)}};function h_(e,t,n,r){let i=Hg(n,r.colResizeDefault),a=[],o=[];for(let n of t){let t=e.getColumnById(n.colId);if(!t?.resizable)continue;let r=y_(t,n.newWidth);if(a.push({width:r,ratios:[1],colIds:[n.colId]}),o.push(n.colId),i){let i=e.getColAfter(n.colId);if(!i?.resizable)continue;let s=t.width-r,c=i.width+s;a.push({width:c,ratios:[1],colIds:[i.colId]}),o.includes(i.colId)||o.push(i.colId)}}return{sets:a,affectedColIds:o}}var g_=class{columnModel;syncLayout;columnFlexService;getCenterViewportWidth;constructor(e,t,n,r){this.columnModel=e,this.syncLayout=t,this.columnFlexService=n,this.getCenterViewportWidth=r}setColumnWidths(e,t,n,r,i){let{sets:a,affectedColIds:o}=h_(this.columnModel,e,t,i);return a.length===0?{changed:!1,affectedColIds:[],flexColIds:[]}:this.resizeColumnSets({resizeSets:a,finished:n,source:r,affectedColIds:o})}resizeColumnSets(e){let{resizeSets:t,affectedColIds:n}=e;if(!t.every(e=>__(this.columnModel,e)))return{changed:!1,affectedColIds:n,flexColIds:[]};let r=[];for(let e of t){let t=v_(this.columnModel,e);for(let[e,n]of Object.entries(t)){let t=r.find(t=>t.colId===e);t?t.width=n:r.push({colId:e,width:n})}}let i=r.filter(e=>this.columnModel.getColumnById(e.colId)?.resizable),a=this.columnModel.applyColumnWidthChanges(i,{widthSource:`manual`});a&&this.syncLayout();let o=[];if(this.columnFlexService&&this.getCenterViewportWidth&&this.columnModel.hasFlexColumns()){let e=this.columnFlexService.refreshFlexedColumns({viewportWidth:this.getCenterViewportWidth(),resizingColIds:n});o=e.flexColIds,e.changed&&this.syncLayout()}return{changed:a||o.length>0,affectedColIds:n,flexColIds:o}}};function __(e,t){let n=0,r=0,i=!0;for(let a of t.colIds){let t=e.getColumnById(a);if(!t)return!1;n+=t.minWidth,t.maxWidth===void 0?i=!1:r+=t.maxWidth}return t.width>=n&&(!i||t.width<=r)}function v_(e,t){let{colIds:n,width:r,ratios:i}=t,a=Object.create(null),o=Object.create(null),s=!0,c=0;for(;s&&(c++,!(c>1e3));){s=!1;let t=[],c=0,l=r;n.forEach((e,n)=>{o[e]?l-=a[e]??0:(t.push(e),c+=i[n]??1)});let u=c>0?1/c:1;t.forEach((c,d)=>{let f=e.getColumnById(c);if(!f)return;let p=d===t.length-1,m;if(p)m=l;else{let e=n.indexOf(c),t=i[e]??1;m=Math.round(t*r*u),l-=m}let h=f.minWidth,g=f.maxWidth;m<h?(m=h,o[c]=!0,s=!0):g!==void 0&&m>g&&(m=g,o[c]=!0,s=!0),a[c]=m})}return a}function y_(e,t){let n=Math.max(t,e.minWidth);return e.maxWidth!==void 0&&(n=Math.min(n,e.maxWidth)),n}var b_=class{columnModel;currentWindow={firstCol:0,lastCol:-1};centerScrollLeft=0;windowHash=``;constructor(e){this.columnModel=e}update(e,t){let{window:n,centerScrollLeft:r}=p_({scrollLeft:e,viewportWidth:t,columnModel:this.columnModel}),i=this.computeHash(n),a=i!==this.windowHash;return this.currentWindow=n,this.centerScrollLeft=r,this.windowHash=i,a}getWindow(){return this.currentWindow}getCenterScrollLeft(){return this.centerScrollLeft}getState(){return{centerWindow:this.currentWindow,fixed:this.columnModel.getFixedColumnGroups(),centerScrollLeft:this.centerScrollLeft}}invalidate(){this.windowHash=``,this.currentWindow={firstCol:0,lastCol:-1},this.centerScrollLeft=0}computeHash(e){let t=this.columnModel.getColumns(),n=this.columnModel.getFixedColumnGroups(),r=`fixed:`;for(let e of n.left){let n=t[e];n&&(r+=`L${n.colId}:${n.width};`)}for(let e of n.right){let n=t[e];n&&(r+=`R${n.colId}:${n.width};`)}if(e.lastCol<e.firstCol)return`${r}|empty`;r+=`|${e.firstCol}:${e.lastCol}`;for(let n=e.firstCol;n<=e.lastCol;n++){let e=t[n];e&&(r+=`|${e.colId}:${e.width}:${e.left}`)}return r}},x_=new class{apply(e,t){if(e.replaceChildren(),typeof t==`string`){e.textContent=t;return}e.appendChild(t)}clear(e){e.replaceChildren()}},S_=class{cachedValue=``;cachedRenderKey=``;cacheVersion=-1;refreshSummaryCell(e,t,n,r,i=!1){let a=typeof i==`boolean`?{force:i}:i,o=a.force??!1;if(e.cellRenderer)return this.refreshRendererCell(e,t,n,r,o,a.scheduleRenderer);let s=t.formattedValue;return!o&&this.cacheVersion===r&&this.cachedValue===s?!1:(n.clearRenderer(),this.cachedValue=s,this.cachedRenderKey=``,this.cacheVersion=r,n.setValue(s),!0)}invalidate(){this.cacheVersion=-1,this.cachedRenderKey=``}refreshRendererCell(e,t,n,r,i,a){let o=t.formattedValue,s=`${r}:summary:${e.colId}:${o}`;if(!i&&this.cacheVersion===r&&this.cachedRenderKey===s)return!1;this.cachedValue=o,this.cachedRenderKey=s,this.cacheVersion=r;let c={rowId:st,rowIndex:-1,colId:e.colId,value:t.value,data:{},formattedValue:o,isSummaryRow:!0},l=()=>{this.applyRenderer(e,n,c)};return a?(a(l),!0):(l(),!0)}applyRenderer(e,t,n){let r=e.cellRenderer;if(!r)return;t.prepareForRenderer();let i=t.getRendererMountEl(),a=r(n,{mountEl:i,clear:()=>{t.clearRenderer()}});a!=null&&(typeof a==`string`||a instanceof HTMLElement)&&x_.apply(i,a)}},C_=class{element;textEl;rendererMount;onUnmountRenderer;usingRenderer=!1;constructor(e,t={}){this.onUnmountRenderer=t.onUnmountRenderer,this.element=document.createElement(`div`),this.element.className=`mg-footer-cell`,this.textEl=document.createElement(`span`),this.textEl.className=`mg-footer-cell__text`,this.rendererMount=document.createElement(`div`),this.rendererMount.className=`mg-footer-cell__renderer`,this.rendererMount.hidden=!0,this.element.append(this.textEl,this.rendererMount),e.appendChild(this.element)}setLayout(e,t){Lp(this.element,{left:e,width:t,fixed:null},`mg-footer-cell`)}setColumnLayout(e){Lp(this.element,e,`mg-footer-cell`)}setValue(e){this.clearRenderer(),this.textEl.hidden=!1,this.textEl.textContent!==e&&(this.textEl.textContent=e)}setRendererResult(e){this.prepareForRenderer(),x_.apply(this.rendererMount,e)}prepareForRenderer(){this.clearRenderer(),this.textEl.hidden=!0,this.textEl.textContent=``,this.rendererMount.hidden=!1,this.usingRenderer=!0}clearRenderer(){(this.usingRenderer||this.rendererMount.childNodes.length>0)&&this.onUnmountRenderer?.(this.rendererMount),x_.clear(this.rendererMount),this.rendererMount.hidden=!0,this.usingRenderer=!1}hasRenderer(){return this.usingRenderer}getRendererMountEl(){return this.rendererMount}setColId(e){this.element.dataset.colId=e}getColId(){return this.element.dataset.colId}getElement(){return this.element}destroy(){this.clearRenderer(),this.element.remove()}};function w_(e,t){return{rowId:e.id,rowIndex:e.rowIndex,data:e.data,colId:t.colId,isSummaryRow:!1,value:H(e,t)}}function T_(e,t=null){return{rowId:st,rowIndex:-1,data:null,colId:e.colId,isSummaryRow:!0,value:t}}function E_(e,t){let n=e[0];if(!n)return{left:0,width:0,fixed:null};let r=Ip(n,t);if(r.width=j_(e),e.length>1){let n=e[e.length-1],i=Ip(n,t);r.isLastLeftFixed=i.isLastLeftFixed,r.isLastCenter=i.isLastCenter,r.isLastColumn=i.isLastColumn}return r}function D_(e,t,n=`mg-cell`){let r=t>1;e.classList.toggle(`${n}--spanning`,r),e.classList.toggle(`${n}--col-span`,r),r?e.dataset.colSpan=String(t):delete e.dataset.colSpan}function O_(e){if(!e.enableCellSpan)return 1;let{column:n,params:r}=e;if(t.it(n.colId)||t.X(n.colId))return 1;let i=n.colSpan;return i?$a(i(r)):1}function k_(e,n){let r=n.getColAfter(e.colId);if(r&&r.fixed===e.fixed&&!(t.it(r.colId)||t.X(r.colId)))return r}function A_(e,t,n){let r=O_({enableCellSpan:n.enableCellSpan,column:e,params:n.params}),i=[e],a=e;for(let e=1;e<r;e++){let e=k_(a,t);if(!e)break;i.push(e),a=e}return i}function j_(e){let t=0;for(let n of e)t+=n.width;return t}function M_(e){let{enableCellSpan:t,columnModel:n,columnIndices:r,paramsForColumn:i,filterCallback:a}=e,o=[],s=r.length;for(let e=0;e<s;){let s=r[e];if(s===void 0){e++;continue}let c=n.getColumn(s);if(!c){e++;continue}let l=A_(c,n,{enableCellSpan:t,params:i(c)}),u=N_(n,r,e,l),d=!0;if(a){d=!1;for(let t=0;t<u;t++){let i=r[e+t];if(i===void 0)continue;let o=n.getColumn(i);if(o&&a(o,i)){d=!0;break}}}d&&o.push(s),e+=Math.max(1,u)}return o}function N_(e,t,n,r){let i=1;for(let a=1;a<r.length&&n+a<t.length;a++){let o=t[n+a];if(o===void 0)break;let s=e.getColumn(o),c=r[a];if(!s||!c||s.colId!==c.colId)break;i++}return i}function P_(e){let{columnModel:t,centerWindow:n,enableCellSpan:r,paramsForColumn:i}=e;return r?{left:M_({enableCellSpan:!0,columnModel:t,columnIndices:t.getLeftFixedColumnIndices(),paramsForColumn:i}),center:M_({enableCellSpan:!0,columnModel:t,columnIndices:t.getCenterColumnIndices(),paramsForColumn:i,filterCallback:(e,t)=>n.lastCol>=n.firstCol&&t>=n.firstCol&&t<=n.lastCol}),right:M_({enableCellSpan:!0,columnModel:t,columnIndices:t.getRightFixedColumnIndices(),paramsForColumn:i})}:Fp(t,n)}function F_(e){if(!e.enableCellSpan||e.params.isSummaryRow)return 1;let{column:n,params:r}=e;if(t.it(n.colId)||t.X(n.colId))return 1;let i=n.rowSpan;return i?$a(i(r)):1}function I_(e){let{enableCellSpan:t,column:n,rowNode:r,getRowByIndex:i,rowCount:a}=e;if(!t||!n.rowSpan||!Qa(r))return{head:r,rowSpan:1,covered:!1};let o=Math.max(0,r.rowIndex-100);for(let e=r.rowIndex-1;e>=o;e--){let o=i(e);if(!o||!Qa(o))continue;let s=U_(F_({enableCellSpan:t,column:n,params:w_(o,n)}),o.rowIndex,a);if(s>1&&o.rowIndex+s-1>=r.rowIndex)return{head:o,rowSpan:s,covered:!0}}return{head:r,rowSpan:U_(F_({enableCellSpan:t,column:n,params:w_(r,n)}),r.rowIndex,a),covered:!1}}function L_(e,t,n){if(t<=1)return e.rowHeight;let r=n(e.rowIndex+t-1)??e,i=r.rowTop+r.rowHeight-e.rowTop;return Math.max(e.rowHeight,i)}function R_(e,t,n){return t<=1||n<=0?!1:e+t-1>=n-1}function z_(e,t,n,r){let i=t>1;if(e.classList.toggle(Ga,i),e.classList.toggle(Ka,i&&(r?.endsTable??!1)),i){e.classList.add(`mg-cell--spanning`),e.dataset.rowSpan=String(t),n!=null&&(e.style.height=`${n}px`);return}delete e.dataset.rowSpan,e.style.removeProperty(`height`),e.classList.remove(`mg-cell--row-span-highlighted`),e.classList.remove(Ka),e.classList.contains(`mg-cell--col-span`)||e.classList.remove(`mg-cell--spanning`)}function B_(e){let{head:t,rowSpan:n,getRowByIndex:r,isRowHighlighted:i}=e;if(n<=1)return i(t.id);for(let e=0;e<n;e++){let n=r(t.rowIndex+e);if(n&&i(n.id))return!0}return!1}function V_(e){let{head:t,rowSpan:n,colId:r,getRowByIndex:i,isCellSelected:a}=e;if(n<=1)return a(t.rowIndex,r);for(let e=0;e<n;e++){let n=i(t.rowIndex+e);if(n&&a(n.rowIndex,r))return!0}return!1}function H_(e){let{enableCellSpan:t,rowModel:n,columns:r,firstRow:i,lastRow:a}=e,o=new Set;if(!t||a<i)return o;let s=r.filter(e=>e.rowSpan!=null);if(s.length===0)return o;let c=n.getRowCount(),l=e=>n.getRow(e),u=Math.max(0,i-50);for(let e=u;e<=a;e++){let n=l(e);if(n)for(let e of s){if(Za(e))continue;let r=I_({enableCellSpan:t,column:e,rowNode:n,getRowByIndex:l,rowCount:c});r.covered||r.rowSpan<=1||r.head.id!==n.id||r.head.rowIndex+r.rowSpan-1>=i&&r.head.rowIndex<=a&&o.add(r.head.id)}}return o}function U_(e,t,n){if(n<=0)return 1;let r=n-t;return Math.min(e,r,50)}function W_(e,t){let n=new Map;if(!so(e.spanRows)||t.length===0)return n;let r=e.spanRows,i=-1,a,o=r=>{if(i<0||r<i)return;let a=i;for(;a<=r;){let i=Math.min(r,a+50-1),o=[];for(let e=a;e<=i;e++)o.push(t[e].id);let s={colId:e.colId,firstRowId:o[0],lastRowId:o[o.length-1],rowIds:o,rowSpan:o.length};for(let e of o)n.set(e,s);a=i+1}};for(let n=0;n<t.length;n++){let s=t[n];if(!Qa(s)){i>=0&&(o(n-1),i=-1);continue}let c=H(s,e);if(i<0){i=n,a=c;continue}let l=t[i];G_(r,l,s,a,c,e.colId)||(o(n-1),i=n,a=c)}return i>=0&&o(t.length-1),n}function G_(e,t,n,r,i,a){return e===!0?Object.is(r,i):typeof e==`function`&&e({nodeA:{rowId:t.id,data:t.data,rowIndex:t.rowIndex},nodeB:{rowId:n.id,data:n.data,rowIndex:n.rowIndex},valueA:r,valueB:i,colId:a})}var K_=class{deps;spanRowsCaches=new Map;warnedBothModes=new Set;constructor(e){this.deps=e}get active(){return this.deps.getEnableCellSpan()}refresh(){if(this.spanRowsCaches.clear(),!this.active)return;let e=this.deps.getDisplayRows(),t=this.deps.getColumnModel().getColumns();for(let n of t)n.rowSpan&&so(n.spanRows)&&this.warnBothModes(n.colId),oo(n.rowSpan,n.spanRows)===`spanRows`&&this.spanRowsCaches.set(n.colId,W_(n,e))}getColSpan(e,t){let n=this.deps.getColumnModel().getColumnById(t);if(!n||!this.active)return 1;if(e===`__mg_summary__`)return O_({enableCellSpan:!0,column:n,params:T_(n,this.deps.getSummaryValue?.(t)??null)});let r=this.deps.getRowById(e);return r?O_({enableCellSpan:!0,column:n,params:w_(r,n)}):1}getCellSpan(e,t){let n=this.deps.getColumnModel(),r=n.getColumnById(t),i=this.deps.getRowById(e);if(!r||!i||!this.active)return null;let a=this.resolveVerticalSpan(i,r),o=A_(r,n,{enableCellSpan:!0,params:w_(i,r)});if(a.rowSpan<=1&&o.length<=1)return null;let s=this.collectVerticalRowIds(a.head,a.rowSpan);return{colId:r.colId,firstRowId:a.head.id,lastRowId:s[s.length-1]??a.head.id,rowSpan:a.rowSpan,colSpan:o.length,rowIds:s,colIds:o.map(e=>e.colId)}}isCovered(e,t){let n=this.deps.getColumnModel().getColumnById(t),r=this.deps.getRowById(e);return!n||!r||!this.active?!1:this.resolveVerticalSpan(r,n).covered}normalizePosition(e,t){let n=this.deps.getColumnModel().getColumnById(t),r=this.deps.getRowById(e);return!n||!r||!this.active?{rowId:e,colId:t}:{rowId:this.resolveVerticalSpan(r,n).head.id,colId:t}}resolveVerticalSpan(e,t){if(!this.active||!Qa(e))return{head:e,rowSpan:1,covered:!1};let n=oo(t.rowSpan,t.spanRows);return n===`rowSpan`?I_({enableCellSpan:!0,column:t,rowNode:e,getRowByIndex:this.deps.getRowByIndex,rowCount:this.deps.getRowCount()}):n===`spanRows`?this.resolveFromSpanRowsCache(e,t):{head:e,rowSpan:1,covered:!1}}getVerticalSpanHeight(e,t){let n=this.resolveVerticalSpan(e,t);return n.covered||n.rowSpan<=1?e.rowHeight:L_(n.head,n.rowSpan,this.deps.getRowByIndex)}collectSpannedHeadRowIds(e,t){let n=new Set;if(!this.active||t<e)return n;let r=this.deps.getColumnModel().getColumns().filter(e=>oo(e.rowSpan,e.spanRows)!==`none`);if(r.length===0)return n;let i=Math.max(0,e-50);for(let a=i;a<=t;a++){let i=this.deps.getRowByIndex(a);if(i)for(let a of r){if(Za(a))continue;let r=this.resolveVerticalSpan(i,a);r.covered||r.rowSpan<=1||r.head.id!==i.id||r.head.rowIndex+r.rowSpan-1>=e&&r.head.rowIndex<=t&&n.add(r.head.id)}}return n}resolveFromSpanRowsCache(e,t){let n=this.spanRowsCaches.get(t.colId)?.get(e.id);return!n||n.rowSpan<=1?{head:e,rowSpan:1,covered:!1}:{head:this.deps.getRowById(n.firstRowId)??e,rowSpan:n.rowSpan,covered:n.firstRowId!==e.id}}collectVerticalRowIds(e,t){let n=[];for(let r=0;r<t;r++){let t=this.deps.getRowByIndex(e.rowIndex+r);t&&n.push(t.id)}return n}warnBothModes(e){this.warnedBothModes.has(e)||(this.warnedBothModes.add(e),console.warn(`[magic-grid] Column "${e}" has both rowSpan and spanRows; rowSpan takes precedence.`))}};function q_(e,t,n,r){if(!r?.active)return!1;if(r.resolveVerticalSpan(e,t).covered)return!0;let i=n.getDisplayedColumns().map(e=>e.colId),a=i.indexOf(t.colId);if(a<=0)return!1;for(let r=0;r<a;r++){let a=n.getColumnById(i[r]);if(!a)continue;let o=A_(a,n,{enableCellSpan:!0,params:w_(e,a)});if(!(o.length<=1)&&o.findIndex(e=>e.colId===t.colId)>0)return!0}return!1}function J_(e,t,n,r){let i=r.indexOf(t);if(i<0)return{leftColId:t,rightColId:t};for(let a=i;a>=0;--a){let i=r[a];if(!i)continue;let o=n.getColumnById(i);if(!o)continue;let s=A_(o,n,{enableCellSpan:!0,params:w_(e,o)});if(!(s.length<=1)&&s.findIndex(e=>e.colId===t)>=0)return{leftColId:s[0].colId,rightColId:s[s.length-1].colId}}return{leftColId:t,rightColId:t}}function Y_(e,t,n){let r={top:e,bottom:e,leftColId:t,rightColId:t},i=n.rowModel.getRow(e);if(!i||!n.cellSpanService?.active)return r;let a=n.columnModel.getColumnById(t);if(!a)return r;let o=n.cellSpanService.resolveVerticalSpan(i,a),s=o.head,c=s.rowIndex,l=s.rowIndex;o.rowSpan>1&&(l=o.head.rowIndex+o.rowSpan-1);let u=J_(s,t,n.columnModel,n.displayedColIds);return{top:c,bottom:l,leftColId:u.leftColId,rightColId:u.rightColId}}function X_(e,t,n){if(!n.cellSpanService?.active)return e;let r=e.top,i=e.bottom,a=e.leftColId,o=e.rightColId,s=t.indexOf(a),c=t.indexOf(o);if(s<0||c<0)return e;let l=Math.min(s,c),u=Math.max(s,c),d=!0;for(;d;){d=!1;for(let e=r;e<=i;e+=1)for(let s=l;s<=u;s+=1){let c=t[s];if(!c)continue;let f=Y_(e,c,n);f.top<r&&(r=f.top,d=!0),f.bottom>i&&(i=f.bottom,d=!0);let p=t.indexOf(f.leftColId),m=t.indexOf(f.rightColId);p>=0&&p<l&&(l=p,a=t[l],d=!0),m>=0&&m>u&&(u=m,o=t[u],d=!0)}}return{top:r,bottom:i,leftColId:a,rightColId:o}}function Z_(e,t){if(!t.cellSpanService?.active)return e;let n=U(e,t.displayedColIds);return n?ks(X_(n,t.displayedColIds,t)):e}function Q_(e,t,n){let r=X_(e,t,{...n,displayedColIds:t,cellSpanService:n.cellSpanService});return{topRowIndex:r.top,bottomRowIndex:r.bottom}}var $_=class{lanes;footerRowEl;frameService;onUnmountRenderer;enableCellSpan;columnModel=null;summaryCells=new Map;constructor(e){this.footerRowEl=e.footerRowEl,this.frameService=e.frameService??null,this.onUnmountRenderer=e.onUnmountRenderer,this.enableCellSpan=e.enableCellSpan??!1,this.lanes={left:this.createLane(e.footerLeftLaneEl),center:this.createLane(e.footerCenterLaneEl),right:this.createLane(e.footerRightLaneEl)}}setEnableCellSpan(e){this.enableCellSpan=e}render(e){this.columnModel=e.columnModel,this.summaryCells=e.summaryCells;let t=P_({columnModel:e.columnModel,centerWindow:e.centerWindow,enableCellSpan:this.enableCellSpan,paramsForColumn:t=>T_(t,e.summaryCells.get(t.colId)?.value??null)});this.syncLaneWidths(e.columnModel),this.syncLaneCells(`left`,t.left),this.syncLaneCells(`center`,t.center),this.syncLaneCells(`right`,t.right),this.syncCellValues(e.summaryCells,e.valueCacheVersion,e.force??!1)}syncRowLayout(e){this.footerRowEl.style.width=`${e.getTotalWidth()}px`,this.syncLaneWidths(e)}syncColumnLayouts(){if(this.columnModel){this.syncRowLayout(this.columnModel);for(let e of[`left`,`center`,`right`]){let t=this.lanes[e];for(let e=0;e<t.indices.length;e++){let n=t.indices[e],r=n===void 0?void 0:this.columnModel.getColumn(n),i=t.cells[e];!r||!i||this.applyCellColumnLayout(i,r)}}}}refreshVisibleColumnStructure(e){if(!this.columnModel)return;let t=P_({columnModel:this.columnModel,centerWindow:e,enableCellSpan:this.enableCellSpan,paramsForColumn:e=>T_(e,this.summaryCells.get(e.colId)?.value??null)});this.syncLaneWidths(this.columnModel),this.syncLaneCells(`left`,t.left),this.syncLaneCells(`center`,t.center),this.syncLaneCells(`right`,t.right),this.syncCellValues(this.summaryCells,0,!0)}destroy(){for(let e of Object.values(this.lanes)){for(let t of e.cells)t.destroy();e.cells.length=0,e.cellCtrls.length=0,e.indices.length=0}}createLane(e){return{element:e,cells:[],cellCtrls:[],indices:[]}}syncLaneWidths(e){this.lanes.left.element.style.width=`${e.getLeftFixedWidth()}px`,this.lanes.center.element.style.width=`${e.getCenterTotalWidth()}px`,this.lanes.right.element.style.width=`${e.getRightFixedWidth()}px`}syncLaneCells(e,n){let r=this.lanes[e];for(r.indices=n;r.cells.length<n.length;)r.cells.push(new C_(r.element,{onUnmountRenderer:this.onUnmountRenderer})),r.cellCtrls.push(new S_);for(;r.cells.length>n.length;)r.cells.pop()?.destroy(),r.cellCtrls.pop();for(let e=0;e<n.length;e++){let i=n[e],a=i===void 0?void 0:this.columnModel.getColumn(i),o=r.cells[e];!a||!o||(this.applyCellColumnLayout(o,a),o.setColId(a.colId),Gp(o.getElement(),a.footerAlign,a.footerValign,`mg-footer-cell`),o.getElement().classList.toggle(`mg-footer-cell--index`,t.it(a.colId)),o.getElement().classList.toggle(`mg-footer-cell--selection`,t.X(a.colId)))}}applyCellColumnLayout(e,t){if(!this.columnModel)return;if(!this.enableCellSpan||!t.colSpan){e.setColumnLayout(Ip(t,this.columnModel)),D_(e.getElement(),1,`mg-footer-cell`);return}let n=A_(t,this.columnModel,{enableCellSpan:!0,params:T_(t,this.summaryCells.get(t.colId)?.value??null)});e.setColumnLayout(E_(n,this.columnModel)),D_(e.getElement(),n.length,`mg-footer-cell`)}syncCellValues(e,t,n){if(this.columnModel)for(let r of[`left`,`center`,`right`]){let i=this.lanes[r];for(let r=0;r<i.indices.length;r++){let a=i.indices[r],o=a===void 0?void 0:this.columnModel.getColumn(a),s=i.cells[r],c=i.cellCtrls[r];if(!o||!s||!c)continue;let l=e.get(o.colId)??{value:null,formattedValue:``};c.refreshSummaryCell(o,l,s,t,{force:n,scheduleRenderer:e=>this.scheduleRendererTask(e)})}}}scheduleRendererTask(e){if(this.frameService){this.frameService.createTask(e,-1,`f1`);return}e()}};function ev(e,t,n,r){e.style.width=`${r.getLeftFixedWidth()}px`,t.style.width=`${r.getCenterTotalWidth()}px`,n.style.width=`${r.getRightFixedWidth()}px`}function tv(e,t,n,r){Rp(e,r,`mg-footer-cell`),Rp(t,r,`mg-footer-cell`),Rp(n,r,`mg-footer-cell`)}function nv(e,t){if(t.filterFormatter)return t.filterFormatter(e.data);let n=t.prop??t.colId,r=n?e.data[n]:void 0;return t.formatter?(t.valueGetter&&(r=t.valueGetter(e.data,r)),t.formatter(e.data,r)):t.valueGetter?t.valueGetter(e.data,r):r}function rv(e,t){return{getFilterType:t=>e(t)?.filterType??`text`,getFilterParams:t=>e(t)?.filterParams??{caseSensitive:!0},getFilterValue:(n,r)=>{let i=e(r);return i?nv(n,i):t(n,r)}}}var iv=3;function av(e,t,n){let r=e.getRowCount();if(r===0)return t;let i=e.getTotalHeight()/r,a=e.getRowIndexAtPixel(n),o=e.getRowBounds(a)?.rowHeight??t;return Math.max(t,i,o)}function ov(e,t,n,r,i){let a=e.getRowCount(),o=t,s=n;for(;o>0;){let t=e.getRowBounds(o);if(!t||t.rowTop<=r)break;o--}for(;s<a-1;){let t=e.getRowBounds(s);if(!t||t.rowTop+t.rowHeight>=i)break;s++}return{firstRow:o,lastRow:s}}function sv(e,t,n){for(let r=t;r<=n;r++)if(e.getRow(r)?.estimated)return!0;return!1}function cv(e,t,n,r){let i=Math.max(n,500);return t-e+1<=i?t:Math.min(e+i-1,r-1)}function lv(e){let{scrollTop:t,viewportHeight:n,rowBuffer:r,rowHeight:i,rowModel:a}=e,o=a.getRowCount();if(o===0)return{firstRow:0,lastRow:-1};let s=0,c=o-1,l=!1;for(let e=0;e<iv&&!l;e++){let e=r*av(a,i,t),u=Math.max(0,t-e),d=t+n+e;s=a.getRowIndexAtPixel(u),c=Math.min(a.getRowIndexAtPixel(d),o-1);let f=ov(a,s,c,u,d);s=f.firstRow,c=f.lastRow,l=!sv(a,s,c)}return c=cv(s,c,r,o),{firstRow:s,lastRow:c}}var uv=class{blocks=new Map;accessCounter=0;get(e){return this.blocks.get(e)}ensure(e,t,n){let r=this.blocks.get(e);if(r)return r;let i={blockIndex:e,startRow:t,endRow:n,state:`idle`,lastAccess:0,retryCount:0};return this.blocks.set(e,i),i}touch(e){let t=this.blocks.get(e);t&&(this.accessCounter+=1,t.lastAccess=this.accessCounter)}setState(e,t){let n=this.blocks.get(e);n&&(n.state=t,this.touch(e))}incrementRetry(e){let t=this.blocks.get(e);return t?(t.retryCount+=1,t.retryCount):0}resetRetry(e){let t=this.blocks.get(e);t&&(t.retryCount=0)}purge(){this.blocks.clear(),this.accessCounter=0}evictLRU(e,t){let n=[...this.blocks.values()].filter(e=>e.state===`loaded`);if(n.length<=e)return[];let r=n.filter(e=>!t.has(e.blockIndex)).sort((e,t)=>e.lastAccess-t.lastAccess),i=[],a=n.length;for(let t of r){if(a<=e)break;t.state=`idle`,t.retryCount=0,i.push(t.blockIndex),--a}return i}};function dv(e,t){return Math.floor(e/t)}function fv(e,t){return e*t}function pv(e,t,n){let r=fv(e,t);return{startRow:r,endRow:Math.min(r+t,n)}}function mv(e,t,n){if(t<e)return[];let r=dv(e,n),i=dv(t,n),a=[];for(let e=r;e<=i;e++)a.push(e);return a}var hv=class{deps;cache=new uv;inflight=new Map;generation=0;destroyed=!1;datasource;constructor(e){this.deps=e,this.datasource=e.datasource}init(){let e=this.deps.getApi();this.datasource.init?.({api:e,getSortModel:this.deps.getSortModel,getFilterModel:this.deps.getFilterModel,getQuickFilterText:()=>this.deps.rowModel.getQuickFilterText()})}setDatasource(e){this.destroyed||(this.datasource.destroy?.(),this.datasource=e,this.purge(`datasource`),this.init(),this.loadInitialBlocks())}destroy(){this.destroyed=!0,this.abortAll(),this.datasource.destroy?.()}loadInitialBlocks(){this.ensureBlocksForViewport(0)}ensurePrefetchOnScrollBottom(){if(this.destroyed||this.deps.rowModel.getKnownLastRow()!==null)return;let e=this.deps.options.blockSize,t=this.deps.rowModel.getRowCount(),n=t+e;this.deps.rowModel.setVirtualRowCount(n,{preserveLoaded:!0});let r=dv(t,e);this.ensureBlockLoaded(r)}ensureBlocksForViewport(e,t){let n=t??0,{firstRow:r,lastRow:i}=lv({scrollTop:e,viewportHeight:n>0?n:this.deps.rowHeight*10,rowBuffer:this.deps.rowBuffer,rowHeight:this.deps.rowHeight,rowModel:this.deps.rowModel});if(i<r){this.ensureBlockLoaded(0);return}let a=this.deps.options.blockSize,o=Math.min(i+a,Math.max(0,this.deps.rowModel.getRowCount()-1));this.ensureBlocksForRange(r,o)}ensureBlocksForRange(e,t){let n=this.deps.options.blockSize,r=mv(e,t,n);for(let e of r)this.ensureBlockLoaded(e);this.evictIfNeeded(e,t)}retryBlock(e){let t=this.deps.options.blockSize,{startRow:n,endRow:r}=pv(e,t,this.deps.rowModel.getRowCount()),i=this.cache.get(e);i&&(i.state=`idle`,this.cache.resetRetry(e)),this.deps.rowModel.markBlockRange(n,r,`idle`),this.ensureBlockLoaded(e)}refreshCache(e=`api`){this.purge(e),this.loadInitialBlocks()}purge(e){this.generation+=1,this.abortAll(),this.cache.purge(),this.deps.rowModel.resetForPurge(this.deps.options.infiniteInitialRowCount),this.deps.eventBus.emit(`infiniteCachePurged`,{reason:e}),this.deps.onModelChanged()}getLoadedRowData(){return this.deps.rowModel.getLoadedRowData()}getInfiniteRowCount(){return this.deps.rowModel.getKnownLastRow()??this.deps.rowModel.getVirtualRowCount()}ensureBlockLoaded(e){if(this.destroyed)return;let t=this.deps.options.blockSize,{startRow:n,endRow:r}=pv(e,t,this.deps.rowModel.getRowCount());if(n>=r)return;let i=this.cache.ensure(e,n,r);if(i.state===`loaded`||i.state===`loading`||i.state===`failed`){this.cache.touch(e);return}this.inflight.has(e)||this.loadBlock(e,n,r)}loadBlock(e,t,n){let r=new AbortController,i=this.generation;this.inflight.set(e,{controller:r,generation:i}),this.cache.setState(e,`loading`),this.deps.rowModel.markBlockRange(t,n,`loading`),this.deps.onModelChanged();let a={blockIndex:e,startRow:t,endRow:n};this.deps.eventBus.emit(`infiniteBlockLoading`,a);try{this.datasource.getRows({startRow:t,endRow:n,sortModel:this.deps.getSortModel(),filterModel:this.deps.getFilterModel(),quickFilterText:this.deps.rowModel.getQuickFilterText(),signal:r.signal,successCallback:(r,a)=>{this.handleSuccess(e,t,n,r,a,i)},failCallback:r=>{this.handleFailure(e,t,n,r,i)}})}catch(r){this.handleFailure(e,t,n,r,i)}}handleSuccess(e,t,n,r,i,a){if(!this.isCurrentGeneration(a,e))return;this.inflight.delete(e),this.cache.setState(e,`loaded`),this.cache.resetRetry(e);let o=this.deps.rowModel.applyBlock(t,r),s=t+r.length;this.deps.rowModel.updateLastRow(i,this.deps.options.blockSize,s);let c=n-t;r.length<c&&i===void 0&&this.deps.rowModel.markBlockRange(t+r.length,n,`idle`);let l={blockIndex:e,startRow:t,endRow:n,rowCount:r.length,lastRow:i};this.deps.eventBus.emit(`infiniteBlockLoaded`,l),this.deps.onModelChanged({refreshedRowIds:o.rowIds,replacedStubIds:o.replacedStubIds})}handleFailure(e,t,n,r,i){if(!this.isCurrentGeneration(i,e))return;this.inflight.delete(e);let a=this.cache.incrementRetry(e),o=this.deps.options.infiniteMaxRetries;if(o>0&&a<=o){this.cache.setState(e,`idle`),this.deps.rowModel.markBlockRange(t,n,`idle`),this.ensureBlockLoaded(e);return}this.cache.setState(e,`failed`),this.deps.rowModel.markBlockRange(t,n,`failed`);let s={blockIndex:e,startRow:t,endRow:n,error:r};this.deps.eventBus.emit(`infiniteBlockLoadFailed`,s),this.deps.onModelChanged()}isCurrentGeneration(e,t){return this.destroyed||e!==this.generation?!1:this.inflight.get(t)?.generation===e}evictIfNeeded(e,t){let n=this.deps.options.blockSize,r=dv(Math.floor((e+t)/2),n),i=new Set([r-1,r,r+1]),a=this.cache.evictLRU(this.deps.options.maxBlocksInCache,i);for(let e of a){let{startRow:t,endRow:r}=pv(e,n,this.deps.rowModel.getRowCount());this.deps.rowModel.evictBlockRange(t,r)}a.length>0&&(this.deps.eventBus.emit(`infiniteCachePurged`,{reason:`lru`}),this.deps.onModelChanged())}abortAll(){for(let e of this.inflight.values())e.controller.abort();this.inflight.clear()}};function gv(e,t){if(t.length===0)return!1;let n=e.__autoHeights??{};return t.some(e=>n[e]==null)}function _v(e){if(!e.getRowHeight)return;let t=e.getRowHeight;return e=>t({rowId:e.id,data:e.data,rowIndex:e.rowIndex})}function vv(e,t,n){if(e.rowHeightPinned&&e.rowHeight>0)return{height:Ua(e.rowHeight,n.rowHeightMin,n.rowHeightMax),estimated:!1};let r=lr(e,t,_v(n));return{height:Ua(r.height,n.rowHeightMin,n.rowHeightMax),estimated:r.estimated}}function yv(e,t,n){if(e.rowHeightPinned)return!1;let r=_v(n)?.(e);return r!=null&&r>0||e.__autoHeights&&Object.keys(e.__autoHeights).length>0?!1:e.rowHeight===t||e.rowHeight===0}function bv(e,t){return t??(e===`api`||e===`uiRowResized`)}var xv=class{deps;defaultRowHeight;options;gridOptions;constructor(e,t,n={}){this.deps=e,this.defaultRowHeight=t,this.gridOptions=n,this.options=Ba(n,t)}getDefaultRowHeight(){return this.defaultRowHeight}setGridOptions(e={}){this.gridOptions=e,this.options=Ba(e,this.defaultRowHeight)}getOptions(){return this.options}updateDefaultRowHeight(e,t={}){let n=this.defaultRowHeight,r=Math.max(1,e);if(this.gridOptions={...this.gridOptions,...t},this.defaultRowHeight=r,this.options=Ba(this.gridOptions,r),n===r)return this.recalculateDisplayRowHeights(void 0,`dimensions`);for(let e of this.deps.getDisplayRows())yv(e,n,this.options)&&(e.rowHeight=0,e.estimated=!1);let i=this.recalculateDisplayRowHeights(void 0,`dimensions`);return i.changed||this.deps.repositionDisplayRows(),i}getRowHeight(e){let t=this.deps.getRowById(e);return t?vv(t,this.defaultRowHeight,this.options).height:null}setRowHeights(e,t){let n=[],r=bv(t.source,t.pin);for(let t of e){let e=this.deps.getRowById(t.rowId);if(!e)continue;let i=Ua(t.height,this.options.rowHeightMin,this.options.rowHeightMax),a=r;if(e.rowHeight===i&&e.rowHeightPinned===a)continue;let o=e.rowHeight;e.rowHeight=i,e.rowHeightPinned=a,e.estimated=!1,n.push({rowId:e.id,rowHeight:i,previousRowHeight:o})}if(n.length===0)return{changed:!1,rows:[],finished:t.finished,source:t.source};this.deps.repositionDisplayRows();let i=Wa(n,t.finished,t.source);return this.deps.emitRowHeightChanged(i),{changed:!0,rows:n,finished:t.finished,source:t.source}}setRowHeight(e,t,n=!0,r=`api`){return this.setRowHeights([{rowId:e,height:t}],{finished:n,source:r})}resetRowHeights(e){let t=this.resolveResetTargets(e),n=[];for(let e of t){e.rowHeightPinned=!1,delete e.__autoHeights,e.rowHeight=0,e.estimated=!1;let t=vv(e,this.defaultRowHeight,this.options);e.rowHeight=t.height,e.estimated=t.estimated,n.push({rowId:e.id,height:t.height})}if(n.length===0)return{changed:!1,rows:[],finished:!0,source:`api`};this.deps.repositionDisplayRows();let r=n.map(e=>({rowId:e.rowId,rowHeight:e.height})),i=Wa(r,!0,`api`);return this.deps.emitRowHeightChanged(i),{changed:!0,rows:r,finished:!0,source:`api`}}recalculateDisplayRowHeights(e,t=`autoHeight`){let n=e?new Set(e):null,r=[];for(let e of this.deps.getDisplayRows()){if(n&&!n.has(e.id)||e.rowHeightPinned)continue;let t=vv(e,this.defaultRowHeight,this.options),i=this.deps.getAutoHeightColumnIds?.()??[],a=t.estimated;!e.rowHeightPinned&&i.length>0&&gv(e,i)&&(a=!0),(e.rowHeight!==t.height||e.estimated!==a)&&(e.rowHeight=t.height,e.estimated=a,r.push({rowId:e.id,rowHeight:t.height}))}if(r.length===0)return{changed:!1,rows:[],finished:!0,source:t};this.deps.repositionDisplayRows();let i=Wa(r,!0,t);return this.deps.emitRowHeightChanged(i),{changed:!0,rows:r,finished:!0,source:t}}getPositionRowHeightFn(){return _v(this.options)}resolveResetTargets(e){return e&&e.length>0?e.map(e=>this.deps.getRowById(e)).filter(e=>e!=null):[...this.deps.getDisplayRows()]}};function Sv(e){return e.classList.contains(`mg-cell--editing`)||e.classList.contains(`mg-cell--inline-editor`)}function Cv(e){if(Sv(e))return 0;let t=wv(e);if(!t)return e.offsetHeight;let n=getComputedStyle(e),r=Number.parseFloat(n.paddingTop)||0,i=Number.parseFloat(n.paddingBottom)||0,a=Number.parseFloat(n.borderTopWidth)||0,o=Number.parseFloat(n.borderBottomWidth)||0,s=t.scrollHeight;return Math.ceil(s+r+i+a+o)}function wv(e){return[e.querySelector(`.mg-cell__text:not([hidden])`),e.querySelector(`.mg-cell__renderer:not([hidden])`),e.querySelector(`.mg-cell__inline-editor:not([hidden])`)].find(e=>e!=null)??null}var Tv=5,Ev=1,Dv=class{deps;active=!1;wasEverActive=!1;debounceTimer=null;pendingRowIds=new Set;constructor(e){this.deps=e}isActive(){return this.active}setCellHeight(e,t,n){if(!this.deps.isColumnAutoHeight(t))return;let r=this.deps.getRowById(e);if(!r)return;if(r.__autoHeights??={},n==null){r.__autoHeights[t]!=null&&(delete r.__autoHeights[t],Object.keys(r.__autoHeights).length===0&&delete r.__autoHeights,r.rowHeightPinned||this.requestCheckAutoHeight(e));return}if(r.rowHeightPinned)return;let i=r.__autoHeights[t];r.__autoHeights[t]=n,this.active=!0,this.wasEverActive=!0,i!==n&&this.requestCheckAutoHeight(e)}setupCellAutoHeight(e){if(!this.deps.isColumnAutoHeight(e.colId))return null;this.active=!0,this.wasEverActive=!0;let{rowId:t,colId:n,cellEl:r}=e;r.classList.add(za);let i=(e=0)=>{if(r.classList.contains(`mg-cell--editing`))return;let a=Cv(r);if(a<=0&&e<Tv){window.setTimeout(()=>i(e+1),0);return}a>0&&this.setCellHeight(t,n,a)};i();let a=wv(r),o=a&&typeof ResizeObserver<`u`?new ResizeObserver(()=>{r.classList.contains(`mg-cell--editing`)||i()}):null;o?.observe(a??r);let s=typeof MutationObserver<`u`?new MutationObserver(()=>{r.classList.contains(`mg-cell--editing`)||i()}):null;return s?.observe(r,{attributes:!0,attributeFilter:[`class`]}),()=>{o?.disconnect(),s?.disconnect(),r.classList.remove(za),this.setCellHeight(t,n,void 0)}}requestCheckAutoHeight(e){this.wasEverActive&&(this.pendingRowIds.add(e),this.scheduleRecalculate())}flushPendingRecalculate(){if(this.pendingRowIds.size===0)return;let e=[...this.pendingRowIds];this.pendingRowIds.clear(),this.deps.rowHeightService.recalculateDisplayRowHeights(e)}destroy(){this.debounceTimer!=null&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.pendingRowIds.clear(),this.active=!1}scheduleRecalculate(){this.debounceTimer??=window.setTimeout(()=>{this.debounceTimer=null,this.flushPendingRecalculate()},Ev)}};function Ov(e){let t=new Set;if(e.lastRow<e.firstRow)return t;for(let n=e.firstRow;n<=e.lastRow;n++)t.add(n);return t}function kv(e,t){let n=Ov(t),r=[],i=[],a=[];for(let t of n)e.has(t)?i.push(t):r.push(t);for(let t of e)n.has(t)||a.push(t);return{toCreate:r,toUpdate:i,toDestroy:a}}function Av(e,t){return e.lastRow<e.firstRow?!1:e.firstRow===t.firstRow&&e.lastRow===t.lastRow}var jv=`mg-cell__index-loading-spinner`,Mv=`mg-cell--index-focused`;function Nv(e,n){if(e.classList.toggle(t.nt,n),n){if(e.classList.remove(Mv,ms),!e.querySelector(`.mg-cell__index-loading-spinner`)){let t=document.createElement(`span`);t.className=jv,t.setAttribute(`aria-hidden`,`true`),e.append(t)}e.setAttribute(`aria-busy`,`true`);return}e.querySelector(`.${jv}`)?.remove(),e.removeAttribute(`aria-busy`)}var Pv=class{pool=new Map;acquire(e,t){let n=this.pool.get(e);if(n)return n;let r=t();return this.pool.set(e,r),r}get(e){return this.pool.get(e)}release(e){let t=this.pool.get(e);t&&(t.destroy(),this.pool.delete(e))}migrateId(e,t){if(e===t)return;let n=this.pool.get(e);n&&(this.pool.delete(e),this.pool.set(t,n))}clear(){for(let e of this.pool.values())e.destroy();this.pool.clear()}getActiveCount(){return this.pool.size}getActiveIds(){return[...this.pool.keys()]}};function Fv(e){let{indices:t,enableCellSpan:n,spannedRowOnly:r,rowNode:i,columnModel:a,cellSpanService:o,getRowByIndex:s,getRowCount:c}=e;if(!n||!Qa(i))return t;let l=e=>{if(o)return o.resolveVerticalSpan(i,e);if(!e.rowSpan||!s)return{head:i,rowSpan:1,covered:!1};let t=c?.()??i.rowIndex+1;return I_({enableCellSpan:!0,column:e,rowNode:i,getRowByIndex:s,rowCount:t})};return t.filter(e=>{let t=a.getColumn(e);if(!t)return!0;let n=l(t);if(n.covered)return!1;let o=n.rowSpan>1&&n.head.id===i.id,s=Za(t);return r?!s&&o:!(o&&!s)})}function Iv(e,t,n){let r=t.getElement();if(!e.enableCellSpan||!n.colSpan)t.setColumnLayout(Ip(n,e.columnModel)),D_(r,1);else{let i=A_(n,e.columnModel,{enableCellSpan:!0,params:w_(e.rowNode,n)});t.setColumnLayout(E_(i,e.columnModel)),D_(r,i.length)}Lv(e,r,n)}function Lv(e,t,n){if(!e.enableCellSpan){z_(t,1,null);return}let r=e.getRowCount?.()??e.rowNode.rowIndex+1,i=(e,t)=>R_(e,t,r);if(e.cellSpanService){let r=e.cellSpanService.resolveVerticalSpan(e.rowNode,n);if(r.covered||r.rowSpan<=1){z_(t,1,null);return}let a=e.cellSpanService.getVerticalSpanHeight(e.rowNode,n);z_(t,r.rowSpan,a,{endsTable:i(r.head.rowIndex,r.rowSpan)}),e.applyRowSpanCoverHighlight(t,r.head,r.rowSpan);return}if(!n.rowSpan||!e.getRowByIndex){z_(t,1,null);return}let a=I_({enableCellSpan:!0,column:n,rowNode:e.rowNode,getRowByIndex:e.getRowByIndex,rowCount:r});if(a.covered||a.rowSpan<=1){z_(t,1,null);return}let o=L_(a.head,a.rowSpan,e.getRowByIndex);z_(t,a.rowSpan,o,{endsTable:i(a.head.rowIndex,a.rowSpan)}),e.applyRowSpanCoverHighlight(t,a.head,a.rowSpan)}function Rv(e,t,n,r){if(!e.getRowByIndex||r<=1){t.classList.remove(`mg-cell--row-span-highlighted`);return}let i=B_({head:n,rowSpan:r,getRowByIndex:e.getRowByIndex,isRowHighlighted:t=>e.isRowCoverHighlighted?e.isRowCoverHighlighted(t):t===n.id&&(e.selected||e.indexFocused)});t.classList.toggle(`mg-cell--row-span-highlighted`,i)}function zv(e,t){if(!(!e.enableCellSpan||!e.rowNode||!e.getRowByIndex))for(let n of t)for(let t of n.cells){let n=t.getElement();if(!n.classList.contains(`mg-cell--row-span`))continue;let r=Number(n.dataset.rowSpan??1);r<=1||Rv(e,n,e.rowNode,r)}}function Bv(e,t){if(e.spannedRowOnly||!e.enableCellSpan||!e.rowNode||!e.columnModel||!e.cellSpanService){t.classList.remove(Ja);return}let n=!1;for(let t of e.columnModel.getColumns())if(Za(t)&&oo(t.rowSpan,t.spanRows)!==`none`&&e.cellSpanService.resolveVerticalSpan(e.rowNode,t).covered){n=!0;break}t.classList.toggle(Ja,n)}function Vv(e,t){let n=e.masterRowId;if(!n)return null;let r=t?.(n);return{rowId:e.id,masterRowId:n,data:e.data,detailRowData:r?.__detailRowData,loading:r?.__detailLoading??!1,loadFailed:r?.__detailLoadError!==void 0,loadError:r?.__detailLoadError}}function Hv(e,t,n,r={}){let i=()=>{if(r.onUnmountRenderer?.(e),e.replaceChildren(),!n){t.loading?e.textContent=`Loading…`:t.loadFailed&&(e.textContent=`Failed to load detail`),r.onAfterRender?.();return}let i={mountEl:e,clear:()=>{r.onUnmountRenderer?.(e),e.replaceChildren()}},a=n(t,i);if(typeof a==`string`){i.clear(),e.textContent=a;return}a instanceof HTMLElement&&(i.clear(),e.appendChild(a)),r.onAfterRender?.()},a=r.rowIndex??0;if(r.frameService){r.frameService.createTask(i,a,`f1`);return}i()}var Uv=class{isActive=!1;contentEl=null;get active(){return this.isActive}activate(e,t,n){this.isActive=!0,n.rowElement.classList.add(`mg-row--full-width-embed`,`mg-row--detail`),n.rowElement.dataset.rowKind=`DETAIL`,e.masterRowId&&(n.rowElement.dataset.masterRowId=e.masterRowId),this.refreshPinnedLanes(n),this.contentEl||(this.contentEl=document.createElement(`div`),this.contentEl.className=E,n.lanes.center.element.appendChild(this.contentEl)),this.refreshContent(n),n.syncStripeClass(),n.syncLastRowClass(t)}refreshPinnedLanes(e){let{left:t,right:n}=e.buildEmbedPinnedLaneIndices();e.syncEmbedLaneCells(t,n),this.syncSpacerCells(e)}refreshContent(e){if(!this.contentEl)return;let t=Vv(e.rowNode,e.getMasterRowById);t&&Hv(this.contentEl,t,e.getDetailCellRenderer?.(),{frameService:e.frameService,onUnmountRenderer:e.onUnmountRenderer,rowIndex:e.rowNode.rowIndex,onAfterRender:()=>{e.detailRowAutoHeightService?.setupContentObserver(e.rowNode.id,this.contentEl)}})}deactivate(e){e.rowNode&&e.detailRowAutoHeightService?.teardownContentObserver(e.rowNode.id),this.isActive=!1,e.rowElement.classList.remove(`mg-row--full-width-embed`,`mg-row--detail`),delete e.rowElement.dataset.rowKind,delete e.rowElement.dataset.masterRowId,this.contentEl&&=(e.onUnmountRenderer?.(this.contentEl),this.contentEl.replaceChildren(),this.contentEl.remove(),null);for(let t of[`left`,`right`])for(let n of e.lanes[t].cells)n.getElement().classList.remove(`mg-cell--embed-spacer`),n.getElement().removeAttribute(`aria-hidden`)}syncSpacerCells(e){for(let t of[`left`,`right`])for(let n of e.lanes[t].cells){let e=n.getElement();e.classList.add(`mg-cell--embed-spacer`),e.setAttribute(`aria-hidden`,`true`),n.clearSelectionCheckbox(),n.clearRowExpandButton(),n.setValue(``)}}};function Wv(e){return e==null?`none`:typeof e==`string`?e:typeof e==`function`?e.name||`fn`:`obj`}function Gv(e,n,r={}){let i=[e.autoHeight?`ah1`:`ah0`,e.rowDrag?`rd1`:`rd0`,e.rowExpand?`re1`:`re0`,e.cellEditorMode??`overlay`,e.cellRenderer?`cr:${Wv(e.cellRenderer)}`:`cr:none`];if(t.V(e)&&i.push(`ed:${Wv(e.cellEditor)}`),t.X(e.colId)&&i.push(`selection`),t.it(e.colId)){let t=R(n)&&(r.rowDragHandleEnabled?.(e.colId)??!1);i.push(t?`idxDrag1`:`idxDrag0`),i.push(r.indexRowResizerEnabled?`idxRsz1`:`idxRsz0`)}return t.V(e)&&i.push(`inlineHost`),i.join(`|`)}function Kv(e,t){return e!==``&&e!==t}function qv(e,t){return t?`折叠第 ${e+1} 行详情`:`展开第 ${e+1} 行详情`}function Jv(){let e=document.createElement(`button`);return e.type=`button`,e.className=S,e.setAttribute(`aria-expanded`,`false`),e.appendChild(jm()),e}function Yv(e,t){if(!t.visible){e.hidden=!0,e.classList.remove(C),e.setAttribute(`aria-expanded`,`false`);return}e.hidden=!1,e.setAttribute(`aria-label`,t.ariaLabel),e.setAttribute(`aria-expanded`,String(t.expanded)),e.classList.toggle(C,t.expanded)}function Xv(e,t){return e===t}function Zv(e,t,n){return n?.length?n.some(n=>n.rowId===e&&n.colId===t):!1}var Qv=class{cachedValue=``;cachedRenderKey=``;cachedCompIdentityKey=``;cacheVersion=-1;inlineSession=null;activeResolveBusinessRowId;pendingVueRendererContext=null;cachedStructuralSignature=``;refreshCell(e,n,r,i,a=!1){let o=typeof a==`boolean`?{force:a}:a,s=o.force??!1,c=o.newData??!1;this.activeResolveBusinessRowId=o.resolveBusinessRowId;let l=o.cellDisableContext??o.getCellDisableContext?.(),u=o.cellStyleContext??o.getCellStyleContext?.(),d=o.indexColumnOptions,f=o.selectionColumnOptions;gt(n.colId,e.rowKind,n.prop,e.id)&&this.syncCellDisabledVisual(e,n,r,l),this.syncCellEditableRoleVisual(e,n,r,u),this.syncCellStyleVisual(e,n,r,u),this.syncCellEditableIndicatorVisual(e,n,r,u),this.syncCellDisabledIndicatorVisual(e,n,r,u);let p=Gv(n,e,o.structuralContext??o.getCellStructuralContext?.()??{indexRowResizerEnabled:d?.enableRowResizer});if(Kv(this.cachedStructuralSignature,p)&&this.recreateCellState(r),this.cachedStructuralSignature=p,Zv(e.id,n.colId,o.overlayEditingTargets))return!1;if(t.X(n.colId))return this.clearInlineSession(r),this.refreshSelectionCell(e,n,r,i,s,f,o.selectionChecked??!1,o.selectionDisabled??!1,o.selectionIndeterminate??!1);if(j(n)&&o.rowExpansionHost?.active())return this.clearInlineSession(r),this.refreshExpandCell(e,n,r,i,s,o.rowExpansionHost);if(ke(n,e)&&o.rowGroupingHost?.active())return this.clearInlineSession(r),this.refreshGroupCell(e,n,r,i,s,o.rowGroupingHost);if(mh(n,e)&&o.treeTableHost?.active())return this.clearInlineSession(r),this.refreshTreeCell(e,r,i,s,o.treeTableHost);if(!t.it(n.colId)&&t.V(n)&&o.inlineEditor&&R(e))return this.refreshInlineEditorCell(e,n,r,i,s,c,o.inlineEditor,o,o.scheduleInlineEditor);if(this.clearInlineSession(r),!t.it(n.colId)&&n.cellRenderer)return this.refreshRendererCell(e,n,r,i,s,c,o.scheduleRenderer,o.cellRendererDefer,o.cellRendererPresentation,o.scrollActive,d);let m=Xf(e,n,d);return!s&&!c&&this.cacheVersion===i&&Xv(this.cachedValue,m)?!1:(r.clearRenderer(),this.cachedValue=m,this.cachedRenderKey=``,this.cacheVersion=i,r.setValue(m),!0)}syncCellDisabledVisual(e,t,n,r){let i=bt(t,e,r);n.setCellDisabled(i)}syncCellEditableRoleVisual(e,t,n,r){let i=kn(t,e,r);n.setCellEditableRole(i)}syncCellStyleVisual(e,t,n,r){let i=Rn(t,e,r);n.setCellStyle(i)}syncCellEditableIndicatorVisual(e,t,n,r){let i=Fn(t,e,r);n.setCellEditableIndicator(i)}syncCellDisabledIndicatorVisual(e,t,n,r){let i=Ln(t,e,r);n.setCellDisabledIndicator(i)}invalidate(){this.cacheVersion=-1,this.cachedRenderKey=``,this.cachedCompIdentityKey=``,this.cachedStructuralSignature=``,this.inlineSession=null,this.pendingVueRendererContext=null}recreateCellState(e){this.clearInlineSession(e),e.clearRenderer(),this.invalidate()}hasPendingVueRenderer(){return this.pendingVueRendererContext!==null}promoteVueRenderer(e,t,n={}){let r=this.pendingVueRendererContext;if(!r)return!1;this.pendingVueRendererContext=null,this.cachedRenderKey.endsWith(`:placeholder`)&&(this.cachedRenderKey=this.cachedRenderKey.slice(0,-12));let i=()=>{this.applyRenderer(r.column,t,r.params,!0)};return n.scheduleRenderer&&ga(r.cellRendererPresentation,r.cellRendererDefer,r.column.cellRenderer,r.column.cellRendererMount)&&n.scheduleRenderer?(n.scheduleRenderer(i),!0):(i(),!0)}clearInlineSession(e){this.inlineSession&&(this.inlineSession.mounted.destroy(),this.inlineSession=null,e.clearInlineEditor())}refreshInlineEditorCell(e,t,n,r,i,a,o,s,c){let l=H(e,t),u=s.cellDisableContext??s.getCellDisableContext?.(),d=V(t,e,u),f=bt(t,e,u),p=!d,m=Sp(e.id,t.colId,d,f,t.cellEditor);if(a&&this.inlineSession&&this.clearInlineSession(n),this.inlineSession&&this.cachedCompIdentityKey===m){let i=String(l)!==this.cachedValue;if($v(this.inlineSession.mounted,l,p,t),n.setInlineEditorDisabledVisual(f),i&&o.host.isVueEditorColumn(t)){let r=n,i=this.buildInlineEditorParams(e,t,n,o,p);o.host.patch(r.getInlineEditorMountEl(),t,i)}return this.cachedValue=String(l),this.cacheVersion=r,!1}this.cachedCompIdentityKey=m,this.cachedRenderKey=m,this.cachedValue=String(l),this.cacheVersion=r;let h=()=>{this.mountInlineEditor(e,t,n,o,p,f)};return c?(c(h),!0):(h(),!0)}buildInlineEditorParams(e,t,n,r,i){return{...r.createParams(e,t),commit:async()=>{let a=this.inlineSession?.mounted;if(!a)return;let o=n;o.setInlineEditorCommitting(!0);let s=a.getFocusTarget();s instanceof HTMLInputElement&&(s.disabled=!0);try{let n=H(e,t);await r.commit(e,t,a.getValue(),n)||$v(a,H(e,t),i,t)}finally{o.setInlineEditorCommitting(!1),s instanceof HTMLInputElement&&(s.disabled=i)}}}}mountInlineEditor(e,t,n,r,i,a){this.clearInlineSession(n);let o=n,s=r.host.isVueEditorColumn(t),c=s&&o.canPatchVueInlineEditor(t.colId);c?o.prepareForInlineEditorPatch(a):o.prepareForInlineEditor(a);let l=o.getInlineEditorMountEl(),u=this.buildInlineEditorParams(e,t,n,r,i),d=r.host.mount(l,t,u,{patch:c});s&&o.markVueInlineEditorMounted(t.colId),this.inlineSession={identityKey:this.cachedCompIdentityKey,mounted:d},$v(d,u.value,i,t);let f=d.getFocusTarget();f instanceof HTMLInputElement&&(f.disabled=i)}refreshSelectionCell(e,t,n,r,i,a,o,s,c){let l=n;if(Ue(e)){let e=`group-row:no-selection`;return!i&&this.cacheVersion===r&&this.cachedValue===e?!1:(this.cachedValue=e,this.cachedRenderKey=``,this.cacheVersion=r,l.clearSelectionCheckbox(),l.setValue(``),!0)}let u=a?Mp(e.rowIndex,a.selectionColumn):`选择第 ${e.rowIndex+1} 行`,d=`${o}:${s}:${c}:${u}`;return!i&&this.cacheVersion===r&&this.cachedValue===d?!1:(this.cachedValue=d,this.cachedRenderKey=``,this.cacheVersion=r,l.setSelectionCheckbox({checked:o,disabled:s,indeterminate:c,ariaLabel:u}),!0)}refreshExpandCell(e,t,n,r,i,a){let o=!I(e)&&a.isRowMaster(e),s=o&&a.isExpanded(e.id),c=qv(e.rowIndex,s),l=`${o}:${s}:${c}`;if(!i&&this.cacheVersion===r&&this.cachedValue===l)return!1;this.cachedValue=l,this.cachedRenderKey=``,this.cacheVersion=r;let u=n;return o?(u.setRowExpandButton({visible:!0,expanded:s,ariaLabel:c}),!0):(u.clearRowExpandButton(),u.setValue(``),!0)}refreshGroupCell(e,t,n,r,i,a){if(oh(t,e)){let e=ah(t,a);return!i&&this.cacheVersion===r&&this.cachedValue===e?!1:(this.cachedValue=e,this.cachedRenderKey=``,this.cacheVersion=r,n.setValue(e),!0)}let o=sh(e,a,t),s=[o.visible,o.showChevron,o.expanded,o.indentLevel,o.label,o.showCount,o.count,o.ariaLabel].join(`:`);if(!i&&this.cacheVersion===r&&this.cachedValue===s)return!1;this.cachedValue=s,this.cachedRenderKey=``,this.cacheVersion=r;let c=n;return o.visible?(c.setGroupCell(o),!0):(c.clearGroupCell(),c.setValue(``),!0)}refreshTreeCell(e,t,n,r,i){let a=gh(e,i),o=[`tree`,a.visible,a.showChevron,a.expanded,a.loading,a.indentLevel,a.label,a.ariaLabel,a.hierarchyActions?.visible??!1].join(`:`);if(!r&&this.cacheVersion===n&&this.cachedValue===o)return!1;this.cachedValue=o,this.cachedRenderKey=``,this.cacheVersion=n;let s=t;return a.visible?(s.setTreeCell(a),!0):(s.clearGroupCell(),s.setValue(``),!0)}refreshRendererCell(e,t,n,r,i,a,o,s=`always`,c=`deferred`,l=!1,u){let d=Xf(e,t,u),f=`${r}:${e.id}:${t.colId}:${d}`,p=Cp(e.id,t.colId,t.cellRenderer),m=ma(t.cellRenderer),h=this.cachedValue!==d,g=this.cachedCompIdentityKey!==p,_=g||a;if(!i&&!a&&this.cacheVersion===r&&this.cachedRenderKey===`${f}:placeholder`&&this.pendingVueRendererContext&&l||!i&&!a&&!h&&!g&&this.cacheVersion===r&&!this.pendingVueRendererContext)return!1;if(i&&!a&&!h&&!g&&!this.pendingVueRendererContext)return this.cacheVersion=r,!1;this.cachedValue=d,this.cacheVersion=r;let v={rowId:this.activeResolveBusinessRowId?.(e)??e.id,rowIndex:e.rowIndex,colId:t.colId,value:H(e,t),data:e.data,formattedValue:d};if(c===`placeholder-then-vue`&&m&&l)return this.cachedRenderKey=`${f}:placeholder`,this.pendingVueRendererContext={column:t,params:v,cellRendererDefer:s,cellRendererPresentation:c,indexColumnOptions:u},n.setRendererPlaceholder(d),!0;this.pendingVueRendererContext=null,this.cachedRenderKey=f,this.cachedCompIdentityKey=p;let y=()=>{this.applyRenderer(t,n,v,_)};return o&&ga(c,s,t.cellRenderer,t.cellRendererMount)&&o?(o(y),!0):(y(),!0)}applyRenderer(e,t,n,r=!1){let i=e.cellRenderer;if(!i)return;let a=t,o=t.getRendererMountEl(),s=ma(i);if(!r&&s&&a.canPatchVueRenderer(e.colId)){if(lp(o,n)){a.markVueRendererMounted(e.colId);return}a.prepareForRendererPatch()}else a.prepareForRenderer();let c=i(n,{mountEl:o,clear:()=>{t.clearRenderer()}});s&&c==null&&a.markVueRendererMounted(e.colId),c!=null&&(typeof c==`string`||c instanceof HTMLElement)&&x_.apply(o,c)}};function $v(e,t,n,r){let i=e.getFocusTarget();!(i instanceof HTMLInputElement)||i.type!==`checkbox`||(i.checked=Jt(t,on(r)),i.disabled=n)}function ey(e,t){e.classList.toggle(Oo,t===`filled`),e.classList.toggle(ko,t===`empty`),e.removeAttribute(`data-has-comment`),e.removeAttribute(`data-comment-empty`),t===`filled`?e.dataset.hasComment=`true`:t===`empty`&&(e.dataset.commentEmpty=`true`)}var ty=class{element;textEl;rendererMount;inlineEditorMount;onUnmountRenderer;onUnmountEditor;selectionCheckbox=null;rowExpandButton=null;groupContentEl=null;groupExpandButton=null;groupLabelEl=null;groupCountEl=null;treeHierarchyActionsEl=null;rowResizeHandle=null;rowDragHandle=null;editableIndicatorEl=null;disabledIndicatorEl=null;usingRenderer=!1;usingInlineEditor=!1;vueRendererActive=!1;vueRendererColId;vueInlineEditorActive=!1;vueInlineEditorColId;rendererPlaceholderActive=!1;lastCellStyle={};constructor(e,t={}){this.onUnmountRenderer=t.onUnmountRenderer,this.onUnmountEditor=t.onUnmountEditor,this.element=document.createElement(`div`),this.element.className=`mg-cell`,this.textEl=document.createElement(`span`),this.textEl.className=`mg-cell__text`,this.rendererMount=document.createElement(`div`),this.rendererMount.className=`mg-cell__renderer`,this.rendererMount.hidden=!0,this.inlineEditorMount=document.createElement(`div`),this.inlineEditorMount.className=`mg-cell__inline-editor`,this.inlineEditorMount.hidden=!0,this.element.append(this.textEl,this.rendererMount,this.inlineEditorMount),e.appendChild(this.element)}setLayout(e,t){Lp(this.element,{left:e,width:t,fixed:null},`mg-cell`)}setColumnLayout(e){Lp(this.element,e,`mg-cell`)}setValue(e){this.clearSelectionCheckbox(),this.clearRowExpandButton(),this.clearGroupCell(),this.clearInlineEditor(),this.clearRenderer(),this.textEl.hidden=!1,this.textEl.textContent!==e&&(this.textEl.textContent=e)}setSelectionCheckbox(e){if(this.clearInlineEditor(),this.clearRenderer(),this.textEl.hidden=!0,this.textEl.textContent=``,this.element.classList.toggle(`mg-cell--selection-disabled`,!!e.disabled),!this.selectionCheckbox){this.selectionCheckbox=kp(e),this.element.append(this.selectionCheckbox);return}Ap(this.selectionCheckbox,e),this.selectionCheckbox.getAttribute(`aria-label`)!==e.ariaLabel&&this.selectionCheckbox.setAttribute(`aria-label`,e.ariaLabel)}clearSelectionCheckbox(){this.selectionCheckbox&&=(this.selectionCheckbox.remove(),null)}getSelectionCheckbox(){return this.selectionCheckbox}setRowExpandButton(e){if(this.clearInlineEditor(),this.clearRenderer(),this.clearGroupCell(),this.textEl.hidden=!0,this.textEl.textContent=``,!e.visible){this.clearRowExpandButton();return}this.rowExpandButton||(this.rowExpandButton=Jv(),this.element.append(this.rowExpandButton)),Yv(this.rowExpandButton,e)}clearRowExpandButton(){this.rowExpandButton&&=(this.rowExpandButton.remove(),null)}getRowExpandButton(){return this.rowExpandButton}setGroupCell(e){if(this.clearInlineEditor(),this.clearRenderer(),this.textEl.hidden=!0,this.textEl.textContent=``,!e.visible){this.clearGroupCell();return}this.groupContentEl||(this.groupContentEl=document.createElement(`div`),this.groupContentEl.className=th,this.groupLabelEl=document.createElement(`span`),this.groupLabelEl.className=nh,this.groupCountEl=document.createElement(`span`),this.groupCountEl.className=rh,this.groupContentEl.append(this.groupLabelEl,this.groupCountEl),this.element.append(this.groupContentEl)),this.groupExpandButton=ph(this.groupContentEl,this.groupExpandButton,this.groupLabelEl,e.showChevron),fh(this.groupContentEl,this.groupExpandButton,this.groupLabelEl,this.groupCountEl,e)}setTreeCell(e){if(this.clearInlineEditor(),this.clearRenderer(),this.textEl.hidden=!0,this.textEl.textContent=``,!e.visible){this.clearGroupCell();return}this.groupContentEl||(this.groupContentEl=document.createElement(`div`),this.groupContentEl.className=th,this.groupLabelEl=document.createElement(`span`),this.groupLabelEl.className=nh,this.groupCountEl=document.createElement(`span`),this.groupCountEl.className=rh,this.groupCountEl.hidden=!0,this.groupContentEl.append(this.groupLabelEl,this.groupCountEl),this.element.append(this.groupContentEl)),this.groupExpandButton=Oh(this.groupContentEl,this.groupExpandButton,this.groupLabelEl,e.showChevron,e.indentLevel),this.treeHierarchyActionsEl=Dh(this.groupContentEl,this.groupExpandButton,this.groupLabelEl,e,this.treeHierarchyActionsEl)}clearGroupCell(){this.groupContentEl&&(this.groupContentEl.remove(),this.groupContentEl=null,this.groupExpandButton=null,this.groupLabelEl=null,this.groupCountEl=null,this.treeHierarchyActionsEl=null)}getGroupExpandButton(){return this.groupExpandButton}setRendererResult(e){this.prepareForRenderer(),x_.apply(this.rendererMount,e)}prepareForRenderer(){this.clearInlineEditor(),this.clearRenderer(),this.textEl.hidden=!0,this.textEl.textContent=``,this.rendererMount.hidden=!1,this.usingRenderer=!0}prepareForRendererPatch(){this.clearInlineEditor(),this.textEl.hidden=!0,this.textEl.textContent=``,this.rendererMount.hidden=!1,this.usingRenderer=!0}canPatchVueRenderer(e){return this.usingRenderer&&this.vueRendererActive&&this.vueRendererColId===e}markVueRendererMounted(e){this.vueRendererActive=!0,this.vueRendererColId=e,this.rendererPlaceholderActive=!1}setRendererPlaceholder(e){this.clearInlineEditor(),this.clearRenderer(),this.textEl.hidden=!1,this.textEl.textContent!==e&&(this.textEl.textContent=e),this.rendererMount.hidden=!0,this.usingRenderer=!1,this.rendererPlaceholderActive=!0}isRendererPlaceholderActive(){return this.rendererPlaceholderActive}prepareForInlineEditor(e){this.clearSelectionCheckbox(),this.clearRowExpandButton(),this.clearGroupCell(),this.clearRenderer(),this.textEl.hidden=!0,this.textEl.textContent=``,this.inlineEditorMount.hidden=!1,this.usingInlineEditor=!0,this.element.classList.add(`mg-cell--inline-editor`),this.setInlineEditorDisabledVisual(e)}prepareForInlineEditorPatch(e){this.clearSelectionCheckbox(),this.clearRowExpandButton(),this.clearGroupCell(),this.clearRenderer(),this.textEl.hidden=!0,this.textEl.textContent=``,this.inlineEditorMount.hidden=!1,this.usingInlineEditor=!0,this.element.classList.add(`mg-cell--inline-editor`),this.setInlineEditorDisabledVisual(e)}canPatchVueInlineEditor(e){return this.usingInlineEditor&&this.vueInlineEditorActive&&this.vueInlineEditorColId===e}markVueInlineEditorMounted(e){this.vueInlineEditorActive=!0,this.vueInlineEditorColId=e}clearInlineEditor(){(this.usingInlineEditor||this.inlineEditorMount.childNodes.length>0)&&this.onUnmountEditor?.(this.inlineEditorMount),this.inlineEditorMount.replaceChildren(),this.inlineEditorMount.hidden=!0,this.usingInlineEditor=!1,this.vueInlineEditorActive=!1,this.vueInlineEditorColId=void 0,this.element.classList.remove(`mg-cell--inline-editor`,`mg-cell--inline-disabled`,`mg-cell--committing`)}getInlineEditorMountEl(){return this.inlineEditorMount}setInlineEditorDisabledVisual(e){this.element.classList.toggle(`mg-cell--inline-disabled`,e),this.setCellDisabled(e)}setInlineEditorCommitting(e){this.setCommittingVisual(e)}setCommittingVisual(e){this.element.classList.toggle(`mg-cell--committing`,e)}setIndexLoadingVisual(e){Nv(this.element,e)}clearRenderer(){(this.usingRenderer||this.rendererMount.childNodes.length>0)&&this.onUnmountRenderer?.(this.rendererMount),x_.clear(this.rendererMount),this.rendererMount.hidden=!0,this.usingRenderer=!1,this.vueRendererActive=!1,this.vueRendererColId=void 0,this.rendererPlaceholderActive=!1}hasRenderer(){return this.usingRenderer}getRendererMountEl(){return this.rendererMount}setColId(e){this.element.dataset.colId=e}setFocused(e){this.element.classList.toggle(`mg-cell--focused`,e)}setRangeSelected(e){this.element.classList.toggle(qo,e)}setRangeAnchor(e){this.element.classList.toggle(Jo,e)}setIndexRangeHighlight(e){this.element.classList.toggle(ms,e)}playRangeCopyFlash(){this.element.classList.remove(rs),this.element.offsetWidth,this.element.classList.add(rs);let e=()=>{this.element.classList.remove(rs),this.element.removeEventListener(`animationend`,e)};this.element.addEventListener(`animationend`,e)}playRangePasteFlash(e){this.element.classList.remove(as,os),this.element.offsetWidth,this.element.classList.add(e?os:as);let t=()=>{this.element.classList.remove(as,os),this.element.removeEventListener(`animationend`,t)};this.element.addEventListener(`animationend`,t)}setCellEditableIndicator(e){if(!e){this.clearCellEditableIndicator();return}this.editableIndicatorEl||(this.editableIndicatorEl=document.createElement(`span`),this.editableIndicatorEl.className=Tt,this.editableIndicatorEl.setAttribute(`aria-hidden`,`true`),this.editableIndicatorEl.append(Lm()),this.element.prepend(this.editableIndicatorEl)),this.element.classList.add(wt)}clearCellEditableIndicator(){this.editableIndicatorEl?.remove(),this.editableIndicatorEl=null,this.element.classList.remove(wt)}setCellDisabledIndicator(e){if(!e){this.clearCellDisabledIndicator();return}this.disabledIndicatorEl||(this.disabledIndicatorEl=document.createElement(`span`),this.disabledIndicatorEl.className=pt,this.disabledIndicatorEl.setAttribute(`aria-hidden`,`true`),this.disabledIndicatorEl.append(zm()),this.element.prepend(this.disabledIndicatorEl)),this.element.classList.add(ft)}clearCellDisabledIndicator(){this.disabledIndicatorEl?.remove(),this.disabledIndicatorEl=null,this.element.classList.remove(ft)}setCellEditableRole(e){this.element.classList.toggle(Ct,e)}setCellDisabled(e){if(this.element.classList.toggle(ut,e),e){this.element.setAttribute(`aria-disabled`,`true`),this.element.setAttribute(dt,`true`);return}this.element.removeAttribute(`aria-disabled`),this.element.removeAttribute(dt)}setCellStyle(e){let t=this.lastCellStyle,n=e.backgroundColor,r=e.color;t.backgroundColor!==n&&(n===void 0||n===``?this.element.style.removeProperty(`background-color`):this.element.style.backgroundColor=n),t.color!==r&&(r===void 0||r===``?this.element.style.removeProperty(`color`):this.element.style.color=r),this.lastCellStyle={backgroundColor:n,color:r},Nt({backgroundColor:n})?this.element.setAttribute(St,`true`):this.element.removeAttribute(St)}setCommentIndicator(e){ey(this.element,e)}setRowDragHandle(e){if(e){this.rowDragHandle||(this.rowDragHandle=document.createElement(`div`),this.rowDragHandle.className=ba,this.rowDragHandle.setAttribute(`role`,`button`),this.rowDragHandle.setAttribute(`aria-label`,`拖拽行`),this.rowDragHandle.append(fm()),this.element.prepend(this.rowDragHandle)),this.element.classList.add(`mg-cell--row-draggable`);return}this.clearRowDragHandle()}clearRowDragHandle(){this.rowDragHandle?.remove(),this.rowDragHandle=null,this.element.classList.remove(`mg-cell--row-draggable`)}setRowResizeHandle(e){if(e){this.rowResizeHandle||(this.rowResizeHandle=document.createElement(`div`),this.rowResizeHandle.className=La,this.rowResizeHandle.setAttribute(`role`,`separator`),this.rowResizeHandle.setAttribute(`aria-orientation`,`horizontal`),this.element.append(this.rowResizeHandle)),this.element.classList.add(`mg-cell--row-resizable`);return}this.clearRowResizeHandle()}clearRowResizeHandle(){this.rowResizeHandle?.remove(),this.rowResizeHandle=null,this.element.classList.remove(`mg-cell--row-resizable`)}getColId(){return this.element.dataset.colId}getElement(){return this.element}destroy(){this.clearSelectionCheckbox(),this.clearRowExpandButton(),this.clearCellEditableIndicator(),this.clearRowDragHandle(),this.clearRowResizeHandle(),this.clearInlineEditor(),this.clearRenderer(),this.element.remove()}};function ny(e){let t=document.createElement(`div`);return t.className=`mg-row__lane mg-row__lane--${e}`,{element:t,cells:[],cellCtrls:[],indices:[],mountedColIds:[],changedSlotIndices:new Set}}function ry(e){return e.left.indices.length>0||e.center.indices.length>0||e.right.indices.length>0}function iy(e,t){e.left.element.style.width=`${t.getLeftFixedWidth()}px`,e.center.element.style.width=`${t.getCenterTotalWidth()}px`,e.right.element.style.width=`${t.getRightFixedWidth()}px`}function ay(e,n,r,i,a,o,s){let c=i.colId;s!==c&&(o.changedSlotIndices.add(a),s&&r.invalidate(),n.setFocused(!1),n.getElement().classList.remove(`mg-cell--invalid`),n.getElement().removeAttribute(`title`)),e.applyCellSpanLayout(n,i),n.setColId(c),n.getElement().toggleAttribute(`data-auto-height`,i.autoHeight),Gp(n.getElement(),i.align,i.valign,`mg-cell`),n.getElement().classList.toggle(`mg-cell--index`,t.it(i.colId)),n.getElement().classList.toggle(`mg-cell--selection`,t.X(i.colId)),n.getElement().classList.toggle(`mg-cell--expand`,A(i.colId)||i.rowExpand),n.getElement().classList.toggle(`mg-cell--group`,L(i.colId));let l=e.rowNode!=null&&R(e.rowNode)&&(e.isRowDragHandleEnabled?.(i.colId)??!1);t.it(i.colId)?(n.getElement().classList.toggle(`mg-cell--index-focused`,e.indexFocused),n.setIndexRangeHighlight(e.indexColumnRangeHighlighted),n.setRowResizeHandle(e.indexColumnOptions?.enableRowResizer??!1),n.setRowDragHandle(l)):(n.clearRowResizeHandle(),n.setRowDragHandle(i.rowDrag?l:!1))}function oy(e){let t=new Map;for(let n of[`left`,`center`,`right`]){let r=e[n];for(let e=0;e<r.cells.length;e++){let n=r.mountedColIds[e];n&&t.set(n,{cell:r.cells[e],ctrl:r.cellCtrls[e]})}}return t}function sy(e,t){for(let{cell:n}of e.values())t(n.getElement()),n.destroy();e.clear()}function cy(e,t,n,r){if(t.indices=n,t.changedSlotIndices.clear(),!e.columnModel)return;let i=[],a=[],o=[];for(let s=0;s<n.length;s++){let c=n[s],l=c===void 0?void 0:e.columnModel.getColumn(c);if(!l)continue;let u=r.get(l.colId),d,f,p=``;u?(d=u.cell,f=u.ctrl,p=l.colId,r.delete(l.colId)):(d=new ty(t.element,{onUnmountRenderer:e.onUnmountRenderer,onUnmountEditor:e.onUnmountEditor}),f=new Qv),t.element.appendChild(d.getElement()),ay(e.bindDeps,d,f,l,s,t,p),i.push(d),a.push(f),o.push(l.colId)}t.cells=i,t.cellCtrls=a,t.mountedColIds=o}function ly(e,t,n,r){cy(e,e.lanes[t],n,r)}function uy(e,t){return Fv({...e,indices:t})}function dy(e){let t=P_({columnModel:e.columnModel,centerWindow:e.columnWindow,enableCellSpan:e.spanFilter.enableCellSpan,paramsForColumn:t=>w_(e.rowNode,t)}),n=oy(e.laneSyncDeps.lanes);for(let r of[`left`,`center`,`right`])ly(e.laneSyncDeps,r,uy(e.spanFilter,t[r]),n);sy(n,e.laneSyncDeps.cleanupAutoHeightCell)}function fy(e){let t=P_({columnModel:e.columnModel,centerWindow:e.columnWindow,enableCellSpan:!1,paramsForColumn:t=>w_(e.rowNode,t)});return{left:uy(e.spanFilter,t.left),right:uy(e.spanFilter,t.right)}}var py=class{element;lanes;frameService;onUnmountRenderer;onUnmountEditor;inlineEditor;indexColumnOptions;selectionColumnOptions;rowAutoHeightService;isRowDragHandleEnabled;isAsyncMutationLoadingRow;infiniteLoadingRowVisible;enableCellSpan;cellSpanService;getRowByIndex;getRowCount;isRowCoverHighlighted;spannedRowOnly;embedFullWidthRows;getDetailCellRenderer;getMasterRowById;rowExpansionHost;rowGroupingHost;treeTableHost;getCellCommentHost;detailRowAutoHeightService;resolveBusinessRowId;getCellDisableContext;getCellStyleContext;cellRendererDefer;isScrollActive;cellRendererPresentation;fullWidthEmbed=new Uv;autoHeightCleanups=new Map;columnModel=null;columnWindow={firstCol:0,lastCol:-1};rowNode=null;stripe=!1;valueCacheVersion=0;selected=!1;selectionIndeterminate=!1;indexFocused=!1;indexColumnRangeHighlighted=!1;selectionDisabled=!1;lastRowTop=null;pendingRendererTasks=[];rendererBatchDepth=0;lastCellValueSyncRowId=null;lastCellValueSyncData=null;lastCellValueSyncValueCacheVersion=-1;constructor(e,t={}){this.stripe=t.stripe??!1,this.frameService=t.frameService??null,this.onUnmountRenderer=t.onUnmountRenderer,this.onUnmountEditor=t.onUnmountEditor,this.inlineEditor=t.inlineEditor,this.indexColumnOptions=t.indexColumnOptions,this.selectionColumnOptions=t.selectionColumnOptions,this.rowAutoHeightService=t.rowAutoHeightService??null,this.isRowDragHandleEnabled=t.isRowDragHandleEnabled,this.isAsyncMutationLoadingRow=t.isAsyncMutationLoadingRow,this.infiniteLoadingRowVisible=t.infiniteLoadingRowVisible??!0,this.enableCellSpan=t.enableCellSpan??!1,this.cellSpanService=t.cellSpanService??null,this.getRowByIndex=t.getRowByIndex,this.getRowCount=t.getRowCount,this.isRowCoverHighlighted=t.isRowCoverHighlighted,this.spannedRowOnly=t.spannedRowOnly??!1,this.embedFullWidthRows=t.embedFullWidthRows??!1,this.getDetailCellRenderer=t.getDetailCellRenderer,this.getMasterRowById=t.getMasterRowById,this.rowExpansionHost=t.rowExpansionHost,this.rowGroupingHost=t.rowGroupingHost,this.treeTableHost=t.treeTableHost,this.getCellCommentHost=t.getCellCommentHost,this.detailRowAutoHeightService=t.detailRowAutoHeightService??null,this.resolveBusinessRowId=t.resolveBusinessRowId,this.getCellDisableContext=t.getCellDisableContext,this.getCellStyleContext=t.getCellStyleContext,this.cellRendererDefer=t.cellRendererDefer??`always`,this.isScrollActive=t.isScrollActive,this.cellRendererPresentation=t.cellRendererPresentation??`deferred`,this.element=document.createElement(`div`),this.element.className=`mg-row`,this.spannedRowOnly&&this.element.classList.add(`mg-row--spanned`),this.syncTopPositioningClass(),this.lanes={left:ny(`left`),center:ny(`center`),right:ny(`right`)},this.element.append(this.lanes.left.element,this.lanes.center.element,this.lanes.right.element),e.appendChild(this.element)}setSelected(e,t=!1){this.selected=e,this.selectionIndeterminate=t,this.element.classList.toggle(`mg-row--selected`,e),this.syncSelectionColumnCheckbox(),this.syncRowSpanHighlights()}setSelectionDisabled(e){this.selectionDisabled=e,this.syncSelectionColumnCheckbox()}setIndexFocused(e){this.indexFocused=e,this.element.classList.toggle(`mg-row--index-focused`,e),this.syncIndexFocusedVisual(),this.syncRowSpanHighlights()}setIndexColumnRangeHighlight(e){this.indexColumnRangeHighlighted!==e&&(this.indexColumnRangeHighlighted=e,this.syncIndexColumnRangeHighlightVisual())}setFocusedColId(e){for(let t of Object.values(this.lanes))for(let n of t.cells){let t=n.getColId();n.setFocused(e!==null&&t===e)}}setCellRangeSelection(e,t,n){for(let r of Object.values(this.lanes))for(let i of r.cells){let r=i.getColId()??``,a=i.getElement(),o=Number(a.dataset.rowSpan??1),s=o>1&&this.rowNode&&this.getRowByIndex&&n?V_({head:this.rowNode,rowSpan:o,colId:r,getRowByIndex:this.getRowByIndex,isCellSelected:n}):e(r);i.setRangeSelected(s),i.setRangeAnchor(t!==null&&r===t)}}flashCellRangeSelection(e,t){for(let n of Object.values(this.lanes))for(let r of n.cells){let n=r.getColId()??``,i=r.getElement(),a=Number(i.dataset.rowSpan??1);(a>1&&this.rowNode&&this.getRowByIndex&&t?V_({head:this.rowNode,rowSpan:a,colId:n,getRowByIndex:this.getRowByIndex,isCellSelected:t}):e(n))&&r.playRangeCopyFlash()}}flashCellRangePaste(e){for(let t of Object.values(this.lanes))for(let n of t.cells){let t=n.getColId(),r=e.find(e=>e.colId===t);r&&n.playRangePasteFlash(!r.applied)}}setRowTop(e){this.lastRowTop=e,this.applyRowTop(e)}syncRowLayout(e){if(this.rowNode=e,this.spannedRowOnly){this.syncSpannedRowHeight();return}this.syncRowHeight(e.rowHeight),this.syncInfiniteLoadingVisual()}syncRowExpansionDisplayChrome(e,t){this.syncExpandedMasterClass(),!(e.length===0||!this.rowNode)&&this.refreshCells({...t,colIds:[...e],force:!0})}setIndexLoadingVisual(e){for(let t of Object.values(this.lanes))for(let n of t.cells)n.getElement().classList.contains(`mg-cell--index`)&&n.setIndexLoadingVisual(e);e||(this.syncIndexFocusedVisual(),this.syncIndexColumnRangeHighlightVisual())}setData(e,t,n,r=0,i=!1,a){if(this.rowNode=e,this.columnModel=t,this.columnWindow=n,this.valueCacheVersion=r,this.element.dataset.rowId=e.id,this.spannedRowOnly?this.syncSpannedRowHeight():this.syncRowHeight(e.rowHeight),this.element.style.width=`${t.getTotalWidth()}px`,this.syncLaneWidths(),this.embedFullWidthRows&&I(e)){this.fullWidthEmbed.activate(e,i,this.buildFullWidthEmbedDeps());return}if(this.fullWidthEmbed.active&&this.fullWidthEmbed.deactivate(this.buildFullWidthEmbedDeps()),this.syncCells(),this.syncPinnedSpanRowClasses(),this.syncIndexLoadingVisual(),this.syncInfiniteLoadingVisual(),this.syncStripeClass(),this.syncLastRowClass(i),this.syncExpandedMasterClass(),this.syncGroupRowClasses(),a?.columnStructureChanged===!0||this.lastCellValueSyncRowId!==e.id||this.lastCellValueSyncData!==e.data||this.lastCellValueSyncValueCacheVersion!==r){let t=a?.overlayEditingTargets;a?.columnStructureChanged?this.syncCellValues(`structure-changed`,t):this.syncCellValues(`all`,t),this.lastCellValueSyncRowId=e.id,this.lastCellValueSyncData=e.data,this.lastCellValueSyncValueCacheVersion=r}this.syncAutoHeightCells(),this.syncCellCommentIndicators()}setEnableCellSpan(e){this.enableCellSpan!==e&&(this.enableCellSpan=e,this.syncTopPositioningClass(),this.lastRowTop!==null&&this.applyRowTop(this.lastRowTop))}setCellSpanService(e){this.cellSpanService=e}setRowSpanAccessors(e){this.getRowByIndex=e.getRowByIndex,this.getRowCount=e.getRowCount}refreshCells(e){if(!this.rowNode)return 0;if(this.columnModel=e.columnModel,this.columnWindow=e.columnWindow,this.valueCacheVersion=e.valueCacheVersion,e.inlineEditor&&(this.inlineEditor=e.inlineEditor),this.syncLaneWidths(),this.fullWidthEmbed.active){let e=this.buildFullWidthEmbedDeps();return this.fullWidthEmbed.refreshPinnedLanes(e),this.fullWidthEmbed.refreshContent(e),1}this.enableCellSpan&&this.syncCells();let t=e.indexColumnOptions??this.indexColumnOptions,n=e.selectionColumnOptions??this.selectionColumnOptions,r=e.colIds?new Set(e.colIds):null;if(!ry(this.lanes)||!this.columnModel)return 0;let i=e.force??!1,a=e.newData??!1,o=e.overlayEditingTargets,s=this.withRendererBatch(()=>{let e=0;for(let s of[`left`,`center`,`right`]){let c=this.lanes[s];for(let l=0;l<c.indices.length;l++)this.refreshCellAtLaneIndex(s,l,r,i,a,t,n,o)&&e++}return e});return this.syncAutoHeightCells(r,i),this.syncCellCommentIndicators(r),s}promoteRendererPlaceholders(){return!this.rowNode||!this.columnModel||this.fullWidthEmbed.active?0:this.withRendererBatch(()=>{let e=0;for(let t of[`left`,`center`,`right`]){let n=this.lanes[t];for(let r=0;r<n.indices.length;r++)this.promoteRendererPlaceholderAtLaneIndex(t,r)&&e++}return e})}syncCellCommentIndicators(e=null){let t=this.getCellCommentHost?.();if(!t?.active()||!this.rowNode||!this.columnModel||this.fullWidthEmbed.active)return;let n=this.rowNode,r=N(n.rowKind);for(let i of[`left`,`center`,`right`]){let a=this.lanes[i];for(let i=0;i<a.indices.length;i++){let o=a.indices[i],s=o===void 0?void 0:this.columnModel.getColumn(o),c=a.cells[i];if(!s||!c)continue;let{colId:l}=s;if(e&&!e.has(l))continue;if(!Ro(l,r,n.id)){c.setCommentIndicator(`none`);continue}let u=t.hasComment(n.id,l),d=t.canCreateComment(n.id,l);c.setCommentIndicator(u?`filled`:d?`empty`:`none`)}}}getElement(){return this.element}destroy(){this.fullWidthEmbed.deactivate(this.buildFullWidthEmbedDeps()),this.clearAutoHeightCleanups();for(let e of Object.values(this.lanes)){for(let t of e.cells)t.destroy();e.cells.length=0,e.cellCtrls.length=0}this.lastCellValueSyncRowId=null,this.lastCellValueSyncData=null,this.lastCellValueSyncValueCacheVersion=-1,this.element.remove()}applyRowTop(e){if(Xa(this.enableCellSpan)){this.element.style.top=`${e}px`,this.element.style.transform=``;return}this.element.style.top=`0px`,this.element.style.transform=`translateY(${e}px)`}syncTopPositioningClass(){this.element.classList.toggle(qa,Xa(this.enableCellSpan))}syncIndexLoadingVisual(){this.rowNode&&this.setIndexLoadingVisual(this.isAsyncMutationLoadingRow?.(this.rowNode.id)??!1)}syncInfiniteLoadingVisual(){if(!this.rowNode||!this.infiniteLoadingRowVisible){this.element.classList.remove(`mg-row--infinite-loading`,`mg-row--infinite-stub`);return}let e=this.rowNode.__infiniteBlockState,t=e==null||e===`loaded`,n=e===`loading`,r=!t;this.element.classList.toggle(`mg-row--infinite-loading`,n),this.element.classList.toggle(`mg-row--infinite-stub`,r)}syncRowHeight(e){let t=`${e}px`;this.element.style.height=t,this.element.style.setProperty(`--mg-row-height`,t)}syncSpannedRowHeight(){this.element.style.height=`0px`,this.element.style.setProperty(`--mg-row-height`,`0px`)}syncPinnedSpanRowClasses(){Bv({spannedRowOnly:this.spannedRowOnly,enableCellSpan:this.enableCellSpan,rowNode:this.rowNode,columnModel:this.columnModel,cellSpanService:this.cellSpanService},this.element)}syncLaneWidths(){this.columnModel&&iy(this.lanes,this.columnModel)}syncColumnLayouts(){if(!this.columnModel)return;if(this.element.style.width=`${this.columnModel.getTotalWidth()}px`,this.syncLaneWidths(),this.fullWidthEmbed.active){this.fullWidthEmbed.refreshPinnedLanes(this.buildFullWidthEmbedDeps());return}let e=this.buildCellSpanLayoutContext();for(let t of[`left`,`center`,`right`]){let n=this.lanes[t];for(let t=0;t<n.indices.length;t++){let r=n.indices[t],i=r===void 0?void 0:this.columnModel.getColumn(r),a=n.cells[t];!i||!a||Iv(e,a,i)}}}syncLanesWithCrossLanePool(e){let t=this.buildLaneSyncDeps(),n=oy(t.lanes);for(let r of[`left`,`center`,`right`])ly(t,r,e[r],n);sy(n,t.cleanupAutoHeightCell)}syncCells(){!this.columnModel||!this.rowNode||dy({rowNode:this.rowNode,columnModel:this.columnModel,columnWindow:this.columnWindow,spanFilter:this.buildSpanFilterParams(),laneSyncDeps:this.buildLaneSyncDeps()})}buildLaneSyncDeps(){return{lanes:this.lanes,columnModel:this.columnModel,bindDeps:this.buildBindCellDeps(),onUnmountRenderer:this.onUnmountRenderer,onUnmountEditor:this.onUnmountEditor,cleanupAutoHeightCell:e=>this.cleanupAutoHeightCell(e)}}buildBindCellDeps(){let e=this.buildCellSpanLayoutContext();return{rowNode:this.rowNode,indexFocused:this.indexFocused,indexColumnRangeHighlighted:this.indexColumnRangeHighlighted,indexColumnOptions:this.indexColumnOptions,isRowDragHandleEnabled:this.isRowDragHandleEnabled,applyCellSpanLayout:(t,n)=>Iv(e,t,n)}}buildCellSpanLayoutContext(){return{enableCellSpan:this.enableCellSpan,rowNode:this.rowNode,columnModel:this.columnModel,cellSpanService:this.cellSpanService,getRowByIndex:this.getRowByIndex,getRowCount:this.getRowCount,applyRowSpanCoverHighlight:(e,t,n)=>Rv(this.buildRowSpanHighlightContext(),e,t,n)}}buildRowSpanHighlightContext(){return{getRowByIndex:this.getRowByIndex,isRowCoverHighlighted:this.isRowCoverHighlighted,selected:this.selected,indexFocused:this.indexFocused}}buildSpanFilterParams(){return{enableCellSpan:this.enableCellSpan,spannedRowOnly:this.spannedRowOnly,rowNode:this.rowNode,columnModel:this.columnModel,cellSpanService:this.cellSpanService,getRowByIndex:this.getRowByIndex,getRowCount:this.getRowCount}}buildFullWidthEmbedDeps(){return{rowElement:this.element,lanes:this.lanes,rowNode:this.rowNode,columnModel:this.columnModel,frameService:this.frameService,onUnmountRenderer:this.onUnmountRenderer,getDetailCellRenderer:this.getDetailCellRenderer,getMasterRowById:this.getMasterRowById,detailRowAutoHeightService:this.detailRowAutoHeightService,syncEmbedLaneCells:(e,t)=>this.syncLanesWithCrossLanePool({left:e,center:[],right:t}),buildEmbedPinnedLaneIndices:()=>fy({columnModel:this.columnModel,columnWindow:this.columnWindow,rowNode:this.rowNode,spanFilter:this.buildSpanFilterParams()}),syncStripeClass:()=>this.syncStripeClass(),syncLastRowClass:e=>this.syncLastRowClass(e)}}syncRowSpanHighlights(){zv({...this.buildRowSpanHighlightContext(),enableCellSpan:this.enableCellSpan,rowNode:this.rowNode},Object.values(this.lanes))}syncIndexFocusedVisual(){if(this.columnModel)for(let e of[`left`,`center`,`right`]){let n=this.lanes[e];for(let e=0;e<n.indices.length;e++){let r=n.indices[e],i=r===void 0?void 0:this.columnModel.getColumn(r),a=n.cells[e];!i||!a||!t.it(i.colId)||a.getElement().classList.toggle(`mg-cell--index-focused`,this.indexFocused)}}}syncIndexColumnRangeHighlightVisual(){if(this.columnModel)for(let e of[`left`,`center`,`right`]){let n=this.lanes[e];for(let e=0;e<n.indices.length;e++){let r=n.indices[e],i=r===void 0?void 0:this.columnModel.getColumn(r),a=n.cells[e];!i||!a||!t.it(i.colId)||a.setIndexRangeHighlight(this.indexColumnRangeHighlighted)}}}refreshCellAtLaneIndex(e,t,n,r,i,a,o,s){let c=this.lanes[e],l=c.indices[t],u=l===void 0?void 0:this.columnModel.getColumn(l),d=c.cells[t],f=c.cellCtrls[t];return!u||!d||!f||!this.rowNode||n&&!n.has(u.colId)?!1:f.refreshCell(this.rowNode,u,d,this.valueCacheVersion,{force:r,newData:i,scheduleRenderer:e=>this.scheduleRendererTask(e),scheduleInlineEditor:e=>this.scheduleInlineEditorTask(e),inlineEditor:this.inlineEditor,indexColumnOptions:a??this.indexColumnOptions,selectionColumnOptions:o??this.selectionColumnOptions,selectionChecked:this.selected,selectionDisabled:this.selectionDisabled,selectionIndeterminate:this.selectionIndeterminate,rowExpansionHost:this.rowExpansionHost,rowGroupingHost:this.rowGroupingHost,treeTableHost:this.treeTableHost,resolveBusinessRowId:this.resolveBusinessRowId,getCellDisableContext:this.getCellDisableContext,getCellStyleContext:this.getCellStyleContext,cellRendererDefer:this.cellRendererDefer,cellRendererPresentation:this.cellRendererPresentation,scrollActive:this.isScrollActive?.()??!1,overlayEditingTargets:s,getCellStructuralContext:()=>({rowDragHandleEnabled:this.isRowDragHandleEnabled,indexRowResizerEnabled:this.indexColumnOptions?.enableRowResizer})})}promoteRendererPlaceholderAtLaneIndex(e,t){let n=this.lanes[e],r=n.indices[t],i=r===void 0?void 0:this.columnModel.getColumn(r),a=n.cells[t],o=n.cellCtrls[t];return!i||!a||!o||!this.rowNode||!o.hasPendingVueRenderer()?!1:o.promoteVueRenderer(this.rowNode,a,{scheduleRenderer:e=>this.scheduleRendererTask(e),cellRendererDefer:this.cellRendererDefer,cellRendererPresentation:this.cellRendererPresentation})}syncGroupRowClasses(){this.rowNode&&(this.element.classList.toggle(he,this.rowNode.rowKind===`GROUP_HEADER`),this.element.classList.toggle(ge,this.rowNode.rowKind===`GROUP_FOOTER`))}syncStripeClass(){this.rowNode&&this.element.classList.toggle(`mg-row--stripe`,this.stripe&&this.rowNode.rowIndex%2==1)}syncLastRowClass(e){this.element.classList.toggle(`mg-row--last`,e)}setBeforeLoadMoreRow(e){this.element.classList.toggle(`mg-row--before-load-more`,e)}syncExpandedMasterClass(){if(!this.rowNode||I(this.rowNode)){this.element.classList.remove(`mg-row--expanded-master`);return}let e=this.rowExpansionHost?.active()===!0&&this.rowExpansionHost.isExpanded(this.rowNode.id);this.element.classList.toggle(`mg-row--expanded-master`,e)}syncSelectionColumnCheckbox(){if(!(!this.columnModel||!this.rowNode||this.fullWidthEmbed.active))for(let e of[`left`,`center`,`right`]){let n=this.lanes[e];for(let e=0;e<n.indices.length;e++){let r=n.indices[e],i=r===void 0?void 0:this.columnModel.getColumn(r),a=n.cells[e];if(!i||!a||!t.X(i.colId))continue;if(Ue(this.rowNode)){a.clearSelectionCheckbox();continue}let o=this.selectionColumnOptions?Mp(this.rowNode.rowIndex,this.selectionColumnOptions.selectionColumn):`选择第 ${this.rowNode.rowIndex+1} 行`;a.setSelectionCheckbox({checked:this.selected,disabled:this.selectionDisabled,indeterminate:this.selectionIndeterminate,ariaLabel:o})}}}syncCellValues(e=`all`,t){return!this.rowNode||!this.columnModel||!ry(this.lanes)?0:this.withRendererBatch(()=>{let n=0;for(let r of[`left`,`center`,`right`]){let i=this.lanes[r];for(let a=0;a<i.indices.length;a++){let o=e===`all`||i.changedSlotIndices.has(a);this.refreshCellAtLaneIndex(r,a,null,o,!1,this.indexColumnOptions,this.selectionColumnOptions,t)&&n++}}return n})}syncAutoHeightCells(e=null,t=!1){if(!(!this.rowAutoHeightService||!this.rowNode||!this.columnModel))for(let n of[`left`,`center`,`right`]){let r=this.lanes[n];for(let n=0;n<r.indices.length;n++){let i=r.indices[n],a=i===void 0?void 0:this.columnModel.getColumn(i),o=r.cells[n];if(!a||!o)continue;let s=o.getElement(),{colId:c}=a;if(e&&!e.has(c))continue;if(!a.autoHeight){o.getElement().removeAttribute(`data-auto-height`),this.cleanupAutoHeightCell(s);continue}if(this.autoHeightCleanups.has(s)&&!t)continue;t&&this.cleanupAutoHeightCell(s);let l=this.rowNode.id;this.scheduleRendererTask(()=>{if(!this.rowNode||this.rowNode.id!==l)return;let e=this.rowAutoHeightService.setupCellAutoHeight({rowId:l,colId:c,cellEl:s});e&&this.autoHeightCleanups.set(s,e)})}}}cleanupAutoHeightCell(e){let t=this.autoHeightCleanups.get(e);t&&(t(),this.autoHeightCleanups.delete(e))}clearAutoHeightCleanups(){for(let e of this.autoHeightCleanups.values())e();this.autoHeightCleanups.clear()}withRendererBatch(e){this.rendererBatchDepth++;try{return e()}finally{this.rendererBatchDepth--,this.flushRowRendererBatch()}}scheduleRendererTask(e){if(this.rendererBatchDepth>0){this.pendingRendererTasks.push(e);return}this.enqueueRendererTask(e)}flushRowRendererBatch(){if(this.rendererBatchDepth>0||this.pendingRendererTasks.length===0)return;let e=this.pendingRendererTasks.splice(0);this.enqueueRendererTask(()=>{for(let t of e)t()})}enqueueRendererTask(e){let t=this.rowNode?.rowIndex??0;if(this.frameService){this.frameService.createTask(e,t,`f1`);return}e()}scheduleInlineEditorTask(e){let t=this.rowNode?.rowIndex??0;if(this.frameService){this.frameService.createTask(e,t,`p2`);return}e()}},my=class{container;rowModel;columnModel;stripe;rowPool=new Pv;frameService;onUnmountRenderer;onUnmountEditor;inlineCellEditor;indexColumnOptions;selectionColumnOptions;rowAutoHeightService;isRowDragHandleEnabled;enableCellSpan;cellSpanService;valueCacheVersion=0;selectedRowIds=new Set;indexFocusedRowIds=new Set;focusedCell=null;cellRangeIsSelected=null;cellRangeAnchor=null;columnWindow={firstCol:0,lastCol:-1};activeHeadIds=new Set;compressedScroll=!1;scrollTop=0;resolveOverlayEditingTargets=()=>[];constructor(e){this.container=e.container,this.rowModel=e.rowModel,this.columnModel=e.columnModel,this.stripe=e.stripe??!1,this.frameService=e.frameService??null,this.onUnmountRenderer=e.onUnmountRenderer,this.onUnmountEditor=e.onUnmountEditor,this.indexColumnOptions=e.indexColumnOptions,this.selectionColumnOptions=e.selectionColumnOptions,this.rowAutoHeightService=e.rowAutoHeightService??null,this.isRowDragHandleEnabled=e.isRowDragHandleEnabled,this.enableCellSpan=e.enableCellSpan??!1,this.cellSpanService=e.cellSpanService??null}setEnableCellSpan(e){this.enableCellSpan=e,e||this.clear()}setCellSpanService(e){this.cellSpanService=e}setRowAutoHeightService(e){this.rowAutoHeightService=e}setInlineCellEditorContext(e){this.inlineCellEditor=e}setOverlayEditingTargetsResolver(e){this.resolveOverlayEditingTargets=e}setCompressedScroll(e){this.compressedScroll=e}setValueCacheVersion(e){this.valueCacheVersion=e}refreshSelection(e){this.selectedRowIds=new Set(e);for(let t of this.rowPool.getActiveIds())this.rowPool.get(t)?.setSelected?.(e.has(t))}refreshIndexFocus(e){this.indexFocusedRowIds=new Set(e);for(let t of this.rowPool.getActiveIds())this.rowPool.get(t)?.setIndexFocused?.(e.has(t))}setFocusedCell(e){this.focusedCell=e,this.refreshFocus()}refreshFocus(){let e=this.focusedCell;for(let t of this.rowPool.getActiveIds())this.rowPool.get(t)?.setFocusedColId?.(e?.rowId===t?e.colId:null)}setCellRangeVisualState(e,t){this.cellRangeIsSelected=e,this.cellRangeAnchor=t,this.refreshCellRangeSelection()}refreshCellRangeSelection(){let e=this.cellRangeIsSelected,t=this.cellRangeAnchor;for(let n of this.rowPool.getActiveIds()){let r=this.findRowIndexById(n),i=this.rowPool.get(n);!i?.setCellRangeSelection||r<0||i.setCellRangeSelection(e?t=>e(r,t):()=>!1,t?.rowIndex===r?t.colId:null,e??void 0)}}playCellRangeCopyFlash(){let e=this.cellRangeIsSelected;if(e)for(let t of this.rowPool.getActiveIds()){let n=this.findRowIndexById(t),r=this.rowPool.get(t);!r?.flashCellRangeSelection||n<0||r.flashCellRangeSelection(t=>e(n,t),e)}}playCellRangePasteFlash(e){if(e.length===0)return;let t=new Map;for(let n of e){let e=t.get(n.rowIndex);e?e.push(n):t.set(n.rowIndex,[n])}for(let e of this.rowPool.getActiveIds()){let n=this.findRowIndexById(e),r=this.rowPool.get(e),i=t.get(n);!r?.flashCellRangePaste||!i?.length||n<0||r.flashCellRangePaste(i)}}syncColumnLayouts(){for(let e of this.rowPool.getActiveIds())this.rowPool.get(e)?.syncColumnLayouts?.()}refreshVisibleColumnStructure(e){if(!this.enableCellSpan)return;this.columnWindow=e;let t={columnStructureChanged:!0};for(let e of this.activeHeadIds)this.updateHeadRow(e,t)}migrateRowId(e,t){if(e===t)return;this.rowPool.migrateId(e,t);let n=this.rowPool.get(t);n&&(n.getElement().dataset.rowId=t),this.selectedRowIds.has(e)&&(this.selectedRowIds.delete(e),this.selectedRowIds.add(t)),this.indexFocusedRowIds.has(e)&&(this.indexFocusedRowIds.delete(e),this.indexFocusedRowIds.add(t)),this.focusedCell?.rowId===e&&(this.focusedCell={rowId:t,colId:this.focusedCell.colId}),this.activeHeadIds.has(e)&&(this.activeHeadIds.delete(e),this.activeHeadIds.add(t))}refreshRows(e){let t=e.rowIds?new Set(e.rowIds):null,n=0;for(let r of this.rowPool.getActiveIds()){if(t&&!this.includesRefreshTarget(r,t))continue;let i=this.rowPool.get(r);i?.refreshCells&&(n+=i.refreshCells({columnModel:this.columnModel,columnWindow:this.columnWindow,valueCacheVersion:this.valueCacheVersion,colIds:e.colIds,force:e.force,newData:e.newData,indexColumnOptions:this.indexColumnOptions,selectionColumnOptions:this.selectionColumnOptions,inlineEditor:this.inlineCellEditor,overlayEditingTargets:this.resolveOverlayEditingTargets()}))}return n}syncVisibleRowLayouts(e){let t=e?new Set(e):null;for(let e of this.rowPool.getActiveIds()){if(t&&!this.includesRefreshTarget(e,t))continue;let n=this.findRowNodeById(e);if(!n)continue;let r=this.rowPool.get(e);r?.syncRowLayout?.(n),r?.setRowTop(this.compressedScroll?n.rowTop-this.scrollTop:n.rowTop)}}redraw(e,t,n,r=!1){if(!this.enableCellSpan){this.clear();return}this.scrollTop=e,this.columnWindow=n;let i=this.collectHeadRowIds(t.firstRow,t.lastRow),a=[...this.activeHeadIds].filter(e=>!i.has(e)),o=[...i];for(let e of a)this.frameService&&!this.compressedScroll?this.frameService.addDestroyTask(()=>{this.rowPool.release(e)}):this.rowPool.release(e);for(let e of o)(!this.activeHeadIds.has(e)||r)&&this.updateHeadRow(e,r?{columnStructureChanged:!0}:void 0);this.activeHeadIds=i,this.container.style.display=i.size>0?``:`none`,this.container.parentElement&&this.container.parentElement.appendChild(this.container)}invalidate(){this.frameService&&this.frameService.flushAllFrames(),this.clear()}destroy(){this.clear()}getActiveHeadCount(){return this.rowPool.getActiveCount()}clear(){this.rowPool.clear(),this.activeHeadIds.clear(),this.container.style.display=`none`}collectHeadRowIds(e,t){return this.cellSpanService?this.cellSpanService.collectSpannedHeadRowIds(e,t):H_({enableCellSpan:this.enableCellSpan,rowModel:this.rowModel,columns:this.columnModel.getColumns(),firstRow:e,lastRow:t})}updateHeadRow(e,t){let n=this.findRowNodeById(e);if(!n)return;let r=this.rowPool.acquire(e,()=>this.createSpannedRowComp()),i=this.rowModel.getRowCount();r.setData(n,this.columnModel,this.columnWindow,this.valueCacheVersion,i>0&&n.rowIndex===i-1,t),r.setRowTop(this.compressedScroll?n.rowTop-this.scrollTop:n.rowTop),r.setSelected?.(this.selectedRowIds.has(e)),r.setIndexFocused?.(this.indexFocusedRowIds.has(e)),r.setFocusedColId?.(this.focusedCell?.rowId===e?this.focusedCell.colId:null),this.applyCellRangeSelectionToHead(e,n.rowIndex)}applyCellRangeSelectionToHead(e,t){let n=this.rowPool.get(e),r=this.cellRangeIsSelected,i=this.cellRangeAnchor;!n?.setCellRangeSelection||t<0||n.setCellRangeSelection(r?e=>r(t,e):()=>!1,i?.rowIndex===t?i.colId:null,r??void 0)}createSpannedRowComp(){return new py(this.container,{stripe:this.stripe,frameService:this.frameService??void 0,onUnmountRenderer:this.onUnmountRenderer,onUnmountEditor:this.onUnmountEditor,inlineEditor:this.inlineCellEditor,indexColumnOptions:this.indexColumnOptions,selectionColumnOptions:this.selectionColumnOptions,rowAutoHeightService:this.rowAutoHeightService,isRowDragHandleEnabled:this.isRowDragHandleEnabled,enableCellSpan:!0,cellSpanService:this.cellSpanService,getRowByIndex:e=>this.rowModel.getRow(e),getRowCount:()=>this.rowModel.getRowCount(),spannedRowOnly:!0,isRowCoverHighlighted:e=>this.selectedRowIds.has(e)||this.indexFocusedRowIds.has(e)})}includesRefreshTarget(e,t){if(t.has(e))return!0;if(!this.cellSpanService)return!1;for(let n of this.columnModel.getColumns().map(e=>e.colId)){let r=this.cellSpanService.getCellSpan(e,n);if(r&&r.rowIds.some(e=>t.has(e)))return!0}return!1}findRowIndexById(e){for(let t=0;t<this.rowModel.getRowCount();t++)if(this.rowModel.getRow(t)?.id===e)return t;return-1}findRowNodeById(e){for(let t=0;t<this.rowModel.getRowCount();t++){let n=this.rowModel.getRow(t);if(n?.id===e)return n}}},hy=class{element;contentEl;frameService;onUnmountRenderer;detailRowAutoHeightService;detailCellRenderer;rowNode=null;renderParams=null;constructor(e,t={}){this.frameService=t.frameService??null,this.onUnmountRenderer=t.onUnmountRenderer,this.detailRowAutoHeightService=t.detailRowAutoHeightService??null,this.element=document.createElement(`div`),this.element.className=T,this.element.dataset.rowKind=`DETAIL`,this.contentEl=document.createElement(`div`),this.contentEl.className=E,this.element.appendChild(this.contentEl),e.appendChild(this.element)}getElement(){return this.element}setDetailCellRenderer(e){this.detailCellRenderer=e,this.renderParams&&this.renderContent(this.renderParams)}setData(e,t,n,r=!1){this.rowNode=e,this.renderParams=t,this.detailCellRenderer=n??this.detailCellRenderer,this.element.dataset.rowId=e.id,this.element.dataset.masterRowId=t.masterRowId==null?``:String(t.masterRowId),this.element.style.height=`${e.rowHeight}px`,this.element.classList.toggle(D,r),this.renderContent(t)}syncRowLayout(e){this.rowNode=e,this.element.style.height=`${e.rowHeight}px`}syncBodyWidth(e){this.element.style.width=`${e}px`}setRowTop(e){this.element.style.transform=`translateY(${e}px)`}destroy(){this.rowNode&&this.detailRowAutoHeightService?.teardownContentObserver(this.rowNode.id),this.onUnmountRenderer?.(this.contentEl),this.contentEl.replaceChildren(),this.element.remove(),this.rowNode=null,this.renderParams=null}renderContent(e){let t=this.rowNode?.id;Hv(this.contentEl,e,this.detailCellRenderer,{frameService:this.frameService,onUnmountRenderer:this.onUnmountRenderer,rowIndex:this.rowNode?.rowIndex??0,onAfterRender:()=>{t&&this.detailRowAutoHeightService?.setupContentObserver(t,this.contentEl)}})}},gy=class{pool=new Map;acquire(e,t){let n=this.pool.get(e);if(n)return n;let r=t();return this.pool.set(e,r),r}get(e){return this.pool.get(e)}release(e){let t=this.pool.get(e);t&&(t.destroy(),this.pool.delete(e))}clear(){for(let e of this.pool.values())e.destroy();this.pool.clear()}getActiveCount(){return this.pool.size}getActiveIds(){return[...this.pool.keys()]}},_y=class{container;rowModel;columnModel;rowPool=new gy;frameService;onUnmountRenderer;getDetailCellRenderer;getMasterRowById;masterDetail;embedFullWidthRows;detailRowAutoHeightService;pinnedRowIds=new Set;activeDetailIds=new Set;compressedScroll=!1;scrollTop=0;constructor(e){this.container=e.container,this.container.classList.add(w),this.rowModel=e.rowModel,this.columnModel=e.columnModel,this.frameService=e.frameService??null,this.onUnmountRenderer=e.onUnmountRenderer,this.getDetailCellRenderer=e.getDetailCellRenderer,this.getMasterRowById=e.getMasterRowById,this.masterDetail=e.masterDetail??!1,this.embedFullWidthRows=e.embedFullWidthRows??!1,this.detailRowAutoHeightService=e.detailRowAutoHeightService??null,this.container.style.display=`none`}setDetailRowAutoHeightService(e){this.detailRowAutoHeightService=e}setEmbedFullWidthRows(e){this.embedFullWidthRows=e,e&&this.clear()}setMasterDetail(e){this.masterDetail=e,e||this.clear()}setCompressedScroll(e){this.compressedScroll=e}setPinnedRowIds(e){this.pinnedRowIds=new Set(e)}redraw(e,t){if(!this.masterDetail||this.embedFullWidthRows){this.clear();return}this.scrollTop=e;let n=this.collectDetailRowIds(t.firstRow,t.lastRow),r=[...this.activeDetailIds].filter(e=>!n.has(e)),i=[...n];for(let e of r)this.frameService&&!this.compressedScroll?this.frameService.addDestroyTask(()=>{this.rowPool.release(e)}):this.rowPool.release(e);for(let e of i)this.activeDetailIds.has(e)?this.syncDetailRowLayout(e):this.updateDetailRow(e);this.activeDetailIds=n}syncVisibleRowLayouts(e){let t=e?new Set(e):null;for(let e of this.rowPool.getActiveIds())t&&!t.has(e)||this.syncDetailRowLayout(e)}syncColumnLayouts(){let e=this.columnModel.getTotalWidth();for(let t of this.rowPool.getActiveIds())this.rowPool.get(t)?.syncBodyWidth(e)}invalidate(){this.frameService&&this.frameService.flushAllFrames(),this.clear()}destroy(){this.clear()}getActiveDetailCount(){return this.rowPool.getActiveCount()}refreshDetailRowContent(e){let t=this.findRowNodeById(e),n=this.rowPool.get(e);if(!t||!n||!I(t))return;let r=this.buildRendererParams(t);r&&(n.syncBodyWidth(this.columnModel.getTotalWidth()),n.setData(t,r,this.getDetailCellRenderer?.(),this.isLastDisplayRow(e)))}clear(){this.rowPool.clear(),this.activeDetailIds.clear()}collectDetailRowIds(e,t){let n=new Set;if(t>=e)for(let r=e;r<=t;r++){let e=this.rowModel.getRow(r);e&&I(e)&&n.add(e.id)}for(let e of this.pinnedRowIds)F(e)&&n.add(e);return n}updateDetailRow(e){let t=this.findRowNodeById(e);if(!t||!I(t)||!t.masterRowId)return;let n=this.buildRendererParams(t);if(!n)return;let r=this.rowPool.acquire(e,()=>new hy(this.container,{frameService:this.frameService??void 0,onUnmountRenderer:this.onUnmountRenderer,detailRowAutoHeightService:this.detailRowAutoHeightService}));r.syncBodyWidth(this.columnModel.getTotalWidth()),r.setData(t,n,this.getDetailCellRenderer?.(),this.isLastDisplayRow(e)),r.setRowTop(this.compressedScroll?t.rowTop-this.scrollTop:t.rowTop)}syncDetailRowLayout(e){let t=this.findRowNodeById(e),n=this.rowPool.get(e);!t||!n||(n.syncRowLayout(t),n.syncBodyWidth(this.columnModel.getTotalWidth()),n.setRowTop(this.compressedScroll?t.rowTop-this.scrollTop:t.rowTop))}buildRendererParams(e){return Vv(e,e=>this.getMasterRowById?.(e)??this.findRowNodeById(e))}findRowNodeById(e){for(let t=0;t<this.rowModel.getRowCount();t++){let n=this.rowModel.getRow(t);if(n?.id===e)return n}}isLastDisplayRow(e){let t=this.rowModel.getRowCount();return t!==0&&this.rowModel.getRow(t-1)?.id===e}};function vy(e,t){return e.loading===t.loading&&e.hasMore===t.hasMore&&e.size===t.size&&e.labels.loadMore===t.labels.loadMore&&e.labels.loading===t.labels.loading&&e.labels.exhausted===t.labels.exhausted}var yy=class{element;contentEl;onUnmountRenderer;loadMoreRowRenderer;rowNode=null;renderParams=null;layoutTop=NaN;constructor(e,t={}){this.onUnmountRenderer=t.onUnmountRenderer,this.element=document.createElement(`div`),this.element.className=`${T} ${uo}`,this.element.dataset.rowKind=`LOAD_MORE`;let n=document.createElement(`div`);n.className=fo,this.contentEl=document.createElement(`div`),this.contentEl.className=E,n.appendChild(this.contentEl),this.element.appendChild(n),e.appendChild(this.element)}setLoadMoreRowRenderer(e){this.loadMoreRowRenderer=e,this.renderParams&&this.renderContent(this.renderParams)}setData(e,t,n){this.rowNode=e,this.element.dataset.rowId=e.id,this.element.style.height=`${e.rowHeight}px`;let r=this.renderParams,i=n??this.loadMoreRowRenderer;if(r&&vy(r,t)&&this.loadMoreRowRenderer===i){this.renderParams=t;return}this.renderParams=t,this.loadMoreRowRenderer=i,this.renderContent(t)}syncRowLayout(e){this.rowNode=e,this.element.style.height=`${e.rowHeight}px`}setRowTop(e){let t=Math.round(e);t!==this.layoutTop&&(this.layoutTop=t,this.element.style.transform=`translate3d(0, ${t}px, 0)`)}destroy(){this.onUnmountRenderer?.(this.contentEl),this.contentEl.replaceChildren(),this.element.remove(),this.rowNode=null,this.renderParams=null}renderContent(e){Do(this.contentEl,e,this.loadMoreRowRenderer,{onUnmountRenderer:this.onUnmountRenderer,rowIndex:this.rowNode?.rowIndex??0})}},by=class{comp=null;acquire(e){return this.comp||=e(),this.comp}get(){return this.comp??void 0}release(){this.comp?.destroy(),this.comp=null}clear(){this.release()}},xy=class{container;rowModel;rowPool=new by;onUnmountRenderer;getLoadMoreRowEnabled;getLoadMoreRowRenderer;getLoadMoreRowLoading;getLoadMoreRowHasMore;getLoadMoreRowGridSize;getLoadMoreRowLabels;onLoadMore;getApi;compressedScroll=!1;scrollTop=0;invokeLoadMore=()=>{this.onLoadMore?.()};constructor(e){this.container=e.container,this.rowModel=e.rowModel,this.onUnmountRenderer=e.onUnmountRenderer,this.getLoadMoreRowEnabled=e.getLoadMoreRowEnabled,this.getLoadMoreRowRenderer=e.getLoadMoreRowRenderer,this.getLoadMoreRowLoading=e.getLoadMoreRowLoading,this.getLoadMoreRowHasMore=e.getLoadMoreRowHasMore,this.getLoadMoreRowGridSize=e.getLoadMoreRowGridSize,this.getLoadMoreRowLabels=e.getLoadMoreRowLabels,this.onLoadMore=e.onLoadMore,this.getApi=e.getApi}setCompressedScroll(e){this.compressedScroll=e}redraw(e,t){if(this.scrollTop=e,!(this.getLoadMoreRowEnabled?.()??!1)){this.clear();return}let n=this.rowModel.getRowCount();if(n===0){this.clear();return}let r=n-1,i=this.rowModel.getRow(r);if(!i||!go(i)){this.clear();return}if(!(r>=t.firstRow&&r<=t.lastRow)){this.clear();return}if(this.rowPool.get()){this.applyLoadMoreRowLayout(i);return}this.updateLoadMoreRow(i)}refreshLoadMoreRowContent(){let e=this.rowModel.getRowCount();if(e===0)return;let t=this.rowModel.getRow(e-1);!t||t.rowKind!==`LOAD_MORE`||this.updateLoadMoreRow(t)}syncColumnLayouts(){this.syncVisibleRowLayouts()}syncVisibleRowLayouts(){let e=this.rowModel.getRowCount();if(e===0)return;let t=this.rowModel.getRow(e-1);!t||!go(t)||!this.rowPool.get()||this.applyLoadMoreRowLayout(t)}applyLoadMoreRowLayout(e){let t=this.rowPool.get();if(!t)return;t.syncRowLayout(e);let n=this.compressedScroll?e.rowTop-this.scrollTop:e.rowTop;t.setRowTop(n)}invalidate(){this.clear()}destroy(){this.clear()}updateLoadMoreRow(e){let t=this.getApi?.();if(!t||!this.onLoadMore)return;let n=this.rowPool.acquire(()=>new yy(this.container,{onUnmountRenderer:this.onUnmountRenderer})),r={loading:this.getLoadMoreRowLoading?.()??!1,hasMore:this.getLoadMoreRowHasMore?.()??!0,size:this.getLoadMoreRowGridSize?.()??`default`,labels:this.getLoadMoreRowLabels?.()??po(),onLoadMore:this.invokeLoadMore,api:t};n.setData(e,r,this.getLoadMoreRowRenderer?.()),this.applyLoadMoreRowLayout(e)}clear(){this.rowPool.clear()}},Sy=class{rowModel;columnModel;rowHeight;rowBuffer;stripe;rowPool=new Pv;rowCompFactory;rowsContainer;frameService;onUnmountRenderer;onUnmountEditor;inlineCellEditor;indexColumnOptions;selectionColumnOptions;rowAutoHeightService;isRowDragHandleEnabled;rowDragCommittingRowIds=null;asyncMutationLoadingCounts=new Map;enableCellSpan;cellSpanService;spannedRowRenderer;fullWidthRowRenderer;loadMoreRowRenderer;fullWidthRowsContainerEl;embedFullWidthRows;rowExpansionHost;rowGroupingHost;treeTableHost;cellCommentHost;getCellDisableContext=()=>({});getCellStyleContext=()=>({});detailRowAutoHeightService=null;resolveBusinessRowId;valueCacheVersion=0;pinnedRowIds=new Set;selectedRowIds=new Set;indeterminateRowIds=new Set;indexFocusedRowIds=new Set;isRowNodeSelectable=()=>!0;focusedCell=null;cellRangeIsSelected=null;cellRangeAnchor=null;indexColumnHighlightChecker=null;activeIndices=new Set;columnWindow={firstCol:0,lastCol:-1};currentWindow={firstRow:0,lastRow:-1,firstCol:0,lastCol:-1};compressedScroll=!1;scrollTop=0;cellRendererDefer=`always`;deferRowDestroyOnScroll=!1;cellRendererPresentation=`deferred`;infiniteLoadingRowVisible;scrollActive=!1;pendingDestroyTasks=new Map;resolveOverlayEditingTargets=()=>[];constructor(e,t){this.rowsContainer=e,this.rowModel=t.rowModel,this.columnModel=t.columnModel,this.rowHeight=t.rowHeight??or,this.rowBuffer=t.rowBuffer??10,this.stripe=t.stripe??!1,this.frameService=t.frameService??null,this.onUnmountRenderer=t.onUnmountRenderer,this.onUnmountEditor=t.onUnmountEditor,this.indexColumnOptions=t.indexColumnOptions,this.selectionColumnOptions=t.selectionColumnOptions,this.rowAutoHeightService=t.rowAutoHeightService??null,this.isRowDragHandleEnabled=t.isRowDragHandleEnabled,this.enableCellSpan=t.enableCellSpan??!1,this.cellSpanService=t.cellSpanService??null,this.embedFullWidthRows=t.embedFullWidthRows??!1,this.rowExpansionHost=t.rowExpansionHost,this.rowGroupingHost=t.rowGroupingHost,this.treeTableHost=t.treeTableHost,this.cellCommentHost=t.cellCommentHost,this.resolveBusinessRowId=t.resolveBusinessRowId,this.getCellDisableContext=t.getCellDisableContext??this.getCellDisableContext,this.getCellStyleContext=t.getCellStyleContext??this.getCellStyleContext,this.cellRendererDefer=t.cellRendererDefer??`always`,this.deferRowDestroyOnScroll=t.deferRowDestroyOnScroll??!1,this.cellRendererPresentation=t.cellRendererPresentation??`deferred`,this.infiniteLoadingRowVisible=t.infiniteLoadingRowVisible??!0,this.rowCompFactory=t.rowCompFactory??{create:()=>new py(this.rowsContainer,{stripe:this.stripe,frameService:this.frameService??void 0,onUnmountRenderer:this.onUnmountRenderer,onUnmountEditor:this.onUnmountEditor,inlineEditor:this.inlineCellEditor,indexColumnOptions:this.indexColumnOptions,selectionColumnOptions:this.selectionColumnOptions,rowAutoHeightService:this.rowAutoHeightService,isRowDragHandleEnabled:this.isRowDragHandleEnabled,isAsyncMutationLoadingRow:e=>this.isAsyncMutationLoadingRowAt(e),enableCellSpan:this.enableCellSpan,cellSpanService:this.cellSpanService,getRowByIndex:e=>this.rowModel.getRow(e),getRowCount:()=>this.rowModel.getRowCount(),embedFullWidthRows:this.embedFullWidthRows,getDetailCellRenderer:t.getDetailCellRenderer,getMasterRowById:t.getMasterRowById,rowExpansionHost:this.rowExpansionHost,rowGroupingHost:this.rowGroupingHost,treeTableHost:this.treeTableHost,getCellCommentHost:()=>this.cellCommentHost,detailRowAutoHeightService:this.detailRowAutoHeightService,resolveBusinessRowId:this.resolveBusinessRowId,getCellDisableContext:()=>this.getCellDisableContext(),getCellStyleContext:()=>this.getCellStyleContext(),cellRendererDefer:this.cellRendererDefer,isScrollActive:()=>this.scrollActive,cellRendererPresentation:this.cellRendererPresentation,infiniteLoadingRowVisible:this.infiniteLoadingRowVisible})},this.spannedRowRenderer=t.spannedRowsContainerEl?new my({container:t.spannedRowsContainerEl,rowModel:this.rowModel,columnModel:this.columnModel,stripe:this.stripe,frameService:this.frameService??void 0,onUnmountRenderer:this.onUnmountRenderer,onUnmountEditor:this.onUnmountEditor,indexColumnOptions:this.indexColumnOptions,selectionColumnOptions:this.selectionColumnOptions,rowAutoHeightService:this.rowAutoHeightService,isRowDragHandleEnabled:this.isRowDragHandleEnabled,enableCellSpan:this.enableCellSpan,cellSpanService:this.cellSpanService}):null,this.fullWidthRowsContainerEl=t.fullWidthRowsContainerEl??null,this.fullWidthRowRenderer=t.fullWidthRowsContainerEl?new _y({container:t.fullWidthRowsContainerEl,rowModel:this.rowModel,columnModel:this.columnModel,frameService:this.frameService??void 0,onUnmountRenderer:this.onUnmountRenderer,masterDetail:t.masterDetail??!1,embedFullWidthRows:t.embedFullWidthRows??!1,getDetailCellRenderer:t.getDetailCellRenderer,getMasterRowById:t.getMasterRowById}):null,this.loadMoreRowRenderer=t.fullWidthRowsContainerEl?new xy({container:t.fullWidthRowsContainerEl,rowModel:this.rowModel,onUnmountRenderer:this.onUnmountRenderer,getLoadMoreRowEnabled:t.getLoadMoreRowEnabled,getLoadMoreRowRenderer:t.getLoadMoreRowRenderer,getLoadMoreRowLoading:t.getLoadMoreRowLoading,getLoadMoreRowHasMore:t.getLoadMoreRowHasMore,getLoadMoreRowGridSize:t.getLoadMoreRowGridSize,getLoadMoreRowLabels:t.getLoadMoreRowLabels,onLoadMore:t.onLoadMore,getApi:t.getApi}):null}setEmbedFullWidthRows(e){this.embedFullWidthRows!==e&&(this.embedFullWidthRows=e,this.fullWidthRowRenderer?.setEmbedFullWidthRows(e),this.invalidate())}setMasterDetail(e){this.fullWidthRowRenderer?.setMasterDetail(e)}setRowDragHandleEnabled(e){this.isRowDragHandleEnabled=e}setRowDragCommittingRows(e){let t=this.rowDragCommittingRowIds,n=e&&e.length>0?new Set(e):null;if(!(t===n||t&&n&&t.size===n.size&&[...t].every(e=>n.has(e)))){if(t){let e=[...t].filter(e=>!n?.has(e));e.length>0&&this.setAsyncMutationLoading(e,!1)}if(this.rowDragCommittingRowIds=n,n){let e=[...n].filter(e=>!t?.has(e));e.length>0&&this.setAsyncMutationLoading(e,!0)}}}setAsyncMutationLoading(e,t){if(e.length!==0)for(let n of e){let e=this.asyncMutationLoadingCounts.get(n)??0,r=t?e+1:Math.max(0,e-1);r===0?(this.asyncMutationLoadingCounts.delete(n),e>0&&this.applyIndexLoadingVisual(n,!1)):(this.asyncMutationLoadingCounts.set(n,r),e===0&&t&&this.applyIndexLoadingVisual(n,!0))}}setEnableCellSpan(e){this.enableCellSpan=e;for(let t of this.rowPool.getActiveIds())this.rowPool.get(t)?.setEnableCellSpan?.(e);this.spannedRowRenderer?.setEnableCellSpan(e)}setCellSpanService(e){this.cellSpanService=e,this.spannedRowRenderer?.setCellSpanService(e)}setRowAutoHeightService(e){this.rowAutoHeightService=e,this.spannedRowRenderer?.setRowAutoHeightService(e)}setDetailRowAutoHeightService(e){this.detailRowAutoHeightService=e,this.fullWidthRowRenderer?.setDetailRowAutoHeightService(e)}setInlineCellEditorContext(e){this.inlineCellEditor=e,this.spannedRowRenderer?.setInlineCellEditorContext(e)}setOverlayEditingTargetsResolver(e){this.resolveOverlayEditingTargets=e,this.spannedRowRenderer?.setOverlayEditingTargetsResolver(e)}setCellCommentHost(e){this.cellCommentHost=e}setGetCellDisableContext(e){this.getCellDisableContext=e}setGetCellStyleContext(e){this.getCellStyleContext=e}setDefaultRowHeight(e){this.rowHeight=Math.max(1,e)}setCompressedScroll(e){this.compressedScroll=e,this.spannedRowRenderer?.setCompressedScroll(e),this.fullWidthRowRenderer?.setCompressedScroll(e)}getScrollTop(){return this.scrollTop}isCompressedScroll(){return this.compressedScroll}setScrollActive(e){this.scrollActive=e}setScrollRenderBehavior(e){e.cellRendererDefer!==void 0&&(this.cellRendererDefer=e.cellRendererDefer),e.deferRowDestroyOnScroll!==void 0&&(this.deferRowDestroyOnScroll=e.deferRowDestroyOnScroll),e.cellRendererPresentation!==void 0&&(this.cellRendererPresentation=e.cellRendererPresentation)}promoteRendererPlaceholders(){let e=0;for(let t of this.rowPool.getActiveIds()){let n=this.rowPool.get(t);e+=n?.promoteRendererPlaceholders()??0}return e}flushDeferredDestroys(){if(this.pendingDestroyTasks.size===0)return;let e=[...this.pendingDestroyTasks.values()];if(this.pendingDestroyTasks.clear(),this.frameService&&!this.compressedScroll){for(let t of e)this.frameService.addDestroyTask(t);return}for(let t of e)t()}cancelPendingDestroy(e){this.pendingDestroyTasks.delete(e)}resetRowRenderWindowCache(){this.activeIndices.clear(),this.currentWindow={firstRow:0,lastRow:-1,firstCol:this.columnWindow.firstCol,lastCol:this.columnWindow.lastCol}}redraw(e,t,n,r=!1){this.scrollTop=e,this.columnWindow=n;let i={...lv({scrollTop:e,viewportHeight:t,rowBuffer:this.rowBuffer,rowHeight:this.rowHeight,rowModel:this.rowModel}),firstCol:n.firstCol,lastCol:n.lastCol};return Av(this.currentWindow,i)&&!r?(this.scrollTop=e,this.columnWindow=n,this.currentWindow=i,this.syncVisibleRowLayout(),this.syncVisibleCellCommentIndicators(),this.refreshIndexColumnHighlight(),this.spannedRowRenderer?.redraw(e,i,n,!1),this.fullWidthRowRenderer?.redraw(e,i),this.loadMoreRowRenderer?.redraw(e,i),this.syncFullWidthContainerDisplay(),this.refreshCellRangeSelection(),i):(this.recycleRows(i,r),this.syncVisibleCellCommentIndicators(),this.refreshIndexColumnHighlight(),this.spannedRowRenderer?.redraw(e,i,n,r),this.fullWidthRowRenderer?.redraw(e,i),this.loadMoreRowRenderer?.redraw(e,i),this.syncFullWidthContainerDisplay(),this.refreshCellRangeSelection(),this.currentWindow=i,i)}getActiveRowCount(){return this.rowPool.getActiveCount()}getCurrentWindow(){return this.currentWindow}destroy(){this.rowPool.clear(),this.spannedRowRenderer?.destroy(),this.fullWidthRowRenderer?.destroy(),this.loadMoreRowRenderer?.destroy(),this.activeIndices.clear()}syncRowExpansionDisplay(e,t,n){this.scrollTop=e,this.columnWindow=n;let r={...lv({scrollTop:e,viewportHeight:t,rowBuffer:this.rowBuffer,rowHeight:this.rowHeight,rowModel:this.rowModel}),firstCol:n.firstCol,lastCol:n.lastCol};this.fullWidthRowRenderer?.redraw(e,r),this.loadMoreRowRenderer?.redraw(e,r),this.syncFullWidthContainerDisplay();let i=this.collectExpandColumnIds(),a={columnModel:this.columnModel,columnWindow:this.columnWindow,valueCacheVersion:this.valueCacheVersion,indexColumnOptions:this.indexColumnOptions,selectionColumnOptions:this.selectionColumnOptions,inlineEditor:this.inlineCellEditor,overlayEditingTargets:this.resolveOverlayEditingTargets()},o=t=>{let n=this.rowModel.getRow(t);if(!n||I(n)||go(n))return;let r=this.rowModel.getRowCount(),o=t+1<r?this.rowModel.getRow(t+1):void 0,s=this.compressedScroll?n.rowTop-e:n.rowTop,c=this.rowPool.get(n.id);if(c){c.syncRowLayout?.(n),c.setRowTop(s),c.setBeforeLoadMoreRow?.(o!=null&&go(o)),c.syncRowExpansionDisplayChrome?.(i,a);return}this.updateRowAtIndex(t),this.rowPool.get(n.id)?.setRowTop(s)};if(r.lastRow>=r.firstRow)for(let e=r.firstRow;e<=r.lastRow;e++)o(e);for(let e of this.pinnedRowIds){if(F(e))continue;let t=this.findRowIndexById(e);t>=0&&o(t)}return this.spannedRowRenderer?.syncVisibleRowLayouts(),this.refreshCellRangeSelection(),this.syncVisibleCellCommentIndicators(),this.refreshIndexColumnHighlight(),this.activeIndices=Cy(r),this.currentWindow=r,this.pruneInactiveRowComps(r),r}pruneInactiveRowComps(e){let t=new Set;if(e.lastRow>=e.firstRow)for(let n=e.firstRow;n<=e.lastRow;n++){let e=this.rowModel.getRow(n);!e||I(e)||go(e)||t.add(e.id)}for(let e of this.pinnedRowIds)F(e)||t.add(e);for(let e of this.rowPool.getActiveIds())t.has(e)||(this.pendingDestroyTasks.delete(e),this.rowPool.release(e))}collectExpandColumnIds(){let e=[];for(let t of this.columnModel.getColumns())(A(t.colId)||t.rowExpand)&&e.push(t.colId);return e}invalidate(){this.frameService&&this.frameService.flushAllFrames(),this.pendingDestroyTasks.clear(),this.rowPool.clear(),this.spannedRowRenderer?.invalidate(),this.fullWidthRowRenderer?.invalidate(),this.loadMoreRowRenderer?.invalidate(),this.activeIndices.clear(),this.currentWindow={firstRow:0,lastRow:-1,firstCol:0,lastCol:-1}}setValueCacheVersion(e){this.valueCacheVersion=e,this.spannedRowRenderer?.setValueCacheVersion(e)}setPinnedRowIds(e){this.pinnedRowIds=new Set(e),this.fullWidthRowRenderer?.setPinnedRowIds(e)}setIsRowNodeSelectable(e){this.isRowNodeSelectable=e}refreshSelection(e,t=new Set){this.selectedRowIds=new Set(e),this.indeterminateRowIds=new Set(t);for(let n of this.rowPool.getActiveIds()){let r=this.rowPool.get(n);r?.setSelected?.(e.has(n),t.has(n)),this.syncRowSelectionDisabled(n,r)}this.spannedRowRenderer?.refreshSelection(e)}refreshDetailRows(e){for(let t of e){let e=P(t);this.fullWidthRowRenderer?.refreshDetailRowContent(e);let n=this.rowPool.get(e);n?.refreshCells&&n.refreshCells({columnModel:this.columnModel,columnWindow:this.columnWindow,valueCacheVersion:this.valueCacheVersion,force:!0})}}syncRowSelectionDisabled(e,t=this.rowPool.get(e)){let n=this.findRowIndexById(e),r=n>=0?this.rowModel.getRow(n):null,i=r?!this.isRowNodeSelectable(r):!1;t?.setSelectionDisabled?.(i)}refreshIndexFocus(e){this.indexFocusedRowIds=new Set(e);for(let t of this.rowPool.getActiveIds())this.rowPool.get(t)?.setIndexFocused?.(e.has(t));this.spannedRowRenderer?.refreshIndexFocus(e)}setFocusedCell(e){this.focusedCell=e,this.refreshFocus()}refreshFocus(){let e=this.focusedCell;for(let t of this.rowPool.getActiveIds())this.rowPool.get(t)?.setFocusedColId?.(e?.rowId===t?e.colId:null);this.spannedRowRenderer?.setFocusedCell(e)}setCellRangeVisualState(e,t){this.cellRangeIsSelected=e,this.cellRangeAnchor=t,this.refreshCellRangeSelection()}setIndexColumnHighlight(e){this.indexColumnHighlightChecker=e,this.refreshIndexColumnHighlight()}refreshCellRangeSelection(){let e=this.cellRangeIsSelected,t=this.cellRangeAnchor;for(let n of this.rowPool.getActiveIds()){let r=this.findRowIndexById(n),i=this.rowPool.get(n);!i?.setCellRangeSelection||r<0||i.setCellRangeSelection(e?t=>e(r,t):()=>!1,t?.rowIndex===r?t.colId:null,e??void 0)}this.spannedRowRenderer?.setCellRangeVisualState(e,t)}refreshIndexColumnHighlight(){let e=this.indexColumnHighlightChecker;for(let t of this.rowPool.getActiveIds()){let n=this.findRowIndexById(t),r=this.rowPool.get(t);!r?.setIndexColumnRangeHighlight||n<0||r.setIndexColumnRangeHighlight(e?e(n):!1)}}playCellRangeCopyFlash(){let e=this.cellRangeIsSelected;if(e){for(let t of this.rowPool.getActiveIds()){let n=this.findRowIndexById(t),r=this.rowPool.get(t);!r?.flashCellRangeSelection||n<0||r.flashCellRangeSelection(t=>e(n,t),e)}this.spannedRowRenderer?.playCellRangeCopyFlash()}}playCellRangePasteFlash(e){if(e.length===0)return;let t=new Map;for(let n of e){let e=t.get(n.rowIndex);e?e.push(n):t.set(n.rowIndex,[n])}for(let e of this.rowPool.getActiveIds()){let n=this.findRowIndexById(e),r=this.rowPool.get(e),i=t.get(n);!r?.flashCellRangePaste||!i?.length||n<0||r.flashCellRangePaste(i)}this.spannedRowRenderer?.playCellRangePasteFlash(e)}syncColumnLayouts(){for(let e of this.rowPool.getActiveIds())this.rowPool.get(e)?.syncColumnLayouts?.();this.spannedRowRenderer?.syncColumnLayouts(),this.fullWidthRowRenderer?.syncColumnLayouts(),this.loadMoreRowRenderer?.syncColumnLayouts()}refreshLoadMoreRowContent(){this.loadMoreRowRenderer?.refreshLoadMoreRowContent(),this.syncFullWidthContainerDisplay()}refreshVisibleColumnStructure(e){this.columnWindow=e;let t={columnStructureChanged:!0};for(let e of this.activeIndices)this.updateRowAtIndex(e,t);for(let e of this.pinnedRowIds){let n=this.findRowIndexById(e);n>=0&&!this.activeIndices.has(n)&&this.updateRowAtIndex(n,t)}this.spannedRowRenderer?.refreshVisibleColumnStructure(e),this.refreshCellRangeSelection(),this.syncVisibleCellCommentIndicators(),this.refreshIndexColumnHighlight()}migrateRowId(e,t){if(e===t)return;this.rowPool.migrateId(e,t);let n=this.rowPool.get(t);n&&(n.getElement().dataset.rowId=t),this.selectedRowIds.has(e)&&(this.selectedRowIds.delete(e),this.selectedRowIds.add(t)),this.indexFocusedRowIds.has(e)&&(this.indexFocusedRowIds.delete(e),this.indexFocusedRowIds.add(t)),this.focusedCell?.rowId===e&&(this.focusedCell={rowId:t,colId:this.focusedCell.colId}),this.pinnedRowIds.has(e)&&(this.pinnedRowIds.delete(e),this.pinnedRowIds.add(t)),this.spannedRowRenderer?.migrateRowId(e,t)}releaseRow(e){this.pendingDestroyTasks.delete(e),this.rowPool.release(e)}releaseRows(e){for(let t of e)this.releaseRow(t)}releaseRowsExcept(e){for(let t of this.rowPool.getActiveIds())e.has(t)||this.releaseRow(t)}reconcileRowPoolAfterModelChange(e,t){if(t){this.invalidate();return}this.releaseRowsExcept(e)}refreshRows(e){let t=e.rowIds?new Set(e.rowIds):null,{firstRow:n,lastRow:r}=this.currentWindow;if(r<n)return 0;let i=0;for(let a=n;a<=r;a++){let n=this.rowModel.getRow(a);if(!n||t&&!t.has(n.id))continue;let r=this.rowPool.get(n.id);r?.refreshCells&&(i+=r.refreshCells({columnModel:this.columnModel,columnWindow:this.columnWindow,valueCacheVersion:this.valueCacheVersion,colIds:e.colIds,force:e.force,newData:e.newData,indexColumnOptions:this.indexColumnOptions,selectionColumnOptions:this.selectionColumnOptions,inlineEditor:this.inlineCellEditor,overlayEditingTargets:this.resolveOverlayEditingTargets()}))}return i+=this.spannedRowRenderer?.refreshRows(e)??0,this.syncVisibleCellCommentIndicators({rowIds:e.rowIds,colIds:e.colIds}),i}syncVisibleCellCommentIndicators(e){if(!this.cellCommentHost?.active())return;let t=e?.rowIds?new Set(e.rowIds):null,n=e?.colIds?new Set(e.colIds):null,{firstRow:r,lastRow:i}=this.currentWindow;if(!(i<r)){for(let e=r;e<=i;e++){let r=this.rowModel.getRow(e);r&&(t&&!t.has(r.id)||this.rowPool.get(r.id)?.syncCellCommentIndicators?.(n))}for(let e of this.pinnedRowIds)t&&!t.has(e)||this.rowPool.get(e)?.syncCellCommentIndicators?.(n)}}syncVisibleRowLayouts(e){let t=e?new Set(e):null,n=e=>{let n=this.rowModel.getRow(e);if(!n||t&&!t.has(n.id))return;let r=this.rowPool.get(n.id);if(!r){this.updateRowAtIndex(e);return}r.syncRowLayout?.(n),r.setRowTop(this.compressedScroll?n.rowTop-this.scrollTop:n.rowTop)};for(let e of this.activeIndices)n(e);for(let e of this.pinnedRowIds){if(t&&!t.has(e))continue;let r=this.findRowIndexById(e);r>=0&&n(r)}this.spannedRowRenderer?.syncVisibleRowLayouts(e),this.fullWidthRowRenderer?.syncVisibleRowLayouts(e),this.loadMoreRowRenderer?.syncVisibleRowLayouts()}syncFullWidthContainerDisplay(){if(!this.fullWidthRowsContainerEl)return;let e=this.fullWidthRowsContainerEl.querySelector(`.mg-full-width-row`)!=null;this.fullWidthRowsContainerEl.style.display=e?``:`none`}recycleRows(e,t){let n=kv(this.activeIndices,e);if(t)for(let e of this.activeIndices)n.toUpdate.includes(e)||n.toUpdate.push(e);for(let e of n.toDestroy){let t=this.rowModel.getRow(e);if(!t||!this.rowPool.get(t.id)||this.pinnedRowIds.has(t.id))continue;let n=t.id,r=()=>{this.rowPool.release(n)};this.frameService&&!this.compressedScroll?this.deferRowDestroyOnScroll&&this.scrollActive?this.pendingDestroyTasks.set(n,r):this.frameService.addDestroyTask(r):r()}for(let e of n.toUpdate)this.updateRowAtIndex(e,t?{columnStructureChanged:!0}:void 0);for(let e of n.toCreate){let n=t?{columnStructureChanged:!0}:void 0;this.frameService&&!this.compressedScroll?this.frameService.createTask(()=>{this.updateRowAtIndex(e,n)},e,`p1`):this.updateRowAtIndex(e,n)}this.activeIndices=Cy(e);for(let e of this.pinnedRowIds){let r=this.findRowIndexById(e);r>=0&&(this.activeIndices.add(r),!n.toUpdate.includes(r)&&!n.toCreate.includes(r)&&this.updateRowAtIndex(r,t?{columnStructureChanged:!0}:void 0))}this.pruneInactiveRowComps(e)}syncVisibleRowLayout(){let{firstRow:e,lastRow:t}=this.currentWindow;if(!(t<e)){for(let n=e;n<=t;n++)this.projectRowVisualsAtIndex(n);for(let e of this.pinnedRowIds){let t=this.findRowIndexById(e);t>=0&&this.projectRowVisualsAtIndex(t)}}}updateRowAtIndex(e,t){let n=this.rowModel.getRow(e);if(!n||I(n)&&!this.embedFullWidthRows||go(n))return;this.cancelPendingDestroy(n.id);let r=this.rowPool.acquire(n.id,()=>this.rowCompFactory.create()),i=this.rowModel.getRowCount(),a=e+1<i?this.rowModel.getRow(e+1):void 0;r.setData(n,this.columnModel,this.columnWindow,this.valueCacheVersion,i>0&&e===i-1,{...t,overlayEditingTargets:this.resolveOverlayEditingTargets()}),r.setBeforeLoadMoreRow?.(a!=null&&go(a)),this.projectRowVisualsAtIndex(e,r,n)}projectRowVisualsAtIndex(e,t=this.rowPool.get(this.rowModel.getRow(e)?.id??``),n=this.rowModel.getRow(e)){n&&(t||=(this.updateRowAtIndex(e),this.rowPool.get(n.id)),t&&(I(n)&&!this.embedFullWidthRows||go(n)||(t.setRowTop(this.compressedScroll?n.rowTop-this.scrollTop:n.rowTop),t.setSelected?.(this.selectedRowIds.has(n.id)),t.setSelectionDisabled?.(!this.isRowNodeSelectable(n)),t.setIndexFocused?.(this.indexFocusedRowIds.has(n.id)),t.setIndexColumnRangeHighlight?.(this.indexColumnHighlightChecker?.(e)??!1),t.setFocusedColId?.(this.focusedCell?.rowId===n.id?this.focusedCell.colId:null))))}findRowIndexById(e){let{firstRow:t,lastRow:n}=this.currentWindow;if(n<t)return-1;for(let r=t;r<=n;r++)if(this.rowModel.getRow(r)?.id===e)return r;for(let t=0;t<this.rowModel.getRowCount();t++)if(this.rowModel.getRow(t)?.id===e)return t;return-1}isAsyncMutationLoadingRowAt(e){return(this.asyncMutationLoadingCounts.get(e)??0)>0}applyIndexLoadingVisual(e,t){if(this.rowPool.get(e)?.setIndexLoadingVisual?.(t),this.rowsContainer.querySelectorAll(`.mg-row[data-row-id="${CSS.escape(e)}"] .mg-cell--index`).forEach(e=>{e instanceof HTMLElement&&Nv(e,t)}),!t){let t=this.indexFocusedRowIds.has(e);this.rowPool.get(e)?.setIndexFocused?.(t)}}};function Cy(e){let t=new Set;if(e.lastRow<e.firstRow)return t;for(let n=e.firstRow;n<=e.lastRow;n++)t.add(n);return t}var wy=class{scrollTop=0;nextScrollTop=0;notifyScroll(e){this.nextScrollTop=e}isScrollGoingDown(){return this.nextScrollTop>=this.scrollTop}scrollGridIfNeeded(e){return this.scrollTop!==this.nextScrollTop&&(this.scrollTop=this.nextScrollTop,e(this.scrollTop),!0)}syncScrollTop(e){this.scrollTop=e,this.nextScrollTop=e}getScrollTop(){return this.scrollTop}getNextScrollTop(){return this.nextScrollTop}},Ty=class{version=0;getVersion(){return this.version}bump(){this.version++}reset(){this.version=0}};function Ey(e={}){return{navigateHeader:e.navigateHeader??!1,navigateFooter:e.navigateFooter??!1}}function Dy(e,t,n){if(t.size===0)return e.slice();let r=[];for(let i of e)te(i)&&(r.push(i),t.has(i.id)&&r.push(n(i)));return r}function Oy(e,t,n,r){if(r?.force)delete e.__detailRowData,delete e.__detailLoadError,e.__detailLoading=!1;else if(e.__detailLoading||e.__detailRowData!==void 0)return;let i=(e.__detailLoadId??0)+1;e.__detailLoadId=i,e.__detailLoading=!0,delete e.__detailLoadError,n.onLoading();let a=!1,o=t=>{a||(a=!0,e.__detailLoadId===i&&(t(),n.onSettled()))},s={rowId:e.id,data:e.data,successCallback:t=>{o(()=>{e.__detailRowData=t,e.__detailLoading=!1})},failCallback:t=>{o(()=>{e.__detailLoading=!1,e.__detailLoadError=t??!0})}};try{let e=t(s);ky(e)&&e.catch(e=>{s.failCallback?.(e)})}catch(e){s.failCallback?.(e)}}function ky(e){return typeof e==`object`&&!!e&&`then`in e&&typeof e.then==`function`}function Ay(e){let t=e.style.height,n=e.style.minHeight,r=e.style.overflow;e.style.height=`auto`,e.style.minHeight=`0`,e.style.overflow=`visible`;let i=e.scrollHeight;return e.style.height=t,e.style.minHeight=n,e.style.overflow=r,Math.ceil(i)}var jy=1,My=5,Ny=class{deps;debounceTimer=null;pendingHeights=new Map;contentCleanups=new Map;constructor(e){this.deps=e}setupContentObserver(e,t){if(!this.deps.isEnabled())return;this.teardownContentObserver(e);let n=(r=0)=>{let i=this.deps.getRowById(e);if(!i||!I(i))return;let a=Ay(t);if(a<=0&&r<My){window.setTimeout(()=>n(r+1),0);return}a>0&&this.queueMeasuredHeight(e,a,i)};n();let r=typeof ResizeObserver<`u`?new ResizeObserver(()=>{n()}):null;r?.observe(t),this.contentCleanups.set(e,()=>{r?.disconnect()})}teardownContentObserver(e){this.contentCleanups.get(e)?.(),this.contentCleanups.delete(e)}destroy(){this.debounceTimer!=null&&(clearTimeout(this.debounceTimer),this.debounceTimer=null);for(let e of this.contentCleanups.values())e();this.contentCleanups.clear(),this.pendingHeights.clear()}queueMeasuredHeight(e,t,n){let r=this.deps.getMinDetailRowHeight(n),i=Math.max(r,t);n.rowHeight===i&&!n.estimated||(this.pendingHeights.set(e,i),this.scheduleApply())}scheduleApply(){this.debounceTimer??=window.setTimeout(()=>{this.debounceTimer=null,this.flushPendingHeights()},jy)}flushPendingHeights(){if(this.pendingHeights.size!==0){for(let[e,t]of this.pendingHeights.entries()){let n=this.deps.getRowById(e);!n||n.rowHeight===t&&!n.estimated||this.deps.rowHeightService.setRowHeight(e,t,!0,`autoHeight`)}this.pendingHeights.clear()}}};function Py(e,t){let n=ne(t.detailRowHeight,{rowId:e.id,data:e.data,masterRowId:e.id});return{id:P(e.id),data:e.data,rowKind:`DETAIL`,masterRowId:e.id,rowTop:0,rowHeight:n,estimated:t.detailRowAutoHeight,rowIndex:0,sourceIndex:-1}}var Fy=class{deps;expandedMasterIds=new Set;constructor(e){this.deps=e}get active(){return this.deps.getOptions().masterDetail}isExpanded(e){return this.expandedMasterIds.has(e)}getExpandedMasterIds(){return this.expandedMasterIds}getPinnedRowIds(){let e=[];for(let t of this.expandedMasterIds)e.push(t,P(t));return e}isRowMaster(e){return!this.active||I(e)?!1:this.deps.getOptions().isRowMaster({rowId:e.id,data:e.data,rowIndex:e.rowIndex})}expandRow(e,t){if(!this.active||this.expandedMasterIds.has(e))return!1;let n=this.findBaseMasterRow(e);return!n||!this.isRowMaster(n)?!1:(this.expandedMasterIds.add(e),this.ensureDetailRowData(e),this.emit(re(e,t)),!0)}collapseRow(e,t){return!this.active||!this.expandedMasterIds.has(e)?!1:(this.expandedMasterIds.delete(e),this.clearMasterDetailCache(e),this.emit(ie(e,t)),!0)}toggleRow(e,t){return this.isExpanded(e)?this.collapseRow(e,t):this.expandRow(e,t)}expandAll(e){if(this.active)for(let t of this.deps.getBaseDisplayRows())this.isRowMaster(t)&&this.expandRow(t.id,e)}collapseAll(e){if(this.active)for(let t of[...this.expandedMasterIds])this.collapseRow(t,e)}pruneExpanded(e){for(let t of[...this.expandedMasterIds])e.has(t)||(this.expandedMasterIds.delete(t),this.clearMasterDetailCache(t))}clearExpanded(){this.expandedMasterIds.clear()}applyDefaultExpanded(e){if(this.active&&this.deps.getOptions().masterDefaultExpanded!==0)for(let t of e)this.isRowMaster(t)&&(this.expandedMasterIds.add(t.id),this.ensureDetailRowData(t.id))}injectDetailRows(e){return!this.active||this.expandedMasterIds.size===0?e.slice():Dy(e,this.expandedMasterIds,e=>this.createDetailRowNode(e))}createDetailRowNode(e){let t=this.deps.getOptions();return Py(e,{detailRowHeight:t.detailRowHeight,detailRowAutoHeight:t.detailRowAutoHeight})}setDetailRowData(e,t){if(!this.active)return!1;let n=this.findBaseMasterRow(e);return!n||!this.isRowMaster(n)?!1:(n.__detailRowData=t,delete n.__detailLoading,delete n.__detailLoadError,this.isExpanded(e)&&this.deps.onDetailDataChanged?.(e),!0)}reloadDetailRowData(e){if(!this.active)return!1;let t=this.deps.getOptions().getDetailRowData;if(!t)return!1;let n=this.findBaseMasterRow(e);return!n||!this.isRowMaster(n)?!1:(Oy(n,t,{onLoading:()=>this.deps.onDetailDataChanged?.(e),onSettled:()=>this.deps.onDetailDataChanged?.(e)},{force:!0}),!0)}findBaseMasterRow(e){return this.deps.getBaseDisplayRows().find(t=>t.id===e)}clearMasterDetailCache(e){let t=this.findBaseMasterRow(e);t&&(delete t.__detailRowData,delete t.__detailLoading,delete t.__detailLoadError,t.__detailLoadId=(t.__detailLoadId??0)+1)}ensureDetailRowData(e){let t=this.deps.getOptions().getDetailRowData;if(!t)return;let n=this.findBaseMasterRow(e);n&&Oy(n,t,{onLoading:()=>this.deps.onDetailDataChanged?.(e),onSettled:()=>this.deps.onDetailDataChanged?.(e)})}emit(e){this.deps.onExpansionChanged?.(e)}};function Iy(e=lo){return{id:co,data:{},rowTop:0,rowHeight:e,estimated:!1,rowIndex:-1,sourceIndex:-1,rowKind:`LOAD_MORE`}}function Ly(e,t){return!t.enabled||e.length===0?e.slice():[...e,Iy(t.height)]}var Ry=class{deps;constructor(e){this.deps=e}injectTrailingRow(e){if(!this.deps.isClientSideRowModel())return e.slice();let t=this.deps.getOptions();return Ly(e,{enabled:t.enabled,height:t.height})}},zy=class{deps;expandedGroupIds=new Set;rowGroupColumns;constructor(e){this.deps=e,this.rowGroupColumns=[...e.getRowGroupColumnsFromDefs()]}get active(){return Me(this.deps.getOptions().rowGrouping,this.rowGroupColumns)}getExpandedGroupIds(){return this.expandedGroupIds}getRowGroupColumns(){return this.rowGroupColumns}syncRowGroupColumnsFromDefs(){this.rowGroupColumns=[...this.deps.getRowGroupColumnsFromDefs()]}setRowGroupColumns(e,t){this.deps.getOptions().rowGrouping&&(this.rowGroupColumns=[...e],this.clearExpanded(),this.emitGroupChanged(Ge(this.rowGroupColumns,t)))}isExpanded(e){return this.expandedGroupIds.has(e)}expandGroup(e,t){if(!this.active||this.expandedGroupIds.has(e))return;let n=Jl(this.deps.getGroupedTreeRoots(),e);n?.groupId&&(this.expandedGroupIds.add(e),this.emitGroupOpened(n,!0,t),this.deps.onGroupingStateChanged?.())}collapseGroup(e,t){if(!this.active||!this.expandedGroupIds.has(e))return;let n=Jl(this.deps.getGroupedTreeRoots(),e);this.expandedGroupIds.delete(e),n?.groupId&&this.emitGroupOpened(n,!1,t),this.deps.onGroupingStateChanged?.()}toggleGroup(e,t){if(this.isExpanded(e)){this.collapseGroup(e,t);return}this.expandGroup(e,t)}expandAll(e){if(this.active)for(let t of ql(this.deps.getGroupedTreeRoots()))this.expandedGroupIds.has(t)||this.expandGroup(t,e)}collapseAll(e){if(this.active)for(let t of[...this.expandedGroupIds])this.collapseGroup(t,e)}clearExpanded(){this.expandedGroupIds.clear()}pruneExpanded(e){for(let t of[...this.expandedGroupIds])e.has(t)||this.expandedGroupIds.delete(t)}applyDefaultExpanded(e){if(!this.active)return;let t=this.deps.getOptions().groupDefaultExpanded;t!==0&&Kl(e,e=>{!Yl(e.groupLevel??0,t)||!e.groupId||this.expandedGroupIds.add(e.groupId)})}getLeafGroupPathKey(e){return!R(e)||Ve(e)||He(e)?null:e.leafGroupPathKey??null}getMapStageOptions(){return{expandedGroupIds:this.expandedGroupIds,showGroupHeader:this.deps.getOptions().showGroupHeader,showGroupFooter:this.deps.getOptions().showGroupFooter}}emitGroupOpened(e,t,n){this.deps.onGroupOpened?.(We({groupId:e.groupId,expanded:t,field:e.groupField??``,key:e.groupKey??``,level:e.groupLevel??0,source:n}))}emitGroupChanged(e){this.deps.onGroupChanged?.(e)}};function By(e,t){for(let n of e)t(n),By(Kr(n),t)}function Vy(e,t=e=>e.treeLeaf!==!0){let n=[];return By(e,e=>{t(e)&&n.push(e.id)}),n}function Hy(e,t){let n;return By(e,e=>{e.id===t&&(n=e)}),n}function Uy(e,t){return t===0?!1:t===-1||e<t}function Wy(e){let t=new Set;return By(e,e=>t.add(e.id)),t}var Gy=class{deps;expandedRowIds=new Set;constructor(e){this.deps=e}get active(){let e=this.deps.getOptions();return nt(e.tree,e.getDataPath)}getExpandedRowIds(){return this.expandedRowIds}isExpanded(e){return this.expandedRowIds.has(e)}expandNode(e,t){if(!this.active||this.expandedRowIds.has(e))return;let n=Hy(this.deps.getTreeTreeRoots(),e);!n||!this.isNodeExpandable(n)||(this.expandedRowIds.add(e),this.emitNodeOpened(n,!0,t),this.deps.onTreeStateChanged?.())}collapseNode(e,t){if(!this.active||!this.expandedRowIds.has(e))return;this.deps.getLazyLoadHost?.()?.abortLoad(e);let n=Hy(this.deps.getTreeTreeRoots(),e);this.expandedRowIds.delete(e),n&&this.emitNodeOpened(n,!1,t),this.deps.onTreeStateChanged?.()}toggleNode(e,t){if(this.isExpanded(e)){this.collapseNode(e,t);return}this.expandNode(e,t)}async requestToggleNode(e,t){if(!this.active)return;if(this.isExpanded(e)){this.collapseNode(e,t);return}let n=Hy(this.deps.getTreeTreeRoots(),e);if(!n||!this.isNodeExpandable(n))return;let r=this.deps.getLazyLoadHost?.();if(r?.ensureChildrenLoaded){if(!await r.ensureChildrenLoaded(n,t))return;let i=Hy(this.deps.getTreeTreeRoots(),e)??n;if(!this.isNodeExpandable(i))return}this.expandNode(e,t)}isNodeExpandable(e){let t=this.deps.getLazyLoadHost?.();return t?t.isExpandable(e):e.treeLeaf!==!0}isNodeLoading(e){return this.deps.getLazyLoadHost?.()?.isLoading(e)??!1}expandAll(e){if(!this.active)return;let t=Vy(this.deps.getTreeTreeRoots(),e=>this.isNodeExpandable(e)),n=!1;for(let e of t){if(this.expandedRowIds.has(e))continue;let t=Hy(this.deps.getTreeTreeRoots(),e);!t||!this.isNodeExpandable(t)||(this.expandedRowIds.add(e),n=!0)}n&&this.deps.onTreeStateChanged?.()}collapseAll(){if(!this.active)return;let e=[...this.expandedRowIds];if(e.length===0)return;let t=this.deps.getLazyLoadHost?.();for(let n of e)t?.abortLoad(n),this.expandedRowIds.delete(n);this.deps.onTreeStateChanged?.()}isAllExpandableNodesExpanded(){if(!this.active)return!1;let e=Vy(this.deps.getTreeTreeRoots(),e=>this.isNodeExpandable(e));return e.length!==0&&e.every(e=>this.expandedRowIds.has(e))}clearExpanded(){this.expandedRowIds.clear()}pruneExpanded(e){for(let t of[...this.expandedRowIds])e.has(t)||this.expandedRowIds.delete(t)}applyDefaultExpanded(e){if(!this.active)return;let t=this.deps.getGroupDefaultExpanded();t!==0&&By(e,e=>{let n=e.treeLevel??0;e.treeLeaf!==!0&&Uy(n,t)&&this.expandedRowIds.add(e.id)})}getDataPathForRow(e){let t=Hy(this.deps.getTreeTreeRoots(),e);return t?.dataPath?[...t.dataPath]:void 0}getMapStageOptions(){let e=this.deps.getOptions();return{expandedRowIds:this.expandedRowIds,treeValueGetter:e.treeValueGetter}}getTreeDisplayValue(e){let t=this.deps.getOptions(),n=e.dataPath??[];return t.treeValueGetter?t.treeValueGetter({data:e.data,dataPath:n,treeLevel:e.treeLevel??0}):n[n.length-1]??``}prepareTreeTree(e){let t=Wy(e);this.pruneExpanded(t),this.deps.getLazyLoadHost?.()?.pruneLoaded(t)}applyDefaultExpandedToTree(e){this.applyDefaultExpanded(e)}expandForQuickFilterDisplay(e){if(this.active)for(let t of qr(e))this.expandedRowIds.add(t)}emitNodeOpened(e,t,n){this.deps.onNodeOpened?.(at(e.id,t,e.treeLevel??0,e.dataPath??[],n))}},Ky=class{deps;loadedParentIds=new Set;emptyLeafParentIds=new Set;loadingParentIds=new Set;inflight=new Map;constructor(e){this.deps=e}get active(){let e=this.deps.getOptions();return e.treeLazyLoad===!0&&typeof e.loadTreeChildren==`function`}isLoading(e){return this.loadingParentIds.has(e)}isLoadedEmptyLeaf(e){return this.emptyLeafParentIds.has(e)}isLoadedParent(e){return this.loadedParentIds.has(e)}resolveExpandable(e){let t=e.childrenAfterTree;if(t&&t.length>0)return!0;if(this.emptyLeafParentIds.has(e.id))return!1;let n=this.deps.getOptions().hasTreeChildren;return n?n({data:e.data,dataPath:e.dataPath??[],treeLevel:e.treeLevel??0}):e.treeLeaf!==!0}isExpandable(e){return this.resolveExpandable(e)}needsLazyLoad(e){return!this.active||this.loadedParentIds.has(e.id)||this.emptyLeafParentIds.has(e.id)||e.childrenAfterTree&&e.childrenAfterTree.length>0?!1:this.resolveExpandable(e)}abortLoad(e){let t=this.inflight.get(e);t&&(t.controller.abort(),this.inflight.delete(e)),this.loadingParentIds.delete(e)}reset(){for(let e of this.inflight.values())e.controller.abort();this.inflight.clear(),this.loadedParentIds.clear(),this.emptyLeafParentIds.clear(),this.loadingParentIds.clear()}prune(e){for(let t of[...this.loadedParentIds])e.has(t)||this.loadedParentIds.delete(t);for(let t of[...this.emptyLeafParentIds])e.has(t)||this.emptyLeafParentIds.delete(t);for(let t of[...this.inflight.keys()])e.has(t)||this.abortLoad(t)}pruneLoaded(e){this.prune(e)}ensureChildrenLoaded(e,t=`ui`){if(!this.needsLazyLoad(e))return Promise.resolve(!0);let n=this.inflight.get(e.id);if(n)return n.promise;let r=new AbortController,i=this.runLoad(e,t,r);return this.inflight.set(e.id,{controller:r,promise:i}),i.finally(()=>{this.inflight.delete(e.id)})}async runLoad(e,t,n){let r=this.deps.getOptions().loadTreeChildren;if(!r)return!1;let i=e.id,a=e.dataPath??[],o=e.treeLevel??0;this.loadingParentIds.add(i),this.deps.onStateChanged?.(),this.deps.onLoading?.({parentRowId:i,dataPath:[...a],treeLevel:o,source:t});try{let s=await r({parentRowId:i,parentData:e.data,dataPath:[...a],treeLevel:o,signal:n.signal});if(n.signal.aborted)return!1;let c=qy(s);return c.length===0?(this.emptyLeafParentIds.add(i),this.deps.onLoaded?.({parentRowId:i,children:[],childCount:0,source:t}),!0):(Jy({parentPath:a,children:c,rowKey:this.deps.rowKey,getDataPath:this.deps.getDataPath(),existingRowKeys:this.deps.getExistingRowKeys()}),this.deps.applyTransaction({add:c}),this.loadedParentIds.add(i),this.deps.onLoaded?.({parentRowId:i,children:c,childCount:c.length,source:t}),!0)}catch(e){if(n.signal.aborted)return!1;let t=e instanceof Error?e.message:String(e);return this.deps.onLoadFailed?.({parentRowId:i,reason:t,aborted:!1}),!1}finally{this.loadingParentIds.delete(i),this.deps.onStateChanged?.()}}};function qy(e){return e?[...e]:[]}function Jy(e){let t=new Set(e.existingRowKeys);for(let n of e.children){let r=e.getDataPath({data:n});if(!Yy(e.parentPath,r))throw Error(`[magic-grid] loadTreeChildren: child path [${r.join(`/`)}] must extend parent [${e.parentPath.join(`/`)}]`);let i=n[e.rowKey];if(i==null||i===``)throw Error(`[magic-grid] loadTreeChildren: child row is missing rowKey value.`);let a=String(i);if(t.has(a))throw Error(`[magic-grid] loadTreeChildren: duplicate rowKey "${a}".`);t.add(a)}}function Yy(e,t){if(t.length!==e.length+1)return!1;for(let n=0;n<e.length;n++)if(t[n]!==e[n])return!1;return!0}var Xy=!1;function Zy(e){let t=e.tree===!0,n=e.rowGrouping===!0;return t?(n&&!Xy&&(Xy=!0,console.warn(`[magic-grid] tree and rowGrouping are mutually exclusive; rowGrouping ignored.`)),{mode:`tree`,rowGroupingIgnored:n}):n?{mode:`group`,rowGroupingIgnored:!1}:{mode:`flat`,rowGroupingIgnored:!1}}var Qy=.2;function $y(e,t,n,r){if(e<t+40){let n=Math.min(1,(t+40-e)/40);return-(n*n*n)*r*Qy}if(e>n-40){let t=Math.min(1,(e-(n-40))/40);return t*t*t*r*Qy}return 0}function eb(e,t,n,r,i){let a=tb(e,n,r);if(a)return a;let o=t.getBoundingClientRect(),s=i()+(r-o.top),c=e.getRowIndexAtPixel(s),l=e.getRow(c);return l?{rowId:l.id,rowIndex:c}:null}function tb(e,t,n){let r=document.elementFromPoint(t,n)?.closest(`.mg-row`);if(!r)return null;let i=r.dataset.rowId;if(!i)return null;let a=e.getRowIndexById(i);return a<0?null:{rowId:i,rowIndex:a}}function nb(e,t,n){return $y(e,t,n,1)!==0}function rb(e){return e===void 0?{}:{nestUnderRowId:e}}function ib(e){return typeof e==`string`?{nestUnderRowId:e}:{}}function ab(e,t){return e.dataPath??t({data:e.data})}function ob(e,t){let n=new Set;for(let r of e){let e=Pl(ab(r,t));if(n.has(e))return!0;n.add(e)}return!1}function sb(e,t){if(t.length<e.length)return!1;for(let n=0;n<e.length;n+=1)if(t[n]!==e[n])return!1;return!0}function cb(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function lb(e,t,n){let r=e;for(;r;){if(r.id===t)return!0;let e=r.parentRowId;if(e==null)return!1;r=n(e)}return!1}function ub(e,t,n){let r=[];for(let i of n){let n=e.find(e=>e.id===i);n&&r.push(ab(n,t))}if(r.length===0)return[];let i=[],a=new Set;for(let n of e){let e=ab(n,t);r.some(t=>cb(e,t)||sb(t,e))&&!a.has(n.id)&&(a.add(n.id),i.push(n.id))}return i}function db(e){let t=eb(e.rowModel,e.viewportEl,e.clientX,e.clientY,e.getLogicalScrollTop);if(!t||new Set(e.movingRowIds??[]).has(t.rowId))return null;let n=e.rowModel.getRowById(t.rowId);if(!n||!B(n))return null;if(e.altKey)return t.rowId;let r=e.viewportEl.querySelector(`.mg-row[data-row-id="${CSS.escape(t.rowId)}"]`)?.querySelector(`.mg-cell[data-col-id="${Ke}"], .mg-cell--tree-auto`);if(!r)return null;let i=bh((n.treeLevel??0)+1,!1),a=r.getBoundingClientRect().left+i*16;return e.clientX>=a?t.rowId:null}function fb(e,t,n,r={}){if(`nestUnderRowId`in r&&r.nestUnderRowId!==void 0){let i=r.nestUnderRowId,a=Math.max(0,Math.min(t,e.length));if(i==null)return{newParentRowId:null,withinSiblingInsertIndex:fd(e,a,null,n)};if(n.has(i))return null;let o=e.find(e=>e.id===i);return!o||!B(o)?null:{newParentRowId:i,withinSiblingInsertIndex:fd(e,a,i,n)}}let i=Math.max(0,Math.min(t,e.length)),a=i<e.length?e[i]:void 0,o=i>0?e[i-1]:void 0;if(!a&&!o)return{newParentRowId:null,withinSiblingInsertIndex:0};let s=a??o;if(!s||!B(s))return null;let c=a?a.parentRowId??null:o.parentRowId??null;return{newParentRowId:c,withinSiblingInsertIndex:fd(e,i,c,n)}}function pb(e,t,n,r,i,a,o={}){for(let e of r){let t=n(e);if(!t||!B(t))return!1}let s=fb(t,i,new Set(ub(e,a,r)),o);if(!s)return!1;if(s.newParentRowId){let e=n(s.newParentRowId);if(!e||!B(e))return!1;for(let t of r)if(s.newParentRowId===t||lb(e,t,n))return!1}return!0}function mb(e){let t=new Set(ub(e.sourceRows,e.getDataPath,e.rowIds));if(e.treeDragScope===`hierarchy`){let n=fb(e.displayRows,e.insertIndex,t,rb(e.nestUnderRowId));if(!n)return null;let r=n.newParentRowId==null?void 0:e.sourceRows.find(e=>e.id===n.newParentRowId);return{parentRowId:n.newParentRowId,siblingIndex:n.withinSiblingInsertIndex,treeLevel:n.newParentRowId==null?0:(r?.treeLevel??0)+1}}let n=dd(e.sourceRows,e.rowIds);if(n===`mixed`||n===`missing`)return null;let r=n==null?void 0:e.sourceRows.find(e=>e.id===n);return{parentRowId:n,siblingIndex:fd(e.displayRows,e.insertIndex,n,t),treeLevel:n==null?0:(r?.treeLevel??0)+1}}function hb(e,t,n){let r=ab(e[t],n),i=t;for(let a=t+1;a<e.length;a+=1){let t=ab(e[a],n);if(sb(r,t)&&!cb(r,t)){i=a;continue}break}return i}function gb(e,t,n,r){let i=[];for(let n=0;n<e.length;n+=1)(e[n].parentRowId??null)===t&&i.push(n);if(i.length===0){if(t==null)return 0;let n=e.findIndex(e=>e.id===t);return n<0?e.length:hb(e,n,r)+1}if(n>=i.length){let t=i[i.length-1];return hb(e,t,r)+1}return i[n]}function _b(e,t,n){for(let r of e)if(cb(ab(r,n),t))return r.id}function vb(e){return e.map(e=>({...e,data:{...e.data},dataPath:e.dataPath?[...e.dataPath]:void 0,childrenAfterTree:e.childrenAfterTree?[...e.childrenAfterTree]:void 0}))}function yb(e){let t=e.sourceRows.find(t=>t.id===e.rowId),n=e.sourceRows.find(t=>t.id===e.previousSiblingRowId);if(!t||!n||!B(t)||!B(n)||(t.parentRowId??null)!==(n.parentRowId??null))return null;let r=t=>ab(t,e.getDataPath),i=r(t),a=r(n),o=a[a.length-1];if(o==null)return null;let s=new Set(ub(e.sourceRows,e.getDataPath,[e.rowId])),c=new Set(ub(e.sourceRows,e.getDataPath,[e.previousSiblingRowId]));for(let e of s)if(c.has(e))return null;let l=vb(e.sourceRows),u=e=>l.find(t=>t.id===e),d=t=>ab(t,e.getDataPath),f=[];for(let e of l){if(s.has(e.id))continue;let t=d(e);(cb(t,a)||sb(a,t))&&f.push({rowId:e.id,newPath:[...i,o,...t.slice(a.length)]})}f.sort((e,t)=>e.newPath.length-t.newPath.length);for(let t of f){let n=u(t.rowId);if(!n)return null;let r=d(n);e.setDataPath({data:n.data,dataPath:t.newPath,treeLevel:t.newPath.length-1,previousPath:[...r]}),n.dataPath=t.newPath,n.treeLevel=t.newPath.length-1,n.parentRowId=t.newPath.length>1?_b(l,t.newPath.slice(0,-1),e.getDataPath):void 0}let p=l.filter(e=>s.has(e.id)),m=l.filter(e=>c.has(e.id)),h=l.filter(e=>!s.has(e.id)&&!c.has(e.id)),g=e.sourceRows.findIndex(t=>t.id===e.previousSiblingRowId),_=0;if(g>=0)for(let t=0;t<g;t+=1){let n=e.sourceRows[t].id;!s.has(n)&&!c.has(n)&&(_+=1)}let v=[...h.slice(0,_),...p,...m,...h.slice(_)];if(ob(v,e.getDataPath))return null;let y=[];for(let t of v){let n=e.sourceRows.findIndex(e=>e.id===t.id),r=v.findIndex(e=>e.id===t.id);n>=0&&r>=0&&n!==r&&y.push(ld(t.id,n,r))}return y.length===0&&f.length===0?null:{rows:v,moves:y}}function bb(e){if(!pb(e.sourceRows,e.displayRows,t=>e.sourceRows.find(e=>e.id===t),e.rowIds,e.displayInsertIndex,e.getDataPath,rb(e.nestUnderRowId)))return null;let t=ub(e.sourceRows,e.getDataPath,e.rowIds),n=new Set(t),r=dd(e.sourceRows,e.rowIds),i=fb(e.displayRows,e.displayInsertIndex,n,rb(e.nestUnderRowId));if(!i||r===`mixed`||r===`missing`)return null;if((i.newParentRowId??null)===r&&t.length===e.rowIds.length)return vd({sourceRows:e.sourceRows,displayRows:e.displayRows,rowIds:e.rowIds,displayInsertIndex:e.displayInsertIndex,parentRowId:r});let a=vb(e.sourceRows),o=e=>a.find(t=>t.id===e),s=t=>ab(t,e.getDataPath),c=new Map,l=new Map;for(let t of e.rowIds){let e=o(t);if(!e)return null;let n=s(e);c.set(t,n);let r=e.parentRowId==null?[]:s(o(e.parentRowId)),a=n.slice(r.length),u=i.newParentRowId==null?[]:s(o(i.newParentRowId));l.set(t,[...u,...a])}let u=[...t].sort((e,t)=>{let n=o(e),r=o(t);return s(n).length-s(r).length});for(let t of u){let n=o(t);if(!n)return null;let r=s(n),i=e.rowIds.find(e=>{let t=c.get(e);return t?cb(r,t)||sb(t,r):!1});if(!i)return null;let u=c.get(i),d=l.get(i);if(!u||!d)return null;let f=[...d,...r.slice(u.length)];e.setDataPath({data:n.data,dataPath:f,treeLevel:f.length-1,previousPath:[...r]}),n.dataPath=f,n.treeLevel=f.length-1,n.parentRowId=f.length>1?_b(a,f.slice(0,-1),e.getDataPath):void 0}let d=a.filter(e=>n.has(e.id)),f=a.filter(e=>!n.has(e.id)),p=gb(f,i.newParentRowId,i.withinSiblingInsertIndex,e.getDataPath),m=[...f.slice(0,p),...d,...f.slice(p)],h=[];for(let t of d){let n=e.sourceRows.findIndex(e=>e.id===t.id),r=m.findIndex(e=>e.id===t.id);n>=0&&r>=0&&n!==r&&h.push(ld(t.id,n,r))}let g=d.some(t=>{let n=e.sourceRows.find(e=>e.id===t.id);if(!n)return!1;let r=ab(n,e.getDataPath),i=s(t);return n.parentRowId!==t.parentRowId||!cb(r,i)});return h.length===0&&!g||ob(m,e.getDataPath)?null:{rows:m,moves:h}}function xb(e,t,n,r,i){let a=eb(e,t,n,r,i);return a?Sb(a,r,t,e,i):-1}function Sb(e,t,n,r,i){let a=r.getRowCount(),o=wb(e,n,r,i),s=e.rowIndex;return o!=null&&t>o&&(s+=1),Math.max(0,Math.min(s,a))}function Cb(e,t){return t<=0?0:Math.max(0,Math.min(e,t-1))}function wb(e,t,n,r){let i=t.querySelector(`.mg-row[data-row-id="${CSS.escape(e.rowId)}"]`);if(i){let e=i.getBoundingClientRect();return e.top+e.height/2}let a=n.getRowBounds(e.rowIndex);return a?t.getBoundingClientRect().top+a.rowTop+a.rowHeight/2-r():null}function Tb(e){return e==null?null:String(e)}function Eb(e,t){return e==null&&t==null?!0:e==null||t==null?!1:e.parentRowId===t.parentRowId&&e.siblingIndex===t.siblingIndex&&e.treeLevel===t.treeLevel}function Db(e,t){let n=[];for(let r of t){let i=K(e,r.id),a=K(t,r.id);a&&(Eb(i,a)||n.push({rowId:r.id,previousParentRowId:Tb(i?.parentRowId),previousSiblingIndex:i?.siblingIndex??0,parentRowId:Tb(a.parentRowId),siblingIndex:a.siblingIndex,treeLevel:a.treeLevel}))}return n}function Ob(e,t){let n=new Map;for(let r of t){let t=K(e,r);t&&n.set(r,t)}return n}function kb(e,t,n){for(let r of e){let e=t.get(r);if(e===void 0)continue;let i=n.findIndex(e=>e.id===r);if(i>=0&&e!==i)return!0}return!1}function Ab(e,t,n){if(!t||t.size===0)return!1;for(let r of e)if(!Eb(t.get(r),K(n,r)))return!0;return!1}function jb(e,t,n,r,i){return r===i?e<0||Cb(t,n)===e:!1}function Mb(e){return kb(e.rowIds,e.startSourceIndices,e.sourceRows)||Ab(e.rowIds,e.startTreePositions,e.sourceRows)?!0:!e.dropAllowed||e.managed?!1:!jb(e.startDisplayIndex,e.dropInsertIndex,e.rowCount,e.nestUnderRowId,e.startNestUnderRowId)}function Nb(e){return e.fromIndex!==e.toIndex||!Eb(e.startTreePosition,e.currentTreePosition)}function Pb(e,t){let n=e[t];if(!n)return t;let r=n.treeLevel??0,i=t;for(let n=t+1;n<e.length&&!((e[n]?.treeLevel??0)<=r);n+=1)i=n;return i}function Fb(e,t){let n=e[t]?.treeLevel??0;for(let r=t-1;r>=0;--r)if((e[r]?.treeLevel??0)===n)return r;return-1}function Ib(e){let t=e.displayRows.findIndex(t=>t.id===e.rowId);if(t<0)return null;let n=e.displayRows[t];if(e.action===`promote`){let r=n.parentRowId;if(r==null){let n=Fb(e.displayRows,t);if(n<0)return null;let r=e.displayRows[n];return{kind:`wrapPreviousSibling`,movingRowId:e.rowId,previousSiblingRowId:r.id,displayInsertIndex:n}}let i=e.displayRows.findIndex(e=>e.id===r);if(i<0)return null;let a=e.displayRows[i];return{kind:`outdent`,movingRowId:e.rowId,nestUnderRowId:a.parentRowId??null,displayInsertIndex:Pb(e.displayRows,i)+1}}let r=Fb(e.displayRows,t);if(r<0)return null;let i=e.displayRows[r];return{kind:`outdent`,movingRowId:e.rowId,nestUnderRowId:i.id,displayInsertIndex:Pb(e.displayRows,r)+1}}function Lb(e){return pb(e.sourceRows,e.displayRows,e.getRowById,[e.move.movingRowId],e.move.displayInsertIndex,e.getDataPath,{nestUnderRowId:e.move.nestUnderRowId})}function Rb(e){let t=Ib({action:e.action,rowId:e.rowId,displayRows:e.displayRows});return t?t.kind===`wrapPreviousSibling`?yb({sourceRows:e.sourceRows,rowId:t.movingRowId,previousSiblingRowId:t.previousSiblingRowId,getDataPath:e.getDataPath,setDataPath:e.setDataPath??(()=>{})})!=null:Lb({sourceRows:e.sourceRows,displayRows:e.displayRows,getRowById:e.getRowById,getDataPath:e.getDataPath,move:t}):!1}function zb(e){return{promote:Rb({...e,action:`promote`}),demote:Rb({...e,action:`demote`})}}function Bb(e){let t=[];return e.promote&&t.push(`promote`),e.demote&&t.push(`demote`),t}function Vb(e,t,n){return{displayIndex:n,...K(e,t)??{}}}function Hb(e){let t=new Set([e.leaderRowId]);for(let n of e.moves)t.add(n.rowId);for(let n of e.hierarchyChanges??[])t.add(n.rowId);return[...t]}function Ub(e){let t=Ib({action:e.action,rowId:e.rowId,displayRows:e.displayRows});if(!t)return{ok:!1};let n=Wb(e);return n?{ok:!0,plan:{rowIds:[e.rowId],leaderRowId:e.rowId,rows:n.rows,moves:n.moves,displayIndex:t.displayInsertIndex,treeDrop:Vb(n.rows,e.rowId,t.displayInsertIndex),hierarchyChanges:Db(e.sourceRows,n.rows)}}:{ok:!1}}function Wb(e){let t=Ib({action:e.action,rowId:e.rowId,displayRows:e.displayRows});return t?t.kind===`wrapPreviousSibling`?yb({sourceRows:e.sourceRows,rowId:t.movingRowId,previousSiblingRowId:t.previousSiblingRowId,getDataPath:e.getDataPath,setDataPath:e.setDataPath}):bb({sourceRows:e.sourceRows,displayRows:e.displayRows,rowIds:[t.movingRowId],displayInsertIndex:t.displayInsertIndex,getDataPath:e.getDataPath,setDataPath:e.setDataPath,nestUnderRowId:t.nestUnderRowId}):null}function Gb(e,t,n){return ud(e,t,n)??{displayIndex:n}}function Kb(e,t,n,r,i){for(let a of t.moves)e(Ma(a.rowId,a.fromIndex,a.toIndex,r,i,Gb(t.rows,a.rowId,n)))}function qb(e,t,n){let r=e.findIndex(e=>e.id===t);if(r<0)return null;let i=$u(n,e.length);if(r===i)return null;let a=[...e],[o]=a.splice(r,1);return a.splice(i,0,o),{rows:a,fromIndex:r,toIndex:i}}function Jb(e,t,n){let r=new Set(t),i=e.filter(e=>r.has(e.id));if(i.length===0||i.length!==t.length)return null;let a=new Map;for(let t=0;t<e.length;t++){let n=e[t];r.has(n.id)&&a.set(n.id,t)}let o=e.filter(e=>!r.has(e.id)),s=Math.max(0,Math.min(n,o.length)),c=[...o.slice(0,s),...i,...o.slice(s)],l=[];for(let e of i){let t=a.get(e.id),n=c.findIndex(t=>t.id===e.id);t==null||n<0||t===n||l.push(ld(e.id,t,n))}return l.length===0?null:{rows:c,moves:l}}var Yb=class{deps;constructor(e){this.deps=e}rejectIfSortOrFilterActive(){return this.deps.isSortOrFilterActive()?{moved:!1,reason:ka}:null}commitPlan(e){if(this.deps.setSourceRows(e.rows),e.treeDisplayInsertIndex!=null){Kb(this.deps.emitRowMoved,{rows:e.rows,moves:[...e.moves]},e.treeDisplayInsertIndex,e.source,e.finished);return}for(let t of e.moves)this.deps.emitRowMoved(Ma(t.rowId,t.fromIndex,t.toIndex,e.source,e.finished))}applyOrDefer(e,t,n){return t?{...n,commitPlan:e}:(this.commitPlan(e),n)}moveRow(e,t=`api`){let n=this.rejectIfSortOrFilterActive();if(n)return n;let r=e.indexMode??`source`,i=Xu({sourceRows:this.deps.getSourceRows(),displayRows:this.deps.getDisplayRows(),sortModelLength:this.deps.getSortModelLength(),filterModelKeyCount:this.deps.getFilterModelKeyCount()}),a=this.deps.getSortModelLength()>0,o=ed(e.toIndex,r,i,a);if(o==null)return{moved:!1,reason:`invalid move target index`};let s=this.deps.getSourceRows(),c=s.findIndex(t=>t.id===e.rowId);if(c<0)return{moved:!1,reason:`row "${e.rowId}" not found`};let l=cd({active:this.deps.isRowGroupingActive?.()??!1,sourceRows:s,rowIds:[e.rowId],targetSourceIndex:o});if(!l.allowed)return{moved:!1,fromIndex:c,reason:l.reason};let u=md({active:this.deps.isTreeActive?.()??!1,sourceRows:s,rowIds:[e.rowId],targetSourceIndex:o});if(!u.allowed)return{moved:!1,fromIndex:c,reason:u.reason};let d=td(s,[e.rowId]);if(typeof d==`string`&&(this.deps.isRowGroupingActive?.()??!1)){if(r===`display`)return this.finishGroupedDisplayMove(s,[e.rowId],e.rowId,e.toIndex,d,t,e.finished??!0,c,e.deferCommit);let n=qb(s,e.rowId,o);if(!n)return{moved:!1,fromIndex:c,toIndex:c};let i=e.finished??!0,a=ld(e.rowId,n.fromIndex,n.toIndex);return this.applyOrDefer({rows:n.rows,moves:[a],source:t,finished:i},e.deferCommit,{moved:!0,fromIndex:n.fromIndex,toIndex:n.toIndex,moves:[a]})}let f=dd(s,[e.rowId]);if((typeof f==`string`||f===null)&&this.deps.isTreeActive?.()){if(r===`display`)return this.finishTreeDisplayMove(s,[e.rowId],e.rowId,e.toIndex,f,t,e.finished??!0,c,e.deferCommit);let n=pd(s,[e.rowId],o,f),i=_d({sourceRows:s,rowIds:[e.rowId],withinSiblingInsertIndex:n,parentRowId:f});if(!i)return{moved:!1,fromIndex:c,toIndex:c};let a=e.finished??!0,l=i.moves[0]??ld(e.rowId,c,c);return this.applyOrDefer({rows:i.rows,moves:i.moves,source:t,finished:a},e.deferCommit,{moved:!0,fromIndex:l.fromIndex,toIndex:l.toIndex,moves:i.moves})}let p=qb(s,e.rowId,o);if(!p)return{moved:!1,fromIndex:c,toIndex:c};let m=e.finished??!0,h=ld(e.rowId,p.fromIndex,p.toIndex);return this.applyOrDefer({rows:p.rows,moves:[h],source:t,finished:m},e.deferCommit,{moved:!0,fromIndex:p.fromIndex,toIndex:p.toIndex,moves:[h]})}moveRows(e,t=`api`){if(e.rowIds.length===0)return{moved:!1,reason:`no rows to move`};let n=this.rejectIfSortOrFilterActive();if(n)return n;if((this.deps.isRowGroupingActive?.()??!1)&&e.displayInsertIndex!=null)return this.moveRowsByGroupedDisplayInsert(e,t);if((this.deps.isTreeActive?.()??!1)&&e.displayInsertIndex!=null)return this.moveRowsByTreeDisplayInsert(e,t);if(e.rowIds.length===1)return this.moveRow({rowId:e.rowIds[0],toIndex:e.toIndex,indexMode:e.indexMode,finished:e.finished,deferCommit:e.deferCommit},t);let r=e.indexMode??`source`,i=Xu({sourceRows:this.deps.getSourceRows(),displayRows:this.deps.getDisplayRows(),sortModelLength:this.deps.getSortModelLength(),filterModelKeyCount:this.deps.getFilterModelKeyCount()}),a=this.deps.getSortModelLength()>0,o=ed(e.toIndex,r,i,a);if(o==null)return{moved:!1,reason:`invalid move target index`};let s=this.deps.getSourceRows(),c=ju(s.length,e.rowIds,e.leaderRowId,o),l=cd({active:this.deps.isRowGroupingActive?.()??!1,sourceRows:s,rowIds:e.rowIds,targetSourceIndex:c});if(!l.allowed)return{moved:!1,reason:l.reason};let u=md({active:this.deps.isTreeActive?.()??!1,sourceRows:s,rowIds:e.rowIds,targetSourceIndex:c});if(!u.allowed)return{moved:!1,reason:u.reason};let d=dd(s,e.rowIds);if((typeof d==`string`||d===null)&&(this.deps.isTreeActive?.()??!1)){let n=pd(s,e.rowIds,c,d),r=_d({sourceRows:s,rowIds:e.rowIds,withinSiblingInsertIndex:n,parentRowId:d});if(!r)return{moved:!1,moves:[]};let i=e.finished??!0,a=r.moves.find(t=>t.rowId===e.leaderRowId);return this.applyOrDefer({rows:r.rows,moves:r.moves,source:t,finished:i},e.deferCommit,{moved:!0,fromIndex:a?.fromIndex,toIndex:a?.toIndex,moves:r.moves})}let f=Jb(s,e.rowIds,c);if(!f)return{moved:!1,moves:[]};let p=e.finished??!0,m=f.moves.find(t=>t.rowId===e.leaderRowId);return this.applyOrDefer({rows:f.rows,moves:f.moves,source:t,finished:p},e.deferCommit,{moved:!0,fromIndex:m?.fromIndex,toIndex:m?.toIndex,moves:f.moves})}moveRowsByGroupedDisplayInsert(e,t){let n=this.deps.getSourceRows(),r=td(n,e.rowIds);if(r===`mixed`)return{moved:!1,reason:`selected rows must belong to the same group`};if(r===`missing`)return{moved:!1,reason:`cannot move non-leaf rows while row grouping is active`};if(r===null)return{moved:!1,reason:`group path missing on source rows`};let i=ad({sourceRows:n,displayRows:this.deps.getDisplayRows(),rowIds:e.rowIds,displayInsertIndex:e.displayInsertIndex,groupPath:r});if(!i)return{moved:!1,moves:[]};let a=e.finished??!0,o=i.moves.find(t=>t.rowId===e.leaderRowId);return this.applyOrDefer({rows:i.rows,moves:i.moves,source:t,finished:a,treeDisplayInsertIndex:e.displayInsertIndex},e.deferCommit,{moved:!0,fromIndex:o?.fromIndex,toIndex:o?.toIndex,moves:i.moves})}finishGroupedDisplayMove(e,t,n,r,i,a,o,s,c){let l=this.deps.getDisplayRows(),u=l.findIndex(e=>e.id===n),d=$u(r,l.length),f=ad({sourceRows:e,displayRows:l,rowIds:t,displayInsertIndex:u>=0&&u<d?d+1:d,groupPath:i});if(!f)return{moved:!1,fromIndex:s,toIndex:s};let p=f.moves,m=p.find(e=>e.rowId===n);return this.applyOrDefer({rows:f.rows,moves:p,source:a,finished:o},c,{moved:!0,fromIndex:m?.fromIndex??s,toIndex:m?.toIndex??s,moves:p})}moveRowsByTreeDisplayInsert(e,t){let n=this.deps.getSourceRows(),r=dd(n,e.rowIds);if(r===`mixed`)return{moved:!1,reason:`selected rows must belong to the same tree parent`};if(r===`missing`)return{moved:!1,reason:`cannot move non-tree rows while tree mode is active`};if(this.deps.getTreeDragScope?.()===`hierarchy`){let r=this.deps.getDataPath?.(),i=this.deps.setDataPath?.();if(!r||!i)return{moved:!1,reason:`hierarchy tree drag requires getDataPath and setDataPath`};let a=bb({sourceRows:n,displayRows:this.deps.getDisplayRows(),rowIds:e.rowIds,displayInsertIndex:e.displayInsertIndex,getDataPath:r,setDataPath:i,nestUnderRowId:e.treeNestUnderRowId});if(!a)return{moved:!1,moves:[]};let o=e.finished??!0,s=a.moves.find(t=>t.rowId===e.leaderRowId);return this.applyOrDefer({rows:a.rows,moves:a.moves,source:t,finished:o,treeDisplayInsertIndex:e.displayInsertIndex},e.deferCommit,{moved:!0,fromIndex:s?.fromIndex,toIndex:s?.toIndex,moves:a.moves})}let i=vd({sourceRows:n,displayRows:this.deps.getDisplayRows(),rowIds:e.rowIds,displayInsertIndex:e.displayInsertIndex,parentRowId:r});if(!i)return{moved:!1,moves:[]};let a=e.finished??!0,o=i.moves.find(t=>t.rowId===e.leaderRowId);return this.applyOrDefer({rows:i.rows,moves:i.moves,source:t,finished:a,treeDisplayInsertIndex:e.displayInsertIndex},e.deferCommit,{moved:!0,fromIndex:o?.fromIndex,toIndex:o?.toIndex,moves:i.moves})}finishTreeDisplayMove(e,t,n,r,i,a,o,s,c){let l=this.deps.getDisplayRows(),u=l.findIndex(e=>e.id===n),d=$u(r,l.length),f=vd({sourceRows:e,displayRows:l,rowIds:t,displayInsertIndex:u>=0&&u<d?d+1:d,parentRowId:i});if(!f)return{moved:!1,fromIndex:s,toIndex:s};let p=f.moves,m=p.find(e=>e.rowId===n);return this.applyOrDefer({rows:f.rows,moves:p,source:a,finished:o},c,{moved:!0,fromIndex:m?.fromIndex??s,toIndex:m?.toIndex??s,moves:p})}};function Xb(e,t,n){return{displayIndex:n,...K(e,t)??{}}}function Zb(e,t,n){let r=e.isTreeActive?Db(e.sourceRows,t.rows):void 0;if(t.moves.length===0&&(r?.length??0)===0)return{ok:!1,reason:`no row order or hierarchy change`};let i=n??e.leaderRowId;return{ok:!0,plan:{rowIds:[...e.rowIds],leaderRowId:e.leaderRowId,rows:t.rows,moves:t.moves,displayIndex:e.displayInsertIndex,treeDrop:e.isTreeActive?Xb(t.rows,i,e.displayInsertIndex):{displayIndex:e.displayInsertIndex},hierarchyChanges:r}}}function Qb(e){let t=td(e.sourceRows,e.rowIds);if(t===`mixed`)return{ok:!1,reason:`selected rows must belong to the same group`};if(t===`missing`)return{ok:!1,reason:`cannot move non-leaf rows while row grouping is active`};if(t===null)return{ok:!1,reason:`group path missing on source rows`};let n=ad({sourceRows:e.sourceRows,displayRows:e.displayRows,rowIds:e.rowIds,displayInsertIndex:e.displayInsertIndex,groupPath:t});return n?Zb(e,n):{ok:!1,reason:`invalid grouped display drop`}}function $b(e){let t=dd(e.sourceRows,e.rowIds);if(t===`mixed`)return{ok:!1,reason:`selected rows must belong to the same tree parent`};if(t===`missing`)return{ok:!1,reason:`cannot move non-tree rows while tree mode is active`};if(e.treeDragScope===`hierarchy`){let t=e.getDataPath,n=e.setDataPath;if(!t||!n)return{ok:!1,reason:`hierarchy tree drag requires getDataPath and setDataPath`};let r=bb({sourceRows:e.sourceRows,displayRows:e.displayRows,rowIds:e.rowIds,displayInsertIndex:e.displayInsertIndex,getDataPath:t,setDataPath:n,nestUnderRowId:e.treeNestUnderRowId});return r?Zb(e,r):{ok:!1,reason:`invalid tree hierarchy display drop`}}let n=vd({sourceRows:e.sourceRows,displayRows:e.displayRows,rowIds:e.rowIds,displayInsertIndex:e.displayInsertIndex,parentRowId:t});return n?Zb(e,n):{ok:!1,reason:`invalid tree sibling display drop`}}function ex(e){let t=e.displayRows.length,n=Cb(e.displayInsertIndex,t),r=e.displayRows.findIndex(t=>t.id===e.leaderRowId);if(r>=0&&n===r)return{ok:!1,reason:`no row order change`};let i=e.sortModelLength>0,a=Xu({sourceRows:e.sourceRows,displayRows:e.displayRows,sortModelLength:e.sortModelLength,filterModelKeyCount:e.filterModelKeyCount}),o=ed(n,a.hasSortOrFilter&&!i?`display`:`source`,a,i);if(o==null)return{ok:!1,reason:`display index mode is not allowed while sort is active`};if(e.rowIds.length===1){let t=qb(e.sourceRows,e.rowIds[0],o);return t?Zb(e,{rows:t.rows,moves:[ld(e.rowIds[0],t.fromIndex,t.toIndex)]}):{ok:!1,reason:`no row order change`}}let s=ju(e.sourceRows.length,e.rowIds,e.leaderRowId,o),c=Jb(e.sourceRows,e.rowIds,s);return c?Zb(e,c):{ok:!1,reason:`no row order change`}}function tx(e){return e.rowIds.length===0?{ok:!1,reason:`no rows to move`}:e.displayInsertIndex<0?{ok:!1,reason:`invalid display insert index`}:e.isRowGroupingActive?Qb(e):e.isTreeActive?$b(e):ex(e)}var nx=class{deps;phase=`idle`;nextCommitId=0;commitController=null;committingTarget=null;constructor(e){this.deps=e}isCommitting(){return this.phase===`committing`}getCommittingTarget(){return this.committingTarget}abort(){this.commitController?.abort(),this.commitController=null,this.phase=`idle`,this.setCommitVisual(null)}destroy(){this.abort()}async commit(t){let n=this.deps.persistMove();if(!n){this.deps.emitFinished(Fa({commitId:-1,leaderRowId:t.plan.leaderRowId,committed:!1,reason:`asyncRowMutation.move is required for deferred row drag commit`}));return}let r=++this.nextCommitId,i=e.s(r,this.commitController);this.commitController=i,this.phase=`committing`,this.setCommitVisual({rowIds:t.rowIds}),this.deps.emitStarted(Pa({rowIds:t.rowIds,leaderRowId:t.plan.leaderRowId,displayIndex:t.plan.displayIndex,treeDrop:t.plan.treeDrop}));let a={ok:!1};try{if(a=await n(Ia(t.plan,t.nestUnderRowId,i.context)),i.context.commitId!==r)return}catch(t){if(e.c(t))a={ok:!1,aborted:!0};else throw t}finally{this.commitController===i&&(this.commitController=null),this.phase=`idle`,this.setCommitVisual(null)}i.context.commitId===r&&(this.deps.emitFinished(Fa({commitId:r,leaderRowId:t.plan.leaderRowId,committed:a.ok,aborted:a.ok?void 0:a.aborted,reason:a.ok?void 0:a.reason})),a.ok&&(this.deps.applyPlan(t.plan),this.deps.emitRowDragEnd(Na(t.plan.leaderRowId,t.plan.displayIndex,!0,t.rowIds,t.treeContext))))}setCommitVisual(e){this.committingTarget=e,this.deps.setCommittingVisual(e)}};function rx(e,n){return e.remove?.length?e.remove.map(e=>{if(typeof e==`string`)return e;let r=e[n];if(r==null)throw new t.p(`Missing rowKey "${n}" in remove item`);return String(r)}):[]}function ix(e,t,n,r){let i=e[t];return i==null?r?.find(t=>t.data===e&&t.isTransient):n(String(i))}function ax(e,t,n){return!e.add?.length||!n?.rows?.length?e:{...e,add:e.add.map((e,r)=>{let i=n.rows?.[r];if(!i)return e;let a={...nu(e,t)},o=i.data?{...a,...i.data}:a;return i.businessId!==void 0&&(o[t]=i.businessId),tu(e,t)?{...e,data:o}:o})}}async function ox(e,n){try{return await n()}catch(n){throw n instanceof t.p?n:new t.p(`${e} persist failed`,n)}}async function sx(e,n){let{handlers:r,rowKey:i,getRowById:a,sourceRows:o,signal:s=new AbortController().signal}=n;if(!r?.add&&!r?.update&&!r?.remove)return e;let c=e;if(r.remove&&e.remove?.length){let t=rx(e,i),n=t.map(e=>{let t=a(e);return{rowId:e,data:t?{...t.data}:{}}});await ox(`remove`,()=>r.remove({rowIds:t,rows:n,signal:s}))}if(r.update&&e.update?.length){let n=e.update.map(e=>{let n,r;if(iu(e)?(n=a(e.rowId),r=e.data):(r=e,n=ix(r,i,a,o)),!n)throw new t.p(`Update target row not found for rowKey "${i}"`);return{rowId:n.id,data:r}});await ox(`update`,()=>r.update({rows:n,signal:s}))}if(r.add&&e.add?.length){let t=e.add.map(e=>({data:nu(e,i)})),n=e.add[0],a=n?ru(n,i):void 0,o=n&&tu(n,i)?n.indexMode:void 0,l=await ox(`add`,()=>r.add({rows:t,index:a,indexMode:o,signal:s}));c=ax(c,i,l)}return c}function cx(e,t,n){return{rowIds:e.rowIds,leaderRowId:e.leaderRowId,toIndex:e.toIndex,indexMode:e.indexMode,moves:e.moves,rows:t,source:e.source,signal:n,displayIndex:e.displayIndex,hierarchyChanges:e.hierarchyChanges,parentRowId:e.parentRowId,siblingIndex:e.siblingIndex,treeLevel:e.treeLevel,nestUnderRowId:e.nestUnderRowId}}async function lx(e,t){let{handlers:n,getRowById:r,signal:i=new AbortController().signal}=t;if(!n?.move)return;let a=e.rowIds.map(e=>{let t=r(e);return{rowId:e,data:t?{...t.data}:{}}});await ox(`move`,()=>n.move(cx(e,a,i)))}async function ux(n,r){let i=n.moves.find(e=>e.rowId===n.leaderRowId)?.toIndex??n.displayIndex;try{return await lx({rowIds:n.rowIds,leaderRowId:n.leaderRowId,toIndex:i,indexMode:`source`,moves:n.moves,source:`uiRowDrag`,displayIndex:n.displayIndex,hierarchyChanges:n.hierarchyChanges,parentRowId:n.parentRowId,siblingIndex:n.siblingIndex,treeLevel:n.treeLevel,nestUnderRowId:n.nestUnderRowId},{...r,signal:n.signal}),{ok:!0}}catch(r){if(e.c(r)||n.signal.aborted)return{ok:!1,reason:`aborted`,aborted:!0};if(r instanceof t.p)return{ok:!1,reason:r.message};throw r}}function dx(e,t=6){let n=e;for(;n;){let e=getComputedStyle(n).getPropertyValue(`--mg-cell-comment-indicator-size`).trim();if(e){let t=parseFloat(e);if(Number.isFinite(t))return t}n=n.parentElement}return t}function fx(e,t,n=0){let r=t,i=t,a=e.right-n,o=e.top+n,s=a-r;return{x:s,y:o,left:s,top:o,right:a,bottom:o+i,width:r,height:i,toJSON:()=>({})}}function px(e,t,n){if(!e.classList.contains(`mg-cell--has-comment`)&&!e.classList.contains(`mg-cell--comment-empty`))return!1;let r=fx(e.getBoundingClientRect(),dx(e));return t>=r.left&&t<=r.right&&n>=r.top&&n<=r.bottom}var mx=`mg-cell-comment-popup__textarea`,hx=`mg-cell-comment-popup__actions`,gx=`mg-cell-comment-popup__btn--save`,_x=`mg-cell-comment-popup__btn--delete`,vx=`mg-cell-comment-popup__btn--cancel`;function yx(e,t=8){let n=e;for(;n;){let e=getComputedStyle(n).getPropertyValue(`--mg-spacing`).trim();if(e){let t=parseFloat(e);if(Number.isFinite(t))return t}n=n.parentElement}return t}function bx(e){return{viewportPadding:yx(e)}}function xx(e,t,n,r=bx(null),i=6){let{viewportPadding:a}=r,o=e.right,s=e.top;return o+t>window.innerWidth-a&&(o=e.left-t),o=Math.max(a,Math.min(o,window.innerWidth-t-a)),s=Math.max(a,Math.min(s,window.innerHeight-n-a)),{left:o,top:s}}function Sx(e,t){if(!t)return 4;let n=e?e.split(`
4
4
  `).length:1;return Math.max(1,Math.min(n,12))}var Cx=class{getMountEl;rootEl=null;textareaEl=null;anchorEl=null;options=null;committing=!1;textareaReadOnly=!1;saveButton=null;deleteButton=null;cancelButton=null;constructor(e=()=>document.body){this.getMountEl=e}onWindowKeyDown=e=>{if(e.key===`Escape`){if(this.committing){e.preventDefault(),e.stopPropagation();return}e.preventDefault(),e.stopPropagation(),this.close()}};get isOpen(){return this.rootEl!=null}isCommitting(){return this.committing}getAnchorEl(){return this.anchorEl}getRootEl(){return this.rootEl}open(e){this.close(),this.options=e,this.anchorEl=e.anchorEl,this.anchorEl.dataset.commentOpen=`true`;let t=e.readOnly===!0||e.mode===`view`,n=e.mode??(e.comment?.text?`edit`:`create`);this.rootEl=document.createElement(`div`),this.rootEl.className=Ao,this.rootEl.classList.toggle(jo,t),this.rootEl.dataset.mode=n,this.textareaEl=document.createElement(`textarea`),this.textareaEl.className=mx,this.textareaEl.value=e.comment?.text??``,this.textareaReadOnly=t,this.textareaEl.readOnly=t,this.textareaEl.rows=Sx(e.comment?.text,t),this.textareaEl.setAttribute(`aria-label`,t?`单元格批注`:`编辑单元格批注`),this.rootEl.append(this.textareaEl),t?this.rootEl.append(this.createActions(`view`,!!e.comment?.text)):this.rootEl.append(this.createActions(n,!!e.comment?.text)),this.getMountEl().append(this.rootEl),this.reposition(),window.addEventListener(`keydown`,this.onWindowKeyDown,!0),t||(this.textareaEl.focus(),this.textareaEl.setSelectionRange(this.textareaEl.value.length,this.textareaEl.value.length))}updatePosition(){this.reposition()}close(e=!1){if(this.committing&&!e)return;window.removeEventListener(`keydown`,this.onWindowKeyDown,!0),this.anchorEl&&=(delete this.anchorEl.dataset.commentOpen,null),this.rootEl?.remove(),this.rootEl=null,this.textareaEl=null,this.saveButton=null,this.deleteButton=null,this.cancelButton=null,this.committing=!1,this.textareaReadOnly=!1;let t=this.options?.onClose;this.options=null,t?.()}reposition(){if(!this.rootEl||!this.anchorEl)return;let e=Math.max(this.rootEl.offsetWidth,280),t=this.rootEl.offsetHeight,n=bx(this.anchorEl),r=dx(this.anchorEl),i=xx(this.anchorEl.getBoundingClientRect(),e,t,n,r);this.rootEl.style.position=`fixed`,this.rootEl.style.left=`${i.left}px`,this.rootEl.style.top=`${i.top}px`,this.rootEl.style.minWidth=`280px`,this.rootEl.style.removeProperty(`min-height`)}createActions(e,t){let n=document.createElement(`div`);if(n.className=hx,e!==`view`){let e=document.createElement(`button`);e.type=`button`,e.className=gx,e.textContent=`保存`,e.addEventListener(`click`,()=>{this.handleSave()}),n.append(e),this.saveButton=e}if(t&&e===`edit`){let e=document.createElement(`button`);e.type=`button`,e.className=_x,e.textContent=`删除`,e.addEventListener(`click`,()=>{this.handleDelete()}),n.append(e),this.deleteButton=e}let r=document.createElement(`button`);return r.type=`button`,r.className=vx,r.textContent=e===`view`?`关闭`:`取消`,r.addEventListener(`click`,()=>{this.close()}),n.append(r),this.cancelButton=r,n}async handleSave(){let e=this.textareaEl?.value.trim()??``;if(!e){this.close();return}await this.runAction(`save`,()=>this.options?.onSave?.(e))}async handleDelete(){await this.runAction(`delete`,()=>this.options?.onDelete?.())}async runAction(e,t){if(this.committing||!this.isOpen)return;this.committing=!0,this.setCommittingVisual(!0,e);let n=!1;try{if(await t()===!1)return;n=!0,this.committing=!1,this.close()}catch{}finally{!n&&this.isOpen&&(this.committing=!1,this.setCommittingVisual(!1))}}setCommittingVisual(e,t){if(this.rootEl?.classList.toggle(Mo,e),this.textareaEl&&(this.textareaEl.readOnly=e||this.textareaReadOnly),this.saveButton?.toggleAttribute(`disabled`,e),this.deleteButton?.toggleAttribute(`disabled`,e),this.cancelButton?.toggleAttribute(`disabled`,e),e&&t===`save`){this.saveButton.textContent=`保存中...`;return}if(e&&t===`delete`){this.deleteButton.textContent=`删除中...`;return}this.saveButton&&(this.saveButton.textContent=`保存`),this.deleteButton&&(this.deleteButton.textContent=`删除`)}},wx=class{deps;datasourceInitialized=!1;presenceCache=new Map;popup;constructor(e){this.deps=e,this.popup=new Cx(()=>e.getMountEl())}getPopup(){return this.popup}get active(){return Io(this.deps.getOptions().cellCommentsDataSource)&&!!this.deps.getRowKey()}init(e){let t=this.deps.getOptions().cellCommentsDataSource;Go(Io(t),this.deps.getRowKey()),Io(t)&&(this.datasourceInitialized||=(t?.init?.({api:e}),!0))}destroy(){this.popup.close(!0);let e=this.deps.getOptions().cellCommentsDataSource;this.datasourceInitialized&&=(e?.destroy?.(),!1),this.presenceCache.clear()}resetDatasourceLifecycle(){let e=this.deps.getOptions().cellCommentsDataSource;this.datasourceInitialized&&=(e?.destroy?.(),!1),this.presenceCache.clear()}getComment(e,t){let n=this.resolveCellParams(e,t);if(!n)return;let r=this.deps.getOptions().cellCommentsDataSource?.getComment(n);return Tx(r)}hasComment(e,t){let n=Wo(e,t),r=this.presenceCache.get(n);if(r!=null)return r;let i=Ho(this.getComment(e,t));return this.presenceCache.set(n,i),i}getCachedHasComment(e,t){return this.presenceCache.get(Wo(e,t))}resolveInteraction(e,t){let n=this.resolveCellParams(e,t);if(!n)return{canView:!1,canCreate:!1,canEdit:!1,canDelete:!1};let r=this.getComment(e,t);return Vo(Bo({gridSuppress:this.deps.getOptions().suppressCellComments,columnSuppress:n.column.suppressCellComments,colId:t,rowId:n.rowId,rowKind:N(n.rowNode.rowKind),data:n.data,hasExistingComment:Ho(r)}),r)}async setComment(e,n,r,i,a){if(!this.active)return!1;let o=this.resolveCellParams(e,n);if(!o)return!1;let s=t.m(e),c=r??void 0,l=c==null;if(i===`ui`&&!a?.bypassSuppress){let e=this.resolveInteraction(s,n);if(l&&!e.canDelete)return!1;if(!l){if(this.getComment(s,n)){if(!e.canEdit)return!1}else if(!e.canCreate)return!1}}i===`api`&&this.deps.getOptions().suppressCellComments&&a?.bypassSuppress;let u=this.deps.getOptions().cellCommentsDataSource;if(!u)return!1;await u.setComment({...o,comment:c}),this.invalidateCache(s,n);let d=Uo(s,n,c??null,i);return this.deps.onCommentChanged?.(d),this.deps.onCommentsRefresh?.({rowIds:[s],colIds:[n]}),!0}refreshPresenceCache(e){for(let t of e){let e=Wo(t.rowId,t.colId);this.presenceCache.set(e,Ho(this.getComment(t.rowId,t.colId)))}}invalidateCache(e,n){if(e==null&&n==null){this.presenceCache.clear();return}if(e!=null&&n!=null){this.presenceCache.delete(Wo(e,n));return}let r=e==null?n==null?null:`::${n}`:`${t.m(e)}::`;if(r)for(let t of[...this.presenceCache.keys()])(e!=null&&t.startsWith(r)||n!=null&&t.endsWith(r))&&this.presenceCache.delete(t)}requestRefresh(e){if(e?.rowIds?.length||e?.colIds?.length){if(e.rowIds?.length&&e.colIds?.length){for(let n of e.rowIds)if(n!=null)for(let r of e.colIds)this.invalidateCache(t.m(n),r)}else if(e.rowIds?.length)for(let n of e.rowIds)n!=null&&this.invalidateCache(t.m(n));else if(e.colIds?.length)for(let t of e.colIds)this.invalidateCache(void 0,t)}else this.invalidateCache();this.deps.onCommentsRefresh?.(e)}createHost(){return{active:()=>this.active,hasComment:(e,t)=>this.hasComment(e,t),canCreateComment:(e,t)=>this.resolveInteraction(e,t).canCreate}}openEditor(e){if(!this.active)return!1;let t=this.resolveCellParams(e.rowId,e.colId);if(!t)return!1;let{rowId:n,colId:r}=t,i=this.getComment(n,r),a=Ho(i),o=this.resolveInteraction(n,r),s=Ex(e.preferredMode,a,o,i?.readOnly===!0);if(!s)return!1;let c=s===`view`||i?.readOnly===!0;return this.popup.open({anchorEl:e.anchorEl,comment:i,readOnly:c,mode:s,onSave:async e=>{let t=this.getComment(n,r);return this.setComment(n,r,{...t,text:e},`ui`)},onDelete:async()=>this.setComment(n,r,null,`ui`),onClose:e.onPopupClose}),!0}closeEditor(){this.popup.close()}getOpenEditorCell(){let e=this.popup.getAnchorEl();if(!e)return null;let t=e.closest(`.mg-row`)?.dataset.rowId,n=e.dataset.colId;return!t||!n?null:{rowId:t,colId:n}}resolveCellParams(e,n){if(!this.active)return;let r=t.m(e),i=this.deps.getRowNode(r),a=this.deps.getColumn(n);if(!(!i||!a))return{rowId:r,colId:n,data:i.data,rowNode:i,column:a}}};function Tx(e){if(e!=null)return e}function Ex(e,t,n,r){if(e===`create`){if(n.canCreate)return`create`;if(t){if(n.canEdit&&!r)return`edit`;if(n.canView)return`view`}return null}return e===`edit`?n.canEdit?`edit`:n.canView?`view`:null:e===`view`?n.canView?`view`:null:t?n.canEdit&&!r?`edit`:n.canView?`view`:null:n.canCreate?`create`:null}function Dx(e,t){let n=e.suppressPaste;return n==null||n===!1?!1:n===!0||n(t)}function Ox(e){let t=e.formattedValue??String(e.value??``),n=Zf(e),r={rowId:e.rowId,rowIndex:e.rowIndex,colId:e.colId,value:e.value,data:e.data,formattedValue:t,size:e.gridSize,context:n},i=e.column?It(e.column,r):void 0;return{...r,cellEditorParams:i,stopEditing:async()=>null,cancelCommit:()=>{},getEditPhase:()=>`idle`,validate:async()=>({valid:!0})}}function kx(e,n,r){let i=e.deps.rowModel.getRowKey(),a=Zf(e.deps),o={rowId:t.T(n,i),rowIndex:n.rowIndex,colId:r.colId,value:H(n,r),data:n.data,formattedValue:Xf(n,r),size:e.deps.gridSize,context:a},s=It(r,o),c={...o,cellEditorParams:s,stopEditing:(t=!0)=>e.stopEditing(!t),cancelCommit:()=>e.cancelCommit(),getEditPhase:()=>e.getEditSessionPhase()},l=Tu(e.deps.cellEditorCacheService,{enableCellEditorCache:e.deps.enableCellEditorCache,rowNode:n,column:r,rowKey:i});return{...c,...l,validate:async t=>{let n=e.deps.rowEditingService.isEditing()?e.deps.rowEditingService.getEditorValue(r.colId):e.deps.editingService.getEditorValue();if(n==null)return{valid:!0};let i={...c,...l,validate:async()=>({valid:!0})},a;try{if(a=_n(n,r,i),cn(a))return{valid:!1,errors:[`Invalid value`]}}catch(e){return{valid:!1,errors:[e instanceof Error?e.message:`Invalid value`]}}return Jf(r,i,a,t?.signal)}}}function Ax(e){return e==null?``:Array.isArray(e)?e.join(`, `):String(e)}function jx(e,t,n){let r=n?.getRowGroupingHost?.();if(r?.active()&&ke(t,e)){let n=sh(e,r,t);return!n.visible||n.label.length===0?``:n.showCount&&n.count>0?`${n.label}${ch(n.count)}`:n.label}let i=n?.getTreeTableHost?.();if(i?.active()&&mh(t,e)){let t=gh(e,i);return t.visible?t.label:``}return null}function Mx(e,t,n,r){return jx(e,t,r)??(t.useFormatterForClipboard===!1?Ax(H(e,t)):Xf(e,t,n))}function Nx(e,t,n,r,i,a){return{rowIndex:e,colId:n.colId,rowNode:t,column:n,value:r,formatValue:e=>Fx(t,n,e),parseValue:e=>Ix(e,n,i)}}function Px(e,t,n,r,i,a,o){return{...Nx(e,t,n,r,a,o),oldValue:i}}function Fx(e,t,n){return t.formatter?t.formatter(e.data,n):Ax(n)}function Ix(e,t,n){return zx(e,t,n)}function Lx(e,t,n,r,i,a,o){let s=Mx(t,n,r,o);return a?Ax(a(Nx(e,t,n,s,i,r))):s}function Rx(e,t,n,r,i,a,o){if(!o)return zx(e,t,i);let s=o(Px(n,r,t,e,i.value,i,a));return cn(s)||t.useParserForClipboard===!1?s:_n(Ax(s),t,i)}function zx(e,t,n){return t.useParserForClipboard===!1?e:_n(e,t,n)}async function Bx(e,t,n,r,i){let a=Rx(n,e,i.rowIndex,i.rowNode,t,i.indexColumnOptions,i.processCellFromClipboard);return cn(a)||await Kf(e,t,a,i.signal??new AbortController().signal)?{status:`blocked`,showBlockedVisual:!0}:Object.is(r,a)?{status:`blocked`,showBlockedVisual:!1}:vn(e,t,a)?{status:`applied`,parsed:a}:{status:`blocked`,showBlockedVisual:!0}}async function Vx(e){if(typeof navigator<`u`&&navigator.clipboard?.writeText)try{return await navigator.clipboard.writeText(e),!0}catch{}let t=globalThis.document;if(!t?.body)return!1;try{let n=t.createElement(`textarea`);n.value=e,n.setAttribute(`readonly`,``),n.style.position=`fixed`,n.style.left=`-9999px`,n.style.top=`0`,t.body.appendChild(n),n.focus(),n.select();let r=t.execCommand(`copy`);return t.body.removeChild(n),r}catch{return!1}}async function Hx(){if(typeof navigator<`u`&&navigator.clipboard?.readText)return navigator.clipboard.readText();throw Error(`Clipboard read unavailable`)}function Ux(e){return/[\t\n\r"]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e}function Wx(e){return e.map(Ux).join(` `)}function Gx(e){return e.map(e=>e.join(`