@opencorestack/opengridx 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/opengridx.es.js +3485 -3370
- package/dist/opengridx.es.js.map +1 -1
- package/dist/opengridx.umd.js +11 -11
- package/dist/opengridx.umd.js.map +1 -1
- package/lib/components/Cell/Cell.tsx +53 -55
- package/lib/components/DataGrid/DataGrid.smoke.test.tsx +58 -0
- package/lib/components/DataGrid/DataGrid.tsx +65 -641
- package/lib/components/Row/Row.tsx +39 -38
- package/lib/components/Toolbar/GlobalSearch.tsx +1 -1
- package/lib/components/Toolbar/GridToolbar.tsx +20 -5
- package/lib/components/Toolbar/PivotPanel.tsx +7 -2
- package/lib/components/ui/DragHandleIcon.tsx +1 -1
- package/lib/hooks/core/useDataGrid.ts +2 -2
- package/lib/hooks/core/useGridKeyboardNavigation.ts +371 -0
- package/lib/hooks/core/useLayout.ts +354 -0
- package/lib/hooks/features/useAggregation.test.ts +135 -0
- package/lib/hooks/features/useGridClipboard.ts +1 -1
- package/lib/hooks/features/useGridDataSource.ts +1 -1
- package/lib/state/useGridStateStorage.ts +1 -1
- package/lib/utils/export/index.ts +1 -1
- package/lib/utils/filtering/filtering.test.ts +178 -0
- package/lib/utils/sorting/sorting.test.ts +88 -0
- package/package.json +12 -5
- package/lib/utils/virtualization/index.ts +0 -106
package/dist/opengridx.umd.js
CHANGED
|
@@ -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,
|
|
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,nt){"use strict";var Ot={exports:{}},Ct={};var En;function xo(){if(En)return Ct;En=1;var t=Symbol.for("react.transitional.element"),o=Symbol.for("react.fragment");function e(r,l,a){var d=null;if(a!==void 0&&(d=""+a),l.key!==void 0&&(d=""+l.key),"key"in l){a={};for(var s in l)s!=="key"&&(a[s]=l[s])}else a=l;return l=a.ref,{$$typeof:t,type:r,key:d,ref:l!==void 0?l:null,props:a}}return Ct.Fragment=o,Ct.jsx=e,Ct.jsxs=e,Ct}var yt={};var Nn;function mo(){return Nn||(Nn=1,process.env.NODE_ENV!=="production"&&(function(){function t(_){if(_==null)return null;if(typeof _=="function")return _.$$typeof===C?null:_.displayName||_.name||null;if(typeof _=="string")return _;switch(_){case j:return"Fragment";case k:return"Profiler";case P:return"StrictMode";case v:return"Suspense";case N:return"SuspenseList";case M:return"Activity"}if(typeof _=="object")switch(typeof _.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),_.$$typeof){case h:return"Portal";case y:return _.displayName||"Context";case E:return(_._context.displayName||"Context")+".Consumer";case g:var G=_.render;return _=_.displayName,_||(_=G.displayName||G.name||"",_=_!==""?"ForwardRef("+_+")":"ForwardRef"),_;case S:return G=_.displayName||null,G!==null?G:t(_.type)||"Memo";case I:G=_._payload,_=_._init;try{return t(_(G))}catch{}}return null}function o(_){return""+_}function e(_){try{o(_);var G=!1}catch{G=!0}if(G){G=console;var B=G.error,z=typeof Symbol=="function"&&Symbol.toStringTag&&_[Symbol.toStringTag]||_.constructor.name||"Object";return B.call(G,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",z),o(_)}}function r(_){if(_===j)return"<>";if(typeof _=="object"&&_!==null&&_.$$typeof===I)return"<...>";try{var G=t(_);return G?"<"+G+">":"<...>"}catch{return"<...>"}}function l(){var _=W.A;return _===null?null:_.getOwner()}function a(){return Error("react-stack-top-frame")}function d(_){if(Y.call(_,"key")){var G=Object.getOwnPropertyDescriptor(_,"key").get;if(G&&G.isReactWarning)return!1}return _.key!==void 0}function s(_,G){function B(){K||(K=!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)",G))}B.isReactWarning=!0,Object.defineProperty(_,"key",{get:B,configurable:!0})}function f(){var _=t(this.type);return O[_]||(O[_]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),_=this.props.ref,_!==void 0?_:null}function c(_,G,B,z,L,X){var H=B.ref;return _={$$typeof:w,type:_,key:G,props:B,_owner:z},(H!==void 0?H:null)!==null?Object.defineProperty(_,"ref",{enumerable:!1,get:f}):Object.defineProperty(_,"ref",{enumerable:!1,value:null}),_._store={},Object.defineProperty(_._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(_,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(_,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:L}),Object.defineProperty(_,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:X}),Object.freeze&&(Object.freeze(_.props),Object.freeze(_)),_}function p(_,G,B,z,L,X){var H=G.children;if(H!==void 0)if(z)if(F(H)){for(z=0;z<H.length;z++)m(H[z]);Object.freeze&&Object.freeze(H)}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(H);if(Y.call(G,"key")){H=t(_);var R=Object.keys(G).filter(function(Z){return Z!=="key"});z=0<R.length?"{key: someKey, "+R.join(": ..., ")+": ...}":"{key: someKey}",ee[H+z]||(R=0<R.length?"{"+R.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} />`,K,$,L,$),pe[$+K]=!0)}if($=null,H!==void 0&&(e(H),$=""+H),d(D)&&(e(D.key),$=""+D.key),"key"in D){H={};for(var ae in D)ae!=="key"&&(H[ae]=D[ae])}else H=D;return $&&s(H,typeof _=="function"?_.displayName||_.name||"Unknown":_),u(_,$,H,l(),R,Y)}function m(_){p(_)?_._store&&(_._store.validated=1):typeof _=="object"&&_!==null&&_.$$typeof===x&&(_._payload.status==="fulfilled"?p(_._payload.value)&&_._payload.value._store&&(_._payload.value._store.validated=1):_._store&&(_._store.validated=1))}function p(_){return typeof _=="object"&&_!==null&&_.$$typeof===C}var f=i,C=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),P=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),j=Symbol.for("react.consumer"),y=Symbol.for("react.context"),w=Symbol.for("react.forward_ref"),v=Symbol.for("react.suspense"),M=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),O=Symbol.for("react.client.reference"),W=f.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,X=Object.prototype.hasOwnProperty,A=Array.isArray,U=console.createTask?console.createTask:function(){return null};f={react_stack_bottom_frame:function(_){return _()}};var q,G={},ee=f.react_stack_bottom_frame.bind(f,a)(),Q=U(r(a)),pe={};Xt.Fragment=E,Xt.jsx=function(_,D,H){var K=1e4>W.recentlyCreatedOwnerStacks++;return h(_,D,H,!1,K?Error("react-stack-top-frame"):ee,K?U(r(_)):Q)},Xt.jsxs=function(_,D,H){var K=1e4>W.recentlyCreatedOwnerStacks++;return h(_,D,H,!0,K?Error("react-stack-top-frame"):ee,K?U(r(_)):Q)}})()),Xt}var eo;function Ao(){return eo||(eo=1,process.env.NODE_ENV==="production"?an.exports=Fo():an.exports=Wo()),an.exports}var t=Ao();function zo({row:n,rowIndex:o,listViewColumn:e,isSelected:r=!1,checkboxSelection:l=!1,rowHeight:a,onRowClick:d,onSelectionChange:s}){const g={row:n,value:void 0,field:e.field,colDef:{field:e.field},rowIndex:o,colIndex:0},u=h=>{h.stopPropagation(),s?.(n.id,h.target.checked)};return t.jsxs("div",{className:`ogx-list-view__row${r?" ogx-list-view__row--selected":""}`,style:a?{minHeight:a}:void 0,onClick:()=>d?.(n),role:"row","aria-rowindex":o+2,"aria-selected":r,children:[l&&t.jsx("div",{className:"ogx-list-view__checkbox",onClick:h=>h.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:r,onChange:u,"aria-label":`Select row ${n.id}`})}),t.jsx("div",{className:"ogx-list-view__cell",role:"gridcell",children:e.renderCell(g)})]})}const qt=({indeterminate:n=!1,label:o,className:e="",inputRef:r,...l})=>{const a=i.useRef(null),d=i.useCallback(g=>{a.current=g,typeof r=="function"?r(g):r&&(r.current=g)},[r]);i.useEffect(()=>{a.current&&(a.current.indeterminate=n)},[n]);const s=["ogx-checkbox-wrapper",l.disabled&&"ogx-checkbox-wrapper--disabled",e].filter(Boolean).join(" ");return t.jsxs("label",{className:s,children:[t.jsx("input",{ref:d,type:"checkbox",className:"ogx-checkbox__input","aria-label":o||l["aria-label"]||(n?"Select some":l.checked?"Deselect":"Select"),...l}),t.jsxs("span",{className:"ogx-checkbox__box",children:[l.checked&&!n&&t.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:t.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})}),n&&t.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:t.jsx("path",{d:"M19 13H5v-2h14v2z"})})]}),o&&t.jsx("span",{className:"ogx-checkbox__label",children:o})]})};function Bo(n){const{field:o,currentWidth:e,onResize:r,minWidth:l=50,maxWidth:a=1e3}=n,[d,s]=i.useState(!1),g=i.useRef(0),u=i.useRef(0),h=i.useCallback(f=>{f.preventDefault(),f.stopPropagation(),s(!0),g.current=f.clientX,u.current=e;let C=0;const b=16,E=k=>{const j=k.clientX-g.current,y=Math.max(l,Math.min(a,u.current+j)),w=Date.now();w-C>=b&&(r(o,y),C=w)},P=k=>{s(!1);const j=k.clientX-g.current,y=Math.max(l,Math.min(a,u.current+j));r(o,y),document.removeEventListener("mousemove",E),document.removeEventListener("mouseup",P)};document.addEventListener("mousemove",E),document.addEventListener("mouseup",P)},[o,e,r,l,a]),m=i.useCallback(f=>{f.preventDefault(),f.stopPropagation()},[]),p=["ogx-column-resize-handle",d&&"ogx-column-resize-handle--dragging"].filter(Boolean).join(" ");return t.jsx("div",{className:p,onMouseDown:h,onClick:f=>f.stopPropagation(),onDragStart:f=>{f.preventDefault(),f.stopPropagation()},onDoubleClick:m,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${o} column`,children:t.jsx("div",{className:"ogx-column-resize-handle__line"})})}function dn(n,o){return o?o.left?.includes(n)?"left":o.right?.includes(n)?"right":null:null}function $o(n,o){const e=[],r=[],l=[];return o?(n.forEach(a=>{const d=dn(a.field,o);d==="left"?e.push(a):d==="right"?l.push(a):r.push(a)}),o.left&&e.sort((a,d)=>{const s=o.left.indexOf(a.field),g=o.left.indexOf(d.field);return s-g}),o.right&&l.sort((a,d)=>{const s=o.right.indexOf(a.field),g=o.right.indexOf(d.field);return s-g}),{left:e,center:r,right:l}):{left:e,center:n,right:l}}function to(n,o,e,r,l,a,d,s){const g={};if(!e)return g;const u=$o(n,e);let h=0;s&&(h+=48),a&&d&&(h+=48),r&&l&&(h+=48),u.left.forEach(p=>{g[p.field]=h;const f=o[p.field]??p.width??100;h+=f});let m=0;return[...u.right].reverse().forEach(p=>{const f=o[p.field]??p.width??100;g[p.field]=m,m+=f}),g}function En(n,o){return o?o.top?.includes(n)?"top":o.bottom?.includes(n)?"bottom":null:null}function Do(n,o){const e=[],r=[],l=[];return o?(n.forEach(a=>{const d=En(a.id,o);d==="top"?e.push(a):d==="bottom"?l.push(a):r.push(a)}),o.top&&e.sort((a,d)=>{const s=o.top.indexOf(a.id),g=o.top.indexOf(d.id);return s-g}),o.bottom&&l.sort((a,d)=>{const s=o.bottom.indexOf(a.id),g=o.bottom.indexOf(d.id);return s-g}),{top:e,center:r,bottom:l}):{top:e,center:n,bottom:l}}function Mt(){return t.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"currentColor",children:t.jsx("circle",{cx:"4",cy:"4",r:"4"})})}function Pt(){return t.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:t.jsx("circle",{cx:"4",cy:"4",r:"3"})})}function Ho(){return t.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",children:[t.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),t.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.3"}),t.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),t.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),t.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),t.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function Go(){return t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),t.jsx("polyline",{points:"5 12 12 5 19 12"})]})}function Vo(){return t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),t.jsx("polyline",{points:"19 12 12 19 5 12"})]})}function Uo(){return t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:t.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})}function Ko(){return t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.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"}),t.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"}),t.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function Yo(){return t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"4",y1:"2",x2:"4",y2:"22"}),t.jsx("polyline",{points:"11 8 4 12 11 16"}),t.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function Xo(){return t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"20",y1:"2",x2:"20",y2:"22"}),t.jsx("polyline",{points:"13 8 20 12 13 16"}),t.jsx("line",{x1:"20",y1:"12",x2:"4",y2:"12"})]})}function qo(){return t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),t.jsx("line",{x1:"4",y1:"4",x2:"4",y2:"20"}),t.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function Jo({colDef:n,sortModel:o,onSort:e,onHide:r,onPin:l,pinnedColumns:a,onManageColumns:d,onClose:s,anchorEl:g}){const u=i.useRef(null),[h,m]=i.useState({position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"});i.useLayoutEffect(()=>{if(!g||!u.current)return;const w=g.getBoundingClientRect(),v=u.current.getBoundingClientRect(),M=window.innerWidth,S=window.innerHeight,x=8;let N=w.left;N+v.width+x>M&&(N=M-v.width-x),N<x&&(N=x);let O=w.bottom+4;O+v.height+x>S&&(O=w.top-v.height-4),m({position:"fixed",zIndex:1300,top:O,left:N,visibility:"visible"})},[g]),i.useEffect(()=>{function w(M){u.current&&!u.current.contains(M.target)&&g&&!g.contains(M.target)&&s()}function v(M){M.key==="Escape"&&s()}return document.addEventListener("mousedown",w),document.addEventListener("keydown",v),window.addEventListener("scroll",s,!0),window.addEventListener("resize",s),()=>{document.removeEventListener("mousedown",w),document.removeEventListener("keydown",v),window.removeEventListener("scroll",s,!0),window.removeEventListener("resize",s)}},[g,s]);const p=w=>{e?.(n.field,w),s()},f=()=>{r?.(n.field),s()},C=w=>{l?.(n.field,w),s()},b=o?.find(w=>w.field===n.field)?.sort,E=b==null,P=a?.left?.includes(n.field)??!1,k=a?.right?.includes(n.field)??!1,j=!P&&!k,y=n.headerName||n.field;return St.createPortal(t.jsxs("div",{ref:u,className:"ogx-column-menu",style:h,role:"menu","aria-label":`Column options for ${y}`,children:[e&&n.sortable!==!1&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{className:`ogx-menu-item${b==="asc"?" ogx-menu-item--active":""}`,onClick:()=>p("asc"),role:"menuitemradio","aria-checked":b==="asc",children:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:b==="asc"?t.jsx(Mt,{}):t.jsx(Pt,{})}),t.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:t.jsx(Go,{})}),"Sort Ascending"]}),t.jsxs("button",{className:`ogx-menu-item${b==="desc"?" ogx-menu-item--active":""}`,onClick:()=>p("desc"),role:"menuitemradio","aria-checked":b==="desc",children:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:b==="desc"?t.jsx(Mt,{}):t.jsx(Pt,{})}),t.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:t.jsx(Vo,{})}),"Sort Descending"]}),t.jsxs("button",{className:`ogx-menu-item${E?" ogx-menu-item--active":""}`,onClick:()=>p(null),role:"menuitemradio","aria-checked":E,children:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:E?t.jsx(Mt,{}):t.jsx(Pt,{})}),t.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:t.jsx(Uo,{})}),"Unsort"]}),t.jsx("div",{className:"ogx-menu-divider"})]}),t.jsx("div",{className:"ogx-menu-section-label","aria-hidden":"true",children:"Pin column"}),t.jsxs("button",{className:`ogx-menu-item${P?" ogx-menu-item--active":""}`,onClick:()=>C("left"),role:"menuitemradio","aria-checked":P,"aria-label":"Pin to left",children:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:P?t.jsx(Mt,{}):t.jsx(Pt,{})}),t.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:t.jsx(Yo,{})}),"Pin to Left"]}),t.jsxs("button",{className:`ogx-menu-item${k?" ogx-menu-item--active":""}`,onClick:()=>C("right"),role:"menuitemradio","aria-checked":k,"aria-label":"Pin to right",children:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:k?t.jsx(Mt,{}):t.jsx(Pt,{})}),t.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:t.jsx(Xo,{})}),"Pin to Right"]}),t.jsxs("button",{className:`ogx-menu-item${j?" ogx-menu-item--active":""}`,onClick:()=>C(null),role:"menuitemradio","aria-checked":j,"aria-label":"Unpin column",children:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:j?t.jsx(Mt,{}):t.jsx(Pt,{})}),t.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:t.jsx(qo,{})}),"Unpin"]}),t.jsx("div",{className:"ogx-menu-divider"}),t.jsxs("button",{className:"ogx-menu-item",onClick:f,role:"menuitem","aria-label":`Hide ${y} column`,children:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),t.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:t.jsx(Ko,{})}),"Hide Column"]}),t.jsx("div",{className:"ogx-menu-divider"}),t.jsxs("button",{className:"ogx-menu-item",onClick:()=>{d?.(),s()},role:"menuitem","aria-label":"Manage all columns",children:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),t.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:t.jsx(Ho,{})}),"Manage columns"]})]}),g?.closest(".ogx-theme-provider")||document.body)}function Qo(){return t.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"18",height:"18",children:t.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 Zo(){return t.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor",children:t.jsx("path",{d:"M6.99 11L3 15l3.99 4v-3H14v-2H6.99v-3zM21 9l-3.99-4v3H10v2h7.01v3L21 9z"})})}function no(n){const o=[];for(const e of n.children)typeof e=="string"?o.push(e):o.push(...no(e));return o}function er(n){let o=0;function e(r,l){o=Math.max(o,l);for(const a of r.children)typeof a!="string"&&e(a,l+1)}return n.forEach(r=>e(r,1)),o}function tr(n,o,e){function r(s,g,u){if(!no(s).includes(g))return null;if(u===e)return s;for(const h of s.children)if(typeof h!="string"){const m=r(h,g,u+1);if(m)return m}return null}const l=new Map;for(const s of o){let g=null;for(const u of n)if(g=r(u,s.field,0),g)break;l.set(s.field,g)}const a=[];let d=0;for(;d<o.length;){const s=o[d],g=l.get(s.field)??null,u=s.width;if(!g)a.push({key:`fg-${s.field}-${e}`,label:"",width:u,isGroup:!1}),d++;else{let h=0,m=d;for(;m<o.length&&l.get(o[m].field)===g;)h+=o[m].width,m++;a.push({key:`${g.groupId}-${e}`,label:g.headerName,width:h,isGroup:!0}),d=m}}return a}function oo(n){const{columns:o,allColumns:e,columnGroupingModel:r,checkboxSelection:l=!1,allSelected:a=!1,someSelected:d=!1,onSelectAll:s,onSort:g,sortModel:u=[],onColumnResize:h,columnWidths:m={},pinnedColumns:p,hasDetailPanel:f=!1,pinCheckboxColumn:C=!0,pinExpandColumn:b=!0,rowReordering:E=!1,aggregationModel:P,draggedColumn:k,dragOverColumn:j,onDragStart:y,onDragOver:w,onDragEnd:v,onDrop:M,focusedCell:S,onHeaderClick:x,onHideColumn:N,onPinColumn:O,onManageColumns:W}=n,X=i.useRef({}),[A,U]=i.useState(null),q=L=>ae=>{ae.stopPropagation(),U({colDef:L,anchorEl:ae.currentTarget})},G=()=>{U(null)};i.useLayoutEffect(()=>{if(S?.id==="HEADER"){const L=X.current[S.field];L&&L.focus()}},[S]);const ee=L=>()=>{if(L.sortable===!1||!g)return;const ae=u.find(me=>me.field===L.field);let oe="asc";ae&&(ae.sort==="asc"?oe="desc":oe=null),g(L.field,oe)},Q=L=>{const ae=u.find(oe=>oe.field===L);return ae?t.jsx("span",{className:`ogx__sort-icon ogx__sort-icon--${ae.sort}`,"aria-hidden":"true"}):null},pe=i.useMemo(()=>to(o,m,p,l,C,f,b,E),[o,m,p,l,C,f,b,E]),_=r?er(r):0,H=(e??o).filter(L=>!L.isSpacer).map(L=>({field:L.field,width:m[L.field]??L.width??100})),$=(E?48:0)+(f?48:0)+(l?48:0);return t.jsxs("div",{className:"ogx__header-wrap",children:[_>0&&Array.from({length:_},(L,ae)=>{const oe=tr(r,H,ae);return t.jsxs("div",{className:"ogx-col-group-row",role:"row",children:[$>0&&t.jsx("div",{className:"ogx-col-group-cell ogx-col-group-cell--filler",style:{width:$,minWidth:$,flexShrink:0},role:"columnheader"}),oe.map(me=>t.jsx("div",{role:"columnheader",className:`ogx-col-group-cell ${me.isGroup?"ogx-col-group-cell--group":"ogx-col-group-cell--filler"}`,style:{width:me.width,minWidth:me.width,flexShrink:0},title:me.isGroup?me.label:void 0,children:me.isGroup&&t.jsx("span",{className:"ogx-col-group-cell__label",children:me.label})},me.key))]},`ogx-grp-${ae}`)}),t.jsxs("div",{className:"ogx__header",role:"row",children:[E&&t.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}}),f&&t.jsx("div",{className:`ogx__header-cell ogx__header-cell--expand ${b?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""}`,role:"columnheader","aria-label":"Expand row details",style:{minWidth:48,maxWidth:48,position:b?"sticky":void 0,left:b?E?48:0:void 0,zIndex:b?5:void 0}}),l&&t.jsx("div",{className:`ogx__header-cell ogx__header-cell--checkbox ${C?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""}`,role:"columnheader",style:{position:C?"sticky":void 0,left:C?(E?48:0)+(f&&b?48:0):void 0},children:t.jsx(qt,{id:"ogx-select-all",name:"ogx-select-all",checked:a,indeterminate:d,onChange:L=>s?.(L.target.checked),"aria-label":a?"Deselect all rows":"Select all rows",tabIndex:S?.id==="HEADER"&&S.field==="__checkbox_col__"?0:-1,onMouseDown:L=>L.preventDefault(),inputRef:L=>{X.current.__checkbox_col__=L}})}),o.map((L,ae)=>{if(L.isSpacer)return t.jsx("div",{style:{width:L.width,minWidth:L.width,flexShrink:0},"aria-hidden":"true"},L.field);const oe=L.sortable!==!1,me=u.some(Be=>Be.field===L.field),Ze=L.resizable!==!1,z=dn(L.field,p),Ne=z!==null,ye=k===L.field,ft=j===L.field,ze=["ogx__header-cell",`ogx__header-cell--align-${L.headerAlign||L.align||"left"}`,oe&&"ogx__header-cell--sortable",me&&"ogx__header-cell--sorted",Ne&&"ogx__header-cell--pinned",Ne&&`ogx__header-cell--pinned-${z}`,ye&&"ogx__header-cell--dragging",ft&&"ogx__header-cell--drag-over",S?.id==="HEADER"&&S.field===L.field&&"ogx__header-cell--focused",L.headerClassName].filter(Boolean).join(" "),et=m[L.field]??L.width??100,tt={width:et,minWidth:L.minWidth,maxWidth:L.maxWidth,flexGrow:L.flex??0,flexShrink:0,flexBasis:(L.flex,"auto"),boxSizing:"border-box",position:Ne?"sticky":"relative",zIndex:L.zIndex,opacity:ye?.5:1};if(Ne&&z){const Be=pe[L.field];z==="left"?tt.left=Be:tt.right=Be}const en=L.renderHeader?L.renderHeader({field:L.field,colDef:L,colIndex:ae}):L.headerName||L.field,Rt=Be=>{if(Be.target.closest(".ogx-column-resize-handle")){Be.stopPropagation();return}x?.(L.field),oe&&ee(L)()},jt=y?y(L.field):void 0,Ot=w?w(L.field):void 0,vt=M?M(L.field):void 0;return t.jsxs("div",{className:ze,style:tt,onClick:Rt,role:"columnheader",draggable:!!y,onDragStart:jt,onDragOver:Ot,onDragEnd:v,onDrop:vt,"aria-sort":oe?me?u.find(Be=>Be.field===L.field)?.sort==="asc"?"ascending":"descending":"none":void 0,"aria-colindex":ae+1+(l?1:0),"data-field":L.field,tabIndex:-1,ref:Be=>{X.current[L.field]=Be},children:[t.jsxs("div",{className:"ogx__header-cell-content",children:[ye&&t.jsx("div",{className:"ogx__header-drag-icon",children:t.jsx(Zo,{})}),t.jsxs("div",{className:"ogx__header-cell-title-wrapper",children:[t.jsx("span",{className:"ogx__header-cell-title",children:en}),P&&P[L.field]&&t.jsx("span",{className:"ogx__header-cell-aggregation",children:P[L.field]})]}),oe&&Q(L.field),!L.disableColumnMenu&&t.jsx("button",{className:"ogx__menu-icon-btn",onClick:q(L),"aria-label":`Open column menu for ${L.headerName||L.field}`,"aria-haspopup":"menu",tabIndex:-1,children:t.jsx(Qo,{})})]}),Ze&&h&&t.jsx(Bo,{field:L.field,currentWidth:et,onResize:h,minWidth:L.minWidth,maxWidth:L.maxWidth})]},L.field)}),A&&t.jsx(Jo,{colDef:A.colDef,sortModel:u,onSort:g,onHide:N,onPin:O,pinnedColumns:p,onManageColumns:W,onClose:G,anchorEl:A.anchorEl})]})]})}function nr({value:n,onValueChange:o,onCommit:e,onCancel:r}){const[l,a]=i.useState(String(n??"")),d=i.useRef(null);return i.useEffect(()=>{d.current?.focus(),d.current?.select()},[]),t.jsx("input",{ref:d,type:"text",className:"ogx__edit-input",value:l,onChange:s=>{a(s.target.value),o(s.target.value)},onBlur:e,onKeyDown:s=>{s.key==="Enter"&&(s.stopPropagation(),e()),s.key==="Escape"&&(s.stopPropagation(),r())}})}function or({value:n,onValueChange:o,onCommit:e,onCancel:r}){const[l,a]=i.useState(n??""),d=i.useRef(null);return i.useEffect(()=>{d.current?.focus(),d.current?.select()},[]),t.jsx("input",{ref:d,type:"number",className:"ogx__edit-input ogx__edit-input--number",value:l,onChange:s=>{const g=s.target.value===""?"":Number(s.target.value);a(g),o(g===""?null:g)},onBlur:e,onKeyDown:s=>{s.key==="Enter"&&(s.stopPropagation(),e()),s.key==="Escape"&&(s.stopPropagation(),r())}})}function rr({value:n,onValueChange:o,onCommit:e,onCancel:r}){const l=i.useRef(null);i.useEffect(()=>{l.current?.focus()},[]);const a=()=>{o(!n),setTimeout(e,0)};return t.jsx("div",{className:"ogx__edit-boolean",children:t.jsx("input",{ref:l,type:"checkbox",className:"ogx__edit-checkbox",checked:!!n,onChange:a,onKeyDown:d=>{d.key==="Escape"&&(d.stopPropagation(),r())}})})}function ir({value:n,colDef:o,onValueChange:e,onCommit:r,onCancel:l}){const a=i.useRef(null);i.useEffect(()=>{a.current?.focus()},[]);const d=o.valueOptions??[];return t.jsx("select",{ref:a,className:"ogx__edit-select",value:n??"",onChange:s=>{e(s.target.value)},onBlur:r,onKeyDown:s=>{s.key==="Enter"&&(s.stopPropagation(),r()),s.key==="Escape"&&(s.stopPropagation(),l())},children:d.map(s=>{const g=typeof s=="object"?s.value:s,u=typeof s=="object"?s.label:String(s);return t.jsx("option",{value:String(g),children:u},String(g))})})}function lr({value:n,onValueChange:o,onCommit:e,onCancel:r}){const[l,a]=i.useState(n??""),d=i.useRef(null);return i.useEffect(()=>{d.current?.focus()},[]),t.jsx("input",{ref:d,type:"date",className:"ogx__edit-input",value:l,onChange:s=>{a(s.target.value),o(s.target.value)},onBlur:e,onKeyDown:s=>{s.key==="Enter"&&(s.stopPropagation(),e()),s.key==="Escape"&&(s.stopPropagation(),r())}})}function sr(n){const{colDef:o}=n;switch(o.type){case"number":return t.jsx("div",{className:"ogx__edit-cell",children:t.jsx(or,{...n})});case"boolean":return t.jsx("div",{className:"ogx__edit-cell",children:t.jsx(rr,{...n})});case"singleSelect":return t.jsx("div",{className:"ogx__edit-cell",children:t.jsx(ir,{...n})});case"date":return t.jsx("div",{className:"ogx__edit-cell",children:t.jsx(lr,{...n})});default:return t.jsx("div",{className:"ogx__edit-cell",children:t.jsx(nr,{...n})})}}function ar(n){const{onCellClick:o,onCellEditStart:e,onCellValueChange:r,value:l,row:a,colDef:d,rowIndex:s,colIndex:g,isSelected:u,onClick:h,width:m,pinnedPosition:p,pinnedOffset:f,isFocused:C,isFocusVisible:b,isEditable:E,isEditing:P,onEditStart:k,onEditStop:j,onValueChange:y,colSpanInfo:w,rowSpan:v,isHiddenByRowSpan:M}=n;if(w?.spannedByColSpan)return null;if(M)return t.jsx("div",{className:"ogx__cell ogx__cell--hidden",style:{width:m??d.width??100},role:"presentation","data-field":d.field,"data-colindex":g});const S=_=>{o&&(_.stopPropagation(),o({row:a,field:d.field,value:l,colDef:d,rowIndex:s,colIndex:g})),h?.(_)},x=i.useCallback(_=>{r?r(d.field,_):y?.(_)},[r,y,d.field]),N=_=>{E&&(k||e)&&(_.stopPropagation(),e?e(d.field,l):k?.())},O=i.useMemo(()=>d.valueFormatter?d.valueFormatter({value:l,row:a,field:d.field}):l==null?"":String(l),[l,a,d]),W=i.useMemo(()=>P&&(r||y)&&j?d.renderEditCell?d.renderEditCell({value:l,row:a,field:d.field,colDef:d,rowIndex:s,colIndex:g}):t.jsx(sr,{value:l,row:a,field:d.field,colDef:d,rowIndex:s,colIndex:g,onValueChange:x,onCommit:()=>j(),onCancel:()=>j(!0)}):d.renderCell?d.renderCell({value:l,row:a,field:d.field,colDef:d,rowIndex:s,colIndex:g}):O,[l,a,d,s,g,O,P,x,j,r,y]),X=p!=null,A=i.useMemo(()=>d.cellClassName?typeof d.cellClassName=="function"?d.cellClassName({value:l,row:a,field:d.field,colDef:d,rowIndex:s,colIndex:g})||"":d.cellClassName:"",[d,l,a,s,g]),U=["ogx__cell",`ogx__cell--align-${d.align||"left"}`,u&&"ogx__cell--selected",C&&"ogx__cell--focused",C&&b&&"ogx__cell--focus-visible",d.type&&`ogx__cell--type-${d.type}`,X&&"ogx__cell--pinned",X&&`ogx__cell--pinned-${p}`,P&&"ogx__cell--editing",v&&v>1&&"ogx__cell--spanned",A].filter(Boolean).join(" "),q=w?.cellProps?.colSpan||1,G=v||1,ee=w?.cellProps?.width??m??d.width??100,Q={width:"var(--width)","--width":typeof ee=="number"?`${ee}px`:ee,flexGrow:d.flex??0,flexShrink:0,flexBasis:(d.flex,"auto"),boxSizing:"border-box",minWidth:d.minWidth,maxWidth:d.maxWidth,position:X?"sticky":void 0,zIndex:d.zIndex??(X?3:void 0),padding:P?0:void 0};G>1&&(Q.height=`calc(var(--height) * ${G} - var(--border-width, 1px))`,Q.zIndex=10,X&&(Q.zIndex=40)),X&&f!==void 0&&(p==="left"?Q.left=f:Q.right=f);const pe=i.useRef(null);return i.useLayoutEffect(()=>{C&&pe.current&&pe.current.focus({preventScroll:!0})},[C]),t.jsx("div",{ref:pe,className:U,style:Q,onClick:S,onDoubleClick:N,role:"gridcell","aria-colindex":g+1,"aria-readonly":!E||void 0,tabIndex:-1,"data-field":d.field,"data-colindex":g,...q>1?{"aria-colspan":q}:{},...G>1?{"aria-rowspan":G}:{},children:t.jsx("div",{className:"ogx__cell-content",children:W})})}const ro=i.memo(ar);function io({isExpanded:n,onClick:o,variant:e="chevron"}){return t.jsx("button",{className:`ogx-expand-icon ${n?"ogx-expand-icon--expanded":""}`,onClick:r=>{o&&o(r)},"aria-label":n?"Collapse row":"Expand row",type:"button",children:e==="plus-minus"?t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("path",{d:"M4 8H12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.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"}})]}):t.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:t.jsx("path",{d:"M6 4L10 8L6 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}const dr=({className:n="",...o})=>t.jsx("button",{type:"button",className:`ogx-drag-handle ${n}`,"aria-label":"Drag to reorder row",...o,children:t.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2zm-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"})})});function cr(n){const{content:o,height:e,isExpanded:r}=n;if(!r)return null;const l={height:e==="auto"?"auto":`${e}px`,overflow:e==="auto"?"visible":"auto"};return t.jsx("div",{className:"ogx__detail-panel",style:l,children:t.jsx("div",{className:"ogx__detail-panel-content",children:o})})}function Jt(n){const{row:o,columns:e,rowIndex:r,isSelected:l=!1,checkboxSelection:a=!1,onRowClick:d,onCellClick:s,onSelectionChange:g,columnWidths:u={},pinnedColumns:h,pinnedRows:m,hasDetailPanel:p=!1,isDetailPanelExpanded:f=!1,onDetailPanelToggle:C,detailPanelContent:b,detailPanelHeight:E=200,pinCheckboxColumn:P=!0,pinExpandColumn:k=!0,rowReordering:j=!1,onDragStart:y,onDragOver:w,onDragEnd:v,onDrop:M,isDragging:S,isDragOver:x,editingCell:N,onEditStart:O,onEditStop:W,onEditCellValueChange:X,focusedCellField:A,isFocusVisible:U,colspanMap:q,rowSpanningCaches:G,rowHeight:ee=52}=n,Q=i.useRef(null),pe=i.useRef(null);if(o._isSkeleton){const z=Math.max(e.length,5);return t.jsx("div",{className:"ogx__row ogx__row--skeleton",role:"row","aria-hidden":"true",style:{height:ee,minHeight:ee},children:Array.from({length:z}).map((Ne,ye)=>t.jsx("div",{className:"ogx__skeleton-cell",children:t.jsx("div",{className:"ogx__skeleton-bar"})},ye))})}i.useLayoutEffect(()=>{A==="__expand_col__"&&Q.current&&Q.current.focus({preventScroll:!0}),A==="__checkbox_col__"&&pe.current&&pe.current.focus({preventScroll:!0})},[A]);const _=z=>{z.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell")||d?.({row:o,id:o.id,rowIndex:r})},D=z=>{z.stopPropagation(),g?.(o.id,z.target.checked)},H=z=>{z.stopPropagation(),C?.(o.id)},K=i.useMemo(()=>to(e,u,h,a,P,p,k,j),[e,u,h,a,P,p,k,j]),R=En(o.id,m),Y=R==="top",$=R==="bottom",L=o._hasChildren===!0,ae=i.useCallback((z,Ne)=>{L||O?.({id:o.id,field:z,value:Ne})},[L,o.id,O]),oe=i.useCallback((z,Ne)=>{X?.({id:o.id,field:z,value:Ne})},[X,o.id]),me=i.useCallback(z=>{W?.({cancel:z})},[W]),Ze=["ogx__row",l&&"ogx__row--selected",r%2===0&&"ogx__row--even",r%2===1&&"ogx__row--odd",Y&&"ogx__row--pinned-top",$&&"ogx__row--pinned-bottom",S&&"ogx__row--dragging",x&&"ogx__row--drag-over",L&&"ogx__row--group"].filter(Boolean).join(" ");return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:Ze,onClick:_,role:"row","aria-rowindex":r+1,"aria-selected":l,"data-rowindex":r,onDragOver:w?w(o.id):void 0,onDrop:M?M(o.id):void 0,style:{maxHeight:`${ee}px`,minHeight:`${ee}px`,"--height":`${ee}px`,"--border-width":"1px"},children:[j&&t.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(o.id):void 0,onDragEnd:v,onClick:z=>z.stopPropagation(),children:t.jsx(dr,{})}),p&&t.jsx("div",{className:`ogx__cell ogx__cell--expand ${k?"ogx__cell--pinned-left":""} ${A==="__expand_col__"?"ogx__cell--focused":""} ${A==="__expand_col__"&&U?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":f?"Collapse row details":"Expand row details","aria-expanded":f,style:{position:k?"sticky":void 0,left:k?j?48:0:void 0,zIndex:k?5:void 0},ref:Q,tabIndex:-1,onClick:z=>{z.stopPropagation(),s?.({row:o,field:"__expand_col__",value:f,colDef:{field:"__expand_col__",width:48},rowIndex:r,colIndex:-1})},children:t.jsx(io,{isExpanded:f,onClick:H,variant:"plus-minus"})}),a&&t.jsx("div",{className:`ogx__cell ogx__cell--checkbox ${P?"ogx__cell--pinned-left":""} ${A==="__checkbox_col__"?"ogx__cell--focused":""} ${A==="__checkbox_col__"&&U?"ogx__cell--focus-visible":""}`,role:"gridcell",style:{position:P?"sticky":void 0,left:P?(j?48:0)+(p&&k?48:0):void 0,zIndex:P?11:void 0},ref:pe,tabIndex:-1,onClick:z=>{z.stopPropagation(),s?.({row:o,field:"__checkbox_col__",value:l,colDef:{field:"__checkbox_col__",width:48},rowIndex:r,colIndex:-1})},children:t.jsx(qt,{id:`ogx-select-row-${o.id}`,name:`ogx-select-row-${o.id}`,checked:l,onChange:D,onClick:z=>z.stopPropagation(),"aria-label":l?`Deselect row ${o.id}`:`Select row ${o.id}`,tabIndex:-1,onMouseDown:z=>z.preventDefault()})}),e.map((z,Ne)=>{if(z.isSpacer)return t.jsx("div",{style:{width:z.width,minWidth:z.width,flexShrink:0},"aria-hidden":"true"},z.field);const ye=z.valueGetter?z.valueGetter({row:o,field:z.field,value:o[z.field]}):o[z.field],ft=u[z.field]??z.width,ze=dn(z.field,h),et=ze?K[z.field]:void 0,tt=N?.id===o.id&&N?.field===z.field,en=tt?N?.value:ye,Rt=q?.get(o.id)?.[z.field],jt=G?.spannedCells[o.id]?.[z.field],Ot=G?.hiddenCells[o.id]?.[z.field]||!1;return t.jsx(ro,{value:en,row:o,colDef:z,rowIndex:r,colIndex:Ne,isSelected:l,onCellClick:s,width:ft,pinnedPosition:ze,pinnedOffset:et,isFocused:A===z.field,isFocusVisible:U,isEditable:z.editable,isEditing:tt,onCellEditStart:ae,onEditStop:me,onCellValueChange:oe,colSpanInfo:Rt,rowSpan:jt,isHiddenByRowSpan:Ot},z.field)})]}),p&&t.jsx(cr,{row:o,rowId:o.id,rowIndex:r,content:b,height:E,isExpanded:f})]})}const ur=({columns:n,rowHeight:o,checkboxSelection:e=!1,hasDetailPanel:r=!1,rowReordering:l=!1})=>t.jsxs("div",{className:"ogx__row ogx__skeleton-row",style:{height:o},role:"row",children:[e&&t.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:t.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),r&&t.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:t.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),l&&t.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:t.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),n.map((a,d)=>{const s=a.width||150,g=Math.min(s*.7,s-20);return t.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:s,minWidth:a.minWidth,maxWidth:a.maxWidth,left:a.left,right:a.right,position:a.isSpacer?"relative":a.pinned?"sticky":"relative",zIndex:a.zIndex},children:!a.isSpacer&&t.jsx("div",{className:"ogx-skeleton-box",style:{width:g,height:16,borderRadius:4}})},a.field||d)})]}),Qt=({variant:n="text",size:o="medium",color:e="default",disabled:r=!1,className:l="",children:a,...d})=>{const s=["ogx-button",`ogx-button--${n}`,`ogx-button--${o}`,`ogx-button--${e}`,r&&"ogx-button--disabled",l].filter(Boolean).join(" ");return t.jsx("button",{className:s,disabled:r,...d,children:a})};function lo(n){const{page:o,pageSize:e,rowCount:r,onPageChange:l,onPageSizeChange:a,pageSizeOptions:d=[10,25,50,100],showFirstButton:s=!0,showLastButton:g=!0}=n,u=Math.max(1,Math.ceil(r/e)),h=Math.min(o,u-1),m=h*e,p=Math.min(m+e,r),f=r===0?0:`${m+1}–${p}`,C=()=>{l(0)},b=()=>{l(Math.max(0,h-1))},E=()=>{l(Math.min(u-1,h+1))},P=()=>{l(u-1)},k=w=>{const v=parseInt(w.target.value,10);a(v)},j=h===0,y=h>=u-1;return t.jsxs("div",{className:"ogx-pagination",role:"navigation","aria-label":"Pagination",children:[t.jsxs("div",{className:"ogx-pagination__page-size",children:[t.jsx("label",{htmlFor:"page-size-select",className:"ogx-pagination__label",children:"Rows per page:"}),t.jsx("select",{id:"page-size-select",className:"ogx-pagination__select",value:e,onChange:k,"aria-label":"Rows per page",children:d.map(w=>t.jsx("option",{value:w,children:w},w))})]}),t.jsxs("div",{className:"ogx-pagination__info","aria-live":"polite","aria-atomic":"true",children:[f," of ",r]}),t.jsxs("div",{className:"ogx-pagination__actions",children:[s&&t.jsx(Qt,{variant:"text",size:"small",onClick:C,disabled:j,"aria-label":"Go to first page",title:"First page",children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"})})}),t.jsx(Qt,{variant:"text",size:"small",onClick:b,disabled:j,"aria-label":"Go to previous page",title:"Previous page",children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),t.jsxs("div",{className:"ogx-pagination__page-info","aria-current":"page",children:["Page ",h+1," of ",u]}),t.jsx(Qt,{variant:"text",size:"small",onClick:E,disabled:y,"aria-label":"Go to next page",title:"Next page",children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})})}),g&&t.jsx(Qt,{variant:"text",size:"small",onClick:P,disabled:y,"aria-label":"Go to last page",title:"Last page",children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z"})})})]})]})}function fr(n,o,e={}){const r=new Map,l=[];n.forEach(s=>{const g=s.id;r.set(g,s),l.push(g)});const a=new Map,d=[];return o.forEach(s=>{a.set(s.field,s),d.push(s.field)}),{rows:{idRowsLookup:r,allRows:l},columns:{all:o,lookup:a,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},scrollTop:0,scrollLeft:0},dimensions:{rowHeight:52,headerHeight:56,viewportWidth:0,viewportHeight:0},dataSource:{loading:!1,error:null}}}function gr(n,o){switch(o.type){case"SET_ROWS":{const e=Array.from(n.rows.idRowsLookup.values()),r=typeof o.payload=="function"?o.payload(e):o.payload,l=new Map,a=[];return r.forEach(d=>{l.set(d.id,d),a.push(d.id)}),{...n,rows:{idRowsLookup:l,allRows:a},pagination:{...n.pagination,rowCount:o.preserveRowCount?n.pagination.rowCount:r.length}}}case"SET_COLUMNS":{const e=new Map,r=[];return o.payload.forEach(l=>{e.set(l.field,l),r.push(l.field)}),{...n,columns:{all:o.payload,lookup:e,orderedFields:r,columnVisibilityModel:{}}}}case"SET_SORT_MODEL":return{...n,sorting:{sortModel:o.payload}};case"SET_FILTER_MODEL":return{...n,filter:{filterModel:o.payload}};case"SET_PAGINATION_MODEL":return{...n,pagination:{...n.pagination,paginationModel:o.payload}};case"SET_SELECTION":return{...n,selection:{selectedRows:o.payload}};case"SET_SCROLL":return{...n,virtualization:{...n.virtualization,scrollTop:o.payload.scrollTop,scrollLeft:o.payload.scrollLeft}};case"SET_DIMENSIONS":return{...n,dimensions:{...n.dimensions,viewportWidth:o.payload.viewportWidth,viewportHeight:o.payload.viewportHeight}};case"SET_DATASOURCE_LOADING":return{...n,dataSource:{...n.dataSource,loading:o.payload}};case"SET_DATASOURCE_ERROR":return{...n,dataSource:{...n.dataSource,error:o.payload}};case"SET_ROW_COUNT":return{...n,pagination:{...n.pagination,rowCount:o.payload}};default:return n}}function hr(n){const{rows:o,columns:e,rowHeight:r=52,headerHeight:l=56,columnVisibilityModel:a,initialState:d}=n,s=i.useMemo(()=>fr(o,e,a),[]),[g,u]=i.useReducer(gr,{...s,sorting:d?.sorting||s.sorting,filter:d?.filter||s.filter,dataSource:d?.dataSource?{...s.dataSource,...d.dataSource}:s.dataSource,pagination:{...s.pagination,...d?.pagination||{},rowCount:n.rowCount??d?.pagination?.rowCount??s.pagination.rowCount},dimensions:{...s.dimensions,rowHeight:r,headerHeight:l}}),h=i.useRef(g);h.current=g;const m=i.useRef(o);i.useEffect(()=>{o!==m.current&&(m.current=o,u({type:"SET_ROWS",payload:o}))},[o]);const p=i.useCallback((S,x)=>{u({type:"SET_ROWS",payload:S,preserveRowCount:x})},[]),f=i.useCallback(S=>{u({type:"SET_COLUMNS",payload:S})},[]),C=i.useCallback(S=>{u({type:"SET_SORT_MODEL",payload:S})},[]),b=i.useCallback(S=>{u({type:"SET_FILTER_MODEL",payload:S})},[]),E=i.useCallback(S=>{u({type:"SET_PAGINATION_MODEL",payload:S})},[]),P=i.useCallback(S=>{u({type:"SET_SELECTION",payload:S})},[]),k=i.useCallback((S,x)=>{u({type:"SET_SCROLL",payload:{scrollTop:S,scrollLeft:x}})},[]),j=i.useCallback((S,x)=>{u({type:"SET_DIMENSIONS",payload:{viewportWidth:S,viewportHeight:x}})},[]),y=i.useCallback(S=>{u({type:"SET_DATASOURCE_LOADING",payload:S})},[]),w=i.useCallback(S=>{u({type:"SET_DATASOURCE_ERROR",payload:S})},[]),v=i.useCallback(S=>{u({type:"SET_ROW_COUNT",payload:S})},[]),M=i.useRef({getRow:S=>h.current.rows.idRowsLookup.get(S)||null,getAllRows:()=>Array.from(h.current.rows.idRowsLookup.values()),getVisibleRows:()=>Array.from(h.current.rows.idRowsLookup.values()),getAggregationResult:()=>null,getAggregationModel:()=>null,getColumn:S=>h.current.columns.lookup.get(S)||null,getAllColumns:()=>h.current.columns.all,getVisibleColumns:()=>h.current.columns.all,selectRow:(S,x=!0)=>{const N=new Set(h.current.selection.selectedRows);x?N.add(S):N.delete(S),P(N)},selectRows:(S,x=!0)=>{const N=new Set(h.current.selection.selectedRows);S.forEach(O=>{x?N.add(O):N.delete(O)}),P(N)},getSelectedRows:()=>Array.from(h.current.selection.selectedRows),sortColumn:(S,x)=>{if(x===null)C(h.current.sorting.sortModel.filter(N=>N.field!==S));else{const N=h.current.sorting.sortModel.findIndex(O=>O.field===S);if(N>=0){const O=[...h.current.sorting.sortModel];O[N]={field:S,sort:x},C(O)}else C([...h.current.sorting.sortModel,{field:S,sort:x}])}},getSortModel:()=>h.current.sorting.sortModel,setFilterModel:b,getFilterModel:()=>h.current.filter.filterModel,setPage:S=>{E({...h.current.pagination.paginationModel,page:S})},setPageSize:S=>{E({...h.current.pagination.paginationModel,pageSize:S,page:0})},scrollToIndexes:()=>{},copySelectedRows:()=>Promise.resolve()});return{state:g,dispatch:u,apiRef:M,setRows:p,setColumns:f,setSortModel:C,setFilterModel:b,setPaginationModel:E,setSelection:P,setScroll:k,setDimensions:j,setDataSourceLoading:y,setDataSourceError:w,setRowCount:v}}function pr(n){const{columns:o,onColumnOrderChange:e,disableColumnReorder:r=!1}=n,[l,a]=i.useState(null),[d,s]=i.useState(null),g=i.useRef(-1),u=i.useCallback(f=>C=>{if(r)return;const b=o.findIndex(P=>P.field===f);if(o[b]?.pinnable===!1){C.preventDefault();return}a(f),g.current=b,C.dataTransfer&&(C.dataTransfer.effectAllowed="move",C.dataTransfer.setData("text/plain",f))},[o,r]),h=i.useCallback(f=>C=>{r||!l||(C.preventDefault(),C.dataTransfer.dropEffect="move",s(f))},[l,r]),m=i.useCallback(f=>C=>{if(C.preventDefault(),r||!l||l===f){a(null),s(null);return}const b=o.findIndex(k=>k.field===l),E=o.findIndex(k=>k.field===f);if(b===-1||E===-1){a(null),s(null);return}const P=o[b];e&&e({column:P,oldIndex:b,targetIndex:E}),a(null),s(null),g.current=-1},[o,l,r,e]),p=i.useCallback(()=>{a(null),s(null),g.current=-1},[]);return{draggedColumn:l,dragOverColumn:d,onDragStart:r?void 0:u,onDragOver:r?void 0:h,onDragEnd:r?void 0:p,onDrop:r?void 0:m}}function xr(n){const{onRowOrderChange:o,rows:e,getRowId:r,rowReordering:l=!1}=n,[a,d]=i.useState(null),[s,g]=i.useState(null),u=i.useCallback(C=>r?r(C):C.id,[r]),h=i.useCallback(C=>b=>{l&&(d(C),b.dataTransfer.effectAllowed="move")},[l]),m=i.useCallback(C=>b=>{!l||!a||(b.preventDefault(),b.dataTransfer.dropEffect="move",s!==C&&g(C))},[l,a,s]),p=i.useCallback(()=>{d(null),g(null)},[]),f=i.useCallback(C=>b=>{if(b.preventDefault(),!a||!o){p();return}const E=e.findIndex(k=>u(k)===a),P=e.findIndex(k=>u(k)===C);E!==-1&&P!==-1&&E!==P&&o({row:e[E],oldIndex:E,targetIndex:P}),p()},[a,o,e,u,p]);return{draggedRowId:a,dragOverRowId:s,onDragStart:l?h:void 0,onDragOver:l?m:void 0,onDragEnd:l?p:void 0,onDrop:l?f:void 0}}const mr={contains:(n,o)=>n==null||o==null?!1:String(n).toLowerCase().includes(String(o).toLowerCase()),equals:(n,o)=>n==null&&o==null?!0:n==null||o==null?!1:String(n).toLowerCase()===String(o).toLowerCase(),startsWith:(n,o)=>n==null||o==null?!1:String(n).toLowerCase().startsWith(String(o).toLowerCase()),endsWith:(n,o)=>n==null||o==null?!1:String(n).toLowerCase().endsWith(String(o).toLowerCase()),isEmpty:n=>n==null||String(n).trim()==="",isNotEmpty:n=>n!=null&&String(n).trim()!=="",">":(n,o)=>{if(n==null||o==null)return!1;const e=Number(n),r=Number(o);return isNaN(e)||isNaN(r)?!1:e>r},">=":(n,o)=>{if(n==null||o==null)return!1;const e=Number(n),r=Number(o);return isNaN(e)||isNaN(r)?!1:e>=r},"<":(n,o)=>{if(n==null||o==null)return!1;const e=Number(n),r=Number(o);return isNaN(e)||isNaN(r)?!1:e<r},"<=":(n,o)=>{if(n==null||o==null)return!1;const e=Number(n),r=Number(o);return isNaN(e)||isNaN(r)?!1:e<=r},"!=":(n,o)=>{if(o==null||o==="")return!0;const e=Number(n),r=Number(o);return!isNaN(e)&&!isNaN(r)?e!==r:String(n).toLowerCase()!==String(o).toLowerCase()},isAnyOf:(n,o)=>n==null||!Array.isArray(o)?!1:o.some(e=>String(n).toLowerCase()===String(e).toLowerCase()),not:(n,o)=>n==null&&o==null?!1:n==null||o==null?!0:String(n).toLowerCase()!==String(o).toLowerCase(),is:(n,o)=>{if(o==null||o==="")return!0;const e=String(n).toLowerCase(),r=String(o).toLowerCase();return e===r},"=":(n,o)=>n==null||o==null||o===""?!1:Number(n)===Number(o)};function br(n,o){const{field:e,operator:r,value:l}=o,a=n[e],d=mr[r];return d?d(a,l):(console.warn(`Unknown filter operator: ${r}`),!0)}function wr(n,o){return!o||o.length===0?!0:o.every(e=>{const r=e.toLowerCase();return Object.values(n).some(l=>l==null?!1:String(l).toLowerCase().includes(r))})}function Nn(n,o){const e=o.items||[],r=o.logicOperator||"and",l=o.quickFilterValues||[];if(l.length>0&&!wr(n,l))return!1;if(e.length===0)return!0;const a=d=>{if("logicOperator"in d&&"items"in d){const s=d,g=s.items;return g.length===0?!0:s.logicOperator==="and"?g.every(a):g.some(a)}else return br(n,d)};return r==="and"?e.every(a):e.some(a)}function vr(n,o){if(!o)return n;const{items:e=[],quickFilterValues:r=[]}=o;return e.length===0&&(!r||r.length===0)?n:n.filter(l=>Nn(l,o))}function _r(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 In(n,o,e){if(n==null&&o==null)return 0;if(n==null)return e==="asc"?1:-1;if(o==null)return e==="asc"?-1:1;if(typeof n=="number"&&typeof o=="number")return e==="asc"?n-o:o-n;if(n instanceof Date&&o instanceof Date)return e==="asc"?n.getTime()-o.getTime():o.getTime()-n.getTime();const r=String(n).toLowerCase(),l=String(o).toLowerCase();return e==="asc"?r<l?-1:r>l?1:0:r>l?-1:r<l?1:0}function Cr(n,o){if(o.length===0)return n;const e=[...n];return e.sort((r,l)=>{for(const a of o){const d=r[a.field],s=l[a.field],g=In(d,s,a.sort);if(g!==0)return g}return 0}),e}function yr(n){const{rows:o,getRowId:e,getTreeDataPath:r,treeData:l=!1,defaultGroupingExpansionDepth:a=0,filterModel:d,sortModel:s,onRowExpansionChange:g}=n,{treeNodes:u,rootIds:h,groupingRows:m}=i.useMemo(()=>{if(!l||!r)return{treeNodes:new Map,rootIds:[],groupingRows:[]};const y=new Map,w=[],v=[],M=new Map,S=x=>x.join("/");return o.forEach(x=>{const N=e(x),O=r(x),W=S(O);M.set(W,N),y.set(N,{id:N,parentId:null,depth:O.length-1,groupingKey:O[O.length-1],isExpanded:!1,children:[],serverChildrenCount:x.serverChildrenCount})}),o.forEach(x=>{const N=e(x),O=r(x);if(O.length===1){w.push(N);return}const W=A=>{if(A.length<=1)return;const U=A.slice(0,-1),q=S(U);let G=M.get(q);if(G===void 0&&(G=`auto-group-${q}`,!y.has(G))){const ee=U[U.length-1];y.set(G,{id:G,parentId:null,depth:U.length-1,groupingKey:ee,isExpanded:!1,children:[],label:ee}),M.set(q,G);const Q={id:G,name:ee,_isGroupRow:!0};v.push(Q),U.length===1&&w.push(G),W(U)}return G},X=W(O);if(X!==void 0){const A=y.get(X),U=y.get(N);A&&U&&(U.parentId=X,A.children=A.children||[],A.children.includes(N)||A.children.push(N))}}),v.forEach(x=>{const N=x.id,O=y.get(N);if(!O)return;const X=N.replace("auto-group-","").split("/");if(X.length>1){const A=X.slice(0,-1),U=S(A),q=M.get(U);if(q&&y.has(q)){O.parentId=q;const G=y.get(q);G&&(G.children=G.children||[],G.children.includes(N)||G.children.push(N))}}}),{treeNodes:y,rootIds:w,groupingRows:v}},[o,r,l,e]),p=i.useMemo(()=>{if(!l)return new Set;const y=new Set;return u.forEach(w=>{w.children&&w.children.length>0&&(a===-1||w.depth<a)&&y.add(w.id)}),y},[u,l,a]),[f,C]=i.useState(new Set);i.useEffect(()=>{p.size>0&&C(p)},[p]);const b=i.useCallback(y=>{C(w=>{const v=new Set(w),M=!v.has(y);if(v.has(y)?v.delete(y):v.add(y),M&&g){const S=u.get(y);S&&g(S)}return v})},[u,g]),E=i.useCallback(()=>{if(!l)return null;const y=new Map;o.forEach(W=>y.set(e(W),W)),m.forEach(W=>y.set(W.id,W));const w=W=>Nn(W,d),v=new Map,M=W=>{if(v.has(W))return v.get(W);const X=y.get(W);if(!X)return!1;if(w(X))return v.set(W,!0),!0;const U=u.get(W);return U&&U.children&&U.children.some(G=>M(G))?(v.set(W,!0),!0):(v.set(W,!1),!1)},S=(W,X)=>{if(!s||s.length===0)return 0;const A=y.get(W),U=y.get(X);if(!A||!U)return 0;for(const q of s){const G=A[q.field],ee=U[q.field],Q=In(G,ee,q.sort);if(Q!==0)return Q}return 0},x=[],N=new Set,O=W=>{const X=W.filter(A=>M(A));X.sort(S),X.forEach(A=>{if(N.has(A))return;const U=y.get(A),q=u.get(A);if(U&&q){N.add(A);const G={...U,_treeDepth:q.depth,_isExpanded:f.has(A),_hasChildren:q.children&&q.children.length>0||q.serverChildrenCount&&q.serverChildrenCount>0,_descendantCount:q.children?q.children.length:0};x.push(G),f.has(A)&&q.children&&q.children.length>0&&O(q.children)}})};return O(h),x},[l,o,m,h,u,f,d,s,e]),P=i.useCallback(y=>f.has(y),[f]),k=i.useCallback(y=>u.get(y),[u]),j=i.useCallback(y=>{const w=[];let v=y;for(;v!==null;){const M=u.get(v);if(!M)break;w.unshift(M.groupingKey),v=M.parentId}return w},[u]);return i.useMemo(()=>({treeNodes:u,groupingRows:m,toggleExpansion:b,isGroupExpanded:P,getVisibleRows:E,getNode:k,getNodePath:j}),[u,m,b,P,E,k,j])}const kr=n=>n?.depth===-1?"footer":"inline";function Sr(n){const{rows:o,getRowId:e,rowGroupingModel:r=[],aggregationModel:l={},defaultGroupingExpansionDepth:a=0,filterModel:d,sortModel:s,getAggregationPosition:g=kr}=n,[u,h]=i.useState(new Set),{treeNodes:m,rootIds:p,groupingRows:f}=i.useMemo(()=>{const k=new Map,j=new Map,y=[];if(r.length===0)return{treeNodes:k,rootIds:y,groupingRows:j};const w=(S,x,N)=>`auto-group-${S}-${x}-${N||"root"}`,v=(S,x,N)=>{if(x>=r.length)return S.map(A=>{const U=e(A);return k.set(U,{id:U,parentId:N,depth:x,groupingKey:"",isExpanded:!1}),U});const O=r[x],W=new Map;S.forEach(A=>{const U=A[O],q=String(U);W.has(q)||W.set(q,[]),W.get(q).push(A)});const X=[];return W.forEach((A,U)=>{const G=A[0][O],ee=w(O,U,N);X.push(ee);const Q={};l&&Object.entries(l).forEach(([K,R])=>{const Y=A.map($=>$[K]);if(R==="sum")Q[K]=Y.reduce(($,L)=>(Number($)||0)+(Number(L)||0),0);else if(R==="min")Q[K]=Math.min(...Y.map($=>Number($)||0));else if(R==="max")Q[K]=Math.max(...Y.map($=>Number($)||0));else if(R==="avg"){const $=Y.reduce((L,ae)=>(Number(L)||0)+(Number(ae)||0),0);Q[K]=Y.length?$/Y.length:0}else R==="count"&&(Q[K]=Y.length)});const pe={[O]:G,...Q,id:ee};j.set(ee,pe);const _={id:ee,parentId:N,depth:x,groupingKey:U,groupingField:O,groupingValue:G,aggregatedValues:Q,isExpanded:!1,children:[],label:`${O}: ${String(G)}`};_.aggregationPosition=g(_),k.set(ee,_);const D=v(A,x+1,ee);k.get(ee).children=D;const H=A.length;k.get(ee).descendantCount=H}),X},M=v(o,0,null);return y.push(...M),{treeNodes:k,rootIds:y,groupingRows:j}},[o,r,l,e,g]);i.useEffect(()=>{if(a===-1){const k=new Set;m.forEach((j,y)=>{j.children&&j.children.length>0&&k.add(y)}),h(k)}else if(a>0){const k=new Set;m.forEach((j,y)=>{j.depth<a&&j.children&&j.children.length>0&&k.add(y)}),h(k)}else h(new Set)},[r,a]);const C=i.useCallback(k=>{h(j=>{const y=new Set(j);return y.has(k)?y.delete(k):y.add(k),y})},[]),b=i.useCallback(k=>u.has(k),[u]),E=i.useCallback(()=>{if(r.length===0)return null;const k=[],j=new Set,y=new Map;o.forEach(S=>y.set(e(S),S));const w=S=>{const x=m.get(S);if(!x)return!1;if(!x.children||x.children.length===0){const N=y.get(S);return!(!N||d&&!Nn(N,d))}return x.children.some(N=>w(N))},v=S=>{let x=S;d&&(x=S.filter(w)),s&&s.length>0&&x.sort((N,O)=>{const W=f.get(N)||y.get(N),X=f.get(O)||y.get(O);if(!W||!X)return 0;for(const A of s){const U=W[A.field],q=X[A.field],G=In(U,q,A.sort);if(G!==0)return G}return 0}),x.forEach(N=>{if(j.has(N))return;const O=m.get(N),W=O?.children&&O.children.length>0,X=W?f.get(N):y.get(N);if(X&&O){j.add(N);const A={...X,_treeDepth:O.depth,_isExpanded:u.has(N),_hasChildren:W,_groupingField:O.groupingField,_groupingValue:O.groupingValue,_descendantCount:O.descendantCount};k.push(A),M.has(N)&&W&&v(O.children)}})},M=u;return v(p),k},[o,e,m,p,f,d,s,u]),P=i.useCallback(k=>m.get(k),[m]);return i.useMemo(()=>({treeNodes:m,groupingRows:f,toggleExpansion:C,isGroupExpanded:b,getVisibleRows:E,getNode:P}),[m,f,C,b,E,P])}function jr(n){const{rows:o,getRowId:e,processRowUpdate:r,onProcessRowUpdateError:l,onRowChange:a}=n,[d,s]=i.useState(null),g=i.useRef(null),u=i.useCallback(f=>{s(f),g.current=typeof f=="function"?f(g.current):f},[]),h=i.useCallback(f=>{u({id:f.id,field:f.field,value:f.value,originalValue:f.value})},[]),m=i.useCallback(async f=>{const C=g.current;if(!C)return;if(f?.cancel){u(null);return}const{id:b,field:E,value:P,originalValue:k}=C;if(P===k){u(null);return}const j=o.find(w=>e(w)===b);if(!j){u(null);return}const y={...j,[E]:P};try{if(r){const w=await r(y,j);a?.(w)}else a?.(y);u(null)}catch(w){l&&l(w)}},[d,o,e,r,a,l]),p=i.useCallback(f=>{d&&d.id===f.id&&d.field===f.field&&u(C=>C?{...C,value:f.value}:null)},[d]);return{editingCell:d,startCellEdit:h,stopCellEdit:m,setEditCellValue:p}}function Er(n,o,e){const[r,l]=i.useState(new Map),[a,d]=i.useState({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}}),s=i.useCallback(()=>{l(new Map)},[]),g=i.useCallback((b,E)=>r.get(b)?.[E],[r]),u=i.useCallback((b,E,P,k,j)=>{const y=new Map(r);for(let w=k;w<j;w++){const v=o[w];if(!v)continue;let M=1;if(v.colSpan)if(typeof v.colSpan=="function"){const x={row:E,value:E[v.field],field:v.field,colDef:v,rowIndex:P,colIndex:w};M=v.colSpan(x)}else M=v.colSpan;if(M<=1){Tt(y,b,v.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:e[v.field]||100}});continue}let S=e[v.field]||100;for(let x=1;x<M;x++)if(w+x<j){const N=o[w+x];N&&(S+=e[N.field]||100,Tt(y,b,N.field,{spannedByColSpan:!0,leftVisibleCellIndex:w,rightVisibleCellIndex:Math.min(w+M-1,o.length-1)}))}Tt(y,b,v.field,{spannedByColSpan:!1,cellProps:{colSpan:M,width:S}}),w+=M-1}l(y)},[r,o,e]),h=i.useCallback((b,E)=>{const P={},k={},j={};o.forEach((y,w)=>{if(y.rowSpan)for(let v=b;v<E;v++){const M=n[v];if(!M||k[M.id]?.[y.field])continue;const S=y.valueGetter?y.valueGetter({row:M,field:y.field,value:M[y.field]}):M[y.field];let x=1;if(typeof y.rowSpan=="function"){const N={row:M,value:S,field:y.field,colDef:y,rowIndex:v,colIndex:w};x=y.rowSpan(N)}else typeof y.rowSpan=="number"&&(x=y.rowSpan);if(x>1){P[M.id]||(P[M.id]={}),P[M.id][y.field]=x;for(let N=1;N<x;N++){const O=v+N;if(O<E&&n[O]){const W=n[O];k[W.id]||(k[W.id]={}),k[W.id][y.field]=!0,j[O]||(j[O]={}),j[O][y.field]=v}}}}}),d({caches:{spannedCells:P,hiddenCells:k,hiddenCellOriginMap:j},processedRange:{firstRowIndex:b,lastRowIndex:E}})},[n,o]),m=i.useCallback(()=>{d({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}})},[]);i.useEffect(()=>{const b=new Map;n.forEach((j,y)=>{for(let w=0;w<o.length;w++){const v=o[w];if(!v)continue;let M=1;if(v.colSpan)if(typeof v.colSpan=="function"){const x={row:j,value:j[v.field],field:v.field,colDef:v,rowIndex:y,colIndex:w};M=v.colSpan(x)}else M=v.colSpan;if(M<=1){const x=e[v.field]||(typeof v.width=="number"?v.width:100);Tt(b,j.id,v.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:x}});continue}let S=e[v.field]||(typeof v.width=="number"?v.width:100);for(let x=1;x<M;x++)if(w+x<o.length){const N=o[w+x];if(N){const O=e[N.field]||(typeof N.width=="number"?N.width:100);S+=O,Tt(b,j.id,N.field,{spannedByColSpan:!0,leftVisibleCellIndex:w,rightVisibleCellIndex:Math.min(w+M-1,o.length-1)})}}Tt(b,j.id,v.field,{spannedByColSpan:!1,cellProps:{colSpan:M,width:S}}),w+=M-1}}),l(b);const E={},P={},k={};o.forEach((j,y)=>{if(j.rowSpan)for(let w=0;w<n.length;w++){const v=n[w];if(!v||P[v.id]?.[j.field])continue;const M=j.valueGetter?j.valueGetter({row:v,field:j.field,value:v[j.field]}):v[j.field];let S=1;if(typeof j.rowSpan=="function"){const x={row:v,value:M,field:j.field,colDef:j,rowIndex:w,colIndex:y};S=j.rowSpan(x)}else typeof j.rowSpan=="number"&&(S=j.rowSpan);if(S>1){E[v.id]||(E[v.id]={}),E[v.id][j.field]=S;for(let x=1;x<S;x++){const N=w+x;if(N<n.length&&n[N]){const O=n[N];P[O.id]||(P[O.id]={}),P[O.id][j.field]=!0,k[N]||(k[N]={}),k[N][j.field]=w}}}}}),d({caches:{spannedCells:E,hiddenCells:P,hiddenCellOriginMap:k},processedRange:{firstRowIndex:0,lastRowIndex:n.length}})},[n,o,e]);const p=i.useCallback(()=>a.caches.spannedCells,[a]),f=i.useCallback(()=>a.caches.hiddenCells,[a]),C=i.useCallback(()=>a.caches.hiddenCellOriginMap,[a]);return{colspanMap:r,resetColSpan:s,getCellColSpanInfo:g,calculateColSpan:u,rowSpanningState:a,calculateRowSpan:h,resetRowSpan:m,getSpannedCells:p,getHiddenCells:f,getHiddenCellOriginMap:C}}function Tt(n,o,e,r){let l=n.get(o);l||(l={},n.set(o,l)),l[e]=r}function Nr(n){const{dataSource:o,sortModel:e,filterModel:r,paginationModel:l,paginationMode:a,sortingMode:d,filterMode:s,aggregationModel:g,setRows:u,setRowCount:h,setDataSourceLoading:m,setDataSourceError:p,onAggregationResults:f}=n,C=i.useRef(null),b=i.useRef(0),E=i.useCallback(async()=>{if(!o)return;const k=++b.current;m(!0),p(null);const j=l.page*l.pageSize,y=j+l.pageSize,w={startRow:j,endRow:y,sortModel:e,filterModel:r,groupKeys:[],aggregationModel:g};try{const v=await o.getRows(w);if(k!==b.current)return;let M=!1;if(a==="infinite"){const S=C.current;if(S){const x=JSON.stringify(S.sortModel)!==JSON.stringify(e),N=JSON.stringify(S.filterModel)!==JSON.stringify(r),O=S.pageSize!==l.pageSize;!x&&!N&&!O&&l.page>S.page&&(M=!0)}}u(M?S=>[...S,...v.rows]:v.rows,!0),v.aggregationResults&&f&&f(v.aggregationResults),v.rowCount!==void 0&&h(v.rowCount),C.current={sortModel:e,filterModel:r,page:l.page,pageSize:l.pageSize}}catch(v){k===b.current&&(p(v),console.error("Data Source Error:",v))}finally{k===b.current&&m(!1)}},[o,l.page,l.pageSize,e,r,a,g,f,u,h,m,p]);i.useEffect(()=>{if(o&&(a==="server"||a==="infinite"||d==="server"||s==="server")){const j=setTimeout(()=>{E()},300);return()=>clearTimeout(j)}},[E,o,a,d,s]);const P=i.useCallback(async(k,j)=>{if(o){m(!0);try{const y=await o.getRows({startRow:0,endRow:-1,sortModel:e,filterModel:r,groupKeys:j});y.rows.length>0&&u(w=>{const v=new Set(w.map(S=>S.id)),M=y.rows.filter(S=>!v.has(S.id));return[...w,...M]})}catch(y){p(y),console.error("Failed to fetch children:",y)}finally{m(!1)}}},[o,e,r,u,m,p]);return{fetchRows:E,fetchChildren:P}}const Ir={sum:n=>n.filter(e=>e!=null&&!isNaN(Number(e))).reduce((e,r)=>e+Number(r),0),avg:n=>{const o=n.filter(e=>e!=null&&!isNaN(Number(e)));return o.length===0?null:o.reduce((e,r)=>e+Number(r),0)/o.length},count:n=>n.filter(o=>o!=null).length,min:n=>{const o=n.filter(e=>e!=null&&!isNaN(Number(e))).map(Number);return o.length?Math.min(...o):null},max:n=>{const o=n.filter(e=>e!=null&&!isNaN(Number(e))).map(Number);return o.length?Math.max(...o):null},unique:n=>new Set(n.filter(o=>o!=null)).size};function bt(n,o){return n==null?"—":typeof n=="number"?o==="avg"?n.toLocaleString(void 0,{maximumFractionDigits:2}):n.toLocaleString():String(n)}function so(n){const{rows:o,aggregationModel:e,isServerSide:r,dataSource:l,filterModel:a,sortModel:d,serverAggregationResults:s}=n,g=i.useMemo(()=>{if(r||Object.keys(e).length===0)return{};const k={};for(const[j,y]of Object.entries(e)){const w=Ir[y];if(!w){console.warn(`[useAggregation] Unknown aggregation function: "${y}"`);continue}const v=o.map(M=>M[j]);k[j]=w(v)}return k},[o,e,r]),[u,h]=i.useState({}),[m,p]=i.useState(!1),[f,C]=i.useState(null),b=i.useRef(0),E=i.useCallback(async()=>{if(!l?.getAggregations||Object.keys(e).length===0)return;const k=++b.current;p(!0),C(null);try{const j=await l.getAggregations({sortModel:d??[],filterModel:a??{items:[]},groupKeys:[],aggregationModel:e});k===b.current&&h(j)}catch(j){k===b.current&&(C(j),console.error("[useAggregation] Server aggregation error:",j))}finally{k===b.current&&p(!1)}},[l,e,a,d]);return i.useEffect(()=>{r&&l?.getAggregations&&!s&&E()},[E,r,l,s]),{aggregationResult:i.useMemo(()=>r?s&&Object.keys(s).length>0?s:u:g,[r,g,s,u]),isLoading:m,error:f}}function Mr(n,o){const e=n.filter(r=>r!=null&&!isNaN(r));if(e.length===0)return null;switch(o){case"sum":return e.reduce((r,l)=>r+l,0);case"avg":return e.reduce((r,l)=>r+l,0)/e.length;case"count":return e.length;case"min":return Math.min(...e);case"max":return Math.max(...e)}}function Mn(n,o){return o.map(e=>String(n[e]??"")).join("\0")}function ao(n,o,e,r){return i.useMemo(()=>{const l={pivotRows:[],pivotColumns:[],colKeys:[],isValid:!1};if(!r)return l;const{rowFields:a,columnFields:d,valueFields:s}=e;if(a.length===0||s.length===0)return l;const g=new Map(o.map(E=>[E.field,E])),u=new Set;for(const E of n)u.add(Mn(E,d));const h=Array.from(u).sort(),m=new Map;for(const E of n){const P=Mn(E,a);if(!m.has(P)){const w={};for(const v of a)w[v]=E[v];m.set(P,{labelValues:w,bucket:new Map})}const k=m.get(P),j=Mn(E,d);k.bucket.has(j)||k.bucket.set(j,new Map);const y=k.bucket.get(j);for(const w of s){const v=Number(E[w.field]);y.has(w.field)||y.set(w.field,[]),isNaN(v)||y.get(w.field).push(v)}}let p=0;const f=[];for(const[,E]of m){const P={id:p++,...E.labelValues};for(const k of h){const j=E.bucket.get(k);for(const y of s){const w=d.length>0?`${k}${y.field}${y.aggFn}`:`${y.field}${y.aggFn}`,v=j?.get(y.field)??[];P[w]=v.length>0?Mr(v,y.aggFn):null}}f.push(P)}const C={id:"__pivot_grand_total__"};for(let E=0;E<a.length;E++)C[a[E]]=E===0?"Grand Total":"";for(const E of h)for(const P of s){const k=d.length>0?`${E}${P.field}${P.aggFn}`:`${P.field}${P.aggFn}`,j=f.reduce((y,w)=>{const v=w[k];return y+(v!=null&&!isNaN(Number(v))?Number(v):0)},0);C[k]=j}f.push(C);const b=[];for(const E of a){const P=g.get(E);b.push({field:E,headerName:P?.headerName??E,width:P?.width??140,sortable:!0})}for(const E of h){const P=d.length>0?E.split("\0").map((k,j)=>{const y=g.get(d[j]);return y?.headerName?`${y.headerName}: ${k}`:k}).join(" / "):"";for(const k of s){const j=g.get(k.field),y=d.length>0?`${E}${k.field}${k.aggFn}`:`${k.field}${k.aggFn}`,w=k.headerName??j?.headerName??k.field,v=P?`${P} — ${w} (${k.aggFn})`:`${w} (${k.aggFn})`;b.push({field:y,headerName:v,width:140,type:"number",align:"right",headerAlign:"right",sortable:!0,valueFormatter:({value:M})=>{if(M==null)return"—";const S=Number(M);return k.aggFn==="avg"?S.toFixed(2):k.aggFn==="count"?S.toLocaleString():j?.valueFormatter?j.valueFormatter({value:M,row:{},field:k.field}):S.toLocaleString()}})}}return{pivotRows:f,pivotColumns:b,colKeys:h,isValid:!0}},[n,o,e,r])}function Pr(n){const o=document.createElement("textarea");o.value=n,o.style.cssText="position:fixed;top:-9999px;left:-9999px;opacity:0;",document.body.appendChild(o),o.focus(),o.select();let e=!1;try{e=document.execCommand("copy")}finally{document.body.removeChild(o)}return e}async function Tr(n){let o=!1;try{o=Pr(n)}catch{}if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")try{await navigator.clipboard.writeText(n);return}catch(e){if(o)return;throw e}else if(!o)throw new Error("Clipboard API not available and fallback failed.")}function Lr(n){const{selectedRowIds:o,columns:e,getVisibleRows:r,getRowId:l}=n,a=i.useCallback(async()=>{if(o.size===0)return;const s=r().filter(p=>o.has(l(p)));if(s.length===0)return;const g=e.filter(p=>!p.field.startsWith("__")),u=g.map(p=>p.headerName||p.field).join(" "),h=s.map(p=>g.map(f=>{const C=p[f.field];return f.valueFormatter?f.valueFormatter({value:C,row:p,field:f.field}):C??""}).join(" ")).join(`
|
|
7
|
-
`),m=`${
|
|
8
|
-
${h}`;try{await Tr(m)}catch(p){console.error("[OpenGridX] Failed to copy to clipboard:",p)}},[o,e,r,l]);return i.useEffect(()=>{const d=s=>{if(!(s.ctrlKey||s.metaKey)||s.key!=="c")return;const g=document.activeElement,u=g?.tagName.toLowerCase(),h=g?.type;u==="input"&&h!=="checkbox"&&h!=="radio"||u==="textarea"||u==="select"||g?.isContentEditable||a()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[a]),{copySelectedRows:a}}function Rr(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function Or(){return t.jsxs("svg",{className:"ogx-column-visibility-panel__drag-handle",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[t.jsx("circle",{cx:"9",cy:"5",r:"1.5"}),t.jsx("circle",{cx:"15",cy:"5",r:"1.5"}),t.jsx("circle",{cx:"9",cy:"12",r:"1.5"}),t.jsx("circle",{cx:"15",cy:"12",r:"1.5"}),t.jsx("circle",{cx:"9",cy:"19",r:"1.5"}),t.jsx("circle",{cx:"15",cy:"19",r:"1.5"})]})}function co(n){const{columns:o,visibleColumns:e,onVisibilityChange:r,onShowAll:l,onHideAll:a,onColumnReorder:d}=n,[s,g]=i.useState(""),[u,h]=i.useState(null),m=i.useRef(null),f=i.useMemo(()=>o.filter(w=>w.hideable!==!1),[o]).every(w=>e.has(w.field)),C=i.useMemo(()=>{if(!s)return o;const w=s.toLowerCase();return o.filter(v=>(v.headerName||v.field).toLowerCase().includes(w))},[o,s]),b=w=>{w.target.checked?l():a()},E=w=>v=>{m.current=w,v.dataTransfer.effectAllowed="move",v.dataTransfer.setDragImage(v.currentTarget.closest(".ogx-column-visibility-panel__item"),20,20)},P=w=>v=>{v.preventDefault(),v.dataTransfer.dropEffect="move",w!==m.current&&h(w)},k=()=>{h(null)},j=w=>v=>{v.preventDefault();const M=m.current;h(null),m.current=null,M&&M!==w&&d&&d(M,w)},y=()=>{h(null),m.current=null};return t.jsxs("div",{className:"ogx-column-visibility-panel",children:[t.jsx("div",{className:"ogx-column-visibility-panel__search-section",children:t.jsxs("div",{className:"ogx-column-visibility-panel__search-container",children:[t.jsx(Rr,{}),t.jsx("input",{id:"ogx-column-search",name:"ogx-column-search",autoComplete:"off",className:"ogx-column-visibility-panel__search-input",placeholder:"Search",value:s,onChange:w=>g(w.target.value)})]})}),t.jsx("div",{className:"ogx-column-visibility-panel__list",children:C.map(w=>{const v=e.has(w.field),M=w.hideable!==!1,S=u===w.field,x=!!d&&!s;return t.jsxs("div",{className:["ogx-column-visibility-panel__item",!M&&"ogx-column-visibility-panel__item--disabled",S&&"ogx-column-visibility-panel__item--drag-over"].filter(Boolean).join(" "),draggable:x,onDragOver:x?P(w.field):void 0,onDragLeave:x?k:void 0,onDrop:x?j(w.field):void 0,onDragEnd:x?y:void 0,children:[x&&t.jsx("span",{className:"ogx-column-visibility-panel__drag-handle-wrapper",draggable:!0,onDragStart:E(w.field),title:"Drag to reorder",children:t.jsx(Or,{})}),t.jsxs("label",{className:"ogx-column-visibility-panel__item-label",style:{display:"flex",alignItems:"center",gap:"var(--ogx-spacing-md)",flex:1,cursor:M?"pointer":"not-allowed"},children:[t.jsx(qt,{checked:v,onChange:N=>r(w.field,N.target.checked),disabled:!M}),t.jsx("span",{className:"ogx-column-visibility-panel__label",children:w.headerName||w.field})]})]},w.field)})}),t.jsxs("div",{className:"ogx-column-visibility-panel__footer",children:[t.jsxs("label",{className:"ogx-column-visibility-panel__item",children:[t.jsx(qt,{checked:f,onChange:b}),t.jsx("span",{className:"ogx-column-visibility-panel__label",children:"Show/Hide All"})]}),t.jsx("button",{className:"ogx-column-visibility-panel__reset-btn",onClick:l,children:"Reset"})]})]})}function Fr(n){const{rows:o,columns:e,getRowId:r,rowHeight:l=52,headerHeight:a=56,autoHeight:d=!1,checkboxSelection:s=!1,rowSelectionModel:g,onRowSelectionModelChange:u,onRowClick:h,onCellClick:m,filterModel:p,onFilterModelChange:f,sortModel:C,onSortModelChange:b,pagination:E=!1,paginationModel:P={page:0,pageSize:100},onPaginationModelChange:k,pageSizeOptions:j=[10,25,50,100],pinnedColumns:y,onPinnedColumnsChange:w,pinnedRows:v,getDetailPanelContent:M,getDetailPanelHeight:S,detailPanelExpandedRowIds:x,onDetailPanelExpandedRowIdsChange:N,pinCheckboxColumn:O=!0,pinExpandColumn:W=!0,disableColumnReorder:X=!1,columnOrder:A,onColumnOrderChange:U,height:q,rowReordering:G=!1,onRowOrderChange:ee,loading:Q=!1,treeData:pe=!1,getTreeDataPath:_,defaultGroupingExpansionDepth:D,rowGroupingModel:H,aggregationModel:K,onAggregationModelChange:R,getAggregationPosition:Y,isCellEditable:$,processRowUpdate:L,onProcessRowUpdateError:ae,dataSource:oe,sortingMode:me="client",filterMode:Ze="client",paginationMode:z="client",rowCount:Ne,slots:ye,slotProps:ft,pivotMode:ze=!1,pivotModel:et,onPivotModelChange:tt,className:en="",style:Rt,onRowsScrollEnd:jt,ariaLabel:Ot,initialState:vt,onStateChange:Be,columnVisibilityModel:mo,onColumnVisibilityModelChange:bo,listView:cn=!1,listViewColumn:wo,columnGroupingModel:Et,noRowsLabel:Tn="No Data",apiRef:Ln}=n,Ci=i.useMemo(()=>({items:[]}),[]),Ve=p||Ci,[yi,ki]=i.useState(()=>vt?.sorting?.sortModel??[]),Rn=C!==void 0,nt=Rn?C:yi,Si=i.useMemo(()=>[],[]),On=H||Si,Fn=K!==void 0,vo=i.useRef(ye?.toolbar);vo.current=ye?.toolbar;const ji=i.useRef(c=>{const I=vo.current;return I?I(c):null}).current,[Ei,Ni]=i.useState(()=>K??{}),ot=Fn?K:Ei,Ii=i.useCallback(c=>{Fn||Ni(c),R?.(c)},[Fn,R]),[Mi,Pi]=i.useState(()=>vt?.columns?.columnVisibilityModel??{}),Wn=mo!==void 0,Xe=Wn?mo:Mi,tn=i.useCallback(c=>{Wn||Pi(c),bo?.(c)},[Wn,bo]),[Ti,Li]=i.useState(()=>vt?.columns?.pinnedColumns??{}),An=y!==void 0,rt=An?y:Ti,zn=i.useCallback(c=>{An||Li(c),w?.(c)},[An,w]),Ri=i.useMemo(()=>({rowFields:[],columnFields:[],valueFields:[]}),[]),[Oi,Fi]=i.useState(et??Ri),_o=et??Oi,Wi=i.useCallback(c=>{Fi(c),tt?.(c)},[tt]),un=ao(o,e,_o,ze),Bn=ze&&un.isValid?un.pivotRows:o,it=ze&&un.isValid?un.pivotColumns:e,[Ai,Co]=i.useState(null);i.useEffect(()=>{Co(null)},[ot]);const[zi,Bi]=i.useState(()=>vt?.pagination?.paginationModel??P),$n=n.paginationModel!==void 0,ge=$n?P:zi,fn=i.useCallback(c=>{$n||Bi(c),k?.(c)},[$n,k]),[$i,yo]=i.useState([]),nn=g!==void 0,ko=nn?g:$i,Ie=i.useMemo(()=>new Set(ko),[ko]),gn=u,Nt=i.useRef(null),Di=i.useRef(null),hn=i.useRef(null),Hi=i.useCallback(c=>c.id,[]),pn=r||Hi,[qe,Ft]=i.useState(null),Wt=i.useCallback(c=>{yn.current?.classList.toggle("ogx--kb",c)},[]),So=i.useRef(oe);So.current=oe;const jo=i.useRef(null),Eo=i.useRef(null),Gi=i.useCallback(c=>{if(So.current&&pe&&c.serverChildrenCount>0&&c.children.length===0){const I=Eo.current?.getNodePath(c.id)||[c.groupingKey];jo.current?.(c.id,I)}},[pe]),lt=hr({rows:Bn,columns:it,rowHeight:l,headerHeight:a,rowCount:Ne,columnVisibilityModel:Xe,initialState:n.initialState}),{state:de,apiRef:At,setRows:Dn,setColumns:No,setScroll:Io,setDimensions:Mo,setDataSourceLoading:Vi,setDataSourceError:Ui,setRowCount:Ki}=lt;i.useEffect(()=>{Ln&&(Ln.current=At.current)},[Ln,At]);const{copySelectedRows:Po}=Lr({selectedRowIds:Ie,columns:it,getVisibleRows:()=>At.current.getVisibleRows(),getRowId:pn});i.useEffect(()=>{At.current.copySelectedRows=Po,At.current.getSelectedRows=()=>Array.from(Ie)},[Po,Ie,At]);const Yi=de.dataSource.loading,on=Q||Yi,rn=i.useMemo(()=>de.rows.allRows.map(c=>de.rows.idRowsLookup.get(c)),[de.rows]),Hn=yr({rows:rn,getRowId:pn,getTreeDataPath:_,treeData:pe,defaultGroupingExpansionDepth:D,filterModel:Ve,sortModel:nt,onRowExpansionChange:Gi});i.useEffect(()=>{Eo.current=Hn},[Hn]);const Xi=Sr({rows:rn,getRowId:pn,rowGroupingModel:On,aggregationModel:ot,defaultGroupingExpansionDepth:D,filterModel:Ve,sortModel:nt,getAggregationPosition:Y}),$e=jr({rows:rn,getRowId:pn,processRowUpdate:L,onProcessRowUpdateError:ae,onRowChange:c=>{const{dispatch:I}=lt,B=Array.from(lt.state.rows.idRowsLookup.values()).map(Z=>Z.id===c.id?c:Z);I({type:"SET_ROWS",payload:B})}}),Gn=pe,zt=!!(On&&On.length>0),xn=Gn||zt,De=Gn?Hn:zt?Xi:null,Me=E&&!zt,mn=i.useCallback(c=>{const{row:I,id:T}=c;if(xn&&I._hasChildren){De?.toggleExpansion(T);return}h?.(c)},[xn,De,h]),ke=i.useMemo(()=>xn?it.map((c,I)=>I===0?{...c,renderCell:T=>{const{_treeDepth:B,_hasChildren:Z,_isExpanded:re,_groupingField:ue,_groupingValue:Oe,_descendantCount:Fe}=T.row,xe=(B||0)*24;let se=c.renderCell?c.renderCell(T):T.value;return Gn&&Z&&T.row._isGroupRow&&(se=t.jsxs("div",{className:"ogx__group-cell-content",children:[T.value,Fe!==void 0&&Fe>0?` (${Fe})`:""]})),zt&&Z&&ue&&(se=t.jsxs("div",{className:"ogx__group-cell-content",children:[c.field===ue?"":`${ue}: `,String(Oe),Fe!==void 0?` (${Fe})`:""]})),t.jsxs("div",{style:{display:"flex",alignItems:"center",paddingLeft:xe,width:"100%",height:"100%"},children:[t.jsx("div",{style:{marginRight:4,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",cursor:Z?"pointer":"default",flexShrink:0},children:Z?t.jsx("div",{onClick:V=>{V.stopPropagation(),V.preventDefault(),De?.toggleExpansion(T.row.id)},onMouseDown:V=>{V.stopPropagation()},style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:10,position:"relative"},children:t.jsx(io,{isExpanded:re,onClick:V=>{V.stopPropagation(),V.preventDefault(),De?.toggleExpansion(T.row.id)}})}):null}),t.jsx("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:se})]})}}:{...c,renderCell:T=>{const{_hasChildren:B,_groupingField:Z}=T.row;return zt&&B?c.field===Z?null:T.value!==void 0&&T.value!==null?c.renderCell?c.renderCell(T):T.value:null:c.renderCell?c.renderCell(T):T.value}}):it,[it,xn,zt,De]),Vn=Nr({dataSource:oe,sortModel:nt,filterModel:Ve,paginationModel:ge,paginationMode:z,sortingMode:me,filterMode:Ze,aggregationModel:ot,setRows:Dn,setRowCount:Ki,setDataSourceLoading:Vi,setDataSourceError:Ui,onAggregationResults:Co});i.useEffect(()=>{Vn.fetchChildren&&(jo.current=Vn.fetchChildren)},[Vn.fetchChildren]);const[Ue,qi]=i.useState(()=>vt?.columns?.columnWidths??{}),[Ji,bn]=i.useState(()=>vt?.columns?.columnOrder??it.map(c=>c.field)),_t=A||Ji;i.useEffect(()=>{oe||Dn(Bn)},[Bn,Dn,oe]),i.useEffect(()=>{No(it)},[it,No]),i.useEffect(()=>{ze&&bn(it.map(c=>c.field))},[ze,it]);const Bt=i.useMemo(()=>{if(X)return ke;const c=new Map(_t.map((I,T)=>[I,T]));return[...ke].sort((I,T)=>{const B=c.get(I.field)??ke.indexOf(I),Z=c.get(T.field)??ke.indexOf(T);return B-Z})},[ke,_t,X]),To=i.useMemo(()=>Bt.filter(c=>Xe[c.field]!==!1),[Bt,Xe]),$t=pr({columns:Bt,onColumnOrderChange:i.useCallback(c=>{const{oldIndex:I,targetIndex:T}=c,B=[..._t],[Z]=B.splice(I,1);B.splice(T,0,Z),A||bn(B),U?.(c)},[_t,A,U]),disableColumnReorder:X}),[Qi,Zi]=i.useState(new Set),Ct=x??Qi,Je=!!M,ln=i.useCallback(c=>{const I=new Set(Ct);I.has(c)?I.delete(c):I.add(c),x===void 0&&Zi(I),N?.(I)},[Ct,x,N]),we=i.useMemo(()=>{const c=[];return G&&c.push({field:"__reorder_col__"}),Je&&c.push({field:"__expand_col__"}),s&&c.push({field:"__checkbox_col__"}),[...c,...Bt]},[Bt,s,Je,G]),el=i.useCallback((c,I)=>{qi(T=>({...T,[c]:I}))},[]),Un=i.useRef(Be);Un.current=Be,i.useEffect(()=>{if(!Un.current)return;const c={sorting:{sortModel:nt},filter:{filterModel:Ve},pagination:{paginationModel:ge},columns:{columnWidths:Ue,columnOrder:_t,columnVisibilityModel:Xe,pinnedColumns:rt}};Un.current(c)},[nt,Ve,ge,Ue,_t,Xe,rt]);const wn=i.useMemo(()=>rn,[rn]),He=i.useMemo(()=>De?De.getVisibleRows()||[]:Ze==="server"&&oe?wn:vr(wn,Ve),[wn,Ve,De,Ze,oe]),{top:Ke,center:Dt,bottom:st}=i.useMemo(()=>De?{top:[],center:He,bottom:[]}:Do(He,v),[He,v,De]),Pe=i.useMemo(()=>De||me==="server"&&oe?Dt:Cr(Dt,nt),[Dt,nt,De,me,oe]),gt=i.useMemo(()=>{if(!Me||z==="server"&&oe)return Pe;const c=ge.page*ge.pageSize,I=c+ge.pageSize;return Pe.slice(c,I)},[Pe,Me,ge.page,ge.pageSize,z,oe]);i.useEffect(()=>{lt.apiRef.current.getVisibleRows=()=>Pe,lt.apiRef.current.getVisibleColumns=()=>ke},[Pe,ke,lt.apiRef]);const Ht=xr({rows:Me?gt:Pe,getRowId:c=>c.id,onRowOrderChange:ee,rowReordering:G}),Se=i.useMemo(()=>{if(De)return Dt;const c=Me?gt:Pe,I=[...Ke,...c,...st];if(z==="infinite"&&de.dataSource.loading&&I.length>0){const T=Math.min(ge.pageSize,20),B=Array.from({length:T},(Z,re)=>({id:`__skeleton_${re}__`,_isSkeleton:!0}));return[...I,...B]}return I},[Ke,gt,Pe,st,Me,De,Dt,z,de.dataSource.loading,ge.pageSize]),Gt=Er(Se,we,Ue),{aggregationResult:Kn}=so({rows:He,aggregationModel:ot,isServerSide:!!(oe&&(z==="server"||me==="server")),dataSource:oe,filterModel:Ve,sortModel:nt,serverAggregationResults:Ai}),vn=Object.keys(ot).length>0;i.useEffect(()=>{lt.apiRef.current.getAggregationResult=()=>vn?Kn:null,lt.apiRef.current.getAggregationModel=()=>vn?ot:null},[Kn,ot,vn,lt.apiRef]);const Yn=i.useMemo(()=>{const c=l,I=Me?gt:Pe,T=I.map((F,J)=>{let te=c;if(Ct.has(F.id)){const Ee=S?.({row:F,id:F.id,rowIndex:Ke.length+J})??200;te+=typeof Ee=="number"?Ee:parseInt(String(Ee),10)||200}return te}),B=T.reduce((F,J,te)=>(F.push((F[te-1]||0)+J),F),[]),re=(z==="infinite"&&de.dataSource.loading&&I.length>0?Math.min(ge.pageSize,20):0)*c,ue=(B[B.length-1]||0)+re,Oe=Ke.length*c,Fe=st.length*c,le=[],xe=[],se=[],V=[];To.forEach(F=>{const J=dn(F.field,rt);J==="left"?le.push(F):J==="right"?xe.push(F):se.push(F)});const he=de.dimensions.viewportWidth||1e3,Ce=(s?48:0)+(Je?48:0)+(G?48:0),be=F=>Ue[F.field]??F.width,Te=F=>{if(F===void 0)return{type:"auto",value:0};if(typeof F=="number")return{type:"fixed",value:F};if(typeof F=="string"){if(F.toLowerCase()==="auto")return{type:"auto",value:0};if(F.endsWith("%"))return{type:"percentage",value:parseFloat(F)};const J=parseFloat(F);if(!isNaN(J))return{type:"fixed",value:J}}return{type:"fixed",value:100}},Le=le.reduce((F,J)=>{const te=Te(be(J));return F+(te.type==="fixed"?te.value:100)},0),fe=xe.reduce((F,J)=>{const te=Te(be(J));return F+(te.type==="fixed"?te.value:100)},0),ce=se.reduce((F,J)=>{if(!Object.prototype.hasOwnProperty.call(Ue,J.field)&&J.flex&&J.flex>0){const mt=J.minWidth??150,qn=typeof J.width=="number"?J.width:150;return F+(mt||qn)}const Ee=Te(be(J));return Ee.type==="fixed"?F+Ee.value:Ee.type==="percentage"?F+100:F+(J.minWidth??150)},0),ht=Math.max(he-Ce-Le-fe,ce),at=[],We=[],je=[];let Ae=0;se.forEach(F=>{const J=Object.prototype.hasOwnProperty.call(Ue,F.field),te=Te(be(F));if(!J&&F.flex&&F.flex>0){je.push({col:F,flex:F.flex}),Ae+=F.flex;return}te.type==="fixed"?at.push({col:F,width:te.value}):te.type==="percentage"?We.push({col:F,percentage:te.value}):(je.push({col:F,flex:1}),Ae+=1)});const Ge=at.reduce((F,{width:J})=>F+J,0);let Re=Math.max(0,ht-Ge);const dt=new Map;We.forEach(({col:F,percentage:J})=>{const te=J/100*Re;dt.set(F.field,te),Re-=te}),Re=Math.max(0,Re);const yt=new Map,pt=je.map(F=>({...F,minWidth:F.col.minWidth??50,maxWidth:F.col.maxWidth??1/0,frozen:!1,computedWidth:0}));(()=>{let F=0;const J=pt.length*2;for(;F<J;){F++;const te=pt.filter(ne=>!ne.frozen);if(te.length===0)break;const Ee=te.reduce((ne,ct)=>ne+ct.flex,0),mt=pt.reduce((ne,ct)=>ct.frozen?ne+ct.computedWidth:ne,0),qn=Math.max(0,Re-mt);if(Ee<=0){te.forEach(ne=>{ne.computedWidth=ne.minWidth,ne.frozen=!0});break}const cl=qn/Ee;let kn=0;const Sn=[],jn=[];if(te.forEach(ne=>{const ct=cl*ne.flex;if(ct<ne.minWidth){const Jn=ne.minWidth-ct;kn+=Jn,Sn.push(ne)}else if(ct>ne.maxWidth){const Jn=ne.maxWidth-ct;kn+=Jn,jn.push(ne)}else ne.computedWidth=ct}),Sn.length===0&&jn.length===0){te.forEach(ne=>ne.frozen=!0);break}kn>0?Sn.forEach(ne=>{ne.computedWidth=ne.minWidth,ne.frozen=!0}):kn<0?jn.forEach(ne=>{ne.computedWidth=ne.maxWidth,ne.frozen=!0}):(Sn.forEach(ne=>{ne.computedWidth=ne.minWidth,ne.frozen=!0}),jn.forEach(ne=>{ne.computedWidth=ne.maxWidth,ne.frozen=!0}))}})(),pt.forEach(F=>yt.set(F.col.field,F.computedWidth));const Ut=new Map;se.forEach(F=>{let J;if(yt.has(F.field))J=yt.get(F.field);else{const te=at.find(mt=>mt.col.field===F.field),Ee=We.find(mt=>mt.col.field===F.field);if(te)J=te.width;else if(Ee){const mt=dt.get(F.field)||0;J=Math.max(F.minWidth??50,mt||100)}else J=100}V.push(J),Ut.set(F.field,J)});const xt=se.map(F=>{const J=pt.find(te=>te.col.field===F.field);return{...F,width:Ut.get(F.field)??(typeof F.width=="number"?F.width:100),flex:J?J.flex:F.flex}}),Ye=11,It=le.map((F,J)=>{const te=Te(be(F)),Ee=te.type==="fixed"?te.value:100;return{...F,width:Ee,zIndex:Ye+J}}),Kt=11,kt=xe.map((F,J)=>{const te=Te(be(F)),Ee=te.type==="fixed"?te.value:100;return{...F,width:Ee,zIndex:Kt+(xe.length-1-J)}}),Qe=V.reduce((F,J)=>F+J,0),ve=Le+Qe+fe+Ce,dl=V.reduce((F,J,te)=>(F.push((F[te-1]||0)+J),F),[]);return{rowHeights:T,cumulativeHeights:B,unpinnedRowsHeight:ue,pinnedTopHeight:Oe,pinnedBottomHeight:Fe,leftPinnedCols:It,rightPinnedCols:kt,unpinnedColsWithWidth:xt,unpinnedColWidths:V,unpinnedAccWidths:dl,totalWidth:ve,leftWidth:Le,rightWidth:fe,unpinnedTotalWidth:Qe,systemColumnsWidth:Ce,pinnedTopRowsLength:Ke.length,pinnedBottomRowsLength:st.length,unpinnedRowsLength:I.length}},[l,Me,gt,Pe,Ct,S,Ke.length,st.length,Ct,S,Ke.length,st.length,To,rt,Ue,de.dimensions.viewportWidth,s,Je,G,O,W,d,z,de.dataSource.loading,ge.pageSize]),_e=i.useMemo(()=>{const{unpinnedAccWidths:c,unpinnedColsWithWidth:I,leftPinnedCols:T,rightPinnedCols:B,totalWidth:Z,leftWidth:re,rightWidth:ue,unpinnedTotalWidth:Oe,systemColumnsWidth:Fe,cumulativeHeights:le,pinnedTopHeight:xe,pinnedBottomHeight:se,unpinnedRowsHeight:V,rowHeights:he,unpinnedRowsLength:Ce}=Yn,be=de.virtualization.scrollLeft,Te=de.virtualization.scrollTop,Le=de.dimensions.viewportWidth||1e3,fe=d?xe+V+se+50:de.dimensions.viewportHeight||600,ce=6,ht=Math.max(0,be-re),at=be+Le-re;let We=0,je=I.length-1,Ae=0,Ge=c.length-1;for(;Ae<=Ge;){const ve=Ae+Ge>>>1;c[ve]<ht?Ae=ve+1:Ge=ve-1}We=Math.max(0,Ae-ce);for(let ve=We;ve<c.length;ve++){if((ve===0?0:c[ve-1])>at){je=Math.min(I.length-1,ve+ce);break}je=Math.min(I.length-1,ve+ce)}const Re=We>0?c[We-1]:0,dt=Oe-c[je],yt=[...T,...Re>0?[{field:"__spacer_left__",width:Re,isSpacer:!0}]:[],...I.slice(We,je+1),...dt>0?[{field:"__spacer_right__",width:dt,isSpacer:!0}]:[],...B],sn=Le>0&&Z>Le?16:0,Ut=xe+V+se+sn+2,xt=5;let Ye=0,It=Ce-1,Kt=0,kt=0,Qe=le.length-1;for(;kt<=Qe;){const ve=kt+Qe>>>1;le[ve]<Te?kt=ve+1:Qe=ve-1}Ye=Math.max(0,kt-xt),Kt=Ye>0?le[Ye-1]:0;for(let ve=Ye;ve<le.length;ve++)if(le[ve]>=Te+fe){It=Math.min(Ce-1,ve+xt);break}return{renderContext:{firstRowIndex:Ye,lastRowIndex:It,firstColumnIndex:We,lastColumnIndex:je},offsetTop:Kt,offsetLeft:0,totalHeight:Ut,pinnedTopHeight:xe,pinnedBottomHeight:se,totalWidth:Z,rowHeights:he,cumulativeHeights:le,virtualColumns:yt,columnMetrics:{leftPinnedWidth:re,rightPinnedWidth:ue,unpinnedAccWidths:c,unpinnedCols:I,totalSpecialsWidth:Fe,pinnedSpecialsWidth:(G?48:0)+(Je&&W?48:0)+(s&&O?48:0)}}},[Yn,de.virtualization.scrollTop,de.virtualization.scrollLeft,de.dimensions.viewportHeight,de.dimensions.viewportWidth,d]),tl=i.useCallback(c=>{const I=c.currentTarget;if(Io(I.scrollTop,I.scrollLeft),jt){const{scrollTop:T,scrollHeight:B,clientHeight:Z}=I;B-T-Z<100&&jt({visibleTop:T,visibleBottom:T+Z,viewportHeight:Z})}},[Io,jt]);i.useEffect(()=>{if(!Nt.current)return;const c=new ResizeObserver(I=>{for(const T of I){const{width:B,height:Z}=T.contentRect;Mo(B,Z)}});return c.observe(Nt.current),()=>{c.disconnect()}},[Mo]);const Vt=i.useCallback((c,I)=>{const T=new Set(Ie);I?T.add(c):T.delete(c);const B=Array.from(T);nn||yo(B),gn?.(B)},[Ie,nn,gn]),nl=i.useCallback(c=>{let I=[];c&&(I=wn.map(T=>T.id)),nn||yo(I),gn?.(I)},[o,nn,gn]),Lo=i.useCallback((c,I)=>{const T=I?[{field:c,sort:I}]:[];Rn||ki(T),b?.(T)},[Rn,b]),Xn=i.useCallback(c=>{Wt(!1),Ft({id:c.row.id,field:c.field}),hn.current?.focus({preventScroll:!0}),m?.(c)},[m,Wt]),Ro=i.useRef($e.editingCell);i.useEffect(()=>{const c=!!Ro.current,I=!!$e.editingCell;c&&!I&&hn.current?.focus({preventScroll:!0}),Ro.current=$e.editingCell},[$e.editingCell]);const Oo=i.useMemo(()=>{const{firstRowIndex:c,lastRowIndex:I}=_e.renderContext,T=Ke.length,B=Ke.map((se,V)=>({row:se,rowIndex:V})),Z=st.map((se,V)=>({row:se,rowIndex:T+(Me?gt.length:Pe.length)+V})),re=Math.max(0,c-T),ue=Math.min(Me?gt.length:Pe.length,I-T+1),Oe=(Me?gt:Pe).slice(re,ue).map((se,V)=>({row:se,rowIndex:T+re+V})),Fe=[...B,...Oe,...Z],le=new Set;return Fe.filter(se=>le.has(se.row.id)?!1:(le.add(se.row.id),!0))},[_e.renderContext,Ke,st,gt,Pe,Me,z,de.dataSource.loading,ge.pageSize,l]),ol=o.length>0&&Ie.size===o.length,rl=Ie.size>0&&Ie.size<o.length,il=i.useCallback(c=>{c.target===c.currentTarget&&Ft(I=>{if(I)return I;if(s)return{id:"HEADER",field:"__checkbox_col__"};const T=Se[0],B=we[0];return T&&B?{id:T.id,field:B.field}:null})},[Se,we]),ll=i.useCallback(c=>{c.currentTarget.contains(c.relatedTarget)||Ft(null)},[]),sl=i.useCallback(c=>{if(Wt(!0),!qe)return;const{id:I,field:T}=qe,B=!!$e.editingCell;if(c.key==="Enter"){if(c.preventDefault(),B)$e.stopCellEdit();else if(we.find(he=>he.field===T)?.editable){const he=Se.find(Ce=>Ce.id===I);he&&$e.startCellEdit({id:I,field:T,value:he[T]})}return}if((c.key===" "||c.key==="Spacebar")&&!B){if(T==="__checkbox_col__"){c.preventDefault(),Vt(I,!Ie.has(I));return}if(T==="__expand_col__"){c.preventDefault(),ln(I);return}}if(I==="HEADER"&&(c.key==="Enter"||c.key===" ")){c.preventDefault();const V=we.find(he=>he.field===T);if(V&&V.sortable!==!1){const he=nt.find(be=>be.field===T);let Ce="asc";he&&(he.sort==="asc"?Ce="desc":Ce=null),Lo(T,Ce)}return}if(c.key==="Escape"){B&&(c.preventDefault(),$e.stopCellEdit({cancel:!0}));return}if(B&&c.key!=="Tab")return;const Z=I==="HEADER",re=Z?-1:Se.findIndex(V=>V.id===I),ue=we.findIndex(V=>V.field===T);if(!Z&&re===-1||ue===-1)return;const Oe=(V,he,Ce,be,Te,Le=!1)=>{let fe=V+Ce,ce=he+be;return Te&&be!==0&&(be>0&&ce>=we.length?(ce=0,fe++):be<0&&ce<0&&(ce=we.length-1,fe--)),!Te&&(ce<0||ce>=we.length)||fe<(Le?-1:0)||fe>=Se.length?null:{r:fe,c:ce}},Fe=(V,he,Ce,be,Te,Le=!1)=>{let fe=V,ce=he,ht=0;const at=Se.length*we.length+we.length;for(;ht<at;){if(ht++,fe+=Ce,ce+=be,be!==0)be>0?ce>=we.length&&(ce=0,fe++):ce<0&&(ce=we.length-1,fe--);else if(ce<0||ce>=we.length)return null;if(fe<-1||fe>=Se.length)return null;if(fe===-1){if(!Le)continue;const Re=we[ce],dt=Re.sortable!==!1;if(["__checkbox_col__"].includes(Re.field)||dt)return{r:fe,c:ce};continue}const We=Se[fe],je=we[ce],Ae=["__checkbox_col__","__expand_col__","__reorder_col__"].includes(je.field);let Ge=je.editable||Ae;if($&&!Ae)try{Ge=$({row:We,field:je.field,value:We[je.field],colDef:je,rowIndex:fe,colIndex:ce})}catch(Re){console.error("Error in isCellEditable:",Re)}if(Ge)return{r:fe,c:ce}}return null};let le=re,xe=ue,se=!1;if(c.key==="Tab"){const V=c.shiftKey?-1:1,he=Fe(re,ue,0,V,!0,!1);he&&(le=he.r,xe=he.c,se=!0)}else if(c.key==="ArrowRight"){const V=Oe(re,ue,0,1,!0,!0);V&&(le=V.r,xe=V.c,se=!0)}else if(c.key==="ArrowLeft"){const V=Oe(re,ue,0,-1,!0,!0);V&&(le=V.r,xe=V.c,se=!0)}else if(c.key==="ArrowDown"){const V=Oe(re,ue,1,0,!1,!0);V&&(le=V.r,xe=V.c,se=!0)}else if(c.key==="ArrowUp"){const V=Oe(re,ue,-1,0,!1,!0);V&&(le=V.r,xe=V.c,se=!0)}else if(c.key==="Home")(c.ctrlKey||c.metaKey)&&(le=-1),xe=0,se=!0;else if(c.key==="End")(c.ctrlKey||c.metaKey)&&(le=Se.length-1),xe=we.length-1,se=!0;else if(c.key==="PageUp"){const V=Me?ge.pageSize:10;le=Math.max(-1,le-V),se=!0}else if(c.key==="PageDown"){const V=Me?ge.pageSize:10;le=Math.min(Se.length-1,le+V),se=!0}if(se&&(c.preventDefault(),B&&c.key==="Tab"&&$e.stopCellEdit(),le>=-1&&le<Se.length&&xe>=0&&xe<we.length)){const V=we[xe];if(le===-1)Ft({id:"HEADER",field:V.field});else{const he=Se[le];Ft({id:he.id,field:V.field})}if(Nt.current){const{cumulativeHeights:he,pinnedTopHeight:Ce}=_e,{clientHeight:be,clientWidth:Te,scrollTop:Le,scrollLeft:fe}=Nt.current,ce=le===0?0:he[le-1],ht=he[le],at=Ce,We=Le+at,je=Le+be;let Ae=Le;if(ce<We?Ae=Math.max(0,ce-at):ht>je&&(Ae=ht-be),Ae!==Le&&(Nt.current.scrollTop=Ae),_e.columnMetrics){const{leftPinnedWidth:Ge,rightPinnedWidth:Re,unpinnedAccWidths:dt,unpinnedCols:yt,totalSpecialsWidth:pt,pinnedSpecialsWidth:sn}=_e.columnMetrics,Ut=V.field,xt=yt.findIndex(Ye=>Ye.field===Ut);if(xt!==-1){const Ye=pt+Ge+(xt>0?dt[xt-1]:0),It=pt+Ge+dt[xt],Kt=fe+sn+Ge,kt=fe+Te-Re;let Qe=fe;Ye<Kt?Qe=Math.max(0,Ye-sn-Ge):It>kt&&(Qe=It-Te+Re),Qe!==fe&&(Nt.current.scrollLeft=Qe)}}}}},[qe,Se,we,$e,_e,Ie,Vt,ln]),al=i.useMemo(()=>ke.some(c=>!!c.rowSpan),[ke]),[_n,Cn]=i.useState(!1),yn=i.useRef(null);return i.useEffect(()=>{if(!_n||ye?.toolbar)return;function c(I){const T=document.getElementById("ogx-standalone-col-panel");T&&!T.contains(I.target)&&Cn(!1)}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[_n,ye?.toolbar]),t.jsxs("div",{ref:yn,className:["ogx",en,d&&"ogx--auto-height",al&&"ogx--row-spanning",cn&&"ogx--list-view"].filter(Boolean).join(" "),style:{...Rt,height:q??Rt?.height,"--ogx-row-height":`${l}px`,"--ogx-header-height":`${a}px`},"aria-busy":on,children:[ye?.toolbar&&(()=>{const c={apiRef:lt.apiRef,columns:ke,baseColumns:e,aggregationModel:ot,onAggregationModelChange:Ii,...ze||et||tt?{pivotModel:_o,onPivotModelChange:Wi}:{},filterModel:Ve,onFilterModelChange:f,columnVisibilityModel:Xe,onColumnVisibilityModelChange:tn,onColumnReorder:X?void 0:(I,T)=>{const B=[..._t],Z=B.indexOf(I),re=B.indexOf(T);if(Z===-1||re===-1)return;const ue=[...B];ue.splice(Z,1),ue.splice(re,0,I),A||bn(ue);const Oe=ke.find(Fe=>Fe.field===I);Oe&&U?.({oldIndex:Z,targetIndex:re,column:Oe})},forceColumnsOpen:_n,onColumnsPanelClose:()=>Cn(!1),...ft?.toolbar};return t.jsx(ji,{...c})})(),!ye?.toolbar&&_n&&St.createPortal(t.jsxs("div",{id:"ogx-standalone-col-panel",style:(()=>{const c=yn.current?.getBoundingClientRect();return{position:"fixed",top:c?c.top+8:16,right:c?window.innerWidth-c.right+8:16,zIndex:9999,display:"inline-block"}})(),children:[t.jsx("button",{onClick:()=>Cn(!1),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:"×"}),t.jsx(co,{columns:ke,visibleColumns:new Set(ke.filter(c=>Xe[c.field]!==!1).map(c=>c.field)),onVisibilityChange:(c,I)=>{tn({...Xe,[c]:I})},onShowAll:()=>{const c={...Xe};ke.forEach(I=>{I.hideable!==!1&&(c[I.field]=!0)}),tn(c)},onHideAll:()=>{const c={...Xe};ke.forEach(I=>{I.hideable!==!1&&(c[I.field]=!1)}),tn(c)},onColumnReorder:X?void 0:(c,I)=>{const T=[..._t],B=T.indexOf(c),Z=T.indexOf(I);if(B===-1||Z===-1)return;const re=[...T];re.splice(B,1),re.splice(Z,0,c),A||bn(re),U?.({oldIndex:B,targetIndex:Z,column:ke.find(ue=>ue.field===c)})}})]}),yn.current?.closest(".ogx-theme-provider")||document.body),cn&&wo&&t.jsxs("div",{className:"ogx-list-view",role:"grid","aria-label":Ot||"Data grid list view","aria-rowcount":Se.length+1,children:[t.jsx("div",{className:"ogx-list-view__toolbar",children:t.jsxs("span",{children:[He.length," ",He.length===1?"item":"items",Me?` · page ${ge.page+1} of ${Math.ceil(He.length/ge.pageSize)||1}`:"",Ie.size>0?` · ${Ie.size} selected`:""]})}),t.jsx("div",{className:"ogx-list-view__rows",children:Se.length===0?t.jsxs("div",{className:"ogx-list-view__empty","aria-live":"polite",role:"status",children:[t.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),t.jsx("path",{d:"M3 9h18M9 21V9"})]}),Tn]}):Se.map((c,I)=>t.jsx(zo,{row:c,rowIndex:I,listViewColumn:wo,isSelected:Ie.has(c.id),checkboxSelection:s,rowHeight:l,onRowClick:T=>mn({row:T,id:T.id,rowIndex:I}),onSelectionChange:Vt},c.id))}),Me&&(()=>{const c=ye?.pagination||lo,I=z==="server"&&oe?de.pagination.rowCount||0:He.length,T={page:ge.page,pageSize:ge.pageSize,rowCount:I,pageSizeOptions:j,onPageChange:B=>fn({...ge,page:B}),onPageSizeChange:B=>fn({...ge,pageSize:B,page:0}),...ft?.pagination};return t.jsx(c,{...T})})()]}),!cn&&t.jsx("div",{ref:c=>{Nt.current=c,hn.current=c},className:"ogx__viewport",onScroll:tl,role:"grid","aria-label":Ot||"Data grid","aria-rowcount":He.length+1,"aria-colcount":e.length+(s?1:0)+(Je?1:0)+(G?1:0),"aria-busy":on,tabIndex:0,onKeyDownCapture:()=>{Wt(!0)},onMouseDownCapture:()=>{Wt(!1)},onKeyDown:sl,onFocus:il,onBlur:ll,children:t.jsxs("div",{ref:Di,className:"ogx__content",style:{width:_e.totalWidth},role:"presentation",children:[t.jsx(oo,{columns:_e.virtualColumns,allColumns:ke,columnGroupingModel:Et,checkboxSelection:s,allSelected:ol,someSelected:rl,onSelectAll:nl,sortModel:nt,onSort:Lo,onColumnResize:el,columnWidths:Ue,pinnedColumns:rt,focusedCell:qe,onHeaderClick:c=>{Ft({id:"HEADER",field:c}),Wt(!1),hn.current?.focus({preventScroll:!0})},onDragStart:Et?void 0:$t.onDragStart,onDragOver:Et?void 0:$t.onDragOver,onDragEnd:Et?void 0:$t.onDragEnd,onDrop:Et?void 0:$t.onDrop,draggedColumn:Et?void 0:$t.draggedColumn,dragOverColumn:Et?void 0:$t.dragOverColumn,rowReordering:G,hasDetailPanel:Je,pinCheckboxColumn:O,pinExpandColumn:W,aggregationModel:ot,onHideColumn:c=>{tn({...Xe,[c]:!1})},onManageColumns:()=>Cn(!0),onPinColumn:(c,I)=>{const T=[...rt?.left??[]],B=[...rt?.right??[]],Z=T.filter(ue=>ue!==c),re=B.filter(ue=>ue!==c);zn(I==="left"?{left:[...Z,c],right:re}:I==="right"?{left:Z,right:[...re,c]}:{left:Z,right:re})}}),!on&&!de.dataSource.error&&He.length===0&&t.jsxs("div",{className:"ogx__empty",style:{width:_e.totalWidth},children:[t.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),t.jsx("path",{d:"M3 9h18M9 21V9"})]}),t.jsx("span",{children:Tn})]}),Ke.length>0&&t.jsx("div",{className:"ogx__pinned-rows ogx__pinned-rows--top",role:"rowgroup",children:Ke.map((c,I)=>t.jsx(Jt,{row:c,columns:_e.virtualColumns,rowIndex:I,isSelected:Ie.has(c.id),checkboxSelection:s,onRowClick:mn,onCellClick:Xn,onSelectionChange:Vt,columnWidths:Ue,pinnedColumns:rt,pinnedRows:v,hasDetailPanel:Je,isDetailPanelExpanded:Ct.has(c.id),detailPanelContent:M?M({row:c,id:c.id,rowIndex:I}):null,detailPanelHeight:S?.({row:c,id:c.id,rowIndex:I})||200,onDetailPanelToggle:ln,pinCheckboxColumn:O,pinExpandColumn:W,focusedCellField:qe?.id===c.id?qe.field:null,colspanMap:Gt.colspanMap,rowSpanningCaches:Gt.rowSpanningState.caches,rowHeight:l},c.id))}),t.jsx("div",{className:"ogx__virtual-container",style:{height:`${_e.totalHeight-_e.pinnedTopHeight-_e.pinnedBottomHeight}px`},role:"presentation",children:t.jsxs("div",{className:"ogx__rows",style:{transform:`translateY(${_e.renderContext.firstRowIndex*l}px)`},role:"rowgroup",children:[on&&Oo.length===0?(()=>{const c=e.length>0?e:(()=>{const I=(de.dimensions.viewportWidth||1e3)-(s?48:0)-(M?48:0)-(G?48:0),T=150,B=Math.max(1,Math.ceil(I/T));return Array.from({length:B},(Z,re)=>({field:`placeholder_${re}`,headerName:"",width:T}))})();return Array.from({length:10}).map((I,T)=>t.jsx(ur,{columns:c,rowHeight:l,checkboxSelection:s,hasDetailPanel:!!M,rowReordering:G},`skeleton-${T}`))})():Oo.filter(({row:c})=>!En(c.id,v)).filter((c,I,T)=>I===T.findIndex(B=>B.row.id===c.row.id)).map(({row:c,rowIndex:I})=>t.jsx(Jt,{row:c,columns:_e.virtualColumns,rowIndex:I,isSelected:Ie.has(c.id),checkboxSelection:s,onRowClick:mn,onCellClick:Xn,onSelectionChange:Vt,columnWidths:Ue,pinnedColumns:rt,pinnedRows:v,hasDetailPanel:Je,isDetailPanelExpanded:Ct.has(c.id),detailPanelContent:M?M({row:c,id:c.id,rowIndex:I}):null,detailPanelHeight:S?.({row:c,id:c.id,rowIndex:I})||200,onDetailPanelToggle:ln,pinCheckboxColumn:O,pinExpandColumn:W,rowReordering:G,onDragStart:Ht.onDragStart,onDragOver:Ht.onDragOver,onDragEnd:Ht.onDragEnd,onDrop:Ht.onDrop,isDragging:Ht.draggedRowId===c.id,isDragOver:Ht.dragOverRowId===c.id,editingCell:$e.editingCell,onEditStart:$e.startCellEdit,onEditStop:$e.stopCellEdit,onEditCellValueChange:$e.setEditCellValue,focusedCellField:qe!=null&&qe.id===c.id?qe.field:null,colspanMap:Gt.colspanMap,rowSpanningCaches:Gt.rowSpanningState.caches,rowHeight:l},`${c.id}-${_e.totalWidth}`)),z==="infinite"&&de.dataSource.loading&&Pe.length>0&&(()=>{const c=Math.min(ge.pageSize,20),I=Yn.unpinnedRowsLength;return t.jsx("div",{className:"ogx__skeleton-group",children:Array.from({length:c}).map((T,B)=>t.jsx(Jt,{row:{id:`__skeleton_${B}__`,_isSkeleton:!0},columns:_e.virtualColumns,rowIndex:I+B,rowHeight:l},`__skeleton_${B}__`))})})()]})}),st.length>0&&t.jsx("div",{className:"ogx__pinned-rows ogx__pinned-rows--bottom",role:"rowgroup",children:st.map((c,I)=>t.jsx(Jt,{row:c,columns:_e.virtualColumns,rowIndex:I,isSelected:Ie.has(c.id),checkboxSelection:s,onRowClick:mn,onCellClick:Xn,onSelectionChange:Vt,columnWidths:Ue,pinnedColumns:rt,pinnedRows:v,hasDetailPanel:Je,isDetailPanelExpanded:Ct.has(c.id),detailPanelContent:M?M({row:c,id:c.id,rowIndex:I}):null,detailPanelHeight:S?.({row:c,id:c.id,rowIndex:I})||200,onDetailPanelToggle:ln,pinCheckboxColumn:O,pinExpandColumn:W,focusedCellField:qe?.id===c.id?qe.field:null,colspanMap:Gt.colspanMap,rowSpanningCaches:Gt.rowSpanningState.caches,rowHeight:l},c.id))}),vn&&!ze&&t.jsxs("div",{className:"ogx__aggregation-footer",role:"row","aria-label":"Aggregation totals","aria-live":"polite",style:{minHeight:`${l}px`},children:[s&&t.jsx("div",{style:{width:48,flexShrink:0}}),Je&&t.jsx("div",{style:{width:48,flexShrink:0}}),G&&t.jsx("div",{style:{width:48,flexShrink:0}}),Bt.map(c=>{const I=ot[c.field],T=Kn[c.field],B=Ue[c.field]??(typeof c.width=="number"?c.width:120);return t.jsx("div",{className:"ogx__aggregation-cell",role:"gridcell",style:{width:B,minWidth:B,maxWidth:B,textAlign:c.align||"left"},children:I?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"ogx__aggregation-label",children:I}),t.jsx("span",{className:"ogx__aggregation-value",children:bt(T,I)})]}):null},c.field)})]})]})}),!cn&&Me&&(()=>{const c=ye?.pagination||lo,I={page:ge.page,pageSize:ge.pageSize,rowCount:de.pagination.rowCount,pageSizeOptions:j,onPageChange:T=>fn({...ge,page:T}),onPageSizeChange:T=>fn({...ge,pageSize:T,page:0}),...ft?.pagination};return t.jsx(c,{...I})})(),t.jsxs("div",{className:"ogx-aria-live-status",role:"status","aria-live":"polite",children:[on?"Loading data...":"",de.dataSource.error?`Error: ${de.dataSource.error.message||"Unknown error"}`:"",!Q&&!de.dataSource.error&&(He.length===0?Tn:Ve&&((Ve.quickFilterValues?.length||0)>0||(Ve.items?.length||0)>0)?`${He.length} ${He.length===1?"row":"rows"} found`:"")]}),de.dataSource.error&&t.jsxs("div",{className:"ogx-error-overlay","aria-live":"assertive",role:"alert",children:[t.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:[t.jsx("circle",{cx:"12",cy:"12",r:"10"}),t.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),t.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),t.jsx("div",{className:"ogx-error-overlay__title",children:"Oops! Something went wrong"}),t.jsx("div",{className:"ogx-error-overlay__message",children:de.dataSource.error.message||"An unexpected error occurred while loading the data."}),t.jsx("button",{onClick:()=>window.location.reload(),className:"ogx-button ogx-button--primary",children:"Retry"})]})]})}function Wr({rows:n=5,columns:o=5}){return t.jsx("div",{className:"ogx__skeleton",children:Array.from({length:n}).map((e,r)=>t.jsx("div",{className:"ogx__skeleton-row",children:Array.from({length:o}).map((l,a)=>t.jsx("div",{className:"ogx__skeleton-cell",children:t.jsx("div",{className:"ogx__skeleton-content"})},a))},r))})}const uo=new Set(["isEmpty","isNotEmpty"]);function Ar(n,o){return n.find(e=>"field"in e&&e.field===o)}const zr=({col:n,item:o,onChange:e})=>{const r=_r(n.type),l=!!o,a=o?.operator??r[0],[d,s]=i.useState(o?.value??""),g=i.useRef(e);g.current=e;const u=i.useRef(o?.value);i.useEffect(()=>{o?.value!==u.current&&(u.current=o?.value,s(o?.value??""))},[o?.value]),i.useEffect(()=>{const b=setTimeout(()=>{const E=o?.value??"";d!==E&&g.current({id:o?.id??`${n.field}-${Date.now()}`,field:n.field,operator:a,value:d})},300);return()=>clearTimeout(b)},[d]);const h=b=>{const E=uo.has(b),P={id:o?.id??`${n.field}-${Date.now()}`,field:n.field,operator:b,value:E?void 0:o?.value??(n.type==="boolean"?"true":"")};e(P)},m=()=>{s(""),e(null)},p=uo.has(String(a)),f=n.type==="boolean",C=!p;return t.jsxs("div",{className:`ogx-filter__row${l?" ogx-filter__row--active":""}`,children:[t.jsx("span",{className:"ogx-filter__col-label",title:n.field,children:n.headerName||n.field}),t.jsxs("div",{className:"ogx-filter__controls",children:[t.jsx("select",{id:`ogx-filter-op-${n.field}`,name:`filter-op-${n.field}`,className:`ogx-filter__op-select${l?" ogx-filter__op-select--active":""}`,value:String(a),onChange:b=>h(b.target.value),"aria-label":`Filter operator for ${n.headerName||n.field}`,children:r.map(b=>t.jsx("option",{value:b,children:b},b))}),C&&f&&t.jsxs("select",{id:`ogx-filter-val-${n.field}`,name:`filter-val-${n.field}`,className:`ogx-filter__value-input ogx-filter__value-select${l?" ogx-filter__value-input--active":""}`,value:String(o?.value??"true"),onChange:b=>{s(b.target.value),e({id:o?.id??`${n.field}-${Date.now()}`,field:n.field,operator:a,value:b.target.value})},"aria-label":`Filter value for ${n.headerName||n.field}`,children:[t.jsx("option",{value:"true",children:"true"}),t.jsx("option",{value:"false",children:"false"})]}),C&&!f&&t.jsx("input",{id:`ogx-filter-val-${n.field}`,name:`filter-val-${n.field}`,className:`ogx-filter__value-input${l?" ogx-filter__value-input--active":""}`,type:"text",value:d,onChange:b=>s(b.target.value),placeholder:n.type==="number"?"Number…":"Value…","aria-label":`Filter value for ${n.headerName||n.field}`}),l&&t.jsx("button",{className:"ogx-filter__row-clear",onClick:m,"aria-label":`Clear filter for ${n.headerName||n.field}`,title:"Clear",children:"×"})]})]})},fo=({filterModel:n,columns:o,onFilterModelChange:e})=>{const r=n.items??[],l=n.logicOperator??"and",a=i.useCallback((g,u)=>{const h=r.filter(p=>"field"in p&&p.field!==g),m=u?[...h,u]:h;e({...n,items:m})},[r,n,e]),d=i.useCallback(g=>{e({...n,logicOperator:g})},[n,e]),s=o.filter(g=>g.filterable!==!1);return t.jsxs(t.Fragment,{children:[r.length>1&&t.jsxs("div",{className:"ogx-filter__logic-bar",children:[t.jsx("span",{className:"ogx-filter__logic-label",children:"Match:"}),t.jsx("button",{className:`ogx-filter__logic-pill${l==="and"?" ogx-filter__logic-pill--active":""}`,onClick:()=>d("and"),"aria-pressed":l==="and",children:"ALL (AND)"}),t.jsx("button",{className:`ogx-filter__logic-pill${l==="or"?" ogx-filter__logic-pill--active":""}`,onClick:()=>d("or"),"aria-pressed":l==="or",children:"ANY (OR)"})]}),s.length===0?t.jsx("div",{className:"ogx-filter__empty",children:"No filterable columns."}):s.map(g=>t.jsx(zr,{col:g,item:Ar(r,g.field),onChange:u=>a(g.field,u)},g.field))]})},Br=["sum","avg","count","min","max"];function go(){return t.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:[t.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),t.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),t.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),t.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1",fill:"currentColor",opacity:"0.25"}),t.jsx("path",{d:"M17 14v-4M17 10l-2 2 2 2"})]})}function $r({anchorRef:n,columns:o,model:e,onChange:r,onClose:l}){const a=i.useRef(null),[d,s]=i.useState({top:0,right:0}),g=i.useCallback(()=>{if(!n.current)return{top:0,right:0};const x=n.current.getBoundingClientRect();return{top:x.bottom+6,right:window.innerWidth-x.right}},[n]);i.useEffect(()=>{s(g());const x=()=>s(g());return window.addEventListener("scroll",x,!0),window.addEventListener("resize",x),()=>{window.removeEventListener("scroll",x,!0),window.removeEventListener("resize",x)}},[g]),i.useEffect(()=>{function x(O){a.current&&!a.current.contains(O.target)&&n.current&&!n.current.contains(O.target)&&l()}function N(O){O.key==="Escape"&&l()}return document.addEventListener("mousedown",x),document.addEventListener("keydown",N),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",N)}},[n,l]);const u=new Set(e.rowFields),h=new Set(e.columnFields),m=new Set(e.valueFields.map(x=>x.field)),p=x=>u.has(x)||h.has(x)||m.has(x);function f(x){u.has(x)||r({...e,rowFields:[...e.rowFields,x]})}function C(x){h.has(x)||r({...e,columnFields:[...e.columnFields,x]})}function b(x,N="sum"){m.has(x)||r({...e,valueFields:[...e.valueFields,{field:x,aggFn:N}]})}function E(x){r({...e,rowFields:e.rowFields.filter(N=>N!==x)})}function P(x){r({...e,columnFields:e.columnFields.filter(N=>N!==x)})}function k(x){r({...e,valueFields:e.valueFields.filter(N=>N.field!==x)})}function j(x,N){r({...e,valueFields:e.valueFields.map(O=>O.field===x?{...O,aggFn:N}:O)})}function y(){r({rowFields:[],columnFields:[],valueFields:[]})}const w=new Set(o.filter(x=>x.type==="number"||x.aggregable).map(x=>x.field)),v=e.rowFields.length+e.columnFields.length+e.valueFields.length,M=x=>o.find(N=>N.field===x)?.headerName??x,S=t.jsxs("div",{ref:a,className:"ogx-pivot-panel",role:"dialog","aria-label":"Pivot configuration",style:{top:d.top,right:d.right},children:[t.jsxs("div",{className:"ogx-pivot-panel__header",children:[t.jsxs("span",{className:"ogx-pivot-panel__title",children:[t.jsx(go,{}),"Pivot Mode"]}),v>0&&t.jsx("button",{className:"ogx-pivot-panel__reset-btn",onClick:y,title:"Reset pivot",children:"Reset"})]}),t.jsxs("div",{className:"ogx-pivot-panel__body",children:[t.jsxs("div",{className:"ogx-pivot-zone",children:[t.jsxs("span",{className:"ogx-pivot-zone__label",children:[t.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--row"}),"Row Fields"]}),t.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(x=>t.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--row",children:[M(x),t.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>E(x),title:`Remove ${M(x)}`,children:"×"})]},x))})]}),t.jsxs("div",{className:"ogx-pivot-zone",children:[t.jsxs("span",{className:"ogx-pivot-zone__label",children:[t.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--col"}),"Column Fields"]}),t.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(x=>t.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--col",children:[M(x),t.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>P(x),title:`Remove ${M(x)}`,children:"×"})]},x))})]}),t.jsxs("div",{className:"ogx-pivot-zone",children:[t.jsxs("span",{className:"ogx-pivot-zone__label",children:[t.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--value"}),"Value Fields (aggregated)"]}),t.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(x=>t.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--value",children:[M(x.field),t.jsx("select",{className:"ogx-pivot-chip__fn-select",value:x.aggFn,onChange:N=>j(x.field,N.target.value),title:"Aggregation function",children:Br.map(N=>t.jsx("option",{value:N,children:N.toUpperCase()},N))}),t.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>k(x.field),title:`Remove ${M(x.field)}`,children:"×"})]},x.field))})]}),t.jsx("hr",{className:"ogx-pivot-panel__divider"}),t.jsxs("div",{children:[t.jsx("div",{className:"ogx-pivot-panel__fields-label",children:"Available Fields"}),t.jsxs("div",{className:"ogx-pivot-fields",children:[o.map(x=>{const N=w.has(x.field);return p(x.field)?null:t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3},children:[t.jsx("span",{className:`ogx-pivot-field-btn${N?" ogx-pivot-field-btn--numeric":""}`,children:x.headerName??x.field}),t.jsxs("div",{className:"ogx-pivot-field-actions",children:[t.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--row",onClick:()=>f(x.field),title:"Add to Row Fields",children:"Row"}),t.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--col",onClick:()=>C(x.field),title:"Add to Column Fields",children:"Col"}),N&&t.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--value",onClick:()=>b(x.field),title:"Add to Value Fields",children:"Val"})]})]},x.field)}),o.every(x=>p(x.field))&&t.jsx("span",{style:{fontSize:12,color:"var(--ogx-color-gray-400, #94a3b8)"},children:"All fields are in use."})]})]})]})]});return St.createPortal(S,n.current?.closest(".ogx-theme-provider")||document.body)}function Dr(){return t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function Hr(){return t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function Gr({value:n="",onChange:o,placeholder:e="Search...",debounceMs:r=250}){const[l,a]=i.useState(()=>n.length>0),[d,s]=i.useState(n),g=i.useRef(null),u=i.useRef(null),h=i.useRef(o);h.current=o;const m=i.useRef(n),p=i.useRef(n),f=i.useRef(!1);i.useLayoutEffect(()=>{f.current&&document.activeElement!==g.current&&g.current?.focus()}),i.useEffect(()=>{n!==p.current&&(p.current=n,n!==m.current&&(s(n),m.current=n,n?a(!0):(f.current=!1,a(!1))))},[n]),i.useEffect(()=>{const k=setTimeout(()=>{d!==m.current&&(m.current=d,h.current(d))},r);return()=>clearTimeout(k)},[d,r]);const C=i.useCallback(()=>{a(!0),requestAnimationFrame(()=>g.current?.focus())},[]),b=i.useCallback(k=>{k.stopPropagation(),s(""),m.current="",h.current(""),g.current?.focus()},[]),E=i.useCallback(()=>{f.current=!0,a(!0)},[]),P=i.useCallback(()=>{f.current=!1,setTimeout(()=>{if(u.current&&document.activeElement&&u.current.contains(document.activeElement)){f.current=!0;return}d||a(!1)},150)},[d]);return i.useEffect(()=>{const k=j=>{u.current&&!u.current.contains(j.target)&&(d||a(!1))};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[d]),t.jsxs("div",{ref:u,className:`ogx-global-search${l?" ogx-global-search--expanded":""}`,onClick:l?void 0:C,children:[t.jsx("div",{className:"ogx-global-search__icon-wrapper",children:t.jsx(Dr,{})}),t.jsx("input",{ref:g,id:"ogx-global-search-input",name:"ogx-global-search",className:"ogx-global-search__input",value:d,onChange:k=>s(k.target.value),onFocus:E,onBlur:P,placeholder:e,"aria-label":"Global Search",autoComplete:"off"}),d&&t.jsx("button",{className:"ogx-global-search__clear",onClick:b,"aria-label":"Clear search",children:t.jsx(Hr,{})})]})}function Zt({title:n,children:o,placement:e="top",enterDelay:r=200,leaveDelay:l=0}){const[a,d]=i.useState(!1),[s,g]=i.useState({top:0,left:0}),u=i.useRef(null),h=i.useRef(null),m=i.useCallback(()=>{if(!h.current)return;const b=h.current.getBoundingClientRect();let E=0,P=0;const k=window.pageXOffset||document.documentElement.scrollLeft,j=window.pageYOffset||document.documentElement.scrollTop;e==="top"?(E=b.top+j-8,P=b.left+k+b.width/2):e==="bottom"&&(E=b.bottom+j+8,P=b.left+k+b.width/2),g({top:E,left:P})},[e]);i.useLayoutEffect(()=>(a&&(m(),window.addEventListener("scroll",m,!0),window.addEventListener("resize",m)),()=>{window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m)}),[a,m]);const p=()=>{u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{d(!0)},r)},f=()=>{u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{d(!1)},l)},C=i.useCallback(b=>{h.current=b?b.firstElementChild??b:null},[]);return t.jsxs(t.Fragment,{children:[t.jsx("span",{ref:C,style:{display:"inline-block",lineHeight:0},onMouseEnter:p,onMouseLeave:f,children:o}),a&&n&&St.createPortal(t.jsx("div",{className:`ogx-tooltip ogx-tooltip--${e}`,style:{top:s.top,left:s.left,position:"absolute",zIndex:99999},children:n}),document.body)]})}const Vr=["none","sum","avg","count","min","max"];function ho(){return t.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:t.jsx("path",{d:"M18 4H6l6 8-6 8h12"})})}function Ur(){return t.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",children:[t.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),t.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.25"}),t.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),t.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),t.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),t.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function po(){return t.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})})}function Kr({anchorRef:n,aggregationModel:o,aggregableColumns:e,onFunctionChange:r,onClearAll:l,onClose:a,activeCount:d}){const s=i.useRef(null),[g,u]=i.useState({top:0,right:0}),h=i.useCallback(()=>{if(!n.current)return{top:0,right:0};const p=n.current.getBoundingClientRect();return{top:p.bottom+6,right:window.innerWidth-p.right}},[n]);i.useEffect(()=>{u(h());const p=()=>u(h());return window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)}},[h]),i.useEffect(()=>{function p(f){s.current&&!s.current.contains(f.target)&&n.current&&!n.current.contains(f.target)&&a()}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[n,a]),i.useEffect(()=>{function p(f){f.key==="Escape"&&a()}return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[a]);const m=t.jsxs("div",{ref:s,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Summaries configuration",style:{top:g.top,right:g.right,width:400,maxWidth:"calc(100vw - 24px)"},children:[t.jsxs("div",{className:"ogx-toolbar__panel-header",children:[t.jsxs("span",{className:"ogx-toolbar__panel-title",children:[t.jsx(ho,{}),"Summaries"]}),d>0&&t.jsx("button",{className:"ogx-toolbar__clear-btn",onClick:l,title:"Clear all summaries",children:"Clear all"})]}),t.jsx("div",{className:"ogx-toolbar__panel-body",children:e.length===0?t.jsxs("p",{className:"ogx-toolbar__empty",children:["No aggregable columns.",t.jsx("br",{}),"Set ",t.jsx("code",{children:"aggregable: true"})," on a column to enable."]}):e.map(p=>{const f=o[p.field]||"none";return t.jsxs("div",{className:"ogx-toolbar__agg-row",children:[t.jsx("span",{className:"ogx-toolbar__agg-label",title:p.field,children:p.headerName||p.field}),t.jsx("div",{className:"ogx-toolbar__agg-pills",children:Vr.map(C=>t.jsx("button",{className:`ogx-toolbar__pill${f===C?" ogx-toolbar__pill--active":""}`,onClick:()=>r(p.field,C),"aria-pressed":f===C,children:C},C))})]},p.field)})})]});return St.createPortal(m,n.current?.closest(".ogx-theme-provider")||document.body)}function Yr({anchorRef:n,columns:o,visibleColumns:e,onVisibilityChange:r,onShowAll:l,onHideAll:a,onColumnReorder:d,onClose:s}){const g=i.useRef(null),[u,h]=i.useState({top:0,right:0}),m=i.useCallback(()=>{if(!n.current)return{top:0,right:0};const f=n.current.getBoundingClientRect();return{top:f.bottom+6,right:window.innerWidth-f.right}},[n]);i.useEffect(()=>{h(m());const f=()=>h(m());return window.addEventListener("scroll",f,!0),window.addEventListener("resize",f),()=>{window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[m]),i.useEffect(()=>{function f(C){g.current&&!g.current.contains(C.target)&&n.current&&!n.current.contains(C.target)&&s()}return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[n,s]);const p=t.jsx("div",{ref:g,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Column visibility",style:{top:u.top,right:u.right,width:280,padding:0},children:t.jsx(co,{columns:o,visibleColumns:e,onVisibilityChange:r,onShowAll:l,onHideAll:a,onColumnReorder:d})});return St.createPortal(p,n.current?.closest(".ogx-theme-provider")||document.body)}function Xr({anchorRef:n,columns:o,filterModel:e,onFilterModelChange:r,onClose:l}){const a=i.useRef(null),[d,s]=i.useState({top:0,right:0}),g=i.useRef(l);g.current=l;const u=i.useCallback(()=>{if(!n.current)return{top:0,right:0};const f=n.current.getBoundingClientRect();return{top:f.bottom+6,right:window.innerWidth-f.right}},[n]);i.useEffect(()=>{s(u());const f=()=>s(u());return window.addEventListener("scroll",f,!0),window.addEventListener("resize",f),()=>{window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[u]),i.useEffect(()=>{function f(C){C.key==="Escape"&&g.current()}return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[]);const h=e.items?.length??0,m=()=>{r({...e,items:[],logicOperator:"and"})},p=t.jsxs("div",{ref:a,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:[t.jsxs("div",{className:"ogx-toolbar__panel-header",children:[t.jsxs("span",{className:"ogx-toolbar__panel-title",children:[t.jsx(po,{}),"Filters",h>0&&t.jsx("span",{className:"ogx-toolbar__panel-count",children:h})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[h>0&&t.jsx("button",{className:"ogx-toolbar__clear-btn",onClick:m,title:"Clear all filters",children:"Clear all"}),t.jsx("button",{className:"ogx-toolbar__close-btn",onClick:()=>g.current(),title:"Close filters","aria-label":"Close filters panel",children:"Close"})]})]}),t.jsx("div",{className:"ogx-toolbar__panel-body ogx-toolbar__panel-body--filter",children:t.jsx(fo,{columns:o,filterModel:e,onFilterModelChange:r})})]});return St.createPortal(p,n.current?.closest(".ogx-theme-provider")||document.body)}const qr={rowFields:[],columnFields:[],valueFields:[]};function Jr({columns:n=[],baseColumns:o,aggregationModel:e={},onAggregationModelChange:r,pivotModel:l,onPivotModelChange:a,filterModel:d,onFilterModelChange:s,columnVisibilityModel:g={},onColumnVisibilityModelChange:u,onColumnReorder:h,forceColumnsOpen:m,onColumnsPanelClose:p,children:f,rightContent:C,style:b}){const[E,P]=i.useState(!1),[k,j]=i.useState(!1),[y,w]=i.useState(!1),[v,M]=i.useState(!1);i.useEffect(()=>{m&&(w(!0),P(!1),j(!1),M(!1))},[m]);const S=i.useRef(null),x=i.useRef(null),N=i.useRef(null),O=i.useRef(null),W=l??qr,X=W.rowFields.length>0||W.columnFields.length>0||W.valueFields.length>0,A=n.filter(R=>R.aggregable!==!1&&(R.type==="number"||R.aggregable===!0)),U=Object.keys(e).filter(R=>e[R]&&e[R]!=="none").length,q=i.useCallback((R,Y)=>{if(!r)return;const $={...e};Y==="none"?delete $[R]:$[R]=Y,r($)},[e,r]),G=i.useCallback(()=>{r?.({})},[r]),ee=i.useCallback(R=>{if(!s)return;const $={...d||{},quickFilterValues:R?[R]:[],items:d?.items||[]};s($)},[d,s]),Q=d?.quickFilterValues?.[0]||"",pe=d?.items?.length||0,_=new Set(n.filter(R=>g[R.field]!==!1).map(R=>R.field)),D=i.useCallback((R,Y)=>{if(!u)return;const $={...g,[R]:Y};u($)},[g,u]),H=i.useCallback(()=>{if(!u)return;const R={...g};n.forEach(Y=>{Y.hideable!==!1&&(R[Y.field]=!0)}),u(R)},[n,g,u]),K=i.useCallback(()=>{if(!u)return;const R={...g};n.forEach(Y=>{Y.hideable!==!1&&(R[Y.field]=!1)}),u(R)},[n,g,u]);return t.jsxs("div",{className:"ogx-toolbar",role:"toolbar","aria-label":"Grid toolbar",style:b,children:[f&&t.jsx("div",{className:"ogx-toolbar__left",children:f}),t.jsx("div",{className:"ogx-toolbar__spacer"}),t.jsxs("div",{className:"ogx-toolbar__actions",children:[s&&t.jsx("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:t.jsx(Gr,{value:Q,onChange:ee,placeholder:"Search..."})}),u&&t.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[t.jsx(Zt,{title:"Columns",children:t.jsx("button",{ref:N,className:`ogx-toolbar__icon-btn${y?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Manage columns",onClick:()=>{w(!y),P(!1),j(!1),M(!1)},children:t.jsx(Ur,{})})}),y&&t.jsx(Yr,{anchorRef:N,columns:n,visibleColumns:_,onVisibilityChange:D,onShowAll:H,onHideAll:K,onColumnReorder:h,onClose:()=>{w(!1),p?.()}})]}),s&&t.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[t.jsx(Zt,{title:"Filters",children:t.jsxs("button",{ref:O,className:`ogx-toolbar__icon-btn${v?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Advanced filters",onClick:()=>{M(!v),P(!1),j(!1),w(!1)},children:[t.jsx(po,{}),pe>0&&t.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Filters active"})]})}),v&&t.jsx(Xr,{anchorRef:O,columns:n,filterModel:d||{items:[]},onFilterModelChange:s,onClose:()=>M(!1)})]}),a&&t.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[t.jsx(Zt,{title:"Pivot",children:t.jsxs("button",{ref:x,id:"ogx-pivot-btn",className:`ogx-toolbar__icon-btn${k?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure pivot","aria-expanded":k,"aria-controls":"ogx-pivot-panel",onClick:()=>{j(!k),P(!1),w(!1),M(!1)},children:[t.jsx(go,{}),X&&t.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Pivot active"})]})}),k&&t.jsx($r,{anchorRef:x,columns:o??n,model:W,onChange:R=>{a?.(R)},onClose:()=>j(!1)})]}),t.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[t.jsx(Zt,{title:"Summaries",children:t.jsxs("button",{ref:S,id:"ogx-aggregation-btn",className:`ogx-toolbar__icon-btn${E?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure summaries","aria-expanded":E,"aria-controls":"ogx-aggregation-panel",onClick:()=>{P(!E),j(!1),w(!1),M(!1)},children:[t.jsx(ho,{}),U>0&&t.jsx("span",{className:"ogx-toolbar__dot","aria-label":`${U} active summaries`})]})}),E&&t.jsx(Kr,{anchorRef:S,aggregationModel:e,aggregableColumns:A,onFunctionChange:q,onClearAll:G,onClose:()=>P(!1),activeCount:U})]}),C]})]})}function Qr(){return i.useRef(null)}const Zr=({fullWidth:n=!1,error:o=!1,startAdornment:e,endAdornment:r,className:l="",...a})=>{const d=["ogx-input-wrapper",n&&"ogx-input-wrapper--full-width",o&&"ogx-input-wrapper--error",a.disabled&&"ogx-input-wrapper--disabled",l].filter(Boolean).join(" ");return t.jsxs("div",{className:d,children:[e&&t.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--start",children:e}),t.jsx("input",{className:"ogx-input",...a}),r&&t.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--end",children:r})]})};function ei(n,o,e={}){const{fileName:r="export.csv",includeHeaders:l=!0,delimiter:a=",",selectedRows:d}=e,s=d&&d.length>0?n.filter(h=>d.includes(h.id)):n;if(s.length===0){console.warn("No rows to export");return}const g=o.filter(h=>!(h.exportable===!1||h.field==="__check__"||h.field==="__actions__"));let u="";if(l){const h=g.map(m=>Lt(m.headerName||m.field));u+=h.join(a)+`
|
|
9
|
-
`}if(s.forEach(
|
|
10
|
-
`}),e.aggregationResult){const
|
|
11
|
-
`;const f
|
|
12
|
-
`}
|
|
13
|
-
`)?`"${
|
|
6
|
+
<%s key={someKey} {...props} />`,z,H,R,H),ee[H+z]=!0)}if(H=null,B!==void 0&&(e(B),H=""+B),d(G)&&(e(G.key),H=""+G.key),"key"in G){B={};for(var re in G)re!=="key"&&(B[re]=G[re])}else B=G;return H&&s(B,typeof _=="function"?_.displayName||_.name||"Unknown":_),c(_,H,B,l(),L,X)}function m(_){b(_)?_._store&&(_._store.validated=1):typeof _=="object"&&_!==null&&_.$$typeof===I&&(_._payload.status==="fulfilled"?b(_._payload.value)&&_._payload.value._store&&(_._payload.value._store.validated=1):_._store&&(_._store.validated=1))}function b(_){return typeof _=="object"&&_!==null&&_.$$typeof===w}var x=i,w=Symbol.for("react.transitional.element"),h=Symbol.for("react.portal"),j=Symbol.for("react.fragment"),P=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),E=Symbol.for("react.consumer"),y=Symbol.for("react.context"),g=Symbol.for("react.forward_ref"),v=Symbol.for("react.suspense"),N=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),M=Symbol.for("react.activity"),C=Symbol.for("react.client.reference"),W=x.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Y=Object.prototype.hasOwnProperty,F=Array.isArray,D=console.createTask?console.createTask:function(){return null};x={react_stack_bottom_frame:function(_){return _()}};var K,O={},V=x.react_stack_bottom_frame.bind(x,a)(),J=D(r(a)),ee={};yt.Fragment=j,yt.jsx=function(_,G,B){var z=1e4>W.recentlyCreatedOwnerStacks++;return p(_,G,B,!1,z?Error("react-stack-top-frame"):V,z?D(r(_)):J)},yt.jsxs=function(_,G,B){var z=1e4>W.recentlyCreatedOwnerStacks++;return p(_,G,B,!0,z?Error("react-stack-top-frame"):V,z?D(r(_)):J)}})()),yt}var In;function bo(){return In||(In=1,process.env.NODE_ENV==="production"?Ot.exports=xo():Ot.exports=mo()),Ot.exports}var n=bo();function Ft(t,o){return o?o.left?.includes(t)?"left":o.right?.includes(t)?"right":null:null}function wo(t,o){const e=[],r=[],l=[];return o?(t.forEach(a=>{const d=Ft(a.field,o);d==="left"?e.push(a):d==="right"?l.push(a):r.push(a)}),o.left&&e.sort((a,d)=>{const s=o.left.indexOf(a.field),f=o.left.indexOf(d.field);return s-f}),o.right&&l.sort((a,d)=>{const s=o.right.indexOf(a.field),f=o.right.indexOf(d.field);return s-f}),{left:e,center:r,right:l}):{left:e,center:t,right:l}}function Pn(t,o,e,r,l,a,d,s){const f={};if(!e)return f;const c=wo(t,e);let p=0;s&&(p+=48),a&&d&&(p+=48),r&&l&&(p+=48),c.left.forEach(b=>{f[b.field]=p;const x=o[b.field]??b.width??100;p+=x});let m=0;return[...c.right].reverse().forEach(b=>{const x=o[b.field]??b.width??100;f[b.field]=m,m+=x}),f}function tn(t,o){return o?o.top?.includes(t)?"top":o.bottom?.includes(t)?"bottom":null:null}function vo(t,o){const e=[],r=[],l=[];return o?(t.forEach(a=>{const d=tn(a.id,o);d==="top"?e.push(a):d==="bottom"?l.push(a):r.push(a)}),o.top&&e.sort((a,d)=>{const s=o.top.indexOf(a.id),f=o.top.indexOf(d.id);return s-f}),o.bottom&&l.sort((a,d)=>{const s=o.bottom.indexOf(a.id),f=o.bottom.indexOf(d.id);return s-f}),{top:e,center:r,bottom:l}):{top:e,center:t,bottom:l}}function it(t){if(t===void 0)return{type:"auto",value:0};if(typeof t=="number")return{type:"fixed",value:t};if(typeof t=="string"){if(t.toLowerCase()==="auto")return{type:"auto",value:0};if(t.endsWith("%"))return{type:"percentage",value:parseFloat(t)};const o=parseFloat(t);if(!isNaN(o))return{type:"fixed",value:o}}return{type:"fixed",value:100}}function _o(t){const{rowHeight:o,pagination:e,paginatedUnpinnedRows:r,sortedUnpinnedRows:l,expandedRowIds:a,getDetailPanelHeight:d,pinnedTopRowsLength:s,pinnedBottomRowsLength:f,visibleOrderedColumns:c,pinnedColumns:p,columnWidths:m,viewportWidth:b,checkboxSelection:x,hasDetailPanel:w,rowReordering:h,pinCheckboxColumn:j,pinExpandColumn:P,autoHeight:k,paginationMode:E,isLoading:y,pageSize:g}=t;return i.useMemo(()=>{const v=e?r:l,N=v.map(($,q)=>{let te=o;if(a.has($.id)){const he=d?.({row:$,id:$.id,rowIndex:s+q})??200;te+=typeof he=="number"?he:parseInt(String(he),10)||200}return te}),S=N.reduce(($,q,te)=>($.push(($[te-1]||0)+q),$),[]),I=E==="infinite"&&y&&v.length>0?Math.min(g,20):0,M=(S[S.length-1]||0)+I*o,C=s*o,W=f*o,Y=[],F=[],D=[],K=[];c.forEach($=>{const q=Ft($.field,p);q==="left"?Y.push($):q==="right"?F.push($):D.push($)});const O=(x?48:0)+(w?48:0)+(h?48:0),V=$=>m[$.field]??$.width,J=Y.reduce(($,q)=>{const te=it(V(q));return $+(te.type==="fixed"?te.value:100)},0),ee=F.reduce(($,q)=>{const te=it(V(q));return $+(te.type==="fixed"?te.value:100)},0),_=D.reduce(($,q)=>{if(!Object.prototype.hasOwnProperty.call(m,q.field)&&q.flex&&q.flex>0){const de=q.minWidth??150,ct=typeof q.width=="number"?q.width:150;return $+(de||ct)}const he=it(V(q));return he.type==="fixed"?$+he.value:he.type==="percentage"?$+100:$+(q.minWidth??150)},0),G=Math.max(b-O-J-ee,_),B=[],z=[],L=[];D.forEach($=>{const q=Object.prototype.hasOwnProperty.call(m,$.field),te=it(V($));if(!q&&$.flex&&$.flex>0){L.push({col:$,flex:$.flex});return}te.type==="fixed"?B.push({col:$,width:te.value}):te.type==="percentage"?z.push({col:$,percentage:te.value}):L.push({col:$,flex:1})});const X=B.reduce(($,{width:q})=>$+q,0);let H=Math.max(0,G-X);const R=new Map;z.forEach(({col:$,percentage:q})=>{const te=q/100*H;R.set($.field,te),H-=te}),H=Math.max(0,H);const re=new Map,Z=L.map($=>({...$,minWidth:$.col.minWidth??50,maxWidth:$.col.maxWidth??1/0,frozen:!1,computedWidth:0}));(()=>{let $=0;const q=Z.length*2;for(;$<q;){$++;const te=Z.filter(oe=>!oe.frozen);if(te.length===0)break;const he=te.reduce((oe,Ee)=>oe+Ee.flex,0),de=Z.reduce((oe,Ee)=>Ee.frozen?oe+Ee.computedWidth:oe,0),ct=Math.max(0,H-de);if(he<=0){te.forEach(oe=>{oe.computedWidth=oe.minWidth,oe.frozen=!0});break}const At=ct/he;let Ve=0;const ot=[],Re=[];if(te.forEach(oe=>{const Ee=At*oe.flex;Ee<oe.minWidth?(Ve+=oe.minWidth-Ee,ot.push(oe)):Ee>oe.maxWidth?(Ve+=oe.maxWidth-Ee,Re.push(oe)):oe.computedWidth=Ee}),ot.length===0&&Re.length===0){te.forEach(oe=>oe.frozen=!0);break}Ve>0?ot.forEach(oe=>{oe.computedWidth=oe.minWidth,oe.frozen=!0}):Ve<0?Re.forEach(oe=>{oe.computedWidth=oe.maxWidth,oe.frozen=!0}):(ot.forEach(oe=>{oe.computedWidth=oe.minWidth,oe.frozen=!0}),Re.forEach(oe=>{oe.computedWidth=oe.maxWidth,oe.frozen=!0}))}})(),Z.forEach($=>re.set($.col.field,$.computedWidth));const me=new Map;D.forEach($=>{let q;if(re.has($.field))q=re.get($.field);else{const te=B.find(de=>de.col.field===$.field),he=z.find(de=>de.col.field===$.field);if(te)q=te.width;else if(he){const de=R.get($.field)||0;q=Math.max($.minWidth??50,de||100)}else q=100}K.push(q),me.set($.field,q)});const U=D.map($=>{const q=Z.find(te=>te.col.field===$.field);return{...$,width:me.get($.field)??(typeof $.width=="number"?$.width:100),flex:q?q.flex:$.flex}}),pe=11,fe=Y.map(($,q)=>{const te=it(V($));return{...$,width:te.type==="fixed"?te.value:100,zIndex:pe+q}}),je=11,ge=F.map(($,q)=>{const te=it(V($));return{...$,width:te.type==="fixed"?te.value:100,zIndex:je+(F.length-1-q)}}),be=K.reduce(($,q)=>$+q,0),Ce=J+be+ee+O,Ge=K.reduce(($,q,te)=>($.push(($[te-1]||0)+q),$),[]);return{rowHeights:N,cumulativeHeights:S,unpinnedRowsHeight:M,pinnedTopHeight:C,pinnedBottomHeight:W,leftPinnedCols:fe,rightPinnedCols:ge,unpinnedColsWithWidth:U,unpinnedColWidths:K,unpinnedAccWidths:Ge,totalWidth:Ce,leftWidth:J,rightWidth:ee,unpinnedTotalWidth:be,systemColumnsWidth:O,pinnedTopRowsLength:s,pinnedBottomRowsLength:f,unpinnedRowsLength:v.length}},[o,e,r,l,a,d,s,f,c,p,m,b,x,w,h,j,P,k,E,y,g])}function Co(t){const{allRenderableRows:o,navigationColumns:e,checkboxSelection:r,selectedRowIds:l,handleSelectionChange:a,handleDetailPanelToggle:d,editingHandlers:s,setKeyboardMode:f,sortModel:c,handleSort:p,isCellEditable:m,pagination:b,pageSize:x,virtualization:w,viewportRef:h}=t,[j,P]=i.useState(null),k=i.useCallback(g=>{g.target===g.currentTarget&&P(v=>{if(v)return v;if(r)return{id:"HEADER",field:"__checkbox_col__"};const N=o[0],S=e[0];return N&&S?{id:N.id,field:S.field}:null})},[o,e,r]),E=i.useCallback(g=>{g.currentTarget.contains(g.relatedTarget)||P(null)},[]),y=i.useCallback(g=>{if(f(!0),!j)return;const{id:v,field:N}=j,S=!!s.editingCell;if(v==="HEADER"&&(g.key==="Enter"||g.key===" ")){g.preventDefault();const O=e.find(V=>V.field===N);if(O&&O.sortable!==!1){const V=c.find(ee=>ee.field===N);let J="asc";V&&(J=V.sort==="asc"?"desc":null),p(N,J)}return}if(g.key==="Enter"){if(g.preventDefault(),S)s.stopCellEdit();else if(e.find(V=>V.field===N)?.editable){const V=o.find(J=>J.id===v);V&&s.startCellEdit({id:v,field:N,value:V[N]})}return}if((g.key===" "||g.key==="Spacebar")&&!S){if(N==="__checkbox_col__"){g.preventDefault(),a(v,!l.has(v));return}if(N==="__expand_col__"){g.preventDefault(),d(v);return}}if(g.key==="Escape"){S&&(g.preventDefault(),s.stopCellEdit({cancel:!0}));return}if(S&&g.key!=="Tab")return;const I=v==="HEADER",M=I?-1:o.findIndex(O=>O.id===v),C=e.findIndex(O=>O.field===N);if(!I&&M===-1||C===-1)return;const W=(O,V,J,ee,_,G=!1)=>{let B=O+J,z=V+ee;return _&&ee!==0&&(ee>0&&z>=e.length?(z=0,B++):ee<0&&z<0&&(z=e.length-1,B--)),!_&&(z<0||z>=e.length)||B<(G?-1:0)||B>=o.length?null:{r:B,c:z}},Y=(O,V,J,ee,_,G=!1)=>{let B=O,z=V,L=0;const X=o.length*e.length+e.length;for(;L<X;){if(L++,B+=J,z+=ee,ee!==0)ee>0?z>=e.length&&(z=0,B++):z<0&&(z=e.length-1,B--);else if(z<0||z>=e.length)return null;if(B<-1||B>=o.length)return null;if(B===-1){if(!G)continue;const se=e[z],me=se.sortable!==!1;if(["__checkbox_col__"].includes(se.field)||me)return{r:B,c:z};continue}const H=o[B],R=e[z],re=["__checkbox_col__","__expand_col__","__reorder_col__"].includes(R.field);let Z=R.editable||re;if(m&&!re)try{Z=m({row:H,field:R.field,value:H[R.field],colDef:R,rowIndex:B,colIndex:z})}catch{}if(Z)return{r:B,c:z}}return null};let F=M,D=C,K=!1;if(g.key==="Tab"){const O=g.shiftKey?-1:1,V=Y(M,C,0,O,!0,!1);V&&(F=V.r,D=V.c,K=!0)}else if(g.key==="ArrowRight"){const O=W(M,C,0,1,!0,!0);O&&(F=O.r,D=O.c,K=!0)}else if(g.key==="ArrowLeft"){const O=W(M,C,0,-1,!0,!0);O&&(F=O.r,D=O.c,K=!0)}else if(g.key==="ArrowDown"){const O=W(M,C,1,0,!1,!0);O&&(F=O.r,D=O.c,K=!0)}else if(g.key==="ArrowUp"){const O=W(M,C,-1,0,!1,!0);O&&(F=O.r,D=O.c,K=!0)}else if(g.key==="Home")D=0,(g.ctrlKey||g.metaKey)&&(F=-1),K=!0;else if(g.key==="End")D=e.length-1,(g.ctrlKey||g.metaKey)&&(F=o.length-1),K=!0;else if(g.key==="PageUp")F=Math.max(-1,F-(b?x:10)),K=!0;else if(g.key==="PageDown"){const O=b?x:10;F=Math.min(o.length-1,F+O),K=!0}if(K&&(g.preventDefault(),S&&g.key==="Tab"&&s.stopCellEdit(),F>=-1&&F<o.length&&D>=0&&D<e.length)){const O=e[D];P(F===-1?{id:"HEADER",field:O.field}:{id:o[F].id,field:O.field});const V=h.current;if(V){const{cumulativeHeights:J,pinnedTopHeight:ee,columnMetrics:_}=w,{clientHeight:G,clientWidth:B,scrollTop:z,scrollLeft:L}=V,X=F<=0?0:J[F-1],H=J[F],R=z+ee,re=z+G;let Z=z;if(X<R?Z=Math.max(0,X-ee):H>re&&(Z=H-G),Z!==z&&(V.scrollTop=Z),_){const{leftPinnedWidth:se,rightPinnedWidth:me,unpinnedAccWidths:U,unpinnedCols:pe,totalSpecialsWidth:fe,pinnedSpecialsWidth:je}=_,ge=pe.findIndex(be=>be.field===O.field);if(ge!==-1){const be=fe+se+(ge>0?U[ge-1]:0),Ce=fe+se+U[ge],Ge=L+je+se,$=L+B-me;let q=L;be<Ge?q=Math.max(0,be-je-se):Ce>$&&(q=Ce-B+me),q!==L&&(V.scrollLeft=q)}}}}},[j,o,e,s,w,l,a,d,f,c,p,m,b,x,h]);return{focusedCell:j,setFocusedCell:P,handleFocus:k,handleBlur:E,handleKeyDown:y}}function yo({row:t,rowIndex:o,listViewColumn:e,isSelected:r=!1,checkboxSelection:l=!1,rowHeight:a,onRowClick:d,onSelectionChange:s}){const f={row:t,value:void 0,field:e.field,colDef:{field:e.field},rowIndex:o,colIndex:0},c=p=>{p.stopPropagation(),s?.(t.id,p.target.checked)};return n.jsxs("div",{className:`ogx-list-view__row${r?" ogx-list-view__row--selected":""}`,style:a?{minHeight:a}:void 0,onClick:()=>d?.(t),role:"row","aria-rowindex":o+2,"aria-selected":r,children:[l&&n.jsx("div",{className:"ogx-list-view__checkbox",onClick:p=>p.stopPropagation(),children:n.jsx("input",{type:"checkbox",checked:r,onChange:c,"aria-label":`Select row ${t.id}`})}),n.jsx("div",{className:"ogx-list-view__cell",role:"gridcell",children:e.renderCell(f)})]})}const kt=({indeterminate:t=!1,label:o,className:e="",inputRef:r,...l})=>{const a=i.useRef(null),d=i.useCallback(f=>{a.current=f,typeof r=="function"?r(f):r&&(r.current=f)},[r]);i.useEffect(()=>{a.current&&(a.current.indeterminate=t)},[t]);const s=["ogx-checkbox-wrapper",l.disabled&&"ogx-checkbox-wrapper--disabled",e].filter(Boolean).join(" ");return n.jsxs("label",{className:s,children:[n.jsx("input",{ref:d,type:"checkbox",className:"ogx-checkbox__input","aria-label":o||l["aria-label"]||(t?"Select some":l.checked?"Deselect":"Select"),...l}),n.jsxs("span",{className:"ogx-checkbox__box",children:[l.checked&&!t&&n.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:n.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})}),t&&n.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:n.jsx("path",{d:"M19 13H5v-2h14v2z"})})]}),o&&n.jsx("span",{className:"ogx-checkbox__label",children:o})]})};function ko(t){const{field:o,currentWidth:e,onResize:r,minWidth:l=50,maxWidth:a=1e3}=t,[d,s]=i.useState(!1),f=i.useRef(0),c=i.useRef(0),p=i.useCallback(x=>{x.preventDefault(),x.stopPropagation(),s(!0),f.current=x.clientX,c.current=e;let w=0;const h=16,j=k=>{const E=k.clientX-f.current,y=Math.max(l,Math.min(a,c.current+E)),g=Date.now();g-w>=h&&(r(o,y),w=g)},P=k=>{s(!1);const E=k.clientX-f.current,y=Math.max(l,Math.min(a,c.current+E));r(o,y),document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",P)};document.addEventListener("mousemove",j),document.addEventListener("mouseup",P)},[o,e,r,l,a]),m=i.useCallback(x=>{x.preventDefault(),x.stopPropagation()},[]),b=["ogx-column-resize-handle",d&&"ogx-column-resize-handle--dragging"].filter(Boolean).join(" ");return n.jsx("div",{className:b,onMouseDown:p,onClick:x=>x.stopPropagation(),onDragStart:x=>{x.preventDefault(),x.stopPropagation()},onDoubleClick:m,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${o} column`,children:n.jsx("div",{className:"ogx-column-resize-handle__line"})})}function lt(){return n.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"currentColor",children:n.jsx("circle",{cx:"4",cy:"4",r:"4"})})}function st(){return n.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:n.jsx("circle",{cx:"4",cy:"4",r:"3"})})}function So(){return n.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",children:[n.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),n.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.3"}),n.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),n.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),n.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function jo(){return n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),n.jsx("polyline",{points:"5 12 12 5 19 12"})]})}function Eo(){return n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),n.jsx("polyline",{points:"19 12 12 19 5 12"})]})}function No(){return n.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:n.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})}function Io(){return n.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.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"}),n.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"}),n.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function Po(){return n.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("line",{x1:"4",y1:"2",x2:"4",y2:"22"}),n.jsx("polyline",{points:"11 8 4 12 11 16"}),n.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function Mo(){return n.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("line",{x1:"20",y1:"2",x2:"20",y2:"22"}),n.jsx("polyline",{points:"13 8 20 12 13 16"}),n.jsx("line",{x1:"20",y1:"12",x2:"4",y2:"12"})]})}function To(){return n.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),n.jsx("line",{x1:"4",y1:"4",x2:"4",y2:"20"}),n.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function Lo({colDef:t,sortModel:o,onSort:e,onHide:r,onPin:l,pinnedColumns:a,onManageColumns:d,onClose:s,anchorEl:f}){const c=i.useRef(null),[p,m]=i.useState({position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"});i.useLayoutEffect(()=>{if(!f||!c.current)return;const g=f.getBoundingClientRect(),v=c.current.getBoundingClientRect(),N=window.innerWidth,S=window.innerHeight,I=8;let M=g.left;M+v.width+I>N&&(M=N-v.width-I),M<I&&(M=I);let C=g.bottom+4;C+v.height+I>S&&(C=g.top-v.height-4),m({position:"fixed",zIndex:1300,top:C,left:M,visibility:"visible"})},[f]),i.useEffect(()=>{function g(N){c.current&&!c.current.contains(N.target)&&f&&!f.contains(N.target)&&s()}function v(N){N.key==="Escape"&&s()}return document.addEventListener("mousedown",g),document.addEventListener("keydown",v),window.addEventListener("scroll",s,!0),window.addEventListener("resize",s),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",v),window.removeEventListener("scroll",s,!0),window.removeEventListener("resize",s)}},[f,s]);const b=g=>{e?.(t.field,g),s()},x=()=>{r?.(t.field),s()},w=g=>{l?.(t.field,g),s()},h=o?.find(g=>g.field===t.field)?.sort,j=h==null,P=a?.left?.includes(t.field)??!1,k=a?.right?.includes(t.field)??!1,E=!P&&!k,y=t.headerName||t.field;return nt.createPortal(n.jsxs("div",{ref:c,className:"ogx-column-menu",style:p,role:"menu","aria-label":`Column options for ${y}`,children:[e&&t.sortable!==!1&&n.jsxs(n.Fragment,{children:[n.jsxs("button",{className:`ogx-menu-item${h==="asc"?" ogx-menu-item--active":""}`,onClick:()=>b("asc"),role:"menuitemradio","aria-checked":h==="asc",children:[n.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:h==="asc"?n.jsx(lt,{}):n.jsx(st,{})}),n.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:n.jsx(jo,{})}),"Sort Ascending"]}),n.jsxs("button",{className:`ogx-menu-item${h==="desc"?" ogx-menu-item--active":""}`,onClick:()=>b("desc"),role:"menuitemradio","aria-checked":h==="desc",children:[n.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:h==="desc"?n.jsx(lt,{}):n.jsx(st,{})}),n.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:n.jsx(Eo,{})}),"Sort Descending"]}),n.jsxs("button",{className:`ogx-menu-item${j?" ogx-menu-item--active":""}`,onClick:()=>b(null),role:"menuitemradio","aria-checked":j,children:[n.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:j?n.jsx(lt,{}):n.jsx(st,{})}),n.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:n.jsx(No,{})}),"Unsort"]}),n.jsx("div",{className:"ogx-menu-divider"})]}),n.jsx("div",{className:"ogx-menu-section-label","aria-hidden":"true",children:"Pin column"}),n.jsxs("button",{className:`ogx-menu-item${P?" ogx-menu-item--active":""}`,onClick:()=>w("left"),role:"menuitemradio","aria-checked":P,"aria-label":"Pin to left",children:[n.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:P?n.jsx(lt,{}):n.jsx(st,{})}),n.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:n.jsx(Po,{})}),"Pin to Left"]}),n.jsxs("button",{className:`ogx-menu-item${k?" ogx-menu-item--active":""}`,onClick:()=>w("right"),role:"menuitemradio","aria-checked":k,"aria-label":"Pin to right",children:[n.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:k?n.jsx(lt,{}):n.jsx(st,{})}),n.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:n.jsx(Mo,{})}),"Pin to Right"]}),n.jsxs("button",{className:`ogx-menu-item${E?" ogx-menu-item--active":""}`,onClick:()=>w(null),role:"menuitemradio","aria-checked":E,"aria-label":"Unpin column",children:[n.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:E?n.jsx(lt,{}):n.jsx(st,{})}),n.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:n.jsx(To,{})}),"Unpin"]}),n.jsx("div",{className:"ogx-menu-divider"}),n.jsxs("button",{className:"ogx-menu-item",onClick:x,role:"menuitem","aria-label":`Hide ${y} column`,children:[n.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),n.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:n.jsx(Io,{})}),"Hide Column"]}),n.jsx("div",{className:"ogx-menu-divider"}),n.jsxs("button",{className:"ogx-menu-item",onClick:()=>{d?.(),s()},role:"menuitem","aria-label":"Manage all columns",children:[n.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),n.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:n.jsx(So,{})}),"Manage columns"]})]}),f?.closest(".ogx-theme-provider")||document.body)}function Ro(){return n.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"18",height:"18",children:n.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 Wo(){return n.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor",children:n.jsx("path",{d:"M6.99 11L3 15l3.99 4v-3H14v-2H6.99v-3zM21 9l-3.99-4v3H10v2h7.01v3L21 9z"})})}function Mn(t){const o=[];for(const e of t.children)typeof e=="string"?o.push(e):o.push(...Mn(e));return o}function Oo(t){let o=0;function e(r,l){o=Math.max(o,l);for(const a of r.children)typeof a!="string"&&e(a,l+1)}return t.forEach(r=>e(r,1)),o}function Fo(t,o,e){function r(s,f,c){if(!Mn(s).includes(f))return null;if(c===e)return s;for(const p of s.children)if(typeof p!="string"){const m=r(p,f,c+1);if(m)return m}return null}const l=new Map;for(const s of o){let f=null;for(const c of t)if(f=r(c,s.field,0),f)break;l.set(s.field,f)}const a=[];let d=0;for(;d<o.length;){const s=o[d],f=l.get(s.field)??null,c=s.width;if(!f)a.push({key:`fg-${s.field}-${e}`,label:"",width:c,isGroup:!1}),d++;else{let p=0,m=d;for(;m<o.length&&l.get(o[m].field)===f;)p+=o[m].width,m++;a.push({key:`${f.groupId}-${e}`,label:f.headerName,width:p,isGroup:!0}),d=m}}return a}function Tn(t){const{columns:o,allColumns:e,columnGroupingModel:r,checkboxSelection:l=!1,allSelected:a=!1,someSelected:d=!1,onSelectAll:s,onSort:f,sortModel:c=[],onColumnResize:p,columnWidths:m={},pinnedColumns:b,hasDetailPanel:x=!1,pinCheckboxColumn:w=!0,pinExpandColumn:h=!0,rowReordering:j=!1,aggregationModel:P,draggedColumn:k,dragOverColumn:E,onDragStart:y,onDragOver:g,onDragEnd:v,onDrop:N,focusedCell:S,onHeaderClick:I,onHideColumn:M,onPinColumn:C,onManageColumns:W}=t,Y=i.useRef({}),[F,D]=i.useState(null),K=R=>re=>{re.stopPropagation(),D({colDef:R,anchorEl:re.currentTarget})},O=()=>{D(null)};i.useLayoutEffect(()=>{if(S?.id==="HEADER"){const R=Y.current[S.field];R&&R.focus()}},[S]);const V=R=>()=>{if(R.sortable===!1||!f)return;const re=c.find(se=>se.field===R.field);let Z="asc";re&&(re.sort==="asc"?Z="desc":Z=null),f(R.field,Z)},J=R=>{const re=c.find(Z=>Z.field===R);return re?n.jsx("span",{className:`ogx__sort-icon ogx__sort-icon--${re.sort}`,"aria-hidden":"true"}):null},ee=i.useMemo(()=>Pn(o,m,b,l,w,x,h,j),[o,m,b,l,w,x,h,j]),_=r?Oo(r):0,B=(e??o).filter(R=>!R.isSpacer).map(R=>({field:R.field,width:m[R.field]??R.width??100})),H=(j?48:0)+(x?48:0)+(l?48:0);return n.jsxs("div",{className:"ogx__header-wrap",children:[_>0&&Array.from({length:_},(R,re)=>{const Z=Fo(r,B,re);return n.jsxs("div",{className:"ogx-col-group-row",role:"row",children:[H>0&&n.jsx("div",{className:"ogx-col-group-cell ogx-col-group-cell--filler",style:{width:H,minWidth:H,flexShrink:0},role:"columnheader"}),Z.map(se=>n.jsx("div",{role:"columnheader",className:`ogx-col-group-cell ${se.isGroup?"ogx-col-group-cell--group":"ogx-col-group-cell--filler"}`,style:{width:se.width,minWidth:se.width,flexShrink:0},title:se.isGroup?se.label:void 0,children:se.isGroup&&n.jsx("span",{className:"ogx-col-group-cell__label",children:se.label})},se.key))]},`ogx-grp-${re}`)}),n.jsxs("div",{className:"ogx__header",role:"row",children:[j&&n.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}}),x&&n.jsx("div",{className:`ogx__header-cell ogx__header-cell--expand ${h?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""}`,role:"columnheader","aria-label":"Expand row details",style:{minWidth:48,maxWidth:48,position:h?"sticky":void 0,left:h?j?48:0:void 0,zIndex:h?5:void 0}}),l&&n.jsx("div",{className:`ogx__header-cell ogx__header-cell--checkbox ${w?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""}`,role:"columnheader",style:{position:w?"sticky":void 0,left:w?(j?48:0)+(x&&h?48:0):void 0},children:n.jsx(kt,{id:"ogx-select-all",name:"ogx-select-all",checked:a,indeterminate:d,onChange:R=>s?.(R.target.checked),"aria-label":a?"Deselect all rows":"Select all rows",tabIndex:S?.id==="HEADER"&&S.field==="__checkbox_col__"?0:-1,onMouseDown:R=>R.preventDefault(),inputRef:R=>{Y.current.__checkbox_col__=R}})}),o.map((R,re)=>{if(R.isSpacer)return n.jsx("div",{style:{width:R.width,minWidth:R.width,flexShrink:0},"aria-hidden":"true"},R.field);const Z=R.sortable!==!1,se=c.some(de=>de.field===R.field),me=R.resizable!==!1,U=Ft(R.field,b),pe=U!==null,fe=k===R.field,je=E===R.field,ge=["ogx__header-cell",`ogx__header-cell--align-${R.headerAlign||R.align||"left"}`,Z&&"ogx__header-cell--sortable",se&&"ogx__header-cell--sorted",pe&&"ogx__header-cell--pinned",pe&&`ogx__header-cell--pinned-${U}`,fe&&"ogx__header-cell--dragging",je&&"ogx__header-cell--drag-over",S?.id==="HEADER"&&S.field===R.field&&"ogx__header-cell--focused",R.headerClassName].filter(Boolean).join(" "),be=m[R.field]??R.width??100,Ce={width:be,minWidth:R.minWidth,maxWidth:R.maxWidth,flexGrow:R.flex??0,flexShrink:0,flexBasis:(R.flex,"auto"),boxSizing:"border-box",position:pe?"sticky":"relative",zIndex:R.zIndex,opacity:fe?.5:1};if(pe&&U){const de=ee[R.field];U==="left"?Ce.left=de:Ce.right=de}const Ge=R.renderHeader?R.renderHeader({field:R.field,colDef:R,colIndex:re}):R.headerName||R.field,$=de=>{if(de.target.closest(".ogx-column-resize-handle")){de.stopPropagation();return}I?.(R.field),Z&&V(R)()},q=y?y(R.field):void 0,te=g?g(R.field):void 0,he=N?N(R.field):void 0;return n.jsxs("div",{className:ge,style:Ce,onClick:$,role:"columnheader",draggable:!!y,onDragStart:q,onDragOver:te,onDragEnd:v,onDrop:he,"aria-sort":Z?se?c.find(de=>de.field===R.field)?.sort==="asc"?"ascending":"descending":"none":void 0,"aria-colindex":re+1+(l?1:0),"data-field":R.field,tabIndex:-1,ref:de=>{Y.current[R.field]=de},children:[n.jsxs("div",{className:"ogx__header-cell-content",children:[fe&&n.jsx("div",{className:"ogx__header-drag-icon",children:n.jsx(Wo,{})}),n.jsxs("div",{className:"ogx__header-cell-title-wrapper",children:[n.jsx("span",{className:"ogx__header-cell-title",children:Ge}),P&&P[R.field]&&n.jsx("span",{className:"ogx__header-cell-aggregation",children:P[R.field]})]}),Z&&J(R.field),!R.disableColumnMenu&&n.jsx("button",{className:"ogx__menu-icon-btn",onClick:K(R),"aria-label":`Open column menu for ${R.headerName||R.field}`,"aria-haspopup":"menu",tabIndex:-1,children:n.jsx(Ro,{})})]}),me&&p&&n.jsx(ko,{field:R.field,currentWidth:be,onResize:p,minWidth:R.minWidth,maxWidth:R.maxWidth})]},R.field)}),F&&n.jsx(Lo,{colDef:F.colDef,sortModel:c,onSort:f,onHide:M,onPin:C,pinnedColumns:b,onManageColumns:W,onClose:O,anchorEl:F.anchorEl})]})]})}function Ao({value:t,onValueChange:o,onCommit:e,onCancel:r}){const[l,a]=i.useState(String(t??"")),d=i.useRef(null);return i.useEffect(()=>{d.current?.focus(),d.current?.select()},[]),n.jsx("input",{ref:d,type:"text",className:"ogx__edit-input",value:l,onChange:s=>{a(s.target.value),o(s.target.value)},onBlur:e,onKeyDown:s=>{s.key==="Enter"&&(s.stopPropagation(),e()),s.key==="Escape"&&(s.stopPropagation(),r())}})}function zo({value:t,onValueChange:o,onCommit:e,onCancel:r}){const[l,a]=i.useState(t??""),d=i.useRef(null);return i.useEffect(()=>{d.current?.focus(),d.current?.select()},[]),n.jsx("input",{ref:d,type:"number",className:"ogx__edit-input ogx__edit-input--number",value:l,onChange:s=>{const f=s.target.value===""?"":Number(s.target.value);a(f),o(f===""?null:f)},onBlur:e,onKeyDown:s=>{s.key==="Enter"&&(s.stopPropagation(),e()),s.key==="Escape"&&(s.stopPropagation(),r())}})}function Bo({value:t,onValueChange:o,onCommit:e,onCancel:r}){const l=i.useRef(null);i.useEffect(()=>{l.current?.focus()},[]);const a=()=>{o(!t),setTimeout(e,0)};return n.jsx("div",{className:"ogx__edit-boolean",children:n.jsx("input",{ref:l,type:"checkbox",className:"ogx__edit-checkbox",checked:!!t,onChange:a,onKeyDown:d=>{d.key==="Escape"&&(d.stopPropagation(),r())}})})}function $o({value:t,colDef:o,onValueChange:e,onCommit:r,onCancel:l}){const a=i.useRef(null);i.useEffect(()=>{a.current?.focus()},[]);const d=o.valueOptions??[];return n.jsx("select",{ref:a,className:"ogx__edit-select",value:t??"",onChange:s=>{e(s.target.value)},onBlur:r,onKeyDown:s=>{s.key==="Enter"&&(s.stopPropagation(),r()),s.key==="Escape"&&(s.stopPropagation(),l())},children:d.map(s=>{const f=typeof s=="object"?s.value:s,c=typeof s=="object"?s.label:String(s);return n.jsx("option",{value:String(f),children:c},String(f))})})}function Do({value:t,onValueChange:o,onCommit:e,onCancel:r}){const[l,a]=i.useState(t??""),d=i.useRef(null);return i.useEffect(()=>{d.current?.focus()},[]),n.jsx("input",{ref:d,type:"date",className:"ogx__edit-input",value:l,onChange:s=>{a(s.target.value),o(s.target.value)},onBlur:e,onKeyDown:s=>{s.key==="Enter"&&(s.stopPropagation(),e()),s.key==="Escape"&&(s.stopPropagation(),r())}})}function Ho(t){const{colDef:o}=t;switch(o.type){case"number":return n.jsx("div",{className:"ogx__edit-cell",children:n.jsx(zo,{...t})});case"boolean":return n.jsx("div",{className:"ogx__edit-cell",children:n.jsx(Bo,{...t})});case"singleSelect":return n.jsx("div",{className:"ogx__edit-cell",children:n.jsx($o,{...t})});case"date":return n.jsx("div",{className:"ogx__edit-cell",children:n.jsx(Do,{...t})});default:return n.jsx("div",{className:"ogx__edit-cell",children:n.jsx(Ao,{...t})})}}function Go(t){const{onCellClick:o,onCellEditStart:e,onCellValueChange:r,value:l,row:a,colDef:d,rowIndex:s,colIndex:f,isSelected:c,onClick:p,width:m,pinnedPosition:b,pinnedOffset:x,isFocused:w,isFocusVisible:h,isEditable:j,isEditing:P,onEditStart:k,onEditStop:E,onValueChange:y,colSpanInfo:g,rowSpan:v,isHiddenByRowSpan:N}=t,S=i.useCallback(_=>{r?r(d.field,_):y?.(_)},[r,y,d.field]),I=i.useMemo(()=>d.valueFormatter?d.valueFormatter({value:l,row:a,field:d.field}):l==null?"":String(l),[l,a,d]),M=i.useMemo(()=>P&&(r||y)&&E?d.renderEditCell?d.renderEditCell({value:l,row:a,field:d.field,colDef:d,rowIndex:s,colIndex:f}):n.jsx(Ho,{value:l,row:a,field:d.field,colDef:d,rowIndex:s,colIndex:f,onValueChange:S,onCommit:()=>E(),onCancel:()=>E(!0)}):d.renderCell?d.renderCell({value:l,row:a,field:d.field,colDef:d,rowIndex:s,colIndex:f}):I,[l,a,d,s,f,I,P,S,E,r,y]),C=i.useMemo(()=>d.cellClassName?typeof d.cellClassName=="function"?d.cellClassName({value:l,row:a,field:d.field,colDef:d,rowIndex:s,colIndex:f})||"":d.cellClassName:"",[d,l,a,s,f]),W=i.useRef(null);if(i.useLayoutEffect(()=>{w&&W.current&&W.current.focus({preventScroll:!0})},[w]),g?.spannedByColSpan)return null;if(N)return n.jsx("div",{className:"ogx__cell ogx__cell--hidden",style:{width:m??d.width??100},role:"presentation","data-field":d.field,"data-colindex":f});const Y=_=>{o&&(_.stopPropagation(),o({row:a,field:d.field,value:l,colDef:d,rowIndex:s,colIndex:f})),p?.(_)},F=_=>{j&&(k||e)&&(_.stopPropagation(),e?e(d.field,l):k?.())},D=b!=null,K=["ogx__cell",`ogx__cell--align-${d.align||"left"}`,c&&"ogx__cell--selected",w&&"ogx__cell--focused",w&&h&&"ogx__cell--focus-visible",d.type&&`ogx__cell--type-${d.type}`,D&&"ogx__cell--pinned",D&&`ogx__cell--pinned-${b}`,P&&"ogx__cell--editing",v&&v>1&&"ogx__cell--spanned",C].filter(Boolean).join(" "),O=g?.cellProps?.colSpan||1,V=v||1,J=g?.cellProps?.width??m??d.width??100,ee={width:"var(--width)","--width":typeof J=="number"?`${J}px`:J,flexGrow:d.flex??0,flexShrink:0,flexBasis:(d.flex,"auto"),boxSizing:"border-box",minWidth:d.minWidth,maxWidth:d.maxWidth,position:D?"sticky":void 0,zIndex:d.zIndex??(D?3:void 0),padding:P?0:void 0};return V>1&&(ee.height=`calc(var(--height) * ${V} - var(--border-width, 1px))`,ee.zIndex=10,D&&(ee.zIndex=40)),D&&x!==void 0&&(b==="left"?ee.left=x:ee.right=x),n.jsx("div",{ref:W,className:K,style:ee,onClick:Y,onDoubleClick:F,role:"gridcell","aria-colindex":f+1,"aria-readonly":!j||void 0,tabIndex:-1,"data-field":d.field,"data-colindex":f,...O>1?{"aria-colspan":O}:{},...V>1?{"aria-rowspan":V}:{},children:n.jsx("div",{className:"ogx__cell-content",children:M})})}const Ln=i.memo(Go);function Rn({isExpanded:t,onClick:o,variant:e="chevron"}){return n.jsx("button",{className:`ogx-expand-icon ${t?"ogx-expand-icon--expanded":""}`,onClick:r=>{o&&o(r)},"aria-label":t?"Collapse row":"Expand row",type:"button",children:e==="plus-minus"?n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("path",{d:"M4 8H12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),n.jsx("path",{d:"M8 4V12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:t?0:1,transition:"opacity 0.2s ease",transformOrigin:"center"}})]}):n.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{transform:t?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.2s ease"},children:n.jsx("path",{d:"M6 4L10 8L6 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}const Vo=({className:t="",...o})=>n.jsx("button",{type:"button",className:`ogx-drag-handle ${t}`,"aria-label":"Drag to reorder row",...o,children:n.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"currentColor","aria-hidden":"true",children:n.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 Uo(t){const{content:o,height:e,isExpanded:r}=t;if(!r)return null;const l={height:e==="auto"?"auto":`${e}px`,overflow:e==="auto"?"visible":"auto"};return n.jsx("div",{className:"ogx__detail-panel",style:l,children:n.jsx("div",{className:"ogx__detail-panel-content",children:o})})}function St(t){const{row:o,columns:e,rowIndex:r,isSelected:l=!1,checkboxSelection:a=!1,onRowClick:d,onCellClick:s,onSelectionChange:f,columnWidths:c={},pinnedColumns:p,pinnedRows:m,hasDetailPanel:b=!1,isDetailPanelExpanded:x=!1,onDetailPanelToggle:w,detailPanelContent:h,detailPanelHeight:j=200,pinCheckboxColumn:P=!0,pinExpandColumn:k=!0,rowReordering:E=!1,onDragStart:y,onDragOver:g,onDragEnd:v,onDrop:N,isDragging:S,isDragOver:I,editingCell:M,onEditStart:C,onEditStop:W,onEditCellValueChange:Y,focusedCellField:F,isFocusVisible:D,colspanMap:K,rowSpanningCaches:O,rowHeight:V=52}=t,J=i.useRef(null),ee=i.useRef(null);i.useLayoutEffect(()=>{F==="__expand_col__"&&J.current&&J.current.focus({preventScroll:!0}),F==="__checkbox_col__"&&ee.current&&ee.current.focus({preventScroll:!0})},[F]);const _=i.useMemo(()=>Pn(e,c,p,a,P,b,k,E),[e,c,p,a,P,b,k,E]),G=o._hasChildren===!0,B=i.useCallback((U,pe)=>{G||C?.({id:o.id,field:U,value:pe})},[G,o.id,C]),z=i.useCallback((U,pe)=>{Y?.({id:o.id,field:U,value:pe})},[Y,o.id]),L=i.useCallback(U=>{W?.({cancel:U})},[W]);if(o._isSkeleton){const U=Math.max(e.length,5);return n.jsx("div",{className:"ogx__row ogx__row--skeleton",role:"row","aria-hidden":"true",style:{height:V,minHeight:V},children:Array.from({length:U}).map((pe,fe)=>n.jsx("div",{className:"ogx__skeleton-cell",children:n.jsx("div",{className:"ogx__skeleton-bar"})},fe))})}const X=U=>{U.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell")||d?.({row:o,id:o.id,rowIndex:r})},H=U=>{U.stopPropagation(),f?.(o.id,U.target.checked)},R=U=>{U.stopPropagation(),w?.(o.id)},re=tn(o.id,m),Z=re==="top",se=re==="bottom",me=["ogx__row",l&&"ogx__row--selected",r%2===0&&"ogx__row--even",r%2===1&&"ogx__row--odd",Z&&"ogx__row--pinned-top",se&&"ogx__row--pinned-bottom",S&&"ogx__row--dragging",I&&"ogx__row--drag-over",G&&"ogx__row--group"].filter(Boolean).join(" ");return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:me,onClick:X,role:"row","aria-rowindex":r+1,"aria-selected":l,"data-rowindex":r,onDragOver:g?g(o.id):void 0,onDrop:N?N(o.id):void 0,style:{maxHeight:`${V}px`,minHeight:`${V}px`,"--height":`${V}px`,"--border-width":"1px"},children:[E&&n.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(o.id):void 0,onDragEnd:v,onClick:U=>U.stopPropagation(),children:n.jsx(Vo,{})}),b&&n.jsx("div",{className:`ogx__cell ogx__cell--expand ${k?"ogx__cell--pinned-left":""} ${F==="__expand_col__"?"ogx__cell--focused":""} ${F==="__expand_col__"&&D?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":x?"Collapse row details":"Expand row details","aria-expanded":x,style:{position:k?"sticky":void 0,left:k?E?48:0:void 0,zIndex:k?5:void 0},ref:J,tabIndex:-1,onClick:U=>{U.stopPropagation(),s?.({row:o,field:"__expand_col__",value:x,colDef:{field:"__expand_col__",width:48},rowIndex:r,colIndex:-1})},children:n.jsx(Rn,{isExpanded:x,onClick:R,variant:"plus-minus"})}),a&&n.jsx("div",{className:`ogx__cell ogx__cell--checkbox ${P?"ogx__cell--pinned-left":""} ${F==="__checkbox_col__"?"ogx__cell--focused":""} ${F==="__checkbox_col__"&&D?"ogx__cell--focus-visible":""}`,role:"gridcell",style:{position:P?"sticky":void 0,left:P?(E?48:0)+(b&&k?48:0):void 0,zIndex:P?11:void 0},ref:ee,tabIndex:-1,onClick:U=>{U.stopPropagation(),s?.({row:o,field:"__checkbox_col__",value:l,colDef:{field:"__checkbox_col__",width:48},rowIndex:r,colIndex:-1})},children:n.jsx(kt,{id:`ogx-select-row-${o.id}`,name:`ogx-select-row-${o.id}`,checked:l,onChange:H,onClick:U=>U.stopPropagation(),"aria-label":l?`Deselect row ${o.id}`:`Select row ${o.id}`,tabIndex:-1,onMouseDown:U=>U.preventDefault()})}),e.map((U,pe)=>{if(U.isSpacer)return n.jsx("div",{style:{width:U.width,minWidth:U.width,flexShrink:0},"aria-hidden":"true"},U.field);const fe=U.valueGetter?U.valueGetter({row:o,field:U.field,value:o[U.field]}):o[U.field],je=c[U.field]??U.width,ge=Ft(U.field,p),be=ge?_[U.field]:void 0,Ce=M?.id===o.id&&M?.field===U.field,Ge=Ce?M?.value:fe,$=K?.get(o.id)?.[U.field],q=O?.spannedCells[o.id]?.[U.field],te=O?.hiddenCells[o.id]?.[U.field]||!1;return n.jsx(Ln,{value:Ge,row:o,colDef:U,rowIndex:r,colIndex:pe,isSelected:l,onCellClick:s,width:je,pinnedPosition:ge,pinnedOffset:be,isFocused:F===U.field,isFocusVisible:D,isEditable:U.editable,isEditing:Ce,onCellEditStart:B,onEditStop:L,onCellValueChange:z,colSpanInfo:$,rowSpan:q,isHiddenByRowSpan:te},U.field)})]}),b&&n.jsx(Uo,{row:o,rowId:o.id,rowIndex:r,content:h,height:j,isExpanded:x})]})}const Ko=({columns:t,rowHeight:o,checkboxSelection:e=!1,hasDetailPanel:r=!1,rowReordering:l=!1})=>n.jsxs("div",{className:"ogx__row ogx__skeleton-row",style:{height:o},role:"row",children:[e&&n.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:n.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),r&&n.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:n.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),l&&n.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:n.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),t.map((a,d)=>{const s=a.width||150,f=Math.min(s*.7,s-20);return n.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:s,minWidth:a.minWidth,maxWidth:a.maxWidth,left:a.left,right:a.right,position:a.isSpacer?"relative":a.pinned?"sticky":"relative",zIndex:a.zIndex},children:!a.isSpacer&&n.jsx("div",{className:"ogx-skeleton-box",style:{width:f,height:16,borderRadius:4}})},a.field||d)})]}),jt=({variant:t="text",size:o="medium",color:e="default",disabled:r=!1,className:l="",children:a,...d})=>{const s=["ogx-button",`ogx-button--${t}`,`ogx-button--${o}`,`ogx-button--${e}`,r&&"ogx-button--disabled",l].filter(Boolean).join(" ");return n.jsx("button",{className:s,disabled:r,...d,children:a})};function Wn(t){const{page:o,pageSize:e,rowCount:r,onPageChange:l,onPageSizeChange:a,pageSizeOptions:d=[10,25,50,100],showFirstButton:s=!0,showLastButton:f=!0}=t,c=Math.max(1,Math.ceil(r/e)),p=Math.min(o,c-1),m=p*e,b=Math.min(m+e,r),x=r===0?0:`${m+1}–${b}`,w=()=>{l(0)},h=()=>{l(Math.max(0,p-1))},j=()=>{l(Math.min(c-1,p+1))},P=()=>{l(c-1)},k=g=>{const v=parseInt(g.target.value,10);a(v)},E=p===0,y=p>=c-1;return n.jsxs("div",{className:"ogx-pagination",role:"navigation","aria-label":"Pagination",children:[n.jsxs("div",{className:"ogx-pagination__page-size",children:[n.jsx("label",{htmlFor:"page-size-select",className:"ogx-pagination__label",children:"Rows per page:"}),n.jsx("select",{id:"page-size-select",className:"ogx-pagination__select",value:e,onChange:k,"aria-label":"Rows per page",children:d.map(g=>n.jsx("option",{value:g,children:g},g))})]}),n.jsxs("div",{className:"ogx-pagination__info","aria-live":"polite","aria-atomic":"true",children:[x," of ",r]}),n.jsxs("div",{className:"ogx-pagination__actions",children:[s&&n.jsx(jt,{variant:"text",size:"small",onClick:w,disabled:E,"aria-label":"Go to first page",title:"First page",children:n.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:n.jsx("path",{d:"M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"})})}),n.jsx(jt,{variant:"text",size:"small",onClick:h,disabled:E,"aria-label":"Go to previous page",title:"Previous page",children:n.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:n.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),n.jsxs("div",{className:"ogx-pagination__page-info","aria-current":"page",children:["Page ",p+1," of ",c]}),n.jsx(jt,{variant:"text",size:"small",onClick:j,disabled:y,"aria-label":"Go to next page",title:"Next page",children:n.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:n.jsx("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})})}),f&&n.jsx(jt,{variant:"text",size:"small",onClick:P,disabled:y,"aria-label":"Go to last page",title:"Last page",children:n.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:n.jsx("path",{d:"M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z"})})})]})]})}function Yo(t,o,e={}){const r=new Map,l=[];t.forEach(s=>{const f=s.id;r.set(f,s),l.push(f)});const a=new Map,d=[];return o.forEach(s=>{a.set(s.field,s),d.push(s.field)}),{rows:{idRowsLookup:r,allRows:l},columns:{all:o,lookup:a,orderedFields:d,columnVisibilityModel:e},sorting:{sortModel:[]},filter:{filterModel:{items:[]}},pagination:{paginationModel:{page:0,pageSize:100},rowCount:t.length},selection:{selectedRows:new Set},pinning:{pinnedColumns:{},pinnedRows:{}},virtualization:{renderContext:{firstRowIndex:0,lastRowIndex:0,firstColumnIndex:0,lastColumnIndex:0},scrollTop:0,scrollLeft:0},dimensions:{rowHeight:52,headerHeight:56,viewportWidth:0,viewportHeight:0},dataSource:{loading:!1,error:null}}}function Xo(t,o){switch(o.type){case"SET_ROWS":{const e=Array.from(t.rows.idRowsLookup.values()),r=typeof o.payload=="function"?o.payload(e):o.payload,l=new Map,a=[];return r.forEach(d=>{l.set(d.id,d),a.push(d.id)}),{...t,rows:{idRowsLookup:l,allRows:a},pagination:{...t.pagination,rowCount:o.preserveRowCount?t.pagination.rowCount:r.length}}}case"SET_COLUMNS":{const e=new Map,r=[];return o.payload.forEach(l=>{e.set(l.field,l),r.push(l.field)}),{...t,columns:{all:o.payload,lookup:e,orderedFields:r,columnVisibilityModel:{}}}}case"SET_SORT_MODEL":return{...t,sorting:{sortModel:o.payload}};case"SET_FILTER_MODEL":return{...t,filter:{filterModel:o.payload}};case"SET_PAGINATION_MODEL":return{...t,pagination:{...t.pagination,paginationModel:o.payload}};case"SET_SELECTION":return{...t,selection:{selectedRows:o.payload}};case"SET_SCROLL":return{...t,virtualization:{...t.virtualization,scrollTop:o.payload.scrollTop,scrollLeft:o.payload.scrollLeft}};case"SET_DIMENSIONS":return{...t,dimensions:{...t.dimensions,viewportWidth:o.payload.viewportWidth,viewportHeight:o.payload.viewportHeight}};case"SET_DATASOURCE_LOADING":return{...t,dataSource:{...t.dataSource,loading:o.payload}};case"SET_DATASOURCE_ERROR":return{...t,dataSource:{...t.dataSource,error:o.payload}};case"SET_ROW_COUNT":return{...t,pagination:{...t.pagination,rowCount:o.payload}};default:return t}}function qo(t){const{rows:o,columns:e,rowHeight:r=52,headerHeight:l=56,columnVisibilityModel:a,initialState:d}=t,s=i.useMemo(()=>Yo(o,e,a),[]),[f,c]=i.useReducer(Xo,{...s,sorting:d?.sorting||s.sorting,filter:d?.filter||s.filter,dataSource:d?.dataSource?{...s.dataSource,...d.dataSource}:s.dataSource,pagination:{...s.pagination,...d?.pagination||{},rowCount:t.rowCount??d?.pagination?.rowCount??s.pagination.rowCount},dimensions:{...s.dimensions,rowHeight:r,headerHeight:l}}),p=i.useRef(f);i.useLayoutEffect(()=>{p.current=f});const m=i.useRef(o);i.useEffect(()=>{o!==m.current&&(m.current=o,c({type:"SET_ROWS",payload:o}))},[o]);const b=i.useCallback((S,I)=>{c({type:"SET_ROWS",payload:S,preserveRowCount:I})},[]),x=i.useCallback(S=>{c({type:"SET_COLUMNS",payload:S})},[]),w=i.useCallback(S=>{c({type:"SET_SORT_MODEL",payload:S})},[]),h=i.useCallback(S=>{c({type:"SET_FILTER_MODEL",payload:S})},[]),j=i.useCallback(S=>{c({type:"SET_PAGINATION_MODEL",payload:S})},[]),P=i.useCallback(S=>{c({type:"SET_SELECTION",payload:S})},[]),k=i.useCallback((S,I)=>{c({type:"SET_SCROLL",payload:{scrollTop:S,scrollLeft:I}})},[]),E=i.useCallback((S,I)=>{c({type:"SET_DIMENSIONS",payload:{viewportWidth:S,viewportHeight:I}})},[]),y=i.useCallback(S=>{c({type:"SET_DATASOURCE_LOADING",payload:S})},[]),g=i.useCallback(S=>{c({type:"SET_DATASOURCE_ERROR",payload:S})},[]),v=i.useCallback(S=>{c({type:"SET_ROW_COUNT",payload:S})},[]),N=i.useRef({getRow:S=>p.current.rows.idRowsLookup.get(S)||null,getAllRows:()=>Array.from(p.current.rows.idRowsLookup.values()),getVisibleRows:()=>Array.from(p.current.rows.idRowsLookup.values()),getAggregationResult:()=>null,getAggregationModel:()=>null,getColumn:S=>p.current.columns.lookup.get(S)||null,getAllColumns:()=>p.current.columns.all,getVisibleColumns:()=>p.current.columns.all,selectRow:(S,I=!0)=>{const M=new Set(p.current.selection.selectedRows);I?M.add(S):M.delete(S),P(M)},selectRows:(S,I=!0)=>{const M=new Set(p.current.selection.selectedRows);S.forEach(C=>{I?M.add(C):M.delete(C)}),P(M)},getSelectedRows:()=>Array.from(p.current.selection.selectedRows),sortColumn:(S,I)=>{if(I===null)w(p.current.sorting.sortModel.filter(M=>M.field!==S));else{const M=p.current.sorting.sortModel.findIndex(C=>C.field===S);if(M>=0){const C=[...p.current.sorting.sortModel];C[M]={field:S,sort:I},w(C)}else w([...p.current.sorting.sortModel,{field:S,sort:I}])}},getSortModel:()=>p.current.sorting.sortModel,setFilterModel:h,getFilterModel:()=>p.current.filter.filterModel,setPage:S=>{j({...p.current.pagination.paginationModel,page:S})},setPageSize:S=>{j({...p.current.pagination.paginationModel,pageSize:S,page:0})},scrollToIndexes:()=>{},copySelectedRows:()=>Promise.resolve()});return{state:f,dispatch:c,apiRef:N,setRows:b,setColumns:x,setSortModel:w,setFilterModel:h,setPaginationModel:j,setSelection:P,setScroll:k,setDimensions:E,setDataSourceLoading:y,setDataSourceError:g,setRowCount:v}}function Jo(t){const{columns:o,onColumnOrderChange:e,disableColumnReorder:r=!1}=t,[l,a]=i.useState(null),[d,s]=i.useState(null),f=i.useRef(-1),c=i.useCallback(x=>w=>{if(r)return;const h=o.findIndex(P=>P.field===x);if(o[h]?.pinnable===!1){w.preventDefault();return}a(x),f.current=h,w.dataTransfer&&(w.dataTransfer.effectAllowed="move",w.dataTransfer.setData("text/plain",x))},[o,r]),p=i.useCallback(x=>w=>{r||!l||(w.preventDefault(),w.dataTransfer.dropEffect="move",s(x))},[l,r]),m=i.useCallback(x=>w=>{if(w.preventDefault(),r||!l||l===x){a(null),s(null);return}const h=o.findIndex(k=>k.field===l),j=o.findIndex(k=>k.field===x);if(h===-1||j===-1){a(null),s(null);return}const P=o[h];e&&e({column:P,oldIndex:h,targetIndex:j}),a(null),s(null),f.current=-1},[o,l,r,e]),b=i.useCallback(()=>{a(null),s(null),f.current=-1},[]);return{draggedColumn:l,dragOverColumn:d,onDragStart:r?void 0:c,onDragOver:r?void 0:p,onDragEnd:r?void 0:b,onDrop:r?void 0:m}}function Qo(t){const{onRowOrderChange:o,rows:e,getRowId:r,rowReordering:l=!1}=t,[a,d]=i.useState(null),[s,f]=i.useState(null),c=i.useCallback(w=>r?r(w):w.id,[r]),p=i.useCallback(w=>h=>{l&&(d(w),h.dataTransfer.effectAllowed="move")},[l]),m=i.useCallback(w=>h=>{!l||!a||(h.preventDefault(),h.dataTransfer.dropEffect="move",s!==w&&f(w))},[l,a,s]),b=i.useCallback(()=>{d(null),f(null)},[]),x=i.useCallback(w=>h=>{if(h.preventDefault(),!a||!o){b();return}const j=e.findIndex(k=>c(k)===a),P=e.findIndex(k=>c(k)===w);j!==-1&&P!==-1&&j!==P&&o({row:e[j],oldIndex:j,targetIndex:P}),b()},[a,o,e,c,b]);return{draggedRowId:a,dragOverRowId:s,onDragStart:l?p:void 0,onDragOver:l?m:void 0,onDragEnd:l?b:void 0,onDrop:l?x:void 0}}const Zo={contains:(t,o)=>t==null||o==null?!1:String(t).toLowerCase().includes(String(o).toLowerCase()),equals:(t,o)=>t==null&&o==null?!0:t==null||o==null?!1:String(t).toLowerCase()===String(o).toLowerCase(),startsWith:(t,o)=>t==null||o==null?!1:String(t).toLowerCase().startsWith(String(o).toLowerCase()),endsWith:(t,o)=>t==null||o==null?!1:String(t).toLowerCase().endsWith(String(o).toLowerCase()),isEmpty:t=>t==null||String(t).trim()==="",isNotEmpty:t=>t!=null&&String(t).trim()!=="",">":(t,o)=>{if(t==null||o==null)return!1;const e=Number(t),r=Number(o);return isNaN(e)||isNaN(r)?!1:e>r},">=":(t,o)=>{if(t==null||o==null)return!1;const e=Number(t),r=Number(o);return isNaN(e)||isNaN(r)?!1:e>=r},"<":(t,o)=>{if(t==null||o==null)return!1;const e=Number(t),r=Number(o);return isNaN(e)||isNaN(r)?!1:e<r},"<=":(t,o)=>{if(t==null||o==null)return!1;const e=Number(t),r=Number(o);return isNaN(e)||isNaN(r)?!1:e<=r},"!=":(t,o)=>{if(o==null||o==="")return!0;const e=Number(t),r=Number(o);return!isNaN(e)&&!isNaN(r)?e!==r:String(t).toLowerCase()!==String(o).toLowerCase()},isAnyOf:(t,o)=>t==null||!Array.isArray(o)?!1:o.some(e=>String(t).toLowerCase()===String(e).toLowerCase()),not:(t,o)=>t==null&&o==null?!1:t==null||o==null?!0:String(t).toLowerCase()!==String(o).toLowerCase(),is:(t,o)=>{if(o==null||o==="")return!0;const e=String(t).toLowerCase(),r=String(o).toLowerCase();return e===r},"=":(t,o)=>t==null||o==null||o===""?!1:Number(t)===Number(o)};function er(t,o){const{field:e,operator:r,value:l}=o,a=t[e],d=Zo[r];return d?d(a,l):(console.warn(`Unknown filter operator: ${r}`),!0)}function tr(t,o){return!o||o.length===0?!0:o.every(e=>{const r=e.toLowerCase();return Object.values(t).some(l=>l==null?!1:String(l).toLowerCase().includes(r))})}function nn(t,o){const e=o.items||[],r=o.logicOperator||"and",l=o.quickFilterValues||[];if(l.length>0&&!tr(t,l))return!1;if(e.length===0)return!0;const a=d=>{if("logicOperator"in d&&"items"in d){const s=d,f=s.items;return f.length===0?!0:s.logicOperator==="and"?f.every(a):f.some(a)}else return er(t,d)};return r==="and"?e.every(a):e.some(a)}function nr(t,o){if(!o)return t;const{items:e=[],quickFilterValues:r=[]}=o;return e.length===0&&(!r||r.length===0)?t:t.filter(l=>nn(l,o))}function or(t){switch(t){case"number":return["=","!=",">",">=","<","<=","isEmpty","isNotEmpty"];case"date":return["is","not","after","onOrAfter","before","onOrBefore","isEmpty","isNotEmpty"];case"boolean":return["is"];case"singleSelect":return["isAnyOf","is","not"];default:return["contains","equals","startsWith","endsWith","isEmpty","isNotEmpty"]}}function on(t,o,e){if(t==null&&o==null)return 0;if(t==null)return e==="asc"?1:-1;if(o==null)return e==="asc"?-1:1;if(typeof t=="number"&&typeof o=="number")return e==="asc"?t-o:o-t;if(t instanceof Date&&o instanceof Date)return e==="asc"?t.getTime()-o.getTime():o.getTime()-t.getTime();const r=String(t).toLowerCase(),l=String(o).toLowerCase();return e==="asc"?r<l?-1:r>l?1:0:r>l?-1:r<l?1:0}function rr(t,o){if(o.length===0)return t;const e=[...t];return e.sort((r,l)=>{for(const a of o){const d=r[a.field],s=l[a.field],f=on(d,s,a.sort);if(f!==0)return f}return 0}),e}function ir(t){const{rows:o,getRowId:e,getTreeDataPath:r,treeData:l=!1,defaultGroupingExpansionDepth:a=0,filterModel:d,sortModel:s,onRowExpansionChange:f}=t,{treeNodes:c,rootIds:p,groupingRows:m}=i.useMemo(()=>{if(!l||!r)return{treeNodes:new Map,rootIds:[],groupingRows:[]};const y=new Map,g=[],v=[],N=new Map,S=I=>I.join("/");return o.forEach(I=>{const M=e(I),C=r(I),W=S(C);N.set(W,M),y.set(M,{id:M,parentId:null,depth:C.length-1,groupingKey:C[C.length-1],isExpanded:!1,children:[],serverChildrenCount:I.serverChildrenCount})}),o.forEach(I=>{const M=e(I),C=r(I);if(C.length===1){g.push(M);return}const W=F=>{if(F.length<=1)return;const D=F.slice(0,-1),K=S(D);let O=N.get(K);if(O===void 0&&(O=`auto-group-${K}`,!y.has(O))){const V=D[D.length-1];y.set(O,{id:O,parentId:null,depth:D.length-1,groupingKey:V,isExpanded:!1,children:[],label:V}),N.set(K,O);const J={id:O,name:V,_isGroupRow:!0};v.push(J),D.length===1&&g.push(O),W(D)}return O},Y=W(C);if(Y!==void 0){const F=y.get(Y),D=y.get(M);F&&D&&(D.parentId=Y,F.children=F.children||[],F.children.includes(M)||F.children.push(M))}}),v.forEach(I=>{const M=I.id,C=y.get(M);if(!C)return;const Y=M.replace("auto-group-","").split("/");if(Y.length>1){const F=Y.slice(0,-1),D=S(F),K=N.get(D);if(K&&y.has(K)){C.parentId=K;const O=y.get(K);O&&(O.children=O.children||[],O.children.includes(M)||O.children.push(M))}}}),{treeNodes:y,rootIds:g,groupingRows:v}},[o,r,l,e]),b=i.useMemo(()=>{if(!l)return new Set;const y=new Set;return c.forEach(g=>{g.children&&g.children.length>0&&(a===-1||g.depth<a)&&y.add(g.id)}),y},[c,l,a]),[x,w]=i.useState(new Set);i.useEffect(()=>{b.size>0&&w(b)},[b]);const h=i.useCallback(y=>{w(g=>{const v=new Set(g),N=!v.has(y);if(v.has(y)?v.delete(y):v.add(y),N&&f){const S=c.get(y);S&&f(S)}return v})},[c,f]),j=i.useCallback(()=>{if(!l)return null;const y=new Map;o.forEach(W=>y.set(e(W),W)),m.forEach(W=>y.set(W.id,W));const g=W=>nn(W,d),v=new Map,N=W=>{if(v.has(W))return v.get(W);const Y=y.get(W);if(!Y)return!1;if(g(Y))return v.set(W,!0),!0;const D=c.get(W);return D&&D.children&&D.children.some(O=>N(O))?(v.set(W,!0),!0):(v.set(W,!1),!1)},S=(W,Y)=>{if(!s||s.length===0)return 0;const F=y.get(W),D=y.get(Y);if(!F||!D)return 0;for(const K of s){const O=F[K.field],V=D[K.field],J=on(O,V,K.sort);if(J!==0)return J}return 0},I=[],M=new Set,C=W=>{const Y=W.filter(F=>N(F));Y.sort(S),Y.forEach(F=>{if(M.has(F))return;const D=y.get(F),K=c.get(F);if(D&&K){M.add(F);const O={...D,_treeDepth:K.depth,_isExpanded:x.has(F),_hasChildren:K.children&&K.children.length>0||K.serverChildrenCount&&K.serverChildrenCount>0,_descendantCount:K.children?K.children.length:0};I.push(O),x.has(F)&&K.children&&K.children.length>0&&C(K.children)}})};return C(p),I},[l,o,m,p,c,x,d,s,e]),P=i.useCallback(y=>x.has(y),[x]),k=i.useCallback(y=>c.get(y),[c]),E=i.useCallback(y=>{const g=[];let v=y;for(;v!==null;){const N=c.get(v);if(!N)break;g.unshift(N.groupingKey),v=N.parentId}return g},[c]);return i.useMemo(()=>({treeNodes:c,groupingRows:m,toggleExpansion:h,isGroupExpanded:P,getVisibleRows:j,getNode:k,getNodePath:E}),[c,m,h,P,j,k,E])}const lr=t=>t?.depth===-1?"footer":"inline";function sr(t){const{rows:o,getRowId:e,rowGroupingModel:r=[],aggregationModel:l={},defaultGroupingExpansionDepth:a=0,filterModel:d,sortModel:s,getAggregationPosition:f=lr}=t,[c,p]=i.useState(new Set),{treeNodes:m,rootIds:b,groupingRows:x}=i.useMemo(()=>{const k=new Map,E=new Map,y=[];if(r.length===0)return{treeNodes:k,rootIds:y,groupingRows:E};const g=(S,I,M)=>`auto-group-${S}-${I}-${M||"root"}`,v=(S,I,M)=>{if(I>=r.length)return S.map(F=>{const D=e(F);return k.set(D,{id:D,parentId:M,depth:I,groupingKey:"",isExpanded:!1}),D});const C=r[I],W=new Map;S.forEach(F=>{const D=F[C],K=String(D);W.has(K)||W.set(K,[]),W.get(K).push(F)});const Y=[];return W.forEach((F,D)=>{const O=F[0][C],V=g(C,D,M);Y.push(V);const J={};l&&Object.entries(l).forEach(([z,L])=>{const X=F.map(H=>H[z]);if(L==="sum")J[z]=X.reduce((H,R)=>(Number(H)||0)+(Number(R)||0),0);else if(L==="min")J[z]=Math.min(...X.map(H=>Number(H)||0));else if(L==="max")J[z]=Math.max(...X.map(H=>Number(H)||0));else if(L==="avg"){const H=X.reduce((R,re)=>(Number(R)||0)+(Number(re)||0),0);J[z]=X.length?H/X.length:0}else L==="count"&&(J[z]=X.length)});const ee={[C]:O,...J,id:V};E.set(V,ee);const _={id:V,parentId:M,depth:I,groupingKey:D,groupingField:C,groupingValue:O,aggregatedValues:J,isExpanded:!1,children:[],label:`${C}: ${String(O)}`};_.aggregationPosition=f(_),k.set(V,_);const G=v(F,I+1,V);k.get(V).children=G;const B=F.length;k.get(V).descendantCount=B}),Y},N=v(o,0,null);return y.push(...N),{treeNodes:k,rootIds:y,groupingRows:E}},[o,r,l,e,f]);i.useEffect(()=>{if(a===-1){const k=new Set;m.forEach((E,y)=>{E.children&&E.children.length>0&&k.add(y)}),p(k)}else if(a>0){const k=new Set;m.forEach((E,y)=>{E.depth<a&&E.children&&E.children.length>0&&k.add(y)}),p(k)}else p(new Set)},[r,a]);const w=i.useCallback(k=>{p(E=>{const y=new Set(E);return y.has(k)?y.delete(k):y.add(k),y})},[]),h=i.useCallback(k=>c.has(k),[c]),j=i.useCallback(()=>{if(r.length===0)return null;const k=[],E=new Set,y=new Map;o.forEach(S=>y.set(e(S),S));const g=S=>{const I=m.get(S);if(!I)return!1;if(!I.children||I.children.length===0){const M=y.get(S);return!(!M||d&&!nn(M,d))}return I.children.some(M=>g(M))},v=S=>{let I=S;d&&(I=S.filter(g)),s&&s.length>0&&I.sort((M,C)=>{const W=x.get(M)||y.get(M),Y=x.get(C)||y.get(C);if(!W||!Y)return 0;for(const F of s){const D=W[F.field],K=Y[F.field],O=on(D,K,F.sort);if(O!==0)return O}return 0}),I.forEach(M=>{if(E.has(M))return;const C=m.get(M),W=C?.children&&C.children.length>0,Y=W?x.get(M):y.get(M);if(Y&&C){E.add(M);const F={...Y,_treeDepth:C.depth,_isExpanded:c.has(M),_hasChildren:W,_groupingField:C.groupingField,_groupingValue:C.groupingValue,_descendantCount:C.descendantCount};k.push(F),N.has(M)&&W&&v(C.children)}})},N=c;return v(b),k},[o,e,m,b,x,d,s,c]),P=i.useCallback(k=>m.get(k),[m]);return i.useMemo(()=>({treeNodes:m,groupingRows:x,toggleExpansion:w,isGroupExpanded:h,getVisibleRows:j,getNode:P}),[m,x,w,h,j,P])}function ar(t){const{rows:o,getRowId:e,processRowUpdate:r,onProcessRowUpdateError:l,onRowChange:a}=t,[d,s]=i.useState(null),f=i.useRef(null),c=i.useCallback(x=>{s(x),f.current=typeof x=="function"?x(f.current):x},[]),p=i.useCallback(x=>{c({id:x.id,field:x.field,value:x.value,originalValue:x.value})},[]),m=i.useCallback(async x=>{const w=f.current;if(!w)return;if(x?.cancel){c(null);return}const{id:h,field:j,value:P,originalValue:k}=w;if(P===k){c(null);return}const E=o.find(g=>e(g)===h);if(!E){c(null);return}const y={...E,[j]:P};try{if(r){const g=await r(y,E);a?.(g)}else a?.(y);c(null)}catch(g){l&&l(g)}},[d,o,e,r,a,l]),b=i.useCallback(x=>{d&&d.id===x.id&&d.field===x.field&&c(w=>w?{...w,value:x.value}:null)},[d]);return{editingCell:d,startCellEdit:p,stopCellEdit:m,setEditCellValue:b}}function dr(t,o,e){const[r,l]=i.useState(new Map),[a,d]=i.useState({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}}),s=i.useCallback(()=>{l(new Map)},[]),f=i.useCallback((h,j)=>r.get(h)?.[j],[r]),c=i.useCallback((h,j,P,k,E)=>{const y=new Map(r);for(let g=k;g<E;g++){const v=o[g];if(!v)continue;let N=1;if(v.colSpan)if(typeof v.colSpan=="function"){const I={row:j,value:j[v.field],field:v.field,colDef:v,rowIndex:P,colIndex:g};N=v.colSpan(I)}else N=v.colSpan;if(N<=1){at(y,h,v.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:e[v.field]||100}});continue}let S=e[v.field]||100;for(let I=1;I<N;I++)if(g+I<E){const M=o[g+I];M&&(S+=e[M.field]||100,at(y,h,M.field,{spannedByColSpan:!0,leftVisibleCellIndex:g,rightVisibleCellIndex:Math.min(g+N-1,o.length-1)}))}at(y,h,v.field,{spannedByColSpan:!1,cellProps:{colSpan:N,width:S}}),g+=N-1}l(y)},[r,o,e]),p=i.useCallback((h,j)=>{const P={},k={},E={};o.forEach((y,g)=>{if(y.rowSpan)for(let v=h;v<j;v++){const N=t[v];if(!N||k[N.id]?.[y.field])continue;const S=y.valueGetter?y.valueGetter({row:N,field:y.field,value:N[y.field]}):N[y.field];let I=1;if(typeof y.rowSpan=="function"){const M={row:N,value:S,field:y.field,colDef:y,rowIndex:v,colIndex:g};I=y.rowSpan(M)}else typeof y.rowSpan=="number"&&(I=y.rowSpan);if(I>1){P[N.id]||(P[N.id]={}),P[N.id][y.field]=I;for(let M=1;M<I;M++){const C=v+M;if(C<j&&t[C]){const W=t[C];k[W.id]||(k[W.id]={}),k[W.id][y.field]=!0,E[C]||(E[C]={}),E[C][y.field]=v}}}}}),d({caches:{spannedCells:P,hiddenCells:k,hiddenCellOriginMap:E},processedRange:{firstRowIndex:h,lastRowIndex:j}})},[t,o]),m=i.useCallback(()=>{d({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}})},[]);i.useEffect(()=>{const h=new Map;t.forEach((E,y)=>{for(let g=0;g<o.length;g++){const v=o[g];if(!v)continue;let N=1;if(v.colSpan)if(typeof v.colSpan=="function"){const I={row:E,value:E[v.field],field:v.field,colDef:v,rowIndex:y,colIndex:g};N=v.colSpan(I)}else N=v.colSpan;if(N<=1){const I=e[v.field]||(typeof v.width=="number"?v.width:100);at(h,E.id,v.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:I}});continue}let S=e[v.field]||(typeof v.width=="number"?v.width:100);for(let I=1;I<N;I++)if(g+I<o.length){const M=o[g+I];if(M){const C=e[M.field]||(typeof M.width=="number"?M.width:100);S+=C,at(h,E.id,M.field,{spannedByColSpan:!0,leftVisibleCellIndex:g,rightVisibleCellIndex:Math.min(g+N-1,o.length-1)})}}at(h,E.id,v.field,{spannedByColSpan:!1,cellProps:{colSpan:N,width:S}}),g+=N-1}}),l(h);const j={},P={},k={};o.forEach((E,y)=>{if(E.rowSpan)for(let g=0;g<t.length;g++){const v=t[g];if(!v||P[v.id]?.[E.field])continue;const N=E.valueGetter?E.valueGetter({row:v,field:E.field,value:v[E.field]}):v[E.field];let S=1;if(typeof E.rowSpan=="function"){const I={row:v,value:N,field:E.field,colDef:E,rowIndex:g,colIndex:y};S=E.rowSpan(I)}else typeof E.rowSpan=="number"&&(S=E.rowSpan);if(S>1){j[v.id]||(j[v.id]={}),j[v.id][E.field]=S;for(let I=1;I<S;I++){const M=g+I;if(M<t.length&&t[M]){const C=t[M];P[C.id]||(P[C.id]={}),P[C.id][E.field]=!0,k[M]||(k[M]={}),k[M][E.field]=g}}}}}),d({caches:{spannedCells:j,hiddenCells:P,hiddenCellOriginMap:k},processedRange:{firstRowIndex:0,lastRowIndex:t.length}})},[t,o,e]);const b=i.useCallback(()=>a.caches.spannedCells,[a]),x=i.useCallback(()=>a.caches.hiddenCells,[a]),w=i.useCallback(()=>a.caches.hiddenCellOriginMap,[a]);return{colspanMap:r,resetColSpan:s,getCellColSpanInfo:f,calculateColSpan:c,rowSpanningState:a,calculateRowSpan:p,resetRowSpan:m,getSpannedCells:b,getHiddenCells:x,getHiddenCellOriginMap:w}}function at(t,o,e,r){let l=t.get(o);l||(l={},t.set(o,l)),l[e]=r}function cr(t){const{dataSource:o,sortModel:e,filterModel:r,paginationModel:l,paginationMode:a,sortingMode:d,filterMode:s,aggregationModel:f,setRows:c,setRowCount:p,setDataSourceLoading:m,setDataSourceError:b,onAggregationResults:x}=t,w=i.useRef(null),h=i.useRef(0),j=i.useCallback(async()=>{if(!o)return;const k=++h.current;m(!0),b(null);const E=l.page*l.pageSize,y=E+l.pageSize,g={startRow:E,endRow:y,sortModel:e,filterModel:r,groupKeys:[],aggregationModel:f};try{const v=await o.getRows(g);if(k!==h.current)return;let N=!1;if(a==="infinite"){const S=w.current;if(S){const I=JSON.stringify(S.sortModel)!==JSON.stringify(e),M=JSON.stringify(S.filterModel)!==JSON.stringify(r),C=S.pageSize!==l.pageSize;!I&&!M&&!C&&l.page>S.page&&(N=!0)}}c(N?S=>[...S,...v.rows]:v.rows,!0),v.aggregationResults&&x&&x(v.aggregationResults),v.rowCount!==void 0&&p(v.rowCount),w.current={sortModel:e,filterModel:r,page:l.page,pageSize:l.pageSize}}catch(v){k===h.current&&(b(v),console.error("Data Source Error:",v))}finally{k===h.current&&m(!1)}},[o,l.page,l.pageSize,e,r,a,f,x,c,p,m,b]);i.useEffect(()=>{if(o&&(a==="server"||a==="infinite"||d==="server"||s==="server")){const E=setTimeout(()=>{j()},300);return()=>clearTimeout(E)}},[j,o,a,d,s]);const P=i.useCallback(async(k,E)=>{if(o){m(!0);try{const y=await o.getRows({startRow:0,endRow:-1,sortModel:e,filterModel:r,groupKeys:E});y.rows.length>0&&c(g=>{const v=new Set(g.map(S=>S.id)),N=y.rows.filter(S=>!v.has(S.id));return[...g,...N]})}catch(y){b(y),console.error("Failed to fetch children:",y)}finally{m(!1)}}},[o,e,r,c,m,b]);return{fetchRows:j,fetchChildren:P}}const ur={sum:t=>t.filter(e=>e!=null&&!isNaN(Number(e))).reduce((e,r)=>e+Number(r),0),avg:t=>{const o=t.filter(e=>e!=null&&!isNaN(Number(e)));return o.length===0?null:o.reduce((e,r)=>e+Number(r),0)/o.length},count:t=>t.filter(o=>o!=null).length,min:t=>{const o=t.filter(e=>e!=null&&!isNaN(Number(e))).map(Number);return o.length?Math.min(...o):null},max:t=>{const o=t.filter(e=>e!=null&&!isNaN(Number(e))).map(Number);return o.length?Math.max(...o):null},unique:t=>new Set(t.filter(o=>o!=null)).size};function qe(t,o){return t==null?"—":typeof t=="number"?o==="avg"?t.toLocaleString(void 0,{maximumFractionDigits:2}):t.toLocaleString():String(t)}function On(t){const{rows:o,aggregationModel:e,isServerSide:r,dataSource:l,filterModel:a,sortModel:d,serverAggregationResults:s}=t,f=i.useMemo(()=>{if(r||Object.keys(e).length===0)return{};const k={};for(const[E,y]of Object.entries(e)){const g=ur[y];if(!g){console.warn(`[useAggregation] Unknown aggregation function: "${y}"`);continue}const v=o.map(N=>N[E]);k[E]=g(v)}return k},[o,e,r]),[c,p]=i.useState({}),[m,b]=i.useState(!1),[x,w]=i.useState(null),h=i.useRef(0),j=i.useCallback(async()=>{if(!l?.getAggregations||Object.keys(e).length===0)return;const k=++h.current;b(!0),w(null);try{const E=await l.getAggregations({sortModel:d??[],filterModel:a??{items:[]},groupKeys:[],aggregationModel:e});k===h.current&&p(E)}catch(E){k===h.current&&(w(E),console.error("[useAggregation] Server aggregation error:",E))}finally{k===h.current&&b(!1)}},[l,e,a,d]);return i.useEffect(()=>{r&&l?.getAggregations&&!s&&j()},[j,r,l,s]),{aggregationResult:i.useMemo(()=>r?s&&Object.keys(s).length>0?s:c:f,[r,f,s,c]),isLoading:m,error:x}}function fr(t,o){const e=t.filter(r=>r!=null&&!isNaN(r));if(e.length===0)return null;switch(o){case"sum":return e.reduce((r,l)=>r+l,0);case"avg":return e.reduce((r,l)=>r+l,0)/e.length;case"count":return e.length;case"min":return Math.min(...e);case"max":return Math.max(...e)}}function rn(t,o){return o.map(e=>String(t[e]??"")).join("\0")}function Fn(t,o,e,r){return i.useMemo(()=>{const l={pivotRows:[],pivotColumns:[],colKeys:[],isValid:!1};if(!r)return l;const{rowFields:a,columnFields:d,valueFields:s}=e;if(a.length===0||s.length===0)return l;const f=new Map(o.map(j=>[j.field,j])),c=new Set;for(const j of t)c.add(rn(j,d));const p=Array.from(c).sort(),m=new Map;for(const j of t){const P=rn(j,a);if(!m.has(P)){const g={};for(const v of a)g[v]=j[v];m.set(P,{labelValues:g,bucket:new Map})}const k=m.get(P),E=rn(j,d);k.bucket.has(E)||k.bucket.set(E,new Map);const y=k.bucket.get(E);for(const g of s){const v=Number(j[g.field]);y.has(g.field)||y.set(g.field,[]),isNaN(v)||y.get(g.field).push(v)}}let b=0;const x=[];for(const[,j]of m){const P={id:b++,...j.labelValues};for(const k of p){const E=j.bucket.get(k);for(const y of s){const g=d.length>0?`${k}${y.field}${y.aggFn}`:`${y.field}${y.aggFn}`,v=E?.get(y.field)??[];P[g]=v.length>0?fr(v,y.aggFn):null}}x.push(P)}const w={id:"__pivot_grand_total__"};for(let j=0;j<a.length;j++)w[a[j]]=j===0?"Grand Total":"";for(const j of p)for(const P of s){const k=d.length>0?`${j}${P.field}${P.aggFn}`:`${P.field}${P.aggFn}`,E=x.reduce((y,g)=>{const v=g[k];return y+(v!=null&&!isNaN(Number(v))?Number(v):0)},0);w[k]=E}x.push(w);const h=[];for(const j of a){const P=f.get(j);h.push({field:j,headerName:P?.headerName??j,width:P?.width??140,sortable:!0})}for(const j of p){const P=d.length>0?j.split("\0").map((k,E)=>{const y=f.get(d[E]);return y?.headerName?`${y.headerName}: ${k}`:k}).join(" / "):"";for(const k of s){const E=f.get(k.field),y=d.length>0?`${j}${k.field}${k.aggFn}`:`${k.field}${k.aggFn}`,g=k.headerName??E?.headerName??k.field,v=P?`${P} — ${g} (${k.aggFn})`:`${g} (${k.aggFn})`;h.push({field:y,headerName:v,width:140,type:"number",align:"right",headerAlign:"right",sortable:!0,valueFormatter:({value:N})=>{if(N==null)return"—";const S=Number(N);return k.aggFn==="avg"?S.toFixed(2):k.aggFn==="count"?S.toLocaleString():E?.valueFormatter?E.valueFormatter({value:N,row:{},field:k.field}):S.toLocaleString()}})}}return{pivotRows:x,pivotColumns:h,colKeys:p,isValid:!0}},[t,o,e,r])}function gr(t){const o=document.createElement("textarea");o.value=t,o.style.cssText="position:fixed;top:-9999px;left:-9999px;opacity:0;",document.body.appendChild(o),o.focus(),o.select();let e=!1;try{e=document.execCommand("copy")}finally{document.body.removeChild(o)}return e}async function hr(t){let o=!1;try{o=gr(t)}catch{}if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")try{await navigator.clipboard.writeText(t);return}catch(e){if(o)return;throw e}else if(!o)throw new Error("Clipboard API not available and fallback failed.")}function pr(t){const{selectedRowIds:o,columns:e,getVisibleRows:r,getRowId:l}=t,a=i.useCallback(async()=>{if(o.size===0)return;const s=r().filter(b=>o.has(l(b)));if(s.length===0)return;const f=e.filter(b=>!b.field.startsWith("__")),c=f.map(b=>b.headerName||b.field).join(" "),p=s.map(b=>f.map(x=>{const w=b[x.field];return x.valueFormatter?x.valueFormatter({value:w,row:b,field:x.field}):w??""}).join(" ")).join(`
|
|
7
|
+
`),m=`${c}
|
|
8
|
+
${p}`;try{await hr(m)}catch(b){console.error("[OpenGridX] Failed to copy to clipboard:",b)}},[o,e,r,l]);return i.useEffect(()=>{const d=s=>{if(!(s.ctrlKey||s.metaKey)||s.key!=="c")return;const f=document.activeElement,c=f?.tagName.toLowerCase(),p=f?.type;c==="input"&&p!=="checkbox"&&p!=="radio"||c==="textarea"||c==="select"||f?.isContentEditable||a()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[a]),{copySelectedRows:a}}function xr(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("circle",{cx:"11",cy:"11",r:"8"}),n.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function mr(){return n.jsxs("svg",{className:"ogx-column-visibility-panel__drag-handle",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[n.jsx("circle",{cx:"9",cy:"5",r:"1.5"}),n.jsx("circle",{cx:"15",cy:"5",r:"1.5"}),n.jsx("circle",{cx:"9",cy:"12",r:"1.5"}),n.jsx("circle",{cx:"15",cy:"12",r:"1.5"}),n.jsx("circle",{cx:"9",cy:"19",r:"1.5"}),n.jsx("circle",{cx:"15",cy:"19",r:"1.5"})]})}function An(t){const{columns:o,visibleColumns:e,onVisibilityChange:r,onShowAll:l,onHideAll:a,onColumnReorder:d}=t,[s,f]=i.useState(""),[c,p]=i.useState(null),m=i.useRef(null),x=i.useMemo(()=>o.filter(g=>g.hideable!==!1),[o]).every(g=>e.has(g.field)),w=i.useMemo(()=>{if(!s)return o;const g=s.toLowerCase();return o.filter(v=>(v.headerName||v.field).toLowerCase().includes(g))},[o,s]),h=g=>{g.target.checked?l():a()},j=g=>v=>{m.current=g,v.dataTransfer.effectAllowed="move",v.dataTransfer.setDragImage(v.currentTarget.closest(".ogx-column-visibility-panel__item"),20,20)},P=g=>v=>{v.preventDefault(),v.dataTransfer.dropEffect="move",g!==m.current&&p(g)},k=()=>{p(null)},E=g=>v=>{v.preventDefault();const N=m.current;p(null),m.current=null,N&&N!==g&&d&&d(N,g)},y=()=>{p(null),m.current=null};return n.jsxs("div",{className:"ogx-column-visibility-panel",children:[n.jsx("div",{className:"ogx-column-visibility-panel__search-section",children:n.jsxs("div",{className:"ogx-column-visibility-panel__search-container",children:[n.jsx(xr,{}),n.jsx("input",{id:"ogx-column-search",name:"ogx-column-search",autoComplete:"off",className:"ogx-column-visibility-panel__search-input",placeholder:"Search",value:s,onChange:g=>f(g.target.value)})]})}),n.jsx("div",{className:"ogx-column-visibility-panel__list",children:w.map(g=>{const v=e.has(g.field),N=g.hideable!==!1,S=c===g.field,I=!!d&&!s;return n.jsxs("div",{className:["ogx-column-visibility-panel__item",!N&&"ogx-column-visibility-panel__item--disabled",S&&"ogx-column-visibility-panel__item--drag-over"].filter(Boolean).join(" "),draggable:I,onDragOver:I?P(g.field):void 0,onDragLeave:I?k:void 0,onDrop:I?E(g.field):void 0,onDragEnd:I?y:void 0,children:[I&&n.jsx("span",{className:"ogx-column-visibility-panel__drag-handle-wrapper",draggable:!0,onDragStart:j(g.field),title:"Drag to reorder",children:n.jsx(mr,{})}),n.jsxs("label",{className:"ogx-column-visibility-panel__item-label",style:{display:"flex",alignItems:"center",gap:"var(--ogx-spacing-md)",flex:1,cursor:N?"pointer":"not-allowed"},children:[n.jsx(kt,{checked:v,onChange:M=>r(g.field,M.target.checked),disabled:!N}),n.jsx("span",{className:"ogx-column-visibility-panel__label",children:g.headerName||g.field})]})]},g.field)})}),n.jsxs("div",{className:"ogx-column-visibility-panel__footer",children:[n.jsxs("label",{className:"ogx-column-visibility-panel__item",children:[n.jsx(kt,{checked:x,onChange:h}),n.jsx("span",{className:"ogx-column-visibility-panel__label",children:"Show/Hide All"})]}),n.jsx("button",{className:"ogx-column-visibility-panel__reset-btn",onClick:l,children:"Reset"})]})]})}function br(t){const{rows:o,columns:e,getRowId:r,rowHeight:l=52,headerHeight:a=56,autoHeight:d=!1,checkboxSelection:s=!1,rowSelectionModel:f,onRowSelectionModelChange:c,onRowClick:p,onCellClick:m,filterModel:b,onFilterModelChange:x,sortModel:w,onSortModelChange:h,pagination:j=!1,paginationModel:P={page:0,pageSize:100},onPaginationModelChange:k,pageSizeOptions:E=[10,25,50,100],pinnedColumns:y,onPinnedColumnsChange:g,pinnedRows:v,getDetailPanelContent:N,getDetailPanelHeight:S,detailPanelExpandedRowIds:I,onDetailPanelExpandedRowIdsChange:M,pinCheckboxColumn:C=!0,pinExpandColumn:W=!0,disableColumnReorder:Y=!1,columnOrder:F,onColumnOrderChange:D,height:K,rowReordering:O=!1,onRowOrderChange:V,loading:J=!1,treeData:ee=!1,getTreeDataPath:_,defaultGroupingExpansionDepth:G,rowGroupingModel:B,aggregationModel:z,onAggregationModelChange:L,getAggregationPosition:X,isCellEditable:H,processRowUpdate:R,onProcessRowUpdateError:re,dataSource:Z,sortingMode:se="client",filterMode:me="client",paginationMode:U="client",rowCount:pe,slots:fe,slotProps:je,pivotMode:ge=!1,pivotModel:be,onPivotModelChange:Ce,className:Ge="",style:$,onRowsScrollEnd:q,ariaLabel:te,initialState:he,onStateChange:de,columnVisibilityModel:ct,onColumnVisibilityModelChange:At,listView:Ve=!1,listViewColumn:ot,columnGroupingModel:Re,noRowsLabel:oe="No Data",apiRef:Ee}=t,ri=i.useMemo(()=>({items:[]}),[]),We=b||ri,[ii,li]=i.useState(()=>he?.sorting?.sortModel??[]),sn=w!==void 0,Ae=sn?w:ii,si=i.useMemo(()=>[],[]),an=B||si,dn=z!==void 0,Vn=i.useRef(fe?.toolbar);Vn.current=fe?.toolbar;const ai=i.useRef(u=>{const T=Vn.current;return T?T(u):null}).current,[di,ci]=i.useState(()=>z??{}),ze=dn?z:di,ui=i.useCallback(u=>{dn||ci(u),L?.(u)},[dn,L]),[fi,gi]=i.useState(()=>he?.columns?.columnVisibilityModel??{}),cn=ct!==void 0,Fe=cn?ct:fi,Nt=i.useCallback(u=>{cn||gi(u),At?.(u)},[cn,At]),[hi,pi]=i.useState(()=>he?.columns?.pinnedColumns??{}),un=y!==void 0,Ue=un?y:hi,fn=i.useCallback(u=>{un||pi(u),g?.(u)},[un,g]),xi=i.useMemo(()=>({rowFields:[],columnFields:[],valueFields:[]}),[]),[mi,bi]=i.useState(be??xi),Un=be??mi,wi=i.useCallback(u=>{bi(u),Ce?.(u)},[Ce]),zt=Fn(o,e,Un,ge),gn=ge&&zt.isValid?zt.pivotRows:o,Be=ge&&zt.isValid?zt.pivotColumns:e,[vi,Kn]=i.useState(null);i.useEffect(()=>{Kn(null)},[ze]);const[_i,Ci]=i.useState(()=>he?.pagination?.paginationModel??P),hn=t.paginationModel!==void 0,ce=hn?P:_i,Bt=i.useCallback(u=>{hn||Ci(u),k?.(u)},[hn,k]),[yi,Yn]=i.useState([]),It=f!==void 0,Xn=It?f:yi,ye=i.useMemo(()=>new Set(Xn),[Xn]),$t=c,ut=i.useRef(null),ki=i.useRef(null),Dt=i.useRef(null),Si=i.useCallback(u=>u.id,[]),Ht=r||Si,ft=i.useCallback(u=>{Qt.current?.classList.toggle("ogx--kb",u)},[]),qn=i.useRef(Z);qn.current=Z;const Jn=i.useRef(null),Qn=i.useRef(null),ji=i.useCallback(u=>{if(qn.current&&ee&&u.serverChildrenCount>0&&u.children.length===0){const T=Qn.current?.getNodePath(u.id)||[u.groupingKey];Jn.current?.(u.id,T)}},[ee]),Oe=qo({rows:gn,columns:Be,rowHeight:l,headerHeight:a,rowCount:pe,columnVisibilityModel:Fe,initialState:t.initialState}),{state:ae,apiRef:gt,setRows:pn,setColumns:Zn,setScroll:eo,setDimensions:to,setDataSourceLoading:Ei,setDataSourceError:Ni,setRowCount:Ii}=Oe;i.useEffect(()=>{Ee&&(Ee.current=gt.current)},[Ee,gt]);const{copySelectedRows:no}=pr({selectedRowIds:ye,columns:Be,getVisibleRows:()=>gt.current.getVisibleRows(),getRowId:Ht});i.useEffect(()=>{gt.current.copySelectedRows=no,gt.current.getSelectedRows=()=>Array.from(ye)},[no,ye,gt]);const Pi=ae.dataSource.loading,Pt=J||Pi,Mt=i.useMemo(()=>ae.rows.allRows.map(u=>ae.rows.idRowsLookup.get(u)),[ae.rows]),xn=ir({rows:Mt,getRowId:Ht,getTreeDataPath:_,treeData:ee,defaultGroupingExpansionDepth:G,filterModel:We,sortModel:Ae,onRowExpansionChange:ji});i.useEffect(()=>{Qn.current=xn},[xn]);const Mi=sr({rows:Mt,getRowId:Ht,rowGroupingModel:an,aggregationModel:ze,defaultGroupingExpansionDepth:G,filterModel:We,sortModel:Ae,getAggregationPosition:X}),Ke=ar({rows:Mt,getRowId:Ht,processRowUpdate:R,onProcessRowUpdateError:re,onRowChange:u=>{const{dispatch:T}=Oe,Q=Array.from(Oe.state.rows.idRowsLookup.values()).map(ne=>ne.id===u.id?u:ne);T({type:"SET_ROWS",payload:Q})}}),mn=ee,ht=!!(an&&an.length>0),Gt=mn||ht,Ne=mn?xn:ht?Mi:null,Ie=j&&!ht,Vt=i.useCallback(u=>{const{row:T,id:A}=u;if(Gt&&T._hasChildren){Ne?.toggleExpansion(A);return}p?.(u)},[Gt,Ne,p]),ve=i.useMemo(()=>Gt?Be.map((u,T)=>T===0?{...u,renderCell:A=>{const{_treeDepth:Q,_hasChildren:ne,_isExpanded:le,_groupingField:ue,_groupingValue:De,_descendantCount:Pe}=A.row,Xe=(Q||0)*24;let we=u.renderCell?u.renderCell(A):A.value;return mn&&ne&&A.row._isGroupRow&&(we=n.jsxs("div",{className:"ogx__group-cell-content",children:[A.value,Pe!==void 0&&Pe>0?` (${Pe})`:""]})),ht&&ne&&ue&&(we=n.jsxs("div",{className:"ogx__group-cell-content",children:[u.field===ue?"":`${ue}: `,String(De),Pe!==void 0?` (${Pe})`:""]})),n.jsxs("div",{style:{display:"flex",alignItems:"center",paddingLeft:Xe,width:"100%",height:"100%"},children:[n.jsx("div",{style:{marginRight:4,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",cursor:ne?"pointer":"default",flexShrink:0},children:ne?n.jsx("div",{onClick:_e=>{_e.stopPropagation(),_e.preventDefault(),Ne?.toggleExpansion(A.row.id)},onMouseDown:_e=>{_e.stopPropagation()},style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:10,position:"relative"},children:n.jsx(Rn,{isExpanded:le,onClick:_e=>{_e.stopPropagation(),_e.preventDefault(),Ne?.toggleExpansion(A.row.id)}})}):null}),n.jsx("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:we})]})}}:{...u,renderCell:A=>{const{_hasChildren:Q,_groupingField:ne}=A.row;return ht&&Q?u.field===ne?null:A.value!==void 0&&A.value!==null?u.renderCell?u.renderCell(A):A.value:null:u.renderCell?u.renderCell(A):A.value}}):Be,[Be,Gt,ht,Ne]),bn=cr({dataSource:Z,sortModel:Ae,filterModel:We,paginationModel:ce,paginationMode:U,sortingMode:se,filterMode:me,aggregationModel:ze,setRows:pn,setRowCount:Ii,setDataSourceLoading:Ei,setDataSourceError:Ni,onAggregationResults:Kn});i.useEffect(()=>{bn.fetchChildren&&(Jn.current=bn.fetchChildren)},[bn.fetchChildren]);const[Ye,Ti]=i.useState(()=>he?.columns?.columnWidths??{}),[Li,Ut]=i.useState(()=>he?.columns?.columnOrder??Be.map(u=>u.field)),Qe=F||Li;i.useEffect(()=>{Z||pn(gn)},[gn,pn,Z]),i.useEffect(()=>{Zn(Be)},[Be,Zn]),i.useEffect(()=>{ge&&Ut(Be.map(u=>u.field))},[ge,Be]);const pt=i.useMemo(()=>{if(Y)return ve;const u=new Map(Qe.map((T,A)=>[T,A]));return[...ve].sort((T,A)=>{const Q=u.get(T.field)??ve.indexOf(T),ne=u.get(A.field)??ve.indexOf(A);return Q-ne})},[ve,Qe,Y]),Ri=i.useMemo(()=>pt.filter(u=>Fe[u.field]!==!1),[pt,Fe]),xt=Jo({columns:pt,onColumnOrderChange:i.useCallback(u=>{const{oldIndex:T,targetIndex:A}=u,Q=[...Qe],[ne]=Q.splice(T,1);Q.splice(A,0,ne),F||Ut(Q),D?.(u)},[Qe,F,D]),disableColumnReorder:Y}),[Wi,Oi]=i.useState(new Set),mt=I??Wi,$e=!!N,Kt=i.useCallback(u=>{const T=new Set(mt);T.has(u)?T.delete(u):T.add(u),I===void 0&&Oi(T),M?.(T)},[mt,I,M]),oo=i.useMemo(()=>{const u=[];return O&&u.push({field:"__reorder_col__"}),$e&&u.push({field:"__expand_col__"}),s&&u.push({field:"__checkbox_col__"}),[...u,...pt]},[pt,s,$e,O]),Fi=i.useCallback((u,T)=>{Ti(A=>({...A,[u]:T}))},[]),wn=i.useRef(de);wn.current=de,i.useEffect(()=>{if(!wn.current)return;const u={sorting:{sortModel:Ae},filter:{filterModel:We},pagination:{paginationModel:ce},columns:{columnWidths:Ye,columnOrder:Qe,columnVisibilityModel:Fe,pinnedColumns:Ue}};wn.current(u)},[Ae,We,ce,Ye,Qe,Fe,Ue]);const Yt=i.useMemo(()=>Mt,[Mt]),Me=i.useMemo(()=>Ne?Ne.getVisibleRows()||[]:me==="server"&&Z?Yt:nr(Yt,We),[Yt,We,Ne,me,Z]),{top:Ze,center:bt,bottom:rt}=i.useMemo(()=>Ne?{top:[],center:Me,bottom:[]}:vo(Me,v),[Me,v,Ne]),ke=i.useMemo(()=>Ne||se==="server"&&Z?bt:rr(bt,Ae),[bt,Ae,Ne,se,Z]),et=i.useMemo(()=>{if(!Ie||U==="server"&&Z)return ke;const u=ce.page*ce.pageSize,T=u+ce.pageSize;return ke.slice(u,T)},[ke,Ie,ce.page,ce.pageSize,U,Z]);i.useEffect(()=>{Oe.apiRef.current.getVisibleRows=()=>ke,Oe.apiRef.current.getVisibleColumns=()=>ve},[ke,ve,Oe.apiRef]);const wt=Qo({rows:Ie?et:ke,getRowId:u=>u.id,onRowOrderChange:V,rowReordering:O}),Tt=i.useMemo(()=>{if(Ne)return bt;const u=Ie?et:ke,T=[...Ze,...u,...rt];if(U==="infinite"&&ae.dataSource.loading&&T.length>0){const A=Math.min(ce.pageSize,20),Q=Array.from({length:A},(ne,le)=>({id:`__skeleton_${le}__`,_isSkeleton:!0}));return[...T,...Q]}return T},[Ze,et,ke,rt,Ie,Ne,bt,U,ae.dataSource.loading,ce.pageSize]),vt=dr(Tt,oo,Ye),{aggregationResult:vn}=On({rows:Me,aggregationModel:ze,isServerSide:!!(Z&&(U==="server"||se==="server")),dataSource:Z,filterModel:We,sortModel:Ae,serverAggregationResults:vi}),Xt=Object.keys(ze).length>0;i.useEffect(()=>{Oe.apiRef.current.getAggregationResult=()=>Xt?vn:null,Oe.apiRef.current.getAggregationModel=()=>Xt?ze:null},[vn,ze,Xt,Oe.apiRef]);const Te=_o({rowHeight:l,pagination:Ie,paginatedUnpinnedRows:et,sortedUnpinnedRows:ke,expandedRowIds:mt,getDetailPanelHeight:S,pinnedTopRowsLength:Ze.length,pinnedBottomRowsLength:rt.length,visibleOrderedColumns:Ri,pinnedColumns:Ue,columnWidths:Ye,viewportWidth:ae.dimensions.viewportWidth||1e3,checkboxSelection:s,hasDetailPanel:$e,rowReordering:O,pinCheckboxColumn:C,pinExpandColumn:W,autoHeight:d,paginationMode:U,isLoading:ae.dataSource.loading,pageSize:ce.pageSize});i.useEffect(()=>{Oe.apiRef.current.scrollToIndexes=({rowIndex:u,colIndex:T})=>{const A=ut.current;if(A){if(u!==void 0&&u>=0){const Q=u>0?Te.cumulativeHeights[u-1]:0,ne=Te.cumulativeHeights[u]??Q,{scrollTop:le,clientHeight:ue}=A;Q<le?A.scrollTop=Q:ne>le+ue&&(A.scrollTop=ne-ue)}if(T!==void 0&&T>=0){const ne=[...Te.leftPinnedCols,...Te.unpinnedColsWithWidth,...Te.rightPinnedCols][T];if(!ne)return;const le=Te.unpinnedColsWithWidth.findIndex(we=>we.field===ne.field);if(le===-1)return;const ue=le>0?Te.unpinnedAccWidths[le-1]:0,De=Te.unpinnedAccWidths[le]??ue,Pe=Te.leftWidth+De,{scrollLeft:Le,clientWidth:Xe}=A;ue<Le?A.scrollLeft=ue:Pe>Le+Xe&&(A.scrollLeft=Pe-Xe)}}}},[Te,ut,Oe.apiRef]);const Se=i.useMemo(()=>{const{unpinnedAccWidths:u,unpinnedColsWithWidth:T,leftPinnedCols:A,rightPinnedCols:Q,totalWidth:ne,leftWidth:le,rightWidth:ue,unpinnedTotalWidth:De,systemColumnsWidth:Pe,cumulativeHeights:Le,pinnedTopHeight:Xe,pinnedBottomHeight:we,unpinnedRowsHeight:_e,rowHeights:Ui,unpinnedRowsLength:so}=Te,ao=ae.virtualization.scrollLeft,co=ae.virtualization.scrollTop,yn=ae.dimensions.viewportWidth||1e3,Ki=d?Xe+_e+we+50:ae.dimensions.viewportHeight||600,kn=6,Yi=Math.max(0,ao-le),Xi=ao+yn-le;let _t=0,Rt=T.length-1,Zt=0,Sn=u.length-1;for(;Zt<=Sn;){const xe=Zt+Sn>>>1;u[xe]<Yi?Zt=xe+1:Sn=xe-1}_t=Math.max(0,Zt-kn);for(let xe=_t;xe<u.length;xe++){if((xe===0?0:u[xe-1])>Xi){Rt=Math.min(T.length-1,xe+kn);break}Rt=Math.min(T.length-1,xe+kn)}const uo=_t>0?u[_t-1]:0,fo=De-u[Rt],qi=[...A,...uo>0?[{field:"__spacer_left__",width:uo,isSpacer:!0}]:[],...T.slice(_t,Rt+1),...fo>0?[{field:"__spacer_right__",width:fo,isSpacer:!0}]:[],...Q],Ji=yn>0&&ne>yn?16:0,Qi=Xe+_e+we+Ji+2,go=5;let Wt=0,ho=so-1,po=0,en=0,jn=Le.length-1;for(;en<=jn;){const xe=en+jn>>>1;Le[xe]<co?en=xe+1:jn=xe-1}Wt=Math.max(0,en-go),po=Wt>0?Le[Wt-1]:0;for(let xe=Wt;xe<Le.length;xe++)if(Le[xe]>=co+Ki){ho=Math.min(so-1,xe+go);break}return{renderContext:{firstRowIndex:Wt,lastRowIndex:ho,firstColumnIndex:_t,lastColumnIndex:Rt},offsetTop:po,offsetLeft:0,totalHeight:Qi,pinnedTopHeight:Xe,pinnedBottomHeight:we,totalWidth:ne,rowHeights:Ui,cumulativeHeights:Le,virtualColumns:qi,columnMetrics:{leftPinnedWidth:le,rightPinnedWidth:ue,unpinnedAccWidths:u,unpinnedCols:T,totalSpecialsWidth:Pe,pinnedSpecialsWidth:(O?48:0)+($e&&W?48:0)+(s&&C?48:0)}}},[Te,ae.virtualization.scrollTop,ae.virtualization.scrollLeft,ae.dimensions.viewportHeight,ae.dimensions.viewportWidth,d]),Ai=i.useCallback(u=>{const T=u.currentTarget;if(eo(T.scrollTop,T.scrollLeft),q){const{scrollTop:A,scrollHeight:Q,clientHeight:ne}=T;Q-A-ne<100&&q({visibleTop:A,visibleBottom:A+ne,viewportHeight:ne})}},[eo,q]);i.useEffect(()=>{if(!ut.current)return;const u=new ResizeObserver(T=>{for(const A of T){const{width:Q,height:ne}=A.contentRect;to(Q,ne)}});return u.observe(ut.current),()=>{u.disconnect()}},[to]);const Lt=i.useCallback((u,T)=>{const A=new Set(ye);T?A.add(u):A.delete(u);const Q=Array.from(A);It||Yn(Q),$t?.(Q)},[ye,It,$t]),zi=i.useCallback(u=>{let T=[];u&&(T=Yt.map(A=>A.id)),It||Yn(T),$t?.(T)},[o,It,$t]),ro=i.useCallback((u,T)=>{const A=T?[{field:u,sort:T}]:[];sn||li(A),h?.(A)},[sn,h]),{focusedCell:tt,setFocusedCell:_n,handleFocus:Bi,handleBlur:$i,handleKeyDown:Di}=Co({allRenderableRows:Tt,navigationColumns:oo,checkboxSelection:s,selectedRowIds:ye,handleSelectionChange:Lt,handleDetailPanelToggle:Kt,editingHandlers:Ke,setKeyboardMode:ft,sortModel:Ae,handleSort:ro,isCellEditable:H,pagination:Ie,pageSize:ce.pageSize,virtualization:Se,viewportRef:ut}),Cn=i.useCallback(u=>{ft(!1),_n({id:u.row.id,field:u.field}),Dt.current?.focus({preventScroll:!0}),m?.(u)},[m,ft,_n]),io=i.useRef(Ke.editingCell);i.useEffect(()=>{const u=!!io.current,T=!!Ke.editingCell;u&&!T&&Dt.current?.focus({preventScroll:!0}),io.current=Ke.editingCell},[Ke.editingCell]);const lo=i.useMemo(()=>{const{firstRowIndex:u,lastRowIndex:T}=Se.renderContext,A=Ze.length,Q=Ze.map((we,_e)=>({row:we,rowIndex:_e})),ne=rt.map((we,_e)=>({row:we,rowIndex:A+(Ie?et.length:ke.length)+_e})),le=Math.max(0,u-A),ue=Math.min(Ie?et.length:ke.length,T-A+1),De=(Ie?et:ke).slice(le,ue).map((we,_e)=>({row:we,rowIndex:A+le+_e})),Pe=[...Q,...De,...ne],Le=new Set;return Pe.filter(we=>Le.has(we.row.id)?!1:(Le.add(we.row.id),!0))},[Se.renderContext,Ze,rt,et,ke,Ie,U,ae.dataSource.loading,ce.pageSize,l]),Hi=o.length>0&&ye.size===o.length,Gi=ye.size>0&&ye.size<o.length,Vi=i.useMemo(()=>ve.some(u=>!!u.rowSpan),[ve]),[qt,Jt]=i.useState(!1),Qt=i.useRef(null);return i.useEffect(()=>{if(!qt||fe?.toolbar)return;function u(T){const A=document.getElementById("ogx-standalone-col-panel");A&&!A.contains(T.target)&&Jt(!1)}return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[qt,fe?.toolbar]),n.jsxs("div",{ref:Qt,className:["ogx",Ge,d&&"ogx--auto-height",Vi&&"ogx--row-spanning",Ve&&"ogx--list-view"].filter(Boolean).join(" "),style:{...$,height:K??$?.height,"--ogx-row-height":`${l}px`,"--ogx-header-height":`${a}px`},"aria-busy":Pt,children:[fe?.toolbar&&(()=>{const u={apiRef:Oe.apiRef,columns:ve,baseColumns:e,aggregationModel:ze,onAggregationModelChange:ui,...ge||be||Ce?{pivotModel:Un,onPivotModelChange:wi}:{},filterModel:We,onFilterModelChange:x,columnVisibilityModel:Fe,onColumnVisibilityModelChange:Nt,onColumnReorder:Y?void 0:(T,A)=>{const Q=[...Qe],ne=Q.indexOf(T),le=Q.indexOf(A);if(ne===-1||le===-1)return;const ue=[...Q];ue.splice(ne,1),ue.splice(le,0,T),F||Ut(ue);const De=ve.find(Pe=>Pe.field===T);De&&D?.({oldIndex:ne,targetIndex:le,column:De})},forceColumnsOpen:qt,onColumnsPanelClose:()=>Jt(!1),...je?.toolbar};return n.jsx(ai,{...u})})(),!fe?.toolbar&&qt&&nt.createPortal(n.jsxs("div",{id:"ogx-standalone-col-panel",style:(()=>{const u=Qt.current?.getBoundingClientRect();return{position:"fixed",top:u?u.top+8:16,right:u?window.innerWidth-u.right+8:16,zIndex:9999,display:"inline-block"}})(),children:[n.jsx("button",{onClick:()=>Jt(!1),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:"×"}),n.jsx(An,{columns:ve,visibleColumns:new Set(ve.filter(u=>Fe[u.field]!==!1).map(u=>u.field)),onVisibilityChange:(u,T)=>{Nt({...Fe,[u]:T})},onShowAll:()=>{const u={...Fe};ve.forEach(T=>{T.hideable!==!1&&(u[T.field]=!0)}),Nt(u)},onHideAll:()=>{const u={...Fe};ve.forEach(T=>{T.hideable!==!1&&(u[T.field]=!1)}),Nt(u)},onColumnReorder:Y?void 0:(u,T)=>{const A=[...Qe],Q=A.indexOf(u),ne=A.indexOf(T);if(Q===-1||ne===-1)return;const le=[...A];le.splice(Q,1),le.splice(ne,0,u),F||Ut(le),D?.({oldIndex:Q,targetIndex:ne,column:ve.find(ue=>ue.field===u)})}})]}),Qt.current?.closest(".ogx-theme-provider")||document.body),Ve&&ot&&n.jsxs("div",{className:"ogx-list-view",role:"grid","aria-label":te||"Data grid list view","aria-rowcount":Tt.length+1,children:[n.jsx("div",{className:"ogx-list-view__toolbar",children:n.jsxs("span",{children:[Me.length," ",Me.length===1?"item":"items",Ie?` · page ${ce.page+1} of ${Math.ceil(Me.length/ce.pageSize)||1}`:"",ye.size>0?` · ${ye.size} selected`:""]})}),n.jsx("div",{className:"ogx-list-view__rows",children:Tt.length===0?n.jsxs("div",{className:"ogx-list-view__empty","aria-live":"polite",role:"status",children:[n.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[n.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),n.jsx("path",{d:"M3 9h18M9 21V9"})]}),oe]}):Tt.map((u,T)=>n.jsx(yo,{row:u,rowIndex:T,listViewColumn:ot,isSelected:ye.has(u.id),checkboxSelection:s,rowHeight:l,onRowClick:A=>Vt({row:A,id:A.id,rowIndex:T}),onSelectionChange:Lt},u.id))}),Ie&&(()=>{const u=fe?.pagination||Wn,T=U==="server"&&Z?ae.pagination.rowCount||0:Me.length,A={page:ce.page,pageSize:ce.pageSize,rowCount:T,pageSizeOptions:E,onPageChange:Q=>Bt({...ce,page:Q}),onPageSizeChange:Q=>Bt({...ce,pageSize:Q,page:0}),...je?.pagination};return n.jsx(u,{...A})})()]}),!Ve&&n.jsx("div",{ref:u=>{ut.current=u,Dt.current=u},className:"ogx__viewport",onScroll:Ai,role:"grid","aria-label":te||"Data grid","aria-rowcount":Me.length+1,"aria-colcount":e.length+(s?1:0)+($e?1:0)+(O?1:0),"aria-busy":Pt,tabIndex:0,onKeyDownCapture:()=>{ft(!0)},onMouseDownCapture:()=>{ft(!1)},onKeyDown:Di,onFocus:Bi,onBlur:$i,children:n.jsxs("div",{ref:ki,className:"ogx__content",style:{width:Se.totalWidth},role:"presentation",children:[n.jsx(Tn,{columns:Se.virtualColumns,allColumns:ve,columnGroupingModel:Re,checkboxSelection:s,allSelected:Hi,someSelected:Gi,onSelectAll:zi,sortModel:Ae,onSort:ro,onColumnResize:Fi,columnWidths:Ye,pinnedColumns:Ue,focusedCell:tt,onHeaderClick:u=>{_n({id:"HEADER",field:u}),ft(!1),Dt.current?.focus({preventScroll:!0})},onDragStart:Re?void 0:xt.onDragStart,onDragOver:Re?void 0:xt.onDragOver,onDragEnd:Re?void 0:xt.onDragEnd,onDrop:Re?void 0:xt.onDrop,draggedColumn:Re?void 0:xt.draggedColumn,dragOverColumn:Re?void 0:xt.dragOverColumn,rowReordering:O,hasDetailPanel:$e,pinCheckboxColumn:C,pinExpandColumn:W,aggregationModel:ze,onHideColumn:u=>{Nt({...Fe,[u]:!1})},onManageColumns:()=>Jt(!0),onPinColumn:(u,T)=>{const A=[...Ue?.left??[]],Q=[...Ue?.right??[]],ne=A.filter(ue=>ue!==u),le=Q.filter(ue=>ue!==u);fn(T==="left"?{left:[...ne,u],right:le}:T==="right"?{left:ne,right:[...le,u]}:{left:ne,right:le})}}),!Pt&&!ae.dataSource.error&&Me.length===0&&n.jsxs("div",{className:"ogx__empty",style:{width:Se.totalWidth},children:[n.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[n.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),n.jsx("path",{d:"M3 9h18M9 21V9"})]}),n.jsx("span",{children:oe})]}),Ze.length>0&&n.jsx("div",{className:"ogx__pinned-rows ogx__pinned-rows--top",role:"rowgroup",children:Ze.map((u,T)=>n.jsx(St,{row:u,columns:Se.virtualColumns,rowIndex:T,isSelected:ye.has(u.id),checkboxSelection:s,onRowClick:Vt,onCellClick:Cn,onSelectionChange:Lt,columnWidths:Ye,pinnedColumns:Ue,pinnedRows:v,hasDetailPanel:$e,isDetailPanelExpanded:mt.has(u.id),detailPanelContent:N?N({row:u,id:u.id,rowIndex:T}):null,detailPanelHeight:S?.({row:u,id:u.id,rowIndex:T})||200,onDetailPanelToggle:Kt,pinCheckboxColumn:C,pinExpandColumn:W,focusedCellField:tt?.id===u.id?tt.field:null,colspanMap:vt.colspanMap,rowSpanningCaches:vt.rowSpanningState.caches,rowHeight:l},u.id))}),n.jsx("div",{className:"ogx__virtual-container",style:{height:`${Se.totalHeight-Se.pinnedTopHeight-Se.pinnedBottomHeight}px`},role:"presentation",children:n.jsxs("div",{className:"ogx__rows",style:{transform:`translateY(${Se.renderContext.firstRowIndex*l}px)`},role:"rowgroup",children:[Pt&&lo.length===0?(()=>{const u=e.length>0?e:(()=>{const T=(ae.dimensions.viewportWidth||1e3)-(s?48:0)-(N?48:0)-(O?48:0),A=150,Q=Math.max(1,Math.ceil(T/A));return Array.from({length:Q},(ne,le)=>({field:`placeholder_${le}`,headerName:"",width:A}))})();return Array.from({length:10}).map((T,A)=>n.jsx(Ko,{columns:u,rowHeight:l,checkboxSelection:s,hasDetailPanel:!!N,rowReordering:O},`skeleton-${A}`))})():lo.filter(({row:u})=>!tn(u.id,v)).filter((u,T,A)=>T===A.findIndex(Q=>Q.row.id===u.row.id)).map(({row:u,rowIndex:T})=>n.jsx(St,{row:u,columns:Se.virtualColumns,rowIndex:T,isSelected:ye.has(u.id),checkboxSelection:s,onRowClick:Vt,onCellClick:Cn,onSelectionChange:Lt,columnWidths:Ye,pinnedColumns:Ue,pinnedRows:v,hasDetailPanel:$e,isDetailPanelExpanded:mt.has(u.id),detailPanelContent:N?N({row:u,id:u.id,rowIndex:T}):null,detailPanelHeight:S?.({row:u,id:u.id,rowIndex:T})||200,onDetailPanelToggle:Kt,pinCheckboxColumn:C,pinExpandColumn:W,rowReordering:O,onDragStart:wt.onDragStart,onDragOver:wt.onDragOver,onDragEnd:wt.onDragEnd,onDrop:wt.onDrop,isDragging:wt.draggedRowId===u.id,isDragOver:wt.dragOverRowId===u.id,editingCell:Ke.editingCell,onEditStart:Ke.startCellEdit,onEditStop:Ke.stopCellEdit,onEditCellValueChange:Ke.setEditCellValue,focusedCellField:tt!=null&&tt.id===u.id?tt.field:null,colspanMap:vt.colspanMap,rowSpanningCaches:vt.rowSpanningState.caches,rowHeight:l},`${u.id}-${Se.totalWidth}`)),U==="infinite"&&ae.dataSource.loading&&ke.length>0&&(()=>{const u=Math.min(ce.pageSize,20),T=Te.unpinnedRowsLength;return n.jsx("div",{className:"ogx__skeleton-group",children:Array.from({length:u}).map((A,Q)=>n.jsx(St,{row:{id:`__skeleton_${Q}__`,_isSkeleton:!0},columns:Se.virtualColumns,rowIndex:T+Q,rowHeight:l},`__skeleton_${Q}__`))})})()]})}),rt.length>0&&n.jsx("div",{className:"ogx__pinned-rows ogx__pinned-rows--bottom",role:"rowgroup",children:rt.map((u,T)=>n.jsx(St,{row:u,columns:Se.virtualColumns,rowIndex:T,isSelected:ye.has(u.id),checkboxSelection:s,onRowClick:Vt,onCellClick:Cn,onSelectionChange:Lt,columnWidths:Ye,pinnedColumns:Ue,pinnedRows:v,hasDetailPanel:$e,isDetailPanelExpanded:mt.has(u.id),detailPanelContent:N?N({row:u,id:u.id,rowIndex:T}):null,detailPanelHeight:S?.({row:u,id:u.id,rowIndex:T})||200,onDetailPanelToggle:Kt,pinCheckboxColumn:C,pinExpandColumn:W,focusedCellField:tt?.id===u.id?tt.field:null,colspanMap:vt.colspanMap,rowSpanningCaches:vt.rowSpanningState.caches,rowHeight:l},u.id))}),Xt&&!ge&&n.jsxs("div",{className:"ogx__aggregation-footer",role:"row","aria-label":"Aggregation totals","aria-live":"polite",style:{minHeight:`${l}px`},children:[s&&n.jsx("div",{style:{width:48,flexShrink:0}}),$e&&n.jsx("div",{style:{width:48,flexShrink:0}}),O&&n.jsx("div",{style:{width:48,flexShrink:0}}),pt.map(u=>{const T=ze[u.field],A=vn[u.field],Q=Ye[u.field]??(typeof u.width=="number"?u.width:120);return n.jsx("div",{className:"ogx__aggregation-cell",role:"gridcell",style:{width:Q,minWidth:Q,maxWidth:Q,textAlign:u.align||"left"},children:T?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"ogx__aggregation-label",children:T}),n.jsx("span",{className:"ogx__aggregation-value",children:qe(A,T)})]}):null},u.field)})]})]})}),!Ve&&Ie&&(()=>{const u=fe?.pagination||Wn,T={page:ce.page,pageSize:ce.pageSize,rowCount:ae.pagination.rowCount,pageSizeOptions:E,onPageChange:A=>Bt({...ce,page:A}),onPageSizeChange:A=>Bt({...ce,pageSize:A,page:0}),...je?.pagination};return n.jsx(u,{...T})})(),n.jsxs("div",{className:"ogx-aria-live-status",role:"status","aria-live":"polite",children:[Pt?"Loading data...":"",ae.dataSource.error?`Error: ${ae.dataSource.error.message||"Unknown error"}`:"",!J&&!ae.dataSource.error&&(Me.length===0?oe:We&&((We.quickFilterValues?.length||0)>0||(We.items?.length||0)>0)?`${Me.length} ${Me.length===1?"row":"rows"} found`:"")]}),ae.dataSource.error&&n.jsxs("div",{className:"ogx-error-overlay","aria-live":"assertive",role:"alert",children:[n.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:[n.jsx("circle",{cx:"12",cy:"12",r:"10"}),n.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),n.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),n.jsx("div",{className:"ogx-error-overlay__title",children:"Oops! Something went wrong"}),n.jsx("div",{className:"ogx-error-overlay__message",children:ae.dataSource.error.message||"An unexpected error occurred while loading the data."}),n.jsx("button",{onClick:()=>window.location.reload(),className:"ogx-button ogx-button--primary",children:"Retry"})]})]})}function wr({rows:t=5,columns:o=5}){return n.jsx("div",{className:"ogx__skeleton",children:Array.from({length:t}).map((e,r)=>n.jsx("div",{className:"ogx__skeleton-row",children:Array.from({length:o}).map((l,a)=>n.jsx("div",{className:"ogx__skeleton-cell",children:n.jsx("div",{className:"ogx__skeleton-content"})},a))},r))})}const zn=new Set(["isEmpty","isNotEmpty"]);function vr(t,o){return t.find(e=>"field"in e&&e.field===o)}const _r=({col:t,item:o,onChange:e})=>{const r=or(t.type),l=!!o,a=o?.operator??r[0],[d,s]=i.useState(o?.value??""),f=i.useRef(e);f.current=e;const c=i.useRef(o?.value);i.useEffect(()=>{o?.value!==c.current&&(c.current=o?.value,s(o?.value??""))},[o?.value]),i.useEffect(()=>{const h=setTimeout(()=>{const j=o?.value??"";d!==j&&f.current({id:o?.id??`${t.field}-${Date.now()}`,field:t.field,operator:a,value:d})},300);return()=>clearTimeout(h)},[d]);const p=h=>{const j=zn.has(h),P={id:o?.id??`${t.field}-${Date.now()}`,field:t.field,operator:h,value:j?void 0:o?.value??(t.type==="boolean"?"true":"")};e(P)},m=()=>{s(""),e(null)},b=zn.has(String(a)),x=t.type==="boolean",w=!b;return n.jsxs("div",{className:`ogx-filter__row${l?" ogx-filter__row--active":""}`,children:[n.jsx("span",{className:"ogx-filter__col-label",title:t.field,children:t.headerName||t.field}),n.jsxs("div",{className:"ogx-filter__controls",children:[n.jsx("select",{id:`ogx-filter-op-${t.field}`,name:`filter-op-${t.field}`,className:`ogx-filter__op-select${l?" ogx-filter__op-select--active":""}`,value:String(a),onChange:h=>p(h.target.value),"aria-label":`Filter operator for ${t.headerName||t.field}`,children:r.map(h=>n.jsx("option",{value:h,children:h},h))}),w&&x&&n.jsxs("select",{id:`ogx-filter-val-${t.field}`,name:`filter-val-${t.field}`,className:`ogx-filter__value-input ogx-filter__value-select${l?" ogx-filter__value-input--active":""}`,value:String(o?.value??"true"),onChange:h=>{s(h.target.value),e({id:o?.id??`${t.field}-${Date.now()}`,field:t.field,operator:a,value:h.target.value})},"aria-label":`Filter value for ${t.headerName||t.field}`,children:[n.jsx("option",{value:"true",children:"true"}),n.jsx("option",{value:"false",children:"false"})]}),w&&!x&&n.jsx("input",{id:`ogx-filter-val-${t.field}`,name:`filter-val-${t.field}`,className:`ogx-filter__value-input${l?" ogx-filter__value-input--active":""}`,type:"text",value:d,onChange:h=>s(h.target.value),placeholder:t.type==="number"?"Number…":"Value…","aria-label":`Filter value for ${t.headerName||t.field}`}),l&&n.jsx("button",{className:"ogx-filter__row-clear",onClick:m,"aria-label":`Clear filter for ${t.headerName||t.field}`,title:"Clear",children:"×"})]})]})},Bn=({filterModel:t,columns:o,onFilterModelChange:e})=>{const r=t.items??[],l=t.logicOperator??"and",a=i.useCallback((f,c)=>{const p=r.filter(b=>"field"in b&&b.field!==f),m=c?[...p,c]:p;e({...t,items:m})},[r,t,e]),d=i.useCallback(f=>{e({...t,logicOperator:f})},[t,e]),s=o.filter(f=>f.filterable!==!1);return n.jsxs(n.Fragment,{children:[r.length>1&&n.jsxs("div",{className:"ogx-filter__logic-bar",children:[n.jsx("span",{className:"ogx-filter__logic-label",children:"Match:"}),n.jsx("button",{className:`ogx-filter__logic-pill${l==="and"?" ogx-filter__logic-pill--active":""}`,onClick:()=>d("and"),"aria-pressed":l==="and",children:"ALL (AND)"}),n.jsx("button",{className:`ogx-filter__logic-pill${l==="or"?" ogx-filter__logic-pill--active":""}`,onClick:()=>d("or"),"aria-pressed":l==="or",children:"ANY (OR)"})]}),s.length===0?n.jsx("div",{className:"ogx-filter__empty",children:"No filterable columns."}):s.map(f=>n.jsx(_r,{col:f,item:vr(r,f.field),onChange:c=>a(f.field,c)},f.field))]})},Cr=["sum","avg","count","min","max"];function $n(){return n.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:[n.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),n.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),n.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),n.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1",fill:"currentColor",opacity:"0.25"}),n.jsx("path",{d:"M17 14v-4M17 10l-2 2 2 2"})]})}function yr({anchorRef:t,columns:o,model:e,onChange:r,onClose:l}){const a=i.useRef(null),[d,s]=i.useState({top:0,right:0}),[f,c]=i.useState(document.body);i.useLayoutEffect(()=>{c(t.current?.closest(".ogx-theme-provider")??document.body)},[t]);const p=i.useCallback(()=>{if(!t.current)return{top:0,right:0};const C=t.current.getBoundingClientRect();return{top:C.bottom+6,right:window.innerWidth-C.right}},[t]);i.useEffect(()=>{s(p());const C=()=>s(p());return window.addEventListener("scroll",C,!0),window.addEventListener("resize",C),()=>{window.removeEventListener("scroll",C,!0),window.removeEventListener("resize",C)}},[p]),i.useEffect(()=>{function C(Y){a.current&&!a.current.contains(Y.target)&&t.current&&!t.current.contains(Y.target)&&l()}function W(Y){Y.key==="Escape"&&l()}return document.addEventListener("mousedown",C),document.addEventListener("keydown",W),()=>{document.removeEventListener("mousedown",C),document.removeEventListener("keydown",W)}},[t,l]);const m=new Set(e.rowFields),b=new Set(e.columnFields),x=new Set(e.valueFields.map(C=>C.field)),w=C=>m.has(C)||b.has(C)||x.has(C);function h(C){m.has(C)||r({...e,rowFields:[...e.rowFields,C]})}function j(C){b.has(C)||r({...e,columnFields:[...e.columnFields,C]})}function P(C,W="sum"){x.has(C)||r({...e,valueFields:[...e.valueFields,{field:C,aggFn:W}]})}function k(C){r({...e,rowFields:e.rowFields.filter(W=>W!==C)})}function E(C){r({...e,columnFields:e.columnFields.filter(W=>W!==C)})}function y(C){r({...e,valueFields:e.valueFields.filter(W=>W.field!==C)})}function g(C,W){r({...e,valueFields:e.valueFields.map(Y=>Y.field===C?{...Y,aggFn:W}:Y)})}function v(){r({rowFields:[],columnFields:[],valueFields:[]})}const N=new Set(o.filter(C=>C.type==="number"||C.aggregable).map(C=>C.field)),S=e.rowFields.length+e.columnFields.length+e.valueFields.length,I=C=>o.find(W=>W.field===C)?.headerName??C,M=n.jsxs("div",{ref:a,className:"ogx-pivot-panel",role:"dialog","aria-label":"Pivot configuration",style:{top:d.top,right:d.right},children:[n.jsxs("div",{className:"ogx-pivot-panel__header",children:[n.jsxs("span",{className:"ogx-pivot-panel__title",children:[n.jsx($n,{}),"Pivot Mode"]}),S>0&&n.jsx("button",{className:"ogx-pivot-panel__reset-btn",onClick:v,title:"Reset pivot",children:"Reset"})]}),n.jsxs("div",{className:"ogx-pivot-panel__body",children:[n.jsxs("div",{className:"ogx-pivot-zone",children:[n.jsxs("span",{className:"ogx-pivot-zone__label",children:[n.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--row"}),"Row Fields"]}),n.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=>n.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--row",children:[I(C),n.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>k(C),title:`Remove ${I(C)}`,children:"×"})]},C))})]}),n.jsxs("div",{className:"ogx-pivot-zone",children:[n.jsxs("span",{className:"ogx-pivot-zone__label",children:[n.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--col"}),"Column Fields"]}),n.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=>n.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--col",children:[I(C),n.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>E(C),title:`Remove ${I(C)}`,children:"×"})]},C))})]}),n.jsxs("div",{className:"ogx-pivot-zone",children:[n.jsxs("span",{className:"ogx-pivot-zone__label",children:[n.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--value"}),"Value Fields (aggregated)"]}),n.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=>n.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--value",children:[I(C.field),n.jsx("select",{className:"ogx-pivot-chip__fn-select",value:C.aggFn,onChange:W=>g(C.field,W.target.value),title:"Aggregation function",children:Cr.map(W=>n.jsx("option",{value:W,children:W.toUpperCase()},W))}),n.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>y(C.field),title:`Remove ${I(C.field)}`,children:"×"})]},C.field))})]}),n.jsx("hr",{className:"ogx-pivot-panel__divider"}),n.jsxs("div",{children:[n.jsx("div",{className:"ogx-pivot-panel__fields-label",children:"Available Fields"}),n.jsxs("div",{className:"ogx-pivot-fields",children:[o.map(C=>{const W=N.has(C.field);return w(C.field)?null:n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3},children:[n.jsx("span",{className:`ogx-pivot-field-btn${W?" ogx-pivot-field-btn--numeric":""}`,children:C.headerName??C.field}),n.jsxs("div",{className:"ogx-pivot-field-actions",children:[n.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--row",onClick:()=>h(C.field),title:"Add to Row Fields",children:"Row"}),n.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--col",onClick:()=>j(C.field),title:"Add to Column Fields",children:"Col"}),W&&n.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--value",onClick:()=>P(C.field),title:"Add to Value Fields",children:"Val"})]})]},C.field)}),o.every(C=>w(C.field))&&n.jsx("span",{style:{fontSize:12,color:"var(--ogx-color-gray-400, #94a3b8)"},children:"All fields are in use."})]})]})]})]});return nt.createPortal(M,f)}function kr(){return n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("circle",{cx:"11",cy:"11",r:"8"}),n.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function Sr(){return n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function jr({value:t="",onChange:o,placeholder:e="Search...",debounceMs:r=250}){const[l,a]=i.useState(()=>t.length>0),[d,s]=i.useState(t),f=i.useRef(null),c=i.useRef(null),p=i.useRef(o);i.useLayoutEffect(()=>{p.current=o},[o]);const m=i.useRef(t),b=i.useRef(t),x=i.useRef(!1);i.useLayoutEffect(()=>{x.current&&document.activeElement!==f.current&&f.current?.focus()}),i.useEffect(()=>{t!==b.current&&(b.current=t,t!==m.current&&(s(t),m.current=t,t?a(!0):(x.current=!1,a(!1))))},[t]),i.useEffect(()=>{const k=setTimeout(()=>{d!==m.current&&(m.current=d,p.current(d))},r);return()=>clearTimeout(k)},[d,r]);const w=i.useCallback(()=>{a(!0),requestAnimationFrame(()=>f.current?.focus())},[]),h=i.useCallback(k=>{k.stopPropagation(),s(""),m.current="",p.current(""),f.current?.focus()},[]),j=i.useCallback(()=>{x.current=!0,a(!0)},[]),P=i.useCallback(()=>{x.current=!1,setTimeout(()=>{if(c.current&&document.activeElement&&c.current.contains(document.activeElement)){x.current=!0;return}d||a(!1)},150)},[d]);return i.useEffect(()=>{const k=E=>{c.current&&!c.current.contains(E.target)&&(d||a(!1))};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[d]),n.jsxs("div",{ref:c,className:`ogx-global-search${l?" ogx-global-search--expanded":""}`,onClick:l?void 0:w,children:[n.jsx("div",{className:"ogx-global-search__icon-wrapper",children:n.jsx(kr,{})}),n.jsx("input",{ref:f,id:"ogx-global-search-input",name:"ogx-global-search",className:"ogx-global-search__input",value:d,onChange:k=>s(k.target.value),onFocus:j,onBlur:P,placeholder:e,"aria-label":"Global Search",autoComplete:"off"}),d&&n.jsx("button",{className:"ogx-global-search__clear",onClick:h,"aria-label":"Clear search",children:n.jsx(Sr,{})})]})}function Et({title:t,children:o,placement:e="top",enterDelay:r=200,leaveDelay:l=0}){const[a,d]=i.useState(!1),[s,f]=i.useState({top:0,left:0}),c=i.useRef(null),p=i.useRef(null),m=i.useCallback(()=>{if(!p.current)return;const h=p.current.getBoundingClientRect();let j=0,P=0;const k=window.pageXOffset||document.documentElement.scrollLeft,E=window.pageYOffset||document.documentElement.scrollTop;e==="top"?(j=h.top+E-8,P=h.left+k+h.width/2):e==="bottom"&&(j=h.bottom+E+8,P=h.left+k+h.width/2),f({top:j,left:P})},[e]);i.useLayoutEffect(()=>(a&&(m(),window.addEventListener("scroll",m,!0),window.addEventListener("resize",m)),()=>{window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m)}),[a,m]);const b=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{d(!0)},r)},x=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{d(!1)},l)},w=i.useCallback(h=>{p.current=h?h.firstElementChild??h:null},[]);return n.jsxs(n.Fragment,{children:[n.jsx("span",{ref:w,style:{display:"inline-block",lineHeight:0},onMouseEnter:b,onMouseLeave:x,children:o}),a&&t&&nt.createPortal(n.jsx("div",{className:`ogx-tooltip ogx-tooltip--${e}`,style:{top:s.top,left:s.left,position:"absolute",zIndex:99999},children:t}),document.body)]})}const Er=["none","sum","avg","count","min","max"];function Dn(){return n.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:n.jsx("path",{d:"M18 4H6l6 8-6 8h12"})})}function Nr(){return n.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",children:[n.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),n.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.25"}),n.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),n.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),n.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),n.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function Hn(){return n.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})})}function Ir({anchorRef:t,aggregationModel:o,aggregableColumns:e,onFunctionChange:r,onClearAll:l,onClose:a,activeCount:d}){const s=i.useRef(null),[f,c]=i.useState({top:0,right:0}),[p,m]=i.useState(document.body);i.useLayoutEffect(()=>{m(t.current?.closest(".ogx-theme-provider")??document.body)},[t]);const b=i.useCallback(()=>{if(!t.current)return{top:0,right:0};const w=t.current.getBoundingClientRect();return{top:w.bottom+6,right:window.innerWidth-w.right}},[t]);i.useEffect(()=>{c(b());const w=()=>c(b());return window.addEventListener("scroll",w,!0),window.addEventListener("resize",w),()=>{window.removeEventListener("scroll",w,!0),window.removeEventListener("resize",w)}},[b]),i.useEffect(()=>{function w(h){s.current&&!s.current.contains(h.target)&&t.current&&!t.current.contains(h.target)&&a()}return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[t,a]),i.useEffect(()=>{function w(h){h.key==="Escape"&&a()}return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[a]);const x=n.jsxs("div",{ref:s,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Summaries configuration",style:{top:f.top,right:f.right,width:400,maxWidth:"calc(100vw - 24px)"},children:[n.jsxs("div",{className:"ogx-toolbar__panel-header",children:[n.jsxs("span",{className:"ogx-toolbar__panel-title",children:[n.jsx(Dn,{}),"Summaries"]}),d>0&&n.jsx("button",{className:"ogx-toolbar__clear-btn",onClick:l,title:"Clear all summaries",children:"Clear all"})]}),n.jsx("div",{className:"ogx-toolbar__panel-body",children:e.length===0?n.jsxs("p",{className:"ogx-toolbar__empty",children:["No aggregable columns.",n.jsx("br",{}),"Set ",n.jsx("code",{children:"aggregable: true"})," on a column to enable."]}):e.map(w=>{const h=o[w.field]||"none";return n.jsxs("div",{className:"ogx-toolbar__agg-row",children:[n.jsx("span",{className:"ogx-toolbar__agg-label",title:w.field,children:w.headerName||w.field}),n.jsx("div",{className:"ogx-toolbar__agg-pills",children:Er.map(j=>n.jsx("button",{className:`ogx-toolbar__pill${h===j?" ogx-toolbar__pill--active":""}`,onClick:()=>r(w.field,j),"aria-pressed":h===j,children:j},j))})]},w.field)})})]});return nt.createPortal(x,p)}function Pr({anchorRef:t,columns:o,visibleColumns:e,onVisibilityChange:r,onShowAll:l,onHideAll:a,onColumnReorder:d,onClose:s}){const f=i.useRef(null),[c,p]=i.useState({top:0,right:0}),[m,b]=i.useState(document.body);i.useLayoutEffect(()=>{b(t.current?.closest(".ogx-theme-provider")??document.body)},[t]);const x=i.useCallback(()=>{if(!t.current)return{top:0,right:0};const h=t.current.getBoundingClientRect();return{top:h.bottom+6,right:window.innerWidth-h.right}},[t]);i.useEffect(()=>{p(x());const h=()=>p(x());return window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}},[x]),i.useEffect(()=>{function h(j){f.current&&!f.current.contains(j.target)&&t.current&&!t.current.contains(j.target)&&s()}return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[t,s]);const w=n.jsx("div",{ref:f,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Column visibility",style:{top:c.top,right:c.right,width:280,padding:0},children:n.jsx(An,{columns:o,visibleColumns:e,onVisibilityChange:r,onShowAll:l,onHideAll:a,onColumnReorder:d})});return nt.createPortal(w,m)}function Mr({anchorRef:t,columns:o,filterModel:e,onFilterModelChange:r,onClose:l}){const a=i.useRef(null),[d,s]=i.useState({top:0,right:0}),f=i.useRef(l);i.useLayoutEffect(()=>{f.current=l},[l]);const[c,p]=i.useState(document.body);i.useLayoutEffect(()=>{p(t.current?.closest(".ogx-theme-provider")??document.body)},[t]);const m=i.useCallback(()=>{if(!t.current)return{top:0,right:0};const h=t.current.getBoundingClientRect();return{top:h.bottom+6,right:window.innerWidth-h.right}},[t]);i.useEffect(()=>{s(m());const h=()=>s(m());return window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}},[m]),i.useEffect(()=>{function h(j){j.key==="Escape"&&f.current()}return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[]);const b=e.items?.length??0,x=()=>{r({...e,items:[],logicOperator:"and"})},w=n.jsxs("div",{ref:a,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:[n.jsxs("div",{className:"ogx-toolbar__panel-header",children:[n.jsxs("span",{className:"ogx-toolbar__panel-title",children:[n.jsx(Hn,{}),"Filters",b>0&&n.jsx("span",{className:"ogx-toolbar__panel-count",children:b})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[b>0&&n.jsx("button",{className:"ogx-toolbar__clear-btn",onClick:x,title:"Clear all filters",children:"Clear all"}),n.jsx("button",{className:"ogx-toolbar__close-btn",onClick:()=>f.current(),title:"Close filters","aria-label":"Close filters panel",children:"Close"})]})]}),n.jsx("div",{className:"ogx-toolbar__panel-body ogx-toolbar__panel-body--filter",children:n.jsx(Bn,{columns:o,filterModel:e,onFilterModelChange:r})})]});return nt.createPortal(w,c)}const Tr={rowFields:[],columnFields:[],valueFields:[]};function Lr({columns:t=[],baseColumns:o,aggregationModel:e={},onAggregationModelChange:r,pivotModel:l,onPivotModelChange:a,filterModel:d,onFilterModelChange:s,columnVisibilityModel:f={},onColumnVisibilityModelChange:c,onColumnReorder:p,forceColumnsOpen:m,onColumnsPanelClose:b,children:x,rightContent:w,style:h}){const[j,P]=i.useState(!1),[k,E]=i.useState(!1),[y,g]=i.useState(!1),[v,N]=i.useState(!1);i.useEffect(()=>{m&&(g(!0),P(!1),E(!1),N(!1))},[m]);const S=i.useRef(null),I=i.useRef(null),M=i.useRef(null),C=i.useRef(null),W=l??Tr,Y=W.rowFields.length>0||W.columnFields.length>0||W.valueFields.length>0,F=t.filter(L=>L.aggregable!==!1&&(L.type==="number"||L.aggregable===!0)),D=Object.keys(e).filter(L=>e[L]&&e[L]!=="none").length,K=i.useCallback((L,X)=>{if(!r)return;const H={...e};X==="none"?delete H[L]:H[L]=X,r(H)},[e,r]),O=i.useCallback(()=>{r?.({})},[r]),V=i.useCallback(L=>{if(!s)return;const H={...d||{},quickFilterValues:L?[L]:[],items:d?.items||[]};s(H)},[d,s]),J=d?.quickFilterValues?.[0]||"",ee=d?.items?.length||0,_=new Set(t.filter(L=>f[L.field]!==!1).map(L=>L.field)),G=i.useCallback((L,X)=>{if(!c)return;const H={...f,[L]:X};c(H)},[f,c]),B=i.useCallback(()=>{if(!c)return;const L={...f};t.forEach(X=>{X.hideable!==!1&&(L[X.field]=!0)}),c(L)},[t,f,c]),z=i.useCallback(()=>{if(!c)return;const L={...f};t.forEach(X=>{X.hideable!==!1&&(L[X.field]=!1)}),c(L)},[t,f,c]);return n.jsxs("div",{className:"ogx-toolbar",role:"toolbar","aria-label":"Grid toolbar",style:h,children:[x&&n.jsx("div",{className:"ogx-toolbar__left",children:x}),n.jsx("div",{className:"ogx-toolbar__spacer"}),n.jsxs("div",{className:"ogx-toolbar__actions",children:[s&&n.jsx("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:n.jsx(jr,{value:J,onChange:V,placeholder:"Search..."})}),c&&n.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[n.jsx(Et,{title:"Columns",children:n.jsx("button",{ref:M,className:`ogx-toolbar__icon-btn${y?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Manage columns",onClick:()=>{g(!y),P(!1),E(!1),N(!1)},children:n.jsx(Nr,{})})}),y&&n.jsx(Pr,{anchorRef:M,columns:t,visibleColumns:_,onVisibilityChange:G,onShowAll:B,onHideAll:z,onColumnReorder:p,onClose:()=>{g(!1),b?.()}})]}),s&&n.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[n.jsx(Et,{title:"Filters",children:n.jsxs("button",{ref:C,className:`ogx-toolbar__icon-btn${v?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Advanced filters",onClick:()=>{N(!v),P(!1),E(!1),g(!1)},children:[n.jsx(Hn,{}),ee>0&&n.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Filters active"})]})}),v&&n.jsx(Mr,{anchorRef:C,columns:t,filterModel:d||{items:[]},onFilterModelChange:s,onClose:()=>N(!1)})]}),a&&n.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[n.jsx(Et,{title:"Pivot",children:n.jsxs("button",{ref:I,id:"ogx-pivot-btn",className:`ogx-toolbar__icon-btn${k?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure pivot","aria-expanded":k,"aria-controls":"ogx-pivot-panel",onClick:()=>{E(!k),P(!1),g(!1),N(!1)},children:[n.jsx($n,{}),Y&&n.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Pivot active"})]})}),k&&n.jsx(yr,{anchorRef:I,columns:o??t,model:W,onChange:L=>{a?.(L)},onClose:()=>E(!1)})]}),n.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[n.jsx(Et,{title:"Summaries",children:n.jsxs("button",{ref:S,id:"ogx-aggregation-btn",className:`ogx-toolbar__icon-btn${j?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure summaries","aria-expanded":j,"aria-controls":"ogx-aggregation-panel",onClick:()=>{P(!j),E(!1),g(!1),N(!1)},children:[n.jsx(Dn,{}),D>0&&n.jsx("span",{className:"ogx-toolbar__dot","aria-label":`${D} active summaries`})]})}),j&&n.jsx(Ir,{anchorRef:S,aggregationModel:e,aggregableColumns:F,onFunctionChange:K,onClearAll:O,onClose:()=>P(!1),activeCount:D})]}),w]})]})}function Rr(){return i.useRef(null)}const Wr=({fullWidth:t=!1,error:o=!1,startAdornment:e,endAdornment:r,className:l="",...a})=>{const d=["ogx-input-wrapper",t&&"ogx-input-wrapper--full-width",o&&"ogx-input-wrapper--error",a.disabled&&"ogx-input-wrapper--disabled",l].filter(Boolean).join(" ");return n.jsxs("div",{className:d,children:[e&&n.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--start",children:e}),n.jsx("input",{className:"ogx-input",...a}),r&&n.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--end",children:r})]})};function Or(t,o,e={}){const{fileName:r="export.csv",includeHeaders:l=!0,delimiter:a=",",selectedRows:d}=e,s=d&&d.length>0?t.filter(p=>d.includes(p.id)):t;if(s.length===0){console.warn("No rows to export");return}const f=o.filter(p=>!(p.exportable===!1||p.field==="__check__"||p.field==="__actions__"));let c="";if(l){const p=f.map(m=>dt(m.headerName||m.field));c+=p.join(a)+`
|
|
9
|
+
`}if(s.forEach(p=>{const m=f.map(b=>{let x=p[b.field];return b.valueGetter&&(x=b.valueGetter({row:p,field:b.field,value:x})),b.valueFormatter&&x!==void 0&&x!==null&&(x=b.valueFormatter({value:x,row:p,field:b.field})),dt(String(x??""))});c+=m.join(a)+`
|
|
10
|
+
`}),e.aggregationResult){const p=e.aggregationResult,m=e.aggregationModel||{},b=f.map(w=>m[w.field]?dt(m[w.field].toUpperCase()):dt(""));c+=b.join(a)+`
|
|
11
|
+
`;const x=f.map(w=>{const h=p[w.field];if(h!=null){let j=h;return w.valueFormatter?j=w.valueFormatter({value:h,row:{},field:w.field}):m[w.field]&&(j=qe(h,m[w.field])),dt(String(j))}return dt("")});c+=x.join(a)+`
|
|
12
|
+
`}ln(c,r,"text/csv;charset=utf-8;")}function dt(t){return t.includes(",")||t.includes('"')||t.includes(`
|
|
13
|
+
`)?`"${t.replace(/"/g,'""')}"`:t}function Fr(t,o,e={}){const{fileName:r="export.xls",sheetName:l="Sheet1",includeHeaders:a=!0,selectedRows:d}=e,s=d&&d.length>0?t.filter(p=>d.includes(p.id)):t;if(s.length===0){console.warn("No rows to export");return}const f=o.filter(p=>!(p.exportable===!1||p.field==="__check__"||p.field==="__actions__"));let c='<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">';if(c+="<head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>",c+=`<x:Name>${l}</x:Name>`,c+="<x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]-->",c+='<meta charset="UTF-8"></head><body>',c+='<table border="1">',a&&(c+="<thead><tr>",f.forEach(p=>{c+=`<th>${He(p.headerName||p.field)}</th>`}),c+="</tr></thead>"),c+="<tbody>",s.forEach(p=>{c+="<tr>",f.forEach(m=>{let b=p[m.field];m.valueGetter&&(b=m.valueGetter({row:p,field:m.field,value:b})),m.valueFormatter&&b!==void 0&&b!==null&&(b=m.valueFormatter({value:b,row:p,field:m.field})),c+=`<td>${He(String(b??""))}</td>`})}),e.aggregationResult){const p=e.aggregationResult,m=e.aggregationModel||{};c+='<tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',f.forEach(b=>{m[b.field]?c+=`<td style="text-align: right; font-weight: bold;">${He(m[b.field].toUpperCase())}</td>`:c+="<td></td>"}),c+="</tr>",c+='<tr style="font-weight: bold; background-color: #f5f5f5;">',f.forEach(b=>{const x=p[b.field];if(x!=null){let w=x;b.valueFormatter?w=b.valueFormatter({value:x,row:{},field:b.field}):m[b.field]&&(w=qe(x,m[b.field])),c+=`<td style="text-align: right;">${He(String(w))}</td>`}else c+="<td></td>"}),c+="</tr>"}c+="</tbody></table></body></html>",ln(c,r,"application/vnd.ms-excel")}function He(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Ar(t,o,e={}){const{fileName:r="export.json",pretty:l=!0,selectedRows:a}=e,d=a&&a.length>0?t.filter(m=>a.includes(m.id)):t;if(d.length===0){console.warn("No rows to export");return}const s=o.filter(m=>!(m.exportable===!1||m.field==="__check__"||m.field==="__actions__")),f=d.map(m=>{const b={};return s.forEach(x=>{let w=m[x.field];x.valueGetter&&(w=x.valueGetter({row:m,field:x.field,value:w})),b[x.field]=w}),b});let c=f;if(e.aggregationResult){const m=e.aggregationResult,b=e.aggregationModel||{},x={};s.forEach(h=>{b[h.field]&&(x[h.field]=b[h.field].toUpperCase())});const w={};s.forEach(h=>{if(m[h.field]!==void 0&&m[h.field]!==null){let j=m[h.field];h.valueFormatter?j=h.valueFormatter({value:j,row:{},field:h.field}):b[h.field]&&(j=qe(j,b[h.field])),w[h.field]=j}}),c={data:f,aggregation:{labels:x,values:w}}}const p=l?JSON.stringify(c,null,2):JSON.stringify(c);ln(p,r,"application/json;charset=utf-8;")}async function zr(t,o,e){const r=window.open("","_blank");if(!r){console.error("Failed to open print window. Please check your popup blocker settings.");return}r.document.write(`
|
|
14
14
|
<!DOCTYPE html>
|
|
15
15
|
<html>
|
|
16
16
|
<head>
|
|
@@ -30,7 +30,7 @@ ${h}`;try{await Tr(m)}catch(p){console.error("[OpenGridX] Failed to copy to clip
|
|
|
30
30
|
</div>
|
|
31
31
|
</body>
|
|
32
32
|
</html>
|
|
33
|
-
`),r.document.close(),await new Promise(l=>setTimeout(l,100));try{let l="Print",a,d=null,s=null;typeof e=="string"?l=e:typeof e=="object"&&(l=e.title||"Print",a=e.selectedRows,d=e.aggregationResult||null,s=e.aggregationModel||null);const
|
|
33
|
+
`),r.document.close(),await new Promise(l=>setTimeout(l,100));try{let l="Print",a,d=null,s=null;typeof e=="string"?l=e:typeof e=="object"&&(l=e.title||"Print",a=e.selectedRows,d=e.aggregationResult||null,s=e.aggregationModel||null);const f=a&&a.length>0?t.filter(b=>a.includes(b.id)):t;if(f.length===0){r.document.body.innerHTML="<h3>No rows to export</h3>";return}const c=o.filter(b=>!(b.exportable===!1||b.field==="__check__"||b.field==="__actions__"));let p=`
|
|
34
34
|
<!DOCTYPE html>
|
|
35
35
|
<html>
|
|
36
36
|
<head>
|
|
@@ -49,5 +49,5 @@ ${h}`;try{await Tr(m)}catch(p){console.error("[OpenGridX] Failed to copy to clip
|
|
|
49
49
|
</style>
|
|
50
50
|
</head>
|
|
51
51
|
<body>
|
|
52
|
-
`;if(l&&(h+=`<h1>${ut(l)}</h1>`),h+="<table>",h+="<thead><tr>",u.forEach(p=>{h+=`<th>${ut(p.headerName||p.field)}</th>`}),h+="</tr></thead>",h+="<tbody>",g.forEach(p=>{h+="<tr>",u.forEach(f=>{let C=p[f.field];f.valueGetter&&(C=f.valueGetter({row:p,field:f.field,value:C})),f.valueFormatter&&C!==void 0&&C!==null&&(C=f.valueFormatter({value:C,row:p,field:f.field})),f.type==="image"&&C?h+=`<td><div style="display:flex;justify-content:center;"><img src="${C}" alt="${f.headerName}" style="max-height: 40px; border-radius: 4px;"></div></td>`:h+=`<td>${ut(String(C??""))}</td>`}),h+="</tr>"}),d){const p=s||{};h+='<tfoot><tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',u.forEach(f=>{p[f.field]?h+=`<td style="text-align: right; font-weight: bold;">${ut(p[f.field].toUpperCase())}</td>`:h+="<td></td>"}),h+='</tr><tr style="font-weight: bold; background-color: #f5f5f5;">',u.forEach(f=>{const C=d[f.field];if(C!=null){let b=C;f.valueFormatter?b=f.valueFormatter({value:C,row:{},field:f.field}):p[f.field]&&(b=bt(C,p[f.field])),h+=`<td style="text-align: right;">${ut(String(b))}</td>`}else h+="<td></td>"}),h+="</tr></tfoot>"}h+="</tbody></table></body></html>",r.document.open(),r.document.write(h),r.document.close(),r.document.title=l||"Print Preview",r.focus();let m=!1;r.onload=()=>{m||(m=!0,r.print(),setTimeout(()=>{r.close()},100))},setTimeout(()=>{!m&&r&&!r.closed&&(m=!0,r.print(),setTimeout(()=>{r.closed||r.close()},100))},500)}catch(l){console.error("Print generation failed:",l),r&&!r.closed&&(r.document.body.innerHTML=`<div style="color: red; padding: 20px;"><h3>Error Generating Print Preview</h3><p>${l.message}</p></div>`)}}function Pn(n,o,e){const r=new Blob([n],{type:e}),l=URL.createObjectURL(r),a=document.createElement("a");a.href=l,a.download=o,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(l)}function ri(n,o){return n.type==="number"?"number":n.type==="boolean"?"boolean":n.type==="date"?"date":typeof o=="number"?"number":typeof o=="boolean"?"boolean":o instanceof Date?"date":"string"}function ii(n){if(n.type==="number")return"#,##0.##";if(n.type==="date")return"yyyy-mm-dd"}function li(n,o){if(o!=null)return o;const e=n.width??120;return Math.min(60,Math.max(8,(e-5)/7))}function si(n,o){const e=o??"";if(e.includes("jpeg")||e.includes("jpg"))return"jpeg";if(e.includes("gif"))return"gif";const r=n.split("?")[0].toLowerCase();return r.endsWith(".jpg")||r.endsWith(".jpeg")?"jpeg":r.endsWith(".gif")?"gif":"png"}async function ai(n){const o=await Promise.allSettled(n.map(async r=>{if(r.startsWith("data:")){const s=r.indexOf(","),g=r.slice(0,s),u=r.slice(s+1),h=atob(u),m=new Uint8Array(h.length);for(let b=0;b<h.length;b++)m[b]=h.charCodeAt(b);const f=g.match(/data:([^;,]+)/)?.[1]??"image/png";let C="png";return f.includes("jpeg")||f.includes("jpg")?C="jpeg":f.includes("gif")&&(C="gif"),{url:r,buffer:m.buffer,ext:C}}const l=await fetch(r,{mode:"cors"});if(!l.ok)throw new Error(`HTTP ${l.status}`);const a=await l.arrayBuffer(),d=si(r,l.headers.get("content-type"));return{url:r,buffer:a,ext:d}})),e=new Map;return o.forEach((r,l)=>{r.status==="fulfilled"?e.set(r.value.url,{buffer:r.value.buffer,extension:r.value.ext}):console.warn(`[exportToExcelAdvanced] Cannot embed image "${n[l]}" (CORS/network error — raw URL written as fallback):`,r.reason)}),e}async function di(n,o,e={}){const{fileName:r="export.xlsx",sheets:l,columnStyles:a={},headerFillColor:d="#f1f5f9",headerTextColor:s="#334155",headerFontSize:g=10,bodyFontSize:u=10,aggregationResult:h=null,aggregationModel:m=null,selectedRows:p}=e,f=(await import("exceljs")).default,C=new f.Workbook;C.creator="OpenGridX",C.created=new Date;const b=o.filter(S=>S.exportable!==!1&&S.field!=="__check__"&&S.field!=="__actions__"&&!S.isSpacer),E=n,P=p&&p.length>0?n.filter(S=>p.includes(S.id)):n,k=l??[{name:"Data",rows:"all",includeHeaders:!0,includeSummary:!1}],j=new Map;for(const S of k){if("type"in S&&S.type==="summary"){if(!h||!m)continue;const _=C.addWorksheet(S.name??"Summary");_.addRow(["Summary / Aggregation Totals"]),_.getRow(1).font={bold:!0,size:g+2,color:{argb:wt(s)}},_.addRow([]),_.addRow(["Column","Function","Value"]).eachCell(H=>{H.fill={type:"pattern",pattern:"solid",fgColor:{argb:wt(d)}},H.font={bold:!0,size:g,color:{argb:wt(s)}},H.border=xo()}),b.forEach(H=>{const K=m[H.field],R=h[H.field];if(K==null||R==null)return;let Y=R;H.valueFormatter?Y=H.valueFormatter({value:R,row:{},field:H.field}):Y=bt(R,K);const $=_.addRow([H.headerName??H.field,K.toUpperCase(),Y]);$.getCell(3).alignment={horizontal:"right"},$.getCell(3).font={bold:!0,size:u}}),_.getColumn(1).width=20,_.getColumn(2).width=12,_.getColumn(3).width=18;continue}const x=S,{name:N="Data",rows:O="all",includeHeaders:W=!0,includeSummary:X=!1,autoFilter:A=!0,frozenHeader:U=!0,alternateRowColor:q="#f8fafc"}=x,G=O==="selected"?P:E,ee=b.filter(_=>a[_.field]?.embedImage);if(ee.length>0){const _=[],D=new Set;if(G.forEach(H=>{ee.forEach(K=>{const R=H[K.field];typeof R=="string"&&R&&!j.has(R)&&!D.has(R)&&(_.push(R),D.add(R))})}),_.length>0){const H=await ai(_);for(const[K,{buffer:R,extension:Y}]of H){const $=C.addImage({buffer:R,extension:Y});j.set(K,$)}}}const Q=C.addWorksheet(N);if(Q.columns=b.map(_=>({key:_.field,width:li(_,a[_.field]?.width),style:{numFmt:a[_.field]?.numFmt??ii(_)}})),W){const _=b.map(H=>H.headerName??H.field),D=Q.addRow(_);D.height=20,D.eachCell((H,K)=>{const R=b[K-1];H.fill={type:"pattern",pattern:"solid",fgColor:{argb:wt(d)}},H.font={bold:!0,size:g,color:{argb:wt(s)}},H.alignment={horizontal:a[R?.field]?.alignment??(R?.type==="number"?"right":"left"),vertical:"middle"},H.border=xo()}),A&&(Q.autoFilter={from:{row:1,column:1},to:{row:1,column:b.length}}),U?Q.views=[{state:"frozen",ySplit:1,showGridLines:!1}]:Q.views=[{showGridLines:!1}]}let pe=W?1:0;if(G.forEach((_,D)=>{const H=b.map(R=>{if(a[R.field]?.embedImage)return"";let Y=_[R.field];return R.valueGetter&&(Y=R.valueGetter({row:_,field:R.field,value:Y})),ri(R,Y)==="string"&&R.valueFormatter&&Y!=null&&(Y=R.valueFormatter({value:Y,row:_,field:R.field})),Y}),K=Q.addRow(H);if(K.font={size:u},q&&D%2===1&&K.eachCell(R=>{R.fill={type:"pattern",pattern:"solid",fgColor:{argb:wt(q)}}}),K.eachCell((R,Y)=>{const $=b[Y-1];$&&(R.alignment={horizontal:a[$.field]?.alignment??($.type==="number"?"right":"left"),vertical:"middle"},R.border={bottom:{style:"thin",color:{argb:"FFf1f5f9"}}})}),ee.length>0){const R=ee.reduce((L,ae)=>Math.max(L,a[ae.field]?.imageHeight??40),0),Y=Math.ceil(R/1.333),$=Y*1.333;K.height=Y,ee.forEach(L=>{const ae=b.indexOf(L),oe=_[L.field],me=typeof oe=="string"?j.get(oe):void 0;if(me===void 0){K.getCell(ae+1).value=typeof oe=="string"?oe:"";return}const Ze=a[L.field],z=Ze?.imageWidth??40,Ne=Ze?.imageHeight??40,ft=(Q.getColumn(ae+1).width??8)*7+5,ze=Math.max(0,ft-z)/2,et=Math.max(0,$-Ne)/2;Q.addImage(me,{tl:{col:ae,row:pe,nativeColOff:Math.floor(ze*9525),nativeRowOff:Math.floor(et*9525)},ext:{width:z,height:Ne},editAs:"oneCell"})})}else K.height=16;pe++}),X&&h&&m){const _=b.map(R=>{const Y=m[R.field];return Y?Y.toUpperCase():""}),D=Q.addRow(_);D.height=16,D.font={size:u-1,italic:!0,color:{argb:"FF94a3b8"}},D.eachCell(R=>{R.alignment={horizontal:"right",vertical:"middle"},R.border={top:{style:"thin",color:{argb:"FFcbd5e1"}}}});const H=b.map(R=>{const Y=m[R.field],$=h[R.field];return Y==null||$==null?"":R.valueFormatter?R.valueFormatter({value:$,row:{},field:R.field}):bt($,Y)}),K=Q.addRow(H);K.height=18,K.font={bold:!0,size:u,color:{argb:wt(s)}},K.eachCell(R=>{R.fill={type:"pattern",pattern:"solid",fgColor:{argb:wt(d)}},R.alignment={horizontal:"right",vertical:"middle"},R.border=ci()})}}const y=await C.xlsx.writeBuffer(),w=new Blob([y],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),v=URL.createObjectURL(w),M=document.createElement("a");M.href=v,M.download=r.endsWith(".xlsx")?r:`${r}.xlsx`,document.body.appendChild(M),M.click(),document.body.removeChild(M),URL.revokeObjectURL(v)}function wt(n){const o=n.replace("#","");return o.length===3?"FF"+o.split("").map(e=>e+e).join(""):o.length===6?"FF"+o:"FF"+o.padEnd(6,"0")}function xo(){return{bottom:{style:"medium",color:{argb:"FFcbd5e1"}}}}function ci(){return{top:{style:"medium",color:{argb:"FFcbd5e1"}}}}const ui={"--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 fi(n){const o={};function e(r,l){l!==void 0&&(o[r]=l)}if(n.colors){const r=n.colors;e("--ogx-color-primary",r.primary),e("--ogx-color-primary-dark",r.primaryDark),e("--ogx-color-primary-light",r.primaryLight),e("--ogx-color-primary-focus",r.primaryFocus),e("--ogx-color-secondary",r.secondary),e("--ogx-color-secondary-dark",r.secondaryDark),e("--ogx-color-secondary-light",r.secondaryLight),e("--ogx-color-success",r.success),e("--ogx-color-warning",r.warning),e("--ogx-color-error",r.error),e("--ogx-color-info",r.info)}if(n.typography){const r=n.typography;e("--ogx-font-family",r.fontFamily),e("--ogx-font-family-mono",r.fontFamilyMono),e("--ogx-font-size-xs",r.fontSizeXs),e("--ogx-font-size-sm",r.fontSizeSm),e("--ogx-font-size-md",r.fontSizeMd),e("--ogx-font-size-lg",r.fontSizeLg),e("--ogx-font-size-xl",r.fontSizeXl)}if(n.spacing){const r=n.spacing;e("--ogx-spacing-xs",r.xs),e("--ogx-spacing-sm",r.sm),e("--ogx-spacing-md",r.md),e("--ogx-spacing-lg",r.lg),e("--ogx-spacing-xl",r.xl),e("--ogx-spacing-xxl",r.xxl)}if(n.borders){const r=n.borders;e("--ogx-border-width-thin",r.widthThin),e("--ogx-border-width-medium",r.widthMedium),e("--ogx-border-width-thick",r.widthThick),e("--ogx-border-radius-sm",r.radiusSm),e("--ogx-border-radius-md",r.radiusMd),e("--ogx-border-radius-lg",r.radiusLg),e("--ogx-border-radius-xl",r.radiusXl),e("--ogx-border-color",r.color),e("--ogx-border-color-hover",r.colorHover)}if(n.shadows){const r=n.shadows;e("--ogx-shadow-sm",r.sm),e("--ogx-shadow-md",r.md),e("--ogx-shadow-lg",r.lg),e("--ogx-shadow-xl",r.xl)}if(n.grid){const r=n.grid;e("--ogx-grid-row-height-compact",r.rowHeightCompact),e("--ogx-grid-row-height-standard",r.rowHeightStandard),e("--ogx-row-height",r.rowHeightStandard),e("--ogx-grid-row-height-comfortable",r.rowHeightComfortable),e("--ogx-grid-header-height",r.headerHeight),e("--ogx-header-height",r.headerHeight),e("--ogx-grid-cell-padding-x",r.cellPaddingX),e("--ogx-grid-cell-padding-y",r.cellPaddingY),e("--ogx-grid-background",r.background),e("--ogx-grid-border-color",r.borderColor),e("--ogx-grid-header-background",r.headerBackground),e("--ogx-grid-header-text",r.headerText),e("--ogx-grid-header-hover-background",r.headerHoverBackground),e("--ogx-grid-header-sorted-background",r.headerSortedBackground),e("--ogx-grid-row-text",r.rowText),e("--ogx-grid-row-hover-background",r.rowHoverBackground),e("--ogx-grid-row-alternate-background",r.rowAlternateBackground),e("--ogx-grid-row-selected-background",r.rowSelectedBackground),e("--ogx-grid-row-selected-hover-background",r.rowSelectedHoverBackground),e("--ogx-grid-cell-focus-border",r.cellFocusBorder),e("--ogx-grid-pinned-left-shadow",r.pinnedLeftShadow),e("--ogx-grid-pinned-right-shadow",r.pinnedRightShadow),e("--ogx-checkbox-bg",r.checkboxBg),e("--ogx-checkbox-border",r.checkboxBorder)}if(n.transitions){const r=n.transitions;e("--ogx-transition-duration-fast",r.durationFast),e("--ogx-transition-duration-normal",r.durationNormal),e("--ogx-transition-duration-slow",r.durationSlow),e("--ogx-transition-easing",r.easing)}if(n.toolbar){const r=n.toolbar;e("--ogx-toolbar-background",r.background),e("--ogx-toolbar-text",r.text),e("--ogx-toolbar-border",r.border),e("--ogx-toolbar-btn-bg",r.buttonBackground),e("--ogx-toolbar-btn-hover",r.buttonHoverBackground),e("--ogx-toolbar-btn-text",r.buttonText),e("--ogx-toolbar-btn-primary-bg",r.buttonPrimaryBackground),e("--ogx-toolbar-btn-primary-hover",r.buttonPrimaryHoverBackground),e("--ogx-toolbar-btn-primary-text",r.buttonPrimaryText),e("--ogx-toolbar-btn-danger-bg",r.buttonDangerBackground),e("--ogx-toolbar-btn-danger-hover",r.buttonDangerHoverBackground),e("--ogx-toolbar-btn-danger-text",r.buttonDangerText),e("--ogx-toolbar-input-bg",r.inputBackground),e("--ogx-toolbar-input-text",r.inputText),e("--ogx-toolbar-input-border",r.inputBorder),e("--ogx-toolbar-input-focus-border",r.inputFocusBorder),e("--ogx-toolbar-input-focus-shadow",r.inputFocusShadow),e("--ogx-toolbar-chip-bg",r.chipBackground),e("--ogx-toolbar-chip-text",r.chipText),e("--ogx-toolbar-chip-active-bg",r.chipActiveBackground),e("--ogx-toolbar-chip-active-text",r.chipActiveText)}if(n.overlays){const r=n.overlays;e("--ogx-overlay-background",r.background),e("--ogx-overlay-text",r.text),e("--ogx-overlay-border",r.border),e("--ogx-overlay-shadow",r.shadow),e("--ogx-overlay-item-hover-bg",r.itemHoverBackground),e("--ogx-overlay-item-hover-text",r.itemHoverText),e("--ogx-overlay-item-selected-bg",r.itemSelectedBackground),e("--ogx-overlay-item-selected-text",r.itemSelectedText),e("--ogx-overlay-item-danger-bg",r.itemDangerBackground),e("--ogx-overlay-item-danger-text",r.itemDangerText)}if(n.scrollbar){const r=n.scrollbar;e("--ogx-scrollbar-thumb",r.thumbColor),e("--ogx-scrollbar-track",r.trackColor),e("--ogx-scrollbar-size",r.size)}if(n.skeleton){const r=n.skeleton;e("--ogx-skeleton-base",r.baseColor),e("--ogx-skeleton-highlight",r.highlightColor),e("--ogx-skeleton-dark-base",r.darkBaseColor),e("--ogx-skeleton-dark-highlight",r.darkHighlightColor)}return o}function gi({theme:n,children:o,className:e,style:r}){const l=i.useMemo(()=>({...ui,...fi(n)}),[n]);return t.jsx("div",{className:`ogx-theme-provider ${e||""}`.trim(),style:{...r,...l},children:o})}const hi={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"}},pi={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"}},xi={colors:{primary:"#059669",primaryDark:"#047857",primaryLight:"#ecfdf5",primaryFocus:"rgba(5, 150, 105, 0.4)"},grid:{headerBackground:"#ecfdf5",headerHoverBackground:"#d1fae5",headerSortedBackground:"#a7f3d0",rowAlternateBackground:"#f6fdf9",rowSelectedBackground:"#d1fae5",rowSelectedHoverBackground:"#a7f3d0",cellFocusBorder:"#059669"}},mi={colors:{primary:"#d97706",primaryDark:"#b45309",primaryLight:"#fffbeb",primaryFocus:"rgba(217, 119, 6, 0.4)"},grid:{headerBackground:"#fffbeb",headerHoverBackground:"#fef3c7",headerSortedBackground:"#fde68a",rowAlternateBackground:"#fffdf5",rowSelectedBackground:"#fef3c7",rowSelectedHoverBackground:"#fde68a",cellFocusBorder:"#d97706"}},bi={grid:{rowHeightCompact:"28px",rowHeightStandard:"36px",rowHeightComfortable:"48px",headerHeight:"40px",cellPaddingX:"8px",cellPaddingY:"4px"},typography:{fontSizeSm:"0.8rem",fontSizeMd:"0.875rem"}};function wi(n,o){try{const e=o.getItem(n);return e?JSON.parse(e):void 0}catch{return}}function vi(n,o,e,r){try{const l=e?Object.fromEntries(Object.entries(o).filter(([a])=>e.includes(a))):o;r.setItem(n,JSON.stringify(l))}catch{}}function _i(n){const o=typeof n=="string"?{key:n}:n,{key:e,debounceMs:r=300,include:l,storage:a=typeof window<"u"?window.localStorage:void 0}=o,d=i.useMemo(()=>{if(a)return wi(e,a)},[e]),s=i.useRef(null),g=i.useRef(null),u=i.useCallback(()=>{g.current&&a&&vi(e,g.current,l,a)},[e,l,a]),h=i.useCallback(p=>{g.current=p,s.current&&clearTimeout(s.current),s.current=setTimeout(u,r)},[u,r]);i.useEffect(()=>()=>{s.current&&(clearTimeout(s.current),u())},[u]);const m=i.useCallback(()=>{a&&a.removeItem(e)},[e,a]);return{initialState:d,onStateChange:h,clearState:m}}ie.Button=Qt,ie.Cell=ro,ie.Checkbox=qt,ie.DataGrid=Fr,ie.DataGridThemeProvider=gi,ie.FilterPanel=fo,ie.GridToolbar=Jr,ie.GridTooltip=Zt,ie.Header=oo,ie.Input=Zr,ie.Row=Jt,ie.Skeleton=Wr,ie.amberTheme=mi,ie.compactTheme=bi,ie.darkTheme=hi,ie.emeraldTheme=xi,ie.exportToCsv=ei,ie.exportToExcel=ti,ie.exportToExcelAdvanced=di,ie.exportToJson=ni,ie.formatAggregationValue=bt,ie.printGrid=oi,ie.roseTheme=pi,ie.useAggregation=so,ie.useGridApiRef=Qr,ie.useGridStateStorage=_i,ie.usePivot=ao,Object.defineProperty(ie,Symbol.toStringTag,{value:"Module"})}));
|
|
52
|
+
`;if(l&&(p+=`<h1>${He(l)}</h1>`),p+="<table>",p+="<thead><tr>",c.forEach(b=>{p+=`<th>${He(b.headerName||b.field)}</th>`}),p+="</tr></thead>",p+="<tbody>",f.forEach(b=>{p+="<tr>",c.forEach(x=>{let w=b[x.field];x.valueGetter&&(w=x.valueGetter({row:b,field:x.field,value:w})),x.valueFormatter&&w!==void 0&&w!==null&&(w=x.valueFormatter({value:w,row:b,field:x.field})),x.type==="image"&&w?p+=`<td><div style="display:flex;justify-content:center;"><img src="${w}" alt="${x.headerName}" style="max-height: 40px; border-radius: 4px;"></div></td>`:p+=`<td>${He(String(w??""))}</td>`}),p+="</tr>"}),d){const b=s||{};p+='<tfoot><tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',c.forEach(x=>{b[x.field]?p+=`<td style="text-align: right; font-weight: bold;">${He(b[x.field].toUpperCase())}</td>`:p+="<td></td>"}),p+='</tr><tr style="font-weight: bold; background-color: #f5f5f5;">',c.forEach(x=>{const w=d[x.field];if(w!=null){let h=w;x.valueFormatter?h=x.valueFormatter({value:w,row:{},field:x.field}):b[x.field]&&(h=qe(w,b[x.field])),p+=`<td style="text-align: right;">${He(String(h))}</td>`}else p+="<td></td>"}),p+="</tr></tfoot>"}p+="</tbody></table></body></html>",r.document.open(),r.document.write(p),r.document.close(),r.document.title=l||"Print Preview",r.focus();let m=!1;r.onload=()=>{m||(m=!0,r.print(),setTimeout(()=>{r.close()},100))},setTimeout(()=>{!m&&r&&!r.closed&&(m=!0,r.print(),setTimeout(()=>{r.closed||r.close()},100))},500)}catch(l){console.error("Print generation failed:",l),r&&!r.closed&&(r.document.body.innerHTML=`<div style="color: red; padding: 20px;"><h3>Error Generating Print Preview</h3><p>${l.message}</p></div>`)}}function ln(t,o,e){const r=new Blob([t],{type:e}),l=URL.createObjectURL(r),a=document.createElement("a");a.href=l,a.download=o,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(l)}function Br(t,o){return t.type==="number"?"number":t.type==="boolean"?"boolean":t.type==="date"?"date":typeof o=="number"?"number":typeof o=="boolean"?"boolean":o instanceof Date?"date":"string"}function $r(t){if(t.type==="number")return"#,##0.##";if(t.type==="date")return"yyyy-mm-dd"}function Dr(t,o){if(o!=null)return o;const e=t.width??120;return Math.min(60,Math.max(8,(e-5)/7))}function Hr(t,o){const e=o??"";if(e.includes("jpeg")||e.includes("jpg"))return"jpeg";if(e.includes("gif"))return"gif";const r=t.split("?")[0].toLowerCase();return r.endsWith(".jpg")||r.endsWith(".jpeg")?"jpeg":r.endsWith(".gif")?"gif":"png"}async function Gr(t){const o=await Promise.allSettled(t.map(async r=>{if(r.startsWith("data:")){const s=r.indexOf(","),f=r.slice(0,s),c=r.slice(s+1),p=atob(c),m=new Uint8Array(p.length);for(let h=0;h<p.length;h++)m[h]=p.charCodeAt(h);const x=f.match(/data:([^;,]+)/)?.[1]??"image/png";let w="png";return x.includes("jpeg")||x.includes("jpg")?w="jpeg":x.includes("gif")&&(w="gif"),{url:r,buffer:m.buffer,ext:w}}const l=await fetch(r,{mode:"cors"});if(!l.ok)throw new Error(`HTTP ${l.status}`);const a=await l.arrayBuffer(),d=Hr(r,l.headers.get("content-type"));return{url:r,buffer:a,ext:d}})),e=new Map;return o.forEach((r,l)=>{r.status==="fulfilled"?e.set(r.value.url,{buffer:r.value.buffer,extension:r.value.ext}):console.warn(`[exportToExcelAdvanced] Cannot embed image "${t[l]}" (CORS/network error — raw URL written as fallback):`,r.reason)}),e}async function Vr(t,o,e={}){const{fileName:r="export.xlsx",sheets:l,columnStyles:a={},headerFillColor:d="#f1f5f9",headerTextColor:s="#334155",headerFontSize:f=10,bodyFontSize:c=10,aggregationResult:p=null,aggregationModel:m=null,selectedRows:b}=e,x=(await import("exceljs")).default,w=new x.Workbook;w.creator="OpenGridX",w.created=new Date;const h=o.filter(S=>S.exportable!==!1&&S.field!=="__check__"&&S.field!=="__actions__"&&!S.isSpacer),j=t,P=b&&b.length>0?t.filter(S=>b.includes(S.id)):t,k=l??[{name:"Data",rows:"all",includeHeaders:!0,includeSummary:!1}],E=new Map;for(const S of k){if("type"in S&&S.type==="summary"){if(!p||!m)continue;const _=w.addWorksheet(S.name??"Summary");_.addRow(["Summary / Aggregation Totals"]),_.getRow(1).font={bold:!0,size:f+2,color:{argb:Je(s)}},_.addRow([]),_.addRow(["Column","Function","Value"]).eachCell(B=>{B.fill={type:"pattern",pattern:"solid",fgColor:{argb:Je(d)}},B.font={bold:!0,size:f,color:{argb:Je(s)}},B.border=Gn()}),h.forEach(B=>{const z=m[B.field],L=p[B.field];if(z==null||L==null)return;let X=L;B.valueFormatter?X=B.valueFormatter({value:L,row:{},field:B.field}):X=qe(L,z);const H=_.addRow([B.headerName??B.field,z.toUpperCase(),X]);H.getCell(3).alignment={horizontal:"right"},H.getCell(3).font={bold:!0,size:c}}),_.getColumn(1).width=20,_.getColumn(2).width=12,_.getColumn(3).width=18;continue}const I=S,{name:M="Data",rows:C="all",includeHeaders:W=!0,includeSummary:Y=!1,autoFilter:F=!0,frozenHeader:D=!0,alternateRowColor:K="#f8fafc"}=I,O=C==="selected"?P:j,V=h.filter(_=>a[_.field]?.embedImage);if(V.length>0){const _=[],G=new Set;if(O.forEach(B=>{V.forEach(z=>{const L=B[z.field];typeof L=="string"&&L&&!E.has(L)&&!G.has(L)&&(_.push(L),G.add(L))})}),_.length>0){const B=await Gr(_);for(const[z,{buffer:L,extension:X}]of B){const H=w.addImage({buffer:L,extension:X});E.set(z,H)}}}const J=w.addWorksheet(M);if(J.columns=h.map(_=>({key:_.field,width:Dr(_,a[_.field]?.width),style:{numFmt:a[_.field]?.numFmt??$r(_)}})),W){const _=h.map(B=>B.headerName??B.field),G=J.addRow(_);G.height=20,G.eachCell((B,z)=>{const L=h[z-1];B.fill={type:"pattern",pattern:"solid",fgColor:{argb:Je(d)}},B.font={bold:!0,size:f,color:{argb:Je(s)}},B.alignment={horizontal:a[L?.field]?.alignment??(L?.type==="number"?"right":"left"),vertical:"middle"},B.border=Gn()}),F&&(J.autoFilter={from:{row:1,column:1},to:{row:1,column:h.length}}),D?J.views=[{state:"frozen",ySplit:1,showGridLines:!1}]:J.views=[{showGridLines:!1}]}let ee=W?1:0;if(O.forEach((_,G)=>{const B=h.map(L=>{if(a[L.field]?.embedImage)return"";let X=_[L.field];return L.valueGetter&&(X=L.valueGetter({row:_,field:L.field,value:X})),Br(L,X)==="string"&&L.valueFormatter&&X!=null&&(X=L.valueFormatter({value:X,row:_,field:L.field})),X}),z=J.addRow(B);if(z.font={size:c},K&&G%2===1&&z.eachCell(L=>{L.fill={type:"pattern",pattern:"solid",fgColor:{argb:Je(K)}}}),z.eachCell((L,X)=>{const H=h[X-1];H&&(L.alignment={horizontal:a[H.field]?.alignment??(H.type==="number"?"right":"left"),vertical:"middle"},L.border={bottom:{style:"thin",color:{argb:"FFf1f5f9"}}})}),V.length>0){const L=V.reduce((R,re)=>Math.max(R,a[re.field]?.imageHeight??40),0),X=Math.ceil(L/1.333),H=X*1.333;z.height=X,V.forEach(R=>{const re=h.indexOf(R),Z=_[R.field],se=typeof Z=="string"?E.get(Z):void 0;if(se===void 0){z.getCell(re+1).value=typeof Z=="string"?Z:"";return}const me=a[R.field],U=me?.imageWidth??40,pe=me?.imageHeight??40,je=(J.getColumn(re+1).width??8)*7+5,ge=Math.max(0,je-U)/2,be=Math.max(0,H-pe)/2;J.addImage(se,{tl:{col:re,row:ee,nativeColOff:Math.floor(ge*9525),nativeRowOff:Math.floor(be*9525)},ext:{width:U,height:pe},editAs:"oneCell"})})}else z.height=16;ee++}),Y&&p&&m){const _=h.map(L=>{const X=m[L.field];return X?X.toUpperCase():""}),G=J.addRow(_);G.height=16,G.font={size:c-1,italic:!0,color:{argb:"FF94a3b8"}},G.eachCell(L=>{L.alignment={horizontal:"right",vertical:"middle"},L.border={top:{style:"thin",color:{argb:"FFcbd5e1"}}}});const B=h.map(L=>{const X=m[L.field],H=p[L.field];return X==null||H==null?"":L.valueFormatter?L.valueFormatter({value:H,row:{},field:L.field}):qe(H,X)}),z=J.addRow(B);z.height=18,z.font={bold:!0,size:c,color:{argb:Je(s)}},z.eachCell(L=>{L.fill={type:"pattern",pattern:"solid",fgColor:{argb:Je(d)}},L.alignment={horizontal:"right",vertical:"middle"},L.border=Ur()})}}const y=await w.xlsx.writeBuffer(),g=new Blob([y],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),v=URL.createObjectURL(g),N=document.createElement("a");N.href=v,N.download=r.endsWith(".xlsx")?r:`${r}.xlsx`,document.body.appendChild(N),N.click(),document.body.removeChild(N),URL.revokeObjectURL(v)}function Je(t){const o=t.replace("#","");return o.length===3?"FF"+o.split("").map(e=>e+e).join(""):o.length===6?"FF"+o:"FF"+o.padEnd(6,"0")}function Gn(){return{bottom:{style:"medium",color:{argb:"FFcbd5e1"}}}}function Ur(){return{top:{style:"medium",color:{argb:"FFcbd5e1"}}}}const Kr={"--ogx-color-primary":"#3b82f6","--ogx-color-primary-dark":"#2563eb","--ogx-color-primary-light":"#eff6ff","--ogx-color-primary-focus":"rgba(59, 130, 246, 0.5)","--ogx-color-secondary":"#8b5cf6","--ogx-color-secondary-dark":"#7c3aed","--ogx-color-secondary-light":"#f5f3ff","--ogx-color-white":"#ffffff","--ogx-color-black":"#0f172a","--ogx-border-color":"#e2e8f0","--ogx-border-color-hover":"#cbd5e1","--ogx-shadow-sm":"0 1px 2px 0 rgba(0, 0, 0, 0.05)","--ogx-shadow-md":"0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03)","--ogx-shadow-lg":"0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02)","--ogx-grid-background":"#ffffff","--ogx-grid-border-color":"#e2e8f0","--ogx-grid-header-background":"#f8fafc","--ogx-grid-header-text":"#334155","--ogx-grid-header-hover-background":"#f1f5f9","--ogx-grid-header-sorted-background":"#f8fafc","--ogx-grid-row-text":"#1e293b","--ogx-grid-row-hover-background":"#f8fafc","--ogx-grid-row-alternate-background":"transparent","--ogx-grid-row-selected-background":"#eff6ff","--ogx-grid-row-selected-hover-background":"#dbeafe","--ogx-grid-cell-focus-border":"#3b82f6","--ogx-checkbox-bg":"#ffffff","--ogx-checkbox-border":"#94a3b8","--ogx-grid-pinned-left-shadow":"4px 0 24px -4px rgba(0, 0, 0, 0.05)","--ogx-grid-pinned-right-shadow":"-4px 0 24px -4px rgba(0, 0, 0, 0.05)","--ogx-toolbar-background":"transparent","--ogx-toolbar-text":"#1e293b","--ogx-toolbar-border":"#e2e8f0","--ogx-toolbar-btn-bg":"transparent","--ogx-toolbar-btn-hover":"#f1f5f9","--ogx-toolbar-btn-text":"#334155","--ogx-toolbar-btn-primary-bg":"#3b82f6","--ogx-toolbar-btn-primary-hover":"#2563eb","--ogx-toolbar-btn-primary-text":"#ffffff","--ogx-toolbar-btn-danger-bg":"rgba(239, 68, 68, 0.08)","--ogx-toolbar-btn-danger-hover":"rgba(239, 68, 68, 0.15)","--ogx-toolbar-btn-danger-text":"#ef4444","--ogx-toolbar-input-bg":"#ffffff","--ogx-toolbar-input-text":"#1e293b","--ogx-toolbar-input-border":"#cbd5e1","--ogx-toolbar-input-focus-border":"#3b82f6","--ogx-toolbar-input-focus-shadow":"0 0 0 3px rgba(59, 130, 246, 0.12)","--ogx-toolbar-chip-bg":"#f1f5f9","--ogx-toolbar-chip-text":"#475569","--ogx-toolbar-chip-active-bg":"rgba(59, 130, 246, 0.12)","--ogx-toolbar-chip-active-text":"#2563eb","--ogx-overlay-background":"#ffffff","--ogx-overlay-text":"#1e293b","--ogx-overlay-border":"#e2e8f0","--ogx-overlay-shadow":"0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.06)","--ogx-overlay-item-hover-bg":"#f8fafc","--ogx-overlay-item-hover-text":"#0f172a","--ogx-overlay-item-selected-bg":"rgba(59, 130, 246, 0.08)","--ogx-overlay-item-selected-text":"#2563eb","--ogx-overlay-item-danger-bg":"rgba(239, 68, 68, 0.08)","--ogx-overlay-item-danger-text":"#ef4444","--ogx-scrollbar-thumb":"rgba(148, 163, 184, 0.5)","--ogx-scrollbar-track":"transparent","--ogx-scrollbar-size":"10px","--ogx-skeleton-base":"#f1f5f9","--ogx-skeleton-highlight":"#ffffff","--ogx-skeleton-dark-base":"#e2e8f0","--ogx-skeleton-dark-highlight":"#f8fafc"};function Yr(t){const o={};function e(r,l){l!==void 0&&(o[r]=l)}if(t.colors){const r=t.colors;e("--ogx-color-primary",r.primary),e("--ogx-color-primary-dark",r.primaryDark),e("--ogx-color-primary-light",r.primaryLight),e("--ogx-color-primary-focus",r.primaryFocus),e("--ogx-color-secondary",r.secondary),e("--ogx-color-secondary-dark",r.secondaryDark),e("--ogx-color-secondary-light",r.secondaryLight),e("--ogx-color-success",r.success),e("--ogx-color-warning",r.warning),e("--ogx-color-error",r.error),e("--ogx-color-info",r.info)}if(t.typography){const r=t.typography;e("--ogx-font-family",r.fontFamily),e("--ogx-font-family-mono",r.fontFamilyMono),e("--ogx-font-size-xs",r.fontSizeXs),e("--ogx-font-size-sm",r.fontSizeSm),e("--ogx-font-size-md",r.fontSizeMd),e("--ogx-font-size-lg",r.fontSizeLg),e("--ogx-font-size-xl",r.fontSizeXl)}if(t.spacing){const r=t.spacing;e("--ogx-spacing-xs",r.xs),e("--ogx-spacing-sm",r.sm),e("--ogx-spacing-md",r.md),e("--ogx-spacing-lg",r.lg),e("--ogx-spacing-xl",r.xl),e("--ogx-spacing-xxl",r.xxl)}if(t.borders){const r=t.borders;e("--ogx-border-width-thin",r.widthThin),e("--ogx-border-width-medium",r.widthMedium),e("--ogx-border-width-thick",r.widthThick),e("--ogx-border-radius-sm",r.radiusSm),e("--ogx-border-radius-md",r.radiusMd),e("--ogx-border-radius-lg",r.radiusLg),e("--ogx-border-radius-xl",r.radiusXl),e("--ogx-border-color",r.color),e("--ogx-border-color-hover",r.colorHover)}if(t.shadows){const r=t.shadows;e("--ogx-shadow-sm",r.sm),e("--ogx-shadow-md",r.md),e("--ogx-shadow-lg",r.lg),e("--ogx-shadow-xl",r.xl)}if(t.grid){const r=t.grid;e("--ogx-grid-row-height-compact",r.rowHeightCompact),e("--ogx-grid-row-height-standard",r.rowHeightStandard),e("--ogx-row-height",r.rowHeightStandard),e("--ogx-grid-row-height-comfortable",r.rowHeightComfortable),e("--ogx-grid-header-height",r.headerHeight),e("--ogx-header-height",r.headerHeight),e("--ogx-grid-cell-padding-x",r.cellPaddingX),e("--ogx-grid-cell-padding-y",r.cellPaddingY),e("--ogx-grid-background",r.background),e("--ogx-grid-border-color",r.borderColor),e("--ogx-grid-header-background",r.headerBackground),e("--ogx-grid-header-text",r.headerText),e("--ogx-grid-header-hover-background",r.headerHoverBackground),e("--ogx-grid-header-sorted-background",r.headerSortedBackground),e("--ogx-grid-row-text",r.rowText),e("--ogx-grid-row-hover-background",r.rowHoverBackground),e("--ogx-grid-row-alternate-background",r.rowAlternateBackground),e("--ogx-grid-row-selected-background",r.rowSelectedBackground),e("--ogx-grid-row-selected-hover-background",r.rowSelectedHoverBackground),e("--ogx-grid-cell-focus-border",r.cellFocusBorder),e("--ogx-grid-pinned-left-shadow",r.pinnedLeftShadow),e("--ogx-grid-pinned-right-shadow",r.pinnedRightShadow),e("--ogx-checkbox-bg",r.checkboxBg),e("--ogx-checkbox-border",r.checkboxBorder)}if(t.transitions){const r=t.transitions;e("--ogx-transition-duration-fast",r.durationFast),e("--ogx-transition-duration-normal",r.durationNormal),e("--ogx-transition-duration-slow",r.durationSlow),e("--ogx-transition-easing",r.easing)}if(t.toolbar){const r=t.toolbar;e("--ogx-toolbar-background",r.background),e("--ogx-toolbar-text",r.text),e("--ogx-toolbar-border",r.border),e("--ogx-toolbar-btn-bg",r.buttonBackground),e("--ogx-toolbar-btn-hover",r.buttonHoverBackground),e("--ogx-toolbar-btn-text",r.buttonText),e("--ogx-toolbar-btn-primary-bg",r.buttonPrimaryBackground),e("--ogx-toolbar-btn-primary-hover",r.buttonPrimaryHoverBackground),e("--ogx-toolbar-btn-primary-text",r.buttonPrimaryText),e("--ogx-toolbar-btn-danger-bg",r.buttonDangerBackground),e("--ogx-toolbar-btn-danger-hover",r.buttonDangerHoverBackground),e("--ogx-toolbar-btn-danger-text",r.buttonDangerText),e("--ogx-toolbar-input-bg",r.inputBackground),e("--ogx-toolbar-input-text",r.inputText),e("--ogx-toolbar-input-border",r.inputBorder),e("--ogx-toolbar-input-focus-border",r.inputFocusBorder),e("--ogx-toolbar-input-focus-shadow",r.inputFocusShadow),e("--ogx-toolbar-chip-bg",r.chipBackground),e("--ogx-toolbar-chip-text",r.chipText),e("--ogx-toolbar-chip-active-bg",r.chipActiveBackground),e("--ogx-toolbar-chip-active-text",r.chipActiveText)}if(t.overlays){const r=t.overlays;e("--ogx-overlay-background",r.background),e("--ogx-overlay-text",r.text),e("--ogx-overlay-border",r.border),e("--ogx-overlay-shadow",r.shadow),e("--ogx-overlay-item-hover-bg",r.itemHoverBackground),e("--ogx-overlay-item-hover-text",r.itemHoverText),e("--ogx-overlay-item-selected-bg",r.itemSelectedBackground),e("--ogx-overlay-item-selected-text",r.itemSelectedText),e("--ogx-overlay-item-danger-bg",r.itemDangerBackground),e("--ogx-overlay-item-danger-text",r.itemDangerText)}if(t.scrollbar){const r=t.scrollbar;e("--ogx-scrollbar-thumb",r.thumbColor),e("--ogx-scrollbar-track",r.trackColor),e("--ogx-scrollbar-size",r.size)}if(t.skeleton){const r=t.skeleton;e("--ogx-skeleton-base",r.baseColor),e("--ogx-skeleton-highlight",r.highlightColor),e("--ogx-skeleton-dark-base",r.darkBaseColor),e("--ogx-skeleton-dark-highlight",r.darkHighlightColor)}return o}function Xr({theme:t,children:o,className:e,style:r}){const l=i.useMemo(()=>({...Kr,...Yr(t)}),[t]);return n.jsx("div",{className:`ogx-theme-provider ${e||""}`.trim(),style:{...r,...l},children:o})}const qr={colors:{primary:"#60a5fa",primaryDark:"#3b82f6",primaryLight:"#1e3a5f",primaryFocus:"rgba(96, 165, 250, 0.4)"},grid:{background:"#0f172a",headerBackground:"#1e293b",headerText:"#e2e8f0",headerHoverBackground:"#334155",headerSortedBackground:"#1e3a5f",rowText:"#cbd5e1",borderColor:"#334155",rowHoverBackground:"#1e293b",rowAlternateBackground:"#162032",rowSelectedBackground:"#1e3a5f",rowSelectedHoverBackground:"#1d4ed8",cellFocusBorder:"#60a5fa",checkboxBg:"#1e293b",checkboxBorder:"#64748b"},borders:{color:"#334155",colorHover:"#475569"},shadows:{sm:"0 1px 2px 0 rgba(0, 0, 0, 0.3)",md:"0 4px 6px -1px rgba(0, 0, 0, 0.3)"},toolbar:{background:"transparent",text:"#cbd5e1",border:"#334155",buttonBackground:"transparent",buttonHoverBackground:"#1e293b",buttonText:"#e2e8f0",buttonPrimaryBackground:"#3b82f6",buttonPrimaryHoverBackground:"#2563eb",buttonPrimaryText:"#ffffff",buttonDangerBackground:"rgba(239, 68, 68, 0.15)",buttonDangerHoverBackground:"rgba(239, 68, 68, 0.25)",buttonDangerText:"#fca5a5",inputBackground:"#0f172a",inputText:"#f8fafc",inputBorder:"#334155",inputFocusBorder:"#60a5fa",inputFocusShadow:"0 0 0 3px rgba(96, 165, 250, 0.2)",chipBackground:"#1e293b",chipText:"#94a3b8",chipActiveBackground:"rgba(96, 165, 250, 0.2)",chipActiveText:"#60a5fa"},overlays:{background:"#1e293b",text:"#f8fafc",border:"#334155",shadow:"0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3)",itemHoverBackground:"#334155",itemHoverText:"#ffffff",itemSelectedBackground:"rgba(96, 165, 250, 0.15)",itemSelectedText:"#60a5fa",itemDangerBackground:"rgba(239, 68, 68, 0.15)",itemDangerText:"#fca5a5"},scrollbar:{thumbColor:"rgba(148, 163, 184, 0.2)",trackColor:"transparent"},skeleton:{baseColor:"#1e293b",highlightColor:"#334155",darkBaseColor:"#0f172a",darkHighlightColor:"#1e293b"}},Jr={colors:{primary:"#e11d48",primaryDark:"#be123c",primaryLight:"#fff1f2",primaryFocus:"rgba(225, 29, 72, 0.4)"},grid:{headerBackground:"#fff1f2",headerHoverBackground:"#ffe4e6",headerSortedBackground:"#fecdd3",rowAlternateBackground:"#fff8f8",rowSelectedBackground:"#ffe4e6",rowSelectedHoverBackground:"#fecdd3",cellFocusBorder:"#e11d48"}},Qr={colors:{primary:"#059669",primaryDark:"#047857",primaryLight:"#ecfdf5",primaryFocus:"rgba(5, 150, 105, 0.4)"},grid:{headerBackground:"#ecfdf5",headerHoverBackground:"#d1fae5",headerSortedBackground:"#a7f3d0",rowAlternateBackground:"#f6fdf9",rowSelectedBackground:"#d1fae5",rowSelectedHoverBackground:"#a7f3d0",cellFocusBorder:"#059669"}},Zr={colors:{primary:"#d97706",primaryDark:"#b45309",primaryLight:"#fffbeb",primaryFocus:"rgba(217, 119, 6, 0.4)"},grid:{headerBackground:"#fffbeb",headerHoverBackground:"#fef3c7",headerSortedBackground:"#fde68a",rowAlternateBackground:"#fffdf5",rowSelectedBackground:"#fef3c7",rowSelectedHoverBackground:"#fde68a",cellFocusBorder:"#d97706"}},ei={grid:{rowHeightCompact:"28px",rowHeightStandard:"36px",rowHeightComfortable:"48px",headerHeight:"40px",cellPaddingX:"8px",cellPaddingY:"4px"},typography:{fontSizeSm:"0.8rem",fontSizeMd:"0.875rem"}};function ti(t,o){try{const e=o.getItem(t);return e?JSON.parse(e):void 0}catch{return}}function ni(t,o,e,r){try{const l=e?Object.fromEntries(Object.entries(o).filter(([a])=>e.includes(a))):o;r.setItem(t,JSON.stringify(l))}catch{}}function oi(t){const o=typeof t=="string"?{key:t}:t,{key:e,debounceMs:r=300,include:l,storage:a=typeof window<"u"?window.localStorage:void 0}=o,d=i.useMemo(()=>{if(a)return ti(e,a)},[e]),s=i.useRef(null),f=i.useRef(null),c=i.useCallback(()=>{f.current&&a&&ni(e,f.current,l,a)},[e,l,a]),p=i.useCallback(b=>{f.current=b,s.current&&clearTimeout(s.current),s.current=setTimeout(c,r)},[c,r]);i.useEffect(()=>()=>{s.current&&(clearTimeout(s.current),c())},[c]);const m=i.useCallback(()=>{a&&a.removeItem(e)},[e,a]);return{initialState:d,onStateChange:p,clearState:m}}ie.Button=jt,ie.Cell=Ln,ie.Checkbox=kt,ie.DataGrid=br,ie.DataGridThemeProvider=Xr,ie.FilterPanel=Bn,ie.GridToolbar=Lr,ie.GridTooltip=Et,ie.Header=Tn,ie.Input=Wr,ie.Row=St,ie.Skeleton=wr,ie.amberTheme=Zr,ie.compactTheme=ei,ie.darkTheme=qr,ie.emeraldTheme=Qr,ie.exportToCsv=Or,ie.exportToExcel=Fr,ie.exportToExcelAdvanced=Vr,ie.exportToJson=Ar,ie.formatAggregationValue=qe,ie.printGrid=zr,ie.roseTheme=Jr,ie.useAggregation=On,ie.useGridApiRef=Rr,ie.useGridStateStorage=oi,ie.usePivot=Fn,Object.defineProperty(ie,Symbol.toStringTag,{value:"Module"})}));
|
|
53
53
|
//# sourceMappingURL=opengridx.umd.js.map
|