@opencorestack/opengridx 1.0.7 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/index.d.ts +100 -12
  3. package/dist/opengridx.css +1 -1
  4. package/dist/opengridx.es.js +3199 -3015
  5. package/dist/opengridx.es.js.map +1 -1
  6. package/dist/opengridx.umd.js +12 -12
  7. package/dist/opengridx.umd.js.map +1 -1
  8. package/docs/API_REFERENCE.md +85 -0
  9. package/docs/components/cell.md +14 -0
  10. package/docs/components/filter-panel.md +13 -0
  11. package/docs/components/pagination.md +26 -0
  12. package/docs/components/row.md +26 -0
  13. package/docs/features/pdf-export.md +110 -0
  14. package/docs/roadmap.md +8 -0
  15. package/lib/components/Cell/Cell.tsx +44 -44
  16. package/lib/components/Cell/CellErrorBoundary.tsx +53 -0
  17. package/lib/components/DataGrid/DataGrid.css +11 -0
  18. package/lib/components/DataGrid/DataGrid.tsx +30 -6
  19. package/lib/components/DataGrid/GridListView.tsx +4 -0
  20. package/lib/components/DataGrid/GridPinnedRows.tsx +4 -0
  21. package/lib/components/DataGrid/GridVirtualRows.tsx +4 -0
  22. package/lib/components/Pagination/Pagination.test.tsx +64 -0
  23. package/lib/components/Pagination/Pagination.tsx +15 -4
  24. package/lib/components/Row/Row.tsx +6 -3
  25. package/lib/hooks/core/useGridColumns.tsx +11 -11
  26. package/lib/hooks/core/useGridControlledState.test.ts +86 -0
  27. package/lib/hooks/core/useGridKeyboardNavigation.test.ts +176 -0
  28. package/lib/hooks/core/useGridRowPipeline.test.ts +117 -0
  29. package/lib/hooks/useRowGrouping.test.ts +84 -0
  30. package/lib/hooks/useRowGrouping.ts +38 -13
  31. package/lib/hooks/useTreeData.ts +22 -2
  32. package/lib/index.ts +5 -1
  33. package/lib/types/index.ts +107 -12
  34. package/lib/utils/export/exportToPdf.test.ts +121 -0
  35. package/lib/utils/export/exportToPdf.ts +277 -0
  36. package/lib/utils/export/index.ts +3 -0
  37. package/lib/utils/export/pdf-types.d.ts +19 -0
  38. package/package.json +9 -1
@@ -1,16 +1,16 @@
1
- (function(ie,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],i):(ie=typeof globalThis<"u"?globalThis:ie||self,i(ie.OpenGridX={},ie.React,ie.ReactDOM))})(this,(function(ie,i,Ae){"use strict";var xt={exports:{}},it={};var un;function Yn(){if(un)return it;un=1;var n=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function e(o,l,s){var d=null;if(s!==void 0&&(d=""+s),l.key!==void 0&&(d=""+l.key),"key"in l){s={};for(var a in l)a!=="key"&&(s[a]=l[a])}else s=l;return l=s.ref,{$$typeof:n,type:o,key:d,ref:l!==void 0?l:null,props:s}}return it.Fragment=t,it.jsx=e,it.jsxs=e,it}var lt={};var fn;function qn(){return fn||(fn=1,process.env.NODE_ENV!=="production"&&(function(){function n(S){if(S==null)return null;if(typeof S=="function")return S.$$typeof===C?null:S.displayName||S.name||null;if(typeof S=="string")return S;switch(S){case j:return"Fragment";case k:return"Profiler";case I:return"StrictMode";case g:return"Suspense";case x:return"SuspenseList";case N:return"Activity"}if(typeof S=="object")switch(typeof S.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),S.$$typeof){case v:return"Portal";case y:return S.displayName||"Context";case w:return(S._context.displayName||"Context")+".Consumer";case b:var B=S.render;return S=S.displayName,S||(S=B.displayName||B.name||"",S=S!==""?"ForwardRef("+S+")":"ForwardRef"),S;case E:return B=S.displayName||null,B!==null?B:n(S.type)||"Memo";case M:B=S._payload,S=S._init;try{return n(S(B))}catch{}}return null}function t(S){return""+S}function e(S){try{t(S);var B=!1}catch{B=!0}if(B){B=console;var W=B.error,A=typeof Symbol=="function"&&Symbol.toStringTag&&S[Symbol.toStringTag]||S.constructor.name||"Object";return W.call(B,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",A),t(S)}}function o(S){if(S===j)return"<>";if(typeof S=="object"&&S!==null&&S.$$typeof===M)return"<...>";try{var B=n(S);return B?"<"+B+">":"<...>"}catch{return"<...>"}}function l(){var S=P.A;return S===null?null:S.getOwner()}function s(){return Error("react-stack-top-frame")}function d(S){if(O.call(S,"key")){var B=Object.getOwnPropertyDescriptor(S,"key").get;if(B&&B.isReactWarning)return!1}return S.key!==void 0}function a(S,B){function W(){H||(H=!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)",B))}W.isReactWarning=!0,Object.defineProperty(S,"key",{get:W,configurable:!0})}function u(){var S=n(this.type);return L[S]||(L[S]=!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.")),S=this.props.ref,S!==void 0?S:null}function c(S,B,W,A,$,X){var U=W.ref;return S={$$typeof:_,type:S,key:B,props:W,_owner:A},(U!==void 0?U:null)!==null?Object.defineProperty(S,"ref",{enumerable:!1,get:u}):Object.defineProperty(S,"ref",{enumerable:!1,value:null}),S._store={},Object.defineProperty(S._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(S,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(S,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:$}),Object.defineProperty(S,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:X}),Object.freeze&&(Object.freeze(S.props),Object.freeze(S)),S}function h(S,B,W,A,$,X){var U=B.children;if(U!==void 0)if(A)if(T(U)){for(A=0;A<U.length;A++)m(U[A]);Object.freeze&&Object.freeze(U)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else m(U);if(O.call(B,"key")){U=n(S);var oe=Object.keys(B).filter(function(Q){return Q!=="key"});A=0<oe.length?"{key: someKey, "+oe.join(": ..., ")+": ...}":"{key: someKey}",G[U+A]||(oe=0<oe.length?"{"+oe.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
1
+ (function(re,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],l):(re=typeof globalThis<"u"?globalThis:re||self,l(re.OpenGridX={},re.React,re.ReactDOM))})(this,(function(re,l,ze){"use strict";var _t={exports:{}},st={};var hn;function Zn(){if(hn)return st;hn=1;var n=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function e(o,i,s){var d=null;if(s!==void 0&&(d=""+s),i.key!==void 0&&(d=""+i.key),"key"in i){s={};for(var a in i)a!=="key"&&(s[a]=i[a])}else s=i;return i=s.ref,{$$typeof:n,type:o,key:d,ref:i!==void 0?i:null,props:s}}return st.Fragment=t,st.jsx=e,st.jsxs=e,st}var at={};var pn;function eo(){return pn||(pn=1,process.env.NODE_ENV!=="production"&&(function(){function n(y){if(y==null)return null;if(typeof y=="function")return y.$$typeof===v?null:y.displayName||y.name||null;if(typeof y=="string")return y;switch(y){case k:return"Fragment";case j:return"Profiler";case M:return"StrictMode";case m:return"Suspense";case g:return"SuspenseList";case N:return"Activity"}if(typeof y=="object")switch(typeof y.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),y.$$typeof){case C:return"Portal";case E:return y.displayName||"Context";case x:return(y._context.displayName||"Context")+".Consumer";case f:var L=y.render;return y=y.displayName,y||(y=L.displayName||L.name||"",y=y!==""?"ForwardRef("+y+")":"ForwardRef"),y;case S:return L=y.displayName||null,L!==null?L:n(y.type)||"Memo";case P:L=y._payload,y=y._init;try{return n(y(L))}catch{}}return null}function t(y){return""+y}function e(y){try{t(y);var L=!1}catch{L=!0}if(L){L=console;var z=L.error,$=typeof Symbol=="function"&&Symbol.toStringTag&&y[Symbol.toStringTag]||y.constructor.name||"Object";return z.call(L,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",$),t(y)}}function o(y){if(y===k)return"<>";if(typeof y=="object"&&y!==null&&y.$$typeof===P)return"<...>";try{var L=n(y);return L?"<"+L+">":"<...>"}catch{return"<...>"}}function i(){var y=I.A;return y===null?null:y.getOwner()}function s(){return Error("react-stack-top-frame")}function d(y){if(R.call(y,"key")){var L=Object.getOwnPropertyDescriptor(y,"key").get;if(L&&L.isReactWarning)return!1}return y.key!==void 0}function a(y,L){function z(){U||(U=!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)",L))}z.isReactWarning=!0,Object.defineProperty(y,"key",{get:z,configurable:!0})}function u(){var y=n(this.type);return T[y]||(T[y]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),y=this.props.ref,y!==void 0?y:null}function c(y,L,z,$,H,X){var Y=z.ref;return y={$$typeof:_,type:y,key:L,props:z,_owner:$},(Y!==void 0?Y:null)!==null?Object.defineProperty(y,"ref",{enumerable:!1,get:u}):Object.defineProperty(y,"ref",{enumerable:!1,value:null}),y._store={},Object.defineProperty(y._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(y,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(y,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:H}),Object.defineProperty(y,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:X}),Object.freeze&&(Object.freeze(y.props),Object.freeze(y)),y}function p(y,L,z,$,H,X){var Y=L.children;if(Y!==void 0)if($)if(W(Y)){for($=0;$<Y.length;$++)w(Y[$]);Object.freeze&&Object.freeze(Y)}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(Y);if(R.call(L,"key")){Y=n(y);var te=Object.keys(L).filter(function(J){return J!=="key"});$=0<te.length?"{key: someKey, "+te.join(": ..., ")+": ...}":"{key: someKey}",V[Y+$]||(te=0<te.length?"{"+te.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
2
  let props = %s;
3
3
  <%s {...props} />
4
4
  React keys must be passed directly to JSX without using spread:
5
5
  let props = %s;
6
- <%s key={someKey} {...props} />`,A,U,oe,U),G[U+A]=!0)}if(U=null,W!==void 0&&(e(W),U=""+W),d(B)&&(e(B.key),U=""+B.key),"key"in B){W={};for(var R in B)R!=="key"&&(W[R]=B[R])}else W=B;return U&&a(W,typeof S=="function"?S.displayName||S.name||"Unknown":S),c(S,U,W,l(),$,X)}function m(S){f(S)?S._store&&(S._store.validated=1):typeof S=="object"&&S!==null&&S.$$typeof===M&&(S._payload.status==="fulfilled"?f(S._payload.value)&&S._payload.value._store&&(S._payload.value._store.validated=1):S._store&&(S._store.validated=1))}function f(S){return typeof S=="object"&&S!==null&&S.$$typeof===_}var p=i,_=Symbol.for("react.transitional.element"),v=Symbol.for("react.portal"),j=Symbol.for("react.fragment"),I=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),w=Symbol.for("react.consumer"),y=Symbol.for("react.context"),b=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),x=Symbol.for("react.suspense_list"),E=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),C=Symbol.for("react.client.reference"),P=p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,O=Object.prototype.hasOwnProperty,T=Array.isArray,F=console.createTask?console.createTask:function(){return null};p={react_stack_bottom_frame:function(S){return S()}};var H,L={},D=p.react_stack_bottom_frame.bind(p,s)(),K=F(o(s)),G={};lt.Fragment=j,lt.jsx=function(S,B,W){var A=1e4>P.recentlyCreatedOwnerStacks++;return h(S,B,W,!1,A?Error("react-stack-top-frame"):D,A?F(o(S)):K)},lt.jsxs=function(S,B,W){var A=1e4>P.recentlyCreatedOwnerStacks++;return h(S,B,W,!0,A?Error("react-stack-top-frame"):D,A?F(o(S)):K)}})()),lt}var gn;function Xn(){return gn||(gn=1,process.env.NODE_ENV==="production"?xt.exports=Yn():xt.exports=qn()),xt.exports}var r=Xn();function st(n,t){return t?t.left?.includes(n)?"left":t.right?.includes(n)?"right":null:null}function Jn(n,t){const e=[],o=[],l=[];return t?(n.forEach(s=>{const d=st(s.field,t);d==="left"?e.push(s):d==="right"?l.push(s):o.push(s)}),t.left&&e.sort((s,d)=>{const a=t.left.indexOf(s.field),u=t.left.indexOf(d.field);return a-u}),t.right&&l.sort((s,d)=>{const a=t.right.indexOf(s.field),u=t.right.indexOf(d.field);return a-u}),{left:e,center:o,right:l}):{left:e,center:n,right:l}}function Ot(n,t,e,o,l,s,d,a){const u={};if(!e)return u;const c=Jn(n,e);let h=0;a&&(h+=48),s&&d&&(h+=48),o&&l&&(h+=48),c.left.forEach(f=>{u[f.field]=h;const p=t[f.field]??f.width??100;h+=p});let m=0;return[...c.right].reverse().forEach(f=>{const p=t[f.field]??f.width??100;u[f.field]=m,m+=p}),u}function Ft(n,t){return t?t.top?.includes(n)?"top":t.bottom?.includes(n)?"bottom":null:null}function Qn(n,t){const e=[],o=[],l=[];return t?(n.forEach(s=>{const d=Ft(s.id,t);d==="top"?e.push(s):d==="bottom"?l.push(s):o.push(s)}),t.top&&e.sort((s,d)=>{const a=t.top.indexOf(s.id),u=t.top.indexOf(d.id);return a-u}),t.bottom&&l.sort((s,d)=>{const a=t.bottom.indexOf(s.id),u=t.bottom.indexOf(d.id);return a-u}),{top:e,center:o,bottom:l}):{top:e,center:n,bottom:l}}function He(n){if(n===void 0)return{type:"auto",value:0};if(typeof n=="number")return{type:"fixed",value:n};if(typeof n=="string"){if(n.toLowerCase()==="auto")return{type:"auto",value:0};if(n.endsWith("%"))return{type:"percentage",value:parseFloat(n)};const t=parseFloat(n);if(!isNaN(t))return{type:"fixed",value:t}}return{type:"fixed",value:100}}function Zn(n){const{rowHeight:t,pagination:e,paginatedUnpinnedRows:o,sortedUnpinnedRows:l,expandedRowIds:s,getDetailPanelHeight:d,pinnedTopRowsLength:a,pinnedBottomRowsLength:u,visibleOrderedColumns:c,pinnedColumns:h,columnWidths:m,viewportWidth:f,checkboxSelection:p,hasDetailPanel:_,rowReordering:v,paginationMode:j,isLoading:I,pageSize:k}=n;return i.useMemo(()=>{const w=e?o:l,y=w.map((z,J)=>{let te=t;if(s.has(z.id)){const ce=d?.({row:z,id:z.id,rowIndex:a+J})??200;te+=typeof ce=="number"?ce:parseInt(String(ce),10)||200}return te}),b=y.reduce((z,J,te)=>(z.push((z[te-1]||0)+J),z),[]),g=j==="infinite"&&I&&w.length>0?Math.min(k,20):0,x=(b[b.length-1]||0)+g*t,E=a*t,M=u*t,N=[],C=[],P=[],O=[];c.forEach(z=>{const J=st(z.field,h);J==="left"?N.push(z):J==="right"?C.push(z):P.push(z)});const T=(p?48:0)+(_?48:0)+(v?48:0),F=z=>m[z.field]??z.width,H=N.reduce((z,J)=>{const te=He(F(J));return z+(te.type==="fixed"?te.value:100)},0),L=C.reduce((z,J)=>{const te=He(F(J));return z+(te.type==="fixed"?te.value:100)},0),D=P.reduce((z,J)=>{if(!Object.prototype.hasOwnProperty.call(m,J.field)&&J.flex&&J.flex>0){const ue=J.minWidth??150,je=typeof J.width=="number"?J.width:150;return z+(ue||je)}const ce=He(F(J));return ce.type==="fixed"?z+ce.value:ce.type==="percentage"?z+100:z+(J.minWidth??150)},0),K=Math.max(f-T-H-L,D),G=[],S=[],B=[];P.forEach(z=>{const J=Object.prototype.hasOwnProperty.call(m,z.field),te=He(F(z));if(!J&&z.flex&&z.flex>0){B.push({col:z,flex:z.flex});return}te.type==="fixed"?G.push({col:z,width:te.value}):te.type==="percentage"?S.push({col:z,percentage:te.value}):B.push({col:z,flex:1})});const W=G.reduce((z,{width:J})=>z+J,0);let A=Math.max(0,K-W);const $=new Map;S.forEach(({col:z,percentage:J})=>{const te=J/100*A;$.set(z.field,te),A-=te}),A=Math.max(0,A);const X=new Map,U=B.map(z=>({...z,minWidth:z.col.minWidth??50,maxWidth:z.col.maxWidth??1/0,frozen:!1,computedWidth:0}));(()=>{let z=0;const J=U.length*2;for(;z<J;){z++;const te=U.filter(ne=>!ne.frozen);if(te.length===0)break;const ce=te.reduce((ne,we)=>ne+we.flex,0),ue=U.reduce((ne,we)=>we.frozen?ne+we.computedWidth:ne,0),je=Math.max(0,A-ue);if(ce<=0){te.forEach(ne=>{ne.computedWidth=ne.minWidth,ne.frozen=!0});break}const Re=je/ce;let We=0;const ge=[],Ke=[];if(te.forEach(ne=>{const we=Re*ne.flex;we<ne.minWidth?(We+=ne.minWidth-we,ge.push(ne)):we>ne.maxWidth?(We+=ne.maxWidth-we,Ke.push(ne)):ne.computedWidth=we}),ge.length===0&&Ke.length===0){te.forEach(ne=>ne.frozen=!0);break}We>0?ge.forEach(ne=>{ne.computedWidth=ne.minWidth,ne.frozen=!0}):We<0?Ke.forEach(ne=>{ne.computedWidth=ne.maxWidth,ne.frozen=!0}):(ge.forEach(ne=>{ne.computedWidth=ne.minWidth,ne.frozen=!0}),Ke.forEach(ne=>{ne.computedWidth=ne.maxWidth,ne.frozen=!0}))}})(),U.forEach(z=>X.set(z.col.field,z.computedWidth));const R=new Map;P.forEach(z=>{let J;if(X.has(z.field))J=X.get(z.field);else{const te=G.find(ue=>ue.col.field===z.field),ce=S.find(ue=>ue.col.field===z.field);if(te)J=te.width;else if(ce){const ue=$.get(z.field)||0;J=Math.max(z.minWidth??50,ue||100)}else J=100}O.push(J),R.set(z.field,J)});const Q=P.map(z=>{const J=U.find(te=>te.col.field===z.field);return{...z,width:R.get(z.field)??(typeof z.width=="number"?z.width:100),flex:J?J.flex:z.flex}}),Z=11,le=N.map((z,J)=>{const te=He(F(z));return{...z,width:te.type==="fixed"?te.value:100,zIndex:Z+J}}),re=11,Y=C.map((z,J)=>{const te=He(F(z));return{...z,width:te.type==="fixed"?te.value:100,zIndex:re+(C.length-1-J)}}),q=O.reduce((z,J)=>z+J,0),se=H+q+L+T,ae=O.reduce((z,J,te)=>(z.push((z[te-1]||0)+J),z),[]);return{rowHeights:y,cumulativeHeights:b,unpinnedRowsHeight:x,pinnedTopHeight:E,pinnedBottomHeight:M,leftPinnedCols:le,rightPinnedCols:Y,unpinnedColsWithWidth:Q,unpinnedColWidths:O,unpinnedAccWidths:ae,totalWidth:se,leftWidth:H,rightWidth:L,unpinnedTotalWidth:q,systemColumnsWidth:T,pinnedTopRowsLength:a,pinnedBottomRowsLength:u,unpinnedRowsLength:w.length}},[t,e,o,l,s,d,a,u,c,h,m,f,p,_,v,j,I,k])}function eo(n){const{allRenderableRows:t,navigationColumns:e,checkboxSelection:o,selectedRowIds:l,handleSelectionChange:s,handleDetailPanelToggle:d,editingHandlers:a,setKeyboardMode:u,sortModel:c,handleSort:h,isCellEditable:m,pagination:f,pageSize:p,virtualization:_,viewportRef:v}=n,[j,I]=i.useState(null),k=i.useCallback(b=>{b.target===b.currentTarget&&I(g=>{if(g)return g;if(o)return{id:"HEADER",field:"__checkbox_col__"};const x=t[0],E=e[0];return x&&E?{id:x.id,field:E.field}:null})},[t,e,o]),w=i.useCallback(b=>{b.currentTarget.contains(b.relatedTarget)||I(null)},[]),y=i.useCallback(b=>{if(u(!0),!j)return;const{id:g,field:x}=j,E=!!a.editingCell;if(g==="HEADER"&&(b.key==="Enter"||b.key===" ")){b.preventDefault();const L=e.find(D=>D.field===x);if(L&&L.sortable!==!1){const D=c.find(G=>G.field===x);let K="asc";D&&(K=D.sort==="asc"?"desc":null),h(x,K)}return}if(b.key==="Enter"){if(b.preventDefault(),E)a.stopCellEdit();else if(e.find(D=>D.field===x)?.editable){const D=t.find(K=>K.id===g);D&&a.startCellEdit({id:g,field:x,value:D[x]})}return}if((b.key===" "||b.key==="Spacebar")&&!E){if(x==="__checkbox_col__"){b.preventDefault(),s(g,!l.has(g));return}if(x==="__expand_col__"){b.preventDefault(),d(g);return}}if(b.key==="Escape"){E&&(b.preventDefault(),a.stopCellEdit({cancel:!0}));return}if(E&&b.key!=="Tab")return;const M=g==="HEADER",N=M?-1:t.findIndex(L=>L.id===g),C=e.findIndex(L=>L.field===x);if(!M&&N===-1||C===-1)return;const P=(L,D,K,G,S,B=!1)=>{let W=L+K,A=D+G;return S&&G!==0&&(G>0&&A>=e.length?(A=0,W++):G<0&&A<0&&(A=e.length-1,W--)),!S&&(A<0||A>=e.length)||W<(B?-1:0)||W>=t.length?null:{r:W,c:A}},O=(L,D,K,G,S,B=!1)=>{let W=L,A=D,$=0;const X=t.length*e.length+e.length;for(;$<X;){if($++,W+=K,A+=G,G!==0)G>0?A>=e.length&&(A=0,W++):A<0&&(A=e.length-1,W--);else if(A<0||A>=e.length)return null;if(W<-1||W>=t.length)return null;if(W===-1){if(!B)continue;const Z=e[A],le=Z.sortable!==!1;if(["__checkbox_col__"].includes(Z.field)||le)return{r:W,c:A};continue}const U=t[W],oe=e[A],R=["__checkbox_col__","__expand_col__","__reorder_col__"].includes(oe.field);let Q=oe.editable||R;if(m&&!R)try{Q=m({row:U,field:oe.field,value:U[oe.field],colDef:oe,rowIndex:W,colIndex:A})}catch{}if(Q)return{r:W,c:A}}return null};let T=N,F=C,H=!1;if(b.key==="Tab"){const L=b.shiftKey?-1:1,D=O(N,C,0,L,!0,!1);D&&(T=D.r,F=D.c,H=!0)}else if(b.key==="ArrowRight"){const L=P(N,C,0,1,!0,!0);L&&(T=L.r,F=L.c,H=!0)}else if(b.key==="ArrowLeft"){const L=P(N,C,0,-1,!0,!0);L&&(T=L.r,F=L.c,H=!0)}else if(b.key==="ArrowDown"){const L=P(N,C,1,0,!1,!0);L&&(T=L.r,F=L.c,H=!0)}else if(b.key==="ArrowUp"){const L=P(N,C,-1,0,!1,!0);L&&(T=L.r,F=L.c,H=!0)}else if(b.key==="Home")F=0,(b.ctrlKey||b.metaKey)&&(T=-1),H=!0;else if(b.key==="End")F=e.length-1,(b.ctrlKey||b.metaKey)&&(T=t.length-1),H=!0;else if(b.key==="PageUp")T=Math.max(-1,T-(f?p:10)),H=!0;else if(b.key==="PageDown"){const L=f?p:10;T=Math.min(t.length-1,T+L),H=!0}if(H&&(b.preventDefault(),E&&b.key==="Tab"&&a.stopCellEdit(),T>=-1&&T<t.length&&F>=0&&F<e.length)){const L=e[F];I(T===-1?{id:"HEADER",field:L.field}:{id:t[T].id,field:L.field});const D=v.current;if(D){const{cumulativeHeights:K,pinnedTopHeight:G,columnMetrics:S}=_,{clientHeight:B,clientWidth:W,scrollTop:A,scrollLeft:$}=D,X=T<=0?0:K[T-1],U=K[T],oe=A+G,R=A+B;let Q=A;if(X<oe?Q=Math.max(0,X-G):U>R&&(Q=U-B),Q!==A&&(D.scrollTop=Q),S){const{leftPinnedWidth:Z,rightPinnedWidth:le,unpinnedAccWidths:re,unpinnedCols:Y,totalSpecialsWidth:q,pinnedSpecialsWidth:se}=S,ae=Y.findIndex(z=>z.field===L.field);if(ae!==-1){const z=q+Z+(ae>0?re[ae-1]:0),J=q+Z+re[ae],te=$+se+Z,ce=$+W-le;let ue=$;z<te?ue=Math.max(0,z-se-Z):J>ce&&(ue=J-W+le),ue!==$&&(D.scrollLeft=ue)}}}}},[j,t,e,a,_,l,s,d,u,c,h,m,f,p,v]);return{focusedCell:j,setFocusedCell:I,handleFocus:k,handleBlur:w,handleKeyDown:y}}const to={rowFields:[],columnFields:[],valueFields:[]};function no(n){const{initialState:t,sortModel:e,aggregationModel:o,onAggregationModelChange:l,columnVisibilityModel:s,onColumnVisibilityModelChange:d,pinnedColumns:a,onPinnedColumnsChange:u,pivotModel:c,onPivotModelChange:h,paginationModel:m={page:0,pageSize:100},onPaginationModelChange:f,rowSelectionModel:p}=n,[_,v]=i.useState(()=>t?.sorting?.sortModel??[]),j=e!==void 0,I=j?e:_,k=o!==void 0,[w,y]=i.useState(()=>o??{}),b=k?o:w,g=i.useCallback(Z=>{k||y(Z),l?.(Z)},[k,l]),x=s!==void 0,[E,M]=i.useState(()=>t?.columns?.columnVisibilityModel??{}),N=x?s:E,C=i.useCallback(Z=>{x||M(Z),d?.(Z)},[x,d]),P=a!==void 0,[O,T]=i.useState(()=>t?.columns?.pinnedColumns??{}),F=P?a:O,H=i.useCallback(Z=>{P||T(Z),u?.(Z)},[P,u]),[L,D]=i.useState(()=>c??to),K=c??L,G=i.useCallback(Z=>{D(Z),h?.(Z)},[h]),S=m!==void 0&&n.paginationModel!==void 0,[B,W]=i.useState(()=>t?.pagination?.paginationModel??m),A=S?m:B,$=i.useCallback(Z=>{S||W(Z),f?.(Z)},[S,f]),X=p!==void 0,[U,oe]=i.useState([]),R=X?p:U,Q=i.useMemo(()=>new Set(R),[R]);return{sortModel:I,isSortControlled:j,setInternalSortModel:v,aggregationModel:b,handleAggregationModelChange:g,columnVisibilityModel:N,handleColumnVisibilityModelChange:C,pinnedColumns:F,handlePinnedColumnsChange:H,currentPivotModel:K,handlePivotModelChange:G,effectivePaginationModel:A,handlePaginationModelChange:$,rowSelectionModel:R,selectedRowIds:Q,isSelectionControlled:X,setInternalRowSelectionModel:oe}}const oo={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 ro(n,t){const{field:e,operator:o,value:l}=t,s=n[e],d=oo[o];return d?d(s,l):(console.warn(`Unknown filter operator: ${o}`),!0)}function io(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 At(n,t){const e=t.items??[],o=t.logicOperator??"and",l=("quickFilterValues"in t?t.quickFilterValues:void 0)??[];if(l.length>0&&!io(n,l))return!1;if(e.length===0)return!0;const s=d=>{if("logicOperator"in d&&"items"in d){const a=d,u=a.items;return u.length===0?!0:a.logicOperator==="and"?u.every(s):u.some(s)}else return ro(n,d)};return o==="and"?e.every(s):e.some(s)}function lo(n,t){if(!t)return n;const{items:e=[],quickFilterValues:o=[]}=t;return e.length===0&&(!o||o.length===0)?n:n.filter(l=>At(l,t))}function so(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 ao(n,t){if(t.length===0)return n;const e=[...n];return e.sort((o,l)=>{for(const s of t){const d=o[s.field],a=l[s.field],u=zt(d,a,s.sort);if(u!==0)return u}return 0}),e}function co(n){const{effectiveRows:t,activeHierarchyHandlers:e,filterMode:o,filterModel:l,dataSource:s,sortModel:d,sortingMode:a,pagination:u,paginationMode:c,effectivePaginationModel:h,pinnedRows:m,isLoading:f,pageSize:p}=n,_=i.useMemo(()=>e?e.getVisibleRows()||[]:o==="server"&&s?t:lo(t,l),[t,l,e,o,s]),{top:v,center:j,bottom:I}=i.useMemo(()=>e?{top:[],center:_,bottom:[]}:Qn(_,m),[_,m,e]),k=i.useMemo(()=>e||a==="server"&&s?j:ao(j,d),[j,d,e,a,s]),w=i.useMemo(()=>{if(!u||c==="server"&&s)return k;const b=h.page*h.pageSize;return k.slice(b,b+h.pageSize)},[k,u,h.page,h.pageSize,c,s]),y=i.useMemo(()=>{if(e)return j;const b=u?w:k,g=[...v,...b,...I];if(c==="infinite"&&f&&g.length>0){const x=Math.min(p,20),E=Array.from({length:x},(M,N)=>({id:`__skeleton_${N}__`,_isSkeleton:!0}));return[...g,...E]}return g},[v,w,k,I,u,e,j,c,f,p]);return{filteredRows:_,pinnedTopRows:v,unpinnedRows:j,pinnedBottomRows:I,sortedUnpinnedRows:k,paginatedUnpinnedRows:w,allRenderableRows:y}}function uo(n){const{layout:t,scrollTop:e,scrollLeft:o,viewportWidth:l,viewportHeight:s,autoHeight:d,rowReordering:a,hasDetailPanel:u,checkboxSelection:c,pinCheckboxColumn:h,pinExpandColumn:m}=n;return i.useMemo(()=>{const{unpinnedAccWidths:f,unpinnedColsWithWidth:p,leftPinnedCols:_,rightPinnedCols:v,totalWidth:j,leftWidth:I,rightWidth:k,unpinnedTotalWidth:w,systemColumnsWidth:y,cumulativeHeights:b,pinnedTopHeight:g,pinnedBottomHeight:x,unpinnedRowsHeight:E,rowHeights:M,unpinnedRowsLength:N}=t,C=l||1e3,P=d?g+E+x+50:s||600,O=6,T=Math.max(0,o-I),F=o+C-I;let H=0,L=p.length-1,D=0,K=f.length-1;for(;D<=K;){const re=D+K>>>1;f[re]<T?D=re+1:K=re-1}H=Math.max(0,D-O);for(let re=H;re<f.length;re++){if((re===0?0:f[re-1])>F){L=Math.min(p.length-1,re+O);break}L=Math.min(p.length-1,re+O)}const G=H>0?f[H-1]:0,S=w-f[L],B=[..._,...G>0?[{field:"__spacer_left__",width:G,isSpacer:!0}]:[],...p.slice(H,L+1),...S>0?[{field:"__spacer_right__",width:S,isSpacer:!0}]:[],...v],A=C>0&&j>C?16:0,$=g+E+x+A+2,X=5;let U=0,oe=N-1,R=0,Q=0,Z=b.length-1;for(;Q<=Z;){const re=Q+Z>>>1;b[re]<e?Q=re+1:Z=re-1}U=Math.max(0,Q-X),R=U>0?b[U-1]:0;for(let re=U;re<b.length;re++)if(b[re]>=e+P){oe=Math.min(N-1,re+X);break}const le=(a?48:0)+(u&&m?48:0)+(c&&h?48:0);return{renderContext:{firstRowIndex:U,lastRowIndex:oe,firstColumnIndex:H,lastColumnIndex:L},offsetTop:R,offsetLeft:0,totalHeight:$,pinnedTopHeight:g,pinnedBottomHeight:x,totalWidth:j,rowHeights:M,cumulativeHeights:b,virtualColumns:B,columnMetrics:{leftPinnedWidth:I,rightPinnedWidth:k,unpinnedAccWidths:f,unpinnedCols:p,totalSpecialsWidth:y,pinnedSpecialsWidth:le}}},[t,e,o,l,s,d,a,u,c,h,m])}function fo(n){const{columns:t,onColumnOrderChange:e,disableColumnReorder:o=!1}=n,[l,s]=i.useState(null),[d,a]=i.useState(null),u=i.useRef(-1),c=i.useCallback(p=>_=>{if(o)return;const v=t.findIndex(I=>I.field===p);if(t[v]?.pinnable===!1){_.preventDefault();return}s(p),u.current=v,_.dataTransfer&&(_.dataTransfer.effectAllowed="move",_.dataTransfer.setData("text/plain",p))},[t,o]),h=i.useCallback(p=>_=>{o||!l||(_.preventDefault(),_.dataTransfer.dropEffect="move",a(p))},[l,o]),m=i.useCallback(p=>_=>{if(_.preventDefault(),o||!l||l===p){s(null),a(null);return}const v=t.findIndex(k=>k.field===l),j=t.findIndex(k=>k.field===p);if(v===-1||j===-1){s(null),a(null);return}const I=t[v];e&&e({column:I,oldIndex:v,targetIndex:j}),s(null),a(null),u.current=-1},[t,l,o,e]),f=i.useCallback(()=>{s(null),a(null),u.current=-1},[]);return{draggedColumn:l,dragOverColumn:d,onDragStart:o?void 0:c,onDragOver:o?void 0:h,onDragEnd:o?void 0:f,onDrop:o?void 0:m}}function hn({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 go(n){const{activeColumns:t,isHierarchyEnabled:e,isRowGrouping:o,isTreeData:l,activeHierarchyHandlers:s,columnVisibilityModel:d,columnOrder:a,onColumnOrderChange:u,disableColumnReorder:c,pivotMode:h,checkboxSelection:m,hasDetailPanel:f,rowReordering:p,initialState:_,setColumns:v}=n,j=i.useMemo(()=>e?t.map((C,P)=>P===0?{...C,renderCell:O=>{const T=O.row,F=typeof T._treeDepth=="number"?T._treeDepth:0,H=!!T._hasChildren,L=!!T._isExpanded,D=typeof T._groupingField=="string"?T._groupingField:void 0,K=T._groupingValue,G=typeof T._descendantCount=="number"?T._descendantCount:void 0,S=!!T._isGroupRow;let B=C.renderCell?C.renderCell(O):O.value;return l&&H&&S&&(B=r.jsxs("div",{className:"ogx__group-cell-content",children:[O.value,G!==void 0&&G>0?` (${G})`:""]})),o&&H&&D&&(B=r.jsxs("div",{className:"ogx__group-cell-content",children:[C.field===D?"":`${D}: `,String(K),G!==void 0?` (${G})`:""]})),r.jsxs("div",{style:{display:"flex",alignItems:"center",paddingLeft:F*24,width:"100%",height:"100%"},children:[r.jsx("div",{style:{marginRight:4,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",cursor:H?"pointer":"default",flexShrink:0},children:H?r.jsx("div",{onClick:W=>{W.stopPropagation(),W.preventDefault(),s?.toggleExpansion(O.row.id)},onMouseDown:W=>{W.stopPropagation()},style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:10,position:"relative"},children:r.jsx(hn,{isExpanded:L,onClick:W=>{W.stopPropagation(),W.preventDefault(),s?.toggleExpansion(O.row.id)}})}):null}),r.jsx("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:B})]})}}:{...C,renderCell:O=>{const T=O.row,F=!!T._hasChildren,H=typeof T._groupingField=="string"?T._groupingField:void 0;return o&&F?C.field===H?null:O.value!==void 0&&O.value!==null?C.renderCell?C.renderCell(O):O.value:null:C.renderCell?C.renderCell(O):O.value}}):t,[t,e,o,l,s]),[I,k]=i.useState(()=>_?.columns?.columnWidths??{}),w=i.useCallback((C,P)=>{k(O=>({...O,[C]:P}))},[]),[y,b]=i.useState(()=>_?.columns?.columnOrder??t.map(C=>C.field)),g=a??y;i.useEffect(()=>{v(t)},[t,v]),i.useEffect(()=>{h&&b(t.map(C=>C.field))},[h,t]);const x=i.useMemo(()=>{if(c)return j;const C=new Map(g.map((P,O)=>[P,O]));return[...j].sort((P,O)=>{const T=C.get(P.field)??j.indexOf(P),F=C.get(O.field)??j.indexOf(O);return T-F})},[j,g,c]),E=i.useMemo(()=>x.filter(C=>d[C.field]!==!1),[x,d]),M=fo({columns:x,onColumnOrderChange:i.useCallback(C=>{const{oldIndex:P,targetIndex:O}=C,T=[...g],[F]=T.splice(P,1);T.splice(O,0,F),a||b(T),u?.(C)},[g,a,u]),disableColumnReorder:c}),N=i.useMemo(()=>{const C=[];return p&&C.push({field:"__reorder_col__"}),f&&C.push({field:"__expand_col__"}),m&&C.push({field:"__checkbox_col__"}),[...C,...x]},[x,m,f,p]);return{effectiveColumns:j,orderedColumns:x,visibleOrderedColumns:E,navigationColumns:N,columnWidths:I,effectiveColumnOrder:g,setInternalColumnOrder:b,columnReorderHandlers:M,handleColumnResize:w}}function ho(n){const{renderContext:t,pinnedTopRows:e,pinnedBottomRows:o,paginatedUnpinnedRows:l,sortedUnpinnedRows:s,pagination:d}=n;return i.useMemo(()=>{const{firstRowIndex:a,lastRowIndex:u}=t,c=d?l:s,h=e.length,m=e.map((k,w)=>({row:k,rowIndex:w})),f=o.map((k,w)=>({row:k,rowIndex:h+c.length+w})),p=Math.max(0,a-h),_=Math.min(c.length,u-h+1),v=c.slice(p,_).map((k,w)=>({row:k,rowIndex:h+p+w})),j=[...m,...v,...f],I=new Set;return j.filter(k=>I.has(k.row.id)?!1:(I.add(k.row.id),!0))},[t,e,o,l,s,d])}function po(n){const{onRowsScrollEnd:t}=n,e=i.useRef({scrollTop:0,scrollLeft:0}),o=i.useRef(null),[l,s]=i.useState({scrollTop:0,scrollLeft:0});i.useEffect(()=>()=>{o.current!==null&&cancelAnimationFrame(o.current)},[]);const d=i.useCallback(a=>{const u=a.currentTarget;if(e.current={scrollTop:u.scrollTop,scrollLeft:u.scrollLeft},o.current!==null&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{o.current=null,s(e.current)}),t){const{scrollTop:c,scrollHeight:h,clientHeight:m}=u;h-c-m<100&&t({visibleTop:c,visibleBottom:c+m,viewportHeight:m})}},[t]);return{scrollTop:l.scrollTop,scrollLeft:l.scrollLeft,handleScroll:d}}function xo(n){const{onStateChange:t,sortModel:e,filterModel:o,effectivePaginationModel:l,columnWidths:s,effectiveColumnOrder:d,columnVisibilityModel:a,pinnedColumns:u}=n,c=i.useRef(t);i.useLayoutEffect(()=>{c.current=t}),i.useEffect(()=>{if(!c.current)return;const h={sorting:{sortModel:e},filter:{filterModel:o},pagination:{paginationModel:l},columns:{columnWidths:s,columnOrder:d,columnVisibilityModel:a,pinnedColumns:u}};c.current(h)},[e,o,l,s,d,a,u])}const mo={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 Te(n,t){return n==null?"—":typeof n=="number"?t==="avg"?n.toLocaleString(void 0,{maximumFractionDigits:2}):n.toLocaleString():String(n)}function pn(n){const{rows:t,aggregationModel:e,isServerSide:o,dataSource:l,filterModel:s,sortModel:d,serverAggregationResults:a}=n,u=i.useMemo(()=>{if(o||Object.keys(e).length===0)return{};const k={};for(const[w,y]of Object.entries(e)){const b=mo[y];if(!b){console.warn(`[useAggregation] Unknown aggregation function: "${y}"`);continue}const g=t.map(x=>x[w]);k[w]=b(g)}return k},[t,e,o]),[c,h]=i.useState({}),[m,f]=i.useState(!1),[p,_]=i.useState(null),v=i.useRef(0),j=i.useCallback(async()=>{if(!l?.getAggregations||Object.keys(e).length===0)return;const k=++v.current;f(!0),_(null);try{const w=await l.getAggregations({sortModel:d??[],filterModel:s??{items:[]},groupKeys:[],aggregationModel:e});k===v.current&&h(w)}catch(w){k===v.current&&(_(w),console.error("[useAggregation] Server aggregation error:",w))}finally{k===v.current&&f(!1)}},[l,e,s,d]);return i.useEffect(()=>{o&&l?.getAggregations&&!a&&j()},[j,o,l,a]),{aggregationResult:i.useMemo(()=>o?a&&Object.keys(a).length>0?a:c:u,[o,u,a,c]),isLoading:m,error:p}}function bo({columns:n,aggregationModel:t,aggregationResult:e,columnWidths:o,rowHeight:l,checkboxSelection:s,hasDetailPanel:d,rowReordering:a,pinnedColumns:u}){const c=i.useMemo(()=>Ot(n,o,u,s,!0,d,!0,a),[n,o,u,s,d,a]),h=u?.left?.[u.left.length-1],m=u?.right?.[0];return r.jsxs("div",{className:"ogx__aggregation-footer",role:"row","aria-label":"Aggregation totals","aria-live":"polite",style:{minHeight:`${l}px`},children:[s&&r.jsx("div",{style:{width:48,flexShrink:0}}),d&&r.jsx("div",{style:{width:48,flexShrink:0}}),a&&r.jsx("div",{style:{width:48,flexShrink:0}}),n.map(f=>{const p=t[f.field],_=e[f.field],v=o[f.field]??(typeof f.width=="number"?f.width:120),j=st(f.field,u),I=j?c[f.field]:void 0,k=["ogx__aggregation-cell",j==="left"&&"ogx__aggregation-cell--pinned-left",j==="right"&&"ogx__aggregation-cell--pinned-right",j==="left"&&f.field===h&&"ogx__aggregation-cell--pinned-left-last",j==="right"&&f.field===m&&"ogx__aggregation-cell--pinned-right-first"].filter(Boolean).join(" "),w={width:v,minWidth:v,maxWidth:v,textAlign:f.align||"left"};return j==="left"&&I!==void 0&&(w.left=I),j==="right"&&I!==void 0&&(w.right=I),r.jsx("div",{className:k,role:"gridcell",style:w,children:p?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"ogx__aggregation-label",children:p}),r.jsx("span",{className:"ogx__aggregation-value",children:Te(_,p)})]}):null},f.field)})]})}function wo({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 vo({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 at=({indeterminate:n=!1,label:t,className:e="",inputRef:o,...l})=>{const s=i.useRef(null),d=i.useCallback(u=>{s.current=u,typeof o=="function"?o(u):o&&(o.current=u)},[o]);i.useEffect(()=>{s.current&&(s.current.indeterminate=n)},[n]);const a=["ogx-checkbox-wrapper",l.disabled&&"ogx-checkbox-wrapper--disabled",e].filter(Boolean).join(" ");return r.jsxs("label",{className:a,children:[r.jsx("input",{ref:d,type:"checkbox",className:"ogx-checkbox__input","aria-label":t||l["aria-label"]||(n?"Select some":l.checked?"Deselect":"Select"),...l}),r.jsxs("span",{className:"ogx-checkbox__box",children:[l.checked&&!n&&r.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:r.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})}),n&&r.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:r.jsx("path",{d:"M19 13H5v-2h14v2z"})})]}),t&&r.jsx("span",{className:"ogx-checkbox__label",children:t})]})};function _o(n){const{field:t,currentWidth:e,onResize:o,minWidth:l=50,maxWidth:s=1e3}=n,[d,a]=i.useState(!1),u=i.useRef(0),c=i.useRef(0),h=i.useCallback(p=>{p.preventDefault(),p.stopPropagation(),a(!0),u.current=p.clientX,c.current=e;let _=0;const v=16,j=k=>{const w=k.clientX-u.current,y=Math.max(l,Math.min(s,c.current+w)),b=Date.now();b-_>=v&&(o(t,y),_=b)},I=k=>{a(!1);const w=k.clientX-u.current,y=Math.max(l,Math.min(s,c.current+w));o(t,y),document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",I)};document.addEventListener("mousemove",j),document.addEventListener("mouseup",I)},[t,e,o,l,s]),m=i.useCallback(p=>{p.preventDefault(),p.stopPropagation()},[]),f=["ogx-column-resize-handle",d&&"ogx-column-resize-handle--dragging"].filter(Boolean).join(" ");return r.jsx("div",{className:f,onMouseDown:h,onClick:p=>p.stopPropagation(),onDragStart:p=>{p.preventDefault(),p.stopPropagation()},onDoubleClick:m,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${t} column`,children:r.jsx("div",{className:"ogx-column-resize-handle__line"})})}function De(){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 Ge(){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 Co(){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 yo(){return r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),r.jsx("polyline",{points:"5 12 12 5 19 12"})]})}function ko(){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 So(){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 jo(){return r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("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 Eo(){return r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"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 No(){return r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"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 Mo(){return r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("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 Io({colDef:n,sortModel:t,onSort:e,onHide:o,onPin:l,pinnedColumns:s,onManageColumns:d,onClose:a,anchorEl:u}){const c=i.useRef(null),[h,m]=i.useState({position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"});i.useLayoutEffect(()=>{if(!u||!c.current)return;const b=u.getBoundingClientRect(),g=c.current.getBoundingClientRect(),x=window.innerWidth,E=window.innerHeight,M=8;let N=b.left;N+g.width+M>x&&(N=x-g.width-M),N<M&&(N=M);let C=b.bottom+4;C+g.height+M>E&&(C=b.top-g.height-4),m({position:"fixed",zIndex:1300,top:C,left:N,visibility:"visible"})},[u]),i.useEffect(()=>{function b(x){c.current&&!c.current.contains(x.target)&&u&&!u.contains(x.target)&&a()}function g(x){x.key==="Escape"&&a()}return document.addEventListener("mousedown",b),document.addEventListener("keydown",g),window.addEventListener("scroll",a,!0),window.addEventListener("resize",a),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",g),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a)}},[u,a]);const f=b=>{e?.(n.field,b),a()},p=()=>{o?.(n.field),a()},_=b=>{l?.(n.field,b),a()},v=t?.find(b=>b.field===n.field)?.sort,j=v==null,I=s?.left?.includes(n.field)??!1,k=s?.right?.includes(n.field)??!1,w=!I&&!k,y=n.headerName||n.field;return Ae.createPortal(r.jsxs("div",{ref:c,className:"ogx-column-menu",style:h,role:"menu","aria-label":`Column options for ${y}`,children:[e&&n.sortable!==!1&&r.jsxs(r.Fragment,{children:[r.jsxs("button",{className:`ogx-menu-item${v==="asc"?" ogx-menu-item--active":""}`,onClick:()=>f("asc"),role:"menuitemradio","aria-checked":v==="asc",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:v==="asc"?r.jsx(De,{}):r.jsx(Ge,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(yo,{})}),"Sort Ascending"]}),r.jsxs("button",{className:`ogx-menu-item${v==="desc"?" ogx-menu-item--active":""}`,onClick:()=>f("desc"),role:"menuitemradio","aria-checked":v==="desc",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:v==="desc"?r.jsx(De,{}):r.jsx(Ge,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(ko,{})}),"Sort Descending"]}),r.jsxs("button",{className:`ogx-menu-item${j?" ogx-menu-item--active":""}`,onClick:()=>f(null),role:"menuitemradio","aria-checked":j,children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:j?r.jsx(De,{}):r.jsx(Ge,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(So,{})}),"Unsort"]}),r.jsx("div",{className:"ogx-menu-divider"})]}),r.jsx("div",{className:"ogx-menu-section-label","aria-hidden":"true",children:"Pin column"}),r.jsxs("button",{className:`ogx-menu-item${I?" ogx-menu-item--active":""}`,onClick:()=>_("left"),role:"menuitemradio","aria-checked":I,"aria-label":"Pin to left",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:I?r.jsx(De,{}):r.jsx(Ge,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(Eo,{})}),"Pin to Left"]}),r.jsxs("button",{className:`ogx-menu-item${k?" ogx-menu-item--active":""}`,onClick:()=>_("right"),role:"menuitemradio","aria-checked":k,"aria-label":"Pin to right",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:k?r.jsx(De,{}):r.jsx(Ge,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(No,{})}),"Pin to Right"]}),r.jsxs("button",{className:`ogx-menu-item${w?" ogx-menu-item--active":""}`,onClick:()=>_(null),role:"menuitemradio","aria-checked":w,"aria-label":"Unpin column",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:w?r.jsx(De,{}):r.jsx(Ge,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(Mo,{})}),"Unpin"]}),r.jsx("div",{className:"ogx-menu-divider"}),r.jsxs("button",{className:"ogx-menu-item",onClick:p,role:"menuitem","aria-label":`Hide ${y} column`,children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(jo,{})}),"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(Co,{})}),"Manage columns"]})]}),u?.closest(".ogx-theme-provider")||document.body)}function Po(){return r.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"18",height:"18",children:r.jsx("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"})})}function To(){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 xn(n){const t=[];for(const e of n.children)typeof e=="string"?t.push(e):t.push(...xn(e));return t}function Lo(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 Ro(n,t,e){function o(a,u,c){if(!xn(a).includes(u))return null;if(c===e)return a;for(const h of a.children)if(typeof h!="string"){const m=o(h,u,c+1);if(m)return m}return null}const l=new Map;for(const a of t){let u=null;for(const c of n)if(u=o(c,a.field,0),u)break;l.set(a.field,u)}const s=[];let d=0;for(;d<t.length;){const a=t[d],u=l.get(a.field)??null,c=a.width;if(!u)s.push({key:`fg-${a.field}-${e}`,label:"",width:c,isGroup:!1}),d++;else{let h=0,m=d;for(;m<t.length&&l.get(t[m].field)===u;)h+=t[m].width,m++;s.push({key:`${u.groupId}-${e}`,label:u.headerName,width:h,isGroup:!0}),d=m}}return s}function mn(n){const{columns:t,allColumns:e,columnGroupingModel:o,checkboxSelection:l=!1,allSelected:s=!1,someSelected:d=!1,onSelectAll:a,onSort:u,sortModel:c=[],onColumnResize:h,columnWidths:m={},pinnedColumns:f,hasDetailPanel:p=!1,pinCheckboxColumn:_=!0,pinExpandColumn:v=!0,rowReordering:j=!1,aggregationModel:I,draggedColumn:k,dragOverColumn:w,onDragStart:y,onDragOver:b,onDragEnd:g,onDrop:x,focusedCell:E,onHeaderClick:M,onHideColumn:N,onPinColumn:C,onManageColumns:P}=n,O=i.useId(),T=i.useRef({}),[F,H]=i.useState(null),L=R=>Q=>{Q.stopPropagation(),H({colDef:R,anchorEl:Q.currentTarget})},D=()=>{H(null)};i.useLayoutEffect(()=>{if(E?.id==="HEADER"){const R=T.current[E.field];R&&R.focus()}},[E]);const K=R=>()=>{if(R.sortable===!1||!u)return;const Q=c.find(le=>le.field===R.field);let Z="asc";Q&&(Q.sort==="asc"?Z="desc":Z=null),u(R.field,Z)},G=R=>{const Q=c.find(Z=>Z.field===R);return Q?r.jsx("span",{className:`ogx__sort-icon ogx__sort-icon--${Q.sort}`,"aria-hidden":"true"}):null},S=i.useMemo(()=>Ot(t,m,f,l,_,p,v,j),[t,m,f,l,_,p,v,j]),B=o?Lo(o):0,A=(e??t).filter(R=>!R.isSpacer).map(R=>({field:R.field,width:m[R.field]??R.width??100})),oe=(j?48:0)+(p?48:0)+(l?48:0);return r.jsxs("div",{className:"ogx__header-wrap",children:[B>0&&Array.from({length:B},(R,Q)=>{const Z=Ro(o,A,Q);return r.jsxs("div",{className:"ogx-col-group-row",role:"row",children:[oe>0&&r.jsx("div",{className:"ogx-col-group-cell ogx-col-group-cell--filler",style:{width:oe,minWidth:oe,flexShrink:0},role:"columnheader"}),Z.map(le=>r.jsx("div",{role:"columnheader",className:`ogx-col-group-cell ${le.isGroup?"ogx-col-group-cell--group":"ogx-col-group-cell--filler"}`,style:{width:le.width,minWidth:le.width,flexShrink:0},title:le.isGroup?le.label:void 0,children:le.isGroup&&r.jsx("span",{className:"ogx-col-group-cell__label",children:le.label})},le.key))]},`ogx-grp-${Q}`)}),r.jsxs("div",{className:"ogx__header",role:"row",children:[j&&r.jsx("div",{className:"ogx__header-cell ogx__header-cell--pinned ogx__header-cell--pinned-left",role:"columnheader","aria-label":"Row reorder handle",title:"Drag to reorder rows",style:{minWidth:48,maxWidth:48,position:"sticky",left:0,zIndex:4}}),p&&r.jsx("div",{className:`ogx__header-cell ogx__header-cell--expand ${v?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""}`,role:"columnheader","aria-label":"Expand row details",style:{minWidth:48,maxWidth:48,position:v?"sticky":void 0,left:v?j?48:0:void 0,zIndex:v?5:void 0}}),l&&r.jsx("div",{className:`ogx__header-cell ogx__header-cell--checkbox ${_?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""}`,role:"columnheader",style:{position:_?"sticky":void 0,left:_?(j?48:0)+(p&&v?48:0):void 0},children:r.jsx(at,{id:O,name:O,checked:s,indeterminate:d,onChange:R=>a?.(R.target.checked),"aria-label":s?"Deselect all rows":"Select all rows",tabIndex:E?.id==="HEADER"&&E.field==="__checkbox_col__"?0:-1,onMouseDown:R=>R.preventDefault(),inputRef:R=>{T.current.__checkbox_col__=R}})}),t.map((R,Q)=>{if(R.isSpacer)return r.jsx("div",{style:{width:R.width,minWidth:R.width,flexShrink:0},"aria-hidden":"true"},R.field);const Z=R.sortable!==!1,le=c.some(ge=>ge.field===R.field),re=R.resizable!==!1,Y=st(R.field,f),q=Y!==null,se=k===R.field,ae=w===R.field,z=["ogx__header-cell",`ogx__header-cell--align-${R.headerAlign||R.align||"left"}`,Z&&"ogx__header-cell--sortable",le&&"ogx__header-cell--sorted",q&&"ogx__header-cell--pinned",q&&`ogx__header-cell--pinned-${Y}`,se&&"ogx__header-cell--dragging",ae&&"ogx__header-cell--drag-over",E?.id==="HEADER"&&E.field===R.field&&"ogx__header-cell--focused",R.headerClassName].filter(Boolean).join(" "),J=m[R.field]??R.width??100,te={width:J,minWidth:R.minWidth,maxWidth:R.maxWidth,flexGrow:R.flex??0,flexShrink:0,flexBasis:(R.flex,"auto"),boxSizing:"border-box",position:q?"sticky":"relative",zIndex:R.zIndex,opacity:se?.5:1};if(q&&Y){const ge=S[R.field];Y==="left"?te.left=ge:te.right=ge}const ce=R.renderHeader?R.renderHeader({field:R.field,colDef:R,colIndex:Q}):R.headerName||R.field,ue=ge=>{if(ge.target.closest(".ogx-column-resize-handle")){ge.stopPropagation();return}M?.(R.field),Z&&K(R)()},je=y?y(R.field):void 0,Re=b?b(R.field):void 0,We=x?x(R.field):void 0;return r.jsxs("div",{className:z,style:te,onClick:ue,role:"columnheader",draggable:!!y,onDragStart:je,onDragOver:Re,onDragEnd:g,onDrop:We,"aria-sort":Z?le?c.find(ge=>ge.field===R.field)?.sort==="asc"?"ascending":"descending":"none":void 0,"aria-colindex":Q+1+(l?1:0),"data-field":R.field,tabIndex:-1,ref:ge=>{T.current[R.field]=ge},children:[r.jsxs("div",{className:"ogx__header-cell-content",children:[se&&r.jsx("div",{className:"ogx__header-drag-icon",children:r.jsx(To,{})}),r.jsxs("div",{className:"ogx__header-cell-title-wrapper",children:[r.jsx("span",{className:"ogx__header-cell-title",children:ce}),I&&I[R.field]&&r.jsx("span",{className:"ogx__header-cell-aggregation",children:I[R.field]})]}),Z&&G(R.field),!R.disableColumnMenu&&r.jsx("button",{className:"ogx__menu-icon-btn",onClick:L(R),"aria-label":`Open column menu for ${R.headerName||R.field}`,"aria-haspopup":"menu",tabIndex:-1,children:r.jsx(Po,{})})]}),re&&h&&r.jsx(_o,{field:R.field,currentWidth:J,onResize:h,minWidth:R.minWidth,maxWidth:R.maxWidth})]},R.field)}),F&&r.jsx(Io,{colDef:F.colDef,sortModel:c,onSort:u,onHide:N,onPin:C,pinnedColumns:f,onManageColumns:P,onClose:D,anchorEl:F.anchorEl})]})]})}const dt=({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 bn(n){const t=i.useId(),{page:e,pageSize:o,rowCount:l,onPageChange:s,onPageSizeChange:d,pageSizeOptions:a=[10,25,50,100],showFirstButton:u=!0,showLastButton:c=!0}=n,h=Math.max(1,Math.ceil(l/o)),m=Math.min(e,h-1),f=m*o,p=Math.min(f+o,l),_=l===0?0:`${f+1}–${p}`,v=()=>{s(0)},j=()=>{s(Math.max(0,m-1))},I=()=>{s(Math.min(h-1,m+1))},k=()=>{s(h-1)},w=g=>{const x=parseInt(g.target.value,10);d(x)},y=m===0,b=m>=h-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:"Rows per page:"}),r.jsx("select",{id:t,className:"ogx-pagination__select",value:o,onChange:w,"aria-label":"Rows per page",children:a.map(g=>r.jsx("option",{value:g,children:g},g))})]}),r.jsxs("div",{className:"ogx-pagination__info","aria-live":"polite","aria-atomic":"true",children:[_," of ",l]}),r.jsxs("div",{className:"ogx-pagination__actions",children:[u&&r.jsx(dt,{variant:"text",size:"small",onClick:v,disabled:y,"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(dt,{variant:"text",size:"small",onClick:j,disabled:y,"aria-label":"Go to previous page",title:"Previous page",children:r.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:r.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),r.jsxs("div",{className:"ogx-pagination__page-info","aria-current":"page",children:["Page ",m+1," of ",h]}),r.jsx(dt,{variant:"text",size:"small",onClick:I,disabled:b,"aria-label":"Go to next page",title:"Next page",children:r.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:r.jsx("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})})}),c&&r.jsx(dt,{variant:"text",size:"small",onClick:k,disabled:b,"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 Wo(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 Oo(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 Fo(n){const{rows:t,columns:e,rowHeight:o=52,headerHeight:l=56,columnVisibilityModel:s,initialState:d}=n,[a]=i.useState(()=>Wo(t,e,s)),[u,c]=i.useReducer(Oo,{...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}}),h=i.useRef(u);i.useLayoutEffect(()=>{h.current=u});const m=i.useRef(t);i.useEffect(()=>{t!==m.current&&(m.current=t,c({type:"SET_ROWS",payload:t}))},[t]);const f=i.useCallback((x,E)=>{c({type:"SET_ROWS",payload:x,preserveRowCount:E})},[]),p=i.useCallback(x=>{c({type:"SET_COLUMNS",payload:x})},[]),_=i.useCallback(x=>{c({type:"SET_SORT_MODEL",payload:x})},[]),v=i.useCallback(x=>{c({type:"SET_FILTER_MODEL",payload:x})},[]),j=i.useCallback(x=>{c({type:"SET_PAGINATION_MODEL",payload:x})},[]),I=i.useCallback(x=>{c({type:"SET_SELECTION",payload:x})},[]),k=i.useCallback((x,E)=>{c({type:"SET_DIMENSIONS",payload:{viewportWidth:x,viewportHeight:E}})},[]),w=i.useCallback(x=>{c({type:"SET_DATASOURCE_LOADING",payload:x})},[]),y=i.useCallback(x=>{c({type:"SET_DATASOURCE_ERROR",payload:x})},[]),b=i.useCallback(x=>{c({type:"SET_ROW_COUNT",payload:x})},[]),g=i.useRef({getRow:x=>h.current.rows.idRowsLookup.get(x)||null,getAllRows:()=>Array.from(h.current.rows.idRowsLookup.values()),getVisibleRows:()=>Array.from(h.current.rows.idRowsLookup.values()),getAggregationResult:()=>null,getAggregationModel:()=>null,getColumn:x=>h.current.columns.lookup.get(x)||null,getAllColumns:()=>h.current.columns.all,getVisibleColumns:()=>h.current.columns.all,selectRow:(x,E=!0)=>{const M=new Set(h.current.selection.selectedRows);E?M.add(x):M.delete(x),I(M)},selectRows:(x,E=!0)=>{const M=new Set(h.current.selection.selectedRows);x.forEach(N=>{E?M.add(N):M.delete(N)}),I(M)},getSelectedRows:()=>Array.from(h.current.selection.selectedRows),sortColumn:(x,E)=>{if(E===null)_(h.current.sorting.sortModel.filter(M=>M.field!==x));else{const M=h.current.sorting.sortModel.findIndex(N=>N.field===x);if(M>=0){const N=[...h.current.sorting.sortModel];N[M]={field:x,sort:E},_(N)}else _([...h.current.sorting.sortModel,{field:x,sort:E}])}},getSortModel:()=>h.current.sorting.sortModel,setFilterModel:v,getFilterModel:()=>h.current.filter.filterModel,setPage:x=>{j({...h.current.pagination.paginationModel,page:x})},setPageSize:x=>{j({...h.current.pagination.paginationModel,pageSize:x,page:0})},scrollToIndexes:()=>{},copySelectedRows:()=>Promise.resolve()});return{state:u,dispatch:c,apiRef:g,setRows:f,setColumns:p,setSortModel:_,setFilterModel:v,setPaginationModel:j,setSelection:I,setDimensions:k,setDataSourceLoading:w,setDataSourceError:y,setRowCount:b}}function Ao(n){const{onRowOrderChange:t,rows:e,getRowId:o,rowReordering:l=!1}=n,[s,d]=i.useState(null),[a,u]=i.useState(null),c=i.useCallback(_=>o?o(_):_.id,[o]),h=i.useCallback(_=>v=>{l&&(d(_),v.dataTransfer.effectAllowed="move")},[l]),m=i.useCallback(_=>v=>{!l||!s||(v.preventDefault(),v.dataTransfer.dropEffect="move",a!==_&&u(_))},[l,s,a]),f=i.useCallback(()=>{d(null),u(null)},[]),p=i.useCallback(_=>v=>{if(v.preventDefault(),!s||!t){f();return}const j=e.findIndex(k=>c(k)===s),I=e.findIndex(k=>c(k)===_);j!==-1&&I!==-1&&j!==I&&t({row:e[j],oldIndex:j,targetIndex:I}),f()},[s,t,e,c,f]);return{draggedRowId:s,dragOverRowId:a,onDragStart:l?h:void 0,onDragOver:l?m:void 0,onDragEnd:l?f:void 0,onDrop:l?p:void 0}}function zo(n){const{rows:t,getRowId:e,getTreeDataPath:o,treeData:l=!1,defaultGroupingExpansionDepth:s=0,filterModel:d,sortModel:a,onRowExpansionChange:u}=n,{treeNodes:c,rootIds:h,groupingRows:m}=i.useMemo(()=>{if(!l||!o)return{treeNodes:new Map,rootIds:[],groupingRows:[]};const y=new Map,b=[],g=[],x=new Map,E=M=>M.join("/");return t.forEach(M=>{const N=e(M),C=o(M),P=E(C);x.set(P,N),y.set(N,{id:N,parentId:null,depth:C.length-1,groupingKey:C[C.length-1],isExpanded:!1,children:[],serverChildrenCount:M.serverChildrenCount})}),t.forEach(M=>{const N=e(M),C=o(M);if(C.length===1){b.push(N);return}const P=T=>{if(T.length<=1)return;const F=T.slice(0,-1),H=E(F);let L=x.get(H);if(L===void 0&&(L=`auto-group-${H}`,!y.has(L))){const D=F[F.length-1];y.set(L,{id:L,parentId:null,depth:F.length-1,groupingKey:D,isExpanded:!1,children:[],label:D}),x.set(H,L);const K={id:L,name:D,_isGroupRow:!0};g.push(K),F.length===1&&b.push(L),P(F)}return L},O=P(C);if(O!==void 0){const T=y.get(O),F=y.get(N);T&&F&&(F.parentId=O,T.children=T.children||[],T.children.includes(N)||T.children.push(N))}}),g.forEach(M=>{const N=M.id,C=y.get(N);if(!C)return;const O=N.replace("auto-group-","").split("/");if(O.length>1){const T=O.slice(0,-1),F=E(T),H=x.get(F);if(H&&y.has(H)){C.parentId=H;const L=y.get(H);L&&(L.children=L.children||[],L.children.includes(N)||L.children.push(N))}}}),{treeNodes:y,rootIds:b,groupingRows:g}},[t,o,l,e]),f=i.useMemo(()=>{if(!l)return new Set;const y=new Set;return c.forEach(b=>{b.children&&b.children.length>0&&(s===-1||b.depth<s)&&y.add(b.id)}),y},[c,l,s]),[p,_]=i.useState(new Set);i.useEffect(()=>{f.size>0&&_(f)},[f]);const v=i.useCallback(y=>{_(b=>{const g=new Set(b),x=!g.has(y);if(g.has(y)?g.delete(y):g.add(y),x&&u){const E=c.get(y);E&&u(E)}return g})},[c,u]),j=i.useCallback(()=>{if(!l)return null;const y=new Map;t.forEach(P=>y.set(e(P),P)),m.forEach(P=>y.set(P.id,P));const b=P=>At(P,d),g=new Map,x=P=>{if(g.has(P))return g.get(P);const O=y.get(P);if(!O)return!1;if(b(O))return g.set(P,!0),!0;const F=c.get(P);return F&&F.children&&F.children.some(L=>x(L))?(g.set(P,!0),!0):(g.set(P,!1),!1)},E=(P,O)=>{if(!a||a.length===0)return 0;const T=y.get(P),F=y.get(O);if(!T||!F)return 0;for(const H of a){const L=T[H.field],D=F[H.field],K=zt(L,D,H.sort);if(K!==0)return K}return 0},M=[],N=new Set,C=P=>{const O=P.filter(T=>x(T));O.sort(E),O.forEach(T=>{if(N.has(T))return;const F=y.get(T),H=c.get(T);if(F&&H){N.add(T);const L={...F,_treeDepth:H.depth,_isExpanded:p.has(T),_hasChildren:!!(H.children&&H.children.length>0||H.serverChildrenCount&&H.serverChildrenCount>0),_descendantCount:H.children?H.children.length:0};M.push(L),p.has(T)&&H.children&&H.children.length>0&&C(H.children)}})};return C(h),M},[l,t,m,h,c,p,d,a,e]),I=i.useCallback(y=>p.has(y),[p]),k=i.useCallback(y=>c.get(y),[c]),w=i.useCallback(y=>{const b=[];let g=y;for(;g!==null;){const x=c.get(g);if(!x)break;b.unshift(x.groupingKey),g=x.parentId}return b},[c]);return i.useMemo(()=>({treeNodes:c,groupingRows:m,toggleExpansion:v,isGroupExpanded:I,getVisibleRows:j,getNode:k,getNodePath:w}),[c,m,v,I,j,k,w])}const Bo=n=>n?.depth===-1?"footer":"inline";function $o(n){const{rows:t,getRowId:e,rowGroupingModel:o=[],aggregationModel:l={},defaultGroupingExpansionDepth:s=0,filterModel:d,sortModel:a,getAggregationPosition:u=Bo}=n,[c,h]=i.useState(new Set),{treeNodes:m,rootIds:f,groupingRows:p}=i.useMemo(()=>{const k=new Map,w=new Map,y=[];if(o.length===0)return{treeNodes:k,rootIds:y,groupingRows:w};const b=(E,M,N)=>`auto-group-${E}-${M}-${N||"root"}`,g=(E,M,N)=>{if(M>=o.length)return E.map(T=>{const F=e(T);return k.set(F,{id:F,parentId:N,depth:M,groupingKey:"",isExpanded:!1}),F});const C=o[M],P=new Map;E.forEach(T=>{const F=T[C],H=String(F);P.has(H)||P.set(H,[]),P.get(H).push(T)});const O=[];return P.forEach((T,F)=>{const L=T[0][C],D=b(C,F,N);O.push(D);const K={};l&&Object.entries(l).forEach(([A,$])=>{const X=T.map(U=>U[A]);if($==="sum")K[A]=X.reduce((U,oe)=>U+(Number(oe)||0),0);else if($==="min")K[A]=Math.min(...X.map(U=>Number(U)||0));else if($==="max")K[A]=Math.max(...X.map(U=>Number(U)||0));else if($==="avg"){const U=X.reduce((oe,R)=>oe+(Number(R)||0),0);K[A]=X.length?U/X.length:0}else $==="count"&&(K[A]=X.length)});const G={[C]:L,...K,id:D};w.set(D,G);const S={id:D,parentId:N,depth:M,groupingKey:F,groupingField:C,groupingValue:L,aggregatedValues:K,isExpanded:!1,children:[],label:`${C}: ${String(L)}`};S.aggregationPosition=u(S),k.set(D,S);const B=g(T,M+1,D);k.get(D).children=B;const W=T.length;k.get(D).descendantCount=W}),O},x=g(t,0,null);return y.push(...x),{treeNodes:k,rootIds:y,groupingRows:w}},[t,o,l,e,u]);i.useEffect(()=>{if(s===-1){const k=new Set;m.forEach((w,y)=>{w.children&&w.children.length>0&&k.add(y)}),h(k)}else if(s>0){const k=new Set;m.forEach((w,y)=>{w.depth<s&&w.children&&w.children.length>0&&k.add(y)}),h(k)}else h(new Set)},[o,s,m]);const _=i.useCallback(k=>{h(w=>{const y=new Set(w);return y.has(k)?y.delete(k):y.add(k),y})},[]),v=i.useCallback(k=>c.has(k),[c]),j=i.useCallback(()=>{if(o.length===0)return null;const k=[],w=new Set,y=new Map;t.forEach(E=>y.set(e(E),E));const b=E=>{const M=m.get(E);if(!M)return!1;if(!M.children||M.children.length===0){const N=y.get(E);return!(!N||d&&!At(N,d))}return M.children.some(N=>b(N))},g=E=>{let M=E;d&&(M=E.filter(b)),a&&a.length>0&&M.sort((N,C)=>{const P=p.get(N)||y.get(N),O=p.get(C)||y.get(C);if(!P||!O)return 0;for(const T of a){const F=P[T.field],H=O[T.field],L=zt(F,H,T.sort);if(L!==0)return L}return 0}),M.forEach(N=>{if(w.has(N))return;const C=m.get(N),P=C?.children&&C.children.length>0,O=P?p.get(N):y.get(N);if(O&&C){w.add(N);const T={...O,_treeDepth:C.depth,_isExpanded:c.has(N),_hasChildren:P,_groupingField:C.groupingField,_groupingValue:C.groupingValue,_descendantCount:C.descendantCount};k.push(T),x.has(N)&&P&&g(C.children)}})},x=c;return g(f),k},[t,e,m,f,p,d,a,c,o]),I=i.useCallback(k=>m.get(k),[m]);return i.useMemo(()=>({treeNodes:m,groupingRows:p,toggleExpansion:_,isGroupExpanded:v,getVisibleRows:j,getNode:I}),[m,p,_,v,j,I])}function Ho(n){const{rows:t,getRowId:e,processRowUpdate:o,onProcessRowUpdateError:l,onRowChange:s}=n,[d,a]=i.useState(null),u=i.useRef(null),c=i.useCallback(p=>{a(p),u.current=typeof p=="function"?p(u.current):p},[]),h=i.useCallback(p=>{c({id:p.id,field:p.field,value:p.value,originalValue:p.value})},[c]),m=i.useCallback(async p=>{const _=u.current;if(!_)return;if(p?.cancel){c(null);return}const{id:v,field:j,value:I,originalValue:k}=_;if(I===k){c(null);return}const w=t.find(b=>e(b)===v);if(!w){c(null);return}const y={...w,[j]:I};try{if(o){const b=await o(y,w);s?.(b)}else s?.(y);c(null)}catch(b){l?.(b)}},[c,t,e,o,s,l]),f=i.useCallback(p=>{d&&d.id===p.id&&d.field===p.field&&c(_=>_?{..._,value:p.value}:null)},[d,c]);return{editingCell:d,startCellEdit:h,stopCellEdit:m,setEditCellValue:f}}function Do(n,t,e){const[o,l]=i.useState(new Map),[s,d]=i.useState({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}}),a=i.useCallback(()=>{l(new Map)},[]),u=i.useCallback((v,j)=>o.get(v)?.[j],[o]),c=i.useCallback((v,j,I,k,w)=>{const y=new Map(o);for(let b=k;b<w;b++){const g=t[b];if(!g)continue;let x=1;if(g.colSpan)if(typeof g.colSpan=="function"){const M={row:j,value:j[g.field],field:g.field,colDef:g,rowIndex:I,colIndex:b};x=g.colSpan(M)}else x=g.colSpan;if(x<=1){Ve(y,v,g.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:e[g.field]||100}});continue}let E=e[g.field]||100;for(let M=1;M<x;M++)if(b+M<w){const N=t[b+M];N&&(E+=e[N.field]||100,Ve(y,v,N.field,{spannedByColSpan:!0,leftVisibleCellIndex:b,rightVisibleCellIndex:Math.min(b+x-1,t.length-1)}))}Ve(y,v,g.field,{spannedByColSpan:!1,cellProps:{colSpan:x,width:E}}),b+=x-1}l(y)},[o,t,e]),h=i.useCallback((v,j)=>{const I={},k={},w={};t.forEach((y,b)=>{if(y.rowSpan)for(let g=v;g<j;g++){const x=n[g];if(!x||k[x.id]?.[y.field])continue;const E=y.valueGetter?y.valueGetter({row:x,field:y.field,value:x[y.field]}):x[y.field];let M=1;if(typeof y.rowSpan=="function"){const N={row:x,value:E,field:y.field,colDef:y,rowIndex:g,colIndex:b};M=y.rowSpan(N)}else typeof y.rowSpan=="number"&&(M=y.rowSpan);if(M>1){I[x.id]||(I[x.id]={}),I[x.id][y.field]=M;for(let N=1;N<M;N++){const C=g+N;if(C<j&&n[C]){const P=n[C];k[P.id]||(k[P.id]={}),k[P.id][y.field]=!0,w[C]||(w[C]={}),w[C][y.field]=g}}}}}),d({caches:{spannedCells:I,hiddenCells:k,hiddenCellOriginMap:w},processedRange:{firstRowIndex:v,lastRowIndex:j}})},[n,t]),m=i.useCallback(()=>{d({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}})},[]);i.useEffect(()=>{const v=new Map;n.forEach((w,y)=>{for(let b=0;b<t.length;b++){const g=t[b];if(!g)continue;let x=1;if(g.colSpan)if(typeof g.colSpan=="function"){const M={row:w,value:w[g.field],field:g.field,colDef:g,rowIndex:y,colIndex:b};x=g.colSpan(M)}else x=g.colSpan;if(x<=1){const M=e[g.field]||(typeof g.width=="number"?g.width:100);Ve(v,w.id,g.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:M}});continue}let E=e[g.field]||(typeof g.width=="number"?g.width:100);for(let M=1;M<x;M++)if(b+M<t.length){const N=t[b+M];if(N){const C=e[N.field]||(typeof N.width=="number"?N.width:100);E+=C,Ve(v,w.id,N.field,{spannedByColSpan:!0,leftVisibleCellIndex:b,rightVisibleCellIndex:Math.min(b+x-1,t.length-1)})}}Ve(v,w.id,g.field,{spannedByColSpan:!1,cellProps:{colSpan:x,width:E}}),b+=x-1}}),l(v);const j={},I={},k={};t.forEach((w,y)=>{if(w.rowSpan)for(let b=0;b<n.length;b++){const g=n[b];if(!g||I[g.id]?.[w.field])continue;const x=w.valueGetter?w.valueGetter({row:g,field:w.field,value:g[w.field]}):g[w.field];let E=1;if(typeof w.rowSpan=="function"){const M={row:g,value:x,field:w.field,colDef:w,rowIndex:b,colIndex:y};E=w.rowSpan(M)}else typeof w.rowSpan=="number"&&(E=w.rowSpan);if(E>1){j[g.id]||(j[g.id]={}),j[g.id][w.field]=E;for(let M=1;M<E;M++){const N=b+M;if(N<n.length&&n[N]){const C=n[N];I[C.id]||(I[C.id]={}),I[C.id][w.field]=!0,k[N]||(k[N]={}),k[N][w.field]=b}}}}}),d({caches:{spannedCells:j,hiddenCells:I,hiddenCellOriginMap:k},processedRange:{firstRowIndex:0,lastRowIndex:n.length}})},[n,t,e]);const f=i.useCallback(()=>s.caches.spannedCells,[s]),p=i.useCallback(()=>s.caches.hiddenCells,[s]),_=i.useCallback(()=>s.caches.hiddenCellOriginMap,[s]);return{colspanMap:o,resetColSpan:a,getCellColSpanInfo:u,calculateColSpan:c,rowSpanningState:s,calculateRowSpan:h,resetRowSpan:m,getSpannedCells:f,getHiddenCells:p,getHiddenCellOriginMap:_}}function Ve(n,t,e,o){let l=n.get(t);l||(l={},n.set(t,l)),l[e]=o}function Go(n){const{dataSource:t,sortModel:e,filterModel:o,paginationModel:l,paginationMode:s,sortingMode:d,filterMode:a,aggregationModel:u,setRows:c,setRowCount:h,setDataSourceLoading:m,setDataSourceError:f,onAggregationResults:p}=n,_=i.useRef(null),v=i.useRef(0),j=i.useCallback(async()=>{if(!t)return;const k=++v.current;m(!0),f(null);const w=l.page*l.pageSize,y=w+l.pageSize,b={startRow:w,endRow:y,sortModel:e,filterModel:o,groupKeys:[],aggregationModel:u};try{const g=await t.getRows(b);if(k!==v.current)return;let x=!1;if(s==="infinite"){const E=_.current;if(E){const M=JSON.stringify(E.sortModel)!==JSON.stringify(e),N=JSON.stringify(E.filterModel)!==JSON.stringify(o),C=E.pageSize!==l.pageSize;!M&&!N&&!C&&l.page>E.page&&(x=!0)}}c(x?E=>[...E,...g.rows]:g.rows,!0),g.aggregationResults&&p&&p(g.aggregationResults),g.rowCount!==void 0&&h(g.rowCount),_.current={sortModel:e,filterModel:o,page:l.page,pageSize:l.pageSize}}catch(g){k===v.current&&(f(g),console.error("Data Source Error:",g))}finally{k===v.current&&m(!1)}},[t,l.page,l.pageSize,e,o,s,u,p,c,h,m,f]);i.useEffect(()=>{if(t&&(s==="server"||s==="infinite"||d==="server"||a==="server")){const w=setTimeout(()=>{j()},300);return()=>clearTimeout(w)}},[j,t,s,d,a]);const I=i.useCallback(async(k,w)=>{if(t){m(!0);try{const y=await t.getRows({startRow:0,endRow:-1,sortModel:e,filterModel:o,groupKeys:w});y.rows.length>0&&c(b=>{const g=new Set(b.map(E=>E.id)),x=y.rows.filter(E=>!g.has(E.id));return[...b,...x]})}catch(y){f(y),console.error("Failed to fetch children:",y)}finally{m(!1)}}},[t,e,o,c,m,f]);return{fetchRows:j,fetchChildren:I}}const wn="\0",ct="";function Vo(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 mt(n,t){return t.map(e=>String(n[e]??"")).join(wn)}function Bt(n,t,e,o){return o?`${n}${ct}${t}${ct}${e}`:`${t}${ct}${e}`}function vn(n,t,e,o){return i.useMemo(()=>{const l={pivotRows:[],pivotColumns:[],colKeys:[],isValid:!1};if(!o)return l;const{rowFields:s,columnFields:d,valueFields:a}=e;if(s.length===0||a.length===0)return l;const u=d.length>0,c=new Map(t.map(k=>[k.field,k])),h=new Set;for(const k of n)h.add(mt(k,d));const m=Array.from(h).sort(),f=new Map;for(const k of n){const w=mt(k,s);if(!f.has(w)){const x={};for(const E of s)x[E]=k[E];f.set(w,{labelValues:x,bucket:new Map})}const y=f.get(w),b=mt(k,d);y.bucket.has(b)||y.bucket.set(b,new Map);const g=y.bucket.get(b);for(const x of a){const E=k[x.field];g.has(x.field)||g.set(x.field,[]),E!=null&&!isNaN(Number(E))&&g.get(x.field).push(Number(E))}}let p=0;const _=[];for(const[,k]of f){const w={id:p++,...k.labelValues};for(const y of m){const b=k.bucket.get(y);for(const g of a){const x=Bt(y,g.field,g.aggFn,u),E=b?.get(g.field)??[];w[x]=E.length>0?Vo(E,g.aggFn):null}}_.push(w)}const v=new Map;for(const k of n){const w=mt(k,d);for(const y of a){if(y.aggFn!=="avg"&&y.aggFn!=="min"&&y.aggFn!=="max")continue;const b=`${w}${ct}${y.field}`;v.has(b)||v.set(b,[]);const g=k[y.field];g!=null&&!isNaN(Number(g))&&v.get(b).push(Number(g))}}const j={id:"__pivot_grand_total__"};for(let k=0;k<s.length;k++)j[s[k]]=k===0?"Grand Total":"";for(const k of m)for(const w of a){const y=Bt(k,w.field,w.aggFn,u),b=_.map(x=>x[y]).filter(x=>x!=null&&!isNaN(Number(x))).map(Number);if(b.length===0){j[y]=null;continue}const g=`${k}${ct}${w.field}`;switch(w.aggFn){case"sum":case"count":j[y]=b.reduce((x,E)=>x+E,0);break;case"avg":{const x=v.get(g)??[];j[y]=x.length>0?x.reduce((E,M)=>E+M,0)/x.length:null;break}case"min":j[y]=Math.min(...v.get(g)??b);break;case"max":j[y]=Math.max(...v.get(g)??b);break}}_.push(j);const I=[];for(const k of s){const w=c.get(k);I.push({field:k,headerName:w?.headerName??k,width:w?.width??140,sortable:!0})}for(const k of m){const w=u?k.split(wn).map((y,b)=>{const g=c.get(d[b]);return g?.headerName?`${g.headerName}: ${y}`:y}).join(" / "):"";for(const y of a){const b=c.get(y.field),g=Bt(k,y.field,y.aggFn,u),x=y.headerName??b?.headerName??y.field,E=w?`${w} — ${x} (${y.aggFn})`:`${x} (${y.aggFn})`;I.push({field:g,headerName:E,width:140,type:"number",align:"right",headerAlign:"right",sortable:!0,valueFormatter:({value:M})=>{if(M==null)return"—";const N=Number(M);return y.aggFn==="avg"?N.toFixed(2):y.aggFn==="count"?N.toLocaleString():b?.valueFormatter?b.valueFormatter({value:M,row:{},field:y.field}):N.toLocaleString()}})}}return{pivotRows:_,pivotColumns:I,colKeys:m,isValid:!0}},[n,t,e,o])}function Uo(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 Ko(n){let t=!1;try{t=Uo(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 Yo(n){const{selectedRowIds:t,columns:e,getVisibleRows:o,getRowId:l}=n,s=i.useCallback(async()=>{if(t.size===0)return;const a=o().filter(f=>t.has(l(f)));if(a.length===0)return;const u=e.filter(f=>!f.field.startsWith("__")),c=u.map(f=>f.headerName||f.field).join(" "),h=a.map(f=>u.map(p=>{const _=f[p.field];return p.valueFormatter?p.valueFormatter({value:_,row:f,field:p.field}):_??""}).join(" ")).join(`
7
- `),m=`${c}
8
- ${h}`;try{await Ko(m)}catch(f){console.error("[OpenGridX] Failed to copy to clipboard:",f)}},[t,e,o,l]);return i.useEffect(()=>{const d=a=>{if(!(a.ctrlKey||a.metaKey)||a.key!=="c")return;const u=document.activeElement,c=u?.tagName.toLowerCase(),h=u?.type;c==="input"&&h!=="checkbox"&&h!=="radio"||c==="textarea"||c==="select"||u?.isContentEditable||s()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[s]),{copySelectedRows:s}}function qo({row:n,rowIndex:t,listViewColumn:e,isSelected:o=!1,checkboxSelection:l=!1,rowHeight:s,onRowClick:d,onSelectionChange:a}){const u={row:n,value:void 0,field:e.field,colDef:{field:e.field},rowIndex:t,colIndex:0},c=h=>{h.stopPropagation(),a?.(n.id,h.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:h=>h.stopPropagation(),children:r.jsx("input",{type:"checkbox",checked:o,onChange:c,"aria-label":`Select row ${n.id}`})}),r.jsx("div",{className:"ogx-list-view__cell",role:"gridcell",children:e.renderCell(u)})]})}function Xo({ariaLabel:n,allRenderableRows:t,filteredRows:e,pagination:o,effectivePaginationModel:l,pageSizeOptions:s,selectedRowIds:d,listViewColumn:a,noRowsLabel:u,rowHeight:c,checkboxSelection:h,paginationMode:m,dataSource:f,serverRowCount:p,paginationSlot:_,paginationSlotProps:v,onRowClick:j,onSelectionChange:I,onPaginationModelChange:k}){const w=_||bn,y=m==="server"&&f?p||0:e.length;return r.jsxs("div",{className:"ogx-list-view",role:"grid","aria-label":n||"Data grid list view","aria-rowcount":t.length+1,children:[r.jsx("div",{className:"ogx-list-view__toolbar",children:r.jsxs("span",{children:[e.length," ",e.length===1?"item":"items",o?` · page ${l.page+1} of ${Math.ceil(e.length/l.pageSize)||1}`:"",d.size>0?` · ${d.size} selected`:""]})}),r.jsx("div",{className:"ogx-list-view__rows",children:t.length===0?r.jsxs("div",{className:"ogx-list-view__empty","aria-live":"polite",role:"status",children:[r.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[r.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),r.jsx("path",{d:"M3 9h18M9 21V9"})]}),u]}):t.map((b,g)=>r.jsx(qo,{row:b,rowIndex:g,listViewColumn:a,isSelected:d.has(b.id),checkboxSelection:h,rowHeight:c,onRowClick:x=>j({row:x,id:x.id,rowIndex:g}),onSelectionChange:I},b.id))}),o&&r.jsx(w,{page:l.page,pageSize:l.pageSize,rowCount:y,pageSizeOptions:s,onPageChange:b=>k({...l,page:b}),onPageSizeChange:b=>k({...l,pageSize:b,page:0}),...v})]})}function Jo({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 Qo({value:n,onValueChange:t,onCommit:e,onCancel:o}){const[l,s]=i.useState(typeof n=="number"?n:""),d=i.useRef(null);return i.useEffect(()=>{d.current?.focus(),d.current?.select()},[]),r.jsx("input",{ref:d,type:"number",className:"ogx__edit-input ogx__edit-input--number",value:l,onChange:a=>{const u=a.target.value===""?"":Number(a.target.value);s(u),t(u===""?null:u)},onBlur:e,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),e()),a.key==="Escape"&&(a.stopPropagation(),o())}})}function Zo({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 er({value:n,colDef:t,onValueChange:e,onCommit:o,onCancel:l}){const s=i.useRef(null);i.useEffect(()=>{s.current?.focus()},[]);const d=t.valueOptions??[];return r.jsx("select",{ref:s,className:"ogx__edit-select",value:String(n??""),onChange:a=>{e(a.target.value)},onBlur:o,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),o()),a.key==="Escape"&&(a.stopPropagation(),l())},children:d.map(a=>{const u=typeof a=="object"?a.value:a,c=typeof a=="object"?a.label:String(a);return r.jsx("option",{value:String(u),children:c},String(u))})})}function tr({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 nr(n){const{colDef:t}=n;switch(t.type){case"number":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(Qo,{...n})});case"boolean":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(Zo,{...n})});case"singleSelect":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(er,{...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(Jo,{...n})})}}function or(n){const{onCellClick:t,onCellEditStart:e,onCellValueChange:o,value:l,row:s,colDef:d,rowIndex:a,colIndex:u,isSelected:c,onClick:h,width:m,pinnedPosition:f,pinnedOffset:p,isFocused:_,isFocusVisible:v,isEditable:j,isEditing:I,onEditStart:k,onEditStop:w,onValueChange:y,colSpanInfo:b,rowSpan:g,isHiddenByRowSpan:x}=n,E=i.useCallback(S=>{o?o(d.field,S):y?.(S)},[o,y,d.field]),M=i.useMemo(()=>d.valueFormatter?d.valueFormatter({value:l,row:s,field:d.field}):l==null?"":String(l),[l,s,d]),N=i.useMemo(()=>I&&(o||y)&&w?d.renderEditCell?d.renderEditCell({value:l,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:u}):r.jsx(nr,{value:l,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:u,onValueChange:E,onCommit:()=>w(),onCancel:()=>w(!0)}):d.renderCell?d.renderCell({value:l,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:u}):M,[l,s,d,a,u,M,I,E,w,o,y]),C=i.useMemo(()=>d.cellClassName?typeof d.cellClassName=="function"?d.cellClassName({value:l,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:u})||"":d.cellClassName:"",[d,l,s,a,u]),P=i.useRef(null);if(i.useLayoutEffect(()=>{_&&P.current&&P.current.focus({preventScroll:!0})},[_]),b?.spannedByColSpan)return null;if(x)return r.jsx("div",{className:"ogx__cell ogx__cell--hidden",style:{width:m??d.width??100},role:"presentation","data-field":d.field,"data-colindex":u});const O=S=>{t&&t({row:s,field:d.field,value:l,colDef:d,rowIndex:a,colIndex:u}),h?.(S)},T=S=>{j&&(k||e)&&(S.stopPropagation(),e?e(d.field,l):k?.())},F=f!=null,H=["ogx__cell",`ogx__cell--align-${d.align||"left"}`,c&&"ogx__cell--selected",_&&"ogx__cell--focused",_&&v&&"ogx__cell--focus-visible",d.type&&`ogx__cell--type-${d.type}`,F&&"ogx__cell--pinned",F&&`ogx__cell--pinned-${f}`,I&&"ogx__cell--editing",g&&g>1&&"ogx__cell--spanned",C].filter(Boolean).join(" "),L=b?.cellProps?.colSpan||1,D=g||1,K=b?.cellProps?.width??m??d.width??100,G={width:"var(--width)","--width":typeof K=="number"?`${K}px`:K,flexGrow:d.flex??0,flexShrink:0,flexBasis:(d.flex,"auto"),boxSizing:"border-box",minWidth:d.minWidth,maxWidth:d.maxWidth,position:F?"sticky":void 0,zIndex:d.zIndex??(F?3:void 0),padding:I?0:void 0};return D>1&&(G.height=`calc(var(--height) * ${D} - var(--border-width, 1px))`,G.zIndex=10,F&&(G.zIndex=40)),F&&p!==void 0&&(f==="left"?G.left=p:G.right=p),r.jsx("div",{ref:P,className:H,style:G,onClick:O,onDoubleClick:T,role:"gridcell","aria-colindex":u+1,"aria-readonly":!j||void 0,tabIndex:-1,"data-field":d.field,"data-colindex":u,...L>1?{"aria-colspan":L}:{},...D>1?{"aria-rowspan":D}:{},children:r.jsx("div",{className:"ogx__cell-content",children:N})})}const _n=i.memo(or),rr=({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 ir(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 bt(n){const{row:t,columns:e,rowIndex:o,isSelected:l=!1,checkboxSelection:s=!1,onRowClick:d,onCellClick:a,onSelectionChange:u,columnWidths:c={},pinnedColumns:h,pinnedRows:m,hasDetailPanel:f=!1,isDetailPanelExpanded:p=!1,onDetailPanelToggle:_,detailPanelContent:v,detailPanelHeight:j=200,pinCheckboxColumn:I=!0,pinExpandColumn:k=!0,rowReordering:w=!1,onDragStart:y,onDragOver:b,onDragEnd:g,onDrop:x,isDragging:E,isDragOver:M,editingCell:N,onEditStart:C,onEditStop:P,onEditCellValueChange:O,focusedCellField:T,isFocusVisible:F,colspanMap:H,rowSpanningCaches:L,rowHeight:D=52}=n,K=i.useId(),G=i.useRef(null),S=i.useRef(null);i.useLayoutEffect(()=>{T==="__expand_col__"&&G.current&&G.current.focus({preventScroll:!0}),T==="__checkbox_col__"&&S.current&&S.current.focus({preventScroll:!0})},[T]);const B=i.useMemo(()=>Ot(e,c,h,s,I,f,k,w),[e,c,h,s,I,f,k,w]),W=t._hasChildren===!0,A=i.useCallback((Y,q)=>{W||C?.({id:t.id,field:Y,value:q})},[W,t.id,C]),$=i.useCallback((Y,q)=>{O?.({id:t.id,field:Y,value:q})},[O,t.id]),X=i.useCallback(Y=>{P?.({cancel:Y})},[P]);if(t._isSkeleton){const Y=Math.max(e.length,5);return r.jsx("div",{className:"ogx__row ogx__row--skeleton",role:"row","aria-hidden":"true",style:{height:D,minHeight:D},children:Array.from({length:Y}).map((q,se)=>r.jsx("div",{className:"ogx__skeleton-cell",children:r.jsx("div",{className:"ogx__skeleton-bar"})},se))})}const U=Y=>{Y.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell")||d?.({row:t,id:t.id,rowIndex:o})},oe=Y=>{Y.stopPropagation(),u?.(t.id,Y.target.checked)},R=Y=>{Y.stopPropagation(),_?.(t.id)},Q=Ft(t.id,m),Z=Q==="top",le=Q==="bottom",re=["ogx__row",l&&"ogx__row--selected",o%2===0&&"ogx__row--even",o%2===1&&"ogx__row--odd",Z&&"ogx__row--pinned-top",le&&"ogx__row--pinned-bottom",E&&"ogx__row--dragging",M&&"ogx__row--drag-over",W&&"ogx__row--group"].filter(Boolean).join(" ");return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:re,onClick:U,role:"row","aria-rowindex":o+1,"aria-selected":l,"data-rowindex":o,onDragOver:b?b(t.id):void 0,onDrop:x?x(t.id):void 0,style:{maxHeight:`${D}px`,minHeight:`${D}px`,"--height":`${D}px`,"--border-width":"1px"},children:[w&&r.jsx("div",{className:"ogx__cell ogx__cell--drag-handle",role:"gridcell","aria-label":"Drag to reorder row",style:{position:"sticky",left:0,zIndex:4},draggable:!0,onDragStart:y?y(t.id):void 0,onDragEnd:g,onClick:Y=>Y.stopPropagation(),children:r.jsx(rr,{})}),f&&r.jsx("div",{className:`ogx__cell ogx__cell--expand ${k?"ogx__cell--pinned-left":""} ${T==="__expand_col__"?"ogx__cell--focused":""} ${T==="__expand_col__"&&F?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":p?"Collapse row details":"Expand row details","aria-expanded":p,style:{position:k?"sticky":void 0,left:k?w?48:0:void 0,zIndex:k?5:void 0},ref:G,tabIndex:-1,onClick:Y=>{Y.stopPropagation(),a?.({row:t,field:"__expand_col__",value:p,colDef:{field:"__expand_col__",width:48},rowIndex:o,colIndex:-1})},children:r.jsx(hn,{isExpanded:p,onClick:R,variant:"plus-minus"})}),s&&r.jsx("div",{className:`ogx__cell ogx__cell--checkbox ${I?"ogx__cell--pinned-left":""} ${T==="__checkbox_col__"?"ogx__cell--focused":""} ${T==="__checkbox_col__"&&F?"ogx__cell--focus-visible":""}`,role:"gridcell",style:{position:I?"sticky":void 0,left:I?(w?48:0)+(f&&k?48:0):void 0,zIndex:I?11:void 0},ref:S,tabIndex:-1,onClick:Y=>{Y.stopPropagation(),a?.({row:t,field:"__checkbox_col__",value:l,colDef:{field:"__checkbox_col__",width:48},rowIndex:o,colIndex:-1})},children:r.jsx(at,{id:K,name:`ogx-select-row-${t.id}`,checked:l,onChange:oe,onClick:Y=>Y.stopPropagation(),"aria-label":l?`Deselect row ${t.id}`:`Select row ${t.id}`,tabIndex:-1,onMouseDown:Y=>Y.preventDefault()})}),e.map((Y,q)=>{if(Y.isSpacer)return r.jsx("div",{style:{width:Y.width,minWidth:Y.width,flexShrink:0},"aria-hidden":"true"},Y.field);const se=Y.valueGetter?Y.valueGetter({row:t,field:Y.field,value:t[Y.field]}):t[Y.field],ae=c[Y.field]??Y.width,z=st(Y.field,h),J=z?B[Y.field]:void 0,te=N?.id===t.id&&N?.field===Y.field,ce=te?N?.value:se,ue=H?.get(t.id)?.[Y.field],je=L?.spannedCells[t.id]?.[Y.field],Re=L?.hiddenCells[t.id]?.[Y.field]||!1;return r.jsx(_n,{value:ce,row:t,colDef:Y,rowIndex:o,colIndex:q,isSelected:l,onCellClick:a,width:ae,pinnedPosition:z,pinnedOffset:J,isFocused:T===Y.field,isFocusVisible:F,isEditable:Y.editable,isEditing:te,onCellEditStart:A,onEditStop:X,onCellValueChange:$,colSpanInfo:ue,rowSpan:je,isHiddenByRowSpan:Re},Y.field)})]}),f&&r.jsx(ir,{row:t,rowId:t.id,rowIndex:o,content:v,height:j,isExpanded:p})]})}function Cn({rows:n,position:t,columns:e,selectedRowIds:o,checkboxSelection:l,onRowClick:s,onCellClick:d,onSelectionChange:a,columnWidths:u,pinnedColumns:c,pinnedRows:h,hasDetailPanel:m,expandedRowIds:f,getDetailPanelContent:p,getDetailPanelHeight:_,onDetailPanelToggle:v,pinCheckboxColumn:j,pinExpandColumn:I,focusedCell:k,colspanMap:w,rowSpanningCaches:y,rowHeight:b}){return n.length===0?null:r.jsx("div",{className:`ogx__pinned-rows ogx__pinned-rows--${t}`,role:"rowgroup",children:n.map((g,x)=>r.jsx(bt,{row:g,columns:e,rowIndex:x,isSelected:o.has(g.id),checkboxSelection:l,onRowClick:s,onCellClick:d,onSelectionChange:a,columnWidths:u,pinnedColumns:c,pinnedRows:h,hasDetailPanel:m,isDetailPanelExpanded:f.has(g.id),detailPanelContent:p?p({row:g,id:g.id,rowIndex:x}):null,detailPanelHeight:_?.({row:g,id:g.id,rowIndex:x})||200,onDetailPanelToggle:v,pinCheckboxColumn:j,pinExpandColumn:I,focusedCellField:k?.id===g.id?k.field:null,colspanMap:w,rowSpanningCaches:y,rowHeight:b},g.id))})}const lr=({columns:n,rowHeight:t,checkboxSelection:e=!1,hasDetailPanel:o=!1,rowReordering:l=!1})=>r.jsxs("div",{className:"ogx__row ogx__skeleton-row",style:{height:t},role:"row",children:[e&&r.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:r.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),o&&r.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:r.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),l&&r.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:r.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),n.map((s,d)=>{const a=typeof s.width=="number"?s.width:150,u=Math.min(a*.7,a-20);return r.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:a,minWidth:s.minWidth,maxWidth:s.maxWidth,left:s.left,right:s.right,position:s.isSpacer?"relative":s.pinned?"sticky":"relative",zIndex:s.zIndex},children:!s.isSpacer&&r.jsx("div",{className:"ogx-skeleton-box",style:{width:u,height:16,borderRadius:4}})},s.field||d)})]});function sr({virtualContainerHeight:n,offsetTop:t,effectiveLoading:e,visibleRows:o,baseColumns:l,virtualColumns:s,viewportWidth:d,checkboxSelection:a,hasDetailPanel:u,rowReordering:c,rowHeight:h,pinnedRows:m,selectedRowIds:f,onRowClick:p,onCellClick:_,onSelectionChange:v,columnWidths:j,pinnedColumns:I,expandedRowIds:k,getDetailPanelContent:w,getDetailPanelHeight:y,onDetailPanelToggle:b,pinCheckboxColumn:g,pinExpandColumn:x,rowReorderHandlers:E,editingHandlers:M,focusedCell:N,colspanMap:C,rowSpanningCaches:P,paginationMode:O,dataSourceLoading:T,sortedUnpinnedRowCount:F,infiniteScrollSkeletonCount:H,unpinnedRowsLength:L}){const D=l.length>0?l:(()=>{const G=(d||1e3)-(a?48:0)-(u?48:0)-(c?48:0),S=150,B=Math.max(1,Math.ceil(G/S));return Array.from({length:B},(W,A)=>({field:`placeholder_${A}`,headerName:"",width:S}))})(),K=o.filter(({row:G})=>!Ft(G.id,m)).filter((G,S,B)=>S===B.findIndex(W=>W.row.id===G.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((G,S)=>r.jsx(lr,{columns:D,rowHeight:h,checkboxSelection:a,hasDetailPanel:u,rowReordering:c},`skeleton-${S}`)):K.map(({row:G,rowIndex:S})=>r.jsx(bt,{row:G,columns:s,rowIndex:S,isSelected:f.has(G.id),checkboxSelection:a,onRowClick:p,onCellClick:_,onSelectionChange:v,columnWidths:j,pinnedColumns:I,pinnedRows:m,hasDetailPanel:u,isDetailPanelExpanded:k.has(G.id),detailPanelContent:w?w({row:G,id:G.id,rowIndex:S}):null,detailPanelHeight:y?.({row:G,id:G.id,rowIndex:S})||200,onDetailPanelToggle:b,pinCheckboxColumn:g,pinExpandColumn:x,rowReordering:c,onDragStart:E.onDragStart,onDragOver:E.onDragOver,onDragEnd:E.onDragEnd,onDrop:E.onDrop,isDragging:E.draggedRowId===G.id,isDragOver:E.dragOverRowId===G.id,editingCell:M.editingCell,onEditStart:M.startCellEdit,onEditStop:M.stopCellEdit,onEditCellValueChange:M.setEditCellValue,focusedCellField:N!=null&&N.id===G.id?N.field:null,colspanMap:C,rowSpanningCaches:P,rowHeight:h},G.id)),O==="infinite"&&T&&F>0&&r.jsx("div",{className:"ogx__skeleton-group",children:Array.from({length:H}).map((G,S)=>r.jsx(bt,{row:{id:`__skeleton_${S}__`,_isSkeleton:!0},columns:s,rowIndex:L+S,rowHeight:h},`__skeleton_${S}__`))})]})})}function ar(){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 yn(n){const{columns:t,visibleColumns:e,onVisibilityChange:o,onShowAll:l,onHideAll:s,onColumnReorder:d,onColumnOrderReset:a}=n,[u,c]=i.useState(""),[h,m]=i.useState(null),f=i.useRef(null),_=i.useMemo(()=>t.filter(g=>g.hideable!==!1),[t]).every(g=>e.has(g.field)),v=i.useMemo(()=>{if(!u)return t;const g=u.toLowerCase();return t.filter(x=>(x.headerName||x.field).toLowerCase().includes(g))},[t,u]),j=g=>{g.target.checked?l():s()},I=g=>x=>{f.current=g,x.dataTransfer.effectAllowed="move",x.dataTransfer.setDragImage(x.currentTarget.closest(".ogx-column-visibility-panel__item"),20,20)},k=g=>x=>{x.preventDefault(),x.dataTransfer.dropEffect="move",g!==f.current&&m(g)},w=()=>{m(null)},y=g=>x=>{x.preventDefault();const E=f.current;m(null),f.current=null,E&&E!==g&&d&&d(E,g)},b=()=>{m(null),f.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(ar,{}),r.jsx("input",{autoComplete:"off",className:"ogx-column-visibility-panel__search-input",placeholder:"Search",value:u,onChange:g=>c(g.target.value)})]})}),r.jsx("div",{className:"ogx-column-visibility-panel__list",children:v.map(g=>{const x=e.has(g.field),E=g.hideable!==!1,M=h===g.field,N=!!d&&!u;return r.jsxs("div",{className:["ogx-column-visibility-panel__item",!E&&"ogx-column-visibility-panel__item--disabled",M&&"ogx-column-visibility-panel__item--drag-over"].filter(Boolean).join(" "),draggable:N,onDragOver:N?k(g.field):void 0,onDragLeave:N?w:void 0,onDrop:N?y(g.field):void 0,onDragEnd:N?b:void 0,children:[N&&r.jsx("span",{className:"ogx-column-visibility-panel__drag-handle-wrapper",draggable:!0,onDragStart:I(g.field),title:"Drag to reorder",children:r.jsx(dr,{})}),r.jsxs("label",{className:"ogx-column-visibility-panel__item-label",style:{display:"flex",alignItems:"center",gap:"var(--ogx-spacing-md)",flex:1,cursor:E?"pointer":"not-allowed"},children:[r.jsx(at,{checked:x,onChange:C=>o(g.field,C.target.checked),disabled:!E}),r.jsx("span",{className:"ogx-column-visibility-panel__label",children:g.headerName||g.field})]})]},g.field)})}),r.jsxs("div",{className:"ogx-column-visibility-panel__footer",children:[r.jsxs("label",{className:"ogx-column-visibility-panel__item",children:[r.jsx(at,{checked:_,onChange:j}),r.jsx("span",{className:"ogx-column-visibility-panel__label",children:"Show/Hide All"})]}),r.jsx("button",{className:"ogx-column-visibility-panel__reset-btn",onClick:()=>{l(),a?.()},children:"Reset"})]})]})}function cr({isOpen:n,containerRef:t,panelRef:e,effectiveColumns:o,columnVisibilityModel:l,effectiveColumnOrder:s,columnOrder:d,disableColumnReorder:a,onClose:u,onColumnVisibilityChange:c,onColumnOrderChange:h,setInternalColumnOrder:m}){const[f,p]=i.useState(16),[_,v]=i.useState(16),[j,I]=i.useState(()=>document.body);if(i.useLayoutEffect(()=>{if(!n||!t.current)return;const w=t.current.getBoundingClientRect();p(w.top+8),v(window.innerWidth-w.right+8),I(t.current.closest(".ogx-theme-provider")||document.body)},[n,t]),!n)return null;const k=a?void 0:(w,y)=>{const b=[...s],g=b.indexOf(w),x=b.indexOf(y);if(g===-1||x===-1)return;const E=[...b];E.splice(g,1),E.splice(x,0,w),d||m(E),h?.({oldIndex:g,targetIndex:x,column:o.find(M=>M.field===w)})};return Ae.createPortal(r.jsxs("div",{ref:e,style:{position:"fixed",top:f,right:_,zIndex:9999,display:"inline-block"},children:[r.jsx("button",{onClick:u,style:{position:"absolute",top:-12,right:-12,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",background:"#334155",color:"#fff",border:"none",borderRadius:"50%",cursor:"pointer",fontSize:14,lineHeight:1,zIndex:1,boxShadow:"0 1px 4px rgba(0,0,0,0.2)"},"aria-label":"Close",children:"×"}),r.jsx(yn,{columns:o,visibleColumns:new Set(o.filter(w=>l[w.field]!==!1).map(w=>w.field)),onVisibilityChange:(w,y)=>{c({...l,[w]:y})},onShowAll:()=>{const w={...l};o.forEach(y=>{y.hideable!==!1&&(w[y.field]=!0)}),c(w)},onHideAll:()=>{const w={...l};o.forEach(y=>{y.hideable!==!1&&(w[y.field]=!1)}),c(w)},onColumnReorder:k})]}),j)}function ur(n){const{rows:t,columns:e,getRowId:o,rowHeight:l=52,headerHeight:s=56,autoHeight:d=!1,checkboxSelection:a=!1,rowSelectionModel:u,onRowSelectionModelChange:c,onRowClick:h,onCellClick:m,filterModel:f,onFilterModelChange:p,sortModel:_,onSortModelChange:v,pagination:j=!1,paginationModel:I={page:0,pageSize:100},onPaginationModelChange:k,pageSizeOptions:w=[10,25,50,100],pinnedColumns:y,onPinnedColumnsChange:b,pinnedRows:g,getDetailPanelContent:x,getDetailPanelHeight:E,detailPanelExpandedRowIds:M,onDetailPanelExpandedRowIdsChange:N,pinCheckboxColumn:C=!0,pinExpandColumn:P=!0,disableColumnReorder:O=!1,columnOrder:T,onColumnOrderChange:F,height:H,rowReordering:L=!1,onRowOrderChange:D,loading:K=!1,treeData:G=!1,getTreeDataPath:S,defaultGroupingExpansionDepth:B,rowGroupingModel:W,aggregationModel:A,onAggregationModelChange:$,getAggregationPosition:X,isCellEditable:U,processRowUpdate:oe,onProcessRowUpdateError:R,dataSource:Q,sortingMode:Z="client",filterMode:le="client",paginationMode:re="client",rowCount:Y,slots:q,slotProps:se,pivotMode:ae=!1,pivotModel:z,onPivotModelChange:J,className:te="",style:ce,onRowsScrollEnd:ue,ariaLabel:je,initialState:Re,onStateChange:We,columnVisibilityModel:ge,onColumnVisibilityModelChange:Ke,listView:ne=!1,listViewColumn:we,columnGroupingModel:ze,noRowsLabel:Ht="No Data",apiRef:Dt}=n,Jr=i.useMemo(()=>({items:[]}),[]),ke=f||Jr,Qr=i.useMemo(()=>[],[]),Gt=W||Qr,In=i.useRef(q?.toolbar);In.current=q?.toolbar;const Zr=i.useRef(V=>{const ee=In.current;return ee?ee(V):null}).current,ei=no({initialState:Re,sortModel:_,aggregationModel:A,onAggregationModelChange:$,columnVisibilityModel:ge,onColumnVisibilityModelChange:Ke,pinnedColumns:y,onPinnedColumnsChange:b,pivotModel:z,onPivotModelChange:J,paginationModel:I,onPaginationModelChange:k,rowSelectionModel:u}),{sortModel:Oe,isSortControlled:Pn,setInternalSortModel:Tn,aggregationModel:Se,handleAggregationModelChange:Ln,columnVisibilityModel:Be,handleColumnVisibilityModelChange:wt,pinnedColumns:Ne,handlePinnedColumnsChange:Vt,currentPivotModel:Ut,handlePivotModelChange:Rn,effectivePaginationModel:Ce,handlePaginationModelChange:Kt,selectedRowIds:ve,isSelectionControlled:vt,setInternalRowSelectionModel:_t}=ei,Ct=c,yt=vn(t,e,Ut,ae),Wn=ae&&yt.isValid?yt.pivotRows:t,Yt=ae&&yt.isValid?yt.pivotColumns:e,[ti,On]=i.useState(null);i.useEffect(()=>{On(null)},[Se]);const Ye=i.useRef(null),ni=i.useRef(null),kt=i.useRef(null),oi=i.useCallback(V=>V.id,[]),qe=o||oi,qt=i.useMemo(()=>Wn.map(V=>{const ee=qe(V);return ee===V.id?V:{...V,id:ee}}),[Wn,qe]),Xe=i.useCallback(V=>{dn.current?.classList.toggle("ogx--kb",V)},[]),Fn=i.useRef(Q);Fn.current=Q;const An=i.useRef(null),zn=i.useRef(null),ri=i.useCallback(V=>{if(Fn.current&&G&&(V.serverChildrenCount??0)>0&&(V.children??[]).length===0){const ee=zn.current?.getNodePath(V.id)||[V.groupingKey];An.current?.(V.id,ee)}},[G]),_e=Fo({rows:qt,columns:Yt,rowHeight:l,headerHeight:s,rowCount:Y,columnVisibilityModel:Be,initialState:n.initialState}),{state:fe,apiRef:Je,setRows:Xt,setColumns:ii,setDimensions:Bn,setDataSourceLoading:li,setDataSourceError:si,setRowCount:ai}=_e,{scrollTop:di,scrollLeft:ci,handleScroll:ui}=po({onRowsScrollEnd:ue});i.useEffect(()=>{Dt&&(Dt.current=Je.current)},[Dt,Je]);const{copySelectedRows:$n}=Yo({selectedRowIds:ve,columns:Yt,getVisibleRows:()=>Je.current.getVisibleRows(),getRowId:qe});i.useEffect(()=>{Je.current.copySelectedRows=$n,Je.current.getSelectedRows=()=>Array.from(ve)},[$n,ve,Je]);const fi=fe.dataSource.loading,ft=K||fi,Qe=i.useMemo(()=>fe.rows.allRows.map(V=>fe.rows.idRowsLookup.get(V)),[fe.rows]),Jt=zo({rows:Qe,getRowId:qe,getTreeDataPath:S,treeData:G,defaultGroupingExpansionDepth:B,filterModel:ke,sortModel:Oe,onRowExpansionChange:ri});i.useEffect(()=>{zn.current=Jt},[Jt]);const gi=$o({rows:Qe,getRowId:qe,rowGroupingModel:Gt,aggregationModel:Se,defaultGroupingExpansionDepth:B,filterModel:ke,sortModel:Oe,getAggregationPosition:X}),Ze=Ho({rows:Qe,getRowId:qe,processRowUpdate:oe,onProcessRowUpdateError:R,onRowChange:V=>{const{dispatch:ee}=_e,xe=Array.from(_e.state.rows.idRowsLookup.values()).map(pe=>pe.id===V.id?V:pe);ee({type:"SET_ROWS",payload:xe})}}),Qt=G,St=!!(Gt&&Gt.length>0),Zt=Qt||St,jt=Qt?Jt:St?gi:null,Me=j&&!St,Et=i.useCallback(V=>{const{row:ee,id:de}=V;if(Zt&&ee._hasChildren){jt?.toggleExpansion(de);return}h?.(V)},[Zt,jt,h]),en=Go({dataSource:Q,sortModel:Oe,filterModel:ke,paginationModel:Ce,paginationMode:re,sortingMode:Z,filterMode:le,aggregationModel:Se,setRows:Xt,setRowCount:ai,setDataSourceLoading:li,setDataSourceError:si,onAggregationResults:On});i.useEffect(()=>{en.fetchChildren&&(An.current=en.fetchChildren)},[en.fetchChildren]),i.useEffect(()=>{Q||Xt(qt)},[qt,Xt,Q]);const Ie=!!x,[hi,pi]=i.useState(new Set),et=M??hi,Nt=i.useCallback(V=>{const ee=new Set(et);ee.has(V)?ee.delete(V):ee.add(V),M===void 0&&pi(ee),N?.(ee)},[et,M,N]),{effectiveColumns:Fe,orderedColumns:tn,visibleOrderedColumns:xi,navigationColumns:Hn,columnWidths:Pe,effectiveColumnOrder:Mt,setInternalColumnOrder:It,columnReorderHandlers:tt,handleColumnResize:mi}=go({activeColumns:Yt,isHierarchyEnabled:Zt,isRowGrouping:St,isTreeData:Qt,activeHierarchyHandlers:jt,columnVisibilityModel:Be,columnOrder:T,onColumnOrderChange:F,disableColumnReorder:O,pivotMode:ae,checkboxSelection:a,hasDetailPanel:Ie,rowReordering:L,initialState:Re,setColumns:ii});xo({onStateChange:We,sortModel:Oe,filterModel:ke,effectivePaginationModel:Ce,columnWidths:Pe,effectiveColumnOrder:Mt,columnVisibilityModel:Be,pinnedColumns:Ne});const nt=co({effectiveRows:Qe,activeHierarchyHandlers:jt,filterMode:le,filterModel:ke,dataSource:Q,sortModel:Oe,sortingMode:Z,pagination:Me,paginationMode:re,effectivePaginationModel:Ce,pinnedRows:g,isLoading:fe.dataSource.loading,pageSize:Ce.pageSize}),$e=nt.filteredRows,nn=nt.pinnedTopRows,on=nt.pinnedBottomRows,ot=nt.sortedUnpinnedRows,gt=nt.paginatedUnpinnedRows,rn=nt.allRenderableRows;i.useEffect(()=>{_e.apiRef.current.getVisibleRows=()=>Me?gt:ot,_e.apiRef.current.getVisibleColumns=()=>Fe},[ot,gt,Me,Fe,_e.apiRef]);const bi=Ao({rows:Me?gt:ot,getRowId:V=>V.id,onRowOrderChange:D,rowReordering:L}),rt=Do(rn,Hn,Pe),{aggregationResult:ln}=pn({rows:$e,aggregationModel:Se,isServerSide:!!(Q&&(re==="server"||Z==="server")),dataSource:Q,filterModel:ke,sortModel:Oe,serverAggregationResults:ti}),Pt=Object.keys(Se).length>0;i.useEffect(()=>{_e.apiRef.current.getAggregationResult=()=>Pt?ln:null,_e.apiRef.current.getAggregationModel=()=>Pt?Se:null},[ln,Se,Pt,_e.apiRef]);const he=Zn({rowHeight:l,pagination:Me,paginatedUnpinnedRows:gt,sortedUnpinnedRows:ot,expandedRowIds:et,getDetailPanelHeight:E,pinnedTopRowsLength:nn.length,pinnedBottomRowsLength:on.length,visibleOrderedColumns:xi,pinnedColumns:Ne,columnWidths:Pe,viewportWidth:fe.dimensions.viewportWidth||1e3,checkboxSelection:a,hasDetailPanel:Ie,rowReordering:L,paginationMode:re,isLoading:fe.dataSource.loading,pageSize:Ce.pageSize}),wi=i.useMemo(()=>{const V={};for(const ee of[...he.leftPinnedCols,...he.unpinnedColsWithWidth,...he.rightPinnedCols])ee.isSpacer||(V[ee.field]=ee.width);return{...V,...Pe}},[he.leftPinnedCols,he.unpinnedColsWithWidth,he.rightPinnedCols,Pe]);i.useEffect(()=>{_e.apiRef.current.scrollToIndexes=({rowIndex:V,colIndex:ee})=>{const de=Ye.current;if(de){if(V!==void 0&&V>=0){const xe=V>0?he.cumulativeHeights[V-1]:0,pe=he.cumulativeHeights[V]??xe,{scrollTop:me,clientHeight:be}=de;xe<me?de.scrollTop=xe:pe>me+be&&(de.scrollTop=pe-be)}if(ee!==void 0&&ee>=0){const pe=[...he.leftPinnedCols,...he.unpinnedColsWithWidth,...he.rightPinnedCols][ee];if(!pe)return;const me=he.unpinnedColsWithWidth.findIndex(Ni=>Ni.field===pe.field);if(me===-1)return;const be=me>0?he.unpinnedAccWidths[me-1]:0,Rt=he.unpinnedAccWidths[me]??be,Wt=he.leftWidth+Rt,{scrollLeft:Un,clientWidth:Kn}=de;be<Un?de.scrollLeft=be:Wt>Un+Kn&&(de.scrollLeft=Wt-Kn)}}}},[he,Ye,_e.apiRef]);const ye=uo({layout:he,scrollTop:di,scrollLeft:ci,viewportWidth:fe.dimensions.viewportWidth,viewportHeight:fe.dimensions.viewportHeight,autoHeight:d,rowReordering:L,hasDetailPanel:Ie,checkboxSelection:a,pinCheckboxColumn:C,pinExpandColumn:P});i.useEffect(()=>{if(!Ye.current)return;const V=new ResizeObserver(ee=>{for(const de of ee){const{width:xe,height:pe}=de.contentRect;Bn(xe,pe)}});return V.observe(Ye.current),()=>{V.disconnect()}},[Bn]);const ht=i.useCallback((V,ee)=>{const de=new Set(ve);ee?de.add(V):de.delete(V);const xe=Array.from(de);vt||_t(xe),Ct?.(xe)},[ve,vt,Ct,_t]),vi=i.useCallback(V=>{let ee=[];V&&(ee=Qe.map(de=>de.id)),vt||_t(ee),Ct?.(ee)},[Qe,vt,Ct,_t]),Dn=i.useCallback((V,ee)=>{const de=ee?[{field:V,sort:ee}]:[];Pn||Tn(de),v?.(de)},[Pn,v,Tn]),{focusedCell:Tt,setFocusedCell:sn,handleFocus:_i,handleBlur:Ci,handleKeyDown:yi}=eo({allRenderableRows:rn,navigationColumns:Hn,checkboxSelection:a,selectedRowIds:ve,handleSelectionChange:ht,handleDetailPanelToggle:Nt,editingHandlers:Ze,setKeyboardMode:Xe,sortModel:Oe,handleSort:Dn,isCellEditable:U,pagination:Me,pageSize:Ce.pageSize,virtualization:ye,viewportRef:Ye}),an=i.useCallback(V=>{Xe(!1),sn({id:V.row.id,field:V.field}),kt.current?.focus({preventScroll:!0}),m?.(V)},[m,Xe,sn]),Gn=i.useRef(Ze.editingCell);i.useEffect(()=>{const V=!!Gn.current,ee=!!Ze.editingCell;V&&!ee&&kt.current?.focus({preventScroll:!0}),Gn.current=Ze.editingCell},[Ze.editingCell]);const ki=ho({renderContext:ye.renderContext,pinnedTopRows:nn,pinnedBottomRows:on,paginatedUnpinnedRows:gt,sortedUnpinnedRows:ot,pagination:Me}),Si=t.length>0&&ve.size===t.length,ji=ve.size>0&&ve.size<t.length,Ei=i.useMemo(()=>Fe.some(V=>!!V.rowSpan),[Fe]),[pt,Lt]=i.useState(!1),dn=i.useRef(null),cn=i.useRef(null),Vn=i.useMemo(()=>{if(!q?.toolbar)return null;const V=O?void 0:(ee,de)=>{const xe=[...Mt],pe=xe.indexOf(ee),me=xe.indexOf(de);if(pe===-1||me===-1)return;const be=[...xe];be.splice(pe,1),be.splice(me,0,ee),T||It(be);const Rt=Fe.find(Wt=>Wt.field===ee);Rt&&F?.({oldIndex:pe,targetIndex:me,column:Rt})};return{apiRef:_e.apiRef,columns:tn,baseColumns:e,aggregationModel:Se,onAggregationModelChange:Ln,...ae||z||J?{pivotModel:Ut,onPivotModelChange:Rn}:{},filterModel:ke,onFilterModelChange:p,columnVisibilityModel:Be,onColumnVisibilityModelChange:wt,onColumnReorder:V,onColumnOrderReset:O?void 0:()=>It(e.map(ee=>ee.field)),forceColumnsOpen:pt,onColumnsPanelClose:()=>Lt(!1),...se?.toolbar}},[q?.toolbar,O,Mt,tn,Fe,T,F,It,_e.apiRef,e,Se,Ln,ae,z,J,Ut,Rn,ke,p,Be,wt,pt,se?.toolbar]);return i.useEffect(()=>{if(!pt||q?.toolbar)return;function V(ee){cn.current&&!cn.current.contains(ee.target)&&Lt(!1)}return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[pt,q?.toolbar]),r.jsxs("div",{ref:dn,className:["ogx",te,d&&"ogx--auto-height",Ei&&"ogx--row-spanning",ne&&"ogx--list-view"].filter(Boolean).join(" "),style:{...ce,height:H??ce?.height,"--ogx-row-height":`${l}px`,"--ogx-header-height":`${s}px`},"aria-busy":ft,children:[Vn&&r.jsx(Zr,{...Vn}),!q?.toolbar&&r.jsx(cr,{isOpen:pt,containerRef:dn,panelRef:cn,effectiveColumns:Fe,columnVisibilityModel:Be,effectiveColumnOrder:Mt,columnOrder:T,disableColumnReorder:O,onClose:()=>Lt(!1),onColumnVisibilityChange:wt,onColumnOrderChange:F,setInternalColumnOrder:It}),ne&&we&&r.jsx(Xo,{ariaLabel:je,allRenderableRows:rn,filteredRows:$e,pagination:Me,effectivePaginationModel:Ce,pageSizeOptions:w,selectedRowIds:ve,listViewColumn:we,noRowsLabel:Ht,rowHeight:l,checkboxSelection:a,paginationMode:re,dataSource:Q,serverRowCount:fe.pagination.rowCount||0,paginationSlot:q?.pagination,paginationSlotProps:se?.pagination,onRowClick:Et,onSelectionChange:ht,onPaginationModelChange:Kt}),!ne&&r.jsx("div",{ref:V=>{Ye.current=V,kt.current=V},className:"ogx__viewport",onScroll:ui,role:"grid","aria-label":je||"Data grid","aria-rowcount":$e.length+1,"aria-colcount":e.length+(a?1:0)+(Ie?1:0)+(L?1:0),"aria-busy":ft,tabIndex:0,onKeyDownCapture:()=>{Xe(!0)},onMouseDownCapture:()=>{Xe(!1)},onKeyDown:yi,onFocus:_i,onBlur:Ci,children:r.jsxs("div",{ref:ni,className:"ogx__content",style:{width:ye.totalWidth},role:"presentation",children:[r.jsx(mn,{columns:ye.virtualColumns,allColumns:Fe,columnGroupingModel:ze,checkboxSelection:a,allSelected:Si,someSelected:ji,onSelectAll:vi,sortModel:Oe,onSort:Dn,onColumnResize:mi,columnWidths:Pe,pinnedColumns:Ne,focusedCell:Tt,onHeaderClick:V=>{sn({id:"HEADER",field:V}),Xe(!1),kt.current?.focus({preventScroll:!0})},onDragStart:ze?void 0:tt.onDragStart,onDragOver:ze?void 0:tt.onDragOver,onDragEnd:ze?void 0:tt.onDragEnd,onDrop:ze?void 0:tt.onDrop,draggedColumn:ze?void 0:tt.draggedColumn,dragOverColumn:ze?void 0:tt.dragOverColumn,rowReordering:L,hasDetailPanel:Ie,pinCheckboxColumn:C,pinExpandColumn:P,aggregationModel:Se,onHideColumn:V=>{wt({...Be,[V]:!1})},onManageColumns:()=>Lt(!0),onPinColumn:(V,ee)=>{const de=[...Ne?.left??[]],xe=[...Ne?.right??[]],pe=de.filter(be=>be!==V),me=xe.filter(be=>be!==V);Vt(ee==="left"?{left:[...pe,V],right:me}:ee==="right"?{left:pe,right:[...me,V]}:{left:pe,right:me})}}),!ft&&!fe.dataSource.error&&$e.length===0&&r.jsx(wo,{noRowsLabel:Ht,width:ye.totalWidth}),r.jsx(Cn,{rows:nn,position:"top",columns:ye.virtualColumns,selectedRowIds:ve,checkboxSelection:a,onRowClick:Et,onCellClick:an,onSelectionChange:ht,columnWidths:Pe,pinnedColumns:Ne,pinnedRows:g,hasDetailPanel:Ie,expandedRowIds:et,getDetailPanelContent:x,getDetailPanelHeight:E,onDetailPanelToggle:Nt,pinCheckboxColumn:C,pinExpandColumn:P,focusedCell:Tt,colspanMap:rt.colspanMap,rowSpanningCaches:rt.rowSpanningState.caches,rowHeight:l}),r.jsx(sr,{virtualContainerHeight:ye.totalHeight-ye.pinnedTopHeight-ye.pinnedBottomHeight,offsetTop:ye.offsetTop,effectiveLoading:ft,visibleRows:ki,baseColumns:e,virtualColumns:ye.virtualColumns,viewportWidth:fe.dimensions.viewportWidth,checkboxSelection:a,hasDetailPanel:Ie,rowReordering:L,rowHeight:l,pinnedRows:g,selectedRowIds:ve,onRowClick:Et,onCellClick:an,onSelectionChange:ht,columnWidths:Pe,pinnedColumns:Ne,expandedRowIds:et,getDetailPanelContent:x,getDetailPanelHeight:E,onDetailPanelToggle:Nt,pinCheckboxColumn:C,pinExpandColumn:P,rowReorderHandlers:bi,editingHandlers:Ze,focusedCell:Tt,colspanMap:rt.colspanMap,rowSpanningCaches:rt.rowSpanningState.caches,paginationMode:re,dataSourceLoading:fe.dataSource.loading,sortedUnpinnedRowCount:ot.length,infiniteScrollSkeletonCount:Math.min(Ce.pageSize,20),unpinnedRowsLength:he.unpinnedRowsLength}),r.jsx(Cn,{rows:on,position:"bottom",columns:ye.virtualColumns,selectedRowIds:ve,checkboxSelection:a,onRowClick:Et,onCellClick:an,onSelectionChange:ht,columnWidths:Pe,pinnedColumns:Ne,pinnedRows:g,hasDetailPanel:Ie,expandedRowIds:et,getDetailPanelContent:x,getDetailPanelHeight:E,onDetailPanelToggle:Nt,pinCheckboxColumn:C,pinExpandColumn:P,focusedCell:Tt,colspanMap:rt.colspanMap,rowSpanningCaches:rt.rowSpanningState.caches,rowHeight:l}),Pt&&!ae&&r.jsx(bo,{columns:tn,aggregationModel:Se,aggregationResult:ln,columnWidths:wi,rowHeight:l,checkboxSelection:a,hasDetailPanel:Ie,rowReordering:L,pinnedColumns:Ne})]})}),!ne&&Me&&(()=>{const V=q?.pagination||bn;return r.jsx(V,{page:Ce.page,pageSize:Ce.pageSize,rowCount:fe.pagination.rowCount,pageSizeOptions:w,onPageChange:ee=>Kt({...Ce,page:ee}),onPageSizeChange:ee=>Kt({...Ce,pageSize:ee,page:0}),...se?.pagination})})(),r.jsxs("div",{className:"ogx-aria-live-status",role:"status","aria-live":"polite",children:[ft?"Loading data...":"",fe.dataSource.error?`Error: ${fe.dataSource.error instanceof Error?fe.dataSource.error.message:"Unknown error"}`:"",!K&&!fe.dataSource.error&&($e.length===0?Ht:ke&&((ke.quickFilterValues?.length||0)>0||(ke.items?.length||0)>0)?`${$e.length} ${$e.length===1?"row":"rows"} found`:"")]}),r.jsx(vo,{error:fe.dataSource.error})]})}function fr({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 kn=new Set(["isEmpty","isNotEmpty"]);function gr(n,t){return n.find(e=>"field"in e&&e.field===t)}const hr=({col:n,item:t,onChange:e})=>{const o=i.useId(),l=so(n.type),s=!!t,d=t?.operator??l[0],[a,u]=i.useState(t?.value!=null?String(t.value):""),c=i.useRef(e),h=i.useRef(t),m=i.useRef(n.field),f=i.useRef(d);i.useLayoutEffect(()=>{c.current=e,h.current=t,m.current=n.field,f.current=d});const p=i.useRef(t?.value);i.useEffect(()=>{t?.value!==p.current&&(p.current=t?.value,u(t?.value!=null?String(t.value):""))},[t?.value]),i.useEffect(()=>{const w=setTimeout(()=>{const y=h.current,b=y?.value??"";a!==b&&c.current({id:y?.id??`${m.current}-${Date.now()}`,field:m.current,operator:f.current,value:a})},300);return()=>clearTimeout(w)},[a]);const _=w=>{const y=kn.has(w),b={id:t?.id??`${n.field}-${Date.now()}`,field:n.field,operator:w,value:y?void 0:t?.value??(n.type==="boolean"?"true":"")};e(b)},v=()=>{u(""),e(null)},j=kn.has(String(d)),I=n.type==="boolean",k=!j;return r.jsxs("div",{className:`ogx-filter__row${s?" ogx-filter__row--active":""}`,children:[r.jsx("span",{className:"ogx-filter__col-label",title:n.field,children:n.headerName||n.field}),r.jsxs("div",{className:"ogx-filter__controls",children:[r.jsx("select",{id:`${o}-op`,name:`filter-op-${n.field}`,className:`ogx-filter__op-select${s?" ogx-filter__op-select--active":""}`,value:String(d),onChange:w=>_(w.target.value),"aria-label":`Filter operator for ${n.headerName||n.field}`,children:l.map(w=>r.jsx("option",{value:w,children:w},w))}),k&&I&&r.jsxs("select",{id:`${o}-val`,name:`filter-val-${n.field}`,className:`ogx-filter__value-input ogx-filter__value-select${s?" ogx-filter__value-input--active":""}`,value:String(t?.value??"true"),onChange:w=>{u(w.target.value),e({id:t?.id??`${n.field}-${Date.now()}`,field:n.field,operator:d,value:w.target.value})},"aria-label":`Filter value for ${n.headerName||n.field}`,children:[r.jsx("option",{value:"true",children:"true"}),r.jsx("option",{value:"false",children:"false"})]}),k&&!I&&r.jsx("input",{id:`${o}-val`,name:`filter-val-${n.field}`,className:`ogx-filter__value-input${s?" ogx-filter__value-input--active":""}`,type:"text",value:a,onChange:w=>u(w.target.value),placeholder:n.type==="number"?"Number…":"Value…","aria-label":`Filter value for ${n.headerName||n.field}`}),s&&r.jsx("button",{className:"ogx-filter__row-clear",onClick:v,"aria-label":`Clear filter for ${n.headerName||n.field}`,title:"Clear",children:"×"})]})]})},Sn=({filterModel:n,columns:t,onFilterModelChange:e})=>{const o=i.useMemo(()=>n.items??[],[n.items]),l=n.logicOperator??"and",s=i.useCallback((u,c)=>{const h=o.filter(f=>"field"in f&&f.field!==u),m=c?[...h,c]:h;e({...n,items:m})},[o,n,e]),d=i.useCallback(u=>{e({...n,logicOperator:u})},[n,e]),a=t.filter(u=>u.filterable!==!1);return r.jsxs(r.Fragment,{children:[o.length>1&&r.jsxs("div",{className:"ogx-filter__logic-bar",children:[r.jsx("span",{className:"ogx-filter__logic-label",children:"Match:"}),r.jsx("button",{className:`ogx-filter__logic-pill${l==="and"?" ogx-filter__logic-pill--active":""}`,onClick:()=>d("and"),"aria-pressed":l==="and",children:"ALL (AND)"}),r.jsx("button",{className:`ogx-filter__logic-pill${l==="or"?" ogx-filter__logic-pill--active":""}`,onClick:()=>d("or"),"aria-pressed":l==="or",children:"ANY (OR)"})]}),a.length===0?r.jsx("div",{className:"ogx-filter__empty",children:"No filterable columns."}):a.map(u=>r.jsx(hr,{col:u,item:gr(o,u.field),onChange:c=>s(u.field,c)},u.field))]})},pr=["sum","avg","count","min","max"];function jn(){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:l}){const s=i.useRef(null),[d,a]=i.useState({top:0,right:0}),[u,c]=i.useState(document.body);i.useLayoutEffect(()=>{c(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const h=i.useCallback(()=>{if(!n.current)return{top:0,right:0};const C=n.current.getBoundingClientRect();return{top:C.bottom+6,right:window.innerWidth-C.right}},[n]);i.useEffect(()=>{a(h());const C=()=>a(h());return window.addEventListener("scroll",C,!0),window.addEventListener("resize",C),()=>{window.removeEventListener("scroll",C,!0),window.removeEventListener("resize",C)}},[h]),i.useEffect(()=>{function C(O){s.current&&!s.current.contains(O.target)&&n.current&&!n.current.contains(O.target)&&l()}function P(O){O.key==="Escape"&&l()}return document.addEventListener("mousedown",C),document.addEventListener("keydown",P),()=>{document.removeEventListener("mousedown",C),document.removeEventListener("keydown",P)}},[n,l]);const m=new Set(e.rowFields),f=new Set(e.columnFields),p=new Set(e.valueFields.map(C=>C.field)),_=C=>m.has(C)||f.has(C)||p.has(C);function v(C){m.has(C)||o({...e,rowFields:[...e.rowFields,C]})}function j(C){f.has(C)||o({...e,columnFields:[...e.columnFields,C]})}function I(C,P="sum"){p.has(C)||o({...e,valueFields:[...e.valueFields,{field:C,aggFn:P}]})}function k(C){o({...e,rowFields:e.rowFields.filter(P=>P!==C)})}function w(C){o({...e,columnFields:e.columnFields.filter(P=>P!==C)})}function y(C){o({...e,valueFields:e.valueFields.filter(P=>P.field!==C)})}function b(C,P){o({...e,valueFields:e.valueFields.map(O=>O.field===C?{...O,aggFn:P}:O)})}function g(){o({rowFields:[],columnFields:[],valueFields:[]})}const x=new Set(t.filter(C=>C.type==="number"||C.aggregable).map(C=>C.field)),E=e.rowFields.length+e.columnFields.length+e.valueFields.length,M=C=>t.find(P=>P.field===C)?.headerName??C,N=r.jsxs("div",{ref:s,className:"ogx-pivot-panel",role:"dialog","aria-label":"Pivot configuration",style:{top:d.top,right:d.right},children:[r.jsxs("div",{className:"ogx-pivot-panel__header",children:[r.jsxs("span",{className:"ogx-pivot-panel__title",children:[r.jsx(jn,{}),"Pivot Mode"]}),E>0&&r.jsx("button",{className:"ogx-pivot-panel__reset-btn",onClick:g,title:"Reset pivot",children:"Reset"})]}),r.jsxs("div",{className:"ogx-pivot-panel__body",children:[r.jsxs("div",{className:"ogx-pivot-zone",children:[r.jsxs("span",{className:"ogx-pivot-zone__label",children:[r.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--row"}),"Row Fields"]}),r.jsx("div",{className:`ogx-pivot-chips${e.rowFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — each becomes a row label",children:e.rowFields.map(C=>r.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--row",children:[M(C),r.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>k(C),title:`Remove ${M(C)}`,children:"×"})]},C))})]}),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(C=>r.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--col",children:[M(C),r.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>w(C),title:`Remove ${M(C)}`,children:"×"})]},C))})]}),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(C=>r.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--value",children:[M(C.field),r.jsx("select",{className:"ogx-pivot-chip__fn-select",value:C.aggFn,onChange:P=>b(C.field,P.target.value),title:"Aggregation function",children:pr.map(P=>r.jsx("option",{value:P,children:P.toUpperCase()},P))}),r.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>y(C.field),title:`Remove ${M(C.field)}`,children:"×"})]},C.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(C=>{const P=x.has(C.field);return _(C.field)?null:r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3},children:[r.jsx("span",{className:`ogx-pivot-field-btn${P?" ogx-pivot-field-btn--numeric":""}`,children:C.headerName??C.field}),r.jsxs("div",{className:"ogx-pivot-field-actions",children:[r.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--row",onClick:()=>v(C.field),title:"Add to Row Fields",children:"Row"}),r.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--col",onClick:()=>j(C.field),title:"Add to Column Fields",children:"Col"}),P&&r.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--value",onClick:()=>I(C.field),title:"Add to Value Fields",children:"Val"})]})]},C.field)}),t.every(C=>_(C.field))&&r.jsx("span",{style:{fontSize:12,color:"var(--ogx-color-gray-400, #94a3b8)"},children:"All fields are in use."})]})]})]})]});return Ae.createPortal(N,u)}function mr(){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 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("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),u=i.useRef(null),c=i.useRef(null),h=i.useRef(t);i.useLayoutEffect(()=>{h.current=t},[t]);const m=i.useRef(n),f=i.useRef(n),p=i.useRef(!1);i.useLayoutEffect(()=>{p.current&&document.activeElement!==u.current&&u.current?.focus()}),i.useEffect(()=>{n!==f.current&&(f.current=n,n!==m.current&&(a(n),m.current=n,n?s(!0):(p.current=!1,s(!1))))},[n]),i.useEffect(()=>{const k=setTimeout(()=>{d!==m.current&&(m.current=d,h.current(d))},o);return()=>clearTimeout(k)},[d,o]);const _=i.useCallback(()=>{s(!0),requestAnimationFrame(()=>u.current?.focus())},[]),v=i.useCallback(k=>{k.stopPropagation(),a(""),m.current="",h.current(""),u.current?.focus()},[]),j=i.useCallback(()=>{p.current=!0,s(!0)},[]),I=i.useCallback(()=>{p.current=!1,setTimeout(()=>{if(c.current&&document.activeElement&&c.current.contains(document.activeElement)){p.current=!0;return}d||s(!1)},150)},[d]);return i.useEffect(()=>{const k=w=>{c.current&&!c.current.contains(w.target)&&(d||s(!1))};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[d]),r.jsxs("div",{ref:c,className:`ogx-global-search${l?" ogx-global-search--expanded":""}`,onClick:l?void 0:_,children:[r.jsx("div",{className:"ogx-global-search__icon-wrapper",children:r.jsx(mr,{})}),r.jsx("input",{ref:u,className:"ogx-global-search__input",value:d,onChange:k=>a(k.target.value),onFocus:j,onBlur:I,placeholder:e,"aria-label":"Global Search",autoComplete:"off"}),d&&r.jsx("button",{className:"ogx-global-search__clear",onClick:v,"aria-label":"Clear search",children:r.jsx(br,{})})]})}function ut({title:n,children:t,placement:e="top",enterDelay:o=200,leaveDelay:l=0}){const[s,d]=i.useState(!1),[a,u]=i.useState({top:0,left:0}),c=i.useRef(null),h=i.useRef(null),m=i.useCallback(()=>{if(!h.current)return;const v=h.current.getBoundingClientRect();let j=0,I=0;const k=window.pageXOffset||document.documentElement.scrollLeft,w=window.pageYOffset||document.documentElement.scrollTop;e==="top"?(j=v.top+w-8,I=v.left+k+v.width/2):e==="bottom"&&(j=v.bottom+w+8,I=v.left+k+v.width/2),u({top:j,left:I})},[e]);i.useLayoutEffect(()=>(s&&(m(),window.addEventListener("scroll",m,!0),window.addEventListener("resize",m)),()=>{window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m)}),[s,m]);const f=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{d(!0)},o)},p=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{d(!1)},l)},_=i.useCallback(v=>{h.current=v?v.firstElementChild??v:null},[]);return r.jsxs(r.Fragment,{children:[r.jsx("span",{ref:_,style:{display:"inline-block",lineHeight:0},onMouseEnter:f,onMouseLeave:p,children:t}),s&&n&&Ae.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 vr=["none","sum","avg","count","min","max"];function En(){return r.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","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 Nn(){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 Cr({anchorRef:n,aggregationModel:t,aggregableColumns:e,onFunctionChange:o,onClearAll:l,onClose:s,activeCount:d}){const a=i.useRef(null),[u,c]=i.useState({top:0,right:0}),[h,m]=i.useState(document.body);i.useLayoutEffect(()=>{m(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const f=i.useCallback(()=>{if(!n.current)return{top:0,right:0};const _=n.current.getBoundingClientRect();return{top:_.bottom+6,right:window.innerWidth-_.right}},[n]);i.useEffect(()=>{c(f());const _=()=>c(f());return window.addEventListener("scroll",_,!0),window.addEventListener("resize",_),()=>{window.removeEventListener("scroll",_,!0),window.removeEventListener("resize",_)}},[f]),i.useEffect(()=>{function _(v){a.current&&!a.current.contains(v.target)&&n.current&&!n.current.contains(v.target)&&s()}return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[n,s]),i.useEffect(()=>{function _(v){v.key==="Escape"&&s()}return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[s]);const p=r.jsxs("div",{ref:a,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Summaries configuration",style:{top:u.top,right:u.right,width:400,maxWidth:"calc(100vw - 24px)"},children:[r.jsxs("div",{className:"ogx-toolbar__panel-header",children:[r.jsxs("span",{className:"ogx-toolbar__panel-title",children:[r.jsx(En,{}),"Summaries"]}),d>0&&r.jsx("button",{className:"ogx-toolbar__clear-btn",onClick:l,title:"Clear all summaries",children:"Clear all"})]}),r.jsx("div",{className:"ogx-toolbar__panel-body",children:e.length===0?r.jsxs("p",{className:"ogx-toolbar__empty",children:["No aggregable columns.",r.jsx("br",{}),"Set ",r.jsx("code",{children:"aggregable: true"})," on a column to enable."]}):e.map(_=>{const v=t[_.field]||"none";return r.jsxs("div",{className:"ogx-toolbar__agg-row",children:[r.jsx("span",{className:"ogx-toolbar__agg-label",title:_.field,children:_.headerName||_.field}),r.jsx("div",{className:"ogx-toolbar__agg-pills",children:vr.map(j=>r.jsx("button",{className:`ogx-toolbar__pill${v===j?" ogx-toolbar__pill--active":""}`,onClick:()=>o(_.field,j),"aria-pressed":v===j,children:j},j))})]},_.field)})})]});return Ae.createPortal(p,h)}function yr({anchorRef:n,columns:t,visibleColumns:e,onVisibilityChange:o,onShowAll:l,onHideAll:s,onColumnReorder:d,onColumnOrderReset:a,onClose:u}){const c=i.useRef(null),[h,m]=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 _=i.useCallback(()=>{if(!n.current)return{top:0,right:0};const j=n.current.getBoundingClientRect();return{top:j.bottom+6,right:window.innerWidth-j.right}},[n]);i.useEffect(()=>{m(_());const j=()=>m(_());return window.addEventListener("scroll",j,!0),window.addEventListener("resize",j),()=>{window.removeEventListener("scroll",j,!0),window.removeEventListener("resize",j)}},[_]),i.useEffect(()=>{function j(I){c.current&&!c.current.contains(I.target)&&n.current&&!n.current.contains(I.target)&&u()}return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[n,u]);const v=r.jsx("div",{ref:c,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Column visibility",style:{top:h.top,right:h.right,width:280,padding:0},children:r.jsx(yn,{columns:t,visibleColumns:e,onVisibilityChange:o,onShowAll:l,onHideAll:s,onColumnReorder:d,onColumnOrderReset:a})});return Ae.createPortal(v,f)}function kr({anchorRef:n,columns:t,filterModel:e,onFilterModelChange:o,onClose:l}){const s=i.useRef(null),[d,a]=i.useState({top:0,right:0}),u=i.useRef(l);i.useLayoutEffect(()=>{u.current=l},[l]);const[c,h]=i.useState(document.body);i.useLayoutEffect(()=>{h(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const m=i.useCallback(()=>{if(!n.current)return{top:0,right:0};const v=n.current.getBoundingClientRect();return{top:v.bottom+6,right:window.innerWidth-v.right}},[n]);i.useEffect(()=>{a(m());const v=()=>a(m());return window.addEventListener("scroll",v,!0),window.addEventListener("resize",v),()=>{window.removeEventListener("scroll",v,!0),window.removeEventListener("resize",v)}},[m]),i.useEffect(()=>{function v(j){j.key==="Escape"&&u.current()}return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[]);const f=e.items?.length??0,p=()=>{o({...e,items:[],logicOperator:"and"})},_=r.jsxs("div",{ref:s,className:"ogx-toolbar__panel ogx-toolbar__panel--filter",role:"dialog","aria-label":"Advanced filters",style:{top:d.top,right:d.right,width:540,maxWidth:"calc(100vw - 24px)"},children:[r.jsxs("div",{className:"ogx-toolbar__panel-header",children:[r.jsxs("span",{className:"ogx-toolbar__panel-title",children:[r.jsx(Nn,{}),"Filters",f>0&&r.jsx("span",{className:"ogx-toolbar__panel-count",children:f})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[f>0&&r.jsx("button",{className:"ogx-toolbar__clear-btn",onClick:p,title:"Clear all filters",children:"Clear all"}),r.jsx("button",{className:"ogx-toolbar__close-btn",onClick:()=>u.current(),title:"Close filters","aria-label":"Close filters panel",children:"Close"})]})]}),r.jsx("div",{className:"ogx-toolbar__panel-body ogx-toolbar__panel-body--filter",children:r.jsx(Sn,{columns:t,filterModel:e,onFilterModelChange:o})})]});return Ae.createPortal(_,c)}const Sr={rowFields:[],columnFields:[],valueFields:[]};function jr({columns:n=[],baseColumns:t,aggregationModel:e={},onAggregationModelChange:o,pivotModel:l,onPivotModelChange:s,filterModel:d,onFilterModelChange:a,columnVisibilityModel:u={},onColumnVisibilityModelChange:c,onColumnReorder:h,onColumnOrderReset:m,forceColumnsOpen:f,onColumnsPanelClose:p,children:_,rightContent:v,style:j,renderColumnsButton:I,renderFilterButton:k,renderAggregationButton:w,renderExportButton:y,renderQuickFilter:b,className:g}){const[x,E]=i.useState(!1),[M,N]=i.useState(!1),[C,P]=i.useState(!1),[O,T]=i.useState(!1);i.useEffect(()=>{f&&(P(!0),E(!1),N(!1),T(!1))},[f]);const F=i.useRef(null),H=i.useRef(null),L=i.useRef(null),D=i.useRef(null),K=i.useRef(null),G=i.useRef(null),S=i.useRef(null),B=l??Sr,W=B.rowFields.length>0||B.columnFields.length>0||B.valueFields.length>0,A=n.filter(q=>q.aggregable!==!1&&(q.type==="number"||q.aggregable===!0)),$=Object.keys(e).filter(q=>e[q]&&e[q]!=="none").length,X=i.useCallback((q,se)=>{if(!o)return;const ae={...e};se==="none"?delete ae[q]:ae[q]=se,o(ae)},[e,o]),U=i.useCallback(()=>{o?.({})},[o]),oe=i.useCallback(q=>{if(!a)return;const ae={...d||{},quickFilterValues:q?[q]:[],items:d?.items||[]};a(ae)},[d,a]),R=d?.quickFilterValues?.[0]||"",Q=d?.items?.length||0,Z=new Set(n.filter(q=>u[q.field]!==!1).map(q=>q.field)),le=i.useCallback((q,se)=>{if(!c)return;const ae={...u,[q]:se};c(ae)},[u,c]),re=i.useCallback(()=>{if(!c)return;const q={...u};n.forEach(se=>{se.hideable!==!1&&(q[se.field]=!0)}),c(q)},[n,u,c]),Y=i.useCallback(()=>{if(!c)return;const q={...u};n.forEach(se=>{se.hideable!==!1&&(q[se.field]=!1)}),c(q)},[n,u,c]);return r.jsxs("div",{className:["ogx-toolbar",g].filter(Boolean).join(" "),role:"toolbar","aria-label":"Grid toolbar",style:j,children:[_&&r.jsx("div",{className:"ogx-toolbar__left",children:_}),r.jsx("div",{className:"ogx-toolbar__spacer"}),r.jsxs("div",{className:"ogx-toolbar__actions",children:[a&&r.jsx("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:b?b({value:R,onChange:oe}):r.jsx(wr,{value:R,onChange:oe,placeholder:"Search..."})}),c&&r.jsxs("div",{ref:K,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[I?I({onClick:()=>{P(q=>!q),E(!1),N(!1),T(!1)},isOpen:C,activeCount:n.length-Z.size}):r.jsx(ut,{title:"Columns",children:r.jsx("button",{ref:L,className:`ogx-toolbar__icon-btn${C?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Manage columns",onClick:()=>{P(!C),E(!1),N(!1),T(!1)},children:r.jsx(_r,{})})}),C&&r.jsx(yr,{anchorRef:I?K:L,columns:n,visibleColumns:Z,onVisibilityChange:le,onShowAll:re,onHideAll:Y,onColumnReorder:h,onColumnOrderReset:m,onClose:()=>{P(!1),p?.()}})]}),a&&r.jsxs("div",{ref:G,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[k?k({onClick:()=>{T(q=>!q),E(!1),N(!1),P(!1)},isOpen:O,activeCount:Q}):r.jsx(ut,{title:"Filters",children:r.jsxs("button",{ref:D,className:`ogx-toolbar__icon-btn${O?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Advanced filters",onClick:()=>{T(!O),E(!1),N(!1),P(!1)},children:[r.jsx(Nn,{}),Q>0&&r.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Filters active"})]})}),O&&r.jsx(kr,{anchorRef:k?G:D,columns:n,filterModel:d||{items:[]},onFilterModelChange:a,onClose:()=>T(!1)})]}),s&&r.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[r.jsx(ut,{title:"Pivot",children:r.jsxs("button",{ref:H,className:`ogx-toolbar__icon-btn${M?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure pivot","aria-expanded":M,onClick:()=>{N(!M),E(!1),P(!1),T(!1)},children:[r.jsx(jn,{}),W&&r.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Pivot active"})]})}),M&&r.jsx(xr,{anchorRef:H,columns:t??n,model:B,onChange:q=>{s?.(q)},onClose:()=>N(!1)})]}),r.jsxs("div",{ref:S,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[w?w({onClick:()=>{E(q=>!q),N(!1),P(!1),T(!1)},isOpen:x,activeCount:$}):r.jsx(ut,{title:"Summaries",children:r.jsxs("button",{ref:F,className:`ogx-toolbar__icon-btn${x?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure summaries","aria-expanded":x,onClick:()=>{E(!x),N(!1),P(!1),T(!1)},children:[r.jsx(En,{}),$>0&&r.jsx("span",{className:"ogx-toolbar__dot","aria-label":`${$} active summaries`})]})}),x&&r.jsx(Cr,{anchorRef:w?S:F,aggregationModel:e,aggregableColumns:A,onFunctionChange:X,onClearAll:U,onClose:()=>E(!1),activeCount:$})]}),y&&y(),v]})]})}function Er(){return i.useRef(null)}const Nr=({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 Mr(n,t,e={}){const{fileName:o="export.csv",includeHeaders:l=!0,delimiter:s=",",selectedRows:d}=e,a=d&&d.length>0?n.filter(h=>d.includes(h.id)):n;if(a.length===0){console.warn("No rows to export");return}const u=t.filter(h=>!(h.exportable===!1||h.field==="__check__"||h.field==="__actions__"));let c="";if(l){const h=u.map(m=>Ue(m.headerName||m.field));c+=h.join(s)+`
9
- `}if(a.forEach(h=>{const m=u.map(f=>{let p=h[f.field];return f.valueGetter&&(p=f.valueGetter({row:h,field:f.field,value:p})),f.valueFormatter&&p!==void 0&&p!==null&&(p=f.valueFormatter({value:p,row:h,field:f.field})),Ue(String(p??""))});c+=m.join(s)+`
10
- `}),e.aggregationResult){const h=e.aggregationResult,m=e.aggregationModel||{},f=u.map(_=>m[_.field]?Ue(m[_.field].toUpperCase()):Ue(""));c+=f.join(s)+`
11
- `;const p=u.map(_=>{const v=h[_.field];if(v!=null){let j=v;return _.valueFormatter?j=_.valueFormatter({value:v,row:{},field:_.field}):m[_.field]&&(j=Te(v,m[_.field])),Ue(String(j))}return Ue("")});c+=p.join(s)+`
12
- `}$t(c,o,"text/csv;charset=utf-8;")}function Ue(n){return n.includes(",")||n.includes('"')||n.includes(`
13
- `)?`"${n.replace(/"/g,'""')}"`:n}function Ir(n,t,e={}){const{fileName:o="export.xls",sheetName:l="Sheet1",includeHeaders:s=!0,selectedRows:d}=e,a=d&&d.length>0?n.filter(h=>d.includes(h.id)):n;if(a.length===0){console.warn("No rows to export");return}const u=t.filter(h=>!(h.exportable===!1||h.field==="__check__"||h.field==="__actions__"));let c='<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">';if(c+="<head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>",c+=`<x:Name>${l}</x:Name>`,c+="<x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]-->",c+='<meta charset="UTF-8"></head><body>',c+='<table border="1">',s&&(c+="<thead><tr>",u.forEach(h=>{c+=`<th>${Ee(h.headerName||h.field)}</th>`}),c+="</tr></thead>"),c+="<tbody>",a.forEach(h=>{c+="<tr>",u.forEach(m=>{let f=h[m.field];m.valueGetter&&(f=m.valueGetter({row:h,field:m.field,value:f})),m.valueFormatter&&f!==void 0&&f!==null&&(f=m.valueFormatter({value:f,row:h,field:m.field})),c+=`<td>${Ee(String(f??""))}</td>`})}),e.aggregationResult){const h=e.aggregationResult,m=e.aggregationModel||{};c+='<tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',u.forEach(f=>{m[f.field]?c+=`<td style="text-align: right; font-weight: bold;">${Ee(m[f.field].toUpperCase())}</td>`:c+="<td></td>"}),c+="</tr>",c+='<tr style="font-weight: bold; background-color: #f5f5f5;">',u.forEach(f=>{const p=h[f.field];if(p!=null){let _=p;f.valueFormatter?_=f.valueFormatter({value:p,row:{},field:f.field}):m[f.field]&&(_=Te(p,m[f.field])),c+=`<td style="text-align: right;">${Ee(String(_))}</td>`}else c+="<td></td>"}),c+="</tr>"}c+="</tbody></table></body></html>",$t(c,o,"application/vnd.ms-excel")}function Ee(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function Pr(n,t,e={}){const{fileName:o="export.json",pretty:l=!0,selectedRows:s}=e,d=s&&s.length>0?n.filter(m=>s.includes(m.id)):n;if(d.length===0){console.warn("No rows to export");return}const a=t.filter(m=>!(m.exportable===!1||m.field==="__check__"||m.field==="__actions__")),u=d.map(m=>{const f={};return a.forEach(p=>{let _=m[p.field];p.valueGetter&&(_=p.valueGetter({row:m,field:p.field,value:_})),f[p.field]=_}),f});let c=u;if(e.aggregationResult){const m=e.aggregationResult,f=e.aggregationModel||{},p={};a.forEach(v=>{f[v.field]&&(p[v.field]=f[v.field].toUpperCase())});const _={};a.forEach(v=>{if(m[v.field]!==void 0&&m[v.field]!==null){let j=m[v.field];v.valueFormatter?j=v.valueFormatter({value:j,row:{},field:v.field}):f[v.field]&&(j=Te(j,f[v.field])),_[v.field]=j}}),c={data:u,aggregation:{labels:p,values:_}}}const h=l?JSON.stringify(c,null,2):JSON.stringify(c);$t(h,o,"application/json;charset=utf-8;")}async function Tr(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(`
6
+ <%s key={someKey} {...props} />`,$,Y,te,Y),V[Y+$]=!0)}if(Y=null,z!==void 0&&(e(z),Y=""+z),d(L)&&(e(L.key),Y=""+L.key),"key"in L){z={};for(var O in L)O!=="key"&&(z[O]=L[O])}else z=L;return Y&&a(z,typeof y=="function"?y.displayName||y.name||"Unknown":y),c(y,Y,z,i(),H,X)}function w(y){h(y)?y._store&&(y._store.validated=1):typeof y=="object"&&y!==null&&y.$$typeof===P&&(y._payload.status==="fulfilled"?h(y._payload.value)&&y._payload.value._store&&(y._payload.value._store.validated=1):y._store&&(y._store.validated=1))}function h(y){return typeof y=="object"&&y!==null&&y.$$typeof===_}var b=l,_=Symbol.for("react.transitional.element"),C=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),M=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),x=Symbol.for("react.consumer"),E=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),v=Symbol.for("react.client.reference"),I=b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,R=Object.prototype.hasOwnProperty,W=Array.isArray,F=console.createTask?console.createTask:function(){return null};b={react_stack_bottom_frame:function(y){return y()}};var U,T={},B=b.react_stack_bottom_frame.bind(b,s)(),G=F(o(s)),V={};at.Fragment=k,at.jsx=function(y,L,z){var $=1e4>I.recentlyCreatedOwnerStacks++;return p(y,L,z,!1,$?Error("react-stack-top-frame"):B,$?F(o(y)):G)},at.jsxs=function(y,L,z){var $=1e4>I.recentlyCreatedOwnerStacks++;return p(y,L,z,!0,$?Error("react-stack-top-frame"):B,$?F(o(y)):G)}})()),at}var xn;function to(){return xn||(xn=1,process.env.NODE_ENV==="production"?_t.exports=Zn():_t.exports=eo()),_t.exports}var r=to();function dt(n,t){return t?t.left?.includes(n)?"left":t.right?.includes(n)?"right":null:null}function no(n,t){const e=[],o=[],i=[];return t?(n.forEach(s=>{const d=dt(s.field,t);d==="left"?e.push(s):d==="right"?i.push(s):o.push(s)}),t.left&&e.sort((s,d)=>{const a=t.left.indexOf(s.field),u=t.left.indexOf(d.field);return a-u}),t.right&&i.sort((s,d)=>{const a=t.right.indexOf(s.field),u=t.right.indexOf(d.field);return a-u}),{left:e,center:o,right:i}):{left:e,center:n,right:i}}function Bt(n,t,e,o,i,s,d,a){const u={};if(!e)return u;const c=no(n,e);let p=0;a&&(p+=48),s&&d&&(p+=48),o&&i&&(p+=48),c.left.forEach(h=>{u[h.field]=p;const b=t[h.field]??h.width??100;p+=b});let w=0;return[...c.right].reverse().forEach(h=>{const b=t[h.field]??h.width??100;u[h.field]=w,w+=b}),u}function $t(n,t){return t?t.top?.includes(n)?"top":t.bottom?.includes(n)?"bottom":null:null}function oo(n,t){const e=[],o=[],i=[];return t?(n.forEach(s=>{const d=$t(s.id,t);d==="top"?e.push(s):d==="bottom"?i.push(s):o.push(s)}),t.top&&e.sort((s,d)=>{const a=t.top.indexOf(s.id),u=t.top.indexOf(d.id);return a-u}),t.bottom&&i.sort((s,d)=>{const a=t.bottom.indexOf(s.id),u=t.bottom.indexOf(d.id);return a-u}),{top:e,center:o,bottom:i}):{top:e,center:n,bottom:i}}function He(n){if(n===void 0)return{type:"auto",value:0};if(typeof n=="number")return{type:"fixed",value:n};if(typeof n=="string"){if(n.toLowerCase()==="auto")return{type:"auto",value:0};if(n.endsWith("%"))return{type:"percentage",value:parseFloat(n)};const t=parseFloat(n);if(!isNaN(t))return{type:"fixed",value:t}}return{type:"fixed",value:100}}function ro(n){const{rowHeight:t,pagination:e,paginatedUnpinnedRows:o,sortedUnpinnedRows:i,expandedRowIds:s,getDetailPanelHeight:d,pinnedTopRowsLength:a,pinnedBottomRowsLength:u,visibleOrderedColumns:c,pinnedColumns:p,columnWidths:w,viewportWidth:h,checkboxSelection:b,hasDetailPanel:_,rowReordering:C,paginationMode:k,isLoading:M,pageSize:j}=n;return l.useMemo(()=>{const x=e?o:i,E=x.map((D,q)=>{let ee=t;if(s.has(D.id)){const de=d?.({row:D,id:D.id,rowIndex:a+q})??200;ee+=typeof de=="number"?de:parseInt(String(de),10)||200}return ee}),f=E.reduce((D,q,ee)=>(D.push((D[ee-1]||0)+q),D),[]),m=k==="infinite"&&M&&x.length>0?Math.min(j,20):0,g=(f[f.length-1]||0)+m*t,S=a*t,P=u*t,N=[],v=[],I=[],R=[];c.forEach(D=>{const q=dt(D.field,p);q==="left"?N.push(D):q==="right"?v.push(D):I.push(D)});const W=(b?48:0)+(_?48:0)+(C?48:0),F=D=>w[D.field]??D.width,U=N.reduce((D,q)=>{const ee=He(F(q));return D+(ee.type==="fixed"?ee.value:100)},0),T=v.reduce((D,q)=>{const ee=He(F(q));return D+(ee.type==="fixed"?ee.value:100)},0),B=I.reduce((D,q)=>{if(!Object.prototype.hasOwnProperty.call(w,q.field)&&q.flex&&q.flex>0){const ce=q.minWidth??150,je=typeof q.width=="number"?q.width:150;return D+(ce||je)}const de=He(F(q));return de.type==="fixed"?D+de.value:de.type==="percentage"?D+100:D+(q.minWidth??150)},0),G=Math.max(h-W-U-T,B),V=[],y=[],L=[];I.forEach(D=>{const q=Object.prototype.hasOwnProperty.call(w,D.field),ee=He(F(D));if(!q&&D.flex&&D.flex>0){L.push({col:D,flex:D.flex});return}ee.type==="fixed"?V.push({col:D,width:ee.value}):ee.type==="percentage"?y.push({col:D,percentage:ee.value}):L.push({col:D,flex:1})});const z=V.reduce((D,{width:q})=>D+q,0);let $=Math.max(0,G-z);const H=new Map;y.forEach(({col:D,percentage:q})=>{const ee=q/100*$;H.set(D.field,ee),$-=ee}),$=Math.max(0,$);const X=new Map,Y=L.map(D=>({...D,minWidth:D.col.minWidth??50,maxWidth:D.col.maxWidth??1/0,frozen:!1,computedWidth:0}));(()=>{let D=0;const q=Y.length*2;for(;D<q;){D++;const ee=Y.filter(ne=>!ne.frozen);if(ee.length===0)break;const de=ee.reduce((ne,we)=>ne+we.flex,0),ce=Y.reduce((ne,we)=>we.frozen?ne+we.computedWidth:ne,0),je=Math.max(0,$-ce);if(de<=0){ee.forEach(ne=>{ne.computedWidth=ne.minWidth,ne.frozen=!0});break}const We=je/de;let Ee=0;const fe=[],Ye=[];if(ee.forEach(ne=>{const we=We*ne.flex;we<ne.minWidth?(Ee+=ne.minWidth-we,fe.push(ne)):we>ne.maxWidth?(Ee+=ne.maxWidth-we,Ye.push(ne)):ne.computedWidth=we}),fe.length===0&&Ye.length===0){ee.forEach(ne=>ne.frozen=!0);break}Ee>0?fe.forEach(ne=>{ne.computedWidth=ne.minWidth,ne.frozen=!0}):Ee<0?Ye.forEach(ne=>{ne.computedWidth=ne.maxWidth,ne.frozen=!0}):(fe.forEach(ne=>{ne.computedWidth=ne.minWidth,ne.frozen=!0}),Ye.forEach(ne=>{ne.computedWidth=ne.maxWidth,ne.frozen=!0}))}})(),Y.forEach(D=>X.set(D.col.field,D.computedWidth));const O=new Map;I.forEach(D=>{let q;if(X.has(D.field))q=X.get(D.field);else{const ee=V.find(ce=>ce.col.field===D.field),de=y.find(ce=>ce.col.field===D.field);if(ee)q=ee.width;else if(de){const ce=H.get(D.field)||0;q=Math.max(D.minWidth??50,ce||100)}else q=100}R.push(q),O.set(D.field,q)});const J=I.map(D=>{const q=Y.find(ee=>ee.col.field===D.field);return{...D,width:O.get(D.field)??(typeof D.width=="number"?D.width:100),flex:q?q.flex:D.flex}}),Q=11,le=N.map((D,q)=>{const ee=He(F(D));return{...D,width:ee.type==="fixed"?ee.value:100,zIndex:Q+q}}),oe=11,pe=v.map((D,q)=>{const ee=He(F(D));return{...D,width:ee.type==="fixed"?ee.value:100,zIndex:oe+(v.length-1-q)}}),A=R.reduce((D,q)=>D+q,0),ie=U+A+T+W,se=R.reduce((D,q,ee)=>(D.push((D[ee-1]||0)+q),D),[]);return{rowHeights:E,cumulativeHeights:f,unpinnedRowsHeight:g,pinnedTopHeight:S,pinnedBottomHeight:P,leftPinnedCols:le,rightPinnedCols:pe,unpinnedColsWithWidth:J,unpinnedColWidths:R,unpinnedAccWidths:se,totalWidth:ie,leftWidth:U,rightWidth:T,unpinnedTotalWidth:A,systemColumnsWidth:W,pinnedTopRowsLength:a,pinnedBottomRowsLength:u,unpinnedRowsLength:x.length}},[t,e,o,i,s,d,a,u,c,p,w,h,b,_,C,k,M,j])}function io(n){const{allRenderableRows:t,navigationColumns:e,checkboxSelection:o,selectedRowIds:i,handleSelectionChange:s,handleDetailPanelToggle:d,editingHandlers:a,setKeyboardMode:u,sortModel:c,handleSort:p,isCellEditable:w,pagination:h,pageSize:b,virtualization:_,viewportRef:C}=n,[k,M]=l.useState(null),j=l.useCallback(f=>{f.target===f.currentTarget&&M(m=>{if(m)return m;if(o)return{id:"HEADER",field:"__checkbox_col__"};const g=t[0],S=e[0];return g&&S?{id:g.id,field:S.field}:null})},[t,e,o]),x=l.useCallback(f=>{f.currentTarget.contains(f.relatedTarget)||M(null)},[]),E=l.useCallback(f=>{if(u(!0),!k)return;const{id:m,field:g}=k,S=!!a.editingCell;if(m==="HEADER"&&(f.key==="Enter"||f.key===" ")){f.preventDefault();const T=e.find(B=>B.field===g);if(T&&T.sortable!==!1){const B=c.find(V=>V.field===g);let G="asc";B&&(G=B.sort==="asc"?"desc":null),p(g,G)}return}if(f.key==="Enter"){if(f.preventDefault(),S)a.stopCellEdit();else if(e.find(B=>B.field===g)?.editable){const B=t.find(G=>G.id===m);B&&a.startCellEdit({id:m,field:g,value:B[g]})}return}if((f.key===" "||f.key==="Spacebar")&&!S){if(g==="__checkbox_col__"){f.preventDefault(),s(m,!i.has(m));return}if(g==="__expand_col__"){f.preventDefault(),d(m);return}}if(f.key==="Escape"){S&&(f.preventDefault(),a.stopCellEdit({cancel:!0}));return}if(S&&f.key!=="Tab")return;const P=m==="HEADER",N=P?-1:t.findIndex(T=>T.id===m),v=e.findIndex(T=>T.field===g);if(!P&&N===-1||v===-1)return;const I=(T,B,G,V,y,L=!1)=>{let z=T+G,$=B+V;return y&&V!==0&&(V>0&&$>=e.length?($=0,z++):V<0&&$<0&&($=e.length-1,z--)),!y&&($<0||$>=e.length)||z<(L?-1:0)||z>=t.length?null:{r:z,c:$}},R=(T,B,G,V,y,L=!1)=>{let z=T,$=B,H=0;const X=t.length*e.length+e.length;for(;H<X;){if(H++,z+=G,$+=V,V!==0)V>0?$>=e.length&&($=0,z++):$<0&&($=e.length-1,z--);else if($<0||$>=e.length)return null;if(z<-1||z>=t.length)return null;if(z===-1){if(!L)continue;const Q=e[$],le=Q.sortable!==!1;if(["__checkbox_col__"].includes(Q.field)||le)return{r:z,c:$};continue}const Y=t[z],te=e[$],O=["__checkbox_col__","__expand_col__","__reorder_col__"].includes(te.field);let J=te.editable||O;if(w&&!O)try{J=w({row:Y,field:te.field,value:Y[te.field],colDef:te,rowIndex:z,colIndex:$})}catch{}if(J)return{r:z,c:$}}return null};let W=N,F=v,U=!1;if(f.key==="Tab"){const T=f.shiftKey?-1:1,B=R(N,v,0,T,!0,!1);B&&(W=B.r,F=B.c,U=!0)}else if(f.key==="ArrowRight"){const T=I(N,v,0,1,!0,!0);T&&(W=T.r,F=T.c,U=!0)}else if(f.key==="ArrowLeft"){const T=I(N,v,0,-1,!0,!0);T&&(W=T.r,F=T.c,U=!0)}else if(f.key==="ArrowDown"){const T=I(N,v,1,0,!1,!0);T&&(W=T.r,F=T.c,U=!0)}else if(f.key==="ArrowUp"){const T=I(N,v,-1,0,!1,!0);T&&(W=T.r,F=T.c,U=!0)}else if(f.key==="Home")F=0,(f.ctrlKey||f.metaKey)&&(W=-1),U=!0;else if(f.key==="End")F=e.length-1,(f.ctrlKey||f.metaKey)&&(W=t.length-1),U=!0;else if(f.key==="PageUp")W=Math.max(-1,W-(h?b:10)),U=!0;else if(f.key==="PageDown"){const T=h?b:10;W=Math.min(t.length-1,W+T),U=!0}if(U&&(f.preventDefault(),S&&f.key==="Tab"&&a.stopCellEdit(),W>=-1&&W<t.length&&F>=0&&F<e.length)){const T=e[F];M(W===-1?{id:"HEADER",field:T.field}:{id:t[W].id,field:T.field});const B=C.current;if(B){const{cumulativeHeights:G,pinnedTopHeight:V,columnMetrics:y}=_,{clientHeight:L,clientWidth:z,scrollTop:$,scrollLeft:H}=B,X=W<=0?0:G[W-1],Y=G[W],te=$+V,O=$+L;let J=$;if(X<te?J=Math.max(0,X-V):Y>O&&(J=Y-L),J!==$&&(B.scrollTop=J),y){const{leftPinnedWidth:Q,rightPinnedWidth:le,unpinnedAccWidths:oe,unpinnedCols:pe,totalSpecialsWidth:A,pinnedSpecialsWidth:ie}=y,se=pe.findIndex(D=>D.field===T.field);if(se!==-1){const D=A+Q+(se>0?oe[se-1]:0),q=A+Q+oe[se],ee=H+ie+Q,de=H+z-le;let ce=H;D<ee?ce=Math.max(0,D-ie-Q):q>de&&(ce=q-z+le),ce!==H&&(B.scrollLeft=ce)}}}}},[k,t,e,a,_,i,s,d,u,c,p,w,h,b,C]);return{focusedCell:k,setFocusedCell:M,handleFocus:j,handleBlur:x,handleKeyDown:E}}const lo={rowFields:[],columnFields:[],valueFields:[]};function so(n){const{initialState:t,sortModel:e,aggregationModel:o,onAggregationModelChange:i,columnVisibilityModel:s,onColumnVisibilityModelChange:d,pinnedColumns:a,onPinnedColumnsChange:u,pivotModel:c,onPivotModelChange:p,paginationModel:w={page:0,pageSize:100},onPaginationModelChange:h,rowSelectionModel:b}=n,[_,C]=l.useState(()=>t?.sorting?.sortModel??[]),k=e!==void 0,M=k?e:_,j=o!==void 0,[x,E]=l.useState(()=>o??{}),f=j?o:x,m=l.useCallback(Q=>{j||E(Q),i?.(Q)},[j,i]),g=s!==void 0,[S,P]=l.useState(()=>t?.columns?.columnVisibilityModel??{}),N=g?s:S,v=l.useCallback(Q=>{g||P(Q),d?.(Q)},[g,d]),I=a!==void 0,[R,W]=l.useState(()=>t?.columns?.pinnedColumns??{}),F=I?a:R,U=l.useCallback(Q=>{I||W(Q),u?.(Q)},[I,u]),[T,B]=l.useState(()=>c??lo),G=c??T,V=l.useCallback(Q=>{B(Q),p?.(Q)},[p]),y=w!==void 0&&n.paginationModel!==void 0,[L,z]=l.useState(()=>t?.pagination?.paginationModel??w),$=y?w:L,H=l.useCallback(Q=>{y||z(Q),h?.(Q)},[y,h]),X=b!==void 0,[Y,te]=l.useState([]),O=X?b:Y,J=l.useMemo(()=>new Set(O),[O]);return{sortModel:M,isSortControlled:k,setInternalSortModel:C,aggregationModel:f,handleAggregationModelChange:m,columnVisibilityModel:N,handleColumnVisibilityModelChange:v,pinnedColumns:F,handlePinnedColumnsChange:U,currentPivotModel:G,handlePivotModelChange:V,effectivePaginationModel:$,handlePaginationModelChange:H,rowSelectionModel:O,selectedRowIds:J,isSelectionControlled:X,setInternalRowSelectionModel:te}}const ao={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 co(n,t){const{field:e,operator:o,value:i}=t,s=n[e],d=ao[o];return d?d(s,i):(console.warn(`Unknown filter operator: ${o}`),!0)}function uo(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 Dt(n,t){const e=t.items??[],o=t.logicOperator??"and",i=("quickFilterValues"in t?t.quickFilterValues:void 0)??[];if(i.length>0&&!uo(n,i))return!1;if(e.length===0)return!0;const s=d=>{if("logicOperator"in d&&"items"in d){const a=d,u=a.items;return u.length===0?!0:a.logicOperator==="and"?u.every(s):u.some(s)}else return co(n,d)};return o==="and"?e.every(s):e.some(s)}function fo(n,t){if(!t)return n;const{items:e=[],quickFilterValues:o=[]}=t;return e.length===0&&(!o||o.length===0)?n:n.filter(i=>Dt(i,t))}function go(n){switch(n){case"number":return["=","!=",">",">=","<","<=","isEmpty","isNotEmpty"];case"date":return["is","not","after","onOrAfter","before","onOrBefore","isEmpty","isNotEmpty"];case"boolean":return["is"];case"singleSelect":return["isAnyOf","is","not"];default:return["contains","equals","startsWith","endsWith","isEmpty","isNotEmpty"]}}function Ht(n,t,e){if(n==null&&t==null)return 0;if(n==null)return e==="asc"?1:-1;if(t==null)return e==="asc"?-1:1;if(typeof n=="number"&&typeof t=="number")return e==="asc"?n-t:t-n;if(n instanceof Date&&t instanceof Date)return e==="asc"?n.getTime()-t.getTime():t.getTime()-n.getTime();const o=String(n).toLowerCase(),i=String(t).toLowerCase();return e==="asc"?o<i?-1:o>i?1:0:o>i?-1:o<i?1:0}function ho(n,t){if(t.length===0)return n;const e=[...n];return e.sort((o,i)=>{for(const s of t){const d=o[s.field],a=i[s.field],u=Ht(d,a,s.sort);if(u!==0)return u}return 0}),e}function po(n){const{effectiveRows:t,activeHierarchyHandlers:e,filterMode:o,filterModel:i,dataSource:s,sortModel:d,sortingMode:a,pagination:u,paginationMode:c,effectivePaginationModel:p,pinnedRows:w,isLoading:h,pageSize:b}=n,_=l.useMemo(()=>e?e.getVisibleRows()||[]:o==="server"&&s?t:fo(t,i),[t,i,e,o,s]),{top:C,center:k,bottom:M}=l.useMemo(()=>e?{top:[],center:_,bottom:[]}:oo(_,w),[_,w,e]),j=l.useMemo(()=>e||a==="server"&&s?k:ho(k,d),[k,d,e,a,s]),x=l.useMemo(()=>{if(!u||c==="server"&&s)return j;const f=p.page*p.pageSize;return j.slice(f,f+p.pageSize)},[j,u,p.page,p.pageSize,c,s]),E=l.useMemo(()=>{if(e)return k;const f=u?x:j,m=[...C,...f,...M];if(c==="infinite"&&h&&m.length>0){const g=Math.min(b,20),S=Array.from({length:g},(P,N)=>({id:`__skeleton_${N}__`,_isSkeleton:!0}));return[...m,...S]}return m},[C,x,j,M,u,e,k,c,h,b]);return{filteredRows:_,pinnedTopRows:C,unpinnedRows:k,pinnedBottomRows:M,sortedUnpinnedRows:j,paginatedUnpinnedRows:x,allRenderableRows:E}}function xo(n){const{layout:t,scrollTop:e,scrollLeft:o,viewportWidth:i,viewportHeight:s,autoHeight:d,rowReordering:a,hasDetailPanel:u,checkboxSelection:c,pinCheckboxColumn:p,pinExpandColumn:w}=n;return l.useMemo(()=>{const{unpinnedAccWidths:h,unpinnedColsWithWidth:b,leftPinnedCols:_,rightPinnedCols:C,totalWidth:k,leftWidth:M,rightWidth:j,unpinnedTotalWidth:x,systemColumnsWidth:E,cumulativeHeights:f,pinnedTopHeight:m,pinnedBottomHeight:g,unpinnedRowsHeight:S,rowHeights:P,unpinnedRowsLength:N}=t,v=i||1e3,I=d?m+S+g+50:s||600,R=6,W=Math.max(0,o-M),F=o+v-M;let U=0,T=b.length-1,B=0,G=h.length-1;for(;B<=G;){const oe=B+G>>>1;h[oe]<W?B=oe+1:G=oe-1}U=Math.max(0,B-R);for(let oe=U;oe<h.length;oe++){if((oe===0?0:h[oe-1])>F){T=Math.min(b.length-1,oe+R);break}T=Math.min(b.length-1,oe+R)}const V=U>0?h[U-1]:0,y=x-h[T],L=[..._,...V>0?[{field:"__spacer_left__",width:V,isSpacer:!0}]:[],...b.slice(U,T+1),...y>0?[{field:"__spacer_right__",width:y,isSpacer:!0}]:[],...C],$=v>0&&k>v?16:0,H=m+S+g+$+2,X=5;let Y=0,te=N-1,O=0,J=0,Q=f.length-1;for(;J<=Q;){const oe=J+Q>>>1;f[oe]<e?J=oe+1:Q=oe-1}Y=Math.max(0,J-X),O=Y>0?f[Y-1]:0;for(let oe=Y;oe<f.length;oe++)if(f[oe]>=e+I){te=Math.min(N-1,oe+X);break}const le=(a?48:0)+(u&&w?48:0)+(c&&p?48:0);return{renderContext:{firstRowIndex:Y,lastRowIndex:te,firstColumnIndex:U,lastColumnIndex:T},offsetTop:O,offsetLeft:0,totalHeight:H,pinnedTopHeight:m,pinnedBottomHeight:g,totalWidth:k,rowHeights:P,cumulativeHeights:f,virtualColumns:L,columnMetrics:{leftPinnedWidth:M,rightPinnedWidth:j,unpinnedAccWidths:h,unpinnedCols:b,totalSpecialsWidth:E,pinnedSpecialsWidth:le}}},[t,e,o,i,s,d,a,u,c,p,w])}function mo(n){const{columns:t,onColumnOrderChange:e,disableColumnReorder:o=!1}=n,[i,s]=l.useState(null),[d,a]=l.useState(null),u=l.useRef(-1),c=l.useCallback(b=>_=>{if(o)return;const C=t.findIndex(M=>M.field===b);if(t[C]?.pinnable===!1){_.preventDefault();return}s(b),u.current=C,_.dataTransfer&&(_.dataTransfer.effectAllowed="move",_.dataTransfer.setData("text/plain",b))},[t,o]),p=l.useCallback(b=>_=>{o||!i||(_.preventDefault(),_.dataTransfer.dropEffect="move",a(b))},[i,o]),w=l.useCallback(b=>_=>{if(_.preventDefault(),o||!i||i===b){s(null),a(null);return}const C=t.findIndex(j=>j.field===i),k=t.findIndex(j=>j.field===b);if(C===-1||k===-1){s(null),a(null);return}const M=t[C];e&&e({column:M,oldIndex:C,targetIndex:k}),s(null),a(null),u.current=-1},[t,i,o,e]),h=l.useCallback(()=>{s(null),a(null),u.current=-1},[]);return{draggedColumn:i,dragOverColumn:d,onDragStart:o?void 0:c,onDragOver:o?void 0:p,onDragEnd:o?void 0:h,onDrop:o?void 0:w}}function mn({isExpanded:n,onClick:t,variant:e="chevron"}){return r.jsx("button",{className:`ogx-expand-icon ${n?"ogx-expand-icon--expanded":""}`,onClick:o=>{t&&t(o)},"aria-label":n?"Collapse row":"Expand row",type:"button",children:e==="plus-minus"?r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r.jsx("path",{d:"M4 8H12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M8 4V12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:n?0:1,transition:"opacity 0.2s ease",transformOrigin:"center"}})]}):r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{transform:n?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.2s ease"},children:r.jsx("path",{d:"M6 4L10 8L6 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}function bo(n){const{activeColumns:t,isHierarchyEnabled:e,isRowGrouping:o,isTreeData:i,activeHierarchyHandlers:s,columnVisibilityModel:d,columnOrder:a,onColumnOrderChange:u,disableColumnReorder:c,pivotMode:p,checkboxSelection:w,hasDetailPanel:h,rowReordering:b,initialState:_,setColumns:C}=n,k=l.useMemo(()=>e?t.map((v,I)=>I===0?{...v,renderCell:R=>{const W=R.rowMeta,F=W?.treeDepth??0,U=!!W?.hasChildren,T=!!W?.isExpanded,B=W?.groupingField,G=W?.groupingValue,V=W?.descendantCount,y=!!W?.isGroupRow;let L=v.renderCell?v.renderCell(R):R.value;return i&&U&&y&&(L=r.jsxs("div",{className:"ogx__group-cell-content",children:[R.value,V!==void 0&&V>0?` (${V})`:""]})),o&&U&&B&&(L=r.jsxs("div",{className:"ogx__group-cell-content",children:[v.field===B?"":`${B}: `,String(G),V!==void 0?` (${V})`:""]})),r.jsxs("div",{style:{display:"flex",alignItems:"center",paddingLeft:F*24,width:"100%",height:"100%"},children:[r.jsx("div",{style:{marginRight:4,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",cursor:U?"pointer":"default",flexShrink:0},children:U?r.jsx("div",{onClick:z=>{z.stopPropagation(),z.preventDefault(),s?.toggleExpansion(R.row.id)},onMouseDown:z=>{z.stopPropagation()},style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:10,position:"relative"},children:r.jsx(mn,{isExpanded:T,onClick:z=>{z.stopPropagation(),z.preventDefault(),s?.toggleExpansion(R.row.id)}})}):null}),r.jsx("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:L})]})}}:{...v,renderCell:R=>{const W=R.rowMeta,F=!!W?.hasChildren,U=W?.groupingField;return o&&F?v.field===U?null:R.value!==void 0&&R.value!==null?v.renderCell?v.renderCell(R):R.value:null:v.renderCell?v.renderCell(R):R.value}}):t,[t,e,o,i,s]),[M,j]=l.useState(()=>_?.columns?.columnWidths??{}),x=l.useCallback((v,I)=>{j(R=>({...R,[v]:I}))},[]),[E,f]=l.useState(()=>_?.columns?.columnOrder??t.map(v=>v.field)),m=a??E;l.useEffect(()=>{C(t)},[t,C]),l.useEffect(()=>{p&&f(t.map(v=>v.field))},[p,t]);const g=l.useMemo(()=>{if(c)return k;const v=new Map(m.map((I,R)=>[I,R]));return[...k].sort((I,R)=>{const W=v.get(I.field)??k.indexOf(I),F=v.get(R.field)??k.indexOf(R);return W-F})},[k,m,c]),S=l.useMemo(()=>g.filter(v=>d[v.field]!==!1),[g,d]),P=mo({columns:g,onColumnOrderChange:l.useCallback(v=>{const{oldIndex:I,targetIndex:R}=v,W=[...m],[F]=W.splice(I,1);W.splice(R,0,F),a||f(W),u?.(v)},[m,a,u]),disableColumnReorder:c}),N=l.useMemo(()=>{const v=[];return b&&v.push({field:"__reorder_col__"}),h&&v.push({field:"__expand_col__"}),w&&v.push({field:"__checkbox_col__"}),[...v,...g]},[g,w,h,b]);return{effectiveColumns:k,orderedColumns:g,visibleOrderedColumns:S,navigationColumns:N,columnWidths:M,effectiveColumnOrder:m,setInternalColumnOrder:f,columnReorderHandlers:P,handleColumnResize:x}}function wo(n){const{renderContext:t,pinnedTopRows:e,pinnedBottomRows:o,paginatedUnpinnedRows:i,sortedUnpinnedRows:s,pagination:d}=n;return l.useMemo(()=>{const{firstRowIndex:a,lastRowIndex:u}=t,c=d?i:s,p=e.length,w=e.map((j,x)=>({row:j,rowIndex:x})),h=o.map((j,x)=>({row:j,rowIndex:p+c.length+x})),b=Math.max(0,a-p),_=Math.min(c.length,u-p+1),C=c.slice(b,_).map((j,x)=>({row:j,rowIndex:p+b+x})),k=[...w,...C,...h],M=new Set;return k.filter(j=>M.has(j.row.id)?!1:(M.add(j.row.id),!0))},[t,e,o,i,s,d])}function vo(n){const{onRowsScrollEnd:t}=n,e=l.useRef({scrollTop:0,scrollLeft:0}),o=l.useRef(null),[i,s]=l.useState({scrollTop:0,scrollLeft:0});l.useEffect(()=>()=>{o.current!==null&&cancelAnimationFrame(o.current)},[]);const d=l.useCallback(a=>{const u=a.currentTarget;if(e.current={scrollTop:u.scrollTop,scrollLeft:u.scrollLeft},o.current!==null&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{o.current=null,s(e.current)}),t){const{scrollTop:c,scrollHeight:p,clientHeight:w}=u;p-c-w<100&&t({visibleTop:c,visibleBottom:c+w,viewportHeight:w})}},[t]);return{scrollTop:i.scrollTop,scrollLeft:i.scrollLeft,handleScroll:d}}function _o(n){const{onStateChange:t,sortModel:e,filterModel:o,effectivePaginationModel:i,columnWidths:s,effectiveColumnOrder:d,columnVisibilityModel:a,pinnedColumns:u}=n,c=l.useRef(t);l.useLayoutEffect(()=>{c.current=t}),l.useEffect(()=>{if(!c.current)return;const p={sorting:{sortModel:e},filter:{filterModel:o},pagination:{paginationModel:i},columns:{columnWidths:s,columnOrder:d,columnVisibilityModel:a,pinnedColumns:u}};c.current(p)},[e,o,i,s,d,a,u])}const Co={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 Ne(n,t){return n==null?"—":typeof n=="number"?t==="avg"?n.toLocaleString(void 0,{maximumFractionDigits:2}):n.toLocaleString():String(n)}function bn(n){const{rows:t,aggregationModel:e,isServerSide:o,dataSource:i,filterModel:s,sortModel:d,serverAggregationResults:a}=n,u=l.useMemo(()=>{if(o||Object.keys(e).length===0)return{};const j={};for(const[x,E]of Object.entries(e)){const f=Co[E];if(!f){console.warn(`[useAggregation] Unknown aggregation function: "${E}"`);continue}const m=t.map(g=>g[x]);j[x]=f(m)}return j},[t,e,o]),[c,p]=l.useState({}),[w,h]=l.useState(!1),[b,_]=l.useState(null),C=l.useRef(0),k=l.useCallback(async()=>{if(!i?.getAggregations||Object.keys(e).length===0)return;const j=++C.current;h(!0),_(null);try{const x=await i.getAggregations({sortModel:d??[],filterModel:s??{items:[]},groupKeys:[],aggregationModel:e});j===C.current&&p(x)}catch(x){j===C.current&&(_(x),console.error("[useAggregation] Server aggregation error:",x))}finally{j===C.current&&h(!1)}},[i,e,s,d]);return l.useEffect(()=>{o&&i?.getAggregations&&!a&&k()},[k,o,i,a]),{aggregationResult:l.useMemo(()=>o?a&&Object.keys(a).length>0?a:c:u,[o,u,a,c]),isLoading:w,error:b}}function yo({columns:n,aggregationModel:t,aggregationResult:e,columnWidths:o,rowHeight:i,checkboxSelection:s,hasDetailPanel:d,rowReordering:a,pinnedColumns:u}){const c=l.useMemo(()=>Bt(n,o,u,s,!0,d,!0,a),[n,o,u,s,d,a]),p=u?.left?.[u.left.length-1],w=u?.right?.[0];return r.jsxs("div",{className:"ogx__aggregation-footer",role:"row","aria-label":"Aggregation totals","aria-live":"polite",style:{minHeight:`${i}px`},children:[s&&r.jsx("div",{style:{width:48,flexShrink:0}}),d&&r.jsx("div",{style:{width:48,flexShrink:0}}),a&&r.jsx("div",{style:{width:48,flexShrink:0}}),n.map(h=>{const b=t[h.field],_=e[h.field],C=o[h.field]??(typeof h.width=="number"?h.width:120),k=dt(h.field,u),M=k?c[h.field]:void 0,j=["ogx__aggregation-cell",k==="left"&&"ogx__aggregation-cell--pinned-left",k==="right"&&"ogx__aggregation-cell--pinned-right",k==="left"&&h.field===p&&"ogx__aggregation-cell--pinned-left-last",k==="right"&&h.field===w&&"ogx__aggregation-cell--pinned-right-first"].filter(Boolean).join(" "),x={width:C,minWidth:C,maxWidth:C,textAlign:h.align||"left"};return k==="left"&&M!==void 0&&(x.left=M),k==="right"&&M!==void 0&&(x.right=M),r.jsx("div",{className:j,role:"gridcell",style:x,children:b?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"ogx__aggregation-label",children:b}),r.jsx("span",{className:"ogx__aggregation-value",children:Ne(_,b)})]}):null},h.field)})]})}function ko({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 So({error:n}){if(!n)return null;const t=n instanceof Error?n.message:typeof n=="string"?n:"An unexpected error occurred while loading the data.";return r.jsxs("div",{className:"ogx-error-overlay","aria-live":"assertive",role:"alert",children:[r.jsxs("svg",{width:"56",height:"56",viewBox:"0 0 24 24",fill:"none",stroke:"var(--ogx-color-error)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),r.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),r.jsx("div",{className:"ogx-error-overlay__title",children:"Oops! Something went wrong"}),r.jsx("div",{className:"ogx-error-overlay__message",children:t}),r.jsx("button",{onClick:()=>window.location.reload(),className:"ogx-button ogx-button--primary",children:"Retry"})]})}const ct=({indeterminate:n=!1,label:t,className:e="",inputRef:o,...i})=>{const s=l.useRef(null),d=l.useCallback(u=>{s.current=u,typeof o=="function"?o(u):o&&(o.current=u)},[o]);l.useEffect(()=>{s.current&&(s.current.indeterminate=n)},[n]);const a=["ogx-checkbox-wrapper",i.disabled&&"ogx-checkbox-wrapper--disabled",e].filter(Boolean).join(" ");return r.jsxs("label",{className:a,children:[r.jsx("input",{ref:d,type:"checkbox",className:"ogx-checkbox__input","aria-label":t||i["aria-label"]||(n?"Select some":i.checked?"Deselect":"Select"),...i}),r.jsxs("span",{className:"ogx-checkbox__box",children:[i.checked&&!n&&r.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:r.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})}),n&&r.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:r.jsx("path",{d:"M19 13H5v-2h14v2z"})})]}),t&&r.jsx("span",{className:"ogx-checkbox__label",children:t})]})};function jo(n){const{field:t,currentWidth:e,onResize:o,minWidth:i=50,maxWidth:s=1e3}=n,[d,a]=l.useState(!1),u=l.useRef(0),c=l.useRef(0),p=l.useCallback(b=>{b.preventDefault(),b.stopPropagation(),a(!0),u.current=b.clientX,c.current=e;let _=0;const C=16,k=j=>{const x=j.clientX-u.current,E=Math.max(i,Math.min(s,c.current+x)),f=Date.now();f-_>=C&&(o(t,E),_=f)},M=j=>{a(!1);const x=j.clientX-u.current,E=Math.max(i,Math.min(s,c.current+x));o(t,E),document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",M)};document.addEventListener("mousemove",k),document.addEventListener("mouseup",M)},[t,e,o,i,s]),w=l.useCallback(b=>{b.preventDefault(),b.stopPropagation()},[]),h=["ogx-column-resize-handle",d&&"ogx-column-resize-handle--dragging"].filter(Boolean).join(" ");return r.jsx("div",{className:h,onMouseDown:p,onClick:b=>b.stopPropagation(),onDragStart:b=>{b.preventDefault(),b.stopPropagation()},onDoubleClick:w,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${t} column`,children:r.jsx("div",{className:"ogx-column-resize-handle__line"})})}function Ge(){return r.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"currentColor",children:r.jsx("circle",{cx:"4",cy:"4",r:"4"})})}function Ve(){return r.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:r.jsx("circle",{cx:"4",cy:"4",r:"3"})})}function Eo(){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 No(){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 Mo(){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 Po(){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 Io(){return r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("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 To(){return r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"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 Lo(){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 Ro(){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 Oo({colDef:n,sortModel:t,onSort:e,onHide:o,onPin:i,pinnedColumns:s,onManageColumns:d,onClose:a,anchorEl:u}){const c=l.useRef(null),[p,w]=l.useState({position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"});l.useLayoutEffect(()=>{if(!u||!c.current)return;const f=u.getBoundingClientRect(),m=c.current.getBoundingClientRect(),g=window.innerWidth,S=window.innerHeight,P=8;let N=f.left;N+m.width+P>g&&(N=g-m.width-P),N<P&&(N=P);let v=f.bottom+4;v+m.height+P>S&&(v=f.top-m.height-4),w({position:"fixed",zIndex:1300,top:v,left:N,visibility:"visible"})},[u]),l.useEffect(()=>{function f(g){c.current&&!c.current.contains(g.target)&&u&&!u.contains(g.target)&&a()}function m(g){g.key==="Escape"&&a()}return document.addEventListener("mousedown",f),document.addEventListener("keydown",m),window.addEventListener("scroll",a,!0),window.addEventListener("resize",a),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",m),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a)}},[u,a]);const h=f=>{e?.(n.field,f),a()},b=()=>{o?.(n.field),a()},_=f=>{i?.(n.field,f),a()},C=t?.find(f=>f.field===n.field)?.sort,k=C==null,M=s?.left?.includes(n.field)??!1,j=s?.right?.includes(n.field)??!1,x=!M&&!j,E=n.headerName||n.field;return ze.createPortal(r.jsxs("div",{ref:c,className:"ogx-column-menu",style:p,role:"menu","aria-label":`Column options for ${E}`,children:[e&&n.sortable!==!1&&r.jsxs(r.Fragment,{children:[r.jsxs("button",{className:`ogx-menu-item${C==="asc"?" ogx-menu-item--active":""}`,onClick:()=>h("asc"),role:"menuitemradio","aria-checked":C==="asc",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:C==="asc"?r.jsx(Ge,{}):r.jsx(Ve,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(No,{})}),"Sort Ascending"]}),r.jsxs("button",{className:`ogx-menu-item${C==="desc"?" ogx-menu-item--active":""}`,onClick:()=>h("desc"),role:"menuitemradio","aria-checked":C==="desc",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:C==="desc"?r.jsx(Ge,{}):r.jsx(Ve,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(Mo,{})}),"Sort Descending"]}),r.jsxs("button",{className:`ogx-menu-item${k?" ogx-menu-item--active":""}`,onClick:()=>h(null),role:"menuitemradio","aria-checked":k,children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:k?r.jsx(Ge,{}):r.jsx(Ve,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(Po,{})}),"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${M?" ogx-menu-item--active":""}`,onClick:()=>_("left"),role:"menuitemradio","aria-checked":M,"aria-label":"Pin to left",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:M?r.jsx(Ge,{}):r.jsx(Ve,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(To,{})}),"Pin to Left"]}),r.jsxs("button",{className:`ogx-menu-item${j?" ogx-menu-item--active":""}`,onClick:()=>_("right"),role:"menuitemradio","aria-checked":j,"aria-label":"Pin to right",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:j?r.jsx(Ge,{}):r.jsx(Ve,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(Lo,{})}),"Pin to Right"]}),r.jsxs("button",{className:`ogx-menu-item${x?" ogx-menu-item--active":""}`,onClick:()=>_(null),role:"menuitemradio","aria-checked":x,"aria-label":"Unpin column",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:x?r.jsx(Ge,{}):r.jsx(Ve,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(Ro,{})}),"Unpin"]}),r.jsx("div",{className:"ogx-menu-divider"}),r.jsxs("button",{className:"ogx-menu-item",onClick:b,role:"menuitem","aria-label":`Hide ${E} column`,children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(Io,{})}),"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(Eo,{})}),"Manage columns"]})]}),u?.closest(".ogx-theme-provider")||document.body)}function Wo(){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 Fo(){return r.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor",children:r.jsx("path",{d:"M6.99 11L3 15l3.99 4v-3H14v-2H6.99v-3zM21 9l-3.99-4v3H10v2h7.01v3L21 9z"})})}function wn(n){const t=[];for(const e of n.children)typeof e=="string"?t.push(e):t.push(...wn(e));return t}function Ao(n){let t=0;function e(o,i){t=Math.max(t,i);for(const s of o.children)typeof s!="string"&&e(s,i+1)}return n.forEach(o=>e(o,1)),t}function zo(n,t,e){function o(a,u,c){if(!wn(a).includes(u))return null;if(c===e)return a;for(const p of a.children)if(typeof p!="string"){const w=o(p,u,c+1);if(w)return w}return null}const i=new Map;for(const a of t){let u=null;for(const c of n)if(u=o(c,a.field,0),u)break;i.set(a.field,u)}const s=[];let d=0;for(;d<t.length;){const a=t[d],u=i.get(a.field)??null,c=a.width;if(!u)s.push({key:`fg-${a.field}-${e}`,label:"",width:c,isGroup:!1}),d++;else{let p=0,w=d;for(;w<t.length&&i.get(t[w].field)===u;)p+=t[w].width,w++;s.push({key:`${u.groupId}-${e}`,label:u.headerName,width:p,isGroup:!0}),d=w}}return s}function vn(n){const{columns:t,allColumns:e,columnGroupingModel:o,checkboxSelection:i=!1,allSelected:s=!1,someSelected:d=!1,onSelectAll:a,onSort:u,sortModel:c=[],onColumnResize:p,columnWidths:w={},pinnedColumns:h,hasDetailPanel:b=!1,pinCheckboxColumn:_=!0,pinExpandColumn:C=!0,rowReordering:k=!1,aggregationModel:M,draggedColumn:j,dragOverColumn:x,onDragStart:E,onDragOver:f,onDragEnd:m,onDrop:g,focusedCell:S,onHeaderClick:P,onHideColumn:N,onPinColumn:v,onManageColumns:I}=n,R=l.useId(),W=l.useRef({}),[F,U]=l.useState(null),T=O=>J=>{J.stopPropagation(),U({colDef:O,anchorEl:J.currentTarget})},B=()=>{U(null)};l.useLayoutEffect(()=>{if(S?.id==="HEADER"){const O=W.current[S.field];O&&O.focus()}},[S]);const G=O=>()=>{if(O.sortable===!1||!u)return;const J=c.find(le=>le.field===O.field);let Q="asc";J&&(J.sort==="asc"?Q="desc":Q=null),u(O.field,Q)},V=O=>{const J=c.find(Q=>Q.field===O);return J?r.jsx("span",{className:`ogx__sort-icon ogx__sort-icon--${J.sort}`,"aria-hidden":"true"}):null},y=l.useMemo(()=>Bt(t,w,h,i,_,b,C,k),[t,w,h,i,_,b,C,k]),L=o?Ao(o):0,$=(e??t).filter(O=>!O.isSpacer).map(O=>({field:O.field,width:w[O.field]??O.width??100})),te=(k?48:0)+(b?48:0)+(i?48:0);return r.jsxs("div",{className:"ogx__header-wrap",children:[L>0&&Array.from({length:L},(O,J)=>{const Q=zo(o,$,J);return r.jsxs("div",{className:"ogx-col-group-row",role:"row",children:[te>0&&r.jsx("div",{className:"ogx-col-group-cell ogx-col-group-cell--filler",style:{width:te,minWidth:te,flexShrink:0},role:"columnheader"}),Q.map(le=>r.jsx("div",{role:"columnheader",className:`ogx-col-group-cell ${le.isGroup?"ogx-col-group-cell--group":"ogx-col-group-cell--filler"}`,style:{width:le.width,minWidth:le.width,flexShrink:0},title:le.isGroup?le.label:void 0,children:le.isGroup&&r.jsx("span",{className:"ogx-col-group-cell__label",children:le.label})},le.key))]},`ogx-grp-${J}`)}),r.jsxs("div",{className:"ogx__header",role:"row",children:[k&&r.jsx("div",{className:"ogx__header-cell ogx__header-cell--pinned ogx__header-cell--pinned-left",role:"columnheader","aria-label":"Row reorder handle",title:"Drag to reorder rows",style:{minWidth:48,maxWidth:48,position:"sticky",left:0,zIndex:4}}),b&&r.jsx("div",{className:`ogx__header-cell ogx__header-cell--expand ${C?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""}`,role:"columnheader","aria-label":"Expand row details",style:{minWidth:48,maxWidth:48,position:C?"sticky":void 0,left:C?k?48:0:void 0,zIndex:C?5:void 0}}),i&&r.jsx("div",{className:`ogx__header-cell ogx__header-cell--checkbox ${_?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""}`,role:"columnheader",style:{position:_?"sticky":void 0,left:_?(k?48:0)+(b&&C?48:0):void 0},children:r.jsx(ct,{id:R,name:R,checked:s,indeterminate:d,onChange:O=>a?.(O.target.checked),"aria-label":s?"Deselect all rows":"Select all rows",tabIndex:S?.id==="HEADER"&&S.field==="__checkbox_col__"?0:-1,onMouseDown:O=>O.preventDefault(),inputRef:O=>{W.current.__checkbox_col__=O}})}),t.map((O,J)=>{if(O.isSpacer)return r.jsx("div",{style:{width:O.width,minWidth:O.width,flexShrink:0},"aria-hidden":"true"},O.field);const Q=O.sortable!==!1,le=c.some(fe=>fe.field===O.field),oe=O.resizable!==!1,pe=dt(O.field,h),A=pe!==null,ie=j===O.field,se=x===O.field,D=["ogx__header-cell",`ogx__header-cell--align-${O.headerAlign||O.align||"left"}`,Q&&"ogx__header-cell--sortable",le&&"ogx__header-cell--sorted",A&&"ogx__header-cell--pinned",A&&`ogx__header-cell--pinned-${pe}`,ie&&"ogx__header-cell--dragging",se&&"ogx__header-cell--drag-over",S?.id==="HEADER"&&S.field===O.field&&"ogx__header-cell--focused",O.headerClassName].filter(Boolean).join(" "),q=w[O.field]??O.width??100,ee={width:q,minWidth:O.minWidth,maxWidth:O.maxWidth,flexGrow:O.flex??0,flexShrink:0,flexBasis:(O.flex,"auto"),boxSizing:"border-box",position:A?"sticky":"relative",zIndex:O.zIndex,opacity:ie?.5:1};if(A&&pe){const fe=y[O.field];pe==="left"?ee.left=fe:ee.right=fe}const de=O.renderHeader?O.renderHeader({field:O.field,colDef:O,colIndex:J}):O.headerName||O.field,ce=fe=>{if(fe.target.closest(".ogx-column-resize-handle")){fe.stopPropagation();return}P?.(O.field),Q&&G(O)()},je=E?E(O.field):void 0,We=f?f(O.field):void 0,Ee=g?g(O.field):void 0;return r.jsxs("div",{className:D,style:ee,onClick:ce,role:"columnheader",draggable:!!E,onDragStart:je,onDragOver:We,onDragEnd:m,onDrop:Ee,"aria-sort":Q?le?c.find(fe=>fe.field===O.field)?.sort==="asc"?"ascending":"descending":"none":void 0,"aria-colindex":J+1+(i?1:0),"data-field":O.field,tabIndex:-1,ref:fe=>{W.current[O.field]=fe},children:[r.jsxs("div",{className:"ogx__header-cell-content",children:[ie&&r.jsx("div",{className:"ogx__header-drag-icon",children:r.jsx(Fo,{})}),r.jsxs("div",{className:"ogx__header-cell-title-wrapper",children:[r.jsx("span",{className:"ogx__header-cell-title",children:de}),M&&M[O.field]&&r.jsx("span",{className:"ogx__header-cell-aggregation",children:M[O.field]})]}),Q&&V(O.field),!O.disableColumnMenu&&r.jsx("button",{className:"ogx__menu-icon-btn",onClick:T(O),"aria-label":`Open column menu for ${O.headerName||O.field}`,"aria-haspopup":"menu",tabIndex:-1,children:r.jsx(Wo,{})})]}),oe&&p&&r.jsx(jo,{field:O.field,currentWidth:q,onResize:p,minWidth:O.minWidth,maxWidth:O.maxWidth})]},O.field)}),F&&r.jsx(Oo,{colDef:F.colDef,sortModel:c,onSort:u,onHide:N,onPin:v,pinnedColumns:h,onManageColumns:I,onClose:B,anchorEl:F.anchorEl})]})]})}const ut=({variant:n="text",size:t="medium",color:e="default",disabled:o=!1,className:i="",children:s,...d})=>{const a=["ogx-button",`ogx-button--${n}`,`ogx-button--${t}`,`ogx-button--${e}`,o&&"ogx-button--disabled",i].filter(Boolean).join(" ");return r.jsx("button",{className:a,disabled:o,...d,children:s})};function _n(n){const t=l.useId(),{page:e,pageSize:o,rowCount:i,onPageChange:s,onPageSizeChange:d,pageSizeOptions:a=[10,25,50,100],showFirstButton:u=!0,showLastButton:c=!0,localeText:p}=n,w=Math.max(1,Math.ceil(i/o)),h=Math.min(e,w-1),b=h*o,_=Math.min(b+o,i),C=i===0?0:`${b+1}–${_}`,k=p?.paginationRowsPerPage??"Rows per page:",M=p?.paginationOf?p.paginationOf(i===0?0:b+1,_,i):`${C} of ${i}`,j=p?.paginationPage?p.paginationPage(h+1,w):`Page ${h+1} of ${w}`,x=()=>{s(0)},E=()=>{s(Math.max(0,h-1))},f=()=>{s(Math.min(w-1,h+1))},m=()=>{s(w-1)},g=N=>{const v=parseInt(N.target.value,10);d(v)},S=h===0,P=h>=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:k}),r.jsx("select",{id:t,className:"ogx-pagination__select",value:o,onChange:g,"aria-label":"Rows per page",children:a.map(N=>r.jsx("option",{value:N,children:N},N))})]}),r.jsx("div",{className:"ogx-pagination__info","aria-live":"polite","aria-atomic":"true",children:M}),r.jsxs("div",{className:"ogx-pagination__actions",children:[u&&r.jsx(ut,{variant:"text",size:"small",onClick:x,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(ut,{variant:"text",size:"small",onClick:E,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:j}),r.jsx(ut,{variant:"text",size:"small",onClick:f,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"})})}),c&&r.jsx(ut,{variant:"text",size:"small",onClick:m,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 Bo(n,t,e={}){const o=new Map,i=[];n.forEach(a=>{o.set(a.id,a),i.push(a.id)});const s=new Map,d=[];return t.forEach(a=>{s.set(a.field,a),d.push(a.field)}),{rows:{idRowsLookup:o,allRows:i},columns:{all:t,lookup:s,orderedFields:d,columnVisibilityModel:e},sorting:{sortModel:[]},filter:{filterModel:{items:[]}},pagination:{paginationModel:{page:0,pageSize:100},rowCount:n.length},selection:{selectedRows:new Set},pinning:{pinnedColumns:{},pinnedRows:{}},virtualization:{renderContext:{firstRowIndex:0,lastRowIndex:0,firstColumnIndex:0,lastColumnIndex:0}},dimensions:{rowHeight:52,headerHeight:56,viewportWidth:0,viewportHeight:0},dataSource:{loading:!1,error:null}}}function $o(n,t){switch(t.type){case"SET_ROWS":{const e=Array.from(n.rows.idRowsLookup.values()),o=typeof t.payload=="function"?t.payload(e):t.payload,i=new Map,s=[];return o.forEach(d=>{i.set(d.id,d),s.push(d.id)}),{...n,rows:{idRowsLookup:i,allRows:s},pagination:{...n.pagination,rowCount:t.preserveRowCount?n.pagination.rowCount:o.length}}}case"SET_COLUMNS":{const e=new Map,o=[];return t.payload.forEach(i=>{e.set(i.field,i),o.push(i.field)}),{...n,columns:{all:t.payload,lookup:e,orderedFields:o,columnVisibilityModel:n.columns.columnVisibilityModel}}}case"SET_SORT_MODEL":return{...n,sorting:{sortModel:t.payload}};case"SET_FILTER_MODEL":return{...n,filter:{filterModel:t.payload}};case"SET_PAGINATION_MODEL":return{...n,pagination:{...n.pagination,paginationModel:t.payload}};case"SET_SELECTION":return{...n,selection:{selectedRows:t.payload}};case"SET_DIMENSIONS":return{...n,dimensions:{...n.dimensions,viewportWidth:t.payload.viewportWidth,viewportHeight:t.payload.viewportHeight}};case"SET_DATASOURCE_LOADING":return{...n,dataSource:{...n.dataSource,loading:t.payload}};case"SET_DATASOURCE_ERROR":return{...n,dataSource:{...n.dataSource,error:t.payload}};case"SET_ROW_COUNT":return{...n,pagination:{...n.pagination,rowCount:t.payload}};default:return n}}function Do(n){const{rows:t,columns:e,rowHeight:o=52,headerHeight:i=56,columnVisibilityModel:s,initialState:d}=n,[a]=l.useState(()=>Bo(t,e,s)),[u,c]=l.useReducer($o,{...a,sorting:d?.sorting||a.sorting,filter:d?.filter||a.filter,dataSource:d?.dataSource?{...a.dataSource,...d.dataSource}:a.dataSource,pagination:{...a.pagination,...d?.pagination||{},rowCount:n.rowCount??d?.pagination?.rowCount??a.pagination.rowCount},dimensions:{...a.dimensions,rowHeight:o,headerHeight:i}}),p=l.useRef(u);l.useLayoutEffect(()=>{p.current=u});const w=l.useRef(t);l.useEffect(()=>{t!==w.current&&(w.current=t,c({type:"SET_ROWS",payload:t}))},[t]);const h=l.useCallback((g,S)=>{c({type:"SET_ROWS",payload:g,preserveRowCount:S})},[]),b=l.useCallback(g=>{c({type:"SET_COLUMNS",payload:g})},[]),_=l.useCallback(g=>{c({type:"SET_SORT_MODEL",payload:g})},[]),C=l.useCallback(g=>{c({type:"SET_FILTER_MODEL",payload:g})},[]),k=l.useCallback(g=>{c({type:"SET_PAGINATION_MODEL",payload:g})},[]),M=l.useCallback(g=>{c({type:"SET_SELECTION",payload:g})},[]),j=l.useCallback((g,S)=>{c({type:"SET_DIMENSIONS",payload:{viewportWidth:g,viewportHeight:S}})},[]),x=l.useCallback(g=>{c({type:"SET_DATASOURCE_LOADING",payload:g})},[]),E=l.useCallback(g=>{c({type:"SET_DATASOURCE_ERROR",payload:g})},[]),f=l.useCallback(g=>{c({type:"SET_ROW_COUNT",payload:g})},[]),m=l.useRef({getRow:g=>p.current.rows.idRowsLookup.get(g)||null,getAllRows:()=>Array.from(p.current.rows.idRowsLookup.values()),getVisibleRows:()=>Array.from(p.current.rows.idRowsLookup.values()),getAggregationResult:()=>null,getAggregationModel:()=>null,getColumn:g=>p.current.columns.lookup.get(g)||null,getAllColumns:()=>p.current.columns.all,getVisibleColumns:()=>p.current.columns.all,selectRow:(g,S=!0)=>{const P=new Set(p.current.selection.selectedRows);S?P.add(g):P.delete(g),M(P)},selectRows:(g,S=!0)=>{const P=new Set(p.current.selection.selectedRows);g.forEach(N=>{S?P.add(N):P.delete(N)}),M(P)},getSelectedRows:()=>Array.from(p.current.selection.selectedRows),sortColumn:(g,S)=>{if(S===null)_(p.current.sorting.sortModel.filter(P=>P.field!==g));else{const P=p.current.sorting.sortModel.findIndex(N=>N.field===g);if(P>=0){const N=[...p.current.sorting.sortModel];N[P]={field:g,sort:S},_(N)}else _([...p.current.sorting.sortModel,{field:g,sort:S}])}},getSortModel:()=>p.current.sorting.sortModel,setFilterModel:C,getFilterModel:()=>p.current.filter.filterModel,setPage:g=>{k({...p.current.pagination.paginationModel,page:g})},setPageSize:g=>{k({...p.current.pagination.paginationModel,pageSize:g,page:0})},scrollToIndexes:()=>{},copySelectedRows:()=>Promise.resolve()});return{state:u,dispatch:c,apiRef:m,setRows:h,setColumns:b,setSortModel:_,setFilterModel:C,setPaginationModel:k,setSelection:M,setDimensions:j,setDataSourceLoading:x,setDataSourceError:E,setRowCount:f}}function Ho(n){const{onRowOrderChange:t,rows:e,getRowId:o,rowReordering:i=!1}=n,[s,d]=l.useState(null),[a,u]=l.useState(null),c=l.useCallback(_=>o?o(_):_.id,[o]),p=l.useCallback(_=>C=>{i&&(d(_),C.dataTransfer.effectAllowed="move")},[i]),w=l.useCallback(_=>C=>{!i||!s||(C.preventDefault(),C.dataTransfer.dropEffect="move",a!==_&&u(_))},[i,s,a]),h=l.useCallback(()=>{d(null),u(null)},[]),b=l.useCallback(_=>C=>{if(C.preventDefault(),!s||!t){h();return}const k=e.findIndex(j=>c(j)===s),M=e.findIndex(j=>c(j)===_);k!==-1&&M!==-1&&k!==M&&t({row:e[k],oldIndex:k,targetIndex:M}),h()},[s,t,e,c,h]);return{draggedRowId:s,dragOverRowId:a,onDragStart:i?p:void 0,onDragOver:i?w:void 0,onDragEnd:i?h:void 0,onDrop:i?b:void 0}}function Go(n){const{rows:t,getRowId:e,getTreeDataPath:o,treeData:i=!1,defaultGroupingExpansionDepth:s=0,filterModel:d,sortModel:a,onRowExpansionChange:u}=n,{treeNodes:c,rootIds:p,groupingRows:w}=l.useMemo(()=>{if(!i||!o)return{treeNodes:new Map,rootIds:[],groupingRows:[]};const f=new Map,m=[],g=[],S=new Map,P=N=>N.join("/");return t.forEach(N=>{const v=e(N),I=o(N),R=P(I);S.set(R,v),f.set(v,{id:v,parentId:null,depth:I.length-1,groupingKey:I[I.length-1],isExpanded:!1,children:[],serverChildrenCount:N.serverChildrenCount})}),t.forEach(N=>{const v=e(N),I=o(N);if(I.length===1){m.push(v);return}const R=F=>{if(F.length<=1)return;const U=F.slice(0,-1),T=P(U);let B=S.get(T);if(B===void 0&&(B=`auto-group-${T}`,!f.has(B))){const G=U[U.length-1];f.set(B,{id:B,parentId:null,depth:U.length-1,groupingKey:G,isExpanded:!1,children:[],label:G}),S.set(T,B);const V={id:B,name:G,_isGroupRow:!0};g.push(V),U.length===1&&m.push(B),R(U)}return B},W=R(I);if(W!==void 0){const F=f.get(W),U=f.get(v);F&&U&&(U.parentId=W,F.children=F.children||[],F.children.includes(v)||F.children.push(v))}}),g.forEach(N=>{const v=N.id,I=f.get(v);if(!I)return;const W=v.replace("auto-group-","").split("/");if(W.length>1){const F=W.slice(0,-1),U=P(F),T=S.get(U);if(T&&f.has(T)){I.parentId=T;const B=f.get(T);B&&(B.children=B.children||[],B.children.includes(v)||B.children.push(v))}}}),{treeNodes:f,rootIds:m,groupingRows:g}},[t,o,i,e]),h=l.useMemo(()=>{if(!i)return new Set;const f=new Set;return c.forEach(m=>{m.children&&m.children.length>0&&(s===-1||m.depth<s)&&f.add(m.id)}),f},[c,i,s]),[b,_]=l.useState(new Set);l.useEffect(()=>{h.size>0&&_(h)},[h]);const C=l.useCallback(f=>{_(m=>{const g=new Set(m),S=!g.has(f);if(g.has(f)?g.delete(f):g.add(f),S&&u){const P=c.get(f);P&&u(P)}return g})},[c,u]),k=l.useCallback(()=>{if(!i)return null;const f=new Map;t.forEach(R=>f.set(e(R),R)),w.forEach(R=>f.set(R.id,R));const m=R=>Dt(R,d),g=new Map,S=R=>{if(g.has(R))return g.get(R);const W=f.get(R);if(!W)return!1;if(m(W))return g.set(R,!0),!0;const U=c.get(R);return U&&U.children&&U.children.some(B=>S(B))?(g.set(R,!0),!0):(g.set(R,!1),!1)},P=(R,W)=>{if(!a||a.length===0)return 0;const F=f.get(R),U=f.get(W);if(!F||!U)return 0;for(const T of a){const B=F[T.field],G=U[T.field],V=Ht(B,G,T.sort);if(V!==0)return V}return 0},N=[],v=new Set,I=R=>{const W=R.filter(F=>S(F));W.sort(P),W.forEach(F=>{if(v.has(F))return;const U=f.get(F),T=c.get(F);if(U&&T){v.add(F);const B={...U,_treeDepth:T.depth,_isExpanded:b.has(F),_hasChildren:!!(T.children&&T.children.length>0||T.serverChildrenCount&&T.serverChildrenCount>0),_descendantCount:T.children?T.children.length:0};N.push(B),b.has(F)&&T.children&&T.children.length>0&&I(T.children)}})};return I(p),N},[i,t,w,p,c,b,d,a,e]),M=l.useCallback(f=>b.has(f),[b]),j=l.useCallback(f=>c.get(f),[c]),x=l.useCallback(f=>{const m=[];let g=f;for(;g!==null;){const S=c.get(g);if(!S)break;m.unshift(S.groupingKey),g=S.parentId}return m},[c]),E=l.useMemo(()=>{const f=new Map,m=new Set(w.map(g=>g.id));return c.forEach((g,S)=>{f.set(S,{hasChildren:!!(g.children&&g.children.length>0||g.serverChildrenCount&&g.serverChildrenCount>0),treeDepth:g.depth,descendantCount:g.children?g.children.length:void 0,isGroupRow:m.has(S),isExpanded:b.has(S)})}),f},[c,w,b]);return l.useMemo(()=>({treeNodes:c,groupingRows:w,toggleExpansion:C,isGroupExpanded:M,getVisibleRows:k,getNode:j,getNodePath:x,rowMetaMap:E}),[c,w,C,M,k,j,x,E])}const Vo=n=>n?.depth===-1?"footer":"inline",Uo=[],Ko={};function Yo(n){const{rows:t,getRowId:e,rowGroupingModel:o=Uo,aggregationModel:i=Ko,defaultGroupingExpansionDepth:s=0,filterModel:d,sortModel:a,getAggregationPosition:u=Vo}=n,[c,p]=l.useState(new Set),{treeNodes:w,rootIds:h,groupingRows:b}=l.useMemo(()=>{const x=new Map,E=new Map,f=[];if(o.length===0)return{treeNodes:x,rootIds:f,groupingRows:E};const m=(P,N,v)=>`auto-group-${P}-${N}-${v||"root"}`,g=(P,N,v)=>{if(N>=o.length)return P.map(F=>{const U=e(F);return x.set(U,{id:U,parentId:v,depth:N,groupingKey:"",isExpanded:!1}),U});const I=o[N],R=new Map;P.forEach(F=>{const U=F[I],T=String(U);R.has(T)||R.set(T,[]),R.get(T).push(F)});const W=[];return R.forEach((F,U)=>{const B=F[0][I],G=m(I,U,v);W.push(G);const V={};i&&Object.entries(i).forEach(([H,X])=>{const Y=F.map(te=>te[H]);if(X==="sum")V[H]=Y.reduce((te,O)=>te+(Number(O)||0),0);else if(X==="min")V[H]=Math.min(...Y.map(te=>Number(te)||0));else if(X==="max")V[H]=Math.max(...Y.map(te=>Number(te)||0));else if(X==="avg"){const te=Y.reduce((O,J)=>O+(Number(J)||0),0);V[H]=Y.length?te/Y.length:0}else X==="count"&&(V[H]=Y.length)});const y={[I]:B,...V,id:G};E.set(G,y);const L={id:G,parentId:v,depth:N,groupingKey:U,groupingField:I,groupingValue:B,aggregatedValues:V,isExpanded:!1,children:[],label:`${I}: ${String(B)}`};L.aggregationPosition=u(L),x.set(G,L);const z=g(F,N+1,G);x.get(G).children=z;const $=F.length;x.get(G).descendantCount=$}),W},S=g(t,0,null);return f.push(...S),{treeNodes:x,rootIds:f,groupingRows:E}},[t,o,i,e,u]);l.useEffect(()=>{if(s===-1){const x=new Set;w.forEach((E,f)=>{E.children&&E.children.length>0&&x.add(f)}),p(x)}else if(s>0){const x=new Set;w.forEach((E,f)=>{E.depth<s&&E.children&&E.children.length>0&&x.add(f)}),p(x)}else p(new Set)},[o,s,w]);const _=l.useCallback(x=>{p(E=>{const f=new Set(E);return f.has(x)?f.delete(x):f.add(x),f})},[]),C=l.useCallback(x=>c.has(x),[c]),k=l.useCallback(()=>{if(o.length===0)return null;const x=[],E=new Set,f=new Map;t.forEach(P=>f.set(e(P),P));const m=P=>{const N=w.get(P);if(!N)return!1;if(!N.children||N.children.length===0){const v=f.get(P);return!(!v||d&&!Dt(v,d))}return N.children.some(v=>m(v))},g=P=>{let N=P;d&&(N=P.filter(m)),a&&a.length>0&&N.sort((v,I)=>{const R=b.get(v)||f.get(v),W=b.get(I)||f.get(I);if(!R||!W)return 0;for(const F of a){const U=R[F.field],T=W[F.field],B=Ht(U,T,F.sort);if(B!==0)return B}return 0}),N.forEach(v=>{if(E.has(v))return;const I=w.get(v),R=I?.children&&I.children.length>0,W=R?b.get(v):f.get(v);if(W&&I){E.add(v);const F={...W,_treeDepth:I.depth,_isExpanded:c.has(v),_hasChildren:R,_groupingField:I.groupingField,_groupingValue:I.groupingValue,_descendantCount:I.descendantCount};x.push(F),S.has(v)&&R&&g(I.children)}})},S=c;return g(h),x},[t,e,w,h,b,d,a,c,o]),M=l.useCallback(x=>w.get(x),[w]),j=l.useMemo(()=>{const x=new Map;return w.forEach((E,f)=>{const m=!!(E.children&&E.children.length>0);x.set(f,{hasChildren:m,treeDepth:E.depth,groupingField:E.groupingField,groupingValue:E.groupingValue,descendantCount:E.descendantCount,isGroupRow:m,isExpanded:m?c.has(f):void 0})}),x},[w,c]);return l.useMemo(()=>({treeNodes:w,groupingRows:b,toggleExpansion:_,isGroupExpanded:C,getVisibleRows:k,getNode:M,rowMetaMap:j}),[w,b,_,C,k,M,j])}function qo(n){const{rows:t,getRowId:e,processRowUpdate:o,onProcessRowUpdateError:i,onRowChange:s}=n,[d,a]=l.useState(null),u=l.useRef(null),c=l.useCallback(b=>{a(b),u.current=typeof b=="function"?b(u.current):b},[]),p=l.useCallback(b=>{c({id:b.id,field:b.field,value:b.value,originalValue:b.value})},[c]),w=l.useCallback(async b=>{const _=u.current;if(!_)return;if(b?.cancel){c(null);return}const{id:C,field:k,value:M,originalValue:j}=_;if(M===j){c(null);return}const x=t.find(f=>e(f)===C);if(!x){c(null);return}const E={...x,[k]:M};try{if(o){const f=await o(E,x);s?.(f)}else s?.(E);c(null)}catch(f){i?.(f)}},[c,t,e,o,s,i]),h=l.useCallback(b=>{d&&d.id===b.id&&d.field===b.field&&c(_=>_?{..._,value:b.value}:null)},[d,c]);return{editingCell:d,startCellEdit:p,stopCellEdit:w,setEditCellValue:h}}function Xo(n,t,e){const[o,i]=l.useState(new Map),[s,d]=l.useState({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}}),a=l.useCallback(()=>{i(new Map)},[]),u=l.useCallback((C,k)=>o.get(C)?.[k],[o]),c=l.useCallback((C,k,M,j,x)=>{const E=new Map(o);for(let f=j;f<x;f++){const m=t[f];if(!m)continue;let g=1;if(m.colSpan)if(typeof m.colSpan=="function"){const P={row:k,value:k[m.field],field:m.field,colDef:m,rowIndex:M,colIndex:f};g=m.colSpan(P)}else g=m.colSpan;if(g<=1){Ue(E,C,m.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:e[m.field]||100}});continue}let S=e[m.field]||100;for(let P=1;P<g;P++)if(f+P<x){const N=t[f+P];N&&(S+=e[N.field]||100,Ue(E,C,N.field,{spannedByColSpan:!0,leftVisibleCellIndex:f,rightVisibleCellIndex:Math.min(f+g-1,t.length-1)}))}Ue(E,C,m.field,{spannedByColSpan:!1,cellProps:{colSpan:g,width:S}}),f+=g-1}i(E)},[o,t,e]),p=l.useCallback((C,k)=>{const M={},j={},x={};t.forEach((E,f)=>{if(E.rowSpan)for(let m=C;m<k;m++){const g=n[m];if(!g||j[g.id]?.[E.field])continue;const S=E.valueGetter?E.valueGetter({row:g,field:E.field,value:g[E.field]}):g[E.field];let P=1;if(typeof E.rowSpan=="function"){const N={row:g,value:S,field:E.field,colDef:E,rowIndex:m,colIndex:f};P=E.rowSpan(N)}else typeof E.rowSpan=="number"&&(P=E.rowSpan);if(P>1){M[g.id]||(M[g.id]={}),M[g.id][E.field]=P;for(let N=1;N<P;N++){const v=m+N;if(v<k&&n[v]){const I=n[v];j[I.id]||(j[I.id]={}),j[I.id][E.field]=!0,x[v]||(x[v]={}),x[v][E.field]=m}}}}}),d({caches:{spannedCells:M,hiddenCells:j,hiddenCellOriginMap:x},processedRange:{firstRowIndex:C,lastRowIndex:k}})},[n,t]),w=l.useCallback(()=>{d({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}})},[]);l.useEffect(()=>{const C=new Map;n.forEach((x,E)=>{for(let f=0;f<t.length;f++){const m=t[f];if(!m)continue;let g=1;if(m.colSpan)if(typeof m.colSpan=="function"){const P={row:x,value:x[m.field],field:m.field,colDef:m,rowIndex:E,colIndex:f};g=m.colSpan(P)}else g=m.colSpan;if(g<=1){const P=e[m.field]||(typeof m.width=="number"?m.width:100);Ue(C,x.id,m.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:P}});continue}let S=e[m.field]||(typeof m.width=="number"?m.width:100);for(let P=1;P<g;P++)if(f+P<t.length){const N=t[f+P];if(N){const v=e[N.field]||(typeof N.width=="number"?N.width:100);S+=v,Ue(C,x.id,N.field,{spannedByColSpan:!0,leftVisibleCellIndex:f,rightVisibleCellIndex:Math.min(f+g-1,t.length-1)})}}Ue(C,x.id,m.field,{spannedByColSpan:!1,cellProps:{colSpan:g,width:S}}),f+=g-1}}),i(C);const k={},M={},j={};t.forEach((x,E)=>{if(x.rowSpan)for(let f=0;f<n.length;f++){const m=n[f];if(!m||M[m.id]?.[x.field])continue;const g=x.valueGetter?x.valueGetter({row:m,field:x.field,value:m[x.field]}):m[x.field];let S=1;if(typeof x.rowSpan=="function"){const P={row:m,value:g,field:x.field,colDef:x,rowIndex:f,colIndex:E};S=x.rowSpan(P)}else typeof x.rowSpan=="number"&&(S=x.rowSpan);if(S>1){k[m.id]||(k[m.id]={}),k[m.id][x.field]=S;for(let P=1;P<S;P++){const N=f+P;if(N<n.length&&n[N]){const v=n[N];M[v.id]||(M[v.id]={}),M[v.id][x.field]=!0,j[N]||(j[N]={}),j[N][x.field]=f}}}}}),d({caches:{spannedCells:k,hiddenCells:M,hiddenCellOriginMap:j},processedRange:{firstRowIndex:0,lastRowIndex:n.length}})},[n,t,e]);const h=l.useCallback(()=>s.caches.spannedCells,[s]),b=l.useCallback(()=>s.caches.hiddenCells,[s]),_=l.useCallback(()=>s.caches.hiddenCellOriginMap,[s]);return{colspanMap:o,resetColSpan:a,getCellColSpanInfo:u,calculateColSpan:c,rowSpanningState:s,calculateRowSpan:p,resetRowSpan:w,getSpannedCells:h,getHiddenCells:b,getHiddenCellOriginMap:_}}function Ue(n,t,e,o){let i=n.get(t);i||(i={},n.set(t,i)),i[e]=o}function Jo(n){const{dataSource:t,sortModel:e,filterModel:o,paginationModel:i,paginationMode:s,sortingMode:d,filterMode:a,aggregationModel:u,setRows:c,setRowCount:p,setDataSourceLoading:w,setDataSourceError:h,onAggregationResults:b}=n,_=l.useRef(null),C=l.useRef(0),k=l.useCallback(async()=>{if(!t)return;const j=++C.current;w(!0),h(null);const x=i.page*i.pageSize,E=x+i.pageSize,f={startRow:x,endRow:E,sortModel:e,filterModel:o,groupKeys:[],aggregationModel:u};try{const m=await t.getRows(f);if(j!==C.current)return;let g=!1;if(s==="infinite"){const S=_.current;if(S){const P=JSON.stringify(S.sortModel)!==JSON.stringify(e),N=JSON.stringify(S.filterModel)!==JSON.stringify(o),v=S.pageSize!==i.pageSize;!P&&!N&&!v&&i.page>S.page&&(g=!0)}}c(g?S=>[...S,...m.rows]:m.rows,!0),m.aggregationResults&&b&&b(m.aggregationResults),m.rowCount!==void 0&&p(m.rowCount),_.current={sortModel:e,filterModel:o,page:i.page,pageSize:i.pageSize}}catch(m){j===C.current&&(h(m),console.error("Data Source Error:",m))}finally{j===C.current&&w(!1)}},[t,i.page,i.pageSize,e,o,s,u,b,c,p,w,h]);l.useEffect(()=>{if(t&&(s==="server"||s==="infinite"||d==="server"||a==="server")){const x=setTimeout(()=>{k()},300);return()=>clearTimeout(x)}},[k,t,s,d,a]);const M=l.useCallback(async(j,x)=>{if(t){w(!0);try{const E=await t.getRows({startRow:0,endRow:-1,sortModel:e,filterModel:o,groupKeys:x});E.rows.length>0&&c(f=>{const m=new Set(f.map(S=>S.id)),g=E.rows.filter(S=>!m.has(S.id));return[...f,...g]})}catch(E){h(E),console.error("Failed to fetch children:",E)}finally{w(!1)}}},[t,e,o,c,w,h]);return{fetchRows:k,fetchChildren:M}}const Cn="\0",ft="";function Qo(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 Ct(n,t){return t.map(e=>String(n[e]??"")).join(Cn)}function Gt(n,t,e,o){return o?`${n}${ft}${t}${ft}${e}`:`${t}${ft}${e}`}function yn(n,t,e,o){return l.useMemo(()=>{const i={pivotRows:[],pivotColumns:[],colKeys:[],isValid:!1};if(!o)return i;const{rowFields:s,columnFields:d,valueFields:a}=e;if(s.length===0||a.length===0)return i;const u=d.length>0,c=new Map(t.map(j=>[j.field,j])),p=new Set;for(const j of n)p.add(Ct(j,d));const w=Array.from(p).sort(),h=new Map;for(const j of n){const x=Ct(j,s);if(!h.has(x)){const g={};for(const S of s)g[S]=j[S];h.set(x,{labelValues:g,bucket:new Map})}const E=h.get(x),f=Ct(j,d);E.bucket.has(f)||E.bucket.set(f,new Map);const m=E.bucket.get(f);for(const g of a){const S=j[g.field];m.has(g.field)||m.set(g.field,[]),S!=null&&!isNaN(Number(S))&&m.get(g.field).push(Number(S))}}let b=0;const _=[];for(const[,j]of h){const x={id:b++,...j.labelValues};for(const E of w){const f=j.bucket.get(E);for(const m of a){const g=Gt(E,m.field,m.aggFn,u),S=f?.get(m.field)??[];x[g]=S.length>0?Qo(S,m.aggFn):null}}_.push(x)}const C=new Map;for(const j of n){const x=Ct(j,d);for(const E of a){if(E.aggFn!=="avg"&&E.aggFn!=="min"&&E.aggFn!=="max")continue;const f=`${x}${ft}${E.field}`;C.has(f)||C.set(f,[]);const m=j[E.field];m!=null&&!isNaN(Number(m))&&C.get(f).push(Number(m))}}const k={id:"__pivot_grand_total__"};for(let j=0;j<s.length;j++)k[s[j]]=j===0?"Grand Total":"";for(const j of w)for(const x of a){const E=Gt(j,x.field,x.aggFn,u),f=_.map(g=>g[E]).filter(g=>g!=null&&!isNaN(Number(g))).map(Number);if(f.length===0){k[E]=null;continue}const m=`${j}${ft}${x.field}`;switch(x.aggFn){case"sum":case"count":k[E]=f.reduce((g,S)=>g+S,0);break;case"avg":{const g=C.get(m)??[];k[E]=g.length>0?g.reduce((S,P)=>S+P,0)/g.length:null;break}case"min":k[E]=Math.min(...C.get(m)??f);break;case"max":k[E]=Math.max(...C.get(m)??f);break}}_.push(k);const M=[];for(const j of s){const x=c.get(j);M.push({field:j,headerName:x?.headerName??j,width:x?.width??140,sortable:!0})}for(const j of w){const x=u?j.split(Cn).map((E,f)=>{const m=c.get(d[f]);return m?.headerName?`${m.headerName}: ${E}`:E}).join(" / "):"";for(const E of a){const f=c.get(E.field),m=Gt(j,E.field,E.aggFn,u),g=E.headerName??f?.headerName??E.field,S=x?`${x} — ${g} (${E.aggFn})`:`${g} (${E.aggFn})`;M.push({field:m,headerName:S,width:140,type:"number",align:"right",headerAlign:"right",sortable:!0,valueFormatter:({value:P})=>{if(P==null)return"—";const N=Number(P);return E.aggFn==="avg"?N.toFixed(2):E.aggFn==="count"?N.toLocaleString():f?.valueFormatter?f.valueFormatter({value:P,row:{},field:E.field}):N.toLocaleString()}})}}return{pivotRows:_,pivotColumns:M,colKeys:w,isValid:!0}},[n,t,e,o])}function Zo(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 er(n){let t=!1;try{t=Zo(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 tr(n){const{selectedRowIds:t,columns:e,getVisibleRows:o,getRowId:i}=n,s=l.useCallback(async()=>{if(t.size===0)return;const a=o().filter(h=>t.has(i(h)));if(a.length===0)return;const u=e.filter(h=>!h.field.startsWith("__")),c=u.map(h=>h.headerName||h.field).join(" "),p=a.map(h=>u.map(b=>{const _=h[b.field];return b.valueFormatter?b.valueFormatter({value:_,row:h,field:b.field}):_??""}).join(" ")).join(`
7
+ `),w=`${c}
8
+ ${p}`;try{await er(w)}catch(h){console.error("[OpenGridX] Failed to copy to clipboard:",h)}},[t,e,o,i]);return l.useEffect(()=>{const d=a=>{if(!(a.ctrlKey||a.metaKey)||a.key!=="c")return;const u=document.activeElement,c=u?.tagName.toLowerCase(),p=u?.type;c==="input"&&p!=="checkbox"&&p!=="radio"||c==="textarea"||c==="select"||u?.isContentEditable||s()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[s]),{copySelectedRows:s}}function nr({row:n,rowIndex:t,listViewColumn:e,isSelected:o=!1,checkboxSelection:i=!1,rowHeight:s,onRowClick:d,onSelectionChange:a}){const u={row:n,value:void 0,field:e.field,colDef:{field:e.field},rowIndex:t,colIndex:0},c=p=>{p.stopPropagation(),a?.(n.id,p.target.checked)};return r.jsxs("div",{className:`ogx-list-view__row${o?" ogx-list-view__row--selected":""}`,style:s?{minHeight:s}:void 0,onClick:()=>d?.(n),role:"row","aria-rowindex":t+2,"aria-selected":o,children:[i&&r.jsx("div",{className:"ogx-list-view__checkbox",onClick:p=>p.stopPropagation(),children:r.jsx("input",{type:"checkbox",checked:o,onChange:c,"aria-label":`Select row ${n.id}`})}),r.jsx("div",{className:"ogx-list-view__cell",role:"gridcell",children:e.renderCell(u)})]})}function or({ariaLabel:n,allRenderableRows:t,filteredRows:e,pagination:o,effectivePaginationModel:i,pageSizeOptions:s,selectedRowIds:d,listViewColumn:a,noRowsLabel:u,rowHeight:c,checkboxSelection:p,paginationMode:w,dataSource:h,serverRowCount:b,paginationSlot:_,paginationSlotProps:C,localeText:k,onRowClick:M,onSelectionChange:j,onPaginationModelChange:x}){const E=_||_n,f=w==="server"&&h?b||0:e.length;return r.jsxs("div",{className:"ogx-list-view",role:"grid","aria-label":n||"Data grid list view","aria-rowcount":t.length+1,children:[r.jsx("div",{className:"ogx-list-view__toolbar",children:r.jsxs("span",{children:[e.length," ",e.length===1?"item":"items",o?` · page ${i.page+1} of ${Math.ceil(e.length/i.pageSize)||1}`:"",d.size>0?` · ${d.size} selected`:""]})}),r.jsx("div",{className:"ogx-list-view__rows",children:t.length===0?r.jsxs("div",{className:"ogx-list-view__empty","aria-live":"polite",role:"status",children:[r.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[r.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),r.jsx("path",{d:"M3 9h18M9 21V9"})]}),u]}):t.map((m,g)=>r.jsx(nr,{row:m,rowIndex:g,listViewColumn:a,isSelected:d.has(m.id),checkboxSelection:p,rowHeight:c,onRowClick:S=>M({row:S,id:S.id,rowIndex:g}),onSelectionChange:j},m.id))}),o&&r.jsx(E,{page:i.page,pageSize:i.pageSize,rowCount:f,pageSizeOptions:s,onPageChange:m=>x({...i,page:m}),onPageSizeChange:m=>x({...i,pageSize:m,page:0}),localeText:k,...C})]})}function rr({value:n,onValueChange:t,onCommit:e,onCancel:o}){const[i,s]=l.useState(String(n??"")),d=l.useRef(null);return l.useEffect(()=>{d.current?.focus(),d.current?.select()},[]),r.jsx("input",{ref:d,type:"text",className:"ogx__edit-input",value:i,onChange:a=>{s(a.target.value),t(a.target.value)},onBlur:e,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),e()),a.key==="Escape"&&(a.stopPropagation(),o())}})}function ir({value:n,onValueChange:t,onCommit:e,onCancel:o}){const[i,s]=l.useState(typeof n=="number"?n:""),d=l.useRef(null);return l.useEffect(()=>{d.current?.focus(),d.current?.select()},[]),r.jsx("input",{ref:d,type:"number",className:"ogx__edit-input ogx__edit-input--number",value:i,onChange:a=>{const u=a.target.value===""?"":Number(a.target.value);s(u),t(u===""?null:u)},onBlur:e,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),e()),a.key==="Escape"&&(a.stopPropagation(),o())}})}function lr({value:n,onValueChange:t,onCommit:e,onCancel:o}){const i=l.useRef(null);l.useEffect(()=>{i.current?.focus()},[]);const s=()=>{t(!n),setTimeout(e,0)};return r.jsx("div",{className:"ogx__edit-boolean",children:r.jsx("input",{ref:i,type:"checkbox",className:"ogx__edit-checkbox",checked:!!n,onChange:s,onKeyDown:d=>{d.key==="Escape"&&(d.stopPropagation(),o())}})})}function sr({value:n,colDef:t,onValueChange:e,onCommit:o,onCancel:i}){const s=l.useRef(null);l.useEffect(()=>{s.current?.focus()},[]);const d=t.valueOptions??[];return r.jsx("select",{ref:s,className:"ogx__edit-select",value:String(n??""),onChange:a=>{e(a.target.value)},onBlur:o,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),o()),a.key==="Escape"&&(a.stopPropagation(),i())},children:d.map(a=>{const u=typeof a=="object"?a.value:a,c=typeof a=="object"?a.label:String(a);return r.jsx("option",{value:String(u),children:c},String(u))})})}function ar({value:n,onValueChange:t,onCommit:e,onCancel:o}){const[i,s]=l.useState(typeof n=="string"?n:String(n??"")),d=l.useRef(null);return l.useEffect(()=>{d.current?.focus()},[]),r.jsx("input",{ref:d,type:"date",className:"ogx__edit-input",value:i,onChange:a=>{s(a.target.value),t(a.target.value)},onBlur:e,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),e()),a.key==="Escape"&&(a.stopPropagation(),o())}})}function dr(n){const{colDef:t}=n;switch(t.type){case"number":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(ir,{...n})});case"boolean":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(lr,{...n})});case"singleSelect":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(sr,{...n})});case"date":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(ar,{...n})});default:return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(rr,{...n})})}}class cr extends l.Component{constructor(t){super(t),this.state={hasError:!1,error:null,resetKey:t.resetKey}}static getDerivedStateFromProps(t,e){return e.hasError&&t.resetKey!==e.resetKey?{hasError:!1,error:null,resetKey:t.resetKey}:t.resetKey!==e.resetKey?{resetKey:t.resetKey}:null}static getDerivedStateFromError(t){return{hasError:!0,error:t}}render(){return this.state.hasError?r.jsx("div",{className:"ogx__cell-error",role:"status","aria-label":`Error in cell: ${this.props.field}`,title:this.state.error?.message??"Render error",children:"⚠"}):this.props.children}}function ur(n){const{onCellClick:t,onCellEditStart:e,onCellValueChange:o,value:i,row:s,colDef:d,rowIndex:a,colIndex:u,isSelected:c,onClick:p,width:w,pinnedPosition:h,pinnedOffset:b,isFocused:_,isFocusVisible:C,isEditable:k,isEditing:M,onEditStart:j,onEditStop:x,onValueChange:E,colSpanInfo:f,rowSpan:m,isHiddenByRowSpan:g,rowMeta:S}=n,P=l.useCallback(y=>{o?o(d.field,y):E?.(y)},[o,E,d.field]),N=l.useMemo(()=>d.valueFormatter?d.valueFormatter({value:i,row:s,field:d.field}):i==null?"":String(i),[i,s,d]),v=l.useMemo(()=>d.cellClassName?typeof d.cellClassName=="function"?d.cellClassName({value:i,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:u})||"":d.cellClassName:"",[d,i,s,a,u]),I=l.useRef(null);if(l.useLayoutEffect(()=>{_&&I.current&&I.current.focus({preventScroll:!0})},[_]),f?.spannedByColSpan)return null;if(g)return r.jsx("div",{className:"ogx__cell ogx__cell--hidden",style:{width:w??d.width??100},role:"presentation","data-field":d.field,"data-colindex":u});const R=y=>{t&&t({row:s,field:d.field,value:i,colDef:d,rowIndex:a,colIndex:u}),p?.(y)},W=y=>{k&&(j||e)&&(y.stopPropagation(),e?e(d.field,i):j?.())},F=h!=null,U=["ogx__cell",`ogx__cell--align-${d.align||"left"}`,c&&"ogx__cell--selected",_&&"ogx__cell--focused",_&&C&&"ogx__cell--focus-visible",d.type&&`ogx__cell--type-${d.type}`,F&&"ogx__cell--pinned",F&&`ogx__cell--pinned-${h}`,M&&"ogx__cell--editing",m&&m>1&&"ogx__cell--spanned",v].filter(Boolean).join(" "),T=f?.cellProps?.colSpan||1,B=m||1,G=f?.cellProps?.width??w??d.width??100,V={width:"var(--width)","--width":typeof G=="number"?`${G}px`:G,flexGrow:d.flex??0,flexShrink:0,flexBasis:(d.flex,"auto"),boxSizing:"border-box",minWidth:d.minWidth,maxWidth:d.maxWidth,position:F?"sticky":void 0,zIndex:d.zIndex??(F?3:void 0),padding:M?0:void 0};return B>1&&(V.height=`calc(var(--height) * ${B} - var(--border-width, 1px))`,V.zIndex=10,F&&(V.zIndex=40)),F&&b!==void 0&&(h==="left"?V.left=b:V.right=b),r.jsx("div",{ref:I,className:U,style:V,onClick:R,onDoubleClick:W,role:"gridcell","aria-colindex":u+1,"aria-readonly":!k||void 0,tabIndex:-1,"data-field":d.field,"data-colindex":u,...T>1?{"aria-colspan":T}:{},...B>1?{"aria-rowspan":B}:{},children:r.jsx("div",{className:"ogx__cell-content",children:M&&(o||E)&&x?d.renderEditCell?d.renderEditCell({value:i,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:u,rowMeta:S}):r.jsx(dr,{value:i,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:u,onValueChange:P,onCommit:()=>x(),onCancel:()=>x(!0)}):d.renderCell?r.jsx(cr,{field:d.field,resetKey:i,children:d.renderCell({value:i,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:u,rowMeta:S})}):N})})}const kn=l.memo(ur),fr=({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 gr(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 yt(n){const{row:t,columns:e,rowIndex:o,isSelected:i=!1,checkboxSelection:s=!1,onRowClick:d,onCellClick:a,onSelectionChange:u,columnWidths:c={},pinnedColumns:p,pinnedRows:w,hasDetailPanel:h=!1,isDetailPanelExpanded:b=!1,onDetailPanelToggle:_,detailPanelContent:C,detailPanelHeight:k=200,pinCheckboxColumn:M=!0,pinExpandColumn:j=!0,rowReordering:x=!1,onDragStart:E,onDragOver:f,onDragEnd:m,onDrop:g,isDragging:S,isDragOver:P,editingCell:N,onEditStart:v,onEditStop:I,onEditCellValueChange:R,focusedCellField:W,isFocusVisible:F,colspanMap:U,rowSpanningCaches:T,rowHeight:B=52,rowMeta:G}=n,V=l.useId(),y=l.useRef(null),L=l.useRef(null);l.useLayoutEffect(()=>{W==="__expand_col__"&&y.current&&y.current.focus({preventScroll:!0}),W==="__checkbox_col__"&&L.current&&L.current.focus({preventScroll:!0})},[W]);const z=l.useMemo(()=>Bt(e,c,p,s,M,h,j,x),[e,c,p,s,M,h,j,x]),$=G?.hasChildren===!0,H=l.useCallback((A,ie)=>{$||v?.({id:t.id,field:A,value:ie})},[$,t.id,v]),X=l.useCallback((A,ie)=>{R?.({id:t.id,field:A,value:ie})},[R,t.id]),Y=l.useCallback(A=>{I?.({cancel:A})},[I]);if(t._isSkeleton){const A=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:A}).map((ie,se)=>r.jsx("div",{className:"ogx__skeleton-cell",children:r.jsx("div",{className:"ogx__skeleton-bar"})},se))})}const te=A=>{A.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell")||d?.({row:t,id:t.id,rowIndex:o})},O=A=>{A.stopPropagation(),u?.(t.id,A.target.checked)},J=A=>{A.stopPropagation(),_?.(t.id)},Q=$t(t.id,w),le=Q==="top",oe=Q==="bottom",pe=["ogx__row",i&&"ogx__row--selected",o%2===0&&"ogx__row--even",o%2===1&&"ogx__row--odd",le&&"ogx__row--pinned-top",oe&&"ogx__row--pinned-bottom",S&&"ogx__row--dragging",P&&"ogx__row--drag-over",$&&"ogx__row--group"].filter(Boolean).join(" ");return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:pe,onClick:te,role:"row","aria-rowindex":o+1,"aria-selected":i,"data-rowindex":o,onDragOver:f?f(t.id):void 0,onDrop:g?g(t.id):void 0,style:{maxHeight:`${B}px`,minHeight:`${B}px`,"--height":`${B}px`,"--border-width":"1px"},children:[x&&r.jsx("div",{className:"ogx__cell ogx__cell--drag-handle",role:"gridcell","aria-label":"Drag to reorder row",style:{position:"sticky",left:0,zIndex:4},draggable:!0,onDragStart:E?E(t.id):void 0,onDragEnd:m,onClick:A=>A.stopPropagation(),children:r.jsx(fr,{})}),h&&r.jsx("div",{className:`ogx__cell ogx__cell--expand ${j?"ogx__cell--pinned-left":""} ${W==="__expand_col__"?"ogx__cell--focused":""} ${W==="__expand_col__"&&F?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":b?"Collapse row details":"Expand row details","aria-expanded":b,style:{position:j?"sticky":void 0,left:j?x?48:0:void 0,zIndex:j?5:void 0},ref:y,tabIndex:-1,onClick:A=>{A.stopPropagation(),a?.({row:t,field:"__expand_col__",value:b,colDef:{field:"__expand_col__",width:48},rowIndex:o,colIndex:-1})},children:r.jsx(mn,{isExpanded:b,onClick:J,variant:"plus-minus"})}),s&&r.jsx("div",{className:`ogx__cell ogx__cell--checkbox ${M?"ogx__cell--pinned-left":""} ${W==="__checkbox_col__"?"ogx__cell--focused":""} ${W==="__checkbox_col__"&&F?"ogx__cell--focus-visible":""}`,role:"gridcell",style:{position:M?"sticky":void 0,left:M?(x?48:0)+(h&&j?48:0):void 0,zIndex:M?11:void 0},ref:L,tabIndex:-1,onClick:A=>{A.stopPropagation(),a?.({row:t,field:"__checkbox_col__",value:i,colDef:{field:"__checkbox_col__",width:48},rowIndex:o,colIndex:-1})},children:r.jsx(ct,{id:V,name:`ogx-select-row-${t.id}`,checked:i,onChange:O,onClick:A=>A.stopPropagation(),"aria-label":i?`Deselect row ${t.id}`:`Select row ${t.id}`,tabIndex:-1,onMouseDown:A=>A.preventDefault()})}),e.map((A,ie)=>{if(A.isSpacer)return r.jsx("div",{style:{width:A.width,minWidth:A.width,flexShrink:0},"aria-hidden":"true"},A.field);const se=A.valueGetter?A.valueGetter({row:t,field:A.field,value:t[A.field]}):t[A.field],D=c[A.field]??A.width,q=dt(A.field,p),ee=q?z[A.field]:void 0,de=N?.id===t.id&&N?.field===A.field,ce=de?N?.value:se,je=U?.get(t.id)?.[A.field],We=T?.spannedCells[t.id]?.[A.field],Ee=T?.hiddenCells[t.id]?.[A.field]||!1;return r.jsx(kn,{value:ce,row:t,colDef:A,rowIndex:o,colIndex:ie,isSelected:i,onCellClick:a,width:D,pinnedPosition:q,pinnedOffset:ee,isFocused:W===A.field,isFocusVisible:F,isEditable:A.editable,isEditing:de,onCellEditStart:H,onEditStop:Y,onCellValueChange:X,colSpanInfo:je,rowSpan:We,isHiddenByRowSpan:Ee,rowMeta:G},A.field)})]}),h&&r.jsx(gr,{row:t,rowId:t.id,rowIndex:o,content:C,height:k,isExpanded:b})]})}function Sn({rows:n,position:t,columns:e,selectedRowIds:o,checkboxSelection:i,onRowClick:s,onCellClick:d,onSelectionChange:a,columnWidths:u,pinnedColumns:c,pinnedRows:p,hasDetailPanel:w,expandedRowIds:h,getDetailPanelContent:b,getDetailPanelHeight:_,onDetailPanelToggle:C,pinCheckboxColumn:k,pinExpandColumn:M,focusedCell:j,colspanMap:x,rowSpanningCaches:E,rowHeight:f,rowMetaMap:m}){return n.length===0?null:r.jsx("div",{className:`ogx__pinned-rows ogx__pinned-rows--${t}`,role:"rowgroup",children:n.map((g,S)=>r.jsx(yt,{row:g,columns:e,rowIndex:S,isSelected:o.has(g.id),checkboxSelection:i,onRowClick:s,onCellClick:d,onSelectionChange:a,columnWidths:u,pinnedColumns:c,pinnedRows:p,hasDetailPanel:w,isDetailPanelExpanded:h.has(g.id),detailPanelContent:b?b({row:g,id:g.id,rowIndex:S}):null,detailPanelHeight:_?.({row:g,id:g.id,rowIndex:S})||200,onDetailPanelToggle:C,pinCheckboxColumn:k,pinExpandColumn:M,focusedCellField:j?.id===g.id?j.field:null,colspanMap:x,rowSpanningCaches:E,rowHeight:f,rowMeta:m.get(g.id)},g.id))})}const hr=({columns:n,rowHeight:t,checkboxSelection:e=!1,hasDetailPanel:o=!1,rowReordering:i=!1})=>r.jsxs("div",{className:"ogx__row ogx__skeleton-row",style:{height:t},role:"row",children:[e&&r.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:r.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),o&&r.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:r.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),i&&r.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:r.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),n.map((s,d)=>{const a=typeof s.width=="number"?s.width:150,u=Math.min(a*.7,a-20);return r.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:a,minWidth:s.minWidth,maxWidth:s.maxWidth,left:s.left,right:s.right,position:s.isSpacer?"relative":s.pinned?"sticky":"relative",zIndex:s.zIndex},children:!s.isSpacer&&r.jsx("div",{className:"ogx-skeleton-box",style:{width:u,height:16,borderRadius:4}})},s.field||d)})]});function pr({virtualContainerHeight:n,offsetTop:t,effectiveLoading:e,visibleRows:o,baseColumns:i,virtualColumns:s,viewportWidth:d,checkboxSelection:a,hasDetailPanel:u,rowReordering:c,rowHeight:p,pinnedRows:w,selectedRowIds:h,onRowClick:b,onCellClick:_,onSelectionChange:C,columnWidths:k,pinnedColumns:M,expandedRowIds:j,getDetailPanelContent:x,getDetailPanelHeight:E,onDetailPanelToggle:f,pinCheckboxColumn:m,pinExpandColumn:g,rowReorderHandlers:S,editingHandlers:P,focusedCell:N,colspanMap:v,rowSpanningCaches:I,paginationMode:R,dataSourceLoading:W,sortedUnpinnedRowCount:F,infiniteScrollSkeletonCount:U,unpinnedRowsLength:T,rowMetaMap:B}){const G=i.length>0?i:(()=>{const y=(d||1e3)-(a?48:0)-(u?48:0)-(c?48:0),L=150,z=Math.max(1,Math.ceil(y/L));return Array.from({length:z},($,H)=>({field:`placeholder_${H}`,headerName:"",width:L}))})(),V=o.filter(({row:y})=>!$t(y.id,w)).filter((y,L,z)=>L===z.findIndex($=>$.row.id===y.row.id));return r.jsx("div",{className:"ogx__virtual-container",style:{height:`${n}px`},role:"presentation",children:r.jsxs("div",{className:"ogx__rows",style:{transform:`translateY(${t}px)`},role:"rowgroup",children:[e&&o.length===0?Array.from({length:10}).map((y,L)=>r.jsx(hr,{columns:G,rowHeight:p,checkboxSelection:a,hasDetailPanel:u,rowReordering:c},`skeleton-${L}`)):V.map(({row:y,rowIndex:L})=>r.jsx(yt,{row:y,columns:s,rowIndex:L,isSelected:h.has(y.id),checkboxSelection:a,onRowClick:b,onCellClick:_,onSelectionChange:C,columnWidths:k,pinnedColumns:M,pinnedRows:w,hasDetailPanel:u,isDetailPanelExpanded:j.has(y.id),detailPanelContent:x?x({row:y,id:y.id,rowIndex:L}):null,detailPanelHeight:E?.({row:y,id:y.id,rowIndex:L})||200,onDetailPanelToggle:f,pinCheckboxColumn:m,pinExpandColumn:g,rowReordering:c,onDragStart:S.onDragStart,onDragOver:S.onDragOver,onDragEnd:S.onDragEnd,onDrop:S.onDrop,isDragging:S.draggedRowId===y.id,isDragOver:S.dragOverRowId===y.id,editingCell:P.editingCell,onEditStart:P.startCellEdit,onEditStop:P.stopCellEdit,onEditCellValueChange:P.setEditCellValue,focusedCellField:N!=null&&N.id===y.id?N.field:null,colspanMap:v,rowSpanningCaches:I,rowHeight:p,rowMeta:B.get(y.id)},y.id)),R==="infinite"&&W&&F>0&&r.jsx("div",{className:"ogx__skeleton-group",children:Array.from({length:U}).map((y,L)=>r.jsx(yt,{row:{id:`__skeleton_${L}__`,_isSkeleton:!0},columns:s,rowIndex:T+L,rowHeight:p},`__skeleton_${L}__`))})]})})}function xr(){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 mr(){return r.jsxs("svg",{className:"ogx-column-visibility-panel__drag-handle",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[r.jsx("circle",{cx:"9",cy:"5",r:"1.5"}),r.jsx("circle",{cx:"15",cy:"5",r:"1.5"}),r.jsx("circle",{cx:"9",cy:"12",r:"1.5"}),r.jsx("circle",{cx:"15",cy:"12",r:"1.5"}),r.jsx("circle",{cx:"9",cy:"19",r:"1.5"}),r.jsx("circle",{cx:"15",cy:"19",r:"1.5"})]})}function jn(n){const{columns:t,visibleColumns:e,onVisibilityChange:o,onShowAll:i,onHideAll:s,onColumnReorder:d,onColumnOrderReset:a}=n,[u,c]=l.useState(""),[p,w]=l.useState(null),h=l.useRef(null),_=l.useMemo(()=>t.filter(m=>m.hideable!==!1),[t]).every(m=>e.has(m.field)),C=l.useMemo(()=>{if(!u)return t;const m=u.toLowerCase();return t.filter(g=>(g.headerName||g.field).toLowerCase().includes(m))},[t,u]),k=m=>{m.target.checked?i():s()},M=m=>g=>{h.current=m,g.dataTransfer.effectAllowed="move",g.dataTransfer.setDragImage(g.currentTarget.closest(".ogx-column-visibility-panel__item"),20,20)},j=m=>g=>{g.preventDefault(),g.dataTransfer.dropEffect="move",m!==h.current&&w(m)},x=()=>{w(null)},E=m=>g=>{g.preventDefault();const S=h.current;w(null),h.current=null,S&&S!==m&&d&&d(S,m)},f=()=>{w(null),h.current=null};return r.jsxs("div",{className:"ogx-column-visibility-panel",children:[r.jsx("div",{className:"ogx-column-visibility-panel__search-section",children:r.jsxs("div",{className:"ogx-column-visibility-panel__search-container",children:[r.jsx(xr,{}),r.jsx("input",{autoComplete:"off",className:"ogx-column-visibility-panel__search-input",placeholder:"Search",value:u,onChange:m=>c(m.target.value)})]})}),r.jsx("div",{className:"ogx-column-visibility-panel__list",children:C.map(m=>{const g=e.has(m.field),S=m.hideable!==!1,P=p===m.field,N=!!d&&!u;return r.jsxs("div",{className:["ogx-column-visibility-panel__item",!S&&"ogx-column-visibility-panel__item--disabled",P&&"ogx-column-visibility-panel__item--drag-over"].filter(Boolean).join(" "),draggable:N,onDragOver:N?j(m.field):void 0,onDragLeave:N?x:void 0,onDrop:N?E(m.field):void 0,onDragEnd:N?f:void 0,children:[N&&r.jsx("span",{className:"ogx-column-visibility-panel__drag-handle-wrapper",draggable:!0,onDragStart:M(m.field),title:"Drag to reorder",children:r.jsx(mr,{})}),r.jsxs("label",{className:"ogx-column-visibility-panel__item-label",style:{display:"flex",alignItems:"center",gap:"var(--ogx-spacing-md)",flex:1,cursor:S?"pointer":"not-allowed"},children:[r.jsx(ct,{checked:g,onChange:v=>o(m.field,v.target.checked),disabled:!S}),r.jsx("span",{className:"ogx-column-visibility-panel__label",children:m.headerName||m.field})]})]},m.field)})}),r.jsxs("div",{className:"ogx-column-visibility-panel__footer",children:[r.jsxs("label",{className:"ogx-column-visibility-panel__item",children:[r.jsx(ct,{checked:_,onChange:k}),r.jsx("span",{className:"ogx-column-visibility-panel__label",children:"Show/Hide All"})]}),r.jsx("button",{className:"ogx-column-visibility-panel__reset-btn",onClick:()=>{i(),a?.()},children:"Reset"})]})]})}function br({isOpen:n,containerRef:t,panelRef:e,effectiveColumns:o,columnVisibilityModel:i,effectiveColumnOrder:s,columnOrder:d,disableColumnReorder:a,onClose:u,onColumnVisibilityChange:c,onColumnOrderChange:p,setInternalColumnOrder:w}){const[h,b]=l.useState(16),[_,C]=l.useState(16),[k,M]=l.useState(()=>document.body);if(l.useLayoutEffect(()=>{if(!n||!t.current)return;const x=t.current.getBoundingClientRect();b(x.top+8),C(window.innerWidth-x.right+8),M(t.current.closest(".ogx-theme-provider")||document.body)},[n,t]),!n)return null;const j=a?void 0:(x,E)=>{const f=[...s],m=f.indexOf(x),g=f.indexOf(E);if(m===-1||g===-1)return;const S=[...f];S.splice(m,1),S.splice(g,0,x),d||w(S),p?.({oldIndex:m,targetIndex:g,column:o.find(P=>P.field===x)})};return ze.createPortal(r.jsxs("div",{ref:e,style:{position:"fixed",top:h,right:_,zIndex:9999,display:"inline-block"},children:[r.jsx("button",{onClick:u,style:{position:"absolute",top:-12,right:-12,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",background:"#334155",color:"#fff",border:"none",borderRadius:"50%",cursor:"pointer",fontSize:14,lineHeight:1,zIndex:1,boxShadow:"0 1px 4px rgba(0,0,0,0.2)"},"aria-label":"Close",children:"×"}),r.jsx(jn,{columns:o,visibleColumns:new Set(o.filter(x=>i[x.field]!==!1).map(x=>x.field)),onVisibilityChange:(x,E)=>{c({...i,[x]:E})},onShowAll:()=>{const x={...i};o.forEach(E=>{E.hideable!==!1&&(x[E.field]=!0)}),c(x)},onHideAll:()=>{const x={...i};o.forEach(E=>{E.hideable!==!1&&(x[E.field]=!1)}),c(x)},onColumnReorder:j})]}),k)}const wr=new Map;function vr(n){const{rows:t,columns:e,getRowId:o,rowHeight:i=52,headerHeight:s=56,autoHeight:d=!1,checkboxSelection:a=!1,rowSelectionModel:u,onRowSelectionModelChange:c,onRowClick:p,onCellClick:w,filterModel:h,onFilterModelChange:b,sortModel:_,onSortModelChange:C,pagination:k=!1,paginationModel:M={page:0,pageSize:100},onPaginationModelChange:j,pageSizeOptions:x=[10,25,50,100],pinnedColumns:E,onPinnedColumnsChange:f,pinnedRows:m,getDetailPanelContent:g,getDetailPanelHeight:S,detailPanelExpandedRowIds:P,onDetailPanelExpandedRowIdsChange:N,pinCheckboxColumn:v=!0,pinExpandColumn:I=!0,disableColumnReorder:R=!1,columnOrder:W,onColumnOrderChange:F,height:U,rowReordering:T=!1,onRowOrderChange:B,loading:G=!1,treeData:V=!1,getTreeDataPath:y,defaultGroupingExpansionDepth:L,rowGroupingModel:z,aggregationModel:$,onAggregationModelChange:H,getAggregationPosition:X,isCellEditable:Y,processRowUpdate:te,onProcessRowUpdateError:O,dataSource:J,sortingMode:Q="client",filterMode:le="client",paginationMode:oe="client",rowCount:pe,slots:A,slotProps:ie,pivotMode:se=!1,pivotModel:D,onPivotModelChange:q,className:ee="",style:de,onRowsScrollEnd:ce,ariaLabel:je,initialState:We,onStateChange:Ee,columnVisibilityModel:fe,onColumnVisibilityModelChange:Ye,listView:ne=!1,listViewColumn:we,columnGroupingModel:Be,noRowsLabel:ui="No Data",localeText:Pe,apiRef:Ut}=n,Kt=Pe?.noRowsLabel??ui,fi=l.useMemo(()=>({items:[]}),[]),ke=h||fi,gi=l.useMemo(()=>[],[]),Yt=z||gi,On=l.useRef(A?.toolbar);On.current=A?.toolbar;const hi=l.useRef(K=>{const Z=On.current;return Z?Z(K):null}).current,pi=so({initialState:We,sortModel:_,aggregationModel:$,onAggregationModelChange:H,columnVisibilityModel:fe,onColumnVisibilityModelChange:Ye,pinnedColumns:E,onPinnedColumnsChange:f,pivotModel:D,onPivotModelChange:q,paginationModel:M,onPaginationModelChange:j,rowSelectionModel:u}),{sortModel:Fe,isSortControlled:Wn,setInternalSortModel:Fn,aggregationModel:Se,handleAggregationModelChange:An,columnVisibilityModel:$e,handleColumnVisibilityModelChange:kt,pinnedColumns:Ie,handlePinnedColumnsChange:qt,currentPivotModel:Xt,handlePivotModelChange:zn,effectivePaginationModel:Ce,handlePaginationModelChange:Jt,selectedRowIds:ve,isSelectionControlled:St,setInternalRowSelectionModel:jt}=pi,Et=c,Nt=yn(t,e,Xt,se),Bn=se&&Nt.isValid?Nt.pivotRows:t,Qt=se&&Nt.isValid?Nt.pivotColumns:e,[xi,$n]=l.useState(null);l.useEffect(()=>{$n(null)},[Se]);const qe=l.useRef(null),mi=l.useRef(null),Mt=l.useRef(null),bi=l.useCallback(K=>K.id,[]),Xe=o||bi,Zt=l.useMemo(()=>Bn.map(K=>{const Z=Xe(K);return Z===K.id?K:{...K,id:Z}}),[Bn,Xe]),Je=l.useCallback(K=>{fn.current?.classList.toggle("ogx--kb",K)},[]),Dn=l.useRef(J);Dn.current=J;const Hn=l.useRef(null),Gn=l.useRef(null),wi=l.useCallback(K=>{if(Dn.current&&V&&(K.serverChildrenCount??0)>0&&(K.children??[]).length===0){const Z=Gn.current?.getNodePath(K.id)||[K.groupingKey];Hn.current?.(K.id,Z)}},[V]),_e=Do({rows:Zt,columns:Qt,rowHeight:i,headerHeight:s,rowCount:pe,columnVisibilityModel:$e,initialState:n.initialState}),{state:ue,apiRef:Qe,setRows:en,setColumns:vi,setDimensions:Vn,setDataSourceLoading:_i,setDataSourceError:Ci,setRowCount:yi}=_e,{scrollTop:ki,scrollLeft:Si,handleScroll:ji}=vo({onRowsScrollEnd:ce});l.useEffect(()=>{Ut&&(Ut.current=Qe.current)},[Ut,Qe]);const{copySelectedRows:Un}=tr({selectedRowIds:ve,columns:Qt,getVisibleRows:()=>Qe.current.getVisibleRows(),getRowId:Xe});l.useEffect(()=>{Qe.current.copySelectedRows=Un,Qe.current.getSelectedRows=()=>Array.from(ve)},[Un,ve,Qe]);const Ei=ue.dataSource.loading,ht=G||Ei,Ze=l.useMemo(()=>ue.rows.allRows.map(K=>ue.rows.idRowsLookup.get(K)),[ue.rows]),pt=Go({rows:Ze,getRowId:Xe,getTreeDataPath:y,treeData:V,defaultGroupingExpansionDepth:L,filterModel:ke,sortModel:Fe,onRowExpansionChange:wi});l.useEffect(()=>{Gn.current=pt},[pt]);const tn=Yo({rows:Ze,getRowId:Xe,rowGroupingModel:Yt,aggregationModel:Se,defaultGroupingExpansionDepth:L,filterModel:ke,sortModel:Fe,getAggregationPosition:X}),et=qo({rows:Ze,getRowId:Xe,processRowUpdate:te,onProcessRowUpdateError:O,onRowChange:K=>{const{dispatch:Z}=_e,xe=Array.from(_e.state.rows.idRowsLookup.values()).map(he=>he.id===K.id?K:he);Z({type:"SET_ROWS",payload:xe})}}),xt=V,tt=!!(Yt&&Yt.length>0),nn=xt||tt,Pt=xt?pt:tt?tn:null,mt=l.useMemo(()=>xt?pt.rowMetaMap:tt?tn.rowMetaMap:wr,[xt,pt.rowMetaMap,tt,tn.rowMetaMap]),Te=k&&!tt,It=l.useCallback(K=>{const{row:Z,id:ae}=K;if(nn&&mt.get(Z.id)?.hasChildren){Pt?.toggleExpansion(ae);return}p?.(K)},[nn,Pt,p,mt]),on=Jo({dataSource:J,sortModel:Fe,filterModel:ke,paginationModel:Ce,paginationMode:oe,sortingMode:Q,filterMode:le,aggregationModel:Se,setRows:en,setRowCount:yi,setDataSourceLoading:_i,setDataSourceError:Ci,onAggregationResults:$n});l.useEffect(()=>{on.fetchChildren&&(Hn.current=on.fetchChildren)},[on.fetchChildren]),l.useEffect(()=>{J||en(Zt)},[Zt,en,J]);const Le=!!g,[Ni,Mi]=l.useState(new Set),nt=P??Ni,Tt=l.useCallback(K=>{const Z=new Set(nt);Z.has(K)?Z.delete(K):Z.add(K),P===void 0&&Mi(Z),N?.(Z)},[nt,P,N]),{effectiveColumns:Ae,orderedColumns:rn,visibleOrderedColumns:Pi,navigationColumns:Kn,columnWidths:Re,effectiveColumnOrder:Lt,setInternalColumnOrder:Rt,columnReorderHandlers:ot,handleColumnResize:Ii}=bo({activeColumns:Qt,isHierarchyEnabled:nn,isRowGrouping:tt,isTreeData:xt,activeHierarchyHandlers:Pt,columnVisibilityModel:$e,columnOrder:W,onColumnOrderChange:F,disableColumnReorder:R,pivotMode:se,checkboxSelection:a,hasDetailPanel:Le,rowReordering:T,initialState:We,setColumns:vi});_o({onStateChange:Ee,sortModel:Fe,filterModel:ke,effectivePaginationModel:Ce,columnWidths:Re,effectiveColumnOrder:Lt,columnVisibilityModel:$e,pinnedColumns:Ie});const rt=po({effectiveRows:Ze,activeHierarchyHandlers:Pt,filterMode:le,filterModel:ke,dataSource:J,sortModel:Fe,sortingMode:Q,pagination:Te,paginationMode:oe,effectivePaginationModel:Ce,pinnedRows:m,isLoading:ue.dataSource.loading,pageSize:Ce.pageSize}),De=rt.filteredRows,ln=rt.pinnedTopRows,sn=rt.pinnedBottomRows,it=rt.sortedUnpinnedRows,bt=rt.paginatedUnpinnedRows,an=rt.allRenderableRows;l.useEffect(()=>{_e.apiRef.current.getVisibleRows=()=>Te?bt:it,_e.apiRef.current.getVisibleColumns=()=>Ae},[it,bt,Te,Ae,_e.apiRef]);const Ti=Ho({rows:Te?bt:it,getRowId:K=>K.id,onRowOrderChange:B,rowReordering:T}),lt=Xo(an,Kn,Re),{aggregationResult:dn}=bn({rows:De,aggregationModel:Se,isServerSide:!!(J&&(oe==="server"||Q==="server")),dataSource:J,filterModel:ke,sortModel:Fe,serverAggregationResults:xi}),Ot=Object.keys(Se).length>0;l.useEffect(()=>{_e.apiRef.current.getAggregationResult=()=>Ot?dn:null,_e.apiRef.current.getAggregationModel=()=>Ot?Se:null},[dn,Se,Ot,_e.apiRef]);const ge=ro({rowHeight:i,pagination:Te,paginatedUnpinnedRows:bt,sortedUnpinnedRows:it,expandedRowIds:nt,getDetailPanelHeight:S,pinnedTopRowsLength:ln.length,pinnedBottomRowsLength:sn.length,visibleOrderedColumns:Pi,pinnedColumns:Ie,columnWidths:Re,viewportWidth:ue.dimensions.viewportWidth||1e3,checkboxSelection:a,hasDetailPanel:Le,rowReordering:T,paginationMode:oe,isLoading:ue.dataSource.loading,pageSize:Ce.pageSize}),Li=l.useMemo(()=>{const K={};for(const Z of[...ge.leftPinnedCols,...ge.unpinnedColsWithWidth,...ge.rightPinnedCols])Z.isSpacer||(K[Z.field]=Z.width);return{...K,...Re}},[ge.leftPinnedCols,ge.unpinnedColsWithWidth,ge.rightPinnedCols,Re]);l.useEffect(()=>{_e.apiRef.current.scrollToIndexes=({rowIndex:K,colIndex:Z})=>{const ae=qe.current;if(ae){if(K!==void 0&&K>=0){const xe=K>0?ge.cumulativeHeights[K-1]:0,he=ge.cumulativeHeights[K]??xe,{scrollTop:me,clientHeight:be}=ae;xe<me?ae.scrollTop=xe:he>me+be&&(ae.scrollTop=he-be)}if(Z!==void 0&&Z>=0){const he=[...ge.leftPinnedCols,...ge.unpinnedColsWithWidth,...ge.rightPinnedCols][Z];if(!he)return;const me=ge.unpinnedColsWithWidth.findIndex(Di=>Di.field===he.field);if(me===-1)return;const be=me>0?ge.unpinnedAccWidths[me-1]:0,At=ge.unpinnedAccWidths[me]??be,zt=ge.leftWidth+At,{scrollLeft:Jn,clientWidth:Qn}=ae;be<Jn?ae.scrollLeft=be:zt>Jn+Qn&&(ae.scrollLeft=zt-Qn)}}}},[ge,qe,_e.apiRef]);const ye=xo({layout:ge,scrollTop:ki,scrollLeft:Si,viewportWidth:ue.dimensions.viewportWidth,viewportHeight:ue.dimensions.viewportHeight,autoHeight:d,rowReordering:T,hasDetailPanel:Le,checkboxSelection:a,pinCheckboxColumn:v,pinExpandColumn:I});l.useEffect(()=>{if(!qe.current)return;const K=new ResizeObserver(Z=>{for(const ae of Z){const{width:xe,height:he}=ae.contentRect;Vn(xe,he)}});return K.observe(qe.current),()=>{K.disconnect()}},[Vn]);const wt=l.useCallback((K,Z)=>{const ae=new Set(ve);Z?ae.add(K):ae.delete(K);const xe=Array.from(ae);St||jt(xe),Et?.(xe)},[ve,St,Et,jt]),Ri=l.useCallback(K=>{let Z=[];K&&(Z=Ze.map(ae=>ae.id)),St||jt(Z),Et?.(Z)},[Ze,St,Et,jt]),Yn=l.useCallback((K,Z)=>{const ae=Z?[{field:K,sort:Z}]:[];Wn||Fn(ae),C?.(ae)},[Wn,C,Fn]),{focusedCell:Wt,setFocusedCell:cn,handleFocus:Oi,handleBlur:Wi,handleKeyDown:Fi}=io({allRenderableRows:an,navigationColumns:Kn,checkboxSelection:a,selectedRowIds:ve,handleSelectionChange:wt,handleDetailPanelToggle:Tt,editingHandlers:et,setKeyboardMode:Je,sortModel:Fe,handleSort:Yn,isCellEditable:Y,pagination:Te,pageSize:Ce.pageSize,virtualization:ye,viewportRef:qe}),un=l.useCallback(K=>{Je(!1),cn({id:K.row.id,field:K.field}),Mt.current?.focus({preventScroll:!0}),w?.(K)},[w,Je,cn]),qn=l.useRef(et.editingCell);l.useEffect(()=>{const K=!!qn.current,Z=!!et.editingCell;K&&!Z&&Mt.current?.focus({preventScroll:!0}),qn.current=et.editingCell},[et.editingCell]);const Ai=wo({renderContext:ye.renderContext,pinnedTopRows:ln,pinnedBottomRows:sn,paginatedUnpinnedRows:bt,sortedUnpinnedRows:it,pagination:Te}),zi=t.length>0&&ve.size===t.length,Bi=ve.size>0&&ve.size<t.length,$i=l.useMemo(()=>Ae.some(K=>!!K.rowSpan),[Ae]),[vt,Ft]=l.useState(!1),fn=l.useRef(null),gn=l.useRef(null),Xn=l.useMemo(()=>{if(!A?.toolbar)return null;const K=R?void 0:(Z,ae)=>{const xe=[...Lt],he=xe.indexOf(Z),me=xe.indexOf(ae);if(he===-1||me===-1)return;const be=[...xe];be.splice(he,1),be.splice(me,0,Z),W||Rt(be);const At=Ae.find(zt=>zt.field===Z);At&&F?.({oldIndex:he,targetIndex:me,column:At})};return{apiRef:_e.apiRef,columns:rn,baseColumns:e,aggregationModel:Se,onAggregationModelChange:An,...se||D||q?{pivotModel:Xt,onPivotModelChange:zn}:{},filterModel:ke,onFilterModelChange:b,columnVisibilityModel:$e,onColumnVisibilityModelChange:kt,onColumnReorder:K,onColumnOrderReset:R?void 0:()=>Rt(e.map(Z=>Z.field)),forceColumnsOpen:vt,onColumnsPanelClose:()=>Ft(!1),...ie?.toolbar}},[A?.toolbar,R,Lt,rn,Ae,W,F,Rt,_e.apiRef,e,Se,An,se,D,q,Xt,zn,ke,b,$e,kt,vt,ie?.toolbar]);return l.useEffect(()=>{if(!vt||A?.toolbar)return;function K(Z){gn.current&&!gn.current.contains(Z.target)&&Ft(!1)}return document.addEventListener("mousedown",K),()=>document.removeEventListener("mousedown",K)},[vt,A?.toolbar]),r.jsxs("div",{ref:fn,className:["ogx",ee,d&&"ogx--auto-height",$i&&"ogx--row-spanning",ne&&"ogx--list-view"].filter(Boolean).join(" "),style:{...de,height:U??de?.height,"--ogx-row-height":`${i}px`,"--ogx-header-height":`${s}px`},"aria-busy":ht,children:[Xn&&r.jsx(hi,{...Xn}),!A?.toolbar&&r.jsx(br,{isOpen:vt,containerRef:fn,panelRef:gn,effectiveColumns:Ae,columnVisibilityModel:$e,effectiveColumnOrder:Lt,columnOrder:W,disableColumnReorder:R,onClose:()=>Ft(!1),onColumnVisibilityChange:kt,onColumnOrderChange:F,setInternalColumnOrder:Rt}),ne&&we&&r.jsx(or,{ariaLabel:je,allRenderableRows:an,filteredRows:De,pagination:Te,effectivePaginationModel:Ce,pageSizeOptions:x,selectedRowIds:ve,listViewColumn:we,noRowsLabel:Kt,rowHeight:i,checkboxSelection:a,paginationMode:oe,dataSource:J,serverRowCount:ue.pagination.rowCount||0,paginationSlot:A?.pagination,paginationSlotProps:ie?.pagination,localeText:Pe?{paginationRowsPerPage:Pe.paginationRowsPerPage,paginationOf:Pe.paginationOf,paginationPage:Pe.paginationPage}:void 0,onRowClick:It,onSelectionChange:wt,onPaginationModelChange:Jt}),!ne&&r.jsx("div",{ref:K=>{qe.current=K,Mt.current=K},className:"ogx__viewport",onScroll:ji,role:"grid","aria-label":je||"Data grid","aria-rowcount":De.length+1,"aria-colcount":e.length+(a?1:0)+(Le?1:0)+(T?1:0),"aria-busy":ht,tabIndex:0,onKeyDownCapture:()=>{Je(!0)},onMouseDownCapture:()=>{Je(!1)},onKeyDown:Fi,onFocus:Oi,onBlur:Wi,children:r.jsxs("div",{ref:mi,className:"ogx__content",style:{width:ye.totalWidth},role:"presentation",children:[r.jsx(vn,{columns:ye.virtualColumns,allColumns:Ae,columnGroupingModel:Be,checkboxSelection:a,allSelected:zi,someSelected:Bi,onSelectAll:Ri,sortModel:Fe,onSort:Yn,onColumnResize:Ii,columnWidths:Re,pinnedColumns:Ie,focusedCell:Wt,onHeaderClick:K=>{cn({id:"HEADER",field:K}),Je(!1),Mt.current?.focus({preventScroll:!0})},onDragStart:Be?void 0:ot.onDragStart,onDragOver:Be?void 0:ot.onDragOver,onDragEnd:Be?void 0:ot.onDragEnd,onDrop:Be?void 0:ot.onDrop,draggedColumn:Be?void 0:ot.draggedColumn,dragOverColumn:Be?void 0:ot.dragOverColumn,rowReordering:T,hasDetailPanel:Le,pinCheckboxColumn:v,pinExpandColumn:I,aggregationModel:Se,onHideColumn:K=>{kt({...$e,[K]:!1})},onManageColumns:()=>Ft(!0),onPinColumn:(K,Z)=>{const ae=[...Ie?.left??[]],xe=[...Ie?.right??[]],he=ae.filter(be=>be!==K),me=xe.filter(be=>be!==K);qt(Z==="left"?{left:[...he,K],right:me}:Z==="right"?{left:he,right:[...me,K]}:{left:he,right:me})}}),!ht&&!ue.dataSource.error&&De.length===0&&r.jsx(ko,{noRowsLabel:Kt,width:ye.totalWidth}),r.jsx(Sn,{rows:ln,position:"top",columns:ye.virtualColumns,selectedRowIds:ve,checkboxSelection:a,onRowClick:It,onCellClick:un,onSelectionChange:wt,columnWidths:Re,pinnedColumns:Ie,pinnedRows:m,hasDetailPanel:Le,expandedRowIds:nt,getDetailPanelContent:g,getDetailPanelHeight:S,onDetailPanelToggle:Tt,pinCheckboxColumn:v,pinExpandColumn:I,focusedCell:Wt,colspanMap:lt.colspanMap,rowSpanningCaches:lt.rowSpanningState.caches,rowHeight:i,rowMetaMap:mt}),r.jsx(pr,{virtualContainerHeight:ye.totalHeight-ye.pinnedTopHeight-ye.pinnedBottomHeight,offsetTop:ye.offsetTop,effectiveLoading:ht,visibleRows:Ai,baseColumns:e,virtualColumns:ye.virtualColumns,viewportWidth:ue.dimensions.viewportWidth,checkboxSelection:a,hasDetailPanel:Le,rowReordering:T,rowHeight:i,pinnedRows:m,selectedRowIds:ve,onRowClick:It,onCellClick:un,onSelectionChange:wt,columnWidths:Re,pinnedColumns:Ie,expandedRowIds:nt,getDetailPanelContent:g,getDetailPanelHeight:S,onDetailPanelToggle:Tt,pinCheckboxColumn:v,pinExpandColumn:I,rowReorderHandlers:Ti,editingHandlers:et,focusedCell:Wt,colspanMap:lt.colspanMap,rowSpanningCaches:lt.rowSpanningState.caches,paginationMode:oe,dataSourceLoading:ue.dataSource.loading,sortedUnpinnedRowCount:it.length,infiniteScrollSkeletonCount:Math.min(Ce.pageSize,20),unpinnedRowsLength:ge.unpinnedRowsLength,rowMetaMap:mt}),r.jsx(Sn,{rows:sn,position:"bottom",columns:ye.virtualColumns,selectedRowIds:ve,checkboxSelection:a,onRowClick:It,onCellClick:un,onSelectionChange:wt,columnWidths:Re,pinnedColumns:Ie,pinnedRows:m,hasDetailPanel:Le,expandedRowIds:nt,getDetailPanelContent:g,getDetailPanelHeight:S,onDetailPanelToggle:Tt,pinCheckboxColumn:v,pinExpandColumn:I,focusedCell:Wt,colspanMap:lt.colspanMap,rowSpanningCaches:lt.rowSpanningState.caches,rowHeight:i,rowMetaMap:mt}),Ot&&!se&&r.jsx(yo,{columns:rn,aggregationModel:Se,aggregationResult:dn,columnWidths:Li,rowHeight:i,checkboxSelection:a,hasDetailPanel:Le,rowReordering:T,pinnedColumns:Ie})]})}),!ne&&Te&&(()=>{const K=A?.pagination||_n;return r.jsx(K,{page:Ce.page,pageSize:Ce.pageSize,rowCount:ue.pagination.rowCount,pageSizeOptions:x,onPageChange:Z=>Jt({...Ce,page:Z}),onPageSizeChange:Z=>Jt({...Ce,pageSize:Z,page:0}),localeText:Pe?{paginationRowsPerPage:Pe.paginationRowsPerPage,paginationOf:Pe.paginationOf,paginationPage:Pe.paginationPage}:void 0,...ie?.pagination})})(),r.jsxs("div",{className:"ogx-aria-live-status",role:"status","aria-live":"polite",children:[ht?"Loading data...":"",ue.dataSource.error?`Error: ${ue.dataSource.error instanceof Error?ue.dataSource.error.message:"Unknown error"}`:"",!G&&!ue.dataSource.error&&(De.length===0?Kt:ke&&((ke.quickFilterValues?.length||0)>0||(ke.items?.length||0)>0)?`${De.length} ${De.length===1?"row":"rows"} found`:"")]}),r.jsx(So,{error:ue.dataSource.error})]})}function _r({rows:n=5,columns:t=5}){return r.jsx("div",{className:"ogx__skeleton",children:Array.from({length:n}).map((e,o)=>r.jsx("div",{className:"ogx__skeleton-row",children:Array.from({length:t}).map((i,s)=>r.jsx("div",{className:"ogx__skeleton-cell",children:r.jsx("div",{className:"ogx__skeleton-content"})},s))},o))})}const En=new Set(["isEmpty","isNotEmpty"]);function Cr(n,t){return n.find(e=>"field"in e&&e.field===t)}const yr=({col:n,item:t,onChange:e})=>{const o=l.useId(),i=go(n.type),s=!!t,d=t?.operator??i[0],[a,u]=l.useState(t?.value!=null?String(t.value):""),c=l.useRef(e),p=l.useRef(t),w=l.useRef(n.field),h=l.useRef(d);l.useLayoutEffect(()=>{c.current=e,p.current=t,w.current=n.field,h.current=d});const b=l.useRef(t?.value);l.useEffect(()=>{t?.value!==b.current&&(b.current=t?.value,u(t?.value!=null?String(t.value):""))},[t?.value]),l.useEffect(()=>{const x=setTimeout(()=>{const E=p.current,f=E?.value??"";a!==f&&c.current({id:E?.id??`${w.current}-${Date.now()}`,field:w.current,operator:h.current,value:a})},300);return()=>clearTimeout(x)},[a]);const _=x=>{const E=En.has(x),f={id:t?.id??`${n.field}-${Date.now()}`,field:n.field,operator:x,value:E?void 0:t?.value??(n.type==="boolean"?"true":"")};e(f)},C=()=>{u(""),e(null)},k=En.has(String(d)),M=n.type==="boolean",j=!k;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:x=>_(x.target.value),"aria-label":`Filter operator for ${n.headerName||n.field}`,children:i.map(x=>r.jsx("option",{value:x,children:x},x))}),j&&M&&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:x=>{u(x.target.value),e({id:t?.id??`${n.field}-${Date.now()}`,field:n.field,operator:d,value:x.target.value})},"aria-label":`Filter value for ${n.headerName||n.field}`,children:[r.jsx("option",{value:"true",children:"true"}),r.jsx("option",{value:"false",children:"false"})]}),j&&!M&&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:x=>u(x.target.value),placeholder:n.type==="number"?"Number…":"Value…","aria-label":`Filter value for ${n.headerName||n.field}`}),s&&r.jsx("button",{className:"ogx-filter__row-clear",onClick:C,"aria-label":`Clear filter for ${n.headerName||n.field}`,title:"Clear",children:"×"})]})]})},Nn=({filterModel:n,columns:t,onFilterModelChange:e})=>{const o=l.useMemo(()=>n.items??[],[n.items]),i=n.logicOperator??"and",s=l.useCallback((u,c)=>{const p=o.filter(h=>"field"in h&&h.field!==u),w=c?[...p,c]:p;e({...n,items:w})},[o,n,e]),d=l.useCallback(u=>{e({...n,logicOperator:u})},[n,e]),a=t.filter(u=>u.filterable!==!1);return r.jsxs(r.Fragment,{children:[o.length>1&&r.jsxs("div",{className:"ogx-filter__logic-bar",children:[r.jsx("span",{className:"ogx-filter__logic-label",children:"Match:"}),r.jsx("button",{className:`ogx-filter__logic-pill${i==="and"?" ogx-filter__logic-pill--active":""}`,onClick:()=>d("and"),"aria-pressed":i==="and",children:"ALL (AND)"}),r.jsx("button",{className:`ogx-filter__logic-pill${i==="or"?" ogx-filter__logic-pill--active":""}`,onClick:()=>d("or"),"aria-pressed":i==="or",children:"ANY (OR)"})]}),a.length===0?r.jsx("div",{className:"ogx-filter__empty",children:"No filterable columns."}):a.map(u=>r.jsx(yr,{col:u,item:Cr(o,u.field),onChange:c=>s(u.field,c)},u.field))]})},kr=["sum","avg","count","min","max"];function Mn(){return r.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[r.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),r.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),r.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),r.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1",fill:"currentColor",opacity:"0.25"}),r.jsx("path",{d:"M17 14v-4M17 10l-2 2 2 2"})]})}function Sr({anchorRef:n,columns:t,model:e,onChange:o,onClose:i}){const s=l.useRef(null),[d,a]=l.useState({top:0,right:0}),[u,c]=l.useState(document.body);l.useLayoutEffect(()=>{c(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const p=l.useCallback(()=>{if(!n.current)return{top:0,right:0};const v=n.current.getBoundingClientRect();return{top:v.bottom+6,right:window.innerWidth-v.right}},[n]);l.useEffect(()=>{a(p());const v=()=>a(p());return window.addEventListener("scroll",v,!0),window.addEventListener("resize",v),()=>{window.removeEventListener("scroll",v,!0),window.removeEventListener("resize",v)}},[p]),l.useEffect(()=>{function v(R){s.current&&!s.current.contains(R.target)&&n.current&&!n.current.contains(R.target)&&i()}function I(R){R.key==="Escape"&&i()}return document.addEventListener("mousedown",v),document.addEventListener("keydown",I),()=>{document.removeEventListener("mousedown",v),document.removeEventListener("keydown",I)}},[n,i]);const w=new Set(e.rowFields),h=new Set(e.columnFields),b=new Set(e.valueFields.map(v=>v.field)),_=v=>w.has(v)||h.has(v)||b.has(v);function C(v){w.has(v)||o({...e,rowFields:[...e.rowFields,v]})}function k(v){h.has(v)||o({...e,columnFields:[...e.columnFields,v]})}function M(v,I="sum"){b.has(v)||o({...e,valueFields:[...e.valueFields,{field:v,aggFn:I}]})}function j(v){o({...e,rowFields:e.rowFields.filter(I=>I!==v)})}function x(v){o({...e,columnFields:e.columnFields.filter(I=>I!==v)})}function E(v){o({...e,valueFields:e.valueFields.filter(I=>I.field!==v)})}function f(v,I){o({...e,valueFields:e.valueFields.map(R=>R.field===v?{...R,aggFn:I}:R)})}function m(){o({rowFields:[],columnFields:[],valueFields:[]})}const g=new Set(t.filter(v=>v.type==="number"||v.aggregable).map(v=>v.field)),S=e.rowFields.length+e.columnFields.length+e.valueFields.length,P=v=>t.find(I=>I.field===v)?.headerName??v,N=r.jsxs("div",{ref:s,className:"ogx-pivot-panel",role:"dialog","aria-label":"Pivot configuration",style:{top:d.top,right:d.right},children:[r.jsxs("div",{className:"ogx-pivot-panel__header",children:[r.jsxs("span",{className:"ogx-pivot-panel__title",children:[r.jsx(Mn,{}),"Pivot Mode"]}),S>0&&r.jsx("button",{className:"ogx-pivot-panel__reset-btn",onClick:m,title:"Reset pivot",children:"Reset"})]}),r.jsxs("div",{className:"ogx-pivot-panel__body",children:[r.jsxs("div",{className:"ogx-pivot-zone",children:[r.jsxs("span",{className:"ogx-pivot-zone__label",children:[r.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--row"}),"Row Fields"]}),r.jsx("div",{className:`ogx-pivot-chips${e.rowFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — each becomes a row label",children:e.rowFields.map(v=>r.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--row",children:[P(v),r.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>j(v),title:`Remove ${P(v)}`,children:"×"})]},v))})]}),r.jsxs("div",{className:"ogx-pivot-zone",children:[r.jsxs("span",{className:"ogx-pivot-zone__label",children:[r.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--col"}),"Column Fields"]}),r.jsx("div",{className:`ogx-pivot-chips${e.columnFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — unique values become column headers",children:e.columnFields.map(v=>r.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--col",children:[P(v),r.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>x(v),title:`Remove ${P(v)}`,children:"×"})]},v))})]}),r.jsxs("div",{className:"ogx-pivot-zone",children:[r.jsxs("span",{className:"ogx-pivot-zone__label",children:[r.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--value"}),"Value Fields (aggregated)"]}),r.jsx("div",{className:`ogx-pivot-chips${e.valueFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add numeric fields here — values are aggregated",children:e.valueFields.map(v=>r.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--value",children:[P(v.field),r.jsx("select",{className:"ogx-pivot-chip__fn-select",value:v.aggFn,onChange:I=>f(v.field,I.target.value),title:"Aggregation function",children:kr.map(I=>r.jsx("option",{value:I,children:I.toUpperCase()},I))}),r.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>E(v.field),title:`Remove ${P(v.field)}`,children:"×"})]},v.field))})]}),r.jsx("hr",{className:"ogx-pivot-panel__divider"}),r.jsxs("div",{children:[r.jsx("div",{className:"ogx-pivot-panel__fields-label",children:"Available Fields"}),r.jsxs("div",{className:"ogx-pivot-fields",children:[t.map(v=>{const I=g.has(v.field);return _(v.field)?null:r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3},children:[r.jsx("span",{className:`ogx-pivot-field-btn${I?" ogx-pivot-field-btn--numeric":""}`,children:v.headerName??v.field}),r.jsxs("div",{className:"ogx-pivot-field-actions",children:[r.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--row",onClick:()=>C(v.field),title:"Add to Row Fields",children:"Row"}),r.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--col",onClick:()=>k(v.field),title:"Add to Column Fields",children:"Col"}),I&&r.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--value",onClick:()=>M(v.field),title:"Add to Value Fields",children:"Val"})]})]},v.field)}),t.every(v=>_(v.field))&&r.jsx("span",{style:{fontSize:12,color:"var(--ogx-color-gray-400, #94a3b8)"},children:"All fields are in use."})]})]})]})]});return ze.createPortal(N,u)}function 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 Er(){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 Nr({value:n="",onChange:t,placeholder:e="Search...",debounceMs:o=250}){const[i,s]=l.useState(()=>n.length>0),[d,a]=l.useState(n),u=l.useRef(null),c=l.useRef(null),p=l.useRef(t);l.useLayoutEffect(()=>{p.current=t},[t]);const w=l.useRef(n),h=l.useRef(n),b=l.useRef(!1);l.useLayoutEffect(()=>{b.current&&document.activeElement!==u.current&&u.current?.focus()}),l.useEffect(()=>{n!==h.current&&(h.current=n,n!==w.current&&(a(n),w.current=n,n?s(!0):(b.current=!1,s(!1))))},[n]),l.useEffect(()=>{const j=setTimeout(()=>{d!==w.current&&(w.current=d,p.current(d))},o);return()=>clearTimeout(j)},[d,o]);const _=l.useCallback(()=>{s(!0),requestAnimationFrame(()=>u.current?.focus())},[]),C=l.useCallback(j=>{j.stopPropagation(),a(""),w.current="",p.current(""),u.current?.focus()},[]),k=l.useCallback(()=>{b.current=!0,s(!0)},[]),M=l.useCallback(()=>{b.current=!1,setTimeout(()=>{if(c.current&&document.activeElement&&c.current.contains(document.activeElement)){b.current=!0;return}d||s(!1)},150)},[d]);return l.useEffect(()=>{const j=x=>{c.current&&!c.current.contains(x.target)&&(d||s(!1))};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[d]),r.jsxs("div",{ref:c,className:`ogx-global-search${i?" ogx-global-search--expanded":""}`,onClick:i?void 0:_,children:[r.jsx("div",{className:"ogx-global-search__icon-wrapper",children:r.jsx(jr,{})}),r.jsx("input",{ref:u,className:"ogx-global-search__input",value:d,onChange:j=>a(j.target.value),onFocus:k,onBlur:M,placeholder:e,"aria-label":"Global Search",autoComplete:"off"}),d&&r.jsx("button",{className:"ogx-global-search__clear",onClick:C,"aria-label":"Clear search",children:r.jsx(Er,{})})]})}function gt({title:n,children:t,placement:e="top",enterDelay:o=200,leaveDelay:i=0}){const[s,d]=l.useState(!1),[a,u]=l.useState({top:0,left:0}),c=l.useRef(null),p=l.useRef(null),w=l.useCallback(()=>{if(!p.current)return;const C=p.current.getBoundingClientRect();let k=0,M=0;const j=window.pageXOffset||document.documentElement.scrollLeft,x=window.pageYOffset||document.documentElement.scrollTop;e==="top"?(k=C.top+x-8,M=C.left+j+C.width/2):e==="bottom"&&(k=C.bottom+x+8,M=C.left+j+C.width/2),u({top:k,left:M})},[e]);l.useLayoutEffect(()=>(s&&(w(),window.addEventListener("scroll",w,!0),window.addEventListener("resize",w)),()=>{window.removeEventListener("scroll",w,!0),window.removeEventListener("resize",w)}),[s,w]);const h=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{d(!0)},o)},b=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{d(!1)},i)},_=l.useCallback(C=>{p.current=C?C.firstElementChild??C:null},[]);return r.jsxs(r.Fragment,{children:[r.jsx("span",{ref:_,style:{display:"inline-block",lineHeight:0},onMouseEnter:h,onMouseLeave:b,children:t}),s&&n&&ze.createPortal(r.jsx("div",{className:`ogx-tooltip ogx-tooltip--${e}`,style:{top:a.top,left:a.left,position:"absolute",zIndex:99999},children:n}),document.body)]})}const Mr=["none","sum","avg","count","min","max"];function Pn(){return r.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r.jsx("path",{d:"M18 4H6l6 8-6 8h12"})})}function Pr(){return r.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",children:[r.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),r.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.25"}),r.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),r.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),r.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),r.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function In(){return r.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})})}function Ir({anchorRef:n,aggregationModel:t,aggregableColumns:e,onFunctionChange:o,onClearAll:i,onClose:s,activeCount:d}){const a=l.useRef(null),[u,c]=l.useState({top:0,right:0}),[p,w]=l.useState(document.body);l.useLayoutEffect(()=>{w(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const h=l.useCallback(()=>{if(!n.current)return{top:0,right:0};const _=n.current.getBoundingClientRect();return{top:_.bottom+6,right:window.innerWidth-_.right}},[n]);l.useEffect(()=>{c(h());const _=()=>c(h());return window.addEventListener("scroll",_,!0),window.addEventListener("resize",_),()=>{window.removeEventListener("scroll",_,!0),window.removeEventListener("resize",_)}},[h]),l.useEffect(()=>{function _(C){a.current&&!a.current.contains(C.target)&&n.current&&!n.current.contains(C.target)&&s()}return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[n,s]),l.useEffect(()=>{function _(C){C.key==="Escape"&&s()}return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[s]);const b=r.jsxs("div",{ref:a,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Summaries configuration",style:{top:u.top,right:u.right,width:400,maxWidth:"calc(100vw - 24px)"},children:[r.jsxs("div",{className:"ogx-toolbar__panel-header",children:[r.jsxs("span",{className:"ogx-toolbar__panel-title",children:[r.jsx(Pn,{}),"Summaries"]}),d>0&&r.jsx("button",{className:"ogx-toolbar__clear-btn",onClick:i,title:"Clear all summaries",children:"Clear all"})]}),r.jsx("div",{className:"ogx-toolbar__panel-body",children:e.length===0?r.jsxs("p",{className:"ogx-toolbar__empty",children:["No aggregable columns.",r.jsx("br",{}),"Set ",r.jsx("code",{children:"aggregable: true"})," on a column to enable."]}):e.map(_=>{const C=t[_.field]||"none";return r.jsxs("div",{className:"ogx-toolbar__agg-row",children:[r.jsx("span",{className:"ogx-toolbar__agg-label",title:_.field,children:_.headerName||_.field}),r.jsx("div",{className:"ogx-toolbar__agg-pills",children:Mr.map(k=>r.jsx("button",{className:`ogx-toolbar__pill${C===k?" ogx-toolbar__pill--active":""}`,onClick:()=>o(_.field,k),"aria-pressed":C===k,children:k},k))})]},_.field)})})]});return ze.createPortal(b,p)}function Tr({anchorRef:n,columns:t,visibleColumns:e,onVisibilityChange:o,onShowAll:i,onHideAll:s,onColumnReorder:d,onColumnOrderReset:a,onClose:u}){const c=l.useRef(null),[p,w]=l.useState({top:0,right:0}),[h,b]=l.useState(document.body);l.useLayoutEffect(()=>{b(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const _=l.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]);l.useEffect(()=>{w(_());const k=()=>w(_());return window.addEventListener("scroll",k,!0),window.addEventListener("resize",k),()=>{window.removeEventListener("scroll",k,!0),window.removeEventListener("resize",k)}},[_]),l.useEffect(()=>{function k(M){c.current&&!c.current.contains(M.target)&&n.current&&!n.current.contains(M.target)&&u()}return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[n,u]);const C=r.jsx("div",{ref:c,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Column visibility",style:{top:p.top,right:p.right,width:280,padding:0},children:r.jsx(jn,{columns:t,visibleColumns:e,onVisibilityChange:o,onShowAll:i,onHideAll:s,onColumnReorder:d,onColumnOrderReset:a})});return ze.createPortal(C,h)}function Lr({anchorRef:n,columns:t,filterModel:e,onFilterModelChange:o,onClose:i}){const s=l.useRef(null),[d,a]=l.useState({top:0,right:0}),u=l.useRef(i);l.useLayoutEffect(()=>{u.current=i},[i]);const[c,p]=l.useState(document.body);l.useLayoutEffect(()=>{p(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const w=l.useCallback(()=>{if(!n.current)return{top:0,right:0};const C=n.current.getBoundingClientRect();return{top:C.bottom+6,right:window.innerWidth-C.right}},[n]);l.useEffect(()=>{a(w());const C=()=>a(w());return window.addEventListener("scroll",C,!0),window.addEventListener("resize",C),()=>{window.removeEventListener("scroll",C,!0),window.removeEventListener("resize",C)}},[w]),l.useEffect(()=>{function C(k){k.key==="Escape"&&u.current()}return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[]);const h=e.items?.length??0,b=()=>{o({...e,items:[],logicOperator:"and"})},_=r.jsxs("div",{ref:s,className:"ogx-toolbar__panel ogx-toolbar__panel--filter",role:"dialog","aria-label":"Advanced filters",style:{top:d.top,right:d.right,width:540,maxWidth:"calc(100vw - 24px)"},children:[r.jsxs("div",{className:"ogx-toolbar__panel-header",children:[r.jsxs("span",{className:"ogx-toolbar__panel-title",children:[r.jsx(In,{}),"Filters",h>0&&r.jsx("span",{className:"ogx-toolbar__panel-count",children:h})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[h>0&&r.jsx("button",{className:"ogx-toolbar__clear-btn",onClick:b,title:"Clear all filters",children:"Clear all"}),r.jsx("button",{className:"ogx-toolbar__close-btn",onClick:()=>u.current(),title:"Close filters","aria-label":"Close filters panel",children:"Close"})]})]}),r.jsx("div",{className:"ogx-toolbar__panel-body ogx-toolbar__panel-body--filter",children:r.jsx(Nn,{columns:t,filterModel:e,onFilterModelChange:o})})]});return ze.createPortal(_,c)}const Rr={rowFields:[],columnFields:[],valueFields:[]};function Or({columns:n=[],baseColumns:t,aggregationModel:e={},onAggregationModelChange:o,pivotModel:i,onPivotModelChange:s,filterModel:d,onFilterModelChange:a,columnVisibilityModel:u={},onColumnVisibilityModelChange:c,onColumnReorder:p,onColumnOrderReset:w,forceColumnsOpen:h,onColumnsPanelClose:b,children:_,rightContent:C,style:k,renderColumnsButton:M,renderFilterButton:j,renderAggregationButton:x,renderExportButton:E,renderQuickFilter:f,className:m}){const[g,S]=l.useState(!1),[P,N]=l.useState(!1),[v,I]=l.useState(!1),[R,W]=l.useState(!1);l.useEffect(()=>{h&&(I(!0),S(!1),N(!1),W(!1))},[h]);const F=l.useRef(null),U=l.useRef(null),T=l.useRef(null),B=l.useRef(null),G=l.useRef(null),V=l.useRef(null),y=l.useRef(null),L=i??Rr,z=L.rowFields.length>0||L.columnFields.length>0||L.valueFields.length>0,$=n.filter(A=>A.aggregable!==!1&&(A.type==="number"||A.aggregable===!0)),H=Object.keys(e).filter(A=>e[A]&&e[A]!=="none").length,X=l.useCallback((A,ie)=>{if(!o)return;const se={...e};ie==="none"?delete se[A]:se[A]=ie,o(se)},[e,o]),Y=l.useCallback(()=>{o?.({})},[o]),te=l.useCallback(A=>{if(!a)return;const se={...d||{},quickFilterValues:A?[A]:[],items:d?.items||[]};a(se)},[d,a]),O=d?.quickFilterValues?.[0]||"",J=d?.items?.length||0,Q=new Set(n.filter(A=>u[A.field]!==!1).map(A=>A.field)),le=l.useCallback((A,ie)=>{if(!c)return;const se={...u,[A]:ie};c(se)},[u,c]),oe=l.useCallback(()=>{if(!c)return;const A={...u};n.forEach(ie=>{ie.hideable!==!1&&(A[ie.field]=!0)}),c(A)},[n,u,c]),pe=l.useCallback(()=>{if(!c)return;const A={...u};n.forEach(ie=>{ie.hideable!==!1&&(A[ie.field]=!1)}),c(A)},[n,u,c]);return r.jsxs("div",{className:["ogx-toolbar",m].filter(Boolean).join(" "),role:"toolbar","aria-label":"Grid toolbar",style:k,children:[_&&r.jsx("div",{className:"ogx-toolbar__left",children:_}),r.jsx("div",{className:"ogx-toolbar__spacer"}),r.jsxs("div",{className:"ogx-toolbar__actions",children:[a&&r.jsx("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:f?f({value:O,onChange:te}):r.jsx(Nr,{value:O,onChange:te,placeholder:"Search..."})}),c&&r.jsxs("div",{ref:G,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[M?M({onClick:()=>{I(A=>!A),S(!1),N(!1),W(!1)},isOpen:v,activeCount:n.length-Q.size}):r.jsx(gt,{title:"Columns",children:r.jsx("button",{ref:T,className:`ogx-toolbar__icon-btn${v?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Manage columns",onClick:()=>{I(!v),S(!1),N(!1),W(!1)},children:r.jsx(Pr,{})})}),v&&r.jsx(Tr,{anchorRef:M?G:T,columns:n,visibleColumns:Q,onVisibilityChange:le,onShowAll:oe,onHideAll:pe,onColumnReorder:p,onColumnOrderReset:w,onClose:()=>{I(!1),b?.()}})]}),a&&r.jsxs("div",{ref:V,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[j?j({onClick:()=>{W(A=>!A),S(!1),N(!1),I(!1)},isOpen:R,activeCount:J}):r.jsx(gt,{title:"Filters",children:r.jsxs("button",{ref:B,className:`ogx-toolbar__icon-btn${R?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Advanced filters",onClick:()=>{W(!R),S(!1),N(!1),I(!1)},children:[r.jsx(In,{}),J>0&&r.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Filters active"})]})}),R&&r.jsx(Lr,{anchorRef:j?V:B,columns:n,filterModel:d||{items:[]},onFilterModelChange:a,onClose:()=>W(!1)})]}),s&&r.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[r.jsx(gt,{title:"Pivot",children:r.jsxs("button",{ref:U,className:`ogx-toolbar__icon-btn${P?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure pivot","aria-expanded":P,onClick:()=>{N(!P),S(!1),I(!1),W(!1)},children:[r.jsx(Mn,{}),z&&r.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Pivot active"})]})}),P&&r.jsx(Sr,{anchorRef:U,columns:t??n,model:L,onChange:A=>{s?.(A)},onClose:()=>N(!1)})]}),r.jsxs("div",{ref:y,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[x?x({onClick:()=>{S(A=>!A),N(!1),I(!1),W(!1)},isOpen:g,activeCount:H}):r.jsx(gt,{title:"Summaries",children:r.jsxs("button",{ref:F,className:`ogx-toolbar__icon-btn${g?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure summaries","aria-expanded":g,onClick:()=>{S(!g),N(!1),I(!1),W(!1)},children:[r.jsx(Pn,{}),H>0&&r.jsx("span",{className:"ogx-toolbar__dot","aria-label":`${H} active summaries`})]})}),g&&r.jsx(Ir,{anchorRef:x?y:F,aggregationModel:e,aggregableColumns:$,onFunctionChange:X,onClearAll:Y,onClose:()=>S(!1),activeCount:H})]}),E&&E(),C]})]})}function Wr(){return l.useRef(null)}const Fr=({fullWidth:n=!1,error:t=!1,startAdornment:e,endAdornment:o,className:i="",...s})=>{const d=["ogx-input-wrapper",n&&"ogx-input-wrapper--full-width",t&&"ogx-input-wrapper--error",s.disabled&&"ogx-input-wrapper--disabled",i].filter(Boolean).join(" ");return r.jsxs("div",{className:d,children:[e&&r.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--start",children:e}),r.jsx("input",{className:"ogx-input",...s}),o&&r.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--end",children:o})]})};function Tn(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 Ar(n){return n.filter(t=>!(t.exportable===!1||t.field==="__check__"||t.field==="__actions__"))}function zr(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 Ln(n){return(typeof n.width=="number"?n.width:void 0)??(n.flex??1)*100}function Br(n,t){const e=n.reduce((i,s)=>i+Ln(s),0),o={};return n.forEach((i,s)=>{o[s]={cellWidth:Ln(i)/e*t}}),o}function $r(n,t){return!n.items||n.items.length===0?"":n.items.flatMap(e=>{if("items"in e)return[];const i=t.find(d=>d.field===e.field)?.headerName??e.field,s=e.value!==void 0&&e.value!==null?String(e.value):"";return[`${i} ${e.operator} "${s}"`]}).join(" • ")}async function Dr(n,t,e={}){let o;try{o=(await import("jspdf")).default,await import("jspdf-autotable")}catch{throw new Error("exportToPdf requires 'jspdf' and 'jspdf-autotable'. Run: npm install jspdf jspdf-autotable")}const{fileName:i="export",title:s,logoUrl:d,orientation:a="landscape",selectedRows:u,aggregationResult:c,aggregationModel:p,filterModel:w,alternateRowColor:h=!0,headerBackgroundColor:b="#4f46e5",headerTextColor:_="#ffffff",fontSize:C=9}=e,k=new o({orientation:a,unit:"mm",format:"a4"}),M=k.internal.pageSize.getWidth(),j=k.internal.pageSize.getHeight(),x=14,E=M-x*2,f=Ar(t),m=u&&u.length>0?n.filter(G=>u.includes(G.id)):n;let g=x;if(s){let G=x,V=x+8;if(d)try{k.addImage(d,"PNG",G,x,10,10),G+=14}catch{}k.setFontSize(16),k.setFont("helvetica","bold"),k.setTextColor(30,41,59),k.text(s,G,V),V+=6,k.setFontSize(8),k.setFont("helvetica","normal"),k.setTextColor(100,116,139);const y=new Date().toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});if(k.text(`Exported: ${y} • ${m.length} row${m.length!==1?"s":""}`,G,V),V+=5,w){const L=$r(w,t);L&&(k.text(`Filters: ${L}`,G,V),V+=5)}k.setDrawColor(226,232,240),k.setLineWidth(.3),k.line(x,V+2,M-x,V+2),g=V+6}const S=[f.map(G=>G.headerName??G.field)],P=m.map(G=>f.map(V=>zr(G,V)));let N;c&&p&&(N=[f.map((V,y)=>{if(y===0)return f.some(H=>p[H.field])?"TOTAL":"";const L=c[V.field];if(L==null)return"";let z=L;return V.valueFormatter?z=V.valueFormatter({value:L,row:{},field:V.field}):p[V.field]&&(z=Ne(L,p[V.field])),String(z)})]);const v=Br(f,E),[I,R,W]=Tn(b),[F,U,T]=Tn(_);k.autoTable({head:S,body:P,...N?{foot:N}:{},startY:g,styles:{fontSize:C,cellPadding:3,font:"helvetica",overflow:"linebreak"},headStyles:{fillColor:[I,R,W],textColor:[F,U,T],fontStyle:"bold"},...h?{alternateRowStyles:{fillColor:[248,250,252]}}:{},...N?{footStyles:{fillColor:[241,245,249],fontStyle:"bold"}}:{},columnStyles:v,showFoot:N?"lastPage":"never",showHead:"everyPage",margin:{top:x,left:x,right:x,bottom:x+6}});const B=k.getNumberOfPages();for(let G=1;G<=B;G++)k.setPage(G),k.setFontSize(8),k.setTextColor(150,150,150),k.text(`Page ${G} of ${B}`,M-x,j-8,{align:"right"});k.save(`${i}.pdf`)}function Hr(n,t,e={}){const{fileName:o="export.csv",includeHeaders:i=!0,delimiter:s=",",selectedRows:d}=e,a=d&&d.length>0?n.filter(p=>d.includes(p.id)):n;if(a.length===0){console.warn("No rows to export");return}const u=t.filter(p=>!(p.exportable===!1||p.field==="__check__"||p.field==="__actions__"));let c="";if(i){const p=u.map(w=>Ke(w.headerName||w.field));c+=p.join(s)+`
9
+ `}if(a.forEach(p=>{const w=u.map(h=>{let b=p[h.field];return h.valueGetter&&(b=h.valueGetter({row:p,field:h.field,value:b})),h.valueFormatter&&b!==void 0&&b!==null&&(b=h.valueFormatter({value:b,row:p,field:h.field})),Ke(String(b??""))});c+=w.join(s)+`
10
+ `}),e.aggregationResult){const p=e.aggregationResult,w=e.aggregationModel||{},h=u.map(_=>w[_.field]?Ke(w[_.field].toUpperCase()):Ke(""));c+=h.join(s)+`
11
+ `;const b=u.map(_=>{const C=p[_.field];if(C!=null){let k=C;return _.valueFormatter?k=_.valueFormatter({value:C,row:{},field:_.field}):w[_.field]&&(k=Ne(C,w[_.field])),Ke(String(k))}return Ke("")});c+=b.join(s)+`
12
+ `}Vt(c,o,"text/csv;charset=utf-8;")}function Ke(n){return n.includes(",")||n.includes('"')||n.includes(`
13
+ `)?`"${n.replace(/"/g,'""')}"`:n}function Gr(n,t,e={}){const{fileName:o="export.xls",sheetName:i="Sheet1",includeHeaders:s=!0,selectedRows:d}=e,a=d&&d.length>0?n.filter(p=>d.includes(p.id)):n;if(a.length===0){console.warn("No rows to export");return}const u=t.filter(p=>!(p.exportable===!1||p.field==="__check__"||p.field==="__actions__"));let c='<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">';if(c+="<head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>",c+=`<x:Name>${i}</x:Name>`,c+="<x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]-->",c+='<meta charset="UTF-8"></head><body>',c+='<table border="1">',s&&(c+="<thead><tr>",u.forEach(p=>{c+=`<th>${Me(p.headerName||p.field)}</th>`}),c+="</tr></thead>"),c+="<tbody>",a.forEach(p=>{c+="<tr>",u.forEach(w=>{let h=p[w.field];w.valueGetter&&(h=w.valueGetter({row:p,field:w.field,value:h})),w.valueFormatter&&h!==void 0&&h!==null&&(h=w.valueFormatter({value:h,row:p,field:w.field})),c+=`<td>${Me(String(h??""))}</td>`})}),e.aggregationResult){const p=e.aggregationResult,w=e.aggregationModel||{};c+='<tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',u.forEach(h=>{w[h.field]?c+=`<td style="text-align: right; font-weight: bold;">${Me(w[h.field].toUpperCase())}</td>`:c+="<td></td>"}),c+="</tr>",c+='<tr style="font-weight: bold; background-color: #f5f5f5;">',u.forEach(h=>{const b=p[h.field];if(b!=null){let _=b;h.valueFormatter?_=h.valueFormatter({value:b,row:{},field:h.field}):w[h.field]&&(_=Ne(b,w[h.field])),c+=`<td style="text-align: right;">${Me(String(_))}</td>`}else c+="<td></td>"}),c+="</tr>"}c+="</tbody></table></body></html>",Vt(c,o,"application/vnd.ms-excel")}function Me(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function Vr(n,t,e={}){const{fileName:o="export.json",pretty:i=!0,selectedRows:s}=e,d=s&&s.length>0?n.filter(w=>s.includes(w.id)):n;if(d.length===0){console.warn("No rows to export");return}const a=t.filter(w=>!(w.exportable===!1||w.field==="__check__"||w.field==="__actions__")),u=d.map(w=>{const h={};return a.forEach(b=>{let _=w[b.field];b.valueGetter&&(_=b.valueGetter({row:w,field:b.field,value:_})),h[b.field]=_}),h});let c=u;if(e.aggregationResult){const w=e.aggregationResult,h=e.aggregationModel||{},b={};a.forEach(C=>{h[C.field]&&(b[C.field]=h[C.field].toUpperCase())});const _={};a.forEach(C=>{if(w[C.field]!==void 0&&w[C.field]!==null){let k=w[C.field];C.valueFormatter?k=C.valueFormatter({value:k,row:{},field:C.field}):h[C.field]&&(k=Ne(k,h[C.field])),_[C.field]=k}}),c={data:u,aggregation:{labels:b,values:_}}}const p=i?JSON.stringify(c,null,2):JSON.stringify(c);Vt(p,o,"application/json;charset=utf-8;")}async function Ur(n,t,e){const o=window.open("","_blank");if(!o){console.error("Failed to open print window. Please check your popup blocker settings.");return}o.document.write(`
14
14
  <!DOCTYPE html>
15
15
  <html>
16
16
  <head>
@@ -30,11 +30,11 @@ ${h}`;try{await Ko(m)}catch(f){console.error("[OpenGridX] Failed to copy to clip
30
30
  </div>
31
31
  </body>
32
32
  </html>
33
- `),o.document.close(),await new Promise(l=>setTimeout(l,100));try{let l="Print",s,d=null,a=null;typeof e=="string"?l=e:typeof e=="object"&&(l=e.title||"Print",s=e.selectedRows,d=e.aggregationResult||null,a=e.aggregationModel||null);const u=s&&s.length>0?n.filter(f=>s.includes(f.id)):n;if(u.length===0){o.document.body.innerHTML="<h3>No rows to export</h3>";return}const c=t.filter(f=>!(f.exportable===!1||f.field==="__check__"||f.field==="__actions__"));let h=`
33
+ `),o.document.close(),await new Promise(i=>setTimeout(i,100));try{let i="Print",s,d=null,a=null;typeof e=="string"?i=e:typeof e=="object"&&(i=e.title||"Print",s=e.selectedRows,d=e.aggregationResult||null,a=e.aggregationModel||null);const u=s&&s.length>0?n.filter(h=>s.includes(h.id)):n;if(u.length===0){o.document.body.innerHTML="<h3>No rows to export</h3>";return}const c=t.filter(h=>!(h.exportable===!1||h.field==="__check__"||h.field==="__actions__"));let p=`
34
34
  <!DOCTYPE html>
35
35
  <html>
36
36
  <head>
37
- <title>${l||"Print"}</title>
37
+ <title>${i||"Print"}</title>
38
38
  <style>
39
39
  body { font-family: Arial, sans-serif; margin: 20px; }
40
40
  h1 { font-size: 24px; margin-bottom: 20px; }
@@ -49,5 +49,5 @@ ${h}`;try{await Ko(m)}catch(f){console.error("[OpenGridX] Failed to copy to clip
49
49
  </style>
50
50
  </head>
51
51
  <body>
52
- `;if(l&&(h+=`<h1>${Ee(l)}</h1>`),h+="<table>",h+="<thead><tr>",c.forEach(f=>{h+=`<th>${Ee(f.headerName||f.field)}</th>`}),h+="</tr></thead>",h+="<tbody>",u.forEach(f=>{h+="<tr>",c.forEach(p=>{let _=f[p.field];p.valueGetter&&(_=p.valueGetter({row:f,field:p.field,value:_})),p.valueFormatter&&_!==void 0&&_!==null&&(_=p.valueFormatter({value:_,row:f,field:p.field})),p.type==="image"&&_?h+=`<td><div style="display:flex;justify-content:center;"><img src="${_}" alt="${p.headerName}" style="max-height: 40px; border-radius: 4px;"></div></td>`:h+=`<td>${Ee(String(_??""))}</td>`}),h+="</tr>"}),d){const f=a||{};h+='<tfoot><tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',c.forEach(p=>{f[p.field]?h+=`<td style="text-align: right; font-weight: bold;">${Ee(f[p.field].toUpperCase())}</td>`:h+="<td></td>"}),h+='</tr><tr style="font-weight: bold; background-color: #f5f5f5;">',c.forEach(p=>{const _=d[p.field];if(_!=null){let v=_;p.valueFormatter?v=p.valueFormatter({value:_,row:{},field:p.field}):f[p.field]&&(v=Te(_,f[p.field])),h+=`<td style="text-align: right;">${Ee(String(v))}</td>`}else h+="<td></td>"}),h+="</tr></tfoot>"}h+="</tbody></table></body></html>",o.document.open(),o.document.write(h),o.document.close(),o.document.title=l||"Print Preview",o.focus();let m=!1;o.onload=()=>{m||(m=!0,o.print(),setTimeout(()=>{o.close()},100))},setTimeout(()=>{!m&&o&&!o.closed&&(m=!0,o.print(),setTimeout(()=>{o.closed||o.close()},100))},500)}catch(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 $t(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 Lr(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 Rr(n){if(n.type==="number")return"#,##0.##";if(n.type==="date")return"yyyy-mm-dd"}function Wr(n,t){if(t!=null)return t;const e=n.width??120;return Math.min(60,Math.max(8,(e-5)/7))}function Or(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 Fr(n){const t=await Promise.allSettled(n.map(async o=>{if(o.startsWith("data:")){const a=o.indexOf(","),u=o.slice(0,a),c=o.slice(a+1),h=atob(c),m=new Uint8Array(h.length);for(let v=0;v<h.length;v++)m[v]=h.charCodeAt(v);const p=u.match(/data:([^;,]+)/)?.[1]??"image/png";let _="png";return p.includes("jpeg")||p.includes("jpg")?_="jpeg":p.includes("gif")&&(_="gif"),{url:o,buffer:m.buffer,ext:_}}const l=await fetch(o,{mode:"cors"});if(!l.ok)throw new Error(`HTTP ${l.status}`);const s=await l.arrayBuffer(),d=Or(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 Ar(n,t,e={}){const{fileName:o="export.xlsx",sheets:l,columnStyles:s={},headerFillColor:d="#f1f5f9",headerTextColor:a="#334155",headerFontSize:u=10,bodyFontSize:c=10,aggregationResult:h=null,aggregationModel:m=null,selectedRows:f}=e,p=(await import("exceljs")).default,_=new p.Workbook;_.creator="OpenGridX",_.created=new Date;const v=t.filter(E=>E.exportable!==!1&&E.field!=="__check__"&&E.field!=="__actions__"&&!E.isSpacer),j=n,I=f&&f.length>0?n.filter(E=>f.includes(E.id)):n,k=l??[{name:"Data",rows:"all",includeHeaders:!0,includeSummary:!1}],w=new Map;for(const E of k){if("type"in E&&E.type==="summary"){if(!h||!m)continue;const S=_.addWorksheet(E.name??"Summary");S.addRow(["Summary / Aggregation Totals"]),S.getRow(1).font={bold:!0,size:u+2,color:{argb:Le(a)}},S.addRow([]),S.addRow(["Column","Function","Value"]).eachCell(W=>{W.fill={type:"pattern",pattern:"solid",fgColor:{argb:Le(d)}},W.font={bold:!0,size:u,color:{argb:Le(a)}},W.border=Mn()}),v.forEach(W=>{const A=m[W.field],$=h[W.field];if(A==null||$==null)return;let X=$;W.valueFormatter?X=W.valueFormatter({value:$,row:{},field:W.field}):X=Te($,A);const U=S.addRow([W.headerName??W.field,A.toUpperCase(),X]);U.getCell(3).alignment={horizontal:"right"},U.getCell(3).font={bold:!0,size:c}}),S.getColumn(1).width=20,S.getColumn(2).width=12,S.getColumn(3).width=18;continue}const M=E,{name:N="Data",rows:C="all",includeHeaders:P=!0,includeSummary:O=!1,autoFilter:T=!0,frozenHeader:F=!0,alternateRowColor:H="#f8fafc"}=M,L=C==="selected"?I:j,D=v.filter(S=>s[S.field]?.embedImage);if(D.length>0){const S=[],B=new Set;if(L.forEach(W=>{D.forEach(A=>{const $=W[A.field];typeof $=="string"&&$&&!w.has($)&&!B.has($)&&(S.push($),B.add($))})}),S.length>0){const W=await Fr(S);for(const[A,{buffer:$,extension:X}]of W){const U=_.addImage({buffer:$,extension:X});w.set(A,U)}}}const K=_.addWorksheet(N);if(K.columns=v.map(S=>({key:S.field,width:Wr(S,s[S.field]?.width),style:{numFmt:s[S.field]?.numFmt??Rr(S)}})),P){const S=v.map(W=>W.headerName??W.field),B=K.addRow(S);B.height=20,B.eachCell((W,A)=>{const $=v[A-1];W.fill={type:"pattern",pattern:"solid",fgColor:{argb:Le(d)}},W.font={bold:!0,size:u,color:{argb:Le(a)}},W.alignment={horizontal:s[$?.field]?.alignment??($?.type==="number"?"right":"left"),vertical:"middle"},W.border=Mn()}),T&&(K.autoFilter={from:{row:1,column:1},to:{row:1,column:v.length}}),F?K.views=[{state:"frozen",ySplit:1,showGridLines:!1}]:K.views=[{showGridLines:!1}]}let G=P?1:0;if(L.forEach((S,B)=>{const W=v.map($=>{if(s[$.field]?.embedImage)return"";let X=S[$.field];return $.valueGetter&&(X=$.valueGetter({row:S,field:$.field,value:X})),Lr($,X)==="string"&&$.valueFormatter&&X!=null&&(X=$.valueFormatter({value:X,row:S,field:$.field})),X}),A=K.addRow(W);if(A.font={size:c},H&&B%2===1&&A.eachCell($=>{$.fill={type:"pattern",pattern:"solid",fgColor:{argb:Le(H)}}}),A.eachCell(($,X)=>{const U=v[X-1];U&&($.alignment={horizontal:s[U.field]?.alignment??(U.type==="number"?"right":"left"),vertical:"middle"},$.border={bottom:{style:"thin",color:{argb:"FFf1f5f9"}}})}),D.length>0){const $=D.reduce((oe,R)=>Math.max(oe,s[R.field]?.imageHeight??40),0),X=Math.ceil($/1.333),U=X*1.333;A.height=X,D.forEach(oe=>{const R=v.indexOf(oe),Q=S[oe.field],Z=typeof Q=="string"?w.get(Q):void 0;if(Z===void 0){A.getCell(R+1).value=typeof Q=="string"?Q:"";return}const le=s[oe.field],re=le?.imageWidth??40,Y=le?.imageHeight??40,se=(K.getColumn(R+1).width??8)*7+5,ae=Math.max(0,se-re)/2,z=Math.max(0,U-Y)/2;K.addImage(Z,{tl:{col:R,row:G,nativeColOff:Math.floor(ae*9525),nativeRowOff:Math.floor(z*9525)},ext:{width:re,height:Y},editAs:"oneCell"})})}else A.height=16;G++}),O&&h&&m){const S=v.map($=>{const X=m[$.field];return X?X.toUpperCase():""}),B=K.addRow(S);B.height=16,B.font={size:c-1,italic:!0,color:{argb:"FF94a3b8"}},B.eachCell($=>{$.alignment={horizontal:"right",vertical:"middle"},$.border={top:{style:"thin",color:{argb:"FFcbd5e1"}}}});const W=v.map($=>{const X=m[$.field],U=h[$.field];return X==null||U==null?"":$.valueFormatter?$.valueFormatter({value:U,row:{},field:$.field}):Te(U,X)}),A=K.addRow(W);A.height=18,A.font={bold:!0,size:c,color:{argb:Le(a)}},A.eachCell($=>{$.fill={type:"pattern",pattern:"solid",fgColor:{argb:Le(d)}},$.alignment={horizontal:"right",vertical:"middle"},$.border=zr()})}}const y=await _.xlsx.writeBuffer(),b=new Blob([y],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),g=URL.createObjectURL(b),x=document.createElement("a");x.href=g,x.download=o.endsWith(".xlsx")?o:`${o}.xlsx`,document.body.appendChild(x),x.click(),document.body.removeChild(x),URL.revokeObjectURL(g)}function Le(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 Mn(){return{bottom:{style:"medium",color:{argb:"FFcbd5e1"}}}}function zr(){return{top:{style:"medium",color:{argb:"FFcbd5e1"}}}}const Br={"--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 $r(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 Hr({theme:n,children:t,className:e,style:o}){const l=i.useMemo(()=>({...Br,...$r(n)}),[n]);return r.jsx("div",{className:`ogx-theme-provider ${e||""}`.trim(),style:{...o,...l},children:t})}const Dr={colors:{primary:"#60a5fa",primaryDark:"#3b82f6",primaryLight:"#1e3a5f",primaryFocus:"rgba(96, 165, 250, 0.4)"},grid:{background:"#0f172a",headerBackground:"#1e293b",headerText:"#e2e8f0",headerHoverBackground:"#334155",headerSortedBackground:"#1e3a5f",rowText:"#cbd5e1",borderColor:"#334155",rowHoverBackground:"#1e293b",rowAlternateBackground:"#162032",rowSelectedBackground:"#1e3a5f",rowSelectedHoverBackground:"#1d4ed8",cellFocusBorder:"#60a5fa",checkboxBg:"#1e293b",checkboxBorder:"#64748b"},borders:{color:"#334155",colorHover:"#475569"},shadows:{sm:"0 1px 2px 0 rgba(0, 0, 0, 0.3)",md:"0 4px 6px -1px rgba(0, 0, 0, 0.3)"},toolbar:{background:"transparent",text:"#cbd5e1",border:"#334155",buttonBackground:"transparent",buttonHoverBackground:"#1e293b",buttonText:"#e2e8f0",buttonPrimaryBackground:"#3b82f6",buttonPrimaryHoverBackground:"#2563eb",buttonPrimaryText:"#ffffff",buttonDangerBackground:"rgba(239, 68, 68, 0.15)",buttonDangerHoverBackground:"rgba(239, 68, 68, 0.25)",buttonDangerText:"#fca5a5",inputBackground:"#0f172a",inputText:"#f8fafc",inputBorder:"#334155",inputFocusBorder:"#60a5fa",inputFocusShadow:"0 0 0 3px rgba(96, 165, 250, 0.2)",chipBackground:"#1e293b",chipText:"#94a3b8",chipActiveBackground:"rgba(96, 165, 250, 0.2)",chipActiveText:"#60a5fa"},overlays:{background:"#1e293b",text:"#f8fafc",border:"#334155",shadow:"0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3)",itemHoverBackground:"#334155",itemHoverText:"#ffffff",itemSelectedBackground:"rgba(96, 165, 250, 0.15)",itemSelectedText:"#60a5fa",itemDangerBackground:"rgba(239, 68, 68, 0.15)",itemDangerText:"#fca5a5"},scrollbar:{thumbColor:"rgba(148, 163, 184, 0.2)",trackColor:"transparent"},skeleton:{baseColor:"#1e293b",highlightColor:"#334155",darkBaseColor:"#0f172a",darkHighlightColor:"#1e293b"}},Gr={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"}},Vr={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"}},Ur={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"}},Kr={grid:{rowHeightCompact:"28px",rowHeightStandard:"36px",rowHeightComfortable:"48px",headerHeight:"40px",cellPaddingX:"8px",cellPaddingY:"4px"},typography:{fontSizeSm:"0.8rem",fontSizeMd:"0.875rem"}};function Yr(n,t){try{const e=t.getItem(n);return e?JSON.parse(e):void 0}catch{return}}function qr(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 Xr(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 Yr(e,s)},[e,s]),a=i.useRef(null),u=i.useRef(null),c=i.useCallback(()=>{u.current&&s&&qr(e,u.current,l,s)},[e,l,s]),h=i.useCallback(f=>{u.current=f,a.current&&clearTimeout(a.current),a.current=setTimeout(c,o)},[c,o]);i.useEffect(()=>()=>{a.current&&(clearTimeout(a.current),c())},[c]);const m=i.useCallback(()=>{s&&s.removeItem(e)},[e,s]);return{initialState:d,onStateChange:h,clearState:m}}ie.Button=dt,ie.Cell=_n,ie.Checkbox=at,ie.DataGrid=ur,ie.DataGridThemeProvider=Hr,ie.FilterPanel=Sn,ie.GridToolbar=jr,ie.GridTooltip=ut,ie.Header=mn,ie.Input=Nr,ie.Row=bt,ie.Skeleton=fr,ie.amberTheme=Ur,ie.compactTheme=Kr,ie.darkTheme=Dr,ie.emeraldTheme=Vr,ie.exportToCsv=Mr,ie.exportToExcel=Ir,ie.exportToExcelAdvanced=Ar,ie.exportToJson=Pr,ie.formatAggregationValue=Te,ie.printGrid=Tr,ie.roseTheme=Gr,ie.useAggregation=pn,ie.useGridApiRef=Er,ie.useGridStateStorage=Xr,ie.usePivot=vn,Object.defineProperty(ie,Symbol.toStringTag,{value:"Module"})}));
52
+ `;if(i&&(p+=`<h1>${Me(i)}</h1>`),p+="<table>",p+="<thead><tr>",c.forEach(h=>{p+=`<th>${Me(h.headerName||h.field)}</th>`}),p+="</tr></thead>",p+="<tbody>",u.forEach(h=>{p+="<tr>",c.forEach(b=>{let _=h[b.field];b.valueGetter&&(_=b.valueGetter({row:h,field:b.field,value:_})),b.valueFormatter&&_!==void 0&&_!==null&&(_=b.valueFormatter({value:_,row:h,field:b.field})),b.type==="image"&&_?p+=`<td><div style="display:flex;justify-content:center;"><img src="${_}" alt="${b.headerName}" style="max-height: 40px; border-radius: 4px;"></div></td>`:p+=`<td>${Me(String(_??""))}</td>`}),p+="</tr>"}),d){const h=a||{};p+='<tfoot><tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',c.forEach(b=>{h[b.field]?p+=`<td style="text-align: right; font-weight: bold;">${Me(h[b.field].toUpperCase())}</td>`:p+="<td></td>"}),p+='</tr><tr style="font-weight: bold; background-color: #f5f5f5;">',c.forEach(b=>{const _=d[b.field];if(_!=null){let C=_;b.valueFormatter?C=b.valueFormatter({value:_,row:{},field:b.field}):h[b.field]&&(C=Ne(_,h[b.field])),p+=`<td style="text-align: right;">${Me(String(C))}</td>`}else p+="<td></td>"}),p+="</tr></tfoot>"}p+="</tbody></table></body></html>",o.document.open(),o.document.write(p),o.document.close(),o.document.title=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 s=i instanceof Error?i.message:String(i);o.document.body.innerHTML=`<div style="color: red; padding: 20px;"><h3>Error Generating Print Preview</h3><p>${s}</p></div>`}}}function Vt(n,t,e){const o=new Blob([n],{type:e}),i=URL.createObjectURL(o),s=document.createElement("a");s.href=i,s.download=t,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(i)}function Kr(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 Yr(n){if(n.type==="number")return"#,##0.##";if(n.type==="date")return"yyyy-mm-dd"}function qr(n,t){if(t!=null)return t;const e=n.width??120;return Math.min(60,Math.max(8,(e-5)/7))}function Xr(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 Jr(n){const t=await Promise.allSettled(n.map(async o=>{if(o.startsWith("data:")){const a=o.indexOf(","),u=o.slice(0,a),c=o.slice(a+1),p=atob(c),w=new Uint8Array(p.length);for(let C=0;C<p.length;C++)w[C]=p.charCodeAt(C);const b=u.match(/data:([^;,]+)/)?.[1]??"image/png";let _="png";return b.includes("jpeg")||b.includes("jpg")?_="jpeg":b.includes("gif")&&(_="gif"),{url:o,buffer:w.buffer,ext:_}}const i=await fetch(o,{mode:"cors"});if(!i.ok)throw new Error(`HTTP ${i.status}`);const s=await i.arrayBuffer(),d=Xr(o,i.headers.get("content-type"));return{url:o,buffer:s,ext:d}})),e=new Map;return t.forEach((o,i)=>{o.status==="fulfilled"?e.set(o.value.url,{buffer:o.value.buffer,extension:o.value.ext}):console.warn(`[exportToExcelAdvanced] Cannot embed image "${n[i]}" (CORS/network error — raw URL written as fallback):`,o.reason)}),e}async function Qr(n,t,e={}){const{fileName:o="export.xlsx",sheets:i,columnStyles:s={},headerFillColor:d="#f1f5f9",headerTextColor:a="#334155",headerFontSize:u=10,bodyFontSize:c=10,aggregationResult:p=null,aggregationModel:w=null,selectedRows:h}=e,b=(await import("exceljs")).default,_=new b.Workbook;_.creator="OpenGridX",_.created=new Date;const C=t.filter(S=>S.exportable!==!1&&S.field!=="__check__"&&S.field!=="__actions__"&&!S.isSpacer),k=n,M=h&&h.length>0?n.filter(S=>h.includes(S.id)):n,j=i??[{name:"Data",rows:"all",includeHeaders:!0,includeSummary:!1}],x=new Map;for(const S of j){if("type"in S&&S.type==="summary"){if(!p||!w)continue;const y=_.addWorksheet(S.name??"Summary");y.addRow(["Summary / Aggregation Totals"]),y.getRow(1).font={bold:!0,size:u+2,color:{argb:Oe(a)}},y.addRow([]),y.addRow(["Column","Function","Value"]).eachCell(z=>{z.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(d)}},z.font={bold:!0,size:u,color:{argb:Oe(a)}},z.border=Rn()}),C.forEach(z=>{const $=w[z.field],H=p[z.field];if($==null||H==null)return;let X=H;z.valueFormatter?X=z.valueFormatter({value:H,row:{},field:z.field}):X=Ne(H,$);const Y=y.addRow([z.headerName??z.field,$.toUpperCase(),X]);Y.getCell(3).alignment={horizontal:"right"},Y.getCell(3).font={bold:!0,size:c}}),y.getColumn(1).width=20,y.getColumn(2).width=12,y.getColumn(3).width=18;continue}const P=S,{name:N="Data",rows:v="all",includeHeaders:I=!0,includeSummary:R=!1,autoFilter:W=!0,frozenHeader:F=!0,alternateRowColor:U="#f8fafc"}=P,T=v==="selected"?M:k,B=C.filter(y=>s[y.field]?.embedImage);if(B.length>0){const y=[],L=new Set;if(T.forEach(z=>{B.forEach($=>{const H=z[$.field];typeof H=="string"&&H&&!x.has(H)&&!L.has(H)&&(y.push(H),L.add(H))})}),y.length>0){const z=await Jr(y);for(const[$,{buffer:H,extension:X}]of z){const Y=_.addImage({buffer:H,extension:X});x.set($,Y)}}}const G=_.addWorksheet(N);if(G.columns=C.map(y=>({key:y.field,width:qr(y,s[y.field]?.width),style:{numFmt:s[y.field]?.numFmt??Yr(y)}})),I){const y=C.map(z=>z.headerName??z.field),L=G.addRow(y);L.height=20,L.eachCell((z,$)=>{const H=C[$-1];z.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(d)}},z.font={bold:!0,size:u,color:{argb:Oe(a)}},z.alignment={horizontal:s[H?.field]?.alignment??(H?.type==="number"?"right":"left"),vertical:"middle"},z.border=Rn()}),W&&(G.autoFilter={from:{row:1,column:1},to:{row:1,column:C.length}}),F?G.views=[{state:"frozen",ySplit:1,showGridLines:!1}]:G.views=[{showGridLines:!1}]}let V=I?1:0;if(T.forEach((y,L)=>{const z=C.map(H=>{if(s[H.field]?.embedImage)return"";let X=y[H.field];return H.valueGetter&&(X=H.valueGetter({row:y,field:H.field,value:X})),Kr(H,X)==="string"&&H.valueFormatter&&X!=null&&(X=H.valueFormatter({value:X,row:y,field:H.field})),X}),$=G.addRow(z);if($.font={size:c},U&&L%2===1&&$.eachCell(H=>{H.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(U)}}}),$.eachCell((H,X)=>{const Y=C[X-1];Y&&(H.alignment={horizontal:s[Y.field]?.alignment??(Y.type==="number"?"right":"left"),vertical:"middle"},H.border={bottom:{style:"thin",color:{argb:"FFf1f5f9"}}})}),B.length>0){const H=B.reduce((te,O)=>Math.max(te,s[O.field]?.imageHeight??40),0),X=Math.ceil(H/1.333),Y=X*1.333;$.height=X,B.forEach(te=>{const O=C.indexOf(te),J=y[te.field],Q=typeof J=="string"?x.get(J):void 0;if(Q===void 0){$.getCell(O+1).value=typeof J=="string"?J:"";return}const le=s[te.field],oe=le?.imageWidth??40,pe=le?.imageHeight??40,ie=(G.getColumn(O+1).width??8)*7+5,se=Math.max(0,ie-oe)/2,D=Math.max(0,Y-pe)/2;G.addImage(Q,{tl:{col:O,row:V,nativeColOff:Math.floor(se*9525),nativeRowOff:Math.floor(D*9525)},ext:{width:oe,height:pe},editAs:"oneCell"})})}else $.height=16;V++}),R&&p&&w){const y=C.map(H=>{const X=w[H.field];return X?X.toUpperCase():""}),L=G.addRow(y);L.height=16,L.font={size:c-1,italic:!0,color:{argb:"FF94a3b8"}},L.eachCell(H=>{H.alignment={horizontal:"right",vertical:"middle"},H.border={top:{style:"thin",color:{argb:"FFcbd5e1"}}}});const z=C.map(H=>{const X=w[H.field],Y=p[H.field];return X==null||Y==null?"":H.valueFormatter?H.valueFormatter({value:Y,row:{},field:H.field}):Ne(Y,X)}),$=G.addRow(z);$.height=18,$.font={bold:!0,size:c,color:{argb:Oe(a)}},$.eachCell(H=>{H.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(d)}},H.alignment={horizontal:"right",vertical:"middle"},H.border=Zr()})}}const E=await _.xlsx.writeBuffer(),f=new Blob([E],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),m=URL.createObjectURL(f),g=document.createElement("a");g.href=m,g.download=o.endsWith(".xlsx")?o:`${o}.xlsx`,document.body.appendChild(g),g.click(),document.body.removeChild(g),URL.revokeObjectURL(m)}function Oe(n){const t=n.replace("#","");return t.length===3?"FF"+t.split("").map(e=>e+e).join(""):t.length===6?"FF"+t:"FF"+t.padEnd(6,"0")}function Rn(){return{bottom:{style:"medium",color:{argb:"FFcbd5e1"}}}}function Zr(){return{top:{style:"medium",color:{argb:"FFcbd5e1"}}}}const ei={"--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 ti(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 ni({theme:n,children:t,className:e,style:o}){const i=l.useMemo(()=>({...ei,...ti(n)}),[n]);return r.jsx("div",{className:`ogx-theme-provider ${e||""}`.trim(),style:{...o,...i},children:t})}const oi={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"}},ri={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"}},ii={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"}},li={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"}},si={grid:{rowHeightCompact:"28px",rowHeightStandard:"36px",rowHeightComfortable:"48px",headerHeight:"40px",cellPaddingX:"8px",cellPaddingY:"4px"},typography:{fontSizeSm:"0.8rem",fontSizeMd:"0.875rem"}};function ai(n,t){try{const e=t.getItem(n);return e?JSON.parse(e):void 0}catch{return}}function di(n,t,e,o){try{const i=e?Object.fromEntries(Object.entries(t).filter(([s])=>e.includes(s))):t;o.setItem(n,JSON.stringify(i))}catch{}}function ci(n){const t=typeof n=="string"?{key:n}:n,{key:e,debounceMs:o=300,include:i,storage:s=typeof window<"u"?window.localStorage:void 0}=t,d=l.useMemo(()=>{if(s)return ai(e,s)},[e,s]),a=l.useRef(null),u=l.useRef(null),c=l.useCallback(()=>{u.current&&s&&di(e,u.current,i,s)},[e,i,s]),p=l.useCallback(h=>{u.current=h,a.current&&clearTimeout(a.current),a.current=setTimeout(c,o)},[c,o]);l.useEffect(()=>()=>{a.current&&(clearTimeout(a.current),c())},[c]);const w=l.useCallback(()=>{s&&s.removeItem(e)},[e,s]);return{initialState:d,onStateChange:p,clearState:w}}re.Button=ut,re.Cell=kn,re.Checkbox=ct,re.DataGrid=vr,re.DataGridThemeProvider=ni,re.FilterPanel=Nn,re.GridToolbar=Or,re.GridTooltip=gt,re.Header=vn,re.Input=Fr,re.Row=yt,re.Skeleton=_r,re.amberTheme=li,re.compactTheme=si,re.darkTheme=oi,re.emeraldTheme=ii,re.exportToCsv=Hr,re.exportToExcel=Gr,re.exportToExcelAdvanced=Qr,re.exportToJson=Vr,re.exportToPdf=Dr,re.formatAggregationValue=Ne,re.printGrid=Ur,re.roseTheme=ri,re.useAggregation=bn,re.useGridApiRef=Wr,re.useGridStateStorage=ci,re.usePivot=yn,Object.defineProperty(re,Symbol.toStringTag,{value:"Module"})}));
53
53
  //# sourceMappingURL=opengridx.umd.js.map