@opencorestack/opengridx 0.1.5 → 0.1.6

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.
@@ -1,16 +1,16 @@
1
- (function(ie,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],l):(ie=typeof globalThis<"u"?globalThis:ie||self,l(ie.OpenGridX={},ie.React,ie.ReactDOM))})(this,(function(ie,l,St){"use strict";var an={exports:{}},Yt={};var Qn;function Wo(){if(Qn)return Yt;Qn=1;var n=Symbol.for("react.transitional.element"),o=Symbol.for("react.fragment");function e(r,i,s){var c=null;if(s!==void 0&&(c=""+s),i.key!==void 0&&(c=""+i.key),"key"in i){s={};for(var a in i)a!=="key"&&(s[a]=i[a])}else s=i;return i=s.ref,{$$typeof:n,type:r,key:c,ref:i!==void 0?i:null,props:s}}return Yt.Fragment=o,Yt.jsx=e,Yt.jsxs=e,Yt}var Xt={};var Zn;function Fo(){return Zn||(Zn=1,process.env.NODE_ENV!=="production"&&(function(){function n(v){if(v==null)return null;if(typeof v=="function")return v.$$typeof===R?null:v.displayName||v.name||null;if(typeof v=="string")return v;switch(v){case M:return"Fragment";case E:return"Profiler";case P:return"StrictMode";case y:return"Suspense";case I:return"SuspenseList";case j:return"Activity"}if(typeof v=="object")switch(typeof v.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),v.$$typeof){case b:return"Portal";case C:return v.displayName||"Context";case k:return(v._context.displayName||"Context")+".Consumer";case _:var D=v.render;return v=v.displayName,v||(v=D.displayName||D.name||"",v=v!==""?"ForwardRef("+v+")":"ForwardRef"),v;case S:return D=v.displayName||null,D!==null?D:n(v.type)||"Memo";case x:D=v._payload,v=v._init;try{return n(v(D))}catch{}}return null}function o(v){return""+v}function e(v){try{o(v);var D=!1}catch{D=!0}if(D){D=console;var H=D.error,W=typeof Symbol=="function"&&Symbol.toStringTag&&v[Symbol.toStringTag]||v.constructor.name||"Object";return H.call(D,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",W),o(v)}}function r(v){if(v===M)return"<>";if(typeof v=="object"&&v!==null&&v.$$typeof===x)return"<...>";try{var D=n(v);return D?"<"+D+">":"<...>"}catch{return"<...>"}}function i(){var v=B.A;return v===null?null:v.getOwner()}function s(){return Error("react-stack-top-frame")}function c(v){if(q.call(v,"key")){var D=Object.getOwnPropertyDescriptor(v,"key").get;if(D&&D.isReactWarning)return!1}return v.key!==void 0}function a(v,D){function H(){Y||(Y=!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)",D))}H.isReactWarning=!0,Object.defineProperty(v,"key",{get:H,configurable:!0})}function g(){var v=n(this.type);return G[v]||(G[v]=!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.")),v=this.props.ref,v!==void 0?v:null}function f(v,D,H,W,F,X){var K=H.ref;return v={$$typeof:w,type:v,key:D,props:H,_owner:W},(K!==void 0?K:null)!==null?Object.defineProperty(v,"ref",{enumerable:!1,get:g}):Object.defineProperty(v,"ref",{enumerable:!1,value:null}),v._store={},Object.defineProperty(v._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(v,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(v,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:F}),Object.defineProperty(v,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:X}),Object.freeze&&(Object.freeze(v.props),Object.freeze(v)),v}function p(v,D,H,W,F,X){var K=D.children;if(K!==void 0)if(W)if(A(K)){for(W=0;W<K.length;W++)m(K[W]);Object.freeze&&Object.freeze(K)}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(K);if(q.call(D,"key")){K=n(v);var L=Object.keys(D).filter(function(oe){return oe!=="key"});W=0<L.length?"{key: someKey, "+L.join(": ..., ")+": ...}":"{key: someKey}",pe[K+W]||(L=0<L.length?"{"+L.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
1
+ (function(ie,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],l):(ie=typeof globalThis<"u"?globalThis:ie||self,l(ie.OpenGridX={},ie.React,ie.ReactDOM))})(this,(function(ie,l,St){"use strict";var an={exports:{}},Yt={};var Qn;function Wo(){if(Qn)return Yt;Qn=1;var n=Symbol.for("react.transitional.element"),o=Symbol.for("react.fragment");function e(r,i,s){var c=null;if(s!==void 0&&(c=""+s),i.key!==void 0&&(c=""+i.key),"key"in i){s={};for(var a in i)a!=="key"&&(s[a]=i[a])}else s=i;return i=s.ref,{$$typeof:n,type:r,key:c,ref:i!==void 0?i:null,props:s}}return Yt.Fragment=o,Yt.jsx=e,Yt.jsxs=e,Yt}var Xt={};var Zn;function Fo(){return Zn||(Zn=1,process.env.NODE_ENV!=="production"&&(function(){function n(v){if(v==null)return null;if(typeof v=="function")return v.$$typeof===R?null:v.displayName||v.name||null;if(typeof v=="string")return v;switch(v){case M:return"Fragment";case E:return"Profiler";case P:return"StrictMode";case y:return"Suspense";case I:return"SuspenseList";case j:return"Activity"}if(typeof v=="object")switch(typeof v.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),v.$$typeof){case b:return"Portal";case C:return v.displayName||"Context";case k:return(v._context.displayName||"Context")+".Consumer";case _:var D=v.render;return v=v.displayName,v||(v=D.displayName||D.name||"",v=v!==""?"ForwardRef("+v+")":"ForwardRef"),v;case S:return D=v.displayName||null,D!==null?D:n(v.type)||"Memo";case x:D=v._payload,v=v._init;try{return n(v(D))}catch{}}return null}function o(v){return""+v}function e(v){try{o(v);var D=!1}catch{D=!0}if(D){D=console;var H=D.error,W=typeof Symbol=="function"&&Symbol.toStringTag&&v[Symbol.toStringTag]||v.constructor.name||"Object";return H.call(D,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",W),o(v)}}function r(v){if(v===M)return"<>";if(typeof v=="object"&&v!==null&&v.$$typeof===x)return"<...>";try{var D=n(v);return D?"<"+D+">":"<...>"}catch{return"<...>"}}function i(){var v=B.A;return v===null?null:v.getOwner()}function s(){return Error("react-stack-top-frame")}function c(v){if(Y.call(v,"key")){var D=Object.getOwnPropertyDescriptor(v,"key").get;if(D&&D.isReactWarning)return!1}return v.key!==void 0}function a(v,D){function H(){X||(X=!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)",D))}H.isReactWarning=!0,Object.defineProperty(v,"key",{get:H,configurable:!0})}function g(){var v=n(this.type);return G[v]||(G[v]=!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.")),v=this.props.ref,v!==void 0?v:null}function f(v,D,H,W,F,q){var K=H.ref;return v={$$typeof:w,type:v,key:D,props:H,_owner:W},(K!==void 0?K:null)!==null?Object.defineProperty(v,"ref",{enumerable:!1,get:g}):Object.defineProperty(v,"ref",{enumerable:!1,value:null}),v._store={},Object.defineProperty(v._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(v,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(v,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:F}),Object.defineProperty(v,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:q}),Object.freeze&&(Object.freeze(v.props),Object.freeze(v)),v}function p(v,D,H,W,F,q){var K=D.children;if(K!==void 0)if(W)if(A(K)){for(W=0;W<K.length;W++)m(K[W]);Object.freeze&&Object.freeze(K)}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(K);if(Y.call(D,"key")){K=n(v);var L=Object.keys(D).filter(function(oe){return oe!=="key"});W=0<L.length?"{key: someKey, "+L.join(": ..., ")+": ...}":"{key: someKey}",pe[K+W]||(L=0<L.length?"{"+L.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} />`,W,K,L,K),pe[K+W]=!0)}if(K=null,H!==void 0&&(e(H),K=""+H),c(D)&&(e(D.key),K=""+D.key),"key"in D){H={};for(var ae in D)ae!=="key"&&(H[ae]=D[ae])}else H=D;return K&&a(H,typeof v=="function"?v.displayName||v.name||"Unknown":v),f(v,K,H,i(),F,X)}function m(v){u(v)?v._store&&(v._store.validated=1):typeof v=="object"&&v!==null&&v.$$typeof===x&&(v._payload.status==="fulfilled"?u(v._payload.value)&&v._payload.value._store&&(v._payload.value._store.validated=1):v._store&&(v._store.validated=1))}function u(v){return typeof v=="object"&&v!==null&&v.$$typeof===w}var h=l,w=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),M=Symbol.for("react.fragment"),P=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),k=Symbol.for("react.consumer"),C=Symbol.for("react.context"),_=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),I=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),j=Symbol.for("react.activity"),R=Symbol.for("react.client.reference"),B=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,q=Object.prototype.hasOwnProperty,A=Array.isArray,U=console.createTask?console.createTask:function(){return null};h={react_stack_bottom_frame:function(v){return v()}};var Y,G={},ee=h.react_stack_bottom_frame.bind(h,s)(),Q=U(r(s)),pe={};Xt.Fragment=M,Xt.jsx=function(v,D,H){var W=1e4>B.recentlyCreatedOwnerStacks++;return p(v,D,H,!1,W?Error("react-stack-top-frame"):ee,W?U(r(v)):Q)},Xt.jsxs=function(v,D,H){var W=1e4>B.recentlyCreatedOwnerStacks++;return p(v,D,H,!0,W?Error("react-stack-top-frame"):ee,W?U(r(v)):Q)}})()),Xt}var eo;function Ao(){return eo||(eo=1,process.env.NODE_ENV==="production"?an.exports=Wo():an.exports=Fo()),an.exports}var t=Ao();function zo({row:n,rowIndex:o,listViewColumn:e,isSelected:r=!1,checkboxSelection:i=!1,rowHeight:s,onRowClick:c,onSelectionChange:a}){const g={row:n,value:void 0,field:e.field,colDef:{field:e.field},rowIndex:o,colIndex:0},f=p=>{p.stopPropagation(),a?.(n.id,p.target.checked)};return t.jsxs("div",{className:`ogx-list-view__row${r?" ogx-list-view__row--selected":""}`,style:s?{minHeight:s}:void 0,onClick:()=>c?.(n),role:"row","aria-rowindex":o+2,"aria-selected":r,children:[i&&t.jsx("div",{className:"ogx-list-view__checkbox",onClick:p=>p.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:r,onChange:f,"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,...i})=>{const s=l.useRef(null),c=l.useCallback(g=>{s.current=g,typeof r=="function"?r(g):r&&(r.current=g)},[r]);l.useEffect(()=>{s.current&&(s.current.indeterminate=n)},[n]);const a=["ogx-checkbox-wrapper",i.disabled&&"ogx-checkbox-wrapper--disabled",e].filter(Boolean).join(" ");return t.jsxs("label",{className:a,children:[t.jsx("input",{ref:c,type:"checkbox",className:"ogx-checkbox__input","aria-label":o||i["aria-label"]||(n?"Select some":i.checked?"Deselect":"Select"),...i}),t.jsxs("span",{className:"ogx-checkbox__box",children:[i.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:i=50,maxWidth:s=1e3}=n,[c,a]=l.useState(!1),g=l.useRef(0),f=l.useRef(0),p=l.useCallback(h=>{h.preventDefault(),h.stopPropagation(),a(!0),g.current=h.clientX,f.current=e;let w=0;const b=16,M=E=>{const k=E.clientX-g.current,C=Math.max(i,Math.min(s,f.current+k)),_=Date.now();_-w>=b&&(r(o,C),w=_)},P=E=>{a(!1);const k=E.clientX-g.current,C=Math.max(i,Math.min(s,f.current+k));r(o,C),document.removeEventListener("mousemove",M),document.removeEventListener("mouseup",P)};document.addEventListener("mousemove",M),document.addEventListener("mouseup",P)},[o,e,r,i,s]),m=l.useCallback(h=>{h.preventDefault(),h.stopPropagation()},[]),u=["ogx-column-resize-handle",c&&"ogx-column-resize-handle--dragging"].filter(Boolean).join(" ");return t.jsx("div",{className:u,onMouseDown:p,onClick:h=>h.stopPropagation(),onDragStart:h=>{h.preventDefault(),h.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=[],i=[];return o?(n.forEach(s=>{const c=dn(s.field,o);c==="left"?e.push(s):c==="right"?i.push(s):r.push(s)}),o.left&&e.sort((s,c)=>{const a=o.left.indexOf(s.field),g=o.left.indexOf(c.field);return a-g}),o.right&&i.sort((s,c)=>{const a=o.right.indexOf(s.field),g=o.right.indexOf(c.field);return a-g}),{left:e,center:r,right:i}):{left:e,center:n,right:i}}function to(n,o,e,r,i,s,c,a){const g={};if(!e)return g;const f=$o(n,e);let p=0;a&&(p+=48),s&&c&&(p+=48),r&&i&&(p+=48),f.left.forEach(u=>{g[u.field]=p;const h=o[u.field]??u.width??100;p+=h});let m=0;return[...f.right].reverse().forEach(u=>{const h=o[u.field]??u.width??100;g[u.field]=m,m+=h}),g}function jn(n,o){return o?o.top?.includes(n)?"top":o.bottom?.includes(n)?"bottom":null:null}function Do(n,o){const e=[],r=[],i=[];return o?(n.forEach(s=>{const c=jn(s.id,o);c==="top"?e.push(s):c==="bottom"?i.push(s):r.push(s)}),o.top&&e.sort((s,c)=>{const a=o.top.indexOf(s.id),g=o.top.indexOf(c.id);return a-g}),o.bottom&&i.sort((s,c)=>{const a=o.bottom.indexOf(s.id),g=o.bottom.indexOf(c.id);return a-g}),{top:e,center:r,bottom:i}):{top:e,center:n,bottom:i}}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:i,pinnedColumns:s,onManageColumns:c,onClose:a,anchorEl:g}){const f=l.useRef(null),[p,m]=l.useState({position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"});l.useLayoutEffect(()=>{if(!g||!f.current)return;const _=g.getBoundingClientRect(),y=f.current.getBoundingClientRect(),I=window.innerWidth,S=window.innerHeight,x=8;let j=_.left;j+y.width+x>I&&(j=I-y.width-x),j<x&&(j=x);let R=_.bottom+4;R+y.height+x>S&&(R=_.top-y.height-4),m({position:"fixed",zIndex:1300,top:R,left:j,visibility:"visible"})},[g]),l.useEffect(()=>{function _(I){f.current&&!f.current.contains(I.target)&&g&&!g.contains(I.target)&&a()}function y(I){I.key==="Escape"&&a()}return document.addEventListener("mousedown",_),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",_),document.removeEventListener("keydown",y)}},[g,a]);const u=_=>{e?.(n.field,_),a()},h=()=>{r?.(n.field),a()},w=_=>{i?.(n.field,_),a()},b=o?.find(_=>_.field===n.field)?.sort,M=b==null,P=s?.left?.includes(n.field)??!1,E=s?.right?.includes(n.field)??!1,k=!P&&!E,C=n.headerName||n.field;return St.createPortal(t.jsxs("div",{ref:f,className:"ogx-column-menu",style:p,role:"menu","aria-label":`Column options for ${C}`,children:[e&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{className:`ogx-menu-item${b==="asc"?" ogx-menu-item--active":""}`,onClick:()=>u("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:()=>u("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${M?" ogx-menu-item--active":""}`,onClick:()=>u(null),role:"menuitemradio","aria-checked":M,children:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:M?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:()=>w("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${E?" ogx-menu-item--active":""}`,onClick:()=>w("right"),role:"menuitemradio","aria-checked":E,"aria-label":"Pin to right",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(Xo,{})}),"Pin to Right"]}),t.jsxs("button",{className:`ogx-menu-item${k?" ogx-menu-item--active":""}`,onClick:()=>w(null),role:"menuitemradio","aria-checked":k,"aria-label":"Unpin column",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(qo,{})}),"Unpin"]}),t.jsx("div",{className:"ogx-menu-divider"}),t.jsxs("button",{className:"ogx-menu-item",onClick:h,role:"menuitem","aria-label":`Hide ${C} 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:()=>{c?.(),a()},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"]})]}),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,i){o=Math.max(o,i);for(const s of r.children)typeof s!="string"&&e(s,i+1)}return n.forEach(r=>e(r,1)),o}function tr(n,o,e){function r(a,g,f){if(!no(a).includes(g))return null;if(f===e)return a;for(const p of a.children)if(typeof p!="string"){const m=r(p,g,f+1);if(m)return m}return null}const i=new Map;for(const a of o){let g=null;for(const f of n)if(g=r(f,a.field,0),g)break;i.set(a.field,g)}const s=[];let c=0;for(;c<o.length;){const a=o[c],g=i.get(a.field)??null,f=a.width;if(!g)s.push({key:`fg-${a.field}-${e}`,label:"",width:f,isGroup:!1}),c++;else{let p=0,m=c;for(;m<o.length&&i.get(o[m].field)===g;)p+=o[m].width,m++;s.push({key:`${g.groupId}-${e}`,label:g.headerName,width:p,isGroup:!0}),c=m}}return s}function oo(n){const{columns:o,allColumns:e,columnGroupingModel:r,checkboxSelection:i=!1,allSelected:s=!1,someSelected:c=!1,onSelectAll:a,onSort:g,sortModel:f=[],onColumnResize:p,columnWidths:m={},pinnedColumns:u,hasDetailPanel:h=!1,pinCheckboxColumn:w=!0,pinExpandColumn:b=!0,rowReordering:M=!1,aggregationModel:P,draggedColumn:E,dragOverColumn:k,onDragStart:C,onDragOver:_,onDragEnd:y,onDrop:I,focusedCell:S,onHeaderClick:x,onHideColumn:j,onPinColumn:R,onManageColumns:B}=n,q=l.useRef({}),[A,U]=l.useState(null),Y=L=>ae=>{ae.stopPropagation(),U({colDef:L,anchorEl:ae.currentTarget})},G=()=>{U(null)};l.useLayoutEffect(()=>{if(S?.id==="HEADER"){const L=q.current[S.field];L&&L.focus()}},[S]);const ee=L=>()=>{if(L.sortable===!1||!g)return;const ae=f.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=f.find(oe=>oe.field===L);return ae?t.jsx("span",{className:`ogx__sort-icon ogx__sort-icon--${ae.sort}`,"aria-hidden":"true"}):null},pe=l.useMemo(()=>to(o,m,u,i,w,h,b,M),[o,m,u,i,w,h,b,M]),v=r?er(r):0,H=(e??o).filter(L=>!L.isSpacer).map(L=>({field:L.field,width:m[L.field]??L.width??100})),K=(M?48:0)+(h?48:0)+(i?48:0);return t.jsxs("div",{className:"ogx__header-wrap",children:[v>0&&Array.from({length:v},(L,ae)=>{const oe=tr(r,H,ae);return t.jsxs("div",{className:"ogx-col-group-row",role:"row",children:[K>0&&t.jsx("div",{className:"ogx-col-group-cell ogx-col-group-cell--filler",style:{width:K,minWidth:K,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:[M&&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}}),h&&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?M?48:0:void 0,zIndex:b?5:void 0}}),i&&t.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?(M?48:0)+(h&&b?48:0):void 0},children:t.jsx(qt,{id:"ogx-select-all",name:"ogx-select-all",checked:s,indeterminate:c,onChange:L=>a?.(L.target.checked),"aria-label":s?"Deselect all rows":"Select all rows",tabIndex:S?.id==="HEADER"&&S.field==="__checkbox_col__"?0:-1,onMouseDown:L=>L.preventDefault(),inputRef:L=>{q.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=f.some(ze=>ze.field===L.field),Ze=L.resizable!==!1,z=dn(L.field,u),Ee=z!==null,Ne=E===L.field,ct=k===L.field,De=["ogx__header-cell",`ogx__header-cell--align-${L.headerAlign||L.align||"left"}`,oe&&"ogx__header-cell--sortable",me&&"ogx__header-cell--sorted",Ee&&"ogx__header-cell--pinned",Ee&&`ogx__header-cell--pinned-${z}`,Ne&&"ogx__header-cell--dragging",ct&&"ogx__header-cell--drag-over",S?.id==="HEADER"&&S.field===L.field&&"ogx__header-cell--focused",L.headerClassName].filter(Boolean).join(" "),ut=m[L.field]??L.width??100,gt={width:ut,minWidth:L.minWidth,maxWidth:L.maxWidth,flexGrow:L.flex??0,flexShrink:0,flexBasis:(L.flex,"auto"),boxSizing:"border-box",position:Ee?"sticky":"relative",zIndex:L.zIndex,opacity:Ne?.5:1};if(Ee&&z){const ze=pe[L.field];z==="left"?gt.left=ze:gt.right=ze}const en=L.renderHeader?L.renderHeader({field:L.field,colDef:L,colIndex:ae}):L.headerName||L.field,Rt=ze=>{if(ze.target.closest(".ogx-column-resize-handle")){ze.stopPropagation();return}x?.(L.field),oe&&ee(L)()},jt=C?C(L.field):void 0,Ot=_?_(L.field):void 0,vt=I?I(L.field):void 0;return t.jsxs("div",{className:De,style:gt,onClick:Rt,role:"columnheader",draggable:!!C,onDragStart:jt,onDragOver:Ot,onDragEnd:y,onDrop:vt,"aria-sort":oe?me?f.find(ze=>ze.field===L.field)?.sort==="asc"?"ascending":"descending":"none":void 0,"aria-colindex":ae+1+(i?1:0),"data-field":L.field,tabIndex:-1,ref:ze=>{q.current[L.field]=ze},children:[t.jsxs("div",{className:"ogx__header-cell-content",children:[Ne&&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:Y(L),"aria-label":`Open column menu for ${L.headerName||L.field}`,"aria-haspopup":"menu",tabIndex:-1,children:t.jsx(Qo,{})})]}),Ze&&p&&t.jsx(Bo,{field:L.field,currentWidth:ut,onResize:p,minWidth:L.minWidth,maxWidth:L.maxWidth})]},L.field)}),A&&t.jsx(Jo,{colDef:A.colDef,sortModel:f,onSort:g,onHide:j,onPin:R,pinnedColumns:u,onManageColumns:B,onClose:G,anchorEl:A.anchorEl})]})]})}function nr({value:n,onValueChange:o,onCommit:e,onCancel:r}){const[i,s]=l.useState(String(n??"")),c=l.useRef(null);return l.useEffect(()=>{c.current?.focus(),c.current?.select()},[]),t.jsx("input",{ref:c,type:"text",className:"ogx__edit-input",value:i,onChange:a=>{s(a.target.value),o(a.target.value)},onBlur:e,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),e()),a.key==="Escape"&&(a.stopPropagation(),r())}})}function or({value:n,onValueChange:o,onCommit:e,onCancel:r}){const[i,s]=l.useState(n??""),c=l.useRef(null);return l.useEffect(()=>{c.current?.focus(),c.current?.select()},[]),t.jsx("input",{ref:c,type:"number",className:"ogx__edit-input ogx__edit-input--number",value:i,onChange:a=>{const g=a.target.value===""?"":Number(a.target.value);s(g),o(g===""?null:g)},onBlur:e,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),e()),a.key==="Escape"&&(a.stopPropagation(),r())}})}function rr({value:n,onValueChange:o,onCommit:e,onCancel:r}){const i=l.useRef(null);l.useEffect(()=>{i.current?.focus()},[]);const s=()=>{o(!n),setTimeout(e,0)};return t.jsx("div",{className:"ogx__edit-boolean",children:t.jsx("input",{ref:i,type:"checkbox",className:"ogx__edit-checkbox",checked:!!n,onChange:s,onKeyDown:c=>{c.key==="Escape"&&(c.stopPropagation(),r())}})})}function ir({value:n,colDef:o,onValueChange:e,onCommit:r,onCancel:i}){const s=l.useRef(null);l.useEffect(()=>{s.current?.focus()},[]);const c=o.valueOptions??[];return t.jsx("select",{ref:s,className:"ogx__edit-select",value:n??"",onChange:a=>{e(a.target.value)},onBlur:r,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),r()),a.key==="Escape"&&(a.stopPropagation(),i())},children:c.map(a=>{const g=typeof a=="object"?a.value:a,f=typeof a=="object"?a.label:String(a);return t.jsx("option",{value:String(g),children:f},String(g))})})}function lr({value:n,onValueChange:o,onCommit:e,onCancel:r}){const[i,s]=l.useState(n??""),c=l.useRef(null);return l.useEffect(()=>{c.current?.focus()},[]),t.jsx("input",{ref:c,type:"date",className:"ogx__edit-input",value:i,onChange:a=>{s(a.target.value),o(a.target.value)},onBlur:e,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),e()),a.key==="Escape"&&(a.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:i,row:s,colDef:c,rowIndex:a,colIndex:g,isSelected:f,onClick:p,width:m,pinnedPosition:u,pinnedOffset:h,isFocused:w,isFocusVisible:b,isEditable:M,isEditing:P,onEditStart:E,onEditStop:k,onValueChange:C,colSpanInfo:_,rowSpan:y,isHiddenByRowSpan:I}=n;if(_?.spannedByColSpan)return null;if(I)return t.jsx("div",{className:"ogx__cell ogx__cell--hidden",style:{width:m??c.width??100},role:"presentation","data-field":c.field,"data-colindex":g});const S=v=>{o&&(v.stopPropagation(),o({row:s,field:c.field,value:i,colDef:c,rowIndex:a,colIndex:g})),p?.(v)},x=l.useCallback(v=>{r?r(c.field,v):C?.(v)},[r,C,c.field]),j=v=>{M&&(E||e)&&(v.stopPropagation(),e?e(c.field,i):E?.())},R=l.useMemo(()=>c.valueFormatter?c.valueFormatter({value:i,row:s,field:c.field}):i==null?"":String(i),[i,s,c]),B=l.useMemo(()=>P&&(r||C)&&k?c.renderEditCell?c.renderEditCell({value:i,row:s,field:c.field,colDef:c,rowIndex:a,colIndex:g}):t.jsx(sr,{value:i,row:s,field:c.field,colDef:c,rowIndex:a,colIndex:g,onValueChange:x,onCommit:()=>k(),onCancel:()=>k(!0)}):c.renderCell?c.renderCell({value:i,row:s,field:c.field,colDef:c,rowIndex:a,colIndex:g}):R,[i,s,c,a,g,R,P,x,k,r,C]),q=u!=null,A=l.useMemo(()=>c.cellClassName?typeof c.cellClassName=="function"?c.cellClassName({value:i,row:s,field:c.field,colDef:c,rowIndex:a,colIndex:g})||"":c.cellClassName:"",[c,i,s,a,g]),U=["ogx__cell",`ogx__cell--align-${c.align||"left"}`,f&&"ogx__cell--selected",w&&"ogx__cell--focused",w&&b&&"ogx__cell--focus-visible",c.type&&`ogx__cell--type-${c.type}`,q&&"ogx__cell--pinned",q&&`ogx__cell--pinned-${u}`,P&&"ogx__cell--editing",y&&y>1&&"ogx__cell--spanned",A].filter(Boolean).join(" "),Y=_?.cellProps?.colSpan||1,G=y||1,ee=_?.cellProps?.width??m??c.width??100,Q={width:"var(--width)","--width":typeof ee=="number"?`${ee}px`:ee,flexGrow:c.flex??0,flexShrink:0,flexBasis:(c.flex,"auto"),boxSizing:"border-box",minWidth:c.minWidth,maxWidth:c.maxWidth,position:q?"sticky":void 0,zIndex:c.zIndex??(q?3:void 0),padding:P?0:void 0};G>1&&(Q.height=`calc(var(--height) * ${G} - var(--border-width, 1px))`,Q.zIndex=10,q&&(Q.zIndex=40)),q&&h!==void 0&&(u==="left"?Q.left=h:Q.right=h);const pe=l.useRef(null);return l.useLayoutEffect(()=>{w&&pe.current&&pe.current.focus({preventScroll:!0})},[w]),t.jsx("div",{ref:pe,className:U,style:Q,onClick:S,onDoubleClick:j,role:"gridcell","aria-colindex":g+1,"aria-readonly":!M||void 0,tabIndex:-1,"data-field":c.field,"data-colindex":g,...Y>1?{"aria-colspan":Y}:{},...G>1?{"aria-rowspan":G}:{},children:t.jsx("div",{className:"ogx__cell-content",children:B})})}const ro=l.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 i={height:e==="auto"?"auto":`${e}px`,overflow:e==="auto"?"visible":"auto"};return t.jsx("div",{className:"ogx__detail-panel",style:i,children:t.jsx("div",{className:"ogx__detail-panel-content",children:o})})}function Jt(n){const{row:o,columns:e,rowIndex:r,isSelected:i=!1,checkboxSelection:s=!1,onRowClick:c,onCellClick:a,onSelectionChange:g,columnWidths:f={},pinnedColumns:p,pinnedRows:m,hasDetailPanel:u=!1,isDetailPanelExpanded:h=!1,onDetailPanelToggle:w,detailPanelContent:b,detailPanelHeight:M=200,pinCheckboxColumn:P=!0,pinExpandColumn:E=!0,rowReordering:k=!1,onDragStart:C,onDragOver:_,onDragEnd:y,onDrop:I,isDragging:S,isDragOver:x,editingCell:j,onEditStart:R,onEditStop:B,onEditCellValueChange:q,focusedCellField:A,isFocusVisible:U,colspanMap:Y,rowSpanningCaches:G,rowHeight:ee=52}=n,Q=l.useRef(null),pe=l.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((Ee,Ne)=>t.jsx("div",{className:"ogx__skeleton-cell",children:t.jsx("div",{className:"ogx__skeleton-bar"})},Ne))})}l.useLayoutEffect(()=>{A==="__expand_col__"&&Q.current&&Q.current.focus({preventScroll:!0}),A==="__checkbox_col__"&&pe.current&&pe.current.focus({preventScroll:!0})},[A]);const v=z=>{z.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell")||c?.({row:o,id:o.id,rowIndex:r})},D=z=>{z.stopPropagation(),g?.(o.id,z.target.checked)},H=z=>{z.stopPropagation(),w?.(o.id)},W=l.useMemo(()=>to(e,f,p,s,P,u,E,k),[e,f,p,s,P,u,E,k]),F=jn(o.id,m),X=F==="top",K=F==="bottom",L=o._hasChildren===!0,ae=l.useCallback((z,Ee)=>{L||R?.({id:o.id,field:z,value:Ee})},[L,o.id,R]),oe=l.useCallback((z,Ee)=>{q?.({id:o.id,field:z,value:Ee})},[q,o.id]),me=l.useCallback(z=>{B?.({cancel:z})},[B]),Ze=["ogx__row",i&&"ogx__row--selected",r%2===0&&"ogx__row--even",r%2===1&&"ogx__row--odd",X&&"ogx__row--pinned-top",K&&"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:v,role:"row","aria-rowindex":r+1,"aria-selected":i,"data-rowindex":r,onDragOver:_?_(o.id):void 0,onDrop:I?I(o.id):void 0,style:{maxHeight:`${ee}px`,minHeight:`${ee}px`,"--height":`${ee}px`,"--border-width":"1px"},children:[k&&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:C?C(o.id):void 0,onDragEnd:y,onClick:z=>z.stopPropagation(),children:t.jsx(dr,{})}),u&&t.jsx("div",{className:`ogx__cell ogx__cell--expand ${E?"ogx__cell--pinned-left":""} ${A==="__expand_col__"?"ogx__cell--focused":""} ${A==="__expand_col__"&&U?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":h?"Collapse row details":"Expand row details","aria-expanded":h,style:{position:E?"sticky":void 0,left:E?k?48:0:void 0,zIndex:E?5:void 0},ref:Q,tabIndex:-1,onClick:z=>{z.stopPropagation(),a?.({row:o,field:"__expand_col__",value:h,colDef:{field:"__expand_col__",width:48},rowIndex:r,colIndex:-1})},children:t.jsx(io,{isExpanded:h,onClick:H,variant:"plus-minus"})}),s&&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?(k?48:0)+(u&&E?48:0):void 0,zIndex:P?11:void 0},ref:pe,tabIndex:-1,onClick:z=>{z.stopPropagation(),a?.({row:o,field:"__checkbox_col__",value:i,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:i,onChange:D,onClick:z=>z.stopPropagation(),"aria-label":i?`Deselect row ${o.id}`:`Select row ${o.id}`,tabIndex:-1,onMouseDown:z=>z.preventDefault()})}),e.map((z,Ee)=>{if(z.isSpacer)return t.jsx("div",{style:{width:z.width,minWidth:z.width,flexShrink:0},"aria-hidden":"true"},z.field);const Ne=z.valueGetter?z.valueGetter({row:o,field:z.field,value:o[z.field]}):o[z.field],ct=f[z.field]??z.width,De=dn(z.field,p),ut=De?W[z.field]:void 0,gt=j?.id===o.id&&j?.field===z.field,en=gt?j?.value:Ne,Rt=Y?.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:Ee,isSelected:i,onCellClick:a,width:ct,pinnedPosition:De,pinnedOffset:ut,isFocused:A===z.field,isFocusVisible:U,isEditable:z.editable,isEditing:gt,onCellEditStart:ae,onEditStop:me,onCellValueChange:oe,colSpanInfo:Rt,rowSpan:jt,isHiddenByRowSpan:Ot},z.field)})]}),u&&t.jsx(cr,{row:o,rowId:o.id,rowIndex:r,content:b,height:M,isExpanded:h})]})}const ur=({columns:n,rowHeight:o,checkboxSelection:e=!1,hasDetailPanel:r=!1,rowReordering:i=!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}})}),i&&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((s,c)=>{const a=s.width||150,g=Math.min(a*.7,a-20);return t.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:a,minWidth:s.minWidth,maxWidth:s.maxWidth,left:s.left,right:s.right,position:s.isSpacer?"relative":s.pinned?"sticky":"relative",zIndex:s.zIndex},children:!s.isSpacer&&t.jsx("div",{className:"ogx-skeleton-box",style:{width:g,height:16,borderRadius:4}})},s.field||c)})]}),Qt=({variant:n="text",size:o="medium",color:e="default",disabled:r=!1,className:i="",children:s,...c})=>{const a=["ogx-button",`ogx-button--${n}`,`ogx-button--${o}`,`ogx-button--${e}`,r&&"ogx-button--disabled",i].filter(Boolean).join(" ");return t.jsx("button",{className:a,disabled:r,...c,children:s})};function lo(n){const{page:o,pageSize:e,rowCount:r,onPageChange:i,onPageSizeChange:s,pageSizeOptions:c=[10,25,50,100],showFirstButton:a=!0,showLastButton:g=!0}=n,f=Math.max(1,Math.ceil(r/e)),p=Math.min(o,f-1),m=p*e,u=Math.min(m+e,r),h=r===0?0:`${m+1}–${u}`,w=()=>{i(0)},b=()=>{i(Math.max(0,p-1))},M=()=>{i(Math.min(f-1,p+1))},P=()=>{i(f-1)},E=_=>{const y=parseInt(_.target.value,10);s(y)},k=p===0,C=p>=f-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:E,"aria-label":"Rows per page",children:c.map(_=>t.jsx("option",{value:_,children:_},_))})]}),t.jsxs("div",{className:"ogx-pagination__info","aria-live":"polite","aria-atomic":"true",children:[h," of ",r]}),t.jsxs("div",{className:"ogx-pagination__actions",children:[a&&t.jsx(Qt,{variant:"text",size:"small",onClick:w,disabled:k,"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:k,"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 ",p+1," of ",f]}),t.jsx(Qt,{variant:"text",size:"small",onClick:M,disabled:C,"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:C,"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 gr(n,o,e={}){const r=new Map,i=[];n.forEach(a=>{const g=a.id;r.set(g,a),i.push(g)});const s=new Map,c=[];return o.forEach(a=>{s.set(a.field,a),c.push(a.field)}),{rows:{idRowsLookup:r,allRows:i},columns:{all:o,lookup:s,orderedFields:c,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 fr(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,i=new Map,s=[];return r.forEach(c=>{i.set(c.id,c),s.push(c.id)}),{...n,rows:{idRowsLookup:i,allRows:s},pagination:{...n.pagination,rowCount:o.preserveRowCount?n.pagination.rowCount:r.length}}}case"SET_COLUMNS":{const e=new Map,r=[];return o.payload.forEach(i=>{e.set(i.field,i),r.push(i.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:i=56,columnVisibilityModel:s,initialState:c}=n,a=l.useMemo(()=>gr(o,e,s),[]),[g,f]=l.useReducer(fr,{...a,sorting:c?.sorting||a.sorting,filter:c?.filter||a.filter,dataSource:c?.dataSource?{...a.dataSource,...c.dataSource}:a.dataSource,pagination:{...a.pagination,...c?.pagination||{},rowCount:n.rowCount??c?.pagination?.rowCount??a.pagination.rowCount},dimensions:{...a.dimensions,rowHeight:r,headerHeight:i}}),p=l.useRef(g);p.current=g;const m=l.useRef(o);l.useEffect(()=>{o!==m.current&&(m.current=o,f({type:"SET_ROWS",payload:o}))},[o]);const u=l.useCallback((S,x)=>{f({type:"SET_ROWS",payload:S,preserveRowCount:x})},[]),h=l.useCallback(S=>{f({type:"SET_COLUMNS",payload:S})},[]),w=l.useCallback(S=>{f({type:"SET_SORT_MODEL",payload:S})},[]),b=l.useCallback(S=>{f({type:"SET_FILTER_MODEL",payload:S})},[]),M=l.useCallback(S=>{f({type:"SET_PAGINATION_MODEL",payload:S})},[]),P=l.useCallback(S=>{f({type:"SET_SELECTION",payload:S})},[]),E=l.useCallback((S,x)=>{f({type:"SET_SCROLL",payload:{scrollTop:S,scrollLeft:x}})},[]),k=l.useCallback((S,x)=>{f({type:"SET_DIMENSIONS",payload:{viewportWidth:S,viewportHeight:x}})},[]),C=l.useCallback(S=>{f({type:"SET_DATASOURCE_LOADING",payload:S})},[]),_=l.useCallback(S=>{f({type:"SET_DATASOURCE_ERROR",payload:S})},[]),y=l.useCallback(S=>{f({type:"SET_ROW_COUNT",payload:S})},[]),I=l.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,x=!0)=>{const j=new Set(p.current.selection.selectedRows);x?j.add(S):j.delete(S),P(j)},selectRows:(S,x=!0)=>{const j=new Set(p.current.selection.selectedRows);S.forEach(R=>{x?j.add(R):j.delete(R)}),P(j)},getSelectedRows:()=>Array.from(p.current.selection.selectedRows),sortColumn:(S,x)=>{if(x===null)w(p.current.sorting.sortModel.filter(j=>j.field!==S));else{const j=p.current.sorting.sortModel.findIndex(R=>R.field===S);if(j>=0){const R=[...p.current.sorting.sortModel];R[j]={field:S,sort:x},w(R)}else w([...p.current.sorting.sortModel,{field:S,sort:x}])}},getSortModel:()=>p.current.sorting.sortModel,setFilterModel:b,getFilterModel:()=>p.current.filter.filterModel,setPage:S=>{M({...p.current.pagination.paginationModel,page:S})},setPageSize:S=>{M({...p.current.pagination.paginationModel,pageSize:S,page:0})},scrollToIndexes:()=>{},copySelectedRows:()=>Promise.resolve()});return{state:g,dispatch:f,apiRef:I,setRows:u,setColumns:h,setSortModel:w,setFilterModel:b,setPaginationModel:M,setSelection:P,setScroll:E,setDimensions:k,setDataSourceLoading:C,setDataSourceError:_,setRowCount:y}}function pr(n){const{columns:o,onColumnOrderChange:e,disableColumnReorder:r=!1}=n,[i,s]=l.useState(null),[c,a]=l.useState(null),g=l.useRef(-1),f=l.useCallback(h=>w=>{if(r)return;const b=o.findIndex(P=>P.field===h);if(o[b]?.pinnable===!1){w.preventDefault();return}s(h),g.current=b,w.dataTransfer&&(w.dataTransfer.effectAllowed="move",w.dataTransfer.setData("text/plain",h))},[o,r]),p=l.useCallback(h=>w=>{r||!i||(w.preventDefault(),w.dataTransfer.dropEffect="move",a(h))},[i,r]),m=l.useCallback(h=>w=>{if(w.preventDefault(),r||!i||i===h){s(null),a(null);return}const b=o.findIndex(E=>E.field===i),M=o.findIndex(E=>E.field===h);if(b===-1||M===-1){s(null),a(null);return}const P=o[b];e&&e({column:P,oldIndex:b,targetIndex:M}),s(null),a(null),g.current=-1},[o,i,r,e]),u=l.useCallback(()=>{s(null),a(null),g.current=-1},[]);return{draggedColumn:i,dragOverColumn:c,onDragStart:r?void 0:f,onDragOver:r?void 0:p,onDragEnd:r?void 0:u,onDrop:r?void 0:m}}function xr(n){const{onRowOrderChange:o,rows:e,getRowId:r,rowReordering:i=!1}=n,[s,c]=l.useState(null),[a,g]=l.useState(null),f=l.useCallback(w=>r?r(w):w.id,[r]),p=l.useCallback(w=>b=>{i&&(c(w),b.dataTransfer.effectAllowed="move")},[i]),m=l.useCallback(w=>b=>{!i||!s||(b.preventDefault(),b.dataTransfer.dropEffect="move",a!==w&&g(w))},[i,s,a]),u=l.useCallback(()=>{c(null),g(null)},[]),h=l.useCallback(w=>b=>{if(b.preventDefault(),!s||!o){u();return}const M=e.findIndex(E=>f(E)===s),P=e.findIndex(E=>f(E)===w);M!==-1&&P!==-1&&M!==P&&o({row:e[M],oldIndex:M,targetIndex:P}),u()},[s,o,e,f,u]);return{draggedRowId:s,dragOverRowId:a,onDragStart:i?p:void 0,onDragOver:i?m:void 0,onDragEnd:i?u:void 0,onDrop:i?h: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:i}=o,s=n[e],c=mr[r];return c?c(s,i):(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(i=>i==null?!1:String(i).toLowerCase().includes(r))})}function En(n,o){const e=o.items||[],r=o.logicOperator||"and",i=o.quickFilterValues||[];if(i.length>0&&!wr(n,i))return!1;if(e.length===0)return!0;const s=c=>{if("logicOperator"in c&&"items"in c){const a=c,g=a.items;return g.length===0?!0:a.logicOperator==="and"?g.every(s):g.some(s)}else return br(n,c)};return r==="and"?e.every(s):e.some(s)}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(i=>En(i,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 Nn(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(),i=String(o).toLowerCase();return e==="asc"?r<i?-1:r>i?1:0:r>i?-1:r<i?1:0}function Cr(n,o){if(o.length===0)return n;const e=[...n];return e.sort((r,i)=>{for(const s of o){const c=r[s.field],a=i[s.field],g=Nn(c,a,s.sort);if(g!==0)return g}return 0}),e}function yr(n){const{rows:o,getRowId:e,getTreeDataPath:r,treeData:i=!1,defaultGroupingExpansionDepth:s=0,filterModel:c,sortModel:a,onRowExpansionChange:g}=n,{treeNodes:f,rootIds:p,groupingRows:m}=l.useMemo(()=>{if(!i||!r)return{treeNodes:new Map,rootIds:[],groupingRows:[]};const C=new Map,_=[],y=[],I=new Map,S=x=>x.join("/");return o.forEach(x=>{const j=e(x),R=r(x),B=S(R);I.set(B,j),C.set(j,{id:j,parentId:null,depth:R.length-1,groupingKey:R[R.length-1],isExpanded:!1,children:[],serverChildrenCount:x.serverChildrenCount})}),o.forEach(x=>{const j=e(x),R=r(x);if(R.length===1){_.push(j);return}const B=A=>{if(A.length<=1)return;const U=A.slice(0,-1),Y=S(U);let G=I.get(Y);if(G===void 0&&(G=`auto-group-${Y}`,!C.has(G))){const ee=U[U.length-1];C.set(G,{id:G,parentId:null,depth:U.length-1,groupingKey:ee,isExpanded:!1,children:[],label:ee}),I.set(Y,G);const Q={id:G,name:ee,_isGroupRow:!0};y.push(Q),U.length===1&&_.push(G),B(U)}return G},q=B(R);if(q!==void 0){const A=C.get(q),U=C.get(j);A&&U&&(U.parentId=q,A.children=A.children||[],A.children.includes(j)||A.children.push(j))}}),y.forEach(x=>{const j=x.id,R=C.get(j);if(!R)return;const q=j.replace("auto-group-","").split("/");if(q.length>1){const A=q.slice(0,-1),U=S(A),Y=I.get(U);if(Y&&C.has(Y)){R.parentId=Y;const G=C.get(Y);G&&(G.children=G.children||[],G.children.includes(j)||G.children.push(j))}}}),{treeNodes:C,rootIds:_,groupingRows:y}},[o,r,i,e]),u=l.useMemo(()=>{if(!i)return new Set;const C=new Set;return f.forEach(_=>{_.children&&_.children.length>0&&(s===-1||_.depth<s)&&C.add(_.id)}),C},[f,i,s]),[h,w]=l.useState(new Set);l.useEffect(()=>{u.size>0&&w(u)},[u]);const b=l.useCallback(C=>{w(_=>{const y=new Set(_),I=!y.has(C);if(y.has(C)?y.delete(C):y.add(C),I&&g){const S=f.get(C);S&&g(S)}return y})},[f,g]),M=l.useCallback(()=>{if(!i)return null;const C=new Map;o.forEach(B=>C.set(e(B),B)),m.forEach(B=>C.set(B.id,B));const _=B=>En(B,c),y=new Map,I=B=>{if(y.has(B))return y.get(B);const q=C.get(B);if(!q)return!1;if(_(q))return y.set(B,!0),!0;const U=f.get(B);return U&&U.children&&U.children.some(G=>I(G))?(y.set(B,!0),!0):(y.set(B,!1),!1)},S=(B,q)=>{if(!a||a.length===0)return 0;const A=C.get(B),U=C.get(q);if(!A||!U)return 0;for(const Y of a){const G=A[Y.field],ee=U[Y.field],Q=Nn(G,ee,Y.sort);if(Q!==0)return Q}return 0},x=[],j=new Set,R=B=>{const q=B.filter(A=>I(A));q.sort(S),q.forEach(A=>{if(j.has(A))return;const U=C.get(A),Y=f.get(A);if(U&&Y){j.add(A);const G={...U,_treeDepth:Y.depth,_isExpanded:h.has(A),_hasChildren:Y.children&&Y.children.length>0||Y.serverChildrenCount&&Y.serverChildrenCount>0,_descendantCount:Y.children?Y.children.length:0};x.push(G),h.has(A)&&Y.children&&Y.children.length>0&&R(Y.children)}})};return R(p),x},[i,o,m,p,f,h,c,a,e]),P=l.useCallback(C=>h.has(C),[h]),E=l.useCallback(C=>f.get(C),[f]),k=l.useCallback(C=>{const _=[];let y=C;for(;y!==null;){const I=f.get(y);if(!I)break;_.unshift(I.groupingKey),y=I.parentId}return _},[f]);return l.useMemo(()=>({treeNodes:f,groupingRows:m,toggleExpansion:b,isGroupExpanded:P,getVisibleRows:M,getNode:E,getNodePath:k}),[f,m,b,P,M,E,k])}const kr=n=>n?.depth===-1?"footer":"inline";function Sr(n){const{rows:o,getRowId:e,rowGroupingModel:r=[],aggregationModel:i={},defaultGroupingExpansionDepth:s=0,filterModel:c,sortModel:a,getAggregationPosition:g=kr}=n,[f,p]=l.useState(new Set),{treeNodes:m,rootIds:u,groupingRows:h}=l.useMemo(()=>{const E=new Map,k=new Map,C=[];if(r.length===0)return{treeNodes:E,rootIds:C,groupingRows:k};const _=(S,x,j)=>`auto-group-${S}-${x}-${j||"root"}`,y=(S,x,j)=>{if(x>=r.length)return S.map(A=>{const U=e(A);return E.set(U,{id:U,parentId:j,depth:x,groupingKey:"",isExpanded:!1}),U});const R=r[x],B=new Map;S.forEach(A=>{const U=A[R],Y=String(U);B.has(Y)||B.set(Y,[]),B.get(Y).push(A)});const q=[];return B.forEach((A,U)=>{const G=A[0][R],ee=_(R,U,j);q.push(ee);const Q={};i&&Object.entries(i).forEach(([W,F])=>{const X=A.map(K=>K[W]);if(F==="sum")Q[W]=X.reduce((K,L)=>(Number(K)||0)+(Number(L)||0),0);else if(F==="min")Q[W]=Math.min(...X.map(K=>Number(K)||0));else if(F==="max")Q[W]=Math.max(...X.map(K=>Number(K)||0));else if(F==="avg"){const K=X.reduce((L,ae)=>(Number(L)||0)+(Number(ae)||0),0);Q[W]=X.length?K/X.length:0}else F==="count"&&(Q[W]=X.length)});const pe={[R]:G,...Q,id:ee};k.set(ee,pe);const v={id:ee,parentId:j,depth:x,groupingKey:U,groupingField:R,groupingValue:G,aggregatedValues:Q,isExpanded:!1,children:[],label:`${R}: ${String(G)}`};v.aggregationPosition=g(v),E.set(ee,v);const D=y(A,x+1,ee);E.get(ee).children=D;const H=A.length;E.get(ee).descendantCount=H}),q},I=y(o,0,null);return C.push(...I),{treeNodes:E,rootIds:C,groupingRows:k}},[o,r,i,e,g]);l.useEffect(()=>{if(s===-1){const E=new Set;m.forEach((k,C)=>{k.children&&k.children.length>0&&E.add(C)}),p(E)}else if(s>0){const E=new Set;m.forEach((k,C)=>{k.depth<s&&k.children&&k.children.length>0&&E.add(C)}),p(E)}else p(new Set)},[r,s]);const w=l.useCallback(E=>{p(k=>{const C=new Set(k);return C.has(E)?C.delete(E):C.add(E),C})},[]),b=l.useCallback(E=>f.has(E),[f]),M=l.useCallback(()=>{if(r.length===0)return null;const E=[],k=new Set,C=new Map;o.forEach(S=>C.set(e(S),S));const _=S=>{const x=m.get(S);if(!x)return!1;if(!x.children||x.children.length===0){const j=C.get(S);return!(!j||c&&!En(j,c))}return x.children.some(j=>_(j))},y=S=>{let x=S;c&&(x=S.filter(_)),a&&a.length>0&&x.sort((j,R)=>{const B=h.get(j)||C.get(j),q=h.get(R)||C.get(R);if(!B||!q)return 0;for(const A of a){const U=B[A.field],Y=q[A.field],G=Nn(U,Y,A.sort);if(G!==0)return G}return 0}),x.forEach(j=>{if(k.has(j))return;const R=m.get(j),B=R?.children&&R.children.length>0,q=B?h.get(j):C.get(j);if(q&&R){k.add(j);const A={...q,_treeDepth:R.depth,_isExpanded:f.has(j),_hasChildren:B,_groupingField:R.groupingField,_groupingValue:R.groupingValue,_descendantCount:R.descendantCount};E.push(A),I.has(j)&&B&&y(R.children)}})},I=f;return y(u),E},[o,e,m,u,h,c,a,f]),P=l.useCallback(E=>m.get(E),[m]);return l.useMemo(()=>({treeNodes:m,groupingRows:h,toggleExpansion:w,isGroupExpanded:b,getVisibleRows:M,getNode:P}),[m,h,w,b,M,P])}function jr(n){const{rows:o,getRowId:e,processRowUpdate:r,onProcessRowUpdateError:i,onRowChange:s}=n,[c,a]=l.useState(null),g=l.useRef(null),f=l.useCallback(h=>{a(h),g.current=typeof h=="function"?h(g.current):h},[]),p=l.useCallback(h=>{f({id:h.id,field:h.field,value:h.value,originalValue:h.value})},[]),m=l.useCallback(async h=>{const w=g.current;if(!w)return;if(h?.cancel){f(null);return}const{id:b,field:M,value:P,originalValue:E}=w;if(P===E){f(null);return}const k=o.find(_=>e(_)===b);if(!k){f(null);return}const C={...k,[M]:P};try{if(r){const _=await r(C,k);s?.(_)}else s?.(C);f(null)}catch(_){i&&i(_)}},[c,o,e,r,s,i]),u=l.useCallback(h=>{c&&c.id===h.id&&c.field===h.field&&f(w=>w?{...w,value:h.value}:null)},[c]);return{editingCell:c,startCellEdit:p,stopCellEdit:m,setEditCellValue:u}}function Er(n,o,e){const[r,i]=l.useState(new Map),[s,c]=l.useState({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}}),a=l.useCallback(()=>{i(new Map)},[]),g=l.useCallback((b,M)=>r.get(b)?.[M],[r]),f=l.useCallback((b,M,P,E,k)=>{const C=new Map(r);for(let _=E;_<k;_++){const y=o[_];if(!y)continue;let I=1;if(y.colSpan)if(typeof y.colSpan=="function"){const x={row:M,value:M[y.field],field:y.field,colDef:y,rowIndex:P,colIndex:_};I=y.colSpan(x)}else I=y.colSpan;if(I<=1){Tt(C,b,y.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:e[y.field]||100}});continue}let S=e[y.field]||100;for(let x=1;x<I;x++)if(_+x<k){const j=o[_+x];j&&(S+=e[j.field]||100,Tt(C,b,j.field,{spannedByColSpan:!0,leftVisibleCellIndex:_,rightVisibleCellIndex:Math.min(_+I-1,o.length-1)}))}Tt(C,b,y.field,{spannedByColSpan:!1,cellProps:{colSpan:I,width:S}}),_+=I-1}i(C)},[r,o,e]),p=l.useCallback((b,M)=>{const P={},E={},k={};o.forEach((C,_)=>{if(C.rowSpan)for(let y=b;y<M;y++){const I=n[y];if(!I||E[I.id]?.[C.field])continue;const S=C.valueGetter?C.valueGetter({row:I,field:C.field,value:I[C.field]}):I[C.field];let x=1;if(typeof C.rowSpan=="function"){const j={row:I,value:S,field:C.field,colDef:C,rowIndex:y,colIndex:_};x=C.rowSpan(j)}else typeof C.rowSpan=="number"&&(x=C.rowSpan);if(x>1){P[I.id]||(P[I.id]={}),P[I.id][C.field]=x;for(let j=1;j<x;j++){const R=y+j;if(R<M&&n[R]){const B=n[R];E[B.id]||(E[B.id]={}),E[B.id][C.field]=!0,k[R]||(k[R]={}),k[R][C.field]=y}}}}}),c({caches:{spannedCells:P,hiddenCells:E,hiddenCellOriginMap:k},processedRange:{firstRowIndex:b,lastRowIndex:M}})},[n,o]),m=l.useCallback(()=>{c({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}})},[]);l.useEffect(()=>{const b=new Map;n.forEach((k,C)=>{for(let _=0;_<o.length;_++){const y=o[_];if(!y)continue;let I=1;if(y.colSpan)if(typeof y.colSpan=="function"){const x={row:k,value:k[y.field],field:y.field,colDef:y,rowIndex:C,colIndex:_};I=y.colSpan(x)}else I=y.colSpan;if(I<=1){const x=e[y.field]||(typeof y.width=="number"?y.width:100);Tt(b,k.id,y.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:x}});continue}let S=e[y.field]||(typeof y.width=="number"?y.width:100);for(let x=1;x<I;x++)if(_+x<o.length){const j=o[_+x];if(j){const R=e[j.field]||(typeof j.width=="number"?j.width:100);S+=R,Tt(b,k.id,j.field,{spannedByColSpan:!0,leftVisibleCellIndex:_,rightVisibleCellIndex:Math.min(_+I-1,o.length-1)})}}Tt(b,k.id,y.field,{spannedByColSpan:!1,cellProps:{colSpan:I,width:S}}),_+=I-1}}),i(b);const M={},P={},E={};o.forEach((k,C)=>{if(k.rowSpan)for(let _=0;_<n.length;_++){const y=n[_];if(!y||P[y.id]?.[k.field])continue;const I=k.valueGetter?k.valueGetter({row:y,field:k.field,value:y[k.field]}):y[k.field];let S=1;if(typeof k.rowSpan=="function"){const x={row:y,value:I,field:k.field,colDef:k,rowIndex:_,colIndex:C};S=k.rowSpan(x)}else typeof k.rowSpan=="number"&&(S=k.rowSpan);if(S>1){M[y.id]||(M[y.id]={}),M[y.id][k.field]=S;for(let x=1;x<S;x++){const j=_+x;if(j<n.length&&n[j]){const R=n[j];P[R.id]||(P[R.id]={}),P[R.id][k.field]=!0,E[j]||(E[j]={}),E[j][k.field]=_}}}}}),c({caches:{spannedCells:M,hiddenCells:P,hiddenCellOriginMap:E},processedRange:{firstRowIndex:0,lastRowIndex:n.length}})},[n,o,e]);const u=l.useCallback(()=>s.caches.spannedCells,[s]),h=l.useCallback(()=>s.caches.hiddenCells,[s]),w=l.useCallback(()=>s.caches.hiddenCellOriginMap,[s]);return{colspanMap:r,resetColSpan:a,getCellColSpanInfo:g,calculateColSpan:f,rowSpanningState:s,calculateRowSpan:p,resetRowSpan:m,getSpannedCells:u,getHiddenCells:h,getHiddenCellOriginMap:w}}function Tt(n,o,e,r){let i=n.get(o);i||(i={},n.set(o,i)),i[e]=r}function Nr(n){const{dataSource:o,sortModel:e,filterModel:r,paginationModel:i,paginationMode:s,sortingMode:c,filterMode:a,aggregationModel:g,setRows:f,setRowCount:p,setDataSourceLoading:m,setDataSourceError:u,onAggregationResults:h}=n,w=l.useRef(null),b=l.useRef(0),M=l.useCallback(async()=>{if(!o)return;const E=++b.current;m(!0),u(null);const k=i.page*i.pageSize,C=k+i.pageSize,_={startRow:k,endRow:C,sortModel:e,filterModel:r,groupKeys:[],aggregationModel:g};try{const y=await o.getRows(_);if(E!==b.current)return;let I=!1;if(s==="infinite"){const S=w.current;if(S){const x=JSON.stringify(S.sortModel)!==JSON.stringify(e),j=JSON.stringify(S.filterModel)!==JSON.stringify(r),R=S.pageSize!==i.pageSize;!x&&!j&&!R&&i.page>S.page&&(I=!0)}}f(I?S=>[...S,...y.rows]:y.rows,!0),y.aggregationResults&&h&&h(y.aggregationResults),y.rowCount!==void 0&&p(y.rowCount),w.current={sortModel:e,filterModel:r,page:i.page,pageSize:i.pageSize}}catch(y){E===b.current&&(u(y),console.error("Data Source Error:",y))}finally{E===b.current&&m(!1)}},[o,i.page,i.pageSize,e,r,s,g,h,f,p,m,u]);l.useEffect(()=>{if(o&&(s==="server"||s==="infinite"||c==="server"||a==="server")){const k=setTimeout(()=>{M()},300);return()=>clearTimeout(k)}},[M,o,s,c,a]);const P=l.useCallback(async(E,k)=>{if(o){m(!0);try{const C=await o.getRows({startRow:0,endRow:-1,sortModel:e,filterModel:r,groupKeys:k});C.rows.length>0&&f(_=>{const y=new Set(_.map(S=>S.id)),I=C.rows.filter(S=>!y.has(S.id));return[..._,...I]})}catch(C){u(C),console.error("Failed to fetch children:",C)}finally{m(!1)}}},[o,e,r,f,m,u]);return{fetchRows:M,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:i,filterModel:s,sortModel:c,serverAggregationResults:a}=n,g=l.useMemo(()=>{if(r||Object.keys(e).length===0)return{};const E={};for(const[k,C]of Object.entries(e)){const _=Ir[C];if(!_){console.warn(`[useAggregation] Unknown aggregation function: "${C}"`);continue}const y=o.map(I=>I[k]);E[k]=_(y)}return E},[o,e,r]),[f,p]=l.useState({}),[m,u]=l.useState(!1),[h,w]=l.useState(null),b=l.useRef(0),M=l.useCallback(async()=>{if(!i?.getAggregations||Object.keys(e).length===0)return;const E=++b.current;u(!0),w(null);try{const k=await i.getAggregations({sortModel:c??[],filterModel:s??{items:[]},groupKeys:[],aggregationModel:e});E===b.current&&p(k)}catch(k){E===b.current&&(w(k),console.error("[useAggregation] Server aggregation error:",k))}finally{E===b.current&&u(!1)}},[i,e,s,c]);return l.useEffect(()=>{r&&i?.getAggregations&&!a&&M()},[M,r,i,a]),{aggregationResult:l.useMemo(()=>r?a&&Object.keys(a).length>0?a:f:g,[r,g,a,f]),isLoading:m,error:h}}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,i)=>r+i,0);case"avg":return e.reduce((r,i)=>r+i,0)/e.length;case"count":return e.length;case"min":return Math.min(...e);case"max":return Math.max(...e)}}function In(n,o){return o.map(e=>String(n[e]??"")).join("\0")}function ao(n,o,e,r){return l.useMemo(()=>{const i={pivotRows:[],pivotColumns:[],colKeys:[],isValid:!1};if(!r)return i;const{rowFields:s,columnFields:c,valueFields:a}=e;if(s.length===0||a.length===0)return i;const g=new Map(o.map(b=>[b.field,b])),f=new Set;for(const b of n)f.add(In(b,c));const p=Array.from(f).sort(),m=new Map;for(const b of n){const M=In(b,s);if(!m.has(M)){const C={};for(const _ of s)C[_]=b[_];m.set(M,{labelValues:C,bucket:new Map})}const P=m.get(M),E=In(b,c);P.bucket.has(E)||P.bucket.set(E,new Map);const k=P.bucket.get(E);for(const C of a){const _=Number(b[C.field]);k.has(C.field)||k.set(C.field,[]),isNaN(_)||k.get(C.field).push(_)}}let u=0;const h=[];for(const[,b]of m){const M={id:u++,...b.labelValues};for(const P of p){const E=b.bucket.get(P);for(const k of a){const C=c.length>0?`${P}${k.field}${k.aggFn}`:`${k.field}${k.aggFn}`,_=E?.get(k.field)??[];M[C]=_.length>0?Mr(_,k.aggFn):null}}h.push(M)}const w=[];for(const b of s){const M=g.get(b);w.push({field:b,headerName:M?.headerName??b,width:M?.width??140,sortable:!0})}for(const b of p){const M=c.length>0?b.split("\0").map((P,E)=>{const k=g.get(c[E]);return k?.headerName?`${k.headerName}: ${P}`:P}).join(" / "):"";for(const P of a){const E=g.get(P.field),k=c.length>0?`${b}${P.field}${P.aggFn}`:`${P.field}${P.aggFn}`,C=P.headerName??E?.headerName??P.field,_=M?`${M} — ${C} (${P.aggFn})`:`${C} (${P.aggFn})`;w.push({field:k,headerName:_,width:140,type:"number",align:"right",headerAlign:"right",sortable:!0,valueFormatter:({value:y})=>{if(y==null)return"—";const I=Number(y);return P.aggFn==="avg"?I.toFixed(2):P.aggFn==="count"?I.toLocaleString():E?.valueFormatter?E.valueFormatter({value:y,row:{},field:P.field}):I.toLocaleString()}})}}return{pivotRows:h,pivotColumns:w,colKeys:p,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:i}=n,s=l.useCallback(async()=>{if(o.size===0)return;const a=r().filter(u=>o.has(i(u)));if(a.length===0)return;const g=e.filter(u=>!u.field.startsWith("__")),f=g.map(u=>u.headerName||u.field).join(" "),p=a.map(u=>g.map(h=>{const w=u[h.field];return h.valueFormatter?h.valueFormatter({value:w,row:u,field:h.field}):w??""}).join(" ")).join(`
6
+ <%s key={someKey} {...props} />`,W,K,L,K),pe[K+W]=!0)}if(K=null,H!==void 0&&(e(H),K=""+H),c(D)&&(e(D.key),K=""+D.key),"key"in D){H={};for(var ae in D)ae!=="key"&&(H[ae]=D[ae])}else H=D;return K&&a(H,typeof v=="function"?v.displayName||v.name||"Unknown":v),f(v,K,H,i(),F,q)}function m(v){u(v)?v._store&&(v._store.validated=1):typeof v=="object"&&v!==null&&v.$$typeof===x&&(v._payload.status==="fulfilled"?u(v._payload.value)&&v._payload.value._store&&(v._payload.value._store.validated=1):v._store&&(v._store.validated=1))}function u(v){return typeof v=="object"&&v!==null&&v.$$typeof===w}var h=l,w=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),M=Symbol.for("react.fragment"),P=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),k=Symbol.for("react.consumer"),C=Symbol.for("react.context"),_=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),I=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),j=Symbol.for("react.activity"),R=Symbol.for("react.client.reference"),B=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Y=Object.prototype.hasOwnProperty,A=Array.isArray,U=console.createTask?console.createTask:function(){return null};h={react_stack_bottom_frame:function(v){return v()}};var X,G={},ee=h.react_stack_bottom_frame.bind(h,s)(),Q=U(r(s)),pe={};Xt.Fragment=M,Xt.jsx=function(v,D,H){var W=1e4>B.recentlyCreatedOwnerStacks++;return p(v,D,H,!1,W?Error("react-stack-top-frame"):ee,W?U(r(v)):Q)},Xt.jsxs=function(v,D,H){var W=1e4>B.recentlyCreatedOwnerStacks++;return p(v,D,H,!0,W?Error("react-stack-top-frame"):ee,W?U(r(v)):Q)}})()),Xt}var eo;function Ao(){return eo||(eo=1,process.env.NODE_ENV==="production"?an.exports=Wo():an.exports=Fo()),an.exports}var t=Ao();function zo({row:n,rowIndex:o,listViewColumn:e,isSelected:r=!1,checkboxSelection:i=!1,rowHeight:s,onRowClick:c,onSelectionChange:a}){const g={row:n,value:void 0,field:e.field,colDef:{field:e.field},rowIndex:o,colIndex:0},f=p=>{p.stopPropagation(),a?.(n.id,p.target.checked)};return t.jsxs("div",{className:`ogx-list-view__row${r?" ogx-list-view__row--selected":""}`,style:s?{minHeight:s}:void 0,onClick:()=>c?.(n),role:"row","aria-rowindex":o+2,"aria-selected":r,children:[i&&t.jsx("div",{className:"ogx-list-view__checkbox",onClick:p=>p.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:r,onChange:f,"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,...i})=>{const s=l.useRef(null),c=l.useCallback(g=>{s.current=g,typeof r=="function"?r(g):r&&(r.current=g)},[r]);l.useEffect(()=>{s.current&&(s.current.indeterminate=n)},[n]);const a=["ogx-checkbox-wrapper",i.disabled&&"ogx-checkbox-wrapper--disabled",e].filter(Boolean).join(" ");return t.jsxs("label",{className:a,children:[t.jsx("input",{ref:c,type:"checkbox",className:"ogx-checkbox__input","aria-label":o||i["aria-label"]||(n?"Select some":i.checked?"Deselect":"Select"),...i}),t.jsxs("span",{className:"ogx-checkbox__box",children:[i.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:i=50,maxWidth:s=1e3}=n,[c,a]=l.useState(!1),g=l.useRef(0),f=l.useRef(0),p=l.useCallback(h=>{h.preventDefault(),h.stopPropagation(),a(!0),g.current=h.clientX,f.current=e;let w=0;const b=16,M=E=>{const k=E.clientX-g.current,C=Math.max(i,Math.min(s,f.current+k)),_=Date.now();_-w>=b&&(r(o,C),w=_)},P=E=>{a(!1);const k=E.clientX-g.current,C=Math.max(i,Math.min(s,f.current+k));r(o,C),document.removeEventListener("mousemove",M),document.removeEventListener("mouseup",P)};document.addEventListener("mousemove",M),document.addEventListener("mouseup",P)},[o,e,r,i,s]),m=l.useCallback(h=>{h.preventDefault(),h.stopPropagation()},[]),u=["ogx-column-resize-handle",c&&"ogx-column-resize-handle--dragging"].filter(Boolean).join(" ");return t.jsx("div",{className:u,onMouseDown:p,onClick:h=>h.stopPropagation(),onDragStart:h=>{h.preventDefault(),h.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=[],i=[];return o?(n.forEach(s=>{const c=dn(s.field,o);c==="left"?e.push(s):c==="right"?i.push(s):r.push(s)}),o.left&&e.sort((s,c)=>{const a=o.left.indexOf(s.field),g=o.left.indexOf(c.field);return a-g}),o.right&&i.sort((s,c)=>{const a=o.right.indexOf(s.field),g=o.right.indexOf(c.field);return a-g}),{left:e,center:r,right:i}):{left:e,center:n,right:i}}function to(n,o,e,r,i,s,c,a){const g={};if(!e)return g;const f=$o(n,e);let p=0;a&&(p+=48),s&&c&&(p+=48),r&&i&&(p+=48),f.left.forEach(u=>{g[u.field]=p;const h=o[u.field]??u.width??100;p+=h});let m=0;return[...f.right].reverse().forEach(u=>{const h=o[u.field]??u.width??100;g[u.field]=m,m+=h}),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=[],i=[];return o?(n.forEach(s=>{const c=En(s.id,o);c==="top"?e.push(s):c==="bottom"?i.push(s):r.push(s)}),o.top&&e.sort((s,c)=>{const a=o.top.indexOf(s.id),g=o.top.indexOf(c.id);return a-g}),o.bottom&&i.sort((s,c)=>{const a=o.bottom.indexOf(s.id),g=o.bottom.indexOf(c.id);return a-g}),{top:e,center:r,bottom:i}):{top:e,center:n,bottom:i}}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:i,pinnedColumns:s,onManageColumns:c,onClose:a,anchorEl:g}){const f=l.useRef(null),[p,m]=l.useState({position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"});l.useLayoutEffect(()=>{if(!g||!f.current)return;const _=g.getBoundingClientRect(),y=f.current.getBoundingClientRect(),I=window.innerWidth,S=window.innerHeight,x=8;let j=_.left;j+y.width+x>I&&(j=I-y.width-x),j<x&&(j=x);let R=_.bottom+4;R+y.height+x>S&&(R=_.top-y.height-4),m({position:"fixed",zIndex:1300,top:R,left:j,visibility:"visible"})},[g]),l.useEffect(()=>{function _(I){f.current&&!f.current.contains(I.target)&&g&&!g.contains(I.target)&&a()}function y(I){I.key==="Escape"&&a()}return document.addEventListener("mousedown",_),document.addEventListener("keydown",y),window.addEventListener("scroll",a,!0),window.addEventListener("resize",a),()=>{document.removeEventListener("mousedown",_),document.removeEventListener("keydown",y),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a)}},[g,a]);const u=_=>{e?.(n.field,_),a()},h=()=>{r?.(n.field),a()},w=_=>{i?.(n.field,_),a()},b=o?.find(_=>_.field===n.field)?.sort,M=b==null,P=s?.left?.includes(n.field)??!1,E=s?.right?.includes(n.field)??!1,k=!P&&!E,C=n.headerName||n.field;return St.createPortal(t.jsxs("div",{ref:f,className:"ogx-column-menu",style:p,role:"menu","aria-label":`Column options for ${C}`,children:[e&&n.sortable!==!1&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{className:`ogx-menu-item${b==="asc"?" ogx-menu-item--active":""}`,onClick:()=>u("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:()=>u("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${M?" ogx-menu-item--active":""}`,onClick:()=>u(null),role:"menuitemradio","aria-checked":M,children:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:M?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:()=>w("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${E?" ogx-menu-item--active":""}`,onClick:()=>w("right"),role:"menuitemradio","aria-checked":E,"aria-label":"Pin to right",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(Xo,{})}),"Pin to Right"]}),t.jsxs("button",{className:`ogx-menu-item${k?" ogx-menu-item--active":""}`,onClick:()=>w(null),role:"menuitemradio","aria-checked":k,"aria-label":"Unpin column",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(qo,{})}),"Unpin"]}),t.jsx("div",{className:"ogx-menu-divider"}),t.jsxs("button",{className:"ogx-menu-item",onClick:h,role:"menuitem","aria-label":`Hide ${C} 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:()=>{c?.(),a()},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,i){o=Math.max(o,i);for(const s of r.children)typeof s!="string"&&e(s,i+1)}return n.forEach(r=>e(r,1)),o}function tr(n,o,e){function r(a,g,f){if(!no(a).includes(g))return null;if(f===e)return a;for(const p of a.children)if(typeof p!="string"){const m=r(p,g,f+1);if(m)return m}return null}const i=new Map;for(const a of o){let g=null;for(const f of n)if(g=r(f,a.field,0),g)break;i.set(a.field,g)}const s=[];let c=0;for(;c<o.length;){const a=o[c],g=i.get(a.field)??null,f=a.width;if(!g)s.push({key:`fg-${a.field}-${e}`,label:"",width:f,isGroup:!1}),c++;else{let p=0,m=c;for(;m<o.length&&i.get(o[m].field)===g;)p+=o[m].width,m++;s.push({key:`${g.groupId}-${e}`,label:g.headerName,width:p,isGroup:!0}),c=m}}return s}function oo(n){const{columns:o,allColumns:e,columnGroupingModel:r,checkboxSelection:i=!1,allSelected:s=!1,someSelected:c=!1,onSelectAll:a,onSort:g,sortModel:f=[],onColumnResize:p,columnWidths:m={},pinnedColumns:u,hasDetailPanel:h=!1,pinCheckboxColumn:w=!0,pinExpandColumn:b=!0,rowReordering:M=!1,aggregationModel:P,draggedColumn:E,dragOverColumn:k,onDragStart:C,onDragOver:_,onDragEnd:y,onDrop:I,focusedCell:S,onHeaderClick:x,onHideColumn:j,onPinColumn:R,onManageColumns:B}=n,Y=l.useRef({}),[A,U]=l.useState(null),X=L=>ae=>{ae.stopPropagation(),U({colDef:L,anchorEl:ae.currentTarget})},G=()=>{U(null)};l.useLayoutEffect(()=>{if(S?.id==="HEADER"){const L=Y.current[S.field];L&&L.focus()}},[S]);const ee=L=>()=>{if(L.sortable===!1||!g)return;const ae=f.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=f.find(oe=>oe.field===L);return ae?t.jsx("span",{className:`ogx__sort-icon ogx__sort-icon--${ae.sort}`,"aria-hidden":"true"}):null},pe=l.useMemo(()=>to(o,m,u,i,w,h,b,M),[o,m,u,i,w,h,b,M]),v=r?er(r):0,H=(e??o).filter(L=>!L.isSpacer).map(L=>({field:L.field,width:m[L.field]??L.width??100})),K=(M?48:0)+(h?48:0)+(i?48:0);return t.jsxs("div",{className:"ogx__header-wrap",children:[v>0&&Array.from({length:v},(L,ae)=>{const oe=tr(r,H,ae);return t.jsxs("div",{className:"ogx-col-group-row",role:"row",children:[K>0&&t.jsx("div",{className:"ogx-col-group-cell ogx-col-group-cell--filler",style:{width:K,minWidth:K,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:[M&&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}}),h&&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?M?48:0:void 0,zIndex:b?5:void 0}}),i&&t.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?(M?48:0)+(h&&b?48:0):void 0},children:t.jsx(qt,{id:"ogx-select-all",name:"ogx-select-all",checked:s,indeterminate:c,onChange:L=>a?.(L.target.checked),"aria-label":s?"Deselect all rows":"Select all rows",tabIndex:S?.id==="HEADER"&&S.field==="__checkbox_col__"?0:-1,onMouseDown:L=>L.preventDefault(),inputRef:L=>{Y.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=f.some(ze=>ze.field===L.field),Ze=L.resizable!==!1,z=dn(L.field,u),Ee=z!==null,Ne=E===L.field,gt=k===L.field,De=["ogx__header-cell",`ogx__header-cell--align-${L.headerAlign||L.align||"left"}`,oe&&"ogx__header-cell--sortable",me&&"ogx__header-cell--sorted",Ee&&"ogx__header-cell--pinned",Ee&&`ogx__header-cell--pinned-${z}`,Ne&&"ogx__header-cell--dragging",gt&&"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:Ee?"sticky":"relative",zIndex:L.zIndex,opacity:Ne?.5:1};if(Ee&&z){const ze=pe[L.field];z==="left"?tt.left=ze:tt.right=ze}const en=L.renderHeader?L.renderHeader({field:L.field,colDef:L,colIndex:ae}):L.headerName||L.field,Rt=ze=>{if(ze.target.closest(".ogx-column-resize-handle")){ze.stopPropagation();return}x?.(L.field),oe&&ee(L)()},jt=C?C(L.field):void 0,Ot=_?_(L.field):void 0,vt=I?I(L.field):void 0;return t.jsxs("div",{className:De,style:tt,onClick:Rt,role:"columnheader",draggable:!!C,onDragStart:jt,onDragOver:Ot,onDragEnd:y,onDrop:vt,"aria-sort":oe?me?f.find(ze=>ze.field===L.field)?.sort==="asc"?"ascending":"descending":"none":void 0,"aria-colindex":ae+1+(i?1:0),"data-field":L.field,tabIndex:-1,ref:ze=>{Y.current[L.field]=ze},children:[t.jsxs("div",{className:"ogx__header-cell-content",children:[Ne&&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:X(L),"aria-label":`Open column menu for ${L.headerName||L.field}`,"aria-haspopup":"menu",tabIndex:-1,children:t.jsx(Qo,{})})]}),Ze&&p&&t.jsx(Bo,{field:L.field,currentWidth:et,onResize:p,minWidth:L.minWidth,maxWidth:L.maxWidth})]},L.field)}),A&&t.jsx(Jo,{colDef:A.colDef,sortModel:f,onSort:g,onHide:j,onPin:R,pinnedColumns:u,onManageColumns:B,onClose:G,anchorEl:A.anchorEl})]})]})}function nr({value:n,onValueChange:o,onCommit:e,onCancel:r}){const[i,s]=l.useState(String(n??"")),c=l.useRef(null);return l.useEffect(()=>{c.current?.focus(),c.current?.select()},[]),t.jsx("input",{ref:c,type:"text",className:"ogx__edit-input",value:i,onChange:a=>{s(a.target.value),o(a.target.value)},onBlur:e,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),e()),a.key==="Escape"&&(a.stopPropagation(),r())}})}function or({value:n,onValueChange:o,onCommit:e,onCancel:r}){const[i,s]=l.useState(n??""),c=l.useRef(null);return l.useEffect(()=>{c.current?.focus(),c.current?.select()},[]),t.jsx("input",{ref:c,type:"number",className:"ogx__edit-input ogx__edit-input--number",value:i,onChange:a=>{const g=a.target.value===""?"":Number(a.target.value);s(g),o(g===""?null:g)},onBlur:e,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),e()),a.key==="Escape"&&(a.stopPropagation(),r())}})}function rr({value:n,onValueChange:o,onCommit:e,onCancel:r}){const i=l.useRef(null);l.useEffect(()=>{i.current?.focus()},[]);const s=()=>{o(!n),setTimeout(e,0)};return t.jsx("div",{className:"ogx__edit-boolean",children:t.jsx("input",{ref:i,type:"checkbox",className:"ogx__edit-checkbox",checked:!!n,onChange:s,onKeyDown:c=>{c.key==="Escape"&&(c.stopPropagation(),r())}})})}function ir({value:n,colDef:o,onValueChange:e,onCommit:r,onCancel:i}){const s=l.useRef(null);l.useEffect(()=>{s.current?.focus()},[]);const c=o.valueOptions??[];return t.jsx("select",{ref:s,className:"ogx__edit-select",value:n??"",onChange:a=>{e(a.target.value)},onBlur:r,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),r()),a.key==="Escape"&&(a.stopPropagation(),i())},children:c.map(a=>{const g=typeof a=="object"?a.value:a,f=typeof a=="object"?a.label:String(a);return t.jsx("option",{value:String(g),children:f},String(g))})})}function lr({value:n,onValueChange:o,onCommit:e,onCancel:r}){const[i,s]=l.useState(n??""),c=l.useRef(null);return l.useEffect(()=>{c.current?.focus()},[]),t.jsx("input",{ref:c,type:"date",className:"ogx__edit-input",value:i,onChange:a=>{s(a.target.value),o(a.target.value)},onBlur:e,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),e()),a.key==="Escape"&&(a.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:i,row:s,colDef:c,rowIndex:a,colIndex:g,isSelected:f,onClick:p,width:m,pinnedPosition:u,pinnedOffset:h,isFocused:w,isFocusVisible:b,isEditable:M,isEditing:P,onEditStart:E,onEditStop:k,onValueChange:C,colSpanInfo:_,rowSpan:y,isHiddenByRowSpan:I}=n;if(_?.spannedByColSpan)return null;if(I)return t.jsx("div",{className:"ogx__cell ogx__cell--hidden",style:{width:m??c.width??100},role:"presentation","data-field":c.field,"data-colindex":g});const S=v=>{o&&(v.stopPropagation(),o({row:s,field:c.field,value:i,colDef:c,rowIndex:a,colIndex:g})),p?.(v)},x=l.useCallback(v=>{r?r(c.field,v):C?.(v)},[r,C,c.field]),j=v=>{M&&(E||e)&&(v.stopPropagation(),e?e(c.field,i):E?.())},R=l.useMemo(()=>c.valueFormatter?c.valueFormatter({value:i,row:s,field:c.field}):i==null?"":String(i),[i,s,c]),B=l.useMemo(()=>P&&(r||C)&&k?c.renderEditCell?c.renderEditCell({value:i,row:s,field:c.field,colDef:c,rowIndex:a,colIndex:g}):t.jsx(sr,{value:i,row:s,field:c.field,colDef:c,rowIndex:a,colIndex:g,onValueChange:x,onCommit:()=>k(),onCancel:()=>k(!0)}):c.renderCell?c.renderCell({value:i,row:s,field:c.field,colDef:c,rowIndex:a,colIndex:g}):R,[i,s,c,a,g,R,P,x,k,r,C]),Y=u!=null,A=l.useMemo(()=>c.cellClassName?typeof c.cellClassName=="function"?c.cellClassName({value:i,row:s,field:c.field,colDef:c,rowIndex:a,colIndex:g})||"":c.cellClassName:"",[c,i,s,a,g]),U=["ogx__cell",`ogx__cell--align-${c.align||"left"}`,f&&"ogx__cell--selected",w&&"ogx__cell--focused",w&&b&&"ogx__cell--focus-visible",c.type&&`ogx__cell--type-${c.type}`,Y&&"ogx__cell--pinned",Y&&`ogx__cell--pinned-${u}`,P&&"ogx__cell--editing",y&&y>1&&"ogx__cell--spanned",A].filter(Boolean).join(" "),X=_?.cellProps?.colSpan||1,G=y||1,ee=_?.cellProps?.width??m??c.width??100,Q={width:"var(--width)","--width":typeof ee=="number"?`${ee}px`:ee,flexGrow:c.flex??0,flexShrink:0,flexBasis:(c.flex,"auto"),boxSizing:"border-box",minWidth:c.minWidth,maxWidth:c.maxWidth,position:Y?"sticky":void 0,zIndex:c.zIndex??(Y?3:void 0),padding:P?0:void 0};G>1&&(Q.height=`calc(var(--height) * ${G} - var(--border-width, 1px))`,Q.zIndex=10,Y&&(Q.zIndex=40)),Y&&h!==void 0&&(u==="left"?Q.left=h:Q.right=h);const pe=l.useRef(null);return l.useLayoutEffect(()=>{w&&pe.current&&pe.current.focus({preventScroll:!0})},[w]),t.jsx("div",{ref:pe,className:U,style:Q,onClick:S,onDoubleClick:j,role:"gridcell","aria-colindex":g+1,"aria-readonly":!M||void 0,tabIndex:-1,"data-field":c.field,"data-colindex":g,...X>1?{"aria-colspan":X}:{},...G>1?{"aria-rowspan":G}:{},children:t.jsx("div",{className:"ogx__cell-content",children:B})})}const ro=l.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 i={height:e==="auto"?"auto":`${e}px`,overflow:e==="auto"?"visible":"auto"};return t.jsx("div",{className:"ogx__detail-panel",style:i,children:t.jsx("div",{className:"ogx__detail-panel-content",children:o})})}function Jt(n){const{row:o,columns:e,rowIndex:r,isSelected:i=!1,checkboxSelection:s=!1,onRowClick:c,onCellClick:a,onSelectionChange:g,columnWidths:f={},pinnedColumns:p,pinnedRows:m,hasDetailPanel:u=!1,isDetailPanelExpanded:h=!1,onDetailPanelToggle:w,detailPanelContent:b,detailPanelHeight:M=200,pinCheckboxColumn:P=!0,pinExpandColumn:E=!0,rowReordering:k=!1,onDragStart:C,onDragOver:_,onDragEnd:y,onDrop:I,isDragging:S,isDragOver:x,editingCell:j,onEditStart:R,onEditStop:B,onEditCellValueChange:Y,focusedCellField:A,isFocusVisible:U,colspanMap:X,rowSpanningCaches:G,rowHeight:ee=52}=n,Q=l.useRef(null),pe=l.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((Ee,Ne)=>t.jsx("div",{className:"ogx__skeleton-cell",children:t.jsx("div",{className:"ogx__skeleton-bar"})},Ne))})}l.useLayoutEffect(()=>{A==="__expand_col__"&&Q.current&&Q.current.focus({preventScroll:!0}),A==="__checkbox_col__"&&pe.current&&pe.current.focus({preventScroll:!0})},[A]);const v=z=>{z.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell")||c?.({row:o,id:o.id,rowIndex:r})},D=z=>{z.stopPropagation(),g?.(o.id,z.target.checked)},H=z=>{z.stopPropagation(),w?.(o.id)},W=l.useMemo(()=>to(e,f,p,s,P,u,E,k),[e,f,p,s,P,u,E,k]),F=En(o.id,m),q=F==="top",K=F==="bottom",L=o._hasChildren===!0,ae=l.useCallback((z,Ee)=>{L||R?.({id:o.id,field:z,value:Ee})},[L,o.id,R]),oe=l.useCallback((z,Ee)=>{Y?.({id:o.id,field:z,value:Ee})},[Y,o.id]),me=l.useCallback(z=>{B?.({cancel:z})},[B]),Ze=["ogx__row",i&&"ogx__row--selected",r%2===0&&"ogx__row--even",r%2===1&&"ogx__row--odd",q&&"ogx__row--pinned-top",K&&"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:v,role:"row","aria-rowindex":r+1,"aria-selected":i,"data-rowindex":r,onDragOver:_?_(o.id):void 0,onDrop:I?I(o.id):void 0,style:{maxHeight:`${ee}px`,minHeight:`${ee}px`,"--height":`${ee}px`,"--border-width":"1px"},children:[k&&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:C?C(o.id):void 0,onDragEnd:y,onClick:z=>z.stopPropagation(),children:t.jsx(dr,{})}),u&&t.jsx("div",{className:`ogx__cell ogx__cell--expand ${E?"ogx__cell--pinned-left":""} ${A==="__expand_col__"?"ogx__cell--focused":""} ${A==="__expand_col__"&&U?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":h?"Collapse row details":"Expand row details","aria-expanded":h,style:{position:E?"sticky":void 0,left:E?k?48:0:void 0,zIndex:E?5:void 0},ref:Q,tabIndex:-1,onClick:z=>{z.stopPropagation(),a?.({row:o,field:"__expand_col__",value:h,colDef:{field:"__expand_col__",width:48},rowIndex:r,colIndex:-1})},children:t.jsx(io,{isExpanded:h,onClick:H,variant:"plus-minus"})}),s&&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?(k?48:0)+(u&&E?48:0):void 0,zIndex:P?11:void 0},ref:pe,tabIndex:-1,onClick:z=>{z.stopPropagation(),a?.({row:o,field:"__checkbox_col__",value:i,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:i,onChange:D,onClick:z=>z.stopPropagation(),"aria-label":i?`Deselect row ${o.id}`:`Select row ${o.id}`,tabIndex:-1,onMouseDown:z=>z.preventDefault()})}),e.map((z,Ee)=>{if(z.isSpacer)return t.jsx("div",{style:{width:z.width,minWidth:z.width,flexShrink:0},"aria-hidden":"true"},z.field);const Ne=z.valueGetter?z.valueGetter({row:o,field:z.field,value:o[z.field]}):o[z.field],gt=f[z.field]??z.width,De=dn(z.field,p),et=De?W[z.field]:void 0,tt=j?.id===o.id&&j?.field===z.field,en=tt?j?.value:Ne,Rt=X?.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:Ee,isSelected:i,onCellClick:a,width:gt,pinnedPosition:De,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)})]}),u&&t.jsx(cr,{row:o,rowId:o.id,rowIndex:r,content:b,height:M,isExpanded:h})]})}const ur=({columns:n,rowHeight:o,checkboxSelection:e=!1,hasDetailPanel:r=!1,rowReordering:i=!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}})}),i&&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((s,c)=>{const a=s.width||150,g=Math.min(a*.7,a-20);return t.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:a,minWidth:s.minWidth,maxWidth:s.maxWidth,left:s.left,right:s.right,position:s.isSpacer?"relative":s.pinned?"sticky":"relative",zIndex:s.zIndex},children:!s.isSpacer&&t.jsx("div",{className:"ogx-skeleton-box",style:{width:g,height:16,borderRadius:4}})},s.field||c)})]}),Qt=({variant:n="text",size:o="medium",color:e="default",disabled:r=!1,className:i="",children:s,...c})=>{const a=["ogx-button",`ogx-button--${n}`,`ogx-button--${o}`,`ogx-button--${e}`,r&&"ogx-button--disabled",i].filter(Boolean).join(" ");return t.jsx("button",{className:a,disabled:r,...c,children:s})};function lo(n){const{page:o,pageSize:e,rowCount:r,onPageChange:i,onPageSizeChange:s,pageSizeOptions:c=[10,25,50,100],showFirstButton:a=!0,showLastButton:g=!0}=n,f=Math.max(1,Math.ceil(r/e)),p=Math.min(o,f-1),m=p*e,u=Math.min(m+e,r),h=r===0?0:`${m+1}–${u}`,w=()=>{i(0)},b=()=>{i(Math.max(0,p-1))},M=()=>{i(Math.min(f-1,p+1))},P=()=>{i(f-1)},E=_=>{const y=parseInt(_.target.value,10);s(y)},k=p===0,C=p>=f-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:E,"aria-label":"Rows per page",children:c.map(_=>t.jsx("option",{value:_,children:_},_))})]}),t.jsxs("div",{className:"ogx-pagination__info","aria-live":"polite","aria-atomic":"true",children:[h," of ",r]}),t.jsxs("div",{className:"ogx-pagination__actions",children:[a&&t.jsx(Qt,{variant:"text",size:"small",onClick:w,disabled:k,"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:k,"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 ",p+1," of ",f]}),t.jsx(Qt,{variant:"text",size:"small",onClick:M,disabled:C,"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:C,"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 gr(n,o,e={}){const r=new Map,i=[];n.forEach(a=>{const g=a.id;r.set(g,a),i.push(g)});const s=new Map,c=[];return o.forEach(a=>{s.set(a.field,a),c.push(a.field)}),{rows:{idRowsLookup:r,allRows:i},columns:{all:o,lookup:s,orderedFields:c,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 fr(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,i=new Map,s=[];return r.forEach(c=>{i.set(c.id,c),s.push(c.id)}),{...n,rows:{idRowsLookup:i,allRows:s},pagination:{...n.pagination,rowCount:o.preserveRowCount?n.pagination.rowCount:r.length}}}case"SET_COLUMNS":{const e=new Map,r=[];return o.payload.forEach(i=>{e.set(i.field,i),r.push(i.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:i=56,columnVisibilityModel:s,initialState:c}=n,a=l.useMemo(()=>gr(o,e,s),[]),[g,f]=l.useReducer(fr,{...a,sorting:c?.sorting||a.sorting,filter:c?.filter||a.filter,dataSource:c?.dataSource?{...a.dataSource,...c.dataSource}:a.dataSource,pagination:{...a.pagination,...c?.pagination||{},rowCount:n.rowCount??c?.pagination?.rowCount??a.pagination.rowCount},dimensions:{...a.dimensions,rowHeight:r,headerHeight:i}}),p=l.useRef(g);p.current=g;const m=l.useRef(o);l.useEffect(()=>{o!==m.current&&(m.current=o,f({type:"SET_ROWS",payload:o}))},[o]);const u=l.useCallback((S,x)=>{f({type:"SET_ROWS",payload:S,preserveRowCount:x})},[]),h=l.useCallback(S=>{f({type:"SET_COLUMNS",payload:S})},[]),w=l.useCallback(S=>{f({type:"SET_SORT_MODEL",payload:S})},[]),b=l.useCallback(S=>{f({type:"SET_FILTER_MODEL",payload:S})},[]),M=l.useCallback(S=>{f({type:"SET_PAGINATION_MODEL",payload:S})},[]),P=l.useCallback(S=>{f({type:"SET_SELECTION",payload:S})},[]),E=l.useCallback((S,x)=>{f({type:"SET_SCROLL",payload:{scrollTop:S,scrollLeft:x}})},[]),k=l.useCallback((S,x)=>{f({type:"SET_DIMENSIONS",payload:{viewportWidth:S,viewportHeight:x}})},[]),C=l.useCallback(S=>{f({type:"SET_DATASOURCE_LOADING",payload:S})},[]),_=l.useCallback(S=>{f({type:"SET_DATASOURCE_ERROR",payload:S})},[]),y=l.useCallback(S=>{f({type:"SET_ROW_COUNT",payload:S})},[]),I=l.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,x=!0)=>{const j=new Set(p.current.selection.selectedRows);x?j.add(S):j.delete(S),P(j)},selectRows:(S,x=!0)=>{const j=new Set(p.current.selection.selectedRows);S.forEach(R=>{x?j.add(R):j.delete(R)}),P(j)},getSelectedRows:()=>Array.from(p.current.selection.selectedRows),sortColumn:(S,x)=>{if(x===null)w(p.current.sorting.sortModel.filter(j=>j.field!==S));else{const j=p.current.sorting.sortModel.findIndex(R=>R.field===S);if(j>=0){const R=[...p.current.sorting.sortModel];R[j]={field:S,sort:x},w(R)}else w([...p.current.sorting.sortModel,{field:S,sort:x}])}},getSortModel:()=>p.current.sorting.sortModel,setFilterModel:b,getFilterModel:()=>p.current.filter.filterModel,setPage:S=>{M({...p.current.pagination.paginationModel,page:S})},setPageSize:S=>{M({...p.current.pagination.paginationModel,pageSize:S,page:0})},scrollToIndexes:()=>{},copySelectedRows:()=>Promise.resolve()});return{state:g,dispatch:f,apiRef:I,setRows:u,setColumns:h,setSortModel:w,setFilterModel:b,setPaginationModel:M,setSelection:P,setScroll:E,setDimensions:k,setDataSourceLoading:C,setDataSourceError:_,setRowCount:y}}function pr(n){const{columns:o,onColumnOrderChange:e,disableColumnReorder:r=!1}=n,[i,s]=l.useState(null),[c,a]=l.useState(null),g=l.useRef(-1),f=l.useCallback(h=>w=>{if(r)return;const b=o.findIndex(P=>P.field===h);if(o[b]?.pinnable===!1){w.preventDefault();return}s(h),g.current=b,w.dataTransfer&&(w.dataTransfer.effectAllowed="move",w.dataTransfer.setData("text/plain",h))},[o,r]),p=l.useCallback(h=>w=>{r||!i||(w.preventDefault(),w.dataTransfer.dropEffect="move",a(h))},[i,r]),m=l.useCallback(h=>w=>{if(w.preventDefault(),r||!i||i===h){s(null),a(null);return}const b=o.findIndex(E=>E.field===i),M=o.findIndex(E=>E.field===h);if(b===-1||M===-1){s(null),a(null);return}const P=o[b];e&&e({column:P,oldIndex:b,targetIndex:M}),s(null),a(null),g.current=-1},[o,i,r,e]),u=l.useCallback(()=>{s(null),a(null),g.current=-1},[]);return{draggedColumn:i,dragOverColumn:c,onDragStart:r?void 0:f,onDragOver:r?void 0:p,onDragEnd:r?void 0:u,onDrop:r?void 0:m}}function xr(n){const{onRowOrderChange:o,rows:e,getRowId:r,rowReordering:i=!1}=n,[s,c]=l.useState(null),[a,g]=l.useState(null),f=l.useCallback(w=>r?r(w):w.id,[r]),p=l.useCallback(w=>b=>{i&&(c(w),b.dataTransfer.effectAllowed="move")},[i]),m=l.useCallback(w=>b=>{!i||!s||(b.preventDefault(),b.dataTransfer.dropEffect="move",a!==w&&g(w))},[i,s,a]),u=l.useCallback(()=>{c(null),g(null)},[]),h=l.useCallback(w=>b=>{if(b.preventDefault(),!s||!o){u();return}const M=e.findIndex(E=>f(E)===s),P=e.findIndex(E=>f(E)===w);M!==-1&&P!==-1&&M!==P&&o({row:e[M],oldIndex:M,targetIndex:P}),u()},[s,o,e,f,u]);return{draggedRowId:s,dragOverRowId:a,onDragStart:i?p:void 0,onDragOver:i?m:void 0,onDragEnd:i?u:void 0,onDrop:i?h: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:i}=o,s=n[e],c=mr[r];return c?c(s,i):(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(i=>i==null?!1:String(i).toLowerCase().includes(r))})}function Nn(n,o){const e=o.items||[],r=o.logicOperator||"and",i=o.quickFilterValues||[];if(i.length>0&&!wr(n,i))return!1;if(e.length===0)return!0;const s=c=>{if("logicOperator"in c&&"items"in c){const a=c,g=a.items;return g.length===0?!0:a.logicOperator==="and"?g.every(s):g.some(s)}else return br(n,c)};return r==="and"?e.every(s):e.some(s)}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(i=>Nn(i,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(),i=String(o).toLowerCase();return e==="asc"?r<i?-1:r>i?1:0:r>i?-1:r<i?1:0}function Cr(n,o){if(o.length===0)return n;const e=[...n];return e.sort((r,i)=>{for(const s of o){const c=r[s.field],a=i[s.field],g=In(c,a,s.sort);if(g!==0)return g}return 0}),e}function yr(n){const{rows:o,getRowId:e,getTreeDataPath:r,treeData:i=!1,defaultGroupingExpansionDepth:s=0,filterModel:c,sortModel:a,onRowExpansionChange:g}=n,{treeNodes:f,rootIds:p,groupingRows:m}=l.useMemo(()=>{if(!i||!r)return{treeNodes:new Map,rootIds:[],groupingRows:[]};const C=new Map,_=[],y=[],I=new Map,S=x=>x.join("/");return o.forEach(x=>{const j=e(x),R=r(x),B=S(R);I.set(B,j),C.set(j,{id:j,parentId:null,depth:R.length-1,groupingKey:R[R.length-1],isExpanded:!1,children:[],serverChildrenCount:x.serverChildrenCount})}),o.forEach(x=>{const j=e(x),R=r(x);if(R.length===1){_.push(j);return}const B=A=>{if(A.length<=1)return;const U=A.slice(0,-1),X=S(U);let G=I.get(X);if(G===void 0&&(G=`auto-group-${X}`,!C.has(G))){const ee=U[U.length-1];C.set(G,{id:G,parentId:null,depth:U.length-1,groupingKey:ee,isExpanded:!1,children:[],label:ee}),I.set(X,G);const Q={id:G,name:ee,_isGroupRow:!0};y.push(Q),U.length===1&&_.push(G),B(U)}return G},Y=B(R);if(Y!==void 0){const A=C.get(Y),U=C.get(j);A&&U&&(U.parentId=Y,A.children=A.children||[],A.children.includes(j)||A.children.push(j))}}),y.forEach(x=>{const j=x.id,R=C.get(j);if(!R)return;const Y=j.replace("auto-group-","").split("/");if(Y.length>1){const A=Y.slice(0,-1),U=S(A),X=I.get(U);if(X&&C.has(X)){R.parentId=X;const G=C.get(X);G&&(G.children=G.children||[],G.children.includes(j)||G.children.push(j))}}}),{treeNodes:C,rootIds:_,groupingRows:y}},[o,r,i,e]),u=l.useMemo(()=>{if(!i)return new Set;const C=new Set;return f.forEach(_=>{_.children&&_.children.length>0&&(s===-1||_.depth<s)&&C.add(_.id)}),C},[f,i,s]),[h,w]=l.useState(new Set);l.useEffect(()=>{u.size>0&&w(u)},[u]);const b=l.useCallback(C=>{w(_=>{const y=new Set(_),I=!y.has(C);if(y.has(C)?y.delete(C):y.add(C),I&&g){const S=f.get(C);S&&g(S)}return y})},[f,g]),M=l.useCallback(()=>{if(!i)return null;const C=new Map;o.forEach(B=>C.set(e(B),B)),m.forEach(B=>C.set(B.id,B));const _=B=>Nn(B,c),y=new Map,I=B=>{if(y.has(B))return y.get(B);const Y=C.get(B);if(!Y)return!1;if(_(Y))return y.set(B,!0),!0;const U=f.get(B);return U&&U.children&&U.children.some(G=>I(G))?(y.set(B,!0),!0):(y.set(B,!1),!1)},S=(B,Y)=>{if(!a||a.length===0)return 0;const A=C.get(B),U=C.get(Y);if(!A||!U)return 0;for(const X of a){const G=A[X.field],ee=U[X.field],Q=In(G,ee,X.sort);if(Q!==0)return Q}return 0},x=[],j=new Set,R=B=>{const Y=B.filter(A=>I(A));Y.sort(S),Y.forEach(A=>{if(j.has(A))return;const U=C.get(A),X=f.get(A);if(U&&X){j.add(A);const G={...U,_treeDepth:X.depth,_isExpanded:h.has(A),_hasChildren:X.children&&X.children.length>0||X.serverChildrenCount&&X.serverChildrenCount>0,_descendantCount:X.children?X.children.length:0};x.push(G),h.has(A)&&X.children&&X.children.length>0&&R(X.children)}})};return R(p),x},[i,o,m,p,f,h,c,a,e]),P=l.useCallback(C=>h.has(C),[h]),E=l.useCallback(C=>f.get(C),[f]),k=l.useCallback(C=>{const _=[];let y=C;for(;y!==null;){const I=f.get(y);if(!I)break;_.unshift(I.groupingKey),y=I.parentId}return _},[f]);return l.useMemo(()=>({treeNodes:f,groupingRows:m,toggleExpansion:b,isGroupExpanded:P,getVisibleRows:M,getNode:E,getNodePath:k}),[f,m,b,P,M,E,k])}const kr=n=>n?.depth===-1?"footer":"inline";function Sr(n){const{rows:o,getRowId:e,rowGroupingModel:r=[],aggregationModel:i={},defaultGroupingExpansionDepth:s=0,filterModel:c,sortModel:a,getAggregationPosition:g=kr}=n,[f,p]=l.useState(new Set),{treeNodes:m,rootIds:u,groupingRows:h}=l.useMemo(()=>{const E=new Map,k=new Map,C=[];if(r.length===0)return{treeNodes:E,rootIds:C,groupingRows:k};const _=(S,x,j)=>`auto-group-${S}-${x}-${j||"root"}`,y=(S,x,j)=>{if(x>=r.length)return S.map(A=>{const U=e(A);return E.set(U,{id:U,parentId:j,depth:x,groupingKey:"",isExpanded:!1}),U});const R=r[x],B=new Map;S.forEach(A=>{const U=A[R],X=String(U);B.has(X)||B.set(X,[]),B.get(X).push(A)});const Y=[];return B.forEach((A,U)=>{const G=A[0][R],ee=_(R,U,j);Y.push(ee);const Q={};i&&Object.entries(i).forEach(([W,F])=>{const q=A.map(K=>K[W]);if(F==="sum")Q[W]=q.reduce((K,L)=>(Number(K)||0)+(Number(L)||0),0);else if(F==="min")Q[W]=Math.min(...q.map(K=>Number(K)||0));else if(F==="max")Q[W]=Math.max(...q.map(K=>Number(K)||0));else if(F==="avg"){const K=q.reduce((L,ae)=>(Number(L)||0)+(Number(ae)||0),0);Q[W]=q.length?K/q.length:0}else F==="count"&&(Q[W]=q.length)});const pe={[R]:G,...Q,id:ee};k.set(ee,pe);const v={id:ee,parentId:j,depth:x,groupingKey:U,groupingField:R,groupingValue:G,aggregatedValues:Q,isExpanded:!1,children:[],label:`${R}: ${String(G)}`};v.aggregationPosition=g(v),E.set(ee,v);const D=y(A,x+1,ee);E.get(ee).children=D;const H=A.length;E.get(ee).descendantCount=H}),Y},I=y(o,0,null);return C.push(...I),{treeNodes:E,rootIds:C,groupingRows:k}},[o,r,i,e,g]);l.useEffect(()=>{if(s===-1){const E=new Set;m.forEach((k,C)=>{k.children&&k.children.length>0&&E.add(C)}),p(E)}else if(s>0){const E=new Set;m.forEach((k,C)=>{k.depth<s&&k.children&&k.children.length>0&&E.add(C)}),p(E)}else p(new Set)},[r,s]);const w=l.useCallback(E=>{p(k=>{const C=new Set(k);return C.has(E)?C.delete(E):C.add(E),C})},[]),b=l.useCallback(E=>f.has(E),[f]),M=l.useCallback(()=>{if(r.length===0)return null;const E=[],k=new Set,C=new Map;o.forEach(S=>C.set(e(S),S));const _=S=>{const x=m.get(S);if(!x)return!1;if(!x.children||x.children.length===0){const j=C.get(S);return!(!j||c&&!Nn(j,c))}return x.children.some(j=>_(j))},y=S=>{let x=S;c&&(x=S.filter(_)),a&&a.length>0&&x.sort((j,R)=>{const B=h.get(j)||C.get(j),Y=h.get(R)||C.get(R);if(!B||!Y)return 0;for(const A of a){const U=B[A.field],X=Y[A.field],G=In(U,X,A.sort);if(G!==0)return G}return 0}),x.forEach(j=>{if(k.has(j))return;const R=m.get(j),B=R?.children&&R.children.length>0,Y=B?h.get(j):C.get(j);if(Y&&R){k.add(j);const A={...Y,_treeDepth:R.depth,_isExpanded:f.has(j),_hasChildren:B,_groupingField:R.groupingField,_groupingValue:R.groupingValue,_descendantCount:R.descendantCount};E.push(A),I.has(j)&&B&&y(R.children)}})},I=f;return y(u),E},[o,e,m,u,h,c,a,f]),P=l.useCallback(E=>m.get(E),[m]);return l.useMemo(()=>({treeNodes:m,groupingRows:h,toggleExpansion:w,isGroupExpanded:b,getVisibleRows:M,getNode:P}),[m,h,w,b,M,P])}function jr(n){const{rows:o,getRowId:e,processRowUpdate:r,onProcessRowUpdateError:i,onRowChange:s}=n,[c,a]=l.useState(null),g=l.useRef(null),f=l.useCallback(h=>{a(h),g.current=typeof h=="function"?h(g.current):h},[]),p=l.useCallback(h=>{f({id:h.id,field:h.field,value:h.value,originalValue:h.value})},[]),m=l.useCallback(async h=>{const w=g.current;if(!w)return;if(h?.cancel){f(null);return}const{id:b,field:M,value:P,originalValue:E}=w;if(P===E){f(null);return}const k=o.find(_=>e(_)===b);if(!k){f(null);return}const C={...k,[M]:P};try{if(r){const _=await r(C,k);s?.(_)}else s?.(C);f(null)}catch(_){i&&i(_)}},[c,o,e,r,s,i]),u=l.useCallback(h=>{c&&c.id===h.id&&c.field===h.field&&f(w=>w?{...w,value:h.value}:null)},[c]);return{editingCell:c,startCellEdit:p,stopCellEdit:m,setEditCellValue:u}}function Er(n,o,e){const[r,i]=l.useState(new Map),[s,c]=l.useState({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}}),a=l.useCallback(()=>{i(new Map)},[]),g=l.useCallback((b,M)=>r.get(b)?.[M],[r]),f=l.useCallback((b,M,P,E,k)=>{const C=new Map(r);for(let _=E;_<k;_++){const y=o[_];if(!y)continue;let I=1;if(y.colSpan)if(typeof y.colSpan=="function"){const x={row:M,value:M[y.field],field:y.field,colDef:y,rowIndex:P,colIndex:_};I=y.colSpan(x)}else I=y.colSpan;if(I<=1){Tt(C,b,y.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:e[y.field]||100}});continue}let S=e[y.field]||100;for(let x=1;x<I;x++)if(_+x<k){const j=o[_+x];j&&(S+=e[j.field]||100,Tt(C,b,j.field,{spannedByColSpan:!0,leftVisibleCellIndex:_,rightVisibleCellIndex:Math.min(_+I-1,o.length-1)}))}Tt(C,b,y.field,{spannedByColSpan:!1,cellProps:{colSpan:I,width:S}}),_+=I-1}i(C)},[r,o,e]),p=l.useCallback((b,M)=>{const P={},E={},k={};o.forEach((C,_)=>{if(C.rowSpan)for(let y=b;y<M;y++){const I=n[y];if(!I||E[I.id]?.[C.field])continue;const S=C.valueGetter?C.valueGetter({row:I,field:C.field,value:I[C.field]}):I[C.field];let x=1;if(typeof C.rowSpan=="function"){const j={row:I,value:S,field:C.field,colDef:C,rowIndex:y,colIndex:_};x=C.rowSpan(j)}else typeof C.rowSpan=="number"&&(x=C.rowSpan);if(x>1){P[I.id]||(P[I.id]={}),P[I.id][C.field]=x;for(let j=1;j<x;j++){const R=y+j;if(R<M&&n[R]){const B=n[R];E[B.id]||(E[B.id]={}),E[B.id][C.field]=!0,k[R]||(k[R]={}),k[R][C.field]=y}}}}}),c({caches:{spannedCells:P,hiddenCells:E,hiddenCellOriginMap:k},processedRange:{firstRowIndex:b,lastRowIndex:M}})},[n,o]),m=l.useCallback(()=>{c({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}})},[]);l.useEffect(()=>{const b=new Map;n.forEach((k,C)=>{for(let _=0;_<o.length;_++){const y=o[_];if(!y)continue;let I=1;if(y.colSpan)if(typeof y.colSpan=="function"){const x={row:k,value:k[y.field],field:y.field,colDef:y,rowIndex:C,colIndex:_};I=y.colSpan(x)}else I=y.colSpan;if(I<=1){const x=e[y.field]||(typeof y.width=="number"?y.width:100);Tt(b,k.id,y.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:x}});continue}let S=e[y.field]||(typeof y.width=="number"?y.width:100);for(let x=1;x<I;x++)if(_+x<o.length){const j=o[_+x];if(j){const R=e[j.field]||(typeof j.width=="number"?j.width:100);S+=R,Tt(b,k.id,j.field,{spannedByColSpan:!0,leftVisibleCellIndex:_,rightVisibleCellIndex:Math.min(_+I-1,o.length-1)})}}Tt(b,k.id,y.field,{spannedByColSpan:!1,cellProps:{colSpan:I,width:S}}),_+=I-1}}),i(b);const M={},P={},E={};o.forEach((k,C)=>{if(k.rowSpan)for(let _=0;_<n.length;_++){const y=n[_];if(!y||P[y.id]?.[k.field])continue;const I=k.valueGetter?k.valueGetter({row:y,field:k.field,value:y[k.field]}):y[k.field];let S=1;if(typeof k.rowSpan=="function"){const x={row:y,value:I,field:k.field,colDef:k,rowIndex:_,colIndex:C};S=k.rowSpan(x)}else typeof k.rowSpan=="number"&&(S=k.rowSpan);if(S>1){M[y.id]||(M[y.id]={}),M[y.id][k.field]=S;for(let x=1;x<S;x++){const j=_+x;if(j<n.length&&n[j]){const R=n[j];P[R.id]||(P[R.id]={}),P[R.id][k.field]=!0,E[j]||(E[j]={}),E[j][k.field]=_}}}}}),c({caches:{spannedCells:M,hiddenCells:P,hiddenCellOriginMap:E},processedRange:{firstRowIndex:0,lastRowIndex:n.length}})},[n,o,e]);const u=l.useCallback(()=>s.caches.spannedCells,[s]),h=l.useCallback(()=>s.caches.hiddenCells,[s]),w=l.useCallback(()=>s.caches.hiddenCellOriginMap,[s]);return{colspanMap:r,resetColSpan:a,getCellColSpanInfo:g,calculateColSpan:f,rowSpanningState:s,calculateRowSpan:p,resetRowSpan:m,getSpannedCells:u,getHiddenCells:h,getHiddenCellOriginMap:w}}function Tt(n,o,e,r){let i=n.get(o);i||(i={},n.set(o,i)),i[e]=r}function Nr(n){const{dataSource:o,sortModel:e,filterModel:r,paginationModel:i,paginationMode:s,sortingMode:c,filterMode:a,aggregationModel:g,setRows:f,setRowCount:p,setDataSourceLoading:m,setDataSourceError:u,onAggregationResults:h}=n,w=l.useRef(null),b=l.useRef(0),M=l.useCallback(async()=>{if(!o)return;const E=++b.current;m(!0),u(null);const k=i.page*i.pageSize,C=k+i.pageSize,_={startRow:k,endRow:C,sortModel:e,filterModel:r,groupKeys:[],aggregationModel:g};try{const y=await o.getRows(_);if(E!==b.current)return;let I=!1;if(s==="infinite"){const S=w.current;if(S){const x=JSON.stringify(S.sortModel)!==JSON.stringify(e),j=JSON.stringify(S.filterModel)!==JSON.stringify(r),R=S.pageSize!==i.pageSize;!x&&!j&&!R&&i.page>S.page&&(I=!0)}}f(I?S=>[...S,...y.rows]:y.rows,!0),y.aggregationResults&&h&&h(y.aggregationResults),y.rowCount!==void 0&&p(y.rowCount),w.current={sortModel:e,filterModel:r,page:i.page,pageSize:i.pageSize}}catch(y){E===b.current&&(u(y),console.error("Data Source Error:",y))}finally{E===b.current&&m(!1)}},[o,i.page,i.pageSize,e,r,s,g,h,f,p,m,u]);l.useEffect(()=>{if(o&&(s==="server"||s==="infinite"||c==="server"||a==="server")){const k=setTimeout(()=>{M()},300);return()=>clearTimeout(k)}},[M,o,s,c,a]);const P=l.useCallback(async(E,k)=>{if(o){m(!0);try{const C=await o.getRows({startRow:0,endRow:-1,sortModel:e,filterModel:r,groupKeys:k});C.rows.length>0&&f(_=>{const y=new Set(_.map(S=>S.id)),I=C.rows.filter(S=>!y.has(S.id));return[..._,...I]})}catch(C){u(C),console.error("Failed to fetch children:",C)}finally{m(!1)}}},[o,e,r,f,m,u]);return{fetchRows:M,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:i,filterModel:s,sortModel:c,serverAggregationResults:a}=n,g=l.useMemo(()=>{if(r||Object.keys(e).length===0)return{};const E={};for(const[k,C]of Object.entries(e)){const _=Ir[C];if(!_){console.warn(`[useAggregation] Unknown aggregation function: "${C}"`);continue}const y=o.map(I=>I[k]);E[k]=_(y)}return E},[o,e,r]),[f,p]=l.useState({}),[m,u]=l.useState(!1),[h,w]=l.useState(null),b=l.useRef(0),M=l.useCallback(async()=>{if(!i?.getAggregations||Object.keys(e).length===0)return;const E=++b.current;u(!0),w(null);try{const k=await i.getAggregations({sortModel:c??[],filterModel:s??{items:[]},groupKeys:[],aggregationModel:e});E===b.current&&p(k)}catch(k){E===b.current&&(w(k),console.error("[useAggregation] Server aggregation error:",k))}finally{E===b.current&&u(!1)}},[i,e,s,c]);return l.useEffect(()=>{r&&i?.getAggregations&&!a&&M()},[M,r,i,a]),{aggregationResult:l.useMemo(()=>r?a&&Object.keys(a).length>0?a:f:g,[r,g,a,f]),isLoading:m,error:h}}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,i)=>r+i,0);case"avg":return e.reduce((r,i)=>r+i,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 l.useMemo(()=>{const i={pivotRows:[],pivotColumns:[],colKeys:[],isValid:!1};if(!r)return i;const{rowFields:s,columnFields:c,valueFields:a}=e;if(s.length===0||a.length===0)return i;const g=new Map(o.map(b=>[b.field,b])),f=new Set;for(const b of n)f.add(Mn(b,c));const p=Array.from(f).sort(),m=new Map;for(const b of n){const M=Mn(b,s);if(!m.has(M)){const C={};for(const _ of s)C[_]=b[_];m.set(M,{labelValues:C,bucket:new Map})}const P=m.get(M),E=Mn(b,c);P.bucket.has(E)||P.bucket.set(E,new Map);const k=P.bucket.get(E);for(const C of a){const _=Number(b[C.field]);k.has(C.field)||k.set(C.field,[]),isNaN(_)||k.get(C.field).push(_)}}let u=0;const h=[];for(const[,b]of m){const M={id:u++,...b.labelValues};for(const P of p){const E=b.bucket.get(P);for(const k of a){const C=c.length>0?`${P}${k.field}${k.aggFn}`:`${k.field}${k.aggFn}`,_=E?.get(k.field)??[];M[C]=_.length>0?Mr(_,k.aggFn):null}}h.push(M)}const w=[];for(const b of s){const M=g.get(b);w.push({field:b,headerName:M?.headerName??b,width:M?.width??140,sortable:!0})}for(const b of p){const M=c.length>0?b.split("\0").map((P,E)=>{const k=g.get(c[E]);return k?.headerName?`${k.headerName}: ${P}`:P}).join(" / "):"";for(const P of a){const E=g.get(P.field),k=c.length>0?`${b}${P.field}${P.aggFn}`:`${P.field}${P.aggFn}`,C=P.headerName??E?.headerName??P.field,_=M?`${M} — ${C} (${P.aggFn})`:`${C} (${P.aggFn})`;w.push({field:k,headerName:_,width:140,type:"number",align:"right",headerAlign:"right",sortable:!0,valueFormatter:({value:y})=>{if(y==null)return"—";const I=Number(y);return P.aggFn==="avg"?I.toFixed(2):P.aggFn==="count"?I.toLocaleString():E?.valueFormatter?E.valueFormatter({value:y,row:{},field:P.field}):I.toLocaleString()}})}}return{pivotRows:h,pivotColumns:w,colKeys:p,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:i}=n,s=l.useCallback(async()=>{if(o.size===0)return;const a=r().filter(u=>o.has(i(u)));if(a.length===0)return;const g=e.filter(u=>!u.field.startsWith("__")),f=g.map(u=>u.headerName||u.field).join(" "),p=a.map(u=>g.map(h=>{const w=u[h.field];return h.valueFormatter?h.valueFormatter({value:w,row:u,field:h.field}):w??""}).join(" ")).join(`
7
7
  `),m=`${f}
8
- ${p}`;try{await Tr(m)}catch(u){console.error("[OpenGridX] Failed to copy to clipboard:",u)}},[o,e,r,i]);return l.useEffect(()=>{const c=a=>{if(!(a.ctrlKey||a.metaKey)||a.key!=="c")return;const g=document.activeElement,f=g?.tagName.toLowerCase(),p=g?.type;f==="input"&&p!=="checkbox"&&p!=="radio"||f==="textarea"||f==="select"||g?.isContentEditable||s()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[s]),{copySelectedRows:s}}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:i,onHideAll:s,onColumnReorder:c}=n,[a,g]=l.useState(""),[f,p]=l.useState(null),m=l.useRef(null),h=l.useMemo(()=>o.filter(_=>_.hideable!==!1),[o]).every(_=>e.has(_.field)),w=l.useMemo(()=>{if(!a)return o;const _=a.toLowerCase();return o.filter(y=>(y.headerName||y.field).toLowerCase().includes(_))},[o,a]),b=_=>{_.target.checked?i():s()},M=_=>y=>{m.current=_,y.dataTransfer.effectAllowed="move",y.dataTransfer.setDragImage(y.currentTarget.closest(".ogx-column-visibility-panel__item"),20,20)},P=_=>y=>{y.preventDefault(),y.dataTransfer.dropEffect="move",_!==m.current&&p(_)},E=()=>{p(null)},k=_=>y=>{y.preventDefault();const I=m.current;p(null),m.current=null,I&&I!==_&&c&&c(I,_)},C=()=>{p(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:a,onChange:_=>g(_.target.value)})]})}),t.jsx("div",{className:"ogx-column-visibility-panel__list",children:w.map(_=>{const y=e.has(_.field),I=_.hideable!==!1,S=f===_.field,x=!!c&&!a;return t.jsxs("div",{className:["ogx-column-visibility-panel__item",!I&&"ogx-column-visibility-panel__item--disabled",S&&"ogx-column-visibility-panel__item--drag-over"].filter(Boolean).join(" "),draggable:x,onDragOver:x?P(_.field):void 0,onDragLeave:x?E:void 0,onDrop:x?k(_.field):void 0,onDragEnd:x?C:void 0,children:[x&&t.jsx("span",{className:"ogx-column-visibility-panel__drag-handle-wrapper",draggable:!0,onDragStart:M(_.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:I?"pointer":"not-allowed"},children:[t.jsx(qt,{checked:y,onChange:j=>r(_.field,j.target.checked),disabled:!I}),t.jsx("span",{className:"ogx-column-visibility-panel__label",children:_.headerName||_.field})]})]},_.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:h,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:i,children:"Reset"})]})]})}function Wr(n){const{rows:o,columns:e,getRowId:r,rowHeight:i=52,headerHeight:s=56,autoHeight:c=!1,checkboxSelection:a=!1,rowSelectionModel:g,onRowSelectionModelChange:f,onRowClick:p,onCellClick:m,filterModel:u,onFilterModelChange:h,sortModel:w,onSortModelChange:b,pagination:M=!1,paginationModel:P={page:0,pageSize:100},onPaginationModelChange:E,pageSizeOptions:k=[10,25,50,100],pinnedColumns:C,onPinnedColumnsChange:_,pinnedRows:y,getDetailPanelContent:I,getDetailPanelHeight:S,detailPanelExpandedRowIds:x,onDetailPanelExpandedRowIdsChange:j,pinCheckboxColumn:R=!0,pinExpandColumn:B=!0,disableColumnReorder:q=!1,columnOrder:A,onColumnOrderChange:U,height:Y,rowReordering:G=!1,onRowOrderChange:ee,loading:Q=!1,treeData:pe=!1,getTreeDataPath:v,defaultGroupingExpansionDepth:D,rowGroupingModel:H,aggregationModel:W,onAggregationModelChange:F,getAggregationPosition:X,isCellEditable:K,processRowUpdate:L,onProcessRowUpdateError:ae,dataSource:oe,sortingMode:me="client",filterMode:Ze="client",paginationMode:z="client",rowCount:Ee,slots:Ne,slotProps:ct,pivotMode:De=!1,pivotModel:ut,onPivotModelChange:gt,className:en="",style:Rt,onRowsScrollEnd:jt,ariaLabel:Ot,initialState:vt,onStateChange:ze,columnVisibilityModel:mo,onColumnVisibilityModelChange:bo,listView:cn=!1,listViewColumn:wo,columnGroupingModel:Et,noRowsLabel:Pn="No Data",apiRef:Tn}=n,Ci=l.useMemo(()=>({items:[]}),[]),Ve=u||Ci,[yi,ki]=l.useState(()=>vt?.sorting?.sortModel??[]),Ln=w!==void 0,et=Ln?w:yi,Si=l.useMemo(()=>[],[]),Rn=H||Si,On=W!==void 0,vo=l.useMemo(()=>Ne?.toolbar,[Ne?.toolbar]),[ji,Ei]=l.useState(()=>W??{}),tt=On?W:ji,Ni=l.useCallback(d=>{On||Ei(d),F?.(d)},[On,F]),[Ii,Mi]=l.useState(()=>vt?.columns?.columnVisibilityModel??{}),Wn=mo!==void 0,Xe=Wn?mo:Ii,tn=l.useCallback(d=>{Wn||Mi(d),bo?.(d)},[Wn,bo]),[Pi,Ti]=l.useState(()=>vt?.columns?.pinnedColumns??{}),Fn=C!==void 0,nt=Fn?C:Pi,An=l.useCallback(d=>{Fn||Ti(d),_?.(d)},[Fn,_]),Li=l.useMemo(()=>({rowFields:[],columnFields:[],valueFields:[]}),[]),[Ri,Oi]=l.useState(ut??Li),_o=ut??Ri,Wi=l.useCallback(d=>{Oi(d),gt?.(d)},[gt]),un=ao(o,e,_o,De),zn=De&&un.isValid?un.pivotRows:o,ot=De&&un.isValid?un.pivotColumns:e,[Fi,Co]=l.useState(null);l.useEffect(()=>{Co(null)},[tt]);const[Ai,zi]=l.useState(()=>vt?.pagination?.paginationModel??P),Bn=n.paginationModel!==void 0,fe=Bn?P:Ai,gn=l.useCallback(d=>{Bn||zi(d),E?.(d)},[Bn,E]),[Bi,yo]=l.useState([]),nn=g!==void 0,ko=nn?g:Bi,Ie=l.useMemo(()=>new Set(ko),[ko]),fn=f,Nt=l.useRef(null),$i=l.useRef(null),hn=l.useRef(null),Di=l.useCallback(d=>d.id,[]),pn=r||Di,[qe,Wt]=l.useState(null),Ft=l.useCallback(d=>{Xn.current?.classList.toggle("ogx--kb",d)},[]),So=l.useRef(oe);So.current=oe;const jo=l.useRef(null),Eo=l.useRef(null),Hi=l.useCallback(d=>{if(So.current&&pe&&d.serverChildrenCount>0&&d.children.length===0){const N=Eo.current?.getNodePath(d.id)||[d.groupingKey];jo.current?.(d.id,N)}},[pe]),rt=hr({rows:zn,columns:ot,rowHeight:i,headerHeight:s,rowCount:Ee,columnVisibilityModel:Xe,initialState:n.initialState}),{state:de,apiRef:At,setRows:$n,setColumns:No,setScroll:Io,setDimensions:Mo,setDataSourceLoading:Gi,setDataSourceError:Vi,setRowCount:Ui}=rt;l.useEffect(()=>{Tn&&(Tn.current=At.current)},[Tn,At]);const{copySelectedRows:Po}=Lr({selectedRowIds:Ie,columns:ot,getVisibleRows:()=>At.current.getVisibleRows(),getRowId:pn});l.useEffect(()=>{At.current.copySelectedRows=Po,At.current.getSelectedRows=()=>Array.from(Ie)},[Po,Ie,At]);const Ki=de.dataSource.loading,on=Q||Ki,rn=l.useMemo(()=>de.rows.allRows.map(d=>de.rows.idRowsLookup.get(d)),[de.rows]),Dn=yr({rows:rn,getRowId:pn,getTreeDataPath:v,treeData:pe,defaultGroupingExpansionDepth:D,filterModel:Ve,sortModel:et,onRowExpansionChange:Hi});l.useEffect(()=>{Eo.current=Dn},[Dn]);const Yi=Sr({rows:rn,getRowId:pn,rowGroupingModel:Rn,aggregationModel:tt,defaultGroupingExpansionDepth:D,filterModel:Ve,sortModel:et,getAggregationPosition:X}),Be=jr({rows:rn,getRowId:pn,processRowUpdate:L,onProcessRowUpdateError:ae,onRowChange:d=>{const{dispatch:N}=rt,$=Array.from(rt.state.rows.idRowsLookup.values()).map(Z=>Z.id===d.id?d:Z);N({type:"SET_ROWS",payload:$})}}),Hn=pe,zt=!!(Rn&&Rn.length>0),xn=Hn||zt,$e=Hn?Dn:zt?Yi:null,Me=M&&!zt,mn=l.useCallback(d=>{const{row:N,id:T}=d;if(xn&&N._hasChildren){$e?.toggleExpansion(T);return}p?.(d)},[xn,$e,p]),ye=l.useMemo(()=>xn?ot.map((d,N)=>N===0?{...d,renderCell:T=>{const{_treeDepth:$,_hasChildren:Z,_isExpanded:re,_groupingField:ue,_groupingValue:Oe,_descendantCount:We}=T.row,xe=($||0)*24;let se=d.renderCell?d.renderCell(T):T.value;return Hn&&Z&&T.row._isGroupRow&&(se=t.jsxs("div",{className:"ogx__group-cell-content",children:[T.value,We!==void 0&&We>0?` (${We})`:""]})),zt&&Z&&ue&&(se=t.jsxs("div",{className:"ogx__group-cell-content",children:[d.field===ue?"":`${ue}: `,String(Oe),We!==void 0?` (${We})`:""]})),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(),$e?.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(),$e?.toggleExpansion(T.row.id)}})}):null}),t.jsx("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:se})]})}}:{...d,renderCell:T=>{const{_hasChildren:$,_groupingField:Z}=T.row;return zt&&$?d.field===Z?null:T.value!==void 0&&T.value!==null?d.renderCell?d.renderCell(T):T.value:null:d.renderCell?d.renderCell(T):T.value}}):ot,[ot,xn,zt,$e]),Gn=Nr({dataSource:oe,sortModel:et,filterModel:Ve,paginationModel:fe,paginationMode:z,sortingMode:me,filterMode:Ze,aggregationModel:tt,setRows:$n,setRowCount:Ui,setDataSourceLoading:Gi,setDataSourceError:Vi,onAggregationResults:Co});l.useEffect(()=>{Gn.fetchChildren&&(jo.current=Gn.fetchChildren)},[Gn.fetchChildren]);const[Ue,Xi]=l.useState(()=>vt?.columns?.columnWidths??{}),[qi,bn]=l.useState(()=>vt?.columns?.columnOrder??ot.map(d=>d.field)),_t=A||qi;l.useEffect(()=>{oe||$n(zn)},[zn,$n,oe]),l.useEffect(()=>{No(ot)},[ot,No]),l.useEffect(()=>{De&&bn(ot.map(d=>d.field))},[De,ot]);const Bt=l.useMemo(()=>{if(q)return ye;const d=new Map(_t.map((N,T)=>[N,T]));return[...ye].sort((N,T)=>{const $=d.get(N.field)??ye.indexOf(N),Z=d.get(T.field)??ye.indexOf(T);return $-Z})},[ye,_t,q]),To=l.useMemo(()=>Bt.filter(d=>Xe[d.field]!==!1),[Bt,Xe]),$t=pr({columns:Bt,onColumnOrderChange:l.useCallback(d=>{const{oldIndex:N,targetIndex:T}=d,$=[..._t],[Z]=$.splice(N,1);$.splice(T,0,Z),A||bn($),U?.(d)},[_t,A,U]),disableColumnReorder:q}),[Ji,Qi]=l.useState(new Set),Ct=x??Ji,Je=!!I,ln=l.useCallback(d=>{const N=new Set(Ct);N.has(d)?N.delete(d):N.add(d),x===void 0&&Qi(N),j?.(N)},[Ct,x,j]),we=l.useMemo(()=>{const d=[];return G&&d.push({field:"__reorder_col__"}),Je&&d.push({field:"__expand_col__"}),a&&d.push({field:"__checkbox_col__"}),[...d,...Bt]},[Bt,a,Je,G]),Zi=l.useCallback((d,N)=>{Xi(T=>({...T,[d]:N}))},[]),Vn=l.useRef(ze);Vn.current=ze,l.useEffect(()=>{if(!Vn.current)return;const d={sorting:{sortModel:et},filter:{filterModel:Ve},pagination:{paginationModel:fe},columns:{columnWidths:Ue,columnOrder:_t,columnVisibilityModel:Xe,pinnedColumns:nt}};Vn.current(d)},[et,Ve,fe,Ue,_t,Xe,nt]);const wn=l.useMemo(()=>rn,[rn]),He=l.useMemo(()=>$e?$e.getVisibleRows()||[]:Ze==="server"&&oe?wn:vr(wn,Ve),[wn,Ve,$e,Ze,oe]),{top:Ke,center:Dt,bottom:it}=l.useMemo(()=>$e?{top:[],center:He,bottom:[]}:Do(He,y),[He,y,$e]),Pe=l.useMemo(()=>$e||me==="server"&&oe?Dt:Cr(Dt,et),[Dt,et,$e,me,oe]),ft=l.useMemo(()=>{if(!Me||z==="server"&&oe)return Pe;const d=fe.page*fe.pageSize,N=d+fe.pageSize;return Pe.slice(d,N)},[Pe,Me,fe.page,fe.pageSize,z,oe]);l.useEffect(()=>{rt.apiRef.current.getVisibleRows=()=>Pe,rt.apiRef.current.getVisibleColumns=()=>ye},[Pe,ye,rt.apiRef]);const Ht=xr({rows:Me?ft:Pe,getRowId:d=>d.id,onRowOrderChange:ee,rowReordering:G}),ke=l.useMemo(()=>{if($e)return Dt;const d=Me?ft:Pe,N=[...Ke,...d,...it];if(z==="infinite"&&de.dataSource.loading&&N.length>0){const T=Math.min(fe.pageSize,20),$=Array.from({length:T},(Z,re)=>({id:`__skeleton_${re}__`,_isSkeleton:!0}));return[...N,...$]}return N},[Ke,ft,Pe,it,Me,$e,Dt,z,de.dataSource.loading,fe.pageSize]),Gt=Er(ke,we,Ue),{aggregationResult:Un}=so({rows:He,aggregationModel:tt,isServerSide:!!(oe&&(z==="server"||me==="server")),dataSource:oe,filterModel:Ve,sortModel:et,serverAggregationResults:Fi}),vn=Object.keys(tt).length>0;l.useEffect(()=>{rt.apiRef.current.getAggregationResult=()=>vn?Un:null,rt.apiRef.current.getAggregationModel=()=>vn?tt:null},[Un,tt,vn,rt.apiRef]);const Kn=l.useMemo(()=>{const d=i,N=Me?ft:Pe,T=N.map((O,J)=>{let te=d;if(Ct.has(O.id)){const je=S?.({row:O,id:O.id,rowIndex:Ke.length+J})??200;te+=typeof je=="number"?je:parseInt(String(je),10)||200}return te}),$=T.reduce((O,J,te)=>(O.push((O[te-1]||0)+J),O),[]),re=(z==="infinite"&&de.dataSource.loading&&N.length>0?Math.min(fe.pageSize,20):0)*d,ue=($[$.length-1]||0)+re,Oe=Ke.length*d,We=it.length*d,le=[],xe=[],se=[],V=[];To.forEach(O=>{const J=dn(O.field,nt);J==="left"?le.push(O):J==="right"?xe.push(O):se.push(O)});const he=de.dimensions.viewportWidth||1e3,Ce=(a?48:0)+(Je?48:0)+(G?48:0),be=O=>Ue[O.field]??O.width,Te=O=>{if(O===void 0)return{type:"auto",value:0};if(typeof O=="number")return{type:"fixed",value:O};if(typeof O=="string"){if(O.toLowerCase()==="auto")return{type:"auto",value:0};if(O.endsWith("%"))return{type:"percentage",value:parseFloat(O)};const J=parseFloat(O);if(!isNaN(J))return{type:"fixed",value:J}}return{type:"fixed",value:100}},Le=le.reduce((O,J)=>{const te=Te(be(J));return O+(te.type==="fixed"?te.value:100)},0),ge=xe.reduce((O,J)=>{const te=Te(be(J));return O+(te.type==="fixed"?te.value:100)},0),ce=se.reduce((O,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 O+(mt||qn)}const je=Te(be(J));return je.type==="fixed"?O+je.value:je.type==="percentage"?O+100:O+(J.minWidth??150)},0),ht=Math.max(he-Ce-Le-ge,ce),lt=[],Fe=[],Se=[];let Ae=0;se.forEach(O=>{const J=Object.prototype.hasOwnProperty.call(Ue,O.field),te=Te(be(O));if(!J&&O.flex&&O.flex>0){Se.push({col:O,flex:O.flex}),Ae+=O.flex;return}te.type==="fixed"?lt.push({col:O,width:te.value}):te.type==="percentage"?Fe.push({col:O,percentage:te.value}):(Se.push({col:O,flex:1}),Ae+=1)});const Ge=lt.reduce((O,{width:J})=>O+J,0);let Re=Math.max(0,ht-Ge);const st=new Map;Fe.forEach(({col:O,percentage:J})=>{const te=J/100*Re;st.set(O.field,te),Re-=te}),Re=Math.max(0,Re);const yt=new Map,pt=Se.map(O=>({...O,minWidth:O.col.minWidth??50,maxWidth:O.col.maxWidth??1/0,frozen:!1,computedWidth:0}));(()=>{let O=0;const J=pt.length*2;for(;O<J;){O++;const te=pt.filter(ne=>!ne.frozen);if(te.length===0)break;const je=te.reduce((ne,at)=>ne+at.flex,0),mt=pt.reduce((ne,at)=>at.frozen?ne+at.computedWidth:ne,0),qn=Math.max(0,Re-mt);if(je<=0){te.forEach(ne=>{ne.computedWidth=ne.minWidth,ne.frozen=!0});break}const dl=qn/je;let yn=0;const kn=[],Sn=[];if(te.forEach(ne=>{const at=dl*ne.flex;if(at<ne.minWidth){const Jn=ne.minWidth-at;yn+=Jn,kn.push(ne)}else if(at>ne.maxWidth){const Jn=ne.maxWidth-at;yn+=Jn,Sn.push(ne)}else ne.computedWidth=at}),kn.length===0&&Sn.length===0){te.forEach(ne=>ne.frozen=!0);break}yn>0?kn.forEach(ne=>{ne.computedWidth=ne.minWidth,ne.frozen=!0}):yn<0?Sn.forEach(ne=>{ne.computedWidth=ne.maxWidth,ne.frozen=!0}):(kn.forEach(ne=>{ne.computedWidth=ne.minWidth,ne.frozen=!0}),Sn.forEach(ne=>{ne.computedWidth=ne.maxWidth,ne.frozen=!0}))}})(),pt.forEach(O=>yt.set(O.col.field,O.computedWidth));const Ut=new Map;se.forEach(O=>{let J;if(yt.has(O.field))J=yt.get(O.field);else{const te=lt.find(mt=>mt.col.field===O.field),je=Fe.find(mt=>mt.col.field===O.field);if(te)J=te.width;else if(je){const mt=st.get(O.field)||0;J=Math.max(O.minWidth??50,mt||100)}else J=100}V.push(J),Ut.set(O.field,J)});const xt=se.map(O=>{const J=pt.find(te=>te.col.field===O.field);return{...O,width:Ut.get(O.field)??(typeof O.width=="number"?O.width:100),flex:J?J.flex:O.flex}}),Ye=11,It=le.map((O,J)=>{const te=Te(be(O)),je=te.type==="fixed"?te.value:100;return{...O,width:je,zIndex:Ye+J}}),Kt=11,kt=xe.map((O,J)=>{const te=Te(be(O)),je=te.type==="fixed"?te.value:100;return{...O,width:je,zIndex:Kt+(xe.length-1-J)}}),Qe=V.reduce((O,J)=>O+J,0),ve=Le+Qe+ge+Ce,al=V.reduce((O,J,te)=>(O.push((O[te-1]||0)+J),O),[]);return{rowHeights:T,cumulativeHeights:$,unpinnedRowsHeight:ue,pinnedTopHeight:Oe,pinnedBottomHeight:We,leftPinnedCols:It,rightPinnedCols:kt,unpinnedColsWithWidth:xt,unpinnedColWidths:V,unpinnedAccWidths:al,totalWidth:ve,leftWidth:Le,rightWidth:ge,unpinnedTotalWidth:Qe,systemColumnsWidth:Ce,pinnedTopRowsLength:Ke.length,pinnedBottomRowsLength:it.length,unpinnedRowsLength:N.length}},[i,Me,ft,Pe,Ct,S,Ke.length,it.length,Ct,S,Ke.length,it.length,To,nt,Ue,de.dimensions.viewportWidth,a,Je,G,R,B,c,z,de.dataSource.loading,fe.pageSize]),_e=l.useMemo(()=>{const{unpinnedAccWidths:d,unpinnedColsWithWidth:N,leftPinnedCols:T,rightPinnedCols:$,totalWidth:Z,leftWidth:re,rightWidth:ue,unpinnedTotalWidth:Oe,systemColumnsWidth:We,cumulativeHeights:le,pinnedTopHeight:xe,pinnedBottomHeight:se,unpinnedRowsHeight:V,rowHeights:he,unpinnedRowsLength:Ce}=Kn,be=de.virtualization.scrollLeft,Te=de.virtualization.scrollTop,Le=de.dimensions.viewportWidth||1e3,ge=c?xe+V+se+50:de.dimensions.viewportHeight||600,ce=6,ht=Math.max(0,be-re),lt=be+Le-re;let Fe=0,Se=N.length-1,Ae=0,Ge=d.length-1;for(;Ae<=Ge;){const ve=Ae+Ge>>>1;d[ve]<ht?Ae=ve+1:Ge=ve-1}Fe=Math.max(0,Ae-ce);for(let ve=Fe;ve<d.length;ve++){if((ve===0?0:d[ve-1])>lt){Se=Math.min(N.length-1,ve+ce);break}Se=Math.min(N.length-1,ve+ce)}const Re=Fe>0?d[Fe-1]:0,st=Oe-d[Se],yt=[...T,...Re>0?[{field:"__spacer_left__",width:Re,isSpacer:!0}]:[],...N.slice(Fe,Se+1),...st>0?[{field:"__spacer_right__",width:st,isSpacer:!0}]:[],...$],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+ge){It=Math.min(Ce-1,ve+xt);break}return{renderContext:{firstRowIndex:Ye,lastRowIndex:It,firstColumnIndex:Fe,lastColumnIndex:Se},offsetTop:Kt,offsetLeft:0,totalHeight:Ut,pinnedTopHeight:xe,pinnedBottomHeight:se,totalWidth:Z,rowHeights:he,cumulativeHeights:le,virtualColumns:yt,columnMetrics:{leftPinnedWidth:re,rightPinnedWidth:ue,unpinnedAccWidths:d,unpinnedCols:N,totalSpecialsWidth:We,pinnedSpecialsWidth:(G?48:0)+(Je&&B?48:0)+(a&&R?48:0)}}},[Kn,de.virtualization.scrollTop,de.virtualization.scrollLeft,de.dimensions.viewportHeight,de.dimensions.viewportWidth,c]),el=l.useCallback(d=>{const N=d.currentTarget;if(Io(N.scrollTop,N.scrollLeft),jt){const{scrollTop:T,scrollHeight:$,clientHeight:Z}=N;$-T-Z<100&&jt({visibleTop:T,visibleBottom:T+Z,viewportHeight:Z})}},[Io,jt]);l.useEffect(()=>{if(!Nt.current)return;const d=new ResizeObserver(N=>{for(const T of N){const{width:$,height:Z}=T.contentRect;Mo($,Z)}});return d.observe(Nt.current),()=>{d.disconnect()}},[Mo]);const Vt=l.useCallback((d,N)=>{const T=new Set(Ie);N?T.add(d):T.delete(d);const $=Array.from(T);nn||yo($),fn?.($)},[Ie,nn,fn]),tl=l.useCallback(d=>{let N=[];d&&(N=wn.map(T=>T.id)),nn||yo(N),fn?.(N)},[o,nn,fn]),Lo=l.useCallback((d,N)=>{const T=N?[{field:d,sort:N}]:[];Ln||ki(T),b?.(T)},[Ln,b]),Yn=l.useCallback(d=>{Ft(!1),Wt({id:d.row.id,field:d.field}),hn.current?.focus({preventScroll:!0}),m?.(d)},[m,Ft]),Ro=l.useRef(Be.editingCell);l.useEffect(()=>{const d=!!Ro.current,N=!!Be.editingCell;d&&!N&&hn.current?.focus({preventScroll:!0}),Ro.current=Be.editingCell},[Be.editingCell]);const Oo=l.useMemo(()=>{const{firstRowIndex:d,lastRowIndex:N}=_e.renderContext,T=Ke.length,$=Ke.map((se,V)=>({row:se,rowIndex:V})),Z=it.map((se,V)=>({row:se,rowIndex:T+(Me?ft.length:Pe.length)+V})),re=Math.max(0,d-T),ue=Math.min(Me?ft.length:Pe.length,N-T+1),Oe=(Me?ft:Pe).slice(re,ue).map((se,V)=>({row:se,rowIndex:T+re+V})),We=[...$,...Oe,...Z],le=new Set;return We.filter(se=>le.has(se.row.id)?!1:(le.add(se.row.id),!0))},[_e.renderContext,Ke,it,ft,Pe,Me,z,de.dataSource.loading,fe.pageSize,i]),nl=o.length>0&&Ie.size===o.length,ol=Ie.size>0&&Ie.size<o.length,rl=l.useCallback(d=>{d.target===d.currentTarget&&Wt(N=>{if(N)return N;if(a)return{id:"HEADER",field:"__checkbox_col__"};const T=ke[0],$=we[0];return T&&$?{id:T.id,field:$.field}:null})},[ke,we]),il=l.useCallback(d=>{d.currentTarget.contains(d.relatedTarget)||Wt(null)},[]),ll=l.useCallback(d=>{if(Ft(!0),!qe)return;const{id:N,field:T}=qe,$=!!Be.editingCell;if(d.key==="Enter"){if(d.preventDefault(),$)Be.stopCellEdit();else if(we.find(he=>he.field===T)?.editable){const he=ke.find(Ce=>Ce.id===N);he&&Be.startCellEdit({id:N,field:T,value:he[T]})}return}if((d.key===" "||d.key==="Spacebar")&&!$){if(T==="__checkbox_col__"){d.preventDefault(),Vt(N,!Ie.has(N));return}if(T==="__expand_col__"){d.preventDefault(),ln(N);return}}if(N==="HEADER"&&(d.key==="Enter"||d.key===" ")){d.preventDefault();const V=we.find(he=>he.field===T);if(V&&V.sortable!==!1){const he=et.find(be=>be.field===T);let Ce="asc";he&&(he.sort==="asc"?Ce="desc":Ce=null),Lo(T,Ce)}return}if(d.key==="Escape"){$&&(d.preventDefault(),Be.stopCellEdit({cancel:!0}));return}if($&&d.key!=="Tab")return;const Z=N==="HEADER",re=Z?-1:ke.findIndex(V=>V.id===N),ue=we.findIndex(V=>V.field===T);if(!Z&&re===-1||ue===-1)return;const Oe=(V,he,Ce,be,Te,Le=!1)=>{let ge=V+Ce,ce=he+be;return Te&&be!==0&&(be>0&&ce>=we.length?(ce=0,ge++):be<0&&ce<0&&(ce=we.length-1,ge--)),!Te&&(ce<0||ce>=we.length)||ge<(Le?-1:0)||ge>=ke.length?null:{r:ge,c:ce}},We=(V,he,Ce,be,Te,Le=!1)=>{let ge=V,ce=he,ht=0;const lt=ke.length*we.length+we.length;for(;ht<lt;){if(ht++,ge+=Ce,ce+=be,be!==0)be>0?ce>=we.length&&(ce=0,ge++):ce<0&&(ce=we.length-1,ge--);else if(ce<0||ce>=we.length)return null;if(ge<-1||ge>=ke.length)return null;if(ge===-1){if(!Le)continue;const Re=we[ce],st=Re.sortable!==!1;if(["__checkbox_col__"].includes(Re.field)||st)return{r:ge,c:ce};continue}const Fe=ke[ge],Se=we[ce],Ae=["__checkbox_col__","__expand_col__","__reorder_col__"].includes(Se.field);let Ge=Se.editable||Ae;if(K&&!Ae)try{Ge=K({row:Fe,field:Se.field,value:Fe[Se.field],colDef:Se,rowIndex:ge,colIndex:ce})}catch(Re){console.error("Error in isCellEditable:",Re)}if(Ge)return{r:ge,c:ce}}return null};let le=re,xe=ue,se=!1;if(d.key==="Tab"){const V=d.shiftKey?-1:1,he=We(re,ue,0,V,!0,!1);he&&(le=he.r,xe=he.c,se=!0)}else if(d.key==="ArrowRight"){const V=Oe(re,ue,0,1,!0,!0);V&&(le=V.r,xe=V.c,se=!0)}else if(d.key==="ArrowLeft"){const V=Oe(re,ue,0,-1,!0,!0);V&&(le=V.r,xe=V.c,se=!0)}else if(d.key==="ArrowDown"){const V=Oe(re,ue,1,0,!1,!0);V&&(le=V.r,xe=V.c,se=!0)}else if(d.key==="ArrowUp"){const V=Oe(re,ue,-1,0,!1,!0);V&&(le=V.r,xe=V.c,se=!0)}else if(d.key==="Home")(d.ctrlKey||d.metaKey)&&(le=-1),xe=0,se=!0;else if(d.key==="End")(d.ctrlKey||d.metaKey)&&(le=ke.length-1),xe=we.length-1,se=!0;else if(d.key==="PageUp"){const V=Me?fe.pageSize:10;le=Math.max(-1,le-V),se=!0}else if(d.key==="PageDown"){const V=Me?fe.pageSize:10;le=Math.min(ke.length-1,le+V),se=!0}if(se&&(d.preventDefault(),$&&d.key==="Tab"&&Be.stopCellEdit(),le>=-1&&le<ke.length&&xe>=0&&xe<we.length)){const V=we[xe];if(le===-1)Wt({id:"HEADER",field:V.field});else{const he=ke[le];Wt({id:he.id,field:V.field})}if(Nt.current){const{cumulativeHeights:he,pinnedTopHeight:Ce}=_e,{clientHeight:be,clientWidth:Te,scrollTop:Le,scrollLeft:ge}=Nt.current,ce=le===0?0:he[le-1],ht=he[le],lt=Ce,Fe=Le+lt,Se=Le+be;let Ae=Le;if(ce<Fe?Ae=Math.max(0,ce-lt):ht>Se&&(Ae=ht-be),Ae!==Le&&(Nt.current.scrollTop=Ae),_e.columnMetrics){const{leftPinnedWidth:Ge,rightPinnedWidth:Re,unpinnedAccWidths:st,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?st[xt-1]:0),It=pt+Ge+st[xt],Kt=ge+sn+Ge,kt=ge+Te-Re;let Qe=ge;Ye<Kt?Qe=Math.max(0,Ye-sn-Ge):It>kt&&(Qe=It-Te+Re),Qe!==ge&&(Nt.current.scrollLeft=Qe)}}}}},[qe,ke,we,Be,_e,Ie,Vt,ln]),sl=l.useMemo(()=>ye.some(d=>!!d.rowSpan),[ye]),[_n,Cn]=l.useState(!1),Xn=l.useRef(null);return l.useEffect(()=>{if(!_n||Ne?.toolbar)return;function d(N){const T=document.getElementById("ogx-standalone-col-panel");T&&!T.contains(N.target)&&Cn(!1)}return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[_n,Ne?.toolbar]),t.jsxs("div",{ref:Xn,className:`ogx ${en} ${c?"ogx--auto-height":""} ${sl?"ogx--row-spanning":""} ${cn?"ogx--list-view":""}`,style:{...Rt,height:Y??Rt?.height,"--ogx-row-height":`${i}px`,"--ogx-header-height":`${s}px`},"aria-busy":on,children:[vo&&(()=>{const d={apiRef:rt.apiRef,columns:ye,aggregationModel:tt,onAggregationModelChange:Ni,...De?{pivotModel:_o,onPivotModelChange:Wi}:{},filterModel:Ve,onFilterModelChange:h,columnVisibilityModel:Xe,onColumnVisibilityModelChange:tn,onColumnReorder:(N,T)=>{const $=[..._t],Z=$.indexOf(N),re=$.indexOf(T);if(Z===-1||re===-1)return;const ue=[...$];ue.splice(Z,1),ue.splice(re,0,N),A||bn(ue);const Oe=ye.find(We=>We.field===N);Oe&&U?.({oldIndex:Z,targetIndex:re,column:Oe})},forceColumnsOpen:_n,onColumnsPanelClose:()=>Cn(!1),...ct?.toolbar};return t.jsx(vo,{...d})})(),!Ne?.toolbar&&_n&&St.createPortal(t.jsxs("div",{id:"ogx-standalone-col-panel",style:(()=>{const d=Xn.current?.getBoundingClientRect();return{position:"fixed",top:d?d.top+8:16,right:d?window.innerWidth-d.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:ye,visibleColumns:new Set(ye.filter(d=>Xe[d.field]!==!1).map(d=>d.field)),onVisibilityChange:(d,N)=>{tn({...Xe,[d]:N})},onShowAll:()=>{const d={...Xe};ye.forEach(N=>{N.hideable!==!1&&(d[N.field]=!0)}),tn(d)},onHideAll:()=>{const d={...Xe};ye.forEach(N=>{N.hideable!==!1&&(d[N.field]=!1)}),tn(d)},onColumnReorder:(d,N)=>{const T=[..._t],$=T.indexOf(d),Z=T.indexOf(N);if($===-1||Z===-1)return;const re=[...T];re.splice($,1),re.splice(Z,0,d),A||bn(re),U?.({oldIndex:$,targetIndex:Z,column:ye.find(ue=>ue.field===d)})}})]}),document.body),cn&&wo&&t.jsxs("div",{className:"ogx-list-view",role:"grid","aria-label":Ot||"Data grid list view","aria-rowcount":ke.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 ${fe.page+1} of ${Math.ceil(He.length/fe.pageSize)||1}`:"",Ie.size>0?` · ${Ie.size} selected`:""]})}),t.jsx("div",{className:"ogx-list-view__rows",children:ke.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"})]}),Pn]}):ke.map((d,N)=>t.jsx(zo,{row:d,rowIndex:N,listViewColumn:wo,isSelected:Ie.has(d.id),checkboxSelection:a,rowHeight:i,onRowClick:T=>mn({row:T,id:T.id,rowIndex:N}),onSelectionChange:Vt},d.id))}),Me&&(()=>{const d=Ne?.pagination||lo,N=z==="server"&&oe?de.pagination.rowCount||0:He.length,T={page:fe.page,pageSize:fe.pageSize,rowCount:N,pageSizeOptions:k,onPageChange:$=>gn({...fe,page:$}),onPageSizeChange:$=>gn({...fe,pageSize:$,page:0}),...ct?.pagination};return t.jsx(d,{...T})})()]}),!cn&&t.jsx("div",{ref:d=>{Nt.current=d,hn.current=d},className:"ogx__viewport",onScroll:el,role:"grid","aria-label":Ot||"Data grid","aria-rowcount":He.length+1,"aria-colcount":e.length+(a?1:0)+(Je?1:0)+(G?1:0),"aria-busy":on,tabIndex:0,onKeyDownCapture:()=>{Ft(!0)},onMouseDownCapture:()=>{Ft(!1)},onKeyDown:ll,onFocus:rl,onBlur:il,children:t.jsxs("div",{ref:$i,className:"ogx__content",style:{width:_e.totalWidth},role:"presentation",children:[t.jsx(oo,{columns:_e.virtualColumns,allColumns:ye,columnGroupingModel:Et,checkboxSelection:a,allSelected:nl,someSelected:ol,onSelectAll:tl,sortModel:et,onSort:Lo,onColumnResize:Zi,columnWidths:Ue,pinnedColumns:nt,focusedCell:qe,onHeaderClick:d=>{Wt({id:"HEADER",field:d}),Ft(!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:R,pinExpandColumn:B,aggregationModel:tt,onHideColumn:d=>{tn({...Xe,[d]:!1})},onManageColumns:()=>Cn(!0),onPinColumn:(d,N)=>{const T=[...nt?.left??[]],$=[...nt?.right??[]],Z=T.filter(ue=>ue!==d),re=$.filter(ue=>ue!==d);An(N==="left"?{left:[...Z,d],right:re}:N==="right"?{left:Z,right:[...re,d]}:{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:Pn})]}),Ke.length>0&&t.jsx("div",{className:"ogx__pinned-rows ogx__pinned-rows--top",role:"rowgroup",children:Ke.map((d,N)=>t.jsx(Jt,{row:d,columns:_e.virtualColumns,rowIndex:N,isSelected:Ie.has(d.id),checkboxSelection:a,onRowClick:mn,onCellClick:Yn,onSelectionChange:Vt,columnWidths:Ue,pinnedColumns:nt,pinnedRows:y,hasDetailPanel:Je,isDetailPanelExpanded:Ct.has(d.id),detailPanelContent:I?I({row:d,id:d.id,rowIndex:N}):null,detailPanelHeight:S?.({row:d,id:d.id,rowIndex:N})||200,onDetailPanelToggle:ln,pinCheckboxColumn:R,pinExpandColumn:B,focusedCellField:qe?.id===d.id?qe.field:null,colspanMap:Gt.colspanMap,rowSpanningCaches:Gt.rowSpanningState.caches,rowHeight:i},d.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*i}px)`},role:"rowgroup",children:[on&&Oo.length===0?(()=>{const d=e.length>0?e:(()=>{const N=(de.dimensions.viewportWidth||1e3)-(a?48:0)-(I?48:0)-(G?48:0),T=150,$=Math.max(1,Math.ceil(N/T));return Array.from({length:$},(Z,re)=>({field:`placeholder_${re}`,headerName:"",width:T}))})();return Array.from({length:10}).map((N,T)=>t.jsx(ur,{columns:d,rowHeight:i,checkboxSelection:a,hasDetailPanel:!!I,rowReordering:G},`skeleton-${T}`))})():Oo.filter(({row:d})=>!jn(d.id,y)).filter((d,N,T)=>N===T.findIndex($=>$.row.id===d.row.id)).map(({row:d,rowIndex:N})=>t.jsx(Jt,{row:d,columns:_e.virtualColumns,rowIndex:N,isSelected:Ie.has(d.id),checkboxSelection:a,onRowClick:mn,onCellClick:Yn,onSelectionChange:Vt,columnWidths:Ue,pinnedColumns:nt,pinnedRows:y,hasDetailPanel:Je,isDetailPanelExpanded:Ct.has(d.id),detailPanelContent:I?I({row:d,id:d.id,rowIndex:N}):null,detailPanelHeight:S?.({row:d,id:d.id,rowIndex:N})||200,onDetailPanelToggle:ln,pinCheckboxColumn:R,pinExpandColumn:B,rowReordering:G,onDragStart:Ht.onDragStart,onDragOver:Ht.onDragOver,onDragEnd:Ht.onDragEnd,onDrop:Ht.onDrop,isDragging:Ht.draggedRowId===d.id,isDragOver:Ht.dragOverRowId===d.id,editingCell:Be.editingCell,onEditStart:Be.startCellEdit,onEditStop:Be.stopCellEdit,onEditCellValueChange:Be.setEditCellValue,focusedCellField:qe!=null&&qe.id===d.id?qe.field:null,colspanMap:Gt.colspanMap,rowSpanningCaches:Gt.rowSpanningState.caches,rowHeight:i},`${d.id}-${_e.totalWidth}`)),z==="infinite"&&de.dataSource.loading&&Pe.length>0&&(()=>{const d=Math.min(fe.pageSize,20),N=Kn.unpinnedRowsLength;return t.jsx("div",{className:"ogx__skeleton-group",children:Array.from({length:d}).map((T,$)=>t.jsx(Jt,{row:{id:`__skeleton_${$}__`,_isSkeleton:!0},columns:_e.virtualColumns,rowIndex:N+$,rowHeight:i},`__skeleton_${$}__`))})})()]})}),it.length>0&&t.jsx("div",{className:"ogx__pinned-rows ogx__pinned-rows--bottom",role:"rowgroup",children:it.map((d,N)=>t.jsx(Jt,{row:d,columns:_e.virtualColumns,rowIndex:N,isSelected:Ie.has(d.id),checkboxSelection:a,onRowClick:mn,onCellClick:Yn,onSelectionChange:Vt,columnWidths:Ue,pinnedColumns:nt,pinnedRows:y,hasDetailPanel:Je,isDetailPanelExpanded:Ct.has(d.id),detailPanelContent:I?I({row:d,id:d.id,rowIndex:N}):null,detailPanelHeight:S?.({row:d,id:d.id,rowIndex:N})||200,onDetailPanelToggle:ln,pinCheckboxColumn:R,pinExpandColumn:B,focusedCellField:qe?.id===d.id?qe.field:null,colspanMap:Gt.colspanMap,rowSpanningCaches:Gt.rowSpanningState.caches,rowHeight:i},d.id))}),vn&&t.jsxs("div",{className:"ogx__aggregation-footer",role:"row","aria-label":"Aggregation totals","aria-live":"polite",style:{minHeight:`${i}px`},children:[a&&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(d=>{const N=tt[d.field],T=Un[d.field],$=Ue[d.field]??(typeof d.width=="number"?d.width:120);return t.jsx("div",{className:"ogx__aggregation-cell",role:"gridcell",style:{width:$,minWidth:$,maxWidth:$,textAlign:d.align||"left"},children:N?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"ogx__aggregation-label",children:N}),t.jsx("span",{className:"ogx__aggregation-value",children:bt(T,N)})]}):null},d.field)})]})]})}),!cn&&Me&&(()=>{const d=Ne?.pagination||lo,N={page:fe.page,pageSize:fe.pageSize,rowCount:de.pagination.rowCount,pageSizeOptions:k,onPageChange:T=>gn({...fe,page:T}),onPageSizeChange:T=>gn({...fe,pageSize:T,page:0}),...ct?.pagination};return t.jsx(d,{...N})})(),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?Pn: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 Fr({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((i,s)=>t.jsx("div",{className:"ogx__skeleton-cell",children:t.jsx("div",{className:"ogx__skeleton-content"})},s))},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),i=!!o,s=o?.operator??r[0],c=u=>{const h=uo.has(u),w={id:o?.id??`${n.field}-${Date.now()}`,field:n.field,operator:u,value:h?void 0:o?.value??(n.type==="boolean"?"true":"")};e(w)},a=u=>{e({id:o?.id??`${n.field}-${Date.now()}`,field:n.field,operator:s,value:u})},g=()=>{e(null)},f=uo.has(String(s)),p=n.type==="boolean",m=!f;return t.jsxs("div",{className:`ogx-filter__row${i?" 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${i?" ogx-filter__op-select--active":""}`,value:String(s),onChange:u=>c(u.target.value),"aria-label":`Filter operator for ${n.headerName||n.field}`,children:r.map(u=>t.jsx("option",{value:u,children:u},u))}),m&&p&&t.jsxs("select",{id:`ogx-filter-val-${n.field}`,name:`filter-val-${n.field}`,className:`ogx-filter__value-input ogx-filter__value-select${i?" ogx-filter__value-input--active":""}`,value:String(o?.value??"true"),onChange:u=>a(u.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"})]}),m&&!p&&t.jsx("input",{id:`ogx-filter-val-${n.field}`,name:`filter-val-${n.field}`,className:`ogx-filter__value-input${i?" ogx-filter__value-input--active":""}`,type:n.type==="number"?"number":"text",value:o?.value??"",onChange:u=>a(u.target.value),placeholder:"Value…","aria-label":`Filter value for ${n.headerName||n.field}`}),i&&t.jsx("button",{className:"ogx-filter__row-clear",onClick:g,"aria-label":`Clear filter for ${n.headerName||n.field}`,title:"Clear",children:"×"})]})]})},go=({filterModel:n,columns:o,onFilterModelChange:e})=>{const r=n.items??[],i=n.logicOperator??"and",s=l.useCallback((g,f)=>{const p=r.filter(u=>"field"in u&&u.field!==g),m=f?[...p,f]:p;e({...n,items:m})},[r,n,e]),c=l.useCallback(g=>{e({...n,logicOperator:g})},[n,e]),a=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${i==="and"?" ogx-filter__logic-pill--active":""}`,onClick:()=>c("and"),"aria-pressed":i==="and",children:"ALL (AND)"}),t.jsx("button",{className:`ogx-filter__logic-pill${i==="or"?" ogx-filter__logic-pill--active":""}`,onClick:()=>c("or"),"aria-pressed":i==="or",children:"ANY (OR)"})]}),a.length===0?t.jsx("div",{className:"ogx-filter__empty",children:"No filterable columns."}):a.map(g=>t.jsx(zr,{col:g,item:Ar(r,g.field),onChange:f=>s(g.field,f)},g.field))]})},Br=["sum","avg","count","min","max"];function fo(){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:i}){const s=l.useRef(null),[c,a]=l.useState({top:0,right:0}),g=l.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]);l.useEffect(()=>{a(g());const x=()=>a(g());return window.addEventListener("scroll",x,!0),window.addEventListener("resize",x),()=>{window.removeEventListener("scroll",x,!0),window.removeEventListener("resize",x)}},[g]),l.useEffect(()=>{function x(R){s.current&&!s.current.contains(R.target)&&n.current&&!n.current.contains(R.target)&&i()}function j(R){R.key==="Escape"&&i()}return document.addEventListener("mousedown",x),document.addEventListener("keydown",j),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",j)}},[n,i]);const f=new Set(e.rowFields),p=new Set(e.columnFields),m=new Set(e.valueFields.map(x=>x.field)),u=x=>f.has(x)||p.has(x)||m.has(x);function h(x){f.has(x)||r({...e,rowFields:[...e.rowFields,x]})}function w(x){p.has(x)||r({...e,columnFields:[...e.columnFields,x]})}function b(x,j="sum"){m.has(x)||r({...e,valueFields:[...e.valueFields,{field:x,aggFn:j}]})}function M(x){r({...e,rowFields:e.rowFields.filter(j=>j!==x)})}function P(x){r({...e,columnFields:e.columnFields.filter(j=>j!==x)})}function E(x){r({...e,valueFields:e.valueFields.filter(j=>j.field!==x)})}function k(x,j){r({...e,valueFields:e.valueFields.map(R=>R.field===x?{...R,aggFn:j}:R)})}function C(){r({rowFields:[],columnFields:[],valueFields:[]})}const _=new Set(o.filter(x=>x.type==="number"||x.aggregable).map(x=>x.field)),y=e.rowFields.length+e.columnFields.length+e.valueFields.length,I=x=>o.find(j=>j.field===x)?.headerName??x,S=t.jsxs("div",{ref:s,className:"ogx-pivot-panel",role:"dialog","aria-label":"Pivot configuration",style:{top:c.top,right:c.right},children:[t.jsxs("div",{className:"ogx-pivot-panel__header",children:[t.jsxs("span",{className:"ogx-pivot-panel__title",children:[t.jsx(fo,{}),"Pivot Mode"]}),y>0&&t.jsx("button",{className:"ogx-pivot-panel__reset-btn",onClick:C,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:[I(x),t.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>M(x),title:`Remove ${I(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:[I(x),t.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>P(x),title:`Remove ${I(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:[I(x.field),t.jsx("select",{className:"ogx-pivot-chip__fn-select",value:x.aggFn,onChange:j=>k(x.field,j.target.value),title:"Aggregation function",children:Br.map(j=>t.jsx("option",{value:j,children:j.toUpperCase()},j))}),t.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>E(x.field),title:`Remove ${I(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 j=_.has(x.field);return u(x.field)?null:t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3},children:[t.jsx("span",{className:`ogx-pivot-field-btn${j?" 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:()=>h(x.field),title:"Add to Row Fields",children:"Row"}),t.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--col",onClick:()=>w(x.field),title:"Add to Column Fields",children:"Col"}),j&&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=>u(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,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[i,s]=l.useState(!1),[c,a]=l.useState(n),g=l.useRef(null),f=l.useRef(null);l.useEffect(()=>{a(n),n&&!i&&s(!0)},[n,i]),l.useEffect(()=>{const h=setTimeout(()=>{c!==n&&o(c)},r);return()=>clearTimeout(h)},[c,o,r,n]);const p=()=>{s(!0)},m=h=>{h.stopPropagation(),a(""),g.current?.focus(),o("")},u=()=>{c||s(!1)};return l.useEffect(()=>{const h=w=>{f.current&&!f.current.contains(w.target)&&(c||s(!1))};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[c]),t.jsxs("div",{ref:f,className:`ogx-global-search${i?" ogx-global-search--expanded":""}`,onClick:()=>{i||(s(!0),setTimeout(()=>g.current?.focus(),50))},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:c,onChange:h=>a(h.target.value),onFocus:p,onBlur:u,placeholder:e,"aria-label":"Global Search",autoComplete:"off"}),c&&t.jsx("button",{className:"ogx-global-search__clear",onClick:m,"aria-label":"Clear search",children:t.jsx(Hr,{})})]})}function Zt({title:n,children:o,placement:e="top",enterDelay:r=200,leaveDelay:i=0}){const[s,c]=l.useState(!1),[a,g]=l.useState({top:0,left:0}),f=l.useRef(null),p=l.useRef(null),m=l.useCallback(()=>{if(!p.current)return;const b=p.current.getBoundingClientRect();let M=0,P=0;const E=window.pageXOffset||document.documentElement.scrollLeft,k=window.pageYOffset||document.documentElement.scrollTop;e==="top"?(M=b.top+k-8,P=b.left+E+b.width/2):e==="bottom"&&(M=b.bottom+k+8,P=b.left+E+b.width/2),g({top:M,left:P})},[e]);l.useLayoutEffect(()=>(s&&(m(),window.addEventListener("scroll",m,!0),window.addEventListener("resize",m)),()=>{window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m)}),[s,m]);const u=()=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{c(!0)},r)},h=()=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{c(!1)},i)},w=l.useCallback(b=>{p.current=b?b.firstElementChild??b:null},[]);return t.jsxs(t.Fragment,{children:[t.jsx("span",{ref:w,style:{display:"inline-block",lineHeight:0},onMouseEnter:u,onMouseLeave:h,children:o}),s&&n&&St.createPortal(t.jsx("div",{className:`ogx-tooltip ogx-tooltip--${e}`,style:{top:a.top,left:a.left,position:"absolute",zIndex:99999},children:n}),document.body)]})}const Vr=["none","sum","avg","count","min","max"];function 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:i,onClose:s,activeCount:c}){const a=l.useRef(null),[g,f]=l.useState({top:0,right:0}),p=l.useCallback(()=>{if(!n.current)return{top:0,right:0};const u=n.current.getBoundingClientRect();return{top:u.bottom+6,right:window.innerWidth-u.right}},[n]);l.useEffect(()=>{f(p());const u=()=>f(p());return window.addEventListener("scroll",u,!0),window.addEventListener("resize",u),()=>{window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",u)}},[p]),l.useEffect(()=>{function u(h){a.current&&!a.current.contains(h.target)&&n.current&&!n.current.contains(h.target)&&s()}return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[n,s]),l.useEffect(()=>{function u(h){h.key==="Escape"&&s()}return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[s]);const m=t.jsxs("div",{ref:a,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"]}),c>0&&t.jsx("button",{className:"ogx-toolbar__clear-btn",onClick:i,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(u=>{const h=o[u.field]||"none";return t.jsxs("div",{className:"ogx-toolbar__agg-row",children:[t.jsx("span",{className:"ogx-toolbar__agg-label",title:u.field,children:u.headerName||u.field}),t.jsx("div",{className:"ogx-toolbar__agg-pills",children:Vr.map(w=>t.jsx("button",{className:`ogx-toolbar__pill${h===w?" ogx-toolbar__pill--active":""}`,onClick:()=>r(u.field,w),"aria-pressed":h===w,children:w},w))})]},u.field)})})]});return St.createPortal(m,document.body)}function Yr({anchorRef:n,columns:o,visibleColumns:e,onVisibilityChange:r,onShowAll:i,onHideAll:s,onColumnReorder:c,onClose:a}){const g=l.useRef(null),[f,p]=l.useState({top:0,right:0}),m=l.useCallback(()=>{if(!n.current)return{top:0,right:0};const h=n.current.getBoundingClientRect();return{top:h.bottom+6,right:window.innerWidth-h.right}},[n]);l.useEffect(()=>{p(m());const h=()=>p(m());return window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}},[m]),l.useEffect(()=>{function h(w){g.current&&!g.current.contains(w.target)&&n.current&&!n.current.contains(w.target)&&a()}return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[n,a]);const u=t.jsx("div",{ref:g,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Column visibility",style:{top:f.top,right:f.right,width:280,padding:0},children:t.jsx(co,{columns:o,visibleColumns:e,onVisibilityChange:r,onShowAll:i,onHideAll:s,onColumnReorder:c})});return St.createPortal(u,document.body)}function Xr({anchorRef:n,columns:o,filterModel:e,onFilterModelChange:r,onClose:i}){const s=l.useRef(null),[c,a]=l.useState({top:0,right:0}),g=l.useCallback(()=>{if(!n.current)return{top:0,right:0};const u=n.current.getBoundingClientRect();return{top:u.bottom+6,right:window.innerWidth-u.right}},[n]);l.useEffect(()=>{a(g());const u=()=>a(g());return window.addEventListener("scroll",u,!0),window.addEventListener("resize",u),()=>{window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",u)}},[g]),l.useEffect(()=>{function u(w){s.current&&!s.current.contains(w.target)&&n.current&&!n.current.contains(w.target)&&i()}function h(w){w.key==="Escape"&&i()}return document.addEventListener("mousedown",u),document.addEventListener("keydown",h),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",h)}},[n,i]);const f=e.items?.length??0,p=()=>{r({...e,items:[],logicOperator:"and"})},m=t.jsxs("div",{ref:s,className:"ogx-toolbar__panel ogx-toolbar__panel--filter",role:"dialog","aria-label":"Advanced filters",style:{top:c.top,right:c.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",f>0&&t.jsx("span",{className:"ogx-toolbar__panel-count",children:f})]}),f>0&&t.jsx("button",{className:"ogx-toolbar__clear-btn",onClick:p,title:"Clear all filters",children:"Clear all"})]}),t.jsx("div",{className:"ogx-toolbar__panel-body ogx-toolbar__panel-body--filter",children:t.jsx(go,{columns:o,filterModel:e,onFilterModelChange:r})})]});return St.createPortal(m,document.body)}const qr={rowFields:[],columnFields:[],valueFields:[]};function Jr({columns:n=[],aggregationModel:o={},onAggregationModelChange:e,pivotModel:r,onPivotModelChange:i,filterModel:s,onFilterModelChange:c,columnVisibilityModel:a={},onColumnVisibilityModelChange:g,onColumnReorder:f,forceColumnsOpen:p,onColumnsPanelClose:m,children:u,rightContent:h,style:w}){const[b,M]=l.useState(!1),[P,E]=l.useState(!1),[k,C]=l.useState(!1),[_,y]=l.useState(!1);l.useEffect(()=>{p&&(C(!0),M(!1),E(!1),y(!1))},[p]);const I=l.useRef(null),S=l.useRef(null),x=l.useRef(null),j=l.useRef(null),R=r??qr,B=R.rowFields.length>0||R.columnFields.length>0||R.valueFields.length>0,q=n.filter(W=>W.aggregable!==!1&&(W.type==="number"||W.aggregable===!0)),A=Object.keys(o).filter(W=>o[W]&&o[W]!=="none").length,U=l.useCallback((W,F)=>{if(!e)return;const X={...o};F==="none"?delete X[W]:X[W]=F,e(X)},[o,e]),Y=l.useCallback(()=>{e?.({})},[e]),G=l.useCallback(W=>{if(!c)return;const X={...s||{},quickFilterValues:W?[W]:[],items:s?.items||[]};c(X)},[s,c]),ee=s?.quickFilterValues?.[0]||"",Q=s?.items?.length||0,pe=new Set(n.filter(W=>a[W.field]!==!1).map(W=>W.field)),v=l.useCallback((W,F)=>{if(!g)return;const X={...a,[W]:F};g(X)},[a,g]),D=l.useCallback(()=>{if(!g)return;const W={...a};n.forEach(F=>{F.hideable!==!1&&(W[F.field]=!0)}),g(W)},[n,a,g]),H=l.useCallback(()=>{if(!g)return;const W={...a};n.forEach(F=>{F.hideable!==!1&&(W[F.field]=!1)}),g(W)},[n,a,g]);return t.jsxs("div",{className:"ogx-toolbar",role:"toolbar","aria-label":"Grid toolbar",style:w,children:[u&&t.jsx("div",{className:"ogx-toolbar__left",children:u}),t.jsx("div",{className:"ogx-toolbar__spacer"}),t.jsxs("div",{className:"ogx-toolbar__actions",children:[c&&t.jsx("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:t.jsx(Gr,{value:ee,onChange:G,placeholder:"Search..."})}),g&&t.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[t.jsx(Zt,{title:"Columns",children:t.jsx("button",{ref:x,className:`ogx-toolbar__icon-btn${k?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Manage columns",onClick:()=>{C(!k),M(!1),E(!1),y(!1)},children:t.jsx(Ur,{})})}),k&&t.jsx(Yr,{anchorRef:x,columns:n,visibleColumns:pe,onVisibilityChange:v,onShowAll:D,onHideAll:H,onColumnReorder:f,onClose:()=>{C(!1),m?.()}})]}),c&&t.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[t.jsx(Zt,{title:"Filters",children:t.jsxs("button",{ref:j,className:`ogx-toolbar__icon-btn${_?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Advanced filters",onClick:()=>{y(!_),M(!1),E(!1),C(!1)},children:[t.jsx(po,{}),Q>0&&t.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Filters active"})]})}),_&&t.jsx(Xr,{anchorRef:j,columns:n,filterModel:s||{items:[]},onFilterModelChange:c,onClose:()=>y(!1)})]}),i&&t.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[t.jsx(Zt,{title:"Pivot",children:t.jsxs("button",{ref:S,id:"ogx-pivot-btn",className:`ogx-toolbar__icon-btn${P?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure pivot","aria-expanded":P,"aria-controls":"ogx-pivot-panel",onClick:()=>{E(!P),M(!1),C(!1),y(!1)},children:[t.jsx(fo,{}),B&&t.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Pivot active"})]})}),P&&t.jsx($r,{anchorRef:S,columns:n,model:R,onChange:W=>{i?.(W)},onClose:()=>E(!1)})]}),t.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[t.jsx(Zt,{title:"Summaries",children:t.jsxs("button",{ref:I,id:"ogx-aggregation-btn",className:`ogx-toolbar__icon-btn${b?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure summaries","aria-expanded":b,"aria-controls":"ogx-aggregation-panel",onClick:()=>{M(!b),E(!1),C(!1),y(!1)},children:[t.jsx(ho,{}),A>0&&t.jsx("span",{className:"ogx-toolbar__dot","aria-label":`${A} active summaries`})]})}),b&&t.jsx(Kr,{anchorRef:I,aggregationModel:o,aggregableColumns:q,onFunctionChange:U,onClearAll:Y,onClose:()=>M(!1),activeCount:A})]}),h]})]})}function Qr(){return l.useRef(null)}const Zr=({fullWidth:n=!1,error:o=!1,startAdornment:e,endAdornment:r,className:i="",...s})=>{const c=["ogx-input-wrapper",n&&"ogx-input-wrapper--full-width",o&&"ogx-input-wrapper--error",s.disabled&&"ogx-input-wrapper--disabled",i].filter(Boolean).join(" ");return t.jsxs("div",{className:c,children:[e&&t.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--start",children:e}),t.jsx("input",{className:"ogx-input",...s}),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:i=!0,delimiter:s=",",selectedRows:c}=e,a=c&&c.length>0?n.filter(p=>c.includes(p.id)):n;if(a.length===0){console.warn("No rows to export");return}const g=o.filter(p=>!(p.field==="__check__"||p.field==="__actions__"));let f="";if(i){const p=g.map(m=>Lt(m.headerName||m.field));f+=p.join(s)+`
8
+ ${p}`;try{await Tr(m)}catch(u){console.error("[OpenGridX] Failed to copy to clipboard:",u)}},[o,e,r,i]);return l.useEffect(()=>{const c=a=>{if(!(a.ctrlKey||a.metaKey)||a.key!=="c")return;const g=document.activeElement,f=g?.tagName.toLowerCase(),p=g?.type;f==="input"&&p!=="checkbox"&&p!=="radio"||f==="textarea"||f==="select"||g?.isContentEditable||s()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[s]),{copySelectedRows:s}}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:i,onHideAll:s,onColumnReorder:c}=n,[a,g]=l.useState(""),[f,p]=l.useState(null),m=l.useRef(null),h=l.useMemo(()=>o.filter(_=>_.hideable!==!1),[o]).every(_=>e.has(_.field)),w=l.useMemo(()=>{if(!a)return o;const _=a.toLowerCase();return o.filter(y=>(y.headerName||y.field).toLowerCase().includes(_))},[o,a]),b=_=>{_.target.checked?i():s()},M=_=>y=>{m.current=_,y.dataTransfer.effectAllowed="move",y.dataTransfer.setDragImage(y.currentTarget.closest(".ogx-column-visibility-panel__item"),20,20)},P=_=>y=>{y.preventDefault(),y.dataTransfer.dropEffect="move",_!==m.current&&p(_)},E=()=>{p(null)},k=_=>y=>{y.preventDefault();const I=m.current;p(null),m.current=null,I&&I!==_&&c&&c(I,_)},C=()=>{p(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:a,onChange:_=>g(_.target.value)})]})}),t.jsx("div",{className:"ogx-column-visibility-panel__list",children:w.map(_=>{const y=e.has(_.field),I=_.hideable!==!1,S=f===_.field,x=!!c&&!a;return t.jsxs("div",{className:["ogx-column-visibility-panel__item",!I&&"ogx-column-visibility-panel__item--disabled",S&&"ogx-column-visibility-panel__item--drag-over"].filter(Boolean).join(" "),draggable:x,onDragOver:x?P(_.field):void 0,onDragLeave:x?E:void 0,onDrop:x?k(_.field):void 0,onDragEnd:x?C:void 0,children:[x&&t.jsx("span",{className:"ogx-column-visibility-panel__drag-handle-wrapper",draggable:!0,onDragStart:M(_.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:I?"pointer":"not-allowed"},children:[t.jsx(qt,{checked:y,onChange:j=>r(_.field,j.target.checked),disabled:!I}),t.jsx("span",{className:"ogx-column-visibility-panel__label",children:_.headerName||_.field})]})]},_.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:h,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:i,children:"Reset"})]})]})}function Wr(n){const{rows:o,columns:e,getRowId:r,rowHeight:i=52,headerHeight:s=56,autoHeight:c=!1,checkboxSelection:a=!1,rowSelectionModel:g,onRowSelectionModelChange:f,onRowClick:p,onCellClick:m,filterModel:u,onFilterModelChange:h,sortModel:w,onSortModelChange:b,pagination:M=!1,paginationModel:P={page:0,pageSize:100},onPaginationModelChange:E,pageSizeOptions:k=[10,25,50,100],pinnedColumns:C,onPinnedColumnsChange:_,pinnedRows:y,getDetailPanelContent:I,getDetailPanelHeight:S,detailPanelExpandedRowIds:x,onDetailPanelExpandedRowIdsChange:j,pinCheckboxColumn:R=!0,pinExpandColumn:B=!0,disableColumnReorder:Y=!1,columnOrder:A,onColumnOrderChange:U,height:X,rowReordering:G=!1,onRowOrderChange:ee,loading:Q=!1,treeData:pe=!1,getTreeDataPath:v,defaultGroupingExpansionDepth:D,rowGroupingModel:H,aggregationModel:W,onAggregationModelChange:F,getAggregationPosition:q,isCellEditable:K,processRowUpdate:L,onProcessRowUpdateError:ae,dataSource:oe,sortingMode:me="client",filterMode:Ze="client",paginationMode:z="client",rowCount:Ee,slots:Ne,slotProps:gt,pivotMode:De=!1,pivotModel:et,onPivotModelChange:tt,className:en="",style:Rt,onRowsScrollEnd:jt,ariaLabel:Ot,initialState:vt,onStateChange:ze,columnVisibilityModel:mo,onColumnVisibilityModelChange:bo,listView:cn=!1,listViewColumn:wo,columnGroupingModel:Et,noRowsLabel:Tn="No Data",apiRef:Ln}=n,Ci=l.useMemo(()=>({items:[]}),[]),Ve=u||Ci,[yi,ki]=l.useState(()=>vt?.sorting?.sortModel??[]),Rn=w!==void 0,nt=Rn?w:yi,Si=l.useMemo(()=>[],[]),On=H||Si,Wn=W!==void 0,vo=l.useMemo(()=>Ne?.toolbar,[Ne?.toolbar]),[ji,Ei]=l.useState(()=>W??{}),ot=Wn?W:ji,Ni=l.useCallback(d=>{Wn||Ei(d),F?.(d)},[Wn,F]),[Ii,Mi]=l.useState(()=>vt?.columns?.columnVisibilityModel??{}),Fn=mo!==void 0,Xe=Fn?mo:Ii,tn=l.useCallback(d=>{Fn||Mi(d),bo?.(d)},[Fn,bo]),[Pi,Ti]=l.useState(()=>vt?.columns?.pinnedColumns??{}),An=C!==void 0,rt=An?C:Pi,zn=l.useCallback(d=>{An||Ti(d),_?.(d)},[An,_]),Li=l.useMemo(()=>({rowFields:[],columnFields:[],valueFields:[]}),[]),[Ri,Oi]=l.useState(et??Li),_o=et??Ri,Wi=l.useCallback(d=>{Oi(d),tt?.(d)},[tt]),un=ao(o,e,_o,De),Bn=De&&un.isValid?un.pivotRows:o,it=De&&un.isValid?un.pivotColumns:e,[Fi,Co]=l.useState(null);l.useEffect(()=>{Co(null)},[ot]);const[Ai,zi]=l.useState(()=>vt?.pagination?.paginationModel??P),$n=n.paginationModel!==void 0,fe=$n?P:Ai,gn=l.useCallback(d=>{$n||zi(d),E?.(d)},[$n,E]),[Bi,yo]=l.useState([]),nn=g!==void 0,ko=nn?g:Bi,Ie=l.useMemo(()=>new Set(ko),[ko]),fn=f,Nt=l.useRef(null),$i=l.useRef(null),hn=l.useRef(null),Di=l.useCallback(d=>d.id,[]),pn=r||Di,[qe,Wt]=l.useState(null),Ft=l.useCallback(d=>{yn.current?.classList.toggle("ogx--kb",d)},[]),So=l.useRef(oe);So.current=oe;const jo=l.useRef(null),Eo=l.useRef(null),Hi=l.useCallback(d=>{if(So.current&&pe&&d.serverChildrenCount>0&&d.children.length===0){const N=Eo.current?.getNodePath(d.id)||[d.groupingKey];jo.current?.(d.id,N)}},[pe]),lt=hr({rows:Bn,columns:it,rowHeight:i,headerHeight:s,rowCount:Ee,columnVisibilityModel:Xe,initialState:n.initialState}),{state:de,apiRef:At,setRows:Dn,setColumns:No,setScroll:Io,setDimensions:Mo,setDataSourceLoading:Gi,setDataSourceError:Vi,setRowCount:Ui}=lt;l.useEffect(()=>{Ln&&(Ln.current=At.current)},[Ln,At]);const{copySelectedRows:Po}=Lr({selectedRowIds:Ie,columns:it,getVisibleRows:()=>At.current.getVisibleRows(),getRowId:pn});l.useEffect(()=>{At.current.copySelectedRows=Po,At.current.getSelectedRows=()=>Array.from(Ie)},[Po,Ie,At]);const Ki=de.dataSource.loading,on=Q||Ki,rn=l.useMemo(()=>de.rows.allRows.map(d=>de.rows.idRowsLookup.get(d)),[de.rows]),Hn=yr({rows:rn,getRowId:pn,getTreeDataPath:v,treeData:pe,defaultGroupingExpansionDepth:D,filterModel:Ve,sortModel:nt,onRowExpansionChange:Hi});l.useEffect(()=>{Eo.current=Hn},[Hn]);const Yi=Sr({rows:rn,getRowId:pn,rowGroupingModel:On,aggregationModel:ot,defaultGroupingExpansionDepth:D,filterModel:Ve,sortModel:nt,getAggregationPosition:q}),Be=jr({rows:rn,getRowId:pn,processRowUpdate:L,onProcessRowUpdateError:ae,onRowChange:d=>{const{dispatch:N}=lt,$=Array.from(lt.state.rows.idRowsLookup.values()).map(Z=>Z.id===d.id?d:Z);N({type:"SET_ROWS",payload:$})}}),Gn=pe,zt=!!(On&&On.length>0),xn=Gn||zt,$e=Gn?Hn:zt?Yi:null,Me=M&&!zt,mn=l.useCallback(d=>{const{row:N,id:T}=d;if(xn&&N._hasChildren){$e?.toggleExpansion(T);return}p?.(d)},[xn,$e,p]),ye=l.useMemo(()=>xn?it.map((d,N)=>N===0?{...d,renderCell:T=>{const{_treeDepth:$,_hasChildren:Z,_isExpanded:re,_groupingField:ue,_groupingValue:Oe,_descendantCount:We}=T.row,xe=($||0)*24;let se=d.renderCell?d.renderCell(T):T.value;return Gn&&Z&&T.row._isGroupRow&&(se=t.jsxs("div",{className:"ogx__group-cell-content",children:[T.value,We!==void 0&&We>0?` (${We})`:""]})),zt&&Z&&ue&&(se=t.jsxs("div",{className:"ogx__group-cell-content",children:[d.field===ue?"":`${ue}: `,String(Oe),We!==void 0?` (${We})`:""]})),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(),$e?.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(),$e?.toggleExpansion(T.row.id)}})}):null}),t.jsx("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:se})]})}}:{...d,renderCell:T=>{const{_hasChildren:$,_groupingField:Z}=T.row;return zt&&$?d.field===Z?null:T.value!==void 0&&T.value!==null?d.renderCell?d.renderCell(T):T.value:null:d.renderCell?d.renderCell(T):T.value}}):it,[it,xn,zt,$e]),Vn=Nr({dataSource:oe,sortModel:nt,filterModel:Ve,paginationModel:fe,paginationMode:z,sortingMode:me,filterMode:Ze,aggregationModel:ot,setRows:Dn,setRowCount:Ui,setDataSourceLoading:Gi,setDataSourceError:Vi,onAggregationResults:Co});l.useEffect(()=>{Vn.fetchChildren&&(jo.current=Vn.fetchChildren)},[Vn.fetchChildren]);const[Ue,Xi]=l.useState(()=>vt?.columns?.columnWidths??{}),[qi,bn]=l.useState(()=>vt?.columns?.columnOrder??it.map(d=>d.field)),_t=A||qi;l.useEffect(()=>{oe||Dn(Bn)},[Bn,Dn,oe]),l.useEffect(()=>{No(it)},[it,No]),l.useEffect(()=>{De&&bn(it.map(d=>d.field))},[De,it]);const Bt=l.useMemo(()=>{if(Y)return ye;const d=new Map(_t.map((N,T)=>[N,T]));return[...ye].sort((N,T)=>{const $=d.get(N.field)??ye.indexOf(N),Z=d.get(T.field)??ye.indexOf(T);return $-Z})},[ye,_t,Y]),To=l.useMemo(()=>Bt.filter(d=>Xe[d.field]!==!1),[Bt,Xe]),$t=pr({columns:Bt,onColumnOrderChange:l.useCallback(d=>{const{oldIndex:N,targetIndex:T}=d,$=[..._t],[Z]=$.splice(N,1);$.splice(T,0,Z),A||bn($),U?.(d)},[_t,A,U]),disableColumnReorder:Y}),[Ji,Qi]=l.useState(new Set),Ct=x??Ji,Je=!!I,ln=l.useCallback(d=>{const N=new Set(Ct);N.has(d)?N.delete(d):N.add(d),x===void 0&&Qi(N),j?.(N)},[Ct,x,j]),we=l.useMemo(()=>{const d=[];return G&&d.push({field:"__reorder_col__"}),Je&&d.push({field:"__expand_col__"}),a&&d.push({field:"__checkbox_col__"}),[...d,...Bt]},[Bt,a,Je,G]),Zi=l.useCallback((d,N)=>{Xi(T=>({...T,[d]:N}))},[]),Un=l.useRef(ze);Un.current=ze,l.useEffect(()=>{if(!Un.current)return;const d={sorting:{sortModel:nt},filter:{filterModel:Ve},pagination:{paginationModel:fe},columns:{columnWidths:Ue,columnOrder:_t,columnVisibilityModel:Xe,pinnedColumns:rt}};Un.current(d)},[nt,Ve,fe,Ue,_t,Xe,rt]);const wn=l.useMemo(()=>rn,[rn]),He=l.useMemo(()=>$e?$e.getVisibleRows()||[]:Ze==="server"&&oe?wn:vr(wn,Ve),[wn,Ve,$e,Ze,oe]),{top:Ke,center:Dt,bottom:st}=l.useMemo(()=>$e?{top:[],center:He,bottom:[]}:Do(He,y),[He,y,$e]),Pe=l.useMemo(()=>$e||me==="server"&&oe?Dt:Cr(Dt,nt),[Dt,nt,$e,me,oe]),ft=l.useMemo(()=>{if(!Me||z==="server"&&oe)return Pe;const d=fe.page*fe.pageSize,N=d+fe.pageSize;return Pe.slice(d,N)},[Pe,Me,fe.page,fe.pageSize,z,oe]);l.useEffect(()=>{lt.apiRef.current.getVisibleRows=()=>Pe,lt.apiRef.current.getVisibleColumns=()=>ye},[Pe,ye,lt.apiRef]);const Ht=xr({rows:Me?ft:Pe,getRowId:d=>d.id,onRowOrderChange:ee,rowReordering:G}),ke=l.useMemo(()=>{if($e)return Dt;const d=Me?ft:Pe,N=[...Ke,...d,...st];if(z==="infinite"&&de.dataSource.loading&&N.length>0){const T=Math.min(fe.pageSize,20),$=Array.from({length:T},(Z,re)=>({id:`__skeleton_${re}__`,_isSkeleton:!0}));return[...N,...$]}return N},[Ke,ft,Pe,st,Me,$e,Dt,z,de.dataSource.loading,fe.pageSize]),Gt=Er(ke,we,Ue),{aggregationResult:Kn}=so({rows:He,aggregationModel:ot,isServerSide:!!(oe&&(z==="server"||me==="server")),dataSource:oe,filterModel:Ve,sortModel:nt,serverAggregationResults:Fi}),vn=Object.keys(ot).length>0;l.useEffect(()=>{lt.apiRef.current.getAggregationResult=()=>vn?Kn:null,lt.apiRef.current.getAggregationModel=()=>vn?ot:null},[Kn,ot,vn,lt.apiRef]);const Yn=l.useMemo(()=>{const d=i,N=Me?ft:Pe,T=N.map((O,J)=>{let te=d;if(Ct.has(O.id)){const je=S?.({row:O,id:O.id,rowIndex:Ke.length+J})??200;te+=typeof je=="number"?je:parseInt(String(je),10)||200}return te}),$=T.reduce((O,J,te)=>(O.push((O[te-1]||0)+J),O),[]),re=(z==="infinite"&&de.dataSource.loading&&N.length>0?Math.min(fe.pageSize,20):0)*d,ue=($[$.length-1]||0)+re,Oe=Ke.length*d,We=st.length*d,le=[],xe=[],se=[],V=[];To.forEach(O=>{const J=dn(O.field,rt);J==="left"?le.push(O):J==="right"?xe.push(O):se.push(O)});const he=de.dimensions.viewportWidth||1e3,Ce=(a?48:0)+(Je?48:0)+(G?48:0),be=O=>Ue[O.field]??O.width,Te=O=>{if(O===void 0)return{type:"auto",value:0};if(typeof O=="number")return{type:"fixed",value:O};if(typeof O=="string"){if(O.toLowerCase()==="auto")return{type:"auto",value:0};if(O.endsWith("%"))return{type:"percentage",value:parseFloat(O)};const J=parseFloat(O);if(!isNaN(J))return{type:"fixed",value:J}}return{type:"fixed",value:100}},Le=le.reduce((O,J)=>{const te=Te(be(J));return O+(te.type==="fixed"?te.value:100)},0),ge=xe.reduce((O,J)=>{const te=Te(be(J));return O+(te.type==="fixed"?te.value:100)},0),ce=se.reduce((O,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 O+(mt||qn)}const je=Te(be(J));return je.type==="fixed"?O+je.value:je.type==="percentage"?O+100:O+(J.minWidth??150)},0),ht=Math.max(he-Ce-Le-ge,ce),at=[],Fe=[],Se=[];let Ae=0;se.forEach(O=>{const J=Object.prototype.hasOwnProperty.call(Ue,O.field),te=Te(be(O));if(!J&&O.flex&&O.flex>0){Se.push({col:O,flex:O.flex}),Ae+=O.flex;return}te.type==="fixed"?at.push({col:O,width:te.value}):te.type==="percentage"?Fe.push({col:O,percentage:te.value}):(Se.push({col:O,flex:1}),Ae+=1)});const Ge=at.reduce((O,{width:J})=>O+J,0);let Re=Math.max(0,ht-Ge);const dt=new Map;Fe.forEach(({col:O,percentage:J})=>{const te=J/100*Re;dt.set(O.field,te),Re-=te}),Re=Math.max(0,Re);const yt=new Map,pt=Se.map(O=>({...O,minWidth:O.col.minWidth??50,maxWidth:O.col.maxWidth??1/0,frozen:!1,computedWidth:0}));(()=>{let O=0;const J=pt.length*2;for(;O<J;){O++;const te=pt.filter(ne=>!ne.frozen);if(te.length===0)break;const je=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(je<=0){te.forEach(ne=>{ne.computedWidth=ne.minWidth,ne.frozen=!0});break}const dl=qn/je;let kn=0;const Sn=[],jn=[];if(te.forEach(ne=>{const ct=dl*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(O=>yt.set(O.col.field,O.computedWidth));const Ut=new Map;se.forEach(O=>{let J;if(yt.has(O.field))J=yt.get(O.field);else{const te=at.find(mt=>mt.col.field===O.field),je=Fe.find(mt=>mt.col.field===O.field);if(te)J=te.width;else if(je){const mt=dt.get(O.field)||0;J=Math.max(O.minWidth??50,mt||100)}else J=100}V.push(J),Ut.set(O.field,J)});const xt=se.map(O=>{const J=pt.find(te=>te.col.field===O.field);return{...O,width:Ut.get(O.field)??(typeof O.width=="number"?O.width:100),flex:J?J.flex:O.flex}}),Ye=11,It=le.map((O,J)=>{const te=Te(be(O)),je=te.type==="fixed"?te.value:100;return{...O,width:je,zIndex:Ye+J}}),Kt=11,kt=xe.map((O,J)=>{const te=Te(be(O)),je=te.type==="fixed"?te.value:100;return{...O,width:je,zIndex:Kt+(xe.length-1-J)}}),Qe=V.reduce((O,J)=>O+J,0),ve=Le+Qe+ge+Ce,al=V.reduce((O,J,te)=>(O.push((O[te-1]||0)+J),O),[]);return{rowHeights:T,cumulativeHeights:$,unpinnedRowsHeight:ue,pinnedTopHeight:Oe,pinnedBottomHeight:We,leftPinnedCols:It,rightPinnedCols:kt,unpinnedColsWithWidth:xt,unpinnedColWidths:V,unpinnedAccWidths:al,totalWidth:ve,leftWidth:Le,rightWidth:ge,unpinnedTotalWidth:Qe,systemColumnsWidth:Ce,pinnedTopRowsLength:Ke.length,pinnedBottomRowsLength:st.length,unpinnedRowsLength:N.length}},[i,Me,ft,Pe,Ct,S,Ke.length,st.length,Ct,S,Ke.length,st.length,To,rt,Ue,de.dimensions.viewportWidth,a,Je,G,R,B,c,z,de.dataSource.loading,fe.pageSize]),_e=l.useMemo(()=>{const{unpinnedAccWidths:d,unpinnedColsWithWidth:N,leftPinnedCols:T,rightPinnedCols:$,totalWidth:Z,leftWidth:re,rightWidth:ue,unpinnedTotalWidth:Oe,systemColumnsWidth:We,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,ge=c?xe+V+se+50:de.dimensions.viewportHeight||600,ce=6,ht=Math.max(0,be-re),at=be+Le-re;let Fe=0,Se=N.length-1,Ae=0,Ge=d.length-1;for(;Ae<=Ge;){const ve=Ae+Ge>>>1;d[ve]<ht?Ae=ve+1:Ge=ve-1}Fe=Math.max(0,Ae-ce);for(let ve=Fe;ve<d.length;ve++){if((ve===0?0:d[ve-1])>at){Se=Math.min(N.length-1,ve+ce);break}Se=Math.min(N.length-1,ve+ce)}const Re=Fe>0?d[Fe-1]:0,dt=Oe-d[Se],yt=[...T,...Re>0?[{field:"__spacer_left__",width:Re,isSpacer:!0}]:[],...N.slice(Fe,Se+1),...dt>0?[{field:"__spacer_right__",width:dt,isSpacer:!0}]:[],...$],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+ge){It=Math.min(Ce-1,ve+xt);break}return{renderContext:{firstRowIndex:Ye,lastRowIndex:It,firstColumnIndex:Fe,lastColumnIndex:Se},offsetTop:Kt,offsetLeft:0,totalHeight:Ut,pinnedTopHeight:xe,pinnedBottomHeight:se,totalWidth:Z,rowHeights:he,cumulativeHeights:le,virtualColumns:yt,columnMetrics:{leftPinnedWidth:re,rightPinnedWidth:ue,unpinnedAccWidths:d,unpinnedCols:N,totalSpecialsWidth:We,pinnedSpecialsWidth:(G?48:0)+(Je&&B?48:0)+(a&&R?48:0)}}},[Yn,de.virtualization.scrollTop,de.virtualization.scrollLeft,de.dimensions.viewportHeight,de.dimensions.viewportWidth,c]),el=l.useCallback(d=>{const N=d.currentTarget;if(Io(N.scrollTop,N.scrollLeft),jt){const{scrollTop:T,scrollHeight:$,clientHeight:Z}=N;$-T-Z<100&&jt({visibleTop:T,visibleBottom:T+Z,viewportHeight:Z})}},[Io,jt]);l.useEffect(()=>{if(!Nt.current)return;const d=new ResizeObserver(N=>{for(const T of N){const{width:$,height:Z}=T.contentRect;Mo($,Z)}});return d.observe(Nt.current),()=>{d.disconnect()}},[Mo]);const Vt=l.useCallback((d,N)=>{const T=new Set(Ie);N?T.add(d):T.delete(d);const $=Array.from(T);nn||yo($),fn?.($)},[Ie,nn,fn]),tl=l.useCallback(d=>{let N=[];d&&(N=wn.map(T=>T.id)),nn||yo(N),fn?.(N)},[o,nn,fn]),Lo=l.useCallback((d,N)=>{const T=N?[{field:d,sort:N}]:[];Rn||ki(T),b?.(T)},[Rn,b]),Xn=l.useCallback(d=>{Ft(!1),Wt({id:d.row.id,field:d.field}),hn.current?.focus({preventScroll:!0}),m?.(d)},[m,Ft]),Ro=l.useRef(Be.editingCell);l.useEffect(()=>{const d=!!Ro.current,N=!!Be.editingCell;d&&!N&&hn.current?.focus({preventScroll:!0}),Ro.current=Be.editingCell},[Be.editingCell]);const Oo=l.useMemo(()=>{const{firstRowIndex:d,lastRowIndex:N}=_e.renderContext,T=Ke.length,$=Ke.map((se,V)=>({row:se,rowIndex:V})),Z=st.map((se,V)=>({row:se,rowIndex:T+(Me?ft.length:Pe.length)+V})),re=Math.max(0,d-T),ue=Math.min(Me?ft.length:Pe.length,N-T+1),Oe=(Me?ft:Pe).slice(re,ue).map((se,V)=>({row:se,rowIndex:T+re+V})),We=[...$,...Oe,...Z],le=new Set;return We.filter(se=>le.has(se.row.id)?!1:(le.add(se.row.id),!0))},[_e.renderContext,Ke,st,ft,Pe,Me,z,de.dataSource.loading,fe.pageSize,i]),nl=o.length>0&&Ie.size===o.length,ol=Ie.size>0&&Ie.size<o.length,rl=l.useCallback(d=>{d.target===d.currentTarget&&Wt(N=>{if(N)return N;if(a)return{id:"HEADER",field:"__checkbox_col__"};const T=ke[0],$=we[0];return T&&$?{id:T.id,field:$.field}:null})},[ke,we]),il=l.useCallback(d=>{d.currentTarget.contains(d.relatedTarget)||Wt(null)},[]),ll=l.useCallback(d=>{if(Ft(!0),!qe)return;const{id:N,field:T}=qe,$=!!Be.editingCell;if(d.key==="Enter"){if(d.preventDefault(),$)Be.stopCellEdit();else if(we.find(he=>he.field===T)?.editable){const he=ke.find(Ce=>Ce.id===N);he&&Be.startCellEdit({id:N,field:T,value:he[T]})}return}if((d.key===" "||d.key==="Spacebar")&&!$){if(T==="__checkbox_col__"){d.preventDefault(),Vt(N,!Ie.has(N));return}if(T==="__expand_col__"){d.preventDefault(),ln(N);return}}if(N==="HEADER"&&(d.key==="Enter"||d.key===" ")){d.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(d.key==="Escape"){$&&(d.preventDefault(),Be.stopCellEdit({cancel:!0}));return}if($&&d.key!=="Tab")return;const Z=N==="HEADER",re=Z?-1:ke.findIndex(V=>V.id===N),ue=we.findIndex(V=>V.field===T);if(!Z&&re===-1||ue===-1)return;const Oe=(V,he,Ce,be,Te,Le=!1)=>{let ge=V+Ce,ce=he+be;return Te&&be!==0&&(be>0&&ce>=we.length?(ce=0,ge++):be<0&&ce<0&&(ce=we.length-1,ge--)),!Te&&(ce<0||ce>=we.length)||ge<(Le?-1:0)||ge>=ke.length?null:{r:ge,c:ce}},We=(V,he,Ce,be,Te,Le=!1)=>{let ge=V,ce=he,ht=0;const at=ke.length*we.length+we.length;for(;ht<at;){if(ht++,ge+=Ce,ce+=be,be!==0)be>0?ce>=we.length&&(ce=0,ge++):ce<0&&(ce=we.length-1,ge--);else if(ce<0||ce>=we.length)return null;if(ge<-1||ge>=ke.length)return null;if(ge===-1){if(!Le)continue;const Re=we[ce],dt=Re.sortable!==!1;if(["__checkbox_col__"].includes(Re.field)||dt)return{r:ge,c:ce};continue}const Fe=ke[ge],Se=we[ce],Ae=["__checkbox_col__","__expand_col__","__reorder_col__"].includes(Se.field);let Ge=Se.editable||Ae;if(K&&!Ae)try{Ge=K({row:Fe,field:Se.field,value:Fe[Se.field],colDef:Se,rowIndex:ge,colIndex:ce})}catch(Re){console.error("Error in isCellEditable:",Re)}if(Ge)return{r:ge,c:ce}}return null};let le=re,xe=ue,se=!1;if(d.key==="Tab"){const V=d.shiftKey?-1:1,he=We(re,ue,0,V,!0,!1);he&&(le=he.r,xe=he.c,se=!0)}else if(d.key==="ArrowRight"){const V=Oe(re,ue,0,1,!0,!0);V&&(le=V.r,xe=V.c,se=!0)}else if(d.key==="ArrowLeft"){const V=Oe(re,ue,0,-1,!0,!0);V&&(le=V.r,xe=V.c,se=!0)}else if(d.key==="ArrowDown"){const V=Oe(re,ue,1,0,!1,!0);V&&(le=V.r,xe=V.c,se=!0)}else if(d.key==="ArrowUp"){const V=Oe(re,ue,-1,0,!1,!0);V&&(le=V.r,xe=V.c,se=!0)}else if(d.key==="Home")(d.ctrlKey||d.metaKey)&&(le=-1),xe=0,se=!0;else if(d.key==="End")(d.ctrlKey||d.metaKey)&&(le=ke.length-1),xe=we.length-1,se=!0;else if(d.key==="PageUp"){const V=Me?fe.pageSize:10;le=Math.max(-1,le-V),se=!0}else if(d.key==="PageDown"){const V=Me?fe.pageSize:10;le=Math.min(ke.length-1,le+V),se=!0}if(se&&(d.preventDefault(),$&&d.key==="Tab"&&Be.stopCellEdit(),le>=-1&&le<ke.length&&xe>=0&&xe<we.length)){const V=we[xe];if(le===-1)Wt({id:"HEADER",field:V.field});else{const he=ke[le];Wt({id:he.id,field:V.field})}if(Nt.current){const{cumulativeHeights:he,pinnedTopHeight:Ce}=_e,{clientHeight:be,clientWidth:Te,scrollTop:Le,scrollLeft:ge}=Nt.current,ce=le===0?0:he[le-1],ht=he[le],at=Ce,Fe=Le+at,Se=Le+be;let Ae=Le;if(ce<Fe?Ae=Math.max(0,ce-at):ht>Se&&(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=ge+sn+Ge,kt=ge+Te-Re;let Qe=ge;Ye<Kt?Qe=Math.max(0,Ye-sn-Ge):It>kt&&(Qe=It-Te+Re),Qe!==ge&&(Nt.current.scrollLeft=Qe)}}}}},[qe,ke,we,Be,_e,Ie,Vt,ln]),sl=l.useMemo(()=>ye.some(d=>!!d.rowSpan),[ye]),[_n,Cn]=l.useState(!1),yn=l.useRef(null);return l.useEffect(()=>{if(!_n||Ne?.toolbar)return;function d(N){const T=document.getElementById("ogx-standalone-col-panel");T&&!T.contains(N.target)&&Cn(!1)}return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[_n,Ne?.toolbar]),t.jsxs("div",{ref:yn,className:`ogx ${en} ${c?"ogx--auto-height":""} ${sl?"ogx--row-spanning":""} ${cn?"ogx--list-view":""}`,style:{...Rt,height:X??Rt?.height,"--ogx-row-height":`${i}px`,"--ogx-header-height":`${s}px`},"aria-busy":on,children:[vo&&(()=>{const d={apiRef:lt.apiRef,columns:ye,aggregationModel:ot,onAggregationModelChange:Ni,...De||et||tt?{pivotModel:_o,onPivotModelChange:Wi}:{},filterModel:Ve,onFilterModelChange:h,columnVisibilityModel:Xe,onColumnVisibilityModelChange:tn,onColumnReorder:Y?void 0:(N,T)=>{const $=[..._t],Z=$.indexOf(N),re=$.indexOf(T);if(Z===-1||re===-1)return;const ue=[...$];ue.splice(Z,1),ue.splice(re,0,N),A||bn(ue);const Oe=ye.find(We=>We.field===N);Oe&&U?.({oldIndex:Z,targetIndex:re,column:Oe})},forceColumnsOpen:_n,onColumnsPanelClose:()=>Cn(!1),...gt?.toolbar};return t.jsx(vo,{...d})})(),!Ne?.toolbar&&_n&&St.createPortal(t.jsxs("div",{id:"ogx-standalone-col-panel",style:(()=>{const d=yn.current?.getBoundingClientRect();return{position:"fixed",top:d?d.top+8:16,right:d?window.innerWidth-d.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:ye,visibleColumns:new Set(ye.filter(d=>Xe[d.field]!==!1).map(d=>d.field)),onVisibilityChange:(d,N)=>{tn({...Xe,[d]:N})},onShowAll:()=>{const d={...Xe};ye.forEach(N=>{N.hideable!==!1&&(d[N.field]=!0)}),tn(d)},onHideAll:()=>{const d={...Xe};ye.forEach(N=>{N.hideable!==!1&&(d[N.field]=!1)}),tn(d)},onColumnReorder:Y?void 0:(d,N)=>{const T=[..._t],$=T.indexOf(d),Z=T.indexOf(N);if($===-1||Z===-1)return;const re=[...T];re.splice($,1),re.splice(Z,0,d),A||bn(re),U?.({oldIndex:$,targetIndex:Z,column:ye.find(ue=>ue.field===d)})}})]}),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":ke.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 ${fe.page+1} of ${Math.ceil(He.length/fe.pageSize)||1}`:"",Ie.size>0?` · ${Ie.size} selected`:""]})}),t.jsx("div",{className:"ogx-list-view__rows",children:ke.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]}):ke.map((d,N)=>t.jsx(zo,{row:d,rowIndex:N,listViewColumn:wo,isSelected:Ie.has(d.id),checkboxSelection:a,rowHeight:i,onRowClick:T=>mn({row:T,id:T.id,rowIndex:N}),onSelectionChange:Vt},d.id))}),Me&&(()=>{const d=Ne?.pagination||lo,N=z==="server"&&oe?de.pagination.rowCount||0:He.length,T={page:fe.page,pageSize:fe.pageSize,rowCount:N,pageSizeOptions:k,onPageChange:$=>gn({...fe,page:$}),onPageSizeChange:$=>gn({...fe,pageSize:$,page:0}),...gt?.pagination};return t.jsx(d,{...T})})()]}),!cn&&t.jsx("div",{ref:d=>{Nt.current=d,hn.current=d},className:"ogx__viewport",onScroll:el,role:"grid","aria-label":Ot||"Data grid","aria-rowcount":He.length+1,"aria-colcount":e.length+(a?1:0)+(Je?1:0)+(G?1:0),"aria-busy":on,tabIndex:0,onKeyDownCapture:()=>{Ft(!0)},onMouseDownCapture:()=>{Ft(!1)},onKeyDown:ll,onFocus:rl,onBlur:il,children:t.jsxs("div",{ref:$i,className:"ogx__content",style:{width:_e.totalWidth},role:"presentation",children:[t.jsx(oo,{columns:_e.virtualColumns,allColumns:ye,columnGroupingModel:Et,checkboxSelection:a,allSelected:nl,someSelected:ol,onSelectAll:tl,sortModel:nt,onSort:Lo,onColumnResize:Zi,columnWidths:Ue,pinnedColumns:rt,focusedCell:qe,onHeaderClick:d=>{Wt({id:"HEADER",field:d}),Ft(!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:R,pinExpandColumn:B,aggregationModel:ot,onHideColumn:d=>{tn({...Xe,[d]:!1})},onManageColumns:()=>Cn(!0),onPinColumn:(d,N)=>{const T=[...rt?.left??[]],$=[...rt?.right??[]],Z=T.filter(ue=>ue!==d),re=$.filter(ue=>ue!==d);zn(N==="left"?{left:[...Z,d],right:re}:N==="right"?{left:Z,right:[...re,d]}:{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((d,N)=>t.jsx(Jt,{row:d,columns:_e.virtualColumns,rowIndex:N,isSelected:Ie.has(d.id),checkboxSelection:a,onRowClick:mn,onCellClick:Xn,onSelectionChange:Vt,columnWidths:Ue,pinnedColumns:rt,pinnedRows:y,hasDetailPanel:Je,isDetailPanelExpanded:Ct.has(d.id),detailPanelContent:I?I({row:d,id:d.id,rowIndex:N}):null,detailPanelHeight:S?.({row:d,id:d.id,rowIndex:N})||200,onDetailPanelToggle:ln,pinCheckboxColumn:R,pinExpandColumn:B,focusedCellField:qe?.id===d.id?qe.field:null,colspanMap:Gt.colspanMap,rowSpanningCaches:Gt.rowSpanningState.caches,rowHeight:i},d.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*i}px)`},role:"rowgroup",children:[on&&Oo.length===0?(()=>{const d=e.length>0?e:(()=>{const N=(de.dimensions.viewportWidth||1e3)-(a?48:0)-(I?48:0)-(G?48:0),T=150,$=Math.max(1,Math.ceil(N/T));return Array.from({length:$},(Z,re)=>({field:`placeholder_${re}`,headerName:"",width:T}))})();return Array.from({length:10}).map((N,T)=>t.jsx(ur,{columns:d,rowHeight:i,checkboxSelection:a,hasDetailPanel:!!I,rowReordering:G},`skeleton-${T}`))})():Oo.filter(({row:d})=>!En(d.id,y)).filter((d,N,T)=>N===T.findIndex($=>$.row.id===d.row.id)).map(({row:d,rowIndex:N})=>t.jsx(Jt,{row:d,columns:_e.virtualColumns,rowIndex:N,isSelected:Ie.has(d.id),checkboxSelection:a,onRowClick:mn,onCellClick:Xn,onSelectionChange:Vt,columnWidths:Ue,pinnedColumns:rt,pinnedRows:y,hasDetailPanel:Je,isDetailPanelExpanded:Ct.has(d.id),detailPanelContent:I?I({row:d,id:d.id,rowIndex:N}):null,detailPanelHeight:S?.({row:d,id:d.id,rowIndex:N})||200,onDetailPanelToggle:ln,pinCheckboxColumn:R,pinExpandColumn:B,rowReordering:G,onDragStart:Ht.onDragStart,onDragOver:Ht.onDragOver,onDragEnd:Ht.onDragEnd,onDrop:Ht.onDrop,isDragging:Ht.draggedRowId===d.id,isDragOver:Ht.dragOverRowId===d.id,editingCell:Be.editingCell,onEditStart:Be.startCellEdit,onEditStop:Be.stopCellEdit,onEditCellValueChange:Be.setEditCellValue,focusedCellField:qe!=null&&qe.id===d.id?qe.field:null,colspanMap:Gt.colspanMap,rowSpanningCaches:Gt.rowSpanningState.caches,rowHeight:i},`${d.id}-${_e.totalWidth}`)),z==="infinite"&&de.dataSource.loading&&Pe.length>0&&(()=>{const d=Math.min(fe.pageSize,20),N=Yn.unpinnedRowsLength;return t.jsx("div",{className:"ogx__skeleton-group",children:Array.from({length:d}).map((T,$)=>t.jsx(Jt,{row:{id:`__skeleton_${$}__`,_isSkeleton:!0},columns:_e.virtualColumns,rowIndex:N+$,rowHeight:i},`__skeleton_${$}__`))})})()]})}),st.length>0&&t.jsx("div",{className:"ogx__pinned-rows ogx__pinned-rows--bottom",role:"rowgroup",children:st.map((d,N)=>t.jsx(Jt,{row:d,columns:_e.virtualColumns,rowIndex:N,isSelected:Ie.has(d.id),checkboxSelection:a,onRowClick:mn,onCellClick:Xn,onSelectionChange:Vt,columnWidths:Ue,pinnedColumns:rt,pinnedRows:y,hasDetailPanel:Je,isDetailPanelExpanded:Ct.has(d.id),detailPanelContent:I?I({row:d,id:d.id,rowIndex:N}):null,detailPanelHeight:S?.({row:d,id:d.id,rowIndex:N})||200,onDetailPanelToggle:ln,pinCheckboxColumn:R,pinExpandColumn:B,focusedCellField:qe?.id===d.id?qe.field:null,colspanMap:Gt.colspanMap,rowSpanningCaches:Gt.rowSpanningState.caches,rowHeight:i},d.id))}),vn&&t.jsxs("div",{className:"ogx__aggregation-footer",role:"row","aria-label":"Aggregation totals","aria-live":"polite",style:{minHeight:`${i}px`},children:[a&&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(d=>{const N=ot[d.field],T=Kn[d.field],$=Ue[d.field]??(typeof d.width=="number"?d.width:120);return t.jsx("div",{className:"ogx__aggregation-cell",role:"gridcell",style:{width:$,minWidth:$,maxWidth:$,textAlign:d.align||"left"},children:N?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"ogx__aggregation-label",children:N}),t.jsx("span",{className:"ogx__aggregation-value",children:bt(T,N)})]}):null},d.field)})]})]})}),!cn&&Me&&(()=>{const d=Ne?.pagination||lo,N={page:fe.page,pageSize:fe.pageSize,rowCount:de.pagination.rowCount,pageSizeOptions:k,onPageChange:T=>gn({...fe,page:T}),onPageSizeChange:T=>gn({...fe,pageSize:T,page:0}),...gt?.pagination};return t.jsx(d,{...N})})(),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 Fr({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((i,s)=>t.jsx("div",{className:"ogx__skeleton-cell",children:t.jsx("div",{className:"ogx__skeleton-content"})},s))},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),i=!!o,s=o?.operator??r[0],c=u=>{const h=uo.has(u),w={id:o?.id??`${n.field}-${Date.now()}`,field:n.field,operator:u,value:h?void 0:o?.value??(n.type==="boolean"?"true":"")};e(w)},a=u=>{e({id:o?.id??`${n.field}-${Date.now()}`,field:n.field,operator:s,value:u})},g=()=>{e(null)},f=uo.has(String(s)),p=n.type==="boolean",m=!f;return t.jsxs("div",{className:`ogx-filter__row${i?" 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${i?" ogx-filter__op-select--active":""}`,value:String(s),onChange:u=>c(u.target.value),"aria-label":`Filter operator for ${n.headerName||n.field}`,children:r.map(u=>t.jsx("option",{value:u,children:u},u))}),m&&p&&t.jsxs("select",{id:`ogx-filter-val-${n.field}`,name:`filter-val-${n.field}`,className:`ogx-filter__value-input ogx-filter__value-select${i?" ogx-filter__value-input--active":""}`,value:String(o?.value??"true"),onChange:u=>a(u.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"})]}),m&&!p&&t.jsx("input",{id:`ogx-filter-val-${n.field}`,name:`filter-val-${n.field}`,className:`ogx-filter__value-input${i?" ogx-filter__value-input--active":""}`,type:n.type==="number"?"number":"text",value:o?.value??"",onChange:u=>a(u.target.value),placeholder:"Value…","aria-label":`Filter value for ${n.headerName||n.field}`}),i&&t.jsx("button",{className:"ogx-filter__row-clear",onClick:g,"aria-label":`Clear filter for ${n.headerName||n.field}`,title:"Clear",children:"×"})]})]})},go=({filterModel:n,columns:o,onFilterModelChange:e})=>{const r=n.items??[],i=n.logicOperator??"and",s=l.useCallback((g,f)=>{const p=r.filter(u=>"field"in u&&u.field!==g),m=f?[...p,f]:p;e({...n,items:m})},[r,n,e]),c=l.useCallback(g=>{e({...n,logicOperator:g})},[n,e]),a=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${i==="and"?" ogx-filter__logic-pill--active":""}`,onClick:()=>c("and"),"aria-pressed":i==="and",children:"ALL (AND)"}),t.jsx("button",{className:`ogx-filter__logic-pill${i==="or"?" ogx-filter__logic-pill--active":""}`,onClick:()=>c("or"),"aria-pressed":i==="or",children:"ANY (OR)"})]}),a.length===0?t.jsx("div",{className:"ogx-filter__empty",children:"No filterable columns."}):a.map(g=>t.jsx(zr,{col:g,item:Ar(r,g.field),onChange:f=>s(g.field,f)},g.field))]})},Br=["sum","avg","count","min","max"];function fo(){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:i}){const s=l.useRef(null),[c,a]=l.useState({top:0,right:0}),g=l.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]);l.useEffect(()=>{a(g());const x=()=>a(g());return window.addEventListener("scroll",x,!0),window.addEventListener("resize",x),()=>{window.removeEventListener("scroll",x,!0),window.removeEventListener("resize",x)}},[g]),l.useEffect(()=>{function x(R){s.current&&!s.current.contains(R.target)&&n.current&&!n.current.contains(R.target)&&i()}function j(R){R.key==="Escape"&&i()}return document.addEventListener("mousedown",x),document.addEventListener("keydown",j),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",j)}},[n,i]);const f=new Set(e.rowFields),p=new Set(e.columnFields),m=new Set(e.valueFields.map(x=>x.field)),u=x=>f.has(x)||p.has(x)||m.has(x);function h(x){f.has(x)||r({...e,rowFields:[...e.rowFields,x]})}function w(x){p.has(x)||r({...e,columnFields:[...e.columnFields,x]})}function b(x,j="sum"){m.has(x)||r({...e,valueFields:[...e.valueFields,{field:x,aggFn:j}]})}function M(x){r({...e,rowFields:e.rowFields.filter(j=>j!==x)})}function P(x){r({...e,columnFields:e.columnFields.filter(j=>j!==x)})}function E(x){r({...e,valueFields:e.valueFields.filter(j=>j.field!==x)})}function k(x,j){r({...e,valueFields:e.valueFields.map(R=>R.field===x?{...R,aggFn:j}:R)})}function C(){r({rowFields:[],columnFields:[],valueFields:[]})}const _=new Set(o.filter(x=>x.type==="number"||x.aggregable).map(x=>x.field)),y=e.rowFields.length+e.columnFields.length+e.valueFields.length,I=x=>o.find(j=>j.field===x)?.headerName??x,S=t.jsxs("div",{ref:s,className:"ogx-pivot-panel",role:"dialog","aria-label":"Pivot configuration",style:{top:c.top,right:c.right},children:[t.jsxs("div",{className:"ogx-pivot-panel__header",children:[t.jsxs("span",{className:"ogx-pivot-panel__title",children:[t.jsx(fo,{}),"Pivot Mode"]}),y>0&&t.jsx("button",{className:"ogx-pivot-panel__reset-btn",onClick:C,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:[I(x),t.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>M(x),title:`Remove ${I(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:[I(x),t.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>P(x),title:`Remove ${I(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:[I(x.field),t.jsx("select",{className:"ogx-pivot-chip__fn-select",value:x.aggFn,onChange:j=>k(x.field,j.target.value),title:"Aggregation function",children:Br.map(j=>t.jsx("option",{value:j,children:j.toUpperCase()},j))}),t.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>E(x.field),title:`Remove ${I(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 j=_.has(x.field);return u(x.field)?null:t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3},children:[t.jsx("span",{className:`ogx-pivot-field-btn${j?" 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:()=>h(x.field),title:"Add to Row Fields",children:"Row"}),t.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--col",onClick:()=>w(x.field),title:"Add to Column Fields",children:"Col"}),j&&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=>u(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[i,s]=l.useState(!1),[c,a]=l.useState(n),g=l.useRef(null),f=l.useRef(null);l.useEffect(()=>{a(n),n&&!i&&s(!0)},[n,i]),l.useEffect(()=>{const h=setTimeout(()=>{c!==n&&o(c)},r);return()=>clearTimeout(h)},[c,o,r,n]);const p=()=>{s(!0)},m=h=>{h.stopPropagation(),a(""),g.current?.focus(),o("")},u=()=>{c||s(!1)};return l.useEffect(()=>{const h=w=>{f.current&&!f.current.contains(w.target)&&(c||s(!1))};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[c]),t.jsxs("div",{ref:f,className:`ogx-global-search${i?" ogx-global-search--expanded":""}`,onClick:()=>{i||(s(!0),setTimeout(()=>g.current?.focus(),50))},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:c,onChange:h=>a(h.target.value),onFocus:p,onBlur:u,placeholder:e,"aria-label":"Global Search",autoComplete:"off"}),c&&t.jsx("button",{className:"ogx-global-search__clear",onClick:m,"aria-label":"Clear search",children:t.jsx(Hr,{})})]})}function Zt({title:n,children:o,placement:e="top",enterDelay:r=200,leaveDelay:i=0}){const[s,c]=l.useState(!1),[a,g]=l.useState({top:0,left:0}),f=l.useRef(null),p=l.useRef(null),m=l.useCallback(()=>{if(!p.current)return;const b=p.current.getBoundingClientRect();let M=0,P=0;const E=window.pageXOffset||document.documentElement.scrollLeft,k=window.pageYOffset||document.documentElement.scrollTop;e==="top"?(M=b.top+k-8,P=b.left+E+b.width/2):e==="bottom"&&(M=b.bottom+k+8,P=b.left+E+b.width/2),g({top:M,left:P})},[e]);l.useLayoutEffect(()=>(s&&(m(),window.addEventListener("scroll",m,!0),window.addEventListener("resize",m)),()=>{window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m)}),[s,m]);const u=()=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{c(!0)},r)},h=()=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{c(!1)},i)},w=l.useCallback(b=>{p.current=b?b.firstElementChild??b:null},[]);return t.jsxs(t.Fragment,{children:[t.jsx("span",{ref:w,style:{display:"inline-block",lineHeight:0},onMouseEnter:u,onMouseLeave:h,children:o}),s&&n&&St.createPortal(t.jsx("div",{className:`ogx-tooltip ogx-tooltip--${e}`,style:{top:a.top,left:a.left,position:"absolute",zIndex:99999},children:n}),document.body)]})}const Vr=["none","sum","avg","count","min","max"];function 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:i,onClose:s,activeCount:c}){const a=l.useRef(null),[g,f]=l.useState({top:0,right:0}),p=l.useCallback(()=>{if(!n.current)return{top:0,right:0};const u=n.current.getBoundingClientRect();return{top:u.bottom+6,right:window.innerWidth-u.right}},[n]);l.useEffect(()=>{f(p());const u=()=>f(p());return window.addEventListener("scroll",u,!0),window.addEventListener("resize",u),()=>{window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",u)}},[p]),l.useEffect(()=>{function u(h){a.current&&!a.current.contains(h.target)&&n.current&&!n.current.contains(h.target)&&s()}return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[n,s]),l.useEffect(()=>{function u(h){h.key==="Escape"&&s()}return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[s]);const m=t.jsxs("div",{ref:a,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"]}),c>0&&t.jsx("button",{className:"ogx-toolbar__clear-btn",onClick:i,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(u=>{const h=o[u.field]||"none";return t.jsxs("div",{className:"ogx-toolbar__agg-row",children:[t.jsx("span",{className:"ogx-toolbar__agg-label",title:u.field,children:u.headerName||u.field}),t.jsx("div",{className:"ogx-toolbar__agg-pills",children:Vr.map(w=>t.jsx("button",{className:`ogx-toolbar__pill${h===w?" ogx-toolbar__pill--active":""}`,onClick:()=>r(u.field,w),"aria-pressed":h===w,children:w},w))})]},u.field)})})]});return St.createPortal(m,n.current?.closest(".ogx-theme-provider")||document.body)}function Yr({anchorRef:n,columns:o,visibleColumns:e,onVisibilityChange:r,onShowAll:i,onHideAll:s,onColumnReorder:c,onClose:a}){const g=l.useRef(null),[f,p]=l.useState({top:0,right:0}),m=l.useCallback(()=>{if(!n.current)return{top:0,right:0};const h=n.current.getBoundingClientRect();return{top:h.bottom+6,right:window.innerWidth-h.right}},[n]);l.useEffect(()=>{p(m());const h=()=>p(m());return window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}},[m]),l.useEffect(()=>{function h(w){g.current&&!g.current.contains(w.target)&&n.current&&!n.current.contains(w.target)&&a()}return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[n,a]);const u=t.jsx("div",{ref:g,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Column visibility",style:{top:f.top,right:f.right,width:280,padding:0},children:t.jsx(co,{columns:o,visibleColumns:e,onVisibilityChange:r,onShowAll:i,onHideAll:s,onColumnReorder:c})});return St.createPortal(u,n.current?.closest(".ogx-theme-provider")||document.body)}function Xr({anchorRef:n,columns:o,filterModel:e,onFilterModelChange:r,onClose:i}){const s=l.useRef(null),[c,a]=l.useState({top:0,right:0}),g=l.useCallback(()=>{if(!n.current)return{top:0,right:0};const u=n.current.getBoundingClientRect();return{top:u.bottom+6,right:window.innerWidth-u.right}},[n]);l.useEffect(()=>{a(g());const u=()=>a(g());return window.addEventListener("scroll",u,!0),window.addEventListener("resize",u),()=>{window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",u)}},[g]),l.useEffect(()=>{function u(w){s.current&&!s.current.contains(w.target)&&n.current&&!n.current.contains(w.target)&&i()}function h(w){w.key==="Escape"&&i()}return document.addEventListener("mousedown",u),document.addEventListener("keydown",h),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",h)}},[n,i]);const f=e.items?.length??0,p=()=>{r({...e,items:[],logicOperator:"and"})},m=t.jsxs("div",{ref:s,className:"ogx-toolbar__panel ogx-toolbar__panel--filter",role:"dialog","aria-label":"Advanced filters",style:{top:c.top,right:c.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",f>0&&t.jsx("span",{className:"ogx-toolbar__panel-count",children:f})]}),f>0&&t.jsx("button",{className:"ogx-toolbar__clear-btn",onClick:p,title:"Clear all filters",children:"Clear all"})]}),t.jsx("div",{className:"ogx-toolbar__panel-body ogx-toolbar__panel-body--filter",children:t.jsx(go,{columns:o,filterModel:e,onFilterModelChange:r})})]});return St.createPortal(m,n.current?.closest(".ogx-theme-provider")||document.body)}const qr={rowFields:[],columnFields:[],valueFields:[]};function Jr({columns:n=[],aggregationModel:o={},onAggregationModelChange:e,pivotModel:r,onPivotModelChange:i,filterModel:s,onFilterModelChange:c,columnVisibilityModel:a={},onColumnVisibilityModelChange:g,onColumnReorder:f,forceColumnsOpen:p,onColumnsPanelClose:m,children:u,rightContent:h,style:w}){const[b,M]=l.useState(!1),[P,E]=l.useState(!1),[k,C]=l.useState(!1),[_,y]=l.useState(!1);l.useEffect(()=>{p&&(C(!0),M(!1),E(!1),y(!1))},[p]);const I=l.useRef(null),S=l.useRef(null),x=l.useRef(null),j=l.useRef(null),R=r??qr,B=R.rowFields.length>0||R.columnFields.length>0||R.valueFields.length>0,Y=n.filter(W=>W.aggregable!==!1&&(W.type==="number"||W.aggregable===!0)),A=Object.keys(o).filter(W=>o[W]&&o[W]!=="none").length,U=l.useCallback((W,F)=>{if(!e)return;const q={...o};F==="none"?delete q[W]:q[W]=F,e(q)},[o,e]),X=l.useCallback(()=>{e?.({})},[e]),G=l.useCallback(W=>{if(!c)return;const q={...s||{},quickFilterValues:W?[W]:[],items:s?.items||[]};c(q)},[s,c]),ee=s?.quickFilterValues?.[0]||"",Q=s?.items?.length||0,pe=new Set(n.filter(W=>a[W.field]!==!1).map(W=>W.field)),v=l.useCallback((W,F)=>{if(!g)return;const q={...a,[W]:F};g(q)},[a,g]),D=l.useCallback(()=>{if(!g)return;const W={...a};n.forEach(F=>{F.hideable!==!1&&(W[F.field]=!0)}),g(W)},[n,a,g]),H=l.useCallback(()=>{if(!g)return;const W={...a};n.forEach(F=>{F.hideable!==!1&&(W[F.field]=!1)}),g(W)},[n,a,g]);return t.jsxs("div",{className:"ogx-toolbar",role:"toolbar","aria-label":"Grid toolbar",style:w,children:[u&&t.jsx("div",{className:"ogx-toolbar__left",children:u}),t.jsx("div",{className:"ogx-toolbar__spacer"}),t.jsxs("div",{className:"ogx-toolbar__actions",children:[c&&t.jsx("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:t.jsx(Gr,{value:ee,onChange:G,placeholder:"Search..."})}),g&&t.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[t.jsx(Zt,{title:"Columns",children:t.jsx("button",{ref:x,className:`ogx-toolbar__icon-btn${k?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Manage columns",onClick:()=>{C(!k),M(!1),E(!1),y(!1)},children:t.jsx(Ur,{})})}),k&&t.jsx(Yr,{anchorRef:x,columns:n,visibleColumns:pe,onVisibilityChange:v,onShowAll:D,onHideAll:H,onColumnReorder:f,onClose:()=>{C(!1),m?.()}})]}),c&&t.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[t.jsx(Zt,{title:"Filters",children:t.jsxs("button",{ref:j,className:`ogx-toolbar__icon-btn${_?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Advanced filters",onClick:()=>{y(!_),M(!1),E(!1),C(!1)},children:[t.jsx(po,{}),Q>0&&t.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Filters active"})]})}),_&&t.jsx(Xr,{anchorRef:j,columns:n,filterModel:s||{items:[]},onFilterModelChange:c,onClose:()=>y(!1)})]}),i&&t.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[t.jsx(Zt,{title:"Pivot",children:t.jsxs("button",{ref:S,id:"ogx-pivot-btn",className:`ogx-toolbar__icon-btn${P?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure pivot","aria-expanded":P,"aria-controls":"ogx-pivot-panel",onClick:()=>{E(!P),M(!1),C(!1),y(!1)},children:[t.jsx(fo,{}),B&&t.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Pivot active"})]})}),P&&t.jsx($r,{anchorRef:S,columns:n,model:R,onChange:W=>{i?.(W)},onClose:()=>E(!1)})]}),t.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[t.jsx(Zt,{title:"Summaries",children:t.jsxs("button",{ref:I,id:"ogx-aggregation-btn",className:`ogx-toolbar__icon-btn${b?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure summaries","aria-expanded":b,"aria-controls":"ogx-aggregation-panel",onClick:()=>{M(!b),E(!1),C(!1),y(!1)},children:[t.jsx(ho,{}),A>0&&t.jsx("span",{className:"ogx-toolbar__dot","aria-label":`${A} active summaries`})]})}),b&&t.jsx(Kr,{anchorRef:I,aggregationModel:o,aggregableColumns:Y,onFunctionChange:U,onClearAll:X,onClose:()=>M(!1),activeCount:A})]}),h]})]})}function Qr(){return l.useRef(null)}const Zr=({fullWidth:n=!1,error:o=!1,startAdornment:e,endAdornment:r,className:i="",...s})=>{const c=["ogx-input-wrapper",n&&"ogx-input-wrapper--full-width",o&&"ogx-input-wrapper--error",s.disabled&&"ogx-input-wrapper--disabled",i].filter(Boolean).join(" ");return t.jsxs("div",{className:c,children:[e&&t.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--start",children:e}),t.jsx("input",{className:"ogx-input",...s}),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:i=!0,delimiter:s=",",selectedRows:c}=e,a=c&&c.length>0?n.filter(p=>c.includes(p.id)):n;if(a.length===0){console.warn("No rows to export");return}const g=o.filter(p=>!(p.field==="__check__"||p.field==="__actions__"));let f="";if(i){const p=g.map(m=>Lt(m.headerName||m.field));f+=p.join(s)+`
9
9
  `}if(a.forEach(p=>{const m=g.map(u=>{let h=p[u.field];return u.valueGetter&&(h=u.valueGetter({row:p,field:u.field,value:h})),u.valueFormatter&&h!==void 0&&h!==null&&(h=u.valueFormatter({value:h,row:p,field:u.field})),Lt(String(h??""))});f+=m.join(s)+`
10
10
  `}),e.aggregationResult){const p=e.aggregationResult,m=e.aggregationModel||{},u=g.map(w=>m[w.field]?Lt(m[w.field].toUpperCase()):Lt(""));f+=u.join(s)+`
11
11
  `;const h=g.map(w=>{const b=p[w.field];if(b!=null){let M=b;return w.valueFormatter?M=w.valueFormatter({value:b,row:{},field:w.field}):m[w.field]&&(M=bt(b,m[w.field])),Lt(String(M))}return Lt("")});f+=h.join(s)+`
12
- `}Mn(f,r,"text/csv;charset=utf-8;")}function Lt(n){return n.includes(",")||n.includes('"')||n.includes(`
13
- `)?`"${n.replace(/"/g,'""')}"`:n}function ti(n,o,e={}){const{fileName:r="export.xlsx",sheetName:i="Sheet1",includeHeaders:s=!0,selectedRows:c}=e,a=c&&c.length>0?n.filter(p=>c.includes(p.id)):n;if(a.length===0){console.warn("No rows to export");return}const g=o.filter(p=>!(p.field==="__check__"||p.field==="__actions__"));let f='<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(f+="<head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>",f+=`<x:Name>${i}</x:Name>`,f+="<x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]-->",f+='<meta charset="UTF-8"></head><body>',f+='<table border="1">',s&&(f+="<thead><tr>",g.forEach(p=>{f+=`<th>${dt(p.headerName||p.field)}</th>`}),f+="</tr></thead>"),f+="<tbody>",a.forEach(p=>{f+="<tr>",g.forEach(m=>{let u=p[m.field];m.valueGetter&&(u=m.valueGetter({row:p,field:m.field,value:u})),m.valueFormatter&&u!==void 0&&u!==null&&(u=m.valueFormatter({value:u,row:p,field:m.field})),f+=`<td>${dt(String(u??""))}</td>`})}),e.aggregationResult){const p=e.aggregationResult,m=e.aggregationModel||{};f+='<tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',g.forEach(u=>{m[u.field]?f+=`<td style="text-align: right; font-weight: bold;">${dt(m[u.field].toUpperCase())}</td>`:f+="<td></td>"}),f+="</tr>",f+='<tr style="font-weight: bold; background-color: #f5f5f5;">',g.forEach(u=>{const h=p[u.field];if(h!=null){let w=h;u.valueFormatter?w=u.valueFormatter({value:h,row:{},field:u.field}):m[u.field]&&(w=bt(h,m[u.field])),f+=`<td style="text-align: right;">${dt(String(w))}</td>`}else f+="<td></td>"}),f+="</tr>"}f+="</tbody></table></body></html>",Mn(f,r,"application/vnd.ms-excel")}function dt(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function ni(n,o,e={}){const{fileName:r="export.json",pretty:i=!0,selectedRows:s}=e,c=s&&s.length>0?n.filter(m=>s.includes(m.id)):n;if(c.length===0){console.warn("No rows to export");return}const a=o.filter(m=>!(m.field==="__check__"||m.field==="__actions__")),g=c.map(m=>{const u={};return a.forEach(h=>{let w=m[h.field];h.valueGetter&&(w=h.valueGetter({row:m,field:h.field,value:w})),u[h.field]=w}),u});let f=g;if(e.aggregationResult){const m=e.aggregationResult,u=e.aggregationModel||{},h={};a.forEach(b=>{u[b.field]&&(h[b.field]=u[b.field].toUpperCase())});const w={};a.forEach(b=>{if(m[b.field]!==void 0&&m[b.field]!==null){let M=m[b.field];b.valueFormatter?M=b.valueFormatter({value:M,row:{},field:b.field}):u[b.field]&&(M=bt(M,u[b.field])),w[b.field]=M}}),f={data:g,aggregation:{labels:h,values:w}}}const p=i?JSON.stringify(f,null,2):JSON.stringify(f);Mn(p,r,"application/json;charset=utf-8;")}async function oi(n,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(`
12
+ `}Pn(f,r,"text/csv;charset=utf-8;")}function Lt(n){return n.includes(",")||n.includes('"')||n.includes(`
13
+ `)?`"${n.replace(/"/g,'""')}"`:n}function ti(n,o,e={}){const{fileName:r="export.xlsx",sheetName:i="Sheet1",includeHeaders:s=!0,selectedRows:c}=e,a=c&&c.length>0?n.filter(p=>c.includes(p.id)):n;if(a.length===0){console.warn("No rows to export");return}const g=o.filter(p=>!(p.field==="__check__"||p.field==="__actions__"));let f='<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(f+="<head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>",f+=`<x:Name>${i}</x:Name>`,f+="<x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]-->",f+='<meta charset="UTF-8"></head><body>',f+='<table border="1">',s&&(f+="<thead><tr>",g.forEach(p=>{f+=`<th>${ut(p.headerName||p.field)}</th>`}),f+="</tr></thead>"),f+="<tbody>",a.forEach(p=>{f+="<tr>",g.forEach(m=>{let u=p[m.field];m.valueGetter&&(u=m.valueGetter({row:p,field:m.field,value:u})),m.valueFormatter&&u!==void 0&&u!==null&&(u=m.valueFormatter({value:u,row:p,field:m.field})),f+=`<td>${ut(String(u??""))}</td>`})}),e.aggregationResult){const p=e.aggregationResult,m=e.aggregationModel||{};f+='<tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',g.forEach(u=>{m[u.field]?f+=`<td style="text-align: right; font-weight: bold;">${ut(m[u.field].toUpperCase())}</td>`:f+="<td></td>"}),f+="</tr>",f+='<tr style="font-weight: bold; background-color: #f5f5f5;">',g.forEach(u=>{const h=p[u.field];if(h!=null){let w=h;u.valueFormatter?w=u.valueFormatter({value:h,row:{},field:u.field}):m[u.field]&&(w=bt(h,m[u.field])),f+=`<td style="text-align: right;">${ut(String(w))}</td>`}else f+="<td></td>"}),f+="</tr>"}f+="</tbody></table></body></html>",Pn(f,r,"application/vnd.ms-excel")}function ut(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function ni(n,o,e={}){const{fileName:r="export.json",pretty:i=!0,selectedRows:s}=e,c=s&&s.length>0?n.filter(m=>s.includes(m.id)):n;if(c.length===0){console.warn("No rows to export");return}const a=o.filter(m=>!(m.field==="__check__"||m.field==="__actions__")),g=c.map(m=>{const u={};return a.forEach(h=>{let w=m[h.field];h.valueGetter&&(w=h.valueGetter({row:m,field:h.field,value:w})),u[h.field]=w}),u});let f=g;if(e.aggregationResult){const m=e.aggregationResult,u=e.aggregationModel||{},h={};a.forEach(b=>{u[b.field]&&(h[b.field]=u[b.field].toUpperCase())});const w={};a.forEach(b=>{if(m[b.field]!==void 0&&m[b.field]!==null){let M=m[b.field];b.valueFormatter?M=b.valueFormatter({value:M,row:{},field:b.field}):u[b.field]&&(M=bt(M,u[b.field])),w[b.field]=M}}),f={data:g,aggregation:{labels:h,values:w}}}const p=i?JSON.stringify(f,null,2):JSON.stringify(f);Pn(p,r,"application/json;charset=utf-8;")}async function oi(n,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>
@@ -49,5 +49,5 @@ ${p}`;try{await Tr(m)}catch(u){console.error("[OpenGridX] Failed to copy to clip
49
49
  </style>
50
50
  </head>
51
51
  <body>
52
- `;if(i&&(p+=`<h1>${dt(i)}</h1>`),p+="<table>",p+="<thead><tr>",f.forEach(u=>{p+=`<th>${dt(u.headerName||u.field)}</th>`}),p+="</tr></thead>",p+="<tbody>",g.forEach(u=>{p+="<tr>",f.forEach(h=>{let w=u[h.field];h.valueGetter&&(w=h.valueGetter({row:u,field:h.field,value:w})),h.valueFormatter&&w!==void 0&&w!==null&&(w=h.valueFormatter({value:w,row:u,field:h.field})),h.type==="image"&&w?p+=`<td><div style="display:flex;justify-content:center;"><img src="${w}" alt="${h.headerName}" style="max-height: 40px; border-radius: 4px;"></div></td>`:p+=`<td>${dt(String(w??""))}</td>`}),p+="</tr>"}),c){const u=a||{};p+='<tfoot><tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',f.forEach(h=>{u[h.field]?p+=`<td style="text-align: right; font-weight: bold;">${dt(u[h.field].toUpperCase())}</td>`:p+="<td></td>"}),p+='</tr><tr style="font-weight: bold; background-color: #f5f5f5;">',f.forEach(h=>{const w=c[h.field];if(w!=null){let b=w;h.valueFormatter?b=h.valueFormatter({value:w,row:{},field:h.field}):u[h.field]&&(b=bt(w,u[h.field])),p+=`<td style="text-align: right;">${dt(String(b))}</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=i||"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(i){console.error("Print generation failed:",i),r&&!r.closed&&(r.document.body.innerHTML=`<div style="color: red; padding: 20px;"><h3>Error Generating Print Preview</h3><p>${i.message}</p></div>`)}}function Mn(n,o,e){const r=new Blob([n],{type:e}),i=URL.createObjectURL(r),s=document.createElement("a");s.href=i,s.download=o,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(i)}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 a=r.indexOf(","),g=r.slice(0,a),f=r.slice(a+1),p=atob(f),m=new Uint8Array(p.length);for(let b=0;b<p.length;b++)m[b]=p.charCodeAt(b);const h=g.match(/data:([^;,]+)/)?.[1]??"image/png";let w="png";return h.includes("jpeg")||h.includes("jpg")?w="jpeg":h.includes("gif")&&(w="gif"),{url:r,buffer:m.buffer,ext:w}}const i=await fetch(r,{mode:"cors"});if(!i.ok)throw new Error(`HTTP ${i.status}`);const s=await i.arrayBuffer(),c=si(r,i.headers.get("content-type"));return{url:r,buffer:s,ext:c}})),e=new Map;return o.forEach((r,i)=>{r.status==="fulfilled"?e.set(r.value.url,{buffer:r.value.buffer,extension:r.value.ext}):console.warn(`[exportToExcelAdvanced] Cannot embed image "${n[i]}" (CORS/network error — raw URL written as fallback):`,r.reason)}),e}async function di(n,o,e={}){const{fileName:r="export.xlsx",sheets:i,columnStyles:s={},headerFillColor:c="#f1f5f9",headerTextColor:a="#334155",headerFontSize:g=10,bodyFontSize:f=10,aggregationResult:p=null,aggregationModel:m=null,selectedRows:u}=e,h=(await import("exceljs")).default,w=new h.Workbook;w.creator="OpenGridX",w.created=new Date;const b=o.filter(S=>S.field!=="__check__"&&S.field!=="__actions__"&&!S.isSpacer),M=n,P=u&&u.length>0?n.filter(S=>u.includes(S.id)):n,E=i??[{name:"Data",rows:"all",includeHeaders:!0,includeSummary:!1}],k=new Map;for(const S of E){if("type"in S&&S.type==="summary"){if(!p||!m)continue;const v=w.addWorksheet(S.name??"Summary");v.addRow(["Summary / Aggregation Totals"]),v.getRow(1).font={bold:!0,size:g+2,color:{argb:wt(a)}},v.addRow([]),v.addRow(["Column","Function","Value"]).eachCell(H=>{H.fill={type:"pattern",pattern:"solid",fgColor:{argb:wt(c)}},H.font={bold:!0,size:g,color:{argb:wt(a)}},H.border=xo()}),b.forEach(H=>{const W=m[H.field],F=p[H.field];if(W==null||F==null)return;let X=F;H.valueFormatter?X=H.valueFormatter({value:F,row:{},field:H.field}):X=bt(F,W);const K=v.addRow([H.headerName??H.field,W.toUpperCase(),X]);K.getCell(3).alignment={horizontal:"right"},K.getCell(3).font={bold:!0,size:f}}),v.getColumn(1).width=20,v.getColumn(2).width=12,v.getColumn(3).width=18;continue}const x=S,{name:j="Data",rows:R="all",includeHeaders:B=!0,includeSummary:q=!1,autoFilter:A=!0,frozenHeader:U=!0,alternateRowColor:Y="#f8fafc"}=x,G=R==="selected"?P:M,ee=b.filter(v=>s[v.field]?.embedImage);if(ee.length>0){const v=[],D=new Set;if(G.forEach(H=>{ee.forEach(W=>{const F=H[W.field];typeof F=="string"&&F&&!k.has(F)&&!D.has(F)&&(v.push(F),D.add(F))})}),v.length>0){const H=await ai(v);for(const[W,{buffer:F,extension:X}]of H){const K=w.addImage({buffer:F,extension:X});k.set(W,K)}}}const Q=w.addWorksheet(j);if(Q.columns=b.map(v=>({key:v.field,width:li(v,s[v.field]?.width),style:{numFmt:s[v.field]?.numFmt??ii(v)}})),B){const v=b.map(H=>H.headerName??H.field),D=Q.addRow(v);D.height=20,D.eachCell((H,W)=>{const F=b[W-1];H.fill={type:"pattern",pattern:"solid",fgColor:{argb:wt(c)}},H.font={bold:!0,size:g,color:{argb:wt(a)}},H.alignment={horizontal:s[F?.field]?.alignment??(F?.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=B?1:0;if(G.forEach((v,D)=>{const H=b.map(F=>{if(s[F.field]?.embedImage)return"";let X=v[F.field];return F.valueGetter&&(X=F.valueGetter({row:v,field:F.field,value:X})),ri(F,X)==="string"&&F.valueFormatter&&X!=null&&(X=F.valueFormatter({value:X,row:v,field:F.field})),X}),W=Q.addRow(H);if(W.font={size:f},Y&&D%2===1&&W.eachCell(F=>{F.fill={type:"pattern",pattern:"solid",fgColor:{argb:wt(Y)}}}),W.eachCell((F,X)=>{const K=b[X-1];K&&(F.alignment={horizontal:s[K.field]?.alignment??(K.type==="number"?"right":"left"),vertical:"middle"},F.border={bottom:{style:"thin",color:{argb:"FFf1f5f9"}}})}),ee.length>0){const F=ee.reduce((L,ae)=>Math.max(L,s[ae.field]?.imageHeight??40),0),X=Math.ceil(F/1.333),K=X*1.333;W.height=X,ee.forEach(L=>{const ae=b.indexOf(L),oe=v[L.field],me=typeof oe=="string"?k.get(oe):void 0;if(me===void 0){W.getCell(ae+1).value=typeof oe=="string"?oe:"";return}const Ze=s[L.field],z=Ze?.imageWidth??40,Ee=Ze?.imageHeight??40,ct=(Q.getColumn(ae+1).width??8)*7+5,De=Math.max(0,ct-z)/2,ut=Math.max(0,K-Ee)/2;Q.addImage(me,{tl:{col:ae,row:pe,nativeColOff:Math.floor(De*9525),nativeRowOff:Math.floor(ut*9525)},ext:{width:z,height:Ee},editAs:"oneCell"})})}else W.height=16;pe++}),q&&p&&m){const v=b.map(F=>{const X=m[F.field];return X?X.toUpperCase():""}),D=Q.addRow(v);D.height=16,D.font={size:f-1,italic:!0,color:{argb:"FF94a3b8"}},D.eachCell(F=>{F.alignment={horizontal:"right",vertical:"middle"},F.border={top:{style:"thin",color:{argb:"FFcbd5e1"}}}});const H=b.map(F=>{const X=m[F.field],K=p[F.field];return X==null||K==null?"":F.valueFormatter?F.valueFormatter({value:K,row:{},field:F.field}):bt(K,X)}),W=Q.addRow(H);W.height=18,W.font={bold:!0,size:f,color:{argb:wt(a)}},W.eachCell(F=>{F.fill={type:"pattern",pattern:"solid",fgColor:{argb:wt(c)}},F.alignment={horizontal:"right",vertical:"middle"},F.border=ci()})}}const C=await w.xlsx.writeBuffer(),_=new Blob([C],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),y=URL.createObjectURL(_),I=document.createElement("a");I.href=y,I.download=r.endsWith(".xlsx")?r:`${r}.xlsx`,document.body.appendChild(I),I.click(),document.body.removeChild(I),URL.revokeObjectURL(y)}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 gi(n){const o={};function e(r,i){i!==void 0&&(o[r]=i)}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 fi({theme:n,children:o,className:e,style:r}){const i=l.useMemo(()=>({...ui,...gi(n)}),[n]);return t.jsx("div",{className:e,style:{...r,...i},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 i=e?Object.fromEntries(Object.entries(o).filter(([s])=>e.includes(s))):o;r.setItem(n,JSON.stringify(i))}catch{}}function _i(n){const o=typeof n=="string"?{key:n}:n,{key:e,debounceMs:r=300,include:i,storage:s=typeof window<"u"?window.localStorage:void 0}=o,c=l.useMemo(()=>{if(s)return wi(e,s)},[e]),a=l.useRef(null),g=l.useRef(null),f=l.useCallback(()=>{g.current&&s&&vi(e,g.current,i,s)},[e,i,s]),p=l.useCallback(u=>{g.current=u,a.current&&clearTimeout(a.current),a.current=setTimeout(f,r)},[f,r]);l.useEffect(()=>()=>{a.current&&(clearTimeout(a.current),f())},[f]);const m=l.useCallback(()=>{s&&s.removeItem(e)},[e,s]);return{initialState:c,onStateChange:p,clearState:m}}ie.Button=Qt,ie.Cell=ro,ie.Checkbox=qt,ie.DataGrid=Wr,ie.DataGridThemeProvider=fi,ie.FilterPanel=go,ie.GridToolbar=Jr,ie.GridTooltip=Zt,ie.Header=oo,ie.Input=Zr,ie.Row=Jt,ie.Skeleton=Fr,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(i&&(p+=`<h1>${ut(i)}</h1>`),p+="<table>",p+="<thead><tr>",f.forEach(u=>{p+=`<th>${ut(u.headerName||u.field)}</th>`}),p+="</tr></thead>",p+="<tbody>",g.forEach(u=>{p+="<tr>",f.forEach(h=>{let w=u[h.field];h.valueGetter&&(w=h.valueGetter({row:u,field:h.field,value:w})),h.valueFormatter&&w!==void 0&&w!==null&&(w=h.valueFormatter({value:w,row:u,field:h.field})),h.type==="image"&&w?p+=`<td><div style="display:flex;justify-content:center;"><img src="${w}" alt="${h.headerName}" style="max-height: 40px; border-radius: 4px;"></div></td>`:p+=`<td>${ut(String(w??""))}</td>`}),p+="</tr>"}),c){const u=a||{};p+='<tfoot><tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',f.forEach(h=>{u[h.field]?p+=`<td style="text-align: right; font-weight: bold;">${ut(u[h.field].toUpperCase())}</td>`:p+="<td></td>"}),p+='</tr><tr style="font-weight: bold; background-color: #f5f5f5;">',f.forEach(h=>{const w=c[h.field];if(w!=null){let b=w;h.valueFormatter?b=h.valueFormatter({value:w,row:{},field:h.field}):u[h.field]&&(b=bt(w,u[h.field])),p+=`<td style="text-align: right;">${ut(String(b))}</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=i||"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(i){console.error("Print generation failed:",i),r&&!r.closed&&(r.document.body.innerHTML=`<div style="color: red; padding: 20px;"><h3>Error Generating Print Preview</h3><p>${i.message}</p></div>`)}}function Pn(n,o,e){const r=new Blob([n],{type:e}),i=URL.createObjectURL(r),s=document.createElement("a");s.href=i,s.download=o,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(i)}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 a=r.indexOf(","),g=r.slice(0,a),f=r.slice(a+1),p=atob(f),m=new Uint8Array(p.length);for(let b=0;b<p.length;b++)m[b]=p.charCodeAt(b);const h=g.match(/data:([^;,]+)/)?.[1]??"image/png";let w="png";return h.includes("jpeg")||h.includes("jpg")?w="jpeg":h.includes("gif")&&(w="gif"),{url:r,buffer:m.buffer,ext:w}}const i=await fetch(r,{mode:"cors"});if(!i.ok)throw new Error(`HTTP ${i.status}`);const s=await i.arrayBuffer(),c=si(r,i.headers.get("content-type"));return{url:r,buffer:s,ext:c}})),e=new Map;return o.forEach((r,i)=>{r.status==="fulfilled"?e.set(r.value.url,{buffer:r.value.buffer,extension:r.value.ext}):console.warn(`[exportToExcelAdvanced] Cannot embed image "${n[i]}" (CORS/network error — raw URL written as fallback):`,r.reason)}),e}async function di(n,o,e={}){const{fileName:r="export.xlsx",sheets:i,columnStyles:s={},headerFillColor:c="#f1f5f9",headerTextColor:a="#334155",headerFontSize:g=10,bodyFontSize:f=10,aggregationResult:p=null,aggregationModel:m=null,selectedRows:u}=e,h=(await import("exceljs")).default,w=new h.Workbook;w.creator="OpenGridX",w.created=new Date;const b=o.filter(S=>S.field!=="__check__"&&S.field!=="__actions__"&&!S.isSpacer),M=n,P=u&&u.length>0?n.filter(S=>u.includes(S.id)):n,E=i??[{name:"Data",rows:"all",includeHeaders:!0,includeSummary:!1}],k=new Map;for(const S of E){if("type"in S&&S.type==="summary"){if(!p||!m)continue;const v=w.addWorksheet(S.name??"Summary");v.addRow(["Summary / Aggregation Totals"]),v.getRow(1).font={bold:!0,size:g+2,color:{argb:wt(a)}},v.addRow([]),v.addRow(["Column","Function","Value"]).eachCell(H=>{H.fill={type:"pattern",pattern:"solid",fgColor:{argb:wt(c)}},H.font={bold:!0,size:g,color:{argb:wt(a)}},H.border=xo()}),b.forEach(H=>{const W=m[H.field],F=p[H.field];if(W==null||F==null)return;let q=F;H.valueFormatter?q=H.valueFormatter({value:F,row:{},field:H.field}):q=bt(F,W);const K=v.addRow([H.headerName??H.field,W.toUpperCase(),q]);K.getCell(3).alignment={horizontal:"right"},K.getCell(3).font={bold:!0,size:f}}),v.getColumn(1).width=20,v.getColumn(2).width=12,v.getColumn(3).width=18;continue}const x=S,{name:j="Data",rows:R="all",includeHeaders:B=!0,includeSummary:Y=!1,autoFilter:A=!0,frozenHeader:U=!0,alternateRowColor:X="#f8fafc"}=x,G=R==="selected"?P:M,ee=b.filter(v=>s[v.field]?.embedImage);if(ee.length>0){const v=[],D=new Set;if(G.forEach(H=>{ee.forEach(W=>{const F=H[W.field];typeof F=="string"&&F&&!k.has(F)&&!D.has(F)&&(v.push(F),D.add(F))})}),v.length>0){const H=await ai(v);for(const[W,{buffer:F,extension:q}]of H){const K=w.addImage({buffer:F,extension:q});k.set(W,K)}}}const Q=w.addWorksheet(j);if(Q.columns=b.map(v=>({key:v.field,width:li(v,s[v.field]?.width),style:{numFmt:s[v.field]?.numFmt??ii(v)}})),B){const v=b.map(H=>H.headerName??H.field),D=Q.addRow(v);D.height=20,D.eachCell((H,W)=>{const F=b[W-1];H.fill={type:"pattern",pattern:"solid",fgColor:{argb:wt(c)}},H.font={bold:!0,size:g,color:{argb:wt(a)}},H.alignment={horizontal:s[F?.field]?.alignment??(F?.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=B?1:0;if(G.forEach((v,D)=>{const H=b.map(F=>{if(s[F.field]?.embedImage)return"";let q=v[F.field];return F.valueGetter&&(q=F.valueGetter({row:v,field:F.field,value:q})),ri(F,q)==="string"&&F.valueFormatter&&q!=null&&(q=F.valueFormatter({value:q,row:v,field:F.field})),q}),W=Q.addRow(H);if(W.font={size:f},X&&D%2===1&&W.eachCell(F=>{F.fill={type:"pattern",pattern:"solid",fgColor:{argb:wt(X)}}}),W.eachCell((F,q)=>{const K=b[q-1];K&&(F.alignment={horizontal:s[K.field]?.alignment??(K.type==="number"?"right":"left"),vertical:"middle"},F.border={bottom:{style:"thin",color:{argb:"FFf1f5f9"}}})}),ee.length>0){const F=ee.reduce((L,ae)=>Math.max(L,s[ae.field]?.imageHeight??40),0),q=Math.ceil(F/1.333),K=q*1.333;W.height=q,ee.forEach(L=>{const ae=b.indexOf(L),oe=v[L.field],me=typeof oe=="string"?k.get(oe):void 0;if(me===void 0){W.getCell(ae+1).value=typeof oe=="string"?oe:"";return}const Ze=s[L.field],z=Ze?.imageWidth??40,Ee=Ze?.imageHeight??40,gt=(Q.getColumn(ae+1).width??8)*7+5,De=Math.max(0,gt-z)/2,et=Math.max(0,K-Ee)/2;Q.addImage(me,{tl:{col:ae,row:pe,nativeColOff:Math.floor(De*9525),nativeRowOff:Math.floor(et*9525)},ext:{width:z,height:Ee},editAs:"oneCell"})})}else W.height=16;pe++}),Y&&p&&m){const v=b.map(F=>{const q=m[F.field];return q?q.toUpperCase():""}),D=Q.addRow(v);D.height=16,D.font={size:f-1,italic:!0,color:{argb:"FF94a3b8"}},D.eachCell(F=>{F.alignment={horizontal:"right",vertical:"middle"},F.border={top:{style:"thin",color:{argb:"FFcbd5e1"}}}});const H=b.map(F=>{const q=m[F.field],K=p[F.field];return q==null||K==null?"":F.valueFormatter?F.valueFormatter({value:K,row:{},field:F.field}):bt(K,q)}),W=Q.addRow(H);W.height=18,W.font={bold:!0,size:f,color:{argb:wt(a)}},W.eachCell(F=>{F.fill={type:"pattern",pattern:"solid",fgColor:{argb:wt(c)}},F.alignment={horizontal:"right",vertical:"middle"},F.border=ci()})}}const C=await w.xlsx.writeBuffer(),_=new Blob([C],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),y=URL.createObjectURL(_),I=document.createElement("a");I.href=y,I.download=r.endsWith(".xlsx")?r:`${r}.xlsx`,document.body.appendChild(I),I.click(),document.body.removeChild(I),URL.revokeObjectURL(y)}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 gi(n){const o={};function e(r,i){i!==void 0&&(o[r]=i)}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 fi({theme:n,children:o,className:e,style:r}){const i=l.useMemo(()=>({...ui,...gi(n)}),[n]);return t.jsx("div",{className:`ogx-theme-provider ${e||""}`.trim(),style:{...r,...i},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 i=e?Object.fromEntries(Object.entries(o).filter(([s])=>e.includes(s))):o;r.setItem(n,JSON.stringify(i))}catch{}}function _i(n){const o=typeof n=="string"?{key:n}:n,{key:e,debounceMs:r=300,include:i,storage:s=typeof window<"u"?window.localStorage:void 0}=o,c=l.useMemo(()=>{if(s)return wi(e,s)},[e]),a=l.useRef(null),g=l.useRef(null),f=l.useCallback(()=>{g.current&&s&&vi(e,g.current,i,s)},[e,i,s]),p=l.useCallback(u=>{g.current=u,a.current&&clearTimeout(a.current),a.current=setTimeout(f,r)},[f,r]);l.useEffect(()=>()=>{a.current&&(clearTimeout(a.current),f())},[f]);const m=l.useCallback(()=>{s&&s.removeItem(e)},[e,s]);return{initialState:c,onStateChange:p,clearState:m}}ie.Button=Qt,ie.Cell=ro,ie.Checkbox=qt,ie.DataGrid=Wr,ie.DataGridThemeProvider=fi,ie.FilterPanel=go,ie.GridToolbar=Jr,ie.GridTooltip=Zt,ie.Header=oo,ie.Input=Zr,ie.Row=Jt,ie.Skeleton=Fr,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"})}));
53
53
  //# sourceMappingURL=opengridx.umd.js.map