@opencorestack/opengridx 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/index.d.ts +15 -9
- package/dist/opengridx.css +1 -1
- package/dist/opengridx.css.d.ts +4 -0
- package/dist/opengridx.es.js +2536 -2458
- package/dist/opengridx.es.js.map +1 -1
- package/dist/opengridx.umd.js +11 -11
- package/dist/opengridx.umd.js.map +1 -1
- package/llms.txt +1 -1
- package/package.json +6 -3
package/dist/opengridx.umd.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
(function(
|
|
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:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,A,U,T,U),he[U+A]=!0)}if(U=null,F!==void 0&&(e(F),U=""+F),d(H)&&(e(H.key),U=""+H.key),"key"in H){F={};for(var se in H)se!=="key"&&(F[se]=H[se])}else F=H;return U&&a(F,typeof v=="function"?v.displayName||v.name||"Unknown":v),g(v,U,F,i(),O,Q)}function b(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"),m=Symbol.for("react.portal"),I=Symbol.for("react.fragment"),M=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),C=Symbol.for("react.consumer"),_=Symbol.for("react.context"),j=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),k=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),S=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,$=Array.isArray,K=console.createTask?console.createTask:function(){return null};h={react_stack_bottom_frame:function(v){return v()}};var q,D={},Z=h.react_stack_bottom_frame.bind(h,s)(),J=K(r(s)),he={};Xt.Fragment=I,Xt.jsx=function(v,H,F){var A=1e4>B.recentlyCreatedOwnerStacks++;return p(v,H,F,!1,A?Error("react-stack-top-frame"):Z,A?K(r(v)):J)},Xt.jsxs=function(v,H,F){var A=1e4>B.recentlyCreatedOwnerStacks++;return p(v,H,F,!0,A?Error("react-stack-top-frame"):Z,A?K(r(v)):J)}})()),Xt}var Qn;function Oo(){return Qn||(Qn=1,process.env.NODE_ENV==="production"?an.exports=Fo():an.exports=Wo()),an.exports}var t=Oo();function Ao({row:n,rowIndex:o,listViewColumn:e,isSelected:r=!1,checkboxSelection:i=!1,rowHeight:s,onRowClick:d,onSelectionChange:a}){const f={row:n,value:void 0,field:e.field,colDef:{field:e.field},rowIndex:o,colIndex:0},g=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:()=>d?.(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:g,"aria-label":`Select row ${n.id}`})}),t.jsx("div",{className:"ogx-list-view__cell",role:"gridcell",children:e.renderCell(f)})]})}const qt=({indeterminate:n=!1,label:o,className:e="",inputRef:r,...i})=>{const s=l.useRef(null),d=l.useCallback(f=>{s.current=f,typeof r=="function"?r(f):r&&(r.current=f)},[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:d,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 zo(n){const{field:o,currentWidth:e,onResize:r,minWidth:i=50,maxWidth:s=1e3}=n,[d,a]=l.useState(!1),f=l.useRef(0),g=l.useRef(0),p=l.useCallback(h=>{h.preventDefault(),h.stopPropagation(),a(!0),f.current=h.clientX,g.current=e;let w=0;const m=16,I=E=>{const C=E.clientX-f.current,_=Math.max(i,Math.min(s,g.current+C)),j=Date.now();j-w>=m&&(r(o,_),w=j)},M=E=>{a(!1);const C=E.clientX-f.current,_=Math.max(i,Math.min(s,g.current+C));r(o,_),document.removeEventListener("mousemove",I),document.removeEventListener("mouseup",M)};document.addEventListener("mousemove",I),document.addEventListener("mouseup",M)},[o,e,r,i,s]),b=l.useCallback(h=>{h.preventDefault(),h.stopPropagation()},[]),u=["ogx-column-resize-handle",d&&"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:b,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 Bo(n,o){const e=[],r=[],i=[];return o?(n.forEach(s=>{const d=dn(s.field,o);d==="left"?e.push(s):d==="right"?i.push(s):r.push(s)}),o.left&&e.sort((s,d)=>{const a=o.left.indexOf(s.field),f=o.left.indexOf(d.field);return a-f}),o.right&&i.sort((s,d)=>{const a=o.right.indexOf(s.field),f=o.right.indexOf(d.field);return a-f}),{left:e,center:r,right:i}):{left:e,center:n,right:i}}function Zn(n,o,e,r,i,s,d,a){const f={};if(!e)return f;const g=Bo(n,e);let p=0;a&&(p+=48),s&&d&&(p+=48),r&&i&&(p+=48),g.left.forEach(u=>{f[u.field]=p;const h=o[u.field]??u.width??100;p+=h});let b=0;return[...g.right].reverse().forEach(u=>{const h=o[u.field]??u.width??100;f[u.field]=b,b+=h}),f}function Sn(n,o){return o?o.top?.includes(n)?"top":o.bottom?.includes(n)?"bottom":null:null}function $o(n,o){const e=[],r=[],i=[];return o?(n.forEach(s=>{const d=Sn(s.id,o);d==="top"?e.push(s):d==="bottom"?i.push(s):r.push(s)}),o.top&&e.sort((s,d)=>{const a=o.top.indexOf(s.id),f=o.top.indexOf(d.id);return a-f}),o.bottom&&i.sort((s,d)=>{const a=o.bottom.indexOf(s.id),f=o.bottom.indexOf(d.id);return a-f}),{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 It(){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 Do(){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 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:"5",x2:"12",y2:"19"}),t.jsx("polyline",{points:"19 12 12 19 5 12"})]})}function Vo(){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 Uo(){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 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("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 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:"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 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:"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 qo({colDef:n,sortModel:o,onSort:e,onHide:r,onPin:i,pinnedColumns:s,onManageColumns:d,onClose:a,anchorEl:f}){const g=l.useRef(null),[p,b]=l.useState({position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"});l.useLayoutEffect(()=>{if(!f||!g.current)return;const j=f.getBoundingClientRect(),y=g.current.getBoundingClientRect(),P=window.innerWidth,k=window.innerHeight,x=8;let S=j.left;S+y.width+x>P&&(S=P-y.width-x),S<x&&(S=x);let R=j.bottom+4;R+y.height+x>k&&(R=j.top-y.height-4),b({position:"fixed",zIndex:1300,top:R,left:S,visibility:"visible"})},[f]),l.useEffect(()=>{function j(P){g.current&&!g.current.contains(P.target)&&f&&!f.contains(P.target)&&a()}function y(P){P.key==="Escape"&&a()}return document.addEventListener("mousedown",j),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",j),document.removeEventListener("keydown",y)}},[f,a]);const u=j=>{e?.(n.field,j),a()},h=()=>{r?.(n.field),a()},w=j=>{i?.(n.field,j),a()},m=o?.find(j=>j.field===n.field)?.sort,I=m==null,M=s?.left?.includes(n.field)??!1,E=s?.right?.includes(n.field)??!1,C=!M&&!E,_=n.headerName||n.field;return kt.createPortal(t.jsxs("div",{ref:g,className:"ogx-column-menu",style:p,role:"menu","aria-label":`Column options for ${_}`,children:[e&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{className:`ogx-menu-item${m==="asc"?" ogx-menu-item--active":""}`,onClick:()=>u("asc"),role:"menuitemradio","aria-checked":m==="asc",children:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:m==="asc"?t.jsx(Mt,{}):t.jsx(It,{})}),t.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:t.jsx(Do,{})}),"Sort Ascending"]}),t.jsxs("button",{className:`ogx-menu-item${m==="desc"?" ogx-menu-item--active":""}`,onClick:()=>u("desc"),role:"menuitemradio","aria-checked":m==="desc",children:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:m==="desc"?t.jsx(Mt,{}):t.jsx(It,{})}),t.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:t.jsx(Go,{})}),"Sort Descending"]}),t.jsxs("button",{className:`ogx-menu-item${I?" ogx-menu-item--active":""}`,onClick:()=>u(null),role:"menuitemradio","aria-checked":I,children:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:I?t.jsx(Mt,{}):t.jsx(It,{})}),t.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:t.jsx(Vo,{})}),"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${M?" ogx-menu-item--active":""}`,onClick:()=>w("left"),role:"menuitemradio","aria-checked":M,"aria-label":"Pin to left",children:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:M?t.jsx(Mt,{}):t.jsx(It,{})}),t.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:t.jsx(Ko,{})}),"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(It,{})}),t.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:t.jsx(Yo,{})}),"Pin to Right"]}),t.jsxs("button",{className:`ogx-menu-item${C?" ogx-menu-item--active":""}`,onClick:()=>w(null),role:"menuitemradio","aria-checked":C,"aria-label":"Unpin column",children:[t.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:C?t.jsx(Mt,{}):t.jsx(It,{})}),t.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:t.jsx(Xo,{})}),"Unpin"]}),t.jsx("div",{className:"ogx-menu-divider"}),t.jsxs("button",{className:"ogx-menu-item",onClick:h,role:"menuitem","aria-label":`Hide ${_} 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(Uo,{})}),"Hide Column"]}),t.jsx("div",{className:"ogx-menu-divider"}),t.jsxs("button",{className:"ogx-menu-item",onClick:()=>{d?.(),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 Jo(){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 Qo(){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 eo(n){const o=[];for(const e of n.children)typeof e=="string"?o.push(e):o.push(...eo(e));return o}function Zo(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 er(n,o,e){function r(a,f,g){if(!eo(a).includes(f))return null;if(g===e)return a;for(const p of a.children)if(typeof p!="string"){const b=r(p,f,g+1);if(b)return b}return null}const i=new Map;for(const a of o){let f=null;for(const g of n)if(f=r(g,a.field,0),f)break;i.set(a.field,f)}const s=[];let d=0;for(;d<o.length;){const a=o[d],f=i.get(a.field)??null,g=a.width;if(!f)s.push({key:`fg-${a.field}-${e}`,label:"",width:g,isGroup:!1}),d++;else{let p=0,b=d;for(;b<o.length&&i.get(o[b].field)===f;)p+=o[b].width,b++;s.push({key:`${f.groupId}-${e}`,label:f.headerName,width:p,isGroup:!0}),d=b}}return s}function to(n){const{columns:o,allColumns:e,columnGroupingModel:r,checkboxSelection:i=!1,allSelected:s=!1,someSelected:d=!1,onSelectAll:a,onSort:f,sortModel:g=[],onColumnResize:p,columnWidths:b={},pinnedColumns:u,hasDetailPanel:h=!1,pinCheckboxColumn:w=!0,pinExpandColumn:m=!0,rowReordering:I=!1,aggregationModel:M,draggedColumn:E,dragOverColumn:C,onDragStart:_,onDragOver:j,onDragEnd:y,onDrop:P,focusedCell:k,onHeaderClick:x,onHideColumn:S,onPinColumn:R,onManageColumns:B}=n,Y=l.useRef({}),[$,K]=l.useState(null),q=T=>se=>{se.stopPropagation(),K({colDef:T,anchorEl:se.currentTarget})},D=()=>{K(null)};l.useLayoutEffect(()=>{if(k?.id==="HEADER"){const T=Y.current[k.field];T&&T.focus()}},[k]);const Z=T=>()=>{if(T.sortable===!1||!f)return;const se=g.find(xe=>xe.field===T.field);let ne="asc";se&&(se.sort==="asc"?ne="desc":ne=null),f(T.field,ne)},J=T=>{const se=g.find(ne=>ne.field===T);return se?t.jsx("span",{className:`ogx__sort-icon ogx__sort-icon--${se.sort}`,"aria-hidden":"true"}):null},he=l.useMemo(()=>Zn(o,b,u,i,w,h,m,I),[o,b,u,i,w,h,m,I]),v=r?Zo(r):0,F=(e??o).filter(T=>!T.isSpacer).map(T=>({field:T.field,width:b[T.field]??T.width??100})),U=(I?48:0)+(h?48:0)+(i?48:0);return t.jsxs("div",{className:"ogx__header-wrap",children:[v>0&&Array.from({length:v},(T,se)=>{const ne=er(r,F,se);return t.jsxs("div",{className:"ogx-col-group-row",role:"row",children:[U>0&&t.jsx("div",{className:"ogx-col-group-cell ogx-col-group-cell--filler",style:{width:U,minWidth:U,flexShrink:0},role:"columnheader"}),ne.map(xe=>t.jsx("div",{role:"columnheader",className:`ogx-col-group-cell ${xe.isGroup?"ogx-col-group-cell--group":"ogx-col-group-cell--filler"}`,style:{width:xe.width,minWidth:xe.width,flexShrink:0},title:xe.isGroup?xe.label:void 0,children:xe.isGroup&&t.jsx("span",{className:"ogx-col-group-cell__label",children:xe.label})},xe.key))]},`ogx-grp-${se}`)}),t.jsxs("div",{className:"ogx__header",role:"row",children:[I&&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 ${m?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""}`,role:"columnheader","aria-label":"Expand row details",style:{minWidth:48,maxWidth:48,position:m?"sticky":void 0,left:m?I?48:0:void 0,zIndex:m?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?(I?48:0)+(h&&m?48:0):void 0},children:t.jsx(qt,{id:"ogx-select-all",name:"ogx-select-all",checked:s,indeterminate:d,onChange:T=>a?.(T.target.checked),"aria-label":s?"Deselect all rows":"Select all rows",tabIndex:k?.id==="HEADER"&&k.field==="__checkbox_col__"?0:-1,onMouseDown:T=>T.preventDefault(),inputRef:T=>{Y.current.__checkbox_col__=T}})}),o.map((T,se)=>{if(T.isSpacer)return t.jsx("div",{style:{width:T.width,minWidth:T.width,flexShrink:0},"aria-hidden":"true"},T.field);const ne=T.sortable!==!1,xe=g.some(We=>We.field===T.field),Qe=T.resizable!==!1,z=dn(T.field,u),Se=z!==null,je=E===T.field,ct=C===T.field,Be=["ogx__header-cell",`ogx__header-cell--align-${T.headerAlign||T.align||"left"}`,ne&&"ogx__header-cell--sortable",xe&&"ogx__header-cell--sorted",Se&&"ogx__header-cell--pinned",Se&&`ogx__header-cell--pinned-${z}`,je&&"ogx__header-cell--dragging",ct&&"ogx__header-cell--drag-over",k?.id==="HEADER"&&k.field===T.field&&"ogx__header-cell--focused",T.headerClassName].filter(Boolean).join(" "),ut=b[T.field]??T.width??100,gt={width:ut,minWidth:T.minWidth,maxWidth:T.maxWidth,flexGrow:T.flex??0,flexShrink:0,flexBasis:(T.flex,"auto"),boxSizing:"border-box",position:Se?"sticky":"relative",zIndex:T.zIndex,opacity:je?.5:1};if(Se&&z){const We=he[T.field];z==="left"?gt.left=We:gt.right=We}const en=T.renderHeader?T.renderHeader({field:T.field,colDef:T,colIndex:se}):T.headerName||T.field,Lt=We=>{if(We.target.closest(".ogx-column-resize-handle")){We.stopPropagation();return}x?.(T.field),ne&&Z(T)()},St=_?_(T.field):void 0,Rt=j?j(T.field):void 0,vt=P?P(T.field):void 0;return t.jsxs("div",{className:Be,style:gt,onClick:Lt,role:"columnheader",draggable:!!_,onDragStart:St,onDragOver:Rt,onDragEnd:y,onDrop:vt,"aria-sort":ne?xe?g.find(We=>We.field===T.field)?.sort==="asc"?"ascending":"descending":"none":void 0,"aria-colindex":se+1+(i?1:0),"data-field":T.field,tabIndex:-1,ref:We=>{Y.current[T.field]=We},children:[t.jsxs("div",{className:"ogx__header-cell-content",children:[je&&t.jsx("div",{className:"ogx__header-drag-icon",children:t.jsx(Qo,{})}),t.jsxs("div",{className:"ogx__header-cell-title-wrapper",children:[t.jsx("span",{className:"ogx__header-cell-title",children:en}),M&&M[T.field]&&t.jsx("span",{className:"ogx__header-cell-aggregation",children:M[T.field]})]}),ne&&J(T.field),!T.disableColumnMenu&&t.jsx("button",{className:"ogx__menu-icon-btn",onClick:q(T),"aria-label":`Open column menu for ${T.headerName||T.field}`,"aria-haspopup":"menu",tabIndex:-1,children:t.jsx(Jo,{})})]}),Qe&&p&&t.jsx(zo,{field:T.field,currentWidth:ut,onResize:p,minWidth:T.minWidth,maxWidth:T.maxWidth})]},T.field)}),$&&t.jsx(qo,{colDef:$.colDef,sortModel:g,onSort:f,onHide:S,onPin:R,pinnedColumns:u,onManageColumns:B,onClose:D,anchorEl:$.anchorEl})]})]})}function tr({value:n,onValueChange:o,onCommit:e,onCancel:r}){const[i,s]=l.useState(String(n??"")),d=l.useRef(null);return l.useEffect(()=>{d.current?.focus(),d.current?.select()},[]),t.jsx("input",{ref:d,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 nr({value:n,onValueChange:o,onCommit:e,onCancel:r}){const[i,s]=l.useState(n??""),d=l.useRef(null);return l.useEffect(()=>{d.current?.focus(),d.current?.select()},[]),t.jsx("input",{ref:d,type:"number",className:"ogx__edit-input ogx__edit-input--number",value:i,onChange:a=>{const f=a.target.value===""?"":Number(a.target.value);s(f),o(f===""?null:f)},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=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:d=>{d.key==="Escape"&&(d.stopPropagation(),r())}})})}function rr({value:n,colDef:o,onValueChange:e,onCommit:r,onCancel:i}){const s=l.useRef(null);l.useEffect(()=>{s.current?.focus()},[]);const d=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:d.map(a=>{const f=typeof a=="object"?a.value:a,g=typeof a=="object"?a.label:String(a);return t.jsx("option",{value:String(f),children:g},String(f))})})}function ir({value:n,onValueChange:o,onCommit:e,onCancel:r}){const[i,s]=l.useState(n??""),d=l.useRef(null);return l.useEffect(()=>{d.current?.focus()},[]),t.jsx("input",{ref:d,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 lr(n){const{colDef:o}=n;switch(o.type){case"number":return t.jsx("div",{className:"ogx__edit-cell",children:t.jsx(nr,{...n})});case"boolean":return t.jsx("div",{className:"ogx__edit-cell",children:t.jsx(or,{...n})});case"singleSelect":return t.jsx("div",{className:"ogx__edit-cell",children:t.jsx(rr,{...n})});case"date":return t.jsx("div",{className:"ogx__edit-cell",children:t.jsx(ir,{...n})});default:return t.jsx("div",{className:"ogx__edit-cell",children:t.jsx(tr,{...n})})}}function sr(n){const{onCellClick:o,onCellEditStart:e,onCellValueChange:r,value:i,row:s,colDef:d,rowIndex:a,colIndex:f,isSelected:g,onClick:p,width:b,pinnedPosition:u,pinnedOffset:h,isFocused:w,isFocusVisible:m,isEditable:I,isEditing:M,onEditStart:E,onEditStop:C,onValueChange:_,colSpanInfo:j,rowSpan:y,isHiddenByRowSpan:P}=n;if(j?.spannedByColSpan)return null;if(P)return t.jsx("div",{className:"ogx__cell ogx__cell--hidden",style:{width:b??d.width??100},role:"presentation","data-field":d.field,"data-colindex":f});const k=v=>{o&&(v.stopPropagation(),o({row:s,field:d.field,value:i,colDef:d,rowIndex:a,colIndex:f})),p?.(v)},x=l.useCallback(v=>{r?r(d.field,v):_?.(v)},[r,_,d.field]),S=v=>{I&&(E||e)&&(v.stopPropagation(),e?e(d.field,i):E?.())},R=l.useMemo(()=>d.valueFormatter?d.valueFormatter({value:i,row:s,field:d.field}):i==null?"":String(i),[i,s,d]),B=l.useMemo(()=>M&&(r||_)&&C?d.renderEditCell?d.renderEditCell({value:i,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:f}):t.jsx(lr,{value:i,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:f,onValueChange:x,onCommit:()=>C(),onCancel:()=>C(!0)}):d.renderCell?d.renderCell({value:i,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:f}):R,[i,s,d,a,f,R,M,x,C,r,_]),Y=u!=null,$=l.useMemo(()=>d.cellClassName?typeof d.cellClassName=="function"?d.cellClassName({value:i,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:f})||"":d.cellClassName:"",[d,i,s,a,f]),K=["ogx__cell",`ogx__cell--align-${d.align||"left"}`,g&&"ogx__cell--selected",w&&"ogx__cell--focused",w&&m&&"ogx__cell--focus-visible",d.type&&`ogx__cell--type-${d.type}`,Y&&"ogx__cell--pinned",Y&&`ogx__cell--pinned-${u}`,M&&"ogx__cell--editing",y&&y>1&&"ogx__cell--spanned",$].filter(Boolean).join(" "),q=j?.cellProps?.colSpan||1,D=y||1,Z=j?.cellProps?.width??b??d.width??100,J={width:"var(--width)","--width":typeof Z=="number"?`${Z}px`:Z,flexGrow:d.flex??0,flexShrink:0,flexBasis:(d.flex,"auto"),boxSizing:"border-box",minWidth:d.minWidth,maxWidth:d.maxWidth,position:Y?"sticky":void 0,zIndex:d.zIndex??(Y?3:void 0),padding:M?0:void 0};D>1&&(J.height=`calc(var(--height) * ${D} - var(--border-width, 1px))`,J.zIndex=10,Y&&(J.zIndex=40)),Y&&h!==void 0&&(u==="left"?J.left=h:J.right=h);const he=l.useRef(null);return l.useLayoutEffect(()=>{w&&he.current&&he.current.focus({preventScroll:!0})},[w]),t.jsx("div",{ref:he,className:K,style:J,onClick:k,onDoubleClick:S,role:"gridcell","aria-colindex":f+1,"aria-readonly":!I||void 0,tabIndex:-1,"data-field":d.field,"data-colindex":f,...q>1?{"aria-colspan":q}:{},...D>1?{"aria-rowspan":D}:{},children:t.jsx("div",{className:"ogx__cell-content",children:B})})}const no=l.memo(sr);function oo({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 ar=({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 dr(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:d,onCellClick:a,onSelectionChange:f,columnWidths:g={},pinnedColumns:p,pinnedRows:b,hasDetailPanel:u=!1,isDetailPanelExpanded:h=!1,onDetailPanelToggle:w,detailPanelContent:m,detailPanelHeight:I=200,pinCheckboxColumn:M=!0,pinExpandColumn:E=!0,rowReordering:C=!1,onDragStart:_,onDragOver:j,onDragEnd:y,onDrop:P,isDragging:k,isDragOver:x,editingCell:S,onEditStart:R,onEditStop:B,onEditCellValueChange:Y,focusedCellField:$,isFocusVisible:K,colspanMap:q,rowSpanningCaches:D,rowHeight:Z=52}=n,J=l.useRef(null),he=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:Z,minHeight:Z},children:Array.from({length:z}).map((Se,je)=>t.jsx("div",{className:"ogx__skeleton-cell",children:t.jsx("div",{className:"ogx__skeleton-bar"})},je))})}l.useLayoutEffect(()=>{$==="__expand_col__"&&J.current&&J.current.focus({preventScroll:!0}),$==="__checkbox_col__"&&he.current&&he.current.focus({preventScroll:!0})},[$]);const v=z=>{z.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell")||d?.({row:o,id:o.id,rowIndex:r})},H=z=>{z.stopPropagation(),f?.(o.id,z.target.checked)},F=z=>{z.stopPropagation(),w?.(o.id)},A=l.useMemo(()=>Zn(e,g,p,s,M,u,E,C),[e,g,p,s,M,u,E,C]),O=Sn(o.id,b),Q=O==="top",U=O==="bottom",T=o._hasChildren===!0,se=l.useCallback((z,Se)=>{T||R?.({id:o.id,field:z,value:Se})},[T,o.id,R]),ne=l.useCallback((z,Se)=>{Y?.({id:o.id,field:z,value:Se})},[Y,o.id]),xe=l.useCallback(z=>{B?.({cancel:z})},[B]),Qe=["ogx__row",i&&"ogx__row--selected",r%2===0&&"ogx__row--even",r%2===1&&"ogx__row--odd",Q&&"ogx__row--pinned-top",U&&"ogx__row--pinned-bottom",k&&"ogx__row--dragging",x&&"ogx__row--drag-over",T&&"ogx__row--group"].filter(Boolean).join(" ");return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:Qe,onClick:v,role:"row","aria-rowindex":r+1,"aria-selected":i,"data-rowindex":r,onDragOver:j?j(o.id):void 0,onDrop:P?P(o.id):void 0,style:{maxHeight:`${Z}px`,minHeight:`${Z}px`,"--height":`${Z}px`,"--border-width":"1px"},children:[C&&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:_?_(o.id):void 0,onDragEnd:y,onClick:z=>z.stopPropagation(),children:t.jsx(ar,{})}),u&&t.jsx("div",{className:`ogx__cell ogx__cell--expand ${E?"ogx__cell--pinned-left":""} ${$==="__expand_col__"?"ogx__cell--focused":""} ${$==="__expand_col__"&&K?"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?C?48:0:void 0,zIndex:E?5:void 0},ref:J,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(oo,{isExpanded:h,onClick:F,variant:"plus-minus"})}),s&&t.jsx("div",{className:`ogx__cell ogx__cell--checkbox ${M?"ogx__cell--pinned-left":""} ${$==="__checkbox_col__"?"ogx__cell--focused":""} ${$==="__checkbox_col__"&&K?"ogx__cell--focus-visible":""}`,role:"gridcell",style:{position:M?"sticky":void 0,left:M?(C?48:0)+(u&&E?48:0):void 0,zIndex:M?11:void 0},ref:he,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:H,onClick:z=>z.stopPropagation(),"aria-label":i?`Deselect row ${o.id}`:`Select row ${o.id}`,tabIndex:-1,onMouseDown:z=>z.preventDefault()})}),e.map((z,Se)=>{if(z.isSpacer)return t.jsx("div",{style:{width:z.width,minWidth:z.width,flexShrink:0},"aria-hidden":"true"},z.field);const je=z.valueGetter?z.valueGetter({row:o,field:z.field,value:o[z.field]}):o[z.field],ct=g[z.field]??z.width,Be=dn(z.field,p),ut=Be?A[z.field]:void 0,gt=S?.id===o.id&&S?.field===z.field,en=gt?S?.value:je,Lt=q?.get(o.id)?.[z.field],St=D?.spannedCells[o.id]?.[z.field],Rt=D?.hiddenCells[o.id]?.[z.field]||!1;return t.jsx(no,{value:en,row:o,colDef:z,rowIndex:r,colIndex:Se,isSelected:i,onCellClick:a,width:ct,pinnedPosition:Be,pinnedOffset:ut,isFocused:$===z.field,isFocusVisible:K,isEditable:z.editable,isEditing:gt,onCellEditStart:se,onEditStop:xe,onCellValueChange:ne,colSpanInfo:Lt,rowSpan:St,isHiddenByRowSpan:Rt},z.field)})]}),u&&t.jsx(dr,{row:o,rowId:o.id,rowIndex:r,content:m,height:I,isExpanded:h})]})}const cr=({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,d)=>{const a=s.width||150,f=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:f,height:16,borderRadius:4}})},s.field||d)})]}),Qt=({variant:n="text",size:o="medium",color:e="default",disabled:r=!1,className:i="",children:s,...d})=>{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,...d,children:s})};function ro(n){const{page:o,pageSize:e,rowCount:r,onPageChange:i,onPageSizeChange:s,pageSizeOptions:d=[10,25,50,100],showFirstButton:a=!0,showLastButton:f=!0}=n,g=Math.max(1,Math.ceil(r/e)),p=Math.min(o,g-1),b=p*e,u=Math.min(b+e,r),h=r===0?0:`${b+1}–${u}`,w=()=>{i(0)},m=()=>{i(Math.max(0,p-1))},I=()=>{i(Math.min(g-1,p+1))},M=()=>{i(g-1)},E=j=>{const y=parseInt(j.target.value,10);s(y)},C=p===0,_=p>=g-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:d.map(j=>t.jsx("option",{value:j,children:j},j))})]}),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:C,"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:m,disabled:C,"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 ",g]}),t.jsx(Qt,{variant:"text",size:"small",onClick:I,disabled:_,"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"})})}),f&&t.jsx(Qt,{variant:"text",size:"small",onClick:M,disabled:_,"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 ur(n,o,e={}){const r=new Map,i=[];n.forEach(a=>{const f=a.id;r.set(f,a),i.push(f)});const s=new Map,d=[];return o.forEach(a=>{s.set(a.field,a),d.push(a.field)}),{rows:{idRowsLookup:r,allRows:i},columns:{all:o,lookup:s,orderedFields:d,columnVisibilityModel:e},sorting:{sortModel:[]},filter:{filterModel:{items:[]}},pagination:{paginationModel:{page:0,pageSize:100},rowCount:n.length},selection:{selectedRows:new Set},pinning:{pinnedColumns:{},pinnedRows:{}},virtualization:{renderContext:{firstRowIndex:0,lastRowIndex:0,firstColumnIndex:0,lastColumnIndex:0},scrollTop:0,scrollLeft:0},dimensions:{rowHeight:52,headerHeight:56,viewportWidth:0,viewportHeight:0},dataSource:{loading:!1,error:null}}}function gr(n,o){switch(o.type){case"SET_ROWS":{const e=Array.from(n.rows.idRowsLookup.values()),r=typeof o.payload=="function"?o.payload(e):o.payload,i=new Map,s=[];return r.forEach(d=>{i.set(d.id,d),s.push(d.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 fr(n){const{rows:o,columns:e,rowHeight:r=52,headerHeight:i=56,columnVisibilityModel:s,initialState:d}=n,a=l.useMemo(()=>ur(o,e,s),[]),[f,g]=l.useReducer(gr,{...a,sorting:d?.sorting||a.sorting,filter:d?.filter||a.filter,dataSource:d?.dataSource?{...a.dataSource,...d.dataSource}:a.dataSource,pagination:{...a.pagination,...d?.pagination||{},rowCount:n.rowCount??d?.pagination?.rowCount??a.pagination.rowCount},dimensions:{...a.dimensions,rowHeight:r,headerHeight:i}}),p=l.useRef(f);p.current=f;const b=l.useRef(o);l.useEffect(()=>{o!==b.current&&(b.current=o,g({type:"SET_ROWS",payload:o}))},[o]);const u=l.useCallback((k,x)=>{g({type:"SET_ROWS",payload:k,preserveRowCount:x})},[]),h=l.useCallback(k=>{g({type:"SET_COLUMNS",payload:k})},[]),w=l.useCallback(k=>{g({type:"SET_SORT_MODEL",payload:k})},[]),m=l.useCallback(k=>{g({type:"SET_FILTER_MODEL",payload:k})},[]),I=l.useCallback(k=>{g({type:"SET_PAGINATION_MODEL",payload:k})},[]),M=l.useCallback(k=>{g({type:"SET_SELECTION",payload:k})},[]),E=l.useCallback((k,x)=>{g({type:"SET_SCROLL",payload:{scrollTop:k,scrollLeft:x}})},[]),C=l.useCallback((k,x)=>{g({type:"SET_DIMENSIONS",payload:{viewportWidth:k,viewportHeight:x}})},[]),_=l.useCallback(k=>{g({type:"SET_DATASOURCE_LOADING",payload:k})},[]),j=l.useCallback(k=>{g({type:"SET_DATASOURCE_ERROR",payload:k})},[]),y=l.useCallback(k=>{g({type:"SET_ROW_COUNT",payload:k})},[]),P=l.useRef({getRow:k=>p.current.rows.idRowsLookup.get(k)||null,getAllRows:()=>Array.from(p.current.rows.idRowsLookup.values()),getVisibleRows:()=>Array.from(p.current.rows.idRowsLookup.values()),getAggregationResult:()=>null,getAggregationModel:()=>null,getColumn:k=>p.current.columns.lookup.get(k)||null,getAllColumns:()=>p.current.columns.all,getVisibleColumns:()=>p.current.columns.all,selectRow:(k,x=!0)=>{const S=new Set(p.current.selection.selectedRows);x?S.add(k):S.delete(k),M(S)},selectRows:(k,x=!0)=>{const S=new Set(p.current.selection.selectedRows);k.forEach(R=>{x?S.add(R):S.delete(R)}),M(S)},getSelectedRows:()=>Array.from(p.current.selection.selectedRows),sortColumn:(k,x)=>{if(x===null)w(p.current.sorting.sortModel.filter(S=>S.field!==k));else{const S=p.current.sorting.sortModel.findIndex(R=>R.field===k);if(S>=0){const R=[...p.current.sorting.sortModel];R[S]={field:k,sort:x},w(R)}else w([...p.current.sorting.sortModel,{field:k,sort:x}])}},getSortModel:()=>p.current.sorting.sortModel,setFilterModel:m,getFilterModel:()=>p.current.filter.filterModel,setPage:k=>{I({...p.current.pagination.paginationModel,page:k})},setPageSize:k=>{I({...p.current.pagination.paginationModel,pageSize:k,page:0})},scrollToIndexes:()=>{},copySelectedRows:()=>Promise.resolve()});return{state:f,dispatch:g,apiRef:P,setRows:u,setColumns:h,setSortModel:w,setFilterModel:m,setPaginationModel:I,setSelection:M,setScroll:E,setDimensions:C,setDataSourceLoading:_,setDataSourceError:j,setRowCount:y}}function hr(n){const{columns:o,onColumnOrderChange:e,disableColumnReorder:r=!1}=n,[i,s]=l.useState(null),[d,a]=l.useState(null),f=l.useRef(-1),g=l.useCallback(h=>w=>{if(r)return;const m=o.findIndex(M=>M.field===h);if(o[m]?.pinnable===!1){w.preventDefault();return}s(h),f.current=m,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]),b=l.useCallback(h=>w=>{if(w.preventDefault(),r||!i||i===h){s(null),a(null);return}const m=o.findIndex(E=>E.field===i),I=o.findIndex(E=>E.field===h);if(m===-1||I===-1){s(null),a(null);return}const M=o[m];e&&e({column:M,oldIndex:m,targetIndex:I}),s(null),a(null),f.current=-1},[o,i,r,e]),u=l.useCallback(()=>{s(null),a(null),f.current=-1},[]);return{draggedColumn:i,dragOverColumn:d,onDragStart:r?void 0:g,onDragOver:r?void 0:p,onDragEnd:r?void 0:u,onDrop:r?void 0:b}}function pr(n){const{onRowOrderChange:o,rows:e,getRowId:r,rowReordering:i=!1}=n,[s,d]=l.useState(null),[a,f]=l.useState(null),g=l.useCallback(w=>r?r(w):w.id,[r]),p=l.useCallback(w=>m=>{i&&(d(w),m.dataTransfer.effectAllowed="move")},[i]),b=l.useCallback(w=>m=>{!i||!s||(m.preventDefault(),m.dataTransfer.dropEffect="move",a!==w&&f(w))},[i,s,a]),u=l.useCallback(()=>{d(null),f(null)},[]),h=l.useCallback(w=>m=>{if(m.preventDefault(),!s||!o){u();return}const I=e.findIndex(E=>g(E)===s),M=e.findIndex(E=>g(E)===w);I!==-1&&M!==-1&&I!==M&&o({row:e[I],oldIndex:I,targetIndex:M}),u()},[s,o,e,g,u]);return{draggedRowId:s,dragOverRowId:a,onDragStart:i?p:void 0,onDragOver:i?b:void 0,onDragEnd:i?u:void 0,onDrop:i?h:void 0}}const xr={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 mr(n,o){const{field:e,operator:r,value:i}=o,s=n[e],d=xr[r];return d?d(s,i):(console.warn(`Unknown filter operator: ${r}`),!0)}function br(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 jn(n,o){const e=o.items||[],r=o.logicOperator||"and",i=o.quickFilterValues||[];if(i.length>0&&!br(n,i))return!1;if(e.length===0)return!0;const s=d=>{if("logicOperator"in d&&"items"in d){const a=d,f=a.items;return f.length===0?!0:a.logicOperator==="and"?f.every(s):f.some(s)}else return mr(n,d)};return r==="and"?e.every(s):e.some(s)}function wr(n,o){if(!o)return n;const{items:e=[],quickFilterValues:r=[]}=o;return e.length===0&&(!r||r.length===0)?n:n.filter(i=>jn(i,o))}function vr(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 En(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 _r(n,o){if(o.length===0)return n;const e=[...n];return e.sort((r,i)=>{for(const s of o){const d=r[s.field],a=i[s.field],f=En(d,a,s.sort);if(f!==0)return f}return 0}),e}function Cr(n){const{rows:o,getRowId:e,getTreeDataPath:r,treeData:i=!1,defaultGroupingExpansionDepth:s=0,filterModel:d,sortModel:a,onRowExpansionChange:f}=n,{treeNodes:g,rootIds:p,groupingRows:b}=l.useMemo(()=>{if(!i||!r)return{treeNodes:new Map,rootIds:[],groupingRows:[]};const _=new Map,j=[],y=[],P=new Map,k=x=>x.join("/");return o.forEach(x=>{const S=e(x),R=r(x),B=k(R);P.set(B,S),_.set(S,{id:S,parentId:null,depth:R.length-1,groupingKey:R[R.length-1],isExpanded:!1,children:[],serverChildrenCount:x.serverChildrenCount})}),o.forEach(x=>{const S=e(x),R=r(x);if(R.length===1){j.push(S);return}const B=$=>{if($.length<=1)return;const K=$.slice(0,-1),q=k(K);let D=P.get(q);if(D===void 0&&(D=`auto-group-${q}`,!_.has(D))){const Z=K[K.length-1];_.set(D,{id:D,parentId:null,depth:K.length-1,groupingKey:Z,isExpanded:!1,children:[],label:Z}),P.set(q,D);const J={id:D,name:Z,_isGroupRow:!0};y.push(J),K.length===1&&j.push(D),B(K)}return D},Y=B(R);if(Y!==void 0){const $=_.get(Y),K=_.get(S);$&&K&&(K.parentId=Y,$.children=$.children||[],$.children.includes(S)||$.children.push(S))}}),y.forEach(x=>{const S=x.id,R=_.get(S);if(!R)return;const Y=S.replace("auto-group-","").split("/");if(Y.length>1){const $=Y.slice(0,-1),K=k($),q=P.get(K);if(q&&_.has(q)){R.parentId=q;const D=_.get(q);D&&(D.children=D.children||[],D.children.includes(S)||D.children.push(S))}}}),{treeNodes:_,rootIds:j,groupingRows:y}},[o,r,i,e]),u=l.useMemo(()=>{if(!i)return new Set;const _=new Set;return g.forEach(j=>{j.children&&j.children.length>0&&(s===-1||j.depth<s)&&_.add(j.id)}),_},[g,i,s]),[h,w]=l.useState(new Set);l.useEffect(()=>{u.size>0&&w(u)},[u]);const m=l.useCallback(_=>{w(j=>{const y=new Set(j),P=!y.has(_);if(y.has(_)?y.delete(_):y.add(_),P&&f){const k=g.get(_);k&&f(k)}return y})},[g,f]),I=l.useCallback(()=>{if(!i)return null;const _=new Map;o.forEach(B=>_.set(e(B),B)),b.forEach(B=>_.set(B.id,B));const j=B=>jn(B,d),y=new Map,P=B=>{if(y.has(B))return y.get(B);const Y=_.get(B);if(!Y)return!1;if(j(Y))return y.set(B,!0),!0;const K=g.get(B);return K&&K.children&&K.children.some(D=>P(D))?(y.set(B,!0),!0):(y.set(B,!1),!1)},k=(B,Y)=>{if(!a||a.length===0)return 0;const $=_.get(B),K=_.get(Y);if(!$||!K)return 0;for(const q of a){const D=$[q.field],Z=K[q.field],J=En(D,Z,q.sort);if(J!==0)return J}return 0},x=[],S=new Set,R=B=>{const Y=B.filter($=>P($));Y.sort(k),Y.forEach($=>{if(S.has($))return;const K=_.get($),q=g.get($);if(K&&q){S.add($);const D={...K,_treeDepth:q.depth,_isExpanded:h.has($),_hasChildren:q.children&&q.children.length>0||q.serverChildrenCount&&q.serverChildrenCount>0,_descendantCount:q.children?q.children.length:0};x.push(D),h.has($)&&q.children&&q.children.length>0&&R(q.children)}})};return R(p),x},[i,o,b,p,g,h,d,a,e]),M=l.useCallback(_=>h.has(_),[h]),E=l.useCallback(_=>g.get(_),[g]),C=l.useCallback(_=>{const j=[];let y=_;for(;y!==null;){const P=g.get(y);if(!P)break;j.unshift(P.groupingKey),y=P.parentId}return j},[g]);return l.useMemo(()=>({treeNodes:g,groupingRows:b,toggleExpansion:m,isGroupExpanded:M,getVisibleRows:I,getNode:E,getNodePath:C}),[g,b,m,M,I,E,C])}const yr=n=>n?.depth===-1?"footer":"inline";function kr(n){const{rows:o,getRowId:e,rowGroupingModel:r=[],aggregationModel:i={},defaultGroupingExpansionDepth:s=0,filterModel:d,sortModel:a,getAggregationPosition:f=yr}=n,[g,p]=l.useState(new Set),{treeNodes:b,rootIds:u,groupingRows:h}=l.useMemo(()=>{const E=new Map,C=new Map,_=[];if(r.length===0)return{treeNodes:E,rootIds:_,groupingRows:C};const j=(k,x,S)=>`auto-group-${k}-${x}-${S||"root"}`,y=(k,x,S)=>{if(x>=r.length)return k.map($=>{const K=e($);return E.set(K,{id:K,parentId:S,depth:x,groupingKey:"",isExpanded:!1}),K});const R=r[x],B=new Map;k.forEach($=>{const K=$[R],q=String(K);B.has(q)||B.set(q,[]),B.get(q).push($)});const Y=[];return B.forEach(($,K)=>{const D=$[0][R],Z=j(R,K,S);Y.push(Z);const J={};i&&Object.entries(i).forEach(([A,O])=>{const Q=$.map(U=>U[A]);if(O==="sum")J[A]=Q.reduce((U,T)=>(Number(U)||0)+(Number(T)||0),0);else if(O==="min")J[A]=Math.min(...Q.map(U=>Number(U)||0));else if(O==="max")J[A]=Math.max(...Q.map(U=>Number(U)||0));else if(O==="avg"){const U=Q.reduce((T,se)=>(Number(T)||0)+(Number(se)||0),0);J[A]=Q.length?U/Q.length:0}else O==="count"&&(J[A]=Q.length)});const he={[R]:D,...J,id:Z};C.set(Z,he);const v={id:Z,parentId:S,depth:x,groupingKey:K,groupingField:R,groupingValue:D,aggregatedValues:J,isExpanded:!1,children:[],label:`${R}: ${String(D)}`};v.aggregationPosition=f(v),E.set(Z,v);const H=y($,x+1,Z);E.get(Z).children=H;const F=$.length;E.get(Z).descendantCount=F}),Y},P=y(o,0,null);return _.push(...P),{treeNodes:E,rootIds:_,groupingRows:C}},[o,r,i,e,f]);l.useEffect(()=>{if(s===-1){const E=new Set;b.forEach((C,_)=>{C.children&&C.children.length>0&&E.add(_)}),p(E)}else if(s>0){const E=new Set;b.forEach((C,_)=>{C.depth<s&&C.children&&C.children.length>0&&E.add(_)}),p(E)}else p(new Set)},[r,s]);const w=l.useCallback(E=>{p(C=>{const _=new Set(C);return _.has(E)?_.delete(E):_.add(E),_})},[]),m=l.useCallback(E=>g.has(E),[g]),I=l.useCallback(()=>{if(r.length===0)return null;const E=[],C=new Set,_=new Map;o.forEach(k=>_.set(e(k),k));const j=k=>{const x=b.get(k);if(!x)return!1;if(!x.children||x.children.length===0){const S=_.get(k);return!(!S||d&&!jn(S,d))}return x.children.some(S=>j(S))},y=k=>{let x=k;d&&(x=k.filter(j)),a&&a.length>0&&x.sort((S,R)=>{const B=h.get(S)||_.get(S),Y=h.get(R)||_.get(R);if(!B||!Y)return 0;for(const $ of a){const K=B[$.field],q=Y[$.field],D=En(K,q,$.sort);if(D!==0)return D}return 0}),x.forEach(S=>{if(C.has(S))return;const R=b.get(S),B=R?.children&&R.children.length>0,Y=B?h.get(S):_.get(S);if(Y&&R){C.add(S);const $={...Y,_treeDepth:R.depth,_isExpanded:g.has(S),_hasChildren:B,_groupingField:R.groupingField,_groupingValue:R.groupingValue,_descendantCount:R.descendantCount};E.push($),P.has(S)&&B&&y(R.children)}})},P=g;return y(u),E},[o,e,b,u,h,d,a,g]),M=l.useCallback(E=>b.get(E),[b]);return l.useMemo(()=>({treeNodes:b,groupingRows:h,toggleExpansion:w,isGroupExpanded:m,getVisibleRows:I,getNode:M}),[b,h,w,m,I,M])}function Sr(n){const{rows:o,getRowId:e,processRowUpdate:r,onProcessRowUpdateError:i,onRowChange:s}=n,[d,a]=l.useState(null),f=l.useRef(null),g=l.useCallback(h=>{a(h),f.current=typeof h=="function"?h(f.current):h},[]),p=l.useCallback(h=>{g({id:h.id,field:h.field,value:h.value,originalValue:h.value})},[]),b=l.useCallback(async h=>{const w=f.current;if(!w)return;if(h?.cancel){g(null);return}const{id:m,field:I,value:M,originalValue:E}=w;if(M===E){g(null);return}const C=o.find(j=>e(j)===m);if(!C){g(null);return}const _={...C,[I]:M};try{if(r){const j=await r(_,C);s?.(j)}else s?.(_);g(null)}catch(j){i&&i(j)}},[d,o,e,r,s,i]),u=l.useCallback(h=>{d&&d.id===h.id&&d.field===h.field&&g(w=>w?{...w,value:h.value}:null)},[d]);return{editingCell:d,startCellEdit:p,stopCellEdit:b,setEditCellValue:u}}function jr(n,o,e){const[r,i]=l.useState(new Map),[s,d]=l.useState({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}}),a=l.useCallback(()=>{i(new Map)},[]),f=l.useCallback((m,I)=>r.get(m)?.[I],[r]),g=l.useCallback((m,I,M,E,C)=>{const _=new Map(r);for(let j=E;j<C;j++){const y=o[j];if(!y)continue;let P=1;if(y.colSpan)if(typeof y.colSpan=="function"){const x={row:I,value:I[y.field],field:y.field,colDef:y,rowIndex:M,colIndex:j};P=y.colSpan(x)}else P=y.colSpan;if(P<=1){Pt(_,m,y.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:e[y.field]||100}});continue}let k=e[y.field]||100;for(let x=1;x<P;x++)if(j+x<C){const S=o[j+x];S&&(k+=e[S.field]||100,Pt(_,m,S.field,{spannedByColSpan:!0,leftVisibleCellIndex:j,rightVisibleCellIndex:Math.min(j+P-1,o.length-1)}))}Pt(_,m,y.field,{spannedByColSpan:!1,cellProps:{colSpan:P,width:k}}),j+=P-1}i(_)},[r,o,e]),p=l.useCallback((m,I)=>{const M={},E={},C={};o.forEach((_,j)=>{if(_.rowSpan)for(let y=m;y<I;y++){const P=n[y];if(!P||E[P.id]?.[_.field])continue;const k=_.valueGetter?_.valueGetter({row:P,field:_.field,value:P[_.field]}):P[_.field];let x=1;if(typeof _.rowSpan=="function"){const S={row:P,value:k,field:_.field,colDef:_,rowIndex:y,colIndex:j};x=_.rowSpan(S)}else typeof _.rowSpan=="number"&&(x=_.rowSpan);if(x>1){M[P.id]||(M[P.id]={}),M[P.id][_.field]=x;for(let S=1;S<x;S++){const R=y+S;if(R<I&&n[R]){const B=n[R];E[B.id]||(E[B.id]={}),E[B.id][_.field]=!0,C[R]||(C[R]={}),C[R][_.field]=y}}}}}),d({caches:{spannedCells:M,hiddenCells:E,hiddenCellOriginMap:C},processedRange:{firstRowIndex:m,lastRowIndex:I}})},[n,o]),b=l.useCallback(()=>{d({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}})},[]);l.useEffect(()=>{const m=new Map;n.forEach((C,_)=>{for(let j=0;j<o.length;j++){const y=o[j];if(!y)continue;let P=1;if(y.colSpan)if(typeof y.colSpan=="function"){const x={row:C,value:C[y.field],field:y.field,colDef:y,rowIndex:_,colIndex:j};P=y.colSpan(x)}else P=y.colSpan;if(P<=1){const x=e[y.field]||(typeof y.width=="number"?y.width:100);Pt(m,C.id,y.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:x}});continue}let k=e[y.field]||(typeof y.width=="number"?y.width:100);for(let x=1;x<P;x++)if(j+x<o.length){const S=o[j+x];if(S){const R=e[S.field]||(typeof S.width=="number"?S.width:100);k+=R,Pt(m,C.id,S.field,{spannedByColSpan:!0,leftVisibleCellIndex:j,rightVisibleCellIndex:Math.min(j+P-1,o.length-1)})}}Pt(m,C.id,y.field,{spannedByColSpan:!1,cellProps:{colSpan:P,width:k}}),j+=P-1}}),i(m);const I={},M={},E={};o.forEach((C,_)=>{if(C.rowSpan)for(let j=0;j<n.length;j++){const y=n[j];if(!y||M[y.id]?.[C.field])continue;const P=C.valueGetter?C.valueGetter({row:y,field:C.field,value:y[C.field]}):y[C.field];let k=1;if(typeof C.rowSpan=="function"){const x={row:y,value:P,field:C.field,colDef:C,rowIndex:j,colIndex:_};k=C.rowSpan(x)}else typeof C.rowSpan=="number"&&(k=C.rowSpan);if(k>1){I[y.id]||(I[y.id]={}),I[y.id][C.field]=k;for(let x=1;x<k;x++){const S=j+x;if(S<n.length&&n[S]){const R=n[S];M[R.id]||(M[R.id]={}),M[R.id][C.field]=!0,E[S]||(E[S]={}),E[S][C.field]=j}}}}}),d({caches:{spannedCells:I,hiddenCells:M,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:f,calculateColSpan:g,rowSpanningState:s,calculateRowSpan:p,resetRowSpan:b,getSpannedCells:u,getHiddenCells:h,getHiddenCellOriginMap:w}}function Pt(n,o,e,r){let i=n.get(o);i||(i={},n.set(o,i)),i[e]=r}function Er(n){const{dataSource:o,sortModel:e,filterModel:r,paginationModel:i,paginationMode:s,sortingMode:d,filterMode:a,aggregationModel:f,setRows:g,setRowCount:p,setDataSourceLoading:b,setDataSourceError:u,onAggregationResults:h}=n,w=l.useRef(null),m=l.useRef(0),I=l.useCallback(async()=>{if(!o)return;const E=++m.current;b(!0),u(null);const C=i.page*i.pageSize,_=C+i.pageSize,j={startRow:C,endRow:_,sortModel:e,filterModel:r,groupKeys:[],aggregationModel:f};try{const y=await o.getRows(j);if(E!==m.current)return;let P=!1;if(s==="infinite"){const k=w.current;if(k){const x=JSON.stringify(k.sortModel)!==JSON.stringify(e),S=JSON.stringify(k.filterModel)!==JSON.stringify(r),R=k.pageSize!==i.pageSize;!x&&!S&&!R&&i.page>k.page&&(P=!0)}}g(P?k=>[...k,...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===m.current&&(u(y),console.error("Data Source Error:",y))}finally{E===m.current&&b(!1)}},[o,i.page,i.pageSize,e,r,s,f,h,g,p,b,u]);l.useEffect(()=>{if(o&&(s==="server"||s==="infinite"||d==="server"||a==="server")){const C=setTimeout(()=>{I()},300);return()=>clearTimeout(C)}},[I,o,s,d,a]);const M=l.useCallback(async(E,C)=>{if(o){b(!0);try{const _=await o.getRows({startRow:0,endRow:-1,sortModel:e,filterModel:r,groupKeys:C});_.rows.length>0&&g(j=>{const y=new Set(j.map(k=>k.id)),P=_.rows.filter(k=>!y.has(k.id));return[...j,...P]})}catch(_){u(_),console.error("Failed to fetch children:",_)}finally{b(!1)}}},[o,e,r,g,b,u]);return{fetchRows:I,fetchChildren:M}}const Nr={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 io(n){const{rows:o,aggregationModel:e,isServerSide:r,dataSource:i,filterModel:s,sortModel:d,serverAggregationResults:a}=n,f=l.useMemo(()=>{if(r||Object.keys(e).length===0)return{};const E={};for(const[C,_]of Object.entries(e)){const j=Nr[_];if(!j){console.warn(`[useAggregation] Unknown aggregation function: "${_}"`);continue}const y=o.map(P=>P[C]);E[C]=j(y)}return E},[o,e,r]),[g,p]=l.useState({}),[b,u]=l.useState(!1),[h,w]=l.useState(null),m=l.useRef(0),I=l.useCallback(async()=>{if(!i?.getAggregations||Object.keys(e).length===0)return;const E=++m.current;u(!0),w(null);try{const C=await i.getAggregations({sortModel:d??[],filterModel:s??{items:[]},groupKeys:[],aggregationModel:e});E===m.current&&p(C)}catch(C){E===m.current&&(w(C),console.error("[useAggregation] Server aggregation error:",C))}finally{E===m.current&&u(!1)}},[i,e,s,d]);return l.useEffect(()=>{r&&i?.getAggregations&&!a&&I()},[I,r,i,a]),{aggregationResult:l.useMemo(()=>r?a&&Object.keys(a).length>0?a:g:f,[r,f,a,g]),isLoading:b,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 Nn(n,o){return o.map(e=>String(n[e]??"")).join("\0")}function lo(n,o,e,r){return l.useMemo(()=>{const i={pivotRows:[],pivotColumns:[],colKeys:[],isValid:!1};if(!r)return i;const{rowFields:s,columnFields:d,valueFields:a}=e;if(s.length===0||a.length===0)return i;const f=new Map(o.map(m=>[m.field,m])),g=new Set;for(const m of n)g.add(Nn(m,d));const p=Array.from(g).sort(),b=new Map;for(const m of n){const I=Nn(m,s);if(!b.has(I)){const _={};for(const j of s)_[j]=m[j];b.set(I,{labelValues:_,bucket:new Map})}const M=b.get(I),E=Nn(m,d);M.bucket.has(E)||M.bucket.set(E,new Map);const C=M.bucket.get(E);for(const _ of a){const j=Number(m[_.field]);C.has(_.field)||C.set(_.field,[]),isNaN(j)||C.get(_.field).push(j)}}let u=0;const h=[];for(const[,m]of b){const I={id:u++,...m.labelValues};for(const M of p){const E=m.bucket.get(M);for(const C of a){const _=d.length>0?`${M}${C.field}${C.aggFn}`:`${C.field}${C.aggFn}`,j=E?.get(C.field)??[];I[_]=j.length>0?Mr(j,C.aggFn):null}}h.push(I)}const w=[];for(const m of s){const I=f.get(m);w.push({field:m,headerName:I?.headerName??m,width:I?.width??140,sortable:!0})}for(const m of p){const I=d.length>0?m.split("\0").map((M,E)=>{const C=f.get(d[E]);return C?.headerName?`${C.headerName}: ${M}`:M}).join(" / "):"";for(const M of a){const E=f.get(M.field),C=d.length>0?`${m}${M.field}${M.aggFn}`:`${M.field}${M.aggFn}`,_=M.headerName??E?.headerName??M.field,j=I?`${I} — ${_} (${M.aggFn})`:`${_} (${M.aggFn})`;w.push({field:C,headerName:j,width:140,type:"number",align:"right",headerAlign:"right",sortable:!0,valueFormatter:({value:y})=>{if(y==null)return"—";const P=Number(y);return M.aggFn==="avg"?P.toFixed(2):M.aggFn==="count"?P.toLocaleString():E?.valueFormatter?E.valueFormatter({value:y,row:{},field:M.field}):P.toLocaleString()}})}}return{pivotRows:h,pivotColumns:w,colKeys:p,isValid:!0}},[n,o,e,r])}function Ir(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 Pr(n){let o=!1;try{o=Ir(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 Tr(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 f=e.filter(u=>!u.field.startsWith("__")),g=f.map(u=>u.headerName||u.field).join(" "),p=a.map(u=>f.map(h=>{const w=u[h.field];return h.valueFormatter?h.valueFormatter({value:w,row:u,field:h.field}):w??""}).join(" ")).join(`
|
|
7
|
-
`),
|
|
8
|
-
${p}`;try{await Pr(b)}catch(u){console.error("[OpenGridX] Failed to copy to clipboard:",u)}},[o,e,r,i]);return l.useEffect(()=>{const d=a=>{if(!(a.ctrlKey||a.metaKey)||a.key!=="c")return;const f=document.activeElement,g=f?.tagName.toLowerCase(),p=f?.type;g==="input"&&p!=="checkbox"&&p!=="radio"||g==="textarea"||g==="select"||f?.isContentEditable||s()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[s]),{copySelectedRows:s}}function Lr(){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 so(n){const{columns:o,visibleColumns:e,onVisibilityChange:r,onShowAll:i,onHideAll:s}=n,[d,a]=l.useState(""),g=l.useMemo(()=>o.filter(u=>u.hideable!==!1),[o]).every(u=>e.has(u.field)),p=l.useMemo(()=>{if(!d)return o;const u=d.toLowerCase();return o.filter(h=>(h.headerName||h.field).toLowerCase().includes(u))},[o,d]),b=u=>{u.target.checked?i():s()};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(Lr,{}),t.jsx("input",{id:"ogx-column-search",name:"ogx-column-search",autoComplete:"off",className:"ogx-column-visibility-panel__search-input",placeholder:"Search",value:d,onChange:u=>a(u.target.value)})]})}),t.jsx("div",{className:"ogx-column-visibility-panel__list",children:p.map(u=>{const h=e.has(u.field),w=u.hideable!==!1;return t.jsxs("label",{className:`ogx-column-visibility-panel__item ${w?"":"ogx-column-visibility-panel__item--disabled"}`,children:[t.jsx(qt,{checked:h,onChange:m=>r(u.field,m.target.checked),disabled:!w}),t.jsx("span",{className:"ogx-column-visibility-panel__label",children:u.headerName||u.field})]},u.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:g,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 Rr(n){const{rows:o,columns:e,getRowId:r,rowHeight:i=52,headerHeight:s=56,autoHeight:d=!1,checkboxSelection:a=!1,rowSelectionModel:f,onRowSelectionModelChange:g,onRowClick:p,onCellClick:b,filterModel:u,onFilterModelChange:h,sortModel:w,onSortModelChange:m,pagination:I=!1,paginationModel:M={page:0,pageSize:100},onPaginationModelChange:E,pageSizeOptions:C=[10,25,50,100],pinnedColumns:_,onPinnedColumnsChange:j,pinnedRows:y,getDetailPanelContent:P,getDetailPanelHeight:k,detailPanelExpandedRowIds:x,onDetailPanelExpandedRowIdsChange:S,pinCheckboxColumn:R=!0,pinExpandColumn:B=!0,disableColumnReorder:Y=!1,columnOrder:$,onColumnOrderChange:K,height:q,rowReordering:D=!1,onRowOrderChange:Z,loading:J=!1,treeData:he=!1,getTreeDataPath:v,defaultGroupingExpansionDepth:H,rowGroupingModel:F,aggregationModel:A,onAggregationModelChange:O,getAggregationPosition:Q,isCellEditable:U,processRowUpdate:T,onProcessRowUpdateError:se,dataSource:ne,sortingMode:xe="client",filterMode:Qe="client",paginationMode:z="client",rowCount:Se,slots:je,slotProps:ct,pivotMode:Be=!1,pivotModel:ut,onPivotModelChange:gt,className:en="",style:Lt,onRowsScrollEnd:St,ariaLabel:Rt,initialState:vt,onStateChange:We,columnVisibilityModel:po,onColumnVisibilityModelChange:xo,listView:cn=!1,listViewColumn:mo,columnGroupingModel:jt,noRowsLabel:In="No Data",apiRef:Pn}=n,vi=l.useMemo(()=>({items:[]}),[]),Ge=u||vi,[_i,Ci]=l.useState(()=>vt?.sorting?.sortModel??[]),Tn=w!==void 0,Ze=Tn?w:_i,yi=l.useMemo(()=>[],[]),Ln=F||yi,Rn=A!==void 0,bo=l.useMemo(()=>je?.toolbar,[je?.toolbar]),[ki,Si]=l.useState(()=>A??{}),et=Rn?A:ki,ji=l.useCallback(c=>{Rn||Si(c),O?.(c)},[Rn,O]),[Ei,Ni]=l.useState(()=>vt?.columns?.columnVisibilityModel??{}),Fn=po!==void 0,Ye=Fn?po:Ei,tn=l.useCallback(c=>{Fn||Ni(c),xo?.(c)},[Fn,xo]),[Mi,Ii]=l.useState(()=>vt?.columns?.pinnedColumns??{}),Wn=_!==void 0,tt=Wn?_:Mi,On=l.useCallback(c=>{Wn||Ii(c),j?.(c)},[Wn,j]),Pi=l.useMemo(()=>({rowFields:[],columnFields:[],valueFields:[]}),[]),[Ti,Li]=l.useState(ut??Pi),wo=ut??Ti,Ri=l.useCallback(c=>{Li(c),gt?.(c)},[gt]),un=lo(o,e,wo,Be),An=Be&&un.isValid?un.pivotRows:o,nt=Be&&un.isValid?un.pivotColumns:e,[Fi,vo]=l.useState(null);l.useEffect(()=>{vo(null)},[et]);const[Wi,Oi]=l.useState(()=>vt?.pagination?.paginationModel??M),zn=n.paginationModel!==void 0,ge=zn?M:Wi,gn=l.useCallback(c=>{zn||Oi(c),E?.(c)},[zn,E]),[Ai,_o]=l.useState([]),nn=f!==void 0,Co=nn?f:Ai,Ee=l.useMemo(()=>new Set(Co),[Co]),fn=g,Et=l.useRef(null),zi=l.useRef(null),hn=l.useRef(null),Bi=l.useCallback(c=>c.id,[]),pn=r||Bi,[Xe,Ft]=l.useState(null),Wt=l.useCallback(c=>{Yn.current?.classList.toggle("ogx--kb",c)},[]),yo=l.useRef(ne);yo.current=ne;const ko=l.useRef(null),So=l.useRef(null),$i=l.useCallback(c=>{if(yo.current&&he&&c.serverChildrenCount>0&&c.children.length===0){const N=So.current?.getNodePath(c.id)||[c.groupingKey];ko.current?.(c.id,N)}},[he]),ot=fr({rows:An,columns:nt,rowHeight:i,headerHeight:s,rowCount:Se,columnVisibilityModel:Ye,initialState:n.initialState}),{state:ae,apiRef:Ot,setRows:Bn,setColumns:jo,setScroll:Eo,setDimensions:No,setDataSourceLoading:Hi,setDataSourceError:Di,setRowCount:Gi}=ot;l.useEffect(()=>{Pn&&(Pn.current=Ot.current)},[Pn,Ot]);const{copySelectedRows:Mo}=Tr({selectedRowIds:Ee,columns:nt,getVisibleRows:()=>Ot.current.getVisibleRows(),getRowId:pn});l.useEffect(()=>{Ot.current.copySelectedRows=Mo,Ot.current.getSelectedRows=()=>Array.from(Ee)},[Mo,Ee,Ot]);const Vi=ae.dataSource.loading,on=J||Vi,rn=l.useMemo(()=>ae.rows.allRows.map(c=>ae.rows.idRowsLookup.get(c)),[ae.rows]),$n=Cr({rows:rn,getRowId:pn,getTreeDataPath:v,treeData:he,defaultGroupingExpansionDepth:H,filterModel:Ge,sortModel:Ze,onRowExpansionChange:$i});l.useEffect(()=>{So.current=$n},[$n]);const Ui=kr({rows:rn,getRowId:pn,rowGroupingModel:Ln,aggregationModel:et,defaultGroupingExpansionDepth:H,filterModel:Ge,sortModel:Ze,getAggregationPosition:Q}),Oe=Sr({rows:rn,getRowId:pn,processRowUpdate:T,onProcessRowUpdateError:se,onRowChange:c=>{const{dispatch:N}=ot,V=Array.from(ot.state.rows.idRowsLookup.values()).map(re=>re.id===c.id?c:re);N({type:"SET_ROWS",payload:V})}}),Hn=he,At=!!(Ln&&Ln.length>0),xn=Hn||At,Ae=Hn?$n:At?Ui:null,Ne=I&&!At,mn=l.useCallback(c=>{const{row:N,id:L}=c;if(xn&&N._hasChildren){Ae?.toggleExpansion(L);return}p?.(c)},[xn,Ae,p]),Le=l.useMemo(()=>xn?nt.map((c,N)=>N===0?{...c,renderCell:L=>{const{_treeDepth:V,_hasChildren:re,_isExpanded:ce,_groupingField:we,_groupingValue:Ue,_descendantCount:He}=L.row,pe=(V||0)*24;let le=c.renderCell?c.renderCell(L):L.value;return Hn&&re&&L.row._isGroupRow&&(le=t.jsxs("div",{className:"ogx__group-cell-content",children:[L.value,He!==void 0&&He>0?` (${He})`:""]})),At&&re&&we&&(le=t.jsxs("div",{className:"ogx__group-cell-content",children:[c.field===we?"":`${we}: `,String(Ue),He!==void 0?` (${He})`:""]})),t.jsxs("div",{style:{display:"flex",alignItems:"center",paddingLeft:pe,width:"100%",height:"100%"},children:[t.jsx("div",{style:{marginRight:4,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",cursor:re?"pointer":"default",flexShrink:0},children:re?t.jsx("div",{onClick:G=>{G.stopPropagation(),G.preventDefault(),Ae?.toggleExpansion(L.row.id)},onMouseDown:G=>{G.stopPropagation()},style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:10,position:"relative"},children:t.jsx(oo,{isExpanded:ce,onClick:G=>{G.stopPropagation(),G.preventDefault(),Ae?.toggleExpansion(L.row.id)}})}):null}),t.jsx("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:le})]})}}:{...c,renderCell:L=>{const{_hasChildren:V,_groupingField:re}=L.row;return At&&V?c.field===re?null:L.value!==void 0&&L.value!==null?c.renderCell?c.renderCell(L):L.value:null:c.renderCell?c.renderCell(L):L.value}}):nt,[nt,xn,At,Ae]),Dn=Er({dataSource:ne,sortModel:Ze,filterModel:Ge,paginationModel:ge,paginationMode:z,sortingMode:xe,filterMode:Qe,aggregationModel:et,setRows:Bn,setRowCount:Gi,setDataSourceLoading:Hi,setDataSourceError:Di,onAggregationResults:vo});l.useEffect(()=>{Dn.fetchChildren&&(ko.current=Dn.fetchChildren)},[Dn.fetchChildren]);const[rt,Ki]=l.useState(()=>vt?.columns?.columnWidths??{}),[Yi,Io]=l.useState(()=>vt?.columns?.columnOrder??nt.map(c=>c.field)),zt=$||Yi;l.useEffect(()=>{ne||Bn(An)},[An,Bn,ne]),l.useEffect(()=>{jo(nt)},[nt,jo]),l.useEffect(()=>{Be&&Io(nt.map(c=>c.field))},[Be,nt]);const Bt=l.useMemo(()=>{if(Y)return Le;const c=new Map(zt.map((N,L)=>[N,L]));return[...Le].sort((N,L)=>{const V=c.get(N.field)??Le.indexOf(N),re=c.get(L.field)??Le.indexOf(L);return V-re})},[Le,zt,Y]),Po=l.useMemo(()=>Bt.filter(c=>Ye[c.field]!==!1),[Bt,Ye]),$t=hr({columns:Bt,onColumnOrderChange:l.useCallback(c=>{const{oldIndex:N,targetIndex:L}=c,V=[...zt],[re]=V.splice(N,1);V.splice(L,0,re),$||Io(V),K?.(c)},[zt,$,K]),disableColumnReorder:Y}),[Xi,qi]=l.useState(new Set),_t=x??Xi,qe=!!P,ln=l.useCallback(c=>{const N=new Set(_t);N.has(c)?N.delete(c):N.add(c),x===void 0&&qi(N),S?.(N)},[_t,x,S]),be=l.useMemo(()=>{const c=[];return D&&c.push({field:"__reorder_col__"}),qe&&c.push({field:"__expand_col__"}),a&&c.push({field:"__checkbox_col__"}),[...c,...Bt]},[Bt,a,qe,D]),Ji=l.useCallback((c,N)=>{Ki(L=>({...L,[c]:N}))},[]),Gn=l.useRef(We);Gn.current=We,l.useEffect(()=>{if(!Gn.current)return;const c={sorting:{sortModel:Ze},filter:{filterModel:Ge},pagination:{paginationModel:ge},columns:{columnWidths:rt,columnOrder:zt,columnVisibilityModel:Ye,pinnedColumns:tt}};Gn.current(c)},[Ze,Ge,ge,rt,zt,Ye,tt]);const bn=l.useMemo(()=>rn,[rn]),$e=l.useMemo(()=>Ae?Ae.getVisibleRows()||[]:Qe==="server"&&ne?bn:wr(bn,Ge),[bn,Ge,Ae,Qe,ne]),{top:Ve,center:Ht,bottom:it}=l.useMemo(()=>Ae?{top:[],center:$e,bottom:[]}:$o($e,y),[$e,y,Ae]),Me=l.useMemo(()=>Ae||xe==="server"&&ne?Ht:_r(Ht,Ze),[Ht,Ze,Ae,xe,ne]),ft=l.useMemo(()=>{if(!Ne||z==="server"&&ne)return Me;const c=ge.page*ge.pageSize,N=c+ge.pageSize;return Me.slice(c,N)},[Me,Ne,ge.page,ge.pageSize,z,ne]);l.useEffect(()=>{ot.apiRef.current.getVisibleRows=()=>Me,ot.apiRef.current.getVisibleColumns=()=>Le},[Me,Le,ot.apiRef]);const Dt=pr({rows:Ne?ft:Me,getRowId:c=>c.id,onRowOrderChange:Z,rowReordering:D}),ye=l.useMemo(()=>{if(Ae)return Ht;const c=Ne?ft:Me,N=[...Ve,...c,...it];if(z==="infinite"&&ae.dataSource.loading&&N.length>0){const L=Math.min(ge.pageSize,20),V=Array.from({length:L},(re,ce)=>({id:`__skeleton_${ce}__`,_isSkeleton:!0}));return[...N,...V]}return N},[Ve,ft,Me,it,Ne,Ae,Ht,z,ae.dataSource.loading,ge.pageSize]),Gt=jr(ye,be,rt),{aggregationResult:Vn}=io({rows:$e,aggregationModel:et,isServerSide:!!(ne&&(z==="server"||xe==="server")),dataSource:ne,filterModel:Ge,sortModel:Ze,serverAggregationResults:Fi}),wn=Object.keys(et).length>0;l.useEffect(()=>{ot.apiRef.current.getAggregationResult=()=>wn?Vn:null,ot.apiRef.current.getAggregationModel=()=>wn?et:null},[Vn,et,wn,ot.apiRef]);const Un=l.useMemo(()=>{const c=i,N=Ne?ft:Me,L=N.map((W,X)=>{let ee=c;if(_t.has(W.id)){const ze=k?.({row:W,id:W.id,rowIndex:Ve.length+X})??200;ee+=typeof ze=="number"?ze:parseInt(String(ze),10)||200}return ee}),V=L.reduce((W,X,ee)=>(W.push((W[ee-1]||0)+X),W),[]),ce=(z==="infinite"&&ae.dataSource.loading&&N.length>0?Math.min(ge.pageSize,20):0)*c,we=(V[V.length-1]||0)+ce,Ue=Ve.length*c,He=it.length*c,ie=[],pe=[],le=[],G=[];Po.forEach(W=>{const X=dn(W.field,tt);X==="left"?ie.push(W):X==="right"?pe.push(W):le.push(W)});const fe=ae.dimensions.viewportWidth||1e3,Ce=(a?48:0)+(qe?48:0)+(D?48:0),me=W=>rt[W.field]??W.width,Ie=W=>{if(W===void 0)return{type:"auto",value:0};if(typeof W=="number")return{type:"fixed",value:W};if(typeof W=="string"){if(W.toLowerCase()==="auto")return{type:"auto",value:0};if(W.endsWith("%"))return{type:"percentage",value:parseFloat(W)};const X=parseFloat(W);if(!isNaN(X))return{type:"fixed",value:X}}return{type:"fixed",value:100}},Pe=ie.reduce((W,X)=>{const ee=Ie(me(X));return W+(ee.type==="fixed"?ee.value:100)},0),ue=pe.reduce((W,X)=>{const ee=Ie(me(X));return W+(ee.type==="fixed"?ee.value:100)},0),de=le.reduce((W,X)=>{if(X.flex&&X.flex>0){const ze=X.minWidth??150,mt=typeof X.width=="number"?X.width:150;return W+(ze||mt)}const ee=Ie(me(X));return ee.type==="fixed"?W+ee.value:ee.type==="percentage"?W+100:W+(X.minWidth??150)},0),ht=Math.max(fe-Ce-Pe-ue,de),lt=[],Re=[],ke=[];let Fe=0;le.forEach(W=>{const X=Ie(me(W));if(W.flex&&W.flex>0){ke.push({col:W,flex:W.flex}),Fe+=W.flex;return}X.type==="fixed"?lt.push({col:W,width:X.value}):X.type==="percentage"?Re.push({col:W,percentage:X.value}):(ke.push({col:W,flex:1}),Fe+=1)});const De=lt.reduce((W,{width:X})=>W+X,0);let Te=Math.max(0,ht-De);const st=new Map;Re.forEach(({col:W,percentage:X})=>{const ee=X/100*Te;st.set(W.field,ee),Te-=ee}),Te=Math.max(0,Te);const Ct=new Map,pt=ke.map(W=>({...W,minWidth:W.col.minWidth??50,maxWidth:W.col.maxWidth??1/0,frozen:!1,computedWidth:0}));(()=>{let W=0;const X=pt.length*2;for(;W<X;){W++;const ee=pt.filter(te=>!te.frozen);if(ee.length===0)break;const ze=ee.reduce((te,at)=>te+at.flex,0),mt=pt.reduce((te,at)=>at.frozen?te+at.computedWidth:te,0),sl=Math.max(0,Te-mt);if(ze<=0){ee.forEach(te=>{te.computedWidth=te.minWidth,te.frozen=!0});break}const al=sl/ze;let Cn=0;const yn=[],kn=[];if(ee.forEach(te=>{const at=al*te.flex;if(at<te.minWidth){const Xn=te.minWidth-at;Cn+=Xn,yn.push(te)}else if(at>te.maxWidth){const Xn=te.maxWidth-at;Cn+=Xn,kn.push(te)}else te.computedWidth=at}),yn.length===0&&kn.length===0){ee.forEach(te=>te.frozen=!0);break}Cn>0?yn.forEach(te=>{te.computedWidth=te.minWidth,te.frozen=!0}):Cn<0?kn.forEach(te=>{te.computedWidth=te.maxWidth,te.frozen=!0}):(yn.forEach(te=>{te.computedWidth=te.minWidth,te.frozen=!0}),kn.forEach(te=>{te.computedWidth=te.maxWidth,te.frozen=!0}))}})(),pt.forEach(W=>Ct.set(W.col.field,W.computedWidth));const Ut=new Map;le.forEach(W=>{let X;if(Ct.has(W.field))X=Ct.get(W.field);else{const ee=lt.find(mt=>mt.col.field===W.field),ze=Re.find(mt=>mt.col.field===W.field);if(ee)X=ee.width;else if(ze){const mt=st.get(W.field)||0;X=Math.max(W.minWidth??50,mt||100)}else X=100}G.push(X),Ut.set(W.field,X)});const xt=le.map(W=>{const X=pt.find(ee=>ee.col.field===W.field);return{...W,width:Ut.get(W.field)??(typeof W.width=="number"?W.width:100),flex:X?X.flex:W.flex}}),Ke=11,Nt=ie.map((W,X)=>{const ee=Ie(me(W)),ze=ee.type==="fixed"?ee.value:100;return{...W,width:ze,zIndex:Ke+X}}),Kt=11,yt=pe.map((W,X)=>{const ee=Ie(me(W)),ze=ee.type==="fixed"?ee.value:100;return{...W,width:ze,zIndex:Kt+(pe.length-1-X)}}),Je=G.reduce((W,X)=>W+X,0),ve=Pe+Je+ue+Ce,ll=G.reduce((W,X,ee)=>(W.push((W[ee-1]||0)+X),W),[]);return{rowHeights:L,cumulativeHeights:V,unpinnedRowsHeight:we,pinnedTopHeight:Ue,pinnedBottomHeight:He,leftPinnedCols:Nt,rightPinnedCols:yt,unpinnedColsWithWidth:xt,unpinnedColWidths:G,unpinnedAccWidths:ll,totalWidth:ve,leftWidth:Pe,rightWidth:ue,unpinnedTotalWidth:Je,systemColumnsWidth:Ce,pinnedTopRowsLength:Ve.length,pinnedBottomRowsLength:it.length,unpinnedRowsLength:N.length}},[i,Ne,ft,Me,_t,k,Ve.length,it.length,_t,k,Ve.length,it.length,Po,tt,rt,ae.dimensions.viewportWidth,a,qe,D,R,B,d,z,ae.dataSource.loading,ge.pageSize]),_e=l.useMemo(()=>{const{unpinnedAccWidths:c,unpinnedColsWithWidth:N,leftPinnedCols:L,rightPinnedCols:V,totalWidth:re,leftWidth:ce,rightWidth:we,unpinnedTotalWidth:Ue,systemColumnsWidth:He,cumulativeHeights:ie,pinnedTopHeight:pe,pinnedBottomHeight:le,unpinnedRowsHeight:G,rowHeights:fe,unpinnedRowsLength:Ce}=Un,me=ae.virtualization.scrollLeft,Ie=ae.virtualization.scrollTop,Pe=ae.dimensions.viewportWidth||1e3,ue=d?pe+G+le+50:ae.dimensions.viewportHeight||600,de=6,ht=Math.max(0,me-ce),lt=me+Pe-ce;let Re=0,ke=N.length-1,Fe=0,De=c.length-1;for(;Fe<=De;){const ve=Fe+De>>>1;c[ve]<ht?Fe=ve+1:De=ve-1}Re=Math.max(0,Fe-de);for(let ve=Re;ve<c.length;ve++){if((ve===0?0:c[ve-1])>lt){ke=Math.min(N.length-1,ve+de);break}ke=Math.min(N.length-1,ve+de)}const Te=Re>0?c[Re-1]:0,st=Ue-c[ke],Ct=[...L,...Te>0?[{field:"__spacer_left__",width:Te,isSpacer:!0}]:[],...N.slice(Re,ke+1),...st>0?[{field:"__spacer_right__",width:st,isSpacer:!0}]:[],...V],sn=Pe>0&&re>Pe?16:0,Ut=pe+G+le+sn+2,xt=5;let Ke=0,Nt=Ce-1,Kt=0,yt=0,Je=ie.length-1;for(;yt<=Je;){const ve=yt+Je>>>1;ie[ve]<Ie?yt=ve+1:Je=ve-1}Ke=Math.max(0,yt-xt),Kt=Ke>0?ie[Ke-1]:0;for(let ve=Ke;ve<ie.length;ve++)if(ie[ve]>=Ie+ue){Nt=Math.min(Ce-1,ve+xt);break}return{renderContext:{firstRowIndex:Ke,lastRowIndex:Nt,firstColumnIndex:Re,lastColumnIndex:ke},offsetTop:Kt,offsetLeft:0,totalHeight:Ut,pinnedTopHeight:pe,pinnedBottomHeight:le,totalWidth:re,rowHeights:fe,cumulativeHeights:ie,virtualColumns:Ct,columnMetrics:{leftPinnedWidth:ce,rightPinnedWidth:we,unpinnedAccWidths:c,unpinnedCols:N,totalSpecialsWidth:He,pinnedSpecialsWidth:(D?48:0)+(qe&&B?48:0)+(a&&R?48:0)}}},[Un,ae.virtualization.scrollTop,ae.virtualization.scrollLeft,ae.dimensions.viewportHeight,ae.dimensions.viewportWidth,d]),Qi=l.useCallback(c=>{const N=c.currentTarget;if(Eo(N.scrollTop,N.scrollLeft),St){const{scrollTop:L,scrollHeight:V,clientHeight:re}=N;V-L-re<100&&St({visibleTop:L,visibleBottom:L+re,viewportHeight:re})}},[Eo,St]);l.useEffect(()=>{if(!Et.current)return;const c=new ResizeObserver(N=>{for(const L of N){const{width:V,height:re}=L.contentRect;No(V,re)}});return c.observe(Et.current),()=>{c.disconnect()}},[No]);const Vt=l.useCallback((c,N)=>{const L=new Set(Ee);N?L.add(c):L.delete(c);const V=Array.from(L);nn||_o(V),fn?.(V)},[Ee,nn,fn]),Zi=l.useCallback(c=>{let N=[];c&&(N=bn.map(L=>L.id)),nn||_o(N),fn?.(N)},[o,nn,fn]),To=l.useCallback((c,N)=>{const L=N?[{field:c,sort:N}]:[];Tn||Ci(L),m?.(L)},[Tn,m]),Kn=l.useCallback(c=>{Wt(!1),Ft({id:c.row.id,field:c.field}),hn.current?.focus({preventScroll:!0}),b?.(c)},[b,Wt]),Lo=l.useRef(Oe.editingCell);l.useEffect(()=>{const c=!!Lo.current,N=!!Oe.editingCell;c&&!N&&hn.current?.focus({preventScroll:!0}),Lo.current=Oe.editingCell},[Oe.editingCell]);const Ro=l.useMemo(()=>{const{firstRowIndex:c,lastRowIndex:N}=_e.renderContext,L=Ve.length,V=Ve.map((le,G)=>({row:le,rowIndex:G})),re=it.map((le,G)=>({row:le,rowIndex:L+(Ne?ft.length:Me.length)+G})),ce=Math.max(0,c-L),we=Math.min(Ne?ft.length:Me.length,N-L+1),Ue=(Ne?ft:Me).slice(ce,we).map((le,G)=>({row:le,rowIndex:L+ce+G})),He=[...V,...Ue,...re],ie=new Set;return He.filter(le=>ie.has(le.row.id)?!1:(ie.add(le.row.id),!0))},[_e.renderContext,Ve,it,ft,Me,Ne,z,ae.dataSource.loading,ge.pageSize,i]),el=o.length>0&&Ee.size===o.length,tl=Ee.size>0&&Ee.size<o.length,nl=l.useCallback(c=>{c.target===c.currentTarget&&Ft(N=>{if(N)return N;if(a)return{id:"HEADER",field:"__checkbox_col__"};const L=ye[0],V=be[0];return L&&V?{id:L.id,field:V.field}:null})},[ye,be]),ol=l.useCallback(c=>{c.currentTarget.contains(c.relatedTarget)||Ft(null)},[]),rl=l.useCallback(c=>{if(Wt(!0),!Xe)return;const{id:N,field:L}=Xe,V=!!Oe.editingCell;if(c.key==="Enter"){if(c.preventDefault(),V)Oe.stopCellEdit();else if(be.find(fe=>fe.field===L)?.editable){const fe=ye.find(Ce=>Ce.id===N);fe&&Oe.startCellEdit({id:N,field:L,value:fe[L]})}return}if((c.key===" "||c.key==="Spacebar")&&!V){if(L==="__checkbox_col__"){c.preventDefault(),Vt(N,!Ee.has(N));return}if(L==="__expand_col__"){c.preventDefault(),ln(N);return}}if(N==="HEADER"&&(c.key==="Enter"||c.key===" ")){c.preventDefault();const G=be.find(fe=>fe.field===L);if(G&&G.sortable!==!1){const fe=Ze.find(me=>me.field===L);let Ce="asc";fe&&(fe.sort==="asc"?Ce="desc":Ce=null),To(L,Ce)}return}if(c.key==="Escape"){V&&(c.preventDefault(),Oe.stopCellEdit({cancel:!0}));return}if(V&&c.key!=="Tab")return;const re=N==="HEADER",ce=re?-1:ye.findIndex(G=>G.id===N),we=be.findIndex(G=>G.field===L);if(!re&&ce===-1||we===-1)return;const Ue=(G,fe,Ce,me,Ie,Pe=!1)=>{let ue=G+Ce,de=fe+me;return Ie&&me!==0&&(me>0&&de>=be.length?(de=0,ue++):me<0&&de<0&&(de=be.length-1,ue--)),!Ie&&(de<0||de>=be.length)||ue<(Pe?-1:0)||ue>=ye.length?null:{r:ue,c:de}},He=(G,fe,Ce,me,Ie,Pe=!1)=>{let ue=G,de=fe,ht=0;const lt=ye.length*be.length+be.length;for(;ht<lt;){if(ht++,ue+=Ce,de+=me,me!==0)me>0?de>=be.length&&(de=0,ue++):de<0&&(de=be.length-1,ue--);else if(de<0||de>=be.length)return null;if(ue<-1||ue>=ye.length)return null;if(ue===-1){if(!Pe)continue;const Te=be[de],st=Te.sortable!==!1;if(["__checkbox_col__"].includes(Te.field)||st)return{r:ue,c:de};continue}const Re=ye[ue],ke=be[de],Fe=["__checkbox_col__","__expand_col__","__reorder_col__"].includes(ke.field);let De=ke.editable||Fe;if(U&&!Fe)try{De=U({row:Re,field:ke.field,value:Re[ke.field],colDef:ke,rowIndex:ue,colIndex:de})}catch(Te){console.error("Error in isCellEditable:",Te)}if(De)return{r:ue,c:de}}return null};let ie=ce,pe=we,le=!1;if(c.key==="Tab"){const G=c.shiftKey?-1:1,fe=He(ce,we,0,G,!0,!1);fe&&(ie=fe.r,pe=fe.c,le=!0)}else if(c.key==="ArrowRight"){const G=Ue(ce,we,0,1,!0,!0);G&&(ie=G.r,pe=G.c,le=!0)}else if(c.key==="ArrowLeft"){const G=Ue(ce,we,0,-1,!0,!0);G&&(ie=G.r,pe=G.c,le=!0)}else if(c.key==="ArrowDown"){const G=Ue(ce,we,1,0,!1,!0);G&&(ie=G.r,pe=G.c,le=!0)}else if(c.key==="ArrowUp"){const G=Ue(ce,we,-1,0,!1,!0);G&&(ie=G.r,pe=G.c,le=!0)}else if(c.key==="Home")(c.ctrlKey||c.metaKey)&&(ie=-1),pe=0,le=!0;else if(c.key==="End")(c.ctrlKey||c.metaKey)&&(ie=ye.length-1),pe=be.length-1,le=!0;else if(c.key==="PageUp"){const G=Ne?ge.pageSize:10;ie=Math.max(-1,ie-G),le=!0}else if(c.key==="PageDown"){const G=Ne?ge.pageSize:10;ie=Math.min(ye.length-1,ie+G),le=!0}if(le&&(c.preventDefault(),V&&c.key==="Tab"&&Oe.stopCellEdit(),ie>=-1&&ie<ye.length&&pe>=0&&pe<be.length)){const G=be[pe];if(ie===-1)Ft({id:"HEADER",field:G.field});else{const fe=ye[ie];Ft({id:fe.id,field:G.field})}if(Et.current){const{cumulativeHeights:fe,pinnedTopHeight:Ce}=_e,{clientHeight:me,clientWidth:Ie,scrollTop:Pe,scrollLeft:ue}=Et.current,de=ie===0?0:fe[ie-1],ht=fe[ie],lt=Ce,Re=Pe+lt,ke=Pe+me;let Fe=Pe;if(de<Re?Fe=Math.max(0,de-lt):ht>ke&&(Fe=ht-me),Fe!==Pe&&(Et.current.scrollTop=Fe),_e.columnMetrics){const{leftPinnedWidth:De,rightPinnedWidth:Te,unpinnedAccWidths:st,unpinnedCols:Ct,totalSpecialsWidth:pt,pinnedSpecialsWidth:sn}=_e.columnMetrics,Ut=G.field,xt=Ct.findIndex(Ke=>Ke.field===Ut);if(xt!==-1){const Ke=pt+De+(xt>0?st[xt-1]:0),Nt=pt+De+st[xt],Kt=ue+sn+De,yt=ue+Ie-Te;let Je=ue;Ke<Kt?Je=Math.max(0,Ke-sn-De):Nt>yt&&(Je=Nt-Ie+Te),Je!==ue&&(Et.current.scrollLeft=Je)}}}}},[Xe,ye,be,Oe,_e,Ee,Vt,ln]),il=l.useMemo(()=>Le.some(c=>!!c.rowSpan),[Le]),[vn,_n]=l.useState(!1),Yn=l.useRef(null);return l.useEffect(()=>{if(!vn||je?.toolbar)return;function c(N){const L=document.getElementById("ogx-standalone-col-panel");L&&!L.contains(N.target)&&_n(!1)}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[vn,je?.toolbar]),t.jsxs("div",{ref:Yn,className:`ogx ${en} ${d?"ogx--auto-height":""} ${il?"ogx--row-spanning":""} ${cn?"ogx--list-view":""}`,style:{...Lt,height:q??Lt?.height,"--ogx-row-height":`${i}px`,"--ogx-header-height":`${s}px`},"aria-busy":on,children:[bo&&(()=>{const c={apiRef:ot.apiRef,columns:Le,aggregationModel:et,onAggregationModelChange:ji,...Be?{pivotModel:wo,onPivotModelChange:Ri}:{},filterModel:Ge,onFilterModelChange:h,columnVisibilityModel:Ye,onColumnVisibilityModelChange:tn,forceColumnsOpen:vn,onColumnsPanelClose:()=>_n(!1),...ct?.toolbar};return t.jsx(bo,{...c})})(),!je?.toolbar&&vn&&kt.createPortal(t.jsxs("div",{id:"ogx-standalone-col-panel",style:(()=>{const c=Yn.current?.getBoundingClientRect();return{position:"fixed",top:c?c.top+8:16,right:c?window.innerWidth-c.right+8:16,zIndex:9999,display:"inline-block"}})(),children:[t.jsx("button",{onClick:()=>_n(!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(so,{columns:Le,visibleColumns:new Set(Le.filter(c=>Ye[c.field]!==!1).map(c=>c.field)),onVisibilityChange:(c,N)=>{tn({...Ye,[c]:N})},onShowAll:()=>{const c={...Ye};Le.forEach(N=>{N.hideable!==!1&&(c[N.field]=!0)}),tn(c)},onHideAll:()=>{const c={...Ye};Le.forEach(N=>{N.hideable!==!1&&(c[N.field]=!1)}),tn(c)}})]}),document.body),cn&&mo&&t.jsxs("div",{className:"ogx-list-view",role:"grid","aria-label":Rt||"Data grid list view","aria-rowcount":ye.length+1,children:[t.jsx("div",{className:"ogx-list-view__toolbar",children:t.jsxs("span",{children:[$e.length," ",$e.length===1?"item":"items",Ne?` · page ${ge.page+1} of ${Math.ceil($e.length/ge.pageSize)||1}`:"",Ee.size>0?` · ${Ee.size} selected`:""]})}),t.jsx("div",{className:"ogx-list-view__rows",children:ye.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"})]}),In]}):ye.map((c,N)=>t.jsx(Ao,{row:c,rowIndex:N,listViewColumn:mo,isSelected:Ee.has(c.id),checkboxSelection:a,rowHeight:i,onRowClick:L=>mn({row:L,id:L.id,rowIndex:N}),onSelectionChange:Vt},c.id))}),Ne&&(()=>{const c=je?.pagination||ro,N=z==="server"&&ne?ae.pagination.rowCount||0:$e.length,L={page:ge.page,pageSize:ge.pageSize,rowCount:N,pageSizeOptions:C,onPageChange:V=>gn({...ge,page:V}),onPageSizeChange:V=>gn({...ge,pageSize:V,page:0}),...ct?.pagination};return t.jsx(c,{...L})})()]}),!cn&&t.jsx("div",{ref:c=>{Et.current=c,hn.current=c},className:"ogx__viewport",onScroll:Qi,role:"grid","aria-label":Rt||"Data grid","aria-rowcount":$e.length+1,"aria-colcount":e.length+(a?1:0)+(qe?1:0)+(D?1:0),"aria-busy":on,tabIndex:0,onKeyDownCapture:()=>{Wt(!0)},onMouseDownCapture:()=>{Wt(!1)},onKeyDown:rl,onFocus:nl,onBlur:ol,children:t.jsxs("div",{ref:zi,className:"ogx__content",style:{width:_e.totalWidth},role:"presentation",children:[t.jsx(to,{columns:_e.virtualColumns,allColumns:Le,columnGroupingModel:jt,checkboxSelection:a,allSelected:el,someSelected:tl,onSelectAll:Zi,sortModel:Ze,onSort:To,onColumnResize:Ji,columnWidths:rt,pinnedColumns:tt,focusedCell:Xe,onHeaderClick:c=>{Ft({id:"HEADER",field:c}),Wt(!1),hn.current?.focus({preventScroll:!0})},onDragStart:jt?void 0:$t.onDragStart,onDragOver:jt?void 0:$t.onDragOver,onDragEnd:jt?void 0:$t.onDragEnd,onDrop:jt?void 0:$t.onDrop,draggedColumn:jt?void 0:$t.draggedColumn,dragOverColumn:jt?void 0:$t.dragOverColumn,rowReordering:D,hasDetailPanel:qe,pinCheckboxColumn:R,pinExpandColumn:B,aggregationModel:et,onHideColumn:c=>{tn({...Ye,[c]:!1})},onManageColumns:()=>_n(!0),onPinColumn:(c,N)=>{const L=[...tt?.left??[]],V=[...tt?.right??[]],re=L.filter(we=>we!==c),ce=V.filter(we=>we!==c);On(N==="left"?{left:[...re,c],right:ce}:N==="right"?{left:re,right:[...ce,c]}:{left:re,right:ce})}}),!on&&!ae.dataSource.error&&$e.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:In})]}),Ve.length>0&&t.jsx("div",{className:"ogx__pinned-rows ogx__pinned-rows--top",role:"rowgroup",children:Ve.map((c,N)=>t.jsx(Jt,{row:c,columns:_e.virtualColumns,rowIndex:N,isSelected:Ee.has(c.id),checkboxSelection:a,onRowClick:mn,onCellClick:Kn,onSelectionChange:Vt,columnWidths:rt,pinnedColumns:tt,pinnedRows:y,hasDetailPanel:qe,isDetailPanelExpanded:_t.has(c.id),detailPanelContent:P?P({row:c,id:c.id,rowIndex:N}):null,detailPanelHeight:k?.({row:c,id:c.id,rowIndex:N})||200,onDetailPanelToggle:ln,pinCheckboxColumn:R,pinExpandColumn:B,focusedCellField:Xe?.id===c.id?Xe.field:null,colspanMap:Gt.colspanMap,rowSpanningCaches:Gt.rowSpanningState.caches,rowHeight:i},c.id))}),t.jsx("div",{className:"ogx__virtual-container",style:{height:`${_e.totalHeight-_e.pinnedTopHeight-_e.pinnedBottomHeight}px`},role:"presentation",children:t.jsxs("div",{className:"ogx__rows",style:{transform:`translateY(${_e.renderContext.firstRowIndex*i}px)`},role:"rowgroup",children:[on&&Ro.length===0?(()=>{const c=e.length>0?e:(()=>{const N=(ae.dimensions.viewportWidth||1e3)-(a?48:0)-(P?48:0)-(D?48:0),L=150,V=Math.max(1,Math.ceil(N/L));return Array.from({length:V},(re,ce)=>({field:`placeholder_${ce}`,headerName:"",width:L}))})();return Array.from({length:10}).map((N,L)=>t.jsx(cr,{columns:c,rowHeight:i,checkboxSelection:a,hasDetailPanel:!!P,rowReordering:D},`skeleton-${L}`))})():Ro.filter(({row:c})=>!Sn(c.id,y)).filter((c,N,L)=>N===L.findIndex(V=>V.row.id===c.row.id)).map(({row:c,rowIndex:N})=>t.jsx(Jt,{row:c,columns:_e.virtualColumns,rowIndex:N,isSelected:Ee.has(c.id),checkboxSelection:a,onRowClick:mn,onCellClick:Kn,onSelectionChange:Vt,columnWidths:rt,pinnedColumns:tt,pinnedRows:y,hasDetailPanel:qe,isDetailPanelExpanded:_t.has(c.id),detailPanelContent:P?P({row:c,id:c.id,rowIndex:N}):null,detailPanelHeight:k?.({row:c,id:c.id,rowIndex:N})||200,onDetailPanelToggle:ln,pinCheckboxColumn:R,pinExpandColumn:B,rowReordering:D,onDragStart:Dt.onDragStart,onDragOver:Dt.onDragOver,onDragEnd:Dt.onDragEnd,onDrop:Dt.onDrop,isDragging:Dt.draggedRowId===c.id,isDragOver:Dt.dragOverRowId===c.id,editingCell:Oe.editingCell,onEditStart:Oe.startCellEdit,onEditStop:Oe.stopCellEdit,onEditCellValueChange:Oe.setEditCellValue,focusedCellField:Xe!=null&&Xe.id===c.id?Xe.field:null,colspanMap:Gt.colspanMap,rowSpanningCaches:Gt.rowSpanningState.caches,rowHeight:i},`${c.id}-${_e.totalWidth}`)),z==="infinite"&&ae.dataSource.loading&&Me.length>0&&(()=>{const c=Math.min(ge.pageSize,20),N=Un.unpinnedRowsLength;return t.jsx("div",{className:"ogx__skeleton-group",children:Array.from({length:c}).map((L,V)=>t.jsx(Jt,{row:{id:`__skeleton_${V}__`,_isSkeleton:!0},columns:_e.virtualColumns,rowIndex:N+V,rowHeight:i},`__skeleton_${V}__`))})})()]})}),it.length>0&&t.jsx("div",{className:"ogx__pinned-rows ogx__pinned-rows--bottom",role:"rowgroup",children:it.map((c,N)=>t.jsx(Jt,{row:c,columns:_e.virtualColumns,rowIndex:N,isSelected:Ee.has(c.id),checkboxSelection:a,onRowClick:mn,onCellClick:Kn,onSelectionChange:Vt,columnWidths:rt,pinnedColumns:tt,pinnedRows:y,hasDetailPanel:qe,isDetailPanelExpanded:_t.has(c.id),detailPanelContent:P?P({row:c,id:c.id,rowIndex:N}):null,detailPanelHeight:k?.({row:c,id:c.id,rowIndex:N})||200,onDetailPanelToggle:ln,pinCheckboxColumn:R,pinExpandColumn:B,focusedCellField:Xe?.id===c.id?Xe.field:null,colspanMap:Gt.colspanMap,rowSpanningCaches:Gt.rowSpanningState.caches,rowHeight:i},c.id))}),wn&&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}}),qe&&t.jsx("div",{style:{width:48,flexShrink:0}}),D&&t.jsx("div",{style:{width:48,flexShrink:0}}),Bt.map(c=>{const N=et[c.field],L=Vn[c.field],V=rt[c.field]??(typeof c.width=="number"?c.width:120);return t.jsx("div",{className:"ogx__aggregation-cell",role:"gridcell",style:{width:V,minWidth:V,maxWidth:V,textAlign:c.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(L,N)})]}):null},c.field)})]})]})}),!cn&&Ne&&(()=>{const c=je?.pagination||ro,N={page:ge.page,pageSize:ge.pageSize,rowCount:ae.pagination.rowCount,pageSizeOptions:C,onPageChange:L=>gn({...ge,page:L}),onPageSizeChange:L=>gn({...ge,pageSize:L,page:0}),...ct?.pagination};return t.jsx(c,{...N})})(),t.jsxs("div",{className:"ogx-aria-live-status",role:"status","aria-live":"polite",children:[on?"Loading data...":"",ae.dataSource.error?`Error: ${ae.dataSource.error.message||"Unknown error"}`:"",!J&&!ae.dataSource.error&&($e.length===0?In:Ge&&((Ge.quickFilterValues?.length||0)>0||(Ge.items?.length||0)>0)?`${$e.length} ${$e.length===1?"row":"rows"} found`:"")]}),ae.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:ae.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 ao=new Set(["isEmpty","isNotEmpty"]);function Wr(n,o){return n.find(e=>"field"in e&&e.field===o)}const Or=({col:n,item:o,onChange:e})=>{const r=vr(n.type),i=!!o,s=o?.operator??r[0],d=u=>{const h=ao.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})},f=()=>{e(null)},g=ao.has(String(s)),p=n.type==="boolean",b=!g;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=>d(u.target.value),"aria-label":`Filter operator for ${n.headerName||n.field}`,children:r.map(u=>t.jsx("option",{value:u,children:u},u))}),b&&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"})]}),b&&!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:f,"aria-label":`Clear filter for ${n.headerName||n.field}`,title:"Clear",children:"×"})]})]})},co=({filterModel:n,columns:o,onFilterModelChange:e})=>{const r=n.items??[],i=n.logicOperator??"and",s=l.useCallback((f,g)=>{const p=r.filter(u=>"field"in u&&u.field!==f),b=g?[...p,g]:p;e({...n,items:b})},[r,n,e]),d=l.useCallback(f=>{e({...n,logicOperator:f})},[n,e]),a=o.filter(f=>f.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:()=>d("and"),"aria-pressed":i==="and",children:"ALL (AND)"}),t.jsx("button",{className:`ogx-filter__logic-pill${i==="or"?" ogx-filter__logic-pill--active":""}`,onClick:()=>d("or"),"aria-pressed":i==="or",children:"ANY (OR)"})]}),a.length===0?t.jsx("div",{className:"ogx-filter__empty",children:"No filterable columns."}):a.map(f=>t.jsx(Or,{col:f,item:Wr(r,f.field),onChange:g=>s(f.field,g)},f.field))]})},Ar=["sum","avg","count","min","max"];function uo(){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 zr({anchorRef:n,columns:o,model:e,onChange:r,onClose:i}){const s=l.useRef(null),[d,a]=l.useState({top:0,right:0}),f=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(f());const x=()=>a(f());return window.addEventListener("scroll",x,!0),window.addEventListener("resize",x),()=>{window.removeEventListener("scroll",x,!0),window.removeEventListener("resize",x)}},[f]),l.useEffect(()=>{function x(R){s.current&&!s.current.contains(R.target)&&n.current&&!n.current.contains(R.target)&&i()}function S(R){R.key==="Escape"&&i()}return document.addEventListener("mousedown",x),document.addEventListener("keydown",S),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",S)}},[n,i]);const g=new Set(e.rowFields),p=new Set(e.columnFields),b=new Set(e.valueFields.map(x=>x.field)),u=x=>g.has(x)||p.has(x)||b.has(x);function h(x){g.has(x)||r({...e,rowFields:[...e.rowFields,x]})}function w(x){p.has(x)||r({...e,columnFields:[...e.columnFields,x]})}function m(x,S="sum"){b.has(x)||r({...e,valueFields:[...e.valueFields,{field:x,aggFn:S}]})}function I(x){r({...e,rowFields:e.rowFields.filter(S=>S!==x)})}function M(x){r({...e,columnFields:e.columnFields.filter(S=>S!==x)})}function E(x){r({...e,valueFields:e.valueFields.filter(S=>S.field!==x)})}function C(x,S){r({...e,valueFields:e.valueFields.map(R=>R.field===x?{...R,aggFn:S}:R)})}function _(){r({rowFields:[],columnFields:[],valueFields:[]})}const j=new Set(o.filter(x=>x.type==="number"||x.aggregable).map(x=>x.field)),y=e.rowFields.length+e.columnFields.length+e.valueFields.length,P=x=>o.find(S=>S.field===x)?.headerName??x,k=t.jsxs("div",{ref:s,className:"ogx-pivot-panel",role:"dialog","aria-label":"Pivot configuration",style:{top:d.top,right:d.right},children:[t.jsxs("div",{className:"ogx-pivot-panel__header",children:[t.jsxs("span",{className:"ogx-pivot-panel__title",children:[t.jsx(uo,{}),"Pivot Mode"]}),y>0&&t.jsx("button",{className:"ogx-pivot-panel__reset-btn",onClick:_,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:[P(x),t.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>I(x),title:`Remove ${P(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:[P(x),t.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>M(x),title:`Remove ${P(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:[P(x.field),t.jsx("select",{className:"ogx-pivot-chip__fn-select",value:x.aggFn,onChange:S=>C(x.field,S.target.value),title:"Aggregation function",children:Ar.map(S=>t.jsx("option",{value:S,children:S.toUpperCase()},S))}),t.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>E(x.field),title:`Remove ${P(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 S=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${S?" 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"}),S&&t.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--value",onClick:()=>m(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 kt.createPortal(k,document.body)}function Br(){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 $r(){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 Hr({value:n="",onChange:o,placeholder:e="Search...",debounceMs:r=250}){const[i,s]=l.useState(!1),[d,a]=l.useState(n),f=l.useRef(null),g=l.useRef(null);l.useEffect(()=>{a(n),n&&!i&&s(!0)},[n,i]),l.useEffect(()=>{const h=setTimeout(()=>{d!==n&&o(d)},r);return()=>clearTimeout(h)},[d,o,r,n]);const p=()=>{s(!0)},b=h=>{h.stopPropagation(),a(""),f.current?.focus(),o("")},u=()=>{d||s(!1)};return l.useEffect(()=>{const h=w=>{g.current&&!g.current.contains(w.target)&&(d||s(!1))};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[d]),t.jsxs("div",{ref:g,className:`ogx-global-search${i?" ogx-global-search--expanded":""}`,onClick:()=>{i||(s(!0),setTimeout(()=>f.current?.focus(),50))},children:[t.jsx("div",{className:"ogx-global-search__icon-wrapper",children:t.jsx(Br,{})}),t.jsx("input",{ref:f,id:"ogx-global-search-input",name:"ogx-global-search",className:"ogx-global-search__input",value:d,onChange:h=>a(h.target.value),onFocus:p,onBlur:u,placeholder:e,"aria-label":"Global Search",autoComplete:"off"}),d&&t.jsx("button",{className:"ogx-global-search__clear",onClick:b,"aria-label":"Clear search",children:t.jsx($r,{})})]})}function Zt({title:n,children:o,placement:e="top",enterDelay:r=200,leaveDelay:i=0}){const[s,d]=l.useState(!1),[a,f]=l.useState({top:0,left:0}),g=l.useRef(null),p=l.useRef(null),b=l.useCallback(()=>{if(!p.current)return;const m=p.current.getBoundingClientRect();let I=0,M=0;const E=window.pageXOffset||document.documentElement.scrollLeft,C=window.pageYOffset||document.documentElement.scrollTop;e==="top"?(I=m.top+C-8,M=m.left+E+m.width/2):e==="bottom"&&(I=m.bottom+C+8,M=m.left+E+m.width/2),f({top:I,left:M})},[e]);l.useLayoutEffect(()=>(s&&(b(),window.addEventListener("scroll",b,!0),window.addEventListener("resize",b)),()=>{window.removeEventListener("scroll",b,!0),window.removeEventListener("resize",b)}),[s,b]);const u=()=>{g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{d(!0)},r)},h=()=>{g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{d(!1)},i)},w=l.useCallback(m=>{p.current=m?m.firstElementChild??m: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&&kt.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 Dr=["none","sum","avg","count","min","max"];function go(){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 Gr(){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 fo(){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 Vr({anchorRef:n,aggregationModel:o,aggregableColumns:e,onFunctionChange:r,onClearAll:i,onClose:s,activeCount:d}){const a=l.useRef(null),[f,g]=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(()=>{g(p());const u=()=>g(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 b=t.jsxs("div",{ref:a,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Summaries configuration",style:{top:f.top,right:f.right,width:400,maxWidth:"calc(100vw - 24px)"},children:[t.jsxs("div",{className:"ogx-toolbar__panel-header",children:[t.jsxs("span",{className:"ogx-toolbar__panel-title",children:[t.jsx(go,{}),"Summaries"]}),d>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:Dr.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 kt.createPortal(b,document.body)}function Ur({anchorRef:n,columns:o,visibleColumns:e,onVisibilityChange:r,onShowAll:i,onHideAll:s,onClose:d}){const a=l.useRef(null),[f,g]=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(()=>{g(p());const u=()=>g(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)&&d()}return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[n,d]);const b=t.jsx("div",{ref:a,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Column visibility",style:{top:f.top,right:f.right,width:280,padding:0},children:t.jsx(so,{columns:o,visibleColumns:e,onVisibilityChange:r,onShowAll:i,onHideAll:s})});return kt.createPortal(b,document.body)}function Kr({anchorRef:n,columns:o,filterModel:e,onFilterModelChange:r,onClose:i}){const s=l.useRef(null),[d,a]=l.useState({top:0,right:0}),f=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(f());const u=()=>a(f());return window.addEventListener("scroll",u,!0),window.addEventListener("resize",u),()=>{window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",u)}},[f]),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 g=e.items?.length??0,p=()=>{r({...e,items:[],logicOperator:"and"})},b=t.jsxs("div",{ref:s,className:"ogx-toolbar__panel ogx-toolbar__panel--filter",role:"dialog","aria-label":"Advanced filters",style:{top:d.top,right:d.right,width:540,maxWidth:"calc(100vw - 24px)"},children:[t.jsxs("div",{className:"ogx-toolbar__panel-header",children:[t.jsxs("span",{className:"ogx-toolbar__panel-title",children:[t.jsx(fo,{}),"Filters",g>0&&t.jsx("span",{className:"ogx-toolbar__panel-count",children:g})]}),g>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(co,{columns:o,filterModel:e,onFilterModelChange:r})})]});return kt.createPortal(b,document.body)}const Yr={rowFields:[],columnFields:[],valueFields:[]};function Xr({columns:n=[],aggregationModel:o={},onAggregationModelChange:e,pivotModel:r,onPivotModelChange:i,filterModel:s,onFilterModelChange:d,columnVisibilityModel:a={},onColumnVisibilityModelChange:f,forceColumnsOpen:g,onColumnsPanelClose:p,children:b,rightContent:u,style:h}){const[w,m]=l.useState(!1),[I,M]=l.useState(!1),[E,C]=l.useState(!1),[_,j]=l.useState(!1);l.useEffect(()=>{g&&(C(!0),m(!1),M(!1),j(!1))},[g]);const y=l.useRef(null),P=l.useRef(null),k=l.useRef(null),x=l.useRef(null),S=r??Yr,R=S.rowFields.length>0||S.columnFields.length>0||S.valueFields.length>0,B=n.filter(F=>F.aggregable!==!1&&(F.type==="number"||F.aggregable===!0)),Y=Object.keys(o).filter(F=>o[F]&&o[F]!=="none").length,$=l.useCallback((F,A)=>{if(!e)return;const O={...o};A==="none"?delete O[F]:O[F]=A,e(O)},[o,e]),K=l.useCallback(()=>{e?.({})},[e]),q=l.useCallback(F=>{if(!d)return;const O={...s||{},quickFilterValues:F?[F]:[],items:s?.items||[]};d(O)},[s,d]),D=s?.quickFilterValues?.[0]||"",Z=s?.items?.length||0,J=new Set(n.filter(F=>a[F.field]!==!1).map(F=>F.field)),he=l.useCallback((F,A)=>{if(!f)return;const O={...a,[F]:A};f(O)},[a,f]),v=l.useCallback(()=>{if(!f)return;const F={...a};n.forEach(A=>{A.hideable!==!1&&(F[A.field]=!0)}),f(F)},[n,a,f]),H=l.useCallback(()=>{if(!f)return;const F={...a};n.forEach(A=>{A.hideable!==!1&&(F[A.field]=!1)}),f(F)},[n,a,f]);return t.jsxs("div",{className:"ogx-toolbar",role:"toolbar","aria-label":"Grid toolbar",style:h,children:[b&&t.jsx("div",{className:"ogx-toolbar__left",children:b}),t.jsx("div",{className:"ogx-toolbar__spacer"}),t.jsxs("div",{className:"ogx-toolbar__actions",children:[d&&t.jsx("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:t.jsx(Hr,{value:D,onChange:q,placeholder:"Search..."})}),f&&t.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[t.jsx(Zt,{title:"Columns",children:t.jsx("button",{ref:k,className:`ogx-toolbar__icon-btn${E?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Manage columns",onClick:()=>{C(!E),m(!1),M(!1),j(!1)},children:t.jsx(Gr,{})})}),E&&t.jsx(Ur,{anchorRef:k,columns:n,visibleColumns:J,onVisibilityChange:he,onShowAll:v,onHideAll:H,onClose:()=>{C(!1),p?.()}})]}),d&&t.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[t.jsx(Zt,{title:"Filters",children:t.jsxs("button",{ref:x,className:`ogx-toolbar__icon-btn${_?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Advanced filters",onClick:()=>{j(!_),m(!1),M(!1),C(!1)},children:[t.jsx(fo,{}),Z>0&&t.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Filters active"})]})}),_&&t.jsx(Kr,{anchorRef:x,columns:n,filterModel:s||{items:[]},onFilterModelChange:d,onClose:()=>j(!1)})]}),i&&t.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[t.jsx(Zt,{title:"Pivot",children:t.jsxs("button",{ref:P,id:"ogx-pivot-btn",className:`ogx-toolbar__icon-btn${I?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure pivot","aria-expanded":I,"aria-controls":"ogx-pivot-panel",onClick:()=>{M(!I),m(!1),C(!1),j(!1)},children:[t.jsx(uo,{}),R&&t.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Pivot active"})]})}),I&&t.jsx(zr,{anchorRef:P,columns:n,model:S,onChange:F=>{i?.(F)},onClose:()=>M(!1)})]}),t.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[t.jsx(Zt,{title:"Summaries",children:t.jsxs("button",{ref:y,id:"ogx-aggregation-btn",className:`ogx-toolbar__icon-btn${w?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure summaries","aria-expanded":w,"aria-controls":"ogx-aggregation-panel",onClick:()=>{m(!w),M(!1),C(!1),j(!1)},children:[t.jsx(go,{}),Y>0&&t.jsx("span",{className:"ogx-toolbar__dot","aria-label":`${Y} active summaries`})]})}),w&&t.jsx(Vr,{anchorRef:y,aggregationModel:o,aggregableColumns:B,onFunctionChange:$,onClearAll:K,onClose:()=>m(!1),activeCount:Y})]}),u]})]})}function qr(){return l.useRef(null)}const Jr=({fullWidth:n=!1,error:o=!1,startAdornment:e,endAdornment:r,className:i="",...s})=>{const d=["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:d,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 Qr(n,o,e={}){const{fileName:r="export.csv",includeHeaders:i=!0,delimiter:s=",",selectedRows:d}=e,a=d&&d.length>0?n.filter(p=>d.includes(p.id)):n;if(a.length===0){console.warn("No rows to export");return}const f=o.filter(p=>!(p.field==="__check__"||p.field==="__actions__"));let g="";if(i){const p=f.map(b=>Tt(b.headerName||b.field));g+=p.join(s)+`
|
|
9
|
-
`}if(a.forEach(p=>{const
|
|
10
|
-
`}),e.aggregationResult){const p=e.aggregationResult,
|
|
11
|
-
`;const h=
|
|
12
|
-
`}Mn(
|
|
13
|
-
`)?`"${n.replace(/"/g,'""')}"`:n}function
|
|
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(`
|
|
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)+`
|
|
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
|
+
`}),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
|
+
`;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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}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(`
|
|
14
14
|
<!DOCTYPE html>
|
|
15
15
|
<html>
|
|
16
16
|
<head>
|
|
@@ -30,7 +30,7 @@ ${p}`;try{await Pr(b)}catch(u){console.error("[OpenGridX] Failed to copy to clip
|
|
|
30
30
|
</div>
|
|
31
31
|
</body>
|
|
32
32
|
</html>
|
|
33
|
-
`),r.document.close(),await new Promise(i=>setTimeout(i,100));try{let i="Print",s,
|
|
33
|
+
`),r.document.close(),await new Promise(i=>setTimeout(i,100));try{let i="Print",s,c=null,a=null;typeof e=="string"?i=e:typeof e=="object"&&(i=e.title||"Print",s=e.selectedRows,c=e.aggregationResult||null,a=e.aggregationModel||null);const g=s&&s.length>0?n.filter(u=>s.includes(u.id)):n;if(g.length===0){r.document.body.innerHTML="<h3>No rows to export</h3>";return}const f=o.filter(u=>!(u.field==="__check__"||u.field==="__actions__"));let p=`
|
|
34
34
|
<!DOCTYPE html>
|
|
35
35
|
<html>
|
|
36
36
|
<head>
|
|
@@ -49,5 +49,5 @@ ${p}`;try{await Pr(b)}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>",g.forEach(u=>{p+=`<th>${dt(u.headerName||u.field)}</th>`}),p+="</tr></thead>",p+="<tbody>",f.forEach(u=>{p+="<tr>",g.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>"}),d){const u=a||{};p+='<tfoot><tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',g.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;">',g.forEach(h=>{const w=d[h.field];if(w!=null){let m=w;h.valueFormatter?m=h.valueFormatter({value:w,row:{},field:h.field}):u[h.field]&&(m=bt(w,u[h.field])),p+=`<td style="text-align: right;">${dt(String(m))}</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 b=!1;r.onload=()=>{b||(b=!0,r.print(),setTimeout(()=>{r.close()},100))},setTimeout(()=>{!b&&r&&!r.closed&&(b=!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 ni(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 oi(n){if(n.type==="number")return"#,##0.##";if(n.type==="date")return"yyyy-mm-dd"}function ri(n,o){if(o!=null)return o;const e=n.width??120;return Math.min(60,Math.max(8,(e-5)/7))}function ii(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 li(n){const o=await Promise.allSettled(n.map(async r=>{if(r.startsWith("data:")){const a=r.indexOf(","),f=r.slice(0,a),g=r.slice(a+1),p=atob(g),b=new Uint8Array(p.length);for(let m=0;m<p.length;m++)b[m]=p.charCodeAt(m);const h=f.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:b.buffer,ext:w}}const i=await fetch(r,{mode:"cors"});if(!i.ok)throw new Error(`HTTP ${i.status}`);const s=await i.arrayBuffer(),d=ii(r,i.headers.get("content-type"));return{url:r,buffer:s,ext:d}})),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 si(n,o,e={}){const{fileName:r="export.xlsx",sheets:i,columnStyles:s={},headerFillColor:d="#f1f5f9",headerTextColor:a="#334155",headerFontSize:f=10,bodyFontSize:g=10,aggregationResult:p=null,aggregationModel:b=null,selectedRows:u}=e,h=(await import("exceljs")).default,w=new h.Workbook;w.creator="OpenGridX",w.created=new Date;const m=o.filter(k=>k.field!=="__check__"&&k.field!=="__actions__"&&!k.isSpacer),I=n,M=u&&u.length>0?n.filter(k=>u.includes(k.id)):n,E=i??[{name:"Data",rows:"all",includeHeaders:!0,includeSummary:!1}],C=new Map;for(const k of E){if("type"in k&&k.type==="summary"){if(!p||!b)continue;const v=w.addWorksheet(k.name??"Summary");v.addRow(["Summary / Aggregation Totals"]),v.getRow(1).font={bold:!0,size:f+2,color:{argb:wt(a)}},v.addRow([]),v.addRow(["Column","Function","Value"]).eachCell(F=>{F.fill={type:"pattern",pattern:"solid",fgColor:{argb:wt(d)}},F.font={bold:!0,size:f,color:{argb:wt(a)}},F.border=ho()}),m.forEach(F=>{const A=b[F.field],O=p[F.field];if(A==null||O==null)return;let Q=O;F.valueFormatter?Q=F.valueFormatter({value:O,row:{},field:F.field}):Q=bt(O,A);const U=v.addRow([F.headerName??F.field,A.toUpperCase(),Q]);U.getCell(3).alignment={horizontal:"right"},U.getCell(3).font={bold:!0,size:g}}),v.getColumn(1).width=20,v.getColumn(2).width=12,v.getColumn(3).width=18;continue}const x=k,{name:S="Data",rows:R="all",includeHeaders:B=!0,includeSummary:Y=!1,autoFilter:$=!0,frozenHeader:K=!0,alternateRowColor:q="#f8fafc"}=x,D=R==="selected"?M:I,Z=m.filter(v=>s[v.field]?.embedImage);if(Z.length>0){const v=[],H=new Set;if(D.forEach(F=>{Z.forEach(A=>{const O=F[A.field];typeof O=="string"&&O&&!C.has(O)&&!H.has(O)&&(v.push(O),H.add(O))})}),v.length>0){const F=await li(v);for(const[A,{buffer:O,extension:Q}]of F){const U=w.addImage({buffer:O,extension:Q});C.set(A,U)}}}const J=w.addWorksheet(S);if(J.columns=m.map(v=>({key:v.field,width:ri(v,s[v.field]?.width),style:{numFmt:s[v.field]?.numFmt??oi(v)}})),B){const v=m.map(F=>F.headerName??F.field),H=J.addRow(v);H.height=20,H.eachCell((F,A)=>{const O=m[A-1];F.fill={type:"pattern",pattern:"solid",fgColor:{argb:wt(d)}},F.font={bold:!0,size:f,color:{argb:wt(a)}},F.alignment={horizontal:s[O?.field]?.alignment??(O?.type==="number"?"right":"left"),vertical:"middle"},F.border=ho()}),$&&(J.autoFilter={from:{row:1,column:1},to:{row:1,column:m.length}}),K?J.views=[{state:"frozen",ySplit:1,showGridLines:!1}]:J.views=[{showGridLines:!1}]}let he=B?1:0;if(D.forEach((v,H)=>{const F=m.map(O=>{if(s[O.field]?.embedImage)return"";let Q=v[O.field];return O.valueGetter&&(Q=O.valueGetter({row:v,field:O.field,value:Q})),ni(O,Q)==="string"&&O.valueFormatter&&Q!=null&&(Q=O.valueFormatter({value:Q,row:v,field:O.field})),Q}),A=J.addRow(F);if(A.font={size:g},q&&H%2===1&&A.eachCell(O=>{O.fill={type:"pattern",pattern:"solid",fgColor:{argb:wt(q)}}}),A.eachCell((O,Q)=>{const U=m[Q-1];U&&(O.alignment={horizontal:s[U.field]?.alignment??(U.type==="number"?"right":"left"),vertical:"middle"},O.border={bottom:{style:"thin",color:{argb:"FFf1f5f9"}}})}),Z.length>0){const O=Z.reduce((T,se)=>Math.max(T,s[se.field]?.imageHeight??40),0),Q=Math.ceil(O/1.333),U=Q*1.333;A.height=Q,Z.forEach(T=>{const se=m.indexOf(T),ne=v[T.field],xe=typeof ne=="string"?C.get(ne):void 0;if(xe===void 0){A.getCell(se+1).value=typeof ne=="string"?ne:"";return}const Qe=s[T.field],z=Qe?.imageWidth??40,Se=Qe?.imageHeight??40,ct=(J.getColumn(se+1).width??8)*7+5,Be=Math.max(0,ct-z)/2,ut=Math.max(0,U-Se)/2;J.addImage(xe,{tl:{col:se,row:he,nativeColOff:Math.floor(Be*9525),nativeRowOff:Math.floor(ut*9525)},ext:{width:z,height:Se},editAs:"oneCell"})})}else A.height=16;he++}),Y&&p&&b){const v=m.map(O=>{const Q=b[O.field];return Q?Q.toUpperCase():""}),H=J.addRow(v);H.height=16,H.font={size:g-1,italic:!0,color:{argb:"FF94a3b8"}},H.eachCell(O=>{O.alignment={horizontal:"right",vertical:"middle"},O.border={top:{style:"thin",color:{argb:"FFcbd5e1"}}}});const F=m.map(O=>{const Q=b[O.field],U=p[O.field];return Q==null||U==null?"":O.valueFormatter?O.valueFormatter({value:U,row:{},field:O.field}):bt(U,Q)}),A=J.addRow(F);A.height=18,A.font={bold:!0,size:g,color:{argb:wt(a)}},A.eachCell(O=>{O.fill={type:"pattern",pattern:"solid",fgColor:{argb:wt(d)}},O.alignment={horizontal:"right",vertical:"middle"},O.border=ai()})}}const _=await w.xlsx.writeBuffer(),j=new Blob([_],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),y=URL.createObjectURL(j),P=document.createElement("a");P.href=y,P.download=r.endsWith(".xlsx")?r:`${r}.xlsx`,document.body.appendChild(P),P.click(),document.body.removeChild(P),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 ho(){return{bottom:{style:"medium",color:{argb:"FFcbd5e1"}}}}function ai(){return{top:{style:"medium",color:{argb:"FFcbd5e1"}}}}const di={"--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 ci(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 ui({theme:n,children:o,className:e,style:r}){const i=l.useMemo(()=>({...di,...ci(n)}),[n]);return t.jsx("div",{className:e,style:{...r,...i},children:o})}const gi={colors:{primary:"#60a5fa",primaryDark:"#3b82f6",primaryLight:"#1e3a5f",primaryFocus:"rgba(96, 165, 250, 0.4)"},grid:{background:"#0f172a",headerBackground:"#1e293b",headerText:"#e2e8f0",headerHoverBackground:"#334155",headerSortedBackground:"#1e3a5f",rowText:"#cbd5e1",borderColor:"#334155",rowHoverBackground:"#1e293b",rowAlternateBackground:"#162032",rowSelectedBackground:"#1e3a5f",rowSelectedHoverBackground:"#1d4ed8",cellFocusBorder:"#60a5fa",checkboxBg:"#1e293b",checkboxBorder:"#64748b"},borders:{color:"#334155",colorHover:"#475569"},shadows:{sm:"0 1px 2px 0 rgba(0, 0, 0, 0.3)",md:"0 4px 6px -1px rgba(0, 0, 0, 0.3)"},toolbar:{background:"transparent",text:"#cbd5e1",border:"#334155",buttonBackground:"transparent",buttonHoverBackground:"#1e293b",buttonText:"#e2e8f0",buttonPrimaryBackground:"#3b82f6",buttonPrimaryHoverBackground:"#2563eb",buttonPrimaryText:"#ffffff",buttonDangerBackground:"rgba(239, 68, 68, 0.15)",buttonDangerHoverBackground:"rgba(239, 68, 68, 0.25)",buttonDangerText:"#fca5a5",inputBackground:"#0f172a",inputText:"#f8fafc",inputBorder:"#334155",inputFocusBorder:"#60a5fa",inputFocusShadow:"0 0 0 3px rgba(96, 165, 250, 0.2)",chipBackground:"#1e293b",chipText:"#94a3b8",chipActiveBackground:"rgba(96, 165, 250, 0.2)",chipActiveText:"#60a5fa"},overlays:{background:"#1e293b",text:"#f8fafc",border:"#334155",shadow:"0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3)",itemHoverBackground:"#334155",itemHoverText:"#ffffff",itemSelectedBackground:"rgba(96, 165, 250, 0.15)",itemSelectedText:"#60a5fa",itemDangerBackground:"rgba(239, 68, 68, 0.15)",itemDangerText:"#fca5a5"},scrollbar:{thumbColor:"rgba(148, 163, 184, 0.2)",trackColor:"transparent"},skeleton:{baseColor:"#1e293b",highlightColor:"#334155",darkBaseColor:"#0f172a",darkHighlightColor:"#1e293b"}},fi={colors:{primary:"#e11d48",primaryDark:"#be123c",primaryLight:"#fff1f2",primaryFocus:"rgba(225, 29, 72, 0.4)"},grid:{headerBackground:"#fff1f2",headerHoverBackground:"#ffe4e6",headerSortedBackground:"#fecdd3",rowAlternateBackground:"#fff8f8",rowSelectedBackground:"#ffe4e6",rowSelectedHoverBackground:"#fecdd3",cellFocusBorder:"#e11d48"}},hi={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"}},pi={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"}},xi={grid:{rowHeightCompact:"28px",rowHeightStandard:"36px",rowHeightComfortable:"48px",headerHeight:"40px",cellPaddingX:"8px",cellPaddingY:"4px"},typography:{fontSizeSm:"0.8rem",fontSizeMd:"0.875rem"}};function mi(n,o){try{const e=o.getItem(n);return e?JSON.parse(e):void 0}catch{return}}function bi(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 wi(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,d=l.useMemo(()=>{if(s)return mi(e,s)},[e]),a=l.useRef(null),f=l.useRef(null),g=l.useCallback(()=>{f.current&&s&&bi(e,f.current,i,s)},[e,i,s]),p=l.useCallback(u=>{f.current=u,a.current&&clearTimeout(a.current),a.current=setTimeout(g,r)},[g,r]);l.useEffect(()=>()=>{a.current&&(clearTimeout(a.current),g())},[g]);const b=l.useCallback(()=>{s&&s.removeItem(e)},[e,s]);return{initialState:d,onStateChange:p,clearState:b}}oe.Button=Qt,oe.Cell=no,oe.Checkbox=qt,oe.DataGrid=Rr,oe.DataGridThemeProvider=ui,oe.FilterPanel=co,oe.GridToolbar=Xr,oe.GridTooltip=Zt,oe.Header=to,oe.Input=Jr,oe.Row=Jt,oe.Skeleton=Fr,oe.amberTheme=pi,oe.compactTheme=xi,oe.darkTheme=gi,oe.emeraldTheme=hi,oe.exportToCsv=Qr,oe.exportToExcel=Zr,oe.exportToExcelAdvanced=si,oe.exportToJson=ei,oe.formatAggregationValue=bt,oe.printGrid=ti,oe.roseTheme=fi,oe.useAggregation=io,oe.useGridApiRef=qr,oe.useGridStateStorage=wi,oe.usePivot=lo,Object.defineProperty(oe,Symbol.toStringTag,{value:"Module"})}));
|
|
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"})}));
|
|
53
53
|
//# sourceMappingURL=opengridx.umd.js.map
|