@agile-team/mach-table 0.38.0 → 0.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +2 -2
  2. package/dist/adapter.cjs +1 -1
  3. package/dist/adapter.d.cts +6 -2
  4. package/dist/adapter.d.ts +6 -2
  5. package/dist/adapter.js +1 -1
  6. package/dist/analysis.cjs +1 -1
  7. package/dist/analysis.d.cts +2 -2
  8. package/dist/analysis.d.ts +2 -2
  9. package/dist/analysis.js +2 -2
  10. package/dist/{api-Bgcy7aRd.d.cts → api-ChEKWrvH.d.cts} +6 -1
  11. package/dist/{api-Bgcy7aRd.d.ts → api-ChEKWrvH.d.ts} +6 -1
  12. package/dist/{configuration-B5dSDN9d.d.ts → configuration-BPj5MIUw.d.ts} +1 -1
  13. package/dist/{configuration-BVWcsdGm.d.cts → configuration-CZm-aiTf.d.cts} +1 -1
  14. package/dist/import.d.cts +1 -1
  15. package/dist/import.d.ts +1 -1
  16. package/dist/index.cjs +6 -6
  17. package/dist/index.d.cts +5 -3
  18. package/dist/index.d.ts +5 -3
  19. package/dist/index.js +6 -6
  20. package/dist/multi-range.cjs +3 -3
  21. package/dist/multi-range.d.cts +1 -1
  22. package/dist/multi-range.d.ts +1 -1
  23. package/dist/multi-range.js +2 -2
  24. package/dist/ordering.cjs +1 -1
  25. package/dist/ordering.d.cts +1 -1
  26. package/dist/ordering.d.ts +1 -1
  27. package/dist/ordering.js +1 -1
  28. package/dist/preferences.d.cts +1 -1
  29. package/dist/preferences.d.ts +1 -1
  30. package/dist/server-side.d.cts +1 -1
  31. package/dist/server-side.d.ts +1 -1
  32. package/dist/{shared-DfLrRGYY.d.cts → shared-BIBSfPcs.d.cts} +1 -1
  33. package/dist/{shared-CLEc9O2p.d.ts → shared-Qnznvth3.d.ts} +1 -1
  34. package/dist/workbench.cjs +1 -1
  35. package/dist/workbench.d.cts +3 -3
  36. package/dist/workbench.d.ts +3 -3
  37. package/dist/workbench.js +1 -1
  38. package/dist/worker.cjs +1 -1
  39. package/dist/worker.d.cts +2 -2
  40. package/dist/worker.d.ts +2 -2
  41. package/dist/worker.js +1 -1
  42. package/package.json +2 -2
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";var lr=Object.defineProperty;var go=Object.getOwnPropertyDescriptor;var yo=Object.getOwnPropertyNames;var vo=Object.prototype.hasOwnProperty;var bo=(n,e)=>{for(var t in e)lr(n,t,{get:e[t],enumerable:!0})},wo=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of yo(e))!vo.call(n,i)&&i!==t&&lr(n,i,{get:()=>e[i],enumerable:!(r=go(e,i))||r.enumerable});return n};var Co=n=>wo(lr({},"__esModule",{value:!0}),n);var Ja={};bo(Ja,{BUILTIN_AGG_FUNCS:()=>ke,DEFAULT_LOCALE:()=>D,EVENT_TYPES:()=>ye,LOCALE_EN:()=>Ti,actionsColumn:()=>ki,advancedFilterCondition:()=>mi,advancedFilterGroup:()=>gi,applyGridViewState:()=>Zr,buildColDefsFromSchema:()=>eo,captureGridViewState:()=>Jr,clearGridState:()=>$n,createActionButtonsRenderer:()=>ge,createAggResolver:()=>lt,createBusinessColumnTypes:()=>uo,createColumnHelper:()=>ro,createEnterprisePreset:()=>no,createGrid:()=>Jn,createGridViewManager:()=>fo,createLocalGridStateStore:()=>Ur,createLocalGridViewStore:()=>Qr,createMachTableCommands:()=>to,createMachTablePreset:()=>Xr,createProgressBarRenderer:()=>br,createRemoteExportRequest:()=>Zn,createRowActionsRenderer:()=>rt,createStatusTagRenderer:()=>vr,defineColumns:()=>io,defineGridOptions:()=>so,defineMachTableConfig:()=>ao,defineMachTablePreset:()=>oo,describeFilter:()=>_t,downloadFile:()=>Ft,dragColumn:()=>Ai,escapeHtml:()=>de,formatText:()=>V,formatTwo:()=>fe,getByPath:()=>H,indexColumn:()=>it,isColDefGroup:()=>pe,isSafePath:()=>Ye,linkRenderer:()=>wr,loadGridState:()=>er,matchLocaleKey:()=>Ze,normalizeAdvancedFilterModel:()=>O,normalizeColumnFilter:()=>Xe,normalizeFilterModel:()=>Y,normalizeGridState:()=>z,normalizeGridViewState:()=>ar,normalizeSavedGridView:()=>we,parseCsv:()=>bt,parseDelimited:()=>wt,parseTsv:()=>vt,resolveGridFeatures:()=>ir,resolveSaveConflict:()=>Tn,resolveTagVariant:()=>Qe,rowActionsColumn:()=>Li,sanitizeFormulaCell:()=>oe,saveGridState:()=>Qt,selectionColumn:()=>Ii,setByPath:()=>ce,toTsv:()=>yt,validateGridOptions:()=>tr,version:()=>Xa});module.exports=Co(Ja);var Be="0.38.0";function M(n,e,t=!1){if(!(typeof n!="number"||!Number.isFinite(n)||n<e))return t?Math.floor(n):n}function N(n){return M(n,0)||void 0}function _e(n){return!n||typeof n.key!="string"||!n.key.trim()?null:{key:n.key.trim(),debounceMs:M(n.debounceMs,0,!0)??160,...n.sections?{sections:[...new Set(n.sections)]}:{},...n.store?{store:n.store}:{}}}function R(n,e,t,r=!1){let i=!1;for(let o of t)(r?Object.prototype.hasOwnProperty.call(n,o):n[o]!=null)&&(e[o]=n[o],i=!0);return i}var dr=new WeakMap,ze=new WeakMap,We=new WeakMap;function Te(n){let e=dr.get(n);return e||(e={},dr.set(n,e)),e}function ur(n){return dr.get(n)}function ri(n,e){e?ze.set(n,e):ze.delete(n)}function ii(n){let e=ze.get(n);return ze.delete(n),e}function ni(n,e){e?We.set(n,e):We.delete(n)}function oi(n){let e=We.get(n);return We.delete(n),e}function cr(n){if(n==null)return"";if(n instanceof Date)return n.toLocaleDateString();if(typeof n=="object")try{return JSON.stringify(n)}catch{return String(n)}return String(n)}function L(n,e){let t=ur(e);if(!t)return;t.flashTimer&&clearTimeout(t.flashTimer),t.flashTimer=void 0;let r=t.destroy;if(t.destroy=void 0,t.refresh=void 0,t.rendererDefinition=void 0,t.rendererRowId=void 0,t.rendererColumnId=void 0,!!r)try{r()}catch(i){n.reportError(i,"cellRenderer.destroy",{colId:e.dataset.colId})}}function si(n,e,t,r,i,o){let s=n.r.tooltipComponent?"":o,a=r.colDef.tooltipValueGetter;if(a)try{s=a({api:n.api,colDef:r.colDef,column:r,node:t,data:t.data,value:i})??o}catch(l){n.reportError(l,"tooltipValueGetter",{colId:r.id,rowId:t.id})}s?e.setAttribute("title",s):e.removeAttribute("title")}function Do(n,e,t,r,i,o){let s=ur(e);if(!s?.refresh||s.rendererDefinition!==i||s.rendererRowId!==t.id||s.rendererColumnId!==r.id)return!1;try{return e.querySelector(":scope > .mach-cell-edit-trigger")?.remove(),s.refresh(o)!==!1}catch(a){return n.reportError(a,"cellRenderer.refresh",{colId:r.id,rowId:t.id}),!1}}function re(n,e,t){return U(n,e,t,n.d(e,t))}function U(n,e,t,r){let i=t.colDef.valueFormatter;if(i)try{let o=i({api:n.api,colDef:t.colDef,column:t,node:e,data:e.data,value:r});return o==null?"":String(o)}catch(o){n.reportError(o,"valueFormatter",{colId:t.id,rowId:e.id})}return cr(r)}function xo(n,e,t,r){let i=r.colDef.cellStyle,o=Te(e),s=o.styleKeys;if(s)for(let d of s)Reflect.set(e.style,d,"");if(!i){o.styleKeys=void 0;return}let a;if(typeof i=="function"){let d=n.d(t,r);try{a=i({api:n.api,colDef:r.colDef,column:r,node:t,data:t.data,value:d,rowIndex:t.rowIndex})}catch(u){n.reportError(u,"cellStyle",{colId:r.id,rowId:t.id}),a=null}}else a=i;if(!a){o.styleKeys=void 0;return}let l=Object.keys(a);for(let d of l)Reflect.set(e.style,d,Reflect.get(a,d));o.styleKeys=l}function Eo(n,e,t,r){let i=n.d(t,r),o=re(n,t,r),s=r.colDef.cellRenderer,a=typeof s=="string"?n.$d(s):s;if(a){let l={api:n.api,colDef:r.colDef,column:r,node:t,data:t.data,value:i,formatted:o,rowIndex:t.rowIndex,rendererParams:r.colDef.cellRendererParams};if(Do(n,e,t,r,a,l)){si(n,e,t,r,i,o);return}L(n,e);let d;try{d=a(l)}catch(u){n.reportError(u,"cellRenderer",{colId:r.id,rowId:t.id}),e.textContent=o;return}if(typeof d=="string")e.textContent=d;else if(d instanceof HTMLElement)e.replaceChildren(d);else if(d&&typeof d=="object"&&d.el instanceof HTMLElement){let u=d;e.replaceChildren(u.el);let c=Te(e);c.destroy=u.destroy,u.refresh&&(c.refresh=h=>u.refresh(h),c.rendererDefinition=a,c.rendererRowId=t.id,c.rendererColumnId=r.id)}else e.textContent=""}else L(n,e),e.textContent=o;si(n,e,t,r,i,o)}function $e(n){let{align:e}=n.colDef;return e==="left"?"mach-cell--left":e==="right"?"mach-cell--right":"mach-cell--center"}function Ro(n,e,t,r,i){let o=r.colDef.cellClass;if(!o)return;if(typeof o=="string"){e.push(o);return}if(Array.isArray(o)){e.push(...o);return}let s={api:n.api,colDef:r.colDef,column:r,node:t,data:t.data,value:i,rowIndex:t.rowIndex};try{let a=o(s);typeof a=="string"?e.push(a):Array.isArray(a)&&e.push(...a)}catch(a){n.reportError(a,"cellClass",{colId:r.id,rowId:t.id})}}function So(n,e,t){e.classList.contains("mach-cell--focus")&&n.push("mach-cell--focus"),e.classList.contains("mach-cell--editing")&&n.push("mach-cell--editing"),t.colDef.wrapText&&n.push("mach-cell--wrap")}function hr(n,e,t,r){let i=n.d(t,r),o=["mach-cell",$e(r)];Ro(n,o,t,r,i),So(o,e,r);let s=o.join(" ");e.className!==s&&(e.className=s)}function Ke(n,e,t,r){Eo(n,e,t,r),hr(n,e,t,r),xo(n,e,t,r)}function De(n,e){return n&&Object.prototype.hasOwnProperty.call(n,e)?n[e]:void 0}function Ue(n,e){if(n==null||n===""||!e||typeof e!="object")return;let t=De(e,String(n));return typeof t=="string"?{color:t}:t}var je=class{constructor(e){this.e=e;this.Un="";this.Lr=!0}jn(){var i;let e=getComputedStyle(this.e.o.root),t=`${e.getPropertyValue("--mach-header-font-weight")||650} ${e.fontSize} ${e.fontFamily}`;this[i="Lr"]||(this[i]=t!==this.Un),this.Un=t;let r=!1;for(let o of this.e.n.u()){if(!this.Lr&&o.minWidth!=null)continue;let s=o.colDef;if(o.minWidth=this.Kd(o),o.manualWidth==null&&s.width==null&&s.autoWidth!==!1&&!o.hasCheckbox&&!o.isDetailToggle){let a=this.Zs(o);r=a!==o.contentWidth||r,o.contentWidth=a}}return this.Lr=!1,r}Qs(e){return this.kr===void 0&&(this.kr=document.createElement("canvas").getContext("2d")),this.kr?(this.kr.font=this.Un,this.kr.measureText(e).width):e.replace(/[^\x00-\xff]/g,"mm").length*7}Kd(e){let t=e.colDef,r=t.headerName??t.field??e.id;return Math.ceil(Math.max(t.minWidth??0,this.Qs(r)+r.length*.15+28+(e.sortable?20:0)+(e.filterable?28:0)+(this.e.r.columnMenu&&!e.hasCheckbox&&!t.suppressColumnMenu?22:0)))}Zs(e){let t=28,r=this.e.i.ge(),i=Math.min(r.length,100);for(let o=0;o<i;o++){let s=r[i===1?0:Math.floor(o*(r.length-1)/(i-1))],a=this.e.d(s,e),l=Ue(a,e.colDef.status)?.label??U(this.e,s,e,a);t=Math.max(t,this.Qs(l.slice(0,128))+(e.colDef.status?44:28))}return Math.ceil(Math.min(N(e.colDef.maxWidth)??360,t))}};function f(n,e,t){let r=document.createElement(n);if(e&&(r.className=e),t)for(let i of Object.keys(t))r.setAttribute(i,t[i]);return r}function j(n,e,t){let r=f("button",n);return r.type="button",r.textContent=e,r.addEventListener("click",t),r}function I(n,e){if(n.classList.add("mach-portal"),!e)return;let t=window.getComputedStyle(e);for(let r=0;r<t.length;r++){let i=t.item(r);if(!i.startsWith("--mach-"))continue;let o=t.getPropertyValue(i).trim();o&&n.style.setProperty(i,o)}n.style.colorScheme=t.colorScheme}function w(n,e,t){return n<e?e:n>t?t:n}function q(n,e,t=4){let r=e.getBoundingClientRect(),i=n.getBoundingClientRect(),o=r.bottom+t,s=o+i.height>window.innerHeight-8?r.top-i.height-t:o;n.style.left=`${w(r.left,8,Math.max(8,window.innerWidth-i.width-8))}px`,n.style.top=`${w(s,8,Math.max(8,window.innerHeight-i.height-8))}px`}var ai=0;function li(n="rg"){return ai++,`${n}-${ai}`}var di='<svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M2 3.5h12L9.5 8v4.5L6.5 14V8L2 3.5z"/></svg>',ui='<svg viewBox="0 0 16 16" width="10" height="10" fill="currentColor"><path d="M8 3l4 5H4l4-5z"/></svg>',ci='<svg viewBox="0 0 16 16" width="10" height="10" fill="currentColor"><path d="M8 13l4-5H4l4 5z"/></svg>',hi='<svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.35" stroke-linecap="round"><path d="M2 4h3m3 0h6M2 8h7m3 0h2M2 12h1m3 0h8"/><circle cx="6.5" cy="4" r="1.35"/><circle cx="10.5" cy="8" r="1.35"/><circle cx="4.5" cy="12" r="1.35"/></svg>';var qe=class{constructor(e){this.Ud=e;this.Ei=new Map}on(e,t){let r=this.Ei.get(e);return r||(r=new Set,this.Ei.set(e,r)),r.add(t),()=>{r.delete(t)}}once(e,t){let r=this.on(e,i=>{r(),t(i)});return r}emit(e,t){let r=this.Ei.get(e);if(r)for(let i of[...r])try{i(t)}catch(o){console.error(`[mach-table] error in "${e}" listener`,o),this.Ud?.(o,e)}}clear(){this.Ei.clear()}};var Mo=new Set(["__proto__","prototype","constructor"]),xe=new Map;function pr(n){if(typeof n!="string"||n.length===0)return null;let e=xe.get(n);if(e!==void 0)return e;let t=n.split("."),r=t.every(i=>i.length>0&&!Mo.has(i))?t:null;return n.length<=1024&&(xe.size>=256&&xe.delete(xe.keys().next().value),xe.set(n,r)),r}function Ye(n){return pr(n)!==null}function H(n,e){if(n==null)return;let t=pr(e);if(!t)return;let r=n;for(let i of t){if(r==null)return;r=r[i]}return r}function ce(n,e,t){if(n==null)return!1;let r=pr(e);if(!r)return!1;let i=n;for(let o=0;o<r.length-1;o++){if(typeof i!="object"&&typeof i!="function"||i===null)return!1;i[r[o]]==null&&(i[r[o]]={}),i=i[r[o]]}return typeof i!="object"&&typeof i!="function"||i===null?!1:(i[r[r.length-1]]=t,!0)}var he={text:["contains","notContains","equals","notEquals","startsWith","endsWith","blank","notBlank"],number:["equals","notEquals","lessThan","lessThanOrEqual","greaterThan","greaterThanOrEqual","inRange","blank","notBlank"],date:["equals","notEquals","lessThan","greaterThan","inRange","blank","notBlank"]};var Io=16,Ao=512,ko=20,Lo=2e3,Go=2e3,Po={text:new Set(he.text),number:new Set(he.number),date:new Set(he.date)};function No(n){return n==null||typeof n=="string"||typeof n=="number"&&Number.isFinite(n)}function Oo(n,e,t){if(n==null||typeof n!="object")return null;let r=n;return typeof r.match!="string"||!t.has(r.match)?null:{match:r.match,...Fo(r,e)}}function Fo(n,e){let t=e==="number"?pi(n.value):typeof n.value=="string"?n.value:void 0,r=e==="number"?pi(n.value2):typeof n.value2=="string"?n.value2:void 0;return{...t!==void 0?{value:t}:{},...r!==void 0?{value2:r}:{}}}function pi(n){return typeof n=="number"&&Number.isFinite(n)?n:void 0}function Ho(n,e){let t=[],r=Po[e];for(let i of n.slice(0,ko)){let o=Oo(i,e,r);o&&t.push(o)}return t}function Xe(n){if(n==null||typeof n!="object")return null;let e=n;return e.type==="set"?Array.isArray(e.values)?{type:"set",values:e.values.filter(No).slice(0,Lo)}:null:e.type!=="text"&&e.type!=="number"&&e.type!=="date"||!Array.isArray(e.conditions)?null:{type:e.type,...e.operator==="or"||e.operator==="and"?{operator:e.operator}:{},conditions:Ho(e.conditions,e.type)}}function Vo(n,e){if(typeof n.colId!="string"||!n.colId.trim())return null;let t=n.colId.trim();if(e.validColumnIds?.has(t)===!1)return null;let r=Xe(n.filter);return r?{kind:"condition",colId:t,filter:r}:null}function Bo(n,e,t){if(!Array.isArray(n.children))return null;let r=[];for(let i of n.children){let o=fi(i,e+1,t);o&&r.push(o)}return r.length===0?null:{kind:"group",operator:n.operator==="or"?"or":"and",children:r,...n.not===!0?{not:!0}:{}}}function _o(n,e,t){return e<=Io&&t.nodes<Ao&&n!=null&&typeof n=="object"}function fi(n,e,t){if(!_o(n,e,t)||t.ancestors.has(n))return null;t.ancestors.add(n),t.nodes++;let r=n,i=r.kind==="condition"?Vo(r,t):r.kind==="group"?Bo(r,e,t):null;return t.ancestors.delete(n),i}function O(n,e){if(n==null||typeof n!="object")return null;let t=n;if(t.version!==1||t.root==null)return null;let r=fi(t.root,0,{ancestors:new WeakSet,nodes:0,validColumnIds:e});return r?{version:1,root:r}:null}function mi(n,e){return{kind:"condition",colId:n,filter:e}}function Y(n,e){if(n==null||typeof n!="object"||Array.isArray(n))return{};let t={};for(let[r,i]of Object.entries(n).slice(0,Go)){let o=r.trim();if(!o||e?.has(o)===!1)continue;let s=Xe(i);s&&(t[o]=s)}return t}function gi(n,e,t={}){return{kind:"group",operator:n,children:e,...t.not?{not:!0}:{}}}var fr={align:"center",sortable:!0,resizable:!0,movable:!0,filter:!1,minWidth:80},Ee={compact:{rowHeight:30,headerHeight:34,fontSize:12,cellPadding:6},normal:{rowHeight:36,headerHeight:40,fontSize:13,cellPadding:9},large:{rowHeight:44,headerHeight:48,fontSize:14,cellPadding:12}},Re={multiSort:!0,stripedRows:!1,showCellBorders:!1,quickFilterText:null,suppressCellFocus:!1,suppressRowHoverHighlight:!1,suppressNoRowsOverlay:!1,suppressHeaderFocus:!1,loading:!1,error:null,className:"",singleClickEdit:!1,manualSorting:!1,manualFiltering:!1,showSummary:!1,rowNumber:!1,indexOffset:0,applyRowDrag:!0,masterDetail:!1,detailToggleColumn:!0,treeData:!1,childrenKey:"children",autoCheckedChildren:!0,defaultExpandAll:!1,columnMenu:!1,suppressWarnings:!1,enableRangeSelection:!1,suppressClipboard:!1,contextMenu:!1,flashCells:!0,fillHandle:!0,ariaLabel:"MachTable data grid",ariaLabelledBy:"",ariaDescribedBy:"",overlayNoRowsTemplate:"",overlayLoadingTemplate:"",overlayErrorTemplate:"",allowUnsafeOverlayHtml:!1},zo=Object.keys(Re);function Wo(n){let e={};for(let t of zo)e[t]=n[t]??Re[t];return e}function E(n,e,t,r=!1){return M(n,t,r)??e}function $o(n){return n&&Object.prototype.hasOwnProperty.call(Ee,n)?n:"normal"}function Ko(n){return n.theme==="light"||n.theme==="dark"||n.theme==="auto"?n.theme:"light"}function Uo(n,e){let t=typeof n.pagination=="object"&&Array.isArray(n.pagination.pageSizeOptions)?n.pagination.pageSizeOptions:void 0,r=t?[...new Set(t.map(i=>E(i,0,1,!0)).filter(Boolean))]:[10,20,50,100];return r.includes(e)||r.push(e),r.sort((i,o)=>i-o)}function mr(n,e){let t=typeof n=="function"?n(e):H(e,n);return t==null?"":String(t)}function jo(n){let e=n.rowKey,t=e?({data:r})=>mr(e,r):void 0;return{...t?{resolveRowId:t}:{},...e?{rowKey:e}:{}}}function qo(n,e){let t=Ee[e];return{columnDefs:Array.isArray(n.columnDefs)?n.columnDefs:[],rowData:Array.isArray(n.rowData)?n.rowData:[],defaultColDef:{...fr,...n.defaultColDef??{}},columnTypes:n.columnTypes??{},...jo(n),rowHeight:E(n.rowHeight,t.rowHeight,1),headerHeight:E(n.headerHeight,t.headerHeight,1),rowBuffer:E(n.rowBuffer,8,0,!0),columnLayout:n.columnLayout==="fit"?"fit":"normal",enableColumnResize:n.enableColumnResize===!0,domLayout:n.domLayout==="autoHeight"?"autoHeight":"normal",rowSelection:n.rowSelection==="single"||n.rowSelection==="multiple"?n.rowSelection:"none",size:e,pinnedTopRowData:Array.isArray(n.pinnedTopRowData)?n.pinnedTopRowData:[],pinnedBottomRowData:Array.isArray(n.pinnedBottomRowData)?n.pinnedBottomRowData:[]}}function Yo(n){return{rowStyleRules:Array.isArray(n.rowStyleRules)?n.rowStyleRules:[],theme:Ko(n)}}function Xo(n){return{editType:n.editType==="fullRow"?"fullRow":"cell",editableIndicator:n.editableIndicator==="always"||n.editableIndicator==="none"?n.editableIndicator:"hover",rowDragPolicy:n.rowDragPolicy,undoStackSize:E(n.undoStackSize,100,0,!0),asyncTransactionWaitMillis:E(n.asyncTransactionWaitMillis,16,0,!0)}}function Jo(n){return{detailRowHeight:E(n.detailRowHeight,240,1)}}function Zo(n){let e=typeof n.pagination=="object"?n.pagination:void 0,t=E(e?.pageSize,20,1,!0);return{paginationEnabled:n.pagination!==!1&&n.datasource==null,paginationMode:e?.mode==="server"?"server":"client",paginationPage:E(e?.page,1,1,!0),paginationTotal:E(e?.total,0,0,!0),paginationPageSize:t,paginationPageSizeOptions:Uo(n,t),paginationShowTotal:e?e.showTotal!==!1:!0,paginationShowSizeSelector:e?e.showPageSizeSelector!==!1:!0}}function gr(n){return{watermarkEnabled:n.watermark!=null&&n.watermark!==!1,watermarkConfig:n.watermark==null||n.watermark===!1?null:n.watermark===!0?{text:"MachTable"}:n.watermark}}function Qo(n){return{advancedFilterModel:O(n.advancedFilterModel),persistence:_e(n.persistence),locale:n.locale??{},tooltipShowDelay:E(n.tooltipShowDelay,600,0),statusBarEnabled:n.statusBar===!0||typeof n.statusBar=="object"&&n.statusBar!=null,statusBarPanels:typeof n.statusBar=="object"&&n.statusBar?.panels?n.statusBar.panels:["rowCount","selectedRowCount","rangeAggregate"]}}function es(n){return{datasourceMode:n.datasourceMode==="block"?"block":"sequential",blockSize:E(n.blockSize,100,1,!0),infiniteBufferRows:E(n.infiniteBufferRows,40,0,!0),maxBlocksInCache:E(n.maxBlocksInCache,12,1,!0),datasourceMaxConcurrentRequests:E(n.datasourceMaxConcurrentRequests,4,1,!0),blockPrefetch:E(n.blockPrefetch,1,0,!0),datasourceRowCount:n.datasourceRowCount==null?null:E(n.datasourceRowCount,0,0,!0),dataProcessorMinRows:E(n.dataProcessorMinRows,5e3,1,!0),datasourceRetryCount:E(n.datasourceRetryCount,2,0,!0),datasourceRetryDelay:E(n.datasourceRetryDelay,300,0,!0),datasourceRetryJitter:Math.min(1,E(n.datasourceRetryJitter,.15,0))}}var ts=["detailRowRenderer","isRowExpandable","aggFuncs","components","actionPolicy","summaryMethod","datasource","getRowHeight","tooltipComponent","getContextMenuItems","initialState","rowEditValidator","isTreeRowExpandable","loadTreeChildren","dataProcessor"];function rs(n,e){for(let t of ts)n[t]&&Reflect.set(e,t,n[t])}function is(n,e){for(let t of Object.keys(n))t.startsWith("on")&&typeof n[t]=="function"&&Reflect.set(e,t,n[t])}function yi(n){let e=$o(n.size),t={...Wo(n),...qo(n,e),...Yo(n),...Xo(n),...Jo(n),...Zo(n),...gr(n),...Qo(n),...es(n),features:Array.isArray(n.features)?n.features:[]};return rs(n,t),is(n,t),t}function vi(n){return Array.isArray(n)?n.filter(e=>typeof e=="string"&&e.length>0):typeof n=="string"&&n.length>0?[n]:[]}function Se(n,e){return vi(n.type).includes(e)}function bi(n,e,t={}){let r={};for(let o of vi(n.type)){o==="rightAligned"&&(r.align="right");let s=t[o];s&&Object.assign(r,s)}let i={...e,...r,...n};return i.align??(i.align=e.align??"center"),i.status&&!i.cellRenderer&&(i.cellRenderer="statusTag"),i}var W=class{constructor(e,t){this.manualWidth=null;this.contentWidth=null;this.flex=null;this.currentWidth=0;this.parentGroup=null;this.level=0;this.isDetailToggle=!1;this.id=e,this.colDef=t,this.hide=t.hide??!1;let r=t.pinned;this.pinned=r===!0?"left":r===!1||r==null?null:r,this.resetWidth()}get sortable(){return this.colDef.sortable!==!1}get resizable(){return this.colDef.resizable!==!1}get movable(){return this.colDef.movable!==!1}get filterable(){return this.colDef.filter!=null&&this.colDef.filter!==!1}get filterType(){let e=this.colDef.filter;return e===!0?"text":e??"text"}get hasCheckbox(){return this.colDef.checkboxSelection===!0}resetWidth(){this.manualWidth=null,this.contentWidth=null,this.flex=N(this.colDef.flex)??null}};function $(n){return!n.hasCheckbox&&!n.isDetailToggle&&!n.isAutoRowNumber}var X=class n{constructor(e,t){this.parent=null;this.children=[];this.groupId=e,this.def=t}get headerName(){return this.def.headerName??this.def.groupId??""}getLeafColumns(e=[]){for(let t of this.children)t instanceof n?t.getLeafColumns(e):e.push(t);return e}};function pe(n){return Array.isArray(n.children)}var Me=150,ns=80;function J(n,e){let t=N(e.minWidth)??ns,r=N(e.maxWidth)??Number.MAX_SAFE_INTEGER,i=N(n)??N(e.width)??Me;return Math.max(t,Math.min(r,i))}function wi(n,e,t,r){let i=r.map((s,a)=>a).filter(s=>r[s]>0),o=t-e.reduce((s,a)=>s+a,0);for(;Math.abs(o)>.001&&i.length;){let s=i.reduce((l,d)=>l+r[d],0),a=0;if(i=i.filter(l=>{let d=e[l];return e[l]=J(d+o*r[l]/s,n[l]),a+=e[l]-d,e[l]!==d}),Math.abs(a)<1e-4)break;o-=a}}function Ci(n,e){let t=n.map(r=>J(r.width??Me,r));return e>t.reduce((r,i)=>r+i,0)&&wi(n,t,e,n.map(r=>r.flex??0)),t}function Je(n,e){let t=n.map(r=>J(r.width??Me,r));return Number.isFinite(e)&&e>0&&wi(n,t,e,[...t]),t}var D={matchContains:"\u5305\u542B",matchNotContains:"\u4E0D\u5305\u542B",matchEquals:"\u7B49\u4E8E",matchNotEquals:"\u4E0D\u7B49\u4E8E",matchStartsWith:"\u5F00\u5934\u662F",matchEndsWith:"\u7ED3\u5C3E\u662F",matchBlank:"\u4E3A\u7A7A",matchNotBlank:"\u4E0D\u4E3A\u7A7A",matchLessThan:"\u5C0F\u4E8E",matchLessThanOrEqual:"\u5C0F\u4E8E\u7B49\u4E8E",matchGreaterThan:"\u5927\u4E8E",matchGreaterThanOrEqual:"\u5927\u4E8E\u7B49\u4E8E",matchInRange:"\u5728\u8303\u56F4\u5185",apply:"\u5E94\u7528",reset:"\u91CD\u7F6E",search:"\u641C\u7D22...",emptySetLabel:"(\u7A7A)",selectedCount:"\u5DF2\u9009 {n} \u9879",sortAsc:"\u5347\u5E8F",sortDesc:"\u964D\u5E8F",clearSort:"\u53D6\u6D88\u6392\u5E8F",pinLeft:"\u56FA\u5B9A\u5DE6\u4FA7",pinRight:"\u56FA\u5B9A\u53F3\u4FA7",clearPin:"\u53D6\u6D88\u56FA\u5B9A",autoSize:"\u81EA\u9002\u5E94\u5217\u5BBD",hideColumn:"\u9690\u85CF\u6B64\u5217",columnVisibility:"\u5217\u663E\u793A",resetAll:"\u91CD\u7F6E\u5168\u90E8",autoSizeAll:"\u5168\u90E8\u81EA\u9002\u5E94",columnSettings:"\u5217\u8BBE\u7F6E",totalLabel:"\u5408\u8BA1",totalRowsLabel:"\u5171 {n} \u884C",menuCopy:"\u590D\u5236",menuPaste:"\u7C98\u8D34",menuClearContents:"\u6E05\u9664\u5185\u5BB9",loading:"\u52A0\u8F7D\u4E2D...",statusSelected:"\u5DF2\u9009 {n} \u884C",statusSum:"\u548C {n}",statusAvg:"\u5747 {n}",statusCount:"\u8BA1 {n}",emptyRows:"\u6CA1\u6709\u53EF\u663E\u793A\u7684\u884C",emptyRowsHint:"\u6682\u65E0\u6570\u636E\uFF0C\u53EF\u8C03\u6574\u67E5\u8BE2\u6761\u4EF6\u540E\u91CD\u8BD5",paginationTotal:"\u5171 {n} \u6761",paginationPage:"\u7B2C {a} / {b} \u9875",perPage:"{n} \u6761/\u9875",pageFirst:"\u9996\u9875",pagePrev:"\u4E0A\u4E00\u9875",pageNext:"\u4E0B\u4E00\u9875",pageLast:"\u672B\u9875",requestFailed:"\u6570\u636E\u52A0\u8F7D\u5931\u8D25",requestFailedHint:"\u8BF7\u68C0\u67E5\u7F51\u7EDC\u540E\u91CD\u8BD5",actionView:"\u67E5\u770B",actionEdit:"\u7F16\u8F91",actionDelete:"\u5220\u9664",actionConfirm:"\u786E\u8BA4",actionSave:"\u4FDD\u5B58",actionCancel:"\u53D6\u6D88",actionMore:"\u66F4\u591A\u64CD\u4F5C",rowDragHandle:"\u62D6\u52A8\u8C03\u6574\u987A\u5E8F\uFF1BAlt + \u4E0A\u4E0B\u65B9\u5411\u952E\u79FB\u52A8",rowDragUnavailable:"\u5F53\u524D\u6392\u5E8F\u6216\u6570\u636E\u6A21\u5F0F\u4E0D\u652F\u6301\u81EA\u52A8\u8C03\u6574\u987A\u5E8F",rowDragPosition:"\u7B2C {a} \u884C \u2192 \u7B2C {b} \u884C",rowDragOutside:"\u79FB\u56DE\u8868\u683C\u5185\u653E\u7F6E \xB7 Esc \u53D6\u6D88"},Ti={matchContains:"Contains",matchNotContains:"Not Contains",matchEquals:"Equals",matchNotEquals:"Not Equals",matchStartsWith:"Starts With",matchEndsWith:"Ends With",matchBlank:"Blank",matchNotBlank:"Not Blank",matchLessThan:"Less Than",matchLessThanOrEqual:"\u2264",matchGreaterThan:"Greater Than",matchGreaterThanOrEqual:"\u2265",matchInRange:"In Range",apply:"Apply",reset:"Reset",search:"Search...",emptySetLabel:"(blank)",selectedCount:"{n} selected",sortAsc:"Ascending",sortDesc:"Descending",clearSort:"Clear Sort",pinLeft:"Pin Left",pinRight:"Pin Right",clearPin:"Unpin",autoSize:"Auto Fit",hideColumn:"Hide Column",columnVisibility:"Columns",resetAll:"Reset All",autoSizeAll:"Fit All",columnSettings:"Column Settings",totalLabel:"Total",totalRowsLabel:"{n} rows",menuCopy:"Copy",menuPaste:"Paste",menuClearContents:"Clear Contents",loading:"Loading...",statusSelected:"{n} selected",statusSum:"Sum {n}",statusAvg:"Avg {n}",statusCount:"Cnt {n}",emptyRows:"No rows to display",emptyRowsHint:"Try adjusting your search or filters.",paginationTotal:"{n} items",paginationPage:"Page {a} / {b}",perPage:"{n} / page",pageFirst:"First",pagePrev:"Previous",pageNext:"Next",pageLast:"Last",requestFailed:"Unable to load data",requestFailedHint:"Check your connection and try again",actionView:"View",actionEdit:"Edit",actionDelete:"Delete",actionConfirm:"Confirm",actionSave:"Save",actionCancel:"Cancel",actionMore:"More actions",rowDragHandle:"Drag to reorder; Alt + Up/Down to move",rowDragUnavailable:"Reordering is unavailable in the current sort or data mode",rowDragPosition:"Row {a} \u2192 Row {b}",rowDragOutside:"Move inside to drop \xB7 Esc to cancel",rowDragSelection:"{a} selected rows \u2192 Row {b}",rowDragBefore:"Before",rowDragAfter:"After",rowDragInside:"Inside",rowDragRejected:"This destination is unavailable"},os={contains:"matchContains",notContains:"matchNotContains",equals:"matchEquals",notEquals:"matchNotEquals",startsWith:"matchStartsWith",endsWith:"matchEndsWith",blank:"matchBlank",notBlank:"matchNotBlank",lessThan:"matchLessThan",lessThanOrEqual:"matchLessThanOrEqual",greaterThan:"matchGreaterThan",greaterThanOrEqual:"matchGreaterThanOrEqual",inRange:"matchInRange"};function Ze(n){return os[n]??"matchEquals"}function V(n,e){return n.replace("{n}",String(e))}function fe(n,e,t){return n.replace("{a}",String(e)).replace("{b}",String(t))}var ss=[[/^(success|ok|done|complete|completed|normal|active|enabled|启用|正常|完成|已完成|运行|运行中|在线|生效|已发运)$/i,"success"],[/^(warning|warn|hold|pending|standby|待机|待审核|暂停|预警|部分完成|待下达|待复核|待发运)$/i,"warning"],[/^(error|fail|failed|danger|fault|offline|disabled|故障|失败|错误|异常|停用|离线|断开)$/i,"danger"],[/^(info|processing|new|draft|进行中|新建|草稿|审批中|同步中|执行中|已下达|装车中)$/i,"info"],[/^(neutral|default)$/i,"neutral"]];function Qe(n,e,t){let r=String(n??"");if(e){let i=De(e,r);if(i)return i;let o=De(e,r.toLowerCase());if(o)return o}for(let[i,o]of ss)if(i.test(r))return o;return t==null?"neutral":Qe(t)}function vr(n={}){return e=>{if(e.value==null||e.value==="")return"";let t=String(e.value),r=Ue(t,e.colDef.status),i=r?.label??De(n.labelMap,t)??(e.formatted||t),o=r?.color,s=Qe(o??t,o?void 0:n.variantMap,i),a=document.createElement("span");return a.className=`mach-tag mach-tag--${s}`,a.textContent=i,o&&s!==o&&(a.style.color=o,a.style.backgroundColor=`color-mix(in srgb, ${o} 12%, transparent)`),a}}function br(n={}){return e=>{let t=Number(e.value);if(isNaN(t))return e.formatted;let r=Math.max(0,Math.min(100,t)),i=f("div","mach-progress"),o=f("div","mach-progress__track"),s=f("div","mach-progress__bar");if(s.style.width=`${r}%`,n.color&&(s.style.background=n.color),o.appendChild(s),i.appendChild(o),n.showValue!==!1){let a=f("span","mach-progress__label");a.textContent=`${Math.round(r)}${n.unit??"%"}`,i.appendChild(a)}return i}}function wr(n){if(n.value==null||n.value==="")return"";let e=f("span","mach-link");return e.textContent=n.formatted||String(n.value),e}var Cr={edit:'<path d="M11.5 2.5l2 2L5 13H3v-2l8.5-8.5z"/>',delete:'<path d="M3 5h10M6 5V3h4v2M5 5l.7 8h4.6L11 5"/>',view:'<path d="M1.5 8s2.4-4.2 6.5-4.2S14.5 8 14.5 8s-2.4 4.2-6.5 4.2S1.5 8 1.5 8z"/><circle cx="8" cy="8" r="1.8"/>',copy:'<rect x="5" y="5" width="8" height="8" rx="1"/><path d="M3 11V3h8"/>',download:'<path d="M8 2v8m0 0l-3-3m3 3l3-3M2.5 13.5h11"/>',refresh:'<path d="M13 3v4h-4M3 13V9h4"/><path d="M13 7a5.5 5.5 0 00-9.7-2.6M3 9a5.5 5.5 0 009.7 2.6"/>',close:'<path d="M3.5 3.5l9 9m0-9l-9 9"/>',check:'<path d="M2.5 8.5l3.5 3.5 7.5-8"/>',plus:'<path d="M8 2.5v11M2.5 8h11"/>',search:'<circle cx="7" cy="7" r="4.5"/><path d="M10.5 10.5L14 14"/>',more:'<circle cx="3" cy="8" r=".9" fill="currentColor" stroke="none"/><circle cx="8" cy="8" r=".9" fill="currentColor" stroke="none"/><circle cx="13" cy="8" r=".9" fill="currentColor" stroke="none"/>'};function et(n,e=14){let t=Cr[n]??"";return`<svg viewBox="0 0 16 16" width="${e}" height="${e}" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">${t}</svg>`}var Q=null,F=null;function Di(n){F&&n.contains(F)&&K()}function K(n=!1){Q?.remove(),Q=null,F&&(F.setAttribute("aria-expanded","false"),n&&F.isConnected&&F.focus({preventScroll:!0})),F=null,document.removeEventListener("mousedown",xi,!0),document.removeEventListener("keydown",Tr,!0)}function xi(n){Q&&!Q.contains(n.target)&&!F?.contains(n.target)&&K()}function Tr(n){if(!Q)return;if(n.key==="Escape"){n.preventDefault(),K(!0);return}let e=[...Q.querySelectorAll("button:not(:disabled)")];if(e.length===0)return;if(n.key==="Tab"){let i=e.indexOf(document.activeElement);(!n.shiftKey&&i===e.length-1||n.shiftKey&&i<=0)&&(n.preventDefault(),e[n.shiftKey?e.length-1:0].focus());return}if(n.key!=="ArrowDown"&&n.key!=="ArrowUp")return;n.preventDefault();let t=e.indexOf(document.activeElement),r=n.key==="ArrowDown"?1:-1;e[(t+r+e.length)%e.length].focus()}function Ei(n,e){let t=document.createElement("button");return t.type="button",t.className=e,n.variant&&n.variant!=="default"&&t.classList.add(`${e}--${n.variant}`),t.disabled=n.disabled===!0,n.icon&&Cr[n.icon]?t.innerHTML=`${et(n.icon,16)}<span>${n.label}</span>`:t.textContent=n.label,t.addEventListener("click",()=>n.pick(t)),t}function as(n,e){K();let t=f("div","mach-context-menu mach-action-menu");t.setAttribute("role","menu");for(let r of e){let i=Ei(r,"mach-context-menu-item");i.setAttribute("role","menuitem"),t.appendChild(i)}I(t,n.closest(".mach-root")),document.body.appendChild(t),q(t,n),Q=t,F=n,n.setAttribute("aria-expanded","true"),document.addEventListener("mousedown",xi,!0),document.addEventListener("keydown",Tr,!0),t.querySelector("button:not(:disabled)")?.focus({preventScroll:!0})}function ls(n,e,t){K();let r=f("div","mach-action-drawer-backdrop"),i=f("section","mach-action-drawer");i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),i.setAttribute("aria-label",e);let o=f("header","mach-action-drawer__header"),s=document.createElement("strong");s.textContent=e;let a=document.createElement("button");a.type="button",a.className="mach-action-drawer__close",a.setAttribute("aria-label","Close"),a.title="Close",a.innerHTML=et("close",16),a.addEventListener("click",()=>K(!0)),o.append(s,a);let l=f("div","mach-action-drawer__body");for(let d of t)l.appendChild(Ei(d,"mach-action-drawer__item"));i.append(o,l),r.appendChild(i),r.addEventListener("mousedown",d=>{d.target===r&&K(!0)}),I(r,n.closest(".mach-root")),document.body.appendChild(r),Q=r,F=n,n.setAttribute("aria-expanded","true"),document.addEventListener("keydown",Tr,!0),i.querySelector("button:not(:disabled)")?.focus({preventScroll:!0})}function Z(n,e){if(typeof n=="function")try{return n(e)}catch{return!1}return n===!0}function Ri(n){return n.variant??"default"}function Si(n){return n.permission?typeof n.permission=="string"?[n.permission]:n.permission:[]}function Dr(n,e,t){return{...n.id?{actionId:n.id}:{},permissions:Si(n),...t?{message:t}:{},params:e}}function tt(n,e,t){let r=t.api.getOption("actionPolicy");try{r?.onError?r.onError(n,Dr(e,t)):console.error("[mach-table] action handler failed",n)}catch(i){console.error("[mach-table] action error policy failed",i,n)}}function ds(n,e){if(Si(n).length===0)return!0;let r=e.api.getOption("actionPolicy");if(!r?.canAccess)return!0;try{return r.canAccess(Dr(n,e))}catch(i){return tt(i,n,e),!1}}function us(n,e){return n.filter(t=>{if(!ds(t,e))return!1;if(!t.show)return!0;try{return t.show(e)}catch{return!1}})}function xr(n,e,t){t.isConnected&&(t.disabled=Z(n.disabled,e)||Z(n.loading,e),t.classList.toggle("mach-action-btn--loading",Z(n.loading,e)))}function cs(n,e,t,r){Promise.resolve(n).catch(i=>tt(i,e,t)).finally(()=>xr(e,t,r))}function hs(n,e,t){try{cs(n.onClick(e),n,e,t)}catch(r){tt(r,n,e),xr(n,e,t)}}function yr(n,e,t){if(n===!1)return!1;let r=typeof n=="string"?n:e.label??e.title??"Confirm action",i=t.api.getOption("actionPolicy");return i?.confirm?i.confirm(Dr(e,t,r)):typeof window>"u"||typeof window.confirm!="function"?!1:window.confirm(r)}function ps(n,e){if(n.confirm==null||n.confirm===!1)return!0;if(typeof n.confirm!="function")return yr(n.confirm,n,e);let t=n.confirm(e);return t instanceof Promise?t.then(r=>yr(r,n,e)):yr(t,n,e)}function fs(n){return(e,t)=>{if(Z(e.disabled,n))return;if(t.disabled=!0,t.classList.add("mach-action-btn--loading"),e.confirm==null||e.confirm===!1){hs(e,n,t);return}(async()=>{await ps(e,n)&&await e.onClick(n)})().catch(i=>tt(i,e,n)).finally(()=>{xr(e,n,t)})}}function ms(n,e,t){let r=document.createElement("button");r.type="button",r.className="mach-action-btn";let i=Ri(n);i!=="default"&&r.classList.add(`mach-action-btn--${i}`);let o=n.title??n.label??"Action";return r.title=o,r.setAttribute("aria-label",o),r.disabled=Z(n.disabled,e),Z(n.loading,e)&&(r.disabled=!0,r.classList.add("mach-action-btn--loading")),n.icon&&Cr[n.icon]?(r.innerHTML=et(n.icon),r.classList.add("mach-action-btn--icon")):r.textContent=n.label??o,r.addEventListener("mousedown",s=>s.stopPropagation()),r.addEventListener("click",s=>{s.stopPropagation(),t(n,r)}),r}function gs(n,e,t,r,i){let o=document.createElement("button");o.type="button",o.className="mach-action-btn mach-action-btn--icon";let s=r.api.getOption("locale")??{},a=t.moreLabel??s.actionMore??D.actionMore;return o.title=a,o.setAttribute("aria-label",a),o.setAttribute("aria-haspopup",e==="drawer"?"dialog":"menu"),o.setAttribute("aria-expanded","false"),o.innerHTML=`${et("more",16)}<span class="mach-sr-only">\u22EF</span>`,o.addEventListener("mousedown",l=>l.stopPropagation()),o.addEventListener("click",l=>{l.stopPropagation();let d=n.map(u=>({label:u.label??u.title??"Action",icon:u.icon,variant:Ri(u),disabled:Z(u.disabled,r)||Z(u.loading,r),pick:c=>{K(),i(u,c)}}));e==="drawer"?ls(o,t.drawerTitle??a,d):as(o,d)}),o}function ge(n){let e=Math.max(0,n.max??3),t=n.overflow??"menu";return r=>{let i=us(n.actions,r);if(i.length===0)return"";let o=f("div","mach-actions"),s=t==="inline"?i:i.slice(0,e),a=t==="inline"?[]:i.slice(e),l=fs(r);for(let d of s)o.appendChild(ms(d,r,l));return a.length>0&&o.appendChild(gs(a,t,n,r,l)),{el:o,destroy:()=>{F&&o.contains(F)&&K()}}}}function me(n,e,t){return n??e??t}function ys(n,e){let t=e.api.getOption("locale")??{};return{view:me(n.labels?.view,t.actionView,D.actionView),edit:me(n.labels?.edit,t.actionEdit,D.actionEdit),delete:me(n.labels?.delete,t.actionDelete,D.actionDelete),confirm:me(n.labels?.confirm,t.actionConfirm,D.actionConfirm),save:me(n.labels?.save,t.actionSave,D.actionSave),cancel:me(n.labels?.cancel,t.actionCancel,D.actionCancel)}}function vs(n,e,t){let r=async()=>{if(!await e.api.editing.stop()||!n.onSave)return;let s=e.api.editing.getChanges().filter(a=>a.rowId===e.node.id);try{await n.onSave(e,s),e.api.editing.markSaved([e.node.id])}catch(a){throw e.api.editing.startRow(e.rowIndex),a}},i=n.onSave?t.save:n.labels?.confirm??n.labels?.save??t.confirm;return ge({actions:[{icon:"check",title:i,variant:"success",onClick:r},{icon:"close",title:t.cancel,variant:"danger",onClick:()=>e.api.editing.stop({cancel:!0}).then(()=>{})}],overflow:"inline"})(e)}function bs(n,e,t){let r=[];return n.onView&&r.push({id:"view",icon:"view",title:t.view,variant:"primary",...n.permissions?.view?{permission:n.permissions.view}:{},onClick:n.onView}),n.edit!==!1&&r.push({id:"edit",icon:"edit",title:t.edit,variant:"warning",...n.permissions?.edit?{permission:n.permissions.edit}:{},onClick:n.onEdit??(()=>{e.api.editing.startRow(e.rowIndex)})}),n.onDelete&&r.push({id:"delete",icon:"delete",title:t.delete,variant:"danger",...n.permissions?.delete?{permission:n.permissions.delete}:{},...n.confirmDelete?{confirm:n.confirmDelete===!0?t.delete:n.confirmDelete}:{},onClick:n.onDelete}),r.push(...n.extraActions??[]),r}function rt(n={}){return e=>{let t=ys(n,e);if(e.api.editing.isRowActive(e.rowIndex))return vs(n,e,t);let r=bs(n,e,t);return ge({actions:r,max:n.max,overflow:n.overflow??"menu",moreLabel:n.moreLabel,drawerTitle:n.drawerTitle})(e)}}var ws=vr(),Cs=br(),Mi=Object.freeze({statusTag:ws,progressBar:Cs,link:wr});var Ie={sortable:!1,resizable:!1,movable:!1,filter:!1,suppressSizeToFit:!0,suppressColumnMenu:!0};function Ii(n={}){let e=n.width??40;return{colId:"sel",headerName:"",width:e,minWidth:n.minWidth??e,maxWidth:n.maxWidth??e,pinned:"left",checkboxSelection:!0,...Ie,...n}}function it(n={}){let e=n.width??52;return{colId:"idx",headerName:"#",type:"index",width:e,minWidth:n.minWidth??e,maxWidth:n.maxWidth??e,pinned:"left",align:"center",headerAlign:"center",...Ie,...n}}function Ai(n={}){let e=n.width??40;return{colId:"drag",headerName:"",rowDrag:!0,width:e,minWidth:n.minWidth??e,maxWidth:n.maxWidth??e,pinned:"left",...Ie,...n}}function ki(n={actions:[]}){let{width:e,pinned:t,...r}=n,i=r.actions?.length??0,o=r.overflow==="inline"?i:Math.min(i,r.max??3),s=r.overflow!=="inline"&&i>o,a=Math.max(1,o)*26+(s?26:0)+10;return{colId:"op",headerName:"\u64CD\u4F5C",width:e??Math.max(64,a),pinned:t??"right",cellRenderer:ge(r),...Ie,cellRendererParams:void 0}}function Li(n={}){let{width:e,pinned:t,...r}=n,i=(r.onView?1:0)+(r.edit===!1?0:1)+(r.onDelete?1:0)+(r.extraActions?.length??0),o=r.overflow==="inline"?i:Math.min(i,r.max??3),s=r.overflow!=="inline"&&i>o,a=Math.max(2,o)*26+(s?26:0)+10;return{colId:"op",headerName:"\u64CD\u4F5C",width:e??Math.max(72,a),pinned:t??"right",cellRenderer:rt(r),...Ie,cellRendererParams:void 0}}var Er="__rg_detail_toggle__";function Ae(n){return N(n)!==void 0}function Pi(n){return n===!0?"left":n||null}function Gi(n,e){let t=e;for(let r=2;n.has(t);r++)t=`${e}_${r}`;return n.add(t),t}function Ts(n,e){let t=e.colDef,r=n.colDef;n.manualWidth=e.manualWidth,(t.width===r.width&&t.autoWidth===r.autoWidth||t.width!=null||t.autoWidth===!1)&&(n.contentWidth=e.contentWidth),(e.manualWidth!=null||e.flex!==(N(t.flex)??null))&&(n.flex=e.flex),e.hide!==(t.hide??!1)&&(n.hide=e.hide),e.pinned!==Pi(t.pinned)&&(n.pinned=e.pinned)}var nt=class{constructor(e){this.e=e;this.q=[];this.qn=new Map;this.ye=[];this.Yn=[];this.Gr=[];this.Xn=[];this.ve=[];this.Jn=[];this.Pr=new Map;this.er=1;this.Zn=new Map;this.jd=0}Ri(e){this.Jn=e?[...e]:[];let t=new Map(this.q.map(u=>[u.id,u])),r=this.e.r.defaultColDef,i=this.e.r.masterDetail&&this.e.r.detailToggleColumn,o=new Set(i?[Er]:[]),s=this.e.r.rowNumber,a=(u,c,h)=>u.map((p,m)=>{if(pe(p)){let B=p.groupId??p.headerName??`group_${m}_${h}`,_=new X(B,p);return _.parent=c,_.children=a(p.children,_,h+1),_}let g=p,v=Gi(o,g.colId??g.field??`col_${m}`),C=new W(v,bi(g,r,this.e.r.columnTypes));s&&(s=!Se(C.colDef,"index")),C.parentGroup=c,C.level=h;let k=t.get(v);return k&&!k.isAutoRowNumber&&Ts(C,k),C});if(this.ye=a(this.Jn,null,0),s&&o.size>Number(i)&&this.qd(Gi(o,"idx"),t),i){let u=new W(Er,{colId:Er,headerName:"",width:38,pinned:"left",sortable:!1,resizable:!1,movable:!1,filter:!1});u.isDetailToggle=!0,this.ye.unshift(u)}this.Pr.size&&this.Yd(),this.q=this.Si(this.ye),this.qn=new Map(this.q.map(u=>[u.id,u])),this.er=this.q.reduce((u,c)=>Math.max(u,c.level+1),1);let l=this.ve.length;this.ve=this.ve.filter(u=>this.qn.has(u.colId));let d=this.ve.length!==l;if(this.ve.length===0){let u=[];for(let c of this.q)c.colDef.initialSort&&u.push({colId:c.id,direction:c.colDef.initialSort});this.ve=u}return this.tr(),d}qd(e,t){let r=new W(e,it({colId:e,headerName:"\u5E8F\u53F7"}));r.isAutoRowNumber=!0;let i=t.get(e);i?.isAutoRowNumber&&(r.hide=i.hide);let o=this.ye.findIndex(s=>!(s instanceof W&&(s.hasCheckbox||s.colDef.rowDrag)));this.ye.splice(o===-1?this.ye.length:o,0,r)}Si(e,t=[]){for(let r of e)r instanceof X?this.Si(r.children,t):t.push(r);return t}tr(){let e=this.q.filter(t=>!t.hide);this.Yn=e.filter(t=>t.pinned==="left"),this.Xn=e.filter(t=>t.pinned==="right"),this.Gr=e.filter(t=>t.pinned===null),this.Zn.clear(),this.u().forEach((t,r)=>this.Zn.set(t.id,r))}ze(e){return this.Zn.get(e)??-1}Z(){return this.q}Qn(){return this.Jn}Xd(){return this.ye}Jd(){return this.er}k(e){return this.qn.get(e)}w(e){return e==="left"?this.Yn:e==="right"?this.Xn:this.Gr}u(){return[...this.Yn,...this.Gr,...this.Xn]}Qe(){return this.u().filter(e=>e.colDef.rowGroup===!0)}Zd(){return this.u().filter(e=>e.colDef.aggFunc!=null&&e.colDef.rowGroup!==!0)}eo(){return this.Gr.some(e=>e.colDef.colSpan!=null)}ea(){let e=this.u();return this.Gr.find($)??e.find($)??e[0]}We(e){return e.pinned==="left"?"left":e.pinned==="right"?"right":"center"}ta(e){this.jd=e;let t=e,r=[],i=[];for(let s of this.u()){let a=this.Mi(s);s.pinned!=null||s.colDef.suppressSizeToFit||s.manualWidth!=null?(s.currentWidth=J(a.width??Me,a),t-=s.currentWidth):(r.push(s),i.push(a))}let o=this.e.r.columnLayout==="fit"?Je(i,Math.max(0,t)):Ci(i,Math.max(0,t));r.forEach((s,a)=>{s.currentWidth=o[a]})}Mi(e){let t=e.colDef;return{width:e.manualWidth??e.contentWidth??t.width??void 0,minWidth:e.minWidth??t.minWidth,maxWidth:t.maxWidth,flex:e.manualWidth==null?e.flex??void 0:void 0}}Ae(e,t){return Ae(t)?(e.manualWidth=J(t,this.Mi(e)),e.flex=null,!0):!1}ra(e,t){return Ae(t)?(e.resetWidth(),e.contentWidth=J(t,this.Mi(e)),!0):!1}to(e,t){let r=this.k(e);!r||r.hide===!t||(r.hide=!t,this.tr())}Nr(e,t){let r=this.k(e);if(!r)return!1;let i=this.We(r),o=c=>r.parentGroup?!0:this.We(c)===i,s=r.parentGroup?r.parentGroup.children:this.ye,a=s.filter(c=>c instanceof W&&!c.hide&&o(c)),l=a.indexOf(r);if(l<0)return!1;a.splice(l,1);let d=Math.max(0,Math.min(t,a.length));a.splice(d,0,r);let u=[];return s.forEach((c,h)=>{c instanceof W&&!c.hide&&o(c)&&u.push(h)}),u.length!==a.length?!1:(u.forEach((c,h)=>{s[c]=a[h]}),l!==d&&this.Pr.set(this.ia(r),a.filter(c=>c.movable).map(c=>c.id)),this.q=this.Si(this.ye),this.tr(),!0)}ro(e,t){let r=this.k(e);!r||!r.movable||(r.pinned=t,this.tr())}na(e=!0){return(e?this.q:this.q.filter(r=>!r.isAutoRowNumber)).map(r=>({colId:r.id,hide:r.hide,width:r.manualWidth??r.currentWidth,flex:r.flex,widthMode:r.manualWidth==null?"auto":"manual",contentWidth:r.contentWidth??void 0,pinned:r.pinned}))}oa(e){let t=new Map(e.map(r=>[r.colId,r]));for(let r of this.q){let i=t.get(r.id);i&&this.Qd(r,i)}this.eu(e),this.tr()}Qd(e,t){typeof t.hide=="boolean"&&(e.hide=t.hide),t.widthMode==="auto"?(e.resetWidth(),Ae(t.flex)&&(e.flex=t.flex)):Ae(t.flex)?(e.flex=t.flex,e.manualWidth=null):this.Ae(e,t.width),Ae(t.contentWidth)&&(e.contentWidth=J(t.contentWidth,this.Mi(e))),e.movable&&(t.pinned==="left"||t.pinned==="right"||t.pinned===null)&&(e.pinned=t.pinned)}eu(e){let t=new Map(e.map((r,i)=>[r.colId,i]));this.no(r=>!r.hide&&r.movable&&t.has(r.id),(r,i)=>{let o=[...r];r.sort((s,a)=>t.get(s.id)-t.get(a.id)),r.some((s,a)=>s!==o[a])&&this.Pr.set(i,r.map(s=>s.id))}),this.q=this.Si(this.ye)}ia(e){if(!e.parentGroup)return this.We(e);let t=[];for(let r=e.parentGroup;r;r=r.parent)t.push(r.groupId);return JSON.stringify(t)}Yd(){let e=new Map;this.no(t=>t.movable,(t,r)=>{let i=this.Pr.get(r);if(!i)return;let o=new Map(t.map(d=>[d.id,d])),s=i.filter(d=>o.has(d));if(s.length<2)return;let a=new Set(s),l=0;t.forEach((d,u)=>{a.has(d.id)&&(t[u]=o.get(s[l++]))}),e.set(r,s)}),this.Pr=e}no(e,t,r=this.ye){let i=new Map;r.forEach((o,s)=>{if(o instanceof X)this.no(e,t,o.children);else if(e(o)){let a=o.parentGroup?"center":this.We(o),l=i.get(a)??[];l.push(s),i.set(a,l)}});for(let o of i.values()){if(o.length<2)continue;let s=o.map(a=>r[a]);t(s,this.ia(s[0])),o.forEach((a,l)=>{r[a]=s[l]})}}oo(){for(let e of this.q)e.resetWidth(),e.hide=e.colDef.hide??!1,e.pinned=Pi(e.colDef.pinned);this.tr()}Q(){return this.ve.map(e=>({...e}))}Or(e){if(!e||e.length===0){this.ve=[];return}this.ve=e.filter(t=>this.q.some(r=>r.id===t.colId)&&(t.direction==="asc"||t.direction==="desc")).map(t=>({colId:t.colId,direction:t.direction}))}Ii(e,t){let r=[...this.ve],i=r.findIndex(l=>l.colId===e.id),o=i>=0?r[i].direction:null,s=o===null?"asc":o==="asc"?"desc":null;t&&this.e.r.multiSort?s===null?i>=0&&r.splice(i,1):i>=0?r[i]={colId:e.id,direction:s}:r.push({colId:e.id,direction:s}):(r.length=0,s&&r.push({colId:e.id,direction:s})),this.ve=r}};function ie(n,e){if(n instanceof Error)return n;let t=new Error(typeof n=="string"?n:e);return t.name="AbortError",t}var Ds=()=>ie(void 0,"[MachTable] Operation cancelled.");function ot(n,e,t=Ds){return e?new Promise((r,i)=>{let o=()=>{e.removeEventListener("abort",o),i(t())};if(n.then(r,i).finally(()=>e.removeEventListener("abort",o)),e.aborted){o();return}e.addEventListener("abort",o,{once:!0})}):n}function Ni(n){return n==null?"":String(n).toLowerCase()}function xs(n,e,t){let r=Ni(n),i=o=>{let s=(o.value??"").toLowerCase();switch(o.match){case"contains":return r.includes(s);case"notContains":return!r.includes(s);case"equals":return r===s;case"notEquals":return r!==s;case"startsWith":return r.startsWith(s);case"endsWith":return r.endsWith(s);case"blank":return r==="";case"notBlank":return r!=="";default:return!0}};return e.length===0||(t==="or"?e.some(i):e.every(i))}function Es(n,e,t){switch(t.match){case"equals":return n===e;case"notEquals":return n!==e;case"lessThan":return n<e;case"lessThanOrEqual":return n<=e;case"greaterThan":return n>e;case"greaterThanOrEqual":return n>=e;case"inRange":return n>=e&&n<=(t.value2??e);default:return!0}}function Rs(n,e){let t=n==null||n==="";if(e.match==="blank")return t;if(e.match==="notBlank")return!t;if(t)return!1;let r=typeof n=="number"?n:Number(n);if(Number.isNaN(r))return!1;let i=e.value;return i==null||Number.isNaN(i)?!1:Es(r,i,e)}function Ss(n,e,t){let r=i=>Rs(n,i);return e.length===0||(t==="or"?e.some(r):e.every(r))}function Rr(n){if(n==null||n==="")return null;if(n instanceof Date)return isNaN(n.getTime())?null:n.getTime();if(typeof n=="number")return n;let e=Date.parse(String(n));return isNaN(e)?null:e}function Ms(n,e,t){let r=Rr(n),i=o=>{let s=r==null;if(o.match==="blank")return s;if(o.match==="notBlank")return!s;if(s)return!1;let a=r,l=o.value!=null?Rr(o.value):null;if(l==null)return!1;switch(o.match){case"equals":return a===l;case"notEquals":return a!==l;case"lessThan":return a<l;case"greaterThan":return a>l;case"inRange":{let d=o.value2!=null?Rr(o.value2):null;return d!=null?a>=l&&a<=d:a>=l}default:return!0}};return e.length===0||(t==="or"?e.some(i):e.every(i))}function Is(n,e){return e.length===0?!0:e.some(t=>t==null&&n==null||t===n)}function Oi(n,e){let t=e.type!=="set"&&e.operator==="or"?"or":"and";switch(e.type){case"text":return xs(n,e.conditions,t);case"number":return Ss(n,e.conditions,t);case"date":return Ms(n,e.conditions,t);case"set":return Is(n,e.values);default:return!0}}function Fi(n,e,t){if(n.kind==="condition"){let i=e.get(n.colId);return i?o=>Oi(t(o,i),n.filter):()=>!0}let r=n.children.map(i=>Fi(i,e,t));return i=>{let o=n.operator==="or"?r.some(s=>s(i)):r.every(s=>s(i));return n.not?!o:o}}function Sr(n,e,t,r,i){let o=new Map(n.map(d=>[d.id,d])),s=Object.entries(e).flatMap(([d,u])=>{let c=o.get(d);return c?[{column:c,filter:u}]:[]}),a=t?Fi(t.root,o,i):()=>!0,l=r?.trim().toLowerCase().split(/\s+/).filter(Boolean)??[];return d=>!s.every(({column:u,filter:c})=>Oi(i(d,u),c))||!a(d)?!1:l.every(u=>n.some(c=>Ni(i(d,c)).includes(u)))}var Hi=typeof Intl<"u"?new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"}):null;function As(n,e){let t=n==null||n==="",r=e==null||e==="";return!t&&!r?null:t&&r?0:t?1:-1}function ks(n,e){let t=Number.isNaN(n),r=Number.isNaN(e);return t||r?t===r?0:t?1:-1:n-e}function Ls(n,e){return n===e?0:n?1:-1}function st(n,e){let t=As(n,e);if(t!==null)return t;if(typeof n=="number"&&typeof e=="number")return ks(n,e);if(n instanceof Date&&e instanceof Date)return n.getTime()-e.getTime();if(typeof n=="boolean"&&typeof e=="boolean")return Ls(n,e);let r=String(n),i=String(e);return Hi?Hi.compare(r,i):r.localeCompare(i)}function Mr(n,e,t,r){let i=new Map(t.map(a=>[a.id,a])),o=e.flatMap(a=>{let l=i.get(a.colId);return l?[{column:l,compare:l.colDef.comparator??st,direction:a.direction}]:[]}),s=n.map(a=>({node:a,values:o.map(({column:l})=>r(a,l))}));return s.sort((a,l)=>{for(let d=0;d<o.length;d++){let u=o[d],c=u.compare(a.values[d],l.values[d],a.node,l.node);if(c!==0)return u.direction==="asc"?c:-c}return 0}),s.map(({node:a})=>a)}function Vi(){return{count:0,numeric:0,sum:0,min:1/0,max:-1/0}}function Bi(n,e){n.count++,!(typeof e!="number"||!Number.isFinite(e))&&(n.numeric++,n.sum+=e,n.min=Math.min(n.min,e),n.max=Math.max(n.max,e))}function _i(n,e){return e==="count"?n?.count??0:n?.numeric?e==="min"?n.min:e==="max"?n.max:Number.isFinite(n.sum)?e==="avg"?n.sum/n.numeric:n.sum:null:null}function at(n,e){let t=Vi();for(let r of n)Bi(t,r);return _i(t,e)}var ke={sum:n=>at(n,"sum"),avg:n=>at(n,"avg"),count:n=>n.length,min:n=>at(n,"min"),max:n=>at(n,"max"),first:n=>n.length>0?n[0]:null,last:n=>n.length>0?n[n.length-1]:null};function zi(n,e,t){if(e===ke.count)return n.length;let r=["sum","avg","min","max"].find(o=>e===ke[o]);if(!r)return e(n.map(t));let i=Vi();for(let o of n)Bi(i,t(o));return _i(i,r)}function lt(n){let e={...ke,...n??{}};return t=>e[t]}var dt="group:";function Wi(n){return n==null?"null":n instanceof Date?JSON.stringify(["date",String(n.getTime())]):JSON.stringify([typeof n,Ir(n)])}function Ir(n){return n==null?"(\u7A7A)":String(n)}function $i(n){return dt+JSON.stringify(n)}function Gs(n,e,t){let r=new Map;for(let i of n){let o=t(i,e),s=Wi(o),a=r.get(s);a||(a={key:s,label:Ir(o),rows:[]},r.set(s,a)),a.rows.push(i)}return[...r.values()].sort((i,o)=>i.label.localeCompare(o.label,void 0,{numeric:!0,sensitivity:"base"})||i.key.localeCompare(o.key))}function Ki(n,e,t,r,i){let o=[],s=(a,l,d)=>{if(l===e.length)return{display:a,leaves:a};let u=[],c=[];for(let h of Gs(a,e[l],t)){let p=[...d,[e[l].id,h.key]],m=$i(p);o.push(m);let g=s(h.rows,l+1,p);if(u.push({id:m,data:null,rowIndex:-1,selected:!1,isGroup:!0,groupLevel:l,groupKey:h.label,leafNodes:g.leaves,aggValues:r(g.leaves)}),i.has(m))for(let v of g.display)u.push(v);if(l>0)for(let v of g.leaves)c.push(v)}return{display:u,leaves:c}};return{rows:s(n,0,[]).display,ids:o}}function Ui(n,e,t,r){let i=new Set([...n].filter(l=>l.startsWith("/g0:")));if(!i.size)return{expanded:n,ambiguous:[]};let o=new Map;for(let l of e){let d=[],u="";for(let c=0;c<t.length;c++){let h=r(l,t[c]);if(d.push([t[c].id,Wi(h)]),u+=`/g${c}:${Ir(h)}`,!i.has(u))continue;let p=$i(d);o.set(u,o.has(u)&&o.get(u)!==p?null:p)}}let s=new Set([...n].filter(l=>!i.has(l))),a=[];for(let l of i){let d=o.get(l);d?s.add(d):d===null?a.push(l):s.add(l)}return{expanded:s,ambiguous:a}}function Ps(n,e){let t=n?[n.root]:[];for(;t.length;){let r=t.pop();if(r.kind==="condition")e.add(r.colId);else for(let i of r.children)t.push(i)}}function ji(n){let e=new Set(Object.keys(n.filterModel));Ps(n.advancedFilter,e);let t=new Set(n.sortModel.map(a=>a.colId));for(let a of t)e.add(a);let r=n.columns.some(a=>a.colDef.rowGroup===!0),i=!!n.quickFilter?.trim(),o=n.columns.filter(a=>e.has(a.id)||i||a.colDef.rowGroup===!0||r&&a.colDef.aggFunc!=null),s=new Set;for(let a of o){let l=a.colDef;if(r&&l.rowGroup!==!0&&l.aggFunc!=null&&n.customAggregates?.[l.aggFunc]||l.valueGetter||t.has(a.id)&&l.comparator||!l.field)return null;s.add(l.field)}return[...s]}function qi(n){return n!=null&&(typeof n=="object"||typeof n=="function")}function Yi(n,e){let t=new WeakMap;for(let r of n){if(r.data==null)continue;let i=e.map(o=>H(r.data,o));i.some(qi)||t.set(r,i)}return t}function Xi(n,e,t,r){return t.length?!r||n===e||n==null||e==null?!0:t.some((i,o)=>{let s=H(e,i);return qi(s)||!Object.is(r[o],s)}):!1}function ne(n){return ie(n.reason,"Block request aborted")}function ut(n){return Number.isFinite(n)?Math.max(1,Math.trunc(n)):1}var ct=class{constructor(e,t,r=4){this.maxBlocks=e;this.uo=t;this.maxConcurrentRequests=r;this.ee=new Map;this.Y=new Map;this.sa=0;this.so=0;this.ao=0;this.aa=0;this.la=0;this.Ai=0;this.ki=new Set;this.maxBlocks=ut(e),this.maxConcurrentRequests=ut(r)}configure(e,t=this.maxConcurrentRequests){this.maxBlocks=ut(e),this.maxConcurrentRequests=ut(t),this.lo(),this.Li()}tu(e){this.ki=e,this.lo()}peek(e){let t=this.ee.get(e);if(t)return t.touchedAt=++this.sa,t}has(e){return this.ee.has(e)}rr(e){let t=this.Y.get(e);t&&(this.Y.delete(e),t.controller.abort(),t.state==="queued"&&t.reject(ne(t.controller.signal)));let r=this.ee.get(e);r&&(this.ee.delete(e),this.uo?.(e,r))}load(e,t,r,i=0){if(r?.aborted)return Promise.reject(ne(r));let o=this.peek(e);if(o)return this.ao++,Promise.resolve(o);let s=this.Y.get(e);if(s)return this.ao++,s.priority=Math.max(s.priority,i),this.Li(),this.da(e,s,r);this.aa++;let a=new AbortController,l,d,u=new Promise((p,m)=>{l=p,d=m}),c={controller:a,promise:u,consumers:0,loader:t,priority:i,state:"queued",resolve:l,reject:d};this.Y.set(e,c);let h=this.da(e,c,r);return this.Li(),h}ru(){this.so++,this.ki.clear();for(let e of this.Y.values())e.controller.abort(),e.state==="queued"&&e.reject(ne(e.controller.signal));this.Y.clear();for(let[e,t]of this.ee)this.uo?.(e,t);this.ee.clear()}snapshot(){let e=0,t=0;for(let r of this.ee.values())e+=r.rows.length;for(let r of this.Y.values())r.state==="active"&&t++;return{cachedBlockCount:this.ee.size,loadingBlockCount:this.Y.size,activeRequestCount:t,queuedRequestCount:Math.max(0,this.Y.size-t),cachedRowCount:e,hitCount:this.ao,missCount:this.aa,evictionCount:this.la}}Li(){for(;this.Ai<this.maxConcurrentRequests;){let e,t;for(let[r,i]of this.Y)i.state!=="queued"||i.controller.signal.aborted||(!t||i.priority>t.priority)&&(e=r,t=i);if(e==null||!t)return;this.iu(e,t)}}iu(e,t){t.state="active",this.Ai++;let r=this.so;this.nu(t).then(i=>{r===this.so&&!t.controller.signal.aborted&&(this.ee.set(e,{rows:i.rows,...i.lastRow==null?{}:{lastRow:i.lastRow},touchedAt:++this.sa}),this.lo()),t.resolve(i)},t.reject).finally(()=>{this.Ai=Math.max(0,this.Ai-1),this.Y.get(e)===t&&this.Y.delete(e),this.Li()})}nu(e){let{signal:t}=e.controller;return ot(Promise.resolve().then(()=>{if(t.aborted)throw ne(t);return e.loader(t)}),t,()=>ne(t))}da(e,t,r){return t.consumers++,new Promise((i,o)=>{let s=!1,a=d=>{s||(s=!0,r?.removeEventListener("abort",l),t.consumers=Math.max(0,t.consumers-1),d())},l=()=>a(()=>{t.consumers===0&&this.Y.get(e)===t&&(this.Y.delete(e),t.controller.abort(r?.reason),t.state==="queued"&&t.reject(ne(t.controller.signal))),o(ne(r))});r?.addEventListener("abort",l,{once:!0}),t.promise.then(d=>a(()=>i(d)),d=>a(()=>o(d instanceof Error?d:new Error(String(d??"Block request failed")))))})}lo(){let e=Math.max(this.maxBlocks,this.ki.size+1);for(;this.ee.size>e;){let t=-1,r=Number.POSITIVE_INFINITY;for(let[o,s]of this.ee)this.ki.has(o)||s.touchedAt<r&&(t=o,r=s.touchedAt);if(t<0)return;let i=this.ee.get(t);this.ee.delete(t),this.la++,i&&this.uo?.(t,i)}}};function Le(n,e){if(n==null||typeof n!="object")return;let t=n[e];return Array.isArray(t)?t:void 0}var ht=class{constructor(e){this.e=e;this.c=[];this.H=[];this.te=new Map;this.be=[];this.p=new Map;this.ke={};this.Le=null;this.$e=null;this.L=new Set;this.K=new Set;this.ir=[];this.Fr=new Map;this.ua=[];this.G=null;this.nr=!1;this.ca=!1;this.et=0;this.Gi=null;this.Pi=null;this.Ni=new WeakMap;this.Hr=new WeakMap;this.tt=new Map;this.Vr=new Map;this.Br=0;this.Oi=0;this.rt=null;this.it=new Map;this.Rt=new Map;this.Fi=new Set;this.St=new Map;this.nt=new ct(12,e=>this.ha(e));this._r=0;this.Hi=null;this.co=!1;this.pa=0;this.ne=[];this.z=1;this.Kr=20;this.Le=O(e.r.advancedFilterModel)}resolveRowId(e,t,r){let i=this.e.r.resolveRowId;if(!i)return r;try{let o=i({data:e,index:t,api:this.e.api});if(typeof o=="string"&&o.length>0)return o;this.e.reportError(new Error("rowKey must resolve to a non-empty identifier"),"rowKey",{index:t})}catch(o){this.e.reportError(o,"rowKey",{index:t})}return r}get O(){return this.e.r.treeData}get g(){return this.e.r.datasource!=null}get we(){return this.g&&this.e.r.datasourceMode==="block"}or(){if(this.g){if(this.we)return this.sr();let e=Math.max(0,this.be.length-this.c.length);return(this.G??this.c.length)+e}return this.be.length}ho(){return this.Br}zr(){return this.Oi}ou(){return this.ca}Vi(e){return!this.g||e?.aborted?Promise.resolve():(this.Oi++,this.e.Ce(),this.e.api.editing.stop({cancel:!0}),this.e.V.clear(),this.Bi(),this.G=null,this.nr=!1,this.c=[],this.H=[],this.p.clear(),this.L.clear(),this.e.B.clear(),this.C(),this.e.h({data:!0}),this.we?(this.nt.configure(this.e.r.maxBlocksInCache,this.e.r.datasourceMaxConcurrentRequests),this._i(0,e)):this.fa(0,void 0,e))}Mt(e){this.ca=e,this.e.o.Mt(e,this.e.T("loading"))}fa(e,t,r){if(!this.g||this.nr||this.G!=null&&e>=this.G)return Promise.resolve();let i=this.e.r.blockSize,o=t??e+i;if(o<=e)return Promise.resolve();let s=++this.et,a=new AbortController,l=()=>a.abort(r?.reason);return r?.addEventListener("abort",l,{once:!0}),this.Gi=a,this.nr=!0,this.Mt(!0),new Promise(d=>{let u=!1;this.Pi=d;let c=h=>{u||(u=!0,r?.removeEventListener("abort",l),s===this.et&&(this.nr=!1,this.Gi=null,this.Pi=null,this.Mt(!1),h!=null&&h?.name!=="AbortError"&&this.e.reportError(h,"datasource.getRows",{startRow:e,endRow:o})),d())};this.ma(e,o,a.signal,(h,p)=>{if(s!==this.et||this.e.s()||a.signal.aborted){c();return}typeof p=="number"&&p>=0?this.G=p:h.length<o-e&&(this.G=e+h.length);let m=this.c.length===0;this.su(h),c(),this.C(),this.e.h({data:!0}),m&&this.e.Te(),this.e._.zi()},h=>c(a.signal.aborted||this.e.s()?void 0:h??new Error("Datasource request failed")))})}Bi(){this.et++,this.Gi?.abort(),this.Gi=null,this.nr=!1,this.Mt(!1),this.Pi?.(),this.Pi=null,this.nt.ru(),this.it.clear(),this.Rt.clear(),this.Fi.clear();for(let[e,t]of this.St)this.p.get(e)===t&&this.p.delete(e);this.St.clear()}su(e){for(let t of e){if(t==null)continue;let r=this.c.length,i=this.resolveRowId(t,r,`inf-${this.e.ar()}`);if(this.p.has(i)){this.e.reportError(new Error(`Duplicate row id: ${i}`),"datasource.getRows",{rowId:i});continue}let o={id:i,data:t,rowIndex:-1,selected:this.e.m.po(i)};this.c.push(o),this.p.set(i,o),this.H.push(o)}}_i(e,t,r=0){if(!this.we||e<0)return Promise.resolve();if(t?.aborted)return Promise.reject(this.ga(t.reason));let i=this.e.r.blockSize,o=this.et,s=e*i;if(s>=this.sr())return Promise.resolve();let a=this.G==null?s+i:Math.min(this.G,s+i),l=this.nt.load(e,d=>this.au(s,a,d),t,r);return this.Mt(this.c.length===0&&this.nt.snapshot().loadingBlockCount>0),l.then(d=>{o!==this.et||t?.aborted||this.e.s()||!this.we||!this.nt.has(e)||this.Fi.has(e)||(this.lu(e,d),this.C(),this.e.h({data:!0}),this.e._.zi(),o===this.et&&!this.e.s()&&this.ya(this.e.a.fo().lastExcl-1))}).catch(d=>{throw d?.name!=="AbortError"&&this.e.reportError(d,"datasource.getRows",{startRow:s,endRow:a}),d}).finally(()=>{o===this.et&&this.Mt(this.c.length===0&&this.nt.snapshot().loadingBlockCount>0)})}au(e,t,r){return new Promise((i,o)=>{this.ma(e,t,r,(s,a)=>i({rows:s,...typeof a=="number"&&a>=0?{lastRow:a}:{}}),s=>o(s instanceof Error?s:new Error(typeof s=="string"?s:"Datasource request failed")))})}ma(e,t,r,i,o){let s=this.e.r.datasource,a=0,l=null,d=!1,u=p=>{d||(d=!0,l!=null&&clearTimeout(l),r.removeEventListener("abort",c),p())},c=()=>u(()=>o(this.ga(r.reason)));r.addEventListener("abort",c,{once:!0});let h=()=>{if(d)return;if(r.aborted||this.e.s()){c();return}a++;let p=!1,m=g=>{if(!(p||d)){if(p=!0,r.aborted||this.e.s()){c();return}a<=this.e.r.datasourceRetryCount?l=setTimeout(h,this.retryDelay(a)):u(()=>o(g))}};try{let g=s.getRows({startRow:e,endRow:t,sortModel:this.e.n.Q(),filterModel:this.De(),advancedFilterModel:this.It(),quickFilterText:this.$e,signal:r,onSuccess:(v,C)=>{p||d||(p=!0,u(()=>i(v??[],C)))},fail:m});g&&typeof g.catch=="function"&&g.catch(m)}catch(g){m(g)}};h()}lu(e,t){let r=this.e.r.blockSize,i=e*r;this.ha(e),typeof t.lastRow=="number"&&t.lastRow>=0?this.G=t.lastRow:t.rows.length<r&&(this.G=i+t.rows.length),t.rows.forEach((o,s)=>{if(o==null)return;let a=i+s;if(this.G!=null&&a>=this.G)return;let l=this.resolveRowId(o,a,`block-${a}`),d=this.St.get(l),u=this.p.get(l);if(u&&u!==d&&u.rowIndex!==a){this.e.reportError(new Error(`Duplicate row id: ${l}`),"datasource.getRows",{rowId:l});return}let c=d??{id:l,data:o,rowIndex:a,selected:this.e.m.po(l)};c.rowIndex=a,c.selected=this.e.m.po(l),this.St.delete(l),this.it.set(a,c),this.Rt.delete(a),this.p.set(l,c),this.Hr.set(c,a+1)}),this.va(),this.Fi.add(e)}ha(e){this.Fi.delete(e);let t=this.e.r.blockSize,r=e*t,i;for(let o=r;o<r+t;o++){let s=this.it.get(o);s&&(i??(i=new Set(this.e.V.getDirtyRowIds())),this.it.delete(o),i.has(s.id)?this.St.set(s.id,s):this.p.get(s.id)===s&&this.p.delete(s.id))}this.va()}va(){this.c=[...this.it.entries()].sort(([e],[t])=>e-t).map(([,e])=>e),this.H=this.c}sr(){if(this.G!=null)return this.G;if(this.e.r.datasourceRowCount!=null)return this.e.r.datasourceRowCount;if(this.it.size===0)return this.e.r.blockSize;let e=0;for(let t of this.it.keys())e=Math.max(e,t+1);return e+this.e.r.blockSize}du(e){let t=this.Rt.get(e);if(!t&&(t={id:`__mach_loading_${e}`,data:null,rowIndex:e,selected:!1,loading:!0},this.Rt.set(e,t),this.Rt.size>2e3)){let r=this.Rt.keys().next().value;r!=null&&this.Rt.delete(r)}return t}ga(e){return ie(e,"Operation aborted")}retryDelay(e){let t=Math.min(this.e.r.datasourceRetryDelay*2**Math.max(0,e-1),3e4),r=this.e.r.datasourceRetryJitter;return Math.max(0,Math.round(t*(1+(Math.random()*2-1)*r)))}uu(e){if(this.we){this.ya(e);return}if(!this.g||this.nr)return;let t=this.c.length;if(this.G!=null&&t>=this.G)return;let r=this.e.r.infiniteBufferRows;if(e+r<t&&e<t)return;let i=this.e.r.blockSize,o=this.G==null?t+i:Math.min(this.G,t+i);this.fa(t,o)}ya(e){if(e<0)return;this.ba();let t=this.e.r.blockSize,r=Math.floor(e/t),i=Math.floor(this.e.a.fo().first/t),o=this.e.r.blockPrefetch,s=r<this.pa?-1:1;this.pa=r;for(let a=i;a<r;a++)this._i(a,void 0,o+2).catch(()=>{});for(let a=0;a<=o;a++){let l=a===0?[r]:[r+s*a,r-s*a];for(let d of l)d<0||d*t>=this.sr()||this._i(d,void 0,o-a+1).catch(()=>{})}}At(){return this.Vi().catch(()=>{})}cu(){return this.Bi(),this.g?this.Vi().catch(()=>{}):(this.G=null,this.ot(this.e.r.rowData),this.e.h({data:!0}),Promise.resolve())}destroy(){this.rt=null,this.Bi(),this.wa(),this.mo(),this.c=this.H=this.be=this.ne=[],this.p.clear(),this.te.clear(),this.Fr.clear(),this.ua=[],this.L.clear(),this.K.clear(),this.ir=[]}go(e,t,r){if(!this.we)return Promise.resolve();this.ba();let i=this.e.r.blockSize,o=Math.max(0,Math.trunc(e)),s=Math.min(this.sr(),Math.max(o,Math.trunc(t))),a=Math.floor(o/i),l=Math.max(a,Math.floor(Math.max(o,s-1)/i)),d=[];for(let u=a;u<=l;u++)d.push(this._i(u,r,100));return Promise.all(d).then(()=>{})}hu(){this.we&&(this.Oi++,this.e.Ce(),this.e.api.editing.stop({cancel:!0}),this.e.V.clear(),this.Bi(),this.e.B.clear(),this.c=[],this.H=[],this.p.clear(),this.C(),this.e.h({data:!0}))}pu(){return this.nt.snapshot()}ba(){let e=new Set(this.e.V.getDirtyRowIds());for(let[l,d]of this.St)e.has(l)||(this.St.delete(l),this.p.get(l)===d&&this.p.delete(l));let t=this.e.r.blockSize,r=new Set,{first:i,lastExcl:o}=this.e.a.fo();for(let l=i;l<o;l+=t)r.add(Math.floor(l/t));o>i&&r.add(Math.floor((o-1)/t));let s=this.e.a.D;s&&r.add(Math.floor(s.rowIndex/t));let a=this.e.l.fu();a!=null&&r.add(Math.floor(a/t)),this.nt.tu(r)}ot(e){this.Oi++,this.e.Ce(),this.e.api.editing.stop({cancel:!0}),this.wa(),this.e.V.clear();let t=this.e.r.resolveRowId,r=this.e.r.childrenKey,i=[],o=[],s=new Map,a=new Map,l=0,d=(u,c,h)=>{let p=l++,m=this.resolveRowId(u,p,`auto-${p}`);if(s.has(m))return this.e.reportError(new Error(`Duplicate row id: ${m}`),"rowData",{rowId:m,index:p}),null;let g=this.O?Le(u,r):void 0,v={id:m,data:u,rowIndex:-1,selected:!1,treeChildrenLoaded:Array.isArray(g)};if(this.Ni.set(v,c),i.push(v),s.set(m,v),h!=null){let C=a.get(h)??[];C.push(m),a.set(h,C)}else o.push(v);if(this.O&&Array.isArray(g))for(let C of g)C!=null&&d(C,c+1,m);return v};(e??[]).forEach(u=>{u!=null&&d(u,0,null)}),this.c=i,this.H=o,this.te=a,this.p=s,this.e.B.clear();for(let u of[...this.L])s.has(u)||this.L.delete(u);if(this.e.r.defaultExpandAll)for(let u of i)this.Ca(u.id)>0&&this.L.add(u.id);this.e.m.Ta(t!=null),this.C()}Wr(e){return this.te.get(e)??[]}Ca(e){return this.te.get(e)?.length??0}yo(e){return this.Ca(e)>0}isTreeRowLoading(e){return this.p.get(e)?.treeLoading===!0}wa(){for(let e of this.tt.values())e.abort();this.tt.clear(),this.Vr.clear()}loadTreeChildren(e,t=!1){let r=this.p.get(e),i=this.e.r.loadTreeChildren;if(!this.O||!r?.data||!i)return Promise.resolve([]);if(!t&&r.treeChildrenLoaded)return Promise.resolve(this.Wr(e).flatMap(l=>{let d=this.p.get(l)?.data;return d==null?[]:[d]}));let o=this.Vr.get(e);if(o&&!t)return o;this.tt.get(e)?.abort();let s=new AbortController;this.tt.set(e,s),r.treeLoading=!0,r.treeLoadError=void 0,this.e.h({data:!0});let a=Promise.resolve().then(()=>i({data:r.data,node:r,api:this.e.api,signal:s.signal})).then(l=>{if(s.signal.aborted||this.e.s())return[];if(!Array.isArray(l))throw new TypeError("[MachTable] loadTreeChildren must resolve to an array.");return this.mu(r,l),r.treeChildrenLoaded=!0,r.treeLoadError=void 0,this.e.emit("treeChildrenLoaded",{rowId:e,rowNode:r,children:l}),l}).catch(l=>{if(s.signal.aborted||l?.name==="AbortError")return[];throw r.treeLoadError=l,r.treeChildrenLoaded=!1,this.e.reportError(l,"treeData.loadChildren",{rowId:e}),this.e.emit("treeChildrenLoadFailed",{rowId:e,rowNode:r,error:l}),l}).finally(()=>{this.tt.get(e)===s&&(this.tt.delete(e),this.Vr.delete(e),r.treeLoading=!1,this.e.h({data:!0}))});return this.Vr.set(e,a),a}mu(e,t){let r=new Set,i=[...this.Wr(e.id)];for(;i.length>0;){let s=i.pop();r.has(s)||(r.add(s),i.push(...this.Wr(s)))}this.gu(t,r);for(let s of r)this.tt.get(s)?.abort(),this.tt.delete(s),this.Vr.delete(s),this.te.delete(s),this.p.delete(s),this.L.delete(s);this.te.delete(e.id);let o=this.vo(e)+1;for(let s of t)s!=null&&this.bo(e,s,o);this.Da(),this.e.m.Ta(this.e.r.resolveRowId!=null),this.C(),this.e.h({data:!0})}gu(e,t){let r=this.e.r.resolveRowId,i=r?new Set([...this.p.keys()].filter(l=>!t.has(l))):null,o=new WeakSet,s=[...e],a=0;for(;s.length>0;){let l=s.pop();if(l==null)continue;if(typeof l=="object"){if(o.has(l))throw new TypeError("[MachTable] Lazy tree children contain a cyclic object graph.");o.add(l)}if(r&&i){let u=r({data:l,index:a++,api:this.e.api});if(typeof u!="string"||u.length===0)throw new TypeError("[MachTable] rowKey must resolve to a non-empty identifier for lazy tree children.");if(i.has(u))throw new Error(`Duplicate row id: ${u}`);i.add(u)}let d=Le(l,this.e.r.childrenKey);d&&s.push(...d)}}$r(e,t=!0){let r=this.e.r.resolveRowId,i=[],o=[],s=[];if(e.remove?.length){let l=new Set,d=new Set,u=h=>{if(r){let m=[this.resolveRowId(h,-1,`__missing_remove_${this.e.ar()}`)];for(;m.length>0;){let g=m.pop();if(!l.has(g)){l.add(g);for(let v of this.te.get(g)??[])m.push(v)}}}else{let p=[h];for(;p.length>0;){let m=p.pop();d.add(m);let g=this.O?Le(m,this.e.r.childrenKey):void 0;if(g)for(let v of g)p.push(v)}}};e.remove.forEach(u),this.c=this.c.filter(h=>{let p=l.has(h.id)||h.data!=null&&d.has(h.data);return p&&(s.push(h.id),this.p.delete(h.id),this.te.delete(h.id)),!p});let c=new Set(this.c);this.H=this.H.filter(h=>c.has(h))}if(e.update?.length)for(let l of e.update){let d;r?d=this.p.get(this.resolveRowId(l,-1,`__missing_update_${this.e.ar()}`)):d=this.c.find(u=>u.data===l),d&&(o.push({node:d,before:d.data,after:l}),d.data=l,s.push(d.id),this.e.a.Wi(d),i.push(d))}if(e.add?.length){let l=e.addIndex!=null?Math.max(0,Math.min(e.addIndex,this.H.length)):this.H.length,d=[];e.add.forEach((u,c)=>{let h=this.resolveRowId(u,l+c,`add-${this.e.ar()}`);if(this.p.has(h)){this.e.reportError(new Error(`Duplicate row id: ${h}`),"transaction.add",{rowId:h});return}let p={id:h,data:u,rowIndex:-1,selected:!1};this.p.set(h,p),this.Ni.set(p,0);let m=this.O?Le(u,this.e.r.childrenKey):void 0;if(m)for(let g of m)g!=null&&this.bo(p,g,1);d.push(p)}),this.H=this.H.slice(0,l).concat(d,this.H.slice(l)),this.Da()}let a={pipelineChanged:this.yu(e,o),updatedRowIds:i.map(l=>l.id)};return this.vu(a,t),this.e.V.bu(s),a}vu(e,t){e.pipelineChanged&&(this.rt=null),t&&(e.pipelineChanged?this.C():e.updatedRowIds.length&&this.xa())}wu(e){if(e.length===0)return{pipelineChanged:!1,updatedRowIds:[]};let t=!1,r=new Set;for(let i of e){let o=this.$r(i,!1);t||(t=o.pipelineChanged);for(let s of o.updatedRowIds)r.add(s)}return t?this.C():r.size>0&&this.xa(),{pipelineChanged:t,updatedRowIds:[...r]}}yu(e,t){if(e.add?.length||e.remove?.length)return!0;if(!t.length)return!1;let r=this.Ea();if(r===null)return!0;if(!r.length)return!1;let i=this.rt;return!i||r.length!==i.fields.length||r.some((o,s)=>o!==i.fields[s])?!0:t.some(({node:o,before:s,after:a})=>Xi(s,a,r,i.values.get(o)))}Ea(){if(this.O||this.e.r.masterDetail||this.e.r.getRowHeight||this.Ra())return null;let e=this.e.n.u();if(e.some(r=>r.colDef.autoHeight===!0||r.colDef.autoRowSpan===!0||r.colDef.rowSpan!=null))return null;let t=!this.e.r.manualFiltering;return ji({columns:e,customAggregates:this.e.r.aggFuncs,sortModel:this.e.r.manualSorting?[]:this.e.n.Q(),filterModel:t?this.ke:{},advancedFilter:t?this.Le:null,quickFilter:t?this.$e:null})}Cu(){let e=this.Ea();this.rt=e?.length?{fields:e,values:Yi(this.c,e)}:null}xa(){this.e.emit("modelUpdated",{rowCount:this.ne.length})}bo(e,t,r){let i=this.resolveRowId(t,-1,`add-${this.e.ar()}`);if(this.p.has(i)){this.e.reportError(new Error(`Duplicate row id: ${i}`),"transaction.add",{rowId:i});return}let o=Le(t,this.e.r.childrenKey),s={id:i,data:t,rowIndex:-1,selected:!1,treeChildrenLoaded:Array.isArray(o)};this.p.set(i,s),this.Ni.set(s,r);let a=this.te.get(e.id)??[];if(a.push(s.id),this.te.set(e.id,a),!!o)for(let l of o)l!=null&&this.bo(s,l,r+1)}Da(){this.c=[];let e=t=>{this.c.push(t),this.p.has(t.id)||this.p.set(t.id,t);for(let r of this.te.get(t.id)??[]){let i=this.p.get(r);i&&e(i)}};for(let t of this.H)e(t)}lr(e){let t=JSON.stringify(this.ke),r=new Set(this.e.n.Z().map(o=>o.id));this.ke=Y(e,r);let i=JSON.stringify(this.ke)!==t;return i&&(this.rt=null),i}De(){return{...this.ke}}Tu(e=this.Le){let t=Object.keys(this.ke).length>0&&this.lr(this.ke),r=(e!=null||this.Le!=null)&&this.kt(e);return t||r}kt(e){let t=new Set(this.e.n.Z().map(s=>s.id)),r=O(e,t),i=JSON.stringify(this.Le);this.Le=r,this.e.r.advancedFilterModel=r;let o=JSON.stringify(r)!==i;return o&&(this.rt=null),o}It(){return O(this.Le)}dr(e){let t=e!=null&&e.trim()!==""?e:null;return t===this.$e?!1:(this.$e=t,this.rt=null,!0)}Sa(){return this.$e}$i(){return Object.keys(this.ke).length>0||this.Le!=null||this.$e!=null}C(){this.rt=null;let e=this.e.oe.start(),t=this.e.n.u(),r=(a,l)=>this.e.d(a,l);if(this.g){this.Du(e);return}if(this.xu(e))return;let i,o=[];if(this.O)i=this.Eu(t,r);else{i=this.c,this.$i()&&!this.e.r.manualFiltering&&(i=i.filter(Sr(t,this.ke,this.Le,this.$e,r)));let l=this.e.n.Q();if(l.length>0&&!this.e.r.manualSorting)try{i=Mr(i,l,t,r)}catch(u){this.e.reportError(u,"comparator",{sortModel:l})}let d=this.e.n.Qe();if(d.length>0){let u=this.Ru(i,d);i=u.rows,o=u.ambiguousExpansions}else if(this.e.r.masterDetail){let u=[];for(let c of i)u.push(c),this.L.has(c.id)&&this.isRowExpandable(c)&&u.push({id:`__detail__${c.id}`,data:c.data,rowIndex:-1,selected:!1,isDetail:!0,masterId:c.id});i=u}}for(let a of this.c)a.rowIndex=-1;let s=0;i.forEach((a,l)=>{a.rowIndex=l,!a.isDetail&&!a.isGroup&&(s++,this.Hr.set(a,s))}),this.ne=i,this.ur(),this.Cu(),this.Ma(r),this.e.emit("modelUpdated",{rowCount:i.length}),this.e.oe.wo(e),this.Su(o)}Du(e){this.c.forEach((t,r)=>{this.we||(t.rowIndex=r),this.Hr.set(t,this.we?t.rowIndex+1:r+1)}),this.be=this.c,this.ne=this.c,this.Fr.clear(),this.Br++,this.e.emit("modelUpdated",{rowCount:this.c.length}),this.e.oe.wo(e)}xu(e){let t=this.co;return this.co=!1,!t&&this.Ra()?(this.Mu(e),!0):(this.mo(),!1)}Ra(){if(!this.e.r.dataProcessor||this.c.length<this.e.r.dataProcessorMinRows||this.O||this.e.r.masterDetail||this.e.n.Qe().length>0)return!1;let e=!this.e.r.manualFiltering&&this.$i(),t=!this.e.r.manualSorting&&this.e.n.Q().length>0;return e||t}Mu(e){this.mo();let t=this.e.r.dataProcessor;if(!t)return;let r=++this._r,i=new AbortController;this.Hi=i;let o=this.e.n.u(),s=this.c.flatMap(d=>d.data==null?[]:[{id:d.id,data:d.data}]),a=!this.e.r.manualFiltering,l=!this.e.r.manualSorting;Promise.resolve().then(()=>t.process({rows:s,columns:o.map(d=>({colId:d.id,...d.colDef.field?{field:d.colDef.field}:{}})),sortModel:l?this.e.n.Q():[],filterModel:a?this.De():{},advancedFilterModel:a?this.It():null,quickFilterText:a?this.$e:null,signal:i.signal})).then(d=>{if(r!==this._r||i.signal.aborted||this.e.s())return;let u=new Set,c=[];for(let p of d.rowIds){if(u.has(p))continue;u.add(p);let m=this.p.get(p);m&&!m.isDetail&&!m.isGroup&&c.push(m)}for(let p of this.c)p.rowIndex=-1;c.forEach((p,m)=>{p.rowIndex=m,this.Hr.set(p,m+1)}),this.ne=c,this.ur();let h=(p,m)=>this.e.d(p,m);this.Ma(h),this.e.emit("modelUpdated",{rowCount:c.length}),this.e.oe.wo(e),this.e.h({data:!0})}).catch(d=>{r!==this._r||i.signal.aborted||this.e.s()||(this.e.reportError(d,"dataProcessor.process"),this.co=!0,this.C(),this.e.h({data:!0}))}).finally(()=>{r===this._r&&(this.Hi=null)})}mo(){this._r++,this.Hi?.abort(),this.Hi=null}get xe(){return this.e.r.paginationEnabled&&!this.g}ur(){if(!this.xe){this.be=this.ne,this.Br++;return}let e=this.Ur(),t=this.getPageCount();if(this.z>t&&(this.z=t),this.z<1&&(this.z=1),this.e.r.paginationPage=this.z,this.e.r.paginationMode==="server"){this.ne.forEach((o,s)=>{o.rowIndex=s}),this.be=this.ne,this.Br++;return}let r=(this.z-1)*e,i=this.ne.slice(r,r+e);i.forEach((o,s)=>{o.rowIndex=s}),this.be=i,this.Br++}Ur(){return this.Kr=this.e.r.paginationPageSize,Math.max(1,this.Kr)}Lt(){return this.xe?this.z:1}getTotalRowCount(){return this.g?this.or():this.xe&&this.e.r.paginationMode==="server"?this.e.r.paginationTotal:this.ne.length}getPageCount(){return this.xe?Math.max(1,Math.ceil(this.getTotalRowCount()/this.Ur())):1}Ia(){return this.ne}setPage(e,t=!1){if(!this.xe)return;let r=this.getPageCount(),i=Math.max(1,Math.min(Math.round(e)||1,r));i!==this.z&&(this.z=i,this.e.r.paginationPage=i,this.ur(),this.e.h({data:!0}),this.e.a.cr(0,"top"),t||this.Ki())}setPageSize(e){if(!this.xe)return;let t=Math.max(1,Math.round(e)||this.Ur()),r=(this.z-1)*this.Ur();this.e.r.paginationPageSize=t,this.Kr=t,this.z=Math.floor(r/t)+1,this.e.r.paginationPage=this.z,this.ur(),this.e.h({data:!0}),this.Ki()}Aa(e,t){this.Kr=Math.max(1,Math.round(t)||1),this.e.r.paginationPageSize=this.Kr,this.z=Math.max(1,Math.round(e)||1),this.e.r.paginationPage=this.z}ka(e){this.e.r.paginationEnabled!==e&&(this.e.r.paginationEnabled=e&&!this.g,this.e.r.paginationEnabled&&(this.z=1),this.ur(),this.e.h({data:!0}),this.Ki())}Iu(){this.xe&&(this.z=this.e.r.paginationMode==="server"?this.e.r.paginationPage:1,this.ur(),this.e.h({data:!0}),this.Ki())}Ki(){this.e.emit("paginationChanged",{page:this.Lt(),pageSize:this.Ur(),pageCount:this.getPageCount(),total:this.getTotalRowCount()})}Eu(e,t){let r=this.e.r.manualSorting?[]:this.e.n.Q(),i=new Map,o=this.$i()&&!this.e.r.manualFiltering,s=Sr(e,this.ke,this.Le,this.$e,t),a=u=>{let c=i.get(u.id);if(c!==void 0)return c;let h=!0;if(o){h=s(u);for(let p of this.te.get(u.id)??[]){let m=this.p.get(p);m&&a(m)&&(h=!0)}}return i.set(u.id,h),h},l=[],d=u=>{let c=u;r.length>0&&(c=Mr(u,r,e,t));for(let h of c)if(a(h)&&(l.push(h),this.L.has(h.id))){let p=(this.te.get(h.id)??[]).map(m=>this.p.get(m)).filter(m=>m!=null);d(p)}};return d(this.H),l}Au(){let e=this.ua,t=0;for(let r of this.be)!r.isDetail&&!r.isGroup&&(e[t++]=r);return e.length=t,e}ku(e,t,r,i){let o=t.colDef.rowSpan;if(!o)return 1;try{let s=o({api:this.e.api,colDef:t.colDef,column:t,node:e,data:e.data,value:r,rowIndex:e.rowIndex});return Math.max(1,Math.min(Math.round(s)||1,i))}catch(s){return this.e.reportError(s,"rowSpan",{colId:t.id,rowId:e.id}),1}}Lu(e,t,r,i,o){if(!r.colDef.autoRowSpan||i==null||i==="")return 1;let s=1;for(;t+s<e.length&&st(i,o(e[t+s],r))===0;)s++;return s}Gu(e,t,r){let i=new Int32Array(e.length),o=0;for(;o<e.length;){let s=e[o],a=r(s,t),l=t.colDef.rowSpan?this.ku(s,t,a,e.length-o):this.Lu(e,o,t,a,r);i[o]=l;for(let d=1;d<l;d++)i[o+d]=-1;o+=l}return i}Ma(e){if(this.Fr.clear(),this.O||this.e.r.masterDetail||this.e.n.Qe().length>0)return;let t=this.e.n.u().filter(i=>i.colDef.rowSpan!=null||i.colDef.autoRowSpan===!0);if(t.length===0)return;let r=this.Au();if(r.length!==0)for(let i of t)this.Fr.set(i.id,this.Gu(r,i,e))}Pu(e){return this.Fr.get(e)}La(e){return this.Hr.get(e)??0}vo(e){return this.Ni.get(e)??0}Ru(e,t){let r=lt(this.e.r.aggFuncs),i=this.e.n.Zd();this.ir=[];let o=l=>{let d={};for(let u of i){let c=r(u.colDef.aggFunc);if(c)try{d[u.id]=zi(l,c,h=>this.e.d(h,u))}catch(h){this.e.reportError(h,"aggFunc",{colId:u.id,aggFunc:u.colDef.aggFunc}),d[u.id]=null}}return d},s=Ui(this.K,this.c,t,(l,d)=>this.e.d(l,d));this.K=s.expanded;let a=Ki(e,t,(l,d)=>this.e.d(l,d),o,this.K);return this.ir=a.ids,{rows:a.rows,ambiguousExpansions:s.ambiguous}}Su(e){for(let t of e){if(this.e.s())return;this.e.reportError(new Error(`Ambiguous legacy group expansion: ${t}`),"gridState.groupExpansion",{groupId:t})}}isRowExpandable(e){if(this.O){if(this.yo(e.id)||e.treeLoading)return!0;if(e.treeChildrenLoaded||!e.data||!this.e.r.loadTreeChildren)return!1;let r=this.e.r.isTreeRowExpandable;if(!r)return!1;try{return r({data:e.data,node:e,api:this.e.api})}catch(i){return this.e.reportError(i,"isTreeRowExpandable",{rowId:e.id}),!1}}if(!this.e.r.masterDetail)return!1;let t=this.e.r.isRowExpandable;if(t)try{return t({data:e.data,node:e,api:this.e.api})}catch(r){return this.e.reportError(r,"isRowExpandable",{rowId:e.id}),!1}return!0}isRowExpanded(e){return this.L.has(e)}Nu(){return[...this.L]}Ou(){return[...this.K]}Fu(e,t){this.L=new Set(e.filter(r=>this.p.has(r))),this.K=new Set(t)}Hu(e){return this.Co(e,!0)}Vu(e){return this.Co(e,!1)}Ui(e){return this.Co(e,!this.L.has(e))}Co(e,t){let r=this.p.get(e);return!r||t&&!this.isRowExpandable(r)?!1:(t===this.L.has(e)||(t?this.L.add(e):this.L.delete(e),this.C(),this.e.h({data:!0}),this.e.emit("detailToggled",{rowId:e,rowNode:r,expanded:t}),t&&this.O&&!this.yo(e)&&!r.treeLoading&&this.loadTreeChildren(e).catch(()=>{})),t)}Bu(){let e=!1;for(let t of this.c)!this.L.has(t.id)&&this.isRowExpandable(t)&&(this.L.add(t.id),e=!0);e&&(this.C(),this.e.h({data:!0}))}_u(){this.L.size!==0&&(this.L.clear(),this.C(),this.e.h({data:!0}))}To(e){return this.setGroupExpanded(e,!this.K.has(e))}isGroupExpanded(e){return this.K.has(e)}zu(){if(this.ir.length===0)return;let e=!1;for(let t of this.ir)this.K.has(t)||(this.K.add(t),e=!0);e&&(this.C(),this.e.h({data:!0}))}Wu(){this.K.size!==0&&(this.K.clear(),this.C(),this.e.h({data:!0}))}setGroupExpanded(e,t){return!this.ir.includes(e)||t===this.K.has(e)||(t?this.K.add(e):this.K.delete(e),this.C(),this.e.h({data:!0})),t}Ga(){return!this.O&&!this.g&&!this.e.r.dataProcessor&&this.e.r.paginationMode!=="server"&&this.e.n.Q().length===0&&this.e.n.Qe().length===0}Pa(e,t){if(!this.Ga()||!Number.isInteger(e)||!Number.isInteger(t))return!1;let r=this.f(e),i=this.f(t);if(!r||!i||r.isDetail||i.isDetail||r.isGroup||i.isGroup)return!1;let o=this.c.indexOf(r),s=this.c.indexOf(i);return o<0||s<0||o===s?!1:(this.c.splice(o,1),this.c.splice(s,0,r),this.C(),this.e.h({data:!0}),!0)}ge(){return this.c}$u(){return this.H}st(){return this.be}P(){return this.we?this.sr():this.be.length}f(e){return this.we?e<0||e>=this.sr()?void 0:this.it.get(e)??this.du(e):this.be[e]}X(e){return this.p.get(e)}Ku(e){this.c.forEach(e)}Uu(e){let t=0;for(let r of this.ne)r.isDetail||r.isGroup||e(r,t++)}};var pt=class{constructor(e){this.e=e;this.S=new Set;this.Ke=null;this.jr=new Set}po(e){return this.S.has(e)}ju(e){return this.jr.has(e)}Ue(e){if(e.loading)return!1;let t=this.qu(e),r=t?.colDef.selectable;if(!t||!r)return!0;try{return r({api:this.e.api,colDef:t.colDef,column:t,node:e,data:e.data,value:this.e.d(e,t),rowIndex:e.rowIndex})}catch(i){return this.e.reportError(i,"selectable",{rowId:e.id,colId:t?.id}),!1}}qu(e){if(!(e.isGroup||e.isDetail))return this.e.n.u().find(t=>t.hasCheckbox&&t.colDef.selectable!=null)}Gt(){return this.e.i.ge().filter(e=>this.S.has(e.id))}Na(){return this.Gt().filter(e=>e.data!=null).map(e=>e.data)}Oa(){return[...this.S]}Yu(e){let t=new Set(e),r=this.e.i.ge().filter(i=>t.has(i.id)&&!i.isDetail&&!i.isGroup).map(i=>({node:i,selected:!0}));this.Ee(r,!0)}Ta(e){if(!e)this.S.clear(),this.Ke=null;else{let t=new Set(this.e.i.ge().map(r=>r.id));for(let r of[...this.S])t.has(r)||this.S.delete(r);this.Ke!=null&&!t.has(this.Ke)&&(this.Ke=null)}for(let t of this.e.i.ge())t.selected=this.S.has(t.id);this.Fa()}Ha(e){let t=e.leafNodes??[];if(t.length===0)return{all:!1,some:!1};let r=0,i=0;for(let o of t)this.Ue(o)&&(r++,this.S.has(o.id)&&i++);return r===0?{all:!1,some:!1}:{all:i===r,some:i>0}}Xu(e,t){let r=(e.leafNodes??[]).filter(i=>this.Ue(i));r.length!==0&&this.Ee(r.map(i=>({node:i,selected:t})))}Va(e,t,r=!1){this.Ee([{node:e,selected:t,clearOthers:r}])}Do(e,t=!0,r=!0){let i=this.e.i.X(e);i&&this.Va(i,t,r)}Ju(e,t){let r=t==="single";this.Ee([{node:e,selected:r?!0:!e.selected,clearOthers:r}]),this.Ke=e.id}Zu(e,t,r){return!r||!t.ctrlKey&&!t.metaKey?!1:(this.Ee([{node:e,selected:!e.selected}]),this.Ke=e.id,!0)}Qu(e,t,r){if(!r||!t.shiftKey||this.Ke==null)return!1;let i=this.e.i.X(this.Ke);if(!i||i.rowIndex<0||e.rowIndex<0)return!1;let o=Math.min(i.rowIndex,e.rowIndex),s=Math.max(i.rowIndex,e.rowIndex),a=[];for(let l=o;l<=s;l++){let d=this.e.i.f(l);d&&!d.isDetail&&!d.isGroup&&this.Ue(d)&&a.push({node:d,selected:!0})}return this.Ee(a),!0}Ba(e,t,r){let i=this.e.r.rowSelection;if(i==="none"||!this.Ue(e))return;if(r){this.Ju(e,i);return}let o=i==="multiple";this.Zu(e,t,o)||this.Qu(e,t,o)||(this.Ee([{node:e,selected:!0,clearOthers:!0}]),this.Ke=e.id)}selectAll(e=!0){let t=this.e.r.rowSelection;if(t==="none")return;let i=(e?this.e.i.st():this.e.i.ge()).filter(o=>!o.isDetail&&!o.isGroup&&this.Ue(o));if(i.length!==0){if(t==="single"){this.Ee([{node:i[0],selected:!0,clearOthers:!0}]);return}this.Ee(i.map(o=>({node:o,selected:!0})))}}deselectAll(){this.Ee([],!0)}ec(){let t=this.e.i.st().filter(r=>!r.isDetail&&!r.isGroup).filter(r=>this.Ue(r));if(t.length===0)return!1;if(this.e.i.g){let r=this.e.i.or();if(t.length<r)return!1}return t.every(r=>this.S.has(r.id))}tc(){let t=this.e.i.st().filter(i=>!i.isDetail&&!i.isGroup).filter(i=>this.Ue(i)),r=t.reduce((i,o)=>i+(this.S.has(o.id)?1:0),0);if(r===0)return!1;if(this.e.i.g){let i=this.e.i.or();if(t.length<i)return!0}return r>0&&r<t.length}rc(e,t=!1){this.Ee(e,t)}ic(e,t,r){!t&&!e.some(i=>i.clearOthers)||(this.S=t?new Set:new Set(e.filter(i=>i.selected).flatMap(i=>r?this._a(i.node):[i.node.id])))}nc(e,t){for(let r of e){if(!this.Ue(r.node))continue;let i=t?this._a(r.node):[r.node.id];for(let o of i)r.selected?this.S.add(o):this.S.delete(o)}}oc(e){let t=new Set;for(let r of new Set([...e,...this.S]))e.has(r)!==this.S.has(r)&&t.add(r);return t}sc(e,t,r){let i=[],o=new Set([...e,...r,...this.jr]);for(let s of this.e.i.ge()){let a=this.S.has(s.id);s.selected=a,(o.has(s.id)||t.get(s.id)!==a)&&s.rowIndex>=0&&i.push(s.rowIndex)}return i}Ee(e,t=!1){let r=new Set(this.S),i=this.e.i.O&&this.e.r.autoCheckedChildren;this.ic(e,t,i),this.nc(e,i);let o=this.oc(r),s=new Map;for(let d of this.e.i.ge())s.set(d.id,d.selected);let a=new Set(this.jr);this.Fa();let l=this.sc(o,s,a);o.size>0&&(this.e.a.at(l),this.e._.zi(),this.e.emit("selectionChanged",{selectedNodes:this.Gt(),selectedRows:this.Na()}))}_a(e){let t=[e.id],r=i=>{for(let o of this.e.i.Wr(i))t.push(o),r(o)};return r(e.id),t}Fa(){if(this.jr.clear(),!this.e.i.O)return;let e=t=>{let r=this.e.i.Wr(t);if(r.length===0)return{all:this.S.has(t),some:this.S.has(t)};let i=!0,o=!1;for(let s of r){let a=e(s);a.all?o=!0:(a.some&&(o=!0),i=!1)}return o&&!i&&this.jr.add(t),i?this.S.add(t):this.S.delete(t),{all:i,some:o}};for(let t of this.e.i.$u())e(t.id);for(let t of this.e.i.ge())t.selected=this.S.has(t.id)}};var ft=class{constructor(e){this.e=e;this.Pt=null;this.re=0;this.lt=0;this.Ge=null;this.Nt=null;this.dt=e=>{let t=this.Eo(e);t&&(this.lt=this.Ka(t,e.clientX),t.didResize||(t.didResize=Math.abs(this.lt-t.startWidth)>=.5),!this.re&&(this.re=requestAnimationFrame(()=>{this.re=0,this.dc()})))};this.Pe=e=>{let t=this.Eo(e);t&&(this.lt=this.Ka(t,e.clientX),t.didResize||(t.didResize=Math.abs(this.lt-t.startWidth)>=.5),this.uc(t))};this.Ft=e=>{this.Eo(e)&&this.Ot()};this.za=()=>{this.Ot()}}ac(e,t){if(!this.e.r.enableColumnResize||!t.resizable||e.isPrimary===!1)return;this.Ot();let r=e.currentTarget,i=t.currentWidth;this.lt=i,this.Pt={column:t,didResize:!1,handle:r,pointerId:e.pointerId,startFlex:t.flex,startManualWidth:t.manualWidth,startWidth:i,startX:e.clientX},window.addEventListener("pointermove",this.dt),window.addEventListener("pointerup",this.Pe,!0),window.addEventListener("pointercancel",this.Ft,!0),r.addEventListener("lostpointercapture",this.za);try{r.setPointerCapture?.(e.pointerId)}catch{}this.e.o.root.classList.add("mach-root--resizing"),r.classList.add("mach-header-resize--active"),this.lc(this.Pt)}Ot(e=!0){let t=this.Pt;t&&(this.Pt=null,this.xo(),this.Wa(t),e&&(t.column.manualWidth=t.startManualWidth,t.column.flex=t.startFlex,this.e.je()),this.e.o.root.classList.remove("mach-root--resizing"),this.$a(t))}uc(e){this.Pt=null,this.xo(),e.didResize&&(Math.abs(this.lt-e.startWidth)<.5?(e.column.manualWidth=e.startManualWidth,e.column.flex=e.startFlex):this.e.n.Ae(e.column,this.lt),this.e.je()),this.Wa(e);try{e.handle.releasePointerCapture?.(e.pointerId)}catch{}this.e.o.root.classList.remove("mach-root--resizing"),this.$a(e),e.didResize&&this.e.hr([e.column])}dc(){let e=this.Pt;!e||!this.e.n.Ae(e.column,this.lt)||(this.e.je(),this.qr(e),this.e.Ua(e.column,!1))}lc(e){this.Ge=document.createElement("div"),this.Ge.className="mach-column-resize-guide",this.Ge.setAttribute("aria-hidden","true"),this.Nt=document.createElement("span"),this.Nt.className="mach-column-resize-label",this.Ge.appendChild(this.Nt),this.e.o.root.appendChild(this.Ge),this.qr(e)}qr(e){if(!this.Ge||!this.Nt)return;let t=this.e.o.root,r=t.getBoundingClientRect(),i=e.handle.parentElement.getBoundingClientRect(),o=Math.max(0,Math.min(t.clientWidth,i.right-r.left-t.clientLeft)),s=Math.max(32,Math.min(t.clientWidth-32,o));this.Ge.style.left=`${o}px`,this.Ge.style.top=`${Math.max(0,i.top-r.top-t.clientTop)}px`,this.Nt.style.left=`${s-o}px`,this.Nt.textContent=`${Math.round(e.column.currentWidth)} px`}$a(e){e.handle.classList.remove("mach-header-resize--active"),this.Ge?.remove(),this.Ge=null,this.Nt=null}Ka(e,t){let r=Number.isFinite(t)?t:e.startX;return Math.max(1,e.startWidth+r-e.startX)}Eo(e){let t=this.Pt;return t&&e.pointerId===t.pointerId?t:null}xo(){this.re&&cancelAnimationFrame(this.re),this.re=0}Wa(e){window.removeEventListener("pointermove",this.dt),window.removeEventListener("pointerup",this.Pe,!0),window.removeEventListener("pointercancel",this.Ft,!0),e.handle.removeEventListener("lostpointercapture",this.za)}destroy(){this.Ot(!1),this.xo(),this.e.o.root?.classList.remove("mach-root--resizing")}};var Ji=6,mt=class{constructor(e){this.e=e;this.Yr=null;this.pr=null;this.Ro=!1;this.se=0;this.ji=null;this.dt=e=>{if(this.pr){this.pc(e);return}let t=this.Yr;t&&(Math.abs(e.clientX-t.startX)<Ji&&Math.abs(e.clientY-t.startY)<Ji||this.fc(e))};this.Pe=e=>{this.Yr=null,e.type!=="pointercancel"&&this.pr&&this.Io(e.clientX,e.clientY),this.So();let t=this.ja();t&&e.type!=="pointercancel"&&t.targetIndex>=0&&this.e.Nr(t.column.id,t.targetIndex)}}cc(e,t){e.button===0&&t.movable&&(this.Yr={column:t,startX:e.clientX,startY:e.clientY},window.addEventListener("pointermove",this.dt),window.addEventListener("pointerup",this.Pe),window.addEventListener("pointercancel",this.Pe))}hc(){let e=this.Ro;return this.Ro=!1,e}fc(e){let t=this.Yr;if(!t)return;let r=this.mc(t.column);if(!r||!r.parentElement){this.So();return}this.Ro=!0;let i=f("div","mach-drop-indicator"),o=f("div","mach-column-drag-ghost");o.textContent=t.column.colDef.headerName??t.column.colDef.field??t.column.id,o.ariaHidden="true",I(o,this.e.o.root),document.body.appendChild(o),r.parentElement.appendChild(i),r.classList.add("mach-header-cell--dragging"),this.e.o.root.classList.add("mach-root--dragging");let s=this.e.a.Mo(t.column),a=this.e.o.fr[s],l=this.e.n.w(s),d=new Float64Array(l.length+1),u=new Float64Array(l.length);for(let h=0;h<l.length;h++){let p=l[h].currentWidth;u[h]=d[h]+p/2,d[h+1]=d[h]+p}let c=o.getBoundingClientRect();this.pr={column:t.column,cellEl:r,ghost:o,indicator:i,targetIndex:-1,pane:s,containerLeft:a.getBoundingClientRect().left,startScrollLeft:this.e.o.M.center.scrollLeft,fromIndex:l.indexOf(t.column),midpoints:u,offsets:d,ghostWidth:c.width,ghostHeight:c.height},this.Io(e.clientX,e.clientY)}mc(e){let t=this.e.a.Mo(e);return this.e.o.fr[t].querySelector(`.mach-header-cell[data-col-id="${Ns(e.id)}"]`)}pc(e){this.ji={clientX:e.clientX,clientY:e.clientY},!this.se&&(this.se=requestAnimationFrame(()=>{this.se=0;let t=this.ji;this.ji=null,t&&this.Io(t.clientX,t.clientY)}))}Io(e,t){let r=this.pr;if(!r)return;let i=w(e+12,8,window.innerWidth-r.ghostWidth-8),o=w(t+12,8,window.innerHeight-r.ghostHeight-8);r.ghost.style.transform=`translate3d(${i}px, ${o}px, 0)`;let s=r.pane==="center"?this.e.o.M.center.scrollLeft-r.startScrollLeft:0,a=e-(r.containerLeft-s),l=r.midpoints.length;for(let d=0;d<r.midpoints.length;d++)if(a<r.midpoints[d]){l=d;break}r.targetIndex=l>r.fromIndex?l-1:l,r.indicator.style.transform=`translate3d(${r.offsets[l]}px, 0, 0)`}ja(){let e=this.pr;return e?(this.pr=null,e.cellEl.classList.remove("mach-header-cell--dragging"),e.ghost.remove(),e.indicator.remove(),this.e.o.root.classList.remove("mach-root--dragging"),e):null}So(){window.removeEventListener("pointermove",this.dt),window.removeEventListener("pointerup",this.Pe),window.removeEventListener("pointercancel",this.Pe),this.se&&cancelAnimationFrame(this.se),this.se=0,this.ji=null}destroy(){this.So(),this.ja(),this.Yr=null}};function Ns(n){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(n):n.replace(/[^a-zA-Z0-9_-]/g,"\\$&")}var Ar=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?$/;function gt(n,e=!0){if(n==="")return null;if(!e||typeof n!="string"||!Ar.test(n)||/^[+-]?0\d/.test(n))return n;let t=Number(n);return Number.isFinite(t)&&(!Number.isInteger(t)||Number.isSafeInteger(t))?t:n}function Os(n,e){let t=n==null?"":String(n);return t.includes(e)||t.includes('"')||t.includes(`
2
- `)||t.includes("\r")?'"'+t.replace(/"/g,'""')+'"':t}function oe(n){return typeof n!="string"||n===""||Ar.test(n)?n:/^[\s\u0000-\u001f]*[=+\-@]/.test(n)?"'"+n:n}function Zi(n,e={}){let t=e.columnSeparator??",",r=e.protectFormulas??!0,i=n.map(o=>o.map(s=>Os(r?oe(s):s,t)).join(t)).join(`\r
3
- `);return e.prependBOM?"\uFEFF"+i:i}function kr(n){return n==null?"":String(n)}function Fs(n,e){let t=e?oe(n):n,r=kr(t);return/["\t\n\r]/.test(r)?'"'+r.replace(/"/g,'""')+'"':r}function yt(n,e=!0){return n.map(t=>t.map(r=>Fs(r,e)).join(" ")).join(`
4
- `)}function vt(n){return wt(n," ")}function bt(n,e=","){return wt(n,e)}function wt(n,e){let t=[],r=[],i="",o=!1,s=0;for(;s<n.length;){let a=n[s];if(o){if(a==='"'){if(n[s+1]==='"'){i+='"',s+=2;continue}o=!1,s++;continue}i+=a,s++;continue}if(a==='"'&&i===""){o=!0,s++;continue}if(a===e){r.push(i),i="",s++;continue}if(a===`
5
- `||a==="\r"){r.push(i),t.push(r),r=[],i="",a==="\r"&&n[s+1]===`
6
- `?s+=2:s++;continue}i+=a,s++}return(i!==""||r.length>0)&&(r.push(i),t.push(r)),t}function Hs(n){let e=null;try{return e=document.createElement("textarea"),e.value=n,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy")}catch{return!1}finally{e?.remove()}}async function Ct(n){try{if(typeof navigator<"u"&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(n),!0}catch{}return Hs(n)}var Qi=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]),Vs=new Set([...Qi,"Enter","F2","Tab"," ","Escape","Delete","Backspace"]),Tt=class{constructor(e){this.e=e;this.Ya=e=>{if(this.Ao(e)||this.e.r.suppressClipboard)return;let t=this.e.a.Xr();if(!t)return;let r=this.e.Ja(t),i=e.clipboardData;i&&typeof i.setData=="function"?i.setData("text/plain",r):Ct(r),e.type==="cut"&&this.e.ko(t),e.preventDefault()};this.yc=e=>{if(this.Ao(e)||this.e.r.suppressClipboard)return;let t=this.e.a.Lo();if(!t)return;let r=e.clipboardData,i=r&&typeof r.getData=="function"?r.getData("text/plain"):null;typeof i!="string"||i===""||(e.preventDefault(),this.e.Za(i,t.row,t.colIdx))};this.gc=e=>{this.Ao(e)||this.e.s()||this.vc(e)||Vs.has(e.key)&&(this.bc(e)||this.wc(e)||this.Cc(e))}}init(){this.qa("addEventListener")}destroy(){this.qa("removeEventListener")}qa(e){let t=this.e.o.root;t[e]("keydown",this.gc),t[e]("copy",this.Ya),t[e]("cut",this.Ya),t[e]("paste",this.yc)}Xa(e,t,r){let i=this.e.n.u(),o=i.findIndex(d=>d.id===t);if(o<0)return null;let s=this.e.i.P(),a=o,l=e;for(let d=0;d<(i.length+1)*(s+1);d++){if(a+=r,a>=i.length){if(l>=s-1)return null;a=0,l=this.Ht(l+1,1)}else if(a<0){if(l<=0)return null;a=i.length-1,l=this.Ht(l-1,-1)}if(l<0||l>=s)return null;let u=this.e.i.f(l);if(u&&!u.isDetail&&this.e.l.U(u,i[a]))return{rowIndex:l,column:i[a]}}return null}Ht(e,t){let r=this.e.i.P();for(;e>=0&&e<r;){let i=this.e.i.f(e);if(!i||!i.isDetail)return e;e+=t}return-1}Ao(e){let t=e.target;return e.defaultPrevented||t instanceof HTMLElement&&(t.isContentEditable||!!t.closest("button,a[href],input,textarea,select"))||this.e.l.isEditing()}vc(e){if(!e.ctrlKey&&!e.metaKey)return!1;let t=e.key.toLowerCase();return t==="a"?(this.e.r.rowSelection==="multiple"&&(e.preventDefault(),this.e.m.selectAll(!0)),!0):e.altKey||t!=="z"&&t!=="y"?!1:(e.preventDefault(),t==="z"&&!e.shiftKey?this.e.B.undo():this.e.B.redo(),!0)}bc(e){let t=this.e.a;if(e.key==="Escape")return this.e.Ce(),this.e.r.enableRangeSelection&&t.Ne()&&(e.preventDefault(),t.mr()),!0;if(e.key!=="Delete"&&e.key!=="Backspace")return!1;if(!this.e.r.enableRangeSelection)return!0;let r=t.Ne();return r&&!(r.r1===r.r2&&r.c1===r.c2)&&(e.preventDefault(),this.e.ko(r)),!0}wc(e){if(this.e.a.D)return!1;let t=this.e.n.u();return this.e.i.P()>0&&t.length>0&&(e.preventDefault(),this.e.a.Oe(0,t[0].id)),!0}Cc(e){let t=this.e.a,r=t.D;if(!r)return;let i=this.e.n.u(),o=i.findIndex(u=>u.id===r.colId),s=this.e.i.P();if(o<0||s===0)return;let a={row:r.rowIndex,colIdx:o},l=this.Tc(e,a,i,s);if(!l)return;e.preventDefault();let d=l.row!==a.row||l.colIdx!==a.colIdx;if(e.shiftKey&&this.e.r.enableRangeSelection&&d){t.Dc(l.row,l.colIdx);return}d&&t.Oe(l.row,i[l.colIdx].id)}Tc(e,t,r,i){return Qi.has(e.key)?this.xc(e,t,r.length,i):e.key==="Enter"||e.key==="F2"?this.Ec(e,t,r,i):e.key===" "?(this.Rc(t.row),t):e.key==="Tab"?this.Sc(e,t,r):null}xc(e,t,r,i){let{row:o,colIdx:s}=t;switch(e.key){case"ArrowUp":o=this.qi(o,this.Ht(o-1,-1),i);break;case"ArrowDown":o=this.qi(o,this.Ht(o+1,1),i);break;case"ArrowLeft":s=Math.max(0,s-1);break;case"ArrowRight":s=Math.min(r-1,s+1);break;case"Home":s=0,e.ctrlKey&&(o=0);break;case"End":s=r-1,e.ctrlKey&&(o=Math.max(0,this.Ht(i-1,-1)));break;case"PageUp":case"PageDown":o=this.Mc(e.key,o,i);break}return{row:o,colIdx:s}}qi(e,t,r){return t>=0&&t<r?t:e}Mc(e,t,r){let i=this.e.o.M.center,o=Math.max(1,Math.floor(i.clientHeight/this.e.r.rowHeight)),s=e==="PageUp"?-1:1,a=Math.max(0,Math.min(r-1,t+o*s));return this.qi(t,this.Ht(a,s),r)}Ec(e,t,r,i){let o=this.e.i.f(t.row),s=r[t.colIdx];if(o&&!o.isDetail&&s&&this.e.l.U(o,s))return this.e.l.start(t.row,s,e.key==="F2"?e.key:null),t;let a=this.Ht(t.row+1,1);return{...t,row:this.qi(t.row,a,i)}}Rc(e){let t=this.e.i.f(e);if(!(!t||t.isDetail)){if(t.isGroup){this.e.i.To(t.id);return}this.e.r.rowSelection!=="none"&&this.e.m.Va(t,!t.selected,this.e.r.rowSelection==="single")}}Sc(e,t,r){let i=this.Xa(t.row,r[t.colIdx].id,e.shiftKey?-1:1);return i?(this.e.a.Oe(i.rowIndex,i.column.id),this.e.l.start(i.rowIndex,i.column),t):null}};var A=null;function en(n){A?.owner&&(n===A.owner||n.contains(A.owner))&&A.close()}function tn(n){let e=n.target;A?.contains(e)||A?.close()}function xt(){A?.reposition()}function rn(n){n.key!=="Escape"||!A||(n.preventDefault(),n.stopImmediatePropagation(),A.close(!0))}function Bs(n){A?.close!==n.close&&A?.close(),!A&&(A=n,document.addEventListener("mousedown",tn,!0),document.addEventListener("keydown",rn,!0),window.addEventListener("resize",xt),window.addEventListener("scroll",xt,!0))}function _s(n){A?.close===n&&(A=null,document.removeEventListener("mousedown",tn,!0),document.removeEventListener("keydown",rn,!0),window.removeEventListener("resize",xt),window.removeEventListener("scroll",xt,!0))}function se(n,e){return e?`${n} ${e}`:n}function Ge(n,e,t){let r=n[e]&&!n[e].disabled,i=r?e+t:t>0?0:n.length-1;for(let o=i;o>=0&&o<n.length;o+=t)if(!n[o].disabled)return o;return r?e:-1}function Dt(n,e){return n.findIndex(t=>t.value===e&&!t.disabled)}function ee(n){let e=f("div",se("mach-select-control",n.classNames?.root)),t=f("select",se("mach-select-native",n.classNames?.native));t.hidden=!0,t.tabIndex=-1,t.setAttribute("aria-hidden","true");let r=f("button",se("mach-select-trigger",n.classNames?.trigger));r.type="button",r.setAttribute("role","combobox"),r.setAttribute("aria-haspopup","listbox"),r.setAttribute("aria-expanded","false"),r.setAttribute("aria-label",n.ariaLabel);let i=f("span",se("mach-select-value",n.classNames?.value)),o=f("span",se("mach-select-caret",n.classNames?.caret));o.setAttribute("aria-hidden","true"),r.append(i,o);let s=f("div",se("mach-select-listbox",n.classNames?.listbox));s.id=li("mach-select-listbox"),s.setAttribute("role","listbox"),s.setAttribute("aria-hidden","true"),r.setAttribute("aria-controls",s.id),e.append(t,r);let a=[...n.options],l=[],d=-1,u=!1,c=()=>n.themeSource??e.closest(".mach-root")??e,h=y=>e.contains(y)||s.contains(y),p=()=>s.classList.contains("mach-select-listbox--open"),m=()=>{let y=a.find(T=>T.value===t.value);i.textContent=y?.label??t.value,l.forEach((T,ue)=>{let S=a[ue]?.value===t.value;T.setAttribute("aria-selected",S?"true":"false"),T.classList.toggle("mach-select-option--selected",S),T.classList.toggle("mach-select-option--active",ue===d)}),r.setAttribute("aria-activedescendant",d>=0?l[d]?.id??"":"")},g=()=>{let y=r.getBoundingClientRect(),T=s.getBoundingClientRect(),ue=Math.max(y.width,T.width),S=w(y.left,8,Math.max(8,window.innerWidth-ue-8)),Ce=window.innerHeight-y.bottom-8,te=Ce<Math.min(T.height,240)&&y.top>Ce,P=te?Math.max(8,y.top-T.height-5):Math.min(window.innerHeight-T.height-8,y.bottom+5);s.style.minWidth=`${y.width}px`,s.style.left=`${S}px`,s.style.top=`${Math.max(8,P)}px`,s.classList.toggle("mach-select-listbox--above",te)},v=(y=!1)=>p()?(s.classList.remove("mach-select-listbox--open","mach-select-listbox--above"),s.setAttribute("aria-hidden","true"),r.setAttribute("aria-expanded","false"),r.removeAttribute("aria-activedescendant"),s.remove(),_s(v),y&&!u&&r.focus({preventScroll:!0}),!0):!1,C=(y,T=!0)=>{!a[y]||a[y].disabled||(d=y,m(),T&&l[y]?.scrollIntoView?.({block:"nearest"}))},k=()=>{if(u||r.disabled||p())return;let y=c();Bs({owner:y,close:v,contains:h,reposition:g}),d=Dt(a,t.value),d<0&&(d=Ge(a,-1,1)),I(s,y),document.body.appendChild(s),s.classList.add("mach-select-listbox--open"),s.setAttribute("aria-hidden","false"),r.setAttribute("aria-expanded","true"),g(),m(),l[d]?.scrollIntoView?.({block:"nearest"})},B=y=>{let T=a[y];!T||T.disabled||(t.value=T.value,d=y,m(),v(!0),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})))},_=(y,T)=>{a=[...y],t.replaceChildren(),s.replaceChildren(),l=a.map((S,Ce)=>{let te=document.createElement("option");te.value=S.value,te.textContent=S.label,te.disabled=S.disabled===!0,t.appendChild(te);let P=f("button",se("mach-select-option",n.classNames?.option));return P.id=`${s.id}-option-${Ce}`,P.type="button",P.tabIndex=-1,P.dataset.value=S.value,P.disabled=S.disabled===!0,P.setAttribute("role","option"),P.textContent=S.label,P.addEventListener("mousedown",mo=>mo.preventDefault()),P.addEventListener("click",()=>B(Ce)),s.appendChild(P),P});let ue=a.find(S=>!S.disabled)?.value??"";t.value=T!=null&&a.some(S=>S.value===T)?T:ue,d=Dt(a,t.value),m()},ei=y=>{if(y.key==="Tab"){v();return}if(y.key==="Escape"){if(!v(!0))return;y.preventDefault(),y.stopPropagation();return}if(y.key==="Enter"||y.key===" "){y.preventDefault(),y.stopPropagation(),p()?B(d):k();return}let T=d;if(y.key==="ArrowDown")T=Ge(a,d,1);else if(y.key==="ArrowUp")T=Ge(a,d,-1);else if(y.key==="Home")T=Ge(a,-1,1);else if(y.key==="End")T=Ge(a,-1,-1);else return;y.preventDefault(),y.stopPropagation(),p()||k(),C(T)},ti=()=>{d=Dt(a,t.value),m(),n.onChange?.(t.value)};return r.addEventListener("click",()=>{v()||k()}),r.addEventListener("keydown",ei),t.addEventListener("change",ti),_(a,n.value),{el:e,native:t,trigger:r,listbox:s,contains:h,isOpen:p,open:k,close:v,focus:()=>r.focus({preventScroll:!0}),getValue:()=>t.value,setValue:y=>{t.value=y,d=Dt(a,y),m()},setOptions:_,destroy:()=>{u||(u=!0,v(),r.removeEventListener("keydown",ei),t.removeEventListener("change",ti),e.remove())}}}function nn(n,e){let t=document.createElement("input");return t.type=n,t.className="mach-editor-input",e!=null&&e!==""&&(t.value=n==="date"?String(e).slice(0,10):String(e)),t}function zs(n){return n?.options?.length?n.options:(n?.values??[]).map(e=>({label:String(e),value:e}))}function Ws(n,e){return e?.options?.length||e?.values?.length?"select":typeof n=="number"?"number":n instanceof Date||typeof n=="string"&&/^\d{4}-\d{2}-\d{2}/.test(n)?"date":"text"}function Lr(n,e,t){let r=n.colDef,i=typeof r.cellEditor=="string"?r.cellEditor:Ws(e,r.cellEditorParams);if(i==="date"){let a=nn("date",e),d=(e==null?"":String(e)).match(/T(\d{2}:\d{2})/);return{el:a,getValue:()=>a.value===""?null:d?`${a.value}T${d[1]}`:a.value,focus:()=>a.focus({preventScroll:!0})}}if(i==="select"){let a=zs(r.cellEditorParams),l=ee({ariaLabel:r.headerName??r.field??n.id,options:a.map(d=>({value:String(d.value),label:d.label,disabled:d.disabled})),value:String(e??""),classNames:{root:"mach-editor-select-control",native:"mach-editor-select"}});return{el:l.el,getValue:()=>{let d=l.getValue();return a.find(c=>String(c.value)===d)?.value??d},focus:()=>l.focus(),destroy:()=>l.destroy()}}let o=i==="number",s=nn(o?"number":"text",e);return!o&&t&&t.length===1&&(s.value=t),{el:s,getValue:()=>o?s.value===""?null:Number(s.value):s.value,focus:()=>{s.focus({preventScroll:!0}),s.select()}}}function ae(n){return n!=null&&typeof n.then=="function"}var Et=class{constructor(e){this.e=e;this.Go=0}Ic(){this.Go++}Po(){let e=++this.Go;return()=>e===this.Go&&!this.e.s()}Yi(e){let t=e[0].node,r=this.e.n.Z(),i=r.map(a=>this.e.d(t,a)),o=this.Jr(e),s=e.every(a=>Object.is(this.e.d(t,a.column),a.oldValue));return()=>s&&o()&&r.every((a,l)=>Object.is(this.e.d(t,a),i[l]))}Jr(e){let t=e[0].node,r=t.data,i=this.e.n.Z(),o=new Set(i),s=e.every(a=>a.node===t&&o.has(a.column));return()=>s&&!this.e.s()&&this.e.i.X(t.id)===t&&t.data===r&&this.e.n.Z()===i}Xi(e,t){let r=e.map(o=>this.Ac(o,t)),i=o=>{let s=o.filter(a=>a!=null);return s.length||!t()?s:this.kc(e,t)};return r.some(ae)?Promise.all(r.map(o=>Promise.resolve(o))).then(i):i(r)}Ac(e,t){let{node:r,column:i,oldValue:o,newValue:s}=e,a=d=>(t()&&this.e.reportError(d,"validate",{colId:i.id,rowId:r.id}),{colId:i.id,message:"Validation failed"}),l=d=>typeof d=="string"?{colId:i.id,message:d}:null;try{let d=i.colDef.validate?.(s,{oldValue:o,newValue:s,node:r,data:r.data,column:i,colDef:i.colDef,api:this.e.api});return ae(d)?d.then(l,a):l(d)}catch(d){return a(d)}}kc(e,t){let r=this.e.r.rowEditValidator;if(!r)return[];let i=e[0].node,o=Object.create(null);for(let l of this.e.n.Z())o[l.id]=this.e.d(i,l);for(let l of e)o[l.column.id]=l.newValue;let s=l=>typeof l=="string"?[{colId:e[0].column.id,message:l}]:l&&typeof l=="object"?Object.entries(l).filter(([,d])=>typeof d=="string"&&d).map(([d,u])=>({colId:d,message:u})):[],a=l=>(t()&&this.e.reportError(l,"validate",{rowId:i.id}),[{colId:e[0].column.id,message:"Row validation failed"}]);try{let l=r({data:i.data,node:i,values:o,api:this.e.api,changes:e.map(({column:d,oldValue:u,newValue:c})=>({colId:d.id,oldValue:u,newValue:c}))});return ae(l)?l.then(s,a):s(l)}catch(l){return a(l)}}No(e,t){let r=[],i=this.Jr(e);for(let o of e){if(!t()||!i()||!Object.is(this.e.d(o.node,o.column),o.oldValue)||!this.e.l.U(o.node,o.column)||!this.e.Ji(o.node,o.column,o.newValue,o.oldValue)){for(let s of r.reverse()){if(!t()||!i())break;this.e.Ji(s.node,s.column,s.oldValue,s.newValue)||this.e.reportError(new Error("A valueSetter rejected input rollback"),"inputRollback",{rowId:s.node.id})}return{colId:o.column.id,message:"Value was rejected by the column setter"}}r.push(o)}return t()&&i()?null:{colId:e[0].column.id,message:"Input target changed during commit"}}Lc(e){let t=this.Po();if(this.e.s()||this.e.l.isEditing())return;let r=new Map;for(let a of e){if(a.newValue===void 0||Object.is(a.oldValue,a.newValue)||!this.e.l.U(a.node,a.column))continue;let l=r.get(a.node)??[];l.push(a),r.set(a.node,l)}let i=[...r.values()].map(a=>{let l=this.Yi(a),d=()=>t()&&l();return{changes:a,current:d,validation:this.Xi(a,d)}}),o=a=>{this.Qa(i,a,t)},s=i.map(a=>a.validation);s.some(ae)?Promise.all(s.map(a=>Promise.resolve(a))).then(o):o(s)}Qa(e,t,r){let i=e.map(()=>({applied:!1,errors:[]}));if(!r())return i;let o=new Set;this.e.B.tl();try{e.forEach(({changes:s,current:a},l)=>{let d=i[l];if(!a()||!s.length)return;d.errors=[...t[l]];let u=d.errors.length?null:this.No(s,r);if(!r())return;if(u&&d.errors.push(u),d.errors.length){this.e.reportError(new Error(d.errors.map(h=>h.message).join("; ")),"validate",{rowId:s[0].node.id,errors:d.errors});return}let c=this.Jr(s);d.applied=!0;for(let h of s){if(!r()||!c()){d.applied=!1;break}this.e.Oo(h.node,h.column,h.oldValue,h.newValue),h.node.rowIndex>=0&&o.add(h.node.rowIndex)}})}finally{this.e.B.rl()}return o.size&&r()&&(this.e.a.at([...o]),this.e.ae.refresh(),this.e.qe.refresh()),i}};function le(n,e,t,r,i,o){let s=t.colDef.valueParser;if(!s)return r;let a=s({api:n.api,colDef:t.colDef,column:t,data:e.data,node:e,value:r,oldValue:o,source:i});if(a!=null&&typeof a.then=="function")throw new TypeError("valueParser must return a synchronous value");return a}function Pe(n,e,t,r){let i=n.d(e,t),o=t.colDef.valueSerializer;if(o)try{let s=o({api:n.api,colDef:t.colDef,column:t,data:e.data,node:e,value:i,target:r});if(s!=null&&typeof s.then=="function")throw new TypeError("valueSerializer must return a synchronous value");return s}catch(s){throw n.reportError(s,"valueSerializer",{colId:t.id,rowId:e.id}),s}return r==="xlsx"||r==="csv"&&typeof i=="number"?i:U(n,e,t,i)}var $s='<path d="M3 8.5 6.4 12 13.5 4"/>',Ks='<path d="m4 4 8 8m0-8-8 8"/>';function on(n,e){let t=document.createElement("button");return t.type="button",t.className=`mach-edit-control mach-edit-control--${n}`,t.setAttribute("aria-label",e),t.title=e,t.innerHTML=`<svg viewBox="0 0 16 16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">${n==="confirm"?$s:Ks}</svg>`,t.addEventListener("mousedown",r=>{r.preventDefault(),r.stopPropagation()}),t}var Rt=class{constructor(e){this.e=e;this.v=null;this.x=null;this.le=null;this.ut=0;this.Gc=e=>{if(this.v&&!(e.isComposing||e.keyCode===229)){if(e.key==="Enter")e.preventDefault(),e.stopPropagation(),this.de(!1);else if(e.key==="Escape")e.preventDefault(),e.stopPropagation(),this.de(!0);else if(e.key==="Tab"){e.preventDefault(),e.stopPropagation();let t=this.v,r=this.e.Ko.Xa(t.rowIndex,t.column.id,e.shiftKey?-1:1);this.de(!1).then(i=>{i&&r&&(this.e.a.cr(r.rowIndex,"nearest"),this.e.a.Oe(r.rowIndex,r.column.id),this.start(r.rowIndex,r.column))})}}}}isEditing(e,t){return this.v?e==null&&t==null?!0:this.v.rowIndex===e&&this.v.column.id===t:this.x?e==null&&t==null?!0:this.Zr(this.x)!==e?!1:t==null||this.x.drafts.has(t):!1}Zi(){return this.v!=null}fu(){return this.v?.node.rowIndex??(this.x?this.Zr(this.x):null)}il(e){return this.x?e==null||this.Zr(this.x)===e:!1}U(e,t){if(e.isDetail||e.isGroup||e.data==null)return!1;let r=t.colDef.editable;if(!r)return!1;if(typeof r=="function")try{return r({api:this.e.api,colDef:t.colDef,column:t,node:e,data:e.data,value:this.e.d(e,t),rowIndex:e.rowIndex})}catch(i){return this.e.reportError(i,"editable",{colId:t.id,rowId:e.id}),!1}return!0}start(e,t,r){if(this.e.r.editType==="fullRow")return this.startRow(e,t.id);if(this.x)return!1;if(this.v)return this.v.rowIndex===e&&this.v.column.id===t.id||this.de(!1).then(p=>{p&&!this.v&&!this.x&&this.start(e,t,r)}),!0;let i=this.e.i.f(e);if(!i||i.data==null||!this.U(i,t))return!1;let o=this.e.a.Qi(e,t.id);if(!o)return!1;this.e.Ce();let s=this.e.d(i,t),a=this.nl(i,t,e,s,r);if(!a)return!1;L(this.e,o);let l=f("div","mach-cell-editor-shell"),d=f("div","mach-cell-editor-controls"),u=on("confirm","Confirm edit"),c=on("cancel","Cancel edit");d.append(u,c),l.append(a.el,d),o.replaceChildren(l),o.classList.add("mach-cell--editing"),o.removeAttribute("title");let h=this.Gc;return a.el.addEventListener("keydown",h),u.addEventListener("click",p=>{p.stopPropagation(),this.de(!1)}),c.addEventListener("click",p=>{p.stopPropagation(),this.de(!0)}),this.v={node:i,column:t,editor:a,rowIndex:e,oldValue:s,cell:o,shell:l,keydown:h,confirmButton:u,cancelButton:c},this.Fo(a,t,i),this.e.emit("cellEditingStarted",{rowIndex:e,colId:t.id,rowNode:i}),!0}startRow(e,t){if(this.v||this.x)return!1;let r=this.e.i.f(e);if(!r||r.data==null||r.isDetail||r.isGroup)return!1;this.e.Ce();let i=new Map;for(let l of this.e.n.u()){if(!this.U(r,l))continue;let d=this.e.d(r,l);i.set(l.id,{column:l,oldValue:d,value:d,mounted:null})}if(i.size===0)return!1;let o={node:r,rowIndex:e,drafts:i,validating:!1};if(this.x=o,this.e.a.at([e]),i.size===0)return this.x=null,this.e.a.at([e]),!1;let s=i.values().next().value,a=(t?i.get(t):void 0)??s;return a?.mounted&&this.Fo(a.mounted.editor,a.column,r),this.e.emit("rowEditingStarted",{rowIndex:e,rowNode:r,data:r.data}),!0}ol(e,t,r,i){if(this.v)return this.v.node===t&&this.v.column.id===r.id;let o=this.x;if(!o||o.node!==t)return!1;let s=o.drafts.get(r.id);return s?s.mounted?.cell!==i&&(s.mounted&&this.sl(s),!this.Pc(e,o,s,i))?(o.drafts.delete(r.id),!1):!0:!1}Ho(e,t,r){let i=this.x;if(i&&this.Zr(i)===e){let o=i.drafts.get(t);o?.mounted?.cell===r&&this.sl(o);return}if(this.v?.cell===r){let o=this.v;this.de(!1),this.v===o&&this.de(!0)}}stop(e=!1){this.de(e)}de(e=!1){if(this.x)return this.Vo(e);let t=this.v;if(!t)return Promise.resolve(!1);if(e)return this.ut++,this.le=null,Promise.resolve(this.gr(t,!0,t.oldValue));if(this.le)return this.le;let r;try{r=t.editor.getValue()}catch(c){return this.e.reportError(c,"cellEditor.getValue",{colId:t.column.id,rowId:t.node.id}),Promise.resolve(this.gr(t,!0,t.oldValue))}try{Object.is(r,t.oldValue)||(r=le(this.e,t.node,t.column,r,"editor",t.oldValue))}catch(c){return this.e.reportError(c,"valueParser",{colId:t.column.id,rowId:t.node.id}),this.Qr(t.editor,c instanceof Error?c.message:String(c)),Promise.resolve(!1)}try{if(t.editor.isCancelAfterEnd?.(r))return Promise.resolve(this.gr(t,!0,t.oldValue))}catch(c){return this.e.reportError(c,"cellEditor.isCancelAfterEnd",{colId:t.column.id,rowId:t.node.id}),Promise.resolve(this.gr(t,!0,t.oldValue))}let i=[{node:t.node,column:t.column,oldValue:t.oldValue,newValue:r}],o=this.e.W.Yi(i),s=++this.ut,a=()=>s===this.ut&&this.v===t&&o(),l=c=>a()?c.length?(this.Bo(t,!1),this.Qr(t.editor,c[0].message),!1):this.gr(t,!1,r):(s===this.ut&&this.v===t&&this.gr(t,!0,t.oldValue),!1),d=this.e.W.Xi(i,a);if(!ae(d))return Promise.resolve(l(d));this.Bo(t,!0);let u=d.then(l).finally(()=>{this.le===u&&(this.le=null)});return this.le=u,u}Vo(e=!1){let t=this.x;if(!t)return Promise.resolve(!1);if(e)return this.ut++,this.le=null,Promise.resolve(this.en(t,!0));if(this.le)return this.le;for(let h of t.drafts.values())this._o(h);let r=[];for(let h of t.drafts.values())if(!Object.is(h.oldValue,h.value))try{let p=le(this.e,t.node,h.column,h.value,"editor",h.oldValue);p!==void 0&&!Object.is(h.oldValue,p)&&r.push({node:t.node,column:h.column,oldValue:h.oldValue,newValue:p})}catch(p){return this.e.reportError(p,"valueParser",{colId:h.column.id,rowId:t.node.id}),this.zo(t,[{draft:h,message:p instanceof Error?p.message:String(p)}]),Promise.resolve(!1)}if(r.length===0)return Promise.resolve(this.en(t,!1,r));let i=r.map(h=>t.drafts.get(h.column.id)),o=i.map(h=>h.value),s=this.e.W.Yi(r),a=++this.ut,l=()=>a===this.ut&&this.x===t&&s();for(let h of i)h.error=void 0;let d=h=>l()?h.length?(this.zo(t,h.map(({colId:p,message:m})=>({draft:t.drafts.get(p)??i[0],message:m}))),!1):i.some((p,m)=>!Object.is(p.value,o[m]))?(t.validating=!1,this.Wo(t,!1),!1):this.en(t,!1,r):(a===this.ut&&this.x===t&&this.en(t,!0),!1),u=this.e.W.Xi(r,l);if(!ae(u))return Promise.resolve(d(u));t.validating=!0,this.Wo(t,!0);let c=u.then(d).finally(()=>{this.le===c&&(this.le=null)});return this.le=c,c}gr(e,t,r){if(this.v!==e)return!1;let i={node:e.node,column:e.column,oldValue:e.oldValue,newValue:r},o=!t&&r!==void 0&&!Object.is(e.oldValue,r);if(o){let s=this.e.W.No([i],()=>!this.e.s());if(s)return this.Bo(e,!1),this.Qr(e.editor,s.message),!1}return this.v=null,o&&this.e.Oo(e.node,e.column,e.oldValue,r),this.$o(e,!0),this.e.s()||(this.e.emit("cellEditingStopped",{rowIndex:e.rowIndex,colId:e.column.id,rowNode:e.node,oldValue:e.oldValue,newValue:o?r:e.oldValue}),e.node.rowIndex>=0&&this.e.a.at([e.node.rowIndex]),this.e.ae.refresh(),this.e.qe.refresh()),!0}en(e,t,r=[]){if(this.x!==e)return!1;let i=t?[]:this.Nc(e,r);if(i==null)return!1;for(let s of e.drafts.values())s.mounted&&this.$o(s.mounted,!0),s.mounted=null;if(this.x=null,this.e.s())return!0;let o=this.Zr(e);return this.e.emit("rowEditingStopped",{rowIndex:o,rowNode:e.node,data:e.node.data,cancelled:t,changes:i}),o>=0&&this.e.a.at([o]),this.e.ae.refresh(),this.e.qe.refresh(),!0}Nc(e,t){if(t.length===0)return[];let r=this.e.W.No(t,()=>!this.e.s());if(r)return this.zo(e,[{draft:e.drafts.get(r.colId)??e.drafts.get(t[0].column.id),message:r.message}]),null;let i=this.e.W.Jr(t);this.e.B.tl();try{for(let o of t){if(!i())break;this.e.Oo(e.node,o.column,o.oldValue,o.newValue)}}finally{this.e.B.rl()}return t.map(({column:o,oldValue:s,newValue:a})=>({colId:o.id,oldValue:s,newValue:a}))}Pc(e,t,r,i){let o=this.nl(t.node,r.column,e,r.value,null);if(!o)return!1;L(this.e,i);let s=f("div","mach-row-editor-shell");s.appendChild(o.el),i.replaceChildren(s),i.classList.add("mach-cell--editing","mach-cell--row-editing"),i.removeAttribute("title");let a=d=>this.Oc(d,t,r),l=()=>{try{r.value=o.getValue(),r.error=void 0}catch{}};return o.el.addEventListener("keydown",a),o.el.addEventListener("input",l),r.mounted={editor:o,cell:i,shell:s,keydown:a,input:l},r.error&&this.Qr(o,r.error),t.validating&&(o.el.classList.add("mach-editor-validating"),o.el.setAttribute("aria-busy","true"),o.el.inert=!0),!0}sl(e){e.mounted&&(this._o(e),this.$o(e.mounted,!0),e.mounted=null)}_o(e){if(e.mounted)try{let t=e.mounted.editor.getValue();t!==void 0&&(e.value=t)}catch(t){this.e.reportError(t,"cellEditor.getValue",{colId:e.column.id,rowId:this.x?.node.id})}}nl(e,t,r,i,o){let s=t.colDef,a;try{let l={api:this.e.api,colDef:s,column:t,node:e,data:e.data,value:i,rowIndex:r,keyPress:o};typeof s.cellEditor=="function"?a=s.cellEditor(l):typeof s.cellEditor=="string"&&!["text","number","date","select"].includes(s.cellEditor)?a=this.e.Fc(s.cellEditor)?.(l)??Lr(t,i,o):a=Lr(t,i,o)}catch(l){return this.e.reportError(l,"cellEditor",{colId:t.id,rowId:e.id}),null}if(!a||!(a.el instanceof HTMLElement))return this.e.reportError(new Error("cellEditor must return an editor with an HTMLElement el"),"cellEditor",{colId:t.id,rowId:e.id}),null;try{if(a.isCancelBeforeStart?.())return a.destroy?.(),null}catch(l){this.e.reportError(l,"cellEditor.isCancelBeforeStart",{colId:t.id,rowId:e.id});try{a.destroy?.()}catch{}return null}return a}zo(e,t){e.validating=!1,this.Wo(e,!1);for(let{draft:r,message:i}of t)r.error=i,r.mounted&&this.Qr(r.mounted.editor,i);t[0].draft.mounted?.editor.focus?.()}Qr(e,t){let r=e.el;r.classList.add("mach-editor-invalid"),r.setAttribute("title",t),r.setAttribute("aria-invalid","true"),r.classList.remove("mach-editor-validating"),r.removeAttribute("aria-busy"),r.inert=!1,(r.querySelector(".mach-select-trigger, input:not([type='hidden']), select:not([hidden]), textarea")??r).focus?.();let o=()=>{r.classList.remove("mach-editor-invalid"),r.removeAttribute("title"),r.removeAttribute("aria-invalid")};r.addEventListener("input",o,{once:!0})}Bo(e,t){e.editor.el.classList.toggle("mach-editor-validating",t),t?e.editor.el.setAttribute("aria-busy","true"):e.editor.el.removeAttribute("aria-busy"),e.editor.el.inert=t,e.confirmButton.disabled=t,e.cancelButton.disabled=!1,e.shell.classList.toggle("mach-editor-shell--busy",t)}Wo(e,t){for(let r of e.drafts.values()){let i=r.mounted?.editor.el;i&&(i.classList.toggle("mach-editor-validating",t),t?i.setAttribute("aria-busy","true"):i.removeAttribute("aria-busy"),i.inert=t)}}Fo(e,t,r){try{e.focus?.()}catch(i){this.e.reportError(i,"cellEditor.focus",{colId:t.id,rowId:r.id})}}$o(e,t){e.editor.el.removeEventListener("keydown",e.keydown),e.input&&e.editor.el.removeEventListener("input",e.input),e.editor.el.classList.remove("mach-editor-validating"),e.editor.el.removeAttribute("aria-busy"),e.editor.el.inert=!1;try{e.editor.destroy?.()}catch(r){this.e.reportError(r,"cellEditor.destroy",{colId:e.cell.dataset.colId})}t&&e.cell.classList.remove("mach-cell--editing","mach-cell--row-editing","mach-cell--error")}Zr(e){return e.node.rowIndex>=0?e.node.rowIndex:e.rowIndex}Oc(e,t,r){if(this.x!==t)return;if(e.key==="Escape"){e.preventDefault(),e.stopPropagation(),this.Vo(!0);return}if(e.key==="Enter"&&!e.shiftKey){e.preventDefault(),e.stopPropagation(),this.Vo(!1);return}if(e.key!=="Tab")return;e.preventDefault(),e.stopPropagation(),this._o(r);let i=[...t.drafts.values()],o=i.indexOf(r),s=e.shiftKey?-1:1;for(let a=1;a<=i.length;a++){let l=i[(o+s*a+i.length)%i.length];if(l.mounted){this.Fo(l.mounted.editor,l.column,t.node);break}}}destroy(){(this.v||this.x)&&this.de(!0)}};function Gr(n){return n==="blank"||n==="notBlank"}function Ne(n){return n===null?"null:":`${typeof n}:${String(n)}`}var St=class{constructor(e){this.e=e;this.y=null;this.ct=null;this.yr=null;this.ht=e=>{if(!this.y)return;let t=e.target;if(!this.y.contains(t)&&!this.yr?.contains(t)){this.close();return}this.yr?.contains(t)||(!(t instanceof Element)||!t.closest(".mach-filter-select-control"))&&this.al()};this.pt=e=>{if(e.key==="Escape"){if(this.al(!0)){e.preventDefault(),e.stopPropagation();return}this.close()}}}toggle(e,t){if(this.ct===e.id){this.close();return}this.close(),this.open(e,t)}open(e,t){let r=this.e.i.De()[e.id]??null,i=r?.type??e.filterType,o=f("div","mach-filter-panel");o.setAttribute("role","dialog"),o.setAttribute("aria-label",`${e.id} filter`);let s=u=>{this.e.Hc(e,u),this.close()},a=i==="set"?this.Vc(o,e,r):this.Bc(o,i,r,s),l=f("div","mach-filter-footer");l.append(j("mach-filter-btn-reset",this.e.T("reset"),()=>s(null)),j("mach-filter-btn-apply",this.e.T("apply"),()=>s(a()))),o.appendChild(l),I(o,this.e.o.root),document.body.appendChild(o),this.y=o,this.ct=e.id,q(o,t),document.addEventListener("mousedown",this.ht,!0),document.addEventListener("keydown",this.pt,!0),o.querySelector(".mach-filter-select-trigger, input")?.focus()}close(){this.y&&(this.yr?.destroy(),this.yr=null,this.y.remove(),this.y=null,this.ct=null,document.removeEventListener("mousedown",this.ht,!0),document.removeEventListener("keydown",this.pt,!0))}destroy(){this.close()}Bc(e,t,r,i){let o=r&&r.type!=="set"&&r.conditions.length>0?r.conditions[0]:null,s=o?.match??(t==="text"?"contains":"equals"),{el:a,native:l}=this._c(t,s),d=this.ll(t),u=this.ll(t,!0);this.zc(t,s,o,d,u),this.dl(s,d,u),l.addEventListener("change",()=>{this.dl(l.value,d,u)});let c=f("div","mach-filter-body");c.append(a,d,u),e.appendChild(c);let h=()=>this.Wc(t,l.value,d.value,u.value),p=m=>{m.key==="Enter"&&i(h())};return d.addEventListener("keydown",p),u.addEventListener("keydown",p),h}_c(e,t){let r=ee({ariaLabel:"Filter condition",options:he[e].map(i=>({value:i,label:this.e.T(Ze(i))})),value:t,classNames:{root:"mach-filter-select-control",native:"mach-filter-select",trigger:"mach-filter-select-trigger",value:"mach-filter-select-value",caret:"mach-filter-select-caret",listbox:"mach-filter-listbox",option:"mach-filter-listbox-option"},themeSource:this.e.o.root});return this.yr=r,r}al(e=!1){return this.yr?.close(e)??!1}ll(e,t=!1){let i=f("input",`mach-filter-input${t?" mach-filter-input--second":""}`);return e==="number"&&(i.type="number"),e==="date"&&(i.type="date"),i}zc(e,t,r,i,o){r?.value!=null&&!Gr(t)&&(i.value=e==="date"?String(r.value).slice(0,10):String(r.value)),r&&"value2"in r&&r.value2!=null&&(o.value=e==="date"?String(r.value2).slice(0,10):String(r.value2))}dl(e,t,r){t.style.display=Gr(e)?"none":"",r.style.display=e==="inRange"?"":"none"}Vc(e,t,r){let o=t.colDef.filterParams,s;if(o?.values)s=o.values;else{let p=new Set;s=[];let m=this.e.i.ge(),g=Math.min(m.length,o?.maxValues??500);for(let v=0;v<g;v++){let C=this.e.d(m[v],t),k=Ne(C??null);p.has(k)||(p.add(k),s.push(C))}}let a=new Set(r?.type==="set"?r.values.map(Ne):s.map(Ne)),l=f("input","mach-filter-input mach-filter-input--search");l.type="text",l.placeholder=this.e.T("search");let d=f("div","mach-filter-set-list"),u=new Map(s.map(p=>[Ne(p),p??null])),c=p=>{d.textContent="";let m=p.trim().toLowerCase();for(let g of s){let v=g==null?this.e.T("emptySetLabel"):String(g);if(m&&!v.toLowerCase().includes(m))continue;let C=Ne(g),k=f("label","mach-filter-set-item"),B=document.createElement("input");B.type="checkbox",B.checked=a.has(C),B.addEventListener("change",()=>{B.checked?a.add(C):a.delete(C)});let _=f("span");_.textContent=v,k.append(B,_),d.appendChild(k)}};l.addEventListener("input",()=>c(l.value)),c("");let h=f("div","mach-filter-body mach-filter-body--set");return h.append(l,d),e.appendChild(h),()=>{let p=[];for(let[m,g]of u)a.has(m)&&p.push(g);return p.length&&p.length<u.size?{type:"set",values:p}:null}}Wc(e,t,r,i){return Gr(t)?{type:e,conditions:[{match:t}]}:r===""&&t!=="inRange"?null:e==="number"?this.$c(t,r,i):e==="date"?{type:e,conditions:[t==="inRange"?{match:t,value:r,value2:i||r}:{match:t,value:r}]}:{type:"text",conditions:[{match:t,value:r}]}}$c(e,t,r){let i=Number(t);if(Number.isNaN(i))return null;if(e!=="inRange")return{type:"number",conditions:[{match:e,value:i}]};let o=r?Number(r):i;return Number.isNaN(o)?null:{type:"number",conditions:[{match:"inRange",value:i,value2:o}]}}};var Mt=class{constructor(e){this.e=e;this.y=null;this.ct=null;this.tn=null;this.rn="";this.ei=new Set;this.ht=e=>{let t=e.target;this.y&&!this.y.contains(t)&&!this.Uc(t)&&this.close()};this.pt=e=>{if(e.key==="Escape"){for(let t of this.ei)if(t.close(!0)){e.preventDefault(),e.stopImmediatePropagation();return}this.close()}}}toggle(e,t){let r=this.ct===e.id;this.close(),r||this.open(e,t)}Kc(e){this.close();let t=e??(()=>{let i=this.e.o.root.getBoundingClientRect(),o=document.createElement("div");return o.style.position="fixed",o.style.left=`${i.right-16}px`,o.style.top=`${i.top+this.e.r.headerHeight}px`,o.style.width="1px",o.style.height="1px",document.body.appendChild(o),this.tn=o,o})();this.open(null,t)}close(){this.ul(),this.tn&&(this.tn.remove(),this.tn=null),this.y?.remove(),this.y=null,this.ct=null,document.removeEventListener("mousedown",this.ht,!0),document.removeEventListener("keydown",this.pt,!0)}destroy(){this.close()}open(e,t){let r=this.e.api,i=f("div","mach-filter-panel mach-column-panel");i.setAttribute("role",e?"menu":"dialog"),e||(i.setAttribute("aria-modal","false"),i.setAttribute("aria-label",this.e.T("columnSettings")));let o=f("div","mach-column-panel-title");o.textContent=e?e.colDef.headerName??e.colDef.field??e.id:this.e.T("columnSettings"),i.appendChild(o);let s=(c,h,p="mach-column-panel-btn")=>j(p,this.e.T(c),()=>{h(),this.close()});if(e){let c=e.id,h=(...p)=>{let m=f("div","mach-column-panel-actions");m.append(...p),i.appendChild(m)};e.sortable&&h(s("sortAsc",()=>r.sorting.setModel([{colId:c,direction:"asc"}])),s("sortDesc",()=>r.sorting.setModel([{colId:c,direction:"desc"}])),s("clearSort",()=>r.sorting.setModel([]))),h(s("pinLeft",()=>r.columns.setPinned(c,"left")),s("pinRight",()=>r.columns.setPinned(c,"right")),s("clearPin",()=>r.columns.setPinned(c,null))),h(s("autoSize",()=>r.columns.autoSize(c)),s("hideColumn",()=>r.columns.setVisible(c,!1)))}let a=f("div","mach-column-panel-divider");i.appendChild(a);let l=f("div","mach-column-panel-subtitle");if(l.textContent=this.e.T("columnVisibility"),i.appendChild(l),!e){let c=document.createElement("input");c.type="search",c.className="mach-column-workbench-search",c.placeholder=this.e.T("search"),c.setAttribute("aria-label",this.e.T("search")),c.value=this.rn,c.addEventListener("input",()=>{this.rn=c.value.trim().toLocaleLowerCase(),this.Uo(d,!0)}),i.appendChild(c)}let d=f("div","mach-column-panel-list");this.Uo(d,!e),i.appendChild(d);let u=f("div","mach-filter-footer");u.append(s("resetAll",()=>r.columns.resetState(),"mach-filter-btn-reset"),s("autoSizeAll",()=>r.columns.autoSizeAll(),"mach-filter-btn-apply")),i.appendChild(u),I(i,this.e.o.root),document.body.appendChild(i),this.y=i,this.ct=e?e.id:"__standalone__",q(i,t),document.addEventListener("mousedown",this.ht,!0),document.addEventListener("keydown",this.pt,!0)}jo(){if(!this.y)return;let e=this.y.querySelector(".mach-column-panel-list");e&&this.Uo(e,this.ct==="__standalone__")}Uo(e,t){let r=this.e.api;this.ul(e),e.replaceChildren();let i=this.e.n.Z().filter(o=>o.isDetailToggle?!1:!t||!this.rn?!0:`${o.colDef.headerName??o.colDef.field??o.id} ${o.id}`.toLocaleLowerCase().includes(this.rn));for(let o of i){let s=f("div",t?"mach-column-workbench-item":"mach-filter-set-item"),a=f("label","mach-column-workbench-label"),l=document.createElement("input");l.type="checkbox",l.checked=!o.hide,l.disabled=o.hasCheckbox,l.addEventListener("change",()=>{r.columns.setVisible(o.id,l.checked),this.jo()});let d=f("span","mach-column-workbench-name");if(d.textContent=o.colDef.headerName??o.colDef.field??o.id,d.title=`${d.textContent} (${o.id})`,a.append(l,d),s.appendChild(a),t){let u=ee({ariaLabel:`${d.textContent} ${this.e.T("clearPin")}`,options:[{value:"",label:this.e.T("clearPin")},{value:"left",label:this.e.T("pinLeft")},{value:"right",label:this.e.T("pinRight")}],value:o.pinned??"",classNames:{root:"mach-column-workbench-pin-control",native:"mach-column-workbench-pin"},themeSource:this.e.o.root,onChange:m=>{r.columns.setPinned(o.id,m==="left"||m==="right"?m:null),this.jo()}});u.trigger.disabled=!o.movable,u.native.disabled=!o.movable,this.ei.add(u),s.appendChild(u.el);let c=this.e.n.Z().filter(m=>!m.hide&&m.parentGroup===o.parentGroup&&(o.parentGroup!=null||m.pinned===o.pinned)),h=c.indexOf(o),p=(m,g,v)=>{let C=j("mach-column-workbench-move",m,()=>{r.columns.move(o.id,g),this.jo()});return C.disabled=v||o.hide||!o.movable,C};s.append(p("\u2191",h-1,h<=0),p("\u2193",h+1,h<0||h>=c.length-1))}e.appendChild(s)}}Uc(e){for(let t of this.ei)if(t.contains(e))return!0;return!1}ul(e){for(let t of this.ei)e&&!e.contains(t.el)||(t.destroy(),this.ei.delete(t))}};var It=class{constructor(e){this.e=e;this.y=null;this.ht=e=>{this.y&&!this.y.contains(e.target)&&this.close()};this.pt=e=>{e.key==="Escape"&&this.close()}}jc(e){if(e){let o=this.e.i.f(e.rowIndex),s=this.e.n.k(e.colId);return o&&s?{node:o,column:s}:null}let t=this.e.a.Xr();if(!t)return null;let r=this.e.i.f(t.r1),i=this.e.n.u()[t.c1];return r&&i?{node:r,column:i}:null}qc(e,t){let r=this.e.r.getContextMenuItems;if(!r)return null;try{return r({data:e.data,node:e,api:this.e.api,colId:t.id,value:this.e.d(e,t),rowIndex:e.rowIndex})??null}catch(i){return this.e.reportError(i,"getContextMenuItems",{colId:t.id,rowId:e.id}),null}}Yc(e,t,r,i){let o=!1;for(let s of t){if(s.separator){e.appendChild(f("div","mach-context-menu-separator"));continue}let a=f("button","mach-context-menu-item");a.type="button",a.textContent=s.label??"",s.danger&&a.classList.add("mach-context-menu-item--danger"),a.disabled=s.disabled===!0,a.disabled||(o=!0,a.addEventListener("click",()=>this.Xc(s,r,i))),e.appendChild(a)}return o}Xc(e,t,r){this.close();try{e.action?.()}catch(i){this.e.reportError(i,"contextMenu.action",{colId:r.id,rowId:t.id})}}Jc(e){let t=this.e,r=(i,o)=>{e.append(j("mach-context-menu-item",t.T(i),()=>{o(),this.close()}))};r("menuCopy",()=>{t.cl()}),!t.r.suppressClipboard&&(r("menuPaste",()=>{t.Zc()}),r("menuClearContents",()=>{let i=t.a.Xr();i&&t.ko(i)}))}open(e,t,r){this.close();let i=this.jc(r);if(!i)return;let o=f("div","mach-context-menu");if(o.setAttribute("role","menu"),this.e.r.getContextMenuItems){let s=this.qc(i.node,i.column);if(!s||!this.Yc(o,s,i.node,i.column))return;this.hl(o,e,t);return}this.Jc(o),this.hl(o,e,t)}hl(e,t,r){I(e,this.e.o.root),document.body.appendChild(e),this.y=e;let i=e.getBoundingClientRect(),o=w(t,8,Math.max(8,window.innerWidth-i.width-8)),s=w(r,8,Math.max(8,window.innerHeight-i.height-8));e.style.left=`${o}px`,e.style.top=`${s}px`,document.addEventListener("mousedown",this.ht,!0),document.addEventListener("keydown",this.pt,!0)}close(){this.y&&(this.y.remove(),this.y=null,document.removeEventListener("mousedown",this.ht,!0),document.removeEventListener("keydown",this.pt,!0))}destroy(){this.close()}};var At=class{constructor(e){this.e=e;this.y=null;this.nn=0;this.qo=0;this.ti=null;this.sn=e=>{if(this.e.s()||!this.e.r.tooltipComponent)return;let r=e.target.closest(".mach-cell");if(!r||r===this.ti)return;this.Yo(),this.an(),this.ti=r;let i=this.Qc(r);if(!i||r.classList.contains("mach-cell--editing"))return;let o=this.eh(i.node,i.column,i.index);this.th(o,i.column)&&(this.nn=window.setTimeout(()=>{this.e.s()||this.ti!==r||this.rh(r,o)},Math.max(0,this.e.r.tooltipShowDelay)))};this.pl=()=>{this.hide()}}init(){let e=this.e.o.Fe;e.addEventListener("mouseover",this.sn),e.addEventListener("mouseleave",this.pl)}destroy(){this.Yo(),this.an();let e=this.e.o.Fe;e.removeEventListener("mouseover",this.sn),e.removeEventListener("mouseleave",this.pl),this.ti=null}hide(){this.Yo(),this.an(),this.ti=null}Yo(){this.nn&&(clearTimeout(this.nn),this.nn=0),this.qo&&(clearTimeout(this.qo),this.qo=0)}an(){this.y&&(this.y.remove(),this.y=null)}Qc(e){let t=e.dataset.colId??"",r=Number(e.closest(".mach-row")?.dataset.index);if(Number.isNaN(r))return null;let i=this.e.i.f(r),o=t?this.e.n.k(t):void 0;return!i||!o||i.isDetail||i.isGroup?null:{node:i,column:o,index:r}}eh(e,t,r){return{data:e.data,node:e,api:this.e.api,colId:t.id,value:this.e.d(e,t),formatted:re(this.e,e,t),rowIndex:r}}th(e,t){let r=t.colDef.tooltipValueGetter;if(!r)return!!e.formatted;try{r({...e,colDef:t.colDef,column:t})}catch(i){this.e.reportError(i,"tooltipValueGetter",{colId:t.id,rowId:e.node.id})}return!0}rh(e,t){this.an();let r=this.e.r.tooltipComponent;if(!r)return;let i=f("div","mach-tooltip");i.setAttribute("role","tooltip");let o;try{o=r(t)}catch(s){this.e.reportError(s,"tooltipComponent",{colId:t.colId,rowIndex:t.rowIndex});return}typeof o=="string"?i.textContent=o:i.appendChild(o),I(i,this.e.o.root),document.body.appendChild(i),this.y=i,q(i,e,6)}};var kt=class{constructor(e){this.e=e;this.J=null}init(){this.J=document.createElement("div"),this.J.className="mach-watermark",this.J.setAttribute("aria-hidden","true"),this.J.style.pointerEvents="none",this.e.o.root.appendChild(this.J),this.apply()}apply(){if(!this.J||this.e.s())return;let e=this.e.r.watermarkEnabled?this.e.r.watermarkConfig:null;if(!e||!e.text){this.J.style.display="none",this.J.style.backgroundImage="";return}let t=this.ih(e);this.J.style.display="",t?(this.J.style.backgroundImage=`url(${t})`,this.J.style.backgroundColor=""):this.J.style.backgroundImage=""}ih(e){try{let t=document.createElement("canvas"),r=t.getContext("2d");if(!r)return null;let i=e.fontSize??14,o=e.gap??160,s=e.angle??-22,a=e.color??(this.nh()?"rgba(255,255,255,0.9)":"rgba(31,55,88,0.9)"),l=e.opacity??.06;r.font=`500 ${i}px sans-serif`;let d=r.measureText(e.text),u=Math.ceil(d.width),c=Math.max(o,u+40);t.width=c,t.height=c;let h=t.getContext("2d");return h.clearRect(0,0,c,c),h.globalAlpha=l,h.fillStyle=a,h.font=`500 ${i}px sans-serif`,h.translate(c/2,c/2),h.rotate(s*Math.PI/180),h.textAlign="center",h.textBaseline="middle",h.fillText(e.text,0,0),t.toDataURL("image/png")}catch{return null}}nh(){return this.e.o.root.classList.contains("mach-theme-dark")}refresh(){this.apply()}destroy(){this.J?.remove(),this.J=null}};var Lt=class{constructor(e){this.e=e;this.Re=[];this.ue=-1;this.ft=null}tl(){this.ft||(this.ft=[])}rl(){if(!this.ft)return;let e=this.ft;this.ft=null,e.length>0&&this.push(e)}Xo(e){if(this.ft){this.ft.push(e);return}this.push([e])}push(e){let t=Math.max(0,this.e.r.undoStackSize);if(t!==0){for(this.Re.length=this.ue+1,this.Re.push(e);this.Re.length>t;)this.Re.shift();this.ue=this.Re.length-1}}oh(){let e=Math.max(0,this.e.r.undoStackSize);if(e===0){this.clear();return}for(;this.Re.length>e;)this.Re.shift(),this.ue--;this.ue<-1&&(this.ue=-1)}canUndo(){return this.ue>=0}canRedo(){return this.ue<this.Re.length-1}undo(){return this.e.Ce(),this.canUndo()?(this.apply(this.Re[this.ue],!1),this.ue--,!0):!1}redo(){return this.e.Ce(),this.canRedo()?(this.ue++,this.apply(this.Re[this.ue],!0),!0):!1}apply(e,t){let r=this.e,i=[];for(let o of e){let s=r.i.X(o.nodeId),a=r.n.k(o.columnId);if(!s||!a||s.data==null)continue;let l=t?o.newValue:o.oldValue,d=t?o.oldValue:o.newValue;r.Ji(s,a,l,d)&&(r.a.Wi(s),r.a.fl([s.rowIndex],[a.id]),s.rowIndex>=0&&i.push(s.rowIndex),r.emit("cellValueChanged",{oldValue:d,newValue:l,rowNode:s,rowIndex:s.rowIndex,column:a,colDef:a.colDef,data:s.data}))}i.length>0&&r.a.at(i),r.ae.refresh(),r.qe.refresh()}clear(){this.Re=[],this.ue=-1,this.ft=null}};var Gt=class{constructor(e){this.e=e;this.F=new Map;this.Jo=!1;this.Zo=null}init(){this.Zo=this.e.ce.on("cellValueChanged",e=>{this.Jo||this.Xo(e)})}Xo(e){let t=`${e.rowNode.id}\0${e.column.id}`,i=this.F.get(t)?.originalValue??e.oldValue;Object.is(e.newValue,i)?this.F.delete(t):this.F.set(t,{rowId:e.rowNode.id,colId:e.column.id,originalValue:i,value:e.newValue}),this.vr()}getDirtyRowIds(){return[...new Set([...this.F.values()].map(e=>e.rowId))]}getChanges(){let e=new Map;for(let t of this.F.values()){let r=this.e.i.X(t.rowId);if(!r?.data)continue;let i=e.get(t.rowId);i||(i={rowId:t.rowId,data:r.data,cells:[]},e.set(t.rowId,i)),i.cells.push({colId:t.colId,originalValue:t.originalValue,value:t.value})}return[...e.values()]}markSaved(e){if(!e)this.F.clear();else{let t=new Set(e);for(let[r,i]of this.F)t.has(i.rowId)&&this.F.delete(r)}this.vr()}sh(e){for(let t of e)for(let r of t.cells){let i=`${t.rowId}\0${r.colId}`,o=this.F.get(i);if(o){Object.is(o.value,r.value)?this.F.delete(i):o.originalValue=r.value;continue}let s=this.e.i.X(t.rowId),a=this.e.n.k(r.colId);if(!s||!a||s.data==null)continue;let l=this.e.d(s,a);Object.is(l,r.value)||this.F.set(i,{rowId:t.rowId,colId:r.colId,originalValue:r.value,value:l})}this.vr()}rollback(e){let t=e?new Set(e):null,r=[...this.F.entries()].filter(([,s])=>!t||t.has(s.rowId));if(r.length===0)return!1;let i=new Set,o=new Set;this.Jo=!0;try{for(let[s,a]of r){let l=this.e.i.X(a.rowId),d=this.e.n.k(a.colId);if(!l||!d||l.data==null)continue;let u=this.e.d(l,d);if(Object.is(u,a.originalValue)){o.add(s);continue}this.e.Ji(l,d,a.originalValue,u)&&(o.add(s),this.e.a.Wi(l),l.rowIndex>=0&&i.add(l.rowIndex),this.e.emit("cellValueChanged",{oldValue:u,newValue:a.originalValue,rowNode:l,rowIndex:l.rowIndex,column:d,colDef:d.colDef,data:l.data}))}}finally{this.Jo=!1}for(let s of o)this.F.delete(s);return i.size>0&&this.e.a.at([...i]),this.e.ae.refresh(),this.e.qe.refresh(),this.vr(),o.size>0}bu(e){if(e.length===0)return;let t=new Set(e);for(let[r,i]of this.F)t.has(i.rowId)&&this.F.delete(r);this.vr()}clear(){this.F.size!==0&&(this.F.clear(),this.vr())}destroy(){this.Zo?.(),this.Zo=null,this.F.clear()}vr(){this.e.emit("dirtyStateChanged",{dirtyRowIds:this.getDirtyRowIds()})}};var Nr=class{constructor(){this.ri=null;this.ln=0;this.ml=0;this.gl=0}acquire(){this.ln++,this.ah();let e=!1;return()=>{e||(e=!0,this.ln=Math.max(0,this.ln-1),this.ln===0&&this.disconnect())}}snapshot(){return{count:this.ml,totalMs:this.gl}}ah(){if(!(this.ri||typeof PerformanceObserver>"u"))try{this.ri=new PerformanceObserver(e=>{for(let t of e.getEntries())this.ml++,this.gl+=t.duration}),this.ri.observe({entryTypes:["longtask"]})}catch{this.disconnect()}}disconnect(){let e=this.ri;this.ri=null;try{e?.disconnect()}catch{}}},Pt=new Nr;function Pr(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}var Nt=class{constructor(){this.Vt=[];this.dn=[];this.un=[];this.Qo=Pt.acquire(),this.cn=Pt.snapshot()}start(){return Pr()}lh(e,t,r){this.Vt.push({duration:Math.max(0,Pr()-e),rows:t,columns:r}),this.Vt.length>120&&this.Vt.shift()}dh(e){this.yl(this.dn,e)}wo(e){this.yl(this.un,e)}snapshot(){let e=this.Vt.map(o=>o.duration),t=this.Vt[this.Vt.length-1],r=[...e].sort((o,s)=>o-s),i=Pt.snapshot();return{sampleCount:e.length,lastRenderMs:t?.duration??0,averageRenderMs:this.uh(e),maxRenderMs:r[r.length-1]??0,p95RenderMs:this.es(r,!0),longRenderCount:e.filter(o=>o>16.7).length,renderedRows:t?.rows??0,renderedColumns:t?.columns??0,renderedCells:(t?.rows??0)*(t?.columns??0),layoutSampleCount:this.dn.length,p95LayoutMs:this.es(this.dn),modelSampleCount:this.un.length,p95ModelMs:this.es(this.un),longTaskCount:Math.max(0,i.count-this.cn.count),longTaskTotalMs:Math.max(0,i.totalMs-this.cn.totalMs),usedHeapBytes:this.usedHeapBytes()}}reset(){this.Vt=[],this.dn=[],this.un=[],this.cn=Pt.snapshot()}destroy(){this.Qo?.(),this.Qo=null}yl(e,t){e.push(Math.max(0,Pr()-t)),e.length>120&&e.shift()}uh(e){return e.length===0?0:e.reduce((t,r)=>t+r,0)/e.length}usedHeapBytes(){let e=typeof performance>"u"?void 0:performance.memory?.usedJSHeapSize;return typeof e=="number"&&Number.isFinite(e)?e:null}es(e,t=!1){if(e.length===0)return 0;let r=t?e:[...e].sort((i,o)=>i-o);return r[Math.max(0,Math.ceil(r.length*.95)-1)]??0}};function sn(n,e){if(!(n==null||e==null))return[...new Set([...n,...e])]}function Us(n,e){return n===!0||e===!0?!0:n?e?{rowIds:sn(n.rowIds,e.rowIds),rowIndexes:n.rowIndexes==null||e.rowIndexes==null?void 0:[...new Set([...n.rowIndexes,...e.rowIndexes])],columns:sn(n.columns,e.columns),force:n.force===!0||e.force===!0,includePinned:n.includePinned===!0||e.includePinned===!0}:n:e}function js(n,e){return{columns:n.columns===!0||e.columns===!0,header:n.header===!0||e.header===!0,pool:n.pool===!0||e.pool===!0,data:n.data===!0||e.data===!0,layout:n.layout===!0||e.layout===!0,cells:Us(n.cells,e.cells),pinned:n.pinned===!0||e.pinned===!0,summary:n.summary===!0||e.summary===!0,overlays:n.overlays===!0||e.overlays===!0}}var Ot=class{constructor(e){this.apply=e;this.Bt=0;this.mt=null;this.vl=0;this.bl=0;this.wl=0;this.hn=!1}batch(e){if(this.hn)return e();this.Bt++;try{return e()}finally{this.Bt--,this.Bt===0&&this.flush()}}Cl(e){this.hn||(this.bl++,this.mt&&this.wl++,this.mt=js(this.mt??{},e),this.Bt===0&&this.flush())}flush(){if(this.hn||this.Bt>0||!this.mt)return;let e=this.mt;this.mt=null,this.vl++,this.apply(e)}snapshot(){return{batchDepth:this.Bt,flushCount:this.vl,requestCount:this.bl,coalescedRequestCount:this.wl,pending:this.mt!=null}}destroy(){this.hn=!0,this.mt=null,this.Bt=0}};var an=Symbol.for("mach-table.adapter.lifecycle.v1");function ln(n,e){Object.defineProperty(n,an,{value:e})}function Or(n){let e=n[an]?.rowDrag;return e?.policy===n.getOption("rowDragPolicy")?e?.factory:void 0}var dn=Symbol.for("mach-table.import.v1");function un(n,e){Object.defineProperty(n,dn,{value:{begin:()=>e.W.Po(),revision:()=>e.i.zr(),isEditing:()=>e.l.isEditing(),columns:()=>e.n.Z(),visibleColumns:()=>e.n.u(),read:(r,i)=>e.d(r,i),editable:(r,i)=>e.l.U(r,i),parse:(r,i,o,s)=>le(e,r,i,o,"import",s),pasteRows:r=>{let i=[];for(let o of e.i.st())if(!o.isGroup&&!o.isDetail&&i.push(o),i.length>=r)break;return i},resolveId:(r,i)=>e.r.resolveRowId?.({data:r,index:i,api:n}),validate:(r,i)=>e.W.Xi(r,i),guard:r=>e.W.Yi(r),commitRows:(r,i,o)=>e.W.Qa(r,i,o)}})}function cn(n){let e=n[dn];if(!e)throw new TypeError("Import plans require a MachTable GridApi");return e}var ye=["gridReady","gridDestroyed","modelUpdated","cellClicked","cellDoubleClicked","cellContextMenu","rowClicked","rowDoubleClicked","selectionChanged","sortChanged","filterChanged","columnResized","columnMoved","columnVisibilityChanged","cellValueChanged","cellEditingStarted","cellEditingStopped","rowEditingStarted","rowEditingStopped","detailToggled","treeChildrenLoaded","treeChildrenLoadFailed","rowDragEnd","rangeSelectionChanged","paginationChanged","displayedColumnsChanged","gridError","dirtyStateChanged"];function qs(n,e,t,r){let i=n.columns().filter(c=>c.colDef.field),o=t.columns??e,s=new Map(i.map(c=>[c.id,c])),a=new Map,l=new Map;for(let c of i){let h=c.colDef.field;a.set(h,a.has(h)?null:c);let p=c.colDef.headerName;p&&l.set(p,l.has(p)?null:c)}let d=[],u=new Set;return o.forEach((c,h)=>{let p=(typeof c=="string"||typeof c=="number"?String(c):"").replace(/^\uFEFF/,"").trim(),m=s.get(p)??(a.has(p)?a.get(p):l.get(p));if(!m){if(r||t.columns||a.has(p)||l.has(p))throw new TypeError(`Unknown or ambiguous import column: ${p}`);return}if(u.has(m.colDef.field))throw new TypeError(`Duplicate import column: ${m.id}`);u.add(m.colDef.field),d.push({column:m,index:h})}),d.length?d:n.visibleColumns().filter(c=>c.colDef.field).map((c,h)=>({column:c,index:h}))}function Ys(n,e){if(!Array.isArray(n)||n.some(t=>!Array.isArray(t)))throw new TypeError("Import requires an array of rows");if(!Number.isInteger(e)||e<-1||e>=n.length)throw new RangeError("Invalid import header row");if(n.length-e-1>1e4||n.reduce((t,r)=>t+r.length,0)>1e5)throw new RangeError("Import supports 10000 data rows and 100000 cells")}function Xs(n,e,t,r,i,o){let s=t.colDef.field,a=n.read(e.node,t),l=o.parseValue?o.parseValue({value:i,field:s,rowIndex:e.rowIndex,columnIndex:r}):t.colDef.valueParser?n.parse(e.node,t,i,a):gt(i,o.coerceNumbers!==!1);if(l!=null&&typeof l.then=="function")throw new TypeError("Import parsers must return synchronous values");if(!ce(e.data,s,l))throw new TypeError(`Unsafe import field: ${s}`);e.changes.push({node:e.node,column:t,oldValue:a,newValue:l})}function Js(n,e,t,r,i,o,s,a){let l=a?.[t]??{},d=s?.[t]??{id:`import:${t}`,rowIndex:t,data:l,selected:!1},u={data:l,node:d,changes:[],rowIndex:t};for(let{column:c,index:h}of r)if(!(e[h]===void 0||s&&!n.editable(d,c)))try{Xs(n,u,c,h,e[h],i)}catch(p){o.issues.push({rowIndex:t,columnIndex:h,colId:c.id,code:"PARSE",message:p instanceof Error?p.message:String(p)})}o.rows.push(u)}function hn(n,e,t={},r,i=!1,o){let s=t.headerRowIndex??(t.columns?-1:0);Ys(e,s);let a=qs(n,s<0?[]:e[s],t,i);if(!a.length)throw new TypeError("Import requires a writable field column");let l={rows:[],issues:[]};for(let d=s+1;d<e.length;d++){let u=e[d];u.some(c=>c!==""&&c!==void 0)&&Js(n,u,d-s-1,a,t,l,r,o)}return l}function de(n){return(n==null?"":String(n)).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Ft(n,e,t="text/plain;charset=utf-8"){try{if(typeof document>"u"||typeof Blob>"u")return!1;let r=document.createElement("a");if(typeof URL<"u"&&typeof URL.createObjectURL=="function"){let i=new Blob([e],{type:t}),o=URL.createObjectURL(i);r.href=o,r.download=n,r.click();let s=typeof URL.revokeObjectURL=="function"?URL.revokeObjectURL.bind(URL):null;s&&setTimeout(()=>{try{s(o)}catch{}},0)}else r.href=`data:${t},${encodeURIComponent(e)}`,r.download=n,r.click();return!0}catch{return!1}}var Zs=["compact","normal","large"],b=["left","center","right"];function Vt(n,e){let t=n.r,r;if(e==="loading")r=t.overlayLoadingTemplate||n.ch();else if(e==="noRows")r=t.overlayNoRowsTemplate||n.hh();else if(e==="error")r=t.overlayErrorTemplate||n.ph();else{n.o.fh();return}n.o.mh(e,r,t.allowUnsafeOverlayHtml)}var Ht=class{constructor(e){this.e=e;this.oi=null;this.ns=null;this.os=!1;this.gn=null;this.ss=[];this.yn=null;this.br=0;this.Tl=-1;this.Dl=-1;this.er=1;this.wr=null}init(e,t){let r=["mach-root",`mach-size--${t.size}`];t.stripedRows&&r.push("mach-striped"),t.showCellBorders&&r.push("mach-cell-borders"),t.domLayout==="autoHeight"&&r.push("mach-dom-layout--auto-height"),this.root=f("div",r.join(" ")),this.xl(t.className),this.root.style.setProperty("--mach-row-h",`${t.rowHeight}px`),this.root.style.setProperty("--mach-header-h",`${t.headerHeight}px`),this.root.setAttribute("role","grid"),this.root.tabIndex=0,this.El(t),this.ii=f("div","mach-header"),this.ii.setAttribute("role","rowgroup"),this.ni={left:[],center:[],right:[]},this.ts={},this.fr={};for(let i of b){let o=f("div",`mach-pane mach-pane--${i} mach-header-pane`),s=f("div","mach-header-rows");if(i==="center"){let a=f("div","mach-header-viewport");a.appendChild(s),o.appendChild(a)}else o.appendChild(s);this.ii.appendChild(o),this.ts[i]=o,this.fr[i]=s}this.Rl(1),this.Fe=f("div","mach-body"),this.pn=f("div","mach-pinned-rows mach-pinned-rows--top"),this.pn.style.display="none",this.fn=f("div","mach-pinned-rows mach-pinned-rows--bottom"),this.fn.style.display="none",this.M={},this.Se={},this.rs={};for(let i of b){let o=f("div",`mach-pane mach-pane--${i} mach-body-pane`),s=f("div",`mach-body-viewport${i==="center"?" mach-body-viewport--scroll":""}`),a=f("div","mach-row-container");s.appendChild(a),o.appendChild(s),this.Fe.appendChild(o),this.rs[i]=o,this.M[i]=s,this.Se[i]=a}this.Ye=f("div","mach-overlay"),this.Ye.style.display="none",this.Ye.setAttribute("role","status"),this.Ye.setAttribute("aria-live","polite"),this.Xe=f("div","mach-overlay-content"),this.Ye.appendChild(this.Xe),this.gt=f("div","mach-infinite-loading"),this.gt.style.display="none",this.gt.appendChild(f("div","mach-spinner")),this.mn=f("span"),this.gt.appendChild(this.mn),this.root.append(this.ii,this.pn,this.Fe,this.fn,this.Ye,this.gt),e.appendChild(this.root),typeof ResizeObserver<"u"&&(this.yn=new ResizeObserver(i=>{let o=i[i.length-1]?.contentRect;if(!o)return;let s=Math.round(o.width),a=Math.round(o.height);s===this.Tl&&a===this.Dl||(this.Tl=s,this.Dl=a,!this.br&&(this.br=requestAnimationFrame(()=>{this.br=0,this.e.Te()})))}),this.yn.observe(this.root)),this.Sl(t.theme)}El(e){e.ariaLabelledBy?(this.root.setAttribute("aria-labelledby",e.ariaLabelledBy),this.root.removeAttribute("aria-label")):(this.root.removeAttribute("aria-labelledby"),this.root.setAttribute("aria-label",e.ariaLabel)),e.ariaDescribedBy?this.root.setAttribute("aria-describedby",e.ariaDescribedBy):this.root.removeAttribute("aria-describedby")}Rl(e){this.er=e;for(let t of b){let r=this.fr[t],i=this.ni[t];for(;i.length<e;){let o=f("div","mach-header-row");o.setAttribute("role","row"),o.setAttribute("aria-rowindex",String(i.length+1)),r.appendChild(o),i.push(o)}for(;i.length>e;)i.pop().remove()}this.Ml()}Il(){return this.er}Ml(){this.ii.style.height=`${this.er*this.e.r.headerHeight}px`;for(let e of b)this.ni[e].forEach((r,i)=>{r.style.top=`${i*this.e.r.headerHeight}px`,r.style.height=`${this.e.r.headerHeight}px`})}gh(e,t){this.Al("left",e),this.Al("right",t)}Al(e,t){let r=this.ts[e],i=this.rs[e];r.style.width=`${t}px`,i.style.width=`${t}px`;let o=t<=0;r.classList.toggle("mach-pane--hidden",o),i.classList.toggle("mach-pane--hidden",o)}as(){let e=this.M.center,t=Math.max(0,e.offsetWidth-e.clientWidth);return Math.max(0,this.Fe.clientWidth-t)}yh(e,t){this.root.style.setProperty("--mach-row-h",`${e}px`),this.root.style.setProperty("--mach-header-h",`${t}px`),this.Ml()}vh(e){for(let t of Zs)this.root.classList.toggle(`mach-size--${t}`,t===e)}Sl(e){if(!this.root)return;this.wr?.(),this.wr=null;let t=e==="dark"||e==="auto"&&this.bh();if(this.root.classList.toggle("mach-theme-dark",t),e==="auto"&&typeof window<"u"&&typeof window.matchMedia=="function"){let r=window.matchMedia("(prefers-color-scheme: dark)"),i=()=>this.root.classList.toggle("mach-theme-dark",r.matches);typeof r.addEventListener=="function"?(r.addEventListener("change",i),this.wr=()=>r.removeEventListener("change",i)):typeof r.addListener=="function"&&(r.addListener(i),this.wr=()=>r.removeListener(i))}}bh(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-color-scheme: dark)").matches}wh(e){this.root.classList.toggle("mach-striped",e)}Ch(e){this.root.classList.toggle("mach-cell-borders",e)}Th(e){this.root.classList.toggle("mach-dom-layout--auto-height",e==="autoHeight")}xl(e){for(let t of this.ss)this.root.classList.remove(t);this.ss=[];for(let t of String(e??"").split(/\s+/).filter(Boolean))this.root.classList.contains(t)||(this.root.classList.add(t),this.ss.push(t))}Dh(e){try{return typeof e=="function"?e():e}catch(t){return this.e.reportError(t,"overlayTemplate"),""}}xh(e,t,r){if(typeof t=="object"&&t!=null&&"el"in t){this.Xe.appendChild(t.el),this.gn=t.destroy??null;return}if(t instanceof HTMLElement){this.Xe.appendChild(t);return}if(t){r?this.Xe.innerHTML=t:this.Xe.textContent=t;return}if(e!=="loading")return;let i=f("div","mach-spinner");i.setAttribute("aria-label","loading"),this.Xe.appendChild(i)}mh(e,t,r=!1){this.oi===e&&this.ns===t&&this.os===r||(this.oi=e,this.ns=t,this.os=r,this.ls(),this.Xe.replaceChildren(),this.xh(e,this.Dh(t),r),this.Ye.style.display="",this.root.classList.add("mach-has-overlay"),this.Ye.setAttribute("role",e==="error"?"alert":"status"),this.root.setAttribute("aria-busy",e==="loading"?"true":"false"))}fh(){this.oi&&(this.oi=null,this.ns=null,this.os=!1,this.Ye.style.display="none",this.root.classList.remove("mach-has-overlay"),this.ls(),this.Xe.replaceChildren(),this.root.setAttribute("aria-busy","false"))}Mt(e,t){this.gt&&(e?(this.mn.textContent!==t&&(this.mn.textContent=t),this.gt.style.display="",this.root.setAttribute("aria-busy","true")):(this.gt.style.display="none",this.oi!=="loading"&&this.root.setAttribute("aria-busy","false")))}destroy(){this.wr?.(),this.wr=null,this.yn?.disconnect(),this.yn=null,this.br&&cancelAnimationFrame(this.br),this.br=0,this.ls(),this.root?.remove()}ls(){if(!this.gn)return;let e=this.gn;this.gn=null;try{e()}catch(t){this.e.reportError(t,"overlayTemplate.destroy")}}};var Oe={columnDefs:"array",rowData:"array",defaultColDef:"object",columnTypes:"object",rowKey:"unknown",rowHeight:"number",headerHeight:"number",rowBuffer:"number",columnLayout:"string",enableColumnResize:"boolean",domLayout:"string",rowSelection:"string",multiSort:"boolean",size:"string",stripedRows:"boolean",rowStyleRules:"array",showCellBorders:"boolean",theme:"string",quickFilterText:"string",advancedFilterModel:"object",masterDetail:"boolean",detailRowHeight:"number",detailRowRenderer:"function",isRowExpandable:"function",detailToggleColumn:"boolean",columnMenu:"boolean",aggFuncs:"object",components:"object",actionPolicy:"object",features:"array",initialState:"object",persistence:"boolean-object",locale:"object",editType:"string",editableIndicator:"string",rowEditValidator:"function",singleClickEdit:"boolean",manualSorting:"boolean",manualFiltering:"boolean",showSummary:"boolean",summaryMethod:"function",treeData:"boolean",childrenKey:"string",isTreeRowExpandable:"function",loadTreeChildren:"function",autoCheckedChildren:"boolean",defaultExpandAll:"boolean",rowNumber:"boolean",indexOffset:"number",applyRowDrag:"boolean",rowDragPolicy:"object",undoStackSize:"number",asyncTransactionWaitMillis:"number",getRowHeight:"function",pinnedTopRowData:"array",pinnedBottomRowData:"array",pagination:"boolean-object",watermark:"boolean-object",suppressWarnings:"boolean",enableRangeSelection:"boolean",suppressClipboard:"boolean",contextMenu:"boolean",getContextMenuItems:"function",tooltipComponent:"function",tooltipShowDelay:"number",flashCells:"boolean",fillHandle:"boolean",statusBar:"boolean-object",datasource:"object",datasourceMode:"string",blockSize:"number",infiniteBufferRows:"number",maxBlocksInCache:"number",datasourceMaxConcurrentRequests:"number",blockPrefetch:"number",datasourceRowCount:"number",dataProcessor:"object-function",dataProcessorMinRows:"number",datasourceRetryCount:"number",datasourceRetryDelay:"number",datasourceRetryJitter:"number",suppressCellFocus:"boolean",suppressRowHoverHighlight:"boolean",suppressNoRowsOverlay:"boolean",suppressHeaderFocus:"boolean",ariaLabel:"string",ariaLabelledBy:"string",ariaDescribedBy:"string",loading:"boolean",error:"unknown",overlayNoRowsTemplate:"unknown",overlayLoadingTemplate:"unknown",overlayErrorTemplate:"unknown",allowUnsafeOverlayHtml:"boolean",className:"string"};var Fr=Object.freeze(Object.keys(Oe));var Hr=new Set(ye.map(n=>`on${n.charAt(0).toUpperCase()}${n.slice(1)}`));function Vr(n,e){return n==null||e==="unknown"?!0:e==="array"?Array.isArray(n):e==="boolean-object"?typeof n=="boolean"||typeof n=="object"&&!Array.isArray(n):e==="object"?typeof n=="object"&&!Array.isArray(n):e==="object-function"?typeof n=="function"||typeof n=="object"&&!Array.isArray(n):e==="number"?typeof n=="number"&&Number.isFinite(n):typeof n===e}function pn(n){let e={};for(let[t,r]of Object.entries(n)){if(Hr.has(t)){(r==null||typeof r=="function")&&(e[t]=r);continue}let i=Oe[t];!i||!Vr(r,i)||(e[t]=r)}return e}var yn=2e3,Br=1e5,Fe=512,ea=1e4;function fn(n){return Array.isArray(n)?[...new Set(n.slice(0,Br).filter(e=>typeof e=="string"&&e.length>0&&e.length<=Fe))]:[]}function ta(n){if(!Array.isArray(n))return[];let e=new Set,t=Br*Fe;for(let r of n.slice(0,Br)){if(typeof r!="string"||!r.length||e.has(r))continue;let i=r.startsWith(dt)?65536:Fe;r.length>i||r.length>t||(e.add(r),t-=r.length)}return[...e]}function mn(n,e){return typeof n=="number"&&Number.isFinite(n)&&n>=1?Math.floor(n):e}function gn(n){return typeof n=="number"&&Number.isFinite(n)&&n>0?n:void 0}function ra(n,e){let t=gn(e.flex);for(let r of["width","contentWidth"]){let i=gn(e[r]);i!==void 0&&(n[r]=i)}e.flex===null?n.flex=null:t!==void 0&&(n.flex=t),(e.widthMode==="auto"||e.widthMode==="manual")&&(n.widthMode=e.widthMode)}function ia(n,e){typeof e.hide=="boolean"&&(n.hide=e.hide),(e.pinned===null||e.pinned==="left"||e.pinned==="right")&&(n.pinned=e.pinned)}function na(n,e){if(n==null||typeof n!="object")return null;let t=n,r=typeof t.colId=="string"?t.colId.trim():"";if(!r||r.length>Fe||e.has(r))return null;e.add(r);let i={colId:r};return ia(i,t),ra(i,t),i}function oa(n){if(!Array.isArray(n))return[];let e=[],t=new Set;for(let r of n.slice(0,yn)){let i=na(r,t);i&&e.push(i)}return e}function sa(n){if(!Array.isArray(n))return[];let e=[],t=new Set;for(let r of n.slice(0,yn)){if(r==null||typeof r!="object")continue;let i=r,o=typeof i.colId=="string"?i.colId.trim():"";!o||o.length>Fe||t.has(o)||i.direction!=="asc"&&i.direction!=="desc"||(t.add(o),e.push({colId:o,direction:i.direction}))}return e}function z(n){if(n==null||typeof n!="object")return null;let e=n;if(e.version!==2||!Array.isArray(e.columns)||!Array.isArray(e.sortModel))return null;let t=e.pagination!=null&&typeof e.pagination=="object"?e.pagination:{};return{version:2,columns:oa(e.columns),sortModel:sa(e.sortModel),filterModel:Y(e.filterModel),advancedFilterModel:O(e.advancedFilterModel),quickFilterText:typeof e.quickFilterText=="string"&&e.quickFilterText.trim()?e.quickFilterText.slice(0,ea):null,pagination:{enabled:t.enabled===!0,page:mn(t.page,1),pageSize:mn(t.pageSize,20)},selectedRowIds:fn(e.selectedRowIds),expandedRowIds:fn(e.expandedRowIds),expandedGroupIds:ta(e.expandedGroupIds)}}function vn(n,e){let t=z(n);if(!t)throw new TypeError("[MachTable] Cannot persist an invalid GridState snapshot.");let r=new Set(e);return{version:2,columns:r.has("columns")?t.columns:[],sortModel:r.has("sort")?t.sortModel:[],filterModel:r.has("filter")?t.filterModel:{},advancedFilterModel:r.has("filter")?t.advancedFilterModel:null,quickFilterText:r.has("filter")?t.quickFilterText:null,pagination:r.has("pagination")?t.pagination:{enabled:!1,page:1,pageSize:20},selectedRowIds:r.has("selection")?t.selectedRowIds:[],expandedRowIds:r.has("expansion")?t.expandedRowIds:[],expandedGroupIds:r.has("expansion")?t.expandedGroupIds:[]}}function aa(n){try{if(typeof structuredClone=="function")return structuredClone(n)}catch{}return Array.isArray(n)?[...n]:n!=null&&typeof n=="object"?{...n}:n}function wn(n,e){let t=e?new Set(e.map(String)):null;return n.filter(r=>!t||t.has(r.rowId)).map(r=>({...r,data:aa(r.data),cells:r.cells.map(i=>({...i}))}))}function la(n,e){let t=typeof n?.rowId=="string"?n.rowId:"";return!e.has(t)||typeof n.message!="string"||!n.message.trim()?null:{...n,rowId:t,message:n.message.trim(),...typeof n.code=="string"&&n.code.trim()?{code:n.code.trim()}:{},...Array.isArray(n.colIds)?{colIds:[...new Set(n.colIds.filter(r=>typeof r=="string"&&r.length>0))]}:{}}}function bn(n,e){let t=new Map;for(let r of n??[]){let i=la(r,e);i&&!t.has(i.rowId)&&t.set(i.rowId,i)}return[...t.values()]}function Cn(n,e){let t=new Set(n.map(d=>d.rowId)),r=bn(e?.conflicts,t),i=new Set(r.map(d=>d.rowId)),o=bn(e?.failures,t).filter(d=>!i.has(d.rowId)),s=new Set([...o,...r].map(d=>d.rowId)),a=e?.savedRowIds==null?null:new Set(e.savedRowIds.map(String).filter(d=>t.has(d))),l=n.filter(d=>!s.has(d.rowId)&&(a==null||a.has(d.rowId)));return{submitted:n,saved:l,failures:o,conflicts:r}}function da(n,e){if(e.serverData===void 0)return null;let t=n.rows.getById(e.rowId);if(!t||t.data==null)return null;let r=n.getOption("rowKey");if(r){let s=typeof r=="function"?r(e.serverData):H(e.serverData,r);return String(s)===e.rowId?{data:e.serverData,mergeIntoCurrent:!1}:null}let i=t.data;return i!=null&&e.serverData!=null&&typeof i=="object"&&typeof e.serverData=="object"?{data:i,mergeIntoCurrent:!0}:null}function Tn(n,e,t){if(n.isDestroyed())return!1;if(t==="keepLocal")return!0;let r=da(n,e);return r?(n.editing.rollback([e.rowId]),r.mergeIntoCurrent&&Object.assign(r.data,e.serverData),n.rows.transact({update:[r.data]}),n.editing.markSaved([e.rowId]),!0):!1}function Dn(n,e){return{setData:t=>n.ot(t),transact:t=>n.$r(t),transactAsync:(t,r)=>n.Eh(t,r),flushTransactions:()=>n.kl(),getCount:()=>e.i.P(),getAt:t=>e.i.f(t),getById:t=>e.i.X(t),forEach:t=>e.i.Ku(t),forEachDisplayed:t=>e.i.Uu(t),reorder:(t,r)=>!e.s()&&!e.l.isEditing()&&e.i.Pa(t,r),isRemote:()=>e.i.g,reload:t=>n.reload(t),ensureLoaded:(t,r,i)=>n.go(t,r,i),purgeCache:()=>{e.s()||e.i.hu()},getCacheSnapshot:()=>e.i.pu()}}function xn(n,e){return{getDefinitions:()=>e.n.Qn(),setDefinitions:t=>n.Ri(t),getState:()=>e.n.na(),setState:t=>n.Rh(t),resetState:()=>n.oo(),setVisible:(t,r)=>n.to(t,r),setPinned:(t,r)=>n.ro(t,r),move:(t,r)=>{e.s()||e.Nr(t,r)},setWidth:(t,r)=>n.Ae(t,r),fit:t=>n.Sh(t),autoSize:t=>n.Mh(t),autoSizeAll:()=>n.Ih(),getWorkbenchItems:()=>n.Ah(),openWorkbench:t=>{e.s()||e.columnMenu.Kc(t)},closeWorkbench:()=>e.columnMenu.close()}}function En(n,e){return{getRows:()=>e.m.Na(),getVisibleRows:()=>n.kh(),getNodes:()=>e.m.Gt(),getIds:()=>e.m.Oa(),setRows:(t,r)=>n.Lh(t,r),setById:(t,r,i)=>n.Do(t,r,i),selectAll:t=>n.selectAll(t),clear:()=>n.deselectAll(),getMode:()=>e.r.rowSelection,setMode:t=>n.Gh(t),getRange:()=>e.a.si(),clearRange:()=>n.mr()}}function Rn(n,e){return{startCell:t=>n.Ph(t),startRow:t=>e.l.startRow(t),isRowActive:t=>e.l.il(t),stop:t=>e.l.de(t?.cancel===!0),getChanges:()=>e.V.getChanges(),getDirtyRowIds:()=>e.V.getDirtyRowIds(),markSaved:t=>e.V.markSaved(t),rollback:t=>e.V.rollback(t),save:(t,r)=>n.Nh(t,r),undo:()=>!e.s()&&e.B.undo(),redo:()=>!e.s()&&e.B.redo(),canUndo:()=>e.B.canUndo(),canRedo:()=>e.B.canRedo()}}function Sn(n){return{get:()=>n.getState(),apply:(e,t)=>n.Ll(e,t)}}function Mn(n,e){return{get:()=>e.Oh(),getPerformance:()=>e.oe.snapshot(),resetPerformance:()=>e.oe.reset()}}function In(n,e){return{getModel:()=>e.i.De(),setModel:t=>n.lr(t),getAdvancedModel:()=>e.i.It(),setAdvancedModel:t=>n.kt(t),getQuickText:()=>e.i.Sa(),setQuickText:t=>n.dr(t),isPresent:t=>t==null?e.i.$i():Object.prototype.hasOwnProperty.call(e.i.De(),t)}}function An(n,e){return{getModel:()=>e.n.Q(),setModel:t=>n.Fh(t)}}function kn(n,e){return{isEnabled:()=>e.i.xe,setEnabled:t=>{e.s()||e.i.ka(t)},getPage:()=>e.i.Lt(),setPage:t=>{e.s()||e.i.setPage(t)},getPageSize:()=>e.r.paginationPageSize,setPageSize:t=>{e.s()||e.i.setPageSize(t)},getPageCount:()=>e.i.getPageCount(),getTotalRowCount:()=>e.i.getTotalRowCount()}}function Ln(n,e){return{isRowExpanded:t=>e.i.isRowExpanded(t),setRowExpanded:(t,r)=>e.s()||e.i.isRowExpanded(t)===r?!1:(r?e.i.Hu(t):e.i.Vu(t),e.i.isRowExpanded(t)===r),isTreeRowLoading:t=>n.isTreeRowLoading(t),loadTreeChildren:(t,r)=>n.loadTreeChildren(t,r),isGroupExpanded:t=>e.i.isGroupExpanded(t),setGroupExpanded:(t,r)=>e.s()||e.i.isGroupExpanded(t)===r?!1:(e.i.To(t),e.i.isGroupExpanded(t)===r),setAllGroupsExpanded:t=>{e.s()||(t?e.i.zu():e.i.Wu())},setAllDetailsExpanded:t=>{e.s()||(t?e.i.Bu():e.i._u())}}}function Gn(n,e){return{getRoot:()=>e.s()?null:e.o.root,scrollToRow:(t,r)=>n.cr(t,r),refreshCells:t=>n.refreshCells(t),refreshLayout:()=>n.refreshLayout(),flush:()=>e.Cr.flush(),setOverlay:t=>n.setOverlay(t),getPinnedRows:t=>e.he.getRows(t),setPinnedRows:(t,r)=>n.setPinnedRows(t,r)}}function Pn(n,e){return{exportCsv:t=>n.Hh(t),importCsv:(t,r)=>n.importCsv(t,r),exportMatrix:t=>n.Gl(t),importMatrix:(t,r)=>n.importMatrix(t,r),print:t=>n.print(t),copyRange:()=>e.s()?Promise.resolve(!1):e.cl()}}function Bt(n){return ie(n?.reason,"The operation was aborted")}function Nn(n,e){return ot(n,e,()=>Bt(e))}function x(n,e){return Object.prototype.hasOwnProperty.call(n,e)}function _r(n,e,t,r=!1){let i=M(n,t,r);return i===void 0||i===e?void 0:i}var zr=class{constructor(e){this.e=e;this.ai=[];this.yt=null}batch(e){return this.e.Pl(()=>e(this.e.api))}ot(e){this.e.s()||(this.e.r.rowData=e??[],!this.e.i.g&&(this.e.i.ot(e),this.e.h({data:!0})))}$r(e){if(this.e.s()||this.e.i.g)return;let t=this.e.i.$r(e);this.Nl(t)}Eh(e,t={}){if(this.e.s()||this.e.i.g)return Promise.resolve();if(t.signal?.aborted)return Promise.reject(Bt(t.signal));let r=new Promise((i,o)=>{let s={transaction:e,resolve:i,reject:o,signal:t.signal,aborted:!1};t.signal&&(s.onAbort=()=>{s.aborted||(s.aborted=!0,o(Bt(t.signal)))},t.signal.addEventListener("abort",s.onAbort,{once:!0})),this.ai.push(s)});return this.yt==null&&(this.yt=setTimeout(()=>this.kl(),this.e.r.asyncTransactionWaitMillis)),r}kl(){this.yt!=null&&clearTimeout(this.yt),this.yt=null;let e=this.ai;this.ai=[];let t=e.filter(r=>!r.aborted).map(r=>r.transaction);if(t.length>0&&!this.e.s()&&!this.e.i.g){let r=this.e.i.wu(t);this.Nl(r)}for(let r of e)r.signal&&r.onAbort&&r.signal.removeEventListener("abort",r.onAbort),r.aborted||r.resolve()}Nl(e){if(e.pipelineChanged){this.e.h({data:!0});return}e.updatedRowIds.length!==0&&this.e.h({cells:{rowIds:e.updatedRowIds},summary:!0,overlays:!0})}Ri(e){this.updateOptions({columnDefs:[...e??[]]})}Rh(e){this.e.s()||(this.e.n.oa(e),this.e._t(),this.e.Tr())}oo(){this.e.s()||(this.e.n.oo(),this.e._t(),this.e.Tr())}to(e,t){this.e.s()||(this.e.n.to(e,t),this.e._t(),this.e.emit("columnVisibilityChanged",{colId:e,visible:t}))}ro(e,t){this.e.s()||(this.e.n.ro(e,t),this.e._t(),this.e.Tr())}Ae(e,t){if(this.e.s())return!1;let r=this.e.n.k(e);return!r||!this.e.n.Ae(r,t)?!1:(this.e.je(),this.e.hr([r]),!0)}Sh(e){if(this.e.s())return;let t=this.e.n.u(),r=t.filter(d=>d.pinned===null&&!d.colDef.suppressSizeToFit);if(r.length===0)return;let i=e??this.e.o.as();if(!Number.isFinite(i)||i<=0)return;let o=t.reduce((d,u)=>d+(u.pinned!==null||u.colDef.suppressSizeToFit?u.currentWidth:0),0),s=Je(r.map(d=>({width:d.currentWidth,minWidth:d.colDef.minWidth,maxWidth:d.colDef.maxWidth})),Math.max(0,i-o)),a=this.e.r.columnLayout==="fit"&&e===void 0,l=r.filter((d,u)=>a?this.e.n.ra(d,s[u]):this.e.n.Ae(d,s[u]));this.e.je(),this.e.hr(l)}Mh(e){if(this.e.s())return;let t=this.e.n.k(e);t&&this.Ol(t)&&(this.e.je(),this.e.hr([t]))}Ol(e){return this.e.r.columnLayout==="fit"&&e.colDef.suppressSizeToFit?!1:e.hasCheckbox||e.isDetailToggle?this.e.n.Ae(e,e.isDetailToggle?38:46):this.Vh(e,this.e.zt.Zs(e))}Vh(e,t){return this.e.r.columnLayout==="fit"?this.e.n.ra(e,t):this.e.n.Ae(e,t)}Ih(){if(this.e.s())return;let e=[];for(let t of this.e.n.u())this.Ol(t)&&e.push(t);e.length>0&&(this.e.je(),this.e.hr(e))}Fh(e){this.e.s()||(this.e.n.Or(e),this.e.Or())}lr(e){if(!this.e.s()){if(this.e.i.lr(e),this.e._.vn(),this.bn(),this.e.i.g){this.e.i.At();return}this.e.i.C(),this.e.h({data:!0})}}kt(e){if(!(this.e.s()||!this.e.i.kt(e))){if(this.bn(),this.e.i.g){this.e.i.At();return}this.e.i.C(),this.e.h({data:!0})}}bn(e=!0){this.e.emit("filterChanged",{filterModel:this.e.i.De(),advancedFilterModel:this.e.i.It()},e)}dr(e){this.e.s()||(this.e.r.quickFilterText=e!=null&&e.trim()!==""?e:null,this.e.i.dr(e)&&this.e.Bh())}Gh(e){this.e.s()||this.e.r.rowSelection!==e&&(this.e.r.rowSelection=e,e==="none"&&this.deselectAll(),this.e._.li(),this.e.a.ds())}Do(e,t=!0,r=!0){this.e.m.Do(e,t,r)}selectAll(e=!0){this.e.m.selectAll(e)}deselectAll(){this.e.m.deselectAll()}cr(e,t="top"){this.e.a.cr(e,t)}loadTreeChildren(e,t={}){return this.e.s()?Promise.resolve([]):this.e.i.loadTreeChildren(e,t.force===!0)}isTreeRowLoading(e){return!this.e.s()&&this.e.i.isTreeRowLoading(e)}Lh(e,t=!0){if(this.e.s())return;let r=this.e.r.resolveRowId,i=[];for(let o of e){let s=r?this.e.i.X(this.e.i.resolveRowId(o,-1,`__missing_selection_${this.e.ar()}`)):this.e.i.ge().find(a=>a.data===o);s&&i.push({node:s,selected:!0})}i.length>0?this.e.m.rc(i,t):t&&this.deselectAll()}kh(){let e=new Set(this.e.m.Gt().map(t=>t.id));return this.e.i.st().filter(t=>!t.isDetail&&!t.isGroup&&e.has(t.id)).map(t=>t.data).filter(Boolean)}async Nh(e,t){let r=wn(this.e.V.getChanges(),t);if(r.length===0)return{submitted:[],saved:[],failures:[],conflicts:[]};let i=this.e.i.zr(),o=Cn(r,await e(r));return!this.e.s()&&i===this.e.i.zr()&&this.e.V.sh(o.saved),o}setPinnedRows(e,t){if(this.e.s())return;let r=e==="top"?"pinnedTopRowData":"pinnedBottomRowData";this.e.r[r]=t??[],this.e.he.setRows(e,this.e.r[r])}mr(){this.e.s()||this.e.a.mr()}Ah(){return this.e.n.Z().filter(e=>!e.isDetailToggle).map(e=>({colId:e.id,label:e.colDef.headerName??e.colDef.field??e.id,visible:!e.hide,pinned:e.pinned,width:e.currentWidth||e.manualWidth||e.colDef.width||0,movable:e.movable,hideable:!e.hasCheckbox}))}refreshLayout(){this.e.s()||(this.e.Te(),this.e.a.wn(!0))}reload(e={}){return this.e.s()?Promise.resolve():e.signal?.aborted?Promise.reject(Bt(e.signal)):this.e.i.g?Nn(this.e.i.Vi(e.signal),e.signal):(this.e.i.ot(this.e.r.rowData),this.e.h({data:!0}),Promise.resolve())}go(e,t,r={}){return this.e.s()?Promise.resolve():Nn(this.e.i.go(e,t,r.signal),r.signal)}importCsv(e,t={}){if(!e)return!1;let{parseValue:r,...i}=t;return this.importMatrix(bt(e,t.separator??","),{...i,parseValue:r?o=>r({...o,value:o.value}):void 0})}importMatrix(e,t={}){if(this.e.s()||this.e.i.g||!Array.isArray(e)||!e.length)return!1;try{let r=cn(this.e.api),i=t.mode==="paste"?r.pasteRows(e.length):void 0,o=hn(r,e,t,i);if(o.issues.length)return this.e.reportError(new Error(o.issues.map(s=>s.message).join("; ")),"import",{issues:o.issues}),!1;if(t.mode==="paste")this.e.di(o.rows.flatMap(s=>s.changes));else{let s=o.rows.map(a=>a.data);t.mode==="append"?this.$r({add:s}):this.ot(s)}return!0}catch(r){return this.e.reportError(r,"import"),!1}}print(e={}){if(this.e.s())return!1;try{let t=window.open("","_blank","width=980,height=720");if(!t)return!1;let r=this.e.n.u().filter(d=>$(d)&&!d.colDef.rowDrag),i=this.e.i.Ia().filter(d=>!d.isDetail&&!d.isGroup),s=e.includeHeader!==!1?`<tr>${r.map(d=>`<th>${de(d.colDef.headerName??d.colDef.field??d.id)}</th>`).join("")}</tr>`:"",a=i.map(d=>`<tr>${r.map(u=>{let c=re(this.e,d,u);return`<td>${de(c)}</td>`}).join("")}</tr>`).join(""),l=`<!doctype html><html><head><meta charset="utf-8"><title>${de(e.title??"MachTable")}</title><style>body{font-family:system-ui,"PingFang SC","Microsoft YaHei",sans-serif;padding:20px}h3{margin:0 0 12px;font-size:16px}table{border-collapse:collapse;width:100%;font-size:12px}th,td{border:1px solid #bbb;padding:5px 8px;text-align:left;word-break:break-all}th{background:#f2f5f9;font-weight:600}@page{margin:12mm}</style></head><body><h3>${de(e.title??"")}</h3><table>${s}${a}</table></body></html>`;return t.document.write(l),t.document.close(),t.focus(),t.print(),!0}catch{return!1}}Ph(e){let t=this.e.n.k(e.colId);return t?this.e.l.start(e.rowIndex,t,e.keyPress??null):!1}refreshCells(e){let t=e==null||e.rowIds==null&&e.rowIndexes==null&&e.columns==null;this.e.h({cells:e??!0,pinned:e?.includePinned??t,summary:t})}getOption(e){return this.e.r[e]}updateOptions(e){this.e.s()||(this.e.us(e),e=pn(e),Object.keys(e).length!==0&&this.e.Pl(()=>{let t={},r=this.e.r.columnMenu;this._h(e,t),this.zh(e,t),this.Wh(e,t),this.$h(e,t),this.Kh(e),this.Uh(e,t),this.jh(e,t),this.qh(e,t),this.Yh(e,t),this.Xh(e,t),this.Jh(e,t,r)}))}_h(e,t){let r=this.e.r;x(e,"columnDefs")&&e.columnDefs!==r.columnDefs&&(r.columnDefs=Array.isArray(e.columnDefs)?e.columnDefs:[],t.needsColumnRebuild=!0,t.columnDefsChanged=!0),R(e,r,["rowNumber"])&&(t.needsColumnRebuild=!0),x(e,"rowData")&&e.rowData!==r.rowData&&(r.rowData=Array.isArray(e.rowData)?e.rowData:[],t.needsRowRebuild=!0),x(e,"initialState")&&e.initialState&&(r.initialState=e.initialState,t.stateToApply=e.initialState),this.Zh(e)}Zh(e){for(let t of ye){let r=`on${t.charAt(0).toUpperCase()}${t.slice(1)}`;x(e,r)&&Object.assign(this.e.r,{[r]:e[r]})}}zh(e,t){let r=this.e.r;for(let o of["rowHeight","headerHeight","rowBuffer"]){let s=_r(e[o],r[o],o==="rowBuffer"?0:1,o==="rowBuffer");s!==void 0&&(r[o]=s,t.needsRelayout=!0,o==="headerHeight"&&(t.needsHeaderRebuild=!0))}e.columnLayout!=null&&e.columnLayout!==r.columnLayout&&(r.columnLayout=e.columnLayout==="fit"?"fit":"normal",t.needsRelayout=!0),e.domLayout!=null&&e.domLayout!==r.domLayout&&(r.domLayout=e.domLayout==="autoHeight"?"autoHeight":"normal",this.e.o.Th(r.domLayout),t.needsPoolRebuild=!0),R(e,r,["multiSort"]);let i=_r(e.detailRowHeight,r.detailRowHeight,1);i!==void 0&&(r.detailRowHeight=i,this.e.a.Cn(),this.e.a.ui(!0))}Wh(e,t){let r=this.e.r;e.editType!=null&&e.editType!==r.editType&&(this.e.l.stop(!0),r.editType=e.editType==="fullRow"?"fullRow":"cell",t.needsCellRefresh=!0),e.editableIndicator!=null&&e.editableIndicator!==r.editableIndicator&&(r.editableIndicator=e.editableIndicator==="always"||e.editableIndicator==="none"?e.editableIndicator:"hover",t.needsCellRefresh=!0),R(e,r,["rowEditValidator"],!0),R(e,r,["singleClickEdit","manualSorting","manualFiltering"])}$h(e,t){let r=this.e.r;typeof e.enableColumnResize=="boolean"&&e.enableColumnResize!==r.enableColumnResize&&(this.e.ci.Ot(),r.enableColumnResize=e.enableColumnResize,t.needsHeaderRebuild=!0),e.locale!=null&&e.locale!==r.locale&&(r.locale=e.locale,t.needsHeaderRebuild=!0,t.needsCellRefresh=!0,this.e.Dr.Me(),this.e.qe.Me()),e.indexOffset!=null&&e.indexOffset!==r.indexOffset&&(r.indexOffset=e.indexOffset,t.needsCellRefresh=!0),e.showSummary!=null&&e.showSummary!==r.showSummary&&(r.showSummary=e.showSummary,t.needsSummaryRefresh=!0,t.needsRelayout=!0);let i=_r(e.undoStackSize,r.undoStackSize,0,!0);i!==void 0&&(r.undoStackSize=i,this.e.B.oh());let o=M(e.asyncTransactionWaitMillis,0,!0);o!==void 0&&(r.asyncTransactionWaitMillis=o),this.Qh(e,t),this.ep(e)}Qh(e,t){if(!x(e,"getRowHeight"))return;let r=this.e.r.getRowHeight!==e.getRowHeight;this.e.r.getRowHeight=e.getRowHeight,r&&this.e.a.Tn(),t.needsRelayout=!0}ep(e){let t=this.e.r;e.enableRangeSelection!=null&&(t.enableRangeSelection=e.enableRangeSelection,e.enableRangeSelection||this.mr()),R(e,t,["tooltipComponent"],!0);let r=M(e.tooltipShowDelay,0);r!==void 0&&(t.tooltipShowDelay=r),R(e,t,["flashCells"]),R(e,t,["getContextMenuItems"],!0),e.theme!=null&&e.theme!==t.theme&&(t.theme=e.theme,this.e.o.Sl(e.theme),this.e.Dn.refresh())}Kh(e){if(!x(e,"pagination"))return;let t=this.e.r,r=e.pagination,i=r!==!1&&t.datasource==null;i!==t.paginationEnabled&&this.e.i.ka(i),typeof r=="object"&&r&&this.tp(r),t.paginationEnabled&&this.e.i.Iu(),this.e.Dr.Me()}tp(e){let t=this.e.r;t.paginationMode=e.mode==="server"?"server":"client";let r=M(e.page,1,!0),i=M(e.total,0,!0);r!==void 0&&(t.paginationPage=r),i!==void 0&&(t.paginationTotal=i),e.pageSize!=null&&(t.paginationPageSize=e.pageSize),e.pageSizeOptions!=null&&(t.paginationPageSizeOptions=e.pageSizeOptions),e.showTotal!=null&&(t.paginationShowTotal=e.showTotal),e.showPageSizeSelector!=null&&(t.paginationShowSizeSelector=e.showPageSizeSelector)}Uh(e,t){x(e,"rowStyleRules")&&(this.e.r.rowStyleRules=Array.isArray(e.rowStyleRules)?e.rowStyleRules:[],t.needsCellRefresh=!0,this.e.h({pinned:!0})),this.rp(e,t),this.ip(e,t);let r=this.e.r;e.stripedRows!=null&&e.stripedRows!==r.stripedRows&&(r.stripedRows=e.stripedRows,this.e.o.wh(e.stripedRows)),e.showCellBorders!=null&&e.showCellBorders!==r.showCellBorders&&(r.showCellBorders=e.showCellBorders,this.e.o.Ch(e.showCellBorders))}rp(e,t){let r=this.e.r;e.watermark!==void 0&&(Object.assign(r,gr(e)),this.e.Dn.refresh()),this.np(e),x(e,"summaryMethod")&&(r.summaryMethod=e.summaryMethod,t.needsSummaryRefresh=!0)}np(e){let t=this.e.r;R(e,t,["suppressClipboard","contextMenu","columnMenu","fillHandle"]),e.statusBar!==void 0&&(t.statusBarEnabled=e.statusBar===!0||typeof e.statusBar=="object"&&e.statusBar!=null,typeof e.statusBar=="object"&&e.statusBar?.panels&&(t.statusBarPanels=e.statusBar.panels),this.e.qe.Me())}ip(e,t){let{size:r}=e;if(r==null||!x(Ee,r)||r===this.e.r.size)return;let i=Ee[r];this.e.r.size=r,this.e.r.rowHeight=e.rowHeight??i.rowHeight,this.e.r.headerHeight=e.headerHeight??i.headerHeight,this.e.o.vh(r),t.needsRelayout=!0,t.needsHeaderRebuild=!0}jh(e,t){let r=this.e.r;R(e,r,["suppressCellFocus","suppressRowHoverHighlight","suppressNoRowsOverlay"]),e.suppressHeaderFocus!=null&&e.suppressHeaderFocus!==r.suppressHeaderFocus&&(r.suppressHeaderFocus=e.suppressHeaderFocus,t.needsHeaderRebuild=!0),this.op(e),this.sp(e)}op(e){let t=this.e.r,r=!1;for(let i of["ariaLabel","ariaLabelledBy","ariaDescribedBy"])x(e,i)&&(t[i]=e[i]??Re[i],r=!0);r&&this.e.o.El(t)}sp(e){let t=this.e.r;for(let r of["overlayNoRowsTemplate","overlayLoadingTemplate","overlayErrorTemplate"])x(e,r)&&(t[r]=e[r]??Re[r]);R(e,t,["allowUnsafeOverlayHtml"]),x(e,"className")&&(t.className=e.className??"",this.e.o.xl(t.className)),R(e,t,["loading"]),x(e,"error")&&(t.error=e.error??null)}qh(e,t){this.ap(e,t),this.lp(e,t);let r=this.e.r;R(e,r,["autoCheckedChildren"]),e.defaultExpandAll!=null&&e.defaultExpandAll!==r.defaultExpandAll&&(r.defaultExpandAll=e.defaultExpandAll,t.needsRowRebuild=!0),e.applyRowDrag!=null&&(r.applyRowDrag=e.applyRowDrag,t.needsCellRefresh=!0),x(e,"rowDragPolicy")&&(r.rowDragPolicy=e.rowDragPolicy,t.needsCellRefresh=!0),R(e,r,["suppressWarnings"])}ap(e,t){let r=this.e.r;if(e.rowSelection!=null&&e.rowSelection!==r.rowSelection&&(r.rowSelection=e.rowSelection,e.rowSelection==="none"&&this.deselectAll(),t.needsHeaderRebuild=!0,t.needsPoolRebuild=!0,this.e.xn()),e.quickFilterText!==void 0&&this.dr(e.quickFilterText),e.defaultColDef!==void 0&&e.defaultColDef!==r.defaultColDef&&(r.defaultColDef={...fr,...e.defaultColDef},t.needsColumnRebuild=!0),x(e,"columnTypes")&&e.columnTypes!==r.columnTypes&&(r.columnTypes=e.columnTypes??{},t.needsColumnRebuild=!0),x(e,"rowKey")){r.rowKey=e.rowKey;let i=e.rowKey;r.resolveRowId=i?({data:o})=>mr(i,o):void 0,t.needsRowRebuild=!0}}lp(e,t){let r=this.e.r;e.masterDetail!=null&&e.masterDetail!==r.masterDetail&&(r.masterDetail=e.masterDetail,t.needsColumnRebuild=!0,t.needsRowRebuild=!0),e.detailToggleColumn!=null&&e.detailToggleColumn!==r.detailToggleColumn&&(r.detailToggleColumn=e.detailToggleColumn,t.needsColumnRebuild=!0),e.treeData!=null&&e.treeData!==r.treeData&&(r.treeData=e.treeData,t.needsRowRebuild=!0,t.needsColumnRebuild=!0,this.e.xn()),e.childrenKey!=null&&e.childrenKey!==r.childrenKey&&(r.childrenKey=e.childrenKey,t.needsRowRebuild=!0),R(e,r,["isTreeRowExpandable","loadTreeChildren"],!0)&&(t.needsCellRefresh=!0)}Yh(e,t){let r=this.e.r;R(e,r,["aggFuncs"],!0)&&(t.needsRowRebuild=!0),R(e,r,["components","actionPolicy"],!0)&&(t.needsCellRefresh=!0),x(e,"features")&&(r.features=Array.isArray(e.features)?e.features:[],t.needsFeatureReload=!0),this.dp(e,t),this.up(e,t)}dp(e,t){let r=this.e.r;x(e,"dataProcessor")&&this.e.Fl(e.dataProcessor)&&(t.needsRowRebuild=!0);let i=M(e.dataProcessorMinRows,1,!0);i!==void 0&&i!==r.dataProcessorMinRows&&(r.dataProcessorMinRows=i,t.needsRowRebuild=!0)}up(e,t){let r=this.e.r;x(e,"persistence")&&(r.persistence=_e(e.persistence),t.needsStateLoad=!0)}Xh(e,t){this.cp(e,t),this.hp(e,t),this.pp(e,t),this.fp(e)}cp(e,t){let r=this.e.r;for(let o of["blockSize","maxBlocksInCache","datasourceMaxConcurrentRequests"]){let s=M(e[o],1,!0);s===void 0||s===r[o]||(r[o]=s,t.datasourceChanged||(t.datasourceChanged=r.datasourceMode==="block"))}for(let o of["infiniteBufferRows","blockPrefetch","datasourceRetryCount","datasourceRetryDelay"]){let s=M(e[o],0,!0);s!==void 0&&(r[o]=s)}let i=M(e.datasourceRetryJitter,0);i!==void 0&&(r.datasourceRetryJitter=Math.min(1,i))}hp(e,t){let r=this.e.r;if(x(e,"datasourceMode")){let i=e.datasourceMode==="block"?"block":"sequential";i!==r.datasourceMode&&(r.datasourceMode=i,t.datasourceChanged=!0)}if(x(e,"datasourceRowCount")){let i=e.datasourceRowCount==null?null:M(e.datasourceRowCount,0,!0)??null;i!==r.datasourceRowCount&&(r.datasourceRowCount=i,t.datasourceChanged=!0)}}pp(e,t){let r=this.e.r;x(e,"datasource")&&e.datasource!==r.datasource&&(r.datasource=e.datasource,r.paginationEnabled=e.datasource==null&&r.paginationEnabled,t.datasourceChanged=!0,this.e.Dr.Me()),R(e,r,["detailRowRenderer","isRowExpandable"],!0)&&(t.needsCellRefresh=!0)}fp(e){let t=this.e.r;e.pinnedTopRowData!==void 0&&(t.pinnedTopRowData=e.pinnedTopRowData??[],this.e.he.setRows("top",t.pinnedTopRowData)),e.pinnedBottomRowData!==void 0&&(t.pinnedBottomRowData=e.pinnedBottomRowData??[],this.e.he.setRows("bottom",t.pinnedBottomRowData))}Jh(e,t,r){let i=this.e.r;t.needsColumnRebuild?this.mp(e,t):x(e,"advancedFilterModel")&&(t.filterChanged=this.e.i.kt(e.advancedFilterModel)),t.needsFeatureReload&&this.e.Hl(i.features),this.gp(t),t.filterChanged&&this.bn(!t.needsColumnRebuild),t.needsRelayout&&this.e.o.yh(i.rowHeight,i.headerHeight),e.columnMenu!=null&&e.columnMenu!==r&&(t.needsHeaderRebuild=!0),t.stateToApply&&this.Ll(t.stateToApply),this.e.h({layout:t.needsRelayout,header:t.needsHeaderRebuild,pool:t.needsPoolRebuild,cells:t.needsCellRefresh&&!t.needsPoolRebuild?!0:void 0,summary:t.needsSummaryRefresh,overlays:!0})}mp(e,t){t.columnDefsChanged&&!t.needsRowRebuild&&(this.e.Ce(),this.e.l.stop(!0));let r=this.e.n.Ri(this.e.r.columnDefs);t.filterChanged=this.e.i.Tu(x(e,"advancedFilterModel")?e.advancedFilterModel??null:void 0),r&&this.e.emit("sortChanged",{sortModel:this.e.n.Q()},!1),this.e._t(),t.needsHeaderRebuild=!1,t.needsPoolRebuild=!1}gp(e){let t=e.needsStateLoad||e.needsColumnRebuild,r=e.datasourceChanged||e.needsRowRebuild||e.columnDefsChanged||e.filterChanged,i=this.e.r.persistence?.sections,o=r&&(this.e.i.g||i?.length===1&&i[0]==="columns");t&&o&&this.e.cs(!e.needsStateLoad,!0),this.yp(e,r),t&&!o&&this.e.cs(!e.needsStateLoad)}yp(e,t){if(e.datasourceChanged){this.e.i.cu();return}if(t){if(this.e.i.g){this.e.i.At();return}e.needsRowRebuild?this.e.i.ot(this.e.r.rowData):this.e.i.C(),this.e.h({data:!0})}}Hh(e={}){let t=this.Gl({...e,target:"csv",protectFormulas:!1});return Zi(t,e)}Gl(e={}){let t=this.e.n.u().filter($),r=e.includeHeader===!1?[]:[t.map(o=>o.colDef.headerName??o.colDef.field??o.id)];if(e.headersOnly)return r;let i=e.onlySelected?this.e.m.Gt().slice().sort((o,s)=>o.rowIndex-s.rowIndex):e.onlyAllDisplayed?this.e.i.st():this.e.i.Ia();return[...r,...i.filter(o=>!o.isDetail&&!o.isGroup).map(o=>t.map(s=>{let a=Pe(this.e,o,s,e.target??"xlsx");return e.protectFormulas===!1?a:oe(a)}))]}getState(){return{version:2,columns:this.e.n.na(!1),sortModel:this.e.n.Q(),filterModel:this.e.i.De(),advancedFilterModel:this.e.i.It(),quickFilterText:this.e.i.Sa(),pagination:{enabled:this.e.i.xe,page:this.e.i.Lt(),pageSize:this.e.r.paginationPageSize},selectedRowIds:this.e.m.Oa(),expandedRowIds:this.e.i.Nu(),expandedGroupIds:this.e.i.Ou()}}Ll(e,t={}){if(this.e.s())return;let r=z(e);if(!r){this.e.reportError(new TypeError("[MachTable] GridState must use the current version 2 schema."),"gridState.apply");return}let i=["columns","sort","filter","pagination","selection","expansion"],o=new Set(t.sections??i);this.e.l.stop(!0),this.vp(r,o),this.bp(r,o),t.emitEvents!==!1&&this.wp(o),o.has("columns")&&this.e.Tr()}vp(e,t){t.has("columns")&&this.e.n.oa(e.columns??[]),t.has("sort")&&this.e.n.Or(e.sortModel??[]),t.has("filter")&&(this.e.i.lr(e.filterModel??{}),this.e.i.kt(e.advancedFilterModel),this.e.i.dr(e.quickFilterText)),t.has("expansion")&&this.e.i.Fu(e.expandedRowIds??[],e.expandedGroupIds??[]),t.has("pagination")&&e.pagination&&(this.e.r.paginationEnabled=e.pagination.enabled&&!this.e.i.g,this.e.i.Aa(e.pagination.page,e.pagination.pageSize),this.e.Dr.Me())}bp(e,t){t.has("columns")&&this.e._t(),this.e.Cp()||(this.e.i.g?(t.has("sort")||t.has("filter"))&&this.e.i.At():(this.e.i.C(),this.e.h({data:!0}))),this.e._.hs(),this.e._.vn(),t.has("selection")&&this.e.m.Yu(e.selectedRowIds??[])}wp(e){e.has("sort")&&this.e.emit("sortChanged",{sortModel:this.e.n.Q()}),e.has("filter")&&this.bn(),e.has("pagination")&&this.e.emit("paginationChanged",{page:this.e.i.Lt(),pageSize:this.e.r.paginationPageSize,pageCount:this.e.i.getPageCount(),total:this.e.i.getTotalRowCount()})}setOverlay(e){Vt(this.e,e)}on(e,t){return this.e.ce.on(e,t)}destroy(){this.yt!=null&&clearTimeout(this.yt),this.yt=null;let e=this.ai;this.ai=[];for(let t of e)t.signal&&t.onAbort&&t.signal.removeEventListener("abort",t.onAbort),t.aborted||t.resolve();this.e.destroy()}},ua={rows:Dn,columns:xn,selection:En,editing:Rn,filtering:In,sorting:An,pagination:kn,hierarchy:Ln,view:Gn,state:Sn,io:Pn,diagnostics:Mn};function On(n){let e=new zr(n),t={};for(let[r,i]of Object.entries(ua)){let o;Object.defineProperty(t,r,{enumerable:!0,get:()=>o??(o=Object.freeze(i(e,n)))})}return Object.assign(t,{batch:r=>e.batch(r),whenReady:()=>n.whenReady(),getOption:r=>e.getOption(r),updateOptions:r=>e.updateOptions(r),on:(r,i)=>e.on(r,i),destroy:()=>e.destroy(),isDestroyed:()=>n.s()}),un(t,n),ln(t,{suspend:()=>n.suspend(),resume:()=>t.view.refreshLayout(),canReplaceData:()=>!n.l.isEditing()&&n.V.getDirtyRowIds().length===0,readCell:(r,i)=>{let o=n.i.X(r),s=n.n.k(i);return o&&s?kr(Pe(n,o,s,"clipboard")):""},writeInput:r=>n.di(r.flatMap(({rowId:i,colId:o,value:s})=>{let a=n.i.X(i),l=n.n.k(o);return a&&l?[{node:a,column:l,oldValue:n.d(a,l),newValue:s}]:[]}))}),Object.freeze(t)}var ca={contains:"\u5305\u542B",notContains:"\u4E0D\u5305\u542B",equals:"=",notEquals:"\u2260",startsWith:"\u5F00\u5934",endsWith:"\u7ED3\u5C3E",blank:"\u4E3A\u7A7A",notBlank:"\u975E\u7A7A",lessThan:"<",lessThanOrEqual:"\u2264",greaterThan:">",greaterThanOrEqual:"\u2265",inRange:"\u8303\u56F4"};function _t(n){if(!n)return"";if(n.type==="set")return`\u5DF2\u9009 ${n.values.length} \u9879`;let e=[];for(let r of n.conditions){let i=ca[r.match]??r.match,o=r.value,s="value2"in r?r.value2:void 0;r.match==="blank"||r.match==="notBlank"?e.push(i):r.match==="inRange"&&o!=null?e.push(`${i} ${o}~${s??o}`):o!=null&&String(o)!==""?e.push(`${i} ${o}`):e.push(i)}let t=n.operator==="or"?" \u6216 ":" \u4E14 ";return e.join(t)}function Fn(n,e){let t=0,r=n.length;for(;t<r;){let i=t+r>>1;n[i]<=e?t=i+1:r=i}return t}function ha(n,e){let t=0,r=n.length;for(;t<r;){let i=t+r>>1;n[i]<e?t=i+1:r=i}return t}var ve=class{constructor(){this.pe=new Float64Array(1)}update(e){let t=0,r=this.pe.length!==e.length+1;for(let o=0;o<e.length;o++)t+=e[o].currentWidth,!r&&this.pe[o+1]!==t&&(r=!0);if(!r)return!1;let i=new Float64Array(e.length+1);for(let o=0;o<e.length;o++)i[o+1]=i[o]+e[o].currentWidth;return this.pe=i,!0}Vl(){return this.pe[this.pe.length-1]??0}vt(e){let t=Math.max(0,Math.min(Math.trunc(e),this.pe.length-1));return this.pe[t]??0}Tp(e){let t=Math.max(0,this.pe.length-1);return t===0?-1:Math.min(t-1,Math.max(0,Fn(this.pe,Math.max(0,e))-1))}Bl(e,t,r=2){let i=Math.max(0,this.pe.length-1);if(i===0||t<=0||this.Vl()<=t)return{first:0,lastExcl:i};let o=Math.max(0,e),s=o+t,a=Math.max(0,Fn(this.pe,o)-1),l=Math.min(i,ha(this.pe,s));return{first:Math.max(0,a-r),lastExcl:Math.min(i,l+r)}}};var pa=".mach-header-resize, .mach-filter-btn, .mach-menu-btn, .mach-select-all";function Wr(n){return n instanceof HTMLElement&&n.closest(pa)!=null}function $r(n){return n==="ArrowLeft"||n==="ArrowRight"}function Hn(n,e){typeof e=="string"?n.classList.add(e):Array.isArray(e)&&n.classList.add(...e)}var zt=class{constructor(e){this.e=e;this.Ie=[];this.ps=[];this.N=new ve;this.Wt=0;this.En=Number.MAX_SAFE_INTEGER}li(){this._l(),this.e.ci.Ot(),this.xr(!1);let e=this.e.n,t=e.Jd();this.e.o.Rl(t);let r=new Set(e.w("center").slice(this.Wt,this.En)),i=(l,d,u)=>{let c=[];for(let h of l)if(h instanceof X){let p=i(h.children,d+1,u);p.length>0&&c.push({group:h,level:d,children:p})}else!h.hide&&e.We(h)===u&&(u!=="center"||r.has(h))&&c.push({column:h,level:d,children:[]});return c},o=e.Xd(),s=b.map(l=>i(o,0,l)),a=this.e.r.headerHeight;b.forEach((l,d)=>{let u=this.e.o.ni[l];for(let h of u)h.textContent="";let c=h=>{let p=u[Math.min(h.level,u.length-1)];if(h.column){let m=this.Dp(h.column,t-h.level,a);p.appendChild(m.el),this.Ie.push(m)}else if(h.group){let m=this.xp(h.group);p.appendChild(m),this.ps.push({group:h.group,el:m})}for(let m of h.children)c(m)};for(let h of s[d])c(h)}),this.e.r.suppressHeaderFocus||this.Ie.forEach((l,d)=>{l.el.tabIndex=d===0?0:-1}),this.bt(),this.hs(),this.vn(),this.zi()}zl(){let e=this.Wt,t=this.En;this._l(),(e!==this.Wt||t!==this.En)&&this.li()}_l(){let e=this.e.n.w("center"),t=this.e.o.M.center;this.N.update(e);let r=e.length>20?this.N.Bl(t.scrollLeft,t.clientWidth,2):{first:0,lastExcl:e.length};this.Wt=r.first,this.En=r.lastExcl}Dp(e,t,r){let i=f("div","mach-header-cell mach-header-cell--leaf");e.hasCheckbox&&i.classList.add("mach-header-cell--selection"),i.dataset.colId=e.id,i.setAttribute("role","columnheader"),i.style.height=`${t*r}px`,this.Ep(i,e),this.Rp(i,e);let o=this.Sp(i,e);this.Mp(i,e);let s=f("span","mach-sort-indicator");i.appendChild(s);let{filterBtn:a,filterTagEl:l}=this.Ip(i,e);return this.Ap(i,e),this.kp(i,e),this.Lp(i,e),{column:e,el:i,sortEl:s,filterBtn:a,filterTagEl:l,selectAllEl:o}}Ep(e,t){let r=t.colDef;Hn(e,r.headerClass),r.headerTooltip&&e.setAttribute("title",r.headerTooltip);let i=r.headerAlign??r.align;i==="center"?e.classList.add("mach-header-cell--center"):i==="right"&&e.classList.add("mach-header-cell--right")}Rp(e,t){this.e.r.suppressHeaderFocus||(e.tabIndex=-1,e.addEventListener("mousedown",()=>this.fs(t)),e.addEventListener("keydown",r=>this.Gp(r,t)))}Sp(e,t){if(!t.hasCheckbox||this.e.r.rowSelection!=="multiple")return;let r=document.createElement("input");return r.type="checkbox",r.className="mach-select-all",r.setAttribute("aria-label","select all rows"),r.addEventListener("click",i=>i.stopPropagation()),r.addEventListener("change",()=>{r.checked?this.e.m.selectAll(!0):this.e.m.deselectAll()}),e.appendChild(r),r}Mp(e,t){let r=t.colDef,i=r.headerComponent,o;if(!i){this.ms(e,r.headerName??r.field??t.id);return}try{o=i({colDef:r,column:t,api:this.e.api})}catch(s){this.e.reportError(s,"headerComponent",{colId:t.id}),o=null}this.Pp(e,t,o)}Pp(e,t,r){if(typeof r=="string"){this.ms(e,r);return}if(r instanceof HTMLElement){this.Wl(e,r);return}if(r&&typeof r=="object"&&r.el instanceof HTMLElement){this.Wl(e,r.el),ni(e,r.destroy);return}let i=t.colDef;this.ms(e,i.headerName??i.field??t.id)}ms(e,t){let r=f("span","mach-header-label");r.textContent=t,e.appendChild(r)}Wl(e,t){let r=f("span","mach-header-label mach-header-label--custom");r.appendChild(t),e.appendChild(r)}Ip(e,t){if(!t.filterable)return{};let r=document.createElement("button");r.type="button",r.className="mach-filter-btn",r.setAttribute("aria-label",`filter ${t.id}`),r.innerHTML=di,r.addEventListener("click",o=>{o.stopPropagation(),this.e.gs.toggle(t,r)}),e.appendChild(r);let i=f("span","mach-filter-tag");return e.appendChild(i),{filterBtn:r,filterTagEl:i}}Ap(e,t){if(!this.e.r.columnMenu||t.hasCheckbox||t.colDef.suppressColumnMenu)return;let r=document.createElement("button");r.type="button",r.className="mach-menu-btn";let o=`${t.colDef.headerName??t.colDef.field??t.id} \xB7 ${this.e.T("columnSettings")}`;r.setAttribute("aria-label",o),r.title=o,r.innerHTML=hi,r.addEventListener("click",s=>{s.stopPropagation(),this.e.columnMenu.toggle(t,r)}),e.appendChild(r)}kp(e,t){if(!this.$l(t))return;let r=f("div","mach-header-resize");r.setAttribute("aria-hidden","true"),r.addEventListener("pointerdown",i=>{i.button===0&&(i.preventDefault(),i.stopPropagation(),this.e.ci.ac(i,t))}),r.addEventListener("dblclick",i=>{i.stopPropagation(),this.e.api.columns.autoSize(t.id)}),r.addEventListener("click",i=>i.stopPropagation()),e.appendChild(r)}Lp(e,t){e.addEventListener("click",r=>{this.e.Rn.hc()||Wr(r.target)||t.sortable&&this.e.Ii(t,r.shiftKey)}),e.addEventListener("pointerdown",r=>{r.button!==0||Wr(r.target)||this.e.Rn.cc(r,t)})}xp(e){let t=f("div","mach-header-cell mach-header-cell--group");e.groupId&&(t.dataset.groupId=e.groupId),t.setAttribute("role","columnheader"),Hn(t,e.def.headerClass);let r=f("span","mach-header-label mach-header-label--group");return r.textContent=e.headerName,t.appendChild(r),t}bt(){let e={left:0,center:0,right:0};for(let t of b){let r=this.e.o.ni[t],i=0,o=new Map;for(let a of this.e.n.w(t))o.set(a.id,i),i+=a.currentWidth;let s=this.e.r.headerHeight;for(let a of this.Ie){if(this.e.n.We(a.column)!==t)continue;let l=o.get(a.column.id)??0;a.el.style.width=`${a.column.currentWidth}px`,a.el.style.left=`${l}px`,a.el.setAttribute("aria-colindex",String(this.e.n.ze(a.column.id)+1))}for(let a of this.ps){let l=this.Np(a.group,t);if(l.length===0)continue;let d=o.get(l[0].id)??0,u=0;for(let c of l)u+=c.currentWidth;a.el.style.left=`${d}px`,a.el.style.width=`${u}px`,a.el.style.height=`${s}px`,a.el.setAttribute("aria-colspan",String(l.length))}for(let a of r)a.style.width=`${i}px`;e[t]=i}this.e.o.gh(e.left,e.right)}Np(e,t){return e.getLeafColumns().filter(r=>!r.hide&&this.e.n.We(r)===t)}Gp(e,t){this.e.s()||this.Op(e,t)||this.Fp(e,t)||this.Hp(e,t)||this.Vp(e,t)||this.Bp(e)}Op(e,t){return e.key!=="Enter"&&e.key!==" "?!1:(Wr(e.target)||(e.preventDefault(),t.sortable&&this.e.Ii(t,e.shiftKey)),!0)}Fp(e,t){if(!e.altKey||!$r(e.key))return!1;if(!this.$l(t))return!0;let r=e.key==="ArrowRight"?24:-24;return this.e.n.Ae(t,t.currentWidth+r),this.e.je(),this.e.hr([t]),e.preventDefault(),!0}Hp(e,t){if(!e.ctrlKey||!$r(e.key))return!1;if(!t.movable)return!0;e.preventDefault();let r=this.e.n.We(t),i=this.e.n.w(r),o=i.indexOf(t),s=e.key==="ArrowRight"?1:-1,a=Math.max(0,Math.min(i.length-1,o+s));return a!==o&&this.e.Nr(t.id,a),!0}Vp(e,t){if(e.altKey||e.ctrlKey||e.metaKey||!$r(e.key))return!1;e.preventDefault();let r=this.e.n.u(),i=r.indexOf(t);if(i<0)return!0;let o=e.key==="ArrowRight"?1:-1,s=Math.max(0,Math.min(r.length-1,i+o));return this.fs(r[s]),!0}Bp(e){if(e.key!=="Home"&&e.key!=="End")return!1;e.preventDefault();let t=this.e.n.u();if(t.length===0)return!0;let r=e.key==="Home"?0:t.length-1;return this.fs(t[r]),!0}fs(e){let t=this.Ie.find(r=>r.column.id===e.id);if(!t&&!e.pinned&&(this._p(e),this.zl(),t=this.Ie.find(r=>r.column.id===e.id)),!!t){for(let r of this.Ie)r.el.tabIndex=r===t?0:-1;t.el.focus({preventScroll:!0})}}_p(e){let t=this.e.n.w("center"),r=t.indexOf(e);if(r<0)return;let i=this.e.o.M.center;this.N.update(t);let o=this.N.vt(r),s=o+e.currentWidth;o<i.scrollLeft?i.scrollLeft=o:s>i.scrollLeft+i.clientWidth&&(i.scrollLeft=s-i.clientWidth)}$l(e){return this.e.r.enableColumnResize&&e.resizable}hs(){let e=this.e.n.Q(),t=e.length>1;for(let r of this.Ie){let i=e.findIndex(o=>o.colId===r.column.id);if(i>=0){let o=e[i].direction,s=t?`<span class="mach-sort-badge">${i+1}</span>`:"";r.sortEl.innerHTML=(o==="asc"?ui:ci)+s,r.el.setAttribute("aria-sort",o==="asc"?"ascending":"descending"),r.el.classList.add("mach-header-cell--sorted")}else r.sortEl.innerHTML="",r.el.removeAttribute("aria-sort"),r.el.classList.remove("mach-header-cell--sorted")}}vn(){let e=this.e.i.De();for(let t of this.Ie){if(!t.filterBtn)continue;let r=e[t.column.id],i=r!=null;if(t.filterBtn.classList.toggle("mach-filter-btn--active",i),t.filterTagEl){let o=i?_t(r):"";t.filterTagEl.style.display=o?"":"none",o&&(t.filterTagEl.textContent=o)}}}zi(){for(let e of this.Ie)e.selectAllEl&&(e.selectAllEl.checked=this.e.m.ec(),e.selectAllEl.indeterminate=this.e.m.tc())}destroy(){this.xr(!0)}xr(e){for(let t of this.Ie){let r=oi(t.el);if(r)try{r()}catch(i){e?console.error("[mach-table] headerComponent destroy error",i):this.e.reportError(i,"headerComponent.destroy",{colId:t.column.id})}}this.Ie=[],this.ps=[]}};var Wt=class{constructor(){this.fe=null;this.Je=null;this.Er=!1;this.ys=-1;this.vs=-1}zp(){return this.fe}bs(){return this.Je}Wp(){return this.fe!=null}start(e,t){(!t||!this.fe)&&(this.fe={...e}),this.Je={...e},this.rr()}$p(e){return this.fe?!0:e.colIdx<0?!1:(this.fe={...e},this.rr(),!0)}setEnd(e){this.Je={...e},this.rr()}clear(){this.fe=null,this.Je=null,this.rr()}rr(){this.Er=!1,this.ys=-1,this.vs=-1}normalize(e,t){return this.Er!==!1&&this.ys===e&&this.vs===t?this.Er:(this.ys=e,this.vs=t,!this.fe||!this.Je||e<=0||t<=0?(this.Er=null,null):(this.Er={r1:Math.max(0,Math.min(this.fe.row,this.Je.row,e-1)),r2:Math.max(0,Math.min(Math.max(this.fe.row,this.Je.row),e-1)),c1:Math.max(0,Math.min(this.fe.colIdx,this.Je.colIdx,t-1)),c2:Math.max(0,Math.min(Math.max(this.fe.colIdx,this.Je.colIdx),t-1))},this.Er))}};var $t=class{constructor(e){this.host=e;this.He=null;this.se=0;this.Sn=0;this.dt=e=>{let t=this.He;if(!(!t||e.pointerId!==t.pointerId)){if(t.clientX=e.clientX,t.clientY=e.clientY,!t.active){if(Math.abs(e.clientY-t.startY)<5)return;t.active=!0,this.host.root.classList.add("mach-root--row-dragging"),this.host.root.querySelectorAll(".mach-row").forEach(r=>r.classList.toggle("mach-row--drag-source",this.sourceContains(r.dataset.id??"")))}this.Ul()}};this.jp=()=>{if(this.se=0,!!this.He?.active){if(!this.current()){this.destroy();return}this.qr(),this.qp()&&this.Ul()}};this.Pe=e=>{let t=this.He;if(!(!t||e.pointerId!==t.pointerId)){t.clientX=e.clientX,t.clientY=e.clientY,t.active&&this.current()&&this.qr(),this.jl();try{t.active&&t.drop?.valid&&this.ws(e.clientX,e.clientY)&&this.current()&&this.commitDrop(t.drop)}finally{this.release()}}};this.Kl=e=>{e.key==="Escape"&&(e.preventDefault(),this.destroy())};this.Ft=e=>{e.type==="pointercancel"&&e.pointerId!==this.He?.pointerId||this.destroy()}}begin(e){let t=this.host.containers.map(i=>{let o=f("div","mach-row-drop-indicator");return o.hidden=!0,i.append(o),o}),r=f("div","mach-row-drag-preview");r.setAttribute("role","status"),r.hidden=!0,this.host.root.append(r),this.He={startY:e.clientY,clientX:e.clientX,clientY:e.clientY,pointerId:e.pointerId,indicators:t,preview:r,drop:null,active:!1},window.addEventListener("pointermove",this.dt),window.addEventListener("pointerup",this.Pe),window.addEventListener("pointercancel",this.Ft),window.addEventListener("keydown",this.Kl),window.addEventListener("blur",this.Ft)}Kp(e){return this.He?.active===!0&&this.sourceContains(e)}Up(e,t=()=>!0){this.Sn=requestAnimationFrame(()=>{this.Sn=0,t()&&[...this.host.root.querySelectorAll(".mach-row-drag-handle")].find(r=>r.closest(".mach-row")?.dataset.id===e)?.focus()})}Ul(){this.se||(this.se=requestAnimationFrame(this.jp))}ws(e,t,r=0){let i=this.host.body.getBoundingClientRect();return e>=i.left&&e<=i.right&&t>=i.top-r&&t<=i.bottom+r}qp(){let e=this.He;if(!e||!this.ws(e.clientX,e.clientY,28))return!1;let t=this.host.viewport,r=t.getBoundingClientRect(),i=Math.min(36,r.height/3);if(i<=0)return!1;let o=e.clientY<r.top+i?-Math.ceil(14*w((r.top+i-e.clientY)/i,0,1)):Math.ceil(14*w((e.clientY-r.bottom+i)/i,0,1));if(this.host.scrollBy)return this.host.scrollBy(o);let s=t.scrollTop;return t.scrollTop=w(s+o,0,Math.max(0,t.scrollHeight-t.clientHeight)),t.scrollTop!==s}qr(){let e=this.He;if(!e?.active)return;let t=e.clientY-this.host.viewport.getBoundingClientRect().top+this.host.viewport.scrollTop,r=this.describe(t);e.drop=r;let i=this.ws(e.clientX,e.clientY);for(let s of e.indicators){if(s.hidden=!i||!r?.valid,!r)continue;s.dataset.dropPosition=r.position??"",s.style.cssText=r.style??"";let a=parseFloat(s.parentElement.style.height),l=Math.min(this.host.getRowTop(r.boundary),Number.isFinite(a)?Math.max(0,a-2):1/0);s.style.transform=`translate3d(0, ${l}px, 0)`}let o=this.host.root.getBoundingClientRect();e.preview.hidden=!1,e.preview.textContent=i?r?.text??this.outsideText():this.outsideText(),e.preview.style.transform=`translate3d(${w(e.clientX-o.left+16,8,Math.max(8,o.width-224))}px, ${w(e.clientY-o.top+16,8,Math.max(8,o.height-48))}px, 0)`}jl(){let e=this.He;this.He=null,window.removeEventListener("pointermove",this.dt),window.removeEventListener("pointerup",this.Pe),window.removeEventListener("pointercancel",this.Ft),window.removeEventListener("keydown",this.Kl),window.removeEventListener("blur",this.Ft),cancelAnimationFrame(this.se),this.se=0,this.host.root?.classList.remove("mach-root--row-dragging"),this.host.root?.querySelectorAll(".mach-row--drag-source").forEach(t=>t.classList.remove("mach-row--drag-source")),e?.indicators.forEach(t=>t.remove()),e?.preview.remove()}destroy(){this.jl(),this.release(),cancelAnimationFrame(this.Sn),this.Sn=0}};function Vn(n,e,t,r,i){let o=r==="before"?-1:1,s=t.rowIndex+o,a=e(s);for(;a&&(a===n||a.isDetail);)s+=o,a=e(s);let l=a&&!a.loading?a.id:null;return{rowIds:[n.id],targetId:t.id,position:r,beforeId:r==="before"?l:t.id,afterId:r==="before"?t.id:l,expectedRevision:i}}var Kt=class extends $t{constructor(t,r,i,o){super({get root(){return t.o.root},get body(){return t.o.Fe},get viewport(){return t.o.M.center},get containers(){return Object.values(t.o.Se)},getRowTop:r,findRowAt:i,scrollBy:o});this.e=t;this.$t=null}Yl(t){return!t.loading&&!t.treeLoading&&!t.isGroup}Xl(t){if(this.e.l.isEditing()||t.isDetail||!this.Yl(t)||t.data==null||this.e.n.Qe().length||this.e.r.applyRowDrag&&!this.e.i.Ga())return!1;let r=this.Rr("canDrag",()=>this.e.r.rowDragPolicy?.canDrag?.({node:t,api:this.e.api})??!0,!1);return r!==!0?r:!this.e.i.O||!!Or(this.e.api)}canDrag(t){return this.Xl(t)===!0}isSource(t){return this.Cs()?.isSource(t)??this.Kp(t.id)}start(t,r){if(this.destroy(),!this.canDrag(r)||t.isPrimary===!1)return;let i=this.Cs();if(i){i.start(t,r);return}let o=this.Rr("getRevision",()=>this.Ts(r),null);o&&(this.$t={node:r,from:r.rowIndex,guard:o},this.begin(t))}moveWithKeyboard(t,r){if(!t.altKey||t.key!=="ArrowUp"&&t.key!=="ArrowDown"||(t.preventDefault(),t.stopPropagation(),!this.canDrag(r)))return;let i=this.Cs();if(i){i.moveWithKeyboard(t,r);return}let o=t.key==="ArrowUp"?-1:1,s=r.rowIndex+o;for(;this.e.i.f(s)?.isDetail;)s+=o;let a=this.e.i.f(s),l=this.Rr("getRevision",()=>this.Ts(r),null);if(!(!a||!l)){this.$t={node:r,from:r.rowIndex,guard:l};try{this.commitDrop(this.destination(a,o>0))&&this.Up(r.id)}finally{this.release()}}}Rr(t,r,i){try{return r()}catch(o){return this.e.reportError(o,`rowDragPolicy.${t}`),i}}Ts(t){let r=this.e.i,i=this.e.n.Z(),o=this.e.r.rowDragPolicy,s=r.zr(),a=r.ho(),l=this.e.r.applyRowDrag,d=o?.getRevision?.();return{revision:d,current:()=>this.Rr("getRevision",()=>o?.getRevision?.()===d&&s===r.zr()&&a===r.ho()&&r.X(t.id)===t&&i===this.e.n.Z()&&o===this.e.r.rowDragPolicy&&l===this.e.r.applyRowDrag,!1)}}Cs(){let t=Or(this.e.api);return t!==this.ql&&(this.Mn?.destroy(),this.ql=t,this.Mn=t?this.Rr("driver",()=>t({...this.host,api:this.e.api,capture:r=>this.Ts(r),emit:(r,i,o,s,a)=>{this.e.emit("rowDragEnd",{rowNode:r,fromIndex:i,toIndex:o,targetIndex:s,applied:!1,intent:a})},report:(r,i)=>this.e.reportError(r,`rowDragPolicy.${i}`)}),void 0):void 0),this.Mn}current(){return this.$t?.guard.current()??!1}release(){this.$t=null}sourceContains(t){return this.$t?.node.id===t}outsideText(){return this.e.r.locale.rowDragOutside??D.rowDragOutside}describe(t){let r=w(this.host.findRowAt(t),0,this.e.i.P()-1),i=this.e.i.f(r);if(i?.isDetail&&(i=this.e.i.X(i.masterId)),!i)return null;let o=this.host.getRowTop(i.rowIndex),s=this.host.getRowTop(i.rowIndex+1);return this.destination(i,t>=(o+s)/2)}destination(t,r){let i=this.$t,o=t.rowIndex+Number(r);for(;this.e.i.f(o)?.isDetail;)o++;let s=this.e.r.rowDragPolicy,a=!this.e.r.applyRowDrag||s?.canDrop?Vn(i.node,c=>this.e.i.f(c),t,r?"after":"before",i.guard.revision):void 0,l=s?.canDrop&&a?this.Rr("canDrop",()=>s.canDrop({node:i.node,api:this.e.api,targetNode:t,intent:a}),!1):!0,d=l===!0&&this.Yl(t),u=typeof l=="string"?l:fe(this.e.r.locale.rowDragPosition??D.rowDragPosition,i.from+1,this.Jl(i.from,o)+1);return{node:t,intent:a,boundary:o,valid:d,text:u,position:r?"after":"before"}}commitDrop(t){let r=this.$t;if(!r||!this.current()||!this.canDrag(r.node)||!this.current())return!1;let i=this.destination(t.node,t.boundary>t.node.rowIndex);if(!i.valid||!this.current())return!1;let o=i.boundary>r.from?i.boundary-1:i.boundary;for(;this.e.i.f(o)?.isDetail;)o--;if(r.from===o)return!1;let s=this.e.r.applyRowDrag&&this.e.i.Pa(r.from,o);return this.e.r.applyRowDrag&&!s?!1:(this.e.emit("rowDragEnd",{rowNode:r.node,fromIndex:r.from,toIndex:i.boundary,targetIndex:s?r.node.rowIndex:this.Jl(r.from,i.boundary),applied:s,intent:i.intent}),!0)}Jl(t,r){let i=t+1;for(;this.e.i.f(i)?.isDetail;)i++;return r>t?r-(i-t):r}destroy(){this.Mn?.destroy(),super.destroy()}};var fa=new Set(["warning","danger","success","info"]);function He(n,e,t=null){if(!(e.data==null||e.isGroup||e.isDetail||e.loading))for(let r of n.r.rowStyleRules)try{if(r.when({data:e.data,node:e,api:n.api,rowPinned:t})===!0)return r}catch(i){n.reportError(i,"rowStyleRules",{rowId:e.id})}}function be(n,e){n.style.removeProperty("--mach-row-rule-bg"),n.style.removeProperty("--mach-row-rule-fg"),e?.tone&&fa.has(e.tone)?n.dataset.rowTone=e.tone:delete n.dataset.rowTone,e?.backgroundColor&&n.style.setProperty("--mach-row-rule-bg",e.backgroundColor),e?.color&&n.style.setProperty("--mach-row-rule-fg",e.color),n.classList.toggle("mach-row--styled",!!e)}var Ut=class{constructor(){this.ie=new Float64Array(0);this.Sr=new Float64Array(1);this.Ds=new WeakMap;this.Kt=new Map;this.wt=0}reset(e,t){this.ie=new Float64Array(e.length),this.Sr=new Float64Array(e.length+1),this.Ds=new WeakMap,this.Kt=new Map,this.wt=0;for(let r=0;r<e.length;r++){this.Ds.set(e[r],r);let i=Math.max(1,t(e[r],r));this.ie[r]=i,this.xs(i,1),this.add(r,i)}}get length(){return this.ie.length}indexOf(e){return this.Ds.get(e)??-1}update(e,t){if(e<0||e>=this.ie.length)return!1;let r=Math.max(1,t),i=r-this.ie[e];return Math.abs(i)<.01?!1:(this.xs(this.ie[e],-1),this.ie[e]=r,this.xs(r,1),this.add(e,i),!0)}vt(e){let t=Math.max(0,Math.min(Math.trunc(e),this.ie.length)),r=0;for(;t>0;)r+=this.Sr[t],t-=t&-t;return r}Es(){return this.vt(this.ie.length)}Yp(){return this.wt}findIndex(e){if(this.ie.length===0)return 0;let t=Math.max(0,e),r=0,i=0,o=1;for(;o<<1<=this.ie.length;)o<<=1;for(;o>0;){let s=r+o;s<=this.ie.length&&i+this.Sr[s]<=t&&(r=s,i+=this.Sr[s]),o>>=1}return Math.min(r,this.ie.length-1)}add(e,t){for(let r=e+1;r<this.Sr.length;r+=r&-r)this.Sr[r]+=t}xs(e,t){let r=(this.Kt.get(e)??0)+t;if(r<=0?this.Kt.delete(e):this.Kt.set(e,r),this.Kt.size===0)this.wt=0;else if(t>0&&(this.wt===0||e<this.wt))this.wt=e;else if(t<0&&e===this.wt&&!this.Kt.has(e)){let i=Number.POSITIVE_INFINITY;for(let o of this.Kt.keys())i=Math.min(i,o);this.wt=Number.isFinite(i)?i:0}}};var ma=16e6,jt=class{constructor(){this.height=0;this.Ut=0;this.Mr=0;this.In=NaN;this.Rs=0}configure(e,t,r=!0){this.height=r?Math.min(e,ma):e,this.Ut=Math.max(0,e-t),this.Mr=Math.max(0,this.height-t),this.In=NaN}get Ct(){return this.Ut>this.Mr}Xp(e){return this.Ut?w(e,0,this.Ut)*this.Mr/this.Ut:0}read(e){return e!==this.In&&(this.In=e,this.Rs=this.Mr>0?w(e,0,this.Mr)*this.Ut/this.Mr:0),this.Rs}anchor(e,t){this.Rs=w(e,0,this.Ut),this.In=t}};function Bn(n){return!!n&&!n.hasCheckbox&&!n.isDetailToggle&&!n.colDef.rowDrag}function _n(n){let e=n.length>1&&n.every(i=>typeof i=="number"&&!Number.isNaN(i)),t=e?(n[n.length-1]-n[0])/(n.length-1):0,r=!e||n.every(i=>Number.isInteger(i));return{difference:t,integer:r,numeric:e,values:n}}function zn(n,e){let t=n.values.length;if(t===1)return n.values[0];if(!n.numeric)return n.values[e%t];let r=n.values[t-1]+n.difference*(e-t+1);return n.integer?Math.round(r):Math.round(r*1e6)/1e6}var qt=class{constructor(e){this.e=e;this.$=[];this.Tt=0;this.Ze=0;this.Ve=-1;this.re=0;this.Ss=0;this.Ms=0;this.Zl=0;this.I=new jt;this.Dt=0;this.Is=!1;this.An=-1;this.j=new Ut;this.N=new ve;this.me=new Wt;this.kn=!1;this.hi=[];this.Wt=0;this.D=null;this.ks=()=>{this.re||(this.re=requestAnimationFrame(()=>{this.re=0,this.wn()}))};this.On=0;this.Fn=new WeakMap;this.qt=new Set;this.Hn="";this.pi=[];this.Gs=null;this.Ls=e=>{if(e.defaultPrevented||e.ctrlKey||e.metaKey||e.shiftKey||!e.deltaY||!e.cancelable)return;let t=this.e.o.M.center,r=e.deltaMode===1?this.e.r.rowHeight:e.deltaMode===2?t.clientHeight:1,i=this.I.read(t.scrollTop);this.Vn(i+e.deltaY*r),this.I.read(t.scrollTop)!==i&&(e.preventDefault(),t.scrollLeft+=e.deltaX*r,this.ks())};this.Pn=null;this.mi=null;this._s=!1;this.Xf=e=>{let t=this.mi;if(!t)return;let r=e;if(typeof r.clientX!="number")return;if(!t.active){let o=Math.abs(r.clientX-t.startX),s=Math.abs(r.clientY-t.startY);if(o<4&&s<4)return;t.active=!0,t.axis=o>=s?"h":"v",this.e.o.root.classList.add("mach-root--filling")}let i=t.axis!=="v";this.Dd(i,i?Math.max(t.c2+1,this.Td(r)):this.Cd(r),!0)};this.Jf=e=>{let t=this.mi;if(!t)return;let r=e;if(!t.active){this.Gn();return}let i=t.axis==="h",o=i?t.c2:t.r2,s=o;i?s=Math.max(o+1,typeof r.clientX=="number"?this.Td(r):o+1):typeof r.clientY=="number"&&(s=this.Cd(r)),this.Gn(),s>o?(this.Zf(t,s,i),this.xt()):this.Dd(i,o,!1)};this.Zp=e=>{if(this.e.s())return;let t=e.target,r=this.Jt(e);if(r&&!t.closest(".mach-cell-editor-shell, .mach-row-editor-shell, .mach-row-drag-handle")&&!(e.detail>1&&this.e.l.Zi())){if(this.e.l.Zi()){let i=r.cellEl?.dataset.colId??"";if(this.e.l.isEditing(r.index,i))return;this.e.l.de(!1).then(o=>{if(!o||this.e.s())return;this.Rd(e,t,r);let s=i?this.e.n.k(i):void 0;s&&!this.e.l.Zi()&&this.e.l.U(r.node,s)&&this.e.l.start(r.index,s)});return}this.Rd(e,t,r)}};this.Qp=e=>{if(this.e.s()||e.target.closest(".mach-cell-editor-shell, .mach-row-editor-shell"))return;let t=this.Jt(e);if(!t)return;let{node:r,index:i,cellEl:o}=t;if(r.isDetail||r.isGroup||!o)return;let s=o.dataset.colId??"",a=this.e.n.k(s);if(!a)return;let l=this.e.d(r,a),d=this.e.emit("cellDoubleClicked",{event:e,rowNode:r,rowIndex:i,column:a,colDef:a.colDef,value:l});a.colDef.onCellDoubleClick?.(d),this.e.emit("rowDoubleClicked",{event:e,rowNode:r,rowIndex:i}),this.e.l.U(r,a)&&this.e.l.start(i,a)};this.ef=e=>{if(this.e.s())return;let t=this.Jt(e);if(!t||t.node.isDetail||t.node.isGroup||!t.cellEl)return;let{node:r,index:i,cellEl:o}=t,s=o.dataset.colId??"",a=this.e.n.k(s);if(a&&(this.e.emit("cellContextMenu",{event:e,rowNode:r,rowIndex:i,column:a,colDef:a.colDef,value:this.e.d(r,a)}),this.e.r.contextMenu)){if(e.preventDefault(),this.e.r.enableRangeSelection&&!this.Ne()){let l=this.e.n.ze(s);l>=0&&this.Bs(i,l,!1)}this.e.zs.open(e.clientX,e.clientY,{rowIndex:i,colId:s})}};this.tf=e=>{if(!this.dm(e)&&this.e.r.enableRangeSelection&&e.button===0){let t=this.Jt(e);if(t&&!t.node.isDetail&&!t.node.isGroup&&t.cellEl&&!t.cellEl.classList.contains("mach-cell--selection")){let r=this.e.n.ze(t.cellEl.dataset.colId??"");r>=0&&(this.Bs(t.index,r,e.shiftKey),this.kn=!0,!e.shiftKey&&!this.e.r.suppressCellFocus&&this.Oe(t.index,t.cellEl.dataset.colId??""))}}};this.ed=()=>{this.kn=!1};this.sn=e=>{if(this.e.s())return;let t=this.Jt(e);if(this.kn&&t&&!t.node.isDetail&&!t.node.isGroup&&t.cellEl){let r=this.e.n.ze(t.cellEl.dataset.colId??""),i=this.me.bs();r>=0&&i&&(i.row!==t.index||i.colIdx!==r)&&this.Bs(t.index,r,!0)}this.e.r.suppressRowHoverHighlight||!t||t.node.isDetail||this.xd(t.index)};this.rf=()=>{this.xd(-1)};this.nf=e=>{if(this.e.s()||e.button!==0||!e.target.closest(".mach-row-drag-handle"))return;let r=this.Jt(e);!r||r.node.isDetail||r.node.isGroup||(this.jt.start(e,r.node),e.preventDefault())};this.of=e=>{if(!e.target.closest(".mach-row-drag-handle"))return;let t=this.Jt(e);t&&this.jt.moveWithKeyboard(e,t.node)};this.jt=new Kt(e,t=>this.Be(t)-this.Dt,t=>this.Ln(t+this.Dt,this.e.i.P()),t=>this.Jp(t))}init(){let e=this.e.o.M.center;this.Ss=e.scrollLeft,this.Ms=e.scrollTop,e.addEventListener("scroll",this.ks,{passive:!0}),this.Ql(!0),window.addEventListener("mouseup",this.ed)}Ql(e){let t=this.e.o.Fe,r=e?"addEventListener":"removeEventListener",i={click:this.Zp,dblclick:this.Qp,contextmenu:this.ef,mousedown:this.tf,mouseover:this.sn,mouseleave:this.rf,pointerdown:this.nf,keydown:this.of};for(let[o,s]of Object.entries(i))t[r](o,s)}suspend(){cancelAnimationFrame(this.re),this.re=0,this.Gn(),this.jt.destroy(),this.kn=!1}destroy(){cancelAnimationFrame(this.re);let e=this.e.o.M.center;e.removeEventListener("scroll",this.ks),e.removeEventListener("wheel",this.Ls),this.Ql(!1),window.removeEventListener("mouseup",this.ed),this.Gn(),this.jt.destroy(),this.td(!1),this.Pn?.remove(),this.pi=[],this.qt.clear(),this.j.reset([],()=>this.e.r.rowHeight),this.N.update([]),this.Gs=null}Mo(e){return this.e.n.We(e)}wn(e=!1){if(this.e.s())return;let t=this.e.o,r=t.M.center,i=r.scrollLeft,o=r.scrollTop,s=this.I.read(o),a=e||i!==this.Ss,l=e||o!==this.Ms||s!==this.Zl;!a&&!l||(this.Ss=i,this.Ms=o,this.Zl=s,a&&(t.fr.center.style.transform=`translate3d(${-i}px, 0, 0)`,this.e._.zl(),this.e.he.sf(i)),l&&this.rd(o),this.e.Nn.hide(),this.ui(!1,a),l&&this.e.i.uu(this.Ve-1))}af(){let e={left:0,center:0,right:0};for(let t of b)e[t]=this.e.n.w(t).reduce((r,i)=>r+i.currentWidth,0);return e}Cn(){let e=this.e.o,t=this.af();this.N.update(this.e.n.w("center")),t.center=this.N.Vl();let r=this.e.i.st(),i=this.lf(r.length);this.df(r,i);let o=this.uf(i);this.cf(t,o),this.hf(o),e.root.setAttribute("aria-rowcount",String(i.rowCount+e.Il()))}lf(e){let t=this.e.i.or(),r=this.e.r.rowHeight,i=this.e.r.masterDetail?[]:this.pf(),o=this.e.r.datasourceMode!=="block"&&(this.e.r.masterDetail||this.e.r.getRowHeight!=null||i.length>0),s=o?this.ff(r,i):`fixed|${r}`;return{autoHeightColumns:i,positionedCount:Math.min(t,e),rowCount:t,rowHeight:r,signature:s,variable:o}}ff(e,t){let r=t.map(i=>`${i.id}:${i.currentWidth}`).join(",");return`${this.e.i.ho()}|${e}|${this.e.r.detailRowHeight}|${r}`}df(e,t){if(!t.variable){this.mf(t);return}if(t.signature!==this.Hn||this.j.length!==t.positionedCount){let r=e.slice(0,t.positionedCount);this.j.reset(r,i=>this.nd(i,t.autoHeightColumns)),this.od(t);return}if(this.qt.size!==0){for(let r of this.qt){let i=this.j.indexOf(r);i>=0&&this.j.update(i,this.nd(r,t.autoHeightColumns))}this.od(t)}}mf(e){this.j.length>0&&this.j.reset([],()=>e.rowHeight),this.Hn=e.signature,this.qt.clear(),this.On=e.rowHeight}od(e){this.Hn=e.signature,this.qt.clear(),this.On=this.j.Yp()||e.rowHeight}uf(e){return(e.variable?this.j.Es():e.positionedCount*e.rowHeight)+Math.max(0,e.rowCount-e.positionedCount)*e.rowHeight}cf(e,t){let r=this.e.o,i=r.M.center,o=this.I.read(i.scrollTop),s=this.I.Ct;this.I.configure(t,i.clientHeight,this.e.r.domLayout!=="autoHeight");let a=Math.max(0,i.clientWidth-e.left-e.right),l=Math.max(e.center,a);for(let d of b){let u=r.Se[d];u.style.height=`${this.I.height}px`,u.style.overflow=this.I.Ct?"hidden":"",d==="center"&&(u.style.width=`${l}px`)}(s||this.I.Ct)&&this.Vn(o),this.rd(i.scrollTop),this.Is!==this.I.Ct&&(this.Is=this.I.Ct,this.Is?i.addEventListener("wheel",this.Ls,{passive:!1}):i.removeEventListener("wheel",this.Ls))}Vn(e){let t=this.e.o.M.center;t.scrollTop=this.I.Xp(e),this.I.anchor(e,t.scrollTop)}rd(e){let t=this.I.Ct;for(let r of["left","right"]){let i=this.e.o.Se[r].style;i.top=t?`${-e}px`:"",i.transform=t?"":`translate3d(0, ${-e}px, 0)`}}Jp(e){let t=this.e.o.M.center,r=this.I.read(t.scrollTop);this.Vn(r+e);let i=this.I.read(t.scrollTop)!==r;return i&&this.wn(),i}Wi(e){this.Fn.delete(e),this.qt.add(e)}hf(e){this.e.o.Fe.style.height=this.e.r.domLayout==="autoHeight"?`${e}px`:""}Tn(){this.Fn=new WeakMap,this.qt.clear(),this.Hn=""}nd(e,t){if(e.isDetail)return this.e.r.detailRowHeight;let r=this.Fn.get(e);if(r!==void 0)return r;let i=this.e.r.rowHeight,o=this.e.r.getRowHeight;if(o)try{let s=o({data:e.data,node:e,api:this.e.api});i=Number.isFinite(s)?Math.max(1,s||i):i}catch(s){this.e.reportError(s,"getRowHeight",{rowId:e.id})}return t.length>0&&(i=Math.max(i,this.gf(e,t))),this.Fn.set(e,i),i}Be(e){let t=this.j.length;return t===0?Math.max(0,e)*this.e.r.rowHeight:e<=t?this.j.vt(e):this.j.Es()+(e-t)*this.e.r.rowHeight}Ln(e,t){if(t<=0)return 0;let r=this.j.length,i=this.j.Es();if(r>0&&e<i)return this.j.findIndex(e);let o=r+Math.floor(Math.max(0,e-i)/this.e.r.rowHeight);return Math.max(0,Math.min(o,t-1))}pf(){return this.e.n.u().filter(e=>e.colDef.autoHeight===!0)}get yf(){return this.e.n.u().some(e=>e.colDef.autoHeight===!0)}gf(e,t){var d;this[d="Gs"]??(this[d]=document.createElement("canvas"));let r=this.Gs.getContext("2d");if(!r)return 0;let i=window.getComputedStyle(this.e.o.root),o=parseFloat(i.fontSize)||13;r.font=`${i.fontStyle} ${i.fontWeight} ${o}px ${i.fontFamily}`;let s=parseFloat(i.getPropertyValue("--mach-cell-padding"))||9,a=Math.round(o*1.45),l=1;for(let u of t){let c=re(this.e,e,u);if(!c)continue;let h=Math.max(10,u.currentWidth-s*2-2),p=1,m=0;for(let g of c){let v=r.measureText(g).width;if(m>0&&m+v>h?(p++,m=v):m+=v,p>=12)break}p>l&&(l=p)}return l*a+Math.round(s*.9)}fl(e,t){if(this.e.r.flashCells)for(let r of e)for(let i of t)this.pi.push([r,i])}sd(){if(this.pi.length===0)return;let e=this.pi;this.pi=[];for(let[t,r]of e){let i=this.Qi(t,r);if(!i)continue;i.classList.remove("mach-cell--flash"),i.offsetWidth,i.classList.add("mach-cell--flash");let o=Te(i),s=o.flashTimer;s&&clearTimeout(s),o.flashTimer=window.setTimeout(()=>{i.classList.remove("mach-cell--flash"),o.flashTimer=void 0},800)}}Te(){this.Cn();let e=this.e.o.M.center,r=this.e.r.rowHeight;this.e.r.masterDetail&&(r=Math.min(r,this.e.r.detailRowHeight)),this.On>0&&(r=Math.min(r,this.On));let i=Math.ceil(e.clientHeight/Math.max(1,r)),o=this.e.r.domLayout==="autoHeight"?this.e.i.P():i+this.e.r.rowBuffer*2+1,s=o%2===0?o:o+1;this.ad(),s>this.Tt&&this.vf(s),this.Ps(),this.ui(!0,!1),this.Ns()}vf(e){for(;this.Tt<e;){let t={index:-1,nodeId:"",kind:"master",rows:{},cells:{}},r=this.e.o;for(let i of b){if(this.e.n.w(i).length===0)continue;let s=f("div","mach-row");s.style.height=`${this.e.r.rowHeight}px`,s.setAttribute("role","row"),s.style.display="none",r.Se[i].appendChild(s),t.rows[i]=s,t.cells[i]=this.Yt(i).map(a=>s.appendChild(this.ld(a)))}if(this.e.r.masterDetail){let i=f("div","mach-row mach-detail-row");i.style.height=`${this.e.r.detailRowHeight}px`,i.setAttribute("role","row"),i.style.display="none",r.Se.center.appendChild(i),t.detailRow=i}this.$.push(t),this.Tt++}}Yt(e){return e==="center"?this.hi:this.e.n.w(e)}ld(e){let t=f("div","mach-cell");if(t.dataset.colId=e.id,t.setAttribute("role","gridcell"),e.hasCheckbox){let r=document.createElement("input");r.type=this.e.r.rowSelection==="single"?"radio":"checkbox",r.className="mach-row-checkbox",r.type==="radio"&&(r.name=`mach-radio-${this.e.gridId}`),r.setAttribute("aria-label","select row"),t.appendChild(r),t.classList.add("mach-cell--selection")}return t}bf(e){let t=new Map(this.hi.map((i,o)=>[i.id,o])),r=e.map(i=>{let o=t.get(i.id);return t.delete(i.id),o});for(let i of this.$){let o=i.rows.center,s=i.cells.center;if(!o||!s)continue;let a=e.map((l,d)=>{let u=r[d];return o.appendChild(u===void 0?this.ld(l):s[u])});for(let l of t.values()){let d=s[l];i.index>=0&&this.e.l.Ho(i.index,d.dataset.colId??"",d),L(this.e,d),d.remove()}i.cells.center=a}}ds(){this.fi=void 0,this.dd(),this.td(!0),this.Ze=0,this.Ve=-1,this.Te()}td(e){for(let t of this.$){t.detailRow&&this.Os(t.detailRow);for(let r of b){for(let i of t.cells[r]??[])!e&&t.index>=0&&this.e.l.Ho(t.index,i.dataset.colId??"",i),L(this.e,i);e&&t.rows[r]?.remove()}e&&t.detailRow?.remove()}this.$=[],this.Tt=0,this.As=void 0,this.hi=[]}Ps(){let e=this.wf();for(let t of b){let r=this.e.n.w(t),i=this.Yt(t),o=this.Cf(t,i,r);this.Tf(t,i,o,e)}this.Df()}wf(){return this.e.r.masterDetail||this.e.r.getRowHeight!=null||this.yf}Cf(e,t,r){let i=0;e==="center"&&t.length>0&&(this.N.update(r),i=this.N.vt(r.indexOf(t[0])));let o=[];for(let s of t)o.push(i),i+=s.currentWidth;return o}Tf(e,t,r,i){for(let o of this.$){let s=o.cells[e],a=o.rows[e];if(!s||!a)continue;i||(a.style.height=`${this.e.r.rowHeight}px`);let l=Math.min(t.length,s.length);for(let d=0;d<l;d++){let u=t[d];s[d].style.width=`${u.currentWidth}px`,s[d].style.left=`${r[d]}px`,s[d].setAttribute("aria-colindex",String(this.e.n.ze(u.id)+1))}}}Df(){if(!this.e.r.masterDetail)return;let e=`${this.e.r.detailRowHeight}px`;for(let t of this.$)t.detailRow?.style.setProperty("--mach-detail-h",e)}ad(){let e=this.e.o.M.center,t=this.e.n.w("center");this.N.update(t);let r=t.length>20&&!this.e.n.eo(),{first:i,lastExcl:o}=r?this.N.Bl(e.scrollLeft,e.clientWidth,2):{first:0,lastExcl:t.length};if(t===this.As&&i===this.Wt&&o-i===this.hi.length)return!1;let s=r?t.slice(i,o):t;return this.$.length>0&&this.bf(s),this.As=t,this.hi=s,this.Wt=i,!0}fo(){return{first:this.Ze,lastExcl:this.Ve}}ui(e=!1,t=!0){let r=this.e.oe.start();if(!this.xf(e,t))return;let i=Math.max(0,this.Ve-this.Ze),o=this.e.n.w("left").length+this.Yt("center").length+this.e.n.w("right").length;this.e.oe.lh(r,i,o)}xf(e,t){let r=this.e.o.M.center,i=this.I.read(r.scrollTop)-r.scrollTop,o=i!==this.Dt;this.Dt=i;let s=this.e.i.P(),a=this.e.r.rowBuffer,l=t&&this.ad();if(l&&this.Ps(),s===0){for(let c of this.$)this.Fs(c);return this.Ze=0,this.Ve=0,!0}if(this.Ef(s,e,l))return!0;let{first:d,lastExcl:u}=this.Rf(r,s,a);return!e&&!l&&d===this.Ze&&u===this.Ve?(o&&(this.ud(),this.xt()),l||o):(this.Ze=d,this.Ve=u,this.Sf(d,u),this.cd(d,u,e,l),o&&this.ud(),this.xt(),!0)}Rf(e,t,r){let i=this.I.read(e.scrollTop),o=this.Ln(i,t),s=i+e.clientHeight,a=Math.min(t,this.Ln(s,t)+1);return{first:w(o-r,0,t-1),lastExcl:w(a+r,1,t)}}Sf(e,t){for(let r of this.$)r.index!==-1&&(r.index<e||r.index>=t)&&this.Fs(r)}cd(e,t,r,i){for(let o=e;o<t;o++){let s=this.e.i.f(o),a=this.$[o%this.Tt];if(!(!a||!s)){if(!r&&a.index===o&&a.nodeId===s.id){i&&a.kind==="master"&&this.Bn(a,s,"center");continue}this.Mf(a,o)}}}Ef(e,t,r){return this.e.r.domLayout!=="autoHeight"?!1:(!t&&!r&&this.Ze===0&&this.Ve===e||(this.Ze=0,this.Ve=e,this.cd(0,e,t,r)),!0)}Fs(e){this.hd(e),this.D?.rowIndex===e.index&&this.e.o.root.removeAttribute("aria-activedescendant"),e.index=-1,e.nodeId="",e.kind="master";for(let t of b){let r=e.rows[t];r&&(r.style.display="none",delete r.dataset.id,delete r.dataset.index,be(r,void 0),r.classList.remove("mach-row--drag-source"))}e.detailRow&&(this.Os(e.detailRow),e.detailRow.style.display="none")}Mf(e,t){e.index>=0&&e.index!==t&&this.hd(e);let r=this.e.i.f(t);if(!r){this.Fs(e);return}e.index=t,e.nodeId=r.id;let i=this.Be(t),o=i-this.Dt,s=this.Be(t+1)-i;if(r.isDetail){this.If(e,r,t,o,s);return}this.Af(e,r,t,o,s)}ud(){for(let e of this.$){if(e.index<this.Ze||e.index>=this.Ve)continue;let t=`translateY(${this.Be(e.index)-this.Dt}px)`;for(let r of Object.values(e.rows))r.style.transform=t;e.detailRow&&(e.detailRow.style.transform=t)}}If(e,t,r,i,o){e.kind="detail";for(let a of b){let l=e.rows[a];l&&(l.style.display="none")}let s=e.detailRow;s&&(this.pd(s,r,i,o),this.Hs(s,t))}Af(e,t,r,i,o){e.kind="master",e.detailRow&&(e.detailRow.style.display="none");let s=this.kf(t),a=He(this.e,t);for(let l of b){let d=e.rows[l];d&&(this.Lf(d,t,r,i,o,s),be(d,a),this.Bn(e,t,l))}this.D&&this.D.rowIndex===r&&this._n()}kf(e){let t=this.e.i.O,r=e.isGroup===!0,i=t&&this.e.i.yo(e.id),o=r||i||this.e.r.masterDetail&&this.e.i.isRowExpandable(e),s=r?this.e.i.isGroupExpanded(e.id):this.e.i.isRowExpanded(e.id),a=null;return r?a=(e.groupLevel??0)+1:t&&(a=this.e.i.vo(e)+1),{expanded:s,expandable:o,level:a}}Lf(e,t,r,i,o,s){this.pd(e,r,i,o,t.id),this.fd(e,t);let a=this.An===r&&!this.e.r.suppressRowHoverHighlight;e.classList.toggle("mach-row--hover",a),e.classList.toggle("mach-row--odd",r%2===1),e.classList.toggle("mach-row--drag-source",this.jt.isSource(t)),this.Gf(e,s)}pd(e,t,r,i,o){e.style.display="",e.style.transform=`translateY(${r}px)`,e.style.height=`${i}px`,e.dataset.index=String(t),o!==void 0&&(e.dataset.id=o),e.setAttribute("aria-rowindex",String(t+this.e.o.Il()+1))}fd(e,t){e.classList.toggle("mach-row--selected",t.selected),e.setAttribute("aria-selected",t.selected?"true":"false")}Gf(e,t){t.expandable?e.setAttribute("aria-expanded",t.expanded?"true":"false"):e.removeAttribute("aria-expanded"),t.level!=null?e.setAttribute("aria-level",String(t.level)):e.removeAttribute("aria-level")}Bn(e,t,r){let i=this.Yt(r),o=e.cells[r];if(!o)return;let s=e.index,a=r==="center"&&this.e.n.eo(),l=0;e.rows[r]?.classList.toggle("mach-row--editing",this.e.l.il(s));for(let d=0;d<i.length;d++){let u=i[d],c=o[d];if(a&&l>0){l--,L(this.e,c),c.setAttribute("aria-hidden","true"),c.style.display!=="none"&&(c.style.display="none");continue}if(c.style.display==="none"&&(c.style.display=""),c.removeAttribute("aria-hidden"),a){let h=this.Pf(t,u,s,i.length-d);h>1?(l=h-1,this.Nf(c,i,d,h)):(c.removeAttribute("aria-colspan"),c.style.width!==`${u.currentWidth}px`&&(c.style.width=`${u.currentWidth}px`))}else c.removeAttribute("aria-colspan");this.e.l.ol(s,t,u,c)||(this.md(c,t,u),this.Vs(c,s,u))}}Pf(e,t,r,i){let o=t.colDef.colSpan;if(!o)return 1;try{let s=o({api:this.e.api,colDef:t.colDef,column:t,node:e,data:e.data,value:this.e.d(e,t),rowIndex:r});return Math.max(1,Math.min(Math.round(s)||1,i))}catch(s){return this.e.reportError(s,"colSpan",{colId:t.id,rowId:e.id}),1}}Nf(e,t,r,i){let o=0;for(let s=r;s<r+i&&s<t.length;s++)o+=t[s].currentWidth;e.style.width=`${o}px`,e.setAttribute("aria-colspan",String(i))}Hs(e,t){this.Os(e);let r=t.masterId!=null?this.e.i.X(t.masterId):t,i=f("div","mach-detail");e.appendChild(i);let o=this.e.r.detailRowRenderer;if(o){let s={data:t.data,node:r??t,api:this.e.api},a;try{a=o(s)}catch(l){this.e.reportError(l,"detailRowRenderer",{rowId:t.id}),a=null}typeof a=="string"?i.textContent=a:a instanceof HTMLElement?i.appendChild(a):a&&typeof a=="object"&&a.el instanceof HTMLElement&&(i.appendChild(a.el),ri(e,a.destroy))}}Os(e){let t=ii(e);if(t)try{t()}catch(r){this.e.reportError(r,"detailRowRenderer.destroy")}e.textContent=""}md(e,t,r){if(t.loading){L(this.e,e),e.className="mach-cell mach-cell--loading",e.setAttribute("aria-readonly","true"),e.setAttribute("aria-busy","true");let o=f("span","mach-cell-loading-bar");o.style.width=`${34+(r.id.length*13+t.rowIndex*7)%44}%`,e.replaceChildren(o),this.Xt(e);return}e.removeAttribute("aria-busy"),e.setAttribute("aria-readonly",this.e.l.U(t,r)?"false":"true"),e.removeAttribute("aria-expanded"),e.removeAttribute("aria-level");let i=this.Of(t,r);if(i!=="standard"){L(this.e,e),this.Ff(i,e,t,r);return}Ke(this.e,e,t,r),this.gd(e,t,r),this.Hf(e,t,r)}Of(e,t){return e.isGroup?"group":t.isDetailToggle?"detail":t.hasCheckbox?"checkbox":t.colDef.rowDrag?"drag":Se(t.colDef,"index")?"index":this.e.i.O&&this.yd()?.id===t.id?"tree":"standard"}Ff(e,t,r,i){if(e==="group")this.Vf(t,r,i);else if(e==="detail"){let o=this.e.i.isRowExpanded(r.id),s=f("span",`mach-detail-toggle${o?" mach-detail-toggle--open":""}`);s.textContent="\u25B6",t.replaceChildren(s),t.classList.add("mach-cell--detail-toggle"),this.Xt(t)}else if(e==="checkbox"){let o=t.querySelector(".mach-row-checkbox");o&&(o.checked=r.selected,o.indeterminate=this.e.m.ju(r.id),o.disabled=!this.e.m.Ue(r)),t.className!=="mach-cell mach-cell--selection"&&(t.className="mach-cell mach-cell--selection"),this.Xt(t)}else if(e==="drag")this.Bf(t,r),t.className!=="mach-cell mach-cell--drag"&&(t.className="mach-cell mach-cell--drag"),this.Xt(t);else if(e==="index"){t.textContent=String(this.e.i.La(r)+this.e.r.indexOffset);let o=`mach-cell mach-cell--index ${$e(i)}`;t.className!==o&&(t.className=o),this.gd(t,r,i)}else this._f(t,r,i)}Hf(e,t,r){if(this.e.r.editType!=="cell"||this.e.r.editableIndicator==="none"||!this.e.l.U(t,r))return;let i=document.createElement("button");i.type="button",i.className=`mach-cell-edit-trigger mach-cell-edit-trigger--${this.e.r.editableIndicator}`,i.tabIndex=-1,i.title="Edit cell",i.setAttribute("aria-label","Edit cell"),i.innerHTML='<svg viewBox="0 0 16 16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m10.8 2.7 2.5 2.5L5.5 13H3v-2.5z"/><path d="m9.5 4 2.5 2.5"/></svg>',i.addEventListener("mousedown",o=>{o.preventDefault(),o.stopPropagation()}),i.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation(),this.Oe(t.rowIndex,r.id),this.e.l.start(t.rowIndex,r)}),e.appendChild(i)}hd(e){if(!(e.index<0))for(let t of b)for(let r of e.cells[t]??[])this.e.l.Ho(e.index,r.dataset.colId??"",r)}yd(){return this.fi!==void 0?this.fi:(this.fi=this.e.n.u().find(e=>!e.hasCheckbox&&!e.isDetailToggle&&!e.colDef.rowDrag&&!Se(e.colDef,"index"))??null,this.fi)}_f(e,t,r){let i=this.e.i.isRowExpandable(t),o=this.e.i.vo(t),s=U(this.e,t,r,this.e.d(t,r)),a=f("span","mach-tree-indent");a.style.width=`${o*16}px`;let l=f("span","mach-tree-cell");if(o>0&&l.appendChild(a),i){let u=this.e.i.isRowExpanded(t.id);e.setAttribute("aria-expanded",u?"true":"false"),e.setAttribute("aria-level",String(o+1));let c=t.treeLoading?" mach-detail-toggle--loading":t.treeLoadError?" mach-detail-toggle--error":"",h=document.createElement("button");h.type="button",h.tabIndex=-1,h.className="mach-tree-toggle",h.setAttribute("aria-label",t.treeLoadError?"Retry loading children":u?"Collapse row":"Expand row"),h.setAttribute("aria-expanded",String(u)),t.treeLoadError&&(h.title="Retry loading children");let p=f("span",`mach-detail-toggle${u?" mach-detail-toggle--open":""}${c}`);p.setAttribute("aria-hidden","true"),p.textContent="\u25B6",h.appendChild(p),h.addEventListener("keydown",m=>{(m.key==="Enter"||m.key===" ")&&m.stopPropagation()}),l.appendChild(h)}else{let u=f("span","mach-tree-toggle-spacer");l.appendChild(u)}let d=f("span","mach-tree-text");d.textContent=s,l.appendChild(d),e.replaceChildren(l),s&&!this.e.r.tooltipComponent?e.title=s:e.removeAttribute("title"),hr(this.e,e,t,r)}Xt(e){e.style.height!==""&&(e.style.height=""),e.style.zIndex!==""&&(e.style.zIndex=""),e.style.display==="none"&&(e.style.display=""),e.removeAttribute("aria-rowspan")}gd(e,t,r){let i=this.e.i.Pu(r.id);if(!i||t.isDetail){this.Xt(e);return}let o=this.e.i.La(t)-1;if(o<0||o>=i.length){this.Xt(e);return}let s=i[o];if(s===-1){e.style.display="none",e.setAttribute("aria-hidden","true");return}if(e.style.display==="none"&&(e.style.display=""),e.removeAttribute("aria-hidden"),s>1){let a=Math.min(o+s,this.e.i.P()),l=this.Be(a)-this.Be(o);e.style.height=`${l>0?l:s*this.e.r.rowHeight}px`,e.style.zIndex="1",e.setAttribute("aria-rowspan",String(s))}else this.Xt(e)}Vf(e,t,r){if(r.hasCheckbox){this.zf(e,t);return}if(r.isDetailToggle){this.vd(e);return}let i=this.e.n.ea();if(i&&r.id===i.id){this.Wf(e,t);return}this.$f(e,t,r)||this.vd(e)}zf(e,t){let r=e.querySelector(".mach-row-checkbox");if(r){let i=this.e.m.Ha(t);r.checked=i.all,r.indeterminate=i.some&&!i.all}e.className!=="mach-cell mach-cell--selection"&&(e.className="mach-cell mach-cell--selection")}Wf(e,t){let r=this.e.i.isGroupExpanded(t.id),i=t.groupLevel??0;e.setAttribute("aria-expanded",r?"true":"false"),e.setAttribute("aria-level",String(i+1));let o=f("span","mach-group-label");o.style.paddingLeft=`${i*16}px`;let s=f("span",`mach-detail-toggle${r?" mach-detail-toggle--open":""}`);s.textContent="\u25B6";let a=f("span","mach-group-text"),l=this.e.n.Qe()[i],d=l?.colDef.headerName?`${l.colDef.headerName}: `:"";a.textContent=`${d}${t.groupKey??""}`;let u=f("span","mach-group-count");u.textContent=`(${t.leafNodes?.length??0})`,o.append(s,a,u),e.replaceChildren(o),e.className!=="mach-cell mach-cell--group"&&(e.className="mach-cell mach-cell--group")}$f(e,t,r){if(!r.colDef.aggFunc||!t.aggValues||!Object.prototype.hasOwnProperty.call(t.aggValues,r.id))return!1;let i=t.aggValues[r.id];e.textContent=r.colDef.valueFormatter!=null?U(this.e,t,r,i):cr(i);let o=`mach-cell ${$e(r)}`;return e.className!==o&&(e.className=o),!0}vd(e){e.textContent="",e.className!=="mach-cell"&&(e.className="mach-cell")}at(e){if(this.e.s())return;let t=new Set;for(let r of e){if(r<0||t.has(r))continue;t.add(r);let i=this.$[r%this.Tt];if(!i||i.index!==r)continue;let o=this.e.i.f(r);if(o){if(i.kind==="detail"){i.detailRow&&this.Hs(i.detailRow,o);continue}for(let s of b){let a=i.rows[s];a&&this.fd(a,o),i.cells[s]&&this.Bn(i,o,s)}}}this._n(),this.sd()}refreshCells(e={}){if(this.e.s())return;let t=e.rowIds==null?null:new Set(e.rowIds),r=e.rowIndexes==null?null:new Set(e.rowIndexes),i=e.columns==null?null:new Set(e.columns);for(let o of this.$){let s=this.e.i.f(o.index);!s||!this.Kf(o,s,t,r)||this.Uf(o,s,i,e.force===!0)}this._n(),this.sd()}Kf(e,t,r,i){return e.index<0?!1:r==null&&i==null?!0:r?.has(t.id)===!0||i?.has(e.index)===!0}Uf(e,t,r,i){if(e.kind==="detail"){r==null&&e.detailRow&&this.Hs(e.detailRow,t);return}let o=r==null||this.e.n.eo(),s=He(this.e,t);for(let a of b){let l=e.rows[a];l&&be(l,s),o?this.Bn(e,t,a):this.jf(e,t,a,r,i)}}jf(e,t,r,i,o){let s=this.Yt(r),a=e.cells[r];if(a)for(let l=0;l<s.length;l++){let d=s[l];if(!i.has(d.id))continue;let u=a[l];u&&(this.e.l.ol(e.index,t,d,u)||(o&&L(this.e,u),this.md(u,t,d),this.Vs(u,e.index,d)))}}qf(){this.e.s()||(this.D&&this.D.rowIndex>=this.e.i.P()&&this.Oe(null,null),this.dd(),this.Cn(),this.ui(!0),this.xt(),this.Ns(),this.e.ae.refresh())}Ns(){let e=this.e.r,t=e.loading?"loading":e.error!=null?"error":this.e.i.P()===0&&!e.suppressNoRowsOverlay?"noRows":null;Vt(this.e,t)}Qi(e,t){let r=this.e.n.k(t);if(!r)return null;let i=this.Mo(r),o=this.Yt(i).indexOf(r);if(o<0)return null;let s=this.$[e%this.Tt];return!s||s.index!==e||s.kind!=="master"?null:s.cells[i]?.[o]??null}dd(){this.me.rr()}Ne(){let e=this.e.i.P(),t=this.e.n.u().length;return this.me.normalize(e,t)}Xr(){let e=this.Ne();if(e)return e;let t=this.D;if(t){let r=this.e.n.ze(t.colId);if(r>=0)return{r1:t.rowIndex,c1:r,r2:t.rowIndex,c2:r}}return null}si(){let e=this.Ne();if(!e)return null;let t=this.e.n.u();return{row1:e.r1,row2:e.r2,colId1:t[e.c1]?.id??"",colId2:t[e.c2]?.id??""}}Lo(){let e=this.me.zp();if(e)return{row:e.row,colIdx:e.colIdx};let t=this.Xr();return t?{row:t.r1,colIdx:t.c1}:null}mr(){let e=this.Ne();this.me.clear(),e&&(this.zn(),this.xt(),this.e.emit("rangeSelectionChanged",{range:null}))}zn(){for(let e of this.$)if(!(e.index<0||e.kind!=="master"))for(let t of b){let r=this.Yt(t);e.cells[t]?.forEach((i,o)=>{let s=r[o];s&&this.Vs(i,e.index,s)})}}Bs(e,t,r){this.me.start({row:e,colIdx:t},r),this.zn(),this.xt(),this.e.emit("rangeSelectionChanged",{range:this.si()})}Dc(e,t){if(!this.me.Wp()){let a=this.D;if(!a)return;let l=this.e.n.ze(a.colId);if(!this.me.$p({row:a.rowIndex,colIdx:l}))return}let r=this.e.i.P(),i=this.e.n.u().length;this.me.setEnd({row:Math.max(0,Math.min(e,r-1)),colIdx:Math.max(0,Math.min(t,i-1))}),this.zn(),this.xt();let o=this.e.n.u(),s=this.me.bs();s&&s.colIdx<o.length&&this.Oe(s.row,o[s.colIdx].id),this.e.emit("rangeSelectionChanged",{range:this.si()})}Vs(e,t,r){let i=this.Ne();if(!i){e.classList.contains("mach-cell--range")&&e.classList.remove("mach-cell--range","mach-cell--range-top","mach-cell--range-bottom","mach-cell--range-left","mach-cell--range-right");return}let o=this.e.n.ze(r.id);if(o<0)return;let s=t>=i.r1&&t<=i.r2&&o>=i.c1&&o<=i.c2;e.classList.toggle("mach-cell--range",s),s?(e.classList.toggle("mach-cell--range-top",t===i.r1),e.classList.toggle("mach-cell--range-bottom",t===i.r2),e.classList.toggle("mach-cell--range-left",o===i.c1),e.classList.toggle("mach-cell--range-right",o===i.c2)):e.classList.remove("mach-cell--range-top","mach-cell--range-bottom","mach-cell--range-left","mach-cell--range-right")}Yf(){if(this.Pn)return this.Pn;let e=f("div","mach-fill-handle");return e.style.display="none",e.addEventListener("pointerdown",t=>{this._s=!0,this.bd(t)}),e.addEventListener("mousedown",t=>{this._s||this.bd(t)}),this.e.o.Se.center.appendChild(e),this.Pn=e,e}xt(){let e=this.Yf(),t=this.Ne();if(!this.e.r.enableRangeSelection||!this.e.r.fillHandle||!t){e.style.display="none";return}let r=this.e.n,i=r.w("left").length,o=r.w("center");if(t.c2<i||t.c2>=i+o.length){e.style.display="none";return}let s=t.c2-i;this.N.update(o);let a=this.N.vt(s+1),l=this.Be(Math.min(t.r2+1,this.e.i.P()))-this.Dt,d=this.e.o.M.center;if(this.I.Ct&&(l<d.scrollTop||l>d.scrollTop+d.clientHeight)){e.style.display="none";return}e.style.display="",e.style.left=`${this.I.Ct?Math.min(a-4,parseFloat(this.e.o.Se.center.style.width)-8):a-4}px`,e.style.top=`${Math.min(l-4,this.I.height-8)}px`}bd(e){if(this.e.s()||e.button!==0)return;let t=this.Ne();t&&(e.preventDefault(),e.stopPropagation(),this.mi={r1:t.r1,r2:t.r2,c1:t.c1,c2:t.c2,startX:e.clientX,startY:e.clientY,axis:null,active:!1},this.wd(!0))}Cd(e){let r=this.e.o.Se.center.getBoundingClientRect(),i=e.clientY-r.top+this.Dt,o=this.e.i.P(),s=this.Ln(i,o);return Math.max(this.mi.r2,Math.min(s,o-1))}Td(e){let r=this.e.o.Se.center.getBoundingClientRect(),i=e.clientX-r.left,o=this.e.n,s=o.w("left").length,a=o.w("center");this.N.update(a);let l=this.N.Tp(i);if(l<0)return s;let d=this.N.vt(l)+a[l].currentWidth/2;return i<d?s+l:l+1<a.length?s+l+1:s+a.length-1}wd(e){let t=e?"addEventListener":"removeEventListener";for(let r of["pointermove","mousemove"])window[t](r,this.Xf);for(let r of["pointerup","mouseup","pointercancel"])window[t](r,this.Jf)}Gn(){this.mi=null,this._s=!1,this.wd(!1),this.e.o.root.classList.remove("mach-root--filling")}Dd(e,t,r){let i=this.me.bs();!i||t===(e?i.colIdx:i.row)||(this.me.setEnd(e?{row:i.row,colIdx:t}:{row:t,colIdx:i.colIdx}),this.zn(),r&&(e&&this.xt(),this.e.emit("rangeSelectionChanged",{range:this.si()})))}Zf({r1:e,r2:t,c1:r,c2:i},o,s){let a=this.e.n.u(),l=[];if(s)for(let d=e;d<=t;d++)this.Qf(d,r,i,o,a,l);else for(let d=r;d<=i;d++){let u=a[d];Bn(u)&&this.em(u,e,t,o,l)}this.e.di(l),this.e.emit("rangeSelectionChanged",{range:this.si()})}Qf(e,t,r,i,o,s){let a=this.e.i.f(e);if(!a||a.isDetail||a.isGroup)return;let l=[];for(let u=t;u<=r;u++){let c=o[u];l.push(c?this.e.d(a,c):void 0)}let d=_n(l);for(let u=r+1;u<=i;u++){let c=o[u];if(!Bn(c)||!this.e.l.U(a,c))continue;let h=zn(d,u-t),p=this.e.d(a,c);s.push({node:a,column:c,oldValue:p,newValue:h})}}em(e,t,r,i,o){let s=[];for(let l=t;l<=r;l++){let d=this.e.i.f(l);s.push(d?this.e.d(d,e):void 0)}if(s.length===1&&s[0]===void 0)return;let a=_n(s);for(let l=r+1;l<=i;l++){let d=this.e.i.f(l);if(!d||d.isDetail||d.isGroup||!this.e.l.U(d,e))continue;let u=zn(a,l-t),c=this.e.d(d,e);o.push({node:d,column:e,oldValue:c,newValue:u})}}Oe(e,t){if(this.tm(),e==null||t==null){this.D=null;return}this.D={rowIndex:e,colId:t},this._n(),this.rm()}_n(){if(!this.D)return;let e=this.Qi(this.D.rowIndex,this.D.colId);if(e){let t=Math.max(0,this.e.n.ze(this.D.colId));e.id=`mach-grid-${this.e.gridId}-r${this.D.rowIndex}-c${t}`,e.classList.add("mach-cell--focus"),this.e.o.root.setAttribute("aria-activedescendant",e.id)}}tm(){if(this.D){let e=this.Qi(this.D.rowIndex,this.D.colId);e&&(e.classList.remove("mach-cell--focus"),e.removeAttribute("id"))}this.e.o.root.removeAttribute("aria-activedescendant")}rm(){if(!this.D)return;this.cr(this.D.rowIndex,"nearest");let e=this.e.n.k(this.D.colId);if(!e||e.pinned)return;let t=this.e.o.M.center,r=this.e.n.w("center");this.N.update(r);let i=this.N.vt(r.indexOf(e)),o=t.scrollLeft,s=t.clientWidth;i<o?t.scrollLeft=i:i+e.currentWidth>o+s&&(t.scrollLeft=i+e.currentWidth-s)}cr(e,t="top"){let r=this.e.o.M.center,i=this.e.i.P();if(i===0)return;let o=w(e,0,i-1),s=r.clientHeight,a=this.I.read(r.scrollTop),l=this.Be(o),d=this.Be(o+1),u=a;t==="top"?u=l:t==="bottom"?u=d-s:t==="middle"?u=l-(s-(d-l))/2:l<a?u=l:d>a+s&&(u=d-s);let c=Math.max(0,this.Be(i)-s);this.Vn(w(u,0,c)),this.wn()}xd(e){if(this.An===e)return;let t=this.An;this.An=e,this.Ed(t,!1),this.Ed(e,!0)}Ed(e,t){if(e<0)return;let r=this.$[e%this.Tt];if(!(!r||r.index!==e||r.kind!=="master"))for(let i of b)r.rows[i]?.classList.toggle("mach-row--hover",t)}gi(){this.e.o.root.focus({preventScroll:!0})}Jt(e){let t=e.target,r=t.closest(".mach-row");if(!r)return null;let i=Number(r.dataset.index);if(Number.isNaN(i))return null;let o=this.e.i.f(i);if(!o)return null;let s=t.closest(".mach-cell");return{node:o,index:i,cellEl:s}}Rd(e,t,r){let{node:i,index:o,cellEl:s}=r;if(this.im(t,i,s)||this.nm(t,i,s))return;let a=s?.dataset.colId??"",l=a?this.e.n.k(a):void 0;this.om(i,l)||i.isDetail||this.sm(t,i,o,e)||!s||!l||(this.gi(),this.e.r.suppressCellFocus||this.Oe(o,a),this.e.m.Ba(i,e,!1),this.am(e,i,o,l),this.lm(i,o,l))}im(e,t,r){if(!t.isGroup)return!1;if(this.gi(),e.closest(".mach-row-checkbox")){let o=this.e.m.Ha(t).all;return this.e.m.Xu(t,!o),!0}let i=this.e.n.ea();return(!i||!r||r.dataset.colId===i.id)&&this.e.i.To(t.id),!0}om(e,t){return!t?.isDetailToggle||e.isDetail?!1:(this.gi(),this.e.Ui(e.id),!0)}sm(e,t,r,i){let o=e.closest(".mach-cell--selection");return o?(this.gi(),this.e.r.suppressCellFocus||this.Oe(r,o.dataset.colId??""),this.mr(),this.e.m.Ba(t,i,!0),!0):!1}am(e,t,r,i){let o=this.e.d(t,i),s=this.e.emit("cellClicked",{event:e,rowNode:t,rowIndex:r,column:i,colDef:i.colDef,value:o});i.colDef.onCellClick?.(s),this.e.emit("rowClicked",{event:e,rowNode:t,rowIndex:r})}lm(e,t,r){(this.e.r.singleClickEdit||r.colDef.singleClickEdit===!0)&&this.e.l.U(e,r)&&this.e.l.start(t,r)}nm(e,t,r){if(!this.e.i.O||!e.closest(".mach-tree-toggle"))return!1;let i=this.yd();return!i||r?.dataset.colId!==i.id||!this.e.i.isRowExpandable(t)?!1:(this.gi(),t.treeLoadError?this.e.i.loadTreeChildren(t.id,!0).catch(()=>{}):this.e.i.Ui(t.id),!0)}dm(e){return!!(e.target.closest(".mach-cell-editor-shell, .mach-row-editor-shell, .mach-tree-toggle, .mach-row-drag-handle")||this.e.l.Zi())}Bf(e,t){let r=e.querySelector("button.mach-row-drag-handle"),i=r?.value===t.id?r:f("button","mach-row-drag-handle");i.type="button",i.value=t.id;let o=this.jt.Xl(t);i.disabled=o!==!0;let s=this.e.r.locale.rowDragHandle??D.rowDragHandle;i.setAttribute("aria-label",s),i.title=typeof o=="string"?o:i.disabled?this.e.r.locale.rowDragUnavailable??D.rowDragUnavailable:s,i.setAttribute("aria-keyshortcuts","Alt+ArrowUp Alt+ArrowDown"),i!==r&&e.replaceChildren(i)}};var Yt=class{constructor(e){this.e=e;this._e=null;this.Sd={left:void 0,center:void 0,right:void 0};this.Ws={left:[],center:[],right:[]}}init(){this._e=f("div","mach-footer"),this._e.style.display="none",this._e.setAttribute("role","row"),this.e.o.root.appendChild(this._e);for(let e of b){let t=f("div",`mach-footer-row mach-footer-row--${e}`);t.style.height=`${this.e.r.rowHeight}px`,this._e.appendChild(t),this.Sd[e]=t}}setVisible(e){this._e&&(this._e.style.display=e?"":"none")}refresh(){if(!this._e||this.e.s())return;let e=this.e.r.showSummary;if(this.setVisible(e),!e)return;let t=this.e.r.summaryMethod,r=this.e.i.st().filter(o=>!o.isDetail&&!o.isGroup),i={...D,...this.e.r.locale};for(let o of b){let s=this.e.n.w(o),a=this.Sd[o];this.Ws[o].length!==s.length&&(a.textContent="",this.Ws[o]=s.map(()=>{let d=f("div","mach-footer-cell");return d.setAttribute("role","cell"),a.appendChild(d),d}));let l=0;s.forEach((d,u)=>{let c=this.Ws[o][u];if(c.style.left=`${l}px`,c.style.width=`${d.currentWidth}px`,l+=d.currentWidth,d.hasCheckbox||d.isDetailToggle||d.colDef.rowDrag){c.textContent="";return}if(t)try{c.textContent=t({colId:d.id,column:d,values:r.map(h=>this.e.d(h,d))})}catch(h){this.e.reportError(h,"summaryMethod",{colId:d.id}),c.textContent=""}else u===0&&o==="left"?c.textContent=V(i.totalRowsLabel,r.length):c.textContent=""})}}destroy(){this._e?.remove(),this._e=null}};var Xt=class{constructor(e){this.e=e;this.b=null;this.Wn=null;this.$s=null;this.Ir=null;this.Zt=null;this.yi=null;this.vi=null;this.bi=null;this.wi=null;this.Qt=[]}init(){this.b=f("div","mach-pagination"),this.b.style.display="none",this.b.setAttribute("role","navigation");let e=(t,r,i)=>{let o=f("button",`mach-pagination-btn ${t}`);return o.type="button",o.title=r,o.setAttribute("aria-label",r),o.textContent=i,o};this.Wn=f("span","mach-pagination-total"),this.yi=e("mach-pagination-first",this.t("pageFirst"),"\xAB"),this.vi=e("mach-pagination-prev",this.t("pagePrev"),"\u2039"),this.$s=f("span","mach-pagination-page"),this.bi=e("mach-pagination-next",this.t("pageNext"),"\u203A"),this.wi=e("mach-pagination-last",this.t("pageLast"),"\xBB"),this.yi.addEventListener("click",()=>this.e.i.setPage(1)),this.vi.addEventListener("click",()=>this.e.i.setPage(this.e.i.Lt()-1)),this.bi.addEventListener("click",()=>this.e.i.setPage(this.e.i.Lt()+1)),this.wi.addEventListener("click",()=>this.e.i.setPage(this.e.i.getPageCount())),this.b.append(this.Wn,this.yi,this.vi,this.$s,this.bi,this.wi),this.e.r.paginationShowSizeSelector&&(this.Zt=ee({ariaLabel:"page size",options:[],classNames:{root:"mach-pagination-size-control",native:"mach-pagination-size"},themeSource:this.e.o.root,onChange:t=>{let r=Number(t);Number.isNaN(r)||this.e.i.setPageSize(r)}}),this.Ir=this.Zt.native,this.Md(),this.b.appendChild(this.Zt.el)),this.e.o.root.appendChild(this.b),this.Qt.push(this.e.ce.on("modelUpdated",()=>this.refresh()),this.e.ce.on("paginationChanged",()=>this.refresh())),this.refresh()}Md(){if(!this.Ir)return;let e=this.e.r.paginationPageSizeOptions,t=this.e.r.paginationPageSize;e.includes(t)||(e.push(t),e.sort((r,i)=>r-i)),this.Zt?.setOptions(e.map(r=>({value:String(r),label:V(this.t("perPage"),r)})),String(t))}t(e){return this.e.r.locale?.[e]??D[e]}Me(){this.b&&(this.Ir&&this.e.r.paginationShowSizeSelector&&this.Md(),this.refresh())}Id(e,t){e&&e.textContent!==t&&(e.textContent=t)}um(e,t){let r=e<=1,i=e>=t;this.yi&&(this.yi.disabled=r),this.vi&&(this.vi.disabled=r),this.bi&&(this.bi.disabled=i),this.wi&&(this.wi.disabled=i)}refresh(){if(!this.b||this.e.s())return;let e=this.e.i,t=e.xe,r=e.getTotalRowCount(),i=t&&r>0;if(this.b.style.display=i?"":"none",!i)return;let o=e.Lt(),s=e.getPageCount();this.Wn&&this.e.r.paginationShowTotal&&this.Id(this.Wn,V(this.t("paginationTotal"),r)),this.Id(this.$s,fe(this.t("paginationPage"),o,s)),this.um(o,s),this.Ir&&Number(this.Ir.value)!==this.e.r.paginationPageSize&&this.Zt?.setValue(String(this.e.r.paginationPageSize))}destroy(){for(let e of this.Qt)e();this.Qt=[],this.Zt?.destroy(),this.Zt=null,this.Ir=null,this.b?.remove(),this.b=null}};var Jt=class{constructor(e){this.e=e;this.top=null;this.bottom=null}init(){this.top=this.Ad(this.e.o.pn),this.bottom=this.Ad(this.e.o.fn)}Ad(e){let t={root:e,segments:{left:f("div"),center:f("div"),right:f("div")},centerViewport:f("div","mach-pinned-viewport"),rowWrappers:{left:[],center:[],right:[]},cells:[],data:[]};for(let r of b)t.segments[r].className=`mach-pinned-seg mach-pinned-seg--${r}`,r!=="center"&&t.segments[r].classList.add("mach-pane--hidden"),r==="center"&&t.centerViewport.appendChild(t.segments[r]);return e.append(t.segments.left,t.centerViewport,t.segments.right),t}setData(e,t){this.e.s()||!this.top||!this.bottom||(this.top.data=e??[],this.bottom.data=t??[],this.refresh(),this.e.Te())}setRows(e,t){let r=this[e];this.e.s()||!r||(r.data=t??[],this.Ks(r,e),this.bt(),this.e.Te())}getRows(e){return this[e]?.data.slice()??[]}Me(){!this.top||!this.bottom||(this.Ks(this.top,"top"),this.Ks(this.bottom,"bottom"))}Ks(e,t){this.xr(e);for(let o of b){for(let s of e.rowWrappers[o])s.remove();e.rowWrappers[o]=[]}if(e.root.style.display=e.data.length>0?"":"none",e.data.length===0)return;let r=this.e.r.rowHeight,i=this.e.n;e.data.forEach((o,s)=>{let a={id:`__pinned_${t}_${s}`,data:o,rowIndex:-1,selected:!1},l={},d=He(this.e,a,t);for(let u of b){let c=f("div","mach-pinned-row");be(c,d),c.style.height=`${r}px`,c.setAttribute("role","row"),l[u]=[];for(let h of i.w(u)){let p=f("div","mach-cell");if(p.dataset.colId=h.id,p.setAttribute("role","gridcell"),h.hasCheckbox&&p.classList.add("mach-cell--selection"),!h.hasCheckbox&&!h.isDetailToggle&&!h.colDef.rowDrag&&h.colDef.type!=="index")try{Ke(this.e,p,a,h)}catch(m){this.e.reportError(m,"pinnedRow.render",{colId:h.id,side:t,rowIndex:s})}c.appendChild(p),l[u].push(p)}e.segments[u].appendChild(c),e.rowWrappers[u].push(c)}e.cells.push(l)})}bt(){if(!this.top||!this.bottom)return;let e=this.e.n,t={left:0,center:0,right:0},r={left:[],center:[],right:[]};for(let i of b){let o=0;for(let s of e.w(i))r[i].push(o),o+=s.currentWidth;t[i]=o}for(let i of[this.top,this.bottom]){let o=i.data.length===0;i.segments.left.classList.toggle("mach-pane--hidden",o||t.left<=0),i.segments.right.classList.toggle("mach-pane--hidden",o||t.right<=0),i.segments.left.style.width=`${t.left}px`,i.segments.right.style.width=`${t.right}px`,i.segments.center.style.width=`${t.center}px`,i.cells.forEach(s=>{let a=0;for(let l of b){let d=e.w(l);s[l].forEach((u,c)=>{u.style.width=`${d[c].currentWidth}px`,u.style.left=`${r[l][c]}px`,u.setAttribute("aria-colindex",String(a+c+1))}),a+=d.length}})}}sf(e){this.top&&(this.top.segments.center.style.transform=`translateX(${-e}px)`),this.bottom&&(this.bottom.segments.center.style.transform=`translateX(${-e}px)`)}refresh(){this.Me(),this.bt()}destroy(){this.top&&this.xr(this.top),this.bottom&&this.xr(this.bottom),this.top=null,this.bottom=null}xr(e){for(let t of e.cells)for(let r of b)for(let i of t[r])L(this.e,i);e.cells=[]}};var Zt=class{constructor(e){this.e=e;this.b=null;this.Ar={};this.Qt=[]}init(){this.b=f("div","mach-statusbar"),this.b.style.display="none",this.b.setAttribute("role","status"),this.e.o.root.appendChild(this.b),this.Me(),this.Qt.push(this.e.ce.on("modelUpdated",()=>this.refresh()),this.e.ce.on("selectionChanged",()=>this.refresh()),this.e.ce.on("rangeSelectionChanged",()=>this.refresh()),this.e.ce.on("cellValueChanged",()=>this.refresh()))}Me(){if(!this.b)return;this.b.textContent="",this.Ar={};let e=this.e.r;if(!e.statusBarEnabled){this.b.style.display="none";return}for(let t of e.statusBarPanels){let r=f("span",`mach-statusbar-item mach-statusbar-item--${t}`);this.b.appendChild(r),this.Ar[t]=r}this.refresh()}text(e,t,r){let i=e[t]??D[t];if(r===void 0)return i;let o=typeof r=="number"?r:parseFloat(String(r))||0;return V(i,o)}Us(e,t){let r=this.Ar[e];r&&r.textContent!==t&&(r.textContent=t)}cm(e){let t=this.e.i,r=t.or(),i=t.xe?t.getTotalRowCount():t.P(),o=V(this.text(e,"totalRowsLabel"),i);return t.g&&r>i?`${o} / ${r}`:o}hm(e){let t=this.e.a.Ne();if(!t)return"";let r=this.e.n.u(),i=0,o=0;for(let l=t.r1;l<=t.r2;l++){let d=this.e.i.f(l);if(!(!d||d.isDetail||d.isGroup))for(let u=t.c1;u<=t.c2;u++){let c=r[u];if(!c)continue;let h=this.e.d(d,c);typeof h!="number"||Number.isNaN(h)||(i+=h,o++)}}if(o===0)return"";let s=Math.round(i/o*100)/100,a=Number.isInteger(i)?String(i):String(Math.round(i*100)/100);return`${this.text(e,"statusSum",a)} \xB7 ${this.text(e,"statusAvg",String(s))} \xB7 ${this.text(e,"statusCount",String(o))}`}refresh(){if(!this.b||this.e.s())return;let e=this.e.r;if(this.b.style.display=e.statusBarEnabled?"":"none",!e.statusBarEnabled)return;let t={...D,...e.locale};if(this.Ar.rowCount&&this.Us("rowCount",this.cm(t)),this.Ar.selectedRowCount){let r=this.e.m.Gt().length;this.Us("selectedRowCount",V(this.text(t,"statusSelected"),r))}this.Ar.rangeAggregate&&this.Us("rangeAggregate",this.hm(t))}destroy(){for(let e of this.Qt)e();this.Qt=[],this.b?.remove(),this.b=null}};function Kr(){try{return typeof localStorage>"u"?null:localStorage}catch{return null}}function Wn(n){return typeof TextEncoder>"u"?n.length*2:new TextEncoder().encode(n).byteLength}function Ur(n={}){let e=(n.namespace??"mach-table:grid-state").replace(/:+$/,""),t=Math.max(1024,Math.floor(n.maxBytes??512*1024)),r=o=>`${e}:${o}`,i=(o,s,a)=>{try{n.onError?.(o,s,a)}catch{}};return{storageKey:r,load(o){try{let s=(n.storage??Kr())?.getItem(r(o));if(!s)return null;if(Wn(s)>t)throw new RangeError(`[MachTable] Stored grid state for "${o}" exceeds ${t} bytes.`);let a=JSON.parse(s);if(a?.schemaVersion!==2)throw new TypeError(`[MachTable] Stored grid state for "${o}" uses an unsupported schema.`);let l=z(a.state);if(!l)throw new TypeError(`[MachTable] Stored grid state for "${o}" is invalid.`);return l}catch(s){return i(s,"load",o),null}},save(o,s){try{let a=z(s);if(!a)throw new TypeError(`[MachTable] Invalid grid state for "${o}".`);let l=JSON.stringify({schemaVersion:2,savedAt:Date.now(),state:a});if(Wn(l)>t)throw new RangeError(`[MachTable] Grid state for "${o}" exceeds ${t} bytes.`);(n.storage??Kr())?.setItem(r(o),l)}catch(a){i(a,"save",o)}},clear(o){try{(n.storage??Kr())?.removeItem(r(o))}catch(s){i(s,"clear",o)}}}}var jr=Ur();function Qt(n,e){jr.save(n,e)}function er(n){return jr.load(n)}function $n(n){jr.clear(n)}var Ve=class{constructor(e){this.onError=e;this.$n=new Set;this.disposed=!1}add(e){let t=!0,r=()=>{if(t){t=!1,this.$n.delete(r);try{e()}catch(i){try{this.onError(i)}catch{}}}};return this.disposed?r():this.$n.add(r),r}A(e){return this.add(()=>e.destroy()),e}dispose(){if(this.disposed)return;this.disposed=!0;let e=[...this.$n].reverse();this.$n.clear();for(let t of e)t()}};function ga(n){return!!(n.field||n.valueGetter||n.cellRenderer||n.checkboxSelection||n.rowDrag||n.type||n.autoRowSpan||n.rowSpan)}function ya(n,e,t){n.width!=null&&n.minWidth!=null&&n.width<n.minWidth&&t.push(`\u5217 "${e}" \u7684 width(${n.width}) \u5C0F\u4E8E minWidth(${n.minWidth})\uFF0C\u5C06\u6309 minWidth \u6E32\u67D3`),n.width!=null&&n.maxWidth!=null&&n.width>n.maxWidth&&t.push(`\u5217 "${e}" \u7684 width(${n.width}) \u5927\u4E8E maxWidth(${n.maxWidth})\uFF0C\u5C06\u6309 maxWidth \u6E32\u67D3`)}function va(n,e){let t=n.colId??n.field??`col_${e.leafIndex}`;e.seenIds.set(t,(e.seenIds.get(t)??0)+1),n.field&&!Ye(n.field)&&e.issues.push(`\u5217 "${t}" \u7684 field \u8DEF\u5F84\u4E0D\u5B89\u5168\u6216\u65E0\u6548\uFF0C\u5DF2\u7981\u6B62\u8BFB\u53D6\u548C\u5199\u5165`),ga(n)||e.issues.push(`\u5217 "${t}" \u65E2\u65E0 field \u4E5F\u65E0 valueGetter\uFF0C\u5C06\u59CB\u7EC8\u663E\u793A\u7A7A\u503C\uFF08\u7EAF\u5DE5\u5177\u5217\u8BF7\u5FFD\u7565\u6B64\u63D0\u793A\uFF09`),ya(n,t,e.issues)}function Kn(n,e){for(let t of n){if(pe(t)){!Array.isArray(t.children)||t.children.length===0?e.issues.push(`\u5217\u5206\u7EC4 "${t.headerName??t.groupId??"?"}" \u7684 children \u4E3A\u7A7A`):Kn(t.children,e);continue}e.leafIndex++,va(t,e)}}function Un(n){if(!n||n.length===0)return[];let e={issues:[],seenIds:new Map,leafIndex:0};Kn(n,e);for(let[t,r]of e.seenIds)r>1&&e.issues.push(`\u5B58\u5728 ${r} \u4E2A\u91CD\u590D\u7684 colId/field "${t}"\uFF0C\u5DF2\u81EA\u52A8\u52A0\u540E\u7F00\u533A\u5206\uFF0C\u5EFA\u8BAE\u663E\u5F0F\u547D\u540D colId`);return e.issues}var jn=new Set([...Fr,...Hr]);function ba(n,e){if(n===e)return 0;if(n.length===0)return e.length;if(e.length===0)return n.length;let t=Array.from({length:e.length+1},(r,i)=>i);for(let r=1;r<=n.length;r++){let i=[r];for(let o=1;o<=e.length;o++)i[o]=Math.min(i[o-1]+1,t[o]+1,t[o-1]+(n[r-1]===e[o-1]?0:1));t=i}return t[e.length]}function wa(n){let e,t=Number.POSITIVE_INFINITY;for(let i of jn){let o=ba(n.toLowerCase(),i.toLowerCase());o<t&&(t=o,e=i)}let r=Math.max(2,Math.floor(n.length*.3));return t<=r?e:void 0}function Ca(n){let e=[];return n.rowKey!=null&&typeof n.rowKey!="string"&&typeof n.rowKey!="function"&&e.push({code:"INVALID_OPTION_VALUE",option:"rowKey",message:"rowKey \u5FC5\u987B\u662F\u5B57\u6BB5\u8DEF\u5F84\u6216\u8FD4\u56DE\u7A33\u5B9A\u4E1A\u52A1\u4E3B\u952E\u7684\u51FD\u6570"}),n.domLayout==="autoHeight"&&n.datasource!=null&&e.push({code:"OPTION_CONFLICT",option:"domLayout",message:"autoHeight \u4F1A\u6E32\u67D3\u5168\u90E8\u5DF2\u52A0\u8F7D\u884C\uFF0C\u4E0D\u9002\u7528\u4E8E datasource \u65E0\u9650\u6EDA\u52A8\u6A21\u5F0F"}),e.push(...Ta(n)),n.enableColumnResize!=null&&typeof n.enableColumnResize!="boolean"&&e.push({code:"INVALID_OPTION_VALUE",option:"enableColumnResize",message:"enableColumnResize \u5FC5\u987B\u662F boolean\uFF1B\u672A\u914D\u7F6E\u65F6\u9ED8\u8BA4\u5173\u95ED"}),e}function Ta(n){if(n.datasourceMode!=="block")return[];let e=[];return n.datasource==null&&e.push({code:"OPTION_CONFLICT",option:"datasourceMode",message:"datasourceMode='block' requires a datasource"}),typeof n.getRowHeight=="function"&&e.push({code:"OPTION_CONFLICT",option:"getRowHeight",message:"Random-access block rows require fixed rowHeight so unloaded offsets remain deterministic"}),n.masterDetail===!0&&e.push({code:"OPTION_CONFLICT",option:"masterDetail",message:"masterDetail is not supported by the sparse random-access block row model"}),n.treeData===!0&&e.push({code:"OPTION_CONFLICT",option:"treeData",message:"treeData requires the local/tree row model and cannot use random-access blocks"}),qn(n)||e.push({code:"MISSING_STABLE_ROW_ID",option:"rowKey",message:"Random-access blocks require rowKey to preserve selection and identity after eviction"}),e}function qn(n){return n.rowKey!=null}function Da(n){let e=new Set(["enableColumnResize","pagination","rowKey"]),t=[];for(let r of Fr){if(e.has(r)||!Object.prototype.hasOwnProperty.call(n,r))continue;let i=n[r],o=Oe[r];Vr(i,o)||t.push({code:"INVALID_OPTION_VALUE",option:r,message:`${r} \u503C\u7C7B\u578B\u65E0\u6548\uFF0C\u671F\u671B ${o}`})}return t}function xa(n){let e=[];for(let t of Object.keys(n)){if(jn.has(t))continue;let r=wa(t);e.push({code:"UNKNOWN_OPTION",option:t,...r?{suggestion:r}:{},message:r?`\u672A\u77E5 GridOption "${t}"\uFF0C\u662F\u5426\u60F3\u4F7F\u7528 "${r}"\uFF1F`:`\u672A\u77E5 GridOption "${t}"\uFF0C\u8BE5\u503C\u4E0D\u4F1A\u751F\u6548`})}return e}function Ea(n,e){if(e.mode!=="server")return[];let t=[];qn(n)||t.push({code:"MISSING_STABLE_ROW_ID",option:"rowKey",message:"\u670D\u52A1\u7AEF\u5206\u9875\u5EFA\u8BAE\u63D0\u4F9B\u7A33\u5B9A rowKey\uFF0C\u5426\u5219\u8DE8\u9875\u9009\u62E9\u4E0E\u589E\u91CF\u66F4\u65B0\u65E0\u6CD5\u53EF\u9760\u4FDD\u6301"});let r=e.total;return r!==void 0&&(typeof r!="number"||!Number.isFinite(r)||r<0)&&t.push({code:"INVALID_OPTION_VALUE",option:"pagination.total",message:"\u670D\u52A1\u7AEF\u5206\u9875 total \u5FC5\u987B\u662F\u975E\u8D1F\u6709\u9650\u6570"}),t}function Ra(n){let e=[],t=n.pagination;return t!=null&&typeof t!="boolean"&&typeof t!="object"&&e.push({code:"INVALID_OPTION_VALUE",option:"pagination",message:"pagination \u5FC5\u987B\u662F boolean \u6216\u914D\u7F6E\u5BF9\u8C61"}),n.datasource!=null&&t!==void 0&&t!==!1&&e.push({code:"OPTION_CONFLICT",option:"pagination",message:"datasource \u987A\u5E8F\u65E0\u9650\u6A21\u5F0F\u4E0E pagination \u4E0D\u80FD\u540C\u65F6\u542F\u7528\uFF1B\u666E\u901A\u670D\u52A1\u7AEF\u5206\u9875\u8BF7\u4F7F\u7528 pagination.mode='server'"}),t&&typeof t=="object"&&e.push(...Ea(n,t)),e}function Sa(n){return n.treeData!==!0||n.masterDetail!==!0?[]:[{code:"OPTION_CONFLICT",option:"masterDetail",message:"treeData \u4E0E masterDetail \u4E0D\u80FD\u540C\u65F6\u542F\u7528\uFF0C\u4E3B\u4ECE\u660E\u7EC6\u5C06\u88AB\u5FFD\u7565"}]}function tr(n){let e=n,t=xa(e);return t.push(...Ra(e)),t.push(...Sa(e)),t.push(...Da(e)),t.push(...Ca(e)),t}function Yn(n){let e=/^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:[-+].*)?$/.exec(n.trim());return e?[Number(e[1]),Number(e[2]??0),Number(e[3]??0)]:null}function qr(n,e){for(let t=0;t<3;t++)if(n[t]!==e[t])return n[t]<e[t]?-1:1;return 0}function Ma(n){return n[0]>0?[n[0]+1,0,0]:n[1]>0?[0,n[1]+1,0]:[0,0,n[2]+1]}function Ia(n,e){if(e==="*"||e.toLowerCase()==="latest")return!0;let t=/^(\^|~|>=|<=|>|<|=)?\s*(.+)$/.exec(e);if(!t)return!1;let r=Yn(t[2]);if(!r)return!1;let i=qr(n,r);switch(t[1]??"="){case">=":return i>=0;case"<=":return i<=0;case">":return i>0;case"<":return i<0;case"^":return i>=0&&qr(n,Ma(r))<0;case"~":return i>=0&&qr(n,[r[0],r[1]+1,0])<0;default:return i===0}}function Xn(n,e){if(!e?.trim())return!0;let t=n?Yn(n):null;return t?e.split("||").some(r=>{let i=r.trim().split(/\s+/).filter(Boolean);return i.length>0&&i.every(o=>Ia(t,o))}):!1}function Aa(n){return[...new Set((n??[]).map(e=>e.trim()).filter(Boolean))]}function rr(n){let e=new Map;for(let t of n??[]){let r=(typeof t=="string"?t:t?.key??"").trim();if(!r||e.has(r))continue;let i=typeof t=="object"?t.version?.trim():void 0;e.set(r,{key:r,...i?{version:i}:{}})}return[...e.values()]}function ir(n){let e=[],t=new Map;for(let l of n){let d=typeof l?.key=="string"?l.key.trim():"";if(!d){e.push({code:"INVALID_FEATURE_KEY",message:"GridFeature.key must be a non-empty string"});continue}if(t.has(d)){e.push({code:"DUPLICATE_FEATURE",feature:d,message:`Duplicate GridFeature key: ${d}`});continue}t.set(d,l)}let r=new Set;for(let[l,d]of t){for(let u of rr(d.requires)){let c=t.get(u.key);c?Xn(c.version,u.version)||(r.add(l),e.push({code:"UNSUPPORTED_FEATURE_VERSION",feature:l,dependency:u.key,message:`GridFeature "${l}" requires "${u.key}" ${u.version}, received ${c.version??"unversioned"}`})):(r.add(l),e.push({code:"MISSING_FEATURE_DEPENDENCY",feature:l,dependency:u.key,message:`GridFeature "${l}" requires missing feature "${u.key}"`}))}for(let u of Aa(d.conflicts))if(t.has(u)){r.add(l),e.push({code:"FEATURE_CONFLICT",feature:l,dependency:u,message:`GridFeature "${l}" conflicts with "${u}"`});break}}let i=[],o=new Set,s=new Set,a=l=>{if(s.has(l))return!r.has(l);if(o.has(l))return r.add(l),e.push({code:"FEATURE_CYCLE",feature:l,message:`GridFeature dependency cycle includes "${l}"`}),!1;let d=t.get(l);if(!d||r.has(l))return!1;o.add(l);let u=!0;for(let c of rr(d.requires))a(c.key)||(u=!1);return o.delete(l),s.add(l),u?(i.push(d),!0):(r.add(l),!1)};for(let l of t.keys())a(l);return{features:i.filter(l=>!r.has(l.key.trim())),issues:e}}var ka=["datasource","treeData"],La=["columnState.","gridState."],Ga=new Set(["valueFormatter","cellStyle","cellClass"]),Pa=new Set(["selectionChanged","sortChanged","filterChanged","columnMoved","columnVisibilityChanged","paginationChanged","detailToggled"]),Na=0,nr=class{constructor(e,t){this.E=!1;this.pm=0;this.Ci=0;this.kd=!1;this.js="";this.R=new Ve(e=>console.error("[mach-table] resource cleanup error",e));this.activeFeatures=new Map;this.Od=0;this.Ti=0;this.recentErrors=[];this.Et=null;this.Fd=0;this.Di=null;this.qs=0;this.xi=null;this.Ys=!1;this.Xs=null;this.Wd=null;this.Kn=new Set;let r;this.Ld=new Promise(i=>{r=i}),this.Gd=r,this.gridId=++Na,this.r=yi(t),this.ce=new qe((i,o)=>{o==="gridError"?console.error("[mach-table] error in gridError listener",i):this.reportError(i,"eventBus.listener",{eventType:o})});try{if(this.Fl(t.dataProcessor),this.n=new nt(this),this.i=this.R.A(new ht(this)),this.m=new pt(this),this.o=this.R.A(new Ht(this)),this._=this.R.A(new zt(this)),this.a=this.R.A(new qt(this)),this.ci=this.R.A(new ft(this)),this.Rn=this.R.A(new mt(this)),this.Ko=this.R.A(new Tt(this)),this.l=this.R.A(new Rt(this)),this.W=new Et(this),this.B=new Lt(this),this.oe=this.R.A(new Nt),this.Cr=this.R.A(new Ot(i=>this.fm(i))),this.gs=this.R.A(new St(this)),this.columnMenu=this.R.A(new Mt(this)),this.zs=this.R.A(new It(this)),this.Nn=this.R.A(new At(this)),this.Dn=this.R.A(new kt(this)),this.Dr=this.R.A(new Xt(this)),this.he=this.R.A(new Jt(this)),this.ae=this.R.A(new Yt(this)),this.qe=this.R.A(new Zt(this)),this.api=On(this),this.zt=new je(this),this.V=this.R.A(new Gt(this)),this.R.add(()=>this.Hd()),this.V.init(),this.o.init(e,this.r),this.Dn.init(),this.a.init(),this.Ko.init(),this.Nn.init(),this.Dr.init(),this.ae.init(),this.qe.init(),this.he.init(),this.i.Aa(this.r.paginationPage,this.r.paginationPageSize),this.n.Ri(this.r.columnDefs),this.i.kt(this.r.advancedFilterModel),this.i.dr(this.r.quickFilterText),this.xn(),this.Vd(this.r.columnDefs),this.us(t),this._.li(),this.r.datasource?this.i.Vi().catch(()=>{}):this.i.ot(this.r.rowData),this.r.initialState&&this.api.state.apply(this.r.initialState,{emitEvents:!1}),this.cs(),this.Te(),this.he.setData(this.r.pinnedTopRowData,this.r.pinnedBottomRowData),this.Hl(this.r.features),this.E)return;this.Ci=requestAnimationFrame(()=>{this.Ci=0,this.E||this.emit("gridReady",{}),this.Bd()})}catch(i){throw this.api&&this.reportError(i,"grid.constructor"),this.destroy(),i}}Fl(e){if(e===this.Pd)return!1;let t=++this.Od,r=typeof e=="function"?e():e;if(this.E||t!==this.Od)return r?.destroy?.(),!1;let i=this.Nd;return this.Pd=e,r===this.r.dataProcessor&&i?!1:(this.r.dataProcessor=r,this.Nd=r?this.R.add(()=>r.destroy?.()):void 0,i?.(),!0)}whenReady(){return this.Ld}Bd(){this.kd||(this.kd=!0,this.Gd(this.api))}$d(e){return this.r.components?.cellRenderers?.[e]??Mi[e]}Fc(e){return this.r.components?.cellEditors?.[e]}mm(e){return rr(e.requires).map(t=>t.key).find(t=>!this.activeFeatures.has(t))}Hl(e){let t=this.Ti+1;if(this.Hd(),this.E||this.Ti!==t)return;let r=ir(e??[]);for(let i of r.issues)this.reportError(new Error(i.message),"feature.manifest",{code:i.code,...i.feature?{key:i.feature}:{},...i.dependency?{dependency:i.dependency}:{}});for(let i of r.features){if(this.E||this.Ti!==t)return;let o=i.key.trim(),s=this.mm(i);if(s){this.reportError(new Error(`GridFeature "${o}" dependency "${s}" did not initialise`),"feature.manifest",{code:"FEATURE_DEPENDENCY_SETUP_FAILED",key:o,dependency:s});continue}let a=new Ve(u=>this.reportError(u,"feature.cleanup",{key:o})),l=u=>a.add(u),d={api:this.api,root:this.o.root,getOptions:()=>this.r,addEventListener:(u,c)=>l(this.ce.on(u,c)),onCleanup:u=>{l(u)},addManagedDomListener:(u,c,h,p)=>(u.addEventListener(c,h,p),l(()=>u.removeEventListener(c,h,p))),setManagedTimeout:(u,c)=>{let h=setTimeout(()=>{p(),u()},Math.max(0,c)),p=l(()=>clearTimeout(h));return h},createAbortController:()=>{let u=new AbortController;return l(()=>u.abort()),u},reportError:(u,c,h)=>this.reportError(u,`feature.${c}`,h)};try{let u=i.setup(d);if(typeof u=="function"&&l(u),this.E||this.Ti!==t){this._d(o,{feature:i,scope:a});return}this.activeFeatures.set(o,{feature:i,scope:a})}catch(u){a.dispose(),this.reportError(u,"feature.setup",{key:o})}}}Hd(){this.Ti++;let e=[...this.activeFeatures.entries()].reverse();this.activeFeatures.clear();for(let[t,r]of e)this._d(t,r)}_d(e,t){t.scope.dispose();try{t.feature.destroy?.()}catch(r){this.reportError(r,"feature.destroy",{key:e})}}s(){return this.E}suspend(){this.Ce(),this.api.editing.stop({cancel:!0}),this.gs.close(),this.columnMenu.close(),this.zs.close(),this.Nn.hide(),this.ci.Ot(),this.Rn.destroy(),this.a.suspend(),en(this.o.root),Di(this.o.root);let e=document.activeElement;e instanceof HTMLElement&&this.o.root.contains(e)&&e.blur()}ar(){return++this.pm}d(e,t){let r=t.colDef;if(r.valueGetter)try{return r.valueGetter({api:this.api,colDef:r,column:t,node:e,data:e.data})}catch(i){this.reportError(i,"valueGetter",{colId:t.id,rowId:e.id});return}if(r.field)return H(e.data,r.field)}T(e){return this.r.locale[e]??D[e]}Ji(e,t,r,i){let o=t.colDef;if(o.valueSetter)try{return o.valueSetter({oldValue:i,newValue:r,data:e.data,node:e,colDef:o,column:t,api:this.api})}catch(s){return this.reportError(s,"valueSetter",{colId:t.id,rowId:e.id}),!1}return o.field?ce(e.data,o.field,r):!1}Oo(e,t,r,i){this.a.Wi(e),this.a.fl([e.rowIndex],[t.id]),this.B.Xo({nodeId:e.id,columnId:t.id,oldValue:r,newValue:i}),this.emit("cellValueChanged",{oldValue:r,newValue:i,rowNode:e,rowIndex:e.rowIndex,column:t,colDef:t.colDef,data:e.data})}Ja(e){let r=this.n.u().slice(e.c1,e.c2+1).filter(o=>!o.isAutoRowNumber),i=[];for(let o=e.r1;o<=e.r2;o++){let s=this.i.f(o);i.push(r.map(a=>!s||s.isDetail||s.isGroup?"":Pe(this,s,a,"clipboard")))}return yt(i)}cl(){let e=this.a.Xr();return e?Ct(this.Ja(e)):Promise.resolve(!1)}ko(e){if(this.E)return;let t=this.n.u(),r=[];for(let i=e.r1;i<=e.r2;i++){let o=this.i.f(i);if(!(!o||o.isDetail||o.isGroup))for(let s=e.c1;s<=e.c2;s++){let a=t[s];!a||!$(a)||a.colDef.rowDrag||r.push({node:o,column:a,oldValue:this.d(o,a),newValue:null})}}this.di(r)}di(e){this.W.Lc(e)}Ce(){this.W?.Ic()}Za(e,t,r){if(this.E)return;let i=vt(e);if(i.length===0)return;let o=this.n.u(),s=this.i.P(),a=[],l=t;for(let d of i){let u=this.gm(l,s);if(!u)break;this.ym(u.node,d,o,r,a),l=u.index+1}this.di(a)}gm(e,t){for(let r=e;r<t;r++){let i=this.i.f(r);if(i&&!i.isDetail&&!i.isGroup)return{index:r,node:i}}return null}vm(e,t){let r=t;for(;r<e.length;){let i=e[r];if($(i)&&!i.colDef.rowDrag)break;r++}return r}ym(e,t,r,i,o){let s=i,a=o.length;for(let l of t){if(s=this.vm(r,s),s>=r.length)return;let d=r[s];if(!this.l.U(e,d)){s++;continue}let u=this.d(e,d);try{let c=d.colDef.valueParser?le(this,e,d,l,"clipboard",u):gt(l,typeof u=="number"||d.colDef.cellEditor==="number");o.push({node:e,column:d,oldValue:u,newValue:c})}catch(c){o.splice(a),this.reportError(c,"validate",{rowId:e.id,colId:d.id});return}s++}}Zc(){let e=this.a.Lo();if(!e)return Promise.resolve();let t=this.W.Po(),r=this.i.f(e.row),i=this.n.u()[e.colIdx];if(!r||!i)return Promise.resolve();let o=this.d(r,i),s=this.W.Jr([{node:r,column:i,oldValue:o,newValue:o}]);try{if(typeof navigator<"u"&&navigator.clipboard?.readText)return navigator.clipboard.readText().then(a=>{let l=this.a.Lo();a&&t()&&s()&&l?.row===e.row&&l.colIdx===e.colIdx&&this.i.f(e.row)===r&&this.n.u()[e.colIdx]===i&&this.Za(a,e.row,e.colIdx)}).catch(()=>{})}catch{}return Promise.resolve()}emit(e,t,r=!0){let i={type:e,api:this.api,...t};this.ce.emit(e,i);let o="on"+e.charAt(0).toUpperCase()+e.slice(1),s=this.r[o];if(typeof s=="function")try{s(i)}catch(l){e==="gridError"?console.error("[mach-table] error in onGridError",l):this.reportError(l,`eventHandler.${String(o)}`,{eventType:e})}let a=e==="columnResized"&&!!i.finished;return r&&(a||Pa.has(e))&&this.Tr(),i}reportError(e,t,r){let i=this.bm(t,e),o=e instanceof Error?e.message:String(e);this.recentErrors.push({code:i,source:t,message:o,timestamp:Date.now(),...r?{context:r}:{}}),this.recentErrors.length>50&&this.recentErrors.splice(0,this.recentErrors.length-50),console.error(`[mach-table] ${i} (${t})`,e),!this.E&&this.emit("gridError",{code:i,error:e,source:t,context:r})}bm(e,t){if(ka.some(i=>e.startsWith(i)))return"DATA_SOURCE_ERROR";let r=t instanceof Error?t.message:String(t);return e==="rowKey"||r.includes("Duplicate row id")?"DATA_INTEGRITY_ERROR":e==="validate"?"VALIDATION_ERROR":e.toLowerCase().includes("renderer")||Ga.has(e)?"RENDERER_ERROR":e.toLowerCase().includes("editor")||e==="editable"?"EDITOR_ERROR":e.startsWith("feature.")?"FEATURE_ERROR":La.some(i=>e.startsWith(i))?"STATE_ERROR":e.startsWith("eventBus.")||e.startsWith("eventHandler.")?"EVENT_HANDLER_ERROR":"GRID_ERROR"}Oh(){return{gridId:this.gridId,version:Be,destroyed:this.E,infinite:this.i.g,loading:this.i.ou()||this.r.loading,rowCount:this.i.or(),renderedRowCount:this.o.Fe.querySelectorAll(".mach-row[data-index]").length,columnCount:this.n.Z().length,selectedRowCount:this.m.Gt().length,dirtyRowCount:this.V.getDirtyRowIds().length,activeFeatures:[...this.activeFeatures].map(([e,t])=>({key:e,...t.feature.version?{version:t.feature.version}:{}})),performance:this.oe.snapshot(),updates:this.Cr.snapshot(),recentErrors:this.recentErrors.map(e=>({...e,...e.context?{context:{...e.context}}:{}}))}}Ii(e,t){this.n.Ii(e,t),this.Or()}Or(){if(this._.hs(),this.emit("sortChanged",{sortModel:this.n.Q()}),this.i.g){this.i.At();return}this.i.C(),this.h({data:!0})}Hc(e,t){let r=this.i.De();if(t?r[e.id]=t:delete r[e.id],this.i.lr(r),this._.vn(),this.emit("filterChanged",{filterModel:this.i.De(),advancedFilterModel:this.i.It()}),this.i.g){this.i.At();return}this.i.C(),this.h({data:!0})}Bh(){if(this.emit("filterChanged",{filterModel:this.i.De(),advancedFilterModel:this.i.It()}),this.i.g){this.i.At();return}this.i.C(),this.h({data:!0})}Nr(e,t){this.n.Nr(e,t)&&(this._t(),this.emit("columnMoved",{colId:e,toIndex:t}))}Ui(e){return this.i.Ui(e)}Ua(e,t){this.emit("columnResized",{colId:e.id,width:e.currentWidth,finished:t})}hr(e){if(!(this.E||e.length===0))for(let t of e){if(this.E)break;this.Ua(t,!0)}}cs(e=!1,t=!1){let r=this.qs,i=this.Di,o=this.n.Qn().length>0;if(e){if(i==null||!o)return;if(i!==r){this.Di=null,this.Tr();return}}this.Di=null;let s=++this.Fd,a=this.r.persistence;if(!a)return;let{key:l,store:d,sections:u}=a;if(!o&&(!u||u.some(p=>p==="columns"||p==="sort"||p==="filter"))){this.Di=r;return}let c;try{c=d?d.load(l):er(l)}catch(p){this.reportError(p,"gridState.load");return}let h=(p,m=!1)=>{if(this.E||s!==this.Fd||r!==this.qs||!p)return;let g=this.xi;this.xi=m?"beforeRows":"normal";try{this.api.state.apply(p,{emitEvents:!1,sections:u})}finally{this.xi=g}};c&&typeof c.then=="function"?Promise.resolve(c).then(h).catch(p=>this.reportError(p,"gridState.load")):h(c,t)}Cp(){return this.xi==="beforeRows"}Tr(){let e=this.r.persistence;if(!(!e||this.E||this.xi)&&(this.qs++,this.Di==null)){if(this.Et&&clearTimeout(this.Et),e.debounceMs===0){this.Et=null,this.Js();return}this.Et=setTimeout(()=>{this.Et=null,this.Js()},e.debounceMs)}}Js(){let e=this.r.persistence;if(!e||this.E)return;let{key:t,store:r,sections:i}=e,o=this.api.state.get(),s=i?vn(o,i):o,a={key:t,...r?{store:r}:{},state:s};if(this.Ys){this.Xs=a;return}this.zd(a)}zd(e){try{let t=e.store?e.store.save(e.key,e.state):Qt(e.key,e.state);if(!t||typeof t.then!="function")return;this.Ys=!0,Promise.resolve(t).catch(r=>this.reportError(r,"gridState.save")).finally(()=>{this.Ys=!1;let r=this.Xs;this.Xs=null,r&&this.zd(r)})}catch(t){this.reportError(t,"gridState.save")}}ph(){let e=f("div","mach-empty mach-empty--error"),t=f("div","mach-empty__title");t.textContent=this.T("requestFailed");let r=f("div","mach-empty__hint");return r.textContent=this.T("requestFailedHint"),e.append(t,r),e}ch(){let e=f("div","mach-loading"),t=f("div","mach-loading__visual");t.setAttribute("aria-hidden","true");for(let s=0;s<4;s+=1){let a=f("span","mach-loading__row");t.appendChild(a)}let r=f("div","mach-loading__status"),i=f("span","mach-spinner mach-loading__spinner");i.setAttribute("aria-hidden","true");let o=f("span","mach-loading__label");return o.textContent=this.T("loading"),r.append(i,o),e.append(t,r),e}hh(){let e=f("div","mach-empty");e.innerHTML='<svg class="mach-empty__icon" viewBox="0 0 96 84" aria-hidden="true"><rect stroke-opacity=".3" x="8" y="6" width="76" height="66" rx="9"/><path fill="#8b98ff" opacity=".12" stroke="none" d="M17 6H75Q84 6 84 15V26H8V15Q8 6 17 6Z"/><path stroke="var(--mach-body-fg)" opacity=".06" d="M8 26h76M38 26v46M61 26v46M8 42h76M8 57h76"/><path stroke-width="5" opacity=".5" d="M19 15h12m17 0h7m15 0h7"/><path stroke="var(--mach-body-fg)" opacity=".06" stroke-width="4" d="M19 34h12m14 0h8m15 0h8M19 49h12m14 0h8m15 0h8M19 64h12m14 0h8"/><circle stroke-opacity=".3" cx="72" cy="55" r="19"/><circle cx="70" cy="53" r="9"/><path d="m77 60 6 6m-16-16 6 6m0-6-6 6"/></svg>';let t=f("div","mach-empty__title");t.textContent=this.T("emptyRows");let r=f("div","mach-empty__hint");return r.textContent=this.T("emptyRowsHint"),e.append(t,r),e}us(e){if(!(this.r.suppressWarnings||this.E)){if(e)for(let t of tr(e)){let r=`${t.code}:${t.option??""}:${t.message}`;this.Kn.has(r)||(this.Kn.add(r),console.warn(`[mach-table:${t.code}] ${t.message}`))}this.r.treeData&&this.n.Qe().length>0&&console.warn("[mach-table] treeData \u4E0E rowGroup \u4E0D\u652F\u6301\u540C\u65F6\u542F\u7528\uFF0C\u884C\u5206\u7EC4\u5DF2\u88AB\u5FFD\u7565")}}Vd(e){if(!(this.r.suppressWarnings||this.E)&&this.Wd!==e){this.Wd=e;for(let t of Un(e))this.Kn.has(t)||(this.Kn.add(t),console.warn(`[mach-table] ${t}`))}}_t(){this.zt.Lr=!0,this.Cr.Cl({columns:!0})}h(e){(e.data||e.cells)&&(this.zt.Lr=!0),this.Cr.Cl(e)}Pl(e){return this.Cr.batch(e)}fm(e){this.E||(e.columns?this.wm():(e.header&&this._.li(),e.pool?this.a.ds():e.layout&&this.Te()),this.Cm(e),e.data&&!e.pool&&!e.columns?this.a.qf():e.cells&&this.a.refreshCells(e.cells===!0?void 0:e.cells),e.pinned&&this.he.refresh(),e.summary&&this.ae.refresh(),e.overlays&&this.a.Ns())}Cm(e){!(e.data||e.cells)||e.layout||e.columns||e.pool||this.zt.jn()&&this.je()}wm(){this.us(),this.Vd(this.n.Qn()),this.a.Tn(),this._.li(),this.a.ds(),this.Te(),this.he.Me(),this.ae.refresh(),this.emit("displayedColumnsChanged",{})}Te(){if(this.E)return;let e=this.oe.start();this.xn(),this.zt.jn(),this.n.ta(this.o.as());let t=this.n.u().map(r=>`${r.id}:${r.currentWidth}`).join("|");this.js&&t!==this.js&&this.a.Tn(),this.js=t,this.o.root.setAttribute("aria-colcount",String(this.n.u().length)),this._.bt(),this.a.Te(),this.he.bt(),this.ae.refresh(),this.oe.dh(e)}xn(){if(!this.o.root)return;let e=this.r.treeData||this.n.Qe().length>0;this.o.root.setAttribute("role",e?"treegrid":"grid"),this.r.rowSelection==="multiple"?this.o.root.setAttribute("aria-multiselectable","true"):this.o.root.removeAttribute("aria-multiselectable"),this.n.u().some(r=>!!r.colDef.editable)?this.o.root.removeAttribute("aria-readonly"):this.o.root.setAttribute("aria-readonly","true")}je(e=!0){this.E||(this.zt.jn(),this.n.ta(this.o.as()),e&&this.a.Tn(),this._.bt(),this.a.Cn(),this.a.Ps(),this.a.ui(!0),this.he.bt(),this.ae.refresh())}destroy(){if(!this.E){if(this.Et&&(clearTimeout(this.Et),this.Et=null,this.Js()),this.E=!0,this.Ce(),this.Ci&&cancelAnimationFrame(this.Ci),this.Ci=0,this.api){this.Bd();try{this.emit("gridDestroyed",{})}catch(e){console.error("[mach-table] grid destroy event",e)}}this.R.dispose(),this.ce.clear()}}};function Jn(n,e={}){if(!n)throw new Error("[mach-table] createGrid requires a container element");if(typeof document>"u")throw new Error("[mach-table] createGrid can only be used in a browser environment");return new nr(n,e).api}function Oa(n){return n.mode==="allMatching"?{mode:"allMatching",excludedKeys:[...n.excludedKeys]}:{mode:"explicit",selectedKeys:[...n.selectedKeys]}}function Zn(n,e){if(e.scope!=="filtered"&&e.scope!=="selected")throw new TypeError("[MachTable] Remote export scope must be filtered or selected.");let t=n.state.get();return{version:1,scope:e.scope,columnIds:t.columns.filter(r=>!r.hide).map(r=>r.colId),sortModel:t.sortModel.map(r=>({...r})),filterModel:Y(t.filterModel),advancedFilterModel:O(t.advancedFilterModel),quickFilterText:t.quickFilterText,...e.scope==="selected"?{selection:Oa(e.selection??{mode:"explicit",selectedKeys:t.selectedRowIds})}:{}}}function Fa(n){return n.value===!0?"\u662F":n.value===!1?"\u5426":""}function Ha(n){return e=>{if(e.value==null||e.value==="")return"";let t=e.value instanceof Date?e.value.toISOString():String(e.value);return n==="datetime"?t.slice(0,16).replace("T"," "):t.slice(0,10)}}function Va(n){return e=>{if(e.value==null)return"";let t=n.find(r=>r.value===e.value);return t?t.label:String(e.value)}}function Ba(n,e){return n.filterable===!1?!1:e==="number"?"number":e==="date"?"date":e==="select"||e==="boolean"?"set":"text"}function _a(n,e,t){if(t==="date"){n.valueFormatter=Ha(e.format);return}if(t==="boolean"){n.valueFormatter=Fa;return}if(t!=="select")return;let r=e.options??[];n.valueFormatter=Va(r),e.editable&&(n.cellEditor="select",n.cellEditorParams={options:r})}function Qn(n){let e=n.type??"string",t={colId:n.field,field:n.field,headerName:n.title??n.field,width:n.width,minWidth:n.minWidth,maxWidth:n.maxWidth,flex:n.flex,pinned:n.pinned??void 0,hide:n.hidden??!1,editable:n.editable??!1,sortable:n.sortable??!0,resizable:n.resizable??!0,filter:Ba(n,e),cellClass:n.cellClass};return _a(t,n,e),t}function eo(n){let e=new Map(n.fields.map(s=>[s.field,s])),t=n.groups??[],r=new Set(t.flatMap(s=>s.fields)),i=new Set,o=[];for(let s of n.fields)i.has(s.field)||r.has(s.field)||(o.push(Qn(s)),i.add(s.field));for(let s of t){let a=[];for(let l of s.fields){let d=e.get(l);!d||i.has(l)||(a.push(Qn(d)),i.add(l))}a.length>0&&o.push({headerName:s.title,children:a})}return o}function G(n){let e=n();return e&&!e.isDestroyed()?e:null}function to(n){let e=()=>n.getApi();return{search(t){G(e)?.filtering.setQuickText(t)},async refresh(){if(n.reload){await n.reload();return}let t=G(e);t&&(t.rows.isRemote()?await t.rows.reload():t.view.refreshCells())},openColumns(t){G(e)?.columns.openWorkbench(t)},setDensity(t){G(e)?.updateOptions({size:t})},selectAll(t=!0){G(e)?.selection.selectAll(t)},clearSelection(){let t=G(e);t?.selection.clear(),t?.selection.clearRange()},resetColumns(){G(e)?.columns.resetState()},resetView(){G(e)?.batch(t=>{t.selection.clear(),t.selection.clearRange(),t.filtering.setModel(null),t.filtering.setAdvancedModel(null),t.sorting.setModel(null),t.pagination.setPage(1),t.columns.resetState()})},undo(){return G(e)?.editing.undo()??!1},redo(){return G(e)?.editing.redo()??!1},canUndo(){return G(e)?.editing.canUndo()??!1},canRedo(){return G(e)?.editing.canRedo()??!1},exportCsv(t="mach-table.csv"){let r=G(e);return r?Ft(t,r.io.exportCsv({prependBOM:!0}),"text/csv;charset=utf-8"):!1},async toggleFullscreen(){if(typeof document>"u")return!1;if(document.fullscreenElement)return await document.exitFullscreen?.(),!1;let r=G(e)?.view.getRoot(),i=n.getFullscreenElement?.()??r?.parentElement??r;return i?.requestFullscreen?(await i.requestFullscreen(),!0):!1}}}function ro(){return{accessor:(n,e={})=>({...e,field:n}),display:n=>({...n}),group:n=>({...n,children:[...n.children]})}}function io(n){return[...n]}function Yr(n,e){return e===void 0?n:typeof e!="object"||e===null||typeof n!="object"||n===null?e:{...n,...e}}function za(n,e){return typeof n!="function"?e:typeof e!="function"?n:(...t)=>{let r;try{n(...t)}catch(i){r=i}try{e(...t)}catch(i){r??(r=i)}if(r!==void 0)throw r}}function Wa(n,e){if(!(!n.components&&!e.components))return{cellRenderers:{...n.components?.cellRenderers,...e.components?.cellRenderers},cellEditors:{...n.components?.cellEditors,...e.components?.cellEditors}}}function $a(n,e){if(!n.columnTypes&&!e.columnTypes)return;let t={},r=new Set([...Object.keys(n.columnTypes??{}),...Object.keys(e.columnTypes??{})]);for(let i of r)t[i]={...n.columnTypes?.[i],...e.columnTypes?.[i]};return t}function Ka(n,e,t){for(let r of new Set([...Object.keys(e),...Object.keys(t)])){if(!/^on[A-Z]/.test(r))continue;let i=e[r],o=t[r];typeof i!="function"||typeof o!="function"||(n[r]=za(i,o))}}function Ua(n,e){let t={...n,...e,features:e.features??n.features};(n.defaultColDef||e.defaultColDef)&&(t.defaultColDef={...n.defaultColDef,...e.defaultColDef}),(n.locale||e.locale)&&(t.locale={...n.locale,...e.locale});let r=Wa(n,e);r&&(t.components=r);let i=$a(n,e);return i&&(t.columnTypes=i),(n.aggFuncs||e.aggFuncs)&&(t.aggFuncs={...n.aggFuncs,...e.aggFuncs}),t.pagination=Yr(n.pagination,e.pagination),t.statusBar=Yr(n.statusBar,e.statusBar),t.watermark=Yr(n.watermark,e.watermark),Ka(t,n,e),t}function Xr(...n){return n.reduce(Ua,{})}function no(n={}){return Xr({defaultColDef:{sortable:!0,resizable:!0,movable:!0,filter:!0},enableColumnResize:!0,rowSelection:"multiple",columnMenu:!0,contextMenu:!0,enableRangeSelection:!0,fillHandle:!0,statusBar:!0,stripedRows:!0},n)}function oo(n){return n}function so(n){return n}function ao(n){return n}function sr(n){return n!=null&&n!==""}function ja(n){if(!sr(n))return null;let e=typeof n=="number"?n:Number(n);return Number.isFinite(e)?e:null}function or(n,e){try{return new Intl.NumberFormat(n,e)}catch{return new Intl.NumberFormat(void 0,e)}}function lo(n,e){try{return new Intl.DateTimeFormat(n,e)}catch{let t={...e};return delete t.timeZone,new Intl.DateTimeFormat(void 0,t)}}function qa(n){if(!sr(n))return null;let e=n instanceof Date?n:new Date(n);return Number.isFinite(e.getTime())?e:null}function uo(n={}){let e=n.emptyText??"",t=n.invalidText??"\u2014",r=or(n.locale,{maximumFractionDigits:n.maximumFractionDigits??2}),i=or(n.locale,{maximumFractionDigits:0}),o=or(n.locale,{style:"currency",currency:n.currency??"CNY",currencyDisplay:n.currencyDisplay??"symbol",maximumFractionDigits:n.maximumFractionDigits??2}),s=or(n.locale,{style:"percent",maximumFractionDigits:n.maximumFractionDigits??2}),a=lo(n.locale,{year:"numeric",month:"2-digit",day:"2-digit",...n.timeZone?{timeZone:n.timeZone}:{}}),l=lo(n.locale,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,...n.timeZone?{timeZone:n.timeZone}:{}}),d=(c,h=1)=>({value:p})=>{if(!sr(p))return e;let m=ja(p);return m==null?t:c.format(m*h)},u=c=>({value:h})=>{if(!sr(h))return e;let p=qa(h);return p==null?t:c.format(p)};return Object.freeze({text:{align:"left",filter:"text"},number:{align:"right",filter:"number",cellEditor:"number",valueFormatter:d(r)},integer:{align:"right",filter:"number",cellEditor:"number",valueFormatter:d(i)},money:{align:"right",filter:"number",cellEditor:"number",valueFormatter:d(o)},percent:{align:"right",filter:"number",cellEditor:"number",valueFormatter:d(s)},percentage:{align:"right",filter:"number",cellEditor:"number",valueFormatter:d(s,.01)},date:{align:"center",filter:"date",cellEditor:"date",valueFormatter:u(a)},datetime:{align:"center",filter:"date",valueFormatter:u(l)},boolean:{align:"center",filter:"set",valueFormatter:({value:c})=>c===!0?n.trueText??"\u662F":c===!1?n.falseText??"\u5426":e},status:{filter:"set",cellRenderer:"statusTag"},link:{filter:"text",cellRenderer:"link"}})}function co(){try{return typeof localStorage>"u"?null:localStorage}catch{return null}}function ho(n){return typeof TextEncoder>"u"?n.length*2:new TextEncoder().encode(n).byteLength}function po(n){if(typeof n!="string")return null;let e=n.trim();return e&&e.length<=256?e:null}function ar(n){if(n==null||typeof n!="object")return null;let e=n;if(e.version!==1)return null;let t=z({version:2,columns:e.columns,sortModel:e.sortModel,filterModel:e.filterModel,advancedFilterModel:e.advancedFilterModel,quickFilterText:e.quickFilterText,pagination:{enabled:!0,page:1,pageSize:e.pageSize},selectedRowIds:[],expandedRowIds:[],expandedGroupIds:[]});return t?{version:1,columns:t.columns,sortModel:t.sortModel,filterModel:t.filterModel,advancedFilterModel:t.advancedFilterModel,quickFilterText:t.quickFilterText,pageSize:t.pagination.pageSize}:null}function we(n){if(n==null||typeof n!="object")return null;let e=n,t=po(e.id),r=typeof e.name=="string"?e.name.trim().slice(0,120):"",i=ar(e.state);if(e.schemaVersion!==1||!t||!r||!i)return null;let o=typeof e.createdAt=="number"&&Number.isFinite(e.createdAt)?e.createdAt:Date.now(),s=typeof e.updatedAt=="number"&&Number.isFinite(e.updatedAt)?e.updatedAt:o;return{schemaVersion:1,id:t,name:r,createdAt:o,updatedAt:s,state:i}}function Jr(n){let e=n.state.get();return{version:1,columns:e.columns,sortModel:e.sortModel,filterModel:e.filterModel,advancedFilterModel:e.advancedFilterModel,quickFilterText:e.quickFilterText,pageSize:e.pagination.pageSize}}function Zr(n,e,t={}){let r=ar(e);if(!r||n.isDestroyed())return!1;let i=n.state.get();return n.state.apply({...i,columns:r.columns,sortModel:r.sortModel,filterModel:r.filterModel,advancedFilterModel:r.advancedFilterModel,quickFilterText:r.quickFilterText,pagination:{...i.pagination,page:1,pageSize:r.pageSize}},{sections:["columns","sort","filter","pagination"],emitEvents:t.emitEvents}),!0}function Qr(n={}){let e=(n.namespace??"mach-table:views").replace(/:+$/,""),t=Math.max(1,Math.floor(n.maxViews??50)),r=Math.max(4096,Math.floor(n.maxBytes??512*1024)),i=l=>`${e}:${encodeURIComponent(l)}`,o=(l,d,u)=>{try{n.onError?.(l,d,u)}catch{}},s=l=>{let d=(n.storage??co())?.getItem(i(l));if(!d||ho(d)>r)return[];let u=JSON.parse(d);return u.schemaVersion!==1||!Array.isArray(u.views)?[]:u.views.flatMap(c=>{let h=we(c);return h?[h]:[]}).slice(0,t)},a=(l,d)=>{let u=JSON.stringify({schemaVersion:1,savedAt:Date.now(),views:d});if(ho(u)>r)throw new RangeError(`[MachTable] Saved views for "${l}" exceed ${r} bytes.`);let c=n.storage??co();if(!c)throw new Error("[MachTable] Saved view storage is unavailable.");c.setItem(i(l),u)};return{list(l){try{return s(l)}catch(d){return o(d,"list",l),[]}},save(l,d){try{let u=we(d);if(!u)throw new TypeError(`[MachTable] Invalid saved view for "${l}".`);let c=s(l).filter(h=>h.id!==u.id);c.unshift(u),a(l,c.slice(0,t))}catch(u){throw o(u,"save",l),u}},remove(l,d){try{a(l,s(l).filter(u=>u.id!==d))}catch(u){throw o(u,"remove",l),u}}}}function Ya(){try{if(typeof crypto<"u"&&crypto.randomUUID)return crypto.randomUUID()}catch{}return`view-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function fo(n,e){let t=e.scope.trim();if(!t||t.length>512)throw new TypeError("[MachTable] Grid view scope must contain between 1 and 512 characters.");let r=e.store??Qr(),i=async()=>(await r.list(t)).flatMap(s=>{let a=we(s);return a?[a]:[]}).sort((s,a)=>a.updatedAt-s.updatedAt);return{list:i,async save(o,s){let a=o.trim().slice(0,120);if(!a)throw new TypeError("[MachTable] Grid view name must be a non-empty string.");let l=po(s)??Ya(),d=(await i()).find(h=>h.id===l),u=Date.now(),c={schemaVersion:1,id:l,name:a,createdAt:d?.createdAt??u,updatedAt:u,state:Jr(n)};return await r.save(t,c),c},async apply(o,s){let a=typeof o=="string"?(await i()).find(d=>d.id===o):we(o),l=typeof o=="string"?o:"provided view";if(!a)throw new Error(`[MachTable] Grid view "${l}" was not found.`);if(!Zr(n,a.state,s))throw new Error(`[MachTable] Grid view "${a.id}" could not be applied.`);return a},async remove(o){await r.remove(t,o)}}}var Xa=Be;0&&(module.exports={BUILTIN_AGG_FUNCS,DEFAULT_LOCALE,EVENT_TYPES,LOCALE_EN,actionsColumn,advancedFilterCondition,advancedFilterGroup,applyGridViewState,buildColDefsFromSchema,captureGridViewState,clearGridState,createActionButtonsRenderer,createAggResolver,createBusinessColumnTypes,createColumnHelper,createEnterprisePreset,createGrid,createGridViewManager,createLocalGridStateStore,createLocalGridViewStore,createMachTableCommands,createMachTablePreset,createProgressBarRenderer,createRemoteExportRequest,createRowActionsRenderer,createStatusTagRenderer,defineColumns,defineGridOptions,defineMachTableConfig,defineMachTablePreset,describeFilter,downloadFile,dragColumn,escapeHtml,formatText,formatTwo,getByPath,indexColumn,isColDefGroup,isSafePath,linkRenderer,loadGridState,matchLocaleKey,normalizeAdvancedFilterModel,normalizeColumnFilter,normalizeFilterModel,normalizeGridState,normalizeGridViewState,normalizeSavedGridView,parseCsv,parseDelimited,parseTsv,resolveGridFeatures,resolveSaveConflict,resolveTagVariant,rowActionsColumn,sanitizeFormulaCell,saveGridState,selectionColumn,setByPath,toTsv,validateGridOptions,version});
1
+ "use strict";var ur=Object.defineProperty;var vo=Object.getOwnPropertyDescriptor;var bo=Object.getOwnPropertyNames;var wo=Object.prototype.hasOwnProperty;var Co=(n,e)=>{for(var t in e)ur(n,t,{get:e[t],enumerable:!0})},To=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of bo(e))!wo.call(n,i)&&i!==t&&ur(n,i,{get:()=>e[i],enumerable:!(r=vo(e,i))||r.enumerable});return n};var Do=n=>To(ur({},"__esModule",{value:!0}),n);var al={};Co(al,{BUILTIN_AGG_FUNCS:()=>Ne,DEFAULT_LOCALE:()=>D,EVENT_TYPES:()=>we,LOCALE_EN:()=>Mi,actionsColumn:()=>Fi,advancedFilterCondition:()=>vi,advancedFilterGroup:()=>bi,applyGridViewState:()=>oi,buildColDefsFromSchema:()=>ro,captureGridViewState:()=>ni,clearGridState:()=>jn,createActionButtonsRenderer:()=>ve,createAggResolver:()=>ht,createBusinessColumnTypes:()=>ho,createColumnHelper:()=>no,createEnterprisePreset:()=>so,createGrid:()=>Qn,createGridViewManager:()=>go,createLocalGridStateStore:()=>Qr,createLocalGridViewStore:()=>si,createMachTableCommands:()=>io,createMachTablePreset:()=>ii,createProgressBarRenderer:()=>Dr,createRemoteExportRequest:()=>eo,createRowActionsRenderer:()=>st,createStatusTagRenderer:()=>Tr,defineColumns:()=>oo,defineGridOptions:()=>lo,defineMachTableConfig:()=>co,defineMachTablePreset:()=>ao,describeFilter:()=>$t,downloadFile:()=>Bt,dragColumn:()=>Oi,escapeHtml:()=>ce,formatText:()=>_,formatTwo:()=>ge,getByPath:()=>B,indexColumn:()=>at,isColDefGroup:()=>me,isSafePath:()=>Qe,linkRenderer:()=>xr,loadGridState:()=>ir,matchLocaleKey:()=>rt,normalizeAdvancedFilterModel:()=>H,normalizeColumnFilter:()=>et,normalizeFilterModel:()=>Z,normalizeGridState:()=>$,normalizeGridViewState:()=>cr,normalizeSavedGridView:()=>xe,parseCsv:()=>Dt,parseDelimited:()=>xt,parseTsv:()=>Tt,resolveGridFeatures:()=>sr,resolveSaveConflict:()=>Mn,resolveTagVariant:()=>it,rowActionsColumn:()=>Hi,sanitizeFormulaCell:()=>ae,saveGridState:()=>rr,selectionColumn:()=>Ni,setByPath:()=>pe,toTsv:()=>Ct,validateGridOptions:()=>nr,version:()=>sl});module.exports=Do(al);var We="0.39.0";function E(n,e,t=!1){if(!(typeof n!="number"||!Number.isFinite(n)||n<e))return t?Math.floor(n):n}function F(n){return E(n,0)||void 0}function $e(n){return!n||typeof n.key!="string"||!n.key.trim()?null:{key:n.key.trim(),debounceMs:E(n.debounceMs,0,!0)??160,...n.sections?{sections:[...new Set(n.sections)]}:{},...n.store?{store:n.store}:{}}}function R(n,e,t,r=!1){let i=!1;for(let o of t)(r?Object.prototype.hasOwnProperty.call(n,o):n[o]!=null)&&(e[o]=n[o],i=!0);return i}var hr=new WeakMap,Ke=new WeakMap;function Re(n){let e=hr.get(n);return e||(e={},hr.set(n,e)),e}function pr(n){return hr.get(n)}function Ue(n,e){e?Ke.set(n,e):Ke.delete(n)}function je(n){let e=Ke.get(n);return Ke.delete(n),e}function fr(n){if(n==null)return"";if(n instanceof Date)return n.toLocaleDateString();if(typeof n=="object")try{return JSON.stringify(n)}catch{return String(n)}return String(n)}function k(n,e){let t=pr(e);if(!t)return;t.flashTimer&&clearTimeout(t.flashTimer),t.flashTimer=void 0;let r=t.destroy;if(t.destroy=void 0,t.refresh=void 0,t.rendererDefinition=void 0,t.rendererRowId=void 0,t.rendererColumnId=void 0,!!r)try{r()}catch(i){n.reportError(i,"cellRenderer.destroy",{colId:e.dataset.colId})}}function di(n,e,t,r,i,o){let s=n.r.tooltipComponent?"":o,a=r.colDef.tooltipValueGetter;if(a)try{s=a({api:n.api,colDef:r.colDef,column:r,node:t,data:t.data,value:i})??o}catch(l){n.reportError(l,"tooltipValueGetter",{colId:r.id,rowId:t.id})}s?e.setAttribute("title",s):e.removeAttribute("title")}function Eo(n,e,t,r,i,o){let s=pr(e);if(!s?.refresh||s.rendererDefinition!==i||s.rendererRowId!==t.id||s.rendererColumnId!==r.id)return!1;try{return e.querySelector(":scope > .mach-cell-edit-trigger")?.remove(),s.refresh(o)!==!1}catch(a){return n.reportError(a,"cellRenderer.refresh",{colId:r.id,rowId:t.id}),!1}}function he(n,e,t){return K(n,e,t,n.c(e,t))}function K(n,e,t,r){let i=t.colDef.valueFormatter;if(i)try{let o=i({api:n.api,colDef:t.colDef,column:t,node:e,data:e.data,value:r});return o==null?"":String(o)}catch(o){n.reportError(o,"valueFormatter",{colId:t.id,rowId:e.id})}return fr(r)}function Ro(n,e,t,r){let i=r.colDef.cellStyle,o=Re(e),s=o.styleKeys;if(s)for(let d of s)Reflect.set(e.style,d,"");if(!i){o.styleKeys=void 0;return}let a;if(typeof i=="function"){let d=n.c(t,r);try{a=i({api:n.api,colDef:r.colDef,column:r,node:t,data:t.data,value:d,rowIndex:t.rowIndex})}catch(c){n.reportError(c,"cellStyle",{colId:r.id,rowId:t.id}),a=null}}else a=i;if(!a){o.styleKeys=void 0;return}let l=Object.keys(a);for(let d of l)Reflect.set(e.style,d,Reflect.get(a,d));o.styleKeys=l}function So(n,e,t,r){let i=n.c(t,r),o=K(n,t,r,i),s=r.colDef.cellRenderer,a=typeof s=="string"?n.tc(s):s;if(a){let l={api:n.api,colDef:r.colDef,column:r,node:t,data:t.data,value:i,formatted:o,rowIndex:t.rowIndex,rendererParams:r.colDef.cellRendererParams};if(Eo(n,e,t,r,a,l)){di(n,e,t,r,i,o);return}k(n,e);let d;try{d=a(l)}catch(c){n.reportError(c,"cellRenderer",{colId:r.id,rowId:t.id}),e.textContent=o;return}if(typeof d=="string")e.textContent=d;else if(d instanceof HTMLElement)e.replaceChildren(d);else if(d&&typeof d=="object"&&d.el instanceof HTMLElement){let c=d;e.replaceChildren(c.el);let u=Re(e);u.destroy=c.destroy,c.refresh&&(u.refresh=h=>c.refresh(h),u.rendererDefinition=a,u.rendererRowId=t.id,u.rendererColumnId=r.id)}else e.textContent=""}else k(n,e),e.textContent=o;di(n,e,t,r,i,o)}function qe(n){let{align:e}=n.colDef;return e==="left"?"mach-cell--left":e==="right"?"mach-cell--right":"mach-cell--center"}function Mo(n,e,t,r,i){let o=r.colDef.cellClass;if(!o)return;if(typeof o=="string"){e.push(o);return}if(Array.isArray(o)){e.push(...o);return}let s={api:n.api,colDef:r.colDef,column:r,node:t,data:t.data,value:i,rowIndex:t.rowIndex};try{let a=o(s);typeof a=="string"?e.push(a):Array.isArray(a)&&e.push(...a)}catch(a){n.reportError(a,"cellClass",{colId:r.id,rowId:t.id})}}function Io(n,e,t){e.classList.contains("mach-cell--focus")&&n.push("mach-cell--focus"),e.classList.contains("mach-cell--editing")&&n.push("mach-cell--editing"),t.colDef.wrapText&&n.push("mach-cell--wrap")}function mr(n,e,t,r){let i=n.c(t,r),o=["mach-cell",qe(r)];Mo(n,o,t,r,i),Io(o,e,r);let s=o.join(" ");e.className!==s&&(e.className=s)}function Ye(n,e,t,r){So(n,e,t,r),mr(n,e,t,r),Ro(n,e,t,r)}function Se(n,e){return n&&Object.prototype.hasOwnProperty.call(n,e)?n[e]:void 0}function Xe(n,e){if(n==null||n===""||!e||typeof e!="object")return;let t=Se(e,String(n));return typeof t=="string"?{color:t}:t}var Je=class{constructor(e){this.e=e;this.Yn="";this.Er=!0}Xn(e){let t=getComputedStyle(this.e.o.root),r=`${t.getPropertyValue("--mach-header-font-weight")||650} ${t.fontSize} ${t.fontFamily}`;r!==this.Yn&&(this.Er=!0,e=void 0),this.Yn=r;let i=this.Er?this.ta():void 0,o=i&&ko(i,e),s=e?.columns&&new Set(e.columns),a=!1;for(let l of this.e.n.d()){if(l.minWidth!=null&&(!o||s&&!s.has(l.id)))continue;let d=this.rc(l);if(a=l.minWidth!==d||a,l.minWidth=d,Ao(l)){let c=this.ra(l,i);a=c!==l.contentWidth||a,l.contentWidth=c}}return this.Er=!1,a}ta(){let e=this.e.i.Oe(),t=Math.min(e.length,100);return Array.from({length:t},(r,i)=>e[Math.floor(i*(e.length-1)/Math.max(t-1,1))])}ia(e){return this.xr===void 0&&(this.xr=document.createElement("canvas").getContext("2d")),this.xr?(this.xr.font=this.Yn,this.xr.measureText(e).width):e.replace(/[^\x00-\xff]/g,"mm").length*7}rc(e){let t=e.colDef,r=t.headerName??t.field??e.id;return Math.ceil(Math.max(t.minWidth??0,this.ia(r)+r.length*.15+28+(e.sortable?20:0)+(e.filterable?28:0)+(this.e.r.columnMenu&&!e.hasCheckbox&&!t.suppressColumnMenu?22:0)))}ra(e,t=this.ta()){let r=28;for(let i of t){let o=this.e.c(i,e),s=Xe(o,e.colDef.status)?.label??K(this.e,i,e,o);r=Math.max(r,this.ia(s.slice(0,128))+(e.colDef.status?44:28))}return Math.ceil(Math.min(F(e.colDef.maxWidth)??360,r))}};function Ao(n){let{width:e,autoWidth:t}=n.colDef;return n.manualWidth==null&&e==null&&t!==!1&&!n.hasCheckbox&&!n.isDetailToggle}function ko(n,e){if(!e?.rowIds&&!e?.rowIndexes)return!0;let t=new Set(e.rowIds),r=new Set(e.rowIndexes);return n.some(i=>t.has(i.id)||r.has(i.rowIndex))}function f(n,e,t){let r=document.createElement(n);if(e&&(r.className=e),t)for(let i of Object.keys(t))r.setAttribute(i,t[i]);return r}function Y(n,e,t){let r=f("button",n);return r.type="button",r.textContent=e,r.addEventListener("click",t),r}function L(n,e,t,r=!1){let i=e?"addEventListener":"removeEventListener";for(let[o,s]of Object.entries(t))n[i](o,s,r)}function X(n,e,t){L(document,n,{mousedown:e,keydown:t},!0)}function M(n,e){if(n.classList.add("mach-portal"),!e)return;let t=window.getComputedStyle(e);for(let r=0;r<t.length;r++){let i=t.item(r);if(!i.startsWith("--mach-"))continue;let o=t.getPropertyValue(i).trim();o&&n.style.setProperty(i,o)}n.style.colorScheme=t.colorScheme}function C(n,e,t){return n<e?e:n>t?t:n}function J(n,e,t=4){let r=e.getBoundingClientRect(),i=n.getBoundingClientRect(),o=r.bottom+t,s=o+i.height>window.innerHeight-8?r.top-i.height-t:o;n.style.left=`${C(r.left,8,Math.max(8,window.innerWidth-i.width-8))}px`,n.style.top=`${C(s,8,Math.max(8,window.innerHeight-i.height-8))}px`}var ci=0;function ui(n="rg"){return ci++,`${n}-${ci}`}var hi='<svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M2 3.5h12L9.5 8v4.5L6.5 14V8L2 3.5z"/></svg>',pi='<svg viewBox="0 0 16 16" width="10" height="10" fill="currentColor"><path d="M8 3l4 5H4l4-5z"/></svg>',fi='<svg viewBox="0 0 16 16" width="10" height="10" fill="currentColor"><path d="M8 13l4-5H4l4 5z"/></svg>',mi='<svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.35" stroke-linecap="round"><path d="M2 4h3m3 0h6M2 8h7m3 0h2M2 12h1m3 0h8"/><circle cx="6.5" cy="4" r="1.35"/><circle cx="10.5" cy="8" r="1.35"/><circle cx="4.5" cy="12" r="1.35"/></svg>';var Ze=class{constructor(e){this.ic=e;this.Si=new Map}on(e,t){let r=this.Si.get(e);return r||(r=new Set,this.Si.set(e,r)),r.add(t),()=>{r.delete(t)}}once(e,t){let r=this.on(e,i=>{r(),t(i)});return r}emit(e,t){let r=this.Si.get(e);if(r)for(let i of[...r])try{i(t)}catch(o){console.error(`[mach-table] error in "${e}" listener`,o),this.ic?.(o,e)}}clear(){this.Si.clear()}};var Po=new Set(["__proto__","prototype","constructor"]),Me=new Map;function gr(n){if(typeof n!="string"||n.length===0)return null;let e=Me.get(n);if(e!==void 0)return e;let t=n.split("."),r=t.every(i=>i.length>0&&!Po.has(i))?t:null;return n.length<=1024&&(Me.size>=256&&Me.delete(Me.keys().next().value),Me.set(n,r)),r}function Qe(n){return gr(n)!==null}function B(n,e){if(n==null)return;let t=gr(e);if(!t)return;let r=n;for(let i of t){if(r==null)return;r=r[i]}return r}function pe(n,e,t){if(n==null)return!1;let r=gr(e);if(!r)return!1;let i=n;for(let o=0;o<r.length-1;o++){if(typeof i!="object"&&typeof i!="function"||i===null)return!1;i[r[o]]==null&&(i[r[o]]={}),i=i[r[o]]}return typeof i!="object"&&typeof i!="function"||i===null?!1:(i[r[r.length-1]]=t,!0)}var fe={text:["contains","notContains","equals","notEquals","startsWith","endsWith","blank","notBlank"],number:["equals","notEquals","lessThan","lessThanOrEqual","greaterThan","greaterThanOrEqual","inRange","blank","notBlank"],date:["equals","notEquals","lessThan","greaterThan","inRange","blank","notBlank"]};var Go=16,Lo=512,No=20,Oo=2e3,Fo=2e3,Ho={text:new Set(fe.text),number:new Set(fe.number),date:new Set(fe.date)};function Vo(n){return n==null||typeof n=="string"||typeof n=="number"&&Number.isFinite(n)}function Bo(n,e,t){if(n==null||typeof n!="object")return null;let r=n;return typeof r.match!="string"||!t.has(r.match)?null:{match:r.match,..._o(r,e)}}function _o(n,e){let t=e==="number"?gi(n.value):typeof n.value=="string"?n.value:void 0,r=e==="number"?gi(n.value2):typeof n.value2=="string"?n.value2:void 0;return{...t!==void 0?{value:t}:{},...r!==void 0?{value2:r}:{}}}function gi(n){return typeof n=="number"&&Number.isFinite(n)?n:void 0}function zo(n,e){let t=[],r=Ho[e];for(let i of n.slice(0,No)){let o=Bo(i,e,r);o&&t.push(o)}return t}function et(n){if(n==null||typeof n!="object")return null;let e=n;return e.type==="set"?Array.isArray(e.values)?{type:"set",values:e.values.filter(Vo).slice(0,Oo)}:null:e.type!=="text"&&e.type!=="number"&&e.type!=="date"||!Array.isArray(e.conditions)?null:{type:e.type,...e.operator==="or"||e.operator==="and"?{operator:e.operator}:{},conditions:zo(e.conditions,e.type)}}function Wo(n,e){if(typeof n.colId!="string"||!n.colId.trim())return null;let t=n.colId.trim();if(e.validColumnIds?.has(t)===!1)return null;let r=et(n.filter);return r?{kind:"condition",colId:t,filter:r}:null}function $o(n,e,t){if(!Array.isArray(n.children))return null;let r=[];for(let i of n.children){let o=yi(i,e+1,t);o&&r.push(o)}return r.length===0?null:{kind:"group",operator:n.operator==="or"?"or":"and",children:r,...n.not===!0?{not:!0}:{}}}function Ko(n,e,t){return e<=Go&&t.nodes<Lo&&n!=null&&typeof n=="object"}function yi(n,e,t){if(!Ko(n,e,t)||t.ancestors.has(n))return null;t.ancestors.add(n),t.nodes++;let r=n,i=r.kind==="condition"?Wo(r,t):r.kind==="group"?$o(r,e,t):null;return t.ancestors.delete(n),i}function H(n,e){if(n==null||typeof n!="object")return null;let t=n;if(t.version!==1||t.root==null)return null;let r=yi(t.root,0,{ancestors:new WeakSet,nodes:0,validColumnIds:e});return r?{version:1,root:r}:null}function vi(n,e){return{kind:"condition",colId:n,filter:e}}function Z(n,e){if(n==null||typeof n!="object"||Array.isArray(n))return{};let t={};for(let[r,i]of Object.entries(n).slice(0,Fo)){let o=r.trim();if(!o||e?.has(o)===!1)continue;let s=et(i);s&&(t[o]=s)}return t}function bi(n,e,t={}){return{kind:"group",operator:n,children:e,...t.not?{not:!0}:{}}}var yr={align:"center",sortable:!0,resizable:!0,movable:!0,filter:!1,minWidth:80},Ie={compact:{rowHeight:30,headerHeight:34,fontSize:12,cellPadding:6},normal:{rowHeight:36,headerHeight:40,fontSize:13,cellPadding:9},large:{rowHeight:44,headerHeight:48,fontSize:14,cellPadding:12}},Ae={multiSort:!0,stripedRows:!1,showCellBorders:!1,quickFilterText:null,suppressCellFocus:!1,suppressRowHoverHighlight:!1,suppressNoRowsOverlay:!1,suppressHeaderFocus:!1,loading:!1,error:null,className:"",singleClickEdit:!1,manualSorting:!1,manualFiltering:!1,showSummary:!1,rowNumber:!1,indexOffset:0,applyRowDrag:!0,masterDetail:!1,detailToggleColumn:!0,treeData:!1,childrenKey:"children",autoCheckedChildren:!0,defaultExpandAll:!1,columnMenu:!1,suppressWarnings:!1,enableRangeSelection:!1,suppressClipboard:!1,contextMenu:!1,flashCells:!0,fillHandle:!0,ariaLabel:"MachTable data grid",ariaLabelledBy:"",ariaDescribedBy:"",overlayNoRowsTemplate:"",overlayLoadingTemplate:"",overlayErrorTemplate:"",allowUnsafeOverlayHtml:!1},Uo=Object.keys(Ae);function jo(n){let e={};for(let t of Uo)e[t]=n[t]??Ae[t];return e}function N(n,e,t,r=!1){return E(n,t,r)??e}function qo(n){return n&&Object.prototype.hasOwnProperty.call(Ie,n)?n:"normal"}function Yo(n){return n.theme==="light"||n.theme==="dark"||n.theme==="auto"?n.theme:"light"}function Xo(n,e){let t=typeof n.pagination=="object"&&Array.isArray(n.pagination.pageSizeOptions)?n.pagination.pageSizeOptions:void 0,r=t?[...new Set(t.map(i=>N(i,0,1,!0)).filter(Boolean))]:[10,20,50,100];return r.includes(e)||r.push(e),r.sort((i,o)=>i-o)}function vr(n,e){let t=typeof n=="function"?n(e):B(e,n);return t==null?"":String(t)}function Jo(n){let e=n.rowKey,t=e?({data:r})=>vr(e,r):void 0;return{...t?{resolveRowId:t}:{},...e?{rowKey:e}:{}}}function Zo(n,e){let t=Ie[e];return{columnDefs:Array.isArray(n.columnDefs)?n.columnDefs:[],rowData:Array.isArray(n.rowData)?n.rowData:[],defaultColDef:{...yr,...n.defaultColDef??{}},columnTypes:n.columnTypes??{},...Jo(n),rowHeight:N(n.rowHeight,t.rowHeight,1),headerHeight:N(n.headerHeight,t.headerHeight,1),rowBuffer:N(n.rowBuffer,8,0,!0),columnLayout:n.columnLayout==="fit"?"fit":"normal",enableColumnResize:n.enableColumnResize===!0,domLayout:n.domLayout==="autoHeight"?"autoHeight":"normal",maxBodyHeight:E(n.maxBodyHeight,1),rowSelection:n.rowSelection==="single"||n.rowSelection==="multiple"?n.rowSelection:"none",size:e,pinnedTopRowData:Array.isArray(n.pinnedTopRowData)?n.pinnedTopRowData:[],pinnedBottomRowData:Array.isArray(n.pinnedBottomRowData)?n.pinnedBottomRowData:[]}}function Qo(n){return{rowStyleRules:Array.isArray(n.rowStyleRules)?n.rowStyleRules:[],theme:Yo(n)}}function es(n){return{editType:n.editType==="fullRow"?"fullRow":"cell",editableIndicator:n.editableIndicator==="always"||n.editableIndicator==="none"?n.editableIndicator:"hover",rowDragPolicy:n.rowDragPolicy,undoStackSize:N(n.undoStackSize,100,0,!0),asyncTransactionWaitMillis:N(n.asyncTransactionWaitMillis,16,0,!0)}}function ts(n){return{detailRowHeight:N(n.detailRowHeight,240,1)}}function rs(n){let e=typeof n.pagination=="object"?n.pagination:void 0,t=N(e?.pageSize,20,1,!0);return{paginationEnabled:n.pagination!==!1&&n.datasource==null,paginationMode:e?.mode==="server"?"server":"client",paginationPage:N(e?.page,1,1,!0),paginationTotal:N(e?.total,0,0,!0),paginationPageSize:t,paginationPageSizeOptions:Xo(n,t),paginationShowTotal:e?e.showTotal!==!1:!0,paginationShowSizeSelector:e?e.showPageSizeSelector!==!1:!0}}function br(n){return{watermarkEnabled:n.watermark!=null&&n.watermark!==!1,watermarkConfig:n.watermark==null||n.watermark===!1?null:n.watermark===!0?{text:"MachTable"}:n.watermark}}function is(n){return{advancedFilterModel:H(n.advancedFilterModel),persistence:$e(n.persistence),locale:n.locale??{},tooltipShowDelay:N(n.tooltipShowDelay,600,0),statusBarEnabled:n.statusBar===!0||typeof n.statusBar=="object"&&n.statusBar!=null,statusBarPanels:typeof n.statusBar=="object"&&n.statusBar?.panels?n.statusBar.panels:["rowCount","selectedRowCount","rangeAggregate"]}}var Ci={blockSize:100,maxBlocksInCache:12,datasourceMaxConcurrentRequests:4},Ti={infiniteBufferRows:40,blockPrefetch:1,datasourceRetryCount:2,datasourceRetryDelay:300},ns=Object.keys(Ci),os=Object.keys(Ti);function wi(n,e,t,r){let i=!1;for(let o of t){let s=E(n[o],r,!0);s===void 0||s===e[o]||(e[o]=s,i=!0)}return i}function wr(n,e){let t=wi(n,e,ns,1);wi(n,e,os,0);let r=E(n.datasourceRetryJitter,0);return r!==void 0&&(e.datasourceRetryJitter=Math.min(1,r)),t}function ss(n){let e={...Ci,...Ti,datasourceRetryJitter:.15};return wr(n,e),{...e,datasourceMode:n.datasourceMode==="block"?"block":"sequential",datasourceRowCount:n.datasourceRowCount==null?null:N(n.datasourceRowCount,0,0,!0),dataProcessorMinRows:N(n.dataProcessorMinRows,5e3,1,!0)}}var as=["detailRowRenderer","isRowExpandable","aggFuncs","components","actionPolicy","summaryMethod","datasource","getRowHeight","tooltipComponent","getContextMenuItems","initialState","rowEditValidator","isTreeRowExpandable","loadTreeChildren","dataProcessor"];function ls(n,e){for(let t of as)n[t]&&Reflect.set(e,t,n[t])}function ds(n,e){for(let t of Object.keys(n))t.startsWith("on")&&typeof n[t]=="function"&&Reflect.set(e,t,n[t])}function Di(n){let e=qo(n.size),t={...jo(n),...Zo(n,e),...Qo(n),...es(n),...ts(n),...rs(n),...br(n),...is(n),...ss(n),features:Array.isArray(n.features)?n.features:[]};return ls(n,t),ds(n,t),t}function xi(n){return Array.isArray(n)?n.filter(e=>typeof e=="string"&&e.length>0):typeof n=="string"&&n.length>0?[n]:[]}function ke(n,e){return xi(n.type).includes(e)}function Ei(n,e,t={}){let r={};for(let o of xi(n.type)){o==="rightAligned"&&(r.align="right");let s=t[o];s&&Object.assign(r,s)}let i={...e,...r,...n};return i.align??(i.align=e.align??"center"),i.status&&!i.cellRenderer&&(i.cellRenderer="statusTag"),i}var U=class{constructor(e,t){this.manualWidth=null;this.contentWidth=null;this.flex=null;this.currentWidth=0;this.parentGroup=null;this.level=0;this.isDetailToggle=!1;this.id=e,this.colDef=t,this.hide=t.hide??!1;let r=t.pinned;this.pinned=r===!0?"left":r===!1||r==null?null:r,this.resetWidth()}get sortable(){return this.colDef.sortable!==!1}get resizable(){return this.colDef.resizable!==!1}get movable(){return this.colDef.movable!==!1}get filterable(){return this.colDef.filter!=null&&this.colDef.filter!==!1}get filterType(){let e=this.colDef.filter;return e===!0?"text":e??"text"}get hasCheckbox(){return this.colDef.checkboxSelection===!0}resetWidth(){this.manualWidth=null,this.contentWidth=null,this.flex=F(this.colDef.flex)??null}};function j(n){return!n.hasCheckbox&&!n.isDetailToggle&&!n.isAutoRowNumber}var Q=class n{constructor(e,t){this.parent=null;this.children=[];this.groupId=e,this.def=t}get headerName(){return this.def.headerName??this.def.groupId??""}getLeafColumns(e=[]){for(let t of this.children)t instanceof n?t.getLeafColumns(e):e.push(t);return e}};function me(n){return Array.isArray(n.children)}var Pe=150,cs=80;function ee(n,e){let t=F(e.minWidth)??cs,r=F(e.maxWidth)??Number.MAX_SAFE_INTEGER,i=F(n)??F(e.width)??Pe;return Math.max(t,Math.min(r,i))}function Ri(n,e,t,r){let i=r.map((s,a)=>a).filter(s=>r[s]>0),o=t-e.reduce((s,a)=>s+a,0);for(;Math.abs(o)>.001&&i.length;){let s=i.reduce((l,d)=>l+r[d],0),a=0;if(i=i.filter(l=>{let d=e[l];return e[l]=ee(d+o*r[l]/s,n[l]),a+=e[l]-d,e[l]!==d}),Math.abs(a)<1e-4)break;o-=a}}function Si(n,e){let t=n.map(r=>ee(r.width??Pe,r));return e>t.reduce((r,i)=>r+i,0)&&Ri(n,t,e,n.map(r=>r.flex??0)),t}function tt(n,e){let t=n.map(r=>ee(r.width??Pe,r));return Number.isFinite(e)&&e>0&&Ri(n,t,e,[...t]),t}var D={matchContains:"\u5305\u542B",matchNotContains:"\u4E0D\u5305\u542B",matchEquals:"\u7B49\u4E8E",matchNotEquals:"\u4E0D\u7B49\u4E8E",matchStartsWith:"\u5F00\u5934\u662F",matchEndsWith:"\u7ED3\u5C3E\u662F",matchBlank:"\u4E3A\u7A7A",matchNotBlank:"\u4E0D\u4E3A\u7A7A",matchLessThan:"\u5C0F\u4E8E",matchLessThanOrEqual:"\u5C0F\u4E8E\u7B49\u4E8E",matchGreaterThan:"\u5927\u4E8E",matchGreaterThanOrEqual:"\u5927\u4E8E\u7B49\u4E8E",matchInRange:"\u5728\u8303\u56F4\u5185",apply:"\u5E94\u7528",reset:"\u91CD\u7F6E",search:"\u641C\u7D22...",emptySetLabel:"(\u7A7A)",selectedCount:"\u5DF2\u9009 {n} \u9879",sortAsc:"\u5347\u5E8F",sortDesc:"\u964D\u5E8F",clearSort:"\u53D6\u6D88\u6392\u5E8F",pinLeft:"\u56FA\u5B9A\u5DE6\u4FA7",pinRight:"\u56FA\u5B9A\u53F3\u4FA7",clearPin:"\u53D6\u6D88\u56FA\u5B9A",autoSize:"\u81EA\u9002\u5E94\u5217\u5BBD",hideColumn:"\u9690\u85CF\u6B64\u5217",columnVisibility:"\u5217\u663E\u793A",resetAll:"\u91CD\u7F6E\u5168\u90E8",autoSizeAll:"\u5168\u90E8\u81EA\u9002\u5E94",columnSettings:"\u5217\u8BBE\u7F6E",totalLabel:"\u5408\u8BA1",totalRowsLabel:"\u5171 {n} \u884C",menuCopy:"\u590D\u5236",menuPaste:"\u7C98\u8D34",menuClearContents:"\u6E05\u9664\u5185\u5BB9",loading:"\u52A0\u8F7D\u4E2D...",statusSelected:"\u5DF2\u9009 {n} \u884C",statusSum:"\u548C {n}",statusAvg:"\u5747 {n}",statusCount:"\u8BA1 {n}",emptyRows:"\u6CA1\u6709\u53EF\u663E\u793A\u7684\u884C",emptyRowsHint:"\u6682\u65E0\u6570\u636E",noMatchingRows:"\u6CA1\u6709\u7B26\u5408\u7B5B\u9009\u6761\u4EF6\u7684\u884C",clearFilters:"\u6E05\u9664\u7B5B\u9009",paginationTotal:"\u5171 {n} \u6761",paginationPage:"\u7B2C {a} / {b} \u9875",perPage:"{n} \u6761/\u9875",pageFirst:"\u9996\u9875",pagePrev:"\u4E0A\u4E00\u9875",pageNext:"\u4E0B\u4E00\u9875",pageLast:"\u672B\u9875",requestFailed:"\u6570\u636E\u52A0\u8F7D\u5931\u8D25",requestFailedHint:"\u8BF7\u68C0\u67E5\u7F51\u7EDC\u540E\u91CD\u8BD5",actionView:"\u67E5\u770B",actionEdit:"\u7F16\u8F91",actionDelete:"\u5220\u9664",actionConfirm:"\u786E\u8BA4",actionSave:"\u4FDD\u5B58",actionCancel:"\u53D6\u6D88",actionMore:"\u66F4\u591A\u64CD\u4F5C",rowDragHandle:"\u62D6\u52A8\u8C03\u6574\u987A\u5E8F\uFF1BAlt + \u4E0A\u4E0B\u65B9\u5411\u952E\u79FB\u52A8",rowDragUnavailable:"\u5F53\u524D\u6392\u5E8F\u6216\u6570\u636E\u6A21\u5F0F\u4E0D\u652F\u6301\u81EA\u52A8\u8C03\u6574\u987A\u5E8F",rowDragPosition:"\u7B2C {a} \u884C \u2192 \u7B2C {b} \u884C",rowDragOutside:"\u79FB\u56DE\u8868\u683C\u5185\u653E\u7F6E \xB7 Esc \u53D6\u6D88"},Mi={matchContains:"Contains",matchNotContains:"Not Contains",matchEquals:"Equals",matchNotEquals:"Not Equals",matchStartsWith:"Starts With",matchEndsWith:"Ends With",matchBlank:"Blank",matchNotBlank:"Not Blank",matchLessThan:"Less Than",matchLessThanOrEqual:"\u2264",matchGreaterThan:"Greater Than",matchGreaterThanOrEqual:"\u2265",matchInRange:"In Range",apply:"Apply",reset:"Reset",search:"Search...",emptySetLabel:"(blank)",selectedCount:"{n} selected",sortAsc:"Ascending",sortDesc:"Descending",clearSort:"Clear Sort",pinLeft:"Pin Left",pinRight:"Pin Right",clearPin:"Unpin",autoSize:"Auto Fit",hideColumn:"Hide Column",columnVisibility:"Columns",resetAll:"Reset All",autoSizeAll:"Fit All",columnSettings:"Column Settings",totalLabel:"Total",totalRowsLabel:"{n} rows",menuCopy:"Copy",menuPaste:"Paste",menuClearContents:"Clear Contents",loading:"Loading...",statusSelected:"{n} selected",statusSum:"Sum {n}",statusAvg:"Avg {n}",statusCount:"Cnt {n}",emptyRows:"No rows to display",emptyRowsHint:"No data is available.",noMatchingRows:"No rows match the filters",clearFilters:"Clear filters",paginationTotal:"{n} items",paginationPage:"Page {a} / {b}",perPage:"{n} / page",pageFirst:"First",pagePrev:"Previous",pageNext:"Next",pageLast:"Last",requestFailed:"Unable to load data",requestFailedHint:"Check your connection and try again",actionView:"View",actionEdit:"Edit",actionDelete:"Delete",actionConfirm:"Confirm",actionSave:"Save",actionCancel:"Cancel",actionMore:"More actions",rowDragHandle:"Drag to reorder; Alt + Up/Down to move",rowDragUnavailable:"Reordering is unavailable in the current sort or data mode",rowDragPosition:"Row {a} \u2192 Row {b}",rowDragOutside:"Move inside to drop \xB7 Esc to cancel",rowDragSelection:"{a} selected rows \u2192 Row {b}",rowDragBefore:"Before",rowDragAfter:"After",rowDragInside:"Inside",rowDragRejected:"This destination is unavailable"},us={contains:"matchContains",notContains:"matchNotContains",equals:"matchEquals",notEquals:"matchNotEquals",startsWith:"matchStartsWith",endsWith:"matchEndsWith",blank:"matchBlank",notBlank:"matchNotBlank",lessThan:"matchLessThan",lessThanOrEqual:"matchLessThanOrEqual",greaterThan:"matchGreaterThan",greaterThanOrEqual:"matchGreaterThanOrEqual",inRange:"matchInRange"};function rt(n){return us[n]??"matchEquals"}function _(n,e){return n.replace("{n}",String(e))}function ge(n,e,t){return n.replace("{a}",String(e)).replace("{b}",String(t))}var hs=[[/^(success|ok|done|complete|completed|normal|active|enabled|启用|正常|完成|已完成|运行|运行中|在线|生效|已发运)$/i,"success"],[/^(warning|warn|hold|pending|standby|待机|待审核|暂停|预警|部分完成|待下达|待复核|待发运)$/i,"warning"],[/^(error|fail|failed|danger|fault|offline|disabled|故障|失败|错误|异常|停用|离线|断开)$/i,"danger"],[/^(info|processing|new|draft|进行中|新建|草稿|审批中|同步中|执行中|已下达|装车中)$/i,"info"],[/^(neutral|default)$/i,"neutral"]];function it(n,e,t){let r=String(n??"");if(e){let i=Se(e,r);if(i)return i;let o=Se(e,r.toLowerCase());if(o)return o}for(let[i,o]of hs)if(i.test(r))return o;return t==null?"neutral":it(t)}function Tr(n={}){return e=>{if(e.value==null||e.value==="")return"";let t=String(e.value),r=Xe(t,e.colDef.status),i=r?.label??Se(n.labelMap,t)??(e.formatted||t),o=r?.color,s=it(o??t,o?void 0:n.variantMap,i),a=document.createElement("span");return a.className=`mach-tag mach-tag--${s}`,a.textContent=i,o&&s!==o&&(a.style.color=o,a.style.backgroundColor=`color-mix(in srgb, ${o} 12%, transparent)`),a}}function Dr(n={}){return e=>{let t=Number(e.value);if(isNaN(t))return e.formatted;let r=Math.max(0,Math.min(100,t)),i=f("div","mach-progress"),o=f("div","mach-progress__track"),s=f("div","mach-progress__bar");if(s.style.width=`${r}%`,n.color&&(s.style.background=n.color),o.appendChild(s),i.appendChild(o),n.showValue!==!1){let a=f("span","mach-progress__label");a.textContent=`${Math.round(r)}${n.unit??"%"}`,i.appendChild(a)}return i}}function xr(n){if(n.value==null||n.value==="")return"";let e=f("span","mach-link");return e.textContent=n.formatted||String(n.value),e}var Er={edit:'<path d="M11.5 2.5l2 2L5 13H3v-2l8.5-8.5z"/>',delete:'<path d="M3 5h10M6 5V3h4v2M5 5l.7 8h4.6L11 5"/>',view:'<path d="M1.5 8s2.4-4.2 6.5-4.2S14.5 8 14.5 8s-2.4 4.2-6.5 4.2S1.5 8 1.5 8z"/><circle cx="8" cy="8" r="1.8"/>',copy:'<rect x="5" y="5" width="8" height="8" rx="1"/><path d="M3 11V3h8"/>',download:'<path d="M8 2v8m0 0l-3-3m3 3l3-3M2.5 13.5h11"/>',refresh:'<path d="M13 3v4h-4M3 13V9h4"/><path d="M13 7a5.5 5.5 0 00-9.7-2.6M3 9a5.5 5.5 0 009.7 2.6"/>',close:'<path d="M3.5 3.5l9 9m0-9l-9 9"/>',check:'<path d="M2.5 8.5l3.5 3.5 7.5-8"/>',plus:'<path d="M8 2.5v11M2.5 8h11"/>',search:'<circle cx="7" cy="7" r="4.5"/><path d="M10.5 10.5L14 14"/>',more:'<circle cx="3" cy="8" r=".9" fill="currentColor" stroke="none"/><circle cx="8" cy="8" r=".9" fill="currentColor" stroke="none"/><circle cx="13" cy="8" r=".9" fill="currentColor" stroke="none"/>'};function nt(n,e=14){let t=Er[n]??"";return`<svg viewBox="0 0 16 16" width="${e}" height="${e}" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">${t}</svg>`}var re=null,V=null;function Ii(n){V&&n.contains(V)&&q()}function q(n=!1){re?.remove(),re=null,V&&(V.setAttribute("aria-expanded","false"),n&&V.isConnected&&V.focus({preventScroll:!0})),V=null,document.removeEventListener("mousedown",Ai,!0),document.removeEventListener("keydown",Rr,!0)}function Ai(n){re&&!re.contains(n.target)&&!V?.contains(n.target)&&q()}function Rr(n){if(!re)return;if(n.key==="Escape"){n.preventDefault(),q(!0);return}let e=[...re.querySelectorAll("button:not(:disabled)")];if(e.length===0)return;if(n.key==="Tab"){let i=e.indexOf(document.activeElement);(!n.shiftKey&&i===e.length-1||n.shiftKey&&i<=0)&&(n.preventDefault(),e[n.shiftKey?e.length-1:0].focus());return}if(n.key!=="ArrowDown"&&n.key!=="ArrowUp")return;n.preventDefault();let t=e.indexOf(document.activeElement),r=n.key==="ArrowDown"?1:-1;e[(t+r+e.length)%e.length].focus()}function ki(n,e){let t=document.createElement("button");return t.type="button",t.className=e,n.variant&&n.variant!=="default"&&t.classList.add(`${e}--${n.variant}`),t.disabled=n.disabled===!0,n.icon&&Er[n.icon]?t.innerHTML=`${nt(n.icon,16)}<span>${n.label}</span>`:t.textContent=n.label,t.addEventListener("click",()=>n.pick(t)),t}function ps(n,e){q();let t=f("div","mach-context-menu mach-action-menu");t.setAttribute("role","menu");for(let r of e){let i=ki(r,"mach-context-menu-item");i.setAttribute("role","menuitem"),t.appendChild(i)}M(t,n.closest(".mach-root")),document.body.appendChild(t),J(t,n),re=t,V=n,n.setAttribute("aria-expanded","true"),document.addEventListener("mousedown",Ai,!0),document.addEventListener("keydown",Rr,!0),t.querySelector("button:not(:disabled)")?.focus({preventScroll:!0})}function fs(n,e,t){q();let r=f("div","mach-action-drawer-backdrop"),i=f("section","mach-action-drawer");i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),i.setAttribute("aria-label",e);let o=f("header","mach-action-drawer__header"),s=document.createElement("strong");s.textContent=e;let a=document.createElement("button");a.type="button",a.className="mach-action-drawer__close",a.setAttribute("aria-label","Close"),a.title="Close",a.innerHTML=nt("close",16),a.addEventListener("click",()=>q(!0)),o.append(s,a);let l=f("div","mach-action-drawer__body");for(let d of t)l.appendChild(ki(d,"mach-action-drawer__item"));i.append(o,l),r.appendChild(i),r.addEventListener("mousedown",d=>{d.target===r&&q(!0)}),M(r,n.closest(".mach-root")),document.body.appendChild(r),re=r,V=n,n.setAttribute("aria-expanded","true"),document.addEventListener("keydown",Rr,!0),i.querySelector("button:not(:disabled)")?.focus({preventScroll:!0})}function te(n,e){if(typeof n=="function")try{return n(e)}catch{return!1}return n===!0}function Pi(n){return n.variant??"default"}function Gi(n){return n.permission?typeof n.permission=="string"?[n.permission]:n.permission:[]}function Sr(n,e,t){return{...n.id?{actionId:n.id}:{},permissions:Gi(n),...t?{message:t}:{},params:e}}function ot(n,e,t){let r=t.api.getOption("actionPolicy");try{r?.onError?r.onError(n,Sr(e,t)):console.error("[mach-table] action handler failed",n)}catch(i){console.error("[mach-table] action error policy failed",i,n)}}function ms(n,e){if(Gi(n).length===0)return!0;let r=e.api.getOption("actionPolicy");if(!r?.canAccess)return!0;try{return r.canAccess(Sr(n,e))}catch(i){return ot(i,n,e),!1}}function gs(n,e){return n.filter(t=>{if(!ms(t,e))return!1;if(!t.show)return!0;try{return t.show(e)}catch{return!1}})}function Mr(n,e,t){t.isConnected&&(t.disabled=te(n.disabled,e)||te(n.loading,e),t.classList.toggle("mach-action-btn--loading",te(n.loading,e)))}function ys(n,e,t,r){Promise.resolve(n).catch(i=>ot(i,e,t)).finally(()=>Mr(e,t,r))}function vs(n,e,t){try{ys(n.onClick(e),n,e,t)}catch(r){ot(r,n,e),Mr(n,e,t)}}function Cr(n,e,t){if(n===!1)return!1;let r=typeof n=="string"?n:e.label??e.title??"Confirm action",i=t.api.getOption("actionPolicy");return i?.confirm?i.confirm(Sr(e,t,r)):typeof window>"u"||typeof window.confirm!="function"?!1:window.confirm(r)}function bs(n,e){if(n.confirm==null||n.confirm===!1)return!0;if(typeof n.confirm!="function")return Cr(n.confirm,n,e);let t=n.confirm(e);return t instanceof Promise?t.then(r=>Cr(r,n,e)):Cr(t,n,e)}function ws(n){return(e,t)=>{if(te(e.disabled,n))return;if(t.disabled=!0,t.classList.add("mach-action-btn--loading"),e.confirm==null||e.confirm===!1){vs(e,n,t);return}(async()=>{await bs(e,n)&&await e.onClick(n)})().catch(i=>ot(i,e,n)).finally(()=>{Mr(e,n,t)})}}function Cs(n,e,t){let r=document.createElement("button");r.type="button",r.className="mach-action-btn";let i=Pi(n);i!=="default"&&r.classList.add(`mach-action-btn--${i}`);let o=n.title??n.label??"Action";return r.title=o,r.setAttribute("aria-label",o),r.disabled=te(n.disabled,e),te(n.loading,e)&&(r.disabled=!0,r.classList.add("mach-action-btn--loading")),n.icon&&Er[n.icon]?(r.innerHTML=nt(n.icon),r.classList.add("mach-action-btn--icon")):r.textContent=n.label??o,r.addEventListener("mousedown",s=>s.stopPropagation()),r.addEventListener("click",s=>{s.stopPropagation(),t(n,r)}),r}function Ts(n,e,t,r,i){let o=document.createElement("button");o.type="button",o.className="mach-action-btn mach-action-btn--icon";let s=r.api.getOption("locale")??{},a=t.moreLabel??s.actionMore??D.actionMore;return o.title=a,o.setAttribute("aria-label",a),o.setAttribute("aria-haspopup",e==="drawer"?"dialog":"menu"),o.setAttribute("aria-expanded","false"),o.innerHTML=`${nt("more",16)}<span class="mach-sr-only">\u22EF</span>`,o.addEventListener("mousedown",l=>l.stopPropagation()),o.addEventListener("click",l=>{l.stopPropagation();let d=n.map(c=>({label:c.label??c.title??"Action",icon:c.icon,variant:Pi(c),disabled:te(c.disabled,r)||te(c.loading,r),pick:u=>{q(),i(c,u)}}));e==="drawer"?fs(o,t.drawerTitle??a,d):ps(o,d)}),o}function ve(n){let e=Math.max(0,n.max??3),t=n.overflow??"menu";return r=>{let i=gs(n.actions,r);if(i.length===0)return"";let o=f("div","mach-actions"),s=t==="inline"?i:i.slice(0,e),a=t==="inline"?[]:i.slice(e),l=ws(r);for(let d of s)o.appendChild(Cs(d,r,l));return a.length>0&&o.appendChild(Ts(a,t,n,r,l)),{el:o,destroy:()=>{V&&o.contains(V)&&q()}}}}function ye(n,e,t){return n??e??t}function Ds(n,e){let t=e.api.getOption("locale")??{};return{view:ye(n.labels?.view,t.actionView,D.actionView),edit:ye(n.labels?.edit,t.actionEdit,D.actionEdit),delete:ye(n.labels?.delete,t.actionDelete,D.actionDelete),confirm:ye(n.labels?.confirm,t.actionConfirm,D.actionConfirm),save:ye(n.labels?.save,t.actionSave,D.actionSave),cancel:ye(n.labels?.cancel,t.actionCancel,D.actionCancel)}}function xs(n,e,t){let r=async()=>{if(!await e.api.editing.stop()||!n.onSave)return;let s=e.api.editing.getChanges().filter(a=>a.rowId===e.node.id);try{await n.onSave(e,s),e.api.editing.markSaved([e.node.id])}catch(a){throw e.api.editing.startRow(e.rowIndex),a}},i=n.onSave?t.save:n.labels?.confirm??n.labels?.save??t.confirm;return ve({actions:[{icon:"check",title:i,variant:"success",onClick:r},{icon:"close",title:t.cancel,variant:"danger",onClick:()=>e.api.editing.stop({cancel:!0}).then(()=>{})}],overflow:"inline"})(e)}function Es(n,e,t){let r=[];return n.onView&&r.push({id:"view",icon:"view",title:t.view,variant:"primary",...n.permissions?.view?{permission:n.permissions.view}:{},onClick:n.onView}),n.edit!==!1&&r.push({id:"edit",icon:"edit",title:t.edit,variant:"warning",...n.permissions?.edit?{permission:n.permissions.edit}:{},onClick:n.onEdit??(()=>{e.api.editing.startRow(e.rowIndex)})}),n.onDelete&&r.push({id:"delete",icon:"delete",title:t.delete,variant:"danger",...n.permissions?.delete?{permission:n.permissions.delete}:{},...n.confirmDelete?{confirm:n.confirmDelete===!0?t.delete:n.confirmDelete}:{},onClick:n.onDelete}),r.push(...n.extraActions??[]),r}function st(n={}){return e=>{let t=Ds(n,e);if(e.api.editing.isRowActive(e.rowIndex))return xs(n,e,t);let r=Es(n,e,t);return ve({actions:r,max:n.max,overflow:n.overflow??"menu",moreLabel:n.moreLabel,drawerTitle:n.drawerTitle})(e)}}var Rs=Tr(),Ss=Dr(),Li=Object.freeze({statusTag:Rs,progressBar:Ss,link:xr});var Ge={sortable:!1,resizable:!1,movable:!1,filter:!1,suppressSizeToFit:!0,suppressColumnMenu:!0};function Ni(n={}){let e=n.width??40;return{colId:"sel",headerName:"",width:e,minWidth:n.minWidth??e,maxWidth:n.maxWidth??e,pinned:"left",checkboxSelection:!0,...Ge,...n}}function at(n={}){let e=n.width??52;return{colId:"idx",headerName:"#",type:"index",width:e,minWidth:n.minWidth??e,maxWidth:n.maxWidth??e,pinned:"left",align:"center",headerAlign:"center",...Ge,...n}}function Oi(n={}){let e=n.width??40;return{colId:"drag",headerName:"",rowDrag:!0,width:e,minWidth:n.minWidth??e,maxWidth:n.maxWidth??e,pinned:"left",...Ge,...n}}function Fi(n={actions:[]}){let{width:e,pinned:t,...r}=n,i=r.actions?.length??0,o=r.overflow==="inline"?i:Math.min(i,r.max??3),s=r.overflow!=="inline"&&i>o,a=Math.max(1,o)*26+(s?26:0)+10;return{colId:"op",headerName:"\u64CD\u4F5C",width:e??Math.max(64,a),pinned:t??"right",cellRenderer:ve(r),...Ge,cellRendererParams:void 0}}function Hi(n={}){let{width:e,pinned:t,...r}=n,i=(r.onView?1:0)+(r.edit===!1?0:1)+(r.onDelete?1:0)+(r.extraActions?.length??0),o=r.overflow==="inline"?i:Math.min(i,r.max??3),s=r.overflow!=="inline"&&i>o,a=Math.max(2,o)*26+(s?26:0)+10;return{colId:"op",headerName:"\u64CD\u4F5C",width:e??Math.max(72,a),pinned:t??"right",cellRenderer:st(r),...Ge,cellRendererParams:void 0}}var Ir="__rg_detail_toggle__";function Le(n){return F(n)!==void 0}function Bi(n){return n===!0?"left":n||null}function Vi(n,e){let t=e;for(let r=2;n.has(t);r++)t=`${e}_${r}`;return n.add(t),t}function Ms(n,e){let t=e.colDef,r=n.colDef;n.manualWidth=e.manualWidth,(t.width===r.width&&t.autoWidth===r.autoWidth||t.width!=null||t.autoWidth===!1)&&(n.contentWidth=e.contentWidth),(e.manualWidth!=null||e.flex!==(F(t.flex)??null))&&(n.flex=e.flex),e.hide!==(t.hide??!1)&&(n.hide=e.hide),e.pinned!==Bi(t.pinned)&&(n.pinned=e.pinned)}var lt=class{constructor(e){this.e=e;this.q=[];this.Jn=new Map;this.fe=[];this.Zn=[];this.Rr=[];this.Qn=[];this.ee=[];this.Mi=[];this.bt=new Map;this.Jt=1;this.eo=new Map;this.nc=0}Sr(e){this.Mi=e?[...e]:[];let t=new Map(this.q.map(c=>[c.id,c])),r=this.e.r.defaultColDef,i=this.e.r.masterDetail&&this.e.r.detailToggleColumn,o=new Set(i?[Ir]:[]),s=this.e.r.rowNumber,a=(c,u,h)=>c.map((p,m)=>{if(me(p)){let z=p.groupId??p.headerName??`group_${m}_${h}`,W=new Q(z,p);return W.parent=u,W.children=a(p.children,W,h+1),W}let g=p,v=Vi(o,g.colId??g.field??`col_${m}`),w=new U(v,Ei(g,r,this.e.r.columnTypes));s&&(s=!ke(w.colDef,"index")),w.parentGroup=u,w.level=h;let A=t.get(v);return A&&!A.isAutoRowNumber&&Ms(w,A),w});if(this.fe=a(this.Mi,null,0),s&&o.size>Number(i)&&this.oc(Vi(o,"idx"),t),i){let c=new U(Ir,{colId:Ir,headerName:"",width:38,pinned:"left",sortable:!1,resizable:!1,movable:!1,filter:!1});c.isDetailToggle=!0,this.fe.unshift(c)}this.bt.size&&this.sc(),this.q=this.Ii(this.fe),this.Jn=new Map(this.q.map(c=>[c.id,c])),this.Jt=this.q.reduce((c,u)=>Math.max(c,u.level+1),1);let l=this.ee.length;this.ee=this.ee.filter(c=>this.Jn.has(c.colId));let d=this.ee.length!==l;if(this.ee.length===0){let c=[];for(let u of this.q)u.colDef.initialSort&&c.push({colId:u.id,direction:u.colDef.initialSort});this.ee=c}return this.Zt(),d}oc(e,t){let r=new U(e,at({colId:e,headerName:"\u5E8F\u53F7"}));r.isAutoRowNumber=!0;let i=t.get(e);i?.isAutoRowNumber&&(r.hide=i.hide);let o=this.fe.findIndex(s=>!(s instanceof U&&(s.hasCheckbox||s.colDef.rowDrag)));this.fe.splice(o===-1?this.fe.length:o,0,r)}Ii(e,t=[]){for(let r of e)r instanceof Q?this.Ii(r.children,t):t.push(r);return t}Zt(){let e=this.q.filter(t=>!t.hide);this.Zn=e.filter(t=>t.pinned==="left"),this.Qn=e.filter(t=>t.pinned==="right"),this.Rr=e.filter(t=>t.pinned===null),this.eo.clear(),this.d().forEach((t,r)=>this.eo.set(t.id,r))}Fe(e){return this.eo.get(e)??-1}te(){return this.q}to(){return this.Mi}ac(){return this.fe}lc(){return this.Jt}S(e){return this.Jn.get(e)}C(e){return e==="left"?this.Zn:e==="right"?this.Qn:this.Rr}d(){return[...this.Zn,...this.Rr,...this.Qn]}Xe(){return this.d().filter(e=>e.colDef.rowGroup===!0)}dc(){return this.d().filter(e=>e.colDef.aggFunc!=null&&e.colDef.rowGroup!==!0)}ro(){return this.Rr.some(e=>e.colDef.colSpan!=null)}na(){let e=this.d();return this.Rr.find(j)??e.find(j)??e[0]}He(e){return e.pinned==="left"?"left":e.pinned==="right"?"right":"center"}oa(e){this.nc=e;let t=e,r=[],i=[];for(let s of this.d()){let a=this.Ai(s);s.pinned!=null||s.colDef.suppressSizeToFit||s.manualWidth!=null?(s.currentWidth=ee(a.width??Pe,a),t-=s.currentWidth):(r.push(s),i.push(a))}let o=this.e.r.columnLayout==="fit"?tt(i,Math.max(0,t)):Si(i,Math.max(0,t));r.forEach((s,a)=>{s.currentWidth=o[a]})}Ai(e){let t=e.colDef;return{width:e.manualWidth??e.contentWidth??t.width??void 0,minWidth:e.minWidth??t.minWidth,maxWidth:t.maxWidth,flex:e.manualWidth==null?e.flex??void 0:void 0}}Ee(e,t){return Le(t)?(e.manualWidth=ee(t,this.Ai(e)),e.flex=null,!0):!1}sa(e,t){return Le(t)?(e.resetWidth(),e.contentWidth=ee(t,this.Ai(e)),!0):!1}no(e,t){let r=this.S(e);!r||r.hide===!t||(r.hide=!t,this.Zt())}Mr(e,t){let r=this.S(e);if(!r)return!1;let i=this.He(r),o=u=>r.parentGroup?!0:this.He(u)===i,s=r.parentGroup?r.parentGroup.children:this.fe,a=s.filter(u=>u instanceof U&&!u.hide&&o(u)),l=a.indexOf(r);if(l<0)return!1;a.splice(l,1);let d=Math.max(0,Math.min(t,a.length));a.splice(d,0,r);let c=[];return s.forEach((u,h)=>{u instanceof U&&!u.hide&&o(u)&&c.push(h)}),c.length!==a.length?!1:(c.forEach((u,h)=>{s[u]=a[h]}),l!==d&&this.bt.set(this.aa(r),a.filter(u=>u.movable).map(u=>u.id)),this.q=this.Ii(this.fe),this.Zt(),!0)}oo(e,t){let r=this.S(e);!r||!r.movable||(r.pinned=t,this.Zt())}la(e=!0){return(e?this.q:this.q.filter(r=>!r.isAutoRowNumber)).map(r=>({colId:r.id,hide:r.hide,width:r.manualWidth??r.currentWidth,flex:r.flex,widthMode:r.manualWidth==null?"auto":"manual",contentWidth:r.contentWidth??void 0,pinned:r.pinned}))}da(e){let t=new Map(e.map(r=>[r.colId,r]));for(let r of this.q){let i=t.get(r.id);i&&this.cc(r,i)}this.uc(e),this.Zt()}cc(e,t){typeof t.hide=="boolean"&&(e.hide=t.hide),t.widthMode==="auto"?(e.resetWidth(),Le(t.flex)&&(e.flex=t.flex)):Le(t.flex)?(e.flex=t.flex,e.manualWidth=null):this.Ee(e,t.width),Le(t.contentWidth)&&(e.contentWidth=ee(t.contentWidth,this.Ai(e))),e.movable&&(t.pinned==="left"||t.pinned==="right"||t.pinned===null)&&(e.pinned=t.pinned)}uc(e){let t=new Map(e.map((r,i)=>[r.colId,i]));this.so(r=>!r.hide&&r.movable&&t.has(r.id),(r,i)=>{let o=[...r];r.sort((s,a)=>t.get(s.id)-t.get(a.id)),r.some((s,a)=>s!==o[a])&&this.bt.set(i,r.map(s=>s.id))}),this.q=this.Ii(this.fe)}aa(e){if(!e.parentGroup)return this.He(e);let t=[];for(let r=e.parentGroup;r;r=r.parent)t.push(r.groupId);return JSON.stringify(t)}sc(){let e=new Map;this.so(t=>t.movable,(t,r)=>{let i=this.bt.get(r);if(!i)return;let o=new Map(t.map(d=>[d.id,d])),s=i.filter(d=>o.has(d));if(s.length<2)return;let a=new Set(s),l=0;t.forEach((d,c)=>{a.has(d.id)&&(t[c]=o.get(s[l++]))}),e.set(r,s)}),this.bt=e}so(e,t,r=this.fe){let i=new Map;r.forEach((o,s)=>{if(o instanceof Q)this.so(e,t,o.children);else if(e(o)){let a=o.parentGroup?"center":this.He(o),l=i.get(a)??[];l.push(s),i.set(a,l)}});for(let o of i.values()){if(o.length<2)continue;let s=o.map(a=>r[a]);t(s,this.aa(s[0])),o.forEach((a,l)=>{r[a]=s[l]})}}ao(){for(let e of this.q)e.resetWidth(),e.hide=e.colDef.hide??!1,e.pinned=Bi(e.colDef.pinned);if(this.bt.size){this.bt.clear();let e=this.ee;this.Sr(this.Mi),this.ee=e;return}this.Zt()}re(){return this.ee.map(e=>({...e}))}Ir(e){if(!e||e.length===0){this.ee=[];return}this.ee=e.filter(t=>this.q.some(r=>r.id===t.colId)&&(t.direction==="asc"||t.direction==="desc")).map(t=>({colId:t.colId,direction:t.direction}))}ki(e,t){let r=[...this.ee],i=r.findIndex(l=>l.colId===e.id),o=i>=0?r[i].direction:null,s=o===null?"asc":o==="asc"?"desc":null;t&&this.e.r.multiSort?s===null?i>=0&&r.splice(i,1):i>=0?r[i]={colId:e.id,direction:s}:r.push({colId:e.id,direction:s}):(r.length=0,s&&r.push({colId:e.id,direction:s})),this.ee=r}};function ie(n,e){if(n instanceof Error)return n;let t=new Error(typeof n=="string"?n:e);return t.name="AbortError",t}var Is=()=>ie(void 0,"[MachTable] Operation cancelled.");function dt(n,e,t=Is){return e?new Promise((r,i)=>{let o=()=>{e.removeEventListener("abort",o),i(t())};if(n.then(r,i).finally(()=>e.removeEventListener("abort",o)),e.aborted){o();return}e.addEventListener("abort",o,{once:!0})}):n}function _i(n){return n==null?"":String(n).toLowerCase()}function kr(n,e,t){return n.length===0||(e==="or"?n.some(t):n.every(t))}function As(n,e,t){let r=_i(n);return kr(e,t,o=>{let s=(o.value??"").toLowerCase();switch(o.match){case"contains":return r.includes(s);case"notContains":return!r.includes(s);case"equals":return r===s;case"notEquals":return r!==s;case"startsWith":return r.startsWith(s);case"endsWith":return r.endsWith(s);case"blank":return r==="";case"notBlank":return r!=="";default:return!0}})}function zi(n,e,t,r){switch(t){case"equals":return n===e;case"notEquals":return n!==e;case"lessThan":return n<e;case"lessThanOrEqual":return n<=e;case"greaterThan":return n>e;case"greaterThanOrEqual":return n>=e;case"inRange":return n>=e&&n<=r;default:return!0}}function ks(n,e){let t=n==null||n==="";if(e.match==="blank")return t;if(e.match==="notBlank")return!t;if(t)return!1;let r=typeof n=="number"?n:Number(n);if(Number.isNaN(r))return!1;let i=e.value;return i==null||Number.isNaN(i)?!1:zi(r,i,e.match,e.value2??i)}function Ps(n,e,t){return kr(e,t,i=>ks(n,i))}function Ar(n){if(n==null||n==="")return null;if(typeof n=="number")return n;let e=n instanceof Date?n.getTime():Date.parse(String(n));return isNaN(e)?null:e}function Gs(n,e,t){let r=Ar(n);return kr(e,t,o=>{let s=r==null;if(o.match==="blank")return s;if(o.match==="notBlank")return!s;if(s)return!1;let a=Ar(o.value);if(a==null)return!1;let l=o.match==="inRange"?Ar(o.value2)??1/0:a;return zi(r,a,o.match,l)})}function Ls(n,e){return e.length===0?!0:e.some(t=>t==null&&n==null||t===n)}function Ns(n,e){let t=e.type!=="set"&&e.operator==="or"?"or":"and";switch(e.type){case"text":return As(n,e.conditions,t);case"number":return Ps(n,e.conditions,t);case"date":return Gs(n,e.conditions,t);case"set":return Ls(n,e.values);default:return!0}}function Wi(n,e,t){return r=>Ns(t(r,n),e)}function $i(n,e,t){if(n.kind==="condition"){let i=e.get(n.colId);return i?Wi(i,n.filter,t):()=>!0}let r=n.children.map(i=>$i(i,e,t));return i=>{let o=n.operator==="or"?r.some(s=>s(i)):r.every(s=>s(i));return n.not?!o:o}}function Pr(n,e,t,r,i){let o=new Map(n.map(l=>[l.id,l])),s=Object.entries(e).flatMap(([l,d])=>{let c=o.get(l);return c?[Wi(c,d,i)]:[]});t&&s.push($i(t.root,o,i));let a=r?.trim().toLowerCase().split(/\s+/).filter(Boolean)??[];return l=>s.every(d=>d(l))&&a.every(d=>n.some(c=>_i(i(l,c)).includes(d)))}var Ki=typeof Intl<"u"?new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"}):null;function Os(n,e){let t=n==null||n==="",r=e==null||e==="";return!t&&!r?null:t&&r?0:t?1:-1}function Fs(n,e){let t=Number.isNaN(n),r=Number.isNaN(e);return t||r?t===r?0:t?1:-1:n-e}function Hs(n,e){return n===e?0:n?1:-1}function ct(n,e){let t=Os(n,e);if(t!==null)return t;if(typeof n=="number"&&typeof e=="number")return Fs(n,e);if(n instanceof Date&&e instanceof Date)return n.getTime()-e.getTime();if(typeof n=="boolean"&&typeof e=="boolean")return Hs(n,e);let r=String(n),i=String(e);return Ki?Ki.compare(r,i):r.localeCompare(i)}function Gr(n,e,t,r){let i=new Map(t.map(a=>[a.id,a])),o=e.flatMap(a=>{let l=i.get(a.colId);return l?[{column:l,compare:l.colDef.comparator??ct,direction:a.direction}]:[]}),s=n.map(a=>({node:a,values:o.map(({column:l})=>r(a,l))}));return s.sort((a,l)=>{for(let d=0;d<o.length;d++){let c=o[d],u=c.compare(a.values[d],l.values[d],a.node,l.node);if(u!==0)return c.direction==="asc"?u:-u}return 0}),s.map(({node:a})=>a)}function Ui(){return{count:0,numeric:0,sum:0,min:1/0,max:-1/0}}function ji(n,e){n.count++,!(typeof e!="number"||!Number.isFinite(e))&&(n.numeric++,n.sum+=e,n.min=Math.min(n.min,e),n.max=Math.max(n.max,e))}function qi(n,e){return e==="count"?n?.count??0:n?.numeric?e==="min"?n.min:e==="max"?n.max:Number.isFinite(n.sum)?e==="avg"?n.sum/n.numeric:n.sum:null:null}function ut(n,e){let t=Ui();for(let r of n)ji(t,r);return qi(t,e)}var Ne={sum:n=>ut(n,"sum"),avg:n=>ut(n,"avg"),count:n=>n.length,min:n=>ut(n,"min"),max:n=>ut(n,"max"),first:n=>n.length>0?n[0]:null,last:n=>n.length>0?n[n.length-1]:null};function Yi(n,e,t){if(e===Ne.count)return n.length;let r=["sum","avg","min","max"].find(o=>e===Ne[o]);if(!r)return e(n.map(t));let i=Ui();for(let o of n)ji(i,t(o));return qi(i,r)}function ht(n){let e={...Ne,...n??{}};return t=>e[t]}var pt="group:";function Xi(n){return n==null?"null":n instanceof Date?JSON.stringify(["date",String(n.getTime())]):JSON.stringify([typeof n,Lr(n)])}function Lr(n){return n==null?"(\u7A7A)":String(n)}function Ji(n){return pt+JSON.stringify(n)}function Vs(n,e,t){let r=new Map;for(let i of n){let o=t(i,e),s=Xi(o),a=r.get(s);a||(a={key:s,label:Lr(o),rows:[]},r.set(s,a)),a.rows.push(i)}return[...r.values()].sort((i,o)=>i.label.localeCompare(o.label,void 0,{numeric:!0,sensitivity:"base"})||i.key.localeCompare(o.key))}function Zi(n,e,t,r,i){let o=[],s=(a,l,d)=>{if(l===e.length)return{display:a,leaves:a};let c=[],u=[];for(let h of Vs(a,e[l],t)){let p=[...d,[e[l].id,h.key]],m=Ji(p);o.push(m);let g=s(h.rows,l+1,p);if(c.push({id:m,data:null,rowIndex:-1,selected:!1,isGroup:!0,groupLevel:l,groupKey:h.label,leafNodes:g.leaves,aggValues:r(g.leaves)}),i.has(m))for(let v of g.display)c.push(v);if(l>0)for(let v of g.leaves)u.push(v)}return{display:c,leaves:u}};return{rows:s(n,0,[]).display,ids:o}}function Qi(n,e,t,r){let i=new Set([...n].filter(l=>l.startsWith("/g0:")));if(!i.size)return{expanded:n,ambiguous:[]};let o=new Map;for(let l of e){let d=[],c="";for(let u=0;u<t.length;u++){let h=r(l,t[u]);if(d.push([t[u].id,Xi(h)]),c+=`/g${u}:${Lr(h)}`,!i.has(c))continue;let p=Ji(d);o.set(c,o.has(c)&&o.get(c)!==p?null:p)}}let s=new Set([...n].filter(l=>!i.has(l))),a=[];for(let l of i){let d=o.get(l);d?s.add(d):d===null?a.push(l):s.add(l)}return{expanded:s,ambiguous:a}}function Bs(n,e){let t=n?[n.root]:[];for(;t.length;){let r=t.pop();if(r.kind==="condition")e.add(r.colId);else for(let i of r.children)t.push(i)}}function en(n){let e=new Set(Object.keys(n.filterModel));Bs(n.advancedFilter,e);let t=new Set(n.sortModel.map(a=>a.colId));for(let a of t)e.add(a);let r=n.columns.some(a=>a.colDef.rowGroup===!0),i=!!n.quickFilter?.trim(),o=n.columns.filter(a=>e.has(a.id)||i||a.colDef.rowGroup===!0||r&&a.colDef.aggFunc!=null),s=new Set;for(let a of o){let l=a.colDef;if(r&&l.rowGroup!==!0&&l.aggFunc!=null&&n.customAggregates?.[l.aggFunc]||l.valueGetter||t.has(a.id)&&l.comparator||!l.field)return null;s.add(l.field)}return[...s]}function tn(n){return n!=null&&(typeof n=="object"||typeof n=="function")}function rn(n,e){let t=new WeakMap;for(let r of n){if(r.data==null)continue;let i=e.map(o=>B(r.data,o));i.some(tn)||t.set(r,i)}return t}function nn(n,e,t,r){return t.length?!r||n===e||n==null||e==null?!0:t.some((i,o)=>{let s=B(e,i);return tn(s)||!Object.is(r[o],s)}):!1}function se(n){return ie(n.reason,"Block request aborted")}function ft(n){return Number.isFinite(n)?Math.max(1,Math.trunc(n)):1}var mt=class{constructor(e,t,r=4){this.maxBlocks=e;this.ho=t;this.maxConcurrentRequests=r;this.ie=new Map;this.Y=new Map;this.ca=0;this.lo=0;this.co=0;this.ua=0;this.ha=0;this.Pi=0;this.Gi=new Set;this.maxBlocks=ft(e),this.maxConcurrentRequests=ft(r)}configure(e,t=this.maxConcurrentRequests){this.maxBlocks=ft(e),this.maxConcurrentRequests=ft(t),this.uo(),this.Li()}hc(e){this.Gi=e,this.uo()}peek(e){let t=this.ie.get(e);if(t)return t.touchedAt=++this.ca,t}has(e){return this.ie.has(e)}Qt(e){let t=this.Y.get(e);t&&(this.Y.delete(e),t.controller.abort(),t.state==="queued"&&t.reject(se(t.controller.signal)));let r=this.ie.get(e);r&&(this.ie.delete(e),this.ho?.(e,r))}load(e,t,r,i=0){if(r?.aborted)return Promise.reject(se(r));let o=this.peek(e);if(o)return this.co++,Promise.resolve(o);let s=this.Y.get(e);if(s)return this.co++,s.priority=Math.max(s.priority,i),this.Li(),this.pa(e,s,r);this.ua++;let a=new AbortController,l,d,c=new Promise((p,m)=>{l=p,d=m}),u={controller:a,promise:c,consumers:0,loader:t,priority:i,state:"queued",resolve:l,reject:d};this.Y.set(e,u);let h=this.pa(e,u,r);return this.Li(),h}pc(){this.lo++,this.Gi.clear();for(let e of this.Y.values())e.controller.abort(),e.state==="queued"&&e.reject(se(e.controller.signal));this.Y.clear();for(let[e,t]of this.ie)this.ho?.(e,t);this.ie.clear()}snapshot(){let e=0,t=0;for(let r of this.ie.values())e+=r.rows.length;for(let r of this.Y.values())r.state==="active"&&t++;return{cachedBlockCount:this.ie.size,loadingBlockCount:this.Y.size,activeRequestCount:t,queuedRequestCount:Math.max(0,this.Y.size-t),cachedRowCount:e,hitCount:this.co,missCount:this.ua,evictionCount:this.ha}}Li(){for(;this.Pi<this.maxConcurrentRequests;){let e,t;for(let[r,i]of this.Y)i.state!=="queued"||i.controller.signal.aborted||(!t||i.priority>t.priority)&&(e=r,t=i);if(e==null||!t)return;this.fc(e,t)}}fc(e,t){t.state="active",this.Pi++;let r=this.lo;this.mc(t).then(i=>{r===this.lo&&!t.controller.signal.aborted&&(this.ie.set(e,{rows:i.rows,...i.lastRow==null?{}:{lastRow:i.lastRow},touchedAt:++this.ca}),this.uo()),t.resolve(i)},t.reject).finally(()=>{this.Pi=Math.max(0,this.Pi-1),this.Y.get(e)===t&&this.Y.delete(e),this.Li()})}mc(e){let{signal:t}=e.controller;return dt(Promise.resolve().then(()=>{if(t.aborted)throw se(t);return e.loader(t)}),t,()=>se(t))}pa(e,t,r){return t.consumers++,new Promise((i,o)=>{let s=!1,a=d=>{s||(s=!0,r?.removeEventListener("abort",l),t.consumers=Math.max(0,t.consumers-1),d())},l=()=>a(()=>{t.consumers===0&&this.Y.get(e)===t&&(this.Y.delete(e),t.controller.abort(r?.reason),t.state==="queued"&&t.reject(se(t.controller.signal))),o(se(r))});r?.addEventListener("abort",l,{once:!0}),t.promise.then(d=>a(()=>i(d)),d=>a(()=>o(d instanceof Error?d:new Error(String(d??"Block request failed")))))})}uo(){let e=Math.max(this.maxBlocks,this.Gi.size+1);for(;this.ie.size>e;){let t=-1,r=Number.POSITIVE_INFINITY;for(let[o,s]of this.ie)this.Gi.has(o)||s.touchedAt<r&&(t=o,r=s.touchedAt);if(t<0)return;let i=this.ie.get(t);this.ie.delete(t),this.ha++,i&&this.ho?.(t,i)}}};function Oe(n,e){if(n==null||typeof n!="object")return;let t=n[e];return Array.isArray(t)?t:void 0}var gt=class{constructor(e){this.e=e;this.u=[];this.z=[];this.ne=new Map;this.me=[];this.p=new Map;this.Re={};this.Se=null;this.Ve=null;this.A=new Set;this.W=new Set;this.Ar=[];this.kr=new Map;this.fa=[];this.k=null;this.Pr=!1;this.ma=!1;this.Je=0;this.Ni=null;this.Oi=new WeakMap;this.Fi=new WeakMap;this.Ze=new Map;this.Gr=new Map;this.Hi=0;this.Vi=0;this.Qe=null;this.et=new Map;this.wt=new Map;this.Bi=new Set;this.Ct=new Map;this.tt=new mt(12,e=>this.ga(e));this.Lr=0;this._i=null;this.po=!1;this.ya=0;this.Me=[];this.H=1;this.zr=20;this.Se=H(e.r.advancedFilterModel)}resolveRowId(e,t,r){let i=this.e.r.resolveRowId;if(!i)return r;try{let o=i({data:e,index:t,api:this.e.api});if(typeof o=="string"&&o.length>0)return o;this.e.reportError(new Error("rowKey must resolve to a non-empty identifier"),"rowKey",{index:t})}catch(o){this.e.reportError(o,"rowKey",{index:t})}return r}get G(){return this.e.r.treeData}get m(){return this.e.r.datasource!=null}get ge(){return this.m&&this.e.r.datasourceMode==="block"}Nr(){if(this.m){if(this.ge)return this.er();let e=Math.max(0,this.me.length-this.u.length);return(this.k??this.u.length)+e}return this.me.length}Or(){return this.Hi}Be(){return this.Vi}gc(){return this.ma}zi(e){return!this.m||e?.aborted?Promise.resolve():(this.va(!0),this.ge?(this.tt.configure(this.e.r.maxBlocksInCache,this.e.r.datasourceMaxConcurrentRequests),this.Wi(0,e)):this.ba(0,void 0,e))}Tt(e){this.ma=e,this.e.o.Tt(e,this.e.y("loading"))}ba(e,t,r){if(!this.m||this.Pr||this.k!=null&&e>=this.k)return Promise.resolve();let i=this.e.r.blockSize,o=t??e+i;if(o<=e)return Promise.resolve();let s=++this.Je,a=new AbortController,l=()=>a.abort(r?.reason);return r?.addEventListener("abort",l,{once:!0}),this.Ni=a,this.Pr=!0,this.Tt(!0),new Promise(d=>{let c=u=>{r?.removeEventListener("abort",l),s===this.Je&&(this.Pr=!1,this.Ni=null,this.Tt(!1),u!=null&&u?.name!=="AbortError"&&this.e.reportError(u,"datasource.getRows",{startRow:e,endRow:o})),d()};this.wa(e,o,a.signal,(u,h)=>{if(s!==this.Je||this.e.s()||a.signal.aborted){c();return}typeof h=="number"&&h>=0?this.k=h:u.length<o-e&&(this.k=e+u.length);let p=this.u.length===0;this.yc(u),c(),this.M(),p&&this.e.ye(),this.e.$.$i()},u=>c(a.signal.aborted||this.e.s()?void 0:u??new Error("Datasource request failed")))})}fo(){this.Je++,this.Ni?.abort(),this.Ni=null,this.Pr=!1,this.Tt(!1),this.tt.pc(),this.et.clear(),this.wt.clear(),this.Bi.clear();for(let[e,t]of this.Ct)this.p.get(e)===t&&this.p.delete(e);this.Ct.clear()}yc(e){for(let t of e){if(t==null)continue;let r=this.u.length,i=this.resolveRowId(t,r,`inf-${this.e.tr()}`);if(this.p.has(i)){this.e.reportError(new Error(`Duplicate row id: ${i}`),"datasource.getRows",{rowId:i});continue}let o={id:i,data:t,rowIndex:-1,selected:this.e.h.mo(i)};this.u.push(o),this.p.set(i,o),this.z.push(o)}}Wi(e,t,r=0){if(!this.ge||e<0)return Promise.resolve();if(t?.aborted)return Promise.reject(this.Ca(t.reason));let i=this.e.r.blockSize,o=this.Je,s=e*i;if(s>=this.er())return Promise.resolve();let a=this.k==null?s+i:Math.min(this.k,s+i),l=this.tt.load(e,d=>this.vc(s,a,d),t,r);return this.Tt(this.u.length===0&&this.tt.snapshot().loadingBlockCount>0),l.then(d=>{o!==this.Je||t?.aborted||this.e.s()||!this.ge||!this.tt.has(e)||this.Bi.has(e)||(this.bc(e,d),this.M(),this.e.$.$i(),o===this.Je&&!this.e.s()&&this.Ta(this.e.a.go().lastExcl-1))}).catch(d=>{throw d?.name!=="AbortError"&&this.e.reportError(d,"datasource.getRows",{startRow:s,endRow:a}),d}).finally(()=>{o===this.Je&&this.Tt(this.u.length===0&&this.tt.snapshot().loadingBlockCount>0)})}vc(e,t,r){return new Promise((i,o)=>{this.wa(e,t,r,(s,a)=>i({rows:s,...typeof a=="number"&&a>=0?{lastRow:a}:{}}),s=>o(s instanceof Error?s:new Error(typeof s=="string"?s:"Datasource request failed")))})}wa(e,t,r,i,o){let s=this.e.r.datasource,a=0,l=null,d=!1,c=()=>d?!1:(d=!0,l!=null&&clearTimeout(l),r.removeEventListener("abort",u),!0),u=()=>{c()&&o(this.Ca(r.reason))};r.addEventListener("abort",u,{once:!0});let h=()=>{if(d)return;if(r.aborted||this.e.s()){u();return}a++;let p=!1,m=g=>{if(!(p||d)){if(p=!0,r.aborted||this.e.s()){u();return}a<=this.e.r.datasourceRetryCount?l=setTimeout(h,this.retryDelay(a)):c()&&o(g)}};try{let g=s.getRows({startRow:e,endRow:t,sortModel:this.e.n.re(),filterModel:this._e(),advancedFilterModel:this.Fr(),quickFilterText:this.Ve,signal:r,onSuccess:(v,w)=>{!p&&c()&&i(v??[],w)},fail:m});g&&typeof g.catch=="function"&&g.catch(m)}catch(g){m(g)}};h()}bc(e,t){let r=this.e.r.blockSize,i=e*r;this.ga(e),typeof t.lastRow=="number"&&t.lastRow>=0?this.k=t.lastRow:t.rows.length<r&&(this.k=i+t.rows.length),t.rows.forEach((o,s)=>{if(o==null)return;let a=i+s;if(this.k!=null&&a>=this.k)return;let l=this.resolveRowId(o,a,`block-${a}`),d=this.Ct.get(l),c=this.p.get(l);if(c&&c!==d&&c.rowIndex!==a){this.e.reportError(new Error(`Duplicate row id: ${l}`),"datasource.getRows",{rowId:l});return}let u=d??{id:l,data:o,rowIndex:a,selected:this.e.h.mo(l)};u.rowIndex=a,u.selected=this.e.h.mo(l),this.Ct.delete(l),this.et.set(a,u),this.wt.delete(a),this.p.set(l,u),this.Fi.set(u,a+1)}),this.Da(),this.Bi.add(e)}ga(e){this.Bi.delete(e);let t=this.e.r.blockSize,r=e*t,i;for(let o=r;o<r+t;o++){let s=this.et.get(o);s&&(i??(i=new Set(this.e.K.getDirtyRowIds())),this.et.delete(o),i.has(s.id)?this.Ct.set(s.id,s):this.p.get(s.id)===s&&this.p.delete(s.id))}this.Da()}Da(){this.u=[...this.et.entries()].sort(([e],[t])=>e-t).map(([,e])=>e),this.z=this.u}er(){if(this.k!=null)return this.k;if(this.e.r.datasourceRowCount!=null)return this.e.r.datasourceRowCount;if(this.et.size===0)return this.e.r.blockSize;let e=0;for(let t of this.et.keys())e=Math.max(e,t+1);return e+this.e.r.blockSize}wc(e){let t=this.wt.get(e);if(!t&&(t={id:`__mach_loading_${e}`,data:null,rowIndex:e,selected:!1,loading:!0},this.wt.set(e,t),this.wt.size>2e3)){let r=this.wt.keys().next().value;r!=null&&this.wt.delete(r)}return t}Ca(e){return ie(e,"Operation aborted")}retryDelay(e){let t=Math.min(this.e.r.datasourceRetryDelay*2**Math.max(0,e-1),3e4),r=this.e.r.datasourceRetryJitter;return Math.max(0,Math.round(t*(1+(Math.random()*2-1)*r)))}Cc(e){if(this.ge){this.Ta(e);return}if(!this.m||this.Pr)return;let t=this.u.length;if(this.k!=null&&t>=this.k)return;let r=this.e.r.infiniteBufferRows;if(e+r<t&&e<t)return;let i=this.e.r.blockSize,o=this.k==null?t+i:Math.min(this.k,t+i);this.ba(t,o)}Ta(e){if(e<0)return;this.xa();let t=this.e.r.blockSize,r=Math.floor(e/t),i=Math.floor(this.e.a.go().first/t),o=this.e.r.blockPrefetch,s=r<this.ya?-1:1;this.ya=r;for(let a=i;a<r;a++)this.Wi(a,void 0,o+2).catch(()=>{});for(let a=0;a<=o;a++){let l=a===0?[r]:[r+s*a,r-s*a];for(let d of l)d<0||d*t>=this.er()||this.Wi(d,void 0,o-a+1).catch(()=>{})}}Ea(){return this.zi().catch(()=>{})}Tc(){return this.fo(),this.m?this.zi().catch(()=>{}):(this.k=null,this.rt(this.e.r.rowData),this.e.U({data:!0}),Promise.resolve())}destroy(){this.Qe=null,this.fo(),this.Ra(),this.yo(),this.u=this.z=this.me=this.Me=[],this.p.clear(),this.ne.clear(),this.kr.clear(),this.fa=[],this.A.clear(),this.W.clear(),this.Ar=[]}vo(e,t,r){if(!this.ge)return Promise.resolve();this.xa();let i=this.e.r.blockSize,o=Math.max(0,Math.trunc(e)),s=Math.min(this.er(),Math.max(o,Math.trunc(t))),a=Math.floor(o/i),l=Math.max(a,Math.floor(Math.max(o,s-1)/i)),d=[];for(let c=a;c<=l;c++)d.push(this.Wi(c,r,100));return Promise.all(d).then(()=>{})}Dc(){this.ge&&this.va(!1)}va(e){this.Sa(),this.e.K.clear(),this.fo(),e&&(this.k=null,this.A.clear()),this.u=[],this.z=[],this.p.clear(),this.e.F.clear(),this.M()}Sa(){this.Vi++,this.e.ze(),this.e.api.editing.stop({cancel:!0})}xc(){return this.tt.snapshot()}xa(){let e=new Set(this.e.K.getDirtyRowIds());for(let[l,d]of this.Ct)e.has(l)||(this.Ct.delete(l),this.p.get(l)===d&&this.p.delete(l));let t=this.e.r.blockSize,r=new Set,{first:i,lastExcl:o}=this.e.a.go();for(let l=i;l<o;l+=t)r.add(Math.floor(l/t));o>i&&r.add(Math.floor((o-1)/t));let s=this.e.a.v;s&&r.add(Math.floor(s.rowIndex/t));let a=this.e.l.Ec();a!=null&&r.add(Math.floor(a/t)),this.tt.hc(r)}rt(e){this.Sa(),this.Ra(),this.e.K.clear();let t=this.e.r.resolveRowId,r=this.e.r.childrenKey,i=[],o=[],s=new Map,a=new Map,l=0,d=(c,u,h)=>{let p=l++,m=this.resolveRowId(c,p,`auto-${p}`);if(s.has(m))return this.e.reportError(new Error(`Duplicate row id: ${m}`),"rowData",{rowId:m,index:p}),null;let g=this.G?Oe(c,r):void 0,v={id:m,data:c,rowIndex:-1,selected:!1,treeChildrenLoaded:Array.isArray(g)};if(this.Oi.set(v,u),i.push(v),s.set(m,v),h!=null){let w=a.get(h)??[];w.push(m),a.set(h,w)}else o.push(v);if(this.G&&Array.isArray(g))for(let w of g)w!=null&&d(w,u+1,m);return v};(e??[]).forEach(c=>{c!=null&&d(c,0,null)}),this.u=i,this.z=o,this.ne=a,this.p=s,this.e.F.clear();for(let c of[...this.A])s.has(c)||this.A.delete(c);if(this.e.r.defaultExpandAll)for(let c of i)this.Ma(c.id)>0&&this.A.add(c.id);this.e.h.Ia(t!=null),this.Ki()}Hr(e){return this.ne.get(e)??[]}Ma(e){return this.ne.get(e)?.length??0}bo(e){return this.Ma(e)>0}isTreeRowLoading(e){return this.p.get(e)?.treeLoading===!0}Ra(){for(let e of this.Ze.values())e.abort();this.Ze.clear(),this.Gr.clear()}loadTreeChildren(e,t=!1){let r=this.p.get(e),i=this.e.r.loadTreeChildren;if(!this.G||!r?.data||!i)return Promise.resolve([]);if(!t&&r.treeChildrenLoaded)return Promise.resolve(this.Hr(e).flatMap(l=>{let d=this.p.get(l)?.data;return d==null?[]:[d]}));let o=this.Gr.get(e);if(o&&!t)return o;this.Ze.get(e)?.abort();let s=new AbortController;this.Ze.set(e,s),r.treeLoading=!0,r.treeLoadError=void 0,this.e.U({data:!0});let a=Promise.resolve().then(()=>i({data:r.data,node:r,api:this.e.api,signal:s.signal})).then(l=>{if(s.signal.aborted||this.e.s())return[];if(!Array.isArray(l))throw new TypeError("[MachTable] loadTreeChildren must resolve to an array.");return this.Rc(r,l),r.treeChildrenLoaded=!0,r.treeLoadError=void 0,this.e.emit("treeChildrenLoaded",{rowId:e,rowNode:r,children:l}),l}).catch(l=>{if(s.signal.aborted||l?.name==="AbortError")return[];throw r.treeLoadError=l,r.treeChildrenLoaded=!1,this.e.reportError(l,"treeData.loadChildren",{rowId:e}),this.e.emit("treeChildrenLoadFailed",{rowId:e,rowNode:r,error:l}),l}).finally(()=>{this.Ze.get(e)===s&&(this.Ze.delete(e),this.Gr.delete(e),r.treeLoading=!1,this.e.U({data:!0}))});return this.Gr.set(e,a),a}Rc(e,t){let r=new Set,i=[...this.Hr(e.id)];for(;i.length>0;){let s=i.pop();r.has(s)||(r.add(s),i.push(...this.Hr(s)))}this.Sc(t,r);for(let s of r)this.Ze.get(s)?.abort(),this.Ze.delete(s),this.Gr.delete(s),this.ne.delete(s),this.p.delete(s),this.A.delete(s);this.ne.delete(e.id);let o=this.wo(e)+1;for(let s of t)s!=null&&this.Co(e,s,o);this.Aa(),this.e.h.Ia(this.e.r.resolveRowId!=null),this.M()}Sc(e,t){let r=this.e.r.resolveRowId,i=r?new Set([...this.p.keys()].filter(l=>!t.has(l))):null,o=new WeakSet,s=[...e],a=0;for(;s.length>0;){let l=s.pop();if(l==null)continue;if(typeof l=="object"){if(o.has(l))throw new TypeError("[MachTable] Lazy tree children contain a cyclic object graph.");o.add(l)}if(r&&i){let c=r({data:l,index:a++,api:this.e.api});if(typeof c!="string"||c.length===0)throw new TypeError("[MachTable] rowKey must resolve to a non-empty identifier for lazy tree children.");if(i.has(c))throw new Error(`Duplicate row id: ${c}`);i.add(c)}let d=Oe(l,this.e.r.childrenKey);d&&s.push(...d)}}Vr(e,t=!0){let r=this.e.r.resolveRowId,i=[],o=[],s=[];if(e.remove?.length){let l=new Set,d=new Set,c=h=>{if(r){let m=[this.resolveRowId(h,-1,`__missing_remove_${this.e.tr()}`)];for(;m.length>0;){let g=m.pop();if(!l.has(g)){l.add(g);for(let v of this.ne.get(g)??[])m.push(v)}}}else{let p=[h];for(;p.length>0;){let m=p.pop();d.add(m);let g=this.G?Oe(m,this.e.r.childrenKey):void 0;if(g)for(let v of g)p.push(v)}}};e.remove.forEach(c),this.u=this.u.filter(h=>{let p=l.has(h.id)||h.data!=null&&d.has(h.data);return p&&(s.push(h.id),this.p.delete(h.id),this.ne.delete(h.id)),!p});let u=new Set(this.u);this.z=this.z.filter(h=>u.has(h))}if(e.update?.length)for(let l of e.update){let d;r?d=this.p.get(this.resolveRowId(l,-1,`__missing_update_${this.e.tr()}`)):d=this.u.find(c=>c.data===l),d&&(o.push({node:d,before:d.data,after:l}),d.data=l,s.push(d.id),this.e.a.Ui(d),i.push(d))}if(e.add?.length){let l=e.addIndex!=null?Math.max(0,Math.min(e.addIndex,this.z.length)):this.z.length,d=[];e.add.forEach((c,u)=>{let h=this.resolveRowId(c,l+u,`add-${this.e.tr()}`);if(this.p.has(h)){this.e.reportError(new Error(`Duplicate row id: ${h}`),"transaction.add",{rowId:h});return}let p={id:h,data:c,rowIndex:-1,selected:!1};this.p.set(h,p),this.Oi.set(p,0);let m=this.G?Oe(c,this.e.r.childrenKey):void 0;if(m)for(let g of m)g!=null&&this.Co(p,g,1);d.push(p)}),this.z=this.z.slice(0,l).concat(d,this.z.slice(l)),this.Aa()}let a={pipelineChanged:this.Mc(e,o),updatedRowIds:i.map(l=>l.id)};return this.e.F.Ic(s),this.Ac(a,t),this.e.K.kc(s),a}Ac(e,t){e.pipelineChanged&&(this.Qe=null),t&&(e.pipelineChanged?this.Ki():e.updatedRowIds.length&&this.ka())}Pc(e){if(e.length===0)return{pipelineChanged:!1,updatedRowIds:[]};let t=this.Vi,r=!1,i=new Set;for(let o of e){let s=this.Vr(o,!1);if(this.Vi!==t)return{pipelineChanged:!1,updatedRowIds:[]};r||(r=s.pipelineChanged);for(let a of s.updatedRowIds)i.add(a)}return r?this.Ki():i.size>0&&this.ka(),{pipelineChanged:r,updatedRowIds:[...i]}}Mc(e,t){if(e.add?.length||e.remove?.length)return!0;if(!t.length)return!1;let r=this.Pa();if(r===null)return!0;if(!r.length)return!1;let i=this.Qe;return!i||r.length!==i.fields.length||r.some((o,s)=>o!==i.fields[s])?!0:t.some(({node:o,before:s,after:a})=>nn(s,a,r,i.values.get(o)))}Pa(){if(this.G||this.e.r.masterDetail||this.e.r.getRowHeight||this.Ga())return null;let e=this.e.n.d();if(e.some(r=>r.colDef.autoHeight===!0||r.colDef.autoRowSpan===!0||r.colDef.rowSpan!=null))return null;let t=!this.e.r.manualFiltering;return en({columns:e,customAggregates:this.e.r.aggFuncs,sortModel:this.e.r.manualSorting?[]:this.e.n.re(),filterModel:t?this.Re:{},advancedFilter:t?this.Se:null,quickFilter:t?this.Ve:null})}Gc(){let e=this.Pa();this.Qe=e?.length?{fields:e,values:rn(this.u,e)}:null}ka(){this.e.emit("modelUpdated",{rowCount:this.Me.length})}Co(e,t,r){let i=this.resolveRowId(t,-1,`add-${this.e.tr()}`);if(this.p.has(i)){this.e.reportError(new Error(`Duplicate row id: ${i}`),"transaction.add",{rowId:i});return}let o=Oe(t,this.e.r.childrenKey),s={id:i,data:t,rowIndex:-1,selected:!1,treeChildrenLoaded:Array.isArray(o)};this.p.set(i,s),this.Oi.set(s,r);let a=this.ne.get(e.id)??[];if(a.push(s.id),this.ne.set(e.id,a),!!o)for(let l of o)l!=null&&this.Co(s,l,r+1)}Aa(){this.u=[];let e=t=>{this.u.push(t),this.p.has(t.id)||this.p.set(t.id,t);for(let r of this.ne.get(t.id)??[]){let i=this.p.get(r);i&&e(i)}};for(let t of this.z)e(t)}Dt(e){let t=JSON.stringify(this.Re),r=new Set(this.e.n.te().map(o=>o.id));this.Re=Z(e,r);let i=JSON.stringify(this.Re)!==t;return i&&(this.Qe=null),i}_e(){return{...this.Re}}Lc(e=this.Se){let t=Object.keys(this.Re).length>0&&this.Dt(this.Re),r=(e!=null||this.Se!=null)&&this.it(e);return t||r}it(e){let t=new Set(this.e.n.te().map(s=>s.id)),r=H(e,t),i=JSON.stringify(this.Se);this.Se=r,this.e.r.advancedFilterModel=r;let o=JSON.stringify(r)!==i;return o&&(this.Qe=null),o}Fr(){return H(this.Se)}xt(e){let t=e!=null&&e.trim()!==""?e:null;return t===this.Ve?!1:(this.Ve=t,this.Qe=null,!0)}La(){return this.Ve}Br(){return Object.keys(this.Re).length>0||this.Se!=null||this.Ve!=null}M(){this.Ki(),this.e.U({data:!0})}To(){this.m?this.Ea():this.M()}Ki(){this.Qe=null;let e=this.e.ve.start(),t=this.e.n.d(),r=(s,a)=>this.e.c(s,a);if(this.m){this.Nc(e);return}if(this.Oc(e))return;let i,o=[];if(this.G)i=this.Fc(t,r);else{i=this.u,this.Br()&&!this.e.r.manualFiltering&&(i=i.filter(Pr(t,this.Re,this.Se,this.Ve,r)));let a=this.e.n.re();if(a.length>0&&!this.e.r.manualSorting)try{i=Gr(i,a,t,r)}catch(d){this.e.reportError(d,"comparator",{sortModel:a})}let l=this.e.n.Xe();if(l.length>0){let d=this.Hc(i,l);i=d.rows,o=d.ambiguousExpansions}else if(this.e.r.masterDetail){let d=[];for(let c of i)d.push(c),this.A.has(c.id)&&this.isRowExpandable(c)&&d.push({id:`__detail__${c.id}`,data:c.data,rowIndex:-1,selected:!1,isDetail:!0,masterId:c.id});i=d}}this.Na(i,e,!0),this.Vc(o)}Na(e,t,r=!1){for(let o of this.u)o.rowIndex=-1;let i=0;e.forEach((o,s)=>{o.rowIndex=s,!o.isDetail&&!o.isGroup&&this.Fi.set(o,++i)}),this.Me=e,this._r(),r&&this.Gc(),this.Bc((o,s)=>this.e.c(o,s)),this.e.emit("modelUpdated",{rowCount:e.length}),this.e.ve.Oa(t)}Nc(e){this.u.forEach((t,r)=>{this.ge||(t.rowIndex=r),this.Fi.set(t,this.ge?t.rowIndex+1:r+1)}),this.me=this.u,this.Me=this.u,this.kr.clear(),this.Hi++,this.e.emit("modelUpdated",{rowCount:this.u.length}),this.e.ve.Oa(e)}Oc(e){let t=this.po;return this.po=!1,!t&&this.Ga()?(this._c(e),!0):(this.yo(),!1)}Ga(){if(!this.e.r.dataProcessor||this.u.length<this.e.r.dataProcessorMinRows||this.G||this.e.r.masterDetail||this.e.n.Xe().length>0)return!1;let e=!this.e.r.manualFiltering&&this.Br(),t=!this.e.r.manualSorting&&this.e.n.re().length>0;return e||t}_c(e){this.yo();let t=this.e.r.dataProcessor;if(!t)return;let r=++this.Lr,i=new AbortController;this._i=i;let o=this.e.n.d(),s=this.u.flatMap(d=>d.data==null?[]:[{id:d.id,data:d.data}]),a=!this.e.r.manualFiltering,l=!this.e.r.manualSorting;Promise.resolve().then(()=>t.process({rows:s,columns:o.map(d=>({colId:d.id,...d.colDef.field?{field:d.colDef.field}:{}})),sortModel:l?this.e.n.re():[],filterModel:a?this._e():{},advancedFilterModel:a?this.Fr():null,quickFilterText:a?this.Ve:null,signal:i.signal})).then(d=>{if(r!==this.Lr||i.signal.aborted||this.e.s())return;let c=new Set,u=[];for(let h of d.rowIds){if(c.has(h))continue;c.add(h);let p=this.p.get(h);p&&!p.isDetail&&!p.isGroup&&u.push(p)}this.Na(u,e),this.e.U({data:!0})}).catch(d=>{r!==this.Lr||i.signal.aborted||this.e.s()||(this.e.reportError(d,"dataProcessor.process"),this.po=!0,this.M())}).finally(()=>{r===this.Lr&&(this._i=null)})}yo(){this.Lr++,this._i?.abort(),this._i=null}get be(){return this.e.r.paginationEnabled&&!this.m}_r(){if(!this.be){this.me=this.Me,this.Hi++;return}let e=this.Wr(),t=this.getPageCount();this.H>t&&(this.H=t),this.H<1&&(this.H=1),this.e.r.paginationPage=this.H;let r=(this.H-1)*e;this.me=this.e.r.paginationMode==="server"?this.Me:this.Me.slice(r,r+e),this.me.forEach((i,o)=>{i.rowIndex=o}),this.Hi++}Wr(){return this.zr=this.e.r.paginationPageSize,Math.max(1,this.zr)}rr(){return this.be?this.H:1}getTotalRowCount(){return this.m?this.Nr():this.be&&this.e.r.paginationMode==="server"?this.e.r.paginationTotal:this.Me.length}getPageCount(){return this.be?Math.max(1,Math.ceil(this.getTotalRowCount()/this.Wr())):1}Fa(){return this.Me}setPage(e,t=!1){if(!this.be)return;let r=this.getPageCount(),i=Math.max(1,Math.min(Math.round(e)||1,r));i!==this.H&&(this.H=i,this.e.r.paginationPage=i,this._r(),this.e.U({data:!0}),this.e.a.ji(0,"top"),t||this.$r())}setPageSize(e){if(!this.be)return;let t=Math.max(1,Math.round(e)||this.Wr()),r=(this.H-1)*this.Wr();this.e.r.paginationPageSize=t,this.zr=t,this.H=Math.floor(r/t)+1,this.e.r.paginationPage=this.H,this._r(),this.e.U({data:!0}),this.$r()}Ha(e,t){this.zr=Math.max(1,Math.round(t)||1),this.e.r.paginationPageSize=this.zr,this.H=Math.max(1,Math.round(e)||1),this.e.r.paginationPage=this.H}Va(e){this.e.r.paginationEnabled!==e&&(this.e.r.paginationEnabled=e&&!this.m,this.e.r.paginationEnabled&&(this.H=1),this._r(),this.e.U({data:!0}),this.$r())}zc(){this.be&&(this.H=this.e.r.paginationMode==="server"?this.e.r.paginationPage:1,this._r(),this.e.U({data:!0}),this.$r())}$r(e=this.Wr()){this.e.emit("paginationChanged",{page:this.rr(),pageSize:e,pageCount:this.getPageCount(),total:this.getTotalRowCount()})}Fc(e,t){let r=this.e.r.manualSorting?[]:this.e.n.re(),i=new Map,o=this.Br()&&!this.e.r.manualFiltering,s=Pr(e,this.Re,this.Se,this.Ve,t),a=c=>{let u=i.get(c.id);if(u!==void 0)return u;let h=!0;if(o){h=s(c);for(let p of this.ne.get(c.id)??[]){let m=this.p.get(p);m&&a(m)&&(h=!0)}}return i.set(c.id,h),h},l=[],d=c=>{let u=c;r.length>0&&(u=Gr(c,r,e,t));for(let h of u)if(a(h)&&(l.push(h),this.A.has(h.id))){let p=(this.ne.get(h.id)??[]).map(m=>this.p.get(m)).filter(m=>m!=null);d(p)}};return d(this.z),l}Wc(){let e=this.fa,t=0;for(let r of this.me)!r.isDetail&&!r.isGroup&&(e[t++]=r);return e.length=t,e}$c(e,t,r,i){let o=t.colDef.rowSpan;if(!o)return 1;try{let s=o({api:this.e.api,colDef:t.colDef,column:t,node:e,data:e.data,value:r,rowIndex:e.rowIndex});return Math.max(1,Math.min(Math.round(s)||1,i))}catch(s){return this.e.reportError(s,"rowSpan",{colId:t.id,rowId:e.id}),1}}Kc(e,t,r,i,o){if(!r.colDef.autoRowSpan||i==null||i==="")return 1;let s=1;for(;t+s<e.length&&ct(i,o(e[t+s],r))===0;)s++;return s}Uc(e,t,r){let i=new Int32Array(e.length),o=0;for(;o<e.length;){let s=e[o],a=r(s,t),l=t.colDef.rowSpan?this.$c(s,t,a,e.length-o):this.Kc(e,o,t,a,r);i[o]=l;for(let d=1;d<l;d++)i[o+d]=-1;o+=l}return i}Bc(e){if(this.kr.clear(),this.G||this.e.r.masterDetail||this.e.n.Xe().length>0)return;let t=this.e.n.d().filter(i=>i.colDef.rowSpan!=null||i.colDef.autoRowSpan===!0);if(t.length===0)return;let r=this.Wc();if(r.length!==0)for(let i of t)this.kr.set(i.id,this.Uc(r,i,e))}jc(e){return this.kr.get(e)}Ba(e){return this.Fi.get(e)??0}wo(e){return this.Oi.get(e)??0}Hc(e,t){let r=ht(this.e.r.aggFuncs),i=this.e.n.dc();this.Ar=[];let o=l=>{let d={};for(let c of i){let u=r(c.colDef.aggFunc);if(u)try{d[c.id]=Yi(l,u,h=>this.e.c(h,c))}catch(h){this.e.reportError(h,"aggFunc",{colId:c.id,aggFunc:c.colDef.aggFunc}),d[c.id]=null}}return d},s=Qi(this.W,this.u,t,(l,d)=>this.e.c(l,d));this.W=s.expanded;let a=Zi(e,t,(l,d)=>this.e.c(l,d),o,this.W);return this.Ar=a.ids,{rows:a.rows,ambiguousExpansions:s.ambiguous}}Vc(e){for(let t of e){if(this.e.s())return;this.e.reportError(new Error(`Ambiguous legacy group expansion: ${t}`),"gridState.groupExpansion",{groupId:t})}}isRowExpandable(e){if(this.G){if(this.bo(e.id)||e.treeLoading)return!0;if(e.treeChildrenLoaded||!e.data||!this.e.r.loadTreeChildren)return!1;let r=this.e.r.isTreeRowExpandable;if(!r)return!1;try{return r({data:e.data,node:e,api:this.e.api})}catch(i){return this.e.reportError(i,"isTreeRowExpandable",{rowId:e.id}),!1}}if(!this.e.r.masterDetail)return!1;let t=this.e.r.isRowExpandable;if(t)try{return t({data:e.data,node:e,api:this.e.api})}catch(r){return this.e.reportError(r,"isRowExpandable",{rowId:e.id}),!1}return!0}isRowExpanded(e){return this.A.has(e)}qc(){return[...this.A]}Yc(){return[...this.W]}Xc(e,t){this.A=new Set(e.filter(r=>this.p.has(r))),this.W=new Set(t)}Jc(e){return this.Do(e,!0)}Zc(e){return this.Do(e,!1)}qi(e){return this.Do(e,!this.A.has(e))}Do(e,t){let r=this.p.get(e);return!r||t&&!this.isRowExpandable(r)?!1:(t===this.A.has(e)||(t?this.A.add(e):this.A.delete(e),this.M(),this.e.emit("detailToggled",{rowId:e,rowNode:r,expanded:t}),t&&this.G&&!this.bo(e)&&!r.treeLoading&&this.loadTreeChildren(e).catch(()=>{})),t)}setAllDetailsExpanded(e){let t=!1;if(e)for(let r of this.u)!this.A.has(r.id)&&this.isRowExpandable(r)&&(this.A.add(r.id),t=!0);else this.A.size>0&&(this.A.clear(),t=!0);t&&this.M()}xo(e){return this.setGroupExpanded(e,!this.W.has(e))}isGroupExpanded(e){return this.W.has(e)}setAllGroupsExpanded(e){let t=this.W.size;if(e)for(let r of this.Ar)this.W.add(r);else this.W.clear();this.W.size!==t&&this.M()}setGroupExpanded(e,t){return!this.Ar.includes(e)||t===this.W.has(e)||(t?this.W.add(e):this.W.delete(e),this.M()),t}_a(){return!this.G&&!this.m&&!this.e.r.dataProcessor&&this.e.r.paginationMode!=="server"&&this.e.n.re().length===0&&this.e.n.Xe().length===0}za(e,t){if(!this._a()||!Number.isInteger(e)||!Number.isInteger(t))return!1;let r=this.f(e),i=this.f(t);if(!r||!i||r.isDetail||i.isDetail||r.isGroup||i.isGroup)return!1;let o=this.u.indexOf(r),s=this.u.indexOf(i);return o<0||s<0||o===s?!1:(this.u.splice(o,1),this.u.splice(s,0,r),this.M(),!0)}Oe(){return this.u}Qc(){return this.z}Et(){return this.me}P(){return this.ge?this.er():this.me.length}f(e){return this.ge?e<0||e>=this.er()?void 0:this.et.get(e)??this.wc(e):this.me[e]}X(e){return this.p.get(e)}eu(e){this.u.forEach(e)}tu(e){let t=0;for(let r of this.Me)r.isDetail||r.isGroup||e(r,t++)}};var yt=class{constructor(e){this.e=e;this.L=new Set;this.We=null;this.Kr=new Set}mo(e){return this.L.has(e)}ru(e){return this.Kr.has(e)}Rt(e){if(e.loading)return!1;let t=this.iu(e),r=t?.colDef.selectable;if(!t||!r)return!0;try{return r({api:this.e.api,colDef:t.colDef,column:t,node:e,data:e.data,value:this.e.c(e,t),rowIndex:e.rowIndex})}catch(i){return this.e.reportError(i,"selectable",{rowId:e.id,colId:t?.id}),!1}}iu(e){if(!(e.isGroup||e.isDetail))return this.e.n.d().find(t=>t.hasCheckbox&&t.colDef.selectable!=null)}St(){return this.e.i.Oe().filter(e=>this.L.has(e.id))}Wa(e=this.St()){return e.filter(t=>t.data!=null).map(t=>t.data)}$a(){return[...this.L]}nu(e){let t=new Set(e),r=this.e.i.Oe().filter(i=>t.has(i.id)&&!i.isDetail&&!i.isGroup).map(i=>({node:i,selected:!0}));this.Mt(r,!0)}Ia(e){let t=this.e.i.Oe();if(!e)this.L.clear(),this.We=null;else{let r=new Set(t.map(i=>i.id));for(let i of[...this.L])r.has(i)||this.L.delete(i);this.We!=null&&!r.has(this.We)&&(this.We=null)}this.Ka();for(let r of t)r.selected=this.L.has(r.id)}Ua(e){let{selectable:t,selected:r}=this.ja(e.leafNodes??[],!1);return{all:r>0&&r===t,some:r>0}}ou(e,t){let r=(e.leafNodes??[]).filter(i=>this.Rt(i));r.length!==0&&this.Mt(r.map(i=>({node:i,selected:t})))}ir(e,t,r=!1){this.Mt([{node:e,selected:t,clearOthers:r}])}su(e,t=!0,r=!0){let i=this.e.i.X(e);i&&this.ir(i,t,r)}au(e,t){let r=t==="single";this.ir(e,r||!e.selected,r),this.We=e.id}lu(e,t,r){return!r||!t.ctrlKey&&!t.metaKey?!1:(this.ir(e,!e.selected),this.We=e.id,!0)}du(e,t,r){if(!r||!t.shiftKey||this.We==null)return!1;let i=this.e.i.X(this.We);if(!i||i.rowIndex<0||e.rowIndex<0)return!1;let o=Math.min(i.rowIndex,e.rowIndex),s=Math.max(i.rowIndex,e.rowIndex),a=[];for(let l=o;l<=s;l++){let d=this.e.i.f(l);d&&!d.isDetail&&!d.isGroup&&this.Rt(d)&&a.push({node:d,selected:!0})}return this.Mt(a),!0}qa(e,t,r){let i=this.e.r.rowSelection;if(i==="none"||!this.Rt(e))return;if(r){this.au(e,i);return}let o=i==="multiple";this.lu(e,t,o)||this.du(e,t,o)||(this.ir(e,!0,!0),this.We=e.id)}selectAll(e=!0){let t=this.e.r.rowSelection;if(t==="none")return;let i=(e?this.e.i.Et():this.e.i.Oe()).filter(o=>!o.isDetail&&!o.isGroup&&this.Rt(o));if(i.length!==0){if(t==="single"){this.ir(i[0],!0,!0);return}this.Mt(i.map(o=>({node:o,selected:!0})))}}deselectAll(){this.Mt([],!0)}cu(){let e=this.e.i,{selectable:t,selected:r}=this.ja(e.Et(),!0),i=r>0&&r===t&&(!e.m||t>=e.Nr());return{all:i,some:r>0&&!i}}ja(e,t){let r=0,i=0;for(let o of e)t&&(o.isDetail||o.isGroup)||!this.Rt(o)||(r++,this.L.has(o.id)&&i++);return{selectable:r,selected:i}}uu(e,t=!1){this.Mt(e,t)}hu(e,t,r){!t&&!e.some(i=>i.clearOthers)||(this.L=t?new Set:new Set(e.filter(i=>i.selected).flatMap(i=>r?this.Ya(i.node):[i.node.id])))}pu(e,t){for(let r of e){if(!this.Rt(r.node))continue;let i=t?this.Ya(r.node):[r.node.id];for(let o of i)r.selected?this.L.add(o):this.L.delete(o)}}fu(e){let t=new Set(e);for(let r of this.L)t.delete(r)||t.add(r);return t}mu(e,t){let r=[],i=new Set([...e,...t,...this.Kr]);for(let o of this.e.i.Oe()){let s=this.L.has(o.id);(i.has(o.id)||o.selected!==s)&&o.rowIndex>=0&&r.push(o.rowIndex),o.selected=s}return r}Mt(e,t=!1){let r=new Set(this.L),i=this.e.i.G&&this.e.r.autoCheckedChildren;this.hu(e,t,i),this.pu(e,i);let o=this.fu(r),s=new Set(this.Kr);this.Ka();let a=this.mu(o,s);if(o.size>0){this.e.a.M(a),this.e.$.$i();let l=this.St();this.e.emit("selectionChanged",{selectedNodes:l,selectedRows:this.Wa(l)})}}Ya(e){let t=[e.id],r=i=>{for(let o of this.e.i.Hr(i))t.push(o),r(o)};return r(e.id),t}Ka(){if(this.Kr.clear(),!this.e.i.G)return;let e=t=>{let r=this.e.i.Hr(t);if(r.length===0)return{all:this.L.has(t),some:this.L.has(t)};let i=!0,o=!1;for(let s of r){let a=e(s);i&&(i=a.all),o||(o=a.some)}return o&&!i&&this.Kr.add(t),i?this.L.add(t):this.L.delete(t),{all:i,some:o}};for(let t of this.e.i.Qc())e(t.id)}};var vt=class{constructor(e){this.e=e;this.It=null;this.oe=0;this.nt=0;this.Ie=null;this.At=null;this.Ur=e=>{let t=this.So(e);t&&(this.nt=this.Ja(t,e.clientX),t.didResize||(t.didResize=Math.abs(this.nt-t.startWidth)>=.5),!this.oe&&(this.oe=requestAnimationFrame(()=>{this.oe=0,this.vu()})))};this.or=e=>{let t=this.So(e);t&&(this.nt=this.Ja(t,e.clientX),t.didResize||(t.didResize=Math.abs(this.nt-t.startWidth)>=.5),this.bu(t))};this.Yi=e=>{this.So(e)&&this.kt()};this.wu=()=>{this.kt()}}gu(e,t){if(!this.e.r.enableColumnResize||!t.resizable||e.isPrimary===!1)return;this.kt();let r=e.currentTarget,i=t.currentWidth;this.nt=i,this.It={column:t,didResize:!1,handle:r,pointerId:e.pointerId,startFlex:t.flex,startManualWidth:t.manualWidth,startWidth:i,startX:e.clientX},this.Eo(r,!0);try{r.setPointerCapture?.(e.pointerId)}catch{}this.e.o.root.classList.add("mach-root--resizing"),r.classList.add("mach-header-resize--active"),this.yu(this.It)}kt(e=!0){let t=this.It;t&&(this.It=null,this.Ro(),this.Eo(t.handle,!1),e&&(t.column.manualWidth=t.startManualWidth,t.column.flex=t.startFlex,this.e.nr()),this.e.o.root.classList.remove("mach-root--resizing"),this.Xa(t))}bu(e){this.It=null,this.Ro(),e.didResize&&(Math.abs(this.nt-e.startWidth)<.5?(e.column.manualWidth=e.startManualWidth,e.column.flex=e.startFlex):this.e.n.Ee(e.column,this.nt),this.e.nr()),this.Eo(e.handle,!1);try{e.handle.releasePointerCapture?.(e.pointerId)}catch{}this.e.o.root.classList.remove("mach-root--resizing"),this.Xa(e),e.didResize&&this.e.ot([e.column])}vu(){let e=this.It;!e||!this.e.n.Ee(e.column,this.nt)||(this.e.nr(),this.jr(e),this.e.Za(e.column,!1))}yu(e){this.Ie=document.createElement("div"),this.Ie.className="mach-column-resize-guide",this.Ie.setAttribute("aria-hidden","true"),this.At=document.createElement("span"),this.At.className="mach-column-resize-label",this.Ie.appendChild(this.At),this.e.o.root.appendChild(this.Ie),this.jr(e)}jr(e){if(!this.Ie||!this.At)return;let t=this.e.o.root,r=t.getBoundingClientRect(),i=e.handle.parentElement.getBoundingClientRect(),o=Math.max(0,Math.min(t.clientWidth,i.right-r.left-t.clientLeft)),s=Math.max(32,Math.min(t.clientWidth-32,o));this.Ie.style.left=`${o}px`,this.Ie.style.top=`${Math.max(0,i.top-r.top-t.clientTop)}px`,this.At.style.left=`${s-o}px`,this.At.textContent=`${Math.round(e.column.currentWidth)} px`}Xa(e){e.handle.classList.remove("mach-header-resize--active"),this.Ie?.remove(),this.Ie=null,this.At=null}Ja(e,t){let r=Number.isFinite(t)?t:e.startX;return Math.max(1,e.startWidth+r-e.startX)}So(e){let t=this.It;return t&&e.pointerId===t.pointerId?t:null}Ro(){this.oe&&cancelAnimationFrame(this.oe),this.oe=0}Eo(e,t){L(window,t,{pointermove:this.Ur}),L(window,t,{pointerup:this.or,pointercancel:this.Yi},!0),L(e,t,{lostpointercapture:this.wu})}destroy(){this.kt(!1),this.Ro(),this.e.o.root?.classList.remove("mach-root--resizing")}};var on=6,bt=class{constructor(e){this.e=e;this.qr=null;this.sr=null;this.Mo=!1;this.ae=0;this.Xi=null;this.Ur=e=>{if(this.sr){this.Du(e);return}let t=this.qr;t&&(Math.abs(e.clientX-t.startX)<on&&Math.abs(e.clientY-t.startY)<on||this.xu(e))};this.or=e=>{this.qr=null,e.type!=="pointercancel"&&this.sr&&this.ko(e.clientX,e.clientY),this.Io();let t=this.Qa();t&&e.type!=="pointercancel"&&t.targetIndex>=0&&this.e.Mr(t.column.id,t.targetIndex)}}Cu(e,t){e.button===0&&t.movable&&(this.qr={column:t,startX:e.clientX,startY:e.clientY},this.Yr(!0))}Yr(e){L(window,e,{pointermove:this.Ur,pointerup:this.or,pointercancel:this.or})}Tu(){let e=this.Mo;return this.Mo=!1,e}xu(e){let t=this.qr;if(!t)return;let r=this.Eu(t.column);if(!r||!r.parentElement){this.Io();return}this.Mo=!0;let i=f("div","mach-drop-indicator"),o=f("div","mach-column-drag-ghost");o.textContent=t.column.colDef.headerName??t.column.colDef.field??t.column.id,o.ariaHidden="true",M(o,this.e.o.root),document.body.appendChild(o),r.parentElement.appendChild(i),r.classList.add("mach-header-cell--dragging"),this.e.o.root.classList.add("mach-root--dragging");let s=this.e.a.Ao(t.column),a=this.e.o.ar[s],l=this.e.n.C(s),d=new Float64Array(l.length+1),c=new Float64Array(l.length);for(let h=0;h<l.length;h++){let p=l[h].currentWidth;c[h]=d[h]+p/2,d[h+1]=d[h]+p}let u=o.getBoundingClientRect();this.sr={column:t.column,cellEl:r,ghost:o,indicator:i,targetIndex:-1,pane:s,containerLeft:a.getBoundingClientRect().left,startScrollLeft:this.e.o.T.center.scrollLeft,fromIndex:l.indexOf(t.column),midpoints:c,offsets:d,ghostWidth:u.width,ghostHeight:u.height},this.ko(e.clientX,e.clientY)}Eu(e){let t=this.e.a.Ao(e);return this.e.o.ar[t].querySelector(`.mach-header-cell[data-col-id="${_s(e.id)}"]`)}Du(e){this.Xi={clientX:e.clientX,clientY:e.clientY},!this.ae&&(this.ae=requestAnimationFrame(()=>{this.ae=0;let t=this.Xi;this.Xi=null,t&&this.ko(t.clientX,t.clientY)}))}ko(e,t){let r=this.sr;if(!r)return;let i=C(e+12,8,window.innerWidth-r.ghostWidth-8),o=C(t+12,8,window.innerHeight-r.ghostHeight-8);r.ghost.style.transform=`translate3d(${i}px, ${o}px, 0)`;let s=r.pane==="center"?this.e.o.T.center.scrollLeft-r.startScrollLeft:0,a=e-(r.containerLeft-s),l=r.midpoints.length;for(let d=0;d<r.midpoints.length;d++)if(a<r.midpoints[d]){l=d;break}r.targetIndex=l>r.fromIndex?l-1:l,r.indicator.style.transform=`translate3d(${r.offsets[l]}px, 0, 0)`}Qa(){let e=this.sr;return e?(this.sr=null,e.cellEl.classList.remove("mach-header-cell--dragging"),e.ghost.remove(),e.indicator.remove(),this.e.o.root.classList.remove("mach-root--dragging"),e):null}Io(){this.Yr(!1),this.ae&&cancelAnimationFrame(this.ae),this.ae=0,this.Xi=null}destroy(){this.Io(),this.Qa(),this.qr=null}};function _s(n){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(n):n.replace(/[^a-zA-Z0-9_-]/g,"\\$&")}var Nr=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?$/;function wt(n,e=!0){if(n==="")return null;if(!e||typeof n!="string"||!Nr.test(n)||/^[+-]?0\d/.test(n))return n;let t=Number(n);return Number.isFinite(t)&&(!Number.isInteger(t)||Number.isSafeInteger(t))?t:n}function zs(n,e){let t=n==null?"":String(n);return t.includes(e)||t.includes('"')||t.includes(`
2
+ `)||t.includes("\r")?'"'+t.replace(/"/g,'""')+'"':t}function ae(n){return typeof n!="string"||n===""||Nr.test(n)?n:/^[\s\u0000-\u001f]*[=+\-@]/.test(n)?"'"+n:n}function sn(n,e={}){let t=e.columnSeparator??",",r=e.protectFormulas??!0,i=n.map(o=>o.map(s=>zs(r?ae(s):s,t)).join(t)).join(`\r
3
+ `);return e.prependBOM?"\uFEFF"+i:i}function Or(n){return n==null?"":String(n)}function Ws(n,e){let t=e?ae(n):n,r=Or(t);return/["\t\n\r]/.test(r)?'"'+r.replace(/"/g,'""')+'"':r}function Ct(n,e=!0){return n.map(t=>t.map(r=>Ws(r,e)).join(" ")).join(`
4
+ `)}function Tt(n){return xt(n," ")}function Dt(n,e=","){return xt(n,e)}function xt(n,e){let t=[],r=[],i="",o=!1,s=0;for(;s<n.length;){let a=n[s];a==='"'&&(o||i==="")?o&&n[s+1]==='"'?(i+=a,s++):o=!o:o?i+=a:a===e?(r.push(i),i=""):a===`
5
+ `||a==="\r"?(r.push(i),t.push(r),r=[],i="",a==="\r"&&n[s+1]===`
6
+ `&&s++):i+=a,s++}return(i!==""||r.length>0)&&(r.push(i),t.push(r)),t}function $s(n){let e=null;try{return e=document.createElement("textarea"),e.value=n,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy")}catch{return!1}finally{e?.remove()}}async function Fe(n){try{if(typeof navigator<"u"&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(n),!0}catch{}return $s(n)}var an=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]),Ks=new Set([...an,"Enter","F2","Tab"," ","Escape","Delete","Backspace"]),Et=class{constructor(e){this.e=e;this.rl=e=>{if(this.Po(e)||this.e.s()||this.e.r.suppressClipboard)return;let t=this.e.a.lr();if(!t)return;let r=this.e.nl(t),i=e.clipboardData;if(e.preventDefault(),i&&typeof i.setData=="function"){try{i.setData("text/plain",r)}catch{return}e.type==="cut"&&this.e.Go(t)}else e.type==="cut"?this.e.Mu(t,r):Fe(r)};this.Su=e=>{if(this.Po(e)||this.e.r.suppressClipboard)return;let t=this.e.a.Lo();if(!t)return;let r=e.clipboardData,i=r&&typeof r.getData=="function"?r.getData("text/plain"):null;typeof i!="string"||i===""||(e.preventDefault(),this.e.ol(i,t.row,t.colIdx))};this.Ru=e=>{this.Po(e)||this.e.s()||this.Iu(e)||Ks.has(e.key)&&(this.Au(e)||this.ku(e)||this.Pu(e))}}init(){this.tl("addEventListener")}destroy(){this.tl("removeEventListener")}tl(e){let t=this.e.o.root;t[e]("keydown",this.Ru),t[e]("copy",this.rl),t[e]("cut",this.rl),t[e]("paste",this.Su)}il(e,t,r){let i=this.e.n.d(),o=i.findIndex(d=>d.id===t);if(o<0)return null;let s=this.e.i.P(),a=o,l=e;for(let d=0;d<(i.length+1)*(s+1);d++){if(a+=r,a>=i.length){if(l>=s-1)return null;a=0,l=this.Pt(l+1,1)}else if(a<0){if(l<=0)return null;a=i.length-1,l=this.Pt(l-1,-1)}if(l<0||l>=s)return null;let c=this.e.i.f(l);if(c&&!c.isDetail&&this.e.l.J(c,i[a]))return{rowIndex:l,column:i[a]}}return null}Pt(e,t){let r=this.e.i.P();for(;e>=0&&e<r;){let i=this.e.i.f(e);if(!i||!i.isDetail)return e;e+=t}return-1}Po(e){let t=e.target;return e.defaultPrevented||t instanceof HTMLElement&&(t.isContentEditable||!!t.closest("button,a[href],input,textarea,select"))||this.e.l.isEditing()}Iu(e){if(!e.ctrlKey&&!e.metaKey)return!1;let t=e.key.toLowerCase();return t==="a"?(this.e.r.rowSelection==="multiple"&&(e.preventDefault(),this.e.h.selectAll(!0)),!0):e.altKey||t!=="z"&&t!=="y"?!1:(e.preventDefault(),t==="z"&&!e.shiftKey?this.e.F.undo():this.e.F.redo(),!0)}Au(e){let t=this.e.a;if(e.key==="Escape")return this.e.ze(),this.e.r.enableRangeSelection&&t.we()&&(e.preventDefault(),t.dr()),!0;if(e.key!=="Delete"&&e.key!=="Backspace")return!1;let r=t.lr();return r&&(e.preventDefault(),this.e.Go(r)),!0}ku(e){if(this.e.a.v)return!1;let t=this.e.n.d();return this.e.i.P()>0&&t.length>0&&(e.preventDefault(),this.e.a.Ae(0,t[0].id)),!0}Pu(e){let t=this.e.a,r=t.v;if(!r)return;let i=this.e.n.d(),o=i.findIndex(c=>c.id===r.colId),s=this.e.i.P();if(o<0||s===0)return;let a={row:r.rowIndex,colIdx:o},l=this.Gu(e,a,i,s);if(!l)return;e.preventDefault();let d=l.row!==a.row||l.colIdx!==a.colIdx;if(e.shiftKey&&this.e.r.enableRangeSelection&&d){t.Lu(l.row,l.colIdx);return}d&&t.Ae(l.row,i[l.colIdx].id)}Gu(e,t,r,i){return an.has(e.key)?this.Nu(e,t,r.length,i):e.key==="Enter"||e.key==="F2"?this.Ou(e,t,r,i):e.key===" "?(this.Fu(t.row),t):e.key==="Tab"?this.Hu(e,t,r):null}Nu(e,t,r,i){let{row:o,colIdx:s}=t;switch(e.key){case"ArrowUp":o=this.Ji(o,this.Pt(o-1,-1),i);break;case"ArrowDown":o=this.Ji(o,this.Pt(o+1,1),i);break;case"ArrowLeft":s=Math.max(0,s-1);break;case"ArrowRight":s=Math.min(r-1,s+1);break;case"Home":s=0,e.ctrlKey&&(o=0);break;case"End":s=r-1,e.ctrlKey&&(o=Math.max(0,this.Pt(i-1,-1)));break;case"PageUp":case"PageDown":o=this.Vu(e.key,o,i);break}return{row:o,colIdx:s}}Ji(e,t,r){return t>=0&&t<r?t:e}Vu(e,t,r){let i=this.e.o.T.center,o=Math.max(1,Math.floor(i.clientHeight/this.e.r.rowHeight)),s=e==="PageUp"?-1:1,a=Math.max(0,Math.min(r-1,t+o*s));return this.Ji(t,this.Pt(a,s),r)}Ou(e,t,r,i){let o=this.e.i.f(t.row),s=r[t.colIdx];if(o&&!o.isDetail&&s&&this.e.l.J(o,s))return this.e.l.start(t.row,s,e.key==="F2"?e.key:null),t;let a=this.Pt(t.row+1,1);return{...t,row:this.Ji(t.row,a,i)}}Fu(e){let t=this.e.i.f(e);if(!(!t||t.isDetail)){if(t.isGroup){this.e.i.xo(t.id);return}this.e.r.rowSelection!=="none"&&this.e.h.ir(t,!t.selected,this.e.r.rowSelection==="single")}}Hu(e,t,r){let i=this.il(t.row,r[t.colIdx].id,e.shiftKey?-1:1);return i?(this.e.a.Ae(i.rowIndex,i.column.id),this.e.l.start(i.rowIndex,i.column),t):null}};var I=null;function dn(n){I?.owner&&(n===I.owner||n.contains(I.owner))&&I.close()}function Us(n){let e=n.target;I?.contains(e)||I?.close()}function ln(){I?.reposition()}function js(n){n.key!=="Escape"||!I||(n.preventDefault(),n.stopImmediatePropagation(),I.close(!0))}function cn(n){X(n,Us,js);let e=n?"addEventListener":"removeEventListener";window[e]("resize",ln),window[e]("scroll",ln,!0)}function qs(n){I?.close!==n.close&&I?.close(),!I&&(I=n,cn(!0))}function Ys(n){I?.close===n&&(I=null,cn(!1))}function le(n,e){return e?`${n} ${e}`:n}function He(n,e,t){let r=n[e]&&!n[e].disabled,i=r?e+t:t>0?0:n.length-1;for(let o=i;o>=0&&o<n.length;o+=t)if(!n[o].disabled)return o;return r?e:-1}function Rt(n,e){return n.findIndex(t=>t.value===e&&!t.disabled)}function ne(n){let e=f("div",le("mach-select-control",n.classNames?.root)),t=f("select",le("mach-select-native",n.classNames?.native));t.hidden=!0,t.tabIndex=-1,t.setAttribute("aria-hidden","true");let r=f("button",le("mach-select-trigger",n.classNames?.trigger));r.type="button",r.setAttribute("role","combobox"),r.setAttribute("aria-haspopup","listbox"),r.setAttribute("aria-expanded","false"),r.setAttribute("aria-label",n.ariaLabel);let i=f("span",le("mach-select-value",n.classNames?.value)),o=f("span",le("mach-select-caret",n.classNames?.caret));o.setAttribute("aria-hidden","true"),r.append(i,o);let s=f("div",le("mach-select-listbox",n.classNames?.listbox));s.id=ui("mach-select-listbox"),s.setAttribute("role","listbox"),s.setAttribute("aria-hidden","true"),r.setAttribute("aria-controls",s.id),e.append(t,r);let a=[...n.options],l=[],d=-1,c=!1,u=()=>n.themeSource??e.closest(".mach-root")??e,h=y=>e.contains(y)||s.contains(y),p=()=>s.classList.contains("mach-select-listbox--open"),m=()=>{let y=a.find(T=>T.value===t.value);i.textContent=y?.label??t.value,l.forEach((T,ue)=>{let S=a[ue]?.value===t.value;T.setAttribute("aria-selected",S?"true":"false"),T.classList.toggle("mach-select-option--selected",S),T.classList.toggle("mach-select-option--active",ue===d)}),r.setAttribute("aria-activedescendant",d>=0?l[d]?.id??"":"")},g=()=>{let y=r.getBoundingClientRect(),T=s.getBoundingClientRect(),ue=Math.max(y.width,T.width),S=C(y.left,8,Math.max(8,window.innerWidth-ue-8)),Ee=window.innerHeight-y.bottom-8,oe=Ee<Math.min(T.height,240)&&y.top>Ee,G=oe?Math.max(8,y.top-T.height-5):Math.min(window.innerHeight-T.height-8,y.bottom+5);s.style.minWidth=`${y.width}px`,s.style.left=`${S}px`,s.style.top=`${Math.max(8,G)}px`,s.classList.toggle("mach-select-listbox--above",oe)},v=(y=!1)=>p()?(s.classList.remove("mach-select-listbox--open","mach-select-listbox--above"),s.setAttribute("aria-hidden","true"),r.setAttribute("aria-expanded","false"),r.removeAttribute("aria-activedescendant"),s.remove(),Ys(v),y&&!c&&r.focus({preventScroll:!0}),!0):!1,w=(y,T=!0)=>{!a[y]||a[y].disabled||(d=y,m(),T&&l[y]?.scrollIntoView?.({block:"nearest"}))},A=()=>{if(c||r.disabled||p())return;let y=u();qs({owner:y,close:v,contains:h,reposition:g}),d=Rt(a,t.value),d<0&&(d=He(a,-1,1)),M(s,y),document.body.appendChild(s),s.classList.add("mach-select-listbox--open"),s.setAttribute("aria-hidden","false"),r.setAttribute("aria-expanded","true"),g(),m(),l[d]?.scrollIntoView?.({block:"nearest"})},z=y=>{let T=a[y];!T||T.disabled||(t.value=T.value,d=y,m(),v(!0),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})))},W=(y,T)=>{a=[...y],t.replaceChildren(),s.replaceChildren(),l=a.map((S,Ee)=>{let oe=document.createElement("option");oe.value=S.value,oe.textContent=S.label,oe.disabled=S.disabled===!0,t.appendChild(oe);let G=f("button",le("mach-select-option",n.classNames?.option));return G.id=`${s.id}-option-${Ee}`,G.type="button",G.tabIndex=-1,G.dataset.value=S.value,G.disabled=S.disabled===!0,G.setAttribute("role","option"),G.textContent=S.label,G.addEventListener("mousedown",yo=>yo.preventDefault()),G.addEventListener("click",()=>z(Ee)),s.appendChild(G),G});let ue=a.find(S=>!S.disabled)?.value??"";t.value=T!=null&&a.some(S=>S.value===T)?T:ue,d=Rt(a,t.value),m()},ai=y=>{if(y.key==="Tab"){v();return}if(y.key==="Escape"){if(!v(!0))return;y.preventDefault(),y.stopPropagation();return}if(y.key==="Enter"||y.key===" "){y.preventDefault(),y.stopPropagation(),p()?z(d):A();return}let T=d;if(y.key==="ArrowDown")T=He(a,d,1);else if(y.key==="ArrowUp")T=He(a,d,-1);else if(y.key==="Home")T=He(a,-1,1);else if(y.key==="End")T=He(a,-1,-1);else return;y.preventDefault(),y.stopPropagation(),p()||A(),w(T)},li=()=>{d=Rt(a,t.value),m(),n.onChange?.(t.value)};return r.addEventListener("click",()=>{v()||A()}),r.addEventListener("keydown",ai),t.addEventListener("change",li),W(a,n.value),{el:e,native:t,trigger:r,listbox:s,contains:h,isOpen:p,open:A,close:v,focus:()=>r.focus({preventScroll:!0}),getValue:()=>t.value,setValue:y=>{t.value=y,d=Rt(a,y),m()},setOptions:W,destroy:()=>{c||(c=!0,v(),r.removeEventListener("keydown",ai),t.removeEventListener("change",li),e.remove())}}}function un(n,e){let t=document.createElement("input");return t.type=n,t.className="mach-editor-input",e!=null&&e!==""&&(t.value=n==="date"?String(e).slice(0,10):String(e)),t}function Xs(n){return n?.options?.length?n.options:(n?.values??[]).map(e=>({label:String(e),value:e}))}function Js(n,e){return e?.options?.length||e?.values?.length?"select":typeof n=="number"?"number":n instanceof Date||typeof n=="string"&&/^\d{4}-\d{2}-\d{2}/.test(n)?"date":"text"}function Fr(n,e,t){let r=n.colDef,i=typeof r.cellEditor=="string"?r.cellEditor:Js(e,r.cellEditorParams);if(i==="date"){let a=un("date",e),d=(e==null?"":String(e)).match(/T(\d{2}:\d{2})/);return{el:a,getValue:()=>a.value===""?null:d?`${a.value}T${d[1]}`:a.value,focus:()=>a.focus({preventScroll:!0})}}if(i==="select"){let a=Xs(r.cellEditorParams),l=ne({ariaLabel:r.headerName??r.field??n.id,options:a.map(d=>({value:String(d.value),label:d.label,disabled:d.disabled})),value:String(e??""),classNames:{root:"mach-editor-select-control",native:"mach-editor-select"}});return{el:l.el,getValue:()=>{let d=l.getValue();return a.find(u=>String(u.value)===d)?.value??d},focus:()=>l.focus(),destroy:()=>l.destroy()}}let o=i==="number",s=un(o?"number":"text",e);return!o&&t&&t.length===1&&(s.value=t),{el:s,getValue:()=>o?s.value===""?null:Number(s.value):s.value,focus:()=>{s.focus({preventScroll:!0}),s.select()}}}function be(n){return n!=null&&typeof n.then=="function"}var St=class{constructor(e){this.e=e;this.No=0}Bu(){this.No++}Zi(){let e=++this.No;return()=>e===this.No&&!this.e.s()}Qi(e){let t=e[0].node,r=this.e.n.te(),i=r.map(a=>this.e.c(t,a)),o=this.Xr(e),s=e.every(a=>Object.is(this.e.c(t,a.column),a.oldValue));return()=>s&&o()&&r.every((a,l)=>Object.is(this.e.c(t,a),i[l]))}Xr(e){let t=e[0].node,r=t.data,i=this.e.n,o=i.te(),s=e.every(a=>a.node===t&&i.S(a.column.id)===a.column);return()=>s&&!this.e.s()&&this.e.i.X(t.id)===t&&t.data===r&&i.te()===o}Oo(e,t){let r=e.map(o=>this._u(o,t)),i=o=>{let s=o.filter(a=>a!=null);return s.length||!t()?s:this.zu(e,t)};return r.some(be)?Promise.all(r.map(o=>Promise.resolve(o))).then(i):i(r)}_u(e,t){let{node:r,column:i,oldValue:o,newValue:s}=e,a=d=>(t()&&this.e.reportError(d,"validate",{colId:i.id,rowId:r.id}),{colId:i.id,message:"Validation failed"}),l=d=>typeof d=="string"?{colId:i.id,message:d}:null;try{let d=i.colDef.validate?.(s,{oldValue:o,newValue:s,node:r,data:r.data,column:i,colDef:i.colDef,api:this.e.api});return be(d)?d.then(l,a):l(d)}catch(d){return a(d)}}zu(e,t){let r=this.e.r.rowEditValidator;if(!r)return[];let i=e[0].node,o=Object.create(null);for(let l of this.e.n.te())o[l.id]=this.e.c(i,l);for(let l of e)o[l.column.id]=l.newValue;let s=l=>typeof l=="string"?[{colId:e[0].column.id,message:l}]:l&&typeof l=="object"?Object.entries(l).filter(([,d])=>typeof d=="string"&&d).map(([d,c])=>({colId:d,message:c})):[],a=l=>(t()&&this.e.reportError(l,"validate",{rowId:i.id}),[{colId:e[0].column.id,message:"Row validation failed"}]);try{let l=r({data:i.data,node:i,values:o,api:this.e.api,changes:e.map(({column:d,oldValue:c,newValue:u})=>({colId:d.id,oldValue:c,newValue:u}))});return be(l)?l.then(s,a):s(l)}catch(l){return a(l)}}Fo(e,t){let r=[],i=this.Xr(e);for(let o of e){if(!t()||!i()||!Object.is(this.e.c(o.node,o.column),o.oldValue)||!this.e.l.J(o.node,o.column)||!this.e.en(o.node,o.column,o.newValue,o.oldValue)){for(let s of r.reverse()){if(!t()||!i())break;this.e.en(s.node,s.column,s.oldValue,s.newValue)||this.e.reportError(new Error("A valueSetter rejected input rollback"),"inputRollback",{rowId:s.node.id})}return{colId:o.column.id,message:"Value was rejected by the column setter"}}r.push(o)}return t()&&i()?null:{colId:e[0].column.id,message:"Input target changed during commit"}}Wu(e){let t=this.Zi();if(this.e.s()||this.e.l.isEditing())return;let r=new Map;for(let a of e){if(a.newValue===void 0||Object.is(a.oldValue,a.newValue)||!this.e.l.J(a.node,a.column))continue;let l=r.get(a.node)??[];l.push(a),r.set(a.node,l)}let i=[...r.values()].map(a=>{let l=this.Qi(a),d=()=>t()&&l();return{changes:a,current:d,validation:this.Oo(a,d)}}),o=a=>{this.sl(i,a,t)},s=i.map(a=>a.validation);s.some(be)?Promise.all(s.map(a=>Promise.resolve(a))).then(o):o(s)}sl(e,t,r){let i=e.map(()=>({applied:!1,errors:[]}));if(!r())return i;let o=new Set;this.e.F.al();try{e.forEach(({changes:s,current:a},l)=>{let d=i[l];if(!a()||!s.length)return;d.errors=[...t[l]];let c=d.errors.length?null:this.Fo(s,r);if(!r())return;if(c&&d.errors.push(c),d.errors.length){this.e.reportError(new Error(d.errors.map(h=>h.message).join("; ")),"validate",{rowId:s[0].node.id,errors:d.errors});return}let u=this.Xr(s);d.applied=!0;for(let h of s){if(!r()||!u()){d.applied=!1;break}this.e.Ho(h.node,h.column,h.oldValue,h.newValue),h.node.rowIndex>=0&&o.add(h.node.rowIndex)}})}finally{this.e.F.ll()}return o.size&&r()&&(this.e.a.M([...o]),this.e.Ce.refresh(),this.e.st.refresh()),i}};function de(n,e,t,r,i,o){let s=t.colDef.valueParser;if(!s)return r;let a=s({api:n.api,colDef:t.colDef,column:t,data:e.data,node:e,value:r,oldValue:o,source:i});if(a!=null&&typeof a.then=="function")throw new TypeError("valueParser must return a synchronous value");return a}function Ve(n,e,t,r){let i=n.c(e,t),o=t.colDef.valueSerializer;if(o)try{let s=o({api:n.api,colDef:t.colDef,column:t,data:e.data,node:e,value:i,target:r});if(s!=null&&typeof s.then=="function")throw new TypeError("valueSerializer must return a synchronous value");return s}catch(s){throw n.reportError(s,"valueSerializer",{colId:t.id,rowId:e.id}),s}return r==="xlsx"||r==="csv"&&typeof i=="number"?i:K(n,e,t,i)}var Zs='<path d="M3 8.5 6.4 12 13.5 4"/>',Qs='<path d="m4 4 8 8m0-8-8 8"/>';function hn(n,e){let t=document.createElement("button");return t.type="button",t.className=`mach-edit-control mach-edit-control--${n}`,t.setAttribute("aria-label",e),t.title=e,t.innerHTML=`<svg viewBox="0 0 16 16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">${n==="confirm"?Zs:Qs}</svg>`,t.addEventListener("mousedown",r=>{r.preventDefault(),r.stopPropagation()}),t}var Mt=class{constructor(e){this.e=e;this.b=null;this.D=null;this.$e=null;this.at=0;this.$u=e=>{if(this.b&&!(e.isComposing||e.keyCode===229)){if(e.key==="Enter")e.preventDefault(),e.stopPropagation(),this.le(!1);else if(e.key==="Escape")e.preventDefault(),e.stopPropagation(),this.le(!0);else if(e.key==="Tab"){e.preventDefault(),e.stopPropagation();let t=this.b,r=this.e.jo.il(t.rowIndex,t.column.id,e.shiftKey?-1:1);this.le(!1).then(i=>{i&&r&&(this.e.a.ji(r.rowIndex,"nearest"),this.e.a.Ae(r.rowIndex,r.column.id),this.start(r.rowIndex,r.column))})}}}}isEditing(e,t){return this.b?e==null&&t==null?!0:this.b.rowIndex===e&&this.b.column.id===t:this.D?e==null&&t==null?!0:this.Jr(this.D)!==e?!1:t==null||this.D.drafts.has(t):!1}tn(){return this.b!=null}Ec(){return this.b?.node.rowIndex??(this.D?this.Jr(this.D):null)}dl(e){return this.D?e==null||this.Jr(this.D)===e:!1}J(e,t){if(e.isDetail||e.isGroup||e.data==null)return!1;let r=t.colDef.editable;if(!r)return!1;if(typeof r=="function")try{return r({api:this.e.api,colDef:t.colDef,column:t,node:e,data:e.data,value:this.e.c(e,t),rowIndex:e.rowIndex})}catch(i){return this.e.reportError(i,"editable",{colId:t.id,rowId:e.id}),!1}return!0}start(e,t,r){if(this.e.r.editType==="fullRow")return this.startRow(e,t.id);if(this.D)return!1;if(this.b)return this.b.rowIndex===e&&this.b.column.id===t.id||this.le(!1).then(p=>{p&&!this.b&&!this.D&&this.start(e,t,r)}),!0;let i=this.e.i.f(e);if(!i||i.data==null||!this.J(i,t))return!1;let o=this.e.a.rn(e,t.id);if(!o)return!1;this.e.ze();let s=this.e.c(i,t),a=this.cl(i,t,e,s,r);if(!a)return!1;let l=f("div","mach-cell-editor-controls"),d=hn("confirm","Confirm edit"),c=hn("cancel","Cancel edit");l.append(d,c);let u=this.ul(a,o,l),h=this.$u;return a.el.addEventListener("keydown",h),d.addEventListener("click",p=>{p.stopPropagation(),this.le(!1)}),c.addEventListener("click",p=>{p.stopPropagation(),this.le(!0)}),this.b={node:i,column:t,editor:a,rowIndex:e,oldValue:s,cell:o,shell:u,keydown:h,confirmButton:d,cancelButton:c},this.Vo(a,t,i),this.e.emit("cellEditingStarted",{rowIndex:e,colId:t.id,rowNode:i}),!0}startRow(e,t){if(this.b||this.D)return!1;let r=this.e.i.f(e);if(!r||r.data==null||r.isDetail||r.isGroup)return!1;this.e.ze();let i=new Map;for(let l of this.e.n.d()){if(!this.J(r,l))continue;let d=this.e.c(r,l);i.set(l.id,{column:l,oldValue:d,value:d,mounted:null})}if(i.size===0)return!1;let o={node:r,rowIndex:e,drafts:i,validating:!1};if(this.D=o,this.e.a.M([e]),i.size===0)return this.D=null,this.e.a.M([e]),!1;let s=i.values().next().value,a=(t?i.get(t):void 0)??s;return a?.mounted&&this.Vo(a.mounted.editor,a.column,r),this.e.emit("rowEditingStarted",{rowIndex:e,rowNode:r,data:r.data}),!0}hl(e,t,r,i){if(this.b)return this.b.node===t&&this.b.column.id===r.id;let o=this.D;if(!o||o.node!==t)return!1;let s=o.drafts.get(r.id);return s?s.mounted?.cell!==i&&(this.pl(s),!this.Ku(e,o,s,i))?(o.drafts.delete(r.id),!1):!0:!1}Bo(e,t,r){let i=this.D;if(i&&this.Jr(i)===e){let o=i.drafts.get(t);o?.mounted?.cell===r&&this.pl(o);return}if(this.b?.cell===r){let o=this.b;this.le(!1),this.b===o&&this.le(!0)}}stop(e=!1){this.le(e)}le(e=!1){if(this.D)return this._o(e);let t=this.b;if(!t)return Promise.resolve(!1);if(e)return this.at++,this.$e=null,Promise.resolve(this.Zr(t,!0,t.oldValue));if(this.$e)return this.$e;let r,i="cellEditor.getValue";try{if(r=t.editor.getValue(),Object.is(r,t.oldValue)||(i="valueParser",r=de(this.e,t.node,t.column,r,"editor",t.oldValue)),i="cellEditor.isCancelAfterEnd",t.editor.isCancelAfterEnd?.(r))return Promise.resolve(this.Zr(t,!0,t.oldValue))}catch(c){return this.e.reportError(c,i,{colId:t.column.id,rowId:t.node.id}),i!=="valueParser"?Promise.resolve(this.Zr(t,!0,t.oldValue)):(this.Qr(t.editor,c instanceof Error?c.message:String(c)),Promise.resolve(!1))}let o=[{node:t.node,column:t.column,oldValue:t.oldValue,newValue:r}],s=this.e.V.Qi(o),a=++this.at,l=()=>a===this.at&&this.b===t&&s(),d=c=>l()?c.length?(this.zo(t,!1),this.Qr(t.editor,c[0].message),!1):this.Zr(t,!1,r):(a===this.at&&this.b===t&&this.Zr(t,!0,t.oldValue),!1);return this.fl(o,l,d,()=>this.zo(t,!0))}_o(e=!1){let t=this.D;if(!t)return Promise.resolve(!1);if(e)return this.at++,this.$e=null,Promise.resolve(this.nn(t,!0));if(this.$e)return this.$e;for(let c of t.drafts.values())this.Wo(c);let r=[];for(let c of t.drafts.values())if(!Object.is(c.oldValue,c.value))try{let u=de(this.e,t.node,c.column,c.value,"editor",c.oldValue);u!==void 0&&!Object.is(c.oldValue,u)&&r.push({node:t.node,column:c.column,oldValue:c.oldValue,newValue:u})}catch(u){return this.e.reportError(u,"valueParser",{colId:c.column.id,rowId:t.node.id}),this.$o(t,[{draft:c,message:u instanceof Error?u.message:String(u)}]),Promise.resolve(!1)}if(r.length===0)return Promise.resolve(this.nn(t,!1,r));let i=r.map(c=>t.drafts.get(c.column.id)),o=i.map(c=>c.value),s=this.e.V.Qi(r),a=++this.at,l=()=>a===this.at&&this.D===t&&s();for(let c of i)c.error=void 0;let d=c=>l()?c.length?(this.$o(t,c.map(({colId:u,message:h})=>({draft:t.drafts.get(u)??i[0],message:h}))),!1):i.some((u,h)=>!Object.is(u.value,o[h]))?(t.validating=!1,this.Ko(t,!1),!1):this.nn(t,!1,r):(a===this.at&&this.D===t&&this.nn(t,!0),!1);return this.fl(r,l,d,()=>{t.validating=!0,this.Ko(t,!0)})}fl(e,t,r,i){let o=this.e.V.Oo(e,t);if(!be(o))return Promise.resolve(r(o));i();let s=o.then(r).finally(()=>{this.$e===s&&(this.$e=null)});return this.$e=s,s}Zr(e,t,r){if(this.b!==e)return!1;let i={node:e.node,column:e.column,oldValue:e.oldValue,newValue:r},o=!t&&r!==void 0&&!Object.is(e.oldValue,r);if(o){let s=this.e.V.Fo([i],()=>!this.e.s());if(s)return this.zo(e,!1),this.Qr(e.editor,s.message),!1}return this.b=null,o&&this.e.Ho(e.node,e.column,e.oldValue,r),this.Uo(e),this.e.s()||(this.e.emit("cellEditingStopped",{rowIndex:e.rowIndex,colId:e.column.id,rowNode:e.node,oldValue:e.oldValue,newValue:o?r:e.oldValue}),this.ml(e.node.rowIndex)),!0}nn(e,t,r=[]){if(this.D!==e)return!1;let i=t?[]:this.Uu(e,r);if(i==null)return!1;for(let s of e.drafts.values())s.mounted&&this.Uo(s.mounted),s.mounted=null;if(this.D=null,this.e.s())return!0;let o=this.Jr(e);return this.e.emit("rowEditingStopped",{rowIndex:o,rowNode:e.node,data:e.node.data,cancelled:t,changes:i}),this.ml(o),!0}ml(e){e>=0&&this.e.a.M([e]),this.e.Ce.refresh(),this.e.st.refresh()}Uu(e,t){if(t.length===0)return[];let r=this.e.V.Fo(t,()=>!this.e.s());if(r)return this.$o(e,[{draft:e.drafts.get(r.colId)??e.drafts.get(t[0].column.id),message:r.message}]),null;let i=this.e.V.Xr(t);this.e.F.al();try{for(let o of t){if(!i())break;this.e.Ho(e.node,o.column,o.oldValue,o.newValue)}}finally{this.e.F.ll()}return t.map(({column:o,oldValue:s,newValue:a})=>({colId:o.id,oldValue:s,newValue:a}))}Ku(e,t,r,i){let o=this.cl(t.node,r.column,e,r.value,null);if(!o)return!1;this.ul(o,i);let s=l=>this.ju(l,t,r),a=()=>{try{r.value=o.getValue(),r.error=void 0}catch{}};return o.el.addEventListener("keydown",s),o.el.addEventListener("input",a),r.mounted={editor:o,cell:i,keydown:s,input:a},r.error&&this.Qr(o,r.error),t.validating&&this.ei(o.el,!0),!0}ul(e,t,r){k(this.e,t);let i=f("div",r?"mach-cell-editor-shell":"mach-row-editor-shell");return i.appendChild(e.el),r&&i.appendChild(r),t.replaceChildren(i),t.classList.add("mach-cell--editing"),r||t.classList.add("mach-cell--row-editing"),t.removeAttribute("title"),i}pl(e){e.mounted&&(this.Wo(e),this.Uo(e.mounted),e.mounted=null)}Wo(e){if(e.mounted)try{let t=e.mounted.editor.getValue();t!==void 0&&(e.value=t)}catch(t){this.e.reportError(t,"cellEditor.getValue",{colId:e.column.id,rowId:this.D?.node.id})}}cl(e,t,r,i,o){let s=t.colDef,a;try{let l={api:this.e.api,colDef:s,column:t,node:e,data:e.data,value:i,rowIndex:r,keyPress:o};typeof s.cellEditor=="function"?a=s.cellEditor(l):typeof s.cellEditor=="string"&&!["text","number","date","select"].includes(s.cellEditor)?a=this.e.qu(s.cellEditor)?.(l)??Fr(t,i,o):a=Fr(t,i,o)}catch(l){return this.e.reportError(l,"cellEditor",{colId:t.id,rowId:e.id}),null}if(!a||!(a.el instanceof HTMLElement))return this.e.reportError(new Error("cellEditor must return an editor with an HTMLElement el"),"cellEditor",{colId:t.id,rowId:e.id}),null;try{if(a.isCancelBeforeStart?.())return a.destroy?.(),null}catch(l){this.e.reportError(l,"cellEditor.isCancelBeforeStart",{colId:t.id,rowId:e.id});try{a.destroy?.()}catch{}return null}return a}$o(e,t){e.validating=!1,this.Ko(e,!1);for(let{draft:r,message:i}of t)r.error=i,r.mounted&&this.Qr(r.mounted.editor,i);t[0].draft.mounted?.editor.focus?.()}Qr(e,t){let r=e.el;r.classList.add("mach-editor-invalid"),r.setAttribute("title",t),r.setAttribute("aria-invalid","true"),this.ei(r,!1),(r.querySelector(".mach-select-trigger, input:not([type='hidden']), select:not([hidden]), textarea")??r).focus?.();let o=()=>{r.classList.remove("mach-editor-invalid"),r.removeAttribute("title"),r.removeAttribute("aria-invalid")};r.addEventListener("input",o,{once:!0})}zo(e,t){this.ei(e.editor.el,t),e.confirmButton.disabled=t,e.cancelButton.disabled=!1,e.shell.classList.toggle("mach-editor-shell--busy",t)}Ko(e,t){for(let r of e.drafts.values()){let i=r.mounted?.editor.el;i&&this.ei(i,t)}}ei(e,t){e.classList.toggle("mach-editor-validating",t),t?e.setAttribute("aria-busy","true"):e.removeAttribute("aria-busy"),e.inert=t}Vo(e,t,r){try{e.focus?.()}catch(i){this.e.reportError(i,"cellEditor.focus",{colId:t.id,rowId:r.id})}}Uo(e){e.editor.el.removeEventListener("keydown",e.keydown),e.input&&e.editor.el.removeEventListener("input",e.input),this.ei(e.editor.el,!1);try{e.editor.destroy?.()}catch(t){this.e.reportError(t,"cellEditor.destroy",{colId:e.cell.dataset.colId})}e.cell.classList.remove("mach-cell--editing","mach-cell--row-editing","mach-cell--error")}Jr(e){return e.node.rowIndex>=0?e.node.rowIndex:e.rowIndex}ju(e,t,r){if(this.D!==t)return;if(e.key==="Escape"){e.preventDefault(),e.stopPropagation(),this._o(!0);return}if(e.key==="Enter"&&!e.shiftKey){e.preventDefault(),e.stopPropagation(),this._o(!1);return}if(e.key!=="Tab")return;e.preventDefault(),e.stopPropagation(),this.Wo(r);let i=[...t.drafts.values()],o=i.indexOf(r),s=e.shiftKey?-1:1;for(let a=1;a<=i.length;a++){let l=i[(o+s*a+i.length)%i.length];if(l.mounted){this.Vo(l.mounted.editor,l.column,t.node);break}}}destroy(){(this.b||this.D)&&this.le(!0)}};function Hr(n){return n==="blank"||n==="notBlank"}function It(n){return n===null?"null:":`${typeof n}:${String(n)}`}var At=class{constructor(e){this.e=e;this.g=null;this.lt=null;this.cr=null;this.Gt=e=>{if(!this.g)return;let t=e.target;if(!this.cr?.contains(t)){if(!this.g.contains(t)){this.close();return}(!(t instanceof Element)||!t.closest(".mach-filter-select-control"))&&this.cr?.close()}};this.Lt=e=>{if(e.key==="Escape"){if(this.cr?.close(!0)){e.preventDefault(),e.stopPropagation();return}this.close()}}}toggle(e,t){if(this.lt===e.id){this.close();return}this.close(),this.open(e,t)}open(e,t){let r=this.e.i._e()[e.id]??null,i=r?.type??e.filterType,o=f("div","mach-filter-panel");o.setAttribute("role","dialog"),o.setAttribute("aria-label",`${e.id} filter`);let s=c=>{this.e.Yu(e,c),this.close()},a=i==="set"?this.Xu(o,e,r):this.Ju(o,i,r,s),l=f("div","mach-filter-footer");l.append(Y("mach-filter-btn-reset",this.e.y("reset"),()=>s(null)),Y("mach-filter-btn-apply",this.e.y("apply"),()=>s(a()))),o.appendChild(l),M(o,this.e.o.root),document.body.appendChild(o),this.g=o,this.lt=e.id,J(o,t),this.gl(!0),o.querySelector(".mach-filter-select-trigger, input")?.focus()}close(){this.g&&(this.cr?.destroy(),this.cr=null,this.g.remove(),this.g=null,this.lt=null,this.gl(!1))}gl(e){L(document,e,{mousedown:this.Gt,keydown:this.Lt},!0)}destroy(){this.close()}Ju(e,t,r,i){let o=r&&r.type!=="set"&&r.conditions.length>0?r.conditions[0]:null,s=o?.match??(t==="text"?"contains":"equals"),{el:a,native:l}=this.Zu(t,s),d=this.yl(t),c=this.yl(t,!0);this.Qu(t,s,o,d,c),this.vl(s,d,c),l.addEventListener("change",()=>{this.vl(l.value,d,c)});let u=f("div","mach-filter-body");u.append(a,d,c),e.appendChild(u);let h=()=>this.eh(t,l.value,d.value,c.value),p=m=>{m.key==="Enter"&&i(h())};return d.addEventListener("keydown",p),c.addEventListener("keydown",p),h}Zu(e,t){let r=ne({ariaLabel:"Filter condition",options:fe[e].map(i=>({value:i,label:this.e.y(rt(i))})),value:t,classNames:{root:"mach-filter-select-control",native:"mach-filter-select",trigger:"mach-filter-select-trigger",value:"mach-filter-select-value",caret:"mach-filter-select-caret",listbox:"mach-filter-listbox",option:"mach-filter-listbox-option"},themeSource:this.e.o.root});return this.cr=r,r}yl(e,t=!1){let i=f("input",`mach-filter-input${t?" mach-filter-input--second":""}`);return i.type=e,i}Qu(e,t,r,i,o){r?.value!=null&&!Hr(t)&&(i.value=e==="date"?String(r.value).slice(0,10):String(r.value)),r&&"value2"in r&&r.value2!=null&&(o.value=e==="date"?String(r.value2).slice(0,10):String(r.value2))}vl(e,t,r){t.style.display=Hr(e)?"none":"",r.style.display=e==="inRange"?"":"none"}Xu(e,t,r){let o=t.colDef.filterParams,s;if(o?.values)s=o.values;else{let p=new Set;s=[];let m=this.e.i.Oe(),g=Math.min(m.length,o?.maxValues??500);for(let v=0;v<g;v++){let w=this.e.c(m[v],t),A=It(w??null);p.has(A)||(p.add(A),s.push(w))}}let a=new Set((r?.type==="set"?r.values:s).map(It)),l=f("input","mach-filter-input mach-filter-input--search");l.type="text",l.placeholder=this.e.y("search");let d=f("div","mach-filter-set-list"),c=new Map(s.map(p=>[It(p),p??null])),u=p=>{d.textContent="";let m=p.trim().toLowerCase();for(let g of s){let v=g==null?this.e.y("emptySetLabel"):String(g);if(m&&!v.toLowerCase().includes(m))continue;let w=It(g),A=f("label","mach-filter-set-item"),z=document.createElement("input");z.type="checkbox",z.checked=a.has(w),z.addEventListener("change",()=>{z.checked?a.add(w):a.delete(w)});let W=f("span");W.textContent=v,A.append(z,W),d.appendChild(A)}};l.addEventListener("input",()=>u(l.value)),u("");let h=f("div","mach-filter-body mach-filter-body--set");return h.append(l,d),e.appendChild(h),()=>{let p=[];for(let[m,g]of c)a.has(m)&&p.push(g);return p.length&&p.length<c.size?{type:"set",values:p}:null}}eh(e,t,r,i){if(Hr(t))return{type:e,conditions:[{match:t}]};if(r===""&&t!=="inRange")return null;let o=e==="number",s=o?Number(r):r;if(Number.isNaN(s))return null;if(e==="text"||t!=="inRange")return{type:e,conditions:[{match:t,value:s}]};let a=i?o?Number(i):i:s;return Number.isNaN(a)?null:{type:e,conditions:[{match:t,value:s,value2:a}]}}};var kt=class{constructor(e){this.e=e;this.g=null;this.lt=null;this.sn=null;this.an="";this.ti=new Set;this.Gt=e=>{let t=e.target;this.g&&!this.g.contains(t)&&!this.rh(t)&&this.close()};this.Lt=e=>{if(e.key==="Escape"){for(let t of this.ti)if(t.close(!0)){e.preventDefault(),e.stopImmediatePropagation();return}this.close()}}}toggle(e,t){let r=this.lt===e.id;this.close(),r||this.open(e,t)}th(e){this.close();let t=e??(()=>{let i=this.e.o.root.getBoundingClientRect(),o=document.createElement("div");return o.style.position="fixed",o.style.left=`${i.right-16}px`,o.style.top=`${i.top+this.e.r.headerHeight}px`,o.style.width="1px",o.style.height="1px",document.body.appendChild(o),this.sn=o,o})();this.open(null,t)}close(){this.bl(),this.sn&&(this.sn.remove(),this.sn=null),this.g?.remove(),this.g=null,this.lt=null,X(!1,this.Gt,this.Lt)}destroy(){this.close()}open(e,t){let r=this.e.api,i=f("div","mach-filter-panel mach-column-panel");i.setAttribute("role",e?"menu":"dialog"),e||(i.setAttribute("aria-modal","false"),i.setAttribute("aria-label",this.e.y("columnSettings")));let o=f("div","mach-column-panel-title");o.textContent=e?e.colDef.headerName??e.colDef.field??e.id:this.e.y("columnSettings"),i.appendChild(o);let s=(u,h,p="mach-column-panel-btn")=>Y(p,this.e.y(u),()=>{h(),this.close()});if(e){let u=e.id,h=(...p)=>{let m=f("div","mach-column-panel-actions");m.append(...p),i.appendChild(m)};e.sortable&&h(s("sortAsc",()=>r.sorting.setModel([{colId:u,direction:"asc"}])),s("sortDesc",()=>r.sorting.setModel([{colId:u,direction:"desc"}])),s("clearSort",()=>r.sorting.setModel([]))),h(s("pinLeft",()=>r.columns.setPinned(u,"left")),s("pinRight",()=>r.columns.setPinned(u,"right")),s("clearPin",()=>r.columns.setPinned(u,null))),h(s("autoSize",()=>r.columns.autoSize(u)),s("hideColumn",()=>r.columns.setVisible(u,!1)))}let a=f("div","mach-column-panel-divider");i.appendChild(a);let l=f("div","mach-column-panel-subtitle");if(l.textContent=this.e.y("columnVisibility"),i.appendChild(l),!e){let u=document.createElement("input");u.type="search",u.className="mach-column-workbench-search",u.placeholder=this.e.y("search"),u.setAttribute("aria-label",this.e.y("search")),u.value=this.an,u.addEventListener("input",()=>{this.an=u.value.trim().toLocaleLowerCase(),this.qo(d,!0)}),i.appendChild(u)}let d=f("div","mach-column-panel-list");this.qo(d,!e),i.appendChild(d);let c=f("div","mach-filter-footer");c.append(s("resetAll",()=>r.columns.resetState(),"mach-filter-btn-reset"),s("autoSizeAll",()=>r.columns.autoSizeAll(),"mach-filter-btn-apply")),i.appendChild(c),M(i,this.e.o.root),document.body.appendChild(i),this.g=i,this.lt=e?e.id:"__standalone__",J(i,t),X(!0,this.Gt,this.Lt)}Yo(){if(!this.g)return;let e=this.g.querySelector(".mach-column-panel-list");e&&this.qo(e,this.lt==="__standalone__")}qo(e,t){let r=this.e.api;this.bl(e),e.replaceChildren();let i=this.e.n.te().filter(o=>o.isDetailToggle?!1:!t||!this.an?!0:`${o.colDef.headerName??o.colDef.field??o.id} ${o.id}`.toLocaleLowerCase().includes(this.an));for(let o of i){let s=f("div",t?"mach-column-workbench-item":"mach-filter-set-item"),a=f("label","mach-column-workbench-label"),l=document.createElement("input");l.type="checkbox",l.checked=!o.hide,l.disabled=o.hasCheckbox,l.addEventListener("change",()=>{r.columns.setVisible(o.id,l.checked),this.Yo()});let d=f("span","mach-column-workbench-name");if(d.textContent=o.colDef.headerName??o.colDef.field??o.id,d.title=`${d.textContent} (${o.id})`,a.append(l,d),s.appendChild(a),t){let c=ne({ariaLabel:`${d.textContent} ${this.e.y("clearPin")}`,options:[{value:"",label:this.e.y("clearPin")},{value:"left",label:this.e.y("pinLeft")},{value:"right",label:this.e.y("pinRight")}],value:o.pinned??"",classNames:{root:"mach-column-workbench-pin-control",native:"mach-column-workbench-pin"},themeSource:this.e.o.root,onChange:m=>{r.columns.setPinned(o.id,m==="left"||m==="right"?m:null),this.Yo()}});c.trigger.disabled=!o.movable,c.native.disabled=!o.movable,this.ti.add(c),s.appendChild(c.el);let u=this.e.n.te().filter(m=>!m.hide&&m.parentGroup===o.parentGroup&&(o.parentGroup!=null||m.pinned===o.pinned)),h=u.indexOf(o),p=(m,g,v)=>{let w=Y("mach-column-workbench-move",m,()=>{r.columns.move(o.id,g),this.Yo()});return w.disabled=v||o.hide||!o.movable,w};s.append(p("\u2191",h-1,h<=0),p("\u2193",h+1,h<0||h>=u.length-1))}e.appendChild(s)}}rh(e){for(let t of this.ti)if(t.contains(e))return!0;return!1}bl(e){for(let t of this.ti)e&&!e.contains(t.el)||(t.destroy(),this.ti.delete(t))}};var Pt=class{constructor(e){this.e=e;this.g=null;this.Gt=e=>{this.g&&!this.g.contains(e.target)&&this.close()};this.Lt=e=>{e.key==="Escape"&&this.close()}}ih(e){if(e){let o=this.e.i.f(e.rowIndex),s=this.e.n.S(e.colId);return o&&s?{node:o,column:s}:null}let t=this.e.a.lr();if(!t)return null;let r=this.e.i.f(t.r1),i=this.e.n.d()[t.c1];return r&&i?{node:r,column:i}:null}nh(e,t){let r=this.e.r.getContextMenuItems;if(!r)return null;try{return r({data:e.data,node:e,api:this.e.api,colId:t.id,value:this.e.c(e,t),rowIndex:e.rowIndex})??null}catch(i){return this.e.reportError(i,"getContextMenuItems",{colId:t.id,rowId:e.id}),null}}oh(e,t,r,i){let o=!1;for(let s of t){if(s.separator){e.appendChild(f("div","mach-context-menu-separator"));continue}let a=f("button","mach-context-menu-item");a.type="button",a.textContent=s.label??"",s.danger&&a.classList.add("mach-context-menu-item--danger"),a.disabled=s.disabled===!0,a.disabled||(o=!0,a.addEventListener("click",()=>this.sh(s,r,i))),e.appendChild(a)}return o}sh(e,t,r){this.close();try{e.action?.()}catch(i){this.e.reportError(i,"contextMenu.action",{colId:r.id,rowId:t.id})}}ah(e){let t=this.e,r=(i,o)=>{e.append(Y("mach-context-menu-item",t.y(i),()=>{o(),this.close()}))};t.r.suppressClipboard||(r("menuCopy",()=>{t.wl()}),r("menuPaste",()=>{t.lh()})),r("menuClearContents",()=>{let i=t.a.lr();i&&t.Go(i)})}open(e,t,r){this.close();let i=this.ih(r);if(!i)return;let o=f("div","mach-context-menu");if(o.setAttribute("role","menu"),this.e.r.getContextMenuItems){let s=this.nh(i.node,i.column);if(!s||!this.oh(o,s,i.node,i.column))return;this.Cl(o,e,t);return}this.ah(o),this.Cl(o,e,t)}Cl(e,t,r){M(e,this.e.o.root),document.body.appendChild(e),this.g=e;let i=e.getBoundingClientRect(),o=C(t,8,Math.max(8,window.innerWidth-i.width-8)),s=C(r,8,Math.max(8,window.innerHeight-i.height-8));e.style.left=`${o}px`,e.style.top=`${s}px`,X(!0,this.Gt,this.Lt)}close(){this.g&&(this.g.remove(),this.g=null,X(!1,this.Gt,this.Lt))}destroy(){this.close()}};var Gt=class{constructor(e){this.e=e;this.g=null;this.ln=0;this.Xo=0;this.ri=null;this.dn=e=>{if(this.e.s()||!this.e.r.tooltipComponent)return;let r=e.target.closest(".mach-cell");if(!r||r===this.ri)return;this.Jo(),this.cn(),this.ri=r;let i=this.dh(r);if(!i||r.classList.contains("mach-cell--editing"))return;let o=this.ch(i.node,i.column,i.index);this.uh(o,i.column)&&(this.ln=window.setTimeout(()=>{this.e.s()||this.ri!==r||this.hh(r,o)},Math.max(0,this.e.r.tooltipShowDelay)))};this.Tl=()=>{this.hide()}}init(){let e=this.e.o.ke;e.addEventListener("mouseover",this.dn),e.addEventListener("mouseleave",this.Tl)}destroy(){this.Jo(),this.cn();let e=this.e.o.ke;e.removeEventListener("mouseover",this.dn),e.removeEventListener("mouseleave",this.Tl),this.ri=null}hide(){this.Jo(),this.cn(),this.ri=null}Jo(){this.ln&&(clearTimeout(this.ln),this.ln=0),this.Xo&&(clearTimeout(this.Xo),this.Xo=0)}cn(){this.g&&(this.g.remove(),this.g=null)}dh(e){let t=e.dataset.colId??"",r=Number(e.closest(".mach-row")?.dataset.index);if(Number.isNaN(r))return null;let i=this.e.i.f(r),o=t?this.e.n.S(t):void 0;return!i||!o||i.isDetail||i.isGroup?null:{node:i,column:o,index:r}}ch(e,t,r){return{data:e.data,node:e,api:this.e.api,colId:t.id,value:this.e.c(e,t),formatted:he(this.e,e,t),rowIndex:r}}uh(e,t){let r=t.colDef.tooltipValueGetter;if(!r)return!!e.formatted;try{r({...e,colDef:t.colDef,column:t})}catch(i){this.e.reportError(i,"tooltipValueGetter",{colId:t.id,rowId:e.node.id})}return!0}hh(e,t){this.cn();let r=this.e.r.tooltipComponent;if(!r)return;let i=f("div","mach-tooltip");i.setAttribute("role","tooltip");let o;try{o=r(t)}catch(s){this.e.reportError(s,"tooltipComponent",{colId:t.colId,rowIndex:t.rowIndex});return}typeof o=="string"?i.textContent=o:i.appendChild(o),M(i,this.e.o.root),document.body.appendChild(i),this.g=i,J(i,e,6)}};var Lt=class{constructor(e){this.e=e;this.Z=null}init(){this.Z=document.createElement("div"),this.Z.className="mach-watermark",this.Z.setAttribute("aria-hidden","true"),this.Z.style.pointerEvents="none",this.e.o.root.appendChild(this.Z),this.apply()}apply(){if(!this.Z||this.e.s())return;let e=this.e.r.watermarkEnabled?this.e.r.watermarkConfig:null;if(!e||!e.text){this.Z.style.display="none",this.Z.style.backgroundImage="";return}let t=this.ph(e);this.Z.style.display="",t?(this.Z.style.backgroundImage=`url(${t})`,this.Z.style.backgroundColor=""):this.Z.style.backgroundImage=""}ph(e){try{let t=document.createElement("canvas"),r=t.getContext("2d");if(!r)return null;let i=e.fontSize??14,o=e.gap??160,s=e.angle??-22,a=e.color??(this.fh()?"rgba(255,255,255,0.9)":"rgba(31,55,88,0.9)"),l=e.opacity??.06;r.font=`500 ${i}px sans-serif`;let d=r.measureText(e.text),c=Math.ceil(d.width),u=Math.max(o,c+40);t.width=u,t.height=u;let h=t.getContext("2d");return h.clearRect(0,0,u,u),h.globalAlpha=l,h.fillStyle=a,h.font=`500 ${i}px sans-serif`,h.translate(u/2,u/2),h.rotate(s*Math.PI/180),h.textAlign="center",h.textBaseline="middle",h.fillText(e.text,0,0),t.toDataURL("image/png")}catch{return null}}fh(){return this.e.o.root.classList.contains("mach-theme-dark")}refresh(){this.apply()}destroy(){this.Z?.remove(),this.Z=null}};var Nt=class{constructor(e){this.e=e;this.N=[];this.Q=-1;this.de=null}al(){this.de===null&&(this.de=[])}ll(){let e=this.de;this.de=null,e&&e.length>0&&this.push(e)}Zo(e){if(this.de!==!1){if(this.de){this.de.push(e);return}this.push([e])}}push(e){let t=Math.max(0,this.e.r.undoStackSize);if(t!==0){for(this.N.length=this.Q+1,this.N.push(e);this.N.length>t;)this.N.shift();this.Q=this.N.length-1}}mh(){let e=Math.max(0,this.e.r.undoStackSize);if(e===0){this.clear();return}for(;this.N.length>e;)this.N.shift(),this.Q--;this.Q<-1&&(this.Q=-1)}canUndo(){return this.Q>=0}canRedo(){return this.Q<this.N.length-1}undo(){if(this.e.ze(),!this.canUndo())return!1;let e=this.N[this.Q];return this.Q--,this.apply(e,!1),!0}redo(){return this.e.ze(),this.canRedo()?(this.Q++,this.apply(this.N[this.Q],!0),!0):!1}apply(e,t){let r=this.e,i=[],o=this.N;for(let s of e){if(o!==this.N&&(o=this.N,!o.includes(e)))break;let a=r.i.X(s.nodeId),l=r.n.S(s.columnId);if(!a||!l||a.data==null)continue;let d=t?s.newValue:s.oldValue,c=t?s.oldValue:s.newValue;!l.colDef.valueGetter&&!l.colDef.valueSetter&&!Object.is(r.c(a,l),c)||r.en(a,l,d,c)&&(r.a.Ui(a),r.a.Dl([a.rowIndex],[l.id]),a.rowIndex>=0&&i.push(a.rowIndex),r.emit("cellValueChanged",{oldValue:c,newValue:d,rowNode:a,rowIndex:a.rowIndex,column:l,colDef:l.colDef,data:a.data}))}i.length>0&&r.a.M(i),r.Ce.refresh(),r.st.refresh()}Ic(e){if(e.length===0||!this.N.length&&!this.de)return;let t=new Set(e),r=o=>o.some(s=>t.has(s.nodeId)),i=this.Q;this.N=this.N.filter((o,s)=>r(o)?(s<=i&&this.Q--,!1):!0),this.de&&r(this.de)&&(this.de=!1)}clear(){this.N=[],this.Q=-1,this.de=null}};var Ot=class{constructor(e){this.e=e;this.B=new Map;this.Qo=!1;this.es=null}init(){this.es=this.e.ce.on("cellValueChanged",e=>{this.Qo||this.Zo(e)})}Zo(e){let t=`${e.rowNode.id}\0${e.column.id}`,i=this.B.get(t)?.originalValue??e.oldValue;Object.is(e.newValue,i)?this.B.delete(t):this.B.set(t,{rowId:e.rowNode.id,colId:e.column.id,originalValue:i,value:e.newValue}),this.ii()}getDirtyRowIds(){let e=new Set;for(let{rowId:t}of this.B.values())e.add(t);return[...e]}getChanges(){let e=new Map;for(let t of this.B.values()){let r=this.e.i.X(t.rowId);if(!r?.data)continue;let i=e.get(t.rowId);i||(i={rowId:t.rowId,data:r.data,cells:[]},e.set(t.rowId,i)),i.cells.push({colId:t.colId,originalValue:t.originalValue,value:t.value})}return[...e.values()]}markSaved(e){if(!e)this.B.clear();else{let t=new Set(e);for(let[r,i]of this.B)t.has(i.rowId)&&this.B.delete(r)}this.ii()}gh(e){for(let t of e)for(let r of t.cells){let i=`${t.rowId}\0${r.colId}`,o=this.B.get(i);if(o){Object.is(o.value,r.value)?this.B.delete(i):o.originalValue=r.value;continue}let s=this.e.i.X(t.rowId),a=this.e.n.S(r.colId);if(!s||!a||s.data==null)continue;let l=this.e.c(s,a);Object.is(l,r.value)||this.B.set(i,{rowId:t.rowId,colId:r.colId,originalValue:r.value,value:l})}this.ii()}rollback(e){let t=e?new Set(e):null,r=[...this.B.entries()].filter(([,s])=>!t||t.has(s.rowId));if(r.length===0)return!1;let i=new Set,o=new Set;this.Qo=!0;try{for(let[s,a]of r){let l=this.e.i.X(a.rowId),d=this.e.n.S(a.colId);if(!l||!d||l.data==null)continue;let c=this.e.c(l,d);if(Object.is(c,a.originalValue)){o.add(s);continue}this.e.en(l,d,a.originalValue,c)&&(o.add(s),this.e.a.Ui(l),l.rowIndex>=0&&i.add(l.rowIndex),this.e.emit("cellValueChanged",{oldValue:c,newValue:a.originalValue,rowNode:l,rowIndex:l.rowIndex,column:d,colDef:d.colDef,data:l.data}))}}finally{this.Qo=!1}for(let s of o)this.B.delete(s);return i.size>0&&this.e.a.M([...i]),this.e.Ce.refresh(),this.e.st.refresh(),this.ii(),o.size>0}kc(e){e.length>0&&this.markSaved(e)}clear(){this.B.size!==0&&(this.B.clear(),this.ii())}destroy(){this.es?.(),this.es=null,this.B.clear()}ii(){this.e.emit("dirtyStateChanged",{dirtyRowIds:this.getDirtyRowIds()})}};var Br=class{constructor(){this.ni=null;this.un=0;this.xl=0;this.El=0}acquire(){this.un++,this.yh();let e=!1;return()=>{e||(e=!0,this.un=Math.max(0,this.un-1),this.un===0&&this.disconnect())}}snapshot(){return{count:this.xl,totalMs:this.El}}yh(){if(!(this.ni||typeof PerformanceObserver>"u"))try{this.ni=new PerformanceObserver(e=>{for(let t of e.getEntries())this.xl++,this.El+=t.duration}),this.ni.observe({entryTypes:["longtask"]})}catch{this.disconnect()}}disconnect(){let e=this.ni;this.ni=null;try{e?.disconnect()}catch{}}},Ft=new Br;function Vr(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}var Ht=class{constructor(){this.Nt=[];this.hn=[];this.pn=[];this.ts=Ft.acquire(),this.fn=Ft.snapshot()}start(){return Vr()}vh(e,t,r){this.Nt.push({duration:Math.max(0,Vr()-e),rows:t,columns:r}),this.Nt.length>120&&this.Nt.shift()}bh(e){this.Rl(this.hn,e)}Oa(e){this.Rl(this.pn,e)}snapshot(){let e=this.Nt.map(o=>o.duration),t=this.Nt[this.Nt.length-1],r=[...e].sort((o,s)=>o-s),i=Ft.snapshot();return{sampleCount:e.length,lastRenderMs:t?.duration??0,averageRenderMs:this.wh(e),maxRenderMs:r[r.length-1]??0,p95RenderMs:this.rs(r,!0),longRenderCount:e.filter(o=>o>16.7).length,renderedRows:t?.rows??0,renderedColumns:t?.columns??0,renderedCells:(t?.rows??0)*(t?.columns??0),layoutSampleCount:this.hn.length,p95LayoutMs:this.rs(this.hn),modelSampleCount:this.pn.length,p95ModelMs:this.rs(this.pn),longTaskCount:Math.max(0,i.count-this.fn.count),longTaskTotalMs:Math.max(0,i.totalMs-this.fn.totalMs),usedHeapBytes:this.usedHeapBytes()}}reset(){this.Nt=[],this.hn=[],this.pn=[],this.fn=Ft.snapshot()}destroy(){this.ts?.(),this.ts=null}Rl(e,t){e.push(Math.max(0,Vr()-t)),e.length>120&&e.shift()}wh(e){return e.length===0?0:e.reduce((t,r)=>t+r,0)/e.length}usedHeapBytes(){let e=typeof performance>"u"?void 0:performance.memory?.usedJSHeapSize;return typeof e=="number"&&Number.isFinite(e)?e:null}rs(e,t=!1){if(e.length===0)return 0;let r=t?e:[...e].sort((i,o)=>i-o);return r[Math.max(0,Math.ceil(r.length*.95)-1)]??0}};function _r(n,e){if(!(n==null||e==null))return[...new Set([...n,...e])]}function ea(n,e){return n===!0||e===!0?!0:n?e?{rowIds:_r(n.rowIds,e.rowIds),rowIndexes:_r(n.rowIndexes,e.rowIndexes),columns:_r(n.columns,e.columns),force:n.force===!0||e.force===!0,includePinned:n.includePinned===!0||e.includePinned===!0}:n:e}var ta=["columns","header","pool","data","layout","pinned","summary","overlays"];function ra(n,e){let t={cells:ea(n.cells,e.cells)};for(let r of ta)t[r]=n[r]===!0||e[r]===!0;return t}var Vt=class{constructor(e){this.apply=e;this.Ot=0;this.dt=null;this.Sl=0;this.Ml=0;this.Il=0;this.mn=!1}batch(e){if(this.mn)return e();this.Ot++;try{return e()}finally{this.Ot--,this.Ot===0&&this.flush()}}Al(e){this.mn||(this.Ml++,this.dt&&this.Il++,this.dt=ra(this.dt??{},e),this.Ot===0&&this.flush())}flush(){if(this.mn||this.Ot>0||!this.dt)return;let e=this.dt;this.dt=null,this.Sl++,this.apply(e)}snapshot(){return{batchDepth:this.Ot,flushCount:this.Sl,requestCount:this.Ml,coalescedRequestCount:this.Il,pending:this.dt!=null}}destroy(){this.mn=!0,this.dt=null,this.Ot=0}};var pn=Symbol.for("mach-table.adapter.lifecycle.v1");function fn(n,e){Object.defineProperty(n,pn,{value:e})}function zr(n){let e=n[pn]?.rowDrag;return e?.policy===n.getOption("rowDragPolicy")?e?.factory:void 0}var mn=Symbol.for("mach-table.import.v1");function gn(n,e){Object.defineProperty(n,mn,{value:{begin:()=>e.V.Zi(),revision:()=>e.i.Be(),isEditing:()=>e.l.isEditing(),columns:()=>e.n.te(),visibleColumns:()=>e.n.d(),read:(r,i)=>e.c(r,i),editable:(r,i)=>e.l.J(r,i),parse:(r,i,o,s)=>de(e,r,i,o,"import",s),pasteRows:r=>{let i=[];for(let o of e.i.Et())if(!o.isGroup&&!o.isDetail&&i.push(o),i.length>=r)break;return i},resolveId:(r,i)=>e.r.resolveRowId?.({data:r,index:i,api:n}),validate:(r,i)=>e.V.Oo(r,i),guard:r=>e.V.Qi(r),commitRows:(r,i,o)=>e.V.sl(r,i,o)}})}function yn(n){let e=n[mn];if(!e)throw new TypeError("Import plans require a MachTable GridApi");return e}var we=["gridReady","gridDestroyed","modelUpdated","cellClicked","cellDoubleClicked","cellContextMenu","rowClicked","rowDoubleClicked","selectionChanged","sortChanged","filterChanged","columnResized","columnMoved","columnVisibilityChanged","cellValueChanged","cellEditingStarted","cellEditingStopped","rowEditingStarted","rowEditingStopped","detailToggled","treeChildrenLoaded","treeChildrenLoadFailed","rowDragEnd","rangeSelectionChanged","paginationChanged","displayedColumnsChanged","gridError","dirtyStateChanged"];function ia(n,e,t,r){let i=n.columns().filter(u=>u.colDef.field),o=t.columns??e,s=new Map(i.map(u=>[u.id,u])),a=new Map,l=new Map;for(let u of i){let h=u.colDef.field;a.set(h,a.has(h)?null:u);let p=u.colDef.headerName;p&&l.set(p,l.has(p)?null:u)}let d=[],c=new Set;return o.forEach((u,h)=>{let p=(typeof u=="string"||typeof u=="number"?String(u):"").replace(/^\uFEFF/,"").trim(),m=s.get(p)??(a.has(p)?a.get(p):l.get(p));if(!m){if(r||t.columns||a.has(p)||l.has(p))throw new TypeError(`Unknown or ambiguous import column: ${p}`);return}if(c.has(m.colDef.field))throw new TypeError(`Duplicate import column: ${m.id}`);c.add(m.colDef.field),d.push({column:m,index:h})}),d.length?d:n.visibleColumns().filter(u=>u.colDef.field).map((u,h)=>({column:u,index:h}))}function na(n,e){if(!Array.isArray(n)||n.some(t=>!Array.isArray(t)))throw new TypeError("Import requires an array of rows");if(!Number.isInteger(e)||e<-1||e>=n.length)throw new RangeError("Invalid import header row");if(n.length-e-1>1e4||n.reduce((t,r)=>t+r.length,0)>1e5)throw new RangeError("Import supports 10000 data rows and 100000 cells")}function oa(n,e,t,r,i,o){let s=t.colDef.field,a=n.read(e.node,t),l=o.parseValue?o.parseValue({value:i,field:s,rowIndex:e.rowIndex,columnIndex:r}):t.colDef.valueParser?n.parse(e.node,t,i,a):wt(i,o.coerceNumbers!==!1);if(l!=null&&typeof l.then=="function")throw new TypeError("Import parsers must return synchronous values");if(!pe(e.data,s,l))throw new TypeError(`Unsafe import field: ${s}`);e.changes.push({node:e.node,column:t,oldValue:a,newValue:l})}function sa(n,e,t,r,i,o,s,a){let l=a?.[t]??{},d=s?.[t]??{id:`import:${t}`,rowIndex:t,data:l,selected:!1},c={data:l,node:d,changes:[],rowIndex:t};for(let{column:u,index:h}of r)if(!(e[h]===void 0||s&&!n.editable(d,u)))try{oa(n,c,u,h,e[h],i)}catch(p){o.issues.push({rowIndex:t,columnIndex:h,colId:u.id,code:"PARSE",message:p instanceof Error?p.message:String(p)})}o.rows.push(c)}function vn(n,e,t={},r,i=!1,o){let s=t.headerRowIndex??(t.columns?-1:0);na(e,s);let a=ia(n,s<0?[]:e[s],t,i);if(!a.length)throw new TypeError("Import requires a writable field column");let l={rows:[],issues:[]};for(let d=s+1;d<e.length;d++){let c=e[d];c.some(u=>u!==""&&u!==void 0)&&sa(n,c,d-s-1,a,t,l,r,o)}return l}function ce(n){return(n==null?"":String(n)).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Bt(n,e,t="text/plain;charset=utf-8"){try{if(typeof document>"u"||typeof Blob>"u")return!1;let r=document.createElement("a");if(typeof URL<"u"&&typeof URL.createObjectURL=="function"){let i=new Blob([e],{type:t}),o=URL.createObjectURL(i);r.href=o,r.download=n,r.click();let s=typeof URL.revokeObjectURL=="function"?URL.revokeObjectURL.bind(URL):null;s&&setTimeout(()=>{try{s(o)}catch{}},0)}else r.href=`data:${t},${encodeURIComponent(e)}`,r.download=n,r.click();return!0}catch{return!1}}var Ce={columnDefs:"array",rowData:"array",defaultColDef:"object",columnTypes:"object",rowKey:"unknown",rowHeight:"number",headerHeight:"number",rowBuffer:"number",columnLayout:"string",enableColumnResize:"boolean",domLayout:"string",maxBodyHeight:"number",rowSelection:"string",multiSort:"boolean",size:"string",stripedRows:"boolean",rowStyleRules:"array",showCellBorders:"boolean",theme:"string",quickFilterText:"string",advancedFilterModel:"object",masterDetail:"boolean",detailRowHeight:"number",detailRowRenderer:"function",isRowExpandable:"function",detailToggleColumn:"boolean",columnMenu:"boolean",aggFuncs:"object",components:"object",actionPolicy:"object",features:"array",initialState:"object",persistence:"boolean-object",locale:"object",editType:"string",editableIndicator:"string",rowEditValidator:"function",singleClickEdit:"boolean",manualSorting:"boolean",manualFiltering:"boolean",showSummary:"boolean",summaryMethod:"function",treeData:"boolean",childrenKey:"string",isTreeRowExpandable:"function",loadTreeChildren:"function",autoCheckedChildren:"boolean",defaultExpandAll:"boolean",rowNumber:"boolean",indexOffset:"number",applyRowDrag:"boolean",rowDragPolicy:"object",undoStackSize:"number",asyncTransactionWaitMillis:"number",getRowHeight:"function",pinnedTopRowData:"array",pinnedBottomRowData:"array",pagination:"boolean-object",watermark:"boolean-object",suppressWarnings:"boolean",enableRangeSelection:"boolean",suppressClipboard:"boolean",contextMenu:"boolean",getContextMenuItems:"function",tooltipComponent:"function",tooltipShowDelay:"number",flashCells:"boolean",fillHandle:"boolean",statusBar:"boolean-object",datasource:"object",datasourceMode:"string",blockSize:"number",infiniteBufferRows:"number",maxBlocksInCache:"number",datasourceMaxConcurrentRequests:"number",blockPrefetch:"number",datasourceRowCount:"number",dataProcessor:"object-function",dataProcessorMinRows:"number",datasourceRetryCount:"number",datasourceRetryDelay:"number",datasourceRetryJitter:"number",suppressCellFocus:"boolean",suppressRowHoverHighlight:"boolean",suppressNoRowsOverlay:"boolean",suppressHeaderFocus:"boolean",ariaLabel:"string",ariaLabelledBy:"string",ariaDescribedBy:"string",loading:"boolean",error:"unknown",overlayNoRowsTemplate:"unknown",overlayLoadingTemplate:"unknown",overlayErrorTemplate:"unknown",allowUnsafeOverlayHtml:"boolean",className:"string"};var Wr=Object.freeze(Object.keys(Ce));var $r=new Set(we.map(n=>`on${n.charAt(0).toUpperCase()}${n.slice(1)}`));function Kr(n,e){let t=Ce[n];return e==null||t==="unknown"?!0:t==="array"?Array.isArray(e):t==="number"?E(e,n==="maxBodyHeight"?1:-1/0)!==void 0:t==="boolean-object"&&typeof e=="boolean"||t==="object-function"&&typeof e=="function"?!0:t==="object"||t==="boolean-object"||t==="object-function"?typeof e=="object"&&!Array.isArray(e):typeof e===t}function bn(n){let e={};for(let[t,r]of Object.entries(n)){if($r.has(t)){(r==null||typeof r=="function")&&(e[t]=r);continue}!Object.prototype.hasOwnProperty.call(Ce,t)||!Kr(t,r)||(e[t]=r)}return e}var Dn=2e3,Ur=1e5,Be=512,la=1e4;function wn(n){return Array.isArray(n)?[...new Set(n.slice(0,Ur).filter(e=>typeof e=="string"&&e.length>0&&e.length<=Be))]:[]}function da(n){if(!Array.isArray(n))return[];let e=new Set,t=Ur*Be;for(let r of n.slice(0,Ur)){if(typeof r!="string"||!r.length||e.has(r))continue;let i=r.startsWith(pt)?65536:Be;r.length>i||r.length>t||(e.add(r),t-=r.length)}return[...e]}function Cn(n,e){return typeof n=="number"&&Number.isFinite(n)&&n>=1?Math.floor(n):e}function Tn(n){return typeof n=="number"&&Number.isFinite(n)&&n>0?n:void 0}function ca(n,e){let t=Tn(e.flex);for(let r of["width","contentWidth"]){let i=Tn(e[r]);i!==void 0&&(n[r]=i)}e.flex===null?n.flex=null:t!==void 0&&(n.flex=t),(e.widthMode==="auto"||e.widthMode==="manual")&&(n.widthMode=e.widthMode)}function ua(n,e){typeof e.hide=="boolean"&&(n.hide=e.hide),(e.pinned===null||e.pinned==="left"||e.pinned==="right")&&(n.pinned=e.pinned)}function ha(n,e){if(n==null||typeof n!="object")return null;let t=n,r=typeof t.colId=="string"?t.colId.trim():"";if(!r||r.length>Be||e.has(r))return null;e.add(r);let i={colId:r};return ua(i,t),ca(i,t),i}function pa(n){if(!Array.isArray(n))return[];let e=[],t=new Set;for(let r of n.slice(0,Dn)){let i=ha(r,t);i&&e.push(i)}return e}function fa(n){if(!Array.isArray(n))return[];let e=[],t=new Set;for(let r of n.slice(0,Dn)){if(r==null||typeof r!="object")continue;let i=r,o=typeof i.colId=="string"?i.colId.trim():"";!o||o.length>Be||t.has(o)||i.direction!=="asc"&&i.direction!=="desc"||(t.add(o),e.push({colId:o,direction:i.direction}))}return e}function $(n){if(n==null||typeof n!="object")return null;let e=n;if(e.version!==2||!Array.isArray(e.columns)||!Array.isArray(e.sortModel))return null;let t=e.pagination!=null&&typeof e.pagination=="object"?e.pagination:{};return{version:2,columns:pa(e.columns),sortModel:fa(e.sortModel),filterModel:Z(e.filterModel),advancedFilterModel:H(e.advancedFilterModel),quickFilterText:typeof e.quickFilterText=="string"&&e.quickFilterText.trim()?e.quickFilterText.slice(0,la):null,pagination:{enabled:t.enabled===!0,page:Cn(t.page,1),pageSize:Cn(t.pageSize,20)},selectedRowIds:wn(e.selectedRowIds),expandedRowIds:wn(e.expandedRowIds),expandedGroupIds:da(e.expandedGroupIds)}}function xn(n,e){let t=$(n);if(!t)throw new TypeError("[MachTable] Cannot persist an invalid GridState snapshot.");let r=new Set(e);return{version:2,columns:r.has("columns")?t.columns:[],sortModel:r.has("sort")?t.sortModel:[],filterModel:r.has("filter")?t.filterModel:{},advancedFilterModel:r.has("filter")?t.advancedFilterModel:null,quickFilterText:r.has("filter")?t.quickFilterText:null,pagination:r.has("pagination")?t.pagination:{enabled:!1,page:1,pageSize:20},selectedRowIds:r.has("selection")?t.selectedRowIds:[],expandedRowIds:r.has("expansion")?t.expandedRowIds:[],expandedGroupIds:r.has("expansion")?t.expandedGroupIds:[]}}function ma(n){try{if(typeof structuredClone=="function")return structuredClone(n)}catch{}return Array.isArray(n)?[...n]:n!=null&&typeof n=="object"?{...n}:n}function Rn(n,e){let t=e?new Set(e.map(String)):null;return n.filter(r=>!t||t.has(r.rowId)).map(r=>({...r,data:ma(r.data),cells:r.cells.map(i=>({...i}))}))}function ga(n,e){let t=typeof n?.rowId=="string"?n.rowId:"";return!e.has(t)||typeof n.message!="string"||!n.message.trim()?null:{...n,rowId:t,message:n.message.trim(),...typeof n.code=="string"&&n.code.trim()?{code:n.code.trim()}:{},...Array.isArray(n.colIds)?{colIds:[...new Set(n.colIds.filter(r=>typeof r=="string"&&r.length>0))]}:{}}}function En(n,e){let t=new Map;for(let r of n??[]){let i=ga(r,e);i&&!t.has(i.rowId)&&t.set(i.rowId,i)}return[...t.values()]}function Sn(n,e){let t=new Set(n.map(d=>d.rowId)),r=En(e?.conflicts,t),i=new Set(r.map(d=>d.rowId)),o=En(e?.failures,t).filter(d=>!i.has(d.rowId)),s=new Set([...o,...r].map(d=>d.rowId)),a=e?.savedRowIds==null?null:new Set(e.savedRowIds.map(String).filter(d=>t.has(d))),l=n.filter(d=>!s.has(d.rowId)&&(a==null||a.has(d.rowId)));return{submitted:n,saved:l,failures:o,conflicts:r}}function ya(n,e){if(e.serverData===void 0)return null;let t=n.rows.getById(e.rowId);if(!t||t.data==null)return null;let r=n.getOption("rowKey");if(r){let s=typeof r=="function"?r(e.serverData):B(e.serverData,r);return String(s)===e.rowId?{data:e.serverData,mergeIntoCurrent:!1}:null}let i=t.data;return i!=null&&e.serverData!=null&&typeof i=="object"&&typeof e.serverData=="object"?{data:i,mergeIntoCurrent:!0}:null}function Mn(n,e,t){if(n.isDestroyed())return!1;if(t==="keepLocal")return!0;let r=ya(n,e);return r?(n.editing.rollback([e.rowId]),r.mergeIntoCurrent&&Object.assign(r.data,e.serverData),n.rows.transact({update:[r.data]}),n.editing.markSaved([e.rowId]),!0):!1}var va=["compact","normal","large"],b=["left","center","right"];function zt(n,e){let t=n.r,r;if(e==="loading")r=t.overlayLoadingTemplate||n.Ch();else if(e==="noRows")r=t.overlayNoRowsTemplate||n.Th();else if(e==="error")r=t.overlayErrorTemplate||n.Dh();else{n.o.xh();return}n.o.Eh(e,r,t.allowUnsafeOverlayHtml)}var _t=class{constructor(e){this.e=e;this.ai=null;this.ss=null;this.as=!1;this.bn=null;this.ls=[];this.wn=null;this.ur=0;this.kl=-1;this.Pl=-1;this.Jt=1;this.hr=null}init(e,t){let r=["mach-root",`mach-size--${t.size}`];t.stripedRows&&r.push("mach-striped"),t.showCellBorders&&r.push("mach-cell-borders"),t.domLayout==="autoHeight"&&r.push("mach-dom-layout--auto-height"),this.root=f("div",r.join(" ")),this.Gl(t.className),this.root.style.setProperty("--mach-row-h",`${t.rowHeight}px`),this.root.style.setProperty("--mach-header-h",`${t.headerHeight}px`),this.root.setAttribute("role","grid"),this.root.tabIndex=0,this.Ll(t),this.oi=f("div","mach-header"),this.oi.setAttribute("role","rowgroup"),this.si={left:[],center:[],right:[]},this.ns={},this.ar={};for(let i of b){let o=f("div",`mach-pane mach-pane--${i} mach-header-pane`),s=f("div","mach-header-rows");if(i==="center"){let a=f("div","mach-header-viewport");a.appendChild(s),o.appendChild(a)}else o.appendChild(s);this.oi.appendChild(o),this.ns[i]=o,this.ar[i]=s}this.Nl(1),this.ke=f("div","mach-body"),this.gn=f("div","mach-pinned-rows mach-pinned-rows--top"),this.gn.style.display="none",this.yn=f("div","mach-pinned-rows mach-pinned-rows--bottom"),this.yn.style.display="none",this.T={},this.Te={},this.os={};for(let i of b){let o=f("div",`mach-pane mach-pane--${i} mach-body-pane`),s=f("div",`mach-body-viewport${i==="center"?" mach-body-viewport--scroll":""}`),a=f("div","mach-row-container");s.appendChild(a),o.appendChild(s),this.ke.appendChild(o),this.os[i]=o,this.T[i]=s,this.Te[i]=a}this.Ke=f("div","mach-overlay"),this.Ke.style.display="none",this.Ke.setAttribute("role","status"),this.Ke.setAttribute("aria-live","polite"),this.Ue=f("div","mach-overlay-content"),this.Ke.appendChild(this.Ue),this.ct=f("div","mach-infinite-loading"),this.ct.style.display="none",this.ct.appendChild(f("div","mach-spinner")),this.vn=f("span"),this.ct.appendChild(this.vn),this.root.append(this.oi,this.gn,this.ke,this.yn,this.Ke,this.ct),e.appendChild(this.root),typeof ResizeObserver<"u"&&(this.wn=new ResizeObserver(i=>{let o=i[i.length-1]?.contentRect;if(!o)return;let s=Math.round(o.width),a=Math.round(o.height);s===this.kl&&a===this.Pl||(this.kl=s,this.Pl=a,!this.ur&&(this.ur=requestAnimationFrame(()=>{this.ur=0,this.e.ye()})))}),this.wn.observe(this.root)),this.Ol(t.theme)}Ll(e){e.ariaLabelledBy?(this.root.setAttribute("aria-labelledby",e.ariaLabelledBy),this.root.removeAttribute("aria-label")):(this.root.removeAttribute("aria-labelledby"),this.root.setAttribute("aria-label",e.ariaLabel)),e.ariaDescribedBy?this.root.setAttribute("aria-describedby",e.ariaDescribedBy):this.root.removeAttribute("aria-describedby")}Nl(e){this.Jt=e;for(let t of b){let r=this.ar[t],i=this.si[t];for(;i.length<e;){let o=f("div","mach-header-row");o.setAttribute("role","row"),o.setAttribute("aria-rowindex",String(i.length+1)),r.appendChild(o),i.push(o)}for(;i.length>e;)i.pop().remove()}this.Fl()}Hl(){return this.Jt}Fl(){this.oi.style.height=`${this.Jt*this.e.r.headerHeight}px`;for(let e of b)this.si[e].forEach((r,i)=>{r.style.top=`${i*this.e.r.headerHeight}px`,r.style.height=`${this.e.r.headerHeight}px`})}Rh(e,t){this.Vl("left",e),this.Vl("right",t)}Vl(e,t){let r=this.ns[e],i=this.os[e];r.style.width=`${t}px`,i.style.width=`${t}px`;let o=t<=0;r.classList.toggle("mach-pane--hidden",o),i.classList.toggle("mach-pane--hidden",o)}ds(){let e=this.T.center,t=Math.max(0,e.offsetWidth-e.clientWidth);return Math.max(0,this.ke.clientWidth-t)}Sh(e,t){this.root.style.setProperty("--mach-row-h",`${e}px`),this.root.style.setProperty("--mach-header-h",`${t}px`),this.Fl()}Mh(e){for(let t of va)this.root.classList.toggle(`mach-size--${t}`,t===e)}Ol(e){if(!this.root)return;this.hr?.(),this.hr=null;let t=e==="dark"||e==="auto"&&this.Ih();if(this.root.classList.toggle("mach-theme-dark",t),e==="auto"&&typeof window<"u"&&typeof window.matchMedia=="function"){let r=window.matchMedia("(prefers-color-scheme: dark)"),i=()=>this.root.classList.toggle("mach-theme-dark",r.matches);typeof r.addEventListener=="function"?(r.addEventListener("change",i),this.hr=()=>r.removeEventListener("change",i)):typeof r.addListener=="function"&&(r.addListener(i),this.hr=()=>r.removeListener(i))}}Ih(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-color-scheme: dark)").matches}Ah(e){this.root.classList.toggle("mach-striped",e)}kh(e){this.root.classList.toggle("mach-cell-borders",e)}Ph(e){this.root.classList.toggle("mach-dom-layout--auto-height",e==="autoHeight")}Gl(e){for(let t of this.ls)this.root.classList.remove(t);this.ls=[];for(let t of String(e??"").split(/\s+/).filter(Boolean))this.root.classList.contains(t)||(this.root.classList.add(t),this.ls.push(t))}Gh(e){try{return typeof e=="function"?e():e}catch(t){return this.e.reportError(t,"overlayTemplate"),""}}Lh(e,t,r){if(typeof t=="object"&&t!=null&&"el"in t){this.Ue.appendChild(t.el),this.bn=t.destroy??null;return}if(t instanceof HTMLElement){this.Ue.appendChild(t);return}if(t){r?this.Ue.innerHTML=t:this.Ue.textContent=t;return}if(e!=="loading")return;let i=f("div","mach-spinner");i.setAttribute("aria-label","loading"),this.Ue.appendChild(i)}Eh(e,t,r=!1){this.ai===e&&this.ss===t&&this.as===r||(this.ai=e,this.ss=t,this.as=r,this.cs(),this.Ue.replaceChildren(),this.Lh(e,this.Gh(t),r),this.Ke.style.display="",this.root.classList.add("mach-has-overlay"),this.Ke.setAttribute("role",e==="error"?"alert":"status"),this.root.setAttribute("aria-busy",e==="loading"?"true":"false"))}xh(){this.ai&&(this.ai=null,this.ss=null,this.as=!1,this.Ke.style.display="none",this.root.classList.remove("mach-has-overlay"),this.cs(),this.Ue.replaceChildren(),this.root.setAttribute("aria-busy","false"))}Tt(e,t){this.ct&&(e?(this.vn.textContent!==t&&(this.vn.textContent=t),this.ct.style.display="",this.root.setAttribute("aria-busy","true")):(this.ct.style.display="none",this.ai!=="loading"&&this.root.setAttribute("aria-busy","false")))}destroy(){this.hr?.(),this.hr=null,this.wn?.disconnect(),this.wn=null,this.ur&&cancelAnimationFrame(this.ur),this.ur=0,this.cs(),this.root?.remove()}cs(){if(!this.bn)return;let e=this.bn;this.bn=null;try{e()}catch(t){this.e.reportError(t,"overlayTemplate.destroy")}}};function In(n,e){return{setData:t=>n.rt(t),transact:t=>n.Vr(t),transactAsync:(t,r)=>n.Nh(t,r),flushTransactions:()=>n.Bl(),getCount:()=>e.i.P(),getAt:t=>e.i.f(t),getById:t=>e.i.X(t),forEach:t=>e.i.eu(t),forEachDisplayed:t=>e.i.tu(t),reorder:(t,r)=>!e.s()&&!e.l.isEditing()&&e.i.za(t,r),isRemote:()=>e.i.m,reload:t=>n.reload(t),ensureLoaded:(t,r,i)=>n.vo(t,r,i),purgeCache:()=>{e.s()||e.i.Dc()},getCacheSnapshot:()=>e.i.xc()}}function An(n,e){return{getDefinitions:()=>e.n.to(),setDefinitions:t=>n.Sr(t),getState:()=>e.n.la(),setState:t=>n.Oh(t),resetState:()=>n.ao(),setVisible:(t,r)=>n.no(t,r),setPinned:(t,r)=>n.oo(t,r),move:(t,r)=>{e.s()||e.Mr(t,r)},setWidth:(t,r)=>n.Ee(t,r),fit:t=>n.Fh(t),autoSize:t=>n.Hh(t),autoSizeAll:()=>n.Vh(),getWorkbenchItems:()=>n.Bh(),openWorkbench:t=>{e.s()||e.columnMenu.th(t)},closeWorkbench:()=>e.columnMenu.close()}}function kn(n,e){return{getRows:()=>e.h.Wa(),getVisibleRows:()=>n._h(),getNodes:()=>e.h.St(),getIds:()=>e.h.$a(),setRows:(t,r)=>n.zh(t,r),setById:(t,r,i)=>e.h.su(t,r,i),selectAll:t=>e.h.selectAll(t),clear:()=>e.h.deselectAll(),getMode:()=>e.r.rowSelection,setMode:t=>n.Wh(t),getRange:()=>e.a.li(),clearRange:()=>n.dr()}}function Pn(n,e){return{startCell:t=>n.$h(t),startRow:t=>e.l.startRow(t),isRowActive:t=>e.l.dl(t),stop:t=>e.l.le(t?.cancel===!0),getChanges:()=>e.K.getChanges(),getDirtyRowIds:()=>e.K.getDirtyRowIds(),markSaved:t=>e.K.markSaved(t),rollback:t=>e.K.rollback(t),save:(t,r)=>n.Kh(t,r),undo:()=>!e.s()&&e.F.undo(),redo:()=>!e.s()&&e.F.redo(),canUndo:()=>e.F.canUndo(),canRedo:()=>e.F.canRedo()}}function Gn(n){return{get:()=>n.getState(),apply:(e,t)=>n._l(e,t)}}function Ln(n,e){return{get:()=>e.Uh(),getPerformance:()=>e.ve.snapshot(),resetPerformance:()=>e.ve.reset()}}function Nn(n,e){return{getModel:()=>e.i._e(),setModel:t=>n.Dt(t),getAdvancedModel:()=>e.i.Fr(),setAdvancedModel:t=>n.it(t),getQuickText:()=>e.i.La(),setQuickText:t=>n.xt(t),isPresent:t=>t==null?e.i.Br():Object.prototype.hasOwnProperty.call(e.i._e(),t)}}function On(n,e){return{getModel:()=>e.n.re(),setModel:t=>n.jh(t)}}function Fn(n,e){return{isEnabled:()=>e.i.be,setEnabled:t=>{e.s()||e.i.Va(t)},getPage:()=>e.i.rr(),setPage:t=>{e.s()||e.i.setPage(t)},getPageSize:()=>e.r.paginationPageSize,setPageSize:t=>{e.s()||e.i.setPageSize(t)},getPageCount:()=>e.i.getPageCount(),getTotalRowCount:()=>e.i.getTotalRowCount()}}function Hn(n,e){return{isRowExpanded:t=>e.i.isRowExpanded(t),setRowExpanded:(t,r)=>e.s()||e.i.isRowExpanded(t)===r?!1:(r?e.i.Jc(t):e.i.Zc(t),e.i.isRowExpanded(t)===r),isTreeRowLoading:t=>!e.s()&&e.i.isTreeRowLoading(t),loadTreeChildren:(t,r)=>e.s()?Promise.resolve([]):e.i.loadTreeChildren(t,r?.force===!0),isGroupExpanded:t=>e.i.isGroupExpanded(t),setGroupExpanded:(t,r)=>e.s()||e.i.isGroupExpanded(t)===r?!1:(e.i.xo(t),e.i.isGroupExpanded(t)===r),setAllGroupsExpanded:t=>{e.s()||e.i.setAllGroupsExpanded(t)},setAllDetailsExpanded:t=>{e.s()||e.i.setAllDetailsExpanded(t)}}}function Vn(n,e){return{getRoot:()=>e.s()?null:e.o.root,scrollToRow:(t,r)=>e.a.ji(t,r),refreshCells:t=>n.refreshCells(t),refreshLayout:()=>n.refreshLayout(),flush:()=>e.pr.flush(),setOverlay:t=>zt(e,t),getPinnedRows:t=>e.Pe.getRows(t),setPinnedRows:(t,r)=>n.setPinnedRows(t,r)}}function Bn(n,e){return{exportCsv:t=>n.qh(t),importCsv:(t,r)=>n.importCsv(t,r),exportMatrix:t=>n.zl(t),importMatrix:(t,r)=>n.importMatrix(t,r),print:t=>n.print(t),copyRange:()=>e.s()?Promise.resolve(!1):e.wl()}}function Wt(n){return ie(n?.reason,"The operation was aborted")}function _n(n,e){return dt(n,e,()=>Wt(e))}function x(n,e){return Object.prototype.hasOwnProperty.call(n,e)}function jr(n,e,t,r=!1){let i=E(n,t,r);return i===void 0||i===e?void 0:i}function O(n,e,t){let r=n[t];return r==null||r===e[t]?!1:(e[t]=r,!0)}var qr=class{constructor(e){this.e=e;this.us=[];this.di=null}batch(e){return this.e.Wl(()=>e(this.e.api))}rt(e){this.e.s()||(this.e.r.rowData=e??[],!this.e.i.m&&(this.e.i.rt(e),this.e.U({data:!0})))}Vr(e){if(this.e.s()||this.e.i.m)return;let t=this.e.i.Vr(e);this.$l(t)}Nh(e,t={}){if(this.e.s()||this.e.i.m)return Promise.resolve();if(t.signal?.aborted)return Promise.reject(Wt(t.signal));let r=new Promise((i,o)=>{let s={transaction:e,revision:this.e.i.Be(),resolve:i,reject:o,signal:t.signal,aborted:!1};t.signal&&(s.onAbort=()=>{s.aborted||(s.aborted=!0,o(Wt(t.signal)))},t.signal.addEventListener("abort",s.onAbort,{once:!0})),this.us.push(s)});return this.di==null&&(this.di=setTimeout(()=>this.Bl(),this.e.r.asyncTransactionWaitMillis)),r}Kl(){this.di!=null&&clearTimeout(this.di),this.di=null;let e=this.us;return this.us=[],e}Bl(){let e=this.Kl(),t=this.e.i,r=t.Be(),i=e.filter(s=>!s.aborted&&s.revision===r).map(s=>s.transaction);if(i.length>0&&!this.e.s()&&!t.m){let s=t.Pc(i);t.Be()===r&&this.$l(s)}let o=t.Be()===r;for(let s of e)s.signal&&s.onAbort&&s.signal.removeEventListener("abort",s.onAbort),!s.aborted&&(o&&s.revision===r?s.resolve():s.reject(ie(void 0,"The table data changed before the transaction could complete")))}$l(e){if(e.pipelineChanged){this.e.U({data:!0});return}e.updatedRowIds.length!==0&&this.e.U({cells:{rowIds:e.updatedRowIds},summary:!0,overlays:!0})}Sr(e){this.updateOptions({columnDefs:[...e??[]]})}Oh(e){this.e.s()||(this.e.n.da(e),this.e.Ft(),this.e.fr())}ao(){this.e.s()||(this.e.n.ao(),this.e.Ft(),this.e.fr())}no(e,t){this.e.s()||(this.e.n.no(e,t),this.e.Ft(),this.e.emit("columnVisibilityChanged",{colId:e,visible:t}))}oo(e,t){this.e.s()||(this.e.n.oo(e,t),this.e.Ft(),this.e.fr())}Ee(e,t){if(this.e.s())return!1;let r=this.e.n.S(e);return!r||!this.e.n.Ee(r,t)?!1:(this.ot([r]),!0)}Fh(e){if(this.e.s())return;let t=this.e.n.d(),r=t.filter(d=>d.pinned===null&&!d.colDef.suppressSizeToFit);if(r.length===0)return;let i=e??this.e.o.ds();if(!Number.isFinite(i)||i<=0)return;let o=t.reduce((d,c)=>d+(c.pinned!==null||c.colDef.suppressSizeToFit?c.currentWidth:0),0),s=tt(r.map(d=>({width:d.currentWidth,minWidth:d.colDef.minWidth,maxWidth:d.colDef.maxWidth})),Math.max(0,i-o)),a=this.e.r.columnLayout==="fit"&&e===void 0,l=r.filter((d,c)=>a?this.e.n.sa(d,s[c]):this.e.n.Ee(d,s[c]));this.ot(l)}Hh(e){if(this.e.s())return;let t=this.e.n.S(e);t&&this.Ul(t)&&this.ot([t])}Ul(e){return this.e.r.columnLayout==="fit"&&e.colDef.suppressSizeToFit?!1:e.hasCheckbox||e.isDetailToggle?this.e.n.Ee(e,e.isDetailToggle?38:46):this.Yh(e,this.e.Ht.ra(e))}Yh(e,t){return this.e.r.columnLayout==="fit"?this.e.n.sa(e,t):this.e.n.Ee(e,t)}Vh(){if(this.e.s())return;let e=[];for(let t of this.e.n.d())this.Ul(t)&&e.push(t);e.length>0&&this.ot(e)}ot(e){this.e.nr(),this.e.ot(e)}jh(e){this.e.s()||(this.e.n.Ir(e),this.e.Ir())}Dt(e){this.e.s()||(this.e.i.Dt(e),this.e.ci())}it(e){this.e.s()||!this.e.i.it(e)||this.e.ci()}xt(e){this.e.s()||(this.e.r.quickFilterText=e!=null&&e.trim()!==""?e:null,this.e.i.xt(e)&&this.e.ci())}Wh(e){this.e.s()||this.e.r.rowSelection!==e&&(this.e.r.rowSelection=e,e==="none"&&this.e.h.deselectAll(),this.e.$.ui(),this.e.a.hs())}zh(e,t=!0){if(this.e.s())return;let r=this.e.r.resolveRowId,i=[];for(let o of e){let s=r?this.e.i.X(this.e.i.resolveRowId(o,-1,`__missing_selection_${this.e.tr()}`)):this.e.i.Oe().find(a=>a.data===o);s&&i.push({node:s,selected:!0})}i.length>0?this.e.h.uu(i,t):t&&this.e.h.deselectAll()}_h(){let e=new Set(this.e.h.St().map(t=>t.id));return this.e.i.Et().filter(t=>!t.isDetail&&!t.isGroup&&e.has(t.id)).map(t=>t.data).filter(Boolean)}async Kh(e,t){let r=Rn(this.e.K.getChanges(),t);if(r.length===0)return{submitted:[],saved:[],failures:[],conflicts:[]};let i=this.e.i.Be(),o=Sn(r,await e(r));return!this.e.s()&&i===this.e.i.Be()&&this.e.K.gh(o.saved),o}setPinnedRows(e,t){if(this.e.s())return;let r=e==="top"?"pinnedTopRowData":"pinnedBottomRowData";this.e.r[r]=t??[],this.e.Pe.setRows(e,this.e.r[r])}dr(){this.e.s()||this.e.a.dr()}Bh(){return this.e.n.te().filter(e=>!e.isDetailToggle).map(e=>({colId:e.id,label:e.colDef.headerName??e.colDef.field??e.id,visible:!e.hide,pinned:e.pinned,width:e.currentWidth||e.manualWidth||e.colDef.width||0,movable:e.movable,hideable:!e.hasCheckbox}))}refreshLayout(){this.e.s()||(this.e.ye(),this.e.a.Cn(!0))}reload(e={}){return this.e.s()?Promise.resolve():e.signal?.aborted?Promise.reject(Wt(e.signal)):this.e.i.m?_n(this.e.i.zi(e.signal),e.signal):(this.rt(this.e.r.rowData),Promise.resolve())}vo(e,t,r={}){return this.e.s()?Promise.resolve():_n(this.e.i.vo(e,t,r.signal),r.signal)}importCsv(e,t={}){if(!e)return!1;let{parseValue:r,...i}=t;return this.importMatrix(Dt(e,t.separator??","),{...i,parseValue:r?o=>r({...o,value:o.value}):void 0})}importMatrix(e,t={}){if(this.e.s()||this.e.i.m||!Array.isArray(e)||!e.length)return!1;try{let r=yn(this.e.api),i=t.mode==="paste"?r.pasteRows(e.length):void 0,o=vn(r,e,t,i);if(o.issues.length)return this.e.reportError(new Error(o.issues.map(s=>s.message).join("; ")),"import",{issues:o.issues}),!1;if(t.mode==="paste")this.e.mr(o.rows.flatMap(s=>s.changes));else{let s=o.rows.map(a=>a.data);t.mode==="append"?this.Vr({add:s}):this.rt(s)}return!0}catch(r){return this.e.reportError(r,"import"),!1}}print(e={}){if(this.e.s())return!1;try{let t=window.open("","_blank","width=980,height=720");if(!t)return!1;let r=this.e.n.d().filter(d=>j(d)&&!d.colDef.rowDrag),i=this.e.i.Fa().filter(d=>!d.isDetail&&!d.isGroup),s=e.includeHeader!==!1?`<tr>${r.map(d=>`<th>${ce(d.colDef.headerName??d.colDef.field??d.id)}</th>`).join("")}</tr>`:"",a=i.map(d=>`<tr>${r.map(c=>{let u=he(this.e,d,c);return`<td>${ce(u)}</td>`}).join("")}</tr>`).join(""),l=`<!doctype html><html><head><meta charset="utf-8"><title>${ce(e.title??"MachTable")}</title><style>body{font-family:system-ui,"PingFang SC","Microsoft YaHei",sans-serif;padding:20px}h3{margin:0 0 12px;font-size:16px}table{border-collapse:collapse;width:100%;font-size:12px}th,td{border:1px solid #bbb;padding:5px 8px;text-align:left;word-break:break-all}th{background:#f2f5f9;font-weight:600}@page{margin:12mm}</style></head><body><h3>${ce(e.title??"")}</h3><table>${s}${a}</table></body></html>`;return t.document.write(l),t.document.close(),t.focus(),t.print(),!0}catch{return!1}}$h(e){let t=this.e.n.S(e.colId);return t?this.e.l.start(e.rowIndex,t,e.keyPress??null):!1}refreshCells(e){let t=e==null||e.rowIds==null&&e.rowIndexes==null&&e.columns==null;this.e.U({cells:e??!0,pinned:e?.includePinned??t,summary:t})}getOption(e){return this.e.r[e]}updateOptions(e){this.e.s()||(this.e.ps(e),e=bn(e),Object.keys(e).length!==0&&this.e.Wl(()=>{let t={},r=this.e.r.columnMenu;this.Xh(e,t),this.Jh(e,t),this.Zh(e,t),this.Qh(e,t),this.ep(e),this.tp(e,t),this.rp(e,t),this.ip(e,t),this.np(e,t),this.op(e,t),this.sp(e,t,r)}))}Xh(e,t){let r=this.e.r;x(e,"columnDefs")&&e.columnDefs!==r.columnDefs&&(r.columnDefs=Array.isArray(e.columnDefs)?e.columnDefs:[],t.needsColumnRebuild=!0,t.columnDefsChanged=!0),R(e,r,["rowNumber"])&&(t.needsColumnRebuild=!0),x(e,"rowData")&&e.rowData!==r.rowData&&(r.rowData=Array.isArray(e.rowData)?e.rowData:[],t.needsRowRebuild=!0),x(e,"initialState")&&e.initialState&&(r.initialState=e.initialState,t.stateToApply=e.initialState),this.ap(e)}ap(e){for(let t of we){let r=`on${t.charAt(0).toUpperCase()}${t.slice(1)}`;x(e,r)&&Object.assign(this.e.r,{[r]:e[r]})}}Jh(e,t){let r=this.e.r;for(let o of["rowHeight","headerHeight","rowBuffer"]){let s=jr(e[o],r[o],o==="rowBuffer"?0:1,o==="rowBuffer");s!==void 0&&(r[o]=s,t.layout=!0,o==="headerHeight"&&(t.header=!0))}e.columnLayout!=null&&e.columnLayout!==r.columnLayout&&(r.columnLayout=e.columnLayout==="fit"?"fit":"normal",t.layout=!0),e.domLayout!=null&&e.domLayout!==r.domLayout&&(r.domLayout=e.domLayout==="autoHeight"?"autoHeight":"normal",this.e.o.Ph(r.domLayout),t.pool=!0),x(e,"maxBodyHeight")&&(r.maxBodyHeight=E(e.maxBodyHeight,1),t.layout=!0),R(e,r,["multiSort"]);let i=jr(e.detailRowHeight,r.detailRowHeight,1);i!==void 0&&(r.detailRowHeight=i,this.e.a.Tn(),this.e.a.hi(!0))}Zh(e,t){let r=this.e.r;e.editType!=null&&e.editType!==r.editType&&(this.e.l.stop(!0),r.editType=e.editType==="fullRow"?"fullRow":"cell",t.cells=!0),e.editableIndicator!=null&&e.editableIndicator!==r.editableIndicator&&(r.editableIndicator=e.editableIndicator==="always"||e.editableIndicator==="none"?e.editableIndicator:"hover",t.cells=!0),R(e,r,["rowEditValidator"],!0),R(e,r,["singleClickEdit","manualSorting","manualFiltering"])}Qh(e,t){let r=this.e.r;typeof e.enableColumnResize=="boolean"&&e.enableColumnResize!==r.enableColumnResize&&(this.e.pi.kt(),r.enableColumnResize=e.enableColumnResize,t.header=!0),O(e,r,"locale")&&(t.header=!0,t.cells=!0,this.e.gr.De(),this.e.st.De()),O(e,r,"indexOffset")&&(t.cells=!0),O(e,r,"showSummary")&&(t.summary=!0,t.layout=!0);let i=jr(e.undoStackSize,r.undoStackSize,0,!0);i!==void 0&&(r.undoStackSize=i,this.e.F.mh());let o=E(e.asyncTransactionWaitMillis,0,!0);o!==void 0&&(r.asyncTransactionWaitMillis=o),this.lp(e,t),this.dp(e)}lp(e,t){x(e,"getRowHeight")&&(this.e.r.getRowHeight=e.getRowHeight,this.e.a.Dn(),t.layout=!0)}dp(e){let t=this.e.r;e.enableRangeSelection!=null&&(t.enableRangeSelection=e.enableRangeSelection,e.enableRangeSelection||this.dr()),R(e,t,["tooltipComponent"],!0);let r=E(e.tooltipShowDelay,0);r!==void 0&&(t.tooltipShowDelay=r),R(e,t,["flashCells"]),R(e,t,["getContextMenuItems"],!0),O(e,t,"theme")&&(this.e.o.Ol(t.theme),this.e.xn.refresh())}ep(e){if(!x(e,"pagination"))return;let t=this.e.r,r=e.pagination,i=r!==!1&&t.datasource==null;i!==t.paginationEnabled&&this.e.i.Va(i),typeof r=="object"&&r&&this.cp(r),t.paginationEnabled&&this.e.i.zc(),this.e.gr.De()}cp(e){let t=this.e.r;t.paginationMode=e.mode==="server"?"server":"client";let r=E(e.page,1,!0),i=E(e.total,0,!0);r!==void 0&&(t.paginationPage=r),i!==void 0&&(t.paginationTotal=i),e.pageSize!=null&&(t.paginationPageSize=e.pageSize),e.pageSizeOptions!=null&&(t.paginationPageSizeOptions=e.pageSizeOptions),e.showTotal!=null&&(t.paginationShowTotal=e.showTotal),e.showPageSizeSelector!=null&&(t.paginationShowSizeSelector=e.showPageSizeSelector)}tp(e,t){x(e,"rowStyleRules")&&(this.e.r.rowStyleRules=Array.isArray(e.rowStyleRules)?e.rowStyleRules:[],t.cells=!0,this.e.U({pinned:!0})),this.up(e,t),this.hp(e,t);let r=this.e.r;O(e,r,"stripedRows")&&this.e.o.Ah(r.stripedRows),O(e,r,"showCellBorders")&&this.e.o.kh(r.showCellBorders)}up(e,t){let r=this.e.r;e.watermark!==void 0&&(Object.assign(r,br(e)),this.e.xn.refresh()),this.pp(e),x(e,"summaryMethod")&&(r.summaryMethod=e.summaryMethod,t.summary=!0)}pp(e){let t=this.e.r;R(e,t,["suppressClipboard","contextMenu","columnMenu","fillHandle"]),e.statusBar!==void 0&&(t.statusBarEnabled=e.statusBar===!0||typeof e.statusBar=="object"&&e.statusBar!=null,typeof e.statusBar=="object"&&e.statusBar?.panels&&(t.statusBarPanels=e.statusBar.panels),this.e.st.De())}hp(e,t){let{size:r}=e;if(r==null||!x(Ie,r)||r===this.e.r.size)return;let i=Ie[r];this.e.r.size=r,this.e.r.rowHeight=e.rowHeight??i.rowHeight,this.e.r.headerHeight=e.headerHeight??i.headerHeight,this.e.o.Mh(r),t.layout=!0,t.header=!0}rp(e,t){let r=this.e.r;R(e,r,["suppressCellFocus","suppressRowHoverHighlight","suppressNoRowsOverlay"]),O(e,r,"suppressHeaderFocus")&&(t.header=!0),this.fp(e),this.mp(e)}fp(e){let t=this.e.r,r=!1;for(let i of["ariaLabel","ariaLabelledBy","ariaDescribedBy"])x(e,i)&&(t[i]=e[i]??Ae[i],r=!0);r&&this.e.o.Ll(t)}mp(e){let t=this.e.r;for(let r of["overlayNoRowsTemplate","overlayLoadingTemplate","overlayErrorTemplate"])x(e,r)&&(t[r]=e[r]??Ae[r]);R(e,t,["allowUnsafeOverlayHtml"]),x(e,"className")&&(t.className=e.className??"",this.e.o.Gl(t.className)),R(e,t,["loading"]),x(e,"error")&&(t.error=e.error??null)}ip(e,t){this.gp(e,t),this.yp(e,t);let r=this.e.r;R(e,r,["autoCheckedChildren"]),O(e,r,"defaultExpandAll")&&(t.needsRowRebuild=!0),e.applyRowDrag!=null&&(r.applyRowDrag=e.applyRowDrag,t.cells=!0),x(e,"rowDragPolicy")&&(r.rowDragPolicy=e.rowDragPolicy,t.cells=!0),R(e,r,["suppressWarnings"])}gp(e,t){let r=this.e.r;if(O(e,r,"rowSelection")&&(e.rowSelection==="none"&&this.e.h.deselectAll(),t.header=!0,t.pool=!0,this.e.En()),e.quickFilterText!==void 0&&this.xt(e.quickFilterText),e.defaultColDef!==void 0&&e.defaultColDef!==r.defaultColDef&&(r.defaultColDef={...yr,...e.defaultColDef},t.needsColumnRebuild=!0),x(e,"columnTypes")&&e.columnTypes!==r.columnTypes&&(r.columnTypes=e.columnTypes??{},t.needsColumnRebuild=!0),x(e,"rowKey")){r.rowKey=e.rowKey;let i=e.rowKey;r.resolveRowId=i?({data:o})=>vr(i,o):void 0,t.needsRowRebuild=!0}}yp(e,t){let r=this.e.r;O(e,r,"masterDetail")&&(t.needsColumnRebuild=!0,t.needsRowRebuild=!0),O(e,r,"detailToggleColumn")&&(t.needsColumnRebuild=!0),O(e,r,"treeData")&&(t.needsRowRebuild=!0,t.needsColumnRebuild=!0,this.e.En()),O(e,r,"childrenKey")&&(t.needsRowRebuild=!0),R(e,r,["isTreeRowExpandable","loadTreeChildren"],!0)&&(t.cells=!0)}np(e,t){let r=this.e.r;R(e,r,["aggFuncs"],!0)&&(t.needsRowRebuild=!0),R(e,r,["components","actionPolicy"],!0)&&(t.cells=!0),x(e,"features")&&(r.features=Array.isArray(e.features)?e.features:[],t.needsFeatureReload=!0),this.vp(e,t),this.bp(e,t)}vp(e,t){let r=this.e.r;x(e,"dataProcessor")&&this.e.jl(e.dataProcessor)&&(t.needsRowRebuild=!0);let i=E(e.dataProcessorMinRows,1,!0);i!==void 0&&i!==r.dataProcessorMinRows&&(r.dataProcessorMinRows=i,t.needsRowRebuild=!0)}bp(e,t){let r=this.e.r;x(e,"persistence")&&(r.persistence=$e(e.persistence),t.needsStateLoad=!0)}op(e,t){let r=this.e.r;wr(e,r)&&r.datasourceMode==="block"&&(t.datasourceChanged=!0),this.wp(e,t),this.Cp(e,t),this.Tp(e)}wp(e,t){let r=this.e.r;if(x(e,"datasourceMode")){let i=e.datasourceMode==="block"?"block":"sequential";i!==r.datasourceMode&&(r.datasourceMode=i,t.datasourceChanged=!0)}if(x(e,"datasourceRowCount")){let i=e.datasourceRowCount==null?null:E(e.datasourceRowCount,0,!0)??null;i!==r.datasourceRowCount&&(r.datasourceRowCount=i,t.datasourceChanged=!0)}}Cp(e,t){let r=this.e.r;x(e,"datasource")&&e.datasource!==r.datasource&&(r.datasource=e.datasource,r.paginationEnabled=e.datasource==null&&r.paginationEnabled,t.datasourceChanged=!0,this.e.gr.De()),R(e,r,["detailRowRenderer","isRowExpandable"],!0)&&(t.cells=!0)}Tp(e){e.pinnedTopRowData!==void 0&&this.setPinnedRows("top",e.pinnedTopRowData),e.pinnedBottomRowData!==void 0&&this.setPinnedRows("bottom",e.pinnedBottomRowData)}sp(e,t,r){let i=this.e.r;t.needsColumnRebuild?this.Dp(e,t):x(e,"advancedFilterModel")&&(t.filterChanged=this.e.i.it(e.advancedFilterModel)),t.needsFeatureReload&&this.e.ql(i.features),this.xp(t),t.filterChanged&&this.e.fs(!t.needsColumnRebuild),t.layout&&this.e.o.Sh(i.rowHeight,i.headerHeight),e.columnMenu!=null&&e.columnMenu!==r&&(t.header=!0),t.stateToApply&&this._l(t.stateToApply),t.pool&&(t.cells=void 0),t.overlays=!0,this.e.U(t)}Dp(e,t){t.columnDefsChanged&&!t.needsRowRebuild&&(this.e.ze(),this.e.l.stop(!0));let r=this.e.n.Sr(this.e.r.columnDefs);t.filterChanged=this.e.i.Lc(x(e,"advancedFilterModel")?e.advancedFilterModel??null:void 0),r&&this.e.emit("sortChanged",{sortModel:this.e.n.re()},!1),this.e.Ft(),t.header=!1,t.pool=!1}xp(e){let t=e.needsStateLoad||e.needsColumnRebuild,r=e.datasourceChanged||e.needsRowRebuild||e.columnDefsChanged||e.filterChanged,i=this.e.r.persistence?.sections,o=r&&(this.e.i.m||i?.length===1&&i[0]==="columns");t&&o&&this.e.ms(!e.needsStateLoad,!0),this.Ep(e,r),t&&!o&&this.e.ms(!e.needsStateLoad)}Ep(e,t){if(e.datasourceChanged){this.e.i.Tc();return}t&&(!this.e.i.m&&e.needsRowRebuild?this.rt(this.e.r.rowData):this.e.i.To())}qh(e={}){let t=this.zl({...e,target:"csv",protectFormulas:!1});return sn(t,e)}zl(e={}){let t=this.e.n.d().filter(j),r=e.includeHeader===!1?[]:[t.map(o=>o.colDef.headerName??o.colDef.field??o.id)];if(e.headersOnly)return r;let i=e.onlySelected?this.e.h.St().slice().sort((o,s)=>o.rowIndex-s.rowIndex):e.onlyAllDisplayed?this.e.i.Et():this.e.i.Fa();return[...r,...i.filter(o=>!o.isDetail&&!o.isGroup).map(o=>t.map(s=>{let a=Ve(this.e,o,s,e.target??"xlsx");return e.protectFormulas===!1?a:ae(a)}))]}getState(){return{version:2,columns:this.e.n.la(!1),sortModel:this.e.n.re(),filterModel:this.e.i._e(),advancedFilterModel:this.e.i.Fr(),quickFilterText:this.e.i.La(),pagination:{enabled:this.e.i.be,page:this.e.i.rr(),pageSize:this.e.r.paginationPageSize},selectedRowIds:this.e.h.$a(),expandedRowIds:this.e.i.qc(),expandedGroupIds:this.e.i.Yc()}}_l(e,t={}){if(this.e.s())return;let r=$(e);if(!r){this.e.reportError(new TypeError("[MachTable] GridState must use the current version 2 schema."),"gridState.apply");return}let i=["columns","sort","filter","pagination","selection","expansion"],o=new Set(t.sections??i);this.e.l.stop(!0),this.Rp(r,o),this.Sp(r,o),t.emitEvents!==!1&&this.Mp(o),o.has("columns")&&this.e.fr()}Rp(e,t){t.has("columns")&&this.e.n.da(e.columns??[]),t.has("sort")&&this.e.n.Ir(e.sortModel??[]),t.has("filter")&&(this.e.i.Dt(e.filterModel??{}),this.e.i.it(e.advancedFilterModel),this.e.i.xt(e.quickFilterText)),t.has("expansion")&&this.e.i.Xc(e.expandedRowIds??[],e.expandedGroupIds??[]),t.has("pagination")&&e.pagination&&(this.e.r.paginationEnabled=e.pagination.enabled&&!this.e.i.m,this.e.i.Ha(e.pagination.page,e.pagination.pageSize),this.e.gr.De())}Sp(e,t){t.has("columns")&&this.e.Ft(),this.e.Ip()||(this.e.i.m?(t.has("sort")||t.has("filter"))&&this.e.i.Ea():this.e.i.M()),this.e.$.gs(),this.e.$.ys(),t.has("selection")&&this.e.h.nu(e.selectedRowIds??[])}Mp(e){e.has("sort")&&this.e.emit("sortChanged",{sortModel:this.e.n.re()}),e.has("filter")&&this.e.fs(),e.has("pagination")&&this.e.i.$r(this.e.r.paginationPageSize)}destroy(){let e=this.Kl();for(let t of e)t.signal&&t.onAbort&&t.signal.removeEventListener("abort",t.onAbort),t.aborted||t.resolve();this.e.destroy()}},ba={rows:In,columns:An,selection:kn,editing:Pn,filtering:Nn,sorting:On,pagination:Fn,hierarchy:Hn,view:Vn,state:Gn,io:Bn,diagnostics:Ln};function zn(n){let e=new qr(n),t={};for(let[r,i]of Object.entries(ba)){let o;Object.defineProperty(t,r,{enumerable:!0,get:()=>o??(o=Object.freeze(i(e,n)))})}return Object.assign(t,{batch:r=>e.batch(r),whenReady:()=>n.whenReady(),getOption:r=>e.getOption(r),updateOptions:r=>e.updateOptions(r),on:(r,i)=>n.ce.on(r,i),destroy:()=>e.destroy(),isDestroyed:()=>n.s()}),gn(t,n),fn(t,{suspend:()=>n.suspend(),resume:()=>t.view.refreshLayout(),canReplaceData:()=>!n.l.isEditing()&&n.K.getDirtyRowIds().length===0,readCell:(r,i)=>{let o=n.i.X(r),s=n.n.S(i);return o&&s?Or(Ve(n,o,s,"clipboard")):""},writeInput:r=>n.mr(r.flatMap(({rowId:i,colId:o,value:s})=>{let a=n.i.X(i),l=n.n.S(o);return a&&l?[{node:a,column:l,oldValue:n.c(a,l),newValue:s}]:[]}))}),Object.freeze(t)}var wa={contains:"\u5305\u542B",notContains:"\u4E0D\u5305\u542B",equals:"=",notEquals:"\u2260",startsWith:"\u5F00\u5934",endsWith:"\u7ED3\u5C3E",blank:"\u4E3A\u7A7A",notBlank:"\u975E\u7A7A",lessThan:"<",lessThanOrEqual:"\u2264",greaterThan:">",greaterThanOrEqual:"\u2265",inRange:"\u8303\u56F4"};function $t(n){if(!n)return"";if(n.type==="set")return`\u5DF2\u9009 ${n.values.length} \u9879`;let e=[];for(let r of n.conditions){let i=wa[r.match]??r.match,o=r.value,s="value2"in r?r.value2:void 0;r.match==="blank"||r.match==="notBlank"?e.push(i):r.match==="inRange"&&o!=null?e.push(`${i} ${o}~${s??o}`):o!=null&&String(o)!==""?e.push(`${i} ${o}`):e.push(i)}let t=n.operator==="or"?" \u6216 ":" \u4E14 ";return e.join(t)}function Yr(n,e,t=!1){let r=0,i=n.length;for(;r<i;){let o=r+i>>1;n[o]<e||t&&n[o]===e?r=o+1:i=o}return r}var Te=class{constructor(){this.ue=new Float64Array(1)}update(e){let t=0,r=this.ue.length!==e.length+1;for(let o=0;o<e.length;o++)t+=e[o].currentWidth,!r&&this.ue[o+1]!==t&&(r=!0);if(!r)return!1;let i=new Float64Array(e.length+1);for(let o=0;o<e.length;o++)i[o+1]=i[o]+e[o].currentWidth;return this.ue=i,!0}Yl(){return this.ue[this.ue.length-1]??0}Vt(e){let t=Math.max(0,Math.min(Math.trunc(e),this.ue.length-1));return this.ue[t]??0}Ap(e){let t=Math.max(0,this.ue.length-1);return t===0?-1:Math.min(t-1,Math.max(0,Yr(this.ue,Math.max(0,e),!0)-1))}Xl(e,t,r=2){let i=Math.max(0,this.ue.length-1);if(i===0||t<=0||this.Yl()<=t)return{first:0,lastExcl:i};let o=Math.max(0,e),s=o+t,a=Math.max(0,Yr(this.ue,o,!0)-1),l=Math.min(i,Yr(this.ue,s));return{first:Math.max(0,a-r),lastExcl:Math.min(i,l+r)}}Rn(e,t,r){let i=t.indexOf(r);if(i<0)return;this.update(t);let o=this.Vt(i),s=o+r.currentWidth;o<e.scrollLeft?e.scrollLeft=o:s>e.scrollLeft+e.clientWidth&&(e.scrollLeft=s-e.clientWidth)}};var Ca=".mach-header-resize, .mach-filter-btn, .mach-menu-btn, .mach-select-all";function Xr(n){return n instanceof HTMLElement&&n.closest(Ca)!=null}function Jr(n){return n==="ArrowLeft"||n==="ArrowRight"}function Wn(n,e){typeof e=="string"?n.classList.add(e):Array.isArray(e)&&n.classList.add(...e)}var Kt=class{constructor(e){this.e=e;this.xe=[];this.vs=[];this.O=new Te;this.Bt=0;this.Sn=Number.MAX_SAFE_INTEGER}ui(){this.Jl(),this.e.pi.kt(),this.yr(!1);let e=this.e.n,t=e.lc();this.e.o.Nl(t);let r=new Set(e.C("center").slice(this.Bt,this.Sn)),i=(l,d,c)=>{let u=[];for(let h of l)if(h instanceof Q){let p=i(h.children,d+1,c);p.length>0&&u.push({group:h,level:d,children:p})}else!h.hide&&e.He(h)===c&&(c!=="center"||r.has(h))&&u.push({column:h,level:d,children:[]});return u},o=e.ac(),s=b.map(l=>i(o,0,l)),a=this.e.r.headerHeight;b.forEach((l,d)=>{let c=this.e.o.si[l];for(let h of c)h.textContent="";let u=h=>{let p=c[Math.min(h.level,c.length-1)];if(h.column){let m=this.kp(h.column,t-h.level,a);p.appendChild(m.el),this.xe.push(m)}else if(h.group){let m=this.Pp(h.group);p.appendChild(m),this.vs.push({group:h.group,el:m})}for(let m of h.children)u(m)};for(let h of s[d])u(h)}),this.e.r.suppressHeaderFocus||this.xe.forEach((l,d)=>{l.el.tabIndex=d===0?0:-1}),this.ut(),this.gs(),this.ys(),this.$i()}Zl(){let e=this.Bt,t=this.Sn;this.Jl(),(e!==this.Bt||t!==this.Sn)&&this.ui()}Jl(){let e=this.e.n.C("center"),t=this.e.o.T.center;this.O.update(e);let r=e.length>20?this.O.Xl(t.scrollLeft,t.clientWidth,2):{first:0,lastExcl:e.length};this.Bt=r.first,this.Sn=r.lastExcl}kp(e,t,r){let i=f("div","mach-header-cell mach-header-cell--leaf");e.hasCheckbox&&i.classList.add("mach-header-cell--selection"),i.dataset.colId=e.id,i.setAttribute("role","columnheader"),i.style.height=`${t*r}px`,this.Gp(i,e),this.Lp(i,e);let o=this.Np(i,e);this.Op(i,e);let s=f("span","mach-sort-indicator");i.appendChild(s);let{filterBtn:a,filterTagEl:l}=this.Fp(i,e);return this.Hp(i,e),this.Vp(i,e),this.Bp(i,e),{column:e,el:i,sortEl:s,filterBtn:a,filterTagEl:l,selectAllEl:o}}Gp(e,t){let r=t.colDef;Wn(e,r.headerClass),r.headerTooltip&&e.setAttribute("title",r.headerTooltip);let i=r.headerAlign??r.align;i==="center"?e.classList.add("mach-header-cell--center"):i==="right"&&e.classList.add("mach-header-cell--right")}Lp(e,t){this.e.r.suppressHeaderFocus||(e.tabIndex=-1,e.addEventListener("mousedown",()=>this.bs(t)),e.addEventListener("keydown",r=>this._p(r,t)))}Np(e,t){if(!t.hasCheckbox||this.e.r.rowSelection!=="multiple")return;let r=document.createElement("input");return r.type="checkbox",r.className="mach-select-all",r.setAttribute("aria-label","select all rows"),r.addEventListener("click",i=>i.stopPropagation()),r.addEventListener("change",()=>{r.checked?this.e.h.selectAll(!0):this.e.h.deselectAll()}),e.appendChild(r),r}Op(e,t){let r=t.colDef,i=r.headerComponent,o;if(!i){this.ws(e,r.headerName??r.field??t.id);return}try{o=i({colDef:r,column:t,api:this.e.api})}catch(s){this.e.reportError(s,"headerComponent",{colId:t.id}),o=null}this.zp(e,t,o)}zp(e,t,r){if(typeof r=="string"){this.ws(e,r);return}if(r instanceof HTMLElement){this.Ql(e,r);return}if(r&&typeof r=="object"&&r.el instanceof HTMLElement){this.Ql(e,r.el),Ue(e,r.destroy);return}let i=t.colDef;this.ws(e,i.headerName??i.field??t.id)}ws(e,t){let r=f("span","mach-header-label");r.textContent=t,e.appendChild(r)}Ql(e,t){let r=f("span","mach-header-label mach-header-label--custom");r.appendChild(t),e.appendChild(r)}Fp(e,t){if(!t.filterable)return{};let r=document.createElement("button");r.type="button",r.className="mach-filter-btn",r.setAttribute("aria-label",`filter ${t.id}`),r.innerHTML=hi,r.addEventListener("click",o=>{o.stopPropagation(),this.e.Cs.toggle(t,r)}),e.appendChild(r);let i=f("span","mach-filter-tag");return e.appendChild(i),{filterBtn:r,filterTagEl:i}}Hp(e,t){if(!this.e.r.columnMenu||t.hasCheckbox||t.colDef.suppressColumnMenu)return;let r=document.createElement("button");r.type="button",r.className="mach-menu-btn";let o=`${t.colDef.headerName??t.colDef.field??t.id} \xB7 ${this.e.y("columnSettings")}`;r.setAttribute("aria-label",o),r.title=o,r.innerHTML=mi,r.addEventListener("click",s=>{s.stopPropagation(),this.e.columnMenu.toggle(t,r)}),e.appendChild(r)}Vp(e,t){if(!this.ed(t))return;let r=f("div","mach-header-resize");r.setAttribute("aria-hidden","true"),r.addEventListener("pointerdown",i=>{i.button===0&&(i.preventDefault(),i.stopPropagation(),this.e.pi.gu(i,t))}),r.addEventListener("dblclick",i=>{i.stopPropagation(),this.e.api.columns.autoSize(t.id)}),r.addEventListener("click",i=>i.stopPropagation()),e.appendChild(r)}Bp(e,t){e.addEventListener("click",r=>{this.e.Mn.Tu()||Xr(r.target)||t.sortable&&this.e.ki(t,r.shiftKey)}),e.addEventListener("pointerdown",r=>{r.button!==0||Xr(r.target)||this.e.Mn.Cu(r,t)})}Pp(e){let t=f("div","mach-header-cell mach-header-cell--group");e.groupId&&(t.dataset.groupId=e.groupId),t.setAttribute("role","columnheader"),Wn(t,e.def.headerClass);let r=f("span","mach-header-label mach-header-label--group");return r.textContent=e.headerName,t.appendChild(r),t}ut(){let e={left:0,center:0,right:0};for(let t of b){let r=this.e.o.si[t],i=0,o=new Map;for(let a of this.e.n.C(t))o.set(a.id,i),i+=a.currentWidth;let s=this.e.r.headerHeight;for(let a of this.xe){if(this.e.n.He(a.column)!==t)continue;let l=o.get(a.column.id)??0;a.el.style.width=`${a.column.currentWidth}px`,a.el.style.left=`${l}px`,a.el.setAttribute("aria-colindex",String(this.e.n.Fe(a.column.id)+1))}for(let a of this.vs){let l=this.Wp(a.group,t);if(l.length===0)continue;let d=o.get(l[0].id)??0,c=0;for(let u of l)c+=u.currentWidth;a.el.style.left=`${d}px`,a.el.style.width=`${c}px`,a.el.style.height=`${s}px`,a.el.setAttribute("aria-colspan",String(l.length))}for(let a of r)a.style.width=`${i}px`;e[t]=i}this.e.o.Rh(e.left,e.right)}Wp(e,t){return e.getLeafColumns().filter(r=>!r.hide&&this.e.n.He(r)===t)}_p(e,t){this.e.s()||this.$p(e,t)||this.Kp(e,t)||this.Up(e,t)||this.jp(e,t)||this.qp(e)}$p(e,t){return e.key!=="Enter"&&e.key!==" "?!1:(Xr(e.target)||(e.preventDefault(),t.sortable&&this.e.ki(t,e.shiftKey)),!0)}Kp(e,t){if(!e.altKey||!Jr(e.key))return!1;if(!this.ed(t))return!0;let r=e.key==="ArrowRight"?24:-24;return this.e.n.Ee(t,t.currentWidth+r),this.e.nr(),this.e.ot([t]),e.preventDefault(),!0}Up(e,t){if(!e.ctrlKey||!Jr(e.key))return!1;if(!t.movable)return!0;e.preventDefault();let r=this.e.n.He(t),i=this.e.n.C(r),o=i.indexOf(t),s=e.key==="ArrowRight"?1:-1,a=Math.max(0,Math.min(i.length-1,o+s));return a!==o&&this.e.Mr(t.id,a),!0}jp(e,t){if(e.altKey||e.ctrlKey||e.metaKey||!Jr(e.key))return!1;e.preventDefault();let r=this.e.n.d(),i=r.indexOf(t);if(i<0)return!0;let o=e.key==="ArrowRight"?1:-1,s=Math.max(0,Math.min(r.length-1,i+o));return this.bs(r[s]),!0}qp(e){if(e.key!=="Home"&&e.key!=="End")return!1;e.preventDefault();let t=this.e.n.d();if(t.length===0)return!0;let r=e.key==="Home"?0:t.length-1;return this.bs(t[r]),!0}bs(e){let t=this.xe.find(r=>r.column.id===e.id);if(!t&&!e.pinned&&(this.Rn(e),this.Zl(),t=this.xe.find(r=>r.column.id===e.id)),!!t){for(let r of this.xe)r.el.tabIndex=r===t?0:-1;t.el.focus({preventScroll:!0})}}Rn(e){this.O.Rn(this.e.o.T.center,this.e.n.C("center"),e)}ed(e){return this.e.r.enableColumnResize&&e.resizable}gs(){let e=this.e.n.re(),t=e.length>1;for(let r of this.xe){let i=e.findIndex(o=>o.colId===r.column.id);if(i>=0){let o=e[i].direction,s=t?`<span class="mach-sort-badge">${i+1}</span>`:"";r.sortEl.innerHTML=(o==="asc"?pi:fi)+s,r.el.setAttribute("aria-sort",o==="asc"?"ascending":"descending"),r.el.classList.add("mach-header-cell--sorted")}else r.sortEl.innerHTML="",r.el.removeAttribute("aria-sort"),r.el.classList.remove("mach-header-cell--sorted")}}ys(){let e=this.e.i._e();for(let t of this.xe){if(!t.filterBtn)continue;let r=e[t.column.id],i=r!=null;if(t.filterBtn.classList.toggle("mach-filter-btn--active",i),t.filterTagEl){let o=i?$t(r):"";t.filterTagEl.style.display=o?"":"none",o&&(t.filterTagEl.textContent=o)}}}$i(){for(let e of this.xe){if(!e.selectAllEl)continue;let{all:t,some:r}=this.e.h.cu();e.selectAllEl.checked=t,e.selectAllEl.indeterminate=r}}destroy(){this.yr(!0)}yr(e){for(let t of this.xe){let r=je(t.el);if(r)try{r()}catch(i){e?console.error("[mach-table] headerComponent destroy error",i):this.e.reportError(i,"headerComponent.destroy",{colId:t.column.id})}}this.xe=[],this.vs=[]}};var Ut=class{constructor(){this.he=null;this.je=null;this.vr=!1;this.Ts=-1;this.Ds=-1}Yp(){return this.he}xs(){return this.je}Xp(){return this.he!=null}start(e,t){(!t||!this.he)&&(this.he={...e}),this.je={...e},this.Qt()}Jp(e){return this.he?!0:e.colIdx<0?!1:(this.he={...e},this.Qt(),!0)}setEnd(e){this.je={...e},this.Qt()}clear(){this.he=null,this.je=null,this.Qt()}Qt(){this.vr=!1,this.Ts=-1,this.Ds=-1}normalize(e,t){return this.vr!==!1&&this.Ts===e&&this.Ds===t?this.vr:(this.Ts=e,this.Ds=t,!this.he||!this.je||e<=0||t<=0?(this.vr=null,null):(this.vr={r1:Math.max(0,Math.min(this.he.row,this.je.row,e-1)),r2:Math.max(0,Math.min(Math.max(this.he.row,this.je.row),e-1)),c1:Math.max(0,Math.min(this.he.colIdx,this.je.colIdx,t-1)),c2:Math.max(0,Math.min(Math.max(this.he.colIdx,this.je.colIdx),t-1))},this.vr))}};var jt=class{constructor(e){this.host=e;this.Ge=null;this.ae=0;this.In=0;this.Ur=e=>{let t=this.Ge;if(!(!t||e.pointerId!==t.pointerId)){if(t.clientX=e.clientX,t.clientY=e.clientY,!t.active){if(Math.abs(e.clientY-t.startY)<5)return;t.active=!0,this.host.root.classList.add("mach-root--row-dragging"),this.host.root.querySelectorAll(".mach-row").forEach(r=>r.classList.toggle("mach-row--drag-source",this.sourceContains(r.dataset.id??"")))}this.td()}};this.tf=()=>{if(this.ae=0,!!this.Ge?.active){if(!this.current()){this.destroy();return}this.jr(),this.rf()&&this.td()}};this.or=e=>{let t=this.Ge;if(!(!t||e.pointerId!==t.pointerId)){t.clientX=e.clientX,t.clientY=e.clientY,t.active&&this.current()&&this.jr(),this.rd();try{t.active&&t.drop?.valid&&this.Es(e.clientX,e.clientY)&&this.current()&&this.commitDrop(t.drop)}finally{this.release()}}};this.Zp=e=>{e.key==="Escape"&&(e.preventDefault(),this.destroy())};this.Yi=e=>{e.type==="pointercancel"&&e.pointerId!==this.Ge?.pointerId||this.destroy()}}begin(e){let t=this.host.containers.map(i=>{let o=f("div","mach-row-drop-indicator");return o.hidden=!0,i.append(o),o}),r=f("div","mach-row-drag-preview");r.setAttribute("role","status"),r.hidden=!0,this.host.root.append(r),this.Ge={startY:e.clientY,clientX:e.clientX,clientY:e.clientY,pointerId:e.pointerId,indicators:t,preview:r,drop:null,active:!1},this.Yr(!0)}Yr(e){L(window,e,{pointermove:this.Ur,pointerup:this.or,pointercancel:this.Yi,keydown:this.Zp,blur:this.Yi})}Qp(e){return this.Ge?.active===!0&&this.sourceContains(e)}ef(e,t=()=>!0){this.In=requestAnimationFrame(()=>{this.In=0,t()&&[...this.host.root.querySelectorAll(".mach-row-drag-handle")].find(r=>r.closest(".mach-row")?.dataset.id===e)?.focus()})}td(){this.ae||(this.ae=requestAnimationFrame(this.tf))}Es(e,t,r=0){let i=this.host.body.getBoundingClientRect();return e>=i.left&&e<=i.right&&t>=i.top-r&&t<=i.bottom+r}rf(){let e=this.Ge;if(!e||!this.Es(e.clientX,e.clientY,28))return!1;let t=this.host.viewport,r=t.getBoundingClientRect(),i=Math.min(36,r.height/3);if(i<=0)return!1;let o=e.clientY<r.top+i?-Math.ceil(14*C((r.top+i-e.clientY)/i,0,1)):Math.ceil(14*C((e.clientY-r.bottom+i)/i,0,1));if(this.host.scrollBy)return this.host.scrollBy(o);let s=t.scrollTop;return t.scrollTop=C(s+o,0,Math.max(0,t.scrollHeight-t.clientHeight)),t.scrollTop!==s}jr(){let e=this.Ge;if(!e?.active)return;let t=e.clientY-this.host.viewport.getBoundingClientRect().top+this.host.viewport.scrollTop,r=this.describe(t);e.drop=r;let i=this.Es(e.clientX,e.clientY);for(let s of e.indicators){if(s.hidden=!i||!r?.valid,!r)continue;s.dataset.dropPosition=r.position??"",s.style.cssText=r.style??"";let a=parseFloat(s.parentElement.style.height),l=Math.min(this.host.getRowTop(r.boundary),Number.isFinite(a)?Math.max(0,a-2):1/0);s.style.transform=`translate3d(0, ${l}px, 0)`}let o=this.host.root.getBoundingClientRect();e.preview.hidden=!1,e.preview.textContent=i?r?.text??this.outsideText():this.outsideText(),e.preview.style.transform=`translate3d(${C(e.clientX-o.left+16,8,Math.max(8,o.width-224))}px, ${C(e.clientY-o.top+16,8,Math.max(8,o.height-48))}px, 0)`}rd(){let e=this.Ge;this.Ge=null,this.Yr(!1),cancelAnimationFrame(this.ae),this.ae=0,this.host.root?.classList.remove("mach-root--row-dragging"),this.host.root?.querySelectorAll(".mach-row--drag-source").forEach(t=>t.classList.remove("mach-row--drag-source")),e?.indicators.forEach(t=>t.remove()),e?.preview.remove()}destroy(){this.rd(),this.release(),cancelAnimationFrame(this.In),this.In=0}};function $n(n,e,t,r,i){let o=r==="before"?-1:1,s=t.rowIndex+o,a=e(s);for(;a&&(a===n||a.isDetail);)s+=o,a=e(s);let l=a&&!a.loading?a.id:null;return{rowIds:[n.id],targetId:t.id,position:r,beforeId:r==="before"?l:t.id,afterId:r==="before"?t.id:l,expectedRevision:i}}var qt=class extends jt{constructor(t,r,i,o){super({get root(){return t.o.root},get body(){return t.o.ke},get viewport(){return t.o.T.center},get containers(){return Object.values(t.o.Te)},getRowTop:r,findRowAt:i,scrollBy:o});this.e=t;this._t=null}od(t){return!t.loading&&!t.treeLoading&&!t.isGroup}sd(t){if(this.e.l.isEditing()||t.isDetail||!this.od(t)||t.data==null||this.e.n.Xe().length||this.e.r.applyRowDrag&&!this.e.i._a())return!1;let r=this.br("canDrag",()=>this.e.r.rowDragPolicy?.canDrag?.({node:t,api:this.e.api})??!0,!1);return r!==!0?r:!this.e.i.G||!!zr(this.e.api)}canDrag(t){return this.sd(t)===!0}isSource(t){return this.Rs()?.isSource(t)??this.Qp(t.id)}start(t,r){if(this.destroy(),!this.canDrag(r)||t.isPrimary===!1)return;let i=this.Rs();if(i){i.start(t,r);return}let o=this.br("getRevision",()=>this.Ss(r),null);o&&(this._t={node:r,from:r.rowIndex,guard:o},this.begin(t))}moveWithKeyboard(t,r){if(!t.altKey||t.key!=="ArrowUp"&&t.key!=="ArrowDown"||(t.preventDefault(),t.stopPropagation(),!this.canDrag(r)))return;let i=this.Rs();if(i){i.moveWithKeyboard(t,r);return}let o=t.key==="ArrowUp"?-1:1,s=r.rowIndex+o;for(;this.e.i.f(s)?.isDetail;)s+=o;let a=this.e.i.f(s),l=this.br("getRevision",()=>this.Ss(r),null);if(!(!a||!l)){this._t={node:r,from:r.rowIndex,guard:l};try{this.commitDrop(this.destination(a,o>0))&&this.ef(r.id)}finally{this.release()}}}br(t,r,i){try{return r()}catch(o){return this.e.reportError(o,`rowDragPolicy.${t}`),i}}Ss(t){let r=this.e.i,i=this.e.n.te(),o=this.e.r.rowDragPolicy,s=r.Be(),a=r.Or(),l=this.e.r.applyRowDrag,d=o?.getRevision?.();return{revision:d,current:()=>this.br("getRevision",()=>o?.getRevision?.()===d&&s===r.Be()&&a===r.Or()&&r.X(t.id)===t&&i===this.e.n.te()&&o===this.e.r.rowDragPolicy&&l===this.e.r.applyRowDrag,!1)}}Rs(){let t=zr(this.e.api);return t!==this.nd&&(this.An?.destroy(),this.nd=t,this.An=t?this.br("driver",()=>t({...this.host,api:this.e.api,capture:r=>this.Ss(r),emit:(r,i,o,s,a)=>{this.e.emit("rowDragEnd",{rowNode:r,fromIndex:i,toIndex:o,targetIndex:s,applied:!1,intent:a})},report:(r,i)=>this.e.reportError(r,`rowDragPolicy.${i}`)}),void 0):void 0),this.An}current(){return this._t?.guard.current()??!1}release(){this._t=null}sourceContains(t){return this._t?.node.id===t}outsideText(){return this.e.r.locale.rowDragOutside??D.rowDragOutside}describe(t){let r=C(this.host.findRowAt(t),0,this.e.i.P()-1),i=this.e.i.f(r);if(i?.isDetail&&(i=this.e.i.X(i.masterId)),!i)return null;let o=this.host.getRowTop(i.rowIndex),s=this.host.getRowTop(i.rowIndex+1);return this.destination(i,t>=(o+s)/2)}destination(t,r){let i=this._t,o=t.rowIndex+Number(r);for(;this.e.i.f(o)?.isDetail;)o++;let s=this.e.r.rowDragPolicy,a=!this.e.r.applyRowDrag||s?.canDrop?$n(i.node,u=>this.e.i.f(u),t,r?"after":"before",i.guard.revision):void 0,l=s?.canDrop&&a?this.br("canDrop",()=>s.canDrop({node:i.node,api:this.e.api,targetNode:t,intent:a}),!1):!0,d=l===!0&&this.od(t),c=typeof l=="string"?l:ge(this.e.r.locale.rowDragPosition??D.rowDragPosition,i.from+1,this.ad(i.from,o)+1);return{node:t,intent:a,boundary:o,valid:d,text:c,position:r?"after":"before"}}commitDrop(t){let r=this._t;if(!r||!this.current()||!this.canDrag(r.node)||!this.current())return!1;let i=this.destination(t.node,t.boundary>t.node.rowIndex);if(!i.valid||!this.current())return!1;let o=i.boundary>r.from?i.boundary-1:i.boundary;for(;this.e.i.f(o)?.isDetail;)o--;if(r.from===o)return!1;let s=this.e.r.applyRowDrag&&this.e.i.za(r.from,o);return this.e.r.applyRowDrag&&!s?!1:(this.e.emit("rowDragEnd",{rowNode:r.node,fromIndex:r.from,toIndex:i.boundary,targetIndex:s?r.node.rowIndex:this.ad(r.from,i.boundary),applied:s,intent:i.intent}),!0)}ad(t,r){let i=t+1;for(;this.e.i.f(i)?.isDetail;)i++;return r>t?r-(i-t):r}destroy(){this.An?.destroy(),super.destroy()}};var Ta=new Set(["warning","danger","success","info"]);function _e(n,e,t=null){if(!(e.data==null||e.isGroup||e.isDetail||e.loading))for(let r of n.r.rowStyleRules)try{if(r.when({data:e.data,node:e,api:n.api,rowPinned:t})===!0)return r}catch(i){n.reportError(i,"rowStyleRules",{rowId:e.id})}}function De(n,e){n.style.removeProperty("--mach-row-rule-bg"),n.style.removeProperty("--mach-row-rule-fg"),e?.tone&&Ta.has(e.tone)?n.dataset.rowTone=e.tone:delete n.dataset.rowTone,e?.backgroundColor&&n.style.setProperty("--mach-row-rule-bg",e.backgroundColor),e?.color&&n.style.setProperty("--mach-row-rule-fg",e.color),n.classList.toggle("mach-row--styled",!!e)}var Yt=class{constructor(){this.se=new Float64Array(0);this.wr=new Float64Array(1);this.Ms=new WeakMap;this.zt=new Map;this.ht=0}reset(e,t){this.se=new Float64Array(e.length),this.wr=new Float64Array(e.length+1),this.Ms=new WeakMap,this.zt=new Map,this.ht=0;for(let r=0;r<e.length;r++){this.Ms.set(e[r],r);let i=Math.max(1,t(e[r],r));this.se[r]=i,this.Is(i,1),this.add(r,i)}}get length(){return this.se.length}indexOf(e){return this.Ms.get(e)??-1}update(e,t){if(e<0||e>=this.se.length)return!1;let r=Math.max(1,t),i=r-this.se[e];return Math.abs(i)<.01?!1:(this.Is(this.se[e],-1),this.se[e]=r,this.Is(r,1),this.add(e,i),!0)}Vt(e){let t=Math.max(0,Math.min(Math.trunc(e),this.se.length)),r=0;for(;t>0;)r+=this.wr[t],t-=t&-t;return r}As(){return this.Vt(this.se.length)}nf(){return this.ht}findIndex(e){if(this.se.length===0)return 0;let t=Math.max(0,e),r=0,i=0,o=1;for(;o<<1<=this.se.length;)o<<=1;for(;o>0;){let s=r+o;s<=this.se.length&&i+this.wr[s]<=t&&(r=s,i+=this.wr[s]),o>>=1}return Math.min(r,this.se.length-1)}add(e,t){for(let r=e+1;r<this.wr.length;r+=r&-r)this.wr[r]+=t}Is(e,t){let r=(this.zt.get(e)??0)+t;if(r<=0?this.zt.delete(e):this.zt.set(e,r),this.zt.size===0)this.ht=0;else if(t>0&&(this.ht===0||e<this.ht))this.ht=e;else if(t<0&&e===this.ht&&!this.zt.has(e)){let i=Number.POSITIVE_INFINITY;for(let o of this.zt.keys())i=Math.min(i,o);this.ht=Number.isFinite(i)?i:0}}};var Da=16e6,Xt=class{constructor(){this.height=0;this.Wt=0;this.Cr=0;this.kn=NaN;this.ks=0}configure(e,t,r=!0){this.height=r?Math.min(e,Da):e,this.Wt=Math.max(0,e-t),this.Cr=Math.max(0,this.height-t),this.kn=NaN}get pt(){return this.Wt>this.Cr}of(e){return this.Wt?C(e,0,this.Wt)*this.Cr/this.Wt:0}read(e){return e!==this.kn&&(this.kn=e,this.ks=this.Cr>0?C(e,0,this.Cr)*this.Wt/this.Cr:0),this.ks}anchor(e,t){this.ks=C(e,0,this.Wt),this.kn=t}};function Kn(n){return!!n&&!n.hasCheckbox&&!n.isDetailToggle&&!n.colDef.rowDrag}function xa(n){let e=n.length>1&&n.every(i=>typeof i=="number"&&!Number.isNaN(i)),t=e?(n[n.length-1]-n[0])/(n.length-1):0,r=!e||n.every(i=>Number.isInteger(i));return{difference:t,integer:r,numeric:e,values:n}}function Ea(n,e){let t=n.values.length;if(t===1)return n.values[0];if(!n.numeric)return n.values[e%t];let r=n.values[t-1]+n.difference*(e-t+1);return n.integer?Math.round(r):Math.round(r*1e6)/1e6}var Jt=class{constructor(e){this.e=e;this._=[];this.qe=0;this.ft=0;this.Ye=-1;this.oe=0;this.Ps=0;this.Gs=0;this.ld=0;this.R=new Xt;this.mt=0;this.Ls=!1;this.Pn=-1;this.j=new Yt;this.O=new Te;this.pe=new Ut;this.Gn=!1;this.fi=[];this.Bt=0;this.v=null;this.Os=()=>{this.oe||(this.oe=requestAnimationFrame(()=>{this.oe=0,this.Cn()}))};this.Hn=0;this.Vn=new WeakMap;this.Kt=new Set;this.Bn="";this.gt=!1;this.mi=[];this.Hs=null;this.Fs=e=>{if(e.defaultPrevented||e.ctrlKey||e.metaKey||e.shiftKey||!e.deltaY||!e.cancelable)return;let t=this.e.o.T.center,r=e.deltaMode===1?this.e.r.rowHeight:e.deltaMode===2?t.clientHeight:1,i=this.R.read(t.scrollTop);this._n(i+e.deltaY*r),this.R.read(t.scrollTop)!==i&&(e.preventDefault(),t.scrollLeft+=e.deltaX*r,this.Os())};this.On=null;this.yi=null;this.$s=!1;this.im=e=>{let t=this.yi;if(!t)return;let r=e;if(typeof r.clientX!="number")return;if(!t.active){let o=Math.abs(r.clientX-t.startX),s=Math.abs(r.clientY-t.startY);if(o<4&&s<4)return;t.active=!0,t.axis=o>=s?"h":"v",this.e.o.root.classList.add("mach-root--filling")}let i=t.axis!=="v";this.Gd(i,i?Math.max(t.c2+1,this.Pd(r)):this.kd(r),!0)};this.nm=e=>{let t=this.yi;if(!t)return;let r=e;if(!t.active){this.Nn();return}let i=t.axis==="h",o=i?t.c2:t.r2,s=o;i?s=Math.max(o+1,typeof r.clientX=="number"?this.Pd(r):o+1):typeof r.clientY=="number"&&(s=this.kd(r)),this.Nn(),s>o?(this.om(t,s,i),this.yt()):this.Gd(i,o,!1)};this.af=e=>{if(this.e.s())return;let t=e.target,r=this.qt(e);if(r&&!t.closest(".mach-cell-editor-shell, .mach-row-editor-shell, .mach-row-drag-handle")&&!(e.detail>1&&this.e.l.tn())){if(this.e.l.tn()){let i=r.cellEl?.dataset.colId??"";if(this.e.l.isEditing(r.index,i))return;this.e.l.le(!1).then(o=>{if(!o||this.e.s())return;this.Od(e,t,r);let s=i?this.e.n.S(i):void 0;s&&!this.e.l.tn()&&this.e.l.J(r.node,s)&&this.e.l.start(r.index,s)});return}this.Od(e,t,r)}};this.lf=e=>{if(this.e.s()||e.target.closest(".mach-cell-editor-shell, .mach-row-editor-shell"))return;let t=this.qt(e);if(!t)return;let{node:r,index:i,cellEl:o}=t;if(r.isDetail||r.isGroup||!o)return;let s=o.dataset.colId??"",a=this.e.n.S(s);if(!a)return;let l=this.e.c(r,a),d=this.e.emit("cellDoubleClicked",{event:e,rowNode:r,rowIndex:i,column:a,colDef:a.colDef,value:l});a.colDef.onCellDoubleClick?.(d),this.e.emit("rowDoubleClicked",{event:e,rowNode:r,rowIndex:i}),this.e.l.J(r,a)&&this.e.l.start(i,a)};this.df=e=>{if(this.e.s())return;let t=this.qt(e);if(!t||t.node.isDetail||t.node.isGroup||!t.cellEl)return;let{node:r,index:i,cellEl:o}=t,s=o.dataset.colId??"",a=this.e.n.S(s);if(a&&(this.e.emit("cellContextMenu",{event:e,rowNode:r,rowIndex:i,column:a,colDef:a.colDef,value:this.e.c(r,a)}),this.e.r.contextMenu)){if(e.preventDefault(),this.e.r.enableRangeSelection&&!this.we()){let l=this.e.n.Fe(s);l>=0&&this.Ws(i,l,!1)}this.e.Ks.open(e.clientX,e.clientY,{rowIndex:i,colId:s})}};this.cf=e=>{if(!this.mm(e)&&this.e.r.enableRangeSelection&&e.button===0){let t=this.qt(e);if(t&&!t.node.isDetail&&!t.node.isGroup&&t.cellEl&&!t.cellEl.classList.contains("mach-cell--selection")){let r=this.e.n.Fe(t.cellEl.dataset.colId??"");r>=0&&(this.Ws(t.index,r,e.shiftKey),this.Gn=!0,!e.shiftKey&&!this.e.r.suppressCellFocus&&this.Ae(t.index,t.cellEl.dataset.colId??""))}}};this.cd=()=>{this.Gn=!1};this.dn=e=>{if(this.e.s())return;let t=this.qt(e);if(this.Gn&&t&&!t.node.isDetail&&!t.node.isGroup&&t.cellEl){let r=this.e.n.Fe(t.cellEl.dataset.colId??""),i=this.pe.xs();r>=0&&i&&(i.row!==t.index||i.colIdx!==r)&&this.Ws(t.index,r,!0)}this.e.r.suppressRowHoverHighlight||!t||t.node.isDetail||this.Ld(t.index)};this.uf=()=>{this.Ld(-1)};this.hf=e=>{if(this.e.s()||e.button!==0||!e.target.closest(".mach-row-drag-handle"))return;let r=this.qt(e);!r||r.node.isDetail||r.node.isGroup||(this.$t.start(e,r.node),e.preventDefault())};this.pf=e=>{if(!e.target.closest(".mach-row-drag-handle"))return;let t=this.qt(e);t&&this.$t.moveWithKeyboard(e,t.node)};this.$t=new qt(e,t=>this.Le(t)-this.mt,t=>this.Ln(t+this.mt,this.e.i.P()),t=>this.sf(t))}init(){let e=this.e.o.T.center;this.Ps=e.scrollLeft,this.Gs=e.scrollTop,e.addEventListener("scroll",this.Os,{passive:!0}),this.dd(!0),window.addEventListener("mouseup",this.cd)}dd(e){L(this.e.o.ke,e,{click:this.af,dblclick:this.lf,contextmenu:this.df,mousedown:this.cf,mouseover:this.dn,mouseleave:this.uf,pointerdown:this.hf,keydown:this.pf})}suspend(){cancelAnimationFrame(this.oe),this.oe=0,this.Nn(),this.$t.destroy(),this.Gn=!1}destroy(){cancelAnimationFrame(this.oe);let e=this.e.o.T.center;e.removeEventListener("scroll",this.Os),e.removeEventListener("wheel",this.Fs),this.dd(!1),window.removeEventListener("mouseup",this.cd),this.Nn(),this.$t.destroy(),this.ud(!1),this.On?.remove(),this.mi=[],this.Kt.clear(),this.j.reset([],()=>this.e.r.rowHeight),this.O.update([]),this.Hs=null}Ao(e){return this.e.n.He(e)}Cn(e=!1){if(this.e.s())return;let t=this.e.o,r=t.T.center,i=r.scrollLeft,o=r.scrollTop,s=this.R.read(o),a=e||i!==this.Ps,l=e||o!==this.Gs||s!==this.ld;!a&&!l||(this.Ps=i,this.Gs=o,this.ld=s,a&&(t.ar.center.style.transform=`translate3d(${-i}px, 0, 0)`,this.e.$.Zl(),this.e.Pe.ff(i)),l&&this.hd(o),this.e.Fn.hide(),this.hi(!1,a),l&&this.e.i.Cc(this.Ye-1))}mf(){let e={left:0,center:0,right:0};for(let t of b)e[t]=this.e.n.C(t).reduce((r,i)=>r+i.currentWidth,0);return e}Tn(){let e=this.e.o,t=this.mf();this.O.update(this.e.n.C("center")),t.center=this.O.Yl();let r=this.e.i.Et(),i=this.gf(r.length);this.yf(r,i);let o=this.vf(i);this.bf(o),this.wf(t,o),e.root.setAttribute("aria-rowcount",String(i.rowCount+e.Hl()))}gf(e){let t=this.e.i.Nr(),r=this.e.r.rowHeight,i=this.e.r.masterDetail?[]:this.Cf(),o=this.e.r.datasourceMode!=="block"&&(this.e.r.masterDetail||this.e.r.getRowHeight!=null||i.length>0),s=o?this.Tf(r,i):`fixed|${r}`;return{autoHeightColumns:i,positionedCount:Math.min(t,e),rowCount:t,rowHeight:r,signature:s,variable:o}}Tf(e,t){let r=t.map(i=>`${i.id}:${i.currentWidth}`).join(",");return`${this.e.i.Or()}|${e}|${this.e.r.detailRowHeight}|${r}`}yf(e,t){if(!t.variable){this.Df(t);return}if(t.signature!==this.Bn||this.j.length!==t.positionedCount){let r=e.slice(0,t.positionedCount);this.j.reset(r,i=>this.pd(i,t.autoHeightColumns)),this.fd(t);return}if(this.Kt.size!==0){for(let r of this.Kt){let i=this.j.indexOf(r);i>=0&&this.j.update(i,this.pd(r,t.autoHeightColumns))}this.fd(t)}}Df(e){this.j.length>0&&this.j.reset([],()=>e.rowHeight),this.Bn=e.signature,this.Kt.clear(),this.Hn=e.rowHeight}fd(e){this.Bn=e.signature,this.Kt.clear(),this.Hn=this.j.nf()||e.rowHeight}vf(e){return(e.variable?this.j.As():e.positionedCount*e.rowHeight)+Math.max(0,e.rowCount-e.positionedCount)*e.rowHeight}wf(e,t){let r=this.e.o,i=r.T.center,o=this.R.read(i.scrollTop),s=this.R.pt;this.R.configure(t,i.clientHeight,!this.gt);let a=Math.max(0,i.clientWidth-e.left-e.right),l=Math.max(e.center,a);for(let d of b){let c=r.Te[d];c.style.height=`${this.R.height}px`,c.style.overflow=this.R.pt?"hidden":"",d==="center"&&(c.style.width=`${l}px`)}(s||this.R.pt)&&this._n(o),this.hd(i.scrollTop),this.Ls!==this.R.pt&&(this.Ls=this.R.pt,this.Ls?i.addEventListener("wheel",this.Fs,{passive:!1}):i.removeEventListener("wheel",this.Fs))}_n(e){let t=this.e.o.T.center;t.scrollTop=this.R.of(e),this.R.anchor(e,t.scrollTop)}hd(e){let t=this.R.pt;for(let r of["left","right"]){let i=this.e.o.Te[r].style;i.top=t?`${-e}px`:"",i.transform=t?"":`translate3d(0, ${-e}px, 0)`}}sf(e){let t=this.e.o.T.center,r=this.R.read(t.scrollTop);this._n(r+e);let i=this.R.read(t.scrollTop)!==r;return i&&this.Cn(),i}Ui(e){this.Vn.delete(e),this.Kt.add(e)}bf(e){let{ke:t,T:r}=this.e.o,{domLayout:i,maxBodyHeight:o}=this.e.r,s=i==="autoHeight",a=Math.min(e,o??e);this.gt=s&&a===e,t.style.height=s?`${a}px`:"",r.center.style.overflowY=s&&!this.gt?"auto":"",this.gt&&r.center.scrollTop&&(r.center.scrollTop=0)}Dn(){this.Vn=new WeakMap,this.Kt.clear(),this.Bn=""}pd(e,t){if(e.isDetail)return this.e.r.detailRowHeight;let r=this.Vn.get(e);if(r!==void 0)return r;let i=this.e.r.rowHeight,o=this.e.r.getRowHeight;if(o)try{let s=o({data:e.data,node:e,api:this.e.api});i=Number.isFinite(s)?Math.max(1,s||i):i}catch(s){this.e.reportError(s,"getRowHeight",{rowId:e.id})}return t.length>0&&(i=Math.max(i,this.xf(e,t))),this.Vn.set(e,i),i}Le(e){let t=this.j.length;return t===0?Math.max(0,e)*this.e.r.rowHeight:e<=t?this.j.Vt(e):this.j.As()+(e-t)*this.e.r.rowHeight}Ln(e,t){if(t<=0)return 0;let r=this.j.length,i=this.j.As();if(r>0&&e<i)return this.j.findIndex(e);let o=r+Math.floor(Math.max(0,e-i)/this.e.r.rowHeight);return Math.max(0,Math.min(o,t-1))}Cf(){return this.e.n.d().filter(e=>e.colDef.autoHeight===!0)}get Ef(){return this.e.n.d().some(e=>e.colDef.autoHeight===!0)}xf(e,t){var d;this[d="Hs"]??(this[d]=document.createElement("canvas"));let r=this.Hs.getContext("2d");if(!r)return 0;let i=window.getComputedStyle(this.e.o.root),o=parseFloat(i.fontSize)||13;r.font=`${i.fontStyle} ${i.fontWeight} ${o}px ${i.fontFamily}`;let s=parseFloat(i.getPropertyValue("--mach-cell-padding"))||9,a=Math.round(o*1.45),l=1;for(let c of t){let u=he(this.e,e,c);if(!u)continue;let h=Math.max(10,c.currentWidth-s*2-2),p=1,m=0;for(let g of u){let v=r.measureText(g).width;if(m>0&&m+v>h?(p++,m=v):m+=v,p>=12)break}p>l&&(l=p)}return l*a+Math.round(s*.9)}Dl(e,t){if(this.e.r.flashCells)for(let r of e)for(let i of t)this.mi.push([r,i])}md(){if(this.mi.length===0)return;let e=this.mi;this.mi=[];for(let[t,r]of e){let i=this.rn(t,r);if(!i)continue;i.classList.remove("mach-cell--flash"),i.offsetWidth,i.classList.add("mach-cell--flash");let o=Re(i),s=o.flashTimer;s&&clearTimeout(s),o.flashTimer=window.setTimeout(()=>{i.classList.remove("mach-cell--flash"),o.flashTimer=void 0},800)}}ye(){this.Tn();let e=this.e.o.T.center,r=this.e.r.rowHeight;this.e.r.masterDetail&&(r=Math.min(r,this.e.r.detailRowHeight)),this.Hn>0&&(r=Math.min(r,this.Hn));let i=Math.ceil(e.clientHeight/Math.max(1,r)),o=this.gt?this.e.i.P():i+this.e.r.rowBuffer*2+1,s=o%2===0?o:o+1;this.gd(),s>this.qe&&this.yd(s),this.zn(),this.hi(!0,!1),this.Vs()}yd(e){for(;this.qe<e;){let t={index:-1,nodeId:"",kind:"master",rows:{},cells:{}},r=this.e.o;for(let i of b){if(this.e.n.C(i).length===0)continue;let s=f("div","mach-row");s.style.height=`${this.e.r.rowHeight}px`,s.setAttribute("role","row"),s.style.display="none",r.Te[i].appendChild(s),t.rows[i]=s,t.cells[i]=this.Ut(i).map(a=>s.appendChild(this.vd(a)))}if(this.e.r.masterDetail){let i=f("div","mach-row mach-detail-row");i.style.height=`${this.e.r.detailRowHeight}px`,i.setAttribute("role","row"),i.style.display="none",r.Te.center.appendChild(i),t.detailRow=i}this._.push(t),this.qe++}}Ut(e){return e==="center"?this.fi:this.e.n.C(e)}vd(e){let t=f("div","mach-cell");if(t.dataset.colId=e.id,t.setAttribute("role","gridcell"),e.hasCheckbox){let r=document.createElement("input");r.type=this.e.r.rowSelection==="single"?"radio":"checkbox",r.className="mach-row-checkbox",r.type==="radio"&&(r.name=`mach-radio-${this.e.gridId}`),r.setAttribute("aria-label","select row"),t.appendChild(r),t.classList.add("mach-cell--selection")}return t}Rf(e){let t=new Map(this.fi.map((i,o)=>[i.id,o])),r=e.map(i=>{let o=t.get(i.id);return t.delete(i.id),o});for(let i of this._){let o=i.rows.center,s=i.cells.center;if(!o||!s)continue;let a=e.map((l,d)=>{let c=r[d];return o.appendChild(c===void 0?this.vd(l):s[c])});for(let l of t.values()){let d=s[l];i.index>=0&&this.e.l.Bo(i.index,d.dataset.colId??"",d),k(this.e,d),d.remove()}i.cells.center=a}}hs(){this.gi=void 0,this.bd(),this.ud(!0),this.ft=0,this.Ye=-1,this.ye()}ud(e){for(let t of this._){t.detailRow&&this.Bs(t.detailRow);for(let r of b){for(let i of t.cells[r]??[])!e&&t.index>=0&&this.e.l.Bo(t.index,i.dataset.colId??"",i),k(this.e,i);e&&t.rows[r]?.remove()}e&&t.detailRow?.remove()}this._=[],this.qe=0,this.Ns=void 0,this.fi=[]}zn(){let e=this.Sf();for(let t of b){let r=this.e.n.C(t),i=this.Ut(t),o=this.Mf(t,i,r);this.If(t,i,o,e)}this.Af()}Sf(){return this.e.r.masterDetail||this.e.r.getRowHeight!=null||this.Ef}Mf(e,t,r){let i=0;e==="center"&&t.length>0&&(this.O.update(r),i=this.O.Vt(r.indexOf(t[0])));let o=[];for(let s of t)o.push(i),i+=s.currentWidth;return o}If(e,t,r,i){for(let o of this._){let s=o.cells[e],a=o.rows[e];if(!s||!a)continue;i||(a.style.height=`${this.e.r.rowHeight}px`);let l=Math.min(t.length,s.length);for(let d=0;d<l;d++){let c=t[d];s[d].style.width=`${c.currentWidth}px`,s[d].style.left=`${r[d]}px`,s[d].setAttribute("aria-colindex",String(this.e.n.Fe(c.id)+1))}}}Af(){if(!this.e.r.masterDetail)return;let e=`${this.e.r.detailRowHeight}px`;for(let t of this._)t.detailRow?.style.setProperty("--mach-detail-h",e)}gd(){let e=this.e.o.T.center,t=this.e.n.C("center");this.O.update(t);let r=t.length>20&&!this.e.n.ro(),{first:i,lastExcl:o}=r?this.O.Xl(e.scrollLeft,e.clientWidth,2):{first:0,lastExcl:t.length};if(t===this.Ns&&i===this.Bt&&o-i===this.fi.length)return!1;let s=r?t.slice(i,o):t;return this._.length>0&&this.Rf(s),this.Ns=t,this.fi=s,this.Bt=i,!0}go(){return{first:this.ft,lastExcl:this.Ye}}hi(e=!1,t=!0){let r=this.e.ve.start();if(!this.kf(e,t))return;let i=Math.max(0,this.Ye-this.ft),o=this.e.n.C("left").length+this.Ut("center").length+this.e.n.C("right").length;this.e.ve.vh(r,i,o)}kf(e,t){let r=this.e.o.T.center,i=this.R.read(r.scrollTop)-r.scrollTop,o=i!==this.mt;this.mt=i;let s=this.e.i.P(),a=this.e.r.rowBuffer,l=t&&this.gd();if(l&&this.zn(),s===0){for(let u of this._)this.wd(u);return this.ft=0,this.Ye=0,!0}let{first:d,lastExcl:c}=this.Pf(r,s,a);return!e&&!l&&d===this.ft&&c===this.Ye?(o&&(this.Cd(),this.yt()),l||o):(this.Gf(d,c),this.ft=d,this.Ye=c,this.Lf(d,c,e,l),o&&this.Cd(),this.yt(),!0)}Pf(e,t,r){if(this.gt)return{first:0,lastExcl:t};let i=this.R.read(e.scrollTop),o=this.Ln(i,t),s=i+e.clientHeight,a=Math.min(t,this.Ln(s,t)+1);return{first:C(o-r,0,t-1),lastExcl:C(a+r,1,t)}}Gf(e,t){if(!(this.gt&&this.ft===0&&t>=this.Ye))for(let r of this._)r.index!==-1&&(r.index<e||r.index>=t)&&this.wd(r)}Lf(e,t,r,i){let o=t-e;o>this.qe&&(this.yd(o+o%2),this.zn());for(let s=e;s<t;s++){let a=this.e.i.f(s),l=this._[s%this.qe];if(!(!l||!a)){if(!r&&l.index===s&&l.nodeId===a.id){i&&l.kind==="master"&&this.Wn(l,a,"center");continue}this.Nf(l,s,a)}}}wd(e){if(this.Td(e),this.gt&&e.index>=0)for(let t of b)for(let r of e.cells[t]??[])k(this.e,r);this.v?.rowIndex===e.index&&this.e.o.root.removeAttribute("aria-activedescendant"),e.index=-1,e.nodeId="",e.kind="master";for(let t of b){let r=e.rows[t];r&&(r.style.display="none",delete r.dataset.id,delete r.dataset.index,De(r,void 0),r.classList.remove("mach-row--drag-source"))}e.detailRow&&(this.Bs(e.detailRow),e.detailRow.style.display="none")}Nf(e,t,r){e.index>=0&&e.index!==t&&this.Td(e),e.index=t,e.nodeId=r.id;let i=this.Le(t),o=i-this.mt,s=this.Le(t+1)-i;if(r.isDetail){this.Of(e,r,t,o,s);return}this.Ff(e,r,t,o,s)}Cd(){for(let e of this._){if(e.index<this.ft||e.index>=this.Ye)continue;let t=`translateY(${this.Le(e.index)-this.mt}px)`;for(let r of Object.values(e.rows))r.style.transform=t;e.detailRow&&(e.detailRow.style.transform=t)}}Of(e,t,r,i,o){e.kind="detail";for(let a of b){let l=e.rows[a];l&&(l.style.display="none")}let s=e.detailRow;s&&(this.Dd(s,r,i,o),this._s(s,t))}Ff(e,t,r,i,o){e.kind="master",e.detailRow&&(e.detailRow.style.display="none");let s=this.Hf(t),a=_e(this.e,t);for(let l of b){let d=e.rows[l];d&&(this.Vf(d,t,r,i,o,s),De(d,a),this.Wn(e,t,l))}this.v&&this.v.rowIndex===r&&this.$n()}Hf(e){let t=this.e.i.G,r=e.isGroup===!0,i=t&&this.e.i.bo(e.id),o=r||i||this.e.r.masterDetail&&this.e.i.isRowExpandable(e),s=r?this.e.i.isGroupExpanded(e.id):this.e.i.isRowExpanded(e.id),a=null;return r?a=(e.groupLevel??0)+1:t&&(a=this.e.i.wo(e)+1),{expanded:s,expandable:o,level:a}}Vf(e,t,r,i,o,s){this.Dd(e,r,i,o,t.id),this.xd(e,t);let a=this.Pn===r&&!this.e.r.suppressRowHoverHighlight;e.classList.toggle("mach-row--hover",a),e.classList.toggle("mach-row--odd",r%2===1),e.classList.toggle("mach-row--drag-source",this.$t.isSource(t)),this.Bf(e,s)}Dd(e,t,r,i,o){e.style.display="",e.style.transform=`translateY(${r}px)`,e.style.height=`${i}px`,e.dataset.index=String(t),o!==void 0&&(e.dataset.id=o),e.setAttribute("aria-rowindex",String(t+this.e.o.Hl()+1))}xd(e,t){e.classList.toggle("mach-row--selected",t.selected),e.setAttribute("aria-selected",t.selected?"true":"false")}Bf(e,t){t.expandable?e.setAttribute("aria-expanded",t.expanded?"true":"false"):e.removeAttribute("aria-expanded"),t.level!=null?e.setAttribute("aria-level",String(t.level)):e.removeAttribute("aria-level")}Wn(e,t,r){let i=this.Ut(r),o=e.cells[r];if(!o)return;let s=e.index,a=r==="center"&&this.e.n.ro(),l=0;e.rows[r]?.classList.toggle("mach-row--editing",this.e.l.dl(s));for(let d=0;d<i.length;d++){let c=i[d],u=o[d];if(a&&l>0){l--,k(this.e,u),u.setAttribute("aria-hidden","true"),u.style.display!=="none"&&(u.style.display="none");continue}if(u.style.display==="none"&&(u.style.display=""),u.removeAttribute("aria-hidden"),a){let h=this._f(t,c,s,i.length-d);h>1?(l=h-1,this.zf(u,i,d,h)):(u.removeAttribute("aria-colspan"),u.style.width!==`${c.currentWidth}px`&&(u.style.width=`${c.currentWidth}px`))}else u.removeAttribute("aria-colspan");this.e.l.hl(s,t,c,u)||(this.Ed(u,t,c),this.zs(u,s,c))}}_f(e,t,r,i){let o=t.colDef.colSpan;if(!o)return 1;try{let s=o({api:this.e.api,colDef:t.colDef,column:t,node:e,data:e.data,value:this.e.c(e,t),rowIndex:r});return Math.max(1,Math.min(Math.round(s)||1,i))}catch(s){return this.e.reportError(s,"colSpan",{colId:t.id,rowId:e.id}),1}}zf(e,t,r,i){let o=0;for(let s=r;s<r+i&&s<t.length;s++)o+=t[s].currentWidth;e.style.width=`${o}px`,e.setAttribute("aria-colspan",String(i))}_s(e,t){this.Bs(e);let r=t.masterId!=null?this.e.i.X(t.masterId):t,i=f("div","mach-detail");e.appendChild(i);let o=this.e.r.detailRowRenderer;if(o){let s={data:t.data,node:r??t,api:this.e.api},a;try{a=o(s)}catch(l){this.e.reportError(l,"detailRowRenderer",{rowId:t.id}),a=null}typeof a=="string"?i.textContent=a:a instanceof HTMLElement?i.appendChild(a):a&&typeof a=="object"&&a.el instanceof HTMLElement&&(i.appendChild(a.el),Ue(e,a.destroy))}}Bs(e){let t=je(e);if(t)try{t()}catch(r){this.e.reportError(r,"detailRowRenderer.destroy")}e.textContent=""}Ed(e,t,r){if(t.loading){k(this.e,e),e.className="mach-cell mach-cell--loading",e.setAttribute("aria-readonly","true"),e.setAttribute("aria-busy","true");let o=f("span","mach-cell-loading-bar");o.style.width=`${34+(r.id.length*13+t.rowIndex*7)%44}%`,e.replaceChildren(o),this.jt(e);return}e.removeAttribute("aria-busy"),e.setAttribute("aria-readonly",this.e.l.J(t,r)?"false":"true"),e.removeAttribute("aria-expanded"),e.removeAttribute("aria-level");let i=this.Wf(t,r);if(i!=="standard"){k(this.e,e),this.$f(i,e,t,r);return}Ye(this.e,e,t,r),this.Rd(e,t,r),this.Kf(e,t,r)}Wf(e,t){return e.isGroup?"group":t.isDetailToggle?"detail":t.hasCheckbox?"checkbox":t.colDef.rowDrag?"drag":ke(t.colDef,"index")?"index":this.e.i.G&&this.Sd()?.id===t.id?"tree":"standard"}$f(e,t,r,i){if(e==="group")this.Uf(t,r,i);else if(e==="detail"){let o=this.e.i.isRowExpanded(r.id),s=f("span",`mach-detail-toggle${o?" mach-detail-toggle--open":""}`);s.textContent="\u25B6",t.replaceChildren(s),t.classList.add("mach-cell--detail-toggle"),this.jt(t)}else if(e==="checkbox"){let o=t.querySelector(".mach-row-checkbox");o&&(o.checked=r.selected,o.indeterminate=this.e.h.ru(r.id),o.disabled=!this.e.h.Rt(r)),t.className!=="mach-cell mach-cell--selection"&&(t.className="mach-cell mach-cell--selection"),this.jt(t)}else if(e==="drag")this.jf(t,r),t.className!=="mach-cell mach-cell--drag"&&(t.className="mach-cell mach-cell--drag"),this.jt(t);else if(e==="index"){t.textContent=String(this.e.i.Ba(r)+this.e.r.indexOffset);let o=`mach-cell mach-cell--index ${qe(i)}`;t.className!==o&&(t.className=o),this.Rd(t,r,i)}else this.qf(t,r,i)}Kf(e,t,r){if(this.e.r.editType!=="cell"||this.e.r.editableIndicator==="none"||!this.e.l.J(t,r))return;let i=document.createElement("button");i.type="button",i.className=`mach-cell-edit-trigger mach-cell-edit-trigger--${this.e.r.editableIndicator}`,i.tabIndex=-1,i.title="Edit cell",i.setAttribute("aria-label","Edit cell"),i.innerHTML='<svg viewBox="0 0 16 16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m10.8 2.7 2.5 2.5L5.5 13H3v-2.5z"/><path d="m9.5 4 2.5 2.5"/></svg>',i.addEventListener("mousedown",o=>{o.preventDefault(),o.stopPropagation()}),i.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation(),this.Ae(t.rowIndex,r.id),this.e.l.start(t.rowIndex,r)}),e.appendChild(i)}Td(e){if(!(e.index<0))for(let t of b)for(let r of e.cells[t]??[])this.e.l.Bo(e.index,r.dataset.colId??"",r)}Sd(){return this.gi!==void 0?this.gi:(this.gi=this.e.n.d().find(e=>!e.hasCheckbox&&!e.isDetailToggle&&!e.colDef.rowDrag&&!ke(e.colDef,"index"))??null,this.gi)}qf(e,t,r){let i=this.e.i.isRowExpandable(t),o=this.e.i.wo(t),s=K(this.e,t,r,this.e.c(t,r)),a=f("span","mach-tree-indent");a.style.width=`${o*16}px`;let l=f("span","mach-tree-cell");if(o>0&&l.appendChild(a),i){let c=this.e.i.isRowExpanded(t.id);e.setAttribute("aria-expanded",c?"true":"false"),e.setAttribute("aria-level",String(o+1));let u=t.treeLoading?" mach-detail-toggle--loading":t.treeLoadError?" mach-detail-toggle--error":"",h=document.createElement("button");h.type="button",h.tabIndex=-1,h.className="mach-tree-toggle",h.setAttribute("aria-label",t.treeLoadError?"Retry loading children":c?"Collapse row":"Expand row"),h.setAttribute("aria-expanded",String(c)),t.treeLoadError&&(h.title="Retry loading children");let p=f("span",`mach-detail-toggle${c?" mach-detail-toggle--open":""}${u}`);p.setAttribute("aria-hidden","true"),p.textContent="\u25B6",h.appendChild(p),h.addEventListener("keydown",m=>{(m.key==="Enter"||m.key===" ")&&m.stopPropagation()}),l.appendChild(h)}else{let c=f("span","mach-tree-toggle-spacer");l.appendChild(c)}let d=f("span","mach-tree-text");d.textContent=s,l.appendChild(d),e.replaceChildren(l),s&&!this.e.r.tooltipComponent?e.title=s:e.removeAttribute("title"),mr(this.e,e,t,r)}jt(e){e.style.height!==""&&(e.style.height=""),e.style.zIndex!==""&&(e.style.zIndex=""),e.style.display==="none"&&(e.style.display=""),e.removeAttribute("aria-rowspan")}Rd(e,t,r){let i=this.e.i.jc(r.id);if(!i||t.isDetail){this.jt(e);return}let o=this.e.i.Ba(t)-1;if(o<0||o>=i.length){this.jt(e);return}let s=i[o];if(s===-1){e.style.display="none",e.setAttribute("aria-hidden","true");return}if(e.style.display==="none"&&(e.style.display=""),e.removeAttribute("aria-hidden"),s>1){let a=Math.min(o+s,this.e.i.P()),l=this.Le(a)-this.Le(o);e.style.height=`${l>0?l:s*this.e.r.rowHeight}px`,e.style.zIndex="1",e.setAttribute("aria-rowspan",String(s))}else this.jt(e)}Uf(e,t,r){if(r.hasCheckbox){this.Yf(e,t);return}if(r.isDetailToggle){this.Md(e);return}let i=this.e.n.na();if(i&&r.id===i.id){this.Xf(e,t);return}this.Jf(e,t,r)||this.Md(e)}Yf(e,t){let r=e.querySelector(".mach-row-checkbox");if(r){let i=this.e.h.Ua(t);r.checked=i.all,r.indeterminate=i.some&&!i.all}e.className!=="mach-cell mach-cell--selection"&&(e.className="mach-cell mach-cell--selection")}Xf(e,t){let r=this.e.i.isGroupExpanded(t.id),i=t.groupLevel??0;e.setAttribute("aria-expanded",r?"true":"false"),e.setAttribute("aria-level",String(i+1));let o=f("span","mach-group-label");o.style.paddingLeft=`${i*16}px`;let s=f("span",`mach-detail-toggle${r?" mach-detail-toggle--open":""}`);s.textContent="\u25B6";let a=f("span","mach-group-text"),l=this.e.n.Xe()[i],d=l?.colDef.headerName?`${l.colDef.headerName}: `:"";a.textContent=`${d}${t.groupKey??""}`;let c=f("span","mach-group-count");c.textContent=`(${t.leafNodes?.length??0})`,o.append(s,a,c),e.replaceChildren(o),e.className!=="mach-cell mach-cell--group"&&(e.className="mach-cell mach-cell--group")}Jf(e,t,r){if(!r.colDef.aggFunc||!t.aggValues||!Object.prototype.hasOwnProperty.call(t.aggValues,r.id))return!1;let i=t.aggValues[r.id];e.textContent=r.colDef.valueFormatter!=null?K(this.e,t,r,i):fr(i);let o=`mach-cell ${qe(r)}`;return e.className!==o&&(e.className=o),!0}Md(e){e.textContent="",e.className!=="mach-cell"&&(e.className="mach-cell")}M(e){if(this.e.s())return;let t=new Set;for(let r of e){if(r<0||t.has(r))continue;t.add(r);let i=this._[r%this.qe];if(!i||i.index!==r)continue;let o=this.e.i.f(r);if(o){if(i.kind==="detail"){i.detailRow&&this._s(i.detailRow,o);continue}for(let s of b){let a=i.rows[s];a&&this.xd(a,o),i.cells[s]&&this.Wn(i,o,s)}}}this.$n(),this.md()}refreshCells(e={}){if(this.e.s())return;let t=e.rowIds==null?null:new Set(e.rowIds),r=e.rowIndexes==null?null:new Set(e.rowIndexes),i=e.columns==null?null:new Set(e.columns);for(let o of this._){let s=this.e.i.f(o.index);!s||!this.Zf(o,s,t,r)||this.Qf(o,s,i,e.force===!0)}this.$n(),this.md()}Zf(e,t,r,i){return e.index<0?!1:r==null&&i==null?!0:r?.has(t.id)===!0||i?.has(e.index)===!0}Qf(e,t,r,i){if(e.kind==="detail"){r==null&&e.detailRow&&this._s(e.detailRow,t);return}let o=r==null||this.e.n.ro(),s=_e(this.e,t);for(let a of b){let l=e.rows[a];l&&De(l,s),o?this.Wn(e,t,a):this.em(e,t,a,r,i)}}em(e,t,r,i,o){let s=this.Ut(r),a=e.cells[r];if(a)for(let l=0;l<s.length;l++){let d=s[l];if(!i.has(d.id))continue;let c=a[l];c&&(this.e.l.hl(e.index,t,d,c)||(o&&k(this.e,c),this.Ed(c,t,d),this.zs(c,e.index,d)))}}tm(){this.e.s()||(this.v&&this.v.rowIndex>=this.e.i.P()&&this.Ae(null,null),this.bd(),this.Tn(),this.hi(!0),this.yt(),this.Vs(),this.e.Ce.refresh())}Vs(){let e=this.e.r,t=e.loading?"loading":e.error!=null?"error":this.e.i.P()===0&&!e.suppressNoRowsOverlay?"noRows":null;zt(this.e,t)}rn(e,t){let r=this.e.n.S(t);if(!r)return null;let i=this.Ao(r),o=this.Ut(i).indexOf(r);if(o<0)return null;let s=this._[e%this.qe];return!s||s.index!==e||s.kind!=="master"?null:s.cells[i]?.[o]??null}bd(){this.pe.Qt()}we(){let e=this.e.i.P(),t=this.e.n.d().length;return this.pe.normalize(e,t)}lr(){let e=this.we();if(e)return e;let t=this.v;if(t){let r=this.e.n.Fe(t.colId);if(r>=0)return{r1:t.rowIndex,c1:r,r2:t.rowIndex,c2:r}}return null}li(){let e=this.we();if(!e)return null;let t=this.e.n.d();return{row1:e.r1,row2:e.r2,colId1:t[e.c1]?.id??"",colId2:t[e.c2]?.id??""}}Lo(){let e=this.pe.Yp();if(e)return{row:e.row,colIdx:e.colIdx};let t=this.lr();return t?{row:t.r1,colIdx:t.c1}:null}dr(){let e=this.we();this.pe.clear(),e&&(this.Kn(),this.yt(),this.e.emit("rangeSelectionChanged",{range:null}))}Kn(){for(let e of this._)if(!(e.index<0||e.kind!=="master"))for(let t of b){let r=this.Ut(t);e.cells[t]?.forEach((i,o)=>{let s=r[o];s&&this.zs(i,e.index,s)})}}Ws(e,t,r){this.pe.start({row:e,colIdx:t},r),this.Kn(),this.yt(),this.e.emit("rangeSelectionChanged",{range:this.li()})}Lu(e,t){if(!this.pe.Xp()){let a=this.v;if(!a)return;let l=this.e.n.Fe(a.colId);if(!this.pe.Jp({row:a.rowIndex,colIdx:l}))return}let r=this.e.i.P(),i=this.e.n.d().length;this.pe.setEnd({row:Math.max(0,Math.min(e,r-1)),colIdx:Math.max(0,Math.min(t,i-1))}),this.Kn(),this.yt();let o=this.e.n.d(),s=this.pe.xs();s&&s.colIdx<o.length&&this.Ae(s.row,o[s.colIdx].id),this.e.emit("rangeSelectionChanged",{range:this.li()})}zs(e,t,r){let i=this.we();if(!i){e.classList.contains("mach-cell--range")&&e.classList.remove("mach-cell--range","mach-cell--range-top","mach-cell--range-bottom","mach-cell--range-left","mach-cell--range-right");return}let o=this.e.n.Fe(r.id);if(o<0)return;let s=t>=i.r1&&t<=i.r2&&o>=i.c1&&o<=i.c2;e.classList.toggle("mach-cell--range",s),s?(e.classList.toggle("mach-cell--range-top",t===i.r1),e.classList.toggle("mach-cell--range-bottom",t===i.r2),e.classList.toggle("mach-cell--range-left",o===i.c1),e.classList.toggle("mach-cell--range-right",o===i.c2)):e.classList.remove("mach-cell--range-top","mach-cell--range-bottom","mach-cell--range-left","mach-cell--range-right")}rm(){if(this.On)return this.On;let e=f("div","mach-fill-handle");return e.style.display="none",e.addEventListener("pointerdown",t=>{this.$s=!0,this.Id(t)}),e.addEventListener("mousedown",t=>{this.$s||this.Id(t)}),this.e.o.Te.center.appendChild(e),this.On=e,e}yt(){let e=this.rm(),t=this.we();if(!this.e.r.enableRangeSelection||!this.e.r.fillHandle||!t){e.style.display="none";return}let r=this.e.n,i=r.C("left").length,o=r.C("center");if(t.c2<i||t.c2>=i+o.length){e.style.display="none";return}let s=t.c2-i;this.O.update(o);let a=this.O.Vt(s+1),l=this.Le(Math.min(t.r2+1,this.e.i.P()))-this.mt,d=this.e.o.T.center;if(this.R.pt&&(l<d.scrollTop||l>d.scrollTop+d.clientHeight)){e.style.display="none";return}e.style.display="",e.style.left=`${this.R.pt?Math.min(a-4,parseFloat(this.e.o.Te.center.style.width)-8):a-4}px`,e.style.top=`${Math.min(l-4,this.R.height-8)}px`}Id(e){if(this.e.s()||e.button!==0)return;let t=this.we();t&&(e.preventDefault(),e.stopPropagation(),this.yi={r1:t.r1,r2:t.r2,c1:t.c1,c2:t.c2,startX:e.clientX,startY:e.clientY,axis:null,active:!1},this.Ad(!0))}kd(e){let r=this.e.o.Te.center.getBoundingClientRect(),i=e.clientY-r.top+this.mt,o=this.e.i.P(),s=this.Ln(i,o);return Math.max(this.yi.r2,Math.min(s,o-1))}Pd(e){let r=this.e.o.Te.center.getBoundingClientRect(),i=e.clientX-r.left,o=this.e.n,s=o.C("left").length,a=o.C("center");this.O.update(a);let l=this.O.Ap(i);if(l<0)return s;let d=this.O.Vt(l)+a[l].currentWidth/2;return i<d?s+l:l+1<a.length?s+l+1:s+a.length-1}Ad(e){let t=e?"addEventListener":"removeEventListener";for(let r of["pointermove","mousemove"])window[t](r,this.im);for(let r of["pointerup","mouseup","pointercancel"])window[t](r,this.nm)}Nn(){this.yi=null,this.$s=!1,this.Ad(!1),this.e.o.root.classList.remove("mach-root--filling")}Gd(e,t,r){let i=this.pe.xs();!i||t===(e?i.colIdx:i.row)||(this.pe.setEnd(e?{row:i.row,colIdx:t}:{row:t,colIdx:i.colIdx}),this.Kn(),r&&(e&&this.yt(),this.e.emit("rangeSelectionChanged",{range:this.li()})))}om({r1:e,r2:t,c1:r,c2:i},o,s){let a=this.e.n.d(),l=[],d=s?r:e,c=s?i:t,u=s?t:i;for(let h=s?e:r;h<=u;h++){let p=s?this.e.i.f(h):void 0,m=s?void 0:a[h];(s?!p||p.isDetail||p.isGroup:!Kn(m))||this.sm(a,d,c,o,l,p,m)}this.e.mr(l),this.e.emit("rangeSelectionChanged",{range:this.li()})}sm(e,t,r,i,o,s,a){let l=[];for(let c=t;c<=r;c++){let u=s??this.e.i.f(c),h=a??e[c];l.push(u&&h?this.e.c(u,h):void 0)}if(a&&l.length===1&&l[0]===void 0)return;let d=xa(l);for(let c=r+1;c<=i;c++){let u=s??this.e.i.f(c),h=a??e[c];if(!u||!Kn(h)||!this.e.l.J(u,h))continue;let p=Ea(d,c-t),m=this.e.c(u,h);o.push({node:u,column:h,oldValue:m,newValue:p})}}Ae(e,t){if(this.am(),e==null||t==null){this.v=null;return}this.v={rowIndex:e,colId:t},this.$n(),this.lm()}$n(){if(!this.v)return;let e=this.rn(this.v.rowIndex,this.v.colId);if(e){let t=Math.max(0,this.e.n.Fe(this.v.colId));e.id=`mach-grid-${this.e.gridId}-r${this.v.rowIndex}-c${t}`,e.classList.add("mach-cell--focus"),this.e.o.root.setAttribute("aria-activedescendant",e.id)}}am(){if(this.v){let e=this.rn(this.v.rowIndex,this.v.colId);e&&(e.classList.remove("mach-cell--focus"),e.removeAttribute("id"))}this.e.o.root.removeAttribute("aria-activedescendant")}lm(){if(!this.v)return;this.ji(this.v.rowIndex,"nearest");let e=this.e.n.S(this.v.colId);!e||e.pinned||this.O.Rn(this.e.o.T.center,this.e.n.C("center"),e)}ji(e,t="top"){let r=this.e.o.T.center,i=this.e.i.P();if(i===0)return;let o=C(e,0,i-1),s=r.clientHeight,a=this.R.read(r.scrollTop),l=this.Le(o),d=this.Le(o+1),c=a;t==="top"?c=l:t==="bottom"?c=d-s:t==="middle"?c=l-(s-(d-l))/2:l<a?c=l:d>a+s&&(c=d-s);let u=Math.max(0,this.Le(i)-s);this._n(C(c,0,u)),this.Cn()}Ld(e){if(this.Pn===e)return;let t=this.Pn;this.Pn=e,this.Nd(t,!1),this.Nd(e,!0)}Nd(e,t){if(e<0)return;let r=this._[e%this.qe];if(!(!r||r.index!==e||r.kind!=="master"))for(let i of b)r.rows[i]?.classList.toggle("mach-row--hover",t)}vi(){this.e.o.root.focus({preventScroll:!0})}qt(e){let t=e.target,r=t.closest(".mach-row");if(!r)return null;let i=Number(r.dataset.index);if(Number.isNaN(i))return null;let o=this.e.i.f(i);if(!o)return null;let s=t.closest(".mach-cell");return{node:o,index:i,cellEl:s}}Od(e,t,r){let{node:i,index:o,cellEl:s}=r;if(this.dm(t,i,s)||this.cm(t,i,s))return;let a=s?.dataset.colId??"",l=a?this.e.n.S(a):void 0;this.um(i,l)||i.isDetail||this.hm(t,i,o,e)||!s||!l||(this.vi(),this.e.r.suppressCellFocus||this.Ae(o,a),this.e.h.qa(i,e,!1),this.pm(e,i,o,l),this.fm(i,o,l))}dm(e,t,r){if(!t.isGroup)return!1;if(this.vi(),e.closest(".mach-row-checkbox")){let o=this.e.h.Ua(t).all;return this.e.h.ou(t,!o),!0}let i=this.e.n.na();return(!i||!r||r.dataset.colId===i.id)&&this.e.i.xo(t.id),!0}um(e,t){return!t?.isDetailToggle||e.isDetail?!1:(this.vi(),this.e.qi(e.id),!0)}hm(e,t,r,i){let o=e.closest(".mach-cell--selection");return o?(this.vi(),this.e.r.suppressCellFocus||this.Ae(r,o.dataset.colId??""),this.dr(),this.e.h.qa(t,i,!0),!0):!1}pm(e,t,r,i){let o=this.e.c(t,i),s=this.e.emit("cellClicked",{event:e,rowNode:t,rowIndex:r,column:i,colDef:i.colDef,value:o});i.colDef.onCellClick?.(s),this.e.emit("rowClicked",{event:e,rowNode:t,rowIndex:r})}fm(e,t,r){(this.e.r.singleClickEdit||r.colDef.singleClickEdit===!0)&&this.e.l.J(e,r)&&this.e.l.start(t,r)}cm(e,t,r){if(!this.e.i.G||!e.closest(".mach-tree-toggle"))return!1;let i=this.Sd();return!i||r?.dataset.colId!==i.id||!this.e.i.isRowExpandable(t)?!1:(this.vi(),t.treeLoadError?this.e.i.loadTreeChildren(t.id,!0).catch(()=>{}):this.e.i.qi(t.id),!0)}mm(e){return!!(e.target.closest(".mach-cell-editor-shell, .mach-row-editor-shell, .mach-tree-toggle, .mach-row-drag-handle")||this.e.l.tn())}jf(e,t){let r=e.querySelector("button.mach-row-drag-handle"),i=r?.value===t.id?r:f("button","mach-row-drag-handle");i.type="button",i.value=t.id;let o=this.$t.sd(t);i.disabled=o!==!0;let s=this.e.r.locale.rowDragHandle??D.rowDragHandle;i.setAttribute("aria-label",s),i.title=typeof o=="string"?o:i.disabled?this.e.r.locale.rowDragUnavailable??D.rowDragUnavailable:s,i.setAttribute("aria-keyshortcuts","Alt+ArrowUp Alt+ArrowDown"),i!==r&&e.replaceChildren(i)}};var Zt=class{constructor(e){this.e=e;this.Ne=null;this.Fd={left:void 0,center:void 0,right:void 0};this.Us={left:[],center:[],right:[]}}init(){this.Ne=f("div","mach-footer"),this.Ne.style.display="none",this.Ne.setAttribute("role","row"),this.e.o.root.appendChild(this.Ne);for(let e of b){let t=f("div",`mach-footer-row mach-footer-row--${e}`);t.style.height=`${this.e.r.rowHeight}px`,this.Ne.appendChild(t),this.Fd[e]=t}}setVisible(e){this.Ne&&(this.Ne.style.display=e?"":"none")}refresh(){if(!this.Ne||this.e.s())return;let e=this.e.r.showSummary;if(this.setVisible(e),!e)return;let t=this.e.r.summaryMethod,r=this.e.i.Et().filter(o=>!o.isDetail&&!o.isGroup),i={...D,...this.e.r.locale};for(let o of b){let s=this.e.n.C(o),a=this.Fd[o];this.Us[o].length!==s.length&&(a.textContent="",this.Us[o]=s.map(()=>{let d=f("div","mach-footer-cell");return d.setAttribute("role","cell"),a.appendChild(d),d}));let l=0;s.forEach((d,c)=>{let u=this.Us[o][c];if(u.style.left=`${l}px`,u.style.width=`${d.currentWidth}px`,l+=d.currentWidth,d.hasCheckbox||d.isDetailToggle||d.colDef.rowDrag){u.textContent="";return}if(t)try{u.textContent=t({colId:d.id,column:d,values:r.map(h=>this.e.c(h,d))})}catch(h){this.e.reportError(h,"summaryMethod",{colId:d.id}),u.textContent=""}else c===0&&o==="left"?u.textContent=_(i.totalRowsLabel,r.length):u.textContent=""})}}destroy(){this.Ne?.remove(),this.Ne=null}};var Qt=class{constructor(e){this.e=e;this.w=null;this.Un=null;this.js=null;this.Tr=null;this.Yt=null;this.bi=null;this.wi=null;this.Ci=null;this.Ti=null;this.Xt=[]}init(){this.w=f("div","mach-pagination"),this.w.style.display="none",this.w.setAttribute("role","navigation");let e=(t,r,i)=>{let o=f("button",`mach-pagination-btn ${t}`);return o.type="button",o.title=r,o.setAttribute("aria-label",r),o.textContent=i,o};this.Un=f("span","mach-pagination-total"),this.bi=e("mach-pagination-first",this.t("pageFirst"),"\xAB"),this.wi=e("mach-pagination-prev",this.t("pagePrev"),"\u2039"),this.js=f("span","mach-pagination-page"),this.Ci=e("mach-pagination-next",this.t("pageNext"),"\u203A"),this.Ti=e("mach-pagination-last",this.t("pageLast"),"\xBB"),this.bi.addEventListener("click",()=>this.e.i.setPage(1)),this.wi.addEventListener("click",()=>this.e.i.setPage(this.e.i.rr()-1)),this.Ci.addEventListener("click",()=>this.e.i.setPage(this.e.i.rr()+1)),this.Ti.addEventListener("click",()=>this.e.i.setPage(this.e.i.getPageCount())),this.w.append(this.Un,this.bi,this.wi,this.js,this.Ci,this.Ti),this.e.r.paginationShowSizeSelector&&(this.Yt=ne({ariaLabel:"page size",options:[],classNames:{root:"mach-pagination-size-control",native:"mach-pagination-size"},themeSource:this.e.o.root,onChange:t=>{let r=Number(t);Number.isNaN(r)||this.e.i.setPageSize(r)}}),this.Tr=this.Yt.native,this.Hd(),this.w.appendChild(this.Yt.el)),this.e.o.root.appendChild(this.w),this.Xt.push(this.e.ce.on("modelUpdated",()=>this.refresh()),this.e.ce.on("paginationChanged",()=>this.refresh())),this.refresh()}Hd(){if(!this.Tr)return;let e=this.e.r.paginationPageSizeOptions,t=this.e.r.paginationPageSize;e.includes(t)||(e.push(t),e.sort((r,i)=>r-i)),this.Yt?.setOptions(e.map(r=>({value:String(r),label:_(this.t("perPage"),r)})),String(t))}t(e){return this.e.r.locale?.[e]??D[e]}De(){this.w&&(this.Tr&&this.e.r.paginationShowSizeSelector&&this.Hd(),this.refresh())}Vd(e,t){e&&e.textContent!==t&&(e.textContent=t)}gm(e,t){let r=e<=1,i=e>=t;this.bi&&(this.bi.disabled=r),this.wi&&(this.wi.disabled=r),this.Ci&&(this.Ci.disabled=i),this.Ti&&(this.Ti.disabled=i)}refresh(){if(!this.w||this.e.s())return;let e=this.e.i,t=e.be,r=e.getTotalRowCount(),i=t&&r>0;if(this.w.style.display=i?"":"none",!i)return;let o=e.rr(),s=e.getPageCount();this.Un&&this.e.r.paginationShowTotal&&this.Vd(this.Un,_(this.t("paginationTotal"),r)),this.Vd(this.js,ge(this.t("paginationPage"),o,s)),this.gm(o,s),this.Tr&&Number(this.Tr.value)!==this.e.r.paginationPageSize&&this.Yt?.setValue(String(this.e.r.paginationPageSize))}destroy(){for(let e of this.Xt)e();this.Xt=[],this.Yt?.destroy(),this.Yt=null,this.Tr=null,this.w?.remove(),this.w=null}};var er=class{constructor(e){this.e=e;this.top=null;this.bottom=null}init(){this.top=this.Bd(this.e.o.gn),this.bottom=this.Bd(this.e.o.yn)}Bd(e){let t={root:e,segments:{left:f("div"),center:f("div"),right:f("div")},centerViewport:f("div","mach-pinned-viewport"),rowWrappers:{left:[],center:[],right:[]},cells:[],data:[]};for(let r of b)t.segments[r].className=`mach-pinned-seg mach-pinned-seg--${r}`,r!=="center"&&t.segments[r].classList.add("mach-pane--hidden"),r==="center"&&t.centerViewport.appendChild(t.segments[r]);return e.append(t.segments.left,t.centerViewport,t.segments.right),t}setData(e,t){this.e.s()||!this.top||!this.bottom||(this.top.data=e??[],this.bottom.data=t??[],this.refresh(),this.e.ye())}setRows(e,t){let r=this[e];this.e.s()||!r||(r.data=t??[],this.qs(r,e),this.ut(),this.e.ye())}getRows(e){return this[e]?.data.slice()??[]}De(){!this.top||!this.bottom||(this.qs(this.top,"top"),this.qs(this.bottom,"bottom"))}qs(e,t){this.yr(e);for(let o of b){for(let s of e.rowWrappers[o])s.remove();e.rowWrappers[o]=[]}if(e.root.style.display=e.data.length>0?"":"none",e.data.length===0)return;let r=this.e.r.rowHeight,i=this.e.n;e.data.forEach((o,s)=>{let a={id:`__pinned_${t}_${s}`,data:o,rowIndex:-1,selected:!1},l={},d=_e(this.e,a,t);for(let c of b){let u=f("div","mach-pinned-row");De(u,d),u.style.height=`${r}px`,u.setAttribute("role","row"),l[c]=[];for(let h of i.C(c)){let p=f("div","mach-cell");if(p.dataset.colId=h.id,p.setAttribute("role","gridcell"),h.hasCheckbox&&p.classList.add("mach-cell--selection"),!h.hasCheckbox&&!h.isDetailToggle&&!h.colDef.rowDrag&&h.colDef.type!=="index")try{Ye(this.e,p,a,h)}catch(m){this.e.reportError(m,"pinnedRow.render",{colId:h.id,side:t,rowIndex:s})}u.appendChild(p),l[c].push(p)}e.segments[c].appendChild(u),e.rowWrappers[c].push(u)}e.cells.push(l)})}ut(){if(!this.top||!this.bottom)return;let e=this.e.n,t={left:0,center:0,right:0},r={left:[],center:[],right:[]};for(let i of b){let o=0;for(let s of e.C(i))r[i].push(o),o+=s.currentWidth;t[i]=o}for(let i of[this.top,this.bottom]){let o=i.data.length===0;i.segments.left.classList.toggle("mach-pane--hidden",o||t.left<=0),i.segments.right.classList.toggle("mach-pane--hidden",o||t.right<=0),i.segments.left.style.width=`${t.left}px`,i.segments.right.style.width=`${t.right}px`,i.segments.center.style.width=`${t.center}px`,i.cells.forEach(s=>{let a=0;for(let l of b){let d=e.C(l);s[l].forEach((c,u)=>{c.style.width=`${d[u].currentWidth}px`,c.style.left=`${r[l][u]}px`,c.setAttribute("aria-colindex",String(a+u+1))}),a+=d.length}})}}ff(e){this.top&&(this.top.segments.center.style.transform=`translateX(${-e}px)`),this.bottom&&(this.bottom.segments.center.style.transform=`translateX(${-e}px)`)}refresh(){this.De(),this.ut()}destroy(){this.top&&this.yr(this.top),this.bottom&&this.yr(this.bottom),this.top=null,this.bottom=null}yr(e){for(let t of e.cells)for(let r of b)for(let i of t[r])k(this.e,i);e.cells=[]}};var tr=class{constructor(e){this.e=e;this.w=null;this.Dr={};this.Xt=[]}init(){this.w=f("div","mach-statusbar"),this.w.style.display="none",this.w.setAttribute("role","status"),this.e.o.root.appendChild(this.w),this.De(),this.Xt.push(this.e.ce.on("modelUpdated",()=>this.refresh()),this.e.ce.on("selectionChanged",()=>this.refresh()),this.e.ce.on("rangeSelectionChanged",()=>this.refresh()),this.e.ce.on("cellValueChanged",()=>this.refresh()))}De(){if(!this.w)return;this.w.textContent="",this.Dr={};let e=this.e.r;if(!e.statusBarEnabled){this.w.style.display="none";return}for(let t of e.statusBarPanels){let r=f("span",`mach-statusbar-item mach-statusbar-item--${t}`);this.w.appendChild(r),this.Dr[t]=r}this.refresh()}text(e,t,r){let i=e[t]??D[t];if(r===void 0)return i;let o=typeof r=="number"?r:parseFloat(String(r))||0;return _(i,o)}Ys(e,t){let r=this.Dr[e];r&&r.textContent!==t&&(r.textContent=t)}ym(e){let t=this.e.i,r=t.Nr(),i=t.be?t.getTotalRowCount():t.P(),o=_(this.text(e,"totalRowsLabel"),i);return t.m&&r>i?`${o} / ${r}`:o}vm(e){let t=this.e.a.we();if(!t)return"";let r=this.e.n.d(),i=0,o=0;for(let l=t.r1;l<=t.r2;l++){let d=this.e.i.f(l);if(!(!d||d.isDetail||d.isGroup))for(let c=t.c1;c<=t.c2;c++){let u=r[c];if(!u)continue;let h=this.e.c(d,u);typeof h!="number"||Number.isNaN(h)||(i+=h,o++)}}if(o===0)return"";let s=Math.round(i/o*100)/100,a=Number.isInteger(i)?String(i):String(Math.round(i*100)/100);return`${this.text(e,"statusSum",a)} \xB7 ${this.text(e,"statusAvg",String(s))} \xB7 ${this.text(e,"statusCount",String(o))}`}refresh(){if(!this.w||this.e.s())return;let e=this.e.r;if(this.w.style.display=e.statusBarEnabled?"":"none",!e.statusBarEnabled)return;let t={...D,...e.locale};if(this.Dr.rowCount&&this.Ys("rowCount",this.ym(t)),this.Dr.selectedRowCount){let r=this.e.h.St().length;this.Ys("selectedRowCount",_(this.text(t,"statusSelected"),r))}this.Dr.rangeAggregate&&this.Ys("rangeAggregate",this.vm(t))}destroy(){for(let e of this.Xt)e();this.Xt=[],this.w?.remove(),this.w=null}};function Zr(){try{return typeof localStorage>"u"?null:localStorage}catch{return null}}function Un(n){return typeof TextEncoder>"u"?n.length*2:new TextEncoder().encode(n).byteLength}function Qr(n={}){let e=(n.namespace??"mach-table:grid-state").replace(/:+$/,""),t=Math.max(1024,Math.floor(n.maxBytes??512*1024)),r=o=>`${e}:${o}`,i=(o,s,a)=>{try{n.onError?.(o,s,a)}catch{}};return{storageKey:r,load(o){try{let s=(n.storage??Zr())?.getItem(r(o));if(!s)return null;if(Un(s)>t)throw new RangeError(`[MachTable] Stored grid state for "${o}" exceeds ${t} bytes.`);let a=JSON.parse(s);if(a?.schemaVersion!==2)throw new TypeError(`[MachTable] Stored grid state for "${o}" uses an unsupported schema.`);let l=$(a.state);if(!l)throw new TypeError(`[MachTable] Stored grid state for "${o}" is invalid.`);return l}catch(s){return i(s,"load",o),null}},save(o,s){try{let a=$(s);if(!a)throw new TypeError(`[MachTable] Invalid grid state for "${o}".`);let l=JSON.stringify({schemaVersion:2,savedAt:Date.now(),state:a});if(Un(l)>t)throw new RangeError(`[MachTable] Grid state for "${o}" exceeds ${t} bytes.`);(n.storage??Zr())?.setItem(r(o),l)}catch(a){i(a,"save",o)}},clear(o){try{(n.storage??Zr())?.removeItem(r(o))}catch(s){i(s,"clear",o)}}}}var ei=Qr();function rr(n,e){ei.save(n,e)}function ir(n){return ei.load(n)}function jn(n){ei.clear(n)}var ze=class{constructor(e){this.onError=e;this.jn=new Set;this.disposed=!1}add(e){let t=!0,r=()=>{if(t){t=!1,this.jn.delete(r);try{e()}catch(i){try{this.onError(i)}catch{}}}};return this.disposed?r():this.jn.add(r),r}I(e){return this.add(()=>e.destroy()),e}dispose(){if(this.disposed)return;this.disposed=!0;let e=[...this.jn].reverse();this.jn.clear();for(let t of e)t()}};function Ra(n){return!!(n.field||n.valueGetter||n.cellRenderer||n.checkboxSelection||n.rowDrag||n.type||n.autoRowSpan||n.rowSpan)}function Sa(n,e,t){n.width!=null&&n.minWidth!=null&&n.width<n.minWidth&&t.push(`\u5217 "${e}" \u7684 width(${n.width}) \u5C0F\u4E8E minWidth(${n.minWidth})\uFF0C\u5C06\u6309 minWidth \u6E32\u67D3`),n.width!=null&&n.maxWidth!=null&&n.width>n.maxWidth&&t.push(`\u5217 "${e}" \u7684 width(${n.width}) \u5927\u4E8E maxWidth(${n.maxWidth})\uFF0C\u5C06\u6309 maxWidth \u6E32\u67D3`)}function Ma(n,e){let t=n.colId??n.field??`col_${e.leafIndex}`;e.seenIds.set(t,(e.seenIds.get(t)??0)+1),n.field&&!Qe(n.field)&&e.issues.push(`\u5217 "${t}" \u7684 field \u8DEF\u5F84\u4E0D\u5B89\u5168\u6216\u65E0\u6548\uFF0C\u5DF2\u7981\u6B62\u8BFB\u53D6\u548C\u5199\u5165`),Ra(n)||e.issues.push(`\u5217 "${t}" \u65E2\u65E0 field \u4E5F\u65E0 valueGetter\uFF0C\u5C06\u59CB\u7EC8\u663E\u793A\u7A7A\u503C\uFF08\u7EAF\u5DE5\u5177\u5217\u8BF7\u5FFD\u7565\u6B64\u63D0\u793A\uFF09`),Sa(n,t,e.issues)}function qn(n,e){for(let t of n){if(me(t)){!Array.isArray(t.children)||t.children.length===0?e.issues.push(`\u5217\u5206\u7EC4 "${t.headerName??t.groupId??"?"}" \u7684 children \u4E3A\u7A7A`):qn(t.children,e);continue}e.leafIndex++,Ma(t,e)}}function Yn(n){if(!n||n.length===0)return[];let e={issues:[],seenIds:new Map,leafIndex:0};qn(n,e);for(let[t,r]of e.seenIds)r>1&&e.issues.push(`\u5B58\u5728 ${r} \u4E2A\u91CD\u590D\u7684 colId/field "${t}"\uFF0C\u5DF2\u81EA\u52A8\u52A0\u540E\u7F00\u533A\u5206\uFF0C\u5EFA\u8BAE\u663E\u5F0F\u547D\u540D colId`);return e.issues}var Xn=new Set([...Wr,...$r]),Ia=new Set(["enableColumnResize","pagination","rowKey"]);function Aa(n,e){if(n===e)return 0;if(n.length===0)return e.length;if(e.length===0)return n.length;let t=Array.from({length:e.length+1},(r,i)=>i);for(let r=1;r<=n.length;r++){let i=t[0];t[0]=r;for(let o=1;o<=e.length;o++){let s=t[o];t[o]=Math.min(t[o-1]+1,s+1,i+(n[r-1]===e[o-1]?0:1)),i=s}}return t[e.length]}function ka(n){let e,t=Math.max(2,Math.floor(n.length*.3))+1,r=n.toLowerCase();for(let i of Xn){if(Math.abs(r.length-i.length)>=t)continue;let o=Aa(r,i.toLowerCase());o<t&&(t=o,e=i)}return e}function Pa(n,e){n.rowKey!=null&&typeof n.rowKey!="string"&&typeof n.rowKey!="function"&&e("INVALID_OPTION_VALUE","rowKey","rowKey \u5FC5\u987B\u662F\u5B57\u6BB5\u8DEF\u5F84\u6216\u8FD4\u56DE\u7A33\u5B9A\u4E1A\u52A1\u4E3B\u952E\u7684\u51FD\u6570"),n.domLayout==="autoHeight"&&n.datasource!=null&&e("OPTION_CONFLICT","domLayout","autoHeight \u4F1A\u6E32\u67D3\u5168\u90E8\u5DF2\u52A0\u8F7D\u884C\uFF0C\u4E0D\u9002\u7528\u4E8E datasource \u65E0\u9650\u6EDA\u52A8\u6A21\u5F0F"),Ga(n,e),n.enableColumnResize!=null&&typeof n.enableColumnResize!="boolean"&&e("INVALID_OPTION_VALUE","enableColumnResize","enableColumnResize \u5FC5\u987B\u662F boolean\uFF1B\u672A\u914D\u7F6E\u65F6\u9ED8\u8BA4\u5173\u95ED")}function Ga(n,e){n.datasourceMode==="block"&&(n.datasource==null&&e("OPTION_CONFLICT","datasourceMode","datasourceMode='block' requires a datasource"),typeof n.getRowHeight=="function"&&e("OPTION_CONFLICT","getRowHeight","Random-access block rows require fixed rowHeight so unloaded offsets remain deterministic"),n.masterDetail===!0&&e("OPTION_CONFLICT","masterDetail","masterDetail is not supported by the sparse random-access block row model"),n.treeData===!0&&e("OPTION_CONFLICT","treeData","treeData requires the local/tree row model and cannot use random-access blocks"),n.rowKey==null&&e("MISSING_STABLE_ROW_ID","rowKey","Random-access blocks require rowKey to preserve selection and identity after eviction"))}function La(n,e){for(let t of Wr)if(!(Ia.has(t)||!Object.prototype.hasOwnProperty.call(n,t))&&!Kr(t,n[t])){let r=t==="maxBodyHeight"?"maxBodyHeight \u5FC5\u987B\u662F\u81F3\u5C11 1px \u7684\u6709\u9650\u6570":`${t} \u503C\u7C7B\u578B\u65E0\u6548\uFF0C\u671F\u671B ${Ce[t]}`;e("INVALID_OPTION_VALUE",t,r)}}function Na(n){let e=[];for(let t of Object.keys(n)){if(Xn.has(t))continue;let r=ka(t);e.push({code:"UNKNOWN_OPTION",option:t,...r?{suggestion:r}:{},message:r?`\u672A\u77E5 GridOption "${t}"\uFF0C\u662F\u5426\u60F3\u4F7F\u7528 "${r}"\uFF1F`:`\u672A\u77E5 GridOption "${t}"\uFF0C\u8BE5\u503C\u4E0D\u4F1A\u751F\u6548`})}return e}function Oa(n,e,t){if(e.mode!=="server")return;n.rowKey==null&&t("MISSING_STABLE_ROW_ID","rowKey","\u670D\u52A1\u7AEF\u5206\u9875\u5EFA\u8BAE\u63D0\u4F9B\u7A33\u5B9A rowKey\uFF0C\u5426\u5219\u8DE8\u9875\u9009\u62E9\u4E0E\u589E\u91CF\u66F4\u65B0\u65E0\u6CD5\u53EF\u9760\u4FDD\u6301");let r=e.total;r!==void 0&&(typeof r!="number"||!Number.isFinite(r)||r<0)&&t("INVALID_OPTION_VALUE","pagination.total","\u670D\u52A1\u7AEF\u5206\u9875 total \u5FC5\u987B\u662F\u975E\u8D1F\u6709\u9650\u6570")}function Fa(n,e){let t=n.pagination;t!=null&&typeof t!="boolean"&&typeof t!="object"&&e("INVALID_OPTION_VALUE","pagination","pagination \u5FC5\u987B\u662F boolean \u6216\u914D\u7F6E\u5BF9\u8C61"),n.datasource!=null&&t!==void 0&&t!==!1&&e("OPTION_CONFLICT","pagination","datasource \u987A\u5E8F\u65E0\u9650\u6A21\u5F0F\u4E0E pagination \u4E0D\u80FD\u540C\u65F6\u542F\u7528\uFF1B\u666E\u901A\u670D\u52A1\u7AEF\u5206\u9875\u8BF7\u4F7F\u7528 pagination.mode='server'"),t&&typeof t=="object"&&Oa(n,t,e)}function nr(n){let e=n,t=Na(e),r=(i,o,s)=>{t.push({code:i,option:o,message:s})};return Fa(e,r),e.treeData===!0&&e.masterDetail===!0&&r("OPTION_CONFLICT","masterDetail","treeData \u4E0E masterDetail \u4E0D\u80FD\u540C\u65F6\u542F\u7528\uFF0C\u4E3B\u4ECE\u660E\u7EC6\u5C06\u88AB\u5FFD\u7565"),La(e,r),Pa(e,r),t}function Jn(n){let e=/^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:[-+].*)?$/.exec(n.trim());return e?[Number(e[1]),Number(e[2]??0),Number(e[3]??0)]:null}function ti(n,e){for(let t=0;t<3;t++)if(n[t]!==e[t])return n[t]<e[t]?-1:1;return 0}function Ha(n){return n[0]>0?[n[0]+1,0,0]:n[1]>0?[0,n[1]+1,0]:[0,0,n[2]+1]}function Va(n,e){if(e==="*"||e.toLowerCase()==="latest")return!0;let t=/^(\^|~|>=|<=|>|<|=)?\s*(.+)$/.exec(e);if(!t)return!1;let r=Jn(t[2]);if(!r)return!1;let i=ti(n,r);switch(t[1]??"="){case">=":return i>=0;case"<=":return i<=0;case">":return i>0;case"<":return i<0;case"^":return i>=0&&ti(n,Ha(r))<0;case"~":return i>=0&&ti(n,[r[0],r[1]+1,0])<0;default:return i===0}}function Zn(n,e){if(!e?.trim())return!0;let t=n?Jn(n):null;return t?e.split("||").some(r=>{let i=r.trim().split(/\s+/).filter(Boolean);return i.length>0&&i.every(o=>Va(t,o))}):!1}function Ba(n){return[...new Set((n??[]).map(e=>e.trim()).filter(Boolean))]}function or(n){let e=new Map;for(let t of n??[]){let r=(typeof t=="string"?t:t?.key??"").trim();if(!r||e.has(r))continue;let i=typeof t=="object"?t.version?.trim():void 0;e.set(r,{key:r,...i?{version:i}:{}})}return[...e.values()]}function sr(n){let e=[],t=new Map;for(let l of n){let d=typeof l?.key=="string"?l.key.trim():"";if(!d){e.push({code:"INVALID_FEATURE_KEY",message:"GridFeature.key must be a non-empty string"});continue}if(t.has(d)){e.push({code:"DUPLICATE_FEATURE",feature:d,message:`Duplicate GridFeature key: ${d}`});continue}t.set(d,l)}let r=new Set;for(let[l,d]of t){for(let c of or(d.requires)){let u=t.get(c.key);u?Zn(u.version,c.version)||(r.add(l),e.push({code:"UNSUPPORTED_FEATURE_VERSION",feature:l,dependency:c.key,message:`GridFeature "${l}" requires "${c.key}" ${c.version}, received ${u.version??"unversioned"}`})):(r.add(l),e.push({code:"MISSING_FEATURE_DEPENDENCY",feature:l,dependency:c.key,message:`GridFeature "${l}" requires missing feature "${c.key}"`}))}for(let c of Ba(d.conflicts))if(t.has(c)){r.add(l),e.push({code:"FEATURE_CONFLICT",feature:l,dependency:c,message:`GridFeature "${l}" conflicts with "${c}"`});break}}let i=[],o=new Set,s=new Set,a=l=>{if(s.has(l))return!r.has(l);if(o.has(l))return r.add(l),e.push({code:"FEATURE_CYCLE",feature:l,message:`GridFeature dependency cycle includes "${l}"`}),!1;let d=t.get(l);if(!d||r.has(l))return!1;o.add(l);let c=!0;for(let u of or(d.requires))a(u.key)||(c=!1);return o.delete(l),s.add(l),c?(i.push(d),!0):(r.add(l),!1)};for(let l of t.keys())a(l);return{features:i.filter(l=>!r.has(l.key.trim())),issues:e}}var _a=["datasource","treeData"],za=["columnState.","gridState."],Wa=new Set(["valueFormatter","cellStyle","cellClass"]),$a=new Set(["selectionChanged","sortChanged","filterChanged","columnMoved","columnVisibilityChanged","paginationChanged","detailToggled"]),Ka=0,ar=class{constructor(e,t){this.x=!1;this.bm=0;this.Di=0;this._d=!1;this.Xs="";this.E=new ze(e=>console.error("[mach-table] resource cleanup error",e));this.activeFeatures=new Map;this.Ud=0;this.xi=0;this.recentErrors=[];this.vt=null;this.jd=0;this.Ei=null;this.Js=0;this.Ri=null;this.Zs=!1;this.Qs=null;this.ec=null;this.qn=new Set;let r;this.zd=new Promise(i=>{r=i}),this.Wd=r,this.gridId=++Ka,this.r=Di(t),this.ce=new Ze((i,o)=>{o==="gridError"?console.error("[mach-table] error in gridError listener",i):this.reportError(i,"eventBus.listener",{eventType:o})});try{if(this.jl(t.dataProcessor),this.n=new lt(this),this.i=this.E.I(new gt(this)),this.h=new yt(this),this.o=this.E.I(new _t(this)),this.$=this.E.I(new Kt(this)),this.a=this.E.I(new Jt(this)),this.pi=this.E.I(new vt(this)),this.Mn=this.E.I(new bt(this)),this.jo=this.E.I(new Et(this)),this.l=this.E.I(new Mt(this)),this.V=new St(this),this.F=new Nt(this),this.ve=this.E.I(new Ht),this.pr=this.E.I(new Vt(i=>this.wm(i))),this.Cs=this.E.I(new At(this)),this.columnMenu=this.E.I(new kt(this)),this.Ks=this.E.I(new Pt(this)),this.Fn=this.E.I(new Gt(this)),this.xn=this.E.I(new Lt(this)),this.gr=this.E.I(new Qt(this)),this.Pe=this.E.I(new er(this)),this.Ce=this.E.I(new Zt(this)),this.st=this.E.I(new tr(this)),this.api=zn(this),this.Ht=new Je(this),this.K=this.E.I(new Ot(this)),this.E.add(()=>this.qd()),this.K.init(),this.o.init(e,this.r),this.xn.init(),this.a.init(),this.jo.init(),this.Fn.init(),this.gr.init(),this.Ce.init(),this.st.init(),this.Pe.init(),this.i.Ha(this.r.paginationPage,this.r.paginationPageSize),this.n.Sr(this.r.columnDefs),this.i.it(this.r.advancedFilterModel),this.i.xt(this.r.quickFilterText),this.En(),this.Yd(this.r.columnDefs),this.ps(t),this.$.ui(),this.r.datasource?this.i.zi().catch(()=>{}):this.i.rt(this.r.rowData),this.r.initialState&&this.api.state.apply(this.r.initialState,{emitEvents:!1}),this.ms(),this.ye(),this.Pe.setData(this.r.pinnedTopRowData,this.r.pinnedBottomRowData),this.ql(this.r.features),this.x)return;this.Di=requestAnimationFrame(()=>{this.Di=0,this.x||this.emit("gridReady",{}),this.Xd()})}catch(i){throw this.api&&this.reportError(i,"grid.constructor"),this.destroy(),i}}jl(e){if(e===this.$d)return!1;let t=++this.Ud,r=typeof e=="function"?e():e;if(this.x||t!==this.Ud)return r?.destroy?.(),!1;let i=this.Kd;return this.$d=e,r===this.r.dataProcessor&&i?!1:(this.r.dataProcessor=r,this.Kd=r?this.E.add(()=>r.destroy?.()):void 0,i?.(),!0)}whenReady(){return this.zd}Xd(){this._d||(this._d=!0,this.Wd(this.api))}tc(e){return this.r.components?.cellRenderers?.[e]??Li[e]}qu(e){return this.r.components?.cellEditors?.[e]}Cm(e){return or(e.requires).map(t=>t.key).find(t=>!this.activeFeatures.has(t))}ql(e){let t=this.xi+1;if(this.qd(),this.x||this.xi!==t)return;let r=sr(e??[]);for(let i of r.issues)this.reportError(new Error(i.message),"feature.manifest",{code:i.code,...i.feature?{key:i.feature}:{},...i.dependency?{dependency:i.dependency}:{}});for(let i of r.features){if(this.x||this.xi!==t)return;let o=i.key.trim(),s=this.Cm(i);if(s){this.reportError(new Error(`GridFeature "${o}" dependency "${s}" did not initialise`),"feature.manifest",{code:"FEATURE_DEPENDENCY_SETUP_FAILED",key:o,dependency:s});continue}let a=new ze(c=>this.reportError(c,"feature.cleanup",{key:o})),l=c=>a.add(c),d={api:this.api,root:this.o.root,getOptions:()=>this.r,addEventListener:(c,u)=>l(this.ce.on(c,u)),onCleanup:c=>{l(c)},addManagedDomListener:(c,u,h,p)=>(c.addEventListener(u,h,p),l(()=>c.removeEventListener(u,h,p))),setManagedTimeout:(c,u)=>{let h=setTimeout(()=>{p(),c()},Math.max(0,u)),p=l(()=>clearTimeout(h));return h},createAbortController:()=>{let c=new AbortController;return l(()=>c.abort()),c},reportError:(c,u,h)=>this.reportError(c,`feature.${u}`,h)};try{let c=i.setup(d);if(typeof c=="function"&&l(c),this.x||this.xi!==t){this.Jd(o,{feature:i,scope:a});return}this.activeFeatures.set(o,{feature:i,scope:a})}catch(c){a.dispose(),this.reportError(c,"feature.setup",{key:o})}}}qd(){this.xi++;let e=[...this.activeFeatures.entries()].reverse();this.activeFeatures.clear();for(let[t,r]of e)this.Jd(t,r)}Jd(e,t){t.scope.dispose();try{t.feature.destroy?.()}catch(r){this.reportError(r,"feature.destroy",{key:e})}}s(){return this.x}suspend(){this.ze(),this.api.editing.stop({cancel:!0}),this.Cs.close(),this.columnMenu.close(),this.Ks.close(),this.Fn.hide(),this.pi.kt(),this.Mn.destroy(),this.a.suspend(),dn(this.o.root),Ii(this.o.root);let e=document.activeElement;e instanceof HTMLElement&&this.o.root.contains(e)&&e.blur()}tr(){return++this.bm}c(e,t){let r=t.colDef;if(r.valueGetter)try{return r.valueGetter({api:this.api,colDef:r,column:t,node:e,data:e.data})}catch(i){this.reportError(i,"valueGetter",{colId:t.id,rowId:e.id});return}if(r.field)return B(e.data,r.field)}y(e){return this.r.locale[e]??D[e]}en(e,t,r,i){let o=t.colDef;if(o.valueSetter)try{return o.valueSetter({oldValue:i,newValue:r,data:e.data,node:e,colDef:o,column:t,api:this.api})}catch(s){return this.reportError(s,"valueSetter",{colId:t.id,rowId:e.id}),!1}return o.field?pe(e.data,o.field,r):!1}Ho(e,t,r,i){this.a.Ui(e),this.a.Dl([e.rowIndex],[t.id]),this.F.Zo({nodeId:e.id,columnId:t.id,oldValue:r,newValue:i}),this.emit("cellValueChanged",{oldValue:r,newValue:i,rowNode:e,rowIndex:e.rowIndex,column:t,colDef:t.colDef,data:e.data})}nl(e){let r=this.n.d().slice(e.c1,e.c2+1).filter(o=>!o.isAutoRowNumber),i=[];for(let o=e.r1;o<=e.r2;o++){let s=this.i.f(o);i.push(r.map(a=>!s||s.isDetail||s.isGroup?"":Ve(this,s,a,"clipboard")))}return Ct(i)}wl(){let e=this.a.lr();return e?Fe(this.nl(e)):Promise.resolve(!1)}Go(e){this.x||this.mr(this.Zd(e,this.n.d()))}async Mu(e,t){let{a:r,n:i,i:o}=this,s=this.V.Zi(),a=o.Or(),l=r.v,d=r.we(),c=i.d(),u=this.Zd(e,c),h=u.map(({node:m})=>m.data);if(!await Fe(t)||!s()||this.r.suppressClipboard||a!==o.Or()||l!==r.v||d!==r.we())return;let p=i.d();c.slice(e.c1,e.c2+1).some((m,g)=>m!==p[e.c1+g])||u.every(({node:m,column:g,oldValue:v},w)=>m.data===h[w]&&Object.is(this.c(m,g),v))&&this.mr(u)}Zd(e,t){let r=[];for(let i=e.r1;i<=e.r2;i++){let o=this.i.f(i);if(!(!o||o.isDetail||o.isGroup))for(let s=e.c1;s<=e.c2;s++){let a=t[s];!a||!j(a)||a.colDef.rowDrag||r.push({node:o,column:a,oldValue:this.c(o,a),newValue:null})}}return r}mr(e){this.V.Wu(e)}ze(){this.V?.Bu()}ol(e,t,r){if(this.x)return;let i=Tt(e);if(i.length===0)return;let o=this.n.d(),s=this.i.P(),a=[],l=t;for(let d of i){let c=this.Tm(l,s);if(!c)break;this.Dm(c.node,d,o,r,a),l=c.index+1}this.mr(a)}Tm(e,t){for(let r=e;r<t;r++){let i=this.i.f(r);if(i&&!i.isDetail&&!i.isGroup)return{index:r,node:i}}return null}xm(e,t){let r=t;for(;r<e.length;){let i=e[r];if(j(i)&&!i.colDef.rowDrag)break;r++}return r}Dm(e,t,r,i,o){let s=i,a=o.length;for(let l of t){if(s=this.xm(r,s),s>=r.length)return;let d=r[s];if(!this.l.J(e,d)){s++;continue}let c=this.c(e,d);try{let u=d.colDef.valueParser?de(this,e,d,l,"clipboard",c):wt(l,typeof c=="number"||d.colDef.cellEditor==="number");o.push({node:e,column:d,oldValue:c,newValue:u})}catch(u){o.splice(a),this.reportError(u,"validate",{rowId:e.id,colId:d.id});return}s++}}lh(){let e=this.a.Lo();if(!e)return Promise.resolve();let t=this.V.Zi(),r=this.i.f(e.row),i=this.n.d()[e.colIdx];if(!r||!i)return Promise.resolve();let o=this.c(r,i),s=this.V.Xr([{node:r,column:i,oldValue:o,newValue:o}]);try{if(typeof navigator<"u"&&navigator.clipboard?.readText)return navigator.clipboard.readText().then(a=>{let l=this.a.Lo();a&&t()&&s()&&l?.row===e.row&&l.colIdx===e.colIdx&&this.i.f(e.row)===r&&this.n.d()[e.colIdx]===i&&this.ol(a,e.row,e.colIdx)}).catch(()=>{})}catch{}return Promise.resolve()}emit(e,t,r=!0){let i={type:e,api:this.api,...t};this.ce.emit(e,i);let o="on"+e.charAt(0).toUpperCase()+e.slice(1),s=this.r[o];if(typeof s=="function")try{s(i)}catch(l){e==="gridError"?console.error("[mach-table] error in onGridError",l):this.reportError(l,`eventHandler.${String(o)}`,{eventType:e})}let a=e==="columnResized"&&!!i.finished;return r&&(a||$a.has(e))&&this.fr(),i}reportError(e,t,r){let i=this.Em(t,e),o=e instanceof Error?e.message:String(e);this.recentErrors.push({code:i,source:t,message:o,timestamp:Date.now(),...r?{context:r}:{}}),this.recentErrors.length>50&&this.recentErrors.splice(0,this.recentErrors.length-50),console.error(`[mach-table] ${i} (${t})`,e),!this.x&&this.emit("gridError",{code:i,error:e,source:t,context:r})}Em(e,t){if(_a.some(i=>e.startsWith(i)))return"DATA_SOURCE_ERROR";let r=t instanceof Error?t.message:String(t);return e==="rowKey"||r.includes("Duplicate row id")?"DATA_INTEGRITY_ERROR":e==="validate"?"VALIDATION_ERROR":e.toLowerCase().includes("renderer")||Wa.has(e)?"RENDERER_ERROR":e.toLowerCase().includes("editor")||e==="editable"?"EDITOR_ERROR":e.startsWith("feature.")?"FEATURE_ERROR":za.some(i=>e.startsWith(i))?"STATE_ERROR":e.startsWith("eventBus.")||e.startsWith("eventHandler.")?"EVENT_HANDLER_ERROR":"GRID_ERROR"}Uh(){return{gridId:this.gridId,version:We,destroyed:this.x,infinite:this.i.m,loading:this.i.gc()||this.r.loading,rowCount:this.i.Nr(),renderedRowCount:this.o.ke.querySelectorAll(".mach-row[data-index]").length,columnCount:this.n.te().length,selectedRowCount:this.h.St().length,dirtyRowCount:this.K.getDirtyRowIds().length,activeFeatures:[...this.activeFeatures].map(([e,t])=>({key:e,...t.feature.version?{version:t.feature.version}:{}})),performance:this.ve.snapshot(),updates:this.pr.snapshot(),recentErrors:this.recentErrors.map(e=>({...e,...e.context?{context:{...e.context}}:{}}))}}ki(e,t){this.n.ki(e,t),this.Ir()}Ir(){this.$.gs(),this.emit("sortChanged",{sortModel:this.n.re()}),this.i.To()}Yu(e,t){let r=this.i._e();t?r[e.id]=t:delete r[e.id],this.i.Dt(r),this.ci()}ci(){this.$.ys(),this.fs(),this.i.To()}fs(e=!0){this.emit("filterChanged",{filterModel:this.i._e(),advancedFilterModel:this.i.Fr()},e)}Mr(e,t){this.n.Mr(e,t)&&(this.Ft(),this.emit("columnMoved",{colId:e,toIndex:t}))}qi(e){return this.i.qi(e)}Za(e,t){this.emit("columnResized",{colId:e.id,width:e.currentWidth,finished:t})}ot(e){if(!(this.x||e.length===0))for(let t of e){if(this.x)break;this.Za(t,!0)}}ms(e=!1,t=!1){let r=this.Js,i=this.Ei,o=this.n.to().length>0;if(e){if(i==null||!o)return;if(i!==r){this.Ei=null,this.fr();return}}this.Ei=null;let s=++this.jd,a=this.r.persistence;if(!a)return;let{key:l,store:d,sections:c}=a;if(!o&&(!c||c.some(p=>p==="columns"||p==="sort"||p==="filter"))){this.Ei=r;return}let u;try{u=d?d.load(l):ir(l)}catch(p){this.reportError(p,"gridState.load");return}let h=(p,m=!1)=>{if(this.x||s!==this.jd||r!==this.Js||!p)return;let g=this.Ri;this.Ri=m?"beforeRows":"normal";try{this.api.state.apply(p,{emitEvents:!1,sections:c})}finally{this.Ri=g}};u&&typeof u.then=="function"?Promise.resolve(u).then(h).catch(p=>this.reportError(p,"gridState.load")):h(u,t)}Ip(){return this.Ri==="beforeRows"}fr(){let e=this.r.persistence;if(!(!e||this.x||this.Ri)&&(this.Js++,this.Ei==null)){if(this.vt&&clearTimeout(this.vt),e.debounceMs===0){this.vt=null,this.ea();return}this.vt=setTimeout(()=>{this.vt=null,this.ea()},e.debounceMs)}}ea(){let e=this.r.persistence;if(!e||this.x)return;let{key:t,store:r,sections:i}=e,o=this.api.state.get(),s=i?xn(o,i):o,a={key:t,...r?{store:r}:{},state:s};if(this.Zs){this.Qs=a;return}this.Qd(a)}Qd(e){try{let t=e.store?e.store.save(e.key,e.state):rr(e.key,e.state);if(!t||typeof t.then!="function")return;this.Zs=!0,Promise.resolve(t).catch(r=>this.reportError(r,"gridState.save")).finally(()=>{this.Zs=!1;let r=this.Qs;this.Qs=null,r&&this.Qd(r)})}catch(t){this.reportError(t,"gridState.save")}}Dh(){let e=f("div","mach-empty mach-empty--error"),t=f("div","mach-empty__title");t.textContent=this.y("requestFailed");let r=f("div","mach-empty__hint");return r.textContent=this.y("requestFailedHint"),e.append(t,r),e}Ch(){let e=f("div","mach-loading"),t=f("div","mach-loading__visual");t.setAttribute("aria-hidden","true");for(let s=0;s<4;s+=1){let a=f("span","mach-loading__row");t.appendChild(a)}let r=f("div","mach-loading__status"),i=f("span","mach-spinner mach-loading__spinner");i.setAttribute("aria-hidden","true");let o=f("span","mach-loading__label");return o.textContent=this.y("loading"),r.append(i,o),e.append(t,r),e}Th(){let e=f("div","mach-empty");e.innerHTML='<svg class="mach-empty__icon" viewBox="0 0 96 84" aria-hidden="true"><rect stroke-opacity=".3" x="8" y="6" width="76" height="66" rx="9"/><path fill="#8b98ff" opacity=".12" stroke="none" d="M17 6H75Q84 6 84 15V26H8V15Q8 6 17 6Z"/><path stroke="var(--mach-body-fg)" opacity=".06" d="M8 26h76M38 26v46M61 26v46M8 42h76M8 57h76"/><path stroke-width="5" opacity=".5" d="M19 15h12m17 0h7m15 0h7"/><path stroke="var(--mach-body-fg)" opacity=".06" stroke-width="4" d="M19 34h12m14 0h8m15 0h8M19 49h12m14 0h8m15 0h8M19 64h12m14 0h8"/><circle stroke-opacity=".3" cx="72" cy="55" r="19"/><circle cx="70" cy="53" r="9"/><path d="m77 60 6 6m-16-16 6 6m0-6-6 6"/></svg>';let{locale:t,manualFiltering:r}=this.r,i=!r&&!this.i.m&&this.i.Oe().length>0&&this.i.Br(),o=f("div","mach-empty__title");o.textContent=i?t.noMatchingRows??t.emptyRows??this.y("noMatchingRows"):this.y("emptyRows");let s=f("div","mach-empty__hint");if(s.textContent=this.y("emptyRowsHint"),e.append(o),(!i||t.emptyRowsHint)&&e.append(s),i){let a=f("button","mach-toolbar__select-host");a.type="button",a.textContent=this.y("clearFilters"),a.onclick=()=>{this.i.Dt({}),this.i.it(null),this.i.xt(null),this.r.quickFilterText=null,this.ci(),this.o.root.focus({preventScroll:!0})},e.append(a)}return e}ps(e){if(!(this.r.suppressWarnings||this.x)){if(e)for(let t of nr(e)){let r=`${t.code}:${t.option??""}:${t.message}`;this.qn.has(r)||(this.qn.add(r),console.warn(`[mach-table:${t.code}] ${t.message}`))}this.r.treeData&&this.n.Xe().length>0&&console.warn("[mach-table] treeData \u4E0E rowGroup \u4E0D\u652F\u6301\u540C\u65F6\u542F\u7528\uFF0C\u884C\u5206\u7EC4\u5DF2\u88AB\u5FFD\u7565")}}Yd(e){if(!(this.r.suppressWarnings||this.x)&&this.ec!==e){this.ec=e;for(let t of Yn(e))this.qn.has(t)||(this.qn.add(t),console.warn(`[mach-table] ${t}`))}}Ft(){this.Ht.Er=!0,this.pr.Al({columns:!0})}U(e){(e.data||e.cells)&&(this.Ht.Er=!0),this.pr.Al(e)}Wl(e){return this.pr.batch(e)}wm(e){this.x||(e.columns?this.Rm():(e.header&&this.$.ui(),e.pool?this.a.hs():e.layout&&this.ye()),this.Sm(e),e.data&&!e.pool&&!e.columns?this.a.tm():e.cells&&this.a.refreshCells(e.cells===!0?void 0:e.cells),e.pinned&&this.Pe.refresh(),e.summary&&this.Ce.refresh(),e.overlays&&this.a.Vs())}Sm(e){if(!(e.data||e.cells)||e.layout||e.columns||e.pool)return;let t=e.data||e.cells===!0?void 0:e.cells;this.Ht.Xn(t)&&this.nr()}Rm(){this.ps(),this.Yd(this.n.to()),this.a.Dn(),this.$.ui(),this.a.hs(),this.ye(),this.Pe.De(),this.Ce.refresh(),this.emit("displayedColumnsChanged",{})}ye(){if(this.x)return;let e=this.ve.start();this.En(),this.Ht.Xn(),this.n.oa(this.o.ds());let t=this.n.d().map(r=>`${r.id}:${r.currentWidth}`).join("|");this.Xs&&t!==this.Xs&&this.a.Dn(),this.Xs=t,this.o.root.setAttribute("aria-colcount",String(this.n.d().length)),this.$.ut(),this.a.ye(),this.Pe.ut(),this.Ce.refresh(),this.ve.bh(e)}En(){if(!this.o.root)return;let e=this.r.treeData||this.n.Xe().length>0;this.o.root.setAttribute("role",e?"treegrid":"grid"),this.r.rowSelection==="multiple"?this.o.root.setAttribute("aria-multiselectable","true"):this.o.root.removeAttribute("aria-multiselectable"),this.n.d().some(r=>!!r.colDef.editable)?this.o.root.removeAttribute("aria-readonly"):this.o.root.setAttribute("aria-readonly","true")}nr(e=!0){this.x||(this.Ht.Xn(),this.n.oa(this.o.ds()),e&&this.a.Dn(),this.$.ut(),this.a.Tn(),this.a.zn(),this.a.hi(!0),this.Pe.ut(),this.Ce.refresh())}destroy(){if(!this.x){if(this.vt&&(clearTimeout(this.vt),this.vt=null,this.ea()),this.x=!0,this.ze(),this.Di&&cancelAnimationFrame(this.Di),this.Di=0,this.api){this.Xd();try{this.emit("gridDestroyed",{})}catch(e){console.error("[mach-table] grid destroy event",e)}}this.E.dispose(),this.ce.clear()}}};function Qn(n,e={}){if(!n)throw new Error("[mach-table] createGrid requires a container element");if(typeof document>"u")throw new Error("[mach-table] createGrid can only be used in a browser environment");return new ar(n,e).api}function Ua(n){return n.mode==="allMatching"?{mode:"allMatching",excludedKeys:[...n.excludedKeys]}:{mode:"explicit",selectedKeys:[...n.selectedKeys]}}function eo(n,e){if(e.scope!=="filtered"&&e.scope!=="selected")throw new TypeError("[MachTable] Remote export scope must be filtered or selected.");let t=n.state.get();return{version:1,scope:e.scope,columnIds:t.columns.filter(r=>!r.hide).map(r=>r.colId),sortModel:t.sortModel.map(r=>({...r})),filterModel:Z(t.filterModel),advancedFilterModel:H(t.advancedFilterModel),quickFilterText:t.quickFilterText,...e.scope==="selected"?{selection:Ua(e.selection??{mode:"explicit",selectedKeys:t.selectedRowIds})}:{}}}function ja(n){return n.value===!0?"\u662F":n.value===!1?"\u5426":""}function qa(n){return e=>{if(e.value==null||e.value==="")return"";let t=e.value instanceof Date?e.value.toISOString():String(e.value);return n==="datetime"?t.slice(0,16).replace("T"," "):t.slice(0,10)}}function Ya(n){return e=>{if(e.value==null)return"";let t=n.find(r=>r.value===e.value);return t?t.label:String(e.value)}}function Xa(n,e){return n.filterable===!1?!1:e==="number"?"number":e==="date"?"date":e==="select"||e==="boolean"?"set":"text"}function Ja(n,e,t){if(e.editable&&(t==="number"||t==="date")&&(n.cellEditor=t),t==="date"){n.valueFormatter=qa(e.format);return}if(t==="boolean"){n.valueFormatter=ja;return}if(t!=="select")return;let r=e.options??[];n.valueFormatter=Ya(r),e.editable&&(n.cellEditor="select",n.cellEditorParams={options:r})}function to(n){let e=n.type??"string",t={colId:n.field,field:n.field,headerName:n.title??n.field,width:n.width,minWidth:n.minWidth,maxWidth:n.maxWidth,flex:n.flex,pinned:n.pinned??void 0,hide:n.hidden??!1,editable:n.editable??!1,sortable:n.sortable??!0,resizable:n.resizable??!0,filter:Xa(n,e),cellClass:n.cellClass};return Ja(t,n,e),t}function ro(n){let e=new Map(n.fields.map(s=>[s.field,s])),t=n.groups??[],r=new Set(t.flatMap(s=>s.fields)),i=new Set,o=[];for(let s of n.fields)i.has(s.field)||r.has(s.field)||(o.push(to(s)),i.add(s.field));for(let s of t){let a=[];for(let l of s.fields){let d=e.get(l);!d||i.has(l)||(a.push(to(d)),i.add(l))}a.length>0&&o.push({groupId:s.groupId,headerName:s.title,children:a})}return o}function P(n){let e=n();return e&&!e.isDestroyed()?e:null}function io(n){let e=()=>n.getApi();return{search(t){P(e)?.filtering.setQuickText(t)},async refresh(){if(n.reload){await n.reload();return}let t=P(e);t&&(t.rows.isRemote()?await t.rows.reload():t.view.refreshCells())},openColumns(t){P(e)?.columns.openWorkbench(t)},setDensity(t){P(e)?.updateOptions({size:t})},selectAll(t=!0){P(e)?.selection.selectAll(t)},clearSelection(){let t=P(e);t?.selection.clear(),t?.selection.clearRange()},resetColumns(){P(e)?.columns.resetState()},resetView(){P(e)?.batch(t=>{t.selection.clear(),t.selection.clearRange(),t.filtering.setModel(null),t.filtering.setAdvancedModel(null),t.sorting.setModel(null),t.pagination.setPage(1),t.columns.resetState()})},undo(){return P(e)?.editing.undo()??!1},redo(){return P(e)?.editing.redo()??!1},canUndo(){return P(e)?.editing.canUndo()??!1},canRedo(){return P(e)?.editing.canRedo()??!1},exportCsv(t="mach-table.csv"){let r=P(e);return r?Bt(t,r.io.exportCsv({prependBOM:!0}),"text/csv;charset=utf-8"):!1},async toggleFullscreen(){if(typeof document>"u")return!1;if(document.fullscreenElement)return await document.exitFullscreen?.(),!1;let r=P(e)?.view.getRoot(),i=n.getFullscreenElement?.()??r?.parentElement??r;return i?.requestFullscreen?(await i.requestFullscreen(),!0):!1}}}function no(){return{accessor:(n,e={})=>({...e,field:n}),display:n=>({...n}),group:n=>({...n,children:[...n.children]})}}function oo(n){return[...n]}function ri(n,e){return e===void 0?n:typeof e!="object"||e===null||typeof n!="object"||n===null?e:{...n,...e}}function Za(n,e){return typeof n!="function"?e:typeof e!="function"?n:(...t)=>{let r;try{n(...t)}catch(i){r=i}try{e(...t)}catch(i){r??(r=i)}if(r!==void 0)throw r}}function Qa(n,e){if(!(!n.components&&!e.components))return{cellRenderers:{...n.components?.cellRenderers,...e.components?.cellRenderers},cellEditors:{...n.components?.cellEditors,...e.components?.cellEditors}}}function el(n,e){if(!n.columnTypes&&!e.columnTypes)return;let t={},r=new Set([...Object.keys(n.columnTypes??{}),...Object.keys(e.columnTypes??{})]);for(let i of r)t[i]={...n.columnTypes?.[i],...e.columnTypes?.[i]};return t}function tl(n,e,t){for(let r of new Set([...Object.keys(e),...Object.keys(t)])){if(!/^on[A-Z]/.test(r))continue;let i=e[r],o=t[r];typeof i!="function"||typeof o!="function"||(n[r]=Za(i,o))}}function rl(n,e){let t={...n,...e,features:e.features??n.features};(n.defaultColDef||e.defaultColDef)&&(t.defaultColDef={...n.defaultColDef,...e.defaultColDef}),(n.locale||e.locale)&&(t.locale={...n.locale,...e.locale});let r=Qa(n,e);r&&(t.components=r);let i=el(n,e);return i&&(t.columnTypes=i),(n.aggFuncs||e.aggFuncs)&&(t.aggFuncs={...n.aggFuncs,...e.aggFuncs}),t.pagination=ri(n.pagination,e.pagination),t.statusBar=ri(n.statusBar,e.statusBar),t.watermark=ri(n.watermark,e.watermark),tl(t,n,e),t}function ii(...n){return n.reduce(rl,{})}function so(n={}){return ii({defaultColDef:{sortable:!0,resizable:!0,movable:!0,filter:!0},enableColumnResize:!0,rowSelection:"multiple",columnMenu:!0,contextMenu:!0,enableRangeSelection:!0,fillHandle:!0,statusBar:!0,stripedRows:!0},n)}function ao(n){return n}function lo(n){return n}function co(n){return n}function dr(n){return n!=null&&n!==""}function il(n){if(!dr(n))return null;let e=typeof n=="number"?n:Number(n);return Number.isFinite(e)?e:null}function lr(n,e){try{return new Intl.NumberFormat(n,e)}catch{return new Intl.NumberFormat(void 0,e)}}function uo(n,e){try{return new Intl.DateTimeFormat(n,e)}catch{let t={...e};return delete t.timeZone,new Intl.DateTimeFormat(void 0,t)}}function nl(n){if(!dr(n))return null;let e=n instanceof Date?n:new Date(n);return Number.isFinite(e.getTime())?e:null}function ho(n={}){let e=n.emptyText??"",t=n.invalidText??"\u2014",r=lr(n.locale,{maximumFractionDigits:n.maximumFractionDigits??2}),i=lr(n.locale,{maximumFractionDigits:0}),o=lr(n.locale,{style:"currency",currency:n.currency??"CNY",currencyDisplay:n.currencyDisplay??"symbol",maximumFractionDigits:n.maximumFractionDigits??2}),s=lr(n.locale,{style:"percent",maximumFractionDigits:n.maximumFractionDigits??2}),a=uo(n.locale,{year:"numeric",month:"2-digit",day:"2-digit",...n.timeZone?{timeZone:n.timeZone}:{}}),l=uo(n.locale,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,...n.timeZone?{timeZone:n.timeZone}:{}}),d=(u,h=1)=>({value:p})=>{if(!dr(p))return e;let m=il(p);return m==null?t:u.format(m*h)},c=u=>({value:h})=>{if(!dr(h))return e;let p=nl(h);return p==null?t:u.format(p)};return Object.freeze({text:{align:"left",filter:"text"},number:{align:"right",filter:"number",cellEditor:"number",valueFormatter:d(r)},integer:{align:"right",filter:"number",cellEditor:"number",valueFormatter:d(i)},money:{align:"right",filter:"number",cellEditor:"number",valueFormatter:d(o)},percent:{align:"right",filter:"number",cellEditor:"number",valueFormatter:d(s)},percentage:{align:"right",filter:"number",cellEditor:"number",valueFormatter:d(s,.01)},date:{align:"center",filter:"date",cellEditor:"date",valueFormatter:c(a)},datetime:{align:"center",filter:"date",valueFormatter:c(l)},boolean:{align:"center",filter:"set",valueFormatter:({value:u})=>u===!0?n.trueText??"\u662F":u===!1?n.falseText??"\u5426":e},status:{filter:"set",cellRenderer:"statusTag"},link:{filter:"text",cellRenderer:"link"}})}function po(){try{return typeof localStorage>"u"?null:localStorage}catch{return null}}function fo(n){return typeof TextEncoder>"u"?n.length*2:new TextEncoder().encode(n).byteLength}function mo(n){if(typeof n!="string")return null;let e=n.trim();return e&&e.length<=256?e:null}function cr(n){if(n==null||typeof n!="object")return null;let e=n;if(e.version!==1)return null;let t=$({version:2,columns:e.columns,sortModel:e.sortModel,filterModel:e.filterModel,advancedFilterModel:e.advancedFilterModel,quickFilterText:e.quickFilterText,pagination:{enabled:!0,page:1,pageSize:e.pageSize},selectedRowIds:[],expandedRowIds:[],expandedGroupIds:[]});return t?{version:1,columns:t.columns,sortModel:t.sortModel,filterModel:t.filterModel,advancedFilterModel:t.advancedFilterModel,quickFilterText:t.quickFilterText,pageSize:t.pagination.pageSize}:null}function xe(n){if(n==null||typeof n!="object")return null;let e=n,t=mo(e.id),r=typeof e.name=="string"?e.name.trim().slice(0,120):"",i=cr(e.state);if(e.schemaVersion!==1||!t||!r||!i)return null;let o=typeof e.createdAt=="number"&&Number.isFinite(e.createdAt)?e.createdAt:Date.now(),s=typeof e.updatedAt=="number"&&Number.isFinite(e.updatedAt)?e.updatedAt:o;return{schemaVersion:1,id:t,name:r,createdAt:o,updatedAt:s,state:i}}function ni(n){let e=n.state.get();return{version:1,columns:e.columns,sortModel:e.sortModel,filterModel:e.filterModel,advancedFilterModel:e.advancedFilterModel,quickFilterText:e.quickFilterText,pageSize:e.pagination.pageSize}}function oi(n,e,t={}){let r=cr(e);if(!r||n.isDestroyed())return!1;let i=n.state.get();return n.state.apply({...i,columns:r.columns,sortModel:r.sortModel,filterModel:r.filterModel,advancedFilterModel:r.advancedFilterModel,quickFilterText:r.quickFilterText,pagination:{...i.pagination,page:1,pageSize:r.pageSize}},{sections:["columns","sort","filter","pagination"],emitEvents:t.emitEvents}),!0}function si(n={}){let e=(n.namespace??"mach-table:views").replace(/:+$/,""),t=Math.max(1,Math.floor(n.maxViews??50)),r=Math.max(4096,Math.floor(n.maxBytes??512*1024)),i=l=>`${e}:${encodeURIComponent(l)}`,o=(l,d,c)=>{try{n.onError?.(l,d,c)}catch{}},s=l=>{let d=(n.storage??po())?.getItem(i(l));if(!d||fo(d)>r)return[];let c=JSON.parse(d);return c.schemaVersion!==1||!Array.isArray(c.views)?[]:c.views.flatMap(u=>{let h=xe(u);return h?[h]:[]}).slice(0,t)},a=(l,d)=>{let c=JSON.stringify({schemaVersion:1,savedAt:Date.now(),views:d});if(fo(c)>r)throw new RangeError(`[MachTable] Saved views for "${l}" exceed ${r} bytes.`);let u=n.storage??po();if(!u)throw new Error("[MachTable] Saved view storage is unavailable.");u.setItem(i(l),c)};return{list(l){try{return s(l)}catch(d){return o(d,"list",l),[]}},save(l,d){try{let c=xe(d);if(!c)throw new TypeError(`[MachTable] Invalid saved view for "${l}".`);let u=s(l).filter(h=>h.id!==c.id);u.unshift(c),a(l,u.slice(0,t))}catch(c){throw o(c,"save",l),c}},remove(l,d){try{a(l,s(l).filter(c=>c.id!==d))}catch(c){throw o(c,"remove",l),c}}}}function ol(){try{if(typeof crypto<"u"&&crypto.randomUUID)return crypto.randomUUID()}catch{}return`view-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function go(n,e){let t=e.scope.trim();if(!t||t.length>512)throw new TypeError("[MachTable] Grid view scope must contain between 1 and 512 characters.");let r=e.store??si(),i=async()=>(await r.list(t)).flatMap(s=>{let a=xe(s);return a?[a]:[]}).sort((s,a)=>a.updatedAt-s.updatedAt);return{list:i,async save(o,s){let a=o.trim().slice(0,120);if(!a)throw new TypeError("[MachTable] Grid view name must be a non-empty string.");let l=mo(s)??ol(),d=(await i()).find(h=>h.id===l),c=Date.now(),u={schemaVersion:1,id:l,name:a,createdAt:d?.createdAt??c,updatedAt:c,state:ni(n)};return await r.save(t,u),u},async apply(o,s){let a=typeof o=="string"?(await i()).find(d=>d.id===o):xe(o),l=typeof o=="string"?o:"provided view";if(!a)throw new Error(`[MachTable] Grid view "${l}" was not found.`);if(!oi(n,a.state,s))throw new Error(`[MachTable] Grid view "${a.id}" could not be applied.`);return a},async remove(o){await r.remove(t,o)}}}var sl=We;0&&(module.exports={BUILTIN_AGG_FUNCS,DEFAULT_LOCALE,EVENT_TYPES,LOCALE_EN,actionsColumn,advancedFilterCondition,advancedFilterGroup,applyGridViewState,buildColDefsFromSchema,captureGridViewState,clearGridState,createActionButtonsRenderer,createAggResolver,createBusinessColumnTypes,createColumnHelper,createEnterprisePreset,createGrid,createGridViewManager,createLocalGridStateStore,createLocalGridViewStore,createMachTableCommands,createMachTablePreset,createProgressBarRenderer,createRemoteExportRequest,createRowActionsRenderer,createStatusTagRenderer,defineColumns,defineGridOptions,defineMachTableConfig,defineMachTablePreset,describeFilter,downloadFile,dragColumn,escapeHtml,formatText,formatTwo,getByPath,indexColumn,isColDefGroup,isSafePath,linkRenderer,loadGridState,matchLocaleKey,normalizeAdvancedFilterModel,normalizeColumnFilter,normalizeFilterModel,normalizeGridState,normalizeGridViewState,normalizeSavedGridView,parseCsv,parseDelimited,parseTsv,resolveGridFeatures,resolveSaveConflict,resolveTagVariant,rowActionsColumn,sanitizeFormulaCell,saveGridState,selectionColumn,setByPath,toTsv,validateGridOptions,version});