@opencorestack/opengridx 1.0.6 → 1.1.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 +18 -0
- package/dist/index.d.ts +40 -12
- package/dist/opengridx.css +1 -1
- package/dist/opengridx.es.js +3212 -3130
- package/dist/opengridx.es.js.map +1 -1
- package/dist/opengridx.umd.js +12 -12
- package/dist/opengridx.umd.js.map +1 -1
- package/docs/API_REFERENCE.md +35 -0
- package/docs/components/cell.md +14 -0
- package/docs/components/filter-panel.md +13 -0
- package/docs/components/pagination.md +26 -0
- package/docs/components/row.md +26 -0
- package/docs/roadmap.md +8 -0
- package/lib/components/Cell/Cell.tsx +44 -44
- package/lib/components/Cell/CellErrorBoundary.tsx +53 -0
- package/lib/components/ColumnVisibilityPanel/ColumnVisibilityPanel.tsx +0 -2
- package/lib/components/DataGrid/DataGrid.css +47 -0
- package/lib/components/DataGrid/DataGrid.tsx +34 -8
- package/lib/components/DataGrid/GridAggregationFooter.tsx +47 -9
- package/lib/components/DataGrid/GridListView.tsx +4 -0
- package/lib/components/DataGrid/GridPinnedRows.tsx +4 -0
- package/lib/components/DataGrid/GridStandaloneColumnPanel.tsx +3 -1
- package/lib/components/DataGrid/GridVirtualRows.tsx +4 -0
- package/lib/components/FilterPanel/FilterPanel.tsx +5 -4
- package/lib/components/Header/Header.tsx +4 -3
- package/lib/components/Pagination/Pagination.test.tsx +64 -0
- package/lib/components/Pagination/Pagination.tsx +19 -7
- package/lib/components/Row/Row.tsx +9 -5
- package/lib/components/Toolbar/GlobalSearch.tsx +0 -2
- package/lib/components/Toolbar/GridToolbar.tsx +0 -4
- package/lib/hooks/core/useGridColumns.tsx +11 -11
- package/lib/hooks/core/useGridControlledState.test.ts +86 -0
- package/lib/hooks/core/useGridKeyboardNavigation.test.ts +176 -0
- package/lib/hooks/core/useGridRowPipeline.test.ts +117 -0
- package/lib/hooks/useRowGrouping.test.ts +84 -0
- package/lib/hooks/useRowGrouping.ts +38 -13
- package/lib/hooks/useTreeData.ts +22 -2
- package/lib/index.ts +2 -0
- package/lib/types/index.ts +38 -12
- package/package.json +1 -1
package/dist/opengridx.umd.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
(function(re,
|
|
1
|
+
(function(re,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],i):(re=typeof globalThis<"u"?globalThis:re||self,i(re.OpenGridX={},re.React,re.ReactDOM))})(this,(function(re,i,ze){"use strict";var _t={exports:{}},st={};var hn;function Jn(){if(hn)return st;hn=1;var n=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function e(o,l,s){var d=null;if(s!==void 0&&(d=""+s),l.key!==void 0&&(d=""+l.key),"key"in l){s={};for(var a in l)a!=="key"&&(s[a]=l[a])}else s=l;return l=s.ref,{$$typeof:n,type:o,key:d,ref:l!==void 0?l:null,props:s}}return st.Fragment=t,st.jsx=e,st.jsxs=e,st}var at={};var pn;function Qn(){return pn||(pn=1,process.env.NODE_ENV!=="production"&&(function(){function n(y){if(y==null)return null;if(typeof y=="function")return y.$$typeof===v?null:y.displayName||y.name||null;if(typeof y=="string")return y;switch(y){case S:return"Fragment";case j:return"Profiler";case P:return"StrictMode";case x:return"Suspense";case f:return"SuspenseList";case N:return"Activity"}if(typeof y=="object")switch(typeof y.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),y.$$typeof){case C:return"Portal";case E:return y.displayName||"Context";case w:return(y._context.displayName||"Context")+".Consumer";case g:var O=y.render;return y=y.displayName,y||(y=O.displayName||O.name||"",y=y!==""?"ForwardRef("+y+")":"ForwardRef"),y;case k:return O=y.displayName||null,O!==null?O:n(y.type)||"Memo";case M:O=y._payload,y=y._init;try{return n(y(O))}catch{}}return null}function t(y){return""+y}function e(y){try{t(y);var O=!1}catch{O=!0}if(O){O=console;var z=O.error,$=typeof Symbol=="function"&&Symbol.toStringTag&&y[Symbol.toStringTag]||y.constructor.name||"Object";return z.call(O,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",$),t(y)}}function o(y){if(y===S)return"<>";if(typeof y=="object"&&y!==null&&y.$$typeof===M)return"<...>";try{var O=n(y);return O?"<"+O+">":"<...>"}catch{return"<...>"}}function l(){var y=I.A;return y===null?null:y.getOwner()}function s(){return Error("react-stack-top-frame")}function d(y){if(L.call(y,"key")){var O=Object.getOwnPropertyDescriptor(y,"key").get;if(O&&O.isReactWarning)return!1}return y.key!==void 0}function a(y,O){function z(){G||(G=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",O))}z.isReactWarning=!0,Object.defineProperty(y,"key",{get:z,configurable:!0})}function u(){var y=n(this.type);return T[y]||(T[y]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),y=this.props.ref,y!==void 0?y:null}function c(y,O,z,$,H,X){var U=z.ref;return y={$$typeof:_,type:y,key:O,props:z,_owner:$},(U!==void 0?U:null)!==null?Object.defineProperty(y,"ref",{enumerable:!1,get:u}):Object.defineProperty(y,"ref",{enumerable:!1,value:null}),y._store={},Object.defineProperty(y._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(y,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(y,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:H}),Object.defineProperty(y,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:X}),Object.freeze&&(Object.freeze(y.props),Object.freeze(y)),y}function p(y,O,z,$,H,X){var U=O.children;if(U!==void 0)if($)if(W(U)){for($=0;$<U.length;$++)b(U[$]);Object.freeze&&Object.freeze(U)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else b(U);if(L.call(O,"key")){U=n(y);var te=Object.keys(O).filter(function(J){return J!=="key"});$=0<te.length?"{key: someKey, "+te.join(": ..., ")+": ...}":"{key: someKey}",K[U+$]||(te=0<te.length?"{"+te.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,A,K,L,K),V[K+A]=!0)}if(K=null,O!==void 0&&(e(O),K=""+O),d(B)&&(e(B.key),K=""+B.key),"key"in B){O={};for(var te in B)te!=="key"&&(O[te]=B[te])}else O=B;return K&&a(O,typeof k=="function"?k.displayName||k.name||"Unknown":k),c(k,K,O,i(),D,X)}function m(k){p(k)?k._store&&(k._store.validated=1):typeof k=="object"&&k!==null&&k.$$typeof===M&&(k._payload.status==="fulfilled"?p(k._payload.value)&&k._payload.value._store&&(k._payload.value._store.validated=1):k._store&&(k._store.validated=1))}function p(k){return typeof k=="object"&&k!==null&&k.$$typeof===v}var b=l,v=Symbol.for("react.transitional.element"),C=Symbol.for("react.portal"),j=Symbol.for("react.fragment"),I=Symbol.for("react.strict_mode"),h=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),y=Symbol.for("react.context"),w=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),x=Symbol.for("react.suspense_list"),E=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),_=Symbol.for("react.client.reference"),P=b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W=Object.prototype.hasOwnProperty,T=Array.isArray,F=console.createTask?console.createTask:function(){return null};b={react_stack_bottom_frame:function(k){return k()}};var H,R={},G=b.react_stack_bottom_frame.bind(b,s)(),Y=F(o(s)),V={};lt.Fragment=j,lt.jsx=function(k,B,O){var A=1e4>P.recentlyCreatedOwnerStacks++;return f(k,B,O,!1,A?Error("react-stack-top-frame"):G,A?F(o(k)):Y)},lt.jsxs=function(k,B,O){var A=1e4>P.recentlyCreatedOwnerStacks++;return f(k,B,O,!0,A?Error("react-stack-top-frame"):G,A?F(o(k)):Y)}})()),lt}var un;function qn(){return un||(un=1,process.env.NODE_ENV==="production"?pt.exports=Kn():pt.exports=Yn()),pt.exports}var r=qn();function xt(n,t){return t?t.left?.includes(n)?"left":t.right?.includes(n)?"right":null:null}function Xn(n,t){const e=[],o=[],i=[];return t?(n.forEach(s=>{const d=xt(s.field,t);d==="left"?e.push(s):d==="right"?i.push(s):o.push(s)}),t.left&&e.sort((s,d)=>{const a=t.left.indexOf(s.field),u=t.left.indexOf(d.field);return a-u}),t.right&&i.sort((s,d)=>{const a=t.right.indexOf(s.field),u=t.right.indexOf(d.field);return a-u}),{left:e,center:o,right:i}):{left:e,center:n,right:i}}function fn(n,t,e,o,i,s,d,a){const u={};if(!e)return u;const c=Xn(n,e);let f=0;a&&(f+=48),s&&d&&(f+=48),o&&i&&(f+=48),c.left.forEach(p=>{u[p.field]=f;const b=t[p.field]??p.width??100;f+=b});let m=0;return[...c.right].reverse().forEach(p=>{const b=t[p.field]??p.width??100;u[p.field]=m,m+=b}),u}function Ot(n,t){return t?t.top?.includes(n)?"top":t.bottom?.includes(n)?"bottom":null:null}function Jn(n,t){const e=[],o=[],i=[];return t?(n.forEach(s=>{const d=Ot(s.id,t);d==="top"?e.push(s):d==="bottom"?i.push(s):o.push(s)}),t.top&&e.sort((s,d)=>{const a=t.top.indexOf(s.id),u=t.top.indexOf(d.id);return a-u}),t.bottom&&i.sort((s,d)=>{const a=t.bottom.indexOf(s.id),u=t.bottom.indexOf(d.id);return a-u}),{top:e,center:o,bottom:i}):{top:e,center:n,bottom:i}}function Be(n){if(n===void 0)return{type:"auto",value:0};if(typeof n=="number")return{type:"fixed",value:n};if(typeof n=="string"){if(n.toLowerCase()==="auto")return{type:"auto",value:0};if(n.endsWith("%"))return{type:"percentage",value:parseFloat(n)};const t=parseFloat(n);if(!isNaN(t))return{type:"fixed",value:t}}return{type:"fixed",value:100}}function Qn(n){const{rowHeight:t,pagination:e,paginatedUnpinnedRows:o,sortedUnpinnedRows:i,expandedRowIds:s,getDetailPanelHeight:d,pinnedTopRowsLength:a,pinnedBottomRowsLength:u,visibleOrderedColumns:c,pinnedColumns:f,columnWidths:m,viewportWidth:p,checkboxSelection:b,hasDetailPanel:v,rowReordering:C,paginationMode:j,isLoading:I,pageSize:h}=n;return l.useMemo(()=>{const S=e?o:i,y=S.map((z,q)=>{let ne=t;if(s.has(z.id)){const de=d?.({row:z,id:z.id,rowIndex:a+q})??200;ne+=typeof de=="number"?de:parseInt(String(de),10)||200}return ne}),w=y.reduce((z,q,ne)=>(z.push((z[ne-1]||0)+q),z),[]),g=j==="infinite"&&I&&S.length>0?Math.min(h,20):0,x=(w[w.length-1]||0)+g*t,E=a*t,M=u*t,N=[],_=[],P=[],W=[];c.forEach(z=>{const q=xt(z.field,f);q==="left"?N.push(z):q==="right"?_.push(z):P.push(z)});const T=(b?48:0)+(v?48:0)+(C?48:0),F=z=>m[z.field]??z.width,H=N.reduce((z,q)=>{const ne=Be(F(q));return z+(ne.type==="fixed"?ne.value:100)},0),R=_.reduce((z,q)=>{const ne=Be(F(q));return z+(ne.type==="fixed"?ne.value:100)},0),G=P.reduce((z,q)=>{if(!Object.prototype.hasOwnProperty.call(m,q.field)&&q.flex&&q.flex>0){const ue=q.minWidth??150,je=typeof q.width=="number"?q.width:150;return z+(ue||je)}const de=Be(F(q));return de.type==="fixed"?z+de.value:de.type==="percentage"?z+100:z+(q.minWidth??150)},0),Y=Math.max(p-T-H-R,G),V=[],k=[],B=[];P.forEach(z=>{const q=Object.prototype.hasOwnProperty.call(m,z.field),ne=Be(F(z));if(!q&&z.flex&&z.flex>0){B.push({col:z,flex:z.flex});return}ne.type==="fixed"?V.push({col:z,width:ne.value}):ne.type==="percentage"?k.push({col:z,percentage:ne.value}):B.push({col:z,flex:1})});const O=V.reduce((z,{width:q})=>z+q,0);let A=Math.max(0,Y-O);const D=new Map;k.forEach(({col:z,percentage:q})=>{const ne=q/100*A;D.set(z.field,ne),A-=ne}),A=Math.max(0,A);const X=new Map,K=B.map(z=>({...z,minWidth:z.col.minWidth??50,maxWidth:z.col.maxWidth??1/0,frozen:!1,computedWidth:0}));(()=>{let z=0;const q=K.length*2;for(;z<q;){z++;const ne=K.filter(oe=>!oe.frozen);if(ne.length===0)break;const de=ne.reduce((oe,we)=>oe+we.flex,0),ue=K.reduce((oe,we)=>we.frozen?oe+we.computedWidth:oe,0),je=Math.max(0,A-ue);if(de<=0){ne.forEach(oe=>{oe.computedWidth=oe.minWidth,oe.frozen=!0});break}const Ve=je/de;let ge=0;const Ue=[],Ke=[];if(ne.forEach(oe=>{const we=Ve*oe.flex;we<oe.minWidth?(ge+=oe.minWidth-we,Ue.push(oe)):we>oe.maxWidth?(ge+=oe.maxWidth-we,Ke.push(oe)):oe.computedWidth=we}),Ue.length===0&&Ke.length===0){ne.forEach(oe=>oe.frozen=!0);break}ge>0?Ue.forEach(oe=>{oe.computedWidth=oe.minWidth,oe.frozen=!0}):ge<0?Ke.forEach(oe=>{oe.computedWidth=oe.maxWidth,oe.frozen=!0}):(Ue.forEach(oe=>{oe.computedWidth=oe.minWidth,oe.frozen=!0}),Ke.forEach(oe=>{oe.computedWidth=oe.maxWidth,oe.frozen=!0}))}})(),K.forEach(z=>X.set(z.col.field,z.computedWidth));const te=new Map;P.forEach(z=>{let q;if(X.has(z.field))q=X.get(z.field);else{const ne=V.find(ue=>ue.col.field===z.field),de=k.find(ue=>ue.col.field===z.field);if(ne)q=ne.width;else if(de){const ue=D.get(z.field)||0;q=Math.max(z.minWidth??50,ue||100)}else q=100}W.push(q),te.set(z.field,q)});const ee=P.map(z=>{const q=K.find(ne=>ne.col.field===z.field);return{...z,width:te.get(z.field)??(typeof z.width=="number"?z.width:100),flex:q?q.flex:z.flex}}),Q=11,ce=N.map((z,q)=>{const ne=Be(F(z));return{...z,width:ne.type==="fixed"?ne.value:100,zIndex:Q+q}}),$=11,ae=_.map((z,q)=>{const ne=Be(F(z));return{...z,width:ne.type==="fixed"?ne.value:100,zIndex:$+(_.length-1-q)}}),J=W.reduce((z,q)=>z+q,0),se=H+J+R+T,ie=W.reduce((z,q,ne)=>(z.push((z[ne-1]||0)+q),z),[]);return{rowHeights:y,cumulativeHeights:w,unpinnedRowsHeight:x,pinnedTopHeight:E,pinnedBottomHeight:M,leftPinnedCols:ce,rightPinnedCols:ae,unpinnedColsWithWidth:ee,unpinnedColWidths:W,unpinnedAccWidths:ie,totalWidth:se,leftWidth:H,rightWidth:R,unpinnedTotalWidth:J,systemColumnsWidth:T,pinnedTopRowsLength:a,pinnedBottomRowsLength:u,unpinnedRowsLength:S.length}},[t,e,o,i,s,d,a,u,c,f,m,p,b,v,C,j,I,h])}function Zn(n){const{allRenderableRows:t,navigationColumns:e,checkboxSelection:o,selectedRowIds:i,handleSelectionChange:s,handleDetailPanelToggle:d,editingHandlers:a,setKeyboardMode:u,sortModel:c,handleSort:f,isCellEditable:m,pagination:p,pageSize:b,virtualization:v,viewportRef:C}=n,[j,I]=l.useState(null),h=l.useCallback(w=>{w.target===w.currentTarget&&I(g=>{if(g)return g;if(o)return{id:"HEADER",field:"__checkbox_col__"};const x=t[0],E=e[0];return x&&E?{id:x.id,field:E.field}:null})},[t,e,o]),S=l.useCallback(w=>{w.currentTarget.contains(w.relatedTarget)||I(null)},[]),y=l.useCallback(w=>{if(u(!0),!j)return;const{id:g,field:x}=j,E=!!a.editingCell;if(g==="HEADER"&&(w.key==="Enter"||w.key===" ")){w.preventDefault();const R=e.find(G=>G.field===x);if(R&&R.sortable!==!1){const G=c.find(V=>V.field===x);let Y="asc";G&&(Y=G.sort==="asc"?"desc":null),f(x,Y)}return}if(w.key==="Enter"){if(w.preventDefault(),E)a.stopCellEdit();else if(e.find(G=>G.field===x)?.editable){const G=t.find(Y=>Y.id===g);G&&a.startCellEdit({id:g,field:x,value:G[x]})}return}if((w.key===" "||w.key==="Spacebar")&&!E){if(x==="__checkbox_col__"){w.preventDefault(),s(g,!i.has(g));return}if(x==="__expand_col__"){w.preventDefault(),d(g);return}}if(w.key==="Escape"){E&&(w.preventDefault(),a.stopCellEdit({cancel:!0}));return}if(E&&w.key!=="Tab")return;const M=g==="HEADER",N=M?-1:t.findIndex(R=>R.id===g),_=e.findIndex(R=>R.field===x);if(!M&&N===-1||_===-1)return;const P=(R,G,Y,V,k,B=!1)=>{let O=R+Y,A=G+V;return k&&V!==0&&(V>0&&A>=e.length?(A=0,O++):V<0&&A<0&&(A=e.length-1,O--)),!k&&(A<0||A>=e.length)||O<(B?-1:0)||O>=t.length?null:{r:O,c:A}},W=(R,G,Y,V,k,B=!1)=>{let O=R,A=G,D=0;const X=t.length*e.length+e.length;for(;D<X;){if(D++,O+=Y,A+=V,V!==0)V>0?A>=e.length&&(A=0,O++):A<0&&(A=e.length-1,O--);else if(A<0||A>=e.length)return null;if(O<-1||O>=t.length)return null;if(O===-1){if(!B)continue;const Q=e[A],ce=Q.sortable!==!1;if(["__checkbox_col__"].includes(Q.field)||ce)return{r:O,c:A};continue}const K=t[O],L=e[A],te=["__checkbox_col__","__expand_col__","__reorder_col__"].includes(L.field);let ee=L.editable||te;if(m&&!te)try{ee=m({row:K,field:L.field,value:K[L.field],colDef:L,rowIndex:O,colIndex:A})}catch{}if(ee)return{r:O,c:A}}return null};let T=N,F=_,H=!1;if(w.key==="Tab"){const R=w.shiftKey?-1:1,G=W(N,_,0,R,!0,!1);G&&(T=G.r,F=G.c,H=!0)}else if(w.key==="ArrowRight"){const R=P(N,_,0,1,!0,!0);R&&(T=R.r,F=R.c,H=!0)}else if(w.key==="ArrowLeft"){const R=P(N,_,0,-1,!0,!0);R&&(T=R.r,F=R.c,H=!0)}else if(w.key==="ArrowDown"){const R=P(N,_,1,0,!1,!0);R&&(T=R.r,F=R.c,H=!0)}else if(w.key==="ArrowUp"){const R=P(N,_,-1,0,!1,!0);R&&(T=R.r,F=R.c,H=!0)}else if(w.key==="Home")F=0,(w.ctrlKey||w.metaKey)&&(T=-1),H=!0;else if(w.key==="End")F=e.length-1,(w.ctrlKey||w.metaKey)&&(T=t.length-1),H=!0;else if(w.key==="PageUp")T=Math.max(-1,T-(p?b:10)),H=!0;else if(w.key==="PageDown"){const R=p?b:10;T=Math.min(t.length-1,T+R),H=!0}if(H&&(w.preventDefault(),E&&w.key==="Tab"&&a.stopCellEdit(),T>=-1&&T<t.length&&F>=0&&F<e.length)){const R=e[F];I(T===-1?{id:"HEADER",field:R.field}:{id:t[T].id,field:R.field});const G=C.current;if(G){const{cumulativeHeights:Y,pinnedTopHeight:V,columnMetrics:k}=v,{clientHeight:B,clientWidth:O,scrollTop:A,scrollLeft:D}=G,X=T<=0?0:Y[T-1],K=Y[T],L=A+V,te=A+B;let ee=A;if(X<L?ee=Math.max(0,X-V):K>te&&(ee=K-B),ee!==A&&(G.scrollTop=ee),k){const{leftPinnedWidth:Q,rightPinnedWidth:ce,unpinnedAccWidths:$,unpinnedCols:ae,totalSpecialsWidth:J,pinnedSpecialsWidth:se}=k,ie=ae.findIndex(z=>z.field===R.field);if(ie!==-1){const z=J+Q+(ie>0?$[ie-1]:0),q=J+Q+$[ie],ne=D+se+Q,de=D+O-ce;let ue=D;z<ne?ue=Math.max(0,z-se-Q):q>de&&(ue=q-O+ce),ue!==D&&(G.scrollLeft=ue)}}}}},[j,t,e,a,v,i,s,d,u,c,f,m,p,b,C]);return{focusedCell:j,setFocusedCell:I,handleFocus:h,handleBlur:S,handleKeyDown:y}}const eo={rowFields:[],columnFields:[],valueFields:[]};function to(n){const{initialState:t,sortModel:e,aggregationModel:o,onAggregationModelChange:i,columnVisibilityModel:s,onColumnVisibilityModelChange:d,pinnedColumns:a,onPinnedColumnsChange:u,pivotModel:c,onPivotModelChange:f,paginationModel:m={page:0,pageSize:100},onPaginationModelChange:p,rowSelectionModel:b}=n,[v,C]=l.useState(()=>t?.sorting?.sortModel??[]),j=e!==void 0,I=j?e:v,h=o!==void 0,[S,y]=l.useState(()=>o??{}),w=h?o:S,g=l.useCallback(Q=>{h||y(Q),i?.(Q)},[h,i]),x=s!==void 0,[E,M]=l.useState(()=>t?.columns?.columnVisibilityModel??{}),N=x?s:E,_=l.useCallback(Q=>{x||M(Q),d?.(Q)},[x,d]),P=a!==void 0,[W,T]=l.useState(()=>t?.columns?.pinnedColumns??{}),F=P?a:W,H=l.useCallback(Q=>{P||T(Q),u?.(Q)},[P,u]),[R,G]=l.useState(()=>c??eo),Y=c??R,V=l.useCallback(Q=>{G(Q),f?.(Q)},[f]),k=m!==void 0&&n.paginationModel!==void 0,[B,O]=l.useState(()=>t?.pagination?.paginationModel??m),A=k?m:B,D=l.useCallback(Q=>{k||O(Q),p?.(Q)},[k,p]),X=b!==void 0,[K,L]=l.useState([]),te=X?b:K,ee=l.useMemo(()=>new Set(te),[te]);return{sortModel:I,isSortControlled:j,setInternalSortModel:C,aggregationModel:w,handleAggregationModelChange:g,columnVisibilityModel:N,handleColumnVisibilityModelChange:_,pinnedColumns:F,handlePinnedColumnsChange:H,currentPivotModel:Y,handlePivotModelChange:V,effectivePaginationModel:A,handlePaginationModelChange:D,rowSelectionModel:te,selectedRowIds:ee,isSelectionControlled:X,setInternalRowSelectionModel:L}}const no={contains:(n,t)=>n==null||t==null?!1:String(n).toLowerCase().includes(String(t).toLowerCase()),equals:(n,t)=>n==null&&t==null?!0:n==null||t==null?!1:String(n).toLowerCase()===String(t).toLowerCase(),startsWith:(n,t)=>n==null||t==null?!1:String(n).toLowerCase().startsWith(String(t).toLowerCase()),endsWith:(n,t)=>n==null||t==null?!1:String(n).toLowerCase().endsWith(String(t).toLowerCase()),isEmpty:n=>n==null||String(n).trim()==="",isNotEmpty:n=>n!=null&&String(n).trim()!=="",">":(n,t)=>{if(n==null||t==null)return!1;const e=Number(n),o=Number(t);return isNaN(e)||isNaN(o)?!1:e>o},">=":(n,t)=>{if(n==null||t==null)return!1;const e=Number(n),o=Number(t);return isNaN(e)||isNaN(o)?!1:e>=o},"<":(n,t)=>{if(n==null||t==null)return!1;const e=Number(n),o=Number(t);return isNaN(e)||isNaN(o)?!1:e<o},"<=":(n,t)=>{if(n==null||t==null)return!1;const e=Number(n),o=Number(t);return isNaN(e)||isNaN(o)?!1:e<=o},"!=":(n,t)=>{if(t==null||t==="")return!0;const e=Number(n),o=Number(t);return!isNaN(e)&&!isNaN(o)?e!==o:String(n).toLowerCase()!==String(t).toLowerCase()},isAnyOf:(n,t)=>n==null||!Array.isArray(t)?!1:t.some(e=>String(n).toLowerCase()===String(e).toLowerCase()),not:(n,t)=>n==null&&t==null?!1:n==null||t==null?!0:String(n).toLowerCase()!==String(t).toLowerCase(),is:(n,t)=>{if(t==null||t==="")return!0;const e=String(n).toLowerCase(),o=String(t).toLowerCase();return e===o},"=":(n,t)=>n==null||t==null||t===""?!1:Number(n)===Number(t)};function oo(n,t){const{field:e,operator:o,value:i}=t,s=n[e],d=no[o];return d?d(s,i):(console.warn(`Unknown filter operator: ${o}`),!0)}function ro(n,t){return!t||t.length===0?!0:t.every(e=>{const o=e.toLowerCase();return Object.values(n).some(i=>i==null?!1:String(i).toLowerCase().includes(o))})}function Ft(n,t){const e=t.items??[],o=t.logicOperator??"and",i=("quickFilterValues"in t?t.quickFilterValues:void 0)??[];if(i.length>0&&!ro(n,i))return!1;if(e.length===0)return!0;const s=d=>{if("logicOperator"in d&&"items"in d){const a=d,u=a.items;return u.length===0?!0:a.logicOperator==="and"?u.every(s):u.some(s)}else return oo(n,d)};return o==="and"?e.every(s):e.some(s)}function io(n,t){if(!t)return n;const{items:e=[],quickFilterValues:o=[]}=t;return e.length===0&&(!o||o.length===0)?n:n.filter(i=>Ft(i,t))}function lo(n){switch(n){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 At(n,t,e){if(n==null&&t==null)return 0;if(n==null)return e==="asc"?1:-1;if(t==null)return e==="asc"?-1:1;if(typeof n=="number"&&typeof t=="number")return e==="asc"?n-t:t-n;if(n instanceof Date&&t instanceof Date)return e==="asc"?n.getTime()-t.getTime():t.getTime()-n.getTime();const o=String(n).toLowerCase(),i=String(t).toLowerCase();return e==="asc"?o<i?-1:o>i?1:0:o>i?-1:o<i?1:0}function so(n,t){if(t.length===0)return n;const e=[...n];return e.sort((o,i)=>{for(const s of t){const d=o[s.field],a=i[s.field],u=At(d,a,s.sort);if(u!==0)return u}return 0}),e}function ao(n){const{effectiveRows:t,activeHierarchyHandlers:e,filterMode:o,filterModel:i,dataSource:s,sortModel:d,sortingMode:a,pagination:u,paginationMode:c,effectivePaginationModel:f,pinnedRows:m,isLoading:p,pageSize:b}=n,v=l.useMemo(()=>e?e.getVisibleRows()||[]:o==="server"&&s?t:io(t,i),[t,i,e,o,s]),{top:C,center:j,bottom:I}=l.useMemo(()=>e?{top:[],center:v,bottom:[]}:Jn(v,m),[v,m,e]),h=l.useMemo(()=>e||a==="server"&&s?j:so(j,d),[j,d,e,a,s]),S=l.useMemo(()=>{if(!u||c==="server"&&s)return h;const w=f.page*f.pageSize;return h.slice(w,w+f.pageSize)},[h,u,f.page,f.pageSize,c,s]),y=l.useMemo(()=>{if(e)return j;const w=u?S:h,g=[...C,...w,...I];if(c==="infinite"&&p&&g.length>0){const x=Math.min(b,20),E=Array.from({length:x},(M,N)=>({id:`__skeleton_${N}__`,_isSkeleton:!0}));return[...g,...E]}return g},[C,S,h,I,u,e,j,c,p,b]);return{filteredRows:v,pinnedTopRows:C,unpinnedRows:j,pinnedBottomRows:I,sortedUnpinnedRows:h,paginatedUnpinnedRows:S,allRenderableRows:y}}function co(n){const{layout:t,scrollTop:e,scrollLeft:o,viewportWidth:i,viewportHeight:s,autoHeight:d,rowReordering:a,hasDetailPanel:u,checkboxSelection:c,pinCheckboxColumn:f,pinExpandColumn:m}=n;return l.useMemo(()=>{const{unpinnedAccWidths:p,unpinnedColsWithWidth:b,leftPinnedCols:v,rightPinnedCols:C,totalWidth:j,leftWidth:I,rightWidth:h,unpinnedTotalWidth:S,systemColumnsWidth:y,cumulativeHeights:w,pinnedTopHeight:g,pinnedBottomHeight:x,unpinnedRowsHeight:E,rowHeights:M,unpinnedRowsLength:N}=t,_=i||1e3,P=d?g+E+x+50:s||600,W=6,T=Math.max(0,o-I),F=o+_-I;let H=0,R=b.length-1,G=0,Y=p.length-1;for(;G<=Y;){const $=G+Y>>>1;p[$]<T?G=$+1:Y=$-1}H=Math.max(0,G-W);for(let $=H;$<p.length;$++){if(($===0?0:p[$-1])>F){R=Math.min(b.length-1,$+W);break}R=Math.min(b.length-1,$+W)}const V=H>0?p[H-1]:0,k=S-p[R],B=[...v,...V>0?[{field:"__spacer_left__",width:V,isSpacer:!0}]:[],...b.slice(H,R+1),...k>0?[{field:"__spacer_right__",width:k,isSpacer:!0}]:[],...C],A=_>0&&j>_?16:0,D=g+E+x+A+2,X=5;let K=0,L=N-1,te=0,ee=0,Q=w.length-1;for(;ee<=Q;){const $=ee+Q>>>1;w[$]<e?ee=$+1:Q=$-1}K=Math.max(0,ee-X),te=K>0?w[K-1]:0;for(let $=K;$<w.length;$++)if(w[$]>=e+P){L=Math.min(N-1,$+X);break}const ce=(a?48:0)+(u&&m?48:0)+(c&&f?48:0);return{renderContext:{firstRowIndex:K,lastRowIndex:L,firstColumnIndex:H,lastColumnIndex:R},offsetTop:te,offsetLeft:0,totalHeight:D,pinnedTopHeight:g,pinnedBottomHeight:x,totalWidth:j,rowHeights:M,cumulativeHeights:w,virtualColumns:B,columnMetrics:{leftPinnedWidth:I,rightPinnedWidth:h,unpinnedAccWidths:p,unpinnedCols:b,totalSpecialsWidth:y,pinnedSpecialsWidth:ce}}},[t,e,o,i,s,d,a,u,c,f,m])}function uo(n){const{columns:t,onColumnOrderChange:e,disableColumnReorder:o=!1}=n,[i,s]=l.useState(null),[d,a]=l.useState(null),u=l.useRef(-1),c=l.useCallback(b=>v=>{if(o)return;const C=t.findIndex(I=>I.field===b);if(t[C]?.pinnable===!1){v.preventDefault();return}s(b),u.current=C,v.dataTransfer&&(v.dataTransfer.effectAllowed="move",v.dataTransfer.setData("text/plain",b))},[t,o]),f=l.useCallback(b=>v=>{o||!i||(v.preventDefault(),v.dataTransfer.dropEffect="move",a(b))},[i,o]),m=l.useCallback(b=>v=>{if(v.preventDefault(),o||!i||i===b){s(null),a(null);return}const C=t.findIndex(h=>h.field===i),j=t.findIndex(h=>h.field===b);if(C===-1||j===-1){s(null),a(null);return}const I=t[C];e&&e({column:I,oldIndex:C,targetIndex:j}),s(null),a(null),u.current=-1},[t,i,o,e]),p=l.useCallback(()=>{s(null),a(null),u.current=-1},[]);return{draggedColumn:i,dragOverColumn:d,onDragStart:o?void 0:c,onDragOver:o?void 0:f,onDragEnd:o?void 0:p,onDrop:o?void 0:m}}function gn({isExpanded:n,onClick:t,variant:e="chevron"}){return r.jsx("button",{className:`ogx-expand-icon ${n?"ogx-expand-icon--expanded":""}`,onClick:o=>{t&&t(o)},"aria-label":n?"Collapse row":"Expand row",type:"button",children:e==="plus-minus"?r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r.jsx("path",{d:"M4 8H12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M8 4V12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:n?0:1,transition:"opacity 0.2s ease",transformOrigin:"center"}})]}):r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{transform:n?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.2s ease"},children:r.jsx("path",{d:"M6 4L10 8L6 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}function fo(n){const{activeColumns:t,isHierarchyEnabled:e,isRowGrouping:o,isTreeData:i,activeHierarchyHandlers:s,columnVisibilityModel:d,columnOrder:a,onColumnOrderChange:u,disableColumnReorder:c,pivotMode:f,checkboxSelection:m,hasDetailPanel:p,rowReordering:b,initialState:v,setColumns:C}=n,j=l.useMemo(()=>e?t.map((_,P)=>P===0?{..._,renderCell:W=>{const T=W.row,F=typeof T._treeDepth=="number"?T._treeDepth:0,H=!!T._hasChildren,R=!!T._isExpanded,G=typeof T._groupingField=="string"?T._groupingField:void 0,Y=T._groupingValue,V=typeof T._descendantCount=="number"?T._descendantCount:void 0,k=!!T._isGroupRow;let B=_.renderCell?_.renderCell(W):W.value;return i&&H&&k&&(B=r.jsxs("div",{className:"ogx__group-cell-content",children:[W.value,V!==void 0&&V>0?` (${V})`:""]})),o&&H&&G&&(B=r.jsxs("div",{className:"ogx__group-cell-content",children:[_.field===G?"":`${G}: `,String(Y),V!==void 0?` (${V})`:""]})),r.jsxs("div",{style:{display:"flex",alignItems:"center",paddingLeft:F*24,width:"100%",height:"100%"},children:[r.jsx("div",{style:{marginRight:4,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",cursor:H?"pointer":"default",flexShrink:0},children:H?r.jsx("div",{onClick:O=>{O.stopPropagation(),O.preventDefault(),s?.toggleExpansion(W.row.id)},onMouseDown:O=>{O.stopPropagation()},style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:10,position:"relative"},children:r.jsx(gn,{isExpanded:R,onClick:O=>{O.stopPropagation(),O.preventDefault(),s?.toggleExpansion(W.row.id)}})}):null}),r.jsx("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:B})]})}}:{..._,renderCell:W=>{const T=W.row,F=!!T._hasChildren,H=typeof T._groupingField=="string"?T._groupingField:void 0;return o&&F?_.field===H?null:W.value!==void 0&&W.value!==null?_.renderCell?_.renderCell(W):W.value:null:_.renderCell?_.renderCell(W):W.value}}):t,[t,e,o,i,s]),[I,h]=l.useState(()=>v?.columns?.columnWidths??{}),S=l.useCallback((_,P)=>{h(W=>({...W,[_]:P}))},[]),[y,w]=l.useState(()=>v?.columns?.columnOrder??t.map(_=>_.field)),g=a??y;l.useEffect(()=>{C(t)},[t,C]),l.useEffect(()=>{f&&w(t.map(_=>_.field))},[f,t]);const x=l.useMemo(()=>{if(c)return j;const _=new Map(g.map((P,W)=>[P,W]));return[...j].sort((P,W)=>{const T=_.get(P.field)??j.indexOf(P),F=_.get(W.field)??j.indexOf(W);return T-F})},[j,g,c]),E=l.useMemo(()=>x.filter(_=>d[_.field]!==!1),[x,d]),M=uo({columns:x,onColumnOrderChange:l.useCallback(_=>{const{oldIndex:P,targetIndex:W}=_,T=[...g],[F]=T.splice(P,1);T.splice(W,0,F),a||w(T),u?.(_)},[g,a,u]),disableColumnReorder:c}),N=l.useMemo(()=>{const _=[];return b&&_.push({field:"__reorder_col__"}),p&&_.push({field:"__expand_col__"}),m&&_.push({field:"__checkbox_col__"}),[..._,...x]},[x,m,p,b]);return{effectiveColumns:j,orderedColumns:x,visibleOrderedColumns:E,navigationColumns:N,columnWidths:I,effectiveColumnOrder:g,setInternalColumnOrder:w,columnReorderHandlers:M,handleColumnResize:S}}function go(n){const{renderContext:t,pinnedTopRows:e,pinnedBottomRows:o,paginatedUnpinnedRows:i,sortedUnpinnedRows:s,pagination:d}=n;return l.useMemo(()=>{const{firstRowIndex:a,lastRowIndex:u}=t,c=d?i:s,f=e.length,m=e.map((h,S)=>({row:h,rowIndex:S})),p=o.map((h,S)=>({row:h,rowIndex:f+c.length+S})),b=Math.max(0,a-f),v=Math.min(c.length,u-f+1),C=c.slice(b,v).map((h,S)=>({row:h,rowIndex:f+b+S})),j=[...m,...C,...p],I=new Set;return j.filter(h=>I.has(h.row.id)?!1:(I.add(h.row.id),!0))},[t,e,o,i,s,d])}function ho(n){const{onRowsScrollEnd:t}=n,e=l.useRef({scrollTop:0,scrollLeft:0}),o=l.useRef(null),[i,s]=l.useState({scrollTop:0,scrollLeft:0});l.useEffect(()=>()=>{o.current!==null&&cancelAnimationFrame(o.current)},[]);const d=l.useCallback(a=>{const u=a.currentTarget;if(e.current={scrollTop:u.scrollTop,scrollLeft:u.scrollLeft},o.current!==null&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{o.current=null,s(e.current)}),t){const{scrollTop:c,scrollHeight:f,clientHeight:m}=u;f-c-m<100&&t({visibleTop:c,visibleBottom:c+m,viewportHeight:m})}},[t]);return{scrollTop:i.scrollTop,scrollLeft:i.scrollLeft,handleScroll:d}}function po(n){const{onStateChange:t,sortModel:e,filterModel:o,effectivePaginationModel:i,columnWidths:s,effectiveColumnOrder:d,columnVisibilityModel:a,pinnedColumns:u}=n,c=l.useRef(t);l.useLayoutEffect(()=>{c.current=t}),l.useEffect(()=>{if(!c.current)return;const f={sorting:{sortModel:e},filter:{filterModel:o},pagination:{paginationModel:i},columns:{columnWidths:s,columnOrder:d,columnVisibilityModel:a,pinnedColumns:u}};c.current(f)},[e,o,i,s,d,a,u])}const xo={sum:n=>n.filter(e=>e!=null&&!isNaN(Number(e))).reduce((e,o)=>e+Number(o),0),avg:n=>{const t=n.filter(e=>e!=null&&!isNaN(Number(e)));return t.length===0?null:t.reduce((e,o)=>e+Number(o),0)/t.length},count:n=>n.filter(t=>t!=null).length,min:n=>{const t=n.filter(e=>e!=null&&!isNaN(Number(e))).map(Number);return t.length?Math.min(...t):null},max:n=>{const t=n.filter(e=>e!=null&&!isNaN(Number(e))).map(Number);return t.length?Math.max(...t):null},unique:n=>new Set(n.filter(t=>t!=null)).size};function Ie(n,t){return n==null?"—":typeof n=="number"?t==="avg"?n.toLocaleString(void 0,{maximumFractionDigits:2}):n.toLocaleString():String(n)}function hn(n){const{rows:t,aggregationModel:e,isServerSide:o,dataSource:i,filterModel:s,sortModel:d,serverAggregationResults:a}=n,u=l.useMemo(()=>{if(o||Object.keys(e).length===0)return{};const h={};for(const[S,y]of Object.entries(e)){const w=xo[y];if(!w){console.warn(`[useAggregation] Unknown aggregation function: "${y}"`);continue}const g=t.map(x=>x[S]);h[S]=w(g)}return h},[t,e,o]),[c,f]=l.useState({}),[m,p]=l.useState(!1),[b,v]=l.useState(null),C=l.useRef(0),j=l.useCallback(async()=>{if(!i?.getAggregations||Object.keys(e).length===0)return;const h=++C.current;p(!0),v(null);try{const S=await i.getAggregations({sortModel:d??[],filterModel:s??{items:[]},groupKeys:[],aggregationModel:e});h===C.current&&f(S)}catch(S){h===C.current&&(v(S),console.error("[useAggregation] Server aggregation error:",S))}finally{h===C.current&&p(!1)}},[i,e,s,d]);return l.useEffect(()=>{o&&i?.getAggregations&&!a&&j()},[j,o,i,a]),{aggregationResult:l.useMemo(()=>o?a&&Object.keys(a).length>0?a:c:u,[o,u,a,c]),isLoading:m,error:b}}function mo({columns:n,aggregationModel:t,aggregationResult:e,columnWidths:o,rowHeight:i,checkboxSelection:s,hasDetailPanel:d,rowReordering:a}){return r.jsxs("div",{className:"ogx__aggregation-footer",role:"row","aria-label":"Aggregation totals","aria-live":"polite",style:{minHeight:`${i}px`},children:[s&&r.jsx("div",{style:{width:48,flexShrink:0}}),d&&r.jsx("div",{style:{width:48,flexShrink:0}}),a&&r.jsx("div",{style:{width:48,flexShrink:0}}),n.map(u=>{const c=t[u.field],f=e[u.field],m=o[u.field]??(typeof u.width=="number"?u.width:120);return r.jsx("div",{className:"ogx__aggregation-cell",role:"gridcell",style:{width:m,minWidth:m,maxWidth:m,textAlign:u.align||"left"},children:c?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"ogx__aggregation-label",children:c}),r.jsx("span",{className:"ogx__aggregation-value",children:Ie(f,c)})]}):null},u.field)})]})}function bo({noRowsLabel:n,width:t}){return r.jsxs("div",{className:"ogx__empty",style:{width:t},children:[r.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[r.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),r.jsx("path",{d:"M3 9h18M9 21V9"})]}),r.jsx("span",{children:n})]})}function wo({error:n}){if(!n)return null;const t=n instanceof Error?n.message:typeof n=="string"?n:"An unexpected error occurred while loading the data.";return r.jsxs("div",{className:"ogx-error-overlay","aria-live":"assertive",role:"alert",children:[r.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:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),r.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),r.jsx("div",{className:"ogx-error-overlay__title",children:"Oops! Something went wrong"}),r.jsx("div",{className:"ogx-error-overlay__message",children:t}),r.jsx("button",{onClick:()=>window.location.reload(),className:"ogx-button ogx-button--primary",children:"Retry"})]})}const st=({indeterminate:n=!1,label:t,className:e="",inputRef:o,...i})=>{const s=l.useRef(null),d=l.useCallback(u=>{s.current=u,typeof o=="function"?o(u):o&&(o.current=u)},[o]);l.useEffect(()=>{s.current&&(s.current.indeterminate=n)},[n]);const a=["ogx-checkbox-wrapper",i.disabled&&"ogx-checkbox-wrapper--disabled",e].filter(Boolean).join(" ");return r.jsxs("label",{className:a,children:[r.jsx("input",{ref:d,type:"checkbox",className:"ogx-checkbox__input","aria-label":t||i["aria-label"]||(n?"Select some":i.checked?"Deselect":"Select"),...i}),r.jsxs("span",{className:"ogx-checkbox__box",children:[i.checked&&!n&&r.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:r.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})}),n&&r.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:r.jsx("path",{d:"M19 13H5v-2h14v2z"})})]}),t&&r.jsx("span",{className:"ogx-checkbox__label",children:t})]})};function vo(n){const{field:t,currentWidth:e,onResize:o,minWidth:i=50,maxWidth:s=1e3}=n,[d,a]=l.useState(!1),u=l.useRef(0),c=l.useRef(0),f=l.useCallback(b=>{b.preventDefault(),b.stopPropagation(),a(!0),u.current=b.clientX,c.current=e;let v=0;const C=16,j=h=>{const S=h.clientX-u.current,y=Math.max(i,Math.min(s,c.current+S)),w=Date.now();w-v>=C&&(o(t,y),v=w)},I=h=>{a(!1);const S=h.clientX-u.current,y=Math.max(i,Math.min(s,c.current+S));o(t,y),document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",I)};document.addEventListener("mousemove",j),document.addEventListener("mouseup",I)},[t,e,o,i,s]),m=l.useCallback(b=>{b.preventDefault(),b.stopPropagation()},[]),p=["ogx-column-resize-handle",d&&"ogx-column-resize-handle--dragging"].filter(Boolean).join(" ");return r.jsx("div",{className:p,onMouseDown:f,onClick:b=>b.stopPropagation(),onDragStart:b=>{b.preventDefault(),b.stopPropagation()},onDoubleClick:m,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${t} column`,children:r.jsx("div",{className:"ogx-column-resize-handle__line"})})}function $e(){return r.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"currentColor",children:r.jsx("circle",{cx:"4",cy:"4",r:"4"})})}function De(){return r.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:r.jsx("circle",{cx:"4",cy:"4",r:"3"})})}function _o(){return r.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",children:[r.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),r.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.3"}),r.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),r.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),r.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),r.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function Co(){return r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),r.jsx("polyline",{points:"5 12 12 5 19 12"})]})}function yo(){return r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("polyline",{points:"19 12 12 19 5 12"})]})}function ko(){return r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})}function So(){return r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.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"}),r.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"}),r.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function jo(){return r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"4",y1:"2",x2:"4",y2:"22"}),r.jsx("polyline",{points:"11 8 4 12 11 16"}),r.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function Eo(){return r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"20",y1:"2",x2:"20",y2:"22"}),r.jsx("polyline",{points:"13 8 20 12 13 16"}),r.jsx("line",{x1:"20",y1:"12",x2:"4",y2:"12"})]})}function No(){return r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),r.jsx("line",{x1:"4",y1:"4",x2:"4",y2:"20"}),r.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function Mo({colDef:n,sortModel:t,onSort:e,onHide:o,onPin:i,pinnedColumns:s,onManageColumns:d,onClose:a,anchorEl:u}){const c=l.useRef(null),[f,m]=l.useState({position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"});l.useLayoutEffect(()=>{if(!u||!c.current)return;const w=u.getBoundingClientRect(),g=c.current.getBoundingClientRect(),x=window.innerWidth,E=window.innerHeight,M=8;let N=w.left;N+g.width+M>x&&(N=x-g.width-M),N<M&&(N=M);let _=w.bottom+4;_+g.height+M>E&&(_=w.top-g.height-4),m({position:"fixed",zIndex:1300,top:_,left:N,visibility:"visible"})},[u]),l.useEffect(()=>{function w(x){c.current&&!c.current.contains(x.target)&&u&&!u.contains(x.target)&&a()}function g(x){x.key==="Escape"&&a()}return document.addEventListener("mousedown",w),document.addEventListener("keydown",g),window.addEventListener("scroll",a,!0),window.addEventListener("resize",a),()=>{document.removeEventListener("mousedown",w),document.removeEventListener("keydown",g),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a)}},[u,a]);const p=w=>{e?.(n.field,w),a()},b=()=>{o?.(n.field),a()},v=w=>{i?.(n.field,w),a()},C=t?.find(w=>w.field===n.field)?.sort,j=C==null,I=s?.left?.includes(n.field)??!1,h=s?.right?.includes(n.field)??!1,S=!I&&!h,y=n.headerName||n.field;return Oe.createPortal(r.jsxs("div",{ref:c,className:"ogx-column-menu",style:f,role:"menu","aria-label":`Column options for ${y}`,children:[e&&n.sortable!==!1&&r.jsxs(r.Fragment,{children:[r.jsxs("button",{className:`ogx-menu-item${C==="asc"?" ogx-menu-item--active":""}`,onClick:()=>p("asc"),role:"menuitemradio","aria-checked":C==="asc",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:C==="asc"?r.jsx($e,{}):r.jsx(De,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(Co,{})}),"Sort Ascending"]}),r.jsxs("button",{className:`ogx-menu-item${C==="desc"?" ogx-menu-item--active":""}`,onClick:()=>p("desc"),role:"menuitemradio","aria-checked":C==="desc",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:C==="desc"?r.jsx($e,{}):r.jsx(De,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(yo,{})}),"Sort Descending"]}),r.jsxs("button",{className:`ogx-menu-item${j?" ogx-menu-item--active":""}`,onClick:()=>p(null),role:"menuitemradio","aria-checked":j,children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:j?r.jsx($e,{}):r.jsx(De,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(ko,{})}),"Unsort"]}),r.jsx("div",{className:"ogx-menu-divider"})]}),r.jsx("div",{className:"ogx-menu-section-label","aria-hidden":"true",children:"Pin column"}),r.jsxs("button",{className:`ogx-menu-item${I?" ogx-menu-item--active":""}`,onClick:()=>v("left"),role:"menuitemradio","aria-checked":I,"aria-label":"Pin to left",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:I?r.jsx($e,{}):r.jsx(De,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(jo,{})}),"Pin to Left"]}),r.jsxs("button",{className:`ogx-menu-item${h?" ogx-menu-item--active":""}`,onClick:()=>v("right"),role:"menuitemradio","aria-checked":h,"aria-label":"Pin to right",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:h?r.jsx($e,{}):r.jsx(De,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(Eo,{})}),"Pin to Right"]}),r.jsxs("button",{className:`ogx-menu-item${S?" ogx-menu-item--active":""}`,onClick:()=>v(null),role:"menuitemradio","aria-checked":S,"aria-label":"Unpin column",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:S?r.jsx($e,{}):r.jsx(De,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(No,{})}),"Unpin"]}),r.jsx("div",{className:"ogx-menu-divider"}),r.jsxs("button",{className:"ogx-menu-item",onClick:b,role:"menuitem","aria-label":`Hide ${y} column`,children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(So,{})}),"Hide Column"]}),r.jsx("div",{className:"ogx-menu-divider"}),r.jsxs("button",{className:"ogx-menu-item",onClick:()=>{d?.(),a()},role:"menuitem","aria-label":"Manage all columns",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(_o,{})}),"Manage columns"]})]}),u?.closest(".ogx-theme-provider")||document.body)}function Po(){return r.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"18",height:"18",children:r.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 Io(){return r.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor",children:r.jsx("path",{d:"M6.99 11L3 15l3.99 4v-3H14v-2H6.99v-3zM21 9l-3.99-4v3H10v2h7.01v3L21 9z"})})}function pn(n){const t=[];for(const e of n.children)typeof e=="string"?t.push(e):t.push(...pn(e));return t}function To(n){let t=0;function e(o,i){t=Math.max(t,i);for(const s of o.children)typeof s!="string"&&e(s,i+1)}return n.forEach(o=>e(o,1)),t}function Lo(n,t,e){function o(a,u,c){if(!pn(a).includes(u))return null;if(c===e)return a;for(const f of a.children)if(typeof f!="string"){const m=o(f,u,c+1);if(m)return m}return null}const i=new Map;for(const a of t){let u=null;for(const c of n)if(u=o(c,a.field,0),u)break;i.set(a.field,u)}const s=[];let d=0;for(;d<t.length;){const a=t[d],u=i.get(a.field)??null,c=a.width;if(!u)s.push({key:`fg-${a.field}-${e}`,label:"",width:c,isGroup:!1}),d++;else{let f=0,m=d;for(;m<t.length&&i.get(t[m].field)===u;)f+=t[m].width,m++;s.push({key:`${u.groupId}-${e}`,label:u.headerName,width:f,isGroup:!0}),d=m}}return s}function xn(n){const{columns:t,allColumns:e,columnGroupingModel:o,checkboxSelection:i=!1,allSelected:s=!1,someSelected:d=!1,onSelectAll:a,onSort:u,sortModel:c=[],onColumnResize:f,columnWidths:m={},pinnedColumns:p,hasDetailPanel:b=!1,pinCheckboxColumn:v=!0,pinExpandColumn:C=!0,rowReordering:j=!1,aggregationModel:I,draggedColumn:h,dragOverColumn:S,onDragStart:y,onDragOver:w,onDragEnd:g,onDrop:x,focusedCell:E,onHeaderClick:M,onHideColumn:N,onPinColumn:_,onManageColumns:P}=n,W=l.useRef({}),[T,F]=l.useState(null),H=L=>te=>{te.stopPropagation(),F({colDef:L,anchorEl:te.currentTarget})},R=()=>{F(null)};l.useLayoutEffect(()=>{if(E?.id==="HEADER"){const L=W.current[E.field];L&&L.focus()}},[E]);const G=L=>()=>{if(L.sortable===!1||!u)return;const te=c.find(Q=>Q.field===L.field);let ee="asc";te&&(te.sort==="asc"?ee="desc":ee=null),u(L.field,ee)},Y=L=>{const te=c.find(ee=>ee.field===L);return te?r.jsx("span",{className:`ogx__sort-icon ogx__sort-icon--${te.sort}`,"aria-hidden":"true"}):null},V=l.useMemo(()=>fn(t,m,p,i,v,b,C,j),[t,m,p,i,v,b,C,j]),k=o?To(o):0,O=(e??t).filter(L=>!L.isSpacer).map(L=>({field:L.field,width:m[L.field]??L.width??100})),K=(j?48:0)+(b?48:0)+(i?48:0);return r.jsxs("div",{className:"ogx__header-wrap",children:[k>0&&Array.from({length:k},(L,te)=>{const ee=Lo(o,O,te);return r.jsxs("div",{className:"ogx-col-group-row",role:"row",children:[K>0&&r.jsx("div",{className:"ogx-col-group-cell ogx-col-group-cell--filler",style:{width:K,minWidth:K,flexShrink:0},role:"columnheader"}),ee.map(Q=>r.jsx("div",{role:"columnheader",className:`ogx-col-group-cell ${Q.isGroup?"ogx-col-group-cell--group":"ogx-col-group-cell--filler"}`,style:{width:Q.width,minWidth:Q.width,flexShrink:0},title:Q.isGroup?Q.label:void 0,children:Q.isGroup&&r.jsx("span",{className:"ogx-col-group-cell__label",children:Q.label})},Q.key))]},`ogx-grp-${te}`)}),r.jsxs("div",{className:"ogx__header",role:"row",children:[j&&r.jsx("div",{className:"ogx__header-cell ogx__header-cell--pinned ogx__header-cell--pinned-left",role:"columnheader","aria-label":"Row reorder handle",title:"Drag to reorder rows",style:{minWidth:48,maxWidth:48,position:"sticky",left:0,zIndex:4}}),b&&r.jsx("div",{className:`ogx__header-cell ogx__header-cell--expand ${C?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""}`,role:"columnheader","aria-label":"Expand row details",style:{minWidth:48,maxWidth:48,position:C?"sticky":void 0,left:C?j?48:0:void 0,zIndex:C?5:void 0}}),i&&r.jsx("div",{className:`ogx__header-cell ogx__header-cell--checkbox ${v?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""}`,role:"columnheader",style:{position:v?"sticky":void 0,left:v?(j?48:0)+(b&&C?48:0):void 0},children:r.jsx(st,{id:"ogx-select-all",name:"ogx-select-all",checked:s,indeterminate:d,onChange:L=>a?.(L.target.checked),"aria-label":s?"Deselect all rows":"Select all rows",tabIndex:E?.id==="HEADER"&&E.field==="__checkbox_col__"?0:-1,onMouseDown:L=>L.preventDefault(),inputRef:L=>{W.current.__checkbox_col__=L}})}),t.map((L,te)=>{if(L.isSpacer)return r.jsx("div",{style:{width:L.width,minWidth:L.width,flexShrink:0},"aria-hidden":"true"},L.field);const ee=L.sortable!==!1,Q=c.some(ge=>ge.field===L.field),ce=L.resizable!==!1,$=xt(L.field,p),ae=$!==null,J=h===L.field,se=S===L.field,ie=["ogx__header-cell",`ogx__header-cell--align-${L.headerAlign||L.align||"left"}`,ee&&"ogx__header-cell--sortable",Q&&"ogx__header-cell--sorted",ae&&"ogx__header-cell--pinned",ae&&`ogx__header-cell--pinned-${$}`,J&&"ogx__header-cell--dragging",se&&"ogx__header-cell--drag-over",E?.id==="HEADER"&&E.field===L.field&&"ogx__header-cell--focused",L.headerClassName].filter(Boolean).join(" "),z=m[L.field]??L.width??100,q={width:z,minWidth:L.minWidth,maxWidth:L.maxWidth,flexGrow:L.flex??0,flexShrink:0,flexBasis:(L.flex,"auto"),boxSizing:"border-box",position:ae?"sticky":"relative",zIndex:L.zIndex,opacity:J?.5:1};if(ae&&$){const ge=V[L.field];$==="left"?q.left=ge:q.right=ge}const ne=L.renderHeader?L.renderHeader({field:L.field,colDef:L,colIndex:te}):L.headerName||L.field,de=ge=>{if(ge.target.closest(".ogx-column-resize-handle")){ge.stopPropagation();return}M?.(L.field),ee&&G(L)()},ue=y?y(L.field):void 0,je=w?w(L.field):void 0,Ve=x?x(L.field):void 0;return r.jsxs("div",{className:ie,style:q,onClick:de,role:"columnheader",draggable:!!y,onDragStart:ue,onDragOver:je,onDragEnd:g,onDrop:Ve,"aria-sort":ee?Q?c.find(ge=>ge.field===L.field)?.sort==="asc"?"ascending":"descending":"none":void 0,"aria-colindex":te+1+(i?1:0),"data-field":L.field,tabIndex:-1,ref:ge=>{W.current[L.field]=ge},children:[r.jsxs("div",{className:"ogx__header-cell-content",children:[J&&r.jsx("div",{className:"ogx__header-drag-icon",children:r.jsx(Io,{})}),r.jsxs("div",{className:"ogx__header-cell-title-wrapper",children:[r.jsx("span",{className:"ogx__header-cell-title",children:ne}),I&&I[L.field]&&r.jsx("span",{className:"ogx__header-cell-aggregation",children:I[L.field]})]}),ee&&Y(L.field),!L.disableColumnMenu&&r.jsx("button",{className:"ogx__menu-icon-btn",onClick:H(L),"aria-label":`Open column menu for ${L.headerName||L.field}`,"aria-haspopup":"menu",tabIndex:-1,children:r.jsx(Po,{})})]}),ce&&f&&r.jsx(vo,{field:L.field,currentWidth:z,onResize:f,minWidth:L.minWidth,maxWidth:L.maxWidth})]},L.field)}),T&&r.jsx(Mo,{colDef:T.colDef,sortModel:c,onSort:u,onHide:N,onPin:_,pinnedColumns:p,onManageColumns:P,onClose:R,anchorEl:T.anchorEl})]})]})}const at=({variant:n="text",size:t="medium",color:e="default",disabled:o=!1,className:i="",children:s,...d})=>{const a=["ogx-button",`ogx-button--${n}`,`ogx-button--${t}`,`ogx-button--${e}`,o&&"ogx-button--disabled",i].filter(Boolean).join(" ");return r.jsx("button",{className:a,disabled:o,...d,children:s})};function mn(n){const{page:t,pageSize:e,rowCount:o,onPageChange:i,onPageSizeChange:s,pageSizeOptions:d=[10,25,50,100],showFirstButton:a=!0,showLastButton:u=!0}=n,c=Math.max(1,Math.ceil(o/e)),f=Math.min(t,c-1),m=f*e,p=Math.min(m+e,o),b=o===0?0:`${m+1}–${p}`,v=()=>{i(0)},C=()=>{i(Math.max(0,f-1))},j=()=>{i(Math.min(c-1,f+1))},I=()=>{i(c-1)},h=w=>{const g=parseInt(w.target.value,10);s(g)},S=f===0,y=f>=c-1;return r.jsxs("div",{className:"ogx-pagination",role:"navigation","aria-label":"Pagination",children:[r.jsxs("div",{className:"ogx-pagination__page-size",children:[r.jsx("label",{htmlFor:"page-size-select",className:"ogx-pagination__label",children:"Rows per page:"}),r.jsx("select",{id:"page-size-select",className:"ogx-pagination__select",value:e,onChange:h,"aria-label":"Rows per page",children:d.map(w=>r.jsx("option",{value:w,children:w},w))})]}),r.jsxs("div",{className:"ogx-pagination__info","aria-live":"polite","aria-atomic":"true",children:[b," of ",o]}),r.jsxs("div",{className:"ogx-pagination__actions",children:[a&&r.jsx(at,{variant:"text",size:"small",onClick:v,disabled:S,"aria-label":"Go to first page",title:"First page",children:r.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:r.jsx("path",{d:"M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"})})}),r.jsx(at,{variant:"text",size:"small",onClick:C,disabled:S,"aria-label":"Go to previous page",title:"Previous page",children:r.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:r.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),r.jsxs("div",{className:"ogx-pagination__page-info","aria-current":"page",children:["Page ",f+1," of ",c]}),r.jsx(at,{variant:"text",size:"small",onClick:j,disabled:y,"aria-label":"Go to next page",title:"Next page",children:r.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:r.jsx("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})})}),u&&r.jsx(at,{variant:"text",size:"small",onClick:I,disabled:y,"aria-label":"Go to last page",title:"Last page",children:r.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:r.jsx("path",{d:"M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z"})})})]})]})}function Ro(n,t,e={}){const o=new Map,i=[];n.forEach(a=>{o.set(a.id,a),i.push(a.id)});const s=new Map,d=[];return t.forEach(a=>{s.set(a.field,a),d.push(a.field)}),{rows:{idRowsLookup:o,allRows:i},columns:{all:t,lookup:s,orderedFields:d,columnVisibilityModel:e},sorting:{sortModel:[]},filter:{filterModel:{items:[]}},pagination:{paginationModel:{page:0,pageSize:100},rowCount:n.length},selection:{selectedRows:new Set},pinning:{pinnedColumns:{},pinnedRows:{}},virtualization:{renderContext:{firstRowIndex:0,lastRowIndex:0,firstColumnIndex:0,lastColumnIndex:0}},dimensions:{rowHeight:52,headerHeight:56,viewportWidth:0,viewportHeight:0},dataSource:{loading:!1,error:null}}}function Wo(n,t){switch(t.type){case"SET_ROWS":{const e=Array.from(n.rows.idRowsLookup.values()),o=typeof t.payload=="function"?t.payload(e):t.payload,i=new Map,s=[];return o.forEach(d=>{i.set(d.id,d),s.push(d.id)}),{...n,rows:{idRowsLookup:i,allRows:s},pagination:{...n.pagination,rowCount:t.preserveRowCount?n.pagination.rowCount:o.length}}}case"SET_COLUMNS":{const e=new Map,o=[];return t.payload.forEach(i=>{e.set(i.field,i),o.push(i.field)}),{...n,columns:{all:t.payload,lookup:e,orderedFields:o,columnVisibilityModel:n.columns.columnVisibilityModel}}}case"SET_SORT_MODEL":return{...n,sorting:{sortModel:t.payload}};case"SET_FILTER_MODEL":return{...n,filter:{filterModel:t.payload}};case"SET_PAGINATION_MODEL":return{...n,pagination:{...n.pagination,paginationModel:t.payload}};case"SET_SELECTION":return{...n,selection:{selectedRows:t.payload}};case"SET_DIMENSIONS":return{...n,dimensions:{...n.dimensions,viewportWidth:t.payload.viewportWidth,viewportHeight:t.payload.viewportHeight}};case"SET_DATASOURCE_LOADING":return{...n,dataSource:{...n.dataSource,loading:t.payload}};case"SET_DATASOURCE_ERROR":return{...n,dataSource:{...n.dataSource,error:t.payload}};case"SET_ROW_COUNT":return{...n,pagination:{...n.pagination,rowCount:t.payload}};default:return n}}function Oo(n){const{rows:t,columns:e,rowHeight:o=52,headerHeight:i=56,columnVisibilityModel:s,initialState:d}=n,[a]=l.useState(()=>Ro(t,e,s)),[u,c]=l.useReducer(Wo,{...a,sorting:d?.sorting||a.sorting,filter:d?.filter||a.filter,dataSource:d?.dataSource?{...a.dataSource,...d.dataSource}:a.dataSource,pagination:{...a.pagination,...d?.pagination||{},rowCount:n.rowCount??d?.pagination?.rowCount??a.pagination.rowCount},dimensions:{...a.dimensions,rowHeight:o,headerHeight:i}}),f=l.useRef(u);l.useLayoutEffect(()=>{f.current=u});const m=l.useRef(t);l.useEffect(()=>{t!==m.current&&(m.current=t,c({type:"SET_ROWS",payload:t}))},[t]);const p=l.useCallback((x,E)=>{c({type:"SET_ROWS",payload:x,preserveRowCount:E})},[]),b=l.useCallback(x=>{c({type:"SET_COLUMNS",payload:x})},[]),v=l.useCallback(x=>{c({type:"SET_SORT_MODEL",payload:x})},[]),C=l.useCallback(x=>{c({type:"SET_FILTER_MODEL",payload:x})},[]),j=l.useCallback(x=>{c({type:"SET_PAGINATION_MODEL",payload:x})},[]),I=l.useCallback(x=>{c({type:"SET_SELECTION",payload:x})},[]),h=l.useCallback((x,E)=>{c({type:"SET_DIMENSIONS",payload:{viewportWidth:x,viewportHeight:E}})},[]),S=l.useCallback(x=>{c({type:"SET_DATASOURCE_LOADING",payload:x})},[]),y=l.useCallback(x=>{c({type:"SET_DATASOURCE_ERROR",payload:x})},[]),w=l.useCallback(x=>{c({type:"SET_ROW_COUNT",payload:x})},[]),g=l.useRef({getRow:x=>f.current.rows.idRowsLookup.get(x)||null,getAllRows:()=>Array.from(f.current.rows.idRowsLookup.values()),getVisibleRows:()=>Array.from(f.current.rows.idRowsLookup.values()),getAggregationResult:()=>null,getAggregationModel:()=>null,getColumn:x=>f.current.columns.lookup.get(x)||null,getAllColumns:()=>f.current.columns.all,getVisibleColumns:()=>f.current.columns.all,selectRow:(x,E=!0)=>{const M=new Set(f.current.selection.selectedRows);E?M.add(x):M.delete(x),I(M)},selectRows:(x,E=!0)=>{const M=new Set(f.current.selection.selectedRows);x.forEach(N=>{E?M.add(N):M.delete(N)}),I(M)},getSelectedRows:()=>Array.from(f.current.selection.selectedRows),sortColumn:(x,E)=>{if(E===null)v(f.current.sorting.sortModel.filter(M=>M.field!==x));else{const M=f.current.sorting.sortModel.findIndex(N=>N.field===x);if(M>=0){const N=[...f.current.sorting.sortModel];N[M]={field:x,sort:E},v(N)}else v([...f.current.sorting.sortModel,{field:x,sort:E}])}},getSortModel:()=>f.current.sorting.sortModel,setFilterModel:C,getFilterModel:()=>f.current.filter.filterModel,setPage:x=>{j({...f.current.pagination.paginationModel,page:x})},setPageSize:x=>{j({...f.current.pagination.paginationModel,pageSize:x,page:0})},scrollToIndexes:()=>{},copySelectedRows:()=>Promise.resolve()});return{state:u,dispatch:c,apiRef:g,setRows:p,setColumns:b,setSortModel:v,setFilterModel:C,setPaginationModel:j,setSelection:I,setDimensions:h,setDataSourceLoading:S,setDataSourceError:y,setRowCount:w}}function Fo(n){const{onRowOrderChange:t,rows:e,getRowId:o,rowReordering:i=!1}=n,[s,d]=l.useState(null),[a,u]=l.useState(null),c=l.useCallback(v=>o?o(v):v.id,[o]),f=l.useCallback(v=>C=>{i&&(d(v),C.dataTransfer.effectAllowed="move")},[i]),m=l.useCallback(v=>C=>{!i||!s||(C.preventDefault(),C.dataTransfer.dropEffect="move",a!==v&&u(v))},[i,s,a]),p=l.useCallback(()=>{d(null),u(null)},[]),b=l.useCallback(v=>C=>{if(C.preventDefault(),!s||!t){p();return}const j=e.findIndex(h=>c(h)===s),I=e.findIndex(h=>c(h)===v);j!==-1&&I!==-1&&j!==I&&t({row:e[j],oldIndex:j,targetIndex:I}),p()},[s,t,e,c,p]);return{draggedRowId:s,dragOverRowId:a,onDragStart:i?f:void 0,onDragOver:i?m:void 0,onDragEnd:i?p:void 0,onDrop:i?b:void 0}}function Ao(n){const{rows:t,getRowId:e,getTreeDataPath:o,treeData:i=!1,defaultGroupingExpansionDepth:s=0,filterModel:d,sortModel:a,onRowExpansionChange:u}=n,{treeNodes:c,rootIds:f,groupingRows:m}=l.useMemo(()=>{if(!i||!o)return{treeNodes:new Map,rootIds:[],groupingRows:[]};const y=new Map,w=[],g=[],x=new Map,E=M=>M.join("/");return t.forEach(M=>{const N=e(M),_=o(M),P=E(_);x.set(P,N),y.set(N,{id:N,parentId:null,depth:_.length-1,groupingKey:_[_.length-1],isExpanded:!1,children:[],serverChildrenCount:M.serverChildrenCount})}),t.forEach(M=>{const N=e(M),_=o(M);if(_.length===1){w.push(N);return}const P=T=>{if(T.length<=1)return;const F=T.slice(0,-1),H=E(F);let R=x.get(H);if(R===void 0&&(R=`auto-group-${H}`,!y.has(R))){const G=F[F.length-1];y.set(R,{id:R,parentId:null,depth:F.length-1,groupingKey:G,isExpanded:!1,children:[],label:G}),x.set(H,R);const Y={id:R,name:G,_isGroupRow:!0};g.push(Y),F.length===1&&w.push(R),P(F)}return R},W=P(_);if(W!==void 0){const T=y.get(W),F=y.get(N);T&&F&&(F.parentId=W,T.children=T.children||[],T.children.includes(N)||T.children.push(N))}}),g.forEach(M=>{const N=M.id,_=y.get(N);if(!_)return;const W=N.replace("auto-group-","").split("/");if(W.length>1){const T=W.slice(0,-1),F=E(T),H=x.get(F);if(H&&y.has(H)){_.parentId=H;const R=y.get(H);R&&(R.children=R.children||[],R.children.includes(N)||R.children.push(N))}}}),{treeNodes:y,rootIds:w,groupingRows:g}},[t,o,i,e]),p=l.useMemo(()=>{if(!i)return new Set;const y=new Set;return c.forEach(w=>{w.children&&w.children.length>0&&(s===-1||w.depth<s)&&y.add(w.id)}),y},[c,i,s]),[b,v]=l.useState(new Set);l.useEffect(()=>{p.size>0&&v(p)},[p]);const C=l.useCallback(y=>{v(w=>{const g=new Set(w),x=!g.has(y);if(g.has(y)?g.delete(y):g.add(y),x&&u){const E=c.get(y);E&&u(E)}return g})},[c,u]),j=l.useCallback(()=>{if(!i)return null;const y=new Map;t.forEach(P=>y.set(e(P),P)),m.forEach(P=>y.set(P.id,P));const w=P=>Ft(P,d),g=new Map,x=P=>{if(g.has(P))return g.get(P);const W=y.get(P);if(!W)return!1;if(w(W))return g.set(P,!0),!0;const F=c.get(P);return F&&F.children&&F.children.some(R=>x(R))?(g.set(P,!0),!0):(g.set(P,!1),!1)},E=(P,W)=>{if(!a||a.length===0)return 0;const T=y.get(P),F=y.get(W);if(!T||!F)return 0;for(const H of a){const R=T[H.field],G=F[H.field],Y=At(R,G,H.sort);if(Y!==0)return Y}return 0},M=[],N=new Set,_=P=>{const W=P.filter(T=>x(T));W.sort(E),W.forEach(T=>{if(N.has(T))return;const F=y.get(T),H=c.get(T);if(F&&H){N.add(T);const R={...F,_treeDepth:H.depth,_isExpanded:b.has(T),_hasChildren:!!(H.children&&H.children.length>0||H.serverChildrenCount&&H.serverChildrenCount>0),_descendantCount:H.children?H.children.length:0};M.push(R),b.has(T)&&H.children&&H.children.length>0&&_(H.children)}})};return _(f),M},[i,t,m,f,c,b,d,a,e]),I=l.useCallback(y=>b.has(y),[b]),h=l.useCallback(y=>c.get(y),[c]),S=l.useCallback(y=>{const w=[];let g=y;for(;g!==null;){const x=c.get(g);if(!x)break;w.unshift(x.groupingKey),g=x.parentId}return w},[c]);return l.useMemo(()=>({treeNodes:c,groupingRows:m,toggleExpansion:C,isGroupExpanded:I,getVisibleRows:j,getNode:h,getNodePath:S}),[c,m,C,I,j,h,S])}const zo=n=>n?.depth===-1?"footer":"inline";function Bo(n){const{rows:t,getRowId:e,rowGroupingModel:o=[],aggregationModel:i={},defaultGroupingExpansionDepth:s=0,filterModel:d,sortModel:a,getAggregationPosition:u=zo}=n,[c,f]=l.useState(new Set),{treeNodes:m,rootIds:p,groupingRows:b}=l.useMemo(()=>{const h=new Map,S=new Map,y=[];if(o.length===0)return{treeNodes:h,rootIds:y,groupingRows:S};const w=(E,M,N)=>`auto-group-${E}-${M}-${N||"root"}`,g=(E,M,N)=>{if(M>=o.length)return E.map(T=>{const F=e(T);return h.set(F,{id:F,parentId:N,depth:M,groupingKey:"",isExpanded:!1}),F});const _=o[M],P=new Map;E.forEach(T=>{const F=T[_],H=String(F);P.has(H)||P.set(H,[]),P.get(H).push(T)});const W=[];return P.forEach((T,F)=>{const R=T[0][_],G=w(_,F,N);W.push(G);const Y={};i&&Object.entries(i).forEach(([A,D])=>{const X=T.map(K=>K[A]);if(D==="sum")Y[A]=X.reduce((K,L)=>K+(Number(L)||0),0);else if(D==="min")Y[A]=Math.min(...X.map(K=>Number(K)||0));else if(D==="max")Y[A]=Math.max(...X.map(K=>Number(K)||0));else if(D==="avg"){const K=X.reduce((L,te)=>L+(Number(te)||0),0);Y[A]=X.length?K/X.length:0}else D==="count"&&(Y[A]=X.length)});const V={[_]:R,...Y,id:G};S.set(G,V);const k={id:G,parentId:N,depth:M,groupingKey:F,groupingField:_,groupingValue:R,aggregatedValues:Y,isExpanded:!1,children:[],label:`${_}: ${String(R)}`};k.aggregationPosition=u(k),h.set(G,k);const B=g(T,M+1,G);h.get(G).children=B;const O=T.length;h.get(G).descendantCount=O}),W},x=g(t,0,null);return y.push(...x),{treeNodes:h,rootIds:y,groupingRows:S}},[t,o,i,e,u]);l.useEffect(()=>{if(s===-1){const h=new Set;m.forEach((S,y)=>{S.children&&S.children.length>0&&h.add(y)}),f(h)}else if(s>0){const h=new Set;m.forEach((S,y)=>{S.depth<s&&S.children&&S.children.length>0&&h.add(y)}),f(h)}else f(new Set)},[o,s,m]);const v=l.useCallback(h=>{f(S=>{const y=new Set(S);return y.has(h)?y.delete(h):y.add(h),y})},[]),C=l.useCallback(h=>c.has(h),[c]),j=l.useCallback(()=>{if(o.length===0)return null;const h=[],S=new Set,y=new Map;t.forEach(E=>y.set(e(E),E));const w=E=>{const M=m.get(E);if(!M)return!1;if(!M.children||M.children.length===0){const N=y.get(E);return!(!N||d&&!Ft(N,d))}return M.children.some(N=>w(N))},g=E=>{let M=E;d&&(M=E.filter(w)),a&&a.length>0&&M.sort((N,_)=>{const P=b.get(N)||y.get(N),W=b.get(_)||y.get(_);if(!P||!W)return 0;for(const T of a){const F=P[T.field],H=W[T.field],R=At(F,H,T.sort);if(R!==0)return R}return 0}),M.forEach(N=>{if(S.has(N))return;const _=m.get(N),P=_?.children&&_.children.length>0,W=P?b.get(N):y.get(N);if(W&&_){S.add(N);const T={...W,_treeDepth:_.depth,_isExpanded:c.has(N),_hasChildren:P,_groupingField:_.groupingField,_groupingValue:_.groupingValue,_descendantCount:_.descendantCount};h.push(T),x.has(N)&&P&&g(_.children)}})},x=c;return g(p),h},[t,e,m,p,b,d,a,c,o]),I=l.useCallback(h=>m.get(h),[m]);return l.useMemo(()=>({treeNodes:m,groupingRows:b,toggleExpansion:v,isGroupExpanded:C,getVisibleRows:j,getNode:I}),[m,b,v,C,j,I])}function $o(n){const{rows:t,getRowId:e,processRowUpdate:o,onProcessRowUpdateError:i,onRowChange:s}=n,[d,a]=l.useState(null),u=l.useRef(null),c=l.useCallback(b=>{a(b),u.current=typeof b=="function"?b(u.current):b},[]),f=l.useCallback(b=>{c({id:b.id,field:b.field,value:b.value,originalValue:b.value})},[c]),m=l.useCallback(async b=>{const v=u.current;if(!v)return;if(b?.cancel){c(null);return}const{id:C,field:j,value:I,originalValue:h}=v;if(I===h){c(null);return}const S=t.find(w=>e(w)===C);if(!S){c(null);return}const y={...S,[j]:I};try{if(o){const w=await o(y,S);s?.(w)}else s?.(y);c(null)}catch(w){i?.(w)}},[c,t,e,o,s,i]),p=l.useCallback(b=>{d&&d.id===b.id&&d.field===b.field&&c(v=>v?{...v,value:b.value}:null)},[d,c]);return{editingCell:d,startCellEdit:f,stopCellEdit:m,setEditCellValue:p}}function Do(n,t,e){const[o,i]=l.useState(new Map),[s,d]=l.useState({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}}),a=l.useCallback(()=>{i(new Map)},[]),u=l.useCallback((C,j)=>o.get(C)?.[j],[o]),c=l.useCallback((C,j,I,h,S)=>{const y=new Map(o);for(let w=h;w<S;w++){const g=t[w];if(!g)continue;let x=1;if(g.colSpan)if(typeof g.colSpan=="function"){const M={row:j,value:j[g.field],field:g.field,colDef:g,rowIndex:I,colIndex:w};x=g.colSpan(M)}else x=g.colSpan;if(x<=1){He(y,C,g.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:e[g.field]||100}});continue}let E=e[g.field]||100;for(let M=1;M<x;M++)if(w+M<S){const N=t[w+M];N&&(E+=e[N.field]||100,He(y,C,N.field,{spannedByColSpan:!0,leftVisibleCellIndex:w,rightVisibleCellIndex:Math.min(w+x-1,t.length-1)}))}He(y,C,g.field,{spannedByColSpan:!1,cellProps:{colSpan:x,width:E}}),w+=x-1}i(y)},[o,t,e]),f=l.useCallback((C,j)=>{const I={},h={},S={};t.forEach((y,w)=>{if(y.rowSpan)for(let g=C;g<j;g++){const x=n[g];if(!x||h[x.id]?.[y.field])continue;const E=y.valueGetter?y.valueGetter({row:x,field:y.field,value:x[y.field]}):x[y.field];let M=1;if(typeof y.rowSpan=="function"){const N={row:x,value:E,field:y.field,colDef:y,rowIndex:g,colIndex:w};M=y.rowSpan(N)}else typeof y.rowSpan=="number"&&(M=y.rowSpan);if(M>1){I[x.id]||(I[x.id]={}),I[x.id][y.field]=M;for(let N=1;N<M;N++){const _=g+N;if(_<j&&n[_]){const P=n[_];h[P.id]||(h[P.id]={}),h[P.id][y.field]=!0,S[_]||(S[_]={}),S[_][y.field]=g}}}}}),d({caches:{spannedCells:I,hiddenCells:h,hiddenCellOriginMap:S},processedRange:{firstRowIndex:C,lastRowIndex:j}})},[n,t]),m=l.useCallback(()=>{d({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}})},[]);l.useEffect(()=>{const C=new Map;n.forEach((S,y)=>{for(let w=0;w<t.length;w++){const g=t[w];if(!g)continue;let x=1;if(g.colSpan)if(typeof g.colSpan=="function"){const M={row:S,value:S[g.field],field:g.field,colDef:g,rowIndex:y,colIndex:w};x=g.colSpan(M)}else x=g.colSpan;if(x<=1){const M=e[g.field]||(typeof g.width=="number"?g.width:100);He(C,S.id,g.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:M}});continue}let E=e[g.field]||(typeof g.width=="number"?g.width:100);for(let M=1;M<x;M++)if(w+M<t.length){const N=t[w+M];if(N){const _=e[N.field]||(typeof N.width=="number"?N.width:100);E+=_,He(C,S.id,N.field,{spannedByColSpan:!0,leftVisibleCellIndex:w,rightVisibleCellIndex:Math.min(w+x-1,t.length-1)})}}He(C,S.id,g.field,{spannedByColSpan:!1,cellProps:{colSpan:x,width:E}}),w+=x-1}}),i(C);const j={},I={},h={};t.forEach((S,y)=>{if(S.rowSpan)for(let w=0;w<n.length;w++){const g=n[w];if(!g||I[g.id]?.[S.field])continue;const x=S.valueGetter?S.valueGetter({row:g,field:S.field,value:g[S.field]}):g[S.field];let E=1;if(typeof S.rowSpan=="function"){const M={row:g,value:x,field:S.field,colDef:S,rowIndex:w,colIndex:y};E=S.rowSpan(M)}else typeof S.rowSpan=="number"&&(E=S.rowSpan);if(E>1){j[g.id]||(j[g.id]={}),j[g.id][S.field]=E;for(let M=1;M<E;M++){const N=w+M;if(N<n.length&&n[N]){const _=n[N];I[_.id]||(I[_.id]={}),I[_.id][S.field]=!0,h[N]||(h[N]={}),h[N][S.field]=w}}}}}),d({caches:{spannedCells:j,hiddenCells:I,hiddenCellOriginMap:h},processedRange:{firstRowIndex:0,lastRowIndex:n.length}})},[n,t,e]);const p=l.useCallback(()=>s.caches.spannedCells,[s]),b=l.useCallback(()=>s.caches.hiddenCells,[s]),v=l.useCallback(()=>s.caches.hiddenCellOriginMap,[s]);return{colspanMap:o,resetColSpan:a,getCellColSpanInfo:u,calculateColSpan:c,rowSpanningState:s,calculateRowSpan:f,resetRowSpan:m,getSpannedCells:p,getHiddenCells:b,getHiddenCellOriginMap:v}}function He(n,t,e,o){let i=n.get(t);i||(i={},n.set(t,i)),i[e]=o}function Ho(n){const{dataSource:t,sortModel:e,filterModel:o,paginationModel:i,paginationMode:s,sortingMode:d,filterMode:a,aggregationModel:u,setRows:c,setRowCount:f,setDataSourceLoading:m,setDataSourceError:p,onAggregationResults:b}=n,v=l.useRef(null),C=l.useRef(0),j=l.useCallback(async()=>{if(!t)return;const h=++C.current;m(!0),p(null);const S=i.page*i.pageSize,y=S+i.pageSize,w={startRow:S,endRow:y,sortModel:e,filterModel:o,groupKeys:[],aggregationModel:u};try{const g=await t.getRows(w);if(h!==C.current)return;let x=!1;if(s==="infinite"){const E=v.current;if(E){const M=JSON.stringify(E.sortModel)!==JSON.stringify(e),N=JSON.stringify(E.filterModel)!==JSON.stringify(o),_=E.pageSize!==i.pageSize;!M&&!N&&!_&&i.page>E.page&&(x=!0)}}c(x?E=>[...E,...g.rows]:g.rows,!0),g.aggregationResults&&b&&b(g.aggregationResults),g.rowCount!==void 0&&f(g.rowCount),v.current={sortModel:e,filterModel:o,page:i.page,pageSize:i.pageSize}}catch(g){h===C.current&&(p(g),console.error("Data Source Error:",g))}finally{h===C.current&&m(!1)}},[t,i.page,i.pageSize,e,o,s,u,b,c,f,m,p]);l.useEffect(()=>{if(t&&(s==="server"||s==="infinite"||d==="server"||a==="server")){const S=setTimeout(()=>{j()},300);return()=>clearTimeout(S)}},[j,t,s,d,a]);const I=l.useCallback(async(h,S)=>{if(t){m(!0);try{const y=await t.getRows({startRow:0,endRow:-1,sortModel:e,filterModel:o,groupKeys:S});y.rows.length>0&&c(w=>{const g=new Set(w.map(E=>E.id)),x=y.rows.filter(E=>!g.has(E.id));return[...w,...x]})}catch(y){p(y),console.error("Failed to fetch children:",y)}finally{m(!1)}}},[t,e,o,c,m,p]);return{fetchRows:j,fetchChildren:I}}const bn="\0",dt="";function Go(n,t){const e=n.filter(o=>o!=null&&!isNaN(o));if(e.length===0)return null;switch(t){case"sum":return e.reduce((o,i)=>o+i,0);case"avg":return e.reduce((o,i)=>o+i,0)/e.length;case"count":return e.length;case"min":return Math.min(...e);case"max":return Math.max(...e)}}function mt(n,t){return t.map(e=>String(n[e]??"")).join(bn)}function zt(n,t,e,o){return o?`${n}${dt}${t}${dt}${e}`:`${t}${dt}${e}`}function wn(n,t,e,o){return l.useMemo(()=>{const i={pivotRows:[],pivotColumns:[],colKeys:[],isValid:!1};if(!o)return i;const{rowFields:s,columnFields:d,valueFields:a}=e;if(s.length===0||a.length===0)return i;const u=d.length>0,c=new Map(t.map(h=>[h.field,h])),f=new Set;for(const h of n)f.add(mt(h,d));const m=Array.from(f).sort(),p=new Map;for(const h of n){const S=mt(h,s);if(!p.has(S)){const x={};for(const E of s)x[E]=h[E];p.set(S,{labelValues:x,bucket:new Map})}const y=p.get(S),w=mt(h,d);y.bucket.has(w)||y.bucket.set(w,new Map);const g=y.bucket.get(w);for(const x of a){const E=h[x.field];g.has(x.field)||g.set(x.field,[]),E!=null&&!isNaN(Number(E))&&g.get(x.field).push(Number(E))}}let b=0;const v=[];for(const[,h]of p){const S={id:b++,...h.labelValues};for(const y of m){const w=h.bucket.get(y);for(const g of a){const x=zt(y,g.field,g.aggFn,u),E=w?.get(g.field)??[];S[x]=E.length>0?Go(E,g.aggFn):null}}v.push(S)}const C=new Map;for(const h of n){const S=mt(h,d);for(const y of a){if(y.aggFn!=="avg"&&y.aggFn!=="min"&&y.aggFn!=="max")continue;const w=`${S}${dt}${y.field}`;C.has(w)||C.set(w,[]);const g=h[y.field];g!=null&&!isNaN(Number(g))&&C.get(w).push(Number(g))}}const j={id:"__pivot_grand_total__"};for(let h=0;h<s.length;h++)j[s[h]]=h===0?"Grand Total":"";for(const h of m)for(const S of a){const y=zt(h,S.field,S.aggFn,u),w=v.map(x=>x[y]).filter(x=>x!=null&&!isNaN(Number(x))).map(Number);if(w.length===0){j[y]=null;continue}const g=`${h}${dt}${S.field}`;switch(S.aggFn){case"sum":case"count":j[y]=w.reduce((x,E)=>x+E,0);break;case"avg":{const x=C.get(g)??[];j[y]=x.length>0?x.reduce((E,M)=>E+M,0)/x.length:null;break}case"min":j[y]=Math.min(...C.get(g)??w);break;case"max":j[y]=Math.max(...C.get(g)??w);break}}v.push(j);const I=[];for(const h of s){const S=c.get(h);I.push({field:h,headerName:S?.headerName??h,width:S?.width??140,sortable:!0})}for(const h of m){const S=u?h.split(bn).map((y,w)=>{const g=c.get(d[w]);return g?.headerName?`${g.headerName}: ${y}`:y}).join(" / "):"";for(const y of a){const w=c.get(y.field),g=zt(h,y.field,y.aggFn,u),x=y.headerName??w?.headerName??y.field,E=S?`${S} — ${x} (${y.aggFn})`:`${x} (${y.aggFn})`;I.push({field:g,headerName:E,width:140,type:"number",align:"right",headerAlign:"right",sortable:!0,valueFormatter:({value:M})=>{if(M==null)return"—";const N=Number(M);return y.aggFn==="avg"?N.toFixed(2):y.aggFn==="count"?N.toLocaleString():w?.valueFormatter?w.valueFormatter({value:M,row:{},field:y.field}):N.toLocaleString()}})}}return{pivotRows:v,pivotColumns:I,colKeys:m,isValid:!0}},[n,t,e,o])}function Vo(n){const t=document.createElement("textarea");t.value=n,t.style.cssText="position:fixed;top:-9999px;left:-9999px;opacity:0;",document.body.appendChild(t),t.focus(),t.select();let e=!1;try{e=document.execCommand("copy")}finally{document.body.removeChild(t)}return e}async function Uo(n){let t=!1;try{t=Vo(n)}catch{}if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")try{await navigator.clipboard.writeText(n);return}catch(e){if(t)return;throw e}else if(!t)throw new Error("Clipboard API not available and fallback failed.")}function Ko(n){const{selectedRowIds:t,columns:e,getVisibleRows:o,getRowId:i}=n,s=l.useCallback(async()=>{if(t.size===0)return;const a=o().filter(p=>t.has(i(p)));if(a.length===0)return;const u=e.filter(p=>!p.field.startsWith("__")),c=u.map(p=>p.headerName||p.field).join(" "),f=a.map(p=>u.map(b=>{const v=p[b.field];return b.valueFormatter?b.valueFormatter({value:v,row:p,field:b.field}):v??""}).join(" ")).join(`
|
|
7
|
-
`),
|
|
8
|
-
${f}`;try{await Uo(m)}catch(p){console.error("[OpenGridX] Failed to copy to clipboard:",p)}},[t,e,o,i]);return l.useEffect(()=>{const d=a=>{if(!(a.ctrlKey||a.metaKey)||a.key!=="c")return;const u=document.activeElement,c=u?.tagName.toLowerCase(),f=u?.type;c==="input"&&f!=="checkbox"&&f!=="radio"||c==="textarea"||c==="select"||u?.isContentEditable||s()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[s]),{copySelectedRows:s}}function Yo({row:n,rowIndex:t,listViewColumn:e,isSelected:o=!1,checkboxSelection:i=!1,rowHeight:s,onRowClick:d,onSelectionChange:a}){const u={row:n,value:void 0,field:e.field,colDef:{field:e.field},rowIndex:t,colIndex:0},c=f=>{f.stopPropagation(),a?.(n.id,f.target.checked)};return r.jsxs("div",{className:`ogx-list-view__row${o?" ogx-list-view__row--selected":""}`,style:s?{minHeight:s}:void 0,onClick:()=>d?.(n),role:"row","aria-rowindex":t+2,"aria-selected":o,children:[i&&r.jsx("div",{className:"ogx-list-view__checkbox",onClick:f=>f.stopPropagation(),children:r.jsx("input",{type:"checkbox",checked:o,onChange:c,"aria-label":`Select row ${n.id}`})}),r.jsx("div",{className:"ogx-list-view__cell",role:"gridcell",children:e.renderCell(u)})]})}function qo({ariaLabel:n,allRenderableRows:t,filteredRows:e,pagination:o,effectivePaginationModel:i,pageSizeOptions:s,selectedRowIds:d,listViewColumn:a,noRowsLabel:u,rowHeight:c,checkboxSelection:f,paginationMode:m,dataSource:p,serverRowCount:b,paginationSlot:v,paginationSlotProps:C,onRowClick:j,onSelectionChange:I,onPaginationModelChange:h}){const S=v||mn,y=m==="server"&&p?b||0:e.length;return r.jsxs("div",{className:"ogx-list-view",role:"grid","aria-label":n||"Data grid list view","aria-rowcount":t.length+1,children:[r.jsx("div",{className:"ogx-list-view__toolbar",children:r.jsxs("span",{children:[e.length," ",e.length===1?"item":"items",o?` · page ${i.page+1} of ${Math.ceil(e.length/i.pageSize)||1}`:"",d.size>0?` · ${d.size} selected`:""]})}),r.jsx("div",{className:"ogx-list-view__rows",children:t.length===0?r.jsxs("div",{className:"ogx-list-view__empty","aria-live":"polite",role:"status",children:[r.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[r.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),r.jsx("path",{d:"M3 9h18M9 21V9"})]}),u]}):t.map((w,g)=>r.jsx(Yo,{row:w,rowIndex:g,listViewColumn:a,isSelected:d.has(w.id),checkboxSelection:f,rowHeight:c,onRowClick:x=>j({row:x,id:x.id,rowIndex:g}),onSelectionChange:I},w.id))}),o&&r.jsx(S,{page:i.page,pageSize:i.pageSize,rowCount:y,pageSizeOptions:s,onPageChange:w=>h({...i,page:w}),onPageSizeChange:w=>h({...i,pageSize:w,page:0}),...C})]})}function Xo({value:n,onValueChange:t,onCommit:e,onCancel:o}){const[i,s]=l.useState(String(n??"")),d=l.useRef(null);return l.useEffect(()=>{d.current?.focus(),d.current?.select()},[]),r.jsx("input",{ref:d,type:"text",className:"ogx__edit-input",value:i,onChange:a=>{s(a.target.value),t(a.target.value)},onBlur:e,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),e()),a.key==="Escape"&&(a.stopPropagation(),o())}})}function Jo({value:n,onValueChange:t,onCommit:e,onCancel:o}){const[i,s]=l.useState(typeof n=="number"?n:""),d=l.useRef(null);return l.useEffect(()=>{d.current?.focus(),d.current?.select()},[]),r.jsx("input",{ref:d,type:"number",className:"ogx__edit-input ogx__edit-input--number",value:i,onChange:a=>{const u=a.target.value===""?"":Number(a.target.value);s(u),t(u===""?null:u)},onBlur:e,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),e()),a.key==="Escape"&&(a.stopPropagation(),o())}})}function Qo({value:n,onValueChange:t,onCommit:e,onCancel:o}){const i=l.useRef(null);l.useEffect(()=>{i.current?.focus()},[]);const s=()=>{t(!n),setTimeout(e,0)};return r.jsx("div",{className:"ogx__edit-boolean",children:r.jsx("input",{ref:i,type:"checkbox",className:"ogx__edit-checkbox",checked:!!n,onChange:s,onKeyDown:d=>{d.key==="Escape"&&(d.stopPropagation(),o())}})})}function Zo({value:n,colDef:t,onValueChange:e,onCommit:o,onCancel:i}){const s=l.useRef(null);l.useEffect(()=>{s.current?.focus()},[]);const d=t.valueOptions??[];return r.jsx("select",{ref:s,className:"ogx__edit-select",value:String(n??""),onChange:a=>{e(a.target.value)},onBlur:o,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),o()),a.key==="Escape"&&(a.stopPropagation(),i())},children:d.map(a=>{const u=typeof a=="object"?a.value:a,c=typeof a=="object"?a.label:String(a);return r.jsx("option",{value:String(u),children:c},String(u))})})}function er({value:n,onValueChange:t,onCommit:e,onCancel:o}){const[i,s]=l.useState(typeof n=="string"?n:String(n??"")),d=l.useRef(null);return l.useEffect(()=>{d.current?.focus()},[]),r.jsx("input",{ref:d,type:"date",className:"ogx__edit-input",value:i,onChange:a=>{s(a.target.value),t(a.target.value)},onBlur:e,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),e()),a.key==="Escape"&&(a.stopPropagation(),o())}})}function tr(n){const{colDef:t}=n;switch(t.type){case"number":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(Jo,{...n})});case"boolean":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(Qo,{...n})});case"singleSelect":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(Zo,{...n})});case"date":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(er,{...n})});default:return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(Xo,{...n})})}}function nr(n){const{onCellClick:t,onCellEditStart:e,onCellValueChange:o,value:i,row:s,colDef:d,rowIndex:a,colIndex:u,isSelected:c,onClick:f,width:m,pinnedPosition:p,pinnedOffset:b,isFocused:v,isFocusVisible:C,isEditable:j,isEditing:I,onEditStart:h,onEditStop:S,onValueChange:y,colSpanInfo:w,rowSpan:g,isHiddenByRowSpan:x}=n,E=l.useCallback(k=>{o?o(d.field,k):y?.(k)},[o,y,d.field]),M=l.useMemo(()=>d.valueFormatter?d.valueFormatter({value:i,row:s,field:d.field}):i==null?"":String(i),[i,s,d]),N=l.useMemo(()=>I&&(o||y)&&S?d.renderEditCell?d.renderEditCell({value:i,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:u}):r.jsx(tr,{value:i,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:u,onValueChange:E,onCommit:()=>S(),onCancel:()=>S(!0)}):d.renderCell?d.renderCell({value:i,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:u}):M,[i,s,d,a,u,M,I,E,S,o,y]),_=l.useMemo(()=>d.cellClassName?typeof d.cellClassName=="function"?d.cellClassName({value:i,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:u})||"":d.cellClassName:"",[d,i,s,a,u]),P=l.useRef(null);if(l.useLayoutEffect(()=>{v&&P.current&&P.current.focus({preventScroll:!0})},[v]),w?.spannedByColSpan)return null;if(x)return r.jsx("div",{className:"ogx__cell ogx__cell--hidden",style:{width:m??d.width??100},role:"presentation","data-field":d.field,"data-colindex":u});const W=k=>{t&&t({row:s,field:d.field,value:i,colDef:d,rowIndex:a,colIndex:u}),f?.(k)},T=k=>{j&&(h||e)&&(k.stopPropagation(),e?e(d.field,i):h?.())},F=p!=null,H=["ogx__cell",`ogx__cell--align-${d.align||"left"}`,c&&"ogx__cell--selected",v&&"ogx__cell--focused",v&&C&&"ogx__cell--focus-visible",d.type&&`ogx__cell--type-${d.type}`,F&&"ogx__cell--pinned",F&&`ogx__cell--pinned-${p}`,I&&"ogx__cell--editing",g&&g>1&&"ogx__cell--spanned",_].filter(Boolean).join(" "),R=w?.cellProps?.colSpan||1,G=g||1,Y=w?.cellProps?.width??m??d.width??100,V={width:"var(--width)","--width":typeof Y=="number"?`${Y}px`:Y,flexGrow:d.flex??0,flexShrink:0,flexBasis:(d.flex,"auto"),boxSizing:"border-box",minWidth:d.minWidth,maxWidth:d.maxWidth,position:F?"sticky":void 0,zIndex:d.zIndex??(F?3:void 0),padding:I?0:void 0};return G>1&&(V.height=`calc(var(--height) * ${G} - var(--border-width, 1px))`,V.zIndex=10,F&&(V.zIndex=40)),F&&b!==void 0&&(p==="left"?V.left=b:V.right=b),r.jsx("div",{ref:P,className:H,style:V,onClick:W,onDoubleClick:T,role:"gridcell","aria-colindex":u+1,"aria-readonly":!j||void 0,tabIndex:-1,"data-field":d.field,"data-colindex":u,...R>1?{"aria-colspan":R}:{},...G>1?{"aria-rowspan":G}:{},children:r.jsx("div",{className:"ogx__cell-content",children:N})})}const vn=l.memo(nr),or=({className:n="",...t})=>r.jsx("button",{type:"button",className:`ogx-drag-handle ${n}`,"aria-label":"Drag to reorder row",...t,children:r.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"currentColor","aria-hidden":"true",children:r.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 rr(n){const{content:t,height:e,isExpanded:o}=n;if(!o)return null;const i={height:e==="auto"?"auto":`${e}px`,overflow:e==="auto"?"visible":"auto"};return r.jsx("div",{className:"ogx__detail-panel",style:i,children:r.jsx("div",{className:"ogx__detail-panel-content",children:t})})}function bt(n){const{row:t,columns:e,rowIndex:o,isSelected:i=!1,checkboxSelection:s=!1,onRowClick:d,onCellClick:a,onSelectionChange:u,columnWidths:c={},pinnedColumns:f,pinnedRows:m,hasDetailPanel:p=!1,isDetailPanelExpanded:b=!1,onDetailPanelToggle:v,detailPanelContent:C,detailPanelHeight:j=200,pinCheckboxColumn:I=!0,pinExpandColumn:h=!0,rowReordering:S=!1,onDragStart:y,onDragOver:w,onDragEnd:g,onDrop:x,isDragging:E,isDragOver:M,editingCell:N,onEditStart:_,onEditStop:P,onEditCellValueChange:W,focusedCellField:T,isFocusVisible:F,colspanMap:H,rowSpanningCaches:R,rowHeight:G=52}=n,Y=l.useRef(null),V=l.useRef(null);l.useLayoutEffect(()=>{T==="__expand_col__"&&Y.current&&Y.current.focus({preventScroll:!0}),T==="__checkbox_col__"&&V.current&&V.current.focus({preventScroll:!0})},[T]);const k=l.useMemo(()=>fn(e,c,f,s,I,p,h,S),[e,c,f,s,I,p,h,S]),B=t._hasChildren===!0,O=l.useCallback(($,ae)=>{B||_?.({id:t.id,field:$,value:ae})},[B,t.id,_]),A=l.useCallback(($,ae)=>{W?.({id:t.id,field:$,value:ae})},[W,t.id]),D=l.useCallback($=>{P?.({cancel:$})},[P]);if(t._isSkeleton){const $=Math.max(e.length,5);return r.jsx("div",{className:"ogx__row ogx__row--skeleton",role:"row","aria-hidden":"true",style:{height:G,minHeight:G},children:Array.from({length:$}).map((ae,J)=>r.jsx("div",{className:"ogx__skeleton-cell",children:r.jsx("div",{className:"ogx__skeleton-bar"})},J))})}const X=$=>{$.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell")||d?.({row:t,id:t.id,rowIndex:o})},K=$=>{$.stopPropagation(),u?.(t.id,$.target.checked)},L=$=>{$.stopPropagation(),v?.(t.id)},te=Ot(t.id,m),ee=te==="top",Q=te==="bottom",ce=["ogx__row",i&&"ogx__row--selected",o%2===0&&"ogx__row--even",o%2===1&&"ogx__row--odd",ee&&"ogx__row--pinned-top",Q&&"ogx__row--pinned-bottom",E&&"ogx__row--dragging",M&&"ogx__row--drag-over",B&&"ogx__row--group"].filter(Boolean).join(" ");return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:ce,onClick:X,role:"row","aria-rowindex":o+1,"aria-selected":i,"data-rowindex":o,onDragOver:w?w(t.id):void 0,onDrop:x?x(t.id):void 0,style:{maxHeight:`${G}px`,minHeight:`${G}px`,"--height":`${G}px`,"--border-width":"1px"},children:[S&&r.jsx("div",{className:"ogx__cell ogx__cell--drag-handle",role:"gridcell","aria-label":"Drag to reorder row",style:{position:"sticky",left:0,zIndex:4},draggable:!0,onDragStart:y?y(t.id):void 0,onDragEnd:g,onClick:$=>$.stopPropagation(),children:r.jsx(or,{})}),p&&r.jsx("div",{className:`ogx__cell ogx__cell--expand ${h?"ogx__cell--pinned-left":""} ${T==="__expand_col__"?"ogx__cell--focused":""} ${T==="__expand_col__"&&F?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":b?"Collapse row details":"Expand row details","aria-expanded":b,style:{position:h?"sticky":void 0,left:h?S?48:0:void 0,zIndex:h?5:void 0},ref:Y,tabIndex:-1,onClick:$=>{$.stopPropagation(),a?.({row:t,field:"__expand_col__",value:b,colDef:{field:"__expand_col__",width:48},rowIndex:o,colIndex:-1})},children:r.jsx(gn,{isExpanded:b,onClick:L,variant:"plus-minus"})}),s&&r.jsx("div",{className:`ogx__cell ogx__cell--checkbox ${I?"ogx__cell--pinned-left":""} ${T==="__checkbox_col__"?"ogx__cell--focused":""} ${T==="__checkbox_col__"&&F?"ogx__cell--focus-visible":""}`,role:"gridcell",style:{position:I?"sticky":void 0,left:I?(S?48:0)+(p&&h?48:0):void 0,zIndex:I?11:void 0},ref:V,tabIndex:-1,onClick:$=>{$.stopPropagation(),a?.({row:t,field:"__checkbox_col__",value:i,colDef:{field:"__checkbox_col__",width:48},rowIndex:o,colIndex:-1})},children:r.jsx(st,{id:`ogx-select-row-${t.id}`,name:`ogx-select-row-${t.id}`,checked:i,onChange:K,onClick:$=>$.stopPropagation(),"aria-label":i?`Deselect row ${t.id}`:`Select row ${t.id}`,tabIndex:-1,onMouseDown:$=>$.preventDefault()})}),e.map(($,ae)=>{if($.isSpacer)return r.jsx("div",{style:{width:$.width,minWidth:$.width,flexShrink:0},"aria-hidden":"true"},$.field);const J=$.valueGetter?$.valueGetter({row:t,field:$.field,value:t[$.field]}):t[$.field],se=c[$.field]??$.width,ie=xt($.field,f),z=ie?k[$.field]:void 0,q=N?.id===t.id&&N?.field===$.field,ne=q?N?.value:J,de=H?.get(t.id)?.[$.field],ue=R?.spannedCells[t.id]?.[$.field],je=R?.hiddenCells[t.id]?.[$.field]||!1;return r.jsx(vn,{value:ne,row:t,colDef:$,rowIndex:o,colIndex:ae,isSelected:i,onCellClick:a,width:se,pinnedPosition:ie,pinnedOffset:z,isFocused:T===$.field,isFocusVisible:F,isEditable:$.editable,isEditing:q,onCellEditStart:O,onEditStop:D,onCellValueChange:A,colSpanInfo:de,rowSpan:ue,isHiddenByRowSpan:je},$.field)})]}),p&&r.jsx(rr,{row:t,rowId:t.id,rowIndex:o,content:C,height:j,isExpanded:b})]})}function _n({rows:n,position:t,columns:e,selectedRowIds:o,checkboxSelection:i,onRowClick:s,onCellClick:d,onSelectionChange:a,columnWidths:u,pinnedColumns:c,pinnedRows:f,hasDetailPanel:m,expandedRowIds:p,getDetailPanelContent:b,getDetailPanelHeight:v,onDetailPanelToggle:C,pinCheckboxColumn:j,pinExpandColumn:I,focusedCell:h,colspanMap:S,rowSpanningCaches:y,rowHeight:w}){return n.length===0?null:r.jsx("div",{className:`ogx__pinned-rows ogx__pinned-rows--${t}`,role:"rowgroup",children:n.map((g,x)=>r.jsx(bt,{row:g,columns:e,rowIndex:x,isSelected:o.has(g.id),checkboxSelection:i,onRowClick:s,onCellClick:d,onSelectionChange:a,columnWidths:u,pinnedColumns:c,pinnedRows:f,hasDetailPanel:m,isDetailPanelExpanded:p.has(g.id),detailPanelContent:b?b({row:g,id:g.id,rowIndex:x}):null,detailPanelHeight:v?.({row:g,id:g.id,rowIndex:x})||200,onDetailPanelToggle:C,pinCheckboxColumn:j,pinExpandColumn:I,focusedCellField:h?.id===g.id?h.field:null,colspanMap:S,rowSpanningCaches:y,rowHeight:w},g.id))})}const ir=({columns:n,rowHeight:t,checkboxSelection:e=!1,hasDetailPanel:o=!1,rowReordering:i=!1})=>r.jsxs("div",{className:"ogx__row ogx__skeleton-row",style:{height:t},role:"row",children:[e&&r.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:r.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),o&&r.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:r.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),i&&r.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:r.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),n.map((s,d)=>{const a=typeof s.width=="number"?s.width:150,u=Math.min(a*.7,a-20);return r.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:a,minWidth:s.minWidth,maxWidth:s.maxWidth,left:s.left,right:s.right,position:s.isSpacer?"relative":s.pinned?"sticky":"relative",zIndex:s.zIndex},children:!s.isSpacer&&r.jsx("div",{className:"ogx-skeleton-box",style:{width:u,height:16,borderRadius:4}})},s.field||d)})]});function lr({virtualContainerHeight:n,offsetTop:t,effectiveLoading:e,visibleRows:o,baseColumns:i,virtualColumns:s,viewportWidth:d,checkboxSelection:a,hasDetailPanel:u,rowReordering:c,rowHeight:f,pinnedRows:m,selectedRowIds:p,onRowClick:b,onCellClick:v,onSelectionChange:C,columnWidths:j,pinnedColumns:I,expandedRowIds:h,getDetailPanelContent:S,getDetailPanelHeight:y,onDetailPanelToggle:w,pinCheckboxColumn:g,pinExpandColumn:x,rowReorderHandlers:E,editingHandlers:M,focusedCell:N,colspanMap:_,rowSpanningCaches:P,paginationMode:W,dataSourceLoading:T,sortedUnpinnedRowCount:F,infiniteScrollSkeletonCount:H,unpinnedRowsLength:R}){const G=i.length>0?i:(()=>{const V=(d||1e3)-(a?48:0)-(u?48:0)-(c?48:0),k=150,B=Math.max(1,Math.ceil(V/k));return Array.from({length:B},(O,A)=>({field:`placeholder_${A}`,headerName:"",width:k}))})(),Y=o.filter(({row:V})=>!Ot(V.id,m)).filter((V,k,B)=>k===B.findIndex(O=>O.row.id===V.row.id));return r.jsx("div",{className:"ogx__virtual-container",style:{height:`${n}px`},role:"presentation",children:r.jsxs("div",{className:"ogx__rows",style:{transform:`translateY(${t}px)`},role:"rowgroup",children:[e&&o.length===0?Array.from({length:10}).map((V,k)=>r.jsx(ir,{columns:G,rowHeight:f,checkboxSelection:a,hasDetailPanel:u,rowReordering:c},`skeleton-${k}`)):Y.map(({row:V,rowIndex:k})=>r.jsx(bt,{row:V,columns:s,rowIndex:k,isSelected:p.has(V.id),checkboxSelection:a,onRowClick:b,onCellClick:v,onSelectionChange:C,columnWidths:j,pinnedColumns:I,pinnedRows:m,hasDetailPanel:u,isDetailPanelExpanded:h.has(V.id),detailPanelContent:S?S({row:V,id:V.id,rowIndex:k}):null,detailPanelHeight:y?.({row:V,id:V.id,rowIndex:k})||200,onDetailPanelToggle:w,pinCheckboxColumn:g,pinExpandColumn:x,rowReordering:c,onDragStart:E.onDragStart,onDragOver:E.onDragOver,onDragEnd:E.onDragEnd,onDrop:E.onDrop,isDragging:E.draggedRowId===V.id,isDragOver:E.dragOverRowId===V.id,editingCell:M.editingCell,onEditStart:M.startCellEdit,onEditStop:M.stopCellEdit,onEditCellValueChange:M.setEditCellValue,focusedCellField:N!=null&&N.id===V.id?N.field:null,colspanMap:_,rowSpanningCaches:P,rowHeight:f},V.id)),W==="infinite"&&T&&F>0&&r.jsx("div",{className:"ogx__skeleton-group",children:Array.from({length:H}).map((V,k)=>r.jsx(bt,{row:{id:`__skeleton_${k}__`,_isSkeleton:!0},columns:s,rowIndex:R+k,rowHeight:f},`__skeleton_${k}__`))})]})})}function sr(){return r.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function ar(){return r.jsxs("svg",{className:"ogx-column-visibility-panel__drag-handle",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[r.jsx("circle",{cx:"9",cy:"5",r:"1.5"}),r.jsx("circle",{cx:"15",cy:"5",r:"1.5"}),r.jsx("circle",{cx:"9",cy:"12",r:"1.5"}),r.jsx("circle",{cx:"15",cy:"12",r:"1.5"}),r.jsx("circle",{cx:"9",cy:"19",r:"1.5"}),r.jsx("circle",{cx:"15",cy:"19",r:"1.5"})]})}function Cn(n){const{columns:t,visibleColumns:e,onVisibilityChange:o,onShowAll:i,onHideAll:s,onColumnReorder:d,onColumnOrderReset:a}=n,[u,c]=l.useState(""),[f,m]=l.useState(null),p=l.useRef(null),v=l.useMemo(()=>t.filter(g=>g.hideable!==!1),[t]).every(g=>e.has(g.field)),C=l.useMemo(()=>{if(!u)return t;const g=u.toLowerCase();return t.filter(x=>(x.headerName||x.field).toLowerCase().includes(g))},[t,u]),j=g=>{g.target.checked?i():s()},I=g=>x=>{p.current=g,x.dataTransfer.effectAllowed="move",x.dataTransfer.setDragImage(x.currentTarget.closest(".ogx-column-visibility-panel__item"),20,20)},h=g=>x=>{x.preventDefault(),x.dataTransfer.dropEffect="move",g!==p.current&&m(g)},S=()=>{m(null)},y=g=>x=>{x.preventDefault();const E=p.current;m(null),p.current=null,E&&E!==g&&d&&d(E,g)},w=()=>{m(null),p.current=null};return r.jsxs("div",{className:"ogx-column-visibility-panel",children:[r.jsx("div",{className:"ogx-column-visibility-panel__search-section",children:r.jsxs("div",{className:"ogx-column-visibility-panel__search-container",children:[r.jsx(sr,{}),r.jsx("input",{id:"ogx-column-search",name:"ogx-column-search",autoComplete:"off",className:"ogx-column-visibility-panel__search-input",placeholder:"Search",value:u,onChange:g=>c(g.target.value)})]})}),r.jsx("div",{className:"ogx-column-visibility-panel__list",children:C.map(g=>{const x=e.has(g.field),E=g.hideable!==!1,M=f===g.field,N=!!d&&!u;return r.jsxs("div",{className:["ogx-column-visibility-panel__item",!E&&"ogx-column-visibility-panel__item--disabled",M&&"ogx-column-visibility-panel__item--drag-over"].filter(Boolean).join(" "),draggable:N,onDragOver:N?h(g.field):void 0,onDragLeave:N?S:void 0,onDrop:N?y(g.field):void 0,onDragEnd:N?w:void 0,children:[N&&r.jsx("span",{className:"ogx-column-visibility-panel__drag-handle-wrapper",draggable:!0,onDragStart:I(g.field),title:"Drag to reorder",children:r.jsx(ar,{})}),r.jsxs("label",{className:"ogx-column-visibility-panel__item-label",style:{display:"flex",alignItems:"center",gap:"var(--ogx-spacing-md)",flex:1,cursor:E?"pointer":"not-allowed"},children:[r.jsx(st,{checked:x,onChange:_=>o(g.field,_.target.checked),disabled:!E}),r.jsx("span",{className:"ogx-column-visibility-panel__label",children:g.headerName||g.field})]})]},g.field)})}),r.jsxs("div",{className:"ogx-column-visibility-panel__footer",children:[r.jsxs("label",{className:"ogx-column-visibility-panel__item",children:[r.jsx(st,{checked:v,onChange:j}),r.jsx("span",{className:"ogx-column-visibility-panel__label",children:"Show/Hide All"})]}),r.jsx("button",{className:"ogx-column-visibility-panel__reset-btn",onClick:()=>{i(),a?.()},children:"Reset"})]})]})}function dr({isOpen:n,containerRef:t,effectiveColumns:e,columnVisibilityModel:o,effectiveColumnOrder:i,columnOrder:s,disableColumnReorder:d,onClose:a,onColumnVisibilityChange:u,onColumnOrderChange:c,setInternalColumnOrder:f}){const[m,p]=l.useState(16),[b,v]=l.useState(16),[C,j]=l.useState(()=>document.body);if(l.useLayoutEffect(()=>{if(!n||!t.current)return;const h=t.current.getBoundingClientRect();p(h.top+8),v(window.innerWidth-h.right+8),j(t.current.closest(".ogx-theme-provider")||document.body)},[n,t]),!n)return null;const I=d?void 0:(h,S)=>{const y=[...i],w=y.indexOf(h),g=y.indexOf(S);if(w===-1||g===-1)return;const x=[...y];x.splice(w,1),x.splice(g,0,h),s||f(x),c?.({oldIndex:w,targetIndex:g,column:e.find(E=>E.field===h)})};return Oe.createPortal(r.jsxs("div",{id:"ogx-standalone-col-panel",style:{position:"fixed",top:m,right:b,zIndex:9999,display:"inline-block"},children:[r.jsx("button",{onClick:a,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:"×"}),r.jsx(Cn,{columns:e,visibleColumns:new Set(e.filter(h=>o[h.field]!==!1).map(h=>h.field)),onVisibilityChange:(h,S)=>{u({...o,[h]:S})},onShowAll:()=>{const h={...o};e.forEach(S=>{S.hideable!==!1&&(h[S.field]=!0)}),u(h)},onHideAll:()=>{const h={...o};e.forEach(S=>{S.hideable!==!1&&(h[S.field]=!1)}),u(h)},onColumnReorder:I})]}),C)}function cr(n){const{rows:t,columns:e,getRowId:o,rowHeight:i=52,headerHeight:s=56,autoHeight:d=!1,checkboxSelection:a=!1,rowSelectionModel:u,onRowSelectionModelChange:c,onRowClick:f,onCellClick:m,filterModel:p,onFilterModelChange:b,sortModel:v,onSortModelChange:C,pagination:j=!1,paginationModel:I={page:0,pageSize:100},onPaginationModelChange:h,pageSizeOptions:S=[10,25,50,100],pinnedColumns:y,onPinnedColumnsChange:w,pinnedRows:g,getDetailPanelContent:x,getDetailPanelHeight:E,detailPanelExpandedRowIds:M,onDetailPanelExpandedRowIdsChange:N,pinCheckboxColumn:_=!0,pinExpandColumn:P=!0,disableColumnReorder:W=!1,columnOrder:T,onColumnOrderChange:F,height:H,rowReordering:R=!1,onRowOrderChange:G,loading:Y=!1,treeData:V=!1,getTreeDataPath:k,defaultGroupingExpansionDepth:B,rowGroupingModel:O,aggregationModel:A,onAggregationModelChange:D,getAggregationPosition:X,isCellEditable:K,processRowUpdate:L,onProcessRowUpdateError:te,dataSource:ee,sortingMode:Q="client",filterMode:ce="client",paginationMode:$="client",rowCount:ae,slots:J,slotProps:se,pivotMode:ie=!1,pivotModel:z,onPivotModelChange:q,className:ne="",style:de,onRowsScrollEnd:ue,ariaLabel:je,initialState:Ve,onStateChange:ge,columnVisibilityModel:Ue,onColumnVisibilityModelChange:Ke,listView:oe=!1,listViewColumn:we,columnGroupingModel:Fe,noRowsLabel:$t="No Data",apiRef:Dt}=n,Xr=l.useMemo(()=>({items:[]}),[]),ke=p||Xr,Jr=l.useMemo(()=>[],[]),Ht=O||Jr,Mn=l.useRef(J?.toolbar);Mn.current=J?.toolbar;const Qr=l.useRef(U=>{const Z=Mn.current;return Z?Z(U):null}).current,Zr=to({initialState:Ve,sortModel:v,aggregationModel:A,onAggregationModelChange:D,columnVisibilityModel:Ue,onColumnVisibilityModelChange:Ke,pinnedColumns:y,onPinnedColumnsChange:w,pivotModel:z,onPivotModelChange:q,paginationModel:I,onPaginationModelChange:h,rowSelectionModel:u}),{sortModel:Le,isSortControlled:Pn,setInternalSortModel:In,aggregationModel:Se,handleAggregationModelChange:Tn,columnVisibilityModel:Ae,handleColumnVisibilityModelChange:wt,pinnedColumns:Re,handlePinnedColumnsChange:Gt,currentPivotModel:Vt,handlePivotModelChange:Ln,effectivePaginationModel:Ce,handlePaginationModelChange:Ut,selectedRowIds:ve,isSelectionControlled:vt,setInternalRowSelectionModel:_t}=Zr,Ct=c,yt=wn(t,e,Vt,ie),Rn=ie&&yt.isValid?yt.pivotRows:t,Kt=ie&&yt.isValid?yt.pivotColumns:e,[ei,Wn]=l.useState(null);l.useEffect(()=>{Wn(null)},[Se]);const Ye=l.useRef(null),ti=l.useRef(null),kt=l.useRef(null),ni=l.useCallback(U=>U.id,[]),qe=o||ni,Yt=l.useMemo(()=>Rn.map(U=>{const Z=qe(U);return Z===U.id?U:{...U,id:Z}}),[Rn,qe]),Xe=l.useCallback(U=>{an.current?.classList.toggle("ogx--kb",U)},[]),On=l.useRef(ee);On.current=ee;const Fn=l.useRef(null),An=l.useRef(null),oi=l.useCallback(U=>{if(On.current&&V&&(U.serverChildrenCount??0)>0&&(U.children??[]).length===0){const Z=An.current?.getNodePath(U.id)||[U.groupingKey];Fn.current?.(U.id,Z)}},[V]),_e=Oo({rows:Yt,columns:Kt,rowHeight:i,headerHeight:s,rowCount:ae,columnVisibilityModel:Ae,initialState:n.initialState}),{state:fe,apiRef:Je,setRows:qt,setColumns:ri,setDimensions:zn,setDataSourceLoading:ii,setDataSourceError:li,setRowCount:si}=_e,{scrollTop:ai,scrollLeft:di,handleScroll:ci}=ho({onRowsScrollEnd:ue});l.useEffect(()=>{Dt&&(Dt.current=Je.current)},[Dt,Je]);const{copySelectedRows:Bn}=Ko({selectedRowIds:ve,columns:Kt,getVisibleRows:()=>Je.current.getVisibleRows(),getRowId:qe});l.useEffect(()=>{Je.current.copySelectedRows=Bn,Je.current.getSelectedRows=()=>Array.from(ve)},[Bn,ve,Je]);const ui=fe.dataSource.loading,ut=Y||ui,Qe=l.useMemo(()=>fe.rows.allRows.map(U=>fe.rows.idRowsLookup.get(U)),[fe.rows]),Xt=Ao({rows:Qe,getRowId:qe,getTreeDataPath:k,treeData:V,defaultGroupingExpansionDepth:B,filterModel:ke,sortModel:Le,onRowExpansionChange:oi});l.useEffect(()=>{An.current=Xt},[Xt]);const fi=Bo({rows:Qe,getRowId:qe,rowGroupingModel:Ht,aggregationModel:Se,defaultGroupingExpansionDepth:B,filterModel:ke,sortModel:Le,getAggregationPosition:X}),Ze=$o({rows:Qe,getRowId:qe,processRowUpdate:L,onProcessRowUpdateError:te,onRowChange:U=>{const{dispatch:Z}=_e,xe=Array.from(_e.state.rows.idRowsLookup.values()).map(pe=>pe.id===U.id?U:pe);Z({type:"SET_ROWS",payload:xe})}}),Jt=V,St=!!(Ht&&Ht.length>0),Qt=Jt||St,jt=Jt?Xt:St?fi:null,Ne=j&&!St,Et=l.useCallback(U=>{const{row:Z,id:le}=U;if(Qt&&Z._hasChildren){jt?.toggleExpansion(le);return}f?.(U)},[Qt,jt,f]),Zt=Ho({dataSource:ee,sortModel:Le,filterModel:ke,paginationModel:Ce,paginationMode:$,sortingMode:Q,filterMode:ce,aggregationModel:Se,setRows:qt,setRowCount:si,setDataSourceLoading:ii,setDataSourceError:li,onAggregationResults:Wn});l.useEffect(()=>{Zt.fetchChildren&&(Fn.current=Zt.fetchChildren)},[Zt.fetchChildren]),l.useEffect(()=>{ee||qt(Yt)},[Yt,qt,ee]);const Me=!!x,[gi,hi]=l.useState(new Set),et=M??gi,Nt=l.useCallback(U=>{const Z=new Set(et);Z.has(U)?Z.delete(U):Z.add(U),M===void 0&&hi(Z),N?.(Z)},[et,M,N]),{effectiveColumns:We,orderedColumns:en,visibleOrderedColumns:pi,navigationColumns:$n,columnWidths:Pe,effectiveColumnOrder:Mt,setInternalColumnOrder:Pt,columnReorderHandlers:tt,handleColumnResize:xi}=fo({activeColumns:Kt,isHierarchyEnabled:Qt,isRowGrouping:St,isTreeData:Jt,activeHierarchyHandlers:jt,columnVisibilityModel:Ae,columnOrder:T,onColumnOrderChange:F,disableColumnReorder:W,pivotMode:ie,checkboxSelection:a,hasDetailPanel:Me,rowReordering:R,initialState:Ve,setColumns:ri});po({onStateChange:ge,sortModel:Le,filterModel:ke,effectivePaginationModel:Ce,columnWidths:Pe,effectiveColumnOrder:Mt,columnVisibilityModel:Ae,pinnedColumns:Re});const nt=ao({effectiveRows:Qe,activeHierarchyHandlers:jt,filterMode:ce,filterModel:ke,dataSource:ee,sortModel:Le,sortingMode:Q,pagination:Ne,paginationMode:$,effectivePaginationModel:Ce,pinnedRows:g,isLoading:fe.dataSource.loading,pageSize:Ce.pageSize}),ze=nt.filteredRows,tn=nt.pinnedTopRows,nn=nt.pinnedBottomRows,ot=nt.sortedUnpinnedRows,ft=nt.paginatedUnpinnedRows,on=nt.allRenderableRows;l.useEffect(()=>{_e.apiRef.current.getVisibleRows=()=>Ne?ft:ot,_e.apiRef.current.getVisibleColumns=()=>We},[ot,ft,Ne,We,_e.apiRef]);const mi=Fo({rows:Ne?ft:ot,getRowId:U=>U.id,onRowOrderChange:G,rowReordering:R}),rt=Do(on,$n,Pe),{aggregationResult:rn}=hn({rows:ze,aggregationModel:Se,isServerSide:!!(ee&&($==="server"||Q==="server")),dataSource:ee,filterModel:ke,sortModel:Le,serverAggregationResults:ei}),It=Object.keys(Se).length>0;l.useEffect(()=>{_e.apiRef.current.getAggregationResult=()=>It?rn:null,_e.apiRef.current.getAggregationModel=()=>It?Se:null},[rn,Se,It,_e.apiRef]);const he=Qn({rowHeight:i,pagination:Ne,paginatedUnpinnedRows:ft,sortedUnpinnedRows:ot,expandedRowIds:et,getDetailPanelHeight:E,pinnedTopRowsLength:tn.length,pinnedBottomRowsLength:nn.length,visibleOrderedColumns:pi,pinnedColumns:Re,columnWidths:Pe,viewportWidth:fe.dimensions.viewportWidth||1e3,checkboxSelection:a,hasDetailPanel:Me,rowReordering:R,paginationMode:$,isLoading:fe.dataSource.loading,pageSize:Ce.pageSize}),bi=l.useMemo(()=>{const U={};for(const Z of[...he.leftPinnedCols,...he.unpinnedColsWithWidth,...he.rightPinnedCols])Z.isSpacer||(U[Z.field]=Z.width);return{...U,...Pe}},[he.leftPinnedCols,he.unpinnedColsWithWidth,he.rightPinnedCols,Pe]);l.useEffect(()=>{_e.apiRef.current.scrollToIndexes=({rowIndex:U,colIndex:Z})=>{const le=Ye.current;if(le){if(U!==void 0&&U>=0){const xe=U>0?he.cumulativeHeights[U-1]:0,pe=he.cumulativeHeights[U]??xe,{scrollTop:me,clientHeight:be}=le;xe<me?le.scrollTop=xe:pe>me+be&&(le.scrollTop=pe-be)}if(Z!==void 0&&Z>=0){const pe=[...he.leftPinnedCols,...he.unpinnedColsWithWidth,...he.rightPinnedCols][Z];if(!pe)return;const me=he.unpinnedColsWithWidth.findIndex(Ei=>Ei.field===pe.field);if(me===-1)return;const be=me>0?he.unpinnedAccWidths[me-1]:0,Rt=he.unpinnedAccWidths[me]??be,Wt=he.leftWidth+Rt,{scrollLeft:Vn,clientWidth:Un}=le;be<Vn?le.scrollLeft=be:Wt>Vn+Un&&(le.scrollLeft=Wt-Un)}}}},[he,Ye,_e.apiRef]);const ye=co({layout:he,scrollTop:ai,scrollLeft:di,viewportWidth:fe.dimensions.viewportWidth,viewportHeight:fe.dimensions.viewportHeight,autoHeight:d,rowReordering:R,hasDetailPanel:Me,checkboxSelection:a,pinCheckboxColumn:_,pinExpandColumn:P});l.useEffect(()=>{if(!Ye.current)return;const U=new ResizeObserver(Z=>{for(const le of Z){const{width:xe,height:pe}=le.contentRect;zn(xe,pe)}});return U.observe(Ye.current),()=>{U.disconnect()}},[zn]);const gt=l.useCallback((U,Z)=>{const le=new Set(ve);Z?le.add(U):le.delete(U);const xe=Array.from(le);vt||_t(xe),Ct?.(xe)},[ve,vt,Ct,_t]),wi=l.useCallback(U=>{let Z=[];U&&(Z=Qe.map(le=>le.id)),vt||_t(Z),Ct?.(Z)},[Qe,vt,Ct,_t]),Dn=l.useCallback((U,Z)=>{const le=Z?[{field:U,sort:Z}]:[];Pn||In(le),C?.(le)},[Pn,C,In]),{focusedCell:Tt,setFocusedCell:ln,handleFocus:vi,handleBlur:_i,handleKeyDown:Ci}=Zn({allRenderableRows:on,navigationColumns:$n,checkboxSelection:a,selectedRowIds:ve,handleSelectionChange:gt,handleDetailPanelToggle:Nt,editingHandlers:Ze,setKeyboardMode:Xe,sortModel:Le,handleSort:Dn,isCellEditable:K,pagination:Ne,pageSize:Ce.pageSize,virtualization:ye,viewportRef:Ye}),sn=l.useCallback(U=>{Xe(!1),ln({id:U.row.id,field:U.field}),kt.current?.focus({preventScroll:!0}),m?.(U)},[m,Xe,ln]),Hn=l.useRef(Ze.editingCell);l.useEffect(()=>{const U=!!Hn.current,Z=!!Ze.editingCell;U&&!Z&&kt.current?.focus({preventScroll:!0}),Hn.current=Ze.editingCell},[Ze.editingCell]);const yi=go({renderContext:ye.renderContext,pinnedTopRows:tn,pinnedBottomRows:nn,paginatedUnpinnedRows:ft,sortedUnpinnedRows:ot,pagination:Ne}),ki=t.length>0&&ve.size===t.length,Si=ve.size>0&&ve.size<t.length,ji=l.useMemo(()=>We.some(U=>!!U.rowSpan),[We]),[ht,Lt]=l.useState(!1),an=l.useRef(null),Gn=l.useMemo(()=>{if(!J?.toolbar)return null;const U=W?void 0:(Z,le)=>{const xe=[...Mt],pe=xe.indexOf(Z),me=xe.indexOf(le);if(pe===-1||me===-1)return;const be=[...xe];be.splice(pe,1),be.splice(me,0,Z),T||Pt(be);const Rt=We.find(Wt=>Wt.field===Z);Rt&&F?.({oldIndex:pe,targetIndex:me,column:Rt})};return{apiRef:_e.apiRef,columns:en,baseColumns:e,aggregationModel:Se,onAggregationModelChange:Tn,...ie||z||q?{pivotModel:Vt,onPivotModelChange:Ln}:{},filterModel:ke,onFilterModelChange:b,columnVisibilityModel:Ae,onColumnVisibilityModelChange:wt,onColumnReorder:U,onColumnOrderReset:W?void 0:()=>Pt(e.map(Z=>Z.field)),forceColumnsOpen:ht,onColumnsPanelClose:()=>Lt(!1),...se?.toolbar}},[J?.toolbar,W,Mt,en,We,T,F,Pt,_e.apiRef,e,Se,Tn,ie,z,q,Vt,Ln,ke,b,Ae,wt,ht,se?.toolbar]);return l.useEffect(()=>{if(!ht||J?.toolbar)return;function U(Z){const le=document.getElementById("ogx-standalone-col-panel");le&&!le.contains(Z.target)&&Lt(!1)}return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[ht,J?.toolbar]),r.jsxs("div",{ref:an,className:["ogx",ne,d&&"ogx--auto-height",ji&&"ogx--row-spanning",oe&&"ogx--list-view"].filter(Boolean).join(" "),style:{...de,height:H??de?.height,"--ogx-row-height":`${i}px`,"--ogx-header-height":`${s}px`},"aria-busy":ut,children:[Gn&&r.jsx(Qr,{...Gn}),!J?.toolbar&&r.jsx(dr,{isOpen:ht,containerRef:an,effectiveColumns:We,columnVisibilityModel:Ae,effectiveColumnOrder:Mt,columnOrder:T,disableColumnReorder:W,onClose:()=>Lt(!1),onColumnVisibilityChange:wt,onColumnOrderChange:F,setInternalColumnOrder:Pt}),oe&&we&&r.jsx(qo,{ariaLabel:je,allRenderableRows:on,filteredRows:ze,pagination:Ne,effectivePaginationModel:Ce,pageSizeOptions:S,selectedRowIds:ve,listViewColumn:we,noRowsLabel:$t,rowHeight:i,checkboxSelection:a,paginationMode:$,dataSource:ee,serverRowCount:fe.pagination.rowCount||0,paginationSlot:J?.pagination,paginationSlotProps:se?.pagination,onRowClick:Et,onSelectionChange:gt,onPaginationModelChange:Ut}),!oe&&r.jsx("div",{ref:U=>{Ye.current=U,kt.current=U},className:"ogx__viewport",onScroll:ci,role:"grid","aria-label":je||"Data grid","aria-rowcount":ze.length+1,"aria-colcount":e.length+(a?1:0)+(Me?1:0)+(R?1:0),"aria-busy":ut,tabIndex:0,onKeyDownCapture:()=>{Xe(!0)},onMouseDownCapture:()=>{Xe(!1)},onKeyDown:Ci,onFocus:vi,onBlur:_i,children:r.jsxs("div",{ref:ti,className:"ogx__content",style:{width:ye.totalWidth},role:"presentation",children:[r.jsx(xn,{columns:ye.virtualColumns,allColumns:We,columnGroupingModel:Fe,checkboxSelection:a,allSelected:ki,someSelected:Si,onSelectAll:wi,sortModel:Le,onSort:Dn,onColumnResize:xi,columnWidths:Pe,pinnedColumns:Re,focusedCell:Tt,onHeaderClick:U=>{ln({id:"HEADER",field:U}),Xe(!1),kt.current?.focus({preventScroll:!0})},onDragStart:Fe?void 0:tt.onDragStart,onDragOver:Fe?void 0:tt.onDragOver,onDragEnd:Fe?void 0:tt.onDragEnd,onDrop:Fe?void 0:tt.onDrop,draggedColumn:Fe?void 0:tt.draggedColumn,dragOverColumn:Fe?void 0:tt.dragOverColumn,rowReordering:R,hasDetailPanel:Me,pinCheckboxColumn:_,pinExpandColumn:P,aggregationModel:Se,onHideColumn:U=>{wt({...Ae,[U]:!1})},onManageColumns:()=>Lt(!0),onPinColumn:(U,Z)=>{const le=[...Re?.left??[]],xe=[...Re?.right??[]],pe=le.filter(be=>be!==U),me=xe.filter(be=>be!==U);Gt(Z==="left"?{left:[...pe,U],right:me}:Z==="right"?{left:pe,right:[...me,U]}:{left:pe,right:me})}}),!ut&&!fe.dataSource.error&&ze.length===0&&r.jsx(bo,{noRowsLabel:$t,width:ye.totalWidth}),r.jsx(_n,{rows:tn,position:"top",columns:ye.virtualColumns,selectedRowIds:ve,checkboxSelection:a,onRowClick:Et,onCellClick:sn,onSelectionChange:gt,columnWidths:Pe,pinnedColumns:Re,pinnedRows:g,hasDetailPanel:Me,expandedRowIds:et,getDetailPanelContent:x,getDetailPanelHeight:E,onDetailPanelToggle:Nt,pinCheckboxColumn:_,pinExpandColumn:P,focusedCell:Tt,colspanMap:rt.colspanMap,rowSpanningCaches:rt.rowSpanningState.caches,rowHeight:i}),r.jsx(lr,{virtualContainerHeight:ye.totalHeight-ye.pinnedTopHeight-ye.pinnedBottomHeight,offsetTop:ye.offsetTop,effectiveLoading:ut,visibleRows:yi,baseColumns:e,virtualColumns:ye.virtualColumns,viewportWidth:fe.dimensions.viewportWidth,checkboxSelection:a,hasDetailPanel:Me,rowReordering:R,rowHeight:i,pinnedRows:g,selectedRowIds:ve,onRowClick:Et,onCellClick:sn,onSelectionChange:gt,columnWidths:Pe,pinnedColumns:Re,expandedRowIds:et,getDetailPanelContent:x,getDetailPanelHeight:E,onDetailPanelToggle:Nt,pinCheckboxColumn:_,pinExpandColumn:P,rowReorderHandlers:mi,editingHandlers:Ze,focusedCell:Tt,colspanMap:rt.colspanMap,rowSpanningCaches:rt.rowSpanningState.caches,paginationMode:$,dataSourceLoading:fe.dataSource.loading,sortedUnpinnedRowCount:ot.length,infiniteScrollSkeletonCount:Math.min(Ce.pageSize,20),unpinnedRowsLength:he.unpinnedRowsLength}),r.jsx(_n,{rows:nn,position:"bottom",columns:ye.virtualColumns,selectedRowIds:ve,checkboxSelection:a,onRowClick:Et,onCellClick:sn,onSelectionChange:gt,columnWidths:Pe,pinnedColumns:Re,pinnedRows:g,hasDetailPanel:Me,expandedRowIds:et,getDetailPanelContent:x,getDetailPanelHeight:E,onDetailPanelToggle:Nt,pinCheckboxColumn:_,pinExpandColumn:P,focusedCell:Tt,colspanMap:rt.colspanMap,rowSpanningCaches:rt.rowSpanningState.caches,rowHeight:i}),It&&!ie&&r.jsx(mo,{columns:en,aggregationModel:Se,aggregationResult:rn,columnWidths:bi,rowHeight:i,checkboxSelection:a,hasDetailPanel:Me,rowReordering:R})]})}),!oe&&Ne&&(()=>{const U=J?.pagination||mn;return r.jsx(U,{page:Ce.page,pageSize:Ce.pageSize,rowCount:fe.pagination.rowCount,pageSizeOptions:S,onPageChange:Z=>Ut({...Ce,page:Z}),onPageSizeChange:Z=>Ut({...Ce,pageSize:Z,page:0}),...se?.pagination})})(),r.jsxs("div",{className:"ogx-aria-live-status",role:"status","aria-live":"polite",children:[ut?"Loading data...":"",fe.dataSource.error?`Error: ${fe.dataSource.error instanceof Error?fe.dataSource.error.message:"Unknown error"}`:"",!Y&&!fe.dataSource.error&&(ze.length===0?$t:ke&&((ke.quickFilterValues?.length||0)>0||(ke.items?.length||0)>0)?`${ze.length} ${ze.length===1?"row":"rows"} found`:"")]}),r.jsx(wo,{error:fe.dataSource.error})]})}function ur({rows:n=5,columns:t=5}){return r.jsx("div",{className:"ogx__skeleton",children:Array.from({length:n}).map((e,o)=>r.jsx("div",{className:"ogx__skeleton-row",children:Array.from({length:t}).map((i,s)=>r.jsx("div",{className:"ogx__skeleton-cell",children:r.jsx("div",{className:"ogx__skeleton-content"})},s))},o))})}const yn=new Set(["isEmpty","isNotEmpty"]);function fr(n,t){return n.find(e=>"field"in e&&e.field===t)}const gr=({col:n,item:t,onChange:e})=>{const o=lo(n.type),i=!!t,s=t?.operator??o[0],[d,a]=l.useState(t?.value!=null?String(t.value):""),u=l.useRef(e),c=l.useRef(t),f=l.useRef(n.field),m=l.useRef(s);l.useLayoutEffect(()=>{u.current=e,c.current=t,f.current=n.field,m.current=s});const p=l.useRef(t?.value);l.useEffect(()=>{t?.value!==p.current&&(p.current=t?.value,a(t?.value!=null?String(t.value):""))},[t?.value]),l.useEffect(()=>{const h=setTimeout(()=>{const S=c.current,y=S?.value??"";d!==y&&u.current({id:S?.id??`${f.current}-${Date.now()}`,field:f.current,operator:m.current,value:d})},300);return()=>clearTimeout(h)},[d]);const b=h=>{const S=yn.has(h),y={id:t?.id??`${n.field}-${Date.now()}`,field:n.field,operator:h,value:S?void 0:t?.value??(n.type==="boolean"?"true":"")};e(y)},v=()=>{a(""),e(null)},C=yn.has(String(s)),j=n.type==="boolean",I=!C;return r.jsxs("div",{className:`ogx-filter__row${i?" ogx-filter__row--active":""}`,children:[r.jsx("span",{className:"ogx-filter__col-label",title:n.field,children:n.headerName||n.field}),r.jsxs("div",{className:"ogx-filter__controls",children:[r.jsx("select",{id:`ogx-filter-op-${n.field}`,name:`filter-op-${n.field}`,className:`ogx-filter__op-select${i?" ogx-filter__op-select--active":""}`,value:String(s),onChange:h=>b(h.target.value),"aria-label":`Filter operator for ${n.headerName||n.field}`,children:o.map(h=>r.jsx("option",{value:h,children:h},h))}),I&&j&&r.jsxs("select",{id:`ogx-filter-val-${n.field}`,name:`filter-val-${n.field}`,className:`ogx-filter__value-input ogx-filter__value-select${i?" ogx-filter__value-input--active":""}`,value:String(t?.value??"true"),onChange:h=>{a(h.target.value),e({id:t?.id??`${n.field}-${Date.now()}`,field:n.field,operator:s,value:h.target.value})},"aria-label":`Filter value for ${n.headerName||n.field}`,children:[r.jsx("option",{value:"true",children:"true"}),r.jsx("option",{value:"false",children:"false"})]}),I&&!j&&r.jsx("input",{id:`ogx-filter-val-${n.field}`,name:`filter-val-${n.field}`,className:`ogx-filter__value-input${i?" ogx-filter__value-input--active":""}`,type:"text",value:d,onChange:h=>a(h.target.value),placeholder:n.type==="number"?"Number…":"Value…","aria-label":`Filter value for ${n.headerName||n.field}`}),i&&r.jsx("button",{className:"ogx-filter__row-clear",onClick:v,"aria-label":`Clear filter for ${n.headerName||n.field}`,title:"Clear",children:"×"})]})]})},kn=({filterModel:n,columns:t,onFilterModelChange:e})=>{const o=l.useMemo(()=>n.items??[],[n.items]),i=n.logicOperator??"and",s=l.useCallback((u,c)=>{const f=o.filter(p=>"field"in p&&p.field!==u),m=c?[...f,c]:f;e({...n,items:m})},[o,n,e]),d=l.useCallback(u=>{e({...n,logicOperator:u})},[n,e]),a=t.filter(u=>u.filterable!==!1);return r.jsxs(r.Fragment,{children:[o.length>1&&r.jsxs("div",{className:"ogx-filter__logic-bar",children:[r.jsx("span",{className:"ogx-filter__logic-label",children:"Match:"}),r.jsx("button",{className:`ogx-filter__logic-pill${i==="and"?" ogx-filter__logic-pill--active":""}`,onClick:()=>d("and"),"aria-pressed":i==="and",children:"ALL (AND)"}),r.jsx("button",{className:`ogx-filter__logic-pill${i==="or"?" ogx-filter__logic-pill--active":""}`,onClick:()=>d("or"),"aria-pressed":i==="or",children:"ANY (OR)"})]}),a.length===0?r.jsx("div",{className:"ogx-filter__empty",children:"No filterable columns."}):a.map(u=>r.jsx(gr,{col:u,item:fr(o,u.field),onChange:c=>s(u.field,c)},u.field))]})},hr=["sum","avg","count","min","max"];function Sn(){return r.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:[r.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),r.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),r.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),r.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1",fill:"currentColor",opacity:"0.25"}),r.jsx("path",{d:"M17 14v-4M17 10l-2 2 2 2"})]})}function pr({anchorRef:n,columns:t,model:e,onChange:o,onClose:i}){const s=l.useRef(null),[d,a]=l.useState({top:0,right:0}),[u,c]=l.useState(document.body);l.useLayoutEffect(()=>{c(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const f=l.useCallback(()=>{if(!n.current)return{top:0,right:0};const _=n.current.getBoundingClientRect();return{top:_.bottom+6,right:window.innerWidth-_.right}},[n]);l.useEffect(()=>{a(f());const _=()=>a(f());return window.addEventListener("scroll",_,!0),window.addEventListener("resize",_),()=>{window.removeEventListener("scroll",_,!0),window.removeEventListener("resize",_)}},[f]),l.useEffect(()=>{function _(W){s.current&&!s.current.contains(W.target)&&n.current&&!n.current.contains(W.target)&&i()}function P(W){W.key==="Escape"&&i()}return document.addEventListener("mousedown",_),document.addEventListener("keydown",P),()=>{document.removeEventListener("mousedown",_),document.removeEventListener("keydown",P)}},[n,i]);const m=new Set(e.rowFields),p=new Set(e.columnFields),b=new Set(e.valueFields.map(_=>_.field)),v=_=>m.has(_)||p.has(_)||b.has(_);function C(_){m.has(_)||o({...e,rowFields:[...e.rowFields,_]})}function j(_){p.has(_)||o({...e,columnFields:[...e.columnFields,_]})}function I(_,P="sum"){b.has(_)||o({...e,valueFields:[...e.valueFields,{field:_,aggFn:P}]})}function h(_){o({...e,rowFields:e.rowFields.filter(P=>P!==_)})}function S(_){o({...e,columnFields:e.columnFields.filter(P=>P!==_)})}function y(_){o({...e,valueFields:e.valueFields.filter(P=>P.field!==_)})}function w(_,P){o({...e,valueFields:e.valueFields.map(W=>W.field===_?{...W,aggFn:P}:W)})}function g(){o({rowFields:[],columnFields:[],valueFields:[]})}const x=new Set(t.filter(_=>_.type==="number"||_.aggregable).map(_=>_.field)),E=e.rowFields.length+e.columnFields.length+e.valueFields.length,M=_=>t.find(P=>P.field===_)?.headerName??_,N=r.jsxs("div",{ref:s,className:"ogx-pivot-panel",role:"dialog","aria-label":"Pivot configuration",style:{top:d.top,right:d.right},children:[r.jsxs("div",{className:"ogx-pivot-panel__header",children:[r.jsxs("span",{className:"ogx-pivot-panel__title",children:[r.jsx(Sn,{}),"Pivot Mode"]}),E>0&&r.jsx("button",{className:"ogx-pivot-panel__reset-btn",onClick:g,title:"Reset pivot",children:"Reset"})]}),r.jsxs("div",{className:"ogx-pivot-panel__body",children:[r.jsxs("div",{className:"ogx-pivot-zone",children:[r.jsxs("span",{className:"ogx-pivot-zone__label",children:[r.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--row"}),"Row Fields"]}),r.jsx("div",{className:`ogx-pivot-chips${e.rowFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — each becomes a row label",children:e.rowFields.map(_=>r.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--row",children:[M(_),r.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>h(_),title:`Remove ${M(_)}`,children:"×"})]},_))})]}),r.jsxs("div",{className:"ogx-pivot-zone",children:[r.jsxs("span",{className:"ogx-pivot-zone__label",children:[r.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--col"}),"Column Fields"]}),r.jsx("div",{className:`ogx-pivot-chips${e.columnFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — unique values become column headers",children:e.columnFields.map(_=>r.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--col",children:[M(_),r.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>S(_),title:`Remove ${M(_)}`,children:"×"})]},_))})]}),r.jsxs("div",{className:"ogx-pivot-zone",children:[r.jsxs("span",{className:"ogx-pivot-zone__label",children:[r.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--value"}),"Value Fields (aggregated)"]}),r.jsx("div",{className:`ogx-pivot-chips${e.valueFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add numeric fields here — values are aggregated",children:e.valueFields.map(_=>r.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--value",children:[M(_.field),r.jsx("select",{className:"ogx-pivot-chip__fn-select",value:_.aggFn,onChange:P=>w(_.field,P.target.value),title:"Aggregation function",children:hr.map(P=>r.jsx("option",{value:P,children:P.toUpperCase()},P))}),r.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>y(_.field),title:`Remove ${M(_.field)}`,children:"×"})]},_.field))})]}),r.jsx("hr",{className:"ogx-pivot-panel__divider"}),r.jsxs("div",{children:[r.jsx("div",{className:"ogx-pivot-panel__fields-label",children:"Available Fields"}),r.jsxs("div",{className:"ogx-pivot-fields",children:[t.map(_=>{const P=x.has(_.field);return v(_.field)?null:r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3},children:[r.jsx("span",{className:`ogx-pivot-field-btn${P?" ogx-pivot-field-btn--numeric":""}`,children:_.headerName??_.field}),r.jsxs("div",{className:"ogx-pivot-field-actions",children:[r.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--row",onClick:()=>C(_.field),title:"Add to Row Fields",children:"Row"}),r.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--col",onClick:()=>j(_.field),title:"Add to Column Fields",children:"Col"}),P&&r.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--value",onClick:()=>I(_.field),title:"Add to Value Fields",children:"Val"})]})]},_.field)}),t.every(_=>v(_.field))&&r.jsx("span",{style:{fontSize:12,color:"var(--ogx-color-gray-400, #94a3b8)"},children:"All fields are in use."})]})]})]})]});return Oe.createPortal(N,u)}function xr(){return r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function mr(){return r.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function br({value:n="",onChange:t,placeholder:e="Search...",debounceMs:o=250}){const[i,s]=l.useState(()=>n.length>0),[d,a]=l.useState(n),u=l.useRef(null),c=l.useRef(null),f=l.useRef(t);l.useLayoutEffect(()=>{f.current=t},[t]);const m=l.useRef(n),p=l.useRef(n),b=l.useRef(!1);l.useLayoutEffect(()=>{b.current&&document.activeElement!==u.current&&u.current?.focus()}),l.useEffect(()=>{n!==p.current&&(p.current=n,n!==m.current&&(a(n),m.current=n,n?s(!0):(b.current=!1,s(!1))))},[n]),l.useEffect(()=>{const h=setTimeout(()=>{d!==m.current&&(m.current=d,f.current(d))},o);return()=>clearTimeout(h)},[d,o]);const v=l.useCallback(()=>{s(!0),requestAnimationFrame(()=>u.current?.focus())},[]),C=l.useCallback(h=>{h.stopPropagation(),a(""),m.current="",f.current(""),u.current?.focus()},[]),j=l.useCallback(()=>{b.current=!0,s(!0)},[]),I=l.useCallback(()=>{b.current=!1,setTimeout(()=>{if(c.current&&document.activeElement&&c.current.contains(document.activeElement)){b.current=!0;return}d||s(!1)},150)},[d]);return l.useEffect(()=>{const h=S=>{c.current&&!c.current.contains(S.target)&&(d||s(!1))};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[d]),r.jsxs("div",{ref:c,className:`ogx-global-search${i?" ogx-global-search--expanded":""}`,onClick:i?void 0:v,children:[r.jsx("div",{className:"ogx-global-search__icon-wrapper",children:r.jsx(xr,{})}),r.jsx("input",{ref:u,id:"ogx-global-search-input",name:"ogx-global-search",className:"ogx-global-search__input",value:d,onChange:h=>a(h.target.value),onFocus:j,onBlur:I,placeholder:e,"aria-label":"Global Search",autoComplete:"off"}),d&&r.jsx("button",{className:"ogx-global-search__clear",onClick:C,"aria-label":"Clear search",children:r.jsx(mr,{})})]})}function ct({title:n,children:t,placement:e="top",enterDelay:o=200,leaveDelay:i=0}){const[s,d]=l.useState(!1),[a,u]=l.useState({top:0,left:0}),c=l.useRef(null),f=l.useRef(null),m=l.useCallback(()=>{if(!f.current)return;const C=f.current.getBoundingClientRect();let j=0,I=0;const h=window.pageXOffset||document.documentElement.scrollLeft,S=window.pageYOffset||document.documentElement.scrollTop;e==="top"?(j=C.top+S-8,I=C.left+h+C.width/2):e==="bottom"&&(j=C.bottom+S+8,I=C.left+h+C.width/2),u({top:j,left:I})},[e]);l.useLayoutEffect(()=>(s&&(m(),window.addEventListener("scroll",m,!0),window.addEventListener("resize",m)),()=>{window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m)}),[s,m]);const p=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{d(!0)},o)},b=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{d(!1)},i)},v=l.useCallback(C=>{f.current=C?C.firstElementChild??C:null},[]);return r.jsxs(r.Fragment,{children:[r.jsx("span",{ref:v,style:{display:"inline-block",lineHeight:0},onMouseEnter:p,onMouseLeave:b,children:t}),s&&n&&Oe.createPortal(r.jsx("div",{className:`ogx-tooltip ogx-tooltip--${e}`,style:{top:a.top,left:a.left,position:"absolute",zIndex:99999},children:n}),document.body)]})}const wr=["none","sum","avg","count","min","max"];function jn(){return r.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:r.jsx("path",{d:"M18 4H6l6 8-6 8h12"})})}function vr(){return r.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",children:[r.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),r.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.25"}),r.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),r.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),r.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),r.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function En(){return r.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})})}function _r({anchorRef:n,aggregationModel:t,aggregableColumns:e,onFunctionChange:o,onClearAll:i,onClose:s,activeCount:d}){const a=l.useRef(null),[u,c]=l.useState({top:0,right:0}),[f,m]=l.useState(document.body);l.useLayoutEffect(()=>{m(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const p=l.useCallback(()=>{if(!n.current)return{top:0,right:0};const v=n.current.getBoundingClientRect();return{top:v.bottom+6,right:window.innerWidth-v.right}},[n]);l.useEffect(()=>{c(p());const v=()=>c(p());return window.addEventListener("scroll",v,!0),window.addEventListener("resize",v),()=>{window.removeEventListener("scroll",v,!0),window.removeEventListener("resize",v)}},[p]),l.useEffect(()=>{function v(C){a.current&&!a.current.contains(C.target)&&n.current&&!n.current.contains(C.target)&&s()}return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[n,s]),l.useEffect(()=>{function v(C){C.key==="Escape"&&s()}return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[s]);const b=r.jsxs("div",{ref:a,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Summaries configuration",style:{top:u.top,right:u.right,width:400,maxWidth:"calc(100vw - 24px)"},children:[r.jsxs("div",{className:"ogx-toolbar__panel-header",children:[r.jsxs("span",{className:"ogx-toolbar__panel-title",children:[r.jsx(jn,{}),"Summaries"]}),d>0&&r.jsx("button",{className:"ogx-toolbar__clear-btn",onClick:i,title:"Clear all summaries",children:"Clear all"})]}),r.jsx("div",{className:"ogx-toolbar__panel-body",children:e.length===0?r.jsxs("p",{className:"ogx-toolbar__empty",children:["No aggregable columns.",r.jsx("br",{}),"Set ",r.jsx("code",{children:"aggregable: true"})," on a column to enable."]}):e.map(v=>{const C=t[v.field]||"none";return r.jsxs("div",{className:"ogx-toolbar__agg-row",children:[r.jsx("span",{className:"ogx-toolbar__agg-label",title:v.field,children:v.headerName||v.field}),r.jsx("div",{className:"ogx-toolbar__agg-pills",children:wr.map(j=>r.jsx("button",{className:`ogx-toolbar__pill${C===j?" ogx-toolbar__pill--active":""}`,onClick:()=>o(v.field,j),"aria-pressed":C===j,children:j},j))})]},v.field)})})]});return Oe.createPortal(b,f)}function Cr({anchorRef:n,columns:t,visibleColumns:e,onVisibilityChange:o,onShowAll:i,onHideAll:s,onColumnReorder:d,onColumnOrderReset:a,onClose:u}){const c=l.useRef(null),[f,m]=l.useState({top:0,right:0}),[p,b]=l.useState(document.body);l.useLayoutEffect(()=>{b(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const v=l.useCallback(()=>{if(!n.current)return{top:0,right:0};const j=n.current.getBoundingClientRect();return{top:j.bottom+6,right:window.innerWidth-j.right}},[n]);l.useEffect(()=>{m(v());const j=()=>m(v());return window.addEventListener("scroll",j,!0),window.addEventListener("resize",j),()=>{window.removeEventListener("scroll",j,!0),window.removeEventListener("resize",j)}},[v]),l.useEffect(()=>{function j(I){c.current&&!c.current.contains(I.target)&&n.current&&!n.current.contains(I.target)&&u()}return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[n,u]);const C=r.jsx("div",{ref:c,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Column visibility",style:{top:f.top,right:f.right,width:280,padding:0},children:r.jsx(Cn,{columns:t,visibleColumns:e,onVisibilityChange:o,onShowAll:i,onHideAll:s,onColumnReorder:d,onColumnOrderReset:a})});return Oe.createPortal(C,p)}function yr({anchorRef:n,columns:t,filterModel:e,onFilterModelChange:o,onClose:i}){const s=l.useRef(null),[d,a]=l.useState({top:0,right:0}),u=l.useRef(i);l.useLayoutEffect(()=>{u.current=i},[i]);const[c,f]=l.useState(document.body);l.useLayoutEffect(()=>{f(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const m=l.useCallback(()=>{if(!n.current)return{top:0,right:0};const C=n.current.getBoundingClientRect();return{top:C.bottom+6,right:window.innerWidth-C.right}},[n]);l.useEffect(()=>{a(m());const C=()=>a(m());return window.addEventListener("scroll",C,!0),window.addEventListener("resize",C),()=>{window.removeEventListener("scroll",C,!0),window.removeEventListener("resize",C)}},[m]),l.useEffect(()=>{function C(j){j.key==="Escape"&&u.current()}return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[]);const p=e.items?.length??0,b=()=>{o({...e,items:[],logicOperator:"and"})},v=r.jsxs("div",{ref:s,className:"ogx-toolbar__panel ogx-toolbar__panel--filter",role:"dialog","aria-label":"Advanced filters",style:{top:d.top,right:d.right,width:540,maxWidth:"calc(100vw - 24px)"},children:[r.jsxs("div",{className:"ogx-toolbar__panel-header",children:[r.jsxs("span",{className:"ogx-toolbar__panel-title",children:[r.jsx(En,{}),"Filters",p>0&&r.jsx("span",{className:"ogx-toolbar__panel-count",children:p})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[p>0&&r.jsx("button",{className:"ogx-toolbar__clear-btn",onClick:b,title:"Clear all filters",children:"Clear all"}),r.jsx("button",{className:"ogx-toolbar__close-btn",onClick:()=>u.current(),title:"Close filters","aria-label":"Close filters panel",children:"Close"})]})]}),r.jsx("div",{className:"ogx-toolbar__panel-body ogx-toolbar__panel-body--filter",children:r.jsx(kn,{columns:t,filterModel:e,onFilterModelChange:o})})]});return Oe.createPortal(v,c)}const kr={rowFields:[],columnFields:[],valueFields:[]};function Sr({columns:n=[],baseColumns:t,aggregationModel:e={},onAggregationModelChange:o,pivotModel:i,onPivotModelChange:s,filterModel:d,onFilterModelChange:a,columnVisibilityModel:u={},onColumnVisibilityModelChange:c,onColumnReorder:f,onColumnOrderReset:m,forceColumnsOpen:p,onColumnsPanelClose:b,children:v,rightContent:C,style:j,renderColumnsButton:I,renderFilterButton:h,renderAggregationButton:S,renderExportButton:y,renderQuickFilter:w,className:g}){const[x,E]=l.useState(!1),[M,N]=l.useState(!1),[_,P]=l.useState(!1),[W,T]=l.useState(!1);l.useEffect(()=>{p&&(P(!0),E(!1),N(!1),T(!1))},[p]);const F=l.useRef(null),H=l.useRef(null),R=l.useRef(null),G=l.useRef(null),Y=l.useRef(null),V=l.useRef(null),k=l.useRef(null),B=i??kr,O=B.rowFields.length>0||B.columnFields.length>0||B.valueFields.length>0,A=n.filter(J=>J.aggregable!==!1&&(J.type==="number"||J.aggregable===!0)),D=Object.keys(e).filter(J=>e[J]&&e[J]!=="none").length,X=l.useCallback((J,se)=>{if(!o)return;const ie={...e};se==="none"?delete ie[J]:ie[J]=se,o(ie)},[e,o]),K=l.useCallback(()=>{o?.({})},[o]),L=l.useCallback(J=>{if(!a)return;const ie={...d||{},quickFilterValues:J?[J]:[],items:d?.items||[]};a(ie)},[d,a]),te=d?.quickFilterValues?.[0]||"",ee=d?.items?.length||0,Q=new Set(n.filter(J=>u[J.field]!==!1).map(J=>J.field)),ce=l.useCallback((J,se)=>{if(!c)return;const ie={...u,[J]:se};c(ie)},[u,c]),$=l.useCallback(()=>{if(!c)return;const J={...u};n.forEach(se=>{se.hideable!==!1&&(J[se.field]=!0)}),c(J)},[n,u,c]),ae=l.useCallback(()=>{if(!c)return;const J={...u};n.forEach(se=>{se.hideable!==!1&&(J[se.field]=!1)}),c(J)},[n,u,c]);return r.jsxs("div",{className:["ogx-toolbar",g].filter(Boolean).join(" "),role:"toolbar","aria-label":"Grid toolbar",style:j,children:[v&&r.jsx("div",{className:"ogx-toolbar__left",children:v}),r.jsx("div",{className:"ogx-toolbar__spacer"}),r.jsxs("div",{className:"ogx-toolbar__actions",children:[a&&r.jsx("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:w?w({value:te,onChange:L}):r.jsx(br,{value:te,onChange:L,placeholder:"Search..."})}),c&&r.jsxs("div",{ref:Y,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[I?I({onClick:()=>{P(J=>!J),E(!1),N(!1),T(!1)},isOpen:_,activeCount:n.length-Q.size}):r.jsx(ct,{title:"Columns",children:r.jsx("button",{ref:R,className:`ogx-toolbar__icon-btn${_?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Manage columns",onClick:()=>{P(!_),E(!1),N(!1),T(!1)},children:r.jsx(vr,{})})}),_&&r.jsx(Cr,{anchorRef:I?Y:R,columns:n,visibleColumns:Q,onVisibilityChange:ce,onShowAll:$,onHideAll:ae,onColumnReorder:f,onColumnOrderReset:m,onClose:()=>{P(!1),b?.()}})]}),a&&r.jsxs("div",{ref:V,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[h?h({onClick:()=>{T(J=>!J),E(!1),N(!1),P(!1)},isOpen:W,activeCount:ee}):r.jsx(ct,{title:"Filters",children:r.jsxs("button",{ref:G,className:`ogx-toolbar__icon-btn${W?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Advanced filters",onClick:()=>{T(!W),E(!1),N(!1),P(!1)},children:[r.jsx(En,{}),ee>0&&r.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Filters active"})]})}),W&&r.jsx(yr,{anchorRef:h?V:G,columns:n,filterModel:d||{items:[]},onFilterModelChange:a,onClose:()=>T(!1)})]}),s&&r.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[r.jsx(ct,{title:"Pivot",children:r.jsxs("button",{ref:H,id:"ogx-pivot-btn",className:`ogx-toolbar__icon-btn${M?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure pivot","aria-expanded":M,"aria-controls":"ogx-pivot-panel",onClick:()=>{N(!M),E(!1),P(!1),T(!1)},children:[r.jsx(Sn,{}),O&&r.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Pivot active"})]})}),M&&r.jsx(pr,{anchorRef:H,columns:t??n,model:B,onChange:J=>{s?.(J)},onClose:()=>N(!1)})]}),r.jsxs("div",{ref:k,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[S?S({onClick:()=>{E(J=>!J),N(!1),P(!1),T(!1)},isOpen:x,activeCount:D}):r.jsx(ct,{title:"Summaries",children:r.jsxs("button",{ref:F,id:"ogx-aggregation-btn",className:`ogx-toolbar__icon-btn${x?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure summaries","aria-expanded":x,"aria-controls":"ogx-aggregation-panel",onClick:()=>{E(!x),N(!1),P(!1),T(!1)},children:[r.jsx(jn,{}),D>0&&r.jsx("span",{className:"ogx-toolbar__dot","aria-label":`${D} active summaries`})]})}),x&&r.jsx(_r,{anchorRef:S?k:F,aggregationModel:e,aggregableColumns:A,onFunctionChange:X,onClearAll:K,onClose:()=>E(!1),activeCount:D})]}),y&&y(),C]})]})}function jr(){return l.useRef(null)}const Er=({fullWidth:n=!1,error:t=!1,startAdornment:e,endAdornment:o,className:i="",...s})=>{const d=["ogx-input-wrapper",n&&"ogx-input-wrapper--full-width",t&&"ogx-input-wrapper--error",s.disabled&&"ogx-input-wrapper--disabled",i].filter(Boolean).join(" ");return r.jsxs("div",{className:d,children:[e&&r.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--start",children:e}),r.jsx("input",{className:"ogx-input",...s}),o&&r.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--end",children:o})]})};function Nr(n,t,e={}){const{fileName:o="export.csv",includeHeaders:i=!0,delimiter:s=",",selectedRows:d}=e,a=d&&d.length>0?n.filter(f=>d.includes(f.id)):n;if(a.length===0){console.warn("No rows to export");return}const u=t.filter(f=>!(f.exportable===!1||f.field==="__check__"||f.field==="__actions__"));let c="";if(i){const f=u.map(m=>Ge(m.headerName||m.field));c+=f.join(s)+`
|
|
9
|
-
`}if(a.forEach(
|
|
10
|
-
`}),e.aggregationResult){const
|
|
11
|
-
`;const
|
|
12
|
-
`}
|
|
13
|
-
`)?`"${n.replace(/"/g,'""')}"`:n}function
|
|
6
|
+
<%s key={someKey} {...props} />`,$,U,te,U),K[U+$]=!0)}if(U=null,z!==void 0&&(e(z),U=""+z),d(O)&&(e(O.key),U=""+O.key),"key"in O){z={};for(var R in O)R!=="key"&&(z[R]=O[R])}else z=O;return U&&a(z,typeof y=="function"?y.displayName||y.name||"Unknown":y),c(y,U,z,l(),H,X)}function b(y){h(y)?y._store&&(y._store.validated=1):typeof y=="object"&&y!==null&&y.$$typeof===M&&(y._payload.status==="fulfilled"?h(y._payload.value)&&y._payload.value._store&&(y._payload.value._store.validated=1):y._store&&(y._store.validated=1))}function h(y){return typeof y=="object"&&y!==null&&y.$$typeof===_}var m=i,_=Symbol.for("react.transitional.element"),C=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),P=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),w=Symbol.for("react.consumer"),E=Symbol.for("react.context"),g=Symbol.for("react.forward_ref"),x=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),k=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),v=Symbol.for("react.client.reference"),I=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L=Object.prototype.hasOwnProperty,W=Array.isArray,A=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(y){return y()}};var G,T={},B=m.react_stack_bottom_frame.bind(m,s)(),Y=A(o(s)),K={};at.Fragment=S,at.jsx=function(y,O,z){var $=1e4>I.recentlyCreatedOwnerStacks++;return p(y,O,z,!1,$?Error("react-stack-top-frame"):B,$?A(o(y)):Y)},at.jsxs=function(y,O,z){var $=1e4>I.recentlyCreatedOwnerStacks++;return p(y,O,z,!0,$?Error("react-stack-top-frame"):B,$?A(o(y)):Y)}})()),at}var xn;function Zn(){return xn||(xn=1,process.env.NODE_ENV==="production"?_t.exports=Jn():_t.exports=Qn()),_t.exports}var r=Zn();function dt(n,t){return t?t.left?.includes(n)?"left":t.right?.includes(n)?"right":null:null}function eo(n,t){const e=[],o=[],l=[];return t?(n.forEach(s=>{const d=dt(s.field,t);d==="left"?e.push(s):d==="right"?l.push(s):o.push(s)}),t.left&&e.sort((s,d)=>{const a=t.left.indexOf(s.field),u=t.left.indexOf(d.field);return a-u}),t.right&&l.sort((s,d)=>{const a=t.right.indexOf(s.field),u=t.right.indexOf(d.field);return a-u}),{left:e,center:o,right:l}):{left:e,center:n,right:l}}function Bt(n,t,e,o,l,s,d,a){const u={};if(!e)return u;const c=eo(n,e);let p=0;a&&(p+=48),s&&d&&(p+=48),o&&l&&(p+=48),c.left.forEach(h=>{u[h.field]=p;const m=t[h.field]??h.width??100;p+=m});let b=0;return[...c.right].reverse().forEach(h=>{const m=t[h.field]??h.width??100;u[h.field]=b,b+=m}),u}function $t(n,t){return t?t.top?.includes(n)?"top":t.bottom?.includes(n)?"bottom":null:null}function to(n,t){const e=[],o=[],l=[];return t?(n.forEach(s=>{const d=$t(s.id,t);d==="top"?e.push(s):d==="bottom"?l.push(s):o.push(s)}),t.top&&e.sort((s,d)=>{const a=t.top.indexOf(s.id),u=t.top.indexOf(d.id);return a-u}),t.bottom&&l.sort((s,d)=>{const a=t.bottom.indexOf(s.id),u=t.bottom.indexOf(d.id);return a-u}),{top:e,center:o,bottom:l}):{top:e,center:n,bottom:l}}function He(n){if(n===void 0)return{type:"auto",value:0};if(typeof n=="number")return{type:"fixed",value:n};if(typeof n=="string"){if(n.toLowerCase()==="auto")return{type:"auto",value:0};if(n.endsWith("%"))return{type:"percentage",value:parseFloat(n)};const t=parseFloat(n);if(!isNaN(t))return{type:"fixed",value:t}}return{type:"fixed",value:100}}function no(n){const{rowHeight:t,pagination:e,paginatedUnpinnedRows:o,sortedUnpinnedRows:l,expandedRowIds:s,getDetailPanelHeight:d,pinnedTopRowsLength:a,pinnedBottomRowsLength:u,visibleOrderedColumns:c,pinnedColumns:p,columnWidths:b,viewportWidth:h,checkboxSelection:m,hasDetailPanel:_,rowReordering:C,paginationMode:S,isLoading:P,pageSize:j}=n;return i.useMemo(()=>{const w=e?o:l,E=w.map((D,q)=>{let ee=t;if(s.has(D.id)){const de=d?.({row:D,id:D.id,rowIndex:a+q})??200;ee+=typeof de=="number"?de:parseInt(String(de),10)||200}return ee}),g=E.reduce((D,q,ee)=>(D.push((D[ee-1]||0)+q),D),[]),x=S==="infinite"&&P&&w.length>0?Math.min(j,20):0,f=(g[g.length-1]||0)+x*t,k=a*t,M=u*t,N=[],v=[],I=[],L=[];c.forEach(D=>{const q=dt(D.field,p);q==="left"?N.push(D):q==="right"?v.push(D):I.push(D)});const W=(m?48:0)+(_?48:0)+(C?48:0),A=D=>b[D.field]??D.width,G=N.reduce((D,q)=>{const ee=He(A(q));return D+(ee.type==="fixed"?ee.value:100)},0),T=v.reduce((D,q)=>{const ee=He(A(q));return D+(ee.type==="fixed"?ee.value:100)},0),B=I.reduce((D,q)=>{if(!Object.prototype.hasOwnProperty.call(b,q.field)&&q.flex&&q.flex>0){const ce=q.minWidth??150,je=typeof q.width=="number"?q.width:150;return D+(ce||je)}const de=He(A(q));return de.type==="fixed"?D+de.value:de.type==="percentage"?D+100:D+(q.minWidth??150)},0),Y=Math.max(h-W-G-T,B),K=[],y=[],O=[];I.forEach(D=>{const q=Object.prototype.hasOwnProperty.call(b,D.field),ee=He(A(D));if(!q&&D.flex&&D.flex>0){O.push({col:D,flex:D.flex});return}ee.type==="fixed"?K.push({col:D,width:ee.value}):ee.type==="percentage"?y.push({col:D,percentage:ee.value}):O.push({col:D,flex:1})});const z=K.reduce((D,{width:q})=>D+q,0);let $=Math.max(0,Y-z);const H=new Map;y.forEach(({col:D,percentage:q})=>{const ee=q/100*$;H.set(D.field,ee),$-=ee}),$=Math.max(0,$);const X=new Map,U=O.map(D=>({...D,minWidth:D.col.minWidth??50,maxWidth:D.col.maxWidth??1/0,frozen:!1,computedWidth:0}));(()=>{let D=0;const q=U.length*2;for(;D<q;){D++;const ee=U.filter(ne=>!ne.frozen);if(ee.length===0)break;const de=ee.reduce((ne,we)=>ne+we.flex,0),ce=U.reduce((ne,we)=>we.frozen?ne+we.computedWidth:ne,0),je=Math.max(0,$-ce);if(de<=0){ee.forEach(ne=>{ne.computedWidth=ne.minWidth,ne.frozen=!0});break}const We=je/de;let Ee=0;const fe=[],Ye=[];if(ee.forEach(ne=>{const we=We*ne.flex;we<ne.minWidth?(Ee+=ne.minWidth-we,fe.push(ne)):we>ne.maxWidth?(Ee+=ne.maxWidth-we,Ye.push(ne)):ne.computedWidth=we}),fe.length===0&&Ye.length===0){ee.forEach(ne=>ne.frozen=!0);break}Ee>0?fe.forEach(ne=>{ne.computedWidth=ne.minWidth,ne.frozen=!0}):Ee<0?Ye.forEach(ne=>{ne.computedWidth=ne.maxWidth,ne.frozen=!0}):(fe.forEach(ne=>{ne.computedWidth=ne.minWidth,ne.frozen=!0}),Ye.forEach(ne=>{ne.computedWidth=ne.maxWidth,ne.frozen=!0}))}})(),U.forEach(D=>X.set(D.col.field,D.computedWidth));const R=new Map;I.forEach(D=>{let q;if(X.has(D.field))q=X.get(D.field);else{const ee=K.find(ce=>ce.col.field===D.field),de=y.find(ce=>ce.col.field===D.field);if(ee)q=ee.width;else if(de){const ce=H.get(D.field)||0;q=Math.max(D.minWidth??50,ce||100)}else q=100}L.push(q),R.set(D.field,q)});const J=I.map(D=>{const q=U.find(ee=>ee.col.field===D.field);return{...D,width:R.get(D.field)??(typeof D.width=="number"?D.width:100),flex:q?q.flex:D.flex}}),Q=11,le=N.map((D,q)=>{const ee=He(A(D));return{...D,width:ee.type==="fixed"?ee.value:100,zIndex:Q+q}}),oe=11,pe=v.map((D,q)=>{const ee=He(A(D));return{...D,width:ee.type==="fixed"?ee.value:100,zIndex:oe+(v.length-1-q)}}),F=L.reduce((D,q)=>D+q,0),ie=G+F+T+W,se=L.reduce((D,q,ee)=>(D.push((D[ee-1]||0)+q),D),[]);return{rowHeights:E,cumulativeHeights:g,unpinnedRowsHeight:f,pinnedTopHeight:k,pinnedBottomHeight:M,leftPinnedCols:le,rightPinnedCols:pe,unpinnedColsWithWidth:J,unpinnedColWidths:L,unpinnedAccWidths:se,totalWidth:ie,leftWidth:G,rightWidth:T,unpinnedTotalWidth:F,systemColumnsWidth:W,pinnedTopRowsLength:a,pinnedBottomRowsLength:u,unpinnedRowsLength:w.length}},[t,e,o,l,s,d,a,u,c,p,b,h,m,_,C,S,P,j])}function oo(n){const{allRenderableRows:t,navigationColumns:e,checkboxSelection:o,selectedRowIds:l,handleSelectionChange:s,handleDetailPanelToggle:d,editingHandlers:a,setKeyboardMode:u,sortModel:c,handleSort:p,isCellEditable:b,pagination:h,pageSize:m,virtualization:_,viewportRef:C}=n,[S,P]=i.useState(null),j=i.useCallback(g=>{g.target===g.currentTarget&&P(x=>{if(x)return x;if(o)return{id:"HEADER",field:"__checkbox_col__"};const f=t[0],k=e[0];return f&&k?{id:f.id,field:k.field}:null})},[t,e,o]),w=i.useCallback(g=>{g.currentTarget.contains(g.relatedTarget)||P(null)},[]),E=i.useCallback(g=>{if(u(!0),!S)return;const{id:x,field:f}=S,k=!!a.editingCell;if(x==="HEADER"&&(g.key==="Enter"||g.key===" ")){g.preventDefault();const T=e.find(B=>B.field===f);if(T&&T.sortable!==!1){const B=c.find(K=>K.field===f);let Y="asc";B&&(Y=B.sort==="asc"?"desc":null),p(f,Y)}return}if(g.key==="Enter"){if(g.preventDefault(),k)a.stopCellEdit();else if(e.find(B=>B.field===f)?.editable){const B=t.find(Y=>Y.id===x);B&&a.startCellEdit({id:x,field:f,value:B[f]})}return}if((g.key===" "||g.key==="Spacebar")&&!k){if(f==="__checkbox_col__"){g.preventDefault(),s(x,!l.has(x));return}if(f==="__expand_col__"){g.preventDefault(),d(x);return}}if(g.key==="Escape"){k&&(g.preventDefault(),a.stopCellEdit({cancel:!0}));return}if(k&&g.key!=="Tab")return;const M=x==="HEADER",N=M?-1:t.findIndex(T=>T.id===x),v=e.findIndex(T=>T.field===f);if(!M&&N===-1||v===-1)return;const I=(T,B,Y,K,y,O=!1)=>{let z=T+Y,$=B+K;return y&&K!==0&&(K>0&&$>=e.length?($=0,z++):K<0&&$<0&&($=e.length-1,z--)),!y&&($<0||$>=e.length)||z<(O?-1:0)||z>=t.length?null:{r:z,c:$}},L=(T,B,Y,K,y,O=!1)=>{let z=T,$=B,H=0;const X=t.length*e.length+e.length;for(;H<X;){if(H++,z+=Y,$+=K,K!==0)K>0?$>=e.length&&($=0,z++):$<0&&($=e.length-1,z--);else if($<0||$>=e.length)return null;if(z<-1||z>=t.length)return null;if(z===-1){if(!O)continue;const Q=e[$],le=Q.sortable!==!1;if(["__checkbox_col__"].includes(Q.field)||le)return{r:z,c:$};continue}const U=t[z],te=e[$],R=["__checkbox_col__","__expand_col__","__reorder_col__"].includes(te.field);let J=te.editable||R;if(b&&!R)try{J=b({row:U,field:te.field,value:U[te.field],colDef:te,rowIndex:z,colIndex:$})}catch{}if(J)return{r:z,c:$}}return null};let W=N,A=v,G=!1;if(g.key==="Tab"){const T=g.shiftKey?-1:1,B=L(N,v,0,T,!0,!1);B&&(W=B.r,A=B.c,G=!0)}else if(g.key==="ArrowRight"){const T=I(N,v,0,1,!0,!0);T&&(W=T.r,A=T.c,G=!0)}else if(g.key==="ArrowLeft"){const T=I(N,v,0,-1,!0,!0);T&&(W=T.r,A=T.c,G=!0)}else if(g.key==="ArrowDown"){const T=I(N,v,1,0,!1,!0);T&&(W=T.r,A=T.c,G=!0)}else if(g.key==="ArrowUp"){const T=I(N,v,-1,0,!1,!0);T&&(W=T.r,A=T.c,G=!0)}else if(g.key==="Home")A=0,(g.ctrlKey||g.metaKey)&&(W=-1),G=!0;else if(g.key==="End")A=e.length-1,(g.ctrlKey||g.metaKey)&&(W=t.length-1),G=!0;else if(g.key==="PageUp")W=Math.max(-1,W-(h?m:10)),G=!0;else if(g.key==="PageDown"){const T=h?m:10;W=Math.min(t.length-1,W+T),G=!0}if(G&&(g.preventDefault(),k&&g.key==="Tab"&&a.stopCellEdit(),W>=-1&&W<t.length&&A>=0&&A<e.length)){const T=e[A];P(W===-1?{id:"HEADER",field:T.field}:{id:t[W].id,field:T.field});const B=C.current;if(B){const{cumulativeHeights:Y,pinnedTopHeight:K,columnMetrics:y}=_,{clientHeight:O,clientWidth:z,scrollTop:$,scrollLeft:H}=B,X=W<=0?0:Y[W-1],U=Y[W],te=$+K,R=$+O;let J=$;if(X<te?J=Math.max(0,X-K):U>R&&(J=U-O),J!==$&&(B.scrollTop=J),y){const{leftPinnedWidth:Q,rightPinnedWidth:le,unpinnedAccWidths:oe,unpinnedCols:pe,totalSpecialsWidth:F,pinnedSpecialsWidth:ie}=y,se=pe.findIndex(D=>D.field===T.field);if(se!==-1){const D=F+Q+(se>0?oe[se-1]:0),q=F+Q+oe[se],ee=H+ie+Q,de=H+z-le;let ce=H;D<ee?ce=Math.max(0,D-ie-Q):q>de&&(ce=q-z+le),ce!==H&&(B.scrollLeft=ce)}}}}},[S,t,e,a,_,l,s,d,u,c,p,b,h,m,C]);return{focusedCell:S,setFocusedCell:P,handleFocus:j,handleBlur:w,handleKeyDown:E}}const ro={rowFields:[],columnFields:[],valueFields:[]};function io(n){const{initialState:t,sortModel:e,aggregationModel:o,onAggregationModelChange:l,columnVisibilityModel:s,onColumnVisibilityModelChange:d,pinnedColumns:a,onPinnedColumnsChange:u,pivotModel:c,onPivotModelChange:p,paginationModel:b={page:0,pageSize:100},onPaginationModelChange:h,rowSelectionModel:m}=n,[_,C]=i.useState(()=>t?.sorting?.sortModel??[]),S=e!==void 0,P=S?e:_,j=o!==void 0,[w,E]=i.useState(()=>o??{}),g=j?o:w,x=i.useCallback(Q=>{j||E(Q),l?.(Q)},[j,l]),f=s!==void 0,[k,M]=i.useState(()=>t?.columns?.columnVisibilityModel??{}),N=f?s:k,v=i.useCallback(Q=>{f||M(Q),d?.(Q)},[f,d]),I=a!==void 0,[L,W]=i.useState(()=>t?.columns?.pinnedColumns??{}),A=I?a:L,G=i.useCallback(Q=>{I||W(Q),u?.(Q)},[I,u]),[T,B]=i.useState(()=>c??ro),Y=c??T,K=i.useCallback(Q=>{B(Q),p?.(Q)},[p]),y=b!==void 0&&n.paginationModel!==void 0,[O,z]=i.useState(()=>t?.pagination?.paginationModel??b),$=y?b:O,H=i.useCallback(Q=>{y||z(Q),h?.(Q)},[y,h]),X=m!==void 0,[U,te]=i.useState([]),R=X?m:U,J=i.useMemo(()=>new Set(R),[R]);return{sortModel:P,isSortControlled:S,setInternalSortModel:C,aggregationModel:g,handleAggregationModelChange:x,columnVisibilityModel:N,handleColumnVisibilityModelChange:v,pinnedColumns:A,handlePinnedColumnsChange:G,currentPivotModel:Y,handlePivotModelChange:K,effectivePaginationModel:$,handlePaginationModelChange:H,rowSelectionModel:R,selectedRowIds:J,isSelectionControlled:X,setInternalRowSelectionModel:te}}const lo={contains:(n,t)=>n==null||t==null?!1:String(n).toLowerCase().includes(String(t).toLowerCase()),equals:(n,t)=>n==null&&t==null?!0:n==null||t==null?!1:String(n).toLowerCase()===String(t).toLowerCase(),startsWith:(n,t)=>n==null||t==null?!1:String(n).toLowerCase().startsWith(String(t).toLowerCase()),endsWith:(n,t)=>n==null||t==null?!1:String(n).toLowerCase().endsWith(String(t).toLowerCase()),isEmpty:n=>n==null||String(n).trim()==="",isNotEmpty:n=>n!=null&&String(n).trim()!=="",">":(n,t)=>{if(n==null||t==null)return!1;const e=Number(n),o=Number(t);return isNaN(e)||isNaN(o)?!1:e>o},">=":(n,t)=>{if(n==null||t==null)return!1;const e=Number(n),o=Number(t);return isNaN(e)||isNaN(o)?!1:e>=o},"<":(n,t)=>{if(n==null||t==null)return!1;const e=Number(n),o=Number(t);return isNaN(e)||isNaN(o)?!1:e<o},"<=":(n,t)=>{if(n==null||t==null)return!1;const e=Number(n),o=Number(t);return isNaN(e)||isNaN(o)?!1:e<=o},"!=":(n,t)=>{if(t==null||t==="")return!0;const e=Number(n),o=Number(t);return!isNaN(e)&&!isNaN(o)?e!==o:String(n).toLowerCase()!==String(t).toLowerCase()},isAnyOf:(n,t)=>n==null||!Array.isArray(t)?!1:t.some(e=>String(n).toLowerCase()===String(e).toLowerCase()),not:(n,t)=>n==null&&t==null?!1:n==null||t==null?!0:String(n).toLowerCase()!==String(t).toLowerCase(),is:(n,t)=>{if(t==null||t==="")return!0;const e=String(n).toLowerCase(),o=String(t).toLowerCase();return e===o},"=":(n,t)=>n==null||t==null||t===""?!1:Number(n)===Number(t)};function so(n,t){const{field:e,operator:o,value:l}=t,s=n[e],d=lo[o];return d?d(s,l):(console.warn(`Unknown filter operator: ${o}`),!0)}function ao(n,t){return!t||t.length===0?!0:t.every(e=>{const o=e.toLowerCase();return Object.values(n).some(l=>l==null?!1:String(l).toLowerCase().includes(o))})}function Dt(n,t){const e=t.items??[],o=t.logicOperator??"and",l=("quickFilterValues"in t?t.quickFilterValues:void 0)??[];if(l.length>0&&!ao(n,l))return!1;if(e.length===0)return!0;const s=d=>{if("logicOperator"in d&&"items"in d){const a=d,u=a.items;return u.length===0?!0:a.logicOperator==="and"?u.every(s):u.some(s)}else return so(n,d)};return o==="and"?e.every(s):e.some(s)}function co(n,t){if(!t)return n;const{items:e=[],quickFilterValues:o=[]}=t;return e.length===0&&(!o||o.length===0)?n:n.filter(l=>Dt(l,t))}function uo(n){switch(n){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 Ht(n,t,e){if(n==null&&t==null)return 0;if(n==null)return e==="asc"?1:-1;if(t==null)return e==="asc"?-1:1;if(typeof n=="number"&&typeof t=="number")return e==="asc"?n-t:t-n;if(n instanceof Date&&t instanceof Date)return e==="asc"?n.getTime()-t.getTime():t.getTime()-n.getTime();const o=String(n).toLowerCase(),l=String(t).toLowerCase();return e==="asc"?o<l?-1:o>l?1:0:o>l?-1:o<l?1:0}function fo(n,t){if(t.length===0)return n;const e=[...n];return e.sort((o,l)=>{for(const s of t){const d=o[s.field],a=l[s.field],u=Ht(d,a,s.sort);if(u!==0)return u}return 0}),e}function go(n){const{effectiveRows:t,activeHierarchyHandlers:e,filterMode:o,filterModel:l,dataSource:s,sortModel:d,sortingMode:a,pagination:u,paginationMode:c,effectivePaginationModel:p,pinnedRows:b,isLoading:h,pageSize:m}=n,_=i.useMemo(()=>e?e.getVisibleRows()||[]:o==="server"&&s?t:co(t,l),[t,l,e,o,s]),{top:C,center:S,bottom:P}=i.useMemo(()=>e?{top:[],center:_,bottom:[]}:to(_,b),[_,b,e]),j=i.useMemo(()=>e||a==="server"&&s?S:fo(S,d),[S,d,e,a,s]),w=i.useMemo(()=>{if(!u||c==="server"&&s)return j;const g=p.page*p.pageSize;return j.slice(g,g+p.pageSize)},[j,u,p.page,p.pageSize,c,s]),E=i.useMemo(()=>{if(e)return S;const g=u?w:j,x=[...C,...g,...P];if(c==="infinite"&&h&&x.length>0){const f=Math.min(m,20),k=Array.from({length:f},(M,N)=>({id:`__skeleton_${N}__`,_isSkeleton:!0}));return[...x,...k]}return x},[C,w,j,P,u,e,S,c,h,m]);return{filteredRows:_,pinnedTopRows:C,unpinnedRows:S,pinnedBottomRows:P,sortedUnpinnedRows:j,paginatedUnpinnedRows:w,allRenderableRows:E}}function ho(n){const{layout:t,scrollTop:e,scrollLeft:o,viewportWidth:l,viewportHeight:s,autoHeight:d,rowReordering:a,hasDetailPanel:u,checkboxSelection:c,pinCheckboxColumn:p,pinExpandColumn:b}=n;return i.useMemo(()=>{const{unpinnedAccWidths:h,unpinnedColsWithWidth:m,leftPinnedCols:_,rightPinnedCols:C,totalWidth:S,leftWidth:P,rightWidth:j,unpinnedTotalWidth:w,systemColumnsWidth:E,cumulativeHeights:g,pinnedTopHeight:x,pinnedBottomHeight:f,unpinnedRowsHeight:k,rowHeights:M,unpinnedRowsLength:N}=t,v=l||1e3,I=d?x+k+f+50:s||600,L=6,W=Math.max(0,o-P),A=o+v-P;let G=0,T=m.length-1,B=0,Y=h.length-1;for(;B<=Y;){const oe=B+Y>>>1;h[oe]<W?B=oe+1:Y=oe-1}G=Math.max(0,B-L);for(let oe=G;oe<h.length;oe++){if((oe===0?0:h[oe-1])>A){T=Math.min(m.length-1,oe+L);break}T=Math.min(m.length-1,oe+L)}const K=G>0?h[G-1]:0,y=w-h[T],O=[..._,...K>0?[{field:"__spacer_left__",width:K,isSpacer:!0}]:[],...m.slice(G,T+1),...y>0?[{field:"__spacer_right__",width:y,isSpacer:!0}]:[],...C],$=v>0&&S>v?16:0,H=x+k+f+$+2,X=5;let U=0,te=N-1,R=0,J=0,Q=g.length-1;for(;J<=Q;){const oe=J+Q>>>1;g[oe]<e?J=oe+1:Q=oe-1}U=Math.max(0,J-X),R=U>0?g[U-1]:0;for(let oe=U;oe<g.length;oe++)if(g[oe]>=e+I){te=Math.min(N-1,oe+X);break}const le=(a?48:0)+(u&&b?48:0)+(c&&p?48:0);return{renderContext:{firstRowIndex:U,lastRowIndex:te,firstColumnIndex:G,lastColumnIndex:T},offsetTop:R,offsetLeft:0,totalHeight:H,pinnedTopHeight:x,pinnedBottomHeight:f,totalWidth:S,rowHeights:M,cumulativeHeights:g,virtualColumns:O,columnMetrics:{leftPinnedWidth:P,rightPinnedWidth:j,unpinnedAccWidths:h,unpinnedCols:m,totalSpecialsWidth:E,pinnedSpecialsWidth:le}}},[t,e,o,l,s,d,a,u,c,p,b])}function po(n){const{columns:t,onColumnOrderChange:e,disableColumnReorder:o=!1}=n,[l,s]=i.useState(null),[d,a]=i.useState(null),u=i.useRef(-1),c=i.useCallback(m=>_=>{if(o)return;const C=t.findIndex(P=>P.field===m);if(t[C]?.pinnable===!1){_.preventDefault();return}s(m),u.current=C,_.dataTransfer&&(_.dataTransfer.effectAllowed="move",_.dataTransfer.setData("text/plain",m))},[t,o]),p=i.useCallback(m=>_=>{o||!l||(_.preventDefault(),_.dataTransfer.dropEffect="move",a(m))},[l,o]),b=i.useCallback(m=>_=>{if(_.preventDefault(),o||!l||l===m){s(null),a(null);return}const C=t.findIndex(j=>j.field===l),S=t.findIndex(j=>j.field===m);if(C===-1||S===-1){s(null),a(null);return}const P=t[C];e&&e({column:P,oldIndex:C,targetIndex:S}),s(null),a(null),u.current=-1},[t,l,o,e]),h=i.useCallback(()=>{s(null),a(null),u.current=-1},[]);return{draggedColumn:l,dragOverColumn:d,onDragStart:o?void 0:c,onDragOver:o?void 0:p,onDragEnd:o?void 0:h,onDrop:o?void 0:b}}function mn({isExpanded:n,onClick:t,variant:e="chevron"}){return r.jsx("button",{className:`ogx-expand-icon ${n?"ogx-expand-icon--expanded":""}`,onClick:o=>{t&&t(o)},"aria-label":n?"Collapse row":"Expand row",type:"button",children:e==="plus-minus"?r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r.jsx("path",{d:"M4 8H12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M8 4V12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:n?0:1,transition:"opacity 0.2s ease",transformOrigin:"center"}})]}):r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{transform:n?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.2s ease"},children:r.jsx("path",{d:"M6 4L10 8L6 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}function xo(n){const{activeColumns:t,isHierarchyEnabled:e,isRowGrouping:o,isTreeData:l,activeHierarchyHandlers:s,columnVisibilityModel:d,columnOrder:a,onColumnOrderChange:u,disableColumnReorder:c,pivotMode:p,checkboxSelection:b,hasDetailPanel:h,rowReordering:m,initialState:_,setColumns:C}=n,S=i.useMemo(()=>e?t.map((v,I)=>I===0?{...v,renderCell:L=>{const W=L.rowMeta,A=W?.treeDepth??0,G=!!W?.hasChildren,T=!!W?.isExpanded,B=W?.groupingField,Y=W?.groupingValue,K=W?.descendantCount,y=!!W?.isGroupRow;let O=v.renderCell?v.renderCell(L):L.value;return l&&G&&y&&(O=r.jsxs("div",{className:"ogx__group-cell-content",children:[L.value,K!==void 0&&K>0?` (${K})`:""]})),o&&G&&B&&(O=r.jsxs("div",{className:"ogx__group-cell-content",children:[v.field===B?"":`${B}: `,String(Y),K!==void 0?` (${K})`:""]})),r.jsxs("div",{style:{display:"flex",alignItems:"center",paddingLeft:A*24,width:"100%",height:"100%"},children:[r.jsx("div",{style:{marginRight:4,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",cursor:G?"pointer":"default",flexShrink:0},children:G?r.jsx("div",{onClick:z=>{z.stopPropagation(),z.preventDefault(),s?.toggleExpansion(L.row.id)},onMouseDown:z=>{z.stopPropagation()},style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:10,position:"relative"},children:r.jsx(mn,{isExpanded:T,onClick:z=>{z.stopPropagation(),z.preventDefault(),s?.toggleExpansion(L.row.id)}})}):null}),r.jsx("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:O})]})}}:{...v,renderCell:L=>{const W=L.rowMeta,A=!!W?.hasChildren,G=W?.groupingField;return o&&A?v.field===G?null:L.value!==void 0&&L.value!==null?v.renderCell?v.renderCell(L):L.value:null:v.renderCell?v.renderCell(L):L.value}}):t,[t,e,o,l,s]),[P,j]=i.useState(()=>_?.columns?.columnWidths??{}),w=i.useCallback((v,I)=>{j(L=>({...L,[v]:I}))},[]),[E,g]=i.useState(()=>_?.columns?.columnOrder??t.map(v=>v.field)),x=a??E;i.useEffect(()=>{C(t)},[t,C]),i.useEffect(()=>{p&&g(t.map(v=>v.field))},[p,t]);const f=i.useMemo(()=>{if(c)return S;const v=new Map(x.map((I,L)=>[I,L]));return[...S].sort((I,L)=>{const W=v.get(I.field)??S.indexOf(I),A=v.get(L.field)??S.indexOf(L);return W-A})},[S,x,c]),k=i.useMemo(()=>f.filter(v=>d[v.field]!==!1),[f,d]),M=po({columns:f,onColumnOrderChange:i.useCallback(v=>{const{oldIndex:I,targetIndex:L}=v,W=[...x],[A]=W.splice(I,1);W.splice(L,0,A),a||g(W),u?.(v)},[x,a,u]),disableColumnReorder:c}),N=i.useMemo(()=>{const v=[];return m&&v.push({field:"__reorder_col__"}),h&&v.push({field:"__expand_col__"}),b&&v.push({field:"__checkbox_col__"}),[...v,...f]},[f,b,h,m]);return{effectiveColumns:S,orderedColumns:f,visibleOrderedColumns:k,navigationColumns:N,columnWidths:P,effectiveColumnOrder:x,setInternalColumnOrder:g,columnReorderHandlers:M,handleColumnResize:w}}function mo(n){const{renderContext:t,pinnedTopRows:e,pinnedBottomRows:o,paginatedUnpinnedRows:l,sortedUnpinnedRows:s,pagination:d}=n;return i.useMemo(()=>{const{firstRowIndex:a,lastRowIndex:u}=t,c=d?l:s,p=e.length,b=e.map((j,w)=>({row:j,rowIndex:w})),h=o.map((j,w)=>({row:j,rowIndex:p+c.length+w})),m=Math.max(0,a-p),_=Math.min(c.length,u-p+1),C=c.slice(m,_).map((j,w)=>({row:j,rowIndex:p+m+w})),S=[...b,...C,...h],P=new Set;return S.filter(j=>P.has(j.row.id)?!1:(P.add(j.row.id),!0))},[t,e,o,l,s,d])}function bo(n){const{onRowsScrollEnd:t}=n,e=i.useRef({scrollTop:0,scrollLeft:0}),o=i.useRef(null),[l,s]=i.useState({scrollTop:0,scrollLeft:0});i.useEffect(()=>()=>{o.current!==null&&cancelAnimationFrame(o.current)},[]);const d=i.useCallback(a=>{const u=a.currentTarget;if(e.current={scrollTop:u.scrollTop,scrollLeft:u.scrollLeft},o.current!==null&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{o.current=null,s(e.current)}),t){const{scrollTop:c,scrollHeight:p,clientHeight:b}=u;p-c-b<100&&t({visibleTop:c,visibleBottom:c+b,viewportHeight:b})}},[t]);return{scrollTop:l.scrollTop,scrollLeft:l.scrollLeft,handleScroll:d}}function wo(n){const{onStateChange:t,sortModel:e,filterModel:o,effectivePaginationModel:l,columnWidths:s,effectiveColumnOrder:d,columnVisibilityModel:a,pinnedColumns:u}=n,c=i.useRef(t);i.useLayoutEffect(()=>{c.current=t}),i.useEffect(()=>{if(!c.current)return;const p={sorting:{sortModel:e},filter:{filterModel:o},pagination:{paginationModel:l},columns:{columnWidths:s,columnOrder:d,columnVisibilityModel:a,pinnedColumns:u}};c.current(p)},[e,o,l,s,d,a,u])}const vo={sum:n=>n.filter(e=>e!=null&&!isNaN(Number(e))).reduce((e,o)=>e+Number(o),0),avg:n=>{const t=n.filter(e=>e!=null&&!isNaN(Number(e)));return t.length===0?null:t.reduce((e,o)=>e+Number(o),0)/t.length},count:n=>n.filter(t=>t!=null).length,min:n=>{const t=n.filter(e=>e!=null&&!isNaN(Number(e))).map(Number);return t.length?Math.min(...t):null},max:n=>{const t=n.filter(e=>e!=null&&!isNaN(Number(e))).map(Number);return t.length?Math.max(...t):null},unique:n=>new Set(n.filter(t=>t!=null)).size};function Re(n,t){return n==null?"—":typeof n=="number"?t==="avg"?n.toLocaleString(void 0,{maximumFractionDigits:2}):n.toLocaleString():String(n)}function bn(n){const{rows:t,aggregationModel:e,isServerSide:o,dataSource:l,filterModel:s,sortModel:d,serverAggregationResults:a}=n,u=i.useMemo(()=>{if(o||Object.keys(e).length===0)return{};const j={};for(const[w,E]of Object.entries(e)){const g=vo[E];if(!g){console.warn(`[useAggregation] Unknown aggregation function: "${E}"`);continue}const x=t.map(f=>f[w]);j[w]=g(x)}return j},[t,e,o]),[c,p]=i.useState({}),[b,h]=i.useState(!1),[m,_]=i.useState(null),C=i.useRef(0),S=i.useCallback(async()=>{if(!l?.getAggregations||Object.keys(e).length===0)return;const j=++C.current;h(!0),_(null);try{const w=await l.getAggregations({sortModel:d??[],filterModel:s??{items:[]},groupKeys:[],aggregationModel:e});j===C.current&&p(w)}catch(w){j===C.current&&(_(w),console.error("[useAggregation] Server aggregation error:",w))}finally{j===C.current&&h(!1)}},[l,e,s,d]);return i.useEffect(()=>{o&&l?.getAggregations&&!a&&S()},[S,o,l,a]),{aggregationResult:i.useMemo(()=>o?a&&Object.keys(a).length>0?a:c:u,[o,u,a,c]),isLoading:b,error:m}}function _o({columns:n,aggregationModel:t,aggregationResult:e,columnWidths:o,rowHeight:l,checkboxSelection:s,hasDetailPanel:d,rowReordering:a,pinnedColumns:u}){const c=i.useMemo(()=>Bt(n,o,u,s,!0,d,!0,a),[n,o,u,s,d,a]),p=u?.left?.[u.left.length-1],b=u?.right?.[0];return r.jsxs("div",{className:"ogx__aggregation-footer",role:"row","aria-label":"Aggregation totals","aria-live":"polite",style:{minHeight:`${l}px`},children:[s&&r.jsx("div",{style:{width:48,flexShrink:0}}),d&&r.jsx("div",{style:{width:48,flexShrink:0}}),a&&r.jsx("div",{style:{width:48,flexShrink:0}}),n.map(h=>{const m=t[h.field],_=e[h.field],C=o[h.field]??(typeof h.width=="number"?h.width:120),S=dt(h.field,u),P=S?c[h.field]:void 0,j=["ogx__aggregation-cell",S==="left"&&"ogx__aggregation-cell--pinned-left",S==="right"&&"ogx__aggregation-cell--pinned-right",S==="left"&&h.field===p&&"ogx__aggregation-cell--pinned-left-last",S==="right"&&h.field===b&&"ogx__aggregation-cell--pinned-right-first"].filter(Boolean).join(" "),w={width:C,minWidth:C,maxWidth:C,textAlign:h.align||"left"};return S==="left"&&P!==void 0&&(w.left=P),S==="right"&&P!==void 0&&(w.right=P),r.jsx("div",{className:j,role:"gridcell",style:w,children:m?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"ogx__aggregation-label",children:m}),r.jsx("span",{className:"ogx__aggregation-value",children:Re(_,m)})]}):null},h.field)})]})}function Co({noRowsLabel:n,width:t}){return r.jsxs("div",{className:"ogx__empty",style:{width:t},children:[r.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[r.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),r.jsx("path",{d:"M3 9h18M9 21V9"})]}),r.jsx("span",{children:n})]})}function yo({error:n}){if(!n)return null;const t=n instanceof Error?n.message:typeof n=="string"?n:"An unexpected error occurred while loading the data.";return r.jsxs("div",{className:"ogx-error-overlay","aria-live":"assertive",role:"alert",children:[r.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:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),r.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),r.jsx("div",{className:"ogx-error-overlay__title",children:"Oops! Something went wrong"}),r.jsx("div",{className:"ogx-error-overlay__message",children:t}),r.jsx("button",{onClick:()=>window.location.reload(),className:"ogx-button ogx-button--primary",children:"Retry"})]})}const ct=({indeterminate:n=!1,label:t,className:e="",inputRef:o,...l})=>{const s=i.useRef(null),d=i.useCallback(u=>{s.current=u,typeof o=="function"?o(u):o&&(o.current=u)},[o]);i.useEffect(()=>{s.current&&(s.current.indeterminate=n)},[n]);const a=["ogx-checkbox-wrapper",l.disabled&&"ogx-checkbox-wrapper--disabled",e].filter(Boolean).join(" ");return r.jsxs("label",{className:a,children:[r.jsx("input",{ref:d,type:"checkbox",className:"ogx-checkbox__input","aria-label":t||l["aria-label"]||(n?"Select some":l.checked?"Deselect":"Select"),...l}),r.jsxs("span",{className:"ogx-checkbox__box",children:[l.checked&&!n&&r.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:r.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})}),n&&r.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:r.jsx("path",{d:"M19 13H5v-2h14v2z"})})]}),t&&r.jsx("span",{className:"ogx-checkbox__label",children:t})]})};function ko(n){const{field:t,currentWidth:e,onResize:o,minWidth:l=50,maxWidth:s=1e3}=n,[d,a]=i.useState(!1),u=i.useRef(0),c=i.useRef(0),p=i.useCallback(m=>{m.preventDefault(),m.stopPropagation(),a(!0),u.current=m.clientX,c.current=e;let _=0;const C=16,S=j=>{const w=j.clientX-u.current,E=Math.max(l,Math.min(s,c.current+w)),g=Date.now();g-_>=C&&(o(t,E),_=g)},P=j=>{a(!1);const w=j.clientX-u.current,E=Math.max(l,Math.min(s,c.current+w));o(t,E),document.removeEventListener("mousemove",S),document.removeEventListener("mouseup",P)};document.addEventListener("mousemove",S),document.addEventListener("mouseup",P)},[t,e,o,l,s]),b=i.useCallback(m=>{m.preventDefault(),m.stopPropagation()},[]),h=["ogx-column-resize-handle",d&&"ogx-column-resize-handle--dragging"].filter(Boolean).join(" ");return r.jsx("div",{className:h,onMouseDown:p,onClick:m=>m.stopPropagation(),onDragStart:m=>{m.preventDefault(),m.stopPropagation()},onDoubleClick:b,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${t} column`,children:r.jsx("div",{className:"ogx-column-resize-handle__line"})})}function Ge(){return r.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"currentColor",children:r.jsx("circle",{cx:"4",cy:"4",r:"4"})})}function Ve(){return r.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:r.jsx("circle",{cx:"4",cy:"4",r:"3"})})}function So(){return r.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",children:[r.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),r.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.3"}),r.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),r.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),r.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),r.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function jo(){return r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),r.jsx("polyline",{points:"5 12 12 5 19 12"})]})}function Eo(){return r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("polyline",{points:"19 12 12 19 5 12"})]})}function No(){return r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})}function Mo(){return r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.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"}),r.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"}),r.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function Po(){return r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"4",y1:"2",x2:"4",y2:"22"}),r.jsx("polyline",{points:"11 8 4 12 11 16"}),r.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function Io(){return r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"20",y1:"2",x2:"20",y2:"22"}),r.jsx("polyline",{points:"13 8 20 12 13 16"}),r.jsx("line",{x1:"20",y1:"12",x2:"4",y2:"12"})]})}function To(){return r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),r.jsx("line",{x1:"4",y1:"4",x2:"4",y2:"20"}),r.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function Lo({colDef:n,sortModel:t,onSort:e,onHide:o,onPin:l,pinnedColumns:s,onManageColumns:d,onClose:a,anchorEl:u}){const c=i.useRef(null),[p,b]=i.useState({position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"});i.useLayoutEffect(()=>{if(!u||!c.current)return;const g=u.getBoundingClientRect(),x=c.current.getBoundingClientRect(),f=window.innerWidth,k=window.innerHeight,M=8;let N=g.left;N+x.width+M>f&&(N=f-x.width-M),N<M&&(N=M);let v=g.bottom+4;v+x.height+M>k&&(v=g.top-x.height-4),b({position:"fixed",zIndex:1300,top:v,left:N,visibility:"visible"})},[u]),i.useEffect(()=>{function g(f){c.current&&!c.current.contains(f.target)&&u&&!u.contains(f.target)&&a()}function x(f){f.key==="Escape"&&a()}return document.addEventListener("mousedown",g),document.addEventListener("keydown",x),window.addEventListener("scroll",a,!0),window.addEventListener("resize",a),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",x),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a)}},[u,a]);const h=g=>{e?.(n.field,g),a()},m=()=>{o?.(n.field),a()},_=g=>{l?.(n.field,g),a()},C=t?.find(g=>g.field===n.field)?.sort,S=C==null,P=s?.left?.includes(n.field)??!1,j=s?.right?.includes(n.field)??!1,w=!P&&!j,E=n.headerName||n.field;return ze.createPortal(r.jsxs("div",{ref:c,className:"ogx-column-menu",style:p,role:"menu","aria-label":`Column options for ${E}`,children:[e&&n.sortable!==!1&&r.jsxs(r.Fragment,{children:[r.jsxs("button",{className:`ogx-menu-item${C==="asc"?" ogx-menu-item--active":""}`,onClick:()=>h("asc"),role:"menuitemradio","aria-checked":C==="asc",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:C==="asc"?r.jsx(Ge,{}):r.jsx(Ve,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(jo,{})}),"Sort Ascending"]}),r.jsxs("button",{className:`ogx-menu-item${C==="desc"?" ogx-menu-item--active":""}`,onClick:()=>h("desc"),role:"menuitemradio","aria-checked":C==="desc",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:C==="desc"?r.jsx(Ge,{}):r.jsx(Ve,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(Eo,{})}),"Sort Descending"]}),r.jsxs("button",{className:`ogx-menu-item${S?" ogx-menu-item--active":""}`,onClick:()=>h(null),role:"menuitemradio","aria-checked":S,children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:S?r.jsx(Ge,{}):r.jsx(Ve,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(No,{})}),"Unsort"]}),r.jsx("div",{className:"ogx-menu-divider"})]}),r.jsx("div",{className:"ogx-menu-section-label","aria-hidden":"true",children:"Pin column"}),r.jsxs("button",{className:`ogx-menu-item${P?" ogx-menu-item--active":""}`,onClick:()=>_("left"),role:"menuitemradio","aria-checked":P,"aria-label":"Pin to left",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:P?r.jsx(Ge,{}):r.jsx(Ve,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(Po,{})}),"Pin to Left"]}),r.jsxs("button",{className:`ogx-menu-item${j?" ogx-menu-item--active":""}`,onClick:()=>_("right"),role:"menuitemradio","aria-checked":j,"aria-label":"Pin to right",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:j?r.jsx(Ge,{}):r.jsx(Ve,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(Io,{})}),"Pin to Right"]}),r.jsxs("button",{className:`ogx-menu-item${w?" ogx-menu-item--active":""}`,onClick:()=>_(null),role:"menuitemradio","aria-checked":w,"aria-label":"Unpin column",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:w?r.jsx(Ge,{}):r.jsx(Ve,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(To,{})}),"Unpin"]}),r.jsx("div",{className:"ogx-menu-divider"}),r.jsxs("button",{className:"ogx-menu-item",onClick:m,role:"menuitem","aria-label":`Hide ${E} column`,children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(Mo,{})}),"Hide Column"]}),r.jsx("div",{className:"ogx-menu-divider"}),r.jsxs("button",{className:"ogx-menu-item",onClick:()=>{d?.(),a()},role:"menuitem","aria-label":"Manage all columns",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(So,{})}),"Manage columns"]})]}),u?.closest(".ogx-theme-provider")||document.body)}function Ro(){return r.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"18",height:"18",children:r.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 Oo(){return r.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor",children:r.jsx("path",{d:"M6.99 11L3 15l3.99 4v-3H14v-2H6.99v-3zM21 9l-3.99-4v3H10v2h7.01v3L21 9z"})})}function wn(n){const t=[];for(const e of n.children)typeof e=="string"?t.push(e):t.push(...wn(e));return t}function Wo(n){let t=0;function e(o,l){t=Math.max(t,l);for(const s of o.children)typeof s!="string"&&e(s,l+1)}return n.forEach(o=>e(o,1)),t}function Fo(n,t,e){function o(a,u,c){if(!wn(a).includes(u))return null;if(c===e)return a;for(const p of a.children)if(typeof p!="string"){const b=o(p,u,c+1);if(b)return b}return null}const l=new Map;for(const a of t){let u=null;for(const c of n)if(u=o(c,a.field,0),u)break;l.set(a.field,u)}const s=[];let d=0;for(;d<t.length;){const a=t[d],u=l.get(a.field)??null,c=a.width;if(!u)s.push({key:`fg-${a.field}-${e}`,label:"",width:c,isGroup:!1}),d++;else{let p=0,b=d;for(;b<t.length&&l.get(t[b].field)===u;)p+=t[b].width,b++;s.push({key:`${u.groupId}-${e}`,label:u.headerName,width:p,isGroup:!0}),d=b}}return s}function vn(n){const{columns:t,allColumns:e,columnGroupingModel:o,checkboxSelection:l=!1,allSelected:s=!1,someSelected:d=!1,onSelectAll:a,onSort:u,sortModel:c=[],onColumnResize:p,columnWidths:b={},pinnedColumns:h,hasDetailPanel:m=!1,pinCheckboxColumn:_=!0,pinExpandColumn:C=!0,rowReordering:S=!1,aggregationModel:P,draggedColumn:j,dragOverColumn:w,onDragStart:E,onDragOver:g,onDragEnd:x,onDrop:f,focusedCell:k,onHeaderClick:M,onHideColumn:N,onPinColumn:v,onManageColumns:I}=n,L=i.useId(),W=i.useRef({}),[A,G]=i.useState(null),T=R=>J=>{J.stopPropagation(),G({colDef:R,anchorEl:J.currentTarget})},B=()=>{G(null)};i.useLayoutEffect(()=>{if(k?.id==="HEADER"){const R=W.current[k.field];R&&R.focus()}},[k]);const Y=R=>()=>{if(R.sortable===!1||!u)return;const J=c.find(le=>le.field===R.field);let Q="asc";J&&(J.sort==="asc"?Q="desc":Q=null),u(R.field,Q)},K=R=>{const J=c.find(Q=>Q.field===R);return J?r.jsx("span",{className:`ogx__sort-icon ogx__sort-icon--${J.sort}`,"aria-hidden":"true"}):null},y=i.useMemo(()=>Bt(t,b,h,l,_,m,C,S),[t,b,h,l,_,m,C,S]),O=o?Wo(o):0,$=(e??t).filter(R=>!R.isSpacer).map(R=>({field:R.field,width:b[R.field]??R.width??100})),te=(S?48:0)+(m?48:0)+(l?48:0);return r.jsxs("div",{className:"ogx__header-wrap",children:[O>0&&Array.from({length:O},(R,J)=>{const Q=Fo(o,$,J);return r.jsxs("div",{className:"ogx-col-group-row",role:"row",children:[te>0&&r.jsx("div",{className:"ogx-col-group-cell ogx-col-group-cell--filler",style:{width:te,minWidth:te,flexShrink:0},role:"columnheader"}),Q.map(le=>r.jsx("div",{role:"columnheader",className:`ogx-col-group-cell ${le.isGroup?"ogx-col-group-cell--group":"ogx-col-group-cell--filler"}`,style:{width:le.width,minWidth:le.width,flexShrink:0},title:le.isGroup?le.label:void 0,children:le.isGroup&&r.jsx("span",{className:"ogx-col-group-cell__label",children:le.label})},le.key))]},`ogx-grp-${J}`)}),r.jsxs("div",{className:"ogx__header",role:"row",children:[S&&r.jsx("div",{className:"ogx__header-cell ogx__header-cell--pinned ogx__header-cell--pinned-left",role:"columnheader","aria-label":"Row reorder handle",title:"Drag to reorder rows",style:{minWidth:48,maxWidth:48,position:"sticky",left:0,zIndex:4}}),m&&r.jsx("div",{className:`ogx__header-cell ogx__header-cell--expand ${C?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""}`,role:"columnheader","aria-label":"Expand row details",style:{minWidth:48,maxWidth:48,position:C?"sticky":void 0,left:C?S?48:0:void 0,zIndex:C?5:void 0}}),l&&r.jsx("div",{className:`ogx__header-cell ogx__header-cell--checkbox ${_?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""}`,role:"columnheader",style:{position:_?"sticky":void 0,left:_?(S?48:0)+(m&&C?48:0):void 0},children:r.jsx(ct,{id:L,name:L,checked:s,indeterminate:d,onChange:R=>a?.(R.target.checked),"aria-label":s?"Deselect all rows":"Select all rows",tabIndex:k?.id==="HEADER"&&k.field==="__checkbox_col__"?0:-1,onMouseDown:R=>R.preventDefault(),inputRef:R=>{W.current.__checkbox_col__=R}})}),t.map((R,J)=>{if(R.isSpacer)return r.jsx("div",{style:{width:R.width,minWidth:R.width,flexShrink:0},"aria-hidden":"true"},R.field);const Q=R.sortable!==!1,le=c.some(fe=>fe.field===R.field),oe=R.resizable!==!1,pe=dt(R.field,h),F=pe!==null,ie=j===R.field,se=w===R.field,D=["ogx__header-cell",`ogx__header-cell--align-${R.headerAlign||R.align||"left"}`,Q&&"ogx__header-cell--sortable",le&&"ogx__header-cell--sorted",F&&"ogx__header-cell--pinned",F&&`ogx__header-cell--pinned-${pe}`,ie&&"ogx__header-cell--dragging",se&&"ogx__header-cell--drag-over",k?.id==="HEADER"&&k.field===R.field&&"ogx__header-cell--focused",R.headerClassName].filter(Boolean).join(" "),q=b[R.field]??R.width??100,ee={width:q,minWidth:R.minWidth,maxWidth:R.maxWidth,flexGrow:R.flex??0,flexShrink:0,flexBasis:(R.flex,"auto"),boxSizing:"border-box",position:F?"sticky":"relative",zIndex:R.zIndex,opacity:ie?.5:1};if(F&&pe){const fe=y[R.field];pe==="left"?ee.left=fe:ee.right=fe}const de=R.renderHeader?R.renderHeader({field:R.field,colDef:R,colIndex:J}):R.headerName||R.field,ce=fe=>{if(fe.target.closest(".ogx-column-resize-handle")){fe.stopPropagation();return}M?.(R.field),Q&&Y(R)()},je=E?E(R.field):void 0,We=g?g(R.field):void 0,Ee=f?f(R.field):void 0;return r.jsxs("div",{className:D,style:ee,onClick:ce,role:"columnheader",draggable:!!E,onDragStart:je,onDragOver:We,onDragEnd:x,onDrop:Ee,"aria-sort":Q?le?c.find(fe=>fe.field===R.field)?.sort==="asc"?"ascending":"descending":"none":void 0,"aria-colindex":J+1+(l?1:0),"data-field":R.field,tabIndex:-1,ref:fe=>{W.current[R.field]=fe},children:[r.jsxs("div",{className:"ogx__header-cell-content",children:[ie&&r.jsx("div",{className:"ogx__header-drag-icon",children:r.jsx(Oo,{})}),r.jsxs("div",{className:"ogx__header-cell-title-wrapper",children:[r.jsx("span",{className:"ogx__header-cell-title",children:de}),P&&P[R.field]&&r.jsx("span",{className:"ogx__header-cell-aggregation",children:P[R.field]})]}),Q&&K(R.field),!R.disableColumnMenu&&r.jsx("button",{className:"ogx__menu-icon-btn",onClick:T(R),"aria-label":`Open column menu for ${R.headerName||R.field}`,"aria-haspopup":"menu",tabIndex:-1,children:r.jsx(Ro,{})})]}),oe&&p&&r.jsx(ko,{field:R.field,currentWidth:q,onResize:p,minWidth:R.minWidth,maxWidth:R.maxWidth})]},R.field)}),A&&r.jsx(Lo,{colDef:A.colDef,sortModel:c,onSort:u,onHide:N,onPin:v,pinnedColumns:h,onManageColumns:I,onClose:B,anchorEl:A.anchorEl})]})]})}const ut=({variant:n="text",size:t="medium",color:e="default",disabled:o=!1,className:l="",children:s,...d})=>{const a=["ogx-button",`ogx-button--${n}`,`ogx-button--${t}`,`ogx-button--${e}`,o&&"ogx-button--disabled",l].filter(Boolean).join(" ");return r.jsx("button",{className:a,disabled:o,...d,children:s})};function _n(n){const t=i.useId(),{page:e,pageSize:o,rowCount:l,onPageChange:s,onPageSizeChange:d,pageSizeOptions:a=[10,25,50,100],showFirstButton:u=!0,showLastButton:c=!0,localeText:p}=n,b=Math.max(1,Math.ceil(l/o)),h=Math.min(e,b-1),m=h*o,_=Math.min(m+o,l),C=l===0?0:`${m+1}–${_}`,S=p?.paginationRowsPerPage??"Rows per page:",P=p?.paginationOf?p.paginationOf(l===0?0:m+1,_,l):`${C} of ${l}`,j=p?.paginationPage?p.paginationPage(h+1,b):`Page ${h+1} of ${b}`,w=()=>{s(0)},E=()=>{s(Math.max(0,h-1))},g=()=>{s(Math.min(b-1,h+1))},x=()=>{s(b-1)},f=N=>{const v=parseInt(N.target.value,10);d(v)},k=h===0,M=h>=b-1;return r.jsxs("div",{className:"ogx-pagination",role:"navigation","aria-label":"Pagination",children:[r.jsxs("div",{className:"ogx-pagination__page-size",children:[r.jsx("label",{htmlFor:t,className:"ogx-pagination__label",children:S}),r.jsx("select",{id:t,className:"ogx-pagination__select",value:o,onChange:f,"aria-label":"Rows per page",children:a.map(N=>r.jsx("option",{value:N,children:N},N))})]}),r.jsx("div",{className:"ogx-pagination__info","aria-live":"polite","aria-atomic":"true",children:P}),r.jsxs("div",{className:"ogx-pagination__actions",children:[u&&r.jsx(ut,{variant:"text",size:"small",onClick:w,disabled:k,"aria-label":"Go to first page",title:"First page",children:r.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:r.jsx("path",{d:"M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"})})}),r.jsx(ut,{variant:"text",size:"small",onClick:E,disabled:k,"aria-label":"Go to previous page",title:"Previous page",children:r.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:r.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),r.jsx("div",{className:"ogx-pagination__page-info","aria-current":"page",children:j}),r.jsx(ut,{variant:"text",size:"small",onClick:g,disabled:M,"aria-label":"Go to next page",title:"Next page",children:r.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:r.jsx("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})})}),c&&r.jsx(ut,{variant:"text",size:"small",onClick:x,disabled:M,"aria-label":"Go to last page",title:"Last page",children:r.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:r.jsx("path",{d:"M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z"})})})]})]})}function Ao(n,t,e={}){const o=new Map,l=[];n.forEach(a=>{o.set(a.id,a),l.push(a.id)});const s=new Map,d=[];return t.forEach(a=>{s.set(a.field,a),d.push(a.field)}),{rows:{idRowsLookup:o,allRows:l},columns:{all:t,lookup:s,orderedFields:d,columnVisibilityModel:e},sorting:{sortModel:[]},filter:{filterModel:{items:[]}},pagination:{paginationModel:{page:0,pageSize:100},rowCount:n.length},selection:{selectedRows:new Set},pinning:{pinnedColumns:{},pinnedRows:{}},virtualization:{renderContext:{firstRowIndex:0,lastRowIndex:0,firstColumnIndex:0,lastColumnIndex:0}},dimensions:{rowHeight:52,headerHeight:56,viewportWidth:0,viewportHeight:0},dataSource:{loading:!1,error:null}}}function zo(n,t){switch(t.type){case"SET_ROWS":{const e=Array.from(n.rows.idRowsLookup.values()),o=typeof t.payload=="function"?t.payload(e):t.payload,l=new Map,s=[];return o.forEach(d=>{l.set(d.id,d),s.push(d.id)}),{...n,rows:{idRowsLookup:l,allRows:s},pagination:{...n.pagination,rowCount:t.preserveRowCount?n.pagination.rowCount:o.length}}}case"SET_COLUMNS":{const e=new Map,o=[];return t.payload.forEach(l=>{e.set(l.field,l),o.push(l.field)}),{...n,columns:{all:t.payload,lookup:e,orderedFields:o,columnVisibilityModel:n.columns.columnVisibilityModel}}}case"SET_SORT_MODEL":return{...n,sorting:{sortModel:t.payload}};case"SET_FILTER_MODEL":return{...n,filter:{filterModel:t.payload}};case"SET_PAGINATION_MODEL":return{...n,pagination:{...n.pagination,paginationModel:t.payload}};case"SET_SELECTION":return{...n,selection:{selectedRows:t.payload}};case"SET_DIMENSIONS":return{...n,dimensions:{...n.dimensions,viewportWidth:t.payload.viewportWidth,viewportHeight:t.payload.viewportHeight}};case"SET_DATASOURCE_LOADING":return{...n,dataSource:{...n.dataSource,loading:t.payload}};case"SET_DATASOURCE_ERROR":return{...n,dataSource:{...n.dataSource,error:t.payload}};case"SET_ROW_COUNT":return{...n,pagination:{...n.pagination,rowCount:t.payload}};default:return n}}function Bo(n){const{rows:t,columns:e,rowHeight:o=52,headerHeight:l=56,columnVisibilityModel:s,initialState:d}=n,[a]=i.useState(()=>Ao(t,e,s)),[u,c]=i.useReducer(zo,{...a,sorting:d?.sorting||a.sorting,filter:d?.filter||a.filter,dataSource:d?.dataSource?{...a.dataSource,...d.dataSource}:a.dataSource,pagination:{...a.pagination,...d?.pagination||{},rowCount:n.rowCount??d?.pagination?.rowCount??a.pagination.rowCount},dimensions:{...a.dimensions,rowHeight:o,headerHeight:l}}),p=i.useRef(u);i.useLayoutEffect(()=>{p.current=u});const b=i.useRef(t);i.useEffect(()=>{t!==b.current&&(b.current=t,c({type:"SET_ROWS",payload:t}))},[t]);const h=i.useCallback((f,k)=>{c({type:"SET_ROWS",payload:f,preserveRowCount:k})},[]),m=i.useCallback(f=>{c({type:"SET_COLUMNS",payload:f})},[]),_=i.useCallback(f=>{c({type:"SET_SORT_MODEL",payload:f})},[]),C=i.useCallback(f=>{c({type:"SET_FILTER_MODEL",payload:f})},[]),S=i.useCallback(f=>{c({type:"SET_PAGINATION_MODEL",payload:f})},[]),P=i.useCallback(f=>{c({type:"SET_SELECTION",payload:f})},[]),j=i.useCallback((f,k)=>{c({type:"SET_DIMENSIONS",payload:{viewportWidth:f,viewportHeight:k}})},[]),w=i.useCallback(f=>{c({type:"SET_DATASOURCE_LOADING",payload:f})},[]),E=i.useCallback(f=>{c({type:"SET_DATASOURCE_ERROR",payload:f})},[]),g=i.useCallback(f=>{c({type:"SET_ROW_COUNT",payload:f})},[]),x=i.useRef({getRow:f=>p.current.rows.idRowsLookup.get(f)||null,getAllRows:()=>Array.from(p.current.rows.idRowsLookup.values()),getVisibleRows:()=>Array.from(p.current.rows.idRowsLookup.values()),getAggregationResult:()=>null,getAggregationModel:()=>null,getColumn:f=>p.current.columns.lookup.get(f)||null,getAllColumns:()=>p.current.columns.all,getVisibleColumns:()=>p.current.columns.all,selectRow:(f,k=!0)=>{const M=new Set(p.current.selection.selectedRows);k?M.add(f):M.delete(f),P(M)},selectRows:(f,k=!0)=>{const M=new Set(p.current.selection.selectedRows);f.forEach(N=>{k?M.add(N):M.delete(N)}),P(M)},getSelectedRows:()=>Array.from(p.current.selection.selectedRows),sortColumn:(f,k)=>{if(k===null)_(p.current.sorting.sortModel.filter(M=>M.field!==f));else{const M=p.current.sorting.sortModel.findIndex(N=>N.field===f);if(M>=0){const N=[...p.current.sorting.sortModel];N[M]={field:f,sort:k},_(N)}else _([...p.current.sorting.sortModel,{field:f,sort:k}])}},getSortModel:()=>p.current.sorting.sortModel,setFilterModel:C,getFilterModel:()=>p.current.filter.filterModel,setPage:f=>{S({...p.current.pagination.paginationModel,page:f})},setPageSize:f=>{S({...p.current.pagination.paginationModel,pageSize:f,page:0})},scrollToIndexes:()=>{},copySelectedRows:()=>Promise.resolve()});return{state:u,dispatch:c,apiRef:x,setRows:h,setColumns:m,setSortModel:_,setFilterModel:C,setPaginationModel:S,setSelection:P,setDimensions:j,setDataSourceLoading:w,setDataSourceError:E,setRowCount:g}}function $o(n){const{onRowOrderChange:t,rows:e,getRowId:o,rowReordering:l=!1}=n,[s,d]=i.useState(null),[a,u]=i.useState(null),c=i.useCallback(_=>o?o(_):_.id,[o]),p=i.useCallback(_=>C=>{l&&(d(_),C.dataTransfer.effectAllowed="move")},[l]),b=i.useCallback(_=>C=>{!l||!s||(C.preventDefault(),C.dataTransfer.dropEffect="move",a!==_&&u(_))},[l,s,a]),h=i.useCallback(()=>{d(null),u(null)},[]),m=i.useCallback(_=>C=>{if(C.preventDefault(),!s||!t){h();return}const S=e.findIndex(j=>c(j)===s),P=e.findIndex(j=>c(j)===_);S!==-1&&P!==-1&&S!==P&&t({row:e[S],oldIndex:S,targetIndex:P}),h()},[s,t,e,c,h]);return{draggedRowId:s,dragOverRowId:a,onDragStart:l?p:void 0,onDragOver:l?b:void 0,onDragEnd:l?h:void 0,onDrop:l?m:void 0}}function Do(n){const{rows:t,getRowId:e,getTreeDataPath:o,treeData:l=!1,defaultGroupingExpansionDepth:s=0,filterModel:d,sortModel:a,onRowExpansionChange:u}=n,{treeNodes:c,rootIds:p,groupingRows:b}=i.useMemo(()=>{if(!l||!o)return{treeNodes:new Map,rootIds:[],groupingRows:[]};const g=new Map,x=[],f=[],k=new Map,M=N=>N.join("/");return t.forEach(N=>{const v=e(N),I=o(N),L=M(I);k.set(L,v),g.set(v,{id:v,parentId:null,depth:I.length-1,groupingKey:I[I.length-1],isExpanded:!1,children:[],serverChildrenCount:N.serverChildrenCount})}),t.forEach(N=>{const v=e(N),I=o(N);if(I.length===1){x.push(v);return}const L=A=>{if(A.length<=1)return;const G=A.slice(0,-1),T=M(G);let B=k.get(T);if(B===void 0&&(B=`auto-group-${T}`,!g.has(B))){const Y=G[G.length-1];g.set(B,{id:B,parentId:null,depth:G.length-1,groupingKey:Y,isExpanded:!1,children:[],label:Y}),k.set(T,B);const K={id:B,name:Y,_isGroupRow:!0};f.push(K),G.length===1&&x.push(B),L(G)}return B},W=L(I);if(W!==void 0){const A=g.get(W),G=g.get(v);A&&G&&(G.parentId=W,A.children=A.children||[],A.children.includes(v)||A.children.push(v))}}),f.forEach(N=>{const v=N.id,I=g.get(v);if(!I)return;const W=v.replace("auto-group-","").split("/");if(W.length>1){const A=W.slice(0,-1),G=M(A),T=k.get(G);if(T&&g.has(T)){I.parentId=T;const B=g.get(T);B&&(B.children=B.children||[],B.children.includes(v)||B.children.push(v))}}}),{treeNodes:g,rootIds:x,groupingRows:f}},[t,o,l,e]),h=i.useMemo(()=>{if(!l)return new Set;const g=new Set;return c.forEach(x=>{x.children&&x.children.length>0&&(s===-1||x.depth<s)&&g.add(x.id)}),g},[c,l,s]),[m,_]=i.useState(new Set);i.useEffect(()=>{h.size>0&&_(h)},[h]);const C=i.useCallback(g=>{_(x=>{const f=new Set(x),k=!f.has(g);if(f.has(g)?f.delete(g):f.add(g),k&&u){const M=c.get(g);M&&u(M)}return f})},[c,u]),S=i.useCallback(()=>{if(!l)return null;const g=new Map;t.forEach(L=>g.set(e(L),L)),b.forEach(L=>g.set(L.id,L));const x=L=>Dt(L,d),f=new Map,k=L=>{if(f.has(L))return f.get(L);const W=g.get(L);if(!W)return!1;if(x(W))return f.set(L,!0),!0;const G=c.get(L);return G&&G.children&&G.children.some(B=>k(B))?(f.set(L,!0),!0):(f.set(L,!1),!1)},M=(L,W)=>{if(!a||a.length===0)return 0;const A=g.get(L),G=g.get(W);if(!A||!G)return 0;for(const T of a){const B=A[T.field],Y=G[T.field],K=Ht(B,Y,T.sort);if(K!==0)return K}return 0},N=[],v=new Set,I=L=>{const W=L.filter(A=>k(A));W.sort(M),W.forEach(A=>{if(v.has(A))return;const G=g.get(A),T=c.get(A);if(G&&T){v.add(A);const B={...G,_treeDepth:T.depth,_isExpanded:m.has(A),_hasChildren:!!(T.children&&T.children.length>0||T.serverChildrenCount&&T.serverChildrenCount>0),_descendantCount:T.children?T.children.length:0};N.push(B),m.has(A)&&T.children&&T.children.length>0&&I(T.children)}})};return I(p),N},[l,t,b,p,c,m,d,a,e]),P=i.useCallback(g=>m.has(g),[m]),j=i.useCallback(g=>c.get(g),[c]),w=i.useCallback(g=>{const x=[];let f=g;for(;f!==null;){const k=c.get(f);if(!k)break;x.unshift(k.groupingKey),f=k.parentId}return x},[c]),E=i.useMemo(()=>{const g=new Map,x=new Set(b.map(f=>f.id));return c.forEach((f,k)=>{g.set(k,{hasChildren:!!(f.children&&f.children.length>0||f.serverChildrenCount&&f.serverChildrenCount>0),treeDepth:f.depth,descendantCount:f.children?f.children.length:void 0,isGroupRow:x.has(k),isExpanded:m.has(k)})}),g},[c,b,m]);return i.useMemo(()=>({treeNodes:c,groupingRows:b,toggleExpansion:C,isGroupExpanded:P,getVisibleRows:S,getNode:j,getNodePath:w,rowMetaMap:E}),[c,b,C,P,S,j,w,E])}const Ho=n=>n?.depth===-1?"footer":"inline",Go=[],Vo={};function Uo(n){const{rows:t,getRowId:e,rowGroupingModel:o=Go,aggregationModel:l=Vo,defaultGroupingExpansionDepth:s=0,filterModel:d,sortModel:a,getAggregationPosition:u=Ho}=n,[c,p]=i.useState(new Set),{treeNodes:b,rootIds:h,groupingRows:m}=i.useMemo(()=>{const w=new Map,E=new Map,g=[];if(o.length===0)return{treeNodes:w,rootIds:g,groupingRows:E};const x=(M,N,v)=>`auto-group-${M}-${N}-${v||"root"}`,f=(M,N,v)=>{if(N>=o.length)return M.map(A=>{const G=e(A);return w.set(G,{id:G,parentId:v,depth:N,groupingKey:"",isExpanded:!1}),G});const I=o[N],L=new Map;M.forEach(A=>{const G=A[I],T=String(G);L.has(T)||L.set(T,[]),L.get(T).push(A)});const W=[];return L.forEach((A,G)=>{const B=A[0][I],Y=x(I,G,v);W.push(Y);const K={};l&&Object.entries(l).forEach(([H,X])=>{const U=A.map(te=>te[H]);if(X==="sum")K[H]=U.reduce((te,R)=>te+(Number(R)||0),0);else if(X==="min")K[H]=Math.min(...U.map(te=>Number(te)||0));else if(X==="max")K[H]=Math.max(...U.map(te=>Number(te)||0));else if(X==="avg"){const te=U.reduce((R,J)=>R+(Number(J)||0),0);K[H]=U.length?te/U.length:0}else X==="count"&&(K[H]=U.length)});const y={[I]:B,...K,id:Y};E.set(Y,y);const O={id:Y,parentId:v,depth:N,groupingKey:G,groupingField:I,groupingValue:B,aggregatedValues:K,isExpanded:!1,children:[],label:`${I}: ${String(B)}`};O.aggregationPosition=u(O),w.set(Y,O);const z=f(A,N+1,Y);w.get(Y).children=z;const $=A.length;w.get(Y).descendantCount=$}),W},k=f(t,0,null);return g.push(...k),{treeNodes:w,rootIds:g,groupingRows:E}},[t,o,l,e,u]);i.useEffect(()=>{if(s===-1){const w=new Set;b.forEach((E,g)=>{E.children&&E.children.length>0&&w.add(g)}),p(w)}else if(s>0){const w=new Set;b.forEach((E,g)=>{E.depth<s&&E.children&&E.children.length>0&&w.add(g)}),p(w)}else p(new Set)},[o,s,b]);const _=i.useCallback(w=>{p(E=>{const g=new Set(E);return g.has(w)?g.delete(w):g.add(w),g})},[]),C=i.useCallback(w=>c.has(w),[c]),S=i.useCallback(()=>{if(o.length===0)return null;const w=[],E=new Set,g=new Map;t.forEach(M=>g.set(e(M),M));const x=M=>{const N=b.get(M);if(!N)return!1;if(!N.children||N.children.length===0){const v=g.get(M);return!(!v||d&&!Dt(v,d))}return N.children.some(v=>x(v))},f=M=>{let N=M;d&&(N=M.filter(x)),a&&a.length>0&&N.sort((v,I)=>{const L=m.get(v)||g.get(v),W=m.get(I)||g.get(I);if(!L||!W)return 0;for(const A of a){const G=L[A.field],T=W[A.field],B=Ht(G,T,A.sort);if(B!==0)return B}return 0}),N.forEach(v=>{if(E.has(v))return;const I=b.get(v),L=I?.children&&I.children.length>0,W=L?m.get(v):g.get(v);if(W&&I){E.add(v);const A={...W,_treeDepth:I.depth,_isExpanded:c.has(v),_hasChildren:L,_groupingField:I.groupingField,_groupingValue:I.groupingValue,_descendantCount:I.descendantCount};w.push(A),k.has(v)&&L&&f(I.children)}})},k=c;return f(h),w},[t,e,b,h,m,d,a,c,o]),P=i.useCallback(w=>b.get(w),[b]),j=i.useMemo(()=>{const w=new Map;return b.forEach((E,g)=>{const x=!!(E.children&&E.children.length>0);w.set(g,{hasChildren:x,treeDepth:E.depth,groupingField:E.groupingField,groupingValue:E.groupingValue,descendantCount:E.descendantCount,isGroupRow:x,isExpanded:x?c.has(g):void 0})}),w},[b,c]);return i.useMemo(()=>({treeNodes:b,groupingRows:m,toggleExpansion:_,isGroupExpanded:C,getVisibleRows:S,getNode:P,rowMetaMap:j}),[b,m,_,C,S,P,j])}function Ko(n){const{rows:t,getRowId:e,processRowUpdate:o,onProcessRowUpdateError:l,onRowChange:s}=n,[d,a]=i.useState(null),u=i.useRef(null),c=i.useCallback(m=>{a(m),u.current=typeof m=="function"?m(u.current):m},[]),p=i.useCallback(m=>{c({id:m.id,field:m.field,value:m.value,originalValue:m.value})},[c]),b=i.useCallback(async m=>{const _=u.current;if(!_)return;if(m?.cancel){c(null);return}const{id:C,field:S,value:P,originalValue:j}=_;if(P===j){c(null);return}const w=t.find(g=>e(g)===C);if(!w){c(null);return}const E={...w,[S]:P};try{if(o){const g=await o(E,w);s?.(g)}else s?.(E);c(null)}catch(g){l?.(g)}},[c,t,e,o,s,l]),h=i.useCallback(m=>{d&&d.id===m.id&&d.field===m.field&&c(_=>_?{..._,value:m.value}:null)},[d,c]);return{editingCell:d,startCellEdit:p,stopCellEdit:b,setEditCellValue:h}}function Yo(n,t,e){const[o,l]=i.useState(new Map),[s,d]=i.useState({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}}),a=i.useCallback(()=>{l(new Map)},[]),u=i.useCallback((C,S)=>o.get(C)?.[S],[o]),c=i.useCallback((C,S,P,j,w)=>{const E=new Map(o);for(let g=j;g<w;g++){const x=t[g];if(!x)continue;let f=1;if(x.colSpan)if(typeof x.colSpan=="function"){const M={row:S,value:S[x.field],field:x.field,colDef:x,rowIndex:P,colIndex:g};f=x.colSpan(M)}else f=x.colSpan;if(f<=1){Ue(E,C,x.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:e[x.field]||100}});continue}let k=e[x.field]||100;for(let M=1;M<f;M++)if(g+M<w){const N=t[g+M];N&&(k+=e[N.field]||100,Ue(E,C,N.field,{spannedByColSpan:!0,leftVisibleCellIndex:g,rightVisibleCellIndex:Math.min(g+f-1,t.length-1)}))}Ue(E,C,x.field,{spannedByColSpan:!1,cellProps:{colSpan:f,width:k}}),g+=f-1}l(E)},[o,t,e]),p=i.useCallback((C,S)=>{const P={},j={},w={};t.forEach((E,g)=>{if(E.rowSpan)for(let x=C;x<S;x++){const f=n[x];if(!f||j[f.id]?.[E.field])continue;const k=E.valueGetter?E.valueGetter({row:f,field:E.field,value:f[E.field]}):f[E.field];let M=1;if(typeof E.rowSpan=="function"){const N={row:f,value:k,field:E.field,colDef:E,rowIndex:x,colIndex:g};M=E.rowSpan(N)}else typeof E.rowSpan=="number"&&(M=E.rowSpan);if(M>1){P[f.id]||(P[f.id]={}),P[f.id][E.field]=M;for(let N=1;N<M;N++){const v=x+N;if(v<S&&n[v]){const I=n[v];j[I.id]||(j[I.id]={}),j[I.id][E.field]=!0,w[v]||(w[v]={}),w[v][E.field]=x}}}}}),d({caches:{spannedCells:P,hiddenCells:j,hiddenCellOriginMap:w},processedRange:{firstRowIndex:C,lastRowIndex:S}})},[n,t]),b=i.useCallback(()=>{d({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}})},[]);i.useEffect(()=>{const C=new Map;n.forEach((w,E)=>{for(let g=0;g<t.length;g++){const x=t[g];if(!x)continue;let f=1;if(x.colSpan)if(typeof x.colSpan=="function"){const M={row:w,value:w[x.field],field:x.field,colDef:x,rowIndex:E,colIndex:g};f=x.colSpan(M)}else f=x.colSpan;if(f<=1){const M=e[x.field]||(typeof x.width=="number"?x.width:100);Ue(C,w.id,x.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:M}});continue}let k=e[x.field]||(typeof x.width=="number"?x.width:100);for(let M=1;M<f;M++)if(g+M<t.length){const N=t[g+M];if(N){const v=e[N.field]||(typeof N.width=="number"?N.width:100);k+=v,Ue(C,w.id,N.field,{spannedByColSpan:!0,leftVisibleCellIndex:g,rightVisibleCellIndex:Math.min(g+f-1,t.length-1)})}}Ue(C,w.id,x.field,{spannedByColSpan:!1,cellProps:{colSpan:f,width:k}}),g+=f-1}}),l(C);const S={},P={},j={};t.forEach((w,E)=>{if(w.rowSpan)for(let g=0;g<n.length;g++){const x=n[g];if(!x||P[x.id]?.[w.field])continue;const f=w.valueGetter?w.valueGetter({row:x,field:w.field,value:x[w.field]}):x[w.field];let k=1;if(typeof w.rowSpan=="function"){const M={row:x,value:f,field:w.field,colDef:w,rowIndex:g,colIndex:E};k=w.rowSpan(M)}else typeof w.rowSpan=="number"&&(k=w.rowSpan);if(k>1){S[x.id]||(S[x.id]={}),S[x.id][w.field]=k;for(let M=1;M<k;M++){const N=g+M;if(N<n.length&&n[N]){const v=n[N];P[v.id]||(P[v.id]={}),P[v.id][w.field]=!0,j[N]||(j[N]={}),j[N][w.field]=g}}}}}),d({caches:{spannedCells:S,hiddenCells:P,hiddenCellOriginMap:j},processedRange:{firstRowIndex:0,lastRowIndex:n.length}})},[n,t,e]);const h=i.useCallback(()=>s.caches.spannedCells,[s]),m=i.useCallback(()=>s.caches.hiddenCells,[s]),_=i.useCallback(()=>s.caches.hiddenCellOriginMap,[s]);return{colspanMap:o,resetColSpan:a,getCellColSpanInfo:u,calculateColSpan:c,rowSpanningState:s,calculateRowSpan:p,resetRowSpan:b,getSpannedCells:h,getHiddenCells:m,getHiddenCellOriginMap:_}}function Ue(n,t,e,o){let l=n.get(t);l||(l={},n.set(t,l)),l[e]=o}function qo(n){const{dataSource:t,sortModel:e,filterModel:o,paginationModel:l,paginationMode:s,sortingMode:d,filterMode:a,aggregationModel:u,setRows:c,setRowCount:p,setDataSourceLoading:b,setDataSourceError:h,onAggregationResults:m}=n,_=i.useRef(null),C=i.useRef(0),S=i.useCallback(async()=>{if(!t)return;const j=++C.current;b(!0),h(null);const w=l.page*l.pageSize,E=w+l.pageSize,g={startRow:w,endRow:E,sortModel:e,filterModel:o,groupKeys:[],aggregationModel:u};try{const x=await t.getRows(g);if(j!==C.current)return;let f=!1;if(s==="infinite"){const k=_.current;if(k){const M=JSON.stringify(k.sortModel)!==JSON.stringify(e),N=JSON.stringify(k.filterModel)!==JSON.stringify(o),v=k.pageSize!==l.pageSize;!M&&!N&&!v&&l.page>k.page&&(f=!0)}}c(f?k=>[...k,...x.rows]:x.rows,!0),x.aggregationResults&&m&&m(x.aggregationResults),x.rowCount!==void 0&&p(x.rowCount),_.current={sortModel:e,filterModel:o,page:l.page,pageSize:l.pageSize}}catch(x){j===C.current&&(h(x),console.error("Data Source Error:",x))}finally{j===C.current&&b(!1)}},[t,l.page,l.pageSize,e,o,s,u,m,c,p,b,h]);i.useEffect(()=>{if(t&&(s==="server"||s==="infinite"||d==="server"||a==="server")){const w=setTimeout(()=>{S()},300);return()=>clearTimeout(w)}},[S,t,s,d,a]);const P=i.useCallback(async(j,w)=>{if(t){b(!0);try{const E=await t.getRows({startRow:0,endRow:-1,sortModel:e,filterModel:o,groupKeys:w});E.rows.length>0&&c(g=>{const x=new Set(g.map(k=>k.id)),f=E.rows.filter(k=>!x.has(k.id));return[...g,...f]})}catch(E){h(E),console.error("Failed to fetch children:",E)}finally{b(!1)}}},[t,e,o,c,b,h]);return{fetchRows:S,fetchChildren:P}}const Cn="\0",ft="";function Xo(n,t){const e=n.filter(o=>o!=null&&!isNaN(o));if(e.length===0)return null;switch(t){case"sum":return e.reduce((o,l)=>o+l,0);case"avg":return e.reduce((o,l)=>o+l,0)/e.length;case"count":return e.length;case"min":return Math.min(...e);case"max":return Math.max(...e)}}function Ct(n,t){return t.map(e=>String(n[e]??"")).join(Cn)}function Gt(n,t,e,o){return o?`${n}${ft}${t}${ft}${e}`:`${t}${ft}${e}`}function yn(n,t,e,o){return i.useMemo(()=>{const l={pivotRows:[],pivotColumns:[],colKeys:[],isValid:!1};if(!o)return l;const{rowFields:s,columnFields:d,valueFields:a}=e;if(s.length===0||a.length===0)return l;const u=d.length>0,c=new Map(t.map(j=>[j.field,j])),p=new Set;for(const j of n)p.add(Ct(j,d));const b=Array.from(p).sort(),h=new Map;for(const j of n){const w=Ct(j,s);if(!h.has(w)){const f={};for(const k of s)f[k]=j[k];h.set(w,{labelValues:f,bucket:new Map})}const E=h.get(w),g=Ct(j,d);E.bucket.has(g)||E.bucket.set(g,new Map);const x=E.bucket.get(g);for(const f of a){const k=j[f.field];x.has(f.field)||x.set(f.field,[]),k!=null&&!isNaN(Number(k))&&x.get(f.field).push(Number(k))}}let m=0;const _=[];for(const[,j]of h){const w={id:m++,...j.labelValues};for(const E of b){const g=j.bucket.get(E);for(const x of a){const f=Gt(E,x.field,x.aggFn,u),k=g?.get(x.field)??[];w[f]=k.length>0?Xo(k,x.aggFn):null}}_.push(w)}const C=new Map;for(const j of n){const w=Ct(j,d);for(const E of a){if(E.aggFn!=="avg"&&E.aggFn!=="min"&&E.aggFn!=="max")continue;const g=`${w}${ft}${E.field}`;C.has(g)||C.set(g,[]);const x=j[E.field];x!=null&&!isNaN(Number(x))&&C.get(g).push(Number(x))}}const S={id:"__pivot_grand_total__"};for(let j=0;j<s.length;j++)S[s[j]]=j===0?"Grand Total":"";for(const j of b)for(const w of a){const E=Gt(j,w.field,w.aggFn,u),g=_.map(f=>f[E]).filter(f=>f!=null&&!isNaN(Number(f))).map(Number);if(g.length===0){S[E]=null;continue}const x=`${j}${ft}${w.field}`;switch(w.aggFn){case"sum":case"count":S[E]=g.reduce((f,k)=>f+k,0);break;case"avg":{const f=C.get(x)??[];S[E]=f.length>0?f.reduce((k,M)=>k+M,0)/f.length:null;break}case"min":S[E]=Math.min(...C.get(x)??g);break;case"max":S[E]=Math.max(...C.get(x)??g);break}}_.push(S);const P=[];for(const j of s){const w=c.get(j);P.push({field:j,headerName:w?.headerName??j,width:w?.width??140,sortable:!0})}for(const j of b){const w=u?j.split(Cn).map((E,g)=>{const x=c.get(d[g]);return x?.headerName?`${x.headerName}: ${E}`:E}).join(" / "):"";for(const E of a){const g=c.get(E.field),x=Gt(j,E.field,E.aggFn,u),f=E.headerName??g?.headerName??E.field,k=w?`${w} — ${f} (${E.aggFn})`:`${f} (${E.aggFn})`;P.push({field:x,headerName:k,width:140,type:"number",align:"right",headerAlign:"right",sortable:!0,valueFormatter:({value:M})=>{if(M==null)return"—";const N=Number(M);return E.aggFn==="avg"?N.toFixed(2):E.aggFn==="count"?N.toLocaleString():g?.valueFormatter?g.valueFormatter({value:M,row:{},field:E.field}):N.toLocaleString()}})}}return{pivotRows:_,pivotColumns:P,colKeys:b,isValid:!0}},[n,t,e,o])}function Jo(n){const t=document.createElement("textarea");t.value=n,t.style.cssText="position:fixed;top:-9999px;left:-9999px;opacity:0;",document.body.appendChild(t),t.focus(),t.select();let e=!1;try{e=document.execCommand("copy")}finally{document.body.removeChild(t)}return e}async function Qo(n){let t=!1;try{t=Jo(n)}catch{}if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")try{await navigator.clipboard.writeText(n);return}catch(e){if(t)return;throw e}else if(!t)throw new Error("Clipboard API not available and fallback failed.")}function Zo(n){const{selectedRowIds:t,columns:e,getVisibleRows:o,getRowId:l}=n,s=i.useCallback(async()=>{if(t.size===0)return;const a=o().filter(h=>t.has(l(h)));if(a.length===0)return;const u=e.filter(h=>!h.field.startsWith("__")),c=u.map(h=>h.headerName||h.field).join(" "),p=a.map(h=>u.map(m=>{const _=h[m.field];return m.valueFormatter?m.valueFormatter({value:_,row:h,field:m.field}):_??""}).join(" ")).join(`
|
|
7
|
+
`),b=`${c}
|
|
8
|
+
${p}`;try{await Qo(b)}catch(h){console.error("[OpenGridX] Failed to copy to clipboard:",h)}},[t,e,o,l]);return i.useEffect(()=>{const d=a=>{if(!(a.ctrlKey||a.metaKey)||a.key!=="c")return;const u=document.activeElement,c=u?.tagName.toLowerCase(),p=u?.type;c==="input"&&p!=="checkbox"&&p!=="radio"||c==="textarea"||c==="select"||u?.isContentEditable||s()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[s]),{copySelectedRows:s}}function er({row:n,rowIndex:t,listViewColumn:e,isSelected:o=!1,checkboxSelection:l=!1,rowHeight:s,onRowClick:d,onSelectionChange:a}){const u={row:n,value:void 0,field:e.field,colDef:{field:e.field},rowIndex:t,colIndex:0},c=p=>{p.stopPropagation(),a?.(n.id,p.target.checked)};return r.jsxs("div",{className:`ogx-list-view__row${o?" ogx-list-view__row--selected":""}`,style:s?{minHeight:s}:void 0,onClick:()=>d?.(n),role:"row","aria-rowindex":t+2,"aria-selected":o,children:[l&&r.jsx("div",{className:"ogx-list-view__checkbox",onClick:p=>p.stopPropagation(),children:r.jsx("input",{type:"checkbox",checked:o,onChange:c,"aria-label":`Select row ${n.id}`})}),r.jsx("div",{className:"ogx-list-view__cell",role:"gridcell",children:e.renderCell(u)})]})}function tr({ariaLabel:n,allRenderableRows:t,filteredRows:e,pagination:o,effectivePaginationModel:l,pageSizeOptions:s,selectedRowIds:d,listViewColumn:a,noRowsLabel:u,rowHeight:c,checkboxSelection:p,paginationMode:b,dataSource:h,serverRowCount:m,paginationSlot:_,paginationSlotProps:C,localeText:S,onRowClick:P,onSelectionChange:j,onPaginationModelChange:w}){const E=_||_n,g=b==="server"&&h?m||0:e.length;return r.jsxs("div",{className:"ogx-list-view",role:"grid","aria-label":n||"Data grid list view","aria-rowcount":t.length+1,children:[r.jsx("div",{className:"ogx-list-view__toolbar",children:r.jsxs("span",{children:[e.length," ",e.length===1?"item":"items",o?` · page ${l.page+1} of ${Math.ceil(e.length/l.pageSize)||1}`:"",d.size>0?` · ${d.size} selected`:""]})}),r.jsx("div",{className:"ogx-list-view__rows",children:t.length===0?r.jsxs("div",{className:"ogx-list-view__empty","aria-live":"polite",role:"status",children:[r.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[r.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),r.jsx("path",{d:"M3 9h18M9 21V9"})]}),u]}):t.map((x,f)=>r.jsx(er,{row:x,rowIndex:f,listViewColumn:a,isSelected:d.has(x.id),checkboxSelection:p,rowHeight:c,onRowClick:k=>P({row:k,id:k.id,rowIndex:f}),onSelectionChange:j},x.id))}),o&&r.jsx(E,{page:l.page,pageSize:l.pageSize,rowCount:g,pageSizeOptions:s,onPageChange:x=>w({...l,page:x}),onPageSizeChange:x=>w({...l,pageSize:x,page:0}),localeText:S,...C})]})}function nr({value:n,onValueChange:t,onCommit:e,onCancel:o}){const[l,s]=i.useState(String(n??"")),d=i.useRef(null);return i.useEffect(()=>{d.current?.focus(),d.current?.select()},[]),r.jsx("input",{ref:d,type:"text",className:"ogx__edit-input",value:l,onChange:a=>{s(a.target.value),t(a.target.value)},onBlur:e,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),e()),a.key==="Escape"&&(a.stopPropagation(),o())}})}function or({value:n,onValueChange:t,onCommit:e,onCancel:o}){const[l,s]=i.useState(typeof n=="number"?n:""),d=i.useRef(null);return i.useEffect(()=>{d.current?.focus(),d.current?.select()},[]),r.jsx("input",{ref:d,type:"number",className:"ogx__edit-input ogx__edit-input--number",value:l,onChange:a=>{const u=a.target.value===""?"":Number(a.target.value);s(u),t(u===""?null:u)},onBlur:e,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),e()),a.key==="Escape"&&(a.stopPropagation(),o())}})}function rr({value:n,onValueChange:t,onCommit:e,onCancel:o}){const l=i.useRef(null);i.useEffect(()=>{l.current?.focus()},[]);const s=()=>{t(!n),setTimeout(e,0)};return r.jsx("div",{className:"ogx__edit-boolean",children:r.jsx("input",{ref:l,type:"checkbox",className:"ogx__edit-checkbox",checked:!!n,onChange:s,onKeyDown:d=>{d.key==="Escape"&&(d.stopPropagation(),o())}})})}function ir({value:n,colDef:t,onValueChange:e,onCommit:o,onCancel:l}){const s=i.useRef(null);i.useEffect(()=>{s.current?.focus()},[]);const d=t.valueOptions??[];return r.jsx("select",{ref:s,className:"ogx__edit-select",value:String(n??""),onChange:a=>{e(a.target.value)},onBlur:o,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),o()),a.key==="Escape"&&(a.stopPropagation(),l())},children:d.map(a=>{const u=typeof a=="object"?a.value:a,c=typeof a=="object"?a.label:String(a);return r.jsx("option",{value:String(u),children:c},String(u))})})}function lr({value:n,onValueChange:t,onCommit:e,onCancel:o}){const[l,s]=i.useState(typeof n=="string"?n:String(n??"")),d=i.useRef(null);return i.useEffect(()=>{d.current?.focus()},[]),r.jsx("input",{ref:d,type:"date",className:"ogx__edit-input",value:l,onChange:a=>{s(a.target.value),t(a.target.value)},onBlur:e,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),e()),a.key==="Escape"&&(a.stopPropagation(),o())}})}function sr(n){const{colDef:t}=n;switch(t.type){case"number":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(or,{...n})});case"boolean":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(rr,{...n})});case"singleSelect":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(ir,{...n})});case"date":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(lr,{...n})});default:return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(nr,{...n})})}}class ar extends i.Component{constructor(t){super(t),this.state={hasError:!1,error:null,resetKey:t.resetKey}}static getDerivedStateFromProps(t,e){return e.hasError&&t.resetKey!==e.resetKey?{hasError:!1,error:null,resetKey:t.resetKey}:t.resetKey!==e.resetKey?{resetKey:t.resetKey}:null}static getDerivedStateFromError(t){return{hasError:!0,error:t}}render(){return this.state.hasError?r.jsx("div",{className:"ogx__cell-error",role:"status","aria-label":`Error in cell: ${this.props.field}`,title:this.state.error?.message??"Render error",children:"⚠"}):this.props.children}}function dr(n){const{onCellClick:t,onCellEditStart:e,onCellValueChange:o,value:l,row:s,colDef:d,rowIndex:a,colIndex:u,isSelected:c,onClick:p,width:b,pinnedPosition:h,pinnedOffset:m,isFocused:_,isFocusVisible:C,isEditable:S,isEditing:P,onEditStart:j,onEditStop:w,onValueChange:E,colSpanInfo:g,rowSpan:x,isHiddenByRowSpan:f,rowMeta:k}=n,M=i.useCallback(y=>{o?o(d.field,y):E?.(y)},[o,E,d.field]),N=i.useMemo(()=>d.valueFormatter?d.valueFormatter({value:l,row:s,field:d.field}):l==null?"":String(l),[l,s,d]),v=i.useMemo(()=>d.cellClassName?typeof d.cellClassName=="function"?d.cellClassName({value:l,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:u})||"":d.cellClassName:"",[d,l,s,a,u]),I=i.useRef(null);if(i.useLayoutEffect(()=>{_&&I.current&&I.current.focus({preventScroll:!0})},[_]),g?.spannedByColSpan)return null;if(f)return r.jsx("div",{className:"ogx__cell ogx__cell--hidden",style:{width:b??d.width??100},role:"presentation","data-field":d.field,"data-colindex":u});const L=y=>{t&&t({row:s,field:d.field,value:l,colDef:d,rowIndex:a,colIndex:u}),p?.(y)},W=y=>{S&&(j||e)&&(y.stopPropagation(),e?e(d.field,l):j?.())},A=h!=null,G=["ogx__cell",`ogx__cell--align-${d.align||"left"}`,c&&"ogx__cell--selected",_&&"ogx__cell--focused",_&&C&&"ogx__cell--focus-visible",d.type&&`ogx__cell--type-${d.type}`,A&&"ogx__cell--pinned",A&&`ogx__cell--pinned-${h}`,P&&"ogx__cell--editing",x&&x>1&&"ogx__cell--spanned",v].filter(Boolean).join(" "),T=g?.cellProps?.colSpan||1,B=x||1,Y=g?.cellProps?.width??b??d.width??100,K={width:"var(--width)","--width":typeof Y=="number"?`${Y}px`:Y,flexGrow:d.flex??0,flexShrink:0,flexBasis:(d.flex,"auto"),boxSizing:"border-box",minWidth:d.minWidth,maxWidth:d.maxWidth,position:A?"sticky":void 0,zIndex:d.zIndex??(A?3:void 0),padding:P?0:void 0};return B>1&&(K.height=`calc(var(--height) * ${B} - var(--border-width, 1px))`,K.zIndex=10,A&&(K.zIndex=40)),A&&m!==void 0&&(h==="left"?K.left=m:K.right=m),r.jsx("div",{ref:I,className:G,style:K,onClick:L,onDoubleClick:W,role:"gridcell","aria-colindex":u+1,"aria-readonly":!S||void 0,tabIndex:-1,"data-field":d.field,"data-colindex":u,...T>1?{"aria-colspan":T}:{},...B>1?{"aria-rowspan":B}:{},children:r.jsx("div",{className:"ogx__cell-content",children:P&&(o||E)&&w?d.renderEditCell?d.renderEditCell({value:l,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:u,rowMeta:k}):r.jsx(sr,{value:l,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:u,onValueChange:M,onCommit:()=>w(),onCancel:()=>w(!0)}):d.renderCell?r.jsx(ar,{field:d.field,resetKey:l,children:d.renderCell({value:l,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:u,rowMeta:k})}):N})})}const kn=i.memo(dr),cr=({className:n="",...t})=>r.jsx("button",{type:"button",className:`ogx-drag-handle ${n}`,"aria-label":"Drag to reorder row",...t,children:r.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"currentColor","aria-hidden":"true",children:r.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 ur(n){const{content:t,height:e,isExpanded:o}=n;if(!o)return null;const l={height:e==="auto"?"auto":`${e}px`,overflow:e==="auto"?"visible":"auto"};return r.jsx("div",{className:"ogx__detail-panel",style:l,children:r.jsx("div",{className:"ogx__detail-panel-content",children:t})})}function yt(n){const{row:t,columns:e,rowIndex:o,isSelected:l=!1,checkboxSelection:s=!1,onRowClick:d,onCellClick:a,onSelectionChange:u,columnWidths:c={},pinnedColumns:p,pinnedRows:b,hasDetailPanel:h=!1,isDetailPanelExpanded:m=!1,onDetailPanelToggle:_,detailPanelContent:C,detailPanelHeight:S=200,pinCheckboxColumn:P=!0,pinExpandColumn:j=!0,rowReordering:w=!1,onDragStart:E,onDragOver:g,onDragEnd:x,onDrop:f,isDragging:k,isDragOver:M,editingCell:N,onEditStart:v,onEditStop:I,onEditCellValueChange:L,focusedCellField:W,isFocusVisible:A,colspanMap:G,rowSpanningCaches:T,rowHeight:B=52,rowMeta:Y}=n,K=i.useId(),y=i.useRef(null),O=i.useRef(null);i.useLayoutEffect(()=>{W==="__expand_col__"&&y.current&&y.current.focus({preventScroll:!0}),W==="__checkbox_col__"&&O.current&&O.current.focus({preventScroll:!0})},[W]);const z=i.useMemo(()=>Bt(e,c,p,s,P,h,j,w),[e,c,p,s,P,h,j,w]),$=Y?.hasChildren===!0,H=i.useCallback((F,ie)=>{$||v?.({id:t.id,field:F,value:ie})},[$,t.id,v]),X=i.useCallback((F,ie)=>{L?.({id:t.id,field:F,value:ie})},[L,t.id]),U=i.useCallback(F=>{I?.({cancel:F})},[I]);if(t._isSkeleton){const F=Math.max(e.length,5);return r.jsx("div",{className:"ogx__row ogx__row--skeleton",role:"row","aria-hidden":"true",style:{height:B,minHeight:B},children:Array.from({length:F}).map((ie,se)=>r.jsx("div",{className:"ogx__skeleton-cell",children:r.jsx("div",{className:"ogx__skeleton-bar"})},se))})}const te=F=>{F.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell")||d?.({row:t,id:t.id,rowIndex:o})},R=F=>{F.stopPropagation(),u?.(t.id,F.target.checked)},J=F=>{F.stopPropagation(),_?.(t.id)},Q=$t(t.id,b),le=Q==="top",oe=Q==="bottom",pe=["ogx__row",l&&"ogx__row--selected",o%2===0&&"ogx__row--even",o%2===1&&"ogx__row--odd",le&&"ogx__row--pinned-top",oe&&"ogx__row--pinned-bottom",k&&"ogx__row--dragging",M&&"ogx__row--drag-over",$&&"ogx__row--group"].filter(Boolean).join(" ");return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:pe,onClick:te,role:"row","aria-rowindex":o+1,"aria-selected":l,"data-rowindex":o,onDragOver:g?g(t.id):void 0,onDrop:f?f(t.id):void 0,style:{maxHeight:`${B}px`,minHeight:`${B}px`,"--height":`${B}px`,"--border-width":"1px"},children:[w&&r.jsx("div",{className:"ogx__cell ogx__cell--drag-handle",role:"gridcell","aria-label":"Drag to reorder row",style:{position:"sticky",left:0,zIndex:4},draggable:!0,onDragStart:E?E(t.id):void 0,onDragEnd:x,onClick:F=>F.stopPropagation(),children:r.jsx(cr,{})}),h&&r.jsx("div",{className:`ogx__cell ogx__cell--expand ${j?"ogx__cell--pinned-left":""} ${W==="__expand_col__"?"ogx__cell--focused":""} ${W==="__expand_col__"&&A?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":m?"Collapse row details":"Expand row details","aria-expanded":m,style:{position:j?"sticky":void 0,left:j?w?48:0:void 0,zIndex:j?5:void 0},ref:y,tabIndex:-1,onClick:F=>{F.stopPropagation(),a?.({row:t,field:"__expand_col__",value:m,colDef:{field:"__expand_col__",width:48},rowIndex:o,colIndex:-1})},children:r.jsx(mn,{isExpanded:m,onClick:J,variant:"plus-minus"})}),s&&r.jsx("div",{className:`ogx__cell ogx__cell--checkbox ${P?"ogx__cell--pinned-left":""} ${W==="__checkbox_col__"?"ogx__cell--focused":""} ${W==="__checkbox_col__"&&A?"ogx__cell--focus-visible":""}`,role:"gridcell",style:{position:P?"sticky":void 0,left:P?(w?48:0)+(h&&j?48:0):void 0,zIndex:P?11:void 0},ref:O,tabIndex:-1,onClick:F=>{F.stopPropagation(),a?.({row:t,field:"__checkbox_col__",value:l,colDef:{field:"__checkbox_col__",width:48},rowIndex:o,colIndex:-1})},children:r.jsx(ct,{id:K,name:`ogx-select-row-${t.id}`,checked:l,onChange:R,onClick:F=>F.stopPropagation(),"aria-label":l?`Deselect row ${t.id}`:`Select row ${t.id}`,tabIndex:-1,onMouseDown:F=>F.preventDefault()})}),e.map((F,ie)=>{if(F.isSpacer)return r.jsx("div",{style:{width:F.width,minWidth:F.width,flexShrink:0},"aria-hidden":"true"},F.field);const se=F.valueGetter?F.valueGetter({row:t,field:F.field,value:t[F.field]}):t[F.field],D=c[F.field]??F.width,q=dt(F.field,p),ee=q?z[F.field]:void 0,de=N?.id===t.id&&N?.field===F.field,ce=de?N?.value:se,je=G?.get(t.id)?.[F.field],We=T?.spannedCells[t.id]?.[F.field],Ee=T?.hiddenCells[t.id]?.[F.field]||!1;return r.jsx(kn,{value:ce,row:t,colDef:F,rowIndex:o,colIndex:ie,isSelected:l,onCellClick:a,width:D,pinnedPosition:q,pinnedOffset:ee,isFocused:W===F.field,isFocusVisible:A,isEditable:F.editable,isEditing:de,onCellEditStart:H,onEditStop:U,onCellValueChange:X,colSpanInfo:je,rowSpan:We,isHiddenByRowSpan:Ee,rowMeta:Y},F.field)})]}),h&&r.jsx(ur,{row:t,rowId:t.id,rowIndex:o,content:C,height:S,isExpanded:m})]})}function Sn({rows:n,position:t,columns:e,selectedRowIds:o,checkboxSelection:l,onRowClick:s,onCellClick:d,onSelectionChange:a,columnWidths:u,pinnedColumns:c,pinnedRows:p,hasDetailPanel:b,expandedRowIds:h,getDetailPanelContent:m,getDetailPanelHeight:_,onDetailPanelToggle:C,pinCheckboxColumn:S,pinExpandColumn:P,focusedCell:j,colspanMap:w,rowSpanningCaches:E,rowHeight:g,rowMetaMap:x}){return n.length===0?null:r.jsx("div",{className:`ogx__pinned-rows ogx__pinned-rows--${t}`,role:"rowgroup",children:n.map((f,k)=>r.jsx(yt,{row:f,columns:e,rowIndex:k,isSelected:o.has(f.id),checkboxSelection:l,onRowClick:s,onCellClick:d,onSelectionChange:a,columnWidths:u,pinnedColumns:c,pinnedRows:p,hasDetailPanel:b,isDetailPanelExpanded:h.has(f.id),detailPanelContent:m?m({row:f,id:f.id,rowIndex:k}):null,detailPanelHeight:_?.({row:f,id:f.id,rowIndex:k})||200,onDetailPanelToggle:C,pinCheckboxColumn:S,pinExpandColumn:P,focusedCellField:j?.id===f.id?j.field:null,colspanMap:w,rowSpanningCaches:E,rowHeight:g,rowMeta:x.get(f.id)},f.id))})}const fr=({columns:n,rowHeight:t,checkboxSelection:e=!1,hasDetailPanel:o=!1,rowReordering:l=!1})=>r.jsxs("div",{className:"ogx__row ogx__skeleton-row",style:{height:t},role:"row",children:[e&&r.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:r.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),o&&r.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:r.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),l&&r.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:r.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),n.map((s,d)=>{const a=typeof s.width=="number"?s.width:150,u=Math.min(a*.7,a-20);return r.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:a,minWidth:s.minWidth,maxWidth:s.maxWidth,left:s.left,right:s.right,position:s.isSpacer?"relative":s.pinned?"sticky":"relative",zIndex:s.zIndex},children:!s.isSpacer&&r.jsx("div",{className:"ogx-skeleton-box",style:{width:u,height:16,borderRadius:4}})},s.field||d)})]});function gr({virtualContainerHeight:n,offsetTop:t,effectiveLoading:e,visibleRows:o,baseColumns:l,virtualColumns:s,viewportWidth:d,checkboxSelection:a,hasDetailPanel:u,rowReordering:c,rowHeight:p,pinnedRows:b,selectedRowIds:h,onRowClick:m,onCellClick:_,onSelectionChange:C,columnWidths:S,pinnedColumns:P,expandedRowIds:j,getDetailPanelContent:w,getDetailPanelHeight:E,onDetailPanelToggle:g,pinCheckboxColumn:x,pinExpandColumn:f,rowReorderHandlers:k,editingHandlers:M,focusedCell:N,colspanMap:v,rowSpanningCaches:I,paginationMode:L,dataSourceLoading:W,sortedUnpinnedRowCount:A,infiniteScrollSkeletonCount:G,unpinnedRowsLength:T,rowMetaMap:B}){const Y=l.length>0?l:(()=>{const y=(d||1e3)-(a?48:0)-(u?48:0)-(c?48:0),O=150,z=Math.max(1,Math.ceil(y/O));return Array.from({length:z},($,H)=>({field:`placeholder_${H}`,headerName:"",width:O}))})(),K=o.filter(({row:y})=>!$t(y.id,b)).filter((y,O,z)=>O===z.findIndex($=>$.row.id===y.row.id));return r.jsx("div",{className:"ogx__virtual-container",style:{height:`${n}px`},role:"presentation",children:r.jsxs("div",{className:"ogx__rows",style:{transform:`translateY(${t}px)`},role:"rowgroup",children:[e&&o.length===0?Array.from({length:10}).map((y,O)=>r.jsx(fr,{columns:Y,rowHeight:p,checkboxSelection:a,hasDetailPanel:u,rowReordering:c},`skeleton-${O}`)):K.map(({row:y,rowIndex:O})=>r.jsx(yt,{row:y,columns:s,rowIndex:O,isSelected:h.has(y.id),checkboxSelection:a,onRowClick:m,onCellClick:_,onSelectionChange:C,columnWidths:S,pinnedColumns:P,pinnedRows:b,hasDetailPanel:u,isDetailPanelExpanded:j.has(y.id),detailPanelContent:w?w({row:y,id:y.id,rowIndex:O}):null,detailPanelHeight:E?.({row:y,id:y.id,rowIndex:O})||200,onDetailPanelToggle:g,pinCheckboxColumn:x,pinExpandColumn:f,rowReordering:c,onDragStart:k.onDragStart,onDragOver:k.onDragOver,onDragEnd:k.onDragEnd,onDrop:k.onDrop,isDragging:k.draggedRowId===y.id,isDragOver:k.dragOverRowId===y.id,editingCell:M.editingCell,onEditStart:M.startCellEdit,onEditStop:M.stopCellEdit,onEditCellValueChange:M.setEditCellValue,focusedCellField:N!=null&&N.id===y.id?N.field:null,colspanMap:v,rowSpanningCaches:I,rowHeight:p,rowMeta:B.get(y.id)},y.id)),L==="infinite"&&W&&A>0&&r.jsx("div",{className:"ogx__skeleton-group",children:Array.from({length:G}).map((y,O)=>r.jsx(yt,{row:{id:`__skeleton_${O}__`,_isSkeleton:!0},columns:s,rowIndex:T+O,rowHeight:p},`__skeleton_${O}__`))})]})})}function hr(){return r.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function pr(){return r.jsxs("svg",{className:"ogx-column-visibility-panel__drag-handle",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[r.jsx("circle",{cx:"9",cy:"5",r:"1.5"}),r.jsx("circle",{cx:"15",cy:"5",r:"1.5"}),r.jsx("circle",{cx:"9",cy:"12",r:"1.5"}),r.jsx("circle",{cx:"15",cy:"12",r:"1.5"}),r.jsx("circle",{cx:"9",cy:"19",r:"1.5"}),r.jsx("circle",{cx:"15",cy:"19",r:"1.5"})]})}function jn(n){const{columns:t,visibleColumns:e,onVisibilityChange:o,onShowAll:l,onHideAll:s,onColumnReorder:d,onColumnOrderReset:a}=n,[u,c]=i.useState(""),[p,b]=i.useState(null),h=i.useRef(null),_=i.useMemo(()=>t.filter(x=>x.hideable!==!1),[t]).every(x=>e.has(x.field)),C=i.useMemo(()=>{if(!u)return t;const x=u.toLowerCase();return t.filter(f=>(f.headerName||f.field).toLowerCase().includes(x))},[t,u]),S=x=>{x.target.checked?l():s()},P=x=>f=>{h.current=x,f.dataTransfer.effectAllowed="move",f.dataTransfer.setDragImage(f.currentTarget.closest(".ogx-column-visibility-panel__item"),20,20)},j=x=>f=>{f.preventDefault(),f.dataTransfer.dropEffect="move",x!==h.current&&b(x)},w=()=>{b(null)},E=x=>f=>{f.preventDefault();const k=h.current;b(null),h.current=null,k&&k!==x&&d&&d(k,x)},g=()=>{b(null),h.current=null};return r.jsxs("div",{className:"ogx-column-visibility-panel",children:[r.jsx("div",{className:"ogx-column-visibility-panel__search-section",children:r.jsxs("div",{className:"ogx-column-visibility-panel__search-container",children:[r.jsx(hr,{}),r.jsx("input",{autoComplete:"off",className:"ogx-column-visibility-panel__search-input",placeholder:"Search",value:u,onChange:x=>c(x.target.value)})]})}),r.jsx("div",{className:"ogx-column-visibility-panel__list",children:C.map(x=>{const f=e.has(x.field),k=x.hideable!==!1,M=p===x.field,N=!!d&&!u;return r.jsxs("div",{className:["ogx-column-visibility-panel__item",!k&&"ogx-column-visibility-panel__item--disabled",M&&"ogx-column-visibility-panel__item--drag-over"].filter(Boolean).join(" "),draggable:N,onDragOver:N?j(x.field):void 0,onDragLeave:N?w:void 0,onDrop:N?E(x.field):void 0,onDragEnd:N?g:void 0,children:[N&&r.jsx("span",{className:"ogx-column-visibility-panel__drag-handle-wrapper",draggable:!0,onDragStart:P(x.field),title:"Drag to reorder",children:r.jsx(pr,{})}),r.jsxs("label",{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:[r.jsx(ct,{checked:f,onChange:v=>o(x.field,v.target.checked),disabled:!k}),r.jsx("span",{className:"ogx-column-visibility-panel__label",children:x.headerName||x.field})]})]},x.field)})}),r.jsxs("div",{className:"ogx-column-visibility-panel__footer",children:[r.jsxs("label",{className:"ogx-column-visibility-panel__item",children:[r.jsx(ct,{checked:_,onChange:S}),r.jsx("span",{className:"ogx-column-visibility-panel__label",children:"Show/Hide All"})]}),r.jsx("button",{className:"ogx-column-visibility-panel__reset-btn",onClick:()=>{l(),a?.()},children:"Reset"})]})]})}function xr({isOpen:n,containerRef:t,panelRef:e,effectiveColumns:o,columnVisibilityModel:l,effectiveColumnOrder:s,columnOrder:d,disableColumnReorder:a,onClose:u,onColumnVisibilityChange:c,onColumnOrderChange:p,setInternalColumnOrder:b}){const[h,m]=i.useState(16),[_,C]=i.useState(16),[S,P]=i.useState(()=>document.body);if(i.useLayoutEffect(()=>{if(!n||!t.current)return;const w=t.current.getBoundingClientRect();m(w.top+8),C(window.innerWidth-w.right+8),P(t.current.closest(".ogx-theme-provider")||document.body)},[n,t]),!n)return null;const j=a?void 0:(w,E)=>{const g=[...s],x=g.indexOf(w),f=g.indexOf(E);if(x===-1||f===-1)return;const k=[...g];k.splice(x,1),k.splice(f,0,w),d||b(k),p?.({oldIndex:x,targetIndex:f,column:o.find(M=>M.field===w)})};return ze.createPortal(r.jsxs("div",{ref:e,style:{position:"fixed",top:h,right:_,zIndex:9999,display:"inline-block"},children:[r.jsx("button",{onClick:u,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:"×"}),r.jsx(jn,{columns:o,visibleColumns:new Set(o.filter(w=>l[w.field]!==!1).map(w=>w.field)),onVisibilityChange:(w,E)=>{c({...l,[w]:E})},onShowAll:()=>{const w={...l};o.forEach(E=>{E.hideable!==!1&&(w[E.field]=!0)}),c(w)},onHideAll:()=>{const w={...l};o.forEach(E=>{E.hideable!==!1&&(w[E.field]=!1)}),c(w)},onColumnReorder:j})]}),S)}const mr=new Map;function br(n){const{rows:t,columns:e,getRowId:o,rowHeight:l=52,headerHeight:s=56,autoHeight:d=!1,checkboxSelection:a=!1,rowSelectionModel:u,onRowSelectionModelChange:c,onRowClick:p,onCellClick:b,filterModel:h,onFilterModelChange:m,sortModel:_,onSortModelChange:C,pagination:S=!1,paginationModel:P={page:0,pageSize:100},onPaginationModelChange:j,pageSizeOptions:w=[10,25,50,100],pinnedColumns:E,onPinnedColumnsChange:g,pinnedRows:x,getDetailPanelContent:f,getDetailPanelHeight:k,detailPanelExpandedRowIds:M,onDetailPanelExpandedRowIdsChange:N,pinCheckboxColumn:v=!0,pinExpandColumn:I=!0,disableColumnReorder:L=!1,columnOrder:W,onColumnOrderChange:A,height:G,rowReordering:T=!1,onRowOrderChange:B,loading:Y=!1,treeData:K=!1,getTreeDataPath:y,defaultGroupingExpansionDepth:O,rowGroupingModel:z,aggregationModel:$,onAggregationModelChange:H,getAggregationPosition:X,isCellEditable:U,processRowUpdate:te,onProcessRowUpdateError:R,dataSource:J,sortingMode:Q="client",filterMode:le="client",paginationMode:oe="client",rowCount:pe,slots:F,slotProps:ie,pivotMode:se=!1,pivotModel:D,onPivotModelChange:q,className:ee="",style:de,onRowsScrollEnd:ce,ariaLabel:je,initialState:We,onStateChange:Ee,columnVisibilityModel:fe,onColumnVisibilityModelChange:Ye,listView:ne=!1,listViewColumn:we,columnGroupingModel:Be,noRowsLabel:ri="No Data",localeText:Me,apiRef:Ut}=n,Kt=Me?.noRowsLabel??ri,ii=i.useMemo(()=>({items:[]}),[]),ke=h||ii,li=i.useMemo(()=>[],[]),Yt=z||li,Ln=i.useRef(F?.toolbar);Ln.current=F?.toolbar;const si=i.useRef(V=>{const Z=Ln.current;return Z?Z(V):null}).current,ai=io({initialState:We,sortModel:_,aggregationModel:$,onAggregationModelChange:H,columnVisibilityModel:fe,onColumnVisibilityModelChange:Ye,pinnedColumns:E,onPinnedColumnsChange:g,pivotModel:D,onPivotModelChange:q,paginationModel:P,onPaginationModelChange:j,rowSelectionModel:u}),{sortModel:Fe,isSortControlled:Rn,setInternalSortModel:On,aggregationModel:Se,handleAggregationModelChange:Wn,columnVisibilityModel:$e,handleColumnVisibilityModelChange:kt,pinnedColumns:Pe,handlePinnedColumnsChange:qt,currentPivotModel:Xt,handlePivotModelChange:Fn,effectivePaginationModel:Ce,handlePaginationModelChange:Jt,selectedRowIds:ve,isSelectionControlled:St,setInternalRowSelectionModel:jt}=ai,Et=c,Nt=yn(t,e,Xt,se),An=se&&Nt.isValid?Nt.pivotRows:t,Qt=se&&Nt.isValid?Nt.pivotColumns:e,[di,zn]=i.useState(null);i.useEffect(()=>{zn(null)},[Se]);const qe=i.useRef(null),ci=i.useRef(null),Mt=i.useRef(null),ui=i.useCallback(V=>V.id,[]),Xe=o||ui,Zt=i.useMemo(()=>An.map(V=>{const Z=Xe(V);return Z===V.id?V:{...V,id:Z}}),[An,Xe]),Je=i.useCallback(V=>{fn.current?.classList.toggle("ogx--kb",V)},[]),Bn=i.useRef(J);Bn.current=J;const $n=i.useRef(null),Dn=i.useRef(null),fi=i.useCallback(V=>{if(Bn.current&&K&&(V.serverChildrenCount??0)>0&&(V.children??[]).length===0){const Z=Dn.current?.getNodePath(V.id)||[V.groupingKey];$n.current?.(V.id,Z)}},[K]),_e=Bo({rows:Zt,columns:Qt,rowHeight:l,headerHeight:s,rowCount:pe,columnVisibilityModel:$e,initialState:n.initialState}),{state:ue,apiRef:Qe,setRows:en,setColumns:gi,setDimensions:Hn,setDataSourceLoading:hi,setDataSourceError:pi,setRowCount:xi}=_e,{scrollTop:mi,scrollLeft:bi,handleScroll:wi}=bo({onRowsScrollEnd:ce});i.useEffect(()=>{Ut&&(Ut.current=Qe.current)},[Ut,Qe]);const{copySelectedRows:Gn}=Zo({selectedRowIds:ve,columns:Qt,getVisibleRows:()=>Qe.current.getVisibleRows(),getRowId:Xe});i.useEffect(()=>{Qe.current.copySelectedRows=Gn,Qe.current.getSelectedRows=()=>Array.from(ve)},[Gn,ve,Qe]);const vi=ue.dataSource.loading,ht=Y||vi,Ze=i.useMemo(()=>ue.rows.allRows.map(V=>ue.rows.idRowsLookup.get(V)),[ue.rows]),pt=Do({rows:Ze,getRowId:Xe,getTreeDataPath:y,treeData:K,defaultGroupingExpansionDepth:O,filterModel:ke,sortModel:Fe,onRowExpansionChange:fi});i.useEffect(()=>{Dn.current=pt},[pt]);const tn=Uo({rows:Ze,getRowId:Xe,rowGroupingModel:Yt,aggregationModel:Se,defaultGroupingExpansionDepth:O,filterModel:ke,sortModel:Fe,getAggregationPosition:X}),et=Ko({rows:Ze,getRowId:Xe,processRowUpdate:te,onProcessRowUpdateError:R,onRowChange:V=>{const{dispatch:Z}=_e,xe=Array.from(_e.state.rows.idRowsLookup.values()).map(he=>he.id===V.id?V:he);Z({type:"SET_ROWS",payload:xe})}}),xt=K,tt=!!(Yt&&Yt.length>0),nn=xt||tt,Pt=xt?pt:tt?tn:null,mt=i.useMemo(()=>xt?pt.rowMetaMap:tt?tn.rowMetaMap:mr,[xt,pt.rowMetaMap,tt,tn.rowMetaMap]),Ie=S&&!tt,It=i.useCallback(V=>{const{row:Z,id:ae}=V;if(nn&&mt.get(Z.id)?.hasChildren){Pt?.toggleExpansion(ae);return}p?.(V)},[nn,Pt,p,mt]),on=qo({dataSource:J,sortModel:Fe,filterModel:ke,paginationModel:Ce,paginationMode:oe,sortingMode:Q,filterMode:le,aggregationModel:Se,setRows:en,setRowCount:xi,setDataSourceLoading:hi,setDataSourceError:pi,onAggregationResults:zn});i.useEffect(()=>{on.fetchChildren&&($n.current=on.fetchChildren)},[on.fetchChildren]),i.useEffect(()=>{J||en(Zt)},[Zt,en,J]);const Te=!!f,[_i,Ci]=i.useState(new Set),nt=M??_i,Tt=i.useCallback(V=>{const Z=new Set(nt);Z.has(V)?Z.delete(V):Z.add(V),M===void 0&&Ci(Z),N?.(Z)},[nt,M,N]),{effectiveColumns:Ae,orderedColumns:rn,visibleOrderedColumns:yi,navigationColumns:Vn,columnWidths:Le,effectiveColumnOrder:Lt,setInternalColumnOrder:Rt,columnReorderHandlers:ot,handleColumnResize:ki}=xo({activeColumns:Qt,isHierarchyEnabled:nn,isRowGrouping:tt,isTreeData:xt,activeHierarchyHandlers:Pt,columnVisibilityModel:$e,columnOrder:W,onColumnOrderChange:A,disableColumnReorder:L,pivotMode:se,checkboxSelection:a,hasDetailPanel:Te,rowReordering:T,initialState:We,setColumns:gi});wo({onStateChange:Ee,sortModel:Fe,filterModel:ke,effectivePaginationModel:Ce,columnWidths:Le,effectiveColumnOrder:Lt,columnVisibilityModel:$e,pinnedColumns:Pe});const rt=go({effectiveRows:Ze,activeHierarchyHandlers:Pt,filterMode:le,filterModel:ke,dataSource:J,sortModel:Fe,sortingMode:Q,pagination:Ie,paginationMode:oe,effectivePaginationModel:Ce,pinnedRows:x,isLoading:ue.dataSource.loading,pageSize:Ce.pageSize}),De=rt.filteredRows,ln=rt.pinnedTopRows,sn=rt.pinnedBottomRows,it=rt.sortedUnpinnedRows,bt=rt.paginatedUnpinnedRows,an=rt.allRenderableRows;i.useEffect(()=>{_e.apiRef.current.getVisibleRows=()=>Ie?bt:it,_e.apiRef.current.getVisibleColumns=()=>Ae},[it,bt,Ie,Ae,_e.apiRef]);const Si=$o({rows:Ie?bt:it,getRowId:V=>V.id,onRowOrderChange:B,rowReordering:T}),lt=Yo(an,Vn,Le),{aggregationResult:dn}=bn({rows:De,aggregationModel:Se,isServerSide:!!(J&&(oe==="server"||Q==="server")),dataSource:J,filterModel:ke,sortModel:Fe,serverAggregationResults:di}),Ot=Object.keys(Se).length>0;i.useEffect(()=>{_e.apiRef.current.getAggregationResult=()=>Ot?dn:null,_e.apiRef.current.getAggregationModel=()=>Ot?Se:null},[dn,Se,Ot,_e.apiRef]);const ge=no({rowHeight:l,pagination:Ie,paginatedUnpinnedRows:bt,sortedUnpinnedRows:it,expandedRowIds:nt,getDetailPanelHeight:k,pinnedTopRowsLength:ln.length,pinnedBottomRowsLength:sn.length,visibleOrderedColumns:yi,pinnedColumns:Pe,columnWidths:Le,viewportWidth:ue.dimensions.viewportWidth||1e3,checkboxSelection:a,hasDetailPanel:Te,rowReordering:T,paginationMode:oe,isLoading:ue.dataSource.loading,pageSize:Ce.pageSize}),ji=i.useMemo(()=>{const V={};for(const Z of[...ge.leftPinnedCols,...ge.unpinnedColsWithWidth,...ge.rightPinnedCols])Z.isSpacer||(V[Z.field]=Z.width);return{...V,...Le}},[ge.leftPinnedCols,ge.unpinnedColsWithWidth,ge.rightPinnedCols,Le]);i.useEffect(()=>{_e.apiRef.current.scrollToIndexes=({rowIndex:V,colIndex:Z})=>{const ae=qe.current;if(ae){if(V!==void 0&&V>=0){const xe=V>0?ge.cumulativeHeights[V-1]:0,he=ge.cumulativeHeights[V]??xe,{scrollTop:me,clientHeight:be}=ae;xe<me?ae.scrollTop=xe:he>me+be&&(ae.scrollTop=he-be)}if(Z!==void 0&&Z>=0){const he=[...ge.leftPinnedCols,...ge.unpinnedColsWithWidth,...ge.rightPinnedCols][Z];if(!he)return;const me=ge.unpinnedColsWithWidth.findIndex(Oi=>Oi.field===he.field);if(me===-1)return;const be=me>0?ge.unpinnedAccWidths[me-1]:0,At=ge.unpinnedAccWidths[me]??be,zt=ge.leftWidth+At,{scrollLeft:qn,clientWidth:Xn}=ae;be<qn?ae.scrollLeft=be:zt>qn+Xn&&(ae.scrollLeft=zt-Xn)}}}},[ge,qe,_e.apiRef]);const ye=ho({layout:ge,scrollTop:mi,scrollLeft:bi,viewportWidth:ue.dimensions.viewportWidth,viewportHeight:ue.dimensions.viewportHeight,autoHeight:d,rowReordering:T,hasDetailPanel:Te,checkboxSelection:a,pinCheckboxColumn:v,pinExpandColumn:I});i.useEffect(()=>{if(!qe.current)return;const V=new ResizeObserver(Z=>{for(const ae of Z){const{width:xe,height:he}=ae.contentRect;Hn(xe,he)}});return V.observe(qe.current),()=>{V.disconnect()}},[Hn]);const wt=i.useCallback((V,Z)=>{const ae=new Set(ve);Z?ae.add(V):ae.delete(V);const xe=Array.from(ae);St||jt(xe),Et?.(xe)},[ve,St,Et,jt]),Ei=i.useCallback(V=>{let Z=[];V&&(Z=Ze.map(ae=>ae.id)),St||jt(Z),Et?.(Z)},[Ze,St,Et,jt]),Un=i.useCallback((V,Z)=>{const ae=Z?[{field:V,sort:Z}]:[];Rn||On(ae),C?.(ae)},[Rn,C,On]),{focusedCell:Wt,setFocusedCell:cn,handleFocus:Ni,handleBlur:Mi,handleKeyDown:Pi}=oo({allRenderableRows:an,navigationColumns:Vn,checkboxSelection:a,selectedRowIds:ve,handleSelectionChange:wt,handleDetailPanelToggle:Tt,editingHandlers:et,setKeyboardMode:Je,sortModel:Fe,handleSort:Un,isCellEditable:U,pagination:Ie,pageSize:Ce.pageSize,virtualization:ye,viewportRef:qe}),un=i.useCallback(V=>{Je(!1),cn({id:V.row.id,field:V.field}),Mt.current?.focus({preventScroll:!0}),b?.(V)},[b,Je,cn]),Kn=i.useRef(et.editingCell);i.useEffect(()=>{const V=!!Kn.current,Z=!!et.editingCell;V&&!Z&&Mt.current?.focus({preventScroll:!0}),Kn.current=et.editingCell},[et.editingCell]);const Ii=mo({renderContext:ye.renderContext,pinnedTopRows:ln,pinnedBottomRows:sn,paginatedUnpinnedRows:bt,sortedUnpinnedRows:it,pagination:Ie}),Ti=t.length>0&&ve.size===t.length,Li=ve.size>0&&ve.size<t.length,Ri=i.useMemo(()=>Ae.some(V=>!!V.rowSpan),[Ae]),[vt,Ft]=i.useState(!1),fn=i.useRef(null),gn=i.useRef(null),Yn=i.useMemo(()=>{if(!F?.toolbar)return null;const V=L?void 0:(Z,ae)=>{const xe=[...Lt],he=xe.indexOf(Z),me=xe.indexOf(ae);if(he===-1||me===-1)return;const be=[...xe];be.splice(he,1),be.splice(me,0,Z),W||Rt(be);const At=Ae.find(zt=>zt.field===Z);At&&A?.({oldIndex:he,targetIndex:me,column:At})};return{apiRef:_e.apiRef,columns:rn,baseColumns:e,aggregationModel:Se,onAggregationModelChange:Wn,...se||D||q?{pivotModel:Xt,onPivotModelChange:Fn}:{},filterModel:ke,onFilterModelChange:m,columnVisibilityModel:$e,onColumnVisibilityModelChange:kt,onColumnReorder:V,onColumnOrderReset:L?void 0:()=>Rt(e.map(Z=>Z.field)),forceColumnsOpen:vt,onColumnsPanelClose:()=>Ft(!1),...ie?.toolbar}},[F?.toolbar,L,Lt,rn,Ae,W,A,Rt,_e.apiRef,e,Se,Wn,se,D,q,Xt,Fn,ke,m,$e,kt,vt,ie?.toolbar]);return i.useEffect(()=>{if(!vt||F?.toolbar)return;function V(Z){gn.current&&!gn.current.contains(Z.target)&&Ft(!1)}return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[vt,F?.toolbar]),r.jsxs("div",{ref:fn,className:["ogx",ee,d&&"ogx--auto-height",Ri&&"ogx--row-spanning",ne&&"ogx--list-view"].filter(Boolean).join(" "),style:{...de,height:G??de?.height,"--ogx-row-height":`${l}px`,"--ogx-header-height":`${s}px`},"aria-busy":ht,children:[Yn&&r.jsx(si,{...Yn}),!F?.toolbar&&r.jsx(xr,{isOpen:vt,containerRef:fn,panelRef:gn,effectiveColumns:Ae,columnVisibilityModel:$e,effectiveColumnOrder:Lt,columnOrder:W,disableColumnReorder:L,onClose:()=>Ft(!1),onColumnVisibilityChange:kt,onColumnOrderChange:A,setInternalColumnOrder:Rt}),ne&&we&&r.jsx(tr,{ariaLabel:je,allRenderableRows:an,filteredRows:De,pagination:Ie,effectivePaginationModel:Ce,pageSizeOptions:w,selectedRowIds:ve,listViewColumn:we,noRowsLabel:Kt,rowHeight:l,checkboxSelection:a,paginationMode:oe,dataSource:J,serverRowCount:ue.pagination.rowCount||0,paginationSlot:F?.pagination,paginationSlotProps:ie?.pagination,localeText:Me?{paginationRowsPerPage:Me.paginationRowsPerPage,paginationOf:Me.paginationOf,paginationPage:Me.paginationPage}:void 0,onRowClick:It,onSelectionChange:wt,onPaginationModelChange:Jt}),!ne&&r.jsx("div",{ref:V=>{qe.current=V,Mt.current=V},className:"ogx__viewport",onScroll:wi,role:"grid","aria-label":je||"Data grid","aria-rowcount":De.length+1,"aria-colcount":e.length+(a?1:0)+(Te?1:0)+(T?1:0),"aria-busy":ht,tabIndex:0,onKeyDownCapture:()=>{Je(!0)},onMouseDownCapture:()=>{Je(!1)},onKeyDown:Pi,onFocus:Ni,onBlur:Mi,children:r.jsxs("div",{ref:ci,className:"ogx__content",style:{width:ye.totalWidth},role:"presentation",children:[r.jsx(vn,{columns:ye.virtualColumns,allColumns:Ae,columnGroupingModel:Be,checkboxSelection:a,allSelected:Ti,someSelected:Li,onSelectAll:Ei,sortModel:Fe,onSort:Un,onColumnResize:ki,columnWidths:Le,pinnedColumns:Pe,focusedCell:Wt,onHeaderClick:V=>{cn({id:"HEADER",field:V}),Je(!1),Mt.current?.focus({preventScroll:!0})},onDragStart:Be?void 0:ot.onDragStart,onDragOver:Be?void 0:ot.onDragOver,onDragEnd:Be?void 0:ot.onDragEnd,onDrop:Be?void 0:ot.onDrop,draggedColumn:Be?void 0:ot.draggedColumn,dragOverColumn:Be?void 0:ot.dragOverColumn,rowReordering:T,hasDetailPanel:Te,pinCheckboxColumn:v,pinExpandColumn:I,aggregationModel:Se,onHideColumn:V=>{kt({...$e,[V]:!1})},onManageColumns:()=>Ft(!0),onPinColumn:(V,Z)=>{const ae=[...Pe?.left??[]],xe=[...Pe?.right??[]],he=ae.filter(be=>be!==V),me=xe.filter(be=>be!==V);qt(Z==="left"?{left:[...he,V],right:me}:Z==="right"?{left:he,right:[...me,V]}:{left:he,right:me})}}),!ht&&!ue.dataSource.error&&De.length===0&&r.jsx(Co,{noRowsLabel:Kt,width:ye.totalWidth}),r.jsx(Sn,{rows:ln,position:"top",columns:ye.virtualColumns,selectedRowIds:ve,checkboxSelection:a,onRowClick:It,onCellClick:un,onSelectionChange:wt,columnWidths:Le,pinnedColumns:Pe,pinnedRows:x,hasDetailPanel:Te,expandedRowIds:nt,getDetailPanelContent:f,getDetailPanelHeight:k,onDetailPanelToggle:Tt,pinCheckboxColumn:v,pinExpandColumn:I,focusedCell:Wt,colspanMap:lt.colspanMap,rowSpanningCaches:lt.rowSpanningState.caches,rowHeight:l,rowMetaMap:mt}),r.jsx(gr,{virtualContainerHeight:ye.totalHeight-ye.pinnedTopHeight-ye.pinnedBottomHeight,offsetTop:ye.offsetTop,effectiveLoading:ht,visibleRows:Ii,baseColumns:e,virtualColumns:ye.virtualColumns,viewportWidth:ue.dimensions.viewportWidth,checkboxSelection:a,hasDetailPanel:Te,rowReordering:T,rowHeight:l,pinnedRows:x,selectedRowIds:ve,onRowClick:It,onCellClick:un,onSelectionChange:wt,columnWidths:Le,pinnedColumns:Pe,expandedRowIds:nt,getDetailPanelContent:f,getDetailPanelHeight:k,onDetailPanelToggle:Tt,pinCheckboxColumn:v,pinExpandColumn:I,rowReorderHandlers:Si,editingHandlers:et,focusedCell:Wt,colspanMap:lt.colspanMap,rowSpanningCaches:lt.rowSpanningState.caches,paginationMode:oe,dataSourceLoading:ue.dataSource.loading,sortedUnpinnedRowCount:it.length,infiniteScrollSkeletonCount:Math.min(Ce.pageSize,20),unpinnedRowsLength:ge.unpinnedRowsLength,rowMetaMap:mt}),r.jsx(Sn,{rows:sn,position:"bottom",columns:ye.virtualColumns,selectedRowIds:ve,checkboxSelection:a,onRowClick:It,onCellClick:un,onSelectionChange:wt,columnWidths:Le,pinnedColumns:Pe,pinnedRows:x,hasDetailPanel:Te,expandedRowIds:nt,getDetailPanelContent:f,getDetailPanelHeight:k,onDetailPanelToggle:Tt,pinCheckboxColumn:v,pinExpandColumn:I,focusedCell:Wt,colspanMap:lt.colspanMap,rowSpanningCaches:lt.rowSpanningState.caches,rowHeight:l,rowMetaMap:mt}),Ot&&!se&&r.jsx(_o,{columns:rn,aggregationModel:Se,aggregationResult:dn,columnWidths:ji,rowHeight:l,checkboxSelection:a,hasDetailPanel:Te,rowReordering:T,pinnedColumns:Pe})]})}),!ne&&Ie&&(()=>{const V=F?.pagination||_n;return r.jsx(V,{page:Ce.page,pageSize:Ce.pageSize,rowCount:ue.pagination.rowCount,pageSizeOptions:w,onPageChange:Z=>Jt({...Ce,page:Z}),onPageSizeChange:Z=>Jt({...Ce,pageSize:Z,page:0}),localeText:Me?{paginationRowsPerPage:Me.paginationRowsPerPage,paginationOf:Me.paginationOf,paginationPage:Me.paginationPage}:void 0,...ie?.pagination})})(),r.jsxs("div",{className:"ogx-aria-live-status",role:"status","aria-live":"polite",children:[ht?"Loading data...":"",ue.dataSource.error?`Error: ${ue.dataSource.error instanceof Error?ue.dataSource.error.message:"Unknown error"}`:"",!Y&&!ue.dataSource.error&&(De.length===0?Kt:ke&&((ke.quickFilterValues?.length||0)>0||(ke.items?.length||0)>0)?`${De.length} ${De.length===1?"row":"rows"} found`:"")]}),r.jsx(yo,{error:ue.dataSource.error})]})}function wr({rows:n=5,columns:t=5}){return r.jsx("div",{className:"ogx__skeleton",children:Array.from({length:n}).map((e,o)=>r.jsx("div",{className:"ogx__skeleton-row",children:Array.from({length:t}).map((l,s)=>r.jsx("div",{className:"ogx__skeleton-cell",children:r.jsx("div",{className:"ogx__skeleton-content"})},s))},o))})}const En=new Set(["isEmpty","isNotEmpty"]);function vr(n,t){return n.find(e=>"field"in e&&e.field===t)}const _r=({col:n,item:t,onChange:e})=>{const o=i.useId(),l=uo(n.type),s=!!t,d=t?.operator??l[0],[a,u]=i.useState(t?.value!=null?String(t.value):""),c=i.useRef(e),p=i.useRef(t),b=i.useRef(n.field),h=i.useRef(d);i.useLayoutEffect(()=>{c.current=e,p.current=t,b.current=n.field,h.current=d});const m=i.useRef(t?.value);i.useEffect(()=>{t?.value!==m.current&&(m.current=t?.value,u(t?.value!=null?String(t.value):""))},[t?.value]),i.useEffect(()=>{const w=setTimeout(()=>{const E=p.current,g=E?.value??"";a!==g&&c.current({id:E?.id??`${b.current}-${Date.now()}`,field:b.current,operator:h.current,value:a})},300);return()=>clearTimeout(w)},[a]);const _=w=>{const E=En.has(w),g={id:t?.id??`${n.field}-${Date.now()}`,field:n.field,operator:w,value:E?void 0:t?.value??(n.type==="boolean"?"true":"")};e(g)},C=()=>{u(""),e(null)},S=En.has(String(d)),P=n.type==="boolean",j=!S;return r.jsxs("div",{className:`ogx-filter__row${s?" ogx-filter__row--active":""}`,children:[r.jsx("span",{className:"ogx-filter__col-label",title:n.field,children:n.headerName||n.field}),r.jsxs("div",{className:"ogx-filter__controls",children:[r.jsx("select",{id:`${o}-op`,name:`filter-op-${n.field}`,className:`ogx-filter__op-select${s?" ogx-filter__op-select--active":""}`,value:String(d),onChange:w=>_(w.target.value),"aria-label":`Filter operator for ${n.headerName||n.field}`,children:l.map(w=>r.jsx("option",{value:w,children:w},w))}),j&&P&&r.jsxs("select",{id:`${o}-val`,name:`filter-val-${n.field}`,className:`ogx-filter__value-input ogx-filter__value-select${s?" ogx-filter__value-input--active":""}`,value:String(t?.value??"true"),onChange:w=>{u(w.target.value),e({id:t?.id??`${n.field}-${Date.now()}`,field:n.field,operator:d,value:w.target.value})},"aria-label":`Filter value for ${n.headerName||n.field}`,children:[r.jsx("option",{value:"true",children:"true"}),r.jsx("option",{value:"false",children:"false"})]}),j&&!P&&r.jsx("input",{id:`${o}-val`,name:`filter-val-${n.field}`,className:`ogx-filter__value-input${s?" ogx-filter__value-input--active":""}`,type:"text",value:a,onChange:w=>u(w.target.value),placeholder:n.type==="number"?"Number…":"Value…","aria-label":`Filter value for ${n.headerName||n.field}`}),s&&r.jsx("button",{className:"ogx-filter__row-clear",onClick:C,"aria-label":`Clear filter for ${n.headerName||n.field}`,title:"Clear",children:"×"})]})]})},Nn=({filterModel:n,columns:t,onFilterModelChange:e})=>{const o=i.useMemo(()=>n.items??[],[n.items]),l=n.logicOperator??"and",s=i.useCallback((u,c)=>{const p=o.filter(h=>"field"in h&&h.field!==u),b=c?[...p,c]:p;e({...n,items:b})},[o,n,e]),d=i.useCallback(u=>{e({...n,logicOperator:u})},[n,e]),a=t.filter(u=>u.filterable!==!1);return r.jsxs(r.Fragment,{children:[o.length>1&&r.jsxs("div",{className:"ogx-filter__logic-bar",children:[r.jsx("span",{className:"ogx-filter__logic-label",children:"Match:"}),r.jsx("button",{className:`ogx-filter__logic-pill${l==="and"?" ogx-filter__logic-pill--active":""}`,onClick:()=>d("and"),"aria-pressed":l==="and",children:"ALL (AND)"}),r.jsx("button",{className:`ogx-filter__logic-pill${l==="or"?" ogx-filter__logic-pill--active":""}`,onClick:()=>d("or"),"aria-pressed":l==="or",children:"ANY (OR)"})]}),a.length===0?r.jsx("div",{className:"ogx-filter__empty",children:"No filterable columns."}):a.map(u=>r.jsx(_r,{col:u,item:vr(o,u.field),onChange:c=>s(u.field,c)},u.field))]})},Cr=["sum","avg","count","min","max"];function Mn(){return r.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:[r.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),r.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),r.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),r.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1",fill:"currentColor",opacity:"0.25"}),r.jsx("path",{d:"M17 14v-4M17 10l-2 2 2 2"})]})}function yr({anchorRef:n,columns:t,model:e,onChange:o,onClose:l}){const s=i.useRef(null),[d,a]=i.useState({top:0,right:0}),[u,c]=i.useState(document.body);i.useLayoutEffect(()=>{c(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const p=i.useCallback(()=>{if(!n.current)return{top:0,right:0};const v=n.current.getBoundingClientRect();return{top:v.bottom+6,right:window.innerWidth-v.right}},[n]);i.useEffect(()=>{a(p());const v=()=>a(p());return window.addEventListener("scroll",v,!0),window.addEventListener("resize",v),()=>{window.removeEventListener("scroll",v,!0),window.removeEventListener("resize",v)}},[p]),i.useEffect(()=>{function v(L){s.current&&!s.current.contains(L.target)&&n.current&&!n.current.contains(L.target)&&l()}function I(L){L.key==="Escape"&&l()}return document.addEventListener("mousedown",v),document.addEventListener("keydown",I),()=>{document.removeEventListener("mousedown",v),document.removeEventListener("keydown",I)}},[n,l]);const b=new Set(e.rowFields),h=new Set(e.columnFields),m=new Set(e.valueFields.map(v=>v.field)),_=v=>b.has(v)||h.has(v)||m.has(v);function C(v){b.has(v)||o({...e,rowFields:[...e.rowFields,v]})}function S(v){h.has(v)||o({...e,columnFields:[...e.columnFields,v]})}function P(v,I="sum"){m.has(v)||o({...e,valueFields:[...e.valueFields,{field:v,aggFn:I}]})}function j(v){o({...e,rowFields:e.rowFields.filter(I=>I!==v)})}function w(v){o({...e,columnFields:e.columnFields.filter(I=>I!==v)})}function E(v){o({...e,valueFields:e.valueFields.filter(I=>I.field!==v)})}function g(v,I){o({...e,valueFields:e.valueFields.map(L=>L.field===v?{...L,aggFn:I}:L)})}function x(){o({rowFields:[],columnFields:[],valueFields:[]})}const f=new Set(t.filter(v=>v.type==="number"||v.aggregable).map(v=>v.field)),k=e.rowFields.length+e.columnFields.length+e.valueFields.length,M=v=>t.find(I=>I.field===v)?.headerName??v,N=r.jsxs("div",{ref:s,className:"ogx-pivot-panel",role:"dialog","aria-label":"Pivot configuration",style:{top:d.top,right:d.right},children:[r.jsxs("div",{className:"ogx-pivot-panel__header",children:[r.jsxs("span",{className:"ogx-pivot-panel__title",children:[r.jsx(Mn,{}),"Pivot Mode"]}),k>0&&r.jsx("button",{className:"ogx-pivot-panel__reset-btn",onClick:x,title:"Reset pivot",children:"Reset"})]}),r.jsxs("div",{className:"ogx-pivot-panel__body",children:[r.jsxs("div",{className:"ogx-pivot-zone",children:[r.jsxs("span",{className:"ogx-pivot-zone__label",children:[r.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--row"}),"Row Fields"]}),r.jsx("div",{className:`ogx-pivot-chips${e.rowFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — each becomes a row label",children:e.rowFields.map(v=>r.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--row",children:[M(v),r.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>j(v),title:`Remove ${M(v)}`,children:"×"})]},v))})]}),r.jsxs("div",{className:"ogx-pivot-zone",children:[r.jsxs("span",{className:"ogx-pivot-zone__label",children:[r.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--col"}),"Column Fields"]}),r.jsx("div",{className:`ogx-pivot-chips${e.columnFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — unique values become column headers",children:e.columnFields.map(v=>r.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--col",children:[M(v),r.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>w(v),title:`Remove ${M(v)}`,children:"×"})]},v))})]}),r.jsxs("div",{className:"ogx-pivot-zone",children:[r.jsxs("span",{className:"ogx-pivot-zone__label",children:[r.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--value"}),"Value Fields (aggregated)"]}),r.jsx("div",{className:`ogx-pivot-chips${e.valueFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add numeric fields here — values are aggregated",children:e.valueFields.map(v=>r.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--value",children:[M(v.field),r.jsx("select",{className:"ogx-pivot-chip__fn-select",value:v.aggFn,onChange:I=>g(v.field,I.target.value),title:"Aggregation function",children:Cr.map(I=>r.jsx("option",{value:I,children:I.toUpperCase()},I))}),r.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>E(v.field),title:`Remove ${M(v.field)}`,children:"×"})]},v.field))})]}),r.jsx("hr",{className:"ogx-pivot-panel__divider"}),r.jsxs("div",{children:[r.jsx("div",{className:"ogx-pivot-panel__fields-label",children:"Available Fields"}),r.jsxs("div",{className:"ogx-pivot-fields",children:[t.map(v=>{const I=f.has(v.field);return _(v.field)?null:r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3},children:[r.jsx("span",{className:`ogx-pivot-field-btn${I?" ogx-pivot-field-btn--numeric":""}`,children:v.headerName??v.field}),r.jsxs("div",{className:"ogx-pivot-field-actions",children:[r.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--row",onClick:()=>C(v.field),title:"Add to Row Fields",children:"Row"}),r.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--col",onClick:()=>S(v.field),title:"Add to Column Fields",children:"Col"}),I&&r.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--value",onClick:()=>P(v.field),title:"Add to Value Fields",children:"Val"})]})]},v.field)}),t.every(v=>_(v.field))&&r.jsx("span",{style:{fontSize:12,color:"var(--ogx-color-gray-400, #94a3b8)"},children:"All fields are in use."})]})]})]})]});return ze.createPortal(N,u)}function kr(){return r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function Sr(){return r.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function jr({value:n="",onChange:t,placeholder:e="Search...",debounceMs:o=250}){const[l,s]=i.useState(()=>n.length>0),[d,a]=i.useState(n),u=i.useRef(null),c=i.useRef(null),p=i.useRef(t);i.useLayoutEffect(()=>{p.current=t},[t]);const b=i.useRef(n),h=i.useRef(n),m=i.useRef(!1);i.useLayoutEffect(()=>{m.current&&document.activeElement!==u.current&&u.current?.focus()}),i.useEffect(()=>{n!==h.current&&(h.current=n,n!==b.current&&(a(n),b.current=n,n?s(!0):(m.current=!1,s(!1))))},[n]),i.useEffect(()=>{const j=setTimeout(()=>{d!==b.current&&(b.current=d,p.current(d))},o);return()=>clearTimeout(j)},[d,o]);const _=i.useCallback(()=>{s(!0),requestAnimationFrame(()=>u.current?.focus())},[]),C=i.useCallback(j=>{j.stopPropagation(),a(""),b.current="",p.current(""),u.current?.focus()},[]),S=i.useCallback(()=>{m.current=!0,s(!0)},[]),P=i.useCallback(()=>{m.current=!1,setTimeout(()=>{if(c.current&&document.activeElement&&c.current.contains(document.activeElement)){m.current=!0;return}d||s(!1)},150)},[d]);return i.useEffect(()=>{const j=w=>{c.current&&!c.current.contains(w.target)&&(d||s(!1))};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[d]),r.jsxs("div",{ref:c,className:`ogx-global-search${l?" ogx-global-search--expanded":""}`,onClick:l?void 0:_,children:[r.jsx("div",{className:"ogx-global-search__icon-wrapper",children:r.jsx(kr,{})}),r.jsx("input",{ref:u,className:"ogx-global-search__input",value:d,onChange:j=>a(j.target.value),onFocus:S,onBlur:P,placeholder:e,"aria-label":"Global Search",autoComplete:"off"}),d&&r.jsx("button",{className:"ogx-global-search__clear",onClick:C,"aria-label":"Clear search",children:r.jsx(Sr,{})})]})}function gt({title:n,children:t,placement:e="top",enterDelay:o=200,leaveDelay:l=0}){const[s,d]=i.useState(!1),[a,u]=i.useState({top:0,left:0}),c=i.useRef(null),p=i.useRef(null),b=i.useCallback(()=>{if(!p.current)return;const C=p.current.getBoundingClientRect();let S=0,P=0;const j=window.pageXOffset||document.documentElement.scrollLeft,w=window.pageYOffset||document.documentElement.scrollTop;e==="top"?(S=C.top+w-8,P=C.left+j+C.width/2):e==="bottom"&&(S=C.bottom+w+8,P=C.left+j+C.width/2),u({top:S,left:P})},[e]);i.useLayoutEffect(()=>(s&&(b(),window.addEventListener("scroll",b,!0),window.addEventListener("resize",b)),()=>{window.removeEventListener("scroll",b,!0),window.removeEventListener("resize",b)}),[s,b]);const h=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{d(!0)},o)},m=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{d(!1)},l)},_=i.useCallback(C=>{p.current=C?C.firstElementChild??C:null},[]);return r.jsxs(r.Fragment,{children:[r.jsx("span",{ref:_,style:{display:"inline-block",lineHeight:0},onMouseEnter:h,onMouseLeave:m,children:t}),s&&n&&ze.createPortal(r.jsx("div",{className:`ogx-tooltip ogx-tooltip--${e}`,style:{top:a.top,left:a.left,position:"absolute",zIndex:99999},children:n}),document.body)]})}const Er=["none","sum","avg","count","min","max"];function Pn(){return r.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:r.jsx("path",{d:"M18 4H6l6 8-6 8h12"})})}function Nr(){return r.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",children:[r.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),r.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.25"}),r.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),r.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),r.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),r.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function In(){return r.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})})}function Mr({anchorRef:n,aggregationModel:t,aggregableColumns:e,onFunctionChange:o,onClearAll:l,onClose:s,activeCount:d}){const a=i.useRef(null),[u,c]=i.useState({top:0,right:0}),[p,b]=i.useState(document.body);i.useLayoutEffect(()=>{b(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const h=i.useCallback(()=>{if(!n.current)return{top:0,right:0};const _=n.current.getBoundingClientRect();return{top:_.bottom+6,right:window.innerWidth-_.right}},[n]);i.useEffect(()=>{c(h());const _=()=>c(h());return window.addEventListener("scroll",_,!0),window.addEventListener("resize",_),()=>{window.removeEventListener("scroll",_,!0),window.removeEventListener("resize",_)}},[h]),i.useEffect(()=>{function _(C){a.current&&!a.current.contains(C.target)&&n.current&&!n.current.contains(C.target)&&s()}return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[n,s]),i.useEffect(()=>{function _(C){C.key==="Escape"&&s()}return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[s]);const m=r.jsxs("div",{ref:a,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Summaries configuration",style:{top:u.top,right:u.right,width:400,maxWidth:"calc(100vw - 24px)"},children:[r.jsxs("div",{className:"ogx-toolbar__panel-header",children:[r.jsxs("span",{className:"ogx-toolbar__panel-title",children:[r.jsx(Pn,{}),"Summaries"]}),d>0&&r.jsx("button",{className:"ogx-toolbar__clear-btn",onClick:l,title:"Clear all summaries",children:"Clear all"})]}),r.jsx("div",{className:"ogx-toolbar__panel-body",children:e.length===0?r.jsxs("p",{className:"ogx-toolbar__empty",children:["No aggregable columns.",r.jsx("br",{}),"Set ",r.jsx("code",{children:"aggregable: true"})," on a column to enable."]}):e.map(_=>{const C=t[_.field]||"none";return r.jsxs("div",{className:"ogx-toolbar__agg-row",children:[r.jsx("span",{className:"ogx-toolbar__agg-label",title:_.field,children:_.headerName||_.field}),r.jsx("div",{className:"ogx-toolbar__agg-pills",children:Er.map(S=>r.jsx("button",{className:`ogx-toolbar__pill${C===S?" ogx-toolbar__pill--active":""}`,onClick:()=>o(_.field,S),"aria-pressed":C===S,children:S},S))})]},_.field)})})]});return ze.createPortal(m,p)}function Pr({anchorRef:n,columns:t,visibleColumns:e,onVisibilityChange:o,onShowAll:l,onHideAll:s,onColumnReorder:d,onColumnOrderReset:a,onClose:u}){const c=i.useRef(null),[p,b]=i.useState({top:0,right:0}),[h,m]=i.useState(document.body);i.useLayoutEffect(()=>{m(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const _=i.useCallback(()=>{if(!n.current)return{top:0,right:0};const S=n.current.getBoundingClientRect();return{top:S.bottom+6,right:window.innerWidth-S.right}},[n]);i.useEffect(()=>{b(_());const S=()=>b(_());return window.addEventListener("scroll",S,!0),window.addEventListener("resize",S),()=>{window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",S)}},[_]),i.useEffect(()=>{function S(P){c.current&&!c.current.contains(P.target)&&n.current&&!n.current.contains(P.target)&&u()}return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[n,u]);const C=r.jsx("div",{ref:c,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Column visibility",style:{top:p.top,right:p.right,width:280,padding:0},children:r.jsx(jn,{columns:t,visibleColumns:e,onVisibilityChange:o,onShowAll:l,onHideAll:s,onColumnReorder:d,onColumnOrderReset:a})});return ze.createPortal(C,h)}function Ir({anchorRef:n,columns:t,filterModel:e,onFilterModelChange:o,onClose:l}){const s=i.useRef(null),[d,a]=i.useState({top:0,right:0}),u=i.useRef(l);i.useLayoutEffect(()=>{u.current=l},[l]);const[c,p]=i.useState(document.body);i.useLayoutEffect(()=>{p(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const b=i.useCallback(()=>{if(!n.current)return{top:0,right:0};const C=n.current.getBoundingClientRect();return{top:C.bottom+6,right:window.innerWidth-C.right}},[n]);i.useEffect(()=>{a(b());const C=()=>a(b());return window.addEventListener("scroll",C,!0),window.addEventListener("resize",C),()=>{window.removeEventListener("scroll",C,!0),window.removeEventListener("resize",C)}},[b]),i.useEffect(()=>{function C(S){S.key==="Escape"&&u.current()}return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[]);const h=e.items?.length??0,m=()=>{o({...e,items:[],logicOperator:"and"})},_=r.jsxs("div",{ref:s,className:"ogx-toolbar__panel ogx-toolbar__panel--filter",role:"dialog","aria-label":"Advanced filters",style:{top:d.top,right:d.right,width:540,maxWidth:"calc(100vw - 24px)"},children:[r.jsxs("div",{className:"ogx-toolbar__panel-header",children:[r.jsxs("span",{className:"ogx-toolbar__panel-title",children:[r.jsx(In,{}),"Filters",h>0&&r.jsx("span",{className:"ogx-toolbar__panel-count",children:h})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[h>0&&r.jsx("button",{className:"ogx-toolbar__clear-btn",onClick:m,title:"Clear all filters",children:"Clear all"}),r.jsx("button",{className:"ogx-toolbar__close-btn",onClick:()=>u.current(),title:"Close filters","aria-label":"Close filters panel",children:"Close"})]})]}),r.jsx("div",{className:"ogx-toolbar__panel-body ogx-toolbar__panel-body--filter",children:r.jsx(Nn,{columns:t,filterModel:e,onFilterModelChange:o})})]});return ze.createPortal(_,c)}const Tr={rowFields:[],columnFields:[],valueFields:[]};function Lr({columns:n=[],baseColumns:t,aggregationModel:e={},onAggregationModelChange:o,pivotModel:l,onPivotModelChange:s,filterModel:d,onFilterModelChange:a,columnVisibilityModel:u={},onColumnVisibilityModelChange:c,onColumnReorder:p,onColumnOrderReset:b,forceColumnsOpen:h,onColumnsPanelClose:m,children:_,rightContent:C,style:S,renderColumnsButton:P,renderFilterButton:j,renderAggregationButton:w,renderExportButton:E,renderQuickFilter:g,className:x}){const[f,k]=i.useState(!1),[M,N]=i.useState(!1),[v,I]=i.useState(!1),[L,W]=i.useState(!1);i.useEffect(()=>{h&&(I(!0),k(!1),N(!1),W(!1))},[h]);const A=i.useRef(null),G=i.useRef(null),T=i.useRef(null),B=i.useRef(null),Y=i.useRef(null),K=i.useRef(null),y=i.useRef(null),O=l??Tr,z=O.rowFields.length>0||O.columnFields.length>0||O.valueFields.length>0,$=n.filter(F=>F.aggregable!==!1&&(F.type==="number"||F.aggregable===!0)),H=Object.keys(e).filter(F=>e[F]&&e[F]!=="none").length,X=i.useCallback((F,ie)=>{if(!o)return;const se={...e};ie==="none"?delete se[F]:se[F]=ie,o(se)},[e,o]),U=i.useCallback(()=>{o?.({})},[o]),te=i.useCallback(F=>{if(!a)return;const se={...d||{},quickFilterValues:F?[F]:[],items:d?.items||[]};a(se)},[d,a]),R=d?.quickFilterValues?.[0]||"",J=d?.items?.length||0,Q=new Set(n.filter(F=>u[F.field]!==!1).map(F=>F.field)),le=i.useCallback((F,ie)=>{if(!c)return;const se={...u,[F]:ie};c(se)},[u,c]),oe=i.useCallback(()=>{if(!c)return;const F={...u};n.forEach(ie=>{ie.hideable!==!1&&(F[ie.field]=!0)}),c(F)},[n,u,c]),pe=i.useCallback(()=>{if(!c)return;const F={...u};n.forEach(ie=>{ie.hideable!==!1&&(F[ie.field]=!1)}),c(F)},[n,u,c]);return r.jsxs("div",{className:["ogx-toolbar",x].filter(Boolean).join(" "),role:"toolbar","aria-label":"Grid toolbar",style:S,children:[_&&r.jsx("div",{className:"ogx-toolbar__left",children:_}),r.jsx("div",{className:"ogx-toolbar__spacer"}),r.jsxs("div",{className:"ogx-toolbar__actions",children:[a&&r.jsx("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:g?g({value:R,onChange:te}):r.jsx(jr,{value:R,onChange:te,placeholder:"Search..."})}),c&&r.jsxs("div",{ref:Y,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[P?P({onClick:()=>{I(F=>!F),k(!1),N(!1),W(!1)},isOpen:v,activeCount:n.length-Q.size}):r.jsx(gt,{title:"Columns",children:r.jsx("button",{ref:T,className:`ogx-toolbar__icon-btn${v?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Manage columns",onClick:()=>{I(!v),k(!1),N(!1),W(!1)},children:r.jsx(Nr,{})})}),v&&r.jsx(Pr,{anchorRef:P?Y:T,columns:n,visibleColumns:Q,onVisibilityChange:le,onShowAll:oe,onHideAll:pe,onColumnReorder:p,onColumnOrderReset:b,onClose:()=>{I(!1),m?.()}})]}),a&&r.jsxs("div",{ref:K,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[j?j({onClick:()=>{W(F=>!F),k(!1),N(!1),I(!1)},isOpen:L,activeCount:J}):r.jsx(gt,{title:"Filters",children:r.jsxs("button",{ref:B,className:`ogx-toolbar__icon-btn${L?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Advanced filters",onClick:()=>{W(!L),k(!1),N(!1),I(!1)},children:[r.jsx(In,{}),J>0&&r.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Filters active"})]})}),L&&r.jsx(Ir,{anchorRef:j?K:B,columns:n,filterModel:d||{items:[]},onFilterModelChange:a,onClose:()=>W(!1)})]}),s&&r.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[r.jsx(gt,{title:"Pivot",children:r.jsxs("button",{ref:G,className:`ogx-toolbar__icon-btn${M?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure pivot","aria-expanded":M,onClick:()=>{N(!M),k(!1),I(!1),W(!1)},children:[r.jsx(Mn,{}),z&&r.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Pivot active"})]})}),M&&r.jsx(yr,{anchorRef:G,columns:t??n,model:O,onChange:F=>{s?.(F)},onClose:()=>N(!1)})]}),r.jsxs("div",{ref:y,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[w?w({onClick:()=>{k(F=>!F),N(!1),I(!1),W(!1)},isOpen:f,activeCount:H}):r.jsx(gt,{title:"Summaries",children:r.jsxs("button",{ref:A,className:`ogx-toolbar__icon-btn${f?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure summaries","aria-expanded":f,onClick:()=>{k(!f),N(!1),I(!1),W(!1)},children:[r.jsx(Pn,{}),H>0&&r.jsx("span",{className:"ogx-toolbar__dot","aria-label":`${H} active summaries`})]})}),f&&r.jsx(Mr,{anchorRef:w?y:A,aggregationModel:e,aggregableColumns:$,onFunctionChange:X,onClearAll:U,onClose:()=>k(!1),activeCount:H})]}),E&&E(),C]})]})}function Rr(){return i.useRef(null)}const Or=({fullWidth:n=!1,error:t=!1,startAdornment:e,endAdornment:o,className:l="",...s})=>{const d=["ogx-input-wrapper",n&&"ogx-input-wrapper--full-width",t&&"ogx-input-wrapper--error",s.disabled&&"ogx-input-wrapper--disabled",l].filter(Boolean).join(" ");return r.jsxs("div",{className:d,children:[e&&r.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--start",children:e}),r.jsx("input",{className:"ogx-input",...s}),o&&r.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--end",children:o})]})};function Wr(n,t,e={}){const{fileName:o="export.csv",includeHeaders:l=!0,delimiter:s=",",selectedRows:d}=e,a=d&&d.length>0?n.filter(p=>d.includes(p.id)):n;if(a.length===0){console.warn("No rows to export");return}const u=t.filter(p=>!(p.exportable===!1||p.field==="__check__"||p.field==="__actions__"));let c="";if(l){const p=u.map(b=>Ke(b.headerName||b.field));c+=p.join(s)+`
|
|
9
|
+
`}if(a.forEach(p=>{const b=u.map(h=>{let m=p[h.field];return h.valueGetter&&(m=h.valueGetter({row:p,field:h.field,value:m})),h.valueFormatter&&m!==void 0&&m!==null&&(m=h.valueFormatter({value:m,row:p,field:h.field})),Ke(String(m??""))});c+=b.join(s)+`
|
|
10
|
+
`}),e.aggregationResult){const p=e.aggregationResult,b=e.aggregationModel||{},h=u.map(_=>b[_.field]?Ke(b[_.field].toUpperCase()):Ke(""));c+=h.join(s)+`
|
|
11
|
+
`;const m=u.map(_=>{const C=p[_.field];if(C!=null){let S=C;return _.valueFormatter?S=_.valueFormatter({value:C,row:{},field:_.field}):b[_.field]&&(S=Re(C,b[_.field])),Ke(String(S))}return Ke("")});c+=m.join(s)+`
|
|
12
|
+
`}Vt(c,o,"text/csv;charset=utf-8;")}function Ke(n){return n.includes(",")||n.includes('"')||n.includes(`
|
|
13
|
+
`)?`"${n.replace(/"/g,'""')}"`:n}function Fr(n,t,e={}){const{fileName:o="export.xls",sheetName:l="Sheet1",includeHeaders:s=!0,selectedRows:d}=e,a=d&&d.length>0?n.filter(p=>d.includes(p.id)):n;if(a.length===0){console.warn("No rows to export");return}const u=t.filter(p=>!(p.exportable===!1||p.field==="__check__"||p.field==="__actions__"));let c='<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">';if(c+="<head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>",c+=`<x:Name>${l}</x:Name>`,c+="<x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]-->",c+='<meta charset="UTF-8"></head><body>',c+='<table border="1">',s&&(c+="<thead><tr>",u.forEach(p=>{c+=`<th>${Ne(p.headerName||p.field)}</th>`}),c+="</tr></thead>"),c+="<tbody>",a.forEach(p=>{c+="<tr>",u.forEach(b=>{let h=p[b.field];b.valueGetter&&(h=b.valueGetter({row:p,field:b.field,value:h})),b.valueFormatter&&h!==void 0&&h!==null&&(h=b.valueFormatter({value:h,row:p,field:b.field})),c+=`<td>${Ne(String(h??""))}</td>`})}),e.aggregationResult){const p=e.aggregationResult,b=e.aggregationModel||{};c+='<tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',u.forEach(h=>{b[h.field]?c+=`<td style="text-align: right; font-weight: bold;">${Ne(b[h.field].toUpperCase())}</td>`:c+="<td></td>"}),c+="</tr>",c+='<tr style="font-weight: bold; background-color: #f5f5f5;">',u.forEach(h=>{const m=p[h.field];if(m!=null){let _=m;h.valueFormatter?_=h.valueFormatter({value:m,row:{},field:h.field}):b[h.field]&&(_=Re(m,b[h.field])),c+=`<td style="text-align: right;">${Ne(String(_))}</td>`}else c+="<td></td>"}),c+="</tr>"}c+="</tbody></table></body></html>",Vt(c,o,"application/vnd.ms-excel")}function Ne(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Ar(n,t,e={}){const{fileName:o="export.json",pretty:l=!0,selectedRows:s}=e,d=s&&s.length>0?n.filter(b=>s.includes(b.id)):n;if(d.length===0){console.warn("No rows to export");return}const a=t.filter(b=>!(b.exportable===!1||b.field==="__check__"||b.field==="__actions__")),u=d.map(b=>{const h={};return a.forEach(m=>{let _=b[m.field];m.valueGetter&&(_=m.valueGetter({row:b,field:m.field,value:_})),h[m.field]=_}),h});let c=u;if(e.aggregationResult){const b=e.aggregationResult,h=e.aggregationModel||{},m={};a.forEach(C=>{h[C.field]&&(m[C.field]=h[C.field].toUpperCase())});const _={};a.forEach(C=>{if(b[C.field]!==void 0&&b[C.field]!==null){let S=b[C.field];C.valueFormatter?S=C.valueFormatter({value:S,row:{},field:C.field}):h[C.field]&&(S=Re(S,h[C.field])),_[C.field]=S}}),c={data:u,aggregation:{labels:m,values:_}}}const p=l?JSON.stringify(c,null,2):JSON.stringify(c);Vt(p,o,"application/json;charset=utf-8;")}async function zr(n,t,e){const o=window.open("","_blank");if(!o){console.error("Failed to open print window. Please check your popup blocker settings.");return}o.document.write(`
|
|
14
14
|
<!DOCTYPE html>
|
|
15
15
|
<html>
|
|
16
16
|
<head>
|
|
@@ -30,11 +30,11 @@ ${f}`;try{await Uo(m)}catch(p){console.error("[OpenGridX] Failed to copy to clip
|
|
|
30
30
|
</div>
|
|
31
31
|
</body>
|
|
32
32
|
</html>
|
|
33
|
-
`),o.document.close(),await new Promise(
|
|
33
|
+
`),o.document.close(),await new Promise(l=>setTimeout(l,100));try{let l="Print",s,d=null,a=null;typeof e=="string"?l=e:typeof e=="object"&&(l=e.title||"Print",s=e.selectedRows,d=e.aggregationResult||null,a=e.aggregationModel||null);const u=s&&s.length>0?n.filter(h=>s.includes(h.id)):n;if(u.length===0){o.document.body.innerHTML="<h3>No rows to export</h3>";return}const c=t.filter(h=>!(h.exportable===!1||h.field==="__check__"||h.field==="__actions__"));let p=`
|
|
34
34
|
<!DOCTYPE html>
|
|
35
35
|
<html>
|
|
36
36
|
<head>
|
|
37
|
-
<title>${
|
|
37
|
+
<title>${l||"Print"}</title>
|
|
38
38
|
<style>
|
|
39
39
|
body { font-family: Arial, sans-serif; margin: 20px; }
|
|
40
40
|
h1 { font-size: 24px; margin-bottom: 20px; }
|
|
@@ -49,5 +49,5 @@ ${f}`;try{await Uo(m)}catch(p){console.error("[OpenGridX] Failed to copy to clip
|
|
|
49
49
|
</style>
|
|
50
50
|
</head>
|
|
51
51
|
<body>
|
|
52
|
-
`;if(i&&(f+=`<h1>${Ee(i)}</h1>`),f+="<table>",f+="<thead><tr>",c.forEach(p=>{f+=`<th>${Ee(p.headerName||p.field)}</th>`}),f+="</tr></thead>",f+="<tbody>",u.forEach(p=>{f+="<tr>",c.forEach(b=>{let v=p[b.field];b.valueGetter&&(v=b.valueGetter({row:p,field:b.field,value:v})),b.valueFormatter&&v!==void 0&&v!==null&&(v=b.valueFormatter({value:v,row:p,field:b.field})),b.type==="image"&&v?f+=`<td><div style="display:flex;justify-content:center;"><img src="${v}" alt="${b.headerName}" style="max-height: 40px; border-radius: 4px;"></div></td>`:f+=`<td>${Ee(String(v??""))}</td>`}),f+="</tr>"}),d){const p=a||{};f+='<tfoot><tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',c.forEach(b=>{p[b.field]?f+=`<td style="text-align: right; font-weight: bold;">${Ee(p[b.field].toUpperCase())}</td>`:f+="<td></td>"}),f+='</tr><tr style="font-weight: bold; background-color: #f5f5f5;">',c.forEach(b=>{const v=d[b.field];if(v!=null){let C=v;b.valueFormatter?C=b.valueFormatter({value:v,row:{},field:b.field}):p[b.field]&&(C=Ie(v,p[b.field])),f+=`<td style="text-align: right;">${Ee(String(C))}</td>`}else f+="<td></td>"}),f+="</tr></tfoot>"}f+="</tbody></table></body></html>",o.document.open(),o.document.write(f),o.document.close(),o.document.title=i||"Print Preview",o.focus();let m=!1;o.onload=()=>{m||(m=!0,o.print(),setTimeout(()=>{o.close()},100))},setTimeout(()=>{!m&&o&&!o.closed&&(m=!0,o.print(),setTimeout(()=>{o.closed||o.close()},100))},500)}catch(i){if(console.error("Print generation failed:",i),o&&!o.closed){const s=i instanceof Error?i.message:String(i);o.document.body.innerHTML=`<div style="color: red; padding: 20px;"><h3>Error Generating Print Preview</h3><p>${s}</p></div>`}}}function Bt(n,t,e){const o=new Blob([n],{type:e}),i=URL.createObjectURL(o),s=document.createElement("a");s.href=i,s.download=t,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(i)}function Tr(n,t){return n.type==="number"?"number":n.type==="boolean"?"boolean":n.type==="date"?"date":typeof t=="number"?"number":typeof t=="boolean"?"boolean":t instanceof Date?"date":"string"}function Lr(n){if(n.type==="number")return"#,##0.##";if(n.type==="date")return"yyyy-mm-dd"}function Rr(n,t){if(t!=null)return t;const e=n.width??120;return Math.min(60,Math.max(8,(e-5)/7))}function Wr(n,t){const e=t??"";if(e.includes("jpeg")||e.includes("jpg"))return"jpeg";if(e.includes("gif"))return"gif";const o=n.split("?")[0].toLowerCase();return o.endsWith(".jpg")||o.endsWith(".jpeg")?"jpeg":o.endsWith(".gif")?"gif":"png"}async function Or(n){const t=await Promise.allSettled(n.map(async o=>{if(o.startsWith("data:")){const a=o.indexOf(","),u=o.slice(0,a),c=o.slice(a+1),f=atob(c),m=new Uint8Array(f.length);for(let C=0;C<f.length;C++)m[C]=f.charCodeAt(C);const b=u.match(/data:([^;,]+)/)?.[1]??"image/png";let v="png";return b.includes("jpeg")||b.includes("jpg")?v="jpeg":b.includes("gif")&&(v="gif"),{url:o,buffer:m.buffer,ext:v}}const i=await fetch(o,{mode:"cors"});if(!i.ok)throw new Error(`HTTP ${i.status}`);const s=await i.arrayBuffer(),d=Wr(o,i.headers.get("content-type"));return{url:o,buffer:s,ext:d}})),e=new Map;return t.forEach((o,i)=>{o.status==="fulfilled"?e.set(o.value.url,{buffer:o.value.buffer,extension:o.value.ext}):console.warn(`[exportToExcelAdvanced] Cannot embed image "${n[i]}" (CORS/network error — raw URL written as fallback):`,o.reason)}),e}async function Fr(n,t,e={}){const{fileName:o="export.xlsx",sheets:i,columnStyles:s={},headerFillColor:d="#f1f5f9",headerTextColor:a="#334155",headerFontSize:u=10,bodyFontSize:c=10,aggregationResult:f=null,aggregationModel:m=null,selectedRows:p}=e,b=(await import("exceljs")).default,v=new b.Workbook;v.creator="OpenGridX",v.created=new Date;const C=t.filter(E=>E.exportable!==!1&&E.field!=="__check__"&&E.field!=="__actions__"&&!E.isSpacer),j=n,I=p&&p.length>0?n.filter(E=>p.includes(E.id)):n,h=i??[{name:"Data",rows:"all",includeHeaders:!0,includeSummary:!1}],S=new Map;for(const E of h){if("type"in E&&E.type==="summary"){if(!f||!m)continue;const k=v.addWorksheet(E.name??"Summary");k.addRow(["Summary / Aggregation Totals"]),k.getRow(1).font={bold:!0,size:u+2,color:{argb:Te(a)}},k.addRow([]),k.addRow(["Column","Function","Value"]).eachCell(O=>{O.fill={type:"pattern",pattern:"solid",fgColor:{argb:Te(d)}},O.font={bold:!0,size:u,color:{argb:Te(a)}},O.border=Nn()}),C.forEach(O=>{const A=m[O.field],D=f[O.field];if(A==null||D==null)return;let X=D;O.valueFormatter?X=O.valueFormatter({value:D,row:{},field:O.field}):X=Ie(D,A);const K=k.addRow([O.headerName??O.field,A.toUpperCase(),X]);K.getCell(3).alignment={horizontal:"right"},K.getCell(3).font={bold:!0,size:c}}),k.getColumn(1).width=20,k.getColumn(2).width=12,k.getColumn(3).width=18;continue}const M=E,{name:N="Data",rows:_="all",includeHeaders:P=!0,includeSummary:W=!1,autoFilter:T=!0,frozenHeader:F=!0,alternateRowColor:H="#f8fafc"}=M,R=_==="selected"?I:j,G=C.filter(k=>s[k.field]?.embedImage);if(G.length>0){const k=[],B=new Set;if(R.forEach(O=>{G.forEach(A=>{const D=O[A.field];typeof D=="string"&&D&&!S.has(D)&&!B.has(D)&&(k.push(D),B.add(D))})}),k.length>0){const O=await Or(k);for(const[A,{buffer:D,extension:X}]of O){const K=v.addImage({buffer:D,extension:X});S.set(A,K)}}}const Y=v.addWorksheet(N);if(Y.columns=C.map(k=>({key:k.field,width:Rr(k,s[k.field]?.width),style:{numFmt:s[k.field]?.numFmt??Lr(k)}})),P){const k=C.map(O=>O.headerName??O.field),B=Y.addRow(k);B.height=20,B.eachCell((O,A)=>{const D=C[A-1];O.fill={type:"pattern",pattern:"solid",fgColor:{argb:Te(d)}},O.font={bold:!0,size:u,color:{argb:Te(a)}},O.alignment={horizontal:s[D?.field]?.alignment??(D?.type==="number"?"right":"left"),vertical:"middle"},O.border=Nn()}),T&&(Y.autoFilter={from:{row:1,column:1},to:{row:1,column:C.length}}),F?Y.views=[{state:"frozen",ySplit:1,showGridLines:!1}]:Y.views=[{showGridLines:!1}]}let V=P?1:0;if(R.forEach((k,B)=>{const O=C.map(D=>{if(s[D.field]?.embedImage)return"";let X=k[D.field];return D.valueGetter&&(X=D.valueGetter({row:k,field:D.field,value:X})),Tr(D,X)==="string"&&D.valueFormatter&&X!=null&&(X=D.valueFormatter({value:X,row:k,field:D.field})),X}),A=Y.addRow(O);if(A.font={size:c},H&&B%2===1&&A.eachCell(D=>{D.fill={type:"pattern",pattern:"solid",fgColor:{argb:Te(H)}}}),A.eachCell((D,X)=>{const K=C[X-1];K&&(D.alignment={horizontal:s[K.field]?.alignment??(K.type==="number"?"right":"left"),vertical:"middle"},D.border={bottom:{style:"thin",color:{argb:"FFf1f5f9"}}})}),G.length>0){const D=G.reduce((L,te)=>Math.max(L,s[te.field]?.imageHeight??40),0),X=Math.ceil(D/1.333),K=X*1.333;A.height=X,G.forEach(L=>{const te=C.indexOf(L),ee=k[L.field],Q=typeof ee=="string"?S.get(ee):void 0;if(Q===void 0){A.getCell(te+1).value=typeof ee=="string"?ee:"";return}const ce=s[L.field],$=ce?.imageWidth??40,ae=ce?.imageHeight??40,se=(Y.getColumn(te+1).width??8)*7+5,ie=Math.max(0,se-$)/2,z=Math.max(0,K-ae)/2;Y.addImage(Q,{tl:{col:te,row:V,nativeColOff:Math.floor(ie*9525),nativeRowOff:Math.floor(z*9525)},ext:{width:$,height:ae},editAs:"oneCell"})})}else A.height=16;V++}),W&&f&&m){const k=C.map(D=>{const X=m[D.field];return X?X.toUpperCase():""}),B=Y.addRow(k);B.height=16,B.font={size:c-1,italic:!0,color:{argb:"FF94a3b8"}},B.eachCell(D=>{D.alignment={horizontal:"right",vertical:"middle"},D.border={top:{style:"thin",color:{argb:"FFcbd5e1"}}}});const O=C.map(D=>{const X=m[D.field],K=f[D.field];return X==null||K==null?"":D.valueFormatter?D.valueFormatter({value:K,row:{},field:D.field}):Ie(K,X)}),A=Y.addRow(O);A.height=18,A.font={bold:!0,size:c,color:{argb:Te(a)}},A.eachCell(D=>{D.fill={type:"pattern",pattern:"solid",fgColor:{argb:Te(d)}},D.alignment={horizontal:"right",vertical:"middle"},D.border=Ar()})}}const y=await v.xlsx.writeBuffer(),w=new Blob([y],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),g=URL.createObjectURL(w),x=document.createElement("a");x.href=g,x.download=o.endsWith(".xlsx")?o:`${o}.xlsx`,document.body.appendChild(x),x.click(),document.body.removeChild(x),URL.revokeObjectURL(g)}function Te(n){const t=n.replace("#","");return t.length===3?"FF"+t.split("").map(e=>e+e).join(""):t.length===6?"FF"+t:"FF"+t.padEnd(6,"0")}function Nn(){return{bottom:{style:"medium",color:{argb:"FFcbd5e1"}}}}function Ar(){return{top:{style:"medium",color:{argb:"FFcbd5e1"}}}}const zr={"--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-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-grid-row-selected-background":"#eff6ff","--ogx-grid-row-selected-hover-background":"#dbeafe","--ogx-grid-cell-focus-border":"#3b82f6","--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":"transparent","--ogx-toolbar-text":"#1e293b","--ogx-toolbar-border":"#e2e8f0","--ogx-toolbar-btn-bg":"transparent","--ogx-toolbar-btn-hover":"#f1f5f9","--ogx-toolbar-btn-text":"#334155","--ogx-toolbar-btn-primary-bg":"#3b82f6","--ogx-toolbar-btn-primary-hover":"#2563eb","--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-bg":"#ffffff","--ogx-toolbar-input-text":"#1e293b","--ogx-toolbar-input-border":"#cbd5e1","--ogx-toolbar-input-focus-border":"#3b82f6","--ogx-toolbar-input-focus-shadow":"0 0 0 3px rgba(59, 130, 246, 0.12)","--ogx-toolbar-chip-bg":"#f1f5f9","--ogx-toolbar-chip-text":"#475569","--ogx-toolbar-chip-active-bg":"rgba(59, 130, 246, 0.12)","--ogx-toolbar-chip-active-text":"#2563eb","--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-selected-bg":"rgba(59, 130, 246, 0.08)","--ogx-overlay-item-selected-text":"#2563eb","--ogx-overlay-item-danger-bg":"rgba(239, 68, 68, 0.08)","--ogx-overlay-item-danger-text":"#ef4444","--ogx-scrollbar-thumb":"rgba(148, 163, 184, 0.5)","--ogx-scrollbar-track":"transparent","--ogx-scrollbar-size":"10px","--ogx-skeleton-base":"#f1f5f9","--ogx-skeleton-highlight":"#ffffff","--ogx-skeleton-dark-base":"#e2e8f0","--ogx-skeleton-dark-highlight":"#f8fafc"};function Br(n){const t={};function e(o,i){i!==void 0&&(t[o]=i)}if(n.colors){const o=n.colors;e("--ogx-color-primary",o.primary),e("--ogx-color-primary-dark",o.primaryDark),e("--ogx-color-primary-light",o.primaryLight),e("--ogx-color-primary-focus",o.primaryFocus),e("--ogx-color-secondary",o.secondary),e("--ogx-color-secondary-dark",o.secondaryDark),e("--ogx-color-secondary-light",o.secondaryLight),e("--ogx-color-success",o.success),e("--ogx-color-warning",o.warning),e("--ogx-color-error",o.error),e("--ogx-color-info",o.info)}if(n.typography){const o=n.typography;e("--ogx-font-family",o.fontFamily),e("--ogx-font-family-mono",o.fontFamilyMono),e("--ogx-font-size-xs",o.fontSizeXs),e("--ogx-font-size-sm",o.fontSizeSm),e("--ogx-font-size-md",o.fontSizeMd),e("--ogx-font-size-lg",o.fontSizeLg),e("--ogx-font-size-xl",o.fontSizeXl)}if(n.spacing){const o=n.spacing;e("--ogx-spacing-xs",o.xs),e("--ogx-spacing-sm",o.sm),e("--ogx-spacing-md",o.md),e("--ogx-spacing-lg",o.lg),e("--ogx-spacing-xl",o.xl),e("--ogx-spacing-xxl",o.xxl)}if(n.borders){const o=n.borders;e("--ogx-border-width-thin",o.widthThin),e("--ogx-border-width-medium",o.widthMedium),e("--ogx-border-width-thick",o.widthThick),e("--ogx-border-radius-sm",o.radiusSm),e("--ogx-border-radius-md",o.radiusMd),e("--ogx-border-radius-lg",o.radiusLg),e("--ogx-border-radius-xl",o.radiusXl),e("--ogx-border-color",o.color),e("--ogx-border-color-hover",o.colorHover)}if(n.shadows){const o=n.shadows;e("--ogx-shadow-sm",o.sm),e("--ogx-shadow-md",o.md),e("--ogx-shadow-lg",o.lg),e("--ogx-shadow-xl",o.xl)}if(n.grid){const o=n.grid;e("--ogx-grid-row-height-compact",o.rowHeightCompact),e("--ogx-grid-row-height-standard",o.rowHeightStandard),e("--ogx-row-height",o.rowHeightStandard),e("--ogx-grid-row-height-comfortable",o.rowHeightComfortable),e("--ogx-grid-header-height",o.headerHeight),e("--ogx-header-height",o.headerHeight),e("--ogx-grid-cell-padding-x",o.cellPaddingX),e("--ogx-grid-cell-padding-y",o.cellPaddingY),e("--ogx-grid-background",o.background),e("--ogx-grid-border-color",o.borderColor),e("--ogx-grid-header-background",o.headerBackground),e("--ogx-grid-header-text",o.headerText),e("--ogx-grid-header-hover-background",o.headerHoverBackground),e("--ogx-grid-header-sorted-background",o.headerSortedBackground),e("--ogx-grid-row-text",o.rowText),e("--ogx-grid-row-hover-background",o.rowHoverBackground),e("--ogx-grid-row-alternate-background",o.rowAlternateBackground),e("--ogx-grid-row-selected-background",o.rowSelectedBackground),e("--ogx-grid-row-selected-hover-background",o.rowSelectedHoverBackground),e("--ogx-grid-cell-focus-border",o.cellFocusBorder),e("--ogx-grid-pinned-left-shadow",o.pinnedLeftShadow),e("--ogx-grid-pinned-right-shadow",o.pinnedRightShadow),e("--ogx-checkbox-bg",o.checkboxBg),e("--ogx-checkbox-border",o.checkboxBorder)}if(n.transitions){const o=n.transitions;e("--ogx-transition-duration-fast",o.durationFast),e("--ogx-transition-duration-normal",o.durationNormal),e("--ogx-transition-duration-slow",o.durationSlow),e("--ogx-transition-easing",o.easing)}if(n.toolbar){const o=n.toolbar;e("--ogx-toolbar-background",o.background),e("--ogx-toolbar-text",o.text),e("--ogx-toolbar-border",o.border),e("--ogx-toolbar-btn-bg",o.buttonBackground),e("--ogx-toolbar-btn-hover",o.buttonHoverBackground),e("--ogx-toolbar-btn-text",o.buttonText),e("--ogx-toolbar-btn-primary-bg",o.buttonPrimaryBackground),e("--ogx-toolbar-btn-primary-hover",o.buttonPrimaryHoverBackground),e("--ogx-toolbar-btn-primary-text",o.buttonPrimaryText),e("--ogx-toolbar-btn-danger-bg",o.buttonDangerBackground),e("--ogx-toolbar-btn-danger-hover",o.buttonDangerHoverBackground),e("--ogx-toolbar-btn-danger-text",o.buttonDangerText),e("--ogx-toolbar-input-bg",o.inputBackground),e("--ogx-toolbar-input-text",o.inputText),e("--ogx-toolbar-input-border",o.inputBorder),e("--ogx-toolbar-input-focus-border",o.inputFocusBorder),e("--ogx-toolbar-input-focus-shadow",o.inputFocusShadow),e("--ogx-toolbar-chip-bg",o.chipBackground),e("--ogx-toolbar-chip-text",o.chipText),e("--ogx-toolbar-chip-active-bg",o.chipActiveBackground),e("--ogx-toolbar-chip-active-text",o.chipActiveText)}if(n.overlays){const o=n.overlays;e("--ogx-overlay-background",o.background),e("--ogx-overlay-text",o.text),e("--ogx-overlay-border",o.border),e("--ogx-overlay-shadow",o.shadow),e("--ogx-overlay-item-hover-bg",o.itemHoverBackground),e("--ogx-overlay-item-hover-text",o.itemHoverText),e("--ogx-overlay-item-selected-bg",o.itemSelectedBackground),e("--ogx-overlay-item-selected-text",o.itemSelectedText),e("--ogx-overlay-item-danger-bg",o.itemDangerBackground),e("--ogx-overlay-item-danger-text",o.itemDangerText)}if(n.scrollbar){const o=n.scrollbar;e("--ogx-scrollbar-thumb",o.thumbColor),e("--ogx-scrollbar-track",o.trackColor),e("--ogx-scrollbar-size",o.size)}if(n.skeleton){const o=n.skeleton;e("--ogx-skeleton-base",o.baseColor),e("--ogx-skeleton-highlight",o.highlightColor),e("--ogx-skeleton-dark-base",o.darkBaseColor),e("--ogx-skeleton-dark-highlight",o.darkHighlightColor)}return t}function $r({theme:n,children:t,className:e,style:o}){const i=l.useMemo(()=>({...zr,...Br(n)}),[n]);return r.jsx("div",{className:`ogx-theme-provider ${e||""}`.trim(),style:{...o,...i},children:t})}const Dr={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",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:"transparent",text:"#cbd5e1",border:"#334155",buttonBackground:"transparent",buttonHoverBackground:"#1e293b",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",darkBaseColor:"#0f172a",darkHighlightColor:"#1e293b"}},Hr={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"}},Gr={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"}},Vr={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"}},Ur={grid:{rowHeightCompact:"28px",rowHeightStandard:"36px",rowHeightComfortable:"48px",headerHeight:"40px",cellPaddingX:"8px",cellPaddingY:"4px"},typography:{fontSizeSm:"0.8rem",fontSizeMd:"0.875rem"}};function Kr(n,t){try{const e=t.getItem(n);return e?JSON.parse(e):void 0}catch{return}}function Yr(n,t,e,o){try{const i=e?Object.fromEntries(Object.entries(t).filter(([s])=>e.includes(s))):t;o.setItem(n,JSON.stringify(i))}catch{}}function qr(n){const t=typeof n=="string"?{key:n}:n,{key:e,debounceMs:o=300,include:i,storage:s=typeof window<"u"?window.localStorage:void 0}=t,d=l.useMemo(()=>{if(s)return Kr(e,s)},[e,s]),a=l.useRef(null),u=l.useRef(null),c=l.useCallback(()=>{u.current&&s&&Yr(e,u.current,i,s)},[e,i,s]),f=l.useCallback(p=>{u.current=p,a.current&&clearTimeout(a.current),a.current=setTimeout(c,o)},[c,o]);l.useEffect(()=>()=>{a.current&&(clearTimeout(a.current),c())},[c]);const m=l.useCallback(()=>{s&&s.removeItem(e)},[e,s]);return{initialState:d,onStateChange:f,clearState:m}}re.Button=at,re.Cell=vn,re.Checkbox=st,re.DataGrid=cr,re.DataGridThemeProvider=$r,re.FilterPanel=kn,re.GridToolbar=Sr,re.GridTooltip=ct,re.Header=xn,re.Input=Er,re.Row=bt,re.Skeleton=ur,re.amberTheme=Vr,re.compactTheme=Ur,re.darkTheme=Dr,re.emeraldTheme=Gr,re.exportToCsv=Nr,re.exportToExcel=Mr,re.exportToExcelAdvanced=Fr,re.exportToJson=Pr,re.formatAggregationValue=Ie,re.printGrid=Ir,re.roseTheme=Hr,re.useAggregation=hn,re.useGridApiRef=jr,re.useGridStateStorage=qr,re.usePivot=wn,Object.defineProperty(re,Symbol.toStringTag,{value:"Module"})}));
|
|
52
|
+
`;if(l&&(p+=`<h1>${Ne(l)}</h1>`),p+="<table>",p+="<thead><tr>",c.forEach(h=>{p+=`<th>${Ne(h.headerName||h.field)}</th>`}),p+="</tr></thead>",p+="<tbody>",u.forEach(h=>{p+="<tr>",c.forEach(m=>{let _=h[m.field];m.valueGetter&&(_=m.valueGetter({row:h,field:m.field,value:_})),m.valueFormatter&&_!==void 0&&_!==null&&(_=m.valueFormatter({value:_,row:h,field:m.field})),m.type==="image"&&_?p+=`<td><div style="display:flex;justify-content:center;"><img src="${_}" alt="${m.headerName}" style="max-height: 40px; border-radius: 4px;"></div></td>`:p+=`<td>${Ne(String(_??""))}</td>`}),p+="</tr>"}),d){const h=a||{};p+='<tfoot><tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',c.forEach(m=>{h[m.field]?p+=`<td style="text-align: right; font-weight: bold;">${Ne(h[m.field].toUpperCase())}</td>`:p+="<td></td>"}),p+='</tr><tr style="font-weight: bold; background-color: #f5f5f5;">',c.forEach(m=>{const _=d[m.field];if(_!=null){let C=_;m.valueFormatter?C=m.valueFormatter({value:_,row:{},field:m.field}):h[m.field]&&(C=Re(_,h[m.field])),p+=`<td style="text-align: right;">${Ne(String(C))}</td>`}else p+="<td></td>"}),p+="</tr></tfoot>"}p+="</tbody></table></body></html>",o.document.open(),o.document.write(p),o.document.close(),o.document.title=l||"Print Preview",o.focus();let b=!1;o.onload=()=>{b||(b=!0,o.print(),setTimeout(()=>{o.close()},100))},setTimeout(()=>{!b&&o&&!o.closed&&(b=!0,o.print(),setTimeout(()=>{o.closed||o.close()},100))},500)}catch(l){if(console.error("Print generation failed:",l),o&&!o.closed){const s=l instanceof Error?l.message:String(l);o.document.body.innerHTML=`<div style="color: red; padding: 20px;"><h3>Error Generating Print Preview</h3><p>${s}</p></div>`}}}function Vt(n,t,e){const o=new Blob([n],{type:e}),l=URL.createObjectURL(o),s=document.createElement("a");s.href=l,s.download=t,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(l)}function Br(n,t){return n.type==="number"?"number":n.type==="boolean"?"boolean":n.type==="date"?"date":typeof t=="number"?"number":typeof t=="boolean"?"boolean":t instanceof Date?"date":"string"}function $r(n){if(n.type==="number")return"#,##0.##";if(n.type==="date")return"yyyy-mm-dd"}function Dr(n,t){if(t!=null)return t;const e=n.width??120;return Math.min(60,Math.max(8,(e-5)/7))}function Hr(n,t){const e=t??"";if(e.includes("jpeg")||e.includes("jpg"))return"jpeg";if(e.includes("gif"))return"gif";const o=n.split("?")[0].toLowerCase();return o.endsWith(".jpg")||o.endsWith(".jpeg")?"jpeg":o.endsWith(".gif")?"gif":"png"}async function Gr(n){const t=await Promise.allSettled(n.map(async o=>{if(o.startsWith("data:")){const a=o.indexOf(","),u=o.slice(0,a),c=o.slice(a+1),p=atob(c),b=new Uint8Array(p.length);for(let C=0;C<p.length;C++)b[C]=p.charCodeAt(C);const m=u.match(/data:([^;,]+)/)?.[1]??"image/png";let _="png";return m.includes("jpeg")||m.includes("jpg")?_="jpeg":m.includes("gif")&&(_="gif"),{url:o,buffer:b.buffer,ext:_}}const l=await fetch(o,{mode:"cors"});if(!l.ok)throw new Error(`HTTP ${l.status}`);const s=await l.arrayBuffer(),d=Hr(o,l.headers.get("content-type"));return{url:o,buffer:s,ext:d}})),e=new Map;return t.forEach((o,l)=>{o.status==="fulfilled"?e.set(o.value.url,{buffer:o.value.buffer,extension:o.value.ext}):console.warn(`[exportToExcelAdvanced] Cannot embed image "${n[l]}" (CORS/network error — raw URL written as fallback):`,o.reason)}),e}async function Vr(n,t,e={}){const{fileName:o="export.xlsx",sheets:l,columnStyles:s={},headerFillColor:d="#f1f5f9",headerTextColor:a="#334155",headerFontSize:u=10,bodyFontSize:c=10,aggregationResult:p=null,aggregationModel:b=null,selectedRows:h}=e,m=(await import("exceljs")).default,_=new m.Workbook;_.creator="OpenGridX",_.created=new Date;const C=t.filter(k=>k.exportable!==!1&&k.field!=="__check__"&&k.field!=="__actions__"&&!k.isSpacer),S=n,P=h&&h.length>0?n.filter(k=>h.includes(k.id)):n,j=l??[{name:"Data",rows:"all",includeHeaders:!0,includeSummary:!1}],w=new Map;for(const k of j){if("type"in k&&k.type==="summary"){if(!p||!b)continue;const y=_.addWorksheet(k.name??"Summary");y.addRow(["Summary / Aggregation Totals"]),y.getRow(1).font={bold:!0,size:u+2,color:{argb:Oe(a)}},y.addRow([]),y.addRow(["Column","Function","Value"]).eachCell(z=>{z.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(d)}},z.font={bold:!0,size:u,color:{argb:Oe(a)}},z.border=Tn()}),C.forEach(z=>{const $=b[z.field],H=p[z.field];if($==null||H==null)return;let X=H;z.valueFormatter?X=z.valueFormatter({value:H,row:{},field:z.field}):X=Re(H,$);const U=y.addRow([z.headerName??z.field,$.toUpperCase(),X]);U.getCell(3).alignment={horizontal:"right"},U.getCell(3).font={bold:!0,size:c}}),y.getColumn(1).width=20,y.getColumn(2).width=12,y.getColumn(3).width=18;continue}const M=k,{name:N="Data",rows:v="all",includeHeaders:I=!0,includeSummary:L=!1,autoFilter:W=!0,frozenHeader:A=!0,alternateRowColor:G="#f8fafc"}=M,T=v==="selected"?P:S,B=C.filter(y=>s[y.field]?.embedImage);if(B.length>0){const y=[],O=new Set;if(T.forEach(z=>{B.forEach($=>{const H=z[$.field];typeof H=="string"&&H&&!w.has(H)&&!O.has(H)&&(y.push(H),O.add(H))})}),y.length>0){const z=await Gr(y);for(const[$,{buffer:H,extension:X}]of z){const U=_.addImage({buffer:H,extension:X});w.set($,U)}}}const Y=_.addWorksheet(N);if(Y.columns=C.map(y=>({key:y.field,width:Dr(y,s[y.field]?.width),style:{numFmt:s[y.field]?.numFmt??$r(y)}})),I){const y=C.map(z=>z.headerName??z.field),O=Y.addRow(y);O.height=20,O.eachCell((z,$)=>{const H=C[$-1];z.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(d)}},z.font={bold:!0,size:u,color:{argb:Oe(a)}},z.alignment={horizontal:s[H?.field]?.alignment??(H?.type==="number"?"right":"left"),vertical:"middle"},z.border=Tn()}),W&&(Y.autoFilter={from:{row:1,column:1},to:{row:1,column:C.length}}),A?Y.views=[{state:"frozen",ySplit:1,showGridLines:!1}]:Y.views=[{showGridLines:!1}]}let K=I?1:0;if(T.forEach((y,O)=>{const z=C.map(H=>{if(s[H.field]?.embedImage)return"";let X=y[H.field];return H.valueGetter&&(X=H.valueGetter({row:y,field:H.field,value:X})),Br(H,X)==="string"&&H.valueFormatter&&X!=null&&(X=H.valueFormatter({value:X,row:y,field:H.field})),X}),$=Y.addRow(z);if($.font={size:c},G&&O%2===1&&$.eachCell(H=>{H.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(G)}}}),$.eachCell((H,X)=>{const U=C[X-1];U&&(H.alignment={horizontal:s[U.field]?.alignment??(U.type==="number"?"right":"left"),vertical:"middle"},H.border={bottom:{style:"thin",color:{argb:"FFf1f5f9"}}})}),B.length>0){const H=B.reduce((te,R)=>Math.max(te,s[R.field]?.imageHeight??40),0),X=Math.ceil(H/1.333),U=X*1.333;$.height=X,B.forEach(te=>{const R=C.indexOf(te),J=y[te.field],Q=typeof J=="string"?w.get(J):void 0;if(Q===void 0){$.getCell(R+1).value=typeof J=="string"?J:"";return}const le=s[te.field],oe=le?.imageWidth??40,pe=le?.imageHeight??40,ie=(Y.getColumn(R+1).width??8)*7+5,se=Math.max(0,ie-oe)/2,D=Math.max(0,U-pe)/2;Y.addImage(Q,{tl:{col:R,row:K,nativeColOff:Math.floor(se*9525),nativeRowOff:Math.floor(D*9525)},ext:{width:oe,height:pe},editAs:"oneCell"})})}else $.height=16;K++}),L&&p&&b){const y=C.map(H=>{const X=b[H.field];return X?X.toUpperCase():""}),O=Y.addRow(y);O.height=16,O.font={size:c-1,italic:!0,color:{argb:"FF94a3b8"}},O.eachCell(H=>{H.alignment={horizontal:"right",vertical:"middle"},H.border={top:{style:"thin",color:{argb:"FFcbd5e1"}}}});const z=C.map(H=>{const X=b[H.field],U=p[H.field];return X==null||U==null?"":H.valueFormatter?H.valueFormatter({value:U,row:{},field:H.field}):Re(U,X)}),$=Y.addRow(z);$.height=18,$.font={bold:!0,size:c,color:{argb:Oe(a)}},$.eachCell(H=>{H.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(d)}},H.alignment={horizontal:"right",vertical:"middle"},H.border=Ur()})}}const E=await _.xlsx.writeBuffer(),g=new Blob([E],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),x=URL.createObjectURL(g),f=document.createElement("a");f.href=x,f.download=o.endsWith(".xlsx")?o:`${o}.xlsx`,document.body.appendChild(f),f.click(),document.body.removeChild(f),URL.revokeObjectURL(x)}function Oe(n){const t=n.replace("#","");return t.length===3?"FF"+t.split("").map(e=>e+e).join(""):t.length===6?"FF"+t:"FF"+t.padEnd(6,"0")}function Tn(){return{bottom:{style:"medium",color:{argb:"FFcbd5e1"}}}}function Ur(){return{top:{style:"medium",color:{argb:"FFcbd5e1"}}}}const Kr={"--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-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-grid-row-selected-background":"#eff6ff","--ogx-grid-row-selected-hover-background":"#dbeafe","--ogx-grid-cell-focus-border":"#3b82f6","--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":"transparent","--ogx-toolbar-text":"#1e293b","--ogx-toolbar-border":"#e2e8f0","--ogx-toolbar-btn-bg":"transparent","--ogx-toolbar-btn-hover":"#f1f5f9","--ogx-toolbar-btn-text":"#334155","--ogx-toolbar-btn-primary-bg":"#3b82f6","--ogx-toolbar-btn-primary-hover":"#2563eb","--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-bg":"#ffffff","--ogx-toolbar-input-text":"#1e293b","--ogx-toolbar-input-border":"#cbd5e1","--ogx-toolbar-input-focus-border":"#3b82f6","--ogx-toolbar-input-focus-shadow":"0 0 0 3px rgba(59, 130, 246, 0.12)","--ogx-toolbar-chip-bg":"#f1f5f9","--ogx-toolbar-chip-text":"#475569","--ogx-toolbar-chip-active-bg":"rgba(59, 130, 246, 0.12)","--ogx-toolbar-chip-active-text":"#2563eb","--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-selected-bg":"rgba(59, 130, 246, 0.08)","--ogx-overlay-item-selected-text":"#2563eb","--ogx-overlay-item-danger-bg":"rgba(239, 68, 68, 0.08)","--ogx-overlay-item-danger-text":"#ef4444","--ogx-scrollbar-thumb":"rgba(148, 163, 184, 0.5)","--ogx-scrollbar-track":"transparent","--ogx-scrollbar-size":"10px","--ogx-skeleton-base":"#f1f5f9","--ogx-skeleton-highlight":"#ffffff","--ogx-skeleton-dark-base":"#e2e8f0","--ogx-skeleton-dark-highlight":"#f8fafc"};function Yr(n){const t={};function e(o,l){l!==void 0&&(t[o]=l)}if(n.colors){const o=n.colors;e("--ogx-color-primary",o.primary),e("--ogx-color-primary-dark",o.primaryDark),e("--ogx-color-primary-light",o.primaryLight),e("--ogx-color-primary-focus",o.primaryFocus),e("--ogx-color-secondary",o.secondary),e("--ogx-color-secondary-dark",o.secondaryDark),e("--ogx-color-secondary-light",o.secondaryLight),e("--ogx-color-success",o.success),e("--ogx-color-warning",o.warning),e("--ogx-color-error",o.error),e("--ogx-color-info",o.info)}if(n.typography){const o=n.typography;e("--ogx-font-family",o.fontFamily),e("--ogx-font-family-mono",o.fontFamilyMono),e("--ogx-font-size-xs",o.fontSizeXs),e("--ogx-font-size-sm",o.fontSizeSm),e("--ogx-font-size-md",o.fontSizeMd),e("--ogx-font-size-lg",o.fontSizeLg),e("--ogx-font-size-xl",o.fontSizeXl)}if(n.spacing){const o=n.spacing;e("--ogx-spacing-xs",o.xs),e("--ogx-spacing-sm",o.sm),e("--ogx-spacing-md",o.md),e("--ogx-spacing-lg",o.lg),e("--ogx-spacing-xl",o.xl),e("--ogx-spacing-xxl",o.xxl)}if(n.borders){const o=n.borders;e("--ogx-border-width-thin",o.widthThin),e("--ogx-border-width-medium",o.widthMedium),e("--ogx-border-width-thick",o.widthThick),e("--ogx-border-radius-sm",o.radiusSm),e("--ogx-border-radius-md",o.radiusMd),e("--ogx-border-radius-lg",o.radiusLg),e("--ogx-border-radius-xl",o.radiusXl),e("--ogx-border-color",o.color),e("--ogx-border-color-hover",o.colorHover)}if(n.shadows){const o=n.shadows;e("--ogx-shadow-sm",o.sm),e("--ogx-shadow-md",o.md),e("--ogx-shadow-lg",o.lg),e("--ogx-shadow-xl",o.xl)}if(n.grid){const o=n.grid;e("--ogx-grid-row-height-compact",o.rowHeightCompact),e("--ogx-grid-row-height-standard",o.rowHeightStandard),e("--ogx-row-height",o.rowHeightStandard),e("--ogx-grid-row-height-comfortable",o.rowHeightComfortable),e("--ogx-grid-header-height",o.headerHeight),e("--ogx-header-height",o.headerHeight),e("--ogx-grid-cell-padding-x",o.cellPaddingX),e("--ogx-grid-cell-padding-y",o.cellPaddingY),e("--ogx-grid-background",o.background),e("--ogx-grid-border-color",o.borderColor),e("--ogx-grid-header-background",o.headerBackground),e("--ogx-grid-header-text",o.headerText),e("--ogx-grid-header-hover-background",o.headerHoverBackground),e("--ogx-grid-header-sorted-background",o.headerSortedBackground),e("--ogx-grid-row-text",o.rowText),e("--ogx-grid-row-hover-background",o.rowHoverBackground),e("--ogx-grid-row-alternate-background",o.rowAlternateBackground),e("--ogx-grid-row-selected-background",o.rowSelectedBackground),e("--ogx-grid-row-selected-hover-background",o.rowSelectedHoverBackground),e("--ogx-grid-cell-focus-border",o.cellFocusBorder),e("--ogx-grid-pinned-left-shadow",o.pinnedLeftShadow),e("--ogx-grid-pinned-right-shadow",o.pinnedRightShadow),e("--ogx-checkbox-bg",o.checkboxBg),e("--ogx-checkbox-border",o.checkboxBorder)}if(n.transitions){const o=n.transitions;e("--ogx-transition-duration-fast",o.durationFast),e("--ogx-transition-duration-normal",o.durationNormal),e("--ogx-transition-duration-slow",o.durationSlow),e("--ogx-transition-easing",o.easing)}if(n.toolbar){const o=n.toolbar;e("--ogx-toolbar-background",o.background),e("--ogx-toolbar-text",o.text),e("--ogx-toolbar-border",o.border),e("--ogx-toolbar-btn-bg",o.buttonBackground),e("--ogx-toolbar-btn-hover",o.buttonHoverBackground),e("--ogx-toolbar-btn-text",o.buttonText),e("--ogx-toolbar-btn-primary-bg",o.buttonPrimaryBackground),e("--ogx-toolbar-btn-primary-hover",o.buttonPrimaryHoverBackground),e("--ogx-toolbar-btn-primary-text",o.buttonPrimaryText),e("--ogx-toolbar-btn-danger-bg",o.buttonDangerBackground),e("--ogx-toolbar-btn-danger-hover",o.buttonDangerHoverBackground),e("--ogx-toolbar-btn-danger-text",o.buttonDangerText),e("--ogx-toolbar-input-bg",o.inputBackground),e("--ogx-toolbar-input-text",o.inputText),e("--ogx-toolbar-input-border",o.inputBorder),e("--ogx-toolbar-input-focus-border",o.inputFocusBorder),e("--ogx-toolbar-input-focus-shadow",o.inputFocusShadow),e("--ogx-toolbar-chip-bg",o.chipBackground),e("--ogx-toolbar-chip-text",o.chipText),e("--ogx-toolbar-chip-active-bg",o.chipActiveBackground),e("--ogx-toolbar-chip-active-text",o.chipActiveText)}if(n.overlays){const o=n.overlays;e("--ogx-overlay-background",o.background),e("--ogx-overlay-text",o.text),e("--ogx-overlay-border",o.border),e("--ogx-overlay-shadow",o.shadow),e("--ogx-overlay-item-hover-bg",o.itemHoverBackground),e("--ogx-overlay-item-hover-text",o.itemHoverText),e("--ogx-overlay-item-selected-bg",o.itemSelectedBackground),e("--ogx-overlay-item-selected-text",o.itemSelectedText),e("--ogx-overlay-item-danger-bg",o.itemDangerBackground),e("--ogx-overlay-item-danger-text",o.itemDangerText)}if(n.scrollbar){const o=n.scrollbar;e("--ogx-scrollbar-thumb",o.thumbColor),e("--ogx-scrollbar-track",o.trackColor),e("--ogx-scrollbar-size",o.size)}if(n.skeleton){const o=n.skeleton;e("--ogx-skeleton-base",o.baseColor),e("--ogx-skeleton-highlight",o.highlightColor),e("--ogx-skeleton-dark-base",o.darkBaseColor),e("--ogx-skeleton-dark-highlight",o.darkHighlightColor)}return t}function qr({theme:n,children:t,className:e,style:o}){const l=i.useMemo(()=>({...Kr,...Yr(n)}),[n]);return r.jsx("div",{className:`ogx-theme-provider ${e||""}`.trim(),style:{...o,...l},children:t})}const Xr={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",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:"transparent",text:"#cbd5e1",border:"#334155",buttonBackground:"transparent",buttonHoverBackground:"#1e293b",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",darkBaseColor:"#0f172a",darkHighlightColor:"#1e293b"}},Jr={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"}},Qr={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"}},Zr={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"}},ei={grid:{rowHeightCompact:"28px",rowHeightStandard:"36px",rowHeightComfortable:"48px",headerHeight:"40px",cellPaddingX:"8px",cellPaddingY:"4px"},typography:{fontSizeSm:"0.8rem",fontSizeMd:"0.875rem"}};function ti(n,t){try{const e=t.getItem(n);return e?JSON.parse(e):void 0}catch{return}}function ni(n,t,e,o){try{const l=e?Object.fromEntries(Object.entries(t).filter(([s])=>e.includes(s))):t;o.setItem(n,JSON.stringify(l))}catch{}}function oi(n){const t=typeof n=="string"?{key:n}:n,{key:e,debounceMs:o=300,include:l,storage:s=typeof window<"u"?window.localStorage:void 0}=t,d=i.useMemo(()=>{if(s)return ti(e,s)},[e,s]),a=i.useRef(null),u=i.useRef(null),c=i.useCallback(()=>{u.current&&s&&ni(e,u.current,l,s)},[e,l,s]),p=i.useCallback(h=>{u.current=h,a.current&&clearTimeout(a.current),a.current=setTimeout(c,o)},[c,o]);i.useEffect(()=>()=>{a.current&&(clearTimeout(a.current),c())},[c]);const b=i.useCallback(()=>{s&&s.removeItem(e)},[e,s]);return{initialState:d,onStateChange:p,clearState:b}}re.Button=ut,re.Cell=kn,re.Checkbox=ct,re.DataGrid=br,re.DataGridThemeProvider=qr,re.FilterPanel=Nn,re.GridToolbar=Lr,re.GridTooltip=gt,re.Header=vn,re.Input=Or,re.Row=yt,re.Skeleton=wr,re.amberTheme=Zr,re.compactTheme=ei,re.darkTheme=Xr,re.emeraldTheme=Qr,re.exportToCsv=Wr,re.exportToExcel=Fr,re.exportToExcelAdvanced=Vr,re.exportToJson=Ar,re.formatAggregationValue=Re,re.printGrid=zr,re.roseTheme=Jr,re.useAggregation=bn,re.useGridApiRef=Rr,re.useGridStateStorage=oi,re.usePivot=yn,Object.defineProperty(re,Symbol.toStringTag,{value:"Module"})}));
|
|
53
53
|
//# sourceMappingURL=opengridx.umd.js.map
|