@opencorestack/opengridx 3.6.0 → 3.7.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 +17 -0
- package/dist/index.d.ts +30 -0
- package/dist/opengridx.css +1 -1
- package/dist/opengridx.es.js +8566 -8130
- package/dist/opengridx.es.js.map +1 -1
- package/dist/opengridx.umd.js +15 -15
- package/dist/opengridx.umd.js.map +1 -1
- package/docs/API_REFERENCE.md +3 -2
- package/docs/architecture/datagrid-orchestration.md +46 -29
- package/docs/architecture/grid-row-meta.md +1 -1
- package/docs/customization/slots-api.md +1 -1
- package/docs/customization/theming.md +43 -0
- package/docs/features/virtualization.md +16 -2
- package/docs/performance.md +3 -1
- package/lib/components/AiAssistant/GridAiAssistantPanel.css +3 -1
- package/lib/components/Cell/Cell.css +4 -2
- package/lib/components/ColumnGroupHeader/ColumnGroupHeader.css +2 -2
- package/lib/components/ColumnVisibilityPanel/ColumnVisibilityPanel.css +3 -1
- package/lib/components/DataGrid/DataGrid.css +9 -9
- package/lib/components/DataGrid/DataGrid.tsx +163 -671
- package/lib/components/DataGrid/GridRoot.tsx +239 -0
- package/lib/components/DataGrid/GridViewport.tsx +314 -0
- package/lib/components/FilterPanel/FilterPanel.css +9 -8
- package/lib/components/Header/ColumnMenu.css +4 -3
- package/lib/components/Header/Header.css +5 -4
- package/lib/components/HeaderFilter/HeaderFilter.css +1 -1
- package/lib/components/Pagination/Pagination.css +1 -1
- package/lib/components/Row/Row.css +2 -2
- package/lib/components/Toolbar/GridToolbar.css +8 -7
- package/lib/components/Toolbar/PivotPanel.css +3 -3
- package/lib/hooks/core/useGridDevWarnings.ts +3 -1
- package/lib/hooks/core/useGridEditPipeline.ts +55 -0
- package/lib/hooks/core/useGridRangeEditing.ts +129 -0
- package/lib/hooks/core/useGridRenderWindow.ts +66 -0
- package/lib/hooks/core/useGridScrollViewport.ts +42 -0
- package/lib/hooks/core/useGridSelectionAndStateApi.ts +61 -0
- package/lib/hooks/core/useGridToolbarStack.ts +49 -0
- package/lib/hooks/core/useGridViewApis.ts +46 -0
- package/lib/styles/base/variables.css +12 -0
- package/lib/theme/DataGridThemeProvider.tsx +15 -0
- package/lib/theme/__baseline__/default-theme.darwin.chromium.json +1503 -0
- package/lib/theme/__baseline__/default-theme.darwin.firefox.json +1503 -0
- package/lib/theme/__baseline__/default-theme.darwin.webkit.json +1503 -0
- package/lib/theme/types.ts +31 -0
- package/lib/types/ai.ts +109 -0
- package/lib/types/api.ts +169 -0
- package/lib/types/columns.ts +341 -0
- package/lib/types/dataSource.ts +40 -0
- package/lib/types/editing.ts +77 -0
- package/lib/types/export.ts +164 -0
- package/lib/types/filtering.ts +52 -0
- package/lib/types/grouping.ts +27 -0
- package/lib/types/index.ts +18 -1702
- package/lib/types/locale.ts +51 -0
- package/lib/types/props.ts +405 -0
- package/lib/types/rows.ts +132 -0
- package/lib/types/selection.ts +66 -0
- package/lib/types/slots.ts +56 -0
- package/lib/types/sorting.ts +25 -0
- package/lib/types/state.ts +35 -0
- package/llms.txt +1 -1
- package/package.json +4 -2
package/dist/opengridx.umd.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
(function(_e,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):(_e=typeof globalThis<"u"?globalThis:_e||self,d(_e.OpenGridX={},_e.ReactJSXRuntime,_e.React,_e.ReactDOM))})(this,(function(_e,d,s,bt){"use strict";"use client";function Po(e,t,n){return Math.max(t??0,Math.min(n??1/0,e))}function At(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 We=48;function ct(e,t){return t?t.left?.includes(e)?"left":t.right?.includes(e)?"right":null:null}function Fa(e,t){const n=[],o=[],r=[];return t?(e.forEach(i=>{const l=ct(i.field,t);l==="left"?n.push(i):l==="right"?r.push(i):o.push(i)}),t.left&&n.sort((i,l)=>{const a=t.left.indexOf(i.field),c=t.left.indexOf(l.field);return a-c}),t.right&&r.sort((i,l)=>{const a=t.right.indexOf(i.field),c=t.right.indexOf(l.field);return a-c}),{left:n,center:o,right:r}):{left:n,center:e,right:r}}function Fo(e,t,n,o,r,i,l,a){const c={};if(!n)return c;let u=(a?We:0)+(i&&l?We:0)+(o&&r?We:0);const g=[];e.forEach(x=>{if(x.isSpacer)return;const y=ct(x.field,n);y==="left"?(c[x.field]=u,u+=At(x,t)):y==="right"&&g.push(x)});let h=0;for(let x=g.length-1;x>=0;x--)c[g[x].field]=h,h+=At(g[x],t);return c}function Oo(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=ct(r.field,t);i==="left"?n=r.field:i==="right"&&o===null&&(o=r.field)}return{lastLeft:n,firstRight:o}}function ui(e,t){return t?t.top?.includes(e)?"top":t.bottom?.includes(e)?"bottom":null:null}function Oa(e,t,n=o=>o.id){const o=[],r=[],i=[];return t?(e.forEach(l=>{const a=ui(n(l),t);a==="top"?o.push(l):a==="bottom"?i.push(l):r.push(l)}),t.top&&o.sort((l,a)=>{const c=t.top.indexOf(n(l)),u=t.top.indexOf(n(a));return c-u}),t.bottom&&i.sort((l,a)=>{const c=t.bottom.indexOf(n(l)),u=t.bottom.indexOf(n(a));return c-u}),{top:o,center:r,bottom:i}):{top:o,center:e,bottom:i}}function Da(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 fi=new Set;function Tt(e,t,n){process.env.NODE_ENV==="production"||fi.has(e)||(fi.add(e),console.warn(`[OpenGridX] ${t}.`,n))}function Do(e,t,n,o){try{return e()}catch(r){return Tt(n,o,r),t}}function gi(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}=gi(e,t,n);return r!==void 0&&Tt(`valueGetter:${t}`,`valueGetter for column "${t}" threw; the value is read as undefined`,r),o}function $o(e,t,n,o){const r=o?.valueFormatter;if(r)try{return r({value:n,row:e,field:t})}catch(i){Tt(`valueFormatter:${t}`,`valueFormatter for column "${t}" threw; the value is shown unformatted`,i);return}}function dt(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==="")return null;const n=Number(t);return Number.isNaN(n)?null:n}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 $a=/^(\d{4})-(\d{2})-(\d{2})$/;function wn(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=$a.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 t=new Date(n)}else return null;return Number.isNaN(t.getTime())?null:t}function Wn(e){const t=wn(e);return t?t.getFullYear()*1e4+(t.getMonth()+1)*100+t.getDate():null}function pi(e){const t=wn(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 hi=null;function mi(e){return hi??=new Intl.DateTimeFormat,hi.format(e)}function Ga(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 Go(e,t){if(e==null)return"";switch(t?.type){case"date":{const n=wn(e);return n?mi(n):String(e)}case"boolean":return e===!0?"Yes":e===!1?"No":String(e);case"singleSelect":return Ga(t.valueOptions,e)??String(e);default:return String(e)}}const Ho=200;function Bo(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:Ho}function Wo(e,t){if(e)return Do(()=>e(t),void 0,"getDetailPanelHeight","getDetailPanelHeight threw; the panel uses the default height")}function Ha(e,t){const n=Bo(e);return n==="auto"?t??Ho:n}function Ba(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 Wa=e=>e.id;function Va(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 za(e,t,n){const o=new Map;e.forEach(f=>{if(!Object.prototype.hasOwnProperty.call(t,f.field)&&f.flex&&f.flex>0){o.set(f.field,{kind:"flex",flex:f.flex});return}const b=Va(t[f.field]??f.width);b.type==="fixed"?o.set(f.field,{kind:"fixed",width:Po(b.value,f.minWidth,f.maxWidth)}):b.type==="percentage"?o.set(f.field,{kind:"percentage",percentage:b.value}):o.set(f.field,{kind:"flex",flex:1})});const r=e.reduce((f,m)=>{const b=o.get(m.field);if(b.kind==="fixed")return f+b.width;if(b.kind==="percentage")return f+100;if(m.flex&&m.flex>0){const w=m.minWidth??150;return f+(w||(typeof m.width=="number"?m.width:150))}return f+(m.minWidth??150)},0),i=Math.max(n,r),l=e.reduce((f,m)=>{const b=o.get(m.field);return b.kind==="fixed"?f+b.width:f},0),a=new Map,c=Math.max(0,i-l);let u=0;e.forEach(f=>{const m=o.get(f.field);if(m.kind==="fixed")a.set(f.field,m.width);else if(m.kind==="percentage"){const b=m.percentage/100*c,w=Po(b>0?b:100,f.minWidth??50,f.maxWidth);a.set(f.field,w),u+=w}});const g=Math.max(0,c-u),h=new Map,x=e.flatMap(f=>{const m=o.get(f.field);return m.kind!=="flex"?[]:(h.set(f.field,m.flex),[{field:f.field,flex:m.flex,minWidth:f.minWidth??50,maxWidth:f.maxWidth??1/0,frozen:!1,computedWidth:0}])});let y=0;const p=x.length*2;for(;y<p;){y++;const f=x.filter(M=>!M.frozen);if(f.length===0)break;const m=f.reduce((M,_)=>M+_.flex,0),b=x.reduce((M,_)=>_.frozen?M+_.computedWidth:M,0),w=Math.max(0,g-b);if(m<=0){f.forEach(M=>{M.computedWidth=M.minWidth,M.frozen=!0});break}const C=w/m;let E=0;const S=[],N=[];if(f.forEach(M=>{const _=C*M.flex;_<M.minWidth?(E+=M.minWidth-_,S.push(M)):_>M.maxWidth?(E+=M.maxWidth-_,N.push(M)):M.computedWidth=_}),S.length===0&&N.length===0){f.forEach(M=>{M.frozen=!0});break}E>0?S.forEach(M=>{M.computedWidth=M.minWidth,M.frozen=!0}):E<0?N.forEach(M=>{M.computedWidth=M.maxWidth,M.frozen=!0}):(S.forEach(M=>{M.computedWidth=M.minWidth,M.frozen=!0}),N.forEach(M=>{M.computedWidth=M.maxWidth,M.frozen=!0}))}return x.forEach(f=>a.set(f.field,f.computedWidth)),{widths:a,flexByField:h}}function Ka(e){const{rowHeight:t,pagination:n,paginatedUnpinnedRows:o,sortedUnpinnedRows:r,expandedRowIds:i,getDetailPanelHeight:l,detailPanelHeights:a,pinnedTopRowsLength:c,pinnedBottomRowsLength:u,pinnedTopRows:g,pinnedBottomRows:h,visibleOrderedColumns:x,pinnedColumns:y,columnWidths:p,viewportWidth:f,checkboxSelection:m,hasDetailPanel:b,rowReordering:w,pinCheckboxColumn:C,pinExpandColumn:E,paginationMode:S,isLoading:N,pageSize:M,getRowId:_=Wa}=e;return s.useMemo(()=>{const O=n?o:r,L=(G,Y)=>{const j=_(G);if(!i.has(j))return t;const q=Wo(l,{row:G,id:j,rowIndex:Y});return t+Ha(q,a?.get(j))},A=O.length,k=new Array(A),I=new Array(A),P=i.size>0;let v=0;for(let G=0;G<A;G++){const Y=P?L(O[G],c+G):t;k[G]=Y,v=(v||0)+Y,I[G]=v}const B=S==="infinite"&&N&&O.length>0?Math.min(M,20):0,V=(I[I.length-1]||0)+B*t,Q=(G,Y)=>G?G.reduce((j,q,ne)=>j+L(q,ne),0):Y*t,H=Q(g,c),z=Q(h,u),{left:W,center:re,right:oe}=Fa(x,y),fe=(m?We:0)+(b?We:0)+(w?We:0),le=(w?We:0)+(b&&E?We:0)+(m&&C?We:0),{widths:ce,flexByField:K}=za([...W,...re,...oe],p,f-fe),de=G=>ce.get(G.field)??100,X=G=>({...G,width:de(G),flex:K.get(G.field)??G.flex}),te=11,U=W.map((G,Y)=>({...X(G),zIndex:te+Y})),J=11,se=oe.map((G,Y)=>({...X(G),zIndex:J+(oe.length-1-Y)})),ue=re.map(X),ee=ue.map(G=>G.width),D=U.reduce((G,Y)=>G+Y.width,0),T=se.reduce((G,Y)=>G+Y.width,0),$=ee.reduce((G,Y)=>G+Y,0),F=D+$+T+fe,Z=ee.reduce((G,Y,j)=>(G.push((G[j-1]||0)+Y),G),[]);return{rowHeights:k,cumulativeHeights:I,unpinnedRowsHeight:V,pinnedTopHeight:H,pinnedBottomHeight:z,leftPinnedCols:U,rightPinnedCols:se,unpinnedColsWithWidth:ue,unpinnedColWidths:ee,unpinnedAccWidths:Z,totalWidth:F,leftWidth:D,rightWidth:T,unpinnedTotalWidth:$,systemColumnsWidth:fe,pinnedSystemColumnsWidth:le,pinnedTopRowsLength:c,pinnedBottomRowsLength:u,unpinnedRowsLength:O.length}},[t,n,o,r,i,l,a,c,u,g,h,x,y,p,f,m,b,w,C,E,S,N,M,_])}function Je(e){if(!e)return!1;const t=e.ownerDocument.defaultView;return t?t.getComputedStyle(e).direction==="rtl":!1}function Vn(e,t){return t?e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e:e}function Kt(e){return Je(e)?-e.scrollLeft:e.scrollLeft}function bn(e,t){e.scrollLeft=Je(e)?-t:t}function zn(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 ja(e){const t=e.querySelector(".ogx__sticky-bottom");return t?t.getBoundingClientRect().height:0}function Kn(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:a}=e,c=i.getBoundingClientRect().top-e.getBoundingClientRect().top+l,u=Math.max(o,ja(e)),g=c+(t===0?0:n[t-1]),h=r!==void 0?Math.min(g+r,c+n[t]):c+n[t];g<l+c?e.scrollTop=Math.max(0,g-c):h>l+a-u&&(e.scrollTop=h-a+u)}function Vo(e,t,n){const{unpinnedAccWidths:o,leftWidth:r,rightWidth:i,systemColumnsWidth:l,pinnedSystemColumnsWidth:a}=n;if(t<0||t>=o.length)return;const c=l+r,u=c+(t>0?o[t-1]:0),g=c+o[t],h=a+r,{clientWidth:x}=e,y=Kt(e);u<y+h?bn(e,Math.max(0,u-h)):g>y+x-i&&bn(e,g-x+i)}function zo(e,t){const{row:n,field:o,value:r,colDef:i,rowIndex:l,colIndex:a,rowMeta:c}=e;if(!i.editable||c?.isGroupRow||n._isSkeleton)return!1;if(!t)return!0;try{return!!t({row:n,field:o,value:r,colDef:i,rowIndex:l,colIndex:a})}catch{return!1}}const Ua={},xn=e=>e==null||typeof e=="string"&&e.trim()==="",wi=e=>{const t=[];for(const n of e){const o=dt(n);o!==null&&t.push(o)}return t},bi=(e,t)=>{let n=null,o=null;for(const r of e){const i=dt(r);i!==null&&(n===null||t(i,n))&&(n=i,o=r)}return n===null?null:o instanceof Date?o:n},xt={sum:e=>wi(e).reduce((t,n)=>t+n,0),avg:e=>{const t=wi(e);return t.length?t.reduce((n,o)=>n+o,0)/t.length:null},count:e=>e.filter(t=>!xn(t)).length,min:e=>bi(e,(t,n)=>t<n),max:e=>bi(e,(t,n)=>t>n),unique:e=>new Set(e.filter(t=>!xn(t))).size};function Ko(e,t){return e?e.aggregable===!1?!1:!e.availableAggregationFunctions||e.availableAggregationFunctions.includes(t):!0}function jn(e,t,n,o){const r={};for(const[i,l]of Object.entries(t)){const a=n.get(i);if(!Ko(a,l))continue;const c=xt[l];if(!c){console.warn(`[${o}] Unknown aggregation function: "${l}"`);continue}r[i]=Object.prototype.hasOwnProperty.call(xt,l)?Ra(e,i,a,l):c(e.map(u=>Me(u,i,a)))}return r}function Ra(e,t,n,o){switch(o){case"sum":case"avg":{let r=0,i=0;for(const l of e){const a=dt(Me(l,t,n));a!==null&&(r+=a,i++)}return o==="sum"?r:i?r/i:null}case"count":{let r=0;for(const i of e)xn(Me(i,t,n))||r++;return r}case"min":case"max":{const r=o==="min";let i=null,l=null;for(const a of e){const c=Me(a,t,n),u=dt(c);u!==null&&(i===null||(r?u<i:u>i))&&(i=u,l=c)}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);xn(l)||r.add(l)}return r.size}}}function yn(e,t){return e==null?"—":typeof e=="number"?t==="avg"?e.toLocaleString(void 0,{maximumFractionDigits:2}):e.toLocaleString():String(e)}const qa=new Set(["count","unique"]);function xi(e){return e!==void 0&&qa.has(e)}function yi(e,t,n){return e?.type==="date"&&(t==="min"||t==="max")&&typeof n=="number"&&Number.isFinite(n)?new Date(n):n}function Un(e,t,n,o){if(e==null)return"—";if(xi(t))return yn(e,t);const r=yi(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())?"":mi(r):yn(r,t)}const jt=new Set(["isEmpty","isNotEmpty"]);function jo(e){return e==null?!0:typeof e=="string"?e.trim()==="":Array.isArray(e)?e.length===0:!1}function Xa(e){return e==null?!0:typeof e=="number"?Number.isNaN(e):typeof e=="string"&&e.trim()===""}const Cn=e=>(t,n)=>{const o=dt(t),r=dt(n);return o===null||r===null?!1:e(o,r)},vn=e=>(t,n)=>{const o=Wn(t),r=Wn(n);return o===null||r===null?!1:e(o,r)},Ci=vn((e,t)=>e===t),vi=(e,t)=>{const n=Wn(e),o=Wn(t);return n===null||o===null?!0:n!==o},_i={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()!=="","=":Cn((e,t)=>e===t),">":Cn((e,t)=>e>t),">=":Cn((e,t)=>e>=t),"<":Cn((e,t)=>e<t),"<=":Cn((e,t)=>e<=t),"!=":(e,t)=>{if(jo(t))return!0;const n=dt(e),o=dt(t);return n!==null&&o!==null?n!==o:Xa(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?vi(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?Ci(e,t):String(e).toLowerCase()===String(t).toLowerCase(),after:vn((e,t)=>e>t),onOrAfter:vn((e,t)=>e>=t),before:vn((e,t)=>e<t),onOrBefore:vn((e,t)=>e<=t)},Ya={is:Ci,not:vi};function Ja(e,t){if(!Object.prototype.hasOwnProperty.call(_i,e))return;const n=e;if(t?.type==="date"){const o=Ya[n];if(o)return o}return _i[n]}function Za(e){return"items"in e&&Array.isArray(e.items)}function Qa(e,t){const{field:n,operator:o,value:r}=e;if(!jt.has(o)&&jo(r))return null;const i=t.columns?.byField.get(n),l=Ja(o,i);return l?a=>l(Me(a,n,i),r):(t.warned.has(o)||(t.warned.add(o),console.warn(`Unknown filter operator: ${o}`)),null)}function Uo(e,t,n){const o=[];for(const r of e){const i=Za(r)?Uo(r.items,r.logicOperator,n):Qa(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 Ro(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=pi(t);n&&e.push(n);return}if(Array.isArray(t))for(const n of t)(n==null||typeof n!="object")&&Ro(e,n)}}function qo(e,t){const n=[];if(!t){for(const o of Object.values(e))Ro(n,o);return n}for(const o of t.quickFilterColumns){const r=Me(e,o.field,o),i=$o(e,o.field,r,o);i!=null&&i!==""&&n.push(String(i).toLowerCase()),Ro(n,r)}return n}const Si=new WeakMap;function ec(e,t){if(!t)return qo(e,t);let n=Si.get(t);n||(n=new WeakMap,Si.set(t,n));let o=n.get(e);return o||(o=qo(e,t),n.set(e,o)),o}function ki(e){return(e??[]).map(t=>String(t??"").trim().toLowerCase()).filter(t=>t!=="")}function Ei(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 tc(e,t){const n=ki(e);return n.length===0?null:o=>Ei(ec(o,t),n)}const Mi=new WeakMap;function nc(e,t){const n=Mi.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]:qo(i,t)}return Mi.set(t,{rows:e,texts:o}),o}function Rn(e,t){if(!e)return null;const n={columns:t,warned:new Set},o="quickFilterValues"in e?e.quickFilterValues:void 0,r=tc(o,t),i=Uo(e.items??[],e.logicOperator??"and",n);return r&&i?l=>r(l)&&i(l):r??i}function Xo(e,t,n){const o=n&&t?ki(t.quickFilterValues):[];if(n&&o.length>0){const i=Uo(t.items??[],t.logicOperator??"and",{columns:n,warned:new Set}),l=nc(e,n),a=[];for(let c=0;c<e.length;c++)Ei(l[c],o)&&(!i||i(e[c]))&&a.push(e[c]);return a}const r=Rn(t,n);return r?e.filter(i=>r(i)):e}function Ni(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 Yo(e,t){return e==null?"":t==="date"||e instanceof Date?pi(e)||(typeof e=="string"?e:""):Array.isArray(e)?e.map(n=>String(n)).join(", "):String(e)}const Jo=new Intl.Collator(void 0,{numeric:!0,sensitivity:"accent"}),qn=0,Ii=1,oc=2,Zo=3,Xn=4;function Ut(e,t){return{rank:e,num:t,str:""}}function Yn(e,t){if(e==null)return null;if(t==="number"){const n=dt(e);return n===null?null:Ut(qn,n)}if(t==="date"){const n=wn(e);return n?Ut(Ii,n.getTime()):null}switch(typeof e){case"number":return Number.isNaN(e)?null:Ut(qn,e);case"bigint":return Ut(qn,Number(e));case"boolean":return Ut(oc,e?1:0);case"string":return{rank:Zo,num:0,str:e}}if(e instanceof Date){const n=e.getTime();return Number.isNaN(n)?null:Ut(Ii,n)}return{rank:Xn,num:0,str:String(e)}}function Li(e,t){return e===null&&t===null?0:e===null?1:t===null?-1:e.rank!==t.rank?e.rank-t.rank:e.rank===Zo||e.rank===Xn?Jo.compare(e.str,t.str):e.num<t.num?-1:e.num>t.num?1:0}function Qo(e,t){return e===0?0:t==="asc"?e:-e}function rc(e,t,n,o){return Qo(Li(Yn(e,o),Yn(t,o)),n)}function Ai(e,t,n){let o;try{o=e(t.value,n.value,t,n)}catch(r){return Tt(`sortComparator:${t.field}`,`sortComparator for column "${t.field}" threw; the values are treated as equal`,r),0}return typeof o!="number"||Number.isNaN(o)?(Tt(`sortComparator:${t.field}:nan`,`sortComparator for column "${t.field}" returned ${String(o)}; the values are treated as equal`,void 0),0):o}const ic=e=>e.id;function lc(e,t,n,o=ic){if(t.length===0)return e;if(e.length<2)return[...e];const r=t.map(i=>{const l=n?.byField.get(i.field),a=l?.sortComparator;if(a)return $i(e.map(u=>{const g=Me(u,i.field,l);return{value:g,type:l.type,comparator:a,params:{id:o(u),field:i.field,row:u,value:g}}}));const c=l?.type;return Di(e.length,u=>Me(e[u],i.field,l),()=>c)});return Gi(e,t,r)}function Ti(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)?$i(i):Di(i.length,l=>i[l].value,l=>i[l].type)});return Gi(e,t,o)}const Pi=Xn+1;function Fi(e,t){const n=[...e.keys()].sort(Jo.compare);let o=0;for(let r=0;r<n.length;r++){r>0&&Jo.compare(n[r-1],n[r])!==0&&o++;for(const i of e.get(n[r])??[])t[i]=o}}function Oi(e,t,n){const o=e.get(t);o?o.push(n):e.set(t,[n])}function Di(e,t,n){const o=new Uint8Array(e),r=new Float64Array(e),i=new Map,l=new Map;for(let a=0;a<e;a++){const c=t(a),u=n(a);if(typeof c=="number"&&u!=="date"){Number.isNaN(c)?o[a]=Pi:(o[a]=qn,r[a]=c);continue}const g=Yn(c,u);g===null?o[a]=Pi:(o[a]=g.rank,g.rank===Zo?Oi(i,g.str,a):g.rank===Xn?Oi(l,g.str,a):r[a]=g.num)}return Fi(i,r),Fi(l,r),{kind:"encoded",group:o,num:r}}function $i(e){return{kind:"generic",values:e,keys:e.map(({value:t,type:n})=>Yn(t,n))}}function sc(e,t,n){if(e.kind==="encoded"){const i=e.group[t],l=e.group[n];if(i!==l)return i-l;const a=e.num[t],c=e.num[n];return a<c?-1:a>c?1:0}const o=e.values[t],r=e.values[n];return o.comparator&&o.comparator===r.comparator&&o.params&&r.params?Ai(o.comparator,o.params,r.params):Li(e.keys[t],e.keys[n])}function Gi(e,t,n){const o=e.length,r=new Array(o);for(let a=0;a<o;a++)r[a]=a;const i=n[0];if(n.length===1&&i.kind==="encoded"){const{group:a,num:c}=i,u=t[0].sort==="asc"?1:-1;r.sort((g,h)=>{const x=a[g],y=a[h];if(x!==y)return(x-y)*u;const p=c[g],f=c[h];return p<f?-u:p>f?u:g-h})}else r.sort((a,c)=>{for(let u=0;u<n.length;u++){const g=Qo(sc(n[u],a,c),t[u].sort);if(g!==0)return g}return a-c});const l=new Array(o);for(let a=0;a<o;a++)l[a]=e[r[a]];return l}function ac(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 er(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 Rt="__pivot_grand_total__",cc="__pivot_row__:",Hi=e=>`${cc}${JSON.stringify(e.split(Bi))}`,dc="Grand Total",Bi="\0",qt="",tr=`${qt}id`,Wi=e=>e==="id"?tr:e,nr={pivotRows:[],pivotColumns:[],colKeys:[],isValid:!1},Vi=e=>e.map(t=>String(t??"")).join(Bi),zi=e=>e===void 0||e===""?null:e;function uc(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 fc(e,t){for(let n=0;n<e.length;n++){const o=uc(e[n],t[n]);if(o!==0)return o}return 0}function Ki(e,t){if(!e||e.length===0)return null;const n=xt[t](e);return typeof n=="number"||n instanceof Date?n:null}const gc=e=>"logicOperator"in e&&"items"in e,pc=e=>!!(e&&e.items&&e.items.length>0);function hc(e,t){const n=l=>!t.has(l)&&l.includes(qt),o=l=>gc(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 ji(e,t,n,o={}){const r=new Map(t.map(k=>[k.field,k])),i=k=>r.get(k)?.groupable!==!1,l=n.rowFields.filter(i),a=n.columnFields.filter(i),c=new Set,u=n.valueFields.filter(k=>{if(!Ko(r.get(k.field),k.aggFn))return!1;const I=`${k.field}${qt}${k.aggFn}`;return c.has(I)?!1:(c.add(I),!0)});if(l.length===0||u.length===0)return nr;const g=a.length>0,h=Array.from(new Set(u.map(k=>k.field))),x=(k,I)=>Me(k,I,r.get(I)),y=new Map,p=new Map(g?[]:[["",{values:[]}]]);for(const k of e){const I=l.map(z=>x(k,z)),P=Vi(I);let v=y.get(P);v||(v={labels:I.map(zi),sample:k,cells:new Map},y.set(P,v));const B=a.map(z=>x(k,z)),V=g?Vi(B):"",Q=p.get(V);Q?Q.sample||(Q.sample=k):p.set(V,{values:B.map(zi),sample:k});let H=v.cells.get(V);H||(H=new Map,v.cells.set(V,H));for(const z of h){const W=x(k,z);if(xn(W))continue;let re=H.get(z);re||(re=[],H.set(z,re)),re.push(W)}}const f=Array.from(p.keys()).sort((k,I)=>fc(p.get(k).values,p.get(I).values)),m=(k,I)=>g?`${k}${qt}${I.field}${qt}${I.aggFn}`:`${I.field}${qt}${I.aggFn}`,b=new Map;let w=[];for(const[k,I]of y){const P={id:Hi(k)};l.forEach((v,B)=>{P[Wi(v)]=I.labels[B]}),P.id=Hi(k);for(const v of f){const B=I.cells.get(v);for(const V of u)P[m(v,V)]=Ki(B?.get(V.field),V.aggFn)}b.set(P.id,I),w.push({row:P,entry:I})}const C=k=>l.includes(k),E=k=>C(k)?r.get(k)?.type:"number",{outputFilterModel:S,sortModel:N}=o;if(pc(S)){const k=[];for(const P of f)for(const v of u)k.push({field:m(P,v),type:"number"});const I=Rn(S,er(k));I&&(w=w.filter(({row:P})=>I(P)))}const M=(k,I)=>I==="id"&&C("id")?k[tr]:k[I];N&&N.length>0&&(w=[...w].sort((k,I)=>{for(const P of N){const v=M(k.row,P.field),B=M(I.row,P.field),V=C(P.field)?r.get(P.field)?.sortComparator:void 0,Q=V?Qo(Ai(V,{id:k.row.id,field:P.field,row:k.row,value:v},{id:I.row.id,field:P.field,row:I.row,value:B}),P.sort):rc(v,B,P.sort,E(P.field));if(Q!==0)return Q}return 0}));const _=w.map(k=>k.row);if(w.length>0){const k={id:Rt};l.forEach((I,P)=>{k[Wi(I)]=P===0?dc:""}),k.id=Rt;for(const I of f)for(const P of h){const v=[];for(const{entry:B}of w){const V=B.cells.get(I)?.get(P);if(V)for(const Q of V)v.push(Q)}for(const B of u)B.field===P&&(k[m(I,B)]=Ki(v,B.aggFn))}_.push(k)}const O=w[0]?.entry.sample,L=k=>k===Rt?O:k===void 0?void 0:b.get(k)?.sample,A=l.map(k=>wc(k,r.get(k),L));for(const k of f){const I=p.get(k),P=g?a.map((v,B)=>{const V=r.get(v),Q=mc(V,v,I.values[B],I.sample);return V?.headerName?`${V.headerName}: ${Q}`:Q}).join(" / "):"";for(const v of u){const B=r.get(v.field),V=v.headerName??B?.headerName??v.field;A.push({field:m(k,v),headerName:P?`${P} — ${V} (${v.aggFn})`:`${V} (${v.aggFn})`,width:140,type:"number",align:"right",headerAlign:"right",sortable:!0,valueFormatter:({value:Q,row:H})=>Un(Q,v.aggFn,B,H)})}}return{pivotRows:_,pivotColumns:A,colKeys:f,isValid:!0}}function mc(e,t,n,o){const r=o?$o(o,t,n,e):void 0;return r!==void 0?r:n==null?"":String(n)}function wc(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:a})=>a[tr]);const r=a=>a?.id===Rt,i=t?.valueFormatter;i&&(o.valueFormatter=({value:a,row:c})=>r(c)?String(a??""):i({value:a,row:n(c?.id)??c,field:e}));const l=t?.renderCell;return l&&(o.renderCell=a=>r(a.row)?a.formattedValue??String(a.value??""):l({...a,row:n(a.row.id)??a.row})),o}function Xe(e,t){return e===Rt||t?.get(e)?.isGroupRow===!0}const Pt="__reorder_col__",Ft="__expand_col__",Ze="__checkbox_col__",Qe=e=>e===Pt||e===Ft||e===Ze,or=(e,t)=>e===t||e!==null&&t!==null&&e.id===t.id&&e.field===t.field&&!e.headerFilter==!t.headerFilter,bc=new Set(["checkbox","radio","button","submit","reset","image","file","color"]),xc=new Set(["textbox","searchbox","combobox","listbox","slider","spinbutton"]);function Ui(e){const t=e.tagName;if(t==="INPUT")return!bc.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&&xc.has(n)}const Ri=e=>e!==null&&e.nodeType===1;function qi(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 Jn(e,t){if(e===t)return"grid";if(!Ri(e)||!t.contains(e))return"foreign";const n=qi(e,t);return n?n.classList.contains("ogx__cell--editing")?"editor":n===e?"grid":Ui(e)?"foreign":n.classList.contains("ogx__header-cell--checkbox")?"grid":"control":"foreign"}function yc(e,t,n,o){if(!Ri(e))return null;const r=qi(e,t),i=r?.dataset.field;if(!r||!i)return null;if(r.getAttribute("role")==="columnheader"){const c=r.parentElement;return c?.classList.contains("ogx__header")?{id:null,field:i}:c?.classList.contains("ogx__header-filter-row")?{id:null,field:i,headerFilter:!0}:null}const l=Number(r.parentElement?.getAttribute("data-rowindex")),a=Number.isInteger(l)?n[l]:void 0;return a?{id:o(a),field:i,rowIndex:l}:null}function Xi(e,t){if(!e)return null;for(const n of Array.from(e.children))if(n.dataset.field===t)return n;return null}function rr(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=Xi(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 Xi(o,t.field)}const Yi="__group__";function Ye(e){return!Qe(e)&&e!==Yi}const yt=(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)=>yt(n.anchor,t[o].anchor)&&yt(n.head,t[o].head))}function Zn(e,t,n){const{rowIds:o,fields:r,rowIndexById:i,colIndexByField:l,spans:a}=n,c={top:e,bottom:e,left:t,right:t};if(!a)return c;const u=o[e],g=r[t],h=a.getSpanOrigin(u,g)??{rowId:u,field:g},x=i.get(h.rowId),y=l.get(h.field);if(x===void 0||y===void 0)return c;const p=Math.max(1,a.getRowSpan(h.rowId,h.field)),f=Math.max(1,a.getColSpan(h.rowId,h.field));return{top:x,bottom:Math.min(o.length-1,x+p-1),left:y,right:Math.min(r.length-1,y+f-1)}}function vc(e,t){if(!t.spans)return e;let{top:n,bottom:o,left:r,right:i}=e,l=!0;const a=c=>{c.top<n&&(n=c.top,l=!0),c.bottom>o&&(o=c.bottom,l=!0),c.left<r&&(r=c.left,l=!0),c.right>i&&(i=c.right,l=!0)};for(;l;){l=!1;for(let c=n;c<=o;c++)a(Zn(c,r,t)),i!==r&&a(Zn(c,i,t));for(let c=r+1;c<i;c++)a(Zn(n,c,t)),o!==n&&a(Zn(o,c,t))}return{top:n,bottom:o,left:r,right:i}}function Qn(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:{...vc({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 Ot=e=>(e.bottom-e.top+1)*(e.right-e.left+1);function _c(e,t,n,o,r,i){const{headRow:l,headCol:a,anchorRow:c,anchorCol:u,top:g,bottom:h,left:x,right:y}=e;let p=l,f=a;switch(t){case"ArrowRight":f=a>=u?y+1:a+1;break;case"ArrowLeft":f=a<=u?x-1:a-1;break;case"ArrowDown":p=l>=c?h+1:l+1;break;case"ArrowUp":p=l<=c?g-1:l-1;break;case"Home":f=0,n&&(p=0);break;case"End":f=i,n&&(p=r);break;case"PageUp":p=l-o;break;case"PageDown":p=l+o;break;default:return null}return p=Math.min(Math.max(p,0),r),f=Math.min(Math.max(f,0),i),p===l&&f===a?null:{row:p,col:f}}function Ji(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,ir=1,Zi=2,Qi=4,el=8,tl=16,nl=32;function kc(e,t,n,o){if(!e)return 0;const r=e.fillHandleCol===t?nl:0,i=t+Math.max(1,n)-1;if(t<e.left||i>e.right)return r;let l=ir|r;return e.isTop&&(l|=Zi),(e.isBottom||o>1&&o-1>=e.bottomOffset)&&(l|=Qi),t===e.left&&(l|=el),i===e.right&&(l|=tl),l}function Ec(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 Mc=1e5,Nc=e=>e.id,ol=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]);function Ic(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 a=e.rowIndex;let c=a!==void 0&&t[a]&&o(t[a])===e.id?a:t.findIndex(u=>o(u)===e.id);return c===-1?t.length===0?{cell:{id:null,field:l},rowIndex:-1}:(c=Math.min(Math.max(a??0,0),t.length-1),{cell:{id:o(t[c]),field:l,rowIndex:c},rowIndex:c}):{cell:l===e.field?e:{...e,field:l},rowIndex:c}}function Lc(e){const{allRenderableRows:t,navigationColumns:n,checkboxSelection:o,selectedRowIds:r,handleSelectionChange:i,handleDetailPanelToggle:l,editingHandlers:a,setKeyboardMode:c,sortModel:u,handleSort:g,handleSortAdd:h,multiSort:x=!1,isCellEditable:y,pagination:p,pageSize:f,virtualization:m,viewportRef:b,pinnedTopRowCount:w=0,getRowId:C=Nc,rowMetaMap:E,onRowActivate:S,toggleRowExpansion:N,handleSelectAll:M,rowSelectionEnabled:_=!0,multipleRowSelectionEnabled:O=!0,pinCheckboxColumn:L=!0,pinExpandColumn:A=!0,rowHeight:k,getSpanOrigin:I,cellSelection:P,headerFilters:v=!1}=e,[B,V]=s.useState(null),[Q,H]=s.useState(!1),z=s.useMemo(()=>Ic(B,t,n,C,v),[B,t,n,C,v]),W=z.cell,re=z.rowIndex,oe=s.useRef(!1),fe=s.useRef(!1),le=s.useRef(!1),ce=s.useRef(null),K=s.useCallback(D=>{fe.current=!0,D.focus({preventScroll:!0}),fe.current=!1},[]),de=s.useCallback(()=>{const D=b.current;D&&!D.contains(D.ownerDocument.activeElement)&&K(D)},[b,K]),X=s.useMemo(()=>n.find(D=>!Qe(D.field))??n[0],[n]),te=s.useCallback(()=>{if(o)return{id:null,field:Ze};if(!X)return null;const D=t[0];return D?{id:C(D),field:X.field,rowIndex:0}:{id:null,field:X.field}},[o,X,t,C]),U=s.useCallback((D,T)=>{const $=b.current;if(!$)return;const{cumulativeHeights:F,pinnedBottomHeight:Z,columnMetrics:G}=m;if(D>=0&&Kn($,D-w,F,Z,k),Qe(T)){!(T===Pt||T===Ft&&A||T===Ze&&L)&&Kt($)>0&&bn($,0);return}if(!G)return;const{clientWidth:Y}=$,j=Kt($),{leftPinnedWidth:q,rightPinnedWidth:ne,unpinnedAccWidths:he,unpinnedCols:me,totalSpecialsWidth:R,pinnedSpecialsWidth:ge}=G,we=me.findIndex(Ee=>Ee.field===T);if(we===-1)return;const ae=R+q+(we>0?he[we-1]:0),ye=R+q+he[we],xe=j+ge+q,ie=j+Y-ne;let Ce=j;ae<xe?Ce=Math.max(0,ae-ge-q):ye>ie&&(Ce=ye-Y+ne),Ce!==j&&bn($,Ce)},[b,m,w,k,L,A]);s.useLayoutEffect(()=>{const D=b.current,T=!or(ce.current,W);if(ce.current=W,!D||!W)return;const $=D.ownerDocument,F=$.activeElement;let Z;if(F===D?Z=!0:!F||F===$.body?Z=oe.current:D.contains(F)?Z=T:Z=!1,!Z)return;const G=rr(D,W,re);G?G.contains(F)||G.focus({preventScroll:!0}):F!==D&&K(D)});const J=s.useCallback(()=>{le.current=!0,c(!1)},[c]),se=s.useCallback(D=>{const T=D.currentTarget,$=D.relatedTarget,F=!($ instanceof Node&&T.contains($)),Z=le.current;if(le.current=!1,oe.current=!0,H(!0),fe.current)return;if(D.target===T){if(!F)return;if(Z||c(!0),W){const j=rr(T,W,re);j?j.focus({preventScroll:!0}):U(re,W.field);return}const Y=te();Y&&(V(j=>j??Y),U(Y.rowIndex??-1,Y.field));return}const G=yc(D.target,T,t,C);G&&!or(G,W)&&V(G)},[W,re,te,U,c,t,C]),ue=s.useCallback(D=>{const T=D.relatedTarget;T instanceof Node&&D.currentTarget.contains(T)||(oe.current=!1,le.current=!1,H(!1),c(!1))},[c]),ee=s.useCallback(D=>{const T=D.currentTarget,$=Jn(D.target,T);if($==="foreign"||(c(!0),D.nativeEvent?.isComposing||D.keyCode===229))return;const F=Vn(D.key,Je(T)),Z=F===" "||F==="Spacebar",G=!!a.editingCell,Y=v?-2:-1,j=(pe,ve)=>{const Se=n[ve];!Se||pe<Y||pe>=t.length||(pe===Y?V({id:null,field:Se.field}):pe<0?V({id:null,field:Se.field,headerFilter:!0}):V({id:C(t[pe]),field:Se.field,rowIndex:pe}),U(pe,Se.field))};if(!W){if(!ol.has(F))return;const pe=te();if(!pe)return;D.preventDefault(),V(pe),U(pe.rowIndex??-1,pe.field);return}const{id:q,field:ne}=W,he=q===null&&!!W.headerFilter,me=q!==null?re:he?-1:Y,R=n.findIndex(pe=>pe.field===ne),ge=n.filter(pe=>Qe(pe.field)).length,we=pe=>Xe(pe,E),ae=(pe,ve,Se)=>{const be=n[Se];return Qe(be.field)?!1:zo({row:pe,field:be.field,value:Me(pe,be.field,be),colDef:be,rowIndex:ve,colIndex:Se-ge,rowMeta:E?.get(C(pe))},y)},ye=pe=>{let ve=me,Se=R;const be=(t.length+1)*n.length;for(let De=0;De<be;De++){if(Se+=pe,Se>=n.length?(Se=0,ve++):Se<0&&(Se=n.length-1,ve--),ve<0||ve>=t.length)return null;const ft=t[ve];if(!I?.(C(ft),n[Se].field)&&ae(ft,ve,Se))return{r:ve,c:Se}}return null};if(G){if(F==="Enter")D.preventDefault(),a.stopCellEdit();else if(F==="Escape")D.preventDefault(),a.stopCellEdit({cancel:!0});else if(F==="Tab"&&q!==null){const pe=ye(D.shiftKey?-1:1);pe&&(D.preventDefault(),a.stopCellEdit(),j(pe.r,pe.c))}return}if(F==="Escape"&&P?.collapseSelection()){D.preventDefault();return}if(F==="Tab"||F==="Escape"||$==="control"&&(F==="Enter"||Z))return;if((D.ctrlKey||D.metaKey)&&(F==="a"||F==="A")){if(P){P.selectAllCells()&&D.preventDefault();return}if(!_||!O||!M)return;D.preventDefault(),M(!0);return}if(he&&(F==="Enter"||Z))return;if(q===null){if(F==="Enter"||Z){if(D.preventDefault(),ne===Ze){rr(T,W,-1)?.click();return}const pe=n[R];if(!pe||Qe(ne)||pe.sortable===!1)return;const ve=u.find(be=>be.field===ne),Se=ve?ve.sort==="asc"?"desc":null:"asc";(x||D.shiftKey)&&h?h(ne,Se):g(ne,Se);return}}else if(F==="Enter"||Z){D.preventDefault();const pe=t[me];if(ne===Ze){i(q,!r.has(q));return}if(ne===Ft){D.shiftKey||l(q);return}if(Z){D.shiftKey&&_&&!we(q)&&i(q,!r.has(q));return}if(ne===Pt)return;if(ae(pe,me,R)){a.startCellEdit({id:q,field:ne,value:Me(pe,ne,n[R])});return}if(N&&E?.get(q)?.hasChildren){N(q);return}S?.({row:pe,id:q,rowIndex:me});return}if(D.altKey&&(F==="ArrowRight"||F==="ArrowLeft")&&N&&q!==null){D.preventDefault();const pe=E?.get(q);pe?.hasChildren&&!!pe.isExpanded!=(F==="ArrowRight")&&N(q);return}if(!ol.has(F))return;D.preventDefault();const xe=t.length-1,ie=n.length-1,Ce=D.ctrlKey||D.metaKey,Ee=p?f:10;if(P&&D.shiftKey&&q!==null&&Ye(ne)&&P.extendSelection(F,Ce,Ee,W))return;const Le=(pe,ve)=>{switch(F){case"ArrowRight":return ve+1>ie?{r:pe+1,c:0}:{r:pe,c:ve+1};case"ArrowLeft":return ve-1<0?{r:pe-1,c:ie}:{r:pe,c:ve-1};case"ArrowDown":return{r:pe+1,c:ve};case"ArrowUp":return{r:pe-1,c:ve};case"Home":return{r:Ce?Y:pe,c:0};case"End":return{r:Ce?xe:pe,c:ie};case"PageUp":return{r:Math.max(Y,pe-Ee),c:ve};default:return{r:Math.min(xe,pe+Ee),c:ve}}},Ie=({r:pe,c:ve})=>pe>=Y&&pe<=xe&&ve>=0&&ve<=ie,Ne=({r:pe,c:ve})=>pe>=0?I?.(C(t[pe]),n[ve].field)??null:null;let ke=Le(me,R);if(F.startsWith("Arrow"))for(let pe=Ie(ke)?Ne(ke):null;pe&&pe.rowId===q&&pe.field===ne;pe=Ie(ke)?Ne(ke):null)ke=Le(ke.r,ke.c);if(!Ie(ke))return;const Fe=Ne(ke);if(Fe){const pe=t.findIndex(Se=>C(Se)===Fe.rowId),ve=n.findIndex(Se=>Se.field===Fe.field);pe!==-1&&ve!==-1&&(ke={r:pe,c:ve})}ke.r===me&&ke.c===R||j(ke.r,ke.c)},[W,re,t,n,a,r,i,l,c,u,g,h,x,y,p,f,E,S,N,M,_,O,te,U,I,C,P,v]);return{focusedCell:W,setFocusedCell:V,viewportTabIndex:Q?-1:0,ensureGridFocus:de,handleFocus:se,handleBlur:ue,handleKeyDown:ee,handleMouseDownCapture:J}}const lr=[];function Ac(e){const{isPivotActive:t}=e,n=t?lr: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 Tc=[],Pc={rowFields:[],columnFields:[],valueFields:[]},rl=100;function Fc(e){return!e||e.length===0||e.includes(rl)?rl:e[0]}function Oc(e){const{initialState:t,sortModel:n,onSortModelChange:o,filterModel:r,onFilterModelChange:i,aggregationModel:l,onAggregationModelChange:a,rowGroupingModel:c,onRowGroupingModelChange:u,columnVisibilityModel:g,onColumnVisibilityModelChange:h,pinnedColumns:x,onPinnedColumnsChange:y,pivotModel:p,onPivotModelChange:f,paginationModel:m,onPaginationModelChange:b,pageSizeOptions:w,rowSelectionModel:C,onRowSelectionModelChange:E,density:S,cellSelectionModel:N,onCellSelectionModelChange:M}=e,[_,O]=s.useState(()=>t?.sorting?.sortModel??[]),L=n!==void 0,A=L?n:_,k=s.useCallback(be=>{L||O(be),o?.(be)},[L,o]),[I,P]=s.useState(()=>t?.filter?.filterModel??{items:[]}),v=r!=null,B=v?r:I,V=s.useCallback(be=>{v||P(be),i?.(be)},[v,i]),Q=l!==void 0,[H,z]=s.useState(()=>l??{}),W=JSON.stringify(Q?l:H),re=s.useMemo(()=>JSON.parse(W),[W]),oe=s.useCallback(be=>{Q||z(be),a?.(be)},[Q,a]),fe=c!==void 0,[le,ce]=s.useState(lr),K=(fe?c:le)||lr,de=s.useCallback(be=>{fe||ce(be),u?.(be)},[fe,u]),X=g!==void 0,[te,U]=s.useState(()=>t?.columns?.columnVisibilityModel??{}),J=X?g:te,se=s.useCallback(be=>{X||U(be),h?.(be)},[X,h]),ue=x!==void 0,[ee,D]=s.useState(()=>t?.columns?.pinnedColumns??{}),T=ue?x:ee,$=s.useCallback(be=>{ue||D(be),y?.(be)},[ue,y]),[F,Z]=s.useState(()=>p??Pc),G=p??F,Y=s.useCallback(be=>{Z(be),f?.(be)},[f]),j=m!==void 0,[q,ne]=s.useState(()=>t?.pagination?.paginationModel??m??{page:0,pageSize:Fc(w)}),he=j?m:q,me=s.useCallback(be=>{j||ne(be),b?.(be)},[j,b]),R=C!==void 0,[ge,we]=s.useState([]),ae=R?C:ge,ye=s.useMemo(()=>new Set(ae),[ae]),xe=s.useRef(null);s.useLayoutEffect(()=>{xe.current=null});const ie=s.useCallback(()=>xe.current,[]),Ce=s.useCallback(be=>{xe.current=be,R||we(be),E?.(be)},[R,E]),[Ee]=s.useState(()=>t?.density?.density??"standard"),Le=S??Ee,Ie=N!==void 0,[Ne,ke]=s.useState(Tc),Fe=Ie?N:Ne,pe=s.useRef(null);s.useLayoutEffect(()=>{pe.current=null});const ve=s.useCallback(()=>pe.current,[]),Se=s.useCallback((be,De)=>{pe.current=be,Ie||ke(be),M?.(be,{reason:De})},[Ie,M]);return{sortModel:A,isSortControlled:L,setInternalSortModel:O,handleSortModelChange:k,filterModel:B,isFilterControlled:v,handleFilterModelChange:V,aggregationModel:re,handleAggregationModelChange:oe,rowGroupingModel:K,handleRowGroupingModelChange:de,columnVisibilityModel:J,handleColumnVisibilityModelChange:se,pinnedColumns:T,handlePinnedColumnsChange:$,currentPivotModel:G,handlePivotModelChange:Y,effectivePaginationModel:he,handlePaginationModelChange:me,rowSelectionModel:ae,selectedRowIds:ye,isSelectionControlled:R,setInternalRowSelectionModel:we,handleRowSelectionModelChange:Ce,getPendingRowSelectionModel:ie,density:Le,cellSelectionModel:Fe,handleCellSelectionModelChange:Se,getPendingCellSelectionModel:ve}}const il=s.createContext(null),Dc=52,$c=56,Gc=32,Hc=72;function eo(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 Bc(e){const{rowHeight:t,headerHeight:n,density:o}=e,r=s.useContext(il)?.grid;let i;return o==="compact"?i=eo(r?.rowHeightCompact)??Gc:o==="comfortable"?i=eo(r?.rowHeightComfortable)??Hc:i=t??eo(r?.rowHeightStandard)??Dc,{rowHeight:i,headerHeight:n??eo(r?.headerHeight)??$c}}function to(e){return e>=1?Math.floor(e):1}function sr(e,t){return Math.max(1,Math.ceil(Math.max(0,e)/to(t)))}function Wc(e){const{paginationMode:t,hasDataSource:n,dataSourceRowCount:o,rowCountProp:r,clientRowCount:i}=e;return t!=="server"?i:(n?o??r:r)??i}function ll(e){return e?{paginationRowsPerPage:e.paginationRowsPerPage,paginationOf:e.paginationOf,paginationPage:e.paginationPage}:void 0}function sl(e,t){return Number.isFinite(e)?Math.min(Math.max(0,Math.floor(e)),Math.max(0,t-1)):0}function Vc(e){const{effectiveRows:t,activeHierarchyHandlers:n,filterMode:o,filterModel:r,sortModel:i,sortingMode:l,pagination:a,paginationMode:c,effectivePaginationModel:u,pinnedRows:g,getRowId:h,columnLookup:x,hierarchyField:y}=e,p=s.useMemo(()=>n?n.getVisibleRows({labelField:y})||[]:o==="server"?t:Xo(t,r,x),[t,r,n,y,o,x]),f=s.useMemo(()=>n?o==="server"?t:Xo(t,r,x):p,[n,p,o,t,r,x]),{top:m,center:b,bottom:w}=s.useMemo(()=>n?{top:[],center:p,bottom:[]}:Oa(p,g,h),[p,g,n,h]),C=s.useMemo(()=>n||l==="server"?b:lc(b,i,x,h),[b,i,n,l,x,h]),E=a&&c!=="server",S=to(u.pageSize),N=E?sl(u.page,sr(C.length,S)):u.page,M=s.useMemo(()=>{if(!E)return C;const O=N*S;return C.slice(O,O+S)},[C,E,N,S]),_=s.useMemo(()=>{const O=a?M:C;return[...m,...O,...w]},[m,M,C,w,a]);return{filteredRows:p,dataRows:f,pinnedTopRows:m,unpinnedRows:b,pinnedBottomRows:w,sortedUnpinnedRows:C,paginatedUnpinnedRows:M,currentPage:N,allRenderableRows:_}}const ar=[33554400,17895e3,1e7,5e6],al=new WeakMap;function zc(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 ar)if(n.style.height=`${o}px`,Math.abs(n.getBoundingClientRect().height-o)<2)return o;return ar[ar.length-1]}finally{n.remove()}}function Kc(e){if(!e)return 1/0;const t=al.get(e);if(t!==void 0)return t;const n=zc(e);return al.set(e,n),n}function jc(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}function Uc(e){const[t,n]=s.useState(void 0);return s.useLayoutEffect(()=>{const o=Kc(e.current?.ownerDocument);n(r=>r===o?r:o)},[e]),t}function Rc(e){const{layout:t,scrollTop:n,scrollLeft:o,viewportWidth:r,viewportHeight:i,autoHeight:l,rowReordering:a,hasDetailPanel:c,checkboxSelection:u,pinCheckboxColumn:g,pinExpandColumn:h,overscanRows:x=5,maxContentHeight:y=1/0}=e;return s.useMemo(()=>{const{unpinnedAccWidths:p,unpinnedColsWithWidth:f,leftPinnedCols:m,rightPinnedCols:b,totalWidth:w,leftWidth:C,rightWidth:E,unpinnedTotalWidth:S,systemColumnsWidth:N,cumulativeHeights:M,pinnedTopHeight:_,pinnedBottomHeight:O,unpinnedRowsHeight:L,rowHeights:A,unpinnedRowsLength:k}=t,I=r||1e3,P=l?_+L+O+50:i||600,v=6,B=Math.max(0,o-C),V=o+I-C;let Q=0,H=f.length-1,z=0,W=p.length-1;for(;z<=W;){const D=z+W>>>1;p[D]<B?z=D+1:W=D-1}Q=Math.max(0,z-v);for(let D=Q;D<p.length;D++){if((D===0?0:p[D-1])>V){H=Math.min(f.length-1,D+v);break}H=Math.min(f.length-1,D+v)}const re=Q>0?p[Q-1]:0,oe=S-p[H],fe=[...m,...re>0?[{field:"__spacer_left__",width:re,isSpacer:!0}]:[],...f.slice(Q,H+1),...oe>0?[{field:"__spacer_right__",width:oe,isSpacer:!0}]:[],...b],ce=I>0&&w>I?16:0,K=_+L+O+ce+2,de=K-_-O,X=Number.isFinite(y)?Math.max(0,Math.min(de,y-_-O)):de;let te=0,U=k-1,J=0,se=0,ue=M.length-1;for(;se<=ue;){const D=se+ue>>>1;M[D]<n?se=D+1:ue=D-1}te=Math.max(0,se-x),J=te>0?M[te-1]:0;for(let D=te;D<M.length;D++)if(M[D]>=n+P){U=Math.min(k-1,D+x);break}const ee=(a?48:0)+(c&&h?48:0)+(u&&g?48:0);return{renderContext:{firstRowIndex:te,lastRowIndex:U,firstColumnIndex:Q,lastColumnIndex:H},offsetTop:J,offsetLeft:0,totalHeight:K,virtualContainerHeight:X,pinnedTopHeight:_,pinnedBottomHeight:O,totalWidth:w,rowHeights:A,cumulativeHeights:M,virtualColumns:fe,columnMetrics:{leftPinnedWidth:C,rightPinnedWidth:E,unpinnedAccWidths:p,unpinnedCols:f,totalSpecialsWidth:N,pinnedSpecialsWidth:ee}}},[t,n,o,r,i,l,a,c,u,g,h,x,y])}const cr="application/x-ogx-row",dr="application/x-ogx-column";function cl(e,t,n){const o=e.dataTransfer;!o||typeof o.setData!="function"||(o.setData(t,n),o.setData("text/plain",n))}function no(e,t){const n=e.dataTransfer?.types;return n?Array.from(n).includes(t):!0}function dl(e,t){if(!e||typeof e.addEventListener!="function")return()=>{};const n=()=>t();return e.addEventListener("dragend",n,{once:!0}),()=>e.removeEventListener("dragend",n)}function qc(e){const{columns:t,onColumnOrderChange:n,disableColumnReorder:o=!1}=e,[r,i]=s.useState(null),[l,a]=s.useState(null),c=s.useRef(()=>{}),u=s.useCallback(()=>{c.current(),c.current=()=>{},i(null),a(null)},[]);s.useEffect(()=>()=>c.current(),[]);const g=s.useCallback(y=>p=>{if(!o){if(!t.some(f=>f.field===y)){p.preventDefault();return}c.current(),c.current=dl(p.currentTarget,u),i(y),p.dataTransfer&&(p.dataTransfer.effectAllowed="move",cl(p,dr,y))}},[t,o,u]),h=s.useCallback(y=>p=>{if(!(o||r===null)){if(!no(p,dr)){u();return}p.preventDefault(),p.dataTransfer&&(p.dataTransfer.dropEffect="move"),a(y)}},[r,o,u]),x=s.useCallback(y=>p=>{if(p.preventDefault(),o||r===null||!no(p,dr)){u();return}const f=t.findIndex(b=>b.field===r),m=t.findIndex(b=>b.field===y);u(),!(f===-1||m===-1||f===m)&&n?.({column:t[f],oldIndex:f,targetIndex:m})},[t,r,o,n,u]);return{draggedColumn:r,dragOverColumn:l,onDragStart:o?void 0:g,onDragOver:o?void 0:h,onDragEnd:o?void 0:u,onDrop:o?void 0:x}}function ur({isExpanded:e,onClick:t,variant:n="chevron",tabIndex:o}){return d.jsx("button",{className:`ogx-expand-icon ${e?"ogx-expand-icon--expanded":""}`,onClick:r=>{t&&t(r)},"aria-label":e?"Collapse row":"Expand row",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 Xc({renderFn:e}){"use no memo";return d.jsx(d.Fragment,{children:e()})}function Yc(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 Dt extends s.Component{constructor(t){super(t),this.state={hasError:!1,error:null,resetKey:t.resetKey}}static getDerivedStateFromProps(t,n){return Yc(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("div",{className:"ogx__cell-error",role:"img","aria-label":`Error in cell: ${this.props.field}`,title:this.state.error?.message??"Render error",children:"⚠"}):d.jsx(Xc,{renderFn:this.props.renderFn})}}function Jc(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)?Un(l.value,t,e,l.row):i?i(l):l.value==null?"":String(l.value)}}function ul(e,t){if(!t)return e;const n=t.left??[],o=t.right??[],r=i=>{const l=ct(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 oo=e=>e.formattedValue??e.value;function fl(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(Dt,{field:e.field,resetKey:t.row,renderFn:()=>{throw l}})}}return r&&i===void 0?{useDefault:!0}:{useDefault:!1,content:d.jsx(Dt,{field:e.field,resetKey:t.row,renderFn:()=>i})}}function Zc(e,t,n){const o=e.rowMeta;if(!o?.isGroupRow)return oo(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})`:""]}):oo(e)}const Qc=e=>e.id;function ed(e){const{activeColumns:t,isHierarchyEnabled:n,isRowGrouping:o,isTreeData:r,activeHierarchyHandlers:i,columnVisibilityModel:l,columnOrder:a,onColumnOrderChange:c,onColumnOrderModelChange:u,disableColumnReorder:g,pivotMode:h,checkboxSelection:x,hasDetailPanel:y,rowReordering:p,initialState:f,setColumns:m,pinnedColumns:b,getRowId:w=Qc,aggregationModel:C,groupingRows:E}=e,S=s.useMemo(()=>t.map(U=>U.field),[t]),[N,M]=s.useState(()=>f?.columns?.columnOrder??null),_=h?S.join("\0"):"",[O,L]=s.useState(null),A=O&&O.key===_?O.order:S,I=h?A:a??(N??S),P=s.useCallback(U=>{if(h){L(J=>{const se=J&&J.key===_?J.order:S;return{key:_,order:typeof U=="function"?U(se):U}});return}M(J=>typeof U=="function"?U(J??S):U)},[h,_,S]),v=s.useCallback(U=>h&&U.hideable===!1||l[U.field]!==!1,[h,l]),B=s.useMemo(()=>{if(!n)return;const U=new Map(I.map((ee,D)=>[ee,D])),J=ee=>U.get(ee.field)??t.indexOf(ee),se=[...t].sort((ee,D)=>J(ee)-J(D));return(ul(se.filter(ee=>l[ee.field]!==!1),b)[0]??t[0])?.field},[n,I,t,l,b]),V=s.useMemo(()=>{if(!n)return t;const U=o?E:void 0;return t.map(J=>{const se=Jc(J,C?.[J.field],U);return J.field===B?{...J,...se,renderCell:ue=>{const ee=ue.rowMeta,D=ee?.treeDepth??0,T=!!ee?.hasChildren,$=!!ee?.isExpanded,F=fl(J,ue,!0),Z=F.useDefault?Zc(ue,o,r):F.content;return d.jsxs("div",{style:{display:"flex",alignItems:"center",paddingInlineStart:D*24,width:"100%",height:"100%"},children:[d.jsx("div",{style:{marginInlineEnd:4,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",cursor:T?"pointer":"default",flexShrink:0},children:T?d.jsx("div",{onClick:G=>{G.stopPropagation(),G.preventDefault(),i?.toggleExpansion(w(ue.row))},onMouseDown:G=>{G.stopPropagation()},style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:10,position:"relative"},children:d.jsx(ur,{isExpanded:$,tabIndex:-1,onClick:G=>{G.stopPropagation(),G.preventDefault(),i?.toggleExpansion(w(ue.row))}})}):null}),d.jsx("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Z})]})}}:{...J,...se,renderCell:ue=>{const ee=ue.rowMeta;if(!ee?.isGroupRow)return J.renderCell?J.renderCell(ue):oo(ue);const D=fl(J,ue,!1);return D.useDefault?J.field===ee.groupingField&&!ee.isGroupFooter||ue.value==null?null:oo(ue):D.content}}})},[t,n,o,r,i,B,w,C,E]),[Q,H]=s.useState(()=>f?.columns?.columnWidths??{}),z=s.useCallback((U,J)=>{H(se=>({...se,[U]:J}))},[]);s.useEffect(()=>{m(t)},[t,m]);const W=s.useMemo(()=>{const U=new Map(I.map((J,se)=>[J,se]));return[...V].sort((J,se)=>{const ue=U.get(J.field)??V.indexOf(J),ee=U.get(se.field)??V.indexOf(se);return ue-ee})},[V,I]),re=s.useMemo(()=>W.filter(v),[W,v]),oe=s.useCallback((U,J)=>{(h||!a)&&P(U),J&&c?.(J),h||u?.(U)},[h,a,P,c,u]),fe=s.useCallback((U,J)=>{const se=W.map(ee=>ee.field),[ue]=se.splice(U,1);se.splice(J,0,ue),oe(se,{column:W[U],oldIndex:U,targetIndex:J})},[W,oe]),le=qc({columns:W,onColumnOrderChange:s.useCallback(({oldIndex:U,targetIndex:J})=>fe(U,J),[fe]),disableColumnReorder:g}),ce=s.useCallback((U,J)=>{const se=W.findIndex(ee=>ee.field===U),ue=W.findIndex(ee=>ee.field===J);se===-1||ue===-1||se===ue||fe(se,ue)},[W,fe]),K=s.useCallback(()=>{oe(S)},[oe,S]),de=s.useMemo(()=>ul(re,b),[re,b]),X=s.useMemo(()=>{const U=[];return p&&U.push({field:Pt,sortable:!1,editable:!1}),y&&U.push({field:Ft,sortable:!1,editable:!1}),x&&U.push({field:Ze,sortable:!1,editable:!1}),[...U,...de]},[de,x,y,p]),te=s.useMemo(()=>new Map(de.map((U,J)=>[U.field,J])),[de]);return{effectiveColumns:V,hierarchyField:B,orderedColumns:W,visibleOrderedColumns:re,renderOrderedColumns:de,navigationColumns:X,columnIndexMap:te,columnWidths:Q,effectiveColumnOrder:I,setInternalColumnOrder:P,columnReorderHandlers:le,moveColumn:ce,resetColumnOrder:K,handleColumnResize:z}}const td=e=>e.id;function nd(e){const{renderContext:t,pinnedTopRows:n,pinnedBottomRows:o,paginatedUnpinnedRows:r,sortedUnpinnedRows:i,pagination:l,getRowId:a=td}=e;return s.useMemo(()=>{const{firstRowIndex:c,lastRowIndex:u}=t,g=l?r:i,h=n.length,x=n.map((C,E)=>({row:C,id:a(C),rowIndex:E,pinned:"top"})),y=o.map((C,E)=>({row:C,id:a(C),rowIndex:h+g.length+E,pinned:"bottom"})),p=Math.max(0,c),f=Math.min(g.length,u+1),m=g.slice(p,f).map((C,E)=>({row:C,id:a(C),rowIndex:h+p+E})),b=[...x,...m,...y],w=new Set;return b.filter(C=>w.has(C.id)?!1:(w.add(C.id),!0))},[t,n,o,r,i,l,a])}const od=100;function gl(e){const{scrollTop:t,scrollHeight:n,clientHeight:o}=e;return n-t-o>=od?null:{visibleTop:t,visibleBottom:t+o,viewportHeight:o}}function rd(e){return e<.5?3:e<3?5:e<15?12:e<40?20:30}function id(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}),a=s.useRef(null),c=s.useRef(null),u=s.useRef(null),g=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(()=>()=>{a.current!==null&&cancelAnimationFrame(a.current),c.current!==null&&clearTimeout(c.current)},[]);const p=s.useCallback(b=>{const w=gl(b);if(!w){g.current=!0;return}if(!g.current)return;const C=h.current;C&&(g.current=!1,C(w))},[]),f=s.useCallback(b=>{const w=b.currentTarget,C=performance.now(),E=Kt(w),S=Math.abs(w.scrollTop-l.current.scrollTop)+Math.abs(E-l.current.scrollLeft),N=C-l.current.time,M=N>0?S/N:0,_=w.scrollTop!==l.current.scrollTop;l.current={scrollTop:w.scrollTop,scrollLeft:E,time:C},i.current={scrollTop:w.scrollTop,scrollLeft:E,velocity:M},a.current!==null&&cancelAnimationFrame(a.current),a.current=requestAnimationFrame(()=>{a.current=null;const{scrollTop:O,scrollLeft:L,velocity:A}=i.current;y({scrollTop:O,scrollLeft:L,velocityOverscan:rd(A)})}),c.current!==null&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,y(O=>O.velocityOverscan===0?O:{...O,velocityOverscan:0})},200),_&&p(w)},[p]);s.useEffect(()=>{g.current=!0;const b=u.current;!b||r||o<=0||b.clientHeight===0||p(b)},[o,r,p]),s.useEffect(()=>{const b=u.current?.ownerDocument??(typeof document>"u"?null:document);if(!b||typeof MutationObserver>"u")return;const w=new MutationObserver(()=>{const C=u.current;if(!C)return;const E={scrollTop:C.scrollTop,scrollLeft:Kt(C)},S=i.current;E.scrollTop===S.scrollTop&&E.scrollLeft===S.scrollLeft||(i.current={...S,...E},l.current={...l.current,...E},y(N=>({...N,...E})))});return w.observe(b.documentElement,{attributes:!0,attributeFilter:["dir"],subtree:!0}),()=>w.disconnect()},[]);const m=s.useCallback(b=>{if(u.current=b,!b)return;const{scrollTop:w,scrollLeft:C}=i.current;if(w===0&&C===0)return;b.scrollTop=w,bn(b,C);const E={scrollTop:b.scrollTop,scrollLeft:Kt(b)};(E.scrollTop!==w||E.scrollLeft!==C)&&(i.current={...i.current,...E},l.current={...l.current,...E},y(S=>({...S,...E})))},[]);return{scrollTop:x.scrollTop,scrollLeft:x.scrollLeft,overscanRows:Math.max(x.velocityOverscan,n),handleScroll:f,attachViewport:m}}function ld(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:a}=i.contentRect;e(l,a)}});o.observe(n),t.current=o},[e])}function sd(e){const{setDimensions:t,viewportRef:n,...o}=e,{scrollTop:r,scrollLeft:i,overscanRows:l,handleScroll:a,attachViewport:c}=id(o),u=ld(t),g=s.useCallback(h=>{n.current=h,u(h),c(h)},[n,u,c]);return{scrollTop:r,scrollLeft:i,overscanRows:l,handleScroll:a,setViewportElement:g}}function ad(){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 cd(e){const{hasDetailPanel:t,controlledExpandedRowIds:n,onDetailPanelExpandedRowIdsChange:o,rowMetaMap:r}=e,[i,l]=s.useState(new Set),a=n??i,c=s.useMemo(()=>Ba(a,r),[a,r]),u=s.useCallback(x=>{if(r.get(x)?.isGroupRow)return;const y=new Set(a);y.has(x)?y.delete(x):y.add(x),n===void 0&&l(y),o?.(y)},[a,r,n,o]),{detailPanelHeights:g,reportDetailPanelHeight:h}=ad();return{hasDetailPanel:t,expandedRowIds:c,handleDetailPanelToggle:u,detailPanelHeights:g,reportDetailPanelHeight:h}}const dd=new Set(["__group__"]),_n=e=>!dd.has(e);function pl(e){return Object.keys(e).every(_n)?e:Object.fromEntries(Object.entries(e).filter(([n])=>_n(n)))}function ud(e){const t={...e};return e.left&&(t.left=e.left.filter(_n)),e.right&&(t.right=e.right.filter(_n)),t}function fd(e){const{onStateChange:t,sortModel:n,filterModel:o,effectivePaginationModel:r,columnWidths:i,effectiveColumnOrder:l,columnVisibilityModel:a,pinnedColumns:c,density:u}=e,g=s.useRef(t);s.useLayoutEffect(()=>{g.current=t});const h=s.useRef(null);s.useEffect(()=>{if(!g.current)return;const x={sorting:{sortModel:n},filter:{filterModel:o},pagination:{paginationModel:r},columns:{columnWidths:pl(i),columnOrder:l.filter(_n),columnVisibilityModel:pl(a),pinnedColumns:ud(c)},density:{density:u}},y=JSON.stringify(x);y!==h.current&&(h.current=y,g.current(x))},[n,o,r,i,l,a,c,u])}const gd=200,pd=2e3,hd=178e5;function md(e){const{paginationRequested:t,isRowGrouping:n,autoHeight:o,viewportHeight:r,renderedRowCount:i,totalRowCount:l,pinnedRowsIgnored:a=!1,scrollHeight:c=0,maxContentHeight:u,reachableRowCount:g,unpinnedRowCount:h,listViewWithoutColumn:x=!1,listViewRowCount:y=0}=e,p=s.useRef(!1),f=s.useRef(!1),m=s.useRef(!1),b=s.useRef(!1),w=s.useRef(!1),C=s.useRef(!1);s.useEffect(()=>{process.env.NODE_ENV==="production"||C.current||y<=pd||(C.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"||w.current||!x||(w.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"||m.current||!a||(m.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."))},[a]),s.useEffect(()=>{if(process.env.NODE_ENV==="production"||b.current||u===void 0)return;const E=Number.isFinite(u);if(E?c<=u:c<=hd)return;b.current=!0;const S=E&&g!==void 0&&h!==void 0?`Only the first ${g.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(c)}px tall, more than this browser lays out (about 17.9M px in Firefox, 33.5M px in Chrome and Safari). `+S+"Use pagination, server-side or infinite loading, or a smaller rowHeight. See docs/features/virtualization.md.")},[c,u,g,h]),s.useEffect(()=>{process.env.NODE_ENV==="production"||p.current||t&&n&&(p.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"||f.current||o||r>0&&l>gd&&i>=l&&r>=c&&(f.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,c])}function wd(e){return typeof window>"u"||typeof window.getComputedStyle!="function"||typeof navigator<"u"&&/jsdom/i.test(navigator.userAgent)?!1:window.getComputedStyle(e).display!=="flex"}let hl=!1;function bd(e){s.useEffect(()=>{if(process.env.NODE_ENV==="production"||hl)return;const t=e.current;!t||!wd(t)||(hl=!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])}function ro(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 xd(e,t,n){return n?e.has(t)?[]:[t]:ro(e,[t],!e.has(t),!1)}function ml(e,t){return t.length===e.size&&t.every(n=>e.has(n))}function yd(e){const{selectedRowIds:t,onSelectionModelChange:n,disableMultipleRowSelection:o,selectableRowIds:r}=e,i=s.useCallback(h=>{ml(t,h)||n(h)},[t,n]),l=s.useCallback((h,x)=>{i(ro(t,[h],x,o))},[i,t,o]),a=s.useCallback(h=>{i(xd(t,h,o))},[i,t,o]),c=s.useCallback(h=>{i(ro(t,r,h,!1))},[i,t,r]),{allSelected:u,someSelected:g}=s.useMemo(()=>{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:a,selectAll:o?void 0:c,allSelected:u,someSelected:g}}function Cd(e){const{dataRows:t,getRowId:n,isPivotActive:o,selectedRowIds:r,onSelectionModelChange:i,disableMultipleRowSelection:l,disableRowSelectionOnClick:a,isHierarchyEnabled:c,rowMetaMap:u,activeHierarchyHandlers:g,onRowClick:h}=e,x=s.useMemo(()=>{const w=t.map(n);return o?w.filter(C=>C!==Rt):w},[t,n,o]),y=yd({selectedRowIds:r,onSelectionModelChange:i,disableMultipleRowSelection:l,selectableRowIds:x}),{clickRow:p,toggleRow:f}=y,m=s.useCallback(w=>{const{id:C}=w,E=c?u.get(C):void 0;if(E?.isGroupRow){E.hasChildren&&g?.toggleExpansion(C);return}h?.(w),!a&&!Xe(C,u)&&p(C)},[c,g,h,u,a,p]),b=s.useCallback((w,C)=>{Xe(w,u)||f(w,C)},[u,f]);return{rowSelection:y,handleRowClick:m,handleSelectionChange:b}}const wl=e=>JSON.stringify(Array.from(e,t=>typeof t=="number"?["n",t]:["s",t]));function vd(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;const g=new Set;for(const h of t)n.has(h)||o.has(h)?g.add(h):u=!0;return u?g:t},[r,t,n,o]),a=s.useRef(i);s.useLayoutEffect(()=>{a.current=i});const c=s.useRef(null);return s.useEffect(()=>{if(l===t){c.current=null;return}const u=`${wl(t)}|${wl(l)}`;c.current!==u&&(c.current=u,a.current(Array.from(l)))},[l,t]),l}function fr(e,t,n,o){return o?ac(e,t,n):n?[{field:t,sort:n}]:e.filter(r=>r.field!==t)}function _d(e){const{sortModel:t,onSortModelChange:n}=e,o=s.useCallback((i,l)=>{n(fr(t,i,l,!1))},[t,n]),r=s.useCallback((i,l)=>{n(fr(t,i,l,!0))},[t,n]);return{handleSort:o,handleSortAdd:r}}function Sd(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(c=>{const u={...i.current.columnVisibilityModel,[c]:!1};i.current={...i.current,columnVisibilityModel:u},n(u)},[n]),a=s.useCallback((c,u)=>{const g=Da(i.current.pinnedColumns,c,u);i.current={...i.current,pinnedColumns:g},r(g)},[r]);return{handleHideColumn:l,handlePinColumn:a}}function kd(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=(c,u)=>{const{sortModel:g,multiSort:h,onSortModelChange:x}=r(),y=fr(g,c,u,h);n.current={...r(),sortModel:y},x(y)},o.getFilterModel=()=>r().filterModel,o.setFilterModel=c=>{n.current={...r(),filterModel:c},r().onFilterModelChange(c)};const i=c=>{n.current={...r(),paginationModel:c},r().onPaginationModelChange(c)};o.setPage=c=>i({...r().paginationModel,page:c}),o.setPageSize=c=>i({...r().paginationModel,pageSize:c,page:0});const l=()=>{const c=r().getPendingRowSelectionModel?.();return c?new Set(c):r().selectedRowIds},a=(c,u)=>{const{disableMultipleRowSelection:g,onRowSelectionModelChange:h,isSyntheticRowId:x}=r(),y=x?c.filter(m=>!x(m)):c;if(y.length===0)return;const p=l(),f=ro(p,y,u,g);ml(p,f)||(n.current={...r(),selectedRowIds:new Set(f)},h(f))};o.getSelectedRows=()=>Array.from(l()),o.selectRow=(c,u=!0)=>a([c],u),o.selectRows=(c,u=!0)=>a(c,u),o.getVisibleRows=()=>r().getVisibleRows(),o.getAllFilteredRows=()=>r().getAllFilteredRows(),o.getVisibleColumns=()=>r().visibleColumns,o.setSortModel=c=>{n.current={...r(),sortModel:c},r().onSortModelChange(c)},o.setRowGroupingModel=c=>{n.current={...r(),rowGroupingModel:c},r().onRowGroupingModelChange(c)},o.setAggregationModel=c=>{n.current={...r(),aggregationModel:c},r().onAggregationModelChange(c)},o.setColumnVisibilityModel=c=>{n.current={...r(),columnVisibilityModel:c},r().onColumnVisibilityModelChange(c)},o.setPivotModel=c=>{n.current={...r(),pivotModel:c},r().onPivotModelChange(c)},o.getGridAiState=()=>{const{filterModel:c,sortModel:u,rowGroupingModel:g,aggregationModel:h,pivotModel:x,columnVisibilityModel:y}=r();return{filterModel:c,sortModel:u,rowGroupingModel:g,aggregationModel:h,pivotModel:x,columnVisibilityModel:y}}},[t])}const bl="\0";function Ed(e,t){const n=e.filter(o=>t[o.field]===!1).map(o=>o.field).join(bl);return s.useMemo(()=>{const o={};if(n)for(const r of n.split(bl))o[r]=!1;return er(e,o)},[e,n])}function Md({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 a=`${i}>${t}`;if(l.current===a)return;l.current=a;const{paginationModel:c,onPaginationModelChange:u}=r.current;u({...c,page:t})},[n,t,i])}function Nd(){const[e,t]=s.useState(!1),[n,o]=s.useState(!1),r=s.useRef(null),i=s.useRef(0),[l,a]=s.useState(0),[c,u]=s.useState(!1),g=s.useMemo(()=>({registerColumnsPanel:()=>(i.current+=1,()=>{i.current-=1}),registerFiltersPanel:()=>(a(m=>m+1),()=>a(m=>m-1))}),[]),h=s.useCallback(()=>u(!0),[]),x=s.useCallback(()=>u(!1),[]),y=s.useCallback(()=>{i.current>0?t(!0):o(!0)},[]),p=s.useCallback(()=>t(!1),[]),f=s.useCallback(()=>o(!1),[]);return s.useEffect(()=>{if(!n)return;function m(w){r.current&&!r.current.contains(w.target)&&o(!1)}function b(w){w.key==="Escape"&&o(!1)}return document.addEventListener("mousedown",m),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("keydown",b)}},[n]),{toolbarHost:g,toolbarPanelRequested:e,closeToolbarPanel:p,standalonePanelOpen:n,closeStandalonePanel:f,standalonePanelRef:r,openColumnsPanel:y,toolbarFiltersRequested:c,closeToolbarFiltersPanel:x,openFiltersPanel:l>0?h:void 0}}const xl=s.createContext(null);function Id(e){if(typeof e!="function")return!1;const t=e.prototype;return!(typeof t=="object"&&t!==null&&"isReactComponent"in t)}function Ld({render:e,toolbarProps:t}){"use no memo";return d.jsx(d.Fragment,{children:e(t)})}function Ad({component:e,toolbarProps:t}){if(Id(e))return d.jsx(Ld,{render:e,toolbarProps:t},`fn:${e.toString()}`);const n=e;return d.jsx(n,{...t})}const yl=48;function Td({columns:e,aggregationModel:t,aggregationResult:n,columnWidths:o,rowHeight:r,checkboxSelection:i,hasDetailPanel:l,rowReordering:a,pinCheckboxColumn:c=!0,pinExpandColumn:u=!0,pinnedColumns:g,loading:h=!1}){const x=s.useMemo(()=>Fo(e,o,g,i,c,l,u,a),[e,o,g,i,c,l,u,a]),{lastLeft:y,firstRight:p}=s.useMemo(()=>Oo(e,g),[e,g]),f=a?yl:0,m=f+(l&&u?yl:0),b=(w,C,E)=>d.jsx("div",{className:`ogx__aggregation-spacer${C?" ogx__aggregation-spacer--pinned":""}`,style:C?{insetInlineStart:E}:void 0,"aria-hidden":"true"},w);return d.jsxs("div",{className:`ogx__aggregation-footer${h?" ogx__aggregation-footer--loading":""}`,role:"row","aria-label":"Aggregation totals","aria-live":"polite","aria-busy":h||void 0,style:{minHeight:`${r}px`},children:[a&&b("__reorder_col__",!0,0),l&&b("__expand_col__",u,f),i&&b("__checkbox_col__",c,m),e.map(w=>{if(w.isSpacer){const A=typeof w.width=="number"?w.width:0;return d.jsx("div",{style:{width:A,minWidth:A,flexShrink:0},"aria-hidden":"true"},w.field)}const C=t[w.field],E=C&&Ko(w,C)?C:void 0,S=n[w.field],N=At(w,o,120),M=ct(w.field,g),_=M?x[w.field]:void 0,O=["ogx__aggregation-cell",M==="left"&&"ogx__aggregation-cell--pinned-left",M==="right"&&"ogx__aggregation-cell--pinned-right",M==="left"&&w.field===y&&"ogx__aggregation-cell--pinned-left-last",M==="right"&&w.field===p&&"ogx__aggregation-cell--pinned-right-first"].filter(Boolean).join(" "),L={width:N,minWidth:N,maxWidth:N,textAlign:w.align||"left"};return M==="left"&&_!==void 0&&(L.insetInlineStart=_),M==="right"&&_!==void 0&&(L.insetInlineEnd=_),d.jsx("div",{className:O,role:"gridcell",style:L,children:E?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"ogx__aggregation-label",children:E}),d.jsx("span",{className:"ogx__aggregation-value",children:Un(S,E,w,n)})]}):null},w.field)})]})}function Pd({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})]})}function Cl({dataSource:e,paginationMode:t,sortingMode:n,filterMode:o}){return!!e&&(t==="server"||t==="infinite"||n==="server"||o==="server")}const vl=Number.MAX_SAFE_INTEGER,Fd="An unexpected error occurred while loading the data.";function _l(e){return typeof e=="string"&&e?e:typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"&&e.message?e.message:Fd}function Od({error:e,onRetry:t}){if(!e)return null;const n=_l(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:"Oops! Something went wrong"}),d.jsx("div",{className:"ogx-error-overlay__message",children:n}),t&&d.jsx("button",{type:"button",onClick:t,className:"ogx-button ogx-button--primary",children:"Retry"})]})}function Sl(e,t){typeof e=="function"?e(t):e&&(e.current=t)}const Ct=s.forwardRef(function({indeterminate:t=!1,label:n,className:o="",inputClassName:r="",inputRef:i,...l},a){const c=s.useRef(null),u=s.useCallback(h=>{c.current=h,Sl(i,h),Sl(a,h)},[i,a]);s.useEffect(()=>{c.current&&(c.current.indeterminate=t)},[t]);const g=["ogx-checkbox-wrapper",l.disabled&&"ogx-checkbox-wrapper--disabled",o].filter(Boolean).join(" ");return d.jsxs("label",{className:g,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})]})});Ct.displayName="Checkbox";const kl=50;function gr(e,t,n,o){const r=Math.min(n??kl,t),i=Math.max(o??1/0,t);return Math.max(r,Math.min(i,e))}const Dd=16;function $d(e){e.preventDefault(),e.stopPropagation()}function Gd(){const e=t=>{t.stopPropagation(),t.preventDefault()};window.addEventListener("click",e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener("click",e,{capture:!0}),0)}function Hd(e){const{field:t,currentWidth:n,onResize:o,onAutosize:r,minWidth:i,maxWidth:l,edge:a="end"}=e,[c,u]=s.useState(!1),g=s.useRef(null);s.useEffect(()=>()=>{g.current=null},[]);const h=s.useCallback((w,C)=>{const E=(C-w.startX)*(w.rtl?-1:1),S=w.startWidth+(a==="start"?-E:E);return gr(S,w.startWidth,i,l)},[a,i,l]),x=s.useCallback(w=>{if(w.button===0){w.stopPropagation(),g.current={pointerId:w.pointerId,startX:w.clientX,startWidth:n,rtl:Je(w.currentTarget),lastUpdate:0,moved:!1},u(!0);try{w.currentTarget.setPointerCapture(w.pointerId)}catch{}}},[n]),y=s.useCallback(w=>{const C=g.current;if(!C||w.pointerId!==C.pointerId||(w.clientX!==C.startX&&(C.moved=!0),!C.moved))return;const E=Date.now();E-C.lastUpdate>=Dd&&(C.lastUpdate=E,o(t,h(C,w.clientX)))},[t,o,h]),p=s.useCallback((w,C)=>{const E=g.current;if(!(!E||w.pointerId!==E.pointerId)){if(g.current=null,u(!1),w.currentTarget.hasPointerCapture?.(w.pointerId))try{w.currentTarget.releasePointerCapture(w.pointerId)}catch{}(E.moved||w.clientX!==E.startX)&&(Gd(),C&&o(t,h(E,w.clientX)))}},[t,o,h]),f=s.useCallback(w=>{if(w.key==="Enter"&&r){w.preventDefault(),w.stopPropagation(),r(t);return}if(w.key!=="ArrowLeft"&&w.key!=="ArrowRight")return;w.preventDefault(),w.stopPropagation();const C=Vn(w.key,Je(w.currentTarget)),E=(w.shiftKey?50:10)*(C==="ArrowRight"?1:-1);o(t,gr(n+E,n,i,l))},[t,n,o,r,i,l]),m=s.useCallback(w=>{w.preventDefault(),w.stopPropagation(),r?.(t)},[t,r]),b=["ogx-column-resize-handle",a==="start"&&"ogx-column-resize-handle--start",c&&"ogx-column-resize-handle--dragging"].filter(Boolean).join(" ");return d.jsx("div",{className:b,onPointerDown:x,onMouseDown:$d,onPointerMove:y,onPointerUp:w=>p(w,!0),onPointerCancel:w=>p(w,!1),onClick:w=>w.stopPropagation(),onDragStart:w=>{w.preventDefault(),w.stopPropagation()},onDoubleClick:m,onKeyDown:f,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${t} column`,"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 El(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 Ml(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 pr(e,t,n){if(!e||e.length===0)return!0;const o=Ml(e),r=o.get(t),i=o.get(n);return(r?.[r.length-1]??null)===(i?.[i.length-1]??null)}function Bd(e,t,n){const o=[];let r=0,i=null,l=null;for(const a of e){const c=a.isSpacer?null:t.get(a.field)?.[n]??null;(i===null||l!==c||i.pinned!==a.pinned)&&(i={key:`${c?c.groupId:"filler"}-${n}-${a.field}`,isGroup:c!==null,label:c?.headerName??"",headerClassName:c?.headerClassName,width:0,flexGrow:0,fields:[],firstDataIndex:r,pinned:a.pinned},l=c,o.push(i)),i.width+=a.width,i.flexGrow+=a.flex??0,a.isSpacer||(i.fields.push(a.field),r++)}return o}function $t(){return document.documentElement.clientWidth||window.innerWidth}function Nl(){return document.documentElement.clientHeight||window.innerHeight}function Xt(){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 Yt(){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 Wd(){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 Vd(){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 zd(){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 Kd(){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 jd(){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 Ud(){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 Rd(){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 qd(){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 Il=e=>e?Array.from(e.querySelectorAll('[role="menuitem"], [role="menuitemradio"]')):[];function Xd({colDef:e,sortModel:t,onSort:n,onHide:o,onPin:r,pinnedColumns:i,onManageColumns:l,onClose:a,anchorEl:c}){const u=s.useRef(null),g=s.useCallback(v=>{v&&(c?.closest('[role="columnheader"]')??c)?.focus({preventScroll:!0}),a()},[c,a]),h=v=>{const B=Il(u.current),V=B.indexOf(v.target);let Q=-1;if(v.key==="ArrowDown")Q=V+1>=B.length?0:V+1;else if(v.key==="ArrowUp")Q=V<=0?B.length-1:V-1;else if(v.key==="Home")Q=0;else if(v.key==="End")Q=B.length-1;else if(v.key==="Tab"){v.preventDefault(),g(!0);return}else return;v.preventDefault(),B[Q]?.focus()},[x,y]=s.useState({position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"});s.useLayoutEffect(()=>{if(!c||!u.current)return;const v=c.getBoundingClientRect(),B=u.current.getBoundingClientRect(),V=$t(),Q=Nl(),H=8;let z=v.left;z+B.width+H>V&&(z=V-B.width-H),z<H&&(z=H);let W=v.bottom+4;W+B.height+H>Q&&(W=v.top-B.height-4),y({position:"fixed",zIndex:1300,top:W,left:z,visibility:"visible"})},[c]);const p=x.visibility==="visible";s.useLayoutEffect(()=>{p&&Il(u.current)[0]?.focus({preventScroll:!0})},[p]),s.useEffect(()=>{function v(V){u.current&&!u.current.contains(V.target)&&c&&!c.contains(V.target)&&a()}function B(V){V.key==="Escape"&&g(!0)}return document.addEventListener("mousedown",v),document.addEventListener("keydown",B),window.addEventListener("scroll",a,!0),window.addEventListener("resize",a),()=>{document.removeEventListener("mousedown",v),document.removeEventListener("keydown",B),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a)}},[c,a,g]);const f=v=>{n?.(e.field,v),g(!0)},m=!!o&&e.hideable!==!1,b=!!r&&e.pinnable!==!1,w=()=>{m&&o?.(e.field),g(!0)},C=v=>{b&&r?.(e.field,v),g(!0)},E=t?.find(v=>v.field===e.field)?.sort,S=E==null,N=i?.left?.includes(e.field)??!1,M=i?.right?.includes(e.field)??!1,_=!N&&!M,O=Je(c),L=O?"right":"left",A=O?"left":"right",k=O?M:N,I=O?N:M,P=e.headerName||e.field;return bt.createPortal(d.jsxs("div",{ref:u,className:"ogx-column-menu",style:x,role:"menu","aria-label":`Column options for ${P}`,onKeyDown:h,children:[n&&e.sortable!==!1&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:`ogx-menu-item${E==="asc"?" ogx-menu-item--active":""}`,onClick:()=>f("asc"),role:"menuitemradio","aria-checked":E==="asc",children:[d.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:E==="asc"?d.jsx(Xt,{}):d.jsx(Yt,{})}),d.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:d.jsx(Vd,{})}),"Sort Ascending"]}),d.jsxs("button",{type:"button",className:`ogx-menu-item${E==="desc"?" ogx-menu-item--active":""}`,onClick:()=>f("desc"),role:"menuitemradio","aria-checked":E==="desc",children:[d.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:E==="desc"?d.jsx(Xt,{}):d.jsx(Yt,{})}),d.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:d.jsx(zd,{})}),"Sort Descending"]}),d.jsxs("button",{type:"button",className:`ogx-menu-item${S?" ogx-menu-item--active":""}`,onClick:()=>f(null),role:"menuitemradio","aria-checked":S,children:[d.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:S?d.jsx(Xt,{}):d.jsx(Yt,{})}),d.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:d.jsx(Kd,{})}),"Unsort"]}),d.jsx("div",{className:"ogx-menu-divider"})]}),b&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"ogx-menu-section-label","aria-hidden":"true",children:"Pin column"}),d.jsxs("button",{type:"button",className:`ogx-menu-item${k?" ogx-menu-item--active":""}`,onClick:()=>C(L),role:"menuitemradio","aria-checked":k,"aria-label":"Pin to left",children:[d.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:k?d.jsx(Xt,{}):d.jsx(Yt,{})}),d.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:d.jsx(Ud,{})}),"Pin to Left"]}),d.jsxs("button",{type:"button",className:`ogx-menu-item${I?" ogx-menu-item--active":""}`,onClick:()=>C(A),role:"menuitemradio","aria-checked":I,"aria-label":"Pin to right",children:[d.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:I?d.jsx(Xt,{}):d.jsx(Yt,{})}),d.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:d.jsx(Rd,{})}),"Pin to Right"]}),d.jsxs("button",{type:"button",className:`ogx-menu-item${_?" ogx-menu-item--active":""}`,onClick:()=>C(null),role:"menuitemradio","aria-checked":_,"aria-label":"Unpin column",children:[d.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:_?d.jsx(Xt,{}):d.jsx(Yt,{})}),d.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:d.jsx(qd,{})}),"Unpin"]}),d.jsx("div",{className:"ogx-menu-divider"})]}),m&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"ogx-menu-item",onClick:w,role:"menuitem","aria-label":`Hide ${P} column`,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(jd,{})}),"Hide Column"]}),d.jsx("div",{className:"ogx-menu-divider"})]}),d.jsxs("button",{type:"button",className:"ogx-menu-item",onClick:()=>{l?.(),g(!1)},role:"menuitem","aria-label":"Manage all columns",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(Wd,{})}),"Manage columns"]})]}),c?.closest(".ogx-theme-provider")||document.body)}const Yd=16,Jd=16;function Zd(e,t=!1){const n=Number.isFinite(e)?e-Jd:0,o=Math.floor(n/Yd)-(t?1:0);return Math.max(1,o)}function Qd(e,t){return e??t??!1}function Ll(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}const eu="header:",tu=40,nu=300,ou="__group__",Al=[];function hr(e){return`${eu}${e}`}function mr(e){return"items"in e&&Array.isArray(e.items)}function ru(e){return e.isSpacer||Qe(e.field)||e.field===ou?!1:e.headerFilter!==!1&&e.filterable!==!1&&e.type!=="image"}function io(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 iu(e){const t=Ni(e.type),n=io(e);return t.includes(n)?t:[n,...t]}function Tl(e,t){return e.items.some(n=>mr(n)?Tl(n,t):n.field===t)}function lu(e){return(e?.logicOperator??"and")==="or"&&(e?.items?.length??0)>0}function Pl(e,t){const n=e?.items??Al;if(lu(e))return{kind:"custom"};const o=hr(t);let r;for(const i of n){if(mr(i)){if(Tl(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 su(e,t,n){const o=e??{items:[]};if(Pl(o,t).kind!=="editable")return o;const r=hr(t),i=o.items??Al,l=i.findIndex(u=>!mr(u)&&u.id===r),a=n?{...n,id:r,field:t}:null;let c;if(l===-1){if(!a)return o;if(i.length===0&&o.logicOperator==="or")return{...o,logicOperator:"and",items:[a]};c=[...i,a]}else a?c=i.map((u,g)=>g===l?a:u):c=i.filter((u,g)=>g!==l);return{...o,items:c}}function wr(e,t,n){const o=jt.has(t);return!o&&jo(n)&&t===io(e)?null:{id:hr(e.field),field:e.field,operator:t,value:o?void 0:n}}function Fl(e,t){if(!jt.has(t))return t==="isAnyOf"?e==null||e===""?[]:Array.isArray(e)?e:[e]:Array.isArray(e)?e.length>0?e[0]:"":e??""}const au={contains:"∋",equals:"=",startsWith:"a…",endsWith:"…a",isEmpty:"∅",isNotEmpty:"!∅",isAnyOf:"∈","=":"=","!=":"≠",">":">",">=":"≥","<":"<","<=":"≤",is:"=",not:"≠",after:">",onOrAfter:"≥",before:"<",onOrBefore:"≤"},cu={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"};function du(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]??cu[n]??n}}const et=s.forwardRef(function({fullWidth:t=!1,error:n=!1,startAdornment:o,endAdornment:r,className:i="",inputClassName:l="",variant:a="field",...c},u){const g=["ogx-input-wrapper",a==="cell"&&"ogx-input-wrapper--cell",t&&"ogx-input-wrapper--full-width",n&&"ogx-input-wrapper--error",c.disabled&&"ogx-input-wrapper--disabled",i].filter(Boolean).join(" "),h=["ogx-input",l].filter(Boolean).join(" ");return d.jsxs("div",{className:g,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,...c}),r&&d.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--end",children:r})]})});et.displayName="Input";const uu={position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"},Ol=e=>e?Array.from(e.querySelectorAll('[role="menuitemradio"]')):[];function fu({anchorEl:e,columnLabel:t,operators:n,current:o,onSelect:r,onClose:i,locale:l}){const a=s.useRef(null),[c,u]=s.useState(uu);s.useLayoutEffect(()=>{const y=a.current;if(!y)return;const p=e.getBoundingClientRect(),f=y.getBoundingClientRect(),m=8;let b=Math.min(p.left,$t()-f.width-m);b<m&&(b=m);let w=p.bottom+4;w+f.height+m>Nl()&&(w=p.top-f.height-4),u({position:"fixed",zIndex:1300,top:w,left:b,visibility:"visible"})},[e]);const g=c.visibility==="visible";s.useLayoutEffect(()=>{if(!g)return;const y=Ol(a.current);(y.find(p=>p.getAttribute("aria-checked")==="true")??y[0])?.focus({preventScroll:!0})},[g]);const h=s.useRef(i);s.useLayoutEffect(()=>{h.current=i}),s.useEffect(()=>{const y=e.ownerDocument,p=y.defaultView;function f(w){const C=w.target;a.current?.contains(C)||e.contains(C)||h.current(!1)}function m(w){a.current?.contains(w.target)||h.current(!1)}function b(){h.current(!1)}return y.addEventListener("mousedown",f),p?.addEventListener("scroll",m,!0),p?.addEventListener("resize",b),()=>{y.removeEventListener("mousedown",f),p?.removeEventListener("scroll",m,!0),p?.removeEventListener("resize",b)}},[e]);const x=y=>{y.stopPropagation();const p=Ol(a.current),f=p.indexOf(y.target);let m=-1;switch(y.key){case"ArrowDown":m=f+1>=p.length?0:f+1;break;case"ArrowUp":m=f<=0?p.length-1:f-1;break;case"Home":m=0;break;case"End":m=p.length-1;break;case"Escape":case"Tab":y.preventDefault(),i(!0);return;default:return}y.preventDefault(),p[m]?.focus()};return bt.createPortal(d.jsx("div",{ref:a,className:"ogx-column-menu ogx__header-filter-menu",style:c,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 gu(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 pu(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 Dl(e,t){return t==="isAnyOf"?e.split(",").map(n=>n.trim()).filter(n=>n!==""):e}function $l(e,t){return Object.is(e,t)?!0:Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((n,o)=>$l(n,t[o])):!1}function Gl(e,t){return e===t?!0:!e||!t?!1:e.operator===t.operator&&$l(e.value,t.value)}function hu(){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 mu({colDef:e,state:t,style:n,className:o,ariaColIndex:r,onItemChange:i,onOpenFilterPanel:l,locale:a}){const c=e.headerName||e.field,u=t.kind==="editable"?t.item:void 0,g=u?.operator??io(e),h=gu(e),x=e.type==="boolean"||e.type==="singleSelect"&&h.length>0,y=!jt.has(g),[p,f]=s.useState(null),[m,b]=s.useState(null),[w,C]=s.useState(void 0),[E,S]=s.useState(u);if(E!==u){S(u);const K=w!==void 0&&Gl(w??void 0,u);!Gl(E,u)&&!K&&f(null)}const N=s.useRef(null),M=s.useRef(null),_=s.useRef(null),O=s.useRef(null),L=s.useRef(null),A=s.useRef({item:u,colDef:e,onItemChange:i});s.useLayoutEffect(()=>{A.current={item:u,colDef:e,onItemChange:i}});const k=s.useCallback(K=>{const{item:de,colDef:X,onItemChange:te}=A.current;if(de?K===Yo(de.value,X.type):K.trim()==="")return;const J=de?.operator??io(X),se=wr(X,J,Dl(K,J));C(se),te(X.field,se)},[]),I=s.useRef(null);s.useLayoutEffect(()=>{I.current=p}),s.useEffect(()=>()=>{const K=I.current;I.current=null,K!==null&&k(K)},[k]),s.useEffect(()=>{if(p===null)return;const K=setTimeout(()=>{I.current=null,k(p),f(null)},nu);return()=>clearTimeout(K)},[p,k]);const P=()=>N.current?.focus({preventScroll:!0}),v=()=>(M.current??_.current)?.focus({preventScroll:!0}),B=K=>{C(K),i(e.field,K)},V=K=>{f(null),B(wr(e,g,K))},Q=()=>{f(null),B(null)},H=()=>{L.current&&b(L.current)},z=K=>{b(null),K&&(M.current||_.current?v():P())},W=K=>{const de=p!==null?Dl(p,K):u?.value;f(null),b(null),B(wr(e,K,Fl(de,K))),requestAnimationFrame(()=>{M.current||_.current?v():P()})},re=t.kind==="custom",oe=!re&&y&&!x,fe=K=>{const de=K.currentTarget,X=K.target;if(!de.contains(X)||K.nativeEvent.isComposing)return;const{key:te}=K,U=X===de;if((K.altKey&&te==="ArrowDown"||(K.ctrlKey||K.metaKey)&&te==="Enter")&&!re&&X!==_.current){K.preventDefault(),K.stopPropagation(),H();return}if(!U){te==="Escape"&&(K.preventDefault(),K.stopPropagation(),P());return}if(te==="Enter"||te===" "||te==="Spacebar"){K.preventDefault(),K.stopPropagation(),re?O.current?.click():M.current||_.current?v():H();return}if((te==="Delete"||te==="Backspace")&&u){K.preventDefault(),K.stopPropagation(),Q();return}oe&&e.type!=="date"&&te.length===1&&!K.ctrlKey&&!K.metaKey&&!K.altKey&&(K.preventDefault(),K.stopPropagation(),M.current?.focus({preventScroll:!0}),f(te))};let le=null;if(re)le=l?d.jsx("button",{ref:O,type:"button",className:"ogx__header-filter-custom",tabIndex:-1,onClick:l,title:a.customTooltip,children:a.custom}):d.jsx("span",{className:"ogx__header-filter-custom",title:a.customTooltip,children:a.custom});else{let K;if(!y)K=d.jsx("span",{className:"ogx__header-filter-operator-label",children:a.operator(g)});else if(e.type==="boolean")K=d.jsxs("select",{ref:_,className:"ogx__header-filter-select",tabIndex:-1,value:u?.value==null||u.value===""?"":String(u.value),onChange:X=>V(X.target.value===""?"":X.target.value==="true"),"aria-label":a.valueLabel(c),children:[d.jsx("option",{value:"",children:a.any}),d.jsx("option",{value:"true",children:a.yes}),d.jsx("option",{value:"false",children:a.no})]});else if(x){const X=h.find(te=>pu(te,u?.value));K=d.jsxs("select",{ref:_,className:"ogx__header-filter-select",tabIndex:-1,value:X?.key??"",onChange:te=>{const U=h.find(J=>J.key===te.target.value);V(Fl(U?U.value:"",g))},"aria-label":a.valueLabel(c),children:[d.jsx("option",{value:"",children:a.any}),h.map(te=>d.jsx("option",{value:te.key,children:te.label},te.key))]})}else K=d.jsx(et,{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:p??Yo(u?.value,e.type),onChange:X=>f(X.target.value),"aria-label":a.valueLabel(c)});const de=a.operator(g);le=d.jsxs(d.Fragment,{children:[d.jsx("button",{ref:L,type:"button",className:`ogx__header-filter-operator${m?" ogx__header-filter-operator--open":""}`,tabIndex:-1,"aria-haspopup":"menu","aria-expanded":m!==null,"aria-label":a.operatorButtonLabel(c,de),title:de,onClick:()=>m?b(null):H(),children:au[g]??"?"}),K,u&&d.jsx("button",{type:"button",className:"ogx__header-filter-clear",tabIndex:-1,"aria-label":a.clearLabel(c),title:a.clearTooltip,onClick:()=>{Q(),P()},children:d.jsx(hu,{})}),m&&d.jsx(fu,{anchorEl:m,columnLabel:c,locale:a,operators:iu(e),current:g,onSelect:W,onClose:z})]})}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:N,className:ce,style:n,role:"columnheader","aria-label":a.cellLabel(c),"aria-colindex":r,"data-field":e.field,tabIndex:-1,onKeyDown:fe,children:le})}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: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 wu(e){const{columns:t,columnWidths:n,pinnedColumns:o,pinnedPositions:r,pinnedEdges:i,rowReordering:l,hasDetailPanel:a,checkboxSelection:c,pinExpandColumn:u,pinCheckboxColumn:g,columnIndexMap:h,ariaRowIndex:x,filterModel:y,onFilterModelChange:p,onOpenFilterPanel:f,focusedField:m,localeText:b}=e,w=s.useRef({filterModel:y,onFilterModelChange:p});s.useLayoutEffect(()=>{w.current={filterModel:y,onFilterModelChange:p}});const C=s.useCallback((A,k)=>{const{filterModel:I,onFilterModelChange:P}=w.current;if(!P)return;const v=su(I,A,k);v!==I&&(w.current={filterModel:v,onFilterModelChange:P},P(v))},[]),E=du(b),S=l?1:0,N=a?S+1:S,M=c?N+1:N,_=M,O=l?We:0,L=O+(a&&u?We:0);return d.jsxs("div",{className:"ogx__header-filter-row",role:"row","aria-rowindex":x,children:[l&&d.jsx(br,{field:Pt,ariaColIndex:S,sticky:!0,left:0,focused:m===Pt}),a&&d.jsx(br,{field:Ft,ariaColIndex:N,sticky:u,left:O,focused:m===Ft}),c&&d.jsx(br,{field:Ze,ariaColIndex:M,sticky:g,left:L,focused:m===Ze}),t.map((A,k)=>{if(A.isSpacer)return d.jsx("div",{style:{width:A.width,minWidth:A.width,flexShrink:0},"aria-hidden":"true"},A.field);const I=ct(A.field,o),P=Ll(A,n,I,I?r[A.field]:void 0),v=_+(h?.get(A.field)??k)+1,B=[I&&"ogx__header-filter-cell--pinned",I&&`ogx__header-filter-cell--pinned-${I}`,I==="left"&&A.field===i.lastLeft&&"ogx__header-filter-cell--pinned-left-last",I==="right"&&A.field===i.firstRight&&"ogx__header-filter-cell--pinned-right-first",m===A.field&&"ogx__header-filter-cell--focused"].filter(Boolean).join(" ");return ru(A)?d.jsx(mu,{colDef:A,state:Pl(y,A.field),style:P,className:B,ariaColIndex:v,onItemChange:C,onOpenFilterPanel:f,locale:E},A.field):d.jsx("div",{className:`ogx__header-filter-cell ogx__header-filter-cell--empty ${B}`,style:P,role:"columnheader","aria-label":`No filter for ${A.headerName||A.field}`,"aria-colindex":v,"data-field":A.field,tabIndex:-1},A.field)})]})}function bu(){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 xu(){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 Hl(e){const{columns:t,allColumns:n,columnGroupingModel:o,checkboxSelection:r=!1,allSelected:i=!1,someSelected:l=!1,onSelectAll:a,onSort:c,sortModel:u=[],onColumnResize:g,onColumnAutosize:h,columnWidths:x={},pinnedColumns:y,hasDetailPanel:p=!1,pinCheckboxColumn:f=!0,pinExpandColumn:m=!0,rowReordering:b=!1,aggregationModel:w,draggedColumn:C,dragOverColumn:E,onDragStart:S,onDragOver:N,onDragEnd:M,onDrop:_,focusedCell:O,onHeaderClick:L,onSortAdd:A,multiSort:k=!1,onHideColumn:I,onPinColumn:P,onManageColumns:v,columnIndexMap:B,wrapHeaderText:V=!1,headerHeight:Q=56,headerFilters:H=!1,filterModel:z,onFilterModelChange:W,onOpenFilterPanel:re,localeText:oe}=e,fe=s.useId(),[le,ce]=s.useState(null),K=R=>ge=>{ge.stopPropagation(),ce({colDef:R,anchorEl:ge.currentTarget})},de=s.useCallback(()=>{ce(null)},[]),X=R=>ge=>{if(ge.altKey&&(ge.key==="ArrowLeft"||ge.key==="ArrowRight")&&ge.target===ge.currentTarget){if(R.resizable===!1||!g)return;ge.preventDefault(),ge.stopPropagation();const xe=At(R,x),ie=Vn(ge.key,Je(ge.currentTarget)),Ce=(ge.shiftKey?50:10)*(ie==="ArrowRight"?1:-1);g(R.field,gr(xe+Ce,xe,R.minWidth,R.maxWidth));return}if(!(ge.altKey&&ge.key==="ArrowDown"||(ge.ctrlKey||ge.metaKey)&&ge.key==="Enter")||R.disableColumnMenu||ge.target!==ge.currentTarget)return;ge.preventDefault(),ge.stopPropagation();const ye=ge.currentTarget.querySelector(".ogx__menu-icon-btn")??ge.currentTarget;ce({colDef:R,anchorEl:ye})},te=R=>O?.id===null&&!O.headerFilter&&O.field===R,U=b?1:0,J=p?U+1:U,se=r?J+1:J,ue=R=>ge=>{if(R.sortable===!1)return;const we=u.find(ye=>ye.field===R.field);let ae="asc";we&&(we.sort==="asc"?ae="desc":ae=null),(ge.shiftKey||k)&&A?A(R.field,ae):c&&c(R.field,ae)},ee=(R,ge)=>{const we=u.some(ye=>ye.field===R);A&&(ge===null||we||k||!c)?A(R,ge):c?.(R,ge)},D=R=>{const ge=u.find(ae=>ae.field===R);if(!ge)return null;const we=u.length>1?u.indexOf(ge)+1:null;return d.jsx("span",{className:`ogx__sort-icon ogx__sort-icon--${ge.sort}`,"aria-hidden":"true",children:we!==null&&d.jsx("span",{className:"ogx__sort-badge",children:we})})},T=s.useMemo(()=>Fo(t,x,y,r,f,p,m,b),[t,x,y,r,f,p,m,b]),$=s.useMemo(()=>Oo(t,y),[t,y]),F=El(o),Z=s.useMemo(()=>Ml(o),[o]),G=s.useMemo(()=>F===0?[]:(n??t).map(R=>({field:R.field,width:At(R,x),flex:R.isSpacer?0:R.flex,pinned:R.isSpacer?null:ct(R.field,y),isSpacer:R.isSpacer})),[F,n,t,x,y]),ne=(b?48:0)+(p?48:0)+(r?48:0),he=(b||p||r)&&(!p||m)&&(!r||f),me=(b?1:0)+(p?1:0)+(r?1:0);return d.jsxs("div",{className:"ogx__header-wrap",children:[F>0&&Array.from({length:F},(R,ge)=>{const we=Bd(G,Z,ge);return d.jsxs("div",{className:"ogx-col-group-row",role:"row","aria-rowindex":ge+1,children:[ne>0&&d.jsx("div",{className:`ogx-col-group-cell ogx-col-group-cell--filler${he?" ogx-col-group-cell--pinned ogx-col-group-cell--pinned-left":""}`,style:{width:ne,minWidth:ne,flexShrink:0,position:he?"sticky":void 0,insetInlineStart:he?0:void 0},"aria-hidden":"true"}),we.map((ae,ye)=>{const xe=ae.pinned?` ogx-col-group-cell--pinned ogx-col-group-cell--pinned-${ae.pinned}`:"",ie={width:ae.width,minWidth:ae.width,flexShrink:0,flexGrow:ae.flexGrow};return ae.pinned==="left"?(ie.position="sticky",ie.insetInlineStart=T[ae.fields[0]]):ae.pinned==="right"&&(ie.position="sticky",ie.insetInlineEnd=T[ae.fields[ae.fields.length-1]],we[ye-1]?.pinned!=="right"&&(ie.marginInlineStart="auto")),ae.isGroup?d.jsx("div",{role:"columnheader","aria-colspan":ae.fields.length,"aria-colindex":me+ae.firstDataIndex+1,className:`ogx-col-group-cell ogx-col-group-cell--group${xe}${ae.headerClassName?` ${ae.headerClassName}`:""}`,style:ie,title:ae.label,children:d.jsx("span",{className:"ogx-col-group-cell__label",children:ae.label})},ae.key):d.jsx("div",{className:`ogx-col-group-cell ogx-col-group-cell--filler${xe}`,style:ie,"aria-hidden":"true"},ae.key)})]},`ogx-grp-${ge}`)}),d.jsxs("div",{className:"ogx__header",role:"row","aria-rowindex":F+1,children:[b&&d.jsx("div",{className:`ogx__header-cell ogx__header-cell--pinned ogx__header-cell--pinned-left ${te("__reorder_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-label":"Row reorder handle","aria-colindex":U,"data-field":"__reorder_col__",tabIndex:-1,title:"Drag to reorder rows",style:{minWidth:48,maxWidth:48,position:"sticky",insetInlineStart:0}}),p&&d.jsx("div",{className:`ogx__header-cell ogx__header-cell--expand ${m?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""} ${te("__expand_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-label":"Expand row details","aria-colindex":J,"data-field":"__expand_col__",tabIndex:-1,style:{minWidth:48,maxWidth:48,position:m?"sticky":void 0,insetInlineStart:m?b?48:0:void 0}}),r&&d.jsx("div",{className:`ogx__header-cell ogx__header-cell--checkbox ${f?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""} ${te("__checkbox_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-colindex":se,"data-field":"__checkbox_col__",style:{position:f?"sticky":void 0,insetInlineStart:f?(b?48:0)+(p&&m?48:0):void 0},children:a&&d.jsx(Ct,{id:fe,name:fe,checked:i,indeterminate:l,onChange:R=>a(R.target.checked),"aria-label":i?"Deselect all rows":"Select all rows",tabIndex:-1,onMouseDown:R=>R.preventDefault()})}),t.map((R,ge)=>{if(R.isSpacer)return d.jsx("div",{style:{width:R.width,minWidth:R.width,flexShrink:0},"aria-hidden":"true"},R.field);const we=R.sortable!==!1,ae=u.findIndex(ot=>ot.field===R.field),ye=ae!==-1,xe=ye?u[ae].sort:null,ie=B?.get(R.field)??ge,Ce=we?ae===0?xe==="asc"?"ascending":"descending":"none":void 0,Ee=ye&&u.length>1?`Sorted ${xe==="asc"?"ascending":"descending"}, sort priority ${ae+1} of ${u.length}`:void 0,Le=R.resizable!==!1,Ie=ct(R.field,y),Ne=Ie!==null,ke=C===R.field,Fe=E===R.field,pe=Qd(R.wrapHeaderText,V),ve=w?.[R.field],Se=["ogx__header-cell",`ogx__header-cell--align-${R.headerAlign||R.align||"left"}`,we&&"ogx__header-cell--sortable",ye&&"ogx__header-cell--sorted",Ne&&"ogx__header-cell--pinned",Ne&&`ogx__header-cell--pinned-${Ie}`,Ie==="left"&&R.field===$.lastLeft&&"ogx__header-cell--pinned-left-last",Ie==="right"&&R.field===$.firstRight&&"ogx__header-cell--pinned-right-first",ke&&"ogx__header-cell--dragging",Fe&&"ogx__header-cell--drag-over",pe&&"ogx__header-cell--wrap",te(R.field)&&"ogx__header-cell--focused",R.headerClassName].filter(Boolean).join(" "),be={...Ll(R,x,Ie,Ie?T[R.field]:void 0),zIndex:R.zIndex,opacity:ke?.5:1},De=R.renderHeader?R.renderHeader({field:R.field,colDef:R,colIndex:ie}):R.headerName||R.field,ft=ot=>{if(ot.target.closest(".ogx-column-resize-handle")){ot.stopPropagation();return}L?.(R.field),we&&ue(R)(ot)},Ht=S&&!Ne?S(R.field):void 0,Pn=N&&!Ne?N(R.field):void 0,ln=_&&!Ne?_(R.field):void 0;return d.jsxs("div",{className:Se,style:be,title:R.description??(pe&&typeof De=="string"?De:void 0),onClick:ft,role:"columnheader",draggable:!!Ht,onDragStart:Ht,onDragOver:Pn,onDragEnd:M,onDrop:ln,onKeyDown:X(R),"aria-sort":Ce,"aria-description":Ee,"aria-colindex":me+ie+1,"data-field":R.field,tabIndex:-1,children:[d.jsxs("div",{className:"ogx__header-cell-content",children:[ke&&d.jsx("div",{className:"ogx__header-drag-icon",children:d.jsx(xu,{})}),d.jsxs("div",{className:"ogx__header-cell-title-wrapper",children:[d.jsx("span",{className:"ogx__header-cell-title",style:pe?{WebkitLineClamp:Zd(Q,!!ve)}:void 0,children:De}),ve&&d.jsx("span",{className:"ogx__header-cell-aggregation",children:ve})]}),we&&D(R.field),!R.disableColumnMenu&&d.jsx("button",{type:"button",className:"ogx__menu-icon-btn",onClick:K(R),"aria-label":`Open column menu for ${R.headerName||R.field}`,"aria-haspopup":"menu",tabIndex:-1,children:d.jsx(bu,{})})]}),Le&&g&&d.jsx(Hd,{field:R.field,currentWidth:At(R,x),onResize:g,onAutosize:h,minWidth:R.minWidth,maxWidth:R.maxWidth,edge:Ie==="right"?"start":"end"})]},R.field)}),le&&d.jsx(Xd,{colDef:le.colDef,sortModel:u,onSort:c||A?ee:void 0,onHide:I,onPin:P,pinnedColumns:y,onManageColumns:v,onClose:de,anchorEl:le.anchorEl})]}),H&&d.jsx(wu,{columns:t,columnWidths:x,pinnedColumns:y,pinnedPositions:T,pinnedEdges:$,rowReordering:b,hasDetailPanel:p,checkboxSelection:r,pinExpandColumn:m,pinCheckboxColumn:f,columnIndexMap:B,ariaRowIndex:F+2,filterModel:z,onFilterModelChange:W,onOpenFilterPanel:re,localeText:oe,focusedField:O?.id===null&&O.headerFilter?O.field:null})]})}const Ae=()=>{},xr=()=>Promise.resolve({updated:[],failed:[],skipped:[]});function Bl(){return{getRow:()=>null,getAllRows:()=>[],getVisibleRows:()=>[],getAllFilteredRows:()=>[],getGroupedExportRows:()=>null,getAggregationResult:()=>null,getAggregationModel:()=>null,getColumn:()=>null,getAllColumns:()=>[],getVisibleColumns:()=>[],selectRow:Ae,selectRows:Ae,getSelectedRows:()=>[],sortColumn:Ae,getSortModel:()=>[],setFilterModel:Ae,getFilterModel:()=>({items:[]}),setPage:Ae,setPageSize:Ae,scrollToIndexes:Ae,autosizeColumn:Ae,autosizeColumns:Ae,copySelectedRows:()=>Promise.resolve(),getCellSelectionModel:()=>[],setCellSelectionModel:Ae,selectCellRange:Ae,clearCellSelection:Ae,getSelectedCells:()=>[],copySelectedCells:()=>Promise.resolve(),pasteText:xr,undo:xr,redo:xr,canUndo:()=>!1,canRedo:()=>!1,clearHistory:Ae,setSortModel:Ae,setRowGroupingModel:Ae,setAggregationModel:Ae,setColumnVisibilityModel:Ae,setPivotModel:Ae,getGridAiState:()=>({}),openAiAssistant:Ae,closeAiAssistant:Ae}}const yu=e=>e.id;let Wl=!1;function Vl(e,t,n){const o=new Map,r=new Map,i=[],l=[];return e.forEach(a=>{const c=n?.get(a)??t(a);if(o.has(c)){l.push(c);return}o.set(c,a),r.set(a,c),i.push(c)}),l.length>0&&!Wl&&process.env.NODE_ENV!=="production"&&(Wl=!0,console.warn(`[OpenGridX] ${l.length} row(s) reuse the id of an earlier row and were ignored (ids: ${l.slice(0,5).map(String).join(", ")}${l.length>5?", …":""}). Every row needs a unique id; pass getRowId if the unique key lives in another field.`)),{idRowsLookup:o,allRows:i,idByRow:r}}function Cu(e,t,n,o={}){const r=new Map,i=[];return n.forEach(l=>{r.set(l.field,l),i.push(l.field)}),{rows:Vl(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 vu(e,t){switch(t.type){case"SET_ROWS":{const n=e.rows.allRows.map(r=>e.rows.idRowsLookup.get(r)),o=typeof t.payload=="function"?t.payload(n):t.payload;return{...e,rows:Vl(o,t.getRowId,e.rows.idByRow)}}case"REPLACE_ROW":{const n=e.rows.idRowsLookup.get(t.id);if(n===void 0)return e;const o=new Map(e.rows.idRowsLookup);o.set(t.id,t.row);const r=new Map(e.rows.idByRow);return r.delete(n),r.set(t.row,t.id),{...e,rows:{...e.rows,idRowsLookup:o,idByRow:r}}}case"REPLACE_ROWS":{let n=!1;const o=new Map(e.rows.idRowsLookup),r=new Map(e.rows.idByRow);for(const[i,l]of t.rows){const a=o.get(i);a!==void 0&&(n=!0,o.set(i,l),r.delete(a),r.set(l,i))}return n?{...e,rows:{...e.rows,idRowsLookup:o,idByRow:r}}:e}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 _u(e){const{rows:t,columns:n,rowHeight:o=52,headerHeight:r=56,columnVisibilityModel:i,initialState:l,syncRows:a=!1}=e,c=e.getRowId??yu,u=s.useRef(c);s.useLayoutEffect(()=>{u.current=c});const[g]=s.useState(()=>Cu(t,c,n,i)),[h,x]=s.useReducer(vu,{...g,dataSource:l?.dataSource?{...g.dataSource,...l.dataSource}:g.dataSource,pagination:{rowCount:l?.pagination?.rowCount},dimensions:{...g.dimensions,rowHeight:o,headerHeight:r}}),[y,p]=s.useState({rows:t,syncRows:a});(y.rows!==t||y.syncRows!==a)&&(p({rows:t,syncRows:a}),a&&x({type:"SET_ROWS",payload:t,getRowId:c}));const f=s.useRef(h);s.useLayoutEffect(()=>{f.current=h});const m=s.useCallback((L,A)=>{x({type:"SET_ROWS",payload:L,getRowId:u.current})},[]),b=s.useCallback((L,A)=>{x({type:"REPLACE_ROW",id:L,row:A})},[]),w=s.useCallback(L=>{L.size>0&&x({type:"REPLACE_ROWS",rows:L})},[]),C=s.useCallback(L=>{x({type:"SET_COLUMNS",payload:L})},[]),E=s.useCallback((L,A)=>{x({type:"SET_DIMENSIONS",payload:{viewportWidth:L,viewportHeight:A}})},[]),S=s.useCallback(L=>{x({type:"SET_DATASOURCE_LOADING",payload:L})},[]),N=s.useCallback(L=>{x({type:"SET_DATASOURCE_ERROR",payload:L})},[]),M=s.useCallback(L=>{x({type:"SET_ROW_COUNT",payload:L})},[]),[_]=s.useState(()=>({...Bl(),getRow:L=>f.current.rows.idRowsLookup.get(L)||null,getAllRows:()=>f.current.rows.allRows.map(L=>f.current.rows.idRowsLookup.get(L)),getColumn:L=>f.current.columns.lookup.get(L)||null,getAllColumns:()=>f.current.columns.all})),O=s.useRef(_);return{state:h,dispatch:x,apiRef:O,setRows:m,replaceRow:b,replaceRows:w,setColumns:C,setDimensions:E,setDataSourceLoading:S,setDataSourceError:N,setRowCount:M}}function Su(e){const{onRowOrderChange:t,rows:n,getRowId:o,rowReordering:r=!1}=e,[i,l]=s.useState(null),[a,c]=s.useState(null),u=s.useRef(()=>{}),g=s.useMemo(()=>{const m=new Map;return n.forEach((b,w)=>m.set(o?o(b):b.id,w)),m},[n,o]),h=s.useCallback(m=>g.has(m),[g]),x=s.useCallback(()=>{u.current(),u.current=()=>{},l(null),c(null)},[]);s.useEffect(()=>()=>u.current(),[]);const y=s.useCallback(m=>b=>{if(r){if(!g.has(m)){b.preventDefault();return}u.current(),u.current=dl(b.currentTarget,x),l(m),b.dataTransfer&&(b.dataTransfer.effectAllowed="move",cl(b,cr,String(m)))}},[r,g,x]),p=s.useCallback(m=>b=>{if(!(!r||i===null)){if(!no(b,cr)){x();return}g.has(m)&&(b.preventDefault(),b.dataTransfer&&(b.dataTransfer.dropEffect="move"),a!==m&&c(m))}},[r,i,a,g,x]),f=s.useCallback(m=>b=>{if(b.preventDefault(),i===null||!no(b,cr)){x();return}const w=g.get(i),C=g.get(m);x(),t&&w!==void 0&&C!==void 0&&w!==C&&t({row:n[w],oldIndex:w,targetIndex:C})},[i,t,n,g,x]);return{draggedRowId:i,dragOverRowId:a,canReorderRow:h,onDragStart:r?y:void 0,onDragOver:r?p:void 0,onDragEnd:r?x:void 0,onDrop:r?f:void 0}}const zl=new Map,Kl=e=>JSON.stringify(e),ku=e=>`auto-group-${e}`,jl=5,Ul=e=>e.slice(0,jl).map(t=>JSON.stringify(t)).join(", ")+(e.length>jl?", …":""),Eu={treeNodes:new Map,rootIds:[],groupingRows:[],syntheticIds:new Set,rowLookup:new Map,issues:[]};function Mu(e,t,n){const o=new Map,r=[],i=[],l=new Set,a=new Map,c=new Map,u=[],g=new Array(e.length),h=new Array(e.length),x=[],y=new Map;e.forEach((f,m)=>{const b=t(f),w=n(f),C=Array.isArray(w)?w.map(E=>String(E)):[];if(g[m]=b,h[m]=C,a.set(b,f),C.length===0)x.push(b);else{const E=Kl(C),S=c.get(E);if(S===void 0)c.set(E,b);else{const N=y.get(E)??[S];N.push(b),y.set(E,N)}}o.set(b,{id:b,parentId:null,depth:Math.max(C.length-1,0),groupingKey:C[C.length-1]??"",isExpanded:!1,children:[],serverChildrenCount:f.serverChildrenCount})});const p=f=>{const m=Kl(f),b=c.get(m);if(b!==void 0)return b;const w=ku(m),C=f[f.length-1],E={id:w,parentId:null,depth:f.length-1,groupingKey:C,isExpanded:!1,children:[],label:C};o.set(w,E),c.set(m,w),l.add(w);const S={id:w};if(i.push(S),a.set(w,S),f.length===1)r.push(w);else{const N=p(f.slice(0,-1));E.parentId=N,o.get(N)?.children?.push(w)}return w};return e.forEach((f,m)=>{const b=g[m],w=h[m];if(w.length<=1){r.push(b);return}const C=p(w.slice(0,-1)),E=o.get(b);E&&(E.parentId=C),o.get(C)?.children?.push(b)}),x.length>0&&u.push(`[OpenGridX] treeData: getTreeDataPath returned an empty path for row(s) ${Ul(x)}. They are shown as top-level rows.`),y.forEach((f,m)=>{u.push(`[OpenGridX] treeData: rows ${Ul(f)} have the same path ${m}. Rows under that path are attached to row ${JSON.stringify(f[0])}.`)}),{treeNodes:o,rootIds:r,groupingRows:i,syntheticIds:l,rowLookup:a,issues:u}}function Nu(e,t){const{treeNodes:n,rootIds:o,syntheticIds:r,rowLookup:i}=e,l=new Set,a=new Map,c=new Map,u=g=>{const h=n.get(g);if(!h)return!1;const x=[];let y=0;for(const b of h.children??[])u(b)&&(x.push(b),y+=(r.has(b)?0:1)+(c.get(b)??0));a.set(g,x),c.set(g,y);const p=i.get(g),m=!r.has(g)&&p!==void 0&&(t?t(p):!0)||x.length>0;return m&&l.add(g),m};return o.forEach(u),{visible:l,visibleChildren:a,descendantCounts:c}}function Iu(e){const{rows:t,getRowId:n,getTreeDataPath:o,treeData:r=!1,defaultGroupingExpansionDepth:i=0,filterModel:l,sortModel:a,onRowExpansionChange:c,columnLookup:u,filterMode:g="client",sortingMode:h="client"}=e,x=r&&!!o,y=s.useMemo(()=>!r||!o?Eu:Mu(t,n,o),[t,o,r,n]),{treeNodes:p,rootIds:f,groupingRows:m,syntheticIds:b,rowLookup:w}=y,C=y.issues.join(`
|
|
1
|
+
(function(_e,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):(_e=typeof globalThis<"u"?globalThis:_e||self,d(_e.OpenGridX={},_e.ReactJSXRuntime,_e.React,_e.ReactDOM))})(this,(function(_e,d,s,st){"use strict";"use client";function lo(e,t,n){return Math.max(t??0,Math.min(n??1/0,e))}function Ct(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 lo(r,e.minWidth,e.maxWidth)}const He=48;function tt(e,t){return t?t.left?.includes(e)?"left":t.right?.includes(e)?"right":null:null}function ca(e,t){const n=[],o=[],r=[];return t?(e.forEach(i=>{const l=tt(i.field,t);l==="left"?n.push(i):l==="right"?r.push(i):o.push(i)}),t.left&&n.sort((i,l)=>{const a=t.left.indexOf(i.field),c=t.left.indexOf(l.field);return a-c}),t.right&&r.sort((i,l)=>{const a=t.right.indexOf(i.field),c=t.right.indexOf(l.field);return a-c}),{left:n,center:o,right:r}):{left:n,center:e,right:r}}function so(e,t,n,o,r,i,l,a){const c={};if(!n)return c;let u=(a?He:0)+(i&&l?He:0)+(o&&r?He:0);const g=[];e.forEach(x=>{if(x.isSpacer)return;const y=tt(x.field,n);y==="left"?(c[x.field]=u,u+=Ct(x,t)):y==="right"&&g.push(x)});let m=0;for(let x=g.length-1;x>=0;x--)c[g[x].field]=m,m+=Ct(g[x],t);return c}function ao(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=tt(r.field,t);i==="left"?n=r.field:i==="right"&&o===null&&(o=r.field)}return{lastLeft:n,firstRight:o}}function Dr(e,t){return t?t.top?.includes(e)?"top":t.bottom?.includes(e)?"bottom":null:null}function da(e,t,n=o=>o.id){const o=[],r=[],i=[];return t?(e.forEach(l=>{const a=Dr(n(l),t);a==="top"?o.push(l):a==="bottom"?i.push(l):r.push(l)}),t.top&&o.sort((l,a)=>{const c=t.top.indexOf(n(l)),u=t.top.indexOf(n(a));return c-u}),t.bottom&&i.sort((l,a)=>{const c=t.bottom.indexOf(n(l)),u=t.bottom.indexOf(n(a));return c-u}),{top:o,center:r,bottom:i}):{top:o,center:e,bottom:i}}function ua(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 $r=new Set;function vt(e,t,n){process.env.NODE_ENV==="production"||$r.has(e)||($r.add(e),console.warn(`[OpenGridX] ${t}.`,n))}function co(e,t,n,o){try{return e()}catch(r){return vt(n,o,r),t}}function Gr(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}=Gr(e,t,n);return r!==void 0&&vt(`valueGetter:${t}`,`valueGetter for column "${t}" threw; the value is read as undefined`,r),o}function uo(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}}function nt(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==="")return null;const n=Number(t);return Number.isNaN(n)?null:n}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 fa=/^(\d{4})-(\d{2})-(\d{2})$/;function Qt(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=fa.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 t=new Date(n)}else return null;return Number.isNaN(t.getTime())?null:t}function kn(e){const t=Qt(e);return t?t.getFullYear()*1e4+(t.getMonth()+1)*100+t.getDate():null}function Hr(e){const t=Qt(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 Br=null;function Wr(e){return Br??=new Intl.DateTimeFormat,Br.format(e)}function ga(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 fo(e,t){if(e==null)return"";switch(t?.type){case"date":{const n=Qt(e);return n?Wr(n):String(e)}case"boolean":return e===!0?"Yes":e===!1?"No":String(e);case"singleSelect":return ga(t.valueOptions,e)??String(e);default:return String(e)}}const go=200;function po(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:go}function ho(e,t){if(e)return co(()=>e(t),void 0,"getDetailPanelHeight","getDetailPanelHeight threw; the panel uses the default height")}function pa(e,t){const n=po(e);return n==="auto"?t??go:n}function ha(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 ma=e=>e.id;function wa(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 ba(e,t,n){const o=new Map;e.forEach(f=>{if(!Object.prototype.hasOwnProperty.call(t,f.field)&&f.flex&&f.flex>0){o.set(f.field,{kind:"flex",flex:f.flex});return}const b=wa(t[f.field]??f.width);b.type==="fixed"?o.set(f.field,{kind:"fixed",width:lo(b.value,f.minWidth,f.maxWidth)}):b.type==="percentage"?o.set(f.field,{kind:"percentage",percentage:b.value}):o.set(f.field,{kind:"flex",flex:1})});const r=e.reduce((f,h)=>{const b=o.get(h.field);if(b.kind==="fixed")return f+b.width;if(b.kind==="percentage")return f+100;if(h.flex&&h.flex>0){const w=h.minWidth??150;return f+(w||(typeof h.width=="number"?h.width:150))}return f+(h.minWidth??150)},0),i=Math.max(n,r),l=e.reduce((f,h)=>{const b=o.get(h.field);return b.kind==="fixed"?f+b.width:f},0),a=new Map,c=Math.max(0,i-l);let u=0;e.forEach(f=>{const h=o.get(f.field);if(h.kind==="fixed")a.set(f.field,h.width);else if(h.kind==="percentage"){const b=h.percentage/100*c,w=lo(b>0?b:100,f.minWidth??50,f.maxWidth);a.set(f.field,w),u+=w}});const g=Math.max(0,c-u),m=new Map,x=e.flatMap(f=>{const h=o.get(f.field);return h.kind!=="flex"?[]:(m.set(f.field,h.flex),[{field:f.field,flex:h.flex,minWidth:f.minWidth??50,maxWidth:f.maxWidth??1/0,frozen:!1,computedWidth:0}])});let y=0;const p=x.length*2;for(;y<p;){y++;const f=x.filter(M=>!M.frozen);if(f.length===0)break;const h=f.reduce((M,_)=>M+_.flex,0),b=x.reduce((M,_)=>_.frozen?M+_.computedWidth:M,0),w=Math.max(0,g-b);if(h<=0){f.forEach(M=>{M.computedWidth=M.minWidth,M.frozen=!0});break}const C=w/h;let E=0;const S=[],N=[];if(f.forEach(M=>{const _=C*M.flex;_<M.minWidth?(E+=M.minWidth-_,S.push(M)):_>M.maxWidth?(E+=M.maxWidth-_,N.push(M)):M.computedWidth=_}),S.length===0&&N.length===0){f.forEach(M=>{M.frozen=!0});break}E>0?S.forEach(M=>{M.computedWidth=M.minWidth,M.frozen=!0}):E<0?N.forEach(M=>{M.computedWidth=M.maxWidth,M.frozen=!0}):(S.forEach(M=>{M.computedWidth=M.minWidth,M.frozen=!0}),N.forEach(M=>{M.computedWidth=M.maxWidth,M.frozen=!0}))}return x.forEach(f=>a.set(f.field,f.computedWidth)),{widths:a,flexByField:m}}function xa(e){const{rowHeight:t,pagination:n,paginatedUnpinnedRows:o,sortedUnpinnedRows:r,expandedRowIds:i,getDetailPanelHeight:l,detailPanelHeights:a,pinnedTopRowsLength:c,pinnedBottomRowsLength:u,pinnedTopRows:g,pinnedBottomRows:m,visibleOrderedColumns:x,pinnedColumns:y,columnWidths:p,viewportWidth:f,checkboxSelection:h,hasDetailPanel:b,rowReordering:w,pinCheckboxColumn:C,pinExpandColumn:E,paginationMode:S,isLoading:N,pageSize:M,getRowId:_=ma}=e;return s.useMemo(()=>{const F=n?o:r,P=(G,Y)=>{const U=_(G);if(!i.has(U))return t;const X=ho(l,{row:G,id:U,rowIndex:Y});return t+pa(X,a?.get(U))},L=F.length,k=new Array(L),I=new Array(L),A=i.size>0;let v=0;for(let G=0;G<L;G++){const Y=A?P(F[G],c+G):t;k[G]=Y,v=(v||0)+Y,I[G]=v}const W=S==="infinite"&&N&&F.length>0?Math.min(M,20):0,V=(I[I.length-1]||0)+W*t,Z=(G,Y)=>G?G.reduce((U,X,ne)=>U+P(X,ne),0):Y*t,H=Z(g,c),z=Z(m,u),{left:B,center:re,right:oe}=ca(x,y),ue=(h?He:0)+(b?He:0)+(w?He:0),se=(w?He:0)+(b&&E?He:0)+(h&&C?He:0),{widths:ce,flexByField:R}=ba([...B,...re,...oe],p,f-ue),de=G=>ce.get(G.field)??100,j=G=>({...G,width:de(G),flex:R.get(G.field)??G.flex}),te=11,q=B.map((G,Y)=>({...j(G),zIndex:te+Y})),Q=11,ae=oe.map((G,Y)=>({...j(G),zIndex:Q+(oe.length-1-Y)})),fe=re.map(j),ee=fe.map(G=>G.width),D=q.reduce((G,Y)=>G+Y.width,0),T=ae.reduce((G,Y)=>G+Y.width,0),$=ee.reduce((G,Y)=>G+Y,0),O=D+$+T+ue,J=ee.reduce((G,Y,U)=>(G.push((G[U-1]||0)+Y),G),[]);return{rowHeights:k,cumulativeHeights:I,unpinnedRowsHeight:V,pinnedTopHeight:H,pinnedBottomHeight:z,leftPinnedCols:q,rightPinnedCols:ae,unpinnedColsWithWidth:fe,unpinnedColWidths:ee,unpinnedAccWidths:J,totalWidth:O,leftWidth:D,rightWidth:T,unpinnedTotalWidth:$,systemColumnsWidth:ue,pinnedSystemColumnsWidth:se,pinnedTopRowsLength:c,pinnedBottomRowsLength:u,unpinnedRowsLength:F.length}},[t,n,o,r,i,l,a,c,u,g,m,x,y,p,f,h,b,w,C,E,S,N,M,_])}function Xe(e){if(!e)return!1;const t=e.ownerDocument.defaultView;return t?t.getComputedStyle(e).direction==="rtl":!1}function En(e,t){return t?e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e:e}function Dt(e){return Xe(e)?-e.scrollLeft:e.scrollLeft}function en(e,t){e.scrollLeft=Xe(e)?-t:t}function Mn(e,t){if(!e)return{top:0,right:0};const n=e.getBoundingClientRect();return Xe(e)?{top:n.bottom+6,left:n.left}:{top:n.bottom+6,right:t-n.right}}function ya(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:a}=e,c=i.getBoundingClientRect().top-e.getBoundingClientRect().top+l,u=Math.max(o,ya(e)),g=c+(t===0?0:n[t-1]),m=r!==void 0?Math.min(g+r,c+n[t]):c+n[t];g<l+c?e.scrollTop=Math.max(0,g-c):m>l+a-u&&(e.scrollTop=m-a+u)}function mo(e,t,n){const{unpinnedAccWidths:o,leftWidth:r,rightWidth:i,systemColumnsWidth:l,pinnedSystemColumnsWidth:a}=n;if(t<0||t>=o.length)return;const c=l+r,u=c+(t>0?o[t-1]:0),g=c+o[t],m=a+r,{clientWidth:x}=e,y=Dt(e);u<y+m?en(e,Math.max(0,u-m)):g>y+x-i&&en(e,g-x+i)}function wo(e,t){const{row:n,field:o,value:r,colDef:i,rowIndex:l,colIndex:a,rowMeta:c}=e;if(!i.editable||c?.isGroupRow||n._isSkeleton)return!1;if(!t)return!0;try{return!!t({row:n,field:o,value:r,colDef:i,rowIndex:l,colIndex:a})}catch{return!1}}const Ca={},tn=e=>e==null||typeof e=="string"&&e.trim()==="",Vr=e=>{const t=[];for(const n of e){const o=nt(n);o!==null&&t.push(o)}return t},zr=(e,t)=>{let n=null,o=null;for(const r of e){const i=nt(r);i!==null&&(n===null||t(i,n))&&(n=i,o=r)}return n===null?null:o instanceof Date?o:n},at={sum:e=>Vr(e).reduce((t,n)=>t+n,0),avg:e=>{const t=Vr(e);return t.length?t.reduce((n,o)=>n+o,0)/t.length:null},count:e=>e.filter(t=>!tn(t)).length,min:e=>zr(e,(t,n)=>t<n),max:e=>zr(e,(t,n)=>t>n),unique:e=>new Set(e.filter(t=>!tn(t))).size};function bo(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 a=n.get(i);if(!bo(a,l))continue;const c=at[l];if(!c){console.warn(`[${o}] Unknown aggregation function: "${l}"`);continue}r[i]=Object.prototype.hasOwnProperty.call(at,l)?va(e,i,a,l):c(e.map(u=>Me(u,i,a)))}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 a=nt(Me(l,t,n));a!==null&&(r+=a,i++)}return o==="sum"?r:i?r/i:null}case"count":{let r=0;for(const i of e)tn(Me(i,t,n))||r++;return r}case"min":case"max":{const r=o==="min";let i=null,l=null;for(const a of e){const c=Me(a,t,n),u=nt(c);u!==null&&(i===null||(r?u<i:u>i))&&(i=u,l=c)}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);tn(l)||r.add(l)}return r.size}}}function nn(e,t){return e==null?"—":typeof e=="number"?t==="avg"?e.toLocaleString(void 0,{maximumFractionDigits:2}):e.toLocaleString():String(e)}const Sa=new Set(["count","unique"]);function Rr(e){return e!==void 0&&Sa.has(e)}function Kr(e,t,n){return e?.type==="date"&&(t==="min"||t==="max")&&typeof n=="number"&&Number.isFinite(n)?new Date(n):n}function Ln(e,t,n,o){if(e==null)return"—";if(Rr(t))return nn(e,t);const r=Kr(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())?"":Wr(r):nn(r,t)}const $t=new Set(["isEmpty","isNotEmpty"]);function xo(e){return e==null?!0:typeof e=="string"?e.trim()==="":Array.isArray(e)?e.length===0:!1}function _a(e){return e==null?!0:typeof e=="number"?Number.isNaN(e):typeof e=="string"&&e.trim()===""}const on=e=>(t,n)=>{const o=nt(t),r=nt(n);return o===null||r===null?!1:e(o,r)},rn=e=>(t,n)=>{const o=kn(t),r=kn(n);return o===null||r===null?!1:e(o,r)},Ur=rn((e,t)=>e===t),jr=(e,t)=>{const n=kn(e),o=kn(t);return n===null||o===null?!0:n!==o},qr={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()!=="","=":on((e,t)=>e===t),">":on((e,t)=>e>t),">=":on((e,t)=>e>=t),"<":on((e,t)=>e<t),"<=":on((e,t)=>e<=t),"!=":(e,t)=>{if(xo(t))return!0;const n=nt(e),o=nt(t);return n!==null&&o!==null?n!==o:_a(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?jr(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?Ur(e,t):String(e).toLowerCase()===String(t).toLowerCase(),after:rn((e,t)=>e>t),onOrAfter:rn((e,t)=>e>=t),before:rn((e,t)=>e<t),onOrBefore:rn((e,t)=>e<=t)},ka={is:Ur,not:jr};function Ea(e,t){if(!Object.prototype.hasOwnProperty.call(qr,e))return;const n=e;if(t?.type==="date"){const o=ka[n];if(o)return o}return qr[n]}function Ma(e){return"items"in e&&Array.isArray(e.items)}function Na(e,t){const{field:n,operator:o,value:r}=e;if(!$t.has(o)&&xo(r))return null;const i=t.columns?.byField.get(n),l=Ea(o,i);return l?a=>l(Me(a,n,i),r):(t.warned.has(o)||(t.warned.add(o),console.warn(`Unknown filter operator: ${o}`)),null)}function yo(e,t,n){const o=[];for(const r of e){const i=Ma(r)?yo(r.items,r.logicOperator,n):Na(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 Co(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=Hr(t);n&&e.push(n);return}if(Array.isArray(t))for(const n of t)(n==null||typeof n!="object")&&Co(e,n)}}function vo(e,t){const n=[];if(!t){for(const o of Object.values(e))Co(n,o);return n}for(const o of t.quickFilterColumns){const r=Me(e,o.field,o),i=uo(e,o.field,r,o);i!=null&&i!==""&&n.push(String(i).toLowerCase()),Co(n,r)}return n}const Xr=new WeakMap;function Ia(e,t){if(!t)return vo(e,t);let n=Xr.get(t);n||(n=new WeakMap,Xr.set(t,n));let o=n.get(e);return o||(o=vo(e,t),n.set(e,o)),o}function Yr(e){return(e??[]).map(t=>String(t??"").trim().toLowerCase()).filter(t=>t!=="")}function Jr(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 La(e,t){const n=Yr(e);return n.length===0?null:o=>Jr(Ia(o,t),n)}const Zr=new WeakMap;function Pa(e,t){const n=Zr.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]:vo(i,t)}return Zr.set(t,{rows:e,texts:o}),o}function Pn(e,t){if(!e)return null;const n={columns:t,warned:new Set},o="quickFilterValues"in e?e.quickFilterValues:void 0,r=La(o,t),i=yo(e.items??[],e.logicOperator??"and",n);return r&&i?l=>r(l)&&i(l):r??i}function So(e,t,n){const o=n&&t?Yr(t.quickFilterValues):[];if(n&&o.length>0){const i=yo(t.items??[],t.logicOperator??"and",{columns:n,warned:new Set}),l=Pa(e,n),a=[];for(let c=0;c<e.length;c++)Jr(l[c],o)&&(!i||i(e[c]))&&a.push(e[c]);return a}const r=Pn(t,n);return r?e.filter(i=>r(i)):e}function Qr(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 _o(e,t){return e==null?"":t==="date"||e instanceof Date?Hr(e)||(typeof e=="string"?e:""):Array.isArray(e)?e.map(n=>String(n)).join(", "):String(e)}const ko=new Intl.Collator(void 0,{numeric:!0,sensitivity:"accent"}),An=0,ei=1,Aa=2,Eo=3,Tn=4;function Gt(e,t){return{rank:e,num:t,str:""}}function Fn(e,t){if(e==null)return null;if(t==="number"){const n=nt(e);return n===null?null:Gt(An,n)}if(t==="date"){const n=Qt(e);return n?Gt(ei,n.getTime()):null}switch(typeof e){case"number":return Number.isNaN(e)?null:Gt(An,e);case"bigint":return Gt(An,Number(e));case"boolean":return Gt(Aa,e?1:0);case"string":return{rank:Eo,num:0,str:e}}if(e instanceof Date){const n=e.getTime();return Number.isNaN(n)?null:Gt(ei,n)}return{rank:Tn,num:0,str:String(e)}}function ti(e,t){return e===null&&t===null?0:e===null?1:t===null?-1:e.rank!==t.rank?e.rank-t.rank:e.rank===Eo||e.rank===Tn?ko.compare(e.str,t.str):e.num<t.num?-1:e.num>t.num?1:0}function Mo(e,t){return e===0?0:t==="asc"?e:-e}function Ta(e,t,n,o){return Mo(ti(Fn(e,o),Fn(t,o)),n)}function ni(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 Fa=e=>e.id;function Oa(e,t,n,o=Fa){if(t.length===0)return e;if(e.length<2)return[...e];const r=t.map(i=>{const l=n?.byField.get(i.field),a=l?.sortComparator;if(a)return ai(e.map(u=>{const g=Me(u,i.field,l);return{value:g,type:l.type,comparator:a,params:{id:o(u),field:i.field,row:u,value:g}}}));const c=l?.type;return si(e.length,u=>Me(e[u],i.field,l),()=>c)});return ci(e,t,r)}function oi(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)?ai(i):si(i.length,l=>i[l].value,l=>i[l].type)});return ci(e,t,o)}const ri=Tn+1;function ii(e,t){const n=[...e.keys()].sort(ko.compare);let o=0;for(let r=0;r<n.length;r++){r>0&&ko.compare(n[r-1],n[r])!==0&&o++;for(const i of e.get(n[r])??[])t[i]=o}}function li(e,t,n){const o=e.get(t);o?o.push(n):e.set(t,[n])}function si(e,t,n){const o=new Uint8Array(e),r=new Float64Array(e),i=new Map,l=new Map;for(let a=0;a<e;a++){const c=t(a),u=n(a);if(typeof c=="number"&&u!=="date"){Number.isNaN(c)?o[a]=ri:(o[a]=An,r[a]=c);continue}const g=Fn(c,u);g===null?o[a]=ri:(o[a]=g.rank,g.rank===Eo?li(i,g.str,a):g.rank===Tn?li(l,g.str,a):r[a]=g.num)}return ii(i,r),ii(l,r),{kind:"encoded",group:o,num:r}}function ai(e){return{kind:"generic",values:e,keys:e.map(({value:t,type:n})=>Fn(t,n))}}function Da(e,t,n){if(e.kind==="encoded"){const i=e.group[t],l=e.group[n];if(i!==l)return i-l;const a=e.num[t],c=e.num[n];return a<c?-1:a>c?1:0}const o=e.values[t],r=e.values[n];return o.comparator&&o.comparator===r.comparator&&o.params&&r.params?ni(o.comparator,o.params,r.params):ti(e.keys[t],e.keys[n])}function ci(e,t,n){const o=e.length,r=new Array(o);for(let a=0;a<o;a++)r[a]=a;const i=n[0];if(n.length===1&&i.kind==="encoded"){const{group:a,num:c}=i,u=t[0].sort==="asc"?1:-1;r.sort((g,m)=>{const x=a[g],y=a[m];if(x!==y)return(x-y)*u;const p=c[g],f=c[m];return p<f?-u:p>f?u:g-m})}else r.sort((a,c)=>{for(let u=0;u<n.length;u++){const g=Mo(Da(n[u],a,c),t[u].sort);if(g!==0)return g}return a-c});const l=new Array(o);for(let a=0;a<o;a++)l[a]=e[r[a]];return l}function $a(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 No(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 Ht="__pivot_grand_total__",Ga="__pivot_row__:",di=e=>`${Ga}${JSON.stringify(e.split(ui))}`,Ha="Grand Total",ui="\0",Bt="",Io=`${Bt}id`,fi=e=>e==="id"?Io:e,Lo={pivotRows:[],pivotColumns:[],colKeys:[],isValid:!1},gi=e=>e.map(t=>String(t??"")).join(ui),pi=e=>e===void 0||e===""?null:e;function Ba(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 Wa(e,t){for(let n=0;n<e.length;n++){const o=Ba(e[n],t[n]);if(o!==0)return o}return 0}function hi(e,t){if(!e||e.length===0)return null;const n=at[t](e);return typeof n=="number"||n instanceof Date?n:null}const Va=e=>"logicOperator"in e&&"items"in e,za=e=>!!(e&&e.items&&e.items.length>0);function Ra(e,t){const n=l=>!t.has(l)&&l.includes(Bt),o=l=>Va(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 mi(e,t,n,o={}){const r=new Map(t.map(k=>[k.field,k])),i=k=>r.get(k)?.groupable!==!1,l=n.rowFields.filter(i),a=n.columnFields.filter(i),c=new Set,u=n.valueFields.filter(k=>{if(!bo(r.get(k.field),k.aggFn))return!1;const I=`${k.field}${Bt}${k.aggFn}`;return c.has(I)?!1:(c.add(I),!0)});if(l.length===0||u.length===0)return Lo;const g=a.length>0,m=Array.from(new Set(u.map(k=>k.field))),x=(k,I)=>Me(k,I,r.get(I)),y=new Map,p=new Map(g?[]:[["",{values:[]}]]);for(const k of e){const I=l.map(z=>x(k,z)),A=gi(I);let v=y.get(A);v||(v={labels:I.map(pi),sample:k,cells:new Map},y.set(A,v));const W=a.map(z=>x(k,z)),V=g?gi(W):"",Z=p.get(V);Z?Z.sample||(Z.sample=k):p.set(V,{values:W.map(pi),sample:k});let H=v.cells.get(V);H||(H=new Map,v.cells.set(V,H));for(const z of m){const B=x(k,z);if(tn(B))continue;let re=H.get(z);re||(re=[],H.set(z,re)),re.push(B)}}const f=Array.from(p.keys()).sort((k,I)=>Wa(p.get(k).values,p.get(I).values)),h=(k,I)=>g?`${k}${Bt}${I.field}${Bt}${I.aggFn}`:`${I.field}${Bt}${I.aggFn}`,b=new Map;let w=[];for(const[k,I]of y){const A={id:di(k)};l.forEach((v,W)=>{A[fi(v)]=I.labels[W]}),A.id=di(k);for(const v of f){const W=I.cells.get(v);for(const V of u)A[h(v,V)]=hi(W?.get(V.field),V.aggFn)}b.set(A.id,I),w.push({row:A,entry:I})}const C=k=>l.includes(k),E=k=>C(k)?r.get(k)?.type:"number",{outputFilterModel:S,sortModel:N}=o;if(za(S)){const k=[];for(const A of f)for(const v of u)k.push({field:h(A,v),type:"number"});const I=Pn(S,No(k));I&&(w=w.filter(({row:A})=>I(A)))}const M=(k,I)=>I==="id"&&C("id")?k[Io]:k[I];N&&N.length>0&&(w=[...w].sort((k,I)=>{for(const A of N){const v=M(k.row,A.field),W=M(I.row,A.field),V=C(A.field)?r.get(A.field)?.sortComparator:void 0,Z=V?Mo(ni(V,{id:k.row.id,field:A.field,row:k.row,value:v},{id:I.row.id,field:A.field,row:I.row,value:W}),A.sort):Ta(v,W,A.sort,E(A.field));if(Z!==0)return Z}return 0}));const _=w.map(k=>k.row);if(w.length>0){const k={id:Ht};l.forEach((I,A)=>{k[fi(I)]=A===0?Ha:""}),k.id=Ht;for(const I of f)for(const A of m){const v=[];for(const{entry:W}of w){const V=W.cells.get(I)?.get(A);if(V)for(const Z of V)v.push(Z)}for(const W of u)W.field===A&&(k[h(I,W)]=hi(v,W.aggFn))}_.push(k)}const F=w[0]?.entry.sample,P=k=>k===Ht?F:k===void 0?void 0:b.get(k)?.sample,L=l.map(k=>Ua(k,r.get(k),P));for(const k of f){const I=p.get(k),A=g?a.map((v,W)=>{const V=r.get(v),Z=Ka(V,v,I.values[W],I.sample);return V?.headerName?`${V.headerName}: ${Z}`:Z}).join(" / "):"";for(const v of u){const W=r.get(v.field),V=v.headerName??W?.headerName??v.field;L.push({field:h(k,v),headerName:A?`${A} — ${V} (${v.aggFn})`:`${V} (${v.aggFn})`,width:140,type:"number",align:"right",headerAlign:"right",sortable:!0,valueFormatter:({value:Z,row:H})=>Ln(Z,v.aggFn,W,H)})}}return{pivotRows:_,pivotColumns:L,colKeys:f,isValid:!0}}function Ka(e,t,n,o){const r=o?uo(o,t,n,e):void 0;return r!==void 0?r:n==null?"":String(n)}function Ua(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:a})=>a[Io]);const r=a=>a?.id===Ht,i=t?.valueFormatter;i&&(o.valueFormatter=({value:a,row:c})=>r(c)?String(a??""):i({value:a,row:n(c?.id)??c,field:e}));const l=t?.renderCell;return l&&(o.renderCell=a=>r(a.row)?a.formattedValue??String(a.value??""):l({...a,row:n(a.row.id)??a.row})),o}function Re(e,t){return e===Ht||t?.get(e)?.isGroupRow===!0}const St="__reorder_col__",_t="__expand_col__",Ye="__checkbox_col__",Je=e=>e===St||e===_t||e===Ye,Po=(e,t)=>e===t||e!==null&&t!==null&&e.id===t.id&&e.field===t.field&&!e.headerFilter==!t.headerFilter,ja=new Set(["checkbox","radio","button","submit","reset","image","file","color"]),qa=new Set(["textbox","searchbox","combobox","listbox","slider","spinbutton"]);function wi(e){const t=e.tagName;if(t==="INPUT")return!ja.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&&qa.has(n)}const bi=e=>e!==null&&e.nodeType===1;function xi(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 On(e,t){if(e===t)return"grid";if(!bi(e)||!t.contains(e))return"foreign";const n=xi(e,t);return n?n.classList.contains("ogx__cell--editing")?"editor":n===e?"grid":wi(e)?"foreign":n.classList.contains("ogx__header-cell--checkbox")?"grid":"control":"foreign"}function Xa(e,t,n,o){if(!bi(e))return null;const r=xi(e,t),i=r?.dataset.field;if(!r||!i)return null;if(r.getAttribute("role")==="columnheader"){const c=r.parentElement;return c?.classList.contains("ogx__header")?{id:null,field:i}:c?.classList.contains("ogx__header-filter-row")?{id:null,field:i,headerFilter:!0}:null}const l=Number(r.parentElement?.getAttribute("data-rowindex")),a=Number.isInteger(l)?n[l]:void 0;return a?{id:o(a),field:i,rowIndex:l}:null}function yi(e,t){if(!e)return null;for(const n of Array.from(e.children))if(n.dataset.field===t)return n;return null}function Ao(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=yi(r,t.field);return i&&t.field===Ye?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 yi(o,t.field)}const Ci="__group__";function Ke(e){return!Je(e)&&e!==Ci}const ct=(e,t)=>e===t||!!e&&!!t&&e.id===t.id&&e.field===t.field;function Ya(e,t){return e===t?!0:e.length!==t.length?!1:e.every((n,o)=>ct(n.anchor,t[o].anchor)&&ct(n.head,t[o].head))}function Dn(e,t,n){const{rowIds:o,fields:r,rowIndexById:i,colIndexByField:l,spans:a}=n,c={top:e,bottom:e,left:t,right:t};if(!a)return c;const u=o[e],g=r[t],m=a.getSpanOrigin(u,g)??{rowId:u,field:g},x=i.get(m.rowId),y=l.get(m.field);if(x===void 0||y===void 0)return c;const p=Math.max(1,a.getRowSpan(m.rowId,m.field)),f=Math.max(1,a.getColSpan(m.rowId,m.field));return{top:x,bottom:Math.min(o.length-1,x+p-1),left:y,right:Math.min(r.length-1,y+f-1)}}function Ja(e,t){if(!t.spans)return e;let{top:n,bottom:o,left:r,right:i}=e,l=!0;const a=c=>{c.top<n&&(n=c.top,l=!0),c.bottom>o&&(o=c.bottom,l=!0),c.left<r&&(r=c.left,l=!0),c.right>i&&(i=c.right,l=!0)};for(;l;){l=!1;for(let c=n;c<=o;c++)a(Dn(c,r,t)),i!==r&&a(Dn(c,i,t));for(let c=r+1;c<i;c++)a(Dn(n,c,t)),o!==n&&a(Dn(o,c,t))}return{top:n,bottom:o,left:r,right:i}}function $n(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:{...Ja({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 Za(e,t,n,o,r,i){const{headRow:l,headCol:a,anchorRow:c,anchorCol:u,top:g,bottom:m,left:x,right:y}=e;let p=l,f=a;switch(t){case"ArrowRight":f=a>=u?y+1:a+1;break;case"ArrowLeft":f=a<=u?x-1:a-1;break;case"ArrowDown":p=l>=c?m+1:l+1;break;case"ArrowUp":p=l<=c?g-1:l-1;break;case"Home":f=0,n&&(p=0);break;case"End":f=i,n&&(p=r);break;case"PageUp":p=l-o;break;case"PageDown":p=l+o;break;default:return null}return p=Math.min(Math.max(p,0),r),f=Math.min(Math.max(f,0),i),p===l&&f===a?null:{row:p,col:f}}function vi(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 Qa=(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,To=1,Si=2,_i=4,ki=8,Ei=16,Mi=32;function ec(e,t,n,o){if(!e)return 0;const r=e.fillHandleCol===t?Mi:0,i=t+Math.max(1,n)-1;if(t<e.left||i>e.right)return r;let l=To|r;return e.isTop&&(l|=Si),(e.isBottom||o>1&&o-1>=e.bottomOffset)&&(l|=_i),t===e.left&&(l|=ki),i===e.right&&(l|=Ei),l}function tc(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 nc=1e5,oc=e=>e.id,Ni=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]);function rc(e,t,n,o,r){if(!e||n.length===0)return{cell:null,rowIndex:-1};const i=(n.find(u=>!Je(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 a=e.rowIndex;let c=a!==void 0&&t[a]&&o(t[a])===e.id?a:t.findIndex(u=>o(u)===e.id);return c===-1?t.length===0?{cell:{id:null,field:l},rowIndex:-1}:(c=Math.min(Math.max(a??0,0),t.length-1),{cell:{id:o(t[c]),field:l,rowIndex:c},rowIndex:c}):{cell:l===e.field?e:{...e,field:l},rowIndex:c}}function ic(e){const{allRenderableRows:t,navigationColumns:n,checkboxSelection:o,selectedRowIds:r,handleSelectionChange:i,handleDetailPanelToggle:l,editingHandlers:a,setKeyboardMode:c,sortModel:u,handleSort:g,handleSortAdd:m,multiSort:x=!1,isCellEditable:y,pagination:p,pageSize:f,virtualization:h,viewportRef:b,pinnedTopRowCount:w=0,getRowId:C=oc,rowMetaMap:E,onRowActivate:S,toggleRowExpansion:N,handleSelectAll:M,rowSelectionEnabled:_=!0,multipleRowSelectionEnabled:F=!0,pinCheckboxColumn:P=!0,pinExpandColumn:L=!0,rowHeight:k,getSpanOrigin:I,cellSelection:A,headerFilters:v=!1}=e,[W,V]=s.useState(null),[Z,H]=s.useState(!1),z=s.useMemo(()=>rc(W,t,n,C,v),[W,t,n,C,v]),B=z.cell,re=z.rowIndex,oe=s.useRef(!1),ue=s.useRef(!1),se=s.useRef(!1),ce=s.useRef(null),R=s.useCallback(D=>{ue.current=!0,D.focus({preventScroll:!0}),ue.current=!1},[]),de=s.useCallback(()=>{const D=b.current;D&&!D.contains(D.ownerDocument.activeElement)&&R(D)},[b,R]),j=s.useMemo(()=>n.find(D=>!Je(D.field))??n[0],[n]),te=s.useCallback(()=>{if(o)return{id:null,field:Ye};if(!j)return null;const D=t[0];return D?{id:C(D),field:j.field,rowIndex:0}:{id:null,field:j.field}},[o,j,t,C]),q=s.useCallback((D,T)=>{const $=b.current;if(!$)return;const{cumulativeHeights:O,pinnedBottomHeight:J,columnMetrics:G}=h;if(D>=0&&Nn($,D-w,O,J,k),Je(T)){!(T===St||T===_t&&L||T===Ye&&P)&&Dt($)>0&&en($,0);return}if(!G)return;const{clientWidth:Y}=$,U=Dt($),{leftPinnedWidth:X,rightPinnedWidth:ne,unpinnedAccWidths:he,unpinnedCols:me,totalSpecialsWidth:K,pinnedSpecialsWidth:ge}=G,we=me.findIndex(ke=>ke.field===T);if(we===-1)return;const ie=K+X+(we>0?he[we-1]:0),xe=K+X+he[we],Ce=U+ge+X,le=U+Y-ne;let ye=U;ie<Ce?ye=Math.max(0,ie-ge-X):xe>le&&(ye=xe-Y+ne),ye!==U&&en($,ye)},[b,h,w,k,P,L]);s.useLayoutEffect(()=>{const D=b.current,T=!Po(ce.current,B);if(ce.current=B,!D||!B)return;const $=D.ownerDocument,O=$.activeElement;let J;if(O===D?J=!0:!O||O===$.body?J=oe.current:D.contains(O)?J=T:J=!1,!J)return;const G=Ao(D,B,re);G?G.contains(O)||G.focus({preventScroll:!0}):O!==D&&R(D)});const Q=s.useCallback(()=>{se.current=!0,c(!1)},[c]),ae=s.useCallback(D=>{const T=D.currentTarget,$=D.relatedTarget,O=!($ instanceof Node&&T.contains($)),J=se.current;if(se.current=!1,oe.current=!0,H(!0),ue.current)return;if(D.target===T){if(!O)return;if(J||c(!0),B){const U=Ao(T,B,re);U?U.focus({preventScroll:!0}):q(re,B.field);return}const Y=te();Y&&(V(U=>U??Y),q(Y.rowIndex??-1,Y.field));return}const G=Xa(D.target,T,t,C);G&&!Po(G,B)&&V(G)},[B,re,te,q,c,t,C]),fe=s.useCallback(D=>{const T=D.relatedTarget;T instanceof Node&&D.currentTarget.contains(T)||(oe.current=!1,se.current=!1,H(!1),c(!1))},[c]),ee=s.useCallback(D=>{const T=D.currentTarget,$=On(D.target,T);if($==="foreign"||(c(!0),D.nativeEvent?.isComposing||D.keyCode===229))return;const O=En(D.key,Xe(T)),J=O===" "||O==="Spacebar",G=!!a.editingCell,Y=v?-2:-1,U=(pe,ve)=>{const Se=n[ve];!Se||pe<Y||pe>=t.length||(pe===Y?V({id:null,field:Se.field}):pe<0?V({id:null,field:Se.field,headerFilter:!0}):V({id:C(t[pe]),field:Se.field,rowIndex:pe}),q(pe,Se.field))};if(!B){if(!Ni.has(O))return;const pe=te();if(!pe)return;D.preventDefault(),V(pe),q(pe.rowIndex??-1,pe.field);return}const{id:X,field:ne}=B,he=X===null&&!!B.headerFilter,me=X!==null?re:he?-1:Y,K=n.findIndex(pe=>pe.field===ne),ge=n.filter(pe=>Je(pe.field)).length,we=pe=>Re(pe,E),ie=(pe,ve,Se)=>{const be=n[Se];return Je(be.field)?!1:wo({row:pe,field:be.field,value:Me(pe,be.field,be),colDef:be,rowIndex:ve,colIndex:Se-ge,rowMeta:E?.get(C(pe))},y)},xe=pe=>{let ve=me,Se=K;const be=(t.length+1)*n.length;for(let Le=0;Le<be;Le++){if(Se+=pe,Se>=n.length?(Se=0,ve++):Se<0&&(Se=n.length-1,ve--),ve<0||ve>=t.length)return null;const Ue=t[ve];if(!I?.(C(Ue),n[Se].field)&&ie(Ue,ve,Se))return{r:ve,c:Se}}return null};if(G){if(O==="Enter")D.preventDefault(),a.stopCellEdit();else if(O==="Escape")D.preventDefault(),a.stopCellEdit({cancel:!0});else if(O==="Tab"&&X!==null){const pe=xe(D.shiftKey?-1:1);pe&&(D.preventDefault(),a.stopCellEdit(),U(pe.r,pe.c))}return}if(O==="Escape"&&A?.collapseSelection()){D.preventDefault();return}if(O==="Tab"||O==="Escape"||$==="control"&&(O==="Enter"||J))return;if((D.ctrlKey||D.metaKey)&&(O==="a"||O==="A")){if(A){A.selectAllCells()&&D.preventDefault();return}if(!_||!F||!M)return;D.preventDefault(),M(!0);return}if(he&&(O==="Enter"||J))return;if(X===null){if(O==="Enter"||J){if(D.preventDefault(),ne===Ye){Ao(T,B,-1)?.click();return}const pe=n[K];if(!pe||Je(ne)||pe.sortable===!1)return;const ve=u.find(be=>be.field===ne),Se=ve?ve.sort==="asc"?"desc":null:"asc";(x||D.shiftKey)&&m?m(ne,Se):g(ne,Se);return}}else if(O==="Enter"||J){D.preventDefault();const pe=t[me];if(ne===Ye){i(X,!r.has(X));return}if(ne===_t){D.shiftKey||l(X);return}if(J){D.shiftKey&&_&&!we(X)&&i(X,!r.has(X));return}if(ne===St)return;if(ie(pe,me,K)){a.startCellEdit({id:X,field:ne,value:Me(pe,ne,n[K])});return}if(N&&E?.get(X)?.hasChildren){N(X);return}S?.({row:pe,id:X,rowIndex:me});return}if(D.altKey&&(O==="ArrowRight"||O==="ArrowLeft")&&N&&X!==null){D.preventDefault();const pe=E?.get(X);pe?.hasChildren&&!!pe.isExpanded!=(O==="ArrowRight")&&N(X);return}if(!Ni.has(O))return;D.preventDefault();const Ce=t.length-1,le=n.length-1,ye=D.ctrlKey||D.metaKey,ke=p?f:10;if(A&&D.shiftKey&&X!==null&&Ke(ne)&&A.extendSelection(O,ye,ke,B))return;const De=(pe,ve)=>{switch(O){case"ArrowRight":return ve+1>le?{r:pe+1,c:0}:{r:pe,c:ve+1};case"ArrowLeft":return ve-1<0?{r:pe-1,c:le}:{r:pe,c:ve-1};case"ArrowDown":return{r:pe+1,c:ve};case"ArrowUp":return{r:pe-1,c:ve};case"Home":return{r:ye?Y:pe,c:0};case"End":return{r:ye?Ce:pe,c:le};case"PageUp":return{r:Math.max(Y,pe-ke),c:ve};default:return{r:Math.min(Ce,pe+ke),c:ve}}},Ne=({r:pe,c:ve})=>pe>=Y&&pe<=Ce&&ve>=0&&ve<=le,Ie=({r:pe,c:ve})=>pe>=0?I?.(C(t[pe]),n[ve].field)??null:null;let Ee=De(me,K);if(O.startsWith("Arrow"))for(let pe=Ne(Ee)?Ie(Ee):null;pe&&pe.rowId===X&&pe.field===ne;pe=Ne(Ee)?Ie(Ee):null)Ee=De(Ee.r,Ee.c);if(!Ne(Ee))return;const Ae=Ie(Ee);if(Ae){const pe=t.findIndex(Se=>C(Se)===Ae.rowId),ve=n.findIndex(Se=>Se.field===Ae.field);pe!==-1&&ve!==-1&&(Ee={r:pe,c:ve})}Ee.r===me&&Ee.c===K||U(Ee.r,Ee.c)},[B,re,t,n,a,r,i,l,c,u,g,m,x,y,p,f,E,S,N,M,_,F,te,q,I,C,A,v]);return{focusedCell:B,setFocusedCell:V,viewportTabIndex:Z?-1:0,ensureGridFocus:de,handleFocus:ae,handleBlur:fe,handleKeyDown:ee,handleMouseDownCapture:Q}}const Fo=[];function lc(e){const{isPivotActive:t}=e,n=t?Fo: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 sc=[],ac={rowFields:[],columnFields:[],valueFields:[]},Ii=100;function cc(e){return!e||e.length===0||e.includes(Ii)?Ii:e[0]}function dc(e){const{initialState:t,sortModel:n,onSortModelChange:o,filterModel:r,onFilterModelChange:i,aggregationModel:l,onAggregationModelChange:a,rowGroupingModel:c,onRowGroupingModelChange:u,columnVisibilityModel:g,onColumnVisibilityModelChange:m,pinnedColumns:x,onPinnedColumnsChange:y,pivotModel:p,onPivotModelChange:f,paginationModel:h,onPaginationModelChange:b,pageSizeOptions:w,rowSelectionModel:C,onRowSelectionModelChange:E,density:S,cellSelectionModel:N,onCellSelectionModelChange:M}=e,[_,F]=s.useState(()=>t?.sorting?.sortModel??[]),P=n!==void 0,L=P?n:_,k=s.useCallback(be=>{P||F(be),o?.(be)},[P,o]),[I,A]=s.useState(()=>t?.filter?.filterModel??{items:[]}),v=r!=null,W=v?r:I,V=s.useCallback(be=>{v||A(be),i?.(be)},[v,i]),Z=l!==void 0,[H,z]=s.useState(()=>l??{}),B=JSON.stringify(Z?l:H),re=s.useMemo(()=>JSON.parse(B),[B]),oe=s.useCallback(be=>{Z||z(be),a?.(be)},[Z,a]),ue=c!==void 0,[se,ce]=s.useState(Fo),R=(ue?c:se)||Fo,de=s.useCallback(be=>{ue||ce(be),u?.(be)},[ue,u]),j=g!==void 0,[te,q]=s.useState(()=>t?.columns?.columnVisibilityModel??{}),Q=j?g:te,ae=s.useCallback(be=>{j||q(be),m?.(be)},[j,m]),fe=x!==void 0,[ee,D]=s.useState(()=>t?.columns?.pinnedColumns??{}),T=fe?x:ee,$=s.useCallback(be=>{fe||D(be),y?.(be)},[fe,y]),[O,J]=s.useState(()=>p??ac),G=p??O,Y=s.useCallback(be=>{J(be),f?.(be)},[f]),U=h!==void 0,[X,ne]=s.useState(()=>t?.pagination?.paginationModel??h??{page:0,pageSize:cc(w)}),he=U?h:X,me=s.useCallback(be=>{U||ne(be),b?.(be)},[U,b]),K=C!==void 0,[ge,we]=s.useState([]),ie=K?C:ge,xe=s.useMemo(()=>new Set(ie),[ie]),Ce=s.useRef(null);s.useLayoutEffect(()=>{Ce.current=null});const le=s.useCallback(()=>Ce.current,[]),ye=s.useCallback(be=>{Ce.current=be,K||we(be),E?.(be)},[K,E]),[ke]=s.useState(()=>t?.density?.density??"standard"),De=S??ke,Ne=N!==void 0,[Ie,Ee]=s.useState(sc),Ae=Ne?N:Ie,pe=s.useRef(null);s.useLayoutEffect(()=>{pe.current=null});const ve=s.useCallback(()=>pe.current,[]),Se=s.useCallback((be,Le)=>{pe.current=be,Ne||Ee(be),M?.(be,{reason:Le})},[Ne,M]);return{sortModel:L,isSortControlled:P,setInternalSortModel:F,handleSortModelChange:k,filterModel:W,isFilterControlled:v,handleFilterModelChange:V,aggregationModel:re,handleAggregationModelChange:oe,rowGroupingModel:R,handleRowGroupingModelChange:de,columnVisibilityModel:Q,handleColumnVisibilityModelChange:ae,pinnedColumns:T,handlePinnedColumnsChange:$,currentPivotModel:G,handlePivotModelChange:Y,effectivePaginationModel:he,handlePaginationModelChange:me,rowSelectionModel:ie,selectedRowIds:xe,isSelectionControlled:K,setInternalRowSelectionModel:we,handleRowSelectionModelChange:ye,getPendingRowSelectionModel:le,density:De,cellSelectionModel:Ae,handleCellSelectionModelChange:Se,getPendingCellSelectionModel:ve}}const Li=s.createContext(null),uc=52,fc=56,gc=32,pc=72;function Gn(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 hc(e){const{rowHeight:t,headerHeight:n,density:o}=e,r=s.useContext(Li)?.grid;let i;return o==="compact"?i=Gn(r?.rowHeightCompact)??gc:o==="comfortable"?i=Gn(r?.rowHeightComfortable)??pc:i=t??Gn(r?.rowHeightStandard)??uc,{rowHeight:i,headerHeight:n??Gn(r?.headerHeight)??fc}}function Hn(e){return e>=1?Math.floor(e):1}function Oo(e,t){return Math.max(1,Math.ceil(Math.max(0,e)/Hn(t)))}function mc(e){const{paginationMode:t,hasDataSource:n,dataSourceRowCount:o,rowCountProp:r,clientRowCount:i}=e;return t!=="server"?i:(n?o??r:r)??i}function Pi(e){return e?{paginationRowsPerPage:e.paginationRowsPerPage,paginationOf:e.paginationOf,paginationPage:e.paginationPage}:void 0}function Ai(e,t){return Number.isFinite(e)?Math.min(Math.max(0,Math.floor(e)),Math.max(0,t-1)):0}function wc(e){const{effectiveRows:t,activeHierarchyHandlers:n,filterMode:o,filterModel:r,sortModel:i,sortingMode:l,pagination:a,paginationMode:c,effectivePaginationModel:u,pinnedRows:g,getRowId:m,columnLookup:x,hierarchyField:y}=e,p=s.useMemo(()=>n?n.getVisibleRows({labelField:y})||[]:o==="server"?t:So(t,r,x),[t,r,n,y,o,x]),f=s.useMemo(()=>n?o==="server"?t:So(t,r,x):p,[n,p,o,t,r,x]),{top:h,center:b,bottom:w}=s.useMemo(()=>n?{top:[],center:p,bottom:[]}:da(p,g,m),[p,g,n,m]),C=s.useMemo(()=>n||l==="server"?b:Oa(b,i,x,m),[b,i,n,l,x,m]),E=a&&c!=="server",S=Hn(u.pageSize),N=E?Ai(u.page,Oo(C.length,S)):u.page,M=s.useMemo(()=>{if(!E)return C;const F=N*S;return C.slice(F,F+S)},[C,E,N,S]),_=s.useMemo(()=>{const F=a?M:C;return[...h,...F,...w]},[h,M,C,w,a]);return{filteredRows:p,dataRows:f,pinnedTopRows:h,unpinnedRows:b,pinnedBottomRows:w,sortedUnpinnedRows:C,paginatedUnpinnedRows:M,currentPage:N,allRenderableRows:_}}const Do=[33554400,17895e3,1e7,5e6],Ti=new WeakMap;function bc(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 Do)if(n.style.height=`${o}px`,Math.abs(n.getBoundingClientRect().height-o)<2)return o;return Do[Do.length-1]}finally{n.remove()}}function xc(e){if(!e)return 1/0;const t=Ti.get(e);if(t!==void 0)return t;const n=bc(e);return Ti.set(e,n),n}function yc(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 $o="application/x-ogx-row",Go="application/x-ogx-column";function Fi(e,t,n){const o=e.dataTransfer;!o||typeof o.setData!="function"||(o.setData(t,n),o.setData("text/plain",n))}function Bn(e,t){const n=e.dataTransfer?.types;return n?Array.from(n).includes(t):!0}function Oi(e,t){if(!e||typeof e.addEventListener!="function")return()=>{};const n=()=>t();return e.addEventListener("dragend",n,{once:!0}),()=>e.removeEventListener("dragend",n)}function Cc(e){const{columns:t,onColumnOrderChange:n,disableColumnReorder:o=!1}=e,[r,i]=s.useState(null),[l,a]=s.useState(null),c=s.useRef(()=>{}),u=s.useCallback(()=>{c.current(),c.current=()=>{},i(null),a(null)},[]);s.useEffect(()=>()=>c.current(),[]);const g=s.useCallback(y=>p=>{if(!o){if(!t.some(f=>f.field===y)){p.preventDefault();return}c.current(),c.current=Oi(p.currentTarget,u),i(y),p.dataTransfer&&(p.dataTransfer.effectAllowed="move",Fi(p,Go,y))}},[t,o,u]),m=s.useCallback(y=>p=>{if(!(o||r===null)){if(!Bn(p,Go)){u();return}p.preventDefault(),p.dataTransfer&&(p.dataTransfer.dropEffect="move"),a(y)}},[r,o,u]),x=s.useCallback(y=>p=>{if(p.preventDefault(),o||r===null||!Bn(p,Go)){u();return}const f=t.findIndex(b=>b.field===r),h=t.findIndex(b=>b.field===y);u(),!(f===-1||h===-1||f===h)&&n?.({column:t[f],oldIndex:f,targetIndex:h})},[t,r,o,n,u]);return{draggedColumn:r,dragOverColumn:l,onDragStart:o?void 0:g,onDragOver:o?void 0:m,onDragEnd:o?void 0:u,onDrop:o?void 0:x}}function Ho({isExpanded:e,onClick:t,variant:n="chevron",tabIndex:o}){return d.jsx("button",{className:`ogx-expand-icon ${e?"ogx-expand-icon--expanded":""}`,onClick:r=>{t&&t(r)},"aria-label":e?"Collapse row":"Expand row",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 vc({renderFn:e}){"use no memo";return d.jsx(d.Fragment,{children:e()})}function Sc(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 Sc(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("div",{className:"ogx__cell-error",role:"img","aria-label":`Error in cell: ${this.props.field}`,title:this.state.error?.message??"Render error",children:"⚠"}):d.jsx(vc,{renderFn:this.props.renderFn})}}function _c(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)?Ln(l.value,t,e,l.row):i?i(l):l.value==null?"":String(l.value)}}function Di(e,t){if(!t)return e;const n=t.left??[],o=t.right??[],r=i=>{const l=tt(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 Wn=e=>e.formattedValue??e.value;function $i(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 kc(e,t,n){const o=e.rowMeta;if(!o?.isGroupRow)return Wn(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})`:""]}):Wn(e)}const Ec=e=>e.id;function Mc(e){const{activeColumns:t,isHierarchyEnabled:n,isRowGrouping:o,isTreeData:r,activeHierarchyHandlers:i,columnVisibilityModel:l,columnOrder:a,onColumnOrderChange:c,onColumnOrderModelChange:u,disableColumnReorder:g,pivotMode:m,checkboxSelection:x,hasDetailPanel:y,rowReordering:p,initialState:f,setColumns:h,pinnedColumns:b,getRowId:w=Ec,aggregationModel:C,groupingRows:E}=e,S=s.useMemo(()=>t.map(q=>q.field),[t]),[N,M]=s.useState(()=>f?.columns?.columnOrder??null),_=m?S.join("\0"):"",[F,P]=s.useState(null),L=F&&F.key===_?F.order:S,I=m?L:a??(N??S),A=s.useCallback(q=>{if(m){P(Q=>{const ae=Q&&Q.key===_?Q.order:S;return{key:_,order:typeof q=="function"?q(ae):q}});return}M(Q=>typeof q=="function"?q(Q??S):q)},[m,_,S]),v=s.useCallback(q=>m&&q.hideable===!1||l[q.field]!==!1,[m,l]),W=s.useMemo(()=>{if(!n)return;const q=new Map(I.map((ee,D)=>[ee,D])),Q=ee=>q.get(ee.field)??t.indexOf(ee),ae=[...t].sort((ee,D)=>Q(ee)-Q(D));return(Di(ae.filter(ee=>l[ee.field]!==!1),b)[0]??t[0])?.field},[n,I,t,l,b]),V=s.useMemo(()=>{if(!n)return t;const q=o?E:void 0;return t.map(Q=>{const ae=_c(Q,C?.[Q.field],q);return Q.field===W?{...Q,...ae,renderCell:fe=>{const ee=fe.rowMeta,D=ee?.treeDepth??0,T=!!ee?.hasChildren,$=!!ee?.isExpanded,O=$i(Q,fe,!0),J=O.useDefault?kc(fe,o,r):O.content;return d.jsxs("div",{style:{display:"flex",alignItems:"center",paddingInlineStart:D*24,width:"100%",height:"100%"},children:[d.jsx("div",{style:{marginInlineEnd:4,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",cursor:T?"pointer":"default",flexShrink:0},children:T?d.jsx("div",{onClick:G=>{G.stopPropagation(),G.preventDefault(),i?.toggleExpansion(w(fe.row))},onMouseDown:G=>{G.stopPropagation()},style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:10,position:"relative"},children:d.jsx(Ho,{isExpanded:$,tabIndex:-1,onClick:G=>{G.stopPropagation(),G.preventDefault(),i?.toggleExpansion(w(fe.row))}})}):null}),d.jsx("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:J})]})}}:{...Q,...ae,renderCell:fe=>{const ee=fe.rowMeta;if(!ee?.isGroupRow)return Q.renderCell?Q.renderCell(fe):Wn(fe);const D=$i(Q,fe,!1);return D.useDefault?Q.field===ee.groupingField&&!ee.isGroupFooter||fe.value==null?null:Wn(fe):D.content}}})},[t,n,o,r,i,W,w,C,E]),[Z,H]=s.useState(()=>f?.columns?.columnWidths??{}),z=s.useCallback((q,Q)=>{H(ae=>({...ae,[q]:Q}))},[]);s.useEffect(()=>{h(t)},[t,h]);const B=s.useMemo(()=>{const q=new Map(I.map((Q,ae)=>[Q,ae]));return[...V].sort((Q,ae)=>{const fe=q.get(Q.field)??V.indexOf(Q),ee=q.get(ae.field)??V.indexOf(ae);return fe-ee})},[V,I]),re=s.useMemo(()=>B.filter(v),[B,v]),oe=s.useCallback((q,Q)=>{(m||!a)&&A(q),Q&&c?.(Q),m||u?.(q)},[m,a,A,c,u]),ue=s.useCallback((q,Q)=>{const ae=B.map(ee=>ee.field),[fe]=ae.splice(q,1);ae.splice(Q,0,fe),oe(ae,{column:B[q],oldIndex:q,targetIndex:Q})},[B,oe]),se=Cc({columns:B,onColumnOrderChange:s.useCallback(({oldIndex:q,targetIndex:Q})=>ue(q,Q),[ue]),disableColumnReorder:g}),ce=s.useCallback((q,Q)=>{const ae=B.findIndex(ee=>ee.field===q),fe=B.findIndex(ee=>ee.field===Q);ae===-1||fe===-1||ae===fe||ue(ae,fe)},[B,ue]),R=s.useCallback(()=>{oe(S)},[oe,S]),de=s.useMemo(()=>Di(re,b),[re,b]),j=s.useMemo(()=>{const q=[];return p&&q.push({field:St,sortable:!1,editable:!1}),y&&q.push({field:_t,sortable:!1,editable:!1}),x&&q.push({field:Ye,sortable:!1,editable:!1}),[...q,...de]},[de,x,y,p]),te=s.useMemo(()=>new Map(de.map((q,Q)=>[q.field,Q])),[de]);return{effectiveColumns:V,hierarchyField:W,orderedColumns:B,visibleOrderedColumns:re,renderOrderedColumns:de,navigationColumns:j,columnIndexMap:te,columnWidths:Z,effectiveColumnOrder:I,setInternalColumnOrder:A,columnReorderHandlers:se,moveColumn:ce,resetColumnOrder:R,handleColumnResize:z}}function Nc(){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 Ic(e){const{hasDetailPanel:t,controlledExpandedRowIds:n,onDetailPanelExpandedRowIdsChange:o,rowMetaMap:r}=e,[i,l]=s.useState(new Set),a=n??i,c=s.useMemo(()=>ha(a,r),[a,r]),u=s.useCallback(x=>{if(r.get(x)?.isGroupRow)return;const y=new Set(a);y.has(x)?y.delete(x):y.add(x),n===void 0&&l(y),o?.(y)},[a,r,n,o]),{detailPanelHeights:g,reportDetailPanelHeight:m}=Nc();return{hasDetailPanel:t,expandedRowIds:c,handleDetailPanelToggle:u,detailPanelHeights:g,reportDetailPanelHeight:m}}const Lc=new Set(["__group__"]),ln=e=>!Lc.has(e);function Gi(e){return Object.keys(e).every(ln)?e:Object.fromEntries(Object.entries(e).filter(([n])=>ln(n)))}function Pc(e){const t={...e};return e.left&&(t.left=e.left.filter(ln)),e.right&&(t.right=e.right.filter(ln)),t}function Ac(e){const{onStateChange:t,sortModel:n,filterModel:o,effectivePaginationModel:r,columnWidths:i,effectiveColumnOrder:l,columnVisibilityModel:a,pinnedColumns:c,density:u}=e,g=s.useRef(t);s.useLayoutEffect(()=>{g.current=t});const m=s.useRef(null);s.useEffect(()=>{if(!g.current)return;const x={sorting:{sortModel:n},filter:{filterModel:o},pagination:{paginationModel:r},columns:{columnWidths:Gi(i),columnOrder:l.filter(ln),columnVisibilityModel:Gi(a),pinnedColumns:Pc(c)},density:{density:u}},y=JSON.stringify(x);y!==m.current&&(m.current=y,g.current(x))},[n,o,r,i,l,a,c,u])}const Tc=200,Fc=2e3,Oc=178e5;function Dc(e){const{paginationRequested:t,isRowGrouping:n,autoHeight:o,viewportHeight:r,renderedRowCount:i,totalRowCount:l,pinnedRowsIgnored:a=!1,scrollHeight:c=0,maxContentHeight:u,reachableRowCount:g,unpinnedRowCount:m,listViewWithoutColumn:x=!1,listViewRowCount:y=0}=e,p=s.useRef(!1),f=s.useRef(!1),h=s.useRef(!1),b=s.useRef(!1),w=s.useRef(!1),C=s.useRef(!1);s.useEffect(()=>{process.env.NODE_ENV==="production"||C.current||y<=Fc||(C.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"||w.current||!x||(w.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"||h.current||!a||(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."))},[a]),s.useEffect(()=>{if(process.env.NODE_ENV==="production"||b.current||u===void 0)return;const E=Number.isFinite(u);if(E?c<=u:c<=Oc)return;b.current=!0;const S=E&&g!==void 0&&m!==void 0?`Only the first ${g.toLocaleString("en-US")} of ${m.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(c)}px tall, more than this browser lays out (about 17.9M px in Firefox, 33.5M px in Chrome and Safari). `+S+'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.')},[c,u,g,m]),s.useEffect(()=>{process.env.NODE_ENV==="production"||p.current||t&&n&&(p.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"||f.current||o||r>0&&l>Tc&&i>=l&&r>=c&&(f.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,c])}function $c(e){return typeof window>"u"||typeof window.getComputedStyle!="function"||typeof navigator<"u"&&/jsdom/i.test(navigator.userAgent)?!1:window.getComputedStyle(e).display!=="flex"}let Hi=!1;function Gc(e){s.useEffect(()=>{if(process.env.NODE_ENV==="production"||Hi)return;const t=e.current;!t||!$c(t)||(Hi=!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 Bi=e=>JSON.stringify(Array.from(e,t=>typeof t=="number"?["n",t]:["s",t]));function Hc(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;const g=new Set;for(const m of t)n.has(m)||o.has(m)?g.add(m):u=!0;return u?g:t},[r,t,n,o]),a=s.useRef(i);s.useLayoutEffect(()=>{a.current=i});const c=s.useRef(null);return s.useEffect(()=>{if(l===t){c.current=null;return}const u=`${Bi(t)}|${Bi(l)}`;c.current!==u&&(c.current=u,a.current(Array.from(l)))},[l,t]),l}function Vn(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 Bc(e,t,n){return n?e.has(t)?[]:[t]:Vn(e,[t],!e.has(t),!1)}function Wi(e,t){return t.length===e.size&&t.every(n=>e.has(n))}function Wc(e){const{selectedRowIds:t,onSelectionModelChange:n,disableMultipleRowSelection:o,selectableRowIds:r}=e,i=s.useCallback(m=>{Wi(t,m)||n(m)},[t,n]),l=s.useCallback((m,x)=>{i(Vn(t,[m],x,o))},[i,t,o]),a=s.useCallback(m=>{i(Bc(t,m,o))},[i,t,o]),c=s.useCallback(m=>{i(Vn(t,r,m,!1))},[i,t,r]),{allSelected:u,someSelected:g}=s.useMemo(()=>{let m=0;for(const y of r)t.has(y)&&m++;const x=r.length>0&&m===r.length;return{allSelected:x,someSelected:!x&&m>0}},[r,t]);return{toggleRow:l,clickRow:a,selectAll:o?void 0:c,allSelected:u,someSelected:g}}function Vc(e){const{dataRows:t,getRowId:n,isPivotActive:o,selectedRowIds:r,onSelectionModelChange:i,disableMultipleRowSelection:l,disableRowSelectionOnClick:a,isHierarchyEnabled:c,rowMetaMap:u,activeHierarchyHandlers:g,onRowClick:m}=e,x=s.useMemo(()=>{const w=t.map(n);return o?w.filter(C=>C!==Ht):w},[t,n,o]),y=Wc({selectedRowIds:r,onSelectionModelChange:i,disableMultipleRowSelection:l,selectableRowIds:x}),{clickRow:p,toggleRow:f}=y,h=s.useCallback(w=>{const{id:C}=w,E=c?u.get(C):void 0;if(E?.isGroupRow){E.hasChildren&&g?.toggleExpansion(C);return}m?.(w),!a&&!Re(C,u)&&p(C)},[c,g,m,u,a,p]),b=s.useCallback((w,C)=>{Re(w,u)||f(w,C)},[u,f]);return{rowSelection:y,handleRowClick:h,handleSelectionChange:b}}function Bo(e,t,n,o){return o?$a(e,t,n):n?[{field:t,sort:n}]:e.filter(r=>r.field!==t)}function zc(e){const{sortModel:t,onSortModelChange:n}=e,o=s.useCallback((i,l)=>{n(Bo(t,i,l,!1))},[t,n]),r=s.useCallback((i,l)=>{n(Bo(t,i,l,!0))},[t,n]);return{handleSort:o,handleSortAdd:r}}function Rc(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(c=>{const u={...i.current.columnVisibilityModel,[c]:!1};i.current={...i.current,columnVisibilityModel:u},n(u)},[n]),a=s.useCallback((c,u)=>{const g=ua(i.current.pinnedColumns,c,u);i.current={...i.current,pinnedColumns:g},r(g)},[r]);return{handleHideColumn:l,handlePinColumn:a}}function Kc(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=(c,u)=>{const{sortModel:g,multiSort:m,onSortModelChange:x}=r(),y=Bo(g,c,u,m);n.current={...r(),sortModel:y},x(y)},o.getFilterModel=()=>r().filterModel,o.setFilterModel=c=>{n.current={...r(),filterModel:c},r().onFilterModelChange(c)};const i=c=>{n.current={...r(),paginationModel:c},r().onPaginationModelChange(c)};o.setPage=c=>i({...r().paginationModel,page:c}),o.setPageSize=c=>i({...r().paginationModel,pageSize:c,page:0});const l=()=>{const c=r().getPendingRowSelectionModel?.();return c?new Set(c):r().selectedRowIds},a=(c,u)=>{const{disableMultipleRowSelection:g,onRowSelectionModelChange:m,isSyntheticRowId:x}=r(),y=x?c.filter(h=>!x(h)):c;if(y.length===0)return;const p=l(),f=Vn(p,y,u,g);Wi(p,f)||(n.current={...r(),selectedRowIds:new Set(f)},m(f))};o.getSelectedRows=()=>Array.from(l()),o.selectRow=(c,u=!0)=>a([c],u),o.selectRows=(c,u=!0)=>a(c,u),o.getVisibleRows=()=>r().getVisibleRows(),o.getAllFilteredRows=()=>r().getAllFilteredRows(),o.getVisibleColumns=()=>r().visibleColumns,o.setSortModel=c=>{n.current={...r(),sortModel:c},r().onSortModelChange(c)},o.setRowGroupingModel=c=>{n.current={...r(),rowGroupingModel:c},r().onRowGroupingModelChange(c)},o.setAggregationModel=c=>{n.current={...r(),aggregationModel:c},r().onAggregationModelChange(c)},o.setColumnVisibilityModel=c=>{n.current={...r(),columnVisibilityModel:c},r().onColumnVisibilityModelChange(c)},o.setPivotModel=c=>{n.current={...r(),pivotModel:c},r().onPivotModelChange(c)},o.getGridAiState=()=>{const{filterModel:c,sortModel:u,rowGroupingModel:g,aggregationModel:m,pivotModel:x,columnVisibilityModel:y}=r();return{filterModel:c,sortModel:u,rowGroupingModel:g,aggregationModel:m,pivotModel:x,columnVisibilityModel:y}}},[t])}function Uc(e){const{controlledState:t,interactions:n,api:o}=e,{sortModel:r,handleSortModelChange:i,filterModel:l,handleFilterModelChange:a,effectivePaginationModel:c,handlePaginationModelChange:u,handleRowSelectionModelChange:g,rowGroupingModel:m,handleRowGroupingModelChange:x,aggregationModel:y,handleAggregationModelChange:p,columnVisibilityModel:f,handleColumnVisibilityModelChange:h,currentPivotModel:b,handlePivotModelChange:w}=t,C=Vc({...n,selectedRowIds:o.selectedRowIds,onSelectionModelChange:g,disableMultipleRowSelection:o.disableMultipleRowSelection});return Kc({...o,onSortModelChange:i,sortModel:r,filterModel:l,onFilterModelChange:a,paginationModel:c,onPaginationModelChange:u,getPendingRowSelectionModel:t.getPendingRowSelectionModel,onRowSelectionModelChange:g,rowGroupingModel:m,onRowGroupingModelChange:x,aggregationModel:y,onAggregationModelChange:p,columnVisibilityModel:f,onColumnVisibilityModelChange:h,pivotModel:b,onPivotModelChange:w}),C}const Vi="\0";function jc(e,t){const n=e.filter(o=>t[o.field]===!1).map(o=>o.field).join(Vi);return s.useMemo(()=>{const o={};if(n)for(const r of n.split(Vi))o[r]=!1;return No(e,o)},[e,n])}function qc({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 a=`${i}>${t}`;if(l.current===a)return;l.current=a;const{paginationModel:c,onPaginationModelChange:u}=r.current;u({...c,page:t})},[n,t,i])}const Pe=()=>{},Wo=()=>Promise.resolve({updated:[],failed:[],skipped:[]});function zi(){return{getRow:()=>null,getAllRows:()=>[],getVisibleRows:()=>[],getAllFilteredRows:()=>[],getGroupedExportRows:()=>null,getAggregationResult:()=>null,getAggregationModel:()=>null,getColumn:()=>null,getAllColumns:()=>[],getVisibleColumns:()=>[],selectRow:Pe,selectRows:Pe,getSelectedRows:()=>[],sortColumn:Pe,getSortModel:()=>[],setFilterModel:Pe,getFilterModel:()=>({items:[]}),setPage:Pe,setPageSize:Pe,scrollToIndexes:Pe,autosizeColumn:Pe,autosizeColumns:Pe,copySelectedRows:()=>Promise.resolve(),getCellSelectionModel:()=>[],setCellSelectionModel:Pe,selectCellRange:Pe,clearCellSelection:Pe,getSelectedCells:()=>[],copySelectedCells:()=>Promise.resolve(),pasteText:Wo,undo:Wo,redo:Wo,canUndo:()=>!1,canRedo:()=>!1,clearHistory:Pe,setSortModel:Pe,setRowGroupingModel:Pe,setAggregationModel:Pe,setColumnVisibilityModel:Pe,setPivotModel:Pe,getGridAiState:()=>({}),openAiAssistant:Pe,closeAiAssistant:Pe}}const Xc=e=>e.id;let Ri=!1;function Ki(e,t,n){const o=new Map,r=new Map,i=[],l=[];return e.forEach(a=>{const c=n?.get(a)??t(a);if(o.has(c)){l.push(c);return}o.set(c,a),r.set(a,c),i.push(c)}),l.length>0&&!Ri&&process.env.NODE_ENV!=="production"&&(Ri=!0,console.warn(`[OpenGridX] ${l.length} row(s) reuse the id of an earlier row and were ignored (ids: ${l.slice(0,5).map(String).join(", ")}${l.length>5?", …":""}). Every row needs a unique id; pass getRowId if the unique key lives in another field.`)),{idRowsLookup:o,allRows:i,idByRow:r}}function Yc(e,t,n,o={}){const r=new Map,i=[];return n.forEach(l=>{r.set(l.field,l),i.push(l.field)}),{rows:Ki(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 Jc(e,t){switch(t.type){case"SET_ROWS":{const n=e.rows.allRows.map(r=>e.rows.idRowsLookup.get(r)),o=typeof t.payload=="function"?t.payload(n):t.payload;return{...e,rows:Ki(o,t.getRowId,e.rows.idByRow)}}case"REPLACE_ROW":{const n=e.rows.idRowsLookup.get(t.id);if(n===void 0)return e;const o=new Map(e.rows.idRowsLookup);o.set(t.id,t.row);const r=new Map(e.rows.idByRow);return r.delete(n),r.set(t.row,t.id),{...e,rows:{...e.rows,idRowsLookup:o,idByRow:r}}}case"REPLACE_ROWS":{let n=!1;const o=new Map(e.rows.idRowsLookup),r=new Map(e.rows.idByRow);for(const[i,l]of t.rows){const a=o.get(i);a!==void 0&&(n=!0,o.set(i,l),r.delete(a),r.set(l,i))}return n?{...e,rows:{...e.rows,idRowsLookup:o,idByRow:r}}:e}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 Zc(e){const{rows:t,columns:n,rowHeight:o=52,headerHeight:r=56,columnVisibilityModel:i,initialState:l,syncRows:a=!1}=e,c=e.getRowId??Xc,u=s.useRef(c);s.useLayoutEffect(()=>{u.current=c});const[g]=s.useState(()=>Yc(t,c,n,i)),[m,x]=s.useReducer(Jc,{...g,dataSource:l?.dataSource?{...g.dataSource,...l.dataSource}:g.dataSource,pagination:{rowCount:l?.pagination?.rowCount},dimensions:{...g.dimensions,rowHeight:o,headerHeight:r}}),[y,p]=s.useState({rows:t,syncRows:a});(y.rows!==t||y.syncRows!==a)&&(p({rows:t,syncRows:a}),a&&x({type:"SET_ROWS",payload:t,getRowId:c}));const f=s.useRef(m);s.useLayoutEffect(()=>{f.current=m});const h=s.useCallback((P,L)=>{x({type:"SET_ROWS",payload:P,getRowId:u.current})},[]),b=s.useCallback((P,L)=>{x({type:"REPLACE_ROW",id:P,row:L})},[]),w=s.useCallback(P=>{P.size>0&&x({type:"REPLACE_ROWS",rows:P})},[]),C=s.useCallback(P=>{x({type:"SET_COLUMNS",payload:P})},[]),E=s.useCallback((P,L)=>{x({type:"SET_DIMENSIONS",payload:{viewportWidth:P,viewportHeight:L}})},[]),S=s.useCallback(P=>{x({type:"SET_DATASOURCE_LOADING",payload:P})},[]),N=s.useCallback(P=>{x({type:"SET_DATASOURCE_ERROR",payload:P})},[]),M=s.useCallback(P=>{x({type:"SET_ROW_COUNT",payload:P})},[]),[_]=s.useState(()=>({...zi(),getRow:P=>f.current.rows.idRowsLookup.get(P)||null,getAllRows:()=>f.current.rows.allRows.map(P=>f.current.rows.idRowsLookup.get(P)),getColumn:P=>f.current.columns.lookup.get(P)||null,getAllColumns:()=>f.current.columns.all})),F=s.useRef(_);return{state:m,dispatch:x,apiRef:F,setRows:h,replaceRow:b,replaceRows:w,setColumns:C,setDimensions:E,setDataSourceLoading:S,setDataSourceError:N,setRowCount:M}}function Qc(e){const{onRowOrderChange:t,rows:n,getRowId:o,rowReordering:r=!1}=e,[i,l]=s.useState(null),[a,c]=s.useState(null),u=s.useRef(()=>{}),g=s.useMemo(()=>{const h=new Map;return n.forEach((b,w)=>h.set(o?o(b):b.id,w)),h},[n,o]),m=s.useCallback(h=>g.has(h),[g]),x=s.useCallback(()=>{u.current(),u.current=()=>{},l(null),c(null)},[]);s.useEffect(()=>()=>u.current(),[]);const y=s.useCallback(h=>b=>{if(r){if(!g.has(h)){b.preventDefault();return}u.current(),u.current=Oi(b.currentTarget,x),l(h),b.dataTransfer&&(b.dataTransfer.effectAllowed="move",Fi(b,$o,String(h)))}},[r,g,x]),p=s.useCallback(h=>b=>{if(!(!r||i===null)){if(!Bn(b,$o)){x();return}g.has(h)&&(b.preventDefault(),b.dataTransfer&&(b.dataTransfer.dropEffect="move"),a!==h&&c(h))}},[r,i,a,g,x]),f=s.useCallback(h=>b=>{if(b.preventDefault(),i===null||!Bn(b,$o)){x();return}const w=g.get(i),C=g.get(h);x(),t&&w!==void 0&&C!==void 0&&w!==C&&t({row:n[w],oldIndex:w,targetIndex:C})},[i,t,n,g,x]);return{draggedRowId:i,dragOverRowId:a,canReorderRow:m,onDragStart:r?y:void 0,onDragOver:r?p:void 0,onDragEnd:r?x:void 0,onDrop:r?f:void 0}}const Ui=new Map,ji=e=>JSON.stringify(e),ed=e=>`auto-group-${e}`,qi=5,Xi=e=>e.slice(0,qi).map(t=>JSON.stringify(t)).join(", ")+(e.length>qi?", …":""),td={treeNodes:new Map,rootIds:[],groupingRows:[],syntheticIds:new Set,rowLookup:new Map,issues:[]};function nd(e,t,n){const o=new Map,r=[],i=[],l=new Set,a=new Map,c=new Map,u=[],g=new Array(e.length),m=new Array(e.length),x=[],y=new Map;e.forEach((f,h)=>{const b=t(f),w=n(f),C=Array.isArray(w)?w.map(E=>String(E)):[];if(g[h]=b,m[h]=C,a.set(b,f),C.length===0)x.push(b);else{const E=ji(C),S=c.get(E);if(S===void 0)c.set(E,b);else{const N=y.get(E)??[S];N.push(b),y.set(E,N)}}o.set(b,{id:b,parentId:null,depth:Math.max(C.length-1,0),groupingKey:C[C.length-1]??"",isExpanded:!1,children:[],serverChildrenCount:f.serverChildrenCount})});const p=f=>{const h=ji(f),b=c.get(h);if(b!==void 0)return b;const w=ed(h),C=f[f.length-1],E={id:w,parentId:null,depth:f.length-1,groupingKey:C,isExpanded:!1,children:[],label:C};o.set(w,E),c.set(h,w),l.add(w);const S={id:w};if(i.push(S),a.set(w,S),f.length===1)r.push(w);else{const N=p(f.slice(0,-1));E.parentId=N,o.get(N)?.children?.push(w)}return w};return e.forEach((f,h)=>{const b=g[h],w=m[h];if(w.length<=1){r.push(b);return}const C=p(w.slice(0,-1)),E=o.get(b);E&&(E.parentId=C),o.get(C)?.children?.push(b)}),x.length>0&&u.push(`[OpenGridX] treeData: getTreeDataPath returned an empty path for row(s) ${Xi(x)}. They are shown as top-level rows.`),y.forEach((f,h)=>{u.push(`[OpenGridX] treeData: rows ${Xi(f)} have the same path ${h}. Rows under that path are attached to row ${JSON.stringify(f[0])}.`)}),{treeNodes:o,rootIds:r,groupingRows:i,syntheticIds:l,rowLookup:a,issues:u}}function od(e,t){const{treeNodes:n,rootIds:o,syntheticIds:r,rowLookup:i}=e,l=new Set,a=new Map,c=new Map,u=g=>{const m=n.get(g);if(!m)return!1;const x=[];let y=0;for(const b of m.children??[])u(b)&&(x.push(b),y+=(r.has(b)?0:1)+(c.get(b)??0));a.set(g,x),c.set(g,y);const p=i.get(g),h=!r.has(g)&&p!==void 0&&(t?t(p):!0)||x.length>0;return h&&l.add(g),h};return o.forEach(u),{visible:l,visibleChildren:a,descendantCounts:c}}function rd(e){const{rows:t,getRowId:n,getTreeDataPath:o,treeData:r=!1,defaultGroupingExpansionDepth:i=0,filterModel:l,sortModel:a,onRowExpansionChange:c,columnLookup:u,filterMode:g="client",sortingMode:m="client"}=e,x=r&&!!o,y=s.useMemo(()=>!r||!o?td:nd(t,n,o),[t,o,r,n]),{treeNodes:p,rootIds:f,groupingRows:h,syntheticIds:b,rowLookup:w}=y,C=y.issues.join(`
|
|
2
2
|
`);s.useEffect(()=>{process.env.NODE_ENV==="production"||!C||C.split(`
|
|
3
|
-
`).forEach(z=>console.warn(z))},[C]);const E=r&&!o;s.useEffect(()=>{process.env.NODE_ENV==="production"||!E||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.")},[E]);const S=s.useMemo(()=>g==="server"?null:Rn(l,u),[g,l,u]),N=s.useMemo(()=>Nu(y,S),[y,S]),M=`${r}|${i}`,[_,O]=s.useState(()=>({configKey:M,overrides:new Map})),L=_.configKey===M?_.overrides:zl,A=s.useCallback(z=>((z?.children?.length??0)>0||(z?.serverChildrenCount??0)>0)&&(i===-1||(z?.depth??0)<i),[i]),k=s.useMemo(()=>{const z=new Set;return x&&p.forEach((W,re)=>{(L.get(re)??A(W))&&z.add(re)}),z},[x,p,L,A]),I=s.useCallback(z=>{const W=!k.has(z);if(O(re=>{const oe=re.configKey===M?re.overrides:zl,fe=new Map(oe);return fe.set(z,W),{configKey:M,overrides:fe}}),W&&c){const re=p.get(z);re&&c(re)}},[k,M,p,c]),P=h!=="server"&&!!(a&&a.length>0),v=s.useCallback(z=>{if(!x)return null;const W=z?.labelField,re=z?.expandAll??!1,{visible:oe,visibleChildren:fe}=N,le=P&&a?a:[],ce=(te,U)=>{if(b.has(te))return{value:U.field===W?p.get(te)?.label:void 0};const J=w.get(te),se=u?.byField.get(U.field),ue=J?Me(J,U.field,se):void 0,ee=se?.sortComparator;return{value:ue,type:se?.type,comparator:ee,params:ee&&J?{id:te,field:U.field,row:J,value:ue}:void 0}},K=[],de=new Set,X=te=>{const U=te.filter(se=>oe.has(se)),J=le.length>0?Ti(U,le,ce):U;for(const se of J){if(de.has(se))continue;const ue=w.get(se);if(!ue)continue;de.add(se),K.push(ue);const ee=fe.get(se);ee&&ee.length>0&&(re||k.has(se))&&X(ee)}};return X(f),K},[x,N,P,a,b,p,w,u,f,k]),B=s.useCallback(z=>k.has(z),[k]),V=s.useCallback(z=>p.get(z),[p]),Q=s.useCallback(z=>{const W=[];let re=z;for(;re!==null;){const oe=p.get(re);if(!oe)break;W.unshift(oe.groupingKey),re=oe.parentId}return W},[p]),H=s.useMemo(()=>{const z=new Map,{visibleChildren:W,descendantCounts:re}=N;return p.forEach((oe,fe)=>{const le=(oe.children?.length??0)===0&&(oe.serverChildrenCount??0)>0,ce=b.has(fe),K={hasChildren:(W.get(fe)?.length??0)>0||le,treeDepth:oe.depth,descendantCount:le?void 0:re.get(fe)??0,isGroupRow:ce,isExpanded:k.has(fe)};ce&&(K.groupLabel=oe.label),z.set(fe,K)}),z},[p,b,N,k]);return s.useMemo(()=>({treeNodes:p,groupingRows:m,toggleExpansion:I,isGroupExpanded:B,getVisibleRows:v,getNode:V,getNodePath:Q,rowMetaMap:H}),[p,m,I,B,v,V,Q,H])}const Rl=e=>e===null?"footer":"inline";function ql(e,t){return Do(()=>e(t),Rl(t),"getAggregationPosition","getAggregationPosition threw; the default position is used")}function Lu(e,t,n){const o=`${t}: ${String(n)}`,r=e?.groupingValueFormatter;return r?Do(()=>r({field:t,value:n}),o,`groupingValueFormatter:${t}`,`groupingValueFormatter for column "${t}" threw; the group is labelled "${t}: value"`):o}const Au=[],Tu={},Xl=new Map,tt="";function Pu(e){if(typeof e=="string")return e;if(e===null)return`${tt}null`;if(e===void 0)return`${tt}undefined`;if(e instanceof Date)return`${tt}date:${e.getTime()}`;if(typeof e=="object")try{return`${tt}object:${JSON.stringify(e)}`}catch{return`${tt}object:${String(e)}`}return`${tt}${typeof e}:${String(e)}`}const Fu=(e,t,n)=>`auto-group-${e}-${t}-${n??"root"}`,Ou=e=>`${e}${tt}footer`,Du=e=>e==="footer"?"f":e===null?"n":"i",$u=e=>e==="f"?"footer":e==="n"?null:"inline";function Gu(e){const{rows:t,getRowId:n,columns:o,rowGroupingModel:r=Au,aggregationModel:i=Tu,defaultGroupingExpansionDepth:l=0,filterModel:a,sortModel:c,getAggregationPosition:u=Rl,columnLookup:g,filterMode:h="client",sortingMode:x="client"}=e,y=r.join(tt),p=s.useMemo(()=>y===""?[]:y.split(tt),[y]),f=JSON.stringify(Object.entries(i)),m=s.useMemo(()=>Object.fromEntries(JSON.parse(f)),[f]),b=Object.keys(m).length>0,w=s.useMemo(()=>{const X=new Map;return(o??[]).forEach(te=>X.set(te.field,te)),X},[o]),C=p.length>0,E=s.useMemo(()=>p.filter(X=>w.get(X)?.groupable!==!1),[p,w]),N=`${E.join(tt)}|${l}`,[M,_]=s.useState(()=>({configKey:N,overrides:new Map})),O=M.configKey===N?M.overrides:Xl,L=s.useMemo(()=>{if(!C||h==="server")return null;const X=Rn(a,g);return X?new Set(t.filter(te=>X(te))):null},[C,t,h,a,g]),A=s.useMemo(()=>{const X=new Map,te=[],U=[],J=new Map,se=new Map,ue=new Map;if(!C)return{treeNodes:X,rootIds:te,groupIds:U,groupRowVariants:J,groupingRows:se,rowLookup:ue};const ee=(D,T,$)=>{if(T>=E.length)return(L?D.filter(q=>L.has(q)):D).map(q=>{const ne=n(q);return ue.set(ne,q),X.set(ne,{id:ne,parentId:$,depth:T,groupingKey:"",isExpanded:!1}),ne});const F=E[T],Z=w.get(F),G=new Map;for(const j of D){const q=Me(j,F,Z),ne=Pu(q);let he=G.get(ne);he||(he={value:q,rows:[]},G.set(ne,he)),he.rows.push(j)}const Y=[];return G.forEach((j,q)=>{const ne=L?j.rows.filter(ye=>L.has(ye)):j.rows;if(ne.length===0)return;const he=Fu(F,q,$);Y.push(he),U.push(he);const me=b?jn(ne,m,w,"useRowGrouping"):{},R={[F]:j.value,...me,id:he},ge={[F]:j.value,id:he},we=b?{...me,id:Ou(he)}:null;J.set(he,{inline:R,bare:ge,footer:we}),se.set(he,R),we&&se.set(we.id,we);const ae={id:he,parentId:$,depth:T,groupingKey:String(j.value),groupingField:F,groupingValue:j.value,aggregatedValues:me,isExpanded:!1,children:[],label:Lu(Z,F,j.value),descendantCount:ne.length};X.set(he,ae),ae.children=ee(j.rows,T+1,he)}),Y};return te.push(...ee(t,0,null)),{treeNodes:X,rootIds:te,groupIds:U,groupRowVariants:J,groupingRows:se,rowLookup:ue}},[C,t,L,E,b,m,n,w]),{treeNodes:k,rootIds:I,groupIds:P,groupRowVariants:v,groupingRows:B,rowLookup:V}=A,Q=s.useCallback(X=>!!(X?.children&&X.children.length>0)&&(l===-1||(X?.depth??0)<l),[l]),H=s.useMemo(()=>{const X=new Set;for(const te of P){const U=k.get(te);!U?.children||U.children.length===0||(O.get(te)??Q(U))&&X.add(te)}return X},[P,k,O,Q]),z=s.useCallback(X=>{_(te=>{const U=te.configKey===N?te.overrides:Xl,J=U.get(X)??Q(k.get(X)),se=new Map(U);return se.set(X,!J),{configKey:N,overrides:se}})},[N,k,Q]),W=s.useCallback(X=>H.has(X),[H]),re=b?P.map(X=>{const te=k.get(X);return te?Du(ql(u,{...te,isExpanded:H.has(X)})):"i"}).join(""):"",oe=s.useMemo(()=>{const X=new Map;return P.forEach((te,U)=>X.set(te,$u(re[U]))),X},[P,re]),fe=b?ql(u,null):"footer",le=x!=="server"&&!!(c&&c.length>0),ce=s.useCallback(X=>{if(!C)return null;const te=X?.labelField,U=X?.expandAll??!1,J=le&&c?c:[],se=(T,$)=>{const F=k.get(T),Z=v.get(T);if(F&&Z){const ne=F.groupingField??"";if($.field===ne||$.field===te){const he=g?.byField.get(ne),me=he?.sortComparator;return{value:F.groupingValue,type:he?.type,comparator:me,params:me?{id:T,field:ne,row:Z.inline,value:F.groupingValue}:void 0}}return F.aggregatedValues&&Object.prototype.hasOwnProperty.call(F.aggregatedValues,$.field)?{value:F.aggregatedValues[$.field],type:g?.byField.get($.field)?.type}:{value:void 0}}const G=V.get(T),Y=g?.byField.get($.field),j=G?Me(G,$.field,Y):void 0,q=Y?.sortComparator;return{value:j,type:Y?.type,comparator:q,params:q&&G?{id:T,field:$.field,row:G,value:j}:void 0}},ue=[],ee=new Set,D=T=>{const $=J.length>0?Ti(T,J,se):T;for(const F of $){if(ee.has(F))continue;ee.add(F);const Z=v.get(F);if(!Z){const ne=V.get(F);ne&&ue.push(ne);continue}const G=k.get(F),Y=H.has(F),j=oe.has(F)?oe.get(F)??null:"inline",q=j==="inline"||j==="footer"&&!Y;ue.push(q?Z.inline:Z.bare),(Y||U)&&G?.children&&(D(G.children),Y&&!U&&j==="footer"&&Z.footer&&ue.push(Z.footer))}};return D(I),ue},[C,le,c,k,v,V,g,H,oe,I]),K=s.useCallback(X=>k.get(X),[k]),de=s.useMemo(()=>{const X=new Map;return k.forEach((te,U)=>{const J=v.get(U);if(!J){X.set(U,{hasChildren:!1,treeDepth:te.depth,isGroupRow:!1});return}const se={hasChildren:!0,treeDepth:te.depth,groupingField:te.groupingField,groupingValue:te.groupingValue,groupLabel:te.label,descendantCount:te.descendantCount,isGroupRow:!0,isExpanded:H.has(U)};X.set(U,se),J.footer&&oe.get(U)==="footer"&&X.set(J.footer.id,{...se,hasChildren:!1,treeDepth:te.depth+1,isExpanded:void 0,isGroupFooter:!0})}),X},[k,v,H,oe]);return s.useMemo(()=>({treeNodes:k,groupingRows:B,toggleExpansion:z,isGroupExpanded:W,getVisibleRows:ce,getNode:K,rowMetaMap:de,aggregationPositions:oe,rootAggregationPosition:fe}),[k,B,z,W,ce,K,de,oe,fe])}const Hu=new Map;function Bu(e){const{rows:t,getRowId:n,getTreeDataPath:o,isTreeDataRequested:r,isTreeData:i,columns:l,rowGroupingModel:a,isRowGrouping:c,aggregationModel:u,defaultGroupingExpansionDepth:g,filterModel:h,sortModel:x,getAggregationPosition:y,columnLookup:p,filterMode:f,sortingMode:m}=e,b=Iu({rows:t,getRowId:n,getTreeDataPath:o,treeData:r,defaultGroupingExpansionDepth:g,filterModel:h,sortModel:x,columnLookup:p,filterMode:f,sortingMode:m}),w=Gu({rows:t,getRowId:n,columns:l,rowGroupingModel:a,aggregationModel:u,defaultGroupingExpansionDepth:g,filterModel:h,sortModel:x,getAggregationPosition:y,columnLookup:p,filterMode:f,sortingMode:m}),C=i?b:c?w:null,E=s.useMemo(()=>i?b.rowMetaMap:c?w.rowMetaMap:Hu,[i,b.rowMetaMap,c,w.rowMetaMap]);return{treeDataHandlers:b,rowGroupingHandlers:w,activeHierarchyHandlers:C,rowMetaMap:E}}function Ve(e){try{return{ok:!0,value:e()}}catch(t){return{ok:!1,error:t}}}class Yl extends Error{}function vt(e,t){return e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Object.is(e,t)}function Jl(e){return typeof e=="object"&&e!==null&&typeof e.then=="function"}function Zl(e,t){t?t(e):process.env.NODE_ENV!=="production"&&e instanceof Yl&&console.error(e.message)}function Ql(e,t){return new Yl(`[OpenGridX] processRowUpdate must return the updated row object (or a Promise of it); it returned ${e===null?"null":typeof e}. ${t}`)}function es(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})}const Jt=Promise.resolve();function Wu(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),a=s.useRef(!1),c=s.useRef(e);s.useLayoutEffect(()=>{c.current=e}),s.useEffect(()=>(a.current=!0,()=>{a.current=!1}),[]);const u=s.useCallback(f=>{o.current=f,n(f)},[]),g=s.useRef(null),h=s.useCallback((f,m)=>{const b=i.current.get(f);if(b)return vt(b.value,m.value)?b.promise:b.promise.then(()=>{const H=o.current;if(!(r.current!==f||!H||vt(H.value,b.value)))return g.current?.(f,H)});const w=()=>r.current===f&&o.current!==null;if(vt(m.value,m.originalValue))return w()&&u(null),Jt;const{rows:C,getRowId:E,columns:S,processRowUpdate:N}=c.current,M=C.find(H=>E(H)===m.id);if(!M)return w()&&u(null),Jt;const _=H=>Zl(H,c.current.onProcessRowUpdateError),O=S?.find(H=>H.field===m.field),L=H=>{if(typeof H!="object"||H===null){_(Ql(H,"The edit was not saved and the editor stays open."));return}c.current.onRowChange?.(H,m.id);const{onCommitted:z}=c.current;if(z){const re=Me(M,m.field,O),oe=Me(H,m.field,O);vt(re,oe)||z([{id:m.id,field:m.field,before:re,after:oe}])}const W=o.current;r.current!==f||!W||(vt(W.value,m.value)?u(null):u({...W,originalValue:m.value}))};let A,k;const I=new Promise((H,z)=>{A=H,k=z}),P={value:m.value,promise:I};i.current.set(f,P);const v=()=>{i.current.get(f)===P&&i.current.delete(f)},B=Ve(()=>{const H=es(M,m,O,l.current);return N?N(H,M):H});if(!B.ok)return v(),_(B.error),A(),I;const V=B.value,Q=H=>{v();try{L(H),A()}catch(z){k(z)}};return Jl(V)?Promise.resolve(V).then(Q,H=>{v(),_(H),A()}):Q(V),I},[u]);s.useLayoutEffect(()=>{g.current=h},[h]);const x=s.useCallback(f=>{const m=o.current;if(m){if(m.id===f.id&&m.field===f.field)return;h(r.current,m)}r.current+=1,u({id:f.id,field:f.field,value:f.value,originalValue:f.value})},[h,u]),y=s.useCallback(f=>{const m=o.current;return!m||!a.current||f?.id!==void 0&&f.id!==m.id||f?.field!==void 0&&f.field!==m.field?Jt:f?.cancel?(u(null),Jt):h(r.current,m)},[h,u]),p=s.useCallback(f=>{const m=o.current;!m||m.id!==f.id||m.field!==f.field||u({...m,value:f.value})},[u]);return s.useMemo(()=>({editingCell:t,startCellEdit:x,stopCellEdit:y,setEditCellValue:p}),[t,x,y,p])}function Vu(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(c=>{const u=n.current.get(c);return u===void 0?t.current.rowsLookup.get(c):u},[]),i=s.useCallback(c=>{c.size!==0&&(c.forEach((u,g)=>{n.current.set(g,u)}),t.current.replaceRows(c))},[]),l=s.useCallback((c,u)=>{i(new Map([[c,u]]))},[i]),a=s.useCallback((c,u)=>{const{columns:g,processRowUpdate:h}=t.current,x=S=>Zl(S,t.current.onProcessRowUpdateError),y=new Map,p=new Map;g.forEach((S,N)=>{y.set(S.field,N),p.set(S.field,S)});const f=[],m=new Map;for(const S of c){const N=r(S.id);if(N===void 0){f.push({id:S.id,field:S.field,reason:"missing"});continue}const M=p.get(S.field);if(S.expect&&!vt(Me(N,S.field,M),S.expect.value)){f.push({id:S.id,field:S.field,reason:"changed"});continue}let _=m.get(S.id);_||(_={id:S.id,row:N,cells:[]},m.set(S.id,_));const O=y.get(S.field)??Number.MAX_SAFE_INTEGER,L=_.cells.findIndex(k=>k.field===S.field),A={field:S.field,value:S.value,colDef:M,order:O};L===-1?_.cells.push(A):_.cells[L]=A}const b=[],w=[],C=o.current;m.forEach(S=>{const{id:N,row:M}=S,_=S.cells.filter(A=>!vt(Me(M,A.field,A.colDef),A.value)).sort((A,k)=>A.order-k.order);if(S.cells=_,_.length===0)return;const O=Ve(()=>{let A=M;for(const k of _)A=es(A,k,k.colDef,C);return h?h(A,M):A});if(!O.ok){b.push({id:N,ok:!1,error:O.error});return}const L=O.value;Jl(L)?w.push(Promise.resolve(L).then(A=>({id:N,ok:!0,processed:A}),A=>({id:N,ok:!1,error:A}))):b.push({id:N,ok:!0,processed:L})});const E=S=>{const N=new Map;S.forEach(A=>{N.set(A.id,A)});const M=[],_=[],O=[],L=new Map;return m.forEach(A=>{const k=N.get(A.id);if(!k)return;if(!k.ok){_.push({id:A.id,error:k.error}),x(k.error);return}const I=k.processed;if(typeof I!="object"||I===null){const v=Ql(I,"The row was not saved.");_.push({id:A.id,error:v}),x(v);return}const P=I;L.set(A.id,P),M.push(A.id);for(const v of A.cells){const B=Me(A.row,v.field,v.colDef),V=Me(P,v.field,v.colDef);vt(B,V)||O.push({id:A.id,field:v.field,before:B,after:V})}}),i(L),O.length>0&&u!=="undo"&&u!=="redo"&&t.current.onCommitted?.(O,u),{result:{updated:M,failed:_,skipped:f},committed:O}};return w.length===0?Promise.resolve(E(b)):Promise.all(w).then(S=>E([...b,...S]))},[r,i]);return s.useMemo(()=>({applyEdits:a,getRow:r,storeRow:l}),[a,r,l])}const ut={ok:!1},Ge=e=>({ok:!0,value:e});function zu(e){const t=[];if(e==="")return t;let n=[],o="",r=0;const i=e.length;let l=!0;for(;r<i;){const a=e[r];if(l&&a==='"'){let c=r+1,u="",g=!1;for(;c<i;){const h=e[c];if(h==='"'){if(e[c+1]==='"'){u+='"',c+=2;continue}g=!0,c+=1;break}u+=h,c+=1}if(!g){o+=a,r+=1,l=!1;continue}o+=u,r=c,l=!1;continue}l=!1,a===" "?(n.push(o),o="",l=!0,r+=1):a===`
|
|
3
|
+
`).forEach(z=>console.warn(z))},[C]);const E=r&&!o;s.useEffect(()=>{process.env.NODE_ENV==="production"||!E||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.")},[E]);const S=s.useMemo(()=>g==="server"?null:Pn(l,u),[g,l,u]),N=s.useMemo(()=>od(y,S),[y,S]),M=`${r}|${i}`,[_,F]=s.useState(()=>({configKey:M,overrides:new Map})),P=_.configKey===M?_.overrides:Ui,L=s.useCallback(z=>((z?.children?.length??0)>0||(z?.serverChildrenCount??0)>0)&&(i===-1||(z?.depth??0)<i),[i]),k=s.useMemo(()=>{const z=new Set;return x&&p.forEach((B,re)=>{(P.get(re)??L(B))&&z.add(re)}),z},[x,p,P,L]),I=s.useCallback(z=>{const B=!k.has(z);if(F(re=>{const oe=re.configKey===M?re.overrides:Ui,ue=new Map(oe);return ue.set(z,B),{configKey:M,overrides:ue}}),B&&c){const re=p.get(z);re&&c(re)}},[k,M,p,c]),A=m!=="server"&&!!(a&&a.length>0),v=s.useCallback(z=>{if(!x)return null;const B=z?.labelField,re=z?.expandAll??!1,{visible:oe,visibleChildren:ue}=N,se=A&&a?a:[],ce=(te,q)=>{if(b.has(te))return{value:q.field===B?p.get(te)?.label:void 0};const Q=w.get(te),ae=u?.byField.get(q.field),fe=Q?Me(Q,q.field,ae):void 0,ee=ae?.sortComparator;return{value:fe,type:ae?.type,comparator:ee,params:ee&&Q?{id:te,field:q.field,row:Q,value:fe}:void 0}},R=[],de=new Set,j=te=>{const q=te.filter(ae=>oe.has(ae)),Q=se.length>0?oi(q,se,ce):q;for(const ae of Q){if(de.has(ae))continue;const fe=w.get(ae);if(!fe)continue;de.add(ae),R.push(fe);const ee=ue.get(ae);ee&&ee.length>0&&(re||k.has(ae))&&j(ee)}};return j(f),R},[x,N,A,a,b,p,w,u,f,k]),W=s.useCallback(z=>k.has(z),[k]),V=s.useCallback(z=>p.get(z),[p]),Z=s.useCallback(z=>{const B=[];let re=z;for(;re!==null;){const oe=p.get(re);if(!oe)break;B.unshift(oe.groupingKey),re=oe.parentId}return B},[p]),H=s.useMemo(()=>{const z=new Map,{visibleChildren:B,descendantCounts:re}=N;return p.forEach((oe,ue)=>{const se=(oe.children?.length??0)===0&&(oe.serverChildrenCount??0)>0,ce=b.has(ue),R={hasChildren:(B.get(ue)?.length??0)>0||se,treeDepth:oe.depth,descendantCount:se?void 0:re.get(ue)??0,isGroupRow:ce,isExpanded:k.has(ue)};ce&&(R.groupLabel=oe.label),z.set(ue,R)}),z},[p,b,N,k]);return s.useMemo(()=>({treeNodes:p,groupingRows:h,toggleExpansion:I,isGroupExpanded:W,getVisibleRows:v,getNode:V,getNodePath:Z,rowMetaMap:H}),[p,h,I,W,v,V,Z,H])}const Yi=e=>e===null?"footer":"inline";function Ji(e,t){return co(()=>e(t),Yi(t),"getAggregationPosition","getAggregationPosition threw; the default position is used")}function id(e,t,n){const o=`${t}: ${String(n)}`,r=e?.groupingValueFormatter;return r?co(()=>r({field:t,value:n}),o,`groupingValueFormatter:${t}`,`groupingValueFormatter for column "${t}" threw; the group is labelled "${t}: value"`):o}const ld=[],sd={},Zi=new Map,Ze="";function ad(e){if(typeof e=="string")return e;if(e===null)return`${Ze}null`;if(e===void 0)return`${Ze}undefined`;if(e instanceof Date)return`${Ze}date:${e.getTime()}`;if(typeof e=="object")try{return`${Ze}object:${JSON.stringify(e)}`}catch{return`${Ze}object:${String(e)}`}return`${Ze}${typeof e}:${String(e)}`}const cd=(e,t,n)=>`auto-group-${e}-${t}-${n??"root"}`,dd=e=>`${e}${Ze}footer`,ud=e=>e==="footer"?"f":e===null?"n":"i",fd=e=>e==="f"?"footer":e==="n"?null:"inline";function gd(e){const{rows:t,getRowId:n,columns:o,rowGroupingModel:r=ld,aggregationModel:i=sd,defaultGroupingExpansionDepth:l=0,filterModel:a,sortModel:c,getAggregationPosition:u=Yi,columnLookup:g,filterMode:m="client",sortingMode:x="client"}=e,y=r.join(Ze),p=s.useMemo(()=>y===""?[]:y.split(Ze),[y]),f=JSON.stringify(Object.entries(i)),h=s.useMemo(()=>Object.fromEntries(JSON.parse(f)),[f]),b=Object.keys(h).length>0,w=s.useMemo(()=>{const j=new Map;return(o??[]).forEach(te=>j.set(te.field,te)),j},[o]),C=p.length>0,E=s.useMemo(()=>p.filter(j=>w.get(j)?.groupable!==!1),[p,w]),N=`${E.join(Ze)}|${l}`,[M,_]=s.useState(()=>({configKey:N,overrides:new Map})),F=M.configKey===N?M.overrides:Zi,P=s.useMemo(()=>{if(!C||m==="server")return null;const j=Pn(a,g);return j?new Set(t.filter(te=>j(te))):null},[C,t,m,a,g]),L=s.useMemo(()=>{const j=new Map,te=[],q=[],Q=new Map,ae=new Map,fe=new Map;if(!C)return{treeNodes:j,rootIds:te,groupIds:q,groupRowVariants:Q,groupingRows:ae,rowLookup:fe};const ee=(D,T,$)=>{if(T>=E.length)return(P?D.filter(X=>P.has(X)):D).map(X=>{const ne=n(X);return fe.set(ne,X),j.set(ne,{id:ne,parentId:$,depth:T,groupingKey:"",isExpanded:!1}),ne});const O=E[T],J=w.get(O),G=new Map;for(const U of D){const X=Me(U,O,J),ne=ad(X);let he=G.get(ne);he||(he={value:X,rows:[]},G.set(ne,he)),he.rows.push(U)}const Y=[];return G.forEach((U,X)=>{const ne=P?U.rows.filter(xe=>P.has(xe)):U.rows;if(ne.length===0)return;const he=cd(O,X,$);Y.push(he),q.push(he);const me=b?In(ne,h,w,"useRowGrouping"):{},K={[O]:U.value,...me,id:he},ge={[O]:U.value,id:he},we=b?{...me,id:dd(he)}:null;Q.set(he,{inline:K,bare:ge,footer:we}),ae.set(he,K),we&&ae.set(we.id,we);const ie={id:he,parentId:$,depth:T,groupingKey:String(U.value),groupingField:O,groupingValue:U.value,aggregatedValues:me,isExpanded:!1,children:[],label:id(J,O,U.value),descendantCount:ne.length};j.set(he,ie),ie.children=ee(U.rows,T+1,he)}),Y};return te.push(...ee(t,0,null)),{treeNodes:j,rootIds:te,groupIds:q,groupRowVariants:Q,groupingRows:ae,rowLookup:fe}},[C,t,P,E,b,h,n,w]),{treeNodes:k,rootIds:I,groupIds:A,groupRowVariants:v,groupingRows:W,rowLookup:V}=L,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 te of A){const q=k.get(te);!q?.children||q.children.length===0||(F.get(te)??Z(q))&&j.add(te)}return j},[A,k,F,Z]),z=s.useCallback(j=>{_(te=>{const q=te.configKey===N?te.overrides:Zi,Q=q.get(j)??Z(k.get(j)),ae=new Map(q);return ae.set(j,!Q),{configKey:N,overrides:ae}})},[N,k,Z]),B=s.useCallback(j=>H.has(j),[H]),re=b?A.map(j=>{const te=k.get(j);return te?ud(Ji(u,{...te,isExpanded:H.has(j)})):"i"}).join(""):"",oe=s.useMemo(()=>{const j=new Map;return A.forEach((te,q)=>j.set(te,fd(re[q]))),j},[A,re]),ue=b?Ji(u,null):"footer",se=x!=="server"&&!!(c&&c.length>0),ce=s.useCallback(j=>{if(!C)return null;const te=j?.labelField,q=j?.expandAll??!1,Q=se&&c?c:[],ae=(T,$)=>{const O=k.get(T),J=v.get(T);if(O&&J){const ne=O.groupingField??"";if($.field===ne||$.field===te){const he=g?.byField.get(ne),me=he?.sortComparator;return{value:O.groupingValue,type:he?.type,comparator:me,params:me?{id:T,field:ne,row:J.inline,value:O.groupingValue}:void 0}}return O.aggregatedValues&&Object.prototype.hasOwnProperty.call(O.aggregatedValues,$.field)?{value:O.aggregatedValues[$.field],type:g?.byField.get($.field)?.type}:{value:void 0}}const G=V.get(T),Y=g?.byField.get($.field),U=G?Me(G,$.field,Y):void 0,X=Y?.sortComparator;return{value:U,type:Y?.type,comparator:X,params:X&&G?{id:T,field:$.field,row:G,value:U}:void 0}},fe=[],ee=new Set,D=T=>{const $=Q.length>0?oi(T,Q,ae):T;for(const O of $){if(ee.has(O))continue;ee.add(O);const J=v.get(O);if(!J){const ne=V.get(O);ne&&fe.push(ne);continue}const G=k.get(O),Y=H.has(O),U=oe.has(O)?oe.get(O)??null:"inline",X=U==="inline"||U==="footer"&&!Y;fe.push(X?J.inline:J.bare),(Y||q)&&G?.children&&(D(G.children),Y&&!q&&U==="footer"&&J.footer&&fe.push(J.footer))}};return D(I),fe},[C,se,c,k,v,V,g,H,oe,I]),R=s.useCallback(j=>k.get(j),[k]),de=s.useMemo(()=>{const j=new Map;return k.forEach((te,q)=>{const Q=v.get(q);if(!Q){j.set(q,{hasChildren:!1,treeDepth:te.depth,isGroupRow:!1});return}const ae={hasChildren:!0,treeDepth:te.depth,groupingField:te.groupingField,groupingValue:te.groupingValue,groupLabel:te.label,descendantCount:te.descendantCount,isGroupRow:!0,isExpanded:H.has(q)};j.set(q,ae),Q.footer&&oe.get(q)==="footer"&&j.set(Q.footer.id,{...ae,hasChildren:!1,treeDepth:te.depth+1,isExpanded:void 0,isGroupFooter:!0})}),j},[k,v,H,oe]);return s.useMemo(()=>({treeNodes:k,groupingRows:W,toggleExpansion:z,isGroupExpanded:B,getVisibleRows:ce,getNode:R,rowMetaMap:de,aggregationPositions:oe,rootAggregationPosition:ue}),[k,W,z,B,ce,R,de,oe,ue])}const pd=new Map;function hd(e){const{rows:t,getRowId:n,getTreeDataPath:o,isTreeDataRequested:r,isTreeData:i,columns:l,rowGroupingModel:a,isRowGrouping:c,aggregationModel:u,defaultGroupingExpansionDepth:g,filterModel:m,sortModel:x,getAggregationPosition:y,columnLookup:p,filterMode:f,sortingMode:h}=e,b=rd({rows:t,getRowId:n,getTreeDataPath:o,treeData:r,defaultGroupingExpansionDepth:g,filterModel:m,sortModel:x,columnLookup:p,filterMode:f,sortingMode:h}),w=gd({rows:t,getRowId:n,columns:l,rowGroupingModel:a,aggregationModel:u,defaultGroupingExpansionDepth:g,filterModel:m,sortModel:x,getAggregationPosition:y,columnLookup:p,filterMode:f,sortingMode:h}),C=i?b:c?w:null,E=s.useMemo(()=>i?b.rowMetaMap:c?w.rowMetaMap:pd,[i,b.rowMetaMap,c,w.rowMetaMap]);return{treeDataHandlers:b,rowGroupingHandlers:w,activeHierarchyHandlers:C,rowMetaMap:E}}function md(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 wd(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 a=n,c=o,u=!0;for(;u;){u=!1;for(const{row:b,id:w}of l){const C=t.getUnpinnedColSpanRanges(w??b.id);if(C)for(let E=0;E<C.length;E+=2){const S=C[E],N=C[E+1];N<a||S>c||(S<a&&(a=S,u=!0),N>c&&(c=N,u=!0))}}}if(a===n&&c===o)return r;const{leftPinnedCols:g,unpinnedColsWithWidth:m,rightPinnedCols:x,unpinnedAccWidths:y,unpinnedTotalWidth:p}=i,f=a>0?y[a-1]:0,h=p-y[c];return[...g,...f>0?[{field:"__spacer_left__",width:f,isSpacer:!0}]:[],...m.slice(a,c+1),...h>0?[{field:"__spacer_right__",width:h,isSpacer:!0}]:[],...x]},[t,n,o,r,i,l])}function bd(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 Qi(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 el(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 Vo(e,t,n){if(!e||e.length===0)return!0;const o=el(e),r=o.get(t),i=o.get(n);return(r?.[r.length-1]??null)===(i?.[i.length-1]??null)}function xd(e,t,n){const o=[];let r=0,i=null,l=null;for(const a of e){const c=a.isSpacer?null:t.get(a.field)?.[n]??null;(i===null||l!==c||i.pinned!==a.pinned)&&(i={key:`${c?c.groupId:"filler"}-${n}-${a.field}`,isGroup:c!==null,label:c?.headerName??"",headerClassName:c?.headerClassName,width:0,flexGrow:0,fields:[],firstDataIndex:r,pinned:a.pinned},l=c,o.push(i)),i.width+=a.width,i.flexGrow+=a.flex??0,a.isSpacer||(i.fields.push(a.field),r++)}return o}function yd(e){const{columnGroupingModel:t,headerFilterRow:n=!1,pinnedTopCount:o,pinnedBottomCount:r,pagination:i,paginationMode:l,paginationModel:a,paginationRowCount:c,paginatedUnpinnedRowCount:u,sortedUnpinnedRowCount:g}=e,{page:m,pageSize:x}=a;return s.useMemo(()=>bd({headerRowCount:1+Qi(t)+(n?1:0),pinnedTopCount:o,pinnedBottomCount:r,pageRowCount:i?u:g,totalCenterRowCount:i&&l==="server"?Math.max(c,u):g,pageOffset:i?m*x:0}),[t,n,o,r,i,u,g,l,c,m,x])}const Cd=e=>e.id;function vd(e){const{renderContext:t,pinnedTopRows:n,pinnedBottomRows:o,paginatedUnpinnedRows:r,sortedUnpinnedRows:i,pagination:l,getRowId:a=Cd}=e;return s.useMemo(()=>{const{firstRowIndex:c,lastRowIndex:u}=t,g=l?r:i,m=n.length,x=n.map((C,E)=>({row:C,id:a(C),rowIndex:E,pinned:"top"})),y=o.map((C,E)=>({row:C,id:a(C),rowIndex:m+g.length+E,pinned:"bottom"})),p=Math.max(0,c),f=Math.min(g.length,u+1),h=g.slice(p,f).map((C,E)=>({row:C,id:a(C),rowIndex:m+p+E})),b=[...x,...h,...y],w=new Set;return b.filter(C=>w.has(C.id)?!1:(w.add(C.id),!0))},[t,n,o,r,i,l,a])}function Sd(e){const{aria:t,spanning:n,virtualization:o,layout:r,pinnedTopRows:i,pinnedBottomRows:l,paginatedUnpinnedRows:a,sortedUnpinnedRows:c,pagination:u,getRowId:g}=e,m=yd(t),x=md({spanning:n,renderContext:o.renderContext,offsetTop:o.offsetTop,cumulativeHeights:r.cumulativeHeights}),y=vd({renderContext:x.renderContext,pinnedTopRows:i,pinnedBottomRows:l,paginatedUnpinnedRows:a,sortedUnpinnedRows:c,pagination:u,getRowId:g}),p=wd({spanning:n,firstColumnIndex:o.renderContext.firstColumnIndex,lastColumnIndex:o.renderContext.lastColumnIndex,virtualColumns:o.virtualColumns,layout:r,rows:y});return{ariaRows:m,spanRowWindow:x,visibleRows:y,renderColumns:p}}const _d=new Set(["__group__","__check__","__actions__"]);function Mt(e){return e.filter(t=>t.exportable!==!1&&!t.isSpacer&&!Je(t.field)&&!_d.has(t.field))}function dt(e){return!!e&&e.length>0}function tl(e,t,n=o=>o.id){const o=new Set(t);return e.filter(r=>o.has(n(r)))}function sn(e,t,n){return dt(t)?tl(e,t,n):e}function an(e,t){return!!e&&e.length>0&&!dt(t)}function Wt(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 cn(e,t){const n=e[t.field];return t.valueGetter?t.valueGetter({row:e,field:t.field,value:n}):n}function dn(e,t,n){if(!t.valueFormatter)return fo(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 zo(e,t,n,o){return n==null?"":Ln(n,t??"",e,o)}function Vt(e,t){return t?`${e}: ${t}`:e}function nl(e,t){const n={};return t.forEach(o=>{Object.prototype.hasOwnProperty.call(e,o.field)&&(n[o.field]=e[o.field])}),n}const kd=/^[=+\-@\t\r]/,Ed=/^[-+]?(?=[\d.,\s]*\d)[\d.,\s]*%?$/;function zn(e,t=!1){return t||!kd.test(e)||Ed.test(e)?e:`'${e}`}function ut(e){return typeof e=="number"||typeof e=="bigint"||typeof e=="boolean"||e instanceof Date}function Te(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Md(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 Nd=/[\\/?*:[\]]/g,ol=31;function Ro(e,t=new Set){let n=Md(String(e??"").replace(Nd,"-").trim()).trim();n||(n="Sheet"),n=n.slice(0,ol).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,ol-l.length).trim()}${l}`}return t.add(r.toLowerCase()),r}const Id=new Set([Ye,_t,St]),Ld=/[\t\n\r"]/;function Ko(e){return Ld.test(e)?`"${e.replace(/"/g,'""')}"`:e}function Pd(e){return Mt(e).filter(t=>!Id.has(t.field))}function Ad(e,t){const n=t.map(r=>Ko(r.headerName||r.field)).join(" "),o=e.map(r=>t.map(i=>Ko(dn(r,i,Me(r,i.field,i)))).join(" "));return[n,...o].join(`
|
|
4
|
+
`)}function Td(e,t){const n=Me(e,t.field,t);try{return dn(e,t,n)}catch{return n==null?"":String(n)}}function Fd(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 a=0;a<t.length;a++){const c=t[a];l[a]=n?.(i,c)?"":Ko(Td(i,c))}o[r]=l.join(" ")}return o.join(`
|
|
5
|
+
`)}function rl(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 Uo(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(rl(e))return;throw n}if(!rl(e))throw new Error("Clipboard API not available and fallback failed.")}function Od(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 Dd(e){const t=s.useRef(e);s.useLayoutEffect(()=>{t.current=e});const n=s.useCallback(async()=>{const{getSelectedRowIds:r,getColumns:i,getRows:l,getRowId:a}=t.current,c=new Set(r());if(c.size===0)return;const u=l().filter(m=>c.has(a(m)));if(u.length===0)return;const g=Ad(u,Pd(i()));await Uo(g)},[]),o=!!e.disableKeyboardShortcut;return s.useEffect(()=>{if(o)return;const r=i=>{if(i.defaultPrevented||!Od(i))return;const l=document.activeElement,a=l?.tagName.toLowerCase(),c=l?.type;if(a==="input"&&c!=="checkbox"&&c!=="radio"||a==="textarea"||a==="select"||l?.isContentEditable)return;const{getRootElement:u}=t.current;if(u){const y=u();if(!y||!l||!y.contains(l))return}const g=window.getSelection();if(g&&!g.isCollapsed&&g.toString()!=="")return;const{getShortcutText:m}=t.current;(m?()=>{const y=m();return y===null?Promise.resolve():Uo(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 $d(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:a,focusedCell:c,setFocusedCell:u,containerRef:g}=e,m=l.range?.anchor??null,x=l.resolved?.anchorRow;s.useLayoutEffect(()=>{l.reportFocus(c);const y=!ct(o.current,m),p=!Po(r.current,c);if(o.current=m,r.current=c,!!l.enabled){if(l.range&&!l.resolved){i.current!==a&&(i.current=a,l.setModel([],"dataChange"));return}if(y&&m){(!c||c.id!==m.id||c.field!==m.field)&&u({id:m.id,field:m.field,rowIndex:x});return}if(p&&c&&c.id!==null&&Ke(c.field)&&!ct(m,{id:c.id,field:c.field})){const f={id:c.id,field:c.field},h=g.current?.classList.contains("ogx--kb")??!1;l.setModel([{anchor:f,head:f}],h?"keyboard":"pointer")}}},[l,a,m,x,c,u,g]),s.useLayoutEffect(()=>{const y=t.current,p=()=>n.current;y.getCellSelectionModel=()=>{const{selection:f,getPendingModel:h,model:b}=p();return f.enabled?h()??b:[]},y.setCellSelectionModel=f=>{p().selection.setModel(f,"api")},y.selectCellRange=(f,h)=>{p().selection.setModel([{anchor:f,head:h}],"api")},y.clearCellSelection=()=>{p().selection.setModel([],"clear")},y.getSelectedCells=()=>p().selection.getSelectedCells(),y.copySelectedCells=async()=>{const{selection:f}=p();if(!f.enabled)return;const h=f.getCopyText();h!==null&&await Uo(h)}},[t])}function We(e){try{return{ok:!0,value:e()}}catch(t){return{ok:!1,error:t}}}const ot={ok:!1},Oe=e=>({ok:!0,value:e});function Gd(e){const t=[];if(e==="")return t;let n=[],o="",r=0;const i=e.length;let l=!0;for(;r<i;){const a=e[r];if(l&&a==='"'){let c=r+1,u="",g=!1;for(;c<i;){const m=e[c];if(m==='"'){if(e[c+1]==='"'){u+='"',c+=2;continue}g=!0,c+=1;break}u+=m,c+=1}if(!g){o+=a,r+=1,l=!1;continue}o+=u,r=c,l=!1;continue}l=!1,a===" "?(n.push(o),o="",l=!0,r+=1):a===`
|
|
4
6
|
`||a==="\r"?(n.push(o),t.push(n),n=[],o="",l=!0,r+=a==="\r"&&e[r+1]===`
|
|
5
|
-
`?2:1):(o+=a,r+=1)}return(!l||n.length>0||o!=="")&&(n.push(o),t.push(n)),t}const Ku=/^\d+(?:\.\d*)?(?:e[+-]?\d+)?$/i,ju=/^\.\d+(?:e[+-]?\d+)?$/i,Uu=/^\d{1,3}(?:,\d{3})+(?:\.\d*)?$/,Ru=/[\p{Sc}\s]/gu;function qu(e){let t=e.replace(Ru,"");if(t==="")return e.trim()===""?Ge(null):ut;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)),Uu.test(t))t=t.split(",").join("");else if(!Ku.test(t)&&!ju.test(t))return ut;let r=Number(t);return Number.isFinite(r)?(o&&(r/=100),n&&(r=-r),Ge(r)):ut}const Xu=/^(\d{4}-\d{2}-\d{2})/,ts=e=>String(e).padStart(2,"0"),Yu=e=>`${e.getFullYear()}-${ts(e.getMonth()+1)}-${ts(e.getDate())}`;function Ju(e,t){const n=e.trim();if(n==="")return Ge(null);const o=wn(n);if(!o)return ut;if(typeof t=="number")return Ge(o.getTime());if(typeof t=="string"){const r=Yu(o);return Ge(Xu.test(t)&&t.length>10?r+t.slice(10):r)}return Ge(o)}const Zu=new Set(["true","yes","1"]),Qu=new Set(["false","no","0"]);function ef(e,t){const n=e.trim().toLowerCase();return n===""?Ge(null):t?.trueLabel!==void 0&&n===t.trueLabel.trim().toLowerCase()?Ge(!0):t?.falseLabel!==void 0&&n===t.falseLabel.trim().toLowerCase()?Ge(!1):Zu.has(n)?Ge(!0):Qu.has(n)?Ge(!1):ut}function tf(e,t){const n=e.trim();if(n==="")return Ge(null);if(!t||t.length===0)return ut;const o=n.toLowerCase();for(const r of t){const i=typeof r=="object"?r.value:r;if(String(i).toLowerCase()===o)return Ge(i)}for(const r of t)if(typeof r=="object"&&r.label.toLowerCase()===o)return Ge(r.value);return ut}function nf(e,t,n){switch(t?.type){case"number":return qu(e);case"date":return Ju(e,n?.current);case"boolean":return ef(e,n?.booleanLabels);case"singleSelect":return tf(e,t.valueOptions);default:return Ge(e)}}function of(e,t,n,o){const{valueParser:r}=t;if(!r)return nf(e,t,o);let i;try{i=r(e,{row:n,field:t.field,colDef:t})}catch{return ut}return i===void 0?ut:Ge(i)}function yr(e,t,n){const o=e.map(t),r=new Map;o.forEach((c,u)=>{r.has(c)||r.set(c,u)});const i=n.filter(c=>Ye(c.field)),l=new Map;i.forEach((c,u)=>{l.set(c.field,u)});const a=n.filter(c=>Qe(c.field)).length;return{rows:e,rowIds:o,rowIndexById:r,columns:i,colIndexByField:l,dataColumnOffset:a}}function Cr(e,t,n,o,r){const i=e.rowIds[o],l=e.columns[r];if(!l||Xe(i,t.rowMetaMap))return!1;const a=t.getSpanOrigin?.(i,l.field);return a&&(a.rowId!==i||a.field!==l.field)?!1:zo({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 rf(e,t){let n=1/0,o=-1/0,r=1/0,i=-1/0;for(const l of t){const a=e.rowIndexById.get(l.id),c=e.colIndexByField.get(l.field);a===void 0||c===void 0||(a<n&&(n=a),a>o&&(o=a),c<r&&(r=c),c>i&&(i=c))}return n===1/0?null:{top:n,bottom:o,left:r,right:i}}function ns(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 lf(e){const t=e?.type;return t===void 0||t==="string"||t==="image"}const os=1e4,lo=()=>({updated:[],failed:[],skipped:[]});function sf(e){process.env.NODE_ENV!=="production"&&console.warn(`[OpenGridX] Pasting ${e} cells. Pastes above ${os} cells can be slow; consider importing the data instead.`)}function af(e){const{apiRef:t,containerRef:n,selection:o,disableClipboardPaste:r,disableRangeClear:i}=e,l=s.useRef(e);s.useLayoutEffect(()=>{l.current=e});const a=s.useCallback(()=>{const{allRenderableRows:p,getRowId:f,navigationColumns:m}=l.current;return yr(p,f,m)},[]),c=s.useCallback(()=>{const{selection:p}=l.current;return p.enabled?p.getCurrentRange().resolved:null},[]),u=s.useCallback(p=>{const f=c();if(f&&p.rowIds[f.top]!==void 0&&p.columns[f.left])return{id:p.rowIds[f.top],field:p.columns[f.left].field};const m=l.current.focusedCell;return m&&m.id!==null&&Ye(m.field)?{id:m.id,field:m.field}:null},[c]),g=s.useCallback(async(p,f,m)=>{const b=a(),w=f??u(b);let C=p;const{onBeforeClipboardPaste:E}=l.current;if(E){const le=Ve(()=>E({text:C,anchor:w}));if(!le.ok)return Tt("onBeforeClipboardPaste","onBeforeClipboardPaste threw; the paste was cancelled",le.error),lo();if(le.value===!1)return lo();typeof le.value=="string"&&(C=le.value)}if(!w)return lo();const S=zu(C),N=b.rowIndexById.get(w.id),M=b.colIndexByField.get(w.field);if(S.length===0||N===void 0||M===void 0)return lo();const _=b.rowIds.length-1,O=b.columns.length-1,L=f?null:c(),A=L&&Ot(L)>1?L:null,k=S.length===1&&S[0].length===1,I=S.reduce((le,ce)=>Math.max(le,ce.length),0);let P;k&&A?P=A:P={top:N,left:M,bottom:Math.min(N+S.length-1,_,A?A.bottom:_),right:Math.min(M+I-1,O,A?A.right:O)};const v=Ot(P);v>os&&sf(v);const{batchEdit:B,isCellEditable:V,rowMetaMap:Q,getSpanOrigin:H}=l.current,z={isCellEditable:V,rowMetaMap:Q,getSpanOrigin:H},W=[],re=[];for(let le=P.top;le<=P.bottom;le++){const ce=b.rowIds[le],K=B.getRow(ce)??b.rows[le],de=k?S[0]:S[le-P.top];for(let X=P.left;X<=P.right;X++){const te=k?S[0][0]:de?.[X-P.left];if(te===void 0)continue;const U=b.columns[X];if(!Cr(b,z,K,le,X)){re.push({id:ce,field:U.field,reason:"notEditable"});continue}const J=of(te,U,K,{current:Me(K,U.field,U)});if(!J.ok){re.push({id:ce,field:U.field,reason:"invalidValue"});continue}W.push({id:ce,field:U.field,value:J.value})}}if(l.current.selection.enabled){const{anchor:le,head:ce}=ns(b,P);l.current.selection.setModel([{anchor:le,head:ce}],m?"keyboard":"api")}const oe=await B.applyEdits(W,"paste"),fe={updated:oe.result.updated,failed:oe.result.failed,skipped:[...re,...oe.result.skipped]};return l.current.onClipboardPaste?.({...fe,text:C}),fe},[a,u,c]),h=s.useCallback(()=>{const p=c();if(!p||Ot(p)<=1)return!1;const f=a(),{batchEdit:m,isCellEditable:b,rowMetaMap:w,getSpanOrigin:C}=l.current,E={isCellEditable:b,rowMetaMap:w,getSpanOrigin:C},S=[];for(let N=p.top;N<=p.bottom;N++){const M=f.rowIds[N];if(M===void 0)continue;const _=m.getRow(M)??f.rows[N];for(let O=p.left;O<=p.right;O++){const L=f.columns[O];!L||!Cr(f,E,_,N,O)||S.push({id:M,field:L.field,value:lf(L)?"":null})}}return m.applyEdits(S,"clear"),!0},[c,a]),x=o.enabled&&!r,y=o.enabled&&!i;s.useEffect(()=>{const p=n.current;if(!p||!x&&!y)return;const f=N=>{const M=l.current.viewportRef.current;if(!M||N.defaultPrevented||l.current.isEditing)return!1;const _=Jn(N.target,M);return _==="grid"||_==="control"};let m=null;const b=()=>{if(!m)return;const{textarea:N,restore:M,timer:_}=m;m=null,window.clearTimeout(_);const O=document.activeElement===N;N.remove(),O&&M&&M.isConnected&&M.focus({preventScroll:!0})},w=()=>{b();const N=document.createElement("textarea");N.setAttribute("aria-hidden","true"),N.tabIndex=-1,N.className="ogx__paste-capture",N.style.cssText="position:fixed;top:0;left:-10000px;width:1px;height:1px;opacity:0;",p.appendChild(N);const M=document.activeElement instanceof HTMLElement?document.activeElement:null;m={textarea:N,restore:M,timer:window.setTimeout(b,250)},N.focus({preventScroll:!0})},C=N=>m!==null&&N.target===m.textarea,E=N=>{if(C(N)){const _=N.clipboardData?N.clipboardData.getData("text/plain"):"";N.preventDefault(),b(),_!==""&&g(_,void 0,!0);return}if(!x||!f(N)||!l.current.navigationColumns.some(_=>_.editable))return;const M=N.clipboardData?N.clipboardData.getData("text/plain"):"";M!==""&&(N.preventDefault(),g(M,void 0,!0))},S=N=>{if((N.ctrlKey||N.metaKey)&&!N.altKey&&!N.shiftKey&&(N.key==="v"||N.key==="V"||N.code==="KeyV")){x&&f(N)&&l.current.navigationColumns.some(M=>M.editable)&&w();return}!y||N.key!=="Delete"&&N.key!=="Backspace"||N.ctrlKey||N.metaKey||N.altKey||N.shiftKey||f(N)&&h()&&N.preventDefault()};return p.addEventListener("paste",E),p.addEventListener("keydown",S),()=>{b(),p.removeEventListener("paste",E),p.removeEventListener("keydown",S)}},[n,x,y,g,h]),s.useLayoutEffect(()=>{t.current.pasteText=(p,f)=>g(p,f,!1)},[t,g])}const cf=100;function df(){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 rs=()=>({updated:[],failed:[],skipped:[]});function uf(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 ff(e){const{apiRef:t,enabled:n,channel:o,containerRef:r}=e,i=s.useRef(e);s.useLayoutEffect(()=>{i.current=e});const l=s.useRef([]),a=s.useRef([]),c=s.useRef({canUndo:!1,canRedo:!1,size:0}),u=s.useRef(Promise.resolve()),g=s.useCallback(()=>{const b={canUndo:l.current.length>0,canRedo:a.current.length>0,size:l.current.length},w=c.current;w.canUndo===b.canUndo&&w.canRedo===b.canRedo&&w.size===b.size||(c.current=b,i.current.onHistoryChange?.(b))},[]),h=s.useCallback(b=>{if(!i.current.enabled||b.length===0)return;const w=l.current;w.push(b);const C=Math.max(1,i.current.limit);w.length>C&&w.splice(0,w.length-C),a.current=[],g()},[g]);s.useLayoutEffect(()=>(o.setListener(n?h:null),()=>o.setListener(null)),[o,n,h]);const x=s.useCallback(()=>{l.current=[],a.current=[],g()},[g]);s.useEffect(()=>{n||x()},[n,x]);const y=s.useCallback(b=>{const w=i.current,C=yr(w.allRenderableRows,w.getRowId,w.navigationColumns),E=rf(C,b);if(!E)return;const{anchor:S,head:N}=ns(C,E);w.selection.enabled?w.selection.setModel([{anchor:S,head:N}],"keyboard"):w.setFocusedCell({id:S.id,field:S.field,rowIndex:E.top});const M=w.viewportRef.current;M&&(Kn(M,E.top-w.pinnedTopRowCount,w.layout.cumulativeHeights,w.layout.pinnedBottomHeight,w.rowHeight),Vo(M,w.layout.unpinnedColsWithWidth.findIndex(_=>_.field===S.field),w.layout))},[]),p=s.useCallback(b=>{const w=async()=>{if(!i.current.enabled)return rs();const E=b==="undo"?l:a,S=b==="undo"?a:l,N=E.current.pop();if(!N)return rs();g();const M=N.map(L=>b==="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}}),_=await i.current.batchEdit.applyEdits(M,b);_.committed.length>0&&S.current.push(b==="undo"?_.committed.map(L=>({id:L.id,field:L.field,before:L.after,after:L.before})):_.committed);const O=new Set(_.result.failed.map(L=>L.id));if(O.size>0){const L=N.filter(A=>O.has(A.id));L.length>0&&E.current.push(L)}return g(),_.committed.length>0&&y(_.committed),_.result},C=u.current.then(w,w);return u.current=C,C},[g,y]),f=s.useCallback(()=>p("undo"),[p]),m=s.useCallback(()=>p("redo"),[p]);s.useEffect(()=>{const b=r.current;if(!b||!n)return;const w=C=>{if(C.defaultPrevented)return;const E=uf(C);if(!E)return;const S=i.current.viewportRef.current;if(!S||i.current.isEditing)return;const N=Jn(C.target,S);N!=="grid"&&N!=="control"||(C.preventDefault(),E==="undo"?f():m())};return b.addEventListener("keydown",w),()=>b.removeEventListener("keydown",w)},[r,n,f,m]),s.useLayoutEffect(()=>{const b=t.current;b.undo=f,b.redo=m,b.canUndo=()=>i.current.enabled&&l.current.length>0,b.canRedo=()=>i.current.enabled&&a.current.length>0,b.clearHistory=x},[t,f,m,x])}function gf(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 vr(e,t){return t===null?e:Number(e.toFixed(Math.min(t,20)))}function pf(e,t){let n=0;for(const l of e){const a=gf(l);n=a===null||n===null?null:Math.max(n,a)}const o=vr(e[1]-e[0],n);for(let l=2;l<e.length;l++)if(vr(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(vr(r+o*l,n));return i}const hf=864e5,is=e=>((e.getHours()*60+e.getMinutes())*60+e.getSeconds())*1e3+e.getMilliseconds(),mf=e=>Math.round(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())/hf),wf=e=>e.getFullYear()*12+e.getMonth(),bf=(e,t)=>new Date(e,t+1,0).getDate();function _r(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 xf(e,t){const n=e[e.length-1],o=e.every(l=>is(l)===is(n));if(o&&e.every(l=>l.getDate()===n.getDate())){const l=_r(e.map(wf));if(l!==null&&l!==0){const a=[];for(let c=1;c<=t;c++){const u=n.getMonth()+l*c,g=n.getFullYear()+Math.floor(u/12),h=(u%12+12)%12,x=new Date(n.getTime());x.setFullYear(g,h,Math.min(n.getDate(),bf(g,h))),a.push(x)}return a}}if(o){const l=_r(e.map(mf));if(l===null)return null;const a=[];for(let c=1;c<=t;c++){const u=new Date(n.getTime());u.setDate(n.getDate()+l*c),a.push(u)}return a}const r=_r(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 yf=e=>typeof e=="number"&&Number.isFinite(e),Cf=e=>e instanceof Date&&!Number.isNaN(e.getTime());function vf(e,t){return e.length<2?null:e.every(yf)?pf(e,t):e.every(Cf)?xf(e,t):null}const _f=e=>e instanceof Date?new Date(e.getTime()):e;function Sf(e,t,n){if(e.length===0||t<=0)return[];const o=n?vf(e,t):null;if(o)return o;const r=[];for(let i=0;i<t;i++)r.push(_f(e[i%e.length]));return r}function kf(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 Ef(e,t,n){const o=(c,u)=>{const g=[];if(c<=u)for(let h=c;h<=u;h++)g.push(h);else for(let h=c;h>=u;h--)g.push(h);return g},i=n==="down"||n==="up"?o(e.left,e.right):o(e.top,e.bottom);let l,a;switch(n){case"down":l=o(e.top,e.bottom),a=t.bottom>e.bottom?o(e.bottom+1,t.bottom):[];break;case"up":l=o(e.bottom,e.top),a=t.top<e.top?o(e.top-1,t.top):[];break;case"right":l=o(e.left,e.right),a=t.right>e.right?o(e.right+1,t.right):[];break;default:l=o(e.right,e.left),a=t.left<e.left?o(e.left-1,t.left):[]}return i.map(c=>({line:c,source:l,targets:a}))}function Mf(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 Nf(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 a=e.bottom;a>=Math.max(0,e.bottom-If);a--)if(t(a)===l.rowId)return{row:a,field:l.field};return null}const If=1e3,Lf="ogx__cell-fill-handle";function Af(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 Tf(e){const{containerRef:t,viewportRef:n,selection:o,disableFillHandle:r,isEditing:i,allRenderableRows:l,getRowId:a,navigationColumns:c,columnIndexMap:u,getSpanOrigin:g}=e,h=s.useRef(e);s.useLayoutEffect(()=>{h.current=e});const x=o.enabled&&!r,y=s.useMemo(()=>c.some(_=>_.editable),[c]),p=o.resolved,f=s.useMemo(()=>{if(!x||!y||!p)return null;const _=c.filter(k=>Ye(k.field)).map(k=>k.field),L=Nf(p,k=>{const I=l[k];return I===void 0?void 0:a(I)},_,g);if(!L)return null;const A=u.get(L.field);return A===void 0?null:{row:L.row,col:A}},[x,y,p,l,a,c,u,g]),m=s.useRef(!0);s.useEffect(()=>(m.current=!0,()=>{m.current=!1}),[]);const b=s.useCallback(()=>{const _=h.current;return yr(_.allRenderableRows,_.getRowId,_.navigationColumns)},[]),w=s.useCallback((_,O,L,A,k)=>{const I=Mf(O,L,A),P=v=>({id:_.rowIds[v.row],field:_.columns[v.col].field});h.current.selection.setModel([{anchor:P(I.anchor),head:P(I.head)}],k)},[]),C=s.useCallback(async(_,O,L,A,k,I,P)=>{const{batchEdit:v,isCellEditable:B,rowMetaMap:V,getSpanOrigin:Q}=h.current,H={isCellEditable:B,rowMetaMap:V,getSpanOrigin:Q},z=A==="down"||A==="up",W=ce=>{const K=_.rowIds[ce];return K===void 0?void 0:v.getRow(K)??_.rows[ce]},re=[],oe=[];for(const ce of Ef(O,L,A)){if(ce.targets.length===0)continue;const K=te=>z?{r:te,c:ce.line}:{r:ce.line,c:te},de=[];for(const te of ce.source){const{r:U,c:J}=K(te),se=W(U),ue=_.columns[J];!se||!ue||Xe(_.rowIds[U],V)||de.push(Me(se,ue.field,ue))}if(de.length===0)continue;const X=Sf(de,ce.targets.length,!k);ce.targets.forEach((te,U)=>{const{r:J,c:se}=K(te),ue=W(J),ee=_.columns[se],D=_.rowIds[J];if(!ue||!ee||D===void 0)return;if(!Cr(_,H,ue,J,se)){oe.push({id:D,field:ee.field,reason:"notEditable"});return}let T=X[U];const $=ee.fillValue;if($){const F=Ve(()=>$.call(ee,{row:ue,id:D,field:ee.field,colDef:ee,direction:A,sourceValues:de.slice(),index:U,value:T,copy:k}));if(!F.ok){Tt(`fillValue:${ee.field}`,`fillValue of column "${ee.field}" threw; the cell was skipped`,F.error),oe.push({id:D,field:ee.field,reason:"invalidValue"});return}T=F.value}re.push({id:D,field:ee.field,value:T})})}w(_,L,A,I,P);const fe=await v.applyEdits(re,"fill"),le={updated:fe.result.updated,failed:fe.result.failed,skipped:[...oe,...fe.result.skipped],direction:A};return h.current.onFill?.(le),le},[w]),E=s.useRef(null),S=s.useCallback((_,O,L)=>{const A=E.current,k=h.current.viewportRef.current;if(!A||!k)return;const I=A.ctx,P=I.rowIndexById.get(_.id),v=I.colIndexByField.get(_.field);if(P===void 0||v===void 0)return;const B=O-A.x+k.scrollLeft-A.scrollLeft,V=L-A.y+k.scrollTop-A.scrollTop,Q=kf(A.source,{row:P,col:v},B,V);A.target=Q,Q?w(I,Q.rect,Q.direction,A.anchor,"pointer"):h.current.selection.setModel(A.sourceModel,"pointer")},[w]),N=s.useCallback(({cancelled:_,altKey:O})=>{const L=E.current;if(E.current=null,!L||!m.current)return;const A=L.ctx;if(_||!L.target){h.current.selection.setModel(L.sourceModel,"pointer");return}C(A,L.source,L.target.rect,L.target.direction,O,L.anchor,"pointer")},[C]),M=x&&y;return s.useEffect(()=>{const _=n.current;if(!_||!M)return;const O=L=>{if(L.button!==0||!(L.target instanceof Element))return;const A=L.target.closest(`.${Lf}`);if(!A||A.closest(".ogx__viewport")!==_||h.current.isEditing)return;const{selection:k}=h.current,{range:I,resolved:P}=k.getCurrentRange();if(!I||!P)return;const v=b(),B=v.rowIds[P.bottom],V=v.columns[P.right];if(B===void 0||!V)return;L.preventDefault();const Q=_.ownerDocument;_.contains(Q.activeElement)||_.focus({preventScroll:!0}),Ve(()=>_.setPointerCapture(L.pointerId)),E.current={source:{top:P.top,bottom:P.bottom,left:P.left,right:P.right},sourceModel:[I],anchor:{row:P.anchorRow,col:P.anchorCol},ctx:v,x:L.clientX,y:L.clientY,scrollLeft:_.scrollLeft,scrollTop:_.scrollTop,target:null},k.startTrackedDrag({start:{id:B,field:V.field},x:L.clientX,y:L.clientY,pointerId:L.pointerId,onTrack:S,onEnd:N})};return _.addEventListener("pointerdown",O),()=>_.removeEventListener("pointerdown",O)},[n,M,b,S,N]),s.useEffect(()=>{const _=t.current;if(!_||!x)return;const O=L=>{if(L.defaultPrevented)return;const A=Af(L);if(!A)return;const k=h.current.viewportRef.current;if(!k||h.current.isEditing)return;const I=Jn(L.target,k);if(I!=="grid"&&I!=="control")return;const{range:P,resolved:v}=h.current.selection.getCurrentRange();if(!P||!v)return;L.preventDefault();const B={top:v.top,bottom:v.bottom,left:v.left,right:v.right},V=A==="down"?{...B,bottom:B.top}:{...B,right:B.left};(A==="down"?B.bottom===B.top:B.right===B.left)||C(b(),V,B,A,!0,{row:v.anchorRow,col:v.anchorCol},"keyboard")};return _.addEventListener("keydown",O),()=>_.removeEventListener("keydown",O)},[t,x,C,b]),{handle:i?null:f}}const Pf=e=>e.id,Ff={hasColSpan:!1,hasRowSpan:!1,colspanMap:new Map,rowSpanningCaches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},getSpanOrigin:()=>null,getUnpinnedColSpanRanges:()=>{},getCenterRowSpanStart:e=>e},ls="\0",ss="";function as(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 Of(e){return e.map(t=>t.field).join(ls)}function Df(e){const{pinnedTopRows:t,centerRows:n,pinnedBottomRows:o,columns:r,leftPinnedColumns:i,unpinnedColumns:l,rightPinnedColumns:a,expandedRowIds:c,rowMetaMap:u,getRowId:g=Pf}=e,h=s.useMemo(()=>r.some(b=>b.colSpan!==void 0&&b.colSpan!==null),[r]),x=s.useMemo(()=>r.some(b=>b.rowSpan!==void 0&&b.rowSpan!==null),[r]),y=h||x,p=y?[i,l,a].map(Of).join(ss):"",f=s.useMemo(()=>{if(!p)return{columns:[],leftCount:0,unpinnedCount:0};const b=new Map(r.map(S=>[S.field,S])),w=p.split(ss).map(S=>S?S.split(ls):[]),C=[];let E=0;for(const S of w){E+=S.length;for(const N of S){const M=b.get(N)??{field:N};C.push({colDef:M,field:N,sectionEnd:E,hasColSpan:M.colSpan!==void 0&&M.colSpan!==null,hasRowSpan:M.rowSpan!==void 0&&M.rowSpan!==null})}}return{columns:C,leftCount:w[0].length,unpinnedCount:w[1].length}},[p,r]),m=s.useMemo(()=>{if(!y||f.columns.length===0)return null;const b={colspanMap:new Map,rowSpanningCaches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},hiddenOriginFields:new Map,unpinnedRanges:new Map,centerRowSpanStart:new Map},C={spanColumns:f,expandedRowIds:c,rowMetaMap:u,getRowId:g,warned:new Set,out:b};return Sr(t,0,!1,C),Sr(n,t.length,!0,C),Sr(o,t.length+n.length,!1,C),b},[y,f,t,n,o,c,u,g]);return s.useMemo(()=>{if(!m)return Ff;const{colspanMap:b,rowSpanningCaches:w,hiddenOriginFields:C,unpinnedRanges:E,centerRowSpanStart:S}=m,N=f.columns;return{hasColSpan:h,hasRowSpan:x,colspanMap:b,rowSpanningCaches:w,getSpanOrigin:(M,_)=>{const O=b.get(M)?.[_];if(O?.spannedByColSpan)return{rowId:M,field:N[O.leftVisibleCellIndex].field};const L=w.hiddenCellOriginMap[M]?.[_];return L===void 0?null:{rowId:L,field:C.get(M)?.[_]??_}},getUnpinnedColSpanRanges:M=>E.get(M),getCenterRowSpanStart:M=>S.get(M)??M}},[m,h,x,f])}function Sr(e,t,n,o){const{spanColumns:r,expandedRowIds:i,rowMetaMap:l,getRowId:a,warned:c,out:u}=o,{columns:g,leftCount:h,unpinnedCount:x}=r,y=g.length,{colspanMap:p,rowSpanningCaches:f,hiddenOriginFields:m,unpinnedRanges:b,centerRowSpanStart:w}=u,C=new Int32Array(y),E=new Array(y),S=new Array(y),N=new Int32Array(y);let M=0;const _=[];g.forEach((A,k)=>{(A.hasColSpan||A.hasRowSpan)&&_.push(k)});const O=(A,k,I)=>{const P=g[I].field;if(Zt(f.hiddenCells,A,P,!0),Zt(f.hiddenCellOriginMap,A,P,E[I]),S[I]!==P&&Zt(m,A,P,S[I]),n){const v=w.get(k);(v===void 0||N[I]<v)&&w.set(k,N[I])}},L=(A,k,I)=>{const P=g[I],v=a(A),B=$f(A,v,P.colDef,t+k,I,l,c);let V=1;if(P.hasColSpan){const H=Math.min(cs(P.colDef.colSpan,B,"colSpan",P.field,c),P.sectionEnd-I);for(;V<H&&C[I+V]<=k;)V++}let Q=1;if(P.hasRowSpan){Q=Math.min(cs(P.colDef.rowSpan,B,"rowSpan",P.field,c),e.length-k);for(let H=1;H<Q;H++)if(Xe(a(e[k+H]),l)){Q=H;break}if(Q>1&&i&&i.size>0){for(let H=0;H<Q-1;H++)if(i.has(a(e[k+H]))){Q=H+1;break}}}if(V>1){Zt(p,v,P.field,{spannedByColSpan:!1,cellProps:{colSpan:V}});for(let H=1;H<V;H++){const z=g[I+H];Zt(p,v,z.field,{spannedByColSpan:!0,leftVisibleCellIndex:I,rightVisibleCellIndex:I+V-1})}if(I>=h&&I<h+x){let H=b.get(v);H||(H=[],b.set(v,H)),H.push(I-h,I+V-1-h)}}if(Q>1){Zt(f.spannedCells,v,P.field,Q);for(let H=I;H<I+V;H++)C[H]=k+Q,E[H]=v,S[H]=P.field,N[H]=k;k+Q>M&&(M=k+Q)}return V};for(let A=0;A<e.length;A++){const k=e[A];if(!k||k._isSkeleton||Xe(a(k),l))continue;if(M<=A){let P=0;for(const v of _)v>=P&&(P=v+L(k,A,v));continue}let I=0;for(;I<y;)C[I]>A?(O(a(k),A,I),I++):g[I].hasColSpan||g[I].hasRowSpan?I+=L(k,A,I):I++}}function $f(e,t,n,o,r,i,l){const a=e[n.field];let c=a;if(n.valueGetter)try{c=n.valueGetter({row:e,field:n.field,value:a})}catch(u){ds(l,`valueGetter:${n.field}`,`valueGetter for column "${n.field}" threw while computing its span`,u),c=void 0}return{row:e,value:c,field:n.field,colDef:n,rowIndex:o,colIndex:r,rowMeta:i?.get(t)}}function cs(e,t,n,o,r){if(typeof e=="number")return as(e);if(typeof e!="function")return 1;try{return as(e(t))}catch(i){return ds(r,`${n}:${o}`,`${n} for column "${o}" threw; the cell is rendered without a span`,i),1}}function ds(e,t,n,o){process.env.NODE_ENV==="production"||e.has(t)||(e.add(t),console.warn(`[OpenGridX] ${n}.`,o))}function Zt(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 Gf(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 Hf(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 a=n,c=o,u=!0;for(;u;){u=!1;for(const{row:b,id:w}of l){const C=t.getUnpinnedColSpanRanges(w??b.id);if(C)for(let E=0;E<C.length;E+=2){const S=C[E],N=C[E+1];N<a||S>c||(S<a&&(a=S,u=!0),N>c&&(c=N,u=!0))}}}if(a===n&&c===o)return r;const{leftPinnedCols:g,unpinnedColsWithWidth:h,rightPinnedCols:x,unpinnedAccWidths:y,unpinnedTotalWidth:p}=i,f=a>0?y[a-1]:0,m=p-y[c];return[...g,...f>0?[{field:"__spacer_left__",width:f,isSpacer:!0}]:[],...h.slice(a,c+1),...m>0?[{field:"__spacer_right__",width:m,isSpacer:!0}]:[],...x]},[t,n,o,r,i,l])}function Bf(e,t){const{draggedColumn:n,onDragOver:o,onDrop:r,onDragEnd:i}=t,l=s.useMemo(()=>{if(!e||e.length===0)return null;const a=c=>n===null||pr(e,n,c);return{onDragOver:o&&(c=>a(c)?o(c):()=>{}),onDrop:r&&(c=>a(c)?r(c):u=>{u.preventDefault(),i?.()})}},[e,n,o,r,i]);return l?{...t,...l}:t}const Wf=300,us=e=>e.id;function Vf(e,t){return e==="infinite"?"infinite":e==="server"?t?"all":"page":"all"}function fs(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 gs(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 zf(e){const{dataSource:t,sortModel:n,filterModel:o,paginationModel:r,paginationMode:i,sortingMode:l,filterMode:a,aggregationModel:c,rowGroupingActive:u=!1}=e,g=Vf(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,p=Cl({dataSource:t,paginationMode:i,sortingMode:l,filterMode:a}),f=JSON.stringify([g,g!=="all"||l==="server"?n:null,g!=="all"||a==="server"?o:null,p?c??null:null,g==="all"?null:r.pageSize]),m=g==="all"?0:r.page,b=g==="all"?0:r.pageSize,w=s.useRef({params:e,kind:g});s.useLayoutEffect(()=>{w.current={params:e,kind:g}});const C=s.useRef(0),E=s.useRef(0),S=s.useRef(null),N=s.useRef({page:0,loadedEnd:0,inFlightEnd:null}),M=s.useRef(null),_=s.useRef(!1),O=s.useRef(0),L=s.useRef(!1),A=s.useRef(new Set),k=s.useCallback(()=>{const z=_.current||O.current>0;z!==L.current&&(L.current=z,w.current.params.setDataSourceLoading(z))},[]),I=s.useCallback(()=>{M.current!==null&&(clearTimeout(M.current),M.current=null)},[]),P=s.useCallback(()=>{C.current++,N.current.inFlightEnd=null,_.current=!1},[]),v=s.useCallback(()=>{E.current++,A.current.clear(),O.current=0},[]),B=s.useCallback(async()=>{const{params:z,kind:W}=w.current,re=z.dataSource;if(!re)return!1;const oe=N.current,fe=z.paginationModel.pageSize;let le,ce;if(W==="infinite"){if(oe.inFlightEnd!==null)return!1;if(le=oe.loadedEnd,ce=(oe.page+1)*fe,ce<=le)return _.current=!1,k(),!1;oe.inFlightEnd=ce}else W==="page"?(le=z.paginationModel.page*fe,ce=le+fe):(le=0,ce=vl);const K=++C.current;_.current=!0,k(),z.setDataSourceError(null);let de;try{de=await re.getRows({startRow:le,endRow:ce,sortModel:z.sortModel,filterModel:z.filterModel,groupKeys:[],aggregationModel:z.aggregationModel})}catch(X){return K!==C.current||(oe.inFlightEnd=null,_.current=!1,w.current.params.setDataSourceError(X),console.error("Data Source Error:",X),k()),!1}if(K!==C.current)return!1;try{const{params:X}=w.current,te=X.getRowId??us,U=fs(de.rows,te);if(W==="infinite"&&le>0?X.setRows(J=>gs(J,U,te),!0):(X.setRows(U.map(J=>J.row),!0),v()),de.aggregationResults&&X.onAggregationResults?.(de.aggregationResults),de.rowCount!==void 0&&X.setRowCount(de.rowCount),W==="infinite"&&(oe.inFlightEnd=null,oe.loadedEnd=le+de.rows.length,de.rows.length>=ce-le&&(oe.page+1)*fe>ce))return!0}catch(X){return oe.inFlightEnd=null,_.current=!1,w.current.params.setDataSourceError(X),console.error("Data Source Error:",X),k(),!1}return _.current=!1,k(),!1},[k,v]),V=s.useCallback(async()=>{for(;await B(););},[B]);s.useLayoutEffect(()=>{if(!y){S.current&&(S.current=null,I(),P(),v(),w.current.params.setDataSourceError(null),k());return}const z=S.current,W=N.current;if(!z||z.key!==f||z.getRows!==y){S.current={key:f,getRows:y},P(),v();const re=g==="infinite"&&z!==null&&m!==0;if(W.page=re?0:m,W.loadedEnd=0,re){const{params:oe}=w.current;oe.onPaginationModelChange?.({...oe.paginationModel,page:0})}}else g==="infinite"?(m<W.page&&(P(),W.loadedEnd=0),W.page=m):P();if(g==="infinite"){const re=W.inFlightEnd!==null;if(re||(W.page+1)*b<=W.loadedEnd){_.current=re,k();return}}return _.current=!0,k(),M.current=setTimeout(()=>{M.current=null,V()},Wf),I},[y,f,g,m,b,I,P,v,k,V]),s.useEffect(()=>()=>{P(),v()},[P,v]);const Q=s.useCallback(()=>(I(),V()),[I,V]),H=s.useCallback(async(z,W,re)=>{const{params:oe}=w.current,fe=oe.dataSource;if(!fe)return;const le=JSON.stringify(W),ce=A.current;if(ce.has(le))return;const K=E.current;ce.add(le),O.current++,k();try{const de=await fe.getRows({startRow:0,endRow:vl,sortModel:oe.sortModel,filterModel:oe.filterModel,groupKeys:W,aggregationModel:oe.aggregationModel});if(K!==E.current)return;if(de.rows.length>0){const{params:X}=w.current,te=X.getRowId??us,U=fs(de.rows,te);X.setRows(J=>gs(J,U,te),!0)}}catch(de){if(K!==E.current)return;ce.delete(le),console.error("Failed to fetch children:",de),re?.(de)}finally{K===E.current&&(O.current--,k())}},[k]);return{fetchRows:Q,fetchChildren:H}}function Kf(e){return(e.serverChildrenCount??0)>0&&(e.children?.length??0)===0}function jf({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((a,c)=>{!Kf(a)||!n(c)||i(c,o(c),()=>{const{isGroupExpanded:u,toggleExpansion:g}=l.current;u(c)&&g(c)})})},[e,t,n,o,i])}const ps={};function Uf(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 hs(e){const{rows:t,columns:n,aggregationModel:o,isServerSide:r,dataSource:i,filterModel:l,sortModel:a,serverAggregationResults:c}=e,u=Object.keys(o).length>0,g=s.useMemo(()=>{const S=new Map;return(n??[]).forEach(N=>S.set(N.field,N)),S},[n]),h=s.useMemo(()=>r||!u?ps:jn(t,o,g,"useAggregation"),[t,g,o,r,u]),x=JSON.stringify([o,l??null,a??[]]),y=r&&u&&!!i?.getAggregations&&!c,p=s.useRef({aggregationModel:o,filterModel:l,sortModel:a});s.useEffect(()=>{p.current={aggregationModel:o,filterModel:l,sortModel:a}});const[f,m]=s.useState(null);s.useEffect(()=>{const S=i?.getAggregations;if(!y||!S)return;let N=!1;const M=p.current,_={sortModel:M.sortModel??[],filterModel:M.filterModel??{items:[]},groupKeys:[],aggregationModel:M.aggregationModel};let O;try{O=Promise.resolve(S(_))}catch(L){O=Promise.reject(L)}return O.then(L=>{N||m({key:x,result:L,error:null})},L=>{N||(console.error("[useAggregation] Server aggregation error:",L),m({key:x,result:null,error:L}))}),()=>{N=!0}},[y,i,x]);const b=f&&f.key===x?f:null,w=y&&b===null,C=y?b?.error??null:null;return{aggregationResult:s.useMemo(()=>r?c&&Object.keys(c).length>0?c:b?.result??ps:h,[r,h,c,b]),isLoading:w,error:C}}const Rf={items:[]},qf=[];function Xf(e){const{rows:t,columns:n,pivotMode:o,pivotModel:r,filterModel:i,sortModel:l,hasDataSource:a,hierarchyRequested:c}=e,u=o&&!a,g=s.useMemo(()=>new Set(n.map(b=>b.field)),[n]),h=s.useMemo(()=>er(n),[n]),x=s.useMemo(()=>hc(i,g),[i,g]),y=s.useMemo(()=>u?Xo(t,x.source,h):t,[u,t,x.source,h]),p=s.useMemo(()=>u?ji(y,n,r,{outputFilterModel:x.output,sortModel:l}):nr,[u,y,n,r,x.output,l]),f=u&&p.isValid,m=s.useRef({dataSource:!1,hierarchy:!1});return s.useEffect(()=>{process.env.NODE_ENV!=="production"&&(o&&a&&!m.current.dataSource&&(m.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`.")),f&&c&&!m.current.hierarchy&&(m.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,a,f,c]),{isActive:f,rows:f?p.pivotRows:t,columns:f?p.pivotColumns:n,pipelineFilterModel:f?Rf:i,pipelineSortModel:f?qf:l}}const nt=({variant:e="text",size:t="medium",color:n="default",disabled:o=!1,className:r="",type:i="button",children:l,...a})=>{const c=["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:c,disabled:o,...a,children:l})};function kr(e){const t=s.useId(),{page:n,pageSize:o,rowCount:r,onPageChange:i,onPageSizeChange:l,pageSizeOptions:a=[10,25,50,100],showFirstButton:c=!0,showLastButton:u=!0,localeText:g}=e,h=to(o),x=sr(r,h),y=sl(n,x),p=a.includes(h)?a:[...a,h].sort((k,I)=>k-I),f=y*h,m=Math.min(f+h,r),b=r===0?0:`${f+1}–${m}`,w=g?.paginationRowsPerPage??"Rows per page:",C=g?.paginationOf?g.paginationOf(r===0?0:f+1,m,r):`${b} of ${r}`,E=g?.paginationPage?g.paginationPage(y+1,x):`Page ${y+1} of ${x}`,S=()=>{i(0)},N=()=>{i(Math.max(0,y-1))},M=()=>{i(Math.min(x-1,y+1))},_=()=>{i(x-1)},O=k=>{const I=parseInt(k.target.value,10);l(I)},L=y===0,A=y>=x-1;return d.jsxs("div",{className:"ogx-pagination",role:"navigation","aria-label":"Pagination",children:[d.jsxs("div",{className:"ogx-pagination__page-size",children:[d.jsx("label",{htmlFor:t,className:"ogx-pagination__label",children:w}),d.jsx("select",{id:t,className:"ogx-pagination__select",value:h,onChange:O,children:p.map(k=>d.jsx("option",{value:k,children:k},k))})]}),d.jsx("div",{className:"ogx-pagination__info","aria-live":"polite","aria-atomic":"true",children:C}),d.jsxs("div",{className:"ogx-pagination__actions",children:[c&&d.jsx(nt,{variant:"text",size:"small",onClick:S,disabled:L,"aria-label":"Go to first page",title:"First page",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(nt,{variant:"text",size:"small",onClick:N,disabled:L,"aria-label":"Go to previous page",title:"Previous page",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:E}),d.jsx(nt,{variant:"text",size:"small",onClick:M,disabled:A,"aria-label":"Go to next page",title:"Next page",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"})})}),u&&d.jsx(nt,{variant:"text",size:"small",onClick:_,disabled:A,"aria-label":"Go to last page",title:"Last page",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 Yf({row:e,rowId:t,rowIndex:n,ariaRowIndex:o,listViewColumn:r,gridColumn:i,rowMeta:l,isSelected:a=!1,checkboxSelection:c=!1,rowHeight:u,onRowClick:g,onRowDoubleClick:h,onSelectionChange:x,tabIndex:y=-1,onFocus:p,onToggleExpansion:f}){const m=t??e.id,b=r.field,w=Me(e,b,i),C=$o(e,b,w,i)??Go(w,i),E=l?.isGroupRow===!0||Xe(m),S={row:e,value:w,formattedValue:C,field:b,colDef:i??r,rowIndex:n,colIndex:0,rowMeta:l},N=M=>{M.stopPropagation(),x?.(m,M.target.checked)};return d.jsxs("div",{className:`ogx-list-view__row${a?" ogx-list-view__row--selected":""}`,style:u?{minHeight:u}:void 0,onClick:()=>g?.(e),onDoubleClick:h?()=>h(e):void 0,role:"row","aria-rowindex":o??n+1,"aria-selected":a,"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:p?M=>{M.target===M.currentTarget&&p(n)}:void 0,children:[c&&d.jsx("div",{className:"ogx-list-view__checkbox",onClick:M=>M.stopPropagation(),children:!E&&d.jsx(Ct,{checked:a,onChange:N,"aria-label":`Select row ${m}`,tabIndex:-1})}),l&&f&&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(ur,{isExpanded:l.isExpanded===!0,onClick:()=>f(m),tabIndex:-1})}),d.jsx("div",{className:"ogx-list-view__cell",role:"gridcell",children:d.jsx(Dt,{field:b,resetKey:e,renderFn:()=>{const M=r.renderCell(S);return M===void 0&&E?l?.groupLabel:M}})})]})}function Jf(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=gl(i.currentTarget);if(!l){n.current=!0;return}if(!n.current)return;const a=o.current;a&&(n.current=!1,a(l))},[]);return e?r:void 0}const Zf=e=>e.id;function Qf({ariaLabel:e,allRenderableRows:t,dataRowCount:n,pinnedTopRowCount:o,pinnedBottomRowCount:r,unpinnedRowCount:i,pagination:l,effectivePaginationModel:a,currentPage:c,pageSizeOptions:u,selectedRowIds:g,listViewColumn:h,columnsByField:x,rowMetaMap:y,noRowsLabel:p,rowHeight:f,checkboxSelection:m,paginationMode:b,serverRowCount:w,paginationSlot:C,paginationSlotProps:E,localeText:S,onRowClick:N,onRowDoubleClick:M,onSelectionChange:_,onPaginationModelChange:O,onRowsScrollEnd:L,getRowId:A=Zf,multiselectable:k=!1,loading:I=!1,loadingOverlay:P,noRowsOverlay:v,showPaginationControls:B=!0,selectable:V=!1,onToggleExpansion:Q}){const H=C||kr,z=s.useRef(null),[W,re]=s.useState(null),oe=W===null?-1:t.findIndex(D=>A(D)===W),fe=oe===-1?0:oe,le=D=>{const T=t[D];T&&(re(A(T)),z.current?.querySelector(`:scope > [role="row"][data-rowindex="${D}"]`)?.focus())},ce=D=>{const T=D.target;if(T.getAttribute("role")!=="row"||T.parentElement!==z.current)return;const $=Number(T.getAttribute("data-rowindex")),F=t[$];if(!F)return;const Z=A(F),G=t.length-1,Y=y.get(Z),j=!!(Y?.hasChildren&&Q);if(D.altKey&&(D.key==="ArrowRight"||D.key==="ArrowLeft")){D.preventDefault();const q=Vn(D.key,Je(D.currentTarget))==="ArrowRight";j&&q!==(Y?.isExpanded===!0)&&Q?.(Z);return}switch(D.key){case"ArrowDown":D.preventDefault(),le(Math.min($+1,G));return;case"ArrowUp":D.preventDefault(),le(Math.max($-1,0));return;case"Home":D.preventDefault(),le(0);return;case"End":D.preventDefault(),le(G);return;case"PageDown":D.preventDefault(),le(Math.min($+10,G));return;case"PageUp":D.preventDefault(),le(Math.max($-10,0));return;case"Enter":case" ":if(D.preventDefault(),D.key===" "&&D.shiftKey){V&&!Y?.isGroupRow&&_(Z,!g.has(Z));return}j?Q?.(Z):N({row:F,id:Z,rowIndex:$});return}},K=b==="server",de=K?w||0:i,X=K?w||0:n,te=to(a.pageSize),U=sr(de,te),J=l?c*te:0,se=t.length-o-r,ue=D=>{if(D<o)return D+1;const T=D-o;return T<se?o+J+T+1:o+de+(T-se)+1},ee=Jf(L,t.length);return d.jsxs("div",{className:"ogx-list-view",role:"grid","aria-label":e||"Data grid list view","aria-rowcount":X,"aria-multiselectable":k,children:[d.jsx("div",{className:"ogx-list-view__toolbar",children:d.jsxs("span",{children:[X," ",X===1?"item":"items",l?` · page ${c+1} of ${U}`:"",g.size>0?` · ${g.size} selected`:""]})}),d.jsx("div",{className:"ogx-list-view__rows",tabIndex:-1,onScroll:ee,onKeyDown:ce,ref:z,children:t.length===0&&I?d.jsx("div",{className:"ogx-list-view__loading",children:P??d.jsx("div",{className:"ogx__loading-bar",role:"progressbar","aria-label":"Loading data"})}):t.length===0&&v?d.jsx("div",{className:"ogx-list-view__empty",children:v}):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"})]}),p]}):t.map((D,T)=>{const $=A(D);return d.jsx(Yf,{row:D,rowId:$,rowIndex:T,ariaRowIndex:ue(T),listViewColumn:h,gridColumn:x.get(h.field),rowMeta:y.get($),isSelected:g.has($),checkboxSelection:m,rowHeight:f,onRowClick:F=>N({row:F,id:$,rowIndex:T}),onRowDoubleClick:M?F=>M({row:F,id:$,rowIndex:T}):void 0,onSelectionChange:_,tabIndex:T===fe?0:-1,onToggleExpansion:Q,onFocus:F=>re(A(t[F]))},$)})}),l&&B&&d.jsx(H,{page:c,pageSize:a.pageSize,rowCount:de,pageSizeOptions:u,onPageChange:D=>O({...a,page:D}),onPageSizeChange:D=>O({...a,pageSize:D,page:0}),localeText:S,...E})]})}function eg({overlay: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":"Loading data"})})}function Sn(e){return e.headerName||e.field}function tg(e){return e.nativeEvent.isComposing||e.keyCode===229}function kn(e,t,n=!0){return o=>{if(tg(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??"")),a=s.useRef(null);return s.useEffect(()=>{a.current?.focus(),a.current?.select()},[]),d.jsx(et,{ref:a,variant:"cell",type:"text",inputClassName:"ogx__edit-input","aria-label":Sn(t),value:i,onChange:c=>{l(c.target.value),n(c.target.value)},onBlur:o,onKeyDown:kn(o,r)})}function og({value:e,colDef:t,onValueChange:n,onCommit:o,onCancel:r}){const[i,l]=s.useState(typeof e=="number"?e:""),a=s.useRef(null);return s.useEffect(()=>{a.current?.focus(),a.current?.select()},[]),d.jsx(et,{ref:a,variant:"cell",type:"number",inputClassName:"ogx__edit-input ogx__edit-input--number","aria-label":Sn(t),value:i,onChange:c=>{const u=c.target.value===""?"":Number(c.target.value);l(u),n(u===""?null:u)},onBlur:o,onKeyDown:kn(o,r)})}function rg({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:a=>a.preventDefault(),children:d.jsx(Ct,{ref:i,inputClassName:"ogx__edit-checkbox","aria-label":Sn(t),checked:!!e,onChange:l,onMouseDown:a=>a.preventDefault(),onBlur:o,onKeyDown:kn(o,r,!1)})})}const Er=e=>typeof e=="object"?e.value:e,ig=e=>typeof e=="object"?e.label:String(e);function lg(e,t){return e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Object.is(e,t)}function sg({value:e,colDef:t,onValueChange:n,onCommit:o,onCancel:r}){const i=s.useRef(null);s.useEffect(()=>{i.current?.focus()},[]);const l=t.valueOptions??[],a=l.map(g=>String(Er(g)));let c=l.findIndex(g=>lg(Er(g),e));c===-1&&e!==null&&e!==void 0&&(c=a.indexOf(String(e)));const u=c===-1;return d.jsxs("select",{ref:i,className:"ogx__edit-select","aria-label":Sn(t),value:u?"":a[c],onChange:g=>{const h=a.indexOf(g.target.value);n(h===-1?null:Er(l[h]))},onBlur:o,onKeyDown:kn(o,r),children:[u&&d.jsx("option",{value:""}),l.map((g,h)=>d.jsx("option",{value:a[h],children:ig(g)},h))]})}const ms=e=>String(e).padStart(2,"0"),ws=/^(\d{4}-\d{2}-\d{2})/;function Mr(e){if(e instanceof Date)return Number.isNaN(e.getTime())?"":`${e.getFullYear()}-${ms(e.getMonth()+1)}-${ms(e.getDate())}`;if(typeof e=="string"){const t=ws.exec(e);return t?t[1]:e===""?"":Mr(new Date(e))}return typeof e=="number"?Mr(new Date(e)):""}function ag(e,t){if(e==="")return null;const[n,o,r]=e.split("-").map(Number),i=l=>{const a=new Date(l.getTime());return a.setFullYear(n,o-1,r),a};return t instanceof Date&&!Number.isNaN(t.getTime())?i(t):typeof t=="number"&&Number.isFinite(t)?i(new Date(t)).getTime():typeof t=="string"&&ws.test(t)&&t.length>10?e+t.slice(10):e}function cg({value:e,colDef:t,onValueChange:n,onCommit:o,onCancel:r}){const[i]=s.useState(e),[l,a]=s.useState(()=>Mr(e)),c=s.useRef(null);return s.useEffect(()=>{c.current?.focus()},[]),d.jsx(et,{ref:c,variant:"cell",type:"date",inputClassName:"ogx__edit-input","aria-label":Sn(t),value:l,onChange:u=>{a(u.target.value),n(ag(u.target.value,i))},onBlur:o,onKeyDown:kn(o,r)})}function dg(e){const{colDef:t}=e;switch(t.type){case"number":return d.jsx("div",{className:"ogx__edit-cell",children:d.jsx(og,{...e})});case"boolean":return d.jsx("div",{className:"ogx__edit-cell",children:d.jsx(rg,{...e})});case"singleSelect":return d.jsx("div",{className:"ogx__edit-cell",children:d.jsx(sg,{...e})});case"date":return d.jsx("div",{className:"ogx__edit-cell",children:d.jsx(cg,{...e})});default:return d.jsx("div",{className:"ogx__edit-cell",children:d.jsx(ng,{...e})})}}function ug(e){const{onCellClick:t,onCellEditStart:n,onCellValueChange:o,value:r,row:i,colDef:l,rowIndex:a,colIndex:c,ariaColIndex:u,isSelected:g,onClick:h,width:x,pinnedPosition:y,pinnedOffset:p,isPinnedEdge:f,isFocused:m,isFocusVisible:b,isEditable:w,isEditing:C,onEditStart:E,onEditStop:S,onValueChange:N,colSpanInfo:M,rowSpan:_,isHiddenByRowSpan:O,rowMeta:L,valueError:A,rangeFlags:k=0}=e,I=s.useCallback(ee=>{o?o(l.field,ee):N?.(ee)},[o,N,l.field]),P=L?.isGroupRow===!0,{formattedValue:v,error:B}=s.useMemo(()=>{const ee=l.valueFormatter;if(ee&&!(P&&r==null)){const D=Ve(()=>ee({value:r,row:i,field:l.field}));return D.ok?{formattedValue:D.value}:{formattedValue:"",error:D.error??new Error("valueFormatter failed")}}return{formattedValue:Go(r,l)}},[r,i,l,P]),V=s.useMemo(()=>{if(!l.cellClassName)return"";const ee=l.cellClassName;if(typeof ee=="function"){const D=Ve(()=>ee({value:r,formattedValue:v,row:i,field:l.field,colDef:l,rowIndex:a,colIndex:c,rowMeta:L}));return D.ok&&D.value||""}return l.cellClassName},[l,r,v,i,a,c,L]),Q=A??B,H=l.field,z=s.useCallback(()=>{S?.(!1,H)},[S,H]),W=s.useCallback(()=>{S?.(!0,H)},[S,H]),re=s.useMemo(()=>[i,l.renderCell,r],[i,l.renderCell,r]),oe=s.useRef(!1);if(s.useEffect(()=>{if(!(!C||!S))return oe.current=!0,()=>{oe.current=!1,queueMicrotask(()=>{oe.current||S(!1,H)})}},[C,S,H]),M?.spannedByColSpan)return null;const fe=M?.cellProps.colSpan??1,le=fe>1,ce=(le?M?.cellProps.width:void 0)??x??l.width??100,K={width:"var(--width)","--width":typeof ce=="number"?`${ce}px`:ce,flexGrow:(le?M?.cellProps.flexGrow:void 0)??l.flex??0,flexShrink:0,flexBasis:"auto",boxSizing:"border-box",minWidth:le?void 0:l.minWidth,maxWidth:le?void 0:l.maxWidth};if(O)return d.jsx("div",{className:"ogx__cell ogx__cell--hidden",style:K,role:"presentation","data-field":l.field,"data-colindex":c});const de=ee=>{C||(t&&t({row:i,field:l.field,value:r,colDef:l,rowIndex:a,colIndex:c}),h?.(ee))},X=()=>{C||!w||(n?n(l.field,r):E?.())},te=l.renderEditCell,U=y!=null,J=["ogx__cell",`ogx__cell--align-${l.align||"left"}`,g&&"ogx__cell--selected",m&&"ogx__cell--focused",m&&b&&"ogx__cell--focus-visible",l.type&&`ogx__cell--type-${l.type}`,U&&"ogx__cell--pinned",U&&`ogx__cell--pinned-${y}`,U&&f&&`ogx__cell--pinned-${y}-${y==="left"?"last":"first"}`,C&&"ogx__cell--editing",_&&_>1&&"ogx__cell--spanned",(k&ir)!==0&&"ogx__cell--range",(k&Zi)!==0&&"ogx__cell--range-top",(k&Qi)!==0&&"ogx__cell--range-bottom",(k&el)!==0&&"ogx__cell--range-left",(k&tl)!==0&&"ogx__cell--range-right",V].filter(Boolean).join(" "),se=_||1,ue={...K,position:U?"sticky":void 0,zIndex:l.zIndex??(U?3:void 0),padding:C?0:void 0};return se>1&&(ue.height=`calc(var(--height) * ${se} - var(--border-width, 1px))`,ue.zIndex=10,U&&(ue.zIndex=40)),U&&p!==void 0&&(y==="left"?ue.insetInlineStart=p:ue.insetInlineEnd=p),d.jsxs("div",{className:J,style:ue,onClick:de,onDoubleClick:X,role:"gridcell","aria-colindex":u??c+1,"aria-readonly":!w||void 0,tabIndex:-1,"data-field":l.field,"data-colindex":c,...fe>1?{"aria-colspan":fe}:{},...se>1?{"aria-rowspan":se}:{},...(k&ir)!==0?{"aria-selected":!0}:{},children:[d.jsx("div",{className:"ogx__cell-content",children:C&&(o||N)&&S?te?d.jsx(Dt,{field:l.field,resetKey:i,renderFn:()=>te({value:r,formattedValue:v,row:i,field:l.field,colDef:l,rowIndex:a,colIndex:c,rowMeta:L,onValueChange:I,onCommit:z,onCancel:W})}):d.jsx(dg,{value:r,formattedValue:v,row:i,field:l.field,colDef:l,rowIndex:a,colIndex:c,rowMeta:L,onValueChange:I,onCommit:z,onCancel:W}):Q!==void 0?d.jsx(Dt,{field:l.field,resetKey:i,renderFn:()=>{throw Q}}):l.renderCell?d.jsx(Dt,{field:l.field,resetKey:re,renderFn:()=>l.renderCell({value:r,formattedValue:v,row:i,field:l.field,colDef:l,rowIndex:a,colIndex:c,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"}):v}),(k&nl)!==0&&!C&&d.jsx("div",{className:"ogx__cell-fill-handle","aria-hidden":"true"})]})}const bs=s.memo(ug),fg=({className:e="",...t})=>d.jsx("button",{type:"button",className:`ogx-drag-handle ${e}`,"aria-label":"Drag to reorder row",...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 gg(e){const{rowId:t,content:n,height:o,isExpanded:r,onHeightChange:i,id:l,colSpan:a}=e,c=s.useRef(null),u=o==="auto";if(s.useLayoutEffect(()=>{const h=c.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 g={height:u?"auto":`${o}px`,overflow:u?"visible":"auto"};return d.jsx("div",{ref:c,className:"ogx__detail-panel",style:g,role:"row",id:l,children:d.jsx("div",{className:"ogx__detail-panel-content",role:"gridcell","aria-colspan":a,children:n})})}const Nr=12;function pg(e,t,n,o){let r=0,i=0,l=0;for(let a=t;a<e.length&&l<n;a++){const c=e[a];if(c.isSpacer)break;r+=At(c,o),i+=c.flex??0,l++}return{spannedByColSpan:!1,cellProps:{colSpan:l,width:r,flexGrow:i}}}function hg(e){const{row:t,rowId:n,columns:o,rowIndex:r,isSelected:i=!1,checkboxSelection:l=!1,onRowClick:a,onRowDoubleClick:c,onCellClick:u,onSelectionChange:g,columnWidths:h={},pinnedColumns:x,pinnedRows:y,hasDetailPanel:p=!1,isDetailPanelExpanded:f=!1,onDetailPanelToggle:m,detailPanelContent:b,detailPanelHeight:w=Ho,onDetailPanelHeightChange:C,pinCheckboxColumn:E=!0,pinExpandColumn:S=!0,rowReordering:N=!1,onDragStart:M,onDragOver:_,onDragEnd:O,onDrop:L,isDragging:A,isDragOver:k,editingCell:I,onEditStart:P,onEditStop:v,onEditCellValueChange:B,isCellEditable:V,focusedCellField:Q,isFocusVisible:H,colspanMap:z,rowSpanningCaches:W,rowHeight:re=52,rowMeta:oe,columnIndexMap:fe,ariaRowIndex:le,cellRange:ce}=e,K=n??t.id,de=s.useId(),X=s.useId(),te=s.useMemo(()=>Fo(o,h,x,l,E,p,S,N),[o,h,x,l,E,p,S,N]),U=s.useMemo(()=>Oo(o,x),[o,x]),J=oe?.hasChildren===!0,se=oe?.isGroupRow===!0,ue=p&&!se,ee=!se&&!Xe(K),D=s.useCallback((ie,Ce)=>{P?.({id:K,field:ie,value:Ce})},[K,P]),T=s.useCallback((ie,Ce)=>{B?.({id:K,field:ie,value:Ce})},[B,K]),$=s.useCallback((ie,Ce)=>{v?.({cancel:ie,id:K,field:Ce})},[v,K]);if(t._isSkeleton){const ie=Math.max(o.length,5);return d.jsx("div",{className:"ogx__row ogx__row--skeleton",role:"row","aria-hidden":"true",style:{height:re,minHeight:re},children:Array.from({length:ie}).map((Ce,Ee)=>d.jsx("div",{className:"ogx__skeleton-cell",children:d.jsx("div",{className:"ogx__skeleton-bar"})},Ee))})}const F=ie=>{ie.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell, .ogx__cell--editing")||a?.({row:t,id:K,rowIndex:r})},Z=ie=>{ie.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell, .ogx__cell--editing")||c?.({row:t,id:K,rowIndex:r})},G=ie=>{ie.stopPropagation(),g?.(K,ie.target.checked)},Y=ie=>{ie.stopPropagation(),m?.(K)},j=N?1:0,q=p?j+1:j,ne=l?q+1:q,he=ne,me=fe?.size??o.filter(ie=>!ie.isSpacer).length,R=oe!==void 0,ge=oe?.hasChildren===!0,we=ui(K,y),ae=we==="top",ye=we==="bottom",xe=["ogx__row",i&&"ogx__row--selected",r%2===0&&"ogx__row--even",r%2===1&&"ogx__row--odd",ae&&"ogx__row--pinned-top",ye&&"ogx__row--pinned-bottom",A&&"ogx__row--dragging",k&&"ogx__row--drag-over",J&&"ogx__row--group",oe?.isGroupFooter&&"ogx__row--group-footer"].filter(Boolean).join(" ");return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:xe,onClick:F,onDoubleClick:c?Z:void 0,role:"row","aria-rowindex":le??r+2,"aria-selected":i,"aria-level":R?(oe?.treeDepth??0)+1:void 0,"aria-expanded":ge?oe?.isExpanded===!0:void 0,"data-rowindex":r,onDragOver:_?_(K):void 0,onDrop:L?L(K):void 0,style:{maxHeight:`${re}px`,minHeight:`${re}px`,"--height":`${re}px`,"--border-width":"1px"},children:[N&&d.jsx("div",{className:`ogx__cell ogx__cell--drag-handle ${Q==="__reorder_col__"?"ogx__cell--focused":""} ${Q==="__reorder_col__"&&H?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":M?"Drag to reorder row":void 0,"aria-colindex":j,"data-field":"__reorder_col__",tabIndex:-1,style:{position:"sticky",insetInlineStart:0,zIndex:Nr},draggable:!!M,onDragStart:M?M(K):void 0,onDragEnd:O,onClick:ie=>ie.stopPropagation(),children:M&&d.jsx(fg,{})}),p&&d.jsx("div",{className:`ogx__cell ogx__cell--expand ${S?"ogx__cell--pinned-left":""} ${Q==="__expand_col__"?"ogx__cell--focused":""} ${Q==="__expand_col__"&&H?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":ue?f?"Collapse row details":"Expand row details":void 0,"aria-expanded":ue?f:void 0,"aria-controls":ue&&f?X:void 0,"aria-colindex":q,"data-field":"__expand_col__",style:{position:S?"sticky":void 0,insetInlineStart:S?N?48:0:void 0,zIndex:S?Nr:void 0},tabIndex:-1,onClick:ie=>{ie.stopPropagation(),u?.({row:t,field:"__expand_col__",value:f,colDef:{field:"__expand_col__",width:48},rowIndex:r,colIndex:-1})},children:ue&&d.jsx(ur,{isExpanded:f,onClick:Y,variant:"plus-minus",tabIndex:-1})}),l&&d.jsx("div",{className:`ogx__cell ogx__cell--checkbox ${E?"ogx__cell--pinned-left":""} ${Q==="__checkbox_col__"?"ogx__cell--focused":""} ${Q==="__checkbox_col__"&&H?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-colindex":ne,"data-field":"__checkbox_col__",style:{position:E?"sticky":void 0,insetInlineStart:E?(N?48:0)+(p&&S?48:0):void 0,zIndex:E?Nr:void 0},tabIndex:-1,onClick:ie=>{ie.stopPropagation(),u?.({row:t,field:"__checkbox_col__",value:i,colDef:{field:"__checkbox_col__",width:48},rowIndex:r,colIndex:-1})},children:ee&&d.jsx(Ct,{id:de,name:`ogx-select-row-${K}`,checked:i,onChange:G,onClick:ie=>ie.stopPropagation(),"aria-label":i?`Deselect row ${K}`:`Select row ${K}`,tabIndex:-1,onMouseDown:ie=>ie.preventDefault()})}),o.map((ie,Ce)=>{if(ie.isSpacer)return d.jsx("div",{style:{width:ie.width,minWidth:ie.width,flexShrink:0},"aria-hidden":"true"},ie.field);let Ee,Le;se?Ee=t[ie.field]:{value:Ee,error:Le}=gi(t,ie.field,ie);const Ie=fe?.get(ie.field)??Ce,Ne=h[ie.field]??ie.width,ke=ct(ie.field,x),Fe=!!P&&zo({row:t,field:ie.field,value:Ee,colDef:ie,rowIndex:r,colIndex:Ie,rowMeta:oe},V),pe=I?.id===K&&I?.field===ie.field,ve=pe?I?.value:Ee,Se=z?.get(K)?.[ie.field],be=Se&&!Se.spannedByColSpan&&Se.cellProps.colSpan>1?pg(o,Ie,Se.cellProps.colSpan,h):Se,De=be&&!be.spannedByColSpan?o[Ie+be.cellProps.colSpan-1]?.field??ie.field:ie.field,ft=ke==="right"?De:ie.field,Ht=ke?te[ft]:void 0,Pn=ke==="left"&&De===U.lastLeft||ke==="right"&&ie.field===U.firstRight,ln=W?.spannedCells[K]?.[ie.field],ot=W?.hiddenCells[K]?.[ie.field]||!1,mo=ce&&!ot&&ie.field!==Yi?kc(ce,Ie,be&&!be.spannedByColSpan?be.cellProps.colSpan:1,ln??1):void 0;return d.jsx(bs,{value:ve,row:t,colDef:ie,rowIndex:r,colIndex:Ie,ariaColIndex:he+Ie+1,isSelected:i,onCellClick:u,width:Ne,pinnedPosition:ke,pinnedOffset:Ht,isPinnedEdge:Pn,isFocused:Q===ie.field,isFocusVisible:H,isEditable:Fe,isEditing:pe,onCellEditStart:D,onEditStop:$,onCellValueChange:T,colSpanInfo:be,rowSpan:ln,isHiddenByRowSpan:ot,rowMeta:oe,valueError:Le,rangeFlags:mo},ie.field)})]}),ue&&d.jsx(gg,{id:X,colSpan:he+me,row:t,rowId:K,rowIndex:r,content:b,height:w,isExpanded:f,onHeightChange:C})]})}function mg(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 so=s.memo(hg,mg);function xs({getContent:e,params:t}){return d.jsx(Dt,{field:"detail panel",renderFn:()=>e(t),resetKey:t.row})}const wg=e=>e.id;function ys({rows:e,position:t,columns:n,selectedRowIds:o,checkboxSelection:r,onRowClick:i,onRowDoubleClick:l,onCellClick:a,onSelectionChange:c,columnWidths:u,pinnedColumns:g,pinnedRows:h,hasDetailPanel:x,expandedRowIds:y,getDetailPanelContent:p,getDetailPanelHeight:f,onDetailPanelToggle:m,onDetailPanelHeightChange:b,pinCheckboxColumn:w,pinExpandColumn:C,focusedCell:E,colspanMap:S,rowSpanningCaches:N,rowHeight:M,rowMetaMap:_,getRowId:O=wg,rowIndexOffset:L=0,ariaRowIndexBase:A,columnIndexMap:k,editingHandlers:I,isCellEditable:P,rowReordering:v=!1,cellRange:B,cellRangeHasRowSpan:V=!1,fillHandle:Q}){return e.length===0?null:d.jsx("div",{className:`ogx__pinned-rows ogx__pinned-rows--${t}`,role:"rowgroup",children:e.map((H,z)=>{const W=O(H),re=L+z;return d.jsx(so,{row:H,rowId:W,columns:n,rowIndex:re,ariaRowIndex:A!==void 0?A+z:void 0,columnIndexMap:k,isSelected:o.has(W),checkboxSelection:r,onRowClick:i,onRowDoubleClick:l,onCellClick:a,onSelectionChange:c,columnWidths:u,pinnedColumns:g,pinnedRows:h,hasDetailPanel:x,isDetailPanelExpanded:y.has(W),detailPanelContent:y.has(W)&&p?d.jsx(xs,{getContent:p,params:{row:H,id:W,rowIndex:re}}):null,detailPanelHeight:y.has(W)?Bo(Wo(f,{row:H,id:W,rowIndex:re})):void 0,onDetailPanelHeightChange:b,onDetailPanelToggle:m,pinCheckboxColumn:w,pinExpandColumn:C,focusedCellField:E?.id===W?E.field:null,colspanMap:S,rowSpanningCaches:N,rowHeight:M,rowMeta:_.get(W),editingCell:I?.editingCell,onEditStart:I?.startCellEdit,onEditStop:I?.stopCellEdit,onEditCellValueChange:I?.setEditCellValue,isCellEditable:P,rowReordering:v,cellRange:Ji(B,re,V,Q)},W)})})}const bg=({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 a=typeof i.width=="number"?i.width:150,c=Math.min(a*.7,a-20);return d.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:a,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:c,height:16,borderRadius:4}})},i.field||l)})]});function xg({virtualContainerHeight:e,offsetTop:t,effectiveLoading:n,visibleRows:o,baseColumns:r,virtualColumns:i,viewportWidth:l,checkboxSelection:a,hasDetailPanel:c,rowReordering:u,rowHeight:g,selectedRowIds:h,onRowClick:x,onRowDoubleClick:y,onCellClick:p,onSelectionChange:f,columnWidths:m,pinnedColumns:b,expandedRowIds:w,getDetailPanelContent:C,getDetailPanelHeight:E,onDetailPanelToggle:S,onDetailPanelHeightChange:N,pinCheckboxColumn:M,pinExpandColumn:_,rowReorderHandlers:O,editingHandlers:L,isCellEditable:A,focusedCell:k,colspanMap:I,rowSpanningCaches:P,paginationMode:v,dataSourceLoading:B,sortedUnpinnedRowCount:V,infiniteScrollSkeletonCount:Q,unpinnedRowsLength:H,lastRenderedRowIndex:z,rowMetaMap:W,loadingOverlay:re,ariaRowIndexOffset:oe,columnIndexMap:fe,cellRange:le,cellRangeHasRowSpan:ce=!1,fillHandle:K}){const de=r.length>0?r:(()=>{const U=(l||1e3)-(a?48:0)-(c?48:0)-(u?48:0),J=150,se=Math.max(1,Math.ceil(U/J));return Array.from({length:se},(ue,ee)=>({field:`placeholder_${ee}`,headerName:"",width:J}))})(),X=o.filter(U=>!U.pinned),te=v==="infinite"&&B&&V>0&&z>=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((U,J)=>d.jsx(bg,{columns:de,rowHeight:g,checkboxSelection:a,hasDetailPanel:c,rowReordering:u},`skeleton-${J}`)):X.map(({row:U,id:J,rowIndex:se})=>d.jsx(so,{row:U,rowId:J,columns:i,rowIndex:se,ariaRowIndex:oe!==void 0?se+oe:void 0,columnIndexMap:fe,isSelected:h.has(J),checkboxSelection:a,onRowClick:x,onRowDoubleClick:y,onCellClick:p,onSelectionChange:f,columnWidths:m,pinnedColumns:b,hasDetailPanel:c,isDetailPanelExpanded:w.has(J),detailPanelContent:w.has(J)&&C?d.jsx(xs,{getContent:C,params:{row:U,id:J,rowIndex:se}}):null,detailPanelHeight:w.has(J)?Bo(Wo(E,{row:U,id:J,rowIndex:se})):void 0,onDetailPanelHeightChange:N,onDetailPanelToggle:S,pinCheckboxColumn:M,pinExpandColumn:_,rowReordering:u,onDragStart:O.canReorderRow(J)?O.onDragStart:void 0,onDragOver:O.onDragOver,onDragEnd:O.onDragEnd,onDrop:O.onDrop,isDragging:O.draggedRowId===J,isDragOver:O.dragOverRowId===J,editingCell:L.editingCell,onEditStart:L.startCellEdit,onEditStop:L.stopCellEdit,onEditCellValueChange:L.setEditCellValue,isCellEditable:A,focusedCellField:k!=null&&k.id===J?k.field:null,colspanMap:I,rowSpanningCaches:P,rowHeight:g,rowMeta:W.get(J),cellRange:Ji(le,se,ce,K)},J)),te&&d.jsx("div",{className:"ogx__skeleton-group",children:Array.from({length:Q}).map((U,J)=>d.jsx(so,{row:{id:`__skeleton_${J}__`,_isSkeleton:!0},columns:i,rowIndex:H+J,rowHeight:g},`__skeleton_${J}__`))})]})})}function yg(){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 Cg(){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 Ir(e){const{columns:t,visibleColumns:n,onVisibilityChange:o,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:a,showNonHideableColumns:c}=e,[u,g]=s.useState(""),h=s.useId(),[x,y]=s.useState(null),p=s.useRef(null),f=s.useMemo(()=>t.filter(_=>_.hideable!==!1),[t]),m=f.every(_=>n.has(_.field)),b=s.useMemo(()=>{const _=c?t:f;if(!u)return _;const O=u.toLowerCase();return _.filter(L=>(L.headerName||L.field).toLowerCase().includes(O))},[t,f,u,c]),w=_=>{_.target.checked?r():i()},C=_=>O=>{p.current=_,O.dataTransfer.effectAllowed="move",O.dataTransfer.setDragImage(O.currentTarget.closest(".ogx-column-visibility-panel__item"),20,20)},E=_=>O=>{O.preventDefault(),O.dataTransfer.dropEffect="move",_!==p.current&&y(_)},S=()=>{y(null)},N=_=>O=>{O.preventDefault();const L=p.current;y(null),p.current=null,L&&L!==_&&l&&l(L,_)},M=()=>{y(null),p.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(yg,{}),d.jsx(et,{autoComplete:"off",inputClassName:"ogx-column-visibility-panel__search-input",placeholder:"Search",value:u,onChange:_=>g(_.target.value)})]})}),d.jsx("div",{className:"ogx-column-visibility-panel__list",children:b.map((_,O)=>{const L=`${h}-col-${O}`,A=n.has(_.field),k=_.hideable!==!1,I=x===_.field,P=!!l&&!u;return d.jsxs("div",{className:["ogx-column-visibility-panel__item",!k&&"ogx-column-visibility-panel__item--disabled",I&&"ogx-column-visibility-panel__item--drag-over"].filter(Boolean).join(" "),draggable:P,onDragOver:P?E(_.field):void 0,onDragLeave:P?S:void 0,onDrop:P?N(_.field):void 0,onDragEnd:P?M:void 0,children:[P&&d.jsx("span",{className:"ogx-column-visibility-panel__drag-handle-wrapper",draggable:!0,onDragStart:C(_.field),title:"Drag to reorder",children:d.jsx(Cg,{})}),d.jsxs("div",{className:"ogx-column-visibility-panel__item-label",style:{display:"flex",alignItems:"center",gap:"var(--ogx-spacing-md)",flex:1,cursor:k?"pointer":"not-allowed"},children:[d.jsx(Ct,{id:L,checked:A,onChange:v=>o(_.field,v.target.checked),disabled:!k}),d.jsx("label",{htmlFor:L,className:"ogx-column-visibility-panel__label",children:_.headerName||_.field})]})]},_.field)})}),d.jsxs("div",{className:"ogx-column-visibility-panel__footer",children:[d.jsxs("div",{className:"ogx-column-visibility-panel__item",children:[d.jsx(Ct,{id:`${h}-all`,checked:m,onChange:w}),d.jsx("label",{htmlFor:`${h}-all`,className:"ogx-column-visibility-panel__label",children:"Show/Hide All"})]}),d.jsx("button",{type:"button",className:"ogx-column-visibility-panel__reset-btn",onClick:()=>{r(),a?.()},children:"Reset"})]})]})}function vg({isOpen:e,containerRef:t,panelRef:n,columns:o,columnVisibilityModel:r,disableColumnReorder:i,onClose:l,onColumnVisibilityChange:a,onColumnMove:c,onColumnOrderReset:u,columnGroupingModel:g}){const[h,x]=s.useState(null);if(s.useLayoutEffect(()=>{if(!e||!t.current)return;const p=t.current.getBoundingClientRect();x({top:p.top+8,right:$t()-p.right+8,target:t.current.closest(".ogx-theme-provider")||document.body})},[e,t]),!e||!h)return null;const y=i?void 0:(p,f)=>{pr(g,p,f)&&c(p,f)};return bt.createPortal(d.jsxs("div",{ref:n,style:{position:"fixed",top:h.top,right:h.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":"Close",children:"×"}),d.jsx(Ir,{columns:o,visibleColumns:new Set(o.filter(p=>r[p.field]!==!1).map(p=>p.field)),onVisibilityChange:(p,f)=>{a({...r,[p]:f})},onShowAll:()=>{const p={...r};o.forEach(f=>{f.hideable!==!1&&(p[f.field]=!0)}),a(p)},onHideAll:()=>{const p={...r};o.forEach(f=>{f.hideable!==!1&&(p[f.field]=!1)}),a(p)},onColumnReorder:y,onColumnOrderReset:i?void 0:u})]}),h.target)}function _g(e){const{baseColumns:t,pinnedColumns:n,hasGroupingColumn:o,groupingColDef:r,isTreeData:i,getTreeDataPath:l}=e,a=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 g=l(u);return g[g.length-1]}}:{},...r,field:"__group__",hideable:!1,sortable:!1,filterable:!1,pinnable:!1,exportable:!1},...t]:t,[r,o,i,l,t]),effectivePinnedColumns:a}}function Sg(e){return e.id}function kg(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 Eg(e,t){s.useLayoutEffect(()=>{e&&(e.current=t.current)},[e,t])}function Mg(e){const{hierarchyHandlers:t,pinnedTopRows:n,sortedUnpinnedRows:o,pinnedBottomRows:r,rowMetaMap:i,getRowId:l,hierarchyField:a,dataRows:c}=e,u=t?.getVisibleRows({expandAll:!0,labelField:a});if(!u)return[...n,...o,...r];const g=c?new Set(c):null;return u.filter(h=>!i.get(l(h))?.isGroupRow&&(!g||g.has(h)))}function Ng(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 Ig(e,t){return e===t?!0:e.length!==t.length?!1:e.every((n,o)=>Ng(n,t[o]))}function Lg(e){const[t,n]=s.useState(e),o=Ig(t,e);return o||n(e),o?t:e}function Ag(e){const{rows:t,getRowId:n,rowMetaMap:o,columns:r,aggregationModel:i,aggregationResult:l,isSubtotalHidden:a}=e,c=Object.keys(i).length>0,u=new Map(r.map(y=>[y.field,y])),g=[],h=[],x=y=>{for(;h.length>0&&h[h.length-1].header.depth>=y;){const p=h.pop();c&&!a?.(p.id)&&g.push({type:"group-subtotal",depth:p.header.depth,groupField:p.header.groupField,groupValue:p.header.groupValue,groupLabel:p.header.groupLabel,aggregatedValues:jn(p.leaves,i,u,"getGroupedExportRows")})}};for(const y of t){const p=n(y),f=o.get(p);if(!f?.isGroupFooter)if(f?.isGroupRow){const m=f.treeDepth??0;x(m);const b={type:"group-header",depth:m,groupField:f.groupingField,groupValue:f.groupingValue,groupLabel:f.groupLabel};g.push(b),h.push({id:p,header:b,leaves:[]})}else g.push({type:"leaf",depth:f?.treeDepth??h.length,row:y}),h.forEach(m=>m.leaves.push(y))}return x(0),c&&l&&g.push({type:"grand-total",depth:0,aggregatedValues:l}),g}function Tg(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:a,rowGroupingHandlers:c,rowMetaMap:u,columns:g,getRowId:h,hierarchyField:x}=o();return a?Ag({rows:c.getVisibleRows({expandAll:!0,labelField:x})??[],getRowId:h,rowMetaMap:u,columns:g,aggregationModel:l,aggregationResult:r&&c.rootAggregationPosition!==null?i:null,isSubtotalHidden:y=>c.aggregationPositions.get(y)===null}):null}},[t])}const Pg=new Set(["__group__","__check__","__actions__"]);function Gt(e){return e.filter(t=>t.exportable!==!1&&!t.isSpacer&&!Qe(t.field)&&!Pg.has(t.field))}function _t(e){return!!e&&e.length>0}function Cs(e,t,n=o=>o.id){const o=new Set(t);return e.filter(r=>o.has(n(r)))}function En(e,t,n){return _t(t)?Cs(e,t,n):e}function Mn(e,t){return!!e&&e.length>0&&!_t(t)}function Qt(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 jn(e,r,i,"export")}function Nn(e,t){const n=e[t.field];return t.valueGetter?t.valueGetter({row:e,field:t.field,value:n}):n}function In(e,t,n){if(!t.valueFormatter)return Go(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 Lr(e,t,n,o){return n==null?"":Un(n,t??"",e,o)}function en(e,t){return t?`${e}: ${t}`:e}function vs(e,t){const n={};return t.forEach(o=>{Object.prototype.hasOwnProperty.call(e,o.field)&&(n[o.field]=e[o.field])}),n}const Fg=/^[=+\-@\t\r]/,Og=/^[-+]?(?=[\d.,\s]*\d)[\d.,\s]*%?$/;function ao(e,t=!1){return t||!Fg.test(e)||Og.test(e)?e:`'${e}`}function St(e){return typeof e=="number"||typeof e=="bigint"||typeof e=="boolean"||e instanceof Date}function Pe(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Dg(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 $g=/[\\/?*:[\]]/g,_s=31;function Ar(e,t=new Set){let n=Dg(String(e??"").replace($g,"-").trim()).trim();n||(n="Sheet"),n=n.slice(0,_s).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,_s-l.length).trim()}${l}`}return t.add(r.toLowerCase()),r}const Gg=new Set([Ze,Ft,Pt]),Hg=/[\t\n\r"]/;function Tr(e){return Hg.test(e)?`"${e.replace(/"/g,'""')}"`:e}function Bg(e){return Gt(e).filter(t=>!Gg.has(t.field))}function Wg(e,t){const n=t.map(r=>Tr(r.headerName||r.field)).join(" "),o=e.map(r=>t.map(i=>Tr(In(r,i,Me(r,i.field,i)))).join(" "));return[n,...o].join(`
|
|
6
|
-
|
|
7
|
-
`)}function Ss(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 Pr(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(Ss(e))return;throw n}if(!Ss(e))throw new Error("Clipboard API not available and fallback failed.")}function Kg(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 jg(e){const t=s.useRef(e);s.useLayoutEffect(()=>{t.current=e});const n=s.useCallback(async()=>{const{getSelectedRowIds:r,getColumns:i,getRows:l,getRowId:a}=t.current,c=new Set(r());if(c.size===0)return;const u=l().filter(h=>c.has(a(h)));if(u.length===0)return;const g=Wg(u,Bg(i()));await Pr(g)},[]),o=!!e.disableKeyboardShortcut;return s.useEffect(()=>{if(o)return;const r=i=>{if(i.defaultPrevented||!Kg(i))return;const l=document.activeElement,a=l?.tagName.toLowerCase(),c=l?.type;if(a==="input"&&c!=="checkbox"&&c!=="radio"||a==="textarea"||a==="select"||l?.isContentEditable)return;const{getRootElement:u}=t.current;if(u){const y=u();if(!y||!l||!y.contains(l))return}const g=window.getSelection();if(g&&!g.isCollapsed&&g.toString()!=="")return;const{getShortcutText:h}=t.current;(h?()=>{const y=h();return y===null?Promise.resolve():Pr(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 Ug(e){const{apiRef:t,columns:n,getRowId:o,containerRef:r,disableKeyboardShortcut:i,getCellRangeCopyText:l}=e,a=s.useCallback(()=>r.current,[r]),{copySelectedRows:c}=jg({getSelectedRowIds:()=>t.current.getSelectedRows(),getColumns:()=>n,getRows:()=>t.current.getAllFilteredRows(),getRowId:o,getRootElement:a,disableKeyboardShortcut:i,getShortcutText:l});s.useLayoutEffect(()=>{t.current.copySelectedRows=c},[c,t])}function Rg(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:a}=n.current,c=i.current;if(c&&(o!==void 0&&o>=0&&Kn(c,o,l.cumulativeHeights,l.pinnedBottomHeight,a),r!==void 0&&r>=0)){const g=[...l.leftPinnedCols,...l.unpinnedColsWithWidth,...l.rightPinnedCols][r];if(!g)return;Vo(c,l.unpinnedColsWithWidth.findIndex(h=>h.field===g.field),l)}}},[t])}const qg=".ogx";function ks(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,a)=>l+(parseFloat(a)||0),0);return o+i}function Xg(e,t){const n=typeof CSS<"u"&&CSS.escape?CSS.escape(t):t.replace(/["\\]/g,"\\$&"),o=l=>l.closest(qg)===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 a=l.querySelector(".ogx__header-cell-content");a&&i(ks(l,a))}),e.querySelectorAll(`[role="gridcell"][data-field="${n}"]`).forEach(l=>{if(!o(l)||l.hasAttribute("aria-colspan"))return;const a=l.querySelector(":scope > .ogx__cell-content");a&&i(ks(l,a))}),r===null?null:Math.ceil(r)}function Yg(e,t,n){return Math.max(t??kl,Math.min(n??1/0,e))}function Jg(e){const{apiRef:t}=e,n=s.useRef(e);s.useLayoutEffect(()=>{n.current=e});const o=s.useCallback(i=>{const{containerRef:l,columns:a,onColumnResize:c}=n.current,u=l.current;if(!u)return;const g=[];for(const h of i??a.map(x=>x.field)){const x=a.find(p=>p.field===h);if(!x||x.resizable===!1)continue;const y=Xg(u,h);y!==null&&g.push([h,Yg(y,x.minWidth,x.maxWidth)])}for(const[h,x]of g)c(h,x)},[]),r=s.useCallback(i=>o([i]),[o]);return s.useLayoutEffect(()=>{t.current.autosizeColumn=r,t.current.autosizeColumns=o},[t,r,o]),r}const Es="ogx--range-dragging",kt=32,Zg=40,Qg=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 Fr(e){const t=e.getSelection();t&&t.rangeCount>0&&t.removeAllRanges()}const Ns=(e,t,n)=>Math.min(Math.max(e,t),n),co=e=>Math.min(Zg,Math.max(2,Math.round(e/2)));function ep(e){process.env.NODE_ENV!=="production"&&console.warn(`[OpenGridX] Copying ${e} cells. For ranges this large, exportToCsv or exportToExcel is the better tool.`)}function tp(e){const{enabled:t,model:n,allRenderableRows:o,getRowId:r,navigationColumns:i,columnIndexMap:l,spanning:a,rowMetaMap:c,localeText:u,showStats:g}=e,h=t&&n.length>0?n[0]:null,x=s.useMemo(()=>t?i.filter(T=>Ye(T.field)):[],[t,i]),y=s.useMemo(()=>{if(!a.hasColSpan&&!a.hasRowSpan)return;const{colspanMap:T,rowSpanningCaches:$,getSpanOrigin:F}=a;return{getSpanOrigin:F,getColSpan:(Z,G)=>{const Y=T.get(Z)?.[G];return Y&&!Y.spannedByColSpan?Y.cellProps.colSpan:1},getRowSpan:(Z,G)=>$.spannedCells[Z]?.[G]??1}},[a]),p=s.useMemo(()=>{if(!t)return null;const T=o.map(r),$=new Map;T.forEach((Z,G)=>{$.has(Z)||$.set(Z,G)});const F=x.map(Z=>Z.field);return{rowIds:T,rowIndexById:$,fields:F,colIndexByField:new Map(F.map((Z,G)=>[Z,G])),spans:y}},[t,o,r,x,y]),f=s.useMemo(()=>h&&p?Qn(h,p):null,[h,p]),m=f!==null&&Ot(f)>1,b=s.useMemo(()=>{if(!f||!m||!p)return null;const T=l.get(p.fields[f.left]),$=l.get(p.fields[f.right]);return T===void 0||$===void 0?null:{top:f.top,bottom:f.bottom,left:T,right:$}},[f,m,p,l]),w=s.useCallback(T=>Xe(T,c),[c]),C=s.useCallback((T,$,F)=>{if(p)for(let Z=T.top;Z<=T.bottom;Z++){const G=o[Z],Y=p.rowIds[Z];if(!(!G||w(Y))){$(G,Y);for(let j=T.left;j<=T.right;j++){const q=x[j],ne=y?.getSpanOrigin(Y,q.field);F(G,Y,q,ne!=null&&(ne.rowId!==Y||ne.field!==q.field))}}}},[p,o,x,y,w]),E={...e,range:h,resolved:f,context:p,rangeColumns:x,forEachCell:C},S=s.useRef(E);s.useLayoutEffect(()=>{S.current=E});const N=s.useRef(null),M=s.useCallback(T=>{N.current=T},[]),_=s.useCallback(()=>{const{getPendingModel:T,model:$}=S.current;return T()??$},[]),O=s.useCallback(()=>{const{context:T,range:$,resolved:F,enabled:Z}=S.current,G=Z?_()[0]??null:null;return!G||!T?{range:null,resolved:null}:G===$?{range:G,resolved:F}:{range:G,resolved:Qn(G,T)}},[_]),L=s.useCallback((T,$)=>{if(!S.current.enabled)return;const F=T.length>1?T.slice(0,1):T;Cc(F,_())||S.current.onModelChange(F,$)},[_]),A=s.useCallback((T,$,F)=>{L([{anchor:T,head:$}],F)},[L]),k=s.useCallback((T,$)=>{const{viewportRef:F,layout:Z,rowHeight:G,pinnedTopRowCount:Y}=S.current,j=F.current;j&&(Kn(j,T-Y,Z.cumulativeHeights,Z.pinnedBottomHeight,G),Vo(j,Z.unpinnedColsWithWidth.findIndex(q=>q.field===$),Z))},[]),I=s.useCallback((T,$,F,Z)=>{const{context:G}=S.current,{range:Y,resolved:j}=O();if(!G||Z.id===null||!Ye(Z.field))return!1;const q=G.rowIndexById.get(Z.id),ne=G.colIndexByField.get(Z.field);if(q===void 0||ne===void 0)return!1;const he=Y&&j&&yt(Y.anchor,{id:Z.id,field:Z.field})?{range:Y,resolved:j}:null,me=he?he.range.anchor:{id:Z.id,field:Z.field},R=he?.resolved??Qn({anchor:me,head:me},G);if(!R)return!1;const ge=_c(R,T,$,F,G.rowIds.length-1,G.fields.length-1);if(!ge)return!0;const we={id:G.rowIds[ge.row],field:G.fields[ge.col]};return A(me,we,"keyboard"),k(ge.row,we.field),!0},[O,A,k]),P=s.useCallback(()=>{const{range:T,resolved:$}=O();return!T||!$||Ot($)<=1?!1:(A(T.anchor,T.anchor,"keyboard"),!0)},[O,A]),v=s.useCallback(()=>{const{context:T}=S.current;return!T||T.rowIds.length===0||T.fields.length===0?!1:(A({id:T.rowIds[0],field:T.fields[0]},{id:T.rowIds[T.rowIds.length-1],field:T.fields[T.fields.length-1]},"selectAll"),!0)},[A]),B=s.useCallback(()=>{const{context:T}=S.current,{range:$,resolved:F}=O();if(!T)return null;if(F)return F;if($)return null;const Z=N.current;return!Z||Z.id===null||!Ye(Z.field)?null:Qn({anchor:{id:Z.id,field:Z.field},head:{id:Z.id,field:Z.field}},T)},[O]),V=s.useCallback(()=>{const T=B();if(!T)return null;const{rangeColumns:$,forEachCell:F}=S.current,Z=Ot(T);Z>Mc&&ep(Z);const G=[];if(F(T,he=>{G.push(he)},()=>{}),G.length===0)return null;const Y=$.slice(T.left,T.right+1),j=S.current.context?.spans,q=S.current.getRowId;return zg(G,Y,j?(he,me)=>{const R=q(he),ge=j.getSpanOrigin(R,me.field);return ge!==null&&(ge.rowId!==R||ge.field!==me.field)}:void 0)},[B]),Q=s.useCallback(()=>{const{forEachCell:T}=S.current,{resolved:$}=O();if(!$)return[];const F=[];return T($,()=>{},(Z,G,Y,j)=>{j||F.push({id:G,field:Y.field,value:Me(Z,Y.field,Y)})}),F},[O]),H=s.useRef(null),z=s.useRef(!1);s.useEffect(()=>()=>H.current?.stop(),[]);const W=s.useCallback((T,$,F)=>{const Z=S.current.context;if(!Z)return null;const G=T.ownerDocument;if(typeof G.elementFromPoint!="function")return null;const Y=Ms(G.elementFromPoint($,F),T);if(!Y)return null;const j=Z.rowIds[Y.rowIndex];if(j===void 0)return null;const q=Ye(Y.field)?Y.field:Z.fields[0];return q===void 0?null:{id:j,field:q}},[]),re=s.useCallback((T,$)=>{const{context:F,layout:Z,pinnedTopRowCount:G}=S.current,Y=Z.cumulativeHeights;if(!F||Y.length===0||T<0)return null;let j=0,q=Y.length-1;for(;j<q;){const he=j+q>>1;Y[he]>T?q=he:j=he+1}const ne=F.rowIds[j+G];return ne===void 0?null:{id:ne,field:$}},[]),oe=s.useRef(()=>{}),fe=s.useCallback(T=>{const $=H.current,F=S.current.viewportRef.current;if(!$||!F)return;$.frame=0;const{layout:Z}=S.current,G=F.getBoundingClientRect(),Y=F.clientWidth,j=F.clientHeight,q=F.querySelector(":scope > .ogx__content > .ogx__sticky-top"),ne=F.querySelector(":scope > .ogx__content > .ogx__sticky-bottom"),he=q?.querySelector(":scope > .ogx__header-wrap"),me=q?q.getBoundingClientRect().bottom:G.top,R=Math.min(G.top+j,ne?ne.getBoundingClientRect().top:G.top+j),ge=he?he.getBoundingClientRect().bottom:me;$.rtl===void 0&&($.rtl=Je(F));const we=$.rtl,ae=we?G.right-Y:G.left,ye=Z.pinnedSystemColumnsWidth+Z.leftWidth,xe=ae+(we?Z.rightWidth:ye),ie=ae+Y-(we?ye:Z.rightWidth),Ce=Ns($.x,ae+1,ae+Y-2);let Ee=$.y;(Ee<G.top||Ee>G.top+j||Ee<ge)&&(Ee=Ns(Ee,me+1,Math.max(me+1,R-2)));const Le=typeof F.ownerDocument.elementFromPoint=="function",Ne=W(F,Ce,Ee)??(Le&&$.moved?re(Ee-G.top-(q?q.getBoundingClientRect().height:0)+F.scrollTop,$.head.field):null);if(Ne&&!yt(Ne,$.head)&&($.head=Ne,!$.moved&&!yt(Ne,$.anchor)&&($.moved=!0,S.current.containerRef.current?.classList.add(Es),Fr(F.ownerDocument)),$.onTrack||A($.anchor,Ne,"pointer")),$.onTrack&&$.onTrack($.head,$.x,$.y),!T)return;const ke=$.y<me||$.y>R||$.x<ae||$.x>ae+Y;if(!$.moved&&!ke)return;let Fe=0,pe=0;$.y<me+kt?Fe=-co(me+kt-$.y):$.y>R-kt&&(Fe=co($.y-(R-kt))),$.x<xe+kt?pe=-co(xe+kt-$.x):$.x>ie-kt&&(pe=co($.x-(ie-kt)));const ve=Fe<0&&F.scrollTop>0||Fe>0&&F.scrollTop+j<F.scrollHeight-1,Se=F.scrollWidth-Y,be=we?-Se:0,De=pe<0&&F.scrollLeft>be||pe>0&&F.scrollLeft<be+Se-1;!ve&&!De||(ve&&(F.scrollTop+=Fe),De&&(F.scrollLeft+=pe),$.frame=requestAnimationFrame(()=>oe.current(!0)))},[W,re,A]);s.useLayoutEffect(()=>{oe.current=fe},[fe]);const le=s.useCallback((T,$,F,Z,G,Y)=>{H.current?.stop();const j=Y?"pointermove":"mousemove",q=Y?"pointerup":"mouseup",ne=ie=>!Y||ie.pointerId===Y.pointerId,he=ie=>{const Ce=H.current;if(!(!Ce||!ne(ie))){if(ie.buttons===0){Ce.stop();return}Ce.x=ie.clientX,Ce.y=ie.clientY,Ce.moved&&(ie.preventDefault(),Fr(G)),Ce.frame||(Ce.frame=requestAnimationFrame(()=>fe(!0)))}},me=ie=>{const Ce=H.current;if(!Ce||!ne(ie))return;Ce.x=ie.clientX,Ce.y=ie.clientY,fe(!1);const Ee=Ce.moved;Ce.stop(!1,ie.altKey),Ee&&Fr(G),Ee&&(z.current=!0,setTimeout(()=>{z.current=!1},0))},R=ie=>{ne(ie)&&H.current?.stop()},ge=ie=>{ie.key!=="Escape"||!H.current||(ie.preventDefault(),ie.stopPropagation(),H.current.stop())},we=G.defaultView,ae=()=>H.current?.stop();let ye=!1;const xe={anchor:T,head:$,x:F,y:Z,frame:0,moved:!1,onTrack:Y?.onTrack,stop:(ie=!0,Ce=!1)=>{xe.frame&&cancelAnimationFrame(xe.frame),xe.frame=0,G.removeEventListener(j,he,!0),G.removeEventListener(q,me,!0),Y&&(G.removeEventListener("pointercancel",R,!0),G.removeEventListener("keydown",ge,!0)),we?.removeEventListener("blur",ae),S.current.containerRef.current?.classList.remove(Es),H.current===xe&&(H.current=null),ye||(ye=!0,Y&&Y.onEnd({cancelled:ie,altKey:Ce}))}};H.current=xe,G.addEventListener(j,he,!0),G.addEventListener(q,me,!0),Y&&(G.addEventListener("pointercancel",R,!0),G.addEventListener("keydown",ge,!0)),we?.addEventListener("blur",ae)},[fe]),ce=s.useCallback(T=>{const $=S.current.viewportRef.current;if(!$||!S.current.enabled)return;const{start:F,x:Z,y:G,pointerId:Y,onTrack:j,onEnd:q}=T;le(F,F,Z,G,$.ownerDocument,{pointerId:Y,onTrack:j,onEnd:q})},[le]),K=s.useCallback(T=>{if(T.button!==0||T.defaultPrevented)return;const{context:$}=S.current;if(!$)return;const F=T.currentTarget,Z=Ms(T.target,F);if(!Z||!Ye(Z.field)||T.target.closest?.(".ogx__cell-fill-handle")||Z.element.classList.contains("ogx__cell--editing")||Ui(T.target))return;const G=$.rowIds[Z.rowIndex];if(G===void 0)return;const Y={id:G,field:Z.field};let j=Y;if(T.shiftKey){const q=_()[0],ne=N.current;q&&$.rowIndexById.has(q.anchor.id)&&$.colIndexByField.has(q.anchor.field)?j=q.anchor:ne&&ne.id!==null&&Ye(ne.field)&&(j={id:ne.id,field:ne.field}),T.preventDefault(),z.current=!0;const he=F.ownerDocument;F.contains(he.activeElement)||F.focus({preventScroll:!0})}if(A(j,Y,"pointer"),le(j,Y,T.clientX,T.clientY,F.ownerDocument),T.shiftKey){const q=H.current;q&&!yt(j,Y)&&(q.moved=!0)}},[_,A,le]),de=s.useCallback(T=>{z.current&&(z.current=!1,T.stopPropagation(),T.preventDefault())},[]),X=f?f.right-f.left+1:0,te=f?f.bottom-f.top+1:0,U=u?.cellSelectionAnnouncement??Ec,J=m?U(te*X,te,X):"",[se,ue]=s.useState("");s.useEffect(()=>{if(!t)return;const T=setTimeout(()=>ue(J),Qg);return()=>clearTimeout(T)},[t,J]);const ee=s.useMemo(()=>{if(!g||!f||!m)return null;const T=[];C(f,()=>{},(F,Z,G,Y)=>{Y||T.push(Me(F,G.field,G))});const $=T.filter(F=>typeof F=="number"&&!Number.isNaN(F));return{cellCount:Ot(f),rowCount:f.bottom-f.top+1,columnCount:f.right-f.left+1,count:xt.count(T),numericCount:$.length,sum:$.length?xt.sum($):null,average:$.length?xt.avg($):null}},[g,f,m,C]),D=s.useMemo(()=>t?{extendSelection:I,collapseSelection:P,selectAllCells:v}:void 0,[t,I,P,v]);return{enabled:t,range:h,resolved:f,displayRange:b,hasRowSpan:a.hasRowSpan,handleMouseDown:t?K:void 0,handleClickCapture:t?de:void 0,extendSelection:I,collapseSelection:P,selectAllCells:v,keyboard:D,getCopyText:V,getSelectedCells:Q,announcement:t?se:"",stats:ee,reportFocus:M,setModel:L,getCurrentRange:O,startTrackedDrag:ce}}function np(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:a,focusedCell:c,setFocusedCell:u,containerRef:g}=e,h=l.range?.anchor??null,x=l.resolved?.anchorRow;s.useLayoutEffect(()=>{l.reportFocus(c);const y=!yt(o.current,h),p=!or(r.current,c);if(o.current=h,r.current=c,!!l.enabled){if(l.range&&!l.resolved){i.current!==a&&(i.current=a,l.setModel([],"dataChange"));return}if(y&&h){(!c||c.id!==h.id||c.field!==h.field)&&u({id:h.id,field:h.field,rowIndex:x});return}if(p&&c&&c.id!==null&&Ye(c.field)&&!yt(h,{id:c.id,field:c.field})){const f={id:c.id,field:c.field},m=g.current?.classList.contains("ogx--kb")??!1;l.setModel([{anchor:f,head:f}],m?"keyboard":"pointer")}}},[l,a,h,x,c,u,g]),s.useLayoutEffect(()=>{const y=t.current,p=()=>n.current;y.getCellSelectionModel=()=>{const{selection:f,getPendingModel:m,model:b}=p();return f.enabled?m()??b:[]},y.setCellSelectionModel=f=>{p().selection.setModel(f,"api")},y.selectCellRange=(f,m)=>{p().selection.setModel([{anchor:f,head:m}],"api")},y.clearCellSelection=()=>{p().selection.setModel([],"clear")},y.getSelectedCells=()=>p().selection.getSelectedCells(),y.copySelectedCells=async()=>{const{selection:f}=p();if(!f.enabled)return;const m=f.getCopyText();m!==null&&await Pr(m)}},[t])}function Is({count:e,sum:t,average:n}){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:"Count"}),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:"Sum"}),d.jsx("span",{className:"ogx__cell-selection-stat-value","data-stat":"sum",children:yn(t,"sum")})]}),n!==null&&d.jsxs("span",{className:"ogx__cell-selection-stat",children:[d.jsx("span",{className:"ogx__cell-selection-stat-label",children:"Average"}),d.jsx("span",{className:"ogx__cell-selection-stat-value","data-stat":"average",children:yn(n,"avg")})]})]})}function op({stats:e,apiRef:t,slot:n,slotProps:o}){const r=n??Is;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 rp(e){return s.useCallback(t=>{e.current?.classList.toggle("ogx--kb",t)},[e])}function ip(e){const{ensureGridFocus:t,setKeyboardMode:n,setFocusedCell:o,getRowId:r,onCellClick:i}=e,l=s.useCallback(c=>{t(),n(!1),o({id:r(c.row),field:c.field,rowIndex:c.rowIndex}),i?.(c)},[i,n,o,t,r]),a=s.useCallback(c=>{t(),o({id:null,field:c}),n(!1)},[t,o,n]);return{handleCellClick:l,handleHeaderClick:a}}function lp({paginationSlot:e,paginationSlotProps:t,page:n,paginationModel:o,rowCount:r,pageSizeOptions:i,onPaginationModelChange:l,localeText:a}){const c=e||kr;return d.jsx(c,{page:n,pageSize:o.pageSize,rowCount:r,pageSizeOptions:i,onPageChange:u=>l({...o,page:u}),onPageSizeChange:u=>l({...o,pageSize:u,page:0}),localeText:ll(a),...t})}function sp({loading:e,error:t,noRowsLabel:n,filteredRowCount:o,dataRowCount:r,filterModel:i,cellSelectionAnnouncement:l,aiAssistantAnnouncement:a}){return d.jsxs("div",{className:"ogx-aria-live-status",role:"status","aria-live":"polite",children:[e?"Loading data...":"",t?`Error: ${_l(t)}`:"",!e&&!t&&(o===0?n:i&&((i.quickFilterValues?.length||0)>0||(i.items?.length||0)>0)?`${r} ${r===1?"row":"rows"} found`:""),l?d.jsxs("span",{className:"ogx-aria-live-status__cells",children:[" ",l]}):null,a?d.jsxs("span",{className:"ogx-aria-live-status__ai",children:[" ",a]}):null]})}function ap(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 cp(e){const{columnGroupingModel:t,headerFilterRow:n=!1,pinnedTopCount:o,pinnedBottomCount:r,pagination:i,paginationMode:l,paginationModel:a,paginationRowCount:c,paginatedUnpinnedRowCount:u,sortedUnpinnedRowCount:g}=e,{page:h,pageSize:x}=a;return s.useMemo(()=>ap({headerRowCount:1+El(t)+(n?1:0),pinnedTopCount:o,pinnedBottomCount:r,pageRowCount:i?u:g,totalCenterRowCount:i&&l==="server"?Math.max(c,u):g,pageOffset:i?h*x:0}),[t,n,o,r,i,u,g,l,c,h,x])}function dp(e){const{toolbar:t,toolbarSlotProps:n,apiRef:o,orderedColumns:r,baseColumns:i,aggregationModel:l,onAggregationModelChange:a,pivotMode:c,pivotModelProp:u,onPivotModelChangeProp:g,pivotModel:h,onPivotModelChange:x,filterModel:y,onFilterModelChange:p,columnVisibilityModel:f,onColumnVisibilityModelChange:m,disableColumnReorder:b,columnGroupingModel:w,moveColumn:C,resetColumnOrder:E,forceColumnsOpen:S,onColumnsPanelClose:N,aiAssistantEnabled:M=!1,aiAssistantOpen:_=!1,onAiAssistantToggle:O,aiAssistantLabel:L,forceFiltersOpen:A,onFiltersPanelClose:k}=e;return s.useMemo(()=>t?{apiRef:o,columns:r,baseColumns:i,aggregationModel:l,onAggregationModelChange:a,...c||u||g?{pivotModel:h,onPivotModelChange:x}:{},filterModel:y,onFilterModelChange:p,columnVisibilityModel:f,onColumnVisibilityModelChange:m,onColumnReorder:b?void 0:(P,v)=>{pr(w,P,v)&&C(P,v)},onColumnOrderReset:b?void 0:E,forceColumnsOpen:S,onColumnsPanelClose:N,...M&&O?{onAiAssistantToggle:O,aiAssistantOpen:_,...L?{aiAssistantLabel:L}:{}}:{},forceFiltersOpen:A,onFiltersPanelClose:k,...n}:null,[t,b,C,E,r,o,i,l,a,c,u,g,h,x,y,p,f,m,S,N,n,w,M,_,O,L,A,k])}const up=Symbol.for("opengridx.ai.validated");function fp(e){return typeof e=="object"&&e!==null&&e[up]===!0}const uo=["filter","sort","grouping","aggregation","pivot","columnVisibility"],Or={filter:"filterModel",sort:"sortModel",grouping:"rowGroupingModel",aggregation:"aggregationModel",pivot:"pivotModel",columnVisibility:"columnVisibilityModel"};function Ls(e){return uo.map(t=>Or[t]).filter(t=>e[t]!==void 0)}function gp(e,t){const n={},o=[];for(const r of uo){const i=Or[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 pp(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 hp(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=>hp(typeof r.path=="string"?r.path:""))),o={};for(const r of Ls(e))n.has(r)&&pp(e,r)||Object.assign(o,{[r]:e[r]});return o}function wp(e,t){const n={};for(const o of Ls(e))Object.assign(n,{[o]:t[o]});return n}function As(e,t){const n={};for(const o of uo.map(r=>Or[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 Dr(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 Ts(e){return Array.isArray(e)?e.map(Ts).join(", "):e instanceof Date?e.toISOString().slice(0,10):e==null?"":String(e)}function Ps(e,t){return"items"in e?`(${e.items.map(n=>Ps(n,t)).join(` ${e.logicOperator} `)})`:[t(e.field),e.operator,Ts(e.value)].filter(Boolean).join(" ")}const bp={sum:"Sum",avg:"Average",count:"Count",min:"Min",max:"Max",unique:"Unique"};function Fs(e,t){const n=[],{filterModel:o,sortModel:r,rowGroupingModel:i,aggregationModel:l,pivotModel:a,columnVisibilityModel:c}=e;if(o){const u=o.items??[];u.forEach((h,x)=>n.push({id:`filter:${x}`,part:"filter",label:Ps(h,t)}));const g=o.quickFilterValues??[];g.length>0&&n.push({id:"filter:quick",part:"filter",label:`Search: ${g.join(" ")}`}),u.length===0&&g.length===0&&n.push({id:"filter:clear",part:"filter",label:"No filters"})}if(r&&(r.forEach((u,g)=>n.push({id:`sort:${g}`,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,g)=>n.push({id:`grouping:${g}`,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(g=>{const h=l[g];n.push({id:`aggregation:${g}`,part:"aggregation",label:`${bp[h]??h}: ${t(g)}`})}),u.length===0&&n.push({id:"aggregation:clear",part:"aggregation",label:"No summaries"})}if(a){const u=[...a.rowFields,...a.columnFields,...a.valueFields.map(g=>g.field)];n.push({id:"pivot",part:"pivot",label:u.length>0?`Pivot: ${u.map(t).join(", ")}`:"No pivot"})}if(c)for(const u of Object.keys(c))n.push({id:`columnVisibility:${u}`,part:"columnVisibility",label:`${c[u]?"Show":"Hide"}: ${t(u)}`});return n}function xp(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 a={...n.filterModel};i==="quick"?delete a.quickFilterValues:i==="clear"?a.items=[]:a.items=(a.items??[]).filter((c,u)=>u!==l),(a.items??[]).length===0&&(a.quickFilterValues??[]).length===0?delete n.filterModel:n.filterModel=a}else if(r==="sort"&&n.sortModel)n.sortModel=n.sortModel.filter((a,c)=>c!==l),(n.sortModel.length===0||i==="clear")&&delete n.sortModel;else if(r==="grouping"&&n.rowGroupingModel)n.rowGroupingModel=n.rowGroupingModel.filter((a,c)=>c!==l),(n.rowGroupingModel.length===0||i==="clear")&&delete n.rowGroupingModel;else if(r==="aggregation"&&n.aggregationModel){const a={...n.aggregationModel};delete a[i],Object.keys(a).length===0?delete n.aggregationModel:n.aggregationModel=a}else if(r==="columnVisibility"&&n.columnVisibilityModel){const a={...n.columnVisibilityModel};delete a[i],Object.keys(a).length===0?delete n.columnVisibilityModel:n.columnVisibilityModel=a}else r==="pivot"&&delete n.pivotModel;return n}const yp="Ask about this table…",Cp=[],fo=[],Os="The reply was not validated";function vp(){return typeof window<"u"&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window)}function _p(e){return typeof e=="object"&&e!==null&&e.name==="AbortError"}function Sp(e){return e instanceof Error&&e.message?e.message:"Unknown error"}function kp(e,t){const n=e===0?"No changes":`Applied ${e} ${e===1?"change":"changes"}`;return t>0?`${n}, ${t} ignored`:n}function Ds(e,t,n){if(!e)return;const o=Ve(()=>e(t));!o.ok&&process.env.NODE_ENV!=="production"&&console.warn(`[OpenGridX] ${n} threw.`,o.error)}function Ep(e){const{apiRef:t,options:n,columns:o}=e,r=!!n,[i,l]=s.useState(!1),[a,c]=s.useState("idle"),[u,g]=s.useState(""),[h,x]=s.useState(null),[y,p]=s.useState(fo),[f,m]=s.useState(null),[b,w]=s.useState([]),C=s.useRef(null),E=s.useRef(null),S=s.useRef({params:e,applied:f,history:b,open:i});s.useLayoutEffect(()=>{S.current={params:e,applied:f,history:b,open:i}});const N=s.useMemo(()=>{const z=new Map(o.map(W=>[W.field,W.headerName||W.field]));return W=>z.get(W)??W},[o]),M=s.useMemo(()=>f?Fs(f.state,N):[],[f,N]),_=s.useCallback(()=>{const z=C.current;C.current=null,z&&z.abort()},[]);s.useEffect(()=>_,[_]);const O=s.useCallback(z=>{if(!S.current.params.options)return;const W=typeof document>"u"?null:document.activeElement;E.current=z??(W instanceof HTMLElement?W:null),l(!0)},[]),L=s.useCallback(()=>{C.current&&(_(),c("stopped"),g("Stopped")),l(!1);const z=E.current;E.current=null,z&&z.isConnected&&z.focus()},[_]),A=s.useCallback(z=>{S.current.open?L():O(z)},[O,L]),k=s.useCallback((z,W)=>{c("error"),g(z),x(null),p(fo),Ds(S.current.params.onError,W,"onAiAssistantError")},[]),I=s.useCallback((z,W)=>{const{params:re}=S.current;if(!(typeof W=="object"&&W!==null)||!fp(W.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."),k(Os,new Error(Os));return}const fe=gp(W.state,re.options?.parts??uo),le=[...Array.isArray(W.errors)?W.errors:[],...fe.errors],ce=mp(fe.state,le),K=t.current,de=wp(ce,K.getGridAiState());Dr(K,As(ce,de)),m({state:ce,previous:de}),p(le),x(typeof W.message=="string"&&W.message?W.message:null),w(X=>[...X,{prompt:z,applied:ce}]),c("applied"),g(kp(Fs(ce,X=>X).length,le.length)),Ds(re.onApply,W,"onAiAssistantApply")},[t,k]),P=s.useCallback(z=>{const W=z.trim(),{params:re,history:oe}=S.current,fe=re.options?.onPrompt;if(!W||!fe)return;_();const le=new AbortController;C.current=le,c("running"),g("Thinking…"),x(null),p(fo);const ce={currentState:t.current.getGridAiState(),history:oe,signal:le.signal},K=Ve(()=>fe(W,ce));(K.ok?Promise.resolve(K.value):Promise.reject(K.error)).then(X=>{C.current===le&&(C.current=null,I(W,X))},X=>{if(C.current===le){if(C.current=null,le.signal.aborted||_p(X)){c("stopped"),g("Stopped");return}k(`The assistant could not answer: ${Sp(X)}`,X)}})},[t,_,I,k]),v=s.useCallback(()=>{C.current&&(_(),c("stopped"),g("Stopped"))},[_]),B=s.useCallback(()=>{const z=S.current.applied;z&&(Dr(t.current,z.previous),m(null),p(fo),x(null),c("idle"),g("Undone"))},[t]),V=s.useCallback(z=>{const W=S.current.applied;if(!W)return;const re=xp(W.state,z);Dr(t.current,As(re,W.previous)),m({state:re,previous:W.previous}),g("Change removed")},[t]);s.useLayoutEffect(()=>{const z=t.current;z.openAiAssistant=()=>O(),z.closeAiAssistant=()=>{S.current.open&&L()}},[t,O,L]);const Q=r&&i,H=s.useMemo(()=>!Q||!n?null:{status:a,statusText:u,message:h,errors:y,chips:M,history:b,suggestions:n.suggestions??Cp,placeholder:n.placeholder??yp,voiceAvailable:n.voice!==!1&&vp(),canUndo:f!==null,submit:P,stop:v,undo:B,removeChip:V,close:L},[Q,n,a,u,h,y,M,b,f,P,v,B,V,L]);return{enabled:r,open:Q,openPanel:O,togglePanel:A,closePanel:L,panelProps:H,announcement:r?u:""}}function Mp(){if(typeof window>"u")return null;const e=window;return e.SpeechRecognition??e.webkitSpeechRecognition??null}function Np(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&&Ve(()=>l.abort())},[]);const i=s.useCallback(()=>{const l=o.current;if(l){Ve(()=>l.stop());return}const a=Mp();if(!a)return;const c=Ve(()=>new a);if(!c.ok)return;const u=c.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 g=()=>{o.current===u&&(o.current=null),n(!1)};u.onend=g,u.onerror=g,o.current=u,n(!0),Ve(()=>u.start()).ok||g()},[]);return{listening:t,toggle:i}}function $s(){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 Ip(){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 Lp(e){const{status:t,statusText:n,message:o,errors:r,chips:i,history:l,suggestions:a,placeholder:c,voiceAvailable:u,canUndo:g,submit:h,stop:x,undo:y,removeChip:p,close:f}=e,[m,b]=s.useState(""),w=s.useRef(null),C=Np(b),E=t==="running";s.useEffect(()=>{w.current&&w.current.focus()},[]);const S=_=>{b(_),h(_)},N=_=>()=>{_(),w.current&&w.current.focus()},M=_=>{_.preventDefault(),E||h(m)};return d.jsxs("div",{className:"ogx-ai-panel",role:"dialog","aria-label":"Ask AI",children:[d.jsxs("div",{className:"ogx-ai-panel__header",children:[d.jsxs("span",{className:"ogx-ai-panel__title",children:[d.jsx($s,{}),"Ask AI"]}),d.jsx(nt,{size:"small",className:"ogx-ai-panel__close","aria-label":"Close",onClick:f,children:"×"})]}),d.jsxs("form",{className:"ogx-ai-panel__form",onSubmit:M,children:[d.jsx(et,{ref:w,className:"ogx-ai-panel__input",value:m,placeholder:c,"aria-label":"Prompt",autoComplete:"off",onChange:_=>b(_.target.value)}),u&&d.jsx(nt,{size:"small",variant:"outlined",className:`ogx-ai-panel__mic${C.listening?" ogx-ai-panel__mic--on":""}`,"aria-label":C.listening?"Stop dictation":"Dictate a prompt","aria-pressed":C.listening,onClick:C.toggle,children:d.jsx(Ip,{})}),E?d.jsx(nt,{size:"small",variant:"outlined",onClick:N(x),children:"Stop"},"stop"):d.jsx(nt,{size:"small",variant:"contained",color:"primary",type:"submit",disabled:m.trim()==="",children:"Ask"},"ask")]}),a.length>0&&d.jsx("div",{className:"ogx-ai-panel__suggestions","aria-label":"Suggestions",role:"group",children:a.map(_=>d.jsx("button",{type:"button",className:"ogx-ai-panel__suggestion",disabled:E,onClick:()=>S(_),children:_},_))}),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||g)&&d.jsxs("div",{className:"ogx-ai-panel__changes",children:[d.jsx("ul",{className:"ogx-ai-panel__chips","aria-label":"Applied changes",children:i.map(_=>d.jsxs("li",{className:"ogx-ai-chip","data-part":_.part,children:[d.jsx("span",{className:"ogx-ai-chip__label",children:_.label}),d.jsx("button",{type:"button",className:"ogx-ai-chip__remove","aria-label":`Remove ${_.label}`,onClick:N(()=>p(_.id)),children:"×"})]},_.id))}),g&&d.jsx(nt,{size:"small",variant:"outlined",className:"ogx-ai-panel__undo",onClick:N(y),children:"Undo"})]}),r.length>0&&d.jsx("ul",{className:"ogx-ai-panel__errors","aria-label":"Ignored",children:r.map((_,O)=>d.jsx("li",{children:_.path?`Ignored: ${_.message}`:_.message},`${_.path}:${O}`))}),l.length>0&&d.jsxs("div",{className:"ogx-ai-panel__history",children:[d.jsx("div",{className:"ogx-ai-panel__history-title",children:"Earlier"}),d.jsx("ul",{children:l.map((_,O)=>d.jsx("li",{children:d.jsx("button",{type:"button",className:"ogx-ai-panel__history-item",onClick:()=>b(_.prompt),children:_.prompt})},`${O}:${_.prompt}`))})]})]})}function Ap({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(Lp,{...e})})}function Tp(e){const{rows:t,columns:n,getRowId:o,rowHeight:r,headerHeight:i,wrapHeaderText:l=!1,headerFilters:a=!1,headerFilterHeight:c=tu,autoHeight:u=!1,density:g,checkboxSelection:h=!1,disableRowSelectionOnClick:x=!1,disableMultipleRowSelection:y=!1,disableClipboardCopy:p=!1,cellSelection:f=!1,cellSelectionModel:m,onCellSelectionModelChange:b,showCellSelectionStats:w=!1,disableClipboardPaste:C=!1,disableRangeClear:E=!1,onClipboardPaste:S,onBeforeClipboardPaste:N,undoRedo:M=!1,disableFillHandle:_=!1,onFill:O,onHistoryChange:L,rowSelectionModel:A,onRowSelectionModelChange:k,onRowClick:I,onRowDoubleClick:P,onCellClick:v,filterModel:B,onFilterModelChange:V,sortModel:Q,onSortModelChange:H,pagination:z=!1,paginationModel:W,onPaginationModelChange:re,pageSizeOptions:oe=[10,25,50,100],pinnedColumns:fe,onPinnedColumnsChange:le,pinnedRows:ce,getDetailPanelContent:K,getDetailPanelHeight:de,detailPanelExpandedRowIds:X,onDetailPanelExpandedRowIdsChange:te,pinCheckboxColumn:U=!0,pinExpandColumn:J=!0,disableColumnReorder:se=!1,columnOrder:ue,onColumnOrderChange:ee,onColumnOrderModelChange:D,height:T,rowReordering:$=!1,onRowOrderChange:F,loading:Z=!1,treeData:G=!1,getTreeDataPath:Y,defaultGroupingExpansionDepth:j,groupingColDef:q,rowGroupingModel:ne,onRowGroupingModelChange:he,aggregationModel:me,onAggregationModelChange:R,getAggregationPosition:ge,isCellEditable:we,processRowUpdate:ae,onProcessRowUpdateError:ye,dataSource:xe,multiSort:ie=!1,sortingMode:Ce="client",filterMode:Ee="client",paginationMode:Le="client",rowCount:Ie,slots:Ne,slotProps:ke,pivotMode:Fe=!1,pivotModel:pe,onPivotModelChange:ve,className:Se="",style:be,onRowsScrollEnd:De,ariaLabel:ft,initialState:Ht,onStateChange:Pn,columnVisibilityModel:ln,onColumnVisibilityModelChange:ot,listView:mo=!1,listViewColumn:Fn,columnGroupingModel:On,noRowsLabel:Yh="No Data",localeText:sn,apiRef:Jh,overscanRowCount:Zh=3,aiAssistant:Qh,onAiAssistantApply:em,onAiAssistantError:tm}=e,Hr=Lg(n),Br=sn?.noRowsLabel??Yh,Bt=Oc({initialState:Ht,sortModel:Q,onSortModelChange:H,filterModel:B,onFilterModelChange:V,aggregationModel:me,onAggregationModelChange:R,rowGroupingModel:ne,onRowGroupingModelChange:he,columnVisibilityModel:ln,onColumnVisibilityModelChange:ot,pinnedColumns:fe,onPinnedColumnsChange:le,pivotModel:pe,onPivotModelChange:ve,paginationModel:W,onPaginationModelChange:re,pageSizeOptions:oe,rowSelectionModel:A,onRowSelectionModelChange:k,density:g,cellSelectionModel:m,onCellSelectionModelChange:b}),{sortModel:gt,handleSortModelChange:fa,filterModel:pt,handleFilterModelChange:Wr,aggregationModel:Ue,handleAggregationModelChange:ga,columnVisibilityModel:Et,handleColumnVisibilityModelChange:wo,pinnedColumns:Vr,handlePinnedColumnsChange:nm,currentPivotModel:zr,handlePivotModelChange:pa,effectivePaginationModel:Re,handlePaginationModelChange:an,selectedRowIds:om,handleRowSelectionModelChange:Kr,density:ha,rowGroupingModel:jr,handleRowGroupingModelChange:rm}=Bt,Dn=Xf({rows:t,columns:Hr,pivotMode:Fe,pivotModel:zr,filterModel:pt,sortModel:gt,hasDataSource:!!xe,hierarchyRequested:G||jr.length>0}),Mt=Dn.isActive,bo=a&&!Mt,{rowReordering:Wt,hierarchyRowGroupingModel:im,isTreeDataRequested:lm,isTreeData:xo,isRowGrouping:cn,isHierarchyEnabled:yo,hasGroupingColumn:sm,pagination:rt,listView:dn}=Ac({rowGroupingModel:jr,treeData:G,hasTreeDataPath:!!Y,isPivotActive:Mt,rowReordering:$,hasGroupingColDef:!!q,pagination:z,paginationMode:Le,listView:mo,hasListViewColumn:!!Fn}),{rowHeight:it,headerHeight:Ur}=Bc({rowHeight:r,headerHeight:i,density:ha}),am=Dn.rows,cm=Dn.columns,{activeColumns:ht,effectivePinnedColumns:un}=_g({baseColumns:cm,pinnedColumns:Vr,hasGroupingColumn:sm,groupingColDef:q,isTreeData:xo,getTreeDataPath:Y}),Rr=Ed(ht,Et),[dm,um]=Uf(Ue),qe=s.useRef(null),Vt=s.useRef(null),ma=!Mt&&o||Sg,qr=rp(qe),Co=_u({rows:am,getRowId:ma,columns:ht,rowHeight:it,headerHeight:Ur,columnVisibilityModel:Et,initialState:e.initialState,syncRows:!xe}),{state:Oe,apiRef:lt,setRows:fm,replaceRows:gm,setColumns:pm,setDimensions:hm,setDataSourceLoading:mm,setDataSourceError:wm,setRowCount:bm}=Co,{getRowIdOf:Te,getRowIdOfInEvents:xm}=kg(Oe.rows.idByRow);Eg(Jh,lt);const ym=Oe.dataSource.loading,Nt=Z||ym,vo=s.useMemo(()=>Oe.rows.allRows.map(wt=>Oe.rows.idRowsLookup.get(wt)),[Oe.rows]),{treeDataHandlers:_o,rowGroupingHandlers:Xr,activeHierarchyHandlers:fn,rowMetaMap:ze}=Bu({rows:vo,getRowId:Te,getTreeDataPath:Y,isTreeDataRequested:lm,isTreeData:xo,columns:ht,rowGroupingModel:im,isRowGrouping:cn,aggregationModel:Ue,defaultGroupingExpansionDepth:j,filterModel:pt,sortModel:gt,getAggregationPosition:ge,columnLookup:Rr,filterMode:Ee,sortingMode:Ce}),Yr=df(),So=Vu({rowsLookup:Oe.rows.idRowsLookup,columns:ht,processRowUpdate:ae,onProcessRowUpdateError:ye,replaceRows:gm,onCommitted:Yr.emit}),$n=Wu({rows:vo,getRowId:Te,columns:ht,processRowUpdate:ae,onProcessRowUpdateError:ye,onRowChange:(wt,Xm)=>{So.storeRow(Xm,wt)},onCommitted:wt=>Yr.emit(wt,"edit")}),Gn=vd({selectedRowIds:om,rowsLookup:Oe.rows.idRowsLookup,rowMetaMap:ze,enabled:!xe&&!Mt&&Le==="client"&&Ee==="client",onSelectionModelChange:Kr}),wa=zf({dataSource:xe,sortModel:gt,filterModel:pt,paginationModel:Re,paginationMode:Le,sortingMode:Ce,filterMode:Ee,aggregationModel:Ue,rowGroupingActive:cn,getRowId:ma,setRows:fm,setRowCount:bm,setDataSourceLoading:mm,setDataSourceError:wm,onAggregationResults:um,onPaginationModelChange:an});jf({enabled:xo&&!!xe,treeNodes:_o.treeNodes,isGroupExpanded:_o.isGroupExpanded,getNodePath:_o.getNodePath,toggleExpansion:_o.toggleExpansion,fetchChildren:wa.fetchChildren});const{hasDetailPanel:zt,expandedRowIds:Jr,handleDetailPanelToggle:ba,detailPanelHeights:Cm,reportDetailPanelHeight:vm}=cd({hasDetailPanel:!!K,controlledExpandedRowIds:X,onDetailPanelExpandedRowIdsChange:te,rowMetaMap:ze}),{effectiveColumns:xa,hierarchyField:Zr,orderedColumns:Qr,visibleOrderedColumns:ya,renderOrderedColumns:_m,navigationColumns:gn,columnIndexMap:ko,columnWidths:Hn,effectiveColumnOrder:Sm,columnReorderHandlers:km,moveColumn:Ca,resetColumnOrder:va,handleColumnResize:_a}=ed({activeColumns:ht,isHierarchyEnabled:yo,isRowGrouping:cn,isTreeData:xo,activeHierarchyHandlers:fn,columnVisibilityModel:Et,columnOrder:ue,onColumnOrderChange:ee,onColumnOrderModelChange:D,disableColumnReorder:se,pivotMode:Mt,checkboxSelection:h,hasDetailPanel:zt,rowReordering:Wt,initialState:Ht,setColumns:pm,pinnedColumns:un,getRowId:xm,aggregationModel:Ue,groupingRows:cn?Xr.groupingRows:void 0});fd({onStateChange:Pn,sortModel:gt,filterModel:pt,effectivePaginationModel:Re,columnWidths:Hn,effectiveColumnOrder:Sm,columnVisibilityModel:Et,pinnedColumns:Vr,density:ha});const Eo=Vc({effectiveRows:vo,activeHierarchyHandlers:fn,filterMode:Ee,filterModel:Dn.pipelineFilterModel,sortModel:Dn.pipelineSortModel,sortingMode:Ce,pagination:rt,paginationMode:Le,effectivePaginationModel:Re,pinnedRows:ce,getRowId:Te,columnLookup:Rr,hierarchyField:Zr}),{filteredRows:Sa,dataRows:pn,pinnedTopRows:Ke,pinnedBottomRows:st,sortedUnpinnedRows:mt,paginatedUnpinnedRows:Mo,allRenderableRows:It}=Eo,ei=rt?Mo:mt;Md({paginationModel:Re,currentPage:Eo.currentPage,enabled:rt&&!Nt&&mt.length>0,onPaginationModelChange:an});const No=Wc({paginationMode:Le,hasDataSource:!!xe,dataSourceRowCount:Oe.pagination.rowCount,rowCountProp:Ie,clientRowCount:mt.length}),{rowSelection:ti,handleRowClick:ni,handleSelectionChange:oi}=Cd({dataRows:pn,getRowId:Te,isPivotActive:Mt,selectedRowIds:Gn,onSelectionModelChange:Kr,disableMultipleRowSelection:y,disableRowSelectionOnClick:x,isHierarchyEnabled:yo,rowMetaMap:ze,activeHierarchyHandlers:fn,onRowClick:I});kd({apiRef:Co.apiRef,sortModel:gt,multiSort:ie,onSortModelChange:fa,filterModel:pt,onFilterModelChange:Wr,paginationModel:Re,onPaginationModelChange:an,selectedRowIds:Gn,getPendingRowSelectionModel:Bt.getPendingRowSelectionModel,onRowSelectionModelChange:Kr,disableMultipleRowSelection:y,isSyntheticRowId:wt=>Xe(wt,ze),getVisibleRows:()=>[...Ke,...ei,...st],getAllFilteredRows:()=>Mg({hierarchyHandlers:fn,pinnedTopRows:Ke,sortedUnpinnedRows:mt,pinnedBottomRows:st,rowMetaMap:ze,getRowId:Te,hierarchyField:Zr,dataRows:pn}),visibleColumns:_m,rowGroupingModel:jr,onRowGroupingModelChange:rm,aggregationModel:Ue,onAggregationModelChange:ga,columnVisibilityModel:Et,onColumnVisibilityModelChange:wo,pivotModel:zr,onPivotModelChange:pa});const Em=Su({rows:vo,getRowId:Te,onRowOrderChange:F,rowReordering:Wt}),{aggregationResult:ri,isLoading:Mm}=hs({rows:pn,columns:ht,aggregationModel:Mt?Ua:Ue,isServerSide:Cl({dataSource:xe,paginationMode:Le,sortingMode:Ce,filterMode:Ee}),dataSource:xe,filterModel:pt,sortModel:gt,serverAggregationResults:dm}),ii=Object.keys(Ue).length>0&&!Mt;Tg({apiRef:lt,hasAggregation:ii,aggregationResult:ri,aggregationModel:Ue,isRowGrouping:cn,rowGroupingHandlers:Xr,rowMetaMap:ze,columns:ht,getRowId:Te,hierarchyField:Zr});const $e=Ka({rowHeight:it,pagination:rt,paginatedUnpinnedRows:Mo,sortedUnpinnedRows:mt,expandedRowIds:Jr,getDetailPanelHeight:de,detailPanelHeights:Cm,pinnedTopRowsLength:Ke.length,pinnedBottomRowsLength:st.length,pinnedTopRows:Ke,pinnedBottomRows:st,visibleOrderedColumns:ya,pinnedColumns:un,columnWidths:Hn,viewportWidth:Oe.dimensions.viewportWidth||1e3,checkboxSelection:h,hasDetailPanel:zt,rowReordering:Wt,pinCheckboxColumn:U,pinExpandColumn:J,paginationMode:Le,isLoading:Oe.dataSource.loading,pageSize:Re.pageSize,getRowId:Te}),Lt=Df({pinnedTopRows:Ke,centerRows:ei,pinnedBottomRows:st,columns:ya,leftPinnedColumns:$e.leftPinnedCols,unpinnedColumns:$e.unpinnedColsWithWidth,rightPinnedColumns:$e.rightPinnedCols,expandedRowIds:zt?Jr:void 0,rowMetaMap:ze,getRowId:Te}),ka=s.useMemo(()=>[...$e.leftPinnedCols,...$e.unpinnedColsWithWidth,...$e.rightPinnedCols],[$e.leftPinnedCols,$e.unpinnedColsWithWidth,$e.rightPinnedCols]),He=tp({enabled:f&&!dn,model:Bt.cellSelectionModel,onModelChange:Bt.handleCellSelectionModelChange,getPendingModel:Bt.getPendingCellSelectionModel,allRenderableRows:It,getRowId:Te,navigationColumns:gn,columnIndexMap:ko,spanning:Lt,rowMetaMap:ze,layout:$e,rowHeight:it,pinnedTopRowCount:Ke.length,viewportRef:Vt,containerRef:qe,localeText:sn,showStats:w});Ug({apiRef:lt,columns:ka,getRowId:Te,containerRef:qe,disableKeyboardShortcut:p,getCellRangeCopyText:He.enabled?He.getCopyText:void 0}),Rg({apiRef:lt,viewportRef:Vt,layout:$e,rowHeight:it});const Nm=Jg({apiRef:lt,containerRef:qe,columns:Qr,onColumnResize:_a}),{scrollTop:Im,scrollLeft:Lm,overscanRows:Am,handleScroll:Tm,setViewportElement:Pm}=sd({onRowsScrollEnd:De,overscanRowCount:Zh,rowCount:$e.unpinnedRowsLength,autoHeight:u,setDimensions:hm,viewportRef:Vt}),Ea=Uc(qe),Be=Rc({layout:$e,scrollTop:Im,scrollLeft:Lm,viewportWidth:Oe.dimensions.viewportWidth,viewportHeight:Oe.dimensions.viewportHeight,autoHeight:u,rowReordering:Wt,hasDetailPanel:zt,checkboxSelection:h,pinCheckboxColumn:U,pinExpandColumn:J,overscanRows:Am,maxContentHeight:Ea??1/0}),{handleSort:Ma,handleSortAdd:Na}=_d({sortModel:gt,onSortModelChange:fa}),Io=h||!x,{focusedCell:Lo,setFocusedCell:li,viewportTabIndex:Fm,ensureGridFocus:Om,handleFocus:Dm,handleBlur:$m,handleKeyDown:Gm,handleMouseDownCapture:Hm}=Lc({allRenderableRows:It,navigationColumns:gn,checkboxSelection:h,selectedRowIds:Gn,handleSelectionChange:oi,handleDetailPanelToggle:ba,editingHandlers:$n,setKeyboardMode:qr,sortModel:gt,handleSort:Ma,handleSortAdd:Na,multiSort:ie,isCellEditable:we,pagination:rt,pageSize:Re.pageSize,virtualization:Be,viewportRef:Vt,pinnedTopRowCount:Ke.length,getRowId:Te,rowMetaMap:ze,getSpanOrigin:Lt.getSpanOrigin,onRowActivate:ni,toggleRowExpansion:fn?.toggleExpansion,handleSelectAll:ti.selectAll,rowSelectionEnabled:Io,multipleRowSelectionEnabled:!y,pinCheckboxColumn:U,pinExpandColumn:J,rowHeight:it,cellSelection:He.keyboard,headerFilters:bo}),{handleCellClick:Bm,handleHeaderClick:Wm}=ip({ensureGridFocus:Om,setKeyboardMode:qr,setFocusedCell:li,getRowId:Te,onCellClick:v});np({apiRef:lt,selection:He,model:Bt.cellSelectionModel,getPendingModel:Bt.getPendingCellSelectionModel,focusedCell:Lo,setFocusedCell:li,containerRef:qe}),af({apiRef:lt,containerRef:qe,viewportRef:Vt,selection:He,disableClipboardPaste:C,disableRangeClear:E,focusedCell:Lo,allRenderableRows:It,getRowId:Te,navigationColumns:gn,isCellEditable:we,rowMetaMap:ze,getSpanOrigin:Lt.getSpanOrigin,isEditing:$n.editingCell!==null,batchEdit:So,onClipboardPaste:S,onBeforeClipboardPaste:N}),ff({apiRef:lt,enabled:!!M,limit:typeof M=="object"&&M.limit||cf,onHistoryChange:L,channel:Yr,batchEdit:So,isEditing:$n.editingCell!==null,containerRef:qe,viewportRef:Vt,selection:He,setFocusedCell:li,allRenderableRows:It,getRowId:Te,navigationColumns:gn,layout:$e,rowHeight:it,pinnedTopRowCount:Ke.length});const Vm=Tf({containerRef:qe,viewportRef:Vt,selection:He,disableFillHandle:_,isEditing:$n.editingCell!==null,allRenderableRows:It,getRowId:Te,navigationColumns:gn,columnIndexMap:ko,isCellEditable:we,rowMetaMap:ze,getSpanOrigin:Lt.getSpanOrigin,batchEdit:So,onFill:O}),{handleHideColumn:zm,handlePinColumn:Km}=Sd({columnVisibilityModel:Et,onColumnVisibilityModelChange:wo,pinnedColumns:Vr,onPinnedColumnsChange:nm}),Bn=cp({columnGroupingModel:On,headerFilterRow:bo,pinnedTopCount:Ke.length,pinnedBottomCount:st.length,pagination:rt,paginationMode:Le,paginationModel:Re,paginationRowCount:No,paginatedUnpinnedRowCount:Mo.length,sortedUnpinnedRowCount:mt.length}),si=Gf({spanning:Lt,renderContext:Be.renderContext,offsetTop:Be.offsetTop,cumulativeHeights:$e.cumulativeHeights}),ai=nd({renderContext:si.renderContext,pinnedTopRows:Ke,pinnedBottomRows:st,paginatedUnpinnedRows:Mo,sortedUnpinnedRows:mt,pagination:rt,getRowId:Te}),Ao=Hf({spanning:Lt,firstColumnIndex:Be.renderContext.firstColumnIndex,lastColumnIndex:Be.renderContext.lastColumnIndex,virtualColumns:Be.virtualColumns,layout:$e,rows:ai});md({paginationRequested:z,isRowGrouping:cn,autoHeight:u,viewportHeight:Oe.dimensions.viewportHeight,renderedRowCount:ai.length,totalRowCount:Ke.length+ei.length+st.length,pinnedRowsIgnored:yo&&!!(ce?.top?.length||ce?.bottom?.length),scrollHeight:Be.totalHeight,maxContentHeight:Ea,reachableRowCount:jc(Be.cumulativeHeights,Be.virtualContainerHeight),unpinnedRowCount:Be.cumulativeHeights.length,listViewWithoutColumn:mo&&!Fn,listViewRowCount:dn&&Fn?It.length:0});const{allSelected:jm,someSelected:Um}=ti,hn=Bf(On,km),Rm=s.useMemo(()=>xa.some(wt=>!!wt.rowSpan),[xa]),at=Nd();bd(qe);const mn=Ep({apiRef:lt,options:Qh,columns:ht,onApply:em,onError:tm}),Ia=Ne?.noRowsOverlay,La=Ne?.loadingOverlay,ci=La?d.jsx(La,{...ke?.loadingOverlay}):void 0,Aa=Ia?d.jsx(Ia,{...ke?.noRowsOverlay}):void 0,To=Ne?.footer,qm=Nt&&It.length>0&&Le!=="infinite",Ta=Ne?.toolbar,Pa=dp({toolbar:Ne?.toolbar,toolbarSlotProps:ke?.toolbar,apiRef:lt,orderedColumns:Qr,baseColumns:Hr,aggregationModel:Ue,onAggregationModelChange:ga,pivotMode:Fe,pivotModelProp:pe,onPivotModelChangeProp:ve,pivotModel:zr,onPivotModelChange:pa,filterModel:pt,onFilterModelChange:Wr,columnVisibilityModel:Et,onColumnVisibilityModelChange:wo,disableColumnReorder:se,columnGroupingModel:On,moveColumn:Ca,resetColumnOrder:va,forceColumnsOpen:at.toolbarPanelRequested,onColumnsPanelClose:at.closeToolbarPanel,aiAssistantEnabled:mn.enabled,aiAssistantOpen:mn.open,onAiAssistantToggle:mn.togglePanel,aiAssistantLabel:sn?.aiAssistantButton,forceFiltersOpen:at.toolbarFiltersRequested,onFiltersPanelClose:at.closeToolbarFiltersPanel}),di={rowReordering:Wt,columnIndexMap:ko,editingHandlers:$n,isCellEditable:we,selectedRowIds:Gn,checkboxSelection:h,onRowClick:ni,onRowDoubleClick:P,onCellClick:Bm,onSelectionChange:oi,columnWidths:Hn,pinnedColumns:un,hasDetailPanel:zt,expandedRowIds:Jr,getDetailPanelContent:K,getDetailPanelHeight:de,onDetailPanelToggle:ba,onDetailPanelHeightChange:vm,pinCheckboxColumn:U,pinExpandColumn:J,focusedCell:Lo,colspanMap:Lt.colspanMap,rowSpanningCaches:Lt.rowSpanningCaches,rowHeight:it,rowMetaMap:ze,cellRange:He.displayRange,cellRangeHasRowSpan:He.hasRowSpan,fillHandle:Vm.handle};return d.jsxs("div",{ref:qe,className:["ogx",Se,u&&"ogx--auto-height",!u&&T===void 0&&be?.height===void 0&&"ogx--fill",Rm&&"ogx--row-spanning",dn&&"ogx--list-view"].filter(Boolean).join(" "),style:{...be,height:T??be?.height,"--ogx-row-height":`${it}px`,"--ogx-header-height":`${Ur}px`,...bo?{"--ogx-header-filter-height":`${c}px`}:void 0},"aria-busy":Nt,children:[Ta&&Pa&&d.jsx(xl.Provider,{value:at.toolbarHost,children:d.jsx(Ad,{component:Ta,toolbarProps:Pa})}),mn.panelProps&&d.jsx(Ap,{panelProps:mn.panelProps,slot:Ne?.aiAssistantPanel,slotProps:ke?.aiAssistantPanel}),d.jsx(vg,{isOpen:at.standalonePanelOpen,containerRef:qe,panelRef:at.standalonePanelRef,columns:Qr,columnVisibilityModel:Et,disableColumnReorder:se,onClose:at.closeStandalonePanel,onColumnVisibilityChange:wo,onColumnMove:Ca,onColumnOrderReset:va,columnGroupingModel:On}),dn&&Fn&&d.jsx(Qf,{ariaLabel:ft,allRenderableRows:It,dataRowCount:pn.length,pinnedTopRowCount:Ke.length,pinnedBottomRowCount:st.length,unpinnedRowCount:mt.length,pagination:rt,effectivePaginationModel:Re,currentPage:Eo.currentPage,pageSizeOptions:oe,selectedRowIds:Gn,listViewColumn:Fn,columnsByField:Rr.byField,rowMetaMap:ze,noRowsLabel:Br,rowHeight:it,checkboxSelection:h,paginationMode:Le,serverRowCount:No,paginationSlot:Ne?.pagination,paginationSlotProps:ke?.pagination,localeText:ll(sn),onRowClick:ni,onRowDoubleClick:P,onSelectionChange:oi,onPaginationModelChange:an,onRowsScrollEnd:De,getRowId:Te,multiselectable:Io&&!y,selectable:Io,onToggleExpansion:fn?.toggleExpansion,loading:Nt,loadingOverlay:ci,noRowsOverlay:Aa,showPaginationControls:!To}),!dn&&d.jsx("div",{ref:Pm,className:"ogx__viewport",onScroll:Tm,role:"grid","aria-label":ft||"Data grid","aria-rowcount":Bn.rowCount,"aria-colcount":gn.length,"aria-multiselectable":Io&&!y||He.enabled,"aria-busy":Nt,tabIndex:Fm,onKeyDownCapture:()=>{qr(!0)},onMouseDownCapture:Hm,onMouseDown:He.handleMouseDown,onClickCapture:He.handleClickCapture,onKeyDown:Gm,onFocus:Dm,onBlur:$m,children:d.jsxs("div",{className:"ogx__content",style:{width:un?.right?.length?`max(100%, ${Be.totalWidth}px)`:Be.totalWidth},role:"presentation",children:[d.jsxs("div",{className:"ogx__sticky-top",role:"presentation",children:[d.jsx(Hl,{columns:Ao,allColumns:ka,columnGroupingModel:On,checkboxSelection:h,allSelected:jm,someSelected:Um,onSelectAll:ti.selectAll,sortModel:gt,onSort:Ma,onSortAdd:Na,multiSort:ie,onColumnResize:_a,onColumnAutosize:Nm,columnWidths:Hn,pinnedColumns:un,focusedCell:Lo,columnIndexMap:ko,onHeaderClick:Wm,onDragStart:hn.onDragStart,onDragOver:hn.onDragOver,onDragEnd:hn.onDragEnd,onDrop:hn.onDrop,draggedColumn:hn.draggedColumn,dragOverColumn:hn.dragOverColumn,rowReordering:Wt,hasDetailPanel:zt,pinCheckboxColumn:U,pinExpandColumn:J,aggregationModel:Ue,onHideColumn:zm,onManageColumns:at.openColumnsPanel,onPinColumn:Km,wrapHeaderText:l,headerHeight:Ur,headerFilters:bo,filterModel:pt,onFilterModelChange:Wr,onOpenFilterPanel:at.openFiltersPanel,localeText:sn}),d.jsx(ys,{...di,rows:Ke,position:"top",ariaRowIndexBase:Bn.topBase,columns:Ao,pinnedRows:ce,getRowId:Te})]}),!Nt&&!Oe.dataSource.error&&Sa.length===0&&d.jsx(Pd,{noRowsLabel:Br,width:Be.totalWidth,overlay:Aa}),d.jsx(xg,{...di,virtualContainerHeight:Be.virtualContainerHeight,offsetTop:si.offsetTop,effectiveLoading:Nt,visibleRows:ai,baseColumns:Hr,virtualColumns:Ao,viewportWidth:Oe.dimensions.viewportWidth,rowReorderHandlers:Em,paginationMode:Le,dataSourceLoading:Oe.dataSource.loading,sortedUnpinnedRowCount:mt.length,infiniteScrollSkeletonCount:Math.min(Re.pageSize,20),unpinnedRowsLength:$e.unpinnedRowsLength,lastRenderedRowIndex:si.renderContext.lastRowIndex,ariaRowIndexOffset:Bn.centerOffset,loadingOverlay:ci}),d.jsxs("div",{className:"ogx__sticky-bottom",role:"presentation",children:[d.jsx(ys,{...di,rows:st,position:"bottom",rowIndexOffset:Bn.bottomRowIndexOffset,ariaRowIndexBase:Bn.bottomBase,columns:Ao,pinnedRows:ce,getRowId:Te}),ii&&Xr.rootAggregationPosition!==null&&d.jsx(Td,{columns:Be.virtualColumns,aggregationModel:Ue,aggregationResult:ri,columnWidths:Hn,rowHeight:it,checkboxSelection:h,hasDetailPanel:zt,rowReordering:Wt,pinCheckboxColumn:U,pinExpandColumn:J,pinnedColumns:un,loading:Mm})]})]})}),He.enabled&&w&&d.jsx(op,{stats:He.stats,apiRef:Co.apiRef,slot:Ne?.cellSelectionStats,slotProps:ke?.cellSelectionStats}),To&&d.jsx(To,{apiRef:Co.apiRef,aggregationModel:Ue,aggregationResult:ii?ri:null,rowCount:yo&&Le!=="server"?pn.length:No,pagination:rt,paginationModel:Re,pageSizeOptions:oe,onPaginationModelChange:an,...ke?.footer}),!dn&&!To&&rt&&d.jsx(lp,{paginationSlot:Ne?.pagination,paginationSlotProps:ke?.pagination,page:Eo.currentPage,paginationModel:Re,rowCount:No,pageSizeOptions:oe,onPaginationModelChange:an,localeText:sn}),d.jsx(sp,{loading:Nt,error:Oe.dataSource.error,noRowsLabel:Br,filteredRowCount:Sa.length,dataRowCount:pn.length,filterModel:pt,cellSelectionAnnouncement:He.announcement,aiAssistantAnnouncement:mn.announcement}),qm&&d.jsx(eg,{overlay:ci}),d.jsx(Od,{error:Oe.dataSource.error,onRetry:xe?wa.fetchRows:void 0})]})}function Pp({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 Fp=300;function tn(e){return"field"in e&&!("items"in e)}function Gs(e,t){return e.find(n=>tn(n)&&n.field===t)}function Hs(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)=>Hs(n,t[o])):!1}function Op(e,t){return e===t?!0:tn(e)&&tn(t)?e.id===t.id&&e.field===t.field&&e.operator===t.operator&&Hs(e.value,t.value):!tn(e)&&!tn(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)=>Op(n,t[o]))}function Dp(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 Bs(e,t){return Object.is(e.value,t)?!0:t!=null&&String(e.value).toLowerCase()===String(t).toLowerCase()}function Ws(e,t){return Yo(e,t.type)}function Vs(e,t){return t==="isAnyOf"?e.split(",").map(n=>n.trim()).filter(n=>n!==""):e}function $p(e,t){if(!jt.has(t))return t==="isAnyOf"?e==null||e===""?[]:Array.isArray(e)?e:[e]:Array.isArray(e)?e.length>0?e[0]:"":e??""}const Gp=({col:e,item:t,resetToken:n,onChange:o})=>{const r=s.useId(),i=s.useMemo(()=>Ni(e.type),[e.type]),l=i[0],a=t?.operator??l,c=i.includes(a)?i:[a,...i],u=!!t,g=e.headerName||e.field,[h,x]=s.useState(null),[y,p]=s.useState(n);y!==n&&(p(n),x(null));const f=s.useRef(o),m=s.useRef(t),b=s.useRef(e);s.useLayoutEffect(()=>{f.current=o,m.current=t,b.current=e});const w=s.useCallback((I,P)=>({id:m.current?.id??`${e.field}-${Date.now()}`,field:e.field,operator:I,value:P}),[e.field]),C=s.useCallback(I=>{const P=m.current;if(P?I===Ws(P.value,b.current):I.trim()==="")return;const B=P?.operator??l;f.current(w(B,Vs(I,B)))},[l,w]),E=s.useRef(null),S=s.useRef(C);s.useLayoutEffect(()=>{E.current=h,S.current=C}),s.useEffect(()=>()=>{const I=E.current;E.current=null,I!==null&&S.current(I)},[]),s.useEffect(()=>{if(h===null)return;const I=setTimeout(()=>{E.current=null,C(h),x(null)},Fp);return()=>clearTimeout(I)},[h,C]);const N=I=>{const P=h!==null?Vs(h,I):t?.value;x(null),o(w(I,$p(P,I)))},M=()=>{x(null),o(null)},_=!jt.has(a),O=Dp(e),L=`ogx-filter__value-input${u?" ogx-filter__value-input--active":""}`,A=`Filter value for ${g}`;let k=null;if(_&&e.type==="boolean")k=d.jsxs("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${L} ogx-filter__value-select`,value:t?.value==null?"":String(t.value),onChange:I=>{I.target.value===""?o(null):o(w(a,I.target.value))},"aria-label":A,children:[d.jsx("option",{value:"",children:"Any"}),d.jsx("option",{value:"true",children:"true"}),d.jsx("option",{value:"false",children:"false"})]});else if(_&&e.type==="singleSelect"&&O.length>0&&a==="isAnyOf"){const I=Array.isArray(t?.value)?t.value:t?.value==null||t.value===""?[]:[t.value];k=d.jsx("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${L} ogx-filter__value-multiselect`,multiple:!0,size:Math.min(O.length,4),value:O.filter(P=>I.some(v=>Bs(P,v))).map(P=>P.key),onChange:P=>{const v=new Set(Array.from(P.target.selectedOptions,B=>B.value));o(w("isAnyOf",O.filter(B=>v.has(B.key)).map(B=>B.value)))},"aria-label":A,children:O.map(P=>d.jsx("option",{value:P.key,children:P.label},P.key))})}else if(_&&e.type==="singleSelect"&&O.length>0&&(a==="is"||a==="not")){const I=O.find(P=>Bs(P,t?.value));k=d.jsxs("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${L} ogx-filter__value-select`,value:I?.key??"",onChange:P=>{const v=O.find(B=>B.key===P.target.value);o(w(a,v?v.value:""))},"aria-label":A,children:[d.jsx("option",{value:"",children:"Any"}),O.map(P=>d.jsx("option",{value:P.key,children:P.label},P.key))]})}else _&&(k=d.jsx(et,{id:`${r}-val`,name:`filter-val-${e.field}`,inputClassName:L,type:e.type==="date"?"date":"text",value:h??Ws(t?.value,e),onChange:I=>x(I.target.value),placeholder:e.type==="number"?"Number…":"Value…","aria-label":A}));return d.jsxs("div",{className:`ogx-filter__row${u?" ogx-filter__row--active":""}`,children:[d.jsx("span",{className:"ogx-filter__col-label",title:e.field,children:g}),d.jsxs("div",{className:"ogx-filter__controls",children:[d.jsx("select",{id:`${r}-op`,name:`filter-op-${e.field}`,className:`ogx-filter__op-select${u?" ogx-filter__op-select--active":""}`,value:a,onChange:I=>N(I.target.value),"aria-label":`Filter operator for ${g}`,children:c.map(I=>d.jsx("option",{value:I,children:I},I))}),k,u&&d.jsx("button",{type:"button",className:"ogx-filter__row-clear",onClick:M,"aria-label":`Clear filter for ${g}`,title:"Clear",children:"×"})]})]})},zs=({filterModel:e,columns:t,onFilterModelChange:n})=>{const o=s.useMemo(()=>e.items??[],[e.items]),r=e.logicOperator??"and",[i,l]=s.useState(null),[a,c]=s.useState(o),[u,g]=s.useState(0);if(a!==o){c(o);const m=!$r(a,o),b=i!==null&&$r(i,o);m&&!b&&g(w=>w+1)}const h=s.useCallback((m,b)=>{const w=o.findIndex(E=>tn(E)&&E.field===m);let C;if(w===-1){if(!b)return;C=[...o,b]}else b?C=o.map((E,S)=>S===w?b:E):C=o.filter((E,S)=>S!==w);l(C),n({...e,items:C})},[o,e,n]),x=s.useCallback(m=>{n({...e,logicOperator:m})},[e,n]),y=t.filter(m=>m.filterable!==!1),p=y.filter(m=>Gs(o,m.field)).length,f=o.length-p;return d.jsxs(d.Fragment,{children:[o.length>1&&d.jsxs("div",{className:"ogx-filter__logic-bar",children:[d.jsx("span",{className:"ogx-filter__logic-label",children:"Match:"}),d.jsx("button",{type:"button",className:`ogx-filter__logic-pill${r==="and"?" ogx-filter__logic-pill--active":""}`,onClick:()=>x("and"),"aria-pressed":r==="and",children:"ALL (AND)"}),d.jsx("button",{type:"button",className:`ogx-filter__logic-pill${r==="or"?" ogx-filter__logic-pill--active":""}`,onClick:()=>x("or"),"aria-pressed":r==="or",children:"ANY (OR)"})]}),f>0&&d.jsx("div",{className:"ogx-filter__hidden-note",role:"note",children:f===1?"1 more condition (a filter group or a second condition on a column) is applied and not shown here.":`${f} more conditions (filter groups or further conditions on a column) are applied and not shown here.`}),y.length===0?d.jsx("div",{className:"ogx-filter__empty",children:"No filterable columns."}):y.map(m=>d.jsx(Gp,{col:m,item:Gs(o,m.field),resetToken:u,onChange:b=>h(m.field,b)},m.field))]})},Ks=["sum","avg","count","min","max"];function js(){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 Hp({anchorRef:e,columns:t,model:n,onChange:o,onClose:r}){const i=s.useRef(null),[l,a]=s.useState({top:0,right:0}),[c,u]=s.useState(null);s.useLayoutEffect(()=>{u(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const g=s.useCallback(()=>zn(e.current,$t()),[e]);s.useEffect(()=>{a(g());const v=()=>a(g());return window.addEventListener("scroll",v,!0),window.addEventListener("resize",v),()=>{window.removeEventListener("scroll",v,!0),window.removeEventListener("resize",v)}},[g]),s.useEffect(()=>{function v(V){i.current&&!i.current.contains(V.target)&&e.current&&!e.current.contains(V.target)&&r()}function B(V){V.key==="Escape"&&r()}return document.addEventListener("mousedown",v),document.addEventListener("keydown",B),()=>{document.removeEventListener("mousedown",v),document.removeEventListener("keydown",B)}},[e,r]);const h=new Set(n.rowFields),x=new Set(n.columnFields),y=new Set(n.valueFields.map(v=>v.field)),p=v=>h.has(v)||x.has(v)||y.has(v),f=v=>t.find(B=>B.field===v),m=v=>f(v)?.headerName??v,b=v=>{const B=f(v)?.availableAggregationFunctions;return B?Ks.filter(V=>B.includes(V)):Ks},w=v=>v.aggregable!==!1&&(v.type==="number"||v.aggregable===!0)&&b(v.field).length>0,C=v=>v.groupable!==!1;function E(v){h.has(v)||o({...n,rowFields:[...n.rowFields,v]})}function S(v){x.has(v)||o({...n,columnFields:[...n.columnFields,v]})}function N(v){y.has(v)||o({...n,valueFields:[...n.valueFields,{field:v,aggFn:b(v)[0]??"sum"}]})}function M(v){o({...n,rowFields:n.rowFields.filter((B,V)=>V!==v)})}function _(v){o({...n,columnFields:n.columnFields.filter((B,V)=>V!==v)})}function O(v){o({...n,valueFields:n.valueFields.filter((B,V)=>V!==v)})}function L(v,B){o({...n,valueFields:n.valueFields.map((V,Q)=>Q===v?{...V,aggFn:B}:V)})}function A(){o({rowFields:[],columnFields:[],valueFields:[]})}const k=n.rowFields.length+n.columnFields.length+n.valueFields.length,I=t.filter(v=>!p(v.field)&&(C(v)||w(v))),P=d.jsxs("div",{ref:i,className:"ogx-pivot-panel",role:"dialog","aria-label":"Pivot configuration",style:{top:l.top,right:l.right,left:l.left},children:[d.jsxs("div",{className:"ogx-pivot-panel__header",children:[d.jsxs("span",{className:"ogx-pivot-panel__title",children:[d.jsx(js,{}),"Pivot Mode"]}),k>0&&d.jsx("button",{type:"button",className:"ogx-pivot-panel__reset-btn",onClick:A,title:"Reset pivot",children:"Reset"})]}),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"}),"Row Fields"]}),d.jsx("div",{className:`ogx-pivot-chips${n.rowFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — each becomes a row label",children:n.rowFields.map((v,B)=>d.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--row",children:[m(v),d.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>M(B),title:`Remove ${m(v)}`,"aria-label":`Remove ${m(v)} from Row Fields`,children:"×"})]},`${B}:${v}`))})]}),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"}),"Column Fields"]}),d.jsx("div",{className:`ogx-pivot-chips${n.columnFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — unique values become column headers",children:n.columnFields.map((v,B)=>d.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--col",children:[m(v),d.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>_(B),title:`Remove ${m(v)}`,"aria-label":`Remove ${m(v)} from Column Fields`,children:"×"})]},`${B}:${v}`))})]}),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"}),"Value Fields (aggregated)"]}),d.jsx("div",{className:`ogx-pivot-chips${n.valueFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add numeric fields here — values are aggregated",children:n.valueFields.map((v,B)=>{const V=b(v.field),Q=V.includes(v.aggFn)?V:[v.aggFn,...V];return d.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--value",children:[m(v.field),d.jsx("select",{className:"ogx-pivot-chip__fn-select",value:v.aggFn,onChange:H=>L(B,H.target.value),title:"Aggregation function","aria-label":`Aggregation function for ${m(v.field)}`,children:Q.map(H=>d.jsx("option",{value:H,children:H.toUpperCase()},H))}),d.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>O(B),title:`Remove ${m(v.field)}`,"aria-label":`Remove ${m(v.field)} (${v.aggFn.toUpperCase()}) from Value Fields`,children:"×"})]},`${B}:${v.field}:${v.aggFn}`)})})]}),d.jsx("hr",{className:"ogx-pivot-panel__divider"}),d.jsxs("div",{children:[d.jsx("div",{className:"ogx-pivot-panel__fields-label",children:"Available Fields"}),d.jsxs("div",{className:"ogx-pivot-fields",children:[I.map(v=>{const B=w(v),V=C(v),Q=v.headerName??v.field;return d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3},children:[d.jsx("span",{className:`ogx-pivot-field-btn${B?" ogx-pivot-field-btn--numeric":""}`,children:Q}),d.jsxs("div",{className:"ogx-pivot-field-actions",children:[V&&d.jsx("button",{type:"button",className:"ogx-pivot-add-btn ogx-pivot-add-btn--row",onClick:()=>E(v.field),title:"Add to Row Fields","aria-label":`Add ${Q} to Row Fields`,children:"Row"}),V&&d.jsx("button",{type:"button",className:"ogx-pivot-add-btn ogx-pivot-add-btn--col",onClick:()=>S(v.field),title:"Add to Column Fields","aria-label":`Add ${Q} to Column Fields`,children:"Col"}),B&&d.jsx("button",{type:"button",className:"ogx-pivot-add-btn ogx-pivot-add-btn--value",onClick:()=>N(v.field),title:"Add to Value Fields","aria-label":`Add ${Q} to Value Fields`,children:"Val"})]})]},v.field)}),I.length===0&&d.jsx("span",{style:{fontSize:12,color:"var(--ogx-color-gray-400, #94a3b8)"},children:"All fields are in use."})]})]})]})]});return c?bt.createPortal(P,c):null}function Bp(){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 Wp(){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 Us(e){return e.trim().split(/\s+/).filter(Boolean).join(" ")}function Vp({value:e="",onChange:t,placeholder:n="Search...",debounceMs:o=250}){const[r,i]=s.useState(()=>e.length>0),[l,a]=s.useState(e),c=s.useRef(null),u=s.useRef(null),g=s.useRef(t);s.useLayoutEffect(()=>{g.current=t},[t]);const h=s.useRef(e),x=s.useRef(e);s.useEffect(()=>{e!==x.current&&(x.current=e,Us(e)!==Us(h.current)&&(a(e),h.current=e,i(e.length>0)))},[e]),s.useEffect(()=>{const w=setTimeout(()=>{l!==h.current&&(h.current=l,g.current(l))},o);return()=>clearTimeout(w)},[l,o]);const y=s.useRef(l);s.useLayoutEffect(()=>{y.current=l}),s.useEffect(()=>()=>{const w=y.current;w!==h.current&&(h.current=w,g.current(w))},[]);const p=s.useCallback(()=>{i(!0),requestAnimationFrame(()=>c.current?.focus())},[]),f=s.useCallback(w=>{w.stopPropagation(),a(""),h.current="",g.current(""),c.current?.focus()},[]),m=s.useCallback(()=>{i(!0)},[]),b=s.useCallback(()=>{setTimeout(()=>{u.current&&document.activeElement&&u.current.contains(document.activeElement)||l||i(!1)},150)},[l]);return s.useEffect(()=>{const w=C=>{u.current&&!u.current.contains(C.target)&&(l||i(!1))};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[l]),d.jsxs("div",{ref:u,className:`ogx-global-search${r?" ogx-global-search--expanded":""}`,onClick:r?void 0:p,children:[d.jsx("div",{className:"ogx-global-search__icon-wrapper",children:d.jsx(Bp,{})}),d.jsx(et,{ref:c,inputClassName:"ogx-global-search__input",value:l,onChange:w=>a(w.target.value),onFocus:m,onBlur:b,placeholder:n,"aria-label":"Global Search",autoComplete:"off"}),l&&d.jsx("button",{type:"button",className:"ogx-global-search__clear",onClick:f,"aria-label":"Clear search",children:d.jsx(Wp,{})})]})}const go=8;function Ln({title:e,children:t,placement:n="top",enterDelay:o=200,leaveDelay:r=0}){const[i,l]=s.useState(!1),[a,c]=s.useState({top:0,left:0}),[u,g]=s.useState(null),h=s.useRef(null),x=s.useRef(null),y=s.useId(),p=s.useCallback(()=>{if(!x.current)return;const S=x.current.getBoundingClientRect(),N=S.left+S.width/2,M=S.top+S.height/2;switch(n){case"bottom":c({top:S.bottom+go,left:N});break;case"left":c({top:M,left:S.left-go});break;case"right":c({top:M,left:S.right+go});break;default:c({top:S.top-go,left:N})}},[n]),f=s.useCallback(()=>{h.current&&clearTimeout(h.current),h.current=null},[]);s.useLayoutEffect(()=>{if(!i)return;p();const S=N=>{N.key==="Escape"&&(f(),l(!1))};return window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),document.addEventListener("keydown",S),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p),document.removeEventListener("keydown",S)}},[i,p,f]),s.useEffect(()=>f,[f]);const m=()=>{f(),h.current=setTimeout(()=>{g(x.current?.closest(".ogx-theme-provider")??document.body),l(!0)},o)},b=()=>{f(),h.current=setTimeout(()=>{l(!1)},r)},w=s.useCallback(S=>{x.current=S?S.firstElementChild??S:null},[]),C=i&&!!e&&u!==null;let E=t;if(C&&s.isValidElement(t)){const S=t,N=S.props["aria-describedby"];E=s.cloneElement(S,{"aria-describedby":N?`${N} ${y}`:y})}return d.jsxs(d.Fragment,{children:[d.jsx("span",{ref:w,style:{display:"inline-block",lineHeight:0},onMouseEnter:m,onMouseLeave:b,onFocus:m,onBlur:b,children:E}),C&&u&&bt.createPortal(d.jsx("div",{id:y,role:"tooltip",className:`ogx-tooltip ogx-tooltip--${n}`,style:{top:a.top,left:a.left,position:"fixed",zIndex:99999},children:e}),u)]})}const zp=Object.keys(xt);function Kp(e){return Object.prototype.hasOwnProperty.call(xt,e)}function Rs(e){return e.availableAggregationFunctions?Array.from(new Set(e.availableAggregationFunctions.filter(Kp))):zp}function qs(){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 jp(){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 Xs(){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 Up({anchorRef:e,aggregationModel:t,aggregableColumns:n,onFunctionChange:o,onClearAll:r,onClose:i,activeCount:l}){const a=s.useRef(null),[c,u]=s.useState({top:0,right:0}),[g,h]=s.useState(null);s.useLayoutEffect(()=>{h(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const x=s.useCallback(()=>zn(e.current,$t()),[e]);s.useEffect(()=>{u(x());const p=()=>u(x());return window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)}},[x]),s.useEffect(()=>{function p(f){a.current&&!a.current.contains(f.target)&&e.current&&!e.current.contains(f.target)&&i()}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[e,i]),s.useEffect(()=>{function p(f){f.key==="Escape"&&i()}return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[i]);const y=d.jsxs("div",{ref:a,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Summaries configuration",style:{top:c.top,right:c.right,left:c.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(qs,{}),"Summaries"]}),l>0&&d.jsx("button",{type:"button",className:"ogx-toolbar__clear-btn",onClick:r,title:"Clear all summaries",children:"Clear all"})]}),d.jsx("div",{className:"ogx-toolbar__panel-body",children:n.length===0?d.jsxs("p",{className:"ogx-toolbar__empty",children:["No aggregable columns.",d.jsx("br",{}),"Set ",d.jsx("code",{children:"aggregable: true"})," on a column to enable."]}):n.map(p=>{const f=t[p.field]||"none";return d.jsxs("div",{className:"ogx-toolbar__agg-row",children:[d.jsx("span",{className:"ogx-toolbar__agg-label",title:p.field,children:p.headerName||p.field}),d.jsx("div",{className:"ogx-toolbar__agg-pills",children:["none",...Rs(p)].map(m=>d.jsx("button",{type:"button",className:`ogx-toolbar__pill${f===m?" ogx-toolbar__pill--active":""}`,onClick:()=>o(p.field,m),"aria-pressed":f===m,children:m},m))})]},p.field)})})]});return g?bt.createPortal(y,g):null}function Rp({anchorRef:e,columns:t,visibleColumns:n,onVisibilityChange:o,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:a,onClose:c,showNonHideableColumns:u}){const g=s.useRef(null),[h,x]=s.useState({top:0,right:0}),[y,p]=s.useState(null);s.useLayoutEffect(()=>{p(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const f=s.useCallback(()=>zn(e.current,$t()),[e]);s.useEffect(()=>{x(f());const b=()=>x(f());return window.addEventListener("scroll",b,!0),window.addEventListener("resize",b),()=>{window.removeEventListener("scroll",b,!0),window.removeEventListener("resize",b)}},[f]),s.useEffect(()=>{function b(w){g.current&&!g.current.contains(w.target)&&e.current&&!e.current.contains(w.target)&&c()}return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[e,c]),s.useEffect(()=>{function b(w){w.key==="Escape"&&c()}return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[c]);const m=d.jsx("div",{ref:g,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Column visibility",style:{top:h.top,right:h.right,left:h.left,width:280,padding:0},children:d.jsx(Ir,{columns:t,visibleColumns:n,onVisibilityChange:o,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:a,showNonHideableColumns:u})});return y?bt.createPortal(m,y):null}function qp({anchorRef:e,columns:t,filterModel:n,onFilterModelChange:o,onClose:r}){const i=s.useRef(null),[l,a]=s.useState({top:0,right:0}),c=s.useRef(r);s.useLayoutEffect(()=>{c.current=r},[r]);const[u,g]=s.useState(null);s.useLayoutEffect(()=>{g(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const h=s.useCallback(()=>zn(e.current,$t()),[e]);s.useEffect(()=>{a(h());const f=()=>a(h());return window.addEventListener("scroll",f,!0),window.addEventListener("resize",f),()=>{window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[h]),s.useEffect(()=>{function f(m){m.key==="Escape"&&c.current()}return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[]);const x=n.items?.length??0,y=()=>{o({...n,items:[],logicOperator:"and"})},p=d.jsxs("div",{ref:i,className:"ogx-toolbar__panel ogx-toolbar__panel--filter",role:"dialog","aria-label":"Advanced filters",style:{top:l.top,right:l.right,left:l.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(Xs,{}),"Filters",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:y,title:"Clear all filters",children:"Clear all"}),d.jsx("button",{type:"button",className:"ogx-toolbar__close-btn",onClick:()=>c.current(),title:"Close filters","aria-label":"Close filters panel",children:"Close"})]})]}),d.jsx("div",{className:"ogx-toolbar__panel-body ogx-toolbar__panel-body--filter",children:d.jsx(zs,{columns:t,filterModel:n,onFilterModelChange:o})})]});return u?bt.createPortal(p,u):null}const Xp={rowFields:[],columnFields:[],valueFields:[]},Yp=[];function Jp({columns:e=Yp,baseColumns:t,aggregationModel:n={},onAggregationModelChange:o,pivotModel:r,onPivotModelChange:i,filterModel:l,onFilterModelChange:a,columnVisibilityModel:c={},onColumnVisibilityModelChange:u,onColumnReorder:g,onColumnOrderReset:h,forceColumnsOpen:x,onColumnsPanelClose:y,forceFiltersOpen:p,onFiltersPanelClose:f,children:m,rightContent:b,style:w,renderColumnsButton:C,renderFilterButton:E,renderAggregationButton:S,renderExportButton:N,renderQuickFilter:M,className:_,showNonHideableColumns:O,onAiAssistantToggle:L,aiAssistantOpen:A=!1,aiAssistantLabel:k="Ask AI"}){const[I,P]=s.useState(x?"columns":null),v=I==="summaries",B=I==="pivot",V=I==="columns",Q=I==="filters",H=ae=>{I==="columns"&&ae!=="columns"&&y?.(),I==="filters"&&ae!=="filters"&&f?.(),P(ae)},z=ae=>H(I===ae?null:ae),W=ae=>{I===ae&&H(null)},[re,oe]=s.useState(x);re!==x&&(oe(x),x&&P("columns"));const[fe,le]=s.useState(p);fe!==p&&(le(p),p&&a&&P("filters"));const ce=s.useContext(xl),K=x!==void 0&&!!u;s.useEffect(()=>{if(!(!ce||!K))return ce.registerColumnsPanel()},[ce,K]);const de=p!==void 0&&!!a;s.useEffect(()=>{if(!(!ce||!de))return ce.registerFiltersPanel()},[ce,de]);const X=s.useRef(null),te=s.useRef(null),U=s.useRef(null),J=s.useRef(null),se=s.useRef(null),ue=s.useRef(null),ee=s.useRef(null),D=s.useRef(null),T=r??Xp,$=T.rowFields.length>0||T.columnFields.length>0||T.valueFields.length>0,F=t?new Set(t.map(ae=>ae.field)):null,Z=e.filter(ae=>ae.aggregable!==!1&&(ae.type==="number"||ae.aggregable===!0)&&Rs(ae).length>0&&(!F||F.has(ae.field))),G=Object.keys(n).filter(ae=>n[ae]&&n[ae]!=="none").length,Y=s.useCallback((ae,ye)=>{if(!o)return;const xe={...n};ye==="none"?delete xe[ae]:xe[ae]=ye,o(xe)},[n,o]),j=s.useCallback(()=>{o?.({})},[o]),q=s.useCallback(ae=>{if(!a)return;const ye=ae.trim().split(/\s+/).filter(Boolean),xe={...l||{},quickFilterValues:ye,items:l?.items||[]};a(xe)},[l,a]),ne=(l?.quickFilterValues??[]).join(" "),he=l?.items?.length||0,me=new Set(e.filter(ae=>c[ae.field]!==!1).map(ae=>ae.field)),R=s.useCallback((ae,ye)=>{if(!u)return;const xe={...c,[ae]:ye};u(xe)},[c,u]),ge=s.useCallback(()=>{if(!u)return;const ae={...c};e.forEach(ye=>{ye.hideable!==!1&&(ae[ye.field]=!0)}),u(ae)},[e,c,u]),we=s.useCallback(()=>{if(!u)return;const ae={...c};e.forEach(ye=>{ye.hideable!==!1&&(ae[ye.field]=!1)}),u(ae)},[e,c,u]);return d.jsxs("div",{className:["ogx-toolbar",_].filter(Boolean).join(" "),role:"toolbar","aria-label":"Grid toolbar",style:w,children:[m&&d.jsx("div",{className:"ogx-toolbar__left",children:m}),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:te,className:`ogx-toolbar__icon-btn ogx-toolbar__ai-btn${A?" ogx-toolbar__icon-btn--active":""}`,"aria-haspopup":"dialog","aria-expanded":A,onClick:()=>{H(null),L(te.current)},children:[d.jsx($s,{}),k]})}),a&&d.jsx("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:M?M({value:ne,onChange:q}):d.jsx(Vp,{value:ne,onChange:q,placeholder:"Search..."})}),u&&d.jsxs("div",{ref:ue,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[C?C({onClick:()=>z("columns"),isOpen:V,activeCount:e.length-me.size}):d.jsx(Ln,{title:"Columns",children:d.jsx("button",{type:"button",ref:J,className:`ogx-toolbar__icon-btn${V?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Manage columns","aria-haspopup":"dialog","aria-expanded":V,onClick:()=>z("columns"),children:d.jsx(jp,{})})}),V&&d.jsx(Rp,{anchorRef:C?ue:J,columns:e,visibleColumns:me,onVisibilityChange:R,onShowAll:ge,onHideAll:we,onColumnReorder:g,onColumnOrderReset:h,onClose:()=>W("columns"),showNonHideableColumns:O})]}),a&&d.jsxs("div",{ref:ee,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[E?E({onClick:()=>z("filters"),isOpen:Q,activeCount:he}):d.jsx(Ln,{title:"Filters",children:d.jsxs("button",{type:"button",ref:se,className:`ogx-toolbar__icon-btn${Q?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Advanced filters","aria-haspopup":"dialog","aria-expanded":Q,onClick:()=>z("filters"),children:[d.jsx(Xs,{}),he>0&&d.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Filters active"})]})}),Q&&d.jsx(qp,{anchorRef:E?ee:se,columns:e,filterModel:l||{items:[]},onFilterModelChange:a,onClose:()=>W("filters")})]}),i&&d.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[d.jsx(Ln,{title:"Pivot",children:d.jsxs("button",{type:"button",ref:U,className:`ogx-toolbar__icon-btn${B?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure pivot","aria-haspopup":"dialog","aria-expanded":B,onClick:()=>z("pivot"),children:[d.jsx(js,{}),$&&d.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Pivot active"})]})}),B&&d.jsx(Hp,{anchorRef:U,columns:t??e,model:T,onChange:ae=>{i?.(ae)},onClose:()=>W("pivot")})]}),o&&d.jsxs("div",{ref:D,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[S?S({onClick:()=>z("summaries"),isOpen:v,activeCount:G}):d.jsx(Ln,{title:"Summaries",children:d.jsxs("button",{type:"button",ref:X,className:`ogx-toolbar__icon-btn${v?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure summaries","aria-haspopup":"dialog","aria-expanded":v,onClick:()=>z("summaries"),children:[d.jsx(qs,{}),G>0&&d.jsx("span",{className:"ogx-toolbar__dot","aria-label":`${G} active summaries`})]})}),v&&d.jsx(Up,{anchorRef:S?D:X,aggregationModel:n,aggregableColumns:Z,onFunctionChange:Y,onClearAll:j,onClose:()=>W("summaries"),activeCount:G})]}),N&&N(),b]})]})}function Zp(){const[e]=s.useState(Bl);return s.useRef(e)}function nn(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 Qp=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 eh(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 th(e){let t="",n=!1;for(const o of e){const r=o.codePointAt(0)??0;if(r<=255||Qp.has(r)){t+=o;continue}const i=eh(r);i!==null?t+=i:(t+="?",n=!0)}return{text:t,lossy:n}}const nh={sliceMs:30,renderChunkRows:40},oh=2e4;function Ys(){return new Promise(e=>setTimeout(e,0))}function rh(){return new DOMException("PDF export was aborted","AbortError")}const on=()=>typeof performance<"u"?performance.now():Date.now(),Js=e=>Math.max(2,Math.floor(e/2)*2),ih=[79,70,229],lh=[255,255,255];function Zs(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 Qs(e,t){return In(e,t,Nn(e,t))}function ea(e){return(typeof e.width=="number"?e.width:void 0)??(e.flex??1)*100}function sh(e,t){const n=e.reduce((r,i)=>r+ea(i),0),o={};return e.forEach((r,i)=>{o[i]={cellWidth:ea(r)/n*t}}),o}const ah=new Set(["isEmpty","isNotEmpty"]);function ch(e,t){const o=t.find(l=>l.field===e.field)?.headerName??e.field;if(ah.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 ta(e,t,n,o){const r=e.map(l=>"items"in l?ta(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 dh(e,t){const n=[],o=ta(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 fh(e,t,n={}){return gh(e,t,n,nh)}async function gh(e,t,n,o){const{signal:r,onProgress:i}=n,l=()=>{if(r?.aborted)throw rh()};l();let a,c;try{const[j,q]=await Promise.all([import("jspdf"),import("jspdf-autotable")]);a=j.default,c=q.default}catch{throw new Error("exportToPdf requires 'jspdf' and 'jspdf-autotable'. Run: npm install jspdf jspdf-autotable")}const{fileName:u="export",title:g,logoUrl:h,orientation:x="landscape",selectedRows:y,getRowId:p,aggregationResult:f,aggregationModel:m,filterModel:b,alternateRowColor:w=!0,headerBackgroundColor:C="#4f46e5",headerTextColor:E="#ffffff",fontSize:S=9,groupedRows:N,font:M,maxRows:_=oh}=n;l();let O=on();const L=async()=>{on()-O<o.sliceMs||(await Ys(),l(),O=on())},A=(j,q,ne)=>{i?.({phase:j,done:q,total:ne})},k=new a({orientation:x,unit:"mm",format:"a4"}),I=k.internal.pageSize.getWidth(),P=k.internal.pageSize.getHeight(),v=14,B=I-v*2;let V="helvetica";M&&(k.addFileToVFS(`${M.name}-normal.ttf`,M.data),k.addFont(`${M.name}-normal.ttf`,M.name,"normal"),M.boldData&&k.addFileToVFS(`${M.name}-bold.ttf`,M.boldData),k.addFont(M.boldData?`${M.name}-bold.ttf`:`${M.name}-normal.ttf`,M.name,"bold"),V=M.name);let Q=!1;const H=j=>{if(M)return j;const q=th(j);return q.lossy&&(Q=!0),q.text},z=(j,q,ne,he,me)=>{const R=k.splitTextToSize(H(j),he);return k.text(R.length===1?R[0]:R,q,ne),Math.max(0,R.length-1)*me*uh},W=Gt(t),re=Mn(N,y),oe=En(e,y,p);let fe=v;if(g){let j=v,q=v+8;if(h)try{k.addImage(h,"PNG",j,v,10,10),j+=14}catch{}const ne=I-v-j;k.setFontSize(16),k.setFont(V,"bold"),k.setTextColor(30,41,59),q+=z(g,j,q,ne,16),q+=6,k.setFontSize(8),k.setFont(V,"normal"),k.setTextColor(100,116,139);const he=new Date().toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),me=re?N.filter(R=>R.type==="leaf").length:oe.length;if(k.text(H(`Exported: ${he} • ${me} row${me!==1?"s":""}`),j,q),q+=5,b){const R=dh(b,t);R&&(q+=z(`Filters: ${R}`,j,q,ne,8),q+=5)}k.setDrawColor(226,232,240),k.setLineWidth(.3),k.line(v,q+2,I-v,q+2),fe=q+6}const le=[W.map(j=>H(j.headerName??j.field))],ce=m||{},K=j=>W.map(q=>Lr(q,ce[q.field],j[q.field],j)),de=[];let X;const te=j=>{de.push(j.map(H))};if(re){const j=N.length;A("prepare",0,j);for(let q=0;q<j;q++){const ne=N[q],he=" ".repeat(ne.depth*2);if(ne.type==="group-header"){const me=`${he}${nn(ne,t)}`;te(W.map((R,ge)=>ge===0?me:""))}else if(ne.type==="leaf"&&ne.row){const me=ne.row;te(W.map((R,ge)=>(ge===0?he:"")+Qs(me,R)))}else if(ne.type==="group-subtotal"&&ne.aggregatedValues){const me=K(ne.aggregatedValues);te(me.map((R,ge)=>ge===0?`${he}${en("Subtotal",R)}`:R))}else ne.type==="grand-total"&&ne.aggregatedValues&&(X=[K(ne.aggregatedValues).map((R,ge)=>ge===0?en("Grand Total",R):R).map(H)]);(q&63)===63&&(A("prepare",q+1,j),await L())}A("prepare",j,j)}else{const j=oe.length;A("prepare",0,j);for(let ne=0;ne<j;ne++)te(W.map(he=>Qs(oe[ne],he))),(ne&63)===63&&(A("prepare",ne+1,j),await L());const q=m?Qt(oe,_t(y),t,f,m):null;if(q&&m){const ne=W.some(me=>m[me.field]);X=[K(q).map((me,R)=>R===0&&ne?en("TOTAL",me):me).map(H)]}A("prepare",j,j)}l(),de.length>_&&process.env.NODE_ENV!=="production"&&console.warn(`[exportToPdf] Exporting ${de.length} table rows (maxRows: ${_}). 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.`),Q&&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 U=sh(W,B),[J,se,ue]=Zs(C,ih),[ee,D,T]=Zs(E,lh),$={head:le,styles:{fontSize:S,cellPadding:3,font:V,overflow:"linebreak"},headStyles:{fillColor:[J,se,ue],textColor:[ee,D,T],fontStyle:"bold"},...w?{alternateRowStyles:{fillColor:[248,250,252]}}:{},...X?{footStyles:{fillColor:[241,245,249],fontStyle:"bold",textColor:[0,0,0]}}:{},columnStyles:U,showHead:"everyPage",margin:{top:v,left:v,right:v,bottom:v+6}},F=de.length;A("render",0,F);let Z=0,G=Js(o.renderChunkRows);do{const j=de.slice(Z,Z+G),q=Z===0,ne=Z+j.length>=F,he=q?fe:k.lastAutoTable.finalY;let me=!0;const R=on();c(k,{...$,body:j,...ne&&X?{foot:X}:{},startY:q?fe:v,showFoot:ne&&X?"lastPage":"never",...q?{}:{willDrawPage:we=>{me?(me=!1,we.settings.showHead="never",we.cursor&&(we.cursor.y=he)):we.settings.showHead="everyPage"}}}),Z+=j.length,A("render",Z,F);const ge=on()-R;G=Js(ge>0?Math.min(G*4,G*(o.sliceMs/ge)):G*4),ne||(await Ys(),l(),O=on())}while(Z<F);const Y=k.getNumberOfPages();for(let j=1;j<=Y;j++)k.setPage(j),k.setFontSize(8),k.setTextColor(150,150,150),k.text(`Page ${j} of ${Y}`,I-v,P-8,{align:"right"}),await L();l(),A("save",0,1),k.save(`${u}.pdf`),A("save",1,1)}function An(e,t){const n=Nn(e,t);return{text:In(e,t,n),raw:n}}function rn(e,t,n){return e.map(o=>Lr(o,n[o.field],t[o.field],t))}const ph="\uFEFF";function hh(e,t,n={}){const{fileName:o="export.csv",includeHeaders:r=!0,delimiter:i=",",selectedRows:l,groupedRows:a,escapeFormulas:c=!0,bom:u=!0}=n,g=Gt(t),h=n.aggregationModel||{},x=(f,m=!1)=>po(c?ao(f,m):f,i),y=()=>g.map(f=>x(f.headerName||f.field)).join(i)+`
|
|
8
|
-
|
|
9
|
-
`}else if(f.
|
|
10
|
-
`}
|
|
11
|
-
|
|
12
|
-
`}
|
|
13
|
-
|
|
14
|
-
`}}Gr((u?ph:"")+p,o,"text/csv;charset=utf-8;")}function po(e,t){return t!==""&&e.includes(t)||e.includes('"')||e.includes(`
|
|
15
|
-
`)||e.includes("\r")?`"${e.replace(/"/g,'""')}"`:e}const ho="ogx-xls-text";function mh(e,t){return e.type!=="number"&&e.type!=="date"&&e.type!=="boolean"&&!St(t)}function wh(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 bh(e,t,n={}){const{fileName:o="export.xls",sheetName:r="Sheet1",includeHeaders:i=!0,selectedRows:l,groupedRows:a,escapeFormulas:c=!0}=n,u=Gt(t),g=n.aggregationModel||{},h=(m,b=!1)=>Pe(c?ao(m,b):m),x=m=>`<td class="${ho}">${m}</td>`;let p=`<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>${Pe(Ar(r))}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--><meta charset="UTF-8"><style>.${ho}{mso-number-format:"\\@";}</style></head><body><table border="1">`;i&&(p+="<thead><tr>",u.forEach(m=>{p+=`<th class="${ho}">${h(m.headerName||m.field)}</th>`}),p+="</tr></thead>"),p+="<tbody>";const f=(m,b,w="")=>{const C=w+h(m.text,St(m.raw));return mh(b,m.raw)?x(C):`<td>${C}</td>`};if(Mn(a,l))a.forEach(m=>{const b=" ".repeat(m.depth*2);if(m.type==="group-header")p+='<tr style="font-weight:bold;background:#e8eaf6;">',p+=`<td colspan="${u.length}" class="${ho}">${Pe(b)}${h(nn(m,t))}</td>`,p+="</tr>";else if(m.type==="leaf"&&m.row){const w=m.row;p+="<tr>",u.forEach((C,E)=>{p+=f(An(w,C),C,E===0?Pe(b):"")}),p+="</tr>"}else if((m.type==="group-subtotal"||m.type==="grand-total")&&m.aggregatedValues){const w=m.aggregatedValues,C=m.type==="grand-total"?"Grand Total":`${b}Subtotal`,E=rn(u,w,g);p+='<tr style="font-weight:bold;background:#f5f5f5;">',u.forEach((S,N)=>{if(N===0){p+=x(Pe(en(C,E[0])));return}p+=E[N]?`<td style="text-align:right;">${h(E[N],St(w[S.field]))}</td>`:"<td></td>"}),p+="</tr>"}});else{const m=En(e,l,n.getRowId);if(m.length===0){console.warn("No rows to export");return}m.forEach(w=>{p+="<tr>",u.forEach(C=>{p+=f(An(w,C),C)}),p+="</tr>"});const b=Qt(m,_t(l),t,n.aggregationResult,n.aggregationModel);if(b){p+='<tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',u.forEach(C=>{p+=g[C.field]?`<td style="text-align:right;font-weight:bold;">${Pe(g[C.field].toUpperCase())}</td>`:"<td></td>"}),p+='</tr><tr style="font-weight:bold;background-color:#f5f5f5;">';const w=rn(u,b,g);u.forEach((C,E)=>{p+=w[E]?`<td style="text-align:right;">${h(w[E],St(b[C.field]))}</td>`:"<td></td>"}),p+="</tr>"}}p+="</tbody></table></body></html>",Gr(p,wh(o),"application/vnd.ms-excel")}function xh(e,t,n={}){const{fileName:o="export.json",pretty:r=!0,selectedRows:i,groupedRows:l}=n,a=Gt(t),c=g=>{const h={};return a.forEach(x=>{h[x.field]=Nn(g,x)}),h};let u;if(Mn(l,i)){const g=[],h=[];let x;l.forEach(y=>{if(y.type==="group-header"){const p={group:nn(y,t),field:y.groupField??"",value:y.groupValue,rows:[],children:[]};for(;g.length>y.depth;)g.pop();g.length===0?h.push(p):(g[g.length-1].children??=[]).push(p),g.push(p)}else y.type==="leaf"&&y.row?g.length>0&&g[g.length-1].rows.push(c(y.row)):y.type==="group-subtotal"&&y.aggregatedValues&&g.length>0?(g[g.length-1].subtotals=vs(y.aggregatedValues,a),g.pop()):y.type==="grand-total"&&y.aggregatedValues&&(x=vs(y.aggregatedValues,a))}),u=x?{groups:h,grandTotal:x}:{groups:h}}else{const g=En(e,i,n.getRowId);if(g.length===0){console.warn("No rows to export");return}const h=g.map(c),x=Qt(g,_t(i),t,n.aggregationResult,n.aggregationModel);if(x){const y=n.aggregationModel||{},p={};a.forEach(m=>{y[m.field]&&(p[m.field]=y[m.field].toUpperCase())});const f={};a.forEach(m=>{x[m.field]!==void 0&&x[m.field]!==null&&(f[m.field]=x[m.field])}),u={data:h,aggregation:{labels:p,values:f}}}else u=h}Gr(r?JSON.stringify(u,null,2):JSON.stringify(u),o,"application/json;charset=utf-8;")}const yh=/^(?:https?:|data:image\/|blob:)/i,Ch=/^[a-z][a-z\d+.-]*:/i;function vh(e){const t=e.trim();return t?yh.test(t)?t:Ch.test(t)?null:t:null}async function _h(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(`
|
|
7
|
+
`?2:1):(o+=a,r+=1)}return(!l||n.length>0||o!=="")&&(n.push(o),t.push(n)),t}const Hd=/^\d+(?:\.\d*)?(?:e[+-]?\d+)?$/i,Bd=/^\.\d+(?:e[+-]?\d+)?$/i,Wd=/^\d{1,3}(?:,\d{3})+(?:\.\d*)?$/,Vd=/[\p{Sc}\s]/gu;function zd(e){let t=e.replace(Vd,"");if(t==="")return e.trim()===""?Oe(null):ot;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)),Wd.test(t))t=t.split(",").join("");else if(!Hd.test(t)&&!Bd.test(t))return ot;let r=Number(t);return Number.isFinite(r)?(o&&(r/=100),n&&(r=-r),Oe(r)):ot}const Rd=/^(\d{4}-\d{2}-\d{2})/,il=e=>String(e).padStart(2,"0"),Kd=e=>`${e.getFullYear()}-${il(e.getMonth()+1)}-${il(e.getDate())}`;function Ud(e,t){const n=e.trim();if(n==="")return Oe(null);const o=Qt(n);if(!o)return ot;if(typeof t=="number")return Oe(o.getTime());if(typeof t=="string"){const r=Kd(o);return Oe(Rd.test(t)&&t.length>10?r+t.slice(10):r)}return Oe(o)}const jd=new Set(["true","yes","1"]),qd=new Set(["false","no","0"]);function Xd(e,t){const n=e.trim().toLowerCase();return n===""?Oe(null):t?.trueLabel!==void 0&&n===t.trueLabel.trim().toLowerCase()?Oe(!0):t?.falseLabel!==void 0&&n===t.falseLabel.trim().toLowerCase()?Oe(!1):jd.has(n)?Oe(!0):qd.has(n)?Oe(!1):ot}function Yd(e,t){const n=e.trim();if(n==="")return Oe(null);if(!t||t.length===0)return ot;const o=n.toLowerCase();for(const r of t){const i=typeof r=="object"?r.value:r;if(String(i).toLowerCase()===o)return Oe(i)}for(const r of t)if(typeof r=="object"&&r.label.toLowerCase()===o)return Oe(r.value);return ot}function Jd(e,t,n){switch(t?.type){case"number":return zd(e);case"date":return Ud(e,n?.current);case"boolean":return Xd(e,n?.booleanLabels);case"singleSelect":return Yd(e,t.valueOptions);default:return Oe(e)}}function Zd(e,t,n,o){const{valueParser:r}=t;if(!r)return Jd(e,t,o);let i;try{i=r(e,{row:n,field:t.field,colDef:t})}catch{return ot}return i===void 0?ot:Oe(i)}function jo(e,t,n){const o=e.map(t),r=new Map;o.forEach((c,u)=>{r.has(c)||r.set(c,u)});const i=n.filter(c=>Ke(c.field)),l=new Map;i.forEach((c,u)=>{l.set(c.field,u)});const a=n.filter(c=>Je(c.field)).length;return{rows:e,rowIds:o,rowIndexById:r,columns:i,colIndexByField:l,dataColumnOffset:a}}function qo(e,t,n,o,r){const i=e.rowIds[o],l=e.columns[r];if(!l||Re(i,t.rowMetaMap))return!1;const a=t.getSpanOrigin?.(i,l.field);return a&&(a.rowId!==i||a.field!==l.field)?!1:wo({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 Qd(e,t){let n=1/0,o=-1/0,r=1/0,i=-1/0;for(const l of t){const a=e.rowIndexById.get(l.id),c=e.colIndexByField.get(l.field);a===void 0||c===void 0||(a<n&&(n=a),a>o&&(o=a),c<r&&(r=c),c>i&&(i=c))}return n===1/0?null:{top:n,bottom:o,left:r,right:i}}function ll(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 eu(e){const t=e?.type;return t===void 0||t==="string"||t==="image"}const sl=1e4,Rn=()=>({updated:[],failed:[],skipped:[]});function tu(e){process.env.NODE_ENV!=="production"&&console.warn(`[OpenGridX] Pasting ${e} cells. Pastes above ${sl} cells can be slow; consider importing the data instead.`)}function nu(e){const{apiRef:t,containerRef:n,selection:o,disableClipboardPaste:r,disableRangeClear:i}=e,l=s.useRef(e);s.useLayoutEffect(()=>{l.current=e});const a=s.useCallback(()=>{const{allRenderableRows:p,getRowId:f,navigationColumns:h}=l.current;return jo(p,f,h)},[]),c=s.useCallback(()=>{const{selection:p}=l.current;return p.enabled?p.getCurrentRange().resolved:null},[]),u=s.useCallback(p=>{const f=c();if(f&&p.rowIds[f.top]!==void 0&&p.columns[f.left])return{id:p.rowIds[f.top],field:p.columns[f.left].field};const h=l.current.focusedCell;return h&&h.id!==null&&Ke(h.field)?{id:h.id,field:h.field}:null},[c]),g=s.useCallback(async(p,f,h)=>{const b=a(),w=f??u(b);let C=p;const{onBeforeClipboardPaste:E}=l.current;if(E){const se=We(()=>E({text:C,anchor:w}));if(!se.ok)return vt("onBeforeClipboardPaste","onBeforeClipboardPaste threw; the paste was cancelled",se.error),Rn();if(se.value===!1)return Rn();typeof se.value=="string"&&(C=se.value)}if(!w)return Rn();const S=Gd(C),N=b.rowIndexById.get(w.id),M=b.colIndexByField.get(w.field);if(S.length===0||N===void 0||M===void 0)return Rn();const _=b.rowIds.length-1,F=b.columns.length-1,P=f?null:c(),L=P&&kt(P)>1?P:null,k=S.length===1&&S[0].length===1,I=S.reduce((se,ce)=>Math.max(se,ce.length),0);let A;k&&L?A=L:A={top:N,left:M,bottom:Math.min(N+S.length-1,_,L?L.bottom:_),right:Math.min(M+I-1,F,L?L.right:F)};const v=kt(A);v>sl&&tu(v);const{batchEdit:W,isCellEditable:V,rowMetaMap:Z,getSpanOrigin:H}=l.current,z={isCellEditable:V,rowMetaMap:Z,getSpanOrigin:H},B=[],re=[];for(let se=A.top;se<=A.bottom;se++){const ce=b.rowIds[se],R=W.getRow(ce)??b.rows[se],de=k?S[0]:S[se-A.top];for(let j=A.left;j<=A.right;j++){const te=k?S[0][0]:de?.[j-A.left];if(te===void 0)continue;const q=b.columns[j];if(!qo(b,z,R,se,j)){re.push({id:ce,field:q.field,reason:"notEditable"});continue}const Q=Zd(te,q,R,{current:Me(R,q.field,q)});if(!Q.ok){re.push({id:ce,field:q.field,reason:"invalidValue"});continue}B.push({id:ce,field:q.field,value:Q.value})}}if(l.current.selection.enabled){const{anchor:se,head:ce}=ll(b,A);l.current.selection.setModel([{anchor:se,head:ce}],h?"keyboard":"api")}const oe=await W.applyEdits(B,"paste"),ue={updated:oe.result.updated,failed:oe.result.failed,skipped:[...re,...oe.result.skipped]};return l.current.onClipboardPaste?.({...ue,text:C}),ue},[a,u,c]),m=s.useCallback(()=>{const p=c();if(!p||kt(p)<=1)return!1;const f=a(),{batchEdit:h,isCellEditable:b,rowMetaMap:w,getSpanOrigin:C}=l.current,E={isCellEditable:b,rowMetaMap:w,getSpanOrigin:C},S=[];for(let N=p.top;N<=p.bottom;N++){const M=f.rowIds[N];if(M===void 0)continue;const _=h.getRow(M)??f.rows[N];for(let F=p.left;F<=p.right;F++){const P=f.columns[F];!P||!qo(f,E,_,N,F)||S.push({id:M,field:P.field,value:eu(P)?"":null})}}return h.applyEdits(S,"clear"),!0},[c,a]),x=o.enabled&&!r,y=o.enabled&&!i;s.useEffect(()=>{const p=n.current;if(!p||!x&&!y)return;const f=N=>{const M=l.current.viewportRef.current;if(!M||N.defaultPrevented||l.current.isEditing)return!1;const _=On(N.target,M);return _==="grid"||_==="control"};let h=null;const b=()=>{if(!h)return;const{textarea:N,restore:M,timer:_}=h;h=null,window.clearTimeout(_);const F=document.activeElement===N;N.remove(),F&&M&&M.isConnected&&M.focus({preventScroll:!0})},w=()=>{b();const N=document.createElement("textarea");N.setAttribute("aria-hidden","true"),N.tabIndex=-1,N.className="ogx__paste-capture",N.style.cssText="position:fixed;top:0;left:-10000px;width:1px;height:1px;opacity:0;",p.appendChild(N);const M=document.activeElement instanceof HTMLElement?document.activeElement:null;h={textarea:N,restore:M,timer:window.setTimeout(b,250)},N.focus({preventScroll:!0})},C=N=>h!==null&&N.target===h.textarea,E=N=>{if(C(N)){const _=N.clipboardData?N.clipboardData.getData("text/plain"):"";N.preventDefault(),b(),_!==""&&g(_,void 0,!0);return}if(!x||!f(N)||!l.current.navigationColumns.some(_=>_.editable))return;const M=N.clipboardData?N.clipboardData.getData("text/plain"):"";M!==""&&(N.preventDefault(),g(M,void 0,!0))},S=N=>{if((N.ctrlKey||N.metaKey)&&!N.altKey&&!N.shiftKey&&(N.key==="v"||N.key==="V"||N.code==="KeyV")){x&&f(N)&&l.current.navigationColumns.some(M=>M.editable)&&w();return}!y||N.key!=="Delete"&&N.key!=="Backspace"||N.ctrlKey||N.metaKey||N.altKey||N.shiftKey||f(N)&&m()&&N.preventDefault()};return p.addEventListener("paste",E),p.addEventListener("keydown",S),()=>{b(),p.removeEventListener("paste",E),p.removeEventListener("keydown",S)}},[n,x,y,g,m]),s.useLayoutEffect(()=>{t.current.pasteText=(p,f)=>g(p,f,!1)},[t,g])}const ou=100;function ru(){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 al=()=>({updated:[],failed:[],skipped:[]});function iu(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 lu(e){const{apiRef:t,enabled:n,channel:o,containerRef:r}=e,i=s.useRef(e);s.useLayoutEffect(()=>{i.current=e});const l=s.useRef([]),a=s.useRef([]),c=s.useRef({canUndo:!1,canRedo:!1,size:0}),u=s.useRef(Promise.resolve()),g=s.useCallback(()=>{const b={canUndo:l.current.length>0,canRedo:a.current.length>0,size:l.current.length},w=c.current;w.canUndo===b.canUndo&&w.canRedo===b.canRedo&&w.size===b.size||(c.current=b,i.current.onHistoryChange?.(b))},[]),m=s.useCallback(b=>{if(!i.current.enabled||b.length===0)return;const w=l.current;w.push(b);const C=Math.max(1,i.current.limit);w.length>C&&w.splice(0,w.length-C),a.current=[],g()},[g]);s.useLayoutEffect(()=>(o.setListener(n?m:null),()=>o.setListener(null)),[o,n,m]);const x=s.useCallback(()=>{l.current=[],a.current=[],g()},[g]);s.useEffect(()=>{n||x()},[n,x]);const y=s.useCallback(b=>{const w=i.current,C=jo(w.allRenderableRows,w.getRowId,w.navigationColumns),E=Qd(C,b);if(!E)return;const{anchor:S,head:N}=ll(C,E);w.selection.enabled?w.selection.setModel([{anchor:S,head:N}],"keyboard"):w.setFocusedCell({id:S.id,field:S.field,rowIndex:E.top});const M=w.viewportRef.current;M&&(Nn(M,E.top-w.pinnedTopRowCount,w.layout.cumulativeHeights,w.layout.pinnedBottomHeight,w.rowHeight),mo(M,w.layout.unpinnedColsWithWidth.findIndex(_=>_.field===S.field),w.layout))},[]),p=s.useCallback(b=>{const w=async()=>{if(!i.current.enabled)return al();const E=b==="undo"?l:a,S=b==="undo"?a:l,N=E.current.pop();if(!N)return al();g();const M=N.map(P=>b==="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}}),_=await i.current.batchEdit.applyEdits(M,b);_.committed.length>0&&S.current.push(b==="undo"?_.committed.map(P=>({id:P.id,field:P.field,before:P.after,after:P.before})):_.committed);const F=new Set(_.result.failed.map(P=>P.id));if(F.size>0){const P=N.filter(L=>F.has(L.id));P.length>0&&E.current.push(P)}return g(),_.committed.length>0&&y(_.committed),_.result},C=u.current.then(w,w);return u.current=C,C},[g,y]),f=s.useCallback(()=>p("undo"),[p]),h=s.useCallback(()=>p("redo"),[p]);s.useEffect(()=>{const b=r.current;if(!b||!n)return;const w=C=>{if(C.defaultPrevented)return;const E=iu(C);if(!E)return;const S=i.current.viewportRef.current;if(!S||i.current.isEditing)return;const N=On(C.target,S);N!=="grid"&&N!=="control"||(C.preventDefault(),E==="undo"?f():h())};return b.addEventListener("keydown",w),()=>b.removeEventListener("keydown",w)},[r,n,f,h]),s.useLayoutEffect(()=>{const b=t.current;b.undo=f,b.redo=h,b.canUndo=()=>i.current.enabled&&l.current.length>0,b.canRedo=()=>i.current.enabled&&a.current.length>0,b.clearHistory=x},[t,f,h,x])}function su(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 Xo(e,t){return t===null?e:Number(e.toFixed(Math.min(t,20)))}function au(e,t){let n=0;for(const l of e){const a=su(l);n=a===null||n===null?null:Math.max(n,a)}const o=Xo(e[1]-e[0],n);for(let l=2;l<e.length;l++)if(Xo(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(Xo(r+o*l,n));return i}const cu=864e5,cl=e=>((e.getHours()*60+e.getMinutes())*60+e.getSeconds())*1e3+e.getMilliseconds(),du=e=>Math.round(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())/cu),uu=e=>e.getFullYear()*12+e.getMonth(),fu=(e,t)=>new Date(e,t+1,0).getDate();function Yo(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 gu(e,t){const n=e[e.length-1],o=e.every(l=>cl(l)===cl(n));if(o&&e.every(l=>l.getDate()===n.getDate())){const l=Yo(e.map(uu));if(l!==null&&l!==0){const a=[];for(let c=1;c<=t;c++){const u=n.getMonth()+l*c,g=n.getFullYear()+Math.floor(u/12),m=(u%12+12)%12,x=new Date(n.getTime());x.setFullYear(g,m,Math.min(n.getDate(),fu(g,m))),a.push(x)}return a}}if(o){const l=Yo(e.map(du));if(l===null)return null;const a=[];for(let c=1;c<=t;c++){const u=new Date(n.getTime());u.setDate(n.getDate()+l*c),a.push(u)}return a}const r=Yo(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 pu=e=>typeof e=="number"&&Number.isFinite(e),hu=e=>e instanceof Date&&!Number.isNaN(e.getTime());function mu(e,t){return e.length<2?null:e.every(pu)?au(e,t):e.every(hu)?gu(e,t):null}const wu=e=>e instanceof Date?new Date(e.getTime()):e;function bu(e,t,n){if(e.length===0||t<=0)return[];const o=n?mu(e,t):null;if(o)return o;const r=[];for(let i=0;i<t;i++)r.push(wu(e[i%e.length]));return r}function xu(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 yu(e,t,n){const o=(c,u)=>{const g=[];if(c<=u)for(let m=c;m<=u;m++)g.push(m);else for(let m=c;m>=u;m--)g.push(m);return g},i=n==="down"||n==="up"?o(e.left,e.right):o(e.top,e.bottom);let l,a;switch(n){case"down":l=o(e.top,e.bottom),a=t.bottom>e.bottom?o(e.bottom+1,t.bottom):[];break;case"up":l=o(e.bottom,e.top),a=t.top<e.top?o(e.top-1,t.top):[];break;case"right":l=o(e.left,e.right),a=t.right>e.right?o(e.right+1,t.right):[];break;default:l=o(e.right,e.left),a=t.left<e.left?o(e.left-1,t.left):[]}return i.map(c=>({line:c,source:l,targets:a}))}function Cu(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 vu(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 a=e.bottom;a>=Math.max(0,e.bottom-Su);a--)if(t(a)===l.rowId)return{row:a,field:l.field};return null}const Su=1e3,_u="ogx__cell-fill-handle";function ku(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 Eu(e){const{containerRef:t,viewportRef:n,selection:o,disableFillHandle:r,isEditing:i,allRenderableRows:l,getRowId:a,navigationColumns:c,columnIndexMap:u,getSpanOrigin:g}=e,m=s.useRef(e);s.useLayoutEffect(()=>{m.current=e});const x=o.enabled&&!r,y=s.useMemo(()=>c.some(_=>_.editable),[c]),p=o.resolved,f=s.useMemo(()=>{if(!x||!y||!p)return null;const _=c.filter(k=>Ke(k.field)).map(k=>k.field),P=vu(p,k=>{const I=l[k];return I===void 0?void 0:a(I)},_,g);if(!P)return null;const L=u.get(P.field);return L===void 0?null:{row:P.row,col:L}},[x,y,p,l,a,c,u,g]),h=s.useRef(!0);s.useEffect(()=>(h.current=!0,()=>{h.current=!1}),[]);const b=s.useCallback(()=>{const _=m.current;return jo(_.allRenderableRows,_.getRowId,_.navigationColumns)},[]),w=s.useCallback((_,F,P,L,k)=>{const I=Cu(F,P,L),A=v=>({id:_.rowIds[v.row],field:_.columns[v.col].field});m.current.selection.setModel([{anchor:A(I.anchor),head:A(I.head)}],k)},[]),C=s.useCallback(async(_,F,P,L,k,I,A)=>{const{batchEdit:v,isCellEditable:W,rowMetaMap:V,getSpanOrigin:Z}=m.current,H={isCellEditable:W,rowMetaMap:V,getSpanOrigin:Z},z=L==="down"||L==="up",B=ce=>{const R=_.rowIds[ce];return R===void 0?void 0:v.getRow(R)??_.rows[ce]},re=[],oe=[];for(const ce of yu(F,P,L)){if(ce.targets.length===0)continue;const R=te=>z?{r:te,c:ce.line}:{r:ce.line,c:te},de=[];for(const te of ce.source){const{r:q,c:Q}=R(te),ae=B(q),fe=_.columns[Q];!ae||!fe||Re(_.rowIds[q],V)||de.push(Me(ae,fe.field,fe))}if(de.length===0)continue;const j=bu(de,ce.targets.length,!k);ce.targets.forEach((te,q)=>{const{r:Q,c:ae}=R(te),fe=B(Q),ee=_.columns[ae],D=_.rowIds[Q];if(!fe||!ee||D===void 0)return;if(!qo(_,H,fe,Q,ae)){oe.push({id:D,field:ee.field,reason:"notEditable"});return}let T=j[q];const $=ee.fillValue;if($){const O=We(()=>$.call(ee,{row:fe,id:D,field:ee.field,colDef:ee,direction:L,sourceValues:de.slice(),index:q,value:T,copy:k}));if(!O.ok){vt(`fillValue:${ee.field}`,`fillValue of column "${ee.field}" threw; the cell was skipped`,O.error),oe.push({id:D,field:ee.field,reason:"invalidValue"});return}T=O.value}re.push({id:D,field:ee.field,value:T})})}w(_,P,L,I,A);const ue=await v.applyEdits(re,"fill"),se={updated:ue.result.updated,failed:ue.result.failed,skipped:[...oe,...ue.result.skipped],direction:L};return m.current.onFill?.(se),se},[w]),E=s.useRef(null),S=s.useCallback((_,F,P)=>{const L=E.current,k=m.current.viewportRef.current;if(!L||!k)return;const I=L.ctx,A=I.rowIndexById.get(_.id),v=I.colIndexByField.get(_.field);if(A===void 0||v===void 0)return;const W=F-L.x+k.scrollLeft-L.scrollLeft,V=P-L.y+k.scrollTop-L.scrollTop,Z=xu(L.source,{row:A,col:v},W,V);L.target=Z,Z?w(I,Z.rect,Z.direction,L.anchor,"pointer"):m.current.selection.setModel(L.sourceModel,"pointer")},[w]),N=s.useCallback(({cancelled:_,altKey:F})=>{const P=E.current;if(E.current=null,!P||!h.current)return;const L=P.ctx;if(_||!P.target){m.current.selection.setModel(P.sourceModel,"pointer");return}C(L,P.source,P.target.rect,P.target.direction,F,P.anchor,"pointer")},[C]),M=x&&y;return s.useEffect(()=>{const _=n.current;if(!_||!M)return;const F=P=>{if(P.button!==0||!(P.target instanceof Element))return;const L=P.target.closest(`.${_u}`);if(!L||L.closest(".ogx__viewport")!==_||m.current.isEditing)return;const{selection:k}=m.current,{range:I,resolved:A}=k.getCurrentRange();if(!I||!A)return;const v=b(),W=v.rowIds[A.bottom],V=v.columns[A.right];if(W===void 0||!V)return;P.preventDefault();const Z=_.ownerDocument;_.contains(Z.activeElement)||_.focus({preventScroll:!0}),We(()=>_.setPointerCapture(P.pointerId)),E.current={source:{top:A.top,bottom:A.bottom,left:A.left,right:A.right},sourceModel:[I],anchor:{row:A.anchorRow,col:A.anchorCol},ctx:v,x:P.clientX,y:P.clientY,scrollLeft:_.scrollLeft,scrollTop:_.scrollTop,target:null},k.startTrackedDrag({start:{id:W,field:V.field},x:P.clientX,y:P.clientY,pointerId:P.pointerId,onTrack:S,onEnd:N})};return _.addEventListener("pointerdown",F),()=>_.removeEventListener("pointerdown",F)},[n,M,b,S,N]),s.useEffect(()=>{const _=t.current;if(!_||!x)return;const F=P=>{if(P.defaultPrevented)return;const L=ku(P);if(!L)return;const k=m.current.viewportRef.current;if(!k||m.current.isEditing)return;const I=On(P.target,k);if(I!=="grid"&&I!=="control")return;const{range:A,resolved:v}=m.current.selection.getCurrentRange();if(!A||!v)return;P.preventDefault();const W={top:v.top,bottom:v.bottom,left:v.left,right:v.right},V=L==="down"?{...W,bottom:W.top}:{...W,right:W.left};(L==="down"?W.bottom===W.top:W.right===W.left)||C(b(),V,W,L,!0,{row:v.anchorRow,col:v.anchorCol},"keyboard")};return _.addEventListener("keydown",F),()=>_.removeEventListener("keydown",F)},[t,x,C,b]),{handle:i?null:f}}function Mu(e){const{props:t,apiRef:n,containerRef:o,viewportRef:r,selection:i,model:l,getPendingModel:a,focusedCell:c,setFocusedCell:u,allRenderableRows:g,getRowId:m,navigationColumns:x,columnIndexMap:y,isCellEditable:p,rowMetaMap:f,getSpanOrigin:h,isEditing:b,batchEdit:w,channel:C,layout:E,rowHeight:S,pinnedTopRowCount:N}=e,{disableClipboardPaste:M=!1,disableRangeClear:_=!1,onClipboardPaste:F,onBeforeClipboardPaste:P,undoRedo:L=!1,disableFillHandle:k=!1,onFill:I,onHistoryChange:A}=t;return $d({apiRef:n,selection:i,model:l,getPendingModel:a,focusedCell:c,setFocusedCell:u,containerRef:o}),nu({apiRef:n,containerRef:o,viewportRef:r,selection:i,disableClipboardPaste:M,disableRangeClear:_,focusedCell:c,allRenderableRows:g,getRowId:m,navigationColumns:x,isCellEditable:p,rowMetaMap:f,getSpanOrigin:h,isEditing:b,batchEdit:w,onClipboardPaste:F,onBeforeClipboardPaste:P}),lu({apiRef:n,enabled:!!L,limit:typeof L=="object"&&L.limit||ou,onHistoryChange:A,channel:C,batchEdit:w,isEditing:b,containerRef:o,viewportRef:r,selection:i,setFocusedCell:u,allRenderableRows:g,getRowId:m,navigationColumns:x,layout:E,rowHeight:S,pinnedTopRowCount:N}),Eu({containerRef:o,viewportRef:r,selection:i,disableFillHandle:k,isEditing:b,allRenderableRows:g,getRowId:m,navigationColumns:x,columnIndexMap:y,isCellEditable:p,rowMetaMap:f,getSpanOrigin:h,batchEdit:w,onFill:I})}const Nu=100;function dl(e){const{scrollTop:t,scrollHeight:n,clientHeight:o}=e;return n-t-o>=Nu?null:{visibleTop:t,visibleBottom:t+o,viewportHeight:o}}function Iu(e){return e<.5?3:e<3?5:e<15?12:e<40?20:30}function Lu(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}),a=s.useRef(null),c=s.useRef(null),u=s.useRef(null),g=s.useRef(!0),m=s.useRef(t),[x,y]=s.useState({scrollTop:0,scrollLeft:0,velocityOverscan:0});s.useEffect(()=>{m.current=t},[t]),s.useEffect(()=>()=>{a.current!==null&&cancelAnimationFrame(a.current),c.current!==null&&clearTimeout(c.current)},[]);const p=s.useCallback(b=>{const w=dl(b);if(!w){g.current=!0;return}if(!g.current)return;const C=m.current;C&&(g.current=!1,C(w))},[]),f=s.useCallback(b=>{const w=b.currentTarget,C=performance.now(),E=Dt(w),S=Math.abs(w.scrollTop-l.current.scrollTop)+Math.abs(E-l.current.scrollLeft),N=C-l.current.time,M=N>0?S/N:0,_=w.scrollTop!==l.current.scrollTop;l.current={scrollTop:w.scrollTop,scrollLeft:E,time:C},i.current={scrollTop:w.scrollTop,scrollLeft:E,velocity:M},a.current!==null&&cancelAnimationFrame(a.current),a.current=requestAnimationFrame(()=>{a.current=null;const{scrollTop:F,scrollLeft:P,velocity:L}=i.current;y({scrollTop:F,scrollLeft:P,velocityOverscan:Iu(L)})}),c.current!==null&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,y(F=>F.velocityOverscan===0?F:{...F,velocityOverscan:0})},200),_&&p(w)},[p]);s.useEffect(()=>{g.current=!0;const b=u.current;!b||r||o<=0||b.clientHeight===0||p(b)},[o,r,p]),s.useEffect(()=>{const b=u.current?.ownerDocument??(typeof document>"u"?null:document);if(!b||typeof MutationObserver>"u")return;const w=new MutationObserver(()=>{const C=u.current;if(!C)return;const E={scrollTop:C.scrollTop,scrollLeft:Dt(C)},S=i.current;E.scrollTop===S.scrollTop&&E.scrollLeft===S.scrollLeft||(i.current={...S,...E},l.current={...l.current,...E},y(N=>({...N,...E})))});return w.observe(b.documentElement,{attributes:!0,attributeFilter:["dir"],subtree:!0}),()=>w.disconnect()},[]);const h=s.useCallback(b=>{if(u.current=b,!b)return;const{scrollTop:w,scrollLeft:C}=i.current;if(w===0&&C===0)return;b.scrollTop=w,en(b,C);const E={scrollTop:b.scrollTop,scrollLeft:Dt(b)};(E.scrollTop!==w||E.scrollLeft!==C)&&(i.current={...i.current,...E},l.current={...l.current,...E},y(S=>({...S,...E})))},[]);return{scrollTop:x.scrollTop,scrollLeft:x.scrollLeft,overscanRows:Math.max(x.velocityOverscan,n),handleScroll:f,attachViewport:h}}function Pu(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:a}=i.contentRect;e(l,a)}});o.observe(n),t.current=o},[e])}function Au(e){const{setDimensions:t,viewportRef:n,...o}=e,{scrollTop:r,scrollLeft:i,overscanRows:l,handleScroll:a,attachViewport:c}=Lu(o),u=Pu(t),g=s.useCallback(m=>{n.current=m,u(m),c(m)},[n,u,c]);return{scrollTop:r,scrollLeft:i,overscanRows:l,handleScroll:a,setViewportElement:g}}function Tu(e){const[t,n]=s.useState(void 0);return s.useLayoutEffect(()=>{const o=xc(e.current?.ownerDocument);n(r=>r===o?r:o)},[e]),t}function Fu(e){const{layout:t,scrollTop:n,scrollLeft:o,viewportWidth:r,viewportHeight:i,autoHeight:l,rowReordering:a,hasDetailPanel:c,checkboxSelection:u,pinCheckboxColumn:g,pinExpandColumn:m,overscanRows:x=5,maxContentHeight:y=1/0}=e;return s.useMemo(()=>{const{unpinnedAccWidths:p,unpinnedColsWithWidth:f,leftPinnedCols:h,rightPinnedCols:b,totalWidth:w,leftWidth:C,rightWidth:E,unpinnedTotalWidth:S,systemColumnsWidth:N,cumulativeHeights:M,pinnedTopHeight:_,pinnedBottomHeight:F,unpinnedRowsHeight:P,rowHeights:L,unpinnedRowsLength:k}=t,I=r||1e3,A=l?_+P+F+50:i||600,v=6,W=Math.max(0,o-C),V=o+I-C;let Z=0,H=f.length-1,z=0,B=p.length-1;for(;z<=B;){const D=z+B>>>1;p[D]<W?z=D+1:B=D-1}Z=Math.max(0,z-v);for(let D=Z;D<p.length;D++){if((D===0?0:p[D-1])>V){H=Math.min(f.length-1,D+v);break}H=Math.min(f.length-1,D+v)}const re=Z>0?p[Z-1]:0,oe=S-p[H],ue=[...h,...re>0?[{field:"__spacer_left__",width:re,isSpacer:!0}]:[],...f.slice(Z,H+1),...oe>0?[{field:"__spacer_right__",width:oe,isSpacer:!0}]:[],...b],ce=I>0&&w>I?16:0,R=_+P+F+ce+2,de=R-_-F,j=Number.isFinite(y)?Math.max(0,Math.min(de,y-_-F)):de;let te=0,q=k-1,Q=0,ae=0,fe=M.length-1;for(;ae<=fe;){const D=ae+fe>>>1;M[D]<n?ae=D+1:fe=D-1}te=Math.max(0,ae-x),Q=te>0?M[te-1]:0;for(let D=te;D<M.length;D++)if(M[D]>=n+A){q=Math.min(k-1,D+x);break}const ee=(a?48:0)+(c&&m?48:0)+(u&&g?48:0);return{renderContext:{firstRowIndex:te,lastRowIndex:q,firstColumnIndex:Z,lastColumnIndex:H},offsetTop:Q,offsetLeft:0,totalHeight:R,virtualContainerHeight:j,pinnedTopHeight:_,pinnedBottomHeight:F,totalWidth:w,rowHeights:L,cumulativeHeights:M,virtualColumns:ue,columnMetrics:{leftPinnedWidth:C,rightPinnedWidth:E,unpinnedAccWidths:p,unpinnedCols:f,totalSpecialsWidth:N,pinnedSpecialsWidth:ee}}},[t,n,o,r,i,l,a,c,u,g,m,x,y])}function Ou(e){const{viewport:t,viewportRef:n,containerRef:o,layout:r,viewportWidth:i,viewportHeight:l,virtualization:a}=e,{scrollTop:c,scrollLeft:u,overscanRows:g,handleScroll:m,setViewportElement:x}=Au({...t,rowCount:r.unpinnedRowsLength,viewportRef:n}),y=Tu(o),p=Fu({layout:r,scrollTop:c,scrollLeft:u,viewportWidth:i,viewportHeight:l,...a,overscanRows:g,maxContentHeight:y??1/0});return{handleScroll:m,setViewportElement:x,maxContentHeight:y,virtualization:p}}function Du(e){const{apiRef:t,columns:n,getRowId:o,containerRef:r,disableKeyboardShortcut:i,getCellRangeCopyText:l}=e,a=s.useCallback(()=>r.current,[r]),{copySelectedRows:c}=Dd({getSelectedRowIds:()=>t.current.getSelectedRows(),getColumns:()=>n,getRows:()=>t.current.getAllFilteredRows(),getRowId:o,getRootElement:a,disableKeyboardShortcut:i,getShortcutText:l});s.useLayoutEffect(()=>{t.current.copySelectedRows=c},[c,t])}function $u(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:a}=n.current,c=i.current;if(c&&(o!==void 0&&o>=0&&Nn(c,o,l.cumulativeHeights,l.pinnedBottomHeight,a),r!==void 0&&r>=0)){const g=[...l.leftPinnedCols,...l.unpinnedColsWithWidth,...l.rightPinnedCols][r];if(!g)return;mo(c,l.unpinnedColsWithWidth.findIndex(m=>m.field===g.field),l)}}},[t])}const ul=50;function Jo(e,t,n,o){const r=Math.min(n??ul,t),i=Math.max(o??1/0,t);return Math.max(r,Math.min(i,e))}const Gu=".ogx";function fl(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,a)=>l+(parseFloat(a)||0),0);return o+i}function Hu(e,t){const n=typeof CSS<"u"&&CSS.escape?CSS.escape(t):t.replace(/["\\]/g,"\\$&"),o=l=>l.closest(Gu)===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 a=l.querySelector(".ogx__header-cell-content");a&&i(fl(l,a))}),e.querySelectorAll(`[role="gridcell"][data-field="${n}"]`).forEach(l=>{if(!o(l)||l.hasAttribute("aria-colspan"))return;const a=l.querySelector(":scope > .ogx__cell-content");a&&i(fl(l,a))}),r===null?null:Math.ceil(r)}function Bu(e,t,n){return Math.max(t??ul,Math.min(n??1/0,e))}function Wu(e){const{apiRef:t}=e,n=s.useRef(e);s.useLayoutEffect(()=>{n.current=e});const o=s.useCallback(i=>{const{containerRef:l,columns:a,onColumnResize:c}=n.current,u=l.current;if(!u)return;const g=[];for(const m of i??a.map(x=>x.field)){const x=a.find(p=>p.field===m);if(!x||x.resizable===!1)continue;const y=Hu(u,m);y!==null&&g.push([m,Bu(y,x.minWidth,x.maxWidth)])}for(const[m,x]of g)c(m,x)},[]),r=s.useCallback(i=>o([i]),[o]);return s.useLayoutEffect(()=>{t.current.autosizeColumn=r,t.current.autosizeColumns=o},[t,r,o]),r}function Vu(e){const{apiRef:t,containerRef:n,viewportRef:o,copyColumns:r,getRowId:i,disableClipboardCopy:l,getCellRangeCopyText:a,layout:c,rowHeight:u,orderedColumns:g,onColumnResize:m}=e;return Du({apiRef:t,columns:r,getRowId:i,containerRef:n,disableKeyboardShortcut:l,getCellRangeCopyText:a}),$u({apiRef:t,viewportRef:o,layout:c,rowHeight:u}),Wu({apiRef:t,containerRef:n,columns:g,onColumnResize:m})}class gl extends Error{}function ft(e,t){return e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Object.is(e,t)}function pl(e){return typeof e=="object"&&e!==null&&typeof e.then=="function"}function hl(e,t){t?t(e):process.env.NODE_ENV!=="production"&&e instanceof gl&&console.error(e.message)}function ml(e,t){return new gl(`[OpenGridX] processRowUpdate must return the updated row object (or a Promise of it); it returned ${e===null?"null":typeof e}. ${t}`)}function wl(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 zu(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(c=>{const u=n.current.get(c);return u===void 0?t.current.rowsLookup.get(c):u},[]),i=s.useCallback(c=>{c.size!==0&&(c.forEach((u,g)=>{n.current.set(g,u)}),t.current.replaceRows(c))},[]),l=s.useCallback((c,u)=>{i(new Map([[c,u]]))},[i]),a=s.useCallback((c,u)=>{const{columns:g,processRowUpdate:m}=t.current,x=S=>hl(S,t.current.onProcessRowUpdateError),y=new Map,p=new Map;g.forEach((S,N)=>{y.set(S.field,N),p.set(S.field,S)});const f=[],h=new Map;for(const S of c){const N=r(S.id);if(N===void 0){f.push({id:S.id,field:S.field,reason:"missing"});continue}const M=p.get(S.field);if(S.expect&&!ft(Me(N,S.field,M),S.expect.value)){f.push({id:S.id,field:S.field,reason:"changed"});continue}let _=h.get(S.id);_||(_={id:S.id,row:N,cells:[]},h.set(S.id,_));const F=y.get(S.field)??Number.MAX_SAFE_INTEGER,P=_.cells.findIndex(k=>k.field===S.field),L={field:S.field,value:S.value,colDef:M,order:F};P===-1?_.cells.push(L):_.cells[P]=L}const b=[],w=[],C=o.current;h.forEach(S=>{const{id:N,row:M}=S,_=S.cells.filter(L=>!ft(Me(M,L.field,L.colDef),L.value)).sort((L,k)=>L.order-k.order);if(S.cells=_,_.length===0)return;const F=We(()=>{let L=M;for(const k of _)L=wl(L,k,k.colDef,C);return m?m(L,M):L});if(!F.ok){b.push({id:N,ok:!1,error:F.error});return}const P=F.value;pl(P)?w.push(Promise.resolve(P).then(L=>({id:N,ok:!0,processed:L}),L=>({id:N,ok:!1,error:L}))):b.push({id:N,ok:!0,processed:P})});const E=S=>{const N=new Map;S.forEach(L=>{N.set(L.id,L)});const M=[],_=[],F=[],P=new Map;return h.forEach(L=>{const k=N.get(L.id);if(!k)return;if(!k.ok){_.push({id:L.id,error:k.error}),x(k.error);return}const I=k.processed;if(typeof I!="object"||I===null){const v=ml(I,"The row was not saved.");_.push({id:L.id,error:v}),x(v);return}const A=I;P.set(L.id,A),M.push(L.id);for(const v of L.cells){const W=Me(L.row,v.field,v.colDef),V=Me(A,v.field,v.colDef);ft(W,V)||F.push({id:L.id,field:v.field,before:W,after:V})}}),i(P),F.length>0&&u!=="undo"&&u!=="redo"&&t.current.onCommitted?.(F,u),{result:{updated:M,failed:_,skipped:f},committed:F}};return w.length===0?Promise.resolve(E(b)):Promise.all(w).then(S=>E([...b,...S]))},[r,i]);return s.useMemo(()=>({applyEdits:a,getRow:r,storeRow:l}),[a,r,l])}const zt=Promise.resolve();function Ru(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),a=s.useRef(!1),c=s.useRef(e);s.useLayoutEffect(()=>{c.current=e}),s.useEffect(()=>(a.current=!0,()=>{a.current=!1}),[]);const u=s.useCallback(f=>{o.current=f,n(f)},[]),g=s.useRef(null),m=s.useCallback((f,h)=>{const b=i.current.get(f);if(b)return ft(b.value,h.value)?b.promise:b.promise.then(()=>{const H=o.current;if(!(r.current!==f||!H||ft(H.value,b.value)))return g.current?.(f,H)});const w=()=>r.current===f&&o.current!==null;if(ft(h.value,h.originalValue))return w()&&u(null),zt;const{rows:C,getRowId:E,columns:S,processRowUpdate:N}=c.current,M=C.find(H=>E(H)===h.id);if(!M)return w()&&u(null),zt;const _=H=>hl(H,c.current.onProcessRowUpdateError),F=S?.find(H=>H.field===h.field),P=H=>{if(typeof H!="object"||H===null){_(ml(H,"The edit was not saved and the editor stays open."));return}c.current.onRowChange?.(H,h.id);const{onCommitted:z}=c.current;if(z){const re=Me(M,h.field,F),oe=Me(H,h.field,F);ft(re,oe)||z([{id:h.id,field:h.field,before:re,after:oe}])}const B=o.current;r.current!==f||!B||(ft(B.value,h.value)?u(null):u({...B,originalValue:h.value}))};let L,k;const I=new Promise((H,z)=>{L=H,k=z}),A={value:h.value,promise:I};i.current.set(f,A);const v=()=>{i.current.get(f)===A&&i.current.delete(f)},W=We(()=>{const H=wl(M,h,F,l.current);return N?N(H,M):H});if(!W.ok)return v(),_(W.error),L(),I;const V=W.value,Z=H=>{v();try{P(H),L()}catch(z){k(z)}};return pl(V)?Promise.resolve(V).then(Z,H=>{v(),_(H),L()}):Z(V),I},[u]);s.useLayoutEffect(()=>{g.current=m},[m]);const x=s.useCallback(f=>{const h=o.current;if(h){if(h.id===f.id&&h.field===f.field)return;m(r.current,h)}r.current+=1,u({id:f.id,field:f.field,value:f.value,originalValue:f.value})},[m,u]),y=s.useCallback(f=>{const h=o.current;return!h||!a.current||f?.id!==void 0&&f.id!==h.id||f?.field!==void 0&&f.field!==h.field?zt:f?.cancel?(u(null),zt):m(r.current,h)},[m,u]),p=s.useCallback(f=>{const h=o.current;!h||h.id!==f.id||h.field!==f.field||u({...h,value:f.value})},[u]);return s.useMemo(()=>({editingCell:t,startCellEdit:x,stopCellEdit:y,setEditCellValue:p}),[t,x,y,p])}function Ku(e){const{rowsLookup:t,rows:n,getRowId:o,columns:r,processRowUpdate:i,onProcessRowUpdateError:l,replaceRows:a}=e,c=ru(),u=zu({rowsLookup:t,columns:r,processRowUpdate:i,onProcessRowUpdateError:l,replaceRows:a,onCommitted:c.emit}),g=Ru({rows:n,getRowId:o,columns:r,processRowUpdate:i,onProcessRowUpdateError:l,onRowChange:(m,x)=>{u.storeRow(x,m)},onCommitted:m=>c.emit(m,"edit")});return{editCommitChannel:c,batchEdit:u,editingHandlers:g}}const Uu=e=>e.id,ju={hasColSpan:!1,hasRowSpan:!1,colspanMap:new Map,rowSpanningCaches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},getSpanOrigin:()=>null,getUnpinnedColSpanRanges:()=>{},getCenterRowSpanStart:e=>e},bl="\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 qu(e){return e.map(t=>t.field).join(bl)}function Xu(e){const{pinnedTopRows:t,centerRows:n,pinnedBottomRows:o,columns:r,leftPinnedColumns:i,unpinnedColumns:l,rightPinnedColumns:a,expandedRowIds:c,rowMetaMap:u,getRowId:g=Uu}=e,m=s.useMemo(()=>r.some(b=>b.colSpan!==void 0&&b.colSpan!==null),[r]),x=s.useMemo(()=>r.some(b=>b.rowSpan!==void 0&&b.rowSpan!==null),[r]),y=m||x,p=y?[i,l,a].map(qu).join(xl):"",f=s.useMemo(()=>{if(!p)return{columns:[],leftCount:0,unpinnedCount:0};const b=new Map(r.map(S=>[S.field,S])),w=p.split(xl).map(S=>S?S.split(bl):[]),C=[];let E=0;for(const S of w){E+=S.length;for(const N of S){const M=b.get(N)??{field:N};C.push({colDef:M,field:N,sectionEnd:E,hasColSpan:M.colSpan!==void 0&&M.colSpan!==null,hasRowSpan:M.rowSpan!==void 0&&M.rowSpan!==null})}}return{columns:C,leftCount:w[0].length,unpinnedCount:w[1].length}},[p,r]),h=s.useMemo(()=>{if(!y||f.columns.length===0)return null;const b={colspanMap:new Map,rowSpanningCaches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},hiddenOriginFields:new Map,unpinnedRanges:new Map,centerRowSpanStart:new Map},C={spanColumns:f,expandedRowIds:c,rowMetaMap:u,getRowId:g,warned:new Set,out:b};return Zo(t,0,!1,C),Zo(n,t.length,!0,C),Zo(o,t.length+n.length,!1,C),b},[y,f,t,n,o,c,u,g]);return s.useMemo(()=>{if(!h)return ju;const{colspanMap:b,rowSpanningCaches:w,hiddenOriginFields:C,unpinnedRanges:E,centerRowSpanStart:S}=h,N=f.columns;return{hasColSpan:m,hasRowSpan:x,colspanMap:b,rowSpanningCaches:w,getSpanOrigin:(M,_)=>{const F=b.get(M)?.[_];if(F?.spannedByColSpan)return{rowId:M,field:N[F.leftVisibleCellIndex].field};const P=w.hiddenCellOriginMap[M]?.[_];return P===void 0?null:{rowId:P,field:C.get(M)?.[_]??_}},getUnpinnedColSpanRanges:M=>E.get(M),getCenterRowSpanStart:M=>S.get(M)??M}},[h,m,x,f])}function Zo(e,t,n,o){const{spanColumns:r,expandedRowIds:i,rowMetaMap:l,getRowId:a,warned:c,out:u}=o,{columns:g,leftCount:m,unpinnedCount:x}=r,y=g.length,{colspanMap:p,rowSpanningCaches:f,hiddenOriginFields:h,unpinnedRanges:b,centerRowSpanStart:w}=u,C=new Int32Array(y),E=new Array(y),S=new Array(y),N=new Int32Array(y);let M=0;const _=[];g.forEach((L,k)=>{(L.hasColSpan||L.hasRowSpan)&&_.push(k)});const F=(L,k,I)=>{const A=g[I].field;if(Rt(f.hiddenCells,L,A,!0),Rt(f.hiddenCellOriginMap,L,A,E[I]),S[I]!==A&&Rt(h,L,A,S[I]),n){const v=w.get(k);(v===void 0||N[I]<v)&&w.set(k,N[I])}},P=(L,k,I)=>{const A=g[I],v=a(L),W=Yu(L,v,A.colDef,t+k,I,l,c);let V=1;if(A.hasColSpan){const H=Math.min(Cl(A.colDef.colSpan,W,"colSpan",A.field,c),A.sectionEnd-I);for(;V<H&&C[I+V]<=k;)V++}let Z=1;if(A.hasRowSpan){Z=Math.min(Cl(A.colDef.rowSpan,W,"rowSpan",A.field,c),e.length-k);for(let H=1;H<Z;H++)if(Re(a(e[k+H]),l)){Z=H;break}if(Z>1&&i&&i.size>0){for(let H=0;H<Z-1;H++)if(i.has(a(e[k+H]))){Z=H+1;break}}}if(V>1){Rt(p,v,A.field,{spannedByColSpan:!1,cellProps:{colSpan:V}});for(let H=1;H<V;H++){const z=g[I+H];Rt(p,v,z.field,{spannedByColSpan:!0,leftVisibleCellIndex:I,rightVisibleCellIndex:I+V-1})}if(I>=m&&I<m+x){let H=b.get(v);H||(H=[],b.set(v,H)),H.push(I-m,I+V-1-m)}}if(Z>1){Rt(f.spannedCells,v,A.field,Z);for(let H=I;H<I+V;H++)C[H]=k+Z,E[H]=v,S[H]=A.field,N[H]=k;k+Z>M&&(M=k+Z)}return V};for(let L=0;L<e.length;L++){const k=e[L];if(!k||k._isSkeleton||Re(a(k),l))continue;if(M<=L){let A=0;for(const v of _)v>=A&&(A=v+P(k,L,v));continue}let I=0;for(;I<y;)C[I]>L?(F(a(k),L,I),I++):g[I].hasColSpan||g[I].hasRowSpan?I+=P(k,L,I):I++}}function Yu(e,t,n,o,r,i,l){const a=e[n.field];let c=a;if(n.valueGetter)try{c=n.valueGetter({row:e,field:n.field,value:a})}catch(u){vl(l,`valueGetter:${n.field}`,`valueGetter for column "${n.field}" threw while computing its span`,u),c=void 0}return{row:e,value:c,field:n.field,colDef:n,rowIndex:o,colIndex:r,rowMeta:i?.get(t)}}function Cl(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 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 Rt(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 Ju(e,t){const{draggedColumn:n,onDragOver:o,onDrop:r,onDragEnd:i}=t,l=s.useMemo(()=>{if(!e||e.length===0)return null;const a=c=>n===null||Vo(e,n,c);return{onDragOver:o&&(c=>a(c)?o(c):()=>{}),onDrop:r&&(c=>a(c)?r(c):u=>{u.preventDefault(),i?.()})}},[e,n,o,r,i]);return l?{...t,...l}:t}function Sl({dataSource:e,paginationMode:t,sortingMode:n,filterMode:o}){return!!e&&(t==="server"||t==="infinite"||n==="server"||o==="server")}const _l=Number.MAX_SAFE_INTEGER,Zu="An unexpected error occurred while loading the data.";function kl(e){return typeof e=="string"&&e?e:typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"&&e.message?e.message:Zu}const Qu=300,El=e=>e.id;function ef(e,t){return e==="infinite"?"infinite":e==="server"?t?"all":"page":"all"}function Ml(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 Nl(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 tf(e){const{dataSource:t,sortModel:n,filterModel:o,paginationModel:r,paginationMode:i,sortingMode:l,filterMode:a,aggregationModel:c,rowGroupingActive:u=!1}=e,g=ef(i,u),m=!!t&&i==="server"&&u,x=s.useRef(!1);s.useEffect(()=>{process.env.NODE_ENV==="production"||x.current||!m||(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."))},[m]);const y=t?.getRows,p=Sl({dataSource:t,paginationMode:i,sortingMode:l,filterMode:a}),f=JSON.stringify([g,g!=="all"||l==="server"?n:null,g!=="all"||a==="server"?o:null,p?c??null:null,g==="all"?null:r.pageSize]),h=g==="all"?0:r.page,b=g==="all"?0:r.pageSize,w=s.useRef({params:e,kind:g});s.useLayoutEffect(()=>{w.current={params:e,kind:g}});const C=s.useRef(0),E=s.useRef(0),S=s.useRef(null),N=s.useRef({page:0,loadedEnd:0,inFlightEnd:null}),M=s.useRef(null),_=s.useRef(!1),F=s.useRef(0),P=s.useRef(!1),L=s.useRef(new Set),k=s.useCallback(()=>{const z=_.current||F.current>0;z!==P.current&&(P.current=z,w.current.params.setDataSourceLoading(z))},[]),I=s.useCallback(()=>{M.current!==null&&(clearTimeout(M.current),M.current=null)},[]),A=s.useCallback(()=>{C.current++,N.current.inFlightEnd=null,_.current=!1},[]),v=s.useCallback(()=>{E.current++,L.current.clear(),F.current=0},[]),W=s.useCallback(async()=>{const{params:z,kind:B}=w.current,re=z.dataSource;if(!re)return!1;const oe=N.current,ue=z.paginationModel.pageSize;let se,ce;if(B==="infinite"){if(oe.inFlightEnd!==null)return!1;if(se=oe.loadedEnd,ce=(oe.page+1)*ue,ce<=se)return _.current=!1,k(),!1;oe.inFlightEnd=ce}else B==="page"?(se=z.paginationModel.page*ue,ce=se+ue):(se=0,ce=_l);const R=++C.current;_.current=!0,k(),z.setDataSourceError(null);let de;try{de=await re.getRows({startRow:se,endRow:ce,sortModel:z.sortModel,filterModel:z.filterModel,groupKeys:[],aggregationModel:z.aggregationModel})}catch(j){return R!==C.current||(oe.inFlightEnd=null,_.current=!1,w.current.params.setDataSourceError(j),console.error("Data Source Error:",j),k()),!1}if(R!==C.current)return!1;try{const{params:j}=w.current,te=j.getRowId??El,q=Ml(de.rows,te);if(B==="infinite"&&se>0?j.setRows(Q=>Nl(Q,q,te),!0):(j.setRows(q.map(Q=>Q.row),!0),v()),de.aggregationResults&&j.onAggregationResults?.(de.aggregationResults),de.rowCount!==void 0&&j.setRowCount(de.rowCount),B==="infinite"&&(oe.inFlightEnd=null,oe.loadedEnd=se+de.rows.length,de.rows.length>=ce-se&&(oe.page+1)*ue>ce))return!0}catch(j){return oe.inFlightEnd=null,_.current=!1,w.current.params.setDataSourceError(j),console.error("Data Source Error:",j),k(),!1}return _.current=!1,k(),!1},[k,v]),V=s.useCallback(async()=>{for(;await W(););},[W]);s.useLayoutEffect(()=>{if(!y){S.current&&(S.current=null,I(),A(),v(),w.current.params.setDataSourceError(null),k());return}const z=S.current,B=N.current;if(!z||z.key!==f||z.getRows!==y){S.current={key:f,getRows:y},A(),v();const re=g==="infinite"&&z!==null&&h!==0;if(B.page=re?0:h,B.loadedEnd=0,re){const{params:oe}=w.current;oe.onPaginationModelChange?.({...oe.paginationModel,page:0})}}else g==="infinite"?(h<B.page&&(A(),B.loadedEnd=0),B.page=h):A();if(g==="infinite"){const re=B.inFlightEnd!==null;if(re||(B.page+1)*b<=B.loadedEnd){_.current=re,k();return}}return _.current=!0,k(),M.current=setTimeout(()=>{M.current=null,V()},Qu),I},[y,f,g,h,b,I,A,v,k,V]),s.useEffect(()=>()=>{A(),v()},[A,v]);const Z=s.useCallback(()=>(I(),V()),[I,V]),H=s.useCallback(async(z,B,re)=>{const{params:oe}=w.current,ue=oe.dataSource;if(!ue)return;const se=JSON.stringify(B),ce=L.current;if(ce.has(se))return;const R=E.current;ce.add(se),F.current++,k();try{const de=await ue.getRows({startRow:0,endRow:_l,sortModel:oe.sortModel,filterModel:oe.filterModel,groupKeys:B,aggregationModel:oe.aggregationModel});if(R!==E.current)return;if(de.rows.length>0){const{params:j}=w.current,te=j.getRowId??El,q=Ml(de.rows,te);j.setRows(Q=>Nl(Q,q,te),!0)}}catch(de){if(R!==E.current)return;ce.delete(se),console.error("Failed to fetch children:",de),re?.(de)}finally{R===E.current&&(F.current--,k())}},[k]);return{fetchRows:Z,fetchChildren:H}}function nf(e){return(e.serverChildrenCount??0)>0&&(e.children?.length??0)===0}function of({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((a,c)=>{!nf(a)||!n(c)||i(c,o(c),()=>{const{isGroupExpanded:u,toggleExpansion:g}=l.current;u(c)&&g(c)})})},[e,t,n,o,i])}const Il={};function rf(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 Ll(e){const{rows:t,columns:n,aggregationModel:o,isServerSide:r,dataSource:i,filterModel:l,sortModel:a,serverAggregationResults:c}=e,u=Object.keys(o).length>0,g=s.useMemo(()=>{const S=new Map;return(n??[]).forEach(N=>S.set(N.field,N)),S},[n]),m=s.useMemo(()=>r||!u?Il:In(t,o,g,"useAggregation"),[t,g,o,r,u]),x=JSON.stringify([o,l??null,a??[]]),y=r&&u&&!!i?.getAggregations&&!c,p=s.useRef({aggregationModel:o,filterModel:l,sortModel:a});s.useEffect(()=>{p.current={aggregationModel:o,filterModel:l,sortModel:a}});const[f,h]=s.useState(null);s.useEffect(()=>{const S=i?.getAggregations;if(!y||!S)return;let N=!1;const M=p.current,_={sortModel:M.sortModel??[],filterModel:M.filterModel??{items:[]},groupKeys:[],aggregationModel:M.aggregationModel};let F;try{F=Promise.resolve(S(_))}catch(P){F=Promise.reject(P)}return F.then(P=>{N||h({key:x,result:P,error:null})},P=>{N||(console.error("[useAggregation] Server aggregation error:",P),h({key:x,result:null,error:P}))}),()=>{N=!0}},[y,i,x]);const b=f&&f.key===x?f:null,w=y&&b===null,C=y?b?.error??null:null;return{aggregationResult:s.useMemo(()=>r?c&&Object.keys(c).length>0?c:b?.result??Il:m,[r,m,c,b]),isLoading:w,error:C}}const lf={items:[]},sf=[];function af(e){const{rows:t,columns:n,pivotMode:o,pivotModel:r,filterModel:i,sortModel:l,hasDataSource:a,hierarchyRequested:c}=e,u=o&&!a,g=s.useMemo(()=>new Set(n.map(b=>b.field)),[n]),m=s.useMemo(()=>No(n),[n]),x=s.useMemo(()=>Ra(i,g),[i,g]),y=s.useMemo(()=>u?So(t,x.source,m):t,[u,t,x.source,m]),p=s.useMemo(()=>u?mi(y,n,r,{outputFilterModel:x.output,sortModel:l}):Lo,[u,y,n,r,x.output,l]),f=u&&p.isValid,h=s.useRef({dataSource:!1,hierarchy:!1});return s.useEffect(()=>{process.env.NODE_ENV!=="production"&&(o&&a&&!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`.")),f&&c&&!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,a,f,c]),{isActive:f,rows:f?p.pivotRows:t,columns:f?p.pivotColumns:n,pipelineFilterModel:f?lf:i,pipelineSortModel:f?sf:l}}const Pl=s.createContext(null);function cf(e){if(typeof e!="function")return!1;const t=e.prototype;return!(typeof t=="object"&&t!==null&&"isReactComponent"in t)}function df({render:e,toolbarProps:t}){"use no memo";return d.jsx(d.Fragment,{children:e(t)})}function uf({component:e,toolbarProps:t}){if(cf(e))return d.jsx(df,{render:e,toolbarProps:t},`fn:${e.toString()}`);const n=e;return d.jsx(n,{...t})}const Qe=({variant:e="text",size:t="medium",color:n="default",disabled:o=!1,className:r="",type:i="button",children:l,...a})=>{const c=["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:c,disabled:o,...a,children:l})},et=s.forwardRef(function({fullWidth:t=!1,error:n=!1,startAdornment:o,endAdornment:r,className:i="",inputClassName:l="",variant:a="field",...c},u){const g=["ogx-input-wrapper",a==="cell"&&"ogx-input-wrapper--cell",t&&"ogx-input-wrapper--full-width",n&&"ogx-input-wrapper--error",c.disabled&&"ogx-input-wrapper--disabled",i].filter(Boolean).join(" "),m=["ogx-input",l].filter(Boolean).join(" ");return d.jsxs("div",{className:g,children:[o&&d.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--start",children:o}),d.jsx("input",{ref:u,className:m,"aria-invalid":n?!0:void 0,...c}),r&&d.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--end",children:r})]})});et.displayName="Input";function ff(){if(typeof window>"u")return null;const e=window;return e.SpeechRecognition??e.webkitSpeechRecognition??null}function gf(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&&We(()=>l.abort())},[]);const i=s.useCallback(()=>{const l=o.current;if(l){We(()=>l.stop());return}const a=ff();if(!a)return;const c=We(()=>new a);if(!c.ok)return;const u=c.value;u.lang=typeof navigator>"u"?"en-US":navigator.language,u.interimResults=!1,u.maxAlternatives=1,u.onresult=m=>{const x=m.results[0],y=x&&x[0]?x[0].transcript:"";y&&r.current(y)};const g=()=>{o.current===u&&(o.current=null),n(!1)};u.onend=g,u.onerror=g,o.current=u,n(!0),We(()=>u.start()).ok||g()},[]);return{listening:t,toggle:i}}function Al(){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 pf(){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 hf(e){const{status:t,statusText:n,message:o,errors:r,chips:i,history:l,suggestions:a,placeholder:c,voiceAvailable:u,canUndo:g,submit:m,stop:x,undo:y,removeChip:p,close:f}=e,[h,b]=s.useState(""),w=s.useRef(null),C=gf(b),E=t==="running";s.useEffect(()=>{w.current&&w.current.focus()},[]);const S=_=>{b(_),m(_)},N=_=>()=>{_(),w.current&&w.current.focus()},M=_=>{_.preventDefault(),E||m(h)};return d.jsxs("div",{className:"ogx-ai-panel",role:"dialog","aria-label":"Ask AI",children:[d.jsxs("div",{className:"ogx-ai-panel__header",children:[d.jsxs("span",{className:"ogx-ai-panel__title",children:[d.jsx(Al,{}),"Ask AI"]}),d.jsx(Qe,{size:"small",className:"ogx-ai-panel__close","aria-label":"Close",onClick:f,children:"×"})]}),d.jsxs("form",{className:"ogx-ai-panel__form",onSubmit:M,children:[d.jsx(et,{ref:w,className:"ogx-ai-panel__input",value:h,placeholder:c,"aria-label":"Prompt",autoComplete:"off",onChange:_=>b(_.target.value)}),u&&d.jsx(Qe,{size:"small",variant:"outlined",className:`ogx-ai-panel__mic${C.listening?" ogx-ai-panel__mic--on":""}`,"aria-label":C.listening?"Stop dictation":"Dictate a prompt","aria-pressed":C.listening,onClick:C.toggle,children:d.jsx(pf,{})}),E?d.jsx(Qe,{size:"small",variant:"outlined",onClick:N(x),children:"Stop"},"stop"):d.jsx(Qe,{size:"small",variant:"contained",color:"primary",type:"submit",disabled:h.trim()==="",children:"Ask"},"ask")]}),a.length>0&&d.jsx("div",{className:"ogx-ai-panel__suggestions","aria-label":"Suggestions",role:"group",children:a.map(_=>d.jsx("button",{type:"button",className:"ogx-ai-panel__suggestion",disabled:E,onClick:()=>S(_),children:_},_))}),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||g)&&d.jsxs("div",{className:"ogx-ai-panel__changes",children:[d.jsx("ul",{className:"ogx-ai-panel__chips","aria-label":"Applied changes",children:i.map(_=>d.jsxs("li",{className:"ogx-ai-chip","data-part":_.part,children:[d.jsx("span",{className:"ogx-ai-chip__label",children:_.label}),d.jsx("button",{type:"button",className:"ogx-ai-chip__remove","aria-label":`Remove ${_.label}`,onClick:N(()=>p(_.id)),children:"×"})]},_.id))}),g&&d.jsx(Qe,{size:"small",variant:"outlined",className:"ogx-ai-panel__undo",onClick:N(y),children:"Undo"})]}),r.length>0&&d.jsx("ul",{className:"ogx-ai-panel__errors","aria-label":"Ignored",children:r.map((_,F)=>d.jsx("li",{children:_.path?`Ignored: ${_.message}`:_.message},`${_.path}:${F}`))}),l.length>0&&d.jsxs("div",{className:"ogx-ai-panel__history",children:[d.jsx("div",{className:"ogx-ai-panel__history-title",children:"Earlier"}),d.jsx("ul",{children:l.map((_,F)=>d.jsx("li",{children:d.jsx("button",{type:"button",className:"ogx-ai-panel__history-item",onClick:()=>b(_.prompt),children:_.prompt})},`${F}:${_.prompt}`))})]})]})}function mf({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(hf,{...e})})}function Tl(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},a){const c=s.useRef(null),u=s.useCallback(m=>{c.current=m,Tl(i,m),Tl(a,m)},[i,a]);s.useEffect(()=>{c.current&&(c.current.indeterminate=t)},[t]);const g=["ogx-checkbox-wrapper",l.disabled&&"ogx-checkbox-wrapper--disabled",o].filter(Boolean).join(" ");return d.jsxs("label",{className:g,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 wf(){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 bf(){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 Qo(e){const{columns:t,visibleColumns:n,onVisibilityChange:o,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:a,showNonHideableColumns:c}=e,[u,g]=s.useState(""),m=s.useId(),[x,y]=s.useState(null),p=s.useRef(null),f=s.useMemo(()=>t.filter(_=>_.hideable!==!1),[t]),h=f.every(_=>n.has(_.field)),b=s.useMemo(()=>{const _=c?t:f;if(!u)return _;const F=u.toLowerCase();return _.filter(P=>(P.headerName||P.field).toLowerCase().includes(F))},[t,f,u,c]),w=_=>{_.target.checked?r():i()},C=_=>F=>{p.current=_,F.dataTransfer.effectAllowed="move",F.dataTransfer.setDragImage(F.currentTarget.closest(".ogx-column-visibility-panel__item"),20,20)},E=_=>F=>{F.preventDefault(),F.dataTransfer.dropEffect="move",_!==p.current&&y(_)},S=()=>{y(null)},N=_=>F=>{F.preventDefault();const P=p.current;y(null),p.current=null,P&&P!==_&&l&&l(P,_)},M=()=>{y(null),p.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(wf,{}),d.jsx(et,{autoComplete:"off",inputClassName:"ogx-column-visibility-panel__search-input",placeholder:"Search",value:u,onChange:_=>g(_.target.value)})]})}),d.jsx("div",{className:"ogx-column-visibility-panel__list",children:b.map((_,F)=>{const P=`${m}-col-${F}`,L=n.has(_.field),k=_.hideable!==!1,I=x===_.field,A=!!l&&!u;return d.jsxs("div",{className:["ogx-column-visibility-panel__item",!k&&"ogx-column-visibility-panel__item--disabled",I&&"ogx-column-visibility-panel__item--drag-over"].filter(Boolean).join(" "),draggable:A,onDragOver:A?E(_.field):void 0,onDragLeave:A?S:void 0,onDrop:A?N(_.field):void 0,onDragEnd:A?M:void 0,children:[A&&d.jsx("span",{className:"ogx-column-visibility-panel__drag-handle-wrapper",draggable:!0,onDragStart:C(_.field),title:"Drag to reorder",children:d.jsx(bf,{})}),d.jsxs("div",{className:"ogx-column-visibility-panel__item-label",style:{display:"flex",alignItems:"center",gap:"var(--ogx-spacing-md)",flex:1,cursor:k?"pointer":"not-allowed"},children:[d.jsx(gt,{id:P,checked:L,onChange:v=>o(_.field,v.target.checked),disabled:!k}),d.jsx("label",{htmlFor:P,className:"ogx-column-visibility-panel__label",children:_.headerName||_.field})]})]},_.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:`${m}-all`,checked:h,onChange:w}),d.jsx("label",{htmlFor:`${m}-all`,className:"ogx-column-visibility-panel__label",children:"Show/Hide All"})]}),d.jsx("button",{type:"button",className:"ogx-column-visibility-panel__reset-btn",onClick:()=>{r(),a?.()},children:"Reset"})]})]})}function Nt(){return document.documentElement.clientWidth||window.innerWidth}function Fl(){return document.documentElement.clientHeight||window.innerHeight}function xf({isOpen:e,containerRef:t,panelRef:n,columns:o,columnVisibilityModel:r,disableColumnReorder:i,onClose:l,onColumnVisibilityChange:a,onColumnMove:c,onColumnOrderReset:u,columnGroupingModel:g}){const[m,x]=s.useState(null);if(s.useLayoutEffect(()=>{if(!e||!t.current)return;const p=t.current.getBoundingClientRect();x({top:p.top+8,right:Nt()-p.right+8,target:t.current.closest(".ogx-theme-provider")||document.body})},[e,t]),!e||!m)return null;const y=i?void 0:(p,f)=>{Vo(g,p,f)&&c(p,f)};return st.createPortal(d.jsxs("div",{ref:n,style:{position:"fixed",top:m.top,right:m.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":"Close",children:"×"}),d.jsx(Qo,{columns:o,visibleColumns:new Set(o.filter(p=>r[p.field]!==!1).map(p=>p.field)),onVisibilityChange:(p,f)=>{a({...r,[p]:f})},onShowAll:()=>{const p={...r};o.forEach(f=>{f.hideable!==!1&&(p[f.field]=!0)}),a(p)},onHideAll:()=>{const p={...r};o.forEach(f=>{f.hideable!==!1&&(p[f.field]=!1)}),a(p)},onColumnReorder:y,onColumnOrderReset:i?void 0:u})]}),m.target)}function er(e){const t=s.useId(),{page:n,pageSize:o,rowCount:r,onPageChange:i,onPageSizeChange:l,pageSizeOptions:a=[10,25,50,100],showFirstButton:c=!0,showLastButton:u=!0,localeText:g}=e,m=Hn(o),x=Oo(r,m),y=Ai(n,x),p=a.includes(m)?a:[...a,m].sort((k,I)=>k-I),f=y*m,h=Math.min(f+m,r),b=r===0?0:`${f+1}–${h}`,w=g?.paginationRowsPerPage??"Rows per page:",C=g?.paginationOf?g.paginationOf(r===0?0:f+1,h,r):`${b} of ${r}`,E=g?.paginationPage?g.paginationPage(y+1,x):`Page ${y+1} of ${x}`,S=()=>{i(0)},N=()=>{i(Math.max(0,y-1))},M=()=>{i(Math.min(x-1,y+1))},_=()=>{i(x-1)},F=k=>{const I=parseInt(k.target.value,10);l(I)},P=y===0,L=y>=x-1;return d.jsxs("div",{className:"ogx-pagination",role:"navigation","aria-label":"Pagination",children:[d.jsxs("div",{className:"ogx-pagination__page-size",children:[d.jsx("label",{htmlFor:t,className:"ogx-pagination__label",children:w}),d.jsx("select",{id:t,className:"ogx-pagination__select",value:m,onChange:F,children:p.map(k=>d.jsx("option",{value:k,children:k},k))})]}),d.jsx("div",{className:"ogx-pagination__info","aria-live":"polite","aria-atomic":"true",children:C}),d.jsxs("div",{className:"ogx-pagination__actions",children:[c&&d.jsx(Qe,{variant:"text",size:"small",onClick:S,disabled:P,"aria-label":"Go to first page",title:"First page",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(Qe,{variant:"text",size:"small",onClick:N,disabled:P,"aria-label":"Go to previous page",title:"Previous page",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:E}),d.jsx(Qe,{variant:"text",size:"small",onClick:M,disabled:L,"aria-label":"Go to next page",title:"Next page",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"})})}),u&&d.jsx(Qe,{variant:"text",size:"small",onClick:_,disabled:L,"aria-label":"Go to last page",title:"Last page",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 yf({row:e,rowId:t,rowIndex:n,ariaRowIndex:o,listViewColumn:r,gridColumn:i,rowMeta:l,isSelected:a=!1,checkboxSelection:c=!1,rowHeight:u,onRowClick:g,onRowDoubleClick:m,onSelectionChange:x,tabIndex:y=-1,onFocus:p,onToggleExpansion:f}){const h=t??e.id,b=r.field,w=Me(e,b,i),C=uo(e,b,w,i)??fo(w,i),E=l?.isGroupRow===!0||Re(h),S={row:e,value:w,formattedValue:C,field:b,colDef:i??r,rowIndex:n,colIndex:0,rowMeta:l},N=M=>{M.stopPropagation(),x?.(h,M.target.checked)};return d.jsxs("div",{className:`ogx-list-view__row${a?" ogx-list-view__row--selected":""}`,style:u?{minHeight:u}:void 0,onClick:()=>g?.(e),onDoubleClick:m?()=>m(e):void 0,role:"row","aria-rowindex":o??n+1,"aria-selected":a,"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:p?M=>{M.target===M.currentTarget&&p(n)}:void 0,children:[c&&d.jsx("div",{className:"ogx-list-view__checkbox",onClick:M=>M.stopPropagation(),children:!E&&d.jsx(gt,{checked:a,onChange:N,"aria-label":`Select row ${h}`,tabIndex:-1})}),l&&f&&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(Ho,{isExpanded:l.isExpanded===!0,onClick:()=>f(h),tabIndex:-1})}),d.jsx("div",{className:"ogx-list-view__cell",role:"gridcell",children:d.jsx(Et,{field:b,resetKey:e,renderFn:()=>{const M=r.renderCell(S);return M===void 0&&E?l?.groupLabel:M}})})]})}function Cf(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=dl(i.currentTarget);if(!l){n.current=!0;return}if(!n.current)return;const a=o.current;a&&(n.current=!1,a(l))},[]);return e?r:void 0}const vf=e=>e.id;function Sf({ariaLabel:e,allRenderableRows:t,dataRowCount:n,pinnedTopRowCount:o,pinnedBottomRowCount:r,unpinnedRowCount:i,pagination:l,effectivePaginationModel:a,currentPage:c,pageSizeOptions:u,selectedRowIds:g,listViewColumn:m,columnsByField:x,rowMetaMap:y,noRowsLabel:p,rowHeight:f,checkboxSelection:h,paginationMode:b,serverRowCount:w,paginationSlot:C,paginationSlotProps:E,localeText:S,onRowClick:N,onRowDoubleClick:M,onSelectionChange:_,onPaginationModelChange:F,onRowsScrollEnd:P,getRowId:L=vf,multiselectable:k=!1,loading:I=!1,loadingOverlay:A,noRowsOverlay:v,showPaginationControls:W=!0,selectable:V=!1,onToggleExpansion:Z}){const H=C||er,z=s.useRef(null),[B,re]=s.useState(null),oe=B===null?-1:t.findIndex(D=>L(D)===B),ue=oe===-1?0:oe,se=D=>{const T=t[D];T&&(re(L(T)),z.current?.querySelector(`:scope > [role="row"][data-rowindex="${D}"]`)?.focus())},ce=D=>{const T=D.target;if(T.getAttribute("role")!=="row"||T.parentElement!==z.current)return;const $=Number(T.getAttribute("data-rowindex")),O=t[$];if(!O)return;const J=L(O),G=t.length-1,Y=y.get(J),U=!!(Y?.hasChildren&&Z);if(D.altKey&&(D.key==="ArrowRight"||D.key==="ArrowLeft")){D.preventDefault();const X=En(D.key,Xe(D.currentTarget))==="ArrowRight";U&&X!==(Y?.isExpanded===!0)&&Z?.(J);return}switch(D.key){case"ArrowDown":D.preventDefault(),se(Math.min($+1,G));return;case"ArrowUp":D.preventDefault(),se(Math.max($-1,0));return;case"Home":D.preventDefault(),se(0);return;case"End":D.preventDefault(),se(G);return;case"PageDown":D.preventDefault(),se(Math.min($+10,G));return;case"PageUp":D.preventDefault(),se(Math.max($-10,0));return;case"Enter":case" ":if(D.preventDefault(),D.key===" "&&D.shiftKey){V&&!Y?.isGroupRow&&_(J,!g.has(J));return}U?Z?.(J):N({row:O,id:J,rowIndex:$});return}},R=b==="server",de=R?w||0:i,j=R?w||0:n,te=Hn(a.pageSize),q=Oo(de,te),Q=l?c*te:0,ae=t.length-o-r,fe=D=>{if(D<o)return D+1;const T=D-o;return T<ae?o+Q+T+1:o+de+(T-ae)+1},ee=Cf(P,t.length);return d.jsxs("div",{className:"ogx-list-view",role:"grid","aria-label":e||"Data grid list view","aria-rowcount":j,"aria-multiselectable":k,children:[d.jsx("div",{className:"ogx-list-view__toolbar",children:d.jsxs("span",{children:[j," ",j===1?"item":"items",l?` · page ${c+1} of ${q}`:"",g.size>0?` · ${g.size} selected`:""]})}),d.jsx("div",{className:"ogx-list-view__rows",tabIndex:-1,onScroll:ee,onKeyDown:ce,ref:z,children:t.length===0&&I?d.jsx("div",{className:"ogx-list-view__loading",children:A??d.jsx("div",{className:"ogx__loading-bar",role:"progressbar","aria-label":"Loading data"})}):t.length===0&&v?d.jsx("div",{className:"ogx-list-view__empty",children:v}):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"})]}),p]}):t.map((D,T)=>{const $=L(D);return d.jsx(yf,{row:D,rowId:$,rowIndex:T,ariaRowIndex:fe(T),listViewColumn:m,gridColumn:x.get(m.field),rowMeta:y.get($),isSelected:g.has($),checkboxSelection:h,rowHeight:f,onRowClick:O=>N({row:O,id:$,rowIndex:T}),onRowDoubleClick:M?O=>M({row:O,id:$,rowIndex:T}):void 0,onSelectionChange:_,tabIndex:T===ue?0:-1,onToggleExpansion:Z,onFocus:O=>re(L(t[O]))},$)})}),l&&W&&d.jsx(H,{page:c,pageSize:a.pageSize,rowCount:de,pageSizeOptions:u,onPageChange:D=>F({...a,page:D}),onPageSizeChange:D=>F({...a,pageSize:D,page:0}),localeText:S,...E})]})}const _f=16;function kf(e){e.preventDefault(),e.stopPropagation()}function Ef(){const e=t=>{t.stopPropagation(),t.preventDefault()};window.addEventListener("click",e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener("click",e,{capture:!0}),0)}function Mf(e){const{field:t,currentWidth:n,onResize:o,onAutosize:r,minWidth:i,maxWidth:l,edge:a="end"}=e,[c,u]=s.useState(!1),g=s.useRef(null);s.useEffect(()=>()=>{g.current=null},[]);const m=s.useCallback((w,C)=>{const E=(C-w.startX)*(w.rtl?-1:1),S=w.startWidth+(a==="start"?-E:E);return Jo(S,w.startWidth,i,l)},[a,i,l]),x=s.useCallback(w=>{if(w.button===0){w.stopPropagation(),g.current={pointerId:w.pointerId,startX:w.clientX,startWidth:n,rtl:Xe(w.currentTarget),lastUpdate:0,moved:!1},u(!0);try{w.currentTarget.setPointerCapture(w.pointerId)}catch{}}},[n]),y=s.useCallback(w=>{const C=g.current;if(!C||w.pointerId!==C.pointerId||(w.clientX!==C.startX&&(C.moved=!0),!C.moved))return;const E=Date.now();E-C.lastUpdate>=_f&&(C.lastUpdate=E,o(t,m(C,w.clientX)))},[t,o,m]),p=s.useCallback((w,C)=>{const E=g.current;if(!(!E||w.pointerId!==E.pointerId)){if(g.current=null,u(!1),w.currentTarget.hasPointerCapture?.(w.pointerId))try{w.currentTarget.releasePointerCapture(w.pointerId)}catch{}(E.moved||w.clientX!==E.startX)&&(Ef(),C&&o(t,m(E,w.clientX)))}},[t,o,m]),f=s.useCallback(w=>{if(w.key==="Enter"&&r){w.preventDefault(),w.stopPropagation(),r(t);return}if(w.key!=="ArrowLeft"&&w.key!=="ArrowRight")return;w.preventDefault(),w.stopPropagation();const C=En(w.key,Xe(w.currentTarget)),E=(w.shiftKey?50:10)*(C==="ArrowRight"?1:-1);o(t,Jo(n+E,n,i,l))},[t,n,o,r,i,l]),h=s.useCallback(w=>{w.preventDefault(),w.stopPropagation(),r?.(t)},[t,r]),b=["ogx-column-resize-handle",a==="start"&&"ogx-column-resize-handle--start",c&&"ogx-column-resize-handle--dragging"].filter(Boolean).join(" ");return d.jsx("div",{className:b,onPointerDown:x,onMouseDown:kf,onPointerMove:y,onPointerUp:w=>p(w,!0),onPointerCancel:w=>p(w,!1),onClick:w=>w.stopPropagation(),onDragStart:w=>{w.preventDefault(),w.stopPropagation()},onDoubleClick:h,onKeyDown:f,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${t} column`,"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 Kt(){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 Ut(){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 Nf(){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 If(){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 Lf(){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 Pf(){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 Af(){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 Tf(){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 Ff(){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 Of(){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 Ol=e=>e?Array.from(e.querySelectorAll('[role="menuitem"], [role="menuitemradio"]')):[];function Df({colDef:e,sortModel:t,onSort:n,onHide:o,onPin:r,pinnedColumns:i,onManageColumns:l,onClose:a,anchorEl:c}){const u=s.useRef(null),g=s.useCallback(v=>{v&&(c?.closest('[role="columnheader"]')??c)?.focus({preventScroll:!0}),a()},[c,a]),m=v=>{const W=Ol(u.current),V=W.indexOf(v.target);let Z=-1;if(v.key==="ArrowDown")Z=V+1>=W.length?0:V+1;else if(v.key==="ArrowUp")Z=V<=0?W.length-1:V-1;else if(v.key==="Home")Z=0;else if(v.key==="End")Z=W.length-1;else if(v.key==="Tab"){v.preventDefault(),g(!0);return}else return;v.preventDefault(),W[Z]?.focus()},[x,y]=s.useState({position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"});s.useLayoutEffect(()=>{if(!c||!u.current)return;const v=c.getBoundingClientRect(),W=u.current.getBoundingClientRect(),V=Nt(),Z=Fl(),H=8;let z=v.left;z+W.width+H>V&&(z=V-W.width-H),z<H&&(z=H);let B=v.bottom+4;B+W.height+H>Z&&(B=v.top-W.height-4),y({position:"fixed",zIndex:1300,top:B,left:z,visibility:"visible"})},[c]);const p=x.visibility==="visible";s.useLayoutEffect(()=>{p&&Ol(u.current)[0]?.focus({preventScroll:!0})},[p]),s.useEffect(()=>{function v(V){u.current&&!u.current.contains(V.target)&&c&&!c.contains(V.target)&&a()}function W(V){V.key==="Escape"&&g(!0)}return document.addEventListener("mousedown",v),document.addEventListener("keydown",W),window.addEventListener("scroll",a,!0),window.addEventListener("resize",a),()=>{document.removeEventListener("mousedown",v),document.removeEventListener("keydown",W),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a)}},[c,a,g]);const f=v=>{n?.(e.field,v),g(!0)},h=!!o&&e.hideable!==!1,b=!!r&&e.pinnable!==!1,w=()=>{h&&o?.(e.field),g(!0)},C=v=>{b&&r?.(e.field,v),g(!0)},E=t?.find(v=>v.field===e.field)?.sort,S=E==null,N=i?.left?.includes(e.field)??!1,M=i?.right?.includes(e.field)??!1,_=!N&&!M,F=Xe(c),P=F?"right":"left",L=F?"left":"right",k=F?M:N,I=F?N:M,A=e.headerName||e.field;return st.createPortal(d.jsxs("div",{ref:u,className:"ogx-column-menu",style:x,role:"menu","aria-label":`Column options for ${A}`,onKeyDown:m,children:[n&&e.sortable!==!1&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:`ogx-menu-item${E==="asc"?" ogx-menu-item--active":""}`,onClick:()=>f("asc"),role:"menuitemradio","aria-checked":E==="asc",children:[d.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:E==="asc"?d.jsx(Kt,{}):d.jsx(Ut,{})}),d.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:d.jsx(If,{})}),"Sort Ascending"]}),d.jsxs("button",{type:"button",className:`ogx-menu-item${E==="desc"?" ogx-menu-item--active":""}`,onClick:()=>f("desc"),role:"menuitemradio","aria-checked":E==="desc",children:[d.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:E==="desc"?d.jsx(Kt,{}):d.jsx(Ut,{})}),d.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:d.jsx(Lf,{})}),"Sort Descending"]}),d.jsxs("button",{type:"button",className:`ogx-menu-item${S?" ogx-menu-item--active":""}`,onClick:()=>f(null),role:"menuitemradio","aria-checked":S,children:[d.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:S?d.jsx(Kt,{}):d.jsx(Ut,{})}),d.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:d.jsx(Pf,{})}),"Unsort"]}),d.jsx("div",{className:"ogx-menu-divider"})]}),b&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"ogx-menu-section-label","aria-hidden":"true",children:"Pin column"}),d.jsxs("button",{type:"button",className:`ogx-menu-item${k?" ogx-menu-item--active":""}`,onClick:()=>C(P),role:"menuitemradio","aria-checked":k,"aria-label":"Pin to left",children:[d.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:k?d.jsx(Kt,{}):d.jsx(Ut,{})}),d.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:d.jsx(Tf,{})}),"Pin to Left"]}),d.jsxs("button",{type:"button",className:`ogx-menu-item${I?" ogx-menu-item--active":""}`,onClick:()=>C(L),role:"menuitemradio","aria-checked":I,"aria-label":"Pin to right",children:[d.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:I?d.jsx(Kt,{}):d.jsx(Ut,{})}),d.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:d.jsx(Ff,{})}),"Pin to Right"]}),d.jsxs("button",{type:"button",className:`ogx-menu-item${_?" ogx-menu-item--active":""}`,onClick:()=>C(null),role:"menuitemradio","aria-checked":_,"aria-label":"Unpin column",children:[d.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:_?d.jsx(Kt,{}):d.jsx(Ut,{})}),d.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:d.jsx(Of,{})}),"Unpin"]}),d.jsx("div",{className:"ogx-menu-divider"})]}),h&&d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:"ogx-menu-item",onClick:w,role:"menuitem","aria-label":`Hide ${A} column`,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(Af,{})}),"Hide Column"]}),d.jsx("div",{className:"ogx-menu-divider"})]}),d.jsxs("button",{type:"button",className:"ogx-menu-item",onClick:()=>{l?.(),g(!1)},role:"menuitem","aria-label":"Manage all columns",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(Nf,{})}),"Manage columns"]})]}),c?.closest(".ogx-theme-provider")||document.body)}const $f=16,Gf=16;function Hf(e,t=!1){const n=Number.isFinite(e)?e-Gf:0,o=Math.floor(n/$f)-(t?1:0);return Math.max(1,o)}function Bf(e,t){return e??t??!1}function Dl(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}const Wf="header:",Vf=40,zf=300,Rf="__group__",$l=[];function tr(e){return`${Wf}${e}`}function nr(e){return"items"in e&&Array.isArray(e.items)}function Kf(e){return e.isSpacer||Je(e.field)||e.field===Rf?!1:e.headerFilter!==!1&&e.filterable!==!1&&e.type!=="image"}function Kn(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 Uf(e){const t=Qr(e.type),n=Kn(e);return t.includes(n)?t:[n,...t]}function Gl(e,t){return e.items.some(n=>nr(n)?Gl(n,t):n.field===t)}function jf(e){return(e?.logicOperator??"and")==="or"&&(e?.items?.length??0)>0}function Hl(e,t){const n=e?.items??$l;if(jf(e))return{kind:"custom"};const o=tr(t);let r;for(const i of n){if(nr(i)){if(Gl(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 qf(e,t,n){const o=e??{items:[]};if(Hl(o,t).kind!=="editable")return o;const r=tr(t),i=o.items??$l,l=i.findIndex(u=>!nr(u)&&u.id===r),a=n?{...n,id:r,field:t}:null;let c;if(l===-1){if(!a)return o;if(i.length===0&&o.logicOperator==="or")return{...o,logicOperator:"and",items:[a]};c=[...i,a]}else a?c=i.map((u,g)=>g===l?a:u):c=i.filter((u,g)=>g!==l);return{...o,items:c}}function or(e,t,n){const o=$t.has(t);return!o&&xo(n)&&t===Kn(e)?null:{id:tr(e.field),field:e.field,operator:t,value:o?void 0:n}}function Bl(e,t){if(!$t.has(t))return t==="isAnyOf"?e==null||e===""?[]:Array.isArray(e)?e:[e]:Array.isArray(e)?e.length>0?e[0]:"":e??""}const Xf={contains:"∋",equals:"=",startsWith:"a…",endsWith:"…a",isEmpty:"∅",isNotEmpty:"!∅",isAnyOf:"∈","=":"=","!=":"≠",">":">",">=":"≥","<":"<","<=":"≤",is:"=",not:"≠",after:">",onOrAfter:"≥",before:"<",onOrBefore:"≤"},Yf={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"};function Jf(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]??Yf[n]??n}}const Zf={position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"},Wl=e=>e?Array.from(e.querySelectorAll('[role="menuitemradio"]')):[];function Qf({anchorEl:e,columnLabel:t,operators:n,current:o,onSelect:r,onClose:i,locale:l}){const a=s.useRef(null),[c,u]=s.useState(Zf);s.useLayoutEffect(()=>{const y=a.current;if(!y)return;const p=e.getBoundingClientRect(),f=y.getBoundingClientRect(),h=8;let b=Math.min(p.left,Nt()-f.width-h);b<h&&(b=h);let w=p.bottom+4;w+f.height+h>Fl()&&(w=p.top-f.height-4),u({position:"fixed",zIndex:1300,top:w,left:b,visibility:"visible"})},[e]);const g=c.visibility==="visible";s.useLayoutEffect(()=>{if(!g)return;const y=Wl(a.current);(y.find(p=>p.getAttribute("aria-checked")==="true")??y[0])?.focus({preventScroll:!0})},[g]);const m=s.useRef(i);s.useLayoutEffect(()=>{m.current=i}),s.useEffect(()=>{const y=e.ownerDocument,p=y.defaultView;function f(w){const C=w.target;a.current?.contains(C)||e.contains(C)||m.current(!1)}function h(w){a.current?.contains(w.target)||m.current(!1)}function b(){m.current(!1)}return y.addEventListener("mousedown",f),p?.addEventListener("scroll",h,!0),p?.addEventListener("resize",b),()=>{y.removeEventListener("mousedown",f),p?.removeEventListener("scroll",h,!0),p?.removeEventListener("resize",b)}},[e]);const x=y=>{y.stopPropagation();const p=Wl(a.current),f=p.indexOf(y.target);let h=-1;switch(y.key){case"ArrowDown":h=f+1>=p.length?0:f+1;break;case"ArrowUp":h=f<=0?p.length-1:f-1;break;case"Home":h=0;break;case"End":h=p.length-1;break;case"Escape":case"Tab":y.preventDefault(),i(!0);return;default:return}y.preventDefault(),p[h]?.focus()};return st.createPortal(d.jsx("div",{ref:a,className:"ogx-column-menu ogx__header-filter-menu",style:c,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 eg(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 tg(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 Vl(e,t){return t==="isAnyOf"?e.split(",").map(n=>n.trim()).filter(n=>n!==""):e}function zl(e,t){return Object.is(e,t)?!0:Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((n,o)=>zl(n,t[o])):!1}function Rl(e,t){return e===t?!0:!e||!t?!1:e.operator===t.operator&&zl(e.value,t.value)}function ng(){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 og({colDef:e,state:t,style:n,className:o,ariaColIndex:r,onItemChange:i,onOpenFilterPanel:l,locale:a}){const c=e.headerName||e.field,u=t.kind==="editable"?t.item:void 0,g=u?.operator??Kn(e),m=eg(e),x=e.type==="boolean"||e.type==="singleSelect"&&m.length>0,y=!$t.has(g),[p,f]=s.useState(null),[h,b]=s.useState(null),[w,C]=s.useState(void 0),[E,S]=s.useState(u);if(E!==u){S(u);const R=w!==void 0&&Rl(w??void 0,u);!Rl(E,u)&&!R&&f(null)}const N=s.useRef(null),M=s.useRef(null),_=s.useRef(null),F=s.useRef(null),P=s.useRef(null),L=s.useRef({item:u,colDef:e,onItemChange:i});s.useLayoutEffect(()=>{L.current={item:u,colDef:e,onItemChange:i}});const k=s.useCallback(R=>{const{item:de,colDef:j,onItemChange:te}=L.current;if(de?R===_o(de.value,j.type):R.trim()==="")return;const Q=de?.operator??Kn(j),ae=or(j,Q,Vl(R,Q));C(ae),te(j.field,ae)},[]),I=s.useRef(null);s.useLayoutEffect(()=>{I.current=p}),s.useEffect(()=>()=>{const R=I.current;I.current=null,R!==null&&k(R)},[k]),s.useEffect(()=>{if(p===null)return;const R=setTimeout(()=>{I.current=null,k(p),f(null)},zf);return()=>clearTimeout(R)},[p,k]);const A=()=>N.current?.focus({preventScroll:!0}),v=()=>(M.current??_.current)?.focus({preventScroll:!0}),W=R=>{C(R),i(e.field,R)},V=R=>{f(null),W(or(e,g,R))},Z=()=>{f(null),W(null)},H=()=>{P.current&&b(P.current)},z=R=>{b(null),R&&(M.current||_.current?v():A())},B=R=>{const de=p!==null?Vl(p,R):u?.value;f(null),b(null),W(or(e,R,Bl(de,R))),requestAnimationFrame(()=>{M.current||_.current?v():A()})},re=t.kind==="custom",oe=!re&&y&&!x,ue=R=>{const de=R.currentTarget,j=R.target;if(!de.contains(j)||R.nativeEvent.isComposing)return;const{key:te}=R,q=j===de;if((R.altKey&&te==="ArrowDown"||(R.ctrlKey||R.metaKey)&&te==="Enter")&&!re&&j!==_.current){R.preventDefault(),R.stopPropagation(),H();return}if(!q){te==="Escape"&&(R.preventDefault(),R.stopPropagation(),A());return}if(te==="Enter"||te===" "||te==="Spacebar"){R.preventDefault(),R.stopPropagation(),re?F.current?.click():M.current||_.current?v():H();return}if((te==="Delete"||te==="Backspace")&&u){R.preventDefault(),R.stopPropagation(),Z();return}oe&&e.type!=="date"&&te.length===1&&!R.ctrlKey&&!R.metaKey&&!R.altKey&&(R.preventDefault(),R.stopPropagation(),M.current?.focus({preventScroll:!0}),f(te))};let se=null;if(re)se=l?d.jsx("button",{ref:F,type:"button",className:"ogx__header-filter-custom",tabIndex:-1,onClick:l,title:a.customTooltip,children:a.custom}):d.jsx("span",{className:"ogx__header-filter-custom",title:a.customTooltip,children:a.custom});else{let R;if(!y)R=d.jsx("span",{className:"ogx__header-filter-operator-label",children:a.operator(g)});else if(e.type==="boolean")R=d.jsxs("select",{ref:_,className:"ogx__header-filter-select",tabIndex:-1,value:u?.value==null||u.value===""?"":String(u.value),onChange:j=>V(j.target.value===""?"":j.target.value==="true"),"aria-label":a.valueLabel(c),children:[d.jsx("option",{value:"",children:a.any}),d.jsx("option",{value:"true",children:a.yes}),d.jsx("option",{value:"false",children:a.no})]});else if(x){const j=m.find(te=>tg(te,u?.value));R=d.jsxs("select",{ref:_,className:"ogx__header-filter-select",tabIndex:-1,value:j?.key??"",onChange:te=>{const q=m.find(Q=>Q.key===te.target.value);V(Bl(q?q.value:"",g))},"aria-label":a.valueLabel(c),children:[d.jsx("option",{value:"",children:a.any}),m.map(te=>d.jsx("option",{value:te.key,children:te.label},te.key))]})}else R=d.jsx(et,{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:p??_o(u?.value,e.type),onChange:j=>f(j.target.value),"aria-label":a.valueLabel(c)});const de=a.operator(g);se=d.jsxs(d.Fragment,{children:[d.jsx("button",{ref:P,type:"button",className:`ogx__header-filter-operator${h?" ogx__header-filter-operator--open":""}`,tabIndex:-1,"aria-haspopup":"menu","aria-expanded":h!==null,"aria-label":a.operatorButtonLabel(c,de),title:de,onClick:()=>h?b(null):H(),children:Xf[g]??"?"}),R,u&&d.jsx("button",{type:"button",className:"ogx__header-filter-clear",tabIndex:-1,"aria-label":a.clearLabel(c),title:a.clearTooltip,onClick:()=>{Z(),A()},children:d.jsx(ng,{})}),h&&d.jsx(Qf,{anchorEl:h,columnLabel:c,locale:a,operators:Uf(e),current:g,onSelect:B,onClose:z})]})}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:N,className:ce,style:n,role:"columnheader","aria-label":a.cellLabel(c),"aria-colindex":r,"data-field":e.field,tabIndex:-1,onKeyDown:ue,children:se})}function rr({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:He,minWidth:He,maxWidth:He,position:n?"sticky":void 0,insetInlineStart:n?o:void 0},role:"columnheader","aria-colindex":t,"data-field":e,tabIndex:-1})}function rg(e){const{columns:t,columnWidths:n,pinnedColumns:o,pinnedPositions:r,pinnedEdges:i,rowReordering:l,hasDetailPanel:a,checkboxSelection:c,pinExpandColumn:u,pinCheckboxColumn:g,columnIndexMap:m,ariaRowIndex:x,filterModel:y,onFilterModelChange:p,onOpenFilterPanel:f,focusedField:h,localeText:b}=e,w=s.useRef({filterModel:y,onFilterModelChange:p});s.useLayoutEffect(()=>{w.current={filterModel:y,onFilterModelChange:p}});const C=s.useCallback((L,k)=>{const{filterModel:I,onFilterModelChange:A}=w.current;if(!A)return;const v=qf(I,L,k);v!==I&&(w.current={filterModel:v,onFilterModelChange:A},A(v))},[]),E=Jf(b),S=l?1:0,N=a?S+1:S,M=c?N+1:N,_=M,F=l?He:0,P=F+(a&&u?He:0);return d.jsxs("div",{className:"ogx__header-filter-row",role:"row","aria-rowindex":x,children:[l&&d.jsx(rr,{field:St,ariaColIndex:S,sticky:!0,left:0,focused:h===St}),a&&d.jsx(rr,{field:_t,ariaColIndex:N,sticky:u,left:F,focused:h===_t}),c&&d.jsx(rr,{field:Ye,ariaColIndex:M,sticky:g,left:P,focused:h===Ye}),t.map((L,k)=>{if(L.isSpacer)return d.jsx("div",{style:{width:L.width,minWidth:L.width,flexShrink:0},"aria-hidden":"true"},L.field);const I=tt(L.field,o),A=Dl(L,n,I,I?r[L.field]:void 0),v=_+(m?.get(L.field)??k)+1,W=[I&&"ogx__header-filter-cell--pinned",I&&`ogx__header-filter-cell--pinned-${I}`,I==="left"&&L.field===i.lastLeft&&"ogx__header-filter-cell--pinned-left-last",I==="right"&&L.field===i.firstRight&&"ogx__header-filter-cell--pinned-right-first",h===L.field&&"ogx__header-filter-cell--focused"].filter(Boolean).join(" ");return Kf(L)?d.jsx(og,{colDef:L,state:Hl(y,L.field),style:A,className:W,ariaColIndex:v,onItemChange:C,onOpenFilterPanel:f,locale:E},L.field):d.jsx("div",{className:`ogx__header-filter-cell ogx__header-filter-cell--empty ${W}`,style:A,role:"columnheader","aria-label":`No filter for ${L.headerName||L.field}`,"aria-colindex":v,"data-field":L.field,tabIndex:-1},L.field)})]})}function ig(){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 lg(){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 Kl(e){const{columns:t,allColumns:n,columnGroupingModel:o,checkboxSelection:r=!1,allSelected:i=!1,someSelected:l=!1,onSelectAll:a,onSort:c,sortModel:u=[],onColumnResize:g,onColumnAutosize:m,columnWidths:x={},pinnedColumns:y,hasDetailPanel:p=!1,pinCheckboxColumn:f=!0,pinExpandColumn:h=!0,rowReordering:b=!1,aggregationModel:w,draggedColumn:C,dragOverColumn:E,onDragStart:S,onDragOver:N,onDragEnd:M,onDrop:_,focusedCell:F,onHeaderClick:P,onSortAdd:L,multiSort:k=!1,onHideColumn:I,onPinColumn:A,onManageColumns:v,columnIndexMap:W,wrapHeaderText:V=!1,headerHeight:Z=56,headerFilters:H=!1,filterModel:z,onFilterModelChange:B,onOpenFilterPanel:re,localeText:oe}=e,ue=s.useId(),[se,ce]=s.useState(null),R=K=>ge=>{ge.stopPropagation(),ce({colDef:K,anchorEl:ge.currentTarget})},de=s.useCallback(()=>{ce(null)},[]),j=K=>ge=>{if(ge.altKey&&(ge.key==="ArrowLeft"||ge.key==="ArrowRight")&&ge.target===ge.currentTarget){if(K.resizable===!1||!g)return;ge.preventDefault(),ge.stopPropagation();const Ce=Ct(K,x),le=En(ge.key,Xe(ge.currentTarget)),ye=(ge.shiftKey?50:10)*(le==="ArrowRight"?1:-1);g(K.field,Jo(Ce+ye,Ce,K.minWidth,K.maxWidth));return}if(!(ge.altKey&&ge.key==="ArrowDown"||(ge.ctrlKey||ge.metaKey)&&ge.key==="Enter")||K.disableColumnMenu||ge.target!==ge.currentTarget)return;ge.preventDefault(),ge.stopPropagation();const xe=ge.currentTarget.querySelector(".ogx__menu-icon-btn")??ge.currentTarget;ce({colDef:K,anchorEl:xe})},te=K=>F?.id===null&&!F.headerFilter&&F.field===K,q=b?1:0,Q=p?q+1:q,ae=r?Q+1:Q,fe=K=>ge=>{if(K.sortable===!1)return;const we=u.find(xe=>xe.field===K.field);let ie="asc";we&&(we.sort==="asc"?ie="desc":ie=null),(ge.shiftKey||k)&&L?L(K.field,ie):c&&c(K.field,ie)},ee=(K,ge)=>{const we=u.some(xe=>xe.field===K);L&&(ge===null||we||k||!c)?L(K,ge):c?.(K,ge)},D=K=>{const ge=u.find(ie=>ie.field===K);if(!ge)return null;const we=u.length>1?u.indexOf(ge)+1:null;return d.jsx("span",{className:`ogx__sort-icon ogx__sort-icon--${ge.sort}`,"aria-hidden":"true",children:we!==null&&d.jsx("span",{className:"ogx__sort-badge",children:we})})},T=s.useMemo(()=>so(t,x,y,r,f,p,h,b),[t,x,y,r,f,p,h,b]),$=s.useMemo(()=>ao(t,y),[t,y]),O=Qi(o),J=s.useMemo(()=>el(o),[o]),G=s.useMemo(()=>O===0?[]:(n??t).map(K=>({field:K.field,width:Ct(K,x),flex:K.isSpacer?0:K.flex,pinned:K.isSpacer?null:tt(K.field,y),isSpacer:K.isSpacer})),[O,n,t,x,y]),ne=(b?48:0)+(p?48:0)+(r?48:0),he=(b||p||r)&&(!p||h)&&(!r||f),me=(b?1:0)+(p?1:0)+(r?1:0);return d.jsxs("div",{className:"ogx__header-wrap",children:[O>0&&Array.from({length:O},(K,ge)=>{const we=xd(G,J,ge);return d.jsxs("div",{className:"ogx-col-group-row",role:"row","aria-rowindex":ge+1,children:[ne>0&&d.jsx("div",{className:`ogx-col-group-cell ogx-col-group-cell--filler${he?" ogx-col-group-cell--pinned ogx-col-group-cell--pinned-left":""}`,style:{width:ne,minWidth:ne,flexShrink:0,position:he?"sticky":void 0,insetInlineStart:he?0:void 0},"aria-hidden":"true"}),we.map((ie,xe)=>{const Ce=ie.pinned?` ogx-col-group-cell--pinned ogx-col-group-cell--pinned-${ie.pinned}`:"",le={width:ie.width,minWidth:ie.width,flexShrink:0,flexGrow:ie.flexGrow};return ie.pinned==="left"?(le.position="sticky",le.insetInlineStart=T[ie.fields[0]]):ie.pinned==="right"&&(le.position="sticky",le.insetInlineEnd=T[ie.fields[ie.fields.length-1]],we[xe-1]?.pinned!=="right"&&(le.marginInlineStart="auto")),ie.isGroup?d.jsx("div",{role:"columnheader","aria-colspan":ie.fields.length,"aria-colindex":me+ie.firstDataIndex+1,className:`ogx-col-group-cell ogx-col-group-cell--group${Ce}${ie.headerClassName?` ${ie.headerClassName}`:""}`,style:le,title:ie.label,children:d.jsx("span",{className:"ogx-col-group-cell__label",children:ie.label})},ie.key):d.jsx("div",{className:`ogx-col-group-cell ogx-col-group-cell--filler${Ce}`,style:le,"aria-hidden":"true"},ie.key)})]},`ogx-grp-${ge}`)}),d.jsxs("div",{className:"ogx__header",role:"row","aria-rowindex":O+1,children:[b&&d.jsx("div",{className:`ogx__header-cell ogx__header-cell--pinned ogx__header-cell--pinned-left ${te("__reorder_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-label":"Row reorder handle","aria-colindex":q,"data-field":"__reorder_col__",tabIndex:-1,title:"Drag to reorder rows",style:{minWidth:48,maxWidth:48,position:"sticky",insetInlineStart:0}}),p&&d.jsx("div",{className:`ogx__header-cell ogx__header-cell--expand ${h?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""} ${te("__expand_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-label":"Expand row details","aria-colindex":Q,"data-field":"__expand_col__",tabIndex:-1,style:{minWidth:48,maxWidth:48,position:h?"sticky":void 0,insetInlineStart:h?b?48:0:void 0}}),r&&d.jsx("div",{className:`ogx__header-cell ogx__header-cell--checkbox ${f?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""} ${te("__checkbox_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-colindex":ae,"data-field":"__checkbox_col__",style:{position:f?"sticky":void 0,insetInlineStart:f?(b?48:0)+(p&&h?48:0):void 0},children:a&&d.jsx(gt,{id:ue,name:ue,checked:i,indeterminate:l,onChange:K=>a(K.target.checked),"aria-label":i?"Deselect all rows":"Select all rows",tabIndex:-1,onMouseDown:K=>K.preventDefault()})}),t.map((K,ge)=>{if(K.isSpacer)return d.jsx("div",{style:{width:K.width,minWidth:K.width,flexShrink:0},"aria-hidden":"true"},K.field);const we=K.sortable!==!1,ie=u.findIndex(Be=>Be.field===K.field),xe=ie!==-1,Ce=xe?u[ie].sort:null,le=W?.get(K.field)??ge,ye=we?ie===0?Ce==="asc"?"ascending":"descending":"none":void 0,ke=xe&&u.length>1?`Sorted ${Ce==="asc"?"ascending":"descending"}, sort priority ${ie+1} of ${u.length}`:void 0,De=K.resizable!==!1,Ne=tt(K.field,y),Ie=Ne!==null,Ee=C===K.field,Ae=E===K.field,pe=Bf(K.wrapHeaderText,V),ve=w?.[K.field],Se=["ogx__header-cell",`ogx__header-cell--align-${K.headerAlign||K.align||"left"}`,we&&"ogx__header-cell--sortable",xe&&"ogx__header-cell--sorted",Ie&&"ogx__header-cell--pinned",Ie&&`ogx__header-cell--pinned-${Ne}`,Ne==="left"&&K.field===$.lastLeft&&"ogx__header-cell--pinned-left-last",Ne==="right"&&K.field===$.firstRight&&"ogx__header-cell--pinned-right-first",Ee&&"ogx__header-cell--dragging",Ae&&"ogx__header-cell--drag-over",pe&&"ogx__header-cell--wrap",te(K.field)&&"ogx__header-cell--focused",K.headerClassName].filter(Boolean).join(" "),be={...Dl(K,x,Ne,Ne?T[K.field]:void 0),zIndex:K.zIndex,opacity:Ee?.5:1},Le=K.renderHeader?K.renderHeader({field:K.field,colDef:K,colIndex:le}):K.headerName||K.field,Ue=Be=>{if(Be.target.closest(".ogx-column-resize-handle")){Be.stopPropagation();return}P?.(K.field),we&&fe(K)(Be)},je=S&&!Ie?S(K.field):void 0,It=N&&!Ie?N(K.field):void 0,ht=_&&!Ie?_(K.field):void 0;return d.jsxs("div",{className:Se,style:be,title:K.description??(pe&&typeof Le=="string"?Le:void 0),onClick:Ue,role:"columnheader",draggable:!!je,onDragStart:je,onDragOver:It,onDragEnd:M,onDrop:ht,onKeyDown:j(K),"aria-sort":ye,"aria-description":ke,"aria-colindex":me+le+1,"data-field":K.field,tabIndex:-1,children:[d.jsxs("div",{className:"ogx__header-cell-content",children:[Ee&&d.jsx("div",{className:"ogx__header-drag-icon",children:d.jsx(lg,{})}),d.jsxs("div",{className:"ogx__header-cell-title-wrapper",children:[d.jsx("span",{className:"ogx__header-cell-title",style:pe?{WebkitLineClamp:Hf(Z,!!ve)}:void 0,children:Le}),ve&&d.jsx("span",{className:"ogx__header-cell-aggregation",children:ve})]}),we&&D(K.field),!K.disableColumnMenu&&d.jsx("button",{type:"button",className:"ogx__menu-icon-btn",onClick:R(K),"aria-label":`Open column menu for ${K.headerName||K.field}`,"aria-haspopup":"menu",tabIndex:-1,children:d.jsx(ig,{})})]}),De&&g&&d.jsx(Mf,{field:K.field,currentWidth:Ct(K,x),onResize:g,onAutosize:m,minWidth:K.minWidth,maxWidth:K.maxWidth,edge:Ne==="right"?"start":"end"})]},K.field)}),se&&d.jsx(Df,{colDef:se.colDef,sortModel:u,onSort:c||L?ee:void 0,onHide:I,onPin:A,pinnedColumns:y,onManageColumns:v,onClose:de,anchorEl:se.anchorEl})]}),H&&d.jsx(rg,{columns:t,columnWidths:x,pinnedColumns:y,pinnedPositions:T,pinnedEdges:$,rowReordering:b,hasDetailPanel:p,checkboxSelection:r,pinExpandColumn:h,pinCheckboxColumn:f,columnIndexMap:W,ariaRowIndex:O+2,filterModel:z,onFilterModelChange:B,onOpenFilterPanel:re,localeText:oe,focusedField:F?.id===null&&F.headerFilter?F.field:null})]})}function un(e){return e.headerName||e.field}function sg(e){return e.nativeEvent.isComposing||e.keyCode===229}function fn(e,t,n=!0){return o=>{if(sg(o)){o.stopPropagation();return}n&&o.key==="Enter"&&(o.stopPropagation(),e()),o.key==="Escape"&&(o.stopPropagation(),t())}}function ag({value:e,colDef:t,onValueChange:n,onCommit:o,onCancel:r}){const[i,l]=s.useState(String(e??"")),a=s.useRef(null);return s.useEffect(()=>{a.current?.focus(),a.current?.select()},[]),d.jsx(et,{ref:a,variant:"cell",type:"text",inputClassName:"ogx__edit-input","aria-label":un(t),value:i,onChange:c=>{l(c.target.value),n(c.target.value)},onBlur:o,onKeyDown:fn(o,r)})}function cg({value:e,colDef:t,onValueChange:n,onCommit:o,onCancel:r}){const[i,l]=s.useState(typeof e=="number"?e:""),a=s.useRef(null);return s.useEffect(()=>{a.current?.focus(),a.current?.select()},[]),d.jsx(et,{ref:a,variant:"cell",type:"number",inputClassName:"ogx__edit-input ogx__edit-input--number","aria-label":un(t),value:i,onChange:c=>{const u=c.target.value===""?"":Number(c.target.value);l(u),n(u===""?null:u)},onBlur:o,onKeyDown:fn(o,r)})}function dg({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:a=>a.preventDefault(),children:d.jsx(gt,{ref:i,inputClassName:"ogx__edit-checkbox","aria-label":un(t),checked:!!e,onChange:l,onMouseDown:a=>a.preventDefault(),onBlur:o,onKeyDown:fn(o,r,!1)})})}const ir=e=>typeof e=="object"?e.value:e,ug=e=>typeof e=="object"?e.label:String(e);function fg(e,t){return e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Object.is(e,t)}function gg({value:e,colDef:t,onValueChange:n,onCommit:o,onCancel:r}){const i=s.useRef(null);s.useEffect(()=>{i.current?.focus()},[]);const l=t.valueOptions??[],a=l.map(g=>String(ir(g)));let c=l.findIndex(g=>fg(ir(g),e));c===-1&&e!==null&&e!==void 0&&(c=a.indexOf(String(e)));const u=c===-1;return d.jsxs("select",{ref:i,className:"ogx__edit-select","aria-label":un(t),value:u?"":a[c],onChange:g=>{const m=a.indexOf(g.target.value);n(m===-1?null:ir(l[m]))},onBlur:o,onKeyDown:fn(o,r),children:[u&&d.jsx("option",{value:""}),l.map((g,m)=>d.jsx("option",{value:a[m],children:ug(g)},m))]})}const Ul=e=>String(e).padStart(2,"0"),jl=/^(\d{4}-\d{2}-\d{2})/;function lr(e){if(e instanceof Date)return Number.isNaN(e.getTime())?"":`${e.getFullYear()}-${Ul(e.getMonth()+1)}-${Ul(e.getDate())}`;if(typeof e=="string"){const t=jl.exec(e);return t?t[1]:e===""?"":lr(new Date(e))}return typeof e=="number"?lr(new Date(e)):""}function pg(e,t){if(e==="")return null;const[n,o,r]=e.split("-").map(Number),i=l=>{const a=new Date(l.getTime());return a.setFullYear(n,o-1,r),a};return t instanceof Date&&!Number.isNaN(t.getTime())?i(t):typeof t=="number"&&Number.isFinite(t)?i(new Date(t)).getTime():typeof t=="string"&&jl.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,a]=s.useState(()=>lr(e)),c=s.useRef(null);return s.useEffect(()=>{c.current?.focus()},[]),d.jsx(et,{ref:c,variant:"cell",type:"date",inputClassName:"ogx__edit-input","aria-label":un(t),value:l,onChange:u=>{a(u.target.value),n(pg(u.target.value,i))},onBlur:o,onKeyDown:fn(o,r)})}function mg(e){const{colDef:t}=e;switch(t.type){case"number":return d.jsx("div",{className:"ogx__edit-cell",children:d.jsx(cg,{...e})});case"boolean":return d.jsx("div",{className:"ogx__edit-cell",children:d.jsx(dg,{...e})});case"singleSelect":return d.jsx("div",{className:"ogx__edit-cell",children:d.jsx(gg,{...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(ag,{...e})})}}function wg(e){const{onCellClick:t,onCellEditStart:n,onCellValueChange:o,value:r,row:i,colDef:l,rowIndex:a,colIndex:c,ariaColIndex:u,isSelected:g,onClick:m,width:x,pinnedPosition:y,pinnedOffset:p,isPinnedEdge:f,isFocused:h,isFocusVisible:b,isEditable:w,isEditing:C,onEditStart:E,onEditStop:S,onValueChange:N,colSpanInfo:M,rowSpan:_,isHiddenByRowSpan:F,rowMeta:P,valueError:L,rangeFlags:k=0}=e,I=s.useCallback(ee=>{o?o(l.field,ee):N?.(ee)},[o,N,l.field]),A=P?.isGroupRow===!0,{formattedValue:v,error:W}=s.useMemo(()=>{const ee=l.valueFormatter;if(ee&&!(A&&r==null)){const D=We(()=>ee({value:r,row:i,field:l.field}));return D.ok?{formattedValue:D.value}:{formattedValue:"",error:D.error??new Error("valueFormatter failed")}}return{formattedValue:fo(r,l)}},[r,i,l,A]),V=s.useMemo(()=>{if(!l.cellClassName)return"";const ee=l.cellClassName;if(typeof ee=="function"){const D=We(()=>ee({value:r,formattedValue:v,row:i,field:l.field,colDef:l,rowIndex:a,colIndex:c,rowMeta:P}));return D.ok&&D.value||""}return l.cellClassName},[l,r,v,i,a,c,P]),Z=L??W,H=l.field,z=s.useCallback(()=>{S?.(!1,H)},[S,H]),B=s.useCallback(()=>{S?.(!0,H)},[S,H]),re=s.useMemo(()=>[i,l.renderCell,r],[i,l.renderCell,r]),oe=s.useRef(!1);if(s.useEffect(()=>{if(!(!C||!S))return oe.current=!0,()=>{oe.current=!1,queueMicrotask(()=>{oe.current||S(!1,H)})}},[C,S,H]),M?.spannedByColSpan)return null;const ue=M?.cellProps.colSpan??1,se=ue>1,ce=(se?M?.cellProps.width:void 0)??x??l.width??100,R={width:"var(--width)","--width":typeof ce=="number"?`${ce}px`:ce,flexGrow:(se?M?.cellProps.flexGrow:void 0)??l.flex??0,flexShrink:0,flexBasis:"auto",boxSizing:"border-box",minWidth:se?void 0:l.minWidth,maxWidth:se?void 0:l.maxWidth};if(F)return d.jsx("div",{className:"ogx__cell ogx__cell--hidden",style:R,role:"presentation","data-field":l.field,"data-colindex":c});const de=ee=>{C||(t&&t({row:i,field:l.field,value:r,colDef:l,rowIndex:a,colIndex:c}),m?.(ee))},j=()=>{C||!w||(n?n(l.field,r):E?.())},te=l.renderEditCell,q=y!=null,Q=["ogx__cell",`ogx__cell--align-${l.align||"left"}`,g&&"ogx__cell--selected",h&&"ogx__cell--focused",h&&b&&"ogx__cell--focus-visible",l.type&&`ogx__cell--type-${l.type}`,q&&"ogx__cell--pinned",q&&`ogx__cell--pinned-${y}`,q&&f&&`ogx__cell--pinned-${y}-${y==="left"?"last":"first"}`,C&&"ogx__cell--editing",_&&_>1&&"ogx__cell--spanned",(k&To)!==0&&"ogx__cell--range",(k&Si)!==0&&"ogx__cell--range-top",(k&_i)!==0&&"ogx__cell--range-bottom",(k&ki)!==0&&"ogx__cell--range-left",(k&Ei)!==0&&"ogx__cell--range-right",V].filter(Boolean).join(" "),ae=_||1,fe={...R,position:q?"sticky":void 0,zIndex:l.zIndex??(q?3:void 0),padding:C?0:void 0};return ae>1&&(fe.height=`calc(var(--height) * ${ae} - var(--border-width, 1px))`,fe.zIndex=10,q&&(fe.zIndex=40)),q&&p!==void 0&&(y==="left"?fe.insetInlineStart=p:fe.insetInlineEnd=p),d.jsxs("div",{className:Q,style:fe,onClick:de,onDoubleClick:j,role:"gridcell","aria-colindex":u??c+1,"aria-readonly":!w||void 0,tabIndex:-1,"data-field":l.field,"data-colindex":c,...ue>1?{"aria-colspan":ue}:{},...ae>1?{"aria-rowspan":ae}:{},...(k&To)!==0?{"aria-selected":!0}:{},children:[d.jsx("div",{className:"ogx__cell-content",children:C&&(o||N)&&S?te?d.jsx(Et,{field:l.field,resetKey:i,renderFn:()=>te({value:r,formattedValue:v,row:i,field:l.field,colDef:l,rowIndex:a,colIndex:c,rowMeta:P,onValueChange:I,onCommit:z,onCancel:B})}):d.jsx(mg,{value:r,formattedValue:v,row:i,field:l.field,colDef:l,rowIndex:a,colIndex:c,rowMeta:P,onValueChange:I,onCommit:z,onCancel:B}):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:v,row:i,field:l.field,colDef:l,rowIndex:a,colIndex:c,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"}):v}),(k&Mi)!==0&&!C&&d.jsx("div",{className:"ogx__cell-fill-handle","aria-hidden":"true"})]})}const ql=s.memo(wg),bg=({className:e="",...t})=>d.jsx("button",{type:"button",className:`ogx-drag-handle ${e}`,"aria-label":"Drag to reorder row",...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 xg(e){const{rowId:t,content:n,height:o,isExpanded:r,onHeightChange:i,id:l,colSpan:a}=e,c=s.useRef(null),u=o==="auto";if(s.useLayoutEffect(()=>{const m=c.current;if(!m||!u||!r||!i)return;const x=()=>{m.getClientRects().length!==0&&i(t,m.offsetHeight)};if(x(),typeof ResizeObserver>"u")return;const y=new ResizeObserver(x);return y.observe(m),()=>y.disconnect()},[u,r,i,t]),!r)return null;const g={height:u?"auto":`${o}px`,overflow:u?"visible":"auto"};return d.jsx("div",{ref:c,className:"ogx__detail-panel",style:g,role:"row",id:l,children:d.jsx("div",{className:"ogx__detail-panel-content",role:"gridcell","aria-colspan":a,children:n})})}const sr=12;function yg(e,t,n,o){let r=0,i=0,l=0;for(let a=t;a<e.length&&l<n;a++){const c=e[a];if(c.isSpacer)break;r+=Ct(c,o),i+=c.flex??0,l++}return{spannedByColSpan:!1,cellProps:{colSpan:l,width:r,flexGrow:i}}}function Cg(e){const{row:t,rowId:n,columns:o,rowIndex:r,isSelected:i=!1,checkboxSelection:l=!1,onRowClick:a,onRowDoubleClick:c,onCellClick:u,onSelectionChange:g,columnWidths:m={},pinnedColumns:x,pinnedRows:y,hasDetailPanel:p=!1,isDetailPanelExpanded:f=!1,onDetailPanelToggle:h,detailPanelContent:b,detailPanelHeight:w=go,onDetailPanelHeightChange:C,pinCheckboxColumn:E=!0,pinExpandColumn:S=!0,rowReordering:N=!1,onDragStart:M,onDragOver:_,onDragEnd:F,onDrop:P,isDragging:L,isDragOver:k,editingCell:I,onEditStart:A,onEditStop:v,onEditCellValueChange:W,isCellEditable:V,focusedCellField:Z,isFocusVisible:H,colspanMap:z,rowSpanningCaches:B,rowHeight:re=52,rowMeta:oe,columnIndexMap:ue,ariaRowIndex:se,cellRange:ce}=e,R=n??t.id,de=s.useId(),j=s.useId(),te=s.useMemo(()=>so(o,m,x,l,E,p,S,N),[o,m,x,l,E,p,S,N]),q=s.useMemo(()=>ao(o,x),[o,x]),Q=oe?.hasChildren===!0,ae=oe?.isGroupRow===!0,fe=p&&!ae,ee=!ae&&!Re(R),D=s.useCallback((le,ye)=>{A?.({id:R,field:le,value:ye})},[R,A]),T=s.useCallback((le,ye)=>{W?.({id:R,field:le,value:ye})},[W,R]),$=s.useCallback((le,ye)=>{v?.({cancel:le,id:R,field:ye})},[v,R]);if(t._isSkeleton){const le=Math.max(o.length,5);return d.jsx("div",{className:"ogx__row ogx__row--skeleton",role:"row","aria-hidden":"true",style:{height:re,minHeight:re},children:Array.from({length:le}).map((ye,ke)=>d.jsx("div",{className:"ogx__skeleton-cell",children:d.jsx("div",{className:"ogx__skeleton-bar"})},ke))})}const O=le=>{le.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell, .ogx__cell--editing")||a?.({row:t,id:R,rowIndex:r})},J=le=>{le.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell, .ogx__cell--editing")||c?.({row:t,id:R,rowIndex:r})},G=le=>{le.stopPropagation(),g?.(R,le.target.checked)},Y=le=>{le.stopPropagation(),h?.(R)},U=N?1:0,X=p?U+1:U,ne=l?X+1:X,he=ne,me=ue?.size??o.filter(le=>!le.isSpacer).length,K=oe!==void 0,ge=oe?.hasChildren===!0,we=Dr(R,y),ie=we==="top",xe=we==="bottom",Ce=["ogx__row",i&&"ogx__row--selected",r%2===0&&"ogx__row--even",r%2===1&&"ogx__row--odd",ie&&"ogx__row--pinned-top",xe&&"ogx__row--pinned-bottom",L&&"ogx__row--dragging",k&&"ogx__row--drag-over",Q&&"ogx__row--group",oe?.isGroupFooter&&"ogx__row--group-footer"].filter(Boolean).join(" ");return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:Ce,onClick:O,onDoubleClick:c?J:void 0,role:"row","aria-rowindex":se??r+2,"aria-selected":i,"aria-level":K?(oe?.treeDepth??0)+1:void 0,"aria-expanded":ge?oe?.isExpanded===!0:void 0,"data-rowindex":r,onDragOver:_?_(R):void 0,onDrop:P?P(R):void 0,style:{maxHeight:`${re}px`,minHeight:`${re}px`,"--height":`${re}px`,"--border-width":"1px"},children:[N&&d.jsx("div",{className:`ogx__cell ogx__cell--drag-handle ${Z==="__reorder_col__"?"ogx__cell--focused":""} ${Z==="__reorder_col__"&&H?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":M?"Drag to reorder row":void 0,"aria-colindex":U,"data-field":"__reorder_col__",tabIndex:-1,style:{position:"sticky",insetInlineStart:0,zIndex:sr},draggable:!!M,onDragStart:M?M(R):void 0,onDragEnd:F,onClick:le=>le.stopPropagation(),children:M&&d.jsx(bg,{})}),p&&d.jsx("div",{className:`ogx__cell ogx__cell--expand ${S?"ogx__cell--pinned-left":""} ${Z==="__expand_col__"?"ogx__cell--focused":""} ${Z==="__expand_col__"&&H?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":fe?f?"Collapse row details":"Expand row details":void 0,"aria-expanded":fe?f:void 0,"aria-controls":fe&&f?j:void 0,"aria-colindex":X,"data-field":"__expand_col__",style:{position:S?"sticky":void 0,insetInlineStart:S?N?48:0:void 0,zIndex:S?sr:void 0},tabIndex:-1,onClick:le=>{le.stopPropagation(),u?.({row:t,field:"__expand_col__",value:f,colDef:{field:"__expand_col__",width:48},rowIndex:r,colIndex:-1})},children:fe&&d.jsx(Ho,{isExpanded:f,onClick:Y,variant:"plus-minus",tabIndex:-1})}),l&&d.jsx("div",{className:`ogx__cell ogx__cell--checkbox ${E?"ogx__cell--pinned-left":""} ${Z==="__checkbox_col__"?"ogx__cell--focused":""} ${Z==="__checkbox_col__"&&H?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-colindex":ne,"data-field":"__checkbox_col__",style:{position:E?"sticky":void 0,insetInlineStart:E?(N?48:0)+(p&&S?48:0):void 0,zIndex:E?sr:void 0},tabIndex:-1,onClick:le=>{le.stopPropagation(),u?.({row:t,field:"__checkbox_col__",value:i,colDef:{field:"__checkbox_col__",width:48},rowIndex:r,colIndex:-1})},children:ee&&d.jsx(gt,{id:de,name:`ogx-select-row-${R}`,checked:i,onChange:G,onClick:le=>le.stopPropagation(),"aria-label":i?`Deselect row ${R}`:`Select row ${R}`,tabIndex:-1,onMouseDown:le=>le.preventDefault()})}),o.map((le,ye)=>{if(le.isSpacer)return d.jsx("div",{style:{width:le.width,minWidth:le.width,flexShrink:0},"aria-hidden":"true"},le.field);let ke,De;ae?ke=t[le.field]:{value:ke,error:De}=Gr(t,le.field,le);const Ne=ue?.get(le.field)??ye,Ie=m[le.field]??le.width,Ee=tt(le.field,x),Ae=!!A&&wo({row:t,field:le.field,value:ke,colDef:le,rowIndex:r,colIndex:Ne,rowMeta:oe},V),pe=I?.id===R&&I?.field===le.field,ve=pe?I?.value:ke,Se=z?.get(R)?.[le.field],be=Se&&!Se.spannedByColSpan&&Se.cellProps.colSpan>1?yg(o,Ne,Se.cellProps.colSpan,m):Se,Le=be&&!be.spannedByColSpan?o[Ne+be.cellProps.colSpan-1]?.field??le.field:le.field,Ue=Ee==="right"?Le:le.field,je=Ee?te[Ue]:void 0,It=Ee==="left"&&Le===q.lastLeft||Ee==="right"&&le.field===q.firstRight,ht=B?.spannedCells[R]?.[le.field],Be=B?.hiddenCells[R]?.[le.field]||!1,gr=ce&&!Be&&le.field!==Ci?ec(ce,Ne,be&&!be.spannedByColSpan?be.cellProps.colSpan:1,ht??1):void 0;return d.jsx(ql,{value:ve,row:t,colDef:le,rowIndex:r,colIndex:Ne,ariaColIndex:he+Ne+1,isSelected:i,onCellClick:u,width:Ie,pinnedPosition:Ee,pinnedOffset:je,isPinnedEdge:It,isFocused:Z===le.field,isFocusVisible:H,isEditable:Ae,isEditing:pe,onCellEditStart:D,onEditStop:$,onCellValueChange:T,colSpanInfo:be,rowSpan:ht,isHiddenByRowSpan:Be,rowMeta:oe,valueError:De,rangeFlags:gr},le.field)})]}),fe&&d.jsx(xg,{id:j,colSpan:he+me,row:t,rowId:R,rowIndex:r,content:b,height:w,isExpanded:f,onHeightChange:C})]})}function vg(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(!Qa(e.cellRange,t.cellRange))return!1}else if(!Object.is(e[o],t[o]))return!1;return!0}const Un=s.memo(Cg,vg);function Xl({getContent:e,params:t}){return d.jsx(Et,{field:"detail panel",renderFn:()=>e(t),resetKey:t.row})}const Sg=e=>e.id;function Yl({rows:e,position:t,columns:n,selectedRowIds:o,checkboxSelection:r,onRowClick:i,onRowDoubleClick:l,onCellClick:a,onSelectionChange:c,columnWidths:u,pinnedColumns:g,pinnedRows:m,hasDetailPanel:x,expandedRowIds:y,getDetailPanelContent:p,getDetailPanelHeight:f,onDetailPanelToggle:h,onDetailPanelHeightChange:b,pinCheckboxColumn:w,pinExpandColumn:C,focusedCell:E,colspanMap:S,rowSpanningCaches:N,rowHeight:M,rowMetaMap:_,getRowId:F=Sg,rowIndexOffset:P=0,ariaRowIndexBase:L,columnIndexMap:k,editingHandlers:I,isCellEditable:A,rowReordering:v=!1,cellRange:W,cellRangeHasRowSpan:V=!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,z)=>{const B=F(H),re=P+z;return d.jsx(Un,{row:H,rowId:B,columns:n,rowIndex:re,ariaRowIndex:L!==void 0?L+z:void 0,columnIndexMap:k,isSelected:o.has(B),checkboxSelection:r,onRowClick:i,onRowDoubleClick:l,onCellClick:a,onSelectionChange:c,columnWidths:u,pinnedColumns:g,pinnedRows:m,hasDetailPanel:x,isDetailPanelExpanded:y.has(B),detailPanelContent:y.has(B)&&p?d.jsx(Xl,{getContent:p,params:{row:H,id:B,rowIndex:re}}):null,detailPanelHeight:y.has(B)?po(ho(f,{row:H,id:B,rowIndex:re})):void 0,onDetailPanelHeightChange:b,onDetailPanelToggle:h,pinCheckboxColumn:w,pinExpandColumn:C,focusedCellField:E?.id===B?E.field:null,colspanMap:S,rowSpanningCaches:N,rowHeight:M,rowMeta:_.get(B),editingCell:I?.editingCell,onEditStart:I?.startCellEdit,onEditStop:I?.stopCellEdit,onEditCellValueChange:I?.setEditCellValue,isCellEditable:A,rowReordering:v,cellRange:vi(W,re,V,Z)},B)})})}const _g=({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 a=typeof i.width=="number"?i.width:150,c=Math.min(a*.7,a-20);return d.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:a,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:c,height:16,borderRadius:4}})},i.field||l)})]});function kg({virtualContainerHeight:e,offsetTop:t,effectiveLoading:n,visibleRows:o,baseColumns:r,virtualColumns:i,viewportWidth:l,checkboxSelection:a,hasDetailPanel:c,rowReordering:u,rowHeight:g,selectedRowIds:m,onRowClick:x,onRowDoubleClick:y,onCellClick:p,onSelectionChange:f,columnWidths:h,pinnedColumns:b,expandedRowIds:w,getDetailPanelContent:C,getDetailPanelHeight:E,onDetailPanelToggle:S,onDetailPanelHeightChange:N,pinCheckboxColumn:M,pinExpandColumn:_,rowReorderHandlers:F,editingHandlers:P,isCellEditable:L,focusedCell:k,colspanMap:I,rowSpanningCaches:A,paginationMode:v,dataSourceLoading:W,sortedUnpinnedRowCount:V,infiniteScrollSkeletonCount:Z,unpinnedRowsLength:H,lastRenderedRowIndex:z,rowMetaMap:B,loadingOverlay:re,ariaRowIndexOffset:oe,columnIndexMap:ue,cellRange:se,cellRangeHasRowSpan:ce=!1,fillHandle:R}){const de=r.length>0?r:(()=>{const q=(l||1e3)-(a?48:0)-(c?48:0)-(u?48:0),Q=150,ae=Math.max(1,Math.ceil(q/Q));return Array.from({length:ae},(fe,ee)=>({field:`placeholder_${ee}`,headerName:"",width:Q}))})(),j=o.filter(q=>!q.pinned),te=v==="infinite"&&W&&V>0&&z>=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((q,Q)=>d.jsx(_g,{columns:de,rowHeight:g,checkboxSelection:a,hasDetailPanel:c,rowReordering:u},`skeleton-${Q}`)):j.map(({row:q,id:Q,rowIndex:ae})=>d.jsx(Un,{row:q,rowId:Q,columns:i,rowIndex:ae,ariaRowIndex:oe!==void 0?ae+oe:void 0,columnIndexMap:ue,isSelected:m.has(Q),checkboxSelection:a,onRowClick:x,onRowDoubleClick:y,onCellClick:p,onSelectionChange:f,columnWidths:h,pinnedColumns:b,hasDetailPanel:c,isDetailPanelExpanded:w.has(Q),detailPanelContent:w.has(Q)&&C?d.jsx(Xl,{getContent:C,params:{row:q,id:Q,rowIndex:ae}}):null,detailPanelHeight:w.has(Q)?po(ho(E,{row:q,id:Q,rowIndex:ae})):void 0,onDetailPanelHeightChange:N,onDetailPanelToggle:S,pinCheckboxColumn:M,pinExpandColumn:_,rowReordering:u,onDragStart:F.canReorderRow(Q)?F.onDragStart:void 0,onDragOver:F.onDragOver,onDragEnd:F.onDragEnd,onDrop:F.onDrop,isDragging:F.draggedRowId===Q,isDragOver:F.dragOverRowId===Q,editingCell:P.editingCell,onEditStart:P.startCellEdit,onEditStop:P.stopCellEdit,onEditCellValueChange:P.setEditCellValue,isCellEditable:L,focusedCellField:k!=null&&k.id===Q?k.field:null,colspanMap:I,rowSpanningCaches:A,rowHeight:g,rowMeta:B.get(Q),cellRange:vi(se,ae,ce,R)},Q)),te&&d.jsx("div",{className:"ogx__skeleton-group",children:Array.from({length:Z}).map((q,Q)=>d.jsx(Un,{row:{id:`__skeleton_${Q}__`,_isSkeleton:!0},columns:i,rowIndex:H+Q,rowHeight:g},`__skeleton_${Q}__`))})]})})}function Eg({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 Jl=48;function Mg({columns:e,aggregationModel:t,aggregationResult:n,columnWidths:o,rowHeight:r,checkboxSelection:i,hasDetailPanel:l,rowReordering:a,pinCheckboxColumn:c=!0,pinExpandColumn:u=!0,pinnedColumns:g,loading:m=!1}){const x=s.useMemo(()=>so(e,o,g,i,c,l,u,a),[e,o,g,i,c,l,u,a]),{lastLeft:y,firstRight:p}=s.useMemo(()=>ao(e,g),[e,g]),f=a?Jl:0,h=f+(l&&u?Jl:0),b=(w,C,E)=>d.jsx("div",{className:`ogx__aggregation-spacer${C?" ogx__aggregation-spacer--pinned":""}`,style:C?{insetInlineStart:E}:void 0,"aria-hidden":"true"},w);return d.jsxs("div",{className:`ogx__aggregation-footer${m?" ogx__aggregation-footer--loading":""}`,role:"row","aria-label":"Aggregation totals","aria-live":"polite","aria-busy":m||void 0,style:{minHeight:`${r}px`},children:[a&&b("__reorder_col__",!0,0),l&&b("__expand_col__",u,f),i&&b("__checkbox_col__",c,h),e.map(w=>{if(w.isSpacer){const L=typeof w.width=="number"?w.width:0;return d.jsx("div",{style:{width:L,minWidth:L,flexShrink:0},"aria-hidden":"true"},w.field)}const C=t[w.field],E=C&&bo(w,C)?C:void 0,S=n[w.field],N=Ct(w,o,120),M=tt(w.field,g),_=M?x[w.field]:void 0,F=["ogx__aggregation-cell",M==="left"&&"ogx__aggregation-cell--pinned-left",M==="right"&&"ogx__aggregation-cell--pinned-right",M==="left"&&w.field===y&&"ogx__aggregation-cell--pinned-left-last",M==="right"&&w.field===p&&"ogx__aggregation-cell--pinned-right-first"].filter(Boolean).join(" "),P={width:N,minWidth:N,maxWidth:N,textAlign:w.align||"left"};return M==="left"&&_!==void 0&&(P.insetInlineStart=_),M==="right"&&_!==void 0&&(P.insetInlineEnd=_),d.jsx("div",{className:F,role:"gridcell",style:P,children:E?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"ogx__aggregation-label",children:E}),d.jsx("span",{className:"ogx__aggregation-value",children:Ln(S,E,w,n)})]}):null},w.field)})]})}function Ng(e){const{setViewportElement:t,handleScroll:n,ariaLabel:o,ariaRows:r,navigationColumnCount:i,rowSelectionEnabled:l,disableMultipleRowSelection:a,cellSelection:c,effectiveLoading:u,viewportTabIndex:g,setKeyboardMode:m,handleMouseDownCapture:x,handleKeyDown:y,handleFocus:p,handleBlur:f,effectivePinnedColumns:h,virtualization:b,renderColumns:w,renderedDataColumns:C,columnGroupingModel:E,checkboxSelection:S,rowSelection:N,sortModel:M,handleSort:_,handleSortAdd:F,multiSort:P,handleColumnResize:L,handleColumnAutosize:k,columnWidths:I,focusedCell:A,columnIndexMap:v,handleHeaderClick:W,headerReorderHandlers:V,rowReordering:Z,hasDetailPanel:H,pinCheckboxColumn:z,pinExpandColumn:B,aggregationModel:re,handleHideColumn:oe,columnsPanel:ue,handlePinColumn:se,wrapHeaderText:ce,headerHeight:R,showHeaderFilters:de,filterModel:j,handleFilterModelChange:te,localeText:q,editingHandlers:Q,isCellEditable:ae,selectedRowIds:fe,handleRowClick:ee,onRowDoubleClick:D,handleCellClick:T,handleSelectionChange:$,expandedRowIds:O,getDetailPanelContent:J,getDetailPanelHeight:G,handleDetailPanelToggle:Y,reportDetailPanelHeight:U,spanning:X,rowMetaMap:ne,fillHandle:he,pinnedTopRows:me,pinnedBottomRows:K,pinnedRows:ge,getRowIdOf:we,showEmptyState:ie,effectiveNoRowsLabel:xe,noRowsOverlay:Ce,loadingOverlay:le,spanRowWindow:ye,visibleRows:ke,baseColumns:De,viewportWidth:Ne,rowReorderHandlers:Ie,paginationMode:Ee,dataSourceLoading:Ae,sortedUnpinnedRowCount:pe,pageSize:ve,unpinnedRowsLength:Se,showAggregationFooter:be,aggregationResult:Le,effectiveRowHeight:Ue,isAggregationLoading:je}=e,{allSelected:It,someSelected:ht}=N,Be={rowReordering:Z,columnIndexMap:v,editingHandlers:Q,isCellEditable:ae,selectedRowIds:fe,checkboxSelection:S,onRowClick:ee,onRowDoubleClick:D,onCellClick:T,onSelectionChange:$,columnWidths:I,pinnedColumns:h,hasDetailPanel:H,expandedRowIds:O,getDetailPanelContent:J,getDetailPanelHeight:G,onDetailPanelToggle:Y,onDetailPanelHeightChange:U,pinCheckboxColumn:z,pinExpandColumn:B,focusedCell:A,colspanMap:X.colspanMap,rowSpanningCaches:X.rowSpanningCaches,rowHeight:Ue,rowMetaMap:ne,cellRange:c.displayRange,cellRangeHasRowSpan:c.hasRowSpan,fillHandle:he.handle};return d.jsx("div",{ref:t,className:"ogx__viewport",onScroll:n,role:"grid","aria-label":o||"Data grid","aria-rowcount":r.rowCount,"aria-colcount":i,"aria-multiselectable":l&&!a||c.enabled,"aria-busy":u,tabIndex:g,onKeyDownCapture:()=>{m(!0)},onMouseDownCapture:x,onMouseDown:c.handleMouseDown,onClickCapture:c.handleClickCapture,onKeyDown:y,onFocus:p,onBlur:f,children:d.jsxs("div",{className:"ogx__content",style:{width:h?.right?.length?`max(100%, ${b.totalWidth}px)`:b.totalWidth},role:"presentation",children:[d.jsxs("div",{className:"ogx__sticky-top",role:"presentation",children:[d.jsx(Kl,{columns:w,allColumns:C,columnGroupingModel:E,checkboxSelection:S,allSelected:It,someSelected:ht,onSelectAll:N.selectAll,sortModel:M,onSort:_,onSortAdd:F,multiSort:P,onColumnResize:L,onColumnAutosize:k,columnWidths:I,pinnedColumns:h,focusedCell:A,columnIndexMap:v,onHeaderClick:W,onDragStart:V.onDragStart,onDragOver:V.onDragOver,onDragEnd:V.onDragEnd,onDrop:V.onDrop,draggedColumn:V.draggedColumn,dragOverColumn:V.dragOverColumn,rowReordering:Z,hasDetailPanel:H,pinCheckboxColumn:z,pinExpandColumn:B,aggregationModel:re,onHideColumn:oe,onManageColumns:ue.openColumnsPanel,onPinColumn:se,wrapHeaderText:ce,headerHeight:R,headerFilters:de,filterModel:j,onFilterModelChange:te,onOpenFilterPanel:ue.openFiltersPanel,localeText:q}),d.jsx(Yl,{...Be,rows:me,position:"top",ariaRowIndexBase:r.topBase,columns:w,pinnedRows:ge,getRowId:we})]}),ie&&d.jsx(Eg,{noRowsLabel:xe,width:b.totalWidth,overlay:Ce}),d.jsx(kg,{...Be,virtualContainerHeight:b.virtualContainerHeight,offsetTop:ye.offsetTop,effectiveLoading:u,visibleRows:ke,baseColumns:De,virtualColumns:w,viewportWidth:Ne,rowReorderHandlers:Ie,paginationMode:Ee,dataSourceLoading:Ae,sortedUnpinnedRowCount:pe,infiniteScrollSkeletonCount:Math.min(ve,20),unpinnedRowsLength:Se,lastRenderedRowIndex:ye.renderContext.lastRowIndex,ariaRowIndexOffset:r.centerOffset,loadingOverlay:le}),d.jsxs("div",{className:"ogx__sticky-bottom",role:"presentation",children:[d.jsx(Yl,{...Be,rows:K,position:"bottom",rowIndexOffset:r.bottomRowIndexOffset,ariaRowIndexBase:r.bottomBase,columns:w,pinnedRows:ge,getRowId:we}),be&&d.jsx(Mg,{columns:b.virtualColumns,aggregationModel:re,aggregationResult:Le,columnWidths:I,rowHeight:Ue,checkboxSelection:S,hasDetailPanel:H,rowReordering:Z,pinCheckboxColumn:z,pinExpandColumn:B,pinnedColumns:h,loading:je})]})]})})}function Zl({count:e,sum:t,average:n}){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:"Count"}),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:"Sum"}),d.jsx("span",{className:"ogx__cell-selection-stat-value","data-stat":"sum",children:nn(t,"sum")})]}),n!==null&&d.jsxs("span",{className:"ogx__cell-selection-stat",children:[d.jsx("span",{className:"ogx__cell-selection-stat-label",children:"Average"}),d.jsx("span",{className:"ogx__cell-selection-stat-value","data-stat":"average",children:nn(n,"avg")})]})]})}function Ig({stats:e,apiRef:t,slot:n,slotProps:o}){const r=n??Zl;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 Lg({paginationSlot:e,paginationSlotProps:t,page:n,paginationModel:o,rowCount:r,pageSizeOptions:i,onPaginationModelChange:l,localeText:a}){const c=e||er;return d.jsx(c,{page:n,pageSize:o.pageSize,rowCount:r,pageSizeOptions:i,onPageChange:u=>l({...o,page:u}),onPageSizeChange:u=>l({...o,pageSize:u,page:0}),localeText:Pi(a),...t})}function Pg({loading:e,error:t,noRowsLabel:n,filteredRowCount:o,dataRowCount:r,filterModel:i,cellSelectionAnnouncement:l,aiAssistantAnnouncement:a}){return d.jsxs("div",{className:"ogx-aria-live-status",role:"status","aria-live":"polite",children:[e?"Loading data...":"",t?`Error: ${kl(t)}`:"",!e&&!t&&(o===0?n:i&&((i.quickFilterValues?.length||0)>0||(i.items?.length||0)>0)?`${r} ${r===1?"row":"rows"} found`:""),l?d.jsxs("span",{className:"ogx-aria-live-status__cells",children:[" ",l]}):null,a?d.jsxs("span",{className:"ogx-aria-live-status__ai",children:[" ",a]}):null]})}function Ag({overlay: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":"Loading data"})})}function Tg({error:e,onRetry:t}){if(!e)return null;const n=kl(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:"Oops! Something went wrong"}),d.jsx("div",{className:"ogx-error-overlay__message",children:n}),t&&d.jsx("button",{type:"button",onClick:t,className:"ogx-button ogx-button--primary",children:"Retry"})]})}function Fg(e){const{containerRef:t,className:n,autoHeight:o,height:r,style:i,hasRowSpanning:l,listView:a,headerFilterHeight:c,slots:u,slotProps:g,toolbarProps:m,aiAssistantPanel:x,orderedColumns:y,columnVisibilityModel:p,disableColumnReorder:f,handleColumnVisibilityModelChange:h,moveColumn:b,resetColumnOrder:w,listViewColumn:C,allRenderableRows:E,dataRows:S,pagination:N,effectivePaginationModel:M,currentPage:_,pageSizeOptions:F,columnsByField:P,paginationRowCount:L,handlePaginationModelChange:k,onRowsScrollEnd:I,toggleExpansion:A,showCellSelectionStats:v,apiRef:W,hasAggregation:V,isHierarchyEnabled:Z,dataSourceError:H,filteredRowCount:z,onRetry:B,...re}=e,{effectiveRowHeight:oe,headerHeight:ue,showHeaderFilters:se,effectiveLoading:ce,columnsPanel:R,columnGroupingModel:de,ariaLabel:j,pinnedTopRows:te,pinnedBottomRows:q,sortedUnpinnedRowCount:Q,effectiveNoRowsLabel:ae,checkboxSelection:fe,paginationMode:ee,localeText:D,getRowIdOf:T,rowSelectionEnabled:$,disableMultipleRowSelection:O,cellSelection:J,aggregationModel:G,aggregationResult:Y,filterModel:U,selectedRowIds:X,rowMetaMap:ne,handleRowClick:he,onRowDoubleClick:me,handleSelectionChange:K}=re,ge=u?.noRowsOverlay,we=u?.loadingOverlay,ie=we?d.jsx(we,{...g?.loadingOverlay}):void 0,xe=ge?d.jsx(ge,{...g?.noRowsOverlay}):void 0,Ce=u?.footer,le=ce&&E.length>0&&ee!=="infinite",ye=u?.toolbar;return 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",a&&"ogx--list-view"].filter(Boolean).join(" "),style:{...i,height:r??i?.height,"--ogx-row-height":`${oe}px`,"--ogx-header-height":`${ue}px`,...se?{"--ogx-header-filter-height":`${c}px`}:void 0},"aria-busy":ce,children:[ye&&m&&d.jsx(Pl.Provider,{value:R.toolbarHost,children:d.jsx(uf,{component:ye,toolbarProps:m})}),x.panelProps&&d.jsx(mf,{panelProps:x.panelProps,slot:u?.aiAssistantPanel,slotProps:g?.aiAssistantPanel}),d.jsx(xf,{isOpen:R.standalonePanelOpen,containerRef:t,panelRef:R.standalonePanelRef,columns:y,columnVisibilityModel:p,disableColumnReorder:f,onClose:R.closeStandalonePanel,onColumnVisibilityChange:h,onColumnMove:b,onColumnOrderReset:w,columnGroupingModel:de}),a&&C&&d.jsx(Sf,{ariaLabel:j,allRenderableRows:E,dataRowCount:S.length,pinnedTopRowCount:te.length,pinnedBottomRowCount:q.length,unpinnedRowCount:Q,pagination:N,effectivePaginationModel:M,currentPage:_,pageSizeOptions:F,selectedRowIds:X,listViewColumn:C,columnsByField:P,rowMetaMap:ne,noRowsLabel:ae,rowHeight:oe,checkboxSelection:fe,paginationMode:ee,serverRowCount:L,paginationSlot:u?.pagination,paginationSlotProps:g?.pagination,localeText:Pi(D),onRowClick:he,onRowDoubleClick:me,onSelectionChange:K,onPaginationModelChange:k,onRowsScrollEnd:I,getRowId:T,multiselectable:$&&!O,selectable:$,onToggleExpansion:A,loading:ce,loadingOverlay:ie,noRowsOverlay:xe,showPaginationControls:!Ce}),!a&&d.jsx(Ng,{...re,loadingOverlay:ie,noRowsOverlay:xe}),J.enabled&&v&&d.jsx(Ig,{stats:J.stats,apiRef:W,slot:u?.cellSelectionStats,slotProps:g?.cellSelectionStats}),Ce&&d.jsx(Ce,{apiRef:W,aggregationModel:G,aggregationResult:V?Y:null,rowCount:Z&&ee!=="server"?S.length:L,pagination:N,paginationModel:M,pageSizeOptions:F,onPaginationModelChange:k,...g?.footer}),!a&&!Ce&&N&&d.jsx(Lg,{paginationSlot:u?.pagination,paginationSlotProps:g?.pagination,page:_,paginationModel:M,rowCount:L,pageSizeOptions:F,onPaginationModelChange:k,localeText:D}),d.jsx(Pg,{loading:ce,error:H,noRowsLabel:ae,filteredRowCount:z,dataRowCount:S.length,filterModel:U,cellSelectionAnnouncement:J.announcement,aiAssistantAnnouncement:x.announcement}),le&&d.jsx(Ag,{overlay:ie}),d.jsx(Tg,{error:H,onRetry:B})]})}function Og(e){const{baseColumns:t,pinnedColumns:n,hasGroupingColumn:o,groupingColDef:r,isTreeData:i,getTreeDataPath:l}=e,a=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 g=l(u);return g[g.length-1]}}:{},...r,field:"__group__",hideable:!1,sortable:!1,filterable:!1,pinnable:!1,exportable:!1},...t]:t,[r,o,i,l,t]),effectivePinnedColumns:a}}function Dg(e){return e.id}function $g(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 Gg(e,t){s.useLayoutEffect(()=>{e&&(e.current=t.current)},[e,t])}function Hg(e){const{hierarchyHandlers:t,pinnedTopRows:n,sortedUnpinnedRows:o,pinnedBottomRows:r,rowMetaMap:i,getRowId:l,hierarchyField:a,dataRows:c}=e,u=t?.getVisibleRows({expandAll:!0,labelField:a});if(!u)return[...n,...o,...r];const g=c?new Set(c):null;return u.filter(m=>!i.get(l(m))?.isGroupRow&&(!g||g.has(m)))}function Bg(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 Wg(e,t){return e===t?!0:e.length!==t.length?!1:e.every((n,o)=>Bg(n,t[o]))}function Vg(e){const[t,n]=s.useState(e),o=Wg(t,e);return o||n(e),o?t:e}function zg(e){const{rows:t,getRowId:n,rowMetaMap:o,columns:r,aggregationModel:i,aggregationResult:l,isSubtotalHidden:a}=e,c=Object.keys(i).length>0,u=new Map(r.map(y=>[y.field,y])),g=[],m=[],x=y=>{for(;m.length>0&&m[m.length-1].header.depth>=y;){const p=m.pop();c&&!a?.(p.id)&&g.push({type:"group-subtotal",depth:p.header.depth,groupField:p.header.groupField,groupValue:p.header.groupValue,groupLabel:p.header.groupLabel,aggregatedValues:In(p.leaves,i,u,"getGroupedExportRows")})}};for(const y of t){const p=n(y),f=o.get(p);if(!f?.isGroupFooter)if(f?.isGroupRow){const h=f.treeDepth??0;x(h);const b={type:"group-header",depth:h,groupField:f.groupingField,groupValue:f.groupingValue,groupLabel:f.groupLabel};g.push(b),m.push({id:p,header:b,leaves:[]})}else g.push({type:"leaf",depth:f?.treeDepth??m.length,row:y}),m.forEach(h=>h.leaves.push(y))}return x(0),c&&l&&g.push({type:"grand-total",depth:0,aggregatedValues:l}),g}function Rg(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:a,rowGroupingHandlers:c,rowMetaMap:u,columns:g,getRowId:m,hierarchyField:x}=o();return a?zg({rows:c.getVisibleRows({expandAll:!0,labelField:x})??[],getRowId:m,rowMetaMap:u,columns:g,aggregationModel:l,aggregationResult:r&&c.rootAggregationPosition!==null?i:null,isSubtotalHidden:y=>c.aggregationPositions.get(y)===null}):null}},[t])}const Ql="ogx--range-dragging",pt=32,Kg=40,Ug=300;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 ar(e){const t=e.getSelection();t&&t.rangeCount>0&&t.removeAllRanges()}const ts=(e,t,n)=>Math.min(Math.max(e,t),n),jn=e=>Math.min(Kg,Math.max(2,Math.round(e/2)));function jg(e){process.env.NODE_ENV!=="production"&&console.warn(`[OpenGridX] Copying ${e} cells. For ranges this large, exportToCsv or exportToExcel is the better tool.`)}function qg(e){const{enabled:t,model:n,allRenderableRows:o,getRowId:r,navigationColumns:i,columnIndexMap:l,spanning:a,rowMetaMap:c,localeText:u,showStats:g}=e,m=t&&n.length>0?n[0]:null,x=s.useMemo(()=>t?i.filter(T=>Ke(T.field)):[],[t,i]),y=s.useMemo(()=>{if(!a.hasColSpan&&!a.hasRowSpan)return;const{colspanMap:T,rowSpanningCaches:$,getSpanOrigin:O}=a;return{getSpanOrigin:O,getColSpan:(J,G)=>{const Y=T.get(J)?.[G];return Y&&!Y.spannedByColSpan?Y.cellProps.colSpan:1},getRowSpan:(J,G)=>$.spannedCells[J]?.[G]??1}},[a]),p=s.useMemo(()=>{if(!t)return null;const T=o.map(r),$=new Map;T.forEach((J,G)=>{$.has(J)||$.set(J,G)});const O=x.map(J=>J.field);return{rowIds:T,rowIndexById:$,fields:O,colIndexByField:new Map(O.map((J,G)=>[J,G])),spans:y}},[t,o,r,x,y]),f=s.useMemo(()=>m&&p?$n(m,p):null,[m,p]),h=f!==null&&kt(f)>1,b=s.useMemo(()=>{if(!f||!h||!p)return null;const T=l.get(p.fields[f.left]),$=l.get(p.fields[f.right]);return T===void 0||$===void 0?null:{top:f.top,bottom:f.bottom,left:T,right:$}},[f,h,p,l]),w=s.useCallback(T=>Re(T,c),[c]),C=s.useCallback((T,$,O)=>{if(p)for(let J=T.top;J<=T.bottom;J++){const G=o[J],Y=p.rowIds[J];if(!(!G||w(Y))){$(G,Y);for(let U=T.left;U<=T.right;U++){const X=x[U],ne=y?.getSpanOrigin(Y,X.field);O(G,Y,X,ne!=null&&(ne.rowId!==Y||ne.field!==X.field))}}}},[p,o,x,y,w]),E={...e,range:m,resolved:f,context:p,rangeColumns:x,forEachCell:C},S=s.useRef(E);s.useLayoutEffect(()=>{S.current=E});const N=s.useRef(null),M=s.useCallback(T=>{N.current=T},[]),_=s.useCallback(()=>{const{getPendingModel:T,model:$}=S.current;return T()??$},[]),F=s.useCallback(()=>{const{context:T,range:$,resolved:O,enabled:J}=S.current,G=J?_()[0]??null:null;return!G||!T?{range:null,resolved:null}:G===$?{range:G,resolved:O}:{range:G,resolved:$n(G,T)}},[_]),P=s.useCallback((T,$)=>{if(!S.current.enabled)return;const O=T.length>1?T.slice(0,1):T;Ya(O,_())||S.current.onModelChange(O,$)},[_]),L=s.useCallback((T,$,O)=>{P([{anchor:T,head:$}],O)},[P]),k=s.useCallback((T,$)=>{const{viewportRef:O,layout:J,rowHeight:G,pinnedTopRowCount:Y}=S.current,U=O.current;U&&(Nn(U,T-Y,J.cumulativeHeights,J.pinnedBottomHeight,G),mo(U,J.unpinnedColsWithWidth.findIndex(X=>X.field===$),J))},[]),I=s.useCallback((T,$,O,J)=>{const{context:G}=S.current,{range:Y,resolved:U}=F();if(!G||J.id===null||!Ke(J.field))return!1;const X=G.rowIndexById.get(J.id),ne=G.colIndexByField.get(J.field);if(X===void 0||ne===void 0)return!1;const he=Y&&U&&ct(Y.anchor,{id:J.id,field:J.field})?{range:Y,resolved:U}:null,me=he?he.range.anchor:{id:J.id,field:J.field},K=he?.resolved??$n({anchor:me,head:me},G);if(!K)return!1;const ge=Za(K,T,$,O,G.rowIds.length-1,G.fields.length-1);if(!ge)return!0;const we={id:G.rowIds[ge.row],field:G.fields[ge.col]};return L(me,we,"keyboard"),k(ge.row,we.field),!0},[F,L,k]),A=s.useCallback(()=>{const{range:T,resolved:$}=F();return!T||!$||kt($)<=1?!1:(L(T.anchor,T.anchor,"keyboard"),!0)},[F,L]),v=s.useCallback(()=>{const{context:T}=S.current;return!T||T.rowIds.length===0||T.fields.length===0?!1:(L({id:T.rowIds[0],field:T.fields[0]},{id:T.rowIds[T.rowIds.length-1],field:T.fields[T.fields.length-1]},"selectAll"),!0)},[L]),W=s.useCallback(()=>{const{context:T}=S.current,{range:$,resolved:O}=F();if(!T)return null;if(O)return O;if($)return null;const J=N.current;return!J||J.id===null||!Ke(J.field)?null:$n({anchor:{id:J.id,field:J.field},head:{id:J.id,field:J.field}},T)},[F]),V=s.useCallback(()=>{const T=W();if(!T)return null;const{rangeColumns:$,forEachCell:O}=S.current,J=kt(T);J>nc&&jg(J);const G=[];if(O(T,he=>{G.push(he)},()=>{}),G.length===0)return null;const Y=$.slice(T.left,T.right+1),U=S.current.context?.spans,X=S.current.getRowId;return Fd(G,Y,U?(he,me)=>{const K=X(he),ge=U.getSpanOrigin(K,me.field);return ge!==null&&(ge.rowId!==K||ge.field!==me.field)}:void 0)},[W]),Z=s.useCallback(()=>{const{forEachCell:T}=S.current,{resolved:$}=F();if(!$)return[];const O=[];return T($,()=>{},(J,G,Y,U)=>{U||O.push({id:G,field:Y.field,value:Me(J,Y.field,Y)})}),O},[F]),H=s.useRef(null),z=s.useRef(!1);s.useEffect(()=>()=>H.current?.stop(),[]);const B=s.useCallback((T,$,O)=>{const J=S.current.context;if(!J)return null;const G=T.ownerDocument;if(typeof G.elementFromPoint!="function")return null;const Y=es(G.elementFromPoint($,O),T);if(!Y)return null;const U=J.rowIds[Y.rowIndex];if(U===void 0)return null;const X=Ke(Y.field)?Y.field:J.fields[0];return X===void 0?null:{id:U,field:X}},[]),re=s.useCallback((T,$)=>{const{context:O,layout:J,pinnedTopRowCount:G}=S.current,Y=J.cumulativeHeights;if(!O||Y.length===0||T<0)return null;let U=0,X=Y.length-1;for(;U<X;){const he=U+X>>1;Y[he]>T?X=he:U=he+1}const ne=O.rowIds[U+G];return ne===void 0?null:{id:ne,field:$}},[]),oe=s.useRef(()=>{}),ue=s.useCallback(T=>{const $=H.current,O=S.current.viewportRef.current;if(!$||!O)return;$.frame=0;const{layout:J}=S.current,G=O.getBoundingClientRect(),Y=O.clientWidth,U=O.clientHeight,X=O.querySelector(":scope > .ogx__content > .ogx__sticky-top"),ne=O.querySelector(":scope > .ogx__content > .ogx__sticky-bottom"),he=X?.querySelector(":scope > .ogx__header-wrap"),me=X?X.getBoundingClientRect().bottom:G.top,K=Math.min(G.top+U,ne?ne.getBoundingClientRect().top:G.top+U),ge=he?he.getBoundingClientRect().bottom:me;$.rtl===void 0&&($.rtl=Xe(O));const we=$.rtl,ie=we?G.right-Y:G.left,xe=J.pinnedSystemColumnsWidth+J.leftWidth,Ce=ie+(we?J.rightWidth:xe),le=ie+Y-(we?xe:J.rightWidth),ye=ts($.x,ie+1,ie+Y-2);let ke=$.y;(ke<G.top||ke>G.top+U||ke<ge)&&(ke=ts(ke,me+1,Math.max(me+1,K-2)));const De=typeof O.ownerDocument.elementFromPoint=="function",Ie=B(O,ye,ke)??(De&&$.moved?re(ke-G.top-(X?X.getBoundingClientRect().height:0)+O.scrollTop,$.head.field):null);if(Ie&&!ct(Ie,$.head)&&($.head=Ie,!$.moved&&!ct(Ie,$.anchor)&&($.moved=!0,S.current.containerRef.current?.classList.add(Ql),ar(O.ownerDocument)),$.onTrack||L($.anchor,Ie,"pointer")),$.onTrack&&$.onTrack($.head,$.x,$.y),!T)return;const Ee=$.y<me||$.y>K||$.x<ie||$.x>ie+Y;if(!$.moved&&!Ee)return;let Ae=0,pe=0;$.y<me+pt?Ae=-jn(me+pt-$.y):$.y>K-pt&&(Ae=jn($.y-(K-pt))),$.x<Ce+pt?pe=-jn(Ce+pt-$.x):$.x>le-pt&&(pe=jn($.x-(le-pt)));const ve=Ae<0&&O.scrollTop>0||Ae>0&&O.scrollTop+U<O.scrollHeight-1,Se=O.scrollWidth-Y,be=we?-Se:0,Le=pe<0&&O.scrollLeft>be||pe>0&&O.scrollLeft<be+Se-1;!ve&&!Le||(ve&&(O.scrollTop+=Ae),Le&&(O.scrollLeft+=pe),$.frame=requestAnimationFrame(()=>oe.current(!0)))},[B,re,L]);s.useLayoutEffect(()=>{oe.current=ue},[ue]);const se=s.useCallback((T,$,O,J,G,Y)=>{H.current?.stop();const U=Y?"pointermove":"mousemove",X=Y?"pointerup":"mouseup",ne=le=>!Y||le.pointerId===Y.pointerId,he=le=>{const ye=H.current;if(!(!ye||!ne(le))){if(le.buttons===0){ye.stop();return}ye.x=le.clientX,ye.y=le.clientY,ye.moved&&(le.preventDefault(),ar(G)),ye.frame||(ye.frame=requestAnimationFrame(()=>ue(!0)))}},me=le=>{const ye=H.current;if(!ye||!ne(le))return;ye.x=le.clientX,ye.y=le.clientY,ue(!1);const ke=ye.moved;ye.stop(!1,le.altKey),ke&&ar(G),ke&&(z.current=!0,setTimeout(()=>{z.current=!1},0))},K=le=>{ne(le)&&H.current?.stop()},ge=le=>{le.key!=="Escape"||!H.current||(le.preventDefault(),le.stopPropagation(),H.current.stop())},we=G.defaultView,ie=()=>H.current?.stop();let xe=!1;const Ce={anchor:T,head:$,x:O,y:J,frame:0,moved:!1,onTrack:Y?.onTrack,stop:(le=!0,ye=!1)=>{Ce.frame&&cancelAnimationFrame(Ce.frame),Ce.frame=0,G.removeEventListener(U,he,!0),G.removeEventListener(X,me,!0),Y&&(G.removeEventListener("pointercancel",K,!0),G.removeEventListener("keydown",ge,!0)),we?.removeEventListener("blur",ie),S.current.containerRef.current?.classList.remove(Ql),H.current===Ce&&(H.current=null),xe||(xe=!0,Y&&Y.onEnd({cancelled:le,altKey:ye}))}};H.current=Ce,G.addEventListener(U,he,!0),G.addEventListener(X,me,!0),Y&&(G.addEventListener("pointercancel",K,!0),G.addEventListener("keydown",ge,!0)),we?.addEventListener("blur",ie)},[ue]),ce=s.useCallback(T=>{const $=S.current.viewportRef.current;if(!$||!S.current.enabled)return;const{start:O,x:J,y:G,pointerId:Y,onTrack:U,onEnd:X}=T;se(O,O,J,G,$.ownerDocument,{pointerId:Y,onTrack:U,onEnd:X})},[se]),R=s.useCallback(T=>{if(T.button!==0||T.defaultPrevented)return;const{context:$}=S.current;if(!$)return;const O=T.currentTarget,J=es(T.target,O);if(!J||!Ke(J.field)||T.target.closest?.(".ogx__cell-fill-handle")||J.element.classList.contains("ogx__cell--editing")||wi(T.target))return;const G=$.rowIds[J.rowIndex];if(G===void 0)return;const Y={id:G,field:J.field};let U=Y;if(T.shiftKey){const X=_()[0],ne=N.current;X&&$.rowIndexById.has(X.anchor.id)&&$.colIndexByField.has(X.anchor.field)?U=X.anchor:ne&&ne.id!==null&&Ke(ne.field)&&(U={id:ne.id,field:ne.field}),T.preventDefault(),z.current=!0;const he=O.ownerDocument;O.contains(he.activeElement)||O.focus({preventScroll:!0})}if(L(U,Y,"pointer"),se(U,Y,T.clientX,T.clientY,O.ownerDocument),T.shiftKey){const X=H.current;X&&!ct(U,Y)&&(X.moved=!0)}},[_,L,se]),de=s.useCallback(T=>{z.current&&(z.current=!1,T.stopPropagation(),T.preventDefault())},[]),j=f?f.right-f.left+1:0,te=f?f.bottom-f.top+1:0,q=u?.cellSelectionAnnouncement??tc,Q=h?q(te*j,te,j):"",[ae,fe]=s.useState("");s.useEffect(()=>{if(!t)return;const T=setTimeout(()=>fe(Q),Ug);return()=>clearTimeout(T)},[t,Q]);const ee=s.useMemo(()=>{if(!g||!f||!h)return null;const T=[];C(f,()=>{},(O,J,G,Y)=>{Y||T.push(Me(O,G.field,G))});const $=T.filter(O=>typeof O=="number"&&!Number.isNaN(O));return{cellCount:kt(f),rowCount:f.bottom-f.top+1,columnCount:f.right-f.left+1,count:at.count(T),numericCount:$.length,sum:$.length?at.sum($):null,average:$.length?at.avg($):null}},[g,f,h,C]),D=s.useMemo(()=>t?{extendSelection:I,collapseSelection:A,selectAllCells:v}:void 0,[t,I,A,v]);return{enabled:t,range:m,resolved:f,displayRange:b,hasRowSpan:a.hasRowSpan,handleMouseDown:t?R:void 0,handleClickCapture:t?de:void 0,extendSelection:I,collapseSelection:A,selectAllCells:v,keyboard:D,getCopyText:V,getSelectedCells:Z,announcement:t?ae:"",stats:ee,reportFocus:M,setModel:P,getCurrentRange:F,startTrackedDrag:ce}}function Xg(e){return s.useCallback(t=>{e.current?.classList.toggle("ogx--kb",t)},[e])}function Yg(e){const{ensureGridFocus:t,setKeyboardMode:n,setFocusedCell:o,getRowId:r,onCellClick:i}=e,l=s.useCallback(c=>{t(),n(!1),o({id:r(c.row),field:c.field,rowIndex:c.rowIndex}),i?.(c)},[i,n,o,t,r]),a=s.useCallback(c=>{t(),o({id:null,field:c}),n(!1)},[t,o,n]);return{handleCellClick:l,handleHeaderClick:a}}function Jg(){const[e,t]=s.useState(!1),[n,o]=s.useState(!1),r=s.useRef(null),i=s.useRef(0),[l,a]=s.useState(0),[c,u]=s.useState(!1),g=s.useMemo(()=>({registerColumnsPanel:()=>(i.current+=1,()=>{i.current-=1}),registerFiltersPanel:()=>(a(h=>h+1),()=>a(h=>h-1))}),[]),m=s.useCallback(()=>u(!0),[]),x=s.useCallback(()=>u(!1),[]),y=s.useCallback(()=>{i.current>0?t(!0):o(!0)},[]),p=s.useCallback(()=>t(!1),[]),f=s.useCallback(()=>o(!1),[]);return s.useEffect(()=>{if(!n)return;function h(w){r.current&&!r.current.contains(w.target)&&o(!1)}function b(w){w.key==="Escape"&&o(!1)}return document.addEventListener("mousedown",h),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",h),document.removeEventListener("keydown",b)}},[n]),{toolbarHost:g,toolbarPanelRequested:e,closeToolbarPanel:p,standalonePanelOpen:n,closeStandalonePanel:f,standalonePanelRef:r,openColumnsPanel:y,toolbarFiltersRequested:c,closeToolbarFiltersPanel:x,openFiltersPanel:l>0?m:void 0}}const Zg=Symbol.for("opengridx.ai.validated");function Qg(e){return typeof e=="object"&&e!==null&&e[Zg]===!0}const qn=["filter","sort","grouping","aggregation","pivot","columnVisibility"],cr={filter:"filterModel",sort:"sortModel",grouping:"rowGroupingModel",aggregation:"aggregationModel",pivot:"pivotModel",columnVisibility:"columnVisibilityModel"};function ns(e){return qn.map(t=>cr[t]).filter(t=>e[t]!==void 0)}function ep(e,t){const n={},o=[];for(const r of qn){const i=cr[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 tp(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 np(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 op(e,t){const n=new Set(t.map(r=>np(typeof r.path=="string"?r.path:""))),o={};for(const r of ns(e))n.has(r)&&tp(e,r)||Object.assign(o,{[r]:e[r]});return o}function rp(e,t){const n={};for(const o of ns(e))Object.assign(n,{[o]:t[o]});return n}function os(e,t){const n={};for(const o of qn.map(r=>cr[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 dr(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 rs(e){return Array.isArray(e)?e.map(rs).join(", "):e instanceof Date?e.toISOString().slice(0,10):e==null?"":String(e)}function is(e,t){return"items"in e?`(${e.items.map(n=>is(n,t)).join(` ${e.logicOperator} `)})`:[t(e.field),e.operator,rs(e.value)].filter(Boolean).join(" ")}const ip={sum:"Sum",avg:"Average",count:"Count",min:"Min",max:"Max",unique:"Unique"};function ls(e,t){const n=[],{filterModel:o,sortModel:r,rowGroupingModel:i,aggregationModel:l,pivotModel:a,columnVisibilityModel:c}=e;if(o){const u=o.items??[];u.forEach((m,x)=>n.push({id:`filter:${x}`,part:"filter",label:is(m,t)}));const g=o.quickFilterValues??[];g.length>0&&n.push({id:"filter:quick",part:"filter",label:`Search: ${g.join(" ")}`}),u.length===0&&g.length===0&&n.push({id:"filter:clear",part:"filter",label:"No filters"})}if(r&&(r.forEach((u,g)=>n.push({id:`sort:${g}`,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,g)=>n.push({id:`grouping:${g}`,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(g=>{const m=l[g];n.push({id:`aggregation:${g}`,part:"aggregation",label:`${ip[m]??m}: ${t(g)}`})}),u.length===0&&n.push({id:"aggregation:clear",part:"aggregation",label:"No summaries"})}if(a){const u=[...a.rowFields,...a.columnFields,...a.valueFields.map(g=>g.field)];n.push({id:"pivot",part:"pivot",label:u.length>0?`Pivot: ${u.map(t).join(", ")}`:"No pivot"})}if(c)for(const u of Object.keys(c))n.push({id:`columnVisibility:${u}`,part:"columnVisibility",label:`${c[u]?"Show":"Hide"}: ${t(u)}`});return n}function lp(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 a={...n.filterModel};i==="quick"?delete a.quickFilterValues:i==="clear"?a.items=[]:a.items=(a.items??[]).filter((c,u)=>u!==l),(a.items??[]).length===0&&(a.quickFilterValues??[]).length===0?delete n.filterModel:n.filterModel=a}else if(r==="sort"&&n.sortModel)n.sortModel=n.sortModel.filter((a,c)=>c!==l),(n.sortModel.length===0||i==="clear")&&delete n.sortModel;else if(r==="grouping"&&n.rowGroupingModel)n.rowGroupingModel=n.rowGroupingModel.filter((a,c)=>c!==l),(n.rowGroupingModel.length===0||i==="clear")&&delete n.rowGroupingModel;else if(r==="aggregation"&&n.aggregationModel){const a={...n.aggregationModel};delete a[i],Object.keys(a).length===0?delete n.aggregationModel:n.aggregationModel=a}else if(r==="columnVisibility"&&n.columnVisibilityModel){const a={...n.columnVisibilityModel};delete a[i],Object.keys(a).length===0?delete n.columnVisibilityModel:n.columnVisibilityModel=a}else r==="pivot"&&delete n.pivotModel;return n}const sp="Ask about this table…",ap=[],Xn=[],ss="The reply was not validated";function cp(){return typeof window<"u"&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window)}function dp(e){return typeof e=="object"&&e!==null&&e.name==="AbortError"}function up(e){return e instanceof Error&&e.message?e.message:"Unknown error"}function fp(e,t){const n=e===0?"No changes":`Applied ${e} ${e===1?"change":"changes"}`;return t>0?`${n}, ${t} ignored`:n}function as(e,t,n){if(!e)return;const o=We(()=>e(t));!o.ok&&process.env.NODE_ENV!=="production"&&console.warn(`[OpenGridX] ${n} threw.`,o.error)}function gp(e){const{apiRef:t,options:n,columns:o}=e,r=!!n,[i,l]=s.useState(!1),[a,c]=s.useState("idle"),[u,g]=s.useState(""),[m,x]=s.useState(null),[y,p]=s.useState(Xn),[f,h]=s.useState(null),[b,w]=s.useState([]),C=s.useRef(null),E=s.useRef(null),S=s.useRef({params:e,applied:f,history:b,open:i});s.useLayoutEffect(()=>{S.current={params:e,applied:f,history:b,open:i}});const N=s.useMemo(()=>{const z=new Map(o.map(B=>[B.field,B.headerName||B.field]));return B=>z.get(B)??B},[o]),M=s.useMemo(()=>f?ls(f.state,N):[],[f,N]),_=s.useCallback(()=>{const z=C.current;C.current=null,z&&z.abort()},[]);s.useEffect(()=>_,[_]);const F=s.useCallback(z=>{if(!S.current.params.options)return;const B=typeof document>"u"?null:document.activeElement;E.current=z??(B instanceof HTMLElement?B:null),l(!0)},[]),P=s.useCallback(()=>{C.current&&(_(),c("stopped"),g("Stopped")),l(!1);const z=E.current;E.current=null,z&&z.isConnected&&z.focus()},[_]),L=s.useCallback(z=>{S.current.open?P():F(z)},[F,P]),k=s.useCallback((z,B)=>{c("error"),g(z),x(null),p(Xn),as(S.current.params.onError,B,"onAiAssistantError")},[]),I=s.useCallback((z,B)=>{const{params:re}=S.current;if(!(typeof B=="object"&&B!==null)||!Qg(B.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."),k(ss,new Error(ss));return}const ue=ep(B.state,re.options?.parts??qn),se=[...Array.isArray(B.errors)?B.errors:[],...ue.errors],ce=op(ue.state,se),R=t.current,de=rp(ce,R.getGridAiState());dr(R,os(ce,de)),h({state:ce,previous:de}),p(se),x(typeof B.message=="string"&&B.message?B.message:null),w(j=>[...j,{prompt:z,applied:ce}]),c("applied"),g(fp(ls(ce,j=>j).length,se.length)),as(re.onApply,B,"onAiAssistantApply")},[t,k]),A=s.useCallback(z=>{const B=z.trim(),{params:re,history:oe}=S.current,ue=re.options?.onPrompt;if(!B||!ue)return;_();const se=new AbortController;C.current=se,c("running"),g("Thinking…"),x(null),p(Xn);const ce={currentState:t.current.getGridAiState(),history:oe,signal:se.signal},R=We(()=>ue(B,ce));(R.ok?Promise.resolve(R.value):Promise.reject(R.error)).then(j=>{C.current===se&&(C.current=null,I(B,j))},j=>{if(C.current===se){if(C.current=null,se.signal.aborted||dp(j)){c("stopped"),g("Stopped");return}k(`The assistant could not answer: ${up(j)}`,j)}})},[t,_,I,k]),v=s.useCallback(()=>{C.current&&(_(),c("stopped"),g("Stopped"))},[_]),W=s.useCallback(()=>{const z=S.current.applied;z&&(dr(t.current,z.previous),h(null),p(Xn),x(null),c("idle"),g("Undone"))},[t]),V=s.useCallback(z=>{const B=S.current.applied;if(!B)return;const re=lp(B.state,z);dr(t.current,os(re,B.previous)),h({state:re,previous:B.previous}),g("Change removed")},[t]);s.useLayoutEffect(()=>{const z=t.current;z.openAiAssistant=()=>F(),z.closeAiAssistant=()=>{S.current.open&&P()}},[t,F,P]);const Z=r&&i,H=s.useMemo(()=>!Z||!n?null:{status:a,statusText:u,message:m,errors:y,chips:M,history:b,suggestions:n.suggestions??ap,placeholder:n.placeholder??sp,voiceAvailable:n.voice!==!1&&cp(),canUndo:f!==null,submit:A,stop:v,undo:W,removeChip:V,close:P},[Z,n,a,u,m,y,M,b,f,A,v,W,V,P]);return{enabled:r,open:Z,openPanel:F,togglePanel:L,closePanel:P,panelProps:H,announcement:r?u:""}}function pp(e){const{toolbar:t,toolbarSlotProps:n,apiRef:o,orderedColumns:r,baseColumns:i,aggregationModel:l,onAggregationModelChange:a,pivotMode:c,pivotModelProp:u,onPivotModelChangeProp:g,pivotModel:m,onPivotModelChange:x,filterModel:y,onFilterModelChange:p,columnVisibilityModel:f,onColumnVisibilityModelChange:h,disableColumnReorder:b,columnGroupingModel:w,moveColumn:C,resetColumnOrder:E,forceColumnsOpen:S,onColumnsPanelClose:N,aiAssistantEnabled:M=!1,aiAssistantOpen:_=!1,onAiAssistantToggle:F,aiAssistantLabel:P,forceFiltersOpen:L,onFiltersPanelClose:k}=e;return s.useMemo(()=>t?{apiRef:o,columns:r,baseColumns:i,aggregationModel:l,onAggregationModelChange:a,...c||u||g?{pivotModel:m,onPivotModelChange:x}:{},filterModel:y,onFilterModelChange:p,columnVisibilityModel:f,onColumnVisibilityModelChange:h,onColumnReorder:b?void 0:(A,v)=>{Vo(w,A,v)&&C(A,v)},onColumnOrderReset:b?void 0:E,forceColumnsOpen:S,onColumnsPanelClose:N,...M&&F?{onAiAssistantToggle:F,aiAssistantOpen:_,...P?{aiAssistantLabel:P}:{}}:{},forceFiltersOpen:L,onFiltersPanelClose:k,...n}:null,[t,b,C,E,r,o,i,l,a,c,u,g,m,x,y,p,f,h,S,N,n,w,M,_,F,P,L,k])}function hp(e){const{apiRef:t,containerRef:n,aiAssistant:o,toolbar:r,localeText:i}=e,l=Jg();Gc(n);const a=gp({apiRef:t,...o}),c=pp({...r,apiRef:t,forceColumnsOpen:l.toolbarPanelRequested,onColumnsPanelClose:l.closeToolbarPanel,aiAssistantEnabled:a.enabled,aiAssistantOpen:a.open,onAiAssistantToggle:a.togglePanel,aiAssistantLabel:i?.aiAssistantButton,forceFiltersOpen:l.toolbarFiltersRequested,onFiltersPanelClose:l.closeToolbarFiltersPanel});return{columnsPanel:l,aiAssistantPanel:a,toolbarProps:c}}function mp(e){const{rows:t,columns:n,getRowId:o,rowHeight:r,headerHeight:i,wrapHeaderText:l=!1,headerFilters:a=!1,headerFilterHeight:c=Vf,autoHeight:u=!1,density:g,height:m,className:x="",style:y,ariaLabel:p,loading:f=!1,checkboxSelection:h=!1,disableRowSelectionOnClick:b=!1,disableMultipleRowSelection:w=!1,disableClipboardCopy:C=!1,cellSelection:E=!1,cellSelectionModel:S,onCellSelectionModelChange:N,showCellSelectionStats:M=!1,rowSelectionModel:_,onRowSelectionModelChange:F,onRowClick:P,onRowDoubleClick:L,onCellClick:k,filterModel:I,onFilterModelChange:A,sortModel:v,onSortModelChange:W,pagination:V=!1,paginationModel:Z,onPaginationModelChange:H,pageSizeOptions:z=[10,25,50,100],pinnedColumns:B,onPinnedColumnsChange:re,pinnedRows:oe,getDetailPanelContent:ue,getDetailPanelHeight:se,detailPanelExpandedRowIds:ce,onDetailPanelExpandedRowIdsChange:R,pinCheckboxColumn:de=!0,pinExpandColumn:j=!0,disableColumnReorder:te=!1,columnOrder:q,onColumnOrderChange:Q,onColumnOrderModelChange:ae,rowReordering:fe=!1,onRowOrderChange:ee,treeData:D=!1,getTreeDataPath:T,defaultGroupingExpansionDepth:$,groupingColDef:O,rowGroupingModel:J,onRowGroupingModelChange:G,aggregationModel:Y,onAggregationModelChange:U,getAggregationPosition:X,isCellEditable:ne,processRowUpdate:he,onProcessRowUpdateError:me,dataSource:K,multiSort:ge=!1,sortingMode:we="client",filterMode:ie="client",paginationMode:xe="client",rowCount:Ce,slots:le,slotProps:ye,pivotMode:ke=!1,pivotModel:De,onPivotModelChange:Ne,onRowsScrollEnd:Ie,initialState:Ee,onStateChange:Ae,columnVisibilityModel:pe,onColumnVisibilityModelChange:ve,listView:Se=!1,listViewColumn:be,columnGroupingModel:Le,noRowsLabel:Ue="No Data",localeText:je,apiRef:It,overscanRowCount:ht=3,aiAssistant:Be,onAiAssistantApply:gr,onAiAssistantError:Fh}=e,pr=Vg(n),Oh=je?.noRowsLabel??Ue,Lt=dc({initialState:Ee,sortModel:v,onSortModelChange:W,filterModel:I,onFilterModelChange:A,aggregationModel:Y,onAggregationModelChange:U,rowGroupingModel:J,onRowGroupingModelChange:G,columnVisibilityModel:pe,onColumnVisibilityModelChange:ve,pinnedColumns:B,onPinnedColumnsChange:re,pivotModel:De,onPivotModelChange:Ne,paginationModel:Z,onPaginationModelChange:H,pageSizeOptions:z,rowSelectionModel:_,onRowSelectionModelChange:F,density:g,cellSelectionModel:S,onCellSelectionModelChange:N}),{sortModel:mt,handleSortModelChange:Dh,filterModel:Pt,handleFilterModelChange:$s,aggregationModel:rt,handleAggregationModelChange:$h,columnVisibilityModel:At,handleColumnVisibilityModelChange:hr,pinnedColumns:mr,handlePinnedColumnsChange:Gh,currentPivotModel:Gs,handlePivotModelChange:Hh,effectivePaginationModel:it,handlePaginationModelChange:wr,selectedRowIds:Bh,handleRowSelectionModelChange:Wh,density:Hs,rowGroupingModel:Bs}=Lt,mn=af({rows:t,columns:pr,pivotMode:ke,pivotModel:Gs,filterModel:Pt,sortModel:mt,hasDataSource:!!K,hierarchyRequested:D||Bs.length>0}),wt=mn.isActive,br=a&&!wt,{rowReordering:wn,hierarchyRowGroupingModel:Vh,isTreeDataRequested:zh,isTreeData:Qn,isRowGrouping:Jt,isHierarchyEnabled:eo,hasGroupingColumn:Rh,pagination:bt,listView:xr}=lc({rowGroupingModel:Bs,treeData:D,hasTreeDataPath:!!T,isPivotActive:wt,rowReordering:fe,hasGroupingColDef:!!O,pagination:V,paginationMode:xe,listView:Se,hasListViewColumn:!!be}),{rowHeight:Tt,headerHeight:Ws}=hc({rowHeight:r,headerHeight:i,density:Hs}),Kh=mn.rows,Uh=mn.columns,{activeColumns:xt,effectivePinnedColumns:yr}=Og({baseColumns:Uh,pinnedColumns:mr,hasGroupingColumn:Rh,groupingColDef:O,isTreeData:Qn,getTreeDataPath:T}),Cr=jc(xt,At),[jh,qh]=rf(rt),Ft=s.useRef(null),bn=s.useRef(null),Vs=!wt&&o||Dg,vr=Xg(Ft),Sr=Zc({rows:Kh,getRowId:Vs,columns:xt,rowHeight:Tt,headerHeight:Ws,columnVisibilityModel:At,initialState:e.initialState,syncRows:!K}),{state:Fe,apiRef:xn,setRows:Xh,replaceRows:Yh,setColumns:Jh,setDimensions:Zh,setDataSourceLoading:Qh,setDataSourceError:em,setRowCount:tm}=Sr,{getRowIdOf:$e,getRowIdOfInEvents:nm}=$g(Fe.rows.idByRow);Gg(It,xn);const om=Fe.dataSource.loading,_r=f||om,to=s.useMemo(()=>Fe.rows.allRows.map(_n=>Fe.rows.idRowsLookup.get(_n)),[Fe.rows]),{treeDataHandlers:no,rowGroupingHandlers:kr,activeHierarchyHandlers:Zt,rowMetaMap:qe}=hd({rows:to,getRowId:$e,getTreeDataPath:T,isTreeDataRequested:zh,isTreeData:Qn,columns:xt,rowGroupingModel:Vh,isRowGrouping:Jt,aggregationModel:rt,defaultGroupingExpansionDepth:$,filterModel:Pt,sortModel:mt,getAggregationPosition:X,columnLookup:Cr,filterMode:ie,sortingMode:we}),{editCommitChannel:rm,batchEdit:im,editingHandlers:Er}=Ku({rowsLookup:Fe.rows.idRowsLookup,rows:to,getRowId:$e,columns:xt,processRowUpdate:he,onProcessRowUpdateError:me,replaceRows:Yh}),Mr=Hc({selectedRowIds:Bh,rowsLookup:Fe.rows.idRowsLookup,rowMetaMap:qe,enabled:!K&&!wt&&xe==="client"&&ie==="client",onSelectionModelChange:Wh}),zs=tf({dataSource:K,sortModel:mt,filterModel:Pt,paginationModel:it,paginationMode:xe,sortingMode:we,filterMode:ie,aggregationModel:rt,rowGroupingActive:Jt,getRowId:Vs,setRows:Xh,setRowCount:tm,setDataSourceLoading:Qh,setDataSourceError:em,onAggregationResults:qh,onPaginationModelChange:wr});of({enabled:Qn&&!!K,treeNodes:no.treeNodes,isGroupExpanded:no.isGroupExpanded,getNodePath:no.getNodePath,toggleExpansion:no.toggleExpansion,fetchChildren:zs.fetchChildren});const{hasDetailPanel:yn,expandedRowIds:Nr,handleDetailPanelToggle:Rs,detailPanelHeights:lm,reportDetailPanelHeight:sm}=Ic({hasDetailPanel:!!ue,controlledExpandedRowIds:ce,onDetailPanelExpandedRowIdsChange:R,rowMetaMap:qe}),{effectiveColumns:Ks,hierarchyField:Ir,orderedColumns:Lr,visibleOrderedColumns:Us,renderOrderedColumns:am,navigationColumns:oo,columnIndexMap:Pr,columnWidths:Ar,effectiveColumnOrder:cm,columnReorderHandlers:dm,moveColumn:js,resetColumnOrder:qs,handleColumnResize:Xs}=Mc({activeColumns:xt,isHierarchyEnabled:eo,isRowGrouping:Jt,isTreeData:Qn,activeHierarchyHandlers:Zt,columnVisibilityModel:At,columnOrder:q,onColumnOrderChange:Q,onColumnOrderModelChange:ae,disableColumnReorder:te,pivotMode:wt,checkboxSelection:h,hasDetailPanel:yn,rowReordering:wn,initialState:Ee,setColumns:Jh,pinnedColumns:yr,getRowId:nm,aggregationModel:rt,groupingRows:Jt?kr.groupingRows:void 0});Ac({onStateChange:Ae,sortModel:mt,filterModel:Pt,effectivePaginationModel:it,columnWidths:Ar,effectiveColumnOrder:cm,columnVisibilityModel:At,pinnedColumns:mr,density:Hs});const Tr=wc({effectiveRows:to,activeHierarchyHandlers:Zt,filterMode:ie,filterModel:mn.pipelineFilterModel,sortModel:mn.pipelineSortModel,sortingMode:we,pagination:bt,paginationMode:xe,effectivePaginationModel:it,pinnedRows:oe,getRowId:$e,columnLookup:Cr,hierarchyField:Ir}),{filteredRows:Ys,dataRows:ro,pinnedTopRows:ze,pinnedBottomRows:lt,sortedUnpinnedRows:yt,paginatedUnpinnedRows:io,allRenderableRows:Cn}=Tr,Fr=bt?io:yt;qc({paginationModel:it,currentPage:Tr.currentPage,enabled:bt&&!_r&&yt.length>0,onPaginationModelChange:wr});const Js=mc({paginationMode:xe,hasDataSource:!!K,dataSourceRowCount:Fe.pagination.rowCount,rowCountProp:Ce,clientRowCount:yt.length}),{rowSelection:Zs,handleRowClick:Qs,handleSelectionChange:ea}=Uc({controlledState:Lt,interactions:{dataRows:ro,getRowId:$e,isPivotActive:wt,disableRowSelectionOnClick:b,isHierarchyEnabled:eo,rowMetaMap:qe,activeHierarchyHandlers:Zt,onRowClick:P},api:{apiRef:Sr.apiRef,multiSort:ge,selectedRowIds:Mr,disableMultipleRowSelection:w,isSyntheticRowId:_n=>Re(_n,qe),getVisibleRows:()=>[...ze,...Fr,...lt],getAllFilteredRows:()=>Hg({hierarchyHandlers:Zt,pinnedTopRows:ze,sortedUnpinnedRows:yt,pinnedBottomRows:lt,rowMetaMap:qe,getRowId:$e,hierarchyField:Ir,dataRows:ro}),visibleColumns:am}}),um=Qc({rows:to,getRowId:$e,onRowOrderChange:ee,rowReordering:wn}),{aggregationResult:ta,isLoading:fm}=Ll({rows:ro,columns:xt,aggregationModel:wt?Ca:rt,isServerSide:Sl({dataSource:K,paginationMode:xe,sortingMode:we,filterMode:ie}),dataSource:K,filterModel:Pt,sortModel:mt,serverAggregationResults:jh}),Or=Object.keys(rt).length>0&&!wt;Rg({apiRef:xn,hasAggregation:Or,aggregationResult:ta,aggregationModel:rt,isRowGrouping:Jt,rowGroupingHandlers:kr,rowMetaMap:qe,columns:xt,getRowId:$e,hierarchyField:Ir});const Ge=xa({rowHeight:Tt,pagination:bt,paginatedUnpinnedRows:io,sortedUnpinnedRows:yt,expandedRowIds:Nr,getDetailPanelHeight:se,detailPanelHeights:lm,pinnedTopRowsLength:ze.length,pinnedBottomRowsLength:lt.length,pinnedTopRows:ze,pinnedBottomRows:lt,visibleOrderedColumns:Us,pinnedColumns:yr,columnWidths:Ar,viewportWidth:Fe.dimensions.viewportWidth||1e3,checkboxSelection:h,hasDetailPanel:yn,rowReordering:wn,pinCheckboxColumn:de,pinExpandColumn:j,paginationMode:xe,isLoading:Fe.dataSource.loading,pageSize:it.pageSize,getRowId:$e}),vn=Xu({pinnedTopRows:ze,centerRows:Fr,pinnedBottomRows:lt,columns:Us,leftPinnedColumns:Ge.leftPinnedCols,unpinnedColumns:Ge.unpinnedColsWithWidth,rightPinnedColumns:Ge.rightPinnedCols,expandedRowIds:yn?Nr:void 0,rowMetaMap:qe,getRowId:$e}),na=s.useMemo(()=>[...Ge.leftPinnedCols,...Ge.unpinnedColsWithWidth,...Ge.rightPinnedCols],[Ge.leftPinnedCols,Ge.unpinnedColsWithWidth,Ge.rightPinnedCols]),Sn=qg({enabled:E&&!xr,model:Lt.cellSelectionModel,onModelChange:Lt.handleCellSelectionModelChange,getPendingModel:Lt.getPendingCellSelectionModel,allRenderableRows:Cn,getRowId:$e,navigationColumns:oo,columnIndexMap:Pr,spanning:vn,rowMetaMap:qe,layout:Ge,rowHeight:Tt,pinnedTopRowCount:ze.length,viewportRef:bn,containerRef:Ft,localeText:je,showStats:M}),gm=Vu({apiRef:xn,containerRef:Ft,viewportRef:bn,copyColumns:na,getRowId:$e,disableClipboardCopy:C,getCellRangeCopyText:Sn.enabled?Sn.getCopyText:void 0,layout:Ge,rowHeight:Tt,orderedColumns:Lr,onColumnResize:Xs}),{handleScroll:pm,setViewportElement:hm,maxContentHeight:mm,virtualization:Ot}=Ou({viewport:{onRowsScrollEnd:Ie,overscanRowCount:ht,autoHeight:u,setDimensions:Zh},viewportRef:bn,containerRef:Ft,layout:Ge,viewportWidth:Fe.dimensions.viewportWidth,viewportHeight:Fe.dimensions.viewportHeight,virtualization:{autoHeight:u,rowReordering:wn,hasDetailPanel:yn,checkboxSelection:h,pinCheckboxColumn:de,pinExpandColumn:j}}),{handleSort:oa,handleSortAdd:ra}=zc({sortModel:mt,onSortModelChange:Dh}),ia=h||!b,{focusedCell:la,setFocusedCell:sa,viewportTabIndex:wm,ensureGridFocus:bm,handleFocus:xm,handleBlur:ym,handleKeyDown:Cm,handleMouseDownCapture:vm}=ic({allRenderableRows:Cn,navigationColumns:oo,checkboxSelection:h,selectedRowIds:Mr,handleSelectionChange:ea,handleDetailPanelToggle:Rs,editingHandlers:Er,setKeyboardMode:vr,sortModel:mt,handleSort:oa,handleSortAdd:ra,multiSort:ge,isCellEditable:ne,pagination:bt,pageSize:it.pageSize,virtualization:Ot,viewportRef:bn,pinnedTopRowCount:ze.length,getRowId:$e,rowMetaMap:qe,getSpanOrigin:vn.getSpanOrigin,onRowActivate:Qs,toggleRowExpansion:Zt?.toggleExpansion,handleSelectAll:Zs.selectAll,rowSelectionEnabled:ia,multipleRowSelectionEnabled:!w,pinCheckboxColumn:de,pinExpandColumn:j,rowHeight:Tt,cellSelection:Sn.keyboard,headerFilters:br}),{handleCellClick:Sm,handleHeaderClick:_m}=Yg({ensureGridFocus:bm,setKeyboardMode:vr,setFocusedCell:sa,getRowId:$e,onCellClick:k}),km=Mu({props:e,apiRef:xn,containerRef:Ft,viewportRef:bn,selection:Sn,model:Lt.cellSelectionModel,getPendingModel:Lt.getPendingCellSelectionModel,focusedCell:la,setFocusedCell:sa,allRenderableRows:Cn,getRowId:$e,navigationColumns:oo,columnIndexMap:Pr,isCellEditable:ne,rowMetaMap:qe,getSpanOrigin:vn.getSpanOrigin,isEditing:Er.editingCell!==null,batchEdit:im,channel:rm,layout:Ge,rowHeight:Tt,pinnedTopRowCount:ze.length}),{handleHideColumn:Em,handlePinColumn:Mm}=Rc({columnVisibilityModel:At,onColumnVisibilityModelChange:hr,pinnedColumns:mr,onPinnedColumnsChange:Gh}),{ariaRows:Nm,spanRowWindow:Im,visibleRows:aa,renderColumns:Lm}=Sd({aria:{columnGroupingModel:Le,headerFilterRow:br,pinnedTopCount:ze.length,pinnedBottomCount:lt.length,pagination:bt,paginationMode:xe,paginationModel:it,paginationRowCount:Js,paginatedUnpinnedRowCount:io.length,sortedUnpinnedRowCount:yt.length},spanning:vn,virtualization:Ot,layout:Ge,pinnedTopRows:ze,pinnedBottomRows:lt,paginatedUnpinnedRows:io,sortedUnpinnedRows:yt,pagination:bt,getRowId:$e});Dc({paginationRequested:V,isRowGrouping:Jt,autoHeight:u,viewportHeight:Fe.dimensions.viewportHeight,renderedRowCount:aa.length,totalRowCount:ze.length+Fr.length+lt.length,pinnedRowsIgnored:eo&&!!(oe?.top?.length||oe?.bottom?.length),scrollHeight:Ot.totalHeight,maxContentHeight:mm,reachableRowCount:yc(Ot.cumulativeHeights,Ot.virtualContainerHeight),unpinnedRowCount:Ot.cumulativeHeights.length,listViewWithoutColumn:Se&&!be,listViewRowCount:xr&&be?Cn.length:0});const Pm=Ju(Le,dm),Am=s.useMemo(()=>Ks.some(_n=>!!_n.rowSpan),[Ks]),{columnsPanel:Tm,aiAssistantPanel:Fm,toolbarProps:Om}=hp({apiRef:xn,containerRef:Ft,localeText:je,aiAssistant:{options:Be,columns:xt,onApply:gr,onError:Fh},toolbar:{toolbar:le?.toolbar,toolbarSlotProps:ye?.toolbar,orderedColumns:Lr,baseColumns:pr,aggregationModel:rt,onAggregationModelChange:$h,pivotMode:ke,pivotModelProp:De,onPivotModelChangeProp:Ne,pivotModel:Gs,onPivotModelChange:Hh,filterModel:Pt,onFilterModelChange:$s,columnVisibilityModel:At,onColumnVisibilityModelChange:hr,disableColumnReorder:te,columnGroupingModel:Le,moveColumn:js,resetColumnOrder:qs}}),Dm={setViewportElement:hm,handleScroll:pm,ariaLabel:p,ariaRows:Nm,navigationColumnCount:oo.length,rowSelectionEnabled:ia,disableMultipleRowSelection:w,cellSelection:Sn,effectiveLoading:_r,viewportTabIndex:wm,setKeyboardMode:vr,handleMouseDownCapture:vm,handleKeyDown:Cm,handleFocus:xm,handleBlur:ym,effectivePinnedColumns:yr,virtualization:Ot,renderColumns:Lm,renderedDataColumns:na,columnGroupingModel:Le,checkboxSelection:h,rowSelection:Zs,sortModel:mt,handleSort:oa,handleSortAdd:ra,multiSort:ge,handleColumnResize:Xs,handleColumnAutosize:gm,columnWidths:Ar,focusedCell:la,columnIndexMap:Pr,handleHeaderClick:_m,headerReorderHandlers:Pm,rowReordering:wn,hasDetailPanel:yn,pinCheckboxColumn:de,pinExpandColumn:j,aggregationModel:rt,handleHideColumn:Em,columnsPanel:Tm,handlePinColumn:Mm,wrapHeaderText:l,headerHeight:Ws,showHeaderFilters:br,filterModel:Pt,handleFilterModelChange:$s,localeText:je,editingHandlers:Er,isCellEditable:ne,selectedRowIds:Mr,handleRowClick:Qs,onRowDoubleClick:L,handleCellClick:Sm,handleSelectionChange:ea,expandedRowIds:Nr,getDetailPanelContent:ue,getDetailPanelHeight:se,handleDetailPanelToggle:Rs,reportDetailPanelHeight:sm,spanning:vn,rowMetaMap:qe,fillHandle:km,pinnedTopRows:ze,pinnedBottomRows:lt,pinnedRows:oe,getRowIdOf:$e,showEmptyState:!_r&&!Fe.dataSource.error&&Ys.length===0,effectiveNoRowsLabel:Oh,spanRowWindow:Im,visibleRows:aa,baseColumns:pr,viewportWidth:Fe.dimensions.viewportWidth,rowReorderHandlers:um,paginationMode:xe,dataSourceLoading:Fe.dataSource.loading,sortedUnpinnedRowCount:yt.length,pageSize:it.pageSize,unpinnedRowsLength:Ge.unpinnedRowsLength,showAggregationFooter:Or&&kr.rootAggregationPosition!==null,aggregationResult:ta,effectiveRowHeight:Tt,isAggregationLoading:fm,containerRef:Ft,className:x,autoHeight:u,height:m,style:y,hasRowSpanning:Am,listView:xr,headerFilterHeight:c,slots:le,slotProps:ye,toolbarProps:Om,aiAssistantPanel:Fm,orderedColumns:Lr,columnVisibilityModel:At,disableColumnReorder:te,handleColumnVisibilityModelChange:hr,moveColumn:js,resetColumnOrder:qs,listViewColumn:be,allRenderableRows:Cn,dataRows:ro,pagination:bt,effectivePaginationModel:it,currentPage:Tr.currentPage,pageSizeOptions:z,columnsByField:Cr.byField,paginationRowCount:Js,handlePaginationModelChange:wr,onRowsScrollEnd:Ie,toggleExpansion:Zt?.toggleExpansion,showCellSelectionStats:M,apiRef:Sr.apiRef,hasAggregation:Or,isHierarchyEnabled:eo,dataSourceError:Fe.dataSource.error,filteredRowCount:Ys.length,onRetry:K?zs.fetchRows:void 0};return d.jsx(Fg,{...Dm})}function wp({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 bp=300;function jt(e){return"field"in e&&!("items"in e)}function cs(e,t){return e.find(n=>jt(n)&&n.field===t)}function ds(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)=>ds(n,t[o])):!1}function xp(e,t){return e===t?!0:jt(e)&&jt(t)?e.id===t.id&&e.field===t.field&&e.operator===t.operator&&ds(e.value,t.value):!jt(e)&&!jt(t)?e.id===t.id&&e.logicOperator===t.logicOperator&&ur(e.items,t.items):!1}function ur(e,t){return e===t?!0:e.length===t.length&&e.every((n,o)=>xp(n,t[o]))}function yp(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 us(e,t){return Object.is(e.value,t)?!0:t!=null&&String(e.value).toLowerCase()===String(t).toLowerCase()}function fs(e,t){return _o(e,t.type)}function gs(e,t){return t==="isAnyOf"?e.split(",").map(n=>n.trim()).filter(n=>n!==""):e}function Cp(e,t){if(!$t.has(t))return t==="isAnyOf"?e==null||e===""?[]:Array.isArray(e)?e:[e]:Array.isArray(e)?e.length>0?e[0]:"":e??""}const vp=({col:e,item:t,resetToken:n,onChange:o})=>{const r=s.useId(),i=s.useMemo(()=>Qr(e.type),[e.type]),l=i[0],a=t?.operator??l,c=i.includes(a)?i:[a,...i],u=!!t,g=e.headerName||e.field,[m,x]=s.useState(null),[y,p]=s.useState(n);y!==n&&(p(n),x(null));const f=s.useRef(o),h=s.useRef(t),b=s.useRef(e);s.useLayoutEffect(()=>{f.current=o,h.current=t,b.current=e});const w=s.useCallback((I,A)=>({id:h.current?.id??`${e.field}-${Date.now()}`,field:e.field,operator:I,value:A}),[e.field]),C=s.useCallback(I=>{const A=h.current;if(A?I===fs(A.value,b.current):I.trim()==="")return;const W=A?.operator??l;f.current(w(W,gs(I,W)))},[l,w]),E=s.useRef(null),S=s.useRef(C);s.useLayoutEffect(()=>{E.current=m,S.current=C}),s.useEffect(()=>()=>{const I=E.current;E.current=null,I!==null&&S.current(I)},[]),s.useEffect(()=>{if(m===null)return;const I=setTimeout(()=>{E.current=null,C(m),x(null)},bp);return()=>clearTimeout(I)},[m,C]);const N=I=>{const A=m!==null?gs(m,I):t?.value;x(null),o(w(I,Cp(A,I)))},M=()=>{x(null),o(null)},_=!$t.has(a),F=yp(e),P=`ogx-filter__value-input${u?" ogx-filter__value-input--active":""}`,L=`Filter value for ${g}`;let k=null;if(_&&e.type==="boolean")k=d.jsxs("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${P} ogx-filter__value-select`,value:t?.value==null?"":String(t.value),onChange:I=>{I.target.value===""?o(null):o(w(a,I.target.value))},"aria-label":L,children:[d.jsx("option",{value:"",children:"Any"}),d.jsx("option",{value:"true",children:"true"}),d.jsx("option",{value:"false",children:"false"})]});else if(_&&e.type==="singleSelect"&&F.length>0&&a==="isAnyOf"){const I=Array.isArray(t?.value)?t.value:t?.value==null||t.value===""?[]:[t.value];k=d.jsx("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${P} ogx-filter__value-multiselect`,multiple:!0,size:Math.min(F.length,4),value:F.filter(A=>I.some(v=>us(A,v))).map(A=>A.key),onChange:A=>{const v=new Set(Array.from(A.target.selectedOptions,W=>W.value));o(w("isAnyOf",F.filter(W=>v.has(W.key)).map(W=>W.value)))},"aria-label":L,children:F.map(A=>d.jsx("option",{value:A.key,children:A.label},A.key))})}else if(_&&e.type==="singleSelect"&&F.length>0&&(a==="is"||a==="not")){const I=F.find(A=>us(A,t?.value));k=d.jsxs("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${P} ogx-filter__value-select`,value:I?.key??"",onChange:A=>{const v=F.find(W=>W.key===A.target.value);o(w(a,v?v.value:""))},"aria-label":L,children:[d.jsx("option",{value:"",children:"Any"}),F.map(A=>d.jsx("option",{value:A.key,children:A.label},A.key))]})}else _&&(k=d.jsx(et,{id:`${r}-val`,name:`filter-val-${e.field}`,inputClassName:P,type:e.type==="date"?"date":"text",value:m??fs(t?.value,e),onChange:I=>x(I.target.value),placeholder:e.type==="number"?"Number…":"Value…","aria-label":L}));return d.jsxs("div",{className:`ogx-filter__row${u?" ogx-filter__row--active":""}`,children:[d.jsx("span",{className:"ogx-filter__col-label",title:e.field,children:g}),d.jsxs("div",{className:"ogx-filter__controls",children:[d.jsx("select",{id:`${r}-op`,name:`filter-op-${e.field}`,className:`ogx-filter__op-select${u?" ogx-filter__op-select--active":""}`,value:a,onChange:I=>N(I.target.value),"aria-label":`Filter operator for ${g}`,children:c.map(I=>d.jsx("option",{value:I,children:I},I))}),k,u&&d.jsx("button",{type:"button",className:"ogx-filter__row-clear",onClick:M,"aria-label":`Clear filter for ${g}`,title:"Clear",children:"×"})]})]})},ps=({filterModel:e,columns:t,onFilterModelChange:n})=>{const o=s.useMemo(()=>e.items??[],[e.items]),r=e.logicOperator??"and",[i,l]=s.useState(null),[a,c]=s.useState(o),[u,g]=s.useState(0);if(a!==o){c(o);const h=!ur(a,o),b=i!==null&&ur(i,o);h&&!b&&g(w=>w+1)}const m=s.useCallback((h,b)=>{const w=o.findIndex(E=>jt(E)&&E.field===h);let C;if(w===-1){if(!b)return;C=[...o,b]}else b?C=o.map((E,S)=>S===w?b:E):C=o.filter((E,S)=>S!==w);l(C),n({...e,items:C})},[o,e,n]),x=s.useCallback(h=>{n({...e,logicOperator:h})},[e,n]),y=t.filter(h=>h.filterable!==!1),p=y.filter(h=>cs(o,h.field)).length,f=o.length-p;return d.jsxs(d.Fragment,{children:[o.length>1&&d.jsxs("div",{className:"ogx-filter__logic-bar",children:[d.jsx("span",{className:"ogx-filter__logic-label",children:"Match:"}),d.jsx("button",{type:"button",className:`ogx-filter__logic-pill${r==="and"?" ogx-filter__logic-pill--active":""}`,onClick:()=>x("and"),"aria-pressed":r==="and",children:"ALL (AND)"}),d.jsx("button",{type:"button",className:`ogx-filter__logic-pill${r==="or"?" ogx-filter__logic-pill--active":""}`,onClick:()=>x("or"),"aria-pressed":r==="or",children:"ANY (OR)"})]}),f>0&&d.jsx("div",{className:"ogx-filter__hidden-note",role:"note",children:f===1?"1 more condition (a filter group or a second condition on a column) is applied and not shown here.":`${f} more conditions (filter groups or further conditions on a column) are applied and not shown here.`}),y.length===0?d.jsx("div",{className:"ogx-filter__empty",children:"No filterable columns."}):y.map(h=>d.jsx(vp,{col:h,item:cs(o,h.field),resetToken:u,onChange:b=>m(h.field,b)},h.field))]})},hs=["sum","avg","count","min","max"];function ms(){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 Sp({anchorRef:e,columns:t,model:n,onChange:o,onClose:r}){const i=s.useRef(null),[l,a]=s.useState({top:0,right:0}),[c,u]=s.useState(null);s.useLayoutEffect(()=>{u(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const g=s.useCallback(()=>Mn(e.current,Nt()),[e]);s.useEffect(()=>{a(g());const v=()=>a(g());return window.addEventListener("scroll",v,!0),window.addEventListener("resize",v),()=>{window.removeEventListener("scroll",v,!0),window.removeEventListener("resize",v)}},[g]),s.useEffect(()=>{function v(V){i.current&&!i.current.contains(V.target)&&e.current&&!e.current.contains(V.target)&&r()}function W(V){V.key==="Escape"&&r()}return document.addEventListener("mousedown",v),document.addEventListener("keydown",W),()=>{document.removeEventListener("mousedown",v),document.removeEventListener("keydown",W)}},[e,r]);const m=new Set(n.rowFields),x=new Set(n.columnFields),y=new Set(n.valueFields.map(v=>v.field)),p=v=>m.has(v)||x.has(v)||y.has(v),f=v=>t.find(W=>W.field===v),h=v=>f(v)?.headerName??v,b=v=>{const W=f(v)?.availableAggregationFunctions;return W?hs.filter(V=>W.includes(V)):hs},w=v=>v.aggregable!==!1&&(v.type==="number"||v.aggregable===!0)&&b(v.field).length>0,C=v=>v.groupable!==!1;function E(v){m.has(v)||o({...n,rowFields:[...n.rowFields,v]})}function S(v){x.has(v)||o({...n,columnFields:[...n.columnFields,v]})}function N(v){y.has(v)||o({...n,valueFields:[...n.valueFields,{field:v,aggFn:b(v)[0]??"sum"}]})}function M(v){o({...n,rowFields:n.rowFields.filter((W,V)=>V!==v)})}function _(v){o({...n,columnFields:n.columnFields.filter((W,V)=>V!==v)})}function F(v){o({...n,valueFields:n.valueFields.filter((W,V)=>V!==v)})}function P(v,W){o({...n,valueFields:n.valueFields.map((V,Z)=>Z===v?{...V,aggFn:W}:V)})}function L(){o({rowFields:[],columnFields:[],valueFields:[]})}const k=n.rowFields.length+n.columnFields.length+n.valueFields.length,I=t.filter(v=>!p(v.field)&&(C(v)||w(v))),A=d.jsxs("div",{ref:i,className:"ogx-pivot-panel",role:"dialog","aria-label":"Pivot configuration",style:{top:l.top,right:l.right,left:l.left},children:[d.jsxs("div",{className:"ogx-pivot-panel__header",children:[d.jsxs("span",{className:"ogx-pivot-panel__title",children:[d.jsx(ms,{}),"Pivot Mode"]}),k>0&&d.jsx("button",{type:"button",className:"ogx-pivot-panel__reset-btn",onClick:L,title:"Reset pivot",children:"Reset"})]}),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"}),"Row Fields"]}),d.jsx("div",{className:`ogx-pivot-chips${n.rowFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — each becomes a row label",children:n.rowFields.map((v,W)=>d.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--row",children:[h(v),d.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>M(W),title:`Remove ${h(v)}`,"aria-label":`Remove ${h(v)} from Row Fields`,children:"×"})]},`${W}:${v}`))})]}),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"}),"Column Fields"]}),d.jsx("div",{className:`ogx-pivot-chips${n.columnFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — unique values become column headers",children:n.columnFields.map((v,W)=>d.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--col",children:[h(v),d.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>_(W),title:`Remove ${h(v)}`,"aria-label":`Remove ${h(v)} from Column Fields`,children:"×"})]},`${W}:${v}`))})]}),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"}),"Value Fields (aggregated)"]}),d.jsx("div",{className:`ogx-pivot-chips${n.valueFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add numeric fields here — values are aggregated",children:n.valueFields.map((v,W)=>{const V=b(v.field),Z=V.includes(v.aggFn)?V:[v.aggFn,...V];return d.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--value",children:[h(v.field),d.jsx("select",{className:"ogx-pivot-chip__fn-select",value:v.aggFn,onChange:H=>P(W,H.target.value),title:"Aggregation function","aria-label":`Aggregation function for ${h(v.field)}`,children:Z.map(H=>d.jsx("option",{value:H,children:H.toUpperCase()},H))}),d.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>F(W),title:`Remove ${h(v.field)}`,"aria-label":`Remove ${h(v.field)} (${v.aggFn.toUpperCase()}) from Value Fields`,children:"×"})]},`${W}:${v.field}:${v.aggFn}`)})})]}),d.jsx("hr",{className:"ogx-pivot-panel__divider"}),d.jsxs("div",{children:[d.jsx("div",{className:"ogx-pivot-panel__fields-label",children:"Available Fields"}),d.jsxs("div",{className:"ogx-pivot-fields",children:[I.map(v=>{const W=w(v),V=C(v),Z=v.headerName??v.field;return d.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3},children:[d.jsx("span",{className:`ogx-pivot-field-btn${W?" ogx-pivot-field-btn--numeric":""}`,children:Z}),d.jsxs("div",{className:"ogx-pivot-field-actions",children:[V&&d.jsx("button",{type:"button",className:"ogx-pivot-add-btn ogx-pivot-add-btn--row",onClick:()=>E(v.field),title:"Add to Row Fields","aria-label":`Add ${Z} to Row Fields`,children:"Row"}),V&&d.jsx("button",{type:"button",className:"ogx-pivot-add-btn ogx-pivot-add-btn--col",onClick:()=>S(v.field),title:"Add to Column Fields","aria-label":`Add ${Z} to Column Fields`,children:"Col"}),W&&d.jsx("button",{type:"button",className:"ogx-pivot-add-btn ogx-pivot-add-btn--value",onClick:()=>N(v.field),title:"Add to Value Fields","aria-label":`Add ${Z} to Value Fields`,children:"Val"})]})]},v.field)}),I.length===0&&d.jsx("span",{style:{fontSize:12,color:"var(--ogx-color-gray-400, #94a3b8)"},children:"All fields are in use."})]})]})]})]});return c?st.createPortal(A,c):null}function _p(){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 kp(){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 ws(e){return e.trim().split(/\s+/).filter(Boolean).join(" ")}function Ep({value:e="",onChange:t,placeholder:n="Search...",debounceMs:o=250}){const[r,i]=s.useState(()=>e.length>0),[l,a]=s.useState(e),c=s.useRef(null),u=s.useRef(null),g=s.useRef(t);s.useLayoutEffect(()=>{g.current=t},[t]);const m=s.useRef(e),x=s.useRef(e);s.useEffect(()=>{e!==x.current&&(x.current=e,ws(e)!==ws(m.current)&&(a(e),m.current=e,i(e.length>0)))},[e]),s.useEffect(()=>{const w=setTimeout(()=>{l!==m.current&&(m.current=l,g.current(l))},o);return()=>clearTimeout(w)},[l,o]);const y=s.useRef(l);s.useLayoutEffect(()=>{y.current=l}),s.useEffect(()=>()=>{const w=y.current;w!==m.current&&(m.current=w,g.current(w))},[]);const p=s.useCallback(()=>{i(!0),requestAnimationFrame(()=>c.current?.focus())},[]),f=s.useCallback(w=>{w.stopPropagation(),a(""),m.current="",g.current(""),c.current?.focus()},[]),h=s.useCallback(()=>{i(!0)},[]),b=s.useCallback(()=>{setTimeout(()=>{u.current&&document.activeElement&&u.current.contains(document.activeElement)||l||i(!1)},150)},[l]);return s.useEffect(()=>{const w=C=>{u.current&&!u.current.contains(C.target)&&(l||i(!1))};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[l]),d.jsxs("div",{ref:u,className:`ogx-global-search${r?" ogx-global-search--expanded":""}`,onClick:r?void 0:p,children:[d.jsx("div",{className:"ogx-global-search__icon-wrapper",children:d.jsx(_p,{})}),d.jsx(et,{ref:c,inputClassName:"ogx-global-search__input",value:l,onChange:w=>a(w.target.value),onFocus:h,onBlur:b,placeholder:n,"aria-label":"Global Search",autoComplete:"off"}),l&&d.jsx("button",{type:"button",className:"ogx-global-search__clear",onClick:f,"aria-label":"Clear search",children:d.jsx(kp,{})})]})}const Yn=8;function gn({title:e,children:t,placement:n="top",enterDelay:o=200,leaveDelay:r=0}){const[i,l]=s.useState(!1),[a,c]=s.useState({top:0,left:0}),[u,g]=s.useState(null),m=s.useRef(null),x=s.useRef(null),y=s.useId(),p=s.useCallback(()=>{if(!x.current)return;const S=x.current.getBoundingClientRect(),N=S.left+S.width/2,M=S.top+S.height/2;switch(n){case"bottom":c({top:S.bottom+Yn,left:N});break;case"left":c({top:M,left:S.left-Yn});break;case"right":c({top:M,left:S.right+Yn});break;default:c({top:S.top-Yn,left:N})}},[n]),f=s.useCallback(()=>{m.current&&clearTimeout(m.current),m.current=null},[]);s.useLayoutEffect(()=>{if(!i)return;p();const S=N=>{N.key==="Escape"&&(f(),l(!1))};return window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),document.addEventListener("keydown",S),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p),document.removeEventListener("keydown",S)}},[i,p,f]),s.useEffect(()=>f,[f]);const h=()=>{f(),m.current=setTimeout(()=>{g(x.current?.closest(".ogx-theme-provider")??document.body),l(!0)},o)},b=()=>{f(),m.current=setTimeout(()=>{l(!1)},r)},w=s.useCallback(S=>{x.current=S?S.firstElementChild??S:null},[]),C=i&&!!e&&u!==null;let E=t;if(C&&s.isValidElement(t)){const S=t,N=S.props["aria-describedby"];E=s.cloneElement(S,{"aria-describedby":N?`${N} ${y}`:y})}return d.jsxs(d.Fragment,{children:[d.jsx("span",{ref:w,style:{display:"inline-block",lineHeight:0},onMouseEnter:h,onMouseLeave:b,onFocus:h,onBlur:b,children:E}),C&&u&&st.createPortal(d.jsx("div",{id:y,role:"tooltip",className:`ogx-tooltip ogx-tooltip--${n}`,style:{top:a.top,left:a.left,position:"fixed",zIndex:99999},children:e}),u)]})}const Mp=Object.keys(at);function Np(e){return Object.prototype.hasOwnProperty.call(at,e)}function bs(e){return e.availableAggregationFunctions?Array.from(new Set(e.availableAggregationFunctions.filter(Np))):Mp}function xs(){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 Ip(){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 ys(){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 Lp({anchorRef:e,aggregationModel:t,aggregableColumns:n,onFunctionChange:o,onClearAll:r,onClose:i,activeCount:l}){const a=s.useRef(null),[c,u]=s.useState({top:0,right:0}),[g,m]=s.useState(null);s.useLayoutEffect(()=>{m(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const x=s.useCallback(()=>Mn(e.current,Nt()),[e]);s.useEffect(()=>{u(x());const p=()=>u(x());return window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)}},[x]),s.useEffect(()=>{function p(f){a.current&&!a.current.contains(f.target)&&e.current&&!e.current.contains(f.target)&&i()}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[e,i]),s.useEffect(()=>{function p(f){f.key==="Escape"&&i()}return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[i]);const y=d.jsxs("div",{ref:a,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Summaries configuration",style:{top:c.top,right:c.right,left:c.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(xs,{}),"Summaries"]}),l>0&&d.jsx("button",{type:"button",className:"ogx-toolbar__clear-btn",onClick:r,title:"Clear all summaries",children:"Clear all"})]}),d.jsx("div",{className:"ogx-toolbar__panel-body",children:n.length===0?d.jsxs("p",{className:"ogx-toolbar__empty",children:["No aggregable columns.",d.jsx("br",{}),"Set ",d.jsx("code",{children:"aggregable: true"})," on a column to enable."]}):n.map(p=>{const f=t[p.field]||"none";return d.jsxs("div",{className:"ogx-toolbar__agg-row",children:[d.jsx("span",{className:"ogx-toolbar__agg-label",title:p.field,children:p.headerName||p.field}),d.jsx("div",{className:"ogx-toolbar__agg-pills",children:["none",...bs(p)].map(h=>d.jsx("button",{type:"button",className:`ogx-toolbar__pill${f===h?" ogx-toolbar__pill--active":""}`,onClick:()=>o(p.field,h),"aria-pressed":f===h,children:h},h))})]},p.field)})})]});return g?st.createPortal(y,g):null}function Pp({anchorRef:e,columns:t,visibleColumns:n,onVisibilityChange:o,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:a,onClose:c,showNonHideableColumns:u}){const g=s.useRef(null),[m,x]=s.useState({top:0,right:0}),[y,p]=s.useState(null);s.useLayoutEffect(()=>{p(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const f=s.useCallback(()=>Mn(e.current,Nt()),[e]);s.useEffect(()=>{x(f());const b=()=>x(f());return window.addEventListener("scroll",b,!0),window.addEventListener("resize",b),()=>{window.removeEventListener("scroll",b,!0),window.removeEventListener("resize",b)}},[f]),s.useEffect(()=>{function b(w){g.current&&!g.current.contains(w.target)&&e.current&&!e.current.contains(w.target)&&c()}return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[e,c]),s.useEffect(()=>{function b(w){w.key==="Escape"&&c()}return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[c]);const h=d.jsx("div",{ref:g,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Column visibility",style:{top:m.top,right:m.right,left:m.left,width:280,padding:0},children:d.jsx(Qo,{columns:t,visibleColumns:n,onVisibilityChange:o,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:a,showNonHideableColumns:u})});return y?st.createPortal(h,y):null}function Ap({anchorRef:e,columns:t,filterModel:n,onFilterModelChange:o,onClose:r}){const i=s.useRef(null),[l,a]=s.useState({top:0,right:0}),c=s.useRef(r);s.useLayoutEffect(()=>{c.current=r},[r]);const[u,g]=s.useState(null);s.useLayoutEffect(()=>{g(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const m=s.useCallback(()=>Mn(e.current,Nt()),[e]);s.useEffect(()=>{a(m());const f=()=>a(m());return window.addEventListener("scroll",f,!0),window.addEventListener("resize",f),()=>{window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[m]),s.useEffect(()=>{function f(h){h.key==="Escape"&&c.current()}return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[]);const x=n.items?.length??0,y=()=>{o({...n,items:[],logicOperator:"and"})},p=d.jsxs("div",{ref:i,className:"ogx-toolbar__panel ogx-toolbar__panel--filter",role:"dialog","aria-label":"Advanced filters",style:{top:l.top,right:l.right,left:l.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(ys,{}),"Filters",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:y,title:"Clear all filters",children:"Clear all"}),d.jsx("button",{type:"button",className:"ogx-toolbar__close-btn",onClick:()=>c.current(),title:"Close filters","aria-label":"Close filters panel",children:"Close"})]})]}),d.jsx("div",{className:"ogx-toolbar__panel-body ogx-toolbar__panel-body--filter",children:d.jsx(ps,{columns:t,filterModel:n,onFilterModelChange:o})})]});return u?st.createPortal(p,u):null}const Tp={rowFields:[],columnFields:[],valueFields:[]},Fp=[];function Op({columns:e=Fp,baseColumns:t,aggregationModel:n={},onAggregationModelChange:o,pivotModel:r,onPivotModelChange:i,filterModel:l,onFilterModelChange:a,columnVisibilityModel:c={},onColumnVisibilityModelChange:u,onColumnReorder:g,onColumnOrderReset:m,forceColumnsOpen:x,onColumnsPanelClose:y,forceFiltersOpen:p,onFiltersPanelClose:f,children:h,rightContent:b,style:w,renderColumnsButton:C,renderFilterButton:E,renderAggregationButton:S,renderExportButton:N,renderQuickFilter:M,className:_,showNonHideableColumns:F,onAiAssistantToggle:P,aiAssistantOpen:L=!1,aiAssistantLabel:k="Ask AI"}){const[I,A]=s.useState(x?"columns":null),v=I==="summaries",W=I==="pivot",V=I==="columns",Z=I==="filters",H=ie=>{I==="columns"&&ie!=="columns"&&y?.(),I==="filters"&&ie!=="filters"&&f?.(),A(ie)},z=ie=>H(I===ie?null:ie),B=ie=>{I===ie&&H(null)},[re,oe]=s.useState(x);re!==x&&(oe(x),x&&A("columns"));const[ue,se]=s.useState(p);ue!==p&&(se(p),p&&a&&A("filters"));const ce=s.useContext(Pl),R=x!==void 0&&!!u;s.useEffect(()=>{if(!(!ce||!R))return ce.registerColumnsPanel()},[ce,R]);const de=p!==void 0&&!!a;s.useEffect(()=>{if(!(!ce||!de))return ce.registerFiltersPanel()},[ce,de]);const j=s.useRef(null),te=s.useRef(null),q=s.useRef(null),Q=s.useRef(null),ae=s.useRef(null),fe=s.useRef(null),ee=s.useRef(null),D=s.useRef(null),T=r??Tp,$=T.rowFields.length>0||T.columnFields.length>0||T.valueFields.length>0,O=t?new Set(t.map(ie=>ie.field)):null,J=e.filter(ie=>ie.aggregable!==!1&&(ie.type==="number"||ie.aggregable===!0)&&bs(ie).length>0&&(!O||O.has(ie.field))),G=Object.keys(n).filter(ie=>n[ie]&&n[ie]!=="none").length,Y=s.useCallback((ie,xe)=>{if(!o)return;const Ce={...n};xe==="none"?delete Ce[ie]:Ce[ie]=xe,o(Ce)},[n,o]),U=s.useCallback(()=>{o?.({})},[o]),X=s.useCallback(ie=>{if(!a)return;const xe=ie.trim().split(/\s+/).filter(Boolean),Ce={...l||{},quickFilterValues:xe,items:l?.items||[]};a(Ce)},[l,a]),ne=(l?.quickFilterValues??[]).join(" "),he=l?.items?.length||0,me=new Set(e.filter(ie=>c[ie.field]!==!1).map(ie=>ie.field)),K=s.useCallback((ie,xe)=>{if(!u)return;const Ce={...c,[ie]:xe};u(Ce)},[c,u]),ge=s.useCallback(()=>{if(!u)return;const ie={...c};e.forEach(xe=>{xe.hideable!==!1&&(ie[xe.field]=!0)}),u(ie)},[e,c,u]),we=s.useCallback(()=>{if(!u)return;const ie={...c};e.forEach(xe=>{xe.hideable!==!1&&(ie[xe.field]=!1)}),u(ie)},[e,c,u]);return d.jsxs("div",{className:["ogx-toolbar",_].filter(Boolean).join(" "),role:"toolbar","aria-label":"Grid toolbar",style:w,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:[P&&d.jsx("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:d.jsxs("button",{type:"button",ref:te,className:`ogx-toolbar__icon-btn ogx-toolbar__ai-btn${L?" ogx-toolbar__icon-btn--active":""}`,"aria-haspopup":"dialog","aria-expanded":L,onClick:()=>{H(null),P(te.current)},children:[d.jsx(Al,{}),k]})}),a&&d.jsx("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:M?M({value:ne,onChange:X}):d.jsx(Ep,{value:ne,onChange:X,placeholder:"Search..."})}),u&&d.jsxs("div",{ref:fe,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[C?C({onClick:()=>z("columns"),isOpen:V,activeCount:e.length-me.size}):d.jsx(gn,{title:"Columns",children:d.jsx("button",{type:"button",ref:Q,className:`ogx-toolbar__icon-btn${V?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Manage columns","aria-haspopup":"dialog","aria-expanded":V,onClick:()=>z("columns"),children:d.jsx(Ip,{})})}),V&&d.jsx(Pp,{anchorRef:C?fe:Q,columns:e,visibleColumns:me,onVisibilityChange:K,onShowAll:ge,onHideAll:we,onColumnReorder:g,onColumnOrderReset:m,onClose:()=>B("columns"),showNonHideableColumns:F})]}),a&&d.jsxs("div",{ref:ee,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[E?E({onClick:()=>z("filters"),isOpen:Z,activeCount:he}):d.jsx(gn,{title:"Filters",children:d.jsxs("button",{type:"button",ref:ae,className:`ogx-toolbar__icon-btn${Z?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Advanced filters","aria-haspopup":"dialog","aria-expanded":Z,onClick:()=>z("filters"),children:[d.jsx(ys,{}),he>0&&d.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Filters active"})]})}),Z&&d.jsx(Ap,{anchorRef:E?ee:ae,columns:e,filterModel:l||{items:[]},onFilterModelChange:a,onClose:()=>B("filters")})]}),i&&d.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[d.jsx(gn,{title:"Pivot",children:d.jsxs("button",{type:"button",ref:q,className:`ogx-toolbar__icon-btn${W?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure pivot","aria-haspopup":"dialog","aria-expanded":W,onClick:()=>z("pivot"),children:[d.jsx(ms,{}),$&&d.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Pivot active"})]})}),W&&d.jsx(Sp,{anchorRef:q,columns:t??e,model:T,onChange:ie=>{i?.(ie)},onClose:()=>B("pivot")})]}),o&&d.jsxs("div",{ref:D,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[S?S({onClick:()=>z("summaries"),isOpen:v,activeCount:G}):d.jsx(gn,{title:"Summaries",children:d.jsxs("button",{type:"button",ref:j,className:`ogx-toolbar__icon-btn${v?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure summaries","aria-haspopup":"dialog","aria-expanded":v,onClick:()=>z("summaries"),children:[d.jsx(xs,{}),G>0&&d.jsx("span",{className:"ogx-toolbar__dot","aria-label":`${G} active summaries`})]})}),v&&d.jsx(Lp,{anchorRef:S?D:j,aggregationModel:n,aggregableColumns:J,onFunctionChange:Y,onClearAll:U,onClose:()=>B("summaries"),activeCount:G})]}),N&&N(),b]})]})}function Dp(){const[e]=s.useState(zi);return s.useRef(e)}function qt(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 $p=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 Gp(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 Hp(e){let t="",n=!1;for(const o of e){const r=o.codePointAt(0)??0;if(r<=255||$p.has(r)){t+=o;continue}const i=Gp(r);i!==null?t+=i:(t+="?",n=!0)}return{text:t,lossy:n}}const Bp={sliceMs:30,renderChunkRows:40},Wp=2e4;function Cs(){return new Promise(e=>setTimeout(e,0))}function Vp(){return new DOMException("PDF export was aborted","AbortError")}const Xt=()=>typeof performance<"u"?performance.now():Date.now(),vs=e=>Math.max(2,Math.floor(e/2)*2),zp=[79,70,229],Rp=[255,255,255];function Ss(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 _s(e,t){return dn(e,t,cn(e,t))}function ks(e){return(typeof e.width=="number"?e.width:void 0)??(e.flex??1)*100}function Kp(e,t){const n=e.reduce((r,i)=>r+ks(i),0),o={};return e.forEach((r,i)=>{o[i]={cellWidth:ks(r)/n*t}}),o}const Up=new Set(["isEmpty","isNotEmpty"]);function jp(e,t){const o=t.find(l=>l.field===e.field)?.headerName??e.field;if(Up.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 Es(e,t,n,o){const r=e.map(l=>"items"in l?Es(l.items,l.logicOperator,n,!0):jp(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 qp(e,t){const n=[],o=Es(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 Xp=1.15*.3528;function Yp(e,t,n={}){return Jp(e,t,n,Bp)}async function Jp(e,t,n,o){const{signal:r,onProgress:i}=n,l=()=>{if(r?.aborted)throw Vp()};l();let a,c;try{const[U,X]=await Promise.all([import("jspdf"),import("jspdf-autotable")]);a=U.default,c=X.default}catch{throw new Error("exportToPdf requires 'jspdf' and 'jspdf-autotable'. Run: npm install jspdf jspdf-autotable")}const{fileName:u="export",title:g,logoUrl:m,orientation:x="landscape",selectedRows:y,getRowId:p,aggregationResult:f,aggregationModel:h,filterModel:b,alternateRowColor:w=!0,headerBackgroundColor:C="#4f46e5",headerTextColor:E="#ffffff",fontSize:S=9,groupedRows:N,font:M,maxRows:_=Wp}=n;l();let F=Xt();const P=async()=>{Xt()-F<o.sliceMs||(await Cs(),l(),F=Xt())},L=(U,X,ne)=>{i?.({phase:U,done:X,total:ne})},k=new a({orientation:x,unit:"mm",format:"a4"}),I=k.internal.pageSize.getWidth(),A=k.internal.pageSize.getHeight(),v=14,W=I-v*2;let V="helvetica";M&&(k.addFileToVFS(`${M.name}-normal.ttf`,M.data),k.addFont(`${M.name}-normal.ttf`,M.name,"normal"),M.boldData&&k.addFileToVFS(`${M.name}-bold.ttf`,M.boldData),k.addFont(M.boldData?`${M.name}-bold.ttf`:`${M.name}-normal.ttf`,M.name,"bold"),V=M.name);let Z=!1;const H=U=>{if(M)return U;const X=Hp(U);return X.lossy&&(Z=!0),X.text},z=(U,X,ne,he,me)=>{const K=k.splitTextToSize(H(U),he);return k.text(K.length===1?K[0]:K,X,ne),Math.max(0,K.length-1)*me*Xp},B=Mt(t),re=an(N,y),oe=sn(e,y,p);let ue=v;if(g){let U=v,X=v+8;if(m)try{k.addImage(m,"PNG",U,v,10,10),U+=14}catch{}const ne=I-v-U;k.setFontSize(16),k.setFont(V,"bold"),k.setTextColor(30,41,59),X+=z(g,U,X,ne,16),X+=6,k.setFontSize(8),k.setFont(V,"normal"),k.setTextColor(100,116,139);const he=new Date().toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),me=re?N.filter(K=>K.type==="leaf").length:oe.length;if(k.text(H(`Exported: ${he} • ${me} row${me!==1?"s":""}`),U,X),X+=5,b){const K=qp(b,t);K&&(X+=z(`Filters: ${K}`,U,X,ne,8),X+=5)}k.setDrawColor(226,232,240),k.setLineWidth(.3),k.line(v,X+2,I-v,X+2),ue=X+6}const se=[B.map(U=>H(U.headerName??U.field))],ce=h||{},R=U=>B.map(X=>zo(X,ce[X.field],U[X.field],U)),de=[];let j;const te=U=>{de.push(U.map(H))};if(re){const U=N.length;L("prepare",0,U);for(let X=0;X<U;X++){const ne=N[X],he=" ".repeat(ne.depth*2);if(ne.type==="group-header"){const me=`${he}${qt(ne,t)}`;te(B.map((K,ge)=>ge===0?me:""))}else if(ne.type==="leaf"&&ne.row){const me=ne.row;te(B.map((K,ge)=>(ge===0?he:"")+_s(me,K)))}else if(ne.type==="group-subtotal"&&ne.aggregatedValues){const me=R(ne.aggregatedValues);te(me.map((K,ge)=>ge===0?`${he}${Vt("Subtotal",K)}`:K))}else ne.type==="grand-total"&&ne.aggregatedValues&&(j=[R(ne.aggregatedValues).map((K,ge)=>ge===0?Vt("Grand Total",K):K).map(H)]);(X&63)===63&&(L("prepare",X+1,U),await P())}L("prepare",U,U)}else{const U=oe.length;L("prepare",0,U);for(let ne=0;ne<U;ne++)te(B.map(he=>_s(oe[ne],he))),(ne&63)===63&&(L("prepare",ne+1,U),await P());const X=h?Wt(oe,dt(y),t,f,h):null;if(X&&h){const ne=B.some(me=>h[me.field]);j=[R(X).map((me,K)=>K===0&&ne?Vt("TOTAL",me):me).map(H)]}L("prepare",U,U)}l(),de.length>_&&process.env.NODE_ENV!=="production"&&console.warn(`[exportToPdf] Exporting ${de.length} table rows (maxRows: ${_}). 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 q=Kp(B,W),[Q,ae,fe]=Ss(C,zp),[ee,D,T]=Ss(E,Rp),$={head:se,styles:{fontSize:S,cellPadding:3,font:V,overflow:"linebreak"},headStyles:{fillColor:[Q,ae,fe],textColor:[ee,D,T],fontStyle:"bold"},...w?{alternateRowStyles:{fillColor:[248,250,252]}}:{},...j?{footStyles:{fillColor:[241,245,249],fontStyle:"bold",textColor:[0,0,0]}}:{},columnStyles:q,showHead:"everyPage",margin:{top:v,left:v,right:v,bottom:v+6}},O=de.length;L("render",0,O);let J=0,G=vs(o.renderChunkRows);do{const U=de.slice(J,J+G),X=J===0,ne=J+U.length>=O,he=X?ue:k.lastAutoTable.finalY;let me=!0;const K=Xt();c(k,{...$,body:U,...ne&&j?{foot:j}:{},startY:X?ue:v,showFoot:ne&&j?"lastPage":"never",...X?{}:{willDrawPage:we=>{me?(me=!1,we.settings.showHead="never",we.cursor&&(we.cursor.y=he)):we.settings.showHead="everyPage"}}}),J+=U.length,L("render",J,O);const ge=Xt()-K;G=vs(ge>0?Math.min(G*4,G*(o.sliceMs/ge)):G*4),ne||(await Cs(),l(),F=Xt())}while(J<O);const Y=k.getNumberOfPages();for(let U=1;U<=Y;U++)k.setPage(U),k.setFontSize(8),k.setTextColor(150,150,150),k.text(`Page ${U} of ${Y}`,I-v,A-8,{align:"right"}),await P();l(),L("save",0,1),k.save(`${u}.pdf`),L("save",1,1)}function pn(e,t){const n=cn(e,t);return{text:dn(e,t,n),raw:n}}function Yt(e,t,n){return e.map(o=>zo(o,n[o.field],t[o.field],t))}const Zp="\uFEFF";function Qp(e,t,n={}){const{fileName:o="export.csv",includeHeaders:r=!0,delimiter:i=",",selectedRows:l,groupedRows:a,escapeFormulas:c=!0,bom:u=!0}=n,g=Mt(t),m=n.aggregationModel||{},x=(f,h=!1)=>Jn(c?zn(f,h):f,i),y=()=>g.map(f=>x(f.headerName||f.field)).join(i)+`
|
|
8
|
+
`;let p="";if(an(a,l))r&&(p+=y()),a.forEach(f=>{const h=" ".repeat(f.depth);if(f.type==="group-header"){const b=qt(f,t),w=Jn(h+(c?zn(b):b),i);p+=g.map((C,E)=>E===0?w:"").join(i)+`
|
|
9
|
+
`}else if(f.type==="leaf"&&f.row){const b=f.row,w=g.map((C,E)=>{const S=pn(b,C),N=c?zn(S.text,ut(S.raw)):S.text;return Jn((E===0?h:"")+N,i)});p+=w.join(i)+`
|
|
10
|
+
`}else if((f.type==="group-subtotal"||f.type==="grand-total")&&f.aggregatedValues){const b=f.aggregatedValues,w=f.type==="grand-total"?"Grand Total":`${h}Subtotal`,C=Yt(g,b,m),E=g.map((S,N)=>N===0?Jn(Vt(w,C[0]),i):x(C[N],ut(b[S.field])));p+=E.join(i)+`
|
|
11
|
+
`}});else{const f=sn(e,l,n.getRowId);if(f.length===0){console.warn("No rows to export");return}r&&(p+=y()),f.forEach(b=>{const w=g.map(C=>{const E=pn(b,C);return x(E.text,ut(E.raw))});p+=w.join(i)+`
|
|
12
|
+
`});const h=Wt(f,dt(l),t,n.aggregationResult,n.aggregationModel);if(h){const b=g.map(C=>x(m[C.field]?m[C.field].toUpperCase():""));p+=b.join(i)+`
|
|
13
|
+
`;const w=Yt(g,h,m);p+=g.map((C,E)=>x(w[E],ut(h[C.field]))).join(i)+`
|
|
14
|
+
`}}fr((u?Zp:"")+p,o,"text/csv;charset=utf-8;")}function Jn(e,t){return t!==""&&e.includes(t)||e.includes('"')||e.includes(`
|
|
15
|
+
`)||e.includes("\r")?`"${e.replace(/"/g,'""')}"`:e}const Zn="ogx-xls-text";function eh(e,t){return e.type!=="number"&&e.type!=="date"&&e.type!=="boolean"&&!ut(t)}function th(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 nh(e,t,n={}){const{fileName:o="export.xls",sheetName:r="Sheet1",includeHeaders:i=!0,selectedRows:l,groupedRows:a,escapeFormulas:c=!0}=n,u=Mt(t),g=n.aggregationModel||{},m=(h,b=!1)=>Te(c?zn(h,b):h),x=h=>`<td class="${Zn}">${h}</td>`;let p=`<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>${Te(Ro(r))}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--><meta charset="UTF-8"><style>.${Zn}{mso-number-format:"\\@";}</style></head><body><table border="1">`;i&&(p+="<thead><tr>",u.forEach(h=>{p+=`<th class="${Zn}">${m(h.headerName||h.field)}</th>`}),p+="</tr></thead>"),p+="<tbody>";const f=(h,b,w="")=>{const C=w+m(h.text,ut(h.raw));return eh(b,h.raw)?x(C):`<td>${C}</td>`};if(an(a,l))a.forEach(h=>{const b=" ".repeat(h.depth*2);if(h.type==="group-header")p+='<tr style="font-weight:bold;background:#e8eaf6;">',p+=`<td colspan="${u.length}" class="${Zn}">${Te(b)}${m(qt(h,t))}</td>`,p+="</tr>";else if(h.type==="leaf"&&h.row){const w=h.row;p+="<tr>",u.forEach((C,E)=>{p+=f(pn(w,C),C,E===0?Te(b):"")}),p+="</tr>"}else if((h.type==="group-subtotal"||h.type==="grand-total")&&h.aggregatedValues){const w=h.aggregatedValues,C=h.type==="grand-total"?"Grand Total":`${b}Subtotal`,E=Yt(u,w,g);p+='<tr style="font-weight:bold;background:#f5f5f5;">',u.forEach((S,N)=>{if(N===0){p+=x(Te(Vt(C,E[0])));return}p+=E[N]?`<td style="text-align:right;">${m(E[N],ut(w[S.field]))}</td>`:"<td></td>"}),p+="</tr>"}});else{const h=sn(e,l,n.getRowId);if(h.length===0){console.warn("No rows to export");return}h.forEach(w=>{p+="<tr>",u.forEach(C=>{p+=f(pn(w,C),C)}),p+="</tr>"});const b=Wt(h,dt(l),t,n.aggregationResult,n.aggregationModel);if(b){p+='<tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',u.forEach(C=>{p+=g[C.field]?`<td style="text-align:right;font-weight:bold;">${Te(g[C.field].toUpperCase())}</td>`:"<td></td>"}),p+='</tr><tr style="font-weight:bold;background-color:#f5f5f5;">';const w=Yt(u,b,g);u.forEach((C,E)=>{p+=w[E]?`<td style="text-align:right;">${m(w[E],ut(b[C.field]))}</td>`:"<td></td>"}),p+="</tr>"}}p+="</tbody></table></body></html>",fr(p,th(o),"application/vnd.ms-excel")}function oh(e,t,n={}){const{fileName:o="export.json",pretty:r=!0,selectedRows:i,groupedRows:l}=n,a=Mt(t),c=g=>{const m={};return a.forEach(x=>{m[x.field]=cn(g,x)}),m};let u;if(an(l,i)){const g=[],m=[];let x;l.forEach(y=>{if(y.type==="group-header"){const p={group:qt(y,t),field:y.groupField??"",value:y.groupValue,rows:[],children:[]};for(;g.length>y.depth;)g.pop();g.length===0?m.push(p):(g[g.length-1].children??=[]).push(p),g.push(p)}else y.type==="leaf"&&y.row?g.length>0&&g[g.length-1].rows.push(c(y.row)):y.type==="group-subtotal"&&y.aggregatedValues&&g.length>0?(g[g.length-1].subtotals=nl(y.aggregatedValues,a),g.pop()):y.type==="grand-total"&&y.aggregatedValues&&(x=nl(y.aggregatedValues,a))}),u=x?{groups:m,grandTotal:x}:{groups:m}}else{const g=sn(e,i,n.getRowId);if(g.length===0){console.warn("No rows to export");return}const m=g.map(c),x=Wt(g,dt(i),t,n.aggregationResult,n.aggregationModel);if(x){const y=n.aggregationModel||{},p={};a.forEach(h=>{y[h.field]&&(p[h.field]=y[h.field].toUpperCase())});const f={};a.forEach(h=>{x[h.field]!==void 0&&x[h.field]!==null&&(f[h.field]=x[h.field])}),u={data:m,aggregation:{labels:p,values:f}}}else u=m}fr(r?JSON.stringify(u,null,2):JSON.stringify(u),o,"application/json;charset=utf-8;")}const rh=/^(?:https?:|data:image\/|blob:)/i,ih=/^[a-z][a-z\d+.-]*:/i;function lh(e){const t=e.trim();return t?rh.test(t)?t:ih.test(t)?null:t:null}async function sh(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,a=null,c=null,u;typeof n=="string"?r=n:typeof n=="object"&&(r=n.title||"Print",i=n.selectedRows,l=n.getRowId,a=n.aggregationResult||null,c=n.aggregationModel||null,u=n.groupedRows);const g=
|
|
35
|
+
`),o.document.close(),await new Promise(r=>setTimeout(r,100));try{let r="Print",i,l,a=null,c=null,u;typeof n=="string"?r=n:typeof n=="object"&&(r=n.title||"Print",i=n.selectedRows,l=n.getRowId,a=n.aggregationResult||null,c=n.aggregationModel||null,u=n.groupedRows);const g=Mt(t),m=c||{};let x=`<!DOCTYPE html><html><head><title>${Te(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&&(x+=`<h1>${Pe(r)}</h1>`),x+="<table><thead><tr>",g.forEach(f=>{x+=`<th>${Pe(f.headerName||f.field)}</th>`}),x+="</tr></thead><tbody>";const y=(f,m,b="",w=!1)=>{const{text:C}=An(f,m),E=m.type==="image"?vh(C):null;if(E!==null){const S=`<img src="${Pe(E)}" alt="${Pe(m.headerName||m.field)}" style="max-height:40px;border-radius:4px;">`;return w?`<td><div style="display:flex;justify-content:center;">${S}</div></td>`:`<td>${S}</td>`}return`<td>${b}${Pe(C)}</td>`};if(Mn(u,i))u.forEach(f=>{const m=" ".repeat(f.depth*4);if(f.type==="group-header")x+=`<tr class="group-header"><td colspan="${g.length}">${m}${Pe(nn(f,t))}</td></tr>`;else if(f.type==="leaf"&&f.row){const b=f.row;x+="<tr>",g.forEach((w,C)=>{x+=y(b,w,C===0?m:"")}),x+="</tr>"}else if((f.type==="group-subtotal"||f.type==="grand-total")&&f.aggregatedValues){const b=f.type==="grand-total",w=rn(g,f.aggregatedValues,h);x+=`<tr class="${b?"grand-total":"group-subtotal"}">`,g.forEach((C,E)=>{if(E===0){x+=`<td>${b?"":m}${Pe(en(b?"Grand Total":"Subtotal",w[0]))}</td>`;return}x+=w[E]?`<td style="text-align:right;">${Pe(w[E])}</td>`:"<td></td>"}),x+="</tr>"}});else{const f=En(e,i,l);if(f.length===0){o.document.body.innerHTML="<h3>No rows to export</h3>";return}f.forEach(b=>{x+="<tr>",g.forEach(w=>{x+=y(b,w,"",!0)}),x+="</tr>"});const m=Qt(f,_t(i),t,a,c);m&&(x+='<tfoot><tr style="font-size:11px;color:#666;background-color:#f5f5f5;">',g.forEach(b=>{x+=h[b.field]?`<td style="text-align:right;font-weight:bold;">${Pe(h[b.field].toUpperCase())}</td>`:"<td></td>"}),x+='</tr><tr style="font-weight:bold;background-color:#f5f5f5;">',rn(g,m,h).forEach(b=>{x+=b?`<td style="text-align:right;">${Pe(b)}</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 p=!1;o.onload=()=>{p||(p=!0,o.print(),setTimeout(()=>{o.close()},100))},setTimeout(()=>{!p&&o&&!o.closed&&(p=!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>${Pe(i)}</p></div>`}}}function Gr(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 Sh(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 Tn(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 kh=/^(\d{4})-(\d{2})-(\d{2})$/,Eh=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?$/i,Mh=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?$/i;function Nh(e){if(e instanceof Date)return Tn(e);if(typeof e=="number")return Number.isFinite(e)?Tn(new Date(e)):null;if(typeof e!="string")return;const t=e.trim(),n=kh.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(Eh.test(t)){const o=new Date(t.replace(" ","T"));return Number.isNaN(o.getTime())?void 0:Tn(o)}}function Ih(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"&&Mh.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 Nh(t)}function na(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 Tn(e);if(typeof e=="object")try{return JSON.stringify(e)??String(e)}catch{return String(e)}return String(e)}function Lh(e,t){const n=Nn(e,t),o=Sh(t,n);if(o!=="string"){const r=Ih(o,n);if(r!=null)return r;if(!t.valueFormatter)return r===null?null:na(n)}return t.valueFormatter?In(e,t,n):na(n)}const oa="#,##0",Ah="#,##0.##";function Th(e){return Number.isInteger(e)?oa:Ah}function ra(e,t){if(t?.numFmt)return t.numFmt;if(e.type==="date")return"yyyy-mm-dd"}function ia(e,t,n){if(!(t?.numFmt||typeof n!="number"||e.type!=="number"))return Th(n)}function Ph(e,t){if(t!=null)return t;const n=e.width??120;return Math.min(60,Math.max(8,(n-5)/7))}function Fh(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 la(e,t){const n=Nn(e,t);return typeof n=="string"&&n?n:null}async function Oh(e){const t=await Promise.allSettled(e.map(async o=>{let r;if(o.startsWith("data:")){const l=o.slice(o.indexOf(",")+1),a=atob(l);r=new Uint8Array(a.length);for(let c=0;c<a.length;c++)r[c]=a.charCodeAt(c)}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=Fh(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 Dh(e,t,n={}){const{fileName:o="export.xlsx",sheets:r,columnStyles:i={},headerFillColor:l="#f1f5f9",headerTextColor:a="#334155",headerFontSize:c=10,bodyFontSize:u=10,aggregationResult:g=null,aggregationModel:h=null,selectedRows:x,getRowId:y,groupedRows:p,groupHeaderFillColor:f="#e8eaf6",groupSubtotalFillColor:m="#f0f4ff"}=n;let b;try{b=(await import("exceljs")).default}catch{throw new Error("exportToExcelAdvanced requires 'exceljs'. Run: npm install exceljs")}const w=new b.Workbook;w.creator="OpenGridX",w.created=new Date;const C=t,E=Gt(C),S=e,N=_t(x)?Cs(S,x,y):[],M=r??[{name:"Data",rows:"all",includeHeaders:!0,includeSummary:!1}],_=new Set,O=new Map,L=(v,B)=>{const V=B[v.field],Q=h?.[v.field];if(V==null)return{value:null};const H=yi(v,Q,V);return typeof H=="number"?Number.isFinite(H)?xi(Q)?{value:H,numFmt:oa}:{value:H,numFmt:ia(v,i[v.field],H)}:{value:null}:H instanceof Date?{value:Tn(H)}:{value:Lr(v,Q,V,B)}};for(const v of M){if("type"in v&&v.type==="summary"){if(!g||!h)continue;const ee=w.addWorksheet(Ar(v.name??"Summary",_));ee.addRow(["Summary / Aggregation Totals"]),ee.getRow(1).font={bold:!0,size:c+2,color:{argb:je(a)}},ee.addRow([]),ee.addRow(["Column","Function","Value"]).eachCell(T=>{T.fill={type:"pattern",pattern:"solid",fgColor:{argb:je(l)}},T.font={bold:!0,size:c,color:{argb:je(a)}},T.border=sa()}),E.forEach(T=>{const $=h[T.field];if($==null||g[T.field]==null)return;const{value:F,numFmt:Z}=L(T,g),Y=ee.addRow([T.headerName??T.field,$.toUpperCase(),F]).getCell(3),j=Z??ra(T,i[T.field]);j&&(Y.numFmt=j),Y.alignment={horizontal:"right"},Y.font={bold:!0,size:u}}),ee.getColumn(1).width=20,ee.getColumn(2).width=12,ee.getColumn(3).width=18;continue}const B=v,{name:V="Data",rows:Q="all",includeHeaders:H=!0,includeSummary:z=!1,autoFilter:W=!0,frozenHeader:re=!0,alternateRowColor:oe="#f8fafc"}=B,fe=Q==="all"&&!!(p&&p.length>0),le=Q==="selected"?N:fe?p.flatMap(ee=>ee.type==="leaf"&&ee.row?[ee.row]:[]):S,ce=E.filter(ee=>i[ee.field]?.embedImage);if(ce.length>0){const ee=[],D=new Set;if(le.forEach(T=>{ce.forEach($=>{const F=la(T,$);F&&!O.has(F)&&!D.has(F)&&(ee.push(F),D.add(F))})}),ee.length>0){const T=await Oh(ee);for(const[$,{buffer:F,extension:Z}]of T){const G=w.addImage({buffer:F,extension:Z});O.set($,G)}}}const K=w.addWorksheet(Ar(V,_));K.columns=E.map(ee=>({key:ee.field,width:Ph(ee,i[ee.field]?.width),style:{numFmt:ra(ee,i[ee.field])}}));const de=(ee,D)=>{E.forEach((T,$)=>D(ee.getCell($+1),T,$+1))};if(H){const ee=E.map(T=>T.headerName??T.field),D=K.addRow(ee);D.height=20,de(D,(T,$)=>{T.fill={type:"pattern",pattern:"solid",fgColor:{argb:je(l)}},T.font={bold:!0,size:c,color:{argb:je(a)}},T.alignment={horizontal:i[$.field]?.alignment??($.type==="number"?"right":"left"),vertical:"middle"},T.border=sa()}),W&&(K.autoFilter={from:{row:1,column:1},to:{row:1,column:E.length}}),re?K.views=[{state:"frozen",ySplit:1,showGridLines:!1}]:K.views=[{showGridLines:!1}]}let X=H?1:0;const te=(ee,D,T)=>{const $=E.map(G=>i[G.field]?.embedImage?"":Lh(ee,G)),F=K.addRow($);F.font={size:u},T>0&&(F.outlineLevel=T);const Z=!!oe&&D%2===1;if(de(F,(G,Y,j)=>{const q=ia(Y,i[Y.field],$[j-1]);q&&(G.numFmt=q),Z&&oe&&(G.fill={type:"pattern",pattern:"solid",fgColor:{argb:je(oe)}}),G.alignment={horizontal:i[Y.field]?.alignment??(Y.type==="number"?"right":"left"),vertical:"middle"},G.border={bottom:{style:"thin",color:{argb:"FFf1f5f9"}}}}),ce.length>0){const G=ce.reduce((q,ne)=>Math.max(q,i[ne.field]?.imageHeight??40),0),Y=Math.ceil(G/1.333),j=Y*1.333;F.height=Y,ce.forEach(q=>{const ne=E.indexOf(q),he=la(ee,q),me=he?O.get(he):void 0;if(me===void 0){F.getCell(ne+1).value=he??"";return}const R=i[q.field],ge=R?.imageWidth??40,we=R?.imageHeight??40,ye=(K.getColumn(ne+1).width??8)*7+5,xe=Math.max(0,ye-ge)/2,ie=Math.max(0,j-we)/2;K.addImage(me,{tl:{col:ne,row:X,nativeColOff:Math.floor(xe*9525),nativeRowOff:Math.floor(ie*9525)},ext:{width:ge,height:we},editAs:"oneCell"})})}else F.height=16;X++},U=ee=>nn(ee,C),J=(ee,D,T,$,F)=>{const Z=E.map((Y,j)=>j===0&&D[Y.field]==null?{value:ee}:L(Y,D)),G=K.addRow(Z.map(Y=>Y.value));G.height=18,$>0&&(G.outlineLevel=$),G.font={bold:F,italic:!F,size:u,color:{argb:je(a)}},de(G,(Y,j,q)=>{const ne=Z[q-1].numFmt;ne&&(Y.numFmt=ne),Y.fill={type:"pattern",pattern:"solid",fgColor:{argb:je(T)}},Y.alignment={horizontal:q===1?"left":j.type==="number"?"right":"left",vertical:"middle"},Y.border=aa()}),X++};let se=!1;if(fe){let ee=0;p.forEach(D=>{if(D.type==="group-header"){const T=K.addRow([U(D)]);T.height=18,D.depth>0&&(T.outlineLevel=D.depth),T.font={bold:!0,size:u,color:{argb:je(a)}};for(let $=1;$<=E.length;$++)T.getCell($).fill={type:"pattern",pattern:"solid",fgColor:{argb:je(f)}};T.getCell(1).alignment={horizontal:"left",vertical:"middle",indent:D.depth},X++,ee=0}else D.type==="leaf"&&D.row?te(D.row,ee++,D.depth):D.type==="group-subtotal"&&D.aggregatedValues?J("Subtotal",D.aggregatedValues,m,D.depth,!1):D.type==="grand-total"&&D.aggregatedValues&&(J("Grand Total",D.aggregatedValues,l,0,!0),se=!0)}),K.properties.outlineProperties={summaryBelow:!0,summaryRight:!1}}else le.forEach((ee,D)=>te(ee,D,0));const ue=Qt(le,Q==="selected",C,g,h);if(z&&!se&&ue&&h){const ee=E.map(F=>{const Z=h[F.field];return Z?Z.toUpperCase():""}),D=K.addRow(ee);D.height=16,D.font={size:u-1,italic:!0,color:{argb:"FF94a3b8"}},de(D,F=>{F.alignment={horizontal:"right",vertical:"middle"},F.border={top:{style:"thin",color:{argb:"FFcbd5e1"}}}});const T=E.map(F=>h[F.field]==null?{value:null}:L(F,ue)),$=K.addRow(T.map(F=>F.value));$.height=18,$.font={bold:!0,size:u,color:{argb:je(a)}},de($,(F,Z,G)=>{const Y=T[G-1].numFmt;Y&&(F.numFmt=Y),F.fill={type:"pattern",pattern:"solid",fgColor:{argb:je(l)}},F.alignment={horizontal:"right",vertical:"middle"},F.border=aa()})}}const A=await w.xlsx.writeBuffer(),k=new Blob([A],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),I=URL.createObjectURL(k),P=document.createElement("a");P.href=I,P.download=o.endsWith(".xlsx")?o:`${o}.xlsx`,document.body.appendChild(P),P.click(),document.body.removeChild(P),URL.revokeObjectURL(I)}function je(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 sa(){return{bottom:{style:"medium",color:{argb:"FFcbd5e1"}}}}function aa(){return{top:{style:"medium",color:{argb:"FFcbd5e1"}}}}function $h(e,t,n,o){return s.useMemo(()=>o?ji(e,t,n):nr,[e,t,n,o])}const ca={"--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)"},da={"--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",...ca},Gh={...da,"--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",...ca,"--ogx-toolbar-chip-active-text":"var(--ogx-color-primary)","--ogx-overlay-item-selected-text":"var(--ogx-color-primary)"},Hh=[50,100,200,300,400,500,600,700,800,900];function Bh(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 Hh)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-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)}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)}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 Wh({theme:e,children:t,className:n,style:o}){const r=s.useMemo(()=>({...e.mode==="dark"?Gh:da,...Bh(e)}),[e]);return d.jsx(il.Provider,{value:e,children:d.jsx("div",{className:`ogx-theme-provider ${n||""}`.trim(),style:{...o,...r},children:t})})}const Vh={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"}},zh={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"}},Kh={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"}},jh={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"}},Uh={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 Rh(){if(!(typeof window>"u"))try{return window.localStorage}catch{return}}function ua(e,t){try{const n=t.getItem(e);return n?JSON.parse(n):void 0}catch{return}}function qh(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 Xh(e){const t=typeof e=="string"?{key:e}:e,{key:n,debounceMs:o=300,include:r,storage:i}=t,[l]=s.useState(Rh),a=i??l,c=s.useRef(r),u=s.useRef(a);s.useLayoutEffect(()=>{c.current=r,u.current=a});const[g,h]=s.useState(()=>({key:n,state:a?ua(n,a):void 0}));let x=g.state;g.key!==n&&(x=a?ua(n,a):void 0,h({key:n,state:x}));const y=s.useRef(null),p=s.useRef(null),f=s.useCallback(()=>{y.current&&(clearTimeout(y.current),y.current=null);const w=p.current;p.current=null;const C=u.current;w&&C&&qh(w.key,w.state,c.current,C)},[]),m=s.useCallback(w=>{p.current&&p.current.key!==n&&f(),p.current={key:n,state:w},y.current&&clearTimeout(y.current),y.current=setTimeout(f,o)},[n,f,o]);s.useEffect(()=>f,[f]);const b=s.useCallback(()=>{y.current&&(clearTimeout(y.current),y.current=null),p.current=null;const w=u.current;if(w)try{w.removeItem(n)}catch{}},[n]);return s.useMemo(()=>({initialState:x,onStateChange:m,clearState:b}),[x,m,b])}_e.Button=nt,_e.Cell=bs,_e.CellSelectionStats=Is,_e.Checkbox=Ct,_e.ColumnVisibilityPanel=Ir,_e.DataGrid=Tp,_e.DataGridThemeProvider=Wh,_e.FilterPanel=zs,_e.GridToolbar=Jp,_e.GridTooltip=Ln,_e.Header=Hl,_e.Input=et,_e.Pagination=kr,_e.Row=so,_e.Skeleton=Pp,_e.amberTheme=jh,_e.compactTheme=Uh,_e.darkTheme=Vh,_e.emeraldTheme=Kh,_e.exportToCsv=hh,_e.exportToExcel=bh,_e.exportToExcelAdvanced=Dh,_e.exportToJson=xh,_e.exportToPdf=fh,_e.formatAggregationValue=yn,_e.printGrid=_h,_e.roseTheme=zh,_e.useAggregation=hs,_e.useGridApiRef=Zp,_e.useGridStateStorage=Xh,_e.usePivot=$h,Object.defineProperty(_e,Symbol.toStringTag,{value:"Module"})}));
|
|
46
|
+
</style></head><body>`;r&&(x+=`<h1>${Te(r)}</h1>`),x+="<table><thead><tr>",g.forEach(f=>{x+=`<th>${Te(f.headerName||f.field)}</th>`}),x+="</tr></thead><tbody>";const y=(f,h,b="",w=!1)=>{const{text:C}=pn(f,h),E=h.type==="image"?lh(C):null;if(E!==null){const S=`<img src="${Te(E)}" alt="${Te(h.headerName||h.field)}" style="max-height:40px;border-radius:4px;">`;return w?`<td><div style="display:flex;justify-content:center;">${S}</div></td>`:`<td>${S}</td>`}return`<td>${b}${Te(C)}</td>`};if(an(u,i))u.forEach(f=>{const h=" ".repeat(f.depth*4);if(f.type==="group-header")x+=`<tr class="group-header"><td colspan="${g.length}">${h}${Te(qt(f,t))}</td></tr>`;else if(f.type==="leaf"&&f.row){const b=f.row;x+="<tr>",g.forEach((w,C)=>{x+=y(b,w,C===0?h:"")}),x+="</tr>"}else if((f.type==="group-subtotal"||f.type==="grand-total")&&f.aggregatedValues){const b=f.type==="grand-total",w=Yt(g,f.aggregatedValues,m);x+=`<tr class="${b?"grand-total":"group-subtotal"}">`,g.forEach((C,E)=>{if(E===0){x+=`<td>${b?"":h}${Te(Vt(b?"Grand Total":"Subtotal",w[0]))}</td>`;return}x+=w[E]?`<td style="text-align:right;">${Te(w[E])}</td>`:"<td></td>"}),x+="</tr>"}});else{const f=sn(e,i,l);if(f.length===0){o.document.body.innerHTML="<h3>No rows to export</h3>";return}f.forEach(b=>{x+="<tr>",g.forEach(w=>{x+=y(b,w,"",!0)}),x+="</tr>"});const h=Wt(f,dt(i),t,a,c);h&&(x+='<tfoot><tr style="font-size:11px;color:#666;background-color:#f5f5f5;">',g.forEach(b=>{x+=m[b.field]?`<td style="text-align:right;font-weight:bold;">${Te(m[b.field].toUpperCase())}</td>`:"<td></td>"}),x+='</tr><tr style="font-weight:bold;background-color:#f5f5f5;">',Yt(g,h,m).forEach(b=>{x+=b?`<td style="text-align:right;">${Te(b)}</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 p=!1;o.onload=()=>{p||(p=!0,o.print(),setTimeout(()=>{o.close()},100))},setTimeout(()=>{!p&&o&&!o.closed&&(p=!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>${Te(i)}</p></div>`}}}function fr(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 ah(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 hn(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 ch=/^(\d{4})-(\d{2})-(\d{2})$/,dh=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?$/i,uh=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?$/i;function fh(e){if(e instanceof Date)return hn(e);if(typeof e=="number")return Number.isFinite(e)?hn(new Date(e)):null;if(typeof e!="string")return;const t=e.trim(),n=ch.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(dh.test(t)){const o=new Date(t.replace(" ","T"));return Number.isNaN(o.getTime())?void 0:hn(o)}}function gh(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"&&uh.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 fh(t)}function Ms(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 hn(e);if(typeof e=="object")try{return JSON.stringify(e)??String(e)}catch{return String(e)}return String(e)}function ph(e,t){const n=cn(e,t),o=ah(t,n);if(o!=="string"){const r=gh(o,n);if(r!=null)return r;if(!t.valueFormatter)return r===null?null:Ms(n)}return t.valueFormatter?dn(e,t,n):Ms(n)}const Ns="#,##0",hh="#,##0.##";function mh(e){return Number.isInteger(e)?Ns:hh}function Is(e,t){if(t?.numFmt)return t.numFmt;if(e.type==="date")return"yyyy-mm-dd"}function Ls(e,t,n){if(!(t?.numFmt||typeof n!="number"||e.type!=="number"))return mh(n)}function wh(e,t){if(t!=null)return t;const n=e.width??120;return Math.min(60,Math.max(8,(n-5)/7))}function bh(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 Ps(e,t){const n=cn(e,t);return typeof n=="string"&&n?n:null}async function xh(e){const t=await Promise.allSettled(e.map(async o=>{let r;if(o.startsWith("data:")){const l=o.slice(o.indexOf(",")+1),a=atob(l);r=new Uint8Array(a.length);for(let c=0;c<a.length;c++)r[c]=a.charCodeAt(c)}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=bh(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 yh(e,t,n={}){const{fileName:o="export.xlsx",sheets:r,columnStyles:i={},headerFillColor:l="#f1f5f9",headerTextColor:a="#334155",headerFontSize:c=10,bodyFontSize:u=10,aggregationResult:g=null,aggregationModel:m=null,selectedRows:x,getRowId:y,groupedRows:p,groupHeaderFillColor:f="#e8eaf6",groupSubtotalFillColor:h="#f0f4ff"}=n;let b;try{b=(await import("exceljs")).default}catch{throw new Error("exportToExcelAdvanced requires 'exceljs'. Run: npm install exceljs")}const w=new b.Workbook;w.creator="OpenGridX",w.created=new Date;const C=t,E=Mt(C),S=e,N=dt(x)?tl(S,x,y):[],M=r??[{name:"Data",rows:"all",includeHeaders:!0,includeSummary:!1}],_=new Set,F=new Map,P=(v,W)=>{const V=W[v.field],Z=m?.[v.field];if(V==null)return{value:null};const H=Kr(v,Z,V);return typeof H=="number"?Number.isFinite(H)?Rr(Z)?{value:H,numFmt:Ns}:{value:H,numFmt:Ls(v,i[v.field],H)}:{value:null}:H instanceof Date?{value:hn(H)}:{value:zo(v,Z,V,W)}};for(const v of M){if("type"in v&&v.type==="summary"){if(!g||!m)continue;const ee=w.addWorksheet(Ro(v.name??"Summary",_));ee.addRow(["Summary / Aggregation Totals"]),ee.getRow(1).font={bold:!0,size:c+2,color:{argb:Ve(a)}},ee.addRow([]),ee.addRow(["Column","Function","Value"]).eachCell(T=>{T.fill={type:"pattern",pattern:"solid",fgColor:{argb:Ve(l)}},T.font={bold:!0,size:c,color:{argb:Ve(a)}},T.border=As()}),E.forEach(T=>{const $=m[T.field];if($==null||g[T.field]==null)return;const{value:O,numFmt:J}=P(T,g),Y=ee.addRow([T.headerName??T.field,$.toUpperCase(),O]).getCell(3),U=J??Is(T,i[T.field]);U&&(Y.numFmt=U),Y.alignment={horizontal:"right"},Y.font={bold:!0,size:u}}),ee.getColumn(1).width=20,ee.getColumn(2).width=12,ee.getColumn(3).width=18;continue}const W=v,{name:V="Data",rows:Z="all",includeHeaders:H=!0,includeSummary:z=!1,autoFilter:B=!0,frozenHeader:re=!0,alternateRowColor:oe="#f8fafc"}=W,ue=Z==="all"&&!!(p&&p.length>0),se=Z==="selected"?N:ue?p.flatMap(ee=>ee.type==="leaf"&&ee.row?[ee.row]:[]):S,ce=E.filter(ee=>i[ee.field]?.embedImage);if(ce.length>0){const ee=[],D=new Set;if(se.forEach(T=>{ce.forEach($=>{const O=Ps(T,$);O&&!F.has(O)&&!D.has(O)&&(ee.push(O),D.add(O))})}),ee.length>0){const T=await xh(ee);for(const[$,{buffer:O,extension:J}]of T){const G=w.addImage({buffer:O,extension:J});F.set($,G)}}}const R=w.addWorksheet(Ro(V,_));R.columns=E.map(ee=>({key:ee.field,width:wh(ee,i[ee.field]?.width),style:{numFmt:Is(ee,i[ee.field])}}));const de=(ee,D)=>{E.forEach((T,$)=>D(ee.getCell($+1),T,$+1))};if(H){const ee=E.map(T=>T.headerName??T.field),D=R.addRow(ee);D.height=20,de(D,(T,$)=>{T.fill={type:"pattern",pattern:"solid",fgColor:{argb:Ve(l)}},T.font={bold:!0,size:c,color:{argb:Ve(a)}},T.alignment={horizontal:i[$.field]?.alignment??($.type==="number"?"right":"left"),vertical:"middle"},T.border=As()}),B&&(R.autoFilter={from:{row:1,column:1},to:{row:1,column:E.length}}),re?R.views=[{state:"frozen",ySplit:1,showGridLines:!1}]:R.views=[{showGridLines:!1}]}let j=H?1:0;const te=(ee,D,T)=>{const $=E.map(G=>i[G.field]?.embedImage?"":ph(ee,G)),O=R.addRow($);O.font={size:u},T>0&&(O.outlineLevel=T);const J=!!oe&&D%2===1;if(de(O,(G,Y,U)=>{const X=Ls(Y,i[Y.field],$[U-1]);X&&(G.numFmt=X),J&&oe&&(G.fill={type:"pattern",pattern:"solid",fgColor:{argb:Ve(oe)}}),G.alignment={horizontal:i[Y.field]?.alignment??(Y.type==="number"?"right":"left"),vertical:"middle"},G.border={bottom:{style:"thin",color:{argb:"FFf1f5f9"}}}}),ce.length>0){const G=ce.reduce((X,ne)=>Math.max(X,i[ne.field]?.imageHeight??40),0),Y=Math.ceil(G/1.333),U=Y*1.333;O.height=Y,ce.forEach(X=>{const ne=E.indexOf(X),he=Ps(ee,X),me=he?F.get(he):void 0;if(me===void 0){O.getCell(ne+1).value=he??"";return}const K=i[X.field],ge=K?.imageWidth??40,we=K?.imageHeight??40,xe=(R.getColumn(ne+1).width??8)*7+5,Ce=Math.max(0,xe-ge)/2,le=Math.max(0,U-we)/2;R.addImage(me,{tl:{col:ne,row:j,nativeColOff:Math.floor(Ce*9525),nativeRowOff:Math.floor(le*9525)},ext:{width:ge,height:we},editAs:"oneCell"})})}else O.height=16;j++},q=ee=>qt(ee,C),Q=(ee,D,T,$,O)=>{const J=E.map((Y,U)=>U===0&&D[Y.field]==null?{value:ee}:P(Y,D)),G=R.addRow(J.map(Y=>Y.value));G.height=18,$>0&&(G.outlineLevel=$),G.font={bold:O,italic:!O,size:u,color:{argb:Ve(a)}},de(G,(Y,U,X)=>{const ne=J[X-1].numFmt;ne&&(Y.numFmt=ne),Y.fill={type:"pattern",pattern:"solid",fgColor:{argb:Ve(T)}},Y.alignment={horizontal:X===1?"left":U.type==="number"?"right":"left",vertical:"middle"},Y.border=Ts()}),j++};let ae=!1;if(ue){let ee=0;p.forEach(D=>{if(D.type==="group-header"){const T=R.addRow([q(D)]);T.height=18,D.depth>0&&(T.outlineLevel=D.depth),T.font={bold:!0,size:u,color:{argb:Ve(a)}};for(let $=1;$<=E.length;$++)T.getCell($).fill={type:"pattern",pattern:"solid",fgColor:{argb:Ve(f)}};T.getCell(1).alignment={horizontal:"left",vertical:"middle",indent:D.depth},j++,ee=0}else D.type==="leaf"&&D.row?te(D.row,ee++,D.depth):D.type==="group-subtotal"&&D.aggregatedValues?Q("Subtotal",D.aggregatedValues,h,D.depth,!1):D.type==="grand-total"&&D.aggregatedValues&&(Q("Grand Total",D.aggregatedValues,l,0,!0),ae=!0)}),R.properties.outlineProperties={summaryBelow:!0,summaryRight:!1}}else se.forEach((ee,D)=>te(ee,D,0));const fe=Wt(se,Z==="selected",C,g,m);if(z&&!ae&&fe&&m){const ee=E.map(O=>{const J=m[O.field];return J?J.toUpperCase():""}),D=R.addRow(ee);D.height=16,D.font={size:u-1,italic:!0,color:{argb:"FF94a3b8"}},de(D,O=>{O.alignment={horizontal:"right",vertical:"middle"},O.border={top:{style:"thin",color:{argb:"FFcbd5e1"}}}});const T=E.map(O=>m[O.field]==null?{value:null}:P(O,fe)),$=R.addRow(T.map(O=>O.value));$.height=18,$.font={bold:!0,size:u,color:{argb:Ve(a)}},de($,(O,J,G)=>{const Y=T[G-1].numFmt;Y&&(O.numFmt=Y),O.fill={type:"pattern",pattern:"solid",fgColor:{argb:Ve(l)}},O.alignment={horizontal:"right",vertical:"middle"},O.border=Ts()})}}const L=await w.xlsx.writeBuffer(),k=new Blob([L],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),I=URL.createObjectURL(k),A=document.createElement("a");A.href=I,A.download=o.endsWith(".xlsx")?o:`${o}.xlsx`,document.body.appendChild(A),A.click(),document.body.removeChild(A),URL.revokeObjectURL(I)}function Ve(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 As(){return{bottom:{style:"medium",color:{argb:"FFcbd5e1"}}}}function Ts(){return{top:{style:"medium",color:{argb:"FFcbd5e1"}}}}function Ch(e,t,n,o){return s.useMemo(()=>o?mi(e,t,n):Lo,[e,t,n,o])}const Fs={"--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)"},Os={"--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",...Fs},vh={...Os,"--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",...Fs,"--ogx-toolbar-chip-active-text":"var(--ogx-color-primary)","--ogx-overlay-item-selected-text":"var(--ogx-color-primary)"},Sh=[50,100,200,300,400,500,600,700,800,900];function _h(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 Sh)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)}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-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 kh({theme:e,children:t,className:n,style:o}){const r=s.useMemo(()=>({...e.mode==="dark"?vh:Os,..._h(e)}),[e]);return d.jsx(Li.Provider,{value:e,children:d.jsx("div",{className:`ogx-theme-provider ${n||""}`.trim(),style:{...o,...r},children:t})})}const Eh={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"}},Mh={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"}},Nh={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"}},Ih={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"}},Lh={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 Ph(){if(!(typeof window>"u"))try{return window.localStorage}catch{return}}function Ds(e,t){try{const n=t.getItem(e);return n?JSON.parse(n):void 0}catch{return}}function Ah(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 Th(e){const t=typeof e=="string"?{key:e}:e,{key:n,debounceMs:o=300,include:r,storage:i}=t,[l]=s.useState(Ph),a=i??l,c=s.useRef(r),u=s.useRef(a);s.useLayoutEffect(()=>{c.current=r,u.current=a});const[g,m]=s.useState(()=>({key:n,state:a?Ds(n,a):void 0}));let x=g.state;g.key!==n&&(x=a?Ds(n,a):void 0,m({key:n,state:x}));const y=s.useRef(null),p=s.useRef(null),f=s.useCallback(()=>{y.current&&(clearTimeout(y.current),y.current=null);const w=p.current;p.current=null;const C=u.current;w&&C&&Ah(w.key,w.state,c.current,C)},[]),h=s.useCallback(w=>{p.current&&p.current.key!==n&&f(),p.current={key:n,state:w},y.current&&clearTimeout(y.current),y.current=setTimeout(f,o)},[n,f,o]);s.useEffect(()=>f,[f]);const b=s.useCallback(()=>{y.current&&(clearTimeout(y.current),y.current=null),p.current=null;const w=u.current;if(w)try{w.removeItem(n)}catch{}},[n]);return s.useMemo(()=>({initialState:x,onStateChange:h,clearState:b}),[x,h,b])}_e.Button=Qe,_e.Cell=ql,_e.CellSelectionStats=Zl,_e.Checkbox=gt,_e.ColumnVisibilityPanel=Qo,_e.DataGrid=mp,_e.DataGridThemeProvider=kh,_e.FilterPanel=ps,_e.GridToolbar=Op,_e.GridTooltip=gn,_e.Header=Kl,_e.Input=et,_e.Pagination=er,_e.Row=Un,_e.Skeleton=wp,_e.amberTheme=Ih,_e.compactTheme=Lh,_e.darkTheme=Eh,_e.emeraldTheme=Nh,_e.exportToCsv=Qp,_e.exportToExcel=nh,_e.exportToExcelAdvanced=yh,_e.exportToJson=oh,_e.exportToPdf=Yp,_e.formatAggregationValue=nn,_e.printGrid=sh,_e.roseTheme=Mh,_e.useAggregation=Ll,_e.useGridApiRef=Dp,_e.useGridStateStorage=Th,_e.usePivot=Ch,Object.defineProperty(_e,Symbol.toStringTag,{value:"Module"})}));
|
|
47
47
|
//# sourceMappingURL=opengridx.umd.js.map
|