@opencorestack/opengridx 2.0.4 → 2.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 +45 -3
- package/dist/index.d.ts +43 -2
- package/dist/opengridx.css +1 -1
- package/dist/opengridx.es.js +3927 -3839
- package/dist/opengridx.es.js.map +1 -1
- package/dist/opengridx.umd.js +16 -16
- package/dist/opengridx.umd.js.map +1 -1
- package/docs/API_REFERENCE.md +13 -4
- package/docs/components/column-visibility.md +40 -16
- package/docs/customization/slots-api.md +18 -6
- package/docs/features/export-guide.md +22 -3
- package/docs/features/sorting-pagination.md +2 -0
- package/docs/features/tree-data-grouping.md +8 -1
- package/docs/features/virtualization.md +36 -8
- package/docs/roadmap.md +13 -7
- package/lib/components/Cell/Cell.tsx +1 -0
- package/lib/components/DataGrid/DataGrid.css +7 -0
- package/lib/components/DataGrid/DataGrid.defects.test.tsx +103 -0
- package/lib/components/DataGrid/DataGrid.tsx +42 -10
- package/lib/components/DataGrid/DataGrid.virtualization.browser.test.tsx +183 -0
- package/lib/components/DataGrid/GridEmptyState.tsx +7 -1
- package/lib/components/DataGrid/GridListView.tsx +3 -0
- package/lib/components/DataGrid/GridPinnedRows.tsx +3 -0
- package/lib/components/DataGrid/GridVirtualRows.tsx +8 -1
- package/lib/components/ListView/ListViewRow.tsx +3 -0
- package/lib/components/Row/Row.tsx +10 -0
- package/lib/hooks/core/useGridColumns.tsx +8 -3
- package/lib/hooks/core/useGridDevWarnings.ts +42 -0
- package/lib/hooks/core/useGridKeyboardNavigation.ts +12 -14
- package/lib/hooks/core/useGridVisibleRows.ts +3 -2
- package/lib/hooks/features/useAggregation.ts +3 -38
- package/lib/hooks/useRowGrouping.test.ts +162 -1
- package/lib/hooks/useRowGrouping.ts +42 -59
- package/lib/hooks/useTreeData.test.ts +83 -0
- package/lib/hooks/useTreeData.ts +44 -43
- package/lib/index.ts +2 -0
- package/lib/types/index.ts +15 -2
- package/lib/utils/aggregation/aggregation.test.ts +16 -0
- package/lib/utils/aggregation/index.ts +62 -0
- package/lib/utils/export/exportToExcelAdvanced.test.ts +109 -0
- package/lib/utils/export/exportToExcelAdvanced.ts +89 -5
- package/lib/utils/scroll/index.ts +28 -0
- package/llms.txt +22 -13
- package/package.json +7 -3
package/dist/opengridx.umd.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(se,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],s):(se=typeof globalThis<"u"?globalThis:se||self,s(se.OpenGridX={},se.React,se.ReactDOM))})(this,(function(se,s,Ve){"use strict";var Ft={exports:{}},xt={};var jn;function bo(){if(jn)return xt;jn=1;var n=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function e(o,i,l){var a=null;if(l!==void 0&&(a=""+l),i.key!==void 0&&(a=""+i.key),"key"in i){l={};for(var d in i)d!=="key"&&(l[d]=i[d])}else l=i;return i=l.ref,{$$typeof:n,type:o,key:a,ref:i!==void 0?i:null,props:l}}return xt.Fragment=t,xt.jsx=e,xt.jsxs=e,xt}var mt={};var En;function vo(){return En||(En=1,process.env.NODE_ENV!=="production"&&(function(){function n(_){if(_==null)return null;if(typeof _=="function")return _.$$typeof===b?null:_.displayName||_.name||null;if(typeof _=="string")return _;switch(_){case v:return"Fragment";case m:return"Profiler";case E:return"StrictMode";case k:return"Suspense";case C:return"SuspenseList";case P:return"Activity"}if(typeof _=="object")switch(typeof _.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),_.$$typeof){case h:return"Portal";case M:return _.displayName||"Context";case y:return(_._context.displayName||"Context")+".Consumer";case N:var T=_.render;return _=_.displayName,_||(_=T.displayName||T.name||"",_=_!==""?"ForwardRef("+_+")":"ForwardRef"),_;case S:return T=_.displayName||null,T!==null?T:n(_.type)||"Memo";case j:T=_._payload,_=_._init;try{return n(_(T))}catch{}}return null}function t(_){return""+_}function e(_){try{t(_);var T=!1}catch{T=!0}if(T){T=console;var I=T.error,O=typeof Symbol=="function"&&Symbol.toStringTag&&_[Symbol.toStringTag]||_.constructor.name||"Object";return I.call(T,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",O),t(_)}}function o(_){if(_===v)return"<>";if(typeof _=="object"&&_!==null&&_.$$typeof===j)return"<...>";try{var T=n(_);return T?"<"+T+">":"<...>"}catch{return"<...>"}}function i(){var _=F.A;return _===null?null:_.getOwner()}function l(){return Error("react-stack-top-frame")}function a(_){if(z.call(_,"key")){var T=Object.getOwnPropertyDescriptor(_,"key").get;if(T&&T.isReactWarning)return!1}return _.key!==void 0}function d(_,T){function I(){$||($=!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)",T))}I.isReactWarning=!0,Object.defineProperty(_,"key",{get:I,configurable:!0})}function c(){var _=n(this.type);return H[_]||(H[_]=!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.")),_=this.props.ref,_!==void 0?_:null}function u(_,T,I,O,X,te){var Z=I.ref;return _={$$typeof:f,type:_,key:T,props:I,_owner:O},(Z!==void 0?Z:null)!==null?Object.defineProperty(_,"ref",{enumerable:!1,get:c}):Object.defineProperty(_,"ref",{enumerable:!1,value:null}),_._store={},Object.defineProperty(_._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(_,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(_,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:X}),Object.defineProperty(_,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:te}),Object.freeze&&(Object.freeze(_.props),Object.freeze(_)),_}function p(_,T,I,O,X,te){var Z=T.children;if(Z!==void 0)if(O)if(K(Z)){for(O=0;O<Z.length;O++)w(Z[O]);Object.freeze&&Object.freeze(Z)}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 w(Z);if(z.call(T,"key")){Z=n(_);var ce=Object.keys(T).filter(function(G){return G!=="key"});O=0<ce.length?"{key: someKey, "+ce.join(": ..., ")+": ...}":"{key: someKey}",D[Z+O]||(ce=0<ce.length?"{"+ce.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} />`,O,K,oe,K),V[K+O]=!0)}if(K=null,L!==void 0&&(e(L),K=""+L),d(M)&&(e(M.key),K=""+M.key),"key"in M){L={};for(var ie in M)ie!=="key"&&(L[ie]=M[ie])}else L=M;return K&&a(L,typeof C=="function"?C.displayName||C.name||"Unknown":C),p(C,K,L,l(),H,U)}function w(C){b(C)?C._store&&(C._store.validated=1):typeof C=="object"&&C!==null&&C.$$typeof===P&&(C._payload.status==="fulfilled"?b(C._payload.value)&&C._payload.value._store&&(C._payload.value._store.validated=1):C._store&&(C._store.validated=1))}function b(C){return typeof C=="object"&&C!==null&&C.$$typeof===g}var c=i,g=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),_=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),N=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),j=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),F=Symbol.for("react.activity"),k=Symbol.for("react.client.reference"),I=c.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,R=Object.prototype.hasOwnProperty,W=Array.isArray,$=console.createTask?console.createTask:function(){return null};c={react_stack_bottom_frame:function(C){return C()}};var D,A={},z=c.react_stack_bottom_frame.bind(c,s)(),Y=$(o(s)),V={};pt.Fragment=_,pt.jsx=function(C,M,L){var O=1e4>I.recentlyCreatedOwnerStacks++;return x(C,M,L,!1,O?Error("react-stack-top-frame"):z,O?$(o(C)):Y)},pt.jsxs=function(C,M,L){var O=1e4>I.recentlyCreatedOwnerStacks++;return x(C,M,L,!0,O?Error("react-stack-top-frame"):z,O?$(o(C)):Y)}})()),pt}var kn;function ao(){return kn||(kn=1,process.env.NODE_ENV==="production"?Rt.exports=lo():Rt.exports=so()),Rt.exports}var r=ao();function xt(n,t){return t?t.left?.includes(n)?"left":t.right?.includes(n)?"right":null:null}function co(n,t){const e=[],o=[],l=[];return t?(n.forEach(s=>{const d=xt(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),f=t.left.indexOf(d.field);return a-f}),t.right&&l.sort((s,d)=>{const a=t.right.indexOf(s.field),f=t.right.indexOf(d.field);return a-f}),{left:e,center:o,right:l}):{left:e,center:n,right:l}}function Xt(n,t,e,o,l,s,d,a){const f={};if(!e)return f;const p=co(n,e);let x=0;a&&(x+=48),s&&d&&(x+=48),o&&l&&(x+=48),p.left.forEach(b=>{f[b.field]=x;const c=t[b.field]??b.width??100;x+=c});let w=0;return[...p.right].reverse().forEach(b=>{const c=t[b.field]??b.width??100;f[b.field]=w,w+=c}),f}function Jt(n,t){return t?t.top?.includes(n)?"top":t.bottom?.includes(n)?"bottom":null:null}function uo(n,t){const e=[],o=[],l=[];return t?(n.forEach(s=>{const d=Jt(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),f=t.top.indexOf(d.id);return a-f}),t.bottom&&l.sort((s,d)=>{const a=t.bottom.indexOf(s.id),f=t.bottom.indexOf(d.id);return a-f}),{top:e,center:o,bottom:l}):{top:e,center:n,bottom:l}}function qe(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 fo(n){const{rowHeight:t,pagination:e,paginatedUnpinnedRows:o,sortedUnpinnedRows:l,expandedRowIds:s,getDetailPanelHeight:d,pinnedTopRowsLength:a,pinnedBottomRowsLength:f,visibleOrderedColumns:p,pinnedColumns:x,columnWidths:w,viewportWidth:b,checkboxSelection:c,hasDetailPanel:g,rowReordering:m,paginationMode:_,isLoading:E,pageSize:v}=n;return i.useMemo(()=>{const S=e?o:l,N=S.map((B,Q)=>{let Z=t;if(s.has(B.id)){const ge=d?.({row:B,id:B.id,rowIndex:a+Q})??200;Z+=typeof ge=="number"?ge:parseInt(String(ge),10)||200}return Z}),h=N.reduce((B,Q,Z)=>(B.push((B[Z-1]||0)+Q),B),[]),y=_==="infinite"&&E&&S.length>0?Math.min(v,20):0,u=(h[h.length-1]||0)+y*t,j=a*t,P=f*t,F=[],k=[],I=[],R=[];p.forEach(B=>{const Q=xt(B.field,x);Q==="left"?F.push(B):Q==="right"?k.push(B):I.push(B)});const W=(c?48:0)+(g?48:0)+(m?48:0),$=B=>w[B.field]??B.width,D=F.reduce((B,Q)=>{const Z=qe($(Q));return B+(Z.type==="fixed"?Z.value:100)},0),A=k.reduce((B,Q)=>{const Z=qe($(Q));return B+(Z.type==="fixed"?Z.value:100)},0),z=I.reduce((B,Q)=>{if(!Object.prototype.hasOwnProperty.call(w,Q.field)&&Q.flex&&Q.flex>0){const ce=Q.minWidth??150,Ee=typeof Q.width=="number"?Q.width:150;return B+(ce||Ee)}const ge=qe($(Q));return ge.type==="fixed"?B+ge.value:ge.type==="percentage"?B+100:B+(Q.minWidth??150)},0),Y=Math.max(b-W-D-A,z),V=[],C=[],M=[];I.forEach(B=>{const Q=Object.prototype.hasOwnProperty.call(w,B.field),Z=qe($(B));if(!Q&&B.flex&&B.flex>0){M.push({col:B,flex:B.flex});return}Z.type==="fixed"?V.push({col:B,width:Z.value}):Z.type==="percentage"?C.push({col:B,percentage:Z.value}):M.push({col:B,flex:1})});const L=V.reduce((B,{width:Q})=>B+Q,0);let O=Math.max(0,Y-L);const H=new Map;C.forEach(({col:B,percentage:Q})=>{const Z=Q/100*O;H.set(B.field,Z),O-=Z}),O=Math.max(0,O);const U=new Map,K=M.map(B=>({...B,minWidth:B.col.minWidth??50,maxWidth:B.col.maxWidth??1/0,frozen:!1,computedWidth:0}));(()=>{let B=0;const Q=K.length*2;for(;B<Q;){B++;const Z=K.filter(ee=>!ee.frozen);if(Z.length===0)break;const ge=Z.reduce((ee,ye)=>ee+ye.flex,0),ce=K.reduce((ee,ye)=>ye.frozen?ee+ye.computedWidth:ee,0),Ee=Math.max(0,O-ce);if(ge<=0){Z.forEach(ee=>{ee.computedWidth=ee.minWidth,ee.frozen=!0});break}const Te=Ee/ge;let Pe=0;const Re=[],ze=[];if(Z.forEach(ee=>{const ye=Te*ee.flex;ye<ee.minWidth?(Pe+=ee.minWidth-ye,Re.push(ee)):ye>ee.maxWidth?(Pe+=ee.maxWidth-ye,ze.push(ee)):ee.computedWidth=ye}),Re.length===0&&ze.length===0){Z.forEach(ee=>ee.frozen=!0);break}Pe>0?Re.forEach(ee=>{ee.computedWidth=ee.minWidth,ee.frozen=!0}):Pe<0?ze.forEach(ee=>{ee.computedWidth=ee.maxWidth,ee.frozen=!0}):(Re.forEach(ee=>{ee.computedWidth=ee.minWidth,ee.frozen=!0}),ze.forEach(ee=>{ee.computedWidth=ee.maxWidth,ee.frozen=!0}))}})(),K.forEach(B=>U.set(B.col.field,B.computedWidth));const ie=new Map;I.forEach(B=>{let Q;if(U.has(B.field))Q=U.get(B.field);else{const Z=V.find(ce=>ce.col.field===B.field),ge=C.find(ce=>ce.col.field===B.field);if(Z)Q=Z.width;else if(ge){const ce=H.get(B.field)||0;Q=Math.max(B.minWidth??50,ce||100)}else Q=100}R.push(Q),ie.set(B.field,Q)});const ne=I.map(B=>{const Q=K.find(Z=>Z.col.field===B.field);return{...B,width:ie.get(B.field)??(typeof B.width=="number"?B.width:100),flex:Q?Q.flex:B.flex}}),T=11,le=F.map((B,Q)=>{const Z=qe($(B));return{...B,width:Z.type==="fixed"?Z.value:100,zIndex:T+Q}}),te=11,re=k.map((B,Q)=>{const Z=qe($(B));return{...B,width:Z.type==="fixed"?Z.value:100,zIndex:te+(k.length-1-Q)}}),q=R.reduce((B,Q)=>B+Q,0),J=D+q+A+W,de=R.reduce((B,Q,Z)=>(B.push((B[Z-1]||0)+Q),B),[]);return{rowHeights:N,cumulativeHeights:h,unpinnedRowsHeight:u,pinnedTopHeight:j,pinnedBottomHeight:P,leftPinnedCols:le,rightPinnedCols:re,unpinnedColsWithWidth:ne,unpinnedColWidths:R,unpinnedAccWidths:de,totalWidth:J,leftWidth:D,rightWidth:A,unpinnedTotalWidth:q,systemColumnsWidth:W,pinnedTopRowsLength:a,pinnedBottomRowsLength:f,unpinnedRowsLength:S.length}},[t,e,o,l,s,d,a,f,p,x,w,b,c,g,m,_,E,v])}function go(n){const{allRenderableRows:t,navigationColumns:e,checkboxSelection:o,selectedRowIds:l,handleSelectionChange:s,handleDetailPanelToggle:d,editingHandlers:a,setKeyboardMode:f,sortModel:p,handleSort:x,isCellEditable:w,pagination:b,pageSize:c,virtualization:g,viewportRef:m}=n,[_,E]=i.useState(null),v=i.useCallback(h=>{h.target===h.currentTarget&&E(y=>{if(y)return y;if(o)return{id:"HEADER",field:"__checkbox_col__"};const u=t[0],j=e[0];return u&&j?{id:u.id,field:j.field}:null})},[t,e,o]),S=i.useCallback(h=>{h.currentTarget.contains(h.relatedTarget)||E(null)},[]),N=i.useCallback(h=>{if(f(!0),!_)return;const{id:y,field:u}=_,j=!!a.editingCell;if(y==="HEADER"&&(h.key==="Enter"||h.key===" ")){h.preventDefault();const A=e.find(z=>z.field===u);if(A&&A.sortable!==!1){const z=p.find(V=>V.field===u);let Y="asc";z&&(Y=z.sort==="asc"?"desc":null),x(u,Y)}return}if(h.key==="Enter"){if(h.preventDefault(),j)a.stopCellEdit();else if(e.find(z=>z.field===u)?.editable){const z=t.find(Y=>Y.id===y);z&&a.startCellEdit({id:y,field:u,value:z[u]})}return}if((h.key===" "||h.key==="Spacebar")&&!j){if(u==="__checkbox_col__"){h.preventDefault(),s(y,!l.has(y));return}if(u==="__expand_col__"){h.preventDefault(),d(y);return}}if(h.key==="Escape"){j&&(h.preventDefault(),a.stopCellEdit({cancel:!0}));return}if(j&&h.key!=="Tab")return;const P=y==="HEADER",F=P?-1:t.findIndex(A=>A.id===y),k=e.findIndex(A=>A.field===u);if(!P&&F===-1||k===-1)return;const I=(A,z,Y,V,C,M=!1)=>{let L=A+Y,O=z+V;return C&&V!==0&&(V>0&&O>=e.length?(O=0,L++):V<0&&O<0&&(O=e.length-1,L--)),!C&&(O<0||O>=e.length)||L<(M?-1:0)||L>=t.length?null:{r:L,c:O}},R=(A,z,Y,V,C,M=!1)=>{let L=A,O=z,H=0;const U=t.length*e.length+e.length;for(;H<U;){if(H++,L+=Y,O+=V,V!==0)V>0?O>=e.length&&(O=0,L++):O<0&&(O=e.length-1,L--);else if(O<0||O>=e.length)return null;if(L<-1||L>=t.length)return null;if(L===-1){if(!M)continue;const T=e[O],le=T.sortable!==!1;if(["__checkbox_col__"].includes(T.field)||le)return{r:L,c:O};continue}const K=t[L],oe=e[O],ie=["__checkbox_col__","__expand_col__","__reorder_col__"].includes(oe.field);let ne=oe.editable||ie;if(w&&!ie)try{ne=w({row:K,field:oe.field,value:K[oe.field],colDef:oe,rowIndex:L,colIndex:O})}catch{}if(ne)return{r:L,c:O}}return null};let W=F,$=k,D=!1;if(h.key==="Tab"){const A=h.shiftKey?-1:1,z=R(F,k,0,A,!0,!1);z&&(W=z.r,$=z.c,D=!0)}else if(h.key==="ArrowRight"){const A=I(F,k,0,1,!0,!0);A&&(W=A.r,$=A.c,D=!0)}else if(h.key==="ArrowLeft"){const A=I(F,k,0,-1,!0,!0);A&&(W=A.r,$=A.c,D=!0)}else if(h.key==="ArrowDown"){const A=I(F,k,1,0,!1,!0);A&&(W=A.r,$=A.c,D=!0)}else if(h.key==="ArrowUp"){const A=I(F,k,-1,0,!1,!0);A&&(W=A.r,$=A.c,D=!0)}else if(h.key==="Home")$=0,(h.ctrlKey||h.metaKey)&&(W=-1),D=!0;else if(h.key==="End")$=e.length-1,(h.ctrlKey||h.metaKey)&&(W=t.length-1),D=!0;else if(h.key==="PageUp")W=Math.max(-1,W-(b?c:10)),D=!0;else if(h.key==="PageDown"){const A=b?c:10;W=Math.min(t.length-1,W+A),D=!0}if(D&&(h.preventDefault(),j&&h.key==="Tab"&&a.stopCellEdit(),W>=-1&&W<t.length&&$>=0&&$<e.length)){const A=e[$];E(W===-1?{id:"HEADER",field:A.field}:{id:t[W].id,field:A.field});const z=m.current;if(z){const{cumulativeHeights:Y,pinnedTopHeight:V,columnMetrics:C}=g,{clientHeight:M,clientWidth:L,scrollTop:O,scrollLeft:H}=z,U=W<=0?0:Y[W-1],K=Y[W],oe=O+V,ie=O+M;let ne=O;if(U<oe?ne=Math.max(0,U-V):K>ie&&(ne=K-M),ne!==O&&(z.scrollTop=ne),C){const{leftPinnedWidth:T,rightPinnedWidth:le,unpinnedAccWidths:te,unpinnedCols:re,totalSpecialsWidth:q,pinnedSpecialsWidth:J}=C,de=re.findIndex(B=>B.field===A.field);if(de!==-1){const B=q+T+(de>0?te[de-1]:0),Q=q+T+te[de],Z=H+J+T,ge=H+L-le;let ce=H;B<Z?ce=Math.max(0,B-J-T):Q>ge&&(ce=Q-L+le),ce!==H&&(z.scrollLeft=ce)}}}}},[_,t,e,a,g,l,s,d,f,p,x,w,b,c,m]);return{focusedCell:_,setFocusedCell:E,handleFocus:v,handleBlur:S,handleKeyDown:N}}const ho={rowFields:[],columnFields:[],valueFields:[]};function po(n){const{initialState:t,sortModel:e,aggregationModel:o,onAggregationModelChange:l,columnVisibilityModel:s,onColumnVisibilityModelChange:d,pinnedColumns:a,onPinnedColumnsChange:f,pivotModel:p,onPivotModelChange:x,paginationModel:w,onPaginationModelChange:b,rowSelectionModel:c}=n,[g,m]=i.useState(()=>t?.sorting?.sortModel??[]),_=e!==void 0,E=_?e:g,v=o!==void 0,[S,N]=i.useState(()=>o??{}),h=v?o:S,y=i.useCallback(T=>{v||N(T),l?.(T)},[v,l]),u=s!==void 0,[j,P]=i.useState(()=>t?.columns?.columnVisibilityModel??{}),F=u?s:j,k=i.useCallback(T=>{u||P(T),d?.(T)},[u,d]),I=a!==void 0,[R,W]=i.useState(()=>t?.columns?.pinnedColumns??{}),$=I?a:R,D=i.useCallback(T=>{I||W(T),f?.(T)},[I,f]),[A,z]=i.useState(()=>p??ho),Y=p??A,V=i.useCallback(T=>{z(T),x?.(T)},[x]),C=w!==void 0,[M,L]=i.useState(()=>t?.pagination?.paginationModel??w??{page:0,pageSize:100}),O=C?w:M,H=i.useCallback(T=>{C||L(T),b?.(T)},[C,b]),U=c!==void 0,[K,oe]=i.useState([]),ie=U?c:K,ne=i.useMemo(()=>new Set(ie),[ie]);return{sortModel:E,isSortControlled:_,setInternalSortModel:m,aggregationModel:h,handleAggregationModelChange:y,columnVisibilityModel:F,handleColumnVisibilityModelChange:k,pinnedColumns:$,handlePinnedColumnsChange:D,currentPivotModel:Y,handlePivotModelChange:V,effectivePaginationModel:O,handlePaginationModelChange:H,rowSelectionModel:ie,selectedRowIds:ne,isSelectionControlled:U,setInternalRowSelectionModel:oe}}const xo={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 mo(n,t){const{field:e,operator:o,value:l}=t,s=n[e],d=xo[o];return d?d(s,l):(console.warn(`Unknown filter operator: ${o}`),!0)}function bo(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 Qt(n,t){const e=t.items??[],o=t.logicOperator??"and",l=("quickFilterValues"in t?t.quickFilterValues:void 0)??[];if(l.length>0&&!bo(n,l))return!1;if(e.length===0)return!0;const s=d=>{if("logicOperator"in d&&"items"in d){const a=d,f=a.items;return f.length===0?!0:a.logicOperator==="and"?f.every(s):f.some(s)}else return mo(n,d)};return o==="and"?e.every(s):e.some(s)}function wo(n,t){if(!t)return n;const{items:e=[],quickFilterValues:o=[]}=t;return e.length===0&&(!o||o.length===0)?n:n.filter(l=>Qt(l,t))}function vo(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 Zt(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 _o(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],f=Zt(d,a,s.sort);if(f!==0)return f}return 0}),e}function Co(n){const{effectiveRows:t,activeHierarchyHandlers:e,filterMode:o,filterModel:l,dataSource:s,sortModel:d,sortingMode:a,pagination:f,paginationMode:p,effectivePaginationModel:x,pinnedRows:w,isLoading:b,pageSize:c}=n,g=i.useMemo(()=>e?e.getVisibleRows()||[]:o==="server"&&s?t:wo(t,l),[t,l,e,o,s]),{top:m,center:_,bottom:E}=i.useMemo(()=>e?{top:[],center:g,bottom:[]}:uo(g,w),[g,w,e]),v=i.useMemo(()=>e||a==="server"&&s?_:_o(_,d),[_,d,e,a,s]),S=i.useMemo(()=>{if(!f||p==="server"&&s)return v;const h=x.page*x.pageSize;return v.slice(h,h+x.pageSize)},[v,f,x.page,x.pageSize,p,s]),N=i.useMemo(()=>{if(e)return _;const h=f?S:v,y=[...m,...h,...E];if(p==="infinite"&&b&&y.length>0){const u=Math.min(c,20),j=Array.from({length:u},(P,F)=>({id:`__skeleton_${F}__`,_isSkeleton:!0}));return[...y,...j]}return y},[m,S,v,E,f,e,_,p,b,c]);return{filteredRows:g,pinnedTopRows:m,unpinnedRows:_,pinnedBottomRows:E,sortedUnpinnedRows:v,paginatedUnpinnedRows:S,allRenderableRows:N}}function yo(n){const{layout:t,scrollTop:e,scrollLeft:o,viewportWidth:l,viewportHeight:s,autoHeight:d,rowReordering:a,hasDetailPanel:f,checkboxSelection:p,pinCheckboxColumn:x,pinExpandColumn:w,overscanRows:b=5}=n;return i.useMemo(()=>{const{unpinnedAccWidths:c,unpinnedColsWithWidth:g,leftPinnedCols:m,rightPinnedCols:_,totalWidth:E,leftWidth:v,rightWidth:S,unpinnedTotalWidth:N,systemColumnsWidth:h,cumulativeHeights:y,pinnedTopHeight:u,pinnedBottomHeight:j,unpinnedRowsHeight:P,rowHeights:F,unpinnedRowsLength:k}=t,I=l||1e3,R=d?u+P+j+50:s||600,W=6,$=Math.max(0,o-v),D=o+I-v;let A=0,z=g.length-1,Y=0,V=c.length-1;for(;Y<=V;){const te=Y+V>>>1;c[te]<$?Y=te+1:V=te-1}A=Math.max(0,Y-W);for(let te=A;te<c.length;te++){if((te===0?0:c[te-1])>D){z=Math.min(g.length-1,te+W);break}z=Math.min(g.length-1,te+W)}const C=A>0?c[A-1]:0,M=N-c[z],L=[...m,...C>0?[{field:"__spacer_left__",width:C,isSpacer:!0}]:[],...g.slice(A,z+1),...M>0?[{field:"__spacer_right__",width:M,isSpacer:!0}]:[],..._],H=I>0&&E>I?16:0,U=u+P+j+H+2;let K=0,oe=k-1,ie=0,ne=0,T=y.length-1;for(;ne<=T;){const te=ne+T>>>1;y[te]<e?ne=te+1:T=te-1}K=Math.max(0,ne-b),ie=K>0?y[K-1]:0;for(let te=K;te<y.length;te++)if(y[te]>=e+R){oe=Math.min(k-1,te+b);break}const le=(a?48:0)+(f&&w?48:0)+(p&&x?48:0);return{renderContext:{firstRowIndex:K,lastRowIndex:oe,firstColumnIndex:A,lastColumnIndex:z},offsetTop:ie,offsetLeft:0,totalHeight:U,pinnedTopHeight:u,pinnedBottomHeight:j,totalWidth:E,rowHeights:F,cumulativeHeights:y,virtualColumns:L,columnMetrics:{leftPinnedWidth:v,rightPinnedWidth:S,unpinnedAccWidths:c,unpinnedCols:g,totalSpecialsWidth:h,pinnedSpecialsWidth:le}}},[t,e,o,l,s,d,a,f,p,x,w,b])}function ko(n){const{columns:t,onColumnOrderChange:e,disableColumnReorder:o=!1}=n,[l,s]=i.useState(null),[d,a]=i.useState(null),f=i.useRef(-1),p=i.useCallback(c=>g=>{if(o)return;const m=t.findIndex(E=>E.field===c);if(t[m]?.pinnable===!1){g.preventDefault();return}s(c),f.current=m,g.dataTransfer&&(g.dataTransfer.effectAllowed="move",g.dataTransfer.setData("text/plain",c))},[t,o]),x=i.useCallback(c=>g=>{o||!l||(g.preventDefault(),g.dataTransfer.dropEffect="move",a(c))},[l,o]),w=i.useCallback(c=>g=>{if(g.preventDefault(),o||!l||l===c){s(null),a(null);return}const m=t.findIndex(v=>v.field===l),_=t.findIndex(v=>v.field===c);if(m===-1||_===-1){s(null),a(null);return}const E=t[m];e&&e({column:E,oldIndex:m,targetIndex:_}),s(null),a(null),f.current=-1},[t,l,o,e]),b=i.useCallback(()=>{s(null),a(null),f.current=-1},[]);return{draggedColumn:l,dragOverColumn:d,onDragStart:o?void 0:p,onDragOver:o?void 0:x,onDragEnd:o?void 0:b,onDrop:o?void 0:w}}function Sn({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 So(n){const{activeColumns:t,isHierarchyEnabled:e,isRowGrouping:o,isTreeData:l,activeHierarchyHandlers:s,columnVisibilityModel:d,columnOrder:a,onColumnOrderChange:f,disableColumnReorder:p,pivotMode:x,checkboxSelection:w,hasDetailPanel:b,rowReordering:c,initialState:g,setColumns:m}=n,_=i.useMemo(()=>e?t.map((k,I)=>I===0?{...k,renderCell:R=>{const W=R.rowMeta,$=W?.treeDepth??0,D=!!W?.hasChildren,A=!!W?.isExpanded,z=W?.groupingField,Y=W?.groupingValue,V=W?.descendantCount,C=!!W?.isGroupRow;let M=k.renderCell?k.renderCell(R):R.value;if(l&&D&&C&&(M=r.jsxs("div",{className:"ogx__group-cell-content",children:[R.value,V!==void 0&&V>0?` (${V})`:""]})),o&&D&&z){const L=W?.groupLabel??`${z}: ${String(Y)}`;M=r.jsxs("div",{className:"ogx__group-cell-content",children:[L,V!==void 0?` (${V})`:""]})}return r.jsxs("div",{style:{display:"flex",alignItems:"center",paddingLeft:$*24,width:"100%",height:"100%"},children:[r.jsx("div",{style:{marginRight:4,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",cursor:D?"pointer":"default",flexShrink:0},children:D?r.jsx("div",{onClick:L=>{L.stopPropagation(),L.preventDefault(),s?.toggleExpansion(R.row.id)},onMouseDown:L=>{L.stopPropagation()},style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:10,position:"relative"},children:r.jsx(Sn,{isExpanded:A,onClick:L=>{L.stopPropagation(),L.preventDefault(),s?.toggleExpansion(R.row.id)}})}):null}),r.jsx("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:M})]})}}:{...k,renderCell:R=>{const W=R.rowMeta,$=!!W?.hasChildren,D=W?.groupingField;return o&&$?k.field===D?null:R.value!==void 0&&R.value!==null?k.renderCell?k.renderCell(R):R.value:null:k.renderCell?k.renderCell(R):R.value}}):t,[t,e,o,l,s]),[E,v]=i.useState(()=>g?.columns?.columnWidths??{}),S=i.useCallback((k,I)=>{v(R=>({...R,[k]:I}))},[]),[N,h]=i.useState(()=>g?.columns?.columnOrder??t.map(k=>k.field)),y=a??N;i.useEffect(()=>{m(t)},[t,m]),i.useEffect(()=>{x&&h(t.map(k=>k.field))},[x,t]);const u=i.useMemo(()=>{if(p)return _;const k=new Map(y.map((I,R)=>[I,R]));return[..._].sort((I,R)=>{const W=k.get(I.field)??_.indexOf(I),$=k.get(R.field)??_.indexOf(R);return W-$})},[_,y,p]),j=i.useMemo(()=>u.filter(k=>d[k.field]!==!1),[u,d]),P=ko({columns:u,onColumnOrderChange:i.useCallback(k=>{const{oldIndex:I,targetIndex:R}=k,W=[...y],[$]=W.splice(I,1);W.splice(R,0,$),a||h(W),f?.(k)},[y,a,f]),disableColumnReorder:p}),F=i.useMemo(()=>{const k=[];return c&&k.push({field:"__reorder_col__"}),b&&k.push({field:"__expand_col__"}),w&&k.push({field:"__checkbox_col__"}),[...k,...u]},[u,w,b,c]);return{effectiveColumns:_,orderedColumns:u,visibleOrderedColumns:j,navigationColumns:F,columnWidths:E,effectiveColumnOrder:y,setInternalColumnOrder:h,columnReorderHandlers:P,handleColumnResize:S}}function jo(n){const{renderContext:t,pinnedTopRows:e,pinnedBottomRows:o,paginatedUnpinnedRows:l,sortedUnpinnedRows:s,pagination:d}=n;return i.useMemo(()=>{const{firstRowIndex:a,lastRowIndex:f}=t,p=d?l:s,x=e.length,w=e.map((v,S)=>({row:v,rowIndex:S})),b=o.map((v,S)=>({row:v,rowIndex:x+p.length+S})),c=Math.max(0,a-x),g=Math.min(p.length,f-x+1),m=p.slice(c,g).map((v,S)=>({row:v,rowIndex:x+c+S})),_=[...w,...m,...b],E=new Set;return _.filter(v=>E.has(v.row.id)?!1:(E.add(v.row.id),!0))},[t,e,o,l,s,d])}function Eo(n,t){let e;return n<.5?e=3:n<3?e=5:n<15?e=12:n<40?e=20:e=30,Math.max(e,t)}function No(n){const{onRowsScrollEnd:t,overscanRowCount:e=3}=n,o=i.useRef({scrollTop:0,scrollLeft:0,velocity:0}),l=i.useRef({scrollTop:0,scrollLeft:0,time:0}),s=i.useRef(null),d=i.useRef(null),[a,f]=i.useState({scrollTop:0,scrollLeft:0,overscanRows:e});i.useEffect(()=>()=>{s.current!==null&&cancelAnimationFrame(s.current),d.current!==null&&clearTimeout(d.current)},[]);const p=i.useCallback(x=>{const w=x.currentTarget,b=performance.now(),c=Math.abs(w.scrollTop-l.current.scrollTop)+Math.abs(w.scrollLeft-l.current.scrollLeft),g=b-l.current.time,m=g>0?c/g:0;if(l.current={scrollTop:w.scrollTop,scrollLeft:w.scrollLeft,time:b},o.current={scrollTop:w.scrollTop,scrollLeft:w.scrollLeft,velocity:m},s.current!==null&&cancelAnimationFrame(s.current),s.current=requestAnimationFrame(()=>{s.current=null;const{scrollTop:_,scrollLeft:E,velocity:v}=o.current;f({scrollTop:_,scrollLeft:E,overscanRows:Eo(v,e)})}),d.current!==null&&clearTimeout(d.current),d.current=setTimeout(()=>{d.current=null,f(_=>({..._,overscanRows:e}))},200),t){const{scrollTop:_,scrollHeight:E,clientHeight:v}=w;E-_-v<100&&t({visibleTop:_,visibleBottom:_+v,viewportHeight:v})}},[t,e]);return{scrollTop:a.scrollTop,scrollLeft:a.scrollLeft,overscanRows:a.overscanRows,handleScroll:p}}function Mo(n){const{onStateChange:t,sortModel:e,filterModel:o,effectivePaginationModel:l,columnWidths:s,effectiveColumnOrder:d,columnVisibilityModel:a,pinnedColumns:f}=n,p=i.useRef(t);i.useLayoutEffect(()=>{p.current=t}),i.useEffect(()=>{if(!p.current)return;const x={sorting:{sortModel:e},filter:{filterModel:o},pagination:{paginationModel:l},columns:{columnWidths:s,columnOrder:d,columnVisibilityModel:a,pinnedColumns:f}};p.current(x)},[e,o,l,s,d,a,f])}const Po={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 _e(n,t){return n==null?"—":typeof n=="number"?t==="avg"?n.toLocaleString(void 0,{maximumFractionDigits:2}):n.toLocaleString():String(n)}function jn(n){const{rows:t,columns:e,aggregationModel:o,isServerSide:l,dataSource:s,filterModel:d,sortModel:a,serverAggregationResults:f}=n,p=i.useMemo(()=>{const N=new Map;return(e??[]).forEach(h=>N.set(h.field,h)),N},[e]),x=i.useMemo(()=>{if(l||Object.keys(o).length===0)return{};const N={};for(const[h,y]of Object.entries(o)){const u=p.get(h);if(u?.availableAggregationFunctions&&!u.availableAggregationFunctions.includes(y))continue;const j=Po[y];if(!j){console.warn(`[useAggregation] Unknown aggregation function: "${y}"`);continue}const P=t.map(F=>F[h]);N[h]=j(P)}return N},[t,p,o,l]),[w,b]=i.useState({}),[c,g]=i.useState(!1),[m,_]=i.useState(null),E=i.useRef(0),v=i.useCallback(async()=>{if(!s?.getAggregations||Object.keys(o).length===0)return;const N=++E.current;g(!0),_(null);try{const h=await s.getAggregations({sortModel:a??[],filterModel:d??{items:[]},groupKeys:[],aggregationModel:o});N===E.current&&b(h)}catch(h){N===E.current&&(_(h),console.error("[useAggregation] Server aggregation error:",h))}finally{N===E.current&&g(!1)}},[s,o,d,a]);return i.useEffect(()=>{l&&s?.getAggregations&&!f&&v()},[v,l,s,f]),{aggregationResult:i.useMemo(()=>l?f&&Object.keys(f).length>0?f:w:x,[l,x,f,w]),isLoading:c,error:m}}function Io({columns:n,aggregationModel:t,aggregationResult:e,columnWidths:o,rowHeight:l,checkboxSelection:s,hasDetailPanel:d,rowReordering:a,pinnedColumns:f}){const p=i.useMemo(()=>Xt(n,o,f,s,!0,d,!0,a),[n,o,f,s,d,a]),x=f?.left?.[f.left.length-1],w=f?.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(b=>{const c=t[b.field],g=e[b.field],m=o[b.field]??(typeof b.width=="number"?b.width:120),_=xt(b.field,f),E=_?p[b.field]:void 0,v=["ogx__aggregation-cell",_==="left"&&"ogx__aggregation-cell--pinned-left",_==="right"&&"ogx__aggregation-cell--pinned-right",_==="left"&&b.field===x&&"ogx__aggregation-cell--pinned-left-last",_==="right"&&b.field===w&&"ogx__aggregation-cell--pinned-right-first"].filter(Boolean).join(" "),S={width:m,minWidth:m,maxWidth:m,textAlign:b.align||"left"};return _==="left"&&E!==void 0&&(S.left=E),_==="right"&&E!==void 0&&(S.right=E),r.jsx("div",{className:v,role:"gridcell",style:S,children:c?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"ogx__aggregation-label",children:c}),r.jsx("span",{className:"ogx__aggregation-value",children:_e(g,c)})]}):null},b.field)})]})}function To({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 Ro({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 mt=({indeterminate:n=!1,label:t,className:e="",inputRef:o,...l})=>{const s=i.useRef(null),d=i.useCallback(f=>{s.current=f,typeof o=="function"?o(f):o&&(o.current=f)},[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 Lo(n){const{field:t,currentWidth:e,onResize:o,minWidth:l=50,maxWidth:s=1e3}=n,[d,a]=i.useState(!1),f=i.useRef(0),p=i.useRef(0),x=i.useCallback(c=>{c.preventDefault(),c.stopPropagation(),a(!0),f.current=c.clientX,p.current=e;let g=0;const m=16,_=v=>{const S=v.clientX-f.current,N=Math.max(l,Math.min(s,p.current+S)),h=Date.now();h-g>=m&&(o(t,N),g=h)},E=v=>{a(!1);const S=v.clientX-f.current,N=Math.max(l,Math.min(s,p.current+S));o(t,N),document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",E)};document.addEventListener("mousemove",_),document.addEventListener("mouseup",E)},[t,e,o,l,s]),w=i.useCallback(c=>{c.preventDefault(),c.stopPropagation()},[]),b=["ogx-column-resize-handle",d&&"ogx-column-resize-handle--dragging"].filter(Boolean).join(" ");return r.jsx("div",{className:b,onMouseDown:x,onClick:c=>c.stopPropagation(),onDragStart:c=>{c.preventDefault(),c.stopPropagation()},onDoubleClick:w,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${t} column`,children:r.jsx("div",{className:"ogx-column-resize-handle__line"})})}function Xe(){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 Je(){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 Fo(){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 Oo(){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 Wo(){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 Ao(){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 $o(){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 zo(){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 Bo(){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 Ho(){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 Do({colDef:n,sortModel:t,onSort:e,onHide:o,onPin:l,pinnedColumns:s,onManageColumns:d,onClose:a,anchorEl:f}){const p=i.useRef(null),[x,w]=i.useState({position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"});i.useLayoutEffect(()=>{if(!f||!p.current)return;const h=f.getBoundingClientRect(),y=p.current.getBoundingClientRect(),u=window.innerWidth,j=window.innerHeight,P=8;let F=h.left;F+y.width+P>u&&(F=u-y.width-P),F<P&&(F=P);let k=h.bottom+4;k+y.height+P>j&&(k=h.top-y.height-4),w({position:"fixed",zIndex:1300,top:k,left:F,visibility:"visible"})},[f]),i.useEffect(()=>{function h(u){p.current&&!p.current.contains(u.target)&&f&&!f.contains(u.target)&&a()}function y(u){u.key==="Escape"&&a()}return document.addEventListener("mousedown",h),document.addEventListener("keydown",y),window.addEventListener("scroll",a,!0),window.addEventListener("resize",a),()=>{document.removeEventListener("mousedown",h),document.removeEventListener("keydown",y),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a)}},[f,a]);const b=h=>{e?.(n.field,h),a()},c=()=>{o?.(n.field),a()},g=h=>{l?.(n.field,h),a()},m=t?.find(h=>h.field===n.field)?.sort,_=m==null,E=s?.left?.includes(n.field)??!1,v=s?.right?.includes(n.field)??!1,S=!E&&!v,N=n.headerName||n.field;return Ge.createPortal(r.jsxs("div",{ref:p,className:"ogx-column-menu",style:x,role:"menu","aria-label":`Column options for ${N}`,children:[e&&n.sortable!==!1&&r.jsxs(r.Fragment,{children:[r.jsxs("button",{className:`ogx-menu-item${m==="asc"?" ogx-menu-item--active":""}`,onClick:()=>b("asc"),role:"menuitemradio","aria-checked":m==="asc",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:m==="asc"?r.jsx(Xe,{}):r.jsx(Je,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(Oo,{})}),"Sort Ascending"]}),r.jsxs("button",{className:`ogx-menu-item${m==="desc"?" ogx-menu-item--active":""}`,onClick:()=>b("desc"),role:"menuitemradio","aria-checked":m==="desc",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:m==="desc"?r.jsx(Xe,{}):r.jsx(Je,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(Wo,{})}),"Sort Descending"]}),r.jsxs("button",{className:`ogx-menu-item${_?" ogx-menu-item--active":""}`,onClick:()=>b(null),role:"menuitemradio","aria-checked":_,children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:_?r.jsx(Xe,{}):r.jsx(Je,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(Ao,{})}),"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${E?" ogx-menu-item--active":""}`,onClick:()=>g("left"),role:"menuitemradio","aria-checked":E,"aria-label":"Pin to left",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:E?r.jsx(Xe,{}):r.jsx(Je,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(zo,{})}),"Pin to Left"]}),r.jsxs("button",{className:`ogx-menu-item${v?" ogx-menu-item--active":""}`,onClick:()=>g("right"),role:"menuitemradio","aria-checked":v,"aria-label":"Pin to right",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:v?r.jsx(Xe,{}):r.jsx(Je,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(Bo,{})}),"Pin to Right"]}),r.jsxs("button",{className:`ogx-menu-item${S?" ogx-menu-item--active":""}`,onClick:()=>g(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(Xe,{}):r.jsx(Je,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(Ho,{})}),"Unpin"]}),r.jsx("div",{className:"ogx-menu-divider"}),r.jsxs("button",{className:"ogx-menu-item",onClick:c,role:"menuitem","aria-label":`Hide ${N} 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($o,{})}),"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(Fo,{})}),"Manage columns"]})]}),f?.closest(".ogx-theme-provider")||document.body)}function Go(){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 Vo(){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 En(n){const t=[];for(const e of n.children)typeof e=="string"?t.push(e):t.push(...En(e));return t}function Uo(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 Ko(n,t,e){function o(a,f,p){if(!En(a).includes(f))return null;if(p===e)return a;for(const x of a.children)if(typeof x!="string"){const w=o(x,f,p+1);if(w)return w}return null}const l=new Map;for(const a of t){let f=null;for(const p of n)if(f=o(p,a.field,0),f)break;l.set(a.field,f)}const s=[];let d=0;for(;d<t.length;){const a=t[d],f=l.get(a.field)??null,p=a.width;if(!f)s.push({key:`fg-${a.field}-${e}`,label:"",width:p,isGroup:!1}),d++;else{let x=0,w=d;for(;w<t.length&&l.get(t[w].field)===f;)x+=t[w].width,w++;s.push({key:`${f.groupId}-${e}`,label:f.headerName,width:x,isGroup:!0}),d=w}}return s}function Nn(n){const{columns:t,allColumns:e,columnGroupingModel:o,checkboxSelection:l=!1,allSelected:s=!1,someSelected:d=!1,onSelectAll:a,onSort:f,sortModel:p=[],onColumnResize:x,columnWidths:w={},pinnedColumns:b,hasDetailPanel:c=!1,pinCheckboxColumn:g=!0,pinExpandColumn:m=!0,rowReordering:_=!1,aggregationModel:E,draggedColumn:v,dragOverColumn:S,onDragStart:N,onDragOver:h,onDragEnd:y,onDrop:u,focusedCell:j,onHeaderClick:P,onSortAdd:F,multiSort:k=!1,onHideColumn:I,onPinColumn:R,onManageColumns:W}=n,$=i.useId(),D=i.useRef({}),[A,z]=i.useState(null),Y=T=>le=>{le.stopPropagation(),z({colDef:T,anchorEl:le.currentTarget})},V=()=>{z(null)};i.useLayoutEffect(()=>{if(j?.id==="HEADER"){const T=D.current[j.field];T&&T.focus()}},[j]);const C=T=>le=>{if(T.sortable===!1)return;const te=p.find(q=>q.field===T.field);let re="asc";te&&(te.sort==="asc"?re="desc":re=null),(le.shiftKey||k)&&F?F(T.field,re):f&&f(T.field,re)},M=T=>{const le=p.find(re=>re.field===T);if(!le)return null;const te=p.length>1?p.indexOf(le)+1:null;return r.jsx("span",{className:`ogx__sort-icon ogx__sort-icon--${le.sort}`,"aria-hidden":"true",children:te!==null&&r.jsx("span",{className:"ogx__sort-badge",children:te})})},L=i.useMemo(()=>Xt(t,w,b,l,g,c,m,_),[t,w,b,l,g,c,m,_]),O=o?Uo(o):0,U=(e??t).filter(T=>!T.isSpacer).map(T=>({field:T.field,width:w[T.field]??T.width??100})),ne=(_?48:0)+(c?48:0)+(l?48:0);return r.jsxs("div",{className:"ogx__header-wrap",children:[O>0&&Array.from({length:O},(T,le)=>{const te=Ko(o,U,le);return r.jsxs("div",{className:"ogx-col-group-row",role:"row",children:[ne>0&&r.jsx("div",{className:"ogx-col-group-cell ogx-col-group-cell--filler",style:{width:ne,minWidth:ne,flexShrink:0},role:"columnheader"}),te.map(re=>r.jsx("div",{role:"columnheader",className:`ogx-col-group-cell ${re.isGroup?"ogx-col-group-cell--group":"ogx-col-group-cell--filler"}`,style:{width:re.width,minWidth:re.width,flexShrink:0},title:re.isGroup?re.label:void 0,children:re.isGroup&&r.jsx("span",{className:"ogx-col-group-cell__label",children:re.label})},re.key))]},`ogx-grp-${le}`)}),r.jsxs("div",{className:"ogx__header",role:"row",children:[_&&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}}),c&&r.jsx("div",{className:`ogx__header-cell ogx__header-cell--expand ${m?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""}`,role:"columnheader","aria-label":"Expand row details",style:{minWidth:48,maxWidth:48,position:m?"sticky":void 0,left:m?_?48:0:void 0,zIndex:m?5:void 0}}),l&&r.jsx("div",{className:`ogx__header-cell ogx__header-cell--checkbox ${g?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""}`,role:"columnheader",style:{position:g?"sticky":void 0,left:g?(_?48:0)+(c&&m?48:0):void 0},children:r.jsx(mt,{id:$,name:$,checked:s,indeterminate:d,onChange:T=>a?.(T.target.checked),"aria-label":s?"Deselect all rows":"Select all rows",tabIndex:j?.id==="HEADER"&&j.field==="__checkbox_col__"?0:-1,onMouseDown:T=>T.preventDefault(),inputRef:T=>{D.current.__checkbox_col__=T}})}),t.map((T,le)=>{if(T.isSpacer)return r.jsx("div",{style:{width:T.width,minWidth:T.width,flexShrink:0},"aria-hidden":"true"},T.field);const te=T.sortable!==!1,re=p.some(ee=>ee.field===T.field),q=T.resizable!==!1,J=xt(T.field,b),de=J!==null,B=v===T.field,Q=S===T.field,Z=["ogx__header-cell",`ogx__header-cell--align-${T.headerAlign||T.align||"left"}`,te&&"ogx__header-cell--sortable",re&&"ogx__header-cell--sorted",de&&"ogx__header-cell--pinned",de&&`ogx__header-cell--pinned-${J}`,B&&"ogx__header-cell--dragging",Q&&"ogx__header-cell--drag-over",j?.id==="HEADER"&&j.field===T.field&&"ogx__header-cell--focused",T.headerClassName].filter(Boolean).join(" "),ge=w[T.field]??T.width??100,ce={width:ge,minWidth:T.minWidth,maxWidth:T.maxWidth,flexGrow:T.flex??0,flexShrink:0,flexBasis:(T.flex,"auto"),boxSizing:"border-box",position:de?"sticky":"relative",zIndex:T.zIndex,opacity:B?.5:1};if(de&&J){const ee=L[T.field];J==="left"?ce.left=ee:ce.right=ee}const Ee=T.renderHeader?T.renderHeader({field:T.field,colDef:T,colIndex:le}):T.headerName||T.field,Te=ee=>{if(ee.target.closest(".ogx-column-resize-handle")){ee.stopPropagation();return}P?.(T.field),te&&C(T)(ee)},Pe=N?N(T.field):void 0,Re=h?h(T.field):void 0,ze=u?u(T.field):void 0;return r.jsxs("div",{className:Z,style:ce,title:T.description,onClick:Te,role:"columnheader",draggable:!!N,onDragStart:Pe,onDragOver:Re,onDragEnd:y,onDrop:ze,"aria-sort":te?re?p.find(ee=>ee.field===T.field)?.sort==="asc"?"ascending":"descending":"none":void 0,"aria-colindex":le+1+(l?1:0),"data-field":T.field,tabIndex:-1,ref:ee=>{D.current[T.field]=ee},children:[r.jsxs("div",{className:"ogx__header-cell-content",children:[B&&r.jsx("div",{className:"ogx__header-drag-icon",children:r.jsx(Vo,{})}),r.jsxs("div",{className:"ogx__header-cell-title-wrapper",children:[r.jsx("span",{className:"ogx__header-cell-title",children:Ee}),E&&E[T.field]&&r.jsx("span",{className:"ogx__header-cell-aggregation",children:E[T.field]})]}),te&&M(T.field),!T.disableColumnMenu&&r.jsx("button",{className:"ogx__menu-icon-btn",onClick:Y(T),"aria-label":`Open column menu for ${T.headerName||T.field}`,"aria-haspopup":"menu",tabIndex:-1,children:r.jsx(Go,{})})]}),q&&x&&r.jsx(Lo,{field:T.field,currentWidth:ge,onResize:x,minWidth:T.minWidth,maxWidth:T.maxWidth})]},T.field)}),A&&r.jsx(Do,{colDef:A.colDef,sortModel:p,onSort:f,onHide:I,onPin:R,pinnedColumns:b,onManageColumns:W,onClose:V,anchorEl:A.anchorEl})]})]})}const bt=({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 Mn(n){const t=i.useId(),{page:e,pageSize:o,rowCount:l,onPageChange:s,onPageSizeChange:d,pageSizeOptions:a=[10,25,50,100],showFirstButton:f=!0,showLastButton:p=!0,localeText:x}=n,w=Math.max(1,Math.ceil(l/o)),b=Math.min(e,w-1),c=b*o,g=Math.min(c+o,l),m=l===0?0:`${c+1}–${g}`,_=x?.paginationRowsPerPage??"Rows per page:",E=x?.paginationOf?x.paginationOf(l===0?0:c+1,g,l):`${m} of ${l}`,v=x?.paginationPage?x.paginationPage(b+1,w):`Page ${b+1} of ${w}`,S=()=>{s(0)},N=()=>{s(Math.max(0,b-1))},h=()=>{s(Math.min(w-1,b+1))},y=()=>{s(w-1)},u=F=>{const k=parseInt(F.target.value,10);d(k)},j=b===0,P=b>=w-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:_}),r.jsx("select",{id:t,className:"ogx-pagination__select",value:o,onChange:u,"aria-label":"Rows per page",children:a.map(F=>r.jsx("option",{value:F,children:F},F))})]}),r.jsx("div",{className:"ogx-pagination__info","aria-live":"polite","aria-atomic":"true",children:E}),r.jsxs("div",{className:"ogx-pagination__actions",children:[f&&r.jsx(bt,{variant:"text",size:"small",onClick:S,disabled:j,"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(bt,{variant:"text",size:"small",onClick:N,disabled:j,"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:v}),r.jsx(bt,{variant:"text",size:"small",onClick:h,disabled:P,"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"})})}),p&&r.jsx(bt,{variant:"text",size:"small",onClick:y,disabled:P,"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 Yo(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 qo(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 Xo(n){const{rows:t,columns:e,rowHeight:o=52,headerHeight:l=56,columnVisibilityModel:s,initialState:d}=n,[a]=i.useState(()=>Yo(t,e,s)),[f,p]=i.useReducer(qo,{...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}}),x=i.useRef(f);i.useLayoutEffect(()=>{x.current=f});const w=i.useRef(t);i.useEffect(()=>{t!==w.current&&(w.current=t,p({type:"SET_ROWS",payload:t}))},[t]);const b=i.useCallback((u,j)=>{p({type:"SET_ROWS",payload:u,preserveRowCount:j})},[]),c=i.useCallback(u=>{p({type:"SET_COLUMNS",payload:u})},[]),g=i.useCallback(u=>{p({type:"SET_SORT_MODEL",payload:u})},[]),m=i.useCallback(u=>{p({type:"SET_FILTER_MODEL",payload:u})},[]),_=i.useCallback(u=>{p({type:"SET_PAGINATION_MODEL",payload:u})},[]),E=i.useCallback(u=>{p({type:"SET_SELECTION",payload:u})},[]),v=i.useCallback((u,j)=>{p({type:"SET_DIMENSIONS",payload:{viewportWidth:u,viewportHeight:j}})},[]),S=i.useCallback(u=>{p({type:"SET_DATASOURCE_LOADING",payload:u})},[]),N=i.useCallback(u=>{p({type:"SET_DATASOURCE_ERROR",payload:u})},[]),h=i.useCallback(u=>{p({type:"SET_ROW_COUNT",payload:u})},[]),y=i.useRef({getRow:u=>x.current.rows.idRowsLookup.get(u)||null,getAllRows:()=>Array.from(x.current.rows.idRowsLookup.values()),getVisibleRows:()=>Array.from(x.current.rows.idRowsLookup.values()),getAllFilteredRows:()=>Array.from(x.current.rows.idRowsLookup.values()),getGroupedExportRows:()=>null,getAggregationResult:()=>null,getAggregationModel:()=>null,getColumn:u=>x.current.columns.lookup.get(u)||null,getAllColumns:()=>x.current.columns.all,getVisibleColumns:()=>x.current.columns.all,selectRow:(u,j=!0)=>{const P=new Set(x.current.selection.selectedRows);j?P.add(u):P.delete(u),E(P)},selectRows:(u,j=!0)=>{const P=new Set(x.current.selection.selectedRows);u.forEach(F=>{j?P.add(F):P.delete(F)}),E(P)},getSelectedRows:()=>Array.from(x.current.selection.selectedRows),sortColumn:(u,j)=>{if(j===null)g(x.current.sorting.sortModel.filter(P=>P.field!==u));else{const P=x.current.sorting.sortModel.findIndex(F=>F.field===u);if(P>=0){const F=[...x.current.sorting.sortModel];F[P]={field:u,sort:j},g(F)}else g([...x.current.sorting.sortModel,{field:u,sort:j}])}},getSortModel:()=>x.current.sorting.sortModel,setFilterModel:m,getFilterModel:()=>x.current.filter.filterModel,setPage:u=>{_({...x.current.pagination.paginationModel,page:u})},setPageSize:u=>{_({...x.current.pagination.paginationModel,pageSize:u,page:0})},scrollToIndexes:()=>{},copySelectedRows:()=>Promise.resolve()});return{state:f,dispatch:p,apiRef:y,setRows:b,setColumns:c,setSortModel:g,setFilterModel:m,setPaginationModel:_,setSelection:E,setDimensions:v,setDataSourceLoading:S,setDataSourceError:N,setRowCount:h}}function Jo(n){const{onRowOrderChange:t,rows:e,getRowId:o,rowReordering:l=!1}=n,[s,d]=i.useState(null),[a,f]=i.useState(null),p=i.useCallback(g=>o?o(g):g.id,[o]),x=i.useCallback(g=>m=>{l&&(d(g),m.dataTransfer.effectAllowed="move")},[l]),w=i.useCallback(g=>m=>{!l||!s||(m.preventDefault(),m.dataTransfer.dropEffect="move",a!==g&&f(g))},[l,s,a]),b=i.useCallback(()=>{d(null),f(null)},[]),c=i.useCallback(g=>m=>{if(m.preventDefault(),!s||!t){b();return}const _=e.findIndex(v=>p(v)===s),E=e.findIndex(v=>p(v)===g);_!==-1&&E!==-1&&_!==E&&t({row:e[_],oldIndex:_,targetIndex:E}),b()},[s,t,e,p,b]);return{draggedRowId:s,dragOverRowId:a,onDragStart:l?x:void 0,onDragOver:l?w:void 0,onDragEnd:l?b:void 0,onDrop:l?c:void 0}}function Qo(n){const{rows:t,getRowId:e,getTreeDataPath:o,treeData:l=!1,defaultGroupingExpansionDepth:s=0,filterModel:d,sortModel:a,onRowExpansionChange:f}=n,{treeNodes:p,rootIds:x,groupingRows:w}=i.useMemo(()=>{if(!l||!o)return{treeNodes:new Map,rootIds:[],groupingRows:[]};const h=new Map,y=[],u=[],j=new Map,P=F=>F.join("/");return t.forEach(F=>{const k=e(F),I=o(F),R=P(I);j.set(R,k),h.set(k,{id:k,parentId:null,depth:I.length-1,groupingKey:I[I.length-1],isExpanded:!1,children:[],serverChildrenCount:F.serverChildrenCount})}),t.forEach(F=>{const k=e(F),I=o(F);if(I.length===1){y.push(k);return}const R=$=>{if($.length<=1)return;const D=$.slice(0,-1),A=P(D);let z=j.get(A);if(z===void 0&&(z=`auto-group-${A}`,!h.has(z))){const Y=D[D.length-1];h.set(z,{id:z,parentId:null,depth:D.length-1,groupingKey:Y,isExpanded:!1,children:[],label:Y}),j.set(A,z);const V={id:z,name:Y,_isGroupRow:!0};u.push(V),D.length===1&&y.push(z),R(D)}return z},W=R(I);if(W!==void 0){const $=h.get(W),D=h.get(k);$&&D&&(D.parentId=W,$.children=$.children||[],$.children.includes(k)||$.children.push(k))}}),u.forEach(F=>{const k=F.id,I=h.get(k);if(!I)return;const W=k.replace("auto-group-","").split("/");if(W.length>1){const $=W.slice(0,-1),D=P($),A=j.get(D);if(A&&h.has(A)){I.parentId=A;const z=h.get(A);z&&(z.children=z.children||[],z.children.includes(k)||z.children.push(k))}}}),{treeNodes:h,rootIds:y,groupingRows:u}},[t,o,l,e]),b=i.useMemo(()=>{if(!l)return new Set;const h=new Set;return p.forEach(y=>{y.children&&y.children.length>0&&(s===-1||y.depth<s)&&h.add(y.id)}),h},[p,l,s]),[c,g]=i.useState(new Set);i.useEffect(()=>{b.size>0&&g(b)},[b]);const m=i.useCallback(h=>{g(y=>{const u=new Set(y),j=!u.has(h);if(u.has(h)?u.delete(h):u.add(h),j&&f){const P=p.get(h);P&&f(P)}return u})},[p,f]),_=i.useCallback(()=>{if(!l)return null;const h=new Map;t.forEach(R=>h.set(e(R),R)),w.forEach(R=>h.set(R.id,R));const y=R=>Qt(R,d),u=new Map,j=R=>{if(u.has(R))return u.get(R);const W=h.get(R);if(!W)return!1;if(y(W))return u.set(R,!0),!0;const D=p.get(R);return D&&D.children&&D.children.some(z=>j(z))?(u.set(R,!0),!0):(u.set(R,!1),!1)},P=(R,W)=>{if(!a||a.length===0)return 0;const $=h.get(R),D=h.get(W);if(!$||!D)return 0;for(const A of a){const z=$[A.field],Y=D[A.field],V=Zt(z,Y,A.sort);if(V!==0)return V}return 0},F=[],k=new Set,I=R=>{const W=R.filter($=>j($));W.sort(P),W.forEach($=>{if(k.has($))return;const D=h.get($),A=p.get($);if(D&&A){k.add($);const z={...D,_treeDepth:A.depth,_isExpanded:c.has($),_hasChildren:!!(A.children&&A.children.length>0||A.serverChildrenCount&&A.serverChildrenCount>0),_descendantCount:A.children?A.children.length:0};F.push(z),c.has($)&&A.children&&A.children.length>0&&I(A.children)}})};return I(x),F},[l,t,w,x,p,c,d,a,e]),E=i.useCallback(h=>c.has(h),[c]),v=i.useCallback(h=>p.get(h),[p]),S=i.useCallback(h=>{const y=[];let u=h;for(;u!==null;){const j=p.get(u);if(!j)break;y.unshift(j.groupingKey),u=j.parentId}return y},[p]),N=i.useMemo(()=>{const h=new Map,y=new Set(w.map(u=>u.id));return p.forEach((u,j)=>{h.set(j,{hasChildren:!!(u.children&&u.children.length>0||u.serverChildrenCount&&u.serverChildrenCount>0),treeDepth:u.depth,descendantCount:u.children?u.children.length:void 0,isGroupRow:y.has(j),isExpanded:c.has(j)})}),h},[p,w,c]);return i.useMemo(()=>({treeNodes:p,groupingRows:w,toggleExpansion:m,isGroupExpanded:E,getVisibleRows:_,getNode:v,getNodePath:S,rowMetaMap:N}),[p,w,m,E,_,v,S,N])}const Zo=n=>n?.depth===-1?"footer":"inline",er=[],tr={};function nr(n){const{rows:t,getRowId:e,columns:o,rowGroupingModel:l=er,aggregationModel:s=tr,defaultGroupingExpansionDepth:d=0,filterModel:a,sortModel:f,getAggregationPosition:p=Zo}=n,x=i.useMemo(()=>{const h=new Map;return(o??[]).forEach(y=>h.set(y.field,y)),h},[o]),[w,b]=i.useState(new Set),{treeNodes:c,rootIds:g,groupingRows:m}=i.useMemo(()=>{const h=new Map,y=new Map,u=[];if(l.length===0)return{treeNodes:h,rootIds:u,groupingRows:y};const j=(k,I,R)=>`auto-group-${k}-${I}-${R||"root"}`,P=(k,I,R)=>{if(I>=l.length)return k.map(z=>{const Y=e(z);return h.set(Y,{id:Y,parentId:R,depth:I,groupingKey:"",isExpanded:!1}),Y});const W=l[I],$=x.get(W);if($&&$.groupable===!1)return P(k,I+1,R);const D=new Map;k.forEach(z=>{const Y=z[W],V=String(Y);D.has(V)||D.set(V,[]),D.get(V).push(z)});const A=[];return D.forEach((z,Y)=>{const C=z[0][W],M=j(W,Y,R);A.push(M);const L={};s&&Object.entries(s).forEach(([oe,ie])=>{const ne=z.map(T=>T[oe]);if(ie==="sum")L[oe]=ne.reduce((T,le)=>T+(Number(le)||0),0);else if(ie==="min")L[oe]=Math.min(...ne.map(T=>Number(T)||0));else if(ie==="max")L[oe]=Math.max(...ne.map(T=>Number(T)||0));else if(ie==="avg"){const T=ne.reduce((le,te)=>le+(Number(te)||0),0);L[oe]=ne.length?T/ne.length:0}else ie==="count"&&(L[oe]=ne.length)});const O={[W]:C,...L,id:M};y.set(M,O);const H={id:M,parentId:R,depth:I,groupingKey:Y,groupingField:W,groupingValue:C,aggregatedValues:L,isExpanded:!1,children:[],label:$?.groupingValueFormatter?$.groupingValueFormatter({field:W,value:C}):`${W}: ${String(C)}`};H.aggregationPosition=p(H),h.set(M,H);const U=P(z,I+1,M);h.get(M).children=U;const K=z.length;h.get(M).descendantCount=K}),A},F=P(t,0,null);return u.push(...F),{treeNodes:h,rootIds:u,groupingRows:y}},[t,l,s,e,p,x]);i.useEffect(()=>{if(d===-1){const h=new Set;c.forEach((y,u)=>{y.children&&y.children.length>0&&h.add(u)}),b(h)}else if(d>0){const h=new Set;c.forEach((y,u)=>{y.depth<d&&y.children&&y.children.length>0&&h.add(u)}),b(h)}else b(new Set)},[l,d,c]);const _=i.useCallback(h=>{b(y=>{const u=new Set(y);return u.has(h)?u.delete(h):u.add(h),u})},[]),E=i.useCallback(h=>w.has(h),[w]),v=i.useCallback(()=>{if(l.length===0)return null;const h=[],y=new Set,u=new Map;t.forEach(k=>u.set(e(k),k));const j=k=>{const I=c.get(k);if(!I)return!1;if(!I.children||I.children.length===0){const R=u.get(k);return!(!R||a&&!Qt(R,a))}return I.children.some(R=>j(R))},P=k=>{let I=k;a&&(I=k.filter(j)),f&&f.length>0&&I.sort((R,W)=>{const $=m.get(R)||u.get(R),D=m.get(W)||u.get(W);if(!$||!D)return 0;for(const A of f){const z=$[A.field],Y=D[A.field],V=Zt(z,Y,A.sort);if(V!==0)return V}return 0}),I.forEach(R=>{if(y.has(R))return;const W=c.get(R),$=W?.children&&W.children.length>0,D=$?m.get(R):u.get(R);if(D&&W){y.add(R);const A={...D,_treeDepth:W.depth,_isExpanded:w.has(R),_hasChildren:$,_groupingField:W.groupingField,_groupingValue:W.groupingValue,_descendantCount:W.descendantCount};h.push(A),F.has(R)&&$&&P(W.children)}})},F=w;return P(g),h},[t,e,c,g,m,a,f,w,l]),S=i.useCallback(h=>c.get(h),[c]),N=i.useMemo(()=>{const h=new Map;return c.forEach((y,u)=>{const j=!!(y.children&&y.children.length>0);h.set(u,{hasChildren:j,treeDepth:y.depth,groupingField:y.groupingField,groupingValue:y.groupingValue,groupLabel:y.label,descendantCount:y.descendantCount,isGroupRow:j,isExpanded:j?w.has(u):void 0})}),h},[c,w]);return i.useMemo(()=>({treeNodes:c,groupingRows:m,toggleExpansion:_,isGroupExpanded:E,getVisibleRows:v,getNode:S,rowMetaMap:N}),[c,m,_,E,v,S,N])}function or(n){const{rows:t,getRowId:e,processRowUpdate:o,onProcessRowUpdateError:l,onRowChange:s}=n,[d,a]=i.useState(null),f=i.useRef(null),p=i.useCallback(c=>{a(c),f.current=typeof c=="function"?c(f.current):c},[]),x=i.useCallback(c=>{p({id:c.id,field:c.field,value:c.value,originalValue:c.value})},[p]),w=i.useCallback(async c=>{const g=f.current;if(!g)return;if(c?.cancel){p(null);return}const{id:m,field:_,value:E,originalValue:v}=g;if(E===v){p(null);return}const S=t.find(h=>e(h)===m);if(!S){p(null);return}const N={...S,[_]:E};try{if(o){const h=await o(N,S);s?.(h)}else s?.(N);p(null)}catch(h){l?.(h)}},[p,t,e,o,s,l]),b=i.useCallback(c=>{d&&d.id===c.id&&d.field===c.field&&p(g=>g?{...g,value:c.value}:null)},[d,p]);return{editingCell:d,startCellEdit:x,stopCellEdit:w,setEditCellValue:b}}function rr(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)},[]),f=i.useCallback((m,_)=>o.get(m)?.[_],[o]),p=i.useCallback((m,_,E,v,S)=>{const N=new Map(o);for(let h=v;h<S;h++){const y=t[h];if(!y)continue;let u=1;if(y.colSpan)if(typeof y.colSpan=="function"){const P={row:_,value:_[y.field],field:y.field,colDef:y,rowIndex:E,colIndex:h};u=y.colSpan(P)}else u=y.colSpan;if(u<=1){Qe(N,m,y.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:e[y.field]||100}});continue}let j=e[y.field]||100;for(let P=1;P<u;P++)if(h+P<S){const F=t[h+P];F&&(j+=e[F.field]||100,Qe(N,m,F.field,{spannedByColSpan:!0,leftVisibleCellIndex:h,rightVisibleCellIndex:Math.min(h+u-1,t.length-1)}))}Qe(N,m,y.field,{spannedByColSpan:!1,cellProps:{colSpan:u,width:j}}),h+=u-1}l(N)},[o,t,e]),x=i.useCallback((m,_)=>{const E={},v={},S={};t.forEach((N,h)=>{if(N.rowSpan)for(let y=m;y<_;y++){const u=n[y];if(!u||v[u.id]?.[N.field])continue;const j=N.valueGetter?N.valueGetter({row:u,field:N.field,value:u[N.field]}):u[N.field];let P=1;if(typeof N.rowSpan=="function"){const F={row:u,value:j,field:N.field,colDef:N,rowIndex:y,colIndex:h};P=N.rowSpan(F)}else typeof N.rowSpan=="number"&&(P=N.rowSpan);if(P>1){E[u.id]||(E[u.id]={}),E[u.id][N.field]=P;for(let F=1;F<P;F++){const k=y+F;if(k<_&&n[k]){const I=n[k];v[I.id]||(v[I.id]={}),v[I.id][N.field]=!0,S[k]||(S[k]={}),S[k][N.field]=y}}}}}),d({caches:{spannedCells:E,hiddenCells:v,hiddenCellOriginMap:S},processedRange:{firstRowIndex:m,lastRowIndex:_}})},[n,t]),w=i.useCallback(()=>{d({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}})},[]);i.useEffect(()=>{const m=new Map;n.forEach((S,N)=>{for(let h=0;h<t.length;h++){const y=t[h];if(!y)continue;let u=1;if(y.colSpan)if(typeof y.colSpan=="function"){const P={row:S,value:S[y.field],field:y.field,colDef:y,rowIndex:N,colIndex:h};u=y.colSpan(P)}else u=y.colSpan;if(u<=1){const P=e[y.field]||(typeof y.width=="number"?y.width:100);Qe(m,S.id,y.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:P}});continue}let j=e[y.field]||(typeof y.width=="number"?y.width:100);for(let P=1;P<u;P++)if(h+P<t.length){const F=t[h+P];if(F){const k=e[F.field]||(typeof F.width=="number"?F.width:100);j+=k,Qe(m,S.id,F.field,{spannedByColSpan:!0,leftVisibleCellIndex:h,rightVisibleCellIndex:Math.min(h+u-1,t.length-1)})}}Qe(m,S.id,y.field,{spannedByColSpan:!1,cellProps:{colSpan:u,width:j}}),h+=u-1}}),l(m);const _={},E={},v={};t.forEach((S,N)=>{if(S.rowSpan)for(let h=0;h<n.length;h++){const y=n[h];if(!y||E[y.id]?.[S.field])continue;const u=S.valueGetter?S.valueGetter({row:y,field:S.field,value:y[S.field]}):y[S.field];let j=1;if(typeof S.rowSpan=="function"){const P={row:y,value:u,field:S.field,colDef:S,rowIndex:h,colIndex:N};j=S.rowSpan(P)}else typeof S.rowSpan=="number"&&(j=S.rowSpan);if(j>1){_[y.id]||(_[y.id]={}),_[y.id][S.field]=j;for(let P=1;P<j;P++){const F=h+P;if(F<n.length&&n[F]){const k=n[F];E[k.id]||(E[k.id]={}),E[k.id][S.field]=!0,v[F]||(v[F]={}),v[F][S.field]=h}}}}}),d({caches:{spannedCells:_,hiddenCells:E,hiddenCellOriginMap:v},processedRange:{firstRowIndex:0,lastRowIndex:n.length}})},[n,t,e]);const b=i.useCallback(()=>s.caches.spannedCells,[s]),c=i.useCallback(()=>s.caches.hiddenCells,[s]),g=i.useCallback(()=>s.caches.hiddenCellOriginMap,[s]);return{colspanMap:o,resetColSpan:a,getCellColSpanInfo:f,calculateColSpan:p,rowSpanningState:s,calculateRowSpan:x,resetRowSpan:w,getSpannedCells:b,getHiddenCells:c,getHiddenCellOriginMap:g}}function Qe(n,t,e,o){let l=n.get(t);l||(l={},n.set(t,l)),l[e]=o}function ir(n){const{dataSource:t,sortModel:e,filterModel:o,paginationModel:l,paginationMode:s,sortingMode:d,filterMode:a,aggregationModel:f,setRows:p,setRowCount:x,setDataSourceLoading:w,setDataSourceError:b,onAggregationResults:c}=n,g=i.useRef(null),m=i.useRef(0),_=i.useCallback(async()=>{if(!t)return;const v=++m.current;w(!0),b(null);const S=l.page*l.pageSize,N=S+l.pageSize,h={startRow:S,endRow:N,sortModel:e,filterModel:o,groupKeys:[],aggregationModel:f};try{const y=await t.getRows(h);if(v!==m.current)return;let u=!1;if(s==="infinite"){const j=g.current;if(j){const P=JSON.stringify(j.sortModel)!==JSON.stringify(e),F=JSON.stringify(j.filterModel)!==JSON.stringify(o),k=j.pageSize!==l.pageSize;!P&&!F&&!k&&l.page>j.page&&(u=!0)}}p(u?j=>[...j,...y.rows]:y.rows,!0),y.aggregationResults&&c&&c(y.aggregationResults),y.rowCount!==void 0&&x(y.rowCount),g.current={sortModel:e,filterModel:o,page:l.page,pageSize:l.pageSize}}catch(y){v===m.current&&(b(y),console.error("Data Source Error:",y))}finally{v===m.current&&w(!1)}},[t,l.page,l.pageSize,e,o,s,f,c,p,x,w,b]);i.useEffect(()=>{if(t&&(s==="server"||s==="infinite"||d==="server"||a==="server")){const S=setTimeout(()=>{_()},300);return()=>clearTimeout(S)}},[_,t,s,d,a]);const E=i.useCallback(async(v,S)=>{if(t){w(!0);try{const N=await t.getRows({startRow:0,endRow:-1,sortModel:e,filterModel:o,groupKeys:S});N.rows.length>0&&p(h=>{const y=new Set(h.map(j=>j.id)),u=N.rows.filter(j=>!y.has(j.id));return[...h,...u]})}catch(N){b(N),console.error("Failed to fetch children:",N)}finally{w(!1)}}},[t,e,o,p,w,b]);return{fetchRows:_,fetchChildren:E}}const Pn="\0",wt="";function lr(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 Lt(n,t){return t.map(e=>String(n[e]??"")).join(Pn)}function en(n,t,e,o){return o?`${n}${wt}${t}${wt}${e}`:`${t}${wt}${e}`}function In(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 f=d.length>0,p=new Map(t.map(v=>[v.field,v])),x=new Set;for(const v of n)x.add(Lt(v,d));const w=Array.from(x).sort(),b=new Map;for(const v of n){const S=Lt(v,s);if(!b.has(S)){const u={};for(const j of s)u[j]=v[j];b.set(S,{labelValues:u,bucket:new Map})}const N=b.get(S),h=Lt(v,d);N.bucket.has(h)||N.bucket.set(h,new Map);const y=N.bucket.get(h);for(const u of a){const j=v[u.field];y.has(u.field)||y.set(u.field,[]),j!=null&&!isNaN(Number(j))&&y.get(u.field).push(Number(j))}}let c=0;const g=[];for(const[,v]of b){const S={id:c++,...v.labelValues};for(const N of w){const h=v.bucket.get(N);for(const y of a){const u=en(N,y.field,y.aggFn,f),j=h?.get(y.field)??[];S[u]=j.length>0?lr(j,y.aggFn):null}}g.push(S)}const m=new Map;for(const v of n){const S=Lt(v,d);for(const N of a){if(N.aggFn!=="avg"&&N.aggFn!=="min"&&N.aggFn!=="max")continue;const h=`${S}${wt}${N.field}`;m.has(h)||m.set(h,[]);const y=v[N.field];y!=null&&!isNaN(Number(y))&&m.get(h).push(Number(y))}}const _={id:"__pivot_grand_total__"};for(let v=0;v<s.length;v++)_[s[v]]=v===0?"Grand Total":"";for(const v of w)for(const S of a){const N=en(v,S.field,S.aggFn,f),h=g.map(u=>u[N]).filter(u=>u!=null&&!isNaN(Number(u))).map(Number);if(h.length===0){_[N]=null;continue}const y=`${v}${wt}${S.field}`;switch(S.aggFn){case"sum":case"count":_[N]=h.reduce((u,j)=>u+j,0);break;case"avg":{const u=m.get(y)??[];_[N]=u.length>0?u.reduce((j,P)=>j+P,0)/u.length:null;break}case"min":_[N]=Math.min(...m.get(y)??h);break;case"max":_[N]=Math.max(...m.get(y)??h);break}}g.push(_);const E=[];for(const v of s){const S=p.get(v);E.push({field:v,headerName:S?.headerName??v,width:S?.width??140,sortable:!0})}for(const v of w){const S=f?v.split(Pn).map((N,h)=>{const y=p.get(d[h]);return y?.headerName?`${y.headerName}: ${N}`:N}).join(" / "):"";for(const N of a){const h=p.get(N.field),y=en(v,N.field,N.aggFn,f),u=N.headerName??h?.headerName??N.field,j=S?`${S} — ${u} (${N.aggFn})`:`${u} (${N.aggFn})`;E.push({field:y,headerName:j,width:140,type:"number",align:"right",headerAlign:"right",sortable:!0,valueFormatter:({value:P})=>{if(P==null)return"—";const F=Number(P);return N.aggFn==="avg"?F.toFixed(2):N.aggFn==="count"?F.toLocaleString():h?.valueFormatter?h.valueFormatter({value:P,row:{},field:N.field}):F.toLocaleString()}})}}return{pivotRows:g,pivotColumns:E,colKeys:w,isValid:!0}},[n,t,e,o])}function sr(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 ar(n){let t=!1;try{t=sr(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 dr(n){const{selectedRowIds:t,columns:e,getVisibleRows:o,getRowId:l}=n,s=i.useCallback(async()=>{if(t.size===0)return;const a=o().filter(b=>t.has(l(b)));if(a.length===0)return;const f=e.filter(b=>!b.field.startsWith("__")),p=f.map(b=>b.headerName||b.field).join(" "),x=a.map(b=>f.map(c=>{const g=b[c.field];return c.valueFormatter?c.valueFormatter({value:g,row:b,field:c.field}):g??""}).join(" ")).join(`
|
|
7
|
-
`),w=`${
|
|
8
|
-
${x}`;try{await ar(w)}catch(b){console.error("[OpenGridX] Failed to copy to clipboard:",b)}},[t,e,o,l]);return i.useEffect(()=>{const d=a=>{if(!(a.ctrlKey||a.metaKey)||a.key!=="c")return;const f=document.activeElement,p=f?.tagName.toLowerCase(),x=f?.type;p==="input"&&x!=="checkbox"&&x!=="radio"||p==="textarea"||p==="select"||f?.isContentEditable||s()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[s]),{copySelectedRows:s}}function cr({row:n,rowIndex:t,listViewColumn:e,isSelected:o=!1,checkboxSelection:l=!1,rowHeight:s,onRowClick:d,onSelectionChange:a}){const f={row:n,value:void 0,field:e.field,colDef:{field:e.field},rowIndex:t,colIndex:0},p=x=>{x.stopPropagation(),a?.(n.id,x.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:x=>x.stopPropagation(),children:r.jsx("input",{type:"checkbox",checked:o,onChange:p,"aria-label":`Select row ${n.id}`})}),r.jsx("div",{className:"ogx-list-view__cell",role:"gridcell",children:e.renderCell(f)})]})}function ur({ariaLabel:n,allRenderableRows:t,filteredRows:e,pagination:o,effectivePaginationModel:l,pageSizeOptions:s,selectedRowIds:d,listViewColumn:a,noRowsLabel:f,rowHeight:p,checkboxSelection:x,paginationMode:w,dataSource:b,serverRowCount:c,paginationSlot:g,paginationSlotProps:m,localeText:_,onRowClick:E,onSelectionChange:v,onPaginationModelChange:S}){const N=g||Mn,h=w==="server"&&b?c||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"})]}),f]}):t.map((y,u)=>r.jsx(cr,{row:y,rowIndex:u,listViewColumn:a,isSelected:d.has(y.id),checkboxSelection:x,rowHeight:p,onRowClick:j=>E({row:j,id:j.id,rowIndex:u}),onSelectionChange:v},y.id))}),o&&r.jsx(N,{page:l.page,pageSize:l.pageSize,rowCount:h,pageSizeOptions:s,onPageChange:y=>S({...l,page:y}),onPageSizeChange:y=>S({...l,pageSize:y,page:0}),localeText:_,...m})]})}function fr({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 gr({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 f=a.target.value===""?"":Number(a.target.value);s(f),t(f===""?null:f)},onBlur:e,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),e()),a.key==="Escape"&&(a.stopPropagation(),o())}})}function hr({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 pr({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 f=typeof a=="object"?a.value:a,p=typeof a=="object"?a.label:String(a);return r.jsx("option",{value:String(f),children:p},String(f))})})}function xr({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 mr(n){const{colDef:t}=n;switch(t.type){case"number":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(gr,{...n})});case"boolean":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(hr,{...n})});case"singleSelect":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(pr,{...n})});case"date":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(xr,{...n})});default:return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(fr,{...n})})}}function br({renderFn:n}){return r.jsx(r.Fragment,{children:n()})}class wr 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}}componentDidCatch(t,e){process.env.NODE_ENV!=="production"&&console.warn(`[CellErrorBoundary] field="${this.props.field}"`,t,e.componentStack)}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:"⚠"}):r.jsx(br,{renderFn:this.props.renderFn})}}function vr(n){const{onCellClick:t,onCellEditStart:e,onCellValueChange:o,value:l,row:s,colDef:d,rowIndex:a,colIndex:f,isSelected:p,onClick:x,width:w,pinnedPosition:b,pinnedOffset:c,isFocused:g,isFocusVisible:m,isEditable:_,isEditing:E,onEditStart:v,onEditStop:S,onValueChange:N,colSpanInfo:h,rowSpan:y,isHiddenByRowSpan:u,rowMeta:j}=n,P=i.useCallback(C=>{o?o(d.field,C):N?.(C)},[o,N,d.field]),F=i.useMemo(()=>d.valueFormatter?d.valueFormatter({value:l,row:s,field:d.field}):l==null?"":String(l),[l,s,d]),k=i.useMemo(()=>d.cellClassName?typeof d.cellClassName=="function"?d.cellClassName({value:l,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:f})||"":d.cellClassName:"",[d,l,s,a,f]),I=i.useRef(null);if(i.useLayoutEffect(()=>{g&&I.current&&I.current.focus({preventScroll:!0})},[g]),h?.spannedByColSpan)return null;if(u)return r.jsx("div",{className:"ogx__cell ogx__cell--hidden",style:{width:w??d.width??100},role:"presentation","data-field":d.field,"data-colindex":f});const R=C=>{t&&t({row:s,field:d.field,value:l,colDef:d,rowIndex:a,colIndex:f}),x?.(C)},W=C=>{_&&(v||e)&&(C.stopPropagation(),e?e(d.field,l):v?.())},$=b!=null,D=["ogx__cell",`ogx__cell--align-${d.align||"left"}`,p&&"ogx__cell--selected",g&&"ogx__cell--focused",g&&m&&"ogx__cell--focus-visible",d.type&&`ogx__cell--type-${d.type}`,$&&"ogx__cell--pinned",$&&`ogx__cell--pinned-${b}`,E&&"ogx__cell--editing",y&&y>1&&"ogx__cell--spanned",k].filter(Boolean).join(" "),A=h?.cellProps?.colSpan||1,z=y||1,Y=h?.cellProps?.width??w??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:$?"sticky":void 0,zIndex:d.zIndex??($?3:void 0),padding:E?0:void 0};return z>1&&(V.height=`calc(var(--height) * ${z} - var(--border-width, 1px))`,V.zIndex=10,$&&(V.zIndex=40)),$&&c!==void 0&&(b==="left"?V.left=c:V.right=c),r.jsx("div",{ref:I,className:D,style:V,onClick:R,onDoubleClick:W,role:"gridcell","aria-colindex":f+1,"aria-readonly":!_||void 0,tabIndex:-1,"data-field":d.field,"data-colindex":f,...A>1?{"aria-colspan":A}:{},...z>1?{"aria-rowspan":z}:{},children:r.jsx("div",{className:"ogx__cell-content",children:E&&(o||N)&&S?d.renderEditCell?d.renderEditCell({value:l,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:f,rowMeta:j}):r.jsx(mr,{value:l,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:f,onValueChange:P,onCommit:()=>S(),onCancel:()=>S(!0)}):d.renderCell?r.jsx(wr,{field:d.field,resetKey:s,renderFn:()=>d.renderCell({value:l,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:f,rowMeta:j})}):F})})}const Tn=i.memo(vr),_r=({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 Cr(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 Ft(n){const{row:t,columns:e,rowIndex:o,isSelected:l=!1,checkboxSelection:s=!1,onRowClick:d,onCellClick:a,onSelectionChange:f,columnWidths:p={},pinnedColumns:x,pinnedRows:w,hasDetailPanel:b=!1,isDetailPanelExpanded:c=!1,onDetailPanelToggle:g,detailPanelContent:m,detailPanelHeight:_=200,pinCheckboxColumn:E=!0,pinExpandColumn:v=!0,rowReordering:S=!1,onDragStart:N,onDragOver:h,onDragEnd:y,onDrop:u,isDragging:j,isDragOver:P,editingCell:F,onEditStart:k,onEditStop:I,onEditCellValueChange:R,focusedCellField:W,isFocusVisible:$,colspanMap:D,rowSpanningCaches:A,rowHeight:z=52,rowMeta:Y}=n,V=i.useId(),C=i.useRef(null),M=i.useRef(null);i.useLayoutEffect(()=>{W==="__expand_col__"&&C.current&&C.current.focus({preventScroll:!0}),W==="__checkbox_col__"&&M.current&&M.current.focus({preventScroll:!0})},[W]);const L=i.useMemo(()=>Xt(e,p,x,s,E,b,v,S),[e,p,x,s,E,b,v,S]),O=Y?.hasChildren===!0,H=i.useCallback((q,J)=>{O||k?.({id:t.id,field:q,value:J})},[O,t.id,k]),U=i.useCallback((q,J)=>{R?.({id:t.id,field:q,value:J})},[R,t.id]),K=i.useCallback(q=>{I?.({cancel:q})},[I]);if(t._isSkeleton){const q=Math.max(e.length,5);return r.jsx("div",{className:"ogx__row ogx__row--skeleton",role:"row","aria-hidden":"true",style:{height:z,minHeight:z},children:Array.from({length:q}).map((J,de)=>r.jsx("div",{className:"ogx__skeleton-cell",children:r.jsx("div",{className:"ogx__skeleton-bar"})},de))})}const oe=q=>{q.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell")||d?.({row:t,id:t.id,rowIndex:o})},ie=q=>{q.stopPropagation(),f?.(t.id,q.target.checked)},ne=q=>{q.stopPropagation(),g?.(t.id)},T=Jt(t.id,w),le=T==="top",te=T==="bottom",re=["ogx__row",l&&"ogx__row--selected",o%2===0&&"ogx__row--even",o%2===1&&"ogx__row--odd",le&&"ogx__row--pinned-top",te&&"ogx__row--pinned-bottom",j&&"ogx__row--dragging",P&&"ogx__row--drag-over",O&&"ogx__row--group"].filter(Boolean).join(" ");return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:re,onClick:oe,role:"row","aria-rowindex":o+1,"aria-selected":l,"data-rowindex":o,onDragOver:h?h(t.id):void 0,onDrop:u?u(t.id):void 0,style:{maxHeight:`${z}px`,minHeight:`${z}px`,"--height":`${z}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:N?N(t.id):void 0,onDragEnd:y,onClick:q=>q.stopPropagation(),children:r.jsx(_r,{})}),b&&r.jsx("div",{className:`ogx__cell ogx__cell--expand ${v?"ogx__cell--pinned-left":""} ${W==="__expand_col__"?"ogx__cell--focused":""} ${W==="__expand_col__"&&$?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":c?"Collapse row details":"Expand row details","aria-expanded":c,style:{position:v?"sticky":void 0,left:v?S?48:0:void 0,zIndex:v?5:void 0},ref:C,tabIndex:-1,onClick:q=>{q.stopPropagation(),a?.({row:t,field:"__expand_col__",value:c,colDef:{field:"__expand_col__",width:48},rowIndex:o,colIndex:-1})},children:r.jsx(Sn,{isExpanded:c,onClick:ne,variant:"plus-minus"})}),s&&r.jsx("div",{className:`ogx__cell ogx__cell--checkbox ${E?"ogx__cell--pinned-left":""} ${W==="__checkbox_col__"?"ogx__cell--focused":""} ${W==="__checkbox_col__"&&$?"ogx__cell--focus-visible":""}`,role:"gridcell",style:{position:E?"sticky":void 0,left:E?(S?48:0)+(b&&v?48:0):void 0,zIndex:E?11:void 0},ref:M,tabIndex:-1,onClick:q=>{q.stopPropagation(),a?.({row:t,field:"__checkbox_col__",value:l,colDef:{field:"__checkbox_col__",width:48},rowIndex:o,colIndex:-1})},children:r.jsx(mt,{id:V,name:`ogx-select-row-${t.id}`,checked:l,onChange:ie,onClick:q=>q.stopPropagation(),"aria-label":l?`Deselect row ${t.id}`:`Select row ${t.id}`,tabIndex:-1,onMouseDown:q=>q.preventDefault()})}),e.map((q,J)=>{if(q.isSpacer)return r.jsx("div",{style:{width:q.width,minWidth:q.width,flexShrink:0},"aria-hidden":"true"},q.field);const de=q.valueGetter?q.valueGetter({row:t,field:q.field,value:t[q.field]}):t[q.field],B=p[q.field]??q.width,Q=xt(q.field,x),Z=Q?L[q.field]:void 0,ge=F?.id===t.id&&F?.field===q.field,ce=ge?F?.value:de,Ee=D?.get(t.id)?.[q.field],Te=A?.spannedCells[t.id]?.[q.field],Pe=A?.hiddenCells[t.id]?.[q.field]||!1;return r.jsx(Tn,{value:ce,row:t,colDef:q,rowIndex:o,colIndex:J,isSelected:l,onCellClick:a,width:B,pinnedPosition:Q,pinnedOffset:Z,isFocused:W===q.field,isFocusVisible:$,isEditable:q.editable,isEditing:ge,onCellEditStart:H,onEditStop:K,onCellValueChange:U,colSpanInfo:Ee,rowSpan:Te,isHiddenByRowSpan:Pe,rowMeta:Y},q.field)})]}),b&&r.jsx(Cr,{row:t,rowId:t.id,rowIndex:o,content:m,height:_,isExpanded:c})]})}function Rn({rows:n,position:t,columns:e,selectedRowIds:o,checkboxSelection:l,onRowClick:s,onCellClick:d,onSelectionChange:a,columnWidths:f,pinnedColumns:p,pinnedRows:x,hasDetailPanel:w,expandedRowIds:b,getDetailPanelContent:c,getDetailPanelHeight:g,onDetailPanelToggle:m,pinCheckboxColumn:_,pinExpandColumn:E,focusedCell:v,colspanMap:S,rowSpanningCaches:N,rowHeight:h,rowMetaMap:y}){return n.length===0?null:r.jsx("div",{className:`ogx__pinned-rows ogx__pinned-rows--${t}`,role:"rowgroup",children:n.map((u,j)=>r.jsx(Ft,{row:u,columns:e,rowIndex:j,isSelected:o.has(u.id),checkboxSelection:l,onRowClick:s,onCellClick:d,onSelectionChange:a,columnWidths:f,pinnedColumns:p,pinnedRows:x,hasDetailPanel:w,isDetailPanelExpanded:b.has(u.id),detailPanelContent:c?c({row:u,id:u.id,rowIndex:j}):null,detailPanelHeight:g?.({row:u,id:u.id,rowIndex:j})||200,onDetailPanelToggle:m,pinCheckboxColumn:_,pinExpandColumn:E,focusedCellField:v?.id===u.id?v.field:null,colspanMap:S,rowSpanningCaches:N,rowHeight:h,rowMeta:y.get(u.id)},u.id))})}const yr=({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,f=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:f,height:16,borderRadius:4}})},s.field||d)})]});function kr({virtualContainerHeight:n,offsetTop:t,effectiveLoading:e,visibleRows:o,baseColumns:l,virtualColumns:s,viewportWidth:d,checkboxSelection:a,hasDetailPanel:f,rowReordering:p,rowHeight:x,pinnedRows:w,selectedRowIds:b,onRowClick:c,onCellClick:g,onSelectionChange:m,columnWidths:_,pinnedColumns:E,expandedRowIds:v,getDetailPanelContent:S,getDetailPanelHeight:N,onDetailPanelToggle:h,pinCheckboxColumn:y,pinExpandColumn:u,rowReorderHandlers:j,editingHandlers:P,focusedCell:F,colspanMap:k,rowSpanningCaches:I,paginationMode:R,dataSourceLoading:W,sortedUnpinnedRowCount:$,infiniteScrollSkeletonCount:D,unpinnedRowsLength:A,rowMetaMap:z}){const Y=l.length>0?l:(()=>{const C=(d||1e3)-(a?48:0)-(f?48:0)-(p?48:0),M=150,L=Math.max(1,Math.ceil(C/M));return Array.from({length:L},(O,H)=>({field:`placeholder_${H}`,headerName:"",width:M}))})(),V=o.filter(({row:C})=>!Jt(C.id,w)).filter((C,M,L)=>M===L.findIndex(O=>O.row.id===C.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((C,M)=>r.jsx(yr,{columns:Y,rowHeight:x,checkboxSelection:a,hasDetailPanel:f,rowReordering:p},`skeleton-${M}`)):V.map(({row:C,rowIndex:M})=>r.jsx(Ft,{row:C,columns:s,rowIndex:M,isSelected:b.has(C.id),checkboxSelection:a,onRowClick:c,onCellClick:g,onSelectionChange:m,columnWidths:_,pinnedColumns:E,pinnedRows:w,hasDetailPanel:f,isDetailPanelExpanded:v.has(C.id),detailPanelContent:S?S({row:C,id:C.id,rowIndex:M}):null,detailPanelHeight:N?.({row:C,id:C.id,rowIndex:M})||200,onDetailPanelToggle:h,pinCheckboxColumn:y,pinExpandColumn:u,rowReordering:p,onDragStart:j.onDragStart,onDragOver:j.onDragOver,onDragEnd:j.onDragEnd,onDrop:j.onDrop,isDragging:j.draggedRowId===C.id,isDragOver:j.dragOverRowId===C.id,editingCell:P.editingCell,onEditStart:P.startCellEdit,onEditStop:P.stopCellEdit,onEditCellValueChange:P.setEditCellValue,focusedCellField:F!=null&&F.id===C.id?F.field:null,colspanMap:k,rowSpanningCaches:I,rowHeight:x,rowMeta:z.get(C.id)},C.id)),R==="infinite"&&W&&$>0&&r.jsx("div",{className:"ogx__skeleton-group",children:Array.from({length:D}).map((C,M)=>r.jsx(Ft,{row:{id:`__skeleton_${M}__`,_isSkeleton:!0},columns:s,rowIndex:A+M,rowHeight:x},`__skeleton_${M}__`))})]})})}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 jr(){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 Ln(n){const{columns:t,visibleColumns:e,onVisibilityChange:o,onShowAll:l,onHideAll:s,onColumnReorder:d,onColumnOrderReset:a,showNonHideableColumns:f}=n,[p,x]=i.useState(""),[w,b]=i.useState(null),c=i.useRef(null),g=i.useMemo(()=>t.filter(u=>u.hideable!==!1),[t]),m=g.every(u=>e.has(u.field)),_=i.useMemo(()=>{const u=f?t:g;if(!p)return u;const j=p.toLowerCase();return u.filter(P=>(P.headerName||P.field).toLowerCase().includes(j))},[t,g,p,f]),E=u=>{u.target.checked?l():s()},v=u=>j=>{c.current=u,j.dataTransfer.effectAllowed="move",j.dataTransfer.setDragImage(j.currentTarget.closest(".ogx-column-visibility-panel__item"),20,20)},S=u=>j=>{j.preventDefault(),j.dataTransfer.dropEffect="move",u!==c.current&&b(u)},N=()=>{b(null)},h=u=>j=>{j.preventDefault();const P=c.current;b(null),c.current=null,P&&P!==u&&d&&d(P,u)},y=()=>{b(null),c.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",{autoComplete:"off",className:"ogx-column-visibility-panel__search-input",placeholder:"Search",value:p,onChange:u=>x(u.target.value)})]})}),r.jsx("div",{className:"ogx-column-visibility-panel__list",children:_.map(u=>{const j=e.has(u.field),P=u.hideable!==!1,F=w===u.field,k=!!d&&!p;return r.jsxs("div",{className:["ogx-column-visibility-panel__item",!P&&"ogx-column-visibility-panel__item--disabled",F&&"ogx-column-visibility-panel__item--drag-over"].filter(Boolean).join(" "),draggable:k,onDragOver:k?S(u.field):void 0,onDragLeave:k?N:void 0,onDrop:k?h(u.field):void 0,onDragEnd:k?y:void 0,children:[k&&r.jsx("span",{className:"ogx-column-visibility-panel__drag-handle-wrapper",draggable:!0,onDragStart:v(u.field),title:"Drag to reorder",children:r.jsx(jr,{})}),r.jsxs("label",{className:"ogx-column-visibility-panel__item-label",style:{display:"flex",alignItems:"center",gap:"var(--ogx-spacing-md)",flex:1,cursor:P?"pointer":"not-allowed"},children:[r.jsx(mt,{checked:j,onChange:I=>o(u.field,I.target.checked),disabled:!P}),r.jsx("span",{className:"ogx-column-visibility-panel__label",children:u.headerName||u.field})]})]},u.field)})}),r.jsxs("div",{className:"ogx-column-visibility-panel__footer",children:[r.jsxs("label",{className:"ogx-column-visibility-panel__item",children:[r.jsx(mt,{checked:m,onChange:E}),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 Er({isOpen:n,containerRef:t,panelRef:e,effectiveColumns:o,columnVisibilityModel:l,effectiveColumnOrder:s,columnOrder:d,disableColumnReorder:a,onClose:f,onColumnVisibilityChange:p,onColumnOrderChange:x,setInternalColumnOrder:w}){const[b,c]=i.useState(16),[g,m]=i.useState(16),[_,E]=i.useState(()=>document.body);if(i.useLayoutEffect(()=>{if(!n||!t.current)return;const S=t.current.getBoundingClientRect();c(S.top+8),m(window.innerWidth-S.right+8),E(t.current.closest(".ogx-theme-provider")||document.body)},[n,t]),!n)return null;const v=a?void 0:(S,N)=>{const h=[...s],y=h.indexOf(S),u=h.indexOf(N);if(y===-1||u===-1)return;const j=[...h];j.splice(y,1),j.splice(u,0,S),d||w(j),x?.({oldIndex:y,targetIndex:u,column:o.find(P=>P.field===S)})};return Ge.createPortal(r.jsxs("div",{ref:e,style:{position:"fixed",top:b,right:g,zIndex:9999,display:"inline-block"},children:[r.jsx("button",{onClick:f,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(Ln,{columns:o,visibleColumns:new Set(o.filter(S=>l[S.field]!==!1).map(S=>S.field)),onVisibilityChange:(S,N)=>{p({...l,[S]:N})},onShowAll:()=>{const S={...l};o.forEach(N=>{N.hideable!==!1&&(S[N.field]=!0)}),p(S)},onHideAll:()=>{const S={...l};o.forEach(N=>{N.hideable!==!1&&(S[N.field]=!1)}),p(S)},onColumnReorder:v})]}),_)}const Nr=new Map;function Mr(n){const{rows:t,columns:e,getRowId:o,rowHeight:l=52,headerHeight:s=56,autoHeight:d=!1,density:a,checkboxSelection:f=!1,disableRowSelectionOnClick:p=!1,disableMultipleRowSelection:x=!1,rowSelectionModel:w,onRowSelectionModelChange:b,onRowClick:c,onCellClick:g,filterModel:m,onFilterModelChange:_,sortModel:E,onSortModelChange:v,pagination:S=!1,paginationModel:N,onPaginationModelChange:h,pageSizeOptions:y=[10,25,50,100],pinnedColumns:u,onPinnedColumnsChange:j,pinnedRows:P,getDetailPanelContent:F,getDetailPanelHeight:k,detailPanelExpandedRowIds:I,onDetailPanelExpandedRowIdsChange:R,pinCheckboxColumn:W=!0,pinExpandColumn:$=!0,disableColumnReorder:D=!1,columnOrder:A,onColumnOrderChange:z,height:Y,rowReordering:V=!1,onRowOrderChange:C,loading:M=!1,treeData:L=!1,getTreeDataPath:O,defaultGroupingExpansionDepth:H,groupingColDef:U,rowGroupingModel:K,aggregationModel:oe,onAggregationModelChange:ie,getAggregationPosition:ne,isCellEditable:T,processRowUpdate:le,onProcessRowUpdateError:te,dataSource:re,multiSort:q=!1,sortingMode:J="client",filterMode:de="client",paginationMode:B="client",rowCount:Q,slots:Z,slotProps:ge,pivotMode:ce=!1,pivotModel:Ee,onPivotModelChange:Te,className:Pe="",style:Re,onRowsScrollEnd:ze,ariaLabel:ee,initialState:ye,onStateChange:wi,columnVisibilityModel:vi,onColumnVisibilityModelChange:_i,listView:Ot=!1,listViewColumn:Gn,columnGroupingModel:Ve,noRowsLabel:Ci="No Data",localeText:Le,apiRef:nn,overscanRowCount:yi=3}=n,on=Le?.noRowsLabel??Ci,ki=i.useMemo(()=>({items:[]}),[]),Ne=m||ki,Si=i.useMemo(()=>[],[]),rn=K||Si,Vn=i.useRef(Z?.toolbar);Vn.current=Z?.toolbar;const ji=i.useRef(G=>{const X=Vn.current;return X?X(G):null}).current,Ei=po({initialState:ye,sortModel:E,aggregationModel:oe,onAggregationModelChange:ie,columnVisibilityModel:vi,onColumnVisibilityModelChange:_i,pinnedColumns:u,onPinnedColumnsChange:j,pivotModel:Ee,onPivotModelChange:Te,paginationModel:N,onPaginationModelChange:h,rowSelectionModel:w}),{sortModel:Ie,isSortControlled:Wt,setInternalSortModel:At,aggregationModel:Me,handleAggregationModelChange:Un,columnVisibilityModel:Ue,handleColumnVisibilityModelChange:$t,pinnedColumns:Ze,handlePinnedColumnsChange:ln,currentPivotModel:sn,handlePivotModelChange:Kn,effectivePaginationModel:ke,handlePaginationModelChange:an,selectedRowIds:ve,isSelectionControlled:et,setInternalRowSelectionModel:tt}=Ei,nt=b,zt=In(t,e,sn,ce),Be=a==="compact"?32:a==="comfortable"?72:l,Yn=ce&&zt.isValid?zt.pivotRows:t,dn=ce&&zt.isValid?zt.pivotColumns:e,Bt=!!(K&&K.length>0),Ke=i.useMemo(()=>U&&Bt&&!ce?{...Ze,left:["__group__",...(Ze?.left??[]).filter(G=>G!=="__group__")]}:Ze,[U,Bt,ce,Ze]),_t=i.useMemo(()=>U&&Bt&&!ce?[{headerName:"Group",width:220,...U,field:"__group__",hideable:!1,sortable:!1,pinnable:!1,exportable:!1},...dn]:dn,[U,Bt,ce,dn]),[Ni,qn]=i.useState(null);i.useEffect(()=>{qn(null)},[Me]);const ot=i.useRef(null),Mi=i.useRef(null),Ht=i.useRef(null),Pi=i.useCallback(G=>G.id,[]),rt=o||Pi,cn=i.useMemo(()=>Yn.map(G=>{const X=rt(G);return X===G.id?G:{...G,id:X}}),[Yn,rt]),it=i.useCallback(G=>{vn.current?.classList.toggle("ogx--kb",G)},[]),Xn=i.useRef(re);Xn.current=re;const Jn=i.useRef(null),Qn=i.useRef(null),Ii=i.useCallback(G=>{if(Xn.current&&L&&(G.serverChildrenCount??0)>0&&(G.children??[]).length===0){const X=Qn.current?.getNodePath(G.id)||[G.groupingKey];Jn.current?.(G.id,X)}},[L]),Ce=Xo({rows:cn,columns:_t,rowHeight:Be,headerHeight:s,rowCount:Q,columnVisibilityModel:Ue,initialState:n.initialState}),{state:pe,apiRef:lt,setRows:un,setColumns:Ti,setDimensions:Zn,setDataSourceLoading:Ri,setDataSourceError:Li,setRowCount:Fi}=Ce,{scrollTop:Oi,scrollLeft:Wi,overscanRows:Ai,handleScroll:$i}=No({onRowsScrollEnd:ze,overscanRowCount:yi});i.useEffect(()=>{nn&&(nn.current=lt.current)},[nn,lt]);const{copySelectedRows:eo}=dr({selectedRowIds:ve,columns:_t,getVisibleRows:()=>lt.current.getVisibleRows(),getRowId:rt});i.useEffect(()=>{lt.current.copySelectedRows=eo,lt.current.getSelectedRows=()=>Array.from(ve)},[eo,ve,lt]);const zi=pe.dataSource.loading,Ct=M||zi,st=i.useMemo(()=>pe.rows.allRows.map(G=>pe.rows.idRowsLookup.get(G)),[pe.rows]),yt=Qo({rows:st,getRowId:rt,getTreeDataPath:O,treeData:L,defaultGroupingExpansionDepth:H,filterModel:Ne,sortModel:Ie,onRowExpansionChange:Ii});i.useEffect(()=>{Qn.current=yt},[yt]);const kt=nr({rows:st,getRowId:rt,columns:_t,rowGroupingModel:rn,aggregationModel:Me,defaultGroupingExpansionDepth:H,filterModel:Ne,sortModel:Ie,getAggregationPosition:ne}),at=or({rows:st,getRowId:rt,processRowUpdate:le,onProcessRowUpdateError:te,onRowChange:G=>{const{dispatch:X}=Ce,ue=Array.from(Ce.state.rows.idRowsLookup.values()).map(fe=>fe.id===G.id?G:fe);X({type:"SET_ROWS",payload:ue})}}),St=L,He=!!(rn&&rn.length>0),fn=St||He,Dt=St?yt:He?kt:null,jt=i.useMemo(()=>St?yt.rowMetaMap:He?kt.rowMetaMap:Nr,[St,yt.rowMetaMap,He,kt.rowMetaMap]),Fe=S&&!He,Gt=i.useCallback(G=>{const{row:X,id:se}=G;if(fn&&jt.get(X.id)?.hasChildren){Dt?.toggleExpansion(se);return}if(c?.(G),!p){let ue;if(x)ue=ve.has(se)?[]:[se];else{const fe=new Set(ve);fe.has(se)?fe.delete(se):fe.add(se),ue=Array.from(fe)}et||tt(ue),nt?.(ue)}},[fn,Dt,c,jt,p,x,ve,et,tt,nt]),gn=ir({dataSource:re,sortModel:Ie,filterModel:Ne,paginationModel:ke,paginationMode:B,sortingMode:J,filterMode:de,aggregationModel:Me,setRows:un,setRowCount:Fi,setDataSourceLoading:Ri,setDataSourceError:Li,onAggregationResults:qn});i.useEffect(()=>{gn.fetchChildren&&(Jn.current=gn.fetchChildren)},[gn.fetchChildren]),i.useEffect(()=>{re||un(cn)},[cn,un,re]);const Oe=!!F,[Bi,Hi]=i.useState(new Set),dt=I??Bi,Vt=i.useCallback(G=>{const X=new Set(dt);X.has(G)?X.delete(G):X.add(G),I===void 0&&Hi(X),R?.(X)},[dt,I,R]),{effectiveColumns:De,orderedColumns:hn,visibleOrderedColumns:Di,navigationColumns:to,columnWidths:We,effectiveColumnOrder:Ut,setInternalColumnOrder:Kt,columnReorderHandlers:ct,handleColumnResize:Gi}=So({activeColumns:_t,isHierarchyEnabled:fn,isRowGrouping:He,isTreeData:St,activeHierarchyHandlers:Dt,columnVisibilityModel:Ue,columnOrder:A,onColumnOrderChange:z,disableColumnReorder:D,pivotMode:ce,checkboxSelection:f,hasDetailPanel:Oe,rowReordering:V,initialState:ye,setColumns:Ti});Mo({onStateChange:wi,sortModel:Ie,filterModel:Ne,effectivePaginationModel:ke,columnWidths:We,effectiveColumnOrder:Ut,columnVisibilityModel:Ue,pinnedColumns:Ke});const ut=Co({effectiveRows:st,activeHierarchyHandlers:Dt,filterMode:de,filterModel:Ne,dataSource:re,sortModel:Ie,sortingMode:J,pagination:Fe,paginationMode:B,effectivePaginationModel:ke,pinnedRows:P,isLoading:pe.dataSource.loading,pageSize:ke.pageSize}),Ye=ut.filteredRows,pn=ut.pinnedTopRows,xn=ut.pinnedBottomRows,Ae=ut.sortedUnpinnedRows,Et=ut.paginatedUnpinnedRows,mn=ut.allRenderableRows;i.useEffect(()=>{Ce.apiRef.current.getVisibleRows=()=>Fe?Et:Ae,Ce.apiRef.current.getAllFilteredRows=()=>Ae,Ce.apiRef.current.getVisibleColumns=()=>De},[Ae,Et,Fe,De,Ce.apiRef]);const Vi=Jo({rows:Fe?Et:Ae,getRowId:G=>G.id,onRowOrderChange:C,rowReordering:V}),ft=rr(mn,to,We),{aggregationResult:Nt}=jn({rows:Ye,columns:_t,aggregationModel:Me,isServerSide:!!(re&&(B==="server"||J==="server")),dataSource:re,filterModel:Ne,sortModel:Ie,serverAggregationResults:Ni}),gt=Object.keys(Me).length>0;i.useEffect(()=>{Ce.apiRef.current.getAggregationResult=()=>gt?Nt:null,Ce.apiRef.current.getAggregationModel=()=>gt?Me:null,Ce.apiRef.current.getGroupedExportRows=()=>{if(!He)return null;const{treeNodes:G,groupingRows:X}=kt,se=new Map;Ae.forEach(he=>se.set(he.id,he));const ue=[],fe=he=>{he.forEach(me=>{const be=G.get(me);if(!be)return;if(!!(be.children&&be.children.length>0))ue.push({type:"group-header",depth:be.depth,groupField:be.groupingField,groupValue:be.groupingValue}),fe(be.children),gt&&be.aggregatedValues&&ue.push({type:"group-subtotal",depth:be.depth,groupField:be.groupingField,groupValue:be.groupingValue,aggregatedValues:be.aggregatedValues});else{const Tt=se.get(me)??X.get(me);Tt&&ue.push({type:"leaf",depth:be.depth,row:Tt})}})};return fe(Array.from(G.keys()).filter(he=>G.get(he)?.parentId===null)),gt&&Nt&&ue.push({type:"grand-total",depth:0,aggregatedValues:Nt}),ue}},[Nt,Me,gt,Ce.apiRef,He,kt,Ae]);const xe=fo({rowHeight:Be,pagination:Fe,paginatedUnpinnedRows:Et,sortedUnpinnedRows:Ae,expandedRowIds:dt,getDetailPanelHeight:k,pinnedTopRowsLength:pn.length,pinnedBottomRowsLength:xn.length,visibleOrderedColumns:Di,pinnedColumns:Ke,columnWidths:We,viewportWidth:pe.dimensions.viewportWidth||1e3,checkboxSelection:f,hasDetailPanel:Oe,rowReordering:V,paginationMode:B,isLoading:pe.dataSource.loading,pageSize:ke.pageSize}),Ui=i.useMemo(()=>{const G={};for(const X of[...xe.leftPinnedCols,...xe.unpinnedColsWithWidth,...xe.rightPinnedCols])X.isSpacer||(G[X.field]=X.width);return{...G,...We}},[xe.leftPinnedCols,xe.unpinnedColsWithWidth,xe.rightPinnedCols,We]);i.useEffect(()=>{Ce.apiRef.current.scrollToIndexes=({rowIndex:G,colIndex:X})=>{const se=ot.current;if(se){if(G!==void 0&&G>=0){const ue=G>0?xe.cumulativeHeights[G-1]:0,fe=xe.cumulativeHeights[G]??ue,{scrollTop:he,clientHeight:me}=se;ue<he?se.scrollTop=ue:fe>he+me&&(se.scrollTop=fe-me)}if(X!==void 0&&X>=0){const fe=[...xe.leftPinnedCols,...xe.unpinnedColsWithWidth,...xe.rightPinnedCols][X];if(!fe)return;const he=xe.unpinnedColsWithWidth.findIndex(nl=>nl.field===fe.field);if(he===-1)return;const me=he>0?xe.unpinnedAccWidths[he-1]:0,be=xe.unpinnedAccWidths[he]??me,It=xe.leftWidth+be,{scrollLeft:Tt,clientWidth:io}=se;me<Tt?se.scrollLeft=me:It>Tt+io&&(se.scrollLeft=It-io)}}}},[xe,ot,Ce.apiRef]);const Se=yo({layout:xe,scrollTop:Oi,scrollLeft:Wi,viewportWidth:pe.dimensions.viewportWidth,viewportHeight:pe.dimensions.viewportHeight,autoHeight:d,rowReordering:V,hasDetailPanel:Oe,checkboxSelection:f,pinCheckboxColumn:W,pinExpandColumn:$,overscanRows:Ai});i.useEffect(()=>{if(!ot.current)return;const G=new ResizeObserver(X=>{for(const se of X){const{width:ue,height:fe}=se.contentRect;Zn(ue,fe)}});return G.observe(ot.current),()=>{G.disconnect()}},[Zn]);const Mt=i.useCallback((G,X)=>{const se=new Set(ve);X?se.add(G):se.delete(G);const ue=Array.from(se);et||tt(ue),nt?.(ue)},[ve,et,nt,tt]),Ki=i.useCallback(G=>{let X=[];G&&(X=st.map(se=>se.id)),et||tt(X),nt?.(X)},[st,et,nt,tt]),no=i.useCallback((G,X)=>{const se=X?[{field:G,sort:X}]:[];Wt||At(se),v?.(se)},[Wt,v,At]),Yi=i.useCallback((G,X)=>{const se=Ie.filter(fe=>fe.field!==G),ue=X?[...se,{field:G,sort:X}]:se;Wt||At(ue),v?.(ue)},[Ie,Wt,v,At]),{focusedCell:Yt,setFocusedCell:bn,handleFocus:qi,handleBlur:Xi,handleKeyDown:Ji}=go({allRenderableRows:mn,navigationColumns:to,checkboxSelection:f,selectedRowIds:ve,handleSelectionChange:Mt,handleDetailPanelToggle:Vt,editingHandlers:at,setKeyboardMode:it,sortModel:Ie,handleSort:no,isCellEditable:T,pagination:Fe,pageSize:ke.pageSize,virtualization:Se,viewportRef:ot}),wn=i.useCallback(G=>{it(!1),bn({id:G.row.id,field:G.field}),Ht.current?.focus({preventScroll:!0}),g?.(G)},[g,it,bn]),oo=i.useRef(at.editingCell);i.useEffect(()=>{const G=!!oo.current,X=!!at.editingCell;G&&!X&&Ht.current?.focus({preventScroll:!0}),oo.current=at.editingCell},[at.editingCell]);const Qi=jo({renderContext:Se.renderContext,pinnedTopRows:pn,pinnedBottomRows:xn,paginatedUnpinnedRows:Et,sortedUnpinnedRows:Ae,pagination:Fe}),Zi=t.length>0&&ve.size===t.length,el=ve.size>0&&ve.size<t.length,tl=i.useMemo(()=>De.some(G=>!!G.rowSpan),[De]),[Pt,qt]=i.useState(!1),vn=i.useRef(null),_n=i.useRef(null),ro=i.useMemo(()=>{if(!Z?.toolbar)return null;const G=D?void 0:(X,se)=>{const ue=[...Ut],fe=ue.indexOf(X),he=ue.indexOf(se);if(fe===-1||he===-1)return;const me=[...ue];me.splice(fe,1),me.splice(he,0,X),A||Kt(me);const be=De.find(It=>It.field===X);be&&z?.({oldIndex:fe,targetIndex:he,column:be})};return{apiRef:Ce.apiRef,columns:hn,baseColumns:e,aggregationModel:Me,onAggregationModelChange:Un,...ce||Ee||Te?{pivotModel:sn,onPivotModelChange:Kn}:{},filterModel:Ne,onFilterModelChange:_,columnVisibilityModel:Ue,onColumnVisibilityModelChange:$t,onColumnReorder:G,onColumnOrderReset:D?void 0:()=>Kt(e.map(X=>X.field)),forceColumnsOpen:Pt,onColumnsPanelClose:()=>qt(!1),...ge?.toolbar}},[Z?.toolbar,D,Ut,hn,De,A,z,Kt,Ce.apiRef,e,Me,Un,ce,Ee,Te,sn,Kn,Ne,_,Ue,$t,Pt,ge?.toolbar]);return i.useEffect(()=>{if(!Pt||Z?.toolbar)return;function G(X){_n.current&&!_n.current.contains(X.target)&&qt(!1)}return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[Pt,Z?.toolbar]),r.jsxs("div",{ref:vn,className:["ogx",Pe,d&&"ogx--auto-height",tl&&"ogx--row-spanning",Ot&&"ogx--list-view"].filter(Boolean).join(" "),style:{...Re,height:Y??Re?.height,"--ogx-row-height":`${Be}px`,"--ogx-header-height":`${s}px`},"aria-busy":Ct,children:[ro&&r.jsx(ji,{...ro}),!Z?.toolbar&&r.jsx(Er,{isOpen:Pt,containerRef:vn,panelRef:_n,effectiveColumns:De,columnVisibilityModel:Ue,effectiveColumnOrder:Ut,columnOrder:A,disableColumnReorder:D,onClose:()=>qt(!1),onColumnVisibilityChange:$t,onColumnOrderChange:z,setInternalColumnOrder:Kt}),Ot&&Gn&&r.jsx(ur,{ariaLabel:ee,allRenderableRows:mn,filteredRows:Ye,pagination:Fe,effectivePaginationModel:ke,pageSizeOptions:y,selectedRowIds:ve,listViewColumn:Gn,noRowsLabel:on,rowHeight:Be,checkboxSelection:f,paginationMode:B,dataSource:re,serverRowCount:pe.pagination.rowCount||0,paginationSlot:Z?.pagination,paginationSlotProps:ge?.pagination,localeText:Le?{paginationRowsPerPage:Le.paginationRowsPerPage,paginationOf:Le.paginationOf,paginationPage:Le.paginationPage}:void 0,onRowClick:Gt,onSelectionChange:Mt,onPaginationModelChange:an}),!Ot&&r.jsx("div",{ref:G=>{ot.current=G,Ht.current=G},className:"ogx__viewport",onScroll:$i,role:"grid","aria-label":ee||"Data grid","aria-rowcount":Ye.length+1,"aria-colcount":e.length+(f?1:0)+(Oe?1:0)+(V?1:0),"aria-busy":Ct,tabIndex:0,onKeyDownCapture:()=>{it(!0)},onMouseDownCapture:()=>{it(!1)},onKeyDown:Ji,onFocus:qi,onBlur:Xi,children:r.jsxs("div",{ref:Mi,className:"ogx__content",style:{width:Se.totalWidth},role:"presentation",children:[r.jsx(Nn,{columns:Se.virtualColumns,allColumns:De,columnGroupingModel:Ve,checkboxSelection:f,allSelected:Zi,someSelected:el,onSelectAll:Ki,sortModel:Ie,onSort:no,onSortAdd:Yi,multiSort:q,onColumnResize:Gi,columnWidths:We,pinnedColumns:Ke,focusedCell:Yt,onHeaderClick:G=>{bn({id:"HEADER",field:G}),it(!1),Ht.current?.focus({preventScroll:!0})},onDragStart:Ve?void 0:ct.onDragStart,onDragOver:Ve?void 0:ct.onDragOver,onDragEnd:Ve?void 0:ct.onDragEnd,onDrop:Ve?void 0:ct.onDrop,draggedColumn:Ve?void 0:ct.draggedColumn,dragOverColumn:Ve?void 0:ct.dragOverColumn,rowReordering:V,hasDetailPanel:Oe,pinCheckboxColumn:W,pinExpandColumn:$,aggregationModel:Me,onHideColumn:G=>{$t({...Ue,[G]:!1})},onManageColumns:()=>qt(!0),onPinColumn:(G,X)=>{const se=[...Ze?.left??[]],ue=[...Ze?.right??[]],fe=se.filter(me=>me!==G),he=ue.filter(me=>me!==G);ln(X==="left"?{left:[...fe,G],right:he}:X==="right"?{left:fe,right:[...he,G]}:{left:fe,right:he})}}),!Ct&&!pe.dataSource.error&&Ye.length===0&&r.jsx(To,{noRowsLabel:on,width:Se.totalWidth}),r.jsx(Rn,{rows:pn,position:"top",columns:Se.virtualColumns,selectedRowIds:ve,checkboxSelection:f,onRowClick:Gt,onCellClick:wn,onSelectionChange:Mt,columnWidths:We,pinnedColumns:Ke,pinnedRows:P,hasDetailPanel:Oe,expandedRowIds:dt,getDetailPanelContent:F,getDetailPanelHeight:k,onDetailPanelToggle:Vt,pinCheckboxColumn:W,pinExpandColumn:$,focusedCell:Yt,colspanMap:ft.colspanMap,rowSpanningCaches:ft.rowSpanningState.caches,rowHeight:Be,rowMetaMap:jt}),r.jsx(kr,{virtualContainerHeight:Se.totalHeight-Se.pinnedTopHeight-Se.pinnedBottomHeight,offsetTop:Se.offsetTop,effectiveLoading:Ct,visibleRows:Qi,baseColumns:e,virtualColumns:Se.virtualColumns,viewportWidth:pe.dimensions.viewportWidth,checkboxSelection:f,hasDetailPanel:Oe,rowReordering:V,rowHeight:Be,pinnedRows:P,selectedRowIds:ve,onRowClick:Gt,onCellClick:wn,onSelectionChange:Mt,columnWidths:We,pinnedColumns:Ke,expandedRowIds:dt,getDetailPanelContent:F,getDetailPanelHeight:k,onDetailPanelToggle:Vt,pinCheckboxColumn:W,pinExpandColumn:$,rowReorderHandlers:Vi,editingHandlers:at,focusedCell:Yt,colspanMap:ft.colspanMap,rowSpanningCaches:ft.rowSpanningState.caches,paginationMode:B,dataSourceLoading:pe.dataSource.loading,sortedUnpinnedRowCount:Ae.length,infiniteScrollSkeletonCount:Math.min(ke.pageSize,20),unpinnedRowsLength:xe.unpinnedRowsLength,rowMetaMap:jt}),r.jsx(Rn,{rows:xn,position:"bottom",columns:Se.virtualColumns,selectedRowIds:ve,checkboxSelection:f,onRowClick:Gt,onCellClick:wn,onSelectionChange:Mt,columnWidths:We,pinnedColumns:Ke,pinnedRows:P,hasDetailPanel:Oe,expandedRowIds:dt,getDetailPanelContent:F,getDetailPanelHeight:k,onDetailPanelToggle:Vt,pinCheckboxColumn:W,pinExpandColumn:$,focusedCell:Yt,colspanMap:ft.colspanMap,rowSpanningCaches:ft.rowSpanningState.caches,rowHeight:Be,rowMetaMap:jt}),gt&&!ce&&r.jsx(Io,{columns:hn,aggregationModel:Me,aggregationResult:Nt,columnWidths:Ui,rowHeight:Be,checkboxSelection:f,hasDetailPanel:Oe,rowReordering:V,pinnedColumns:Ke})]})}),!Ot&&Fe&&(()=>{const G=Z?.pagination||Mn;return r.jsx(G,{page:ke.page,pageSize:ke.pageSize,rowCount:pe.pagination.rowCount,pageSizeOptions:y,onPageChange:X=>an({...ke,page:X}),onPageSizeChange:X=>an({...ke,pageSize:X,page:0}),localeText:Le?{paginationRowsPerPage:Le.paginationRowsPerPage,paginationOf:Le.paginationOf,paginationPage:Le.paginationPage}:void 0,...ge?.pagination})})(),r.jsxs("div",{className:"ogx-aria-live-status",role:"status","aria-live":"polite",children:[Ct?"Loading data...":"",pe.dataSource.error?`Error: ${pe.dataSource.error instanceof Error?pe.dataSource.error.message:"Unknown error"}`:"",!M&&!pe.dataSource.error&&(Ye.length===0?on:Ne&&((Ne.quickFilterValues?.length||0)>0||(Ne.items?.length||0)>0)?`${Ye.length} ${Ye.length===1?"row":"rows"} found`:"")]}),r.jsx(Ro,{error:pe.dataSource.error})]})}function Pr({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 Fn=new Set(["isEmpty","isNotEmpty"]);function Ir(n,t){return n.find(e=>"field"in e&&e.field===t)}const Tr=({col:n,item:t,onChange:e})=>{const o=i.useId(),l=vo(n.type),s=!!t,d=t?.operator??l[0],[a,f]=i.useState(t?.value!=null?String(t.value):""),p=i.useRef(e),x=i.useRef(t),w=i.useRef(n.field),b=i.useRef(d);i.useLayoutEffect(()=>{p.current=e,x.current=t,w.current=n.field,b.current=d});const c=i.useRef(t?.value);i.useEffect(()=>{t?.value!==c.current&&(c.current=t?.value,f(t?.value!=null?String(t.value):""))},[t?.value]),i.useEffect(()=>{const S=setTimeout(()=>{const N=x.current,h=N?.value??"";a!==h&&p.current({id:N?.id??`${w.current}-${Date.now()}`,field:w.current,operator:b.current,value:a})},300);return()=>clearTimeout(S)},[a]);const g=S=>{const N=Fn.has(S),h={id:t?.id??`${n.field}-${Date.now()}`,field:n.field,operator:S,value:N?void 0:t?.value??(n.type==="boolean"?"true":"")};e(h)},m=()=>{f(""),e(null)},_=Fn.has(String(d)),E=n.type==="boolean",v=!_;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:S=>g(S.target.value),"aria-label":`Filter operator for ${n.headerName||n.field}`,children:l.map(S=>r.jsx("option",{value:S,children:S},S))}),v&&E&&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:S=>{f(S.target.value),e({id:t?.id??`${n.field}-${Date.now()}`,field:n.field,operator:d,value:S.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"})]}),v&&!E&&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:S=>f(S.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:m,"aria-label":`Clear filter for ${n.headerName||n.field}`,title:"Clear",children:"×"})]})]})},On=({filterModel:n,columns:t,onFilterModelChange:e})=>{const o=i.useMemo(()=>n.items??[],[n.items]),l=n.logicOperator??"and",s=i.useCallback((f,p)=>{const x=o.filter(b=>"field"in b&&b.field!==f),w=p?[...x,p]:x;e({...n,items:w})},[o,n,e]),d=i.useCallback(f=>{e({...n,logicOperator:f})},[n,e]),a=t.filter(f=>f.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(f=>r.jsx(Tr,{col:f,item:Ir(o,f.field),onChange:p=>s(f.field,p)},f.field))]})},Rr=["sum","avg","count","min","max"];function Wn(){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 Lr({anchorRef:n,columns:t,model:e,onChange:o,onClose:l}){const s=i.useRef(null),[d,a]=i.useState({top:0,right:0}),[f,p]=i.useState(document.body);i.useLayoutEffect(()=>{p(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const x=i.useCallback(()=>{if(!n.current)return{top:0,right:0};const k=n.current.getBoundingClientRect();return{top:k.bottom+6,right:window.innerWidth-k.right}},[n]);i.useEffect(()=>{a(x());const k=()=>a(x());return window.addEventListener("scroll",k,!0),window.addEventListener("resize",k),()=>{window.removeEventListener("scroll",k,!0),window.removeEventListener("resize",k)}},[x]),i.useEffect(()=>{function k(R){s.current&&!s.current.contains(R.target)&&n.current&&!n.current.contains(R.target)&&l()}function I(R){R.key==="Escape"&&l()}return document.addEventListener("mousedown",k),document.addEventListener("keydown",I),()=>{document.removeEventListener("mousedown",k),document.removeEventListener("keydown",I)}},[n,l]);const w=new Set(e.rowFields),b=new Set(e.columnFields),c=new Set(e.valueFields.map(k=>k.field)),g=k=>w.has(k)||b.has(k)||c.has(k);function m(k){w.has(k)||o({...e,rowFields:[...e.rowFields,k]})}function _(k){b.has(k)||o({...e,columnFields:[...e.columnFields,k]})}function E(k,I="sum"){c.has(k)||o({...e,valueFields:[...e.valueFields,{field:k,aggFn:I}]})}function v(k){o({...e,rowFields:e.rowFields.filter(I=>I!==k)})}function S(k){o({...e,columnFields:e.columnFields.filter(I=>I!==k)})}function N(k){o({...e,valueFields:e.valueFields.filter(I=>I.field!==k)})}function h(k,I){o({...e,valueFields:e.valueFields.map(R=>R.field===k?{...R,aggFn:I}:R)})}function y(){o({rowFields:[],columnFields:[],valueFields:[]})}const u=new Set(t.filter(k=>k.type==="number"||k.aggregable).map(k=>k.field)),j=e.rowFields.length+e.columnFields.length+e.valueFields.length,P=k=>t.find(I=>I.field===k)?.headerName??k,F=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(Wn,{}),"Pivot Mode"]}),j>0&&r.jsx("button",{className:"ogx-pivot-panel__reset-btn",onClick:y,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(k=>r.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--row",children:[P(k),r.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>v(k),title:`Remove ${P(k)}`,children:"×"})]},k))})]}),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(k=>r.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--col",children:[P(k),r.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>S(k),title:`Remove ${P(k)}`,children:"×"})]},k))})]}),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(k=>r.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--value",children:[P(k.field),r.jsx("select",{className:"ogx-pivot-chip__fn-select",value:k.aggFn,onChange:I=>h(k.field,I.target.value),title:"Aggregation function",children:Rr.map(I=>r.jsx("option",{value:I,children:I.toUpperCase()},I))}),r.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>N(k.field),title:`Remove ${P(k.field)}`,children:"×"})]},k.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(k=>{const I=u.has(k.field);return g(k.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:k.headerName??k.field}),r.jsxs("div",{className:"ogx-pivot-field-actions",children:[r.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--row",onClick:()=>m(k.field),title:"Add to Row Fields",children:"Row"}),r.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--col",onClick:()=>_(k.field),title:"Add to Column Fields",children:"Col"}),I&&r.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--value",onClick:()=>E(k.field),title:"Add to Value Fields",children:"Val"})]})]},k.field)}),t.every(k=>g(k.field))&&r.jsx("span",{style:{fontSize:12,color:"var(--ogx-color-gray-400, #94a3b8)"},children:"All fields are in use."})]})]})]})]});return Ge.createPortal(F,f)}function Fr(){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 Or(){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 Wr({value:n="",onChange:t,placeholder:e="Search...",debounceMs:o=250}){const[l,s]=i.useState(()=>n.length>0),[d,a]=i.useState(n),f=i.useRef(null),p=i.useRef(null),x=i.useRef(t);i.useLayoutEffect(()=>{x.current=t},[t]);const w=i.useRef(n),b=i.useRef(n),c=i.useRef(!1);i.useLayoutEffect(()=>{c.current&&document.activeElement!==f.current&&f.current?.focus()}),i.useEffect(()=>{n!==b.current&&(b.current=n,n!==w.current&&(a(n),w.current=n,n?s(!0):(c.current=!1,s(!1))))},[n]),i.useEffect(()=>{const v=setTimeout(()=>{d!==w.current&&(w.current=d,x.current(d))},o);return()=>clearTimeout(v)},[d,o]);const g=i.useCallback(()=>{s(!0),requestAnimationFrame(()=>f.current?.focus())},[]),m=i.useCallback(v=>{v.stopPropagation(),a(""),w.current="",x.current(""),f.current?.focus()},[]),_=i.useCallback(()=>{c.current=!0,s(!0)},[]),E=i.useCallback(()=>{c.current=!1,setTimeout(()=>{if(p.current&&document.activeElement&&p.current.contains(document.activeElement)){c.current=!0;return}d||s(!1)},150)},[d]);return i.useEffect(()=>{const v=S=>{p.current&&!p.current.contains(S.target)&&(d||s(!1))};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[d]),r.jsxs("div",{ref:p,className:`ogx-global-search${l?" ogx-global-search--expanded":""}`,onClick:l?void 0:g,children:[r.jsx("div",{className:"ogx-global-search__icon-wrapper",children:r.jsx(Fr,{})}),r.jsx("input",{ref:f,className:"ogx-global-search__input",value:d,onChange:v=>a(v.target.value),onFocus:_,onBlur:E,placeholder:e,"aria-label":"Global Search",autoComplete:"off"}),d&&r.jsx("button",{className:"ogx-global-search__clear",onClick:m,"aria-label":"Clear search",children:r.jsx(Or,{})})]})}function vt({title:n,children:t,placement:e="top",enterDelay:o=200,leaveDelay:l=0}){const[s,d]=i.useState(!1),[a,f]=i.useState({top:0,left:0}),p=i.useRef(null),x=i.useRef(null),w=i.useCallback(()=>{if(!x.current)return;const m=x.current.getBoundingClientRect();let _=0,E=0;const v=window.pageXOffset||document.documentElement.scrollLeft,S=window.pageYOffset||document.documentElement.scrollTop;e==="top"?(_=m.top+S-8,E=m.left+v+m.width/2):e==="bottom"&&(_=m.bottom+S+8,E=m.left+v+m.width/2),f({top:_,left:E})},[e]);i.useLayoutEffect(()=>(s&&(w(),window.addEventListener("scroll",w,!0),window.addEventListener("resize",w)),()=>{window.removeEventListener("scroll",w,!0),window.removeEventListener("resize",w)}),[s,w]);const b=()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{d(!0)},o)},c=()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{d(!1)},l)},g=i.useCallback(m=>{x.current=m?m.firstElementChild??m:null},[]);return r.jsxs(r.Fragment,{children:[r.jsx("span",{ref:g,style:{display:"inline-block",lineHeight:0},onMouseEnter:b,onMouseLeave:c,children:t}),s&&n&&Ge.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 Ar=["none","sum","avg","count","min","max"];function An(){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 $r(){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 $n(){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 zr({anchorRef:n,aggregationModel:t,aggregableColumns:e,onFunctionChange:o,onClearAll:l,onClose:s,activeCount:d}){const a=i.useRef(null),[f,p]=i.useState({top:0,right:0}),[x,w]=i.useState(document.body);i.useLayoutEffect(()=>{w(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const b=i.useCallback(()=>{if(!n.current)return{top:0,right:0};const g=n.current.getBoundingClientRect();return{top:g.bottom+6,right:window.innerWidth-g.right}},[n]);i.useEffect(()=>{p(b());const g=()=>p(b());return window.addEventListener("scroll",g,!0),window.addEventListener("resize",g),()=>{window.removeEventListener("scroll",g,!0),window.removeEventListener("resize",g)}},[b]),i.useEffect(()=>{function g(m){a.current&&!a.current.contains(m.target)&&n.current&&!n.current.contains(m.target)&&s()}return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[n,s]),i.useEffect(()=>{function g(m){m.key==="Escape"&&s()}return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[s]);const c=r.jsxs("div",{ref:a,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Summaries configuration",style:{top:f.top,right:f.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(An,{}),"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(g=>{const m=t[g.field]||"none";return r.jsxs("div",{className:"ogx-toolbar__agg-row",children:[r.jsx("span",{className:"ogx-toolbar__agg-label",title:g.field,children:g.headerName||g.field}),r.jsx("div",{className:"ogx-toolbar__agg-pills",children:Ar.map(_=>r.jsx("button",{className:`ogx-toolbar__pill${m===_?" ogx-toolbar__pill--active":""}`,onClick:()=>o(g.field,_),"aria-pressed":m===_,children:_},_))})]},g.field)})})]});return Ge.createPortal(c,x)}function Br({anchorRef:n,columns:t,visibleColumns:e,onVisibilityChange:o,onShowAll:l,onHideAll:s,onColumnReorder:d,onColumnOrderReset:a,onClose:f,showNonHideableColumns:p}){const x=i.useRef(null),[w,b]=i.useState({top:0,right:0}),[c,g]=i.useState(document.body);i.useLayoutEffect(()=>{g(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const m=i.useCallback(()=>{if(!n.current)return{top:0,right:0};const E=n.current.getBoundingClientRect();return{top:E.bottom+6,right:window.innerWidth-E.right}},[n]);i.useEffect(()=>{b(m());const E=()=>b(m());return window.addEventListener("scroll",E,!0),window.addEventListener("resize",E),()=>{window.removeEventListener("scroll",E,!0),window.removeEventListener("resize",E)}},[m]),i.useEffect(()=>{function E(v){x.current&&!x.current.contains(v.target)&&n.current&&!n.current.contains(v.target)&&f()}return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[n,f]);const _=r.jsx("div",{ref:x,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Column visibility",style:{top:w.top,right:w.right,width:280,padding:0},children:r.jsx(Ln,{columns:t,visibleColumns:e,onVisibilityChange:o,onShowAll:l,onHideAll:s,onColumnReorder:d,onColumnOrderReset:a,showNonHideableColumns:p})});return Ge.createPortal(_,c)}function Hr({anchorRef:n,columns:t,filterModel:e,onFilterModelChange:o,onClose:l}){const s=i.useRef(null),[d,a]=i.useState({top:0,right:0}),f=i.useRef(l);i.useLayoutEffect(()=>{f.current=l},[l]);const[p,x]=i.useState(document.body);i.useLayoutEffect(()=>{x(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const w=i.useCallback(()=>{if(!n.current)return{top:0,right:0};const m=n.current.getBoundingClientRect();return{top:m.bottom+6,right:window.innerWidth-m.right}},[n]);i.useEffect(()=>{a(w());const m=()=>a(w());return window.addEventListener("scroll",m,!0),window.addEventListener("resize",m),()=>{window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m)}},[w]),i.useEffect(()=>{function m(_){_.key==="Escape"&&f.current()}return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[]);const b=e.items?.length??0,c=()=>{o({...e,items:[],logicOperator:"and"})},g=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($n,{}),"Filters",b>0&&r.jsx("span",{className:"ogx-toolbar__panel-count",children:b})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[b>0&&r.jsx("button",{className:"ogx-toolbar__clear-btn",onClick:c,title:"Clear all filters",children:"Clear all"}),r.jsx("button",{className:"ogx-toolbar__close-btn",onClick:()=>f.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(On,{columns:t,filterModel:e,onFilterModelChange:o})})]});return Ge.createPortal(g,p)}const Dr={rowFields:[],columnFields:[],valueFields:[]};function Gr({columns:n=[],baseColumns:t,aggregationModel:e={},onAggregationModelChange:o,pivotModel:l,onPivotModelChange:s,filterModel:d,onFilterModelChange:a,columnVisibilityModel:f={},onColumnVisibilityModelChange:p,onColumnReorder:x,onColumnOrderReset:w,forceColumnsOpen:b,onColumnsPanelClose:c,children:g,rightContent:m,style:_,renderColumnsButton:E,renderFilterButton:v,renderAggregationButton:S,renderExportButton:N,renderQuickFilter:h,className:y,showNonHideableColumns:u}){const[j,P]=i.useState(!1),[F,k]=i.useState(!1),[I,R]=i.useState(!1),[W,$]=i.useState(!1);i.useEffect(()=>{b&&(R(!0),P(!1),k(!1),$(!1))},[b]);const D=i.useRef(null),A=i.useRef(null),z=i.useRef(null),Y=i.useRef(null),V=i.useRef(null),C=i.useRef(null),M=i.useRef(null),L=l??Dr,O=L.rowFields.length>0||L.columnFields.length>0||L.valueFields.length>0,H=n.filter(J=>J.aggregable!==!1&&(J.type==="number"||J.aggregable===!0)),U=Object.keys(e).filter(J=>e[J]&&e[J]!=="none").length,K=i.useCallback((J,de)=>{if(!o)return;const B={...e};de==="none"?delete B[J]:B[J]=de,o(B)},[e,o]),oe=i.useCallback(()=>{o?.({})},[o]),ie=i.useCallback(J=>{if(!a)return;const B={...d||{},quickFilterValues:J?[J]:[],items:d?.items||[]};a(B)},[d,a]),ne=d?.quickFilterValues?.[0]||"",T=d?.items?.length||0,le=new Set(n.filter(J=>f[J.field]!==!1).map(J=>J.field)),te=i.useCallback((J,de)=>{if(!p)return;const B={...f,[J]:de};p(B)},[f,p]),re=i.useCallback(()=>{if(!p)return;const J={...f};n.forEach(de=>{de.hideable!==!1&&(J[de.field]=!0)}),p(J)},[n,f,p]),q=i.useCallback(()=>{if(!p)return;const J={...f};n.forEach(de=>{de.hideable!==!1&&(J[de.field]=!1)}),p(J)},[n,f,p]);return r.jsxs("div",{className:["ogx-toolbar",y].filter(Boolean).join(" "),role:"toolbar","aria-label":"Grid toolbar",style:_,children:[g&&r.jsx("div",{className:"ogx-toolbar__left",children:g}),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:h?h({value:ne,onChange:ie}):r.jsx(Wr,{value:ne,onChange:ie,placeholder:"Search..."})}),p&&r.jsxs("div",{ref:V,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[E?E({onClick:()=>{R(J=>!J),P(!1),k(!1),$(!1)},isOpen:I,activeCount:n.length-le.size}):r.jsx(vt,{title:"Columns",children:r.jsx("button",{ref:z,className:`ogx-toolbar__icon-btn${I?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Manage columns",onClick:()=>{R(!I),P(!1),k(!1),$(!1)},children:r.jsx($r,{})})}),I&&r.jsx(Br,{anchorRef:E?V:z,columns:n,visibleColumns:le,onVisibilityChange:te,onShowAll:re,onHideAll:q,onColumnReorder:x,onColumnOrderReset:w,onClose:()=>{R(!1),c?.()},showNonHideableColumns:u})]}),a&&r.jsxs("div",{ref:C,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[v?v({onClick:()=>{$(J=>!J),P(!1),k(!1),R(!1)},isOpen:W,activeCount:T}):r.jsx(vt,{title:"Filters",children:r.jsxs("button",{ref:Y,className:`ogx-toolbar__icon-btn${W?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Advanced filters",onClick:()=>{$(!W),P(!1),k(!1),R(!1)},children:[r.jsx($n,{}),T>0&&r.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Filters active"})]})}),W&&r.jsx(Hr,{anchorRef:v?C:Y,columns:n,filterModel:d||{items:[]},onFilterModelChange:a,onClose:()=>$(!1)})]}),s&&r.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[r.jsx(vt,{title:"Pivot",children:r.jsxs("button",{ref:A,className:`ogx-toolbar__icon-btn${F?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure pivot","aria-expanded":F,onClick:()=>{k(!F),P(!1),R(!1),$(!1)},children:[r.jsx(Wn,{}),O&&r.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Pivot active"})]})}),F&&r.jsx(Lr,{anchorRef:A,columns:t??n,model:L,onChange:J=>{s?.(J)},onClose:()=>k(!1)})]}),r.jsxs("div",{ref:M,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[S?S({onClick:()=>{P(J=>!J),k(!1),R(!1),$(!1)},isOpen:j,activeCount:U}):r.jsx(vt,{title:"Summaries",children:r.jsxs("button",{ref:D,className:`ogx-toolbar__icon-btn${j?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure summaries","aria-expanded":j,onClick:()=>{P(!j),k(!1),R(!1),$(!1)},children:[r.jsx(An,{}),U>0&&r.jsx("span",{className:"ogx-toolbar__dot","aria-label":`${U} active summaries`})]})}),j&&r.jsx(zr,{anchorRef:S?M:D,aggregationModel:e,aggregableColumns:H,onFunctionChange:K,onClearAll:oe,onClose:()=>P(!1),activeCount:U})]}),N&&N(),m]})]})}function Vr(){return i.useRef(null)}const Ur=({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 zn(n){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);return t?[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]:[79,70,229]}function Kr(n){return n.filter(t=>!(t.exportable===!1||t.field==="__check__"||t.field==="__actions__"))}function Bn(n,t){let e=n[t.field];return t.valueGetter&&(e=t.valueGetter({row:n,field:t.field,value:e})),t.valueFormatter&&e!==void 0&&e!==null&&(e=t.valueFormatter({value:e,row:n,field:t.field})),String(e??"")}function Hn(n){return(typeof n.width=="number"?n.width:void 0)??(n.flex??1)*100}function Yr(n,t){const e=n.reduce((l,s)=>l+Hn(s),0),o={};return n.forEach((l,s)=>{o[s]={cellWidth:Hn(l)/e*t}}),o}function qr(n,t){return!n.items||n.items.length===0?"":n.items.flatMap(e=>{if("items"in e)return[];const l=t.find(d=>d.field===e.field)?.headerName??e.field,s=e.value!==void 0&&e.value!==null?String(e.value):"";return[`${l} ${e.operator} "${s}"`]}).join(" • ")}async function Xr(n,t,e={}){let o,l;try{const[C,M]=await Promise.all([import("jspdf"),import("jspdf-autotable")]);o=C.default,l=M.default}catch{throw new Error("exportToPdf requires 'jspdf' and 'jspdf-autotable'. Run: npm install jspdf jspdf-autotable")}const{fileName:s="export",title:d,logoUrl:a,orientation:f="landscape",selectedRows:p,aggregationResult:x,aggregationModel:w,filterModel:b,alternateRowColor:c=!0,headerBackgroundColor:g="#4f46e5",headerTextColor:m="#ffffff",fontSize:_=9,groupedRows:E}=e,v=new o({orientation:f,unit:"mm",format:"a4"}),S=v.internal.pageSize.getWidth(),N=v.internal.pageSize.getHeight(),h=14,y=S-h*2,u=Kr(t),j=p&&p.length>0?n.filter(C=>p.includes(C.id)):n;let P=h;if(d){let C=h,M=h+8;if(a)try{v.addImage(a,"PNG",C,h,10,10),C+=14}catch{}v.setFontSize(16),v.setFont("helvetica","bold"),v.setTextColor(30,41,59),v.text(d,C,M),M+=6,v.setFontSize(8),v.setFont("helvetica","normal"),v.setTextColor(100,116,139);const L=new Date().toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),O=E?E.filter(H=>H.type==="leaf").length:j.length;if(v.text(`Exported: ${L} • ${O} row${O!==1?"s":""}`,C,M),M+=5,b){const H=qr(b,t);H&&(v.text(`Filters: ${H}`,C,M),M+=5)}v.setDrawColor(226,232,240),v.setLineWidth(.3),v.line(h,M+2,S-h,M+2),P=M+6}const F=[u.map(C=>C.headerName??C.field)];let k,I;if(E&&E.length>0){k=[];const C=w||{};E.forEach(M=>{if(M.type==="group-header"){const O=`${" ".repeat(M.depth*2)}${M.groupField??""}: ${String(M.groupValue??"")}`;k.push(u.map((H,U)=>U===0?O:""))}else if(M.type==="leaf"&&M.row){const L=M.row,O=" ".repeat(M.depth*2);k.push(u.map((H,U)=>(U===0?O:"")+Bn(L,H)))}else if(M.type==="group-subtotal"&&M.aggregatedValues){const L=" ".repeat(M.depth*2);k.push(u.map((O,H)=>{if(H===0)return`${L}Subtotal`;const U=M.aggregatedValues[O.field];if(U==null)return"";let K=U;return O.valueFormatter?K=O.valueFormatter({value:U,row:{},field:O.field}):C[O.field]&&(K=_e(U,C[O.field])),String(K)}))}else M.type==="grand-total"&&M.aggregatedValues&&(I=[u.map((O,H)=>{if(H===0)return"Grand Total";const U=M.aggregatedValues[O.field];if(U==null)return"";let K=U;return O.valueFormatter?K=O.valueFormatter({value:U,row:{},field:O.field}):C[O.field]&&(K=_e(U,C[O.field])),String(K)})])})}else k=j.map(C=>u.map(M=>Bn(C,M))),x&&w&&(I=[u.map((M,L)=>{if(L===0)return u.some(K=>w[K.field])?"TOTAL":"";const O=x[M.field];if(O==null)return"";let H=O;return M.valueFormatter?H=M.valueFormatter({value:O,row:{},field:M.field}):w[M.field]&&(H=_e(O,w[M.field])),String(H)})]);const R=Yr(u,y),[W,$,D]=zn(g),[A,z,Y]=zn(m);l(v,{head:F,body:k,...I?{foot:I}:{},startY:P,styles:{fontSize:_,cellPadding:3,font:"helvetica",overflow:"linebreak"},headStyles:{fillColor:[W,$,D],textColor:[A,z,Y],fontStyle:"bold"},...c?{alternateRowStyles:{fillColor:[248,250,252]}}:{},...I?{footStyles:{fillColor:[241,245,249],fontStyle:"bold",textColor:[0,0,0]}}:{},columnStyles:R,showFoot:I?"lastPage":"never",showHead:"everyPage",margin:{top:h,left:h,right:h,bottom:h+6}});const V=v.getNumberOfPages();for(let C=1;C<=V;C++)v.setPage(C),v.setFontSize(8),v.setTextColor(150,150,150),v.text(`Page ${C} of ${V}`,S-h,N-8,{align:"right"});v.save(`${s}.pdf`)}function Jr(n,t,e={}){const{fileName:o="export.csv",includeHeaders:l=!0,delimiter:s=",",selectedRows:d,groupedRows:a}=e,f=t.filter(x=>!(x.exportable===!1||x.field==="__check__"||x.field==="__actions__"));let p="";if(a&&a.length>0)l&&(p+=f.map(x=>je(x.headerName||x.field)).join(s)+`
|
|
9
|
-
`),
|
|
10
|
-
`}else if(
|
|
11
|
-
`}else if(
|
|
12
|
-
`}else if(
|
|
13
|
-
`}});else{const
|
|
14
|
-
`),
|
|
15
|
-
`}),e.aggregationResult){const w=e.aggregationResult,
|
|
16
|
-
`;const
|
|
17
|
-
`}}
|
|
18
|
-
`)?`"${n.replace(/"/g,'""')}"`:n}function
|
|
6
|
+
<%s key={someKey} {...props} />`,O,Z,ce,Z),D[Z+O]=!0)}if(Z=null,I!==void 0&&(e(I),Z=""+I),a(T)&&(e(T.key),Z=""+T.key),"key"in T){I={};for(var le in T)le!=="key"&&(I[le]=T[le])}else I=T;return Z&&d(I,typeof _=="function"?_.displayName||_.name||"Unknown":_),u(_,Z,I,i(),X,te)}function w(_){x(_)?_._store&&(_._store.validated=1):typeof _=="object"&&_!==null&&_.$$typeof===j&&(_._payload.status==="fulfilled"?x(_._payload.value)&&_._payload.value._store&&(_._payload.value._store.validated=1):_._store&&(_._store.validated=1))}function x(_){return typeof _=="object"&&_!==null&&_.$$typeof===f}var g=s,f=Symbol.for("react.transitional.element"),h=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),m=Symbol.for("react.profiler"),y=Symbol.for("react.consumer"),M=Symbol.for("react.context"),N=Symbol.for("react.forward_ref"),k=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),P=Symbol.for("react.activity"),b=Symbol.for("react.client.reference"),F=g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,z=Object.prototype.hasOwnProperty,K=Array.isArray,W=console.createTask?console.createTask:function(){return null};g={react_stack_bottom_frame:function(_){return _()}};var $,H={},L=g.react_stack_bottom_frame.bind(g,l)(),B=W(o(l)),D={};mt.Fragment=v,mt.jsx=function(_,T,I){var O=1e4>F.recentlyCreatedOwnerStacks++;return p(_,T,I,!1,O?Error("react-stack-top-frame"):L,O?W(o(_)):B)},mt.jsxs=function(_,T,I){var O=1e4>F.recentlyCreatedOwnerStacks++;return p(_,T,I,!0,O?Error("react-stack-top-frame"):L,O?W(o(_)):B)}})()),mt}var Nn;function Co(){return Nn||(Nn=1,process.env.NODE_ENV==="production"?Ft.exports=bo():Ft.exports=vo()),Ft.exports}var r=Co();function wt(n,t){return t?t.left?.includes(n)?"left":t.right?.includes(n)?"right":null:null}function _o(n,t){const e=[],o=[],i=[];return t?(n.forEach(l=>{const a=wt(l.field,t);a==="left"?e.push(l):a==="right"?i.push(l):o.push(l)}),t.left&&e.sort((l,a)=>{const d=t.left.indexOf(l.field),c=t.left.indexOf(a.field);return d-c}),t.right&&i.sort((l,a)=>{const d=t.right.indexOf(l.field),c=t.right.indexOf(a.field);return d-c}),{left:e,center:o,right:i}):{left:e,center:n,right:i}}function en(n,t,e,o,i,l,a,d){const c={};if(!e)return c;const u=_o(n,e);let p=0;d&&(p+=48),l&&a&&(p+=48),o&&i&&(p+=48),u.left.forEach(x=>{c[x.field]=p;const g=t[x.field]??x.width??100;p+=g});let w=0;return[...u.right].reverse().forEach(x=>{const g=t[x.field]??x.width??100;c[x.field]=w,w+=g}),c}function tn(n,t){return t?t.top?.includes(n)?"top":t.bottom?.includes(n)?"bottom":null:null}function yo(n,t){const e=[],o=[],i=[];return t?(n.forEach(l=>{const a=tn(l.id,t);a==="top"?e.push(l):a==="bottom"?i.push(l):o.push(l)}),t.top&&e.sort((l,a)=>{const d=t.top.indexOf(l.id),c=t.top.indexOf(a.id);return d-c}),t.bottom&&i.sort((l,a)=>{const d=t.bottom.indexOf(l.id),c=t.bottom.indexOf(a.id);return d-c}),{top:e,center:o,bottom:i}):{top:e,center:n,bottom:i}}function Je(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 ko(n){const{rowHeight:t,pagination:e,paginatedUnpinnedRows:o,sortedUnpinnedRows:i,expandedRowIds:l,getDetailPanelHeight:a,pinnedTopRowsLength:d,pinnedBottomRowsLength:c,visibleOrderedColumns:u,pinnedColumns:p,columnWidths:w,viewportWidth:x,checkboxSelection:g,hasDetailPanel:f,rowReordering:h,paginationMode:v,isLoading:E,pageSize:m}=n;return s.useMemo(()=>{const y=e?o:i,M=y.map((A,ee)=>{let ie=t;if(l.has(A.id)){const ae=a?.({row:A,id:A.id,rowIndex:d+ee})??200;ie+=typeof ae=="number"?ae:parseInt(String(ae),10)||200}return ie}),N=M.reduce((A,ee,ie)=>(A.push((A[ie-1]||0)+ee),A),[]),k=v==="infinite"&&E&&y.length>0?Math.min(m,20):0,C=(N[N.length-1]||0)+k*t,S=d*t,j=c*t,P=[],b=[],F=[],z=[];u.forEach(A=>{const ee=wt(A.field,p);ee==="left"?P.push(A):ee==="right"?b.push(A):F.push(A)});const K=(g?48:0)+(f?48:0)+(h?48:0),W=A=>w[A.field]??A.width,$=P.reduce((A,ee)=>{const ie=Je(W(ee));return A+(ie.type==="fixed"?ie.value:100)},0),H=b.reduce((A,ee)=>{const ie=Je(W(ee));return A+(ie.type==="fixed"?ie.value:100)},0),L=F.reduce((A,ee)=>{if(!Object.prototype.hasOwnProperty.call(w,ee.field)&&ee.flex&&ee.flex>0){const fe=ee.minWidth??150,he=typeof ee.width=="number"?ee.width:150;return A+(fe||he)}const ae=Je(W(ee));return ae.type==="fixed"?A+ae.value:ae.type==="percentage"?A+100:A+(ee.minWidth??150)},0),B=Math.max(x-K-$-H,L),D=[],_=[],T=[];F.forEach(A=>{const ee=Object.prototype.hasOwnProperty.call(w,A.field),ie=Je(W(A));if(!ee&&A.flex&&A.flex>0){T.push({col:A,flex:A.flex});return}ie.type==="fixed"?D.push({col:A,width:ie.value}):ie.type==="percentage"?_.push({col:A,percentage:ie.value}):T.push({col:A,flex:1})});const I=D.reduce((A,{width:ee})=>A+ee,0);let O=Math.max(0,B-I);const X=new Map;_.forEach(({col:A,percentage:ee})=>{const ie=ee/100*O;X.set(A.field,ie),O-=ie}),O=Math.max(0,O);const te=new Map,Z=T.map(A=>({...A,minWidth:A.col.minWidth??50,maxWidth:A.col.maxWidth??1/0,frozen:!1,computedWidth:0}));(()=>{let A=0;const ee=Z.length*2;for(;A<ee;){A++;const ie=Z.filter(oe=>!oe.frozen);if(ie.length===0)break;const ae=ie.reduce((oe,je)=>oe+je.flex,0),fe=Z.reduce((oe,je)=>je.frozen?oe+je.computedWidth:oe,0),he=Math.max(0,O-fe);if(ae<=0){ie.forEach(oe=>{oe.computedWidth=oe.minWidth,oe.frozen=!0});break}const Me=he/ae;let ke=0;const Pe=[],Se=[];if(ie.forEach(oe=>{const je=Me*oe.flex;je<oe.minWidth?(ke+=oe.minWidth-je,Pe.push(oe)):je>oe.maxWidth?(ke+=oe.maxWidth-je,Se.push(oe)):oe.computedWidth=je}),Pe.length===0&&Se.length===0){ie.forEach(oe=>oe.frozen=!0);break}ke>0?Pe.forEach(oe=>{oe.computedWidth=oe.minWidth,oe.frozen=!0}):ke<0?Se.forEach(oe=>{oe.computedWidth=oe.maxWidth,oe.frozen=!0}):(Pe.forEach(oe=>{oe.computedWidth=oe.minWidth,oe.frozen=!0}),Se.forEach(oe=>{oe.computedWidth=oe.maxWidth,oe.frozen=!0}))}})(),Z.forEach(A=>te.set(A.col.field,A.computedWidth));const le=new Map;F.forEach(A=>{let ee;if(te.has(A.field))ee=te.get(A.field);else{const ie=D.find(fe=>fe.col.field===A.field),ae=_.find(fe=>fe.col.field===A.field);if(ie)ee=ie.width;else if(ae){const fe=X.get(A.field)||0;ee=Math.max(A.minWidth??50,fe||100)}else ee=100}z.push(ee),le.set(A.field,ee)});const G=F.map(A=>{const ee=Z.find(ie=>ie.col.field===A.field);return{...A,width:le.get(A.field)??(typeof A.width=="number"?A.width:100),flex:ee?ee.flex:A.flex}}),R=11,Y=P.map((A,ee)=>{const ie=Je(W(A));return{...A,width:ie.type==="fixed"?ie.value:100,zIndex:R+ee}}),Q=11,J=b.map((A,ee)=>{const ie=Je(W(A));return{...A,width:ie.type==="fixed"?ie.value:100,zIndex:Q+(b.length-1-ee)}}),re=z.reduce((A,ee)=>A+ee,0),q=$+re+H+K,V=z.reduce((A,ee,ie)=>(A.push((A[ie-1]||0)+ee),A),[]);return{rowHeights:M,cumulativeHeights:N,unpinnedRowsHeight:C,pinnedTopHeight:S,pinnedBottomHeight:j,leftPinnedCols:Y,rightPinnedCols:J,unpinnedColsWithWidth:G,unpinnedColWidths:z,unpinnedAccWidths:V,totalWidth:q,leftWidth:$,rightWidth:H,unpinnedTotalWidth:re,systemColumnsWidth:K,pinnedTopRowsLength:d,pinnedBottomRowsLength:c,unpinnedRowsLength:y.length}},[t,e,o,i,l,a,d,c,u,p,w,x,g,f,h,v,E,m])}function Mn(n,t,e,o){if(t<0||t>=e.length)return;const i=n.querySelector(".ogx__virtual-container");if(!i)return;const{scrollTop:l,clientHeight:a}=n,d=i.getBoundingClientRect().top-n.getBoundingClientRect().top+l,c=d+(t===0?0:e[t-1]),u=d+e[t];c<l+d?n.scrollTop=Math.max(0,c-d):u>l+a-o&&(n.scrollTop=u-a+o)}function So(n){const{allRenderableRows:t,navigationColumns:e,checkboxSelection:o,selectedRowIds:i,handleSelectionChange:l,handleDetailPanelToggle:a,editingHandlers:d,setKeyboardMode:c,sortModel:u,handleSort:p,isCellEditable:w,pagination:x,pageSize:g,virtualization:f,viewportRef:h,pinnedTopRowCount:v=0}=n,[E,m]=s.useState(null),y=s.useCallback(k=>{k.target===k.currentTarget&&m(C=>{if(C)return C;if(o)return{id:"HEADER",field:"__checkbox_col__"};const S=t[0],j=e[0];return S&&j?{id:S.id,field:j.field}:null})},[t,e,o]),M=s.useCallback(k=>{k.currentTarget.contains(k.relatedTarget)||m(null)},[]),N=s.useCallback(k=>{if(c(!0),!E)return;const{id:C,field:S}=E,j=!!d.editingCell;if(C==="HEADER"&&(k.key==="Enter"||k.key===" ")){k.preventDefault();const L=e.find(B=>B.field===S);if(L&&L.sortable!==!1){const B=u.find(_=>_.field===S);let D="asc";B&&(D=B.sort==="asc"?"desc":null),p(S,D)}return}if(k.key==="Enter"){if(k.preventDefault(),j)d.stopCellEdit();else if(e.find(B=>B.field===S)?.editable){const B=t.find(D=>D.id===C);B&&d.startCellEdit({id:C,field:S,value:B[S]})}return}if((k.key===" "||k.key==="Spacebar")&&!j){if(S==="__checkbox_col__"){k.preventDefault(),l(C,!i.has(C));return}if(S==="__expand_col__"){k.preventDefault(),a(C);return}}if(k.key==="Escape"){j&&(k.preventDefault(),d.stopCellEdit({cancel:!0}));return}if(j&&k.key!=="Tab")return;const P=C==="HEADER",b=P?-1:t.findIndex(L=>L.id===C),F=e.findIndex(L=>L.field===S);if(!P&&b===-1||F===-1)return;const z=(L,B,D,_,T,I=!1)=>{let O=L+D,X=B+_;return T&&_!==0&&(_>0&&X>=e.length?(X=0,O++):_<0&&X<0&&(X=e.length-1,O--)),!T&&(X<0||X>=e.length)||O<(I?-1:0)||O>=t.length?null:{r:O,c:X}},K=(L,B,D,_,T,I=!1)=>{let O=L,X=B,te=0;const Z=t.length*e.length+e.length;for(;te<Z;){if(te++,O+=D,X+=_,_!==0)_>0?X>=e.length&&(X=0,O++):X<0&&(X=e.length-1,O--);else if(X<0||X>=e.length)return null;if(O<-1||O>=t.length)return null;if(O===-1){if(!I)continue;const Y=e[X],Q=Y.sortable!==!1;if(["__checkbox_col__"].includes(Y.field)||Q)return{r:O,c:X};continue}const ce=t[O],le=e[X],G=["__checkbox_col__","__expand_col__","__reorder_col__"].includes(le.field);let R=le.editable||G;if(w&&!G)try{R=w({row:ce,field:le.field,value:ce[le.field],colDef:le,rowIndex:O,colIndex:X})}catch{}if(R)return{r:O,c:X}}return null};let W=b,$=F,H=!1;if(k.key==="Tab"){const L=k.shiftKey?-1:1,B=K(b,F,0,L,!0,!1);B&&(W=B.r,$=B.c,H=!0)}else if(k.key==="ArrowRight"){const L=z(b,F,0,1,!0,!0);L&&(W=L.r,$=L.c,H=!0)}else if(k.key==="ArrowLeft"){const L=z(b,F,0,-1,!0,!0);L&&(W=L.r,$=L.c,H=!0)}else if(k.key==="ArrowDown"){const L=z(b,F,1,0,!1,!0);L&&(W=L.r,$=L.c,H=!0)}else if(k.key==="ArrowUp"){const L=z(b,F,-1,0,!1,!0);L&&(W=L.r,$=L.c,H=!0)}else if(k.key==="Home")$=0,(k.ctrlKey||k.metaKey)&&(W=-1),H=!0;else if(k.key==="End")$=e.length-1,(k.ctrlKey||k.metaKey)&&(W=t.length-1),H=!0;else if(k.key==="PageUp")W=Math.max(-1,W-(x?g:10)),H=!0;else if(k.key==="PageDown"){const L=x?g:10;W=Math.min(t.length-1,W+L),H=!0}if(H&&(k.preventDefault(),j&&k.key==="Tab"&&d.stopCellEdit(),W>=-1&&W<t.length&&$>=0&&$<e.length)){const L=e[$];m(W===-1?{id:"HEADER",field:L.field}:{id:t[W].id,field:L.field});const B=h.current;if(B){const{cumulativeHeights:D,pinnedBottomHeight:_,columnMetrics:T}=f,{clientWidth:I,scrollLeft:O}=B;if(W>=0&&Mn(B,W-v,D,_),T){const{leftPinnedWidth:X,rightPinnedWidth:te,unpinnedAccWidths:Z,unpinnedCols:ce,totalSpecialsWidth:le,pinnedSpecialsWidth:G}=T,R=ce.findIndex(Y=>Y.field===L.field);if(R!==-1){const Y=le+X+(R>0?Z[R-1]:0),Q=le+X+Z[R],J=O+G+X,re=O+I-te;let q=O;Y<J?q=Math.max(0,Y-G-X):Q>re&&(q=Q-I+te),q!==O&&(B.scrollLeft=q)}}}}},[E,t,e,d,f,i,l,a,c,u,p,w,x,g,h,v]);return{focusedCell:E,setFocusedCell:m,handleFocus:y,handleBlur:M,handleKeyDown:N}}const jo={rowFields:[],columnFields:[],valueFields:[]};function Eo(n){const{initialState:t,sortModel:e,aggregationModel:o,onAggregationModelChange:i,columnVisibilityModel:l,onColumnVisibilityModelChange:a,pinnedColumns:d,onPinnedColumnsChange:c,pivotModel:u,onPivotModelChange:p,paginationModel:w,onPaginationModelChange:x,rowSelectionModel:g}=n,[f,h]=s.useState(()=>t?.sorting?.sortModel??[]),v=e!==void 0,E=v?e:f,m=o!==void 0,[y,M]=s.useState(()=>o??{}),N=m?o:y,k=s.useCallback(R=>{m||M(R),i?.(R)},[m,i]),C=l!==void 0,[S,j]=s.useState(()=>t?.columns?.columnVisibilityModel??{}),P=C?l:S,b=s.useCallback(R=>{C||j(R),a?.(R)},[C,a]),F=d!==void 0,[z,K]=s.useState(()=>t?.columns?.pinnedColumns??{}),W=F?d:z,$=s.useCallback(R=>{F||K(R),c?.(R)},[F,c]),[H,L]=s.useState(()=>u??jo),B=u??H,D=s.useCallback(R=>{L(R),p?.(R)},[p]),_=w!==void 0,[T,I]=s.useState(()=>t?.pagination?.paginationModel??w??{page:0,pageSize:100}),O=_?w:T,X=s.useCallback(R=>{_||I(R),x?.(R)},[_,x]),te=g!==void 0,[Z,ce]=s.useState([]),le=te?g:Z,G=s.useMemo(()=>new Set(le),[le]);return{sortModel:E,isSortControlled:v,setInternalSortModel:h,aggregationModel:N,handleAggregationModelChange:k,columnVisibilityModel:P,handleColumnVisibilityModelChange:b,pinnedColumns:W,handlePinnedColumnsChange:$,currentPivotModel:B,handlePivotModelChange:D,effectivePaginationModel:O,handlePaginationModelChange:X,rowSelectionModel:le,selectedRowIds:G,isSelectionControlled:te,setInternalRowSelectionModel:ce}}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 Mo(n,t){const{field:e,operator:o,value:i}=t,l=n[e],a=No[o];return a?a(l,i):(console.warn(`Unknown filter operator: ${o}`),!0)}function Po(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 nn(n,t){const e=t.items??[],o=t.logicOperator??"and",i=("quickFilterValues"in t?t.quickFilterValues:void 0)??[];if(i.length>0&&!Po(n,i))return!1;if(e.length===0)return!0;const l=a=>{if("logicOperator"in a&&"items"in a){const d=a,c=d.items;return c.length===0?!0:d.logicOperator==="and"?c.every(l):c.some(l)}else return Mo(n,a)};return o==="and"?e.every(l):e.some(l)}function Ro(n,t){if(!t)return n;const{items:e=[],quickFilterValues:o=[]}=t;return e.length===0&&(!o||o.length===0)?n:n.filter(i=>nn(i,t))}function To(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 on(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 Io(n,t){if(t.length===0)return n;const e=[...n];return e.sort((o,i)=>{for(const l of t){const a=o[l.field],d=i[l.field],c=on(a,d,l.sort);if(c!==0)return c}return 0}),e}function Lo(n){const{effectiveRows:t,activeHierarchyHandlers:e,filterMode:o,filterModel:i,dataSource:l,sortModel:a,sortingMode:d,pagination:c,paginationMode:u,effectivePaginationModel:p,pinnedRows:w,isLoading:x,pageSize:g}=n,f=s.useMemo(()=>e?e.getVisibleRows()||[]:o==="server"&&l?t:Ro(t,i),[t,i,e,o,l]),{top:h,center:v,bottom:E}=s.useMemo(()=>e?{top:[],center:f,bottom:[]}:yo(f,w),[f,w,e]),m=s.useMemo(()=>e||d==="server"&&l?v:Io(v,a),[v,a,e,d,l]),y=s.useMemo(()=>{if(!c||u==="server"&&l)return m;const N=p.page*p.pageSize;return m.slice(N,N+p.pageSize)},[m,c,p.page,p.pageSize,u,l]),M=s.useMemo(()=>{if(e)return v;const N=c?y:m,k=[...h,...N,...E];if(u==="infinite"&&x&&k.length>0){const C=Math.min(g,20),S=Array.from({length:C},(j,P)=>({id:`__skeleton_${P}__`,_isSkeleton:!0}));return[...k,...S]}return k},[h,y,m,E,c,e,v,u,x,g]);return{filteredRows:f,pinnedTopRows:h,unpinnedRows:v,pinnedBottomRows:E,sortedUnpinnedRows:m,paginatedUnpinnedRows:y,allRenderableRows:M}}function Fo(n){const{layout:t,scrollTop:e,scrollLeft:o,viewportWidth:i,viewportHeight:l,autoHeight:a,rowReordering:d,hasDetailPanel:c,checkboxSelection:u,pinCheckboxColumn:p,pinExpandColumn:w,overscanRows:x=5}=n;return s.useMemo(()=>{const{unpinnedAccWidths:g,unpinnedColsWithWidth:f,leftPinnedCols:h,rightPinnedCols:v,totalWidth:E,leftWidth:m,rightWidth:y,unpinnedTotalWidth:M,systemColumnsWidth:N,cumulativeHeights:k,pinnedTopHeight:C,pinnedBottomHeight:S,unpinnedRowsHeight:j,rowHeights:P,unpinnedRowsLength:b}=t,F=i||1e3,z=a?C+j+S+50:l||600,K=6,W=Math.max(0,o-m),$=o+F-m;let H=0,L=f.length-1,B=0,D=g.length-1;for(;B<=D;){const Q=B+D>>>1;g[Q]<W?B=Q+1:D=Q-1}H=Math.max(0,B-K);for(let Q=H;Q<g.length;Q++){if((Q===0?0:g[Q-1])>$){L=Math.min(f.length-1,Q+K);break}L=Math.min(f.length-1,Q+K)}const _=H>0?g[H-1]:0,T=M-g[L],I=[...h,..._>0?[{field:"__spacer_left__",width:_,isSpacer:!0}]:[],...f.slice(H,L+1),...T>0?[{field:"__spacer_right__",width:T,isSpacer:!0}]:[],...v],X=F>0&&E>F?16:0,te=C+j+S+X+2;let Z=0,ce=b-1,le=0,G=0,R=k.length-1;for(;G<=R;){const Q=G+R>>>1;k[Q]<e?G=Q+1:R=Q-1}Z=Math.max(0,G-x),le=Z>0?k[Z-1]:0;for(let Q=Z;Q<k.length;Q++)if(k[Q]>=e+z){ce=Math.min(b-1,Q+x);break}const Y=(d?48:0)+(c&&w?48:0)+(u&&p?48:0);return{renderContext:{firstRowIndex:Z,lastRowIndex:ce,firstColumnIndex:H,lastColumnIndex:L},offsetTop:le,offsetLeft:0,totalHeight:te,pinnedTopHeight:C,pinnedBottomHeight:S,totalWidth:E,rowHeights:P,cumulativeHeights:k,virtualColumns:I,columnMetrics:{leftPinnedWidth:m,rightPinnedWidth:y,unpinnedAccWidths:g,unpinnedCols:f,totalSpecialsWidth:N,pinnedSpecialsWidth:Y}}},[t,e,o,i,l,a,d,c,u,p,w,x])}function Oo(n){const{columns:t,onColumnOrderChange:e,disableColumnReorder:o=!1}=n,[i,l]=s.useState(null),[a,d]=s.useState(null),c=s.useRef(-1),u=s.useCallback(g=>f=>{if(o)return;const h=t.findIndex(E=>E.field===g);if(t[h]?.pinnable===!1){f.preventDefault();return}l(g),c.current=h,f.dataTransfer&&(f.dataTransfer.effectAllowed="move",f.dataTransfer.setData("text/plain",g))},[t,o]),p=s.useCallback(g=>f=>{o||!i||(f.preventDefault(),f.dataTransfer.dropEffect="move",d(g))},[i,o]),w=s.useCallback(g=>f=>{if(f.preventDefault(),o||!i||i===g){l(null),d(null);return}const h=t.findIndex(m=>m.field===i),v=t.findIndex(m=>m.field===g);if(h===-1||v===-1){l(null),d(null);return}const E=t[h];e&&e({column:E,oldIndex:h,targetIndex:v}),l(null),d(null),c.current=-1},[t,i,o,e]),x=s.useCallback(()=>{l(null),d(null),c.current=-1},[]);return{draggedColumn:i,dragOverColumn:a,onDragStart:o?void 0:u,onDragOver:o?void 0:p,onDragEnd:o?void 0:x,onDrop:o?void 0:w}}function Pn({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"})})})}const rn=n=>n.formattedValue??n.value;function Wo(n){const{activeColumns:t,isHierarchyEnabled:e,isRowGrouping:o,isTreeData:i,activeHierarchyHandlers:l,columnVisibilityModel:a,columnOrder:d,onColumnOrderChange:c,disableColumnReorder:u,pivotMode:p,checkboxSelection:w,hasDetailPanel:x,rowReordering:g,initialState:f,setColumns:h}=n,v=s.useMemo(()=>e?t.map((b,F)=>F===0?{...b,renderCell:z=>{const K=z.rowMeta,W=K?.treeDepth??0,$=!!K?.hasChildren,H=!!K?.isExpanded,L=K?.groupingField,B=K?.groupingValue,D=K?.descendantCount,_=!!K?.isGroupRow;let T=b.renderCell?b.renderCell(z):rn(z);if(i&&$&&_&&(T=r.jsxs("div",{className:"ogx__group-cell-content",children:[z.value,D!==void 0&&D>0?` (${D})`:""]})),o&&$&&L){const I=K?.groupLabel??`${L}: ${String(B)}`;T=r.jsxs("div",{className:"ogx__group-cell-content",children:[I,D!==void 0?` (${D})`:""]})}return r.jsxs("div",{style:{display:"flex",alignItems:"center",paddingLeft:W*24,width:"100%",height:"100%"},children:[r.jsx("div",{style:{marginRight:4,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",cursor:$?"pointer":"default",flexShrink:0},children:$?r.jsx("div",{onClick:I=>{I.stopPropagation(),I.preventDefault(),l?.toggleExpansion(z.row.id)},onMouseDown:I=>{I.stopPropagation()},style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:10,position:"relative"},children:r.jsx(Pn,{isExpanded:H,onClick:I=>{I.stopPropagation(),I.preventDefault(),l?.toggleExpansion(z.row.id)}})}):null}),r.jsx("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:T})]})}}:{...b,renderCell:z=>{const K=z.rowMeta,W=!!K?.hasChildren,$=K?.groupingField;return o&&W?b.field===$?null:z.value!==void 0&&z.value!==null?b.renderCell?b.renderCell(z):rn(z):null:b.renderCell?b.renderCell(z):rn(z)}}):t,[t,e,o,i,l]),[E,m]=s.useState(()=>f?.columns?.columnWidths??{}),y=s.useCallback((b,F)=>{m(z=>({...z,[b]:F}))},[]),[M,N]=s.useState(()=>f?.columns?.columnOrder??t.map(b=>b.field)),k=d??M;s.useEffect(()=>{h(t)},[t,h]),s.useEffect(()=>{p&&N(t.map(b=>b.field))},[p,t]);const C=s.useMemo(()=>{if(u)return v;const b=new Map(k.map((F,z)=>[F,z]));return[...v].sort((F,z)=>{const K=b.get(F.field)??v.indexOf(F),W=b.get(z.field)??v.indexOf(z);return K-W})},[v,k,u]),S=s.useMemo(()=>C.filter(b=>a[b.field]!==!1),[C,a]),j=Oo({columns:C,onColumnOrderChange:s.useCallback(b=>{const{oldIndex:F,targetIndex:z}=b,K=[...k],[W]=K.splice(F,1);K.splice(z,0,W),d||N(K),c?.(b)},[k,d,c]),disableColumnReorder:u}),P=s.useMemo(()=>{const b=[];return g&&b.push({field:"__reorder_col__"}),x&&b.push({field:"__expand_col__"}),w&&b.push({field:"__checkbox_col__"}),[...b,...C]},[C,w,x,g]);return{effectiveColumns:v,orderedColumns:C,visibleOrderedColumns:S,navigationColumns:P,columnWidths:E,effectiveColumnOrder:k,setInternalColumnOrder:N,columnReorderHandlers:j,handleColumnResize:y}}function Ao(n){const{renderContext:t,pinnedTopRows:e,pinnedBottomRows:o,paginatedUnpinnedRows:i,sortedUnpinnedRows:l,pagination:a}=n;return s.useMemo(()=>{const{firstRowIndex:d,lastRowIndex:c}=t,u=a?i:l,p=e.length,w=e.map((m,y)=>({row:m,rowIndex:y})),x=o.map((m,y)=>({row:m,rowIndex:p+u.length+y})),g=Math.max(0,d),f=Math.min(u.length,c+1),h=u.slice(g,f).map((m,y)=>({row:m,rowIndex:p+g+y})),v=[...w,...h,...x],E=new Set;return v.filter(m=>E.has(m.row.id)?!1:(E.add(m.row.id),!0))},[t,e,o,i,l,a])}function $o(n,t){let e;return n<.5?e=3:n<3?e=5:n<15?e=12:n<40?e=20:e=30,Math.max(e,t)}function zo(n){const{onRowsScrollEnd:t,overscanRowCount:e=3}=n,o=s.useRef({scrollTop:0,scrollLeft:0,velocity:0}),i=s.useRef({scrollTop:0,scrollLeft:0,time:0}),l=s.useRef(null),a=s.useRef(null),[d,c]=s.useState({scrollTop:0,scrollLeft:0,overscanRows:e});s.useEffect(()=>()=>{l.current!==null&&cancelAnimationFrame(l.current),a.current!==null&&clearTimeout(a.current)},[]);const u=s.useCallback(p=>{const w=p.currentTarget,x=performance.now(),g=Math.abs(w.scrollTop-i.current.scrollTop)+Math.abs(w.scrollLeft-i.current.scrollLeft),f=x-i.current.time,h=f>0?g/f:0;if(i.current={scrollTop:w.scrollTop,scrollLeft:w.scrollLeft,time:x},o.current={scrollTop:w.scrollTop,scrollLeft:w.scrollLeft,velocity:h},l.current!==null&&cancelAnimationFrame(l.current),l.current=requestAnimationFrame(()=>{l.current=null;const{scrollTop:v,scrollLeft:E,velocity:m}=o.current;c({scrollTop:v,scrollLeft:E,overscanRows:$o(m,e)})}),a.current!==null&&clearTimeout(a.current),a.current=setTimeout(()=>{a.current=null,c(v=>({...v,overscanRows:e}))},200),t){const{scrollTop:v,scrollHeight:E,clientHeight:m}=w;E-v-m<100&&t({visibleTop:v,visibleBottom:v+m,viewportHeight:m})}},[t,e]);return{scrollTop:d.scrollTop,scrollLeft:d.scrollLeft,overscanRows:d.overscanRows,handleScroll:u}}function Bo(n){const{onStateChange:t,sortModel:e,filterModel:o,effectivePaginationModel:i,columnWidths:l,effectiveColumnOrder:a,columnVisibilityModel:d,pinnedColumns:c}=n,u=s.useRef(t);s.useLayoutEffect(()=>{u.current=t}),s.useEffect(()=>{if(!u.current)return;const p={sorting:{sortModel:e},filter:{filterModel:o},pagination:{paginationModel:i},columns:{columnWidths:l,columnOrder:a,columnVisibilityModel:d,pinnedColumns:c}};u.current(p)},[e,o,i,l,a,d,c])}const Do=200;function Ho(n){const{paginationRequested:t,isRowGrouping:e,autoHeight:o,viewportHeight:i,renderedRowCount:l,totalRowCount:a}=n,d=s.useRef(!1),c=s.useRef(!1);s.useEffect(()=>{process.env.NODE_ENV==="production"||d.current||t&&e&&(d.current=!0,console.warn("[OpenGridX] `pagination` is ignored while `rowGroupingModel` is active — all group rows render in one scrollable view. Give the grid a bounded height so it virtualizes. See docs/features/tree-data-grouping.md."))},[t,e]),s.useEffect(()=>{process.env.NODE_ENV==="production"||c.current||o||i>0&&a>Do&&l>=a&&(c.current=!0,console.warn(`[OpenGridX] The grid viewport is ${Math.round(i)}px tall and is rendering all ${a} rows, so row virtualization is effectively off. The grid container has no bounded height: it grows to fit its content. Give it a fixed height, or if it is a flex child add \`min-height: 0\`. See docs/features/virtualization.md.`))},[o,i,l,a])}const Ot=n=>{const t=[];for(const e of n){if(e==null)continue;const o=Number(e);isNaN(o)||t.push(o)}return t},Vo=n=>{if(n.length===0)return null;let t=n[0];for(let e=1;e<n.length;e++)n[e]<t&&(t=n[e]);return t},Go=n=>{if(n.length===0)return null;let t=n[0];for(let e=1;e<n.length;e++)n[e]>t&&(t=n[e]);return t},Uo={sum:n=>Ot(n).reduce((t,e)=>t+e,0),avg:n=>{const t=Ot(n);return t.length?t.reduce((e,o)=>e+o,0)/t.length:null},count:n=>n.filter(t=>t!=null).length,min:n=>Vo(Ot(n)),max:n=>Go(Ot(n)),unique:n=>new Set(n.filter(t=>t!=null)).size};function Rn(n,t,e,o){const i={};for(const[l,a]of Object.entries(t)){const d=e.get(l);if(d?.availableAggregationFunctions&&!d.availableAggregationFunctions.includes(a))continue;const c=Uo[a];if(!c){console.warn(`[${o}] Unknown aggregation function: "${a}"`);continue}i[l]=c(n.map(u=>u[l]))}return i}function ve(n,t){return n==null?"—":typeof n=="number"?t==="avg"?n.toLocaleString(void 0,{maximumFractionDigits:2}):n.toLocaleString():String(n)}function Tn(n){const{rows:t,columns:e,aggregationModel:o,isServerSide:i,dataSource:l,filterModel:a,sortModel:d,serverAggregationResults:c}=n,u=s.useMemo(()=>{const M=new Map;return(e??[]).forEach(N=>M.set(N.field,N)),M},[e]),p=s.useMemo(()=>i||Object.keys(o).length===0?{}:Rn(t,o,u,"useAggregation"),[t,u,o,i]),[w,x]=s.useState({}),[g,f]=s.useState(!1),[h,v]=s.useState(null),E=s.useRef(0),m=s.useCallback(async()=>{if(!l?.getAggregations||Object.keys(o).length===0)return;const M=++E.current;f(!0),v(null);try{const N=await l.getAggregations({sortModel:d??[],filterModel:a??{items:[]},groupKeys:[],aggregationModel:o});M===E.current&&x(N)}catch(N){M===E.current&&(v(N),console.error("[useAggregation] Server aggregation error:",N))}finally{M===E.current&&f(!1)}},[l,o,a,d]);return s.useEffect(()=>{i&&l?.getAggregations&&!c&&m()},[m,i,l,c]),{aggregationResult:s.useMemo(()=>i?c&&Object.keys(c).length>0?c:w:p,[i,p,c,w]),isLoading:g,error:h}}function Ko({columns:n,aggregationModel:t,aggregationResult:e,columnWidths:o,rowHeight:i,checkboxSelection:l,hasDetailPanel:a,rowReordering:d,pinnedColumns:c}){const u=s.useMemo(()=>en(n,o,c,l,!0,a,!0,d),[n,o,c,l,a,d]),p=c?.left?.[c.left.length-1],w=c?.right?.[0];return r.jsxs("div",{className:"ogx__aggregation-footer",role:"row","aria-label":"Aggregation totals","aria-live":"polite",style:{minHeight:`${i}px`},children:[l&&r.jsx("div",{style:{width:48,flexShrink:0}}),a&&r.jsx("div",{style:{width:48,flexShrink:0}}),d&&r.jsx("div",{style:{width:48,flexShrink:0}}),n.map(x=>{const g=t[x.field],f=e[x.field],h=o[x.field]??(typeof x.width=="number"?x.width:120),v=wt(x.field,c),E=v?u[x.field]:void 0,m=["ogx__aggregation-cell",v==="left"&&"ogx__aggregation-cell--pinned-left",v==="right"&&"ogx__aggregation-cell--pinned-right",v==="left"&&x.field===p&&"ogx__aggregation-cell--pinned-left-last",v==="right"&&x.field===w&&"ogx__aggregation-cell--pinned-right-first"].filter(Boolean).join(" "),y={width:h,minWidth:h,maxWidth:h,textAlign:x.align||"left"};return v==="left"&&E!==void 0&&(y.left=E),v==="right"&&E!==void 0&&(y.right=E),r.jsx("div",{className:m,role:"gridcell",style:y,children:g?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"ogx__aggregation-label",children:g}),r.jsx("span",{className:"ogx__aggregation-value",children:ve(f,g)})]}):null},x.field)})]})}function Yo({noRowsLabel:n,width:t,overlay:e}){return e?r.jsx("div",{className:"ogx__empty",style:{width:t},children:e}):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 qo({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 bt=({indeterminate:n=!1,label:t,className:e="",inputRef:o,...i})=>{const l=s.useRef(null),a=s.useCallback(c=>{l.current=c,typeof o=="function"?o(c):o&&(o.current=c)},[o]);s.useEffect(()=>{l.current&&(l.current.indeterminate=n)},[n]);const d=["ogx-checkbox-wrapper",i.disabled&&"ogx-checkbox-wrapper--disabled",e].filter(Boolean).join(" ");return r.jsxs("label",{className:d,children:[r.jsx("input",{ref:a,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 Xo(n){const{field:t,currentWidth:e,onResize:o,minWidth:i=50,maxWidth:l=1e3}=n,[a,d]=s.useState(!1),c=s.useRef(0),u=s.useRef(0),p=s.useCallback(g=>{g.preventDefault(),g.stopPropagation(),d(!0),c.current=g.clientX,u.current=e;let f=0;const h=16,v=m=>{const y=m.clientX-c.current,M=Math.max(i,Math.min(l,u.current+y)),N=Date.now();N-f>=h&&(o(t,M),f=N)},E=m=>{d(!1);const y=m.clientX-c.current,M=Math.max(i,Math.min(l,u.current+y));o(t,M),document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",E)};document.addEventListener("mousemove",v),document.addEventListener("mouseup",E)},[t,e,o,i,l]),w=s.useCallback(g=>{g.preventDefault(),g.stopPropagation()},[]),x=["ogx-column-resize-handle",a&&"ogx-column-resize-handle--dragging"].filter(Boolean).join(" ");return r.jsx("div",{className:x,onMouseDown:p,onClick:g=>g.stopPropagation(),onDragStart:g=>{g.preventDefault(),g.stopPropagation()},onDoubleClick:w,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${t} column`,children:r.jsx("div",{className:"ogx-column-resize-handle__line"})})}function Qe(){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 Ze(){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 Jo(){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 Qo(){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 Zo(){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 er(){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 tr(){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 nr(){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 or(){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 rr(){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 ir({colDef:n,sortModel:t,onSort:e,onHide:o,onPin:i,pinnedColumns:l,onManageColumns:a,onClose:d,anchorEl:c}){const u=s.useRef(null),[p,w]=s.useState({position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"});s.useLayoutEffect(()=>{if(!c||!u.current)return;const N=c.getBoundingClientRect(),k=u.current.getBoundingClientRect(),C=window.innerWidth,S=window.innerHeight,j=8;let P=N.left;P+k.width+j>C&&(P=C-k.width-j),P<j&&(P=j);let b=N.bottom+4;b+k.height+j>S&&(b=N.top-k.height-4),w({position:"fixed",zIndex:1300,top:b,left:P,visibility:"visible"})},[c]),s.useEffect(()=>{function N(C){u.current&&!u.current.contains(C.target)&&c&&!c.contains(C.target)&&d()}function k(C){C.key==="Escape"&&d()}return document.addEventListener("mousedown",N),document.addEventListener("keydown",k),window.addEventListener("scroll",d,!0),window.addEventListener("resize",d),()=>{document.removeEventListener("mousedown",N),document.removeEventListener("keydown",k),window.removeEventListener("scroll",d,!0),window.removeEventListener("resize",d)}},[c,d]);const x=N=>{e?.(n.field,N),d()},g=()=>{o?.(n.field),d()},f=N=>{i?.(n.field,N),d()},h=t?.find(N=>N.field===n.field)?.sort,v=h==null,E=l?.left?.includes(n.field)??!1,m=l?.right?.includes(n.field)??!1,y=!E&&!m,M=n.headerName||n.field;return Ve.createPortal(r.jsxs("div",{ref:u,className:"ogx-column-menu",style:p,role:"menu","aria-label":`Column options for ${M}`,children:[e&&n.sortable!==!1&&r.jsxs(r.Fragment,{children:[r.jsxs("button",{className:`ogx-menu-item${h==="asc"?" ogx-menu-item--active":""}`,onClick:()=>x("asc"),role:"menuitemradio","aria-checked":h==="asc",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:h==="asc"?r.jsx(Qe,{}):r.jsx(Ze,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(Qo,{})}),"Sort Ascending"]}),r.jsxs("button",{className:`ogx-menu-item${h==="desc"?" ogx-menu-item--active":""}`,onClick:()=>x("desc"),role:"menuitemradio","aria-checked":h==="desc",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:h==="desc"?r.jsx(Qe,{}):r.jsx(Ze,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(Zo,{})}),"Sort Descending"]}),r.jsxs("button",{className:`ogx-menu-item${v?" ogx-menu-item--active":""}`,onClick:()=>x(null),role:"menuitemradio","aria-checked":v,children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:v?r.jsx(Qe,{}):r.jsx(Ze,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(er,{})}),"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${E?" ogx-menu-item--active":""}`,onClick:()=>f("left"),role:"menuitemradio","aria-checked":E,"aria-label":"Pin to left",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:E?r.jsx(Qe,{}):r.jsx(Ze,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(nr,{})}),"Pin to Left"]}),r.jsxs("button",{className:`ogx-menu-item${m?" ogx-menu-item--active":""}`,onClick:()=>f("right"),role:"menuitemradio","aria-checked":m,"aria-label":"Pin to right",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:m?r.jsx(Qe,{}):r.jsx(Ze,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(or,{})}),"Pin to Right"]}),r.jsxs("button",{className:`ogx-menu-item${y?" ogx-menu-item--active":""}`,onClick:()=>f(null),role:"menuitemradio","aria-checked":y,"aria-label":"Unpin column",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:y?r.jsx(Qe,{}):r.jsx(Ze,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(rr,{})}),"Unpin"]}),r.jsx("div",{className:"ogx-menu-divider"}),r.jsxs("button",{className:"ogx-menu-item",onClick:g,role:"menuitem","aria-label":`Hide ${M} 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(tr,{})}),"Hide Column"]}),r.jsx("div",{className:"ogx-menu-divider"}),r.jsxs("button",{className:"ogx-menu-item",onClick:()=>{a?.(),d()},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(Jo,{})}),"Manage columns"]})]}),c?.closest(".ogx-theme-provider")||document.body)}function lr(){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 sr(){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 In(n){const t=[];for(const e of n.children)typeof e=="string"?t.push(e):t.push(...In(e));return t}function ar(n){let t=0;function e(o,i){t=Math.max(t,i);for(const l of o.children)typeof l!="string"&&e(l,i+1)}return n.forEach(o=>e(o,1)),t}function dr(n,t,e){function o(d,c,u){if(!In(d).includes(c))return null;if(u===e)return d;for(const p of d.children)if(typeof p!="string"){const w=o(p,c,u+1);if(w)return w}return null}const i=new Map;for(const d of t){let c=null;for(const u of n)if(c=o(u,d.field,0),c)break;i.set(d.field,c)}const l=[];let a=0;for(;a<t.length;){const d=t[a],c=i.get(d.field)??null,u=d.width;if(!c)l.push({key:`fg-${d.field}-${e}`,label:"",width:u,isGroup:!1}),a++;else{let p=0,w=a;for(;w<t.length&&i.get(t[w].field)===c;)p+=t[w].width,w++;l.push({key:`${c.groupId}-${e}`,label:c.headerName,width:p,isGroup:!0}),a=w}}return l}function Ln(n){const{columns:t,allColumns:e,columnGroupingModel:o,checkboxSelection:i=!1,allSelected:l=!1,someSelected:a=!1,onSelectAll:d,onSort:c,sortModel:u=[],onColumnResize:p,columnWidths:w={},pinnedColumns:x,hasDetailPanel:g=!1,pinCheckboxColumn:f=!0,pinExpandColumn:h=!0,rowReordering:v=!1,aggregationModel:E,draggedColumn:m,dragOverColumn:y,onDragStart:M,onDragOver:N,onDragEnd:k,onDrop:C,focusedCell:S,onHeaderClick:j,onSortAdd:P,multiSort:b=!1,onHideColumn:F,onPinColumn:z,onManageColumns:K}=n,W=s.useId(),$=s.useRef({}),[H,L]=s.useState(null),B=R=>Y=>{Y.stopPropagation(),L({colDef:R,anchorEl:Y.currentTarget})},D=()=>{L(null)};s.useLayoutEffect(()=>{if(S?.id==="HEADER"){const R=$.current[S.field];R&&R.focus()}},[S]);const _=R=>Y=>{if(R.sortable===!1)return;const Q=u.find(re=>re.field===R.field);let J="asc";Q&&(Q.sort==="asc"?J="desc":J=null),(Y.shiftKey||b)&&P?P(R.field,J):c&&c(R.field,J)},T=R=>{const Y=u.find(J=>J.field===R);if(!Y)return null;const Q=u.length>1?u.indexOf(Y)+1:null;return r.jsx("span",{className:`ogx__sort-icon ogx__sort-icon--${Y.sort}`,"aria-hidden":"true",children:Q!==null&&r.jsx("span",{className:"ogx__sort-badge",children:Q})})},I=s.useMemo(()=>en(t,w,x,i,f,g,h,v),[t,w,x,i,f,g,h,v]),O=o?ar(o):0,te=(e??t).filter(R=>!R.isSpacer).map(R=>({field:R.field,width:w[R.field]??R.width??100})),G=(v?48:0)+(g?48:0)+(i?48:0);return r.jsxs("div",{className:"ogx__header-wrap",children:[O>0&&Array.from({length:O},(R,Y)=>{const Q=dr(o,te,Y);return r.jsxs("div",{className:"ogx-col-group-row",role:"row",children:[G>0&&r.jsx("div",{className:"ogx-col-group-cell ogx-col-group-cell--filler",style:{width:G,minWidth:G,flexShrink:0},role:"columnheader"}),Q.map(J=>r.jsx("div",{role:"columnheader",className:`ogx-col-group-cell ${J.isGroup?"ogx-col-group-cell--group":"ogx-col-group-cell--filler"}`,style:{width:J.width,minWidth:J.width,flexShrink:0},title:J.isGroup?J.label:void 0,children:J.isGroup&&r.jsx("span",{className:"ogx-col-group-cell__label",children:J.label})},J.key))]},`ogx-grp-${Y}`)}),r.jsxs("div",{className:"ogx__header",role:"row",children:[v&&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}}),g&&r.jsx("div",{className:`ogx__header-cell ogx__header-cell--expand ${h?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""}`,role:"columnheader","aria-label":"Expand row details",style:{minWidth:48,maxWidth:48,position:h?"sticky":void 0,left:h?v?48:0:void 0,zIndex:h?5:void 0}}),i&&r.jsx("div",{className:`ogx__header-cell ogx__header-cell--checkbox ${f?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""}`,role:"columnheader",style:{position:f?"sticky":void 0,left:f?(v?48:0)+(g&&h?48:0):void 0},children:r.jsx(bt,{id:W,name:W,checked:l,indeterminate:a,onChange:R=>d?.(R.target.checked),"aria-label":l?"Deselect all rows":"Select all rows",tabIndex:S?.id==="HEADER"&&S.field==="__checkbox_col__"?0:-1,onMouseDown:R=>R.preventDefault(),inputRef:R=>{$.current.__checkbox_col__=R}})}),t.map((R,Y)=>{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,J=u.some(oe=>oe.field===R.field),re=R.resizable!==!1,q=wt(R.field,x),V=q!==null,A=m===R.field,ee=y===R.field,ie=["ogx__header-cell",`ogx__header-cell--align-${R.headerAlign||R.align||"left"}`,Q&&"ogx__header-cell--sortable",J&&"ogx__header-cell--sorted",V&&"ogx__header-cell--pinned",V&&`ogx__header-cell--pinned-${q}`,A&&"ogx__header-cell--dragging",ee&&"ogx__header-cell--drag-over",S?.id==="HEADER"&&S.field===R.field&&"ogx__header-cell--focused",R.headerClassName].filter(Boolean).join(" "),ae=w[R.field]??R.width??100,fe={width:ae,minWidth:R.minWidth,maxWidth:R.maxWidth,flexGrow:R.flex??0,flexShrink:0,flexBasis:(R.flex,"auto"),boxSizing:"border-box",position:V?"sticky":"relative",zIndex:R.zIndex,opacity:A?.5:1};if(V&&q){const oe=I[R.field];q==="left"?fe.left=oe:fe.right=oe}const he=R.renderHeader?R.renderHeader({field:R.field,colDef:R,colIndex:Y}):R.headerName||R.field,Me=oe=>{if(oe.target.closest(".ogx-column-resize-handle")){oe.stopPropagation();return}j?.(R.field),Q&&_(R)(oe)},ke=M?M(R.field):void 0,Pe=N?N(R.field):void 0,Se=C?C(R.field):void 0;return r.jsxs("div",{className:ie,style:fe,title:R.description,onClick:Me,role:"columnheader",draggable:!!M,onDragStart:ke,onDragOver:Pe,onDragEnd:k,onDrop:Se,"aria-sort":Q?J?u.find(oe=>oe.field===R.field)?.sort==="asc"?"ascending":"descending":"none":void 0,"aria-colindex":Y+1+(i?1:0),"data-field":R.field,tabIndex:-1,ref:oe=>{$.current[R.field]=oe},children:[r.jsxs("div",{className:"ogx__header-cell-content",children:[A&&r.jsx("div",{className:"ogx__header-drag-icon",children:r.jsx(sr,{})}),r.jsxs("div",{className:"ogx__header-cell-title-wrapper",children:[r.jsx("span",{className:"ogx__header-cell-title",children:he}),E&&E[R.field]&&r.jsx("span",{className:"ogx__header-cell-aggregation",children:E[R.field]})]}),Q&&T(R.field),!R.disableColumnMenu&&r.jsx("button",{className:"ogx__menu-icon-btn",onClick:B(R),"aria-label":`Open column menu for ${R.headerName||R.field}`,"aria-haspopup":"menu",tabIndex:-1,children:r.jsx(lr,{})})]}),re&&p&&r.jsx(Xo,{field:R.field,currentWidth:ae,onResize:p,minWidth:R.minWidth,maxWidth:R.maxWidth})]},R.field)}),H&&r.jsx(ir,{colDef:H.colDef,sortModel:u,onSort:c,onHide:F,onPin:z,pinnedColumns:x,onManageColumns:K,onClose:D,anchorEl:H.anchorEl})]})]})}const vt=({variant:n="text",size:t="medium",color:e="default",disabled:o=!1,className:i="",children:l,...a})=>{const d=["ogx-button",`ogx-button--${n}`,`ogx-button--${t}`,`ogx-button--${e}`,o&&"ogx-button--disabled",i].filter(Boolean).join(" ");return r.jsx("button",{className:d,disabled:o,...a,children:l})};function Fn(n){const t=s.useId(),{page:e,pageSize:o,rowCount:i,onPageChange:l,onPageSizeChange:a,pageSizeOptions:d=[10,25,50,100],showFirstButton:c=!0,showLastButton:u=!0,localeText:p}=n,w=Math.max(1,Math.ceil(i/o)),x=Math.min(e,w-1),g=x*o,f=Math.min(g+o,i),h=i===0?0:`${g+1}–${f}`,v=p?.paginationRowsPerPage??"Rows per page:",E=p?.paginationOf?p.paginationOf(i===0?0:g+1,f,i):`${h} of ${i}`,m=p?.paginationPage?p.paginationPage(x+1,w):`Page ${x+1} of ${w}`,y=()=>{l(0)},M=()=>{l(Math.max(0,x-1))},N=()=>{l(Math.min(w-1,x+1))},k=()=>{l(w-1)},C=P=>{const b=parseInt(P.target.value,10);a(b)},S=x===0,j=x>=w-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:v}),r.jsx("select",{id:t,className:"ogx-pagination__select",value:o,onChange:C,"aria-label":"Rows per page",children:d.map(P=>r.jsx("option",{value:P,children:P},P))})]}),r.jsx("div",{className:"ogx-pagination__info","aria-live":"polite","aria-atomic":"true",children:E}),r.jsxs("div",{className:"ogx-pagination__actions",children:[c&&r.jsx(vt,{variant:"text",size:"small",onClick:y,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(vt,{variant:"text",size:"small",onClick:M,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.jsx("div",{className:"ogx-pagination__page-info","aria-current":"page",children:m}),r.jsx(vt,{variant:"text",size:"small",onClick:N,disabled:j,"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(vt,{variant:"text",size:"small",onClick:k,disabled:j,"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 cr(n,t,e={}){const o=new Map,i=[];n.forEach(d=>{o.set(d.id,d),i.push(d.id)});const l=new Map,a=[];return t.forEach(d=>{l.set(d.field,d),a.push(d.field)}),{rows:{idRowsLookup:o,allRows:i},columns:{all:t,lookup:l,orderedFields:a,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 ur(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,l=[];return o.forEach(a=>{i.set(a.id,a),l.push(a.id)}),{...n,rows:{idRowsLookup:i,allRows:l},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 fr(n){const{rows:t,columns:e,rowHeight:o=52,headerHeight:i=56,columnVisibilityModel:l,initialState:a}=n,[d]=s.useState(()=>cr(t,e,l)),[c,u]=s.useReducer(ur,{...d,sorting:a?.sorting||d.sorting,filter:a?.filter||d.filter,dataSource:a?.dataSource?{...d.dataSource,...a.dataSource}:d.dataSource,pagination:{...d.pagination,...a?.pagination||{},rowCount:n.rowCount??a?.pagination?.rowCount??d.pagination.rowCount},dimensions:{...d.dimensions,rowHeight:o,headerHeight:i}}),p=s.useRef(c);s.useLayoutEffect(()=>{p.current=c});const w=s.useRef(t);s.useEffect(()=>{t!==w.current&&(w.current=t,u({type:"SET_ROWS",payload:t}))},[t]);const x=s.useCallback((C,S)=>{u({type:"SET_ROWS",payload:C,preserveRowCount:S})},[]),g=s.useCallback(C=>{u({type:"SET_COLUMNS",payload:C})},[]),f=s.useCallback(C=>{u({type:"SET_SORT_MODEL",payload:C})},[]),h=s.useCallback(C=>{u({type:"SET_FILTER_MODEL",payload:C})},[]),v=s.useCallback(C=>{u({type:"SET_PAGINATION_MODEL",payload:C})},[]),E=s.useCallback(C=>{u({type:"SET_SELECTION",payload:C})},[]),m=s.useCallback((C,S)=>{u({type:"SET_DIMENSIONS",payload:{viewportWidth:C,viewportHeight:S}})},[]),y=s.useCallback(C=>{u({type:"SET_DATASOURCE_LOADING",payload:C})},[]),M=s.useCallback(C=>{u({type:"SET_DATASOURCE_ERROR",payload:C})},[]),N=s.useCallback(C=>{u({type:"SET_ROW_COUNT",payload:C})},[]),k=s.useRef({getRow:C=>p.current.rows.idRowsLookup.get(C)||null,getAllRows:()=>Array.from(p.current.rows.idRowsLookup.values()),getVisibleRows:()=>Array.from(p.current.rows.idRowsLookup.values()),getAllFilteredRows:()=>Array.from(p.current.rows.idRowsLookup.values()),getGroupedExportRows:()=>null,getAggregationResult:()=>null,getAggregationModel:()=>null,getColumn:C=>p.current.columns.lookup.get(C)||null,getAllColumns:()=>p.current.columns.all,getVisibleColumns:()=>p.current.columns.all,selectRow:(C,S=!0)=>{const j=new Set(p.current.selection.selectedRows);S?j.add(C):j.delete(C),E(j)},selectRows:(C,S=!0)=>{const j=new Set(p.current.selection.selectedRows);C.forEach(P=>{S?j.add(P):j.delete(P)}),E(j)},getSelectedRows:()=>Array.from(p.current.selection.selectedRows),sortColumn:(C,S)=>{if(S===null)f(p.current.sorting.sortModel.filter(j=>j.field!==C));else{const j=p.current.sorting.sortModel.findIndex(P=>P.field===C);if(j>=0){const P=[...p.current.sorting.sortModel];P[j]={field:C,sort:S},f(P)}else f([...p.current.sorting.sortModel,{field:C,sort:S}])}},getSortModel:()=>p.current.sorting.sortModel,setFilterModel:h,getFilterModel:()=>p.current.filter.filterModel,setPage:C=>{v({...p.current.pagination.paginationModel,page:C})},setPageSize:C=>{v({...p.current.pagination.paginationModel,pageSize:C,page:0})},scrollToIndexes:()=>{},copySelectedRows:()=>Promise.resolve()});return{state:c,dispatch:u,apiRef:k,setRows:x,setColumns:g,setSortModel:f,setFilterModel:h,setPaginationModel:v,setSelection:E,setDimensions:m,setDataSourceLoading:y,setDataSourceError:M,setRowCount:N}}function gr(n){const{onRowOrderChange:t,rows:e,getRowId:o,rowReordering:i=!1}=n,[l,a]=s.useState(null),[d,c]=s.useState(null),u=s.useCallback(f=>o?o(f):f.id,[o]),p=s.useCallback(f=>h=>{i&&(a(f),h.dataTransfer.effectAllowed="move")},[i]),w=s.useCallback(f=>h=>{!i||!l||(h.preventDefault(),h.dataTransfer.dropEffect="move",d!==f&&c(f))},[i,l,d]),x=s.useCallback(()=>{a(null),c(null)},[]),g=s.useCallback(f=>h=>{if(h.preventDefault(),!l||!t){x();return}const v=e.findIndex(m=>u(m)===l),E=e.findIndex(m=>u(m)===f);v!==-1&&E!==-1&&v!==E&&t({row:e[v],oldIndex:v,targetIndex:E}),x()},[l,t,e,u,x]);return{draggedRowId:l,dragOverRowId:d,onDragStart:i?p:void 0,onDragOver:i?w:void 0,onDragEnd:i?x:void 0,onDrop:i?g:void 0}}const On=new Map;function hr(n){const{rows:t,getRowId:e,getTreeDataPath:o,treeData:i=!1,defaultGroupingExpansionDepth:l=0,filterModel:a,sortModel:d,onRowExpansionChange:c}=n,{treeNodes:u,rootIds:p,groupingRows:w}=s.useMemo(()=>{if(!i||!o)return{treeNodes:new Map,rootIds:[],groupingRows:[]};const S=new Map,j=[],P=[],b=new Map,F=z=>z.join("/");return t.forEach(z=>{const K=e(z),W=o(z),$=F(W);b.set($,K),S.set(K,{id:K,parentId:null,depth:W.length-1,groupingKey:W[W.length-1],isExpanded:!1,children:[],serverChildrenCount:z.serverChildrenCount})}),t.forEach(z=>{const K=e(z),W=o(z);if(W.length===1){j.push(K);return}const $=L=>{if(L.length<=1)return;const B=L.slice(0,-1),D=F(B);let _=b.get(D);if(_===void 0&&(_=`auto-group-${D}`,!S.has(_))){const T=B[B.length-1];S.set(_,{id:_,parentId:null,depth:B.length-1,groupingKey:T,isExpanded:!1,children:[],label:T}),b.set(D,_);const I={id:_,name:T,_isGroupRow:!0};P.push(I),B.length===1&&j.push(_),$(B)}return _},H=$(W);if(H!==void 0){const L=S.get(H),B=S.get(K);L&&B&&(B.parentId=H,L.children=L.children||[],L.children.includes(K)||L.children.push(K))}}),P.forEach(z=>{const K=z.id,W=S.get(K);if(!W)return;const H=K.replace("auto-group-","").split("/");if(H.length>1){const L=H.slice(0,-1),B=F(L),D=b.get(B);if(D&&S.has(D)){W.parentId=D;const _=S.get(D);_&&(_.children=_.children||[],_.children.includes(K)||_.children.push(K))}}}),{treeNodes:S,rootIds:j,groupingRows:P}},[t,o,i,e]),x=`${i}|${l}`,[g,f]=s.useState(()=>({configKey:x,overrides:new Map})),h=g.configKey===x?g.overrides:On,v=s.useCallback(S=>!!(S?.children&&S.children.length>0)&&(l===-1||(S?.depth??0)<l),[l]),E=s.useMemo(()=>{const S=new Set;return i&&u.forEach((j,P)=>{(h.get(P)??v(j))&&S.add(P)}),S},[i,u,h,v]),m=s.useCallback(S=>{const j=!E.has(S);if(f(P=>{const b=P.configKey===x?P.overrides:On,F=new Map(b);return F.set(S,j),{configKey:x,overrides:F}}),j&&c){const P=u.get(S);P&&c(P)}},[E,x,u,c]),y=s.useCallback(()=>{if(!i)return null;const S=new Map;t.forEach($=>S.set(e($),$)),w.forEach($=>S.set($.id,$));const j=$=>a?nn($,a):!0,P=new Map,b=$=>{if(P.has($))return P.get($);const H=S.get($);if(!H)return!1;if(j(H))return P.set($,!0),!0;const B=u.get($);return B&&B.children&&B.children.some(_=>b(_))?(P.set($,!0),!0):(P.set($,!1),!1)},F=($,H)=>{if(!d||d.length===0)return 0;const L=S.get($),B=S.get(H);if(!L||!B)return 0;for(const D of d){const _=L[D.field],T=B[D.field],I=on(_,T,D.sort);if(I!==0)return I}return 0},z=[],K=new Set,W=$=>{const H=$.filter(L=>b(L));H.sort(F),H.forEach(L=>{if(K.has(L))return;const B=S.get(L),D=u.get(L);if(B&&D){K.add(L);const _={...B,_treeDepth:D.depth,_isExpanded:E.has(L),_hasChildren:!!(D.children&&D.children.length>0||D.serverChildrenCount&&D.serverChildrenCount>0),_descendantCount:D.children?D.children.length:0};z.push(_),E.has(L)&&D.children&&D.children.length>0&&W(D.children)}})};return W(p),z},[i,t,w,p,u,E,a,d,e]),M=s.useCallback(S=>E.has(S),[E]),N=s.useCallback(S=>u.get(S),[u]),k=s.useCallback(S=>{const j=[];let P=S;for(;P!==null;){const b=u.get(P);if(!b)break;j.unshift(b.groupingKey),P=b.parentId}return j},[u]),C=s.useMemo(()=>{const S=new Map,j=new Set(w.map(P=>P.id));return u.forEach((P,b)=>{S.set(b,{hasChildren:!!(P.children&&P.children.length>0||P.serverChildrenCount&&P.serverChildrenCount>0),treeDepth:P.depth,descendantCount:P.children?P.children.length:void 0,isGroupRow:j.has(b),isExpanded:E.has(b)})}),S},[u,w,E]);return s.useMemo(()=>({treeNodes:u,groupingRows:w,toggleExpansion:m,isGroupExpanded:M,getVisibleRows:y,getNode:N,getNodePath:k,rowMetaMap:C}),[u,w,m,M,y,N,k,C])}const pr=n=>n?.depth===-1?"footer":"inline",xr=[],mr={},Wn=new Map;function wr(n){const{rows:t,getRowId:e,columns:o,rowGroupingModel:i=xr,aggregationModel:l=mr,defaultGroupingExpansionDepth:a=0,filterModel:d,sortModel:c,getAggregationPosition:u=pr}=n,p=s.useMemo(()=>{const j=new Map;return(o??[]).forEach(P=>j.set(P.field,P)),j},[o]),w=`${i.join("")}|${a}`,[x,g]=s.useState(()=>({configKey:w,overrides:new Map})),f=x.configKey===w?x.overrides:Wn,{treeNodes:h,rootIds:v,groupingRows:E}=s.useMemo(()=>{const j=new Map,P=new Map,b=[];if(i.length===0)return{treeNodes:j,rootIds:b,groupingRows:P};const F=(W,$,H)=>`auto-group-${W}-${$}-${H||"root"}`,z=(W,$,H)=>{if($>=i.length)return W.map(T=>{const I=e(T);return j.set(I,{id:I,parentId:H,depth:$,groupingKey:"",isExpanded:!1}),I});const L=i[$],B=p.get(L);if(B&&B.groupable===!1)return z(W,$+1,H);const D=new Map;W.forEach(T=>{const I=T[L],O=String(I);D.has(O)||D.set(O,[]),D.get(O).push(T)});const _=[];return D.forEach((T,I)=>{const X=T[0][L],te=F(L,I,H);_.push(te);const Z=Rn(T,l,p,"useRowGrouping"),ce={[L]:X,...Z,id:te};P.set(te,ce);const le={id:te,parentId:H,depth:$,groupingKey:I,groupingField:L,groupingValue:X,aggregatedValues:Z,isExpanded:!1,children:[],label:B?.groupingValueFormatter?B.groupingValueFormatter({field:L,value:X}):`${L}: ${String(X)}`};le.aggregationPosition=u(le),j.set(te,le);const G=z(T,$+1,te);j.get(te).children=G;const R=T.length;j.get(te).descendantCount=R}),_},K=z(t,0,null);return b.push(...K),{treeNodes:j,rootIds:b,groupingRows:P}},[t,i,l,e,u,p]),m=s.useCallback(j=>!!(j?.children&&j.children.length>0)&&(a===-1||(j?.depth??0)<a),[a]),y=s.useMemo(()=>{const j=new Set;return h.forEach((P,b)=>{!P.children||P.children.length===0||(f.get(b)??m(P))&&j.add(b)}),j},[h,f,m]),M=s.useCallback(j=>{g(P=>{const b=P.configKey===w?P.overrides:Wn,F=b.get(j)??m(h.get(j)),z=new Map(b);return z.set(j,!F),{configKey:w,overrides:z}})},[w,h,m]),N=s.useCallback(j=>y.has(j),[y]),k=s.useCallback(()=>{if(i.length===0)return null;const j=[],P=new Set,b=new Map;t.forEach(K=>b.set(e(K),K));const F=K=>{const W=h.get(K);if(!W)return!1;if(!W.children||W.children.length===0){const $=b.get(K);return!(!$||d&&!nn($,d))}return W.children.some($=>F($))},z=K=>{const W=d?K.filter(F):[...K];c&&c.length>0&&W.sort(($,H)=>{const L=E.get($)||b.get($),B=E.get(H)||b.get(H);if(!L||!B)return 0;for(const D of c){const _=L[D.field],T=B[D.field],I=on(_,T,D.sort);if(I!==0)return I}return 0}),W.forEach($=>{if(P.has($))return;const H=h.get($),L=H?.children&&H.children.length>0,B=L?E.get($):b.get($);if(B&&H){P.add($);const D={...B,_treeDepth:H.depth,_isExpanded:y.has($),_hasChildren:L,_groupingField:H.groupingField,_groupingValue:H.groupingValue,_descendantCount:H.descendantCount};j.push(D),y.has($)&&L&&z(H.children)}})};return z(v),j},[t,e,h,v,E,d,c,y,i]),C=s.useCallback(j=>h.get(j),[h]),S=s.useMemo(()=>{const j=new Map;return h.forEach((P,b)=>{const F=!!(P.children&&P.children.length>0);j.set(b,{hasChildren:F,treeDepth:P.depth,groupingField:P.groupingField,groupingValue:P.groupingValue,groupLabel:P.label,descendantCount:P.descendantCount,isGroupRow:F,isExpanded:F?y.has(b):void 0})}),j},[h,y]);return s.useMemo(()=>({treeNodes:h,groupingRows:E,toggleExpansion:M,isGroupExpanded:N,getVisibleRows:k,getNode:C,rowMetaMap:S}),[h,E,M,N,k,C,S])}function br(n){const{rows:t,getRowId:e,processRowUpdate:o,onProcessRowUpdateError:i,onRowChange:l}=n,[a,d]=s.useState(null),c=s.useRef(null),u=s.useCallback(g=>{d(g),c.current=typeof g=="function"?g(c.current):g},[]),p=s.useCallback(g=>{u({id:g.id,field:g.field,value:g.value,originalValue:g.value})},[u]),w=s.useCallback(async g=>{const f=c.current;if(!f)return;if(g?.cancel){u(null);return}const{id:h,field:v,value:E,originalValue:m}=f;if(E===m){u(null);return}const y=t.find(N=>e(N)===h);if(!y){u(null);return}const M={...y,[v]:E};try{if(o){const N=await o(M,y);l?.(N)}else l?.(M);u(null)}catch(N){i?.(N)}},[u,t,e,o,l,i]),x=s.useCallback(g=>{a&&a.id===g.id&&a.field===g.field&&u(f=>f?{...f,value:g.value}:null)},[a,u]);return{editingCell:a,startCellEdit:p,stopCellEdit:w,setEditCellValue:x}}function vr(n,t,e){const[o,i]=s.useState(new Map),[l,a]=s.useState({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}}),d=s.useCallback(()=>{i(new Map)},[]),c=s.useCallback((h,v)=>o.get(h)?.[v],[o]),u=s.useCallback((h,v,E,m,y)=>{const M=new Map(o);for(let N=m;N<y;N++){const k=t[N];if(!k)continue;let C=1;if(k.colSpan)if(typeof k.colSpan=="function"){const j={row:v,value:v[k.field],field:k.field,colDef:k,rowIndex:E,colIndex:N};C=k.colSpan(j)}else C=k.colSpan;if(C<=1){et(M,h,k.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:e[k.field]||100}});continue}let S=e[k.field]||100;for(let j=1;j<C;j++)if(N+j<y){const P=t[N+j];P&&(S+=e[P.field]||100,et(M,h,P.field,{spannedByColSpan:!0,leftVisibleCellIndex:N,rightVisibleCellIndex:Math.min(N+C-1,t.length-1)}))}et(M,h,k.field,{spannedByColSpan:!1,cellProps:{colSpan:C,width:S}}),N+=C-1}i(M)},[o,t,e]),p=s.useCallback((h,v)=>{const E={},m={},y={};t.forEach((M,N)=>{if(M.rowSpan)for(let k=h;k<v;k++){const C=n[k];if(!C||m[C.id]?.[M.field])continue;const S=M.valueGetter?M.valueGetter({row:C,field:M.field,value:C[M.field]}):C[M.field];let j=1;if(typeof M.rowSpan=="function"){const P={row:C,value:S,field:M.field,colDef:M,rowIndex:k,colIndex:N};j=M.rowSpan(P)}else typeof M.rowSpan=="number"&&(j=M.rowSpan);if(j>1){E[C.id]||(E[C.id]={}),E[C.id][M.field]=j;for(let P=1;P<j;P++){const b=k+P;if(b<v&&n[b]){const F=n[b];m[F.id]||(m[F.id]={}),m[F.id][M.field]=!0,y[b]||(y[b]={}),y[b][M.field]=k}}}}}),a({caches:{spannedCells:E,hiddenCells:m,hiddenCellOriginMap:y},processedRange:{firstRowIndex:h,lastRowIndex:v}})},[n,t]),w=s.useCallback(()=>{a({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}})},[]);s.useEffect(()=>{const h=new Map;n.forEach((y,M)=>{for(let N=0;N<t.length;N++){const k=t[N];if(!k)continue;let C=1;if(k.colSpan)if(typeof k.colSpan=="function"){const j={row:y,value:y[k.field],field:k.field,colDef:k,rowIndex:M,colIndex:N};C=k.colSpan(j)}else C=k.colSpan;if(C<=1){const j=e[k.field]||(typeof k.width=="number"?k.width:100);et(h,y.id,k.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:j}});continue}let S=e[k.field]||(typeof k.width=="number"?k.width:100);for(let j=1;j<C;j++)if(N+j<t.length){const P=t[N+j];if(P){const b=e[P.field]||(typeof P.width=="number"?P.width:100);S+=b,et(h,y.id,P.field,{spannedByColSpan:!0,leftVisibleCellIndex:N,rightVisibleCellIndex:Math.min(N+C-1,t.length-1)})}}et(h,y.id,k.field,{spannedByColSpan:!1,cellProps:{colSpan:C,width:S}}),N+=C-1}}),i(h);const v={},E={},m={};t.forEach((y,M)=>{if(y.rowSpan)for(let N=0;N<n.length;N++){const k=n[N];if(!k||E[k.id]?.[y.field])continue;const C=y.valueGetter?y.valueGetter({row:k,field:y.field,value:k[y.field]}):k[y.field];let S=1;if(typeof y.rowSpan=="function"){const j={row:k,value:C,field:y.field,colDef:y,rowIndex:N,colIndex:M};S=y.rowSpan(j)}else typeof y.rowSpan=="number"&&(S=y.rowSpan);if(S>1){v[k.id]||(v[k.id]={}),v[k.id][y.field]=S;for(let j=1;j<S;j++){const P=N+j;if(P<n.length&&n[P]){const b=n[P];E[b.id]||(E[b.id]={}),E[b.id][y.field]=!0,m[P]||(m[P]={}),m[P][y.field]=N}}}}}),a({caches:{spannedCells:v,hiddenCells:E,hiddenCellOriginMap:m},processedRange:{firstRowIndex:0,lastRowIndex:n.length}})},[n,t,e]);const x=s.useCallback(()=>l.caches.spannedCells,[l]),g=s.useCallback(()=>l.caches.hiddenCells,[l]),f=s.useCallback(()=>l.caches.hiddenCellOriginMap,[l]);return{colspanMap:o,resetColSpan:d,getCellColSpanInfo:c,calculateColSpan:u,rowSpanningState:l,calculateRowSpan:p,resetRowSpan:w,getSpannedCells:x,getHiddenCells:g,getHiddenCellOriginMap:f}}function et(n,t,e,o){let i=n.get(t);i||(i={},n.set(t,i)),i[e]=o}function Cr(n){const{dataSource:t,sortModel:e,filterModel:o,paginationModel:i,paginationMode:l,sortingMode:a,filterMode:d,aggregationModel:c,setRows:u,setRowCount:p,setDataSourceLoading:w,setDataSourceError:x,onAggregationResults:g}=n,f=s.useRef(null),h=s.useRef(0),v=s.useCallback(async()=>{if(!t)return;const m=++h.current;w(!0),x(null);const y=i.page*i.pageSize,M=y+i.pageSize,N={startRow:y,endRow:M,sortModel:e,filterModel:o,groupKeys:[],aggregationModel:c};try{const k=await t.getRows(N);if(m!==h.current)return;let C=!1;if(l==="infinite"){const S=f.current;if(S){const j=JSON.stringify(S.sortModel)!==JSON.stringify(e),P=JSON.stringify(S.filterModel)!==JSON.stringify(o),b=S.pageSize!==i.pageSize;!j&&!P&&!b&&i.page>S.page&&(C=!0)}}u(C?S=>[...S,...k.rows]:k.rows,!0),k.aggregationResults&&g&&g(k.aggregationResults),k.rowCount!==void 0&&p(k.rowCount),f.current={sortModel:e,filterModel:o,page:i.page,pageSize:i.pageSize}}catch(k){m===h.current&&(x(k),console.error("Data Source Error:",k))}finally{m===h.current&&w(!1)}},[t,i.page,i.pageSize,e,o,l,c,g,u,p,w,x]);s.useEffect(()=>{if(t&&(l==="server"||l==="infinite"||a==="server"||d==="server")){const y=setTimeout(()=>{v()},300);return()=>clearTimeout(y)}},[v,t,l,a,d]);const E=s.useCallback(async(m,y)=>{if(t){w(!0);try{const M=await t.getRows({startRow:0,endRow:-1,sortModel:e,filterModel:o,groupKeys:y});M.rows.length>0&&u(N=>{const k=new Set(N.map(S=>S.id)),C=M.rows.filter(S=>!k.has(S.id));return[...N,...C]})}catch(M){x(M),console.error("Failed to fetch children:",M)}finally{w(!1)}}},[t,e,o,u,w,x]);return{fetchRows:v,fetchChildren:E}}const An="\0",Ct="";function _r(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 Wt(n,t){return t.map(e=>String(n[e]??"")).join(An)}function ln(n,t,e,o){return o?`${n}${Ct}${t}${Ct}${e}`:`${t}${Ct}${e}`}function $n(n,t,e,o){return s.useMemo(()=>{const i={pivotRows:[],pivotColumns:[],colKeys:[],isValid:!1};if(!o)return i;const{rowFields:l,columnFields:a,valueFields:d}=e;if(l.length===0||d.length===0)return i;const c=a.length>0,u=new Map(t.map(m=>[m.field,m])),p=new Set;for(const m of n)p.add(Wt(m,a));const w=Array.from(p).sort(),x=new Map;for(const m of n){const y=Wt(m,l);if(!x.has(y)){const C={};for(const S of l)C[S]=m[S];x.set(y,{labelValues:C,bucket:new Map})}const M=x.get(y),N=Wt(m,a);M.bucket.has(N)||M.bucket.set(N,new Map);const k=M.bucket.get(N);for(const C of d){const S=m[C.field];k.has(C.field)||k.set(C.field,[]),S!=null&&!isNaN(Number(S))&&k.get(C.field).push(Number(S))}}let g=0;const f=[];for(const[,m]of x){const y={id:g++,...m.labelValues};for(const M of w){const N=m.bucket.get(M);for(const k of d){const C=ln(M,k.field,k.aggFn,c),S=N?.get(k.field)??[];y[C]=S.length>0?_r(S,k.aggFn):null}}f.push(y)}const h=new Map;for(const m of n){const y=Wt(m,a);for(const M of d){if(M.aggFn!=="avg"&&M.aggFn!=="min"&&M.aggFn!=="max")continue;const N=`${y}${Ct}${M.field}`;h.has(N)||h.set(N,[]);const k=m[M.field];k!=null&&!isNaN(Number(k))&&h.get(N).push(Number(k))}}const v={id:"__pivot_grand_total__"};for(let m=0;m<l.length;m++)v[l[m]]=m===0?"Grand Total":"";for(const m of w)for(const y of d){const M=ln(m,y.field,y.aggFn,c),N=f.map(C=>C[M]).filter(C=>C!=null&&!isNaN(Number(C))).map(Number);if(N.length===0){v[M]=null;continue}const k=`${m}${Ct}${y.field}`;switch(y.aggFn){case"sum":case"count":v[M]=N.reduce((C,S)=>C+S,0);break;case"avg":{const C=h.get(k)??[];v[M]=C.length>0?C.reduce((S,j)=>S+j,0)/C.length:null;break}case"min":v[M]=Math.min(...h.get(k)??N);break;case"max":v[M]=Math.max(...h.get(k)??N);break}}f.push(v);const E=[];for(const m of l){const y=u.get(m);E.push({field:m,headerName:y?.headerName??m,width:y?.width??140,sortable:!0})}for(const m of w){const y=c?m.split(An).map((M,N)=>{const k=u.get(a[N]);return k?.headerName?`${k.headerName}: ${M}`:M}).join(" / "):"";for(const M of d){const N=u.get(M.field),k=ln(m,M.field,M.aggFn,c),C=M.headerName??N?.headerName??M.field,S=y?`${y} — ${C} (${M.aggFn})`:`${C} (${M.aggFn})`;E.push({field:k,headerName:S,width:140,type:"number",align:"right",headerAlign:"right",sortable:!0,valueFormatter:({value:j})=>{if(j==null)return"—";const P=Number(j);return M.aggFn==="avg"?P.toFixed(2):M.aggFn==="count"?P.toLocaleString():N?.valueFormatter?N.valueFormatter({value:j,row:{},field:M.field}):P.toLocaleString()}})}}return{pivotRows:f,pivotColumns:E,colKeys:w,isValid:!0}},[n,t,e,o])}function yr(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 kr(n){let t=!1;try{t=yr(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 Sr(n){const{selectedRowIds:t,columns:e,getVisibleRows:o,getRowId:i}=n,l=s.useCallback(async()=>{if(t.size===0)return;const d=o().filter(x=>t.has(i(x)));if(d.length===0)return;const c=e.filter(x=>!x.field.startsWith("__")),u=c.map(x=>x.headerName||x.field).join(" "),p=d.map(x=>c.map(g=>{const f=x[g.field];return g.valueFormatter?g.valueFormatter({value:f,row:x,field:g.field}):f??""}).join(" ")).join(`
|
|
7
|
+
`),w=`${u}
|
|
8
|
+
${p}`;try{await kr(w)}catch(x){console.error("[OpenGridX] Failed to copy to clipboard:",x)}},[t,e,o,i]);return s.useEffect(()=>{const a=d=>{if(!(d.ctrlKey||d.metaKey)||d.key!=="c")return;const c=document.activeElement,u=c?.tagName.toLowerCase(),p=c?.type;u==="input"&&p!=="checkbox"&&p!=="radio"||u==="textarea"||u==="select"||c?.isContentEditable||l()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[l]),{copySelectedRows:l}}function jr({row:n,rowIndex:t,listViewColumn:e,isSelected:o=!1,checkboxSelection:i=!1,rowHeight:l,onRowClick:a,onRowDoubleClick:d,onSelectionChange:c}){const u={row:n,value:void 0,field:e.field,colDef:{field:e.field},rowIndex:t,colIndex:0},p=w=>{w.stopPropagation(),c?.(n.id,w.target.checked)};return r.jsxs("div",{className:`ogx-list-view__row${o?" ogx-list-view__row--selected":""}`,style:l?{minHeight:l}:void 0,onClick:()=>a?.(n),onDoubleClick:d?()=>d(n):void 0,role:"row","aria-rowindex":t+2,"aria-selected":o,children:[i&&r.jsx("div",{className:"ogx-list-view__checkbox",onClick:w=>w.stopPropagation(),children:r.jsx("input",{type:"checkbox",checked:o,onChange:p,"aria-label":`Select row ${n.id}`})}),r.jsx("div",{className:"ogx-list-view__cell",role:"gridcell",children:e.renderCell(u)})]})}function Er({ariaLabel:n,allRenderableRows:t,filteredRows:e,pagination:o,effectivePaginationModel:i,pageSizeOptions:l,selectedRowIds:a,listViewColumn:d,noRowsLabel:c,rowHeight:u,checkboxSelection:p,paginationMode:w,dataSource:x,serverRowCount:g,paginationSlot:f,paginationSlotProps:h,localeText:v,onRowClick:E,onRowDoubleClick:m,onSelectionChange:y,onPaginationModelChange:M}){const N=f||Fn,k=w==="server"&&x?g||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}`:"",a.size>0?` · ${a.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"})]}),c]}):t.map((C,S)=>r.jsx(jr,{row:C,rowIndex:S,listViewColumn:d,isSelected:a.has(C.id),checkboxSelection:p,rowHeight:u,onRowClick:j=>E({row:j,id:j.id,rowIndex:S}),onRowDoubleClick:m?j=>m({row:j,id:j.id,rowIndex:S}):void 0,onSelectionChange:y},C.id))}),o&&r.jsx(N,{page:i.page,pageSize:i.pageSize,rowCount:k,pageSizeOptions:l,onPageChange:C=>M({...i,page:C}),onPageSizeChange:C=>M({...i,pageSize:C,page:0}),localeText:v,...h})]})}function Nr({value:n,onValueChange:t,onCommit:e,onCancel:o}){const[i,l]=s.useState(String(n??"")),a=s.useRef(null);return s.useEffect(()=>{a.current?.focus(),a.current?.select()},[]),r.jsx("input",{ref:a,type:"text",className:"ogx__edit-input",value:i,onChange:d=>{l(d.target.value),t(d.target.value)},onBlur:e,onKeyDown:d=>{d.key==="Enter"&&(d.stopPropagation(),e()),d.key==="Escape"&&(d.stopPropagation(),o())}})}function Mr({value:n,onValueChange:t,onCommit:e,onCancel:o}){const[i,l]=s.useState(typeof n=="number"?n:""),a=s.useRef(null);return s.useEffect(()=>{a.current?.focus(),a.current?.select()},[]),r.jsx("input",{ref:a,type:"number",className:"ogx__edit-input ogx__edit-input--number",value:i,onChange:d=>{const c=d.target.value===""?"":Number(d.target.value);l(c),t(c===""?null:c)},onBlur:e,onKeyDown:d=>{d.key==="Enter"&&(d.stopPropagation(),e()),d.key==="Escape"&&(d.stopPropagation(),o())}})}function Pr({value:n,onValueChange:t,onCommit:e,onCancel:o}){const i=s.useRef(null);s.useEffect(()=>{i.current?.focus()},[]);const l=()=>{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:l,onKeyDown:a=>{a.key==="Escape"&&(a.stopPropagation(),o())}})})}function Rr({value:n,colDef:t,onValueChange:e,onCommit:o,onCancel:i}){const l=s.useRef(null);s.useEffect(()=>{l.current?.focus()},[]);const a=t.valueOptions??[];return r.jsx("select",{ref:l,className:"ogx__edit-select",value:String(n??""),onChange:d=>{e(d.target.value)},onBlur:o,onKeyDown:d=>{d.key==="Enter"&&(d.stopPropagation(),o()),d.key==="Escape"&&(d.stopPropagation(),i())},children:a.map(d=>{const c=typeof d=="object"?d.value:d,u=typeof d=="object"?d.label:String(d);return r.jsx("option",{value:String(c),children:u},String(c))})})}function Tr({value:n,onValueChange:t,onCommit:e,onCancel:o}){const[i,l]=s.useState(typeof n=="string"?n:String(n??"")),a=s.useRef(null);return s.useEffect(()=>{a.current?.focus()},[]),r.jsx("input",{ref:a,type:"date",className:"ogx__edit-input",value:i,onChange:d=>{l(d.target.value),t(d.target.value)},onBlur:e,onKeyDown:d=>{d.key==="Enter"&&(d.stopPropagation(),e()),d.key==="Escape"&&(d.stopPropagation(),o())}})}function Ir(n){const{colDef:t}=n;switch(t.type){case"number":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(Mr,{...n})});case"boolean":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(Pr,{...n})});case"singleSelect":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(Rr,{...n})});case"date":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(Tr,{...n})});default:return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(Nr,{...n})})}}function Lr({renderFn:n}){return r.jsx(r.Fragment,{children:n()})}class Fr extends s.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}}componentDidCatch(t,e){process.env.NODE_ENV!=="production"&&console.warn(`[CellErrorBoundary] field="${this.props.field}"`,t,e.componentStack)}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:"⚠"}):r.jsx(Lr,{renderFn:this.props.renderFn})}}function Or(n){const{onCellClick:t,onCellEditStart:e,onCellValueChange:o,value:i,row:l,colDef:a,rowIndex:d,colIndex:c,isSelected:u,onClick:p,width:w,pinnedPosition:x,pinnedOffset:g,isFocused:f,isFocusVisible:h,isEditable:v,isEditing:E,onEditStart:m,onEditStop:y,onValueChange:M,colSpanInfo:N,rowSpan:k,isHiddenByRowSpan:C,rowMeta:S}=n,j=s.useCallback(_=>{o?o(a.field,_):M?.(_)},[o,M,a.field]),P=s.useMemo(()=>a.valueFormatter?a.valueFormatter({value:i,row:l,field:a.field}):i==null?"":String(i),[i,l,a]),b=s.useMemo(()=>a.cellClassName?typeof a.cellClassName=="function"?a.cellClassName({value:i,row:l,field:a.field,colDef:a,rowIndex:d,colIndex:c})||"":a.cellClassName:"",[a,i,l,d,c]),F=s.useRef(null);if(s.useLayoutEffect(()=>{f&&F.current&&F.current.focus({preventScroll:!0})},[f]),N?.spannedByColSpan)return null;if(C)return r.jsx("div",{className:"ogx__cell ogx__cell--hidden",style:{width:w??a.width??100},role:"presentation","data-field":a.field,"data-colindex":c});const z=_=>{t&&t({row:l,field:a.field,value:i,colDef:a,rowIndex:d,colIndex:c}),p?.(_)},K=_=>{v&&(m||e)&&(_.stopPropagation(),e?e(a.field,i):m?.())},W=x!=null,$=["ogx__cell",`ogx__cell--align-${a.align||"left"}`,u&&"ogx__cell--selected",f&&"ogx__cell--focused",f&&h&&"ogx__cell--focus-visible",a.type&&`ogx__cell--type-${a.type}`,W&&"ogx__cell--pinned",W&&`ogx__cell--pinned-${x}`,E&&"ogx__cell--editing",k&&k>1&&"ogx__cell--spanned",b].filter(Boolean).join(" "),H=N?.cellProps?.colSpan||1,L=k||1,B=N?.cellProps?.width??w??a.width??100,D={width:"var(--width)","--width":typeof B=="number"?`${B}px`:B,flexGrow:a.flex??0,flexShrink:0,flexBasis:(a.flex,"auto"),boxSizing:"border-box",minWidth:a.minWidth,maxWidth:a.maxWidth,position:W?"sticky":void 0,zIndex:a.zIndex??(W?3:void 0),padding:E?0:void 0};return L>1&&(D.height=`calc(var(--height) * ${L} - var(--border-width, 1px))`,D.zIndex=10,W&&(D.zIndex=40)),W&&g!==void 0&&(x==="left"?D.left=g:D.right=g),r.jsx("div",{ref:F,className:$,style:D,onClick:z,onDoubleClick:K,role:"gridcell","aria-colindex":c+1,"aria-readonly":!v||void 0,tabIndex:-1,"data-field":a.field,"data-colindex":c,...H>1?{"aria-colspan":H}:{},...L>1?{"aria-rowspan":L}:{},children:r.jsx("div",{className:"ogx__cell-content",children:E&&(o||M)&&y?a.renderEditCell?a.renderEditCell({value:i,row:l,field:a.field,colDef:a,rowIndex:d,colIndex:c,rowMeta:S}):r.jsx(Ir,{value:i,row:l,field:a.field,colDef:a,rowIndex:d,colIndex:c,onValueChange:j,onCommit:()=>y(),onCancel:()=>y(!0)}):a.renderCell?r.jsx(Fr,{field:a.field,resetKey:l,renderFn:()=>a.renderCell({value:i,formattedValue:P,row:l,field:a.field,colDef:a,rowIndex:d,colIndex:c,rowMeta:S})}):P})})}const zn=s.memo(Or),Wr=({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 Ar(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 At(n){const{row:t,columns:e,rowIndex:o,isSelected:i=!1,checkboxSelection:l=!1,onRowClick:a,onRowDoubleClick:d,onCellClick:c,onSelectionChange:u,columnWidths:p={},pinnedColumns:w,pinnedRows:x,hasDetailPanel:g=!1,isDetailPanelExpanded:f=!1,onDetailPanelToggle:h,detailPanelContent:v,detailPanelHeight:E=200,pinCheckboxColumn:m=!0,pinExpandColumn:y=!0,rowReordering:M=!1,onDragStart:N,onDragOver:k,onDragEnd:C,onDrop:S,isDragging:j,isDragOver:P,editingCell:b,onEditStart:F,onEditStop:z,onEditCellValueChange:K,focusedCellField:W,isFocusVisible:$,colspanMap:H,rowSpanningCaches:L,rowHeight:B=52,rowMeta:D}=n,_=s.useId(),T=s.useRef(null),I=s.useRef(null);s.useLayoutEffect(()=>{W==="__expand_col__"&&T.current&&T.current.focus({preventScroll:!0}),W==="__checkbox_col__"&&I.current&&I.current.focus({preventScroll:!0})},[W]);const O=s.useMemo(()=>en(e,p,w,l,m,g,y,M),[e,p,w,l,m,g,y,M]),X=D?.hasChildren===!0,te=s.useCallback((V,A)=>{X||F?.({id:t.id,field:V,value:A})},[X,t.id,F]),Z=s.useCallback((V,A)=>{K?.({id:t.id,field:V,value:A})},[K,t.id]),ce=s.useCallback(V=>{z?.({cancel:V})},[z]);if(t._isSkeleton){const V=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:V}).map((A,ee)=>r.jsx("div",{className:"ogx__skeleton-cell",children:r.jsx("div",{className:"ogx__skeleton-bar"})},ee))})}const le=V=>{V.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell")||a?.({row:t,id:t.id,rowIndex:o})},G=V=>{V.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell")||d?.({row:t,id:t.id,rowIndex:o})},R=V=>{V.stopPropagation(),u?.(t.id,V.target.checked)},Y=V=>{V.stopPropagation(),h?.(t.id)},Q=tn(t.id,x),J=Q==="top",re=Q==="bottom",q=["ogx__row",i&&"ogx__row--selected",o%2===0&&"ogx__row--even",o%2===1&&"ogx__row--odd",J&&"ogx__row--pinned-top",re&&"ogx__row--pinned-bottom",j&&"ogx__row--dragging",P&&"ogx__row--drag-over",X&&"ogx__row--group"].filter(Boolean).join(" ");return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:q,onClick:le,onDoubleClick:d?G:void 0,role:"row","aria-rowindex":o+1,"aria-selected":i,"data-rowindex":o,onDragOver:k?k(t.id):void 0,onDrop:S?S(t.id):void 0,style:{maxHeight:`${B}px`,minHeight:`${B}px`,"--height":`${B}px`,"--border-width":"1px"},children:[M&&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:N?N(t.id):void 0,onDragEnd:C,onClick:V=>V.stopPropagation(),children:r.jsx(Wr,{})}),g&&r.jsx("div",{className:`ogx__cell ogx__cell--expand ${y?"ogx__cell--pinned-left":""} ${W==="__expand_col__"?"ogx__cell--focused":""} ${W==="__expand_col__"&&$?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":f?"Collapse row details":"Expand row details","aria-expanded":f,style:{position:y?"sticky":void 0,left:y?M?48:0:void 0,zIndex:y?5:void 0},ref:T,tabIndex:-1,onClick:V=>{V.stopPropagation(),c?.({row:t,field:"__expand_col__",value:f,colDef:{field:"__expand_col__",width:48},rowIndex:o,colIndex:-1})},children:r.jsx(Pn,{isExpanded:f,onClick:Y,variant:"plus-minus"})}),l&&r.jsx("div",{className:`ogx__cell ogx__cell--checkbox ${m?"ogx__cell--pinned-left":""} ${W==="__checkbox_col__"?"ogx__cell--focused":""} ${W==="__checkbox_col__"&&$?"ogx__cell--focus-visible":""}`,role:"gridcell",style:{position:m?"sticky":void 0,left:m?(M?48:0)+(g&&y?48:0):void 0,zIndex:m?11:void 0},ref:I,tabIndex:-1,onClick:V=>{V.stopPropagation(),c?.({row:t,field:"__checkbox_col__",value:i,colDef:{field:"__checkbox_col__",width:48},rowIndex:o,colIndex:-1})},children:r.jsx(bt,{id:_,name:`ogx-select-row-${t.id}`,checked:i,onChange:R,onClick:V=>V.stopPropagation(),"aria-label":i?`Deselect row ${t.id}`:`Select row ${t.id}`,tabIndex:-1,onMouseDown:V=>V.preventDefault()})}),e.map((V,A)=>{if(V.isSpacer)return r.jsx("div",{style:{width:V.width,minWidth:V.width,flexShrink:0},"aria-hidden":"true"},V.field);const ee=V.valueGetter?V.valueGetter({row:t,field:V.field,value:t[V.field]}):t[V.field],ie=p[V.field]??V.width,ae=wt(V.field,w),fe=ae?O[V.field]:void 0,he=b?.id===t.id&&b?.field===V.field,Me=he?b?.value:ee,ke=H?.get(t.id)?.[V.field],Pe=L?.spannedCells[t.id]?.[V.field],Se=L?.hiddenCells[t.id]?.[V.field]||!1;return r.jsx(zn,{value:Me,row:t,colDef:V,rowIndex:o,colIndex:A,isSelected:i,onCellClick:c,width:ie,pinnedPosition:ae,pinnedOffset:fe,isFocused:W===V.field,isFocusVisible:$,isEditable:V.editable,isEditing:he,onCellEditStart:te,onEditStop:ce,onCellValueChange:Z,colSpanInfo:ke,rowSpan:Pe,isHiddenByRowSpan:Se,rowMeta:D},V.field)})]}),g&&r.jsx(Ar,{row:t,rowId:t.id,rowIndex:o,content:v,height:E,isExpanded:f})]})}function Bn({rows:n,position:t,columns:e,selectedRowIds:o,checkboxSelection:i,onRowClick:l,onRowDoubleClick:a,onCellClick:d,onSelectionChange:c,columnWidths:u,pinnedColumns:p,pinnedRows:w,hasDetailPanel:x,expandedRowIds:g,getDetailPanelContent:f,getDetailPanelHeight:h,onDetailPanelToggle:v,pinCheckboxColumn:E,pinExpandColumn:m,focusedCell:y,colspanMap:M,rowSpanningCaches:N,rowHeight:k,rowMetaMap:C}){return n.length===0?null:r.jsx("div",{className:`ogx__pinned-rows ogx__pinned-rows--${t}`,role:"rowgroup",children:n.map((S,j)=>r.jsx(At,{row:S,columns:e,rowIndex:j,isSelected:o.has(S.id),checkboxSelection:i,onRowClick:l,onRowDoubleClick:a,onCellClick:d,onSelectionChange:c,columnWidths:u,pinnedColumns:p,pinnedRows:w,hasDetailPanel:x,isDetailPanelExpanded:g.has(S.id),detailPanelContent:f?f({row:S,id:S.id,rowIndex:j}):null,detailPanelHeight:h?.({row:S,id:S.id,rowIndex:j})||200,onDetailPanelToggle:v,pinCheckboxColumn:E,pinExpandColumn:m,focusedCellField:y?.id===S.id?y.field:null,colspanMap:M,rowSpanningCaches:N,rowHeight:k,rowMeta:C.get(S.id)},S.id))})}const $r=({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((l,a)=>{const d=typeof l.width=="number"?l.width:150,c=Math.min(d*.7,d-20);return r.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:d,minWidth:l.minWidth,maxWidth:l.maxWidth,left:l.left,right:l.right,position:l.isSpacer?"relative":l.pinned?"sticky":"relative",zIndex:l.zIndex},children:!l.isSpacer&&r.jsx("div",{className:"ogx-skeleton-box",style:{width:c,height:16,borderRadius:4}})},l.field||a)})]});function zr({virtualContainerHeight:n,offsetTop:t,effectiveLoading:e,visibleRows:o,baseColumns:i,virtualColumns:l,viewportWidth:a,checkboxSelection:d,hasDetailPanel:c,rowReordering:u,rowHeight:p,pinnedRows:w,selectedRowIds:x,onRowClick:g,onRowDoubleClick:f,onCellClick:h,onSelectionChange:v,columnWidths:E,pinnedColumns:m,expandedRowIds:y,getDetailPanelContent:M,getDetailPanelHeight:N,onDetailPanelToggle:k,pinCheckboxColumn:C,pinExpandColumn:S,rowReorderHandlers:j,editingHandlers:P,focusedCell:b,colspanMap:F,rowSpanningCaches:z,paginationMode:K,dataSourceLoading:W,sortedUnpinnedRowCount:$,infiniteScrollSkeletonCount:H,unpinnedRowsLength:L,rowMetaMap:B,loadingOverlay:D}){const _=i.length>0?i:(()=>{const I=(a||1e3)-(d?48:0)-(c?48:0)-(u?48:0),O=150,X=Math.max(1,Math.ceil(I/O));return Array.from({length:X},(te,Z)=>({field:`placeholder_${Z}`,headerName:"",width:O}))})(),T=o.filter(({row:I})=>!tn(I.id,w)).filter((I,O,X)=>O===X.findIndex(te=>te.row.id===I.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&&D?r.jsx("div",{className:"ogx__loading-overlay",style:{width:a||void 0},children:D}):e&&o.length===0?Array.from({length:10}).map((I,O)=>r.jsx($r,{columns:_,rowHeight:p,checkboxSelection:d,hasDetailPanel:c,rowReordering:u},`skeleton-${O}`)):T.map(({row:I,rowIndex:O})=>r.jsx(At,{row:I,columns:l,rowIndex:O,isSelected:x.has(I.id),checkboxSelection:d,onRowClick:g,onRowDoubleClick:f,onCellClick:h,onSelectionChange:v,columnWidths:E,pinnedColumns:m,pinnedRows:w,hasDetailPanel:c,isDetailPanelExpanded:y.has(I.id),detailPanelContent:M?M({row:I,id:I.id,rowIndex:O}):null,detailPanelHeight:N?.({row:I,id:I.id,rowIndex:O})||200,onDetailPanelToggle:k,pinCheckboxColumn:C,pinExpandColumn:S,rowReordering:u,onDragStart:j.onDragStart,onDragOver:j.onDragOver,onDragEnd:j.onDragEnd,onDrop:j.onDrop,isDragging:j.draggedRowId===I.id,isDragOver:j.dragOverRowId===I.id,editingCell:P.editingCell,onEditStart:P.startCellEdit,onEditStop:P.stopCellEdit,onEditCellValueChange:P.setEditCellValue,focusedCellField:b!=null&&b.id===I.id?b.field:null,colspanMap:F,rowSpanningCaches:z,rowHeight:p,rowMeta:B.get(I.id)},I.id)),K==="infinite"&&W&&$>0&&r.jsx("div",{className:"ogx__skeleton-group",children:Array.from({length:H}).map((I,O)=>r.jsx(At,{row:{id:`__skeleton_${O}__`,_isSkeleton:!0},columns:l,rowIndex:L+O,rowHeight:p},`__skeleton_${O}__`))})]})})}function Br(){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 Dr(){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 sn(n){const{columns:t,visibleColumns:e,onVisibilityChange:o,onShowAll:i,onHideAll:l,onColumnReorder:a,onColumnOrderReset:d,showNonHideableColumns:c}=n,[u,p]=s.useState(""),[w,x]=s.useState(null),g=s.useRef(null),f=s.useMemo(()=>t.filter(C=>C.hideable!==!1),[t]),h=f.every(C=>e.has(C.field)),v=s.useMemo(()=>{const C=c?t:f;if(!u)return C;const S=u.toLowerCase();return C.filter(j=>(j.headerName||j.field).toLowerCase().includes(S))},[t,f,u,c]),E=C=>{C.target.checked?i():l()},m=C=>S=>{g.current=C,S.dataTransfer.effectAllowed="move",S.dataTransfer.setDragImage(S.currentTarget.closest(".ogx-column-visibility-panel__item"),20,20)},y=C=>S=>{S.preventDefault(),S.dataTransfer.dropEffect="move",C!==g.current&&x(C)},M=()=>{x(null)},N=C=>S=>{S.preventDefault();const j=g.current;x(null),g.current=null,j&&j!==C&&a&&a(j,C)},k=()=>{x(null),g.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(Br,{}),r.jsx("input",{autoComplete:"off",className:"ogx-column-visibility-panel__search-input",placeholder:"Search",value:u,onChange:C=>p(C.target.value)})]})}),r.jsx("div",{className:"ogx-column-visibility-panel__list",children:v.map(C=>{const S=e.has(C.field),j=C.hideable!==!1,P=w===C.field,b=!!a&&!u;return r.jsxs("div",{className:["ogx-column-visibility-panel__item",!j&&"ogx-column-visibility-panel__item--disabled",P&&"ogx-column-visibility-panel__item--drag-over"].filter(Boolean).join(" "),draggable:b,onDragOver:b?y(C.field):void 0,onDragLeave:b?M:void 0,onDrop:b?N(C.field):void 0,onDragEnd:b?k:void 0,children:[b&&r.jsx("span",{className:"ogx-column-visibility-panel__drag-handle-wrapper",draggable:!0,onDragStart:m(C.field),title:"Drag to reorder",children:r.jsx(Dr,{})}),r.jsxs("label",{className:"ogx-column-visibility-panel__item-label",style:{display:"flex",alignItems:"center",gap:"var(--ogx-spacing-md)",flex:1,cursor:j?"pointer":"not-allowed"},children:[r.jsx(bt,{checked:S,onChange:F=>o(C.field,F.target.checked),disabled:!j}),r.jsx("span",{className:"ogx-column-visibility-panel__label",children:C.headerName||C.field})]})]},C.field)})}),r.jsxs("div",{className:"ogx-column-visibility-panel__footer",children:[r.jsxs("label",{className:"ogx-column-visibility-panel__item",children:[r.jsx(bt,{checked:h,onChange:E}),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(),d?.()},children:"Reset"})]})]})}function Hr({isOpen:n,containerRef:t,panelRef:e,effectiveColumns:o,columnVisibilityModel:i,effectiveColumnOrder:l,columnOrder:a,disableColumnReorder:d,onClose:c,onColumnVisibilityChange:u,onColumnOrderChange:p,setInternalColumnOrder:w}){const[x,g]=s.useState(16),[f,h]=s.useState(16),[v,E]=s.useState(()=>document.body);if(s.useLayoutEffect(()=>{if(!n||!t.current)return;const y=t.current.getBoundingClientRect();g(y.top+8),h(window.innerWidth-y.right+8),E(t.current.closest(".ogx-theme-provider")||document.body)},[n,t]),!n)return null;const m=d?void 0:(y,M)=>{const N=[...l],k=N.indexOf(y),C=N.indexOf(M);if(k===-1||C===-1)return;const S=[...N];S.splice(k,1),S.splice(C,0,y),a||w(S),p?.({oldIndex:k,targetIndex:C,column:o.find(j=>j.field===y)})};return Ve.createPortal(r.jsxs("div",{ref:e,style:{position:"fixed",top:x,right:f,zIndex:9999,display:"inline-block"},children:[r.jsx("button",{onClick:c,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(sn,{columns:o,visibleColumns:new Set(o.filter(y=>i[y.field]!==!1).map(y=>y.field)),onVisibilityChange:(y,M)=>{u({...i,[y]:M})},onShowAll:()=>{const y={...i};o.forEach(M=>{M.hideable!==!1&&(y[M.field]=!0)}),u(y)},onHideAll:()=>{const y={...i};o.forEach(M=>{M.hideable!==!1&&(y[M.field]=!1)}),u(y)},onColumnReorder:m})]}),v)}const Vr=new Map;function Gr(n){const{rows:t,columns:e,getRowId:o,rowHeight:i=52,headerHeight:l=56,autoHeight:a=!1,density:d,checkboxSelection:c=!1,disableRowSelectionOnClick:u=!1,disableMultipleRowSelection:p=!1,rowSelectionModel:w,onRowSelectionModelChange:x,onRowClick:g,onRowDoubleClick:f,onCellClick:h,filterModel:v,onFilterModelChange:E,sortModel:m,onSortModelChange:y,pagination:M=!1,paginationModel:N,onPaginationModelChange:k,pageSizeOptions:C=[10,25,50,100],pinnedColumns:S,onPinnedColumnsChange:j,pinnedRows:P,getDetailPanelContent:b,getDetailPanelHeight:F,detailPanelExpandedRowIds:z,onDetailPanelExpandedRowIdsChange:K,pinCheckboxColumn:W=!0,pinExpandColumn:$=!0,disableColumnReorder:H=!1,columnOrder:L,onColumnOrderChange:B,height:D,rowReordering:_=!1,onRowOrderChange:T,loading:I=!1,treeData:O=!1,getTreeDataPath:X,defaultGroupingExpansionDepth:te,groupingColDef:Z,rowGroupingModel:ce,aggregationModel:le,onAggregationModelChange:G,getAggregationPosition:R,isCellEditable:Y,processRowUpdate:Q,onProcessRowUpdateError:J,dataSource:re,multiSort:q=!1,sortingMode:V="client",filterMode:A="client",paginationMode:ee="client",rowCount:ie,slots:ae,slotProps:fe,pivotMode:he=!1,pivotModel:Me,onPivotModelChange:ke,className:Pe="",style:Se,onRowsScrollEnd:oe,ariaLabel:je,initialState:Qn,onStateChange:Li,columnVisibilityModel:Fi,onColumnVisibilityModelChange:Oi,listView:yt=!1,listViewColumn:Zn,columnGroupingModel:Ge,noRowsLabel:Wi="No Data",localeText:$e,apiRef:dn,overscanRowCount:Ai=3}=n,cn=$e?.noRowsLabel??Wi,$i=s.useMemo(()=>({items:[]}),[]),Le=v||$i,zi=s.useMemo(()=>[],[]),un=ce||zi,eo=s.useRef(ae?.toolbar);eo.current=ae?.toolbar;const Bi=s.useRef(U=>{const ne=eo.current;return ne?ne(U):null}).current,Di=Eo({initialState:Qn,sortModel:m,aggregationModel:le,onAggregationModelChange:G,columnVisibilityModel:Fi,onColumnVisibilityModelChange:Oi,pinnedColumns:S,onPinnedColumnsChange:j,pivotModel:Me,onPivotModelChange:ke,paginationModel:N,onPaginationModelChange:k,rowSelectionModel:w}),{sortModel:We,isSortControlled:$t,setInternalSortModel:zt,aggregationModel:Re,handleAggregationModelChange:to,columnVisibilityModel:Ue,handleColumnVisibilityModelChange:Bt,pinnedColumns:tt,handlePinnedColumnsChange:fn,currentPivotModel:gn,handlePivotModelChange:no,effectivePaginationModel:Ee,handlePaginationModelChange:Dt,selectedRowIds:Ce,isSelectionControlled:nt,setInternalRowSelectionModel:ot}=Di,rt=x,Ht=$n(t,e,gn,he),De=d==="compact"?32:d==="comfortable"?72:i,oo=he&&Ht.isValid?Ht.pivotRows:t,hn=he&&Ht.isValid?Ht.pivotColumns:e,Vt=!!(ce&&ce.length>0),Ke=s.useMemo(()=>Z&&Vt&&!he?{...tt,left:["__group__",...(tt?.left??[]).filter(U=>U!=="__group__")]}:tt,[Z,Vt,he,tt]),kt=s.useMemo(()=>Z&&Vt&&!he?[{headerName:"Group",width:220,...Z,field:"__group__",hideable:!1,sortable:!1,pinnable:!1,exportable:!1},...hn]:hn,[Z,Vt,he,hn]),[Hi,ro]=s.useState(null);s.useEffect(()=>{ro(null)},[Re]);const it=s.useRef(null),Vi=s.useRef(null),Gt=s.useRef(null),Gi=s.useCallback(U=>U.id,[]),lt=o||Gi,pn=s.useMemo(()=>oo.map(U=>{const ne=lt(U);return ne===U.id?U:{...U,id:ne}}),[oo,lt]),st=s.useCallback(U=>{yn.current?.classList.toggle("ogx--kb",U)},[]),io=s.useRef(re);io.current=re;const lo=s.useRef(null),so=s.useRef(null),Ui=s.useCallback(U=>{if(io.current&&O&&(U.serverChildrenCount??0)>0&&(U.children??[]).length===0){const ne=so.current?.getNodePath(U.id)||[U.groupingKey];lo.current?.(U.id,ne)}},[O]),_e=fr({rows:pn,columns:kt,rowHeight:De,headerHeight:l,rowCount:ie,columnVisibilityModel:Ue,initialState:n.initialState}),{state:pe,apiRef:at,setRows:xn,setColumns:Ki,setDimensions:ao,setDataSourceLoading:Yi,setDataSourceError:qi,setRowCount:Xi}=_e,{scrollTop:Ji,scrollLeft:Qi,overscanRows:Zi,handleScroll:el}=zo({onRowsScrollEnd:oe,overscanRowCount:Ai});s.useEffect(()=>{dn&&(dn.current=at.current)},[dn,at]);const{copySelectedRows:co}=Sr({selectedRowIds:Ce,columns:kt,getVisibleRows:()=>at.current.getVisibleRows(),getRowId:lt});s.useEffect(()=>{at.current.copySelectedRows=co,at.current.getSelectedRows=()=>Array.from(Ce)},[co,Ce,at]);const tl=pe.dataSource.loading,St=I||tl,Ye=s.useMemo(()=>pe.rows.allRows.map(U=>pe.rows.idRowsLookup.get(U)),[pe.rows]),jt=hr({rows:Ye,getRowId:lt,getTreeDataPath:X,treeData:O,defaultGroupingExpansionDepth:te,filterModel:Le,sortModel:We,onRowExpansionChange:Ui});s.useEffect(()=>{so.current=jt},[jt]);const Et=wr({rows:Ye,getRowId:lt,columns:kt,rowGroupingModel:un,aggregationModel:Re,defaultGroupingExpansionDepth:te,filterModel:Le,sortModel:We,getAggregationPosition:R}),dt=br({rows:Ye,getRowId:lt,processRowUpdate:Q,onProcessRowUpdateError:J,onRowChange:U=>{const{dispatch:ne}=_e,ue=Array.from(_e.state.rows.idRowsLookup.values()).map(ge=>ge.id===U.id?U:ge);ne({type:"SET_ROWS",payload:ue})}}),Nt=O,Ae=!!(un&&un.length>0),mn=Nt||Ae,Ut=Nt?jt:Ae?Et:null,Mt=s.useMemo(()=>Nt?jt.rowMetaMap:Ae?Et.rowMetaMap:Vr,[Nt,jt.rowMetaMap,Ae,Et.rowMetaMap]),Fe=M&&!Ae,Kt=s.useCallback(U=>{const{row:ne,id:de}=U;if(mn&&Mt.get(ne.id)?.hasChildren){Ut?.toggleExpansion(de);return}if(g?.(U),!u){let ue;if(p)ue=Ce.has(de)?[]:[de];else{const ge=new Set(Ce);ge.has(de)?ge.delete(de):ge.add(de),ue=Array.from(ge)}nt||ot(ue),rt?.(ue)}},[mn,Ut,g,Mt,u,p,Ce,nt,ot,rt]),wn=Cr({dataSource:re,sortModel:We,filterModel:Le,paginationModel:Ee,paginationMode:ee,sortingMode:V,filterMode:A,aggregationModel:Re,setRows:xn,setRowCount:Xi,setDataSourceLoading:Yi,setDataSourceError:qi,onAggregationResults:ro});s.useEffect(()=>{wn.fetchChildren&&(lo.current=wn.fetchChildren)},[wn.fetchChildren]),s.useEffect(()=>{re||xn(pn)},[pn,xn,re]);const ze=!!b,[nl,ol]=s.useState(new Set),ct=z??nl,Yt=s.useCallback(U=>{const ne=new Set(ct);ne.has(U)?ne.delete(U):ne.add(U),z===void 0&&ol(ne),K?.(ne)},[ct,z,K]),{effectiveColumns:He,orderedColumns:bn,visibleOrderedColumns:rl,navigationColumns:uo,columnWidths:Be,effectiveColumnOrder:qt,setInternalColumnOrder:Xt,columnReorderHandlers:ut,handleColumnResize:il}=Wo({activeColumns:kt,isHierarchyEnabled:mn,isRowGrouping:Ae,isTreeData:Nt,activeHierarchyHandlers:Ut,columnVisibilityModel:Ue,columnOrder:L,onColumnOrderChange:B,disableColumnReorder:H,pivotMode:he,checkboxSelection:c,hasDetailPanel:ze,rowReordering:_,initialState:Qn,setColumns:Ki});Bo({onStateChange:Li,sortModel:We,filterModel:Le,effectivePaginationModel:Ee,columnWidths:Be,effectiveColumnOrder:qt,columnVisibilityModel:Ue,pinnedColumns:Ke});const ft=Lo({effectiveRows:Ye,activeHierarchyHandlers:Ut,filterMode:A,filterModel:Le,dataSource:re,sortModel:We,sortingMode:V,pagination:Fe,paginationMode:ee,effectivePaginationModel:Ee,pinnedRows:P,isLoading:pe.dataSource.loading,pageSize:Ee.pageSize}),qe=ft.filteredRows,Pt=ft.pinnedTopRows,Jt=ft.pinnedBottomRows,Oe=ft.sortedUnpinnedRows,gt=ft.paginatedUnpinnedRows,vn=ft.allRenderableRows;s.useEffect(()=>{_e.apiRef.current.getVisibleRows=()=>Fe?gt:Oe,_e.apiRef.current.getAllFilteredRows=()=>Oe,_e.apiRef.current.getVisibleColumns=()=>He},[Oe,gt,Fe,He,_e.apiRef]);const ll=gr({rows:Fe?gt:Oe,getRowId:U=>U.id,onRowOrderChange:T,rowReordering:_}),ht=vr(vn,uo,Be),{aggregationResult:pt}=Tn({rows:qe,columns:kt,aggregationModel:Re,isServerSide:!!(re&&(ee==="server"||V==="server")),dataSource:re,filterModel:Le,sortModel:We,serverAggregationResults:Hi}),Xe=Object.keys(Re).length>0;s.useEffect(()=>{_e.apiRef.current.getAggregationResult=()=>Xe?pt:null,_e.apiRef.current.getAggregationModel=()=>Xe?Re:null,_e.apiRef.current.getGroupedExportRows=()=>{if(!Ae)return null;const{treeNodes:U,groupingRows:ne}=Et,de=new Map;Oe.forEach(xe=>de.set(xe.id,xe));const ue=[],ge=xe=>{xe.forEach(ye=>{const we=U.get(ye);if(!we)return;if(!!(we.children&&we.children.length>0))ue.push({type:"group-header",depth:we.depth,groupField:we.groupingField,groupValue:we.groupingValue}),ge(we.children),Xe&&we.aggregatedValues&&ue.push({type:"group-subtotal",depth:we.depth,groupField:we.groupingField,groupValue:we.groupingValue,aggregatedValues:we.aggregatedValues});else{const Lt=de.get(ye)??ne.get(ye);Lt&&ue.push({type:"leaf",depth:we.depth,row:Lt})}})};return ge(Array.from(U.keys()).filter(xe=>U.get(xe)?.parentId===null)),Xe&&pt&&ue.push({type:"grand-total",depth:0,aggregatedValues:pt}),ue}},[pt,Re,Xe,_e.apiRef,Ae,Et,Oe]);const me=ko({rowHeight:De,pagination:Fe,paginatedUnpinnedRows:gt,sortedUnpinnedRows:Oe,expandedRowIds:ct,getDetailPanelHeight:F,pinnedTopRowsLength:Pt.length,pinnedBottomRowsLength:Jt.length,visibleOrderedColumns:rl,pinnedColumns:Ke,columnWidths:Be,viewportWidth:pe.dimensions.viewportWidth||1e3,checkboxSelection:c,hasDetailPanel:ze,rowReordering:_,paginationMode:ee,isLoading:pe.dataSource.loading,pageSize:Ee.pageSize}),sl=s.useMemo(()=>{const U={};for(const ne of[...me.leftPinnedCols,...me.unpinnedColsWithWidth,...me.rightPinnedCols])ne.isSpacer||(U[ne.field]=ne.width);return{...U,...Be}},[me.leftPinnedCols,me.unpinnedColsWithWidth,me.rightPinnedCols,Be]);s.useEffect(()=>{_e.apiRef.current.scrollToIndexes=({rowIndex:U,colIndex:ne})=>{const de=it.current;if(de&&(U!==void 0&&U>=0&&Mn(de,U,me.cumulativeHeights,me.pinnedBottomHeight),ne!==void 0&&ne>=0)){const ge=[...me.leftPinnedCols,...me.unpinnedColsWithWidth,...me.rightPinnedCols][ne];if(!ge)return;const xe=me.unpinnedColsWithWidth.findIndex(xl=>xl.field===ge.field);if(xe===-1)return;const ye=xe>0?me.unpinnedAccWidths[xe-1]:0,we=me.unpinnedAccWidths[xe]??ye,It=me.leftWidth+we,{scrollLeft:Lt,clientWidth:wo}=de;ye<Lt?de.scrollLeft=ye:It>Lt+wo&&(de.scrollLeft=It-wo)}}},[me,it,_e.apiRef]);const Te=Fo({layout:me,scrollTop:Ji,scrollLeft:Qi,viewportWidth:pe.dimensions.viewportWidth,viewportHeight:pe.dimensions.viewportHeight,autoHeight:a,rowReordering:_,hasDetailPanel:ze,checkboxSelection:c,pinCheckboxColumn:W,pinExpandColumn:$,overscanRows:Zi});s.useEffect(()=>{if(!it.current)return;const U=new ResizeObserver(ne=>{for(const de of ne){const{width:ue,height:ge}=de.contentRect;ao(ue,ge)}});return U.observe(it.current),()=>{U.disconnect()}},[ao]);const Rt=s.useCallback((U,ne)=>{const de=new Set(Ce);ne?de.add(U):de.delete(U);const ue=Array.from(de);nt||ot(ue),rt?.(ue)},[Ce,nt,rt,ot]),al=s.useCallback(U=>{let ne=[];U&&(ne=Ye.map(de=>de.id)),nt||ot(ne),rt?.(ne)},[Ye,nt,rt,ot]),fo=s.useCallback((U,ne)=>{const de=ne?[{field:U,sort:ne}]:[];$t||zt(de),y?.(de)},[$t,y,zt]),dl=s.useCallback((U,ne)=>{const de=We.filter(ge=>ge.field!==U),ue=ne?[...de,{field:U,sort:ne}]:de;$t||zt(ue),y?.(ue)},[We,$t,y,zt]),{focusedCell:Qt,setFocusedCell:Cn,handleFocus:cl,handleBlur:ul,handleKeyDown:fl}=So({allRenderableRows:vn,navigationColumns:uo,checkboxSelection:c,selectedRowIds:Ce,handleSelectionChange:Rt,handleDetailPanelToggle:Yt,editingHandlers:dt,setKeyboardMode:st,sortModel:We,handleSort:fo,isCellEditable:Y,pagination:Fe,pageSize:Ee.pageSize,virtualization:Te,viewportRef:it,pinnedTopRowCount:Pt.length}),_n=s.useCallback(U=>{st(!1),Cn({id:U.row.id,field:U.field}),Gt.current?.focus({preventScroll:!0}),h?.(U)},[h,st,Cn]),go=s.useRef(dt.editingCell);s.useEffect(()=>{const U=!!go.current,ne=!!dt.editingCell;U&&!ne&&Gt.current?.focus({preventScroll:!0}),go.current=dt.editingCell},[dt.editingCell]);const ho=Ao({renderContext:Te.renderContext,pinnedTopRows:Pt,pinnedBottomRows:Jt,paginatedUnpinnedRows:gt,sortedUnpinnedRows:Oe,pagination:Fe});Ho({paginationRequested:M,isRowGrouping:Ae,autoHeight:a,viewportHeight:pe.dimensions.viewportHeight,renderedRowCount:ho.length,totalRowCount:Pt.length+(Fe?gt.length:Oe.length)+Jt.length});const gl=t.length>0&&Ce.size===t.length,hl=Ce.size>0&&Ce.size<t.length,pl=s.useMemo(()=>He.some(U=>!!U.rowSpan),[He]),[Tt,Zt]=s.useState(!1),yn=s.useRef(null),kn=s.useRef(null),po=ae?.noRowsOverlay,xo=ae?.loadingOverlay,Sn=ae?.footer,mo=s.useMemo(()=>{if(!ae?.toolbar)return null;const U=H?void 0:(ne,de)=>{const ue=[...qt],ge=ue.indexOf(ne),xe=ue.indexOf(de);if(ge===-1||xe===-1)return;const ye=[...ue];ye.splice(ge,1),ye.splice(xe,0,ne),L||Xt(ye);const we=He.find(It=>It.field===ne);we&&B?.({oldIndex:ge,targetIndex:xe,column:we})};return{apiRef:_e.apiRef,columns:bn,baseColumns:e,aggregationModel:Re,onAggregationModelChange:to,...he||Me||ke?{pivotModel:gn,onPivotModelChange:no}:{},filterModel:Le,onFilterModelChange:E,columnVisibilityModel:Ue,onColumnVisibilityModelChange:Bt,onColumnReorder:U,onColumnOrderReset:H?void 0:()=>Xt(e.map(ne=>ne.field)),forceColumnsOpen:Tt,onColumnsPanelClose:()=>Zt(!1),...fe?.toolbar}},[ae?.toolbar,H,qt,bn,He,L,B,Xt,_e.apiRef,e,Re,to,he,Me,ke,gn,no,Le,E,Ue,Bt,Tt,fe?.toolbar]);return s.useEffect(()=>{if(!Tt||ae?.toolbar)return;function U(ne){kn.current&&!kn.current.contains(ne.target)&&Zt(!1)}return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[Tt,ae?.toolbar]),r.jsxs("div",{ref:yn,className:["ogx",Pe,a&&"ogx--auto-height",pl&&"ogx--row-spanning",yt&&"ogx--list-view"].filter(Boolean).join(" "),style:{...Se,height:D??Se?.height,"--ogx-row-height":`${De}px`,"--ogx-header-height":`${l}px`},"aria-busy":St,children:[mo&&r.jsx(Bi,{...mo}),!ae?.toolbar&&r.jsx(Hr,{isOpen:Tt,containerRef:yn,panelRef:kn,effectiveColumns:He,columnVisibilityModel:Ue,effectiveColumnOrder:qt,columnOrder:L,disableColumnReorder:H,onClose:()=>Zt(!1),onColumnVisibilityChange:Bt,onColumnOrderChange:B,setInternalColumnOrder:Xt}),yt&&Zn&&r.jsx(Er,{ariaLabel:je,allRenderableRows:vn,filteredRows:qe,pagination:Fe,effectivePaginationModel:Ee,pageSizeOptions:C,selectedRowIds:Ce,listViewColumn:Zn,noRowsLabel:cn,rowHeight:De,checkboxSelection:c,paginationMode:ee,dataSource:re,serverRowCount:pe.pagination.rowCount||0,paginationSlot:ae?.pagination,paginationSlotProps:fe?.pagination,localeText:$e?{paginationRowsPerPage:$e.paginationRowsPerPage,paginationOf:$e.paginationOf,paginationPage:$e.paginationPage}:void 0,onRowClick:Kt,onRowDoubleClick:f,onSelectionChange:Rt,onPaginationModelChange:Dt}),!yt&&r.jsx("div",{ref:U=>{it.current=U,Gt.current=U},className:"ogx__viewport",onScroll:el,role:"grid","aria-label":je||"Data grid","aria-rowcount":qe.length+1,"aria-colcount":e.length+(c?1:0)+(ze?1:0)+(_?1:0),"aria-busy":St,tabIndex:0,onKeyDownCapture:()=>{st(!0)},onMouseDownCapture:()=>{st(!1)},onKeyDown:fl,onFocus:cl,onBlur:ul,children:r.jsxs("div",{ref:Vi,className:"ogx__content",style:{width:Te.totalWidth},role:"presentation",children:[r.jsx(Ln,{columns:Te.virtualColumns,allColumns:He,columnGroupingModel:Ge,checkboxSelection:c,allSelected:gl,someSelected:hl,onSelectAll:al,sortModel:We,onSort:fo,onSortAdd:dl,multiSort:q,onColumnResize:il,columnWidths:Be,pinnedColumns:Ke,focusedCell:Qt,onHeaderClick:U=>{Cn({id:"HEADER",field:U}),st(!1),Gt.current?.focus({preventScroll:!0})},onDragStart:Ge?void 0:ut.onDragStart,onDragOver:Ge?void 0:ut.onDragOver,onDragEnd:Ge?void 0:ut.onDragEnd,onDrop:Ge?void 0:ut.onDrop,draggedColumn:Ge?void 0:ut.draggedColumn,dragOverColumn:Ge?void 0:ut.dragOverColumn,rowReordering:_,hasDetailPanel:ze,pinCheckboxColumn:W,pinExpandColumn:$,aggregationModel:Re,onHideColumn:U=>{Bt({...Ue,[U]:!1})},onManageColumns:()=>Zt(!0),onPinColumn:(U,ne)=>{const de=[...tt?.left??[]],ue=[...tt?.right??[]],ge=de.filter(ye=>ye!==U),xe=ue.filter(ye=>ye!==U);fn(ne==="left"?{left:[...ge,U],right:xe}:ne==="right"?{left:ge,right:[...xe,U]}:{left:ge,right:xe})}}),!St&&!pe.dataSource.error&&qe.length===0&&r.jsx(Yo,{noRowsLabel:cn,width:Te.totalWidth,overlay:po?r.jsx(po,{...fe?.noRowsOverlay}):void 0}),r.jsx(Bn,{rows:Pt,position:"top",columns:Te.virtualColumns,selectedRowIds:Ce,checkboxSelection:c,onRowClick:Kt,onRowDoubleClick:f,onCellClick:_n,onSelectionChange:Rt,columnWidths:Be,pinnedColumns:Ke,pinnedRows:P,hasDetailPanel:ze,expandedRowIds:ct,getDetailPanelContent:b,getDetailPanelHeight:F,onDetailPanelToggle:Yt,pinCheckboxColumn:W,pinExpandColumn:$,focusedCell:Qt,colspanMap:ht.colspanMap,rowSpanningCaches:ht.rowSpanningState.caches,rowHeight:De,rowMetaMap:Mt}),r.jsx(zr,{virtualContainerHeight:Te.totalHeight-Te.pinnedTopHeight-Te.pinnedBottomHeight,offsetTop:Te.offsetTop,effectiveLoading:St,visibleRows:ho,baseColumns:e,virtualColumns:Te.virtualColumns,viewportWidth:pe.dimensions.viewportWidth,checkboxSelection:c,hasDetailPanel:ze,rowReordering:_,rowHeight:De,pinnedRows:P,selectedRowIds:Ce,onRowClick:Kt,onRowDoubleClick:f,onCellClick:_n,onSelectionChange:Rt,columnWidths:Be,pinnedColumns:Ke,expandedRowIds:ct,getDetailPanelContent:b,getDetailPanelHeight:F,onDetailPanelToggle:Yt,pinCheckboxColumn:W,pinExpandColumn:$,rowReorderHandlers:ll,editingHandlers:dt,focusedCell:Qt,colspanMap:ht.colspanMap,rowSpanningCaches:ht.rowSpanningState.caches,paginationMode:ee,dataSourceLoading:pe.dataSource.loading,sortedUnpinnedRowCount:Oe.length,infiniteScrollSkeletonCount:Math.min(Ee.pageSize,20),unpinnedRowsLength:me.unpinnedRowsLength,rowMetaMap:Mt,loadingOverlay:xo?r.jsx(xo,{...fe?.loadingOverlay}):void 0}),r.jsx(Bn,{rows:Jt,position:"bottom",columns:Te.virtualColumns,selectedRowIds:Ce,checkboxSelection:c,onRowClick:Kt,onRowDoubleClick:f,onCellClick:_n,onSelectionChange:Rt,columnWidths:Be,pinnedColumns:Ke,pinnedRows:P,hasDetailPanel:ze,expandedRowIds:ct,getDetailPanelContent:b,getDetailPanelHeight:F,onDetailPanelToggle:Yt,pinCheckboxColumn:W,pinExpandColumn:$,focusedCell:Qt,colspanMap:ht.colspanMap,rowSpanningCaches:ht.rowSpanningState.caches,rowHeight:De,rowMetaMap:Mt}),Xe&&!he&&r.jsx(Ko,{columns:bn,aggregationModel:Re,aggregationResult:pt,columnWidths:sl,rowHeight:De,checkboxSelection:c,hasDetailPanel:ze,rowReordering:_,pinnedColumns:Ke})]})}),!yt&&Sn&&r.jsx(Sn,{apiRef:_e.apiRef,aggregationModel:Re,aggregationResult:Xe?pt:null,rowCount:Ae?Ye.length:Oe.length,pagination:Fe,paginationModel:Ee,pageSizeOptions:C,onPaginationModelChange:Dt,...fe?.footer}),!yt&&!Sn&&Fe&&(()=>{const U=ae?.pagination||Fn;return r.jsx(U,{page:Ee.page,pageSize:Ee.pageSize,rowCount:pe.pagination.rowCount,pageSizeOptions:C,onPageChange:ne=>Dt({...Ee,page:ne}),onPageSizeChange:ne=>Dt({...Ee,pageSize:ne,page:0}),localeText:$e?{paginationRowsPerPage:$e.paginationRowsPerPage,paginationOf:$e.paginationOf,paginationPage:$e.paginationPage}:void 0,...fe?.pagination})})(),r.jsxs("div",{className:"ogx-aria-live-status",role:"status","aria-live":"polite",children:[St?"Loading data...":"",pe.dataSource.error?`Error: ${pe.dataSource.error instanceof Error?pe.dataSource.error.message:"Unknown error"}`:"",!I&&!pe.dataSource.error&&(qe.length===0?cn:Le&&((Le.quickFilterValues?.length||0)>0||(Le.items?.length||0)>0)?`${qe.length} ${qe.length===1?"row":"rows"} found`:"")]}),r.jsx(qo,{error:pe.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,l)=>r.jsx("div",{className:"ogx__skeleton-cell",children:r.jsx("div",{className:"ogx__skeleton-content"})},l))},o))})}const Dn=new Set(["isEmpty","isNotEmpty"]);function Kr(n,t){return n.find(e=>"field"in e&&e.field===t)}const Yr=({col:n,item:t,onChange:e})=>{const o=s.useId(),i=To(n.type),l=!!t,a=t?.operator??i[0],[d,c]=s.useState(t?.value!=null?String(t.value):""),u=s.useRef(e),p=s.useRef(t),w=s.useRef(n.field),x=s.useRef(a);s.useLayoutEffect(()=>{u.current=e,p.current=t,w.current=n.field,x.current=a});const g=s.useRef(t?.value);s.useEffect(()=>{t?.value!==g.current&&(g.current=t?.value,c(t?.value!=null?String(t.value):""))},[t?.value]),s.useEffect(()=>{const y=setTimeout(()=>{const M=p.current,N=M?.value??"";d!==N&&u.current({id:M?.id??`${w.current}-${Date.now()}`,field:w.current,operator:x.current,value:d})},300);return()=>clearTimeout(y)},[d]);const f=y=>{const M=Dn.has(y),N={id:t?.id??`${n.field}-${Date.now()}`,field:n.field,operator:y,value:M?void 0:t?.value??(n.type==="boolean"?"true":"")};e(N)},h=()=>{c(""),e(null)},v=Dn.has(String(a)),E=n.type==="boolean",m=!v;return r.jsxs("div",{className:`ogx-filter__row${l?" 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${l?" ogx-filter__op-select--active":""}`,value:String(a),onChange:y=>f(y.target.value),"aria-label":`Filter operator for ${n.headerName||n.field}`,children:i.map(y=>r.jsx("option",{value:y,children:y},y))}),m&&E&&r.jsxs("select",{id:`${o}-val`,name:`filter-val-${n.field}`,className:`ogx-filter__value-input ogx-filter__value-select${l?" ogx-filter__value-input--active":""}`,value:String(t?.value??"true"),onChange:y=>{c(y.target.value),e({id:t?.id??`${n.field}-${Date.now()}`,field:n.field,operator:a,value:y.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"})]}),m&&!E&&r.jsx("input",{id:`${o}-val`,name:`filter-val-${n.field}`,className:`ogx-filter__value-input${l?" ogx-filter__value-input--active":""}`,type:"text",value:d,onChange:y=>c(y.target.value),placeholder:n.type==="number"?"Number…":"Value…","aria-label":`Filter value for ${n.headerName||n.field}`}),l&&r.jsx("button",{className:"ogx-filter__row-clear",onClick:h,"aria-label":`Clear filter for ${n.headerName||n.field}`,title:"Clear",children:"×"})]})]})},Hn=({filterModel:n,columns:t,onFilterModelChange:e})=>{const o=s.useMemo(()=>n.items??[],[n.items]),i=n.logicOperator??"and",l=s.useCallback((c,u)=>{const p=o.filter(x=>"field"in x&&x.field!==c),w=u?[...p,u]:p;e({...n,items:w})},[o,n,e]),a=s.useCallback(c=>{e({...n,logicOperator:c})},[n,e]),d=t.filter(c=>c.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:()=>a("and"),"aria-pressed":i==="and",children:"ALL (AND)"}),r.jsx("button",{className:`ogx-filter__logic-pill${i==="or"?" ogx-filter__logic-pill--active":""}`,onClick:()=>a("or"),"aria-pressed":i==="or",children:"ANY (OR)"})]}),d.length===0?r.jsx("div",{className:"ogx-filter__empty",children:"No filterable columns."}):d.map(c=>r.jsx(Yr,{col:c,item:Kr(o,c.field),onChange:u=>l(c.field,u)},c.field))]})},qr=["sum","avg","count","min","max"];function Vn(){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 Xr({anchorRef:n,columns:t,model:e,onChange:o,onClose:i}){const l=s.useRef(null),[a,d]=s.useState({top:0,right:0}),[c,u]=s.useState(document.body);s.useLayoutEffect(()=>{u(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const p=s.useCallback(()=>{if(!n.current)return{top:0,right:0};const b=n.current.getBoundingClientRect();return{top:b.bottom+6,right:window.innerWidth-b.right}},[n]);s.useEffect(()=>{d(p());const b=()=>d(p());return window.addEventListener("scroll",b,!0),window.addEventListener("resize",b),()=>{window.removeEventListener("scroll",b,!0),window.removeEventListener("resize",b)}},[p]),s.useEffect(()=>{function b(z){l.current&&!l.current.contains(z.target)&&n.current&&!n.current.contains(z.target)&&i()}function F(z){z.key==="Escape"&&i()}return document.addEventListener("mousedown",b),document.addEventListener("keydown",F),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",F)}},[n,i]);const w=new Set(e.rowFields),x=new Set(e.columnFields),g=new Set(e.valueFields.map(b=>b.field)),f=b=>w.has(b)||x.has(b)||g.has(b);function h(b){w.has(b)||o({...e,rowFields:[...e.rowFields,b]})}function v(b){x.has(b)||o({...e,columnFields:[...e.columnFields,b]})}function E(b,F="sum"){g.has(b)||o({...e,valueFields:[...e.valueFields,{field:b,aggFn:F}]})}function m(b){o({...e,rowFields:e.rowFields.filter(F=>F!==b)})}function y(b){o({...e,columnFields:e.columnFields.filter(F=>F!==b)})}function M(b){o({...e,valueFields:e.valueFields.filter(F=>F.field!==b)})}function N(b,F){o({...e,valueFields:e.valueFields.map(z=>z.field===b?{...z,aggFn:F}:z)})}function k(){o({rowFields:[],columnFields:[],valueFields:[]})}const C=new Set(t.filter(b=>b.type==="number"||b.aggregable).map(b=>b.field)),S=e.rowFields.length+e.columnFields.length+e.valueFields.length,j=b=>t.find(F=>F.field===b)?.headerName??b,P=r.jsxs("div",{ref:l,className:"ogx-pivot-panel",role:"dialog","aria-label":"Pivot configuration",style:{top:a.top,right:a.right},children:[r.jsxs("div",{className:"ogx-pivot-panel__header",children:[r.jsxs("span",{className:"ogx-pivot-panel__title",children:[r.jsx(Vn,{}),"Pivot Mode"]}),S>0&&r.jsx("button",{className:"ogx-pivot-panel__reset-btn",onClick:k,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(b=>r.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--row",children:[j(b),r.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>m(b),title:`Remove ${j(b)}`,children:"×"})]},b))})]}),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(b=>r.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--col",children:[j(b),r.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>y(b),title:`Remove ${j(b)}`,children:"×"})]},b))})]}),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(b=>r.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--value",children:[j(b.field),r.jsx("select",{className:"ogx-pivot-chip__fn-select",value:b.aggFn,onChange:F=>N(b.field,F.target.value),title:"Aggregation function",children:qr.map(F=>r.jsx("option",{value:F,children:F.toUpperCase()},F))}),r.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>M(b.field),title:`Remove ${j(b.field)}`,children:"×"})]},b.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(b=>{const F=C.has(b.field);return f(b.field)?null:r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3},children:[r.jsx("span",{className:`ogx-pivot-field-btn${F?" ogx-pivot-field-btn--numeric":""}`,children:b.headerName??b.field}),r.jsxs("div",{className:"ogx-pivot-field-actions",children:[r.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--row",onClick:()=>h(b.field),title:"Add to Row Fields",children:"Row"}),r.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--col",onClick:()=>v(b.field),title:"Add to Column Fields",children:"Col"}),F&&r.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--value",onClick:()=>E(b.field),title:"Add to Value Fields",children:"Val"})]})]},b.field)}),t.every(b=>f(b.field))&&r.jsx("span",{style:{fontSize:12,color:"var(--ogx-color-gray-400, #94a3b8)"},children:"All fields are in use."})]})]})]})]});return Ve.createPortal(P,c)}function Jr(){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 Qr(){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 Zr({value:n="",onChange:t,placeholder:e="Search...",debounceMs:o=250}){const[i,l]=s.useState(()=>n.length>0),[a,d]=s.useState(n),c=s.useRef(null),u=s.useRef(null),p=s.useRef(t);s.useLayoutEffect(()=>{p.current=t},[t]);const w=s.useRef(n),x=s.useRef(n),g=s.useRef(!1);s.useLayoutEffect(()=>{g.current&&document.activeElement!==c.current&&c.current?.focus()}),s.useEffect(()=>{n!==x.current&&(x.current=n,n!==w.current&&(d(n),w.current=n,n?l(!0):(g.current=!1,l(!1))))},[n]),s.useEffect(()=>{const m=setTimeout(()=>{a!==w.current&&(w.current=a,p.current(a))},o);return()=>clearTimeout(m)},[a,o]);const f=s.useCallback(()=>{l(!0),requestAnimationFrame(()=>c.current?.focus())},[]),h=s.useCallback(m=>{m.stopPropagation(),d(""),w.current="",p.current(""),c.current?.focus()},[]),v=s.useCallback(()=>{g.current=!0,l(!0)},[]),E=s.useCallback(()=>{g.current=!1,setTimeout(()=>{if(u.current&&document.activeElement&&u.current.contains(document.activeElement)){g.current=!0;return}a||l(!1)},150)},[a]);return s.useEffect(()=>{const m=y=>{u.current&&!u.current.contains(y.target)&&(a||l(!1))};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[a]),r.jsxs("div",{ref:u,className:`ogx-global-search${i?" ogx-global-search--expanded":""}`,onClick:i?void 0:f,children:[r.jsx("div",{className:"ogx-global-search__icon-wrapper",children:r.jsx(Jr,{})}),r.jsx("input",{ref:c,className:"ogx-global-search__input",value:a,onChange:m=>d(m.target.value),onFocus:v,onBlur:E,placeholder:e,"aria-label":"Global Search",autoComplete:"off"}),a&&r.jsx("button",{className:"ogx-global-search__clear",onClick:h,"aria-label":"Clear search",children:r.jsx(Qr,{})})]})}function _t({title:n,children:t,placement:e="top",enterDelay:o=200,leaveDelay:i=0}){const[l,a]=s.useState(!1),[d,c]=s.useState({top:0,left:0}),u=s.useRef(null),p=s.useRef(null),w=s.useCallback(()=>{if(!p.current)return;const h=p.current.getBoundingClientRect();let v=0,E=0;const m=window.pageXOffset||document.documentElement.scrollLeft,y=window.pageYOffset||document.documentElement.scrollTop;e==="top"?(v=h.top+y-8,E=h.left+m+h.width/2):e==="bottom"&&(v=h.bottom+y+8,E=h.left+m+h.width/2),c({top:v,left:E})},[e]);s.useLayoutEffect(()=>(l&&(w(),window.addEventListener("scroll",w,!0),window.addEventListener("resize",w)),()=>{window.removeEventListener("scroll",w,!0),window.removeEventListener("resize",w)}),[l,w]);const x=()=>{u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{a(!0)},o)},g=()=>{u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{a(!1)},i)},f=s.useCallback(h=>{p.current=h?h.firstElementChild??h:null},[]);return r.jsxs(r.Fragment,{children:[r.jsx("span",{ref:f,style:{display:"inline-block",lineHeight:0},onMouseEnter:x,onMouseLeave:g,children:t}),l&&n&&Ve.createPortal(r.jsx("div",{className:`ogx-tooltip ogx-tooltip--${e}`,style:{top:d.top,left:d.left,position:"absolute",zIndex:99999},children:n}),document.body)]})}const ei=["none","sum","avg","count","min","max"];function Gn(){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 ti(){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 Un(){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 ni({anchorRef:n,aggregationModel:t,aggregableColumns:e,onFunctionChange:o,onClearAll:i,onClose:l,activeCount:a}){const d=s.useRef(null),[c,u]=s.useState({top:0,right:0}),[p,w]=s.useState(document.body);s.useLayoutEffect(()=>{w(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const x=s.useCallback(()=>{if(!n.current)return{top:0,right:0};const f=n.current.getBoundingClientRect();return{top:f.bottom+6,right:window.innerWidth-f.right}},[n]);s.useEffect(()=>{u(x());const f=()=>u(x());return window.addEventListener("scroll",f,!0),window.addEventListener("resize",f),()=>{window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[x]),s.useEffect(()=>{function f(h){d.current&&!d.current.contains(h.target)&&n.current&&!n.current.contains(h.target)&&l()}return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[n,l]),s.useEffect(()=>{function f(h){h.key==="Escape"&&l()}return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[l]);const g=r.jsxs("div",{ref:d,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Summaries configuration",style:{top:c.top,right:c.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(Gn,{}),"Summaries"]}),a>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(f=>{const h=t[f.field]||"none";return r.jsxs("div",{className:"ogx-toolbar__agg-row",children:[r.jsx("span",{className:"ogx-toolbar__agg-label",title:f.field,children:f.headerName||f.field}),r.jsx("div",{className:"ogx-toolbar__agg-pills",children:ei.map(v=>r.jsx("button",{className:`ogx-toolbar__pill${h===v?" ogx-toolbar__pill--active":""}`,onClick:()=>o(f.field,v),"aria-pressed":h===v,children:v},v))})]},f.field)})})]});return Ve.createPortal(g,p)}function oi({anchorRef:n,columns:t,visibleColumns:e,onVisibilityChange:o,onShowAll:i,onHideAll:l,onColumnReorder:a,onColumnOrderReset:d,onClose:c,showNonHideableColumns:u}){const p=s.useRef(null),[w,x]=s.useState({top:0,right:0}),[g,f]=s.useState(document.body);s.useLayoutEffect(()=>{f(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const h=s.useCallback(()=>{if(!n.current)return{top:0,right:0};const E=n.current.getBoundingClientRect();return{top:E.bottom+6,right:window.innerWidth-E.right}},[n]);s.useEffect(()=>{x(h());const E=()=>x(h());return window.addEventListener("scroll",E,!0),window.addEventListener("resize",E),()=>{window.removeEventListener("scroll",E,!0),window.removeEventListener("resize",E)}},[h]),s.useEffect(()=>{function E(m){p.current&&!p.current.contains(m.target)&&n.current&&!n.current.contains(m.target)&&c()}return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[n,c]);const v=r.jsx("div",{ref:p,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Column visibility",style:{top:w.top,right:w.right,width:280,padding:0},children:r.jsx(sn,{columns:t,visibleColumns:e,onVisibilityChange:o,onShowAll:i,onHideAll:l,onColumnReorder:a,onColumnOrderReset:d,showNonHideableColumns:u})});return Ve.createPortal(v,g)}function ri({anchorRef:n,columns:t,filterModel:e,onFilterModelChange:o,onClose:i}){const l=s.useRef(null),[a,d]=s.useState({top:0,right:0}),c=s.useRef(i);s.useLayoutEffect(()=>{c.current=i},[i]);const[u,p]=s.useState(document.body);s.useLayoutEffect(()=>{p(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const w=s.useCallback(()=>{if(!n.current)return{top:0,right:0};const h=n.current.getBoundingClientRect();return{top:h.bottom+6,right:window.innerWidth-h.right}},[n]);s.useEffect(()=>{d(w());const h=()=>d(w());return window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}},[w]),s.useEffect(()=>{function h(v){v.key==="Escape"&&c.current()}return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[]);const x=e.items?.length??0,g=()=>{o({...e,items:[],logicOperator:"and"})},f=r.jsxs("div",{ref:l,className:"ogx-toolbar__panel ogx-toolbar__panel--filter",role:"dialog","aria-label":"Advanced filters",style:{top:a.top,right:a.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(Un,{}),"Filters",x>0&&r.jsx("span",{className:"ogx-toolbar__panel-count",children:x})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[x>0&&r.jsx("button",{className:"ogx-toolbar__clear-btn",onClick:g,title:"Clear all filters",children:"Clear all"}),r.jsx("button",{className:"ogx-toolbar__close-btn",onClick:()=>c.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(Hn,{columns:t,filterModel:e,onFilterModelChange:o})})]});return Ve.createPortal(f,u)}const ii={rowFields:[],columnFields:[],valueFields:[]};function li({columns:n=[],baseColumns:t,aggregationModel:e={},onAggregationModelChange:o,pivotModel:i,onPivotModelChange:l,filterModel:a,onFilterModelChange:d,columnVisibilityModel:c={},onColumnVisibilityModelChange:u,onColumnReorder:p,onColumnOrderReset:w,forceColumnsOpen:x,onColumnsPanelClose:g,children:f,rightContent:h,style:v,renderColumnsButton:E,renderFilterButton:m,renderAggregationButton:y,renderExportButton:M,renderQuickFilter:N,className:k,showNonHideableColumns:C}){const[S,j]=s.useState(!1),[P,b]=s.useState(!1),[F,z]=s.useState(!1),[K,W]=s.useState(!1);s.useEffect(()=>{x&&(z(!0),j(!1),b(!1),W(!1))},[x]);const $=s.useRef(null),H=s.useRef(null),L=s.useRef(null),B=s.useRef(null),D=s.useRef(null),_=s.useRef(null),T=s.useRef(null),I=i??ii,O=I.rowFields.length>0||I.columnFields.length>0||I.valueFields.length>0,X=n.filter(q=>q.aggregable!==!1&&(q.type==="number"||q.aggregable===!0)),te=Object.keys(e).filter(q=>e[q]&&e[q]!=="none").length,Z=s.useCallback((q,V)=>{if(!o)return;const A={...e};V==="none"?delete A[q]:A[q]=V,o(A)},[e,o]),ce=s.useCallback(()=>{o?.({})},[o]),le=s.useCallback(q=>{if(!d)return;const A={...a||{},quickFilterValues:q?[q]:[],items:a?.items||[]};d(A)},[a,d]),G=a?.quickFilterValues?.[0]||"",R=a?.items?.length||0,Y=new Set(n.filter(q=>c[q.field]!==!1).map(q=>q.field)),Q=s.useCallback((q,V)=>{if(!u)return;const A={...c,[q]:V};u(A)},[c,u]),J=s.useCallback(()=>{if(!u)return;const q={...c};n.forEach(V=>{V.hideable!==!1&&(q[V.field]=!0)}),u(q)},[n,c,u]),re=s.useCallback(()=>{if(!u)return;const q={...c};n.forEach(V=>{V.hideable!==!1&&(q[V.field]=!1)}),u(q)},[n,c,u]);return r.jsxs("div",{className:["ogx-toolbar",k].filter(Boolean).join(" "),role:"toolbar","aria-label":"Grid toolbar",style:v,children:[f&&r.jsx("div",{className:"ogx-toolbar__left",children:f}),r.jsx("div",{className:"ogx-toolbar__spacer"}),r.jsxs("div",{className:"ogx-toolbar__actions",children:[d&&r.jsx("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:N?N({value:G,onChange:le}):r.jsx(Zr,{value:G,onChange:le,placeholder:"Search..."})}),u&&r.jsxs("div",{ref:D,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[E?E({onClick:()=>{z(q=>!q),j(!1),b(!1),W(!1)},isOpen:F,activeCount:n.length-Y.size}):r.jsx(_t,{title:"Columns",children:r.jsx("button",{ref:L,className:`ogx-toolbar__icon-btn${F?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Manage columns",onClick:()=>{z(!F),j(!1),b(!1),W(!1)},children:r.jsx(ti,{})})}),F&&r.jsx(oi,{anchorRef:E?D:L,columns:n,visibleColumns:Y,onVisibilityChange:Q,onShowAll:J,onHideAll:re,onColumnReorder:p,onColumnOrderReset:w,onClose:()=>{z(!1),g?.()},showNonHideableColumns:C})]}),d&&r.jsxs("div",{ref:_,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[m?m({onClick:()=>{W(q=>!q),j(!1),b(!1),z(!1)},isOpen:K,activeCount:R}):r.jsx(_t,{title:"Filters",children:r.jsxs("button",{ref:B,className:`ogx-toolbar__icon-btn${K?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Advanced filters",onClick:()=>{W(!K),j(!1),b(!1),z(!1)},children:[r.jsx(Un,{}),R>0&&r.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Filters active"})]})}),K&&r.jsx(ri,{anchorRef:m?_:B,columns:n,filterModel:a||{items:[]},onFilterModelChange:d,onClose:()=>W(!1)})]}),l&&r.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[r.jsx(_t,{title:"Pivot",children:r.jsxs("button",{ref:H,className:`ogx-toolbar__icon-btn${P?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure pivot","aria-expanded":P,onClick:()=>{b(!P),j(!1),z(!1),W(!1)},children:[r.jsx(Vn,{}),O&&r.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Pivot active"})]})}),P&&r.jsx(Xr,{anchorRef:H,columns:t??n,model:I,onChange:q=>{l?.(q)},onClose:()=>b(!1)})]}),r.jsxs("div",{ref:T,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[y?y({onClick:()=>{j(q=>!q),b(!1),z(!1),W(!1)},isOpen:S,activeCount:te}):r.jsx(_t,{title:"Summaries",children:r.jsxs("button",{ref:$,className:`ogx-toolbar__icon-btn${S?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure summaries","aria-expanded":S,onClick:()=>{j(!S),b(!1),z(!1),W(!1)},children:[r.jsx(Gn,{}),te>0&&r.jsx("span",{className:"ogx-toolbar__dot","aria-label":`${te} active summaries`})]})}),S&&r.jsx(ni,{anchorRef:y?T:$,aggregationModel:e,aggregableColumns:X,onFunctionChange:Z,onClearAll:ce,onClose:()=>j(!1),activeCount:te})]}),M&&M(),h]})]})}function si(){return s.useRef(null)}const ai=({fullWidth:n=!1,error:t=!1,startAdornment:e,endAdornment:o,className:i="",...l})=>{const a=["ogx-input-wrapper",n&&"ogx-input-wrapper--full-width",t&&"ogx-input-wrapper--error",l.disabled&&"ogx-input-wrapper--disabled",i].filter(Boolean).join(" ");return r.jsxs("div",{className:a,children:[e&&r.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--start",children:e}),r.jsx("input",{className:"ogx-input",...l}),o&&r.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--end",children:o})]})};function Kn(n){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);return t?[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]:[79,70,229]}function di(n){return n.filter(t=>!(t.exportable===!1||t.field==="__check__"||t.field==="__actions__"))}function Yn(n,t){let e=n[t.field];return t.valueGetter&&(e=t.valueGetter({row:n,field:t.field,value:e})),t.valueFormatter&&e!==void 0&&e!==null&&(e=t.valueFormatter({value:e,row:n,field:t.field})),String(e??"")}function qn(n){return(typeof n.width=="number"?n.width:void 0)??(n.flex??1)*100}function ci(n,t){const e=n.reduce((i,l)=>i+qn(l),0),o={};return n.forEach((i,l)=>{o[l]={cellWidth:qn(i)/e*t}}),o}function ui(n,t){return!n.items||n.items.length===0?"":n.items.flatMap(e=>{if("items"in e)return[];const i=t.find(a=>a.field===e.field)?.headerName??e.field,l=e.value!==void 0&&e.value!==null?String(e.value):"";return[`${i} ${e.operator} "${l}"`]}).join(" • ")}async function fi(n,t,e={}){let o,i;try{const[_,T]=await Promise.all([import("jspdf"),import("jspdf-autotable")]);o=_.default,i=T.default}catch{throw new Error("exportToPdf requires 'jspdf' and 'jspdf-autotable'. Run: npm install jspdf jspdf-autotable")}const{fileName:l="export",title:a,logoUrl:d,orientation:c="landscape",selectedRows:u,aggregationResult:p,aggregationModel:w,filterModel:x,alternateRowColor:g=!0,headerBackgroundColor:f="#4f46e5",headerTextColor:h="#ffffff",fontSize:v=9,groupedRows:E}=e,m=new o({orientation:c,unit:"mm",format:"a4"}),y=m.internal.pageSize.getWidth(),M=m.internal.pageSize.getHeight(),N=14,k=y-N*2,C=di(t),S=u&&u.length>0?n.filter(_=>u.includes(_.id)):n;let j=N;if(a){let _=N,T=N+8;if(d)try{m.addImage(d,"PNG",_,N,10,10),_+=14}catch{}m.setFontSize(16),m.setFont("helvetica","bold"),m.setTextColor(30,41,59),m.text(a,_,T),T+=6,m.setFontSize(8),m.setFont("helvetica","normal"),m.setTextColor(100,116,139);const I=new Date().toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),O=E?E.filter(X=>X.type==="leaf").length:S.length;if(m.text(`Exported: ${I} • ${O} row${O!==1?"s":""}`,_,T),T+=5,x){const X=ui(x,t);X&&(m.text(`Filters: ${X}`,_,T),T+=5)}m.setDrawColor(226,232,240),m.setLineWidth(.3),m.line(N,T+2,y-N,T+2),j=T+6}const P=[C.map(_=>_.headerName??_.field)];let b,F;if(E&&E.length>0){b=[];const _=w||{};E.forEach(T=>{if(T.type==="group-header"){const O=`${" ".repeat(T.depth*2)}${T.groupField??""}: ${String(T.groupValue??"")}`;b.push(C.map((X,te)=>te===0?O:""))}else if(T.type==="leaf"&&T.row){const I=T.row,O=" ".repeat(T.depth*2);b.push(C.map((X,te)=>(te===0?O:"")+Yn(I,X)))}else if(T.type==="group-subtotal"&&T.aggregatedValues){const I=" ".repeat(T.depth*2);b.push(C.map((O,X)=>{if(X===0)return`${I}Subtotal`;const te=T.aggregatedValues[O.field];if(te==null)return"";let Z=te;return O.valueFormatter?Z=O.valueFormatter({value:te,row:{},field:O.field}):_[O.field]&&(Z=ve(te,_[O.field])),String(Z)}))}else T.type==="grand-total"&&T.aggregatedValues&&(F=[C.map((O,X)=>{if(X===0)return"Grand Total";const te=T.aggregatedValues[O.field];if(te==null)return"";let Z=te;return O.valueFormatter?Z=O.valueFormatter({value:te,row:{},field:O.field}):_[O.field]&&(Z=ve(te,_[O.field])),String(Z)})])})}else b=S.map(_=>C.map(T=>Yn(_,T))),p&&w&&(F=[C.map((T,I)=>{if(I===0)return C.some(Z=>w[Z.field])?"TOTAL":"";const O=p[T.field];if(O==null)return"";let X=O;return T.valueFormatter?X=T.valueFormatter({value:O,row:{},field:T.field}):w[T.field]&&(X=ve(O,w[T.field])),String(X)})]);const z=ci(C,k),[K,W,$]=Kn(f),[H,L,B]=Kn(h);i(m,{head:P,body:b,...F?{foot:F}:{},startY:j,styles:{fontSize:v,cellPadding:3,font:"helvetica",overflow:"linebreak"},headStyles:{fillColor:[K,W,$],textColor:[H,L,B],fontStyle:"bold"},...g?{alternateRowStyles:{fillColor:[248,250,252]}}:{},...F?{footStyles:{fillColor:[241,245,249],fontStyle:"bold",textColor:[0,0,0]}}:{},columnStyles:z,showFoot:F?"lastPage":"never",showHead:"everyPage",margin:{top:N,left:N,right:N,bottom:N+6}});const D=m.getNumberOfPages();for(let _=1;_<=D;_++)m.setPage(_),m.setFontSize(8),m.setTextColor(150,150,150),m.text(`Page ${_} of ${D}`,y-N,M-8,{align:"right"});m.save(`${l}.pdf`)}function gi(n,t,e={}){const{fileName:o="export.csv",includeHeaders:i=!0,delimiter:l=",",selectedRows:a,groupedRows:d}=e,c=t.filter(p=>!(p.exportable===!1||p.field==="__check__"||p.field==="__actions__"));let u="";if(d&&d.length>0)i&&(u+=c.map(p=>Ie(p.headerName||p.field)).join(l)+`
|
|
9
|
+
`),d.forEach(p=>{if(p.type==="group-header"){const x=`${" ".repeat(p.depth)}${p.groupField??""}: ${String(p.groupValue??"")}`,g=c.map((f,h)=>h===0?Ie(x):"");u+=g.join(l)+`
|
|
10
|
+
`}else if(p.type==="leaf"&&p.row){const w=p.row,x=" ".repeat(p.depth),g=c.map((f,h)=>{let v=w[f.field];return f.valueGetter&&(v=f.valueGetter({row:w,field:f.field,value:v})),f.valueFormatter&&v!==void 0&&v!==null&&(v=f.valueFormatter({value:v,row:w,field:f.field})),Ie((h===0?x:"")+String(v??""))});u+=g.join(l)+`
|
|
11
|
+
`}else if(p.type==="group-subtotal"&&p.aggregatedValues){const w=" ".repeat(p.depth),x=e.aggregationModel||{},g=c.map((f,h)=>{if(h===0)return Ie(`${w}Subtotal`);const v=p.aggregatedValues[f.field];if(v!=null){let E=v;return f.valueFormatter?E=f.valueFormatter({value:v,row:{},field:f.field}):x[f.field]&&(E=ve(v,x[f.field])),Ie(String(E))}return""});u+=g.join(l)+`
|
|
12
|
+
`}else if(p.type==="grand-total"&&p.aggregatedValues){const w=e.aggregationModel||{},x=c.map((g,f)=>{if(f===0)return Ie("Grand Total");const h=p.aggregatedValues[g.field];if(h!=null){let v=h;return g.valueFormatter?v=g.valueFormatter({value:h,row:{},field:g.field}):w[g.field]&&(v=ve(h,w[g.field])),Ie(String(v))}return""});u+=x.join(l)+`
|
|
13
|
+
`}});else{const p=a&&a.length>0?n.filter(w=>a.includes(w.id)):n;if(p.length===0){console.warn("No rows to export");return}if(i&&(u+=c.map(w=>Ie(w.headerName||w.field)).join(l)+`
|
|
14
|
+
`),p.forEach(w=>{const x=c.map(g=>{let f=w[g.field];return g.valueGetter&&(f=g.valueGetter({row:w,field:g.field,value:f})),g.valueFormatter&&f!==void 0&&f!==null&&(f=g.valueFormatter({value:f,row:w,field:g.field})),Ie(String(f??""))});u+=x.join(l)+`
|
|
15
|
+
`}),e.aggregationResult){const w=e.aggregationResult,x=e.aggregationModel||{},g=c.map(h=>Ie(x[h.field]?x[h.field].toUpperCase():""));u+=g.join(l)+`
|
|
16
|
+
`;const f=c.map(h=>{const v=w[h.field];if(v!=null){let E=v;return h.valueFormatter?E=h.valueFormatter({value:v,row:{},field:h.field}):x[h.field]&&(E=ve(v,x[h.field])),Ie(String(E))}return""});u+=f.join(l)+`
|
|
17
|
+
`}}an(u,o,"text/csv;charset=utf-8;")}function Ie(n){return n.includes(",")||n.includes('"')||n.includes(`
|
|
18
|
+
`)?`"${n.replace(/"/g,'""')}"`:n}function hi(n,t,e={}){const{fileName:o="export.xls",sheetName:i="Sheet1",includeHeaders:l=!0,selectedRows:a,groupedRows:d}=e,c=t.filter(w=>!(w.exportable===!1||w.field==="__check__"||w.field==="__actions__"));let p=`<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>${i}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--><meta charset="UTF-8"></head><body><table border="1">`;if(l&&(p+="<thead><tr>",c.forEach(w=>{p+=`<th>${be(w.headerName||w.field)}</th>`}),p+="</tr></thead>"),p+="<tbody>",d&&d.length>0){const w=e.aggregationModel||{};d.forEach(x=>{if(x.type==="group-header"){const f=`${" ".repeat(x.depth*2)}${x.groupField??""}: ${String(x.groupValue??"")}`;p+='<tr style="font-weight:bold;background:#e8eaf6;">',p+=`<td colspan="${c.length}">${be(f)}</td>`,p+="</tr>"}else if(x.type==="leaf"&&x.row){const g=x.row,f=" ".repeat(x.depth*2);p+="<tr>",c.forEach((h,v)=>{let E=g[h.field];h.valueGetter&&(E=h.valueGetter({row:g,field:h.field,value:E})),h.valueFormatter&&E!==void 0&&E!==null&&(E=h.valueFormatter({value:E,row:g,field:h.field})),p+=`<td>${be((v===0?f:"")+String(E??""))}</td>`}),p+="</tr>"}else if((x.type==="group-subtotal"||x.type==="grand-total")&&x.aggregatedValues){const g=x.type==="grand-total",f=g?"":" ".repeat(x.depth*2),h=g?"Grand Total":`${f}Subtotal`;p+='<tr style="font-weight:bold;background:#f5f5f5;">',c.forEach((v,E)=>{if(E===0){p+=`<td>${be(h)}</td>`;return}const m=x.aggregatedValues[v.field];if(m!=null){let y=m;v.valueFormatter?y=v.valueFormatter({value:m,row:{},field:v.field}):w[v.field]&&(y=ve(m,w[v.field])),p+=`<td style="text-align:right;">${be(String(y))}</td>`}else p+="<td></td>"}),p+="</tr>"}})}else{const w=a&&a.length>0?n.filter(x=>a.includes(x.id)):n;if(w.length===0){console.warn("No rows to export");return}if(w.forEach(x=>{p+="<tr>",c.forEach(g=>{let f=x[g.field];g.valueGetter&&(f=g.valueGetter({row:x,field:g.field,value:f})),g.valueFormatter&&f!==void 0&&f!==null&&(f=g.valueFormatter({value:f,row:x,field:g.field})),p+=`<td>${be(String(f??""))}</td>`}),p+="</tr>"}),e.aggregationResult){const x=e.aggregationResult,g=e.aggregationModel||{};p+='<tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',c.forEach(f=>{p+=g[f.field]?`<td style="text-align:right;font-weight:bold;">${be(g[f.field].toUpperCase())}</td>`:"<td></td>"}),p+='</tr><tr style="font-weight:bold;background-color:#f5f5f5;">',c.forEach(f=>{const h=x[f.field];if(h!=null){let v=h;f.valueFormatter?v=f.valueFormatter({value:h,row:{},field:f.field}):g[f.field]&&(v=ve(h,g[f.field])),p+=`<td style="text-align:right;">${be(String(v))}</td>`}else p+="<td></td>"}),p+="</tr>"}}p+="</tbody></table></body></html>",an(p,o,"application/vnd.ms-excel")}function be(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function pi(n,t,e={}){const{fileName:o="export.json",pretty:i=!0,selectedRows:l,groupedRows:a}=e,d=t.filter(u=>!(u.exportable===!1||u.field==="__check__"||u.field==="__actions__"));let c;if(a&&a.length>0){const u=[],p=[];let w;a.forEach(x=>{if(x.type==="group-header"){const g={group:`${x.groupField??""}: ${String(x.groupValue??"")}`,field:x.groupField??"",value:x.groupValue,rows:[],children:[]};for(;u.length>x.depth;)u.pop();u.length===0?p.push(g):(u[u.length-1].children??=[]).push(g),u.push(g)}else if(x.type==="leaf"&&x.row){const g=x.row,f={};d.forEach(h=>{let v=g[h.field];h.valueGetter&&(v=h.valueGetter({row:g,field:h.field,value:v})),f[h.field]=v}),u.length>0&&u[u.length-1].rows.push(f)}else x.type==="group-subtotal"&&x.aggregatedValues&&u.length>0?(u[u.length-1].subtotals={...x.aggregatedValues},u.pop()):x.type==="grand-total"&&x.aggregatedValues&&(w={...x.aggregatedValues})}),c=w?{groups:p,grandTotal:w}:{groups:p}}else{const u=l&&l.length>0?n.filter(w=>l.includes(w.id)):n;if(u.length===0){console.warn("No rows to export");return}const p=u.map(w=>{const x={};return d.forEach(g=>{let f=w[g.field];g.valueGetter&&(f=g.valueGetter({row:w,field:g.field,value:f})),x[g.field]=f}),x});if(e.aggregationResult){const w=e.aggregationResult,x=e.aggregationModel||{},g={};d.forEach(h=>{x[h.field]&&(g[h.field]=x[h.field].toUpperCase())});const f={};d.forEach(h=>{if(w[h.field]!==void 0&&w[h.field]!==null){let v=w[h.field];h.valueFormatter?v=h.valueFormatter({value:v,row:{},field:h.field}):x[h.field]&&(v=ve(v,x[h.field])),f[h.field]=v}}),c={data:p,aggregation:{labels:g,values:f}}}else c=p}an(i?JSON.stringify(c,null,2):JSON.stringify(c),o,"application/json;charset=utf-8;")}async function xi(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(`
|
|
19
19
|
<!DOCTYPE html>
|
|
20
20
|
<html>
|
|
21
21
|
<head>
|
|
@@ -35,7 +35,7 @@ ${x}`;try{await ar(w)}catch(b){console.error("[OpenGridX] Failed to copy to clip
|
|
|
35
35
|
</div>
|
|
36
36
|
</body>
|
|
37
37
|
</html>
|
|
38
|
-
`),o.document.close(),await new Promise(
|
|
38
|
+
`),o.document.close(),await new Promise(i=>setTimeout(i,100));try{let i="Print",l,a=null,d=null,c;typeof e=="string"?i=e:typeof e=="object"&&(i=e.title||"Print",l=e.selectedRows,a=e.aggregationResult||null,d=e.aggregationModel||null,c=e.groupedRows);const u=t.filter(x=>!(x.exportable===!1||x.field==="__check__"||x.field==="__actions__"));let p=`<!DOCTYPE html><html><head><title>${i||"Print"}</title><style>
|
|
39
39
|
body{font-family:Arial,sans-serif;margin:20px;}
|
|
40
40
|
h1{font-size:24px;margin-bottom:20px;}
|
|
41
41
|
table{border-collapse:collapse;width:100%;}
|
|
@@ -46,5 +46,5 @@ ${x}`;try{await ar(w)}catch(b){console.error("[OpenGridX] Failed to copy to clip
|
|
|
46
46
|
.group-subtotal{background:#f0f4ff;font-style:italic;}
|
|
47
47
|
.grand-total{background:#f5f5f5;font-weight:bold;}
|
|
48
48
|
@media print{body{margin:0;}@page{margin:1cm;}}
|
|
49
|
-
</style></head><body>`;if(l&&(x+=`<h1>${we(l)}</h1>`),x+="<table><thead><tr>",p.forEach(b=>{x+=`<th>${we(b.headerName||b.field)}</th>`}),x+="</tr></thead><tbody>",f&&f.length>0){const b=a||{};f.forEach(c=>{if(c.type==="group-header"){const m=`${" ".repeat(c.depth*4)}${we(c.groupField??"")}: ${we(String(c.groupValue??""))}`;x+=`<tr class="group-header"><td colspan="${p.length}">${m}</td></tr>`}else if(c.type==="leaf"&&c.row){const g=c.row,m=" ".repeat(c.depth*4);x+="<tr>",p.forEach((_,E)=>{let v=g[_.field];_.valueGetter&&(v=_.valueGetter({row:g,field:_.field,value:v})),_.valueFormatter&&v!==void 0&&v!==null&&(v=_.valueFormatter({value:v,row:g,field:_.field})),_.type==="image"&&v?x+=`<td><img src="${v}" style="max-height:40px;border-radius:4px;"></td>`:x+=`<td>${(E===0?m:"")+we(String(v??""))}</td>`}),x+="</tr>"}else if((c.type==="group-subtotal"||c.type==="grand-total")&&c.aggregatedValues){const g=c.type==="grand-total",m=g?"":" ".repeat(c.depth*4),_=g?"Grand Total":`${m}Subtotal`;x+=`<tr class="${g?"grand-total":"group-subtotal"}">`,p.forEach((v,S)=>{if(S===0){x+=`<td>${_}</td>`;return}const N=c.aggregatedValues[v.field];if(N!=null){let h=N;v.valueFormatter?h=v.valueFormatter({value:N,row:{},field:v.field}):b[v.field]&&(h=_e(N,b[v.field])),x+=`<td style="text-align:right;">${we(String(h))}</td>`}else x+="<td></td>"}),x+="</tr>"}})}else{const b=s&&s.length>0?n.filter(c=>s.includes(c.id)):n;if(b.length===0){o.document.body.innerHTML="<h3>No rows to export</h3>";return}if(b.forEach(c=>{x+="<tr>",p.forEach(g=>{let m=c[g.field];g.valueGetter&&(m=g.valueGetter({row:c,field:g.field,value:m})),g.valueFormatter&&m!==void 0&&m!==null&&(m=g.valueFormatter({value:m,row:c,field:g.field})),g.type==="image"&&m?x+=`<td><div style="display:flex;justify-content:center;"><img src="${m}" alt="${g.headerName}" style="max-height:40px;border-radius:4px;"></div></td>`:x+=`<td>${we(String(m??""))}</td>`}),x+="</tr>"}),d){const c=a||{};x+='<tfoot><tr style="font-size:11px;color:#666;background-color:#f5f5f5;">',p.forEach(g=>{x+=c[g.field]?`<td style="text-align:right;font-weight:bold;">${we(c[g.field].toUpperCase())}</td>`:"<td></td>"}),x+='</tr><tr style="font-weight:bold;background-color:#f5f5f5;">',p.forEach(g=>{const m=d[g.field];if(m!=null){let _=m;g.valueFormatter?_=g.valueFormatter({value:m,row:{},field:g.field}):c[g.field]&&(_=_e(m,c[g.field])),x+=`<td style="text-align:right;">${we(String(_))}</td>`}else x+="<td></td>"}),x+="</tr></tfoot>"}}x+="</tbody></table></body></html>",o.document.open(),o.document.write(x),o.document.close(),o.document.title=l||"Print Preview",o.focus();let w=!1;o.onload=()=>{w||(w=!0,o.print(),setTimeout(()=>{o.close()},100))},setTimeout(()=>{!w&&o&&!o.closed&&(w=!0,o.print(),setTimeout(()=>{o.closed||o.close()},100))},500)}catch(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 tn(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 ti(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 ni(n){if(n.type==="number")return"#,##0.##";if(n.type==="date")return"yyyy-mm-dd"}function oi(n,t){if(t!=null)return t;const e=n.width??120;return Math.min(60,Math.max(8,(e-5)/7))}function ri(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 ii(n){const t=await Promise.allSettled(n.map(async o=>{if(o.startsWith("data:")){const a=o.indexOf(","),f=o.slice(0,a),p=o.slice(a+1),x=atob(p),w=new Uint8Array(x.length);for(let m=0;m<x.length;m++)w[m]=x.charCodeAt(m);const c=f.match(/data:([^;,]+)/)?.[1]??"image/png";let g="png";return c.includes("jpeg")||c.includes("jpg")?g="jpeg":c.includes("gif")&&(g="gif"),{url:o,buffer:w.buffer,ext:g}}const l=await fetch(o,{mode:"cors"});if(!l.ok)throw new Error(`HTTP ${l.status}`);const s=await l.arrayBuffer(),d=ri(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 li(n,t,e={}){const{fileName:o="export.xlsx",sheets:l,columnStyles:s={},headerFillColor:d="#f1f5f9",headerTextColor:a="#334155",headerFontSize:f=10,bodyFontSize:p=10,aggregationResult:x=null,aggregationModel:w=null,selectedRows:b}=e,c=(await import("exceljs")).default,g=new c.Workbook;g.creator="OpenGridX",g.created=new Date;const m=t.filter(j=>j.exportable!==!1&&j.field!=="__check__"&&j.field!=="__actions__"&&!j.isSpacer),_=n,E=b&&b.length>0?n.filter(j=>b.includes(j.id)):n,v=l??[{name:"Data",rows:"all",includeHeaders:!0,includeSummary:!1}],S=new Map;for(const j of v){if("type"in j&&j.type==="summary"){if(!x||!w)continue;const C=g.addWorksheet(j.name??"Summary");C.addRow(["Summary / Aggregation Totals"]),C.getRow(1).font={bold:!0,size:f+2,color:{argb:$e(a)}},C.addRow([]),C.addRow(["Column","Function","Value"]).eachCell(L=>{L.fill={type:"pattern",pattern:"solid",fgColor:{argb:$e(d)}},L.font={bold:!0,size:f,color:{argb:$e(a)}},L.border=Dn()}),m.forEach(L=>{const O=w[L.field],H=x[L.field];if(O==null||H==null)return;let U=H;L.valueFormatter?U=L.valueFormatter({value:H,row:{},field:L.field}):U=_e(H,O);const K=C.addRow([L.headerName??L.field,O.toUpperCase(),U]);K.getCell(3).alignment={horizontal:"right"},K.getCell(3).font={bold:!0,size:p}}),C.getColumn(1).width=20,C.getColumn(2).width=12,C.getColumn(3).width=18;continue}const P=j,{name:F="Data",rows:k="all",includeHeaders:I=!0,includeSummary:R=!1,autoFilter:W=!0,frozenHeader:$=!0,alternateRowColor:D="#f8fafc"}=P,A=k==="selected"?E:_,z=m.filter(C=>s[C.field]?.embedImage);if(z.length>0){const C=[],M=new Set;if(A.forEach(L=>{z.forEach(O=>{const H=L[O.field];typeof H=="string"&&H&&!S.has(H)&&!M.has(H)&&(C.push(H),M.add(H))})}),C.length>0){const L=await ii(C);for(const[O,{buffer:H,extension:U}]of L){const K=g.addImage({buffer:H,extension:U});S.set(O,K)}}}const Y=g.addWorksheet(F);if(Y.columns=m.map(C=>({key:C.field,width:oi(C,s[C.field]?.width),style:{numFmt:s[C.field]?.numFmt??ni(C)}})),I){const C=m.map(L=>L.headerName??L.field),M=Y.addRow(C);M.height=20,M.eachCell((L,O)=>{const H=m[O-1];L.fill={type:"pattern",pattern:"solid",fgColor:{argb:$e(d)}},L.font={bold:!0,size:f,color:{argb:$e(a)}},L.alignment={horizontal:s[H?.field]?.alignment??(H?.type==="number"?"right":"left"),vertical:"middle"},L.border=Dn()}),W&&(Y.autoFilter={from:{row:1,column:1},to:{row:1,column:m.length}}),$?Y.views=[{state:"frozen",ySplit:1,showGridLines:!1}]:Y.views=[{showGridLines:!1}]}let V=I?1:0;if(A.forEach((C,M)=>{const L=m.map(H=>{if(s[H.field]?.embedImage)return"";let U=C[H.field];return H.valueGetter&&(U=H.valueGetter({row:C,field:H.field,value:U})),ti(H,U)==="string"&&H.valueFormatter&&U!=null&&(U=H.valueFormatter({value:U,row:C,field:H.field})),U}),O=Y.addRow(L);if(O.font={size:p},D&&M%2===1&&O.eachCell(H=>{H.fill={type:"pattern",pattern:"solid",fgColor:{argb:$e(D)}}}),O.eachCell((H,U)=>{const K=m[U-1];K&&(H.alignment={horizontal:s[K.field]?.alignment??(K.type==="number"?"right":"left"),vertical:"middle"},H.border={bottom:{style:"thin",color:{argb:"FFf1f5f9"}}})}),z.length>0){const H=z.reduce((oe,ie)=>Math.max(oe,s[ie.field]?.imageHeight??40),0),U=Math.ceil(H/1.333),K=U*1.333;O.height=U,z.forEach(oe=>{const ie=m.indexOf(oe),ne=C[oe.field],T=typeof ne=="string"?S.get(ne):void 0;if(T===void 0){O.getCell(ie+1).value=typeof ne=="string"?ne:"";return}const le=s[oe.field],te=le?.imageWidth??40,re=le?.imageHeight??40,J=(Y.getColumn(ie+1).width??8)*7+5,de=Math.max(0,J-te)/2,B=Math.max(0,K-re)/2;Y.addImage(T,{tl:{col:ie,row:V,nativeColOff:Math.floor(de*9525),nativeRowOff:Math.floor(B*9525)},ext:{width:te,height:re},editAs:"oneCell"})})}else O.height=16;V++}),R&&x&&w){const C=m.map(H=>{const U=w[H.field];return U?U.toUpperCase():""}),M=Y.addRow(C);M.height=16,M.font={size:p-1,italic:!0,color:{argb:"FF94a3b8"}},M.eachCell(H=>{H.alignment={horizontal:"right",vertical:"middle"},H.border={top:{style:"thin",color:{argb:"FFcbd5e1"}}}});const L=m.map(H=>{const U=w[H.field],K=x[H.field];return U==null||K==null?"":H.valueFormatter?H.valueFormatter({value:K,row:{},field:H.field}):_e(K,U)}),O=Y.addRow(L);O.height=18,O.font={bold:!0,size:p,color:{argb:$e(a)}},O.eachCell(H=>{H.fill={type:"pattern",pattern:"solid",fgColor:{argb:$e(d)}},H.alignment={horizontal:"right",vertical:"middle"},H.border=si()})}}const N=await g.xlsx.writeBuffer(),h=new Blob([N],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),y=URL.createObjectURL(h),u=document.createElement("a");u.href=y,u.download=o.endsWith(".xlsx")?o:`${o}.xlsx`,document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL(y)}function $e(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 Dn(){return{bottom:{style:"medium",color:{argb:"FFcbd5e1"}}}}function si(){return{top:{style:"medium",color:{argb:"FFcbd5e1"}}}}const ai={"--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 di(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 ci({theme:n,children:t,className:e,style:o}){const l=i.useMemo(()=>({...ai,...di(n)}),[n]);return r.jsx("div",{className:`ogx-theme-provider ${e||""}`.trim(),style:{...o,...l},children:t})}const ui={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"}},fi={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"}},gi={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"}},hi={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"}},pi={grid:{rowHeightCompact:"28px",rowHeightStandard:"36px",rowHeightComfortable:"48px",headerHeight:"40px",cellPaddingX:"8px",cellPaddingY:"4px"},typography:{fontSizeSm:"0.8rem",fontSizeMd:"0.875rem"}};function xi(n,t){try{const e=t.getItem(n);return e?JSON.parse(e):void 0}catch{return}}function mi(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 bi(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 xi(e,s)},[e,s]),a=i.useRef(null),f=i.useRef(null),p=i.useCallback(()=>{f.current&&s&&mi(e,f.current,l,s)},[e,l,s]),x=i.useCallback(b=>{f.current=b,a.current&&clearTimeout(a.current),a.current=setTimeout(p,o)},[p,o]);i.useEffect(()=>()=>{a.current&&(clearTimeout(a.current),p())},[p]);const w=i.useCallback(()=>{s&&s.removeItem(e)},[e,s]);return{initialState:d,onStateChange:x,clearState:w}}ae.Button=bt,ae.Cell=Tn,ae.Checkbox=mt,ae.DataGrid=Mr,ae.DataGridThemeProvider=ci,ae.FilterPanel=On,ae.GridToolbar=Gr,ae.GridTooltip=vt,ae.Header=Nn,ae.Input=Ur,ae.Row=Ft,ae.Skeleton=Pr,ae.amberTheme=hi,ae.compactTheme=pi,ae.darkTheme=ui,ae.emeraldTheme=gi,ae.exportToCsv=Jr,ae.exportToExcel=Qr,ae.exportToExcelAdvanced=li,ae.exportToJson=Zr,ae.exportToPdf=Xr,ae.formatAggregationValue=_e,ae.printGrid=ei,ae.roseTheme=fi,ae.useAggregation=jn,ae.useGridApiRef=Vr,ae.useGridStateStorage=bi,ae.usePivot=In,Object.defineProperty(ae,Symbol.toStringTag,{value:"Module"})}));
|
|
49
|
+
</style></head><body>`;if(i&&(p+=`<h1>${be(i)}</h1>`),p+="<table><thead><tr>",u.forEach(x=>{p+=`<th>${be(x.headerName||x.field)}</th>`}),p+="</tr></thead><tbody>",c&&c.length>0){const x=d||{};c.forEach(g=>{if(g.type==="group-header"){const h=`${" ".repeat(g.depth*4)}${be(g.groupField??"")}: ${be(String(g.groupValue??""))}`;p+=`<tr class="group-header"><td colspan="${u.length}">${h}</td></tr>`}else if(g.type==="leaf"&&g.row){const f=g.row,h=" ".repeat(g.depth*4);p+="<tr>",u.forEach((v,E)=>{let m=f[v.field];v.valueGetter&&(m=v.valueGetter({row:f,field:v.field,value:m})),v.valueFormatter&&m!==void 0&&m!==null&&(m=v.valueFormatter({value:m,row:f,field:v.field})),v.type==="image"&&m?p+=`<td><img src="${m}" style="max-height:40px;border-radius:4px;"></td>`:p+=`<td>${(E===0?h:"")+be(String(m??""))}</td>`}),p+="</tr>"}else if((g.type==="group-subtotal"||g.type==="grand-total")&&g.aggregatedValues){const f=g.type==="grand-total",h=f?"":" ".repeat(g.depth*4),v=f?"Grand Total":`${h}Subtotal`;p+=`<tr class="${f?"grand-total":"group-subtotal"}">`,u.forEach((m,y)=>{if(y===0){p+=`<td>${v}</td>`;return}const M=g.aggregatedValues[m.field];if(M!=null){let N=M;m.valueFormatter?N=m.valueFormatter({value:M,row:{},field:m.field}):x[m.field]&&(N=ve(M,x[m.field])),p+=`<td style="text-align:right;">${be(String(N))}</td>`}else p+="<td></td>"}),p+="</tr>"}})}else{const x=l&&l.length>0?n.filter(g=>l.includes(g.id)):n;if(x.length===0){o.document.body.innerHTML="<h3>No rows to export</h3>";return}if(x.forEach(g=>{p+="<tr>",u.forEach(f=>{let h=g[f.field];f.valueGetter&&(h=f.valueGetter({row:g,field:f.field,value:h})),f.valueFormatter&&h!==void 0&&h!==null&&(h=f.valueFormatter({value:h,row:g,field:f.field})),f.type==="image"&&h?p+=`<td><div style="display:flex;justify-content:center;"><img src="${h}" alt="${f.headerName}" style="max-height:40px;border-radius:4px;"></div></td>`:p+=`<td>${be(String(h??""))}</td>`}),p+="</tr>"}),a){const g=d||{};p+='<tfoot><tr style="font-size:11px;color:#666;background-color:#f5f5f5;">',u.forEach(f=>{p+=g[f.field]?`<td style="text-align:right;font-weight:bold;">${be(g[f.field].toUpperCase())}</td>`:"<td></td>"}),p+='</tr><tr style="font-weight:bold;background-color:#f5f5f5;">',u.forEach(f=>{const h=a[f.field];if(h!=null){let v=h;f.valueFormatter?v=f.valueFormatter({value:h,row:{},field:f.field}):g[f.field]&&(v=ve(h,g[f.field])),p+=`<td style="text-align:right;">${be(String(v))}</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=i||"Print Preview",o.focus();let w=!1;o.onload=()=>{w||(w=!0,o.print(),setTimeout(()=>{o.close()},100))},setTimeout(()=>{!w&&o&&!o.closed&&(w=!0,o.print(),setTimeout(()=>{o.closed||o.close()},100))},500)}catch(i){if(console.error("Print generation failed:",i),o&&!o.closed){const l=i instanceof Error?i.message:String(i);o.document.body.innerHTML=`<div style="color: red; padding: 20px;"><h3>Error Generating Print Preview</h3><p>${l}</p></div>`}}}function an(n,t,e){const o=new Blob([n],{type:e}),i=URL.createObjectURL(o),l=document.createElement("a");l.href=i,l.download=t,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(i)}function mi(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 wi(n){if(n.type==="number")return"#,##0.##";if(n.type==="date")return"yyyy-mm-dd"}function bi(n,t){if(t!=null)return t;const e=n.width??120;return Math.min(60,Math.max(8,(e-5)/7))}function vi(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 Ci(n){const t=await Promise.allSettled(n.map(async o=>{if(o.startsWith("data:")){const d=o.indexOf(","),c=o.slice(0,d),u=o.slice(d+1),p=atob(u),w=new Uint8Array(p.length);for(let h=0;h<p.length;h++)w[h]=p.charCodeAt(h);const g=c.match(/data:([^;,]+)/)?.[1]??"image/png";let f="png";return g.includes("jpeg")||g.includes("jpg")?f="jpeg":g.includes("gif")&&(f="gif"),{url:o,buffer:w.buffer,ext:f}}const i=await fetch(o,{mode:"cors"});if(!i.ok)throw new Error(`HTTP ${i.status}`);const l=await i.arrayBuffer(),a=vi(o,i.headers.get("content-type"));return{url:o,buffer:l,ext:a}})),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 _i(n,t,e={}){const{fileName:o="export.xlsx",sheets:i,columnStyles:l={},headerFillColor:a="#f1f5f9",headerTextColor:d="#334155",headerFontSize:c=10,bodyFontSize:u=10,aggregationResult:p=null,aggregationModel:w=null,selectedRows:x,groupedRows:g,groupHeaderFillColor:f="#e8eaf6",groupSubtotalFillColor:h="#f0f4ff"}=e,v=(await import("exceljs")).default,E=new v.Workbook;E.creator="OpenGridX",E.created=new Date;const m=t.filter(b=>b.exportable!==!1&&b.field!=="__check__"&&b.field!=="__actions__"&&!b.isSpacer),y=n,M=x&&x.length>0?n.filter(b=>x.includes(b.id)):n,N=i??[{name:"Data",rows:"all",includeHeaders:!0,includeSummary:!1}],k=new Map;for(const b of N){if("type"in b&&b.type==="summary"){if(!p||!w)continue;const G=E.addWorksheet(b.name??"Summary");G.addRow(["Summary / Aggregation Totals"]),G.getRow(1).font={bold:!0,size:c+2,color:{argb:Ne(d)}},G.addRow([]),G.addRow(["Column","Function","Value"]).eachCell(Y=>{Y.fill={type:"pattern",pattern:"solid",fgColor:{argb:Ne(a)}},Y.font={bold:!0,size:c,color:{argb:Ne(d)}},Y.border=Xn()}),m.forEach(Y=>{const Q=w[Y.field],J=p[Y.field];if(Q==null||J==null)return;let re=J;Y.valueFormatter?re=Y.valueFormatter({value:J,row:{},field:Y.field}):re=ve(J,Q);const q=G.addRow([Y.headerName??Y.field,Q.toUpperCase(),re]);q.getCell(3).alignment={horizontal:"right"},q.getCell(3).font={bold:!0,size:u}}),G.getColumn(1).width=20,G.getColumn(2).width=12,G.getColumn(3).width=18;continue}const F=b,{name:z="Data",rows:K="all",includeHeaders:W=!0,includeSummary:$=!1,autoFilter:H=!0,frozenHeader:L=!0,alternateRowColor:B="#f8fafc"}=F,D=K==="all"&&!!(g&&g.length>0),_=K==="selected"?M:D?g.flatMap(G=>G.type==="leaf"&&G.row?[G.row]:[]):y,T=m.filter(G=>l[G.field]?.embedImage);if(T.length>0){const G=[],R=new Set;if(_.forEach(Y=>{T.forEach(Q=>{const J=Y[Q.field];typeof J=="string"&&J&&!k.has(J)&&!R.has(J)&&(G.push(J),R.add(J))})}),G.length>0){const Y=await Ci(G);for(const[Q,{buffer:J,extension:re}]of Y){const q=E.addImage({buffer:J,extension:re});k.set(Q,q)}}}const I=E.addWorksheet(z);if(I.columns=m.map(G=>({key:G.field,width:bi(G,l[G.field]?.width),style:{numFmt:l[G.field]?.numFmt??wi(G)}})),W){const G=m.map(Y=>Y.headerName??Y.field),R=I.addRow(G);R.height=20,R.eachCell((Y,Q)=>{const J=m[Q-1];Y.fill={type:"pattern",pattern:"solid",fgColor:{argb:Ne(a)}},Y.font={bold:!0,size:c,color:{argb:Ne(d)}},Y.alignment={horizontal:l[J?.field]?.alignment??(J?.type==="number"?"right":"left"),vertical:"middle"},Y.border=Xn()}),H&&(I.autoFilter={from:{row:1,column:1},to:{row:1,column:m.length}}),L?I.views=[{state:"frozen",ySplit:1,showGridLines:!1}]:I.views=[{showGridLines:!1}]}let O=W?1:0;const X=(G,R,Y)=>{const Q=m.map(re=>{if(l[re.field]?.embedImage)return"";let q=G[re.field];return re.valueGetter&&(q=re.valueGetter({row:G,field:re.field,value:q})),mi(re,q)==="string"&&re.valueFormatter&&q!=null&&(q=re.valueFormatter({value:q,row:G,field:re.field})),q}),J=I.addRow(Q);if(J.font={size:u},Y>0&&(J.outlineLevel=Y),B&&R%2===1&&J.eachCell(re=>{re.fill={type:"pattern",pattern:"solid",fgColor:{argb:Ne(B)}}}),J.eachCell((re,q)=>{const V=m[q-1];V&&(re.alignment={horizontal:l[V.field]?.alignment??(V.type==="number"?"right":"left"),vertical:"middle"},re.border={bottom:{style:"thin",color:{argb:"FFf1f5f9"}}})}),T.length>0){const re=T.reduce((A,ee)=>Math.max(A,l[ee.field]?.imageHeight??40),0),q=Math.ceil(re/1.333),V=q*1.333;J.height=q,T.forEach(A=>{const ee=m.indexOf(A),ie=G[A.field],ae=typeof ie=="string"?k.get(ie):void 0;if(ae===void 0){J.getCell(ee+1).value=typeof ie=="string"?ie:"";return}const fe=l[A.field],he=fe?.imageWidth??40,Me=fe?.imageHeight??40,Pe=(I.getColumn(ee+1).width??8)*7+5,Se=Math.max(0,Pe-he)/2,oe=Math.max(0,V-Me)/2;I.addImage(ae,{tl:{col:ee,row:O,nativeColOff:Math.floor(Se*9525),nativeRowOff:Math.floor(oe*9525)},ext:{width:he,height:Me},editAs:"oneCell"})})}else J.height=16;O++},te=G=>{const R=m.find(Y=>Y.field===G.groupField);return R?.groupingValueFormatter&&G.groupField?R.groupingValueFormatter({field:G.groupField,value:G.groupValue}):`${R?.headerName??G.groupField??""}: ${String(G.groupValue??"")}`},Z=(G,R)=>{const Y=R[G.field];return Y==null?"":typeof Y=="number"?Y:G.valueFormatter?G.valueFormatter({value:Y,row:{},field:G.field}):ve(Y,w?.[G.field]??"")},ce=(G,R,Y,Q,J)=>{const re=m.map((V,A)=>A===0&&R[V.field]==null?G:Z(V,R)),q=I.addRow(re);q.height=18,Q>0&&(q.outlineLevel=Q),q.font={bold:J,italic:!J,size:u,color:{argb:Ne(d)}},q.eachCell((V,A)=>{V.fill={type:"pattern",pattern:"solid",fgColor:{argb:Ne(Y)}};const ee=m[A-1];V.alignment={horizontal:A===1?"left":ee?.type==="number"?"right":"left",vertical:"middle"},V.border=Jn()}),O++};let le=!1;if(D){let G=0;g.forEach(R=>{if(R.type==="group-header"){const Y=I.addRow([te(R)]);Y.height=18,R.depth>0&&(Y.outlineLevel=R.depth),Y.font={bold:!0,size:u,color:{argb:Ne(d)}};for(let Q=1;Q<=m.length;Q++)Y.getCell(Q).fill={type:"pattern",pattern:"solid",fgColor:{argb:Ne(f)}};Y.getCell(1).alignment={horizontal:"left",vertical:"middle",indent:R.depth},O++,G=0}else R.type==="leaf"&&R.row?X(R.row,G++,R.depth):R.type==="group-subtotal"&&R.aggregatedValues?ce("Subtotal",R.aggregatedValues,h,R.depth,!1):R.type==="grand-total"&&R.aggregatedValues&&(ce("Grand Total",R.aggregatedValues,a,0,!0),le=!0)}),I.properties.outlineProperties={summaryBelow:!0,summaryRight:!1}}else _.forEach((G,R)=>X(G,R,0));if($&&!le&&p&&w){const G=m.map(J=>{const re=w[J.field];return re?re.toUpperCase():""}),R=I.addRow(G);R.height=16,R.font={size:u-1,italic:!0,color:{argb:"FF94a3b8"}},R.eachCell(J=>{J.alignment={horizontal:"right",vertical:"middle"},J.border={top:{style:"thin",color:{argb:"FFcbd5e1"}}}});const Y=m.map(J=>{const re=w[J.field],q=p[J.field];return re==null||q==null?"":J.valueFormatter?J.valueFormatter({value:q,row:{},field:J.field}):ve(q,re)}),Q=I.addRow(Y);Q.height=18,Q.font={bold:!0,size:u,color:{argb:Ne(d)}},Q.eachCell(J=>{J.fill={type:"pattern",pattern:"solid",fgColor:{argb:Ne(a)}},J.alignment={horizontal:"right",vertical:"middle"},J.border=Jn()})}}const C=await E.xlsx.writeBuffer(),S=new Blob([C],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),j=URL.createObjectURL(S),P=document.createElement("a");P.href=j,P.download=o.endsWith(".xlsx")?o:`${o}.xlsx`,document.body.appendChild(P),P.click(),document.body.removeChild(P),URL.revokeObjectURL(j)}function Ne(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 Xn(){return{bottom:{style:"medium",color:{argb:"FFcbd5e1"}}}}function Jn(){return{top:{style:"medium",color:{argb:"FFcbd5e1"}}}}const yi={"--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 ki(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 Si({theme:n,children:t,className:e,style:o}){const i=s.useMemo(()=>({...yi,...ki(n)}),[n]);return r.jsx("div",{className:`ogx-theme-provider ${e||""}`.trim(),style:{...o,...i},children:t})}const ji={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"}},Ei={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"}},Ni={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"}},Mi={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"}},Pi={grid:{rowHeightCompact:"28px",rowHeightStandard:"36px",rowHeightComfortable:"48px",headerHeight:"40px",cellPaddingX:"8px",cellPaddingY:"4px"},typography:{fontSizeSm:"0.8rem",fontSizeMd:"0.875rem"}};function Ri(n,t){try{const e=t.getItem(n);return e?JSON.parse(e):void 0}catch{return}}function Ti(n,t,e,o){try{const i=e?Object.fromEntries(Object.entries(t).filter(([l])=>e.includes(l))):t;o.setItem(n,JSON.stringify(i))}catch{}}function Ii(n){const t=typeof n=="string"?{key:n}:n,{key:e,debounceMs:o=300,include:i,storage:l=typeof window<"u"?window.localStorage:void 0}=t,a=s.useMemo(()=>{if(l)return Ri(e,l)},[e,l]),d=s.useRef(null),c=s.useRef(null),u=s.useCallback(()=>{c.current&&l&&Ti(e,c.current,i,l)},[e,i,l]),p=s.useCallback(x=>{c.current=x,d.current&&clearTimeout(d.current),d.current=setTimeout(u,o)},[u,o]);s.useEffect(()=>()=>{d.current&&(clearTimeout(d.current),u())},[u]);const w=s.useCallback(()=>{l&&l.removeItem(e)},[e,l]);return{initialState:a,onStateChange:p,clearState:w}}se.Button=vt,se.Cell=zn,se.Checkbox=bt,se.ColumnVisibilityPanel=sn,se.DataGrid=Gr,se.DataGridThemeProvider=Si,se.FilterPanel=Hn,se.GridToolbar=li,se.GridTooltip=_t,se.Header=Ln,se.Input=ai,se.Row=At,se.Skeleton=Ur,se.amberTheme=Mi,se.compactTheme=Pi,se.darkTheme=ji,se.emeraldTheme=Ni,se.exportToCsv=gi,se.exportToExcel=hi,se.exportToExcelAdvanced=_i,se.exportToJson=pi,se.exportToPdf=fi,se.formatAggregationValue=ve,se.printGrid=xi,se.roseTheme=Ei,se.useAggregation=Tn,se.useGridApiRef=si,se.useGridStateStorage=Ii,se.usePivot=$n,Object.defineProperty(se,Symbol.toStringTag,{value:"Module"})}));
|
|
50
50
|
//# sourceMappingURL=opengridx.umd.js.map
|