@opencorestack/opengridx 3.9.0 → 3.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/README.md +11 -7
- package/dist/index.d.ts +55 -0
- package/dist/opengridx.es.js +6346 -6279
- package/dist/opengridx.es.js.map +1 -1
- package/dist/opengridx.umd.js +16 -16
- package/dist/opengridx.umd.js.map +1 -1
- package/docs/API_REFERENCE.md +4 -0
- package/docs/architecture/datagrid-orchestration.md +4 -2
- package/docs/architecture/use-grid-virtualization.md +2 -0
- package/docs/components/pagination.md +1 -1
- package/docs/features/ai-toolkit.md +1 -0
- package/docs/features/rtl.md +1 -1
- package/docs/performance.md +19 -1
- package/docs/roadmap.md +26 -5
- package/lib/components/Cell/Cell.tsx +2 -1
- package/lib/components/DataGrid/DataGrid.tsx +19 -18
- package/lib/components/DataGrid/GridListView.tsx +1 -1
- package/lib/components/DataGrid/GridPinnedRows.tsx +1 -1
- package/lib/components/DataGrid/GridViewport.tsx +2 -1
- package/lib/components/DataGrid/GridVirtualRows.tsx +1 -1
- package/lib/components/Header/Header.tsx +4 -3
- package/lib/components/Row/Row.tsx +6 -2
- package/lib/components/Toolbar/AggregationPanel.tsx +90 -0
- package/lib/components/Toolbar/ColumnsPanelWrapper.tsx +56 -0
- package/lib/components/Toolbar/FilterPanelWrapper.tsx +82 -0
- package/lib/components/Toolbar/GridToolbar.tsx +7 -380
- package/lib/components/Toolbar/ToolbarIcons.tsx +35 -0
- package/lib/components/Toolbar/useToolbarPanel.ts +71 -0
- package/lib/hooks/core/gridKeyDown.ts +272 -0
- package/lib/hooks/core/useDataGrid.ts +13 -5
- package/lib/hooks/core/useGridApiMethods.ts +2 -2
- package/lib/hooks/core/useGridCellRangeDrag.ts +345 -0
- package/lib/hooks/core/useGridCellSelection.ts +17 -297
- package/lib/hooks/core/useGridColumnLookup.ts +2 -1
- package/lib/hooks/core/useGridColumns.tsx +3 -2
- package/lib/hooks/core/useGridControlledState.ts +3 -2
- package/lib/hooks/core/useGridHierarchy.ts +1 -1
- package/lib/hooks/core/useGridKeyboardNavigation.ts +51 -235
- package/lib/hooks/core/useGridLiveRowSelection.ts +2 -2
- package/lib/hooks/core/useGridRowInteractions.ts +1 -1
- package/lib/hooks/core/useGridRowSelection.ts +11 -2
- package/lib/hooks/core/useGridToolbarProps.ts +3 -2
- package/lib/hooks/features/useGridAiAssistant.ts +3 -2
- package/lib/hooks/useColumnReorder.ts +2 -1
- package/lib/hooks/useTreeData.ts +4 -2
- package/lib/types/locale.ts +22 -0
- package/lib/utils/aggregation/index.ts +16 -0
- package/lib/utils/aiAssistant.ts +46 -15
- package/lib/utils/export/excelCells.ts +244 -0
- package/lib/utils/export/exportCsv.ts +179 -0
- package/lib/utils/export/exportExcelHtml.ts +220 -0
- package/lib/utils/export/exportJson.ts +179 -0
- package/lib/utils/export/exportRows.ts +85 -0
- package/lib/utils/export/exportToExcelAdvanced.ts +22 -242
- package/lib/utils/export/index.ts +5 -695
- package/lib/utils/export/printGrid.ts +282 -0
- package/lib/utils/gridLocale.ts +30 -0
- package/lib/utils/selectionSets.ts +36 -0
- package/lib/utils/untypedColumns.ts +16 -0
- package/llms.txt +3 -1
- package/package.json +6 -2
- package/lib/theme/__baseline__/default-theme.darwin.chromium.json +0 -1
- package/lib/theme/__baseline__/default-theme.darwin.firefox.json +0 -1
- package/lib/theme/__baseline__/default-theme.darwin.webkit.json +0 -1
package/dist/opengridx.umd.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
(function(ke,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("react/jsx-runtime"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-dom"],d):(ke=typeof globalThis<"u"?globalThis:ke||self,d(ke.OpenGridX={},ke.ReactJSXRuntime,ke.React,ke.ReactDOM))})(this,(function(ke,d,s,at){"use strict";"use client";function go(e,t,n){return Math.max(t??0,Math.min(n??1/0,e))}function yt(e,t,n=100){if(e.isSpacer)return typeof e.width=="number"?e.width:0;const o=t[e.field]??e.width,r=typeof o=="number"&&Number.isFinite(o)?o:n;return go(r,e.minWidth,e.maxWidth)}const We=48;function nt(e,t){return t?t.left?.includes(e)?"left":t.right?.includes(e)?"right":null:null}function ya(e,t){const n=[],o=[],r=[];return t?(e.forEach(i=>{const l=nt(i.field,t);l==="left"?n.push(i):l==="right"?r.push(i):o.push(i)}),t.left&&n.sort((i,l)=>{const c=t.left.indexOf(i.field),a=t.left.indexOf(l.field);return c-a}),t.right&&r.sort((i,l)=>{const c=t.right.indexOf(i.field),a=t.right.indexOf(l.field);return c-a}),{left:n,center:o,right:r}):{left:n,center:e,right:r}}function po(e,t,n,o,r,i,l,c){const a={};if(!n)return a;let u=(c?We:0)+(i&&l?We:0)+(o&&r?We:0);const f=[];e.forEach(b=>{if(b.isSpacer)return;const x=nt(b.field,n);x==="left"?(a[b.field]=u,u+=yt(b,t)):x==="right"&&f.push(b)});let p=0;for(let b=f.length-1;b>=0;b--)a[f[b].field]=p,p+=yt(f[b],t);return a}function ho(e,t){let n=null,o=null;if(!t)return{lastLeft:n,firstRight:o};for(const r of e){if(r.isSpacer)continue;const i=nt(r.field,t);i==="left"?n=r.field:i==="right"&&o===null&&(o=r.field)}return{lastLeft:n,firstRight:o}}function Kr(e,t){return t?t.top?.includes(e)?"top":t.bottom?.includes(e)?"bottom":null:null}function va(e,t,n=o=>o.id){const o=[],r=[],i=[];return t?(e.forEach(l=>{const c=Kr(n(l),t);c==="top"?o.push(l):c==="bottom"?i.push(l):r.push(l)}),t.top&&o.sort((l,c)=>{const a=t.top.indexOf(n(l)),u=t.top.indexOf(n(c));return a-u}),t.bottom&&i.sort((l,c)=>{const a=t.bottom.indexOf(n(l)),u=t.bottom.indexOf(n(c));return a-u}),{top:o,center:r,bottom:i}):{top:o,center:e,bottom:i}}function Sa(e,t,n){const o=(e?.left??[]).filter(i=>i!==t),r=(e?.right??[]).filter(i=>i!==t);return n==="left"?{left:[...o,t],right:r}:n==="right"?{left:o,right:[...r,t]}:{left:o,right:r}}const jr=new Set;function vt(e,t,n){process.env.NODE_ENV==="production"||jr.has(e)||(jr.add(e),console.warn(`[OpenGridX] ${t}.`,n))}function mo(e,t,n,o){try{return e()}catch(r){return vt(n,o,r),t}}function qr(e,t,n){const o=e[t];if(!n?.valueGetter)return{value:o};try{return{value:n.valueGetter({row:e,field:t,value:o})}}catch(r){return{value:void 0,error:r??new Error("valueGetter failed")}}}function Me(e,t,n){if(!n?.valueGetter)return e[t];const{value:o,error:r}=qr(e,t,n);return r!==void 0&&vt(`valueGetter:${t}`,`valueGetter for column "${t}" threw; the value is read as undefined`,r),o}function wo(e,t,n,o){const r=o?.valueFormatter;if(r)try{return r({value:n,row:e,field:t})}catch(i){vt(`valueFormatter:${t}`,`valueFormatter for column "${t}" threw; the value is shown unformatted`,i);return}}const _a=/^[+-]?0[box]/i;function ot(e){if(e==null)return null;if(typeof e=="number")return Number.isNaN(e)?null:e;if(typeof e=="string"){const t=e.trim();if(t===""||_a.test(t))return null;const n=Number(t);return Number.isFinite(n)?n:null}if(typeof e=="boolean")return null;if(e instanceof Date){const t=e.getTime();return Number.isNaN(t)?null:t}return typeof e=="bigint"?Number(e):null}const ka=/^(\d{4})-(\d{2})-(\d{2})$/;function tn(e){if(e==null)return null;let t;if(e instanceof Date)t=e;else if(typeof e=="number")t=new Date(e);else if(typeof e=="string"){const n=e.trim();if(n==="")return null;const o=ka.exec(n);if(o){const r=Number(o[1]),i=Number(o[2])-1,l=Number(o[3]);if(t=new Date(r,i,l),t.getMonth()!==i||t.getDate()!==l)return null}else{if(!Aa(n))return null;t=new Date(n)}}else return null;return Number.isNaN(t.getTime())?null:t}const Ea=["january","february","march","april","may","june","july","august","september","october","november","december","monday","tuesday","wednesday","thursday","friday","saturday","sunday"],Ma=new Set(["t","z","am","pm","gmt","utc","sept"]);function La(e){return Ma.has(e)?!0:e.length>=3&&Ea.some(t=>t.startsWith(e))}function Aa(e){let t="";for(let n=0;n<=e.length;n++){const o=n<e.length?e[n].toLowerCase():"";if(o>="a"&&o<="z"){t+=o;continue}if(t!==""&&!La(t))return!1;t=""}return!0}function Ln(e){const t=tn(e);return t?t.getFullYear()*1e4+(t.getMonth()+1)*100+t.getDate():null}function Xr(e){const t=tn(e);if(!t)return"";const n=String(t.getFullYear()).padStart(4,"0"),o=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${n}-${o}-${r}`}let Yr=null;function Jr(e){return Yr??=new Intl.DateTimeFormat,Yr.format(e)}function Pa(e,t){if(!e)return;const n=i=>typeof i=="object"?i.value:i,o=i=>typeof i=="object"?i.label:String(i),r=e.find(i=>Object.is(n(i),t))??e.find(i=>String(n(i))===String(t));return r===void 0?void 0:o(r)}function An(e,t){if(e==null)return"";switch(t?.type){case"date":{const n=tn(e);return n?Jr(n):String(e)}case"boolean":return e===!0?"Yes":e===!1?"No":String(e);case"singleSelect":return Pa(t.valueOptions,e)??String(e);default:return String(e)}}const bo=200;function xo(e){if(e==="auto")return"auto";const t=typeof e=="string"?Number.parseFloat(e):e;return typeof t=="number"&&Number.isFinite(t)&&t>=0?t:bo}function Co(e,t){if(e)return mo(()=>e(t),void 0,"getDetailPanelHeight","getDetailPanelHeight threw; the panel uses the default height")}function Ia(e,t){const n=xo(e);return n==="auto"?t??bo:n}function Na(e,t){if(t.size===0||e.size===0)return e;let n=!1;const o=new Set;for(const r of e)t.get(r)?.isGroupRow?n=!0:o.add(r);return n?o:e}const Fa=e=>e.id;function Ta(e){if(e===void 0)return{type:"auto",value:0};if(typeof e=="number")return{type:"fixed",value:e};if(typeof e=="string"){if(e.toLowerCase()==="auto")return{type:"auto",value:0};if(e.endsWith("%"))return{type:"percentage",value:parseFloat(e)};const t=parseFloat(e);if(!isNaN(t))return{type:"fixed",value:t}}return{type:"fixed",value:100}}function Oa(e,t,n){const o=new Map;e.forEach(g=>{if(!Object.prototype.hasOwnProperty.call(t,g.field)&&g.flex&&g.flex>0){o.set(g.field,{kind:"flex",flex:g.flex});return}const m=Ta(t[g.field]??g.width);m.type==="fixed"?o.set(g.field,{kind:"fixed",width:go(m.value,g.minWidth,g.maxWidth)}):m.type==="percentage"?o.set(g.field,{kind:"percentage",percentage:m.value}):o.set(g.field,{kind:"flex",flex:1})});const r=e.reduce((g,h)=>{const m=o.get(h.field);if(m.kind==="fixed")return g+m.width;if(m.kind==="percentage")return g+100;if(h.flex&&h.flex>0){const C=h.minWidth??150;return g+(C||(typeof h.width=="number"?h.width:150))}return g+(h.minWidth??150)},0),i=Math.max(n,r),l=e.reduce((g,h)=>{const m=o.get(h.field);return m.kind==="fixed"?g+m.width:g},0),c=new Map,a=Math.max(0,i-l);let u=0;e.forEach(g=>{const h=o.get(g.field);if(h.kind==="fixed")c.set(g.field,h.width);else if(h.kind==="percentage"){const m=h.percentage/100*a,C=go(m>0?m:100,g.minWidth??50,g.maxWidth);c.set(g.field,C),u+=C}});const f=Math.max(0,a-u),p=new Map,b=e.flatMap(g=>{const h=o.get(g.field);return h.kind!=="flex"?[]:(p.set(g.field,h.flex),[{field:g.field,flex:h.flex,minWidth:g.minWidth??50,maxWidth:g.maxWidth??1/0,frozen:!1,computedWidth:0}])});let x=0;const w=b.length*2;for(;x<w;){x++;const g=b.filter(M=>!M.frozen);if(g.length===0)break;const h=g.reduce((M,E)=>M+E.flex,0),m=b.reduce((M,E)=>E.frozen?M+E.computedWidth:M,0),C=Math.max(0,f-m);if(h<=0){g.forEach(M=>{M.computedWidth=M.minWidth,M.frozen=!0});break}const y=C/h;let _=0;const v=[],k=[];if(g.forEach(M=>{const E=y*M.flex;E<M.minWidth?(_+=M.minWidth-E,v.push(M)):E>M.maxWidth?(_+=M.maxWidth-E,k.push(M)):M.computedWidth=E}),v.length===0&&k.length===0){g.forEach(M=>{M.frozen=!0});break}_>0?v.forEach(M=>{M.computedWidth=M.minWidth,M.frozen=!0}):_<0?k.forEach(M=>{M.computedWidth=M.maxWidth,M.frozen=!0}):(v.forEach(M=>{M.computedWidth=M.minWidth,M.frozen=!0}),k.forEach(M=>{M.computedWidth=M.maxWidth,M.frozen=!0}))}return b.forEach(g=>c.set(g.field,g.computedWidth)),{widths:c,flexByField:p}}function Da(e){const{rowHeight:t,pagination:n,paginatedUnpinnedRows:o,sortedUnpinnedRows:r,expandedRowIds:i,getDetailPanelHeight:l,detailPanelHeights:c,pinnedTopRowsLength:a,pinnedBottomRowsLength:u,pinnedTopRows:f,pinnedBottomRows:p,visibleOrderedColumns:b,pinnedColumns:x,columnWidths:w,viewportWidth:g,checkboxSelection:h,hasDetailPanel:m,rowReordering:C,pinCheckboxColumn:y,pinExpandColumn:_,paginationMode:v,isLoading:k,pageSize:M,getRowId:E=Fa}=e,I=s.useMemo(()=>{const N=n?o:r,S=(R,te)=>{const ie=E(R);if(!i.has(ie))return t;const ce=Co(l,{row:R,id:ie,rowIndex:te});return t+Ia(ce,c?.get(ie))},F=N.length,T=new Array(F),P=new Array(F),A=i.size>0;let G=0;for(let R=0;R<F;R++){const te=A?S(N[R],a+R):t;T[R]=te,G=(G||0)+te,P[R]=G}const z=v==="infinite"&&k&&N.length>0?Math.min(M,20):0,H=(P[P.length-1]||0)+z*t,Y=(R,te)=>R?R.reduce((ie,ce,J)=>ie+S(ce,J),0):te*t,K=Y(f,a),re=Y(p,u);return{rowHeights:T,cumulativeHeights:P,unpinnedRowsHeight:H,pinnedTopHeight:K,pinnedBottomHeight:re,pinnedTopRowsLength:a,pinnedBottomRowsLength:u,unpinnedRowsLength:F}},[t,n,o,r,i,l,c,a,u,f,p,v,k,M,E]),L=s.useMemo(()=>{const{left:N,center:S,right:F}=ya(b,x),T=(h?We:0)+(m?We:0)+(C?We:0),P=(C?We:0)+(m&&_?We:0)+(h&&y?We:0),{widths:A,flexByField:G}=Oa([...N,...S,...F],w,g-T),z=B=>A.get(B.field)??100,H=B=>({...B,width:z(B),flex:G.get(B.field)??B.flex}),Y=11,K=N.map((B,W)=>({...H(B),zIndex:Y+W})),re=11,R=F.map((B,W)=>({...H(B),zIndex:re+(F.length-1-W)})),te=S.map(H),ie=te.map(B=>B.width),ce=K.reduce((B,W)=>B+W.width,0),J=R.reduce((B,W)=>B+W.width,0),se=ie.reduce((B,W)=>B+W,0),ne=ce+se+J+T,j=ie.reduce((B,W,ae)=>(B.push((B[ae-1]||0)+W),B),[]);return{leftPinnedCols:K,rightPinnedCols:R,unpinnedColsWithWidth:te,unpinnedColWidths:ie,unpinnedAccWidths:j,totalWidth:ne,leftWidth:ce,rightWidth:J,unpinnedTotalWidth:se,systemColumnsWidth:T,pinnedSystemColumnsWidth:P}},[b,x,w,g,h,m,C,y,_]);return s.useMemo(()=>({...I,...L}),[I,L])}function Ye(e){if(!e)return!1;const t=e.ownerDocument.defaultView;return t?t.getComputedStyle(e).direction==="rtl":!1}function Pn(e,t){return t?e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e:e}function $t(e){return Ye(e)?-e.scrollLeft:e.scrollLeft}function nn(e,t){e.scrollLeft=Ye(e)?-t:t}function In(e,t){if(!e)return{top:0,right:0};const n=e.getBoundingClientRect();return Ye(e)?{top:n.bottom+6,left:n.left}:{top:n.bottom+6,right:t-n.right}}function $a(e){const t=e.querySelector(".ogx__sticky-bottom");return t?t.getBoundingClientRect().height:0}function Nn(e,t,n,o,r){if(t<0||t>=n.length)return;const i=e.querySelector(".ogx__virtual-container");if(!i)return;const{scrollTop:l,clientHeight:c}=e,a=i.getBoundingClientRect().top-e.getBoundingClientRect().top+l,u=Math.max(o,$a(e)),f=a+(t===0?0:n[t-1]),p=r!==void 0?Math.min(f+r,a+n[t]):a+n[t];f<l+a?e.scrollTop=Math.max(0,f-a):p>l+c-u&&(e.scrollTop=p-c+u)}function yo(e,t,n){const{unpinnedAccWidths:o,leftWidth:r,rightWidth:i,systemColumnsWidth:l,pinnedSystemColumnsWidth:c}=n;if(t<0||t>=o.length)return;const a=l+r,u=a+(t>0?o[t-1]:0),f=a+o[t],p=c+r,{clientWidth:b}=e,x=$t(e);u<x+p?nn(e,Math.max(0,u-p)):f>x+b-i&&nn(e,f-b+i)}function vo(e,t){const{row:n,field:o,value:r,colDef:i,rowIndex:l,colIndex:c,rowMeta:a}=e;if(!i.editable||a?.isGroupRow)return!1;if(!t)return!0;try{return!!t({row:n,field:o,value:r,colDef:i,rowIndex:l,colIndex:c})}catch{return!1}}const Ga={},on=e=>e==null||typeof e=="string"&&e.trim()==="",Zr=e=>{const t=[];for(const n of e){const o=ot(n);o!==null&&t.push(o)}return t},Qr=(e,t)=>{let n=null,o=null;for(const r of e){const i=ot(r);i!==null&&(n===null||t(i,n))&&(n=i,o=r)}return n===null?null:o instanceof Date?o:n},ct={sum:e=>Zr(e).reduce((t,n)=>t+n,0),avg:e=>{const t=Zr(e);return t.length?t.reduce((n,o)=>n+o,0)/t.length:null},count:e=>e.filter(t=>!on(t)).length,min:e=>Qr(e,(t,n)=>t<n),max:e=>Qr(e,(t,n)=>t>n),unique:e=>new Set(e.filter(t=>!on(t))).size};function So(e,t){return e?e.aggregable===!1?!1:!e.availableAggregationFunctions||e.availableAggregationFunctions.includes(t):!0}function Fn(e,t,n,o){const r={};for(const[i,l]of Object.entries(t)){const c=n.get(i);if(!So(c,l))continue;const a=ct[l];if(!a){console.warn(`[${o}] Unknown aggregation function: "${l}"`);continue}r[i]=Object.prototype.hasOwnProperty.call(ct,l)?Ha(e,i,c,l):a(e.map(u=>Me(u,i,c)))}return r}function Ha(e,t,n,o){switch(o){case"sum":case"avg":{let r=0,i=0;for(const l of e){const c=ot(Me(l,t,n));c!==null&&(r+=c,i++)}return o==="sum"?r:i?r/i:null}case"count":{let r=0;for(const i of e)on(Me(i,t,n))||r++;return r}case"min":case"max":{const r=o==="min";let i=null,l=null;for(const c of e){const a=Me(c,t,n),u=ot(a);u!==null&&(i===null||(r?u<i:u>i))&&(i=u,l=a)}return i===null?null:l instanceof Date?l:i}case"unique":{const r=new Set;for(const i of e){const l=Me(i,t,n);on(l)||r.add(l)}return r.size}}}function rn(e,t){return e==null?"—":typeof e=="number"?t==="avg"?e.toLocaleString(void 0,{maximumFractionDigits:2}):e.toLocaleString():String(e)}const Ba=new Set(["count","unique"]);function ei(e){return e!==void 0&&Ba.has(e)}function ti(e,t,n){return e?.type==="date"&&(t==="min"||t==="max")&&typeof n=="number"&&Number.isFinite(n)?new Date(n):n}function Tn(e,t,n,o){if(e==null)return"—";if(ei(t))return rn(e,t);const r=ti(n,t,e);if(n?.valueFormatter)try{return String(n.valueFormatter({value:r,row:o??{},field:n.field})??"")}catch{}return r instanceof Date?Number.isNaN(r.getTime())?"":Jr(r):rn(r,t)}const Gt=new Set(["isEmpty","isNotEmpty"]);function _o(e){return e==null?!0:typeof e=="string"?e.trim()==="":Array.isArray(e)?e.length===0:!1}function Wa(e){return e==null?!0:typeof e=="number"?Number.isNaN(e):typeof e=="string"&&e.trim()===""}const ln=e=>(t,n)=>{const o=ot(t),r=ot(n);return o===null||r===null?!1:e(o,r)},sn=e=>(t,n)=>{const o=Ln(t),r=Ln(n);return o===null||r===null?!1:e(o,r)},ni=sn((e,t)=>e===t),oi=(e,t)=>{const n=Ln(e),o=Ln(t);return n===null||o===null?!0:n!==o},ri={contains:(e,t)=>e==null||t==null?!1:String(e).toLowerCase().includes(String(t).toLowerCase()),equals:(e,t)=>e==null&&t==null?!0:e==null||t==null?!1:String(e).toLowerCase()===String(t).toLowerCase(),startsWith:(e,t)=>e==null||t==null?!1:String(e).toLowerCase().startsWith(String(t).toLowerCase()),endsWith:(e,t)=>e==null||t==null?!1:String(e).toLowerCase().endsWith(String(t).toLowerCase()),isEmpty:e=>e==null||String(e).trim()==="",isNotEmpty:e=>e!=null&&String(e).trim()!=="","=":ln((e,t)=>e===t),">":ln((e,t)=>e>t),">=":ln((e,t)=>e>=t),"<":ln((e,t)=>e<t),"<=":ln((e,t)=>e<=t),"!=":(e,t)=>{if(_o(t))return!0;const n=ot(e),o=ot(t);return n!==null&&o!==null?n!==o:Wa(e)?!0:String(e).toLowerCase()!==String(t).toLowerCase()},isAnyOf:(e,t)=>{if(e==null)return!1;const n=Array.isArray(t)?t:[t],o=String(e).toLowerCase();return n.some(r=>r!=null&&String(r).toLowerCase()===o)},not:(e,t)=>e instanceof Date?oi(e,t):e==null&&t==null?!1:e==null||t==null?!0:String(e).toLowerCase()!==String(t).toLowerCase(),is:(e,t)=>t==null||t===""?!0:e instanceof Date?ni(e,t):String(e).toLowerCase()===String(t).toLowerCase(),after:sn((e,t)=>e>t),onOrAfter:sn((e,t)=>e>=t),before:sn((e,t)=>e<t),onOrBefore:sn((e,t)=>e<=t)},Va={is:ni,not:oi};function za(e,t){if(!Object.prototype.hasOwnProperty.call(ri,e))return;const n=e;if(t?.type==="date"){const o=Va[n];if(o)return o}return ri[n]}function Ra(e){return"items"in e&&Array.isArray(e.items)}function Ua(e,t){const{field:n,operator:o,value:r}=e;if(!Gt.has(o)&&_o(r))return null;const i=t.columns?.byField.get(n),l=za(o,i);return l?c=>l(Me(c,n,i),r):(t.warned.has(o)||(t.warned.add(o),console.warn(`Unknown filter operator: ${o}`)),null)}function ko(e,t,n){const o=[];for(const r of e){const i=Ra(r)?ko(r.items,r.logicOperator,n):Ua(r,n);i&&o.push(i)}return o.length===0?null:o.length===1?o[0]:t==="or"?r=>o.some(i=>i(r)):r=>o.every(i=>i(r))}function Eo(e,t){if(t!=null){switch(typeof t){case"string":e.push(t.toLowerCase());return;case"number":Number.isNaN(t)||e.push(String(t));return;case"boolean":case"bigint":e.push(String(t));return}if(t instanceof Date){const n=Xr(t);n&&e.push(n);return}if(Array.isArray(t))for(const n of t)(n==null||typeof n!="object")&&Eo(e,n)}}function Mo(e,t){const n=[];if(!t){for(const o of Object.values(e))Eo(n,o);return n}for(const o of t.quickFilterColumns){const r=Me(e,o.field,o),i=wo(e,o.field,r,o);if(i!=null&&i!=="")n.push(String(i).toLowerCase());else if(o.type==="date"||o.type==="boolean"||o.type==="singleSelect"){const l=An(r,o);l!==""&&n.push(l.toLowerCase())}Eo(n,r)}return n}const ii=new WeakMap;function Ka(e,t){if(!t)return Mo(e,t);let n=ii.get(t);n||(n=new WeakMap,ii.set(t,n));let o=n.get(e);return o||(o=Mo(e,t),n.set(e,o)),o}function li(e){return(e??[]).map(t=>String(t??"").trim().toLowerCase()).filter(t=>t!=="")}function si(e,t){for(let n=0;n<t.length;n++){const o=t[n];let r=!1;for(let i=0;i<e.length;i++)if(e[i].includes(o)){r=!0;break}if(!r)return!1}return!0}function ja(e,t){const n=li(e);return n.length===0?null:o=>si(Ka(o,t),n)}const ai=new WeakMap;function qa(e,t){const n=ai.get(t);if(n&&n.rows===e)return n.texts;const o=new Array(e.length);for(let r=0;r<e.length;r++){const i=e[r];o[r]=n&&r<n.rows.length&&n.rows[r]===i?n.texts[r]:Mo(i,t)}return ai.set(t,{rows:e,texts:o}),o}function On(e,t){if(!e)return null;const n={columns:t,warned:new Set},o="quickFilterValues"in e?e.quickFilterValues:void 0,r=ja(o,t),i=ko(e.items??[],e.logicOperator??"and",n);return r&&i?l=>r(l)&&i(l):r??i}function Lo(e,t,n){const o=n&&t?li(t.quickFilterValues):[];if(n&&o.length>0){const i=ko(t.items??[],t.logicOperator??"and",{columns:n,warned:new Set}),l=qa(e,n),c=[];for(let a=0;a<e.length;a++)si(l[a],o)&&(!i||i(e[a]))&&c.push(e[a]);return c}const r=On(t,n);return r?e.filter(i=>r(i)):e}function ci(e){switch(e){case"number":return["=","!=",">",">=","<","<=","isEmpty","isNotEmpty"];case"date":return["is","not","after","onOrAfter","before","onOrBefore","isEmpty","isNotEmpty"];case"boolean":return["is"];case"singleSelect":return["isAnyOf","is","not"];default:return["contains","equals","startsWith","endsWith","isEmpty","isNotEmpty"]}}function Ao(e,t){return e==null?"":t==="date"||e instanceof Date?Xr(e)||(typeof e=="string"?e:""):Array.isArray(e)?e.map(n=>String(n)).join(", "):String(e)}const Po=new Intl.Collator(void 0,{numeric:!0,sensitivity:"accent"}),Ht=0,di=1,Xa=2,Io=3,Dn=4;function an(e,t){return{rank:e,num:t,str:""}}function $n(e,t){if(e==null)return null;if(t==="number"){if(typeof e=="bigint")return{rank:Ht,num:Number(e),str:"",big:e};const n=ot(e);return n===null?null:an(Ht,n)}if(t==="date"){const n=tn(e);return n?an(di,n.getTime()):null}switch(typeof e){case"number":return Number.isNaN(e)?null:an(Ht,e);case"bigint":return{rank:Ht,num:Number(e),str:"",big:e};case"boolean":return an(Xa,e?1:0);case"string":return{rank:Io,num:0,str:e}}if(e instanceof Date){const n=e.getTime();return Number.isNaN(n)?null:an(di,n)}return{rank:Dn,num:0,str:String(e)}}function ui(e,t){return e===null&&t===null?0:e===null?1:t===null?-1:e.rank!==t.rank?e.rank-t.rank:e.rank===Io||e.rank===Dn?Po.compare(e.str,t.str):e.num!==t.num?e.num<t.num?-1:1:e.big!==void 0||t.big!==void 0?Gn(e.big??e.num,t.big??t.num):0}function Gn(e,t){if(typeof e=="number"&&typeof t=="number"||typeof e=="bigint"&&typeof t=="bigint")return e<t?-1:e>t?1:0;if(typeof e=="number")return-Gn(t,e);const n=t;if(!Number.isFinite(n))return n>0?-1:1;const o=Math.floor(n),r=BigInt(o);return e<r?-1:e>r?1:n>o?-1:0}const Ya=e=>typeof e=="bigint"&&(e>BigInt(Number.MAX_SAFE_INTEGER)||e<BigInt(Number.MIN_SAFE_INTEGER));function No(e,t){return e===0?0:t==="asc"?e:-e}function Ja(e,t,n,o){return No(ui($n(e,o),$n(t,o)),n)}function fi(e,t,n){let o;try{o=e(t.value,n.value,t,n)}catch(r){return vt(`sortComparator:${t.field}`,`sortComparator for column "${t.field}" threw; the values are treated as equal`,r),0}return typeof o!="number"||Number.isNaN(o)?(vt(`sortComparator:${t.field}:nan`,`sortComparator for column "${t.field}" returned ${String(o)}; the values are treated as equal`,void 0),0):o}const Za=e=>e.id;function Qa(e,t,n,o=Za){if(t.length===0)return e;if(e.length<2)return[...e];const r=t.map(i=>{const l=n?.byField.get(i.field),c=l?.sortComparator;if(c)return bi(e.map(u=>{const f=Me(u,i.field,l);return{value:f,type:l.type,comparator:c,params:{id:o(u),field:i.field,row:u,value:f}}}));const a=l?.type;return wi(e.length,u=>Me(e[u],i.field,l),()=>a)});return xi(e,t,r)}function gi(e,t,n){if(t.length===0||e.length<2)return[...e];const o=t.map(r=>{const i=e.map(l=>n(l,r));return i.some(l=>l.comparator&&l.params)?bi(i):wi(i.length,l=>i[l].value,l=>i[l].type)});return xi(e,t,o)}const pi=Dn+1;function hi(e,t){const n=[...e.keys()].sort(Po.compare);let o=0;for(let r=0;r<n.length;r++){r>0&&Po.compare(n[r-1],n[r])!==0&&o++;for(const i of e.get(n[r])??[])t[i]=o}}function ec(e,t,n){const o=[];for(let l=0;l<e.length;l++)e[l]===Ht&&o.push(l);const r=l=>n.get(l)??t[l];o.sort((l,c)=>Gn(r(l),r(c)));let i=0;for(let l=0;l<o.length;l++)l>0&&Gn(r(o[l-1]),r(o[l]))!==0&&i++,t[o[l]]=i}function mi(e,t,n){const o=e.get(t);o?o.push(n):e.set(t,[n])}function wi(e,t,n){const o=new Uint8Array(e),r=new Float64Array(e),i=new Map,l=new Map;let c=null;for(let a=0;a<e;a++){const u=t(a),f=n(a);if(Ya(u)&&f!=="date"&&(c??=new Map).set(a,u),typeof u=="number"&&f!=="date"){Number.isNaN(u)?o[a]=pi:(o[a]=Ht,r[a]=u);continue}const p=$n(u,f);p===null?o[a]=pi:(o[a]=p.rank,p.rank===Io?mi(i,p.str,a):p.rank===Dn?mi(l,p.str,a):r[a]=p.num)}return hi(i,r),hi(l,r),c&&ec(o,r,c),{kind:"encoded",group:o,num:r}}function bi(e){return{kind:"generic",values:e,keys:e.map(({value:t,type:n})=>$n(t,n))}}function tc(e,t,n){if(e.kind==="encoded"){const i=e.group[t],l=e.group[n];if(i!==l)return i-l;const c=e.num[t],a=e.num[n];return c<a?-1:c>a?1:0}const o=e.values[t],r=e.values[n];return o.comparator&&o.comparator===r.comparator&&o.params&&r.params?fi(o.comparator,o.params,r.params):ui(e.keys[t],e.keys[n])}function xi(e,t,n){const o=e.length,r=new Array(o);for(let c=0;c<o;c++)r[c]=c;const i=n[0];if(n.length===1&&i.kind==="encoded"){const{group:c,num:a}=i,u=t[0].sort==="asc"?1:-1;r.sort((f,p)=>{const b=c[f],x=c[p];if(b!==x)return(b-x)*u;const w=a[f],g=a[p];return w<g?-u:w>g?u:f-p})}else r.sort((c,a)=>{for(let u=0;u<n.length;u++){const f=No(tc(n[u],c,a),t[u].sort);if(f!==0)return f}return c-a});const l=new Array(o);for(let c=0;c<o;c++)l[c]=e[r[c]];return l}function nc(e,t,n){if(!n)return e.filter(r=>r.field!==t);const o=e.findIndex(r=>r.field===t);return o===-1?[...e,{field:t,sort:n}]:e.map((r,i)=>i===o?{field:t,sort:n}:r)}function Fo(e,t={}){const n=new Map,o=[];for(const r of e)n.set(r.field,r),!(r.isSpacer||r.field.startsWith("__"))&&r.filterable!==!1&&t[r.field]!==!1&&o.push(r);return{byField:n,quickFilterColumns:o}}const Bt="__pivot_grand_total__",oc="__pivot_row__:",Ci=e=>`${oc}${JSON.stringify(e.split(yi))}`,rc="Grand Total",yi="\0",Wt="",To=`${Wt}id`,vi=e=>e==="id"?To:e,Oo={pivotRows:[],pivotColumns:[],colKeys:[],isValid:!1},Si=e=>e.map(t=>String(t??"")).join(yi),_i=e=>e===void 0||e===""?null:e;function ic(e,t){const n=e==null,o=t==null;return n||o?n===o?0:n?1:-1:typeof e=="number"&&typeof t=="number"?e-t:e instanceof Date&&t instanceof Date?e.getTime()-t.getTime():typeof e=="boolean"&&typeof t=="boolean"?Number(e)-Number(t):String(e).localeCompare(String(t),void 0,{numeric:!0})}function lc(e,t){for(let n=0;n<e.length;n++){const o=ic(e[n],t[n]);if(o!==0)return o}return 0}function ki(e,t){if(!e||e.length===0)return null;const n=ct[t](e);return typeof n=="number"||n instanceof Date?n:null}const sc=e=>"logicOperator"in e&&"items"in e,ac=e=>!!(e&&e.items&&e.items.length>0);function cc(e,t){const n=l=>!t.has(l)&&l.includes(Wt),o=l=>sc(l)?l.items.length>0&&l.items.every(o):n(l.field),r=[],i=[];for(const l of e.items??[])(o(l)?i:r).push(l);return{source:{...e,items:r},output:{items:i,logicOperator:e.logicOperator}}}function Ei(e,t,n,o={}){const r=new Map(t.map(S=>[S.field,S])),i=S=>r.get(S)?.groupable!==!1,l=n.rowFields.filter(i),c=n.columnFields.filter(i),a=new Set,u=n.valueFields.filter(S=>{if(!So(r.get(S.field),S.aggFn))return!1;const F=`${S.field}${Wt}${S.aggFn}`;return a.has(F)?!1:(a.add(F),!0)});if(l.length===0||u.length===0)return Oo;const f=c.length>0,p=Array.from(new Set(u.map(S=>S.field))),b=(S,F)=>Me(S,F,r.get(F)),x=new Map,w=new Map(f?[]:[["",{values:[]}]]);for(const S of e){const F=l.map(Y=>b(S,Y)),T=Si(F);let P=x.get(T);P||(P={labels:F.map(_i),sample:S,cells:new Map},x.set(T,P));const A=c.map(Y=>b(S,Y)),G=f?Si(A):"",z=w.get(G);z?z.sample||(z.sample=S):w.set(G,{values:A.map(_i),sample:S});let H=P.cells.get(G);H||(H=new Map,P.cells.set(G,H));for(const Y of p){const K=b(S,Y);if(on(K))continue;let re=H.get(Y);re||(re=[],H.set(Y,re)),re.push(K)}}const g=Array.from(w.keys()).sort((S,F)=>lc(w.get(S).values,w.get(F).values)),h=(S,F)=>f?`${S}${Wt}${F.field}${Wt}${F.aggFn}`:`${F.field}${Wt}${F.aggFn}`,m=new Map;let C=[];for(const[S,F]of x){const T={id:Ci(S)};l.forEach((P,A)=>{T[vi(P)]=F.labels[A]}),T.id=Ci(S);for(const P of g){const A=F.cells.get(P);for(const G of u)T[h(P,G)]=ki(A?.get(G.field),G.aggFn)}m.set(T.id,F),C.push({row:T,entry:F})}const y=S=>l.includes(S),_=S=>y(S)?r.get(S)?.type:"number",{outputFilterModel:v,sortModel:k}=o;if(ac(v)){const S=[];for(const T of g)for(const P of u)S.push({field:h(T,P),type:"number"});const F=On(v,Fo(S));F&&(C=C.filter(({row:T})=>F(T)))}const M=(S,F)=>F==="id"&&y("id")?S[To]:S[F];k&&k.length>0&&(C=[...C].sort((S,F)=>{for(const T of k){const P=M(S.row,T.field),A=M(F.row,T.field),G=y(T.field)?r.get(T.field)?.sortComparator:void 0,z=G?No(fi(G,{id:S.row.id,field:T.field,row:S.row,value:P},{id:F.row.id,field:T.field,row:F.row,value:A}),T.sort):Ja(P,A,T.sort,_(T.field));if(z!==0)return z}return 0}));const E=C.map(S=>S.row);if(C.length>0){const S={id:Bt};l.forEach((F,T)=>{S[vi(F)]=T===0?rc:""}),S.id=Bt;for(const F of g)for(const T of p){const P=[];for(const{entry:A}of C){const G=A.cells.get(F)?.get(T);if(G)for(const z of G)P.push(z)}for(const A of u)A.field===T&&(S[h(F,A)]=ki(P,A.aggFn))}E.push(S)}const I=C[0]?.entry.sample,L=S=>S===Bt?I:S===void 0?void 0:m.get(S)?.sample,N=l.map(S=>uc(S,r.get(S),L));for(const S of g){const F=w.get(S),T=f?c.map((P,A)=>{const G=r.get(P),z=dc(G,P,F.values[A],F.sample);return G?.headerName?`${G.headerName}: ${z}`:z}).join(" / "):"";for(const P of u){const A=r.get(P.field),G=P.headerName??A?.headerName??P.field;N.push({field:h(S,P),headerName:T?`${T} — ${G} (${P.aggFn})`:`${G} (${P.aggFn})`,width:140,type:"number",align:"right",headerAlign:"right",sortable:!0,valueFormatter:({value:z,row:H})=>Tn(z,P.aggFn,A,H)})}}return{pivotRows:E,pivotColumns:N,colKeys:g,isValid:!0}}function dc(e,t,n,o){const r=o?wo(o,t,n,e):void 0;return r!==void 0?r:n==null?"":String(n)}function uc(e,t,n){const o={field:e,headerName:t?.headerName??e,width:t?.width??140,sortable:!0,hideable:!1};t&&(t.type!==void 0&&(o.type=t.type),t.align!==void 0&&(o.align=t.align),t.headerAlign!==void 0&&(o.headerAlign=t.headerAlign),t.description!==void 0&&(o.description=t.description),t.minWidth!==void 0&&(o.minWidth=t.minWidth),t.maxWidth!==void 0&&(o.maxWidth=t.maxWidth),t.valueOptions!==void 0&&(o.valueOptions=t.valueOptions)),e==="id"&&(o.valueGetter=({row:c})=>c[To]);const r=c=>c?.id===Bt,i=t?.valueFormatter;i&&(o.valueFormatter=({value:c,row:a})=>r(a)?String(c??""):i({value:c,row:n(a?.id)??a,field:e}));const l=t?.renderCell;return l&&(o.renderCell=c=>r(c.row)?c.formattedValue??String(c.value??""):l({...c,row:n(c.row.id)??c.row})),o}function je(e,t){return e===Bt||t?.get(e)?.isGroupRow===!0}const St="__reorder_col__",_t="__expand_col__",Je="__checkbox_col__",Ze=e=>e===St||e===_t||e===Je,Do=(e,t)=>e===t||e!==null&&t!==null&&e.id===t.id&&e.field===t.field&&!e.headerFilter==!t.headerFilter,fc=new Set(["checkbox","radio","button","submit","reset","image","file","color"]),gc=new Set(["textbox","searchbox","combobox","listbox","slider","spinbutton"]);function Mi(e){const t=e.tagName;if(t==="INPUT")return!fc.has(e.type);if(t==="TEXTAREA"||t==="SELECT"||e.isContentEditable||e.closest('[contenteditable]:not([contenteditable="false"])'))return!0;const n=e.getAttribute("role");return n!==null&&gc.has(n)}const Li=e=>e!==null&&e.nodeType===1;function Ai(e,t){const n=e.closest(".ogx__detail-panel");if(n&&t.contains(n))return null;const o=e.closest('[role="gridcell"], [role="columnheader"]');return!o||o.closest(".ogx__viewport")!==t?null:o}function Hn(e,t){if(e===t)return"grid";if(!Li(e)||!t.contains(e))return"foreign";const n=Ai(e,t);return n?n.classList.contains("ogx__cell--editing")?"editor":n===e?"grid":Mi(e)?"foreign":n.classList.contains("ogx__header-cell--checkbox")?"grid":"control":"foreign"}function pc(e,t,n,o){if(!Li(e))return null;const r=Ai(e,t),i=r?.dataset.field;if(!r||!i)return null;if(r.getAttribute("role")==="columnheader"){const a=r.parentElement;return a?.classList.contains("ogx__header")?{id:null,field:i}:a?.classList.contains("ogx__header-filter-row")?{id:null,field:i,headerFilter:!0}:null}const l=Number(r.parentElement?.getAttribute("data-rowindex")),c=Number.isInteger(l)?n[l]:void 0;return c?{id:o(c),field:i,rowIndex:l}:null}function Pi(e,t){if(!e)return null;for(const n of Array.from(e.children))if(n.dataset.field===t)return n;return null}function $o(e,t,n){if(t.id===null){const r=e.querySelector(`:scope > .ogx__content > .ogx__sticky-top > .ogx__header-wrap > ${t.headerFilter?".ogx__header-filter-row":".ogx__header"}`),i=Pi(r,t.field);return i&&t.field===Je?i.querySelector("input")??i:i}if(n<0)return null;const o=e.querySelector(`:scope > .ogx__content > .ogx__virtual-container > .ogx__rows > [data-rowindex="${n}"],:scope > .ogx__content > .ogx__sticky-top > .ogx__pinned-rows > [data-rowindex="${n}"],:scope > .ogx__content > .ogx__sticky-bottom > .ogx__pinned-rows > [data-rowindex="${n}"]`);return Pi(o,t.field)}const Ii="__group__";function qe(e){return!Ze(e)&&e!==Ii}const dt=(e,t)=>e===t||!!e&&!!t&&e.id===t.id&&e.field===t.field;function hc(e,t){return e===t?!0:e.length!==t.length?!1:e.every((n,o)=>dt(n.anchor,t[o].anchor)&&dt(n.head,t[o].head))}function Bn(e,t,n){const{rowIds:o,fields:r,rowIndexById:i,colIndexByField:l,spans:c}=n,a={top:e,bottom:e,left:t,right:t};if(!c)return a;const u=o[e],f=r[t],p=c.getSpanOrigin(u,f)??{rowId:u,field:f},b=i.get(p.rowId),x=l.get(p.field);if(b===void 0||x===void 0)return a;const w=Math.max(1,c.getRowSpan(p.rowId,p.field)),g=Math.max(1,c.getColSpan(p.rowId,p.field));return{top:b,bottom:Math.min(o.length-1,b+w-1),left:x,right:Math.min(r.length-1,x+g-1)}}function mc(e,t){if(!t.spans)return e;let{top:n,bottom:o,left:r,right:i}=e,l=!0;const c=a=>{a.top<n&&(n=a.top,l=!0),a.bottom>o&&(o=a.bottom,l=!0),a.left<r&&(r=a.left,l=!0),a.right>i&&(i=a.right,l=!0)};for(;l;){l=!1;for(let a=n;a<=o;a++)c(Bn(a,r,t)),i!==r&&c(Bn(a,i,t));for(let a=r+1;a<i;a++)c(Bn(n,a,t)),o!==n&&c(Bn(o,a,t))}return{top:n,bottom:o,left:r,right:i}}function Wn(e,t){const n=t.rowIndexById.get(e.anchor.id),o=t.rowIndexById.get(e.head.id),r=t.colIndexByField.get(e.anchor.field),i=t.colIndexByField.get(e.head.field);return n===void 0||o===void 0||r===void 0||i===void 0?null:{...mc({top:Math.min(n,o),bottom:Math.max(n,o),left:Math.min(r,i),right:Math.max(r,i)},t),anchorRow:n,anchorCol:r,headRow:o,headCol:i}}const kt=e=>(e.bottom-e.top+1)*(e.right-e.left+1);function wc(e,t,n,o,r,i){const{headRow:l,headCol:c,anchorRow:a,anchorCol:u,top:f,bottom:p,left:b,right:x}=e;let w=l,g=c;switch(t){case"ArrowRight":g=c>=u?x+1:c+1;break;case"ArrowLeft":g=c<=u?b-1:c-1;break;case"ArrowDown":w=l>=a?p+1:l+1;break;case"ArrowUp":w=l<=a?f-1:l-1;break;case"Home":g=0,n&&(w=0);break;case"End":g=i,n&&(w=r);break;case"PageUp":w=l-o;break;case"PageDown":w=l+o;break;default:return null}return w=Math.min(Math.max(w,0),r),g=Math.min(Math.max(g,0),i),w===l&&g===c?null:{row:w,col:g}}function Ni(e,t,n,o){const r=o&&o.row===t?o.col:void 0;if(!e||t<e.top||t>e.bottom)return r===void 0?null:{left:0,right:-1,isTop:!1,isBottom:!1,bottomOffset:0,fillHandleCol:r};const i={left:e.left,right:e.right,isTop:t===e.top,isBottom:t===e.bottom,bottomOffset:n?e.bottom-t:0};return r!==void 0&&(i.fillHandleCol=r),i}const bc=(e,t)=>e===t||!!e&&!!t&&e.left===t.left&&e.right===t.right&&e.isTop===t.isTop&&e.isBottom===t.isBottom&&e.bottomOffset===t.bottomOffset&&e.fillHandleCol===t.fillHandleCol,Go=1,Fi=2,Ti=4,Oi=8,Di=16,$i=32;function xc(e,t,n,o){if(!e)return 0;const r=e.fillHandleCol===t?$i:0,i=t+Math.max(1,n)-1;if(t<e.left||i>e.right)return r;let l=Go|r;return e.isTop&&(l|=Fi),(e.isBottom||o>1&&o-1>=e.bottomOffset)&&(l|=Ti),t===e.left&&(l|=Oi),i===e.right&&(l|=Di),l}function Gi(e,t,n){const o=(r,i,l)=>`${r} ${r===1?i:l}`;return`${o(e,"cell","cells")} selected, ${o(t,"row","rows")} by ${o(n,"column","columns")}`}const Cc=1e5,yc=e=>e.id,Hi=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]);function vc(e,t,n,o,r){if(!e||n.length===0)return{cell:null,rowIndex:-1};const i=(n.find(u=>!Ze(u.field))??n[0]).field,l=n.some(u=>u.field===e.field)?e.field:i;if(e.id===null){const u=!!e.headerFilter&&r;return l===e.field&&u===!!e.headerFilter?{cell:e,rowIndex:-1}:{cell:u?{id:null,field:l,headerFilter:u}:{id:null,field:l},rowIndex:-1}}const c=e.rowIndex;let a=c!==void 0&&t[c]&&o(t[c])===e.id?c:t.findIndex(u=>o(u)===e.id);return a===-1?t.length===0?{cell:{id:null,field:l},rowIndex:-1}:(a=Math.min(Math.max(c??0,0),t.length-1),{cell:{id:o(t[a]),field:l,rowIndex:a},rowIndex:a}):{cell:l===e.field?e:{...e,field:l},rowIndex:a}}function Sc(e){const{allRenderableRows:t,navigationColumns:n,checkboxSelection:o,selectedRowIds:r,handleSelectionChange:i,handleDetailPanelToggle:l,editingHandlers:c,setKeyboardMode:a,sortModel:u,handleSort:f,handleSortAdd:p,multiSort:b=!1,isCellEditable:x,pagination:w,pageSize:g,virtualization:h,viewportRef:m,pinnedTopRowCount:C=0,getRowId:y=yc,rowMetaMap:_,onRowActivate:v,toggleRowExpansion:k,handleSelectAll:M,rowSelectionEnabled:E=!0,multipleRowSelectionEnabled:I=!0,pinCheckboxColumn:L=!0,pinExpandColumn:N=!0,rowHeight:S,getSpanOrigin:F,cellSelection:T,headerFilters:P=!1}=e,[A,G]=s.useState(null),[z,H]=s.useState(!1),Y=s.useMemo(()=>vc(A,t,n,y,P),[A,t,n,y,P]),K=Y.cell,re=Y.rowIndex,R=s.useRef(!1),te=s.useRef(!1),ie=s.useRef(!1),ce=s.useRef(null),J=s.useCallback(U=>{te.current=!0,U.focus({preventScroll:!0}),te.current=!1},[]),se=s.useCallback(()=>{const U=m.current;U&&!U.contains(U.ownerDocument.activeElement)&&J(U)},[m,J]),ne=s.useMemo(()=>n.find(U=>!Ze(U.field))??n[0],[n]),j=s.useCallback(()=>{if(o)return{id:null,field:Je};if(!ne)return null;const U=t[0];return U?{id:y(U),field:ne.field,rowIndex:0}:{id:null,field:ne.field}},[o,ne,t,y]),B=s.useCallback((U,O)=>{const $=m.current;if(!$)return;const{cumulativeHeights:D,pinnedBottomHeight:V,columnMetrics:q}=h;if(U>=0&&Nn($,U-C,D,V,S),Ze(O)){!(O===St||O===_t&&N||O===Je&&L)&&$t($)>0&&nn($,0);return}if(!q)return;const{clientWidth:oe}=$,Z=$t($),{leftPinnedWidth:X,rightPinnedWidth:le,unpinnedAccWidths:we,unpinnedCols:ge,totalSpecialsWidth:he,pinnedSpecialsWidth:ee}=q,ue=ge.findIndex(de=>de.field===O);if(ue===-1)return;const Ce=he+X+(ue>0?we[ue-1]:0),be=he+X+we[ue],me=Z+ee+X,xe=Z+oe-le;let ye=Z;Ce<me?ye=Math.max(0,Ce-ee-X):be>xe&&(ye=be-oe+le),ye!==Z&&nn($,ye)},[m,h,C,S,L,N]);s.useLayoutEffect(()=>{const U=m.current,O=!Do(ce.current,K);if(ce.current=K,!U||!K)return;const $=U.ownerDocument,D=$.activeElement;let V;if(D===U?V=!0:!D||D===$.body?V=R.current:U.contains(D)?V=O:V=!1,!V)return;const q=$o(U,K,re);q?q.contains(D)||q.focus({preventScroll:!0}):D!==U&&J(U)});const W=s.useCallback(()=>{ie.current=!0,a(!1)},[a]),ae=s.useCallback(U=>{const O=U.currentTarget,$=U.relatedTarget,D=!($ instanceof Node&&O.contains($)),V=ie.current;if(ie.current=!1,R.current=!0,H(!0),te.current)return;if(U.target===O){if(!D)return;if(V||a(!0),K){const Z=$o(O,K,re);Z?Z.focus({preventScroll:!0}):B(re,K.field);return}const oe=j();oe&&(G(Z=>Z??oe),B(oe.rowIndex??-1,oe.field));return}const q=pc(U.target,O,t,y);q&&!Do(q,K)&&G(q)},[K,re,j,B,a,t,y]),fe=s.useCallback(U=>{const O=U.relatedTarget;O instanceof Node&&U.currentTarget.contains(O)||(R.current=!1,ie.current=!1,H(!1),a(!1))},[a]),Q=s.useCallback(U=>{const O=U.currentTarget,$=Hn(U.target,O);if($==="foreign"||(a(!0),U.nativeEvent?.isComposing||U.keyCode===229))return;const D=Pn(U.key,Ye(O)),V=D===" "||D==="Spacebar",q=!!c.editingCell,oe=P?-2:-1,Z=(pe,Se)=>{const _e=n[Se];!_e||pe<oe||pe>=t.length||(pe===oe?G({id:null,field:_e.field}):pe<0?G({id:null,field:_e.field,headerFilter:!0}):G({id:y(t[pe]),field:_e.field,rowIndex:pe}),B(pe,_e.field))};if(!K){if(!Hi.has(D))return;const pe=j();if(!pe)return;U.preventDefault(),G(pe),B(pe.rowIndex??-1,pe.field);return}const{id:X,field:le}=K,we=X===null&&!!K.headerFilter,ge=X!==null?re:we?-1:oe,he=n.findIndex(pe=>pe.field===le),ee=n.filter(pe=>Ze(pe.field)).length,ue=pe=>je(pe,_),Ce=(pe,Se,_e)=>{const ve=n[_e];return Ze(ve.field)?!1:vo({row:pe,field:ve.field,value:Me(pe,ve.field,ve),colDef:ve,rowIndex:Se,colIndex:_e-ee,rowMeta:_?.get(y(pe))},x)},be=pe=>{let Se=ge,_e=he;const ve=(t.length+1)*n.length;for(let Ne=0;Ne<ve;Ne++){if(_e+=pe,_e>=n.length?(_e=0,Se++):_e<0&&(_e=n.length-1,Se--),Se<0||Se>=t.length)return null;const $e=t[Se];if(!F?.(y($e),n[_e].field)&&Ce($e,Se,_e))return{r:Se,c:_e}}return null};if(q){if(D==="Enter")U.preventDefault(),c.stopCellEdit();else if(D==="Escape")U.preventDefault(),c.stopCellEdit({cancel:!0});else if(D==="Tab"&&X!==null){const pe=be(U.shiftKey?-1:1);pe&&(U.preventDefault(),c.stopCellEdit(),Z(pe.r,pe.c))}return}if(D==="Escape"&&T?.collapseSelection()){U.preventDefault();return}if(D==="Tab"||D==="Escape"||$==="control"&&(D==="Enter"||V))return;if((U.ctrlKey||U.metaKey)&&(D==="a"||D==="A")){if(T){T.selectAllCells()&&U.preventDefault();return}if(!E||!I||!M)return;U.preventDefault(),M(!0);return}if(we&&(D==="Enter"||V))return;if(X===null){if(D==="Enter"||V){if(U.preventDefault(),le===Je){$o(O,K,-1)?.click();return}const pe=n[he];if(!pe||Ze(le)||pe.sortable===!1)return;const Se=u.find(ve=>ve.field===le),_e=Se?Se.sort==="asc"?"desc":null:"asc";(b||U.shiftKey)&&p?p(le,_e):f(le,_e);return}}else if(D==="Enter"||V){U.preventDefault();const pe=t[ge];if(le===Je){i(X,!r.has(X));return}if(le===_t){U.shiftKey||l(X);return}if(V){U.shiftKey&&E&&!ue(X)&&i(X,!r.has(X));return}if(le===St)return;if(Ce(pe,ge,he)){c.startCellEdit({id:X,field:le,value:Me(pe,le,n[he])});return}if(k&&_?.get(X)?.hasChildren){k(X);return}v?.({row:pe,id:X,rowIndex:ge});return}if(U.altKey&&(D==="ArrowRight"||D==="ArrowLeft")&&k&&X!==null){U.preventDefault();const pe=_?.get(X);pe?.hasChildren&&!!pe.isExpanded!=(D==="ArrowRight")&&k(X);return}if(!Hi.has(D))return;U.preventDefault();const me=t.length-1,xe=n.length-1,ye=U.ctrlKey||U.metaKey,de=w?g:10;if(T&&U.shiftKey&&X!==null&&qe(le)&&T.extendSelection(D,ye,de,K))return;const Pe=(pe,Se)=>{switch(D){case"ArrowRight":return Se+1>xe?{r:pe+1,c:0}:{r:pe,c:Se+1};case"ArrowLeft":return Se-1<0?{r:pe-1,c:xe}:{r:pe,c:Se-1};case"ArrowDown":return{r:pe+1,c:Se};case"ArrowUp":return{r:pe-1,c:Se};case"Home":return{r:ye?oe:pe,c:0};case"End":return{r:ye?me:pe,c:xe};case"PageUp":return{r:Math.max(oe,pe-de),c:Se};default:return{r:Math.min(me,pe+de),c:Se}}},Ie=({r:pe,c:Se})=>pe>=oe&&pe<=me&&Se>=0&&Se<=xe,Ae=({r:pe,c:Se})=>pe>=0?F?.(y(t[pe]),n[Se].field)??null:null;let Ee=Pe(ge,he);if(D.startsWith("Arrow"))for(let pe=Ie(Ee)?Ae(Ee):null;pe&&pe.rowId===X&&pe.field===le;pe=Ie(Ee)?Ae(Ee):null)Ee=Pe(Ee.r,Ee.c);if(!Ie(Ee))return;const Fe=Ae(Ee);if(Fe){const pe=t.findIndex(_e=>y(_e)===Fe.rowId),Se=n.findIndex(_e=>_e.field===Fe.field);pe!==-1&&Se!==-1&&(Ee={r:pe,c:Se})}Ee.r===ge&&Ee.c===he||Z(Ee.r,Ee.c)},[K,re,t,n,c,r,i,l,a,u,f,p,b,x,w,g,_,v,k,M,E,I,j,B,F,y,T,P]);return{focusedCell:K,setFocusedCell:G,viewportTabIndex:z?-1:0,ensureGridFocus:se,handleFocus:ae,handleBlur:fe,handleKeyDown:Q,handleMouseDownCapture:W}}const Ho=[];function _c(e){const{isPivotActive:t}=e,n=t?Ho:e.rowGroupingModel,o=e.treeData&&!t,r=o&&e.hasTreeDataPath,i=n.length>0;return{rowReordering:e.rowReordering&&!t,hierarchyRowGroupingModel:n,isTreeDataRequested:o,isTreeData:r,isRowGrouping:i,isHierarchyEnabled:r||i,hasGroupingColumn:e.hasGroupingColDef&&(i||r),pagination:e.pagination&&!i&&e.paginationMode!=="infinite",listView:e.listView&&e.hasListViewColumn}}const kc=[],Ec={rowFields:[],columnFields:[],valueFields:[]},Bi=100;function Mc(e){return!e||e.length===0||e.includes(Bi)?Bi:e[0]}function Lc(e){const{initialState:t,sortModel:n,onSortModelChange:o,filterModel:r,onFilterModelChange:i,aggregationModel:l,onAggregationModelChange:c,rowGroupingModel:a,onRowGroupingModelChange:u,columnVisibilityModel:f,onColumnVisibilityModelChange:p,pinnedColumns:b,onPinnedColumnsChange:x,pivotModel:w,onPivotModelChange:g,paginationModel:h,onPaginationModelChange:m,pageSizeOptions:C,rowSelectionModel:y,onRowSelectionModelChange:_,density:v,cellSelectionModel:k,onCellSelectionModelChange:M}=e,[E,I]=s.useState(()=>t?.sorting?.sortModel??[]),L=n!==void 0,N=L?n:E,S=s.useCallback(ve=>{L||I(ve),o?.(ve)},[L,o]),[F,T]=s.useState(()=>t?.filter?.filterModel??{items:[]}),P=r!=null,A=P?r:F,G=s.useCallback(ve=>{P||T(ve),i?.(ve)},[P,i]),z=l!==void 0,[H,Y]=s.useState(()=>l??{}),K=JSON.stringify(z?l:H),re=s.useMemo(()=>JSON.parse(K),[K]),R=s.useCallback(ve=>{z||Y(ve),c?.(ve)},[z,c]),te=a!==void 0,[ie,ce]=s.useState(Ho),J=(te?a:ie)||Ho,se=s.useCallback(ve=>{te||ce(ve),u?.(ve)},[te,u]),ne=f!==void 0,[j,B]=s.useState(()=>t?.columns?.columnVisibilityModel??{}),W=ne?f:j,ae=s.useCallback(ve=>{ne||B(ve),p?.(ve)},[ne,p]),fe=b!==void 0,[Q,U]=s.useState(()=>t?.columns?.pinnedColumns??{}),O=fe?b:Q,$=s.useCallback(ve=>{fe||U(ve),x?.(ve)},[fe,x]),[D,V]=s.useState(()=>w??Ec),q=w??D,oe=s.useCallback(ve=>{V(ve),g?.(ve)},[g]),Z=h!==void 0,[X,le]=s.useState(()=>t?.pagination?.paginationModel??h??{page:0,pageSize:Mc(C)}),we=Z?h:X,ge=s.useCallback(ve=>{Z||le(ve),m?.(ve)},[Z,m]),he=y!==void 0,[ee,ue]=s.useState([]),Ce=he?y:ee,be=s.useMemo(()=>new Set(Ce),[Ce]),me=s.useRef(null);s.useLayoutEffect(()=>{me.current=null});const xe=s.useCallback(()=>me.current,[]),ye=s.useCallback(ve=>{me.current=ve,he||ue(ve),_?.(ve)},[he,_]),[de]=s.useState(()=>t?.density?.density??"standard"),Pe=v??de,Ie=k!==void 0,[Ae,Ee]=s.useState(kc),Fe=Ie?k:Ae,pe=s.useRef(null);s.useLayoutEffect(()=>{pe.current=null});const Se=s.useCallback(()=>pe.current,[]),_e=s.useCallback((ve,Ne)=>{pe.current=ve,Ie||Ee(ve),M?.(ve,{reason:Ne})},[Ie,M]);return{sortModel:N,isSortControlled:L,setInternalSortModel:I,handleSortModelChange:S,filterModel:A,isFilterControlled:P,handleFilterModelChange:G,aggregationModel:re,handleAggregationModelChange:R,rowGroupingModel:J,handleRowGroupingModelChange:se,columnVisibilityModel:W,handleColumnVisibilityModelChange:ae,pinnedColumns:O,handlePinnedColumnsChange:$,currentPivotModel:q,handlePivotModelChange:oe,effectivePaginationModel:we,handlePaginationModelChange:ge,rowSelectionModel:Ce,selectedRowIds:be,isSelectionControlled:he,setInternalRowSelectionModel:ue,handleRowSelectionModelChange:ye,getPendingRowSelectionModel:xe,density:Pe,cellSelectionModel:Fe,handleCellSelectionModelChange:_e,getPendingCellSelectionModel:Se}}const Wi=s.createContext(null),Ac=52,Pc=56,Ic=32,Nc=72;function Vn(e){if(e===void 0)return;const t=/^(\d+(?:\.\d+)?)(?:\s*px)?$/.exec(e.trim());if(!t)return;const n=Number(t[1]);return n>0?n:void 0}function Fc(e){const{rowHeight:t,headerHeight:n,density:o}=e,r=s.useContext(Wi)?.grid;let i;return o==="compact"?i=Vn(r?.rowHeightCompact)??Ic:o==="comfortable"?i=Vn(r?.rowHeightComfortable)??Nc:i=t??Vn(r?.rowHeightStandard)??Ac,{rowHeight:i,headerHeight:n??Vn(r?.headerHeight)??Pc}}function zn(e){return e>=1?Math.floor(e):1}function Bo(e,t){return Math.max(1,Math.ceil(Math.max(0,e)/zn(t)))}function Tc(e){const{paginationMode:t,hasDataSource:n,dataSourceRowCount:o,rowCountProp:r,clientRowCount:i}=e;return t!=="server"?i:(n?o??r:r)??i}function Vi(e){return e?{paginationRowsPerPage:e.paginationRowsPerPage,paginationOf:e.paginationOf,paginationPage:e.paginationPage}:void 0}function zi(e,t){return Number.isFinite(e)?Math.min(Math.max(0,Math.floor(e)),Math.max(0,t-1)):0}function Oc(e){const{effectiveRows:t,activeHierarchyHandlers:n,filterMode:o,filterModel:r,sortModel:i,sortingMode:l,pagination:c,paginationMode:a,effectivePaginationModel:u,pinnedRows:f,getRowId:p,columnLookup:b,hierarchyField:x}=e,w=s.useMemo(()=>n?n.getVisibleRows({labelField:x})||[]:o==="server"?t:Lo(t,r,b),[t,r,n,x,o,b]),g=s.useMemo(()=>n?o==="server"?t:Lo(t,r,b):w,[n,w,o,t,r,b]),{top:h,center:m,bottom:C}=s.useMemo(()=>n?{top:[],center:w,bottom:[]}:va(w,f,p),[w,f,n,p]),y=s.useMemo(()=>n||l==="server"?m:Qa(m,i,b,p),[m,i,n,l,b,p]),_=c&&a!=="server",v=zn(u.pageSize),k=_?zi(u.page,Bo(y.length,v)):u.page,M=s.useMemo(()=>{if(!_)return y;const I=k*v;return y.slice(I,I+v)},[y,_,k,v]),E=s.useMemo(()=>{const I=c?M:y;return[...h,...I,...C]},[h,M,y,C,c]);return{filteredRows:w,dataRows:g,pinnedTopRows:h,unpinnedRows:m,pinnedBottomRows:C,sortedUnpinnedRows:y,paginatedUnpinnedRows:M,currentPage:k,allRenderableRows:E}}const Wo=[33554400,17895e3,1e7,5e6],Ri=new WeakMap;function Dc(e){const t=e.body;if(!t)return 1/0;const n=e.createElement("div");n.setAttribute("aria-hidden","true"),n.style.cssText="position:absolute;top:0;left:-10000px;width:1px;visibility:hidden;pointer-events:none;",t.appendChild(n);try{if(n.style.height="100px",Math.abs(n.getBoundingClientRect().height-100)>1)return 1/0;for(const o of Wo)if(n.style.height=`${o}px`,Math.abs(n.getBoundingClientRect().height-o)<2)return o;return Wo[Wo.length-1]}finally{n.remove()}}function $c(e){if(!e)return 1/0;const t=Ri.get(e);if(t!==void 0)return t;const n=Dc(e);return Ri.set(e,n),n}function Gc(e,t){if(!Number.isFinite(t))return e.length;let n=0,o=e.length;for(;n<o;){const r=n+o>>1;e[r]<=t?n=r+1:o=r}return n}const Vo="application/x-ogx-row",zo="application/x-ogx-column";function Ui(e,t,n){const o=e.dataTransfer;!o||typeof o.setData!="function"||(o.setData(t,n),o.setData("text/plain",n))}function Rn(e,t){const n=e.dataTransfer?.types;return n?Array.from(n).includes(t):!0}function Ki(e,t){if(!e||typeof e.addEventListener!="function")return()=>{};const n=()=>t();return e.addEventListener("dragend",n,{once:!0}),()=>e.removeEventListener("dragend",n)}function Hc(e){const{columns:t,onColumnOrderChange:n,disableColumnReorder:o=!1}=e,[r,i]=s.useState(null),[l,c]=s.useState(null),a=s.useRef(()=>{}),u=s.useCallback(()=>{a.current(),a.current=()=>{},i(null),c(null)},[]);s.useEffect(()=>()=>a.current(),[]);const f=s.useCallback(x=>w=>{if(!o){if(!t.some(g=>g.field===x)){w.preventDefault();return}a.current(),a.current=Ki(w.currentTarget,u),i(x),w.dataTransfer&&(w.dataTransfer.effectAllowed="move",Ui(w,zo,x))}},[t,o,u]),p=s.useCallback(x=>w=>{if(!(o||r===null)){if(!Rn(w,zo)){u();return}w.preventDefault(),w.dataTransfer&&(w.dataTransfer.dropEffect="move"),c(x)}},[r,o,u]),b=s.useCallback(x=>w=>{if(w.preventDefault(),o||r===null||!Rn(w,zo)){u();return}const g=t.findIndex(m=>m.field===r),h=t.findIndex(m=>m.field===x);u(),!(g===-1||h===-1||g===h)&&n?.({column:t[g],oldIndex:g,targetIndex:h})},[t,r,o,n,u]);return{draggedColumn:r,dragOverColumn:l,onDragStart:o?void 0:f,onDragOver:o?void 0:p,onDragEnd:o?void 0:u,onDrop:o?void 0:b}}const Bc="header:",Wc=40,Vc=300,zc="__group__",ji=[];function Ro(e){return`${Bc}${e}`}function Uo(e){return"items"in e&&Array.isArray(e.items)}function Rc(e){return e.isSpacer||Ze(e.field)||e.field===zc?!1:e.headerFilter!==!1&&e.filterable!==!1&&e.type!=="image"}function Un(e){if(e.headerFilterOperator)return e.headerFilterOperator;switch(e.type){case"number":return"=";case"date":case"boolean":case"singleSelect":return"is";default:return"contains"}}function Uc(e){const t=ci(e.type),n=Un(e);return t.includes(n)?t:[n,...t]}function qi(e,t){return e.items.some(n=>Uo(n)?qi(n,t):n.field===t)}function Kc(e){return(e?.logicOperator??"and")==="or"&&(e?.items?.length??0)>0}function Xi(e,t){const n=e?.items??ji;if(Kc(e))return{kind:"custom"};const o=Ro(t);let r;for(const i of n){if(Uo(i)){if(qi(i,t))return{kind:"custom"};continue}if(i.field===t){if(i.id!==o||r)return{kind:"custom"};r=i}}return{kind:"editable",item:r}}function jc(e,t,n){const o=e??{items:[]};if(Xi(o,t).kind!=="editable")return o;const r=Ro(t),i=o.items??ji,l=i.findIndex(u=>!Uo(u)&&u.id===r),c=n?{...n,id:r,field:t}:null;let a;if(l===-1){if(!c)return o;if(i.length===0&&o.logicOperator==="or")return{...o,logicOperator:"and",items:[c]};a=[...i,c]}else c?a=i.map((u,f)=>f===l?c:u):a=i.filter((u,f)=>f!==l);return{...o,items:a}}function Ko(e,t,n){const o=Gt.has(t);return!o&&_o(n)&&t===Un(e)?null:{id:Ro(e.field),field:e.field,operator:t,value:o?void 0:n}}function Yi(e,t){if(!Gt.has(t))return t==="isAnyOf"?e==null||e===""?[]:Array.isArray(e)?e:[e]:Array.isArray(e)?e.length>0?e[0]:"":e??""}const qc={contains:"∋",equals:"=",startsWith:"a…",endsWith:"…a",isEmpty:"∅",isNotEmpty:"!∅",isAnyOf:"∈","=":"=","!=":"≠",">":">",">=":"≥","<":"<","<=":"≤",is:"=",not:"≠",after:">",onOrAfter:"≥",before:"<",onOrBefore:"≤"},Ji={contains:"Contains",equals:"Equals",startsWith:"Starts with",endsWith:"Ends with",isEmpty:"Is empty",isNotEmpty:"Is not empty",isAnyOf:"Is any of","=":"Equals","!=":"Does not equal",">":"Greater than",">=":"Greater than or equal","<":"Less than","<=":"Less than or equal",is:"Is",not:"Is not",after:"After",onOrAfter:"On or after",before:"Before",onOrBefore:"On or before"},jo=(e,t,n)=>e===1?t:n,Zi={paginationRowsPerPage:"Rows per page:",paginationOf:(e,t,n)=>n===0?`0 of ${n}`:`${e}–${t} of ${n}`,paginationPage:(e,t)=>`Page ${e} of ${t}`,noRowsLabel:"No Data",cellSelectionAnnouncement:Gi,aiAssistantButton:"Ask AI",headerFilterCustom:"Custom filter",headerFilterCustomTooltip:"Set in the filter panel",headerFilterCellLabel:e=>`Filter ${e}`,headerFilterValueLabel:e=>`Filter value for ${e}`,headerFilterOperatorButtonLabel:(e,t)=>`Filter operator for ${e}: ${t}`,headerFilterOperatorMenuLabel:e=>`Filter operator for ${e}`,headerFilterClearLabel:e=>`Clear filter for ${e}`,headerFilterClearTooltip:"Clear",headerFilterAny:"Any",headerFilterTrue:"Yes",headerFilterFalse:"No",gridLabel:"Data grid",listViewLabel:"Data grid list view",listViewItemCount:e=>`${e} ${jo(e,"item","items")}`,listViewPage:(e,t)=>`page ${e} of ${t}`,listViewSelectedCount:e=>`${e} selected`,loadingLabel:"Loading data",liveRegionLoading:"Loading data...",liveRegionError:e=>`Error: ${e}`,liveRegionRowsFound:e=>`${e} ${jo(e,"row","rows")} found`,errorOverlayTitle:"Oops! Something went wrong",errorOverlayRetry:"Retry",aggregationFooterLabel:"Aggregation totals",cellErrorLabel:e=>`Error in cell: ${e}`,cellErrorTooltip:"Render error",headerRowReorderLabel:"Row reorder handle",headerRowReorderTooltip:"Drag to reorder rows",headerDetailPanelLabel:"Expand row details",headerSelectAllLabel:"Select all rows",headerDeselectAllLabel:"Deselect all rows",headerSortDescription:(e,t,n)=>`Sorted ${e==="asc"?"ascending":"descending"}, sort priority ${t} of ${n}`,headerColumnMenuButtonLabel:e=>`Open column menu for ${e}`,headerColumnResizeLabel:e=>`Resize ${e} column`,headerFilterNoFilterLabel:e=>`No filter for ${e}`,rowSelectLabel:e=>`Select row ${e}`,rowDeselectLabel:e=>`Deselect row ${e}`,rowReorderLabel:"Drag to reorder row",rowDetailPanelExpandLabel:"Expand row details",rowDetailPanelCollapseLabel:"Collapse row details",rowExpandLabel:"Expand row",rowCollapseLabel:"Collapse row",columnMenuLabel:e=>`Column options for ${e}`,columnMenuSortAscending:"Sort Ascending",columnMenuSortDescending:"Sort Descending",columnMenuUnsort:"Unsort",columnMenuPinColumn:"Pin column",columnMenuPinLeft:"Pin to Left",columnMenuPinLeftLabel:"Pin to left",columnMenuPinRight:"Pin to Right",columnMenuPinRightLabel:"Pin to right",columnMenuUnpin:"Unpin",columnMenuUnpinLabel:"Unpin column",columnMenuHideColumn:"Hide Column",columnMenuHideColumnLabel:e=>`Hide ${e} column`,columnMenuManageColumns:"Manage columns",columnMenuManageColumnsLabel:"Manage all columns",columnsPanelSearchPlaceholder:"Search",columnsPanelDragToReorder:"Drag to reorder",columnsPanelShowHideAll:"Show/Hide All",columnsPanelReset:"Reset",columnsPanelClose:"Close",filterPanelValueLabel:e=>`Filter value for ${e}`,filterPanelOperatorLabel:e=>`Filter operator for ${e}`,filterPanelClearLabel:e=>`Clear filter for ${e}`,filterPanelClearTooltip:"Clear",filterPanelAny:"Any",filterPanelTrue:"true",filterPanelFalse:"false",filterPanelNumberPlaceholder:"Number…",filterPanelValuePlaceholder:"Value…",filterPanelMatch:"Match:",filterPanelAnd:"ALL (AND)",filterPanelOr:"ANY (OR)",filterPanelHiddenConditions:e=>e===1?"1 more condition (a filter group or a second condition on a column) is applied and not shown here.":`${e} more conditions (filter groups or further conditions on a column) are applied and not shown here.`,filterPanelNoColumns:"No filterable columns.",toolbarLabel:"Grid toolbar",toolbarSearchPlaceholder:"Search...",toolbarSearchLabel:"Global Search",toolbarSearchClear:"Clear search",toolbarColumns:"Columns",toolbarColumnsLabel:"Manage columns",toolbarColumnsPanelLabel:"Column visibility",toolbarFilters:"Filters",toolbarFiltersLabel:"Advanced filters",toolbarFiltersActive:"Filters active",toolbarFiltersClearAll:"Clear all",toolbarFiltersClearAllTooltip:"Clear all filters",toolbarFiltersClose:"Close",toolbarFiltersCloseTooltip:"Close filters",toolbarFiltersCloseLabel:"Close filters panel",toolbarPivot:"Pivot",toolbarPivotLabel:"Configure pivot",toolbarPivotActive:"Pivot active",toolbarSummaries:"Summaries",toolbarSummariesLabel:"Configure summaries",toolbarSummariesActive:e=>`${e} active summaries`,toolbarSummariesPanelLabel:"Summaries configuration",toolbarSummariesClearAll:"Clear all",toolbarSummariesClearAllTooltip:"Clear all summaries",toolbarSummariesEmpty:"No aggregable columns.",toolbarSummariesEmptyHintBefore:"Set",toolbarSummariesEmptyHintAfter:"on a column to enable.",pivotPanelLabel:"Pivot configuration",pivotMode:"Pivot Mode",pivotReset:"Reset",pivotResetTooltip:"Reset pivot",pivotRowFields:"Row Fields",pivotColumnFields:"Column Fields",pivotValueFields:"Value Fields (aggregated)",pivotRowFieldsPlaceholder:"Add fields here — each becomes a row label",pivotColumnFieldsPlaceholder:"Add fields here — unique values become column headers",pivotValueFieldsPlaceholder:"Add numeric fields here — values are aggregated",pivotRemoveTooltip:e=>`Remove ${e}`,pivotRemoveRowLabel:e=>`Remove ${e} from Row Fields`,pivotRemoveColumnLabel:e=>`Remove ${e} from Column Fields`,pivotRemoveValueLabel:(e,t)=>`Remove ${e} (${t}) from Value Fields`,pivotAggregationTooltip:"Aggregation function",pivotAggregationLabel:e=>`Aggregation function for ${e}`,pivotAvailableFields:"Available Fields",pivotAllFieldsInUse:"All fields are in use.",pivotAddRow:"Row",pivotAddColumn:"Col",pivotAddValue:"Val",pivotAddRowTooltip:"Add to Row Fields",pivotAddColumnTooltip:"Add to Column Fields",pivotAddValueTooltip:"Add to Value Fields",pivotAddRowLabel:e=>`Add ${e} to Row Fields`,pivotAddColumnLabel:e=>`Add ${e} to Column Fields`,pivotAddValueLabel:e=>`Add ${e} to Value Fields`,aiAssistantTitle:"Ask AI",aiAssistantClose:"Close",aiAssistantPromptLabel:"Prompt",aiAssistantPlaceholder:"Ask about this table…",aiAssistantStartDictation:"Dictate a prompt",aiAssistantStopDictation:"Stop dictation",aiAssistantAsk:"Ask",aiAssistantStop:"Stop",aiAssistantSuggestions:"Suggestions",aiAssistantAppliedChanges:"Applied changes",aiAssistantRemoveChange:e=>`Remove ${e}`,aiAssistantUndo:"Undo",aiAssistantIgnored:"Ignored",aiAssistantIgnoredItem:e=>`Ignored: ${e}`,aiAssistantEarlier:"Earlier",aiAssistantThinking:"Thinking…",aiAssistantStopped:"Stopped",aiAssistantUndone:"Undone",aiAssistantChangeRemoved:"Change removed",aiAssistantApplied:(e,t)=>{const n=e===0?"No changes":`Applied ${e} ${jo(e,"change","changes")}`;return t>0?`${n}, ${t} ignored`:n},aiAssistantNotValidated:"The reply was not validated",aiAssistantFailed:e=>`The assistant could not answer: ${e}`,aiAssistantUnknownError:"Unknown error",paginationLabel:"Pagination",paginationFirstPageLabel:"Go to first page",paginationFirstPageTooltip:"First page",paginationPreviousPageLabel:"Go to previous page",paginationPreviousPageTooltip:"Previous page",paginationNextPageLabel:"Go to next page",paginationNextPageTooltip:"Next page",paginationLastPageLabel:"Go to last page",paginationLastPageTooltip:"Last page",cellSelectionStatsCount:"Count",cellSelectionStatsSum:"Sum",cellSelectionStatsAverage:"Average"},Xc=Object.keys(Zi);function Yc(e,t,n){const o=t[n];o!==void 0&&(e[n]=o)}function qo(e){const t={...Zi};e&&Xc.forEach(l=>Yc(t,e,l));const n=e?.headerFilterOperators,o=e?.filterPanelOperators,r=e?.toolbarAggregationFunctions,i=e?.pivotAggregationFunctions;return{...t,headerFilterOperator:l=>n?.[l]??Ji[l]??l,filterPanelOperator:l=>o?.[l]??l,toolbarAggregationFunction:l=>r?.[l]??l,pivotAggregationFunction:l=>i?.[l]??l.toUpperCase()}}const Qi=s.createContext(qo(void 0));function Le(){return s.useContext(Qi)}function Xo({isExpanded:e,onClick:t,variant:n="chevron",tabIndex:o}){const r=Le();return d.jsx("button",{className:`ogx-expand-icon ${e?"ogx-expand-icon--expanded":""}`,onClick:i=>{t&&t(i)},"aria-label":e?r.rowCollapseLabel:r.rowExpandLabel,type:"button",tabIndex:o,children:n==="plus-minus"?d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[d.jsx("path",{d:"M4 8H12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),d.jsx("path",{d:"M8 4V12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:e?0:1,transition:"opacity 0.2s ease",transformOrigin:"center"}})]}):d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ogx-expand-icon__chevron","aria-hidden":"true",children:d.jsx("path",{d:"M6 4L10 8L6 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}function Jc({renderFn:e}){"use no memo";return d.jsx(d.Fragment,{children:e()})}function Zc({field:e,message:t}){const n=Le();return d.jsx("div",{className:"ogx__cell-error",role:"img","aria-label":n.cellErrorLabel(e),title:t??n.cellErrorTooltip,children:"⚠"})}function Qc(e,t){return Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((n,o)=>Object.is(n,t[o])):Object.is(e,t)}class Et extends s.Component{constructor(t){super(t),this.state={hasError:!1,error:null,resetKey:t.resetKey}}static getDerivedStateFromProps(t,n){return Qc(t.resetKey,n.resetKey)?null:n.hasError?{hasError:!1,error:null,resetKey:t.resetKey}:{resetKey:t.resetKey}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){process.env.NODE_ENV!=="production"&&console.warn(`[CellErrorBoundary] field="${this.props.field}"`,t,n.componentStack)}render(){return this.state.hasError?d.jsx(Zc,{field:this.props.field,message:this.state.error?.message}):d.jsx(Jc,{renderFn:this.props.renderFn})}}function ed(e,t,n){if(!t||!n)return{valueGetter:e.valueGetter,valueFormatter:e.valueFormatter};const o=l=>n.has(l.id),r=e.valueGetter,i=e.valueFormatter;return{valueGetter:r?l=>o(l.row)?l.value:r(l):void 0,valueFormatter:l=>o(l.row)?Tn(l.value,t,e,l.row):i?i(l):l.value==null?"":String(l.value)}}function el(e,t){if(!t)return e;const n=t.left??[],o=t.right??[],r=i=>{const l=nt(i.field,t);return l==="left"?n.indexOf(i.field)-n.length:l==="right"?1+o.indexOf(i.field):0};return[...e].sort((i,l)=>r(i)-r(l))}const Kn=e=>e.formattedValue??e.value;function tl(e,t,n){const o=e.renderCell;if(!o)return{useDefault:!0};const r=!!t.rowMeta?.isGroupRow;if(!n){const l=o(t);return r&&l===void 0?{useDefault:!0}:{useDefault:!1,content:l}}let i;try{i=o(t)}catch(l){return{useDefault:!1,content:d.jsx(Et,{field:e.field,resetKey:t.row,renderFn:()=>{throw l}})}}return r&&i===void 0?{useDefault:!0}:{useDefault:!1,content:d.jsx(Et,{field:e.field,resetKey:t.row,renderFn:()=>i})}}function td(e,t,n){const o=e.rowMeta;if(!o?.isGroupRow)return Kn(e);if(o.isGroupFooter)return null;const r=o.descendantCount;if(t&&o.hasChildren){const i=o.groupLabel??`${o.groupingField}: ${String(o.groupingValue)}`;return d.jsxs("div",{className:"ogx__group-cell-content",children:[i,r!==void 0?` (${r})`:""]})}return n?d.jsxs("div",{className:"ogx__group-cell-content",children:[o.groupLabel,r!==void 0&&r>0?` (${r})`:""]}):Kn(e)}const nd=e=>e.id;function od(e){const{activeColumns:t,isHierarchyEnabled:n,isRowGrouping:o,isTreeData:r,activeHierarchyHandlers:i,columnVisibilityModel:l,columnOrder:c,onColumnOrderChange:a,onColumnOrderModelChange:u,disableColumnReorder:f,pivotMode:p,checkboxSelection:b,hasDetailPanel:x,rowReordering:w,initialState:g,setColumns:h,pinnedColumns:m,getRowId:C=nd,aggregationModel:y,groupingRows:_}=e,v=s.useMemo(()=>t.map(B=>B.field),[t]),[k,M]=s.useState(()=>g?.columns?.columnOrder??null),E=p?v.join("\0"):"",[I,L]=s.useState(null),N=I&&I.key===E?I.order:v,F=p?N:c??(k??v),T=s.useCallback(B=>{if(p){L(W=>{const ae=W&&W.key===E?W.order:v;return{key:E,order:typeof B=="function"?B(ae):B}});return}M(W=>typeof B=="function"?B(W??v):B)},[p,E,v]),P=s.useCallback(B=>p&&B.hideable===!1||l[B.field]!==!1,[p,l]),A=s.useMemo(()=>{if(!n)return;const B=new Map(F.map((Q,U)=>[Q,U])),W=Q=>B.get(Q.field)??t.indexOf(Q),ae=[...t].sort((Q,U)=>W(Q)-W(U));return(el(ae.filter(Q=>l[Q.field]!==!1),m)[0]??t[0])?.field},[n,F,t,l,m]),G=s.useMemo(()=>{if(!n)return t;const B=o?_:void 0;return t.map(W=>{const ae=ed(W,y?.[W.field],B);return W.field===A?{...W,...ae,renderCell:fe=>{const Q=fe.rowMeta,U=Q?.treeDepth??0,O=!!Q?.hasChildren,$=!!Q?.isExpanded,D=tl(W,fe,!0),V=D.useDefault?td(fe,o,r):D.content;return d.jsxs("div",{style:{display:"flex",alignItems:"center",paddingInlineStart:U*24,width:"100%",height:"100%"},children:[d.jsx("div",{style:{marginInlineEnd:4,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",cursor:O?"pointer":"default",flexShrink:0},children:O?d.jsx("div",{onClick:q=>{q.stopPropagation(),q.preventDefault(),i?.toggleExpansion(C(fe.row))},onMouseDown:q=>{q.stopPropagation()},style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:10,position:"relative"},children:d.jsx(Xo,{isExpanded:$,tabIndex:-1,onClick:q=>{q.stopPropagation(),q.preventDefault(),i?.toggleExpansion(C(fe.row))}})}):null}),d.jsx("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:V})]})}}:{...W,...ae,renderCell:fe=>{const Q=fe.rowMeta;if(!Q?.isGroupRow)return W.renderCell?W.renderCell(fe):Kn(fe);const U=tl(W,fe,!1);return U.useDefault?W.field===Q.groupingField&&!Q.isGroupFooter||fe.value==null?null:Kn(fe):U.content}}})},[t,n,o,r,i,A,C,y,_]),[z,H]=s.useState(()=>g?.columns?.columnWidths??{}),Y=s.useCallback((B,W)=>{H(ae=>({...ae,[B]:W}))},[]);s.useEffect(()=>{h(t)},[t,h]);const K=s.useMemo(()=>{const B=new Map(F.map((W,ae)=>[W,ae]));return[...G].sort((W,ae)=>{const fe=B.get(W.field)??G.indexOf(W),Q=B.get(ae.field)??G.indexOf(ae);return fe-Q})},[G,F]),re=s.useMemo(()=>K.filter(P),[K,P]),R=s.useCallback((B,W)=>{(p||!c)&&T(B),W&&a?.(W),p||u?.(B)},[p,c,T,a,u]),te=s.useCallback((B,W)=>{const ae=K.map(Q=>Q.field),[fe]=ae.splice(B,1);ae.splice(W,0,fe),R(ae,{column:K[B],oldIndex:B,targetIndex:W})},[K,R]),ie=Hc({columns:K,onColumnOrderChange:s.useCallback(({oldIndex:B,targetIndex:W})=>te(B,W),[te]),disableColumnReorder:f}),ce=s.useCallback((B,W)=>{const ae=K.findIndex(Q=>Q.field===B),fe=K.findIndex(Q=>Q.field===W);ae===-1||fe===-1||ae===fe||te(ae,fe)},[K,te]),J=s.useCallback(()=>{R(v)},[R,v]),se=s.useMemo(()=>el(re,m),[re,m]),ne=s.useMemo(()=>{const B=[];return w&&B.push({field:St,sortable:!1,editable:!1}),x&&B.push({field:_t,sortable:!1,editable:!1}),b&&B.push({field:Je,sortable:!1,editable:!1}),[...B,...se]},[se,b,x,w]),j=s.useMemo(()=>new Map(se.map((B,W)=>[B.field,W])),[se]);return{effectiveColumns:G,hierarchyField:A,orderedColumns:K,visibleOrderedColumns:re,renderOrderedColumns:se,navigationColumns:ne,columnIndexMap:j,columnWidths:z,effectiveColumnOrder:F,setInternalColumnOrder:T,columnReorderHandlers:ie,moveColumn:ce,resetColumnOrder:J,handleColumnResize:Y}}function rd(){const[e,t]=s.useState(()=>new Map),n=s.useCallback((o,r)=>{t(i=>{if(i.get(o)===r)return i;const l=new Map(i);return l.set(o,r),l})},[]);return{detailPanelHeights:e,reportDetailPanelHeight:n}}function id(e){const{hasDetailPanel:t,controlledExpandedRowIds:n,onDetailPanelExpandedRowIdsChange:o,rowMetaMap:r}=e,[i,l]=s.useState(new Set),c=n??i,a=s.useMemo(()=>Na(c,r),[c,r]),u=s.useCallback(b=>{if(r.get(b)?.isGroupRow)return;const x=new Set(c);x.has(b)?x.delete(b):x.add(b),n===void 0&&l(x),o?.(x)},[c,r,n,o]),{detailPanelHeights:f,reportDetailPanelHeight:p}=rd();return{hasDetailPanel:t,expandedRowIds:a,handleDetailPanelToggle:u,detailPanelHeights:f,reportDetailPanelHeight:p}}const ld=new Set(["__group__"]),cn=e=>!ld.has(e);function nl(e){return Object.keys(e).every(cn)?e:Object.fromEntries(Object.entries(e).filter(([n])=>cn(n)))}function sd(e){const t={...e};return e.left&&(t.left=e.left.filter(cn)),e.right&&(t.right=e.right.filter(cn)),t}function ad(e){const{onStateChange:t,sortModel:n,filterModel:o,effectivePaginationModel:r,columnWidths:i,effectiveColumnOrder:l,columnVisibilityModel:c,pinnedColumns:a,density:u}=e,f=s.useRef(t);s.useLayoutEffect(()=>{f.current=t});const p=s.useRef(null);s.useEffect(()=>{if(!f.current)return;const b={sorting:{sortModel:n},filter:{filterModel:o},pagination:{paginationModel:r},columns:{columnWidths:nl(i),columnOrder:l.filter(cn),columnVisibilityModel:nl(c),pinnedColumns:sd(a)},density:{density:u}},x=JSON.stringify(b);x!==p.current&&(p.current=x,f.current(b))},[n,o,r,i,l,c,a,u])}const cd=200,dd=2e3,ud=178e5;function fd(e){const{paginationRequested:t,isRowGrouping:n,autoHeight:o,viewportHeight:r,renderedRowCount:i,totalRowCount:l,pinnedRowsIgnored:c=!1,scrollHeight:a=0,maxContentHeight:u,reachableRowCount:f,unpinnedRowCount:p,listViewWithoutColumn:b=!1,listViewRowCount:x=0}=e,w=s.useRef(!1),g=s.useRef(!1),h=s.useRef(!1),m=s.useRef(!1),C=s.useRef(!1),y=s.useRef(!1);s.useEffect(()=>{process.env.NODE_ENV==="production"||y.current||x<=dd||(y.current=!0,console.warn(`[OpenGridX] The list view is rendering all ${x} items: it does not virtualize. Above a few thousand items use \`pagination\`, server-side loading, or the grid view. See docs/features/list-view.md.`))},[x]),s.useEffect(()=>{process.env.NODE_ENV==="production"||C.current||!b||(C.current=!0,console.warn("[OpenGridX] `listView` is set without a `listViewColumn`, so the grid view is shown instead. Pass `listViewColumn` to render list items. See docs/features/list-view.md."))},[b]),s.useEffect(()=>{process.env.NODE_ENV==="production"||h.current||!c||(h.current=!0,console.warn("[OpenGridX] `pinnedRows` is ignored while treeData or rowGroupingModel is active: the rows stay in their place in the hierarchy. See docs/features/pinning.md."))},[c]),s.useEffect(()=>{if(process.env.NODE_ENV==="production"||m.current||u===void 0)return;const _=Number.isFinite(u);if(_?a<=u:a<=ud)return;m.current=!0;const v=_&&f!==void 0&&p!==void 0?`Only the first ${f.toLocaleString("en-US")} of ${p.toLocaleString("en-US")} rows can be scrolled to in this browser. `:"The last rows may not be reachable by scrolling. ";console.warn(`[OpenGridX] The grid content is ${Math.round(a)}px tall, more than this browser lays out (about 17.9M px in Firefox, 33.5M px in Chrome and Safari). `+v+'Load the rows on demand with a `dataSource` (server-side pages or infinite scroll, docs/features/data-source.md), use `pagination`, or a smaller rowHeight (density="compact"). See docs/features/virtualization.md#the-browser-height-limit.')},[a,u,f,p]),s.useEffect(()=>{process.env.NODE_ENV==="production"||w.current||t&&n&&(w.current=!0,console.warn("[OpenGridX] `pagination` is ignored while `rowGroupingModel` is active — all group rows render in one scrollable view. Give the grid a bounded height so it virtualizes. See docs/features/tree-data-grouping.md."))},[t,n]),s.useEffect(()=>{process.env.NODE_ENV==="production"||g.current||o||r>0&&l>cd&&i>=l&&r>=a&&(g.current=!0,console.warn(`[OpenGridX] The grid viewport is ${Math.round(r)}px tall and is rendering all ${l} rows, so row virtualization is effectively off: the grid fills its container, and the container grows to fit every row. Give the container a definite height (for example \`height: 600px\` or \`100vh\`). If the container, or any ancestor up to the sized one, is a flex or grid item, add \`min-height: 0\` to it. Alternatively pass a \`height\` prop, or \`autoHeight\` if rendering every row is intended. See docs/features/virtualization.md.`))},[o,r,i,l,a])}function gd(e){return typeof window>"u"||typeof window.getComputedStyle!="function"||typeof navigator<"u"&&/jsdom/i.test(navigator.userAgent)?!1:window.getComputedStyle(e).display!=="flex"}let ol=!1;function pd(e){s.useEffect(()=>{if(process.env.NODE_ENV==="production"||ol)return;const t=e.current;!t||!gd(t)||(ol=!0,console.warn("[OpenGridX] The grid stylesheet is not loaded, so the grid is unstyled and renders every row (its viewport does not scroll). Add `import '@opencorestack/opengridx/styles'` once in your app root. See README.md, Getting Started."))},[e])}const rl=e=>JSON.stringify(Array.from(e,t=>typeof t=="number"?["n",t]:["s",t]));function hd(e){const{selectedRowIds:t,rowsLookup:n,rowMetaMap:o,enabled:r,onSelectionModelChange:i}=e,l=s.useMemo(()=>{if(!r||t.size===0)return t;let u=!1;for(const p of t)if(!n.has(p)&&!o.has(p)){u=!0;break}if(!u)return t;const f=new Set;for(const p of t)(n.has(p)||o.has(p))&&f.add(p);return f},[r,t,n,o]),c=s.useRef(i);s.useLayoutEffect(()=>{c.current=i});const a=s.useRef(null);return s.useEffect(()=>{if(l===t){a.current=null;return}const u=`${rl(t)}|${rl(l)}`;a.current!==u&&(a.current=u,c.current(Array.from(l)))},[l,t]),l}function jn(e,t,n,o){if(n&&o)return t.length>0?[t[t.length-1]]:Array.from(e);const r=new Set(e);return t.forEach(i=>n?r.add(i):r.delete(i)),Array.from(r)}function md(e,t,n){return n?e.has(t)?[]:[t]:jn(e,[t],!e.has(t),!1)}function il(e,t){return t.length===e.size&&t.every(n=>e.has(n))}function wd(e){const{selectedRowIds:t,onSelectionModelChange:n,disableMultipleRowSelection:o,selectableRowIds:r}=e,i=s.useCallback(p=>{il(t,p)||n(p)},[t,n]),l=s.useCallback((p,b)=>{i(jn(t,[p],b,o))},[i,t,o]),c=s.useCallback(p=>{i(md(t,p,o))},[i,t,o]),a=s.useCallback(p=>{i(jn(t,r,p,!1))},[i,t,r]),{allSelected:u,someSelected:f}=s.useMemo(()=>{let p=0;for(const x of r)t.has(x)&&p++;const b=r.length>0&&p===r.length;return{allSelected:b,someSelected:!b&&p>0}},[r,t]);return{toggleRow:l,clickRow:c,selectAll:o?void 0:a,allSelected:u,someSelected:f}}const ll=new WeakMap;function bd(e,t){const n=new Array(e.length),o=new Map;for(let r=0;r<e.length;r++){const i=t(e[r]);n[r]=i,o.has(i)||o.set(i,r)}return{rowIds:n,rowIndexById:o}}function Yo(e,t,n){let o=ll.get(t);const r=o?.get(n);if(r&&r.rows.length===e.length){const l=r.rows,c=r.value.rowIds;let a=!0;for(let u=0;u<e.length;u++){const f=e[u];if(f!==l[u]&&t(f)!==c[u]){a=!1;break}}if(a)return r.rows=e,r.value}const i=bd(e,t);return o||(o=new Map,ll.set(t,o)),o.set(n,{rows:e,value:i}),i}function xd(e){const{dataRows:t,getRowId:n,isPivotActive:o,selectedRowIds:r,onSelectionModelChange:i,disableMultipleRowSelection:l,disableRowSelectionOnClick:c,isHierarchyEnabled:a,rowMetaMap:u,activeHierarchyHandlers:f,onRowClick:p}=e,b=s.useMemo(()=>{const{rowIds:v}=Yo(t,n,"data");return o?v.filter(k=>k!==Bt):v},[t,n,o]),x=wd({selectedRowIds:r,onSelectionModelChange:i,disableMultipleRowSelection:l,selectableRowIds:b}),{clickRow:w,toggleRow:g}=x,h=s.useCallback(v=>{const{id:k}=v,M=a?u.get(k):void 0;if(M?.isGroupRow){M.hasChildren&&f?.toggleExpansion(k);return}p?.(v),!c&&!je(k,u)&&w(k)},[a,f,p,u,c,w]),m=s.useCallback((v,k)=>{je(v,u)||g(v,k)},[u,g]),C=s.useRef({rowClick:h,selectionChange:m});s.useLayoutEffect(()=>{C.current={rowClick:h,selectionChange:m}});const y=s.useCallback(v=>C.current.rowClick(v),[]),_=s.useCallback((v,k)=>C.current.selectionChange(v,k),[]);return{rowSelection:x,handleRowClick:y,handleSelectionChange:_}}function Jo(e,t,n,o){return o?nc(e,t,n):n?[{field:t,sort:n}]:e.filter(r=>r.field!==t)}function Cd(e){const{sortModel:t,onSortModelChange:n}=e,o=s.useCallback((i,l)=>{n(Jo(t,i,l,!1))},[t,n]),r=s.useCallback((i,l)=>{n(Jo(t,i,l,!0))},[t,n]);return{handleSort:o,handleSortAdd:r}}function yd(e){const{columnVisibilityModel:t,onColumnVisibilityModelChange:n,pinnedColumns:o,onPinnedColumnsChange:r}=e,i=s.useRef({columnVisibilityModel:t,pinnedColumns:o});s.useLayoutEffect(()=>{i.current={columnVisibilityModel:t,pinnedColumns:o}});const l=s.useCallback(a=>{const u={...i.current.columnVisibilityModel,[a]:!1};i.current={...i.current,columnVisibilityModel:u},n(u)},[n]),c=s.useCallback((a,u)=>{const f=Sa(i.current.pinnedColumns,a,u);i.current={...i.current,pinnedColumns:f},r(f)},[r]);return{handleHideColumn:l,handlePinColumn:c}}function vd(e){const{apiRef:t}=e,n=s.useRef(e);s.useLayoutEffect(()=>{n.current=e}),s.useLayoutEffect(()=>{const o=t.current,r=()=>n.current;o.getSortModel=()=>r().sortModel,o.sortColumn=(a,u)=>{const{sortModel:f,multiSort:p,onSortModelChange:b}=r(),x=Jo(f,a,u,p);n.current={...r(),sortModel:x},b(x)},o.getFilterModel=()=>r().filterModel,o.setFilterModel=a=>{n.current={...r(),filterModel:a},r().onFilterModelChange(a)};const i=a=>{n.current={...r(),paginationModel:a},r().onPaginationModelChange(a)};o.setPage=a=>i({...r().paginationModel,page:a}),o.setPageSize=a=>i({...r().paginationModel,pageSize:a,page:0});const l=()=>{const a=r().getPendingRowSelectionModel?.();return a?new Set(a):r().selectedRowIds},c=(a,u)=>{const{disableMultipleRowSelection:f,onRowSelectionModelChange:p,isSyntheticRowId:b}=r(),x=b?a.filter(h=>!b(h)):a;if(x.length===0)return;const w=l(),g=jn(w,x,u,f);il(w,g)||(n.current={...r(),selectedRowIds:new Set(g)},p(g))};o.getSelectedRows=()=>Array.from(l()),o.selectRow=(a,u=!0)=>c([a],u),o.selectRows=(a,u=!0)=>c(a,u),o.getVisibleRows=()=>r().getVisibleRows(),o.getAllFilteredRows=()=>r().getAllFilteredRows(),o.getVisibleColumns=()=>r().visibleColumns,o.setSortModel=a=>{n.current={...r(),sortModel:a},r().onSortModelChange(a)},o.setRowGroupingModel=a=>{n.current={...r(),rowGroupingModel:a},r().onRowGroupingModelChange(a)},o.setAggregationModel=a=>{n.current={...r(),aggregationModel:a},r().onAggregationModelChange(a)},o.setColumnVisibilityModel=a=>{n.current={...r(),columnVisibilityModel:a},r().onColumnVisibilityModelChange(a)},o.setPivotModel=a=>{n.current={...r(),pivotModel:a},r().onPivotModelChange(a)},o.getGridAiState=()=>{const{filterModel:a,sortModel:u,rowGroupingModel:f,aggregationModel:p,pivotModel:b,columnVisibilityModel:x}=r();return{filterModel:a,sortModel:u,rowGroupingModel:f,aggregationModel:p,pivotModel:b,columnVisibilityModel:x}}},[t])}function Sd(e){const{controlledState:t,interactions:n,api:o}=e,{sortModel:r,handleSortModelChange:i,filterModel:l,handleFilterModelChange:c,effectivePaginationModel:a,handlePaginationModelChange:u,handleRowSelectionModelChange:f,rowGroupingModel:p,handleRowGroupingModelChange:b,aggregationModel:x,handleAggregationModelChange:w,columnVisibilityModel:g,handleColumnVisibilityModelChange:h,currentPivotModel:m,handlePivotModelChange:C}=t,y=xd({...n,selectedRowIds:o.selectedRowIds,onSelectionModelChange:f,disableMultipleRowSelection:o.disableMultipleRowSelection});return vd({...o,onSortModelChange:i,sortModel:r,filterModel:l,onFilterModelChange:c,paginationModel:a,onPaginationModelChange:u,getPendingRowSelectionModel:t.getPendingRowSelectionModel,onRowSelectionModelChange:f,rowGroupingModel:p,onRowGroupingModelChange:b,aggregationModel:x,onAggregationModelChange:w,columnVisibilityModel:g,onColumnVisibilityModelChange:h,pivotModel:m,onPivotModelChange:C}),y}const sl="\0";function _d(e,t){const n=e.filter(o=>t[o.field]===!1).map(o=>o.field).join(sl);return s.useMemo(()=>{const o={};if(n)for(const r of n.split(sl))o[r]=!1;return Fo(e,o)},[e,n])}function kd({paginationModel:e,currentPage:t,enabled:n,onPaginationModelChange:o}){const r=s.useRef({paginationModel:e,onPaginationModelChange:o});s.useLayoutEffect(()=>{r.current={paginationModel:e,onPaginationModelChange:o}});const i=e.page,l=s.useRef(null);s.useEffect(()=>{if(!n)return;if(t===i){l.current=null;return}const c=`${i}>${t}`;if(l.current===c)return;l.current=c;const{paginationModel:a,onPaginationModelChange:u}=r.current;u({...a,page:t})},[n,t,i])}const Te=()=>{},Zo=()=>Promise.resolve({updated:[],failed:[],skipped:[]});function al(){return{getRow:()=>null,getAllRows:()=>[],getVisibleRows:()=>[],getAllFilteredRows:()=>[],getGroupedExportRows:()=>null,getAggregationResult:()=>null,getAggregationModel:()=>null,getColumn:()=>null,getAllColumns:()=>[],getVisibleColumns:()=>[],selectRow:Te,selectRows:Te,getSelectedRows:()=>[],sortColumn:Te,getSortModel:()=>[],setFilterModel:Te,getFilterModel:()=>({items:[]}),setPage:Te,setPageSize:Te,scrollToIndexes:Te,autosizeColumn:Te,autosizeColumns:Te,copySelectedRows:()=>Promise.resolve(),getCellSelectionModel:()=>[],setCellSelectionModel:Te,selectCellRange:Te,clearCellSelection:Te,getSelectedCells:()=>[],copySelectedCells:()=>Promise.resolve(),pasteText:Zo,undo:Zo,redo:Zo,canUndo:()=>!1,canRedo:()=>!1,clearHistory:Te,setSortModel:Te,setRowGroupingModel:Te,setAggregationModel:Te,setColumnVisibilityModel:Te,setPivotModel:Te,getGridAiState:()=>({}),openAiAssistant:Te,closeAiAssistant:Te}}const Ed=e=>e.id;let cl=!1;function dl(e,t,n){const o=new Map,r=new Map,i=new Map,l=[],c=[],a=[];return e.forEach(u=>{const f=n?.get(u)??t(u);if(o.has(f)){a.push(f);return}o.set(f,u),r.set(u,f),i.set(f,l.length),l.push(f),c.push(u)}),a.length>0&&!cl&&process.env.NODE_ENV!=="production"&&(cl=!0,console.warn(`[OpenGridX] ${a.length} row(s) reuse the id of an earlier row and were ignored (ids: ${a.slice(0,5).map(String).join(", ")}${a.length>5?", …":""}). Every row needs a unique id; pass getRowId if the unique key lives in another field.`)),{idRowsLookup:o,allRows:l,idByRow:r,rows:c,indexById:i}}function Md(e,t,n,o={}){const r=new Map,i=[];return n.forEach(l=>{r.set(l.field,l),i.push(l.field)}),{rows:dl(e,t),columns:{all:n,lookup:r,orderedFields:i,columnVisibilityModel:o},pagination:{rowCount:void 0},pinning:{pinnedColumns:{},pinnedRows:{}},dimensions:{rowHeight:52,headerHeight:56,viewportWidth:0,viewportHeight:0},dataSource:{loading:!1,error:null}}}function ul(e,t){const{idRowsLookup:n,idByRow:o,indexById:r}=e.rows;let i=null;for(const[l,c]of t){const a=r.get(l);if(a===void 0)continue;const u=n.get(l);u!==void 0&&u!==c&&o.delete(u),n.set(l,c),o.set(c,l),e.rows.rows[a]!==c&&(i??=e.rows.rows.slice(),i[a]=c)}return i?{...e,rows:{...e.rows,rows:i}}:e}function Ld(e,t){switch(t.type){case"SET_ROWS":{const n=e.rows.rows,o=typeof t.payload=="function"?t.payload(n):t.payload;return{...e,rows:dl(o,t.getRowId,e.rows.idByRow)}}case"REPLACE_ROW":return ul(e,[[t.id,t.row]]);case"REPLACE_ROWS":return ul(e,t.rows);case"SET_COLUMNS":{const n=new Map,o=[];return t.payload.forEach(r=>{n.set(r.field,r),o.push(r.field)}),{...e,columns:{all:t.payload,lookup:n,orderedFields:o,columnVisibilityModel:e.columns.columnVisibilityModel}}}case"SET_DIMENSIONS":return{...e,dimensions:{...e.dimensions,viewportWidth:t.payload.viewportWidth,viewportHeight:t.payload.viewportHeight}};case"SET_DATASOURCE_LOADING":return{...e,dataSource:{...e.dataSource,loading:t.payload}};case"SET_DATASOURCE_ERROR":return{...e,dataSource:{...e.dataSource,error:t.payload}};case"SET_ROW_COUNT":return{...e,pagination:{...e.pagination,rowCount:t.payload}};default:return e}}function Ad(e){const{rows:t,columns:n,rowHeight:o=52,headerHeight:r=56,columnVisibilityModel:i,initialState:l,syncRows:c=!1}=e,a=e.getRowId??Ed,u=s.useRef(a);s.useLayoutEffect(()=>{u.current=a});const[f]=s.useState(()=>Md(t,a,n,i)),[p,b]=s.useReducer(Ld,{...f,dataSource:l?.dataSource?{...f.dataSource,...l.dataSource}:f.dataSource,pagination:{rowCount:l?.pagination?.rowCount},dimensions:{...f.dimensions,rowHeight:o,headerHeight:r}}),[x,w]=s.useState({rows:t,syncRows:c});(x.rows!==t||x.syncRows!==c)&&(w({rows:t,syncRows:c}),c&&b({type:"SET_ROWS",payload:t,getRowId:a}));const g=s.useRef(p);s.useLayoutEffect(()=>{g.current=p});const h=s.useCallback((L,N)=>{b({type:"SET_ROWS",payload:L,getRowId:u.current})},[]),m=s.useCallback((L,N)=>{b({type:"REPLACE_ROW",id:L,row:N})},[]),C=s.useCallback(L=>{L.size>0&&b({type:"REPLACE_ROWS",rows:L})},[]),y=s.useCallback(L=>{b({type:"SET_COLUMNS",payload:L})},[]),_=s.useCallback((L,N)=>{b({type:"SET_DIMENSIONS",payload:{viewportWidth:L,viewportHeight:N}})},[]),v=s.useCallback(L=>{b({type:"SET_DATASOURCE_LOADING",payload:L})},[]),k=s.useCallback(L=>{b({type:"SET_DATASOURCE_ERROR",payload:L})},[]),M=s.useCallback(L=>{b({type:"SET_ROW_COUNT",payload:L})},[]),[E]=s.useState(()=>({...al(),getRow:L=>g.current.rows.idRowsLookup.get(L)||null,getAllRows:()=>g.current.rows.rows.slice(),getColumn:L=>g.current.columns.lookup.get(L)||null,getAllColumns:()=>g.current.columns.all})),I=s.useRef(E);return{state:p,dispatch:b,apiRef:I,setRows:h,replaceRow:m,replaceRows:C,setColumns:y,setDimensions:_,setDataSourceLoading:v,setDataSourceError:k,setRowCount:M}}function Pd(e){const{onRowOrderChange:t,rows:n,getRowId:o,indexById:r,rowReordering:i=!1}=e,[l,c]=s.useState(null),[a,u]=s.useState(null),f=s.useRef(()=>{}),p=s.useMemo(()=>{if(r)return r;const m=new Map;return n.forEach((C,y)=>m.set(o?o(C):C.id,y)),m},[r,n,o]),b=s.useCallback(m=>p.has(m),[p]),x=s.useCallback(()=>{f.current(),f.current=()=>{},c(null),u(null)},[]);s.useEffect(()=>()=>f.current(),[]);const w=s.useCallback(m=>C=>{if(i){if(!p.has(m)){C.preventDefault();return}f.current(),f.current=Ki(C.currentTarget,x),c(m),C.dataTransfer&&(C.dataTransfer.effectAllowed="move",Ui(C,Vo,String(m)))}},[i,p,x]),g=s.useCallback(m=>C=>{if(!(!i||l===null)){if(!Rn(C,Vo)){x();return}p.has(m)&&(C.preventDefault(),C.dataTransfer&&(C.dataTransfer.dropEffect="move"),a!==m&&u(m))}},[i,l,a,p,x]),h=s.useCallback(m=>C=>{if(C.preventDefault(),l===null||!Rn(C,Vo)){x();return}const y=p.get(l),_=p.get(m);x(),t&&y!==void 0&&_!==void 0&&y!==_&&t({row:n[y],oldIndex:y,targetIndex:_})},[l,t,n,p,x]);return{draggedRowId:l,dragOverRowId:a,canReorderRow:b,onDragStart:i?w:void 0,onDragOver:i?g:void 0,onDragEnd:i?x:void 0,onDrop:i?h:void 0}}const fl=new Map,gl=e=>JSON.stringify(e),Id=e=>`auto-group-${e}`,pl=5,hl=e=>e.slice(0,pl).map(t=>JSON.stringify(t)).join(", ")+(e.length>pl?", …":""),Nd={treeNodes:new Map,rootIds:[],groupingRows:[],syntheticIds:new Set,rowLookup:new Map,issues:[]};function Fd(e,t,n){const o=new Map,r=[],i=[],l=new Set,c=new Map,a=new Map,u=[],f=new Array(e.length),p=new Array(e.length),b=[],x=new Map;e.forEach((g,h)=>{const m=t(g),C=n(g),y=Array.isArray(C)?C.map(_=>String(_)):[];if(f[h]=m,p[h]=y,c.set(m,g),y.length===0)b.push(m);else{const _=gl(y),v=a.get(_);if(v===void 0)a.set(_,m);else{const k=x.get(_)??[v];k.push(m),x.set(_,k)}}o.set(m,{id:m,parentId:null,depth:Math.max(y.length-1,0),groupingKey:y[y.length-1]??"",isExpanded:!1,children:[],serverChildrenCount:g.serverChildrenCount})});const w=g=>{const h=gl(g),m=a.get(h);if(m!==void 0)return m;const C=Id(h),y=g[g.length-1],_={id:C,parentId:null,depth:g.length-1,groupingKey:y,isExpanded:!1,children:[],label:y};o.set(C,_),a.set(h,C),l.add(C);const v={id:C};if(i.push(v),c.set(C,v),g.length===1)r.push(C);else{const k=w(g.slice(0,-1));_.parentId=k,o.get(k)?.children?.push(C)}return C};return e.forEach((g,h)=>{const m=f[h],C=p[h];if(C.length<=1){r.push(m);return}const y=w(C.slice(0,-1)),_=o.get(m);_&&(_.parentId=y),o.get(y)?.children?.push(m)}),b.length>0&&u.push(`[OpenGridX] treeData: getTreeDataPath returned an empty path for row(s) ${hl(b)}. They are shown as top-level rows.`),x.forEach((g,h)=>{u.push(`[OpenGridX] treeData: rows ${hl(g)} have the same path ${h}. Rows under that path are attached to row ${JSON.stringify(g[0])}.`)}),{treeNodes:o,rootIds:r,groupingRows:i,syntheticIds:l,rowLookup:c,issues:u}}function Td(e,t){const{treeNodes:n,rootIds:o,syntheticIds:r,rowLookup:i}=e,l=new Set,c=new Map,a=new Map,u=f=>{const p=n.get(f);if(!p)return!1;const b=[];let x=0;for(const m of p.children??[])u(m)&&(b.push(m),x+=(r.has(m)?0:1)+(a.get(m)??0));c.set(f,b),a.set(f,x);const w=i.get(f),h=!r.has(f)&&w!==void 0&&(t?t(w):!0)||b.length>0;return h&&l.add(f),h};return o.forEach(u),{visible:l,visibleChildren:c,descendantCounts:a}}function Od(e){const{rows:t,getRowId:n,getTreeDataPath:o,treeData:r=!1,defaultGroupingExpansionDepth:i=0,filterModel:l,sortModel:c,onRowExpansionChange:a,columnLookup:u,filterMode:f="client",sortingMode:p="client"}=e,b=r&&!!o,x=s.useMemo(()=>!r||!o?Nd:Fd(t,n,o),[t,o,r,n]),{treeNodes:w,rootIds:g,groupingRows:h,syntheticIds:m,rowLookup:C}=x,y=x.issues.join(`
|
|
2
|
-
`);s.useEffect(()=>{process.env.NODE_ENV==="production"||!
|
|
3
|
-
`).forEach(Y=>console.warn(Y))},[y]);const _=r&&!o;s.useEffect(()=>{process.env.NODE_ENV==="production"||!_||console.warn("[OpenGridX] treeData is set without getTreeDataPath, so the rows are shown as a flat list. Pass getTreeDataPath={(row) => row.path} to build the tree.")},[_]);const v=s.useMemo(()=>f==="server"?null:On(l,u),[f,l,u]),k=s.useMemo(()=>Td(x,v),[x,v]),M=`${r}|${i}`,[E,I]=s.useState(()=>({configKey:M,overrides:new Map})),L=E.configKey===M?E.overrides:fl,N=s.useCallback(Y=>((Y?.children?.length??0)>0||(Y?.serverChildrenCount??0)>0)&&(i===-1||(Y?.depth??0)<i),[i]),S=s.useMemo(()=>{const Y=new Set;return b&&w.forEach((K,re)=>{(L.get(re)??N(K))&&Y.add(re)}),Y},[b,w,L,N]),F=s.useCallback(Y=>{const K=!S.has(Y);if(I(re=>{const R=re.configKey===M?re.overrides:fl,te=new Map(R);return te.set(Y,K),{configKey:M,overrides:te}}),K&&a){const re=w.get(Y);re&&a(re)}},[S,M,w,a]),T=p!=="server"&&!!(c&&c.length>0),P=s.useCallback(Y=>{if(!b)return null;const K=Y?.labelField,re=Y?.expandAll??!1,{visible:R,visibleChildren:te}=k,ie=T&&c?c:[],ce=(j,B)=>{if(m.has(j))return{value:B.field===K?w.get(j)?.label:void 0};const W=C.get(j),ae=u?.byField.get(B.field),fe=W?Me(W,B.field,ae):void 0,Q=ae?.sortComparator;return{value:fe,type:ae?.type,comparator:Q,params:Q&&W?{id:j,field:B.field,row:W,value:fe}:void 0}},J=[],se=new Set,ne=j=>{const B=j.filter(ae=>R.has(ae)),W=ie.length>0?gi(B,ie,ce):B;for(const ae of W){if(se.has(ae))continue;const fe=C.get(ae);if(!fe)continue;se.add(ae),J.push(fe);const Q=te.get(ae);Q&&Q.length>0&&(re||S.has(ae))&&ne(Q)}};return ne(g),J},[b,k,T,c,m,w,C,u,g,S]),A=s.useCallback(Y=>S.has(Y),[S]),G=s.useCallback(Y=>w.get(Y),[w]),z=s.useCallback(Y=>{const K=[];let re=Y;for(;re!==null;){const R=w.get(re);if(!R)break;K.unshift(R.groupingKey),re=R.parentId}return K},[w]),H=s.useMemo(()=>{const Y=new Map,{visibleChildren:K,descendantCounts:re}=k;return w.forEach((R,te)=>{const ie=(R.children?.length??0)===0&&(R.serverChildrenCount??0)>0,ce=m.has(te),J={hasChildren:(K.get(te)?.length??0)>0||ie,treeDepth:R.depth,descendantCount:ie?void 0:re.get(te)??0,isGroupRow:ce,isExpanded:S.has(te)};ce&&(J.groupLabel=R.label),Y.set(te,J)}),Y},[w,m,k,S]);return s.useMemo(()=>({treeNodes:w,groupingRows:h,toggleExpansion:F,isGroupExpanded:A,getVisibleRows:P,getNode:G,getNodePath:z,rowMetaMap:H}),[w,h,F,A,P,G,z,H])}class Dd{base;top;constructor(t,n){this.base=t,this.top=n}get size(){return this.base.size+this.top.size}get(t){const n=this.top.get(t);return n!==void 0||this.top.has(t)?n:this.base.get(t)}has(t){return this.top.has(t)||this.base.has(t)}forEach(t,n){this.base.forEach((o,r)=>t.call(n,o,r,this)),this.top.forEach((o,r)=>t.call(n,o,r,this))}*entries(){yield*this.base.entries(),yield*this.top.entries()}*keys(){yield*this.base.keys(),yield*this.top.keys()}*values(){yield*this.base.values(),yield*this.top.values()}[Symbol.iterator](){return this.entries()}}const ml=e=>e===null?"footer":"inline";function wl(e,t){return mo(()=>e(t),ml(t),"getAggregationPosition","getAggregationPosition threw; the default position is used")}function $d(e,t,n){const o=`${t}: ${String(n)}`,r=e?.groupingValueFormatter;return r?mo(()=>r({field:t,value:n}),o,`groupingValueFormatter:${t}`,`groupingValueFormatter for column "${t}" threw; the group is labelled "${t}: value"`):o}const Gd=[],Hd={},bl=new Map,Qe="";function Bd(e){if(typeof e=="string")return e;if(e===null)return`${Qe}null`;if(e===void 0)return`${Qe}undefined`;if(e instanceof Date)return`${Qe}date:${e.getTime()}`;if(typeof e=="object")try{return`${Qe}object:${JSON.stringify(e)}`}catch{return`${Qe}object:${String(e)}`}return`${Qe}${typeof e}:${String(e)}`}const Wd=(e,t,n)=>`auto-group-${e}-${t}-${n??"root"}`,Vd=e=>`${e}${Qe}footer`,zd=e=>e==="footer"?"f":e===null?"n":"i",Rd=e=>e==="f"?"footer":e==="n"?null:"inline";function Ud(e){const{rows:t,getRowId:n,columns:o,rowGroupingModel:r=Gd,aggregationModel:i=Hd,defaultGroupingExpansionDepth:l=0,filterModel:c,sortModel:a,getAggregationPosition:u=ml,columnLookup:f,filterMode:p="client",sortingMode:b="client"}=e,x=r.join(Qe),w=s.useMemo(()=>x===""?[]:x.split(Qe),[x]),g=JSON.stringify(Object.entries(i)),h=s.useMemo(()=>Object.fromEntries(JSON.parse(g)),[g]),m=Object.keys(h).length>0,C=s.useMemo(()=>{const j=new Map;return(o??[]).forEach(B=>j.set(B.field,B)),j},[o]),y=w.length>0,_=s.useMemo(()=>w.filter(j=>C.get(j)?.groupable!==!1),[w,C]),k=`${_.join(Qe)}|${l}`,[M,E]=s.useState(()=>({configKey:k,overrides:new Map})),I=M.configKey===k?M.overrides:bl,L=s.useMemo(()=>{if(!y||p==="server")return null;const j=On(c,f);return j?new Set(t.filter(B=>j(B))):null},[y,t,p,c,f]),N=s.useMemo(()=>{const j=new Map,B=[],W=[],ae=new Map,fe=new Map,Q=new Map;if(!y)return{treeNodes:j,rootIds:B,groupIds:W,groupRowVariants:ae,groupingRows:fe,rowLookup:Q};const U=(O,$,D)=>{if($>=_.length)return(L?O.filter(le=>L.has(le)):O).map(le=>{const we=n(le);return Q.set(we,le),j.set(we,{id:we,parentId:D,depth:$,groupingKey:"",isExpanded:!1}),we});const V=_[$],q=C.get(V),oe=new Map;for(const X of O){const le=Me(X,V,q),we=Bd(le);let ge=oe.get(we);ge||(ge={value:le,rows:[]},oe.set(we,ge)),ge.rows.push(X)}const Z=[];return oe.forEach((X,le)=>{const we=L?X.rows.filter(me=>L.has(me)):X.rows;if(we.length===0)return;const ge=Wd(V,le,D);Z.push(ge),W.push(ge);const he=m?Fn(we,h,C,"useRowGrouping"):{},ee={[V]:X.value,...he,id:ge},ue={[V]:X.value,id:ge},Ce=m?{...he,id:Vd(ge)}:null;ae.set(ge,{inline:ee,bare:ue,footer:Ce}),fe.set(ge,ee),Ce&&fe.set(Ce.id,Ce);const be={id:ge,parentId:D,depth:$,groupingKey:String(X.value),groupingField:V,groupingValue:X.value,aggregatedValues:he,isExpanded:!1,children:[],label:$d(q,V,X.value),descendantCount:we.length};j.set(ge,be),be.children=U(X.rows,$+1,ge)}),Z};return B.push(...U(t,0,null)),{treeNodes:j,rootIds:B,groupIds:W,groupRowVariants:ae,groupingRows:fe,rowLookup:Q}},[y,t,L,_,m,h,n,C]),{treeNodes:S,rootIds:F,groupIds:T,groupRowVariants:P,groupingRows:A,rowLookup:G}=N,z=s.useCallback(j=>!!(j?.children&&j.children.length>0)&&(l===-1||(j?.depth??0)<l),[l]),H=s.useMemo(()=>{const j=new Set;for(const B of T){const W=S.get(B);!W?.children||W.children.length===0||(I.get(B)??z(W))&&j.add(B)}return j},[T,S,I,z]),Y=s.useCallback(j=>{E(B=>{const W=B.configKey===k?B.overrides:bl,ae=W.get(j)??z(S.get(j)),fe=new Map(W);return fe.set(j,!ae),{configKey:k,overrides:fe}})},[k,S,z]),K=s.useCallback(j=>H.has(j),[H]),re=m?T.map(j=>{const B=S.get(j);return B?zd(wl(u,{...B,isExpanded:H.has(j)})):"i"}).join(""):"",R=s.useMemo(()=>{const j=new Map;return T.forEach((B,W)=>j.set(B,Rd(re[W]))),j},[T,re]),te=m?wl(u,null):"footer",ie=b!=="server"&&!!(a&&a.length>0),ce=s.useCallback(j=>{if(!y)return null;const B=j?.labelField,W=j?.expandAll??!1,ae=ie&&a?a:[],fe=($,D)=>{const V=S.get($),q=P.get($);if(V&&q){const we=V.groupingField??"";if(D.field===we||D.field===B){const ge=f?.byField.get(we),he=ge?.sortComparator;return{value:V.groupingValue,type:ge?.type,comparator:he,params:he?{id:$,field:we,row:q.inline,value:V.groupingValue}:void 0}}return V.aggregatedValues&&Object.prototype.hasOwnProperty.call(V.aggregatedValues,D.field)?{value:V.aggregatedValues[D.field],type:f?.byField.get(D.field)?.type}:{value:void 0}}const oe=G.get($),Z=f?.byField.get(D.field),X=oe?Me(oe,D.field,Z):void 0,le=Z?.sortComparator;return{value:X,type:Z?.type,comparator:le,params:le&&oe?{id:$,field:D.field,row:oe,value:X}:void 0}},Q=[],U=new Set,O=$=>{const D=ae.length>0?gi($,ae,fe):$;for(const V of D){if(U.has(V))continue;U.add(V);const q=P.get(V);if(!q){const we=G.get(V);we&&Q.push(we);continue}const oe=S.get(V),Z=H.has(V),X=R.has(V)?R.get(V)??null:"inline",le=X==="inline"||X==="footer"&&!Z;Q.push(le?q.inline:q.bare),(Z||W)&&oe?.children&&(O(oe.children),Z&&!W&&X==="footer"&&q.footer&&Q.push(q.footer))}};return O(F),Q},[y,ie,a,S,P,G,f,H,R,F]),J=s.useCallback(j=>S.get(j),[S]),se=s.useMemo(()=>{const j=new Map;return S.forEach((B,W)=>{P.has(W)||j.set(W,{hasChildren:!1,treeDepth:B.depth,isGroupRow:!1})}),j},[S,P]),ne=s.useMemo(()=>{const j=new Map;return P.forEach((B,W)=>{const ae=S.get(W);if(!ae)return;const fe={hasChildren:!0,treeDepth:ae.depth,groupingField:ae.groupingField,groupingValue:ae.groupingValue,groupLabel:ae.label,descendantCount:ae.descendantCount,isGroupRow:!0,isExpanded:H.has(W)};j.set(W,fe),B.footer&&R.get(W)==="footer"&&j.set(B.footer.id,{...fe,hasChildren:!1,treeDepth:ae.depth+1,isExpanded:void 0,isGroupFooter:!0})}),new Dd(se,j)},[se,S,P,H,R]);return s.useMemo(()=>({treeNodes:S,groupingRows:A,toggleExpansion:Y,isGroupExpanded:K,getVisibleRows:ce,getNode:J,rowMetaMap:ne,aggregationPositions:R,rootAggregationPosition:te}),[S,A,Y,K,ce,J,ne,R,te])}const Kd=new Map;function jd(e){const{rows:t,getRowId:n,getTreeDataPath:o,isTreeDataRequested:r,isTreeData:i,columns:l,rowGroupingModel:c,isRowGrouping:a,aggregationModel:u,defaultGroupingExpansionDepth:f,filterModel:p,sortModel:b,getAggregationPosition:x,columnLookup:w,filterMode:g,sortingMode:h}=e,m=Od({rows:t,getRowId:n,getTreeDataPath:o,treeData:r,defaultGroupingExpansionDepth:f,filterModel:p,sortModel:b,columnLookup:w,filterMode:g,sortingMode:h}),C=Ud({rows:t,getRowId:n,columns:l,rowGroupingModel:c,aggregationModel:u,defaultGroupingExpansionDepth:f,filterModel:p,sortModel:b,getAggregationPosition:x,columnLookup:w,filterMode:g,sortingMode:h}),y=i?m:a?C:null,_=s.useMemo(()=>i?m.rowMetaMap:a?C.rowMetaMap:Kd,[i,m.rowMetaMap,a,C.rowMetaMap]);return{treeDataHandlers:m,rowGroupingHandlers:C,activeHierarchyHandlers:y,rowMetaMap:_}}function qd(e){const{spanning:t,renderContext:n,offsetTop:o,cumulativeHeights:r}=e;return s.useMemo(()=>{if(!t.hasRowSpan)return{renderContext:n,offsetTop:o};let i=Math.max(0,n.firstRowIndex);for(let l=t.getCenterRowSpanStart(i);l<i;l=t.getCenterRowSpanStart(i))i=l;return i>=n.firstRowIndex?{renderContext:n,offsetTop:o}:{renderContext:{...n,firstRowIndex:i},offsetTop:i>0?r[i-1]??0:0}},[t,n,o,r])}function Xd(e){const{spanning:t,firstColumnIndex:n,lastColumnIndex:o,virtualColumns:r,layout:i,rows:l}=e;return s.useMemo(()=>{if(!t.hasColSpan||i.unpinnedColsWithWidth.length===0)return r;let c=n,a=o,u=!0;for(;u;){u=!1;for(const{row:m,id:C}of l){const y=t.getUnpinnedColSpanRanges(C??m.id);if(y)for(let _=0;_<y.length;_+=2){const v=y[_],k=y[_+1];k<c||v>a||(v<c&&(c=v,u=!0),k>a&&(a=k,u=!0))}}}if(c===n&&a===o)return r;const{leftPinnedCols:f,unpinnedColsWithWidth:p,rightPinnedCols:b,unpinnedAccWidths:x,unpinnedTotalWidth:w}=i,g=c>0?x[c-1]:0,h=w-x[a];return[...f,...g>0?[{field:"__spacer_left__",width:g,isSpacer:!0}]:[],...p.slice(c,a+1),...h>0?[{field:"__spacer_right__",width:h,isSpacer:!0}]:[],...b]},[t,n,o,r,i,l])}function Yd(e){const{headerRowCount:t,pinnedTopCount:n,pinnedBottomCount:o,pageRowCount:r,totalCenterRowCount:i,pageOffset:l}=e;return{rowCount:t+n+i+o,topBase:t+1,centerOffset:t+l+1,bottomBase:t+n+i+1,bottomRowIndexOffset:n+r}}function xl(e){if(!e)return 0;let t=0;const n=(o,r)=>{t=Math.max(t,r);for(const i of o.children)typeof i!="string"&&n(i,r+1)};return e.forEach(o=>n(o,1)),t}function Cl(e){const t=new Map;if(!e)return t;const n=(o,r)=>{const i=[...r,o];for(const l of o.children)typeof l=="string"?t.has(l)||t.set(l,i):n(l,i)};return e.forEach(o=>n(o,[])),t}function Qo(e,t,n){if(!e||e.length===0)return!0;const o=Cl(e),r=o.get(t),i=o.get(n);return(r?.[r.length-1]??null)===(i?.[i.length-1]??null)}function Jd(e,t,n){const o=[];let r=0,i=null,l=null;for(const c of e){const a=c.isSpacer?null:t.get(c.field)?.[n]??null;(i===null||l!==a||i.pinned!==c.pinned)&&(i={key:`${a?a.groupId:"filler"}-${n}-${c.field}`,isGroup:a!==null,label:a?.headerName??"",headerClassName:a?.headerClassName,width:0,flexGrow:0,fields:[],firstDataIndex:r,pinned:c.pinned},l=a,o.push(i)),i.width+=c.width,i.flexGrow+=c.flex??0,c.isSpacer||(i.fields.push(c.field),r++)}return o}function Zd(e){const{columnGroupingModel:t,headerFilterRow:n=!1,pinnedTopCount:o,pinnedBottomCount:r,pagination:i,paginationMode:l,paginationModel:c,paginationRowCount:a,paginatedUnpinnedRowCount:u,sortedUnpinnedRowCount:f}=e,{page:p,pageSize:b}=c;return s.useMemo(()=>Yd({headerRowCount:1+xl(t)+(n?1:0),pinnedTopCount:o,pinnedBottomCount:r,pageRowCount:i?u:f,totalCenterRowCount:i&&l==="server"?Math.max(a,u):f,pageOffset:i?p*b:0}),[t,n,o,r,i,u,f,l,a,p,b])}const Qd=e=>e.id;function eu(e){const{renderContext:t,pinnedTopRows:n,pinnedBottomRows:o,paginatedUnpinnedRows:r,sortedUnpinnedRows:i,pagination:l,getRowId:c=Qd}=e;return s.useMemo(()=>{const{firstRowIndex:a,lastRowIndex:u}=t,f=l?r:i,p=n.length,b=n.map((y,_)=>({row:y,id:c(y),rowIndex:_,pinned:"top"})),x=o.map((y,_)=>({row:y,id:c(y),rowIndex:p+f.length+_,pinned:"bottom"})),w=Math.max(0,a),g=Math.min(f.length,u+1),h=f.slice(w,g).map((y,_)=>({row:y,id:c(y),rowIndex:p+w+_})),m=[...b,...h,...x],C=new Set;return m.filter(y=>C.has(y.id)?!1:(C.add(y.id),!0))},[t,n,o,r,i,l,c])}function tu(e){const{aria:t,spanning:n,virtualization:o,layout:r,pinnedTopRows:i,pinnedBottomRows:l,paginatedUnpinnedRows:c,sortedUnpinnedRows:a,pagination:u,getRowId:f}=e,p=Zd(t),b=qd({spanning:n,renderContext:o.renderContext,offsetTop:o.offsetTop,cumulativeHeights:r.cumulativeHeights}),x=eu({renderContext:b.renderContext,pinnedTopRows:i,pinnedBottomRows:l,paginatedUnpinnedRows:c,sortedUnpinnedRows:a,pagination:u,getRowId:f}),w=Xd({spanning:n,firstColumnIndex:o.renderContext.firstColumnIndex,lastColumnIndex:o.renderContext.lastColumnIndex,virtualColumns:o.virtualColumns,layout:r,rows:x});return{ariaRows:p,spanRowWindow:b,visibleRows:x,renderColumns:w}}const nu=new Set(["__group__","__check__","__actions__"]);function Mt(e){return e.filter(t=>t.exportable!==!1&&!t.isSpacer&&!Ze(t.field)&&!nu.has(t.field))}function ut(e){return!!e&&e.length>0}function yl(e,t,n=o=>o.id){const o=new Set(t);return e.filter(r=>o.has(n(r)))}function dn(e,t,n){return ut(t)?yl(e,t,n):e}function un(e,t){return!!e&&e.length>0&&!ut(t)}function Vt(e,t,n,o,r){if(!o)return null;if(!t||!r||Object.keys(r).length===0)return o;const i=new Map(n.map(l=>[l.field,l]));return Fn(e,r,i,"export")}function fn(e,t){return Me(e,t.field,t)}function gn(e,t,n){if(!t.valueFormatter)return An(n,t);if(n==null)try{return String(t.valueFormatter({value:n,row:e,field:t.field})??"")}catch{return""}return String(t.valueFormatter({value:n,row:e,field:t.field})??"")}function er(e,t,n,o){return n==null?"":Tn(n,t??"",e,o)}function zt(e,t){return t?`${e}: ${t}`:e}function vl(e,t){const n={};return t.forEach(o=>{Object.prototype.hasOwnProperty.call(e,o.field)&&(n[o.field]=e[o.field])}),n}const ou=/^[=+\-@\t\r]/,ru=/^[-+]?(?=[\d.,\s]*\d)[\d.,\s]*%?$/;function qn(e,t=!1){return t||!ou.test(e)||ru.test(e)?e:`'${e}`}const iu=/^[\d\s.,'%+\-()\p{Sc}]*$/u;function lu(e,t,n){return Rt(e)?!n||iu.test(t):!1}function Rt(e){return typeof e=="number"||typeof e=="bigint"||typeof e=="boolean"||e instanceof Date}function Oe(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function su(e){let t=0,n=e.length;for(;t<n&&e[t]==="'";)t++;for(;n>t&&e[n-1]==="'";)n--;return e.slice(t,n)}const au=/[\\/?*:[\]]/g,Sl=31;function tr(e,t=new Set){let n=su(String(e??"").replace(au,"-").trim()).trim();n||(n="Sheet"),n=n.slice(0,Sl).trim();const o=i=>t.has(i.toLowerCase())||i.toLowerCase()==="history";let r=n;for(let i=2;o(r);i++){const l=` (${i})`;r=`${n.slice(0,Sl-l.length).trim()}${l}`}return t.add(r.toLowerCase()),r}const cu=new Set([Je,_t,St]),du=/[\t\n\r"]/;function nr(e){return du.test(e)?`"${e.replace(/"/g,'""')}"`:e}function uu(e){return Mt(e).filter(t=>!cu.has(t.field))}function fu(e,t){const n=t.map(r=>nr(r.headerName||r.field)).join(" "),o=e.map(r=>t.map(i=>nr(gn(r,i,Me(r,i.field,i)))).join(" "));return[n,...o].join(`
|
|
4
|
-
`)}function
|
|
5
|
-
`)}function
|
|
1
|
+
(function(Ce,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("react/jsx-runtime"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-dom"],d):(Ce=typeof globalThis<"u"?globalThis:Ce||self,d(Ce.OpenGridX={},Ce.ReactJSXRuntime,Ce.React,Ce.ReactDOM))})(this,(function(Ce,d,s,ct){"use strict";"use client";function po(e,t,n){return Math.max(t??0,Math.min(n??1/0,e))}function vt(e,t,n=100){if(e.isSpacer)return typeof e.width=="number"?e.width:0;const o=t[e.field]??e.width,r=typeof o=="number"&&Number.isFinite(o)?o:n;return po(r,e.minWidth,e.maxWidth)}const Ge=48;function ot(e,t){return t?t.left?.includes(e)?"left":t.right?.includes(e)?"right":null:null}function ka(e,t){const n=[],o=[],r=[];return t?(e.forEach(i=>{const l=ot(i.field,t);l==="left"?n.push(i):l==="right"?r.push(i):o.push(i)}),t.left&&n.sort((i,l)=>{const c=t.left.indexOf(i.field),a=t.left.indexOf(l.field);return c-a}),t.right&&r.sort((i,l)=>{const c=t.right.indexOf(i.field),a=t.right.indexOf(l.field);return c-a}),{left:n,center:o,right:r}):{left:n,center:e,right:r}}function ho(e,t,n,o,r,i,l,c){const a={};if(!n)return a;let u=(c?Ge:0)+(i&&l?Ge:0)+(o&&r?Ge:0);const f=[];e.forEach(x=>{if(x.isSpacer)return;const y=ot(x.field,n);y==="left"?(a[x.field]=u,u+=vt(x,t)):y==="right"&&f.push(x)});let h=0;for(let x=f.length-1;x>=0;x--)a[f[x].field]=h,h+=vt(f[x],t);return a}function mo(e,t){let n=null,o=null;if(!t)return{lastLeft:n,firstRight:o};for(const r of e){if(r.isSpacer)continue;const i=ot(r.field,t);i==="left"?n=r.field:i==="right"&&o===null&&(o=r.field)}return{lastLeft:n,firstRight:o}}function qr(e,t){return t?t.top?.includes(e)?"top":t.bottom?.includes(e)?"bottom":null:null}function Ea(e,t,n=o=>o.id){const o=[],r=[],i=[];return t?(e.forEach(l=>{const c=qr(n(l),t);c==="top"?o.push(l):c==="bottom"?i.push(l):r.push(l)}),t.top&&o.sort((l,c)=>{const a=t.top.indexOf(n(l)),u=t.top.indexOf(n(c));return a-u}),t.bottom&&i.sort((l,c)=>{const a=t.bottom.indexOf(n(l)),u=t.bottom.indexOf(n(c));return a-u}),{top:o,center:r,bottom:i}):{top:o,center:e,bottom:i}}function Ma(e,t,n){const o=(e?.left??[]).filter(i=>i!==t),r=(e?.right??[]).filter(i=>i!==t);return n==="left"?{left:[...o,t],right:r}:n==="right"?{left:o,right:[...r,t]}:{left:o,right:r}}const Xr=new Set;function St(e,t,n){process.env.NODE_ENV==="production"||Xr.has(e)||(Xr.add(e),console.warn(`[OpenGridX] ${t}.`,n))}function wo(e,t,n,o){try{return e()}catch(r){return St(n,o,r),t}}function Yr(e,t,n){const o=e[t];if(!n?.valueGetter)return{value:o};try{return{value:n.valueGetter({row:e,field:t,value:o})}}catch(r){return{value:void 0,error:r??new Error("valueGetter failed")}}}function Se(e,t,n){if(!n?.valueGetter)return e[t];const{value:o,error:r}=Yr(e,t,n);return r!==void 0&&St(`valueGetter:${t}`,`valueGetter for column "${t}" threw; the value is read as undefined`,r),o}function bo(e,t,n,o){const r=o?.valueFormatter;if(r)try{return r({value:n,row:e,field:t})}catch(i){St(`valueFormatter:${t}`,`valueFormatter for column "${t}" threw; the value is shown unformatted`,i);return}}const Aa=/^[+-]?0[box]/i;function rt(e){if(e==null)return null;if(typeof e=="number")return Number.isNaN(e)?null:e;if(typeof e=="string"){const t=e.trim();if(t===""||Aa.test(t))return null;const n=Number(t);return Number.isFinite(n)?n:null}if(typeof e=="boolean")return null;if(e instanceof Date){const t=e.getTime();return Number.isNaN(t)?null:t}return typeof e=="bigint"?Number(e):null}const Pa=/^(\d{4})-(\d{2})-(\d{2})$/;function tn(e){if(e==null)return null;let t;if(e instanceof Date)t=e;else if(typeof e=="number")t=new Date(e);else if(typeof e=="string"){const n=e.trim();if(n==="")return null;const o=Pa.exec(n);if(o){const r=Number(o[1]),i=Number(o[2])-1,l=Number(o[3]);if(t=new Date(r,i,l),t.getMonth()!==i||t.getDate()!==l)return null}else{if(!Fa(n))return null;t=new Date(n)}}else return null;return Number.isNaN(t.getTime())?null:t}const La=["january","february","march","april","may","june","july","august","september","october","november","december","monday","tuesday","wednesday","thursday","friday","saturday","sunday"],Na=new Set(["t","z","am","pm","gmt","utc","sept"]);function Ia(e){return Na.has(e)?!0:e.length>=3&&La.some(t=>t.startsWith(e))}function Fa(e){let t="";for(let n=0;n<=e.length;n++){const o=n<e.length?e[n].toLowerCase():"";if(o>="a"&&o<="z"){t+=o;continue}if(t!==""&&!Ia(t))return!1;t=""}return!0}function Pn(e){const t=tn(e);return t?t.getFullYear()*1e4+(t.getMonth()+1)*100+t.getDate():null}function Jr(e){const t=tn(e);if(!t)return"";const n=String(t.getFullYear()).padStart(4,"0"),o=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${n}-${o}-${r}`}let Zr=null;function Qr(e){return Zr??=new Intl.DateTimeFormat,Zr.format(e)}function Ta(e,t){if(!e)return;const n=i=>typeof i=="object"?i.value:i,o=i=>typeof i=="object"?i.label:String(i),r=e.find(i=>Object.is(n(i),t))??e.find(i=>String(n(i))===String(t));return r===void 0?void 0:o(r)}function Ln(e,t){if(e==null)return"";switch(t?.type){case"date":{const n=tn(e);return n?Qr(n):String(e)}case"boolean":return e===!0?"Yes":e===!1?"No":String(e);case"singleSelect":return Ta(t.valueOptions,e)??String(e);default:return String(e)}}const xo=200;function Co(e){if(e==="auto")return"auto";const t=typeof e=="string"?Number.parseFloat(e):e;return typeof t=="number"&&Number.isFinite(t)&&t>=0?t:xo}function yo(e,t){if(e)return wo(()=>e(t),void 0,"getDetailPanelHeight","getDetailPanelHeight threw; the panel uses the default height")}function Oa(e,t){const n=Co(e);return n==="auto"?t??xo:n}function Da(e,t){if(t.size===0||e.size===0)return e;let n=!1;const o=new Set;for(const r of e)t.get(r)?.isGroupRow?n=!0:o.add(r);return n?o:e}const $a=e=>e.id;function Ga(e){if(e===void 0)return{type:"auto",value:0};if(typeof e=="number")return{type:"fixed",value:e};if(typeof e=="string"){if(e.toLowerCase()==="auto")return{type:"auto",value:0};if(e.endsWith("%"))return{type:"percentage",value:parseFloat(e)};const t=parseFloat(e);if(!isNaN(t))return{type:"fixed",value:t}}return{type:"fixed",value:100}}function Ha(e,t,n){const o=new Map;e.forEach(g=>{if(!Object.prototype.hasOwnProperty.call(t,g.field)&&g.flex&&g.flex>0){o.set(g.field,{kind:"flex",flex:g.flex});return}const m=Ga(t[g.field]??g.width);m.type==="fixed"?o.set(g.field,{kind:"fixed",width:po(m.value,g.minWidth,g.maxWidth)}):m.type==="percentage"?o.set(g.field,{kind:"percentage",percentage:m.value}):o.set(g.field,{kind:"flex",flex:1})});const r=e.reduce((g,p)=>{const m=o.get(p.field);if(m.kind==="fixed")return g+m.width;if(m.kind==="percentage")return g+100;if(p.flex&&p.flex>0){const C=p.minWidth??150;return g+(C||(typeof p.width=="number"?p.width:150))}return g+(p.minWidth??150)},0),i=Math.max(n,r),l=e.reduce((g,p)=>{const m=o.get(p.field);return m.kind==="fixed"?g+m.width:g},0),c=new Map,a=Math.max(0,i-l);let u=0;e.forEach(g=>{const p=o.get(g.field);if(p.kind==="fixed")c.set(g.field,p.width);else if(p.kind==="percentage"){const m=p.percentage/100*a,C=po(m>0?m:100,g.minWidth??50,g.maxWidth);c.set(g.field,C),u+=C}});const f=Math.max(0,a-u),h=new Map,x=e.flatMap(g=>{const p=o.get(g.field);return p.kind!=="flex"?[]:(h.set(g.field,p.flex),[{field:g.field,flex:p.flex,minWidth:g.minWidth??50,maxWidth:g.maxWidth??1/0,frozen:!1,computedWidth:0}])});let y=0;const w=x.length*2;for(;y<w;){y++;const g=x.filter(A=>!A.frozen);if(g.length===0)break;const p=g.reduce((A,M)=>A+M.flex,0),m=x.reduce((A,M)=>M.frozen?A+M.computedWidth:A,0),C=Math.max(0,f-m);if(p<=0){g.forEach(A=>{A.computedWidth=A.minWidth,A.frozen=!0});break}const b=C/p;let _=0;const v=[],k=[];if(g.forEach(A=>{const M=b*A.flex;M<A.minWidth?(_+=A.minWidth-M,v.push(A)):M>A.maxWidth?(_+=A.maxWidth-M,k.push(A)):A.computedWidth=M}),v.length===0&&k.length===0){g.forEach(A=>{A.frozen=!0});break}_>0?v.forEach(A=>{A.computedWidth=A.minWidth,A.frozen=!0}):_<0?k.forEach(A=>{A.computedWidth=A.maxWidth,A.frozen=!0}):(v.forEach(A=>{A.computedWidth=A.minWidth,A.frozen=!0}),k.forEach(A=>{A.computedWidth=A.maxWidth,A.frozen=!0}))}return x.forEach(g=>c.set(g.field,g.computedWidth)),{widths:c,flexByField:h}}function Ba(e){const{rowHeight:t,pagination:n,paginatedUnpinnedRows:o,sortedUnpinnedRows:r,expandedRowIds:i,getDetailPanelHeight:l,detailPanelHeights:c,pinnedTopRowsLength:a,pinnedBottomRowsLength:u,pinnedTopRows:f,pinnedBottomRows:h,visibleOrderedColumns:x,pinnedColumns:y,columnWidths:w,viewportWidth:g,checkboxSelection:p,hasDetailPanel:m,rowReordering:C,pinCheckboxColumn:b,pinExpandColumn:_,paginationMode:v,isLoading:k,pageSize:A,getRowId:M=$a}=e,N=s.useMemo(()=>{const T=n?o:r,S=(j,Q)=>{const U=M(j);if(!i.has(U))return t;const re=yo(l,{row:j,id:U,rowIndex:Q});return t+Oa(re,c?.get(U))},I=T.length,F=new Array(I),L=new Array(I),E=i.size>0;let O=0;for(let j=0;j<I;j++){const Q=E?S(T[j],a+j):t;F[j]=Q,O=(O||0)+Q,L[j]=O}const B=v==="infinite"&&k&&T.length>0?Math.min(A,20):0,H=(L[L.length-1]||0)+B*t,K=(j,Q)=>j?j.reduce((U,re,q)=>U+S(re,q),0):Q*t,R=K(f,a),X=K(h,u);return{rowHeights:F,cumulativeHeights:L,unpinnedRowsHeight:H,pinnedTopHeight:R,pinnedBottomHeight:X,pinnedTopRowsLength:a,pinnedBottomRowsLength:u,unpinnedRowsLength:I}},[t,n,o,r,i,l,c,a,u,f,h,v,k,A,M]),P=s.useMemo(()=>{const{left:T,center:S,right:I}=ka(x,y),F=(p?Ge:0)+(m?Ge:0)+(C?Ge:0),L=(C?Ge:0)+(m&&_?Ge:0)+(p&&b?Ge:0),{widths:E,flexByField:O}=Ha([...T,...S,...I],w,g-F),B=D=>E.get(D.field)??100,H=D=>({...D,width:B(D),flex:O.get(D.field)??D.flex}),K=11,R=T.map((D,G)=>({...H(D),zIndex:K+G})),X=11,j=I.map((D,G)=>({...H(D),zIndex:X+(I.length-1-G)})),Q=S.map(H),U=Q.map(D=>D.width),re=R.reduce((D,G)=>D+G.width,0),q=j.reduce((D,G)=>D+G.width,0),se=U.reduce((D,G)=>D+G,0),Z=re+se+q+F,$=U.reduce((D,G,W)=>(D.push((D[W-1]||0)+G),D),[]);return{leftPinnedCols:R,rightPinnedCols:j,unpinnedColsWithWidth:Q,unpinnedColWidths:U,unpinnedAccWidths:$,totalWidth:Z,leftWidth:re,rightWidth:q,unpinnedTotalWidth:se,systemColumnsWidth:F,pinnedSystemColumnsWidth:L}},[x,y,w,g,p,m,C,b,_]);return s.useMemo(()=>({...N,...P}),[N,P])}function Je(e){if(!e)return!1;const t=e.ownerDocument.defaultView;return t?t.getComputedStyle(e).direction==="rtl":!1}function Nn(e,t){return t?e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e:e}function $t(e){return Je(e)?-e.scrollLeft:e.scrollLeft}function nn(e,t){e.scrollLeft=Je(e)?-t:t}function ei(e,t){if(!e)return{top:0,right:0};const n=e.getBoundingClientRect();return Je(e)?{top:n.bottom+6,left:n.left}:{top:n.bottom+6,right:t-n.right}}function vo(e,t){const{row:n,field:o,value:r,colDef:i,rowIndex:l,colIndex:c,rowMeta:a}=e;if(!i.editable||a?.isGroupRow)return!1;if(!t)return!0;try{return!!t({row:n,field:o,value:r,colDef:i,rowIndex:l,colIndex:c})}catch{return!1}}const Wa={},on=e=>e==null||typeof e=="string"&&e.trim()==="",ti=e=>{const t=[];for(const n of e){const o=rt(n);o!==null&&t.push(o)}return t},ni=(e,t)=>{let n=null,o=null;for(const r of e){const i=rt(r);i!==null&&(n===null||t(i,n))&&(n=i,o=r)}return n===null?null:o instanceof Date?o:n},dt={sum:e=>ti(e).reduce((t,n)=>t+n,0),avg:e=>{const t=ti(e);return t.length?t.reduce((n,o)=>n+o,0)/t.length:null},count:e=>e.filter(t=>!on(t)).length,min:e=>ni(e,(t,n)=>t<n),max:e=>ni(e,(t,n)=>t>n),unique:e=>new Set(e.filter(t=>!on(t))).size};function So(e,t){return e?e.aggregable===!1?!1:!e.availableAggregationFunctions||e.availableAggregationFunctions.includes(t):!0}function In(e,t,n,o){const r={};for(const[i,l]of Object.entries(t)){const c=n.get(i);if(!So(c,l))continue;const a=dt[l];if(!a){console.warn(`[${o}] Unknown aggregation function: "${l}"`);continue}r[i]=Object.prototype.hasOwnProperty.call(dt,l)?Va(e,i,c,l):a(e.map(u=>Se(u,i,c)))}return r}function Va(e,t,n,o){switch(o){case"sum":case"avg":{let r=0,i=0;for(const l of e){const c=rt(Se(l,t,n));c!==null&&(r+=c,i++)}return o==="sum"?r:i?r/i:null}case"count":{let r=0;for(const i of e)on(Se(i,t,n))||r++;return r}case"min":case"max":{const r=o==="min";let i=null,l=null;for(const c of e){const a=Se(c,t,n),u=rt(a);u!==null&&(i===null||(r?u<i:u>i))&&(i=u,l=a)}return i===null?null:l instanceof Date?l:i}case"unique":{const r=new Set;for(const i of e){const l=Se(i,t,n);on(l)||r.add(l)}return r.size}}}function rn(e,t){return e==null?"—":typeof e=="number"?t==="avg"?e.toLocaleString(void 0,{maximumFractionDigits:2}):e.toLocaleString():String(e)}const za=new Set(["count","unique"]);function oi(e){return e!==void 0&&za.has(e)}function ri(e,t,n){return e?.type==="date"&&(t==="min"||t==="max")&&typeof n=="number"&&Number.isFinite(n)?new Date(n):n}function Fn(e,t,n,o){if(e==null)return"—";if(oi(t))return rn(e,t);const r=ri(n,t,e);if(n?.valueFormatter)try{return String(n.valueFormatter({value:r,row:o??{},field:n.field})??"")}catch{}return r instanceof Date?Number.isNaN(r.getTime())?"":Qr(r):rn(r,t)}const Ra=Object.keys(dt);function Ua(e){return Object.prototype.hasOwnProperty.call(dt,e)}function ii(e){return e.availableAggregationFunctions?Array.from(new Set(e.availableAggregationFunctions.filter(Ua))):Ra}const Gt=new Set(["isEmpty","isNotEmpty"]);function _o(e){return e==null?!0:typeof e=="string"?e.trim()==="":Array.isArray(e)?e.length===0:!1}function Ka(e){return e==null?!0:typeof e=="number"?Number.isNaN(e):typeof e=="string"&&e.trim()===""}const ln=e=>(t,n)=>{const o=rt(t),r=rt(n);return o===null||r===null?!1:e(o,r)},sn=e=>(t,n)=>{const o=Pn(t),r=Pn(n);return o===null||r===null?!1:e(o,r)},li=sn((e,t)=>e===t),si=(e,t)=>{const n=Pn(e),o=Pn(t);return n===null||o===null?!0:n!==o},ai={contains:(e,t)=>e==null||t==null?!1:String(e).toLowerCase().includes(String(t).toLowerCase()),equals:(e,t)=>e==null&&t==null?!0:e==null||t==null?!1:String(e).toLowerCase()===String(t).toLowerCase(),startsWith:(e,t)=>e==null||t==null?!1:String(e).toLowerCase().startsWith(String(t).toLowerCase()),endsWith:(e,t)=>e==null||t==null?!1:String(e).toLowerCase().endsWith(String(t).toLowerCase()),isEmpty:e=>e==null||String(e).trim()==="",isNotEmpty:e=>e!=null&&String(e).trim()!=="","=":ln((e,t)=>e===t),">":ln((e,t)=>e>t),">=":ln((e,t)=>e>=t),"<":ln((e,t)=>e<t),"<=":ln((e,t)=>e<=t),"!=":(e,t)=>{if(_o(t))return!0;const n=rt(e),o=rt(t);return n!==null&&o!==null?n!==o:Ka(e)?!0:String(e).toLowerCase()!==String(t).toLowerCase()},isAnyOf:(e,t)=>{if(e==null)return!1;const n=Array.isArray(t)?t:[t],o=String(e).toLowerCase();return n.some(r=>r!=null&&String(r).toLowerCase()===o)},not:(e,t)=>e instanceof Date?si(e,t):e==null&&t==null?!1:e==null||t==null?!0:String(e).toLowerCase()!==String(t).toLowerCase(),is:(e,t)=>t==null||t===""?!0:e instanceof Date?li(e,t):String(e).toLowerCase()===String(t).toLowerCase(),after:sn((e,t)=>e>t),onOrAfter:sn((e,t)=>e>=t),before:sn((e,t)=>e<t),onOrBefore:sn((e,t)=>e<=t)},ja={is:li,not:si};function qa(e,t){if(!Object.prototype.hasOwnProperty.call(ai,e))return;const n=e;if(t?.type==="date"){const o=ja[n];if(o)return o}return ai[n]}function Xa(e){return"items"in e&&Array.isArray(e.items)}function Ya(e,t){const{field:n,operator:o,value:r}=e;if(!Gt.has(o)&&_o(r))return null;const i=t.columns?.byField.get(n),l=qa(o,i);return l?c=>l(Se(c,n,i),r):(t.warned.has(o)||(t.warned.add(o),console.warn(`Unknown filter operator: ${o}`)),null)}function ko(e,t,n){const o=[];for(const r of e){const i=Xa(r)?ko(r.items,r.logicOperator,n):Ya(r,n);i&&o.push(i)}return o.length===0?null:o.length===1?o[0]:t==="or"?r=>o.some(i=>i(r)):r=>o.every(i=>i(r))}function Eo(e,t){if(t!=null){switch(typeof t){case"string":e.push(t.toLowerCase());return;case"number":Number.isNaN(t)||e.push(String(t));return;case"boolean":case"bigint":e.push(String(t));return}if(t instanceof Date){const n=Jr(t);n&&e.push(n);return}if(Array.isArray(t))for(const n of t)(n==null||typeof n!="object")&&Eo(e,n)}}function Mo(e,t){const n=[];if(!t){for(const o of Object.values(e))Eo(n,o);return n}for(const o of t.quickFilterColumns){const r=Se(e,o.field,o),i=bo(e,o.field,r,o);if(i!=null&&i!=="")n.push(String(i).toLowerCase());else if(o.type==="date"||o.type==="boolean"||o.type==="singleSelect"){const l=Ln(r,o);l!==""&&n.push(l.toLowerCase())}Eo(n,r)}return n}const ci=new WeakMap;function Ja(e,t){if(!t)return Mo(e,t);let n=ci.get(t);n||(n=new WeakMap,ci.set(t,n));let o=n.get(e);return o||(o=Mo(e,t),n.set(e,o)),o}function di(e){return(e??[]).map(t=>String(t??"").trim().toLowerCase()).filter(t=>t!=="")}function ui(e,t){for(let n=0;n<t.length;n++){const o=t[n];let r=!1;for(let i=0;i<e.length;i++)if(e[i].includes(o)){r=!0;break}if(!r)return!1}return!0}function Za(e,t){const n=di(e);return n.length===0?null:o=>ui(Ja(o,t),n)}const fi=new WeakMap;function Qa(e,t){const n=fi.get(t);if(n&&n.rows===e)return n.texts;const o=new Array(e.length);for(let r=0;r<e.length;r++){const i=e[r];o[r]=n&&r<n.rows.length&&n.rows[r]===i?n.texts[r]:Mo(i,t)}return fi.set(t,{rows:e,texts:o}),o}function Tn(e,t){if(!e)return null;const n={columns:t,warned:new Set},o="quickFilterValues"in e?e.quickFilterValues:void 0,r=Za(o,t),i=ko(e.items??[],e.logicOperator??"and",n);return r&&i?l=>r(l)&&i(l):r??i}function Ao(e,t,n){const o=n&&t?di(t.quickFilterValues):[];if(n&&o.length>0){const i=ko(t.items??[],t.logicOperator??"and",{columns:n,warned:new Set}),l=Qa(e,n),c=[];for(let a=0;a<e.length;a++)ui(l[a],o)&&(!i||i(e[a]))&&c.push(e[a]);return c}const r=Tn(t,n);return r?e.filter(i=>r(i)):e}function gi(e){switch(e){case"number":return["=","!=",">",">=","<","<=","isEmpty","isNotEmpty"];case"date":return["is","not","after","onOrAfter","before","onOrBefore","isEmpty","isNotEmpty"];case"boolean":return["is"];case"singleSelect":return["isAnyOf","is","not"];default:return["contains","equals","startsWith","endsWith","isEmpty","isNotEmpty"]}}function Po(e,t){return e==null?"":t==="date"||e instanceof Date?Jr(e)||(typeof e=="string"?e:""):Array.isArray(e)?e.map(n=>String(n)).join(", "):String(e)}const Lo=new Intl.Collator(void 0,{numeric:!0,sensitivity:"accent"}),Ht=0,pi=1,ec=2,No=3,On=4;function an(e,t){return{rank:e,num:t,str:""}}function Dn(e,t){if(e==null)return null;if(t==="number"){if(typeof e=="bigint")return{rank:Ht,num:Number(e),str:"",big:e};const n=rt(e);return n===null?null:an(Ht,n)}if(t==="date"){const n=tn(e);return n?an(pi,n.getTime()):null}switch(typeof e){case"number":return Number.isNaN(e)?null:an(Ht,e);case"bigint":return{rank:Ht,num:Number(e),str:"",big:e};case"boolean":return an(ec,e?1:0);case"string":return{rank:No,num:0,str:e}}if(e instanceof Date){const n=e.getTime();return Number.isNaN(n)?null:an(pi,n)}return{rank:On,num:0,str:String(e)}}function hi(e,t){return e===null&&t===null?0:e===null?1:t===null?-1:e.rank!==t.rank?e.rank-t.rank:e.rank===No||e.rank===On?Lo.compare(e.str,t.str):e.num!==t.num?e.num<t.num?-1:1:e.big!==void 0||t.big!==void 0?$n(e.big??e.num,t.big??t.num):0}function $n(e,t){if(typeof e=="number"&&typeof t=="number"||typeof e=="bigint"&&typeof t=="bigint")return e<t?-1:e>t?1:0;if(typeof e=="number")return-$n(t,e);const n=t;if(!Number.isFinite(n))return n>0?-1:1;const o=Math.floor(n),r=BigInt(o);return e<r?-1:e>r?1:n>o?-1:0}const tc=e=>typeof e=="bigint"&&(e>BigInt(Number.MAX_SAFE_INTEGER)||e<BigInt(Number.MIN_SAFE_INTEGER));function Io(e,t){return e===0?0:t==="asc"?e:-e}function nc(e,t,n,o){return Io(hi(Dn(e,o),Dn(t,o)),n)}function mi(e,t,n){let o;try{o=e(t.value,n.value,t,n)}catch(r){return St(`sortComparator:${t.field}`,`sortComparator for column "${t.field}" threw; the values are treated as equal`,r),0}return typeof o!="number"||Number.isNaN(o)?(St(`sortComparator:${t.field}:nan`,`sortComparator for column "${t.field}" returned ${String(o)}; the values are treated as equal`,void 0),0):o}const oc=e=>e.id;function rc(e,t,n,o=oc){if(t.length===0)return e;if(e.length<2)return[...e];const r=t.map(i=>{const l=n?.byField.get(i.field),c=l?.sortComparator;if(c)return vi(e.map(u=>{const f=Se(u,i.field,l);return{value:f,type:l.type,comparator:c,params:{id:o(u),field:i.field,row:u,value:f}}}));const a=l?.type;return yi(e.length,u=>Se(e[u],i.field,l),()=>a)});return Si(e,t,r)}function wi(e,t,n){if(t.length===0||e.length<2)return[...e];const o=t.map(r=>{const i=e.map(l=>n(l,r));return i.some(l=>l.comparator&&l.params)?vi(i):yi(i.length,l=>i[l].value,l=>i[l].type)});return Si(e,t,o)}const bi=On+1;function xi(e,t){const n=[...e.keys()].sort(Lo.compare);let o=0;for(let r=0;r<n.length;r++){r>0&&Lo.compare(n[r-1],n[r])!==0&&o++;for(const i of e.get(n[r])??[])t[i]=o}}function ic(e,t,n){const o=[];for(let l=0;l<e.length;l++)e[l]===Ht&&o.push(l);const r=l=>n.get(l)??t[l];o.sort((l,c)=>$n(r(l),r(c)));let i=0;for(let l=0;l<o.length;l++)l>0&&$n(r(o[l-1]),r(o[l]))!==0&&i++,t[o[l]]=i}function Ci(e,t,n){const o=e.get(t);o?o.push(n):e.set(t,[n])}function yi(e,t,n){const o=new Uint8Array(e),r=new Float64Array(e),i=new Map,l=new Map;let c=null;for(let a=0;a<e;a++){const u=t(a),f=n(a);if(tc(u)&&f!=="date"&&(c??=new Map).set(a,u),typeof u=="number"&&f!=="date"){Number.isNaN(u)?o[a]=bi:(o[a]=Ht,r[a]=u);continue}const h=Dn(u,f);h===null?o[a]=bi:(o[a]=h.rank,h.rank===No?Ci(i,h.str,a):h.rank===On?Ci(l,h.str,a):r[a]=h.num)}return xi(i,r),xi(l,r),c&&ic(o,r,c),{kind:"encoded",group:o,num:r}}function vi(e){return{kind:"generic",values:e,keys:e.map(({value:t,type:n})=>Dn(t,n))}}function lc(e,t,n){if(e.kind==="encoded"){const i=e.group[t],l=e.group[n];if(i!==l)return i-l;const c=e.num[t],a=e.num[n];return c<a?-1:c>a?1:0}const o=e.values[t],r=e.values[n];return o.comparator&&o.comparator===r.comparator&&o.params&&r.params?mi(o.comparator,o.params,r.params):hi(e.keys[t],e.keys[n])}function Si(e,t,n){const o=e.length,r=new Array(o);for(let c=0;c<o;c++)r[c]=c;const i=n[0];if(n.length===1&&i.kind==="encoded"){const{group:c,num:a}=i,u=t[0].sort==="asc"?1:-1;r.sort((f,h)=>{const x=c[f],y=c[h];if(x!==y)return(x-y)*u;const w=a[f],g=a[h];return w<g?-u:w>g?u:f-h})}else r.sort((c,a)=>{for(let u=0;u<n.length;u++){const f=Io(lc(n[u],c,a),t[u].sort);if(f!==0)return f}return c-a});const l=new Array(o);for(let c=0;c<o;c++)l[c]=e[r[c]];return l}function sc(e,t,n){if(!n)return e.filter(r=>r.field!==t);const o=e.findIndex(r=>r.field===t);return o===-1?[...e,{field:t,sort:n}]:e.map((r,i)=>i===o?{field:t,sort:n}:r)}function Fo(e,t={}){const n=new Map,o=[];for(const r of e)n.set(r.field,r),!(r.isSpacer||r.field.startsWith("__"))&&r.filterable!==!1&&t[r.field]!==!1&&o.push(r);return{byField:n,quickFilterColumns:o}}const Bt="__pivot_grand_total__",ac="__pivot_row__:",_i=e=>`${ac}${JSON.stringify(e.split(ki))}`,cc="Grand Total",ki="\0",Wt="",To=`${Wt}id`,Ei=e=>e==="id"?To:e,Oo={pivotRows:[],pivotColumns:[],colKeys:[],isValid:!1},Mi=e=>e.map(t=>String(t??"")).join(ki),Ai=e=>e===void 0||e===""?null:e;function dc(e,t){const n=e==null,o=t==null;return n||o?n===o?0:n?1:-1:typeof e=="number"&&typeof t=="number"?e-t:e instanceof Date&&t instanceof Date?e.getTime()-t.getTime():typeof e=="boolean"&&typeof t=="boolean"?Number(e)-Number(t):String(e).localeCompare(String(t),void 0,{numeric:!0})}function uc(e,t){for(let n=0;n<e.length;n++){const o=dc(e[n],t[n]);if(o!==0)return o}return 0}function Pi(e,t){if(!e||e.length===0)return null;const n=dt[t](e);return typeof n=="number"||n instanceof Date?n:null}const fc=e=>"logicOperator"in e&&"items"in e,gc=e=>!!(e&&e.items&&e.items.length>0);function pc(e,t){const n=l=>!t.has(l)&&l.includes(Wt),o=l=>fc(l)?l.items.length>0&&l.items.every(o):n(l.field),r=[],i=[];for(const l of e.items??[])(o(l)?i:r).push(l);return{source:{...e,items:r},output:{items:i,logicOperator:e.logicOperator}}}function Li(e,t,n,o={}){const r=new Map(t.map(S=>[S.field,S])),i=S=>r.get(S)?.groupable!==!1,l=n.rowFields.filter(i),c=n.columnFields.filter(i),a=new Set,u=n.valueFields.filter(S=>{if(!So(r.get(S.field),S.aggFn))return!1;const I=`${S.field}${Wt}${S.aggFn}`;return a.has(I)?!1:(a.add(I),!0)});if(l.length===0||u.length===0)return Oo;const f=c.length>0,h=Array.from(new Set(u.map(S=>S.field))),x=(S,I)=>Se(S,I,r.get(I)),y=new Map,w=new Map(f?[]:[["",{values:[]}]]);for(const S of e){const I=l.map(K=>x(S,K)),F=Mi(I);let L=y.get(F);L||(L={labels:I.map(Ai),sample:S,cells:new Map},y.set(F,L));const E=c.map(K=>x(S,K)),O=f?Mi(E):"",B=w.get(O);B?B.sample||(B.sample=S):w.set(O,{values:E.map(Ai),sample:S});let H=L.cells.get(O);H||(H=new Map,L.cells.set(O,H));for(const K of h){const R=x(S,K);if(on(R))continue;let X=H.get(K);X||(X=[],H.set(K,X)),X.push(R)}}const g=Array.from(w.keys()).sort((S,I)=>uc(w.get(S).values,w.get(I).values)),p=(S,I)=>f?`${S}${Wt}${I.field}${Wt}${I.aggFn}`:`${I.field}${Wt}${I.aggFn}`,m=new Map;let C=[];for(const[S,I]of y){const F={id:_i(S)};l.forEach((L,E)=>{F[Ei(L)]=I.labels[E]}),F.id=_i(S);for(const L of g){const E=I.cells.get(L);for(const O of u)F[p(L,O)]=Pi(E?.get(O.field),O.aggFn)}m.set(F.id,I),C.push({row:F,entry:I})}const b=S=>l.includes(S),_=S=>b(S)?r.get(S)?.type:"number",{outputFilterModel:v,sortModel:k}=o;if(gc(v)){const S=[];for(const F of g)for(const L of u)S.push({field:p(F,L),type:"number"});const I=Tn(v,Fo(S));I&&(C=C.filter(({row:F})=>I(F)))}const A=(S,I)=>I==="id"&&b("id")?S[To]:S[I];k&&k.length>0&&(C=[...C].sort((S,I)=>{for(const F of k){const L=A(S.row,F.field),E=A(I.row,F.field),O=b(F.field)?r.get(F.field)?.sortComparator:void 0,B=O?Io(mi(O,{id:S.row.id,field:F.field,row:S.row,value:L},{id:I.row.id,field:F.field,row:I.row,value:E}),F.sort):nc(L,E,F.sort,_(F.field));if(B!==0)return B}return 0}));const M=C.map(S=>S.row);if(C.length>0){const S={id:Bt};l.forEach((I,F)=>{S[Ei(I)]=F===0?cc:""}),S.id=Bt;for(const I of g)for(const F of h){const L=[];for(const{entry:E}of C){const O=E.cells.get(I)?.get(F);if(O)for(const B of O)L.push(B)}for(const E of u)E.field===F&&(S[p(I,E)]=Pi(L,E.aggFn))}M.push(S)}const N=C[0]?.entry.sample,P=S=>S===Bt?N:S===void 0?void 0:m.get(S)?.sample,T=l.map(S=>mc(S,r.get(S),P));for(const S of g){const I=w.get(S),F=f?c.map((L,E)=>{const O=r.get(L),B=hc(O,L,I.values[E],I.sample);return O?.headerName?`${O.headerName}: ${B}`:B}).join(" / "):"";for(const L of u){const E=r.get(L.field),O=L.headerName??E?.headerName??L.field;T.push({field:p(S,L),headerName:F?`${F} — ${O} (${L.aggFn})`:`${O} (${L.aggFn})`,width:140,type:"number",align:"right",headerAlign:"right",sortable:!0,valueFormatter:({value:B,row:H})=>Fn(B,L.aggFn,E,H)})}}return{pivotRows:M,pivotColumns:T,colKeys:g,isValid:!0}}function hc(e,t,n,o){const r=o?bo(o,t,n,e):void 0;return r!==void 0?r:n==null?"":String(n)}function mc(e,t,n){const o={field:e,headerName:t?.headerName??e,width:t?.width??140,sortable:!0,hideable:!1};t&&(t.type!==void 0&&(o.type=t.type),t.align!==void 0&&(o.align=t.align),t.headerAlign!==void 0&&(o.headerAlign=t.headerAlign),t.description!==void 0&&(o.description=t.description),t.minWidth!==void 0&&(o.minWidth=t.minWidth),t.maxWidth!==void 0&&(o.maxWidth=t.maxWidth),t.valueOptions!==void 0&&(o.valueOptions=t.valueOptions)),e==="id"&&(o.valueGetter=({row:c})=>c[To]);const r=c=>c?.id===Bt,i=t?.valueFormatter;i&&(o.valueFormatter=({value:c,row:a})=>r(a)?String(c??""):i({value:c,row:n(a?.id)??a,field:e}));const l=t?.renderCell;return l&&(o.renderCell=c=>r(c.row)?c.formattedValue??String(c.value??""):l({...c,row:n(c.row.id)??c.row})),o}function Ke(e,t){return e===Bt||t?.get(e)?.isGroupRow===!0}const _t="__reorder_col__",kt="__expand_col__",Ze="__checkbox_col__",Qe=e=>e===_t||e===kt||e===Ze,Do=(e,t)=>e===t||e!==null&&t!==null&&e.id===t.id&&e.field===t.field&&!e.headerFilter==!t.headerFilter,wc=new Set(["checkbox","radio","button","submit","reset","image","file","color"]),bc=new Set(["textbox","searchbox","combobox","listbox","slider","spinbutton"]);function Ni(e){const t=e.tagName;if(t==="INPUT")return!wc.has(e.type);if(t==="TEXTAREA"||t==="SELECT"||e.isContentEditable||e.closest('[contenteditable]:not([contenteditable="false"])'))return!0;const n=e.getAttribute("role");return n!==null&&bc.has(n)}const Ii=e=>e!==null&&e.nodeType===1;function Fi(e,t){const n=e.closest(".ogx__detail-panel");if(n&&t.contains(n))return null;const o=e.closest('[role="gridcell"], [role="columnheader"]');return!o||o.closest(".ogx__viewport")!==t?null:o}function Gn(e,t){if(e===t)return"grid";if(!Ii(e)||!t.contains(e))return"foreign";const n=Fi(e,t);return n?n.classList.contains("ogx__cell--editing")?"editor":n===e?"grid":Ni(e)?"foreign":n.classList.contains("ogx__header-cell--checkbox")?"grid":"control":"foreign"}function xc(e,t,n,o){if(!Ii(e))return null;const r=Fi(e,t),i=r?.dataset.field;if(!r||!i)return null;if(r.getAttribute("role")==="columnheader"){const a=r.parentElement;return a?.classList.contains("ogx__header")?{id:null,field:i}:a?.classList.contains("ogx__header-filter-row")?{id:null,field:i,headerFilter:!0}:null}const l=Number(r.parentElement?.getAttribute("data-rowindex")),c=Number.isInteger(l)?n[l]:void 0;return c?{id:o(c),field:i,rowIndex:l}:null}function Ti(e,t){if(!e)return null;for(const n of Array.from(e.children))if(n.dataset.field===t)return n;return null}function $o(e,t,n){if(t.id===null){const r=e.querySelector(`:scope > .ogx__content > .ogx__sticky-top > .ogx__header-wrap > ${t.headerFilter?".ogx__header-filter-row":".ogx__header"}`),i=Ti(r,t.field);return i&&t.field===Ze?i.querySelector("input")??i:i}if(n<0)return null;const o=e.querySelector(`:scope > .ogx__content > .ogx__virtual-container > .ogx__rows > [data-rowindex="${n}"],:scope > .ogx__content > .ogx__sticky-top > .ogx__pinned-rows > [data-rowindex="${n}"],:scope > .ogx__content > .ogx__sticky-bottom > .ogx__pinned-rows > [data-rowindex="${n}"]`);return Ti(o,t.field)}const Oi="__group__";function je(e){return!Qe(e)&&e!==Oi}const ut=(e,t)=>e===t||!!e&&!!t&&e.id===t.id&&e.field===t.field;function Cc(e,t){return e===t?!0:e.length!==t.length?!1:e.every((n,o)=>ut(n.anchor,t[o].anchor)&&ut(n.head,t[o].head))}function Hn(e,t,n){const{rowIds:o,fields:r,rowIndexById:i,colIndexByField:l,spans:c}=n,a={top:e,bottom:e,left:t,right:t};if(!c)return a;const u=o[e],f=r[t],h=c.getSpanOrigin(u,f)??{rowId:u,field:f},x=i.get(h.rowId),y=l.get(h.field);if(x===void 0||y===void 0)return a;const w=Math.max(1,c.getRowSpan(h.rowId,h.field)),g=Math.max(1,c.getColSpan(h.rowId,h.field));return{top:x,bottom:Math.min(o.length-1,x+w-1),left:y,right:Math.min(r.length-1,y+g-1)}}function yc(e,t){if(!t.spans)return e;let{top:n,bottom:o,left:r,right:i}=e,l=!0;const c=a=>{a.top<n&&(n=a.top,l=!0),a.bottom>o&&(o=a.bottom,l=!0),a.left<r&&(r=a.left,l=!0),a.right>i&&(i=a.right,l=!0)};for(;l;){l=!1;for(let a=n;a<=o;a++)c(Hn(a,r,t)),i!==r&&c(Hn(a,i,t));for(let a=r+1;a<i;a++)c(Hn(n,a,t)),o!==n&&c(Hn(o,a,t))}return{top:n,bottom:o,left:r,right:i}}function Bn(e,t){const n=t.rowIndexById.get(e.anchor.id),o=t.rowIndexById.get(e.head.id),r=t.colIndexByField.get(e.anchor.field),i=t.colIndexByField.get(e.head.field);return n===void 0||o===void 0||r===void 0||i===void 0?null:{...yc({top:Math.min(n,o),bottom:Math.max(n,o),left:Math.min(r,i),right:Math.max(r,i)},t),anchorRow:n,anchorCol:r,headRow:o,headCol:i}}const Et=e=>(e.bottom-e.top+1)*(e.right-e.left+1);function vc(e,t,n,o,r,i){const{headRow:l,headCol:c,anchorRow:a,anchorCol:u,top:f,bottom:h,left:x,right:y}=e;let w=l,g=c;switch(t){case"ArrowRight":g=c>=u?y+1:c+1;break;case"ArrowLeft":g=c<=u?x-1:c-1;break;case"ArrowDown":w=l>=a?h+1:l+1;break;case"ArrowUp":w=l<=a?f-1:l-1;break;case"Home":g=0,n&&(w=0);break;case"End":g=i,n&&(w=r);break;case"PageUp":w=l-o;break;case"PageDown":w=l+o;break;default:return null}return w=Math.min(Math.max(w,0),r),g=Math.min(Math.max(g,0),i),w===l&&g===c?null:{row:w,col:g}}function Di(e,t,n,o){const r=o&&o.row===t?o.col:void 0;if(!e||t<e.top||t>e.bottom)return r===void 0?null:{left:0,right:-1,isTop:!1,isBottom:!1,bottomOffset:0,fillHandleCol:r};const i={left:e.left,right:e.right,isTop:t===e.top,isBottom:t===e.bottom,bottomOffset:n?e.bottom-t:0};return r!==void 0&&(i.fillHandleCol=r),i}const Sc=(e,t)=>e===t||!!e&&!!t&&e.left===t.left&&e.right===t.right&&e.isTop===t.isTop&&e.isBottom===t.isBottom&&e.bottomOffset===t.bottomOffset&&e.fillHandleCol===t.fillHandleCol,Go=1,$i=2,Gi=4,Hi=8,Bi=16,Wi=32;function _c(e,t,n,o){if(!e)return 0;const r=e.fillHandleCol===t?Wi:0,i=t+Math.max(1,n)-1;if(t<e.left||i>e.right)return r;let l=Go|r;return e.isTop&&(l|=$i),(e.isBottom||o>1&&o-1>=e.bottomOffset)&&(l|=Gi),t===e.left&&(l|=Hi),i===e.right&&(l|=Bi),l}function Vi(e,t,n){const o=(r,i,l)=>`${r} ${r===1?i:l}`;return`${o(e,"cell","cells")} selected, ${o(t,"row","rows")} by ${o(n,"column","columns")}`}const kc=1e5,zi=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]);function Ec(e,t){const{focusedCell:n,focusedRowIndex:o,allRenderableRows:r,navigationColumns:i,editingHandlers:l,selectedRowIds:c,handleSelectionChange:a,handleDetailPanelToggle:u,setKeyboardMode:f,sortModel:h,handleSort:x,handleSortAdd:y,multiSort:w,isCellEditable:g,pagination:p,pageSize:m,rowMetaMap:C,onRowActivate:b,toggleRowExpansion:_,handleSelectAll:v,rowSelectionEnabled:k,multipleRowSelectionEnabled:A,getDefaultFocus:M,scrollCellIntoView:N,getSpanOrigin:P,getRowId:T,cellSelection:S,headerFilters:I,setFocusedCell:F}=t,L=e.currentTarget,E=Gn(e.target,L);if(E==="foreign"||(f(!0),e.nativeEvent?.isComposing||e.keyCode===229))return;const O=Nn(e.key,Je(L)),B=O===" "||O==="Spacebar",H=!!l.editingCell,K=I?-2:-1,R=(z,ie)=>{const ae=i[ie];!ae||z<K||z>=r.length||(z===K?F({id:null,field:ae.field}):z<0?F({id:null,field:ae.field,headerFilter:!0}):F({id:T(r[z]),field:ae.field,rowIndex:z}),N(z,ae.field))};if(!n){if(!zi.has(O))return;const z=M();if(!z)return;e.preventDefault(),F(z),N(z.rowIndex??-1,z.field);return}const{id:X,field:j}=n,Q=X===null&&!!n.headerFilter,U=X!==null?o:Q?-1:K,re=i.findIndex(z=>z.field===j),q=i.filter(z=>Qe(z.field)).length,se=z=>Ke(z,C),Z=(z,ie,ae)=>{const le=i[ae];return Qe(le.field)?!1:vo({row:z,field:le.field,value:Se(z,le.field,le),colDef:le,rowIndex:ie,colIndex:ae-q,rowMeta:C?.get(T(z))},g)},$=z=>{let ie=U,ae=re;const le=(r.length+1)*i.length;for(let ce=0;ce<le;ce++){if(ae+=z,ae>=i.length?(ae=0,ie++):ae<0&&(ae=i.length-1,ie--),ie<0||ie>=r.length)return null;const de=r[ie];if(!P?.(T(de),i[ae].field)&&Z(de,ie,ae))return{r:ie,c:ae}}return null};if(H){if(O==="Enter")e.preventDefault(),l.stopCellEdit();else if(O==="Escape")e.preventDefault(),l.stopCellEdit({cancel:!0});else if(O==="Tab"&&X!==null){const z=$(e.shiftKey?-1:1);z&&(e.preventDefault(),l.stopCellEdit(),R(z.r,z.c))}return}if(O==="Escape"&&S?.collapseSelection()){e.preventDefault();return}if(O==="Tab"||O==="Escape"||E==="control"&&(O==="Enter"||B))return;if((e.ctrlKey||e.metaKey)&&(O==="a"||O==="A")){if(S){S.selectAllCells()&&e.preventDefault();return}if(!k||!A||!v)return;e.preventDefault(),v(!0);return}if(Q&&(O==="Enter"||B))return;if(X===null){if(O==="Enter"||B){if(e.preventDefault(),j===Ze){$o(L,n,-1)?.click();return}const z=i[re];if(!z||Qe(j)||z.sortable===!1)return;const ie=h.find(le=>le.field===j),ae=ie?ie.sort==="asc"?"desc":null:"asc";(w||e.shiftKey)&&y?y(j,ae):x(j,ae);return}}else if(O==="Enter"||B){e.preventDefault();const z=r[U];if(j===Ze){a(X,!c.has(X));return}if(j===kt){e.shiftKey||u(X);return}if(B){e.shiftKey&&k&&!se(X)&&a(X,!c.has(X));return}if(j===_t)return;if(Z(z,U,re)){l.startCellEdit({id:X,field:j,value:Se(z,j,i[re])});return}if(_&&C?.get(X)?.hasChildren){_(X);return}b?.({row:z,id:X,rowIndex:U});return}if(e.altKey&&(O==="ArrowRight"||O==="ArrowLeft")&&_&&X!==null){e.preventDefault();const z=C?.get(X);z?.hasChildren&&!!z.isExpanded!=(O==="ArrowRight")&&_(X);return}if(!zi.has(O))return;e.preventDefault();const D=r.length-1,G=i.length-1,W=e.ctrlKey||e.metaKey,ee=p?m:10;if(S&&e.shiftKey&&X!==null&&je(j)&&S.extendSelection(O,W,ee,n))return;const V=(z,ie)=>{switch(O){case"ArrowRight":return ie+1>G?{r:z+1,c:0}:{r:z,c:ie+1};case"ArrowLeft":return ie-1<0?{r:z-1,c:G}:{r:z,c:ie-1};case"ArrowDown":return{r:z+1,c:ie};case"ArrowUp":return{r:z-1,c:ie};case"Home":return{r:W?K:z,c:0};case"End":return{r:W?D:z,c:G};case"PageUp":return{r:Math.max(K,z-ee),c:ie};default:return{r:Math.min(D,z+ee),c:ie}}},Y=({r:z,c:ie})=>z>=K&&z<=D&&ie>=0&&ie<=G,J=({r:z,c:ie})=>z>=0?P?.(T(r[z]),i[ie].field)??null:null;let te=V(U,re);if(O.startsWith("Arrow"))for(let z=Y(te)?J(te):null;z&&z.rowId===X&&z.field===j;z=Y(te)?J(te):null)te=V(te.r,te.c);if(!Y(te))return;const ne=J(te);if(ne){const z=r.findIndex(ae=>T(ae)===ne.rowId),ie=i.findIndex(ae=>ae.field===ne.field);z!==-1&&ie!==-1&&(te={r:z,c:ie})}te.r===U&&te.c===re||R(te.r,te.c)}function Mc(e){const t=e.querySelector(".ogx__sticky-bottom");return t?t.getBoundingClientRect().height:0}function Wn(e,t,n,o,r){if(t<0||t>=n.length)return;const i=e.querySelector(".ogx__virtual-container");if(!i)return;const{scrollTop:l,clientHeight:c}=e,a=i.getBoundingClientRect().top-e.getBoundingClientRect().top+l,u=Math.max(o,Mc(e)),f=a+(t===0?0:n[t-1]),h=r!==void 0?Math.min(f+r,a+n[t]):a+n[t];f<l+a?e.scrollTop=Math.max(0,f-a):h>l+c-u&&(e.scrollTop=h-c+u)}function Ho(e,t,n){const{unpinnedAccWidths:o,leftWidth:r,rightWidth:i,systemColumnsWidth:l,pinnedSystemColumnsWidth:c}=n;if(t<0||t>=o.length)return;const a=l+r,u=a+(t>0?o[t-1]:0),f=a+o[t],h=c+r,{clientWidth:x}=e,y=$t(e);u<y+h?nn(e,Math.max(0,u-h)):f>y+x-i&&nn(e,f-x+i)}const Ac=e=>e.id;function Pc(e,t,n,o,r){if(!e||n.length===0)return{cell:null,rowIndex:-1};const i=(n.find(u=>!Qe(u.field))??n[0]).field,l=n.some(u=>u.field===e.field)?e.field:i;if(e.id===null){const u=!!e.headerFilter&&r;return l===e.field&&u===!!e.headerFilter?{cell:e,rowIndex:-1}:{cell:u?{id:null,field:l,headerFilter:u}:{id:null,field:l},rowIndex:-1}}const c=e.rowIndex;let a=c!==void 0&&t[c]&&o(t[c])===e.id?c:t.findIndex(u=>o(u)===e.id);return a===-1?t.length===0?{cell:{id:null,field:l},rowIndex:-1}:(a=Math.min(Math.max(c??0,0),t.length-1),{cell:{id:o(t[a]),field:l,rowIndex:a},rowIndex:a}):{cell:l===e.field?e:{...e,field:l},rowIndex:a}}function Lc(e){const{allRenderableRows:t,navigationColumns:n,checkboxSelection:o,selectedRowIds:r,handleSelectionChange:i,handleDetailPanelToggle:l,editingHandlers:c,setKeyboardMode:a,sortModel:u,handleSort:f,handleSortAdd:h,multiSort:x=!1,isCellEditable:y,pagination:w,pageSize:g,virtualization:p,viewportRef:m,pinnedTopRowCount:C=0,getRowId:b=Ac,rowMetaMap:_,onRowActivate:v,toggleRowExpansion:k,handleSelectAll:A,rowSelectionEnabled:M=!0,multipleRowSelectionEnabled:N=!0,pinCheckboxColumn:P=!0,pinExpandColumn:T=!0,rowHeight:S,getSpanOrigin:I,cellSelection:F,headerFilters:L=!1}=e,[E,O]=s.useState(null),[B,H]=s.useState(!1),K=s.useMemo(()=>Pc(E,t,n,b,L),[E,t,n,b,L]),R=K.cell,X=K.rowIndex,j=s.useRef(!1),Q=s.useRef(!1),U=s.useRef(!1),re=s.useRef(null),q=s.useCallback(Y=>{Q.current=!0,Y.focus({preventScroll:!0}),Q.current=!1},[]),se=s.useCallback(()=>{const Y=m.current;Y&&!Y.contains(Y.ownerDocument.activeElement)&&q(Y)},[m,q]),Z=s.useMemo(()=>n.find(Y=>!Qe(Y.field))??n[0],[n]),$=s.useCallback(()=>{if(o)return{id:null,field:Ze};if(!Z)return null;const Y=t[0];return Y?{id:b(Y),field:Z.field,rowIndex:0}:{id:null,field:Z.field}},[o,Z,t,b]),D=s.useCallback((Y,J)=>{const te=m.current;if(!te)return;const{cumulativeHeights:ne,pinnedBottomHeight:z,columnMetrics:ie}=p;if(Y>=0&&Wn(te,Y-C,ne,z,S),Qe(J)){!(J===_t||J===kt&&T||J===Ze&&P)&&$t(te)>0&&nn(te,0);return}if(!ie)return;const{clientWidth:ae}=te,le=$t(te),{leftPinnedWidth:ce,rightPinnedWidth:de,unpinnedAccWidths:we,unpinnedCols:me,totalSpecialsWidth:pe,pinnedSpecialsWidth:oe}=ie,ue=me.findIndex(fe=>fe.field===J);if(ue===-1)return;const be=pe+ce+(ue>0?we[ue-1]:0),he=pe+ce+we[ue],ge=le+oe+ce,ve=le+ae-de;let ye=le;be<ge?ye=Math.max(0,be-oe-ce):he>ve&&(ye=he-ae+de),ye!==le&&nn(te,ye)},[m,p,C,S,P,T]);s.useLayoutEffect(()=>{const Y=m.current,J=!Do(re.current,R);if(re.current=R,!Y||!R)return;const te=Y.ownerDocument,ne=te.activeElement;let z;if(ne===Y?z=!0:!ne||ne===te.body?z=j.current:Y.contains(ne)?z=J:z=!1,!z)return;const ie=$o(Y,R,X);ie?ie.contains(ne)||ie.focus({preventScroll:!0}):ne!==Y&&q(Y)});const G=s.useCallback(()=>{U.current=!0,a(!1)},[a]),W=s.useCallback(Y=>{const J=Y.currentTarget,te=Y.relatedTarget,ne=!(te instanceof Node&&J.contains(te)),z=U.current;if(U.current=!1,j.current=!0,H(!0),Q.current)return;if(Y.target===J){if(!ne)return;if(z||a(!0),R){const le=$o(J,R,X);le?le.focus({preventScroll:!0}):D(X,R.field);return}const ae=$();ae&&(O(le=>le??ae),D(ae.rowIndex??-1,ae.field));return}const ie=xc(Y.target,J,t,b);ie&&!Do(ie,R)&&O(ie)},[R,X,$,D,a,t,b]),ee=s.useCallback(Y=>{const J=Y.relatedTarget;J instanceof Node&&Y.currentTarget.contains(J)||(j.current=!1,U.current=!1,H(!1),a(!1))},[a]),V=s.useCallback(Y=>{Ec(Y,{focusedCell:R,focusedRowIndex:X,allRenderableRows:t,navigationColumns:n,editingHandlers:c,selectedRowIds:r,handleSelectionChange:i,handleDetailPanelToggle:l,setKeyboardMode:a,sortModel:u,handleSort:f,handleSortAdd:h,multiSort:x,isCellEditable:y,pagination:w,pageSize:g,rowMetaMap:_,onRowActivate:v,toggleRowExpansion:k,handleSelectAll:A,rowSelectionEnabled:M,multipleRowSelectionEnabled:N,getDefaultFocus:$,scrollCellIntoView:D,getSpanOrigin:I,getRowId:b,cellSelection:F,headerFilters:L,setFocusedCell:O})},[R,X,t,n,c,r,i,l,a,u,f,h,x,y,w,g,_,v,k,A,M,N,$,D,I,b,F,L]);return{focusedCell:R,setFocusedCell:O,viewportTabIndex:B?-1:0,ensureGridFocus:se,handleFocus:W,handleBlur:ee,handleKeyDown:V,handleMouseDownCapture:G}}const Bo=[];function Nc(e){const{isPivotActive:t}=e,n=t?Bo:e.rowGroupingModel,o=e.treeData&&!t,r=o&&e.hasTreeDataPath,i=n.length>0;return{rowReordering:e.rowReordering&&!t,hierarchyRowGroupingModel:n,isTreeDataRequested:o,isTreeData:r,isRowGrouping:i,isHierarchyEnabled:r||i,hasGroupingColumn:e.hasGroupingColDef&&(i||r),pagination:e.pagination&&!i&&e.paginationMode!=="infinite",listView:e.listView&&e.hasListViewColumn}}const Wo=new WeakMap,Ri=new WeakMap;function Ic(e){let t=Wo.get(e);return t||(t=new Set(e),Wo.set(e,t)),t}function Fc(e,t){Wo.set(e,t)}function Tc(e,t){Ri.set(e,t)}function Oc(e,t){return Ri.get(e)===t}const Dc=[],$c={rowFields:[],columnFields:[],valueFields:[]},Ui=100;function Gc(e){return!e||e.length===0||e.includes(Ui)?Ui:e[0]}function Hc(e){const{initialState:t,sortModel:n,onSortModelChange:o,filterModel:r,onFilterModelChange:i,aggregationModel:l,onAggregationModelChange:c,rowGroupingModel:a,onRowGroupingModelChange:u,columnVisibilityModel:f,onColumnVisibilityModelChange:h,pinnedColumns:x,onPinnedColumnsChange:y,pivotModel:w,onPivotModelChange:g,paginationModel:p,onPaginationModelChange:m,pageSizeOptions:C,rowSelectionModel:b,onRowSelectionModelChange:_,density:v,cellSelectionModel:k,onCellSelectionModelChange:A}=e,[M,N]=s.useState(()=>t?.sorting?.sortModel??[]),P=n!==void 0,T=P?n:M,S=s.useCallback(xe=>{P||N(xe),o?.(xe)},[P,o]),[I,F]=s.useState(()=>t?.filter?.filterModel??{items:[]}),L=r!=null,E=L?r:I,O=s.useCallback(xe=>{L||F(xe),i?.(xe)},[L,i]),B=l!==void 0,[H,K]=s.useState(()=>l??{}),R=JSON.stringify(B?l:H),X=s.useMemo(()=>JSON.parse(R),[R]),j=s.useCallback(xe=>{B||K(xe),c?.(xe)},[B,c]),Q=a!==void 0,[U,re]=s.useState(Bo),q=(Q?a:U)||Bo,se=s.useCallback(xe=>{Q||re(xe),u?.(xe)},[Q,u]),Z=f!==void 0,[$,D]=s.useState(()=>t?.columns?.columnVisibilityModel??{}),G=Z?f:$,W=s.useCallback(xe=>{Z||D(xe),h?.(xe)},[Z,h]),ee=x!==void 0,[V,Y]=s.useState(()=>t?.columns?.pinnedColumns??{}),J=ee?x:V,te=s.useCallback(xe=>{ee||Y(xe),y?.(xe)},[ee,y]),[ne,z]=s.useState(()=>w??$c),ie=w??ne,ae=s.useCallback(xe=>{z(xe),g?.(xe)},[g]),le=p!==void 0,[ce,de]=s.useState(()=>t?.pagination?.paginationModel??p??{page:0,pageSize:Gc(C)}),we=le?p:ce,me=s.useCallback(xe=>{le||de(xe),m?.(xe)},[le,m]),pe=b!==void 0,[oe,ue]=s.useState([]),be=pe?b:oe,he=s.useMemo(()=>Ic(be),[be]),ge=s.useRef(null);s.useLayoutEffect(()=>{ge.current=null});const ve=s.useCallback(()=>ge.current,[]),ye=s.useCallback(xe=>{ge.current=xe,pe||ue(xe),_?.(xe)},[pe,_]),[fe]=s.useState(()=>t?.density?.density??"standard"),Ee=v??fe,Le=k!==void 0,[Ne,Me]=s.useState(Dc),qe=Le?k:Ne,Fe=s.useRef(null);s.useLayoutEffect(()=>{Fe.current=null});const Xe=s.useCallback(()=>Fe.current,[]),We=s.useCallback((xe,Ie)=>{Fe.current=xe,Le||Me(xe),A?.(xe,{reason:Ie})},[Le,A]);return{sortModel:T,isSortControlled:P,setInternalSortModel:N,handleSortModelChange:S,filterModel:E,isFilterControlled:L,handleFilterModelChange:O,aggregationModel:X,handleAggregationModelChange:j,rowGroupingModel:q,handleRowGroupingModelChange:se,columnVisibilityModel:G,handleColumnVisibilityModelChange:W,pinnedColumns:J,handlePinnedColumnsChange:te,currentPivotModel:ie,handlePivotModelChange:ae,effectivePaginationModel:we,handlePaginationModelChange:me,rowSelectionModel:be,selectedRowIds:he,isSelectionControlled:pe,setInternalRowSelectionModel:ue,handleRowSelectionModelChange:ye,getPendingRowSelectionModel:ve,density:Ee,cellSelectionModel:qe,handleCellSelectionModelChange:We,getPendingCellSelectionModel:Xe}}const Ki=s.createContext(null),Bc=52,Wc=56,Vc=32,zc=72;function Vn(e){if(e===void 0)return;const t=/^(\d+(?:\.\d+)?)(?:\s*px)?$/.exec(e.trim());if(!t)return;const n=Number(t[1]);return n>0?n:void 0}function Rc(e){const{rowHeight:t,headerHeight:n,density:o}=e,r=s.useContext(Ki)?.grid;let i;return o==="compact"?i=Vn(r?.rowHeightCompact)??Vc:o==="comfortable"?i=Vn(r?.rowHeightComfortable)??zc:i=t??Vn(r?.rowHeightStandard)??Bc,{rowHeight:i,headerHeight:n??Vn(r?.headerHeight)??Wc}}function zn(e){return e>=1?Math.floor(e):1}function Vo(e,t){return Math.max(1,Math.ceil(Math.max(0,e)/zn(t)))}function Uc(e){const{paginationMode:t,hasDataSource:n,dataSourceRowCount:o,rowCountProp:r,clientRowCount:i}=e;return t!=="server"?i:(n?o??r:r)??i}function ji(e){return e?{paginationRowsPerPage:e.paginationRowsPerPage,paginationOf:e.paginationOf,paginationPage:e.paginationPage}:void 0}function qi(e,t){return Number.isFinite(e)?Math.min(Math.max(0,Math.floor(e)),Math.max(0,t-1)):0}function Kc(e){const{effectiveRows:t,activeHierarchyHandlers:n,filterMode:o,filterModel:r,sortModel:i,sortingMode:l,pagination:c,paginationMode:a,effectivePaginationModel:u,pinnedRows:f,getRowId:h,columnLookup:x,hierarchyField:y}=e,w=s.useMemo(()=>n?n.getVisibleRows({labelField:y})||[]:o==="server"?t:Ao(t,r,x),[t,r,n,y,o,x]),g=s.useMemo(()=>n?o==="server"?t:Ao(t,r,x):w,[n,w,o,t,r,x]),{top:p,center:m,bottom:C}=s.useMemo(()=>n?{top:[],center:w,bottom:[]}:Ea(w,f,h),[w,f,n,h]),b=s.useMemo(()=>n||l==="server"?m:rc(m,i,x,h),[m,i,n,l,x,h]),_=c&&a!=="server",v=zn(u.pageSize),k=_?qi(u.page,Vo(b.length,v)):u.page,A=s.useMemo(()=>{if(!_)return b;const N=k*v;return b.slice(N,N+v)},[b,_,k,v]),M=s.useMemo(()=>{const N=c?A:b;return[...p,...N,...C]},[p,A,b,C,c]);return{filteredRows:w,dataRows:g,pinnedTopRows:p,unpinnedRows:m,pinnedBottomRows:C,sortedUnpinnedRows:b,paginatedUnpinnedRows:A,currentPage:k,allRenderableRows:M}}const zo=[33554400,17895e3,1e7,5e6],Xi=new WeakMap;function jc(e){const t=e.body;if(!t)return 1/0;const n=e.createElement("div");n.setAttribute("aria-hidden","true"),n.style.cssText="position:absolute;top:0;left:-10000px;width:1px;visibility:hidden;pointer-events:none;",t.appendChild(n);try{if(n.style.height="100px",Math.abs(n.getBoundingClientRect().height-100)>1)return 1/0;for(const o of zo)if(n.style.height=`${o}px`,Math.abs(n.getBoundingClientRect().height-o)<2)return o;return zo[zo.length-1]}finally{n.remove()}}function qc(e){if(!e)return 1/0;const t=Xi.get(e);if(t!==void 0)return t;const n=jc(e);return Xi.set(e,n),n}function Xc(e,t){if(!Number.isFinite(t))return e.length;let n=0,o=e.length;for(;n<o;){const r=n+o>>1;e[r]<=t?n=r+1:o=r}return n}const Ro="application/x-ogx-row",Uo="application/x-ogx-column";function Yi(e,t,n){const o=e.dataTransfer;!o||typeof o.setData!="function"||(o.setData(t,n),o.setData("text/plain",n))}function Rn(e,t){const n=e.dataTransfer?.types;return n?Array.from(n).includes(t):!0}function Ji(e,t){if(!e||typeof e.addEventListener!="function")return()=>{};const n=()=>t();return e.addEventListener("dragend",n,{once:!0}),()=>e.removeEventListener("dragend",n)}function vw(e){return e}function Sw(e){return e}function Yc(e){const{columns:t,onColumnOrderChange:n,disableColumnReorder:o=!1}=e,[r,i]=s.useState(null),[l,c]=s.useState(null),a=s.useRef(()=>{}),u=s.useCallback(()=>{a.current(),a.current=()=>{},i(null),c(null)},[]);s.useEffect(()=>()=>a.current(),[]);const f=s.useCallback(y=>w=>{if(!o){if(!t.some(g=>g.field===y)){w.preventDefault();return}a.current(),a.current=Ji(w.currentTarget,u),i(y),w.dataTransfer&&(w.dataTransfer.effectAllowed="move",Yi(w,Uo,y))}},[t,o,u]),h=s.useCallback(y=>w=>{if(!(o||r===null)){if(!Rn(w,Uo)){u();return}w.preventDefault(),w.dataTransfer&&(w.dataTransfer.dropEffect="move"),c(y)}},[r,o,u]),x=s.useCallback(y=>w=>{if(w.preventDefault(),o||r===null||!Rn(w,Uo)){u();return}const g=t.findIndex(m=>m.field===r),p=t.findIndex(m=>m.field===y);u(),!(g===-1||p===-1||g===p)&&n?.({column:t[g],oldIndex:g,targetIndex:p})},[t,r,o,n,u]);return{draggedColumn:r,dragOverColumn:l,onDragStart:o?void 0:f,onDragOver:o?void 0:h,onDragEnd:o?void 0:u,onDrop:o?void 0:x}}const Jc="header:",Zc=40,Qc=300,ed="__group__",Zi=[];function Ko(e){return`${Jc}${e}`}function jo(e){return"items"in e&&Array.isArray(e.items)}function td(e){return e.isSpacer||Qe(e.field)||e.field===ed?!1:e.headerFilter!==!1&&e.filterable!==!1&&e.type!=="image"}function Un(e){if(e.headerFilterOperator)return e.headerFilterOperator;switch(e.type){case"number":return"=";case"date":case"boolean":case"singleSelect":return"is";default:return"contains"}}function nd(e){const t=gi(e.type),n=Un(e);return t.includes(n)?t:[n,...t]}function Qi(e,t){return e.items.some(n=>jo(n)?Qi(n,t):n.field===t)}function od(e){return(e?.logicOperator??"and")==="or"&&(e?.items?.length??0)>0}function el(e,t){const n=e?.items??Zi;if(od(e))return{kind:"custom"};const o=Ko(t);let r;for(const i of n){if(jo(i)){if(Qi(i,t))return{kind:"custom"};continue}if(i.field===t){if(i.id!==o||r)return{kind:"custom"};r=i}}return{kind:"editable",item:r}}function rd(e,t,n){const o=e??{items:[]};if(el(o,t).kind!=="editable")return o;const r=Ko(t),i=o.items??Zi,l=i.findIndex(u=>!jo(u)&&u.id===r),c=n?{...n,id:r,field:t}:null;let a;if(l===-1){if(!c)return o;if(i.length===0&&o.logicOperator==="or")return{...o,logicOperator:"and",items:[c]};a=[...i,c]}else c?a=i.map((u,f)=>f===l?c:u):a=i.filter((u,f)=>f!==l);return{...o,items:a}}function qo(e,t,n){const o=Gt.has(t);return!o&&_o(n)&&t===Un(e)?null:{id:Ko(e.field),field:e.field,operator:t,value:o?void 0:n}}function tl(e,t){if(!Gt.has(t))return t==="isAnyOf"?e==null||e===""?[]:Array.isArray(e)?e:[e]:Array.isArray(e)?e.length>0?e[0]:"":e??""}const id={contains:"∋",equals:"=",startsWith:"a…",endsWith:"…a",isEmpty:"∅",isNotEmpty:"!∅",isAnyOf:"∈","=":"=","!=":"≠",">":">",">=":"≥","<":"<","<=":"≤",is:"=",not:"≠",after:">",onOrAfter:"≥",before:"<",onOrBefore:"≤"},nl={contains:"Contains",equals:"Equals",startsWith:"Starts with",endsWith:"Ends with",isEmpty:"Is empty",isNotEmpty:"Is not empty",isAnyOf:"Is any of","=":"Equals","!=":"Does not equal",">":"Greater than",">=":"Greater than or equal","<":"Less than","<=":"Less than or equal",is:"Is",not:"Is not",after:"After",onOrAfter:"On or after",before:"Before",onOrBefore:"On or before"},Kn=["filter","sort","grouping","aggregation","pivot","columnVisibility"],Xo={filter:"filterModel",sort:"sortModel",grouping:"rowGroupingModel",aggregation:"aggregationModel",pivot:"pivotModel",columnVisibility:"columnVisibilityModel"};function ol(e){return Kn.map(t=>Xo[t]).filter(t=>e[t]!==void 0)}function ld(e,t){const n={},o=[];for(const r of Kn){const i=Xo[r];e[i]!==void 0&&(t.includes(r)?Object.assign(n,{[i]:e[i]}):o.push({path:i,message:"Part not allowed"}))}return{state:n,errors:o}}function sd(e,t){const n=e[t];if(Array.isArray(n))return n.length===0;if(t==="filterModel"){const o=e.filterModel;return!o||(o.items??[]).length===0&&(o.quickFilterValues??[]).length===0}if(t==="pivotModel"){const o=e.pivotModel;return!o||o.rowFields.length===0&&o.columnFields.length===0&&o.valueFields.length===0}return typeof n=="object"&&n!==null&&Object.keys(n).length===0}function ad(e){let t=e.length;for(const n of[".","["]){const o=e.indexOf(n);o>=0&&o<t&&(t=o)}return e.slice(0,t)}function cd(e,t){const n=new Set(t.map(r=>ad(typeof r.path=="string"?r.path:""))),o={};for(const r of ol(e))n.has(r)&&sd(e,r)||Object.assign(o,{[r]:e[r]});return o}function dd(e,t){const n={};for(const o of ol(e))Object.assign(n,{[o]:t[o]});return n}function rl(e,t){const n={};for(const o of Kn.map(r=>Xo[r]))!(o in t)&&e[o]===void 0||(e[o]===void 0?Object.assign(n,{[o]:t[o]}):o==="columnVisibilityModel"?n.columnVisibilityModel={...t.columnVisibilityModel,...e.columnVisibilityModel}:Object.assign(n,{[o]:e[o]}));return n}function Yo(e,t){t.filterModel&&e.setFilterModel(t.filterModel),t.sortModel&&e.setSortModel(t.sortModel),t.rowGroupingModel&&e.setRowGroupingModel(t.rowGroupingModel),t.aggregationModel&&e.setAggregationModel(t.aggregationModel),t.pivotModel&&e.setPivotModel(t.pivotModel),t.columnVisibilityModel&&e.setColumnVisibilityModel(t.columnVisibilityModel)}function il(e){return Array.isArray(e)?e.map(il).join(", "):e instanceof Date?e.toISOString().slice(0,10):e==null?"":String(e)}function ll(e,t,n){return"items"in e?`(${e.items.map(o=>ll(o,t,n)).join(` ${e.logicOperator} `)})`:[t(e.field),n(e.operator),il(e.value)].filter(Boolean).join(" ")}const ud={sum:"Sum",avg:"Average",count:"Count",min:"Min",max:"Max",unique:"Unique"},Ve={operator:e=>e,search:e=>`Search: ${e}`,noFilters:"No filters",sort:(e,t)=>`Sort: ${e}, ${t==="desc"?"descending":"ascending"}`,noSorting:"No sorting",group:e=>`Group: ${e}`,noGrouping:"No grouping",summary:(e,t)=>`${ud[e]??e}: ${t}`,noSummaries:"No summaries",pivot:e=>`Pivot: ${e}`,noPivot:"No pivot",visibility:(e,t)=>`${t?"Show":"Hide"}: ${e}`};function sl(e,t,n=Ve){const o=[],{filterModel:r,sortModel:i,rowGroupingModel:l,aggregationModel:c,pivotModel:a,columnVisibilityModel:u}=e;if(r){const f=r.items??[];f.forEach((x,y)=>o.push({id:`filter:${y}`,part:"filter",label:ll(x,t,n.operator)}));const h=r.quickFilterValues??[];h.length>0&&o.push({id:"filter:quick",part:"filter",label:n.search(h.join(" "))}),f.length===0&&h.length===0&&o.push({id:"filter:clear",part:"filter",label:n.noFilters})}if(i&&(i.forEach((f,h)=>o.push({id:`sort:${h}`,part:"sort",label:n.sort(t(f.field),f.sort==="desc"?"desc":"asc")})),i.length===0&&o.push({id:"sort:clear",part:"sort",label:n.noSorting})),l&&(l.forEach((f,h)=>o.push({id:`grouping:${h}`,part:"grouping",label:n.group(t(f))})),l.length===0&&o.push({id:"grouping:clear",part:"grouping",label:n.noGrouping})),c){const f=Object.keys(c);f.forEach(h=>{const x=c[h];o.push({id:`aggregation:${h}`,part:"aggregation",label:n.summary(x,t(h))})}),f.length===0&&o.push({id:"aggregation:clear",part:"aggregation",label:n.noSummaries})}if(a){const f=[...a.rowFields,...a.columnFields,...a.valueFields.map(h=>h.field)];o.push({id:"pivot",part:"pivot",label:f.length>0?n.pivot(f.map(t).join(", ")):n.noPivot})}if(u)for(const f of Object.keys(u))o.push({id:`columnVisibility:${f}`,part:"columnVisibility",label:n.visibility(t(f),!!u[f])});return o}function fd(e,t){const n={...e},o=t.indexOf(":"),r=o<0?t:t.slice(0,o),i=o<0?"":t.slice(o+1),l=Number(i);if(r==="filter"&&n.filterModel){const c={...n.filterModel};i==="quick"?delete c.quickFilterValues:i==="clear"?c.items=[]:c.items=(c.items??[]).filter((a,u)=>u!==l),(c.items??[]).length===0&&(c.quickFilterValues??[]).length===0?delete n.filterModel:n.filterModel=c}else if(r==="sort"&&n.sortModel)n.sortModel=n.sortModel.filter((c,a)=>a!==l),(n.sortModel.length===0||i==="clear")&&delete n.sortModel;else if(r==="grouping"&&n.rowGroupingModel)n.rowGroupingModel=n.rowGroupingModel.filter((c,a)=>a!==l),(n.rowGroupingModel.length===0||i==="clear")&&delete n.rowGroupingModel;else if(r==="aggregation"&&n.aggregationModel){const c={...n.aggregationModel};delete c[i],Object.keys(c).length===0?delete n.aggregationModel:n.aggregationModel=c}else if(r==="columnVisibility"&&n.columnVisibilityModel){const c={...n.columnVisibilityModel};delete c[i],Object.keys(c).length===0?delete n.columnVisibilityModel:n.columnVisibilityModel=c}else r==="pivot"&&delete n.pivotModel;return n}const Jo=(e,t,n)=>e===1?t:n,al={paginationRowsPerPage:"Rows per page:",paginationOf:(e,t,n)=>n===0?`0 of ${n}`:`${e}–${t} of ${n}`,paginationPage:(e,t)=>`Page ${e} of ${t}`,noRowsLabel:"No Data",cellSelectionAnnouncement:Vi,aiAssistantButton:"Ask AI",headerFilterCustom:"Custom filter",headerFilterCustomTooltip:"Set in the filter panel",headerFilterCellLabel:e=>`Filter ${e}`,headerFilterValueLabel:e=>`Filter value for ${e}`,headerFilterOperatorButtonLabel:(e,t)=>`Filter operator for ${e}: ${t}`,headerFilterOperatorMenuLabel:e=>`Filter operator for ${e}`,headerFilterClearLabel:e=>`Clear filter for ${e}`,headerFilterClearTooltip:"Clear",headerFilterAny:"Any",headerFilterTrue:"Yes",headerFilterFalse:"No",gridLabel:"Data grid",listViewLabel:"Data grid list view",listViewItemCount:e=>`${e} ${Jo(e,"item","items")}`,listViewPage:(e,t)=>`page ${e} of ${t}`,listViewSelectedCount:e=>`${e} selected`,loadingLabel:"Loading data",liveRegionLoading:"Loading data...",liveRegionError:e=>`Error: ${e}`,liveRegionRowsFound:e=>`${e} ${Jo(e,"row","rows")} found`,errorOverlayTitle:"Oops! Something went wrong",errorOverlayRetry:"Retry",aggregationFooterLabel:"Aggregation totals",cellErrorLabel:e=>`Error in cell: ${e}`,cellErrorTooltip:"Render error",headerRowReorderLabel:"Row reorder handle",headerRowReorderTooltip:"Drag to reorder rows",headerDetailPanelLabel:"Expand row details",headerSelectAllLabel:"Select all rows",headerDeselectAllLabel:"Deselect all rows",headerSortDescription:(e,t,n)=>`Sorted ${e==="asc"?"ascending":"descending"}, sort priority ${t} of ${n}`,headerColumnMenuButtonLabel:e=>`Open column menu for ${e}`,headerColumnResizeLabel:e=>`Resize ${e} column`,headerFilterNoFilterLabel:e=>`No filter for ${e}`,rowSelectLabel:e=>`Select row ${e}`,rowDeselectLabel:e=>`Deselect row ${e}`,rowReorderLabel:"Drag to reorder row",rowDetailPanelExpandLabel:"Expand row details",rowDetailPanelCollapseLabel:"Collapse row details",rowExpandLabel:"Expand row",rowCollapseLabel:"Collapse row",columnMenuLabel:e=>`Column options for ${e}`,columnMenuSortAscending:"Sort Ascending",columnMenuSortDescending:"Sort Descending",columnMenuUnsort:"Unsort",columnMenuPinColumn:"Pin column",columnMenuPinLeft:"Pin to Left",columnMenuPinLeftLabel:"Pin to left",columnMenuPinRight:"Pin to Right",columnMenuPinRightLabel:"Pin to right",columnMenuUnpin:"Unpin",columnMenuUnpinLabel:"Unpin column",columnMenuHideColumn:"Hide Column",columnMenuHideColumnLabel:e=>`Hide ${e} column`,columnMenuManageColumns:"Manage columns",columnMenuManageColumnsLabel:"Manage all columns",columnsPanelSearchPlaceholder:"Search",columnsPanelDragToReorder:"Drag to reorder",columnsPanelShowHideAll:"Show/Hide All",columnsPanelReset:"Reset",columnsPanelClose:"Close",filterPanelValueLabel:e=>`Filter value for ${e}`,filterPanelOperatorLabel:e=>`Filter operator for ${e}`,filterPanelClearLabel:e=>`Clear filter for ${e}`,filterPanelClearTooltip:"Clear",filterPanelAny:"Any",filterPanelTrue:"true",filterPanelFalse:"false",filterPanelNumberPlaceholder:"Number…",filterPanelValuePlaceholder:"Value…",filterPanelMatch:"Match:",filterPanelAnd:"ALL (AND)",filterPanelOr:"ANY (OR)",filterPanelHiddenConditions:e=>e===1?"1 more condition (a filter group or a second condition on a column) is applied and not shown here.":`${e} more conditions (filter groups or further conditions on a column) are applied and not shown here.`,filterPanelNoColumns:"No filterable columns.",toolbarLabel:"Grid toolbar",toolbarSearchPlaceholder:"Search...",toolbarSearchLabel:"Global Search",toolbarSearchClear:"Clear search",toolbarColumns:"Columns",toolbarColumnsLabel:"Manage columns",toolbarColumnsPanelLabel:"Column visibility",toolbarFilters:"Filters",toolbarFiltersLabel:"Advanced filters",toolbarFiltersActive:"Filters active",toolbarFiltersClearAll:"Clear all",toolbarFiltersClearAllTooltip:"Clear all filters",toolbarFiltersClose:"Close",toolbarFiltersCloseTooltip:"Close filters",toolbarFiltersCloseLabel:"Close filters panel",toolbarPivot:"Pivot",toolbarPivotLabel:"Configure pivot",toolbarPivotActive:"Pivot active",toolbarSummaries:"Summaries",toolbarSummariesLabel:"Configure summaries",toolbarSummariesActive:e=>`${e} active summaries`,toolbarSummariesPanelLabel:"Summaries configuration",toolbarSummariesClearAll:"Clear all",toolbarSummariesClearAllTooltip:"Clear all summaries",toolbarSummariesEmpty:"No aggregable columns.",toolbarSummariesEmptyHintBefore:"Set",toolbarSummariesEmptyHintAfter:"on a column to enable.",pivotPanelLabel:"Pivot configuration",pivotMode:"Pivot Mode",pivotReset:"Reset",pivotResetTooltip:"Reset pivot",pivotRowFields:"Row Fields",pivotColumnFields:"Column Fields",pivotValueFields:"Value Fields (aggregated)",pivotRowFieldsPlaceholder:"Add fields here — each becomes a row label",pivotColumnFieldsPlaceholder:"Add fields here — unique values become column headers",pivotValueFieldsPlaceholder:"Add numeric fields here — values are aggregated",pivotRemoveTooltip:e=>`Remove ${e}`,pivotRemoveRowLabel:e=>`Remove ${e} from Row Fields`,pivotRemoveColumnLabel:e=>`Remove ${e} from Column Fields`,pivotRemoveValueLabel:(e,t)=>`Remove ${e} (${t}) from Value Fields`,pivotAggregationTooltip:"Aggregation function",pivotAggregationLabel:e=>`Aggregation function for ${e}`,pivotAvailableFields:"Available Fields",pivotAllFieldsInUse:"All fields are in use.",pivotAddRow:"Row",pivotAddColumn:"Col",pivotAddValue:"Val",pivotAddRowTooltip:"Add to Row Fields",pivotAddColumnTooltip:"Add to Column Fields",pivotAddValueTooltip:"Add to Value Fields",pivotAddRowLabel:e=>`Add ${e} to Row Fields`,pivotAddColumnLabel:e=>`Add ${e} to Column Fields`,pivotAddValueLabel:e=>`Add ${e} to Value Fields`,aiAssistantTitle:"Ask AI",aiAssistantClose:"Close",aiAssistantPromptLabel:"Prompt",aiAssistantPlaceholder:"Ask about this table…",aiAssistantStartDictation:"Dictate a prompt",aiAssistantStopDictation:"Stop dictation",aiAssistantAsk:"Ask",aiAssistantStop:"Stop",aiAssistantSuggestions:"Suggestions",aiAssistantAppliedChanges:"Applied changes",aiAssistantRemoveChange:e=>`Remove ${e}`,aiAssistantUndo:"Undo",aiAssistantIgnored:"Ignored",aiAssistantIgnoredItem:e=>`Ignored: ${e}`,aiAssistantEarlier:"Earlier",aiAssistantThinking:"Thinking…",aiAssistantStopped:"Stopped",aiAssistantUndone:"Undone",aiAssistantChangeRemoved:"Change removed",aiAssistantApplied:(e,t)=>{const n=e===0?"No changes":`Applied ${e} ${Jo(e,"change","changes")}`;return t>0?`${n}, ${t} ignored`:n},aiAssistantNotValidated:"The reply was not validated",aiAssistantFailed:e=>`The assistant could not answer: ${e}`,aiAssistantUnknownError:"Unknown error",aiAssistantChipSearch:Ve.search,aiAssistantChipNoFilters:Ve.noFilters,aiAssistantChipSort:Ve.sort,aiAssistantChipNoSorting:Ve.noSorting,aiAssistantChipGroup:Ve.group,aiAssistantChipNoGrouping:Ve.noGrouping,aiAssistantChipSummary:Ve.summary,aiAssistantChipNoSummaries:Ve.noSummaries,aiAssistantChipPivot:Ve.pivot,aiAssistantChipNoPivot:Ve.noPivot,aiAssistantChipVisibility:Ve.visibility,paginationLabel:"Pagination",paginationFirstPageLabel:"Go to first page",paginationFirstPageTooltip:"First page",paginationPreviousPageLabel:"Go to previous page",paginationPreviousPageTooltip:"Previous page",paginationNextPageLabel:"Go to next page",paginationNextPageTooltip:"Next page",paginationLastPageLabel:"Go to last page",paginationLastPageTooltip:"Last page",cellSelectionStatsCount:"Count",cellSelectionStatsSum:"Sum",cellSelectionStatsAverage:"Average"},gd=Object.keys(al);function pd(e,t,n){const o=t[n];o!==void 0&&(e[n]=o)}function hd(e){return{operator:t=>e.filterPanelOperator(t),search:e.aiAssistantChipSearch,noFilters:e.aiAssistantChipNoFilters,sort:e.aiAssistantChipSort,noSorting:e.aiAssistantChipNoSorting,group:e.aiAssistantChipGroup,noGrouping:e.aiAssistantChipNoGrouping,summary:e.aiAssistantChipSummary,noSummaries:e.aiAssistantChipNoSummaries,pivot:e.aiAssistantChipPivot,noPivot:e.aiAssistantChipNoPivot,visibility:e.aiAssistantChipVisibility}}function Zo(e){const t={...al};e&&gd.forEach(l=>pd(t,e,l));const n=e?.headerFilterOperators,o=e?.filterPanelOperators,r=e?.toolbarAggregationFunctions,i=e?.pivotAggregationFunctions;return{...t,headerFilterOperator:l=>n?.[l]??nl[l]??l,filterPanelOperator:l=>o?.[l]??l,toolbarAggregationFunction:l=>r?.[l]??l,pivotAggregationFunction:l=>i?.[l]??l.toUpperCase()}}const cl=s.createContext(Zo(void 0));function _e(){return s.useContext(cl)}function Qo({isExpanded:e,onClick:t,variant:n="chevron",tabIndex:o}){const r=_e();return d.jsx("button",{className:`ogx-expand-icon ${e?"ogx-expand-icon--expanded":""}`,onClick:i=>{t&&t(i)},"aria-label":e?r.rowCollapseLabel:r.rowExpandLabel,type:"button",tabIndex:o,children:n==="plus-minus"?d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[d.jsx("path",{d:"M4 8H12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),d.jsx("path",{d:"M8 4V12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:e?0:1,transition:"opacity 0.2s ease",transformOrigin:"center"}})]}):d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ogx-expand-icon__chevron","aria-hidden":"true",children:d.jsx("path",{d:"M6 4L10 8L6 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}function md({renderFn:e}){"use no memo";return d.jsx(d.Fragment,{children:e()})}function wd({field:e,message:t}){const n=_e();return d.jsx("div",{className:"ogx__cell-error",role:"img","aria-label":n.cellErrorLabel(e),title:t??n.cellErrorTooltip,children:"⚠"})}function bd(e,t){return Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((n,o)=>Object.is(n,t[o])):Object.is(e,t)}class Mt extends s.Component{constructor(t){super(t),this.state={hasError:!1,error:null,resetKey:t.resetKey}}static getDerivedStateFromProps(t,n){return bd(t.resetKey,n.resetKey)?null:n.hasError?{hasError:!1,error:null,resetKey:t.resetKey}:{resetKey:t.resetKey}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){process.env.NODE_ENV!=="production"&&console.warn(`[CellErrorBoundary] field="${this.props.field}"`,t,n.componentStack)}render(){return this.state.hasError?d.jsx(wd,{field:this.props.field,message:this.state.error?.message}):d.jsx(md,{renderFn:this.props.renderFn})}}function xd(e,t,n){if(!t||!n)return{valueGetter:e.valueGetter,valueFormatter:e.valueFormatter};const o=l=>n.has(l.id),r=e.valueGetter,i=e.valueFormatter;return{valueGetter:r?l=>o(l.row)?l.value:r(l):void 0,valueFormatter:l=>o(l.row)?Fn(l.value,t,e,l.row):i?i(l):l.value==null?"":String(l.value)}}function dl(e,t){if(!t)return e;const n=t.left??[],o=t.right??[],r=i=>{const l=ot(i.field,t);return l==="left"?n.indexOf(i.field)-n.length:l==="right"?1+o.indexOf(i.field):0};return[...e].sort((i,l)=>r(i)-r(l))}const jn=e=>e.formattedValue??e.value;function ul(e,t,n){const o=e.renderCell;if(!o)return{useDefault:!0};const r=!!t.rowMeta?.isGroupRow;if(!n){const l=o(t);return r&&l===void 0?{useDefault:!0}:{useDefault:!1,content:l}}let i;try{i=o(t)}catch(l){return{useDefault:!1,content:d.jsx(Mt,{field:e.field,resetKey:t.row,renderFn:()=>{throw l}})}}return r&&i===void 0?{useDefault:!0}:{useDefault:!1,content:d.jsx(Mt,{field:e.field,resetKey:t.row,renderFn:()=>i})}}function Cd(e,t,n){const o=e.rowMeta;if(!o?.isGroupRow)return jn(e);if(o.isGroupFooter)return null;const r=o.descendantCount;if(t&&o.hasChildren){const i=o.groupLabel??`${o.groupingField}: ${String(o.groupingValue)}`;return d.jsxs("div",{className:"ogx__group-cell-content",children:[i,r!==void 0?` (${r})`:""]})}return n?d.jsxs("div",{className:"ogx__group-cell-content",children:[o.groupLabel,r!==void 0&&r>0?` (${r})`:""]}):jn(e)}const yd=e=>e.id;function vd(e){const{activeColumns:t,isHierarchyEnabled:n,isRowGrouping:o,isTreeData:r,activeHierarchyHandlers:i,columnVisibilityModel:l,columnOrder:c,onColumnOrderChange:a,onColumnOrderModelChange:u,disableColumnReorder:f,pivotMode:h,checkboxSelection:x,hasDetailPanel:y,rowReordering:w,initialState:g,setColumns:p,pinnedColumns:m,getRowId:C=yd,aggregationModel:b,groupingRows:_}=e,v=s.useMemo(()=>t.map(D=>D.field),[t]),[k,A]=s.useState(()=>g?.columns?.columnOrder??null),M=h?v.join("\0"):"",[N,P]=s.useState(null),T=N&&N.key===M?N.order:v,I=h?T:c??(k??v),F=s.useCallback(D=>{if(h){P(G=>{const W=G&&G.key===M?G.order:v;return{key:M,order:typeof D=="function"?D(W):D}});return}A(G=>typeof D=="function"?D(G??v):D)},[h,M,v]),L=s.useCallback(D=>h&&D.hideable===!1||l[D.field]!==!1,[h,l]),E=s.useMemo(()=>{if(!n)return;const D=new Map(I.map((V,Y)=>[V,Y])),G=V=>D.get(V.field)??t.indexOf(V),W=[...t].sort((V,Y)=>G(V)-G(Y));return(dl(W.filter(V=>l[V.field]!==!1),m)[0]??t[0])?.field},[n,I,t,l,m]),O=s.useMemo(()=>{if(!n)return t;const D=o?_:void 0;return t.map(G=>{const W=xd(G,b?.[G.field],D);return G.field===E?{...G,...W,renderCell:ee=>{const V=ee.rowMeta,Y=V?.treeDepth??0,J=!!V?.hasChildren,te=!!V?.isExpanded,ne=ul(G,ee,!0),z=ne.useDefault?Cd(ee,o,r):ne.content;return d.jsxs("div",{style:{display:"flex",alignItems:"center",paddingInlineStart:Y*24,width:"100%",height:"100%"},children:[d.jsx("div",{style:{marginInlineEnd:4,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",cursor:J?"pointer":"default",flexShrink:0},children:J?d.jsx("div",{onClick:ie=>{ie.stopPropagation(),ie.preventDefault(),i?.toggleExpansion(C(ee.row))},onMouseDown:ie=>{ie.stopPropagation()},style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:10,position:"relative"},children:d.jsx(Qo,{isExpanded:te,tabIndex:-1,onClick:ie=>{ie.stopPropagation(),ie.preventDefault(),i?.toggleExpansion(C(ee.row))}})}):null}),d.jsx("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z})]})}}:{...G,...W,renderCell:ee=>{const V=ee.rowMeta;if(!V?.isGroupRow)return G.renderCell?G.renderCell(ee):jn(ee);const Y=ul(G,ee,!1);return Y.useDefault?G.field===V.groupingField&&!V.isGroupFooter||ee.value==null?null:jn(ee):Y.content}}})},[t,n,o,r,i,E,C,b,_]),[B,H]=s.useState(()=>g?.columns?.columnWidths??{}),K=s.useCallback((D,G)=>{H(W=>({...W,[D]:G}))},[]);s.useEffect(()=>{p(t)},[t,p]);const R=s.useMemo(()=>{const D=new Map(I.map((G,W)=>[G,W]));return[...O].sort((G,W)=>{const ee=D.get(G.field)??O.indexOf(G),V=D.get(W.field)??O.indexOf(W);return ee-V})},[O,I]),X=s.useMemo(()=>R.filter(L),[R,L]),j=s.useCallback((D,G)=>{(h||!c)&&F(D),G&&a?.(G),h||u?.(D)},[h,c,F,a,u]),Q=s.useCallback((D,G)=>{const W=R.map(V=>V.field),[ee]=W.splice(D,1);W.splice(G,0,ee),j(W,{column:R[D],oldIndex:D,targetIndex:G})},[R,j]),U=Yc({columns:R,onColumnOrderChange:s.useCallback(({oldIndex:D,targetIndex:G})=>Q(D,G),[Q]),disableColumnReorder:f}),re=s.useCallback((D,G)=>{const W=R.findIndex(V=>V.field===D),ee=R.findIndex(V=>V.field===G);W===-1||ee===-1||W===ee||Q(W,ee)},[R,Q]),q=s.useCallback(()=>{j(v)},[j,v]),se=s.useMemo(()=>dl(X,m),[X,m]),Z=s.useMemo(()=>{const D=[];return w&&D.push({field:_t,sortable:!1,editable:!1}),y&&D.push({field:kt,sortable:!1,editable:!1}),x&&D.push({field:Ze,sortable:!1,editable:!1}),[...D,...se]},[se,x,y,w]),$=s.useMemo(()=>new Map(se.map((D,G)=>[D.field,G])),[se]);return{effectiveColumns:O,hierarchyField:E,orderedColumns:R,visibleOrderedColumns:X,renderOrderedColumns:se,navigationColumns:Z,columnIndexMap:$,columnWidths:B,effectiveColumnOrder:I,setInternalColumnOrder:F,columnReorderHandlers:U,moveColumn:re,resetColumnOrder:q,handleColumnResize:K}}function Sd(){const[e,t]=s.useState(()=>new Map),n=s.useCallback((o,r)=>{t(i=>{if(i.get(o)===r)return i;const l=new Map(i);return l.set(o,r),l})},[]);return{detailPanelHeights:e,reportDetailPanelHeight:n}}function _d(e){const{hasDetailPanel:t,controlledExpandedRowIds:n,onDetailPanelExpandedRowIdsChange:o,rowMetaMap:r}=e,[i,l]=s.useState(new Set),c=n??i,a=s.useMemo(()=>Da(c,r),[c,r]),u=s.useCallback(x=>{if(r.get(x)?.isGroupRow)return;const y=new Set(c);y.has(x)?y.delete(x):y.add(x),n===void 0&&l(y),o?.(y)},[c,r,n,o]),{detailPanelHeights:f,reportDetailPanelHeight:h}=Sd();return{hasDetailPanel:t,expandedRowIds:a,handleDetailPanelToggle:u,detailPanelHeights:f,reportDetailPanelHeight:h}}const kd=new Set(["__group__"]),cn=e=>!kd.has(e);function fl(e){return Object.keys(e).every(cn)?e:Object.fromEntries(Object.entries(e).filter(([n])=>cn(n)))}function Ed(e){const t={...e};return e.left&&(t.left=e.left.filter(cn)),e.right&&(t.right=e.right.filter(cn)),t}function Md(e){const{onStateChange:t,sortModel:n,filterModel:o,effectivePaginationModel:r,columnWidths:i,effectiveColumnOrder:l,columnVisibilityModel:c,pinnedColumns:a,density:u}=e,f=s.useRef(t);s.useLayoutEffect(()=>{f.current=t});const h=s.useRef(null);s.useEffect(()=>{if(!f.current)return;const x={sorting:{sortModel:n},filter:{filterModel:o},pagination:{paginationModel:r},columns:{columnWidths:fl(i),columnOrder:l.filter(cn),columnVisibilityModel:fl(c),pinnedColumns:Ed(a)},density:{density:u}},y=JSON.stringify(x);y!==h.current&&(h.current=y,f.current(x))},[n,o,r,i,l,c,a,u])}const Ad=200,Pd=2e3,Ld=178e5;function Nd(e){const{paginationRequested:t,isRowGrouping:n,autoHeight:o,viewportHeight:r,renderedRowCount:i,totalRowCount:l,pinnedRowsIgnored:c=!1,scrollHeight:a=0,maxContentHeight:u,reachableRowCount:f,unpinnedRowCount:h,listViewWithoutColumn:x=!1,listViewRowCount:y=0}=e,w=s.useRef(!1),g=s.useRef(!1),p=s.useRef(!1),m=s.useRef(!1),C=s.useRef(!1),b=s.useRef(!1);s.useEffect(()=>{process.env.NODE_ENV==="production"||b.current||y<=Pd||(b.current=!0,console.warn(`[OpenGridX] The list view is rendering all ${y} items: it does not virtualize. Above a few thousand items use \`pagination\`, server-side loading, or the grid view. See docs/features/list-view.md.`))},[y]),s.useEffect(()=>{process.env.NODE_ENV==="production"||C.current||!x||(C.current=!0,console.warn("[OpenGridX] `listView` is set without a `listViewColumn`, so the grid view is shown instead. Pass `listViewColumn` to render list items. See docs/features/list-view.md."))},[x]),s.useEffect(()=>{process.env.NODE_ENV==="production"||p.current||!c||(p.current=!0,console.warn("[OpenGridX] `pinnedRows` is ignored while treeData or rowGroupingModel is active: the rows stay in their place in the hierarchy. See docs/features/pinning.md."))},[c]),s.useEffect(()=>{if(process.env.NODE_ENV==="production"||m.current||u===void 0)return;const _=Number.isFinite(u);if(_?a<=u:a<=Ld)return;m.current=!0;const v=_&&f!==void 0&&h!==void 0?`Only the first ${f.toLocaleString("en-US")} of ${h.toLocaleString("en-US")} rows can be scrolled to in this browser. `:"The last rows may not be reachable by scrolling. ";console.warn(`[OpenGridX] The grid content is ${Math.round(a)}px tall, more than this browser lays out (about 17.9M px in Firefox, 33.5M px in Chrome and Safari). `+v+'Load the rows on demand with a `dataSource` (server-side pages or infinite scroll, docs/features/data-source.md), use `pagination`, or a smaller rowHeight (density="compact"). See docs/features/virtualization.md#the-browser-height-limit.')},[a,u,f,h]),s.useEffect(()=>{process.env.NODE_ENV==="production"||w.current||t&&n&&(w.current=!0,console.warn("[OpenGridX] `pagination` is ignored while `rowGroupingModel` is active — all group rows render in one scrollable view. Give the grid a bounded height so it virtualizes. See docs/features/tree-data-grouping.md."))},[t,n]),s.useEffect(()=>{process.env.NODE_ENV==="production"||g.current||o||r>0&&l>Ad&&i>=l&&r>=a&&(g.current=!0,console.warn(`[OpenGridX] The grid viewport is ${Math.round(r)}px tall and is rendering all ${l} rows, so row virtualization is effectively off: the grid fills its container, and the container grows to fit every row. Give the container a definite height (for example \`height: 600px\` or \`100vh\`). If the container, or any ancestor up to the sized one, is a flex or grid item, add \`min-height: 0\` to it. Alternatively pass a \`height\` prop, or \`autoHeight\` if rendering every row is intended. See docs/features/virtualization.md.`))},[o,r,i,l,a])}function Id(e){return typeof window>"u"||typeof window.getComputedStyle!="function"||typeof navigator<"u"&&/jsdom/i.test(navigator.userAgent)?!1:window.getComputedStyle(e).display!=="flex"}let gl=!1;function Fd(e){s.useEffect(()=>{if(process.env.NODE_ENV==="production"||gl)return;const t=e.current;!t||!Id(t)||(gl=!0,console.warn("[OpenGridX] The grid stylesheet is not loaded, so the grid is unstyled and renders every row (its viewport does not scroll). Add `import '@opencorestack/opengridx/styles'` once in your app root. See README.md, Getting Started."))},[e])}const pl=e=>JSON.stringify(Array.from(e,t=>typeof t=="number"?["n",t]:["s",t]));function Td(e){const{selectedRowIds:t,rowsLookup:n,rowMetaMap:o,enabled:r,onSelectionModelChange:i}=e,l=s.useMemo(()=>{if(!r||t.size===0)return t;let u=!1;for(const h of t)if(!n.has(h)&&!o.has(h)){u=!0;break}if(!u)return t;const f=new Set;for(const h of t)(n.has(h)||o.has(h))&&f.add(h);return f},[r,t,n,o]),c=s.useRef(i);s.useLayoutEffect(()=>{c.current=i});const a=s.useRef(null);return s.useEffect(()=>{if(l===t){a.current=null;return}const u=`${pl(t)}|${pl(l)}`;a.current!==u&&(a.current=u,c.current(Array.from(l)))},[l,t]),l}function qn(e,t,n,o){if(n&&o)return t.length>0?[t[t.length-1]]:Array.from(e);const r=new Set(e);t.forEach(l=>n?r.add(l):r.delete(l));const i=Array.from(r);return Fc(i,r),n&&Tc(r,t),i}function Od(e,t,n){return n?e.has(t)?[]:[t]:qn(e,[t],!e.has(t),!1)}function hl(e,t){return t.length===e.size&&t.every(n=>e.has(n))}function Dd(e){const{selectedRowIds:t,onSelectionModelChange:n,disableMultipleRowSelection:o,selectableRowIds:r}=e,i=s.useCallback(h=>{hl(t,h)||n(h)},[t,n]),l=s.useCallback((h,x)=>{i(qn(t,[h],x,o))},[i,t,o]),c=s.useCallback(h=>{i(Od(t,h,o))},[i,t,o]),a=s.useCallback(h=>{i(qn(t,r,h,!1))},[i,t,r]),{allSelected:u,someSelected:f}=s.useMemo(()=>{if(r.length>0&&Oc(t,r))return{allSelected:!0,someSelected:!1};let h=0;for(const y of r)t.has(y)&&h++;const x=r.length>0&&h===r.length;return{allSelected:x,someSelected:!x&&h>0}},[r,t]);return{toggleRow:l,clickRow:c,selectAll:o?void 0:a,allSelected:u,someSelected:f}}const ml=new WeakMap;function $d(e,t){const n=new Array(e.length),o=new Map;for(let r=0;r<e.length;r++){const i=t(e[r]);n[r]=i,o.has(i)||o.set(i,r)}return{rowIds:n,rowIndexById:o}}function er(e,t,n){let o=ml.get(t);const r=o?.get(n);if(r&&r.rows.length===e.length){const l=r.rows,c=r.value.rowIds;let a=!0;for(let u=0;u<e.length;u++){const f=e[u];if(f!==l[u]&&t(f)!==c[u]){a=!1;break}}if(a)return r.rows=e,r.value}const i=$d(e,t);return o||(o=new Map,ml.set(t,o)),o.set(n,{rows:e,value:i}),i}function Gd(e){const{dataRows:t,getRowId:n,isPivotActive:o,selectedRowIds:r,onSelectionModelChange:i,disableMultipleRowSelection:l,disableRowSelectionOnClick:c,isHierarchyEnabled:a,rowMetaMap:u,activeHierarchyHandlers:f,onRowClick:h}=e,x=s.useMemo(()=>{const{rowIds:v}=er(t,n,"data");return o?v.filter(k=>k!==Bt):v},[t,n,o]),y=Dd({selectedRowIds:r,onSelectionModelChange:i,disableMultipleRowSelection:l,selectableRowIds:x}),{clickRow:w,toggleRow:g}=y,p=s.useCallback(v=>{const{id:k}=v,A=a?u.get(k):void 0;if(A?.isGroupRow){A.hasChildren&&f?.toggleExpansion(k);return}h?.(v),!c&&!Ke(k,u)&&w(k)},[a,f,h,u,c,w]),m=s.useCallback((v,k)=>{Ke(v,u)||g(v,k)},[u,g]),C=s.useRef({rowClick:p,selectionChange:m});s.useLayoutEffect(()=>{C.current={rowClick:p,selectionChange:m}});const b=s.useCallback(v=>C.current.rowClick(v),[]),_=s.useCallback((v,k)=>C.current.selectionChange(v,k),[]);return{rowSelection:y,handleRowClick:b,handleSelectionChange:_}}function tr(e,t,n,o){return o?sc(e,t,n):n?[{field:t,sort:n}]:e.filter(r=>r.field!==t)}function Hd(e){const{sortModel:t,onSortModelChange:n}=e,o=s.useCallback((i,l)=>{n(tr(t,i,l,!1))},[t,n]),r=s.useCallback((i,l)=>{n(tr(t,i,l,!0))},[t,n]);return{handleSort:o,handleSortAdd:r}}function Bd(e){const{columnVisibilityModel:t,onColumnVisibilityModelChange:n,pinnedColumns:o,onPinnedColumnsChange:r}=e,i=s.useRef({columnVisibilityModel:t,pinnedColumns:o});s.useLayoutEffect(()=>{i.current={columnVisibilityModel:t,pinnedColumns:o}});const l=s.useCallback(a=>{const u={...i.current.columnVisibilityModel,[a]:!1};i.current={...i.current,columnVisibilityModel:u},n(u)},[n]),c=s.useCallback((a,u)=>{const f=Ma(i.current.pinnedColumns,a,u);i.current={...i.current,pinnedColumns:f},r(f)},[r]);return{handleHideColumn:l,handlePinColumn:c}}function Wd(e){const{apiRef:t}=e,n=s.useRef(e);s.useLayoutEffect(()=>{n.current=e}),s.useLayoutEffect(()=>{const o=t.current,r=()=>n.current;o.getSortModel=()=>r().sortModel,o.sortColumn=(a,u)=>{const{sortModel:f,multiSort:h,onSortModelChange:x}=r(),y=tr(f,a,u,h);n.current={...r(),sortModel:y},x(y)},o.getFilterModel=()=>r().filterModel,o.setFilterModel=a=>{n.current={...r(),filterModel:a},r().onFilterModelChange(a)};const i=a=>{n.current={...r(),paginationModel:a},r().onPaginationModelChange(a)};o.setPage=a=>i({...r().paginationModel,page:a}),o.setPageSize=a=>i({...r().paginationModel,pageSize:a,page:0});const l=()=>{const a=r().getPendingRowSelectionModel?.();return a?new Set(a):r().selectedRowIds},c=(a,u)=>{const{disableMultipleRowSelection:f,onRowSelectionModelChange:h,isSyntheticRowId:x}=r(),y=x?a.filter(p=>!x(p)):a;if(y.length===0)return;const w=l(),g=qn(w,y,u,f);hl(w,g)||(n.current={...r(),selectedRowIds:new Set(g)},h(g))};o.getSelectedRows=()=>Array.from(l()),o.selectRow=(a,u=!0)=>c([a],u),o.selectRows=(a,u=!0)=>c(a,u),o.getVisibleRows=()=>r().getVisibleRows(),o.getAllFilteredRows=()=>r().getAllFilteredRows(),o.getVisibleColumns=()=>r().visibleColumns,o.setSortModel=a=>{n.current={...r(),sortModel:a},r().onSortModelChange(a)},o.setRowGroupingModel=a=>{n.current={...r(),rowGroupingModel:a},r().onRowGroupingModelChange(a)},o.setAggregationModel=a=>{n.current={...r(),aggregationModel:a},r().onAggregationModelChange(a)},o.setColumnVisibilityModel=a=>{n.current={...r(),columnVisibilityModel:a},r().onColumnVisibilityModelChange(a)},o.setPivotModel=a=>{n.current={...r(),pivotModel:a},r().onPivotModelChange(a)},o.getGridAiState=()=>{const{filterModel:a,sortModel:u,rowGroupingModel:f,aggregationModel:h,pivotModel:x,columnVisibilityModel:y}=r();return{filterModel:a,sortModel:u,rowGroupingModel:f,aggregationModel:h,pivotModel:x,columnVisibilityModel:y}}},[t])}function Vd(e){const{controlledState:t,interactions:n,api:o}=e,{sortModel:r,handleSortModelChange:i,filterModel:l,handleFilterModelChange:c,effectivePaginationModel:a,handlePaginationModelChange:u,handleRowSelectionModelChange:f,rowGroupingModel:h,handleRowGroupingModelChange:x,aggregationModel:y,handleAggregationModelChange:w,columnVisibilityModel:g,handleColumnVisibilityModelChange:p,currentPivotModel:m,handlePivotModelChange:C}=t,b=Gd({...n,selectedRowIds:o.selectedRowIds,onSelectionModelChange:f,disableMultipleRowSelection:o.disableMultipleRowSelection});return Wd({...o,onSortModelChange:i,sortModel:r,filterModel:l,onFilterModelChange:c,paginationModel:a,onPaginationModelChange:u,getPendingRowSelectionModel:t.getPendingRowSelectionModel,onRowSelectionModelChange:f,rowGroupingModel:h,onRowGroupingModelChange:x,aggregationModel:y,onAggregationModelChange:w,columnVisibilityModel:g,onColumnVisibilityModelChange:p,pivotModel:m,onPivotModelChange:C}),b}const wl="\0";function zd(e,t){const n=e.filter(o=>t[o.field]===!1).map(o=>o.field).join(wl);return s.useMemo(()=>{const o={};if(n)for(const r of n.split(wl))o[r]=!1;return Fo(e,o)},[e,n])}function Rd({paginationModel:e,currentPage:t,enabled:n,onPaginationModelChange:o}){const r=s.useRef({paginationModel:e,onPaginationModelChange:o});s.useLayoutEffect(()=>{r.current={paginationModel:e,onPaginationModelChange:o}});const i=e.page,l=s.useRef(null);s.useEffect(()=>{if(!n)return;if(t===i){l.current=null;return}const c=`${i}>${t}`;if(l.current===c)return;l.current=c;const{paginationModel:a,onPaginationModelChange:u}=r.current;u({...a,page:t})},[n,t,i])}const ke=()=>{},nr=()=>Promise.resolve({updated:[],failed:[],skipped:[]});function bl(){return{getRow:()=>null,getAllRows:()=>[],getVisibleRows:()=>[],getAllFilteredRows:()=>[],getGroupedExportRows:()=>null,getAggregationResult:()=>null,getAggregationModel:()=>null,getColumn:()=>null,getAllColumns:()=>[],getVisibleColumns:()=>[],selectRow:ke,selectRows:ke,getSelectedRows:()=>[],sortColumn:ke,getSortModel:()=>[],setFilterModel:ke,getFilterModel:()=>({items:[]}),setPage:ke,setPageSize:ke,scrollToIndexes:ke,autosizeColumn:ke,autosizeColumns:ke,copySelectedRows:()=>Promise.resolve(),getCellSelectionModel:()=>[],setCellSelectionModel:ke,selectCellRange:ke,clearCellSelection:ke,getSelectedCells:()=>[],copySelectedCells:()=>Promise.resolve(),pasteText:nr,undo:nr,redo:nr,canUndo:()=>!1,canRedo:()=>!1,clearHistory:ke,setSortModel:ke,setRowGroupingModel:ke,setAggregationModel:ke,setColumnVisibilityModel:ke,setPivotModel:ke,getGridAiState:()=>({}),openAiAssistant:ke,closeAiAssistant:ke}}const Ud=e=>e.id;let xl=!1;function Cl(e,t,n){const o=new Map,r=new Map,i=new Map,l=[],c=[],a=[];return e.forEach(u=>{const f=n?.get(u)??t(u);if(o.has(f)){a.push(f);return}o.set(f,u),r.set(u,f),i.set(f,l.length),l.push(f),c.push(u)}),a.length>0&&!xl&&process.env.NODE_ENV!=="production"&&(xl=!0,console.warn(`[OpenGridX] ${a.length} row(s) reuse the id of an earlier row and were ignored (ids: ${a.slice(0,5).map(String).join(", ")}${a.length>5?", …":""}). Every row needs a unique id; pass getRowId if the unique key lives in another field.`)),{idRowsLookup:o,allRows:l,idByRow:r,rows:c,indexById:i}}function Kd(e,t,n,o={}){const r=new Map,i=[];return n.forEach(l=>{r.set(l.field,l),i.push(l.field)}),{rows:Cl(e,t),columns:{all:n,lookup:r,orderedFields:i,columnVisibilityModel:o},pagination:{rowCount:void 0},pinning:{pinnedColumns:{},pinnedRows:{}},dimensions:{rowHeight:52,headerHeight:56,viewportWidth:0,viewportHeight:0},dataSource:{loading:!1,error:null}}}function yl(e,t){const{idRowsLookup:n,idByRow:o,indexById:r}=e.rows;let i=null;for(const[l,c]of t){const a=r.get(l);if(a===void 0)continue;const u=n.get(l);u!==void 0&&u!==c&&o.delete(u),n.set(l,c),o.set(c,l),e.rows.rows[a]!==c&&(i??=e.rows.rows.slice(),i[a]=c)}return i?{...e,rows:{...e.rows,rows:i}}:e}function jd(e,t){switch(t.type){case"SET_ROWS":{const n=e.rows.rows,o=typeof t.payload=="function"?t.payload(n):t.payload;return{...e,rows:Cl(o,t.getRowId,e.rows.idByRow)}}case"REPLACE_ROW":return yl(e,[[t.id,t.row]]);case"REPLACE_ROWS":return yl(e,t.rows);case"SET_COLUMNS":{const n=new Map,o=[];return t.payload.forEach(r=>{n.set(r.field,r),o.push(r.field)}),{...e,columns:{all:t.payload,lookup:n,orderedFields:o,columnVisibilityModel:e.columns.columnVisibilityModel}}}case"SET_DIMENSIONS":return{...e,dimensions:{...e.dimensions,viewportWidth:t.payload.viewportWidth,viewportHeight:t.payload.viewportHeight}};case"SET_DATASOURCE_LOADING":return{...e,dataSource:{...e.dataSource,loading:t.payload}};case"SET_DATASOURCE_ERROR":return{...e,dataSource:{...e.dataSource,error:t.payload}};case"SET_ROW_COUNT":return{...e,pagination:{...e.pagination,rowCount:t.payload}};default:return e}}function qd(e){const{rows:t,columns:n,rowHeight:o=52,headerHeight:r=56,columnVisibilityModel:i,initialState:l,syncRows:c=!1}=e,a=e.getRowId??Ud,u=s.useRef(a);s.useLayoutEffect(()=>{u.current=a});const[f]=s.useState(()=>Kd(t,a,n,i)),[h,x]=s.useReducer(jd,{...f,dataSource:l?.dataSource?{...f.dataSource,...l.dataSource}:f.dataSource,pagination:{rowCount:l?.pagination?.rowCount},dimensions:{...f.dimensions,rowHeight:o,headerHeight:r}}),[y,w]=s.useState({rows:t,syncRows:c});(y.rows!==t||y.syncRows!==c)&&(w({rows:t,syncRows:c}),c&&x({type:"SET_ROWS",payload:t,getRowId:a}));const g=s.useRef(h);s.useLayoutEffect(()=>{g.current=h});const p=s.useCallback((P,T)=>{x({type:"SET_ROWS",payload:typeof P=="function"?I=>P(I):P,getRowId:u.current})},[]),m=s.useCallback((P,T)=>{x({type:"REPLACE_ROW",id:P,row:T})},[]),C=s.useCallback(P=>{P.size>0&&x({type:"REPLACE_ROWS",rows:P})},[]),b=s.useCallback(P=>{x({type:"SET_COLUMNS",payload:P})},[]),_=s.useCallback((P,T)=>{x({type:"SET_DIMENSIONS",payload:{viewportWidth:P,viewportHeight:T}})},[]),v=s.useCallback(P=>{x({type:"SET_DATASOURCE_LOADING",payload:P})},[]),k=s.useCallback(P=>{x({type:"SET_DATASOURCE_ERROR",payload:P})},[]),A=s.useCallback(P=>{x({type:"SET_ROW_COUNT",payload:P})},[]),[M]=s.useState(()=>({...bl(),getRow:P=>g.current.rows.idRowsLookup.get(P)||null,getAllRows:()=>g.current.rows.rows.slice(),getColumn:P=>g.current.columns.lookup.get(P)||null,getAllColumns:()=>g.current.columns.all})),N=s.useRef(M);return{state:h,rowsLookup:h.rows.idRowsLookup,dispatch:x,apiRef:N,setRows:p,replaceRow:m,replaceRows:C,setColumns:b,setDimensions:_,setDataSourceLoading:v,setDataSourceError:k,setRowCount:A}}function Xd(e){const{onRowOrderChange:t,rows:n,getRowId:o,indexById:r,rowReordering:i=!1}=e,[l,c]=s.useState(null),[a,u]=s.useState(null),f=s.useRef(()=>{}),h=s.useMemo(()=>{if(r)return r;const m=new Map;return n.forEach((C,b)=>m.set(o?o(C):C.id,b)),m},[r,n,o]),x=s.useCallback(m=>h.has(m),[h]),y=s.useCallback(()=>{f.current(),f.current=()=>{},c(null),u(null)},[]);s.useEffect(()=>()=>f.current(),[]);const w=s.useCallback(m=>C=>{if(i){if(!h.has(m)){C.preventDefault();return}f.current(),f.current=Ji(C.currentTarget,y),c(m),C.dataTransfer&&(C.dataTransfer.effectAllowed="move",Yi(C,Ro,String(m)))}},[i,h,y]),g=s.useCallback(m=>C=>{if(!(!i||l===null)){if(!Rn(C,Ro)){y();return}h.has(m)&&(C.preventDefault(),C.dataTransfer&&(C.dataTransfer.dropEffect="move"),a!==m&&u(m))}},[i,l,a,h,y]),p=s.useCallback(m=>C=>{if(C.preventDefault(),l===null||!Rn(C,Ro)){y();return}const b=h.get(l),_=h.get(m);y(),t&&b!==void 0&&_!==void 0&&b!==_&&t({row:n[b],oldIndex:b,targetIndex:_})},[l,t,n,h,y]);return{draggedRowId:l,dragOverRowId:a,canReorderRow:x,onDragStart:i?w:void 0,onDragOver:i?g:void 0,onDragEnd:i?y:void 0,onDrop:i?p:void 0}}const vl=new Map,Sl=e=>JSON.stringify(e),Yd=e=>`auto-group-${e}`,_l=5,kl=e=>e.slice(0,_l).map(t=>JSON.stringify(t)).join(", ")+(e.length>_l?", …":""),Jd={treeNodes:new Map,rootIds:[],groupingRows:[],syntheticIds:new Set,rowLookup:new Map,issues:[]};function Zd(e,t,n){const o=new Map,r=[],i=[],l=new Set,c=new Map,a=new Map,u=[],f=new Array(e.length),h=new Array(e.length),x=[],y=new Map;e.forEach((g,p)=>{const m=t(g),C=n(g),b=Array.isArray(C)?C.map(_=>String(_)):[];if(f[p]=m,h[p]=b,c.set(m,g),b.length===0)x.push(m);else{const _=Sl(b),v=a.get(_);if(v===void 0)a.set(_,m);else{const k=y.get(_)??[v];k.push(m),y.set(_,k)}}o.set(m,{id:m,parentId:null,depth:Math.max(b.length-1,0),groupingKey:b[b.length-1]??"",isExpanded:!1,children:[],serverChildrenCount:g.serverChildrenCount})});const w=g=>{const p=Sl(g),m=a.get(p);if(m!==void 0)return m;const C=Yd(p),b=g[g.length-1],_={id:C,parentId:null,depth:g.length-1,groupingKey:b,isExpanded:!1,children:[],label:b};o.set(C,_),a.set(p,C),l.add(C);const v={id:C};if(i.push(v),c.set(C,v),g.length===1)r.push(C);else{const k=w(g.slice(0,-1));_.parentId=k,o.get(k)?.children?.push(C)}return C};return e.forEach((g,p)=>{const m=f[p],C=h[p];if(C.length<=1){r.push(m);return}const b=w(C.slice(0,-1)),_=o.get(m);_&&(_.parentId=b),o.get(b)?.children?.push(m)}),x.length>0&&u.push(`[OpenGridX] treeData: getTreeDataPath returned an empty path for row(s) ${kl(x)}. They are shown as top-level rows.`),y.forEach((g,p)=>{u.push(`[OpenGridX] treeData: rows ${kl(g)} have the same path ${p}. Rows under that path are attached to row ${JSON.stringify(g[0])}.`)}),{treeNodes:o,rootIds:r,groupingRows:i,syntheticIds:l,rowLookup:c,issues:u}}function Qd(e,t){const{treeNodes:n,rootIds:o,syntheticIds:r,rowLookup:i}=e,l=new Set,c=new Map,a=new Map,u=f=>{const h=n.get(f);if(!h)return!1;const x=[];let y=0;for(const m of h.children??[])u(m)&&(x.push(m),y+=(r.has(m)?0:1)+(a.get(m)??0));c.set(f,x),a.set(f,y);const w=i.get(f),p=!r.has(f)&&w!==void 0&&(t?t(w):!0)||x.length>0;return p&&l.add(f),p};return o.forEach(u),{visible:l,visibleChildren:c,descendantCounts:a}}function eu(e){const{rows:t,getRowId:n,getTreeDataPath:o,treeData:r=!1,defaultGroupingExpansionDepth:i=0,filterModel:l,sortModel:c,onRowExpansionChange:a,columnLookup:u,filterMode:f="client",sortingMode:h="client"}=e,x=r&&!!o,y=s.useMemo(()=>!r||!o?Jd:Zd(t,n,o),[t,o,r,n]),{treeNodes:w,rootIds:g,groupingRows:p,syntheticIds:m,rowLookup:C}=y,b=y.issues.join(`
|
|
2
|
+
`);s.useEffect(()=>{process.env.NODE_ENV==="production"||!b||b.split(`
|
|
3
|
+
`).forEach(K=>console.warn(K))},[b]);const _=r&&!o;s.useEffect(()=>{process.env.NODE_ENV==="production"||!_||console.warn("[OpenGridX] treeData is set without getTreeDataPath, so the rows are shown as a flat list. Pass getTreeDataPath={(row) => row.path} to build the tree.")},[_]);const v=s.useMemo(()=>f==="server"?null:Tn(l,u),[f,l,u]),k=s.useMemo(()=>Qd(y,v),[y,v]),A=`${r}|${i}`,[M,N]=s.useState(()=>({configKey:A,overrides:new Map})),P=M.configKey===A?M.overrides:vl,T=s.useCallback(K=>((K?.children?.length??0)>0||(K?.serverChildrenCount??0)>0)&&(i===-1||(K?.depth??0)<i),[i]),S=s.useMemo(()=>{const K=new Set;return x&&w.forEach((R,X)=>{(P.get(X)??T(R))&&K.add(X)}),K},[x,w,P,T]),I=s.useCallback(K=>{const R=!S.has(K);if(N(X=>{const j=X.configKey===A?X.overrides:vl,Q=new Map(j);return Q.set(K,R),{configKey:A,overrides:Q}}),R&&a){const X=w.get(K);X&&a(X)}},[S,A,w,a]),F=h!=="server"&&!!(c&&c.length>0),L=s.useCallback(K=>{if(!x)return null;const R=K?.labelField,X=K?.expandAll??!1,{visible:j,visibleChildren:Q}=k,U=F&&c?c:[],re=($,D)=>{if(m.has($))return{value:D.field===R?w.get($)?.label:void 0};const G=C.get($),W=u?.byField.get(D.field),ee=G?Se(G,D.field,W):void 0,V=W?.sortComparator;return{value:ee,type:W?.type,comparator:V,params:V&&G?{id:$,field:D.field,row:G,value:ee}:void 0}},q=[],se=new Set,Z=$=>{const D=$.filter(W=>j.has(W)),G=U.length>0?wi(D,U,re):D;for(const W of G){if(se.has(W))continue;const ee=C.get(W);if(!ee)continue;se.add(W),q.push(ee);const V=Q.get(W);V&&V.length>0&&(X||S.has(W))&&Z(V)}};return Z(g),q},[x,k,F,c,m,w,C,u,g,S]),E=s.useCallback(K=>S.has(K),[S]),O=s.useCallback(K=>w.get(K),[w]),B=s.useCallback(K=>{const R=[];let X=K;for(;X!==null;){const j=w.get(X);if(!j)break;R.unshift(j.groupingKey),X=j.parentId}return R},[w]),H=s.useMemo(()=>{const K=new Map,{visibleChildren:R,descendantCounts:X}=k;return w.forEach((j,Q)=>{const U=(j.children?.length??0)===0&&(j.serverChildrenCount??0)>0,re=m.has(Q),q={hasChildren:(R.get(Q)?.length??0)>0||U,treeDepth:j.depth,descendantCount:U?void 0:X.get(Q)??0,isGroupRow:re,isExpanded:S.has(Q)};re&&(q.groupLabel=j.label),K.set(Q,q)}),K},[w,m,k,S]);return s.useMemo(()=>({treeNodes:w,groupingRows:p,toggleExpansion:I,isGroupExpanded:E,getVisibleRows:L,getNode:O,getNodePath:B,rowMetaMap:H}),[w,p,I,E,L,O,B,H])}class tu{base;top;constructor(t,n){this.base=t,this.top=n}get size(){return this.base.size+this.top.size}get(t){const n=this.top.get(t);return n!==void 0||this.top.has(t)?n:this.base.get(t)}has(t){return this.top.has(t)||this.base.has(t)}forEach(t,n){this.base.forEach((o,r)=>t.call(n,o,r,this)),this.top.forEach((o,r)=>t.call(n,o,r,this))}*entries(){yield*this.base.entries(),yield*this.top.entries()}*keys(){yield*this.base.keys(),yield*this.top.keys()}*values(){yield*this.base.values(),yield*this.top.values()}[Symbol.iterator](){return this.entries()}}const El=e=>e===null?"footer":"inline";function Ml(e,t){return wo(()=>e(t),El(t),"getAggregationPosition","getAggregationPosition threw; the default position is used")}function nu(e,t,n){const o=`${t}: ${String(n)}`,r=e?.groupingValueFormatter;return r?wo(()=>r({field:t,value:n}),o,`groupingValueFormatter:${t}`,`groupingValueFormatter for column "${t}" threw; the group is labelled "${t}: value"`):o}const ou=[],ru={},Al=new Map,et="";function iu(e){if(typeof e=="string")return e;if(e===null)return`${et}null`;if(e===void 0)return`${et}undefined`;if(e instanceof Date)return`${et}date:${e.getTime()}`;if(typeof e=="object")try{return`${et}object:${JSON.stringify(e)}`}catch{return`${et}object:${String(e)}`}return`${et}${typeof e}:${String(e)}`}const lu=(e,t,n)=>`auto-group-${e}-${t}-${n??"root"}`,su=e=>`${e}${et}footer`,au=e=>e==="footer"?"f":e===null?"n":"i",cu=e=>e==="f"?"footer":e==="n"?null:"inline";function du(e){const{rows:t,getRowId:n,columns:o,rowGroupingModel:r=ou,aggregationModel:i=ru,defaultGroupingExpansionDepth:l=0,filterModel:c,sortModel:a,getAggregationPosition:u=El,columnLookup:f,filterMode:h="client",sortingMode:x="client"}=e,y=r.join(et),w=s.useMemo(()=>y===""?[]:y.split(et),[y]),g=JSON.stringify(Object.entries(i)),p=s.useMemo(()=>Object.fromEntries(JSON.parse(g)),[g]),m=Object.keys(p).length>0,C=s.useMemo(()=>{const $=new Map;return(o??[]).forEach(D=>$.set(D.field,D)),$},[o]),b=w.length>0,_=s.useMemo(()=>w.filter($=>C.get($)?.groupable!==!1),[w,C]),k=`${_.join(et)}|${l}`,[A,M]=s.useState(()=>({configKey:k,overrides:new Map})),N=A.configKey===k?A.overrides:Al,P=s.useMemo(()=>{if(!b||h==="server")return null;const $=Tn(c,f);return $?new Set(t.filter(D=>$(D))):null},[b,t,h,c,f]),T=s.useMemo(()=>{const $=new Map,D=[],G=[],W=new Map,ee=new Map,V=new Map;if(!b)return{treeNodes:$,rootIds:D,groupIds:G,groupRowVariants:W,groupingRows:ee,rowLookup:V};const Y=(J,te,ne)=>{if(te>=_.length)return(P?J.filter(de=>P.has(de)):J).map(de=>{const we=n(de);return V.set(we,de),$.set(we,{id:we,parentId:ne,depth:te,groupingKey:"",isExpanded:!1}),we});const z=_[te],ie=C.get(z),ae=new Map;for(const ce of J){const de=Se(ce,z,ie),we=iu(de);let me=ae.get(we);me||(me={value:de,rows:[]},ae.set(we,me)),me.rows.push(ce)}const le=[];return ae.forEach((ce,de)=>{const we=P?ce.rows.filter(ge=>P.has(ge)):ce.rows;if(we.length===0)return;const me=lu(z,de,ne);le.push(me),G.push(me);const pe=m?In(we,p,C,"useRowGrouping"):{},oe={[z]:ce.value,...pe,id:me},ue={[z]:ce.value,id:me},be=m?{...pe,id:su(me)}:null;W.set(me,{inline:oe,bare:ue,footer:be}),ee.set(me,oe),be&&ee.set(be.id,be);const he={id:me,parentId:ne,depth:te,groupingKey:String(ce.value),groupingField:z,groupingValue:ce.value,aggregatedValues:pe,isExpanded:!1,children:[],label:nu(ie,z,ce.value),descendantCount:we.length};$.set(me,he),he.children=Y(ce.rows,te+1,me)}),le};return D.push(...Y(t,0,null)),{treeNodes:$,rootIds:D,groupIds:G,groupRowVariants:W,groupingRows:ee,rowLookup:V}},[b,t,P,_,m,p,n,C]),{treeNodes:S,rootIds:I,groupIds:F,groupRowVariants:L,groupingRows:E,rowLookup:O}=T,B=s.useCallback($=>!!($?.children&&$.children.length>0)&&(l===-1||($?.depth??0)<l),[l]),H=s.useMemo(()=>{const $=new Set;for(const D of F){const G=S.get(D);!G?.children||G.children.length===0||(N.get(D)??B(G))&&$.add(D)}return $},[F,S,N,B]),K=s.useCallback($=>{M(D=>{const G=D.configKey===k?D.overrides:Al,W=G.get($)??B(S.get($)),ee=new Map(G);return ee.set($,!W),{configKey:k,overrides:ee}})},[k,S,B]),R=s.useCallback($=>H.has($),[H]),X=m?F.map($=>{const D=S.get($);return D?au(Ml(u,{...D,isExpanded:H.has($)})):"i"}).join(""):"",j=s.useMemo(()=>{const $=new Map;return F.forEach((D,G)=>$.set(D,cu(X[G]))),$},[F,X]),Q=m?Ml(u,null):"footer",U=x!=="server"&&!!(a&&a.length>0),re=s.useCallback($=>{if(!b)return null;const D=$?.labelField,G=$?.expandAll??!1,W=U&&a?a:[],ee=(te,ne)=>{const z=S.get(te),ie=L.get(te);if(z&&ie){const we=z.groupingField??"";if(ne.field===we||ne.field===D){const me=f?.byField.get(we),pe=me?.sortComparator;return{value:z.groupingValue,type:me?.type,comparator:pe,params:pe?{id:te,field:we,row:ie.inline,value:z.groupingValue}:void 0}}return z.aggregatedValues&&Object.prototype.hasOwnProperty.call(z.aggregatedValues,ne.field)?{value:z.aggregatedValues[ne.field],type:f?.byField.get(ne.field)?.type}:{value:void 0}}const ae=O.get(te),le=f?.byField.get(ne.field),ce=ae?Se(ae,ne.field,le):void 0,de=le?.sortComparator;return{value:ce,type:le?.type,comparator:de,params:de&&ae?{id:te,field:ne.field,row:ae,value:ce}:void 0}},V=[],Y=new Set,J=te=>{const ne=W.length>0?wi(te,W,ee):te;for(const z of ne){if(Y.has(z))continue;Y.add(z);const ie=L.get(z);if(!ie){const we=O.get(z);we&&V.push(we);continue}const ae=S.get(z),le=H.has(z),ce=j.has(z)?j.get(z)??null:"inline",de=ce==="inline"||ce==="footer"&&!le;V.push(de?ie.inline:ie.bare),(le||G)&&ae?.children&&(J(ae.children),le&&!G&&ce==="footer"&&ie.footer&&V.push(ie.footer))}};return J(I),V},[b,U,a,S,L,O,f,H,j,I]),q=s.useCallback($=>S.get($),[S]),se=s.useMemo(()=>{const $=new Map;return S.forEach((D,G)=>{L.has(G)||$.set(G,{hasChildren:!1,treeDepth:D.depth,isGroupRow:!1})}),$},[S,L]),Z=s.useMemo(()=>{const $=new Map;return L.forEach((D,G)=>{const W=S.get(G);if(!W)return;const ee={hasChildren:!0,treeDepth:W.depth,groupingField:W.groupingField,groupingValue:W.groupingValue,groupLabel:W.label,descendantCount:W.descendantCount,isGroupRow:!0,isExpanded:H.has(G)};$.set(G,ee),D.footer&&j.get(G)==="footer"&&$.set(D.footer.id,{...ee,hasChildren:!1,treeDepth:W.depth+1,isExpanded:void 0,isGroupFooter:!0})}),new tu(se,$)},[se,S,L,H,j]);return s.useMemo(()=>({treeNodes:S,groupingRows:E,toggleExpansion:K,isGroupExpanded:R,getVisibleRows:re,getNode:q,rowMetaMap:Z,aggregationPositions:j,rootAggregationPosition:Q}),[S,E,K,R,re,q,Z,j,Q])}const uu=new Map;function fu(e){const{rows:t,getRowId:n,getTreeDataPath:o,isTreeDataRequested:r,isTreeData:i,columns:l,rowGroupingModel:c,isRowGrouping:a,aggregationModel:u,defaultGroupingExpansionDepth:f,filterModel:h,sortModel:x,getAggregationPosition:y,columnLookup:w,filterMode:g,sortingMode:p}=e,m=eu({rows:t,getRowId:n,getTreeDataPath:o,treeData:r,defaultGroupingExpansionDepth:f,filterModel:h,sortModel:x,columnLookup:w,filterMode:g,sortingMode:p}),C=du({rows:t,getRowId:n,columns:l,rowGroupingModel:c,aggregationModel:u,defaultGroupingExpansionDepth:f,filterModel:h,sortModel:x,getAggregationPosition:y,columnLookup:w,filterMode:g,sortingMode:p}),b=i?m:a?C:null,_=s.useMemo(()=>i?m.rowMetaMap:a?C.rowMetaMap:uu,[i,m.rowMetaMap,a,C.rowMetaMap]);return{treeDataHandlers:m,rowGroupingHandlers:C,activeHierarchyHandlers:b,rowMetaMap:_}}function gu(e){const{spanning:t,renderContext:n,offsetTop:o,cumulativeHeights:r}=e;return s.useMemo(()=>{if(!t.hasRowSpan)return{renderContext:n,offsetTop:o};let i=Math.max(0,n.firstRowIndex);for(let l=t.getCenterRowSpanStart(i);l<i;l=t.getCenterRowSpanStart(i))i=l;return i>=n.firstRowIndex?{renderContext:n,offsetTop:o}:{renderContext:{...n,firstRowIndex:i},offsetTop:i>0?r[i-1]??0:0}},[t,n,o,r])}function pu(e){const{spanning:t,firstColumnIndex:n,lastColumnIndex:o,virtualColumns:r,layout:i,rows:l}=e;return s.useMemo(()=>{if(!t.hasColSpan||i.unpinnedColsWithWidth.length===0)return r;let c=n,a=o,u=!0;for(;u;){u=!1;for(const{row:m,id:C}of l){const b=t.getUnpinnedColSpanRanges(C??m.id);if(b)for(let _=0;_<b.length;_+=2){const v=b[_],k=b[_+1];k<c||v>a||(v<c&&(c=v,u=!0),k>a&&(a=k,u=!0))}}}if(c===n&&a===o)return r;const{leftPinnedCols:f,unpinnedColsWithWidth:h,rightPinnedCols:x,unpinnedAccWidths:y,unpinnedTotalWidth:w}=i,g=c>0?y[c-1]:0,p=w-y[a];return[...f,...g>0?[{field:"__spacer_left__",width:g,isSpacer:!0}]:[],...h.slice(c,a+1),...p>0?[{field:"__spacer_right__",width:p,isSpacer:!0}]:[],...x]},[t,n,o,r,i,l])}function hu(e){const{headerRowCount:t,pinnedTopCount:n,pinnedBottomCount:o,pageRowCount:r,totalCenterRowCount:i,pageOffset:l}=e;return{rowCount:t+n+i+o,topBase:t+1,centerOffset:t+l+1,bottomBase:t+n+i+1,bottomRowIndexOffset:n+r}}function Pl(e){if(!e)return 0;let t=0;const n=(o,r)=>{t=Math.max(t,r);for(const i of o.children)typeof i!="string"&&n(i,r+1)};return e.forEach(o=>n(o,1)),t}function Ll(e){const t=new Map;if(!e)return t;const n=(o,r)=>{const i=[...r,o];for(const l of o.children)typeof l=="string"?t.has(l)||t.set(l,i):n(l,i)};return e.forEach(o=>n(o,[])),t}function or(e,t,n){if(!e||e.length===0)return!0;const o=Ll(e),r=o.get(t),i=o.get(n);return(r?.[r.length-1]??null)===(i?.[i.length-1]??null)}function mu(e,t,n){const o=[];let r=0,i=null,l=null;for(const c of e){const a=c.isSpacer?null:t.get(c.field)?.[n]??null;(i===null||l!==a||i.pinned!==c.pinned)&&(i={key:`${a?a.groupId:"filler"}-${n}-${c.field}`,isGroup:a!==null,label:a?.headerName??"",headerClassName:a?.headerClassName,width:0,flexGrow:0,fields:[],firstDataIndex:r,pinned:c.pinned},l=a,o.push(i)),i.width+=c.width,i.flexGrow+=c.flex??0,c.isSpacer||(i.fields.push(c.field),r++)}return o}function wu(e){const{columnGroupingModel:t,headerFilterRow:n=!1,pinnedTopCount:o,pinnedBottomCount:r,pagination:i,paginationMode:l,paginationModel:c,paginationRowCount:a,paginatedUnpinnedRowCount:u,sortedUnpinnedRowCount:f}=e,{page:h,pageSize:x}=c;return s.useMemo(()=>hu({headerRowCount:1+Pl(t)+(n?1:0),pinnedTopCount:o,pinnedBottomCount:r,pageRowCount:i?u:f,totalCenterRowCount:i&&l==="server"?Math.max(a,u):f,pageOffset:i?h*x:0}),[t,n,o,r,i,u,f,l,a,h,x])}const bu=e=>e.id;function xu(e){const{renderContext:t,pinnedTopRows:n,pinnedBottomRows:o,paginatedUnpinnedRows:r,sortedUnpinnedRows:i,pagination:l,getRowId:c=bu}=e;return s.useMemo(()=>{const{firstRowIndex:a,lastRowIndex:u}=t,f=l?r:i,h=n.length,x=n.map((b,_)=>({row:b,id:c(b),rowIndex:_,pinned:"top"})),y=o.map((b,_)=>({row:b,id:c(b),rowIndex:h+f.length+_,pinned:"bottom"})),w=Math.max(0,a),g=Math.min(f.length,u+1),p=f.slice(w,g).map((b,_)=>({row:b,id:c(b),rowIndex:h+w+_})),m=[...x,...p,...y],C=new Set;return m.filter(b=>C.has(b.id)?!1:(C.add(b.id),!0))},[t,n,o,r,i,l,c])}function Cu(e){const{aria:t,spanning:n,virtualization:o,layout:r,pinnedTopRows:i,pinnedBottomRows:l,paginatedUnpinnedRows:c,sortedUnpinnedRows:a,pagination:u,getRowId:f}=e,h=wu(t),x=gu({spanning:n,renderContext:o.renderContext,offsetTop:o.offsetTop,cumulativeHeights:r.cumulativeHeights}),y=xu({renderContext:x.renderContext,pinnedTopRows:i,pinnedBottomRows:l,paginatedUnpinnedRows:c,sortedUnpinnedRows:a,pagination:u,getRowId:f}),w=pu({spanning:n,firstColumnIndex:o.renderContext.firstColumnIndex,lastColumnIndex:o.renderContext.lastColumnIndex,virtualColumns:o.virtualColumns,layout:r,rows:y});return{ariaRows:h,spanRowWindow:x,visibleRows:y,renderColumns:w}}const yu=new Set(["__group__","__check__","__actions__"]);function At(e){return e.filter(t=>t.exportable!==!1&&!t.isSpacer&&!Qe(t.field)&&!yu.has(t.field))}function ft(e){return!!e&&e.length>0}function Nl(e,t,n=o=>o.id){const o=new Set(t);return e.filter(r=>o.has(n(r)))}function dn(e,t,n){return ft(t)?Nl(e,t,n):e}function un(e,t){return!!e&&e.length>0&&!ft(t)}function Vt(e,t,n,o,r){if(!o)return null;if(!t||!r||Object.keys(r).length===0)return o;const i=new Map(n.map(l=>[l.field,l]));return In(e,r,i,"export")}function fn(e,t){return Se(e,t.field,t)}function gn(e,t,n){if(!t.valueFormatter)return Ln(n,t);if(n==null)try{return String(t.valueFormatter({value:n,row:e,field:t.field})??"")}catch{return""}return String(t.valueFormatter({value:n,row:e,field:t.field})??"")}function rr(e,t,n,o){return n==null?"":Fn(n,t??"",e,o)}function zt(e,t){return t?`${e}: ${t}`:e}function Il(e,t){const n={};return t.forEach(o=>{Object.prototype.hasOwnProperty.call(e,o.field)&&(n[o.field]=e[o.field])}),n}const vu=/^[=+\-@\t\r]/,Su=/^[-+]?(?=[\d.,\s]*\d)[\d.,\s]*%?$/;function Xn(e,t=!1){return t||!vu.test(e)||Su.test(e)?e:`'${e}`}const _u=/^[\d\s.,'%+\-()\p{Sc}]*$/u;function ku(e,t,n){return Rt(e)?!n||_u.test(t):!1}function Rt(e){return typeof e=="number"||typeof e=="bigint"||typeof e=="boolean"||e instanceof Date}function Ae(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Eu(e){let t=0,n=e.length;for(;t<n&&e[t]==="'";)t++;for(;n>t&&e[n-1]==="'";)n--;return e.slice(t,n)}const Mu=/[\\/?*:[\]]/g,Fl=31;function ir(e,t=new Set){let n=Eu(String(e??"").replace(Mu,"-").trim()).trim();n||(n="Sheet"),n=n.slice(0,Fl).trim();const o=i=>t.has(i.toLowerCase())||i.toLowerCase()==="history";let r=n;for(let i=2;o(r);i++){const l=` (${i})`;r=`${n.slice(0,Fl-l.length).trim()}${l}`}return t.add(r.toLowerCase()),r}const Au=new Set([Ze,kt,_t]),Pu=/[\t\n\r"]/;function lr(e){return Pu.test(e)?`"${e.replace(/"/g,'""')}"`:e}function Lu(e){return At(e).filter(t=>!Au.has(t.field))}function Nu(e,t){const n=t.map(r=>lr(r.headerName||r.field)).join(" "),o=e.map(r=>t.map(i=>lr(gn(r,i,Se(r,i.field,i)))).join(" "));return[n,...o].join(`
|
|
4
|
+
`)}function Iu(e,t){const n=Se(e,t.field,t);try{return gn(e,t,n)}catch{return n==null?"":String(n)}}function Fu(e,t,n){const o=new Array(e.length);for(let r=0;r<e.length;r++){const i=e[r],l=new Array(t.length);for(let c=0;c<t.length;c++){const a=t[c];l[c]=n?.(i,a)?"":lr(Iu(i,a))}o[r]=l.join(" ")}return o.join(`
|
|
5
|
+
`)}function Tl(e){if(typeof document.execCommand!="function")return!1;const t=document.activeElement instanceof HTMLElement?document.activeElement:null,n=document.getSelection(),o=[];if(n)for(let l=0;l<n.rangeCount;l++)o.push(n.getRangeAt(l));const r=document.createElement("textarea");r.value=e,r.setAttribute("readonly",""),r.setAttribute("aria-hidden","true"),r.style.cssText="position:fixed;top:-9999px;left:-9999px;opacity:0;",document.body.appendChild(r);let i=!1;try{r.focus({preventScroll:!0}),r.select(),i=document.execCommand("copy")}finally{document.body.removeChild(r),t&&t.isConnected&&t.focus({preventScroll:!0}),n&&(n.removeAllRanges(),o.forEach(l=>n.addRange(l)))}return i}async function sr(e){const t=typeof navigator<"u"?navigator.clipboard:void 0;if(t&&typeof t.writeText=="function")try{await t.writeText(e);return}catch(n){if(Tl(e))return;throw n}if(!Tl(e))throw new Error("Clipboard API not available and fallback failed.")}function Tu(e){if(!(e.ctrlKey||e.metaKey)||e.altKey||e.shiftKey)return!1;const t=e.key??"";return t.toLowerCase()==="c"?!0:e.code==="KeyC"&&!/^[a-z]$/i.test(t)}function Ou(e){const t=s.useRef(e);s.useLayoutEffect(()=>{t.current=e});const n=s.useCallback(async()=>{const{getSelectedRowIds:r,getColumns:i,getRows:l,getRowId:c}=t.current,a=new Set(r());if(a.size===0)return;const u=l().filter(h=>a.has(c(h)));if(u.length===0)return;const f=Nu(u,Lu(i()));await sr(f)},[]),o=!!e.disableKeyboardShortcut;return s.useEffect(()=>{if(o)return;const r=i=>{if(i.defaultPrevented||!Tu(i))return;const l=document.activeElement,c=l?.tagName.toLowerCase(),a=l?.type;if(c==="input"&&a!=="checkbox"&&a!=="radio"||c==="textarea"||c==="select"||l?.isContentEditable)return;const{getRootElement:u}=t.current;if(u){const y=u();if(!y||!l||!y.contains(l))return}const f=window.getSelection();if(f&&!f.isCollapsed&&f.toString()!=="")return;const{getShortcutText:h}=t.current;(h?()=>{const y=h();return y===null?Promise.resolve():sr(y)}:n)().catch(y=>{console.error("[OpenGridX] Failed to copy to clipboard:",y)})};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[n,o]),{copySelectedRows:n}}function Du(e){const{apiRef:t}=e,n=s.useRef(e);s.useLayoutEffect(()=>{n.current=e});const o=s.useRef(null),r=s.useRef(null),i=s.useRef(null),{selection:l,model:c,focusedCell:a,setFocusedCell:u,containerRef:f}=e,h=l.range?.anchor??null,x=l.resolved?.anchorRow;s.useLayoutEffect(()=>{l.reportFocus(a);const y=!ut(o.current,h),w=!Do(r.current,a);if(o.current=h,r.current=a,!!l.enabled){if(l.range&&!l.resolved){i.current!==c&&(i.current=c,l.setModel([],"dataChange"));return}if(y&&h){(!a||a.id!==h.id||a.field!==h.field)&&u({id:h.id,field:h.field,rowIndex:x});return}if(w&&a&&a.id!==null&&je(a.field)&&!ut(h,{id:a.id,field:a.field})){const g={id:a.id,field:a.field},p=f.current?.classList.contains("ogx--kb")??!1;l.setModel([{anchor:g,head:g}],p?"keyboard":"pointer")}}},[l,c,h,x,a,u,f]),s.useLayoutEffect(()=>{const y=t.current,w=()=>n.current;y.getCellSelectionModel=()=>{const{selection:g,getPendingModel:p,model:m}=w();return g.enabled?p()??m:[]},y.setCellSelectionModel=g=>{w().selection.setModel(g,"api")},y.selectCellRange=(g,p)=>{w().selection.setModel([{anchor:g,head:p}],"api")},y.clearCellSelection=()=>{w().selection.setModel([],"clear")},y.getSelectedCells=()=>w().selection.getSelectedCells(),y.copySelectedCells=async()=>{const{selection:g}=w();if(!g.enabled)return;const p=g.getCopyText();p!==null&&await sr(p)}},[t])}function Be(e){try{return{ok:!0,value:e()}}catch(t){return{ok:!1,error:t}}}const it={ok:!1},Pe=e=>({ok:!0,value:e});function $u(e){const t=[];if(e==="")return t;let n=[],o="",r=0;const i=e.length;let l=!0;for(;r<i;){const c=e[r];if(l&&c==='"'){let a=r+1,u="",f=!1;for(;a<i;){const h=e[a];if(h==='"'){if(e[a+1]==='"'){u+='"',a+=2;continue}f=!0,a+=1;break}u+=h,a+=1}if(!f){o+=c,r+=1,l=!1;continue}o+=u,r=a,l=!1;continue}l=!1,c===" "?(n.push(o),o="",l=!0,r+=1):c===`
|
|
6
6
|
`||c==="\r"?(n.push(o),t.push(n),n=[],o="",l=!0,r+=c==="\r"&&e[r+1]===`
|
|
7
|
-
`?2:1):(o+=c,r+=1)}return(!l||n.length>0||o!=="")&&(n.push(o),t.push(n)),t}const xu=/^\d+(?:\.\d*)?(?:e[+-]?\d+)?$/i,Cu=/^\.\d+(?:e[+-]?\d+)?$/i,yu=/^\d{1,3}(?:,\d{3})+(?:\.\d*)?$/,vu=/[\p{Sc}\s]/gu;function Su(e){let t=e.replace(vu,"");if(t==="")return e.trim()===""?De(null):rt;let n=!1;t.startsWith("(")&&t.endsWith(")")&&(n=!0,t=t.slice(1,-1)),(t.startsWith("-")||t.startsWith("+")||t.startsWith("−"))&&(t[0]!=="+"&&(n=!n),t=t.slice(1));let o=!1;if(t.endsWith("%")&&(o=!0,t=t.slice(0,-1)),yu.test(t))t=t.split(",").join("");else if(!xu.test(t)&&!Cu.test(t))return rt;let r=Number(t);return Number.isFinite(r)?(o&&(r/=100),n&&(r=-r),De(r)):rt}const _u=/^(\d{4}-\d{2}-\d{2})/,kl=e=>String(e).padStart(2,"0");function ku(e){const t=e.trimEnd();if(t.endsWith("Z")||t.endsWith("z"))return!0;const n=t.indexOf("T");if(n<0)return!1;for(let o=t.length-1;o>n;o--){const r=t[o];if(r==="+"||r==="-")return!0;if(!(r>="0"&&r<="9")&&r!==":")return!1}return!1}const Eu=e=>`${e.getFullYear()}-${kl(e.getMonth()+1)}-${kl(e.getDate())}`;function Mu(e,t){const n=e.trim();if(n==="")return De(null);const o=tn(n);if(!o)return rt;if(typeof t=="number")return De(o.getTime());if(typeof t=="string"){const r=Eu(o);if(!_u.test(t)||t.length<=10)return De(r);const i=ku(t)?new Date(t):null;return i&&!Number.isNaN(i.getTime())?De(new Date(o.getFullYear(),o.getMonth(),o.getDate(),i.getHours(),i.getMinutes(),i.getSeconds(),i.getMilliseconds()).toISOString()):De(r+t.slice(10))}return De(o)}const Lu=new Set(["true","yes","1"]),Au=new Set(["false","no","0"]);function Pu(e,t){const n=e.trim().toLowerCase();return n===""?De(null):t?.trueLabel!==void 0&&n===t.trueLabel.trim().toLowerCase()?De(!0):t?.falseLabel!==void 0&&n===t.falseLabel.trim().toLowerCase()?De(!1):Lu.has(n)?De(!0):Au.has(n)?De(!1):rt}function Iu(e,t){const n=e.trim();if(n==="")return De(null);if(!t||t.length===0)return rt;const o=n.toLowerCase();for(const r of t){const i=typeof r=="object"?r.value:r;if(String(i).toLowerCase()===o)return De(i)}for(const r of t)if(typeof r=="object"&&r.label.toLowerCase()===o)return De(r.value);return rt}function Nu(e,t,n){switch(t?.type){case"number":return Su(e);case"date":return Mu(e,n?.current);case"boolean":return Pu(e,n?.booleanLabels);case"singleSelect":return Iu(e,t.valueOptions);default:return De(e)}}function Fu(e,t,n,o){const{valueParser:r}=t;if(!r)return Nu(e,t,o);let i;try{i=r(e,{row:n,field:t.field,colDef:t})}catch{return rt}return i===void 0?rt:De(i)}function rr(e,t,n){const{rowIds:o,rowIndexById:r}=Yo(e,t,"renderable"),i=n.filter(a=>qe(a.field)),l=new Map;i.forEach((a,u)=>{l.set(a.field,u)});const c=n.filter(a=>Ze(a.field)).length;return{rows:e,rowIds:o,rowIndexById:r,columns:i,colIndexByField:l,dataColumnOffset:c}}function ir(e,t,n,o,r){const i=e.rowIds[o],l=e.columns[r];if(!l||je(i,t.rowMetaMap))return!1;const c=t.getSpanOrigin?.(i,l.field);return c&&(c.rowId!==i||c.field!==l.field)?!1:vo({row:n,field:l.field,value:Me(n,l.field,l),colDef:l,rowIndex:o,colIndex:e.dataColumnOffset+r,rowMeta:t.rowMetaMap?.get(i)},t.isCellEditable)}function Tu(e,t){let n=1/0,o=-1/0,r=1/0,i=-1/0;for(const l of t){const c=e.rowIndexById.get(l.id),a=e.colIndexByField.get(l.field);c===void 0||a===void 0||(c<n&&(n=c),c>o&&(o=c),a<r&&(r=a),a>i&&(i=a))}return n===1/0?null:{top:n,bottom:o,left:r,right:i}}function El(e,t){return{anchor:{id:e.rowIds[t.top],field:e.columns[t.left].field},head:{id:e.rowIds[t.bottom],field:e.columns[t.right].field}}}function Ou(e){const t=e?.type;return t===void 0||t==="string"||t==="image"}const Ml=1e4,Xn=()=>({updated:[],failed:[],skipped:[]});function Du(e){process.env.NODE_ENV!=="production"&&console.warn(`[OpenGridX] Pasting ${e} cells. Pastes above ${Ml} cells can be slow; consider importing the data instead.`)}function $u(e){const{apiRef:t,containerRef:n,selection:o,disableClipboardPaste:r,disableRangeClear:i}=e,l=s.useRef(e);s.useLayoutEffect(()=>{l.current=e});const c=s.useCallback(()=>{const{allRenderableRows:w,getRowId:g,navigationColumns:h}=l.current;return rr(w,g,h)},[]),a=s.useCallback(()=>{const{selection:w}=l.current;return w.enabled?w.getCurrentRange().resolved:null},[]),u=s.useCallback(w=>{const g=a();if(g&&w.rowIds[g.top]!==void 0&&w.columns[g.left])return{id:w.rowIds[g.top],field:w.columns[g.left].field};const h=l.current.focusedCell;return h&&h.id!==null&&qe(h.field)?{id:h.id,field:h.field}:null},[a]),f=s.useCallback(async(w,g,h)=>{const m=c(),C=g??u(m);let y=w;const{onBeforeClipboardPaste:_}=l.current;if(_){const ie=ze(()=>_({text:y,anchor:C}));if(!ie.ok)return vt("onBeforeClipboardPaste","onBeforeClipboardPaste threw; the paste was cancelled",ie.error),Xn();if(ie.value===!1)return Xn();typeof ie.value=="string"&&(y=ie.value)}if(!C)return Xn();const v=bu(y),k=m.rowIndexById.get(C.id),M=m.colIndexByField.get(C.field);if(v.length===0||k===void 0||M===void 0)return Xn();const E=m.rowIds.length-1,I=m.columns.length-1,L=g?null:a(),N=L&&kt(L)>1?L:null,S=v.length===1&&v[0].length===1,F=v.reduce((ie,ce)=>Math.max(ie,ce.length),0);let T;S&&N?T=N:T={top:k,left:M,bottom:Math.min(k+v.length-1,E,N?N.bottom:E),right:Math.min(M+F-1,I,N?N.right:I)};const P=kt(T);P>Ml&&Du(P);const{batchEdit:A,isCellEditable:G,rowMetaMap:z,getSpanOrigin:H}=l.current,Y={isCellEditable:G,rowMetaMap:z,getSpanOrigin:H},K=[],re=[];for(let ie=T.top;ie<=T.bottom;ie++){const ce=m.rowIds[ie],J=A.getRow(ce)??m.rows[ie],se=S?v[0]:v[ie-T.top];for(let ne=T.left;ne<=T.right;ne++){const j=S?v[0][0]:se?.[ne-T.left];if(j===void 0)continue;const B=m.columns[ne];if(!ir(m,Y,J,ie,ne)){re.push({id:ce,field:B.field,reason:"notEditable"});continue}const W=Fu(j,B,J,{current:Me(J,B.field,B)});if(!W.ok){re.push({id:ce,field:B.field,reason:"invalidValue"});continue}K.push({id:ce,field:B.field,value:W.value})}}if(l.current.selection.enabled){const{anchor:ie,head:ce}=El(m,T);l.current.selection.setModel([{anchor:ie,head:ce}],h?"keyboard":"api")}const R=await A.applyEdits(K,"paste"),te={updated:R.result.updated,failed:R.result.failed,skipped:[...re,...R.result.skipped]};return l.current.onClipboardPaste?.({...te,text:y}),te},[c,u,a]),p=s.useCallback(()=>{const w=a();if(!w||kt(w)<=1)return!1;const g=c(),{batchEdit:h,isCellEditable:m,rowMetaMap:C,getSpanOrigin:y}=l.current,_={isCellEditable:m,rowMetaMap:C,getSpanOrigin:y},v=[];for(let k=w.top;k<=w.bottom;k++){const M=g.rowIds[k];if(M===void 0)continue;const E=h.getRow(M)??g.rows[k];for(let I=w.left;I<=w.right;I++){const L=g.columns[I];!L||!ir(g,_,E,k,I)||v.push({id:M,field:L.field,value:Ou(L)?"":null})}}return h.applyEdits(v,"clear"),!0},[a,c]),b=o.enabled&&!r,x=o.enabled&&!i;s.useEffect(()=>{const w=n.current;if(!w||!b&&!x)return;const g=k=>{const M=l.current.viewportRef.current;if(!M||k.defaultPrevented||l.current.isEditing)return!1;const E=Hn(k.target,M);return E==="grid"||E==="control"};let h=null;const m=()=>{if(!h)return;const{textarea:k,restore:M,timer:E}=h;h=null,window.clearTimeout(E);const I=document.activeElement===k;k.remove(),I&&M&&M.isConnected&&M.focus({preventScroll:!0})},C=()=>{m();const k=document.createElement("textarea");k.setAttribute("aria-hidden","true"),k.tabIndex=-1,k.className="ogx__paste-capture",k.style.cssText="position:fixed;top:0;left:-10000px;width:1px;height:1px;opacity:0;",w.appendChild(k);const M=document.activeElement instanceof HTMLElement?document.activeElement:null;h={textarea:k,restore:M,timer:window.setTimeout(m,250)},k.focus({preventScroll:!0})},y=k=>h!==null&&k.target===h.textarea,_=k=>{if(y(k)){const E=k.clipboardData?k.clipboardData.getData("text/plain"):"";k.preventDefault(),m(),E!==""&&f(E,void 0,!0);return}if(!b||!g(k)||!l.current.navigationColumns.some(E=>E.editable))return;const M=k.clipboardData?k.clipboardData.getData("text/plain"):"";M!==""&&(k.preventDefault(),f(M,void 0,!0))},v=k=>{if((k.ctrlKey||k.metaKey)&&!k.altKey&&!k.shiftKey&&(k.key==="v"||k.key==="V"||k.code==="KeyV")){b&&g(k)&&l.current.navigationColumns.some(M=>M.editable)&&C();return}!x||k.key!=="Delete"&&k.key!=="Backspace"||k.ctrlKey||k.metaKey||k.altKey||k.shiftKey||g(k)&&p()&&k.preventDefault()};return w.addEventListener("paste",_),w.addEventListener("keydown",v),()=>{m(),w.removeEventListener("paste",_),w.removeEventListener("keydown",v)}},[n,b,x,f,p]),s.useLayoutEffect(()=>{t.current.pasteText=(w,g)=>f(w,g,!1)},[t,f])}const Gu=100;function Hu(){const e=s.useRef(null),t=s.useCallback((o,r)=>{const i=e.current;i&&i(o,r)},[]),n=s.useCallback(o=>{e.current=o},[]);return s.useMemo(()=>({emit:t,setListener:n}),[t,n])}const Ll=()=>({updated:[],failed:[],skipped:[]});function Bu(e){if(e.altKey||!(e.ctrlKey||e.metaKey))return null;const t=(e.key??"").toLowerCase(),n=/^[a-z]$/.test(t),o=t==="z"||!n&&e.code==="KeyZ",r=t==="y"||!n&&e.code==="KeyY";return o?e.shiftKey?"redo":"undo":r&&e.ctrlKey&&!e.shiftKey?"redo":null}function Wu(e){const{apiRef:t,enabled:n,channel:o,containerRef:r}=e,i=s.useRef(e);s.useLayoutEffect(()=>{i.current=e});const l=s.useRef([]),c=s.useRef([]),a=s.useRef({canUndo:!1,canRedo:!1,size:0}),u=s.useRef(Promise.resolve()),f=s.useCallback(()=>{const m={canUndo:l.current.length>0,canRedo:c.current.length>0,size:l.current.length},C=a.current;C.canUndo===m.canUndo&&C.canRedo===m.canRedo&&C.size===m.size||(a.current=m,i.current.onHistoryChange?.(m))},[]),p=s.useCallback(m=>{if(!i.current.enabled||m.length===0)return;const C=l.current;C.push(m);const y=Math.max(1,i.current.limit);C.length>y&&C.splice(0,C.length-y),c.current=[],f()},[f]);s.useLayoutEffect(()=>(o.setListener(n?p:null),()=>o.setListener(null)),[o,n,p]);const b=s.useCallback(()=>{l.current=[],c.current=[],f()},[f]);s.useEffect(()=>{n||b()},[n,b]);const x=s.useCallback(m=>{const C=i.current,y=rr(C.allRenderableRows,C.getRowId,C.navigationColumns),_=Tu(y,m);if(!_)return;const{anchor:v,head:k}=El(y,_);C.selection.enabled?C.selection.setModel([{anchor:v,head:k}],"keyboard"):C.setFocusedCell({id:v.id,field:v.field,rowIndex:_.top});const M=C.viewportRef.current;M&&(Nn(M,_.top-C.pinnedTopRowCount,C.layout.cumulativeHeights,C.layout.pinnedBottomHeight,C.rowHeight),yo(M,C.layout.unpinnedColsWithWidth.findIndex(E=>E.field===v.field),C.layout))},[]),w=s.useCallback(m=>{const C=async()=>{if(!i.current.enabled)return Ll();const _=m==="undo"?l:c,v=m==="undo"?c:l,k=_.current.pop();if(!k)return Ll();f();const M=k.map(L=>m==="undo"?{id:L.id,field:L.field,value:L.before,expect:{value:L.after}}:{id:L.id,field:L.field,value:L.after,expect:{value:L.before}}),E=await i.current.batchEdit.applyEdits(M,m);E.committed.length>0&&v.current.push(m==="undo"?E.committed.map(L=>({id:L.id,field:L.field,before:L.after,after:L.before})):E.committed);const I=new Set(E.result.failed.map(L=>L.id));if(I.size>0){const L=k.filter(N=>I.has(N.id));L.length>0&&_.current.push(L)}return f(),E.committed.length>0&&x(E.committed),E.result},y=u.current.then(C,C);return u.current=y,y},[f,x]),g=s.useCallback(()=>w("undo"),[w]),h=s.useCallback(()=>w("redo"),[w]);s.useEffect(()=>{const m=r.current;if(!m||!n)return;const C=y=>{if(y.defaultPrevented)return;const _=Bu(y);if(!_)return;const v=i.current.viewportRef.current;if(!v||i.current.isEditing)return;const k=Hn(y.target,v);k!=="grid"&&k!=="control"||(y.preventDefault(),_==="undo"?g():h())};return m.addEventListener("keydown",C),()=>m.removeEventListener("keydown",C)},[r,n,g,h]),s.useLayoutEffect(()=>{const m=t.current;m.undo=g,m.redo=h,m.canUndo=()=>i.current.enabled&&l.current.length>0,m.canRedo=()=>i.current.enabled&&c.current.length>0,m.clearHistory=b},[t,g,h,b])}function Vu(e){const t=String(e);if(t.includes("e")||t.includes("E"))return null;const n=t.indexOf(".");return n===-1?0:t.length-n-1}function lr(e,t){return t===null?e:Number(e.toFixed(Math.min(t,20)))}function zu(e,t){let n=0;for(const l of e){const c=Vu(l);n=c===null||n===null?null:Math.max(n,c)}const o=lr(e[1]-e[0],n);for(let l=2;l<e.length;l++)if(lr(e[l]-e[l-1],n)!==o)return null;const r=e[e.length-1],i=[];for(let l=1;l<=t;l++)i.push(lr(r+o*l,n));return i}const Ru=864e5,Al=e=>((e.getHours()*60+e.getMinutes())*60+e.getSeconds())*1e3+e.getMilliseconds(),Uu=e=>Math.round(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())/Ru),Ku=e=>e.getFullYear()*12+e.getMonth(),ju=(e,t)=>new Date(e,t+1,0).getDate();function sr(e){const t=e[1]-e[0];for(let n=2;n<e.length;n++)if(e[n]-e[n-1]!==t)return null;return t}function qu(e,t){const n=e[e.length-1],o=e.every(l=>Al(l)===Al(n));if(o&&e.every(l=>l.getDate()===n.getDate())){const l=sr(e.map(Ku));if(l!==null&&l!==0){const c=[];for(let a=1;a<=t;a++){const u=n.getMonth()+l*a,f=n.getFullYear()+Math.floor(u/12),p=(u%12+12)%12,b=new Date(n.getTime());b.setFullYear(f,p,Math.min(n.getDate(),ju(f,p))),c.push(b)}return c}}if(o){const l=sr(e.map(Uu));if(l===null)return null;const c=[];for(let a=1;a<=t;a++){const u=new Date(n.getTime());u.setDate(n.getDate()+l*a),c.push(u)}return c}const r=sr(e.map(l=>l.getTime()));if(r===null)return null;const i=[];for(let l=1;l<=t;l++)i.push(new Date(n.getTime()+r*l));return i}const Xu=e=>typeof e=="number"&&Number.isFinite(e),Yu=e=>e instanceof Date&&!Number.isNaN(e.getTime());function Ju(e,t){return e.length<2?null:e.every(Xu)?zu(e,t):e.every(Yu)?qu(e,t):null}const Zu=e=>e instanceof Date?new Date(e.getTime()):e;function Qu(e,t,n){if(e.length===0||t<=0)return[];const o=n?Ju(e,t):null;if(o)return o;const r=[];for(let i=0;i<t;i++)r.push(Zu(e[i%e.length]));return r}function ef(e,t,n,o){const r=t.row>e.bottom||t.row<e.top,i=t.col>e.right||t.col<e.left;return!r&&!i?null:r&&(!i||Math.abs(o)>=Math.abs(n))?t.row>e.bottom?{rect:{...e,bottom:t.row},direction:"down"}:{rect:{...e,top:t.row},direction:"up"}:t.col>e.right?{rect:{...e,right:t.col},direction:"right"}:{rect:{...e,left:t.col},direction:"left"}}function tf(e,t,n){const o=(a,u)=>{const f=[];if(a<=u)for(let p=a;p<=u;p++)f.push(p);else for(let p=a;p>=u;p--)f.push(p);return f},i=n==="down"||n==="up"?o(e.left,e.right):o(e.top,e.bottom);let l,c;switch(n){case"down":l=o(e.top,e.bottom),c=t.bottom>e.bottom?o(e.bottom+1,t.bottom):[];break;case"up":l=o(e.bottom,e.top),c=t.top<e.top?o(e.top-1,t.top):[];break;case"right":l=o(e.left,e.right),c=t.right>e.right?o(e.right+1,t.right):[];break;default:l=o(e.right,e.left),c=t.left<e.left?o(e.left-1,t.left):[]}return i.map(a=>({line:a,source:l,targets:c}))}function nf(e,t,n){const o=n.row===e.top||n.row===e.bottom,r=n.col===e.left||n.col===e.right;let i=n.row,l=n.col;return(!o||!r)&&(t==="down"||t==="up"?(i=t==="down"?e.top:e.bottom,l=n.col===e.right?e.right:e.left):(l=t==="right"?e.left:e.right,i=n.row===e.bottom?e.bottom:e.top)),{anchor:{row:i,col:l},head:{row:i===e.top?e.bottom:e.top,col:l===e.left?e.right:e.left}}}function of(e,t,n,o){const r=t(e.bottom),i=n[e.right];if(r===void 0||i===void 0)return null;const l=o?.(r,i);if(!l||l.rowId===r&&l.field===i)return{row:e.bottom,field:i};for(let c=e.bottom;c>=Math.max(0,e.bottom-rf);c--)if(t(c)===l.rowId)return{row:c,field:l.field};return null}const rf=1e3,lf="ogx__cell-fill-handle";function sf(e){if(e.altKey||e.shiftKey||!(e.ctrlKey||e.metaKey))return null;const t=(e.key??"").toLowerCase(),n=/^[a-z]$/.test(t);return t==="d"||!n&&e.code==="KeyD"?"down":t==="r"||!n&&e.code==="KeyR"?"right":null}function af(e){const{containerRef:t,viewportRef:n,selection:o,disableFillHandle:r,isEditing:i,allRenderableRows:l,getRowId:c,navigationColumns:a,columnIndexMap:u,getSpanOrigin:f}=e,p=s.useRef(e);s.useLayoutEffect(()=>{p.current=e});const b=o.enabled&&!r,x=s.useMemo(()=>a.some(E=>E.editable),[a]),w=o.resolved,g=s.useMemo(()=>{if(!b||!x||!w)return null;const E=a.filter(S=>qe(S.field)).map(S=>S.field),L=of(w,S=>{const F=l[S];return F===void 0?void 0:c(F)},E,f);if(!L)return null;const N=u.get(L.field);return N===void 0?null:{row:L.row,col:N}},[b,x,w,l,c,a,u,f]),h=s.useRef(!0);s.useEffect(()=>(h.current=!0,()=>{h.current=!1}),[]);const m=s.useCallback(()=>{const E=p.current;return rr(E.allRenderableRows,E.getRowId,E.navigationColumns)},[]),C=s.useCallback((E,I,L,N,S)=>{const F=nf(I,L,N),T=P=>({id:E.rowIds[P.row],field:E.columns[P.col].field});p.current.selection.setModel([{anchor:T(F.anchor),head:T(F.head)}],S)},[]),y=s.useCallback(async(E,I,L,N,S,F,T)=>{const{batchEdit:P,isCellEditable:A,rowMetaMap:G,getSpanOrigin:z}=p.current,H={isCellEditable:A,rowMetaMap:G,getSpanOrigin:z},Y=N==="down"||N==="up",K=ce=>{const J=E.rowIds[ce];return J===void 0?void 0:P.getRow(J)??E.rows[ce]},re=[],R=[];for(const ce of tf(I,L,N)){if(ce.targets.length===0)continue;const J=j=>Y?{r:j,c:ce.line}:{r:ce.line,c:j},se=[];for(const j of ce.source){const{r:B,c:W}=J(j),ae=K(B),fe=E.columns[W];!ae||!fe||je(E.rowIds[B],G)||se.push(Me(ae,fe.field,fe))}if(se.length===0)continue;const ne=Qu(se,ce.targets.length,!S);ce.targets.forEach((j,B)=>{const{r:W,c:ae}=J(j),fe=K(W),Q=E.columns[ae],U=E.rowIds[W];if(!fe||!Q||U===void 0)return;if(!ir(E,H,fe,W,ae)){R.push({id:U,field:Q.field,reason:"notEditable"});return}let O=ne[B];const $=Q.fillValue;if($){const D=ze(()=>$.call(Q,{row:fe,id:U,field:Q.field,colDef:Q,direction:N,sourceValues:se.slice(),index:B,value:O,copy:S}));if(!D.ok){vt(`fillValue:${Q.field}`,`fillValue of column "${Q.field}" threw; the cell was skipped`,D.error),R.push({id:U,field:Q.field,reason:"invalidValue"});return}O=D.value}re.push({id:U,field:Q.field,value:O})})}C(E,L,N,F,T);const te=await P.applyEdits(re,"fill"),ie={updated:te.result.updated,failed:te.result.failed,skipped:[...R,...te.result.skipped],direction:N};return p.current.onFill?.(ie),ie},[C]),_=s.useRef(null),v=s.useCallback((E,I,L)=>{const N=_.current,S=p.current.viewportRef.current;if(!N||!S)return;const F=N.ctx,T=F.rowIndexById.get(E.id),P=F.colIndexByField.get(E.field);if(T===void 0||P===void 0)return;const A=I-N.x+S.scrollLeft-N.scrollLeft,G=L-N.y+S.scrollTop-N.scrollTop,z=ef(N.source,{row:T,col:P},A,G);N.target=z,z?C(F,z.rect,z.direction,N.anchor,"pointer"):p.current.selection.setModel(N.sourceModel,"pointer")},[C]),k=s.useCallback(({cancelled:E,altKey:I})=>{const L=_.current;if(_.current=null,!L||!h.current)return;const N=L.ctx;if(E||!L.target){p.current.selection.setModel(L.sourceModel,"pointer");return}y(N,L.source,L.target.rect,L.target.direction,I,L.anchor,"pointer")},[y]),M=b&&x;return s.useEffect(()=>{const E=n.current;if(!E||!M)return;const I=L=>{if(L.button!==0||!(L.target instanceof Element))return;const N=L.target.closest(`.${lf}`);if(!N||N.closest(".ogx__viewport")!==E||p.current.isEditing)return;const{selection:S}=p.current,{range:F,resolved:T}=S.getCurrentRange();if(!F||!T)return;const P=m(),A=P.rowIds[T.bottom],G=P.columns[T.right];if(A===void 0||!G)return;L.preventDefault();const z=E.ownerDocument;E.contains(z.activeElement)||E.focus({preventScroll:!0}),ze(()=>E.setPointerCapture(L.pointerId)),_.current={source:{top:T.top,bottom:T.bottom,left:T.left,right:T.right},sourceModel:[F],anchor:{row:T.anchorRow,col:T.anchorCol},ctx:P,x:L.clientX,y:L.clientY,scrollLeft:E.scrollLeft,scrollTop:E.scrollTop,target:null},S.startTrackedDrag({start:{id:A,field:G.field},x:L.clientX,y:L.clientY,pointerId:L.pointerId,onTrack:v,onEnd:k})};return E.addEventListener("pointerdown",I),()=>E.removeEventListener("pointerdown",I)},[n,M,m,v,k]),s.useEffect(()=>{const E=t.current;if(!E||!b)return;const I=L=>{if(L.defaultPrevented)return;const N=sf(L);if(!N)return;const S=p.current.viewportRef.current;if(!S||p.current.isEditing)return;const F=Hn(L.target,S);if(F!=="grid"&&F!=="control")return;const{range:T,resolved:P}=p.current.selection.getCurrentRange();if(!T||!P)return;L.preventDefault();const A={top:P.top,bottom:P.bottom,left:P.left,right:P.right},G=N==="down"?{...A,bottom:A.top}:{...A,right:A.left};(N==="down"?A.bottom===A.top:A.right===A.left)||y(m(),G,A,N,!0,{row:P.anchorRow,col:P.anchorCol},"keyboard")};return E.addEventListener("keydown",I),()=>E.removeEventListener("keydown",I)},[t,b,y,m]),{handle:i?null:g}}function cf(e){const{props:t,apiRef:n,containerRef:o,viewportRef:r,selection:i,model:l,getPendingModel:c,focusedCell:a,setFocusedCell:u,allRenderableRows:f,getRowId:p,navigationColumns:b,columnIndexMap:x,isCellEditable:w,rowMetaMap:g,getSpanOrigin:h,isEditing:m,batchEdit:C,channel:y,layout:_,rowHeight:v,pinnedTopRowCount:k}=e,{disableClipboardPaste:M=!1,disableRangeClear:E=!1,onClipboardPaste:I,onBeforeClipboardPaste:L,undoRedo:N=!1,disableFillHandle:S=!1,onFill:F,onHistoryChange:T}=t;return wu({apiRef:n,selection:i,model:l,getPendingModel:c,focusedCell:a,setFocusedCell:u,containerRef:o}),$u({apiRef:n,containerRef:o,viewportRef:r,selection:i,disableClipboardPaste:M,disableRangeClear:E,focusedCell:a,allRenderableRows:f,getRowId:p,navigationColumns:b,isCellEditable:w,rowMetaMap:g,getSpanOrigin:h,isEditing:m,batchEdit:C,onClipboardPaste:I,onBeforeClipboardPaste:L}),Wu({apiRef:n,enabled:!!N,limit:typeof N=="object"&&N.limit||Gu,onHistoryChange:T,channel:y,batchEdit:C,isEditing:m,containerRef:o,viewportRef:r,selection:i,setFocusedCell:u,allRenderableRows:f,getRowId:p,navigationColumns:b,layout:_,rowHeight:v,pinnedTopRowCount:k}),af({containerRef:o,viewportRef:r,selection:i,disableFillHandle:S,isEditing:m,allRenderableRows:f,getRowId:p,navigationColumns:b,columnIndexMap:x,isCellEditable:w,rowMetaMap:g,getSpanOrigin:h,batchEdit:C,onFill:F})}const df=100;function Pl(e){const{scrollTop:t,scrollHeight:n,clientHeight:o}=e;return n-t-o>=df?null:{visibleTop:t,visibleBottom:t+o,viewportHeight:o}}function uf(e){return e<.5?3:e<3?5:e<15?12:e<40?20:30}function ff(e){const{onRowsScrollEnd:t,overscanRowCount:n=3,rowCount:o=0,autoHeight:r=!1}=e,i=s.useRef({scrollTop:0,scrollLeft:0,velocity:0}),l=s.useRef({scrollTop:0,scrollLeft:0,time:0}),c=s.useRef(null),a=s.useRef(null),u=s.useRef(null),f=s.useRef(!0),p=s.useRef(t),[b,x]=s.useState({scrollTop:0,scrollLeft:0,velocityOverscan:0});s.useEffect(()=>{p.current=t},[t]),s.useEffect(()=>()=>{c.current!==null&&cancelAnimationFrame(c.current),a.current!==null&&clearTimeout(a.current)},[]);const w=s.useCallback(m=>{const C=Pl(m);if(!C){f.current=!0;return}if(!f.current)return;const y=p.current;y&&(f.current=!1,y(C))},[]),g=s.useCallback(m=>{const C=m.currentTarget,y=performance.now(),_=$t(C),v=Math.abs(C.scrollTop-l.current.scrollTop)+Math.abs(_-l.current.scrollLeft),k=y-l.current.time,M=k>0?v/k:0,E=C.scrollTop!==l.current.scrollTop;l.current={scrollTop:C.scrollTop,scrollLeft:_,time:y},i.current={scrollTop:C.scrollTop,scrollLeft:_,velocity:M},c.current!==null&&cancelAnimationFrame(c.current),c.current=requestAnimationFrame(()=>{c.current=null;const{scrollTop:I,scrollLeft:L,velocity:N}=i.current;x({scrollTop:I,scrollLeft:L,velocityOverscan:uf(N)})}),a.current!==null&&clearTimeout(a.current),a.current=setTimeout(()=>{a.current=null,x(I=>I.velocityOverscan===0?I:{...I,velocityOverscan:0})},200),E&&w(C)},[w]);s.useEffect(()=>{f.current=!0;const m=u.current;!m||r||o<=0||m.clientHeight===0||w(m)},[o,r,w]),s.useEffect(()=>{const m=u.current?.ownerDocument??(typeof document>"u"?null:document);if(!m||typeof MutationObserver>"u")return;const C=new MutationObserver(()=>{const y=u.current;if(!y)return;const _={scrollTop:y.scrollTop,scrollLeft:$t(y)},v=i.current;_.scrollTop===v.scrollTop&&_.scrollLeft===v.scrollLeft||(i.current={...v,..._},l.current={...l.current,..._},x(k=>({...k,..._})))});return C.observe(m.documentElement,{attributes:!0,attributeFilter:["dir"],subtree:!0}),()=>C.disconnect()},[]);const h=s.useCallback(m=>{if(u.current=m,!m)return;const{scrollTop:C,scrollLeft:y}=i.current;if(C===0&&y===0)return;m.scrollTop=C,nn(m,y);const _={scrollTop:m.scrollTop,scrollLeft:$t(m)};(_.scrollTop!==C||_.scrollLeft!==y)&&(i.current={...i.current,..._},l.current={...l.current,..._},x(v=>({...v,..._})))},[]);return{scrollTop:b.scrollTop,scrollLeft:b.scrollLeft,overscanRows:Math.max(b.velocityOverscan,n),handleScroll:g,attachViewport:h}}function gf(e){const t=s.useRef(null);return s.useCallback(n=>{if(t.current?.disconnect(),t.current=null,!n||typeof ResizeObserver>"u")return;const o=new ResizeObserver(r=>{for(const i of r){const{width:l,height:c}=i.contentRect;e(l,c)}});o.observe(n),t.current=o},[e])}function pf(e){const{setDimensions:t,viewportRef:n,...o}=e,{scrollTop:r,scrollLeft:i,overscanRows:l,handleScroll:c,attachViewport:a}=ff(o),u=gf(t),f=s.useCallback(p=>{n.current=p,u(p),a(p)},[n,u,a]);return{scrollTop:r,scrollLeft:i,overscanRows:l,handleScroll:c,setViewportElement:f}}function hf(e){const[t,n]=s.useState(void 0);return s.useLayoutEffect(()=>{const o=$c(e.current?.ownerDocument);n(r=>r===o?r:o)},[e]),t}function mf(e){const{layout:t,scrollTop:n,scrollLeft:o,viewportWidth:r,viewportHeight:i,autoHeight:l,rowReordering:c,hasDetailPanel:a,checkboxSelection:u,pinCheckboxColumn:f,pinExpandColumn:p,overscanRows:b=5,maxContentHeight:x=1/0}=e,{unpinnedAccWidths:w,unpinnedColsWithWidth:g,leftPinnedCols:h,rightPinnedCols:m,leftWidth:C,unpinnedTotalWidth:y}=t,_=s.useMemo(()=>{const v=r||1e3,k=Math.max(0,o-C),M=o+v-C,E=6;let I=0,L=g.length-1,N=0,S=w.length-1;for(;N<=S;){const A=N+S>>>1;w[A]<k?N=A+1:S=A-1}I=Math.max(0,N-E);for(let A=I;A<w.length;A++){if((A===0?0:w[A-1])>M){L=Math.min(g.length-1,A+E);break}L=Math.min(g.length-1,A+E)}const F=I>0?w[I-1]:0,T=y-w[L],P=[...h,...F>0?[{field:"__spacer_left__",width:F,isSpacer:!0}]:[],...g.slice(I,L+1),...T>0?[{field:"__spacer_right__",width:T,isSpacer:!0}]:[],...m];return{firstUnpinnedIndex:I,lastUnpinnedIndex:L,virtualColumns:P}},[w,g,h,m,C,y,o,r]);return s.useMemo(()=>{const{totalWidth:v,rightWidth:k,systemColumnsWidth:M,cumulativeHeights:E,pinnedTopHeight:I,pinnedBottomHeight:L,unpinnedRowsHeight:N,rowHeights:S,unpinnedRowsLength:F}=t,T=r||1e3,P=l?I+N+L+50:i||600,{firstUnpinnedIndex:A,lastUnpinnedIndex:G,virtualColumns:z}=_,Y=T>0&&v>T?16:0,K=I+N+L+Y+2,re=K-I-L,R=Number.isFinite(x)?Math.max(0,Math.min(re,x-I-L)):re;let te=0,ie=F-1,ce=0,J=0,se=E.length-1;for(;J<=se;){const j=J+se>>>1;E[j]<n?J=j+1:se=j-1}te=Math.max(0,J-b),ce=te>0?E[te-1]:0;for(let j=te;j<E.length;j++)if(E[j]>=n+P){ie=Math.min(F-1,j+b);break}const ne=(c?48:0)+(a&&p?48:0)+(u&&f?48:0);return{renderContext:{firstRowIndex:te,lastRowIndex:ie,firstColumnIndex:A,lastColumnIndex:G},offsetTop:ce,offsetLeft:0,totalHeight:K,virtualContainerHeight:R,pinnedTopHeight:I,pinnedBottomHeight:L,totalWidth:v,rowHeights:S,cumulativeHeights:E,virtualColumns:z,columnMetrics:{leftPinnedWidth:C,rightPinnedWidth:k,unpinnedAccWidths:w,unpinnedCols:g,totalSpecialsWidth:M,pinnedSpecialsWidth:ne}}},[t,_,C,w,g,n,r,i,l,c,a,u,f,p,b,x])}function wf(e){const{viewport:t,viewportRef:n,containerRef:o,layout:r,viewportWidth:i,viewportHeight:l,virtualization:c}=e,{scrollTop:a,scrollLeft:u,overscanRows:f,handleScroll:p,setViewportElement:b}=pf({...t,rowCount:r.unpinnedRowsLength,viewportRef:n}),x=hf(o),w=mf({layout:r,scrollTop:a,scrollLeft:u,viewportWidth:i,viewportHeight:l,...c,overscanRows:f,maxContentHeight:x??1/0});return{handleScroll:p,setViewportElement:b,maxContentHeight:x,virtualization:w}}function bf(e){const{apiRef:t,columns:n,getRowId:o,containerRef:r,disableKeyboardShortcut:i,getCellRangeCopyText:l}=e,c=s.useCallback(()=>r.current,[r]),{copySelectedRows:a}=mu({getSelectedRowIds:()=>t.current.getSelectedRows(),getColumns:()=>n,getRows:()=>t.current.getAllFilteredRows(),getRowId:o,getRootElement:c,disableKeyboardShortcut:i,getShortcutText:l});s.useLayoutEffect(()=>{t.current.copySelectedRows=a},[a,t])}function xf(e){const{apiRef:t}=e,n=s.useRef(e);s.useLayoutEffect(()=>{n.current=e}),s.useLayoutEffect(()=>{t.current.scrollToIndexes=({rowIndex:o,colIndex:r})=>{const{viewportRef:i,layout:l,rowHeight:c}=n.current,a=i.current;if(a&&(o!==void 0&&o>=0&&Nn(a,o,l.cumulativeHeights,l.pinnedBottomHeight,c),r!==void 0&&r>=0)){const f=[...l.leftPinnedCols,...l.unpinnedColsWithWidth,...l.rightPinnedCols][r];if(!f)return;yo(a,l.unpinnedColsWithWidth.findIndex(p=>p.field===f.field),l)}}},[t])}const Il=50;function ar(e,t,n,o){const r=Math.min(n??Il,t),i=Math.max(o??1/0,t);return Math.max(r,Math.min(i,e))}const Cf=".ogx";function Nl(e,t){const n=t.style.cssText;t.style.width="max-content",t.style.minWidth="0",t.style.maxWidth="none",t.style.flex="none";const o=t.getBoundingClientRect().width;t.style.cssText=n;const r=getComputedStyle(e),i=[r.paddingLeft,r.paddingRight,r.borderLeftWidth,r.borderRightWidth].reduce((l,c)=>l+(parseFloat(c)||0),0);return o+i}function yf(e,t){const n=typeof CSS<"u"&&CSS.escape?CSS.escape(t):t.replace(/["\\]/g,"\\$&"),o=l=>l.closest(Cf)===e;let r=null;const i=l=>{r=r===null?l:Math.max(r,l)};return e.querySelectorAll(`[role="columnheader"][data-field="${n}"]`).forEach(l=>{if(!o(l))return;const c=l.querySelector(".ogx__header-cell-content");c&&i(Nl(l,c))}),e.querySelectorAll(`[role="gridcell"][data-field="${n}"]`).forEach(l=>{if(!o(l)||l.hasAttribute("aria-colspan"))return;const c=l.querySelector(":scope > .ogx__cell-content");c&&i(Nl(l,c))}),r===null?null:Math.ceil(r)}function vf(e,t,n){return Math.max(t??Il,Math.min(n??1/0,e))}function Sf(e){const{apiRef:t}=e,n=s.useRef(e);s.useLayoutEffect(()=>{n.current=e});const o=s.useCallback(i=>{const{containerRef:l,columns:c,onColumnResize:a}=n.current,u=l.current;if(!u)return;const f=[];for(const p of i??c.map(b=>b.field)){const b=c.find(w=>w.field===p);if(!b||b.resizable===!1)continue;const x=yf(u,p);x!==null&&f.push([p,vf(x,b.minWidth,b.maxWidth)])}for(const[p,b]of f)a(p,b)},[]),r=s.useCallback(i=>o([i]),[o]);return s.useLayoutEffect(()=>{t.current.autosizeColumn=r,t.current.autosizeColumns=o},[t,r,o]),r}function _f(e){const{apiRef:t,containerRef:n,viewportRef:o,copyColumns:r,getRowId:i,disableClipboardCopy:l,getCellRangeCopyText:c,layout:a,rowHeight:u,orderedColumns:f,onColumnResize:p}=e;return bf({apiRef:t,columns:r,getRowId:i,containerRef:n,disableKeyboardShortcut:l,getCellRangeCopyText:c}),xf({apiRef:t,viewportRef:o,layout:a,rowHeight:u}),Sf({apiRef:t,containerRef:n,columns:f,onColumnResize:p})}class Fl extends Error{}function ft(e,t){return e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Object.is(e,t)}function Tl(e){return typeof e=="object"&&e!==null&&typeof e.then=="function"}function Ol(e,t){t?t(e):process.env.NODE_ENV!=="production"&&e instanceof Fl&&console.error(e.message)}function Dl(e,t){return new Fl(`[OpenGridX] processRowUpdate must return the updated row object (or a Promise of it); it returned ${e===null?"null":typeof e}. ${t}`)}function $l(e,t,n,o){return n?.valueSetter?n.valueSetter({value:t.value,row:e,field:t.field}):(n?.valueGetter&&process.env.NODE_ENV!=="production"&&!o.has(t.field)&&(o.add(t.field),console.warn(`[OpenGridX] Column "${t.field}" is editable and has a valueGetter but no valueSetter. The edited value was written to row["${t.field}"], which the valueGetter may ignore, so the cell can keep showing the old value. Add a valueSetter that maps the value back onto the row.`)),{...e,[t.field]:t.value})}function kf(e){const t=s.useRef(e),n=s.useRef(new Map),o=s.useRef(new Set);s.useLayoutEffect(()=>{t.current=e,n.current.clear()});const r=s.useCallback(a=>{const u=n.current.get(a);return u===void 0?t.current.rowsLookup.get(a):u},[]),i=s.useCallback(a=>{a.size!==0&&(a.forEach((u,f)=>{n.current.set(f,u)}),t.current.replaceRows(a))},[]),l=s.useCallback((a,u)=>{i(new Map([[a,u]]))},[i]),c=s.useCallback((a,u)=>{const{columns:f,processRowUpdate:p}=t.current,b=v=>Ol(v,t.current.onProcessRowUpdateError),x=new Map,w=new Map;f.forEach((v,k)=>{x.set(v.field,k),w.set(v.field,v)});const g=[],h=new Map;for(const v of a){const k=r(v.id);if(k===void 0){g.push({id:v.id,field:v.field,reason:"missing"});continue}const M=w.get(v.field);if(v.expect&&!ft(Me(k,v.field,M),v.expect.value)){g.push({id:v.id,field:v.field,reason:"changed"});continue}let E=h.get(v.id);E||(E={id:v.id,row:k,cells:[]},h.set(v.id,E));const I=x.get(v.field)??Number.MAX_SAFE_INTEGER,L=E.cells.findIndex(S=>S.field===v.field),N={field:v.field,value:v.value,colDef:M,order:I};L===-1?E.cells.push(N):E.cells[L]=N}const m=[],C=[],y=o.current;h.forEach(v=>{const{id:k,row:M}=v,E=v.cells.filter(N=>!ft(Me(M,N.field,N.colDef),N.value)).sort((N,S)=>N.order-S.order);if(v.cells=E,E.length===0)return;const I=ze(()=>{let N=M;for(const S of E)N=$l(N,S,S.colDef,y);return p?p(N,M):N});if(!I.ok){m.push({id:k,ok:!1,error:I.error});return}const L=I.value;Tl(L)?C.push(Promise.resolve(L).then(N=>({id:k,ok:!0,processed:N}),N=>({id:k,ok:!1,error:N}))):m.push({id:k,ok:!0,processed:L})});const _=v=>{const k=new Map;v.forEach(N=>{k.set(N.id,N)});const M=[],E=[],I=[],L=new Map;return h.forEach(N=>{const S=k.get(N.id);if(!S)return;if(!S.ok){E.push({id:N.id,error:S.error}),b(S.error);return}const F=S.processed;if(typeof F!="object"||F===null){const P=Dl(F,"The row was not saved.");E.push({id:N.id,error:P}),b(P);return}const T=F;L.set(N.id,T),M.push(N.id);for(const P of N.cells){const A=Me(N.row,P.field,P.colDef),G=Me(T,P.field,P.colDef);ft(A,G)||I.push({id:N.id,field:P.field,before:A,after:G})}}),i(L),I.length>0&&u!=="undo"&&u!=="redo"&&t.current.onCommitted?.(I,u),{result:{updated:M,failed:E,skipped:g},committed:I}};return C.length===0?Promise.resolve(_(m)):Promise.all(C).then(v=>_([...m,...v]))},[r,i]);return s.useMemo(()=>({applyEdits:c,getRow:r,storeRow:l}),[c,r,l])}const Ut=Promise.resolve();function Ef(e){const[t,n]=s.useState(null),o=s.useRef(null),r=s.useRef(0),i=s.useRef(new Map),l=s.useRef(new Set),c=s.useRef(!1),a=s.useRef(e);s.useLayoutEffect(()=>{a.current=e}),s.useEffect(()=>(c.current=!0,()=>{c.current=!1}),[]);const u=s.useCallback(g=>{o.current=g,n(g)},[]),f=s.useRef(null),p=s.useCallback((g,h)=>{const m=i.current.get(g);if(m)return ft(m.value,h.value)?m.promise:m.promise.then(()=>{const H=o.current;if(!(r.current!==g||!H||ft(H.value,m.value)))return f.current?.(g,H)});const C=()=>r.current===g&&o.current!==null;if(ft(h.value,h.originalValue))return C()&&u(null),Ut;const{rows:y,getRowId:_,columns:v,processRowUpdate:k}=a.current,M=y.find(H=>_(H)===h.id);if(!M)return C()&&u(null),Ut;const E=H=>Ol(H,a.current.onProcessRowUpdateError),I=v?.find(H=>H.field===h.field),L=H=>{if(typeof H!="object"||H===null){E(Dl(H,"The edit was not saved and the editor stays open."));return}a.current.onRowChange?.(H,h.id);const{onCommitted:Y}=a.current;if(Y){const re=Me(M,h.field,I),R=Me(H,h.field,I);ft(re,R)||Y([{id:h.id,field:h.field,before:re,after:R}])}const K=o.current;r.current!==g||!K||(ft(K.value,h.value)?u(null):u({...K,originalValue:h.value}))};let N,S;const F=new Promise((H,Y)=>{N=H,S=Y}),T={value:h.value,promise:F};i.current.set(g,T);const P=()=>{i.current.get(g)===T&&i.current.delete(g)},A=ze(()=>{const H=$l(M,h,I,l.current);return k?k(H,M):H});if(!A.ok)return P(),E(A.error),N(),F;const G=A.value,z=H=>{P();try{L(H),N()}catch(Y){S(Y)}};return Tl(G)?Promise.resolve(G).then(z,H=>{P(),E(H),N()}):z(G),F},[u]);s.useLayoutEffect(()=>{f.current=p},[p]);const b=s.useCallback(g=>{const h=o.current;if(h){if(h.id===g.id&&h.field===g.field)return;p(r.current,h)}r.current+=1,u({id:g.id,field:g.field,value:g.value,originalValue:g.value})},[p,u]),x=s.useCallback(g=>{const h=o.current;return!h||!c.current||g?.id!==void 0&&g.id!==h.id||g?.field!==void 0&&g.field!==h.field?Ut:g?.cancel?(u(null),Ut):p(r.current,h)},[p,u]),w=s.useCallback(g=>{const h=o.current;!h||h.id!==g.id||h.field!==g.field||u({...h,value:g.value})},[u]);return s.useMemo(()=>({editingCell:t,startCellEdit:b,stopCellEdit:x,setEditCellValue:w}),[t,b,x,w])}function Mf(e){const{rowsLookup:t,rows:n,getRowId:o,columns:r,processRowUpdate:i,onProcessRowUpdateError:l,replaceRows:c}=e,a=Hu(),u=kf({rowsLookup:t,columns:r,processRowUpdate:i,onProcessRowUpdateError:l,replaceRows:c,onCommitted:a.emit}),f=Ef({rows:n,getRowId:o,columns:r,processRowUpdate:i,onProcessRowUpdateError:l,onRowChange:(p,b)=>{u.storeRow(b,p)},onCommitted:p=>a.emit(p,"edit")});return{editCommitChannel:a,batchEdit:u,editingHandlers:f}}const Lf=e=>e.id,Af={hasColSpan:!1,hasRowSpan:!1,colspanMap:new Map,rowSpanningCaches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},getSpanOrigin:()=>null,getUnpinnedColSpanRanges:()=>{},getCenterRowSpanStart:e=>e},Gl="\0",Hl="";function Bl(e){if(typeof e!="number"||Number.isNaN(e))return 1;if(e===1/0)return Number.MAX_SAFE_INTEGER;if(!Number.isFinite(e))return 1;const t=Math.floor(e);return t<1?1:t}function Pf(e){return e.map(t=>t.field).join(Gl)}function If(e){const{pinnedTopRows:t,centerRows:n,pinnedBottomRows:o,columns:r,leftPinnedColumns:i,unpinnedColumns:l,rightPinnedColumns:c,expandedRowIds:a,rowMetaMap:u,getRowId:f=Lf}=e,p=s.useMemo(()=>r.some(m=>m.colSpan!==void 0&&m.colSpan!==null),[r]),b=s.useMemo(()=>r.some(m=>m.rowSpan!==void 0&&m.rowSpan!==null),[r]),x=p||b,w=x?[i,l,c].map(Pf).join(Hl):"",g=s.useMemo(()=>{if(!w)return{columns:[],leftCount:0,unpinnedCount:0};const m=new Map(r.map(v=>[v.field,v])),C=w.split(Hl).map(v=>v?v.split(Gl):[]),y=[];let _=0;for(const v of C){_+=v.length;for(const k of v){const M=m.get(k)??{field:k};y.push({colDef:M,field:k,sectionEnd:_,hasColSpan:M.colSpan!==void 0&&M.colSpan!==null,hasRowSpan:M.rowSpan!==void 0&&M.rowSpan!==null})}}return{columns:y,leftCount:C[0].length,unpinnedCount:C[1].length}},[w,r]),h=s.useMemo(()=>{if(!x||g.columns.length===0)return null;const m={colspanMap:new Map,rowSpanningCaches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},hiddenOriginFields:new Map,unpinnedRanges:new Map,centerRowSpanStart:new Map},y={spanColumns:g,expandedRowIds:a,rowMetaMap:u,getRowId:f,warned:new Set,out:m};return cr(t,0,!1,y),cr(n,t.length,!0,y),cr(o,t.length+n.length,!1,y),m},[x,g,t,n,o,a,u,f]);return s.useMemo(()=>{if(!h)return Af;const{colspanMap:m,rowSpanningCaches:C,hiddenOriginFields:y,unpinnedRanges:_,centerRowSpanStart:v}=h,k=g.columns;return{hasColSpan:p,hasRowSpan:b,colspanMap:m,rowSpanningCaches:C,getSpanOrigin:(M,E)=>{const I=m.get(M)?.[E];if(I?.spannedByColSpan)return{rowId:M,field:k[I.leftVisibleCellIndex].field};const L=C.hiddenCellOriginMap[M]?.[E];return L===void 0?null:{rowId:L,field:y.get(M)?.[E]??E}},getUnpinnedColSpanRanges:M=>_.get(M),getCenterRowSpanStart:M=>v.get(M)??M}},[h,p,b,g])}function cr(e,t,n,o){const{spanColumns:r,expandedRowIds:i,rowMetaMap:l,getRowId:c,warned:a,out:u}=o,{columns:f,leftCount:p,unpinnedCount:b}=r,x=f.length,{colspanMap:w,rowSpanningCaches:g,hiddenOriginFields:h,unpinnedRanges:m,centerRowSpanStart:C}=u,y=new Int32Array(x),_=new Array(x),v=new Array(x),k=new Int32Array(x);let M=0;const E=[];f.forEach((N,S)=>{(N.hasColSpan||N.hasRowSpan)&&E.push(S)});const I=(N,S,F)=>{const T=f[F].field;if(Kt(g.hiddenCells,N,T,!0),Kt(g.hiddenCellOriginMap,N,T,_[F]),v[F]!==T&&Kt(h,N,T,v[F]),n){const P=C.get(S);(P===void 0||k[F]<P)&&C.set(S,k[F])}},L=(N,S,F)=>{const T=f[F],P=c(N),A=Nf(N,P,T.colDef,t+S,F,l,a);let G=1;if(T.hasColSpan){const H=Math.min(Wl(T.colDef.colSpan,A,"colSpan",T.field,a),T.sectionEnd-F);for(;G<H&&y[F+G]<=S;)G++}let z=1;if(T.hasRowSpan){z=Math.min(Wl(T.colDef.rowSpan,A,"rowSpan",T.field,a),e.length-S);for(let H=1;H<z;H++)if(je(c(e[S+H]),l)){z=H;break}if(z>1&&i&&i.size>0){for(let H=0;H<z-1;H++)if(i.has(c(e[S+H]))){z=H+1;break}}}if(G>1){Kt(w,P,T.field,{spannedByColSpan:!1,cellProps:{colSpan:G}});for(let H=1;H<G;H++){const Y=f[F+H];Kt(w,P,Y.field,{spannedByColSpan:!0,leftVisibleCellIndex:F,rightVisibleCellIndex:F+G-1})}if(F>=p&&F<p+b){let H=m.get(P);H||(H=[],m.set(P,H)),H.push(F-p,F+G-1-p)}}if(z>1){Kt(g.spannedCells,P,T.field,z);for(let H=F;H<F+G;H++)y[H]=S+z,_[H]=P,v[H]=T.field,k[H]=S;S+z>M&&(M=S+z)}return G};for(let N=0;N<e.length;N++){const S=e[N];if(!S||je(c(S),l))continue;if(M<=N){let T=0;for(const P of E)P>=T&&(T=P+L(S,N,P));continue}let F=0;for(;F<x;)y[F]>N?(I(c(S),N,F),F++):f[F].hasColSpan||f[F].hasRowSpan?F+=L(S,N,F):F++}}function Nf(e,t,n,o,r,i,l){const c=e[n.field];let a=c;if(n.valueGetter)try{a=n.valueGetter({row:e,field:n.field,value:c})}catch(u){Vl(l,`valueGetter:${n.field}`,`valueGetter for column "${n.field}" threw while computing its span`,u),a=void 0}return{row:e,value:a,field:n.field,colDef:n,rowIndex:o,colIndex:r,rowMeta:i?.get(t)}}function Wl(e,t,n,o,r){if(typeof e=="number")return Bl(e);if(typeof e!="function")return 1;try{return Bl(e(t))}catch(i){return Vl(r,`${n}:${o}`,`${n} for column "${o}" threw; the cell is rendered without a span`,i),1}}function Vl(e,t,n,o){process.env.NODE_ENV==="production"||e.has(t)||(e.add(t),console.warn(`[OpenGridX] ${n}.`,o))}function Kt(e,t,n,o){if(e instanceof Map){let i=e.get(t);i||(i={},e.set(t,i)),i[n]=o;return}let r=e[t];r||(r={},e[t]=r),r[n]=o}function Ff(e,t){const{draggedColumn:n,onDragOver:o,onDrop:r,onDragEnd:i}=t,l=s.useMemo(()=>{if(!e||e.length===0)return null;const c=a=>n===null||Qo(e,n,a);return{onDragOver:o&&(a=>c(a)?o(a):()=>{}),onDrop:r&&(a=>c(a)?r(a):u=>{u.preventDefault(),i?.()})}},[e,n,o,r,i]);return l?{...t,...l}:t}function zl({dataSource:e,paginationMode:t,sortingMode:n,filterMode:o}){return!!e&&(t==="server"||t==="infinite"||n==="server"||o==="server")}const Rl=Number.MAX_SAFE_INTEGER,Tf="An unexpected error occurred while loading the data.";function Ul(e){return typeof e=="string"&&e?e:typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"&&e.message?e.message:Tf}const Of=300,Kl=e=>e.id;function Df(e,t){return e==="infinite"?"infinite":e==="server"?t?"all":"page":"all"}function jl(e,t){const n=new Set,o=[];return e.forEach(r=>{const i=t(r);n.has(i)||(n.add(i),o.push({id:i,row:r}))}),o}function ql(e,t,n){const o=new Set(e.map(n)),r=t.filter(i=>!o.has(i.id)).map(i=>i.row);return r.length===0?e:[...e,...r]}function $f(e){const{dataSource:t,sortModel:n,filterModel:o,paginationModel:r,paginationMode:i,sortingMode:l,filterMode:c,aggregationModel:a,rowGroupingActive:u=!1}=e,f=Df(i,u),p=!!t&&i==="server"&&u,b=s.useRef(!1);s.useEffect(()=>{process.env.NODE_ENV==="production"||b.current||!p||(b.current=!0,console.warn("[OpenGridX] `rowGroupingModel` turns pagination off, so the dataSource with `paginationMode: 'server'` is asked for every row (startRow 0, endRow Number.MAX_SAFE_INTEGER) instead of one page. See docs/features/data-source.md."))},[p]);const x=t?.getRows,w=zl({dataSource:t,paginationMode:i,sortingMode:l,filterMode:c}),g=JSON.stringify([f,f!=="all"||l==="server"?n:null,f!=="all"||c==="server"?o:null,w?a??null:null,f==="all"?null:r.pageSize]),h=f==="all"?0:r.page,m=f==="all"?0:r.pageSize,C=s.useRef({params:e,kind:f});s.useLayoutEffect(()=>{C.current={params:e,kind:f}});const y=s.useRef(0),_=s.useRef(0),v=s.useRef(null),k=s.useRef({page:0,loadedEnd:0,inFlightEnd:null}),M=s.useRef(null),E=s.useRef(!1),I=s.useRef(0),L=s.useRef(!1),N=s.useRef(new Set),S=s.useCallback(()=>{const Y=E.current||I.current>0;Y!==L.current&&(L.current=Y,C.current.params.setDataSourceLoading(Y))},[]),F=s.useCallback(()=>{M.current!==null&&(clearTimeout(M.current),M.current=null)},[]),T=s.useCallback(()=>{y.current++,k.current.inFlightEnd=null,E.current=!1},[]),P=s.useCallback(()=>{_.current++,N.current.clear(),I.current=0},[]),A=s.useCallback(async()=>{const{params:Y,kind:K}=C.current,re=Y.dataSource;if(!re)return!1;const R=k.current,te=Y.paginationModel.pageSize;let ie,ce;if(K==="infinite"){if(R.inFlightEnd!==null)return!1;if(ie=R.loadedEnd,ce=(R.page+1)*te,ce<=ie)return E.current=!1,S(),!1;R.inFlightEnd=ce}else K==="page"?(ie=Y.paginationModel.page*te,ce=ie+te):(ie=0,ce=Rl);const J=++y.current;E.current=!0,S(),Y.setDataSourceError(null);let se;try{se=await re.getRows({startRow:ie,endRow:ce,sortModel:Y.sortModel,filterModel:Y.filterModel,groupKeys:[],aggregationModel:Y.aggregationModel})}catch(ne){return J!==y.current||(R.inFlightEnd=null,E.current=!1,C.current.params.setDataSourceError(ne),console.error("Data Source Error:",ne),S()),!1}if(J!==y.current)return!1;try{const{params:ne}=C.current,j=ne.getRowId??Kl,B=jl(se.rows,j);if(K==="infinite"&&ie>0?ne.setRows(W=>ql(W,B,j),!0):(ne.setRows(B.map(W=>W.row),!0),P()),se.aggregationResults&&ne.onAggregationResults?.(se.aggregationResults),se.rowCount!==void 0&&ne.setRowCount(se.rowCount),K==="infinite"&&(R.inFlightEnd=null,R.loadedEnd=ie+se.rows.length,se.rows.length>=ce-ie&&(R.page+1)*te>ce))return!0}catch(ne){return R.inFlightEnd=null,E.current=!1,C.current.params.setDataSourceError(ne),console.error("Data Source Error:",ne),S(),!1}return E.current=!1,S(),!1},[S,P]),G=s.useCallback(async()=>{for(;await A(););},[A]);s.useLayoutEffect(()=>{if(!x){v.current&&(v.current=null,F(),T(),P(),C.current.params.setDataSourceError(null),S());return}const Y=v.current,K=k.current;if(!Y||Y.key!==g||Y.getRows!==x){v.current={key:g,getRows:x},T(),P();const re=f==="infinite"&&Y!==null&&h!==0;if(K.page=re?0:h,K.loadedEnd=0,re){const{params:R}=C.current;R.onPaginationModelChange?.({...R.paginationModel,page:0})}}else f==="infinite"?(h<K.page&&(T(),K.loadedEnd=0),K.page=h):T();if(f==="infinite"){const re=K.inFlightEnd!==null;if(re||(K.page+1)*m<=K.loadedEnd){E.current=re,S();return}}return E.current=!0,S(),M.current=setTimeout(()=>{M.current=null,G()},Of),F},[x,g,f,h,m,F,T,P,S,G]),s.useEffect(()=>()=>{T(),P()},[T,P]);const z=s.useCallback(()=>(F(),G()),[F,G]),H=s.useCallback(async(Y,K,re)=>{const{params:R}=C.current,te=R.dataSource;if(!te)return;const ie=JSON.stringify(K),ce=N.current;if(ce.has(ie))return;const J=_.current;ce.add(ie),I.current++,S();try{const se=await te.getRows({startRow:0,endRow:Rl,sortModel:R.sortModel,filterModel:R.filterModel,groupKeys:K,aggregationModel:R.aggregationModel});if(J!==_.current)return;if(se.rows.length>0){const{params:ne}=C.current,j=ne.getRowId??Kl,B=jl(se.rows,j);ne.setRows(W=>ql(W,B,j),!0)}}catch(se){if(J!==_.current)return;ce.delete(ie),console.error("Failed to fetch children:",se),re?.(se)}finally{J===_.current&&(I.current--,S())}},[S]);return{fetchRows:z,fetchChildren:H}}function Gf(e){return(e.serverChildrenCount??0)>0&&(e.children?.length??0)===0}function Hf({enabled:e,treeNodes:t,isGroupExpanded:n,getNodePath:o,toggleExpansion:r,fetchChildren:i}){const l=s.useRef({isGroupExpanded:n,toggleExpansion:r});s.useLayoutEffect(()=>{l.current={isGroupExpanded:n,toggleExpansion:r}}),s.useEffect(()=>{e&&t.forEach((c,a)=>{!Gf(c)||!n(a)||i(a,o(a),()=>{const{isGroupExpanded:u,toggleExpansion:f}=l.current;u(a)&&f(a)})})},[e,t,n,o,i])}const Xl={};function Bf(e){const t=JSON.stringify(e),[n,o]=s.useState(null),r=s.useCallback(i=>o({modelKey:t,results:i}),[t]);return[n&&n.modelKey===t?n.results:null,r]}function Yl(e){const{rows:t,columns:n,aggregationModel:o,isServerSide:r,dataSource:i,filterModel:l,sortModel:c,serverAggregationResults:a}=e,u=Object.keys(o).length>0,f=s.useMemo(()=>{const v=new Map;return(n??[]).forEach(k=>v.set(k.field,k)),v},[n]),p=s.useMemo(()=>r||!u?Xl:Fn(t,o,f,"useAggregation"),[t,f,o,r,u]),b=JSON.stringify([o,l??null,c??[]]),x=r&&u&&!!i?.getAggregations&&!a,w=s.useRef({aggregationModel:o,filterModel:l,sortModel:c});s.useEffect(()=>{w.current={aggregationModel:o,filterModel:l,sortModel:c}});const[g,h]=s.useState(null);s.useEffect(()=>{const v=i?.getAggregations;if(!x||!v)return;let k=!1;const M=w.current,E={sortModel:M.sortModel??[],filterModel:M.filterModel??{items:[]},groupKeys:[],aggregationModel:M.aggregationModel};let I;try{I=Promise.resolve(v(E))}catch(L){I=Promise.reject(L)}return I.then(L=>{k||h({key:b,result:L,error:null})},L=>{k||(console.error("[useAggregation] Server aggregation error:",L),h({key:b,result:null,error:L}))}),()=>{k=!0}},[x,i,b]);const m=g&&g.key===b?g:null,C=x&&m===null,y=x?m?.error??null:null;return{aggregationResult:s.useMemo(()=>r?a&&Object.keys(a).length>0?a:m?.result??Xl:p,[r,p,a,m]),isLoading:C,error:y}}const Wf={items:[]},Vf=[];function zf(e){const{rows:t,columns:n,pivotMode:o,pivotModel:r,filterModel:i,sortModel:l,hasDataSource:c,hierarchyRequested:a}=e,u=o&&!c,f=s.useMemo(()=>new Set(n.map(m=>m.field)),[n]),p=s.useMemo(()=>Fo(n),[n]),b=s.useMemo(()=>cc(i,f),[i,f]),x=s.useMemo(()=>u?Lo(t,b.source,p):t,[u,t,b.source,p]),w=s.useMemo(()=>u?Ei(x,n,r,{outputFilterModel:b.output,sortModel:l}):Oo,[u,x,n,r,b.output,l]),g=u&&w.isValid,h=s.useRef({dataSource:!1,hierarchy:!1});return s.useEffect(()=>{process.env.NODE_ENV!=="production"&&(o&&c&&!h.current.dataSource&&(h.current.dataSource=!0,console.warn("[OpenGridX] `pivotMode` is ignored when a `dataSource` is set: pivoting is client-side and the grid only holds the rows of one server page. Pivot on the server, or pass the full dataset as `rows`.")),g&&a&&!h.current.hierarchy&&(h.current.hierarchy=!0,console.warn("[OpenGridX] `treeData` and `rowGroupingModel` are turned off while `pivotMode` is active: the pivot rows are already grouped by the pivot row fields.")))},[o,c,g,a]),{isActive:g,rows:g?w.pivotRows:t,columns:g?w.pivotColumns:n,pipelineFilterModel:g?Wf:i,pipelineSortModel:g?Vf:l}}function Jl(e,t,n=1){if(Object.is(e,t))return!0;if(!e||!t||typeof e!="object"||typeof t!="object"||Array.isArray(e)||Array.isArray(t))return!1;const o=e,r=t,i=Object.keys(o);return i.length!==Object.keys(r).length?!1:i.every(l=>Object.prototype.hasOwnProperty.call(r,l)&&(Object.is(o[l],r[l])||n>0&&Jl(o[l],r[l],n-1)))}function Rf(e){const[t,n]=s.useState(e);return t!==e&&!Jl(t,e)?(n(e),e):t}const Zl=s.createContext(null);function Uf(e){if(typeof e!="function")return!1;const t=e.prototype;return!(typeof t=="object"&&t!==null&&"isReactComponent"in t)}function Kf({render:e,toolbarProps:t}){"use no memo";return d.jsx(d.Fragment,{children:e(t)})}function jf({component:e,toolbarProps:t}){if(Uf(e))return d.jsx(Kf,{render:e,toolbarProps:t},`fn:${e.toString()}`);const n=e;return d.jsx(n,{...t})}const et=({variant:e="text",size:t="medium",color:n="default",disabled:o=!1,className:r="",type:i="button",children:l,...c})=>{const a=["ogx-button",`ogx-button--${e}`,`ogx-button--${t}`,`ogx-button--${n}`,o&&"ogx-button--disabled",r].filter(Boolean).join(" ");return d.jsx("button",{type:i,className:a,disabled:o,...c,children:l})},tt=s.forwardRef(function({fullWidth:t=!1,error:n=!1,startAdornment:o,endAdornment:r,className:i="",inputClassName:l="",variant:c="field",...a},u){const f=["ogx-input-wrapper",c==="cell"&&"ogx-input-wrapper--cell",t&&"ogx-input-wrapper--full-width",n&&"ogx-input-wrapper--error",a.disabled&&"ogx-input-wrapper--disabled",i].filter(Boolean).join(" "),p=["ogx-input",l].filter(Boolean).join(" ");return d.jsxs("div",{className:f,children:[o&&d.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--start",children:o}),d.jsx("input",{ref:u,className:p,"aria-invalid":n?!0:void 0,...a}),r&&d.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--end",children:r})]})});tt.displayName="Input";function qf(){if(typeof window>"u")return null;const e=window;return e.SpeechRecognition??e.webkitSpeechRecognition??null}function Xf(e){const[t,n]=s.useState(!1),o=s.useRef(null),r=s.useRef(e);s.useLayoutEffect(()=>{r.current=e}),s.useEffect(()=>()=>{const l=o.current;o.current=null,l&&ze(()=>l.abort())},[]);const i=s.useCallback(()=>{const l=o.current;if(l){ze(()=>l.stop());return}const c=qf();if(!c)return;const a=ze(()=>new c);if(!a.ok)return;const u=a.value;u.lang=typeof navigator>"u"?"en-US":navigator.language,u.interimResults=!1,u.maxAlternatives=1,u.onresult=p=>{const b=p.results[0],x=b&&b[0]?b[0].transcript:"";x&&r.current(x)};const f=()=>{o.current===u&&(o.current=null),n(!1)};u.onend=f,u.onerror=f,o.current=u,n(!0),ze(()=>u.start()).ok||f()},[]);return{listening:t,toggle:i}}function Ql(){return d.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:[d.jsx("path",{d:"M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9z"}),d.jsx("path",{d:"M19 15l.8 2.2L22 18l-2.2.8L19 21l-.8-2.2L16 18l2.2-.8z"})]})}function Yf(){return d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",focusable:"false",children:[d.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),d.jsx("path",{d:"M5 11a7 7 0 0 0 14 0M12 18v3"})]})}function Jf(e){const{status:t,statusText:n,message:o,errors:r,chips:i,history:l,suggestions:c,placeholder:a,voiceAvailable:u,canUndo:f,submit:p,stop:b,undo:x,removeChip:w,close:g}=e,h=Le(),[m,C]=s.useState(""),y=s.useRef(null),_=Xf(C),v=t==="running";s.useEffect(()=>{y.current&&y.current.focus()},[]);const k=I=>{C(I),p(I)},M=I=>()=>{I(),y.current&&y.current.focus()},E=I=>{I.preventDefault(),v||p(m)};return d.jsxs("div",{className:"ogx-ai-panel",role:"dialog","aria-label":h.aiAssistantTitle,children:[d.jsxs("div",{className:"ogx-ai-panel__header",children:[d.jsxs("span",{className:"ogx-ai-panel__title",children:[d.jsx(Ql,{}),h.aiAssistantTitle]}),d.jsx(et,{size:"small",className:"ogx-ai-panel__close","aria-label":h.aiAssistantClose,onClick:g,children:"×"})]}),d.jsxs("form",{className:"ogx-ai-panel__form",onSubmit:E,children:[d.jsx(tt,{ref:y,className:"ogx-ai-panel__input",value:m,placeholder:a,"aria-label":h.aiAssistantPromptLabel,autoComplete:"off",onChange:I=>C(I.target.value)}),u&&d.jsx(et,{size:"small",variant:"outlined",className:`ogx-ai-panel__mic${_.listening?" ogx-ai-panel__mic--on":""}`,"aria-label":_.listening?h.aiAssistantStopDictation:h.aiAssistantStartDictation,"aria-pressed":_.listening,onClick:_.toggle,children:d.jsx(Yf,{})}),v?d.jsx(et,{size:"small",variant:"outlined",onClick:M(b),children:h.aiAssistantStop},"stop"):d.jsx(et,{size:"small",variant:"contained",color:"primary",type:"submit",disabled:m.trim()==="",children:h.aiAssistantAsk},"ask")]}),c.length>0&&d.jsx("div",{className:"ogx-ai-panel__suggestions","aria-label":h.aiAssistantSuggestions,role:"group",children:c.map(I=>d.jsx("button",{type:"button",className:"ogx-ai-panel__suggestion",disabled:v,onClick:()=>k(I),children:I},I))}),n&&d.jsx("div",{className:`ogx-ai-panel__status ogx-ai-panel__status--${t}`,children:n}),o&&d.jsx("p",{className:"ogx-ai-panel__message",children:o}),(i.length>0||f)&&d.jsxs("div",{className:"ogx-ai-panel__changes",children:[d.jsx("ul",{className:"ogx-ai-panel__chips","aria-label":h.aiAssistantAppliedChanges,children:i.map(I=>d.jsxs("li",{className:"ogx-ai-chip","data-part":I.part,children:[d.jsx("span",{className:"ogx-ai-chip__label",children:I.label}),d.jsx("button",{type:"button",className:"ogx-ai-chip__remove","aria-label":h.aiAssistantRemoveChange(I.label),onClick:M(()=>w(I.id)),children:"×"})]},I.id))}),f&&d.jsx(et,{size:"small",variant:"outlined",className:"ogx-ai-panel__undo",onClick:M(x),children:h.aiAssistantUndo})]}),r.length>0&&d.jsx("ul",{className:"ogx-ai-panel__errors","aria-label":h.aiAssistantIgnored,children:r.map((I,L)=>d.jsx("li",{children:I.path?h.aiAssistantIgnoredItem(I.message):I.message},`${I.path}:${L}`))}),l.length>0&&d.jsxs("div",{className:"ogx-ai-panel__history",children:[d.jsx("div",{className:"ogx-ai-panel__history-title",children:h.aiAssistantEarlier}),d.jsx("ul",{children:l.map((I,L)=>d.jsx("li",{children:d.jsx("button",{type:"button",className:"ogx-ai-panel__history-item",onClick:()=>C(I.prompt),children:I.prompt})},`${L}:${I.prompt}`))})]})]})}function Zf({panelProps:e,slot:t,slotProps:n}){const o=r=>{r.key==="Escape"&&(r.stopPropagation(),e.close())};return d.jsx("div",{className:"ogx-ai-anchor",onKeyDown:o,children:t?d.jsx(t,{...e,...n}):d.jsx(Jf,{...e})})}function es(e,t){typeof e=="function"?e(t):e&&(e.current=t)}const gt=s.forwardRef(function({indeterminate:t=!1,label:n,className:o="",inputClassName:r="",inputRef:i,...l},c){const a=s.useRef(null),u=s.useCallback(p=>{a.current=p,es(i,p),es(c,p)},[i,c]);s.useEffect(()=>{a.current&&(a.current.indeterminate=t)},[t]);const f=["ogx-checkbox-wrapper",l.disabled&&"ogx-checkbox-wrapper--disabled",o].filter(Boolean).join(" ");return d.jsxs("label",{className:f,children:[d.jsx("input",{ref:u,type:"checkbox",className:["ogx-checkbox__input",r].filter(Boolean).join(" "),...l}),d.jsxs("span",{className:"ogx-checkbox__box",children:[l.checked&&!t&&d.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:d.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})}),t&&d.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:d.jsx("path",{d:"M19 13H5v-2h14v2z"})})]}),n&&d.jsx("span",{className:"ogx-checkbox__label",children:n})]})});gt.displayName="Checkbox";function Qf(){return d.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("circle",{cx:"11",cy:"11",r:"8"}),d.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function eg(){return d.jsxs("svg",{className:"ogx-column-visibility-panel__drag-handle",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[d.jsx("circle",{cx:"9",cy:"5",r:"1.5"}),d.jsx("circle",{cx:"15",cy:"5",r:"1.5"}),d.jsx("circle",{cx:"9",cy:"12",r:"1.5"}),d.jsx("circle",{cx:"15",cy:"12",r:"1.5"}),d.jsx("circle",{cx:"9",cy:"19",r:"1.5"}),d.jsx("circle",{cx:"15",cy:"19",r:"1.5"})]})}function dr(e){const{columns:t,visibleColumns:n,onVisibilityChange:o,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:c,showNonHideableColumns:a}=e,u=Le(),[f,p]=s.useState(""),b=s.useId(),[x,w]=s.useState(null),g=s.useRef(null),h=s.useMemo(()=>t.filter(I=>I.hideable!==!1),[t]),m=h.every(I=>n.has(I.field)),C=s.useMemo(()=>{const I=a?t:h;if(!f)return I;const L=f.toLowerCase();return I.filter(N=>(N.headerName||N.field).toLowerCase().includes(L))},[t,h,f,a]),y=I=>{I.target.checked?r():i()},_=I=>L=>{g.current=I,L.dataTransfer.effectAllowed="move",L.dataTransfer.setDragImage(L.currentTarget.closest(".ogx-column-visibility-panel__item"),20,20)},v=I=>L=>{L.preventDefault(),L.dataTransfer.dropEffect="move",I!==g.current&&w(I)},k=()=>{w(null)},M=I=>L=>{L.preventDefault();const N=g.current;w(null),g.current=null,N&&N!==I&&l&&l(N,I)},E=()=>{w(null),g.current=null};return d.jsxs("div",{className:"ogx-column-visibility-panel",children:[d.jsx("div",{className:"ogx-column-visibility-panel__search-section",children:d.jsxs("div",{className:"ogx-column-visibility-panel__search-container",children:[d.jsx(Qf,{}),d.jsx(tt,{autoComplete:"off",inputClassName:"ogx-column-visibility-panel__search-input",placeholder:u.columnsPanelSearchPlaceholder,value:f,onChange:I=>p(I.target.value)})]})}),d.jsx("div",{className:"ogx-column-visibility-panel__list",children:C.map((I,L)=>{const N=`${b}-col-${L}`,S=n.has(I.field),F=I.hideable!==!1,T=x===I.field,P=!!l&&!f;return d.jsxs("div",{className:["ogx-column-visibility-panel__item",!F&&"ogx-column-visibility-panel__item--disabled",T&&"ogx-column-visibility-panel__item--drag-over"].filter(Boolean).join(" "),draggable:P,onDragOver:P?v(I.field):void 0,onDragLeave:P?k:void 0,onDrop:P?M(I.field):void 0,onDragEnd:P?E:void 0,children:[P&&d.jsx("span",{className:"ogx-column-visibility-panel__drag-handle-wrapper",draggable:!0,onDragStart:_(I.field),title:u.columnsPanelDragToReorder,children:d.jsx(eg,{})}),d.jsxs("div",{className:"ogx-column-visibility-panel__item-label",style:{display:"flex",alignItems:"center",gap:"var(--ogx-spacing-md)",flex:1,cursor:F?"pointer":"not-allowed"},children:[d.jsx(gt,{id:N,checked:S,onChange:A=>o(I.field,A.target.checked),disabled:!F}),d.jsx("label",{htmlFor:N,className:"ogx-column-visibility-panel__label",children:I.headerName||I.field})]})]},I.field)})}),d.jsxs("div",{className:"ogx-column-visibility-panel__footer",children:[d.jsxs("div",{className:"ogx-column-visibility-panel__item",children:[d.jsx(gt,{id:`${b}-all`,checked:m,onChange:y}),d.jsx("label",{htmlFor:`${b}-all`,className:"ogx-column-visibility-panel__label",children:u.columnsPanelShowHideAll})]}),d.jsx("button",{type:"button",className:"ogx-column-visibility-panel__reset-btn",onClick:()=>{r(),c?.()},children:u.columnsPanelReset})]})]})}function Lt(){return document.documentElement.clientWidth||window.innerWidth}function ts(){return document.documentElement.clientHeight||window.innerHeight}function tg({isOpen:e,containerRef:t,panelRef:n,columns:o,columnVisibilityModel:r,disableColumnReorder:i,onClose:l,onColumnVisibilityChange:c,onColumnMove:a,onColumnOrderReset:u,columnGroupingModel:f}){const p=Le(),[b,x]=s.useState(null);if(s.useLayoutEffect(()=>{if(!e||!t.current)return;const g=t.current.getBoundingClientRect();x({top:g.top+8,right:Lt()-g.right+8,target:t.current.closest(".ogx-theme-provider")||document.body})},[e,t]),!e||!b)return null;const w=i?void 0:(g,h)=>{Qo(f,g,h)&&a(g,h)};return at.createPortal(d.jsxs("div",{ref:n,style:{position:"fixed",top:b.top,right:b.right,zIndex:9999,display:"inline-block"},children:[d.jsx("button",{type:"button",onClick:l,style:{position:"absolute",top:-12,right:-12,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",background:"#334155",color:"#fff",border:"none",borderRadius:"50%",cursor:"pointer",fontSize:14,lineHeight:1,zIndex:1,boxShadow:"0 1px 4px rgba(0,0,0,0.2)"},"aria-label":p.columnsPanelClose,children:"×"}),d.jsx(dr,{columns:o,visibleColumns:new Set(o.filter(g=>r[g.field]!==!1).map(g=>g.field)),onVisibilityChange:(g,h)=>{c({...r,[g]:h})},onShowAll:()=>{const g={...r};o.forEach(h=>{h.hideable!==!1&&(g[h.field]=!0)}),c(g)},onHideAll:()=>{const g={...r};o.forEach(h=>{h.hideable!==!1&&(g[h.field]=!1)}),c(g)},onColumnReorder:w,onColumnOrderReset:i?void 0:u})]}),b.target)}function ur(e){const t=s.useId(),n=Le(),{page:o,pageSize:r,rowCount:i,onPageChange:l,onPageSizeChange:c,pageSizeOptions:a=[10,25,50,100],showFirstButton:u=!0,showLastButton:f=!0,localeText:p}=e,b=zn(r),x=Bo(i,b),w=zi(o,x),g=a.includes(b)?a:[...a,b].sort((S,F)=>S-F),h=w*b,m=Math.min(h+b,i),C=p?.paginationRowsPerPage??n.paginationRowsPerPage,y=(p?.paginationOf??n.paginationOf)(i===0?0:h+1,m,i),_=(p?.paginationPage??n.paginationPage)(w+1,x),v=()=>{l(0)},k=()=>{l(Math.max(0,w-1))},M=()=>{l(Math.min(x-1,w+1))},E=()=>{l(x-1)},I=S=>{const F=parseInt(S.target.value,10);c(F)},L=w===0,N=w>=x-1;return d.jsxs("div",{className:"ogx-pagination",role:"navigation","aria-label":n.paginationLabel,children:[d.jsxs("div",{className:"ogx-pagination__page-size",children:[d.jsx("label",{htmlFor:t,className:"ogx-pagination__label",children:C}),d.jsx("select",{id:t,className:"ogx-pagination__select",value:b,onChange:I,children:g.map(S=>d.jsx("option",{value:S,children:S},S))})]}),d.jsx("div",{className:"ogx-pagination__info","aria-live":"polite","aria-atomic":"true",children:y}),d.jsxs("div",{className:"ogx-pagination__actions",children:[u&&d.jsx(et,{variant:"text",size:"small",onClick:v,disabled:L,"aria-label":n.paginationFirstPageLabel,title:n.paginationFirstPageTooltip,children:d.jsx("svg",{className:"ogx-pagination__icon",width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:d.jsx("path",{d:"M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"})})}),d.jsx(et,{variant:"text",size:"small",onClick:k,disabled:L,"aria-label":n.paginationPreviousPageLabel,title:n.paginationPreviousPageTooltip,children:d.jsx("svg",{className:"ogx-pagination__icon",width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:d.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),d.jsx("div",{className:"ogx-pagination__page-info","aria-current":"page",children:_}),d.jsx(et,{variant:"text",size:"small",onClick:M,disabled:N,"aria-label":n.paginationNextPageLabel,title:n.paginationNextPageTooltip,children:d.jsx("svg",{className:"ogx-pagination__icon",width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:d.jsx("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})})}),f&&d.jsx(et,{variant:"text",size:"small",onClick:E,disabled:N,"aria-label":n.paginationLastPageLabel,title:n.paginationLastPageTooltip,children:d.jsx("svg",{className:"ogx-pagination__icon",width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:d.jsx("path",{d:"M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z"})})})]})]})}function ng({row:e,rowId:t,rowIndex:n,ariaRowIndex:o,listViewColumn:r,gridColumn:i,rowMeta:l,isSelected:c=!1,checkboxSelection:a=!1,rowHeight:u,onRowClick:f,onRowDoubleClick:p,onSelectionChange:b,tabIndex:x=-1,onFocus:w,onToggleExpansion:g}){const h=t??e.id,m=r.field,C=Me(e,m,i),y=wo(e,m,C,i)??An(C,i),_=l?.isGroupRow===!0||je(h),v={row:e,value:C,formattedValue:y,field:m,colDef:i??r,rowIndex:n,colIndex:0,rowMeta:l},k=Le(),M=E=>{E.stopPropagation(),b?.(h,E.target.checked)};return d.jsxs("div",{className:`ogx-list-view__row${c?" ogx-list-view__row--selected":""}`,style:u?{minHeight:u}:void 0,onClick:()=>f?.(e),onDoubleClick:p?()=>p(e):void 0,role:"row","aria-rowindex":o??n+1,"aria-selected":c,"aria-level":l?.treeDepth!==void 0?l.treeDepth+1:void 0,"aria-expanded":l?.hasChildren?l.isExpanded===!0:void 0,"data-rowindex":n,tabIndex:x,onFocus:w?E=>{E.target===E.currentTarget&&w(n)}:void 0,children:[a&&d.jsx("div",{className:"ogx-list-view__checkbox",onClick:E=>E.stopPropagation(),children:!_&&d.jsx(gt,{checked:c,onChange:M,"aria-label":k.rowSelectLabel(h),tabIndex:-1})}),l&&g&&d.jsx("div",{className:"ogx-list-view__expand",style:{paddingInlineStart:(l.treeDepth??0)*16},onClick:E=>E.stopPropagation(),onDoubleClick:E=>E.stopPropagation(),children:l.hasChildren&&d.jsx(Xo,{isExpanded:l.isExpanded===!0,onClick:()=>g(h),tabIndex:-1})}),d.jsx("div",{className:"ogx-list-view__cell",role:"gridcell",children:d.jsx(Et,{field:m,resetKey:e,renderFn:()=>{const E=r.renderCell(v);return E===void 0&&_?l?.groupLabel:E}})})]})}function og(e,t){const n=s.useRef(!0),o=s.useRef(e);s.useEffect(()=>{o.current=e},[e]),s.useEffect(()=>{n.current=!0},[t]);const r=s.useCallback(i=>{const l=Pl(i.currentTarget);if(!l){n.current=!0;return}if(!n.current)return;const c=o.current;c&&(n.current=!1,c(l))},[]);return e?r:void 0}const rg=e=>e.id;function ig({ariaLabel:e,allRenderableRows:t,dataRowCount:n,pinnedTopRowCount:o,pinnedBottomRowCount:r,unpinnedRowCount:i,pagination:l,effectivePaginationModel:c,currentPage:a,pageSizeOptions:u,selectedRowIds:f,listViewColumn:p,columnsByField:b,rowMetaMap:x,noRowsLabel:w,rowHeight:g,checkboxSelection:h,paginationMode:m,serverRowCount:C,paginationSlot:y,paginationSlotProps:_,localeText:v,onRowClick:k,onRowDoubleClick:M,onSelectionChange:E,onPaginationModelChange:I,onRowsScrollEnd:L,getRowId:N=rg,multiselectable:S=!1,loading:F=!1,loadingOverlay:T,noRowsOverlay:P,showPaginationControls:A=!0,selectable:G=!1,onToggleExpansion:z}){const H=Le(),Y=y||ur,K=s.useRef(null),[re,R]=s.useState(null),te=re===null?-1:t.findIndex(O=>N(O)===re),ie=te===-1?0:te,ce=O=>{const $=t[O];$&&(R(N($)),K.current?.querySelector(`:scope > [role="row"][data-rowindex="${O}"]`)?.focus())},J=O=>{const $=O.target;if($.getAttribute("role")!=="row"||$.parentElement!==K.current)return;const D=Number($.getAttribute("data-rowindex")),V=t[D];if(!V)return;const q=N(V),oe=t.length-1,Z=x.get(q),X=!!(Z?.hasChildren&&z);if(O.altKey&&(O.key==="ArrowRight"||O.key==="ArrowLeft")){O.preventDefault();const le=Pn(O.key,Ye(O.currentTarget))==="ArrowRight";X&&le!==(Z?.isExpanded===!0)&&z?.(q);return}switch(O.key){case"ArrowDown":O.preventDefault(),ce(Math.min(D+1,oe));return;case"ArrowUp":O.preventDefault(),ce(Math.max(D-1,0));return;case"Home":O.preventDefault(),ce(0);return;case"End":O.preventDefault(),ce(oe);return;case"PageDown":O.preventDefault(),ce(Math.min(D+10,oe));return;case"PageUp":O.preventDefault(),ce(Math.max(D-10,0));return;case"Enter":case" ":if(O.preventDefault(),O.key===" "&&O.shiftKey){G&&!Z?.isGroupRow&&E(q,!f.has(q));return}X?z?.(q):k({row:V,id:q,rowIndex:D});return}},se=m==="server",ne=se?C||0:i,j=se?C||0:n,B=zn(c.pageSize),W=Bo(ne,B),ae=l?a*B:0,fe=t.length-o-r,Q=O=>{if(O<o)return O+1;const $=O-o;return $<fe?o+ae+$+1:o+ne+($-fe)+1},U=og(L,t.length);return d.jsxs("div",{className:"ogx-list-view",role:"grid","aria-label":e||H.listViewLabel,"aria-rowcount":j,"aria-multiselectable":S,children:[d.jsx("div",{className:"ogx-list-view__toolbar",children:d.jsxs("span",{children:[H.listViewItemCount(j),l?` · ${H.listViewPage(a+1,W)}`:"",f.size>0?` · ${H.listViewSelectedCount(f.size)}`:""]})}),d.jsx("div",{className:"ogx-list-view__rows",tabIndex:-1,onScroll:U,onKeyDown:J,ref:K,children:t.length===0&&F?d.jsx("div",{className:"ogx-list-view__loading",children:T??d.jsx("div",{className:"ogx__loading-bar",role:"progressbar","aria-label":H.loadingLabel})}):t.length===0&&P?d.jsx("div",{className:"ogx-list-view__empty",children:P}):t.length===0?d.jsxs("div",{className:"ogx-list-view__empty",children:[d.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[d.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),d.jsx("path",{d:"M3 9h18M9 21V9"})]}),w]}):t.map((O,$)=>{const D=N(O);return d.jsx(ng,{row:O,rowId:D,rowIndex:$,ariaRowIndex:Q($),listViewColumn:p,gridColumn:b.get(p.field),rowMeta:x.get(D),isSelected:f.has(D),checkboxSelection:h,rowHeight:g,onRowClick:V=>k({row:V,id:D,rowIndex:$}),onRowDoubleClick:M?V=>M({row:V,id:D,rowIndex:$}):void 0,onSelectionChange:E,tabIndex:$===ie?0:-1,onToggleExpansion:z,onFocus:V=>R(N(t[V]))},D)})}),l&&A&&d.jsx(Y,{page:a,pageSize:c.pageSize,rowCount:ne,pageSizeOptions:u,onPageChange:O=>I({...c,page:O}),onPageSizeChange:O=>I({...c,pageSize:O,page:0}),localeText:v,..._})]})}const lg=16;function sg(e){e.preventDefault(),e.stopPropagation()}function ag(){const e=t=>{t.stopPropagation(),t.preventDefault()};window.addEventListener("click",e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener("click",e,{capture:!0}),0)}function cg(e){const{field:t,currentWidth:n,onResize:o,onAutosize:r,minWidth:i,maxWidth:l,edge:c="end"}=e,a=Le(),[u,f]=s.useState(!1),p=s.useRef(null);s.useEffect(()=>()=>{p.current=null},[]);const b=s.useCallback((y,_)=>{const v=(_-y.startX)*(y.rtl?-1:1),k=y.startWidth+(c==="start"?-v:v);return ar(k,y.startWidth,i,l)},[c,i,l]),x=s.useCallback(y=>{if(y.button===0){y.stopPropagation(),p.current={pointerId:y.pointerId,startX:y.clientX,startWidth:n,rtl:Ye(y.currentTarget),lastUpdate:0,moved:!1},f(!0);try{y.currentTarget.setPointerCapture(y.pointerId)}catch{}}},[n]),w=s.useCallback(y=>{const _=p.current;if(!_||y.pointerId!==_.pointerId||(y.clientX!==_.startX&&(_.moved=!0),!_.moved))return;const v=Date.now();v-_.lastUpdate>=lg&&(_.lastUpdate=v,o(t,b(_,y.clientX)))},[t,o,b]),g=s.useCallback((y,_)=>{const v=p.current;if(!(!v||y.pointerId!==v.pointerId)){if(p.current=null,f(!1),y.currentTarget.hasPointerCapture?.(y.pointerId))try{y.currentTarget.releasePointerCapture(y.pointerId)}catch{}(v.moved||y.clientX!==v.startX)&&(ag(),_&&o(t,b(v,y.clientX)))}},[t,o,b]),h=s.useCallback(y=>{if(y.key==="Enter"&&r){y.preventDefault(),y.stopPropagation(),r(t);return}if(y.key!=="ArrowLeft"&&y.key!=="ArrowRight")return;y.preventDefault(),y.stopPropagation();const _=Pn(y.key,Ye(y.currentTarget)),v=(y.shiftKey?50:10)*(_==="ArrowRight"?1:-1);o(t,ar(n+v,n,i,l))},[t,n,o,r,i,l]),m=s.useCallback(y=>{y.preventDefault(),y.stopPropagation(),r?.(t)},[t,r]),C=["ogx-column-resize-handle",c==="start"&&"ogx-column-resize-handle--start",u&&"ogx-column-resize-handle--dragging"].filter(Boolean).join(" ");return d.jsx("div",{className:C,onPointerDown:x,onMouseDown:sg,onPointerMove:w,onPointerUp:y=>g(y,!0),onPointerCancel:y=>g(y,!1),onClick:y=>y.stopPropagation(),onDragStart:y=>{y.preventDefault(),y.stopPropagation()},onDoubleClick:m,onKeyDown:h,role:"separator","aria-orientation":"vertical","aria-label":a.headerColumnResizeLabel(t),"aria-valuenow":Math.round(n),"aria-valuemin":Math.round(Math.min(i??50,n)),"aria-valuemax":l,tabIndex:-1,children:d.jsx("div",{className:"ogx-column-resize-handle__line"})})}function jt(){return d.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"currentColor",children:d.jsx("circle",{cx:"4",cy:"4",r:"4"})})}function qt(){return d.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:d.jsx("circle",{cx:"4",cy:"4",r:"3"})})}function dg(){return d.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",children:[d.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),d.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.3"}),d.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),d.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),d.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),d.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function ug(){return d.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),d.jsx("polyline",{points:"5 12 12 5 19 12"})]})}function fg(){return d.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),d.jsx("polyline",{points:"19 12 12 19 5 12"})]})}function gg(){return d.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:d.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})}function pg(){return d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"}),d.jsx("path",{d:"M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"}),d.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function hg(){return d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("line",{x1:"4",y1:"2",x2:"4",y2:"22"}),d.jsx("polyline",{points:"11 8 4 12 11 16"}),d.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function mg(){return d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("line",{x1:"20",y1:"2",x2:"20",y2:"22"}),d.jsx("polyline",{points:"13 8 20 12 13 16"}),d.jsx("line",{x1:"20",y1:"12",x2:"4",y2:"12"})]})}function wg(){return d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),d.jsx("line",{x1:"4",y1:"4",x2:"4",y2:"20"}),d.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}const ns=e=>e?Array.from(e.querySelectorAll('[role="menuitem"], [role="menuitemradio"]')):[];function bg({colDef:e,sortModel:t,onSort:n,onHide:o,onPin:r,pinnedColumns:i,onManageColumns:l,onClose:c,anchorEl:a}){const u=s.useRef(null),f=Le(),p=s.useCallback(A=>{A&&(a?.closest('[role="columnheader"]')??a)?.focus({preventScroll:!0}),c()},[a,c]),b=A=>{const G=ns(u.current),z=G.indexOf(A.target);let H=-1;if(A.key==="ArrowDown")H=z+1>=G.length?0:z+1;else if(A.key==="ArrowUp")H=z<=0?G.length-1:z-1;else if(A.key==="Home")H=0;else if(A.key==="End")H=G.length-1;else if(A.key==="Tab"){A.preventDefault(),p(!0);return}else return;A.preventDefault(),G[H]?.focus()},[x,w]=s.useState({position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"});s.useLayoutEffect(()=>{if(!a||!u.current)return;const A=a.getBoundingClientRect(),G=u.current.getBoundingClientRect(),z=Lt(),H=ts(),Y=8;let K=A.left;K+G.width+Y>z&&(K=z-G.width-Y),K<Y&&(K=Y);let re=A.bottom+4;re+G.height+Y>H&&(re=A.top-G.height-4),w({position:"fixed",zIndex:1300,top:re,left:K,visibility:"visible"})},[a]);const g=x.visibility==="visible";s.useLayoutEffect(()=>{g&&ns(u.current)[0]?.focus({preventScroll:!0})},[g]),s.useEffect(()=>{function A(z){u.current&&!u.current.contains(z.target)&&a&&!a.contains(z.target)&&c()}function G(z){z.key==="Escape"&&p(!0)}return document.addEventListener("mousedown",A),document.addEventListener("keydown",G),window.addEventListener("scroll",c,!0),window.addEventListener("resize",c),()=>{document.removeEventListener("mousedown",A),document.removeEventListener("keydown",G),window.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c)}},[a,c,p]);const h=A=>{n?.(e.field,A),p(!0)},m=!!o&&e.hideable!==!1,C=!!r&&e.pinnable!==!1,y=()=>{m&&o?.(e.field),p(!0)},_=A=>{C&&r?.(e.field,A),p(!0)},v=t?.find(A=>A.field===e.field)?.sort,k=v==null,M=i?.left?.includes(e.field)??!1,E=i?.right?.includes(e.field)??!1,I=!M&&!E,L=Ye(a),N=L?"right":"left",S=L?"left":"right",F=L?E:M,T=L?M:E,P=e.headerName||e.field;return at.createPortal(d.jsxs("div",{ref:u,className:"ogx-column-menu",style:x,role:"menu","aria-label":f.columnMenuLabel(P),onKeyDown:b,children:[n&&e.sortable!==!1&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:`ogx-menu-item${v==="asc"?" ogx-menu-item--active":""}`,onClick:()=>h("asc"),role:"menuitemradio","aria-checked":v==="asc",children:[d.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:v==="asc"?d.jsx(jt,{}):d.jsx(qt,{})}),d.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:d.jsx(ug,{})}),f.columnMenuSortAscending]}),d.jsxs("button",{type:"button",className:`ogx-menu-item${v==="desc"?" ogx-menu-item--active":""}`,onClick:()=>h("desc"),role:"menuitemradio","aria-checked":v==="desc",children:[d.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:v==="desc"?d.jsx(jt,{}):d.jsx(qt,{})}),d.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:d.jsx(fg,{})}),f.columnMenuSortDescending]}),d.jsxs("button",{type:"button",className:`ogx-menu-item${k?" ogx-menu-item--active":""}`,onClick:()=>h(null),role:"menuitemradio","aria-checked":k,children:[d.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:k?d.jsx(jt,{}):d.jsx(qt,{})}),d.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:d.jsx(gg,{})}),f.columnMenuUnsort]}),d.jsx("div",{className:"ogx-menu-divider"})]}),C&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"ogx-menu-section-label","aria-hidden":"true",children:f.columnMenuPinColumn}),d.jsxs("button",{type:"button",className:`ogx-menu-item${F?" ogx-menu-item--active":""}`,onClick:()=>_(N),role:"menuitemradio","aria-checked":F,"aria-label":f.columnMenuPinLeftLabel,children:[d.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:F?d.jsx(jt,{}):d.jsx(qt,{})}),d.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:d.jsx(hg,{})}),f.columnMenuPinLeft]}),d.jsxs("button",{type:"button",className:`ogx-menu-item${T?" ogx-menu-item--active":""}`,onClick:()=>_(S),role:"menuitemradio","aria-checked":T,"aria-label":f.columnMenuPinRightLabel,children:[d.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:T?d.jsx(jt,{}):d.jsx(qt,{})}),d.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:d.jsx(mg,{})}),f.columnMenuPinRight]}),d.jsxs("button",{type:"button",className:`ogx-menu-item${I?" ogx-menu-item--active":""}`,onClick:()=>_(null),role:"menuitemradio","aria-checked":I,"aria-label":f.columnMenuUnpinLabel,children:[d.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:I?d.jsx(jt,{}):d.jsx(qt,{})}),d.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:d.jsx(wg,{})}),f.columnMenuUnpin]}),d.jsx("div",{className:"ogx-menu-divider"})]}),m&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"ogx-menu-item",onClick:y,role:"menuitem","aria-label":f.columnMenuHideColumnLabel(P),children:[d.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),d.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:d.jsx(pg,{})}),f.columnMenuHideColumn]}),d.jsx("div",{className:"ogx-menu-divider"})]}),d.jsxs("button",{type:"button",className:"ogx-menu-item",onClick:()=>{l?.(),p(!1)},role:"menuitem","aria-label":f.columnMenuManageColumnsLabel,children:[d.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),d.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:d.jsx(dg,{})}),f.columnMenuManageColumns]})]}),a?.closest(".ogx-theme-provider")||document.body)}const xg=16,Cg=16;function yg(e,t=!1){const n=Number.isFinite(e)?e-Cg:0,o=Math.floor(n/xg)-(t?1:0);return Math.max(1,o)}function vg(e,t){return e??t??!1}function os(e,t,n,o){const r={width:t[e.field]??e.width??100,minWidth:e.minWidth,maxWidth:e.maxWidth,flexGrow:e.flex??0,flexShrink:0,flexBasis:"auto",boxSizing:"border-box",position:n?"sticky":"relative"};return n==="left"?r.insetInlineStart=o:n==="right"&&(r.insetInlineEnd=o),r}function Sg(e){const t=e?.headerFilterOperators;return{custom:e?.headerFilterCustom??"Custom filter",customTooltip:e?.headerFilterCustomTooltip??"Set in the filter panel",cellLabel:e?.headerFilterCellLabel??(n=>`Filter ${n}`),valueLabel:e?.headerFilterValueLabel??(n=>`Filter value for ${n}`),operatorButtonLabel:e?.headerFilterOperatorButtonLabel??((n,o)=>`Filter operator for ${n}: ${o}`),operatorMenuLabel:e?.headerFilterOperatorMenuLabel??(n=>`Filter operator for ${n}`),clearLabel:e?.headerFilterClearLabel??(n=>`Clear filter for ${n}`),clearTooltip:e?.headerFilterClearTooltip??"Clear",any:e?.headerFilterAny??"Any",yes:e?.headerFilterTrue??"Yes",no:e?.headerFilterFalse??"No",operator:n=>t?.[n]??Ji[n]??n}}function rs(e){return(e.valueOptions??[]).map((t,n)=>t!==null&&typeof t=="object"?{key:String(n),value:t.value,label:t.label}:{key:String(n),value:t,label:String(t)})}function fr(e,t){const n=Array.isArray(t)?t[0]:t;return Object.is(e.value,n)?!0:n!=null&&String(e.value).toLowerCase()===String(n).toLowerCase()}function Yn(e,t){return t==="isAnyOf"?e.split(",").map(n=>n.trim()).filter(n=>n!==""):e}function gr(e,t){return Object.is(e,t)?!0:e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((n,o)=>gr(n,t[o])):!1}const _g={position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"},is=e=>e?Array.from(e.querySelectorAll('[role="menuitemradio"]')):[];function kg({anchorEl:e,columnLabel:t,operators:n,current:o,onSelect:r,onClose:i,locale:l}){const c=s.useRef(null),[a,u]=s.useState(_g);s.useLayoutEffect(()=>{const x=c.current;if(!x)return;const w=e.getBoundingClientRect(),g=x.getBoundingClientRect(),h=8;let m=Math.min(w.left,Lt()-g.width-h);m<h&&(m=h);let C=w.bottom+4;C+g.height+h>ts()&&(C=w.top-g.height-4),u({position:"fixed",zIndex:1300,top:C,left:m,visibility:"visible"})},[e]);const f=a.visibility==="visible";s.useLayoutEffect(()=>{if(!f)return;const x=is(c.current);(x.find(w=>w.getAttribute("aria-checked")==="true")??x[0])?.focus({preventScroll:!0})},[f]);const p=s.useRef(i);s.useLayoutEffect(()=>{p.current=i}),s.useEffect(()=>{const x=e.ownerDocument,w=x.defaultView;function g(C){const y=C.target;c.current?.contains(y)||e.contains(y)||p.current(!1)}function h(C){c.current?.contains(C.target)||p.current(!1)}function m(){p.current(!1)}return x.addEventListener("mousedown",g),w?.addEventListener("scroll",h,!0),w?.addEventListener("resize",m),()=>{x.removeEventListener("mousedown",g),w?.removeEventListener("scroll",h,!0),w?.removeEventListener("resize",m)}},[e]);const b=x=>{x.stopPropagation();const w=is(c.current),g=w.indexOf(x.target);let h=-1;switch(x.key){case"ArrowDown":h=g+1>=w.length?0:g+1;break;case"ArrowUp":h=g<=0?w.length-1:g-1;break;case"Home":h=0;break;case"End":h=w.length-1;break;case"Escape":case"Tab":x.preventDefault(),i(!0);return;default:return}x.preventDefault(),w[h]?.focus()};return at.createPortal(d.jsx("div",{ref:c,className:"ogx-column-menu ogx__header-filter-menu",style:a,role:"menu","aria-label":l.operatorMenuLabel(t),onKeyDown:b,children:n.map(x=>d.jsx("button",{type:"button",role:"menuitemradio","aria-checked":x===o,tabIndex:-1,className:`ogx-menu-item${x===o?" ogx-menu-item--active":""}`,onClick:()=>r(x),children:l.operator(x)},x))}),e.closest(".ogx-theme-provider")??e.ownerDocument.body)}function ls(e,t){return e===t?!0:!e||!t?!1:e.operator===t.operator&&gr(e.value,t.value)}function Eg(){return d.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",children:[d.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"}),d.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"})]})}function Mg({colDef:e,state:t,style:n,className:o,ariaColIndex:r,onItemChange:i,onOpenFilterPanel:l,locale:c}){const a=e.headerName||e.field,u=t.kind==="editable"?t.item:void 0,f=u?.operator??Un(e),p=rs(e),b=e.type==="boolean"||e.type==="singleSelect"&&p.length>0,x=!Gt.has(f),[w,g]=s.useState(null),[h,m]=s.useState(null),[C,y]=s.useState(void 0),[_,v]=s.useState(u);if(_!==u){v(u);const J=C!==void 0&&ls(C??void 0,u);!ls(_,u)&&!J&&g(null)}const k=s.useRef(null),M=s.useRef(null),E=s.useRef(null),I=s.useRef(null),L=s.useRef(null),N=s.useRef({item:u,colDef:e,onItemChange:i});s.useLayoutEffect(()=>{N.current={item:u,colDef:e,onItemChange:i}});const S=s.useCallback(J=>{const{item:se,colDef:ne,onItemChange:j}=N.current;if(se?J===Ao(se.value,ne.type):J.trim()==="")return;const W=se?.operator??Un(ne),ae=Ko(ne,W,Yn(J,W));y(ae),j(ne.field,ae)},[]),F=s.useRef(null);s.useLayoutEffect(()=>{F.current=w}),s.useEffect(()=>()=>{const J=F.current;F.current=null,J!==null&&S(J)},[S]),s.useEffect(()=>{if(w===null)return;const J=setTimeout(()=>{F.current=null,S(w),g(null)},Vc);return()=>clearTimeout(J)},[w,S]);const T=()=>k.current?.focus({preventScroll:!0}),P=()=>(M.current??E.current)?.focus({preventScroll:!0}),A=J=>{y(J),i(e.field,J)},G=J=>{g(null),A(Ko(e,f,J))},z=()=>{g(null),A(null)},H=()=>{L.current&&m(L.current)},Y=J=>{m(null),J&&(M.current||E.current?P():T())},K=J=>{const se=w!==null?Yn(w,J):u?.value;g(null),m(null),A(Ko(e,J,Yi(se,J))),requestAnimationFrame(()=>{M.current||E.current?P():T()})},re=t.kind==="custom",R=!re&&x&&!b,te=J=>{const se=J.currentTarget,ne=J.target;if(!se.contains(ne)||J.nativeEvent.isComposing)return;const{key:j}=J,B=ne===se;if((J.altKey&&j==="ArrowDown"||(J.ctrlKey||J.metaKey)&&j==="Enter")&&!re&&ne!==E.current){J.preventDefault(),J.stopPropagation(),H();return}if(!B){j==="Escape"&&(J.preventDefault(),J.stopPropagation(),T());return}if(j==="Enter"||j===" "||j==="Spacebar"){J.preventDefault(),J.stopPropagation(),re?I.current?.click():M.current||E.current?P():H();return}if((j==="Delete"||j==="Backspace")&&u){J.preventDefault(),J.stopPropagation(),z();return}R&&e.type!=="date"&&j.length===1&&!J.ctrlKey&&!J.metaKey&&!J.altKey&&(J.preventDefault(),J.stopPropagation(),M.current?.focus({preventScroll:!0}),g(j))};let ie=null;if(re)ie=l?d.jsx("button",{ref:I,type:"button",className:"ogx__header-filter-custom",tabIndex:-1,onClick:l,title:c.customTooltip,children:c.custom}):d.jsx("span",{className:"ogx__header-filter-custom",title:c.customTooltip,children:c.custom});else{let J;if(!x)J=d.jsx("span",{className:"ogx__header-filter-operator-label",children:c.operator(f)});else if(e.type==="boolean")J=d.jsxs("select",{ref:E,className:"ogx__header-filter-select",tabIndex:-1,value:u?.value==null||u.value===""?"":String(u.value),onChange:ne=>G(ne.target.value===""?"":ne.target.value==="true"),"aria-label":c.valueLabel(a),children:[d.jsx("option",{value:"",children:c.any}),d.jsx("option",{value:"true",children:c.yes}),d.jsx("option",{value:"false",children:c.no})]});else if(b){const ne=p.find(j=>fr(j,u?.value));J=d.jsxs("select",{ref:E,className:"ogx__header-filter-select",tabIndex:-1,value:ne?.key??"",onChange:j=>{const B=p.find(W=>W.key===j.target.value);G(Yi(B?B.value:"",f))},"aria-label":c.valueLabel(a),children:[d.jsx("option",{value:"",children:c.any}),p.map(j=>d.jsx("option",{value:j.key,children:j.label},j.key))]})}else J=d.jsx(tt,{ref:M,className:"ogx__header-filter-input-wrapper",inputClassName:"ogx__header-filter-input",type:e.type==="date"?"date":"text",inputMode:e.type==="number"?"decimal":void 0,tabIndex:-1,autoComplete:"off",value:w??Ao(u?.value,e.type),onChange:ne=>g(ne.target.value),"aria-label":c.valueLabel(a)});const se=c.operator(f);ie=d.jsxs(d.Fragment,{children:[d.jsx("button",{ref:L,type:"button",className:`ogx__header-filter-operator${h?" ogx__header-filter-operator--open":""}`,tabIndex:-1,"aria-haspopup":"menu","aria-expanded":h!==null,"aria-label":c.operatorButtonLabel(a,se),title:se,onClick:()=>h?m(null):H(),children:qc[f]??"?"}),J,u&&d.jsx("button",{type:"button",className:"ogx__header-filter-clear",tabIndex:-1,"aria-label":c.clearLabel(a),title:c.clearTooltip,onClick:()=>{z(),T()},children:d.jsx(Eg,{})}),h&&d.jsx(kg,{anchorEl:h,columnLabel:a,locale:c,operators:Uc(e),current:f,onSelect:K,onClose:Y})]})}const ce=["ogx__header-filter-cell",u&&"ogx__header-filter-cell--active",re&&"ogx__header-filter-cell--custom",o].filter(Boolean).join(" ");return d.jsx("div",{ref:k,className:ce,style:n,role:"columnheader","aria-label":c.cellLabel(a),"aria-colindex":r,"data-field":e.field,tabIndex:-1,onKeyDown:te,children:ie})}function pr({field:e,ariaColIndex:t,sticky:n,left:o,focused:r}){return d.jsx("div",{className:["ogx__header-filter-cell","ogx__header-filter-cell--system",n&&"ogx__header-filter-cell--pinned ogx__header-filter-cell--pinned-left",r&&"ogx__header-filter-cell--focused"].filter(Boolean).join(" "),style:{width:We,minWidth:We,maxWidth:We,position:n?"sticky":void 0,insetInlineStart:n?o:void 0},role:"columnheader","aria-colindex":t,"data-field":e,tabIndex:-1})}function Lg(e){const t=Le(),{columns:n,columnWidths:o,pinnedColumns:r,pinnedPositions:i,pinnedEdges:l,rowReordering:c,hasDetailPanel:a,checkboxSelection:u,pinExpandColumn:f,pinCheckboxColumn:p,columnIndexMap:b,ariaRowIndex:x,filterModel:w,onFilterModelChange:g,onOpenFilterPanel:h,focusedField:m,localeText:C}=e,y=s.useRef({filterModel:w,onFilterModelChange:g});s.useLayoutEffect(()=>{y.current={filterModel:w,onFilterModelChange:g}});const _=s.useCallback((S,F)=>{const{filterModel:T,onFilterModelChange:P}=y.current;if(!P)return;const A=jc(T,S,F);A!==T&&(y.current={filterModel:A,onFilterModelChange:P},P(A))},[]),v=Sg(C),k=c?1:0,M=a?k+1:k,E=u?M+1:M,I=E,L=c?We:0,N=L+(a&&f?We:0);return d.jsxs("div",{className:"ogx__header-filter-row",role:"row","aria-rowindex":x,children:[c&&d.jsx(pr,{field:St,ariaColIndex:k,sticky:!0,left:0,focused:m===St}),a&&d.jsx(pr,{field:_t,ariaColIndex:M,sticky:f,left:L,focused:m===_t}),u&&d.jsx(pr,{field:Je,ariaColIndex:E,sticky:p,left:N,focused:m===Je}),n.map((S,F)=>{if(S.isSpacer)return d.jsx("div",{style:{width:S.width,minWidth:S.width,flexShrink:0},"aria-hidden":"true"},S.field);const T=nt(S.field,r),P=os(S,o,T,T?i[S.field]:void 0),A=I+(b?.get(S.field)??F)+1,G=[T&&"ogx__header-filter-cell--pinned",T&&`ogx__header-filter-cell--pinned-${T}`,T==="left"&&S.field===l.lastLeft&&"ogx__header-filter-cell--pinned-left-last",T==="right"&&S.field===l.firstRight&&"ogx__header-filter-cell--pinned-right-first",m===S.field&&"ogx__header-filter-cell--focused"].filter(Boolean).join(" ");return Rc(S)?d.jsx(Mg,{colDef:S,state:Xi(w,S.field),style:P,className:G,ariaColIndex:A,onItemChange:_,onOpenFilterPanel:h,locale:v},S.field):d.jsx("div",{className:`ogx__header-filter-cell ogx__header-filter-cell--empty ${G}`,style:P,role:"columnheader","aria-label":t.headerFilterNoFilterLabel(S.headerName||S.field),"aria-colindex":A,"data-field":S.field,tabIndex:-1},S.field)})]})}function Ag(){return d.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"18",height:"18",children:d.jsx("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"})})}function Pg(){return d.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor",children:d.jsx("path",{d:"M6.99 11L3 15l3.99 4v-3H14v-2H6.99v-3zM21 9l-3.99-4v3H10v2h7.01v3L21 9z"})})}function ss(e){const t=Le(),{columns:n,allColumns:o,columnGroupingModel:r,checkboxSelection:i=!1,allSelected:l=!1,someSelected:c=!1,onSelectAll:a,onSort:u,sortModel:f=[],onColumnResize:p,onColumnAutosize:b,columnWidths:x={},pinnedColumns:w,hasDetailPanel:g=!1,pinCheckboxColumn:h=!0,pinExpandColumn:m=!0,rowReordering:C=!1,aggregationModel:y,draggedColumn:_,dragOverColumn:v,onDragStart:k,onDragOver:M,onDragEnd:E,onDrop:I,focusedCell:L,onHeaderClick:N,onSortAdd:S,multiSort:F=!1,onHideColumn:T,onPinColumn:P,onManageColumns:A,columnIndexMap:G,wrapHeaderText:z=!1,headerHeight:H=56,headerFilters:Y=!1,filterModel:K,onFilterModelChange:re,onOpenFilterPanel:R,localeText:te}=e,ie=s.useId(),[ce,J]=s.useState(null),se=ee=>ue=>{ue.stopPropagation(),J({colDef:ee,anchorEl:ue.currentTarget})},ne=s.useCallback(()=>{J(null)},[]),j=ee=>ue=>{if(ue.altKey&&(ue.key==="ArrowLeft"||ue.key==="ArrowRight")&&ue.target===ue.currentTarget){if(ee.resizable===!1||!p)return;ue.preventDefault(),ue.stopPropagation();const xe=yt(ee,x),ye=Pn(ue.key,Ye(ue.currentTarget)),de=(ue.shiftKey?50:10)*(ye==="ArrowRight"?1:-1);p(ee.field,ar(xe+de,xe,ee.minWidth,ee.maxWidth));return}if(!(ue.altKey&&ue.key==="ArrowDown"||(ue.ctrlKey||ue.metaKey)&&ue.key==="Enter")||ee.disableColumnMenu||ue.target!==ue.currentTarget)return;ue.preventDefault(),ue.stopPropagation();const me=ue.currentTarget.querySelector(".ogx__menu-icon-btn")??ue.currentTarget;J({colDef:ee,anchorEl:me})},B=ee=>L?.id===null&&!L.headerFilter&&L.field===ee,W=C?1:0,ae=g?W+1:W,fe=i?ae+1:ae,Q=ee=>ue=>{if(ee.sortable===!1)return;const Ce=f.find(me=>me.field===ee.field);let be="asc";Ce&&(Ce.sort==="asc"?be="desc":be=null),(ue.shiftKey||F)&&S?S(ee.field,be):u&&u(ee.field,be)},U=(ee,ue)=>{const Ce=f.some(me=>me.field===ee);S&&(ue===null||Ce||F||!u)?S(ee,ue):u?.(ee,ue)},O=ee=>{const ue=f.find(be=>be.field===ee);if(!ue)return null;const Ce=f.length>1?f.indexOf(ue)+1:null;return d.jsx("span",{className:`ogx__sort-icon ogx__sort-icon--${ue.sort}`,"aria-hidden":"true",children:Ce!==null&&d.jsx("span",{className:"ogx__sort-badge",children:Ce})})},$=s.useMemo(()=>po(n,x,w,i,h,g,m,C),[n,x,w,i,h,g,m,C]),D=s.useMemo(()=>ho(n,w),[n,w]),V=xl(r),q=s.useMemo(()=>Cl(r),[r]),oe=s.useMemo(()=>V===0?[]:(o??n).map(ee=>({field:ee.field,width:yt(ee,x),flex:ee.isSpacer?0:ee.flex,pinned:ee.isSpacer?null:nt(ee.field,w),isSpacer:ee.isSpacer})),[V,o,n,x,w]),we=(C?48:0)+(g?48:0)+(i?48:0),ge=(C||g||i)&&(!g||m)&&(!i||h),he=(C?1:0)+(g?1:0)+(i?1:0);return d.jsxs("div",{className:"ogx__header-wrap",children:[V>0&&Array.from({length:V},(ee,ue)=>{const Ce=Jd(oe,q,ue);return d.jsxs("div",{className:"ogx-col-group-row",role:"row","aria-rowindex":ue+1,children:[we>0&&d.jsx("div",{className:`ogx-col-group-cell ogx-col-group-cell--filler${ge?" ogx-col-group-cell--pinned ogx-col-group-cell--pinned-left":""}`,style:{width:we,minWidth:we,flexShrink:0,position:ge?"sticky":void 0,insetInlineStart:ge?0:void 0},"aria-hidden":"true"}),Ce.map((be,me)=>{const xe=be.pinned?` ogx-col-group-cell--pinned ogx-col-group-cell--pinned-${be.pinned}`:"",ye={width:be.width,minWidth:be.width,flexShrink:0,flexGrow:be.flexGrow};return be.pinned==="left"?(ye.position="sticky",ye.insetInlineStart=$[be.fields[0]]):be.pinned==="right"&&(ye.position="sticky",ye.insetInlineEnd=$[be.fields[be.fields.length-1]],Ce[me-1]?.pinned!=="right"&&(ye.marginInlineStart="auto")),be.isGroup?d.jsx("div",{role:"columnheader","aria-colspan":be.fields.length,"aria-colindex":he+be.firstDataIndex+1,className:`ogx-col-group-cell ogx-col-group-cell--group${xe}${be.headerClassName?` ${be.headerClassName}`:""}`,style:ye,title:be.label,children:d.jsx("span",{className:"ogx-col-group-cell__label",children:be.label})},be.key):d.jsx("div",{className:`ogx-col-group-cell ogx-col-group-cell--filler${xe}`,style:ye,"aria-hidden":"true"},be.key)})]},`ogx-grp-${ue}`)}),d.jsxs("div",{className:"ogx__header",role:"row","aria-rowindex":V+1,children:[C&&d.jsx("div",{className:`ogx__header-cell ogx__header-cell--pinned ogx__header-cell--pinned-left ${B("__reorder_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-label":t.headerRowReorderLabel,"aria-colindex":W,"data-field":"__reorder_col__",tabIndex:-1,title:t.headerRowReorderTooltip,style:{minWidth:48,maxWidth:48,position:"sticky",insetInlineStart:0}}),g&&d.jsx("div",{className:`ogx__header-cell ogx__header-cell--expand ${m?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""} ${B("__expand_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-label":t.headerDetailPanelLabel,"aria-colindex":ae,"data-field":"__expand_col__",tabIndex:-1,style:{minWidth:48,maxWidth:48,position:m?"sticky":void 0,insetInlineStart:m?C?48:0:void 0}}),i&&d.jsx("div",{className:`ogx__header-cell ogx__header-cell--checkbox ${h?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""} ${B("__checkbox_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-colindex":fe,"data-field":"__checkbox_col__",style:{position:h?"sticky":void 0,insetInlineStart:h?(C?48:0)+(g&&m?48:0):void 0},children:a&&d.jsx(gt,{id:ie,name:ie,checked:l,indeterminate:c,onChange:ee=>a(ee.target.checked),"aria-label":l?t.headerDeselectAllLabel:t.headerSelectAllLabel,tabIndex:-1,onMouseDown:ee=>ee.preventDefault()})}),n.map((ee,ue)=>{if(ee.isSpacer)return d.jsx("div",{style:{width:ee.width,minWidth:ee.width,flexShrink:0},"aria-hidden":"true"},ee.field);const Ce=ee.sortable!==!1,be=f.findIndex(Ve=>Ve.field===ee.field),me=be!==-1,xe=me?f[be].sort:null,ye=G?.get(ee.field)??ue,de=Ce?be===0?xe==="asc"?"ascending":"descending":"none":void 0,Pe=me&&f.length>1?t.headerSortDescription(xe==="asc"?"asc":"desc",be+1,f.length):void 0,Ie=ee.resizable!==!1,Ae=nt(ee.field,w),Ee=Ae!==null,Fe=_===ee.field,pe=v===ee.field,Se=vg(ee.wrapHeaderText,z),_e=y?.[ee.field],ve=["ogx__header-cell",`ogx__header-cell--align-${ee.headerAlign||ee.align||"left"}`,Ce&&"ogx__header-cell--sortable",me&&"ogx__header-cell--sorted",Ee&&"ogx__header-cell--pinned",Ee&&`ogx__header-cell--pinned-${Ae}`,Ae==="left"&&ee.field===D.lastLeft&&"ogx__header-cell--pinned-left-last",Ae==="right"&&ee.field===D.firstRight&&"ogx__header-cell--pinned-right-first",Fe&&"ogx__header-cell--dragging",pe&&"ogx__header-cell--drag-over",Se&&"ogx__header-cell--wrap",B(ee.field)&&"ogx__header-cell--focused",ee.headerClassName].filter(Boolean).join(" "),Ne={...os(ee,x,Ae,Ae?$[ee.field]:void 0),zIndex:ee.zIndex,opacity:Fe?.5:1},$e=ee.renderHeader?ee.renderHeader({field:ee.field,colDef:ee,colIndex:ye}):ee.headerName||ee.field,Ue=Ve=>{if(Ve.target.closest(".ogx-column-resize-handle")){Ve.stopPropagation();return}N?.(ee.field),Ce&&Q(ee)(Ve)},ht=k&&!Ee?k(ee.field):void 0,At=M&&!Ee?M(ee.field):void 0,Pt=I&&!Ee?I(ee.field):void 0;return d.jsxs("div",{className:ve,style:Ne,title:ee.description??(Se&&typeof $e=="string"?$e:void 0),onClick:Ue,role:"columnheader",draggable:!!ht,onDragStart:ht,onDragOver:At,onDragEnd:E,onDrop:Pt,onKeyDown:j(ee),"aria-sort":de,"aria-description":Pe,"aria-colindex":he+ye+1,"data-field":ee.field,tabIndex:-1,children:[d.jsxs("div",{className:"ogx__header-cell-content",children:[Fe&&d.jsx("div",{className:"ogx__header-drag-icon",children:d.jsx(Pg,{})}),d.jsxs("div",{className:"ogx__header-cell-title-wrapper",children:[d.jsx("span",{className:"ogx__header-cell-title",style:Se?{WebkitLineClamp:yg(H,!!_e)}:void 0,children:$e}),_e&&d.jsx("span",{className:"ogx__header-cell-aggregation",children:_e})]}),Ce&&O(ee.field),!ee.disableColumnMenu&&d.jsx("button",{type:"button",className:"ogx__menu-icon-btn",onClick:se(ee),"aria-label":t.headerColumnMenuButtonLabel(ee.headerName||ee.field),"aria-haspopup":"menu",tabIndex:-1,children:d.jsx(Ag,{})})]}),Ie&&p&&d.jsx(cg,{field:ee.field,currentWidth:yt(ee,x),onResize:p,onAutosize:b,minWidth:ee.minWidth,maxWidth:ee.maxWidth,edge:Ae==="right"?"start":"end"})]},ee.field)}),ce&&d.jsx(bg,{colDef:ce.colDef,sortModel:f,onSort:u||S?U:void 0,onHide:T,onPin:P,pinnedColumns:w,onManageColumns:A,onClose:ne,anchorEl:ce.anchorEl})]}),Y&&d.jsx(Lg,{columns:n,columnWidths:x,pinnedColumns:w,pinnedPositions:$,pinnedEdges:D,rowReordering:C,hasDetailPanel:g,checkboxSelection:i,pinExpandColumn:m,pinCheckboxColumn:h,columnIndexMap:G,ariaRowIndex:V+2,filterModel:K,onFilterModelChange:re,onOpenFilterPanel:R,localeText:te,focusedField:L?.id===null&&L.headerFilter?L.field:null})]})}function pn(e){return e.headerName||e.field}function Ig(e){return e.nativeEvent.isComposing||e.keyCode===229}function hn(e,t,n=!0){return o=>{if(Ig(o)){o.stopPropagation();return}n&&o.key==="Enter"&&(o.stopPropagation(),e()),o.key==="Escape"&&(o.stopPropagation(),t())}}function Ng({value:e,colDef:t,onValueChange:n,onCommit:o,onCancel:r}){const[i,l]=s.useState(String(e??"")),c=s.useRef(null);return s.useEffect(()=>{c.current?.focus(),c.current?.select()},[]),d.jsx(tt,{ref:c,variant:"cell",type:"text",inputClassName:"ogx__edit-input","aria-label":pn(t),value:i,onChange:a=>{l(a.target.value),n(a.target.value)},onBlur:o,onKeyDown:hn(o,r)})}function Fg({value:e,colDef:t,onValueChange:n,onCommit:o,onCancel:r}){const[i,l]=s.useState(typeof e=="number"?e:""),c=s.useRef(null);return s.useEffect(()=>{c.current?.focus(),c.current?.select()},[]),d.jsx(tt,{ref:c,variant:"cell",type:"number",inputClassName:"ogx__edit-input ogx__edit-input--number","aria-label":pn(t),value:i,onChange:a=>{const u=a.target.value===""?"":Number(a.target.value);l(u),n(u===""?null:u)},onBlur:o,onKeyDown:hn(o,r)})}function Tg({value:e,colDef:t,onValueChange:n,onCommit:o,onCancel:r}){const i=s.useRef(null);s.useEffect(()=>{i.current?.focus()},[]);const l=()=>{n(!e),o()};return d.jsx("div",{className:"ogx__edit-boolean",onMouseDown:c=>c.preventDefault(),children:d.jsx(gt,{ref:i,inputClassName:"ogx__edit-checkbox","aria-label":pn(t),checked:!!e,onChange:l,onMouseDown:c=>c.preventDefault(),onBlur:o,onKeyDown:hn(o,r,!1)})})}const hr=e=>typeof e=="object"?e.value:e,Og=e=>typeof e=="object"?e.label:String(e);function Dg(e,t){return e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Object.is(e,t)}function $g({value:e,colDef:t,onValueChange:n,onCommit:o,onCancel:r}){const i=s.useRef(null);s.useEffect(()=>{i.current?.focus()},[]);const l=t.valueOptions??[],c=l.map(f=>String(hr(f)));let a=l.findIndex(f=>Dg(hr(f),e));a===-1&&e!==null&&e!==void 0&&(a=c.indexOf(String(e)));const u=a===-1;return d.jsxs("select",{ref:i,className:"ogx__edit-select","aria-label":pn(t),value:u?"":c[a],onChange:f=>{const p=c.indexOf(f.target.value);n(p===-1?null:hr(l[p]))},onBlur:o,onKeyDown:hn(o,r),children:[u&&d.jsx("option",{value:""}),l.map((f,p)=>d.jsx("option",{value:c[p],children:Og(f)},p))]})}const as=e=>String(e).padStart(2,"0"),cs=/^(\d{4}-\d{2}-\d{2})/;function mr(e){if(e instanceof Date)return Number.isNaN(e.getTime())?"":`${e.getFullYear()}-${as(e.getMonth()+1)}-${as(e.getDate())}`;if(typeof e=="string"){const t=cs.exec(e);return t?t[1]:e===""?"":mr(new Date(e))}return typeof e=="number"?mr(new Date(e)):""}function Gg(e,t){if(e==="")return null;const[n,o,r]=e.split("-").map(Number),i=l=>{const c=new Date(l.getTime());return c.setFullYear(n,o-1,r),c};return t instanceof Date&&!Number.isNaN(t.getTime())?i(t):typeof t=="number"&&Number.isFinite(t)?i(new Date(t)).getTime():typeof t=="string"&&cs.test(t)&&t.length>10?e+t.slice(10):e}function Hg({value:e,colDef:t,onValueChange:n,onCommit:o,onCancel:r}){const[i]=s.useState(e),[l,c]=s.useState(()=>mr(e)),a=s.useRef(null);return s.useEffect(()=>{a.current?.focus()},[]),d.jsx(tt,{ref:a,variant:"cell",type:"date",inputClassName:"ogx__edit-input","aria-label":pn(t),value:l,onChange:u=>{c(u.target.value),n(Gg(u.target.value,i))},onBlur:o,onKeyDown:hn(o,r)})}function Bg(e){const{colDef:t}=e;switch(t.type){case"number":return d.jsx("div",{className:"ogx__edit-cell",children:d.jsx(Fg,{...e})});case"boolean":return d.jsx("div",{className:"ogx__edit-cell",children:d.jsx(Tg,{...e})});case"singleSelect":return d.jsx("div",{className:"ogx__edit-cell",children:d.jsx($g,{...e})});case"date":return d.jsx("div",{className:"ogx__edit-cell",children:d.jsx(Hg,{...e})});default:return d.jsx("div",{className:"ogx__edit-cell",children:d.jsx(Ng,{...e})})}}function Wg(e){const{onCellClick:t,onCellEditStart:n,onCellValueChange:o,value:r,row:i,colDef:l,rowIndex:c,colIndex:a,ariaColIndex:u,isSelected:f,onClick:p,width:b,pinnedPosition:x,pinnedOffset:w,isPinnedEdge:g,isFocused:h,isFocusVisible:m,isEditable:C,isEditing:y,onEditStart:_,onEditStop:v,onValueChange:k,colSpanInfo:M,rowSpan:E,isHiddenByRowSpan:I,rowMeta:L,valueError:N,rangeFlags:S=0}=e,F=s.useCallback(Q=>{o?o(l.field,Q):k?.(Q)},[o,k,l.field]),T=L?.isGroupRow===!0,{formattedValue:P,error:A}=s.useMemo(()=>{const Q=l.valueFormatter;if(Q&&!(T&&r==null)){const U=ze(()=>Q({value:r,row:i,field:l.field}));return U.ok?{formattedValue:U.value}:{formattedValue:"",error:U.error??new Error("valueFormatter failed")}}return{formattedValue:An(r,l)}},[r,i,l,T]),G=s.useMemo(()=>{if(!l.cellClassName)return"";const Q=l.cellClassName;if(typeof Q=="function"){const U=ze(()=>Q({value:r,formattedValue:P,row:i,field:l.field,colDef:l,rowIndex:c,colIndex:a,rowMeta:L}));return U.ok&&U.value||""}return l.cellClassName},[l,r,P,i,c,a,L]),z=N??A,H=l.field,Y=s.useCallback(()=>{v?.(!1,H)},[v,H]),K=s.useCallback(()=>{v?.(!0,H)},[v,H]),re=s.useMemo(()=>[i,l.renderCell,r],[i,l.renderCell,r]),R=s.useRef(!1);if(s.useEffect(()=>{if(!(!y||!v))return R.current=!0,()=>{R.current=!1,queueMicrotask(()=>{R.current||v(!1,H)})}},[y,v,H]),M?.spannedByColSpan)return null;const te=M?.cellProps.colSpan??1,ie=te>1,ce=(ie?M?.cellProps.width:void 0)??b??l.width??100,J={width:"var(--width)","--width":typeof ce=="number"?`${ce}px`:ce,flexGrow:(ie?M?.cellProps.flexGrow:void 0)??l.flex??0,flexShrink:0,flexBasis:"auto",boxSizing:"border-box",minWidth:ie?void 0:l.minWidth,maxWidth:ie?void 0:l.maxWidth};if(I)return d.jsx("div",{className:"ogx__cell ogx__cell--hidden",style:J,role:"presentation","data-field":l.field,"data-colindex":a});const se=Q=>{y||(t&&t({row:i,field:l.field,value:r,colDef:l,rowIndex:c,colIndex:a}),p?.(Q))},ne=()=>{y||!C||(n?n(l.field,r):_?.())},j=l.renderEditCell,B=x!=null,W=["ogx__cell",`ogx__cell--align-${l.align||"left"}`,f&&"ogx__cell--selected",h&&"ogx__cell--focused",h&&m&&"ogx__cell--focus-visible",l.type&&`ogx__cell--type-${l.type}`,B&&"ogx__cell--pinned",B&&`ogx__cell--pinned-${x}`,B&&g&&`ogx__cell--pinned-${x}-${x==="left"?"last":"first"}`,y&&"ogx__cell--editing",E&&E>1&&"ogx__cell--spanned",(S&Go)!==0&&"ogx__cell--range",(S&Fi)!==0&&"ogx__cell--range-top",(S&Ti)!==0&&"ogx__cell--range-bottom",(S&Oi)!==0&&"ogx__cell--range-left",(S&Di)!==0&&"ogx__cell--range-right",G].filter(Boolean).join(" "),ae=E||1,fe={...J,position:B?"sticky":void 0,zIndex:l.zIndex??(B?3:void 0),padding:y?0:void 0};return ae>1&&(fe.height=`calc(var(--height) * ${ae} - var(--border-width, 1px))`,fe.zIndex=10,B&&(fe.zIndex=40)),B&&w!==void 0&&(x==="left"?fe.insetInlineStart=w:fe.insetInlineEnd=w),d.jsxs("div",{className:W,style:fe,onClick:se,onDoubleClick:ne,role:"gridcell","aria-colindex":u??a+1,"aria-readonly":!C||void 0,tabIndex:-1,"data-field":l.field,"data-colindex":a,...te>1?{"aria-colspan":te}:{},...ae>1?{"aria-rowspan":ae}:{},...(S&Go)!==0?{"aria-selected":!0}:{},children:[d.jsx("div",{className:"ogx__cell-content",children:y&&(o||k)&&v?j?d.jsx(Et,{field:l.field,resetKey:i,renderFn:()=>j({value:r,formattedValue:P,row:i,field:l.field,colDef:l,rowIndex:c,colIndex:a,rowMeta:L,onValueChange:F,onCommit:Y,onCancel:K})}):d.jsx(Bg,{value:r,formattedValue:P,row:i,field:l.field,colDef:l,rowIndex:c,colIndex:a,rowMeta:L,onValueChange:F,onCommit:Y,onCancel:K}):z!==void 0?d.jsx(Et,{field:l.field,resetKey:i,renderFn:()=>{throw z}}):l.renderCell?d.jsx(Et,{field:l.field,resetKey:re,renderFn:()=>l.renderCell({value:r,formattedValue:P,row:i,field:l.field,colDef:l,rowIndex:c,colIndex:a,rowMeta:L})}):l.type==="image"&&typeof r=="string"&&r!==""?d.jsx("img",{className:"ogx__cell-image",src:r,alt:l.headerName??l.field,loading:"lazy"}):P}),(S&$i)!==0&&!y&&d.jsx("div",{className:"ogx__cell-fill-handle","aria-hidden":"true"})]})}const ds=s.memo(Wg),Vg=({className:e="",...t})=>{const n=Le();return d.jsx("button",{type:"button",className:`ogx-drag-handle ${e}`,"aria-label":n.rowReorderLabel,...t,children:d.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"currentColor","aria-hidden":"true",children:d.jsx("path",{d:"M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2zm-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"})})})};function zg(e){const{rowId:t,content:n,height:o,isExpanded:r,onHeightChange:i,id:l,colSpan:c}=e,a=s.useRef(null),u=o==="auto";if(s.useLayoutEffect(()=>{const p=a.current;if(!p||!u||!r||!i)return;const b=()=>{p.getClientRects().length!==0&&i(t,p.offsetHeight)};if(b(),typeof ResizeObserver>"u")return;const x=new ResizeObserver(b);return x.observe(p),()=>x.disconnect()},[u,r,i,t]),!r)return null;const f={height:u?"auto":`${o}px`,overflow:u?"visible":"auto"};return d.jsx("div",{ref:a,className:"ogx__detail-panel",style:f,role:"row",id:l,children:d.jsx("div",{className:"ogx__detail-panel-content",role:"gridcell","aria-colspan":c,children:n})})}const wr=12;function Rg(e,t,n,o){let r=0,i=0,l=0;for(let c=t;c<e.length&&l<n;c++){const a=e[c];if(a.isSpacer)break;r+=yt(a,o),i+=a.flex??0,l++}return{spannedByColSpan:!1,cellProps:{colSpan:l,width:r,flexGrow:i}}}function Ug(e){const t=Le(),{row:n,skeleton:o=!1,rowId:r,columns:i,rowIndex:l,isSelected:c=!1,checkboxSelection:a=!1,onRowClick:u,onRowDoubleClick:f,onCellClick:p,onSelectionChange:b,columnWidths:x={},pinnedColumns:w,pinnedRows:g,hasDetailPanel:h=!1,isDetailPanelExpanded:m=!1,onDetailPanelToggle:C,detailPanelContent:y,detailPanelHeight:_=bo,onDetailPanelHeightChange:v,pinCheckboxColumn:k=!0,pinExpandColumn:M=!0,rowReordering:E=!1,onDragStart:I,onDragOver:L,onDragEnd:N,onDrop:S,isDragging:F,isDragOver:T,editingCell:P,onEditStart:A,onEditStop:G,onEditCellValueChange:z,isCellEditable:H,focusedCellField:Y,isFocusVisible:K,colspanMap:re,rowSpanningCaches:R,rowHeight:te=52,rowMeta:ie,columnIndexMap:ce,ariaRowIndex:J,cellRange:se}=e,ne=r??n.id,j=s.useId(),B=s.useId(),W=s.useMemo(()=>po(i,x,w,a,k,h,M,E),[i,x,w,a,k,h,M,E]),ae=s.useMemo(()=>ho(i,w),[i,w]),fe=ie?.hasChildren===!0,Q=ie?.isGroupRow===!0,U=h&&!Q,O=!Q&&!je(ne),$=s.useCallback((de,Pe)=>{A?.({id:ne,field:de,value:Pe})},[ne,A]),D=s.useCallback((de,Pe)=>{z?.({id:ne,field:de,value:Pe})},[z,ne]),V=s.useCallback((de,Pe)=>{G?.({cancel:de,id:ne,field:Pe})},[G,ne]);if(o){const de=Math.max(i.length,5);return d.jsx("div",{className:"ogx__row ogx__row--skeleton",role:"row","aria-hidden":"true",style:{height:te,minHeight:te},children:Array.from({length:de}).map((Pe,Ie)=>d.jsx("div",{className:"ogx__skeleton-cell",children:d.jsx("div",{className:"ogx__skeleton-bar"})},Ie))})}const q=de=>{de.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell, .ogx__cell--editing")||u?.({row:n,id:ne,rowIndex:l})},oe=de=>{de.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell, .ogx__cell--editing")||f?.({row:n,id:ne,rowIndex:l})},Z=de=>{de.stopPropagation(),b?.(ne,de.target.checked)},X=de=>{de.stopPropagation(),C?.(ne)},le=E?1:0,we=h?le+1:le,ge=a?we+1:we,he=ge,ee=ce?.size??i.filter(de=>!de.isSpacer).length,ue=ie!==void 0,Ce=ie?.hasChildren===!0,be=Kr(ne,g),me=be==="top",xe=be==="bottom",ye=["ogx__row",c&&"ogx__row--selected",l%2===0&&"ogx__row--even",l%2===1&&"ogx__row--odd",me&&"ogx__row--pinned-top",xe&&"ogx__row--pinned-bottom",F&&"ogx__row--dragging",T&&"ogx__row--drag-over",fe&&"ogx__row--group",ie?.isGroupFooter&&"ogx__row--group-footer"].filter(Boolean).join(" ");return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:ye,onClick:q,onDoubleClick:f?oe:void 0,role:"row","aria-rowindex":J??l+2,"aria-selected":c,"aria-level":ue?(ie?.treeDepth??0)+1:void 0,"aria-expanded":Ce?ie?.isExpanded===!0:void 0,"data-rowindex":l,onDragOver:L?L(ne):void 0,onDrop:S?S(ne):void 0,style:{maxHeight:`${te}px`,minHeight:`${te}px`,"--height":`${te}px`,"--border-width":"1px"},children:[E&&d.jsx("div",{className:`ogx__cell ogx__cell--drag-handle ${Y==="__reorder_col__"?"ogx__cell--focused":""} ${Y==="__reorder_col__"&&K?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":I?t.rowReorderLabel:void 0,"aria-colindex":le,"data-field":"__reorder_col__",tabIndex:-1,style:{position:"sticky",insetInlineStart:0,zIndex:wr},draggable:!!I,onDragStart:I?I(ne):void 0,onDragEnd:N,onClick:de=>de.stopPropagation(),children:I&&d.jsx(Vg,{})}),h&&d.jsx("div",{className:`ogx__cell ogx__cell--expand ${M?"ogx__cell--pinned-left":""} ${Y==="__expand_col__"?"ogx__cell--focused":""} ${Y==="__expand_col__"&&K?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":U?m?t.rowDetailPanelCollapseLabel:t.rowDetailPanelExpandLabel:void 0,"aria-expanded":U?m:void 0,"aria-controls":U&&m?B:void 0,"aria-colindex":we,"data-field":"__expand_col__",style:{position:M?"sticky":void 0,insetInlineStart:M?E?48:0:void 0,zIndex:M?wr:void 0},tabIndex:-1,onClick:de=>{de.stopPropagation(),p?.({row:n,field:"__expand_col__",value:m,colDef:{field:"__expand_col__",width:48},rowIndex:l,colIndex:-1})},children:U&&d.jsx(Xo,{isExpanded:m,onClick:X,variant:"plus-minus",tabIndex:-1})}),a&&d.jsx("div",{className:`ogx__cell ogx__cell--checkbox ${k?"ogx__cell--pinned-left":""} ${Y==="__checkbox_col__"?"ogx__cell--focused":""} ${Y==="__checkbox_col__"&&K?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-colindex":ge,"data-field":"__checkbox_col__",style:{position:k?"sticky":void 0,insetInlineStart:k?(E?48:0)+(h&&M?48:0):void 0,zIndex:k?wr:void 0},tabIndex:-1,onClick:de=>{de.stopPropagation(),p?.({row:n,field:"__checkbox_col__",value:c,colDef:{field:"__checkbox_col__",width:48},rowIndex:l,colIndex:-1})},children:O&&d.jsx(gt,{id:j,name:`ogx-select-row-${ne}`,checked:c,onChange:Z,onClick:de=>de.stopPropagation(),"aria-label":c?t.rowDeselectLabel(ne):t.rowSelectLabel(ne),tabIndex:-1,onMouseDown:de=>de.preventDefault()})}),i.map((de,Pe)=>{if(de.isSpacer)return d.jsx("div",{style:{width:de.width,minWidth:de.width,flexShrink:0},"aria-hidden":"true"},de.field);let Ie,Ae;Q?Ie=n[de.field]:{value:Ie,error:Ae}=qr(n,de.field,de);const Ee=ce?.get(de.field)??Pe,Fe=x[de.field]??de.width,pe=nt(de.field,w),Se=!!A&&vo({row:n,field:de.field,value:Ie,colDef:de,rowIndex:l,colIndex:Ee,rowMeta:ie},H),_e=P?.id===ne&&P?.field===de.field,ve=_e?P?.value:Ie,Ne=re?.get(ne)?.[de.field],$e=Ne&&!Ne.spannedByColSpan&&Ne.cellProps.colSpan>1?Rg(i,Ee,Ne.cellProps.colSpan,x):Ne,Ue=$e&&!$e.spannedByColSpan?i[Ee+$e.cellProps.colSpan-1]?.field??de.field:de.field,ht=pe==="right"?Ue:de.field,At=pe?W[ht]:void 0,Pt=pe==="left"&&Ue===ae.lastLeft||pe==="right"&&de.field===ae.firstRight,Ve=R?.spannedCells[ne]?.[de.field],ro=R?.hiddenCells[ne]?.[de.field]||!1,xn=se&&!ro&&de.field!==Ii?xc(se,Ee,$e&&!$e.spannedByColSpan?$e.cellProps.colSpan:1,Ve??1):void 0;return d.jsx(ds,{value:ve,row:n,colDef:de,rowIndex:l,colIndex:Ee,ariaColIndex:he+Ee+1,isSelected:c,onCellClick:p,width:Fe,pinnedPosition:pe,pinnedOffset:At,isPinnedEdge:Pt,isFocused:Y===de.field,isFocusVisible:K,isEditable:Se,isEditing:_e,onCellEditStart:$,onEditStop:V,onCellValueChange:D,colSpanInfo:$e,rowSpan:Ve,isHiddenByRowSpan:ro,rowMeta:ie,valueError:Ae,rangeFlags:xn},de.field)})]}),U&&d.jsx(zg,{id:B,colSpan:he+ee,row:n,rowId:ne,rowIndex:l,content:y,height:_,isExpanded:m,onHeightChange:v})]})}function Kg(e,t){const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(o==="cellRange"){if(!bc(e.cellRange,t.cellRange))return!1}else if(!Object.is(e[o],t[o]))return!1;return!0}const Jn=s.memo(Ug,Kg);function us({getContent:e,params:t}){return d.jsx(Et,{field:"detail panel",renderFn:()=>e(t),resetKey:t.row})}const jg=e=>e.id;function fs({rows:e,position:t,columns:n,selectedRowIds:o,checkboxSelection:r,onRowClick:i,onRowDoubleClick:l,onCellClick:c,onSelectionChange:a,columnWidths:u,pinnedColumns:f,pinnedRows:p,hasDetailPanel:b,expandedRowIds:x,getDetailPanelContent:w,getDetailPanelHeight:g,onDetailPanelToggle:h,onDetailPanelHeightChange:m,pinCheckboxColumn:C,pinExpandColumn:y,focusedCell:_,colspanMap:v,rowSpanningCaches:k,rowHeight:M,rowMetaMap:E,getRowId:I=jg,rowIndexOffset:L=0,ariaRowIndexBase:N,columnIndexMap:S,editingHandlers:F,isCellEditable:T,rowReordering:P=!1,cellRange:A,cellRangeHasRowSpan:G=!1,fillHandle:z}){return e.length===0?null:d.jsx("div",{className:`ogx__pinned-rows ogx__pinned-rows--${t}`,role:"rowgroup",children:e.map((H,Y)=>{const K=I(H),re=L+Y;return d.jsx(Jn,{row:H,rowId:K,columns:n,rowIndex:re,ariaRowIndex:N!==void 0?N+Y:void 0,columnIndexMap:S,isSelected:o.has(K),checkboxSelection:r,onRowClick:i,onRowDoubleClick:l,onCellClick:c,onSelectionChange:a,columnWidths:u,pinnedColumns:f,pinnedRows:p,hasDetailPanel:b,isDetailPanelExpanded:x.has(K),detailPanelContent:x.has(K)&&w?d.jsx(us,{getContent:w,params:{row:H,id:K,rowIndex:re}}):null,detailPanelHeight:x.has(K)?xo(Co(g,{row:H,id:K,rowIndex:re})):void 0,onDetailPanelHeightChange:m,onDetailPanelToggle:h,pinCheckboxColumn:C,pinExpandColumn:y,focusedCellField:_?.id===K?_.field:null,colspanMap:v,rowSpanningCaches:k,rowHeight:M,rowMeta:E.get(K),editingCell:F?.editingCell?.id===K?F.editingCell:null,onEditStart:F?.startCellEdit,onEditStop:F?.stopCellEdit,onEditCellValueChange:F?.setEditCellValue,isCellEditable:T,rowReordering:P,cellRange:Ni(A,re,G,z)},K)})})}const qg=({columns:e,rowHeight:t,checkboxSelection:n=!1,hasDetailPanel:o=!1,rowReordering:r=!1})=>d.jsxs("div",{className:"ogx__row ogx__skeleton-row",style:{height:t},role:"row",children:[n&&d.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:d.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),o&&d.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:d.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),r&&d.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:d.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),e.map((i,l)=>{const c=typeof i.width=="number"?i.width:150,a=Math.min(c*.7,c-20);return d.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:c,minWidth:i.minWidth,maxWidth:i.maxWidth,insetInlineStart:i.left,insetInlineEnd:i.right,position:i.isSpacer?"relative":i.pinned?"sticky":"relative",zIndex:i.zIndex},children:!i.isSpacer&&d.jsx("div",{className:"ogx-skeleton-box",style:{width:a,height:16,borderRadius:4}})},i.field||l)})]});function Xg({virtualContainerHeight:e,offsetTop:t,effectiveLoading:n,visibleRows:o,baseColumns:r,virtualColumns:i,viewportWidth:l,checkboxSelection:c,hasDetailPanel:a,rowReordering:u,rowHeight:f,selectedRowIds:p,onRowClick:b,onRowDoubleClick:x,onCellClick:w,onSelectionChange:g,columnWidths:h,pinnedColumns:m,expandedRowIds:C,getDetailPanelContent:y,getDetailPanelHeight:_,onDetailPanelToggle:v,onDetailPanelHeightChange:k,pinCheckboxColumn:M,pinExpandColumn:E,rowReorderHandlers:I,editingHandlers:L,isCellEditable:N,focusedCell:S,colspanMap:F,rowSpanningCaches:T,paginationMode:P,dataSourceLoading:A,sortedUnpinnedRowCount:G,infiniteScrollSkeletonCount:z,unpinnedRowsLength:H,lastRenderedRowIndex:Y,rowMetaMap:K,loadingOverlay:re,ariaRowIndexOffset:R,columnIndexMap:te,cellRange:ie,cellRangeHasRowSpan:ce=!1,fillHandle:J}){const se=r.length>0?r:(()=>{const B=(l||1e3)-(c?48:0)-(a?48:0)-(u?48:0),W=150,ae=Math.max(1,Math.ceil(B/W));return Array.from({length:ae},(fe,Q)=>({field:`placeholder_${Q}`,headerName:"",width:W}))})(),ne=o.filter(B=>!B.pinned),j=P==="infinite"&&A&&G>0&&Y>=H-1;return d.jsx("div",{className:"ogx__virtual-container",style:{height:`${e}px`},role:"presentation",children:d.jsxs("div",{className:"ogx__rows",style:{transform:`translateY(${t}px)`},role:"rowgroup",children:[n&&o.length===0&&re?d.jsx("div",{className:"ogx__loading-overlay",style:{width:l||void 0},children:re}):n&&o.length===0?Array.from({length:10}).map((B,W)=>d.jsx(qg,{columns:se,rowHeight:f,checkboxSelection:c,hasDetailPanel:a,rowReordering:u},`skeleton-${W}`)):ne.map(({row:B,id:W,rowIndex:ae})=>d.jsx(Jn,{row:B,rowId:W,columns:i,rowIndex:ae,ariaRowIndex:R!==void 0?ae+R:void 0,columnIndexMap:te,isSelected:p.has(W),checkboxSelection:c,onRowClick:b,onRowDoubleClick:x,onCellClick:w,onSelectionChange:g,columnWidths:h,pinnedColumns:m,hasDetailPanel:a,isDetailPanelExpanded:C.has(W),detailPanelContent:C.has(W)&&y?d.jsx(us,{getContent:y,params:{row:B,id:W,rowIndex:ae}}):null,detailPanelHeight:C.has(W)?xo(Co(_,{row:B,id:W,rowIndex:ae})):void 0,onDetailPanelHeightChange:k,onDetailPanelToggle:v,pinCheckboxColumn:M,pinExpandColumn:E,rowReordering:u,onDragStart:I.canReorderRow(W)?I.onDragStart:void 0,onDragOver:I.onDragOver,onDragEnd:I.onDragEnd,onDrop:I.onDrop,isDragging:I.draggedRowId===W,isDragOver:I.dragOverRowId===W,editingCell:L.editingCell?.id===W?L.editingCell:null,onEditStart:L.startCellEdit,onEditStop:L.stopCellEdit,onEditCellValueChange:L.setEditCellValue,isCellEditable:N,focusedCellField:S!=null&&S.id===W?S.field:null,colspanMap:F,rowSpanningCaches:T,rowHeight:f,rowMeta:K.get(W),cellRange:Ni(ie,ae,ce,J)},W)),j&&d.jsx("div",{className:"ogx__skeleton-group",children:Array.from({length:z}).map((B,W)=>d.jsx(Jn,{row:{id:`__skeleton_${W}__`},skeleton:!0,columns:i,rowIndex:H+W,rowHeight:f},`__skeleton_${W}__`))})]})})}function Yg({noRowsLabel:e,width:t,overlay:n}){return n?d.jsx("div",{className:"ogx__empty",style:{width:t},children:n}):d.jsxs("div",{className:"ogx__empty",style:{width:t},children:[d.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[d.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),d.jsx("path",{d:"M3 9h18M9 21V9"})]}),d.jsx("span",{children:e})]})}const gs=48;function Jg({columns:e,aggregationModel:t,aggregationResult:n,columnWidths:o,rowHeight:r,checkboxSelection:i,hasDetailPanel:l,rowReordering:c,pinCheckboxColumn:a=!0,pinExpandColumn:u=!0,pinnedColumns:f,loading:p=!1}){const b=Le(),x=s.useMemo(()=>po(e,o,f,i,a,l,u,c),[e,o,f,i,a,l,u,c]),{lastLeft:w,firstRight:g}=s.useMemo(()=>ho(e,f),[e,f]),h=c?gs:0,m=h+(l&&u?gs:0),C=(y,_,v)=>d.jsx("div",{className:`ogx__aggregation-spacer${_?" ogx__aggregation-spacer--pinned":""}`,style:_?{insetInlineStart:v}:void 0,"aria-hidden":"true"},y);return d.jsxs("div",{className:`ogx__aggregation-footer${p?" ogx__aggregation-footer--loading":""}`,role:"row","aria-label":b.aggregationFooterLabel,"aria-live":"polite","aria-busy":p||void 0,style:{minHeight:`${r}px`},children:[c&&C("__reorder_col__",!0,0),l&&C("__expand_col__",u,h),i&&C("__checkbox_col__",a,m),e.map(y=>{if(y.isSpacer){const S=typeof y.width=="number"?y.width:0;return d.jsx("div",{style:{width:S,minWidth:S,flexShrink:0},"aria-hidden":"true"},y.field)}const _=t[y.field],v=_&&So(y,_)?_:void 0,k=n[y.field],M=yt(y,o,120),E=nt(y.field,f),I=E?x[y.field]:void 0,L=["ogx__aggregation-cell",E==="left"&&"ogx__aggregation-cell--pinned-left",E==="right"&&"ogx__aggregation-cell--pinned-right",E==="left"&&y.field===w&&"ogx__aggregation-cell--pinned-left-last",E==="right"&&y.field===g&&"ogx__aggregation-cell--pinned-right-first"].filter(Boolean).join(" "),N={width:M,minWidth:M,maxWidth:M,textAlign:y.align||"left"};return E==="left"&&I!==void 0&&(N.insetInlineStart=I),E==="right"&&I!==void 0&&(N.insetInlineEnd=I),d.jsx("div",{className:L,role:"gridcell",style:N,children:v?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"ogx__aggregation-label",children:v}),d.jsx("span",{className:"ogx__aggregation-value",children:Tn(k,v,y,n)})]}):null},y.field)})]})}function Zg(e){const t=Le(),{setViewportElement:n,handleScroll:o,ariaLabel:r,ariaRows:i,navigationColumnCount:l,rowSelectionEnabled:c,disableMultipleRowSelection:a,cellSelection:u,effectiveLoading:f,viewportTabIndex:p,setKeyboardMode:b,handleMouseDownCapture:x,handleKeyDown:w,handleFocus:g,handleBlur:h,effectivePinnedColumns:m,virtualization:C,renderColumns:y,renderedDataColumns:_,columnGroupingModel:v,checkboxSelection:k,rowSelection:M,sortModel:E,handleSort:I,handleSortAdd:L,multiSort:N,handleColumnResize:S,handleColumnAutosize:F,columnWidths:T,focusedCell:P,columnIndexMap:A,handleHeaderClick:G,headerReorderHandlers:z,rowReordering:H,hasDetailPanel:Y,pinCheckboxColumn:K,pinExpandColumn:re,aggregationModel:R,handleHideColumn:te,columnsPanel:ie,handlePinColumn:ce,wrapHeaderText:J,headerHeight:se,showHeaderFilters:ne,filterModel:j,handleFilterModelChange:B,localeText:W,editingHandlers:ae,isCellEditable:fe,selectedRowIds:Q,handleRowClick:U,onRowDoubleClick:O,handleCellClick:$,handleSelectionChange:D,expandedRowIds:V,getDetailPanelContent:q,getDetailPanelHeight:oe,handleDetailPanelToggle:Z,reportDetailPanelHeight:X,spanning:le,rowMetaMap:we,fillHandle:ge,pinnedTopRows:he,pinnedBottomRows:ee,pinnedRows:ue,getRowIdOf:Ce,showEmptyState:be,effectiveNoRowsLabel:me,noRowsOverlay:xe,loadingOverlay:ye,spanRowWindow:de,visibleRows:Pe,baseColumns:Ie,viewportWidth:Ae,rowReorderHandlers:Ee,paginationMode:Fe,dataSourceLoading:pe,sortedUnpinnedRowCount:Se,pageSize:_e,unpinnedRowsLength:ve,showAggregationFooter:Ne,aggregationResult:$e,effectiveRowHeight:Ue,isAggregationLoading:ht}=e,{allSelected:At,someSelected:Pt}=M,Ve={rowReordering:H,columnIndexMap:A,editingHandlers:ae,isCellEditable:fe,selectedRowIds:Q,checkboxSelection:k,onRowClick:U,onRowDoubleClick:O,onCellClick:$,onSelectionChange:D,columnWidths:T,pinnedColumns:m,hasDetailPanel:Y,expandedRowIds:V,getDetailPanelContent:q,getDetailPanelHeight:oe,onDetailPanelToggle:Z,onDetailPanelHeightChange:X,pinCheckboxColumn:K,pinExpandColumn:re,focusedCell:P,colspanMap:le.colspanMap,rowSpanningCaches:le.rowSpanningCaches,rowHeight:Ue,rowMetaMap:we,cellRange:u.displayRange,cellRangeHasRowSpan:u.hasRowSpan,fillHandle:ge.handle};return d.jsx("div",{ref:n,className:"ogx__viewport",onScroll:o,role:"grid","aria-label":r||t.gridLabel,"aria-rowcount":i.rowCount,"aria-colcount":l,"aria-multiselectable":c&&!a||u.enabled,"aria-busy":f,tabIndex:p,onKeyDownCapture:()=>{b(!0)},onMouseDownCapture:x,onMouseDown:u.handleMouseDown,onClickCapture:u.handleClickCapture,onKeyDown:w,onFocus:g,onBlur:h,children:d.jsxs("div",{className:"ogx__content",style:{width:m?.right?.length?`max(100%, ${C.totalWidth}px)`:C.totalWidth},role:"presentation",children:[d.jsxs("div",{className:"ogx__sticky-top",role:"presentation",children:[d.jsx(ss,{columns:y,allColumns:_,columnGroupingModel:v,checkboxSelection:k,allSelected:At,someSelected:Pt,onSelectAll:M.selectAll,sortModel:E,onSort:I,onSortAdd:L,multiSort:N,onColumnResize:S,onColumnAutosize:F,columnWidths:T,pinnedColumns:m,focusedCell:P,columnIndexMap:A,onHeaderClick:G,onDragStart:z.onDragStart,onDragOver:z.onDragOver,onDragEnd:z.onDragEnd,onDrop:z.onDrop,draggedColumn:z.draggedColumn,dragOverColumn:z.dragOverColumn,rowReordering:H,hasDetailPanel:Y,pinCheckboxColumn:K,pinExpandColumn:re,aggregationModel:R,onHideColumn:te,onManageColumns:ie.openColumnsPanel,onPinColumn:ce,wrapHeaderText:J,headerHeight:se,headerFilters:ne,filterModel:j,onFilterModelChange:B,onOpenFilterPanel:ie.openFiltersPanel,localeText:W}),d.jsx(fs,{...Ve,rows:he,position:"top",ariaRowIndexBase:i.topBase,columns:y,pinnedRows:ue,getRowId:Ce})]}),be&&d.jsx(Yg,{noRowsLabel:me,width:C.totalWidth,overlay:xe}),d.jsx(Xg,{...Ve,virtualContainerHeight:C.virtualContainerHeight,offsetTop:de.offsetTop,effectiveLoading:f,visibleRows:Pe,baseColumns:Ie,virtualColumns:y,viewportWidth:Ae,rowReorderHandlers:Ee,paginationMode:Fe,dataSourceLoading:pe,sortedUnpinnedRowCount:Se,infiniteScrollSkeletonCount:Math.min(_e,20),unpinnedRowsLength:ve,lastRenderedRowIndex:de.renderContext.lastRowIndex,ariaRowIndexOffset:i.centerOffset,loadingOverlay:ye}),d.jsxs("div",{className:"ogx__sticky-bottom",role:"presentation",children:[d.jsx(fs,{...Ve,rows:ee,position:"bottom",rowIndexOffset:i.bottomRowIndexOffset,ariaRowIndexBase:i.bottomBase,columns:y,pinnedRows:ue,getRowId:Ce}),Ne&&d.jsx(Jg,{columns:C.virtualColumns,aggregationModel:R,aggregationResult:$e,columnWidths:T,rowHeight:Ue,checkboxSelection:k,hasDetailPanel:Y,rowReordering:H,pinCheckboxColumn:K,pinExpandColumn:re,pinnedColumns:m,loading:ht})]})]})})}function ps({count:e,sum:t,average:n}){const o=Le();return d.jsxs("div",{className:"ogx__cell-selection-stats",children:[d.jsxs("span",{className:"ogx__cell-selection-stat",children:[d.jsx("span",{className:"ogx__cell-selection-stat-label",children:o.cellSelectionStatsCount}),d.jsx("span",{className:"ogx__cell-selection-stat-value","data-stat":"count",children:e.toLocaleString()})]}),t!==null&&d.jsxs("span",{className:"ogx__cell-selection-stat",children:[d.jsx("span",{className:"ogx__cell-selection-stat-label",children:o.cellSelectionStatsSum}),d.jsx("span",{className:"ogx__cell-selection-stat-value","data-stat":"sum",children:rn(t,"sum")})]}),n!==null&&d.jsxs("span",{className:"ogx__cell-selection-stat",children:[d.jsx("span",{className:"ogx__cell-selection-stat-label",children:o.cellSelectionStatsAverage}),d.jsx("span",{className:"ogx__cell-selection-stat-value","data-stat":"average",children:rn(n,"avg")})]})]})}function Qg({stats:e,apiRef:t,slot:n,slotProps:o}){const r=n??ps;return d.jsx("div",{className:"ogx__cell-selection-stats-area","aria-hidden":e?void 0:!0,children:e&&d.jsx(r,{apiRef:t,...e,...o})})}function ep({paginationSlot:e,paginationSlotProps:t,page:n,paginationModel:o,rowCount:r,pageSizeOptions:i,onPaginationModelChange:l,localeText:c}){const a=e||ur;return d.jsx(a,{page:n,pageSize:o.pageSize,rowCount:r,pageSizeOptions:i,onPageChange:u=>l({...o,page:u}),onPageSizeChange:u=>l({...o,pageSize:u,page:0}),localeText:Vi(c),...t})}function tp({loading:e,error:t,noRowsLabel:n,filteredRowCount:o,dataRowCount:r,filterModel:i,cellSelectionAnnouncement:l,aiAssistantAnnouncement:c}){const a=Le();return d.jsxs("div",{className:"ogx-aria-live-status",role:"status","aria-live":"polite",children:[e?a.liveRegionLoading:"",t?a.liveRegionError(Ul(t)):"",!e&&!t&&(o===0?n:i&&((i.quickFilterValues?.length||0)>0||(i.items?.length||0)>0)?a.liveRegionRowsFound(r):""),l?d.jsxs("span",{className:"ogx-aria-live-status__cells",children:[" ",l]}):null,c?d.jsxs("span",{className:"ogx-aria-live-status__ai",children:[" ",c]}):null]})}function np({overlay:e}){const t=Le();return e?d.jsx("div",{className:"ogx__loading-overlay ogx__loading-overlay--over-rows ogx__loading-overlay--custom",children:e}):d.jsx("div",{className:"ogx__loading-overlay ogx__loading-overlay--over-rows",children:d.jsx("div",{className:"ogx__loading-bar",role:"progressbar","aria-label":t.loadingLabel})})}function op({error:e,onRetry:t}){const n=Le();if(!e)return null;const o=Ul(e);return d.jsxs("div",{className:"ogx-error-overlay","aria-live":"assertive",role:"alert",children:[d.jsxs("svg",{width:"56",height:"56",viewBox:"0 0 24 24",fill:"none",stroke:"var(--ogx-color-error)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("circle",{cx:"12",cy:"12",r:"10"}),d.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),d.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),d.jsx("div",{className:"ogx-error-overlay__title",children:n.errorOverlayTitle}),d.jsx("div",{className:"ogx-error-overlay__message",children:o}),t&&d.jsx("button",{type:"button",onClick:t,className:"ogx-button ogx-button--primary",children:n.errorOverlayRetry})]})}function rp(e){const{containerRef:t,className:n,autoHeight:o,height:r,style:i,hasRowSpanning:l,listView:c,headerFilterHeight:a,slots:u,slotProps:f,toolbarProps:p,aiAssistantPanel:b,orderedColumns:x,columnVisibilityModel:w,disableColumnReorder:g,handleColumnVisibilityModelChange:h,moveColumn:m,resetColumnOrder:C,listViewColumn:y,allRenderableRows:_,dataRows:v,pagination:k,effectivePaginationModel:M,currentPage:E,pageSizeOptions:I,columnsByField:L,paginationRowCount:N,handlePaginationModelChange:S,onRowsScrollEnd:F,toggleExpansion:T,showCellSelectionStats:P,apiRef:A,hasAggregation:G,isHierarchyEnabled:z,dataSourceError:H,filteredRowCount:Y,onRetry:K,...re}=e,{effectiveRowHeight:R,headerHeight:te,showHeaderFilters:ie,effectiveLoading:ce,columnsPanel:J,columnGroupingModel:se,ariaLabel:ne,pinnedTopRows:j,pinnedBottomRows:B,sortedUnpinnedRowCount:W,effectiveNoRowsLabel:ae,checkboxSelection:fe,paginationMode:Q,localeText:U,getRowIdOf:O,rowSelectionEnabled:$,disableMultipleRowSelection:D,cellSelection:V,aggregationModel:q,aggregationResult:oe,filterModel:Z,selectedRowIds:X,rowMetaMap:le,handleRowClick:we,onRowDoubleClick:ge,handleSelectionChange:he}=re,ee=u?.noRowsOverlay,ue=u?.loadingOverlay,Ce=ue?d.jsx(ue,{...f?.loadingOverlay}):void 0,be=ee?d.jsx(ee,{...f?.noRowsOverlay}):void 0,me=u?.footer,xe=ce&&_.length>0&&Q!=="infinite",ye=u?.toolbar,de=Rf(U),Pe=s.useMemo(()=>qo(de),[de]);return d.jsx(Qi.Provider,{value:Pe,children:d.jsxs("div",{ref:t,className:["ogx",n,o&&"ogx--auto-height",!o&&r===void 0&&i?.height===void 0&&"ogx--fill",l&&"ogx--row-spanning",c&&"ogx--list-view"].filter(Boolean).join(" "),style:{...i,height:r??i?.height,"--ogx-row-height":`${R}px`,"--ogx-header-height":`${te}px`,...ie?{"--ogx-header-filter-height":`${a}px`}:void 0},"aria-busy":ce,children:[ye&&p&&d.jsx(Zl.Provider,{value:J.toolbarHost,children:d.jsx(jf,{component:ye,toolbarProps:p})}),b.panelProps&&d.jsx(Zf,{panelProps:b.panelProps,slot:u?.aiAssistantPanel,slotProps:f?.aiAssistantPanel}),d.jsx(tg,{isOpen:J.standalonePanelOpen,containerRef:t,panelRef:J.standalonePanelRef,columns:x,columnVisibilityModel:w,disableColumnReorder:g,onClose:J.closeStandalonePanel,onColumnVisibilityChange:h,onColumnMove:m,onColumnOrderReset:C,columnGroupingModel:se}),c&&y&&d.jsx(ig,{ariaLabel:ne,allRenderableRows:_,dataRowCount:v.length,pinnedTopRowCount:j.length,pinnedBottomRowCount:B.length,unpinnedRowCount:W,pagination:k,effectivePaginationModel:M,currentPage:E,pageSizeOptions:I,selectedRowIds:X,listViewColumn:y,columnsByField:L,rowMetaMap:le,noRowsLabel:ae,rowHeight:R,checkboxSelection:fe,paginationMode:Q,serverRowCount:N,paginationSlot:u?.pagination,paginationSlotProps:f?.pagination,localeText:Vi(U),onRowClick:we,onRowDoubleClick:ge,onSelectionChange:he,onPaginationModelChange:S,onRowsScrollEnd:F,getRowId:O,multiselectable:$&&!D,selectable:$,onToggleExpansion:T,loading:ce,loadingOverlay:Ce,noRowsOverlay:be,showPaginationControls:!me}),!c&&d.jsx(Zg,{...re,loadingOverlay:Ce,noRowsOverlay:be}),V.enabled&&P&&d.jsx(Qg,{stats:V.stats,apiRef:A,slot:u?.cellSelectionStats,slotProps:f?.cellSelectionStats}),me&&d.jsx(me,{apiRef:A,aggregationModel:q,aggregationResult:G?oe:null,rowCount:z&&Q!=="server"?v.length:N,pagination:k,paginationModel:M,pageSizeOptions:I,onPaginationModelChange:S,...f?.footer}),!c&&!me&&k&&d.jsx(ep,{paginationSlot:u?.pagination,paginationSlotProps:f?.pagination,page:E,paginationModel:M,rowCount:N,pageSizeOptions:I,onPaginationModelChange:S,localeText:U}),d.jsx(tp,{loading:ce,error:H,noRowsLabel:ae,filteredRowCount:Y,dataRowCount:v.length,filterModel:Z,cellSelectionAnnouncement:V.announcement,aiAssistantAnnouncement:b.announcement}),xe&&d.jsx(np,{overlay:Ce}),d.jsx(op,{error:H,onRetry:K})]})})}function ip(e){const{baseColumns:t,pinnedColumns:n,hasGroupingColumn:o,groupingColDef:r,isTreeData:i,getTreeDataPath:l}=e,c=s.useMemo(()=>o?{...n,left:["__group__",...(n?.left??[]).filter(u=>u!=="__group__")]}:n,[o,n]);return{activeColumns:s.useMemo(()=>o?[{headerName:"Group",width:220,...i&&l?{valueGetter:({row:u})=>{const f=l(u);return f[f.length-1]}}:{},...r,field:"__group__",hideable:!1,sortable:!1,filterable:!1,pinnable:!1,exportable:!1},...t]:t,[r,o,i,l,t]),effectivePinnedColumns:c}}function lp(e){return e.id}function sp(e){const t=s.useCallback(r=>e.get(r)??r.id,[e]),n=s.useRef(t);s.useLayoutEffect(()=>{n.current=t});const o=s.useCallback(r=>n.current(r),[]);return{getRowIdOf:t,getRowIdOfInEvents:o}}function ap(e,t){s.useLayoutEffect(()=>{e&&(e.current=t.current)},[e,t])}function cp(e){const{hierarchyHandlers:t,pinnedTopRows:n,sortedUnpinnedRows:o,pinnedBottomRows:r,rowMetaMap:i,getRowId:l,hierarchyField:c,dataRows:a}=e,u=t?.getVisibleRows({expandAll:!0,labelField:c});if(!u)return[...n,...o,...r];const f=a?new Set(a):null;return u.filter(p=>!i.get(l(p))?.isGroupRow&&(!f||f.has(p)))}function dp(e,t){if(e===t)return!0;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;const o=e,r=t;return n.every(i=>Object.prototype.hasOwnProperty.call(t,i)&&Object.is(o[i],r[i]))}function up(e,t){return e===t?!0:e.length!==t.length?!1:e.every((n,o)=>dp(n,t[o]))}function fp(e){const[t,n]=s.useState(e),o=up(t,e);return o||n(e),o?t:e}function gp(e){const{rows:t,getRowId:n,rowMetaMap:o,columns:r,aggregationModel:i,aggregationResult:l,isSubtotalHidden:c}=e,a=Object.keys(i).length>0,u=new Map(r.map(x=>[x.field,x])),f=[],p=[],b=x=>{for(;p.length>0&&p[p.length-1].header.depth>=x;){const w=p.pop();a&&!c?.(w.id)&&f.push({type:"group-subtotal",depth:w.header.depth,groupField:w.header.groupField,groupValue:w.header.groupValue,groupLabel:w.header.groupLabel,aggregatedValues:Fn(w.leaves,i,u,"getGroupedExportRows")})}};for(const x of t){const w=n(x),g=o.get(w);if(!g?.isGroupFooter)if(g?.isGroupRow){const h=g.treeDepth??0;b(h);const m={type:"group-header",depth:h,groupField:g.groupingField,groupValue:g.groupingValue,groupLabel:g.groupLabel};f.push(m),p.push({id:w,header:m,leaves:[]})}else f.push({type:"leaf",depth:g?.treeDepth??p.length,row:x}),p.forEach(h=>h.leaves.push(x))}return b(0),a&&l&&f.push({type:"grand-total",depth:0,aggregatedValues:l}),f}function pp(e){const{apiRef:t}=e,n=s.useRef(e);s.useLayoutEffect(()=>{n.current=e}),s.useLayoutEffect(()=>{const o=()=>n.current;t.current.getAggregationResult=()=>o().hasAggregation?o().aggregationResult:null,t.current.getAggregationModel=()=>o().hasAggregation?o().aggregationModel:null,t.current.getGroupedExportRows=()=>{const{hasAggregation:r,aggregationResult:i,aggregationModel:l,isRowGrouping:c,rowGroupingHandlers:a,rowMetaMap:u,columns:f,getRowId:p,hierarchyField:b}=o();return c?gp({rows:a.getVisibleRows({expandAll:!0,labelField:b})??[],getRowId:p,rowMetaMap:u,columns:f,aggregationModel:l,aggregationResult:r&&a.rootAggregationPosition!==null?i:null,isSubtotalHidden:x=>a.aggregationPositions.get(x)===null}):null}},[t])}const hs="ogx--range-dragging",pt=32,hp=40,mp=300;function ms(e,t){if(!e||e.nodeType!==1)return null;const n=e.closest(".ogx__cell[data-field]");if(!n||n.closest(".ogx__viewport")!==t)return null;const o=n.closest(".ogx__detail-panel");if(o&&t.contains(o))return null;const r=n.closest('[role="row"][data-rowindex]');if(!r)return null;const i=Number(r.getAttribute("data-rowindex")),l=n.dataset.field;return!Number.isInteger(i)||!l?null:{rowIndex:i,field:l,element:n}}function br(e){const t=e.getSelection();t&&t.rangeCount>0&&t.removeAllRanges()}const ws=(e,t,n)=>Math.min(Math.max(e,t),n),Zn=e=>Math.min(hp,Math.max(2,Math.round(e/2)));function wp(e){process.env.NODE_ENV!=="production"&&console.warn(`[OpenGridX] Copying ${e} cells. For ranges this large, exportToCsv or exportToExcel is the better tool.`)}function bp(e){const{enabled:t,model:n,allRenderableRows:o,getRowId:r,navigationColumns:i,columnIndexMap:l,spanning:c,rowMetaMap:a,localeText:u,showStats:f}=e,p=t&&n.length>0?n[0]:null,b=s.useMemo(()=>t?i.filter(O=>qe(O.field)):[],[t,i]),x=s.useMemo(()=>{if(!c.hasColSpan&&!c.hasRowSpan)return;const{colspanMap:O,rowSpanningCaches:$,getSpanOrigin:D}=c;return{getSpanOrigin:D,getColSpan:(V,q)=>{const oe=O.get(V)?.[q];return oe&&!oe.spannedByColSpan?oe.cellProps.colSpan:1},getRowSpan:(V,q)=>$.spannedCells[V]?.[q]??1}},[c]),w=s.useMemo(()=>{if(!t)return null;const{rowIds:O,rowIndexById:$}=Yo(o,r,"renderable"),D=b.map(V=>V.field);return{rowIds:O,rowIndexById:$,fields:D,colIndexByField:new Map(D.map((V,q)=>[V,q])),spans:x}},[t,o,r,b,x]),g=s.useMemo(()=>p&&w?Wn(p,w):null,[p,w]),h=g!==null&&kt(g)>1,m=s.useMemo(()=>{if(!g||!h||!w)return null;const O=l.get(w.fields[g.left]),$=l.get(w.fields[g.right]);return O===void 0||$===void 0?null:{top:g.top,bottom:g.bottom,left:O,right:$}},[g,h,w,l]),C=s.useCallback(O=>je(O,a),[a]),y=s.useCallback((O,$,D)=>{if(w)for(let V=O.top;V<=O.bottom;V++){const q=o[V],oe=w.rowIds[V];if(!(!q||C(oe))){$(q,oe);for(let Z=O.left;Z<=O.right;Z++){const X=b[Z],le=x?.getSpanOrigin(oe,X.field);D(q,oe,X,le!=null&&(le.rowId!==oe||le.field!==X.field))}}}},[w,o,b,x,C]),_={...e,range:p,resolved:g,context:w,rangeColumns:b,forEachCell:y},v=s.useRef(_);s.useLayoutEffect(()=>{v.current=_});const k=s.useRef(null),M=s.useCallback(O=>{k.current=O},[]),E=s.useCallback(()=>{const{getPendingModel:O,model:$}=v.current;return O()??$},[]),I=s.useCallback(()=>{const{context:O,range:$,resolved:D,enabled:V}=v.current,q=V?E()[0]??null:null;return!q||!O?{range:null,resolved:null}:q===$?{range:q,resolved:D}:{range:q,resolved:Wn(q,O)}},[E]),L=s.useCallback((O,$)=>{if(!v.current.enabled)return;const D=O.length>1?O.slice(0,1):O;hc(D,E())||v.current.onModelChange(D,$)},[E]),N=s.useCallback((O,$,D)=>{L([{anchor:O,head:$}],D)},[L]),S=s.useCallback((O,$)=>{const{viewportRef:D,layout:V,rowHeight:q,pinnedTopRowCount:oe}=v.current,Z=D.current;Z&&(Nn(Z,O-oe,V.cumulativeHeights,V.pinnedBottomHeight,q),yo(Z,V.unpinnedColsWithWidth.findIndex(X=>X.field===$),V))},[]),F=s.useCallback((O,$,D,V)=>{const{context:q}=v.current,{range:oe,resolved:Z}=I();if(!q||V.id===null||!qe(V.field))return!1;const X=q.rowIndexById.get(V.id),le=q.colIndexByField.get(V.field);if(X===void 0||le===void 0)return!1;const we=oe&&Z&&dt(oe.anchor,{id:V.id,field:V.field})?{range:oe,resolved:Z}:null,ge=we?we.range.anchor:{id:V.id,field:V.field},he=we?.resolved??Wn({anchor:ge,head:ge},q);if(!he)return!1;const ee=wc(he,O,$,D,q.rowIds.length-1,q.fields.length-1);if(!ee)return!0;const ue={id:q.rowIds[ee.row],field:q.fields[ee.col]};return N(ge,ue,"keyboard"),S(ee.row,ue.field),!0},[I,N,S]),T=s.useCallback(()=>{const{range:O,resolved:$}=I();return!O||!$||kt($)<=1?!1:(N(O.anchor,O.anchor,"keyboard"),!0)},[I,N]),P=s.useCallback(()=>{const{context:O}=v.current;return!O||O.rowIds.length===0||O.fields.length===0?!1:(N({id:O.rowIds[0],field:O.fields[0]},{id:O.rowIds[O.rowIds.length-1],field:O.fields[O.fields.length-1]},"selectAll"),!0)},[N]),A=s.useCallback(()=>{const{context:O}=v.current,{range:$,resolved:D}=I();if(!O)return null;if(D)return D;if($)return null;const V=k.current;return!V||V.id===null||!qe(V.field)?null:Wn({anchor:{id:V.id,field:V.field},head:{id:V.id,field:V.field}},O)},[I]),G=s.useCallback(()=>{const O=A();if(!O)return null;const{rangeColumns:$,forEachCell:D}=v.current,V=kt(O);V>Cc&&wp(V);const q=[];if(D(O,we=>{q.push(we)},()=>{}),q.length===0)return null;const oe=$.slice(O.left,O.right+1),Z=v.current.context?.spans,X=v.current.getRowId;return pu(q,oe,Z?(we,ge)=>{const he=X(we),ee=Z.getSpanOrigin(he,ge.field);return ee!==null&&(ee.rowId!==he||ee.field!==ge.field)}:void 0)},[A]),z=s.useCallback(()=>{const{forEachCell:O}=v.current,{resolved:$}=I();if(!$)return[];const D=[];return O($,()=>{},(V,q,oe,Z)=>{Z||D.push({id:q,field:oe.field,value:Me(V,oe.field,oe)})}),D},[I]),H=s.useRef(null),Y=s.useRef(!1);s.useEffect(()=>()=>H.current?.stop(),[]);const K=s.useCallback((O,$,D)=>{const V=v.current.context;if(!V)return null;const q=O.ownerDocument;if(typeof q.elementFromPoint!="function")return null;const oe=ms(q.elementFromPoint($,D),O);if(!oe)return null;const Z=V.rowIds[oe.rowIndex];if(Z===void 0)return null;const X=qe(oe.field)?oe.field:V.fields[0];return X===void 0?null:{id:Z,field:X}},[]),re=s.useCallback((O,$)=>{const{context:D,layout:V,pinnedTopRowCount:q}=v.current,oe=V.cumulativeHeights;if(!D||oe.length===0||O<0)return null;let Z=0,X=oe.length-1;for(;Z<X;){const we=Z+X>>1;oe[we]>O?X=we:Z=we+1}const le=D.rowIds[Z+q];return le===void 0?null:{id:le,field:$}},[]),R=s.useRef(()=>{}),te=s.useCallback(O=>{const $=H.current,D=v.current.viewportRef.current;if(!$||!D)return;$.frame=0;const{layout:V}=v.current,q=D.getBoundingClientRect(),oe=D.clientWidth,Z=D.clientHeight,X=D.querySelector(":scope > .ogx__content > .ogx__sticky-top"),le=D.querySelector(":scope > .ogx__content > .ogx__sticky-bottom"),we=X?.querySelector(":scope > .ogx__header-wrap"),ge=X?X.getBoundingClientRect().bottom:q.top,he=Math.min(q.top+Z,le?le.getBoundingClientRect().top:q.top+Z),ee=we?we.getBoundingClientRect().bottom:ge;$.rtl===void 0&&($.rtl=Ye(D));const ue=$.rtl,Ce=ue?q.right-oe:q.left,be=V.pinnedSystemColumnsWidth+V.leftWidth,me=Ce+(ue?V.rightWidth:be),xe=Ce+oe-(ue?be:V.rightWidth),ye=ws($.x,Ce+1,Ce+oe-2);let de=$.y;(de<q.top||de>q.top+Z||de<ee)&&(de=ws(de,ge+1,Math.max(ge+1,he-2)));const Pe=typeof D.ownerDocument.elementFromPoint=="function",Ae=K(D,ye,de)??(Pe&&$.moved?re(de-q.top-(X?X.getBoundingClientRect().height:0)+D.scrollTop,$.head.field):null);if(Ae&&!dt(Ae,$.head)&&($.head=Ae,!$.moved&&!dt(Ae,$.anchor)&&($.moved=!0,v.current.containerRef.current?.classList.add(hs),br(D.ownerDocument)),$.onTrack||N($.anchor,Ae,"pointer")),$.onTrack&&$.onTrack($.head,$.x,$.y),!O)return;const Ee=$.y<ge||$.y>he||$.x<Ce||$.x>Ce+oe;if(!$.moved&&!Ee)return;let Fe=0,pe=0;$.y<ge+pt?Fe=-Zn(ge+pt-$.y):$.y>he-pt&&(Fe=Zn($.y-(he-pt))),$.x<me+pt?pe=-Zn(me+pt-$.x):$.x>xe-pt&&(pe=Zn($.x-(xe-pt)));const Se=Fe<0&&D.scrollTop>0||Fe>0&&D.scrollTop+Z<D.scrollHeight-1,_e=D.scrollWidth-oe,ve=ue?-_e:0,Ne=pe<0&&D.scrollLeft>ve||pe>0&&D.scrollLeft<ve+_e-1;!Se&&!Ne||(Se&&(D.scrollTop+=Fe),Ne&&(D.scrollLeft+=pe),$.frame=requestAnimationFrame(()=>R.current(!0)))},[K,re,N]);s.useLayoutEffect(()=>{R.current=te},[te]);const ie=s.useCallback((O,$,D,V,q,oe)=>{H.current?.stop();const Z=oe?"pointermove":"mousemove",X=oe?"pointerup":"mouseup",le=xe=>!oe||xe.pointerId===oe.pointerId,we=xe=>{const ye=H.current;if(!(!ye||!le(xe))){if(xe.buttons===0){ye.stop();return}ye.x=xe.clientX,ye.y=xe.clientY,ye.moved&&(xe.preventDefault(),br(q)),ye.frame||(ye.frame=requestAnimationFrame(()=>te(!0)))}},ge=xe=>{const ye=H.current;if(!ye||!le(xe))return;ye.x=xe.clientX,ye.y=xe.clientY,te(!1);const de=ye.moved;ye.stop(!1,xe.altKey),de&&br(q),de&&(Y.current=!0,setTimeout(()=>{Y.current=!1},0))},he=xe=>{le(xe)&&H.current?.stop()},ee=xe=>{xe.key!=="Escape"||!H.current||(xe.preventDefault(),xe.stopPropagation(),H.current.stop())},ue=q.defaultView,Ce=()=>H.current?.stop();let be=!1;const me={anchor:O,head:$,x:D,y:V,frame:0,moved:!1,onTrack:oe?.onTrack,stop:(xe=!0,ye=!1)=>{me.frame&&cancelAnimationFrame(me.frame),me.frame=0,q.removeEventListener(Z,we,!0),q.removeEventListener(X,ge,!0),oe&&(q.removeEventListener("pointercancel",he,!0),q.removeEventListener("keydown",ee,!0)),ue?.removeEventListener("blur",Ce),v.current.containerRef.current?.classList.remove(hs),H.current===me&&(H.current=null),be||(be=!0,oe&&oe.onEnd({cancelled:xe,altKey:ye}))}};H.current=me,q.addEventListener(Z,we,!0),q.addEventListener(X,ge,!0),oe&&(q.addEventListener("pointercancel",he,!0),q.addEventListener("keydown",ee,!0)),ue?.addEventListener("blur",Ce)},[te]),ce=s.useCallback(O=>{const $=v.current.viewportRef.current;if(!$||!v.current.enabled)return;const{start:D,x:V,y:q,pointerId:oe,onTrack:Z,onEnd:X}=O;ie(D,D,V,q,$.ownerDocument,{pointerId:oe,onTrack:Z,onEnd:X})},[ie]),J=s.useCallback(O=>{if(O.button!==0||O.defaultPrevented)return;const{context:$}=v.current;if(!$)return;const D=O.currentTarget,V=ms(O.target,D);if(!V||!qe(V.field)||O.target.closest?.(".ogx__cell-fill-handle")||V.element.classList.contains("ogx__cell--editing")||Mi(O.target))return;const q=$.rowIds[V.rowIndex];if(q===void 0)return;const oe={id:q,field:V.field};let Z=oe;if(O.shiftKey){const X=E()[0],le=k.current;X&&$.rowIndexById.has(X.anchor.id)&&$.colIndexByField.has(X.anchor.field)?Z=X.anchor:le&&le.id!==null&&qe(le.field)&&(Z={id:le.id,field:le.field}),O.preventDefault(),Y.current=!0;const we=D.ownerDocument;D.contains(we.activeElement)||D.focus({preventScroll:!0})}if(N(Z,oe,"pointer"),ie(Z,oe,O.clientX,O.clientY,D.ownerDocument),O.shiftKey){const X=H.current;X&&!dt(Z,oe)&&(X.moved=!0)}},[E,N,ie]),se=s.useCallback(O=>{Y.current&&(Y.current=!1,O.stopPropagation(),O.preventDefault())},[]),ne=g?g.right-g.left+1:0,j=g?g.bottom-g.top+1:0,B=u?.cellSelectionAnnouncement??Gi,W=h?B(j*ne,j,ne):"",[ae,fe]=s.useState("");s.useEffect(()=>{if(!t)return;const O=setTimeout(()=>fe(W),mp);return()=>clearTimeout(O)},[t,W]);const Q=s.useMemo(()=>{if(!f||!g||!h)return null;const O=[];y(g,()=>{},(D,V,q,oe)=>{oe||O.push(Me(D,q.field,q))});const $=O.filter(D=>typeof D=="number"&&!Number.isNaN(D));return{cellCount:kt(g),rowCount:g.bottom-g.top+1,columnCount:g.right-g.left+1,count:ct.count(O),numericCount:$.length,sum:$.length?ct.sum($):null,average:$.length?ct.avg($):null}},[f,g,h,y]),U=s.useMemo(()=>t?{extendSelection:F,collapseSelection:T,selectAllCells:P}:void 0,[t,F,T,P]);return{enabled:t,range:p,resolved:g,displayRange:m,hasRowSpan:c.hasRowSpan,handleMouseDown:t?J:void 0,handleClickCapture:t?se:void 0,extendSelection:F,collapseSelection:T,selectAllCells:P,keyboard:U,getCopyText:G,getSelectedCells:z,announcement:t?ae:"",stats:Q,reportFocus:M,setModel:L,getCurrentRange:I,startTrackedDrag:ce}}function xp(e){return s.useCallback(t=>{e.current?.classList.toggle("ogx--kb",t)},[e])}function Cp(e){const{ensureGridFocus:t,setKeyboardMode:n,setFocusedCell:o,getRowId:r,onCellClick:i}=e,l=s.useCallback(a=>{t(),n(!1),o({id:r(a.row),field:a.field,rowIndex:a.rowIndex}),i?.(a)},[i,n,o,t,r]),c=s.useCallback(a=>{t(),o({id:null,field:a}),n(!1)},[t,o,n]);return{handleCellClick:l,handleHeaderClick:c}}function yp(){const[e,t]=s.useState(!1),[n,o]=s.useState(!1),r=s.useRef(null),i=s.useRef(0),[l,c]=s.useState(0),[a,u]=s.useState(!1),f=s.useMemo(()=>({registerColumnsPanel:()=>(i.current+=1,()=>{i.current-=1}),registerFiltersPanel:()=>(c(h=>h+1),()=>c(h=>h-1))}),[]),p=s.useCallback(()=>u(!0),[]),b=s.useCallback(()=>u(!1),[]),x=s.useCallback(()=>{i.current>0?t(!0):o(!0)},[]),w=s.useCallback(()=>t(!1),[]),g=s.useCallback(()=>o(!1),[]);return s.useEffect(()=>{if(!n)return;function h(C){r.current&&!r.current.contains(C.target)&&o(!1)}function m(C){C.key==="Escape"&&o(!1)}return document.addEventListener("mousedown",h),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",h),document.removeEventListener("keydown",m)}},[n]),{toolbarHost:f,toolbarPanelRequested:e,closeToolbarPanel:w,standalonePanelOpen:n,closeStandalonePanel:g,standalonePanelRef:r,openColumnsPanel:x,toolbarFiltersRequested:a,closeToolbarFiltersPanel:b,openFiltersPanel:l>0?p:void 0}}const vp=Symbol.for("opengridx.ai.validated");function Sp(e){return typeof e=="object"&&e!==null&&e[vp]===!0}const Qn=["filter","sort","grouping","aggregation","pivot","columnVisibility"],xr={filter:"filterModel",sort:"sortModel",grouping:"rowGroupingModel",aggregation:"aggregationModel",pivot:"pivotModel",columnVisibility:"columnVisibilityModel"};function bs(e){return Qn.map(t=>xr[t]).filter(t=>e[t]!==void 0)}function _p(e,t){const n={},o=[];for(const r of Qn){const i=xr[r];e[i]!==void 0&&(t.includes(r)?Object.assign(n,{[i]:e[i]}):o.push({path:i,message:"Part not allowed"}))}return{state:n,errors:o}}function kp(e,t){const n=e[t];if(Array.isArray(n))return n.length===0;if(t==="filterModel"){const o=e.filterModel;return!o||(o.items??[]).length===0&&(o.quickFilterValues??[]).length===0}if(t==="pivotModel"){const o=e.pivotModel;return!o||o.rowFields.length===0&&o.columnFields.length===0&&o.valueFields.length===0}return typeof n=="object"&&n!==null&&Object.keys(n).length===0}function Ep(e){let t=e.length;for(const n of[".","["]){const o=e.indexOf(n);o>=0&&o<t&&(t=o)}return e.slice(0,t)}function Mp(e,t){const n=new Set(t.map(r=>Ep(typeof r.path=="string"?r.path:""))),o={};for(const r of bs(e))n.has(r)&&kp(e,r)||Object.assign(o,{[r]:e[r]});return o}function Lp(e,t){const n={};for(const o of bs(e))Object.assign(n,{[o]:t[o]});return n}function xs(e,t){const n={};for(const o of Qn.map(r=>xr[r]))!(o in t)&&e[o]===void 0||(e[o]===void 0?Object.assign(n,{[o]:t[o]}):o==="columnVisibilityModel"?n.columnVisibilityModel={...t.columnVisibilityModel,...e.columnVisibilityModel}:Object.assign(n,{[o]:e[o]}));return n}function Cr(e,t){t.filterModel&&e.setFilterModel(t.filterModel),t.sortModel&&e.setSortModel(t.sortModel),t.rowGroupingModel&&e.setRowGroupingModel(t.rowGroupingModel),t.aggregationModel&&e.setAggregationModel(t.aggregationModel),t.pivotModel&&e.setPivotModel(t.pivotModel),t.columnVisibilityModel&&e.setColumnVisibilityModel(t.columnVisibilityModel)}function Cs(e){return Array.isArray(e)?e.map(Cs).join(", "):e instanceof Date?e.toISOString().slice(0,10):e==null?"":String(e)}function ys(e,t){return"items"in e?`(${e.items.map(n=>ys(n,t)).join(` ${e.logicOperator} `)})`:[t(e.field),e.operator,Cs(e.value)].filter(Boolean).join(" ")}const Ap={sum:"Sum",avg:"Average",count:"Count",min:"Min",max:"Max",unique:"Unique"};function vs(e,t){const n=[],{filterModel:o,sortModel:r,rowGroupingModel:i,aggregationModel:l,pivotModel:c,columnVisibilityModel:a}=e;if(o){const u=o.items??[];u.forEach((p,b)=>n.push({id:`filter:${b}`,part:"filter",label:ys(p,t)}));const f=o.quickFilterValues??[];f.length>0&&n.push({id:"filter:quick",part:"filter",label:`Search: ${f.join(" ")}`}),u.length===0&&f.length===0&&n.push({id:"filter:clear",part:"filter",label:"No filters"})}if(r&&(r.forEach((u,f)=>n.push({id:`sort:${f}`,part:"sort",label:`Sort: ${t(u.field)}, ${u.sort==="desc"?"descending":"ascending"}`})),r.length===0&&n.push({id:"sort:clear",part:"sort",label:"No sorting"})),i&&(i.forEach((u,f)=>n.push({id:`grouping:${f}`,part:"grouping",label:`Group: ${t(u)}`})),i.length===0&&n.push({id:"grouping:clear",part:"grouping",label:"No grouping"})),l){const u=Object.keys(l);u.forEach(f=>{const p=l[f];n.push({id:`aggregation:${f}`,part:"aggregation",label:`${Ap[p]??p}: ${t(f)}`})}),u.length===0&&n.push({id:"aggregation:clear",part:"aggregation",label:"No summaries"})}if(c){const u=[...c.rowFields,...c.columnFields,...c.valueFields.map(f=>f.field)];n.push({id:"pivot",part:"pivot",label:u.length>0?`Pivot: ${u.map(t).join(", ")}`:"No pivot"})}if(a)for(const u of Object.keys(a))n.push({id:`columnVisibility:${u}`,part:"columnVisibility",label:`${a[u]?"Show":"Hide"}: ${t(u)}`});return n}function Pp(e,t){const n={...e},o=t.indexOf(":"),r=o<0?t:t.slice(0,o),i=o<0?"":t.slice(o+1),l=Number(i);if(r==="filter"&&n.filterModel){const c={...n.filterModel};i==="quick"?delete c.quickFilterValues:i==="clear"?c.items=[]:c.items=(c.items??[]).filter((a,u)=>u!==l),(c.items??[]).length===0&&(c.quickFilterValues??[]).length===0?delete n.filterModel:n.filterModel=c}else if(r==="sort"&&n.sortModel)n.sortModel=n.sortModel.filter((c,a)=>a!==l),(n.sortModel.length===0||i==="clear")&&delete n.sortModel;else if(r==="grouping"&&n.rowGroupingModel)n.rowGroupingModel=n.rowGroupingModel.filter((c,a)=>a!==l),(n.rowGroupingModel.length===0||i==="clear")&&delete n.rowGroupingModel;else if(r==="aggregation"&&n.aggregationModel){const c={...n.aggregationModel};delete c[i],Object.keys(c).length===0?delete n.aggregationModel:n.aggregationModel=c}else if(r==="columnVisibility"&&n.columnVisibilityModel){const c={...n.columnVisibilityModel};delete c[i],Object.keys(c).length===0?delete n.columnVisibilityModel:n.columnVisibilityModel=c}else r==="pivot"&&delete n.pivotModel;return n}const Ip=[],eo=[],Np="The reply was not validated";function Fp(){return typeof window<"u"&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window)}function Tp(e){return typeof e=="object"&&e!==null&&e.name==="AbortError"}const Op={kind:"none"},Dp={kind:"thinking"},yr={kind:"stopped"},$p={kind:"undone"},Gp={kind:"removed"},Hp={kind:"notValidated"};function Bp(e,t){switch(e.kind){case"none":return"";case"thinking":return t.aiAssistantThinking;case"stopped":return t.aiAssistantStopped;case"undone":return t.aiAssistantUndone;case"removed":return t.aiAssistantChangeRemoved;case"applied":return t.aiAssistantApplied(e.count,e.ignored);case"notValidated":return t.aiAssistantNotValidated;case"failed":{const{error:n}=e;return t.aiAssistantFailed(n instanceof Error&&n.message?n.message:t.aiAssistantUnknownError)}}}function Ss(e,t,n){if(!e)return;const o=ze(()=>e(t));!o.ok&&process.env.NODE_ENV!=="production"&&console.warn(`[OpenGridX] ${n} threw.`,o.error)}function Wp(e){const{apiRef:t,options:n,columns:o,localeText:r}=e,i=s.useMemo(()=>qo(r),[r]),l=!!n,[c,a]=s.useState(!1),[u,f]=s.useState("idle"),[p,b]=s.useState(Op),x=Bp(p,i),[w,g]=s.useState(null),[h,m]=s.useState(eo),[C,y]=s.useState(null),[_,v]=s.useState([]),k=s.useRef(null),M=s.useRef(null),E=s.useRef({params:e,applied:C,history:_,open:c});s.useLayoutEffect(()=>{E.current={params:e,applied:C,history:_,open:c}});const I=s.useMemo(()=>{const R=new Map(o.map(te=>[te.field,te.headerName||te.field]));return te=>R.get(te)??te},[o]),L=s.useMemo(()=>C?vs(C.state,I):[],[C,I]),N=s.useCallback(()=>{const R=k.current;k.current=null,R&&R.abort()},[]);s.useEffect(()=>N,[N]);const S=s.useCallback(R=>{if(!E.current.params.options)return;const te=typeof document>"u"?null:document.activeElement;M.current=R??(te instanceof HTMLElement?te:null),a(!0)},[]),F=s.useCallback(()=>{k.current&&(N(),f("stopped"),b(yr)),a(!1);const R=M.current;M.current=null,R&&R.isConnected&&R.focus()},[N]),T=s.useCallback(R=>{E.current.open?F():S(R)},[S,F]),P=s.useCallback((R,te)=>{f("error"),b(R),g(null),m(eo),Ss(E.current.params.onError,te,"onAiAssistantError")},[]),A=s.useCallback((R,te)=>{const{params:ie}=E.current;if(!(typeof te=="object"&&te!==null)||!Sp(te.state)){process.env.NODE_ENV!=="production"&&console.warn("[OpenGridX] aiAssistant: the onPrompt result was not applied because its state was not validated. Return the result of createGridAiPromptHandler, or pass the model reply through validateGridAiState (from @opencorestack/opengridx/ai) and return its state."),P(Hp,new Error(Np));return}const J=_p(te.state,ie.options?.parts??Qn),se=[...Array.isArray(te.errors)?te.errors:[],...J.errors],ne=Mp(J.state,se),j=t.current,B=Lp(ne,j.getGridAiState());Cr(j,xs(ne,B)),y({state:ne,previous:B}),m(se),g(typeof te.message=="string"&&te.message?te.message:null),v(W=>[...W,{prompt:R,applied:ne}]),f("applied"),b({kind:"applied",count:vs(ne,W=>W).length,ignored:se.length}),Ss(ie.onApply,te,"onAiAssistantApply")},[t,P]),G=s.useCallback(R=>{const te=R.trim(),{params:ie,history:ce}=E.current,J=ie.options?.onPrompt;if(!te||!J)return;N();const se=new AbortController;k.current=se,f("running"),b(Dp),g(null),m(eo);const ne={currentState:t.current.getGridAiState(),history:ce,signal:se.signal},j=ze(()=>J(te,ne));(j.ok?Promise.resolve(j.value):Promise.reject(j.error)).then(W=>{k.current===se&&(k.current=null,A(te,W))},W=>{if(k.current===se){if(k.current=null,se.signal.aborted||Tp(W)){f("stopped"),b(yr);return}P({kind:"failed",error:W},W)}})},[t,N,A,P]),z=s.useCallback(()=>{k.current&&(N(),f("stopped"),b(yr))},[N]),H=s.useCallback(()=>{const R=E.current.applied;R&&(Cr(t.current,R.previous),y(null),m(eo),g(null),f("idle"),b($p))},[t]),Y=s.useCallback(R=>{const te=E.current.applied;if(!te)return;const ie=Pp(te.state,R);Cr(t.current,xs(ie,te.previous)),y({state:ie,previous:te.previous}),b(Gp)},[t]);s.useLayoutEffect(()=>{const R=t.current;R.openAiAssistant=()=>S(),R.closeAiAssistant=()=>{E.current.open&&F()}},[t,S,F]);const K=l&&c,re=s.useMemo(()=>!K||!n?null:{status:u,statusText:x,message:w,errors:h,chips:L,history:_,suggestions:n.suggestions??Ip,placeholder:n.placeholder??i.aiAssistantPlaceholder,voiceAvailable:n.voice!==!1&&Fp(),canUndo:C!==null,submit:G,stop:z,undo:H,removeChip:Y,close:F},[K,n,u,x,w,h,L,_,C,G,z,H,Y,F,i]);return{enabled:l,open:K,openPanel:S,togglePanel:T,closePanel:F,panelProps:re,announcement:l?x:""}}function Vp(e){const{toolbar:t,toolbarSlotProps:n,apiRef:o,orderedColumns:r,baseColumns:i,aggregationModel:l,onAggregationModelChange:c,pivotMode:a,pivotModelProp:u,onPivotModelChangeProp:f,pivotModel:p,onPivotModelChange:b,filterModel:x,onFilterModelChange:w,columnVisibilityModel:g,onColumnVisibilityModelChange:h,disableColumnReorder:m,columnGroupingModel:C,moveColumn:y,resetColumnOrder:_,forceColumnsOpen:v,onColumnsPanelClose:k,aiAssistantEnabled:M=!1,aiAssistantOpen:E=!1,onAiAssistantToggle:I,aiAssistantLabel:L,forceFiltersOpen:N,onFiltersPanelClose:S}=e;return s.useMemo(()=>t?{apiRef:o,columns:r,baseColumns:i,aggregationModel:l,onAggregationModelChange:c,...a||u||f?{pivotModel:p,onPivotModelChange:b}:{},filterModel:x,onFilterModelChange:w,columnVisibilityModel:g,onColumnVisibilityModelChange:h,onColumnReorder:m?void 0:(T,P)=>{Qo(C,T,P)&&y(T,P)},onColumnOrderReset:m?void 0:_,forceColumnsOpen:v,onColumnsPanelClose:k,...M&&I?{onAiAssistantToggle:I,aiAssistantOpen:E,...L?{aiAssistantLabel:L}:{}}:{},forceFiltersOpen:N,onFiltersPanelClose:S,...n}:null,[t,m,y,_,r,o,i,l,c,a,u,f,p,b,x,w,g,h,v,k,n,C,M,E,I,L,N,S])}function zp(e){const{apiRef:t,containerRef:n,aiAssistant:o,toolbar:r,localeText:i}=e,l=yp();pd(n);const c=Wp({apiRef:t,localeText:i,...o}),a=Vp({...r,apiRef:t,forceColumnsOpen:l.toolbarPanelRequested,onColumnsPanelClose:l.closeToolbarPanel,aiAssistantEnabled:c.enabled,aiAssistantOpen:c.open,onAiAssistantToggle:c.togglePanel,aiAssistantLabel:i?.aiAssistantButton,forceFiltersOpen:l.toolbarFiltersRequested,onFiltersPanelClose:l.closeToolbarFiltersPanel});return{columnsPanel:l,aiAssistantPanel:c,toolbarProps:a}}function Rp(e){const{rows:t,columns:n,getRowId:o,rowHeight:r,headerHeight:i,wrapHeaderText:l=!1,headerFilters:c=!1,headerFilterHeight:a=Wc,autoHeight:u=!1,density:f,height:p,className:b="",style:x,ariaLabel:w,loading:g=!1,checkboxSelection:h=!1,disableRowSelectionOnClick:m=!1,disableMultipleRowSelection:C=!1,disableClipboardCopy:y=!1,cellSelection:_=!1,cellSelectionModel:v,onCellSelectionModelChange:k,showCellSelectionStats:M=!1,rowSelectionModel:E,onRowSelectionModelChange:I,onRowClick:L,onRowDoubleClick:N,onCellClick:S,filterModel:F,onFilterModelChange:T,sortModel:P,onSortModelChange:A,pagination:G=!1,paginationModel:z,onPaginationModelChange:H,pageSizeOptions:Y=[10,25,50,100],pinnedColumns:K,onPinnedColumnsChange:re,pinnedRows:R,getDetailPanelContent:te,getDetailPanelHeight:ie,detailPanelExpandedRowIds:ce,onDetailPanelExpandedRowIdsChange:J,pinCheckboxColumn:se=!0,pinExpandColumn:ne=!0,disableColumnReorder:j=!1,columnOrder:B,onColumnOrderChange:W,onColumnOrderModelChange:ae,rowReordering:fe=!1,onRowOrderChange:Q,treeData:U=!1,getTreeDataPath:O,defaultGroupingExpansionDepth:$,groupingColDef:D,rowGroupingModel:V,onRowGroupingModelChange:q,aggregationModel:oe,onAggregationModelChange:Z,getAggregationPosition:X,isCellEditable:le,processRowUpdate:we,onProcessRowUpdateError:ge,dataSource:he,multiSort:ee=!1,sortingMode:ue="client",filterMode:Ce="client",paginationMode:be="client",rowCount:me,slots:xe,slotProps:ye,pivotMode:de=!1,pivotModel:Pe,onPivotModelChange:Ie,onRowsScrollEnd:Ae,initialState:Ee,onStateChange:Fe,columnVisibilityModel:pe,onColumnVisibilityModelChange:Se,listView:_e=!1,listViewColumn:ve,columnGroupingModel:Ne,noRowsLabel:$e="No Data",localeText:Ue,apiRef:ht,overscanRowCount:At=3,aiAssistant:Pt,onAiAssistantApply:Ve,onAiAssistantError:ro}=e,xn=fp(n),sm=Ue?.noRowsLabel??$e,It=Lc({initialState:Ee,sortModel:P,onSortModelChange:A,filterModel:F,onFilterModelChange:T,aggregationModel:oe,onAggregationModelChange:Z,rowGroupingModel:V,onRowGroupingModelChange:q,columnVisibilityModel:pe,onColumnVisibilityModelChange:Se,pinnedColumns:K,onPinnedColumnsChange:re,pivotModel:Pe,onPivotModelChange:Ie,paginationModel:z,onPaginationModelChange:H,pageSizeOptions:Y,rowSelectionModel:E,onRowSelectionModelChange:I,density:f,cellSelectionModel:v,onCellSelectionModelChange:k}),{sortModel:mt,handleSortModelChange:am,filterModel:Nt,handleFilterModelChange:Xs,aggregationModel:it,handleAggregationModelChange:cm,columnVisibilityModel:Ft,handleColumnVisibilityModelChange:_r,pinnedColumns:kr,handlePinnedColumnsChange:dm,currentPivotModel:Ys,handlePivotModelChange:um,effectivePaginationModel:lt,handlePaginationModelChange:Er,selectedRowIds:fm,handleRowSelectionModelChange:gm,density:Js,rowGroupingModel:Zs}=It,Cn=zf({rows:t,columns:xn,pivotMode:de,pivotModel:Ys,filterModel:Nt,sortModel:mt,hasDataSource:!!he,hierarchyRequested:U||Zs.length>0}),wt=Cn.isActive,Mr=c&&!wt,{rowReordering:yn,hierarchyRowGroupingModel:pm,isTreeDataRequested:hm,isTreeData:io,isRowGrouping:Qt,isHierarchyEnabled:lo,hasGroupingColumn:mm,pagination:bt,listView:Lr}=_c({rowGroupingModel:Zs,treeData:U,hasTreeDataPath:!!O,isPivotActive:wt,rowReordering:fe,hasGroupingColDef:!!D,pagination:G,paginationMode:be,listView:_e,hasListViewColumn:!!ve}),{rowHeight:Tt,headerHeight:Qs}=Fc({rowHeight:r,headerHeight:i,density:Js}),wm=Cn.rows,bm=Cn.columns,{activeColumns:xt,effectivePinnedColumns:Ar}=ip({baseColumns:bm,pinnedColumns:kr,hasGroupingColumn:mm,groupingColDef:D,isTreeData:io,getTreeDataPath:O}),Pr=_d(xt,Ft),[xm,Cm]=Bf(it),Ot=s.useRef(null),vn=s.useRef(null),ea=!wt&&o||lp,Ir=xp(Ot),Nr=Ad({rows:wm,getRowId:ea,columns:xt,rowHeight:Tt,headerHeight:Qs,columnVisibilityModel:Ft,initialState:e.initialState,syncRows:!he}),{state:Ge,apiRef:Sn,setRows:ym,replaceRows:vm,setColumns:Sm,setDimensions:_m,setDataSourceLoading:km,setDataSourceError:Em,setRowCount:Mm}=Nr,{getRowIdOf:He,getRowIdOfInEvents:Lm}=sp(Ge.rows.idByRow);ap(ht,Sn);const Am=Ge.dataSource.loading,Fr=g||Am,so=Ge.rows.rows,{treeDataHandlers:ao,rowGroupingHandlers:Tr,activeHierarchyHandlers:en,rowMetaMap:Xe}=jd({rows:so,getRowId:He,getTreeDataPath:O,isTreeDataRequested:hm,isTreeData:io,columns:xt,rowGroupingModel:pm,isRowGrouping:Qt,aggregationModel:it,defaultGroupingExpansionDepth:$,filterModel:Nt,sortModel:mt,getAggregationPosition:X,columnLookup:Pr,filterMode:Ce,sortingMode:ue}),{editCommitChannel:Pm,batchEdit:Im,editingHandlers:Or}=Mf({rowsLookup:Ge.rows.idRowsLookup,rows:so,getRowId:He,columns:xt,processRowUpdate:we,onProcessRowUpdateError:ge,replaceRows:vm}),Dr=hd({selectedRowIds:fm,rowsLookup:Ge.rows.idRowsLookup,rowMetaMap:Xe,enabled:!he&&!wt&&be==="client"&&Ce==="client",onSelectionModelChange:gm}),ta=$f({dataSource:he,sortModel:mt,filterModel:Nt,paginationModel:lt,paginationMode:be,sortingMode:ue,filterMode:Ce,aggregationModel:it,rowGroupingActive:Qt,getRowId:ea,setRows:ym,setRowCount:Mm,setDataSourceLoading:km,setDataSourceError:Em,onAggregationResults:Cm,onPaginationModelChange:Er});Hf({enabled:io&&!!he,treeNodes:ao.treeNodes,isGroupExpanded:ao.isGroupExpanded,getNodePath:ao.getNodePath,toggleExpansion:ao.toggleExpansion,fetchChildren:ta.fetchChildren});const{hasDetailPanel:_n,expandedRowIds:$r,handleDetailPanelToggle:na,detailPanelHeights:Nm,reportDetailPanelHeight:Fm}=id({hasDetailPanel:!!te,controlledExpandedRowIds:ce,onDetailPanelExpandedRowIdsChange:J,rowMetaMap:Xe}),{effectiveColumns:oa,hierarchyField:Gr,orderedColumns:Hr,visibleOrderedColumns:ra,renderOrderedColumns:Tm,navigationColumns:co,columnIndexMap:Br,columnWidths:Wr,effectiveColumnOrder:Om,columnReorderHandlers:Dm,moveColumn:ia,resetColumnOrder:la,handleColumnResize:sa}=od({activeColumns:xt,isHierarchyEnabled:lo,isRowGrouping:Qt,isTreeData:io,activeHierarchyHandlers:en,columnVisibilityModel:Ft,columnOrder:B,onColumnOrderChange:W,onColumnOrderModelChange:ae,disableColumnReorder:j,pivotMode:wt,checkboxSelection:h,hasDetailPanel:_n,rowReordering:yn,initialState:Ee,setColumns:Sm,pinnedColumns:Ar,getRowId:Lm,aggregationModel:it,groupingRows:Qt?Tr.groupingRows:void 0});ad({onStateChange:Fe,sortModel:mt,filterModel:Nt,effectivePaginationModel:lt,columnWidths:Wr,effectiveColumnOrder:Om,columnVisibilityModel:Ft,pinnedColumns:kr,density:Js});const Vr=Oc({effectiveRows:so,activeHierarchyHandlers:en,filterMode:Ce,filterModel:Cn.pipelineFilterModel,sortModel:Cn.pipelineSortModel,sortingMode:ue,pagination:bt,paginationMode:be,effectivePaginationModel:lt,pinnedRows:R,getRowId:He,columnLookup:Pr,hierarchyField:Gr}),{filteredRows:aa,dataRows:uo,pinnedTopRows:Ke,pinnedBottomRows:st,sortedUnpinnedRows:Ct,paginatedUnpinnedRows:fo,allRenderableRows:kn}=Vr,zr=bt?fo:Ct;kd({paginationModel:lt,currentPage:Vr.currentPage,enabled:bt&&!Fr&&Ct.length>0,onPaginationModelChange:Er});const ca=Tc({paginationMode:be,hasDataSource:!!he,dataSourceRowCount:Ge.pagination.rowCount,rowCountProp:me,clientRowCount:Ct.length}),{rowSelection:da,handleRowClick:ua,handleSelectionChange:fa}=Sd({controlledState:It,interactions:{dataRows:uo,getRowId:He,isPivotActive:wt,disableRowSelectionOnClick:m,isHierarchyEnabled:lo,rowMetaMap:Xe,activeHierarchyHandlers:en,onRowClick:L},api:{apiRef:Nr.apiRef,multiSort:ee,selectedRowIds:Dr,disableMultipleRowSelection:C,isSyntheticRowId:Ur=>je(Ur,Xe),getVisibleRows:()=>[...Ke,...zr,...st],getAllFilteredRows:()=>cp({hierarchyHandlers:en,pinnedTopRows:Ke,sortedUnpinnedRows:Ct,pinnedBottomRows:st,rowMetaMap:Xe,getRowId:He,hierarchyField:Gr,dataRows:uo}),visibleColumns:Tm}}),$m=Pd({rows:so,indexById:Ge.rows.indexById,onRowOrderChange:Q,rowReordering:yn}),{aggregationResult:ga,isLoading:Gm}=Yl({rows:uo,columns:xt,aggregationModel:wt?Ga:it,isServerSide:zl({dataSource:he,paginationMode:be,sortingMode:ue,filterMode:Ce}),dataSource:he,filterModel:Nt,sortModel:mt,serverAggregationResults:xm}),Rr=Object.keys(it).length>0&&!wt;pp({apiRef:Sn,hasAggregation:Rr,aggregationResult:ga,aggregationModel:it,isRowGrouping:Qt,rowGroupingHandlers:Tr,rowMetaMap:Xe,columns:xt,getRowId:He,hierarchyField:Gr});const Be=Da({rowHeight:Tt,pagination:bt,paginatedUnpinnedRows:fo,sortedUnpinnedRows:Ct,expandedRowIds:$r,getDetailPanelHeight:ie,detailPanelHeights:Nm,pinnedTopRowsLength:Ke.length,pinnedBottomRowsLength:st.length,pinnedTopRows:Ke,pinnedBottomRows:st,visibleOrderedColumns:ra,pinnedColumns:Ar,columnWidths:Wr,viewportWidth:Ge.dimensions.viewportWidth||1e3,checkboxSelection:h,hasDetailPanel:_n,rowReordering:yn,pinCheckboxColumn:se,pinExpandColumn:ne,paginationMode:be,isLoading:Ge.dataSource.loading,pageSize:lt.pageSize,getRowId:He}),En=If({pinnedTopRows:Ke,centerRows:zr,pinnedBottomRows:st,columns:ra,leftPinnedColumns:Be.leftPinnedCols,unpinnedColumns:Be.unpinnedColsWithWidth,rightPinnedColumns:Be.rightPinnedCols,expandedRowIds:_n?$r:void 0,rowMetaMap:Xe,getRowId:He}),pa=s.useMemo(()=>[...Be.leftPinnedCols,...Be.unpinnedColsWithWidth,...Be.rightPinnedCols],[Be.leftPinnedCols,Be.unpinnedColsWithWidth,Be.rightPinnedCols]),Mn=bp({enabled:_&&!Lr,model:It.cellSelectionModel,onModelChange:It.handleCellSelectionModelChange,getPendingModel:It.getPendingCellSelectionModel,allRenderableRows:kn,getRowId:He,navigationColumns:co,columnIndexMap:Br,spanning:En,rowMetaMap:Xe,layout:Be,rowHeight:Tt,pinnedTopRowCount:Ke.length,viewportRef:vn,containerRef:Ot,localeText:Ue,showStats:M}),Hm=_f({apiRef:Sn,containerRef:Ot,viewportRef:vn,copyColumns:pa,getRowId:He,disableClipboardCopy:y,getCellRangeCopyText:Mn.enabled?Mn.getCopyText:void 0,layout:Be,rowHeight:Tt,orderedColumns:Hr,onColumnResize:sa}),{handleScroll:Bm,setViewportElement:Wm,maxContentHeight:Vm,virtualization:Dt}=wf({viewport:{onRowsScrollEnd:Ae,overscanRowCount:At,autoHeight:u,setDimensions:_m},viewportRef:vn,containerRef:Ot,layout:Be,viewportWidth:Ge.dimensions.viewportWidth,viewportHeight:Ge.dimensions.viewportHeight,virtualization:{autoHeight:u,rowReordering:yn,hasDetailPanel:_n,checkboxSelection:h,pinCheckboxColumn:se,pinExpandColumn:ne}}),{handleSort:ha,handleSortAdd:ma}=Cd({sortModel:mt,onSortModelChange:am}),wa=h||!m,{focusedCell:ba,setFocusedCell:xa,viewportTabIndex:zm,ensureGridFocus:Rm,handleFocus:Um,handleBlur:Km,handleKeyDown:jm,handleMouseDownCapture:qm}=Sc({allRenderableRows:kn,navigationColumns:co,checkboxSelection:h,selectedRowIds:Dr,handleSelectionChange:fa,handleDetailPanelToggle:na,editingHandlers:Or,setKeyboardMode:Ir,sortModel:mt,handleSort:ha,handleSortAdd:ma,multiSort:ee,isCellEditable:le,pagination:bt,pageSize:lt.pageSize,virtualization:Dt,viewportRef:vn,pinnedTopRowCount:Ke.length,getRowId:He,rowMetaMap:Xe,getSpanOrigin:En.getSpanOrigin,onRowActivate:ua,toggleRowExpansion:en?.toggleExpansion,handleSelectAll:da.selectAll,rowSelectionEnabled:wa,multipleRowSelectionEnabled:!C,pinCheckboxColumn:se,pinExpandColumn:ne,rowHeight:Tt,cellSelection:Mn.keyboard,headerFilters:Mr}),{handleCellClick:Xm,handleHeaderClick:Ym}=Cp({ensureGridFocus:Rm,setKeyboardMode:Ir,setFocusedCell:xa,getRowId:He,onCellClick:S}),Jm=cf({props:e,apiRef:Sn,containerRef:Ot,viewportRef:vn,selection:Mn,model:It.cellSelectionModel,getPendingModel:It.getPendingCellSelectionModel,focusedCell:ba,setFocusedCell:xa,allRenderableRows:kn,getRowId:He,navigationColumns:co,columnIndexMap:Br,isCellEditable:le,rowMetaMap:Xe,getSpanOrigin:En.getSpanOrigin,isEditing:Or.editingCell!==null,batchEdit:Im,channel:Pm,layout:Be,rowHeight:Tt,pinnedTopRowCount:Ke.length}),{handleHideColumn:Zm,handlePinColumn:Qm}=yd({columnVisibilityModel:Ft,onColumnVisibilityModelChange:_r,pinnedColumns:kr,onPinnedColumnsChange:dm}),{ariaRows:ew,spanRowWindow:tw,visibleRows:Ca,renderColumns:nw}=tu({aria:{columnGroupingModel:Ne,headerFilterRow:Mr,pinnedTopCount:Ke.length,pinnedBottomCount:st.length,pagination:bt,paginationMode:be,paginationModel:lt,paginationRowCount:ca,paginatedUnpinnedRowCount:fo.length,sortedUnpinnedRowCount:Ct.length},spanning:En,virtualization:Dt,layout:Be,pinnedTopRows:Ke,pinnedBottomRows:st,paginatedUnpinnedRows:fo,sortedUnpinnedRows:Ct,pagination:bt,getRowId:He});fd({paginationRequested:G,isRowGrouping:Qt,autoHeight:u,viewportHeight:Ge.dimensions.viewportHeight,renderedRowCount:Ca.length,totalRowCount:Ke.length+zr.length+st.length,pinnedRowsIgnored:lo&&!!(R?.top?.length||R?.bottom?.length),scrollHeight:Dt.totalHeight,maxContentHeight:Vm,reachableRowCount:Gc(Dt.cumulativeHeights,Dt.virtualContainerHeight),unpinnedRowCount:Dt.cumulativeHeights.length,listViewWithoutColumn:_e&&!ve,listViewRowCount:Lr&&ve?kn.length:0});const ow=Ff(Ne,Dm),rw=s.useMemo(()=>oa.some(Ur=>!!Ur.rowSpan),[oa]),{columnsPanel:iw,aiAssistantPanel:lw,toolbarProps:sw}=zp({apiRef:Sn,containerRef:Ot,localeText:Ue,aiAssistant:{options:Pt,columns:xt,onApply:Ve,onError:ro},toolbar:{toolbar:xe?.toolbar,toolbarSlotProps:ye?.toolbar,orderedColumns:Hr,baseColumns:xn,aggregationModel:it,onAggregationModelChange:cm,pivotMode:de,pivotModelProp:Pe,onPivotModelChangeProp:Ie,pivotModel:Ys,onPivotModelChange:um,filterModel:Nt,onFilterModelChange:Xs,columnVisibilityModel:Ft,onColumnVisibilityModelChange:_r,disableColumnReorder:j,columnGroupingModel:Ne,moveColumn:ia,resetColumnOrder:la}}),aw={setViewportElement:Wm,handleScroll:Bm,ariaLabel:w,ariaRows:ew,navigationColumnCount:co.length,rowSelectionEnabled:wa,disableMultipleRowSelection:C,cellSelection:Mn,effectiveLoading:Fr,viewportTabIndex:zm,setKeyboardMode:Ir,handleMouseDownCapture:qm,handleKeyDown:jm,handleFocus:Um,handleBlur:Km,effectivePinnedColumns:Ar,virtualization:Dt,renderColumns:nw,renderedDataColumns:pa,columnGroupingModel:Ne,checkboxSelection:h,rowSelection:da,sortModel:mt,handleSort:ha,handleSortAdd:ma,multiSort:ee,handleColumnResize:sa,handleColumnAutosize:Hm,columnWidths:Wr,focusedCell:ba,columnIndexMap:Br,handleHeaderClick:Ym,headerReorderHandlers:ow,rowReordering:yn,hasDetailPanel:_n,pinCheckboxColumn:se,pinExpandColumn:ne,aggregationModel:it,handleHideColumn:Zm,columnsPanel:iw,handlePinColumn:Qm,wrapHeaderText:l,headerHeight:Qs,showHeaderFilters:Mr,filterModel:Nt,handleFilterModelChange:Xs,localeText:Ue,editingHandlers:Or,isCellEditable:le,selectedRowIds:Dr,handleRowClick:ua,onRowDoubleClick:N,handleCellClick:Xm,handleSelectionChange:fa,expandedRowIds:$r,getDetailPanelContent:te,getDetailPanelHeight:ie,handleDetailPanelToggle:na,reportDetailPanelHeight:Fm,spanning:En,rowMetaMap:Xe,fillHandle:Jm,pinnedTopRows:Ke,pinnedBottomRows:st,pinnedRows:R,getRowIdOf:He,showEmptyState:!Fr&&!Ge.dataSource.error&&aa.length===0,effectiveNoRowsLabel:sm,spanRowWindow:tw,visibleRows:Ca,baseColumns:xn,viewportWidth:Ge.dimensions.viewportWidth,rowReorderHandlers:$m,paginationMode:be,dataSourceLoading:Ge.dataSource.loading,sortedUnpinnedRowCount:Ct.length,pageSize:lt.pageSize,unpinnedRowsLength:Be.unpinnedRowsLength,showAggregationFooter:Rr&&Tr.rootAggregationPosition!==null,aggregationResult:ga,effectiveRowHeight:Tt,isAggregationLoading:Gm,containerRef:Ot,className:b,autoHeight:u,height:p,style:x,hasRowSpanning:rw,listView:Lr,headerFilterHeight:a,slots:xe,slotProps:ye,toolbarProps:sw,aiAssistantPanel:lw,orderedColumns:Hr,columnVisibilityModel:Ft,disableColumnReorder:j,handleColumnVisibilityModelChange:_r,moveColumn:ia,resetColumnOrder:la,listViewColumn:ve,allRenderableRows:kn,dataRows:uo,pagination:bt,effectivePaginationModel:lt,currentPage:Vr.currentPage,pageSizeOptions:Y,columnsByField:Pr.byField,paginationRowCount:ca,handlePaginationModelChange:Er,onRowsScrollEnd:Ae,toggleExpansion:en?.toggleExpansion,showCellSelectionStats:M,apiRef:Nr.apiRef,hasAggregation:Rr,isHierarchyEnabled:lo,dataSourceError:Ge.dataSource.error,filteredRowCount:aa.length,onRetry:he?ta.fetchRows:void 0};return d.jsx(rp,{...aw})}function Up({rows:e=5,columns:t=5}){return d.jsx("div",{className:"ogx__skeleton",children:Array.from({length:e}).map((n,o)=>d.jsx("div",{className:"ogx__skeleton-row",children:Array.from({length:t}).map((r,i)=>d.jsx("div",{className:"ogx__skeleton-cell",children:d.jsx("div",{className:"ogx__skeleton-content"})},i))},o))})}const Kp=300;function Xt(e){return"field"in e&&!("items"in e)}function _s(e,t){return e.find(n=>Xt(n)&&n.field===t)}function jp(e,t){return e===t?!0:Xt(e)&&Xt(t)?e.id===t.id&&e.field===t.field&&e.operator===t.operator&&gr(e.value,t.value):!Xt(e)&&!Xt(t)?e.id===t.id&&e.logicOperator===t.logicOperator&&vr(e.items,t.items):!1}function vr(e,t){return e===t?!0:e.length===t.length&&e.every((n,o)=>jp(n,t[o]))}function ks(e,t){return Ao(e,t.type)}function qp(e,t){if(!Gt.has(t))return t==="isAnyOf"?e==null||e===""?[]:Array.isArray(e)?e:[e]:Array.isArray(e)?e.length>0?e[0]:"":e??""}const Xp=({col:e,item:t,resetToken:n,onChange:o})=>{const r=s.useId(),i=Le(),l=s.useMemo(()=>ci(e.type),[e.type]),c=l[0],a=t?.operator??c,u=l.includes(a)?l:[a,...l],f=!!t,p=e.headerName||e.field,[b,x]=s.useState(null),[w,g]=s.useState(n);w!==n&&(g(n),x(null));const h=s.useRef(o),m=s.useRef(t),C=s.useRef(e);s.useLayoutEffect(()=>{h.current=o,m.current=t,C.current=e});const y=s.useCallback((T,P)=>({id:m.current?.id??`${e.field}-${Date.now()}`,field:e.field,operator:T,value:P}),[e.field]),_=s.useCallback(T=>{const P=m.current;if(P?T===ks(P.value,C.current):T.trim()==="")return;const G=P?.operator??c;h.current(y(G,Yn(T,G)))},[c,y]),v=s.useRef(null),k=s.useRef(_);s.useLayoutEffect(()=>{v.current=b,k.current=_}),s.useEffect(()=>()=>{const T=v.current;v.current=null,T!==null&&k.current(T)},[]),s.useEffect(()=>{if(b===null)return;const T=setTimeout(()=>{v.current=null,_(b),x(null)},Kp);return()=>clearTimeout(T)},[b,_]);const M=T=>{const P=b!==null?Yn(b,T):t?.value;x(null),o(y(T,qp(P,T)))},E=()=>{x(null),o(null)},I=!Gt.has(a),L=rs(e),N=`ogx-filter__value-input${f?" ogx-filter__value-input--active":""}`,S=i.filterPanelValueLabel(p);let F=null;if(I&&e.type==="boolean")F=d.jsxs("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${N} ogx-filter__value-select`,value:t?.value==null?"":String(t.value),onChange:T=>{T.target.value===""?o(null):o(y(a,T.target.value))},"aria-label":S,children:[d.jsx("option",{value:"",children:i.filterPanelAny}),d.jsx("option",{value:"true",children:i.filterPanelTrue}),d.jsx("option",{value:"false",children:i.filterPanelFalse})]});else if(I&&e.type==="singleSelect"&&L.length>0&&a==="isAnyOf"){const T=Array.isArray(t?.value)?t.value:t?.value==null||t.value===""?[]:[t.value];F=d.jsx("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${N} ogx-filter__value-multiselect`,multiple:!0,size:Math.min(L.length,4),value:L.filter(P=>T.some(A=>fr(P,A))).map(P=>P.key),onChange:P=>{const A=new Set(Array.from(P.target.selectedOptions,G=>G.value));o(y("isAnyOf",L.filter(G=>A.has(G.key)).map(G=>G.value)))},"aria-label":S,children:L.map(P=>d.jsx("option",{value:P.key,children:P.label},P.key))})}else if(I&&e.type==="singleSelect"&&L.length>0&&(a==="is"||a==="not")){const T=L.find(P=>fr(P,t?.value));F=d.jsxs("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${N} ogx-filter__value-select`,value:T?.key??"",onChange:P=>{const A=L.find(G=>G.key===P.target.value);o(y(a,A?A.value:""))},"aria-label":S,children:[d.jsx("option",{value:"",children:i.filterPanelAny}),L.map(P=>d.jsx("option",{value:P.key,children:P.label},P.key))]})}else I&&(F=d.jsx(tt,{id:`${r}-val`,name:`filter-val-${e.field}`,inputClassName:N,type:e.type==="date"?"date":"text",value:b??ks(t?.value,e),onChange:T=>x(T.target.value),placeholder:e.type==="number"?i.filterPanelNumberPlaceholder:i.filterPanelValuePlaceholder,"aria-label":S}));return d.jsxs("div",{className:`ogx-filter__row${f?" ogx-filter__row--active":""}`,children:[d.jsx("span",{className:"ogx-filter__col-label",title:e.field,children:p}),d.jsxs("div",{className:"ogx-filter__controls",children:[d.jsx("select",{id:`${r}-op`,name:`filter-op-${e.field}`,className:`ogx-filter__op-select${f?" ogx-filter__op-select--active":""}`,value:a,onChange:T=>M(T.target.value),"aria-label":i.filterPanelOperatorLabel(p),children:u.map(T=>d.jsx("option",{value:T,children:i.filterPanelOperator(T)},T))}),F,f&&d.jsx("button",{type:"button",className:"ogx-filter__row-clear",onClick:E,"aria-label":i.filterPanelClearLabel(p),title:i.filterPanelClearTooltip,children:"×"})]})]})},Es=({filterModel:e,columns:t,onFilterModelChange:n})=>{const o=Le(),r=s.useMemo(()=>e.items??[],[e.items]),i=e.logicOperator??"and",[l,c]=s.useState(null),[a,u]=s.useState(r),[f,p]=s.useState(0);if(a!==r){u(r);const m=!vr(a,r),C=l!==null&&vr(l,r);m&&!C&&p(y=>y+1)}const b=s.useCallback((m,C)=>{const y=r.findIndex(v=>Xt(v)&&v.field===m);let _;if(y===-1){if(!C)return;_=[...r,C]}else C?_=r.map((v,k)=>k===y?C:v):_=r.filter((v,k)=>k!==y);c(_),n({...e,items:_})},[r,e,n]),x=s.useCallback(m=>{n({...e,logicOperator:m})},[e,n]),w=t.filter(m=>m.filterable!==!1),g=w.filter(m=>_s(r,m.field)).length,h=r.length-g;return d.jsxs(d.Fragment,{children:[r.length>1&&d.jsxs("div",{className:"ogx-filter__logic-bar",children:[d.jsx("span",{className:"ogx-filter__logic-label",children:o.filterPanelMatch}),d.jsx("button",{type:"button",className:`ogx-filter__logic-pill${i==="and"?" ogx-filter__logic-pill--active":""}`,onClick:()=>x("and"),"aria-pressed":i==="and",children:o.filterPanelAnd}),d.jsx("button",{type:"button",className:`ogx-filter__logic-pill${i==="or"?" ogx-filter__logic-pill--active":""}`,onClick:()=>x("or"),"aria-pressed":i==="or",children:o.filterPanelOr})]}),h>0&&d.jsx("div",{className:"ogx-filter__hidden-note",role:"note",children:o.filterPanelHiddenConditions(h)}),w.length===0?d.jsx("div",{className:"ogx-filter__empty",children:o.filterPanelNoColumns}):w.map(m=>d.jsx(Xp,{col:m,item:_s(r,m.field),resetToken:f,onChange:C=>b(m.field,C)},m.field))]})},Ms=["sum","avg","count","min","max"];function Ls(){return d.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),d.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),d.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),d.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1",fill:"currentColor",opacity:"0.25"}),d.jsx("path",{d:"M17 14v-4M17 10l-2 2 2 2"})]})}function Yp({anchorRef:e,columns:t,model:n,onChange:o,onClose:r}){const i=Le(),l=s.useRef(null),[c,a]=s.useState({top:0,right:0}),[u,f]=s.useState(null);s.useLayoutEffect(()=>{f(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const p=s.useCallback(()=>In(e.current,Lt()),[e]);s.useEffect(()=>{a(p());const A=()=>a(p());return window.addEventListener("scroll",A,!0),window.addEventListener("resize",A),()=>{window.removeEventListener("scroll",A,!0),window.removeEventListener("resize",A)}},[p]),s.useEffect(()=>{function A(z){l.current&&!l.current.contains(z.target)&&e.current&&!e.current.contains(z.target)&&r()}function G(z){z.key==="Escape"&&r()}return document.addEventListener("mousedown",A),document.addEventListener("keydown",G),()=>{document.removeEventListener("mousedown",A),document.removeEventListener("keydown",G)}},[e,r]);const b=new Set(n.rowFields),x=new Set(n.columnFields),w=new Set(n.valueFields.map(A=>A.field)),g=A=>b.has(A)||x.has(A)||w.has(A),h=A=>t.find(G=>G.field===A),m=A=>h(A)?.headerName??A,C=A=>{const G=h(A)?.availableAggregationFunctions;return G?Ms.filter(z=>G.includes(z)):Ms},y=A=>A.aggregable!==!1&&(A.type==="number"||A.aggregable===!0)&&C(A.field).length>0,_=A=>A.groupable!==!1;function v(A){b.has(A)||o({...n,rowFields:[...n.rowFields,A]})}function k(A){x.has(A)||o({...n,columnFields:[...n.columnFields,A]})}function M(A){w.has(A)||o({...n,valueFields:[...n.valueFields,{field:A,aggFn:C(A)[0]??"sum"}]})}function E(A){o({...n,rowFields:n.rowFields.filter((G,z)=>z!==A)})}function I(A){o({...n,columnFields:n.columnFields.filter((G,z)=>z!==A)})}function L(A){o({...n,valueFields:n.valueFields.filter((G,z)=>z!==A)})}function N(A,G){o({...n,valueFields:n.valueFields.map((z,H)=>H===A?{...z,aggFn:G}:z)})}function S(){o({rowFields:[],columnFields:[],valueFields:[]})}const F=n.rowFields.length+n.columnFields.length+n.valueFields.length,T=t.filter(A=>!g(A.field)&&(_(A)||y(A))),P=d.jsxs("div",{ref:l,className:"ogx-pivot-panel",role:"dialog","aria-label":i.pivotPanelLabel,style:{top:c.top,right:c.right,left:c.left},children:[d.jsxs("div",{className:"ogx-pivot-panel__header",children:[d.jsxs("span",{className:"ogx-pivot-panel__title",children:[d.jsx(Ls,{}),i.pivotMode]}),F>0&&d.jsx("button",{type:"button",className:"ogx-pivot-panel__reset-btn",onClick:S,title:i.pivotResetTooltip,children:i.pivotReset})]}),d.jsxs("div",{className:"ogx-pivot-panel__body",children:[d.jsxs("div",{className:"ogx-pivot-zone",children:[d.jsxs("span",{className:"ogx-pivot-zone__label",children:[d.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--row"}),i.pivotRowFields]}),d.jsx("div",{className:`ogx-pivot-chips${n.rowFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":i.pivotRowFieldsPlaceholder,children:n.rowFields.map((A,G)=>d.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--row",children:[m(A),d.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>E(G),title:i.pivotRemoveTooltip(m(A)),"aria-label":i.pivotRemoveRowLabel(m(A)),children:"×"})]},`${G}:${A}`))})]}),d.jsxs("div",{className:"ogx-pivot-zone",children:[d.jsxs("span",{className:"ogx-pivot-zone__label",children:[d.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--col"}),i.pivotColumnFields]}),d.jsx("div",{className:`ogx-pivot-chips${n.columnFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":i.pivotColumnFieldsPlaceholder,children:n.columnFields.map((A,G)=>d.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--col",children:[m(A),d.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>I(G),title:i.pivotRemoveTooltip(m(A)),"aria-label":i.pivotRemoveColumnLabel(m(A)),children:"×"})]},`${G}:${A}`))})]}),d.jsxs("div",{className:"ogx-pivot-zone",children:[d.jsxs("span",{className:"ogx-pivot-zone__label",children:[d.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--value"}),i.pivotValueFields]}),d.jsx("div",{className:`ogx-pivot-chips${n.valueFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":i.pivotValueFieldsPlaceholder,children:n.valueFields.map((A,G)=>{const z=C(A.field),H=z.includes(A.aggFn)?z:[A.aggFn,...z];return d.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--value",children:[m(A.field),d.jsx("select",{className:"ogx-pivot-chip__fn-select",value:A.aggFn,onChange:Y=>N(G,Y.target.value),title:i.pivotAggregationTooltip,"aria-label":i.pivotAggregationLabel(m(A.field)),children:H.map(Y=>d.jsx("option",{value:Y,children:i.pivotAggregationFunction(Y)},Y))}),d.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>L(G),title:i.pivotRemoveTooltip(m(A.field)),"aria-label":i.pivotRemoveValueLabel(m(A.field),i.pivotAggregationFunction(A.aggFn)),children:"×"})]},`${G}:${A.field}:${A.aggFn}`)})})]}),d.jsx("hr",{className:"ogx-pivot-panel__divider"}),d.jsxs("div",{children:[d.jsx("div",{className:"ogx-pivot-panel__fields-label",children:i.pivotAvailableFields}),d.jsxs("div",{className:"ogx-pivot-fields",children:[T.map(A=>{const G=y(A),z=_(A),H=A.headerName??A.field;return d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3},children:[d.jsx("span",{className:`ogx-pivot-field-btn${G?" ogx-pivot-field-btn--numeric":""}`,children:H}),d.jsxs("div",{className:"ogx-pivot-field-actions",children:[z&&d.jsx("button",{type:"button",className:"ogx-pivot-add-btn ogx-pivot-add-btn--row",onClick:()=>v(A.field),title:i.pivotAddRowTooltip,"aria-label":i.pivotAddRowLabel(H),children:i.pivotAddRow}),z&&d.jsx("button",{type:"button",className:"ogx-pivot-add-btn ogx-pivot-add-btn--col",onClick:()=>k(A.field),title:i.pivotAddColumnTooltip,"aria-label":i.pivotAddColumnLabel(H),children:i.pivotAddColumn}),G&&d.jsx("button",{type:"button",className:"ogx-pivot-add-btn ogx-pivot-add-btn--value",onClick:()=>M(A.field),title:i.pivotAddValueTooltip,"aria-label":i.pivotAddValueLabel(H),children:i.pivotAddValue})]})]},A.field)}),T.length===0&&d.jsx("span",{style:{fontSize:12,color:"var(--ogx-color-gray-400, #94a3b8)"},children:i.pivotAllFieldsInUse})]})]})]})]});return u?at.createPortal(P,u):null}function Jp(){return d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("circle",{cx:"11",cy:"11",r:"8"}),d.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function Zp(){return d.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),d.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function As(e){return e.trim().split(/\s+/).filter(Boolean).join(" ")}function Qp({value:e="",onChange:t,placeholder:n,debounceMs:o=250}){const r=Le(),i=n??r.toolbarSearchPlaceholder,[l,c]=s.useState(()=>e.length>0),[a,u]=s.useState(e),f=s.useRef(null),p=s.useRef(null),b=s.useRef(t);s.useLayoutEffect(()=>{b.current=t},[t]);const x=s.useRef(e),w=s.useRef(e);s.useEffect(()=>{e!==w.current&&(w.current=e,As(e)!==As(x.current)&&(u(e),x.current=e,c(e.length>0)))},[e]),s.useEffect(()=>{const _=setTimeout(()=>{a!==x.current&&(x.current=a,b.current(a))},o);return()=>clearTimeout(_)},[a,o]);const g=s.useRef(a);s.useLayoutEffect(()=>{g.current=a}),s.useEffect(()=>()=>{const _=g.current;_!==x.current&&(x.current=_,b.current(_))},[]);const h=s.useCallback(()=>{c(!0),requestAnimationFrame(()=>f.current?.focus())},[]),m=s.useCallback(_=>{_.stopPropagation(),u(""),x.current="",b.current(""),f.current?.focus()},[]),C=s.useCallback(()=>{c(!0)},[]),y=s.useCallback(()=>{setTimeout(()=>{p.current&&document.activeElement&&p.current.contains(document.activeElement)||a||c(!1)},150)},[a]);return s.useEffect(()=>{const _=v=>{p.current&&!p.current.contains(v.target)&&(a||c(!1))};return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[a]),d.jsxs("div",{ref:p,className:`ogx-global-search${l?" ogx-global-search--expanded":""}`,onClick:l?void 0:h,children:[d.jsx("div",{className:"ogx-global-search__icon-wrapper",children:d.jsx(Jp,{})}),d.jsx(tt,{ref:f,inputClassName:"ogx-global-search__input",value:a,onChange:_=>u(_.target.value),onFocus:C,onBlur:y,placeholder:i,"aria-label":r.toolbarSearchLabel,autoComplete:"off"}),a&&d.jsx("button",{type:"button",className:"ogx-global-search__clear",onClick:m,"aria-label":r.toolbarSearchClear,children:d.jsx(Zp,{})})]})}const to=8;function mn({title:e,children:t,placement:n="top",enterDelay:o=200,leaveDelay:r=0}){const[i,l]=s.useState(!1),[c,a]=s.useState({top:0,left:0}),[u,f]=s.useState(null),p=s.useRef(null),b=s.useRef(null),x=s.useId(),w=s.useCallback(()=>{if(!b.current)return;const v=b.current.getBoundingClientRect(),k=v.left+v.width/2,M=v.top+v.height/2;switch(n){case"bottom":a({top:v.bottom+to,left:k});break;case"left":a({top:M,left:v.left-to});break;case"right":a({top:M,left:v.right+to});break;default:a({top:v.top-to,left:k})}},[n]),g=s.useCallback(()=>{p.current&&clearTimeout(p.current),p.current=null},[]);s.useLayoutEffect(()=>{if(!i)return;w();const v=k=>{k.key==="Escape"&&(g(),l(!1))};return window.addEventListener("scroll",w,!0),window.addEventListener("resize",w),document.addEventListener("keydown",v),()=>{window.removeEventListener("scroll",w,!0),window.removeEventListener("resize",w),document.removeEventListener("keydown",v)}},[i,w,g]),s.useEffect(()=>g,[g]);const h=()=>{g(),p.current=setTimeout(()=>{f(b.current?.closest(".ogx-theme-provider")??document.body),l(!0)},o)},m=()=>{g(),p.current=setTimeout(()=>{l(!1)},r)},C=s.useCallback(v=>{b.current=v?v.firstElementChild??v:null},[]),y=i&&!!e&&u!==null;let _=t;if(y&&s.isValidElement(t)){const v=t,k=v.props["aria-describedby"];_=s.cloneElement(v,{"aria-describedby":k?`${k} ${x}`:x})}return d.jsxs(d.Fragment,{children:[d.jsx("span",{ref:C,style:{display:"inline-block",lineHeight:0},onMouseEnter:h,onMouseLeave:m,onFocus:h,onBlur:m,children:_}),y&&u&&at.createPortal(d.jsx("div",{id:x,role:"tooltip",className:`ogx-tooltip ogx-tooltip--${n}`,style:{top:c.top,left:c.left,position:"fixed",zIndex:99999},children:e}),u)]})}const eh=Object.keys(ct);function th(e){return Object.prototype.hasOwnProperty.call(ct,e)}function Ps(e){return e.availableAggregationFunctions?Array.from(new Set(e.availableAggregationFunctions.filter(th))):eh}function Is(){return d.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:d.jsx("path",{d:"M18 4H6l6 8-6 8h12"})})}function nh(){return d.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",children:[d.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),d.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.25"}),d.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),d.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),d.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),d.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function Ns(){return d.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})})}function oh({anchorRef:e,aggregationModel:t,aggregableColumns:n,onFunctionChange:o,onClearAll:r,onClose:i,activeCount:l}){const c=Le(),a=s.useRef(null),[u,f]=s.useState({top:0,right:0}),[p,b]=s.useState(null);s.useLayoutEffect(()=>{b(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const x=s.useCallback(()=>In(e.current,Lt()),[e]);s.useEffect(()=>{f(x());const g=()=>f(x());return window.addEventListener("scroll",g,!0),window.addEventListener("resize",g),()=>{window.removeEventListener("scroll",g,!0),window.removeEventListener("resize",g)}},[x]),s.useEffect(()=>{function g(h){a.current&&!a.current.contains(h.target)&&e.current&&!e.current.contains(h.target)&&i()}return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[e,i]),s.useEffect(()=>{function g(h){h.key==="Escape"&&i()}return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[i]);const w=d.jsxs("div",{ref:a,className:"ogx-toolbar__panel",role:"dialog","aria-label":c.toolbarSummariesPanelLabel,style:{top:u.top,right:u.right,left:u.left,width:400,maxWidth:"calc(100vw - 24px)"},children:[d.jsxs("div",{className:"ogx-toolbar__panel-header",children:[d.jsxs("span",{className:"ogx-toolbar__panel-title",children:[d.jsx(Is,{}),c.toolbarSummaries]}),l>0&&d.jsx("button",{type:"button",className:"ogx-toolbar__clear-btn",onClick:r,title:c.toolbarSummariesClearAllTooltip,children:c.toolbarSummariesClearAll})]}),d.jsx("div",{className:"ogx-toolbar__panel-body",children:n.length===0?d.jsxs("p",{className:"ogx-toolbar__empty",children:[c.toolbarSummariesEmpty,d.jsx("br",{}),`${c.toolbarSummariesEmptyHintBefore} `,d.jsx("code",{children:"aggregable: true"}),` ${c.toolbarSummariesEmptyHintAfter}`]}):n.map(g=>{const h=t[g.field]||"none";return d.jsxs("div",{className:"ogx-toolbar__agg-row",children:[d.jsx("span",{className:"ogx-toolbar__agg-label",title:g.field,children:g.headerName||g.field}),d.jsx("div",{className:"ogx-toolbar__agg-pills",children:["none",...Ps(g)].map(m=>d.jsx("button",{type:"button",className:`ogx-toolbar__pill${h===m?" ogx-toolbar__pill--active":""}`,onClick:()=>o(g.field,m),"aria-pressed":h===m,children:c.toolbarAggregationFunction(m)},m))})]},g.field)})})]});return p?at.createPortal(w,p):null}function rh({anchorRef:e,columns:t,visibleColumns:n,onVisibilityChange:o,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:c,onClose:a,showNonHideableColumns:u}){const f=Le(),p=s.useRef(null),[b,x]=s.useState({top:0,right:0}),[w,g]=s.useState(null);s.useLayoutEffect(()=>{g(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const h=s.useCallback(()=>In(e.current,Lt()),[e]);s.useEffect(()=>{x(h());const C=()=>x(h());return window.addEventListener("scroll",C,!0),window.addEventListener("resize",C),()=>{window.removeEventListener("scroll",C,!0),window.removeEventListener("resize",C)}},[h]),s.useEffect(()=>{function C(y){p.current&&!p.current.contains(y.target)&&e.current&&!e.current.contains(y.target)&&a()}return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[e,a]),s.useEffect(()=>{function C(y){y.key==="Escape"&&a()}return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[a]);const m=d.jsx("div",{ref:p,className:"ogx-toolbar__panel",role:"dialog","aria-label":f.toolbarColumnsPanelLabel,style:{top:b.top,right:b.right,left:b.left,width:280,padding:0},children:d.jsx(dr,{columns:t,visibleColumns:n,onVisibilityChange:o,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:c,showNonHideableColumns:u})});return w?at.createPortal(m,w):null}function ih({anchorRef:e,columns:t,filterModel:n,onFilterModelChange:o,onClose:r}){const i=Le(),l=s.useRef(null),[c,a]=s.useState({top:0,right:0}),u=s.useRef(r);s.useLayoutEffect(()=>{u.current=r},[r]);const[f,p]=s.useState(null);s.useLayoutEffect(()=>{p(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const b=s.useCallback(()=>In(e.current,Lt()),[e]);s.useEffect(()=>{a(b());const h=()=>a(b());return window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}},[b]),s.useEffect(()=>{function h(m){m.key==="Escape"&&u.current()}return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[]);const x=n.items?.length??0,w=()=>{o({...n,items:[],logicOperator:"and"})},g=d.jsxs("div",{ref:l,className:"ogx-toolbar__panel ogx-toolbar__panel--filter",role:"dialog","aria-label":i.toolbarFiltersLabel,style:{top:c.top,right:c.right,left:c.left,width:540,maxWidth:"calc(100vw - 24px)"},children:[d.jsxs("div",{className:"ogx-toolbar__panel-header",children:[d.jsxs("span",{className:"ogx-toolbar__panel-title",children:[d.jsx(Ns,{}),i.toolbarFilters,x>0&&d.jsx("span",{className:"ogx-toolbar__panel-count",children:x})]}),d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[x>0&&d.jsx("button",{type:"button",className:"ogx-toolbar__clear-btn",onClick:w,title:i.toolbarFiltersClearAllTooltip,children:i.toolbarFiltersClearAll}),d.jsx("button",{type:"button",className:"ogx-toolbar__close-btn",onClick:()=>u.current(),title:i.toolbarFiltersCloseTooltip,"aria-label":i.toolbarFiltersCloseLabel,children:i.toolbarFiltersClose})]})]}),d.jsx("div",{className:"ogx-toolbar__panel-body ogx-toolbar__panel-body--filter",children:d.jsx(Es,{columns:t,filterModel:n,onFilterModelChange:o})})]});return f?at.createPortal(g,f):null}const lh={rowFields:[],columnFields:[],valueFields:[]},sh=[];function ah({columns:e=sh,baseColumns:t,aggregationModel:n={},onAggregationModelChange:o,pivotModel:r,onPivotModelChange:i,filterModel:l,onFilterModelChange:c,columnVisibilityModel:a={},onColumnVisibilityModelChange:u,onColumnReorder:f,onColumnOrderReset:p,forceColumnsOpen:b,onColumnsPanelClose:x,forceFiltersOpen:w,onFiltersPanelClose:g,children:h,rightContent:m,style:C,renderColumnsButton:y,renderFilterButton:_,renderAggregationButton:v,renderExportButton:k,renderQuickFilter:M,className:E,showNonHideableColumns:I,onAiAssistantToggle:L,aiAssistantOpen:N=!1,aiAssistantLabel:S}){const F=Le(),T=S??F.aiAssistantButton,[P,A]=s.useState(b?"columns":null),G=P==="summaries",z=P==="pivot",H=P==="columns",Y=P==="filters",K=me=>{P==="columns"&&me!=="columns"&&x?.(),P==="filters"&&me!=="filters"&&g?.(),A(me)},re=me=>K(P===me?null:me),R=me=>{P===me&&K(null)},[te,ie]=s.useState(b);te!==b&&(ie(b),b&&A("columns"));const[ce,J]=s.useState(w);ce!==w&&(J(w),w&&c&&A("filters"));const se=s.useContext(Zl),ne=b!==void 0&&!!u;s.useEffect(()=>{if(!(!se||!ne))return se.registerColumnsPanel()},[se,ne]);const j=w!==void 0&&!!c;s.useEffect(()=>{if(!(!se||!j))return se.registerFiltersPanel()},[se,j]);const B=s.useRef(null),W=s.useRef(null),ae=s.useRef(null),fe=s.useRef(null),Q=s.useRef(null),U=s.useRef(null),O=s.useRef(null),$=s.useRef(null),D=r??lh,V=D.rowFields.length>0||D.columnFields.length>0||D.valueFields.length>0,q=t?new Set(t.map(me=>me.field)):null,oe=e.filter(me=>me.aggregable!==!1&&(me.type==="number"||me.aggregable===!0)&&Ps(me).length>0&&(!q||q.has(me.field))),Z=Object.keys(n).filter(me=>n[me]&&n[me]!=="none").length,X=s.useCallback((me,xe)=>{if(!o)return;const ye={...n};xe==="none"?delete ye[me]:ye[me]=xe,o(ye)},[n,o]),le=s.useCallback(()=>{o?.({})},[o]),we=s.useCallback(me=>{if(!c)return;const xe=me.trim().split(/\s+/).filter(Boolean),ye={...l||{},quickFilterValues:xe,items:l?.items||[]};c(ye)},[l,c]),ge=(l?.quickFilterValues??[]).join(" "),he=l?.items?.length||0,ee=new Set(e.filter(me=>a[me.field]!==!1).map(me=>me.field)),ue=s.useCallback((me,xe)=>{if(!u)return;const ye={...a,[me]:xe};u(ye)},[a,u]),Ce=s.useCallback(()=>{if(!u)return;const me={...a};e.forEach(xe=>{xe.hideable!==!1&&(me[xe.field]=!0)}),u(me)},[e,a,u]),be=s.useCallback(()=>{if(!u)return;const me={...a};e.forEach(xe=>{xe.hideable!==!1&&(me[xe.field]=!1)}),u(me)},[e,a,u]);return d.jsxs("div",{className:["ogx-toolbar",E].filter(Boolean).join(" "),role:"toolbar","aria-label":F.toolbarLabel,style:C,children:[h&&d.jsx("div",{className:"ogx-toolbar__left",children:h}),d.jsx("div",{className:"ogx-toolbar__spacer"}),d.jsxs("div",{className:"ogx-toolbar__actions",children:[L&&d.jsx("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:d.jsxs("button",{type:"button",ref:W,className:`ogx-toolbar__icon-btn ogx-toolbar__ai-btn${N?" ogx-toolbar__icon-btn--active":""}`,"aria-haspopup":"dialog","aria-expanded":N,onClick:()=>{K(null),L(W.current)},children:[d.jsx(Ql,{}),T]})}),c&&d.jsx("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:M?M({value:ge,onChange:we}):d.jsx(Qp,{value:ge,onChange:we,placeholder:F.toolbarSearchPlaceholder})}),u&&d.jsxs("div",{ref:U,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[y?y({onClick:()=>re("columns"),isOpen:H,activeCount:e.length-ee.size}):d.jsx(mn,{title:F.toolbarColumns,children:d.jsx("button",{type:"button",ref:fe,className:`ogx-toolbar__icon-btn${H?" ogx-toolbar__icon-btn--active":""}`,"aria-label":F.toolbarColumnsLabel,"aria-haspopup":"dialog","aria-expanded":H,onClick:()=>re("columns"),children:d.jsx(nh,{})})}),H&&d.jsx(rh,{anchorRef:y?U:fe,columns:e,visibleColumns:ee,onVisibilityChange:ue,onShowAll:Ce,onHideAll:be,onColumnReorder:f,onColumnOrderReset:p,onClose:()=>R("columns"),showNonHideableColumns:I})]}),c&&d.jsxs("div",{ref:O,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[_?_({onClick:()=>re("filters"),isOpen:Y,activeCount:he}):d.jsx(mn,{title:F.toolbarFilters,children:d.jsxs("button",{type:"button",ref:Q,className:`ogx-toolbar__icon-btn${Y?" ogx-toolbar__icon-btn--active":""}`,"aria-label":F.toolbarFiltersLabel,"aria-haspopup":"dialog","aria-expanded":Y,onClick:()=>re("filters"),children:[d.jsx(Ns,{}),he>0&&d.jsx("span",{className:"ogx-toolbar__dot","aria-label":F.toolbarFiltersActive})]})}),Y&&d.jsx(ih,{anchorRef:_?O:Q,columns:e,filterModel:l||{items:[]},onFilterModelChange:c,onClose:()=>R("filters")})]}),i&&d.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[d.jsx(mn,{title:F.toolbarPivot,children:d.jsxs("button",{type:"button",ref:ae,className:`ogx-toolbar__icon-btn${z?" ogx-toolbar__icon-btn--active":""}`,"aria-label":F.toolbarPivotLabel,"aria-haspopup":"dialog","aria-expanded":z,onClick:()=>re("pivot"),children:[d.jsx(Ls,{}),V&&d.jsx("span",{className:"ogx-toolbar__dot","aria-label":F.toolbarPivotActive})]})}),z&&d.jsx(Yp,{anchorRef:ae,columns:t??e,model:D,onChange:me=>{i?.(me)},onClose:()=>R("pivot")})]}),o&&d.jsxs("div",{ref:$,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[v?v({onClick:()=>re("summaries"),isOpen:G,activeCount:Z}):d.jsx(mn,{title:F.toolbarSummaries,children:d.jsxs("button",{type:"button",ref:B,className:`ogx-toolbar__icon-btn${G?" ogx-toolbar__icon-btn--active":""}`,"aria-label":F.toolbarSummariesLabel,"aria-haspopup":"dialog","aria-expanded":G,onClick:()=>re("summaries"),children:[d.jsx(Is,{}),Z>0&&d.jsx("span",{className:"ogx-toolbar__dot","aria-label":F.toolbarSummariesActive(Z)})]})}),G&&d.jsx(oh,{anchorRef:v?$:B,aggregationModel:n,aggregableColumns:oe,onFunctionChange:X,onClearAll:le,onClose:()=>R("summaries"),activeCount:Z})]}),k&&k(),m]})]})}function ch(){const[e]=s.useState(al);return s.useRef(e)}function Yt(e,t){if(e.groupLabel!==void 0)return e.groupLabel;const n=e.groupField??"",o=t.find(r=>r.field===n)?.groupingValueFormatter;return o?o({field:n,value:e.groupValue}):`${n}: ${String(e.groupValue??"")}`}const dh=new Set([8364,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,381,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,382,376]);function uh(e){return e>=8192&&e<=8202||e===8239||e===8287||e===12288?" ":e>=8203&&e<=8205||e===8288||e===65279?"":e===8208||e===8209||e===8210||e===8722?"-":null}function fh(e){let t="",n=!1;for(const o of e){const r=o.codePointAt(0)??0;if(r<=255||dh.has(r)){t+=o;continue}const i=uh(r);i!==null?t+=i:(t+="?",n=!0)}return{text:t,lossy:n}}const gh={sliceMs:30,renderChunkRows:40},ph=2e4;function Fs(){return new Promise(e=>setTimeout(e,0))}function hh(){return new DOMException("PDF export was aborted","AbortError")}const Jt=()=>typeof performance<"u"?performance.now():Date.now(),Ts=e=>Math.max(2,Math.floor(e/2)*2),mh=[79,70,229],wh=[255,255,255];function Os(e,t){const n=e.trim().replace(/^#/,""),o=/^[a-f\d]{3}$/i.test(n)?n.split("").map(i=>i+i).join(""):n,r=/^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(o);return r?[parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16)]:t}function Ds(e,t){return gn(e,t,fn(e,t))}function $s(e){return(typeof e.width=="number"?e.width:void 0)??(e.flex??1)*100}function bh(e,t){const n=e.reduce((r,i)=>r+$s(i),0),o={};return e.forEach((r,i)=>{o[i]={cellWidth:$s(r)/n*t}}),o}const xh=new Set(["isEmpty","isNotEmpty"]);function Ch(e,t){const o=t.find(l=>l.field===e.field)?.headerName??e.field;if(xh.has(e.operator))return`${o} ${e.operator}`;const{value:r}=e;if(r==null||r===""||Array.isArray(r)&&r.length===0)return null;const i=Array.isArray(r)?r.map(String).join(", "):String(r);return`${o} ${e.operator} "${i}"`}function Gs(e,t,n,o){const r=e.map(l=>"items"in l?Gs(l.items,l.logicOperator,n,!0):Ch(l,n)).filter(l=>!!l);if(r.length===0)return"";const i=r.join(t==="or"?" OR ":" AND ");return o&&r.length>1?`(${i})`:i}function yh(e,t){const n=[],o=Gs(e.items??[],e.logicOperator??"and",t,!1);o&&n.push(o);const r=(e.quickFilterValues??[]).filter(i=>i.trim()!=="");return r.length>0&&n.push(`Search: ${r.map(i=>`"${i}"`).join(" ")}`),n.join(" • ")}const vh=1.15*.3528;function Sh(e,t,n={}){return _h(e,t,n,gh)}async function _h(e,t,n,o){const{signal:r,onProgress:i}=n,l=()=>{if(r?.aborted)throw hh()};l();let c,a;try{const[Z,X]=await Promise.all([import("jspdf"),import("jspdf-autotable")]);c=Z.default,a=X.default}catch{throw new Error("exportToPdf requires 'jspdf' and 'jspdf-autotable'. Run: npm install jspdf jspdf-autotable")}const{fileName:u="export",title:f,logoUrl:p,orientation:b="landscape",selectedRows:x,getRowId:w,aggregationResult:g,aggregationModel:h,filterModel:m,alternateRowColor:C=!0,headerBackgroundColor:y="#4f46e5",headerTextColor:_="#ffffff",fontSize:v=9,groupedRows:k,font:M,maxRows:E=ph}=n;l();let I=Jt();const L=async()=>{Jt()-I<o.sliceMs||(await Fs(),l(),I=Jt())},N=(Z,X,le)=>{i?.({phase:Z,done:X,total:le})},S=new c({orientation:b,unit:"mm",format:"a4"}),F=S.internal.pageSize.getWidth(),T=S.internal.pageSize.getHeight(),P=14,A=F-P*2;let G="helvetica";M&&(S.addFileToVFS(`${M.name}-normal.ttf`,M.data),S.addFont(`${M.name}-normal.ttf`,M.name,"normal"),M.boldData&&S.addFileToVFS(`${M.name}-bold.ttf`,M.boldData),S.addFont(M.boldData?`${M.name}-bold.ttf`:`${M.name}-normal.ttf`,M.name,"bold"),G=M.name);let z=!1;const H=Z=>{if(M)return Z;const X=fh(Z);return X.lossy&&(z=!0),X.text},Y=(Z,X,le,we,ge)=>{const he=S.splitTextToSize(H(Z),we);return S.text(he.length===1?he[0]:he,X,le),Math.max(0,he.length-1)*ge*vh},K=Mt(t),re=un(k,x),R=dn(e,x,w);let te=P;if(f){let Z=P,X=P+8;if(p)try{S.addImage(p,"PNG",Z,P,10,10),Z+=14}catch{}const le=F-P-Z;S.setFontSize(16),S.setFont(G,"bold"),S.setTextColor(30,41,59),X+=Y(f,Z,X,le,16),X+=6,S.setFontSize(8),S.setFont(G,"normal"),S.setTextColor(100,116,139);const we=new Date().toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),ge=re?k.filter(he=>he.type==="leaf").length:R.length;if(S.text(H(`Exported: ${we} • ${ge} row${ge!==1?"s":""}`),Z,X),X+=5,m){const he=yh(m,t);he&&(X+=Y(`Filters: ${he}`,Z,X,le,8),X+=5)}S.setDrawColor(226,232,240),S.setLineWidth(.3),S.line(P,X+2,F-P,X+2),te=X+6}const ie=[K.map(Z=>H(Z.headerName??Z.field))],ce=h||{},J=Z=>K.map(X=>er(X,ce[X.field],Z[X.field],Z)),se=[];let ne;const j=Z=>{se.push(Z.map(H))};if(re){const Z=k.length;N("prepare",0,Z);for(let X=0;X<Z;X++){const le=k[X],we=" ".repeat(le.depth*2);if(le.type==="group-header"){const ge=`${we}${Yt(le,t)}`;j(K.map((he,ee)=>ee===0?ge:""))}else if(le.type==="leaf"&&le.row){const ge=le.row;j(K.map((he,ee)=>(ee===0?we:"")+Ds(ge,he)))}else if(le.type==="group-subtotal"&&le.aggregatedValues){const ge=J(le.aggregatedValues);j(ge.map((he,ee)=>ee===0?`${we}${zt("Subtotal",he)}`:he))}else le.type==="grand-total"&&le.aggregatedValues&&(ne=[J(le.aggregatedValues).map((he,ee)=>ee===0?zt("Grand Total",he):he).map(H)]);(X&63)===63&&(N("prepare",X+1,Z),await L())}N("prepare",Z,Z)}else{const Z=R.length;N("prepare",0,Z);for(let le=0;le<Z;le++)j(K.map(we=>Ds(R[le],we))),(le&63)===63&&(N("prepare",le+1,Z),await L());const X=h?Vt(R,ut(x),t,g,h):null;if(X&&h){const le=K.some(ge=>h[ge.field]);ne=[J(X).map((ge,he)=>he===0&&le?zt("TOTAL",ge):ge).map(H)]}N("prepare",Z,Z)}l(),se.length>E&&process.env.NODE_ENV!=="production"&&console.warn(`[exportToPdf] Exporting ${se.length} table rows (maxRows: ${E}). PDFs this large are slow to build and open and can reach tens of MB. Prefer exportToCsv or exportToExcelAdvanced for full-dataset exports, or pass a larger \`maxRows\` to silence this warning.`),z&&console.warn('[exportToPdf] Some characters cannot be drawn with the built-in Helvetica font and were replaced with "?". Pass the `font` option (a Unicode .ttf, e.g. Noto Sans) to draw them.');const B=bh(K,A),[W,ae,fe]=Os(y,mh),[Q,U,O]=Os(_,wh),$={head:ie,styles:{fontSize:v,cellPadding:3,font:G,overflow:"linebreak"},headStyles:{fillColor:[W,ae,fe],textColor:[Q,U,O],fontStyle:"bold"},...C?{alternateRowStyles:{fillColor:[248,250,252]}}:{},...ne?{footStyles:{fillColor:[241,245,249],fontStyle:"bold",textColor:[0,0,0]}}:{},columnStyles:B,showHead:"everyPage",margin:{top:P,left:P,right:P,bottom:P+6}},D=se.length;N("render",0,D);let V=0,q=Ts(o.renderChunkRows);do{const Z=se.slice(V,V+q),X=V===0,le=V+Z.length>=D,we=X?te:S.lastAutoTable.finalY;let ge=!0;const he=Jt();a(S,{...$,body:Z,...le&&ne?{foot:ne}:{},startY:X?te:P,showFoot:le&&ne?"lastPage":"never",...X?{}:{willDrawPage:ue=>{ge?(ge=!1,ue.settings.showHead="never",ue.cursor&&(ue.cursor.y=we)):ue.settings.showHead="everyPage"}}}),V+=Z.length,N("render",V,D);const ee=Jt()-he;q=Ts(ee>0?Math.min(q*4,q*(o.sliceMs/ee)):q*4),le||(await Fs(),l(),I=Jt())}while(V<D);const oe=S.getNumberOfPages();for(let Z=1;Z<=oe;Z++)S.setPage(Z),S.setFontSize(8),S.setTextColor(150,150,150),S.text(`Page ${Z} of ${oe}`,F-P,T-8,{align:"right"}),await L();l(),N("save",0,1),S.save(`${u}.pdf`),N("save",1,1)}function wn(e,t){const n=fn(e,t),o=gn(e,t,n);return{text:o,raw:n,fromNonText:lu(n,o,!!t.valueFormatter)}}function Zt(e,t,n){return e.map(o=>er(o,n[o.field],t[o.field],t))}const kh="\uFEFF";function Eh(e,t,n={}){const{fileName:o="export.csv",includeHeaders:r=!0,delimiter:i=",",selectedRows:l,groupedRows:c,escapeFormulas:a=!0,bom:u=!0}=n,f=Mt(t),p=n.aggregationModel||{},b=(g,h=!1)=>no(a?qn(g,h):g,i),x=()=>f.map(g=>b(g.headerName||g.field)).join(i)+`
|
|
8
|
-
`;let w="";if(un(c,l))r&&(w+=
|
|
9
|
-
`}else if(g.type==="leaf"&&g.row){const m=g.row,C=f.map((
|
|
10
|
-
`}else if((g.type==="group-subtotal"||g.type==="grand-total")&&g.aggregatedValues){const m=g.aggregatedValues,C=g.type==="grand-total"?"Grand Total":`${
|
|
11
|
-
`}});else{const g=dn(e,l,n.getRowId);if(g.length===0){console.warn("No rows to export");return}r&&(w+=
|
|
12
|
-
`});const
|
|
13
|
-
`;const C=
|
|
14
|
-
`}}
|
|
15
|
-
`)||e.includes("\r")?`"${e.replace(/"/g,'""')}"`:e}const oo="ogx-xls-text";function
|
|
7
|
+
`?2:1):(o+=c,r+=1)}return(!l||n.length>0||o!=="")&&(n.push(o),t.push(n)),t}const Gu=/^\d+(?:\.\d*)?(?:e[+-]?\d+)?$/i,Hu=/^\.\d+(?:e[+-]?\d+)?$/i,Bu=/^\d{1,3}(?:,\d{3})+(?:\.\d*)?$/,Wu=/[\p{Sc}\s]/gu;function Vu(e){let t=e.replace(Wu,"");if(t==="")return e.trim()===""?Pe(null):it;let n=!1;t.startsWith("(")&&t.endsWith(")")&&(n=!0,t=t.slice(1,-1)),(t.startsWith("-")||t.startsWith("+")||t.startsWith("−"))&&(t[0]!=="+"&&(n=!n),t=t.slice(1));let o=!1;if(t.endsWith("%")&&(o=!0,t=t.slice(0,-1)),Bu.test(t))t=t.split(",").join("");else if(!Gu.test(t)&&!Hu.test(t))return it;let r=Number(t);return Number.isFinite(r)?(o&&(r/=100),n&&(r=-r),Pe(r)):it}const zu=/^(\d{4}-\d{2}-\d{2})/,Ol=e=>String(e).padStart(2,"0");function Ru(e){const t=e.trimEnd();if(t.endsWith("Z")||t.endsWith("z"))return!0;const n=t.indexOf("T");if(n<0)return!1;for(let o=t.length-1;o>n;o--){const r=t[o];if(r==="+"||r==="-")return!0;if(!(r>="0"&&r<="9")&&r!==":")return!1}return!1}const Uu=e=>`${e.getFullYear()}-${Ol(e.getMonth()+1)}-${Ol(e.getDate())}`;function Ku(e,t){const n=e.trim();if(n==="")return Pe(null);const o=tn(n);if(!o)return it;if(typeof t=="number")return Pe(o.getTime());if(typeof t=="string"){const r=Uu(o);if(!zu.test(t)||t.length<=10)return Pe(r);const i=Ru(t)?new Date(t):null;return i&&!Number.isNaN(i.getTime())?Pe(new Date(o.getFullYear(),o.getMonth(),o.getDate(),i.getHours(),i.getMinutes(),i.getSeconds(),i.getMilliseconds()).toISOString()):Pe(r+t.slice(10))}return Pe(o)}const ju=new Set(["true","yes","1"]),qu=new Set(["false","no","0"]);function Xu(e,t){const n=e.trim().toLowerCase();return n===""?Pe(null):t?.trueLabel!==void 0&&n===t.trueLabel.trim().toLowerCase()?Pe(!0):t?.falseLabel!==void 0&&n===t.falseLabel.trim().toLowerCase()?Pe(!1):ju.has(n)?Pe(!0):qu.has(n)?Pe(!1):it}function Yu(e,t){const n=e.trim();if(n==="")return Pe(null);if(!t||t.length===0)return it;const o=n.toLowerCase();for(const r of t){const i=typeof r=="object"?r.value:r;if(String(i).toLowerCase()===o)return Pe(i)}for(const r of t)if(typeof r=="object"&&r.label.toLowerCase()===o)return Pe(r.value);return it}function Ju(e,t,n){switch(t?.type){case"number":return Vu(e);case"date":return Ku(e,n?.current);case"boolean":return Xu(e,n?.booleanLabels);case"singleSelect":return Yu(e,t.valueOptions);default:return Pe(e)}}function Zu(e,t,n,o){const{valueParser:r}=t;if(!r)return Ju(e,t,o);let i;try{i=r(e,{row:n,field:t.field,colDef:t})}catch{return it}return i===void 0?it:Pe(i)}function ar(e,t,n){const{rowIds:o,rowIndexById:r}=er(e,t,"renderable"),i=n.filter(a=>je(a.field)),l=new Map;i.forEach((a,u)=>{l.set(a.field,u)});const c=n.filter(a=>Qe(a.field)).length;return{rows:e,rowIds:o,rowIndexById:r,columns:i,colIndexByField:l,dataColumnOffset:c}}function cr(e,t,n,o,r){const i=e.rowIds[o],l=e.columns[r];if(!l||Ke(i,t.rowMetaMap))return!1;const c=t.getSpanOrigin?.(i,l.field);return c&&(c.rowId!==i||c.field!==l.field)?!1:vo({row:n,field:l.field,value:Se(n,l.field,l),colDef:l,rowIndex:o,colIndex:e.dataColumnOffset+r,rowMeta:t.rowMetaMap?.get(i)},t.isCellEditable)}function Qu(e,t){let n=1/0,o=-1/0,r=1/0,i=-1/0;for(const l of t){const c=e.rowIndexById.get(l.id),a=e.colIndexByField.get(l.field);c===void 0||a===void 0||(c<n&&(n=c),c>o&&(o=c),a<r&&(r=a),a>i&&(i=a))}return n===1/0?null:{top:n,bottom:o,left:r,right:i}}function Dl(e,t){return{anchor:{id:e.rowIds[t.top],field:e.columns[t.left].field},head:{id:e.rowIds[t.bottom],field:e.columns[t.right].field}}}function ef(e){const t=e?.type;return t===void 0||t==="string"||t==="image"}const $l=1e4,Yn=()=>({updated:[],failed:[],skipped:[]});function tf(e){process.env.NODE_ENV!=="production"&&console.warn(`[OpenGridX] Pasting ${e} cells. Pastes above ${$l} cells can be slow; consider importing the data instead.`)}function nf(e){const{apiRef:t,containerRef:n,selection:o,disableClipboardPaste:r,disableRangeClear:i}=e,l=s.useRef(e);s.useLayoutEffect(()=>{l.current=e});const c=s.useCallback(()=>{const{allRenderableRows:w,getRowId:g,navigationColumns:p}=l.current;return ar(w,g,p)},[]),a=s.useCallback(()=>{const{selection:w}=l.current;return w.enabled?w.getCurrentRange().resolved:null},[]),u=s.useCallback(w=>{const g=a();if(g&&w.rowIds[g.top]!==void 0&&w.columns[g.left])return{id:w.rowIds[g.top],field:w.columns[g.left].field};const p=l.current.focusedCell;return p&&p.id!==null&&je(p.field)?{id:p.id,field:p.field}:null},[a]),f=s.useCallback(async(w,g,p)=>{const m=c(),C=g??u(m);let b=w;const{onBeforeClipboardPaste:_}=l.current;if(_){const U=Be(()=>_({text:b,anchor:C}));if(!U.ok)return St("onBeforeClipboardPaste","onBeforeClipboardPaste threw; the paste was cancelled",U.error),Yn();if(U.value===!1)return Yn();typeof U.value=="string"&&(b=U.value)}if(!C)return Yn();const v=$u(b),k=m.rowIndexById.get(C.id),A=m.colIndexByField.get(C.field);if(v.length===0||k===void 0||A===void 0)return Yn();const M=m.rowIds.length-1,N=m.columns.length-1,P=g?null:a(),T=P&&Et(P)>1?P:null,S=v.length===1&&v[0].length===1,I=v.reduce((U,re)=>Math.max(U,re.length),0);let F;S&&T?F=T:F={top:k,left:A,bottom:Math.min(k+v.length-1,M,T?T.bottom:M),right:Math.min(A+I-1,N,T?T.right:N)};const L=Et(F);L>$l&&tf(L);const{batchEdit:E,isCellEditable:O,rowMetaMap:B,getSpanOrigin:H}=l.current,K={isCellEditable:O,rowMetaMap:B,getSpanOrigin:H},R=[],X=[];for(let U=F.top;U<=F.bottom;U++){const re=m.rowIds[U],q=E.getRow(re)??m.rows[U],se=S?v[0]:v[U-F.top];for(let Z=F.left;Z<=F.right;Z++){const $=S?v[0][0]:se?.[Z-F.left];if($===void 0)continue;const D=m.columns[Z];if(!cr(m,K,q,U,Z)){X.push({id:re,field:D.field,reason:"notEditable"});continue}const G=Zu($,D,q,{current:Se(q,D.field,D)});if(!G.ok){X.push({id:re,field:D.field,reason:"invalidValue"});continue}R.push({id:re,field:D.field,value:G.value})}}if(l.current.selection.enabled){const{anchor:U,head:re}=Dl(m,F);l.current.selection.setModel([{anchor:U,head:re}],p?"keyboard":"api")}const j=await E.applyEdits(R,"paste"),Q={updated:j.result.updated,failed:j.result.failed,skipped:[...X,...j.result.skipped]};return l.current.onClipboardPaste?.({...Q,text:b}),Q},[c,u,a]),h=s.useCallback(()=>{const w=a();if(!w||Et(w)<=1)return!1;const g=c(),{batchEdit:p,isCellEditable:m,rowMetaMap:C,getSpanOrigin:b}=l.current,_={isCellEditable:m,rowMetaMap:C,getSpanOrigin:b},v=[];for(let k=w.top;k<=w.bottom;k++){const A=g.rowIds[k];if(A===void 0)continue;const M=p.getRow(A)??g.rows[k];for(let N=w.left;N<=w.right;N++){const P=g.columns[N];!P||!cr(g,_,M,k,N)||v.push({id:A,field:P.field,value:ef(P)?"":null})}}return p.applyEdits(v,"clear"),!0},[a,c]),x=o.enabled&&!r,y=o.enabled&&!i;s.useEffect(()=>{const w=n.current;if(!w||!x&&!y)return;const g=k=>{const A=l.current.viewportRef.current;if(!A||k.defaultPrevented||l.current.isEditing)return!1;const M=Gn(k.target,A);return M==="grid"||M==="control"};let p=null;const m=()=>{if(!p)return;const{textarea:k,restore:A,timer:M}=p;p=null,window.clearTimeout(M);const N=document.activeElement===k;k.remove(),N&&A&&A.isConnected&&A.focus({preventScroll:!0})},C=()=>{m();const k=document.createElement("textarea");k.setAttribute("aria-hidden","true"),k.tabIndex=-1,k.className="ogx__paste-capture",k.style.cssText="position:fixed;top:0;left:-10000px;width:1px;height:1px;opacity:0;",w.appendChild(k);const A=document.activeElement instanceof HTMLElement?document.activeElement:null;p={textarea:k,restore:A,timer:window.setTimeout(m,250)},k.focus({preventScroll:!0})},b=k=>p!==null&&k.target===p.textarea,_=k=>{if(b(k)){const M=k.clipboardData?k.clipboardData.getData("text/plain"):"";k.preventDefault(),m(),M!==""&&f(M,void 0,!0);return}if(!x||!g(k)||!l.current.navigationColumns.some(M=>M.editable))return;const A=k.clipboardData?k.clipboardData.getData("text/plain"):"";A!==""&&(k.preventDefault(),f(A,void 0,!0))},v=k=>{if((k.ctrlKey||k.metaKey)&&!k.altKey&&!k.shiftKey&&(k.key==="v"||k.key==="V"||k.code==="KeyV")){x&&g(k)&&l.current.navigationColumns.some(A=>A.editable)&&C();return}!y||k.key!=="Delete"&&k.key!=="Backspace"||k.ctrlKey||k.metaKey||k.altKey||k.shiftKey||g(k)&&h()&&k.preventDefault()};return w.addEventListener("paste",_),w.addEventListener("keydown",v),()=>{m(),w.removeEventListener("paste",_),w.removeEventListener("keydown",v)}},[n,x,y,f,h]),s.useLayoutEffect(()=>{t.current.pasteText=(w,g)=>f(w,g,!1)},[t,f])}const of=100;function rf(){const e=s.useRef(null),t=s.useCallback((o,r)=>{const i=e.current;i&&i(o,r)},[]),n=s.useCallback(o=>{e.current=o},[]);return s.useMemo(()=>({emit:t,setListener:n}),[t,n])}const Gl=()=>({updated:[],failed:[],skipped:[]});function lf(e){if(e.altKey||!(e.ctrlKey||e.metaKey))return null;const t=(e.key??"").toLowerCase(),n=/^[a-z]$/.test(t),o=t==="z"||!n&&e.code==="KeyZ",r=t==="y"||!n&&e.code==="KeyY";return o?e.shiftKey?"redo":"undo":r&&e.ctrlKey&&!e.shiftKey?"redo":null}function sf(e){const{apiRef:t,enabled:n,channel:o,containerRef:r}=e,i=s.useRef(e);s.useLayoutEffect(()=>{i.current=e});const l=s.useRef([]),c=s.useRef([]),a=s.useRef({canUndo:!1,canRedo:!1,size:0}),u=s.useRef(Promise.resolve()),f=s.useCallback(()=>{const m={canUndo:l.current.length>0,canRedo:c.current.length>0,size:l.current.length},C=a.current;C.canUndo===m.canUndo&&C.canRedo===m.canRedo&&C.size===m.size||(a.current=m,i.current.onHistoryChange?.(m))},[]),h=s.useCallback(m=>{if(!i.current.enabled||m.length===0)return;const C=l.current;C.push(m);const b=Math.max(1,i.current.limit);C.length>b&&C.splice(0,C.length-b),c.current=[],f()},[f]);s.useLayoutEffect(()=>(o.setListener(n?h:null),()=>o.setListener(null)),[o,n,h]);const x=s.useCallback(()=>{l.current=[],c.current=[],f()},[f]);s.useEffect(()=>{n||x()},[n,x]);const y=s.useCallback(m=>{const C=i.current,b=ar(C.allRenderableRows,C.getRowId,C.navigationColumns),_=Qu(b,m);if(!_)return;const{anchor:v,head:k}=Dl(b,_);C.selection.enabled?C.selection.setModel([{anchor:v,head:k}],"keyboard"):C.setFocusedCell({id:v.id,field:v.field,rowIndex:_.top});const A=C.viewportRef.current;A&&(Wn(A,_.top-C.pinnedTopRowCount,C.layout.cumulativeHeights,C.layout.pinnedBottomHeight,C.rowHeight),Ho(A,C.layout.unpinnedColsWithWidth.findIndex(M=>M.field===v.field),C.layout))},[]),w=s.useCallback(m=>{const C=async()=>{if(!i.current.enabled)return Gl();const _=m==="undo"?l:c,v=m==="undo"?c:l,k=_.current.pop();if(!k)return Gl();f();const A=k.map(P=>m==="undo"?{id:P.id,field:P.field,value:P.before,expect:{value:P.after}}:{id:P.id,field:P.field,value:P.after,expect:{value:P.before}}),M=await i.current.batchEdit.applyEdits(A,m);M.committed.length>0&&v.current.push(m==="undo"?M.committed.map(P=>({id:P.id,field:P.field,before:P.after,after:P.before})):M.committed);const N=new Set(M.result.failed.map(P=>P.id));if(N.size>0){const P=k.filter(T=>N.has(T.id));P.length>0&&_.current.push(P)}return f(),M.committed.length>0&&y(M.committed),M.result},b=u.current.then(C,C);return u.current=b,b},[f,y]),g=s.useCallback(()=>w("undo"),[w]),p=s.useCallback(()=>w("redo"),[w]);s.useEffect(()=>{const m=r.current;if(!m||!n)return;const C=b=>{if(b.defaultPrevented)return;const _=lf(b);if(!_)return;const v=i.current.viewportRef.current;if(!v||i.current.isEditing)return;const k=Gn(b.target,v);k!=="grid"&&k!=="control"||(b.preventDefault(),_==="undo"?g():p())};return m.addEventListener("keydown",C),()=>m.removeEventListener("keydown",C)},[r,n,g,p]),s.useLayoutEffect(()=>{const m=t.current;m.undo=g,m.redo=p,m.canUndo=()=>i.current.enabled&&l.current.length>0,m.canRedo=()=>i.current.enabled&&c.current.length>0,m.clearHistory=x},[t,g,p,x])}function af(e){const t=String(e);if(t.includes("e")||t.includes("E"))return null;const n=t.indexOf(".");return n===-1?0:t.length-n-1}function dr(e,t){return t===null?e:Number(e.toFixed(Math.min(t,20)))}function cf(e,t){let n=0;for(const l of e){const c=af(l);n=c===null||n===null?null:Math.max(n,c)}const o=dr(e[1]-e[0],n);for(let l=2;l<e.length;l++)if(dr(e[l]-e[l-1],n)!==o)return null;const r=e[e.length-1],i=[];for(let l=1;l<=t;l++)i.push(dr(r+o*l,n));return i}const df=864e5,Hl=e=>((e.getHours()*60+e.getMinutes())*60+e.getSeconds())*1e3+e.getMilliseconds(),uf=e=>Math.round(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())/df),ff=e=>e.getFullYear()*12+e.getMonth(),gf=(e,t)=>new Date(e,t+1,0).getDate();function ur(e){const t=e[1]-e[0];for(let n=2;n<e.length;n++)if(e[n]-e[n-1]!==t)return null;return t}function pf(e,t){const n=e[e.length-1],o=e.every(l=>Hl(l)===Hl(n));if(o&&e.every(l=>l.getDate()===n.getDate())){const l=ur(e.map(ff));if(l!==null&&l!==0){const c=[];for(let a=1;a<=t;a++){const u=n.getMonth()+l*a,f=n.getFullYear()+Math.floor(u/12),h=(u%12+12)%12,x=new Date(n.getTime());x.setFullYear(f,h,Math.min(n.getDate(),gf(f,h))),c.push(x)}return c}}if(o){const l=ur(e.map(uf));if(l===null)return null;const c=[];for(let a=1;a<=t;a++){const u=new Date(n.getTime());u.setDate(n.getDate()+l*a),c.push(u)}return c}const r=ur(e.map(l=>l.getTime()));if(r===null)return null;const i=[];for(let l=1;l<=t;l++)i.push(new Date(n.getTime()+r*l));return i}const hf=e=>typeof e=="number"&&Number.isFinite(e),mf=e=>e instanceof Date&&!Number.isNaN(e.getTime());function wf(e,t){return e.length<2?null:e.every(hf)?cf(e,t):e.every(mf)?pf(e,t):null}const bf=e=>e instanceof Date?new Date(e.getTime()):e;function xf(e,t,n){if(e.length===0||t<=0)return[];const o=n?wf(e,t):null;if(o)return o;const r=[];for(let i=0;i<t;i++)r.push(bf(e[i%e.length]));return r}function Cf(e,t,n,o){const r=t.row>e.bottom||t.row<e.top,i=t.col>e.right||t.col<e.left;return!r&&!i?null:r&&(!i||Math.abs(o)>=Math.abs(n))?t.row>e.bottom?{rect:{...e,bottom:t.row},direction:"down"}:{rect:{...e,top:t.row},direction:"up"}:t.col>e.right?{rect:{...e,right:t.col},direction:"right"}:{rect:{...e,left:t.col},direction:"left"}}function yf(e,t,n){const o=(a,u)=>{const f=[];if(a<=u)for(let h=a;h<=u;h++)f.push(h);else for(let h=a;h>=u;h--)f.push(h);return f},i=n==="down"||n==="up"?o(e.left,e.right):o(e.top,e.bottom);let l,c;switch(n){case"down":l=o(e.top,e.bottom),c=t.bottom>e.bottom?o(e.bottom+1,t.bottom):[];break;case"up":l=o(e.bottom,e.top),c=t.top<e.top?o(e.top-1,t.top):[];break;case"right":l=o(e.left,e.right),c=t.right>e.right?o(e.right+1,t.right):[];break;default:l=o(e.right,e.left),c=t.left<e.left?o(e.left-1,t.left):[]}return i.map(a=>({line:a,source:l,targets:c}))}function vf(e,t,n){const o=n.row===e.top||n.row===e.bottom,r=n.col===e.left||n.col===e.right;let i=n.row,l=n.col;return(!o||!r)&&(t==="down"||t==="up"?(i=t==="down"?e.top:e.bottom,l=n.col===e.right?e.right:e.left):(l=t==="right"?e.left:e.right,i=n.row===e.bottom?e.bottom:e.top)),{anchor:{row:i,col:l},head:{row:i===e.top?e.bottom:e.top,col:l===e.left?e.right:e.left}}}function Sf(e,t,n,o){const r=t(e.bottom),i=n[e.right];if(r===void 0||i===void 0)return null;const l=o?.(r,i);if(!l||l.rowId===r&&l.field===i)return{row:e.bottom,field:i};for(let c=e.bottom;c>=Math.max(0,e.bottom-_f);c--)if(t(c)===l.rowId)return{row:c,field:l.field};return null}const _f=1e3,kf="ogx__cell-fill-handle";function Ef(e){if(e.altKey||e.shiftKey||!(e.ctrlKey||e.metaKey))return null;const t=(e.key??"").toLowerCase(),n=/^[a-z]$/.test(t);return t==="d"||!n&&e.code==="KeyD"?"down":t==="r"||!n&&e.code==="KeyR"?"right":null}function Mf(e){const{containerRef:t,viewportRef:n,selection:o,disableFillHandle:r,isEditing:i,allRenderableRows:l,getRowId:c,navigationColumns:a,columnIndexMap:u,getSpanOrigin:f}=e,h=s.useRef(e);s.useLayoutEffect(()=>{h.current=e});const x=o.enabled&&!r,y=s.useMemo(()=>a.some(M=>M.editable),[a]),w=o.resolved,g=s.useMemo(()=>{if(!x||!y||!w)return null;const M=a.filter(S=>je(S.field)).map(S=>S.field),P=Sf(w,S=>{const I=l[S];return I===void 0?void 0:c(I)},M,f);if(!P)return null;const T=u.get(P.field);return T===void 0?null:{row:P.row,col:T}},[x,y,w,l,c,a,u,f]),p=s.useRef(!0);s.useEffect(()=>(p.current=!0,()=>{p.current=!1}),[]);const m=s.useCallback(()=>{const M=h.current;return ar(M.allRenderableRows,M.getRowId,M.navigationColumns)},[]),C=s.useCallback((M,N,P,T,S)=>{const I=vf(N,P,T),F=L=>({id:M.rowIds[L.row],field:M.columns[L.col].field});h.current.selection.setModel([{anchor:F(I.anchor),head:F(I.head)}],S)},[]),b=s.useCallback(async(M,N,P,T,S,I,F)=>{const{batchEdit:L,isCellEditable:E,rowMetaMap:O,getSpanOrigin:B}=h.current,H={isCellEditable:E,rowMetaMap:O,getSpanOrigin:B},K=T==="down"||T==="up",R=re=>{const q=M.rowIds[re];return q===void 0?void 0:L.getRow(q)??M.rows[re]},X=[],j=[];for(const re of yf(N,P,T)){if(re.targets.length===0)continue;const q=$=>K?{r:$,c:re.line}:{r:re.line,c:$},se=[];for(const $ of re.source){const{r:D,c:G}=q($),W=R(D),ee=M.columns[G];!W||!ee||Ke(M.rowIds[D],O)||se.push(Se(W,ee.field,ee))}if(se.length===0)continue;const Z=xf(se,re.targets.length,!S);re.targets.forEach(($,D)=>{const{r:G,c:W}=q($),ee=R(G),V=M.columns[W],Y=M.rowIds[G];if(!ee||!V||Y===void 0)return;if(!cr(M,H,ee,G,W)){j.push({id:Y,field:V.field,reason:"notEditable"});return}let J=Z[D];const te=V.fillValue;if(te){const ne=Be(()=>te.call(V,{row:ee,id:Y,field:V.field,colDef:V,direction:T,sourceValues:se.slice(),index:D,value:J,copy:S}));if(!ne.ok){St(`fillValue:${V.field}`,`fillValue of column "${V.field}" threw; the cell was skipped`,ne.error),j.push({id:Y,field:V.field,reason:"invalidValue"});return}J=ne.value}X.push({id:Y,field:V.field,value:J})})}C(M,P,T,I,F);const Q=await L.applyEdits(X,"fill"),U={updated:Q.result.updated,failed:Q.result.failed,skipped:[...j,...Q.result.skipped],direction:T};return h.current.onFill?.(U),U},[C]),_=s.useRef(null),v=s.useCallback((M,N,P)=>{const T=_.current,S=h.current.viewportRef.current;if(!T||!S)return;const I=T.ctx,F=I.rowIndexById.get(M.id),L=I.colIndexByField.get(M.field);if(F===void 0||L===void 0)return;const E=N-T.x+S.scrollLeft-T.scrollLeft,O=P-T.y+S.scrollTop-T.scrollTop,B=Cf(T.source,{row:F,col:L},E,O);T.target=B,B?C(I,B.rect,B.direction,T.anchor,"pointer"):h.current.selection.setModel(T.sourceModel,"pointer")},[C]),k=s.useCallback(({cancelled:M,altKey:N})=>{const P=_.current;if(_.current=null,!P||!p.current)return;const T=P.ctx;if(M||!P.target){h.current.selection.setModel(P.sourceModel,"pointer");return}b(T,P.source,P.target.rect,P.target.direction,N,P.anchor,"pointer")},[b]),A=x&&y;return s.useEffect(()=>{const M=n.current;if(!M||!A)return;const N=P=>{if(P.button!==0||!(P.target instanceof Element))return;const T=P.target.closest(`.${kf}`);if(!T||T.closest(".ogx__viewport")!==M||h.current.isEditing)return;const{selection:S}=h.current,{range:I,resolved:F}=S.getCurrentRange();if(!I||!F)return;const L=m(),E=L.rowIds[F.bottom],O=L.columns[F.right];if(E===void 0||!O)return;P.preventDefault();const B=M.ownerDocument;M.contains(B.activeElement)||M.focus({preventScroll:!0}),Be(()=>M.setPointerCapture(P.pointerId)),_.current={source:{top:F.top,bottom:F.bottom,left:F.left,right:F.right},sourceModel:[I],anchor:{row:F.anchorRow,col:F.anchorCol},ctx:L,x:P.clientX,y:P.clientY,scrollLeft:M.scrollLeft,scrollTop:M.scrollTop,target:null},S.startTrackedDrag({start:{id:E,field:O.field},x:P.clientX,y:P.clientY,pointerId:P.pointerId,onTrack:v,onEnd:k})};return M.addEventListener("pointerdown",N),()=>M.removeEventListener("pointerdown",N)},[n,A,m,v,k]),s.useEffect(()=>{const M=t.current;if(!M||!x)return;const N=P=>{if(P.defaultPrevented)return;const T=Ef(P);if(!T)return;const S=h.current.viewportRef.current;if(!S||h.current.isEditing)return;const I=Gn(P.target,S);if(I!=="grid"&&I!=="control")return;const{range:F,resolved:L}=h.current.selection.getCurrentRange();if(!F||!L)return;P.preventDefault();const E={top:L.top,bottom:L.bottom,left:L.left,right:L.right},O=T==="down"?{...E,bottom:E.top}:{...E,right:E.left};(T==="down"?E.bottom===E.top:E.right===E.left)||b(m(),O,E,T,!0,{row:L.anchorRow,col:L.anchorCol},"keyboard")};return M.addEventListener("keydown",N),()=>M.removeEventListener("keydown",N)},[t,x,b,m]),{handle:i?null:g}}function Af(e){const{props:t,apiRef:n,containerRef:o,viewportRef:r,selection:i,model:l,getPendingModel:c,focusedCell:a,setFocusedCell:u,allRenderableRows:f,getRowId:h,navigationColumns:x,columnIndexMap:y,isCellEditable:w,rowMetaMap:g,getSpanOrigin:p,isEditing:m,batchEdit:C,channel:b,layout:_,rowHeight:v,pinnedTopRowCount:k}=e,{disableClipboardPaste:A=!1,disableRangeClear:M=!1,onClipboardPaste:N,onBeforeClipboardPaste:P,undoRedo:T=!1,disableFillHandle:S=!1,onFill:I,onHistoryChange:F}=t;return Du({apiRef:n,selection:i,model:l,getPendingModel:c,focusedCell:a,setFocusedCell:u,containerRef:o}),nf({apiRef:n,containerRef:o,viewportRef:r,selection:i,disableClipboardPaste:A,disableRangeClear:M,focusedCell:a,allRenderableRows:f,getRowId:h,navigationColumns:x,isCellEditable:w,rowMetaMap:g,getSpanOrigin:p,isEditing:m,batchEdit:C,onClipboardPaste:N,onBeforeClipboardPaste:P}),sf({apiRef:n,enabled:!!T,limit:typeof T=="object"&&T.limit||of,onHistoryChange:F,channel:b,batchEdit:C,isEditing:m,containerRef:o,viewportRef:r,selection:i,setFocusedCell:u,allRenderableRows:f,getRowId:h,navigationColumns:x,layout:_,rowHeight:v,pinnedTopRowCount:k}),Mf({containerRef:o,viewportRef:r,selection:i,disableFillHandle:S,isEditing:m,allRenderableRows:f,getRowId:h,navigationColumns:x,columnIndexMap:y,isCellEditable:w,rowMetaMap:g,getSpanOrigin:p,batchEdit:C,onFill:I})}const Pf=100;function Bl(e){const{scrollTop:t,scrollHeight:n,clientHeight:o}=e;return n-t-o>=Pf?null:{visibleTop:t,visibleBottom:t+o,viewportHeight:o}}function Lf(e){return e<.5?3:e<3?5:e<15?12:e<40?20:30}function Nf(e){const{onRowsScrollEnd:t,overscanRowCount:n=3,rowCount:o=0,autoHeight:r=!1}=e,i=s.useRef({scrollTop:0,scrollLeft:0,velocity:0}),l=s.useRef({scrollTop:0,scrollLeft:0,time:0}),c=s.useRef(null),a=s.useRef(null),u=s.useRef(null),f=s.useRef(!0),h=s.useRef(t),[x,y]=s.useState({scrollTop:0,scrollLeft:0,velocityOverscan:0});s.useEffect(()=>{h.current=t},[t]),s.useEffect(()=>()=>{c.current!==null&&cancelAnimationFrame(c.current),a.current!==null&&clearTimeout(a.current)},[]);const w=s.useCallback(m=>{const C=Bl(m);if(!C){f.current=!0;return}if(!f.current)return;const b=h.current;b&&(f.current=!1,b(C))},[]),g=s.useCallback(m=>{const C=m.currentTarget,b=performance.now(),_=$t(C),v=Math.abs(C.scrollTop-l.current.scrollTop)+Math.abs(_-l.current.scrollLeft),k=b-l.current.time,A=k>0?v/k:0,M=C.scrollTop!==l.current.scrollTop;l.current={scrollTop:C.scrollTop,scrollLeft:_,time:b},i.current={scrollTop:C.scrollTop,scrollLeft:_,velocity:A},c.current!==null&&cancelAnimationFrame(c.current),c.current=requestAnimationFrame(()=>{c.current=null;const{scrollTop:N,scrollLeft:P,velocity:T}=i.current;y({scrollTop:N,scrollLeft:P,velocityOverscan:Lf(T)})}),a.current!==null&&clearTimeout(a.current),a.current=setTimeout(()=>{a.current=null,y(N=>N.velocityOverscan===0?N:{...N,velocityOverscan:0})},200),M&&w(C)},[w]);s.useEffect(()=>{f.current=!0;const m=u.current;!m||r||o<=0||m.clientHeight===0||w(m)},[o,r,w]),s.useEffect(()=>{const m=u.current?.ownerDocument??(typeof document>"u"?null:document);if(!m||typeof MutationObserver>"u")return;const C=new MutationObserver(()=>{const b=u.current;if(!b)return;const _={scrollTop:b.scrollTop,scrollLeft:$t(b)},v=i.current;_.scrollTop===v.scrollTop&&_.scrollLeft===v.scrollLeft||(i.current={...v,..._},l.current={...l.current,..._},y(k=>({...k,..._})))});return C.observe(m.documentElement,{attributes:!0,attributeFilter:["dir"],subtree:!0}),()=>C.disconnect()},[]);const p=s.useCallback(m=>{if(u.current=m,!m)return;const{scrollTop:C,scrollLeft:b}=i.current;if(C===0&&b===0)return;m.scrollTop=C,nn(m,b);const _={scrollTop:m.scrollTop,scrollLeft:$t(m)};(_.scrollTop!==C||_.scrollLeft!==b)&&(i.current={...i.current,..._},l.current={...l.current,..._},y(v=>({...v,..._})))},[]);return{scrollTop:x.scrollTop,scrollLeft:x.scrollLeft,overscanRows:Math.max(x.velocityOverscan,n),handleScroll:g,attachViewport:p}}function If(e){const t=s.useRef(null);return s.useCallback(n=>{if(t.current?.disconnect(),t.current=null,!n||typeof ResizeObserver>"u")return;const o=new ResizeObserver(r=>{for(const i of r){const{width:l,height:c}=i.contentRect;e(l,c)}});o.observe(n),t.current=o},[e])}function Ff(e){const{setDimensions:t,viewportRef:n,...o}=e,{scrollTop:r,scrollLeft:i,overscanRows:l,handleScroll:c,attachViewport:a}=Nf(o),u=If(t),f=s.useCallback(h=>{n.current=h,u(h),a(h)},[n,u,a]);return{scrollTop:r,scrollLeft:i,overscanRows:l,handleScroll:c,setViewportElement:f}}function Tf(e){const[t,n]=s.useState(void 0);return s.useLayoutEffect(()=>{const o=qc(e.current?.ownerDocument);n(r=>r===o?r:o)},[e]),t}function Of(e){const{layout:t,scrollTop:n,scrollLeft:o,viewportWidth:r,viewportHeight:i,autoHeight:l,rowReordering:c,hasDetailPanel:a,checkboxSelection:u,pinCheckboxColumn:f,pinExpandColumn:h,overscanRows:x=5,maxContentHeight:y=1/0}=e,{unpinnedAccWidths:w,unpinnedColsWithWidth:g,leftPinnedCols:p,rightPinnedCols:m,leftWidth:C,unpinnedTotalWidth:b}=t,_=s.useMemo(()=>{const v=r||1e3,k=Math.max(0,o-C),A=o+v-C,M=6;let N=0,P=g.length-1,T=0,S=w.length-1;for(;T<=S;){const E=T+S>>>1;w[E]<k?T=E+1:S=E-1}N=Math.max(0,T-M);for(let E=N;E<w.length;E++){if((E===0?0:w[E-1])>A){P=Math.min(g.length-1,E+M);break}P=Math.min(g.length-1,E+M)}const I=N>0?w[N-1]:0,F=b-w[P],L=[...p,...I>0?[{field:"__spacer_left__",width:I,isSpacer:!0}]:[],...g.slice(N,P+1),...F>0?[{field:"__spacer_right__",width:F,isSpacer:!0}]:[],...m];return{firstUnpinnedIndex:N,lastUnpinnedIndex:P,virtualColumns:L}},[w,g,p,m,C,b,o,r]);return s.useMemo(()=>{const{totalWidth:v,rightWidth:k,systemColumnsWidth:A,cumulativeHeights:M,pinnedTopHeight:N,pinnedBottomHeight:P,unpinnedRowsHeight:T,rowHeights:S,unpinnedRowsLength:I}=t,F=r||1e3,L=l?N+T+P+50:i||600,{firstUnpinnedIndex:E,lastUnpinnedIndex:O,virtualColumns:B}=_,K=F>0&&v>F?16:0,R=N+T+P+K+2,X=R-N-P,j=Number.isFinite(y)?Math.max(0,Math.min(X,y-N-P)):X;let Q=0,U=I-1,re=0,q=0,se=M.length-1;for(;q<=se;){const $=q+se>>>1;M[$]<n?q=$+1:se=$-1}Q=Math.max(0,q-x),re=Q>0?M[Q-1]:0;for(let $=Q;$<M.length;$++)if(M[$]>=n+L){U=Math.min(I-1,$+x);break}const Z=(c?48:0)+(a&&h?48:0)+(u&&f?48:0);return{renderContext:{firstRowIndex:Q,lastRowIndex:U,firstColumnIndex:E,lastColumnIndex:O},offsetTop:re,offsetLeft:0,totalHeight:R,virtualContainerHeight:j,pinnedTopHeight:N,pinnedBottomHeight:P,totalWidth:v,rowHeights:S,cumulativeHeights:M,virtualColumns:B,columnMetrics:{leftPinnedWidth:C,rightPinnedWidth:k,unpinnedAccWidths:w,unpinnedCols:g,totalSpecialsWidth:A,pinnedSpecialsWidth:Z}}},[t,_,C,w,g,n,r,i,l,c,a,u,f,h,x,y])}function Df(e){const{viewport:t,viewportRef:n,containerRef:o,layout:r,viewportWidth:i,viewportHeight:l,virtualization:c}=e,{scrollTop:a,scrollLeft:u,overscanRows:f,handleScroll:h,setViewportElement:x}=Ff({...t,rowCount:r.unpinnedRowsLength,viewportRef:n}),y=Tf(o),w=Of({layout:r,scrollTop:a,scrollLeft:u,viewportWidth:i,viewportHeight:l,...c,overscanRows:f,maxContentHeight:y??1/0});return{handleScroll:h,setViewportElement:x,maxContentHeight:y,virtualization:w}}function $f(e){const{apiRef:t,columns:n,getRowId:o,containerRef:r,disableKeyboardShortcut:i,getCellRangeCopyText:l}=e,c=s.useCallback(()=>r.current,[r]),{copySelectedRows:a}=Ou({getSelectedRowIds:()=>t.current.getSelectedRows(),getColumns:()=>n,getRows:()=>t.current.getAllFilteredRows(),getRowId:o,getRootElement:c,disableKeyboardShortcut:i,getShortcutText:l});s.useLayoutEffect(()=>{t.current.copySelectedRows=a},[a,t])}function Gf(e){const{apiRef:t}=e,n=s.useRef(e);s.useLayoutEffect(()=>{n.current=e}),s.useLayoutEffect(()=>{t.current.scrollToIndexes=({rowIndex:o,colIndex:r})=>{const{viewportRef:i,layout:l,rowHeight:c}=n.current,a=i.current;if(a&&(o!==void 0&&o>=0&&Wn(a,o,l.cumulativeHeights,l.pinnedBottomHeight,c),r!==void 0&&r>=0)){const f=[...l.leftPinnedCols,...l.unpinnedColsWithWidth,...l.rightPinnedCols][r];if(!f)return;Ho(a,l.unpinnedColsWithWidth.findIndex(h=>h.field===f.field),l)}}},[t])}const Wl=50;function fr(e,t,n,o){const r=Math.min(n??Wl,t),i=Math.max(o??1/0,t);return Math.max(r,Math.min(i,e))}const Hf=".ogx";function Vl(e,t){const n=t.style.cssText;t.style.width="max-content",t.style.minWidth="0",t.style.maxWidth="none",t.style.flex="none";const o=t.getBoundingClientRect().width;t.style.cssText=n;const r=getComputedStyle(e),i=[r.paddingLeft,r.paddingRight,r.borderLeftWidth,r.borderRightWidth].reduce((l,c)=>l+(parseFloat(c)||0),0);return o+i}function Bf(e,t){const n=typeof CSS<"u"&&CSS.escape?CSS.escape(t):t.replace(/["\\]/g,"\\$&"),o=l=>l.closest(Hf)===e;let r=null;const i=l=>{r=r===null?l:Math.max(r,l)};return e.querySelectorAll(`[role="columnheader"][data-field="${n}"]`).forEach(l=>{if(!o(l))return;const c=l.querySelector(".ogx__header-cell-content");c&&i(Vl(l,c))}),e.querySelectorAll(`[role="gridcell"][data-field="${n}"]`).forEach(l=>{if(!o(l)||l.hasAttribute("aria-colspan"))return;const c=l.querySelector(":scope > .ogx__cell-content");c&&i(Vl(l,c))}),r===null?null:Math.ceil(r)}function Wf(e,t,n){return Math.max(t??Wl,Math.min(n??1/0,e))}function Vf(e){const{apiRef:t}=e,n=s.useRef(e);s.useLayoutEffect(()=>{n.current=e});const o=s.useCallback(i=>{const{containerRef:l,columns:c,onColumnResize:a}=n.current,u=l.current;if(!u)return;const f=[];for(const h of i??c.map(x=>x.field)){const x=c.find(w=>w.field===h);if(!x||x.resizable===!1)continue;const y=Bf(u,h);y!==null&&f.push([h,Wf(y,x.minWidth,x.maxWidth)])}for(const[h,x]of f)a(h,x)},[]),r=s.useCallback(i=>o([i]),[o]);return s.useLayoutEffect(()=>{t.current.autosizeColumn=r,t.current.autosizeColumns=o},[t,r,o]),r}function zf(e){const{apiRef:t,containerRef:n,viewportRef:o,copyColumns:r,getRowId:i,disableClipboardCopy:l,getCellRangeCopyText:c,layout:a,rowHeight:u,orderedColumns:f,onColumnResize:h}=e;return $f({apiRef:t,columns:r,getRowId:i,containerRef:n,disableKeyboardShortcut:l,getCellRangeCopyText:c}),Gf({apiRef:t,viewportRef:o,layout:a,rowHeight:u}),Vf({apiRef:t,containerRef:n,columns:f,onColumnResize:h})}class zl extends Error{}function gt(e,t){return e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Object.is(e,t)}function Rl(e){return typeof e=="object"&&e!==null&&typeof e.then=="function"}function Ul(e,t){t?t(e):process.env.NODE_ENV!=="production"&&e instanceof zl&&console.error(e.message)}function Kl(e,t){return new zl(`[OpenGridX] processRowUpdate must return the updated row object (or a Promise of it); it returned ${e===null?"null":typeof e}. ${t}`)}function jl(e,t,n,o){return n?.valueSetter?n.valueSetter({value:t.value,row:e,field:t.field}):(n?.valueGetter&&process.env.NODE_ENV!=="production"&&!o.has(t.field)&&(o.add(t.field),console.warn(`[OpenGridX] Column "${t.field}" is editable and has a valueGetter but no valueSetter. The edited value was written to row["${t.field}"], which the valueGetter may ignore, so the cell can keep showing the old value. Add a valueSetter that maps the value back onto the row.`)),{...e,[t.field]:t.value})}function Rf(e){const t=s.useRef(e),n=s.useRef(new Map),o=s.useRef(new Set);s.useLayoutEffect(()=>{t.current=e,n.current.clear()});const r=s.useCallback(a=>{const u=n.current.get(a);return u===void 0?t.current.rowsLookup.get(a):u},[]),i=s.useCallback(a=>{a.size!==0&&(a.forEach((u,f)=>{n.current.set(f,u)}),t.current.replaceRows(a))},[]),l=s.useCallback((a,u)=>{i(new Map([[a,u]]))},[i]),c=s.useCallback((a,u)=>{const{columns:f,processRowUpdate:h}=t.current,x=v=>Ul(v,t.current.onProcessRowUpdateError),y=new Map,w=new Map;f.forEach((v,k)=>{y.set(v.field,k),w.set(v.field,v)});const g=[],p=new Map;for(const v of a){const k=r(v.id);if(k===void 0){g.push({id:v.id,field:v.field,reason:"missing"});continue}const A=w.get(v.field);if(v.expect&&!gt(Se(k,v.field,A),v.expect.value)){g.push({id:v.id,field:v.field,reason:"changed"});continue}let M=p.get(v.id);M||(M={id:v.id,row:k,cells:[]},p.set(v.id,M));const N=y.get(v.field)??Number.MAX_SAFE_INTEGER,P=M.cells.findIndex(S=>S.field===v.field),T={field:v.field,value:v.value,colDef:A,order:N};P===-1?M.cells.push(T):M.cells[P]=T}const m=[],C=[],b=o.current;p.forEach(v=>{const{id:k,row:A}=v,M=v.cells.filter(T=>!gt(Se(A,T.field,T.colDef),T.value)).sort((T,S)=>T.order-S.order);if(v.cells=M,M.length===0)return;const N=Be(()=>{let T=A;for(const S of M)T=jl(T,S,S.colDef,b);return h?h(T,A):T});if(!N.ok){m.push({id:k,ok:!1,error:N.error});return}const P=N.value;Rl(P)?C.push(Promise.resolve(P).then(T=>({id:k,ok:!0,processed:T}),T=>({id:k,ok:!1,error:T}))):m.push({id:k,ok:!0,processed:P})});const _=v=>{const k=new Map;v.forEach(T=>{k.set(T.id,T)});const A=[],M=[],N=[],P=new Map;return p.forEach(T=>{const S=k.get(T.id);if(!S)return;if(!S.ok){M.push({id:T.id,error:S.error}),x(S.error);return}const I=S.processed;if(typeof I!="object"||I===null){const L=Kl(I,"The row was not saved.");M.push({id:T.id,error:L}),x(L);return}const F=I;P.set(T.id,F),A.push(T.id);for(const L of T.cells){const E=Se(T.row,L.field,L.colDef),O=Se(F,L.field,L.colDef);gt(E,O)||N.push({id:T.id,field:L.field,before:E,after:O})}}),i(P),N.length>0&&u!=="undo"&&u!=="redo"&&t.current.onCommitted?.(N,u),{result:{updated:A,failed:M,skipped:g},committed:N}};return C.length===0?Promise.resolve(_(m)):Promise.all(C).then(v=>_([...m,...v]))},[r,i]);return s.useMemo(()=>({applyEdits:c,getRow:r,storeRow:l}),[c,r,l])}const Ut=Promise.resolve();function Uf(e){const[t,n]=s.useState(null),o=s.useRef(null),r=s.useRef(0),i=s.useRef(new Map),l=s.useRef(new Set),c=s.useRef(!1),a=s.useRef(e);s.useLayoutEffect(()=>{a.current=e}),s.useEffect(()=>(c.current=!0,()=>{c.current=!1}),[]);const u=s.useCallback(g=>{o.current=g,n(g)},[]),f=s.useRef(null),h=s.useCallback((g,p)=>{const m=i.current.get(g);if(m)return gt(m.value,p.value)?m.promise:m.promise.then(()=>{const H=o.current;if(!(r.current!==g||!H||gt(H.value,m.value)))return f.current?.(g,H)});const C=()=>r.current===g&&o.current!==null;if(gt(p.value,p.originalValue))return C()&&u(null),Ut;const{rows:b,getRowId:_,columns:v,processRowUpdate:k}=a.current,A=b.find(H=>_(H)===p.id);if(!A)return C()&&u(null),Ut;const M=H=>Ul(H,a.current.onProcessRowUpdateError),N=v?.find(H=>H.field===p.field),P=H=>{if(typeof H!="object"||H===null){M(Kl(H,"The edit was not saved and the editor stays open."));return}a.current.onRowChange?.(H,p.id);const{onCommitted:K}=a.current;if(K){const X=Se(A,p.field,N),j=Se(H,p.field,N);gt(X,j)||K([{id:p.id,field:p.field,before:X,after:j}])}const R=o.current;r.current!==g||!R||(gt(R.value,p.value)?u(null):u({...R,originalValue:p.value}))};let T,S;const I=new Promise((H,K)=>{T=H,S=K}),F={value:p.value,promise:I};i.current.set(g,F);const L=()=>{i.current.get(g)===F&&i.current.delete(g)},E=Be(()=>{const H=jl(A,p,N,l.current);return k?k(H,A):H});if(!E.ok)return L(),M(E.error),T(),I;const O=E.value,B=H=>{L();try{P(H),T()}catch(K){S(K)}};return Rl(O)?Promise.resolve(O).then(B,H=>{L(),M(H),T()}):B(O),I},[u]);s.useLayoutEffect(()=>{f.current=h},[h]);const x=s.useCallback(g=>{const p=o.current;if(p){if(p.id===g.id&&p.field===g.field)return;h(r.current,p)}r.current+=1,u({id:g.id,field:g.field,value:g.value,originalValue:g.value})},[h,u]),y=s.useCallback(g=>{const p=o.current;return!p||!c.current||g?.id!==void 0&&g.id!==p.id||g?.field!==void 0&&g.field!==p.field?Ut:g?.cancel?(u(null),Ut):h(r.current,p)},[h,u]),w=s.useCallback(g=>{const p=o.current;!p||p.id!==g.id||p.field!==g.field||u({...p,value:g.value})},[u]);return s.useMemo(()=>({editingCell:t,startCellEdit:x,stopCellEdit:y,setEditCellValue:w}),[t,x,y,w])}function Kf(e){const{rowsLookup:t,rows:n,getRowId:o,columns:r,processRowUpdate:i,onProcessRowUpdateError:l,replaceRows:c}=e,a=rf(),u=Rf({rowsLookup:t,columns:r,processRowUpdate:i,onProcessRowUpdateError:l,replaceRows:c,onCommitted:a.emit}),f=Uf({rows:n,getRowId:o,columns:r,processRowUpdate:i,onProcessRowUpdateError:l,onRowChange:(h,x)=>{u.storeRow(x,h)},onCommitted:h=>a.emit(h,"edit")});return{editCommitChannel:a,batchEdit:u,editingHandlers:f}}const jf=e=>e.id,qf={hasColSpan:!1,hasRowSpan:!1,colspanMap:new Map,rowSpanningCaches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},getSpanOrigin:()=>null,getUnpinnedColSpanRanges:()=>{},getCenterRowSpanStart:e=>e},ql="\0",Xl="";function Yl(e){if(typeof e!="number"||Number.isNaN(e))return 1;if(e===1/0)return Number.MAX_SAFE_INTEGER;if(!Number.isFinite(e))return 1;const t=Math.floor(e);return t<1?1:t}function Xf(e){return e.map(t=>t.field).join(ql)}function Yf(e){const{pinnedTopRows:t,centerRows:n,pinnedBottomRows:o,columns:r,leftPinnedColumns:i,unpinnedColumns:l,rightPinnedColumns:c,expandedRowIds:a,rowMetaMap:u,getRowId:f=jf}=e,h=s.useMemo(()=>r.some(m=>m.colSpan!==void 0&&m.colSpan!==null),[r]),x=s.useMemo(()=>r.some(m=>m.rowSpan!==void 0&&m.rowSpan!==null),[r]),y=h||x,w=y?[i,l,c].map(Xf).join(Xl):"",g=s.useMemo(()=>{if(!w)return{columns:[],leftCount:0,unpinnedCount:0};const m=new Map(r.map(v=>[v.field,v])),C=w.split(Xl).map(v=>v?v.split(ql):[]),b=[];let _=0;for(const v of C){_+=v.length;for(const k of v){const A=m.get(k)??{field:k};b.push({colDef:A,field:k,sectionEnd:_,hasColSpan:A.colSpan!==void 0&&A.colSpan!==null,hasRowSpan:A.rowSpan!==void 0&&A.rowSpan!==null})}}return{columns:b,leftCount:C[0].length,unpinnedCount:C[1].length}},[w,r]),p=s.useMemo(()=>{if(!y||g.columns.length===0)return null;const m={colspanMap:new Map,rowSpanningCaches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},hiddenOriginFields:new Map,unpinnedRanges:new Map,centerRowSpanStart:new Map},b={spanColumns:g,expandedRowIds:a,rowMetaMap:u,getRowId:f,warned:new Set,out:m};return gr(t,0,!1,b),gr(n,t.length,!0,b),gr(o,t.length+n.length,!1,b),m},[y,g,t,n,o,a,u,f]);return s.useMemo(()=>{if(!p)return qf;const{colspanMap:m,rowSpanningCaches:C,hiddenOriginFields:b,unpinnedRanges:_,centerRowSpanStart:v}=p,k=g.columns;return{hasColSpan:h,hasRowSpan:x,colspanMap:m,rowSpanningCaches:C,getSpanOrigin:(A,M)=>{const N=m.get(A)?.[M];if(N?.spannedByColSpan)return{rowId:A,field:k[N.leftVisibleCellIndex].field};const P=C.hiddenCellOriginMap[A]?.[M];return P===void 0?null:{rowId:P,field:b.get(A)?.[M]??M}},getUnpinnedColSpanRanges:A=>_.get(A),getCenterRowSpanStart:A=>v.get(A)??A}},[p,h,x,g])}function gr(e,t,n,o){const{spanColumns:r,expandedRowIds:i,rowMetaMap:l,getRowId:c,warned:a,out:u}=o,{columns:f,leftCount:h,unpinnedCount:x}=r,y=f.length,{colspanMap:w,rowSpanningCaches:g,hiddenOriginFields:p,unpinnedRanges:m,centerRowSpanStart:C}=u,b=new Int32Array(y),_=new Array(y),v=new Array(y),k=new Int32Array(y);let A=0;const M=[];f.forEach((T,S)=>{(T.hasColSpan||T.hasRowSpan)&&M.push(S)});const N=(T,S,I)=>{const F=f[I].field;if(Kt(g.hiddenCells,T,F,!0),Kt(g.hiddenCellOriginMap,T,F,_[I]),v[I]!==F&&Kt(p,T,F,v[I]),n){const L=C.get(S);(L===void 0||k[I]<L)&&C.set(S,k[I])}},P=(T,S,I)=>{const F=f[I],L=c(T),E=Jf(T,L,F.colDef,t+S,I,l,a);let O=1;if(F.hasColSpan){const H=Math.min(Jl(F.colDef.colSpan,E,"colSpan",F.field,a),F.sectionEnd-I);for(;O<H&&b[I+O]<=S;)O++}let B=1;if(F.hasRowSpan){B=Math.min(Jl(F.colDef.rowSpan,E,"rowSpan",F.field,a),e.length-S);for(let H=1;H<B;H++)if(Ke(c(e[S+H]),l)){B=H;break}if(B>1&&i&&i.size>0){for(let H=0;H<B-1;H++)if(i.has(c(e[S+H]))){B=H+1;break}}}if(O>1){Kt(w,L,F.field,{spannedByColSpan:!1,cellProps:{colSpan:O}});for(let H=1;H<O;H++){const K=f[I+H];Kt(w,L,K.field,{spannedByColSpan:!0,leftVisibleCellIndex:I,rightVisibleCellIndex:I+O-1})}if(I>=h&&I<h+x){let H=m.get(L);H||(H=[],m.set(L,H)),H.push(I-h,I+O-1-h)}}if(B>1){Kt(g.spannedCells,L,F.field,B);for(let H=I;H<I+O;H++)b[H]=S+B,_[H]=L,v[H]=F.field,k[H]=S;S+B>A&&(A=S+B)}return O};for(let T=0;T<e.length;T++){const S=e[T];if(!S||Ke(c(S),l))continue;if(A<=T){let F=0;for(const L of M)L>=F&&(F=L+P(S,T,L));continue}let I=0;for(;I<y;)b[I]>T?(N(c(S),T,I),I++):f[I].hasColSpan||f[I].hasRowSpan?I+=P(S,T,I):I++}}function Jf(e,t,n,o,r,i,l){const c=e[n.field];let a=c;if(n.valueGetter)try{a=n.valueGetter({row:e,field:n.field,value:c})}catch(u){Zl(l,`valueGetter:${n.field}`,`valueGetter for column "${n.field}" threw while computing its span`,u),a=void 0}return{row:e,value:a,field:n.field,colDef:n,rowIndex:o,colIndex:r,rowMeta:i?.get(t)}}function Jl(e,t,n,o,r){if(typeof e=="number")return Yl(e);if(typeof e!="function")return 1;try{return Yl(e(t))}catch(i){return Zl(r,`${n}:${o}`,`${n} for column "${o}" threw; the cell is rendered without a span`,i),1}}function Zl(e,t,n,o){process.env.NODE_ENV==="production"||e.has(t)||(e.add(t),console.warn(`[OpenGridX] ${n}.`,o))}function Kt(e,t,n,o){if(e instanceof Map){let i=e.get(t);i||(i={},e.set(t,i)),i[n]=o;return}let r=e[t];r||(r={},e[t]=r),r[n]=o}function Zf(e,t){const{draggedColumn:n,onDragOver:o,onDrop:r,onDragEnd:i}=t,l=s.useMemo(()=>{if(!e||e.length===0)return null;const c=a=>n===null||or(e,n,a);return{onDragOver:o&&(a=>c(a)?o(a):()=>{}),onDrop:r&&(a=>c(a)?r(a):u=>{u.preventDefault(),i?.()})}},[e,n,o,r,i]);return l?{...t,...l}:t}function Ql({dataSource:e,paginationMode:t,sortingMode:n,filterMode:o}){return!!e&&(t==="server"||t==="infinite"||n==="server"||o==="server")}const es=Number.MAX_SAFE_INTEGER,Qf="An unexpected error occurred while loading the data.";function ts(e){return typeof e=="string"&&e?e:typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"&&e.message?e.message:Qf}const eg=300,ns=e=>e.id;function tg(e,t){return e==="infinite"?"infinite":e==="server"?t?"all":"page":"all"}function os(e,t){const n=new Set,o=[];return e.forEach(r=>{const i=t(r);n.has(i)||(n.add(i),o.push({id:i,row:r}))}),o}function rs(e,t,n){const o=new Set(e.map(n)),r=t.filter(i=>!o.has(i.id)).map(i=>i.row);return r.length===0?e:[...e,...r]}function ng(e){const{dataSource:t,sortModel:n,filterModel:o,paginationModel:r,paginationMode:i,sortingMode:l,filterMode:c,aggregationModel:a,rowGroupingActive:u=!1}=e,f=tg(i,u),h=!!t&&i==="server"&&u,x=s.useRef(!1);s.useEffect(()=>{process.env.NODE_ENV==="production"||x.current||!h||(x.current=!0,console.warn("[OpenGridX] `rowGroupingModel` turns pagination off, so the dataSource with `paginationMode: 'server'` is asked for every row (startRow 0, endRow Number.MAX_SAFE_INTEGER) instead of one page. See docs/features/data-source.md."))},[h]);const y=t?.getRows,w=Ql({dataSource:t,paginationMode:i,sortingMode:l,filterMode:c}),g=JSON.stringify([f,f!=="all"||l==="server"?n:null,f!=="all"||c==="server"?o:null,w?a??null:null,f==="all"?null:r.pageSize]),p=f==="all"?0:r.page,m=f==="all"?0:r.pageSize,C=s.useRef({params:e,kind:f});s.useLayoutEffect(()=>{C.current={params:e,kind:f}});const b=s.useRef(0),_=s.useRef(0),v=s.useRef(null),k=s.useRef({page:0,loadedEnd:0,inFlightEnd:null}),A=s.useRef(null),M=s.useRef(!1),N=s.useRef(0),P=s.useRef(!1),T=s.useRef(new Set),S=s.useCallback(()=>{const K=M.current||N.current>0;K!==P.current&&(P.current=K,C.current.params.setDataSourceLoading(K))},[]),I=s.useCallback(()=>{A.current!==null&&(clearTimeout(A.current),A.current=null)},[]),F=s.useCallback(()=>{b.current++,k.current.inFlightEnd=null,M.current=!1},[]),L=s.useCallback(()=>{_.current++,T.current.clear(),N.current=0},[]),E=s.useCallback(async()=>{const{params:K,kind:R}=C.current,X=K.dataSource;if(!X)return!1;const j=k.current,Q=K.paginationModel.pageSize;let U,re;if(R==="infinite"){if(j.inFlightEnd!==null)return!1;if(U=j.loadedEnd,re=(j.page+1)*Q,re<=U)return M.current=!1,S(),!1;j.inFlightEnd=re}else R==="page"?(U=K.paginationModel.page*Q,re=U+Q):(U=0,re=es);const q=++b.current;M.current=!0,S(),K.setDataSourceError(null);let se;try{se=await X.getRows({startRow:U,endRow:re,sortModel:K.sortModel,filterModel:K.filterModel,groupKeys:[],aggregationModel:K.aggregationModel})}catch(Z){return q!==b.current||(j.inFlightEnd=null,M.current=!1,C.current.params.setDataSourceError(Z),console.error("Data Source Error:",Z),S()),!1}if(q!==b.current)return!1;try{const{params:Z}=C.current,$=Z.getRowId??ns,D=os(se.rows,$);if(R==="infinite"&&U>0?Z.setRows(G=>rs(G,D,$),!0):(Z.setRows(D.map(G=>G.row),!0),L()),se.aggregationResults&&Z.onAggregationResults?.(se.aggregationResults),se.rowCount!==void 0&&Z.setRowCount(se.rowCount),R==="infinite"&&(j.inFlightEnd=null,j.loadedEnd=U+se.rows.length,se.rows.length>=re-U&&(j.page+1)*Q>re))return!0}catch(Z){return j.inFlightEnd=null,M.current=!1,C.current.params.setDataSourceError(Z),console.error("Data Source Error:",Z),S(),!1}return M.current=!1,S(),!1},[S,L]),O=s.useCallback(async()=>{for(;await E(););},[E]);s.useLayoutEffect(()=>{if(!y){v.current&&(v.current=null,I(),F(),L(),C.current.params.setDataSourceError(null),S());return}const K=v.current,R=k.current;if(!K||K.key!==g||K.getRows!==y){v.current={key:g,getRows:y},F(),L();const X=f==="infinite"&&K!==null&&p!==0;if(R.page=X?0:p,R.loadedEnd=0,X){const{params:j}=C.current;j.onPaginationModelChange?.({...j.paginationModel,page:0})}}else f==="infinite"?(p<R.page&&(F(),R.loadedEnd=0),R.page=p):F();if(f==="infinite"){const X=R.inFlightEnd!==null;if(X||(R.page+1)*m<=R.loadedEnd){M.current=X,S();return}}return M.current=!0,S(),A.current=setTimeout(()=>{A.current=null,O()},eg),I},[y,g,f,p,m,I,F,L,S,O]),s.useEffect(()=>()=>{F(),L()},[F,L]);const B=s.useCallback(()=>(I(),O()),[I,O]),H=s.useCallback(async(K,R,X)=>{const{params:j}=C.current,Q=j.dataSource;if(!Q)return;const U=JSON.stringify(R),re=T.current;if(re.has(U))return;const q=_.current;re.add(U),N.current++,S();try{const se=await Q.getRows({startRow:0,endRow:es,sortModel:j.sortModel,filterModel:j.filterModel,groupKeys:R,aggregationModel:j.aggregationModel});if(q!==_.current)return;if(se.rows.length>0){const{params:Z}=C.current,$=Z.getRowId??ns,D=os(se.rows,$);Z.setRows(G=>rs(G,D,$),!0)}}catch(se){if(q!==_.current)return;re.delete(U),console.error("Failed to fetch children:",se),X?.(se)}finally{q===_.current&&(N.current--,S())}},[S]);return{fetchRows:B,fetchChildren:H}}function og(e){return(e.serverChildrenCount??0)>0&&(e.children?.length??0)===0}function rg({enabled:e,treeNodes:t,isGroupExpanded:n,getNodePath:o,toggleExpansion:r,fetchChildren:i}){const l=s.useRef({isGroupExpanded:n,toggleExpansion:r});s.useLayoutEffect(()=>{l.current={isGroupExpanded:n,toggleExpansion:r}}),s.useEffect(()=>{e&&t.forEach((c,a)=>{!og(c)||!n(a)||i(a,o(a),()=>{const{isGroupExpanded:u,toggleExpansion:f}=l.current;u(a)&&f(a)})})},[e,t,n,o,i])}const is={};function ig(e){const t=JSON.stringify(e),[n,o]=s.useState(null),r=s.useCallback(i=>o({modelKey:t,results:i}),[t]);return[n&&n.modelKey===t?n.results:null,r]}function ls(e){const{rows:t,columns:n,aggregationModel:o,isServerSide:r,dataSource:i,filterModel:l,sortModel:c,serverAggregationResults:a}=e,u=Object.keys(o).length>0,f=s.useMemo(()=>{const v=new Map;return(n??[]).forEach(k=>v.set(k.field,k)),v},[n]),h=s.useMemo(()=>r||!u?is:In(t,o,f,"useAggregation"),[t,f,o,r,u]),x=JSON.stringify([o,l??null,c??[]]),y=r&&u&&!!i?.getAggregations&&!a,w=s.useRef({aggregationModel:o,filterModel:l,sortModel:c});s.useEffect(()=>{w.current={aggregationModel:o,filterModel:l,sortModel:c}});const[g,p]=s.useState(null);s.useEffect(()=>{const v=i?.getAggregations;if(!y||!v)return;let k=!1;const A=w.current,M={sortModel:A.sortModel??[],filterModel:A.filterModel??{items:[]},groupKeys:[],aggregationModel:A.aggregationModel};let N;try{N=Promise.resolve(v(M))}catch(P){N=Promise.reject(P)}return N.then(P=>{k||p({key:x,result:P,error:null})},P=>{k||(console.error("[useAggregation] Server aggregation error:",P),p({key:x,result:null,error:P}))}),()=>{k=!0}},[y,i,x]);const m=g&&g.key===x?g:null,C=y&&m===null,b=y?m?.error??null:null;return{aggregationResult:s.useMemo(()=>r?a&&Object.keys(a).length>0?a:m?.result??is:h,[r,h,a,m]),isLoading:C,error:b}}const lg={items:[]},sg=[];function ag(e){const{rows:t,columns:n,pivotMode:o,pivotModel:r,filterModel:i,sortModel:l,hasDataSource:c,hierarchyRequested:a}=e,u=o&&!c,f=s.useMemo(()=>new Set(n.map(m=>m.field)),[n]),h=s.useMemo(()=>Fo(n),[n]),x=s.useMemo(()=>pc(i,f),[i,f]),y=s.useMemo(()=>u?Ao(t,x.source,h):t,[u,t,x.source,h]),w=s.useMemo(()=>u?Li(y,n,r,{outputFilterModel:x.output,sortModel:l}):Oo,[u,y,n,r,x.output,l]),g=u&&w.isValid,p=s.useRef({dataSource:!1,hierarchy:!1});return s.useEffect(()=>{process.env.NODE_ENV!=="production"&&(o&&c&&!p.current.dataSource&&(p.current.dataSource=!0,console.warn("[OpenGridX] `pivotMode` is ignored when a `dataSource` is set: pivoting is client-side and the grid only holds the rows of one server page. Pivot on the server, or pass the full dataset as `rows`.")),g&&a&&!p.current.hierarchy&&(p.current.hierarchy=!0,console.warn("[OpenGridX] `treeData` and `rowGroupingModel` are turned off while `pivotMode` is active: the pivot rows are already grouped by the pivot row fields.")))},[o,c,g,a]),{isActive:g,rows:g?w.pivotRows:t,columns:g?w.pivotColumns:n,pipelineFilterModel:g?lg:i,pipelineSortModel:g?sg:l}}function ss(e,t,n=1){if(Object.is(e,t))return!0;if(!e||!t||typeof e!="object"||typeof t!="object"||Array.isArray(e)||Array.isArray(t))return!1;const o=e,r=t,i=Object.keys(o);return i.length!==Object.keys(r).length?!1:i.every(l=>Object.prototype.hasOwnProperty.call(r,l)&&(Object.is(o[l],r[l])||n>0&&ss(o[l],r[l],n-1)))}function cg(e){const[t,n]=s.useState(e);return t!==e&&!ss(t,e)?(n(e),e):t}const as=s.createContext(null);function dg(e){if(typeof e!="function")return!1;const t=e.prototype;return!(typeof t=="object"&&t!==null&&"isReactComponent"in t)}function ug({render:e,toolbarProps:t}){"use no memo";return d.jsx(d.Fragment,{children:e(t)})}function fg({component:e,toolbarProps:t}){if(dg(e))return d.jsx(ug,{render:e,toolbarProps:t},`fn:${e.toString()}`);const n=e;return d.jsx(n,{...t})}const tt=({variant:e="text",size:t="medium",color:n="default",disabled:o=!1,className:r="",type:i="button",children:l,...c})=>{const a=["ogx-button",`ogx-button--${e}`,`ogx-button--${t}`,`ogx-button--${n}`,o&&"ogx-button--disabled",r].filter(Boolean).join(" ");return d.jsx("button",{type:i,className:a,disabled:o,...c,children:l})},nt=s.forwardRef(function({fullWidth:t=!1,error:n=!1,startAdornment:o,endAdornment:r,className:i="",inputClassName:l="",variant:c="field",...a},u){const f=["ogx-input-wrapper",c==="cell"&&"ogx-input-wrapper--cell",t&&"ogx-input-wrapper--full-width",n&&"ogx-input-wrapper--error",a.disabled&&"ogx-input-wrapper--disabled",i].filter(Boolean).join(" "),h=["ogx-input",l].filter(Boolean).join(" ");return d.jsxs("div",{className:f,children:[o&&d.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--start",children:o}),d.jsx("input",{ref:u,className:h,"aria-invalid":n?!0:void 0,...a}),r&&d.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--end",children:r})]})});nt.displayName="Input";function gg(){if(typeof window>"u")return null;const e=window;return e.SpeechRecognition??e.webkitSpeechRecognition??null}function pg(e){const[t,n]=s.useState(!1),o=s.useRef(null),r=s.useRef(e);s.useLayoutEffect(()=>{r.current=e}),s.useEffect(()=>()=>{const l=o.current;o.current=null,l&&Be(()=>l.abort())},[]);const i=s.useCallback(()=>{const l=o.current;if(l){Be(()=>l.stop());return}const c=gg();if(!c)return;const a=Be(()=>new c);if(!a.ok)return;const u=a.value;u.lang=typeof navigator>"u"?"en-US":navigator.language,u.interimResults=!1,u.maxAlternatives=1,u.onresult=h=>{const x=h.results[0],y=x&&x[0]?x[0].transcript:"";y&&r.current(y)};const f=()=>{o.current===u&&(o.current=null),n(!1)};u.onend=f,u.onerror=f,o.current=u,n(!0),Be(()=>u.start()).ok||f()},[]);return{listening:t,toggle:i}}function cs(){return d.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:[d.jsx("path",{d:"M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9z"}),d.jsx("path",{d:"M19 15l.8 2.2L22 18l-2.2.8L19 21l-.8-2.2L16 18l2.2-.8z"})]})}function hg(){return d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",focusable:"false",children:[d.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),d.jsx("path",{d:"M5 11a7 7 0 0 0 14 0M12 18v3"})]})}function mg(e){const{status:t,statusText:n,message:o,errors:r,chips:i,history:l,suggestions:c,placeholder:a,voiceAvailable:u,canUndo:f,submit:h,stop:x,undo:y,removeChip:w,close:g}=e,p=_e(),[m,C]=s.useState(""),b=s.useRef(null),_=pg(C),v=t==="running";s.useEffect(()=>{b.current&&b.current.focus()},[]);const k=N=>{C(N),h(N)},A=N=>()=>{N(),b.current&&b.current.focus()},M=N=>{N.preventDefault(),v||h(m)};return d.jsxs("div",{className:"ogx-ai-panel",role:"dialog","aria-label":p.aiAssistantTitle,children:[d.jsxs("div",{className:"ogx-ai-panel__header",children:[d.jsxs("span",{className:"ogx-ai-panel__title",children:[d.jsx(cs,{}),p.aiAssistantTitle]}),d.jsx(tt,{size:"small",className:"ogx-ai-panel__close","aria-label":p.aiAssistantClose,onClick:g,children:"×"})]}),d.jsxs("form",{className:"ogx-ai-panel__form",onSubmit:M,children:[d.jsx(nt,{ref:b,className:"ogx-ai-panel__input",value:m,placeholder:a,"aria-label":p.aiAssistantPromptLabel,autoComplete:"off",onChange:N=>C(N.target.value)}),u&&d.jsx(tt,{size:"small",variant:"outlined",className:`ogx-ai-panel__mic${_.listening?" ogx-ai-panel__mic--on":""}`,"aria-label":_.listening?p.aiAssistantStopDictation:p.aiAssistantStartDictation,"aria-pressed":_.listening,onClick:_.toggle,children:d.jsx(hg,{})}),v?d.jsx(tt,{size:"small",variant:"outlined",onClick:A(x),children:p.aiAssistantStop},"stop"):d.jsx(tt,{size:"small",variant:"contained",color:"primary",type:"submit",disabled:m.trim()==="",children:p.aiAssistantAsk},"ask")]}),c.length>0&&d.jsx("div",{className:"ogx-ai-panel__suggestions","aria-label":p.aiAssistantSuggestions,role:"group",children:c.map(N=>d.jsx("button",{type:"button",className:"ogx-ai-panel__suggestion",disabled:v,onClick:()=>k(N),children:N},N))}),n&&d.jsx("div",{className:`ogx-ai-panel__status ogx-ai-panel__status--${t}`,children:n}),o&&d.jsx("p",{className:"ogx-ai-panel__message",children:o}),(i.length>0||f)&&d.jsxs("div",{className:"ogx-ai-panel__changes",children:[d.jsx("ul",{className:"ogx-ai-panel__chips","aria-label":p.aiAssistantAppliedChanges,children:i.map(N=>d.jsxs("li",{className:"ogx-ai-chip","data-part":N.part,children:[d.jsx("span",{className:"ogx-ai-chip__label",children:N.label}),d.jsx("button",{type:"button",className:"ogx-ai-chip__remove","aria-label":p.aiAssistantRemoveChange(N.label),onClick:A(()=>w(N.id)),children:"×"})]},N.id))}),f&&d.jsx(tt,{size:"small",variant:"outlined",className:"ogx-ai-panel__undo",onClick:A(y),children:p.aiAssistantUndo})]}),r.length>0&&d.jsx("ul",{className:"ogx-ai-panel__errors","aria-label":p.aiAssistantIgnored,children:r.map((N,P)=>d.jsx("li",{children:N.path?p.aiAssistantIgnoredItem(N.message):N.message},`${N.path}:${P}`))}),l.length>0&&d.jsxs("div",{className:"ogx-ai-panel__history",children:[d.jsx("div",{className:"ogx-ai-panel__history-title",children:p.aiAssistantEarlier}),d.jsx("ul",{children:l.map((N,P)=>d.jsx("li",{children:d.jsx("button",{type:"button",className:"ogx-ai-panel__history-item",onClick:()=>C(N.prompt),children:N.prompt})},`${P}:${N.prompt}`))})]})]})}function wg({panelProps:e,slot:t,slotProps:n}){const o=r=>{r.key==="Escape"&&(r.stopPropagation(),e.close())};return d.jsx("div",{className:"ogx-ai-anchor",onKeyDown:o,children:t?d.jsx(t,{...e,...n}):d.jsx(mg,{...e})})}function ds(e,t){typeof e=="function"?e(t):e&&(e.current=t)}const pt=s.forwardRef(function({indeterminate:t=!1,label:n,className:o="",inputClassName:r="",inputRef:i,...l},c){const a=s.useRef(null),u=s.useCallback(h=>{a.current=h,ds(i,h),ds(c,h)},[i,c]);s.useEffect(()=>{a.current&&(a.current.indeterminate=t)},[t]);const f=["ogx-checkbox-wrapper",l.disabled&&"ogx-checkbox-wrapper--disabled",o].filter(Boolean).join(" ");return d.jsxs("label",{className:f,children:[d.jsx("input",{ref:u,type:"checkbox",className:["ogx-checkbox__input",r].filter(Boolean).join(" "),...l}),d.jsxs("span",{className:"ogx-checkbox__box",children:[l.checked&&!t&&d.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:d.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})}),t&&d.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:d.jsx("path",{d:"M19 13H5v-2h14v2z"})})]}),n&&d.jsx("span",{className:"ogx-checkbox__label",children:n})]})});pt.displayName="Checkbox";function bg(){return d.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("circle",{cx:"11",cy:"11",r:"8"}),d.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function xg(){return d.jsxs("svg",{className:"ogx-column-visibility-panel__drag-handle",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[d.jsx("circle",{cx:"9",cy:"5",r:"1.5"}),d.jsx("circle",{cx:"15",cy:"5",r:"1.5"}),d.jsx("circle",{cx:"9",cy:"12",r:"1.5"}),d.jsx("circle",{cx:"15",cy:"12",r:"1.5"}),d.jsx("circle",{cx:"9",cy:"19",r:"1.5"}),d.jsx("circle",{cx:"15",cy:"19",r:"1.5"})]})}function pr(e){const{columns:t,visibleColumns:n,onVisibilityChange:o,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:c,showNonHideableColumns:a}=e,u=_e(),[f,h]=s.useState(""),x=s.useId(),[y,w]=s.useState(null),g=s.useRef(null),p=s.useMemo(()=>t.filter(N=>N.hideable!==!1),[t]),m=p.every(N=>n.has(N.field)),C=s.useMemo(()=>{const N=a?t:p;if(!f)return N;const P=f.toLowerCase();return N.filter(T=>(T.headerName||T.field).toLowerCase().includes(P))},[t,p,f,a]),b=N=>{N.target.checked?r():i()},_=N=>P=>{g.current=N,P.dataTransfer.effectAllowed="move",P.dataTransfer.setDragImage(P.currentTarget.closest(".ogx-column-visibility-panel__item"),20,20)},v=N=>P=>{P.preventDefault(),P.dataTransfer.dropEffect="move",N!==g.current&&w(N)},k=()=>{w(null)},A=N=>P=>{P.preventDefault();const T=g.current;w(null),g.current=null,T&&T!==N&&l&&l(T,N)},M=()=>{w(null),g.current=null};return d.jsxs("div",{className:"ogx-column-visibility-panel",children:[d.jsx("div",{className:"ogx-column-visibility-panel__search-section",children:d.jsxs("div",{className:"ogx-column-visibility-panel__search-container",children:[d.jsx(bg,{}),d.jsx(nt,{autoComplete:"off",inputClassName:"ogx-column-visibility-panel__search-input",placeholder:u.columnsPanelSearchPlaceholder,value:f,onChange:N=>h(N.target.value)})]})}),d.jsx("div",{className:"ogx-column-visibility-panel__list",children:C.map((N,P)=>{const T=`${x}-col-${P}`,S=n.has(N.field),I=N.hideable!==!1,F=y===N.field,L=!!l&&!f;return d.jsxs("div",{className:["ogx-column-visibility-panel__item",!I&&"ogx-column-visibility-panel__item--disabled",F&&"ogx-column-visibility-panel__item--drag-over"].filter(Boolean).join(" "),draggable:L,onDragOver:L?v(N.field):void 0,onDragLeave:L?k:void 0,onDrop:L?A(N.field):void 0,onDragEnd:L?M:void 0,children:[L&&d.jsx("span",{className:"ogx-column-visibility-panel__drag-handle-wrapper",draggable:!0,onDragStart:_(N.field),title:u.columnsPanelDragToReorder,children:d.jsx(xg,{})}),d.jsxs("div",{className:"ogx-column-visibility-panel__item-label",style:{display:"flex",alignItems:"center",gap:"var(--ogx-spacing-md)",flex:1,cursor:I?"pointer":"not-allowed"},children:[d.jsx(pt,{id:T,checked:S,onChange:E=>o(N.field,E.target.checked),disabled:!I}),d.jsx("label",{htmlFor:T,className:"ogx-column-visibility-panel__label",children:N.headerName||N.field})]})]},N.field)})}),d.jsxs("div",{className:"ogx-column-visibility-panel__footer",children:[d.jsxs("div",{className:"ogx-column-visibility-panel__item",children:[d.jsx(pt,{id:`${x}-all`,checked:m,onChange:b}),d.jsx("label",{htmlFor:`${x}-all`,className:"ogx-column-visibility-panel__label",children:u.columnsPanelShowHideAll})]}),d.jsx("button",{type:"button",className:"ogx-column-visibility-panel__reset-btn",onClick:()=>{r(),c?.()},children:u.columnsPanelReset})]})]})}function pn(){return document.documentElement.clientWidth||window.innerWidth}function us(){return document.documentElement.clientHeight||window.innerHeight}function Cg({isOpen:e,containerRef:t,panelRef:n,columns:o,columnVisibilityModel:r,disableColumnReorder:i,onClose:l,onColumnVisibilityChange:c,onColumnMove:a,onColumnOrderReset:u,columnGroupingModel:f}){const h=_e(),[x,y]=s.useState(null);if(s.useLayoutEffect(()=>{if(!e||!t.current)return;const g=t.current.getBoundingClientRect();y({top:g.top+8,right:pn()-g.right+8,target:t.current.closest(".ogx-theme-provider")||document.body})},[e,t]),!e||!x)return null;const w=i?void 0:(g,p)=>{or(f,g,p)&&a(g,p)};return ct.createPortal(d.jsxs("div",{ref:n,style:{position:"fixed",top:x.top,right:x.right,zIndex:9999,display:"inline-block"},children:[d.jsx("button",{type:"button",onClick:l,style:{position:"absolute",top:-12,right:-12,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",background:"#334155",color:"#fff",border:"none",borderRadius:"50%",cursor:"pointer",fontSize:14,lineHeight:1,zIndex:1,boxShadow:"0 1px 4px rgba(0,0,0,0.2)"},"aria-label":h.columnsPanelClose,children:"×"}),d.jsx(pr,{columns:o,visibleColumns:new Set(o.filter(g=>r[g.field]!==!1).map(g=>g.field)),onVisibilityChange:(g,p)=>{c({...r,[g]:p})},onShowAll:()=>{const g={...r};o.forEach(p=>{p.hideable!==!1&&(g[p.field]=!0)}),c(g)},onHideAll:()=>{const g={...r};o.forEach(p=>{p.hideable!==!1&&(g[p.field]=!1)}),c(g)},onColumnReorder:w,onColumnOrderReset:i?void 0:u})]}),x.target)}function hr(e){const t=s.useId(),n=_e(),{page:o,pageSize:r,rowCount:i,onPageChange:l,onPageSizeChange:c,pageSizeOptions:a=[10,25,50,100],showFirstButton:u=!0,showLastButton:f=!0,localeText:h}=e,x=zn(r),y=Vo(i,x),w=qi(o,y),g=a.includes(x)?a:[...a,x].sort((S,I)=>S-I),p=w*x,m=Math.min(p+x,i),C=h?.paginationRowsPerPage??n.paginationRowsPerPage,b=(h?.paginationOf??n.paginationOf)(i===0?0:p+1,m,i),_=(h?.paginationPage??n.paginationPage)(w+1,y),v=()=>{l(0)},k=()=>{l(Math.max(0,w-1))},A=()=>{l(Math.min(y-1,w+1))},M=()=>{l(y-1)},N=S=>{const I=parseInt(S.target.value,10);c(I)},P=w===0,T=w>=y-1;return d.jsxs("div",{className:"ogx-pagination",role:"navigation","aria-label":n.paginationLabel,children:[d.jsxs("div",{className:"ogx-pagination__page-size",children:[d.jsx("label",{htmlFor:t,className:"ogx-pagination__label",children:C}),d.jsx("select",{id:t,className:"ogx-pagination__select",value:x,onChange:N,children:g.map(S=>d.jsx("option",{value:S,children:S},S))})]}),d.jsx("div",{className:"ogx-pagination__info","aria-live":"polite","aria-atomic":"true",children:b}),d.jsxs("div",{className:"ogx-pagination__actions",children:[u&&d.jsx(tt,{variant:"text",size:"small",onClick:v,disabled:P,"aria-label":n.paginationFirstPageLabel,title:n.paginationFirstPageTooltip,children:d.jsx("svg",{className:"ogx-pagination__icon",width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:d.jsx("path",{d:"M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"})})}),d.jsx(tt,{variant:"text",size:"small",onClick:k,disabled:P,"aria-label":n.paginationPreviousPageLabel,title:n.paginationPreviousPageTooltip,children:d.jsx("svg",{className:"ogx-pagination__icon",width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:d.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),d.jsx("div",{className:"ogx-pagination__page-info","aria-current":"page",children:_}),d.jsx(tt,{variant:"text",size:"small",onClick:A,disabled:T,"aria-label":n.paginationNextPageLabel,title:n.paginationNextPageTooltip,children:d.jsx("svg",{className:"ogx-pagination__icon",width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:d.jsx("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})})}),f&&d.jsx(tt,{variant:"text",size:"small",onClick:M,disabled:T,"aria-label":n.paginationLastPageLabel,title:n.paginationLastPageTooltip,children:d.jsx("svg",{className:"ogx-pagination__icon",width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:d.jsx("path",{d:"M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z"})})})]})]})}function yg({row:e,rowId:t,rowIndex:n,ariaRowIndex:o,listViewColumn:r,gridColumn:i,rowMeta:l,isSelected:c=!1,checkboxSelection:a=!1,rowHeight:u,onRowClick:f,onRowDoubleClick:h,onSelectionChange:x,tabIndex:y=-1,onFocus:w,onToggleExpansion:g}){const p=t??e.id,m=r.field,C=Se(e,m,i),b=bo(e,m,C,i)??Ln(C,i),_=l?.isGroupRow===!0||Ke(p),v={row:e,value:C,formattedValue:b,field:m,colDef:i??r,rowIndex:n,colIndex:0,rowMeta:l},k=_e(),A=M=>{M.stopPropagation(),x?.(p,M.target.checked)};return d.jsxs("div",{className:`ogx-list-view__row${c?" ogx-list-view__row--selected":""}`,style:u?{minHeight:u}:void 0,onClick:()=>f?.(e),onDoubleClick:h?()=>h(e):void 0,role:"row","aria-rowindex":o??n+1,"aria-selected":c,"aria-level":l?.treeDepth!==void 0?l.treeDepth+1:void 0,"aria-expanded":l?.hasChildren?l.isExpanded===!0:void 0,"data-rowindex":n,tabIndex:y,onFocus:w?M=>{M.target===M.currentTarget&&w(n)}:void 0,children:[a&&d.jsx("div",{className:"ogx-list-view__checkbox",onClick:M=>M.stopPropagation(),children:!_&&d.jsx(pt,{checked:c,onChange:A,"aria-label":k.rowSelectLabel(p),tabIndex:-1})}),l&&g&&d.jsx("div",{className:"ogx-list-view__expand",style:{paddingInlineStart:(l.treeDepth??0)*16},onClick:M=>M.stopPropagation(),onDoubleClick:M=>M.stopPropagation(),children:l.hasChildren&&d.jsx(Qo,{isExpanded:l.isExpanded===!0,onClick:()=>g(p),tabIndex:-1})}),d.jsx("div",{className:"ogx-list-view__cell",role:"gridcell",children:d.jsx(Mt,{field:m,resetKey:e,renderFn:()=>{const M=r.renderCell(v);return M===void 0&&_?l?.groupLabel:M}})})]})}function vg(e,t){const n=s.useRef(!0),o=s.useRef(e);s.useEffect(()=>{o.current=e},[e]),s.useEffect(()=>{n.current=!0},[t]);const r=s.useCallback(i=>{const l=Bl(i.currentTarget);if(!l){n.current=!0;return}if(!n.current)return;const c=o.current;c&&(n.current=!1,c(l))},[]);return e?r:void 0}const Sg=e=>e.id;function _g({ariaLabel:e,allRenderableRows:t,dataRowCount:n,pinnedTopRowCount:o,pinnedBottomRowCount:r,unpinnedRowCount:i,pagination:l,effectivePaginationModel:c,currentPage:a,pageSizeOptions:u,selectedRowIds:f,listViewColumn:h,columnsByField:x,rowMetaMap:y,noRowsLabel:w,rowHeight:g,checkboxSelection:p,paginationMode:m,serverRowCount:C,paginationSlot:b,paginationSlotProps:_,localeText:v,onRowClick:k,onRowDoubleClick:A,onSelectionChange:M,onPaginationModelChange:N,onRowsScrollEnd:P,getRowId:T=Sg,multiselectable:S=!1,loading:I=!1,loadingOverlay:F,noRowsOverlay:L,showPaginationControls:E=!0,selectable:O=!1,onToggleExpansion:B}){const H=_e(),K=b||hr,R=s.useRef(null),[X,j]=s.useState(null),Q=X===null?-1:t.findIndex(J=>T(J)===X),U=Q===-1?0:Q,re=J=>{const te=t[J];te&&(j(T(te)),R.current?.querySelector(`:scope > [role="row"][data-rowindex="${J}"]`)?.focus())},q=J=>{const te=J.target;if(te.getAttribute("role")!=="row"||te.parentElement!==R.current)return;const ne=Number(te.getAttribute("data-rowindex")),z=t[ne];if(!z)return;const ie=T(z),ae=t.length-1,le=y.get(ie),ce=!!(le?.hasChildren&&B);if(J.altKey&&(J.key==="ArrowRight"||J.key==="ArrowLeft")){J.preventDefault();const de=Nn(J.key,Je(J.currentTarget))==="ArrowRight";ce&&de!==(le?.isExpanded===!0)&&B?.(ie);return}switch(J.key){case"ArrowDown":J.preventDefault(),re(Math.min(ne+1,ae));return;case"ArrowUp":J.preventDefault(),re(Math.max(ne-1,0));return;case"Home":J.preventDefault(),re(0);return;case"End":J.preventDefault(),re(ae);return;case"PageDown":J.preventDefault(),re(Math.min(ne+10,ae));return;case"PageUp":J.preventDefault(),re(Math.max(ne-10,0));return;case"Enter":case" ":if(J.preventDefault(),J.key===" "&&J.shiftKey){O&&!le?.isGroupRow&&M(ie,!f.has(ie));return}ce?B?.(ie):k({row:z,id:ie,rowIndex:ne});return}},se=m==="server",Z=se?C||0:i,$=se?C||0:n,D=zn(c.pageSize),G=Vo(Z,D),W=l?a*D:0,ee=t.length-o-r,V=J=>{if(J<o)return J+1;const te=J-o;return te<ee?o+W+te+1:o+Z+(te-ee)+1},Y=vg(P,t.length);return d.jsxs("div",{className:"ogx-list-view",role:"grid","aria-label":e||H.listViewLabel,"aria-rowcount":$,"aria-multiselectable":S,children:[d.jsx("div",{className:"ogx-list-view__toolbar",children:d.jsxs("span",{children:[H.listViewItemCount($),l?` · ${H.listViewPage(a+1,G)}`:"",f.size>0?` · ${H.listViewSelectedCount(f.size)}`:""]})}),d.jsx("div",{className:"ogx-list-view__rows",tabIndex:-1,onScroll:Y,onKeyDown:q,ref:R,children:t.length===0&&I?d.jsx("div",{className:"ogx-list-view__loading",children:F??d.jsx("div",{className:"ogx__loading-bar",role:"progressbar","aria-label":H.loadingLabel})}):t.length===0&&L?d.jsx("div",{className:"ogx-list-view__empty",children:L}):t.length===0?d.jsxs("div",{className:"ogx-list-view__empty",children:[d.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[d.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),d.jsx("path",{d:"M3 9h18M9 21V9"})]}),w]}):t.map((J,te)=>{const ne=T(J);return d.jsx(yg,{row:J,rowId:ne,rowIndex:te,ariaRowIndex:V(te),listViewColumn:h,gridColumn:x.get(h.field),rowMeta:y.get(ne),isSelected:f.has(ne),checkboxSelection:p,rowHeight:g,onRowClick:z=>k({row:z,id:ne,rowIndex:te}),onRowDoubleClick:A?z=>A({row:z,id:ne,rowIndex:te}):void 0,onSelectionChange:M,tabIndex:te===U?0:-1,onToggleExpansion:B,onFocus:z=>j(T(t[z]))},ne)})}),l&&E&&d.jsx(K,{page:a,pageSize:c.pageSize,rowCount:Z,pageSizeOptions:u,onPageChange:J=>N({...c,page:J}),onPageSizeChange:J=>N({...c,pageSize:J,page:0}),localeText:v,..._})]})}const kg=16;function Eg(e){e.preventDefault(),e.stopPropagation()}function Mg(){const e=t=>{t.stopPropagation(),t.preventDefault()};window.addEventListener("click",e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener("click",e,{capture:!0}),0)}function Ag(e){const{field:t,currentWidth:n,onResize:o,onAutosize:r,minWidth:i,maxWidth:l,edge:c="end"}=e,a=_e(),[u,f]=s.useState(!1),h=s.useRef(null);s.useEffect(()=>()=>{h.current=null},[]);const x=s.useCallback((b,_)=>{const v=(_-b.startX)*(b.rtl?-1:1),k=b.startWidth+(c==="start"?-v:v);return fr(k,b.startWidth,i,l)},[c,i,l]),y=s.useCallback(b=>{if(b.button===0){b.stopPropagation(),h.current={pointerId:b.pointerId,startX:b.clientX,startWidth:n,rtl:Je(b.currentTarget),lastUpdate:0,moved:!1},f(!0);try{b.currentTarget.setPointerCapture(b.pointerId)}catch{}}},[n]),w=s.useCallback(b=>{const _=h.current;if(!_||b.pointerId!==_.pointerId||(b.clientX!==_.startX&&(_.moved=!0),!_.moved))return;const v=Date.now();v-_.lastUpdate>=kg&&(_.lastUpdate=v,o(t,x(_,b.clientX)))},[t,o,x]),g=s.useCallback((b,_)=>{const v=h.current;if(!(!v||b.pointerId!==v.pointerId)){if(h.current=null,f(!1),b.currentTarget.hasPointerCapture?.(b.pointerId))try{b.currentTarget.releasePointerCapture(b.pointerId)}catch{}(v.moved||b.clientX!==v.startX)&&(Mg(),_&&o(t,x(v,b.clientX)))}},[t,o,x]),p=s.useCallback(b=>{if(b.key==="Enter"&&r){b.preventDefault(),b.stopPropagation(),r(t);return}if(b.key!=="ArrowLeft"&&b.key!=="ArrowRight")return;b.preventDefault(),b.stopPropagation();const _=Nn(b.key,Je(b.currentTarget)),v=(b.shiftKey?50:10)*(_==="ArrowRight"?1:-1);o(t,fr(n+v,n,i,l))},[t,n,o,r,i,l]),m=s.useCallback(b=>{b.preventDefault(),b.stopPropagation(),r?.(t)},[t,r]),C=["ogx-column-resize-handle",c==="start"&&"ogx-column-resize-handle--start",u&&"ogx-column-resize-handle--dragging"].filter(Boolean).join(" ");return d.jsx("div",{className:C,onPointerDown:y,onMouseDown:Eg,onPointerMove:w,onPointerUp:b=>g(b,!0),onPointerCancel:b=>g(b,!1),onClick:b=>b.stopPropagation(),onDragStart:b=>{b.preventDefault(),b.stopPropagation()},onDoubleClick:m,onKeyDown:p,role:"separator","aria-orientation":"vertical","aria-label":a.headerColumnResizeLabel(t),"aria-valuenow":Math.round(n),"aria-valuemin":Math.round(Math.min(i??50,n)),"aria-valuemax":l,tabIndex:-1,children:d.jsx("div",{className:"ogx-column-resize-handle__line"})})}function jt(){return d.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"currentColor",children:d.jsx("circle",{cx:"4",cy:"4",r:"4"})})}function qt(){return d.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:d.jsx("circle",{cx:"4",cy:"4",r:"3"})})}function Pg(){return d.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",children:[d.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),d.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.3"}),d.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),d.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),d.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),d.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function Lg(){return d.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),d.jsx("polyline",{points:"5 12 12 5 19 12"})]})}function Ng(){return d.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),d.jsx("polyline",{points:"19 12 12 19 5 12"})]})}function Ig(){return d.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:d.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})}function Fg(){return d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"}),d.jsx("path",{d:"M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"}),d.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function Tg(){return d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("line",{x1:"4",y1:"2",x2:"4",y2:"22"}),d.jsx("polyline",{points:"11 8 4 12 11 16"}),d.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function Og(){return d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("line",{x1:"20",y1:"2",x2:"20",y2:"22"}),d.jsx("polyline",{points:"13 8 20 12 13 16"}),d.jsx("line",{x1:"20",y1:"12",x2:"4",y2:"12"})]})}function Dg(){return d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),d.jsx("line",{x1:"4",y1:"4",x2:"4",y2:"20"}),d.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}const fs=e=>e?Array.from(e.querySelectorAll('[role="menuitem"], [role="menuitemradio"]')):[];function $g({colDef:e,sortModel:t,onSort:n,onHide:o,onPin:r,pinnedColumns:i,onManageColumns:l,onClose:c,anchorEl:a}){const u=s.useRef(null),f=_e(),h=s.useCallback(E=>{E&&(a?.closest('[role="columnheader"]')??a)?.focus({preventScroll:!0}),c()},[a,c]),x=E=>{const O=fs(u.current),B=O.indexOf(E.target);let H=-1;if(E.key==="ArrowDown")H=B+1>=O.length?0:B+1;else if(E.key==="ArrowUp")H=B<=0?O.length-1:B-1;else if(E.key==="Home")H=0;else if(E.key==="End")H=O.length-1;else if(E.key==="Tab"){E.preventDefault(),h(!0);return}else return;E.preventDefault(),O[H]?.focus()},[y,w]=s.useState({position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"});s.useLayoutEffect(()=>{if(!a||!u.current)return;const E=a.getBoundingClientRect(),O=u.current.getBoundingClientRect(),B=pn(),H=us(),K=8;let R=E.left;R+O.width+K>B&&(R=B-O.width-K),R<K&&(R=K);let X=E.bottom+4;X+O.height+K>H&&(X=E.top-O.height-4),w({position:"fixed",zIndex:1300,top:X,left:R,visibility:"visible"})},[a]);const g=y.visibility==="visible";s.useLayoutEffect(()=>{g&&fs(u.current)[0]?.focus({preventScroll:!0})},[g]),s.useEffect(()=>{function E(B){u.current&&!u.current.contains(B.target)&&a&&!a.contains(B.target)&&c()}function O(B){B.key==="Escape"&&h(!0)}return document.addEventListener("mousedown",E),document.addEventListener("keydown",O),window.addEventListener("scroll",c,!0),window.addEventListener("resize",c),()=>{document.removeEventListener("mousedown",E),document.removeEventListener("keydown",O),window.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c)}},[a,c,h]);const p=E=>{n?.(e.field,E),h(!0)},m=!!o&&e.hideable!==!1,C=!!r&&e.pinnable!==!1,b=()=>{m&&o?.(e.field),h(!0)},_=E=>{C&&r?.(e.field,E),h(!0)},v=t?.find(E=>E.field===e.field)?.sort,k=v==null,A=i?.left?.includes(e.field)??!1,M=i?.right?.includes(e.field)??!1,N=!A&&!M,P=Je(a),T=P?"right":"left",S=P?"left":"right",I=P?M:A,F=P?A:M,L=e.headerName||e.field;return ct.createPortal(d.jsxs("div",{ref:u,className:"ogx-column-menu",style:y,role:"menu","aria-label":f.columnMenuLabel(L),onKeyDown:x,children:[n&&e.sortable!==!1&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:`ogx-menu-item${v==="asc"?" ogx-menu-item--active":""}`,onClick:()=>p("asc"),role:"menuitemradio","aria-checked":v==="asc",children:[d.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:v==="asc"?d.jsx(jt,{}):d.jsx(qt,{})}),d.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:d.jsx(Lg,{})}),f.columnMenuSortAscending]}),d.jsxs("button",{type:"button",className:`ogx-menu-item${v==="desc"?" ogx-menu-item--active":""}`,onClick:()=>p("desc"),role:"menuitemradio","aria-checked":v==="desc",children:[d.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:v==="desc"?d.jsx(jt,{}):d.jsx(qt,{})}),d.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:d.jsx(Ng,{})}),f.columnMenuSortDescending]}),d.jsxs("button",{type:"button",className:`ogx-menu-item${k?" ogx-menu-item--active":""}`,onClick:()=>p(null),role:"menuitemradio","aria-checked":k,children:[d.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:k?d.jsx(jt,{}):d.jsx(qt,{})}),d.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:d.jsx(Ig,{})}),f.columnMenuUnsort]}),d.jsx("div",{className:"ogx-menu-divider"})]}),C&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"ogx-menu-section-label","aria-hidden":"true",children:f.columnMenuPinColumn}),d.jsxs("button",{type:"button",className:`ogx-menu-item${I?" ogx-menu-item--active":""}`,onClick:()=>_(T),role:"menuitemradio","aria-checked":I,"aria-label":f.columnMenuPinLeftLabel,children:[d.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:I?d.jsx(jt,{}):d.jsx(qt,{})}),d.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:d.jsx(Tg,{})}),f.columnMenuPinLeft]}),d.jsxs("button",{type:"button",className:`ogx-menu-item${F?" ogx-menu-item--active":""}`,onClick:()=>_(S),role:"menuitemradio","aria-checked":F,"aria-label":f.columnMenuPinRightLabel,children:[d.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:F?d.jsx(jt,{}):d.jsx(qt,{})}),d.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:d.jsx(Og,{})}),f.columnMenuPinRight]}),d.jsxs("button",{type:"button",className:`ogx-menu-item${N?" ogx-menu-item--active":""}`,onClick:()=>_(null),role:"menuitemradio","aria-checked":N,"aria-label":f.columnMenuUnpinLabel,children:[d.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:N?d.jsx(jt,{}):d.jsx(qt,{})}),d.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:d.jsx(Dg,{})}),f.columnMenuUnpin]}),d.jsx("div",{className:"ogx-menu-divider"})]}),m&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"ogx-menu-item",onClick:b,role:"menuitem","aria-label":f.columnMenuHideColumnLabel(L),children:[d.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),d.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:d.jsx(Fg,{})}),f.columnMenuHideColumn]}),d.jsx("div",{className:"ogx-menu-divider"})]}),d.jsxs("button",{type:"button",className:"ogx-menu-item",onClick:()=>{l?.(),h(!1)},role:"menuitem","aria-label":f.columnMenuManageColumnsLabel,children:[d.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),d.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:d.jsx(Pg,{})}),f.columnMenuManageColumns]})]}),a?.closest(".ogx-theme-provider")||document.body)}const Gg=16,Hg=16;function Bg(e,t=!1){const n=Number.isFinite(e)?e-Hg:0,o=Math.floor(n/Gg)-(t?1:0);return Math.max(1,o)}function Wg(e,t){return e??t??!1}function gs(e,t,n,o){const r={width:t[e.field]??e.width??100,minWidth:e.minWidth,maxWidth:e.maxWidth,flexGrow:e.flex??0,flexShrink:0,flexBasis:"auto",boxSizing:"border-box",position:n?"sticky":"relative"};return n==="left"?r.insetInlineStart=o:n==="right"&&(r.insetInlineEnd=o),r}function Vg(e){const t=e?.headerFilterOperators;return{custom:e?.headerFilterCustom??"Custom filter",customTooltip:e?.headerFilterCustomTooltip??"Set in the filter panel",cellLabel:e?.headerFilterCellLabel??(n=>`Filter ${n}`),valueLabel:e?.headerFilterValueLabel??(n=>`Filter value for ${n}`),operatorButtonLabel:e?.headerFilterOperatorButtonLabel??((n,o)=>`Filter operator for ${n}: ${o}`),operatorMenuLabel:e?.headerFilterOperatorMenuLabel??(n=>`Filter operator for ${n}`),clearLabel:e?.headerFilterClearLabel??(n=>`Clear filter for ${n}`),clearTooltip:e?.headerFilterClearTooltip??"Clear",any:e?.headerFilterAny??"Any",yes:e?.headerFilterTrue??"Yes",no:e?.headerFilterFalse??"No",operator:n=>t?.[n]??nl[n]??n}}function ps(e){return(e.valueOptions??[]).map((t,n)=>t!==null&&typeof t=="object"?{key:String(n),value:t.value,label:t.label}:{key:String(n),value:t,label:String(t)})}function mr(e,t){const n=Array.isArray(t)?t[0]:t;return Object.is(e.value,n)?!0:n!=null&&String(e.value).toLowerCase()===String(n).toLowerCase()}function Jn(e,t){return t==="isAnyOf"?e.split(",").map(n=>n.trim()).filter(n=>n!==""):e}function wr(e,t){return Object.is(e,t)?!0:e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((n,o)=>wr(n,t[o])):!1}const zg={position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"},hs=e=>e?Array.from(e.querySelectorAll('[role="menuitemradio"]')):[];function Rg({anchorEl:e,columnLabel:t,operators:n,current:o,onSelect:r,onClose:i,locale:l}){const c=s.useRef(null),[a,u]=s.useState(zg);s.useLayoutEffect(()=>{const y=c.current;if(!y)return;const w=e.getBoundingClientRect(),g=y.getBoundingClientRect(),p=8;let m=Math.min(w.left,pn()-g.width-p);m<p&&(m=p);let C=w.bottom+4;C+g.height+p>us()&&(C=w.top-g.height-4),u({position:"fixed",zIndex:1300,top:C,left:m,visibility:"visible"})},[e]);const f=a.visibility==="visible";s.useLayoutEffect(()=>{if(!f)return;const y=hs(c.current);(y.find(w=>w.getAttribute("aria-checked")==="true")??y[0])?.focus({preventScroll:!0})},[f]);const h=s.useRef(i);s.useLayoutEffect(()=>{h.current=i}),s.useEffect(()=>{const y=e.ownerDocument,w=y.defaultView;function g(C){const b=C.target;c.current?.contains(b)||e.contains(b)||h.current(!1)}function p(C){c.current?.contains(C.target)||h.current(!1)}function m(){h.current(!1)}return y.addEventListener("mousedown",g),w?.addEventListener("scroll",p,!0),w?.addEventListener("resize",m),()=>{y.removeEventListener("mousedown",g),w?.removeEventListener("scroll",p,!0),w?.removeEventListener("resize",m)}},[e]);const x=y=>{y.stopPropagation();const w=hs(c.current),g=w.indexOf(y.target);let p=-1;switch(y.key){case"ArrowDown":p=g+1>=w.length?0:g+1;break;case"ArrowUp":p=g<=0?w.length-1:g-1;break;case"Home":p=0;break;case"End":p=w.length-1;break;case"Escape":case"Tab":y.preventDefault(),i(!0);return;default:return}y.preventDefault(),w[p]?.focus()};return ct.createPortal(d.jsx("div",{ref:c,className:"ogx-column-menu ogx__header-filter-menu",style:a,role:"menu","aria-label":l.operatorMenuLabel(t),onKeyDown:x,children:n.map(y=>d.jsx("button",{type:"button",role:"menuitemradio","aria-checked":y===o,tabIndex:-1,className:`ogx-menu-item${y===o?" ogx-menu-item--active":""}`,onClick:()=>r(y),children:l.operator(y)},y))}),e.closest(".ogx-theme-provider")??e.ownerDocument.body)}function ms(e,t){return e===t?!0:!e||!t?!1:e.operator===t.operator&&wr(e.value,t.value)}function Ug(){return d.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",children:[d.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"}),d.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"})]})}function Kg({colDef:e,state:t,style:n,className:o,ariaColIndex:r,onItemChange:i,onOpenFilterPanel:l,locale:c}){const a=e.headerName||e.field,u=t.kind==="editable"?t.item:void 0,f=u?.operator??Un(e),h=ps(e),x=e.type==="boolean"||e.type==="singleSelect"&&h.length>0,y=!Gt.has(f),[w,g]=s.useState(null),[p,m]=s.useState(null),[C,b]=s.useState(void 0),[_,v]=s.useState(u);if(_!==u){v(u);const q=C!==void 0&&ms(C??void 0,u);!ms(_,u)&&!q&&g(null)}const k=s.useRef(null),A=s.useRef(null),M=s.useRef(null),N=s.useRef(null),P=s.useRef(null),T=s.useRef({item:u,colDef:e,onItemChange:i});s.useLayoutEffect(()=>{T.current={item:u,colDef:e,onItemChange:i}});const S=s.useCallback(q=>{const{item:se,colDef:Z,onItemChange:$}=T.current;if(se?q===Po(se.value,Z.type):q.trim()==="")return;const G=se?.operator??Un(Z),W=qo(Z,G,Jn(q,G));b(W),$(Z.field,W)},[]),I=s.useRef(null);s.useLayoutEffect(()=>{I.current=w}),s.useEffect(()=>()=>{const q=I.current;I.current=null,q!==null&&S(q)},[S]),s.useEffect(()=>{if(w===null)return;const q=setTimeout(()=>{I.current=null,S(w),g(null)},Qc);return()=>clearTimeout(q)},[w,S]);const F=()=>k.current?.focus({preventScroll:!0}),L=()=>(A.current??M.current)?.focus({preventScroll:!0}),E=q=>{b(q),i(e.field,q)},O=q=>{g(null),E(qo(e,f,q))},B=()=>{g(null),E(null)},H=()=>{P.current&&m(P.current)},K=q=>{m(null),q&&(A.current||M.current?L():F())},R=q=>{const se=w!==null?Jn(w,q):u?.value;g(null),m(null),E(qo(e,q,tl(se,q))),requestAnimationFrame(()=>{A.current||M.current?L():F()})},X=t.kind==="custom",j=!X&&y&&!x,Q=q=>{const se=q.currentTarget,Z=q.target;if(!se.contains(Z)||q.nativeEvent.isComposing)return;const{key:$}=q,D=Z===se;if((q.altKey&&$==="ArrowDown"||(q.ctrlKey||q.metaKey)&&$==="Enter")&&!X&&Z!==M.current){q.preventDefault(),q.stopPropagation(),H();return}if(!D){$==="Escape"&&(q.preventDefault(),q.stopPropagation(),F());return}if($==="Enter"||$===" "||$==="Spacebar"){q.preventDefault(),q.stopPropagation(),X?N.current?.click():A.current||M.current?L():H();return}if(($==="Delete"||$==="Backspace")&&u){q.preventDefault(),q.stopPropagation(),B();return}j&&e.type!=="date"&&$.length===1&&!q.ctrlKey&&!q.metaKey&&!q.altKey&&(q.preventDefault(),q.stopPropagation(),A.current?.focus({preventScroll:!0}),g($))};let U=null;if(X)U=l?d.jsx("button",{ref:N,type:"button",className:"ogx__header-filter-custom",tabIndex:-1,onClick:l,title:c.customTooltip,children:c.custom}):d.jsx("span",{className:"ogx__header-filter-custom",title:c.customTooltip,children:c.custom});else{let q;if(!y)q=d.jsx("span",{className:"ogx__header-filter-operator-label",children:c.operator(f)});else if(e.type==="boolean")q=d.jsxs("select",{ref:M,className:"ogx__header-filter-select",tabIndex:-1,value:u?.value==null||u.value===""?"":String(u.value),onChange:Z=>O(Z.target.value===""?"":Z.target.value==="true"),"aria-label":c.valueLabel(a),children:[d.jsx("option",{value:"",children:c.any}),d.jsx("option",{value:"true",children:c.yes}),d.jsx("option",{value:"false",children:c.no})]});else if(x){const Z=h.find($=>mr($,u?.value));q=d.jsxs("select",{ref:M,className:"ogx__header-filter-select",tabIndex:-1,value:Z?.key??"",onChange:$=>{const D=h.find(G=>G.key===$.target.value);O(tl(D?D.value:"",f))},"aria-label":c.valueLabel(a),children:[d.jsx("option",{value:"",children:c.any}),h.map($=>d.jsx("option",{value:$.key,children:$.label},$.key))]})}else q=d.jsx(nt,{ref:A,className:"ogx__header-filter-input-wrapper",inputClassName:"ogx__header-filter-input",type:e.type==="date"?"date":"text",inputMode:e.type==="number"?"decimal":void 0,tabIndex:-1,autoComplete:"off",value:w??Po(u?.value,e.type),onChange:Z=>g(Z.target.value),"aria-label":c.valueLabel(a)});const se=c.operator(f);U=d.jsxs(d.Fragment,{children:[d.jsx("button",{ref:P,type:"button",className:`ogx__header-filter-operator${p?" ogx__header-filter-operator--open":""}`,tabIndex:-1,"aria-haspopup":"menu","aria-expanded":p!==null,"aria-label":c.operatorButtonLabel(a,se),title:se,onClick:()=>p?m(null):H(),children:id[f]??"?"}),q,u&&d.jsx("button",{type:"button",className:"ogx__header-filter-clear",tabIndex:-1,"aria-label":c.clearLabel(a),title:c.clearTooltip,onClick:()=>{B(),F()},children:d.jsx(Ug,{})}),p&&d.jsx(Rg,{anchorEl:p,columnLabel:a,locale:c,operators:nd(e),current:f,onSelect:R,onClose:K})]})}const re=["ogx__header-filter-cell",u&&"ogx__header-filter-cell--active",X&&"ogx__header-filter-cell--custom",o].filter(Boolean).join(" ");return d.jsx("div",{ref:k,className:re,style:n,role:"columnheader","aria-label":c.cellLabel(a),"aria-colindex":r,"data-field":e.field,tabIndex:-1,onKeyDown:Q,children:U})}function br({field:e,ariaColIndex:t,sticky:n,left:o,focused:r}){return d.jsx("div",{className:["ogx__header-filter-cell","ogx__header-filter-cell--system",n&&"ogx__header-filter-cell--pinned ogx__header-filter-cell--pinned-left",r&&"ogx__header-filter-cell--focused"].filter(Boolean).join(" "),style:{width:Ge,minWidth:Ge,maxWidth:Ge,position:n?"sticky":void 0,insetInlineStart:n?o:void 0},role:"columnheader","aria-colindex":t,"data-field":e,tabIndex:-1})}function jg(e){const t=_e(),{columns:n,columnWidths:o,pinnedColumns:r,pinnedPositions:i,pinnedEdges:l,rowReordering:c,hasDetailPanel:a,checkboxSelection:u,pinExpandColumn:f,pinCheckboxColumn:h,columnIndexMap:x,ariaRowIndex:y,filterModel:w,onFilterModelChange:g,onOpenFilterPanel:p,focusedField:m,localeText:C}=e,b=s.useRef({filterModel:w,onFilterModelChange:g});s.useLayoutEffect(()=>{b.current={filterModel:w,onFilterModelChange:g}});const _=s.useCallback((S,I)=>{const{filterModel:F,onFilterModelChange:L}=b.current;if(!L)return;const E=rd(F,S,I);E!==F&&(b.current={filterModel:E,onFilterModelChange:L},L(E))},[]),v=Vg(C),k=c?1:0,A=a?k+1:k,M=u?A+1:A,N=M,P=c?Ge:0,T=P+(a&&f?Ge:0);return d.jsxs("div",{className:"ogx__header-filter-row",role:"row","aria-rowindex":y,children:[c&&d.jsx(br,{field:_t,ariaColIndex:k,sticky:!0,left:0,focused:m===_t}),a&&d.jsx(br,{field:kt,ariaColIndex:A,sticky:f,left:P,focused:m===kt}),u&&d.jsx(br,{field:Ze,ariaColIndex:M,sticky:h,left:T,focused:m===Ze}),n.map((S,I)=>{if(S.isSpacer)return d.jsx("div",{style:{width:S.width,minWidth:S.width,flexShrink:0},"aria-hidden":"true"},S.field);const F=ot(S.field,r),L=gs(S,o,F,F?i[S.field]:void 0),E=N+(x?.get(S.field)??I)+1,O=[F&&"ogx__header-filter-cell--pinned",F&&`ogx__header-filter-cell--pinned-${F}`,F==="left"&&S.field===l.lastLeft&&"ogx__header-filter-cell--pinned-left-last",F==="right"&&S.field===l.firstRight&&"ogx__header-filter-cell--pinned-right-first",m===S.field&&"ogx__header-filter-cell--focused"].filter(Boolean).join(" ");return td(S)?d.jsx(Kg,{colDef:S,state:el(w,S.field),style:L,className:O,ariaColIndex:E,onItemChange:_,onOpenFilterPanel:p,locale:v},S.field):d.jsx("div",{className:`ogx__header-filter-cell ogx__header-filter-cell--empty ${O}`,style:L,role:"columnheader","aria-label":t.headerFilterNoFilterLabel(S.headerName||S.field),"aria-colindex":E,"data-field":S.field,tabIndex:-1},S.field)})]})}function qg(){return d.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"18",height:"18",children:d.jsx("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"})})}function Xg(){return d.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor",children:d.jsx("path",{d:"M6.99 11L3 15l3.99 4v-3H14v-2H6.99v-3zM21 9l-3.99-4v3H10v2h7.01v3L21 9z"})})}function ws(e){const t=_e(),{columns:n,allColumns:o,columnGroupingModel:r,checkboxSelection:i=!1,allSelected:l=!1,someSelected:c=!1,onSelectAll:a,onSort:u,sortModel:f=[],onColumnResize:h,onColumnAutosize:x,columnWidths:y={},pinnedColumns:w,hasDetailPanel:g=!1,pinCheckboxColumn:p=!0,pinExpandColumn:m=!0,rowReordering:C=!1,aggregationModel:b,draggedColumn:_,dragOverColumn:v,onDragStart:k,onDragOver:A,onDragEnd:M,onDrop:N,focusedCell:P,onHeaderClick:T,onSortAdd:S,multiSort:I=!1,onHideColumn:F,onPinColumn:L,onManageColumns:E,columnIndexMap:O,wrapHeaderText:B=!1,headerHeight:H=56,headerFilters:K=!1,filterModel:R,onFilterModelChange:X,onOpenFilterPanel:j,localeText:Q}=e,U=s.useId(),[re,q]=s.useState(null),se=oe=>ue=>{ue.stopPropagation(),q({colDef:oe,anchorEl:ue.currentTarget})},Z=s.useCallback(()=>{q(null)},[]),$=oe=>ue=>{if(ue.altKey&&(ue.key==="ArrowLeft"||ue.key==="ArrowRight")&&ue.target===ue.currentTarget){if(oe.resizable===!1||!h)return;ue.preventDefault(),ue.stopPropagation();const ve=vt(oe,y),ye=Nn(ue.key,Je(ue.currentTarget)),fe=(ue.shiftKey?50:10)*(ye==="ArrowRight"?1:-1);h(oe.field,fr(ve+fe,ve,oe.minWidth,oe.maxWidth));return}if(!(ue.altKey&&ue.key==="ArrowDown"||(ue.ctrlKey||ue.metaKey)&&ue.key==="Enter")||oe.disableColumnMenu||ue.target!==ue.currentTarget)return;ue.preventDefault(),ue.stopPropagation();const ge=ue.currentTarget.querySelector(".ogx__menu-icon-btn")??ue.currentTarget;q({colDef:oe,anchorEl:ge})},D=oe=>P?.id===null&&!P.headerFilter&&P.field===oe,G=C?1:0,W=g?G+1:G,ee=i?W+1:W,V=oe=>ue=>{if(oe.sortable===!1)return;const be=f.find(ge=>ge.field===oe.field);let he="asc";be&&(be.sort==="asc"?he="desc":he=null),(ue.shiftKey||I)&&S?S(oe.field,he):u&&u(oe.field,he)},Y=(oe,ue)=>{const be=f.some(ge=>ge.field===oe);S&&(ue===null||be||I||!u)?S(oe,ue):u?.(oe,ue)},J=oe=>{const ue=f.find(he=>he.field===oe);if(!ue)return null;const be=f.length>1?f.indexOf(ue)+1:null;return d.jsx("span",{className:`ogx__sort-icon ogx__sort-icon--${ue.sort}`,"aria-hidden":"true",children:be!==null&&d.jsx("span",{className:"ogx__sort-badge",children:be})})},te=s.useMemo(()=>ho(n,y,w,i,p,g,m,C),[n,y,w,i,p,g,m,C]),ne=s.useMemo(()=>mo(n,w),[n,w]),z=Pl(r),ie=s.useMemo(()=>Ll(r),[r]),ae=s.useMemo(()=>z===0?[]:(o??n).map(oe=>({field:oe.field,width:vt(oe,y),flex:oe.isSpacer?0:oe.flex,pinned:oe.isSpacer?null:ot(oe.field,w),isSpacer:oe.isSpacer})),[z,o,n,y,w]),we=(C?48:0)+(g?48:0)+(i?48:0),me=(C||g||i)&&(!g||m)&&(!i||p),pe=(C?1:0)+(g?1:0)+(i?1:0);return d.jsxs("div",{className:"ogx__header-wrap",children:[z>0&&Array.from({length:z},(oe,ue)=>{const be=mu(ae,ie,ue);return d.jsxs("div",{className:"ogx-col-group-row",role:"row","aria-rowindex":ue+1,children:[we>0&&d.jsx("div",{className:`ogx-col-group-cell ogx-col-group-cell--filler${me?" ogx-col-group-cell--pinned ogx-col-group-cell--pinned-left":""}`,style:{width:we,minWidth:we,flexShrink:0,position:me?"sticky":void 0,insetInlineStart:me?0:void 0},"aria-hidden":"true"}),be.map((he,ge)=>{const ve=he.pinned?` ogx-col-group-cell--pinned ogx-col-group-cell--pinned-${he.pinned}`:"",ye={width:he.width,minWidth:he.width,flexShrink:0,flexGrow:he.flexGrow};return he.pinned==="left"?(ye.position="sticky",ye.insetInlineStart=te[he.fields[0]]):he.pinned==="right"&&(ye.position="sticky",ye.insetInlineEnd=te[he.fields[he.fields.length-1]],be[ge-1]?.pinned!=="right"&&(ye.marginInlineStart="auto")),he.isGroup?d.jsx("div",{role:"columnheader","aria-colspan":he.fields.length,"aria-colindex":pe+he.firstDataIndex+1,className:`ogx-col-group-cell ogx-col-group-cell--group${ve}${he.headerClassName?` ${he.headerClassName}`:""}`,style:ye,title:he.label,children:d.jsx("span",{className:"ogx-col-group-cell__label",children:he.label})},he.key):d.jsx("div",{className:`ogx-col-group-cell ogx-col-group-cell--filler${ve}`,style:ye,"aria-hidden":"true"},he.key)})]},`ogx-grp-${ue}`)}),d.jsxs("div",{className:"ogx__header",role:"row","aria-rowindex":z+1,children:[C&&d.jsx("div",{className:`ogx__header-cell ogx__header-cell--pinned ogx__header-cell--pinned-left ${D("__reorder_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-label":t.headerRowReorderLabel,"aria-colindex":G,"data-field":"__reorder_col__",tabIndex:-1,title:t.headerRowReorderTooltip,style:{minWidth:48,maxWidth:48,position:"sticky",insetInlineStart:0}}),g&&d.jsx("div",{className:`ogx__header-cell ogx__header-cell--expand ${m?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""} ${D("__expand_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-label":t.headerDetailPanelLabel,"aria-colindex":W,"data-field":"__expand_col__",tabIndex:-1,style:{minWidth:48,maxWidth:48,position:m?"sticky":void 0,insetInlineStart:m?C?48:0:void 0}}),i&&d.jsx("div",{className:`ogx__header-cell ogx__header-cell--checkbox ${p?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""} ${D("__checkbox_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-colindex":ee,"data-field":"__checkbox_col__",style:{position:p?"sticky":void 0,insetInlineStart:p?(C?48:0)+(g&&m?48:0):void 0},children:a&&d.jsx(pt,{id:U,name:U,checked:l,indeterminate:c,onChange:oe=>a(oe.target.checked),"aria-label":l?t.headerDeselectAllLabel:t.headerSelectAllLabel,tabIndex:-1,onMouseDown:oe=>oe.preventDefault()})}),n.map((oe,ue)=>{if(oe.isSpacer)return d.jsx("div",{style:{width:oe.width,minWidth:oe.width,flexShrink:0},"aria-hidden":"true"},oe.field);const be=oe.sortable!==!1,he=f.findIndex(He=>He.field===oe.field),ge=he!==-1,ve=ge?f[he].sort:null,ye=O?.get(oe.field)??ue,fe=be?he===0?ve==="asc"?"ascending":"descending":"none":void 0,Ee=ge&&f.length>1?t.headerSortDescription(ve==="asc"?"asc":"desc",he+1,f.length):void 0,Le=oe.resizable!==!1,Ne=ot(oe.field,w),Me=Ne!==null,qe=_===oe.field,Fe=v===oe.field,Xe=Wg(oe.wrapHeaderText,B),We=b?.[oe.field],xe=["ogx__header-cell",`ogx__header-cell--align-${oe.headerAlign||oe.align||"left"}`,be&&"ogx__header-cell--sortable",ge&&"ogx__header-cell--sorted",Me&&"ogx__header-cell--pinned",Me&&`ogx__header-cell--pinned-${Ne}`,Ne==="left"&&oe.field===ne.lastLeft&&"ogx__header-cell--pinned-left-last",Ne==="right"&&oe.field===ne.firstRight&&"ogx__header-cell--pinned-right-first",qe&&"ogx__header-cell--dragging",Fe&&"ogx__header-cell--drag-over",Xe&&"ogx__header-cell--wrap",D(oe.field)&&"ogx__header-cell--focused",oe.headerClassName].filter(Boolean).join(" "),Ie={...gs(oe,y,Ne,Ne?te[oe.field]:void 0),zIndex:oe.zIndex,opacity:qe?.5:1},Te=oe.renderHeader?oe.renderHeader({field:oe.field,colDef:oe,colIndex:ye}):oe.headerName||oe.field,Re=He=>{if(He.target.closest(".ogx-column-resize-handle")){He.stopPropagation();return}T?.(oe.field),be&&V(oe)(He)},mt=k&&!Me?k(oe.field):void 0,Pt=A&&!Me?A(oe.field):void 0,Lt=N&&!Me?N(oe.field):void 0;return d.jsxs("div",{className:xe,style:Ie,title:oe.description??(Xe&&typeof Te=="string"?Te:void 0),onClick:Re,role:"columnheader",draggable:!!mt,onDragStart:mt,onDragOver:Pt,onDragEnd:M,onDrop:Lt,onKeyDown:$(oe),"aria-sort":fe,"aria-description":Ee,"aria-colindex":pe+ye+1,"data-field":oe.field,tabIndex:-1,children:[d.jsxs("div",{className:"ogx__header-cell-content",children:[qe&&d.jsx("div",{className:"ogx__header-drag-icon",children:d.jsx(Xg,{})}),d.jsxs("div",{className:"ogx__header-cell-title-wrapper",children:[d.jsx("span",{className:"ogx__header-cell-title",style:Xe?{WebkitLineClamp:Bg(H,!!We)}:void 0,children:Te}),We&&d.jsx("span",{className:"ogx__header-cell-aggregation",children:We})]}),be&&J(oe.field),!oe.disableColumnMenu&&d.jsx("button",{type:"button",className:"ogx__menu-icon-btn",onClick:se(oe),"aria-label":t.headerColumnMenuButtonLabel(oe.headerName||oe.field),"aria-haspopup":"menu",tabIndex:-1,children:d.jsx(qg,{})})]}),Le&&h&&d.jsx(Ag,{field:oe.field,currentWidth:vt(oe,y),onResize:h,onAutosize:x,minWidth:oe.minWidth,maxWidth:oe.maxWidth,edge:Ne==="right"?"start":"end"})]},oe.field)}),re&&d.jsx($g,{colDef:re.colDef,sortModel:f,onSort:u||S?Y:void 0,onHide:F,onPin:L,pinnedColumns:w,onManageColumns:E,onClose:Z,anchorEl:re.anchorEl})]}),K&&d.jsx(jg,{columns:n,columnWidths:y,pinnedColumns:w,pinnedPositions:te,pinnedEdges:ne,rowReordering:C,hasDetailPanel:g,checkboxSelection:i,pinExpandColumn:m,pinCheckboxColumn:p,columnIndexMap:O,ariaRowIndex:z+2,filterModel:R,onFilterModelChange:X,onOpenFilterPanel:j,localeText:Q,focusedField:P?.id===null&&P.headerFilter?P.field:null})]})}function hn(e){return e.headerName||e.field}function Yg(e){return e.nativeEvent.isComposing||e.keyCode===229}function mn(e,t,n=!0){return o=>{if(Yg(o)){o.stopPropagation();return}n&&o.key==="Enter"&&(o.stopPropagation(),e()),o.key==="Escape"&&(o.stopPropagation(),t())}}function Jg({value:e,colDef:t,onValueChange:n,onCommit:o,onCancel:r}){const[i,l]=s.useState(String(e??"")),c=s.useRef(null);return s.useEffect(()=>{c.current?.focus(),c.current?.select()},[]),d.jsx(nt,{ref:c,variant:"cell",type:"text",inputClassName:"ogx__edit-input","aria-label":hn(t),value:i,onChange:a=>{l(a.target.value),n(a.target.value)},onBlur:o,onKeyDown:mn(o,r)})}function Zg({value:e,colDef:t,onValueChange:n,onCommit:o,onCancel:r}){const[i,l]=s.useState(typeof e=="number"?e:""),c=s.useRef(null);return s.useEffect(()=>{c.current?.focus(),c.current?.select()},[]),d.jsx(nt,{ref:c,variant:"cell",type:"number",inputClassName:"ogx__edit-input ogx__edit-input--number","aria-label":hn(t),value:i,onChange:a=>{const u=a.target.value===""?"":Number(a.target.value);l(u),n(u===""?null:u)},onBlur:o,onKeyDown:mn(o,r)})}function Qg({value:e,colDef:t,onValueChange:n,onCommit:o,onCancel:r}){const i=s.useRef(null);s.useEffect(()=>{i.current?.focus()},[]);const l=()=>{n(!e),o()};return d.jsx("div",{className:"ogx__edit-boolean",onMouseDown:c=>c.preventDefault(),children:d.jsx(pt,{ref:i,inputClassName:"ogx__edit-checkbox","aria-label":hn(t),checked:!!e,onChange:l,onMouseDown:c=>c.preventDefault(),onBlur:o,onKeyDown:mn(o,r,!1)})})}const xr=e=>typeof e=="object"?e.value:e,ep=e=>typeof e=="object"?e.label:String(e);function tp(e,t){return e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Object.is(e,t)}function np({value:e,colDef:t,onValueChange:n,onCommit:o,onCancel:r}){const i=s.useRef(null);s.useEffect(()=>{i.current?.focus()},[]);const l=t.valueOptions??[],c=l.map(f=>String(xr(f)));let a=l.findIndex(f=>tp(xr(f),e));a===-1&&e!==null&&e!==void 0&&(a=c.indexOf(String(e)));const u=a===-1;return d.jsxs("select",{ref:i,className:"ogx__edit-select","aria-label":hn(t),value:u?"":c[a],onChange:f=>{const h=c.indexOf(f.target.value);n(h===-1?null:xr(l[h]))},onBlur:o,onKeyDown:mn(o,r),children:[u&&d.jsx("option",{value:""}),l.map((f,h)=>d.jsx("option",{value:c[h],children:ep(f)},h))]})}const bs=e=>String(e).padStart(2,"0"),xs=/^(\d{4}-\d{2}-\d{2})/;function Cr(e){if(e instanceof Date)return Number.isNaN(e.getTime())?"":`${e.getFullYear()}-${bs(e.getMonth()+1)}-${bs(e.getDate())}`;if(typeof e=="string"){const t=xs.exec(e);return t?t[1]:e===""?"":Cr(new Date(e))}return typeof e=="number"?Cr(new Date(e)):""}function op(e,t){if(e==="")return null;const[n,o,r]=e.split("-").map(Number),i=l=>{const c=new Date(l.getTime());return c.setFullYear(n,o-1,r),c};return t instanceof Date&&!Number.isNaN(t.getTime())?i(t):typeof t=="number"&&Number.isFinite(t)?i(new Date(t)).getTime():typeof t=="string"&&xs.test(t)&&t.length>10?e+t.slice(10):e}function rp({value:e,colDef:t,onValueChange:n,onCommit:o,onCancel:r}){const[i]=s.useState(e),[l,c]=s.useState(()=>Cr(e)),a=s.useRef(null);return s.useEffect(()=>{a.current?.focus()},[]),d.jsx(nt,{ref:a,variant:"cell",type:"date",inputClassName:"ogx__edit-input","aria-label":hn(t),value:l,onChange:u=>{c(u.target.value),n(op(u.target.value,i))},onBlur:o,onKeyDown:mn(o,r)})}function ip(e){const{colDef:t}=e;switch(t.type){case"number":return d.jsx("div",{className:"ogx__edit-cell",children:d.jsx(Zg,{...e})});case"boolean":return d.jsx("div",{className:"ogx__edit-cell",children:d.jsx(Qg,{...e})});case"singleSelect":return d.jsx("div",{className:"ogx__edit-cell",children:d.jsx(np,{...e})});case"date":return d.jsx("div",{className:"ogx__edit-cell",children:d.jsx(rp,{...e})});default:return d.jsx("div",{className:"ogx__edit-cell",children:d.jsx(Jg,{...e})})}}function lp(e){const{onCellClick:t,onCellEditStart:n,onCellValueChange:o,value:r,row:i,colDef:l,rowIndex:c,colIndex:a,ariaColIndex:u,isSelected:f,onClick:h,width:x,pinnedPosition:y,pinnedOffset:w,isPinnedEdge:g,isFocused:p,isFocusVisible:m,isEditable:C,isEditing:b,onEditStart:_,onEditStop:v,onValueChange:k,colSpanInfo:A,rowSpan:M,isHiddenByRowSpan:N,rowMeta:P,valueError:T,rangeFlags:S=0}=e,I=s.useCallback(V=>{o?o(l.field,V):k?.(V)},[o,k,l.field]),F=P?.isGroupRow===!0,{formattedValue:L,error:E}=s.useMemo(()=>{const V=l.valueFormatter;if(V&&!(F&&r==null)){const Y=Be(()=>V({value:r,row:i,field:l.field}));return Y.ok?{formattedValue:Y.value}:{formattedValue:"",error:Y.error??new Error("valueFormatter failed")}}return{formattedValue:Ln(r,l)}},[r,i,l,F]),O=s.useMemo(()=>{if(!l.cellClassName)return"";const V=l.cellClassName;if(typeof V=="function"){const Y=Be(()=>V({value:r,formattedValue:L,row:i,field:l.field,colDef:l,rowIndex:c,colIndex:a,rowMeta:P}));return Y.ok&&Y.value||""}return l.cellClassName},[l,r,L,i,c,a,P]),B=T??E,H=l.field,K=s.useCallback(()=>{v?.(!1,H)},[v,H]),R=s.useCallback(()=>{v?.(!0,H)},[v,H]),X=s.useMemo(()=>[i,l.renderCell,r],[i,l.renderCell,r]),j=s.useRef(!1);if(s.useEffect(()=>{if(!(!b||!v))return j.current=!0,()=>{j.current=!1,queueMicrotask(()=>{j.current||v(!1,H)})}},[b,v,H]),A?.spannedByColSpan)return null;const Q=A?.cellProps.colSpan??1,U=Q>1,re=(U?A?.cellProps.width:void 0)??x??l.width??100,q={width:"var(--width)","--width":typeof re=="number"?`${re}px`:re,flexGrow:(U?A?.cellProps.flexGrow:void 0)??l.flex??0,flexShrink:0,flexBasis:"auto",boxSizing:"border-box",minWidth:U?void 0:l.minWidth,maxWidth:U?void 0:l.maxWidth};if(N)return d.jsx("div",{className:"ogx__cell ogx__cell--hidden",style:q,role:"presentation","data-field":l.field,"data-colindex":a});const se=V=>{b||(t&&t({row:i,field:l.field,value:r,colDef:l,rowIndex:c,colIndex:a}),h?.(V))},Z=()=>{b||!C||(n?n(l.field,r):_?.())},$=l.renderEditCell,D=y!=null,G=["ogx__cell",`ogx__cell--align-${l.align||"left"}`,f&&"ogx__cell--selected",p&&"ogx__cell--focused",p&&m&&"ogx__cell--focus-visible",l.type&&`ogx__cell--type-${l.type}`,D&&"ogx__cell--pinned",D&&`ogx__cell--pinned-${y}`,D&&g&&`ogx__cell--pinned-${y}-${y==="left"?"last":"first"}`,b&&"ogx__cell--editing",M&&M>1&&"ogx__cell--spanned",(S&Go)!==0&&"ogx__cell--range",(S&$i)!==0&&"ogx__cell--range-top",(S&Gi)!==0&&"ogx__cell--range-bottom",(S&Hi)!==0&&"ogx__cell--range-left",(S&Bi)!==0&&"ogx__cell--range-right",O].filter(Boolean).join(" "),W=M||1,ee={...q,position:D?"sticky":void 0,zIndex:l.zIndex??(D?3:void 0),padding:b?0:void 0};return W>1&&(ee.height=`calc(var(--height) * ${W} - var(--border-width, 1px))`,ee.zIndex=10,D&&(ee.zIndex=40)),D&&w!==void 0&&(y==="left"?ee.insetInlineStart=w:ee.insetInlineEnd=w),d.jsxs("div",{className:G,style:ee,onClick:se,onDoubleClick:Z,role:"gridcell","aria-colindex":u??a+1,"aria-readonly":!C||void 0,tabIndex:-1,"data-field":l.field,"data-colindex":a,...Q>1?{"aria-colspan":Q}:{},...W>1?{"aria-rowspan":W}:{},...(S&Go)!==0?{"aria-selected":!0}:{},children:[d.jsx("div",{className:"ogx__cell-content",children:b&&(o||k)&&v?$?d.jsx(Mt,{field:l.field,resetKey:i,renderFn:()=>$({value:r,formattedValue:L,row:i,field:l.field,colDef:l,rowIndex:c,colIndex:a,rowMeta:P,onValueChange:I,onCommit:K,onCancel:R})}):d.jsx(ip,{value:r,formattedValue:L,row:i,field:l.field,colDef:l,rowIndex:c,colIndex:a,rowMeta:P,onValueChange:I,onCommit:K,onCancel:R}):B!==void 0?d.jsx(Mt,{field:l.field,resetKey:i,renderFn:()=>{throw B}}):l.renderCell?d.jsx(Mt,{field:l.field,resetKey:X,renderFn:()=>l.renderCell({value:r,formattedValue:L,row:i,field:l.field,colDef:l,rowIndex:c,colIndex:a,rowMeta:P})}):l.type==="image"&&typeof r=="string"&&r!==""?d.jsx("img",{className:"ogx__cell-image",src:r,alt:l.headerName??l.field,loading:"lazy"}):L}),(S&Wi)!==0&&!b&&d.jsx("div",{className:"ogx__cell-fill-handle","aria-hidden":"true"})]})}const Cs=s.memo(lp),sp=({className:e="",...t})=>{const n=_e();return d.jsx("button",{type:"button",className:`ogx-drag-handle ${e}`,"aria-label":n.rowReorderLabel,...t,children:d.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"currentColor","aria-hidden":"true",children:d.jsx("path",{d:"M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2zm-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"})})})};function ap(e){const{rowId:t,content:n,height:o,isExpanded:r,onHeightChange:i,id:l,colSpan:c}=e,a=s.useRef(null),u=o==="auto";if(s.useLayoutEffect(()=>{const h=a.current;if(!h||!u||!r||!i)return;const x=()=>{h.getClientRects().length!==0&&i(t,h.offsetHeight)};if(x(),typeof ResizeObserver>"u")return;const y=new ResizeObserver(x);return y.observe(h),()=>y.disconnect()},[u,r,i,t]),!r)return null;const f={height:u?"auto":`${o}px`,overflow:u?"visible":"auto"};return d.jsx("div",{ref:a,className:"ogx__detail-panel",style:f,role:"row",id:l,children:d.jsx("div",{className:"ogx__detail-panel-content",role:"gridcell","aria-colspan":c,children:n})})}const yr=12;function cp(e,t,n,o){let r=0,i=0,l=0;for(let c=t;c<e.length&&l<n;c++){const a=e[c];if(a.isSpacer)break;r+=vt(a,o),i+=a.flex??0,l++}return{spannedByColSpan:!1,cellProps:{colSpan:l,width:r,flexGrow:i}}}const dp={field:"__expand_col__",width:48},up={field:"__checkbox_col__",width:48};function fp(e){const t=_e(),{row:n,skeleton:o=!1,rowId:r,columns:i,rowIndex:l,isSelected:c=!1,checkboxSelection:a=!1,onRowClick:u,onRowDoubleClick:f,onCellClick:h,onSelectionChange:x,columnWidths:y={},pinnedColumns:w,pinnedRows:g,hasDetailPanel:p=!1,isDetailPanelExpanded:m=!1,onDetailPanelToggle:C,detailPanelContent:b,detailPanelHeight:_=xo,onDetailPanelHeightChange:v,pinCheckboxColumn:k=!0,pinExpandColumn:A=!0,rowReordering:M=!1,onDragStart:N,onDragOver:P,onDragEnd:T,onDrop:S,isDragging:I,isDragOver:F,editingCell:L,onEditStart:E,onEditStop:O,onEditCellValueChange:B,isCellEditable:H,focusedCellField:K,isFocusVisible:R,colspanMap:X,rowSpanningCaches:j,rowHeight:Q=52,rowMeta:U,columnIndexMap:re,ariaRowIndex:q,cellRange:se}=e,Z=r??n.id,$=s.useId(),D=s.useId(),G=s.useMemo(()=>ho(i,y,w,a,k,p,A,M),[i,y,w,a,k,p,A,M]),W=s.useMemo(()=>mo(i,w),[i,w]),ee=U?.hasChildren===!0,V=U?.isGroupRow===!0,Y=p&&!V,J=!V&&!Ke(Z),te=s.useCallback((fe,Ee)=>{E?.({id:Z,field:fe,value:Ee})},[Z,E]),ne=s.useCallback((fe,Ee)=>{B?.({id:Z,field:fe,value:Ee})},[B,Z]),z=s.useCallback((fe,Ee)=>{O?.({cancel:fe,id:Z,field:Ee})},[O,Z]);if(o){const fe=Math.max(i.length,5);return d.jsx("div",{className:"ogx__row ogx__row--skeleton",role:"row","aria-hidden":"true",style:{height:Q,minHeight:Q},children:Array.from({length:fe}).map((Ee,Le)=>d.jsx("div",{className:"ogx__skeleton-cell",children:d.jsx("div",{className:"ogx__skeleton-bar"})},Le))})}const ie=fe=>{fe.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell, .ogx__cell--editing")||u?.({row:n,id:Z,rowIndex:l})},ae=fe=>{fe.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell, .ogx__cell--editing")||f?.({row:n,id:Z,rowIndex:l})},le=fe=>{fe.stopPropagation(),x?.(Z,fe.target.checked)},ce=fe=>{fe.stopPropagation(),C?.(Z)},de=M?1:0,we=p?de+1:de,me=a?we+1:we,pe=me,oe=re?.size??i.filter(fe=>!fe.isSpacer).length,ue=U!==void 0,be=U?.hasChildren===!0,he=qr(Z,g),ge=he==="top",ve=he==="bottom",ye=["ogx__row",c&&"ogx__row--selected",l%2===0&&"ogx__row--even",l%2===1&&"ogx__row--odd",ge&&"ogx__row--pinned-top",ve&&"ogx__row--pinned-bottom",I&&"ogx__row--dragging",F&&"ogx__row--drag-over",ee&&"ogx__row--group",U?.isGroupFooter&&"ogx__row--group-footer"].filter(Boolean).join(" ");return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:ye,onClick:ie,onDoubleClick:f?ae:void 0,role:"row","aria-rowindex":q??l+2,"aria-selected":c,"aria-level":ue?(U?.treeDepth??0)+1:void 0,"aria-expanded":be?U?.isExpanded===!0:void 0,"data-rowindex":l,onDragOver:P?P(Z):void 0,onDrop:S?S(Z):void 0,style:{maxHeight:`${Q}px`,minHeight:`${Q}px`,"--height":`${Q}px`,"--border-width":"1px"},children:[M&&d.jsx("div",{className:`ogx__cell ogx__cell--drag-handle ${K==="__reorder_col__"?"ogx__cell--focused":""} ${K==="__reorder_col__"&&R?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":N?t.rowReorderLabel:void 0,"aria-colindex":de,"data-field":"__reorder_col__",tabIndex:-1,style:{position:"sticky",insetInlineStart:0,zIndex:yr},draggable:!!N,onDragStart:N?N(Z):void 0,onDragEnd:T,onClick:fe=>fe.stopPropagation(),children:N&&d.jsx(sp,{})}),p&&d.jsx("div",{className:`ogx__cell ogx__cell--expand ${A?"ogx__cell--pinned-left":""} ${K==="__expand_col__"?"ogx__cell--focused":""} ${K==="__expand_col__"&&R?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":Y?m?t.rowDetailPanelCollapseLabel:t.rowDetailPanelExpandLabel:void 0,"aria-expanded":Y?m:void 0,"aria-controls":Y&&m?D:void 0,"aria-colindex":we,"data-field":"__expand_col__",style:{position:A?"sticky":void 0,insetInlineStart:A?M?48:0:void 0,zIndex:A?yr:void 0},tabIndex:-1,onClick:fe=>{fe.stopPropagation(),h?.({row:n,field:"__expand_col__",value:m,colDef:dp,rowIndex:l,colIndex:-1})},children:Y&&d.jsx(Qo,{isExpanded:m,onClick:ce,variant:"plus-minus",tabIndex:-1})}),a&&d.jsx("div",{className:`ogx__cell ogx__cell--checkbox ${k?"ogx__cell--pinned-left":""} ${K==="__checkbox_col__"?"ogx__cell--focused":""} ${K==="__checkbox_col__"&&R?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-colindex":me,"data-field":"__checkbox_col__",style:{position:k?"sticky":void 0,insetInlineStart:k?(M?48:0)+(p&&A?48:0):void 0,zIndex:k?yr:void 0},tabIndex:-1,onClick:fe=>{fe.stopPropagation(),h?.({row:n,field:"__checkbox_col__",value:c,colDef:up,rowIndex:l,colIndex:-1})},children:J&&d.jsx(pt,{id:$,name:`ogx-select-row-${Z}`,checked:c,onChange:le,onClick:fe=>fe.stopPropagation(),"aria-label":c?t.rowDeselectLabel(Z):t.rowSelectLabel(Z),tabIndex:-1,onMouseDown:fe=>fe.preventDefault()})}),i.map((fe,Ee)=>{if(fe.isSpacer)return d.jsx("div",{style:{width:fe.width,minWidth:fe.width,flexShrink:0},"aria-hidden":"true"},fe.field);let Le,Ne;V?Le=n[fe.field]:{value:Le,error:Ne}=Yr(n,fe.field,fe);const Me=re?.get(fe.field)??Ee,qe=y[fe.field]??fe.width,Fe=ot(fe.field,w),Xe=!!E&&vo({row:n,field:fe.field,value:Le,colDef:fe,rowIndex:l,colIndex:Me,rowMeta:U},H),We=L?.id===Z&&L?.field===fe.field,xe=We?L?.value:Le,Ie=X?.get(Z)?.[fe.field],Te=Ie&&!Ie.spannedByColSpan&&Ie.cellProps.colSpan>1?cp(i,Me,Ie.cellProps.colSpan,y):Ie,Re=Te&&!Te.spannedByColSpan?i[Me+Te.cellProps.colSpan-1]?.field??fe.field:fe.field,mt=Fe==="right"?Re:fe.field,Pt=Fe?G[mt]:void 0,Lt=Fe==="left"&&Re===W.lastLeft||Fe==="right"&&fe.field===W.firstRight,He=j?.spannedCells[Z]?.[fe.field],ro=j?.hiddenCells[Z]?.[fe.field]||!1,Cn=se&&!ro&&fe.field!==Oi?_c(se,Me,Te&&!Te.spannedByColSpan?Te.cellProps.colSpan:1,He??1):void 0;return d.jsx(Cs,{value:xe,row:n,colDef:fe,rowIndex:l,colIndex:Me,ariaColIndex:pe+Me+1,isSelected:c,onCellClick:h,width:qe,pinnedPosition:Fe,pinnedOffset:Pt,isPinnedEdge:Lt,isFocused:K===fe.field,isFocusVisible:R,isEditable:Xe,isEditing:We,onCellEditStart:te,onEditStop:z,onCellValueChange:ne,colSpanInfo:Te,rowSpan:He,isHiddenByRowSpan:ro,rowMeta:U,valueError:Ne,rangeFlags:Cn},fe.field)})]}),Y&&d.jsx(ap,{id:D,colSpan:pe+oe,row:n,rowId:Z,rowIndex:l,content:b,height:_,isExpanded:m,onHeightChange:v})]})}function gp(e,t){const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(o==="cellRange"){if(!Sc(e.cellRange,t.cellRange))return!1}else if(!Object.is(e[o],t[o]))return!1;return!0}const Zn=s.memo(fp,gp);function ys({getContent:e,params:t}){return d.jsx(Mt,{field:"detail panel",renderFn:()=>e(t),resetKey:t.row})}const pp=e=>e.id;function vs({rows:e,position:t,columns:n,selectedRowIds:o,checkboxSelection:r,onRowClick:i,onRowDoubleClick:l,onCellClick:c,onSelectionChange:a,columnWidths:u,pinnedColumns:f,pinnedRows:h,hasDetailPanel:x,expandedRowIds:y,getDetailPanelContent:w,getDetailPanelHeight:g,onDetailPanelToggle:p,onDetailPanelHeightChange:m,pinCheckboxColumn:C,pinExpandColumn:b,focusedCell:_,colspanMap:v,rowSpanningCaches:k,rowHeight:A,rowMetaMap:M,getRowId:N=pp,rowIndexOffset:P=0,ariaRowIndexBase:T,columnIndexMap:S,editingHandlers:I,isCellEditable:F,rowReordering:L=!1,cellRange:E,cellRangeHasRowSpan:O=!1,fillHandle:B}){return e.length===0?null:d.jsx("div",{className:`ogx__pinned-rows ogx__pinned-rows--${t}`,role:"rowgroup",children:e.map((H,K)=>{const R=N(H),X=P+K;return d.jsx(Zn,{row:H,rowId:R,columns:n,rowIndex:X,ariaRowIndex:T!==void 0?T+K:void 0,columnIndexMap:S,isSelected:o.has(R),checkboxSelection:r,onRowClick:i,onRowDoubleClick:l,onCellClick:c,onSelectionChange:a,columnWidths:u,pinnedColumns:f,pinnedRows:h,hasDetailPanel:x,isDetailPanelExpanded:y.has(R),detailPanelContent:y.has(R)&&w?d.jsx(ys,{getContent:w,params:{row:H,id:R,rowIndex:X}}):null,detailPanelHeight:y.has(R)?Co(yo(g,{row:H,id:R,rowIndex:X})):void 0,onDetailPanelHeightChange:m,onDetailPanelToggle:p,pinCheckboxColumn:C,pinExpandColumn:b,focusedCellField:_?.id===R?_.field:null,colspanMap:v,rowSpanningCaches:k,rowHeight:A,rowMeta:M.get(R),editingCell:I?.editingCell?.id===R?I.editingCell:null,onEditStart:I?.startCellEdit,onEditStop:I?.stopCellEdit,onEditCellValueChange:I?.setEditCellValue,isCellEditable:F,rowReordering:L,cellRange:Di(E,X,O,B)},R)})})}const hp=({columns:e,rowHeight:t,checkboxSelection:n=!1,hasDetailPanel:o=!1,rowReordering:r=!1})=>d.jsxs("div",{className:"ogx__row ogx__skeleton-row",style:{height:t},role:"row",children:[n&&d.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:d.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),o&&d.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:d.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),r&&d.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:d.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),e.map((i,l)=>{const c=typeof i.width=="number"?i.width:150,a=Math.min(c*.7,c-20);return d.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:c,minWidth:i.minWidth,maxWidth:i.maxWidth,insetInlineStart:i.left,insetInlineEnd:i.right,position:i.isSpacer?"relative":i.pinned?"sticky":"relative",zIndex:i.zIndex},children:!i.isSpacer&&d.jsx("div",{className:"ogx-skeleton-box",style:{width:a,height:16,borderRadius:4}})},i.field||l)})]});function mp({virtualContainerHeight:e,offsetTop:t,effectiveLoading:n,visibleRows:o,baseColumns:r,virtualColumns:i,viewportWidth:l,checkboxSelection:c,hasDetailPanel:a,rowReordering:u,rowHeight:f,selectedRowIds:h,onRowClick:x,onRowDoubleClick:y,onCellClick:w,onSelectionChange:g,columnWidths:p,pinnedColumns:m,expandedRowIds:C,getDetailPanelContent:b,getDetailPanelHeight:_,onDetailPanelToggle:v,onDetailPanelHeightChange:k,pinCheckboxColumn:A,pinExpandColumn:M,rowReorderHandlers:N,editingHandlers:P,isCellEditable:T,focusedCell:S,colspanMap:I,rowSpanningCaches:F,paginationMode:L,dataSourceLoading:E,sortedUnpinnedRowCount:O,infiniteScrollSkeletonCount:B,unpinnedRowsLength:H,lastRenderedRowIndex:K,rowMetaMap:R,loadingOverlay:X,ariaRowIndexOffset:j,columnIndexMap:Q,cellRange:U,cellRangeHasRowSpan:re=!1,fillHandle:q}){const se=r.length>0?r:(()=>{const D=(l||1e3)-(c?48:0)-(a?48:0)-(u?48:0),G=150,W=Math.max(1,Math.ceil(D/G));return Array.from({length:W},(ee,V)=>({field:`placeholder_${V}`,headerName:"",width:G}))})(),Z=o.filter(D=>!D.pinned),$=L==="infinite"&&E&&O>0&&K>=H-1;return d.jsx("div",{className:"ogx__virtual-container",style:{height:`${e}px`},role:"presentation",children:d.jsxs("div",{className:"ogx__rows",style:{transform:`translateY(${t}px)`},role:"rowgroup",children:[n&&o.length===0&&X?d.jsx("div",{className:"ogx__loading-overlay",style:{width:l||void 0},children:X}):n&&o.length===0?Array.from({length:10}).map((D,G)=>d.jsx(hp,{columns:se,rowHeight:f,checkboxSelection:c,hasDetailPanel:a,rowReordering:u},`skeleton-${G}`)):Z.map(({row:D,id:G,rowIndex:W})=>d.jsx(Zn,{row:D,rowId:G,columns:i,rowIndex:W,ariaRowIndex:j!==void 0?W+j:void 0,columnIndexMap:Q,isSelected:h.has(G),checkboxSelection:c,onRowClick:x,onRowDoubleClick:y,onCellClick:w,onSelectionChange:g,columnWidths:p,pinnedColumns:m,hasDetailPanel:a,isDetailPanelExpanded:C.has(G),detailPanelContent:C.has(G)&&b?d.jsx(ys,{getContent:b,params:{row:D,id:G,rowIndex:W}}):null,detailPanelHeight:C.has(G)?Co(yo(_,{row:D,id:G,rowIndex:W})):void 0,onDetailPanelHeightChange:k,onDetailPanelToggle:v,pinCheckboxColumn:A,pinExpandColumn:M,rowReordering:u,onDragStart:N.canReorderRow(G)?N.onDragStart:void 0,onDragOver:N.onDragOver,onDragEnd:N.onDragEnd,onDrop:N.onDrop,isDragging:N.draggedRowId===G,isDragOver:N.dragOverRowId===G,editingCell:P.editingCell?.id===G?P.editingCell:null,onEditStart:P.startCellEdit,onEditStop:P.stopCellEdit,onEditCellValueChange:P.setEditCellValue,isCellEditable:T,focusedCellField:S!=null&&S.id===G?S.field:null,colspanMap:I,rowSpanningCaches:F,rowHeight:f,rowMeta:R.get(G),cellRange:Di(U,W,re,q)},G)),$&&d.jsx("div",{className:"ogx__skeleton-group",children:Array.from({length:B}).map((D,G)=>d.jsx(Zn,{row:{id:`__skeleton_${G}__`},skeleton:!0,columns:i,rowIndex:H+G,rowHeight:f},`__skeleton_${G}__`))})]})})}function wp({noRowsLabel:e,width:t,overlay:n}){return n?d.jsx("div",{className:"ogx__empty",style:{width:t},children:n}):d.jsxs("div",{className:"ogx__empty",style:{width:t},children:[d.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[d.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),d.jsx("path",{d:"M3 9h18M9 21V9"})]}),d.jsx("span",{children:e})]})}const Ss=48;function bp({columns:e,aggregationModel:t,aggregationResult:n,columnWidths:o,rowHeight:r,checkboxSelection:i,hasDetailPanel:l,rowReordering:c,pinCheckboxColumn:a=!0,pinExpandColumn:u=!0,pinnedColumns:f,loading:h=!1}){const x=_e(),y=s.useMemo(()=>ho(e,o,f,i,a,l,u,c),[e,o,f,i,a,l,u,c]),{lastLeft:w,firstRight:g}=s.useMemo(()=>mo(e,f),[e,f]),p=c?Ss:0,m=p+(l&&u?Ss:0),C=(b,_,v)=>d.jsx("div",{className:`ogx__aggregation-spacer${_?" ogx__aggregation-spacer--pinned":""}`,style:_?{insetInlineStart:v}:void 0,"aria-hidden":"true"},b);return d.jsxs("div",{className:`ogx__aggregation-footer${h?" ogx__aggregation-footer--loading":""}`,role:"row","aria-label":x.aggregationFooterLabel,"aria-live":"polite","aria-busy":h||void 0,style:{minHeight:`${r}px`},children:[c&&C("__reorder_col__",!0,0),l&&C("__expand_col__",u,p),i&&C("__checkbox_col__",a,m),e.map(b=>{if(b.isSpacer){const S=typeof b.width=="number"?b.width:0;return d.jsx("div",{style:{width:S,minWidth:S,flexShrink:0},"aria-hidden":"true"},b.field)}const _=t[b.field],v=_&&So(b,_)?_:void 0,k=n[b.field],A=vt(b,o,120),M=ot(b.field,f),N=M?y[b.field]:void 0,P=["ogx__aggregation-cell",M==="left"&&"ogx__aggregation-cell--pinned-left",M==="right"&&"ogx__aggregation-cell--pinned-right",M==="left"&&b.field===w&&"ogx__aggregation-cell--pinned-left-last",M==="right"&&b.field===g&&"ogx__aggregation-cell--pinned-right-first"].filter(Boolean).join(" "),T={width:A,minWidth:A,maxWidth:A,textAlign:b.align||"left"};return M==="left"&&N!==void 0&&(T.insetInlineStart=N),M==="right"&&N!==void 0&&(T.insetInlineEnd=N),d.jsx("div",{className:P,role:"gridcell",style:T,children:v?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"ogx__aggregation-label",children:v}),d.jsx("span",{className:"ogx__aggregation-value",children:Fn(k,v,b,n)})]}):null},b.field)})]})}function xp(e){const t=_e(),{setViewportElement:n,handleScroll:o,ariaLabel:r,ariaRows:i,navigationColumnCount:l,rowSelectionEnabled:c,disableMultipleRowSelection:a,cellSelection:u,effectiveLoading:f,viewportTabIndex:h,setKeyboardMode:x,handleMouseDownCapture:y,handleKeyDown:w,handleFocus:g,handleBlur:p,effectivePinnedColumns:m,virtualization:C,renderColumns:b,renderedDataColumns:_,columnGroupingModel:v,checkboxSelection:k,rowSelection:A,sortModel:M,handleSort:N,handleSortAdd:P,multiSort:T,handleColumnResize:S,handleColumnAutosize:I,columnWidths:F,focusedCell:L,columnIndexMap:E,handleHeaderClick:O,headerReorderHandlers:B,rowReordering:H,hasDetailPanel:K,pinCheckboxColumn:R,pinExpandColumn:X,aggregationModel:j,handleHideColumn:Q,columnsPanel:U,handlePinColumn:re,wrapHeaderText:q,headerHeight:se,showHeaderFilters:Z,filterModel:$,handleFilterModelChange:D,localeText:G,editingHandlers:W,isCellEditable:ee,selectedRowIds:V,handleRowClick:Y,onRowDoubleClick:J,handleCellClick:te,handleSelectionChange:ne,expandedRowIds:z,getDetailPanelContent:ie,getDetailPanelHeight:ae,handleDetailPanelToggle:le,reportDetailPanelHeight:ce,spanning:de,rowMetaMap:we,fillHandle:me,pinnedTopRows:pe,pinnedBottomRows:oe,pinnedRows:ue,getRowIdOf:be,showEmptyState:he,effectiveNoRowsLabel:ge,noRowsOverlay:ve,loadingOverlay:ye,spanRowWindow:fe,visibleRows:Ee,baseColumns:Le,viewportWidth:Ne,rowReorderHandlers:Me,paginationMode:qe,dataSourceLoading:Fe,sortedUnpinnedRowCount:Xe,pageSize:We,unpinnedRowsLength:xe,showAggregationFooter:Ie,aggregationResult:Te,effectiveRowHeight:Re,isAggregationLoading:mt}=e,{allSelected:Pt,someSelected:Lt}=A,He={rowReordering:H,columnIndexMap:E,editingHandlers:W,isCellEditable:ee,selectedRowIds:V,checkboxSelection:k,onRowClick:Y,onRowDoubleClick:J,onCellClick:te,onSelectionChange:ne,columnWidths:F,pinnedColumns:m,hasDetailPanel:K,expandedRowIds:z,getDetailPanelContent:ie,getDetailPanelHeight:ae,onDetailPanelToggle:le,onDetailPanelHeightChange:ce,pinCheckboxColumn:R,pinExpandColumn:X,focusedCell:L,colspanMap:de.colspanMap,rowSpanningCaches:de.rowSpanningCaches,rowHeight:Re,rowMetaMap:we,cellRange:u.displayRange,cellRangeHasRowSpan:u.hasRowSpan,fillHandle:me.handle};return d.jsx("div",{ref:n,className:"ogx__viewport",onScroll:o,role:"grid","aria-label":r||t.gridLabel,"aria-rowcount":i.rowCount,"aria-colcount":l,"aria-multiselectable":c&&!a||u.enabled,"aria-busy":f,tabIndex:h,onKeyDownCapture:()=>{x(!0)},onMouseDownCapture:y,onMouseDown:u.handleMouseDown,onClickCapture:u.handleClickCapture,onKeyDown:w,onFocus:g,onBlur:p,children:d.jsxs("div",{className:"ogx__content",style:{width:m?.right?.length?`max(100%, ${C.totalWidth}px)`:C.totalWidth},role:"presentation",children:[d.jsxs("div",{className:"ogx__sticky-top",role:"presentation",children:[d.jsx(ws,{columns:b,allColumns:_,columnGroupingModel:v,checkboxSelection:k,allSelected:Pt,someSelected:Lt,onSelectAll:A.selectAll,sortModel:M,onSort:N,onSortAdd:P,multiSort:T,onColumnResize:S,onColumnAutosize:I,columnWidths:F,pinnedColumns:m,focusedCell:L,columnIndexMap:E,onHeaderClick:O,onDragStart:B.onDragStart,onDragOver:B.onDragOver,onDragEnd:B.onDragEnd,onDrop:B.onDrop,draggedColumn:B.draggedColumn,dragOverColumn:B.dragOverColumn,rowReordering:H,hasDetailPanel:K,pinCheckboxColumn:R,pinExpandColumn:X,aggregationModel:j,onHideColumn:Q,onManageColumns:U.openColumnsPanel,onPinColumn:re,wrapHeaderText:q,headerHeight:se,headerFilters:Z,filterModel:$,onFilterModelChange:D,onOpenFilterPanel:U.openFiltersPanel,localeText:G}),d.jsx(vs,{...He,rows:pe,position:"top",ariaRowIndexBase:i.topBase,columns:b,pinnedRows:ue,getRowId:be})]}),he&&d.jsx(wp,{noRowsLabel:ge,width:C.totalWidth,overlay:ve}),d.jsx(mp,{...He,virtualContainerHeight:C.virtualContainerHeight,offsetTop:fe.offsetTop,effectiveLoading:f,visibleRows:Ee,baseColumns:Le,virtualColumns:b,viewportWidth:Ne,rowReorderHandlers:Me,paginationMode:qe,dataSourceLoading:Fe,sortedUnpinnedRowCount:Xe,infiniteScrollSkeletonCount:Math.min(We,20),unpinnedRowsLength:xe,lastRenderedRowIndex:fe.renderContext.lastRowIndex,ariaRowIndexOffset:i.centerOffset,loadingOverlay:ye}),d.jsxs("div",{className:"ogx__sticky-bottom",role:"presentation",children:[d.jsx(vs,{...He,rows:oe,position:"bottom",rowIndexOffset:i.bottomRowIndexOffset,ariaRowIndexBase:i.bottomBase,columns:b,pinnedRows:ue,getRowId:be}),Ie&&d.jsx(bp,{columns:C.virtualColumns,aggregationModel:j,aggregationResult:Te,columnWidths:F,rowHeight:Re,checkboxSelection:k,hasDetailPanel:K,rowReordering:H,pinCheckboxColumn:R,pinExpandColumn:X,pinnedColumns:m,loading:mt})]})]})})}function _s({count:e,sum:t,average:n}){const o=_e();return d.jsxs("div",{className:"ogx__cell-selection-stats",children:[d.jsxs("span",{className:"ogx__cell-selection-stat",children:[d.jsx("span",{className:"ogx__cell-selection-stat-label",children:o.cellSelectionStatsCount}),d.jsx("span",{className:"ogx__cell-selection-stat-value","data-stat":"count",children:e.toLocaleString()})]}),t!==null&&d.jsxs("span",{className:"ogx__cell-selection-stat",children:[d.jsx("span",{className:"ogx__cell-selection-stat-label",children:o.cellSelectionStatsSum}),d.jsx("span",{className:"ogx__cell-selection-stat-value","data-stat":"sum",children:rn(t,"sum")})]}),n!==null&&d.jsxs("span",{className:"ogx__cell-selection-stat",children:[d.jsx("span",{className:"ogx__cell-selection-stat-label",children:o.cellSelectionStatsAverage}),d.jsx("span",{className:"ogx__cell-selection-stat-value","data-stat":"average",children:rn(n,"avg")})]})]})}function Cp({stats:e,apiRef:t,slot:n,slotProps:o}){const r=n??_s;return d.jsx("div",{className:"ogx__cell-selection-stats-area","aria-hidden":e?void 0:!0,children:e&&d.jsx(r,{apiRef:t,...e,...o})})}function yp({paginationSlot:e,paginationSlotProps:t,page:n,paginationModel:o,rowCount:r,pageSizeOptions:i,onPaginationModelChange:l,localeText:c}){const a=e||hr;return d.jsx(a,{page:n,pageSize:o.pageSize,rowCount:r,pageSizeOptions:i,onPageChange:u=>l({...o,page:u}),onPageSizeChange:u=>l({...o,pageSize:u,page:0}),localeText:ji(c),...t})}function vp({loading:e,error:t,noRowsLabel:n,filteredRowCount:o,dataRowCount:r,filterModel:i,cellSelectionAnnouncement:l,aiAssistantAnnouncement:c}){const a=_e();return d.jsxs("div",{className:"ogx-aria-live-status",role:"status","aria-live":"polite",children:[e?a.liveRegionLoading:"",t?a.liveRegionError(ts(t)):"",!e&&!t&&(o===0?n:i&&((i.quickFilterValues?.length||0)>0||(i.items?.length||0)>0)?a.liveRegionRowsFound(r):""),l?d.jsxs("span",{className:"ogx-aria-live-status__cells",children:[" ",l]}):null,c?d.jsxs("span",{className:"ogx-aria-live-status__ai",children:[" ",c]}):null]})}function Sp({overlay:e}){const t=_e();return e?d.jsx("div",{className:"ogx__loading-overlay ogx__loading-overlay--over-rows ogx__loading-overlay--custom",children:e}):d.jsx("div",{className:"ogx__loading-overlay ogx__loading-overlay--over-rows",children:d.jsx("div",{className:"ogx__loading-bar",role:"progressbar","aria-label":t.loadingLabel})})}function _p({error:e,onRetry:t}){const n=_e();if(!e)return null;const o=ts(e);return d.jsxs("div",{className:"ogx-error-overlay","aria-live":"assertive",role:"alert",children:[d.jsxs("svg",{width:"56",height:"56",viewBox:"0 0 24 24",fill:"none",stroke:"var(--ogx-color-error)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("circle",{cx:"12",cy:"12",r:"10"}),d.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),d.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),d.jsx("div",{className:"ogx-error-overlay__title",children:n.errorOverlayTitle}),d.jsx("div",{className:"ogx-error-overlay__message",children:o}),t&&d.jsx("button",{type:"button",onClick:t,className:"ogx-button ogx-button--primary",children:n.errorOverlayRetry})]})}function kp(e){const{containerRef:t,className:n,autoHeight:o,height:r,style:i,hasRowSpanning:l,listView:c,headerFilterHeight:a,slots:u,slotProps:f,toolbarProps:h,aiAssistantPanel:x,orderedColumns:y,columnVisibilityModel:w,disableColumnReorder:g,handleColumnVisibilityModelChange:p,moveColumn:m,resetColumnOrder:C,listViewColumn:b,allRenderableRows:_,dataRows:v,pagination:k,effectivePaginationModel:A,currentPage:M,pageSizeOptions:N,columnsByField:P,paginationRowCount:T,handlePaginationModelChange:S,onRowsScrollEnd:I,toggleExpansion:F,showCellSelectionStats:L,apiRef:E,hasAggregation:O,isHierarchyEnabled:B,dataSourceError:H,filteredRowCount:K,onRetry:R,...X}=e,{effectiveRowHeight:j,headerHeight:Q,showHeaderFilters:U,effectiveLoading:re,columnsPanel:q,columnGroupingModel:se,ariaLabel:Z,pinnedTopRows:$,pinnedBottomRows:D,sortedUnpinnedRowCount:G,effectiveNoRowsLabel:W,checkboxSelection:ee,paginationMode:V,localeText:Y,getRowIdOf:J,rowSelectionEnabled:te,disableMultipleRowSelection:ne,cellSelection:z,aggregationModel:ie,aggregationResult:ae,filterModel:le,selectedRowIds:ce,rowMetaMap:de,handleRowClick:we,onRowDoubleClick:me,handleSelectionChange:pe}=X,oe=u?.noRowsOverlay,ue=u?.loadingOverlay,be=ue?d.jsx(ue,{...f?.loadingOverlay}):void 0,he=oe?d.jsx(oe,{...f?.noRowsOverlay}):void 0,ge=u?.footer,ve=re&&_.length>0&&V!=="infinite",ye=u?.toolbar,fe=cg(Y),Ee=s.useMemo(()=>Zo(fe),[fe]);return d.jsx(cl.Provider,{value:Ee,children:d.jsxs("div",{ref:t,className:["ogx",n,o&&"ogx--auto-height",!o&&r===void 0&&i?.height===void 0&&"ogx--fill",l&&"ogx--row-spanning",c&&"ogx--list-view"].filter(Boolean).join(" "),style:{...i,height:r??i?.height,"--ogx-row-height":`${j}px`,"--ogx-header-height":`${Q}px`,...U?{"--ogx-header-filter-height":`${a}px`}:void 0},"aria-busy":re,children:[ye&&h&&d.jsx(as.Provider,{value:q.toolbarHost,children:d.jsx(fg,{component:ye,toolbarProps:h})}),x.panelProps&&d.jsx(wg,{panelProps:x.panelProps,slot:u?.aiAssistantPanel,slotProps:f?.aiAssistantPanel}),d.jsx(Cg,{isOpen:q.standalonePanelOpen,containerRef:t,panelRef:q.standalonePanelRef,columns:y,columnVisibilityModel:w,disableColumnReorder:g,onClose:q.closeStandalonePanel,onColumnVisibilityChange:p,onColumnMove:m,onColumnOrderReset:C,columnGroupingModel:se}),c&&b&&d.jsx(_g,{ariaLabel:Z,allRenderableRows:_,dataRowCount:v.length,pinnedTopRowCount:$.length,pinnedBottomRowCount:D.length,unpinnedRowCount:G,pagination:k,effectivePaginationModel:A,currentPage:M,pageSizeOptions:N,selectedRowIds:ce,listViewColumn:b,columnsByField:P,rowMetaMap:de,noRowsLabel:W,rowHeight:j,checkboxSelection:ee,paginationMode:V,serverRowCount:T,paginationSlot:u?.pagination,paginationSlotProps:f?.pagination,localeText:ji(Y),onRowClick:we,onRowDoubleClick:me,onSelectionChange:pe,onPaginationModelChange:S,onRowsScrollEnd:I,getRowId:J,multiselectable:te&&!ne,selectable:te,onToggleExpansion:F,loading:re,loadingOverlay:be,noRowsOverlay:he,showPaginationControls:!ge}),!c&&d.jsx(xp,{...X,loadingOverlay:be,noRowsOverlay:he}),z.enabled&&L&&d.jsx(Cp,{stats:z.stats,apiRef:E,slot:u?.cellSelectionStats,slotProps:f?.cellSelectionStats}),ge&&d.jsx(ge,{apiRef:E,aggregationModel:ie,aggregationResult:O?ae:null,rowCount:B&&V!=="server"?v.length:T,pagination:k,paginationModel:A,pageSizeOptions:N,onPaginationModelChange:S,...f?.footer}),!c&&!ge&&k&&d.jsx(yp,{paginationSlot:u?.pagination,paginationSlotProps:f?.pagination,page:M,paginationModel:A,rowCount:T,pageSizeOptions:N,onPaginationModelChange:S,localeText:Y}),d.jsx(vp,{loading:re,error:H,noRowsLabel:W,filteredRowCount:K,dataRowCount:v.length,filterModel:le,cellSelectionAnnouncement:z.announcement,aiAssistantAnnouncement:x.announcement}),ve&&d.jsx(Sp,{overlay:be}),d.jsx(_p,{error:H,onRetry:R})]})})}function Ep(e){const{baseColumns:t,pinnedColumns:n,hasGroupingColumn:o,groupingColDef:r,isTreeData:i,getTreeDataPath:l}=e,c=s.useMemo(()=>o?{...n,left:["__group__",...(n?.left??[]).filter(u=>u!=="__group__")]}:n,[o,n]);return{activeColumns:s.useMemo(()=>o?[{headerName:"Group",width:220,...i&&l?{valueGetter:({row:u})=>{const f=l(u);return f[f.length-1]}}:{},...r,field:"__group__",hideable:!1,sortable:!1,filterable:!1,pinnable:!1,exportable:!1},...t]:t,[r,o,i,l,t]),effectivePinnedColumns:c}}function Mp(e){return e.id}function Ap(e){const t=s.useCallback(r=>e.get(r)??r.id,[e]),n=s.useRef(t);s.useLayoutEffect(()=>{n.current=t});const o=s.useCallback(r=>n.current(r),[]);return{getRowIdOf:t,getRowIdOfInEvents:o}}function Pp(e,t){s.useLayoutEffect(()=>{e&&(e.current=t.current)},[e,t])}function Lp(e){const{hierarchyHandlers:t,pinnedTopRows:n,sortedUnpinnedRows:o,pinnedBottomRows:r,rowMetaMap:i,getRowId:l,hierarchyField:c,dataRows:a}=e,u=t?.getVisibleRows({expandAll:!0,labelField:c});if(!u)return[...n,...o,...r];const f=a?new Set(a):null;return u.filter(h=>!i.get(l(h))?.isGroupRow&&(!f||f.has(h)))}function Np(e,t){if(e===t)return!0;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;const o=e,r=t;return n.every(i=>Object.prototype.hasOwnProperty.call(t,i)&&Object.is(o[i],r[i]))}function Ip(e,t){return e===t?!0:e.length!==t.length?!1:e.every((n,o)=>Np(n,t[o]))}function Fp(e){const[t,n]=s.useState(e),o=Ip(t,e);return o||n(e),o?t:e}function Tp(e){const{rows:t,getRowId:n,rowMetaMap:o,columns:r,aggregationModel:i,aggregationResult:l,isSubtotalHidden:c}=e,a=Object.keys(i).length>0,u=new Map(r.map(y=>[y.field,y])),f=[],h=[],x=y=>{for(;h.length>0&&h[h.length-1].header.depth>=y;){const w=h.pop();a&&!c?.(w.id)&&f.push({type:"group-subtotal",depth:w.header.depth,groupField:w.header.groupField,groupValue:w.header.groupValue,groupLabel:w.header.groupLabel,aggregatedValues:In(w.leaves,i,u,"getGroupedExportRows")})}};for(const y of t){const w=n(y),g=o.get(w);if(!g?.isGroupFooter)if(g?.isGroupRow){const p=g.treeDepth??0;x(p);const m={type:"group-header",depth:p,groupField:g.groupingField,groupValue:g.groupingValue,groupLabel:g.groupLabel};f.push(m),h.push({id:w,header:m,leaves:[]})}else f.push({type:"leaf",depth:g?.treeDepth??h.length,row:y}),h.forEach(p=>p.leaves.push(y))}return x(0),a&&l&&f.push({type:"grand-total",depth:0,aggregatedValues:l}),f}function Op(e){const{apiRef:t}=e,n=s.useRef(e);s.useLayoutEffect(()=>{n.current=e}),s.useLayoutEffect(()=>{const o=()=>n.current;t.current.getAggregationResult=()=>o().hasAggregation?o().aggregationResult:null,t.current.getAggregationModel=()=>o().hasAggregation?o().aggregationModel:null,t.current.getGroupedExportRows=()=>{const{hasAggregation:r,aggregationResult:i,aggregationModel:l,isRowGrouping:c,rowGroupingHandlers:a,rowMetaMap:u,columns:f,getRowId:h,hierarchyField:x}=o();return c?Tp({rows:a.getVisibleRows({expandAll:!0,labelField:x})??[],getRowId:h,rowMetaMap:u,columns:f,aggregationModel:l,aggregationResult:r&&a.rootAggregationPosition!==null?i:null,isSubtotalHidden:y=>a.aggregationPositions.get(y)===null}):null}},[t])}const ks="ogx--range-dragging",ht=32,Dp=40;function Es(e,t){if(!e||e.nodeType!==1)return null;const n=e.closest(".ogx__cell[data-field]");if(!n||n.closest(".ogx__viewport")!==t)return null;const o=n.closest(".ogx__detail-panel");if(o&&t.contains(o))return null;const r=n.closest('[role="row"][data-rowindex]');if(!r)return null;const i=Number(r.getAttribute("data-rowindex")),l=n.dataset.field;return!Number.isInteger(i)||!l?null:{rowIndex:i,field:l,element:n}}function vr(e){const t=e.getSelection();t&&t.rangeCount>0&&t.removeAllRanges()}const Ms=(e,t,n)=>Math.min(Math.max(e,t),n),Qn=e=>Math.min(Dp,Math.max(2,Math.round(e/2)));function $p(e){const{latestRef:t,focusRef:n,setRange:o,currentModel:r}=e,i=s.useRef(null),l=s.useRef(!1);s.useEffect(()=>()=>i.current?.stop(),[]);const c=s.useCallback((g,p,m)=>{const C=t.current.context;if(!C)return null;const b=g.ownerDocument;if(typeof b.elementFromPoint!="function")return null;const _=Es(b.elementFromPoint(p,m),g);if(!_)return null;const v=C.rowIds[_.rowIndex];if(v===void 0)return null;const k=je(_.field)?_.field:C.fields[0];return k===void 0?null:{id:v,field:k}},[t]),a=s.useCallback((g,p)=>{const{context:m,layout:C,pinnedTopRowCount:b}=t.current,_=C.cumulativeHeights;if(!m||_.length===0||g<0)return null;let v=0,k=_.length-1;for(;v<k;){const M=v+k>>1;_[M]>g?k=M:v=M+1}const A=m.rowIds[v+b];return A===void 0?null:{id:A,field:p}},[t]),u=s.useRef(()=>{}),f=s.useCallback(g=>{const p=i.current,m=t.current.viewportRef.current;if(!p||!m)return;p.frame=0;const{layout:C}=t.current,b=m.getBoundingClientRect(),_=m.clientWidth,v=m.clientHeight,k=m.querySelector(":scope > .ogx__content > .ogx__sticky-top"),A=m.querySelector(":scope > .ogx__content > .ogx__sticky-bottom"),M=k?.querySelector(":scope > .ogx__header-wrap"),N=k?k.getBoundingClientRect().bottom:b.top,P=Math.min(b.top+v,A?A.getBoundingClientRect().top:b.top+v),T=M?M.getBoundingClientRect().bottom:N;p.rtl===void 0&&(p.rtl=Je(m));const S=p.rtl,I=S?b.right-_:b.left,F=C.pinnedSystemColumnsWidth+C.leftWidth,L=I+(S?C.rightWidth:F),E=I+_-(S?F:C.rightWidth),O=Ms(p.x,I+1,I+_-2);let B=p.y;(B<b.top||B>b.top+v||B<T)&&(B=Ms(B,N+1,Math.max(N+1,P-2)));const H=typeof m.ownerDocument.elementFromPoint=="function",R=c(m,O,B)??(H&&p.moved?a(B-b.top-(k?k.getBoundingClientRect().height:0)+m.scrollTop,p.head.field):null);if(R&&!ut(R,p.head)&&(p.head=R,!p.moved&&!ut(R,p.anchor)&&(p.moved=!0,t.current.containerRef.current?.classList.add(ks),vr(m.ownerDocument)),p.onTrack||o(p.anchor,R,"pointer")),p.onTrack&&p.onTrack(p.head,p.x,p.y),!g)return;const X=p.y<N||p.y>P||p.x<I||p.x>I+_;if(!p.moved&&!X)return;let j=0,Q=0;p.y<N+ht?j=-Qn(N+ht-p.y):p.y>P-ht&&(j=Qn(p.y-(P-ht))),p.x<L+ht?Q=-Qn(L+ht-p.x):p.x>E-ht&&(Q=Qn(p.x-(E-ht)));const U=j<0&&m.scrollTop>0||j>0&&m.scrollTop+v<m.scrollHeight-1,re=m.scrollWidth-_,q=S?-re:0,se=Q<0&&m.scrollLeft>q||Q>0&&m.scrollLeft<q+re-1;!U&&!se||(U&&(m.scrollTop+=j),se&&(m.scrollLeft+=Q),p.frame=requestAnimationFrame(()=>u.current(!0)))},[t,c,a,o]);s.useLayoutEffect(()=>{u.current=f},[f]);const h=s.useCallback((g,p,m,C,b,_)=>{i.current?.stop();const v=_?"pointermove":"mousemove",k=_?"pointerup":"mouseup",A=E=>!_||E.pointerId===_.pointerId,M=E=>{const O=i.current;if(!(!O||!A(E))){if(E.buttons===0){O.stop();return}O.x=E.clientX,O.y=E.clientY,O.moved&&(E.preventDefault(),vr(b)),O.frame||(O.frame=requestAnimationFrame(()=>f(!0)))}},N=E=>{const O=i.current;if(!O||!A(E))return;O.x=E.clientX,O.y=E.clientY,f(!1);const B=O.moved;O.stop(!1,E.altKey),B&&vr(b),B&&(l.current=!0,setTimeout(()=>{l.current=!1},0))},P=E=>{A(E)&&i.current?.stop()},T=E=>{E.key!=="Escape"||!i.current||(E.preventDefault(),E.stopPropagation(),i.current.stop())},S=b.defaultView,I=()=>i.current?.stop();let F=!1;const L={anchor:g,head:p,x:m,y:C,frame:0,moved:!1,onTrack:_?.onTrack,stop:(E=!0,O=!1)=>{L.frame&&cancelAnimationFrame(L.frame),L.frame=0,b.removeEventListener(v,M,!0),b.removeEventListener(k,N,!0),_&&(b.removeEventListener("pointercancel",P,!0),b.removeEventListener("keydown",T,!0)),S?.removeEventListener("blur",I),t.current.containerRef.current?.classList.remove(ks),i.current===L&&(i.current=null),F||(F=!0,_&&_.onEnd({cancelled:E,altKey:O}))}};i.current=L,b.addEventListener(v,M,!0),b.addEventListener(k,N,!0),_&&(b.addEventListener("pointercancel",P,!0),b.addEventListener("keydown",T,!0)),S?.addEventListener("blur",I)},[t,f]),x=s.useCallback(g=>{const p=t.current.viewportRef.current;if(!p||!t.current.enabled)return;const{start:m,x:C,y:b,pointerId:_,onTrack:v,onEnd:k}=g;h(m,m,C,b,p.ownerDocument,{pointerId:_,onTrack:v,onEnd:k})},[t,h]),y=s.useCallback(g=>{if(g.button!==0||g.defaultPrevented)return;const{context:p}=t.current;if(!p)return;const m=g.currentTarget,C=Es(g.target,m);if(!C||!je(C.field)||g.target.closest?.(".ogx__cell-fill-handle")||C.element.classList.contains("ogx__cell--editing")||Ni(g.target))return;const b=p.rowIds[C.rowIndex];if(b===void 0)return;const _={id:b,field:C.field};let v=_;if(g.shiftKey){const k=r()[0],A=n.current;k&&p.rowIndexById.has(k.anchor.id)&&p.colIndexByField.has(k.anchor.field)?v=k.anchor:A&&A.id!==null&&je(A.field)&&(v={id:A.id,field:A.field}),g.preventDefault(),l.current=!0;const M=m.ownerDocument;m.contains(M.activeElement)||m.focus({preventScroll:!0})}if(o(v,_,"pointer"),h(v,_,g.clientX,g.clientY,m.ownerDocument),g.shiftKey){const k=i.current;k&&!ut(v,_)&&(k.moved=!0)}},[n,t,r,o,h]),w=s.useCallback(g=>{l.current&&(l.current=!1,g.stopPropagation(),g.preventDefault())},[]);return{startTrackedDrag:x,handleMouseDown:y,handleClickCapture:w}}const Gp=300;function Hp(e){process.env.NODE_ENV!=="production"&&console.warn(`[OpenGridX] Copying ${e} cells. For ranges this large, exportToCsv or exportToExcel is the better tool.`)}function Bp(e){const{enabled:t,model:n,allRenderableRows:o,getRowId:r,navigationColumns:i,columnIndexMap:l,spanning:c,rowMetaMap:a,localeText:u,showStats:f}=e,h=t&&n.length>0?n[0]:null,x=s.useMemo(()=>t?i.filter($=>je($.field)):[],[t,i]),y=s.useMemo(()=>{if(!c.hasColSpan&&!c.hasRowSpan)return;const{colspanMap:$,rowSpanningCaches:D,getSpanOrigin:G}=c;return{getSpanOrigin:G,getColSpan:(W,ee)=>{const V=$.get(W)?.[ee];return V&&!V.spannedByColSpan?V.cellProps.colSpan:1},getRowSpan:(W,ee)=>D.spannedCells[W]?.[ee]??1}},[c]),w=s.useMemo(()=>{if(!t)return null;const{rowIds:$,rowIndexById:D}=er(o,r,"renderable"),G=x.map(W=>W.field);return{rowIds:$,rowIndexById:D,fields:G,colIndexByField:new Map(G.map((W,ee)=>[W,ee])),spans:y}},[t,o,r,x,y]),g=s.useMemo(()=>h&&w?Bn(h,w):null,[h,w]),p=g!==null&&Et(g)>1,m=s.useMemo(()=>{if(!g||!p||!w)return null;const $=l.get(w.fields[g.left]),D=l.get(w.fields[g.right]);return $===void 0||D===void 0?null:{top:g.top,bottom:g.bottom,left:$,right:D}},[g,p,w,l]),C=s.useCallback($=>Ke($,a),[a]),b=s.useCallback(($,D,G)=>{if(w)for(let W=$.top;W<=$.bottom;W++){const ee=o[W],V=w.rowIds[W];if(!(!ee||C(V))){D(ee,V);for(let Y=$.left;Y<=$.right;Y++){const J=x[Y],te=y?.getSpanOrigin(V,J.field);G(ee,V,J,te!=null&&(te.rowId!==V||te.field!==J.field))}}}},[w,o,x,y,C]),_={...e,range:h,resolved:g,context:w,rangeColumns:x,forEachCell:b},v=s.useRef(_);s.useLayoutEffect(()=>{v.current=_});const k=s.useRef(null),A=s.useCallback($=>{k.current=$},[]),M=s.useCallback(()=>{const{getPendingModel:$,model:D}=v.current;return $()??D},[]),N=s.useCallback(()=>{const{context:$,range:D,resolved:G,enabled:W}=v.current,ee=W?M()[0]??null:null;return!ee||!$?{range:null,resolved:null}:ee===D?{range:ee,resolved:G}:{range:ee,resolved:Bn(ee,$)}},[M]),P=s.useCallback(($,D)=>{if(!v.current.enabled)return;const G=$.length>1?$.slice(0,1):$;Cc(G,M())||v.current.onModelChange(G,D)},[M]),T=s.useCallback(($,D,G)=>{P([{anchor:$,head:D}],G)},[P]),S=s.useCallback(($,D)=>{const{viewportRef:G,layout:W,rowHeight:ee,pinnedTopRowCount:V}=v.current,Y=G.current;Y&&(Wn(Y,$-V,W.cumulativeHeights,W.pinnedBottomHeight,ee),Ho(Y,W.unpinnedColsWithWidth.findIndex(J=>J.field===D),W))},[]),I=s.useCallback(($,D,G,W)=>{const{context:ee}=v.current,{range:V,resolved:Y}=N();if(!ee||W.id===null||!je(W.field))return!1;const J=ee.rowIndexById.get(W.id),te=ee.colIndexByField.get(W.field);if(J===void 0||te===void 0)return!1;const ne=V&&Y&&ut(V.anchor,{id:W.id,field:W.field})?{range:V,resolved:Y}:null,z=ne?ne.range.anchor:{id:W.id,field:W.field},ie=ne?.resolved??Bn({anchor:z,head:z},ee);if(!ie)return!1;const ae=vc(ie,$,D,G,ee.rowIds.length-1,ee.fields.length-1);if(!ae)return!0;const le={id:ee.rowIds[ae.row],field:ee.fields[ae.col]};return T(z,le,"keyboard"),S(ae.row,le.field),!0},[N,T,S]),F=s.useCallback(()=>{const{range:$,resolved:D}=N();return!$||!D||Et(D)<=1?!1:(T($.anchor,$.anchor,"keyboard"),!0)},[N,T]),L=s.useCallback(()=>{const{context:$}=v.current;return!$||$.rowIds.length===0||$.fields.length===0?!1:(T({id:$.rowIds[0],field:$.fields[0]},{id:$.rowIds[$.rowIds.length-1],field:$.fields[$.fields.length-1]},"selectAll"),!0)},[T]),E=s.useCallback(()=>{const{context:$}=v.current,{range:D,resolved:G}=N();if(!$)return null;if(G)return G;if(D)return null;const W=k.current;return!W||W.id===null||!je(W.field)?null:Bn({anchor:{id:W.id,field:W.field},head:{id:W.id,field:W.field}},$)},[N]),O=s.useCallback(()=>{const $=E();if(!$)return null;const{rangeColumns:D,forEachCell:G}=v.current,W=Et($);W>kc&&Hp(W);const ee=[];if(G($,ne=>{ee.push(ne)},()=>{}),ee.length===0)return null;const V=D.slice($.left,$.right+1),Y=v.current.context?.spans,J=v.current.getRowId;return Fu(ee,V,Y?(ne,z)=>{const ie=J(ne),ae=Y.getSpanOrigin(ie,z.field);return ae!==null&&(ae.rowId!==ie||ae.field!==z.field)}:void 0)},[E]),B=s.useCallback(()=>{const{forEachCell:$}=v.current,{resolved:D}=N();if(!D)return[];const G=[];return $(D,()=>{},(W,ee,V,Y)=>{Y||G.push({id:ee,field:V.field,value:Se(W,V.field,V)})}),G},[N]),{startTrackedDrag:H,handleMouseDown:K,handleClickCapture:R}=$p({latestRef:v,focusRef:k,setRange:T,currentModel:M}),X=g?g.right-g.left+1:0,j=g?g.bottom-g.top+1:0,Q=u?.cellSelectionAnnouncement??Vi,U=p?Q(j*X,j,X):"",[re,q]=s.useState("");s.useEffect(()=>{if(!t)return;const $=setTimeout(()=>q(U),Gp);return()=>clearTimeout($)},[t,U]);const se=s.useMemo(()=>{if(!f||!g||!p)return null;const $=[];b(g,()=>{},(G,W,ee,V)=>{V||$.push(Se(G,ee.field,ee))});const D=$.filter(G=>typeof G=="number"&&!Number.isNaN(G));return{cellCount:Et(g),rowCount:g.bottom-g.top+1,columnCount:g.right-g.left+1,count:dt.count($),numericCount:D.length,sum:D.length?dt.sum(D):null,average:D.length?dt.avg(D):null}},[f,g,p,b]),Z=s.useMemo(()=>t?{extendSelection:I,collapseSelection:F,selectAllCells:L}:void 0,[t,I,F,L]);return{enabled:t,range:h,resolved:g,displayRange:m,hasRowSpan:c.hasRowSpan,handleMouseDown:t?K:void 0,handleClickCapture:t?R:void 0,extendSelection:I,collapseSelection:F,selectAllCells:L,keyboard:Z,getCopyText:O,getSelectedCells:B,announcement:t?re:"",stats:se,reportFocus:A,setModel:P,getCurrentRange:N,startTrackedDrag:H}}function Wp(e){return s.useCallback(t=>{e.current?.classList.toggle("ogx--kb",t)},[e])}function Vp(e){const{ensureGridFocus:t,setKeyboardMode:n,setFocusedCell:o,getRowId:r,onCellClick:i}=e,l=s.useCallback(a=>{t(),n(!1),o({id:r(a.row),field:a.field,rowIndex:a.rowIndex}),i?.(a)},[i,n,o,t,r]),c=s.useCallback(a=>{t(),o({id:null,field:a}),n(!1)},[t,o,n]);return{handleCellClick:l,handleHeaderClick:c}}function zp(){const[e,t]=s.useState(!1),[n,o]=s.useState(!1),r=s.useRef(null),i=s.useRef(0),[l,c]=s.useState(0),[a,u]=s.useState(!1),f=s.useMemo(()=>({registerColumnsPanel:()=>(i.current+=1,()=>{i.current-=1}),registerFiltersPanel:()=>(c(p=>p+1),()=>c(p=>p-1))}),[]),h=s.useCallback(()=>u(!0),[]),x=s.useCallback(()=>u(!1),[]),y=s.useCallback(()=>{i.current>0?t(!0):o(!0)},[]),w=s.useCallback(()=>t(!1),[]),g=s.useCallback(()=>o(!1),[]);return s.useEffect(()=>{if(!n)return;function p(C){r.current&&!r.current.contains(C.target)&&o(!1)}function m(C){C.key==="Escape"&&o(!1)}return document.addEventListener("mousedown",p),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",m)}},[n]),{toolbarHost:f,toolbarPanelRequested:e,closeToolbarPanel:w,standalonePanelOpen:n,closeStandalonePanel:g,standalonePanelRef:r,openColumnsPanel:y,toolbarFiltersRequested:a,closeToolbarFiltersPanel:x,openFiltersPanel:l>0?h:void 0}}const Rp=Symbol.for("opengridx.ai.validated");function Up(e){return typeof e=="object"&&e!==null&&e[Rp]===!0}const Kp=[],eo=[],jp="The reply was not validated";function qp(){return typeof window<"u"&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window)}function Xp(e){return typeof e=="object"&&e!==null&&e.name==="AbortError"}const Yp={kind:"none"},Jp={kind:"thinking"},Sr={kind:"stopped"},Zp={kind:"undone"},Qp={kind:"removed"},eh={kind:"notValidated"};function th(e,t){switch(e.kind){case"none":return"";case"thinking":return t.aiAssistantThinking;case"stopped":return t.aiAssistantStopped;case"undone":return t.aiAssistantUndone;case"removed":return t.aiAssistantChangeRemoved;case"applied":return t.aiAssistantApplied(e.count,e.ignored);case"notValidated":return t.aiAssistantNotValidated;case"failed":{const{error:n}=e;return t.aiAssistantFailed(n instanceof Error&&n.message?n.message:t.aiAssistantUnknownError)}}}function As(e,t,n){if(!e)return;const o=Be(()=>e(t));!o.ok&&process.env.NODE_ENV!=="production"&&console.warn(`[OpenGridX] ${n} threw.`,o.error)}function nh(e){const{apiRef:t,options:n,columns:o,localeText:r}=e,i=s.useMemo(()=>Zo(r),[r]),l=!!n,[c,a]=s.useState(!1),[u,f]=s.useState("idle"),[h,x]=s.useState(Yp),y=th(h,i),[w,g]=s.useState(null),[p,m]=s.useState(eo),[C,b]=s.useState(null),[_,v]=s.useState([]),k=s.useRef(null),A=s.useRef(null),M=s.useRef({params:e,applied:C,history:_,open:c});s.useLayoutEffect(()=>{M.current={params:e,applied:C,history:_,open:c}});const N=s.useMemo(()=>{const Q=new Map(o.map(U=>[U.field,U.headerName||U.field]));return U=>Q.get(U)??U},[o]),P=s.useMemo(()=>hd(i),[i]),T=s.useMemo(()=>C?sl(C.state,N,P):[],[C,N,P]),S=s.useCallback(()=>{const Q=k.current;k.current=null,Q&&Q.abort()},[]);s.useEffect(()=>S,[S]);const I=s.useCallback(Q=>{if(!M.current.params.options)return;const U=typeof document>"u"?null:document.activeElement;A.current=Q??(U instanceof HTMLElement?U:null),a(!0)},[]),F=s.useCallback(()=>{k.current&&(S(),f("stopped"),x(Sr)),a(!1);const Q=A.current;A.current=null,Q&&Q.isConnected&&Q.focus()},[S]),L=s.useCallback(Q=>{M.current.open?F():I(Q)},[I,F]),E=s.useCallback((Q,U)=>{f("error"),x(Q),g(null),m(eo),As(M.current.params.onError,U,"onAiAssistantError")},[]),O=s.useCallback((Q,U)=>{const{params:re}=M.current;if(!(typeof U=="object"&&U!==null)||!Up(U.state)){process.env.NODE_ENV!=="production"&&console.warn("[OpenGridX] aiAssistant: the onPrompt result was not applied because its state was not validated. Return the result of createGridAiPromptHandler, or pass the model reply through validateGridAiState (from @opencorestack/opengridx/ai) and return its state."),E(eh,new Error(jp));return}const se=ld(U.state,re.options?.parts??Kn),Z=[...Array.isArray(U.errors)?U.errors:[],...se.errors],$=cd(se.state,Z),D=t.current,G=dd($,D.getGridAiState());Yo(D,rl($,G)),b({state:$,previous:G}),m(Z),g(typeof U.message=="string"&&U.message?U.message:null),v(W=>[...W,{prompt:Q,applied:$}]),f("applied"),x({kind:"applied",count:sl($,W=>W).length,ignored:Z.length}),As(re.onApply,U,"onAiAssistantApply")},[t,E]),B=s.useCallback(Q=>{const U=Q.trim(),{params:re,history:q}=M.current,se=re.options?.onPrompt;if(!U||!se)return;S();const Z=new AbortController;k.current=Z,f("running"),x(Jp),g(null),m(eo);const $={currentState:t.current.getGridAiState(),history:q,signal:Z.signal},D=Be(()=>se(U,$));(D.ok?Promise.resolve(D.value):Promise.reject(D.error)).then(W=>{k.current===Z&&(k.current=null,O(U,W))},W=>{if(k.current===Z){if(k.current=null,Z.signal.aborted||Xp(W)){f("stopped"),x(Sr);return}E({kind:"failed",error:W},W)}})},[t,S,O,E]),H=s.useCallback(()=>{k.current&&(S(),f("stopped"),x(Sr))},[S]),K=s.useCallback(()=>{const Q=M.current.applied;Q&&(Yo(t.current,Q.previous),b(null),m(eo),g(null),f("idle"),x(Zp))},[t]),R=s.useCallback(Q=>{const U=M.current.applied;if(!U)return;const re=fd(U.state,Q);Yo(t.current,rl(re,U.previous)),b({state:re,previous:U.previous}),x(Qp)},[t]);s.useLayoutEffect(()=>{const Q=t.current;Q.openAiAssistant=()=>I(),Q.closeAiAssistant=()=>{M.current.open&&F()}},[t,I,F]);const X=l&&c,j=s.useMemo(()=>!X||!n?null:{status:u,statusText:y,message:w,errors:p,chips:T,history:_,suggestions:n.suggestions??Kp,placeholder:n.placeholder??i.aiAssistantPlaceholder,voiceAvailable:n.voice!==!1&&qp(),canUndo:C!==null,submit:B,stop:H,undo:K,removeChip:R,close:F},[X,n,u,y,w,p,T,_,C,B,H,K,R,F,i]);return{enabled:l,open:X,openPanel:I,togglePanel:L,closePanel:F,panelProps:j,announcement:l?y:""}}function oh(e){const{toolbar:t,toolbarSlotProps:n,apiRef:o,orderedColumns:r,baseColumns:i,aggregationModel:l,onAggregationModelChange:c,pivotMode:a,pivotModelProp:u,onPivotModelChangeProp:f,pivotModel:h,onPivotModelChange:x,filterModel:y,onFilterModelChange:w,columnVisibilityModel:g,onColumnVisibilityModelChange:p,disableColumnReorder:m,columnGroupingModel:C,moveColumn:b,resetColumnOrder:_,forceColumnsOpen:v,onColumnsPanelClose:k,aiAssistantEnabled:A=!1,aiAssistantOpen:M=!1,onAiAssistantToggle:N,aiAssistantLabel:P,forceFiltersOpen:T,onFiltersPanelClose:S}=e;return s.useMemo(()=>{if(!t)return null;const I=m?void 0:(F,L)=>{or(C,F,L)&&b(F,L)};return{apiRef:o,columns:r,baseColumns:i&&i,aggregationModel:l,onAggregationModelChange:c,...a||u||f?{pivotModel:h,onPivotModelChange:x}:{},filterModel:y,onFilterModelChange:w,columnVisibilityModel:g,onColumnVisibilityModelChange:p,onColumnReorder:I,onColumnOrderReset:m?void 0:_,forceColumnsOpen:v,onColumnsPanelClose:k,...A&&N?{onAiAssistantToggle:N,aiAssistantOpen:M,...P?{aiAssistantLabel:P}:{}}:{},forceFiltersOpen:T,onFiltersPanelClose:S,...n}},[t,m,b,_,r,o,i,l,c,a,u,f,h,x,y,w,g,p,v,k,n,C,A,M,N,P,T,S])}function rh(e){const{apiRef:t,containerRef:n,aiAssistant:o,toolbar:r,localeText:i}=e,l=zp();Fd(n);const c=nh({apiRef:t,localeText:i,...o}),a=oh({...r,apiRef:t,forceColumnsOpen:l.toolbarPanelRequested,onColumnsPanelClose:l.closeToolbarPanel,aiAssistantEnabled:c.enabled,aiAssistantOpen:c.open,onAiAssistantToggle:c.togglePanel,aiAssistantLabel:i?.aiAssistantButton,forceFiltersOpen:l.toolbarFiltersRequested,onFiltersPanelClose:l.closeToolbarFiltersPanel});return{columnsPanel:l,aiAssistantPanel:c,toolbarProps:a}}function ih(e){const{rows:t,columns:n,getRowId:o,rowHeight:r,headerHeight:i,wrapHeaderText:l=!1,headerFilters:c=!1,headerFilterHeight:a=Zc,autoHeight:u=!1,density:f,height:h,className:x="",style:y,ariaLabel:w,loading:g=!1,checkboxSelection:p=!1,disableRowSelectionOnClick:m=!1,disableMultipleRowSelection:C=!1,disableClipboardCopy:b=!1,cellSelection:_=!1,cellSelectionModel:v,onCellSelectionModelChange:k,showCellSelectionStats:A=!1,rowSelectionModel:M,onRowSelectionModelChange:N,onRowClick:P,onRowDoubleClick:T,onCellClick:S,filterModel:I,onFilterModelChange:F,sortModel:L,onSortModelChange:E,pagination:O=!1,paginationModel:B,onPaginationModelChange:H,pageSizeOptions:K=[10,25,50,100],pinnedColumns:R,onPinnedColumnsChange:X,pinnedRows:j,getDetailPanelContent:Q,getDetailPanelHeight:U,detailPanelExpandedRowIds:re,onDetailPanelExpandedRowIdsChange:q,pinCheckboxColumn:se=!0,pinExpandColumn:Z=!0,disableColumnReorder:$=!1,columnOrder:D,onColumnOrderChange:G,onColumnOrderModelChange:W,rowReordering:ee=!1,onRowOrderChange:V,treeData:Y=!1,getTreeDataPath:J,defaultGroupingExpansionDepth:te,groupingColDef:ne,rowGroupingModel:z,onRowGroupingModelChange:ie,aggregationModel:ae,onAggregationModelChange:le,getAggregationPosition:ce,isCellEditable:de,processRowUpdate:we,onProcessRowUpdateError:me,dataSource:pe,multiSort:oe=!1,sortingMode:ue="client",filterMode:be="client",paginationMode:he="client",rowCount:ge,slots:ve,slotProps:ye,pivotMode:fe=!1,pivotModel:Ee,onPivotModelChange:Le,onRowsScrollEnd:Ne,initialState:Me,onStateChange:qe,columnVisibilityModel:Fe,onColumnVisibilityModelChange:Xe,listView:We=!1,listViewColumn:xe,columnGroupingModel:Ie,noRowsLabel:Te="No Data",localeText:Re,apiRef:mt,overscanRowCount:Pt=3,aiAssistant:Lt,onAiAssistantApply:He,onAiAssistantError:ro}=e,Cn=Fp(n),Cm=Re?.noRowsLabel??Te,Nt=Hc({initialState:Me,sortModel:L,onSortModelChange:E,filterModel:I,onFilterModelChange:F,aggregationModel:ae,onAggregationModelChange:le,rowGroupingModel:z,onRowGroupingModelChange:ie,columnVisibilityModel:Fe,onColumnVisibilityModelChange:Xe,pinnedColumns:R,onPinnedColumnsChange:X,pivotModel:Ee,onPivotModelChange:Le,paginationModel:B,onPaginationModelChange:H,pageSizeOptions:K,rowSelectionModel:M,onRowSelectionModelChange:N,density:f,cellSelectionModel:v,onCellSelectionModelChange:k}),{sortModel:wt,handleSortModelChange:ym,filterModel:It,handleFilterModelChange:Qs,aggregationModel:lt,handleAggregationModelChange:vm,columnVisibilityModel:Ft,handleColumnVisibilityModelChange:Mr,pinnedColumns:Ar,handlePinnedColumnsChange:Sm,currentPivotModel:ea,handlePivotModelChange:_m,effectivePaginationModel:st,handlePaginationModelChange:Pr,selectedRowIds:km,handleRowSelectionModelChange:Em,density:ta,rowGroupingModel:na}=Nt,yn=ag({rows:t,columns:Cn,pivotMode:fe,pivotModel:ea,filterModel:It,sortModel:wt,hasDataSource:!!pe,hierarchyRequested:Y||na.length>0}),bt=yn.isActive,Lr=c&&!bt,{rowReordering:vn,hierarchyRowGroupingModel:Mm,isTreeDataRequested:Am,isTreeData:io,isRowGrouping:Qt,isHierarchyEnabled:lo,hasGroupingColumn:Pm,pagination:xt,listView:Nr}=Nc({rowGroupingModel:na,treeData:Y,hasTreeDataPath:!!J,isPivotActive:bt,rowReordering:ee,hasGroupingColDef:!!ne,pagination:O,paginationMode:he,listView:We,hasListViewColumn:!!xe}),{rowHeight:Tt,headerHeight:oa}=Rc({rowHeight:r,headerHeight:i,density:ta}),Lm=yn.rows,Nm=yn.columns,{activeColumns:Ct,effectivePinnedColumns:Ir}=Ep({baseColumns:Nm,pinnedColumns:Ar,hasGroupingColumn:Pm,groupingColDef:ne,isTreeData:io,getTreeDataPath:J}),Fr=zd(Ct,Ft),[Im,Fm]=ig(lt),Ot=s.useRef(null),Sn=s.useRef(null),ra=!bt&&o||Mp,Tr=Wp(Ot),so=qd({rows:Lm,getRowId:ra,columns:Ct,rowHeight:Tt,headerHeight:oa,columnVisibilityModel:Ft,initialState:e.initialState,syncRows:!pe}),{state:Oe,apiRef:_n,setRows:Tm,replaceRows:Om,setColumns:Dm,setDimensions:$m,setDataSourceLoading:Gm,setDataSourceError:Hm,setRowCount:Bm}=so,{getRowIdOf:De,getRowIdOfInEvents:Wm}=Ap(Oe.rows.idByRow);Pp(mt,_n);const Vm=Oe.dataSource.loading,Or=g||Vm,ao=Oe.rows.rows,{treeDataHandlers:co,rowGroupingHandlers:Dr,activeHierarchyHandlers:en,rowMetaMap:Ye}=fu({rows:ao,getRowId:De,getTreeDataPath:J,isTreeDataRequested:Am,isTreeData:io,columns:Ct,rowGroupingModel:Mm,isRowGrouping:Qt,aggregationModel:lt,defaultGroupingExpansionDepth:te,filterModel:It,sortModel:wt,getAggregationPosition:ce,columnLookup:Fr,filterMode:be,sortingMode:ue}),{editCommitChannel:zm,batchEdit:Rm,editingHandlers:$r}=Kf({rowsLookup:so.rowsLookup,rows:ao,getRowId:De,columns:Ct,processRowUpdate:we,onProcessRowUpdateError:me,replaceRows:Om}),Gr=Td({selectedRowIds:km,rowsLookup:Oe.rows.idRowsLookup,rowMetaMap:Ye,enabled:!pe&&!bt&&he==="client"&&be==="client",onSelectionModelChange:Em}),ia=ng({dataSource:pe,sortModel:wt,filterModel:It,paginationModel:st,paginationMode:he,sortingMode:ue,filterMode:be,aggregationModel:lt,rowGroupingActive:Qt,getRowId:ra,setRows:Tm,setRowCount:Bm,setDataSourceLoading:Gm,setDataSourceError:Hm,onAggregationResults:Fm,onPaginationModelChange:Pr});rg({enabled:io&&!!pe,treeNodes:co.treeNodes,isGroupExpanded:co.isGroupExpanded,getNodePath:co.getNodePath,toggleExpansion:co.toggleExpansion,fetchChildren:ia.fetchChildren});const{hasDetailPanel:kn,expandedRowIds:Hr,handleDetailPanelToggle:la,detailPanelHeights:Um,reportDetailPanelHeight:Km}=_d({hasDetailPanel:!!Q,controlledExpandedRowIds:re,onDetailPanelExpandedRowIdsChange:q,rowMetaMap:Ye}),{effectiveColumns:sa,hierarchyField:Br,orderedColumns:Wr,visibleOrderedColumns:aa,renderOrderedColumns:jm,navigationColumns:uo,columnIndexMap:Vr,columnWidths:zr,effectiveColumnOrder:qm,columnReorderHandlers:Xm,moveColumn:ca,resetColumnOrder:da,handleColumnResize:ua}=vd({activeColumns:Ct,isHierarchyEnabled:lo,isRowGrouping:Qt,isTreeData:io,activeHierarchyHandlers:en,columnVisibilityModel:Ft,columnOrder:D,onColumnOrderChange:G,onColumnOrderModelChange:W,disableColumnReorder:$,pivotMode:bt,checkboxSelection:p,hasDetailPanel:kn,rowReordering:vn,initialState:Me,setColumns:Dm,pinnedColumns:Ir,getRowId:Wm,aggregationModel:lt,groupingRows:Qt?Dr.groupingRows:void 0});Md({onStateChange:qe,sortModel:wt,filterModel:It,effectivePaginationModel:st,columnWidths:zr,effectiveColumnOrder:qm,columnVisibilityModel:Ft,pinnedColumns:Ar,density:ta});const Rr=Kc({effectiveRows:ao,activeHierarchyHandlers:en,filterMode:be,filterModel:yn.pipelineFilterModel,sortModel:yn.pipelineSortModel,sortingMode:ue,pagination:xt,paginationMode:he,effectivePaginationModel:st,pinnedRows:j,getRowId:De,columnLookup:Fr,hierarchyField:Br}),{filteredRows:fa,dataRows:fo,pinnedTopRows:Ue,pinnedBottomRows:at,sortedUnpinnedRows:yt,paginatedUnpinnedRows:go,allRenderableRows:En}=Rr,Ur=xt?go:yt;Rd({paginationModel:st,currentPage:Rr.currentPage,enabled:xt&&!Or&&yt.length>0,onPaginationModelChange:Pr});const ga=Uc({paginationMode:he,hasDataSource:!!pe,dataSourceRowCount:Oe.pagination.rowCount,rowCountProp:ge,clientRowCount:yt.length}),{rowSelection:pa,handleRowClick:ha,handleSelectionChange:ma}=Vd({controlledState:Nt,interactions:{dataRows:fo,getRowId:De,isPivotActive:bt,disableRowSelectionOnClick:m,isHierarchyEnabled:lo,rowMetaMap:Ye,activeHierarchyHandlers:en,onRowClick:P},api:{apiRef:so.apiRef,multiSort:oe,selectedRowIds:Gr,disableMultipleRowSelection:C,isSyntheticRowId:jr=>Ke(jr,Ye),getVisibleRows:()=>[...Ue,...Ur,...at],getAllFilteredRows:()=>Lp({hierarchyHandlers:en,pinnedTopRows:Ue,sortedUnpinnedRows:yt,pinnedBottomRows:at,rowMetaMap:Ye,getRowId:De,hierarchyField:Br,dataRows:fo}),visibleColumns:jm}}),Ym=Xd({rows:ao,indexById:Oe.rows.indexById,onRowOrderChange:V,rowReordering:vn}),{aggregationResult:wa,isLoading:Jm}=ls({rows:fo,columns:Ct,aggregationModel:bt?Wa:lt,isServerSide:Ql({dataSource:pe,paginationMode:he,sortingMode:ue,filterMode:be}),dataSource:pe,filterModel:It,sortModel:wt,serverAggregationResults:Im}),Kr=Object.keys(lt).length>0&&!bt;Op({apiRef:_n,hasAggregation:Kr,aggregationResult:wa,aggregationModel:lt,isRowGrouping:Qt,rowGroupingHandlers:Dr,rowMetaMap:Ye,columns:Ct,getRowId:De,hierarchyField:Br});const $e=Ba({rowHeight:Tt,pagination:xt,paginatedUnpinnedRows:go,sortedUnpinnedRows:yt,expandedRowIds:Hr,getDetailPanelHeight:U,detailPanelHeights:Um,pinnedTopRowsLength:Ue.length,pinnedBottomRowsLength:at.length,pinnedTopRows:Ue,pinnedBottomRows:at,visibleOrderedColumns:aa,pinnedColumns:Ir,columnWidths:zr,viewportWidth:Oe.dimensions.viewportWidth||1e3,checkboxSelection:p,hasDetailPanel:kn,rowReordering:vn,pinCheckboxColumn:se,pinExpandColumn:Z,paginationMode:he,isLoading:Oe.dataSource.loading,pageSize:st.pageSize,getRowId:De}),Mn=Yf({pinnedTopRows:Ue,centerRows:Ur,pinnedBottomRows:at,columns:aa,leftPinnedColumns:$e.leftPinnedCols,unpinnedColumns:$e.unpinnedColsWithWidth,rightPinnedColumns:$e.rightPinnedCols,expandedRowIds:kn?Hr:void 0,rowMetaMap:Ye,getRowId:De}),ba=s.useMemo(()=>[...$e.leftPinnedCols,...$e.unpinnedColsWithWidth,...$e.rightPinnedCols],[$e.leftPinnedCols,$e.unpinnedColsWithWidth,$e.rightPinnedCols]),An=Bp({enabled:_&&!Nr,model:Nt.cellSelectionModel,onModelChange:Nt.handleCellSelectionModelChange,getPendingModel:Nt.getPendingCellSelectionModel,allRenderableRows:En,getRowId:De,navigationColumns:uo,columnIndexMap:Vr,spanning:Mn,rowMetaMap:Ye,layout:$e,rowHeight:Tt,pinnedTopRowCount:Ue.length,viewportRef:Sn,containerRef:Ot,localeText:Re,showStats:A}),Zm=zf({apiRef:_n,containerRef:Ot,viewportRef:Sn,copyColumns:ba,getRowId:De,disableClipboardCopy:b,getCellRangeCopyText:An.enabled?An.getCopyText:void 0,layout:$e,rowHeight:Tt,orderedColumns:Wr,onColumnResize:ua}),{handleScroll:Qm,setViewportElement:ew,maxContentHeight:tw,virtualization:Dt}=Df({viewport:{onRowsScrollEnd:Ne,overscanRowCount:Pt,autoHeight:u,setDimensions:$m},viewportRef:Sn,containerRef:Ot,layout:$e,viewportWidth:Oe.dimensions.viewportWidth,viewportHeight:Oe.dimensions.viewportHeight,virtualization:{autoHeight:u,rowReordering:vn,hasDetailPanel:kn,checkboxSelection:p,pinCheckboxColumn:se,pinExpandColumn:Z}}),{handleSort:xa,handleSortAdd:Ca}=Hd({sortModel:wt,onSortModelChange:ym}),ya=p||!m,{focusedCell:va,setFocusedCell:Sa,viewportTabIndex:nw,ensureGridFocus:ow,handleFocus:rw,handleBlur:iw,handleKeyDown:lw,handleMouseDownCapture:sw}=Lc({allRenderableRows:En,navigationColumns:uo,checkboxSelection:p,selectedRowIds:Gr,handleSelectionChange:ma,handleDetailPanelToggle:la,editingHandlers:$r,setKeyboardMode:Tr,sortModel:wt,handleSort:xa,handleSortAdd:Ca,multiSort:oe,isCellEditable:de,pagination:xt,pageSize:st.pageSize,virtualization:Dt,viewportRef:Sn,pinnedTopRowCount:Ue.length,getRowId:De,rowMetaMap:Ye,getSpanOrigin:Mn.getSpanOrigin,onRowActivate:ha,toggleRowExpansion:en?.toggleExpansion,handleSelectAll:pa.selectAll,rowSelectionEnabled:ya,multipleRowSelectionEnabled:!C,pinCheckboxColumn:se,pinExpandColumn:Z,rowHeight:Tt,cellSelection:An.keyboard,headerFilters:Lr}),{handleCellClick:aw,handleHeaderClick:cw}=Vp({ensureGridFocus:ow,setKeyboardMode:Tr,setFocusedCell:Sa,getRowId:De,onCellClick:S}),dw=Af({props:e,apiRef:_n,containerRef:Ot,viewportRef:Sn,selection:An,model:Nt.cellSelectionModel,getPendingModel:Nt.getPendingCellSelectionModel,focusedCell:va,setFocusedCell:Sa,allRenderableRows:En,getRowId:De,navigationColumns:uo,columnIndexMap:Vr,isCellEditable:de,rowMetaMap:Ye,getSpanOrigin:Mn.getSpanOrigin,isEditing:$r.editingCell!==null,batchEdit:Rm,channel:zm,layout:$e,rowHeight:Tt,pinnedTopRowCount:Ue.length}),{handleHideColumn:uw,handlePinColumn:fw}=Bd({columnVisibilityModel:Ft,onColumnVisibilityModelChange:Mr,pinnedColumns:Ar,onPinnedColumnsChange:Sm}),{ariaRows:gw,spanRowWindow:pw,visibleRows:_a,renderColumns:hw}=Cu({aria:{columnGroupingModel:Ie,headerFilterRow:Lr,pinnedTopCount:Ue.length,pinnedBottomCount:at.length,pagination:xt,paginationMode:he,paginationModel:st,paginationRowCount:ga,paginatedUnpinnedRowCount:go.length,sortedUnpinnedRowCount:yt.length},spanning:Mn,virtualization:Dt,layout:$e,pinnedTopRows:Ue,pinnedBottomRows:at,paginatedUnpinnedRows:go,sortedUnpinnedRows:yt,pagination:xt,getRowId:De});Nd({paginationRequested:O,isRowGrouping:Qt,autoHeight:u,viewportHeight:Oe.dimensions.viewportHeight,renderedRowCount:_a.length,totalRowCount:Ue.length+Ur.length+at.length,pinnedRowsIgnored:lo&&!!(j?.top?.length||j?.bottom?.length),scrollHeight:Dt.totalHeight,maxContentHeight:tw,reachableRowCount:Xc(Dt.cumulativeHeights,Dt.virtualContainerHeight),unpinnedRowCount:Dt.cumulativeHeights.length,listViewWithoutColumn:We&&!xe,listViewRowCount:Nr&&xe?En.length:0});const mw=Zf(Ie,Xm),ww=s.useMemo(()=>sa.some(jr=>!!jr.rowSpan),[sa]),{columnsPanel:bw,aiAssistantPanel:xw,toolbarProps:Cw}=rh({apiRef:_n,containerRef:Ot,localeText:Re,aiAssistant:{options:Lt,columns:Ct,onApply:He,onError:ro},toolbar:{toolbar:ve?.toolbar,toolbarSlotProps:ye?.toolbar,orderedColumns:Wr,baseColumns:Cn,aggregationModel:lt,onAggregationModelChange:vm,pivotMode:fe,pivotModelProp:Ee,onPivotModelChangeProp:Le,pivotModel:ea,onPivotModelChange:_m,filterModel:It,onFilterModelChange:Qs,columnVisibilityModel:Ft,onColumnVisibilityModelChange:Mr,disableColumnReorder:$,columnGroupingModel:Ie,moveColumn:ca,resetColumnOrder:da}}),yw={setViewportElement:ew,handleScroll:Qm,ariaLabel:w,ariaRows:gw,navigationColumnCount:uo.length,rowSelectionEnabled:ya,disableMultipleRowSelection:C,cellSelection:An,effectiveLoading:Or,viewportTabIndex:nw,setKeyboardMode:Tr,handleMouseDownCapture:sw,handleKeyDown:lw,handleFocus:rw,handleBlur:iw,effectivePinnedColumns:Ir,virtualization:Dt,renderColumns:hw,renderedDataColumns:ba,columnGroupingModel:Ie,checkboxSelection:p,rowSelection:pa,sortModel:wt,handleSort:xa,handleSortAdd:Ca,multiSort:oe,handleColumnResize:ua,handleColumnAutosize:Zm,columnWidths:zr,focusedCell:va,columnIndexMap:Vr,handleHeaderClick:cw,headerReorderHandlers:mw,rowReordering:vn,hasDetailPanel:kn,pinCheckboxColumn:se,pinExpandColumn:Z,aggregationModel:lt,handleHideColumn:uw,columnsPanel:bw,handlePinColumn:fw,wrapHeaderText:l,headerHeight:oa,showHeaderFilters:Lr,filterModel:It,handleFilterModelChange:Qs,localeText:Re,editingHandlers:$r,isCellEditable:de,selectedRowIds:Gr,handleRowClick:ha,onRowDoubleClick:T,handleCellClick:aw,handleSelectionChange:ma,expandedRowIds:Hr,getDetailPanelContent:Q,getDetailPanelHeight:U,handleDetailPanelToggle:la,reportDetailPanelHeight:Km,spanning:Mn,rowMetaMap:Ye,fillHandle:dw,pinnedTopRows:Ue,pinnedBottomRows:at,pinnedRows:j,getRowIdOf:De,showEmptyState:!Or&&!Oe.dataSource.error&&fa.length===0,effectiveNoRowsLabel:Cm,spanRowWindow:pw,visibleRows:_a,baseColumns:Cn,viewportWidth:Oe.dimensions.viewportWidth,rowReorderHandlers:Ym,paginationMode:he,dataSourceLoading:Oe.dataSource.loading,sortedUnpinnedRowCount:yt.length,pageSize:st.pageSize,unpinnedRowsLength:$e.unpinnedRowsLength,showAggregationFooter:Kr&&Dr.rootAggregationPosition!==null,aggregationResult:wa,effectiveRowHeight:Tt,isAggregationLoading:Jm,containerRef:Ot,className:x,autoHeight:u,height:h,style:y,hasRowSpanning:ww,listView:Nr,headerFilterHeight:a,slots:ve,slotProps:ye,toolbarProps:Cw,aiAssistantPanel:xw,orderedColumns:Wr,columnVisibilityModel:Ft,disableColumnReorder:$,handleColumnVisibilityModelChange:Mr,moveColumn:ca,resetColumnOrder:da,listViewColumn:xe,allRenderableRows:En,dataRows:fo,pagination:xt,effectivePaginationModel:st,currentPage:Rr.currentPage,pageSizeOptions:K,columnsByField:Fr.byField,paginationRowCount:ga,handlePaginationModelChange:Pr,onRowsScrollEnd:Ne,toggleExpansion:en?.toggleExpansion,showCellSelectionStats:A,apiRef:so.apiRef,hasAggregation:Kr,isHierarchyEnabled:lo,dataSourceError:Oe.dataSource.error,filteredRowCount:fa.length,onRetry:pe?ia.fetchRows:void 0};return d.jsx(kp,{...yw})}function lh({rows:e=5,columns:t=5}){return d.jsx("div",{className:"ogx__skeleton",children:Array.from({length:e}).map((n,o)=>d.jsx("div",{className:"ogx__skeleton-row",children:Array.from({length:t}).map((r,i)=>d.jsx("div",{className:"ogx__skeleton-cell",children:d.jsx("div",{className:"ogx__skeleton-content"})},i))},o))})}const sh=300;function Xt(e){return"field"in e&&!("items"in e)}function Ps(e,t){return e.find(n=>Xt(n)&&n.field===t)}function ah(e,t){return e===t?!0:Xt(e)&&Xt(t)?e.id===t.id&&e.field===t.field&&e.operator===t.operator&&wr(e.value,t.value):!Xt(e)&&!Xt(t)?e.id===t.id&&e.logicOperator===t.logicOperator&&_r(e.items,t.items):!1}function _r(e,t){return e===t?!0:e.length===t.length&&e.every((n,o)=>ah(n,t[o]))}function Ls(e,t){return Po(e,t.type)}function ch(e,t){if(!Gt.has(t))return t==="isAnyOf"?e==null||e===""?[]:Array.isArray(e)?e:[e]:Array.isArray(e)?e.length>0?e[0]:"":e??""}const dh=({col:e,item:t,resetToken:n,onChange:o})=>{const r=s.useId(),i=_e(),l=s.useMemo(()=>gi(e.type),[e.type]),c=l[0],a=t?.operator??c,u=l.includes(a)?l:[a,...l],f=!!t,h=e.headerName||e.field,[x,y]=s.useState(null),[w,g]=s.useState(n);w!==n&&(g(n),y(null));const p=s.useRef(o),m=s.useRef(t),C=s.useRef(e);s.useLayoutEffect(()=>{p.current=o,m.current=t,C.current=e});const b=s.useCallback((F,L)=>({id:m.current?.id??`${e.field}-${Date.now()}`,field:e.field,operator:F,value:L}),[e.field]),_=s.useCallback(F=>{const L=m.current;if(L?F===Ls(L.value,C.current):F.trim()==="")return;const O=L?.operator??c;p.current(b(O,Jn(F,O)))},[c,b]),v=s.useRef(null),k=s.useRef(_);s.useLayoutEffect(()=>{v.current=x,k.current=_}),s.useEffect(()=>()=>{const F=v.current;v.current=null,F!==null&&k.current(F)},[]),s.useEffect(()=>{if(x===null)return;const F=setTimeout(()=>{v.current=null,_(x),y(null)},sh);return()=>clearTimeout(F)},[x,_]);const A=F=>{const L=x!==null?Jn(x,F):t?.value;y(null),o(b(F,ch(L,F)))},M=()=>{y(null),o(null)},N=!Gt.has(a),P=ps(e),T=`ogx-filter__value-input${f?" ogx-filter__value-input--active":""}`,S=i.filterPanelValueLabel(h);let I=null;if(N&&e.type==="boolean")I=d.jsxs("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${T} ogx-filter__value-select`,value:t?.value==null?"":String(t.value),onChange:F=>{F.target.value===""?o(null):o(b(a,F.target.value))},"aria-label":S,children:[d.jsx("option",{value:"",children:i.filterPanelAny}),d.jsx("option",{value:"true",children:i.filterPanelTrue}),d.jsx("option",{value:"false",children:i.filterPanelFalse})]});else if(N&&e.type==="singleSelect"&&P.length>0&&a==="isAnyOf"){const F=Array.isArray(t?.value)?t.value:t?.value==null||t.value===""?[]:[t.value];I=d.jsx("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${T} ogx-filter__value-multiselect`,multiple:!0,size:Math.min(P.length,4),value:P.filter(L=>F.some(E=>mr(L,E))).map(L=>L.key),onChange:L=>{const E=new Set(Array.from(L.target.selectedOptions,O=>O.value));o(b("isAnyOf",P.filter(O=>E.has(O.key)).map(O=>O.value)))},"aria-label":S,children:P.map(L=>d.jsx("option",{value:L.key,children:L.label},L.key))})}else if(N&&e.type==="singleSelect"&&P.length>0&&(a==="is"||a==="not")){const F=P.find(L=>mr(L,t?.value));I=d.jsxs("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${T} ogx-filter__value-select`,value:F?.key??"",onChange:L=>{const E=P.find(O=>O.key===L.target.value);o(b(a,E?E.value:""))},"aria-label":S,children:[d.jsx("option",{value:"",children:i.filterPanelAny}),P.map(L=>d.jsx("option",{value:L.key,children:L.label},L.key))]})}else N&&(I=d.jsx(nt,{id:`${r}-val`,name:`filter-val-${e.field}`,inputClassName:T,type:e.type==="date"?"date":"text",value:x??Ls(t?.value,e),onChange:F=>y(F.target.value),placeholder:e.type==="number"?i.filterPanelNumberPlaceholder:i.filterPanelValuePlaceholder,"aria-label":S}));return d.jsxs("div",{className:`ogx-filter__row${f?" ogx-filter__row--active":""}`,children:[d.jsx("span",{className:"ogx-filter__col-label",title:e.field,children:h}),d.jsxs("div",{className:"ogx-filter__controls",children:[d.jsx("select",{id:`${r}-op`,name:`filter-op-${e.field}`,className:`ogx-filter__op-select${f?" ogx-filter__op-select--active":""}`,value:a,onChange:F=>A(F.target.value),"aria-label":i.filterPanelOperatorLabel(h),children:u.map(F=>d.jsx("option",{value:F,children:i.filterPanelOperator(F)},F))}),I,f&&d.jsx("button",{type:"button",className:"ogx-filter__row-clear",onClick:M,"aria-label":i.filterPanelClearLabel(h),title:i.filterPanelClearTooltip,children:"×"})]})]})},Ns=({filterModel:e,columns:t,onFilterModelChange:n})=>{const o=_e(),r=s.useMemo(()=>e.items??[],[e.items]),i=e.logicOperator??"and",[l,c]=s.useState(null),[a,u]=s.useState(r),[f,h]=s.useState(0);if(a!==r){u(r);const m=!_r(a,r),C=l!==null&&_r(l,r);m&&!C&&h(b=>b+1)}const x=s.useCallback((m,C)=>{const b=r.findIndex(v=>Xt(v)&&v.field===m);let _;if(b===-1){if(!C)return;_=[...r,C]}else C?_=r.map((v,k)=>k===b?C:v):_=r.filter((v,k)=>k!==b);c(_),n({...e,items:_})},[r,e,n]),y=s.useCallback(m=>{n({...e,logicOperator:m})},[e,n]),w=t.filter(m=>m.filterable!==!1),g=w.filter(m=>Ps(r,m.field)).length,p=r.length-g;return d.jsxs(d.Fragment,{children:[r.length>1&&d.jsxs("div",{className:"ogx-filter__logic-bar",children:[d.jsx("span",{className:"ogx-filter__logic-label",children:o.filterPanelMatch}),d.jsx("button",{type:"button",className:`ogx-filter__logic-pill${i==="and"?" ogx-filter__logic-pill--active":""}`,onClick:()=>y("and"),"aria-pressed":i==="and",children:o.filterPanelAnd}),d.jsx("button",{type:"button",className:`ogx-filter__logic-pill${i==="or"?" ogx-filter__logic-pill--active":""}`,onClick:()=>y("or"),"aria-pressed":i==="or",children:o.filterPanelOr})]}),p>0&&d.jsx("div",{className:"ogx-filter__hidden-note",role:"note",children:o.filterPanelHiddenConditions(p)}),w.length===0?d.jsx("div",{className:"ogx-filter__empty",children:o.filterPanelNoColumns}):w.map(m=>d.jsx(dh,{col:m,item:Ps(r,m.field),resetToken:f,onChange:C=>x(m.field,C)},m.field))]})},Is=["sum","avg","count","min","max"];function Fs(){return d.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),d.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),d.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),d.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1",fill:"currentColor",opacity:"0.25"}),d.jsx("path",{d:"M17 14v-4M17 10l-2 2 2 2"})]})}function uh({anchorRef:e,columns:t,model:n,onChange:o,onClose:r}){const i=_e(),l=s.useRef(null),[c,a]=s.useState({top:0,right:0}),[u,f]=s.useState(null);s.useLayoutEffect(()=>{f(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const h=s.useCallback(()=>ei(e.current,pn()),[e]);s.useEffect(()=>{a(h());const E=()=>a(h());return window.addEventListener("scroll",E,!0),window.addEventListener("resize",E),()=>{window.removeEventListener("scroll",E,!0),window.removeEventListener("resize",E)}},[h]),s.useEffect(()=>{function E(B){l.current&&!l.current.contains(B.target)&&e.current&&!e.current.contains(B.target)&&r()}function O(B){B.key==="Escape"&&r()}return document.addEventListener("mousedown",E),document.addEventListener("keydown",O),()=>{document.removeEventListener("mousedown",E),document.removeEventListener("keydown",O)}},[e,r]);const x=new Set(n.rowFields),y=new Set(n.columnFields),w=new Set(n.valueFields.map(E=>E.field)),g=E=>x.has(E)||y.has(E)||w.has(E),p=E=>t.find(O=>O.field===E),m=E=>p(E)?.headerName??E,C=E=>{const O=p(E)?.availableAggregationFunctions;return O?Is.filter(B=>O.includes(B)):Is},b=E=>E.aggregable!==!1&&(E.type==="number"||E.aggregable===!0)&&C(E.field).length>0,_=E=>E.groupable!==!1;function v(E){x.has(E)||o({...n,rowFields:[...n.rowFields,E]})}function k(E){y.has(E)||o({...n,columnFields:[...n.columnFields,E]})}function A(E){w.has(E)||o({...n,valueFields:[...n.valueFields,{field:E,aggFn:C(E)[0]??"sum"}]})}function M(E){o({...n,rowFields:n.rowFields.filter((O,B)=>B!==E)})}function N(E){o({...n,columnFields:n.columnFields.filter((O,B)=>B!==E)})}function P(E){o({...n,valueFields:n.valueFields.filter((O,B)=>B!==E)})}function T(E,O){o({...n,valueFields:n.valueFields.map((B,H)=>H===E?{...B,aggFn:O}:B)})}function S(){o({rowFields:[],columnFields:[],valueFields:[]})}const I=n.rowFields.length+n.columnFields.length+n.valueFields.length,F=t.filter(E=>!g(E.field)&&(_(E)||b(E))),L=d.jsxs("div",{ref:l,className:"ogx-pivot-panel",role:"dialog","aria-label":i.pivotPanelLabel,style:{top:c.top,right:c.right,left:c.left},children:[d.jsxs("div",{className:"ogx-pivot-panel__header",children:[d.jsxs("span",{className:"ogx-pivot-panel__title",children:[d.jsx(Fs,{}),i.pivotMode]}),I>0&&d.jsx("button",{type:"button",className:"ogx-pivot-panel__reset-btn",onClick:S,title:i.pivotResetTooltip,children:i.pivotReset})]}),d.jsxs("div",{className:"ogx-pivot-panel__body",children:[d.jsxs("div",{className:"ogx-pivot-zone",children:[d.jsxs("span",{className:"ogx-pivot-zone__label",children:[d.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--row"}),i.pivotRowFields]}),d.jsx("div",{className:`ogx-pivot-chips${n.rowFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":i.pivotRowFieldsPlaceholder,children:n.rowFields.map((E,O)=>d.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--row",children:[m(E),d.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>M(O),title:i.pivotRemoveTooltip(m(E)),"aria-label":i.pivotRemoveRowLabel(m(E)),children:"×"})]},`${O}:${E}`))})]}),d.jsxs("div",{className:"ogx-pivot-zone",children:[d.jsxs("span",{className:"ogx-pivot-zone__label",children:[d.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--col"}),i.pivotColumnFields]}),d.jsx("div",{className:`ogx-pivot-chips${n.columnFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":i.pivotColumnFieldsPlaceholder,children:n.columnFields.map((E,O)=>d.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--col",children:[m(E),d.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>N(O),title:i.pivotRemoveTooltip(m(E)),"aria-label":i.pivotRemoveColumnLabel(m(E)),children:"×"})]},`${O}:${E}`))})]}),d.jsxs("div",{className:"ogx-pivot-zone",children:[d.jsxs("span",{className:"ogx-pivot-zone__label",children:[d.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--value"}),i.pivotValueFields]}),d.jsx("div",{className:`ogx-pivot-chips${n.valueFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":i.pivotValueFieldsPlaceholder,children:n.valueFields.map((E,O)=>{const B=C(E.field),H=B.includes(E.aggFn)?B:[E.aggFn,...B];return d.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--value",children:[m(E.field),d.jsx("select",{className:"ogx-pivot-chip__fn-select",value:E.aggFn,onChange:K=>T(O,K.target.value),title:i.pivotAggregationTooltip,"aria-label":i.pivotAggregationLabel(m(E.field)),children:H.map(K=>d.jsx("option",{value:K,children:i.pivotAggregationFunction(K)},K))}),d.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>P(O),title:i.pivotRemoveTooltip(m(E.field)),"aria-label":i.pivotRemoveValueLabel(m(E.field),i.pivotAggregationFunction(E.aggFn)),children:"×"})]},`${O}:${E.field}:${E.aggFn}`)})})]}),d.jsx("hr",{className:"ogx-pivot-panel__divider"}),d.jsxs("div",{children:[d.jsx("div",{className:"ogx-pivot-panel__fields-label",children:i.pivotAvailableFields}),d.jsxs("div",{className:"ogx-pivot-fields",children:[F.map(E=>{const O=b(E),B=_(E),H=E.headerName??E.field;return d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3},children:[d.jsx("span",{className:`ogx-pivot-field-btn${O?" ogx-pivot-field-btn--numeric":""}`,children:H}),d.jsxs("div",{className:"ogx-pivot-field-actions",children:[B&&d.jsx("button",{type:"button",className:"ogx-pivot-add-btn ogx-pivot-add-btn--row",onClick:()=>v(E.field),title:i.pivotAddRowTooltip,"aria-label":i.pivotAddRowLabel(H),children:i.pivotAddRow}),B&&d.jsx("button",{type:"button",className:"ogx-pivot-add-btn ogx-pivot-add-btn--col",onClick:()=>k(E.field),title:i.pivotAddColumnTooltip,"aria-label":i.pivotAddColumnLabel(H),children:i.pivotAddColumn}),O&&d.jsx("button",{type:"button",className:"ogx-pivot-add-btn ogx-pivot-add-btn--value",onClick:()=>A(E.field),title:i.pivotAddValueTooltip,"aria-label":i.pivotAddValueLabel(H),children:i.pivotAddValue})]})]},E.field)}),F.length===0&&d.jsx("span",{style:{fontSize:12,color:"var(--ogx-color-gray-400, #94a3b8)"},children:i.pivotAllFieldsInUse})]})]})]})]});return u?ct.createPortal(L,u):null}function fh(){return d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("circle",{cx:"11",cy:"11",r:"8"}),d.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function gh(){return d.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),d.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function Ts(e){return e.trim().split(/\s+/).filter(Boolean).join(" ")}function ph({value:e="",onChange:t,placeholder:n,debounceMs:o=250}){const r=_e(),i=n??r.toolbarSearchPlaceholder,[l,c]=s.useState(()=>e.length>0),[a,u]=s.useState(e),f=s.useRef(null),h=s.useRef(null),x=s.useRef(t);s.useLayoutEffect(()=>{x.current=t},[t]);const y=s.useRef(e),w=s.useRef(e);s.useEffect(()=>{e!==w.current&&(w.current=e,Ts(e)!==Ts(y.current)&&(u(e),y.current=e,c(e.length>0)))},[e]),s.useEffect(()=>{const _=setTimeout(()=>{a!==y.current&&(y.current=a,x.current(a))},o);return()=>clearTimeout(_)},[a,o]);const g=s.useRef(a);s.useLayoutEffect(()=>{g.current=a}),s.useEffect(()=>()=>{const _=g.current;_!==y.current&&(y.current=_,x.current(_))},[]);const p=s.useCallback(()=>{c(!0),requestAnimationFrame(()=>f.current?.focus())},[]),m=s.useCallback(_=>{_.stopPropagation(),u(""),y.current="",x.current(""),f.current?.focus()},[]),C=s.useCallback(()=>{c(!0)},[]),b=s.useCallback(()=>{setTimeout(()=>{h.current&&document.activeElement&&h.current.contains(document.activeElement)||a||c(!1)},150)},[a]);return s.useEffect(()=>{const _=v=>{h.current&&!h.current.contains(v.target)&&(a||c(!1))};return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[a]),d.jsxs("div",{ref:h,className:`ogx-global-search${l?" ogx-global-search--expanded":""}`,onClick:l?void 0:p,children:[d.jsx("div",{className:"ogx-global-search__icon-wrapper",children:d.jsx(fh,{})}),d.jsx(nt,{ref:f,inputClassName:"ogx-global-search__input",value:a,onChange:_=>u(_.target.value),onFocus:C,onBlur:b,placeholder:i,"aria-label":r.toolbarSearchLabel,autoComplete:"off"}),a&&d.jsx("button",{type:"button",className:"ogx-global-search__clear",onClick:m,"aria-label":r.toolbarSearchClear,children:d.jsx(gh,{})})]})}const to=8;function wn({title:e,children:t,placement:n="top",enterDelay:o=200,leaveDelay:r=0}){const[i,l]=s.useState(!1),[c,a]=s.useState({top:0,left:0}),[u,f]=s.useState(null),h=s.useRef(null),x=s.useRef(null),y=s.useId(),w=s.useCallback(()=>{if(!x.current)return;const v=x.current.getBoundingClientRect(),k=v.left+v.width/2,A=v.top+v.height/2;switch(n){case"bottom":a({top:v.bottom+to,left:k});break;case"left":a({top:A,left:v.left-to});break;case"right":a({top:A,left:v.right+to});break;default:a({top:v.top-to,left:k})}},[n]),g=s.useCallback(()=>{h.current&&clearTimeout(h.current),h.current=null},[]);s.useLayoutEffect(()=>{if(!i)return;w();const v=k=>{k.key==="Escape"&&(g(),l(!1))};return window.addEventListener("scroll",w,!0),window.addEventListener("resize",w),document.addEventListener("keydown",v),()=>{window.removeEventListener("scroll",w,!0),window.removeEventListener("resize",w),document.removeEventListener("keydown",v)}},[i,w,g]),s.useEffect(()=>g,[g]);const p=()=>{g(),h.current=setTimeout(()=>{f(x.current?.closest(".ogx-theme-provider")??document.body),l(!0)},o)},m=()=>{g(),h.current=setTimeout(()=>{l(!1)},r)},C=s.useCallback(v=>{x.current=v?v.firstElementChild??v:null},[]),b=i&&!!e&&u!==null;let _=t;if(b&&s.isValidElement(t)){const v=t,k=v.props["aria-describedby"];_=s.cloneElement(v,{"aria-describedby":k?`${k} ${y}`:y})}return d.jsxs(d.Fragment,{children:[d.jsx("span",{ref:C,style:{display:"inline-block",lineHeight:0},onMouseEnter:p,onMouseLeave:m,onFocus:p,onBlur:m,children:_}),b&&u&&ct.createPortal(d.jsx("div",{id:y,role:"tooltip",className:`ogx-tooltip ogx-tooltip--${n}`,style:{top:c.top,left:c.left,position:"fixed",zIndex:99999},children:e}),u)]})}function Os(){return d.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:d.jsx("path",{d:"M18 4H6l6 8-6 8h12"})})}function hh(){return d.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",children:[d.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),d.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.25"}),d.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),d.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),d.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),d.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function Ds(){return d.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})})}function kr(e,t,{closeOnOutsideClick:n=!0}={}){const o=s.useRef(null),[r,i]=s.useState({top:0,right:0}),[l,c]=s.useState(null),a=s.useRef(t);s.useLayoutEffect(()=>{a.current=t}),s.useLayoutEffect(()=>{c(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const u=s.useCallback(()=>ei(e.current,pn()),[e]);return s.useEffect(()=>{i(u());const f=()=>i(u());return window.addEventListener("scroll",f,!0),window.addEventListener("resize",f),()=>{window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[u]),s.useEffect(()=>{if(!n)return;function f(h){const x=h.target;o.current&&!o.current.contains(x)&&e.current&&!e.current.contains(x)&&a.current()}return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[e,n]),s.useEffect(()=>{function f(h){h.key==="Escape"&&a.current()}return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[]),{panelRef:o,position:r,portalContainer:l}}function mh({anchorRef:e,aggregationModel:t,aggregableColumns:n,onFunctionChange:o,onClearAll:r,onClose:i,activeCount:l}){const c=_e(),{panelRef:a,position:u,portalContainer:f}=kr(e,i),h=d.jsxs("div",{ref:a,className:"ogx-toolbar__panel",role:"dialog","aria-label":c.toolbarSummariesPanelLabel,style:{top:u.top,right:u.right,left:u.left,width:400,maxWidth:"calc(100vw - 24px)"},children:[d.jsxs("div",{className:"ogx-toolbar__panel-header",children:[d.jsxs("span",{className:"ogx-toolbar__panel-title",children:[d.jsx(Os,{}),c.toolbarSummaries]}),l>0&&d.jsx("button",{type:"button",className:"ogx-toolbar__clear-btn",onClick:r,title:c.toolbarSummariesClearAllTooltip,children:c.toolbarSummariesClearAll})]}),d.jsx("div",{className:"ogx-toolbar__panel-body",children:n.length===0?d.jsxs("p",{className:"ogx-toolbar__empty",children:[c.toolbarSummariesEmpty,d.jsx("br",{}),`${c.toolbarSummariesEmptyHintBefore} `,d.jsx("code",{children:"aggregable: true"}),` ${c.toolbarSummariesEmptyHintAfter}`]}):n.map(x=>{const y=t[x.field]||"none";return d.jsxs("div",{className:"ogx-toolbar__agg-row",children:[d.jsx("span",{className:"ogx-toolbar__agg-label",title:x.field,children:x.headerName||x.field}),d.jsx("div",{className:"ogx-toolbar__agg-pills",children:["none",...ii(x)].map(w=>d.jsx("button",{type:"button",className:`ogx-toolbar__pill${y===w?" ogx-toolbar__pill--active":""}`,onClick:()=>o(x.field,w),"aria-pressed":y===w,children:c.toolbarAggregationFunction(w)},w))})]},x.field)})})]});return f?ct.createPortal(h,f):null}function wh({anchorRef:e,columns:t,visibleColumns:n,onVisibilityChange:o,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:c,onClose:a,showNonHideableColumns:u}){const f=_e(),{panelRef:h,position:x,portalContainer:y}=kr(e,a),w=d.jsx("div",{ref:h,className:"ogx-toolbar__panel",role:"dialog","aria-label":f.toolbarColumnsPanelLabel,style:{top:x.top,right:x.right,left:x.left,width:280,padding:0},children:d.jsx(pr,{columns:t,visibleColumns:n,onVisibilityChange:o,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:c,showNonHideableColumns:u})});return y?ct.createPortal(w,y):null}function bh({anchorRef:e,columns:t,filterModel:n,onFilterModelChange:o,onClose:r}){const i=_e(),{panelRef:l,position:c,portalContainer:a}=kr(e,r,{closeOnOutsideClick:!1}),u=n.items?.length??0,f=()=>{o({...n,items:[],logicOperator:"and"})},h=d.jsxs("div",{ref:l,className:"ogx-toolbar__panel ogx-toolbar__panel--filter",role:"dialog","aria-label":i.toolbarFiltersLabel,style:{top:c.top,right:c.right,left:c.left,width:540,maxWidth:"calc(100vw - 24px)"},children:[d.jsxs("div",{className:"ogx-toolbar__panel-header",children:[d.jsxs("span",{className:"ogx-toolbar__panel-title",children:[d.jsx(Ds,{}),i.toolbarFilters,u>0&&d.jsx("span",{className:"ogx-toolbar__panel-count",children:u})]}),d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[u>0&&d.jsx("button",{type:"button",className:"ogx-toolbar__clear-btn",onClick:f,title:i.toolbarFiltersClearAllTooltip,children:i.toolbarFiltersClearAll}),d.jsx("button",{type:"button",className:"ogx-toolbar__close-btn",onClick:r,title:i.toolbarFiltersCloseTooltip,"aria-label":i.toolbarFiltersCloseLabel,children:i.toolbarFiltersClose})]})]}),d.jsx("div",{className:"ogx-toolbar__panel-body ogx-toolbar__panel-body--filter",children:d.jsx(Ns,{columns:t,filterModel:n,onFilterModelChange:o})})]});return a?ct.createPortal(h,a):null}const xh={rowFields:[],columnFields:[],valueFields:[]},Ch=[];function yh({columns:e=Ch,baseColumns:t,aggregationModel:n={},onAggregationModelChange:o,pivotModel:r,onPivotModelChange:i,filterModel:l,onFilterModelChange:c,columnVisibilityModel:a={},onColumnVisibilityModelChange:u,onColumnReorder:f,onColumnOrderReset:h,forceColumnsOpen:x,onColumnsPanelClose:y,forceFiltersOpen:w,onFiltersPanelClose:g,children:p,rightContent:m,style:C,renderColumnsButton:b,renderFilterButton:_,renderAggregationButton:v,renderExportButton:k,renderQuickFilter:A,className:M,showNonHideableColumns:N,onAiAssistantToggle:P,aiAssistantOpen:T=!1,aiAssistantLabel:S}){const I=_e(),F=S??I.aiAssistantButton,[L,E]=s.useState(x?"columns":null),O=L==="summaries",B=L==="pivot",H=L==="columns",K=L==="filters",R=ge=>{L==="columns"&&ge!=="columns"&&y?.(),L==="filters"&&ge!=="filters"&&g?.(),E(ge)},X=ge=>R(L===ge?null:ge),j=ge=>{L===ge&&R(null)},[Q,U]=s.useState(x);Q!==x&&(U(x),x&&E("columns"));const[re,q]=s.useState(w);re!==w&&(q(w),w&&c&&E("filters"));const se=s.useContext(as),Z=x!==void 0&&!!u;s.useEffect(()=>{if(!(!se||!Z))return se.registerColumnsPanel()},[se,Z]);const $=w!==void 0&&!!c;s.useEffect(()=>{if(!(!se||!$))return se.registerFiltersPanel()},[se,$]);const D=s.useRef(null),G=s.useRef(null),W=s.useRef(null),ee=s.useRef(null),V=s.useRef(null),Y=s.useRef(null),J=s.useRef(null),te=s.useRef(null),ne=r??xh,z=ne.rowFields.length>0||ne.columnFields.length>0||ne.valueFields.length>0,ie=t?new Set(t.map(ge=>ge.field)):null,ae=e.filter(ge=>ge.aggregable!==!1&&(ge.type==="number"||ge.aggregable===!0)&&ii(ge).length>0&&(!ie||ie.has(ge.field))),le=Object.keys(n).filter(ge=>n[ge]&&n[ge]!=="none").length,ce=s.useCallback((ge,ve)=>{if(!o)return;const ye={...n};ve==="none"?delete ye[ge]:ye[ge]=ve,o(ye)},[n,o]),de=s.useCallback(()=>{o?.({})},[o]),we=s.useCallback(ge=>{if(!c)return;const ve=ge.trim().split(/\s+/).filter(Boolean),ye={...l||{},quickFilterValues:ve,items:l?.items||[]};c(ye)},[l,c]),me=(l?.quickFilterValues??[]).join(" "),pe=l?.items?.length||0,oe=new Set(e.filter(ge=>a[ge.field]!==!1).map(ge=>ge.field)),ue=s.useCallback((ge,ve)=>{if(!u)return;const ye={...a,[ge]:ve};u(ye)},[a,u]),be=s.useCallback(()=>{if(!u)return;const ge={...a};e.forEach(ve=>{ve.hideable!==!1&&(ge[ve.field]=!0)}),u(ge)},[e,a,u]),he=s.useCallback(()=>{if(!u)return;const ge={...a};e.forEach(ve=>{ve.hideable!==!1&&(ge[ve.field]=!1)}),u(ge)},[e,a,u]);return d.jsxs("div",{className:["ogx-toolbar",M].filter(Boolean).join(" "),role:"toolbar","aria-label":I.toolbarLabel,style:C,children:[p&&d.jsx("div",{className:"ogx-toolbar__left",children:p}),d.jsx("div",{className:"ogx-toolbar__spacer"}),d.jsxs("div",{className:"ogx-toolbar__actions",children:[P&&d.jsx("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:d.jsxs("button",{type:"button",ref:G,className:`ogx-toolbar__icon-btn ogx-toolbar__ai-btn${T?" ogx-toolbar__icon-btn--active":""}`,"aria-haspopup":"dialog","aria-expanded":T,onClick:()=>{R(null),P(G.current)},children:[d.jsx(cs,{}),F]})}),c&&d.jsx("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:A?A({value:me,onChange:we}):d.jsx(ph,{value:me,onChange:we,placeholder:I.toolbarSearchPlaceholder})}),u&&d.jsxs("div",{ref:Y,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[b?b({onClick:()=>X("columns"),isOpen:H,activeCount:e.length-oe.size}):d.jsx(wn,{title:I.toolbarColumns,children:d.jsx("button",{type:"button",ref:ee,className:`ogx-toolbar__icon-btn${H?" ogx-toolbar__icon-btn--active":""}`,"aria-label":I.toolbarColumnsLabel,"aria-haspopup":"dialog","aria-expanded":H,onClick:()=>X("columns"),children:d.jsx(hh,{})})}),H&&d.jsx(wh,{anchorRef:b?Y:ee,columns:e,visibleColumns:oe,onVisibilityChange:ue,onShowAll:be,onHideAll:he,onColumnReorder:f,onColumnOrderReset:h,onClose:()=>j("columns"),showNonHideableColumns:N})]}),c&&d.jsxs("div",{ref:J,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[_?_({onClick:()=>X("filters"),isOpen:K,activeCount:pe}):d.jsx(wn,{title:I.toolbarFilters,children:d.jsxs("button",{type:"button",ref:V,className:`ogx-toolbar__icon-btn${K?" ogx-toolbar__icon-btn--active":""}`,"aria-label":I.toolbarFiltersLabel,"aria-haspopup":"dialog","aria-expanded":K,onClick:()=>X("filters"),children:[d.jsx(Ds,{}),pe>0&&d.jsx("span",{className:"ogx-toolbar__dot","aria-label":I.toolbarFiltersActive})]})}),K&&d.jsx(bh,{anchorRef:_?J:V,columns:e,filterModel:l||{items:[]},onFilterModelChange:c,onClose:()=>j("filters")})]}),i&&d.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[d.jsx(wn,{title:I.toolbarPivot,children:d.jsxs("button",{type:"button",ref:W,className:`ogx-toolbar__icon-btn${B?" ogx-toolbar__icon-btn--active":""}`,"aria-label":I.toolbarPivotLabel,"aria-haspopup":"dialog","aria-expanded":B,onClick:()=>X("pivot"),children:[d.jsx(Fs,{}),z&&d.jsx("span",{className:"ogx-toolbar__dot","aria-label":I.toolbarPivotActive})]})}),B&&d.jsx(uh,{anchorRef:W,columns:t??e,model:ne,onChange:ge=>{i?.(ge)},onClose:()=>j("pivot")})]}),o&&d.jsxs("div",{ref:te,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[v?v({onClick:()=>X("summaries"),isOpen:O,activeCount:le}):d.jsx(wn,{title:I.toolbarSummaries,children:d.jsxs("button",{type:"button",ref:D,className:`ogx-toolbar__icon-btn${O?" ogx-toolbar__icon-btn--active":""}`,"aria-label":I.toolbarSummariesLabel,"aria-haspopup":"dialog","aria-expanded":O,onClick:()=>X("summaries"),children:[d.jsx(Os,{}),le>0&&d.jsx("span",{className:"ogx-toolbar__dot","aria-label":I.toolbarSummariesActive(le)})]})}),O&&d.jsx(mh,{anchorRef:v?te:D,aggregationModel:n,aggregableColumns:ae,onFunctionChange:ce,onClearAll:de,onClose:()=>j("summaries"),activeCount:le})]}),k&&k(),m]})]})}function vh(){const[e]=s.useState(bl);return s.useRef(e)}function Yt(e,t){if(e.groupLabel!==void 0)return e.groupLabel;const n=e.groupField??"",o=t.find(r=>r.field===n)?.groupingValueFormatter;return o?o({field:n,value:e.groupValue}):`${n}: ${String(e.groupValue??"")}`}function bn(e,t){const n=fn(e,t),o=gn(e,t,n);return{text:o,raw:n,fromNonText:ku(n,o,!!t.valueFormatter)}}function Jt(e,t,n){return e.map(o=>rr(o,n[o.field],t[o.field],t))}function Er(e,t,n){const o=new Blob([e],{type:n}),r=URL.createObjectURL(o),i=document.createElement("a");i.href=r,i.download=t,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}const Sh="\uFEFF";function _h(e,t,n={}){const{fileName:o="export.csv",includeHeaders:r=!0,delimiter:i=",",selectedRows:l,groupedRows:c,escapeFormulas:a=!0,bom:u=!0}=n,f=At(t),h=n.aggregationModel||{},x=(g,p=!1)=>no(a?Xn(g,p):g,i),y=()=>f.map(g=>x(g.headerName||g.field)).join(i)+`
|
|
8
|
+
`;let w="";if(un(c,l))r&&(w+=y()),c.forEach(g=>{const p=" ".repeat(g.depth);if(g.type==="group-header"){const m=Yt(g,t),C=no(p+(a?Xn(m):m),i);w+=f.map((b,_)=>_===0?C:"").join(i)+`
|
|
9
|
+
`}else if(g.type==="leaf"&&g.row){const m=g.row,C=f.map((b,_)=>{const v=bn(m,b),k=a?Xn(v.text,v.fromNonText):v.text;return no((_===0?p:"")+k,i)});w+=C.join(i)+`
|
|
10
|
+
`}else if((g.type==="group-subtotal"||g.type==="grand-total")&&g.aggregatedValues){const m=g.aggregatedValues,C=g.type==="grand-total"?"Grand Total":`${p}Subtotal`,b=Jt(f,m,h),_=f.map((v,k)=>k===0?no(zt(C,b[0]),i):x(b[k],Rt(m[v.field])));w+=_.join(i)+`
|
|
11
|
+
`}});else{const g=dn(e,l,n.getRowId);if(g.length===0){console.warn("No rows to export");return}r&&(w+=y()),g.forEach(m=>{const C=f.map(b=>{const _=bn(m,b);return x(_.text,_.fromNonText)});w+=C.join(i)+`
|
|
12
|
+
`});const p=Vt(g,ft(l),t,n.aggregationResult,n.aggregationModel);if(p){const m=f.map(b=>x(h[b.field]?h[b.field].toUpperCase():""));w+=m.join(i)+`
|
|
13
|
+
`;const C=Jt(f,p,h);w+=f.map((b,_)=>x(C[_],Rt(p[b.field]))).join(i)+`
|
|
14
|
+
`}}Er((u?Sh:"")+w,o,"text/csv;charset=utf-8;")}function no(e,t){return t!==""&&e.includes(t)||e.includes('"')||e.includes(`
|
|
15
|
+
`)||e.includes("\r")?`"${e.replace(/"/g,'""')}"`:e}const oo="ogx-xls-text";function kh(e,t){return e.type!=="number"&&e.type!=="date"&&e.type!=="boolean"&&!Rt(t)}function Eh(e){if(!/\.xlsx$/i.test(e))return e;const t=e.replace(/\.xlsx$/i,".xls");return console.warn(`[exportToExcel] "${e}" renamed to "${t}": exportToExcel writes an HTML table that Excel refuses to open as .xlsx. Use exportToExcelAdvanced for a real .xlsx file.`),t}function Mh(e,t,n={}){const{fileName:o="export.xls",sheetName:r="Sheet1",includeHeaders:i=!0,selectedRows:l,groupedRows:c,escapeFormulas:a=!0}=n,u=At(t),f=n.aggregationModel||{},h=(p,m=!1)=>Ae(a?Xn(p,m):p),x=p=>`<td class="${oo}">${p}</td>`;let w=`<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>${Ae(ir(r))}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--><meta charset="UTF-8"><style>.${oo}{mso-number-format:"\\@";}</style></head><body><table border="1">`;i&&(w+="<thead><tr>",u.forEach(p=>{w+=`<th class="${oo}">${h(p.headerName||p.field)}</th>`}),w+="</tr></thead>"),w+="<tbody>";const g=(p,m,C="")=>{const b=C+h(p.text,p.fromNonText);return kh(m,p.raw)?x(b):`<td>${b}</td>`};if(un(c,l))c.forEach(p=>{const m=" ".repeat(p.depth*2);if(p.type==="group-header")w+='<tr style="font-weight:bold;background:#e8eaf6;">',w+=`<td colspan="${u.length}" class="${oo}">${Ae(m)}${h(Yt(p,t))}</td>`,w+="</tr>";else if(p.type==="leaf"&&p.row){const C=p.row;w+="<tr>",u.forEach((b,_)=>{w+=g(bn(C,b),b,_===0?Ae(m):"")}),w+="</tr>"}else if((p.type==="group-subtotal"||p.type==="grand-total")&&p.aggregatedValues){const C=p.aggregatedValues,b=p.type==="grand-total"?"Grand Total":`${m}Subtotal`,_=Jt(u,C,f);w+='<tr style="font-weight:bold;background:#f5f5f5;">',u.forEach((v,k)=>{if(k===0){w+=x(Ae(zt(b,_[0])));return}w+=_[k]?`<td style="text-align:right;">${h(_[k],Rt(C[v.field]))}</td>`:"<td></td>"}),w+="</tr>"}});else{const p=dn(e,l,n.getRowId);if(p.length===0){console.warn("No rows to export");return}p.forEach(C=>{w+="<tr>",u.forEach(b=>{w+=g(bn(C,b),b)}),w+="</tr>"});const m=Vt(p,ft(l),t,n.aggregationResult,n.aggregationModel);if(m){w+='<tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',u.forEach(b=>{w+=f[b.field]?`<td style="text-align:right;font-weight:bold;">${Ae(f[b.field].toUpperCase())}</td>`:"<td></td>"}),w+='</tr><tr style="font-weight:bold;background-color:#f5f5f5;">';const C=Jt(u,m,f);u.forEach((b,_)=>{w+=C[_]?`<td style="text-align:right;">${h(C[_],Rt(m[b.field]))}</td>`:"<td></td>"}),w+="</tr>"}}w+="</tbody></table></body></html>",Er(w,Eh(o),"application/vnd.ms-excel")}function Ah(e,t,n={}){const{fileName:o="export.json",pretty:r=!0,selectedRows:i,groupedRows:l}=n,c=At(t),a=f=>{const h={};return c.forEach(x=>{h[x.field]=fn(f,x)}),h};let u;if(un(l,i)){const f=[],h=[];let x;l.forEach(y=>{if(y.type==="group-header"){const w={group:Yt(y,t),field:y.groupField??"",value:y.groupValue,rows:[],children:[]};for(;f.length>y.depth;)f.pop();f.length===0?h.push(w):(f[f.length-1].children??=[]).push(w),f.push(w)}else y.type==="leaf"&&y.row?f.length>0&&f[f.length-1].rows.push(a(y.row)):y.type==="group-subtotal"&&y.aggregatedValues&&f.length>0?(f[f.length-1].subtotals=Il(y.aggregatedValues,c),f.pop()):y.type==="grand-total"&&y.aggregatedValues&&(x=Il(y.aggregatedValues,c))}),u=x?{groups:h,grandTotal:x}:{groups:h}}else{const f=dn(e,i,n.getRowId);if(f.length===0){console.warn("No rows to export");return}const h=f.map(a),x=Vt(f,ft(i),t,n.aggregationResult,n.aggregationModel);if(x){const y=n.aggregationModel||{},w={};c.forEach(p=>{y[p.field]&&(w[p.field]=y[p.field].toUpperCase())});const g={};c.forEach(p=>{x[p.field]!==void 0&&x[p.field]!==null&&(g[p.field]=x[p.field])}),u={data:h,aggregation:{labels:w,values:g}}}else u=h}Er(r?JSON.stringify(u,null,2):JSON.stringify(u),o,"application/json;charset=utf-8;")}const Ph=/^(?:https?:|data:image\/|blob:)/i,Lh=/^[a-z][a-z\d+.-]*:/i;function Nh(e){const t=e.trim();return t?Ph.test(t)?t:Lh.test(t)?null:t:null}async function Ih(e,t,n){const o=window.open("","_blank");if(!o){console.error("Failed to open print window. Please check your popup blocker settings.");return}o.document.write(`
|
|
16
16
|
<!DOCTYPE html>
|
|
17
17
|
<html>
|
|
18
18
|
<head>
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
</div>
|
|
33
33
|
</body>
|
|
34
34
|
</html>
|
|
35
|
-
`),o.document.close(),await new Promise(r=>setTimeout(r,100));try{let r="Print",i,l,c=null,a=null,u;typeof n=="string"?r=n:typeof n=="object"&&(r=n.title||"Print",i=n.selectedRows,l=n.getRowId,c=n.aggregationResult||null,a=n.aggregationModel||null,u=n.groupedRows);const f=
|
|
35
|
+
`),o.document.close(),await new Promise(r=>setTimeout(r,100));try{let r="Print",i,l,c=null,a=null,u;typeof n=="string"?r=n:typeof n=="object"&&(r=n.title||"Print",i=n.selectedRows,l=n.getRowId,c=n.aggregationResult||null,a=n.aggregationModel||null,u=n.groupedRows);const f=At(t),h=a||{};let x=`<!DOCTYPE html><html><head><title>${Ae(r||"Print")}</title><style>
|
|
36
36
|
body{font-family:Arial,sans-serif;margin:20px;}
|
|
37
37
|
h1{font-size:24px;margin-bottom:20px;}
|
|
38
38
|
table{border-collapse:collapse;width:100%;}
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
tr.group-subtotal{background:#f0f4ff;font-style:italic;}
|
|
44
44
|
tr.grand-total{background:#f5f5f5;font-weight:bold;}
|
|
45
45
|
@media print{body{margin:0;}@page{margin:1cm;}}
|
|
46
|
-
</style></head><body>`;r&&(b+=`<h1>${Oe(r)}</h1>`),b+="<table><thead><tr>",f.forEach(g=>{b+=`<th>${Oe(g.headerName||g.field)}</th>`}),b+="</tr></thead><tbody>";const x=(g,h,m="",C=!1)=>{const{text:y}=wn(g,h),_=h.type==="image"?Fh(y):null;if(_!==null){const v=`<img src="${Oe(_)}" alt="${Oe(h.headerName||h.field)}" style="max-height:40px;border-radius:4px;">`;return C?`<td><div style="display:flex;justify-content:center;">${v}</div></td>`:`<td>${v}</td>`}return`<td>${m}${Oe(y)}</td>`};if(un(u,i))u.forEach(g=>{const h=" ".repeat(g.depth*4);if(g.type==="group-header")b+=`<tr class="group-header"><td colspan="${f.length}">${h}${Oe(Yt(g,t))}</td></tr>`;else if(g.type==="leaf"&&g.row){const m=g.row;b+="<tr>",f.forEach((C,y)=>{b+=x(m,C,y===0?h:"")}),b+="</tr>"}else if((g.type==="group-subtotal"||g.type==="grand-total")&&g.aggregatedValues){const m=g.type==="grand-total",C=Zt(f,g.aggregatedValues,p);b+=`<tr class="${m?"grand-total":"group-subtotal"}">`,f.forEach((y,_)=>{if(_===0){b+=`<td>${m?"":h}${Oe(zt(m?"Grand Total":"Subtotal",C[0]))}</td>`;return}b+=C[_]?`<td style="text-align:right;">${Oe(C[_])}</td>`:"<td></td>"}),b+="</tr>"}});else{const g=dn(e,i,l);if(g.length===0){o.document.body.innerHTML="<h3>No rows to export</h3>";return}g.forEach(m=>{b+="<tr>",f.forEach(C=>{b+=x(m,C,"",!0)}),b+="</tr>"});const h=Vt(g,ut(i),t,c,a);h&&(b+='<tfoot><tr style="font-size:11px;color:#666;background-color:#f5f5f5;">',f.forEach(m=>{b+=p[m.field]?`<td style="text-align:right;font-weight:bold;">${Oe(p[m.field].toUpperCase())}</td>`:"<td></td>"}),b+='</tr><tr style="font-weight:bold;background-color:#f5f5f5;">',Zt(f,h,p).forEach(m=>{b+=m?`<td style="text-align:right;">${Oe(m)}</td>`:"<td></td>"}),b+="</tr></tfoot>")}b+="</tbody></table></body></html>",o.document.open(),o.document.write(b),o.document.close(),o.document.title=r||"Print Preview",o.focus();let w=!1;o.onload=()=>{w||(w=!0,o.print(),setTimeout(()=>{o.close()},100))},setTimeout(()=>{!w&&o&&!o.closed&&(w=!0,o.print(),setTimeout(()=>{o.closed||o.close()},100))},500)}catch(r){if(console.error("Print generation failed:",r),o&&!o.closed){const i=r instanceof Error?r.message:String(r);o.document.body.innerHTML=`<div style="color: red; padding: 20px;"><h3>Error Generating Print Preview</h3><p>${Oe(i)}</p></div>`}}}function Sr(e,t,n){const o=new Blob([e],{type:n}),r=URL.createObjectURL(o),i=document.createElement("a");i.href=r,i.download=t,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}function Oh(e,t){return e.type==="number"?"number":e.type==="boolean"?"boolean":e.type==="date"?"date":typeof t=="number"?"number":typeof t=="boolean"?"boolean":t instanceof Date?"date":"string"}function bn(e){return Number.isNaN(e.getTime())?null:new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()))}const Dh=/^(\d{4})-(\d{2})-(\d{2})$/,$h=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?$/i,Gh=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?$/i;function Hh(e){if(e instanceof Date)return bn(e);if(typeof e=="number")return Number.isFinite(e)?bn(new Date(e)):null;if(typeof e!="string")return;const t=e.trim(),n=Dh.exec(t);if(n){const[o,r,i]=[Number(n[1]),Number(n[2]),Number(n[3])],l=new Date(Date.UTC(o,r-1,i));return l.getUTCMonth()===r-1&&l.getUTCDate()===i?l:void 0}if($h.test(t)){const o=new Date(t.replace(" ","T"));return Number.isNaN(o.getTime())?void 0:bn(o)}}function Bh(e,t){if(t==null||t==="")return null;if(e==="number"){if(typeof t=="number")return Number.isFinite(t)?t:null;if(typeof t=="bigint"){const n=Number(t);return Number.isSafeInteger(n)?n:void 0}if(typeof t=="string"&&Gh.test(t.trim())){const n=Number(t.trim());return Number.isFinite(n)?n:void 0}return}if(e==="boolean"){if(typeof t=="boolean")return t;if(typeof t=="string"){const n=t.trim().toLowerCase();if(n==="true")return!0;if(n==="false")return!1}return}return Hh(t)}function Hs(e){if(e==null)return null;if(typeof e=="string"||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)?e:null;if(e instanceof Date)return bn(e);if(typeof e=="object")try{return JSON.stringify(e)??String(e)}catch{return String(e)}return String(e)}function Wh(e,t){const n=fn(e,t),o=Oh(t,n);if(o!=="string"){const r=Bh(o,n);if(r!=null)return r;if(!t.valueFormatter)return r===null?null:Hs(n)}return t.valueFormatter?gn(e,t,n):Hs(n)}const Bs="#,##0",Vh="#,##0.##";function zh(e){return Number.isInteger(e)?Bs:Vh}function Ws(e,t){if(t?.numFmt)return t.numFmt;if(e.type==="date")return"yyyy-mm-dd"}function Vs(e,t,n){if(!(t?.numFmt||typeof n!="number"||e.type!=="number"))return zh(n)}function Rh(e,t){if(t!=null)return t;const n=e.width??120;return Math.min(60,Math.max(8,(n-5)/7))}function Uh(e){return e.length>=8&&e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71?"png":e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255?"jpeg":e.length>=6&&e[0]===71&&e[1]===73&&e[2]===70&&e[3]===56?"gif":null}function zs(e,t){const n=fn(e,t);return typeof n=="string"&&n?n:null}async function Kh(e){const t=await Promise.allSettled(e.map(async o=>{let r;if(o.startsWith("data:")){const l=o.slice(o.indexOf(",")+1),c=atob(l);r=new Uint8Array(c.length);for(let a=0;a<c.length;a++)r[a]=c.charCodeAt(a)}else{const l=await fetch(o,{mode:"cors"});if(!l.ok)throw new Error(`HTTP ${l.status}`);r=new Uint8Array(await l.arrayBuffer())}const i=Uh(r);if(!i)throw new Error("unsupported image format (only PNG, JPEG and GIF can be embedded)");return{url:o,buffer:r.slice().buffer,ext:i}})),n=new Map;return t.forEach((o,r)=>{o.status==="fulfilled"?n.set(o.value.url,{buffer:o.value.buffer,extension:o.value.ext}):console.warn(`[exportToExcelAdvanced] Cannot embed image "${e[r]}" (CORS/network error or unsupported format — raw URL written as fallback):`,o.reason)}),n}async function jh(e,t,n={}){const{fileName:o="export.xlsx",sheets:r,columnStyles:i={},headerFillColor:l="#f1f5f9",headerTextColor:c="#334155",headerFontSize:a=10,bodyFontSize:u=10,aggregationResult:f=null,aggregationModel:p=null,selectedRows:b,getRowId:x,groupedRows:w,groupHeaderFillColor:g="#e8eaf6",groupSubtotalFillColor:h="#f0f4ff"}=n;let m;try{m=(await import("exceljs")).default}catch{throw new Error("exportToExcelAdvanced requires 'exceljs'. Run: npm install exceljs")}const C=new m.Workbook;C.creator="OpenGridX",C.created=new Date;const y=t,_=Mt(y),v=e,k=ut(b)?yl(v,b,x):[],M=r??[{name:"Data",rows:"all",includeHeaders:!0,includeSummary:!1}],E=new Set,I=new Map,L=(P,A)=>{const G=A[P.field],z=p?.[P.field];if(G==null)return{value:null};const H=ti(P,z,G);return typeof H=="number"?Number.isFinite(H)?ei(z)?{value:H,numFmt:Bs}:{value:H,numFmt:Vs(P,i[P.field],H)}:{value:null}:H instanceof Date?{value:bn(H)}:{value:er(P,z,G,A)}};for(const P of M){if("type"in P&&P.type==="summary"){if(!f||!p)continue;const Q=C.addWorksheet(tr(P.name??"Summary",E));Q.addRow(["Summary / Aggregation Totals"]),Q.getRow(1).font={bold:!0,size:a+2,color:{argb:Re(c)}},Q.addRow([]),Q.addRow(["Column","Function","Value"]).eachCell(O=>{O.fill={type:"pattern",pattern:"solid",fgColor:{argb:Re(l)}},O.font={bold:!0,size:a,color:{argb:Re(c)}},O.border=Rs()}),_.forEach(O=>{const $=p[O.field];if($==null||f[O.field]==null)return;const{value:D,numFmt:V}=L(O,f),oe=Q.addRow([O.headerName??O.field,$.toUpperCase(),D]).getCell(3),Z=V??Ws(O,i[O.field]);Z&&(oe.numFmt=Z),oe.alignment={horizontal:"right"},oe.font={bold:!0,size:u}}),Q.getColumn(1).width=20,Q.getColumn(2).width=12,Q.getColumn(3).width=18;continue}const A=P,{name:G="Data",rows:z="all",includeHeaders:H=!0,includeSummary:Y=!1,autoFilter:K=!0,frozenHeader:re=!0,alternateRowColor:R="#f8fafc"}=A,te=z==="all"&&!!(w&&w.length>0),ie=z==="selected"?k:te?w.flatMap(Q=>Q.type==="leaf"&&Q.row?[Q.row]:[]):v,ce=_.filter(Q=>i[Q.field]?.embedImage);if(ce.length>0){const Q=[],U=new Set;if(ie.forEach(O=>{ce.forEach($=>{const D=zs(O,$);D&&!I.has(D)&&!U.has(D)&&(Q.push(D),U.add(D))})}),Q.length>0){const O=await Kh(Q);for(const[$,{buffer:D,extension:V}]of O){const q=C.addImage({buffer:D,extension:V});I.set($,q)}}}const J=C.addWorksheet(tr(G,E));J.columns=_.map(Q=>({key:Q.field,width:Rh(Q,i[Q.field]?.width),style:{numFmt:Ws(Q,i[Q.field])}}));const se=(Q,U)=>{_.forEach((O,$)=>U(Q.getCell($+1),O,$+1))};if(H){const Q=_.map(O=>O.headerName??O.field),U=J.addRow(Q);U.height=20,se(U,(O,$)=>{O.fill={type:"pattern",pattern:"solid",fgColor:{argb:Re(l)}},O.font={bold:!0,size:a,color:{argb:Re(c)}},O.alignment={horizontal:i[$.field]?.alignment??($.type==="number"?"right":"left"),vertical:"middle"},O.border=Rs()}),K&&(J.autoFilter={from:{row:1,column:1},to:{row:1,column:_.length}}),re?J.views=[{state:"frozen",ySplit:1,showGridLines:!1}]:J.views=[{showGridLines:!1}]}let ne=H?1:0;const j=(Q,U,O)=>{const $=_.map(q=>i[q.field]?.embedImage?"":Wh(Q,q)),D=J.addRow($);D.font={size:u},O>0&&(D.outlineLevel=O);const V=!!R&&U%2===1;if(se(D,(q,oe,Z)=>{const X=Vs(oe,i[oe.field],$[Z-1]);X&&(q.numFmt=X),V&&R&&(q.fill={type:"pattern",pattern:"solid",fgColor:{argb:Re(R)}}),q.alignment={horizontal:i[oe.field]?.alignment??(oe.type==="number"?"right":"left"),vertical:"middle"},q.border={bottom:{style:"thin",color:{argb:"FFf1f5f9"}}}}),ce.length>0){const q=ce.reduce((X,le)=>Math.max(X,i[le.field]?.imageHeight??40),0),oe=Math.ceil(q/1.333),Z=oe*1.333;D.height=oe,ce.forEach(X=>{const le=_.indexOf(X),we=zs(Q,X),ge=we?I.get(we):void 0;if(ge===void 0){D.getCell(le+1).value=we??"";return}const he=i[X.field],ee=he?.imageWidth??40,ue=he?.imageHeight??40,be=(J.getColumn(le+1).width??8)*7+5,me=Math.max(0,be-ee)/2,xe=Math.max(0,Z-ue)/2;J.addImage(ge,{tl:{col:le,row:ne,nativeColOff:Math.floor(me*9525),nativeRowOff:Math.floor(xe*9525)},ext:{width:ee,height:ue},editAs:"oneCell"})})}else D.height=16;ne++},B=Q=>Yt(Q,y),W=(Q,U,O,$,D)=>{const V=_.map((oe,Z)=>Z===0&&U[oe.field]==null?{value:Q}:L(oe,U)),q=J.addRow(V.map(oe=>oe.value));q.height=18,$>0&&(q.outlineLevel=$),q.font={bold:D,italic:!D,size:u,color:{argb:Re(c)}},se(q,(oe,Z,X)=>{const le=V[X-1].numFmt;le&&(oe.numFmt=le),oe.fill={type:"pattern",pattern:"solid",fgColor:{argb:Re(O)}},oe.alignment={horizontal:X===1?"left":Z.type==="number"?"right":"left",vertical:"middle"},oe.border=Us()}),ne++};let ae=!1;if(te){let Q=0;w.forEach(U=>{if(U.type==="group-header"){const O=J.addRow([B(U)]);O.height=18,U.depth>0&&(O.outlineLevel=U.depth),O.font={bold:!0,size:u,color:{argb:Re(c)}};for(let $=1;$<=_.length;$++)O.getCell($).fill={type:"pattern",pattern:"solid",fgColor:{argb:Re(g)}};O.getCell(1).alignment={horizontal:"left",vertical:"middle",indent:U.depth},ne++,Q=0}else U.type==="leaf"&&U.row?j(U.row,Q++,U.depth):U.type==="group-subtotal"&&U.aggregatedValues?W("Subtotal",U.aggregatedValues,h,U.depth,!1):U.type==="grand-total"&&U.aggregatedValues&&(W("Grand Total",U.aggregatedValues,l,0,!0),ae=!0)}),J.properties.outlineProperties={summaryBelow:!0,summaryRight:!1}}else ie.forEach((Q,U)=>j(Q,U,0));const fe=Vt(ie,z==="selected",y,f,p);if(Y&&!ae&&fe&&p){const Q=_.map(D=>{const V=p[D.field];return V?V.toUpperCase():""}),U=J.addRow(Q);U.height=16,U.font={size:u-1,italic:!0,color:{argb:"FF94a3b8"}},se(U,D=>{D.alignment={horizontal:"right",vertical:"middle"},D.border={top:{style:"thin",color:{argb:"FFcbd5e1"}}}});const O=_.map(D=>p[D.field]==null?{value:null}:L(D,fe)),$=J.addRow(O.map(D=>D.value));$.height=18,$.font={bold:!0,size:u,color:{argb:Re(c)}},se($,(D,V,q)=>{const oe=O[q-1].numFmt;oe&&(D.numFmt=oe),D.fill={type:"pattern",pattern:"solid",fgColor:{argb:Re(l)}},D.alignment={horizontal:"right",vertical:"middle"},D.border=Us()})}}const N=await C.xlsx.writeBuffer(),S=new Blob([N],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),F=URL.createObjectURL(S),T=document.createElement("a");T.href=F,T.download=o.endsWith(".xlsx")?o:`${o}.xlsx`,document.body.appendChild(T),T.click(),document.body.removeChild(T),URL.revokeObjectURL(F)}function Re(e){const t=e.replace("#","");return t.length===3?"FF"+t.split("").map(n=>n+n).join(""):t.length===6?"FF"+t:"FF"+t.padEnd(6,"0")}function Rs(){return{bottom:{style:"medium",color:{argb:"FFcbd5e1"}}}}function Us(){return{top:{style:"medium",color:{argb:"FFcbd5e1"}}}}function qh(e,t,n,o){return s.useMemo(()=>o?Ei(e,t,n):Oo,[e,t,n,o])}const Ks={"--ogx-grid-row-selected-background":"var(--ogx-color-primary-light)","--ogx-grid-row-selected-hover-background":"color-mix(in srgb, var(--ogx-color-primary) 14%, var(--ogx-color-primary-light))","--ogx-grid-cell-focus-border":"var(--ogx-color-primary)","--ogx-range-background":"color-mix(in srgb, var(--ogx-color-primary) 12%, transparent)","--ogx-range-border":"var(--ogx-color-primary)","--ogx-fill-handle-color":"var(--ogx-range-border)","--ogx-toolbar-btn-primary-bg":"var(--ogx-color-primary)","--ogx-toolbar-btn-primary-hover":"var(--ogx-color-primary-dark)","--ogx-toolbar-input-focus-border":"var(--ogx-color-primary)","--ogx-toolbar-input-focus-shadow":"0 0 0 3px color-mix(in srgb, var(--ogx-color-primary) 12%, transparent)","--ogx-toolbar-chip-active-bg":"color-mix(in srgb, var(--ogx-color-primary) 12%, transparent)","--ogx-toolbar-chip-active-text":"var(--ogx-color-primary-dark)","--ogx-overlay-item-selected-bg":"color-mix(in srgb, var(--ogx-color-primary) 8%, transparent)","--ogx-overlay-item-selected-text":"var(--ogx-color-primary-dark)"},js={"--ogx-color-primary":"#3b82f6","--ogx-color-primary-dark":"#2563eb","--ogx-color-primary-light":"#eff6ff","--ogx-color-primary-focus":"rgba(59, 130, 246, 0.5)","--ogx-color-secondary":"#8b5cf6","--ogx-color-secondary-dark":"#7c3aed","--ogx-color-secondary-light":"#f5f3ff","--ogx-color-white":"#ffffff","--ogx-color-black":"#0f172a","--ogx-color-gray-50":"#f8fafc","--ogx-color-gray-100":"#f1f5f9","--ogx-color-gray-200":"#e2e8f0","--ogx-color-gray-300":"#cbd5e1","--ogx-color-gray-400":"#94a3b8","--ogx-color-gray-500":"#64748b","--ogx-color-gray-600":"#475569","--ogx-color-gray-700":"#334155","--ogx-color-gray-800":"#1e293b","--ogx-color-gray-900":"#0f172a","--ogx-border-color":"#e2e8f0","--ogx-border-color-hover":"#cbd5e1","--ogx-shadow-sm":"0 1px 2px 0 rgba(0, 0, 0, 0.05)","--ogx-shadow-md":"0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03)","--ogx-shadow-lg":"0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02)","--ogx-grid-background":"#ffffff","--ogx-grid-border-color":"#e2e8f0","--ogx-grid-header-background":"#f8fafc","--ogx-grid-header-text":"#334155","--ogx-grid-header-hover-background":"#f1f5f9","--ogx-grid-header-sorted-background":"#f8fafc","--ogx-grid-row-text":"#1e293b","--ogx-grid-row-hover-background":"#f8fafc","--ogx-grid-row-alternate-background":"transparent","--ogx-checkbox-bg":"#ffffff","--ogx-checkbox-border":"#94a3b8","--ogx-grid-pinned-left-shadow":"4px 0 24px -4px rgba(0, 0, 0, 0.05)","--ogx-grid-pinned-right-shadow":"-4px 0 24px -4px rgba(0, 0, 0, 0.05)",...{"--ogx-toolbar-background":"var(--ogx-grid-header-background)","--ogx-toolbar-text":"var(--ogx-grid-header-text)","--ogx-toolbar-border":"var(--ogx-grid-border-color)","--ogx-toolbar-btn-bg":"transparent","--ogx-toolbar-btn-hover":"var(--ogx-grid-header-hover-background)","--ogx-toolbar-btn-text":"var(--ogx-grid-header-text)","--ogx-toolbar-input-bg":"var(--ogx-grid-background)","--ogx-toolbar-input-text":"var(--ogx-grid-row-text)","--ogx-toolbar-chip-bg":"transparent","--ogx-toolbar-chip-text":"var(--ogx-grid-row-text)"},"--ogx-toolbar-btn-primary-text":"#ffffff","--ogx-toolbar-btn-danger-bg":"rgba(239, 68, 68, 0.08)","--ogx-toolbar-btn-danger-hover":"rgba(239, 68, 68, 0.15)","--ogx-toolbar-btn-danger-text":"#ef4444","--ogx-toolbar-input-border":"#cbd5e1","--ogx-overlay-background":"#ffffff","--ogx-overlay-text":"#1e293b","--ogx-overlay-border":"#e2e8f0","--ogx-overlay-shadow":"0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.06)","--ogx-overlay-item-hover-bg":"#f8fafc","--ogx-overlay-item-hover-text":"#0f172a","--ogx-overlay-item-danger-bg":"rgba(239, 68, 68, 0.08)","--ogx-overlay-item-danger-text":"#ef4444","--ogx-scrollbar-thumb":"#cbd5e1","--ogx-scrollbar-track":"transparent","--ogx-scrollbar-size":"8px","--ogx-skeleton-base":"#f1f5f9","--ogx-skeleton-highlight":"#ffffff",...Ks},Xh={...js,"--ogx-color-primary":"#60a5fa","--ogx-color-primary-dark":"#3b82f6","--ogx-color-primary-light":"#1e3a5f","--ogx-color-primary-focus":"rgba(96, 165, 250, 0.4)","--ogx-color-white":"#0f172a","--ogx-color-black":"#f8fafc","--ogx-color-gray-50":"#1e293b","--ogx-color-gray-100":"#334155","--ogx-color-gray-200":"#475569","--ogx-color-gray-300":"#64748b","--ogx-color-gray-400":"#94a3b8","--ogx-color-gray-500":"#cbd5e1","--ogx-color-gray-600":"#e2e8f0","--ogx-color-gray-700":"#e2e8f0","--ogx-color-gray-800":"#f1f5f9","--ogx-color-gray-900":"#f8fafc","--ogx-border-color":"#334155","--ogx-border-color-hover":"#475569","--ogx-shadow-sm":"0 1px 2px 0 rgba(0, 0, 0, 0.3)","--ogx-shadow-md":"0 4px 6px -1px rgba(0, 0, 0, 0.3)","--ogx-shadow-lg":"0 10px 15px -3px rgba(0, 0, 0, 0.3)","--ogx-grid-background":"#0f172a","--ogx-grid-border-color":"#334155","--ogx-grid-header-background":"#1e293b","--ogx-grid-header-text":"#e2e8f0","--ogx-grid-header-hover-background":"#334155","--ogx-grid-header-sorted-background":"#1e3a5f","--ogx-grid-row-text":"#cbd5e1","--ogx-grid-row-hover-background":"#1e293b","--ogx-grid-row-alternate-background":"#162032","--ogx-checkbox-bg":"#1e293b","--ogx-checkbox-border":"#64748b","--ogx-grid-pinned-left-shadow":"4px 0 24px -4px rgba(0, 0, 0, 0.3)","--ogx-grid-pinned-right-shadow":"-4px 0 24px -4px rgba(0, 0, 0, 0.3)","--ogx-toolbar-btn-danger-bg":"rgba(239, 68, 68, 0.15)","--ogx-toolbar-btn-danger-hover":"rgba(239, 68, 68, 0.25)","--ogx-toolbar-btn-danger-text":"#fca5a5","--ogx-toolbar-input-border":"#334155","--ogx-overlay-background":"#1e293b","--ogx-overlay-text":"#cbd5e1","--ogx-overlay-border":"#334155","--ogx-overlay-shadow":"0 4px 6px -1px rgba(0,0,0,0.4), 0 2px 4px -1px rgba(0,0,0,0.3), 0 0 0 1px rgba(0,0,0,0.2)","--ogx-overlay-item-hover-bg":"#334155","--ogx-overlay-item-hover-text":"#f1f5f9","--ogx-overlay-item-danger-bg":"rgba(239, 68, 68, 0.15)","--ogx-overlay-item-danger-text":"#fca5a5","--ogx-scrollbar-thumb":"#475569","--ogx-skeleton-base":"#1e293b","--ogx-skeleton-highlight":"#334155",...Ks,"--ogx-toolbar-chip-active-text":"var(--ogx-color-primary)","--ogx-overlay-item-selected-text":"var(--ogx-color-primary)"},Yh=[50,100,200,300,400,500,600,700,800,900];function Jh(e){const t={};function n(o,r){r!==void 0&&(t[o]=r)}if(e.colors){const o=e.colors;if(n("--ogx-color-primary",o.primary),n("--ogx-color-primary-dark",o.primaryDark),n("--ogx-color-primary-light",o.primaryLight),n("--ogx-color-primary-focus",o.primaryFocus),n("--ogx-color-secondary",o.secondary),n("--ogx-color-secondary-dark",o.secondaryDark),n("--ogx-color-secondary-light",o.secondaryLight),n("--ogx-color-success",o.success),n("--ogx-color-warning",o.warning),n("--ogx-color-error",o.error),n("--ogx-color-info",o.info),n("--ogx-color-white",o.white),n("--ogx-color-black",o.black),o.gray)for(const r of Yh)n(`--ogx-color-gray-${r}`,o.gray[r])}if(e.typography){const o=e.typography;n("--ogx-font-family",o.fontFamily),n("--ogx-font-family-mono",o.fontFamilyMono),n("--ogx-font-size-xs",o.fontSizeXs),n("--ogx-font-size-sm",o.fontSizeSm),n("--ogx-font-size-md",o.fontSizeMd),n("--ogx-font-size-lg",o.fontSizeLg),n("--ogx-font-size-xl",o.fontSizeXl)}if(e.spacing){const o=e.spacing;n("--ogx-spacing-xs",o.xs),n("--ogx-spacing-sm",o.sm),n("--ogx-spacing-md",o.md),n("--ogx-spacing-lg",o.lg),n("--ogx-spacing-xl",o.xl),n("--ogx-spacing-xxl",o.xxl)}if(e.borders){const o=e.borders;n("--ogx-border-width-thin",o.widthThin),n("--ogx-border-width-medium",o.widthMedium),n("--ogx-border-width-thick",o.widthThick),n("--ogx-border-radius-sm",o.radiusSm),n("--ogx-border-radius-md",o.radiusMd),n("--ogx-border-radius-lg",o.radiusLg),n("--ogx-border-radius-xl",o.radiusXl),n("--ogx-border-color",o.color),n("--ogx-border-color-hover",o.colorHover)}if(e.shadows){const o=e.shadows;n("--ogx-shadow-sm",o.sm),n("--ogx-shadow-md",o.md),n("--ogx-shadow-lg",o.lg),n("--ogx-shadow-xl",o.xl)}if(e.grid){const o=e.grid;n("--ogx-grid-row-height-compact",o.rowHeightCompact),n("--ogx-grid-row-height-standard",o.rowHeightStandard),n("--ogx-row-height",o.rowHeightStandard),n("--ogx-grid-row-height-comfortable",o.rowHeightComfortable),n("--ogx-grid-header-height",o.headerHeight),n("--ogx-header-height",o.headerHeight),n("--ogx-grid-cell-padding-x",o.cellPaddingX),n("--ogx-grid-cell-padding-y",o.cellPaddingY),n("--ogx-grid-cell-font-size",o.cellFontSize),n("--ogx-grid-header-font-size",o.headerFontSize),n("--ogx-grid-header-font-family",o.headerFontFamily),n("--ogx-grid-header-font-weight",o.headerFontWeight),n("--ogx-grid-cell-font-family",o.cellFontFamily),n("--ogx-grid-cell-font-weight",o.cellFontWeight),n("--ogx-grid-header-padding-x",o.headerPaddingX),n("--ogx-grid-border-width",o.borderWidth),n("--ogx-grid-border-radius",o.borderRadius),n("--ogx-grid-column-divider-width",o.columnDividerWidth),n("--ogx-grid-header-column-divider-width",o.headerColumnDividerWidth),n("--ogx-grid-row-divider-width",o.rowDividerWidth),n("--ogx-grid-column-divider-color",o.columnDividerColor),n("--ogx-grid-row-divider-color",o.rowDividerColor),n("--ogx-grid-background",o.background),n("--ogx-grid-border-color",o.borderColor),n("--ogx-grid-header-background",o.headerBackground),n("--ogx-grid-header-text",o.headerText),n("--ogx-grid-header-hover-background",o.headerHoverBackground),n("--ogx-grid-header-sorted-background",o.headerSortedBackground),n("--ogx-grid-row-text",o.rowText),n("--ogx-grid-row-hover-background",o.rowHoverBackground),n("--ogx-grid-row-alternate-background",o.rowAlternateBackground),n("--ogx-grid-row-selected-background",o.rowSelectedBackground),n("--ogx-grid-row-selected-hover-background",o.rowSelectedHoverBackground),n("--ogx-grid-cell-focus-border",o.cellFocusBorder),n("--ogx-range-background",o.rangeBackground),n("--ogx-range-border",o.rangeBorder),n("--ogx-fill-handle-color",o.fillHandleColor),n("--ogx-grid-pinned-left-shadow",o.pinnedLeftShadow),n("--ogx-grid-pinned-right-shadow",o.pinnedRightShadow),n("--ogx-checkbox-bg",o.checkboxBg),n("--ogx-checkbox-border",o.checkboxBorder),n("--ogx-checkbox-checked-bg",o.checkboxCheckedBackground),n("--ogx-checkbox-checkmark",o.checkboxCheckmark),n("--ogx-expand-icon-color",o.expandIconColor),n("--ogx-expand-icon-hover-color",o.expandIconHoverColor)}if(e.transitions){const o=e.transitions;n("--ogx-transition-duration-fast",o.durationFast),n("--ogx-transition-duration-normal",o.durationNormal),n("--ogx-transition-duration-slow",o.durationSlow),n("--ogx-transition-easing",o.easing)}if(e.toolbar){const o=e.toolbar;n("--ogx-toolbar-background",o.background),n("--ogx-toolbar-text",o.text),n("--ogx-toolbar-border",o.border),n("--ogx-toolbar-btn-bg",o.buttonBackground),n("--ogx-toolbar-btn-hover",o.buttonHoverBackground),n("--ogx-toolbar-btn-text",o.buttonText),n("--ogx-toolbar-btn-primary-bg",o.buttonPrimaryBackground),n("--ogx-toolbar-btn-primary-hover",o.buttonPrimaryHoverBackground),n("--ogx-toolbar-btn-primary-text",o.buttonPrimaryText),n("--ogx-toolbar-btn-danger-bg",o.buttonDangerBackground),n("--ogx-toolbar-btn-danger-hover",o.buttonDangerHoverBackground),n("--ogx-toolbar-btn-danger-text",o.buttonDangerText),n("--ogx-toolbar-input-bg",o.inputBackground),n("--ogx-toolbar-input-text",o.inputText),n("--ogx-toolbar-input-border",o.inputBorder),n("--ogx-toolbar-input-focus-border",o.inputFocusBorder),n("--ogx-toolbar-input-focus-shadow",o.inputFocusShadow),n("--ogx-toolbar-chip-bg",o.chipBackground),n("--ogx-toolbar-chip-text",o.chipText),n("--ogx-toolbar-chip-active-bg",o.chipActiveBackground),n("--ogx-toolbar-chip-active-text",o.chipActiveText)}if(e.overlays){const o=e.overlays;n("--ogx-overlay-background",o.background),n("--ogx-overlay-text",o.text),n("--ogx-overlay-border",o.border),n("--ogx-overlay-shadow",o.shadow),n("--ogx-overlay-item-hover-bg",o.itemHoverBackground),n("--ogx-overlay-item-hover-text",o.itemHoverText),n("--ogx-overlay-item-selected-bg",o.itemSelectedBackground),n("--ogx-overlay-item-selected-text",o.itemSelectedText),n("--ogx-overlay-item-danger-bg",o.itemDangerBackground),n("--ogx-overlay-item-danger-text",o.itemDangerText),n("--ogx-overlay-item-indicator",o.itemIndicatorColor),n("--ogx-overlay-item-selected-icon",o.itemSelectedIcon),n("--ogx-overlay-icon",o.iconColor),n("--ogx-overlay-section-label-text",o.sectionLabelText),n("--ogx-overlay-divider",o.dividerColor),n("--ogx-overlay-font-family",o.fontFamily),n("--ogx-overlay-font-weight",o.fontWeight),n("--ogx-overlay-font-size",o.fontSize)}if(e.scrollbar){const o=e.scrollbar;n("--ogx-scrollbar-thumb",o.thumbColor),n("--ogx-scrollbar-track",o.trackColor),n("--ogx-scrollbar-size",o.size)}if(e.skeleton){const o=e.skeleton;n("--ogx-skeleton-base",o.baseColor),n("--ogx-skeleton-highlight",o.highlightColor)}return t}function Zh({theme:e,children:t,className:n,style:o}){const r=s.useMemo(()=>({...e.mode==="dark"?Xh:js,...Jh(e)}),[e]);return d.jsx(Wi.Provider,{value:e,children:d.jsx("div",{className:`ogx-theme-provider ${n||""}`.trim(),style:{...o,...r},children:t})})}const Qh={mode:"dark",colors:{primary:"#60a5fa",primaryDark:"#3b82f6",primaryLight:"#1e3a5f",primaryFocus:"rgba(96, 165, 250, 0.4)"},grid:{background:"#0f172a",headerBackground:"#1e293b",headerText:"#e2e8f0",headerHoverBackground:"#334155",headerSortedBackground:"#1e3a5f",rowText:"#cbd5e1",borderColor:"#334155",rowHoverBackground:"#1e293b",rowAlternateBackground:"#162032",rowSelectedBackground:"#1e3a5f",rowSelectedHoverBackground:"#1d4ed8",cellFocusBorder:"#60a5fa",rangeBackground:"rgba(96, 165, 250, 0.18)",rangeBorder:"#60a5fa",checkboxBg:"#1e293b",checkboxBorder:"#64748b"},borders:{color:"#334155",colorHover:"#475569"},shadows:{sm:"0 1px 2px 0 rgba(0, 0, 0, 0.3)",md:"0 4px 6px -1px rgba(0, 0, 0, 0.3)"},toolbar:{background:"#1e293b",text:"#cbd5e1",border:"#334155",buttonBackground:"transparent",buttonHoverBackground:"#334155",buttonText:"#e2e8f0",buttonPrimaryBackground:"#3b82f6",buttonPrimaryHoverBackground:"#2563eb",buttonPrimaryText:"#ffffff",buttonDangerBackground:"rgba(239, 68, 68, 0.15)",buttonDangerHoverBackground:"rgba(239, 68, 68, 0.25)",buttonDangerText:"#fca5a5",inputBackground:"#0f172a",inputText:"#f8fafc",inputBorder:"#334155",inputFocusBorder:"#60a5fa",inputFocusShadow:"0 0 0 3px rgba(96, 165, 250, 0.2)",chipBackground:"#1e293b",chipText:"#94a3b8",chipActiveBackground:"rgba(96, 165, 250, 0.2)",chipActiveText:"#60a5fa"},overlays:{background:"#1e293b",text:"#f8fafc",border:"#334155",shadow:"0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3)",itemHoverBackground:"#334155",itemHoverText:"#ffffff",itemSelectedBackground:"rgba(96, 165, 250, 0.15)",itemSelectedText:"#60a5fa",itemDangerBackground:"rgba(239, 68, 68, 0.15)",itemDangerText:"#fca5a5"},scrollbar:{thumbColor:"rgba(148, 163, 184, 0.2)",trackColor:"transparent"},skeleton:{baseColor:"#1e293b",highlightColor:"#334155"}},em={colors:{primary:"#e11d48",primaryDark:"#be123c",primaryLight:"#fff1f2",primaryFocus:"rgba(225, 29, 72, 0.4)"},grid:{headerBackground:"#fff1f2",headerHoverBackground:"#ffe4e6",headerSortedBackground:"#fecdd3",rowAlternateBackground:"#fff8f8",rowSelectedBackground:"#ffe4e6",rowSelectedHoverBackground:"#fecdd3",cellFocusBorder:"#e11d48",rangeBackground:"rgba(225, 29, 72, 0.10)",rangeBorder:"#e11d48"}},tm={colors:{primary:"#059669",primaryDark:"#047857",primaryLight:"#ecfdf5",primaryFocus:"rgba(5, 150, 105, 0.4)"},grid:{headerBackground:"#ecfdf5",headerHoverBackground:"#d1fae5",headerSortedBackground:"#a7f3d0",rowAlternateBackground:"#f6fdf9",rowSelectedBackground:"#d1fae5",rowSelectedHoverBackground:"#a7f3d0",cellFocusBorder:"#059669",rangeBackground:"rgba(5, 150, 105, 0.12)",rangeBorder:"#059669"}},nm={colors:{primary:"#d97706",primaryDark:"#b45309",primaryLight:"#fffbeb",primaryFocus:"rgba(217, 119, 6, 0.4)"},grid:{headerBackground:"#fffbeb",headerHoverBackground:"#fef3c7",headerSortedBackground:"#fde68a",rowAlternateBackground:"#fffdf5",rowSelectedBackground:"#fef3c7",rowSelectedHoverBackground:"#fde68a",cellFocusBorder:"#d97706",rangeBackground:"rgba(217, 119, 6, 0.12)",rangeBorder:"#d97706"}},om={grid:{rowHeightCompact:"28px",rowHeightStandard:"36px",rowHeightComfortable:"48px",headerHeight:"40px",cellPaddingX:"8px",cellPaddingY:"4px",cellFontSize:"12px",headerFontSize:"12px"},typography:{fontSizeSm:"0.8rem",fontSizeMd:"0.875rem"}};function rm(){if(!(typeof window>"u"))try{return window.localStorage}catch{return}}function qs(e,t){try{const n=t.getItem(e);return n?JSON.parse(n):void 0}catch{return}}function im(e,t,n,o){try{const r=n?Object.fromEntries(Object.entries(t).filter(([i])=>n.includes(i))):t;o.setItem(e,JSON.stringify(r))}catch{}}function lm(e){const t=typeof e=="string"?{key:e}:e,{key:n,debounceMs:o=300,include:r,storage:i}=t,[l]=s.useState(rm),c=i??l,a=s.useRef(r),u=s.useRef(c);s.useLayoutEffect(()=>{a.current=r,u.current=c});const[f,p]=s.useState(()=>({key:n,state:c?qs(n,c):void 0}));let b=f.state;f.key!==n&&(b=c?qs(n,c):void 0,p({key:n,state:b}));const x=s.useRef(null),w=s.useRef(null),g=s.useCallback(()=>{x.current&&(clearTimeout(x.current),x.current=null);const C=w.current;w.current=null;const y=u.current;C&&y&&im(C.key,C.state,a.current,y)},[]),h=s.useCallback(C=>{w.current&&w.current.key!==n&&g(),w.current={key:n,state:C},x.current&&clearTimeout(x.current),x.current=setTimeout(g,o)},[n,g,o]);s.useEffect(()=>g,[g]);const m=s.useCallback(()=>{x.current&&(clearTimeout(x.current),x.current=null),w.current=null;const C=u.current;if(C)try{C.removeItem(n)}catch{}},[n]);return s.useMemo(()=>({initialState:b,onStateChange:h,clearState:m}),[b,h,m])}ke.Button=et,ke.Cell=ds,ke.CellSelectionStats=ps,ke.Checkbox=gt,ke.ColumnVisibilityPanel=dr,ke.DataGrid=Rp,ke.DataGridThemeProvider=Zh,ke.FilterPanel=Es,ke.GridToolbar=ah,ke.GridTooltip=mn,ke.Header=ss,ke.Input=tt,ke.Pagination=ur,ke.Row=Jn,ke.Skeleton=Up,ke.amberTheme=nm,ke.compactTheme=om,ke.darkTheme=Qh,ke.emeraldTheme=tm,ke.exportToCsv=Eh,ke.exportToExcel=Ah,ke.exportToExcelAdvanced=jh,ke.exportToJson=Ph,ke.exportToPdf=Sh,ke.formatAggregationValue=rn,ke.printGrid=Th,ke.roseTheme=em,ke.useAggregation=Yl,ke.useGridApiRef=ch,ke.useGridStateStorage=lm,ke.usePivot=qh,Object.defineProperty(ke,Symbol.toStringTag,{value:"Module"})}));
|
|
46
|
+
</style></head><body>`;r&&(x+=`<h1>${Ae(r)}</h1>`),x+="<table><thead><tr>",f.forEach(g=>{x+=`<th>${Ae(g.headerName||g.field)}</th>`}),x+="</tr></thead><tbody>";const y=(g,p,m="",C=!1)=>{const{text:b}=bn(g,p),_=p.type==="image"?Nh(b):null;if(_!==null){const v=`<img src="${Ae(_)}" alt="${Ae(p.headerName||p.field)}" style="max-height:40px;border-radius:4px;">`;return C?`<td><div style="display:flex;justify-content:center;">${v}</div></td>`:`<td>${v}</td>`}return`<td>${m}${Ae(b)}</td>`};if(un(u,i))u.forEach(g=>{const p=" ".repeat(g.depth*4);if(g.type==="group-header")x+=`<tr class="group-header"><td colspan="${f.length}">${p}${Ae(Yt(g,t))}</td></tr>`;else if(g.type==="leaf"&&g.row){const m=g.row;x+="<tr>",f.forEach((C,b)=>{x+=y(m,C,b===0?p:"")}),x+="</tr>"}else if((g.type==="group-subtotal"||g.type==="grand-total")&&g.aggregatedValues){const m=g.type==="grand-total",C=Jt(f,g.aggregatedValues,h);x+=`<tr class="${m?"grand-total":"group-subtotal"}">`,f.forEach((b,_)=>{if(_===0){x+=`<td>${m?"":p}${Ae(zt(m?"Grand Total":"Subtotal",C[0]))}</td>`;return}x+=C[_]?`<td style="text-align:right;">${Ae(C[_])}</td>`:"<td></td>"}),x+="</tr>"}});else{const g=dn(e,i,l);if(g.length===0){o.document.body.innerHTML="<h3>No rows to export</h3>";return}g.forEach(m=>{x+="<tr>",f.forEach(C=>{x+=y(m,C,"",!0)}),x+="</tr>"});const p=Vt(g,ft(i),t,c,a);p&&(x+='<tfoot><tr style="font-size:11px;color:#666;background-color:#f5f5f5;">',f.forEach(m=>{x+=h[m.field]?`<td style="text-align:right;font-weight:bold;">${Ae(h[m.field].toUpperCase())}</td>`:"<td></td>"}),x+='</tr><tr style="font-weight:bold;background-color:#f5f5f5;">',Jt(f,p,h).forEach(m=>{x+=m?`<td style="text-align:right;">${Ae(m)}</td>`:"<td></td>"}),x+="</tr></tfoot>")}x+="</tbody></table></body></html>",o.document.open(),o.document.write(x),o.document.close(),o.document.title=r||"Print Preview",o.focus();let w=!1;o.onload=()=>{w||(w=!0,o.print(),setTimeout(()=>{o.close()},100))},setTimeout(()=>{!w&&o&&!o.closed&&(w=!0,o.print(),setTimeout(()=>{o.closed||o.close()},100))},500)}catch(r){if(console.error("Print generation failed:",r),o&&!o.closed){const i=r instanceof Error?r.message:String(r);o.document.body.innerHTML=`<div style="color: red; padding: 20px;"><h3>Error Generating Print Preview</h3><p>${Ae(i)}</p></div>`}}}const Fh=new Set([8364,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,381,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,382,376]);function Th(e){return e>=8192&&e<=8202||e===8239||e===8287||e===12288?" ":e>=8203&&e<=8205||e===8288||e===65279?"":e===8208||e===8209||e===8210||e===8722?"-":null}function Oh(e){let t="",n=!1;for(const o of e){const r=o.codePointAt(0)??0;if(r<=255||Fh.has(r)){t+=o;continue}const i=Th(r);i!==null?t+=i:(t+="?",n=!0)}return{text:t,lossy:n}}const Dh={sliceMs:30,renderChunkRows:40},$h=2e4;function $s(){return new Promise(e=>setTimeout(e,0))}function Gh(){return new DOMException("PDF export was aborted","AbortError")}const Zt=()=>typeof performance<"u"?performance.now():Date.now(),Gs=e=>Math.max(2,Math.floor(e/2)*2),Hh=[79,70,229],Bh=[255,255,255];function Hs(e,t){const n=e.trim().replace(/^#/,""),o=/^[a-f\d]{3}$/i.test(n)?n.split("").map(i=>i+i).join(""):n,r=/^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(o);return r?[parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16)]:t}function Bs(e,t){return gn(e,t,fn(e,t))}function Ws(e){return(typeof e.width=="number"?e.width:void 0)??(e.flex??1)*100}function Wh(e,t){const n=e.reduce((r,i)=>r+Ws(i),0),o={};return e.forEach((r,i)=>{o[i]={cellWidth:Ws(r)/n*t}}),o}const Vh=new Set(["isEmpty","isNotEmpty"]);function zh(e,t){const o=t.find(l=>l.field===e.field)?.headerName??e.field;if(Vh.has(e.operator))return`${o} ${e.operator}`;const{value:r}=e;if(r==null||r===""||Array.isArray(r)&&r.length===0)return null;const i=Array.isArray(r)?r.map(String).join(", "):String(r);return`${o} ${e.operator} "${i}"`}function Vs(e,t,n,o){const r=e.map(l=>"items"in l?Vs(l.items,l.logicOperator,n,!0):zh(l,n)).filter(l=>!!l);if(r.length===0)return"";const i=r.join(t==="or"?" OR ":" AND ");return o&&r.length>1?`(${i})`:i}function Rh(e,t){const n=[],o=Vs(e.items??[],e.logicOperator??"and",t,!1);o&&n.push(o);const r=(e.quickFilterValues??[]).filter(i=>i.trim()!=="");return r.length>0&&n.push(`Search: ${r.map(i=>`"${i}"`).join(" ")}`),n.join(" • ")}const Uh=1.15*.3528;function Kh(e,t,n={}){return jh(e,t,n,Dh)}async function jh(e,t,n,o){const{signal:r,onProgress:i}=n,l=()=>{if(r?.aborted)throw Gh()};l();let c,a;try{const[le,ce]=await Promise.all([import("jspdf"),import("jspdf-autotable")]);c=le.default,a=ce.default}catch{throw new Error("exportToPdf requires 'jspdf' and 'jspdf-autotable'. Run: npm install jspdf jspdf-autotable")}const{fileName:u="export",title:f,logoUrl:h,orientation:x="landscape",selectedRows:y,getRowId:w,aggregationResult:g,aggregationModel:p,filterModel:m,alternateRowColor:C=!0,headerBackgroundColor:b="#4f46e5",headerTextColor:_="#ffffff",fontSize:v=9,groupedRows:k,font:A,maxRows:M=$h}=n;l();let N=Zt();const P=async()=>{Zt()-N<o.sliceMs||(await $s(),l(),N=Zt())},T=(le,ce,de)=>{i?.({phase:le,done:ce,total:de})},S=new c({orientation:x,unit:"mm",format:"a4"}),I=S.internal.pageSize.getWidth(),F=S.internal.pageSize.getHeight(),L=14,E=I-L*2;let O="helvetica";A&&(S.addFileToVFS(`${A.name}-normal.ttf`,A.data),S.addFont(`${A.name}-normal.ttf`,A.name,"normal"),A.boldData&&S.addFileToVFS(`${A.name}-bold.ttf`,A.boldData),S.addFont(A.boldData?`${A.name}-bold.ttf`:`${A.name}-normal.ttf`,A.name,"bold"),O=A.name);let B=!1;const H=le=>{if(A)return le;const ce=Oh(le);return ce.lossy&&(B=!0),ce.text},K=(le,ce,de,we,me)=>{const pe=S.splitTextToSize(H(le),we);return S.text(pe.length===1?pe[0]:pe,ce,de),Math.max(0,pe.length-1)*me*Uh},R=At(t),X=un(k,y),j=dn(e,y,w);let Q=L;if(f){let le=L,ce=L+8;if(h)try{S.addImage(h,"PNG",le,L,10,10),le+=14}catch{}const de=I-L-le;S.setFontSize(16),S.setFont(O,"bold"),S.setTextColor(30,41,59),ce+=K(f,le,ce,de,16),ce+=6,S.setFontSize(8),S.setFont(O,"normal"),S.setTextColor(100,116,139);const we=new Date().toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),me=X?k.filter(pe=>pe.type==="leaf").length:j.length;if(S.text(H(`Exported: ${we} • ${me} row${me!==1?"s":""}`),le,ce),ce+=5,m){const pe=Rh(m,t);pe&&(ce+=K(`Filters: ${pe}`,le,ce,de,8),ce+=5)}S.setDrawColor(226,232,240),S.setLineWidth(.3),S.line(L,ce+2,I-L,ce+2),Q=ce+6}const U=[R.map(le=>H(le.headerName??le.field))],re=p||{},q=le=>R.map(ce=>rr(ce,re[ce.field],le[ce.field],le)),se=[];let Z;const $=le=>{se.push(le.map(H))};if(X){const le=k.length;T("prepare",0,le);for(let ce=0;ce<le;ce++){const de=k[ce],we=" ".repeat(de.depth*2);if(de.type==="group-header"){const me=`${we}${Yt(de,t)}`;$(R.map((pe,oe)=>oe===0?me:""))}else if(de.type==="leaf"&&de.row){const me=de.row;$(R.map((pe,oe)=>(oe===0?we:"")+Bs(me,pe)))}else if(de.type==="group-subtotal"&&de.aggregatedValues){const me=q(de.aggregatedValues);$(me.map((pe,oe)=>oe===0?`${we}${zt("Subtotal",pe)}`:pe))}else de.type==="grand-total"&&de.aggregatedValues&&(Z=[q(de.aggregatedValues).map((pe,oe)=>oe===0?zt("Grand Total",pe):pe).map(H)]);(ce&63)===63&&(T("prepare",ce+1,le),await P())}T("prepare",le,le)}else{const le=j.length;T("prepare",0,le);for(let de=0;de<le;de++)$(R.map(we=>Bs(j[de],we))),(de&63)===63&&(T("prepare",de+1,le),await P());const ce=p?Vt(j,ft(y),t,g,p):null;if(ce&&p){const de=R.some(me=>p[me.field]);Z=[q(ce).map((me,pe)=>pe===0&&de?zt("TOTAL",me):me).map(H)]}T("prepare",le,le)}l(),se.length>M&&process.env.NODE_ENV!=="production"&&console.warn(`[exportToPdf] Exporting ${se.length} table rows (maxRows: ${M}). PDFs this large are slow to build and open and can reach tens of MB. Prefer exportToCsv or exportToExcelAdvanced for full-dataset exports, or pass a larger \`maxRows\` to silence this warning.`),B&&console.warn('[exportToPdf] Some characters cannot be drawn with the built-in Helvetica font and were replaced with "?". Pass the `font` option (a Unicode .ttf, e.g. Noto Sans) to draw them.');const D=Wh(R,E),[G,W,ee]=Hs(b,Hh),[V,Y,J]=Hs(_,Bh),te={head:U,styles:{fontSize:v,cellPadding:3,font:O,overflow:"linebreak"},headStyles:{fillColor:[G,W,ee],textColor:[V,Y,J],fontStyle:"bold"},...C?{alternateRowStyles:{fillColor:[248,250,252]}}:{},...Z?{footStyles:{fillColor:[241,245,249],fontStyle:"bold",textColor:[0,0,0]}}:{},columnStyles:D,showHead:"everyPage",margin:{top:L,left:L,right:L,bottom:L+6}},ne=se.length;T("render",0,ne);let z=0,ie=Gs(o.renderChunkRows);do{const le=se.slice(z,z+ie),ce=z===0,de=z+le.length>=ne,we=ce?Q:S.lastAutoTable.finalY;let me=!0;const pe=Zt();a(S,{...te,body:le,...de&&Z?{foot:Z}:{},startY:ce?Q:L,showFoot:de&&Z?"lastPage":"never",...ce?{}:{willDrawPage:ue=>{me?(me=!1,ue.settings.showHead="never",ue.cursor&&(ue.cursor.y=we)):ue.settings.showHead="everyPage"}}}),z+=le.length,T("render",z,ne);const oe=Zt()-pe;ie=Gs(oe>0?Math.min(ie*4,ie*(o.sliceMs/oe)):ie*4),de||(await $s(),l(),N=Zt())}while(z<ne);const ae=S.getNumberOfPages();for(let le=1;le<=ae;le++)S.setPage(le),S.setFontSize(8),S.setTextColor(150,150,150),S.text(`Page ${le} of ${ae}`,I-L,F-8,{align:"right"}),await P();l(),T("save",0,1),S.save(`${u}.pdf`),T("save",1,1)}function qh(e,t){return e.type==="number"?"number":e.type==="boolean"?"boolean":e.type==="date"?"date":typeof t=="number"?"number":typeof t=="boolean"?"boolean":t instanceof Date?"date":"string"}function xn(e){return Number.isNaN(e.getTime())?null:new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()))}const Xh=/^(\d{4})-(\d{2})-(\d{2})$/,Yh=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?$/i,Jh=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?$/i;function Zh(e){if(e instanceof Date)return xn(e);if(typeof e=="number")return Number.isFinite(e)?xn(new Date(e)):null;if(typeof e!="string")return;const t=e.trim(),n=Xh.exec(t);if(n){const[o,r,i]=[Number(n[1]),Number(n[2]),Number(n[3])],l=new Date(Date.UTC(o,r-1,i));return l.getUTCMonth()===r-1&&l.getUTCDate()===i?l:void 0}if(Yh.test(t)){const o=new Date(t.replace(" ","T"));return Number.isNaN(o.getTime())?void 0:xn(o)}}function Qh(e,t){if(t==null||t==="")return null;if(e==="number"){if(typeof t=="number")return Number.isFinite(t)?t:null;if(typeof t=="bigint"){const n=Number(t);return Number.isSafeInteger(n)?n:void 0}if(typeof t=="string"&&Jh.test(t.trim())){const n=Number(t.trim());return Number.isFinite(n)?n:void 0}return}if(e==="boolean"){if(typeof t=="boolean")return t;if(typeof t=="string"){const n=t.trim().toLowerCase();if(n==="true")return!0;if(n==="false")return!1}return}return Zh(t)}function zs(e){if(e==null)return null;if(typeof e=="string"||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)?e:null;if(e instanceof Date)return xn(e);if(typeof e=="object")try{return JSON.stringify(e)??String(e)}catch{return String(e)}return String(e)}function em(e,t){const n=fn(e,t),o=qh(t,n);if(o!=="string"){const r=Qh(o,n);if(r!=null)return r;if(!t.valueFormatter)return r===null?null:zs(n)}return t.valueFormatter?gn(e,t,n):zs(n)}const Rs="#,##0",tm="#,##0.##";function nm(e){return Number.isInteger(e)?Rs:tm}function Us(e,t){if(t?.numFmt)return t.numFmt;if(e.type==="date")return"yyyy-mm-dd"}function Ks(e,t,n){if(!(t?.numFmt||typeof n!="number"||e.type!=="number"))return nm(n)}function om(e,t){if(t!=null)return t;const n=e.width??120;return Math.min(60,Math.max(8,(n-5)/7))}function rm(e){return e.length>=8&&e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71?"png":e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255?"jpeg":e.length>=6&&e[0]===71&&e[1]===73&&e[2]===70&&e[3]===56?"gif":null}function js(e,t){const n=fn(e,t);return typeof n=="string"&&n?n:null}async function im(e){const t=await Promise.allSettled(e.map(async o=>{let r;if(o.startsWith("data:")){const l=o.slice(o.indexOf(",")+1),c=atob(l);r=new Uint8Array(c.length);for(let a=0;a<c.length;a++)r[a]=c.charCodeAt(a)}else{const l=await fetch(o,{mode:"cors"});if(!l.ok)throw new Error(`HTTP ${l.status}`);r=new Uint8Array(await l.arrayBuffer())}const i=rm(r);if(!i)throw new Error("unsupported image format (only PNG, JPEG and GIF can be embedded)");return{url:o,buffer:r.slice().buffer,ext:i}})),n=new Map;return t.forEach((o,r)=>{o.status==="fulfilled"?n.set(o.value.url,{buffer:o.value.buffer,extension:o.value.ext}):console.warn(`[exportToExcelAdvanced] Cannot embed image "${e[r]}" (CORS/network error or unsupported format — raw URL written as fallback):`,o.reason)}),n}function ze(e){const t=e.replace("#","");return t.length===3?"FF"+t.split("").map(n=>n+n).join(""):t.length===6?"FF"+t:"FF"+t.padEnd(6,"0")}function qs(){return{bottom:{style:"medium",color:{argb:"FFcbd5e1"}}}}function Xs(){return{top:{style:"medium",color:{argb:"FFcbd5e1"}}}}async function lm(e,t,n={}){const{fileName:o="export.xlsx",sheets:r,columnStyles:i={},headerFillColor:l="#f1f5f9",headerTextColor:c="#334155",headerFontSize:a=10,bodyFontSize:u=10,aggregationResult:f=null,aggregationModel:h=null,selectedRows:x,getRowId:y,groupedRows:w,groupHeaderFillColor:g="#e8eaf6",groupSubtotalFillColor:p="#f0f4ff"}=n;let m;try{m=(await import("exceljs")).default}catch{throw new Error("exportToExcelAdvanced requires 'exceljs'. Run: npm install exceljs")}const C=new m.Workbook;C.creator="OpenGridX",C.created=new Date;const b=t,_=At(b),v=e,k=ft(x)?Nl(v,x,y):[],A=r??[{name:"Data",rows:"all",includeHeaders:!0,includeSummary:!1}],M=new Set,N=new Map,P=(L,E)=>{const O=E[L.field],B=h?.[L.field];if(O==null)return{value:null};const H=ri(L,B,O);return typeof H=="number"?Number.isFinite(H)?oi(B)?{value:H,numFmt:Rs}:{value:H,numFmt:Ks(L,i[L.field],H)}:{value:null}:H instanceof Date?{value:xn(H)}:{value:rr(L,B,O,E)}};for(const L of A){if("type"in L&&L.type==="summary"){if(!f||!h)continue;const V=C.addWorksheet(ir(L.name??"Summary",M));V.addRow(["Summary / Aggregation Totals"]),V.getRow(1).font={bold:!0,size:a+2,color:{argb:ze(c)}},V.addRow([]),V.addRow(["Column","Function","Value"]).eachCell(J=>{J.fill={type:"pattern",pattern:"solid",fgColor:{argb:ze(l)}},J.font={bold:!0,size:a,color:{argb:ze(c)}},J.border=qs()}),_.forEach(J=>{const te=h[J.field];if(te==null||f[J.field]==null)return;const{value:ne,numFmt:z}=P(J,f),ae=V.addRow([J.headerName??J.field,te.toUpperCase(),ne]).getCell(3),le=z??Us(J,i[J.field]);le&&(ae.numFmt=le),ae.alignment={horizontal:"right"},ae.font={bold:!0,size:u}}),V.getColumn(1).width=20,V.getColumn(2).width=12,V.getColumn(3).width=18;continue}const E=L,{name:O="Data",rows:B="all",includeHeaders:H=!0,includeSummary:K=!1,autoFilter:R=!0,frozenHeader:X=!0,alternateRowColor:j="#f8fafc"}=E,Q=B==="all"&&!!(w&&w.length>0),U=B==="selected"?k:Q?w.flatMap(V=>V.type==="leaf"&&V.row?[V.row]:[]):v,re=_.filter(V=>i[V.field]?.embedImage);if(re.length>0){const V=[],Y=new Set;if(U.forEach(J=>{re.forEach(te=>{const ne=js(J,te);ne&&!N.has(ne)&&!Y.has(ne)&&(V.push(ne),Y.add(ne))})}),V.length>0){const J=await im(V);for(const[te,{buffer:ne,extension:z}]of J){const ie=C.addImage({buffer:ne,extension:z});N.set(te,ie)}}}const q=C.addWorksheet(ir(O,M));q.columns=_.map(V=>({key:V.field,width:om(V,i[V.field]?.width),style:{numFmt:Us(V,i[V.field])}}));const se=(V,Y)=>{_.forEach((J,te)=>Y(V.getCell(te+1),J,te+1))};if(H){const V=_.map(J=>J.headerName??J.field),Y=q.addRow(V);Y.height=20,se(Y,(J,te)=>{J.fill={type:"pattern",pattern:"solid",fgColor:{argb:ze(l)}},J.font={bold:!0,size:a,color:{argb:ze(c)}},J.alignment={horizontal:i[te.field]?.alignment??(te.type==="number"?"right":"left"),vertical:"middle"},J.border=qs()}),R&&(q.autoFilter={from:{row:1,column:1},to:{row:1,column:_.length}}),X?q.views=[{state:"frozen",ySplit:1,showGridLines:!1}]:q.views=[{showGridLines:!1}]}let Z=H?1:0;const $=(V,Y,J)=>{const te=_.map(ie=>i[ie.field]?.embedImage?"":em(V,ie)),ne=q.addRow(te);ne.font={size:u},J>0&&(ne.outlineLevel=J);const z=!!j&&Y%2===1;if(se(ne,(ie,ae,le)=>{const ce=Ks(ae,i[ae.field],te[le-1]);ce&&(ie.numFmt=ce),z&&j&&(ie.fill={type:"pattern",pattern:"solid",fgColor:{argb:ze(j)}}),ie.alignment={horizontal:i[ae.field]?.alignment??(ae.type==="number"?"right":"left"),vertical:"middle"},ie.border={bottom:{style:"thin",color:{argb:"FFf1f5f9"}}}}),re.length>0){const ie=re.reduce((ce,de)=>Math.max(ce,i[de.field]?.imageHeight??40),0),ae=Math.ceil(ie/1.333),le=ae*1.333;ne.height=ae,re.forEach(ce=>{const de=_.indexOf(ce),we=js(V,ce),me=we?N.get(we):void 0;if(me===void 0){ne.getCell(de+1).value=we??"";return}const pe=i[ce.field],oe=pe?.imageWidth??40,ue=pe?.imageHeight??40,he=(q.getColumn(de+1).width??8)*7+5,ge=Math.max(0,he-oe)/2,ve=Math.max(0,le-ue)/2;q.addImage(me,{tl:{col:de,row:Z,nativeColOff:Math.floor(ge*9525),nativeRowOff:Math.floor(ve*9525)},ext:{width:oe,height:ue},editAs:"oneCell"})})}else ne.height=16;Z++},D=V=>Yt(V,b),G=(V,Y,J,te,ne)=>{const z=_.map((ae,le)=>le===0&&Y[ae.field]==null?{value:V}:P(ae,Y)),ie=q.addRow(z.map(ae=>ae.value));ie.height=18,te>0&&(ie.outlineLevel=te),ie.font={bold:ne,italic:!ne,size:u,color:{argb:ze(c)}},se(ie,(ae,le,ce)=>{const de=z[ce-1].numFmt;de&&(ae.numFmt=de),ae.fill={type:"pattern",pattern:"solid",fgColor:{argb:ze(J)}},ae.alignment={horizontal:ce===1?"left":le.type==="number"?"right":"left",vertical:"middle"},ae.border=Xs()}),Z++};let W=!1;if(Q){let V=0;w.forEach(Y=>{if(Y.type==="group-header"){const J=q.addRow([D(Y)]);J.height=18,Y.depth>0&&(J.outlineLevel=Y.depth),J.font={bold:!0,size:u,color:{argb:ze(c)}};for(let te=1;te<=_.length;te++)J.getCell(te).fill={type:"pattern",pattern:"solid",fgColor:{argb:ze(g)}};J.getCell(1).alignment={horizontal:"left",vertical:"middle",indent:Y.depth},Z++,V=0}else Y.type==="leaf"&&Y.row?$(Y.row,V++,Y.depth):Y.type==="group-subtotal"&&Y.aggregatedValues?G("Subtotal",Y.aggregatedValues,p,Y.depth,!1):Y.type==="grand-total"&&Y.aggregatedValues&&(G("Grand Total",Y.aggregatedValues,l,0,!0),W=!0)}),q.properties.outlineProperties={summaryBelow:!0,summaryRight:!1}}else U.forEach((V,Y)=>$(V,Y,0));const ee=Vt(U,B==="selected",b,f,h);if(K&&!W&&ee&&h){const V=_.map(ne=>{const z=h[ne.field];return z?z.toUpperCase():""}),Y=q.addRow(V);Y.height=16,Y.font={size:u-1,italic:!0,color:{argb:"FF94a3b8"}},se(Y,ne=>{ne.alignment={horizontal:"right",vertical:"middle"},ne.border={top:{style:"thin",color:{argb:"FFcbd5e1"}}}});const J=_.map(ne=>h[ne.field]==null?{value:null}:P(ne,ee)),te=q.addRow(J.map(ne=>ne.value));te.height=18,te.font={bold:!0,size:u,color:{argb:ze(c)}},se(te,(ne,z,ie)=>{const ae=J[ie-1].numFmt;ae&&(ne.numFmt=ae),ne.fill={type:"pattern",pattern:"solid",fgColor:{argb:ze(l)}},ne.alignment={horizontal:"right",vertical:"middle"},ne.border=Xs()})}}const T=await C.xlsx.writeBuffer(),S=new Blob([T],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),I=URL.createObjectURL(S),F=document.createElement("a");F.href=I,F.download=o.endsWith(".xlsx")?o:`${o}.xlsx`,document.body.appendChild(F),F.click(),document.body.removeChild(F),URL.revokeObjectURL(I)}function sm(e,t,n,o){return s.useMemo(()=>o?Li(e,t,n):Oo,[e,t,n,o])}const Ys={"--ogx-grid-row-selected-background":"var(--ogx-color-primary-light)","--ogx-grid-row-selected-hover-background":"color-mix(in srgb, var(--ogx-color-primary) 14%, var(--ogx-color-primary-light))","--ogx-grid-cell-focus-border":"var(--ogx-color-primary)","--ogx-range-background":"color-mix(in srgb, var(--ogx-color-primary) 12%, transparent)","--ogx-range-border":"var(--ogx-color-primary)","--ogx-fill-handle-color":"var(--ogx-range-border)","--ogx-toolbar-btn-primary-bg":"var(--ogx-color-primary)","--ogx-toolbar-btn-primary-hover":"var(--ogx-color-primary-dark)","--ogx-toolbar-input-focus-border":"var(--ogx-color-primary)","--ogx-toolbar-input-focus-shadow":"0 0 0 3px color-mix(in srgb, var(--ogx-color-primary) 12%, transparent)","--ogx-toolbar-chip-active-bg":"color-mix(in srgb, var(--ogx-color-primary) 12%, transparent)","--ogx-toolbar-chip-active-text":"var(--ogx-color-primary-dark)","--ogx-overlay-item-selected-bg":"color-mix(in srgb, var(--ogx-color-primary) 8%, transparent)","--ogx-overlay-item-selected-text":"var(--ogx-color-primary-dark)"},Js={"--ogx-color-primary":"#3b82f6","--ogx-color-primary-dark":"#2563eb","--ogx-color-primary-light":"#eff6ff","--ogx-color-primary-focus":"rgba(59, 130, 246, 0.5)","--ogx-color-secondary":"#8b5cf6","--ogx-color-secondary-dark":"#7c3aed","--ogx-color-secondary-light":"#f5f3ff","--ogx-color-white":"#ffffff","--ogx-color-black":"#0f172a","--ogx-color-gray-50":"#f8fafc","--ogx-color-gray-100":"#f1f5f9","--ogx-color-gray-200":"#e2e8f0","--ogx-color-gray-300":"#cbd5e1","--ogx-color-gray-400":"#94a3b8","--ogx-color-gray-500":"#64748b","--ogx-color-gray-600":"#475569","--ogx-color-gray-700":"#334155","--ogx-color-gray-800":"#1e293b","--ogx-color-gray-900":"#0f172a","--ogx-border-color":"#e2e8f0","--ogx-border-color-hover":"#cbd5e1","--ogx-shadow-sm":"0 1px 2px 0 rgba(0, 0, 0, 0.05)","--ogx-shadow-md":"0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03)","--ogx-shadow-lg":"0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02)","--ogx-grid-background":"#ffffff","--ogx-grid-border-color":"#e2e8f0","--ogx-grid-header-background":"#f8fafc","--ogx-grid-header-text":"#334155","--ogx-grid-header-hover-background":"#f1f5f9","--ogx-grid-header-sorted-background":"#f8fafc","--ogx-grid-row-text":"#1e293b","--ogx-grid-row-hover-background":"#f8fafc","--ogx-grid-row-alternate-background":"transparent","--ogx-checkbox-bg":"#ffffff","--ogx-checkbox-border":"#94a3b8","--ogx-grid-pinned-left-shadow":"4px 0 24px -4px rgba(0, 0, 0, 0.05)","--ogx-grid-pinned-right-shadow":"-4px 0 24px -4px rgba(0, 0, 0, 0.05)",...{"--ogx-toolbar-background":"var(--ogx-grid-header-background)","--ogx-toolbar-text":"var(--ogx-grid-header-text)","--ogx-toolbar-border":"var(--ogx-grid-border-color)","--ogx-toolbar-btn-bg":"transparent","--ogx-toolbar-btn-hover":"var(--ogx-grid-header-hover-background)","--ogx-toolbar-btn-text":"var(--ogx-grid-header-text)","--ogx-toolbar-input-bg":"var(--ogx-grid-background)","--ogx-toolbar-input-text":"var(--ogx-grid-row-text)","--ogx-toolbar-chip-bg":"transparent","--ogx-toolbar-chip-text":"var(--ogx-grid-row-text)"},"--ogx-toolbar-btn-primary-text":"#ffffff","--ogx-toolbar-btn-danger-bg":"rgba(239, 68, 68, 0.08)","--ogx-toolbar-btn-danger-hover":"rgba(239, 68, 68, 0.15)","--ogx-toolbar-btn-danger-text":"#ef4444","--ogx-toolbar-input-border":"#cbd5e1","--ogx-overlay-background":"#ffffff","--ogx-overlay-text":"#1e293b","--ogx-overlay-border":"#e2e8f0","--ogx-overlay-shadow":"0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.06)","--ogx-overlay-item-hover-bg":"#f8fafc","--ogx-overlay-item-hover-text":"#0f172a","--ogx-overlay-item-danger-bg":"rgba(239, 68, 68, 0.08)","--ogx-overlay-item-danger-text":"#ef4444","--ogx-scrollbar-thumb":"#cbd5e1","--ogx-scrollbar-track":"transparent","--ogx-scrollbar-size":"8px","--ogx-skeleton-base":"#f1f5f9","--ogx-skeleton-highlight":"#ffffff",...Ys},am={...Js,"--ogx-color-primary":"#60a5fa","--ogx-color-primary-dark":"#3b82f6","--ogx-color-primary-light":"#1e3a5f","--ogx-color-primary-focus":"rgba(96, 165, 250, 0.4)","--ogx-color-white":"#0f172a","--ogx-color-black":"#f8fafc","--ogx-color-gray-50":"#1e293b","--ogx-color-gray-100":"#334155","--ogx-color-gray-200":"#475569","--ogx-color-gray-300":"#64748b","--ogx-color-gray-400":"#94a3b8","--ogx-color-gray-500":"#cbd5e1","--ogx-color-gray-600":"#e2e8f0","--ogx-color-gray-700":"#e2e8f0","--ogx-color-gray-800":"#f1f5f9","--ogx-color-gray-900":"#f8fafc","--ogx-border-color":"#334155","--ogx-border-color-hover":"#475569","--ogx-shadow-sm":"0 1px 2px 0 rgba(0, 0, 0, 0.3)","--ogx-shadow-md":"0 4px 6px -1px rgba(0, 0, 0, 0.3)","--ogx-shadow-lg":"0 10px 15px -3px rgba(0, 0, 0, 0.3)","--ogx-grid-background":"#0f172a","--ogx-grid-border-color":"#334155","--ogx-grid-header-background":"#1e293b","--ogx-grid-header-text":"#e2e8f0","--ogx-grid-header-hover-background":"#334155","--ogx-grid-header-sorted-background":"#1e3a5f","--ogx-grid-row-text":"#cbd5e1","--ogx-grid-row-hover-background":"#1e293b","--ogx-grid-row-alternate-background":"#162032","--ogx-checkbox-bg":"#1e293b","--ogx-checkbox-border":"#64748b","--ogx-grid-pinned-left-shadow":"4px 0 24px -4px rgba(0, 0, 0, 0.3)","--ogx-grid-pinned-right-shadow":"-4px 0 24px -4px rgba(0, 0, 0, 0.3)","--ogx-toolbar-btn-danger-bg":"rgba(239, 68, 68, 0.15)","--ogx-toolbar-btn-danger-hover":"rgba(239, 68, 68, 0.25)","--ogx-toolbar-btn-danger-text":"#fca5a5","--ogx-toolbar-input-border":"#334155","--ogx-overlay-background":"#1e293b","--ogx-overlay-text":"#cbd5e1","--ogx-overlay-border":"#334155","--ogx-overlay-shadow":"0 4px 6px -1px rgba(0,0,0,0.4), 0 2px 4px -1px rgba(0,0,0,0.3), 0 0 0 1px rgba(0,0,0,0.2)","--ogx-overlay-item-hover-bg":"#334155","--ogx-overlay-item-hover-text":"#f1f5f9","--ogx-overlay-item-danger-bg":"rgba(239, 68, 68, 0.15)","--ogx-overlay-item-danger-text":"#fca5a5","--ogx-scrollbar-thumb":"#475569","--ogx-skeleton-base":"#1e293b","--ogx-skeleton-highlight":"#334155",...Ys,"--ogx-toolbar-chip-active-text":"var(--ogx-color-primary)","--ogx-overlay-item-selected-text":"var(--ogx-color-primary)"},cm=[50,100,200,300,400,500,600,700,800,900];function dm(e){const t={};function n(o,r){r!==void 0&&(t[o]=r)}if(e.colors){const o=e.colors;if(n("--ogx-color-primary",o.primary),n("--ogx-color-primary-dark",o.primaryDark),n("--ogx-color-primary-light",o.primaryLight),n("--ogx-color-primary-focus",o.primaryFocus),n("--ogx-color-secondary",o.secondary),n("--ogx-color-secondary-dark",o.secondaryDark),n("--ogx-color-secondary-light",o.secondaryLight),n("--ogx-color-success",o.success),n("--ogx-color-warning",o.warning),n("--ogx-color-error",o.error),n("--ogx-color-info",o.info),n("--ogx-color-white",o.white),n("--ogx-color-black",o.black),o.gray)for(const r of cm)n(`--ogx-color-gray-${r}`,o.gray[r])}if(e.typography){const o=e.typography;n("--ogx-font-family",o.fontFamily),n("--ogx-font-family-mono",o.fontFamilyMono),n("--ogx-font-size-xs",o.fontSizeXs),n("--ogx-font-size-sm",o.fontSizeSm),n("--ogx-font-size-md",o.fontSizeMd),n("--ogx-font-size-lg",o.fontSizeLg),n("--ogx-font-size-xl",o.fontSizeXl)}if(e.spacing){const o=e.spacing;n("--ogx-spacing-xs",o.xs),n("--ogx-spacing-sm",o.sm),n("--ogx-spacing-md",o.md),n("--ogx-spacing-lg",o.lg),n("--ogx-spacing-xl",o.xl),n("--ogx-spacing-xxl",o.xxl)}if(e.borders){const o=e.borders;n("--ogx-border-width-thin",o.widthThin),n("--ogx-border-width-medium",o.widthMedium),n("--ogx-border-width-thick",o.widthThick),n("--ogx-border-radius-sm",o.radiusSm),n("--ogx-border-radius-md",o.radiusMd),n("--ogx-border-radius-lg",o.radiusLg),n("--ogx-border-radius-xl",o.radiusXl),n("--ogx-border-color",o.color),n("--ogx-border-color-hover",o.colorHover)}if(e.shadows){const o=e.shadows;n("--ogx-shadow-sm",o.sm),n("--ogx-shadow-md",o.md),n("--ogx-shadow-lg",o.lg),n("--ogx-shadow-xl",o.xl)}if(e.grid){const o=e.grid;n("--ogx-grid-row-height-compact",o.rowHeightCompact),n("--ogx-grid-row-height-standard",o.rowHeightStandard),n("--ogx-row-height",o.rowHeightStandard),n("--ogx-grid-row-height-comfortable",o.rowHeightComfortable),n("--ogx-grid-header-height",o.headerHeight),n("--ogx-header-height",o.headerHeight),n("--ogx-grid-cell-padding-x",o.cellPaddingX),n("--ogx-grid-cell-padding-y",o.cellPaddingY),n("--ogx-grid-cell-font-size",o.cellFontSize),n("--ogx-grid-header-font-size",o.headerFontSize),n("--ogx-grid-header-font-family",o.headerFontFamily),n("--ogx-grid-header-font-weight",o.headerFontWeight),n("--ogx-grid-cell-font-family",o.cellFontFamily),n("--ogx-grid-cell-font-weight",o.cellFontWeight),n("--ogx-grid-header-padding-x",o.headerPaddingX),n("--ogx-grid-border-width",o.borderWidth),n("--ogx-grid-border-radius",o.borderRadius),n("--ogx-grid-column-divider-width",o.columnDividerWidth),n("--ogx-grid-header-column-divider-width",o.headerColumnDividerWidth),n("--ogx-grid-row-divider-width",o.rowDividerWidth),n("--ogx-grid-column-divider-color",o.columnDividerColor),n("--ogx-grid-row-divider-color",o.rowDividerColor),n("--ogx-grid-background",o.background),n("--ogx-grid-border-color",o.borderColor),n("--ogx-grid-header-background",o.headerBackground),n("--ogx-grid-header-text",o.headerText),n("--ogx-grid-header-hover-background",o.headerHoverBackground),n("--ogx-grid-header-sorted-background",o.headerSortedBackground),n("--ogx-grid-row-text",o.rowText),n("--ogx-grid-row-hover-background",o.rowHoverBackground),n("--ogx-grid-row-alternate-background",o.rowAlternateBackground),n("--ogx-grid-row-selected-background",o.rowSelectedBackground),n("--ogx-grid-row-selected-hover-background",o.rowSelectedHoverBackground),n("--ogx-grid-cell-focus-border",o.cellFocusBorder),n("--ogx-range-background",o.rangeBackground),n("--ogx-range-border",o.rangeBorder),n("--ogx-fill-handle-color",o.fillHandleColor),n("--ogx-grid-pinned-left-shadow",o.pinnedLeftShadow),n("--ogx-grid-pinned-right-shadow",o.pinnedRightShadow),n("--ogx-checkbox-bg",o.checkboxBg),n("--ogx-checkbox-border",o.checkboxBorder),n("--ogx-checkbox-checked-bg",o.checkboxCheckedBackground),n("--ogx-checkbox-checkmark",o.checkboxCheckmark),n("--ogx-expand-icon-color",o.expandIconColor),n("--ogx-expand-icon-hover-color",o.expandIconHoverColor)}if(e.transitions){const o=e.transitions;n("--ogx-transition-duration-fast",o.durationFast),n("--ogx-transition-duration-normal",o.durationNormal),n("--ogx-transition-duration-slow",o.durationSlow),n("--ogx-transition-easing",o.easing)}if(e.toolbar){const o=e.toolbar;n("--ogx-toolbar-background",o.background),n("--ogx-toolbar-text",o.text),n("--ogx-toolbar-border",o.border),n("--ogx-toolbar-btn-bg",o.buttonBackground),n("--ogx-toolbar-btn-hover",o.buttonHoverBackground),n("--ogx-toolbar-btn-text",o.buttonText),n("--ogx-toolbar-btn-primary-bg",o.buttonPrimaryBackground),n("--ogx-toolbar-btn-primary-hover",o.buttonPrimaryHoverBackground),n("--ogx-toolbar-btn-primary-text",o.buttonPrimaryText),n("--ogx-toolbar-btn-danger-bg",o.buttonDangerBackground),n("--ogx-toolbar-btn-danger-hover",o.buttonDangerHoverBackground),n("--ogx-toolbar-btn-danger-text",o.buttonDangerText),n("--ogx-toolbar-input-bg",o.inputBackground),n("--ogx-toolbar-input-text",o.inputText),n("--ogx-toolbar-input-border",o.inputBorder),n("--ogx-toolbar-input-focus-border",o.inputFocusBorder),n("--ogx-toolbar-input-focus-shadow",o.inputFocusShadow),n("--ogx-toolbar-chip-bg",o.chipBackground),n("--ogx-toolbar-chip-text",o.chipText),n("--ogx-toolbar-chip-active-bg",o.chipActiveBackground),n("--ogx-toolbar-chip-active-text",o.chipActiveText)}if(e.overlays){const o=e.overlays;n("--ogx-overlay-background",o.background),n("--ogx-overlay-text",o.text),n("--ogx-overlay-border",o.border),n("--ogx-overlay-shadow",o.shadow),n("--ogx-overlay-item-hover-bg",o.itemHoverBackground),n("--ogx-overlay-item-hover-text",o.itemHoverText),n("--ogx-overlay-item-selected-bg",o.itemSelectedBackground),n("--ogx-overlay-item-selected-text",o.itemSelectedText),n("--ogx-overlay-item-danger-bg",o.itemDangerBackground),n("--ogx-overlay-item-danger-text",o.itemDangerText),n("--ogx-overlay-item-indicator",o.itemIndicatorColor),n("--ogx-overlay-item-selected-icon",o.itemSelectedIcon),n("--ogx-overlay-icon",o.iconColor),n("--ogx-overlay-section-label-text",o.sectionLabelText),n("--ogx-overlay-divider",o.dividerColor),n("--ogx-overlay-font-family",o.fontFamily),n("--ogx-overlay-font-weight",o.fontWeight),n("--ogx-overlay-font-size",o.fontSize)}if(e.scrollbar){const o=e.scrollbar;n("--ogx-scrollbar-thumb",o.thumbColor),n("--ogx-scrollbar-track",o.trackColor),n("--ogx-scrollbar-size",o.size)}if(e.skeleton){const o=e.skeleton;n("--ogx-skeleton-base",o.baseColor),n("--ogx-skeleton-highlight",o.highlightColor)}return t}function um({theme:e,children:t,className:n,style:o}){const r=s.useMemo(()=>({...e.mode==="dark"?am:Js,...dm(e)}),[e]);return d.jsx(Ki.Provider,{value:e,children:d.jsx("div",{className:`ogx-theme-provider ${n||""}`.trim(),style:{...o,...r},children:t})})}const fm={mode:"dark",colors:{primary:"#60a5fa",primaryDark:"#3b82f6",primaryLight:"#1e3a5f",primaryFocus:"rgba(96, 165, 250, 0.4)"},grid:{background:"#0f172a",headerBackground:"#1e293b",headerText:"#e2e8f0",headerHoverBackground:"#334155",headerSortedBackground:"#1e3a5f",rowText:"#cbd5e1",borderColor:"#334155",rowHoverBackground:"#1e293b",rowAlternateBackground:"#162032",rowSelectedBackground:"#1e3a5f",rowSelectedHoverBackground:"#1d4ed8",cellFocusBorder:"#60a5fa",rangeBackground:"rgba(96, 165, 250, 0.18)",rangeBorder:"#60a5fa",checkboxBg:"#1e293b",checkboxBorder:"#64748b"},borders:{color:"#334155",colorHover:"#475569"},shadows:{sm:"0 1px 2px 0 rgba(0, 0, 0, 0.3)",md:"0 4px 6px -1px rgba(0, 0, 0, 0.3)"},toolbar:{background:"#1e293b",text:"#cbd5e1",border:"#334155",buttonBackground:"transparent",buttonHoverBackground:"#334155",buttonText:"#e2e8f0",buttonPrimaryBackground:"#3b82f6",buttonPrimaryHoverBackground:"#2563eb",buttonPrimaryText:"#ffffff",buttonDangerBackground:"rgba(239, 68, 68, 0.15)",buttonDangerHoverBackground:"rgba(239, 68, 68, 0.25)",buttonDangerText:"#fca5a5",inputBackground:"#0f172a",inputText:"#f8fafc",inputBorder:"#334155",inputFocusBorder:"#60a5fa",inputFocusShadow:"0 0 0 3px rgba(96, 165, 250, 0.2)",chipBackground:"#1e293b",chipText:"#94a3b8",chipActiveBackground:"rgba(96, 165, 250, 0.2)",chipActiveText:"#60a5fa"},overlays:{background:"#1e293b",text:"#f8fafc",border:"#334155",shadow:"0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3)",itemHoverBackground:"#334155",itemHoverText:"#ffffff",itemSelectedBackground:"rgba(96, 165, 250, 0.15)",itemSelectedText:"#60a5fa",itemDangerBackground:"rgba(239, 68, 68, 0.15)",itemDangerText:"#fca5a5"},scrollbar:{thumbColor:"rgba(148, 163, 184, 0.2)",trackColor:"transparent"},skeleton:{baseColor:"#1e293b",highlightColor:"#334155"}},gm={colors:{primary:"#e11d48",primaryDark:"#be123c",primaryLight:"#fff1f2",primaryFocus:"rgba(225, 29, 72, 0.4)"},grid:{headerBackground:"#fff1f2",headerHoverBackground:"#ffe4e6",headerSortedBackground:"#fecdd3",rowAlternateBackground:"#fff8f8",rowSelectedBackground:"#ffe4e6",rowSelectedHoverBackground:"#fecdd3",cellFocusBorder:"#e11d48",rangeBackground:"rgba(225, 29, 72, 0.10)",rangeBorder:"#e11d48"}},pm={colors:{primary:"#059669",primaryDark:"#047857",primaryLight:"#ecfdf5",primaryFocus:"rgba(5, 150, 105, 0.4)"},grid:{headerBackground:"#ecfdf5",headerHoverBackground:"#d1fae5",headerSortedBackground:"#a7f3d0",rowAlternateBackground:"#f6fdf9",rowSelectedBackground:"#d1fae5",rowSelectedHoverBackground:"#a7f3d0",cellFocusBorder:"#059669",rangeBackground:"rgba(5, 150, 105, 0.12)",rangeBorder:"#059669"}},hm={colors:{primary:"#d97706",primaryDark:"#b45309",primaryLight:"#fffbeb",primaryFocus:"rgba(217, 119, 6, 0.4)"},grid:{headerBackground:"#fffbeb",headerHoverBackground:"#fef3c7",headerSortedBackground:"#fde68a",rowAlternateBackground:"#fffdf5",rowSelectedBackground:"#fef3c7",rowSelectedHoverBackground:"#fde68a",cellFocusBorder:"#d97706",rangeBackground:"rgba(217, 119, 6, 0.12)",rangeBorder:"#d97706"}},mm={grid:{rowHeightCompact:"28px",rowHeightStandard:"36px",rowHeightComfortable:"48px",headerHeight:"40px",cellPaddingX:"8px",cellPaddingY:"4px",cellFontSize:"12px",headerFontSize:"12px"},typography:{fontSizeSm:"0.8rem",fontSizeMd:"0.875rem"}};function wm(){if(!(typeof window>"u"))try{return window.localStorage}catch{return}}function Zs(e,t){try{const n=t.getItem(e);return n?JSON.parse(n):void 0}catch{return}}function bm(e,t,n,o){try{const r=n?Object.fromEntries(Object.entries(t).filter(([i])=>n.includes(i))):t;o.setItem(e,JSON.stringify(r))}catch{}}function xm(e){const t=typeof e=="string"?{key:e}:e,{key:n,debounceMs:o=300,include:r,storage:i}=t,[l]=s.useState(wm),c=i??l,a=s.useRef(r),u=s.useRef(c);s.useLayoutEffect(()=>{a.current=r,u.current=c});const[f,h]=s.useState(()=>({key:n,state:c?Zs(n,c):void 0}));let x=f.state;f.key!==n&&(x=c?Zs(n,c):void 0,h({key:n,state:x}));const y=s.useRef(null),w=s.useRef(null),g=s.useCallback(()=>{y.current&&(clearTimeout(y.current),y.current=null);const C=w.current;w.current=null;const b=u.current;C&&b&&bm(C.key,C.state,a.current,b)},[]),p=s.useCallback(C=>{w.current&&w.current.key!==n&&g(),w.current={key:n,state:C},y.current&&clearTimeout(y.current),y.current=setTimeout(g,o)},[n,g,o]);s.useEffect(()=>g,[g]);const m=s.useCallback(()=>{y.current&&(clearTimeout(y.current),y.current=null),w.current=null;const C=u.current;if(C)try{C.removeItem(n)}catch{}},[n]);return s.useMemo(()=>({initialState:x,onStateChange:p,clearState:m}),[x,p,m])}Ce.Button=tt,Ce.Cell=Cs,Ce.CellSelectionStats=_s,Ce.Checkbox=pt,Ce.ColumnVisibilityPanel=pr,Ce.DataGrid=ih,Ce.DataGridThemeProvider=um,Ce.FilterPanel=Ns,Ce.GridToolbar=yh,Ce.GridTooltip=wn,Ce.Header=ws,Ce.Input=nt,Ce.Pagination=hr,Ce.Row=Zn,Ce.Skeleton=lh,Ce.amberTheme=hm,Ce.compactTheme=mm,Ce.darkTheme=fm,Ce.emeraldTheme=pm,Ce.exportToCsv=_h,Ce.exportToExcel=Mh,Ce.exportToExcelAdvanced=lm,Ce.exportToJson=Ah,Ce.exportToPdf=Kh,Ce.formatAggregationValue=rn,Ce.printGrid=Ih,Ce.roseTheme=gm,Ce.useAggregation=ls,Ce.useGridApiRef=vh,Ce.useGridStateStorage=xm,Ce.usePivot=sm,Object.defineProperty(Ce,Symbol.toStringTag,{value:"Module"})}));
|
|
47
47
|
//# sourceMappingURL=opengridx.umd.js.map
|