@opencorestack/opengridx 2.0.4 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. package/CHANGELOG.md +408 -3
  2. package/README.md +93 -72
  3. package/dist/index.d.ts +611 -121
  4. package/dist/opengridx.css +1 -1
  5. package/dist/opengridx.es.js +7992 -5650
  6. package/dist/opengridx.es.js.map +1 -1
  7. package/dist/opengridx.umd.js +17 -23
  8. package/dist/opengridx.umd.js.map +1 -1
  9. package/docs/API_REFERENCE.md +348 -161
  10. package/docs/README.md +6 -1
  11. package/docs/architecture/datagrid-orchestration.md +81 -0
  12. package/docs/architecture/grid-row-meta.md +102 -0
  13. package/docs/architecture/use-grid-columns.md +128 -0
  14. package/docs/architecture/use-grid-controlled-state.md +157 -0
  15. package/docs/architecture/use-grid-row-pipeline.md +120 -0
  16. package/docs/architecture/use-grid-scroll-sync.md +111 -0
  17. package/docs/architecture/use-grid-state-snapshot.md +90 -0
  18. package/docs/architecture/use-grid-virtualization.md +115 -0
  19. package/docs/architecture/use-grid-visible-rows.md +85 -0
  20. package/docs/assets/banner-alt.png +0 -0
  21. package/docs/assets/banner.png +0 -0
  22. package/docs/assets/hero.png +0 -0
  23. package/docs/assets/logo.png +0 -0
  24. package/docs/components/aggregation-footer.md +15 -10
  25. package/docs/components/cell.md +16 -6
  26. package/docs/components/column-group-header.md +55 -28
  27. package/docs/components/column-resize.md +17 -13
  28. package/docs/components/column-visibility.md +45 -22
  29. package/docs/components/datagrid.md +14 -12
  30. package/docs/components/empty-state.md +2 -1
  31. package/docs/components/error-overlay.md +12 -7
  32. package/docs/components/filter-panel.md +28 -8
  33. package/docs/components/header.md +28 -9
  34. package/docs/components/pagination.md +14 -8
  35. package/docs/components/row.md +21 -5
  36. package/docs/components/toolbar.md +27 -9
  37. package/docs/components/tooltip.md +16 -7
  38. package/docs/customization/slots-api.md +100 -36
  39. package/docs/customization/theming.md +66 -18
  40. package/docs/features/aggregation-pivot.md +75 -9
  41. package/docs/features/cell-spanning.md +80 -125
  42. package/docs/features/clipboard.md +41 -16
  43. package/docs/features/custom-pagination.md +38 -18
  44. package/docs/features/data-source.md +36 -13
  45. package/docs/features/editing-reordering.md +125 -16
  46. package/docs/features/export-guide.md +147 -41
  47. package/docs/features/filtering.md +44 -6
  48. package/docs/features/infinite-scroll.md +54 -46
  49. package/docs/features/keyboard-navigation.md +83 -0
  50. package/docs/features/list-view.md +58 -5
  51. package/docs/features/loading-states.md +18 -20
  52. package/docs/features/master-detail.md +18 -5
  53. package/docs/features/pdf-export.md +56 -19
  54. package/docs/features/pinning.md +23 -5
  55. package/docs/features/selection.md +50 -10
  56. package/docs/features/sorting-pagination.md +66 -14
  57. package/docs/features/state-persistence.md +78 -10
  58. package/docs/features/toolbar-customization.md +26 -17
  59. package/docs/features/tree-data-grouping.md +44 -9
  60. package/docs/features/virtualization.md +64 -15
  61. package/docs/migration/v1-to-v2.md +115 -0
  62. package/docs/migration/v2-to-v3.md +1222 -0
  63. package/docs/performance.md +124 -0
  64. package/docs/roadmap.md +16 -10
  65. package/lib/components/Cell/Cell.css +13 -1
  66. package/lib/components/Cell/Cell.tsx +130 -57
  67. package/lib/components/Cell/CellErrorBoundary.tsx +12 -6
  68. package/lib/components/Cell/GridEditInputCell.tsx +114 -41
  69. package/lib/components/ColumnGroupHeader/ColumnGroupHeader.css +7 -1
  70. package/lib/components/ColumnResizeHandle/ColumnResizeHandle.css +11 -0
  71. package/lib/components/ColumnResizeHandle/ColumnResizeHandle.tsx +104 -38
  72. package/lib/components/ColumnResizeHandle/clampResizeWidth.ts +13 -0
  73. package/lib/components/ColumnVisibilityPanel/ColumnVisibilityPanel.css +6 -0
  74. package/lib/components/ColumnVisibilityPanel/ColumnVisibilityPanel.tsx +21 -13
  75. package/lib/components/DataGrid/DataGrid.css +84 -12
  76. package/lib/components/DataGrid/DataGrid.tsx +606 -872
  77. package/lib/components/DataGrid/GridAggregationFooter.tsx +53 -17
  78. package/lib/components/DataGrid/GridEmptyState.tsx +7 -1
  79. package/lib/components/DataGrid/GridErrorOverlay.tsx +15 -12
  80. package/lib/components/DataGrid/GridListView.tsx +166 -23
  81. package/lib/components/DataGrid/GridLiveRegion.tsx +31 -0
  82. package/lib/components/DataGrid/GridLoadingOverlay.tsx +27 -0
  83. package/lib/components/DataGrid/GridPaginationArea.tsx +44 -0
  84. package/lib/components/DataGrid/GridPinnedRows.tsx +65 -11
  85. package/lib/components/DataGrid/GridStandaloneColumnPanel.tsx +40 -38
  86. package/lib/components/DataGrid/GridToolbarSlot.tsx +51 -0
  87. package/lib/components/DataGrid/GridVirtualRows.tsx +48 -25
  88. package/lib/components/DetailPanel/DetailPanel.css +0 -6
  89. package/lib/components/DetailPanel/DetailPanel.tsx +34 -5
  90. package/lib/components/DetailPanel/DetailPanelContent.tsx +17 -0
  91. package/lib/components/FilterPanel/FilterPanel.css +13 -2
  92. package/lib/components/FilterPanel/FilterPanel.tsx +272 -99
  93. package/lib/components/Header/ColumnMenu.tsx +91 -39
  94. package/lib/components/Header/Header.css +3 -3
  95. package/lib/components/Header/Header.tsx +179 -160
  96. package/lib/components/ListView/ListView.css +25 -0
  97. package/lib/components/ListView/ListViewRow.tsx +79 -10
  98. package/lib/components/Pagination/Pagination.tsx +15 -7
  99. package/lib/components/Row/Row.tsx +185 -75
  100. package/lib/components/Toolbar/GlobalSearch.css +6 -3
  101. package/lib/components/Toolbar/GlobalSearch.tsx +26 -27
  102. package/lib/components/Toolbar/GridToolbar.css +12 -11
  103. package/lib/components/Toolbar/GridToolbar.tsx +133 -89
  104. package/lib/components/Toolbar/PivotPanel.tsx +89 -49
  105. package/lib/components/Tooltip/Tooltip.css +20 -0
  106. package/lib/components/Tooltip/Tooltip.tsx +68 -35
  107. package/lib/components/ui/Button.tsx +3 -0
  108. package/lib/components/ui/Checkbox.tsx +2 -1
  109. package/lib/components/ui/ExpandIcon.css +0 -9
  110. package/lib/components/ui/ExpandIcon.tsx +4 -1
  111. package/lib/hooks/core/gridApiPlaceholder.ts +34 -0
  112. package/lib/hooks/core/gridToolbarHostContext.ts +14 -0
  113. package/lib/hooks/core/useDataGrid.ts +115 -173
  114. package/lib/hooks/core/useGridAggregationApi.ts +72 -0
  115. package/lib/hooks/core/useGridApiMethods.ts +115 -0
  116. package/lib/hooks/core/useGridApiRef.ts +15 -3
  117. package/lib/hooks/core/useGridApiRefBinding.ts +18 -0
  118. package/lib/hooks/core/useGridAriaRows.ts +38 -0
  119. package/lib/hooks/core/useGridClipboardApi.ts +38 -0
  120. package/lib/hooks/core/useGridColumnLookup.ts +30 -0
  121. package/lib/hooks/core/useGridColumns.tsx +284 -76
  122. package/lib/hooks/core/useGridColumnsPanel.ts +77 -0
  123. package/lib/hooks/core/useGridControlledState.ts +99 -6
  124. package/lib/hooks/core/useGridDetailPanel.ts +51 -0
  125. package/lib/hooks/core/useGridDevWarnings.ts +123 -0
  126. package/lib/hooks/core/useGridFocusHandlers.ts +50 -0
  127. package/lib/hooks/core/useGridGroupingColumn.ts +62 -0
  128. package/lib/hooks/core/useGridHeaderHandlers.ts +92 -0
  129. package/lib/hooks/core/useGridHierarchy.ts +81 -0
  130. package/lib/hooks/core/useGridKeyboardNavigation.ts +452 -250
  131. package/lib/hooks/core/useGridLiveRowSelection.ts +67 -0
  132. package/lib/hooks/core/useGridPageCorrection.ts +55 -0
  133. package/lib/hooks/core/useGridRowIdOf.ts +32 -0
  134. package/lib/hooks/core/useGridRowInteractions.ts +81 -0
  135. package/lib/hooks/core/useGridRowPipeline.ts +69 -39
  136. package/lib/hooks/core/useGridRowSelection.ts +91 -0
  137. package/lib/hooks/core/useGridScrollSync.ts +80 -32
  138. package/lib/hooks/core/useGridScrollToIndexesApi.ts +45 -0
  139. package/lib/hooks/core/useGridStateSnapshot.ts +40 -5
  140. package/lib/hooks/core/useGridThemeDimensions.ts +49 -0
  141. package/lib/hooks/core/useGridToolbarProps.ts +97 -0
  142. package/lib/hooks/core/useGridViewport.ts +38 -0
  143. package/lib/hooks/core/useGridViewportSize.ts +26 -0
  144. package/lib/hooks/core/useGridVisibleRows.ts +20 -7
  145. package/lib/hooks/core/useLayout.ts +215 -195
  146. package/lib/hooks/core/useRowsScrollEndLatch.ts +41 -0
  147. package/lib/hooks/core/useStableColumns.ts +34 -0
  148. package/lib/hooks/features/useAggregation.ts +86 -90
  149. package/lib/hooks/features/useColumnGroupReorderGuard.ts +34 -0
  150. package/lib/hooks/features/useDetailPanelHeights.ts +29 -0
  151. package/lib/hooks/features/useGridClipboard.ts +133 -73
  152. package/lib/hooks/features/useGridDataSource.ts +354 -128
  153. package/lib/hooks/features/useGridEditing.ts +211 -51
  154. package/lib/hooks/features/useGridPivot.ts +92 -0
  155. package/lib/hooks/features/useGridSpanRenderWindow.ts +104 -0
  156. package/lib/hooks/features/useGridSpanning.ts +410 -306
  157. package/lib/hooks/features/usePivot.ts +0 -0
  158. package/lib/hooks/features/useServerTreeChildren.ts +50 -0
  159. package/lib/hooks/useColumnReorder.ts +38 -44
  160. package/lib/hooks/useRowGrouping.ts +335 -214
  161. package/lib/hooks/useRowReorder.ts +62 -31
  162. package/lib/hooks/useTreeData.ts +330 -262
  163. package/lib/index.ts +30 -2
  164. package/lib/state/index.ts +1 -0
  165. package/lib/state/types.ts +7 -1
  166. package/lib/state/useGridStateStorage.ts +88 -29
  167. package/lib/theme/DataGridThemeProvider.tsx +143 -38
  168. package/lib/theme/gridThemeContext.ts +5 -0
  169. package/lib/theme/index.ts +5 -0
  170. package/lib/theme/presets.ts +5 -4
  171. package/lib/theme/types.ts +40 -2
  172. package/lib/types/index.ts +311 -108
  173. package/lib/utils/aggregation/index.ts +157 -0
  174. package/lib/utils/aria/index.ts +40 -0
  175. package/lib/utils/columnGroups.ts +110 -0
  176. package/lib/utils/columnLookup.ts +33 -0
  177. package/lib/utils/columnWidth.ts +22 -0
  178. package/lib/utils/dataSource/index.ts +46 -0
  179. package/lib/utils/detailPanel.ts +66 -0
  180. package/lib/utils/dragData.ts +44 -0
  181. package/lib/utils/editing/index.ts +30 -0
  182. package/lib/utils/export/exportShared.ts +197 -0
  183. package/lib/utils/export/exportToExcelAdvanced.ts +344 -121
  184. package/lib/utils/export/exportToPdf.ts +143 -92
  185. package/lib/utils/export/groupLabel.ts +14 -0
  186. package/lib/utils/export/index.ts +278 -272
  187. package/lib/utils/export/pdfText.ts +50 -0
  188. package/lib/utils/filtering/index.ts +277 -148
  189. package/lib/utils/focus/index.ts +115 -0
  190. package/lib/utils/gridApiRows.ts +35 -0
  191. package/lib/utils/gridModes.ts +77 -0
  192. package/lib/utils/grouping/groupedExportRows.ts +91 -0
  193. package/lib/utils/pagination/index.ts +56 -0
  194. package/lib/utils/pinning/index.ts +77 -33
  195. package/lib/utils/pivot/index.ts +368 -0
  196. package/lib/utils/scroll/index.ts +78 -0
  197. package/lib/utils/scroll/scrollEnd.ts +18 -0
  198. package/lib/utils/sorting/index.ts +154 -30
  199. package/lib/utils/syntheticRows.ts +12 -0
  200. package/lib/utils/values.ts +206 -0
  201. package/lib/utils/viewport.ts +14 -0
  202. package/llms.txt +272 -166
  203. package/package.json +18 -6
  204. package/lib/components/ColumnGroupHeader/ColumnGroupHeader.tsx +0 -220
  205. package/lib/components/ColumnVisibilityPanel/ColumnVisibilityPanel.test.tsx +0 -85
  206. package/lib/components/DataGrid/DataGrid.regression.test.tsx +0 -132
  207. package/lib/components/DataGrid/DataGrid.smoke.test.tsx +0 -58
  208. package/lib/components/DataGrid/DataGrid.v2.test.tsx +0 -127
  209. package/lib/components/Header/Header.test.tsx +0 -135
  210. package/lib/components/Pagination/Pagination.test.tsx +0 -64
  211. package/lib/hooks/core/useDataGrid.regression.test.ts +0 -66
  212. package/lib/hooks/core/useGridControlledState.test.ts +0 -86
  213. package/lib/hooks/core/useGridKeyboardNavigation.test.ts +0 -176
  214. package/lib/hooks/core/useGridRowPipeline.test.ts +0 -117
  215. package/lib/hooks/features/useAggregation.test.ts +0 -175
  216. package/lib/hooks/features/usePivot.test.ts +0 -202
  217. package/lib/hooks/useRowGrouping.test.ts +0 -137
  218. package/lib/utils/export/exportToPdf.test.ts +0 -120
  219. package/lib/utils/export/groupedExport.test.ts +0 -144
  220. package/lib/utils/filtering/filtering.test.ts +0 -178
  221. package/lib/utils/sorting/sorting.test.ts +0 -88
@@ -1,21 +1,15 @@
1
- (function(ae,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],i):(ae=typeof globalThis<"u"?globalThis:ae||self,i(ae.OpenGridX={},ae.React,ae.ReactDOM))})(this,(function(ae,i,Ge){"use strict";var Rt={exports:{}},ht={};var Cn;function lo(){if(Cn)return ht;Cn=1;var n=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function e(o,l,s){var d=null;if(s!==void 0&&(d=""+s),l.key!==void 0&&(d=""+l.key),"key"in l){s={};for(var a in l)a!=="key"&&(s[a]=l[a])}else s=l;return l=s.ref,{$$typeof:n,type:o,key:d,ref:l!==void 0?l:null,props:s}}return ht.Fragment=t,ht.jsx=e,ht.jsxs=e,ht}var pt={};var yn;function so(){return yn||(yn=1,process.env.NODE_ENV!=="production"&&(function(){function n(C){if(C==null)return null;if(typeof C=="function")return C.$$typeof===k?null:C.displayName||C.name||null;if(typeof C=="string")return C;switch(C){case _:return"Fragment";case v:return"Profiler";case E:return"StrictMode";case y:return"Suspense";case u:return"SuspenseList";case F:return"Activity"}if(typeof C=="object")switch(typeof C.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),C.$$typeof){case m:return"Portal";case N:return C.displayName||"Context";case S:return(C._context.displayName||"Context")+".Consumer";case h:var M=C.render;return C=C.displayName,C||(C=M.displayName||M.name||"",C=C!==""?"ForwardRef("+C+")":"ForwardRef"),C;case j:return M=C.displayName||null,M!==null?M:n(C.type)||"Memo";case P:M=C._payload,C=C._init;try{return n(C(M))}catch{}}return null}function t(C){return""+C}function e(C){try{t(C);var M=!1}catch{M=!0}if(M){M=console;var L=M.error,O=typeof Symbol=="function"&&Symbol.toStringTag&&C[Symbol.toStringTag]||C.constructor.name||"Object";return L.call(M,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",O),t(C)}}function o(C){if(C===_)return"<>";if(typeof C=="object"&&C!==null&&C.$$typeof===P)return"<...>";try{var M=n(C);return M?"<"+M+">":"<...>"}catch{return"<...>"}}function l(){var C=I.A;return C===null?null:C.getOwner()}function s(){return Error("react-stack-top-frame")}function d(C){if(R.call(C,"key")){var M=Object.getOwnPropertyDescriptor(C,"key").get;if(M&&M.isReactWarning)return!1}return C.key!==void 0}function a(C,M){function L(){D||(D=!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)",M))}L.isReactWarning=!0,Object.defineProperty(C,"key",{get:L,configurable:!0})}function f(){var C=n(this.type);return A[C]||(A[C]=!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.")),C=this.props.ref,C!==void 0?C:null}function p(C,M,L,O,H,U){var K=L.ref;return C={$$typeof:g,type:C,key:M,props:L,_owner:O},(K!==void 0?K:null)!==null?Object.defineProperty(C,"ref",{enumerable:!1,get:f}):Object.defineProperty(C,"ref",{enumerable:!1,value:null}),C._store={},Object.defineProperty(C._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(C,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(C,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:H}),Object.defineProperty(C,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:U}),Object.freeze&&(Object.freeze(C.props),Object.freeze(C)),C}function x(C,M,L,O,H,U){var K=M.children;if(K!==void 0)if(O)if(W(K)){for(O=0;O<K.length;O++)w(K[O]);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 w(K);if(R.call(M,"key")){K=n(C);var oe=Object.keys(M).filter(function(ne){return ne!=="key"});O=0<oe.length?"{key: someKey, "+oe.join(": ..., ")+": ...}":"{key: someKey}",V[K+O]||(oe=0<oe.length?"{"+oe.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
- let props = %s;
3
- <%s {...props} />
4
- React keys must be passed directly to JSX without using spread:
5
- let props = %s;
6
- <%s key={someKey} {...props} />`,O,K,oe,K),V[K+O]=!0)}if(K=null,L!==void 0&&(e(L),K=""+L),d(M)&&(e(M.key),K=""+M.key),"key"in M){L={};for(var ie in M)ie!=="key"&&(L[ie]=M[ie])}else L=M;return K&&a(L,typeof C=="function"?C.displayName||C.name||"Unknown":C),p(C,K,L,l(),H,U)}function w(C){b(C)?C._store&&(C._store.validated=1):typeof C=="object"&&C!==null&&C.$$typeof===P&&(C._payload.status==="fulfilled"?b(C._payload.value)&&C._payload.value._store&&(C._payload.value._store.validated=1):C._store&&(C._store.validated=1))}function b(C){return typeof C=="object"&&C!==null&&C.$$typeof===g}var c=i,g=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),_=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),N=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),j=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),F=Symbol.for("react.activity"),k=Symbol.for("react.client.reference"),I=c.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,R=Object.prototype.hasOwnProperty,W=Array.isArray,$=console.createTask?console.createTask:function(){return null};c={react_stack_bottom_frame:function(C){return C()}};var D,A={},z=c.react_stack_bottom_frame.bind(c,s)(),Y=$(o(s)),V={};pt.Fragment=_,pt.jsx=function(C,M,L){var O=1e4>I.recentlyCreatedOwnerStacks++;return x(C,M,L,!1,O?Error("react-stack-top-frame"):z,O?$(o(C)):Y)},pt.jsxs=function(C,M,L){var O=1e4>I.recentlyCreatedOwnerStacks++;return x(C,M,L,!0,O?Error("react-stack-top-frame"):z,O?$(o(C)):Y)}})()),pt}var kn;function ao(){return kn||(kn=1,process.env.NODE_ENV==="production"?Rt.exports=lo():Rt.exports=so()),Rt.exports}var r=ao();function xt(n,t){return t?t.left?.includes(n)?"left":t.right?.includes(n)?"right":null:null}function co(n,t){const e=[],o=[],l=[];return t?(n.forEach(s=>{const d=xt(s.field,t);d==="left"?e.push(s):d==="right"?l.push(s):o.push(s)}),t.left&&e.sort((s,d)=>{const a=t.left.indexOf(s.field),f=t.left.indexOf(d.field);return a-f}),t.right&&l.sort((s,d)=>{const a=t.right.indexOf(s.field),f=t.right.indexOf(d.field);return a-f}),{left:e,center:o,right:l}):{left:e,center:n,right:l}}function Xt(n,t,e,o,l,s,d,a){const f={};if(!e)return f;const p=co(n,e);let x=0;a&&(x+=48),s&&d&&(x+=48),o&&l&&(x+=48),p.left.forEach(b=>{f[b.field]=x;const c=t[b.field]??b.width??100;x+=c});let w=0;return[...p.right].reverse().forEach(b=>{const c=t[b.field]??b.width??100;f[b.field]=w,w+=c}),f}function Jt(n,t){return t?t.top?.includes(n)?"top":t.bottom?.includes(n)?"bottom":null:null}function uo(n,t){const e=[],o=[],l=[];return t?(n.forEach(s=>{const d=Jt(s.id,t);d==="top"?e.push(s):d==="bottom"?l.push(s):o.push(s)}),t.top&&e.sort((s,d)=>{const a=t.top.indexOf(s.id),f=t.top.indexOf(d.id);return a-f}),t.bottom&&l.sort((s,d)=>{const a=t.bottom.indexOf(s.id),f=t.bottom.indexOf(d.id);return a-f}),{top:e,center:o,bottom:l}):{top:e,center:n,bottom:l}}function qe(n){if(n===void 0)return{type:"auto",value:0};if(typeof n=="number")return{type:"fixed",value:n};if(typeof n=="string"){if(n.toLowerCase()==="auto")return{type:"auto",value:0};if(n.endsWith("%"))return{type:"percentage",value:parseFloat(n)};const t=parseFloat(n);if(!isNaN(t))return{type:"fixed",value:t}}return{type:"fixed",value:100}}function fo(n){const{rowHeight:t,pagination:e,paginatedUnpinnedRows:o,sortedUnpinnedRows:l,expandedRowIds:s,getDetailPanelHeight:d,pinnedTopRowsLength:a,pinnedBottomRowsLength:f,visibleOrderedColumns:p,pinnedColumns:x,columnWidths:w,viewportWidth:b,checkboxSelection:c,hasDetailPanel:g,rowReordering:m,paginationMode:_,isLoading:E,pageSize:v}=n;return i.useMemo(()=>{const S=e?o:l,N=S.map((B,Q)=>{let Z=t;if(s.has(B.id)){const ge=d?.({row:B,id:B.id,rowIndex:a+Q})??200;Z+=typeof ge=="number"?ge:parseInt(String(ge),10)||200}return Z}),h=N.reduce((B,Q,Z)=>(B.push((B[Z-1]||0)+Q),B),[]),y=_==="infinite"&&E&&S.length>0?Math.min(v,20):0,u=(h[h.length-1]||0)+y*t,j=a*t,P=f*t,F=[],k=[],I=[],R=[];p.forEach(B=>{const Q=xt(B.field,x);Q==="left"?F.push(B):Q==="right"?k.push(B):I.push(B)});const W=(c?48:0)+(g?48:0)+(m?48:0),$=B=>w[B.field]??B.width,D=F.reduce((B,Q)=>{const Z=qe($(Q));return B+(Z.type==="fixed"?Z.value:100)},0),A=k.reduce((B,Q)=>{const Z=qe($(Q));return B+(Z.type==="fixed"?Z.value:100)},0),z=I.reduce((B,Q)=>{if(!Object.prototype.hasOwnProperty.call(w,Q.field)&&Q.flex&&Q.flex>0){const ce=Q.minWidth??150,Ee=typeof Q.width=="number"?Q.width:150;return B+(ce||Ee)}const ge=qe($(Q));return ge.type==="fixed"?B+ge.value:ge.type==="percentage"?B+100:B+(Q.minWidth??150)},0),Y=Math.max(b-W-D-A,z),V=[],C=[],M=[];I.forEach(B=>{const Q=Object.prototype.hasOwnProperty.call(w,B.field),Z=qe($(B));if(!Q&&B.flex&&B.flex>0){M.push({col:B,flex:B.flex});return}Z.type==="fixed"?V.push({col:B,width:Z.value}):Z.type==="percentage"?C.push({col:B,percentage:Z.value}):M.push({col:B,flex:1})});const L=V.reduce((B,{width:Q})=>B+Q,0);let O=Math.max(0,Y-L);const H=new Map;C.forEach(({col:B,percentage:Q})=>{const Z=Q/100*O;H.set(B.field,Z),O-=Z}),O=Math.max(0,O);const U=new Map,K=M.map(B=>({...B,minWidth:B.col.minWidth??50,maxWidth:B.col.maxWidth??1/0,frozen:!1,computedWidth:0}));(()=>{let B=0;const Q=K.length*2;for(;B<Q;){B++;const Z=K.filter(ee=>!ee.frozen);if(Z.length===0)break;const ge=Z.reduce((ee,ye)=>ee+ye.flex,0),ce=K.reduce((ee,ye)=>ye.frozen?ee+ye.computedWidth:ee,0),Ee=Math.max(0,O-ce);if(ge<=0){Z.forEach(ee=>{ee.computedWidth=ee.minWidth,ee.frozen=!0});break}const Te=Ee/ge;let Pe=0;const Re=[],ze=[];if(Z.forEach(ee=>{const ye=Te*ee.flex;ye<ee.minWidth?(Pe+=ee.minWidth-ye,Re.push(ee)):ye>ee.maxWidth?(Pe+=ee.maxWidth-ye,ze.push(ee)):ee.computedWidth=ye}),Re.length===0&&ze.length===0){Z.forEach(ee=>ee.frozen=!0);break}Pe>0?Re.forEach(ee=>{ee.computedWidth=ee.minWidth,ee.frozen=!0}):Pe<0?ze.forEach(ee=>{ee.computedWidth=ee.maxWidth,ee.frozen=!0}):(Re.forEach(ee=>{ee.computedWidth=ee.minWidth,ee.frozen=!0}),ze.forEach(ee=>{ee.computedWidth=ee.maxWidth,ee.frozen=!0}))}})(),K.forEach(B=>U.set(B.col.field,B.computedWidth));const ie=new Map;I.forEach(B=>{let Q;if(U.has(B.field))Q=U.get(B.field);else{const Z=V.find(ce=>ce.col.field===B.field),ge=C.find(ce=>ce.col.field===B.field);if(Z)Q=Z.width;else if(ge){const ce=H.get(B.field)||0;Q=Math.max(B.minWidth??50,ce||100)}else Q=100}R.push(Q),ie.set(B.field,Q)});const ne=I.map(B=>{const Q=K.find(Z=>Z.col.field===B.field);return{...B,width:ie.get(B.field)??(typeof B.width=="number"?B.width:100),flex:Q?Q.flex:B.flex}}),T=11,le=F.map((B,Q)=>{const Z=qe($(B));return{...B,width:Z.type==="fixed"?Z.value:100,zIndex:T+Q}}),te=11,re=k.map((B,Q)=>{const Z=qe($(B));return{...B,width:Z.type==="fixed"?Z.value:100,zIndex:te+(k.length-1-Q)}}),q=R.reduce((B,Q)=>B+Q,0),J=D+q+A+W,de=R.reduce((B,Q,Z)=>(B.push((B[Z-1]||0)+Q),B),[]);return{rowHeights:N,cumulativeHeights:h,unpinnedRowsHeight:u,pinnedTopHeight:j,pinnedBottomHeight:P,leftPinnedCols:le,rightPinnedCols:re,unpinnedColsWithWidth:ne,unpinnedColWidths:R,unpinnedAccWidths:de,totalWidth:J,leftWidth:D,rightWidth:A,unpinnedTotalWidth:q,systemColumnsWidth:W,pinnedTopRowsLength:a,pinnedBottomRowsLength:f,unpinnedRowsLength:S.length}},[t,e,o,l,s,d,a,f,p,x,w,b,c,g,m,_,E,v])}function go(n){const{allRenderableRows:t,navigationColumns:e,checkboxSelection:o,selectedRowIds:l,handleSelectionChange:s,handleDetailPanelToggle:d,editingHandlers:a,setKeyboardMode:f,sortModel:p,handleSort:x,isCellEditable:w,pagination:b,pageSize:c,virtualization:g,viewportRef:m}=n,[_,E]=i.useState(null),v=i.useCallback(h=>{h.target===h.currentTarget&&E(y=>{if(y)return y;if(o)return{id:"HEADER",field:"__checkbox_col__"};const u=t[0],j=e[0];return u&&j?{id:u.id,field:j.field}:null})},[t,e,o]),S=i.useCallback(h=>{h.currentTarget.contains(h.relatedTarget)||E(null)},[]),N=i.useCallback(h=>{if(f(!0),!_)return;const{id:y,field:u}=_,j=!!a.editingCell;if(y==="HEADER"&&(h.key==="Enter"||h.key===" ")){h.preventDefault();const A=e.find(z=>z.field===u);if(A&&A.sortable!==!1){const z=p.find(V=>V.field===u);let Y="asc";z&&(Y=z.sort==="asc"?"desc":null),x(u,Y)}return}if(h.key==="Enter"){if(h.preventDefault(),j)a.stopCellEdit();else if(e.find(z=>z.field===u)?.editable){const z=t.find(Y=>Y.id===y);z&&a.startCellEdit({id:y,field:u,value:z[u]})}return}if((h.key===" "||h.key==="Spacebar")&&!j){if(u==="__checkbox_col__"){h.preventDefault(),s(y,!l.has(y));return}if(u==="__expand_col__"){h.preventDefault(),d(y);return}}if(h.key==="Escape"){j&&(h.preventDefault(),a.stopCellEdit({cancel:!0}));return}if(j&&h.key!=="Tab")return;const P=y==="HEADER",F=P?-1:t.findIndex(A=>A.id===y),k=e.findIndex(A=>A.field===u);if(!P&&F===-1||k===-1)return;const I=(A,z,Y,V,C,M=!1)=>{let L=A+Y,O=z+V;return C&&V!==0&&(V>0&&O>=e.length?(O=0,L++):V<0&&O<0&&(O=e.length-1,L--)),!C&&(O<0||O>=e.length)||L<(M?-1:0)||L>=t.length?null:{r:L,c:O}},R=(A,z,Y,V,C,M=!1)=>{let L=A,O=z,H=0;const U=t.length*e.length+e.length;for(;H<U;){if(H++,L+=Y,O+=V,V!==0)V>0?O>=e.length&&(O=0,L++):O<0&&(O=e.length-1,L--);else if(O<0||O>=e.length)return null;if(L<-1||L>=t.length)return null;if(L===-1){if(!M)continue;const T=e[O],le=T.sortable!==!1;if(["__checkbox_col__"].includes(T.field)||le)return{r:L,c:O};continue}const K=t[L],oe=e[O],ie=["__checkbox_col__","__expand_col__","__reorder_col__"].includes(oe.field);let ne=oe.editable||ie;if(w&&!ie)try{ne=w({row:K,field:oe.field,value:K[oe.field],colDef:oe,rowIndex:L,colIndex:O})}catch{}if(ne)return{r:L,c:O}}return null};let W=F,$=k,D=!1;if(h.key==="Tab"){const A=h.shiftKey?-1:1,z=R(F,k,0,A,!0,!1);z&&(W=z.r,$=z.c,D=!0)}else if(h.key==="ArrowRight"){const A=I(F,k,0,1,!0,!0);A&&(W=A.r,$=A.c,D=!0)}else if(h.key==="ArrowLeft"){const A=I(F,k,0,-1,!0,!0);A&&(W=A.r,$=A.c,D=!0)}else if(h.key==="ArrowDown"){const A=I(F,k,1,0,!1,!0);A&&(W=A.r,$=A.c,D=!0)}else if(h.key==="ArrowUp"){const A=I(F,k,-1,0,!1,!0);A&&(W=A.r,$=A.c,D=!0)}else if(h.key==="Home")$=0,(h.ctrlKey||h.metaKey)&&(W=-1),D=!0;else if(h.key==="End")$=e.length-1,(h.ctrlKey||h.metaKey)&&(W=t.length-1),D=!0;else if(h.key==="PageUp")W=Math.max(-1,W-(b?c:10)),D=!0;else if(h.key==="PageDown"){const A=b?c:10;W=Math.min(t.length-1,W+A),D=!0}if(D&&(h.preventDefault(),j&&h.key==="Tab"&&a.stopCellEdit(),W>=-1&&W<t.length&&$>=0&&$<e.length)){const A=e[$];E(W===-1?{id:"HEADER",field:A.field}:{id:t[W].id,field:A.field});const z=m.current;if(z){const{cumulativeHeights:Y,pinnedTopHeight:V,columnMetrics:C}=g,{clientHeight:M,clientWidth:L,scrollTop:O,scrollLeft:H}=z,U=W<=0?0:Y[W-1],K=Y[W],oe=O+V,ie=O+M;let ne=O;if(U<oe?ne=Math.max(0,U-V):K>ie&&(ne=K-M),ne!==O&&(z.scrollTop=ne),C){const{leftPinnedWidth:T,rightPinnedWidth:le,unpinnedAccWidths:te,unpinnedCols:re,totalSpecialsWidth:q,pinnedSpecialsWidth:J}=C,de=re.findIndex(B=>B.field===A.field);if(de!==-1){const B=q+T+(de>0?te[de-1]:0),Q=q+T+te[de],Z=H+J+T,ge=H+L-le;let ce=H;B<Z?ce=Math.max(0,B-J-T):Q>ge&&(ce=Q-L+le),ce!==H&&(z.scrollLeft=ce)}}}}},[_,t,e,a,g,l,s,d,f,p,x,w,b,c,m]);return{focusedCell:_,setFocusedCell:E,handleFocus:v,handleBlur:S,handleKeyDown:N}}const ho={rowFields:[],columnFields:[],valueFields:[]};function po(n){const{initialState:t,sortModel:e,aggregationModel:o,onAggregationModelChange:l,columnVisibilityModel:s,onColumnVisibilityModelChange:d,pinnedColumns:a,onPinnedColumnsChange:f,pivotModel:p,onPivotModelChange:x,paginationModel:w,onPaginationModelChange:b,rowSelectionModel:c}=n,[g,m]=i.useState(()=>t?.sorting?.sortModel??[]),_=e!==void 0,E=_?e:g,v=o!==void 0,[S,N]=i.useState(()=>o??{}),h=v?o:S,y=i.useCallback(T=>{v||N(T),l?.(T)},[v,l]),u=s!==void 0,[j,P]=i.useState(()=>t?.columns?.columnVisibilityModel??{}),F=u?s:j,k=i.useCallback(T=>{u||P(T),d?.(T)},[u,d]),I=a!==void 0,[R,W]=i.useState(()=>t?.columns?.pinnedColumns??{}),$=I?a:R,D=i.useCallback(T=>{I||W(T),f?.(T)},[I,f]),[A,z]=i.useState(()=>p??ho),Y=p??A,V=i.useCallback(T=>{z(T),x?.(T)},[x]),C=w!==void 0,[M,L]=i.useState(()=>t?.pagination?.paginationModel??w??{page:0,pageSize:100}),O=C?w:M,H=i.useCallback(T=>{C||L(T),b?.(T)},[C,b]),U=c!==void 0,[K,oe]=i.useState([]),ie=U?c:K,ne=i.useMemo(()=>new Set(ie),[ie]);return{sortModel:E,isSortControlled:_,setInternalSortModel:m,aggregationModel:h,handleAggregationModelChange:y,columnVisibilityModel:F,handleColumnVisibilityModelChange:k,pinnedColumns:$,handlePinnedColumnsChange:D,currentPivotModel:Y,handlePivotModelChange:V,effectivePaginationModel:O,handlePaginationModelChange:H,rowSelectionModel:ie,selectedRowIds:ne,isSelectionControlled:U,setInternalRowSelectionModel:oe}}const xo={contains:(n,t)=>n==null||t==null?!1:String(n).toLowerCase().includes(String(t).toLowerCase()),equals:(n,t)=>n==null&&t==null?!0:n==null||t==null?!1:String(n).toLowerCase()===String(t).toLowerCase(),startsWith:(n,t)=>n==null||t==null?!1:String(n).toLowerCase().startsWith(String(t).toLowerCase()),endsWith:(n,t)=>n==null||t==null?!1:String(n).toLowerCase().endsWith(String(t).toLowerCase()),isEmpty:n=>n==null||String(n).trim()==="",isNotEmpty:n=>n!=null&&String(n).trim()!=="",">":(n,t)=>{if(n==null||t==null)return!1;const e=Number(n),o=Number(t);return isNaN(e)||isNaN(o)?!1:e>o},">=":(n,t)=>{if(n==null||t==null)return!1;const e=Number(n),o=Number(t);return isNaN(e)||isNaN(o)?!1:e>=o},"<":(n,t)=>{if(n==null||t==null)return!1;const e=Number(n),o=Number(t);return isNaN(e)||isNaN(o)?!1:e<o},"<=":(n,t)=>{if(n==null||t==null)return!1;const e=Number(n),o=Number(t);return isNaN(e)||isNaN(o)?!1:e<=o},"!=":(n,t)=>{if(t==null||t==="")return!0;const e=Number(n),o=Number(t);return!isNaN(e)&&!isNaN(o)?e!==o:String(n).toLowerCase()!==String(t).toLowerCase()},isAnyOf:(n,t)=>n==null||!Array.isArray(t)?!1:t.some(e=>String(n).toLowerCase()===String(e).toLowerCase()),not:(n,t)=>n==null&&t==null?!1:n==null||t==null?!0:String(n).toLowerCase()!==String(t).toLowerCase(),is:(n,t)=>{if(t==null||t==="")return!0;const e=String(n).toLowerCase(),o=String(t).toLowerCase();return e===o},"=":(n,t)=>n==null||t==null||t===""?!1:Number(n)===Number(t)};function mo(n,t){const{field:e,operator:o,value:l}=t,s=n[e],d=xo[o];return d?d(s,l):(console.warn(`Unknown filter operator: ${o}`),!0)}function bo(n,t){return!t||t.length===0?!0:t.every(e=>{const o=e.toLowerCase();return Object.values(n).some(l=>l==null?!1:String(l).toLowerCase().includes(o))})}function Qt(n,t){const e=t.items??[],o=t.logicOperator??"and",l=("quickFilterValues"in t?t.quickFilterValues:void 0)??[];if(l.length>0&&!bo(n,l))return!1;if(e.length===0)return!0;const s=d=>{if("logicOperator"in d&&"items"in d){const a=d,f=a.items;return f.length===0?!0:a.logicOperator==="and"?f.every(s):f.some(s)}else return mo(n,d)};return o==="and"?e.every(s):e.some(s)}function wo(n,t){if(!t)return n;const{items:e=[],quickFilterValues:o=[]}=t;return e.length===0&&(!o||o.length===0)?n:n.filter(l=>Qt(l,t))}function vo(n){switch(n){case"number":return["=","!=",">",">=","<","<=","isEmpty","isNotEmpty"];case"date":return["is","not","after","onOrAfter","before","onOrBefore","isEmpty","isNotEmpty"];case"boolean":return["is"];case"singleSelect":return["isAnyOf","is","not"];default:return["contains","equals","startsWith","endsWith","isEmpty","isNotEmpty"]}}function Zt(n,t,e){if(n==null&&t==null)return 0;if(n==null)return e==="asc"?1:-1;if(t==null)return e==="asc"?-1:1;if(typeof n=="number"&&typeof t=="number")return e==="asc"?n-t:t-n;if(n instanceof Date&&t instanceof Date)return e==="asc"?n.getTime()-t.getTime():t.getTime()-n.getTime();const o=String(n).toLowerCase(),l=String(t).toLowerCase();return e==="asc"?o<l?-1:o>l?1:0:o>l?-1:o<l?1:0}function _o(n,t){if(t.length===0)return n;const e=[...n];return e.sort((o,l)=>{for(const s of t){const d=o[s.field],a=l[s.field],f=Zt(d,a,s.sort);if(f!==0)return f}return 0}),e}function Co(n){const{effectiveRows:t,activeHierarchyHandlers:e,filterMode:o,filterModel:l,dataSource:s,sortModel:d,sortingMode:a,pagination:f,paginationMode:p,effectivePaginationModel:x,pinnedRows:w,isLoading:b,pageSize:c}=n,g=i.useMemo(()=>e?e.getVisibleRows()||[]:o==="server"&&s?t:wo(t,l),[t,l,e,o,s]),{top:m,center:_,bottom:E}=i.useMemo(()=>e?{top:[],center:g,bottom:[]}:uo(g,w),[g,w,e]),v=i.useMemo(()=>e||a==="server"&&s?_:_o(_,d),[_,d,e,a,s]),S=i.useMemo(()=>{if(!f||p==="server"&&s)return v;const h=x.page*x.pageSize;return v.slice(h,h+x.pageSize)},[v,f,x.page,x.pageSize,p,s]),N=i.useMemo(()=>{if(e)return _;const h=f?S:v,y=[...m,...h,...E];if(p==="infinite"&&b&&y.length>0){const u=Math.min(c,20),j=Array.from({length:u},(P,F)=>({id:`__skeleton_${F}__`,_isSkeleton:!0}));return[...y,...j]}return y},[m,S,v,E,f,e,_,p,b,c]);return{filteredRows:g,pinnedTopRows:m,unpinnedRows:_,pinnedBottomRows:E,sortedUnpinnedRows:v,paginatedUnpinnedRows:S,allRenderableRows:N}}function yo(n){const{layout:t,scrollTop:e,scrollLeft:o,viewportWidth:l,viewportHeight:s,autoHeight:d,rowReordering:a,hasDetailPanel:f,checkboxSelection:p,pinCheckboxColumn:x,pinExpandColumn:w,overscanRows:b=5}=n;return i.useMemo(()=>{const{unpinnedAccWidths:c,unpinnedColsWithWidth:g,leftPinnedCols:m,rightPinnedCols:_,totalWidth:E,leftWidth:v,rightWidth:S,unpinnedTotalWidth:N,systemColumnsWidth:h,cumulativeHeights:y,pinnedTopHeight:u,pinnedBottomHeight:j,unpinnedRowsHeight:P,rowHeights:F,unpinnedRowsLength:k}=t,I=l||1e3,R=d?u+P+j+50:s||600,W=6,$=Math.max(0,o-v),D=o+I-v;let A=0,z=g.length-1,Y=0,V=c.length-1;for(;Y<=V;){const te=Y+V>>>1;c[te]<$?Y=te+1:V=te-1}A=Math.max(0,Y-W);for(let te=A;te<c.length;te++){if((te===0?0:c[te-1])>D){z=Math.min(g.length-1,te+W);break}z=Math.min(g.length-1,te+W)}const C=A>0?c[A-1]:0,M=N-c[z],L=[...m,...C>0?[{field:"__spacer_left__",width:C,isSpacer:!0}]:[],...g.slice(A,z+1),...M>0?[{field:"__spacer_right__",width:M,isSpacer:!0}]:[],..._],H=I>0&&E>I?16:0,U=u+P+j+H+2;let K=0,oe=k-1,ie=0,ne=0,T=y.length-1;for(;ne<=T;){const te=ne+T>>>1;y[te]<e?ne=te+1:T=te-1}K=Math.max(0,ne-b),ie=K>0?y[K-1]:0;for(let te=K;te<y.length;te++)if(y[te]>=e+R){oe=Math.min(k-1,te+b);break}const le=(a?48:0)+(f&&w?48:0)+(p&&x?48:0);return{renderContext:{firstRowIndex:K,lastRowIndex:oe,firstColumnIndex:A,lastColumnIndex:z},offsetTop:ie,offsetLeft:0,totalHeight:U,pinnedTopHeight:u,pinnedBottomHeight:j,totalWidth:E,rowHeights:F,cumulativeHeights:y,virtualColumns:L,columnMetrics:{leftPinnedWidth:v,rightPinnedWidth:S,unpinnedAccWidths:c,unpinnedCols:g,totalSpecialsWidth:h,pinnedSpecialsWidth:le}}},[t,e,o,l,s,d,a,f,p,x,w,b])}function ko(n){const{columns:t,onColumnOrderChange:e,disableColumnReorder:o=!1}=n,[l,s]=i.useState(null),[d,a]=i.useState(null),f=i.useRef(-1),p=i.useCallback(c=>g=>{if(o)return;const m=t.findIndex(E=>E.field===c);if(t[m]?.pinnable===!1){g.preventDefault();return}s(c),f.current=m,g.dataTransfer&&(g.dataTransfer.effectAllowed="move",g.dataTransfer.setData("text/plain",c))},[t,o]),x=i.useCallback(c=>g=>{o||!l||(g.preventDefault(),g.dataTransfer.dropEffect="move",a(c))},[l,o]),w=i.useCallback(c=>g=>{if(g.preventDefault(),o||!l||l===c){s(null),a(null);return}const m=t.findIndex(v=>v.field===l),_=t.findIndex(v=>v.field===c);if(m===-1||_===-1){s(null),a(null);return}const E=t[m];e&&e({column:E,oldIndex:m,targetIndex:_}),s(null),a(null),f.current=-1},[t,l,o,e]),b=i.useCallback(()=>{s(null),a(null),f.current=-1},[]);return{draggedColumn:l,dragOverColumn:d,onDragStart:o?void 0:p,onDragOver:o?void 0:x,onDragEnd:o?void 0:b,onDrop:o?void 0:w}}function Sn({isExpanded:n,onClick:t,variant:e="chevron"}){return r.jsx("button",{className:`ogx-expand-icon ${n?"ogx-expand-icon--expanded":""}`,onClick:o=>{t&&t(o)},"aria-label":n?"Collapse row":"Expand row",type:"button",children:e==="plus-minus"?r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r.jsx("path",{d:"M4 8H12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M8 4V12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:n?0:1,transition:"opacity 0.2s ease",transformOrigin:"center"}})]}):r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{transform:n?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.2s ease"},children:r.jsx("path",{d:"M6 4L10 8L6 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}function So(n){const{activeColumns:t,isHierarchyEnabled:e,isRowGrouping:o,isTreeData:l,activeHierarchyHandlers:s,columnVisibilityModel:d,columnOrder:a,onColumnOrderChange:f,disableColumnReorder:p,pivotMode:x,checkboxSelection:w,hasDetailPanel:b,rowReordering:c,initialState:g,setColumns:m}=n,_=i.useMemo(()=>e?t.map((k,I)=>I===0?{...k,renderCell:R=>{const W=R.rowMeta,$=W?.treeDepth??0,D=!!W?.hasChildren,A=!!W?.isExpanded,z=W?.groupingField,Y=W?.groupingValue,V=W?.descendantCount,C=!!W?.isGroupRow;let M=k.renderCell?k.renderCell(R):R.value;if(l&&D&&C&&(M=r.jsxs("div",{className:"ogx__group-cell-content",children:[R.value,V!==void 0&&V>0?` (${V})`:""]})),o&&D&&z){const L=W?.groupLabel??`${z}: ${String(Y)}`;M=r.jsxs("div",{className:"ogx__group-cell-content",children:[L,V!==void 0?` (${V})`:""]})}return r.jsxs("div",{style:{display:"flex",alignItems:"center",paddingLeft:$*24,width:"100%",height:"100%"},children:[r.jsx("div",{style:{marginRight:4,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",cursor:D?"pointer":"default",flexShrink:0},children:D?r.jsx("div",{onClick:L=>{L.stopPropagation(),L.preventDefault(),s?.toggleExpansion(R.row.id)},onMouseDown:L=>{L.stopPropagation()},style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:10,position:"relative"},children:r.jsx(Sn,{isExpanded:A,onClick:L=>{L.stopPropagation(),L.preventDefault(),s?.toggleExpansion(R.row.id)}})}):null}),r.jsx("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:M})]})}}:{...k,renderCell:R=>{const W=R.rowMeta,$=!!W?.hasChildren,D=W?.groupingField;return o&&$?k.field===D?null:R.value!==void 0&&R.value!==null?k.renderCell?k.renderCell(R):R.value:null:k.renderCell?k.renderCell(R):R.value}}):t,[t,e,o,l,s]),[E,v]=i.useState(()=>g?.columns?.columnWidths??{}),S=i.useCallback((k,I)=>{v(R=>({...R,[k]:I}))},[]),[N,h]=i.useState(()=>g?.columns?.columnOrder??t.map(k=>k.field)),y=a??N;i.useEffect(()=>{m(t)},[t,m]),i.useEffect(()=>{x&&h(t.map(k=>k.field))},[x,t]);const u=i.useMemo(()=>{if(p)return _;const k=new Map(y.map((I,R)=>[I,R]));return[..._].sort((I,R)=>{const W=k.get(I.field)??_.indexOf(I),$=k.get(R.field)??_.indexOf(R);return W-$})},[_,y,p]),j=i.useMemo(()=>u.filter(k=>d[k.field]!==!1),[u,d]),P=ko({columns:u,onColumnOrderChange:i.useCallback(k=>{const{oldIndex:I,targetIndex:R}=k,W=[...y],[$]=W.splice(I,1);W.splice(R,0,$),a||h(W),f?.(k)},[y,a,f]),disableColumnReorder:p}),F=i.useMemo(()=>{const k=[];return c&&k.push({field:"__reorder_col__"}),b&&k.push({field:"__expand_col__"}),w&&k.push({field:"__checkbox_col__"}),[...k,...u]},[u,w,b,c]);return{effectiveColumns:_,orderedColumns:u,visibleOrderedColumns:j,navigationColumns:F,columnWidths:E,effectiveColumnOrder:y,setInternalColumnOrder:h,columnReorderHandlers:P,handleColumnResize:S}}function jo(n){const{renderContext:t,pinnedTopRows:e,pinnedBottomRows:o,paginatedUnpinnedRows:l,sortedUnpinnedRows:s,pagination:d}=n;return i.useMemo(()=>{const{firstRowIndex:a,lastRowIndex:f}=t,p=d?l:s,x=e.length,w=e.map((v,S)=>({row:v,rowIndex:S})),b=o.map((v,S)=>({row:v,rowIndex:x+p.length+S})),c=Math.max(0,a-x),g=Math.min(p.length,f-x+1),m=p.slice(c,g).map((v,S)=>({row:v,rowIndex:x+c+S})),_=[...w,...m,...b],E=new Set;return _.filter(v=>E.has(v.row.id)?!1:(E.add(v.row.id),!0))},[t,e,o,l,s,d])}function Eo(n,t){let e;return n<.5?e=3:n<3?e=5:n<15?e=12:n<40?e=20:e=30,Math.max(e,t)}function No(n){const{onRowsScrollEnd:t,overscanRowCount:e=3}=n,o=i.useRef({scrollTop:0,scrollLeft:0,velocity:0}),l=i.useRef({scrollTop:0,scrollLeft:0,time:0}),s=i.useRef(null),d=i.useRef(null),[a,f]=i.useState({scrollTop:0,scrollLeft:0,overscanRows:e});i.useEffect(()=>()=>{s.current!==null&&cancelAnimationFrame(s.current),d.current!==null&&clearTimeout(d.current)},[]);const p=i.useCallback(x=>{const w=x.currentTarget,b=performance.now(),c=Math.abs(w.scrollTop-l.current.scrollTop)+Math.abs(w.scrollLeft-l.current.scrollLeft),g=b-l.current.time,m=g>0?c/g:0;if(l.current={scrollTop:w.scrollTop,scrollLeft:w.scrollLeft,time:b},o.current={scrollTop:w.scrollTop,scrollLeft:w.scrollLeft,velocity:m},s.current!==null&&cancelAnimationFrame(s.current),s.current=requestAnimationFrame(()=>{s.current=null;const{scrollTop:_,scrollLeft:E,velocity:v}=o.current;f({scrollTop:_,scrollLeft:E,overscanRows:Eo(v,e)})}),d.current!==null&&clearTimeout(d.current),d.current=setTimeout(()=>{d.current=null,f(_=>({..._,overscanRows:e}))},200),t){const{scrollTop:_,scrollHeight:E,clientHeight:v}=w;E-_-v<100&&t({visibleTop:_,visibleBottom:_+v,viewportHeight:v})}},[t,e]);return{scrollTop:a.scrollTop,scrollLeft:a.scrollLeft,overscanRows:a.overscanRows,handleScroll:p}}function Mo(n){const{onStateChange:t,sortModel:e,filterModel:o,effectivePaginationModel:l,columnWidths:s,effectiveColumnOrder:d,columnVisibilityModel:a,pinnedColumns:f}=n,p=i.useRef(t);i.useLayoutEffect(()=>{p.current=t}),i.useEffect(()=>{if(!p.current)return;const x={sorting:{sortModel:e},filter:{filterModel:o},pagination:{paginationModel:l},columns:{columnWidths:s,columnOrder:d,columnVisibilityModel:a,pinnedColumns:f}};p.current(x)},[e,o,l,s,d,a,f])}const Po={sum:n=>n.filter(e=>e!=null&&!isNaN(Number(e))).reduce((e,o)=>e+Number(o),0),avg:n=>{const t=n.filter(e=>e!=null&&!isNaN(Number(e)));return t.length===0?null:t.reduce((e,o)=>e+Number(o),0)/t.length},count:n=>n.filter(t=>t!=null).length,min:n=>{const t=n.filter(e=>e!=null&&!isNaN(Number(e))).map(Number);return t.length?Math.min(...t):null},max:n=>{const t=n.filter(e=>e!=null&&!isNaN(Number(e))).map(Number);return t.length?Math.max(...t):null},unique:n=>new Set(n.filter(t=>t!=null)).size};function _e(n,t){return n==null?"—":typeof n=="number"?t==="avg"?n.toLocaleString(void 0,{maximumFractionDigits:2}):n.toLocaleString():String(n)}function jn(n){const{rows:t,columns:e,aggregationModel:o,isServerSide:l,dataSource:s,filterModel:d,sortModel:a,serverAggregationResults:f}=n,p=i.useMemo(()=>{const N=new Map;return(e??[]).forEach(h=>N.set(h.field,h)),N},[e]),x=i.useMemo(()=>{if(l||Object.keys(o).length===0)return{};const N={};for(const[h,y]of Object.entries(o)){const u=p.get(h);if(u?.availableAggregationFunctions&&!u.availableAggregationFunctions.includes(y))continue;const j=Po[y];if(!j){console.warn(`[useAggregation] Unknown aggregation function: "${y}"`);continue}const P=t.map(F=>F[h]);N[h]=j(P)}return N},[t,p,o,l]),[w,b]=i.useState({}),[c,g]=i.useState(!1),[m,_]=i.useState(null),E=i.useRef(0),v=i.useCallback(async()=>{if(!s?.getAggregations||Object.keys(o).length===0)return;const N=++E.current;g(!0),_(null);try{const h=await s.getAggregations({sortModel:a??[],filterModel:d??{items:[]},groupKeys:[],aggregationModel:o});N===E.current&&b(h)}catch(h){N===E.current&&(_(h),console.error("[useAggregation] Server aggregation error:",h))}finally{N===E.current&&g(!1)}},[s,o,d,a]);return i.useEffect(()=>{l&&s?.getAggregations&&!f&&v()},[v,l,s,f]),{aggregationResult:i.useMemo(()=>l?f&&Object.keys(f).length>0?f:w:x,[l,x,f,w]),isLoading:c,error:m}}function Io({columns:n,aggregationModel:t,aggregationResult:e,columnWidths:o,rowHeight:l,checkboxSelection:s,hasDetailPanel:d,rowReordering:a,pinnedColumns:f}){const p=i.useMemo(()=>Xt(n,o,f,s,!0,d,!0,a),[n,o,f,s,d,a]),x=f?.left?.[f.left.length-1],w=f?.right?.[0];return r.jsxs("div",{className:"ogx__aggregation-footer",role:"row","aria-label":"Aggregation totals","aria-live":"polite",style:{minHeight:`${l}px`},children:[s&&r.jsx("div",{style:{width:48,flexShrink:0}}),d&&r.jsx("div",{style:{width:48,flexShrink:0}}),a&&r.jsx("div",{style:{width:48,flexShrink:0}}),n.map(b=>{const c=t[b.field],g=e[b.field],m=o[b.field]??(typeof b.width=="number"?b.width:120),_=xt(b.field,f),E=_?p[b.field]:void 0,v=["ogx__aggregation-cell",_==="left"&&"ogx__aggregation-cell--pinned-left",_==="right"&&"ogx__aggregation-cell--pinned-right",_==="left"&&b.field===x&&"ogx__aggregation-cell--pinned-left-last",_==="right"&&b.field===w&&"ogx__aggregation-cell--pinned-right-first"].filter(Boolean).join(" "),S={width:m,minWidth:m,maxWidth:m,textAlign:b.align||"left"};return _==="left"&&E!==void 0&&(S.left=E),_==="right"&&E!==void 0&&(S.right=E),r.jsx("div",{className:v,role:"gridcell",style:S,children:c?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"ogx__aggregation-label",children:c}),r.jsx("span",{className:"ogx__aggregation-value",children:_e(g,c)})]}):null},b.field)})]})}function To({noRowsLabel:n,width:t}){return r.jsxs("div",{className:"ogx__empty",style:{width:t},children:[r.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[r.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),r.jsx("path",{d:"M3 9h18M9 21V9"})]}),r.jsx("span",{children:n})]})}function Ro({error:n}){if(!n)return null;const t=n instanceof Error?n.message:typeof n=="string"?n:"An unexpected error occurred while loading the data.";return r.jsxs("div",{className:"ogx-error-overlay","aria-live":"assertive",role:"alert",children:[r.jsxs("svg",{width:"56",height:"56",viewBox:"0 0 24 24",fill:"none",stroke:"var(--ogx-color-error)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),r.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),r.jsx("div",{className:"ogx-error-overlay__title",children:"Oops! Something went wrong"}),r.jsx("div",{className:"ogx-error-overlay__message",children:t}),r.jsx("button",{onClick:()=>window.location.reload(),className:"ogx-button ogx-button--primary",children:"Retry"})]})}const mt=({indeterminate:n=!1,label:t,className:e="",inputRef:o,...l})=>{const s=i.useRef(null),d=i.useCallback(f=>{s.current=f,typeof o=="function"?o(f):o&&(o.current=f)},[o]);i.useEffect(()=>{s.current&&(s.current.indeterminate=n)},[n]);const a=["ogx-checkbox-wrapper",l.disabled&&"ogx-checkbox-wrapper--disabled",e].filter(Boolean).join(" ");return r.jsxs("label",{className:a,children:[r.jsx("input",{ref:d,type:"checkbox",className:"ogx-checkbox__input","aria-label":t||l["aria-label"]||(n?"Select some":l.checked?"Deselect":"Select"),...l}),r.jsxs("span",{className:"ogx-checkbox__box",children:[l.checked&&!n&&r.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:r.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})}),n&&r.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:r.jsx("path",{d:"M19 13H5v-2h14v2z"})})]}),t&&r.jsx("span",{className:"ogx-checkbox__label",children:t})]})};function Lo(n){const{field:t,currentWidth:e,onResize:o,minWidth:l=50,maxWidth:s=1e3}=n,[d,a]=i.useState(!1),f=i.useRef(0),p=i.useRef(0),x=i.useCallback(c=>{c.preventDefault(),c.stopPropagation(),a(!0),f.current=c.clientX,p.current=e;let g=0;const m=16,_=v=>{const S=v.clientX-f.current,N=Math.max(l,Math.min(s,p.current+S)),h=Date.now();h-g>=m&&(o(t,N),g=h)},E=v=>{a(!1);const S=v.clientX-f.current,N=Math.max(l,Math.min(s,p.current+S));o(t,N),document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",E)};document.addEventListener("mousemove",_),document.addEventListener("mouseup",E)},[t,e,o,l,s]),w=i.useCallback(c=>{c.preventDefault(),c.stopPropagation()},[]),b=["ogx-column-resize-handle",d&&"ogx-column-resize-handle--dragging"].filter(Boolean).join(" ");return r.jsx("div",{className:b,onMouseDown:x,onClick:c=>c.stopPropagation(),onDragStart:c=>{c.preventDefault(),c.stopPropagation()},onDoubleClick:w,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${t} column`,children:r.jsx("div",{className:"ogx-column-resize-handle__line"})})}function Xe(){return r.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"currentColor",children:r.jsx("circle",{cx:"4",cy:"4",r:"4"})})}function Je(){return r.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:r.jsx("circle",{cx:"4",cy:"4",r:"3"})})}function Fo(){return r.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",children:[r.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),r.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.3"}),r.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),r.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),r.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),r.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function Oo(){return r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),r.jsx("polyline",{points:"5 12 12 5 19 12"})]})}function Wo(){return r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("polyline",{points:"19 12 12 19 5 12"})]})}function Ao(){return r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})}function $o(){return r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"}),r.jsx("path",{d:"M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"}),r.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function zo(){return r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"4",y1:"2",x2:"4",y2:"22"}),r.jsx("polyline",{points:"11 8 4 12 11 16"}),r.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function Bo(){return r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"20",y1:"2",x2:"20",y2:"22"}),r.jsx("polyline",{points:"13 8 20 12 13 16"}),r.jsx("line",{x1:"20",y1:"12",x2:"4",y2:"12"})]})}function Ho(){return r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),r.jsx("line",{x1:"4",y1:"4",x2:"4",y2:"20"}),r.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function Do({colDef:n,sortModel:t,onSort:e,onHide:o,onPin:l,pinnedColumns:s,onManageColumns:d,onClose:a,anchorEl:f}){const p=i.useRef(null),[x,w]=i.useState({position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"});i.useLayoutEffect(()=>{if(!f||!p.current)return;const h=f.getBoundingClientRect(),y=p.current.getBoundingClientRect(),u=window.innerWidth,j=window.innerHeight,P=8;let F=h.left;F+y.width+P>u&&(F=u-y.width-P),F<P&&(F=P);let k=h.bottom+4;k+y.height+P>j&&(k=h.top-y.height-4),w({position:"fixed",zIndex:1300,top:k,left:F,visibility:"visible"})},[f]),i.useEffect(()=>{function h(u){p.current&&!p.current.contains(u.target)&&f&&!f.contains(u.target)&&a()}function y(u){u.key==="Escape"&&a()}return document.addEventListener("mousedown",h),document.addEventListener("keydown",y),window.addEventListener("scroll",a,!0),window.addEventListener("resize",a),()=>{document.removeEventListener("mousedown",h),document.removeEventListener("keydown",y),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a)}},[f,a]);const b=h=>{e?.(n.field,h),a()},c=()=>{o?.(n.field),a()},g=h=>{l?.(n.field,h),a()},m=t?.find(h=>h.field===n.field)?.sort,_=m==null,E=s?.left?.includes(n.field)??!1,v=s?.right?.includes(n.field)??!1,S=!E&&!v,N=n.headerName||n.field;return Ge.createPortal(r.jsxs("div",{ref:p,className:"ogx-column-menu",style:x,role:"menu","aria-label":`Column options for ${N}`,children:[e&&n.sortable!==!1&&r.jsxs(r.Fragment,{children:[r.jsxs("button",{className:`ogx-menu-item${m==="asc"?" ogx-menu-item--active":""}`,onClick:()=>b("asc"),role:"menuitemradio","aria-checked":m==="asc",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:m==="asc"?r.jsx(Xe,{}):r.jsx(Je,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(Oo,{})}),"Sort Ascending"]}),r.jsxs("button",{className:`ogx-menu-item${m==="desc"?" ogx-menu-item--active":""}`,onClick:()=>b("desc"),role:"menuitemradio","aria-checked":m==="desc",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:m==="desc"?r.jsx(Xe,{}):r.jsx(Je,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(Wo,{})}),"Sort Descending"]}),r.jsxs("button",{className:`ogx-menu-item${_?" ogx-menu-item--active":""}`,onClick:()=>b(null),role:"menuitemradio","aria-checked":_,children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:_?r.jsx(Xe,{}):r.jsx(Je,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(Ao,{})}),"Unsort"]}),r.jsx("div",{className:"ogx-menu-divider"})]}),r.jsx("div",{className:"ogx-menu-section-label","aria-hidden":"true",children:"Pin column"}),r.jsxs("button",{className:`ogx-menu-item${E?" ogx-menu-item--active":""}`,onClick:()=>g("left"),role:"menuitemradio","aria-checked":E,"aria-label":"Pin to left",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:E?r.jsx(Xe,{}):r.jsx(Je,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(zo,{})}),"Pin to Left"]}),r.jsxs("button",{className:`ogx-menu-item${v?" ogx-menu-item--active":""}`,onClick:()=>g("right"),role:"menuitemradio","aria-checked":v,"aria-label":"Pin to right",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:v?r.jsx(Xe,{}):r.jsx(Je,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(Bo,{})}),"Pin to Right"]}),r.jsxs("button",{className:`ogx-menu-item${S?" ogx-menu-item--active":""}`,onClick:()=>g(null),role:"menuitemradio","aria-checked":S,"aria-label":"Unpin column",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:S?r.jsx(Xe,{}):r.jsx(Je,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(Ho,{})}),"Unpin"]}),r.jsx("div",{className:"ogx-menu-divider"}),r.jsxs("button",{className:"ogx-menu-item",onClick:c,role:"menuitem","aria-label":`Hide ${N} column`,children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx($o,{})}),"Hide Column"]}),r.jsx("div",{className:"ogx-menu-divider"}),r.jsxs("button",{className:"ogx-menu-item",onClick:()=>{d?.(),a()},role:"menuitem","aria-label":"Manage all columns",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(Fo,{})}),"Manage columns"]})]}),f?.closest(".ogx-theme-provider")||document.body)}function Go(){return r.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"18",height:"18",children:r.jsx("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"})})}function Vo(){return r.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor",children:r.jsx("path",{d:"M6.99 11L3 15l3.99 4v-3H14v-2H6.99v-3zM21 9l-3.99-4v3H10v2h7.01v3L21 9z"})})}function En(n){const t=[];for(const e of n.children)typeof e=="string"?t.push(e):t.push(...En(e));return t}function Uo(n){let t=0;function e(o,l){t=Math.max(t,l);for(const s of o.children)typeof s!="string"&&e(s,l+1)}return n.forEach(o=>e(o,1)),t}function Ko(n,t,e){function o(a,f,p){if(!En(a).includes(f))return null;if(p===e)return a;for(const x of a.children)if(typeof x!="string"){const w=o(x,f,p+1);if(w)return w}return null}const l=new Map;for(const a of t){let f=null;for(const p of n)if(f=o(p,a.field,0),f)break;l.set(a.field,f)}const s=[];let d=0;for(;d<t.length;){const a=t[d],f=l.get(a.field)??null,p=a.width;if(!f)s.push({key:`fg-${a.field}-${e}`,label:"",width:p,isGroup:!1}),d++;else{let x=0,w=d;for(;w<t.length&&l.get(t[w].field)===f;)x+=t[w].width,w++;s.push({key:`${f.groupId}-${e}`,label:f.headerName,width:x,isGroup:!0}),d=w}}return s}function Nn(n){const{columns:t,allColumns:e,columnGroupingModel:o,checkboxSelection:l=!1,allSelected:s=!1,someSelected:d=!1,onSelectAll:a,onSort:f,sortModel:p=[],onColumnResize:x,columnWidths:w={},pinnedColumns:b,hasDetailPanel:c=!1,pinCheckboxColumn:g=!0,pinExpandColumn:m=!0,rowReordering:_=!1,aggregationModel:E,draggedColumn:v,dragOverColumn:S,onDragStart:N,onDragOver:h,onDragEnd:y,onDrop:u,focusedCell:j,onHeaderClick:P,onSortAdd:F,multiSort:k=!1,onHideColumn:I,onPinColumn:R,onManageColumns:W}=n,$=i.useId(),D=i.useRef({}),[A,z]=i.useState(null),Y=T=>le=>{le.stopPropagation(),z({colDef:T,anchorEl:le.currentTarget})},V=()=>{z(null)};i.useLayoutEffect(()=>{if(j?.id==="HEADER"){const T=D.current[j.field];T&&T.focus()}},[j]);const C=T=>le=>{if(T.sortable===!1)return;const te=p.find(q=>q.field===T.field);let re="asc";te&&(te.sort==="asc"?re="desc":re=null),(le.shiftKey||k)&&F?F(T.field,re):f&&f(T.field,re)},M=T=>{const le=p.find(re=>re.field===T);if(!le)return null;const te=p.length>1?p.indexOf(le)+1:null;return r.jsx("span",{className:`ogx__sort-icon ogx__sort-icon--${le.sort}`,"aria-hidden":"true",children:te!==null&&r.jsx("span",{className:"ogx__sort-badge",children:te})})},L=i.useMemo(()=>Xt(t,w,b,l,g,c,m,_),[t,w,b,l,g,c,m,_]),O=o?Uo(o):0,U=(e??t).filter(T=>!T.isSpacer).map(T=>({field:T.field,width:w[T.field]??T.width??100})),ne=(_?48:0)+(c?48:0)+(l?48:0);return r.jsxs("div",{className:"ogx__header-wrap",children:[O>0&&Array.from({length:O},(T,le)=>{const te=Ko(o,U,le);return r.jsxs("div",{className:"ogx-col-group-row",role:"row",children:[ne>0&&r.jsx("div",{className:"ogx-col-group-cell ogx-col-group-cell--filler",style:{width:ne,minWidth:ne,flexShrink:0},role:"columnheader"}),te.map(re=>r.jsx("div",{role:"columnheader",className:`ogx-col-group-cell ${re.isGroup?"ogx-col-group-cell--group":"ogx-col-group-cell--filler"}`,style:{width:re.width,minWidth:re.width,flexShrink:0},title:re.isGroup?re.label:void 0,children:re.isGroup&&r.jsx("span",{className:"ogx-col-group-cell__label",children:re.label})},re.key))]},`ogx-grp-${le}`)}),r.jsxs("div",{className:"ogx__header",role:"row",children:[_&&r.jsx("div",{className:"ogx__header-cell ogx__header-cell--pinned ogx__header-cell--pinned-left",role:"columnheader","aria-label":"Row reorder handle",title:"Drag to reorder rows",style:{minWidth:48,maxWidth:48,position:"sticky",left:0,zIndex:4}}),c&&r.jsx("div",{className:`ogx__header-cell ogx__header-cell--expand ${m?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""}`,role:"columnheader","aria-label":"Expand row details",style:{minWidth:48,maxWidth:48,position:m?"sticky":void 0,left:m?_?48:0:void 0,zIndex:m?5:void 0}}),l&&r.jsx("div",{className:`ogx__header-cell ogx__header-cell--checkbox ${g?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""}`,role:"columnheader",style:{position:g?"sticky":void 0,left:g?(_?48:0)+(c&&m?48:0):void 0},children:r.jsx(mt,{id:$,name:$,checked:s,indeterminate:d,onChange:T=>a?.(T.target.checked),"aria-label":s?"Deselect all rows":"Select all rows",tabIndex:j?.id==="HEADER"&&j.field==="__checkbox_col__"?0:-1,onMouseDown:T=>T.preventDefault(),inputRef:T=>{D.current.__checkbox_col__=T}})}),t.map((T,le)=>{if(T.isSpacer)return r.jsx("div",{style:{width:T.width,minWidth:T.width,flexShrink:0},"aria-hidden":"true"},T.field);const te=T.sortable!==!1,re=p.some(ee=>ee.field===T.field),q=T.resizable!==!1,J=xt(T.field,b),de=J!==null,B=v===T.field,Q=S===T.field,Z=["ogx__header-cell",`ogx__header-cell--align-${T.headerAlign||T.align||"left"}`,te&&"ogx__header-cell--sortable",re&&"ogx__header-cell--sorted",de&&"ogx__header-cell--pinned",de&&`ogx__header-cell--pinned-${J}`,B&&"ogx__header-cell--dragging",Q&&"ogx__header-cell--drag-over",j?.id==="HEADER"&&j.field===T.field&&"ogx__header-cell--focused",T.headerClassName].filter(Boolean).join(" "),ge=w[T.field]??T.width??100,ce={width:ge,minWidth:T.minWidth,maxWidth:T.maxWidth,flexGrow:T.flex??0,flexShrink:0,flexBasis:(T.flex,"auto"),boxSizing:"border-box",position:de?"sticky":"relative",zIndex:T.zIndex,opacity:B?.5:1};if(de&&J){const ee=L[T.field];J==="left"?ce.left=ee:ce.right=ee}const Ee=T.renderHeader?T.renderHeader({field:T.field,colDef:T,colIndex:le}):T.headerName||T.field,Te=ee=>{if(ee.target.closest(".ogx-column-resize-handle")){ee.stopPropagation();return}P?.(T.field),te&&C(T)(ee)},Pe=N?N(T.field):void 0,Re=h?h(T.field):void 0,ze=u?u(T.field):void 0;return r.jsxs("div",{className:Z,style:ce,title:T.description,onClick:Te,role:"columnheader",draggable:!!N,onDragStart:Pe,onDragOver:Re,onDragEnd:y,onDrop:ze,"aria-sort":te?re?p.find(ee=>ee.field===T.field)?.sort==="asc"?"ascending":"descending":"none":void 0,"aria-colindex":le+1+(l?1:0),"data-field":T.field,tabIndex:-1,ref:ee=>{D.current[T.field]=ee},children:[r.jsxs("div",{className:"ogx__header-cell-content",children:[B&&r.jsx("div",{className:"ogx__header-drag-icon",children:r.jsx(Vo,{})}),r.jsxs("div",{className:"ogx__header-cell-title-wrapper",children:[r.jsx("span",{className:"ogx__header-cell-title",children:Ee}),E&&E[T.field]&&r.jsx("span",{className:"ogx__header-cell-aggregation",children:E[T.field]})]}),te&&M(T.field),!T.disableColumnMenu&&r.jsx("button",{className:"ogx__menu-icon-btn",onClick:Y(T),"aria-label":`Open column menu for ${T.headerName||T.field}`,"aria-haspopup":"menu",tabIndex:-1,children:r.jsx(Go,{})})]}),q&&x&&r.jsx(Lo,{field:T.field,currentWidth:ge,onResize:x,minWidth:T.minWidth,maxWidth:T.maxWidth})]},T.field)}),A&&r.jsx(Do,{colDef:A.colDef,sortModel:p,onSort:f,onHide:I,onPin:R,pinnedColumns:b,onManageColumns:W,onClose:V,anchorEl:A.anchorEl})]})]})}const bt=({variant:n="text",size:t="medium",color:e="default",disabled:o=!1,className:l="",children:s,...d})=>{const a=["ogx-button",`ogx-button--${n}`,`ogx-button--${t}`,`ogx-button--${e}`,o&&"ogx-button--disabled",l].filter(Boolean).join(" ");return r.jsx("button",{className:a,disabled:o,...d,children:s})};function Mn(n){const t=i.useId(),{page:e,pageSize:o,rowCount:l,onPageChange:s,onPageSizeChange:d,pageSizeOptions:a=[10,25,50,100],showFirstButton:f=!0,showLastButton:p=!0,localeText:x}=n,w=Math.max(1,Math.ceil(l/o)),b=Math.min(e,w-1),c=b*o,g=Math.min(c+o,l),m=l===0?0:`${c+1}–${g}`,_=x?.paginationRowsPerPage??"Rows per page:",E=x?.paginationOf?x.paginationOf(l===0?0:c+1,g,l):`${m} of ${l}`,v=x?.paginationPage?x.paginationPage(b+1,w):`Page ${b+1} of ${w}`,S=()=>{s(0)},N=()=>{s(Math.max(0,b-1))},h=()=>{s(Math.min(w-1,b+1))},y=()=>{s(w-1)},u=F=>{const k=parseInt(F.target.value,10);d(k)},j=b===0,P=b>=w-1;return r.jsxs("div",{className:"ogx-pagination",role:"navigation","aria-label":"Pagination",children:[r.jsxs("div",{className:"ogx-pagination__page-size",children:[r.jsx("label",{htmlFor:t,className:"ogx-pagination__label",children:_}),r.jsx("select",{id:t,className:"ogx-pagination__select",value:o,onChange:u,"aria-label":"Rows per page",children:a.map(F=>r.jsx("option",{value:F,children:F},F))})]}),r.jsx("div",{className:"ogx-pagination__info","aria-live":"polite","aria-atomic":"true",children:E}),r.jsxs("div",{className:"ogx-pagination__actions",children:[f&&r.jsx(bt,{variant:"text",size:"small",onClick:S,disabled:j,"aria-label":"Go to first page",title:"First page",children:r.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:r.jsx("path",{d:"M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"})})}),r.jsx(bt,{variant:"text",size:"small",onClick:N,disabled:j,"aria-label":"Go to previous page",title:"Previous page",children:r.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:r.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),r.jsx("div",{className:"ogx-pagination__page-info","aria-current":"page",children:v}),r.jsx(bt,{variant:"text",size:"small",onClick:h,disabled:P,"aria-label":"Go to next page",title:"Next page",children:r.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:r.jsx("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})})}),p&&r.jsx(bt,{variant:"text",size:"small",onClick:y,disabled:P,"aria-label":"Go to last page",title:"Last page",children:r.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:r.jsx("path",{d:"M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z"})})})]})]})}function Yo(n,t,e={}){const o=new Map,l=[];n.forEach(a=>{o.set(a.id,a),l.push(a.id)});const s=new Map,d=[];return t.forEach(a=>{s.set(a.field,a),d.push(a.field)}),{rows:{idRowsLookup:o,allRows:l},columns:{all:t,lookup:s,orderedFields:d,columnVisibilityModel:e},sorting:{sortModel:[]},filter:{filterModel:{items:[]}},pagination:{paginationModel:{page:0,pageSize:100},rowCount:n.length},selection:{selectedRows:new Set},pinning:{pinnedColumns:{},pinnedRows:{}},virtualization:{renderContext:{firstRowIndex:0,lastRowIndex:0,firstColumnIndex:0,lastColumnIndex:0}},dimensions:{rowHeight:52,headerHeight:56,viewportWidth:0,viewportHeight:0},dataSource:{loading:!1,error:null}}}function qo(n,t){switch(t.type){case"SET_ROWS":{const e=Array.from(n.rows.idRowsLookup.values()),o=typeof t.payload=="function"?t.payload(e):t.payload,l=new Map,s=[];return o.forEach(d=>{l.set(d.id,d),s.push(d.id)}),{...n,rows:{idRowsLookup:l,allRows:s},pagination:{...n.pagination,rowCount:t.preserveRowCount?n.pagination.rowCount:o.length}}}case"SET_COLUMNS":{const e=new Map,o=[];return t.payload.forEach(l=>{e.set(l.field,l),o.push(l.field)}),{...n,columns:{all:t.payload,lookup:e,orderedFields:o,columnVisibilityModel:n.columns.columnVisibilityModel}}}case"SET_SORT_MODEL":return{...n,sorting:{sortModel:t.payload}};case"SET_FILTER_MODEL":return{...n,filter:{filterModel:t.payload}};case"SET_PAGINATION_MODEL":return{...n,pagination:{...n.pagination,paginationModel:t.payload}};case"SET_SELECTION":return{...n,selection:{selectedRows:t.payload}};case"SET_DIMENSIONS":return{...n,dimensions:{...n.dimensions,viewportWidth:t.payload.viewportWidth,viewportHeight:t.payload.viewportHeight}};case"SET_DATASOURCE_LOADING":return{...n,dataSource:{...n.dataSource,loading:t.payload}};case"SET_DATASOURCE_ERROR":return{...n,dataSource:{...n.dataSource,error:t.payload}};case"SET_ROW_COUNT":return{...n,pagination:{...n.pagination,rowCount:t.payload}};default:return n}}function Xo(n){const{rows:t,columns:e,rowHeight:o=52,headerHeight:l=56,columnVisibilityModel:s,initialState:d}=n,[a]=i.useState(()=>Yo(t,e,s)),[f,p]=i.useReducer(qo,{...a,sorting:d?.sorting||a.sorting,filter:d?.filter||a.filter,dataSource:d?.dataSource?{...a.dataSource,...d.dataSource}:a.dataSource,pagination:{...a.pagination,...d?.pagination||{},rowCount:n.rowCount??d?.pagination?.rowCount??a.pagination.rowCount},dimensions:{...a.dimensions,rowHeight:o,headerHeight:l}}),x=i.useRef(f);i.useLayoutEffect(()=>{x.current=f});const w=i.useRef(t);i.useEffect(()=>{t!==w.current&&(w.current=t,p({type:"SET_ROWS",payload:t}))},[t]);const b=i.useCallback((u,j)=>{p({type:"SET_ROWS",payload:u,preserveRowCount:j})},[]),c=i.useCallback(u=>{p({type:"SET_COLUMNS",payload:u})},[]),g=i.useCallback(u=>{p({type:"SET_SORT_MODEL",payload:u})},[]),m=i.useCallback(u=>{p({type:"SET_FILTER_MODEL",payload:u})},[]),_=i.useCallback(u=>{p({type:"SET_PAGINATION_MODEL",payload:u})},[]),E=i.useCallback(u=>{p({type:"SET_SELECTION",payload:u})},[]),v=i.useCallback((u,j)=>{p({type:"SET_DIMENSIONS",payload:{viewportWidth:u,viewportHeight:j}})},[]),S=i.useCallback(u=>{p({type:"SET_DATASOURCE_LOADING",payload:u})},[]),N=i.useCallback(u=>{p({type:"SET_DATASOURCE_ERROR",payload:u})},[]),h=i.useCallback(u=>{p({type:"SET_ROW_COUNT",payload:u})},[]),y=i.useRef({getRow:u=>x.current.rows.idRowsLookup.get(u)||null,getAllRows:()=>Array.from(x.current.rows.idRowsLookup.values()),getVisibleRows:()=>Array.from(x.current.rows.idRowsLookup.values()),getAllFilteredRows:()=>Array.from(x.current.rows.idRowsLookup.values()),getGroupedExportRows:()=>null,getAggregationResult:()=>null,getAggregationModel:()=>null,getColumn:u=>x.current.columns.lookup.get(u)||null,getAllColumns:()=>x.current.columns.all,getVisibleColumns:()=>x.current.columns.all,selectRow:(u,j=!0)=>{const P=new Set(x.current.selection.selectedRows);j?P.add(u):P.delete(u),E(P)},selectRows:(u,j=!0)=>{const P=new Set(x.current.selection.selectedRows);u.forEach(F=>{j?P.add(F):P.delete(F)}),E(P)},getSelectedRows:()=>Array.from(x.current.selection.selectedRows),sortColumn:(u,j)=>{if(j===null)g(x.current.sorting.sortModel.filter(P=>P.field!==u));else{const P=x.current.sorting.sortModel.findIndex(F=>F.field===u);if(P>=0){const F=[...x.current.sorting.sortModel];F[P]={field:u,sort:j},g(F)}else g([...x.current.sorting.sortModel,{field:u,sort:j}])}},getSortModel:()=>x.current.sorting.sortModel,setFilterModel:m,getFilterModel:()=>x.current.filter.filterModel,setPage:u=>{_({...x.current.pagination.paginationModel,page:u})},setPageSize:u=>{_({...x.current.pagination.paginationModel,pageSize:u,page:0})},scrollToIndexes:()=>{},copySelectedRows:()=>Promise.resolve()});return{state:f,dispatch:p,apiRef:y,setRows:b,setColumns:c,setSortModel:g,setFilterModel:m,setPaginationModel:_,setSelection:E,setDimensions:v,setDataSourceLoading:S,setDataSourceError:N,setRowCount:h}}function Jo(n){const{onRowOrderChange:t,rows:e,getRowId:o,rowReordering:l=!1}=n,[s,d]=i.useState(null),[a,f]=i.useState(null),p=i.useCallback(g=>o?o(g):g.id,[o]),x=i.useCallback(g=>m=>{l&&(d(g),m.dataTransfer.effectAllowed="move")},[l]),w=i.useCallback(g=>m=>{!l||!s||(m.preventDefault(),m.dataTransfer.dropEffect="move",a!==g&&f(g))},[l,s,a]),b=i.useCallback(()=>{d(null),f(null)},[]),c=i.useCallback(g=>m=>{if(m.preventDefault(),!s||!t){b();return}const _=e.findIndex(v=>p(v)===s),E=e.findIndex(v=>p(v)===g);_!==-1&&E!==-1&&_!==E&&t({row:e[_],oldIndex:_,targetIndex:E}),b()},[s,t,e,p,b]);return{draggedRowId:s,dragOverRowId:a,onDragStart:l?x:void 0,onDragOver:l?w:void 0,onDragEnd:l?b:void 0,onDrop:l?c:void 0}}function Qo(n){const{rows:t,getRowId:e,getTreeDataPath:o,treeData:l=!1,defaultGroupingExpansionDepth:s=0,filterModel:d,sortModel:a,onRowExpansionChange:f}=n,{treeNodes:p,rootIds:x,groupingRows:w}=i.useMemo(()=>{if(!l||!o)return{treeNodes:new Map,rootIds:[],groupingRows:[]};const h=new Map,y=[],u=[],j=new Map,P=F=>F.join("/");return t.forEach(F=>{const k=e(F),I=o(F),R=P(I);j.set(R,k),h.set(k,{id:k,parentId:null,depth:I.length-1,groupingKey:I[I.length-1],isExpanded:!1,children:[],serverChildrenCount:F.serverChildrenCount})}),t.forEach(F=>{const k=e(F),I=o(F);if(I.length===1){y.push(k);return}const R=$=>{if($.length<=1)return;const D=$.slice(0,-1),A=P(D);let z=j.get(A);if(z===void 0&&(z=`auto-group-${A}`,!h.has(z))){const Y=D[D.length-1];h.set(z,{id:z,parentId:null,depth:D.length-1,groupingKey:Y,isExpanded:!1,children:[],label:Y}),j.set(A,z);const V={id:z,name:Y,_isGroupRow:!0};u.push(V),D.length===1&&y.push(z),R(D)}return z},W=R(I);if(W!==void 0){const $=h.get(W),D=h.get(k);$&&D&&(D.parentId=W,$.children=$.children||[],$.children.includes(k)||$.children.push(k))}}),u.forEach(F=>{const k=F.id,I=h.get(k);if(!I)return;const W=k.replace("auto-group-","").split("/");if(W.length>1){const $=W.slice(0,-1),D=P($),A=j.get(D);if(A&&h.has(A)){I.parentId=A;const z=h.get(A);z&&(z.children=z.children||[],z.children.includes(k)||z.children.push(k))}}}),{treeNodes:h,rootIds:y,groupingRows:u}},[t,o,l,e]),b=i.useMemo(()=>{if(!l)return new Set;const h=new Set;return p.forEach(y=>{y.children&&y.children.length>0&&(s===-1||y.depth<s)&&h.add(y.id)}),h},[p,l,s]),[c,g]=i.useState(new Set);i.useEffect(()=>{b.size>0&&g(b)},[b]);const m=i.useCallback(h=>{g(y=>{const u=new Set(y),j=!u.has(h);if(u.has(h)?u.delete(h):u.add(h),j&&f){const P=p.get(h);P&&f(P)}return u})},[p,f]),_=i.useCallback(()=>{if(!l)return null;const h=new Map;t.forEach(R=>h.set(e(R),R)),w.forEach(R=>h.set(R.id,R));const y=R=>Qt(R,d),u=new Map,j=R=>{if(u.has(R))return u.get(R);const W=h.get(R);if(!W)return!1;if(y(W))return u.set(R,!0),!0;const D=p.get(R);return D&&D.children&&D.children.some(z=>j(z))?(u.set(R,!0),!0):(u.set(R,!1),!1)},P=(R,W)=>{if(!a||a.length===0)return 0;const $=h.get(R),D=h.get(W);if(!$||!D)return 0;for(const A of a){const z=$[A.field],Y=D[A.field],V=Zt(z,Y,A.sort);if(V!==0)return V}return 0},F=[],k=new Set,I=R=>{const W=R.filter($=>j($));W.sort(P),W.forEach($=>{if(k.has($))return;const D=h.get($),A=p.get($);if(D&&A){k.add($);const z={...D,_treeDepth:A.depth,_isExpanded:c.has($),_hasChildren:!!(A.children&&A.children.length>0||A.serverChildrenCount&&A.serverChildrenCount>0),_descendantCount:A.children?A.children.length:0};F.push(z),c.has($)&&A.children&&A.children.length>0&&I(A.children)}})};return I(x),F},[l,t,w,x,p,c,d,a,e]),E=i.useCallback(h=>c.has(h),[c]),v=i.useCallback(h=>p.get(h),[p]),S=i.useCallback(h=>{const y=[];let u=h;for(;u!==null;){const j=p.get(u);if(!j)break;y.unshift(j.groupingKey),u=j.parentId}return y},[p]),N=i.useMemo(()=>{const h=new Map,y=new Set(w.map(u=>u.id));return p.forEach((u,j)=>{h.set(j,{hasChildren:!!(u.children&&u.children.length>0||u.serverChildrenCount&&u.serverChildrenCount>0),treeDepth:u.depth,descendantCount:u.children?u.children.length:void 0,isGroupRow:y.has(j),isExpanded:c.has(j)})}),h},[p,w,c]);return i.useMemo(()=>({treeNodes:p,groupingRows:w,toggleExpansion:m,isGroupExpanded:E,getVisibleRows:_,getNode:v,getNodePath:S,rowMetaMap:N}),[p,w,m,E,_,v,S,N])}const Zo=n=>n?.depth===-1?"footer":"inline",er=[],tr={};function nr(n){const{rows:t,getRowId:e,columns:o,rowGroupingModel:l=er,aggregationModel:s=tr,defaultGroupingExpansionDepth:d=0,filterModel:a,sortModel:f,getAggregationPosition:p=Zo}=n,x=i.useMemo(()=>{const h=new Map;return(o??[]).forEach(y=>h.set(y.field,y)),h},[o]),[w,b]=i.useState(new Set),{treeNodes:c,rootIds:g,groupingRows:m}=i.useMemo(()=>{const h=new Map,y=new Map,u=[];if(l.length===0)return{treeNodes:h,rootIds:u,groupingRows:y};const j=(k,I,R)=>`auto-group-${k}-${I}-${R||"root"}`,P=(k,I,R)=>{if(I>=l.length)return k.map(z=>{const Y=e(z);return h.set(Y,{id:Y,parentId:R,depth:I,groupingKey:"",isExpanded:!1}),Y});const W=l[I],$=x.get(W);if($&&$.groupable===!1)return P(k,I+1,R);const D=new Map;k.forEach(z=>{const Y=z[W],V=String(Y);D.has(V)||D.set(V,[]),D.get(V).push(z)});const A=[];return D.forEach((z,Y)=>{const C=z[0][W],M=j(W,Y,R);A.push(M);const L={};s&&Object.entries(s).forEach(([oe,ie])=>{const ne=z.map(T=>T[oe]);if(ie==="sum")L[oe]=ne.reduce((T,le)=>T+(Number(le)||0),0);else if(ie==="min")L[oe]=Math.min(...ne.map(T=>Number(T)||0));else if(ie==="max")L[oe]=Math.max(...ne.map(T=>Number(T)||0));else if(ie==="avg"){const T=ne.reduce((le,te)=>le+(Number(te)||0),0);L[oe]=ne.length?T/ne.length:0}else ie==="count"&&(L[oe]=ne.length)});const O={[W]:C,...L,id:M};y.set(M,O);const H={id:M,parentId:R,depth:I,groupingKey:Y,groupingField:W,groupingValue:C,aggregatedValues:L,isExpanded:!1,children:[],label:$?.groupingValueFormatter?$.groupingValueFormatter({field:W,value:C}):`${W}: ${String(C)}`};H.aggregationPosition=p(H),h.set(M,H);const U=P(z,I+1,M);h.get(M).children=U;const K=z.length;h.get(M).descendantCount=K}),A},F=P(t,0,null);return u.push(...F),{treeNodes:h,rootIds:u,groupingRows:y}},[t,l,s,e,p,x]);i.useEffect(()=>{if(d===-1){const h=new Set;c.forEach((y,u)=>{y.children&&y.children.length>0&&h.add(u)}),b(h)}else if(d>0){const h=new Set;c.forEach((y,u)=>{y.depth<d&&y.children&&y.children.length>0&&h.add(u)}),b(h)}else b(new Set)},[l,d,c]);const _=i.useCallback(h=>{b(y=>{const u=new Set(y);return u.has(h)?u.delete(h):u.add(h),u})},[]),E=i.useCallback(h=>w.has(h),[w]),v=i.useCallback(()=>{if(l.length===0)return null;const h=[],y=new Set,u=new Map;t.forEach(k=>u.set(e(k),k));const j=k=>{const I=c.get(k);if(!I)return!1;if(!I.children||I.children.length===0){const R=u.get(k);return!(!R||a&&!Qt(R,a))}return I.children.some(R=>j(R))},P=k=>{let I=k;a&&(I=k.filter(j)),f&&f.length>0&&I.sort((R,W)=>{const $=m.get(R)||u.get(R),D=m.get(W)||u.get(W);if(!$||!D)return 0;for(const A of f){const z=$[A.field],Y=D[A.field],V=Zt(z,Y,A.sort);if(V!==0)return V}return 0}),I.forEach(R=>{if(y.has(R))return;const W=c.get(R),$=W?.children&&W.children.length>0,D=$?m.get(R):u.get(R);if(D&&W){y.add(R);const A={...D,_treeDepth:W.depth,_isExpanded:w.has(R),_hasChildren:$,_groupingField:W.groupingField,_groupingValue:W.groupingValue,_descendantCount:W.descendantCount};h.push(A),F.has(R)&&$&&P(W.children)}})},F=w;return P(g),h},[t,e,c,g,m,a,f,w,l]),S=i.useCallback(h=>c.get(h),[c]),N=i.useMemo(()=>{const h=new Map;return c.forEach((y,u)=>{const j=!!(y.children&&y.children.length>0);h.set(u,{hasChildren:j,treeDepth:y.depth,groupingField:y.groupingField,groupingValue:y.groupingValue,groupLabel:y.label,descendantCount:y.descendantCount,isGroupRow:j,isExpanded:j?w.has(u):void 0})}),h},[c,w]);return i.useMemo(()=>({treeNodes:c,groupingRows:m,toggleExpansion:_,isGroupExpanded:E,getVisibleRows:v,getNode:S,rowMetaMap:N}),[c,m,_,E,v,S,N])}function or(n){const{rows:t,getRowId:e,processRowUpdate:o,onProcessRowUpdateError:l,onRowChange:s}=n,[d,a]=i.useState(null),f=i.useRef(null),p=i.useCallback(c=>{a(c),f.current=typeof c=="function"?c(f.current):c},[]),x=i.useCallback(c=>{p({id:c.id,field:c.field,value:c.value,originalValue:c.value})},[p]),w=i.useCallback(async c=>{const g=f.current;if(!g)return;if(c?.cancel){p(null);return}const{id:m,field:_,value:E,originalValue:v}=g;if(E===v){p(null);return}const S=t.find(h=>e(h)===m);if(!S){p(null);return}const N={...S,[_]:E};try{if(o){const h=await o(N,S);s?.(h)}else s?.(N);p(null)}catch(h){l?.(h)}},[p,t,e,o,s,l]),b=i.useCallback(c=>{d&&d.id===c.id&&d.field===c.field&&p(g=>g?{...g,value:c.value}:null)},[d,p]);return{editingCell:d,startCellEdit:x,stopCellEdit:w,setEditCellValue:b}}function rr(n,t,e){const[o,l]=i.useState(new Map),[s,d]=i.useState({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}}),a=i.useCallback(()=>{l(new Map)},[]),f=i.useCallback((m,_)=>o.get(m)?.[_],[o]),p=i.useCallback((m,_,E,v,S)=>{const N=new Map(o);for(let h=v;h<S;h++){const y=t[h];if(!y)continue;let u=1;if(y.colSpan)if(typeof y.colSpan=="function"){const P={row:_,value:_[y.field],field:y.field,colDef:y,rowIndex:E,colIndex:h};u=y.colSpan(P)}else u=y.colSpan;if(u<=1){Qe(N,m,y.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:e[y.field]||100}});continue}let j=e[y.field]||100;for(let P=1;P<u;P++)if(h+P<S){const F=t[h+P];F&&(j+=e[F.field]||100,Qe(N,m,F.field,{spannedByColSpan:!0,leftVisibleCellIndex:h,rightVisibleCellIndex:Math.min(h+u-1,t.length-1)}))}Qe(N,m,y.field,{spannedByColSpan:!1,cellProps:{colSpan:u,width:j}}),h+=u-1}l(N)},[o,t,e]),x=i.useCallback((m,_)=>{const E={},v={},S={};t.forEach((N,h)=>{if(N.rowSpan)for(let y=m;y<_;y++){const u=n[y];if(!u||v[u.id]?.[N.field])continue;const j=N.valueGetter?N.valueGetter({row:u,field:N.field,value:u[N.field]}):u[N.field];let P=1;if(typeof N.rowSpan=="function"){const F={row:u,value:j,field:N.field,colDef:N,rowIndex:y,colIndex:h};P=N.rowSpan(F)}else typeof N.rowSpan=="number"&&(P=N.rowSpan);if(P>1){E[u.id]||(E[u.id]={}),E[u.id][N.field]=P;for(let F=1;F<P;F++){const k=y+F;if(k<_&&n[k]){const I=n[k];v[I.id]||(v[I.id]={}),v[I.id][N.field]=!0,S[k]||(S[k]={}),S[k][N.field]=y}}}}}),d({caches:{spannedCells:E,hiddenCells:v,hiddenCellOriginMap:S},processedRange:{firstRowIndex:m,lastRowIndex:_}})},[n,t]),w=i.useCallback(()=>{d({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}})},[]);i.useEffect(()=>{const m=new Map;n.forEach((S,N)=>{for(let h=0;h<t.length;h++){const y=t[h];if(!y)continue;let u=1;if(y.colSpan)if(typeof y.colSpan=="function"){const P={row:S,value:S[y.field],field:y.field,colDef:y,rowIndex:N,colIndex:h};u=y.colSpan(P)}else u=y.colSpan;if(u<=1){const P=e[y.field]||(typeof y.width=="number"?y.width:100);Qe(m,S.id,y.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:P}});continue}let j=e[y.field]||(typeof y.width=="number"?y.width:100);for(let P=1;P<u;P++)if(h+P<t.length){const F=t[h+P];if(F){const k=e[F.field]||(typeof F.width=="number"?F.width:100);j+=k,Qe(m,S.id,F.field,{spannedByColSpan:!0,leftVisibleCellIndex:h,rightVisibleCellIndex:Math.min(h+u-1,t.length-1)})}}Qe(m,S.id,y.field,{spannedByColSpan:!1,cellProps:{colSpan:u,width:j}}),h+=u-1}}),l(m);const _={},E={},v={};t.forEach((S,N)=>{if(S.rowSpan)for(let h=0;h<n.length;h++){const y=n[h];if(!y||E[y.id]?.[S.field])continue;const u=S.valueGetter?S.valueGetter({row:y,field:S.field,value:y[S.field]}):y[S.field];let j=1;if(typeof S.rowSpan=="function"){const P={row:y,value:u,field:S.field,colDef:S,rowIndex:h,colIndex:N};j=S.rowSpan(P)}else typeof S.rowSpan=="number"&&(j=S.rowSpan);if(j>1){_[y.id]||(_[y.id]={}),_[y.id][S.field]=j;for(let P=1;P<j;P++){const F=h+P;if(F<n.length&&n[F]){const k=n[F];E[k.id]||(E[k.id]={}),E[k.id][S.field]=!0,v[F]||(v[F]={}),v[F][S.field]=h}}}}}),d({caches:{spannedCells:_,hiddenCells:E,hiddenCellOriginMap:v},processedRange:{firstRowIndex:0,lastRowIndex:n.length}})},[n,t,e]);const b=i.useCallback(()=>s.caches.spannedCells,[s]),c=i.useCallback(()=>s.caches.hiddenCells,[s]),g=i.useCallback(()=>s.caches.hiddenCellOriginMap,[s]);return{colspanMap:o,resetColSpan:a,getCellColSpanInfo:f,calculateColSpan:p,rowSpanningState:s,calculateRowSpan:x,resetRowSpan:w,getSpannedCells:b,getHiddenCells:c,getHiddenCellOriginMap:g}}function Qe(n,t,e,o){let l=n.get(t);l||(l={},n.set(t,l)),l[e]=o}function ir(n){const{dataSource:t,sortModel:e,filterModel:o,paginationModel:l,paginationMode:s,sortingMode:d,filterMode:a,aggregationModel:f,setRows:p,setRowCount:x,setDataSourceLoading:w,setDataSourceError:b,onAggregationResults:c}=n,g=i.useRef(null),m=i.useRef(0),_=i.useCallback(async()=>{if(!t)return;const v=++m.current;w(!0),b(null);const S=l.page*l.pageSize,N=S+l.pageSize,h={startRow:S,endRow:N,sortModel:e,filterModel:o,groupKeys:[],aggregationModel:f};try{const y=await t.getRows(h);if(v!==m.current)return;let u=!1;if(s==="infinite"){const j=g.current;if(j){const P=JSON.stringify(j.sortModel)!==JSON.stringify(e),F=JSON.stringify(j.filterModel)!==JSON.stringify(o),k=j.pageSize!==l.pageSize;!P&&!F&&!k&&l.page>j.page&&(u=!0)}}p(u?j=>[...j,...y.rows]:y.rows,!0),y.aggregationResults&&c&&c(y.aggregationResults),y.rowCount!==void 0&&x(y.rowCount),g.current={sortModel:e,filterModel:o,page:l.page,pageSize:l.pageSize}}catch(y){v===m.current&&(b(y),console.error("Data Source Error:",y))}finally{v===m.current&&w(!1)}},[t,l.page,l.pageSize,e,o,s,f,c,p,x,w,b]);i.useEffect(()=>{if(t&&(s==="server"||s==="infinite"||d==="server"||a==="server")){const S=setTimeout(()=>{_()},300);return()=>clearTimeout(S)}},[_,t,s,d,a]);const E=i.useCallback(async(v,S)=>{if(t){w(!0);try{const N=await t.getRows({startRow:0,endRow:-1,sortModel:e,filterModel:o,groupKeys:S});N.rows.length>0&&p(h=>{const y=new Set(h.map(j=>j.id)),u=N.rows.filter(j=>!y.has(j.id));return[...h,...u]})}catch(N){b(N),console.error("Failed to fetch children:",N)}finally{w(!1)}}},[t,e,o,p,w,b]);return{fetchRows:_,fetchChildren:E}}const Pn="\0",wt="";function lr(n,t){const e=n.filter(o=>o!=null&&!isNaN(o));if(e.length===0)return null;switch(t){case"sum":return e.reduce((o,l)=>o+l,0);case"avg":return e.reduce((o,l)=>o+l,0)/e.length;case"count":return e.length;case"min":return Math.min(...e);case"max":return Math.max(...e)}}function Lt(n,t){return t.map(e=>String(n[e]??"")).join(Pn)}function en(n,t,e,o){return o?`${n}${wt}${t}${wt}${e}`:`${t}${wt}${e}`}function In(n,t,e,o){return i.useMemo(()=>{const l={pivotRows:[],pivotColumns:[],colKeys:[],isValid:!1};if(!o)return l;const{rowFields:s,columnFields:d,valueFields:a}=e;if(s.length===0||a.length===0)return l;const f=d.length>0,p=new Map(t.map(v=>[v.field,v])),x=new Set;for(const v of n)x.add(Lt(v,d));const w=Array.from(x).sort(),b=new Map;for(const v of n){const S=Lt(v,s);if(!b.has(S)){const u={};for(const j of s)u[j]=v[j];b.set(S,{labelValues:u,bucket:new Map})}const N=b.get(S),h=Lt(v,d);N.bucket.has(h)||N.bucket.set(h,new Map);const y=N.bucket.get(h);for(const u of a){const j=v[u.field];y.has(u.field)||y.set(u.field,[]),j!=null&&!isNaN(Number(j))&&y.get(u.field).push(Number(j))}}let c=0;const g=[];for(const[,v]of b){const S={id:c++,...v.labelValues};for(const N of w){const h=v.bucket.get(N);for(const y of a){const u=en(N,y.field,y.aggFn,f),j=h?.get(y.field)??[];S[u]=j.length>0?lr(j,y.aggFn):null}}g.push(S)}const m=new Map;for(const v of n){const S=Lt(v,d);for(const N of a){if(N.aggFn!=="avg"&&N.aggFn!=="min"&&N.aggFn!=="max")continue;const h=`${S}${wt}${N.field}`;m.has(h)||m.set(h,[]);const y=v[N.field];y!=null&&!isNaN(Number(y))&&m.get(h).push(Number(y))}}const _={id:"__pivot_grand_total__"};for(let v=0;v<s.length;v++)_[s[v]]=v===0?"Grand Total":"";for(const v of w)for(const S of a){const N=en(v,S.field,S.aggFn,f),h=g.map(u=>u[N]).filter(u=>u!=null&&!isNaN(Number(u))).map(Number);if(h.length===0){_[N]=null;continue}const y=`${v}${wt}${S.field}`;switch(S.aggFn){case"sum":case"count":_[N]=h.reduce((u,j)=>u+j,0);break;case"avg":{const u=m.get(y)??[];_[N]=u.length>0?u.reduce((j,P)=>j+P,0)/u.length:null;break}case"min":_[N]=Math.min(...m.get(y)??h);break;case"max":_[N]=Math.max(...m.get(y)??h);break}}g.push(_);const E=[];for(const v of s){const S=p.get(v);E.push({field:v,headerName:S?.headerName??v,width:S?.width??140,sortable:!0})}for(const v of w){const S=f?v.split(Pn).map((N,h)=>{const y=p.get(d[h]);return y?.headerName?`${y.headerName}: ${N}`:N}).join(" / "):"";for(const N of a){const h=p.get(N.field),y=en(v,N.field,N.aggFn,f),u=N.headerName??h?.headerName??N.field,j=S?`${S} — ${u} (${N.aggFn})`:`${u} (${N.aggFn})`;E.push({field:y,headerName:j,width:140,type:"number",align:"right",headerAlign:"right",sortable:!0,valueFormatter:({value:P})=>{if(P==null)return"—";const F=Number(P);return N.aggFn==="avg"?F.toFixed(2):N.aggFn==="count"?F.toLocaleString():h?.valueFormatter?h.valueFormatter({value:P,row:{},field:N.field}):F.toLocaleString()}})}}return{pivotRows:g,pivotColumns:E,colKeys:w,isValid:!0}},[n,t,e,o])}function sr(n){const t=document.createElement("textarea");t.value=n,t.style.cssText="position:fixed;top:-9999px;left:-9999px;opacity:0;",document.body.appendChild(t),t.focus(),t.select();let e=!1;try{e=document.execCommand("copy")}finally{document.body.removeChild(t)}return e}async function ar(n){let t=!1;try{t=sr(n)}catch{}if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function")try{await navigator.clipboard.writeText(n);return}catch(e){if(t)return;throw e}else if(!t)throw new Error("Clipboard API not available and fallback failed.")}function dr(n){const{selectedRowIds:t,columns:e,getVisibleRows:o,getRowId:l}=n,s=i.useCallback(async()=>{if(t.size===0)return;const a=o().filter(b=>t.has(l(b)));if(a.length===0)return;const f=e.filter(b=>!b.field.startsWith("__")),p=f.map(b=>b.headerName||b.field).join(" "),x=a.map(b=>f.map(c=>{const g=b[c.field];return c.valueFormatter?c.valueFormatter({value:g,row:b,field:c.field}):g??""}).join(" ")).join(`
7
- `),w=`${p}
8
- ${x}`;try{await ar(w)}catch(b){console.error("[OpenGridX] Failed to copy to clipboard:",b)}},[t,e,o,l]);return i.useEffect(()=>{const d=a=>{if(!(a.ctrlKey||a.metaKey)||a.key!=="c")return;const f=document.activeElement,p=f?.tagName.toLowerCase(),x=f?.type;p==="input"&&x!=="checkbox"&&x!=="radio"||p==="textarea"||p==="select"||f?.isContentEditable||s()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[s]),{copySelectedRows:s}}function cr({row:n,rowIndex:t,listViewColumn:e,isSelected:o=!1,checkboxSelection:l=!1,rowHeight:s,onRowClick:d,onSelectionChange:a}){const f={row:n,value:void 0,field:e.field,colDef:{field:e.field},rowIndex:t,colIndex:0},p=x=>{x.stopPropagation(),a?.(n.id,x.target.checked)};return r.jsxs("div",{className:`ogx-list-view__row${o?" ogx-list-view__row--selected":""}`,style:s?{minHeight:s}:void 0,onClick:()=>d?.(n),role:"row","aria-rowindex":t+2,"aria-selected":o,children:[l&&r.jsx("div",{className:"ogx-list-view__checkbox",onClick:x=>x.stopPropagation(),children:r.jsx("input",{type:"checkbox",checked:o,onChange:p,"aria-label":`Select row ${n.id}`})}),r.jsx("div",{className:"ogx-list-view__cell",role:"gridcell",children:e.renderCell(f)})]})}function ur({ariaLabel:n,allRenderableRows:t,filteredRows:e,pagination:o,effectivePaginationModel:l,pageSizeOptions:s,selectedRowIds:d,listViewColumn:a,noRowsLabel:f,rowHeight:p,checkboxSelection:x,paginationMode:w,dataSource:b,serverRowCount:c,paginationSlot:g,paginationSlotProps:m,localeText:_,onRowClick:E,onSelectionChange:v,onPaginationModelChange:S}){const N=g||Mn,h=w==="server"&&b?c||0:e.length;return r.jsxs("div",{className:"ogx-list-view",role:"grid","aria-label":n||"Data grid list view","aria-rowcount":t.length+1,children:[r.jsx("div",{className:"ogx-list-view__toolbar",children:r.jsxs("span",{children:[e.length," ",e.length===1?"item":"items",o?` · page ${l.page+1} of ${Math.ceil(e.length/l.pageSize)||1}`:"",d.size>0?` · ${d.size} selected`:""]})}),r.jsx("div",{className:"ogx-list-view__rows",children:t.length===0?r.jsxs("div",{className:"ogx-list-view__empty","aria-live":"polite",role:"status",children:[r.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[r.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),r.jsx("path",{d:"M3 9h18M9 21V9"})]}),f]}):t.map((y,u)=>r.jsx(cr,{row:y,rowIndex:u,listViewColumn:a,isSelected:d.has(y.id),checkboxSelection:x,rowHeight:p,onRowClick:j=>E({row:j,id:j.id,rowIndex:u}),onSelectionChange:v},y.id))}),o&&r.jsx(N,{page:l.page,pageSize:l.pageSize,rowCount:h,pageSizeOptions:s,onPageChange:y=>S({...l,page:y}),onPageSizeChange:y=>S({...l,pageSize:y,page:0}),localeText:_,...m})]})}function fr({value:n,onValueChange:t,onCommit:e,onCancel:o}){const[l,s]=i.useState(String(n??"")),d=i.useRef(null);return i.useEffect(()=>{d.current?.focus(),d.current?.select()},[]),r.jsx("input",{ref:d,type:"text",className:"ogx__edit-input",value:l,onChange:a=>{s(a.target.value),t(a.target.value)},onBlur:e,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),e()),a.key==="Escape"&&(a.stopPropagation(),o())}})}function gr({value:n,onValueChange:t,onCommit:e,onCancel:o}){const[l,s]=i.useState(typeof n=="number"?n:""),d=i.useRef(null);return i.useEffect(()=>{d.current?.focus(),d.current?.select()},[]),r.jsx("input",{ref:d,type:"number",className:"ogx__edit-input ogx__edit-input--number",value:l,onChange:a=>{const f=a.target.value===""?"":Number(a.target.value);s(f),t(f===""?null:f)},onBlur:e,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),e()),a.key==="Escape"&&(a.stopPropagation(),o())}})}function hr({value:n,onValueChange:t,onCommit:e,onCancel:o}){const l=i.useRef(null);i.useEffect(()=>{l.current?.focus()},[]);const s=()=>{t(!n),setTimeout(e,0)};return r.jsx("div",{className:"ogx__edit-boolean",children:r.jsx("input",{ref:l,type:"checkbox",className:"ogx__edit-checkbox",checked:!!n,onChange:s,onKeyDown:d=>{d.key==="Escape"&&(d.stopPropagation(),o())}})})}function pr({value:n,colDef:t,onValueChange:e,onCommit:o,onCancel:l}){const s=i.useRef(null);i.useEffect(()=>{s.current?.focus()},[]);const d=t.valueOptions??[];return r.jsx("select",{ref:s,className:"ogx__edit-select",value:String(n??""),onChange:a=>{e(a.target.value)},onBlur:o,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),o()),a.key==="Escape"&&(a.stopPropagation(),l())},children:d.map(a=>{const f=typeof a=="object"?a.value:a,p=typeof a=="object"?a.label:String(a);return r.jsx("option",{value:String(f),children:p},String(f))})})}function xr({value:n,onValueChange:t,onCommit:e,onCancel:o}){const[l,s]=i.useState(typeof n=="string"?n:String(n??"")),d=i.useRef(null);return i.useEffect(()=>{d.current?.focus()},[]),r.jsx("input",{ref:d,type:"date",className:"ogx__edit-input",value:l,onChange:a=>{s(a.target.value),t(a.target.value)},onBlur:e,onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),e()),a.key==="Escape"&&(a.stopPropagation(),o())}})}function mr(n){const{colDef:t}=n;switch(t.type){case"number":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(gr,{...n})});case"boolean":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(hr,{...n})});case"singleSelect":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(pr,{...n})});case"date":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(xr,{...n})});default:return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(fr,{...n})})}}function br({renderFn:n}){return r.jsx(r.Fragment,{children:n()})}class wr extends i.Component{constructor(t){super(t),this.state={hasError:!1,error:null,resetKey:t.resetKey}}static getDerivedStateFromProps(t,e){return e.hasError&&t.resetKey!==e.resetKey?{hasError:!1,error:null,resetKey:t.resetKey}:t.resetKey!==e.resetKey?{resetKey:t.resetKey}:null}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,e){process.env.NODE_ENV!=="production"&&console.warn(`[CellErrorBoundary] field="${this.props.field}"`,t,e.componentStack)}render(){return this.state.hasError?r.jsx("div",{className:"ogx__cell-error",role:"status","aria-label":`Error in cell: ${this.props.field}`,title:this.state.error?.message??"Render error",children:"⚠"}):r.jsx(br,{renderFn:this.props.renderFn})}}function vr(n){const{onCellClick:t,onCellEditStart:e,onCellValueChange:o,value:l,row:s,colDef:d,rowIndex:a,colIndex:f,isSelected:p,onClick:x,width:w,pinnedPosition:b,pinnedOffset:c,isFocused:g,isFocusVisible:m,isEditable:_,isEditing:E,onEditStart:v,onEditStop:S,onValueChange:N,colSpanInfo:h,rowSpan:y,isHiddenByRowSpan:u,rowMeta:j}=n,P=i.useCallback(C=>{o?o(d.field,C):N?.(C)},[o,N,d.field]),F=i.useMemo(()=>d.valueFormatter?d.valueFormatter({value:l,row:s,field:d.field}):l==null?"":String(l),[l,s,d]),k=i.useMemo(()=>d.cellClassName?typeof d.cellClassName=="function"?d.cellClassName({value:l,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:f})||"":d.cellClassName:"",[d,l,s,a,f]),I=i.useRef(null);if(i.useLayoutEffect(()=>{g&&I.current&&I.current.focus({preventScroll:!0})},[g]),h?.spannedByColSpan)return null;if(u)return r.jsx("div",{className:"ogx__cell ogx__cell--hidden",style:{width:w??d.width??100},role:"presentation","data-field":d.field,"data-colindex":f});const R=C=>{t&&t({row:s,field:d.field,value:l,colDef:d,rowIndex:a,colIndex:f}),x?.(C)},W=C=>{_&&(v||e)&&(C.stopPropagation(),e?e(d.field,l):v?.())},$=b!=null,D=["ogx__cell",`ogx__cell--align-${d.align||"left"}`,p&&"ogx__cell--selected",g&&"ogx__cell--focused",g&&m&&"ogx__cell--focus-visible",d.type&&`ogx__cell--type-${d.type}`,$&&"ogx__cell--pinned",$&&`ogx__cell--pinned-${b}`,E&&"ogx__cell--editing",y&&y>1&&"ogx__cell--spanned",k].filter(Boolean).join(" "),A=h?.cellProps?.colSpan||1,z=y||1,Y=h?.cellProps?.width??w??d.width??100,V={width:"var(--width)","--width":typeof Y=="number"?`${Y}px`:Y,flexGrow:d.flex??0,flexShrink:0,flexBasis:(d.flex,"auto"),boxSizing:"border-box",minWidth:d.minWidth,maxWidth:d.maxWidth,position:$?"sticky":void 0,zIndex:d.zIndex??($?3:void 0),padding:E?0:void 0};return z>1&&(V.height=`calc(var(--height) * ${z} - var(--border-width, 1px))`,V.zIndex=10,$&&(V.zIndex=40)),$&&c!==void 0&&(b==="left"?V.left=c:V.right=c),r.jsx("div",{ref:I,className:D,style:V,onClick:R,onDoubleClick:W,role:"gridcell","aria-colindex":f+1,"aria-readonly":!_||void 0,tabIndex:-1,"data-field":d.field,"data-colindex":f,...A>1?{"aria-colspan":A}:{},...z>1?{"aria-rowspan":z}:{},children:r.jsx("div",{className:"ogx__cell-content",children:E&&(o||N)&&S?d.renderEditCell?d.renderEditCell({value:l,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:f,rowMeta:j}):r.jsx(mr,{value:l,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:f,onValueChange:P,onCommit:()=>S(),onCancel:()=>S(!0)}):d.renderCell?r.jsx(wr,{field:d.field,resetKey:s,renderFn:()=>d.renderCell({value:l,row:s,field:d.field,colDef:d,rowIndex:a,colIndex:f,rowMeta:j})}):F})})}const Tn=i.memo(vr),_r=({className:n="",...t})=>r.jsx("button",{type:"button",className:`ogx-drag-handle ${n}`,"aria-label":"Drag to reorder row",...t,children:r.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"currentColor","aria-hidden":"true",children:r.jsx("path",{d:"M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2zm-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"})})});function Cr(n){const{content:t,height:e,isExpanded:o}=n;if(!o)return null;const l={height:e==="auto"?"auto":`${e}px`,overflow:e==="auto"?"visible":"auto"};return r.jsx("div",{className:"ogx__detail-panel",style:l,children:r.jsx("div",{className:"ogx__detail-panel-content",children:t})})}function Ft(n){const{row:t,columns:e,rowIndex:o,isSelected:l=!1,checkboxSelection:s=!1,onRowClick:d,onCellClick:a,onSelectionChange:f,columnWidths:p={},pinnedColumns:x,pinnedRows:w,hasDetailPanel:b=!1,isDetailPanelExpanded:c=!1,onDetailPanelToggle:g,detailPanelContent:m,detailPanelHeight:_=200,pinCheckboxColumn:E=!0,pinExpandColumn:v=!0,rowReordering:S=!1,onDragStart:N,onDragOver:h,onDragEnd:y,onDrop:u,isDragging:j,isDragOver:P,editingCell:F,onEditStart:k,onEditStop:I,onEditCellValueChange:R,focusedCellField:W,isFocusVisible:$,colspanMap:D,rowSpanningCaches:A,rowHeight:z=52,rowMeta:Y}=n,V=i.useId(),C=i.useRef(null),M=i.useRef(null);i.useLayoutEffect(()=>{W==="__expand_col__"&&C.current&&C.current.focus({preventScroll:!0}),W==="__checkbox_col__"&&M.current&&M.current.focus({preventScroll:!0})},[W]);const L=i.useMemo(()=>Xt(e,p,x,s,E,b,v,S),[e,p,x,s,E,b,v,S]),O=Y?.hasChildren===!0,H=i.useCallback((q,J)=>{O||k?.({id:t.id,field:q,value:J})},[O,t.id,k]),U=i.useCallback((q,J)=>{R?.({id:t.id,field:q,value:J})},[R,t.id]),K=i.useCallback(q=>{I?.({cancel:q})},[I]);if(t._isSkeleton){const q=Math.max(e.length,5);return r.jsx("div",{className:"ogx__row ogx__row--skeleton",role:"row","aria-hidden":"true",style:{height:z,minHeight:z},children:Array.from({length:q}).map((J,de)=>r.jsx("div",{className:"ogx__skeleton-cell",children:r.jsx("div",{className:"ogx__skeleton-bar"})},de))})}const oe=q=>{q.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell")||d?.({row:t,id:t.id,rowIndex:o})},ie=q=>{q.stopPropagation(),f?.(t.id,q.target.checked)},ne=q=>{q.stopPropagation(),g?.(t.id)},T=Jt(t.id,w),le=T==="top",te=T==="bottom",re=["ogx__row",l&&"ogx__row--selected",o%2===0&&"ogx__row--even",o%2===1&&"ogx__row--odd",le&&"ogx__row--pinned-top",te&&"ogx__row--pinned-bottom",j&&"ogx__row--dragging",P&&"ogx__row--drag-over",O&&"ogx__row--group"].filter(Boolean).join(" ");return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:re,onClick:oe,role:"row","aria-rowindex":o+1,"aria-selected":l,"data-rowindex":o,onDragOver:h?h(t.id):void 0,onDrop:u?u(t.id):void 0,style:{maxHeight:`${z}px`,minHeight:`${z}px`,"--height":`${z}px`,"--border-width":"1px"},children:[S&&r.jsx("div",{className:"ogx__cell ogx__cell--drag-handle",role:"gridcell","aria-label":"Drag to reorder row",style:{position:"sticky",left:0,zIndex:4},draggable:!0,onDragStart:N?N(t.id):void 0,onDragEnd:y,onClick:q=>q.stopPropagation(),children:r.jsx(_r,{})}),b&&r.jsx("div",{className:`ogx__cell ogx__cell--expand ${v?"ogx__cell--pinned-left":""} ${W==="__expand_col__"?"ogx__cell--focused":""} ${W==="__expand_col__"&&$?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":c?"Collapse row details":"Expand row details","aria-expanded":c,style:{position:v?"sticky":void 0,left:v?S?48:0:void 0,zIndex:v?5:void 0},ref:C,tabIndex:-1,onClick:q=>{q.stopPropagation(),a?.({row:t,field:"__expand_col__",value:c,colDef:{field:"__expand_col__",width:48},rowIndex:o,colIndex:-1})},children:r.jsx(Sn,{isExpanded:c,onClick:ne,variant:"plus-minus"})}),s&&r.jsx("div",{className:`ogx__cell ogx__cell--checkbox ${E?"ogx__cell--pinned-left":""} ${W==="__checkbox_col__"?"ogx__cell--focused":""} ${W==="__checkbox_col__"&&$?"ogx__cell--focus-visible":""}`,role:"gridcell",style:{position:E?"sticky":void 0,left:E?(S?48:0)+(b&&v?48:0):void 0,zIndex:E?11:void 0},ref:M,tabIndex:-1,onClick:q=>{q.stopPropagation(),a?.({row:t,field:"__checkbox_col__",value:l,colDef:{field:"__checkbox_col__",width:48},rowIndex:o,colIndex:-1})},children:r.jsx(mt,{id:V,name:`ogx-select-row-${t.id}`,checked:l,onChange:ie,onClick:q=>q.stopPropagation(),"aria-label":l?`Deselect row ${t.id}`:`Select row ${t.id}`,tabIndex:-1,onMouseDown:q=>q.preventDefault()})}),e.map((q,J)=>{if(q.isSpacer)return r.jsx("div",{style:{width:q.width,minWidth:q.width,flexShrink:0},"aria-hidden":"true"},q.field);const de=q.valueGetter?q.valueGetter({row:t,field:q.field,value:t[q.field]}):t[q.field],B=p[q.field]??q.width,Q=xt(q.field,x),Z=Q?L[q.field]:void 0,ge=F?.id===t.id&&F?.field===q.field,ce=ge?F?.value:de,Ee=D?.get(t.id)?.[q.field],Te=A?.spannedCells[t.id]?.[q.field],Pe=A?.hiddenCells[t.id]?.[q.field]||!1;return r.jsx(Tn,{value:ce,row:t,colDef:q,rowIndex:o,colIndex:J,isSelected:l,onCellClick:a,width:B,pinnedPosition:Q,pinnedOffset:Z,isFocused:W===q.field,isFocusVisible:$,isEditable:q.editable,isEditing:ge,onCellEditStart:H,onEditStop:K,onCellValueChange:U,colSpanInfo:Ee,rowSpan:Te,isHiddenByRowSpan:Pe,rowMeta:Y},q.field)})]}),b&&r.jsx(Cr,{row:t,rowId:t.id,rowIndex:o,content:m,height:_,isExpanded:c})]})}function Rn({rows:n,position:t,columns:e,selectedRowIds:o,checkboxSelection:l,onRowClick:s,onCellClick:d,onSelectionChange:a,columnWidths:f,pinnedColumns:p,pinnedRows:x,hasDetailPanel:w,expandedRowIds:b,getDetailPanelContent:c,getDetailPanelHeight:g,onDetailPanelToggle:m,pinCheckboxColumn:_,pinExpandColumn:E,focusedCell:v,colspanMap:S,rowSpanningCaches:N,rowHeight:h,rowMetaMap:y}){return n.length===0?null:r.jsx("div",{className:`ogx__pinned-rows ogx__pinned-rows--${t}`,role:"rowgroup",children:n.map((u,j)=>r.jsx(Ft,{row:u,columns:e,rowIndex:j,isSelected:o.has(u.id),checkboxSelection:l,onRowClick:s,onCellClick:d,onSelectionChange:a,columnWidths:f,pinnedColumns:p,pinnedRows:x,hasDetailPanel:w,isDetailPanelExpanded:b.has(u.id),detailPanelContent:c?c({row:u,id:u.id,rowIndex:j}):null,detailPanelHeight:g?.({row:u,id:u.id,rowIndex:j})||200,onDetailPanelToggle:m,pinCheckboxColumn:_,pinExpandColumn:E,focusedCellField:v?.id===u.id?v.field:null,colspanMap:S,rowSpanningCaches:N,rowHeight:h,rowMeta:y.get(u.id)},u.id))})}const yr=({columns:n,rowHeight:t,checkboxSelection:e=!1,hasDetailPanel:o=!1,rowReordering:l=!1})=>r.jsxs("div",{className:"ogx__row ogx__skeleton-row",style:{height:t},role:"row",children:[e&&r.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:r.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),o&&r.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:r.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),l&&r.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:r.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),n.map((s,d)=>{const a=typeof s.width=="number"?s.width:150,f=Math.min(a*.7,a-20);return r.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:a,minWidth:s.minWidth,maxWidth:s.maxWidth,left:s.left,right:s.right,position:s.isSpacer?"relative":s.pinned?"sticky":"relative",zIndex:s.zIndex},children:!s.isSpacer&&r.jsx("div",{className:"ogx-skeleton-box",style:{width:f,height:16,borderRadius:4}})},s.field||d)})]});function kr({virtualContainerHeight:n,offsetTop:t,effectiveLoading:e,visibleRows:o,baseColumns:l,virtualColumns:s,viewportWidth:d,checkboxSelection:a,hasDetailPanel:f,rowReordering:p,rowHeight:x,pinnedRows:w,selectedRowIds:b,onRowClick:c,onCellClick:g,onSelectionChange:m,columnWidths:_,pinnedColumns:E,expandedRowIds:v,getDetailPanelContent:S,getDetailPanelHeight:N,onDetailPanelToggle:h,pinCheckboxColumn:y,pinExpandColumn:u,rowReorderHandlers:j,editingHandlers:P,focusedCell:F,colspanMap:k,rowSpanningCaches:I,paginationMode:R,dataSourceLoading:W,sortedUnpinnedRowCount:$,infiniteScrollSkeletonCount:D,unpinnedRowsLength:A,rowMetaMap:z}){const Y=l.length>0?l:(()=>{const C=(d||1e3)-(a?48:0)-(f?48:0)-(p?48:0),M=150,L=Math.max(1,Math.ceil(C/M));return Array.from({length:L},(O,H)=>({field:`placeholder_${H}`,headerName:"",width:M}))})(),V=o.filter(({row:C})=>!Jt(C.id,w)).filter((C,M,L)=>M===L.findIndex(O=>O.row.id===C.row.id));return r.jsx("div",{className:"ogx__virtual-container",style:{height:`${n}px`},role:"presentation",children:r.jsxs("div",{className:"ogx__rows",style:{transform:`translateY(${t}px)`},role:"rowgroup",children:[e&&o.length===0?Array.from({length:10}).map((C,M)=>r.jsx(yr,{columns:Y,rowHeight:x,checkboxSelection:a,hasDetailPanel:f,rowReordering:p},`skeleton-${M}`)):V.map(({row:C,rowIndex:M})=>r.jsx(Ft,{row:C,columns:s,rowIndex:M,isSelected:b.has(C.id),checkboxSelection:a,onRowClick:c,onCellClick:g,onSelectionChange:m,columnWidths:_,pinnedColumns:E,pinnedRows:w,hasDetailPanel:f,isDetailPanelExpanded:v.has(C.id),detailPanelContent:S?S({row:C,id:C.id,rowIndex:M}):null,detailPanelHeight:N?.({row:C,id:C.id,rowIndex:M})||200,onDetailPanelToggle:h,pinCheckboxColumn:y,pinExpandColumn:u,rowReordering:p,onDragStart:j.onDragStart,onDragOver:j.onDragOver,onDragEnd:j.onDragEnd,onDrop:j.onDrop,isDragging:j.draggedRowId===C.id,isDragOver:j.dragOverRowId===C.id,editingCell:P.editingCell,onEditStart:P.startCellEdit,onEditStop:P.stopCellEdit,onEditCellValueChange:P.setEditCellValue,focusedCellField:F!=null&&F.id===C.id?F.field:null,colspanMap:k,rowSpanningCaches:I,rowHeight:x,rowMeta:z.get(C.id)},C.id)),R==="infinite"&&W&&$>0&&r.jsx("div",{className:"ogx__skeleton-group",children:Array.from({length:D}).map((C,M)=>r.jsx(Ft,{row:{id:`__skeleton_${M}__`,_isSkeleton:!0},columns:s,rowIndex:A+M,rowHeight:x},`__skeleton_${M}__`))})]})})}function Sr(){return r.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function jr(){return r.jsxs("svg",{className:"ogx-column-visibility-panel__drag-handle",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[r.jsx("circle",{cx:"9",cy:"5",r:"1.5"}),r.jsx("circle",{cx:"15",cy:"5",r:"1.5"}),r.jsx("circle",{cx:"9",cy:"12",r:"1.5"}),r.jsx("circle",{cx:"15",cy:"12",r:"1.5"}),r.jsx("circle",{cx:"9",cy:"19",r:"1.5"}),r.jsx("circle",{cx:"15",cy:"19",r:"1.5"})]})}function Ln(n){const{columns:t,visibleColumns:e,onVisibilityChange:o,onShowAll:l,onHideAll:s,onColumnReorder:d,onColumnOrderReset:a,showNonHideableColumns:f}=n,[p,x]=i.useState(""),[w,b]=i.useState(null),c=i.useRef(null),g=i.useMemo(()=>t.filter(u=>u.hideable!==!1),[t]),m=g.every(u=>e.has(u.field)),_=i.useMemo(()=>{const u=f?t:g;if(!p)return u;const j=p.toLowerCase();return u.filter(P=>(P.headerName||P.field).toLowerCase().includes(j))},[t,g,p,f]),E=u=>{u.target.checked?l():s()},v=u=>j=>{c.current=u,j.dataTransfer.effectAllowed="move",j.dataTransfer.setDragImage(j.currentTarget.closest(".ogx-column-visibility-panel__item"),20,20)},S=u=>j=>{j.preventDefault(),j.dataTransfer.dropEffect="move",u!==c.current&&b(u)},N=()=>{b(null)},h=u=>j=>{j.preventDefault();const P=c.current;b(null),c.current=null,P&&P!==u&&d&&d(P,u)},y=()=>{b(null),c.current=null};return r.jsxs("div",{className:"ogx-column-visibility-panel",children:[r.jsx("div",{className:"ogx-column-visibility-panel__search-section",children:r.jsxs("div",{className:"ogx-column-visibility-panel__search-container",children:[r.jsx(Sr,{}),r.jsx("input",{autoComplete:"off",className:"ogx-column-visibility-panel__search-input",placeholder:"Search",value:p,onChange:u=>x(u.target.value)})]})}),r.jsx("div",{className:"ogx-column-visibility-panel__list",children:_.map(u=>{const j=e.has(u.field),P=u.hideable!==!1,F=w===u.field,k=!!d&&!p;return r.jsxs("div",{className:["ogx-column-visibility-panel__item",!P&&"ogx-column-visibility-panel__item--disabled",F&&"ogx-column-visibility-panel__item--drag-over"].filter(Boolean).join(" "),draggable:k,onDragOver:k?S(u.field):void 0,onDragLeave:k?N:void 0,onDrop:k?h(u.field):void 0,onDragEnd:k?y:void 0,children:[k&&r.jsx("span",{className:"ogx-column-visibility-panel__drag-handle-wrapper",draggable:!0,onDragStart:v(u.field),title:"Drag to reorder",children:r.jsx(jr,{})}),r.jsxs("label",{className:"ogx-column-visibility-panel__item-label",style:{display:"flex",alignItems:"center",gap:"var(--ogx-spacing-md)",flex:1,cursor:P?"pointer":"not-allowed"},children:[r.jsx(mt,{checked:j,onChange:I=>o(u.field,I.target.checked),disabled:!P}),r.jsx("span",{className:"ogx-column-visibility-panel__label",children:u.headerName||u.field})]})]},u.field)})}),r.jsxs("div",{className:"ogx-column-visibility-panel__footer",children:[r.jsxs("label",{className:"ogx-column-visibility-panel__item",children:[r.jsx(mt,{checked:m,onChange:E}),r.jsx("span",{className:"ogx-column-visibility-panel__label",children:"Show/Hide All"})]}),r.jsx("button",{className:"ogx-column-visibility-panel__reset-btn",onClick:()=>{l(),a?.()},children:"Reset"})]})]})}function Er({isOpen:n,containerRef:t,panelRef:e,effectiveColumns:o,columnVisibilityModel:l,effectiveColumnOrder:s,columnOrder:d,disableColumnReorder:a,onClose:f,onColumnVisibilityChange:p,onColumnOrderChange:x,setInternalColumnOrder:w}){const[b,c]=i.useState(16),[g,m]=i.useState(16),[_,E]=i.useState(()=>document.body);if(i.useLayoutEffect(()=>{if(!n||!t.current)return;const S=t.current.getBoundingClientRect();c(S.top+8),m(window.innerWidth-S.right+8),E(t.current.closest(".ogx-theme-provider")||document.body)},[n,t]),!n)return null;const v=a?void 0:(S,N)=>{const h=[...s],y=h.indexOf(S),u=h.indexOf(N);if(y===-1||u===-1)return;const j=[...h];j.splice(y,1),j.splice(u,0,S),d||w(j),x?.({oldIndex:y,targetIndex:u,column:o.find(P=>P.field===S)})};return Ge.createPortal(r.jsxs("div",{ref:e,style:{position:"fixed",top:b,right:g,zIndex:9999,display:"inline-block"},children:[r.jsx("button",{onClick:f,style:{position:"absolute",top:-12,right:-12,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",background:"#334155",color:"#fff",border:"none",borderRadius:"50%",cursor:"pointer",fontSize:14,lineHeight:1,zIndex:1,boxShadow:"0 1px 4px rgba(0,0,0,0.2)"},"aria-label":"Close",children:"×"}),r.jsx(Ln,{columns:o,visibleColumns:new Set(o.filter(S=>l[S.field]!==!1).map(S=>S.field)),onVisibilityChange:(S,N)=>{p({...l,[S]:N})},onShowAll:()=>{const S={...l};o.forEach(N=>{N.hideable!==!1&&(S[N.field]=!0)}),p(S)},onHideAll:()=>{const S={...l};o.forEach(N=>{N.hideable!==!1&&(S[N.field]=!1)}),p(S)},onColumnReorder:v})]}),_)}const Nr=new Map;function Mr(n){const{rows:t,columns:e,getRowId:o,rowHeight:l=52,headerHeight:s=56,autoHeight:d=!1,density:a,checkboxSelection:f=!1,disableRowSelectionOnClick:p=!1,disableMultipleRowSelection:x=!1,rowSelectionModel:w,onRowSelectionModelChange:b,onRowClick:c,onCellClick:g,filterModel:m,onFilterModelChange:_,sortModel:E,onSortModelChange:v,pagination:S=!1,paginationModel:N,onPaginationModelChange:h,pageSizeOptions:y=[10,25,50,100],pinnedColumns:u,onPinnedColumnsChange:j,pinnedRows:P,getDetailPanelContent:F,getDetailPanelHeight:k,detailPanelExpandedRowIds:I,onDetailPanelExpandedRowIdsChange:R,pinCheckboxColumn:W=!0,pinExpandColumn:$=!0,disableColumnReorder:D=!1,columnOrder:A,onColumnOrderChange:z,height:Y,rowReordering:V=!1,onRowOrderChange:C,loading:M=!1,treeData:L=!1,getTreeDataPath:O,defaultGroupingExpansionDepth:H,groupingColDef:U,rowGroupingModel:K,aggregationModel:oe,onAggregationModelChange:ie,getAggregationPosition:ne,isCellEditable:T,processRowUpdate:le,onProcessRowUpdateError:te,dataSource:re,multiSort:q=!1,sortingMode:J="client",filterMode:de="client",paginationMode:B="client",rowCount:Q,slots:Z,slotProps:ge,pivotMode:ce=!1,pivotModel:Ee,onPivotModelChange:Te,className:Pe="",style:Re,onRowsScrollEnd:ze,ariaLabel:ee,initialState:ye,onStateChange:wi,columnVisibilityModel:vi,onColumnVisibilityModelChange:_i,listView:Ot=!1,listViewColumn:Gn,columnGroupingModel:Ve,noRowsLabel:Ci="No Data",localeText:Le,apiRef:nn,overscanRowCount:yi=3}=n,on=Le?.noRowsLabel??Ci,ki=i.useMemo(()=>({items:[]}),[]),Ne=m||ki,Si=i.useMemo(()=>[],[]),rn=K||Si,Vn=i.useRef(Z?.toolbar);Vn.current=Z?.toolbar;const ji=i.useRef(G=>{const X=Vn.current;return X?X(G):null}).current,Ei=po({initialState:ye,sortModel:E,aggregationModel:oe,onAggregationModelChange:ie,columnVisibilityModel:vi,onColumnVisibilityModelChange:_i,pinnedColumns:u,onPinnedColumnsChange:j,pivotModel:Ee,onPivotModelChange:Te,paginationModel:N,onPaginationModelChange:h,rowSelectionModel:w}),{sortModel:Ie,isSortControlled:Wt,setInternalSortModel:At,aggregationModel:Me,handleAggregationModelChange:Un,columnVisibilityModel:Ue,handleColumnVisibilityModelChange:$t,pinnedColumns:Ze,handlePinnedColumnsChange:ln,currentPivotModel:sn,handlePivotModelChange:Kn,effectivePaginationModel:ke,handlePaginationModelChange:an,selectedRowIds:ve,isSelectionControlled:et,setInternalRowSelectionModel:tt}=Ei,nt=b,zt=In(t,e,sn,ce),Be=a==="compact"?32:a==="comfortable"?72:l,Yn=ce&&zt.isValid?zt.pivotRows:t,dn=ce&&zt.isValid?zt.pivotColumns:e,Bt=!!(K&&K.length>0),Ke=i.useMemo(()=>U&&Bt&&!ce?{...Ze,left:["__group__",...(Ze?.left??[]).filter(G=>G!=="__group__")]}:Ze,[U,Bt,ce,Ze]),_t=i.useMemo(()=>U&&Bt&&!ce?[{headerName:"Group",width:220,...U,field:"__group__",hideable:!1,sortable:!1,pinnable:!1,exportable:!1},...dn]:dn,[U,Bt,ce,dn]),[Ni,qn]=i.useState(null);i.useEffect(()=>{qn(null)},[Me]);const ot=i.useRef(null),Mi=i.useRef(null),Ht=i.useRef(null),Pi=i.useCallback(G=>G.id,[]),rt=o||Pi,cn=i.useMemo(()=>Yn.map(G=>{const X=rt(G);return X===G.id?G:{...G,id:X}}),[Yn,rt]),it=i.useCallback(G=>{vn.current?.classList.toggle("ogx--kb",G)},[]),Xn=i.useRef(re);Xn.current=re;const Jn=i.useRef(null),Qn=i.useRef(null),Ii=i.useCallback(G=>{if(Xn.current&&L&&(G.serverChildrenCount??0)>0&&(G.children??[]).length===0){const X=Qn.current?.getNodePath(G.id)||[G.groupingKey];Jn.current?.(G.id,X)}},[L]),Ce=Xo({rows:cn,columns:_t,rowHeight:Be,headerHeight:s,rowCount:Q,columnVisibilityModel:Ue,initialState:n.initialState}),{state:pe,apiRef:lt,setRows:un,setColumns:Ti,setDimensions:Zn,setDataSourceLoading:Ri,setDataSourceError:Li,setRowCount:Fi}=Ce,{scrollTop:Oi,scrollLeft:Wi,overscanRows:Ai,handleScroll:$i}=No({onRowsScrollEnd:ze,overscanRowCount:yi});i.useEffect(()=>{nn&&(nn.current=lt.current)},[nn,lt]);const{copySelectedRows:eo}=dr({selectedRowIds:ve,columns:_t,getVisibleRows:()=>lt.current.getVisibleRows(),getRowId:rt});i.useEffect(()=>{lt.current.copySelectedRows=eo,lt.current.getSelectedRows=()=>Array.from(ve)},[eo,ve,lt]);const zi=pe.dataSource.loading,Ct=M||zi,st=i.useMemo(()=>pe.rows.allRows.map(G=>pe.rows.idRowsLookup.get(G)),[pe.rows]),yt=Qo({rows:st,getRowId:rt,getTreeDataPath:O,treeData:L,defaultGroupingExpansionDepth:H,filterModel:Ne,sortModel:Ie,onRowExpansionChange:Ii});i.useEffect(()=>{Qn.current=yt},[yt]);const kt=nr({rows:st,getRowId:rt,columns:_t,rowGroupingModel:rn,aggregationModel:Me,defaultGroupingExpansionDepth:H,filterModel:Ne,sortModel:Ie,getAggregationPosition:ne}),at=or({rows:st,getRowId:rt,processRowUpdate:le,onProcessRowUpdateError:te,onRowChange:G=>{const{dispatch:X}=Ce,ue=Array.from(Ce.state.rows.idRowsLookup.values()).map(fe=>fe.id===G.id?G:fe);X({type:"SET_ROWS",payload:ue})}}),St=L,He=!!(rn&&rn.length>0),fn=St||He,Dt=St?yt:He?kt:null,jt=i.useMemo(()=>St?yt.rowMetaMap:He?kt.rowMetaMap:Nr,[St,yt.rowMetaMap,He,kt.rowMetaMap]),Fe=S&&!He,Gt=i.useCallback(G=>{const{row:X,id:se}=G;if(fn&&jt.get(X.id)?.hasChildren){Dt?.toggleExpansion(se);return}if(c?.(G),!p){let ue;if(x)ue=ve.has(se)?[]:[se];else{const fe=new Set(ve);fe.has(se)?fe.delete(se):fe.add(se),ue=Array.from(fe)}et||tt(ue),nt?.(ue)}},[fn,Dt,c,jt,p,x,ve,et,tt,nt]),gn=ir({dataSource:re,sortModel:Ie,filterModel:Ne,paginationModel:ke,paginationMode:B,sortingMode:J,filterMode:de,aggregationModel:Me,setRows:un,setRowCount:Fi,setDataSourceLoading:Ri,setDataSourceError:Li,onAggregationResults:qn});i.useEffect(()=>{gn.fetchChildren&&(Jn.current=gn.fetchChildren)},[gn.fetchChildren]),i.useEffect(()=>{re||un(cn)},[cn,un,re]);const Oe=!!F,[Bi,Hi]=i.useState(new Set),dt=I??Bi,Vt=i.useCallback(G=>{const X=new Set(dt);X.has(G)?X.delete(G):X.add(G),I===void 0&&Hi(X),R?.(X)},[dt,I,R]),{effectiveColumns:De,orderedColumns:hn,visibleOrderedColumns:Di,navigationColumns:to,columnWidths:We,effectiveColumnOrder:Ut,setInternalColumnOrder:Kt,columnReorderHandlers:ct,handleColumnResize:Gi}=So({activeColumns:_t,isHierarchyEnabled:fn,isRowGrouping:He,isTreeData:St,activeHierarchyHandlers:Dt,columnVisibilityModel:Ue,columnOrder:A,onColumnOrderChange:z,disableColumnReorder:D,pivotMode:ce,checkboxSelection:f,hasDetailPanel:Oe,rowReordering:V,initialState:ye,setColumns:Ti});Mo({onStateChange:wi,sortModel:Ie,filterModel:Ne,effectivePaginationModel:ke,columnWidths:We,effectiveColumnOrder:Ut,columnVisibilityModel:Ue,pinnedColumns:Ke});const ut=Co({effectiveRows:st,activeHierarchyHandlers:Dt,filterMode:de,filterModel:Ne,dataSource:re,sortModel:Ie,sortingMode:J,pagination:Fe,paginationMode:B,effectivePaginationModel:ke,pinnedRows:P,isLoading:pe.dataSource.loading,pageSize:ke.pageSize}),Ye=ut.filteredRows,pn=ut.pinnedTopRows,xn=ut.pinnedBottomRows,Ae=ut.sortedUnpinnedRows,Et=ut.paginatedUnpinnedRows,mn=ut.allRenderableRows;i.useEffect(()=>{Ce.apiRef.current.getVisibleRows=()=>Fe?Et:Ae,Ce.apiRef.current.getAllFilteredRows=()=>Ae,Ce.apiRef.current.getVisibleColumns=()=>De},[Ae,Et,Fe,De,Ce.apiRef]);const Vi=Jo({rows:Fe?Et:Ae,getRowId:G=>G.id,onRowOrderChange:C,rowReordering:V}),ft=rr(mn,to,We),{aggregationResult:Nt}=jn({rows:Ye,columns:_t,aggregationModel:Me,isServerSide:!!(re&&(B==="server"||J==="server")),dataSource:re,filterModel:Ne,sortModel:Ie,serverAggregationResults:Ni}),gt=Object.keys(Me).length>0;i.useEffect(()=>{Ce.apiRef.current.getAggregationResult=()=>gt?Nt:null,Ce.apiRef.current.getAggregationModel=()=>gt?Me:null,Ce.apiRef.current.getGroupedExportRows=()=>{if(!He)return null;const{treeNodes:G,groupingRows:X}=kt,se=new Map;Ae.forEach(he=>se.set(he.id,he));const ue=[],fe=he=>{he.forEach(me=>{const be=G.get(me);if(!be)return;if(!!(be.children&&be.children.length>0))ue.push({type:"group-header",depth:be.depth,groupField:be.groupingField,groupValue:be.groupingValue}),fe(be.children),gt&&be.aggregatedValues&&ue.push({type:"group-subtotal",depth:be.depth,groupField:be.groupingField,groupValue:be.groupingValue,aggregatedValues:be.aggregatedValues});else{const Tt=se.get(me)??X.get(me);Tt&&ue.push({type:"leaf",depth:be.depth,row:Tt})}})};return fe(Array.from(G.keys()).filter(he=>G.get(he)?.parentId===null)),gt&&Nt&&ue.push({type:"grand-total",depth:0,aggregatedValues:Nt}),ue}},[Nt,Me,gt,Ce.apiRef,He,kt,Ae]);const xe=fo({rowHeight:Be,pagination:Fe,paginatedUnpinnedRows:Et,sortedUnpinnedRows:Ae,expandedRowIds:dt,getDetailPanelHeight:k,pinnedTopRowsLength:pn.length,pinnedBottomRowsLength:xn.length,visibleOrderedColumns:Di,pinnedColumns:Ke,columnWidths:We,viewportWidth:pe.dimensions.viewportWidth||1e3,checkboxSelection:f,hasDetailPanel:Oe,rowReordering:V,paginationMode:B,isLoading:pe.dataSource.loading,pageSize:ke.pageSize}),Ui=i.useMemo(()=>{const G={};for(const X of[...xe.leftPinnedCols,...xe.unpinnedColsWithWidth,...xe.rightPinnedCols])X.isSpacer||(G[X.field]=X.width);return{...G,...We}},[xe.leftPinnedCols,xe.unpinnedColsWithWidth,xe.rightPinnedCols,We]);i.useEffect(()=>{Ce.apiRef.current.scrollToIndexes=({rowIndex:G,colIndex:X})=>{const se=ot.current;if(se){if(G!==void 0&&G>=0){const ue=G>0?xe.cumulativeHeights[G-1]:0,fe=xe.cumulativeHeights[G]??ue,{scrollTop:he,clientHeight:me}=se;ue<he?se.scrollTop=ue:fe>he+me&&(se.scrollTop=fe-me)}if(X!==void 0&&X>=0){const fe=[...xe.leftPinnedCols,...xe.unpinnedColsWithWidth,...xe.rightPinnedCols][X];if(!fe)return;const he=xe.unpinnedColsWithWidth.findIndex(nl=>nl.field===fe.field);if(he===-1)return;const me=he>0?xe.unpinnedAccWidths[he-1]:0,be=xe.unpinnedAccWidths[he]??me,It=xe.leftWidth+be,{scrollLeft:Tt,clientWidth:io}=se;me<Tt?se.scrollLeft=me:It>Tt+io&&(se.scrollLeft=It-io)}}}},[xe,ot,Ce.apiRef]);const Se=yo({layout:xe,scrollTop:Oi,scrollLeft:Wi,viewportWidth:pe.dimensions.viewportWidth,viewportHeight:pe.dimensions.viewportHeight,autoHeight:d,rowReordering:V,hasDetailPanel:Oe,checkboxSelection:f,pinCheckboxColumn:W,pinExpandColumn:$,overscanRows:Ai});i.useEffect(()=>{if(!ot.current)return;const G=new ResizeObserver(X=>{for(const se of X){const{width:ue,height:fe}=se.contentRect;Zn(ue,fe)}});return G.observe(ot.current),()=>{G.disconnect()}},[Zn]);const Mt=i.useCallback((G,X)=>{const se=new Set(ve);X?se.add(G):se.delete(G);const ue=Array.from(se);et||tt(ue),nt?.(ue)},[ve,et,nt,tt]),Ki=i.useCallback(G=>{let X=[];G&&(X=st.map(se=>se.id)),et||tt(X),nt?.(X)},[st,et,nt,tt]),no=i.useCallback((G,X)=>{const se=X?[{field:G,sort:X}]:[];Wt||At(se),v?.(se)},[Wt,v,At]),Yi=i.useCallback((G,X)=>{const se=Ie.filter(fe=>fe.field!==G),ue=X?[...se,{field:G,sort:X}]:se;Wt||At(ue),v?.(ue)},[Ie,Wt,v,At]),{focusedCell:Yt,setFocusedCell:bn,handleFocus:qi,handleBlur:Xi,handleKeyDown:Ji}=go({allRenderableRows:mn,navigationColumns:to,checkboxSelection:f,selectedRowIds:ve,handleSelectionChange:Mt,handleDetailPanelToggle:Vt,editingHandlers:at,setKeyboardMode:it,sortModel:Ie,handleSort:no,isCellEditable:T,pagination:Fe,pageSize:ke.pageSize,virtualization:Se,viewportRef:ot}),wn=i.useCallback(G=>{it(!1),bn({id:G.row.id,field:G.field}),Ht.current?.focus({preventScroll:!0}),g?.(G)},[g,it,bn]),oo=i.useRef(at.editingCell);i.useEffect(()=>{const G=!!oo.current,X=!!at.editingCell;G&&!X&&Ht.current?.focus({preventScroll:!0}),oo.current=at.editingCell},[at.editingCell]);const Qi=jo({renderContext:Se.renderContext,pinnedTopRows:pn,pinnedBottomRows:xn,paginatedUnpinnedRows:Et,sortedUnpinnedRows:Ae,pagination:Fe}),Zi=t.length>0&&ve.size===t.length,el=ve.size>0&&ve.size<t.length,tl=i.useMemo(()=>De.some(G=>!!G.rowSpan),[De]),[Pt,qt]=i.useState(!1),vn=i.useRef(null),_n=i.useRef(null),ro=i.useMemo(()=>{if(!Z?.toolbar)return null;const G=D?void 0:(X,se)=>{const ue=[...Ut],fe=ue.indexOf(X),he=ue.indexOf(se);if(fe===-1||he===-1)return;const me=[...ue];me.splice(fe,1),me.splice(he,0,X),A||Kt(me);const be=De.find(It=>It.field===X);be&&z?.({oldIndex:fe,targetIndex:he,column:be})};return{apiRef:Ce.apiRef,columns:hn,baseColumns:e,aggregationModel:Me,onAggregationModelChange:Un,...ce||Ee||Te?{pivotModel:sn,onPivotModelChange:Kn}:{},filterModel:Ne,onFilterModelChange:_,columnVisibilityModel:Ue,onColumnVisibilityModelChange:$t,onColumnReorder:G,onColumnOrderReset:D?void 0:()=>Kt(e.map(X=>X.field)),forceColumnsOpen:Pt,onColumnsPanelClose:()=>qt(!1),...ge?.toolbar}},[Z?.toolbar,D,Ut,hn,De,A,z,Kt,Ce.apiRef,e,Me,Un,ce,Ee,Te,sn,Kn,Ne,_,Ue,$t,Pt,ge?.toolbar]);return i.useEffect(()=>{if(!Pt||Z?.toolbar)return;function G(X){_n.current&&!_n.current.contains(X.target)&&qt(!1)}return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[Pt,Z?.toolbar]),r.jsxs("div",{ref:vn,className:["ogx",Pe,d&&"ogx--auto-height",tl&&"ogx--row-spanning",Ot&&"ogx--list-view"].filter(Boolean).join(" "),style:{...Re,height:Y??Re?.height,"--ogx-row-height":`${Be}px`,"--ogx-header-height":`${s}px`},"aria-busy":Ct,children:[ro&&r.jsx(ji,{...ro}),!Z?.toolbar&&r.jsx(Er,{isOpen:Pt,containerRef:vn,panelRef:_n,effectiveColumns:De,columnVisibilityModel:Ue,effectiveColumnOrder:Ut,columnOrder:A,disableColumnReorder:D,onClose:()=>qt(!1),onColumnVisibilityChange:$t,onColumnOrderChange:z,setInternalColumnOrder:Kt}),Ot&&Gn&&r.jsx(ur,{ariaLabel:ee,allRenderableRows:mn,filteredRows:Ye,pagination:Fe,effectivePaginationModel:ke,pageSizeOptions:y,selectedRowIds:ve,listViewColumn:Gn,noRowsLabel:on,rowHeight:Be,checkboxSelection:f,paginationMode:B,dataSource:re,serverRowCount:pe.pagination.rowCount||0,paginationSlot:Z?.pagination,paginationSlotProps:ge?.pagination,localeText:Le?{paginationRowsPerPage:Le.paginationRowsPerPage,paginationOf:Le.paginationOf,paginationPage:Le.paginationPage}:void 0,onRowClick:Gt,onSelectionChange:Mt,onPaginationModelChange:an}),!Ot&&r.jsx("div",{ref:G=>{ot.current=G,Ht.current=G},className:"ogx__viewport",onScroll:$i,role:"grid","aria-label":ee||"Data grid","aria-rowcount":Ye.length+1,"aria-colcount":e.length+(f?1:0)+(Oe?1:0)+(V?1:0),"aria-busy":Ct,tabIndex:0,onKeyDownCapture:()=>{it(!0)},onMouseDownCapture:()=>{it(!1)},onKeyDown:Ji,onFocus:qi,onBlur:Xi,children:r.jsxs("div",{ref:Mi,className:"ogx__content",style:{width:Se.totalWidth},role:"presentation",children:[r.jsx(Nn,{columns:Se.virtualColumns,allColumns:De,columnGroupingModel:Ve,checkboxSelection:f,allSelected:Zi,someSelected:el,onSelectAll:Ki,sortModel:Ie,onSort:no,onSortAdd:Yi,multiSort:q,onColumnResize:Gi,columnWidths:We,pinnedColumns:Ke,focusedCell:Yt,onHeaderClick:G=>{bn({id:"HEADER",field:G}),it(!1),Ht.current?.focus({preventScroll:!0})},onDragStart:Ve?void 0:ct.onDragStart,onDragOver:Ve?void 0:ct.onDragOver,onDragEnd:Ve?void 0:ct.onDragEnd,onDrop:Ve?void 0:ct.onDrop,draggedColumn:Ve?void 0:ct.draggedColumn,dragOverColumn:Ve?void 0:ct.dragOverColumn,rowReordering:V,hasDetailPanel:Oe,pinCheckboxColumn:W,pinExpandColumn:$,aggregationModel:Me,onHideColumn:G=>{$t({...Ue,[G]:!1})},onManageColumns:()=>qt(!0),onPinColumn:(G,X)=>{const se=[...Ze?.left??[]],ue=[...Ze?.right??[]],fe=se.filter(me=>me!==G),he=ue.filter(me=>me!==G);ln(X==="left"?{left:[...fe,G],right:he}:X==="right"?{left:fe,right:[...he,G]}:{left:fe,right:he})}}),!Ct&&!pe.dataSource.error&&Ye.length===0&&r.jsx(To,{noRowsLabel:on,width:Se.totalWidth}),r.jsx(Rn,{rows:pn,position:"top",columns:Se.virtualColumns,selectedRowIds:ve,checkboxSelection:f,onRowClick:Gt,onCellClick:wn,onSelectionChange:Mt,columnWidths:We,pinnedColumns:Ke,pinnedRows:P,hasDetailPanel:Oe,expandedRowIds:dt,getDetailPanelContent:F,getDetailPanelHeight:k,onDetailPanelToggle:Vt,pinCheckboxColumn:W,pinExpandColumn:$,focusedCell:Yt,colspanMap:ft.colspanMap,rowSpanningCaches:ft.rowSpanningState.caches,rowHeight:Be,rowMetaMap:jt}),r.jsx(kr,{virtualContainerHeight:Se.totalHeight-Se.pinnedTopHeight-Se.pinnedBottomHeight,offsetTop:Se.offsetTop,effectiveLoading:Ct,visibleRows:Qi,baseColumns:e,virtualColumns:Se.virtualColumns,viewportWidth:pe.dimensions.viewportWidth,checkboxSelection:f,hasDetailPanel:Oe,rowReordering:V,rowHeight:Be,pinnedRows:P,selectedRowIds:ve,onRowClick:Gt,onCellClick:wn,onSelectionChange:Mt,columnWidths:We,pinnedColumns:Ke,expandedRowIds:dt,getDetailPanelContent:F,getDetailPanelHeight:k,onDetailPanelToggle:Vt,pinCheckboxColumn:W,pinExpandColumn:$,rowReorderHandlers:Vi,editingHandlers:at,focusedCell:Yt,colspanMap:ft.colspanMap,rowSpanningCaches:ft.rowSpanningState.caches,paginationMode:B,dataSourceLoading:pe.dataSource.loading,sortedUnpinnedRowCount:Ae.length,infiniteScrollSkeletonCount:Math.min(ke.pageSize,20),unpinnedRowsLength:xe.unpinnedRowsLength,rowMetaMap:jt}),r.jsx(Rn,{rows:xn,position:"bottom",columns:Se.virtualColumns,selectedRowIds:ve,checkboxSelection:f,onRowClick:Gt,onCellClick:wn,onSelectionChange:Mt,columnWidths:We,pinnedColumns:Ke,pinnedRows:P,hasDetailPanel:Oe,expandedRowIds:dt,getDetailPanelContent:F,getDetailPanelHeight:k,onDetailPanelToggle:Vt,pinCheckboxColumn:W,pinExpandColumn:$,focusedCell:Yt,colspanMap:ft.colspanMap,rowSpanningCaches:ft.rowSpanningState.caches,rowHeight:Be,rowMetaMap:jt}),gt&&!ce&&r.jsx(Io,{columns:hn,aggregationModel:Me,aggregationResult:Nt,columnWidths:Ui,rowHeight:Be,checkboxSelection:f,hasDetailPanel:Oe,rowReordering:V,pinnedColumns:Ke})]})}),!Ot&&Fe&&(()=>{const G=Z?.pagination||Mn;return r.jsx(G,{page:ke.page,pageSize:ke.pageSize,rowCount:pe.pagination.rowCount,pageSizeOptions:y,onPageChange:X=>an({...ke,page:X}),onPageSizeChange:X=>an({...ke,pageSize:X,page:0}),localeText:Le?{paginationRowsPerPage:Le.paginationRowsPerPage,paginationOf:Le.paginationOf,paginationPage:Le.paginationPage}:void 0,...ge?.pagination})})(),r.jsxs("div",{className:"ogx-aria-live-status",role:"status","aria-live":"polite",children:[Ct?"Loading data...":"",pe.dataSource.error?`Error: ${pe.dataSource.error instanceof Error?pe.dataSource.error.message:"Unknown error"}`:"",!M&&!pe.dataSource.error&&(Ye.length===0?on:Ne&&((Ne.quickFilterValues?.length||0)>0||(Ne.items?.length||0)>0)?`${Ye.length} ${Ye.length===1?"row":"rows"} found`:"")]}),r.jsx(Ro,{error:pe.dataSource.error})]})}function Pr({rows:n=5,columns:t=5}){return r.jsx("div",{className:"ogx__skeleton",children:Array.from({length:n}).map((e,o)=>r.jsx("div",{className:"ogx__skeleton-row",children:Array.from({length:t}).map((l,s)=>r.jsx("div",{className:"ogx__skeleton-cell",children:r.jsx("div",{className:"ogx__skeleton-content"})},s))},o))})}const Fn=new Set(["isEmpty","isNotEmpty"]);function Ir(n,t){return n.find(e=>"field"in e&&e.field===t)}const Tr=({col:n,item:t,onChange:e})=>{const o=i.useId(),l=vo(n.type),s=!!t,d=t?.operator??l[0],[a,f]=i.useState(t?.value!=null?String(t.value):""),p=i.useRef(e),x=i.useRef(t),w=i.useRef(n.field),b=i.useRef(d);i.useLayoutEffect(()=>{p.current=e,x.current=t,w.current=n.field,b.current=d});const c=i.useRef(t?.value);i.useEffect(()=>{t?.value!==c.current&&(c.current=t?.value,f(t?.value!=null?String(t.value):""))},[t?.value]),i.useEffect(()=>{const S=setTimeout(()=>{const N=x.current,h=N?.value??"";a!==h&&p.current({id:N?.id??`${w.current}-${Date.now()}`,field:w.current,operator:b.current,value:a})},300);return()=>clearTimeout(S)},[a]);const g=S=>{const N=Fn.has(S),h={id:t?.id??`${n.field}-${Date.now()}`,field:n.field,operator:S,value:N?void 0:t?.value??(n.type==="boolean"?"true":"")};e(h)},m=()=>{f(""),e(null)},_=Fn.has(String(d)),E=n.type==="boolean",v=!_;return r.jsxs("div",{className:`ogx-filter__row${s?" ogx-filter__row--active":""}`,children:[r.jsx("span",{className:"ogx-filter__col-label",title:n.field,children:n.headerName||n.field}),r.jsxs("div",{className:"ogx-filter__controls",children:[r.jsx("select",{id:`${o}-op`,name:`filter-op-${n.field}`,className:`ogx-filter__op-select${s?" ogx-filter__op-select--active":""}`,value:String(d),onChange:S=>g(S.target.value),"aria-label":`Filter operator for ${n.headerName||n.field}`,children:l.map(S=>r.jsx("option",{value:S,children:S},S))}),v&&E&&r.jsxs("select",{id:`${o}-val`,name:`filter-val-${n.field}`,className:`ogx-filter__value-input ogx-filter__value-select${s?" ogx-filter__value-input--active":""}`,value:String(t?.value??"true"),onChange:S=>{f(S.target.value),e({id:t?.id??`${n.field}-${Date.now()}`,field:n.field,operator:d,value:S.target.value})},"aria-label":`Filter value for ${n.headerName||n.field}`,children:[r.jsx("option",{value:"true",children:"true"}),r.jsx("option",{value:"false",children:"false"})]}),v&&!E&&r.jsx("input",{id:`${o}-val`,name:`filter-val-${n.field}`,className:`ogx-filter__value-input${s?" ogx-filter__value-input--active":""}`,type:"text",value:a,onChange:S=>f(S.target.value),placeholder:n.type==="number"?"Number…":"Value…","aria-label":`Filter value for ${n.headerName||n.field}`}),s&&r.jsx("button",{className:"ogx-filter__row-clear",onClick:m,"aria-label":`Clear filter for ${n.headerName||n.field}`,title:"Clear",children:"×"})]})]})},On=({filterModel:n,columns:t,onFilterModelChange:e})=>{const o=i.useMemo(()=>n.items??[],[n.items]),l=n.logicOperator??"and",s=i.useCallback((f,p)=>{const x=o.filter(b=>"field"in b&&b.field!==f),w=p?[...x,p]:x;e({...n,items:w})},[o,n,e]),d=i.useCallback(f=>{e({...n,logicOperator:f})},[n,e]),a=t.filter(f=>f.filterable!==!1);return r.jsxs(r.Fragment,{children:[o.length>1&&r.jsxs("div",{className:"ogx-filter__logic-bar",children:[r.jsx("span",{className:"ogx-filter__logic-label",children:"Match:"}),r.jsx("button",{className:`ogx-filter__logic-pill${l==="and"?" ogx-filter__logic-pill--active":""}`,onClick:()=>d("and"),"aria-pressed":l==="and",children:"ALL (AND)"}),r.jsx("button",{className:`ogx-filter__logic-pill${l==="or"?" ogx-filter__logic-pill--active":""}`,onClick:()=>d("or"),"aria-pressed":l==="or",children:"ANY (OR)"})]}),a.length===0?r.jsx("div",{className:"ogx-filter__empty",children:"No filterable columns."}):a.map(f=>r.jsx(Tr,{col:f,item:Ir(o,f.field),onChange:p=>s(f.field,p)},f.field))]})},Rr=["sum","avg","count","min","max"];function Wn(){return r.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[r.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),r.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),r.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),r.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1",fill:"currentColor",opacity:"0.25"}),r.jsx("path",{d:"M17 14v-4M17 10l-2 2 2 2"})]})}function Lr({anchorRef:n,columns:t,model:e,onChange:o,onClose:l}){const s=i.useRef(null),[d,a]=i.useState({top:0,right:0}),[f,p]=i.useState(document.body);i.useLayoutEffect(()=>{p(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const x=i.useCallback(()=>{if(!n.current)return{top:0,right:0};const k=n.current.getBoundingClientRect();return{top:k.bottom+6,right:window.innerWidth-k.right}},[n]);i.useEffect(()=>{a(x());const k=()=>a(x());return window.addEventListener("scroll",k,!0),window.addEventListener("resize",k),()=>{window.removeEventListener("scroll",k,!0),window.removeEventListener("resize",k)}},[x]),i.useEffect(()=>{function k(R){s.current&&!s.current.contains(R.target)&&n.current&&!n.current.contains(R.target)&&l()}function I(R){R.key==="Escape"&&l()}return document.addEventListener("mousedown",k),document.addEventListener("keydown",I),()=>{document.removeEventListener("mousedown",k),document.removeEventListener("keydown",I)}},[n,l]);const w=new Set(e.rowFields),b=new Set(e.columnFields),c=new Set(e.valueFields.map(k=>k.field)),g=k=>w.has(k)||b.has(k)||c.has(k);function m(k){w.has(k)||o({...e,rowFields:[...e.rowFields,k]})}function _(k){b.has(k)||o({...e,columnFields:[...e.columnFields,k]})}function E(k,I="sum"){c.has(k)||o({...e,valueFields:[...e.valueFields,{field:k,aggFn:I}]})}function v(k){o({...e,rowFields:e.rowFields.filter(I=>I!==k)})}function S(k){o({...e,columnFields:e.columnFields.filter(I=>I!==k)})}function N(k){o({...e,valueFields:e.valueFields.filter(I=>I.field!==k)})}function h(k,I){o({...e,valueFields:e.valueFields.map(R=>R.field===k?{...R,aggFn:I}:R)})}function y(){o({rowFields:[],columnFields:[],valueFields:[]})}const u=new Set(t.filter(k=>k.type==="number"||k.aggregable).map(k=>k.field)),j=e.rowFields.length+e.columnFields.length+e.valueFields.length,P=k=>t.find(I=>I.field===k)?.headerName??k,F=r.jsxs("div",{ref:s,className:"ogx-pivot-panel",role:"dialog","aria-label":"Pivot configuration",style:{top:d.top,right:d.right},children:[r.jsxs("div",{className:"ogx-pivot-panel__header",children:[r.jsxs("span",{className:"ogx-pivot-panel__title",children:[r.jsx(Wn,{}),"Pivot Mode"]}),j>0&&r.jsx("button",{className:"ogx-pivot-panel__reset-btn",onClick:y,title:"Reset pivot",children:"Reset"})]}),r.jsxs("div",{className:"ogx-pivot-panel__body",children:[r.jsxs("div",{className:"ogx-pivot-zone",children:[r.jsxs("span",{className:"ogx-pivot-zone__label",children:[r.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--row"}),"Row Fields"]}),r.jsx("div",{className:`ogx-pivot-chips${e.rowFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — each becomes a row label",children:e.rowFields.map(k=>r.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--row",children:[P(k),r.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>v(k),title:`Remove ${P(k)}`,children:"×"})]},k))})]}),r.jsxs("div",{className:"ogx-pivot-zone",children:[r.jsxs("span",{className:"ogx-pivot-zone__label",children:[r.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--col"}),"Column Fields"]}),r.jsx("div",{className:`ogx-pivot-chips${e.columnFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — unique values become column headers",children:e.columnFields.map(k=>r.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--col",children:[P(k),r.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>S(k),title:`Remove ${P(k)}`,children:"×"})]},k))})]}),r.jsxs("div",{className:"ogx-pivot-zone",children:[r.jsxs("span",{className:"ogx-pivot-zone__label",children:[r.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--value"}),"Value Fields (aggregated)"]}),r.jsx("div",{className:`ogx-pivot-chips${e.valueFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add numeric fields here — values are aggregated",children:e.valueFields.map(k=>r.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--value",children:[P(k.field),r.jsx("select",{className:"ogx-pivot-chip__fn-select",value:k.aggFn,onChange:I=>h(k.field,I.target.value),title:"Aggregation function",children:Rr.map(I=>r.jsx("option",{value:I,children:I.toUpperCase()},I))}),r.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>N(k.field),title:`Remove ${P(k.field)}`,children:"×"})]},k.field))})]}),r.jsx("hr",{className:"ogx-pivot-panel__divider"}),r.jsxs("div",{children:[r.jsx("div",{className:"ogx-pivot-panel__fields-label",children:"Available Fields"}),r.jsxs("div",{className:"ogx-pivot-fields",children:[t.map(k=>{const I=u.has(k.field);return g(k.field)?null:r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3},children:[r.jsx("span",{className:`ogx-pivot-field-btn${I?" ogx-pivot-field-btn--numeric":""}`,children:k.headerName??k.field}),r.jsxs("div",{className:"ogx-pivot-field-actions",children:[r.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--row",onClick:()=>m(k.field),title:"Add to Row Fields",children:"Row"}),r.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--col",onClick:()=>_(k.field),title:"Add to Column Fields",children:"Col"}),I&&r.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--value",onClick:()=>E(k.field),title:"Add to Value Fields",children:"Val"})]})]},k.field)}),t.every(k=>g(k.field))&&r.jsx("span",{style:{fontSize:12,color:"var(--ogx-color-gray-400, #94a3b8)"},children:"All fields are in use."})]})]})]})]});return Ge.createPortal(F,f)}function Fr(){return r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function Or(){return r.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function Wr({value:n="",onChange:t,placeholder:e="Search...",debounceMs:o=250}){const[l,s]=i.useState(()=>n.length>0),[d,a]=i.useState(n),f=i.useRef(null),p=i.useRef(null),x=i.useRef(t);i.useLayoutEffect(()=>{x.current=t},[t]);const w=i.useRef(n),b=i.useRef(n),c=i.useRef(!1);i.useLayoutEffect(()=>{c.current&&document.activeElement!==f.current&&f.current?.focus()}),i.useEffect(()=>{n!==b.current&&(b.current=n,n!==w.current&&(a(n),w.current=n,n?s(!0):(c.current=!1,s(!1))))},[n]),i.useEffect(()=>{const v=setTimeout(()=>{d!==w.current&&(w.current=d,x.current(d))},o);return()=>clearTimeout(v)},[d,o]);const g=i.useCallback(()=>{s(!0),requestAnimationFrame(()=>f.current?.focus())},[]),m=i.useCallback(v=>{v.stopPropagation(),a(""),w.current="",x.current(""),f.current?.focus()},[]),_=i.useCallback(()=>{c.current=!0,s(!0)},[]),E=i.useCallback(()=>{c.current=!1,setTimeout(()=>{if(p.current&&document.activeElement&&p.current.contains(document.activeElement)){c.current=!0;return}d||s(!1)},150)},[d]);return i.useEffect(()=>{const v=S=>{p.current&&!p.current.contains(S.target)&&(d||s(!1))};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[d]),r.jsxs("div",{ref:p,className:`ogx-global-search${l?" ogx-global-search--expanded":""}`,onClick:l?void 0:g,children:[r.jsx("div",{className:"ogx-global-search__icon-wrapper",children:r.jsx(Fr,{})}),r.jsx("input",{ref:f,className:"ogx-global-search__input",value:d,onChange:v=>a(v.target.value),onFocus:_,onBlur:E,placeholder:e,"aria-label":"Global Search",autoComplete:"off"}),d&&r.jsx("button",{className:"ogx-global-search__clear",onClick:m,"aria-label":"Clear search",children:r.jsx(Or,{})})]})}function vt({title:n,children:t,placement:e="top",enterDelay:o=200,leaveDelay:l=0}){const[s,d]=i.useState(!1),[a,f]=i.useState({top:0,left:0}),p=i.useRef(null),x=i.useRef(null),w=i.useCallback(()=>{if(!x.current)return;const m=x.current.getBoundingClientRect();let _=0,E=0;const v=window.pageXOffset||document.documentElement.scrollLeft,S=window.pageYOffset||document.documentElement.scrollTop;e==="top"?(_=m.top+S-8,E=m.left+v+m.width/2):e==="bottom"&&(_=m.bottom+S+8,E=m.left+v+m.width/2),f({top:_,left:E})},[e]);i.useLayoutEffect(()=>(s&&(w(),window.addEventListener("scroll",w,!0),window.addEventListener("resize",w)),()=>{window.removeEventListener("scroll",w,!0),window.removeEventListener("resize",w)}),[s,w]);const b=()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{d(!0)},o)},c=()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{d(!1)},l)},g=i.useCallback(m=>{x.current=m?m.firstElementChild??m:null},[]);return r.jsxs(r.Fragment,{children:[r.jsx("span",{ref:g,style:{display:"inline-block",lineHeight:0},onMouseEnter:b,onMouseLeave:c,children:t}),s&&n&&Ge.createPortal(r.jsx("div",{className:`ogx-tooltip ogx-tooltip--${e}`,style:{top:a.top,left:a.left,position:"absolute",zIndex:99999},children:n}),document.body)]})}const Ar=["none","sum","avg","count","min","max"];function An(){return r.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r.jsx("path",{d:"M18 4H6l6 8-6 8h12"})})}function $r(){return r.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",children:[r.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),r.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.25"}),r.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),r.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),r.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),r.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function $n(){return r.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})})}function zr({anchorRef:n,aggregationModel:t,aggregableColumns:e,onFunctionChange:o,onClearAll:l,onClose:s,activeCount:d}){const a=i.useRef(null),[f,p]=i.useState({top:0,right:0}),[x,w]=i.useState(document.body);i.useLayoutEffect(()=>{w(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const b=i.useCallback(()=>{if(!n.current)return{top:0,right:0};const g=n.current.getBoundingClientRect();return{top:g.bottom+6,right:window.innerWidth-g.right}},[n]);i.useEffect(()=>{p(b());const g=()=>p(b());return window.addEventListener("scroll",g,!0),window.addEventListener("resize",g),()=>{window.removeEventListener("scroll",g,!0),window.removeEventListener("resize",g)}},[b]),i.useEffect(()=>{function g(m){a.current&&!a.current.contains(m.target)&&n.current&&!n.current.contains(m.target)&&s()}return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[n,s]),i.useEffect(()=>{function g(m){m.key==="Escape"&&s()}return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[s]);const c=r.jsxs("div",{ref:a,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Summaries configuration",style:{top:f.top,right:f.right,width:400,maxWidth:"calc(100vw - 24px)"},children:[r.jsxs("div",{className:"ogx-toolbar__panel-header",children:[r.jsxs("span",{className:"ogx-toolbar__panel-title",children:[r.jsx(An,{}),"Summaries"]}),d>0&&r.jsx("button",{className:"ogx-toolbar__clear-btn",onClick:l,title:"Clear all summaries",children:"Clear all"})]}),r.jsx("div",{className:"ogx-toolbar__panel-body",children:e.length===0?r.jsxs("p",{className:"ogx-toolbar__empty",children:["No aggregable columns.",r.jsx("br",{}),"Set ",r.jsx("code",{children:"aggregable: true"})," on a column to enable."]}):e.map(g=>{const m=t[g.field]||"none";return r.jsxs("div",{className:"ogx-toolbar__agg-row",children:[r.jsx("span",{className:"ogx-toolbar__agg-label",title:g.field,children:g.headerName||g.field}),r.jsx("div",{className:"ogx-toolbar__agg-pills",children:Ar.map(_=>r.jsx("button",{className:`ogx-toolbar__pill${m===_?" ogx-toolbar__pill--active":""}`,onClick:()=>o(g.field,_),"aria-pressed":m===_,children:_},_))})]},g.field)})})]});return Ge.createPortal(c,x)}function Br({anchorRef:n,columns:t,visibleColumns:e,onVisibilityChange:o,onShowAll:l,onHideAll:s,onColumnReorder:d,onColumnOrderReset:a,onClose:f,showNonHideableColumns:p}){const x=i.useRef(null),[w,b]=i.useState({top:0,right:0}),[c,g]=i.useState(document.body);i.useLayoutEffect(()=>{g(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const m=i.useCallback(()=>{if(!n.current)return{top:0,right:0};const E=n.current.getBoundingClientRect();return{top:E.bottom+6,right:window.innerWidth-E.right}},[n]);i.useEffect(()=>{b(m());const E=()=>b(m());return window.addEventListener("scroll",E,!0),window.addEventListener("resize",E),()=>{window.removeEventListener("scroll",E,!0),window.removeEventListener("resize",E)}},[m]),i.useEffect(()=>{function E(v){x.current&&!x.current.contains(v.target)&&n.current&&!n.current.contains(v.target)&&f()}return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[n,f]);const _=r.jsx("div",{ref:x,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Column visibility",style:{top:w.top,right:w.right,width:280,padding:0},children:r.jsx(Ln,{columns:t,visibleColumns:e,onVisibilityChange:o,onShowAll:l,onHideAll:s,onColumnReorder:d,onColumnOrderReset:a,showNonHideableColumns:p})});return Ge.createPortal(_,c)}function Hr({anchorRef:n,columns:t,filterModel:e,onFilterModelChange:o,onClose:l}){const s=i.useRef(null),[d,a]=i.useState({top:0,right:0}),f=i.useRef(l);i.useLayoutEffect(()=>{f.current=l},[l]);const[p,x]=i.useState(document.body);i.useLayoutEffect(()=>{x(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const w=i.useCallback(()=>{if(!n.current)return{top:0,right:0};const m=n.current.getBoundingClientRect();return{top:m.bottom+6,right:window.innerWidth-m.right}},[n]);i.useEffect(()=>{a(w());const m=()=>a(w());return window.addEventListener("scroll",m,!0),window.addEventListener("resize",m),()=>{window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m)}},[w]),i.useEffect(()=>{function m(_){_.key==="Escape"&&f.current()}return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[]);const b=e.items?.length??0,c=()=>{o({...e,items:[],logicOperator:"and"})},g=r.jsxs("div",{ref:s,className:"ogx-toolbar__panel ogx-toolbar__panel--filter",role:"dialog","aria-label":"Advanced filters",style:{top:d.top,right:d.right,width:540,maxWidth:"calc(100vw - 24px)"},children:[r.jsxs("div",{className:"ogx-toolbar__panel-header",children:[r.jsxs("span",{className:"ogx-toolbar__panel-title",children:[r.jsx($n,{}),"Filters",b>0&&r.jsx("span",{className:"ogx-toolbar__panel-count",children:b})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[b>0&&r.jsx("button",{className:"ogx-toolbar__clear-btn",onClick:c,title:"Clear all filters",children:"Clear all"}),r.jsx("button",{className:"ogx-toolbar__close-btn",onClick:()=>f.current(),title:"Close filters","aria-label":"Close filters panel",children:"Close"})]})]}),r.jsx("div",{className:"ogx-toolbar__panel-body ogx-toolbar__panel-body--filter",children:r.jsx(On,{columns:t,filterModel:e,onFilterModelChange:o})})]});return Ge.createPortal(g,p)}const Dr={rowFields:[],columnFields:[],valueFields:[]};function Gr({columns:n=[],baseColumns:t,aggregationModel:e={},onAggregationModelChange:o,pivotModel:l,onPivotModelChange:s,filterModel:d,onFilterModelChange:a,columnVisibilityModel:f={},onColumnVisibilityModelChange:p,onColumnReorder:x,onColumnOrderReset:w,forceColumnsOpen:b,onColumnsPanelClose:c,children:g,rightContent:m,style:_,renderColumnsButton:E,renderFilterButton:v,renderAggregationButton:S,renderExportButton:N,renderQuickFilter:h,className:y,showNonHideableColumns:u}){const[j,P]=i.useState(!1),[F,k]=i.useState(!1),[I,R]=i.useState(!1),[W,$]=i.useState(!1);i.useEffect(()=>{b&&(R(!0),P(!1),k(!1),$(!1))},[b]);const D=i.useRef(null),A=i.useRef(null),z=i.useRef(null),Y=i.useRef(null),V=i.useRef(null),C=i.useRef(null),M=i.useRef(null),L=l??Dr,O=L.rowFields.length>0||L.columnFields.length>0||L.valueFields.length>0,H=n.filter(J=>J.aggregable!==!1&&(J.type==="number"||J.aggregable===!0)),U=Object.keys(e).filter(J=>e[J]&&e[J]!=="none").length,K=i.useCallback((J,de)=>{if(!o)return;const B={...e};de==="none"?delete B[J]:B[J]=de,o(B)},[e,o]),oe=i.useCallback(()=>{o?.({})},[o]),ie=i.useCallback(J=>{if(!a)return;const B={...d||{},quickFilterValues:J?[J]:[],items:d?.items||[]};a(B)},[d,a]),ne=d?.quickFilterValues?.[0]||"",T=d?.items?.length||0,le=new Set(n.filter(J=>f[J.field]!==!1).map(J=>J.field)),te=i.useCallback((J,de)=>{if(!p)return;const B={...f,[J]:de};p(B)},[f,p]),re=i.useCallback(()=>{if(!p)return;const J={...f};n.forEach(de=>{de.hideable!==!1&&(J[de.field]=!0)}),p(J)},[n,f,p]),q=i.useCallback(()=>{if(!p)return;const J={...f};n.forEach(de=>{de.hideable!==!1&&(J[de.field]=!1)}),p(J)},[n,f,p]);return r.jsxs("div",{className:["ogx-toolbar",y].filter(Boolean).join(" "),role:"toolbar","aria-label":"Grid toolbar",style:_,children:[g&&r.jsx("div",{className:"ogx-toolbar__left",children:g}),r.jsx("div",{className:"ogx-toolbar__spacer"}),r.jsxs("div",{className:"ogx-toolbar__actions",children:[a&&r.jsx("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:h?h({value:ne,onChange:ie}):r.jsx(Wr,{value:ne,onChange:ie,placeholder:"Search..."})}),p&&r.jsxs("div",{ref:V,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[E?E({onClick:()=>{R(J=>!J),P(!1),k(!1),$(!1)},isOpen:I,activeCount:n.length-le.size}):r.jsx(vt,{title:"Columns",children:r.jsx("button",{ref:z,className:`ogx-toolbar__icon-btn${I?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Manage columns",onClick:()=>{R(!I),P(!1),k(!1),$(!1)},children:r.jsx($r,{})})}),I&&r.jsx(Br,{anchorRef:E?V:z,columns:n,visibleColumns:le,onVisibilityChange:te,onShowAll:re,onHideAll:q,onColumnReorder:x,onColumnOrderReset:w,onClose:()=>{R(!1),c?.()},showNonHideableColumns:u})]}),a&&r.jsxs("div",{ref:C,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[v?v({onClick:()=>{$(J=>!J),P(!1),k(!1),R(!1)},isOpen:W,activeCount:T}):r.jsx(vt,{title:"Filters",children:r.jsxs("button",{ref:Y,className:`ogx-toolbar__icon-btn${W?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Advanced filters",onClick:()=>{$(!W),P(!1),k(!1),R(!1)},children:[r.jsx($n,{}),T>0&&r.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Filters active"})]})}),W&&r.jsx(Hr,{anchorRef:v?C:Y,columns:n,filterModel:d||{items:[]},onFilterModelChange:a,onClose:()=>$(!1)})]}),s&&r.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[r.jsx(vt,{title:"Pivot",children:r.jsxs("button",{ref:A,className:`ogx-toolbar__icon-btn${F?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure pivot","aria-expanded":F,onClick:()=>{k(!F),P(!1),R(!1),$(!1)},children:[r.jsx(Wn,{}),O&&r.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Pivot active"})]})}),F&&r.jsx(Lr,{anchorRef:A,columns:t??n,model:L,onChange:J=>{s?.(J)},onClose:()=>k(!1)})]}),r.jsxs("div",{ref:M,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[S?S({onClick:()=>{P(J=>!J),k(!1),R(!1),$(!1)},isOpen:j,activeCount:U}):r.jsx(vt,{title:"Summaries",children:r.jsxs("button",{ref:D,className:`ogx-toolbar__icon-btn${j?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure summaries","aria-expanded":j,onClick:()=>{P(!j),k(!1),R(!1),$(!1)},children:[r.jsx(An,{}),U>0&&r.jsx("span",{className:"ogx-toolbar__dot","aria-label":`${U} active summaries`})]})}),j&&r.jsx(zr,{anchorRef:S?M:D,aggregationModel:e,aggregableColumns:H,onFunctionChange:K,onClearAll:oe,onClose:()=>P(!1),activeCount:U})]}),N&&N(),m]})]})}function Vr(){return i.useRef(null)}const Ur=({fullWidth:n=!1,error:t=!1,startAdornment:e,endAdornment:o,className:l="",...s})=>{const d=["ogx-input-wrapper",n&&"ogx-input-wrapper--full-width",t&&"ogx-input-wrapper--error",s.disabled&&"ogx-input-wrapper--disabled",l].filter(Boolean).join(" ");return r.jsxs("div",{className:d,children:[e&&r.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--start",children:e}),r.jsx("input",{className:"ogx-input",...s}),o&&r.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--end",children:o})]})};function zn(n){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);return t?[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]:[79,70,229]}function Kr(n){return n.filter(t=>!(t.exportable===!1||t.field==="__check__"||t.field==="__actions__"))}function Bn(n,t){let e=n[t.field];return t.valueGetter&&(e=t.valueGetter({row:n,field:t.field,value:e})),t.valueFormatter&&e!==void 0&&e!==null&&(e=t.valueFormatter({value:e,row:n,field:t.field})),String(e??"")}function Hn(n){return(typeof n.width=="number"?n.width:void 0)??(n.flex??1)*100}function Yr(n,t){const e=n.reduce((l,s)=>l+Hn(s),0),o={};return n.forEach((l,s)=>{o[s]={cellWidth:Hn(l)/e*t}}),o}function qr(n,t){return!n.items||n.items.length===0?"":n.items.flatMap(e=>{if("items"in e)return[];const l=t.find(d=>d.field===e.field)?.headerName??e.field,s=e.value!==void 0&&e.value!==null?String(e.value):"";return[`${l} ${e.operator} "${s}"`]}).join(" • ")}async function Xr(n,t,e={}){let o,l;try{const[C,M]=await Promise.all([import("jspdf"),import("jspdf-autotable")]);o=C.default,l=M.default}catch{throw new Error("exportToPdf requires 'jspdf' and 'jspdf-autotable'. Run: npm install jspdf jspdf-autotable")}const{fileName:s="export",title:d,logoUrl:a,orientation:f="landscape",selectedRows:p,aggregationResult:x,aggregationModel:w,filterModel:b,alternateRowColor:c=!0,headerBackgroundColor:g="#4f46e5",headerTextColor:m="#ffffff",fontSize:_=9,groupedRows:E}=e,v=new o({orientation:f,unit:"mm",format:"a4"}),S=v.internal.pageSize.getWidth(),N=v.internal.pageSize.getHeight(),h=14,y=S-h*2,u=Kr(t),j=p&&p.length>0?n.filter(C=>p.includes(C.id)):n;let P=h;if(d){let C=h,M=h+8;if(a)try{v.addImage(a,"PNG",C,h,10,10),C+=14}catch{}v.setFontSize(16),v.setFont("helvetica","bold"),v.setTextColor(30,41,59),v.text(d,C,M),M+=6,v.setFontSize(8),v.setFont("helvetica","normal"),v.setTextColor(100,116,139);const L=new Date().toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),O=E?E.filter(H=>H.type==="leaf").length:j.length;if(v.text(`Exported: ${L} • ${O} row${O!==1?"s":""}`,C,M),M+=5,b){const H=qr(b,t);H&&(v.text(`Filters: ${H}`,C,M),M+=5)}v.setDrawColor(226,232,240),v.setLineWidth(.3),v.line(h,M+2,S-h,M+2),P=M+6}const F=[u.map(C=>C.headerName??C.field)];let k,I;if(E&&E.length>0){k=[];const C=w||{};E.forEach(M=>{if(M.type==="group-header"){const O=`${" ".repeat(M.depth*2)}${M.groupField??""}: ${String(M.groupValue??"")}`;k.push(u.map((H,U)=>U===0?O:""))}else if(M.type==="leaf"&&M.row){const L=M.row,O=" ".repeat(M.depth*2);k.push(u.map((H,U)=>(U===0?O:"")+Bn(L,H)))}else if(M.type==="group-subtotal"&&M.aggregatedValues){const L=" ".repeat(M.depth*2);k.push(u.map((O,H)=>{if(H===0)return`${L}Subtotal`;const U=M.aggregatedValues[O.field];if(U==null)return"";let K=U;return O.valueFormatter?K=O.valueFormatter({value:U,row:{},field:O.field}):C[O.field]&&(K=_e(U,C[O.field])),String(K)}))}else M.type==="grand-total"&&M.aggregatedValues&&(I=[u.map((O,H)=>{if(H===0)return"Grand Total";const U=M.aggregatedValues[O.field];if(U==null)return"";let K=U;return O.valueFormatter?K=O.valueFormatter({value:U,row:{},field:O.field}):C[O.field]&&(K=_e(U,C[O.field])),String(K)})])})}else k=j.map(C=>u.map(M=>Bn(C,M))),x&&w&&(I=[u.map((M,L)=>{if(L===0)return u.some(K=>w[K.field])?"TOTAL":"";const O=x[M.field];if(O==null)return"";let H=O;return M.valueFormatter?H=M.valueFormatter({value:O,row:{},field:M.field}):w[M.field]&&(H=_e(O,w[M.field])),String(H)})]);const R=Yr(u,y),[W,$,D]=zn(g),[A,z,Y]=zn(m);l(v,{head:F,body:k,...I?{foot:I}:{},startY:P,styles:{fontSize:_,cellPadding:3,font:"helvetica",overflow:"linebreak"},headStyles:{fillColor:[W,$,D],textColor:[A,z,Y],fontStyle:"bold"},...c?{alternateRowStyles:{fillColor:[248,250,252]}}:{},...I?{footStyles:{fillColor:[241,245,249],fontStyle:"bold",textColor:[0,0,0]}}:{},columnStyles:R,showFoot:I?"lastPage":"never",showHead:"everyPage",margin:{top:h,left:h,right:h,bottom:h+6}});const V=v.getNumberOfPages();for(let C=1;C<=V;C++)v.setPage(C),v.setFontSize(8),v.setTextColor(150,150,150),v.text(`Page ${C} of ${V}`,S-h,N-8,{align:"right"});v.save(`${s}.pdf`)}function Jr(n,t,e={}){const{fileName:o="export.csv",includeHeaders:l=!0,delimiter:s=",",selectedRows:d,groupedRows:a}=e,f=t.filter(x=>!(x.exportable===!1||x.field==="__check__"||x.field==="__actions__"));let p="";if(a&&a.length>0)l&&(p+=f.map(x=>je(x.headerName||x.field)).join(s)+`
9
- `),a.forEach(x=>{if(x.type==="group-header"){const b=`${" ".repeat(x.depth)}${x.groupField??""}: ${String(x.groupValue??"")}`,c=f.map((g,m)=>m===0?je(b):"");p+=c.join(s)+`
10
- `}else if(x.type==="leaf"&&x.row){const w=x.row,b=" ".repeat(x.depth),c=f.map((g,m)=>{let _=w[g.field];return g.valueGetter&&(_=g.valueGetter({row:w,field:g.field,value:_})),g.valueFormatter&&_!==void 0&&_!==null&&(_=g.valueFormatter({value:_,row:w,field:g.field})),je((m===0?b:"")+String(_??""))});p+=c.join(s)+`
11
- `}else if(x.type==="group-subtotal"&&x.aggregatedValues){const w=" ".repeat(x.depth),b=e.aggregationModel||{},c=f.map((g,m)=>{if(m===0)return je(`${w}Subtotal`);const _=x.aggregatedValues[g.field];if(_!=null){let E=_;return g.valueFormatter?E=g.valueFormatter({value:_,row:{},field:g.field}):b[g.field]&&(E=_e(_,b[g.field])),je(String(E))}return""});p+=c.join(s)+`
12
- `}else if(x.type==="grand-total"&&x.aggregatedValues){const w=e.aggregationModel||{},b=f.map((c,g)=>{if(g===0)return je("Grand Total");const m=x.aggregatedValues[c.field];if(m!=null){let _=m;return c.valueFormatter?_=c.valueFormatter({value:m,row:{},field:c.field}):w[c.field]&&(_=_e(m,w[c.field])),je(String(_))}return""});p+=b.join(s)+`
13
- `}});else{const x=d&&d.length>0?n.filter(w=>d.includes(w.id)):n;if(x.length===0){console.warn("No rows to export");return}if(l&&(p+=f.map(w=>je(w.headerName||w.field)).join(s)+`
14
- `),x.forEach(w=>{const b=f.map(c=>{let g=w[c.field];return c.valueGetter&&(g=c.valueGetter({row:w,field:c.field,value:g})),c.valueFormatter&&g!==void 0&&g!==null&&(g=c.valueFormatter({value:g,row:w,field:c.field})),je(String(g??""))});p+=b.join(s)+`
15
- `}),e.aggregationResult){const w=e.aggregationResult,b=e.aggregationModel||{},c=f.map(m=>je(b[m.field]?b[m.field].toUpperCase():""));p+=c.join(s)+`
16
- `;const g=f.map(m=>{const _=w[m.field];if(_!=null){let E=_;return m.valueFormatter?E=m.valueFormatter({value:_,row:{},field:m.field}):b[m.field]&&(E=_e(_,b[m.field])),je(String(E))}return""});p+=g.join(s)+`
17
- `}}tn(p,o,"text/csv;charset=utf-8;")}function je(n){return n.includes(",")||n.includes('"')||n.includes(`
18
- `)?`"${n.replace(/"/g,'""')}"`:n}function Qr(n,t,e={}){const{fileName:o="export.xls",sheetName:l="Sheet1",includeHeaders:s=!0,selectedRows:d,groupedRows:a}=e,f=t.filter(w=>!(w.exportable===!1||w.field==="__check__"||w.field==="__actions__"));let x=`<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>${l}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--><meta charset="UTF-8"></head><body><table border="1">`;if(s&&(x+="<thead><tr>",f.forEach(w=>{x+=`<th>${we(w.headerName||w.field)}</th>`}),x+="</tr></thead>"),x+="<tbody>",a&&a.length>0){const w=e.aggregationModel||{};a.forEach(b=>{if(b.type==="group-header"){const g=`${"  ".repeat(b.depth*2)}${b.groupField??""}: ${String(b.groupValue??"")}`;x+='<tr style="font-weight:bold;background:#e8eaf6;">',x+=`<td colspan="${f.length}">${we(g)}</td>`,x+="</tr>"}else if(b.type==="leaf"&&b.row){const c=b.row,g="  ".repeat(b.depth*2);x+="<tr>",f.forEach((m,_)=>{let E=c[m.field];m.valueGetter&&(E=m.valueGetter({row:c,field:m.field,value:E})),m.valueFormatter&&E!==void 0&&E!==null&&(E=m.valueFormatter({value:E,row:c,field:m.field})),x+=`<td>${we((_===0?g:"")+String(E??""))}</td>`}),x+="</tr>"}else if((b.type==="group-subtotal"||b.type==="grand-total")&&b.aggregatedValues){const c=b.type==="grand-total",g=c?"":"  ".repeat(b.depth*2),m=c?"Grand Total":`${g}Subtotal`;x+='<tr style="font-weight:bold;background:#f5f5f5;">',f.forEach((_,E)=>{if(E===0){x+=`<td>${we(m)}</td>`;return}const v=b.aggregatedValues[_.field];if(v!=null){let S=v;_.valueFormatter?S=_.valueFormatter({value:v,row:{},field:_.field}):w[_.field]&&(S=_e(v,w[_.field])),x+=`<td style="text-align:right;">${we(String(S))}</td>`}else x+="<td></td>"}),x+="</tr>"}})}else{const w=d&&d.length>0?n.filter(b=>d.includes(b.id)):n;if(w.length===0){console.warn("No rows to export");return}if(w.forEach(b=>{x+="<tr>",f.forEach(c=>{let g=b[c.field];c.valueGetter&&(g=c.valueGetter({row:b,field:c.field,value:g})),c.valueFormatter&&g!==void 0&&g!==null&&(g=c.valueFormatter({value:g,row:b,field:c.field})),x+=`<td>${we(String(g??""))}</td>`}),x+="</tr>"}),e.aggregationResult){const b=e.aggregationResult,c=e.aggregationModel||{};x+='<tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',f.forEach(g=>{x+=c[g.field]?`<td style="text-align:right;font-weight:bold;">${we(c[g.field].toUpperCase())}</td>`:"<td></td>"}),x+='</tr><tr style="font-weight:bold;background-color:#f5f5f5;">',f.forEach(g=>{const m=b[g.field];if(m!=null){let _=m;g.valueFormatter?_=g.valueFormatter({value:m,row:{},field:g.field}):c[g.field]&&(_=_e(m,c[g.field])),x+=`<td style="text-align:right;">${we(String(_))}</td>`}else x+="<td></td>"}),x+="</tr>"}}x+="</tbody></table></body></html>",tn(x,o,"application/vnd.ms-excel")}function we(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function Zr(n,t,e={}){const{fileName:o="export.json",pretty:l=!0,selectedRows:s,groupedRows:d}=e,a=t.filter(p=>!(p.exportable===!1||p.field==="__check__"||p.field==="__actions__"));let f;if(d&&d.length>0){const p=[],x=[];let w;d.forEach(b=>{if(b.type==="group-header"){const c={group:`${b.groupField??""}: ${String(b.groupValue??"")}`,field:b.groupField??"",value:b.groupValue,rows:[],children:[]};for(;p.length>b.depth;)p.pop();p.length===0?x.push(c):(p[p.length-1].children??=[]).push(c),p.push(c)}else if(b.type==="leaf"&&b.row){const c=b.row,g={};a.forEach(m=>{let _=c[m.field];m.valueGetter&&(_=m.valueGetter({row:c,field:m.field,value:_})),g[m.field]=_}),p.length>0&&p[p.length-1].rows.push(g)}else b.type==="group-subtotal"&&b.aggregatedValues&&p.length>0?(p[p.length-1].subtotals={...b.aggregatedValues},p.pop()):b.type==="grand-total"&&b.aggregatedValues&&(w={...b.aggregatedValues})}),f=w?{groups:x,grandTotal:w}:{groups:x}}else{const p=s&&s.length>0?n.filter(w=>s.includes(w.id)):n;if(p.length===0){console.warn("No rows to export");return}const x=p.map(w=>{const b={};return a.forEach(c=>{let g=w[c.field];c.valueGetter&&(g=c.valueGetter({row:w,field:c.field,value:g})),b[c.field]=g}),b});if(e.aggregationResult){const w=e.aggregationResult,b=e.aggregationModel||{},c={};a.forEach(m=>{b[m.field]&&(c[m.field]=b[m.field].toUpperCase())});const g={};a.forEach(m=>{if(w[m.field]!==void 0&&w[m.field]!==null){let _=w[m.field];m.valueFormatter?_=m.valueFormatter({value:_,row:{},field:m.field}):b[m.field]&&(_=_e(_,b[m.field])),g[m.field]=_}}),f={data:x,aggregation:{labels:c,values:g}}}else f=x}tn(l?JSON.stringify(f,null,2):JSON.stringify(f),o,"application/json;charset=utf-8;")}async function ei(n,t,e){const o=window.open("","_blank");if(!o){console.error("Failed to open print window. Please check your popup blocker settings.");return}o.document.write(`
1
+ (function(pe,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("react/jsx-runtime"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-dom"],s):(pe=typeof globalThis<"u"?globalThis:pe||self,s(pe.OpenGridX={},pe.ReactJSXRuntime,pe.React,pe.ReactDOM))})(this,(function(pe,s,a,tt){"use strict";function $o(e,t,o){return Math.max(t??0,Math.min(o??1/0,e))}function ot(e,t,o=100){if(e.isSpacer)return typeof e.width=="number"?e.width:0;const n=t[e.field]??e.width,r=typeof n=="number"&&Number.isFinite(n)?n:o;return $o(r,e.minWidth,e.maxWidth)}const je=48;function Xe(e,t){return t?t.left?.includes(e)?"left":t.right?.includes(e)?"right":null:null}function _l(e,t){const o=[],n=[],r=[];return t?(e.forEach(i=>{const l=Xe(i.field,t);l==="left"?o.push(i):l==="right"?r.push(i):n.push(i)}),t.left&&o.sort((i,l)=>{const c=t.left.indexOf(i.field),d=t.left.indexOf(l.field);return c-d}),t.right&&r.sort((i,l)=>{const c=t.right.indexOf(i.field),d=t.right.indexOf(l.field);return c-d}),{left:o,center:n,right:r}):{left:o,center:e,right:r}}function Go(e,t,o,n,r,i,l,c){const d={};if(!o)return d;let u=(c?je:0)+(i&&l?je:0)+(n&&r?je:0);const g=[];e.forEach(x=>{if(x.isSpacer)return;const v=Xe(x.field,o);v==="left"?(d[x.field]=u,u+=ot(x,t)):v==="right"&&g.push(x)});let m=0;for(let x=g.length-1;x>=0;x--)d[g[x].field]=m,m+=ot(g[x],t);return d}function Wo(e,t){let o=null,n=null;if(!t)return{lastLeft:o,firstRight:n};for(const r of e){if(r.isSpacer)continue;const i=Xe(r.field,t);i==="left"?o=r.field:i==="right"&&n===null&&(n=r.field)}return{lastLeft:o,firstRight:n}}function zn(e,t){return t?t.top?.includes(e)?"top":t.bottom?.includes(e)?"bottom":null:null}function Sl(e,t,o=n=>n.id){const n=[],r=[],i=[];return t?(e.forEach(l=>{const c=zn(o(l),t);c==="top"?n.push(l):c==="bottom"?i.push(l):r.push(l)}),t.top&&n.sort((l,c)=>{const d=t.top.indexOf(o(l)),u=t.top.indexOf(o(c));return d-u}),t.bottom&&i.sort((l,c)=>{const d=t.bottom.indexOf(o(l)),u=t.bottom.indexOf(o(c));return d-u}),{top:n,center:r,bottom:i}):{top:n,center:e,bottom:i}}function kl(e,t,o){const n=(e?.left??[]).filter(i=>i!==t),r=(e?.right??[]).filter(i=>i!==t);return o==="left"?{left:[...n,t],right:r}:o==="right"?{left:n,right:[...r,t]}:{left:n,right:r}}const Kn=new Set;function jn(e,t,o){process.env.NODE_ENV==="production"||Kn.has(e)||(Kn.add(e),console.warn(`[OpenGridX] ${t}.`,o))}function no(e,t,o,n){try{return e()}catch(r){return jn(o,n,r),t}}function Un(e,t,o){const n=e[t];if(!o?.valueGetter)return{value:n};try{return{value:o.valueGetter({row:e,field:t,value:n})}}catch(r){return{value:void 0,error:r??new Error("valueGetter failed")}}}function Le(e,t,o){const{value:n,error:r}=Un(e,t,o);return r!==void 0&&jn(`valueGetter:${t}`,`valueGetter for column "${t}" threw; the value is read as undefined`,r),n}function Ho(e,t,o,n){const r=n?.valueFormatter;if(r)return no(()=>r({value:o,row:e,field:t}),void 0,`valueFormatter:${t}`,`valueFormatter for column "${t}" threw; the value is shown unformatted`)}function nt(e){if(e==null)return null;if(typeof e=="number")return Number.isNaN(e)?null:e;if(typeof e=="string"){const t=e.trim();if(t==="")return null;const o=Number(t);return Number.isNaN(o)?null:o}if(typeof e=="boolean")return null;if(e instanceof Date){const t=e.getTime();return Number.isNaN(t)?null:t}return typeof e=="bigint"?Number(e):null}const El=/^(\d{4})-(\d{2})-(\d{2})$/;function ro(e){if(e==null)return null;let t;if(e instanceof Date)t=e;else if(typeof e=="number")t=new Date(e);else if(typeof e=="string"){const o=e.trim();if(o==="")return null;const n=El.exec(o);if(n){const r=Number(n[1]),i=Number(n[2])-1,l=Number(n[3]);if(t=new Date(r,i,l),t.getMonth()!==i||t.getDate()!==l)return null}else t=new Date(o)}else return null;return Number.isNaN(t.getTime())?null:t}function io(e){const t=ro(e);return t?t.getFullYear()*1e4+(t.getMonth()+1)*100+t.getDate():null}function Xn(e){const t=ro(e);if(!t)return"";const o=String(t.getFullYear()).padStart(4,"0"),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${o}-${n}-${r}`}let qn=null;function Yn(e){return qn??=new Intl.DateTimeFormat,qn.format(e)}function Ml(e,t){if(!e)return;const o=i=>typeof i=="object"?i.value:i,n=i=>typeof i=="object"?i.label:String(i),r=e.find(i=>Object.is(o(i),t))??e.find(i=>String(o(i))===String(t));return r===void 0?void 0:n(r)}function Bo(e,t){if(e==null)return"";switch(t?.type){case"date":{const o=ro(e);return o?Yn(o):String(e)}case"boolean":return e===!0?"Yes":e===!1?"No":String(e);case"singleSelect":return Ml(t.valueOptions,e)??String(e);default:return String(e)}}const Vo=200;function zo(e){if(e==="auto")return"auto";const t=typeof e=="string"?Number.parseFloat(e):e;return typeof t=="number"&&Number.isFinite(t)&&t>=0?t:Vo}function Ko(e,t){if(e)return no(()=>e(t),void 0,"getDetailPanelHeight","getDetailPanelHeight threw; the panel uses the default height")}function Nl(e,t){const o=zo(e);return o==="auto"?t??Vo:o}function Pl(e,t){if(t.size===0||e.size===0)return e;let o=!1;const n=new Set;for(const r of e)t.get(r)?.isGroupRow?o=!0:n.add(r);return o?n:e}const Il=e=>e.id;function Tl(e){if(e===void 0)return{type:"auto",value:0};if(typeof e=="number")return{type:"fixed",value:e};if(typeof e=="string"){if(e.toLowerCase()==="auto")return{type:"auto",value:0};if(e.endsWith("%"))return{type:"percentage",value:parseFloat(e)};const t=parseFloat(e);if(!isNaN(t))return{type:"fixed",value:t}}return{type:"fixed",value:100}}function Fl(e,t,o){const n=new Map;e.forEach(f=>{if(!Object.prototype.hasOwnProperty.call(t,f.field)&&f.flex&&f.flex>0){n.set(f.field,{kind:"flex",flex:f.flex});return}const p=Tl(t[f.field]??f.width);p.type==="fixed"?n.set(f.field,{kind:"fixed",width:$o(p.value,f.minWidth,f.maxWidth)}):p.type==="percentage"?n.set(f.field,{kind:"percentage",percentage:p.value}):n.set(f.field,{kind:"flex",flex:1})});const r=e.reduce((f,w)=>{const p=n.get(w.field);if(p.kind==="fixed")return f+p.width;if(p.kind==="percentage")return f+100;if(w.flex&&w.flex>0){const b=w.minWidth??150;return f+(b||(typeof w.width=="number"?w.width:150))}return f+(w.minWidth??150)},0),i=Math.max(o,r),l=e.reduce((f,w)=>{const p=n.get(w.field);return p.kind==="fixed"?f+p.width:f},0),c=new Map,d=Math.max(0,i-l);let u=0;e.forEach(f=>{const w=n.get(f.field);if(w.kind==="fixed")c.set(f.field,w.width);else if(w.kind==="percentage"){const p=w.percentage/100*d,b=$o(p>0?p:100,f.minWidth??50,f.maxWidth);c.set(f.field,b),u+=b}});const g=Math.max(0,d-u),m=new Map,x=e.flatMap(f=>{const w=n.get(f.field);return w.kind!=="flex"?[]:(m.set(f.field,w.flex),[{field:f.field,flex:w.flex,minWidth:f.minWidth??50,maxWidth:f.maxWidth??1/0,frozen:!1,computedWidth:0}])});let v=0;const h=x.length*2;for(;v<h;){v++;const f=x.filter(E=>!E.frozen);if(f.length===0)break;const w=f.reduce((E,P)=>E+P.flex,0),p=x.reduce((E,P)=>P.frozen?E+P.computedWidth:E,0),b=Math.max(0,g-p);if(w<=0){f.forEach(E=>{E.computedWidth=E.minWidth,E.frozen=!0});break}const y=b/w;let C=0;const N=[],T=[];if(f.forEach(E=>{const P=y*E.flex;P<E.minWidth?(C+=E.minWidth-P,N.push(E)):P>E.maxWidth?(C+=E.maxWidth-P,T.push(E)):E.computedWidth=P}),N.length===0&&T.length===0){f.forEach(E=>{E.frozen=!0});break}C>0?N.forEach(E=>{E.computedWidth=E.minWidth,E.frozen=!0}):C<0?T.forEach(E=>{E.computedWidth=E.maxWidth,E.frozen=!0}):(N.forEach(E=>{E.computedWidth=E.minWidth,E.frozen=!0}),T.forEach(E=>{E.computedWidth=E.maxWidth,E.frozen=!0}))}return x.forEach(f=>c.set(f.field,f.computedWidth)),{widths:c,flexByField:m}}function Ll(e){const{rowHeight:t,pagination:o,paginatedUnpinnedRows:n,sortedUnpinnedRows:r,expandedRowIds:i,getDetailPanelHeight:l,detailPanelHeights:c,pinnedTopRowsLength:d,pinnedBottomRowsLength:u,pinnedTopRows:g,pinnedBottomRows:m,visibleOrderedColumns:x,pinnedColumns:v,columnWidths:h,viewportWidth:f,checkboxSelection:w,hasDetailPanel:p,rowReordering:b,pinCheckboxColumn:y,pinExpandColumn:C,paginationMode:N,isLoading:T,pageSize:E,getRowId:P=Il}=e;return a.useMemo(()=>{const O=o?n:r,W=(j,z)=>{const k=P(j);if(!i.has(k))return t;const L=Ko(l,{row:j,id:k,rowIndex:z});return t+Nl(L,c?.get(k))},X=O.map((j,z)=>W(j,d+z)),S=X.reduce((j,z,k)=>(j.push((j[k-1]||0)+z),j),[]),M=N==="infinite"&&T&&O.length>0?Math.min(E,20):0,I=(S[S.length-1]||0)+M*t,_=(j,z)=>j?j.reduce((k,L,Q)=>k+W(L,Q),0):z*t,F=_(g,d),A=_(m,u),{left:q,center:K,right:J}=_l(x,v),te=(w?je:0)+(p?je:0)+(b?je:0),ne=(b?je:0)+(p&&C?je:0)+(w&&y?je:0),{widths:Z,flexByField:de}=Fl([...q,...K,...J],h,f-te),ae=j=>Z.get(j.field)??100,oe=j=>({...j,width:ae(j),flex:de.get(j.field)??j.flex}),se=11,re=q.map((j,z)=>({...oe(j),zIndex:se+z})),B=11,D=J.map((j,z)=>({...oe(j),zIndex:B+(J.length-1-z)})),$=K.map(oe),R=$.map(j=>j.width),U=re.reduce((j,z)=>j+z.width,0),G=D.reduce((j,z)=>j+z.width,0),V=R.reduce((j,z)=>j+z,0),Y=U+V+G+te,H=R.reduce((j,z,k)=>(j.push((j[k-1]||0)+z),j),[]);return{rowHeights:X,cumulativeHeights:S,unpinnedRowsHeight:I,pinnedTopHeight:F,pinnedBottomHeight:A,leftPinnedCols:re,rightPinnedCols:D,unpinnedColsWithWidth:$,unpinnedColWidths:R,unpinnedAccWidths:H,totalWidth:Y,leftWidth:U,rightWidth:G,unpinnedTotalWidth:V,systemColumnsWidth:te,pinnedSystemColumnsWidth:ne,pinnedTopRowsLength:d,pinnedBottomRowsLength:u,unpinnedRowsLength:O.length}},[t,o,n,r,i,l,c,d,u,g,m,x,v,h,f,w,p,b,y,C,N,T,E,P])}function Ol(e){const t=e.querySelector(".ogx__sticky-bottom");return t?t.getBoundingClientRect().height:0}function Rn(e,t,o,n,r){if(t<0||t>=o.length)return;const i=e.querySelector(".ogx__virtual-container");if(!i)return;const{scrollTop:l,clientHeight:c}=e,d=i.getBoundingClientRect().top-e.getBoundingClientRect().top+l,u=Math.max(n,Ol(e)),g=d+(t===0?0:o[t-1]),m=r!==void 0?Math.min(g+r,d+o[t]):d+o[t];g<l+d?e.scrollTop=Math.max(0,g-d):m>l+c-u&&(e.scrollTop=m-c+u)}function Dl(e,t,o){const{unpinnedAccWidths:n,leftWidth:r,rightWidth:i,systemColumnsWidth:l,pinnedSystemColumnsWidth:c}=o;if(t<0||t>=n.length)return;const d=l+r,u=d+(t>0?n[t-1]:0),g=d+n[t],m=c+r,{scrollLeft:x,clientWidth:v}=e;u<x+m?e.scrollLeft=Math.max(0,u-m):g>x+v-i&&(e.scrollLeft=g-v+i)}function Jn(e,t){const{row:o,field:n,value:r,colDef:i,rowIndex:l,colIndex:c,rowMeta:d}=e;if(!i.editable||d?.isGroupRow||o._isSkeleton)return!1;if(!t)return!0;try{return!!t({row:o,field:n,value:r,colDef:i,rowIndex:l,colIndex:c})}catch{return!1}}const Al={},jo=e=>e==null||typeof e=="string"&&e.trim()==="",Qn=e=>{const t=[];for(const o of e){const n=nt(o);n!==null&&t.push(n)}return t},Zn=(e,t)=>{let o=null,n=null;for(const r of e){const i=nt(r);i!==null&&(o===null||t(i,o))&&(o=i,n=r)}return o===null?null:n instanceof Date?n:o},lo={sum:e=>Qn(e).reduce((t,o)=>t+o,0),avg:e=>{const t=Qn(e);return t.length?t.reduce((o,n)=>o+n,0)/t.length:null},count:e=>e.filter(t=>!jo(t)).length,min:e=>Zn(e,(t,o)=>t<o),max:e=>Zn(e,(t,o)=>t>o),unique:e=>new Set(e.filter(t=>!jo(t))).size};function Uo(e,t){return e?e.aggregable===!1?!1:!e.availableAggregationFunctions||e.availableAggregationFunctions.includes(t):!0}function so(e,t,o,n){const r={};for(const[i,l]of Object.entries(t)){const c=o.get(i);if(!Uo(c,l))continue;const d=lo[l];if(!d){console.warn(`[${n}] Unknown aggregation function: "${l}"`);continue}r[i]=d(e.map(u=>Le(u,i,c)))}return r}function Xo(e,t){return e==null?"—":typeof e=="number"?t==="avg"?e.toLocaleString(void 0,{maximumFractionDigits:2}):e.toLocaleString():String(e)}const $l=new Set(["count","unique"]);function er(e){return e!==void 0&&$l.has(e)}function tr(e,t,o){return e?.type==="date"&&(t==="min"||t==="max")&&typeof o=="number"&&Number.isFinite(o)?new Date(o):o}function ao(e,t,o,n){if(e==null)return"—";if(er(t))return Xo(e,t);const r=tr(o,t,e);if(o?.valueFormatter)try{return String(o.valueFormatter({value:r,row:n??{},field:o.field})??"")}catch{}return r instanceof Date?Number.isNaN(r.getTime())?"":Yn(r):Xo(r,t)}const qo=new Set(["isEmpty","isNotEmpty"]);function or(e){return e==null?!0:typeof e=="string"?e.trim()==="":Array.isArray(e)?e.length===0:!1}function Gl(e){return e==null?!0:typeof e=="number"?Number.isNaN(e):typeof e=="string"&&e.trim()===""}const Lt=e=>(t,o)=>{const n=nt(t),r=nt(o);return n===null||r===null?!1:e(n,r)},Ot=e=>(t,o)=>{const n=io(t),r=io(o);return n===null||r===null?!1:e(n,r)},nr=Ot((e,t)=>e===t),rr=(e,t)=>{const o=io(e),n=io(t);return o===null||n===null?!0:o!==n},ir={contains:(e,t)=>e==null||t==null?!1:String(e).toLowerCase().includes(String(t).toLowerCase()),equals:(e,t)=>e==null&&t==null?!0:e==null||t==null?!1:String(e).toLowerCase()===String(t).toLowerCase(),startsWith:(e,t)=>e==null||t==null?!1:String(e).toLowerCase().startsWith(String(t).toLowerCase()),endsWith:(e,t)=>e==null||t==null?!1:String(e).toLowerCase().endsWith(String(t).toLowerCase()),isEmpty:e=>e==null||String(e).trim()==="",isNotEmpty:e=>e!=null&&String(e).trim()!=="","=":Lt((e,t)=>e===t),">":Lt((e,t)=>e>t),">=":Lt((e,t)=>e>=t),"<":Lt((e,t)=>e<t),"<=":Lt((e,t)=>e<=t),"!=":(e,t)=>{if(or(t))return!0;const o=nt(e),n=nt(t);return o!==null&&n!==null?o!==n:Gl(e)?!0:String(e).toLowerCase()!==String(t).toLowerCase()},isAnyOf:(e,t)=>{if(e==null)return!1;const o=Array.isArray(t)?t:[t],n=String(e).toLowerCase();return o.some(r=>r!=null&&String(r).toLowerCase()===n)},not:(e,t)=>e instanceof Date?rr(e,t):e==null&&t==null?!1:e==null||t==null?!0:String(e).toLowerCase()!==String(t).toLowerCase(),is:(e,t)=>t==null||t===""?!0:e instanceof Date?nr(e,t):String(e).toLowerCase()===String(t).toLowerCase(),after:Ot((e,t)=>e>t),onOrAfter:Ot((e,t)=>e>=t),before:Ot((e,t)=>e<t),onOrBefore:Ot((e,t)=>e<=t)},Wl={is:nr,not:rr};function Hl(e,t){if(!Object.prototype.hasOwnProperty.call(ir,e))return;const o=e;if(t?.type==="date"){const n=Wl[o];if(n)return n}return ir[o]}function Bl(e){return"items"in e&&Array.isArray(e.items)}function Vl(e,t){const{field:o,operator:n,value:r}=e;if(!qo.has(n)&&or(r))return null;const i=t.columns?.byField.get(o),l=Hl(n,i);return l?c=>l(Le(c,o,i),r):(t.warned.has(n)||(t.warned.add(n),console.warn(`Unknown filter operator: ${n}`)),null)}function lr(e,t,o){const n=[];for(const r of e){const i=Bl(r)?lr(r.items,r.logicOperator,o):Vl(r,o);i&&n.push(i)}return n.length===0?null:n.length===1?n[0]:t==="or"?r=>n.some(i=>i(r)):r=>n.every(i=>i(r))}function Yo(e,t){if(t!=null){switch(typeof t){case"string":e.push(t.toLowerCase());return;case"number":Number.isNaN(t)||e.push(String(t));return;case"boolean":case"bigint":e.push(String(t));return}if(t instanceof Date){const o=Xn(t);o&&e.push(o);return}if(Array.isArray(t))for(const o of t)(o==null||typeof o!="object")&&Yo(e,o)}}function sr(e,t){const o=[];if(!t){for(const n of Object.values(e))Yo(o,n);return o}for(const n of t.quickFilterColumns){const r=Le(e,n.field,n),i=Ho(e,n.field,r,n);i!=null&&i!==""&&o.push(String(i).toLowerCase()),Yo(o,r)}return o}const ar=new WeakMap;function zl(e,t){if(!t)return sr(e,t);let o=ar.get(t);o||(o=new WeakMap,ar.set(t,o));let n=o.get(e);return n||(n=sr(e,t),o.set(e,n)),n}function Kl(e,t){const o=(e??[]).map(n=>String(n??"").trim().toLowerCase()).filter(n=>n!=="");return o.length===0?null:n=>{const r=zl(n,t);return o.every(i=>r.some(l=>l.includes(i)))}}function co(e,t){if(!e)return null;const o={columns:t,warned:new Set},n="quickFilterValues"in e?e.quickFilterValues:void 0,r=Kl(n,t),i=lr(e.items??[],e.logicOperator??"and",o);return r&&i?l=>r(l)&&i(l):r??i}function Ro(e,t,o){const n=co(t,o);return n?e.filter(r=>n(r)):e}function jl(e){switch(e){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"]}}const Ul=new Intl.Collator(void 0,{numeric:!0,sensitivity:"accent"}),Jo=0,dr=1,Xl=2,cr=3,ur=4;function ht(e,t){return{rank:e,num:t,str:""}}function Qo(e,t){if(e==null)return null;if(t==="number"){const o=nt(e);return o===null?null:ht(Jo,o)}if(t==="date"){const o=ro(e);return o?ht(dr,o.getTime()):null}switch(typeof e){case"number":return Number.isNaN(e)?null:ht(Jo,e);case"bigint":return ht(Jo,Number(e));case"boolean":return ht(Xl,e?1:0);case"string":return{rank:cr,num:0,str:e}}if(e instanceof Date){const o=e.getTime();return Number.isNaN(o)?null:ht(dr,o)}return{rank:ur,num:0,str:String(e)}}function fr(e,t){return e===null&&t===null?0:e===null?1:t===null?-1:e.rank!==t.rank?e.rank-t.rank:e.rank===cr||e.rank===ur?Ul.compare(e.str,t.str):e.num<t.num?-1:e.num>t.num?1:0}function gr(e,t){return e===0?0:t==="asc"?e:-e}function ql(e,t,o,n){return gr(fr(Qo(e,n),Qo(t,n)),o)}function Yl(e,t,o){return t.length===0?e:Zo(e,t,(n,r)=>{const i=o?.byField.get(r.field);return{value:Le(n,r.field,i),type:i?.type}})}function Zo(e,t,o){if(t.length===0||e.length<2)return[...e];const n=t.map(i=>e.map(l=>{const{value:c,type:d}=o(l,i);return Qo(c,d)})),r=e.map((i,l)=>l);return r.sort((i,l)=>{for(let c=0;c<t.length;c++){const d=gr(fr(n[c][i],n[c][l]),t[c].sort);if(d!==0)return d}return i-l}),r.map(i=>e[i])}function Rl(e,t,o){if(!o)return e.filter(r=>r.field!==t);const n=e.findIndex(r=>r.field===t);return n===-1?[...e,{field:t,sort:o}]:e.map((r,i)=>i===n?{field:t,sort:o}:r)}function en(e,t={}){const o=new Map,n=[];for(const r of e)o.set(r.field,r),!(r.isSpacer||r.field.startsWith("__"))&&r.filterable!==!1&&t[r.field]!==!1&&n.push(r);return{byField:o,quickFilterColumns:n}}const wt="__pivot_grand_total__",Jl="__pivot_row__:",pr=e=>`${Jl}${JSON.stringify(e.split(hr))}`,Ql="Grand Total",hr="\0",mt="",tn=`${mt}id`,wr=e=>e==="id"?tn:e,on={pivotRows:[],pivotColumns:[],colKeys:[],isValid:!1},mr=e=>e.map(t=>String(t??"")).join(hr),xr=e=>e===void 0||e===""?null:e;function Zl(e,t){const o=e==null,n=t==null;return o||n?o===n?0:o?1:-1:typeof e=="number"&&typeof t=="number"?e-t:e instanceof Date&&t instanceof Date?e.getTime()-t.getTime():typeof e=="boolean"&&typeof t=="boolean"?Number(e)-Number(t):String(e).localeCompare(String(t),void 0,{numeric:!0})}function es(e,t){for(let o=0;o<e.length;o++){const n=Zl(e[o],t[o]);if(n!==0)return n}return 0}function br(e,t){if(!e||e.length===0)return null;const o=lo[t](e);return typeof o=="number"||o instanceof Date?o:null}const ts=e=>"logicOperator"in e&&"items"in e,os=e=>!!(e&&e.items&&e.items.length>0);function ns(e,t){const o=l=>!t.has(l)&&l.includes(mt),n=l=>ts(l)?l.items.length>0&&l.items.every(n):o(l.field),r=[],i=[];for(const l of e.items??[])(n(l)?i:r).push(l);return{source:{...e,items:r},output:{items:i,logicOperator:e.logicOperator}}}function vr(e,t,o,n={}){const r=new Map(t.map(S=>[S.field,S])),i=S=>r.get(S)?.groupable!==!1,l=o.rowFields.filter(i),c=o.columnFields.filter(i),d=new Set,u=o.valueFields.filter(S=>{if(!Uo(r.get(S.field),S.aggFn))return!1;const M=`${S.field}${mt}${S.aggFn}`;return d.has(M)?!1:(d.add(M),!0)});if(l.length===0||u.length===0)return on;const g=c.length>0,m=Array.from(new Set(u.map(S=>S.field))),x=(S,M)=>Le(S,M,r.get(M)),v=new Map,h=new Map(g?[]:[["",{values:[]}]]);for(const S of e){const M=l.map(J=>x(S,J)),I=mr(M);let _=v.get(I);_||(_={labels:M.map(xr),sample:S,cells:new Map},v.set(I,_));const F=c.map(J=>x(S,J)),A=g?mr(F):"",q=h.get(A);q?q.sample||(q.sample=S):h.set(A,{values:F.map(xr),sample:S});let K=_.cells.get(A);K||(K=new Map,_.cells.set(A,K));for(const J of m){const te=x(S,J);if(jo(te))continue;let ne=K.get(J);ne||(ne=[],K.set(J,ne)),ne.push(te)}}const f=Array.from(h.keys()).sort((S,M)=>es(h.get(S).values,h.get(M).values)),w=(S,M)=>g?`${S}${mt}${M.field}${mt}${M.aggFn}`:`${M.field}${mt}${M.aggFn}`,p=new Map;let b=[];for(const[S,M]of v){const I={id:pr(S)};l.forEach((_,F)=>{I[wr(_)]=M.labels[F]}),I.id=pr(S);for(const _ of f){const F=M.cells.get(_);for(const A of u)I[w(_,A)]=br(F?.get(A.field),A.aggFn)}p.set(I.id,M),b.push({row:I,entry:M})}const y=S=>l.includes(S),C=S=>y(S)?r.get(S)?.type:"number",{outputFilterModel:N,sortModel:T}=n;if(os(N)){const S=[];for(const I of f)for(const _ of u)S.push({field:w(I,_),type:"number"});const M=co(N,en(S));M&&(b=b.filter(({row:I})=>M(I)))}const E=(S,M)=>M==="id"&&y("id")?S[tn]:S[M];T&&T.length>0&&(b=[...b].sort((S,M)=>{for(const I of T){const _=ql(E(S.row,I.field),E(M.row,I.field),I.sort,C(I.field));if(_!==0)return _}return 0}));const P=b.map(S=>S.row);if(b.length>0){const S={id:wt};l.forEach((M,I)=>{S[wr(M)]=I===0?Ql:""}),S.id=wt;for(const M of f)for(const I of m){const _=[];for(const{entry:F}of b){const A=F.cells.get(M)?.get(I);if(A)for(const q of A)_.push(q)}for(const F of u)F.field===I&&(S[w(M,F)]=br(_,F.aggFn))}P.push(S)}const O=b[0]?.entry.sample,W=S=>S===wt?O:S===void 0?void 0:p.get(S)?.sample,X=l.map(S=>is(S,r.get(S),W));for(const S of f){const M=h.get(S),I=g?c.map((_,F)=>{const A=r.get(_),q=rs(A,_,M.values[F],M.sample);return A?.headerName?`${A.headerName}: ${q}`:q}).join(" / "):"";for(const _ of u){const F=r.get(_.field),A=_.headerName??F?.headerName??_.field;X.push({field:w(S,_),headerName:I?`${I} — ${A} (${_.aggFn})`:`${A} (${_.aggFn})`,width:140,type:"number",align:"right",headerAlign:"right",sortable:!0,valueFormatter:({value:q,row:K})=>ao(q,_.aggFn,F,K)})}}return{pivotRows:P,pivotColumns:X,colKeys:f,isValid:!0}}function rs(e,t,o,n){const r=n?Ho(n,t,o,e):void 0;return r!==void 0?r:o==null?"":String(o)}function is(e,t,o){const n={field:e,headerName:t?.headerName??e,width:t?.width??140,sortable:!0,hideable:!1};t&&(t.type!==void 0&&(n.type=t.type),t.align!==void 0&&(n.align=t.align),t.headerAlign!==void 0&&(n.headerAlign=t.headerAlign),t.description!==void 0&&(n.description=t.description),t.minWidth!==void 0&&(n.minWidth=t.minWidth),t.maxWidth!==void 0&&(n.maxWidth=t.maxWidth),t.valueOptions!==void 0&&(n.valueOptions=t.valueOptions)),e==="id"&&(n.valueGetter=({row:c})=>c[tn]);const r=c=>c?.id===wt,i=t?.valueFormatter;i&&(n.valueFormatter=({value:c,row:d})=>r(d)?String(c??""):i({value:c,row:o(d?.id)??d,field:e}));const l=t?.renderCell;return l&&(n.renderCell=c=>r(c.row)?c.formattedValue??String(c.value??""):l({...c,row:o(c.row.id)??c.row})),n}function qe(e,t){return e===wt||t?.get(e)?.isGroupRow===!0}const Dt="__reorder_col__",At="__expand_col__",Ye="__checkbox_col__",rt=e=>e===Dt||e===At||e===Ye,yr=(e,t)=>e===t||e!==null&&t!==null&&e.id===t.id&&e.field===t.field,ls=new Set(["checkbox","radio","button","submit","reset","image","file","color"]),ss=new Set(["textbox","searchbox","combobox","listbox","slider","spinbutton"]);function as(e){const t=e.tagName;if(t==="INPUT")return!ls.has(e.type);if(t==="TEXTAREA"||t==="SELECT"||e.isContentEditable||e.closest('[contenteditable]:not([contenteditable="false"])'))return!0;const o=e.getAttribute("role");return o!==null&&ss.has(o)}const Cr=e=>e!==null&&e.nodeType===1;function _r(e,t){const o=e.closest(".ogx__detail-panel");if(o&&t.contains(o))return null;const n=e.closest('[role="gridcell"], [role="columnheader"]');return!n||n.closest(".ogx__viewport")!==t?null:n}function ds(e,t){if(e===t)return"grid";if(!Cr(e)||!t.contains(e))return"foreign";const o=_r(e,t);return o?o.classList.contains("ogx__cell--editing")?"editor":o===e?"grid":as(e)?"foreign":o.classList.contains("ogx__header-cell--checkbox")?"grid":"control":"foreign"}function cs(e,t,o,n){if(!Cr(e))return null;const r=_r(e,t),i=r?.dataset.field;if(!r||!i)return null;if(r.getAttribute("role")==="columnheader")return r.parentElement?.classList.contains("ogx__header")?{id:null,field:i}:null;const l=Number(r.parentElement?.getAttribute("data-rowindex")),c=Number.isInteger(l)?o[l]:void 0;return c?{id:n(c),field:i,rowIndex:l}:null}function Sr(e,t){if(!e)return null;for(const o of Array.from(e.children))if(o.dataset.field===t)return o;return null}function nn(e,t,o){if(t.id===null){const r=e.querySelector(":scope > .ogx__content > .ogx__sticky-top > .ogx__header-wrap > .ogx__header"),i=Sr(r,t.field);return i&&t.field===Ye?i.querySelector("input")??i:i}if(o<0)return null;const n=e.querySelector(`:scope > .ogx__content > .ogx__virtual-container > .ogx__rows > [data-rowindex="${o}"],:scope > .ogx__content > .ogx__sticky-top > .ogx__pinned-rows > [data-rowindex="${o}"],:scope > .ogx__content > .ogx__sticky-bottom > .ogx__pinned-rows > [data-rowindex="${o}"]`);return Sr(n,t.field)}const us=e=>e.id,kr=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]);function fs(e,t,o,n){if(!e||o.length===0)return{cell:null,rowIndex:-1};const r=(o.find(d=>!rt(d.field))??o[0]).field,i=o.some(d=>d.field===e.field)?e.field:r;if(e.id===null)return{cell:i===e.field?e:{id:null,field:i},rowIndex:-1};const l=e.rowIndex;let c=l!==void 0&&t[l]&&n(t[l])===e.id?l:t.findIndex(d=>n(d)===e.id);return c===-1?t.length===0?{cell:{id:null,field:i},rowIndex:-1}:(c=Math.min(Math.max(l??0,0),t.length-1),{cell:{id:n(t[c]),field:i,rowIndex:c},rowIndex:c}):{cell:i===e.field?e:{...e,field:i},rowIndex:c}}function gs(e){const{allRenderableRows:t,navigationColumns:o,checkboxSelection:n,selectedRowIds:r,handleSelectionChange:i,handleDetailPanelToggle:l,editingHandlers:c,setKeyboardMode:d,sortModel:u,handleSort:g,handleSortAdd:m,multiSort:x=!1,isCellEditable:v,pagination:h,pageSize:f,virtualization:w,viewportRef:p,pinnedTopRowCount:b=0,getRowId:y=us,rowMetaMap:C,onRowActivate:N,toggleRowExpansion:T,handleSelectAll:E,rowSelectionEnabled:P=!0,multipleRowSelectionEnabled:O=!0,pinCheckboxColumn:W=!0,pinExpandColumn:X=!0,rowHeight:S,getSpanOrigin:M}=e,[I,_]=a.useState(null),[F,A]=a.useState(!1),q=a.useMemo(()=>fs(I,t,o,y),[I,t,o,y]),K=q.cell,J=q.rowIndex,te=a.useRef(!1),ne=a.useRef(!1),Z=a.useRef(!1),de=a.useRef(null),ae=a.useCallback(G=>{ne.current=!0,G.focus({preventScroll:!0}),ne.current=!1},[]),oe=a.useCallback(()=>{const G=p.current;G&&!G.contains(G.ownerDocument.activeElement)&&ae(G)},[p,ae]),se=a.useMemo(()=>o.find(G=>!rt(G.field))??o[0],[o]),re=a.useCallback(()=>{if(n)return{id:null,field:Ye};if(!se)return null;const G=t[0];return G?{id:y(G),field:se.field,rowIndex:0}:{id:null,field:se.field}},[n,se,t,y]),B=a.useCallback((G,V)=>{const Y=p.current;if(!Y)return;const{cumulativeHeights:H,pinnedBottomHeight:j,columnMetrics:z}=w;if(G>=0&&Rn(Y,G-b,H,j,S),rt(V)){!(V===Dt||V===At&&X||V===Ye&&W)&&Y.scrollLeft>0&&(Y.scrollLeft=0);return}if(!z)return;const{clientWidth:k,scrollLeft:L}=Y,{leftPinnedWidth:Q,rightPinnedWidth:ee,unpinnedAccWidths:ce,unpinnedCols:ue,totalSpecialsWidth:he,pinnedSpecialsWidth:be}=z,Ce=ue.findIndex(ye=>ye.field===V);if(Ce===-1)return;const fe=he+Q+(Ce>0?ce[Ce-1]:0),me=he+Q+ce[Ce],ve=L+be+Q,Se=L+k-ee;let le=L;fe<ve?le=Math.max(0,fe-be-Q):me>Se&&(le=me-k+ee),le!==L&&(Y.scrollLeft=le)},[p,w,b,S,W,X]);a.useLayoutEffect(()=>{const G=p.current,V=!yr(de.current,K);if(de.current=K,!G||!K)return;const Y=G.ownerDocument,H=Y.activeElement;let j;if(H===G?j=!0:!H||H===Y.body?j=te.current:G.contains(H)?j=V:j=!1,!j)return;const z=nn(G,K,J);z?z.contains(H)||z.focus({preventScroll:!0}):H!==G&&ae(G)});const D=a.useCallback(()=>{Z.current=!0,d(!1)},[d]),$=a.useCallback(G=>{const V=G.currentTarget,Y=G.relatedTarget,H=!(Y instanceof Node&&V.contains(Y)),j=Z.current;if(Z.current=!1,te.current=!0,A(!0),ne.current)return;if(G.target===V){if(!H)return;if(j||d(!0),K){const L=nn(V,K,J);L?L.focus({preventScroll:!0}):B(J,K.field);return}const k=re();k&&(_(L=>L??k),B(k.rowIndex??-1,k.field));return}const z=cs(G.target,V,t,y);z&&!yr(z,K)&&_(z)},[K,J,re,B,d,t,y]),R=a.useCallback(G=>{const V=G.relatedTarget;V instanceof Node&&G.currentTarget.contains(V)||(te.current=!1,Z.current=!1,A(!1),d(!1))},[d]),U=a.useCallback(G=>{const V=G.currentTarget,Y=ds(G.target,V);if(Y==="foreign"||(d(!0),G.nativeEvent?.isComposing||G.keyCode===229))return;const{key:H}=G,j=H===" "||H==="Spacebar",z=!!c.editingCell,k=(ie,ge)=>{const we=o[ge];!we||ie<-1||ie>=t.length||(_(ie===-1?{id:null,field:we.field}:{id:y(t[ie]),field:we.field,rowIndex:ie}),B(ie,we.field))};if(!K){if(!kr.has(H))return;const ie=re();if(!ie)return;G.preventDefault(),_(ie),B(ie.rowIndex??-1,ie.field);return}const{id:L,field:Q}=K,ee=J,ce=o.findIndex(ie=>ie.field===Q),ue=o.filter(ie=>rt(ie.field)).length,he=ie=>qe(ie,C),be=(ie,ge,we)=>{const Me=o[we];return rt(Me.field)?!1:Jn({row:ie,field:Me.field,value:Le(ie,Me.field,Me),colDef:Me,rowIndex:ge,colIndex:we-ue,rowMeta:C?.get(y(ie))},v)},Ce=ie=>{let ge=ee,we=ce;const Me=(t.length+1)*o.length;for(let Pe=0;Pe<Me;Pe++){if(we+=ie,we>=o.length?(we=0,ge++):we<0&&(we=o.length-1,ge--),ge<0||ge>=t.length)return null;const De=t[ge];if(!M?.(y(De),o[we].field)&&be(De,ge,we))return{r:ge,c:we}}return null};if(z){if(H==="Enter")G.preventDefault(),c.stopCellEdit();else if(H==="Escape")G.preventDefault(),c.stopCellEdit({cancel:!0});else if(H==="Tab"&&L!==null){const ie=Ce(G.shiftKey?-1:1);ie&&(G.preventDefault(),c.stopCellEdit(),k(ie.r,ie.c))}return}if(H==="Tab"||H==="Escape"||Y==="control"&&(H==="Enter"||j))return;if((G.ctrlKey||G.metaKey)&&(H==="a"||H==="A")){if(!P||!O||!E)return;G.preventDefault(),E(!0);return}if(L===null){if(H==="Enter"||j){if(G.preventDefault(),Q===Ye){nn(V,K,-1)?.click();return}const ie=o[ce];if(!ie||rt(Q)||ie.sortable===!1)return;const ge=u.find(Me=>Me.field===Q),we=ge?ge.sort==="asc"?"desc":null:"asc";(x||G.shiftKey)&&m?m(Q,we):g(Q,we);return}}else if(H==="Enter"||j){G.preventDefault();const ie=t[ee];if(Q===Ye){i(L,!r.has(L));return}if(Q===At){G.shiftKey||l(L);return}if(j){G.shiftKey&&P&&!he(L)&&i(L,!r.has(L));return}if(Q===Dt)return;if(be(ie,ee,ce)){c.startCellEdit({id:L,field:Q,value:Le(ie,Q,o[ce])});return}if(T&&C?.get(L)?.hasChildren){T(L);return}N?.({row:ie,id:L,rowIndex:ee});return}if(G.altKey&&(H==="ArrowRight"||H==="ArrowLeft")&&T&&L!==null){G.preventDefault();const ie=C?.get(L);ie?.hasChildren&&!!ie.isExpanded!=(H==="ArrowRight")&&T(L);return}if(!kr.has(H))return;G.preventDefault();const fe=t.length-1,me=o.length-1,ve=G.ctrlKey||G.metaKey,Se=h?f:10,le=(ie,ge)=>{switch(H){case"ArrowRight":return ge+1>me?{r:ie+1,c:0}:{r:ie,c:ge+1};case"ArrowLeft":return ge-1<0?{r:ie-1,c:me}:{r:ie,c:ge-1};case"ArrowDown":return{r:ie+1,c:ge};case"ArrowUp":return{r:ie-1,c:ge};case"Home":return{r:ve?-1:ie,c:0};case"End":return{r:ve?fe:ie,c:me};case"PageUp":return{r:Math.max(-1,ie-Se),c:ge};default:return{r:Math.min(fe,ie+Se),c:ge}}},ye=({r:ie,c:ge})=>ie>=-1&&ie<=fe&&ge>=0&&ge<=me,Te=({r:ie,c:ge})=>ie>=0?M?.(y(t[ie]),o[ge].field)??null:null;let xe=le(ee,ce);if(H.startsWith("Arrow"))for(let ie=ye(xe)?Te(xe):null;ie&&ie.rowId===L&&ie.field===Q;ie=ye(xe)?Te(xe):null)xe=le(xe.r,xe.c);if(!ye(xe))return;const Ee=Te(xe);if(Ee){const ie=t.findIndex(we=>y(we)===Ee.rowId),ge=o.findIndex(we=>we.field===Ee.field);ie!==-1&&ge!==-1&&(xe={r:ie,c:ge})}xe.r===ee&&xe.c===ce||k(xe.r,xe.c)},[K,J,t,o,c,r,i,l,d,u,g,m,x,v,h,f,C,N,T,E,P,O,re,B,M,y]);return{focusedCell:K,setFocusedCell:_,viewportTabIndex:F?-1:0,ensureGridFocus:oe,handleFocus:$,handleBlur:R,handleKeyDown:U,handleMouseDownCapture:D}}const ps={rowFields:[],columnFields:[],valueFields:[]},Er=100;function hs(e){return!e||e.length===0||e.includes(Er)?Er:e[0]}function ws(e){const{initialState:t,sortModel:o,onSortModelChange:n,filterModel:r,onFilterModelChange:i,aggregationModel:l,onAggregationModelChange:c,columnVisibilityModel:d,onColumnVisibilityModelChange:u,pinnedColumns:g,onPinnedColumnsChange:m,pivotModel:x,onPivotModelChange:v,paginationModel:h,onPaginationModelChange:f,pageSizeOptions:w,rowSelectionModel:p,onRowSelectionModelChange:b,density:y}=e,[C,N]=a.useState(()=>t?.sorting?.sortModel??[]),T=o!==void 0,E=T?o:C,P=a.useCallback(fe=>{T||N(fe),n?.(fe)},[T,n]),[O,W]=a.useState(()=>t?.filter?.filterModel??{items:[]}),X=r!=null,S=X?r:O,M=a.useCallback(fe=>{X||W(fe),i?.(fe)},[X,i]),I=l!==void 0,[_,F]=a.useState(()=>l??{}),A=JSON.stringify(I?l:_),q=a.useMemo(()=>JSON.parse(A),[A]),K=a.useCallback(fe=>{I||F(fe),c?.(fe)},[I,c]),J=d!==void 0,[te,ne]=a.useState(()=>t?.columns?.columnVisibilityModel??{}),Z=J?d:te,de=a.useCallback(fe=>{J||ne(fe),u?.(fe)},[J,u]),ae=g!==void 0,[oe,se]=a.useState(()=>t?.columns?.pinnedColumns??{}),re=ae?g:oe,B=a.useCallback(fe=>{ae||se(fe),m?.(fe)},[ae,m]),[D,$]=a.useState(()=>x??ps),R=x??D,U=a.useCallback(fe=>{$(fe),v?.(fe)},[v]),G=h!==void 0,[V,Y]=a.useState(()=>t?.pagination?.paginationModel??h??{page:0,pageSize:hs(w)}),H=G?h:V,j=a.useCallback(fe=>{G||Y(fe),f?.(fe)},[G,f]),z=p!==void 0,[k,L]=a.useState([]),Q=z?p:k,ee=a.useMemo(()=>new Set(Q),[Q]),ce=a.useRef(null);a.useLayoutEffect(()=>{ce.current=null});const ue=a.useCallback(()=>ce.current,[]),he=a.useCallback(fe=>{ce.current=fe,z||L(fe),b?.(fe)},[z,b]),[be]=a.useState(()=>t?.density?.density??"standard");return{sortModel:E,isSortControlled:T,setInternalSortModel:N,handleSortModelChange:P,filterModel:S,isFilterControlled:X,handleFilterModelChange:M,aggregationModel:q,handleAggregationModelChange:K,columnVisibilityModel:Z,handleColumnVisibilityModelChange:de,pinnedColumns:re,handlePinnedColumnsChange:B,currentPivotModel:R,handlePivotModelChange:U,effectivePaginationModel:H,handlePaginationModelChange:j,rowSelectionModel:Q,selectedRowIds:ee,isSelectionControlled:z,setInternalRowSelectionModel:L,handleRowSelectionModelChange:he,getPendingRowSelectionModel:ue,density:y??be}}const Mr=a.createContext(null),ms=52,xs=56,bs=32,vs=72;function uo(e){if(e===void 0)return;const t=/^\s*(\d+(?:\.\d+)?)\s*(px)?\s*$/.exec(e);if(!t)return;const o=Number(t[1]);return o>0?o:void 0}function ys(e){const{rowHeight:t,headerHeight:o,density:n}=e,r=a.useContext(Mr)?.grid;let i;return n==="compact"?i=uo(r?.rowHeightCompact)??bs:n==="comfortable"?i=uo(r?.rowHeightComfortable)??vs:i=t??uo(r?.rowHeightStandard)??ms,{rowHeight:i,headerHeight:o??uo(r?.headerHeight)??xs}}function fo(e){return e>=1?Math.floor(e):1}function rn(e,t){return Math.max(1,Math.ceil(Math.max(0,e)/fo(t)))}function Cs(e){const{paginationMode:t,hasDataSource:o,dataSourceRowCount:n,rowCountProp:r,clientRowCount:i}=e;return t!=="server"?i:(o?n??r:r)??i}function Nr(e){return e?{paginationRowsPerPage:e.paginationRowsPerPage,paginationOf:e.paginationOf,paginationPage:e.paginationPage}:void 0}function Pr(e,t){return Number.isFinite(e)?Math.min(Math.max(0,Math.floor(e)),Math.max(0,t-1)):0}function _s(e){const{effectiveRows:t,activeHierarchyHandlers:o,filterMode:n,filterModel:r,sortModel:i,sortingMode:l,pagination:c,paginationMode:d,effectivePaginationModel:u,pinnedRows:g,getRowId:m,columnLookup:x,hierarchyField:v}=e,h=a.useMemo(()=>o?o.getVisibleRows({labelField:v})||[]:n==="server"?t:Ro(t,r,x),[t,r,o,v,n,x]),f=a.useMemo(()=>o?n==="server"?t:Ro(t,r,x):h,[o,h,n,t,r,x]),{top:w,center:p,bottom:b}=a.useMemo(()=>o?{top:[],center:h,bottom:[]}:Sl(h,g,m),[h,g,o,m]),y=a.useMemo(()=>o||l==="server"?p:Yl(p,i,x),[p,i,o,l,x]),C=c&&d!=="server",N=fo(u.pageSize),T=C?Pr(u.page,rn(y.length,N)):u.page,E=a.useMemo(()=>{if(!C)return y;const O=T*N;return y.slice(O,O+N)},[y,C,T,N]),P=a.useMemo(()=>{const O=c?E:y;return[...w,...O,...b]},[w,E,y,b,c]);return{filteredRows:h,dataRows:f,pinnedTopRows:w,unpinnedRows:p,pinnedBottomRows:b,sortedUnpinnedRows:y,paginatedUnpinnedRows:E,currentPage:T,allRenderableRows:P}}function Ss(e){const{layout:t,scrollTop:o,scrollLeft:n,viewportWidth:r,viewportHeight:i,autoHeight:l,rowReordering:c,hasDetailPanel:d,checkboxSelection:u,pinCheckboxColumn:g,pinExpandColumn:m,overscanRows:x=5}=e;return a.useMemo(()=>{const{unpinnedAccWidths:v,unpinnedColsWithWidth:h,leftPinnedCols:f,rightPinnedCols:w,totalWidth:p,leftWidth:b,rightWidth:y,unpinnedTotalWidth:C,systemColumnsWidth:N,cumulativeHeights:T,pinnedTopHeight:E,pinnedBottomHeight:P,unpinnedRowsHeight:O,rowHeights:W,unpinnedRowsLength:X}=t,S=r||1e3,M=l?E+O+P+50:i||600,I=6,_=Math.max(0,n-b),F=n+S-b;let A=0,q=h.length-1,K=0,J=v.length-1;for(;K<=J;){const U=K+J>>>1;v[U]<_?K=U+1:J=U-1}A=Math.max(0,K-I);for(let U=A;U<v.length;U++){if((U===0?0:v[U-1])>F){q=Math.min(h.length-1,U+I);break}q=Math.min(h.length-1,U+I)}const te=A>0?v[A-1]:0,ne=C-v[q],Z=[...f,...te>0?[{field:"__spacer_left__",width:te,isSpacer:!0}]:[],...h.slice(A,q+1),...ne>0?[{field:"__spacer_right__",width:ne,isSpacer:!0}]:[],...w],ae=S>0&&p>S?16:0,oe=E+O+P+ae+2;let se=0,re=X-1,B=0,D=0,$=T.length-1;for(;D<=$;){const U=D+$>>>1;T[U]<o?D=U+1:$=U-1}se=Math.max(0,D-x),B=se>0?T[se-1]:0;for(let U=se;U<T.length;U++)if(T[U]>=o+M){re=Math.min(X-1,U+x);break}const R=(c?48:0)+(d&&m?48:0)+(u&&g?48:0);return{renderContext:{firstRowIndex:se,lastRowIndex:re,firstColumnIndex:A,lastColumnIndex:q},offsetTop:B,offsetLeft:0,totalHeight:oe,pinnedTopHeight:E,pinnedBottomHeight:P,totalWidth:p,rowHeights:W,cumulativeHeights:T,virtualColumns:Z,columnMetrics:{leftPinnedWidth:b,rightPinnedWidth:y,unpinnedAccWidths:v,unpinnedCols:h,totalSpecialsWidth:N,pinnedSpecialsWidth:R}}},[t,o,n,r,i,l,c,d,u,g,m,x])}const ln="application/x-ogx-row",sn="application/x-ogx-column";function Ir(e,t,o){const n=e.dataTransfer;!n||typeof n.setData!="function"||(n.setData(t,o),n.setData("text/plain",o))}function go(e,t){const o=e.dataTransfer?.types;return o?Array.from(o).includes(t):!0}function Tr(e,t){if(!e||typeof e.addEventListener!="function")return()=>{};const o=()=>t();return e.addEventListener("dragend",o,{once:!0}),()=>e.removeEventListener("dragend",o)}function ks(e){const{columns:t,onColumnOrderChange:o,disableColumnReorder:n=!1}=e,[r,i]=a.useState(null),[l,c]=a.useState(null),d=a.useRef(()=>{}),u=a.useCallback(()=>{d.current(),d.current=()=>{},i(null),c(null)},[]);a.useEffect(()=>()=>d.current(),[]);const g=a.useCallback(v=>h=>{if(!n){if(!t.some(f=>f.field===v)){h.preventDefault();return}d.current(),d.current=Tr(h.currentTarget,u),i(v),h.dataTransfer&&(h.dataTransfer.effectAllowed="move",Ir(h,sn,v))}},[t,n,u]),m=a.useCallback(v=>h=>{if(!(n||r===null)){if(!go(h,sn)){u();return}h.preventDefault(),h.dataTransfer&&(h.dataTransfer.dropEffect="move"),c(v)}},[r,n,u]),x=a.useCallback(v=>h=>{if(h.preventDefault(),n||r===null||!go(h,sn)){u();return}const f=t.findIndex(p=>p.field===r),w=t.findIndex(p=>p.field===v);u(),!(f===-1||w===-1||f===w)&&o?.({column:t[f],oldIndex:f,targetIndex:w})},[t,r,n,o,u]);return{draggedColumn:r,dragOverColumn:l,onDragStart:n?void 0:g,onDragOver:n?void 0:m,onDragEnd:n?void 0:u,onDrop:n?void 0:x}}function an({isExpanded:e,onClick:t,variant:o="chevron",tabIndex:n}){return s.jsx("button",{className:`ogx-expand-icon ${e?"ogx-expand-icon--expanded":""}`,onClick:r=>{t&&t(r)},"aria-label":e?"Collapse row":"Expand row",type:"button",tabIndex:n,children:o==="plus-minus"?s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M4 8H12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M8 4V12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:e?0:1,transition:"opacity 0.2s ease",transformOrigin:"center"}})]}):s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{transform:e?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.2s ease"},children:s.jsx("path",{d:"M6 4L10 8L6 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}function Es({renderFn:e}){return s.jsx(s.Fragment,{children:e()})}function Ms(e,t){return Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((o,n)=>Object.is(o,t[n])):Object.is(e,t)}class it extends a.Component{constructor(t){super(t),this.state={hasError:!1,error:null,resetKey:t.resetKey}}static getDerivedStateFromProps(t,o){return Ms(t.resetKey,o.resetKey)?null:o.hasError?{hasError:!1,error:null,resetKey:t.resetKey}:{resetKey:t.resetKey}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,o){process.env.NODE_ENV!=="production"&&console.warn(`[CellErrorBoundary] field="${this.props.field}"`,t,o.componentStack)}render(){return this.state.hasError?s.jsx("div",{className:"ogx__cell-error",role:"img","aria-label":`Error in cell: ${this.props.field}`,title:this.state.error?.message??"Render error",children:"⚠"}):s.jsx(Es,{renderFn:this.props.renderFn})}}function Ns(e,t,o){if(!t||!o)return{valueGetter:e.valueGetter,valueFormatter:e.valueFormatter};const n=l=>o.has(l.id),r=e.valueGetter,i=e.valueFormatter;return{valueGetter:r?l=>n(l.row)?l.value:r(l):void 0,valueFormatter:l=>n(l.row)?ao(l.value,t,e,l.row):i?i(l):l.value==null?"":String(l.value)}}function Fr(e,t){if(!t)return e;const o=t.left??[],n=t.right??[],r=i=>{const l=Xe(i.field,t);return l==="left"?o.indexOf(i.field)-o.length:l==="right"?1+n.indexOf(i.field):0};return[...e].sort((i,l)=>r(i)-r(l))}const po=e=>e.formattedValue??e.value;function Lr(e,t,o){const n=e.renderCell;if(!n)return{useDefault:!0};const r=!!t.rowMeta?.isGroupRow;if(!o){const l=n(t);return r&&l===void 0?{useDefault:!0}:{useDefault:!1,content:l}}let i;try{i=n(t)}catch(l){return{useDefault:!1,content:s.jsx(it,{field:e.field,resetKey:t.row,renderFn:()=>{throw l}})}}return r&&i===void 0?{useDefault:!0}:{useDefault:!1,content:s.jsx(it,{field:e.field,resetKey:t.row,renderFn:()=>i})}}function Ps(e,t,o){const n=e.rowMeta;if(!n?.isGroupRow)return po(e);if(n.isGroupFooter)return null;const r=n.descendantCount;if(t&&n.hasChildren){const i=n.groupLabel??`${n.groupingField}: ${String(n.groupingValue)}`;return s.jsxs("div",{className:"ogx__group-cell-content",children:[i,r!==void 0?` (${r})`:""]})}return o?s.jsxs("div",{className:"ogx__group-cell-content",children:[n.groupLabel,r!==void 0&&r>0?` (${r})`:""]}):po(e)}const Is=e=>e.id;function Ts(e){const{activeColumns:t,isHierarchyEnabled:o,isRowGrouping:n,isTreeData:r,activeHierarchyHandlers:i,columnVisibilityModel:l,columnOrder:c,onColumnOrderChange:d,onColumnOrderModelChange:u,disableColumnReorder:g,pivotMode:m,checkboxSelection:x,hasDetailPanel:v,rowReordering:h,initialState:f,setColumns:w,pinnedColumns:p,getRowId:b=Is,aggregationModel:y,groupingRows:C}=e,N=a.useMemo(()=>t.map($=>$.field),[t]),[T,E]=a.useState(()=>f?.columns?.columnOrder??null),P=m?N.join("\0"):"",[O,W]=a.useState(null),X=O&&O.key===P?O.order:N,M=m?X:c??(T??N),I=a.useCallback($=>{if(m){W(R=>{const U=R&&R.key===P?R.order:N;return{key:P,order:typeof $=="function"?$(U):$}});return}E(R=>typeof $=="function"?$(R??N):$)},[m,P,N]),_=a.useCallback($=>m&&$.hideable===!1||l[$.field]!==!1,[m,l]),F=a.useMemo(()=>{if(!o)return;const $=new Map(M.map((V,Y)=>[V,Y])),R=V=>$.get(V.field)??t.indexOf(V),U=[...t].sort((V,Y)=>R(V)-R(Y));return(Fr(U.filter(V=>l[V.field]!==!1),p)[0]??t[0])?.field},[o,M,t,l,p]),A=a.useMemo(()=>{if(!o)return t;const $=n?C:void 0;return t.map(R=>{const U=Ns(R,y?.[R.field],$);return R.field===F?{...R,...U,renderCell:G=>{const V=G.rowMeta,Y=V?.treeDepth??0,H=!!V?.hasChildren,j=!!V?.isExpanded,z=Lr(R,G,!0),k=z.useDefault?Ps(G,n,r):z.content;return s.jsxs("div",{style:{display:"flex",alignItems:"center",paddingLeft:Y*24,width:"100%",height:"100%"},children:[s.jsx("div",{style:{marginRight:4,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",cursor:H?"pointer":"default",flexShrink:0},children:H?s.jsx("div",{onClick:L=>{L.stopPropagation(),L.preventDefault(),i?.toggleExpansion(b(G.row))},onMouseDown:L=>{L.stopPropagation()},style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:10,position:"relative"},children:s.jsx(an,{isExpanded:j,tabIndex:-1,onClick:L=>{L.stopPropagation(),L.preventDefault(),i?.toggleExpansion(b(G.row))}})}):null}),s.jsx("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:k})]})}}:{...R,...U,renderCell:G=>{const V=G.rowMeta;if(!V?.isGroupRow)return R.renderCell?R.renderCell(G):po(G);const Y=Lr(R,G,!1);return Y.useDefault?R.field===V.groupingField&&!V.isGroupFooter||G.value==null?null:po(G):Y.content}}})},[t,o,n,r,i,F,b,y,C]),[q,K]=a.useState(()=>f?.columns?.columnWidths??{}),J=a.useCallback(($,R)=>{K(U=>({...U,[$]:R}))},[]);a.useEffect(()=>{w(t)},[t,w]);const te=a.useMemo(()=>{const $=new Map(M.map((R,U)=>[R,U]));return[...A].sort((R,U)=>{const G=$.get(R.field)??A.indexOf(R),V=$.get(U.field)??A.indexOf(U);return G-V})},[A,M]),ne=a.useMemo(()=>te.filter(_),[te,_]),Z=a.useCallback(($,R)=>{(m||!c)&&I($),R&&d?.(R),m||u?.($)},[m,c,I,d,u]),de=a.useCallback(($,R)=>{const U=te.map(V=>V.field),[G]=U.splice($,1);U.splice(R,0,G),Z(U,{column:te[$],oldIndex:$,targetIndex:R})},[te,Z]),ae=ks({columns:te,onColumnOrderChange:a.useCallback(({oldIndex:$,targetIndex:R})=>de($,R),[de]),disableColumnReorder:g}),oe=a.useCallback(($,R)=>{const U=te.findIndex(V=>V.field===$),G=te.findIndex(V=>V.field===R);U===-1||G===-1||U===G||de(U,G)},[te,de]),se=a.useCallback(()=>{Z(N)},[Z,N]),re=a.useMemo(()=>Fr(ne,p),[ne,p]),B=a.useMemo(()=>{const $=[];return h&&$.push({field:Dt,sortable:!1,editable:!1}),v&&$.push({field:At,sortable:!1,editable:!1}),x&&$.push({field:Ye,sortable:!1,editable:!1}),[...$,...re]},[re,x,v,h]),D=a.useMemo(()=>new Map(re.map(($,R)=>[$.field,R])),[re]);return{effectiveColumns:A,hierarchyField:F,orderedColumns:te,visibleOrderedColumns:ne,renderOrderedColumns:re,navigationColumns:B,columnIndexMap:D,columnWidths:q,effectiveColumnOrder:M,setInternalColumnOrder:I,columnReorderHandlers:ae,moveColumn:oe,resetColumnOrder:se,handleColumnResize:J}}const Fs=e=>e.id;function Ls(e){const{renderContext:t,pinnedTopRows:o,pinnedBottomRows:n,paginatedUnpinnedRows:r,sortedUnpinnedRows:i,pagination:l,getRowId:c=Fs}=e;return a.useMemo(()=>{const{firstRowIndex:d,lastRowIndex:u}=t,g=l?r:i,m=o.length,x=o.map((y,C)=>({row:y,id:c(y),rowIndex:C,pinned:"top"})),v=n.map((y,C)=>({row:y,id:c(y),rowIndex:m+g.length+C,pinned:"bottom"})),h=Math.max(0,d),f=Math.min(g.length,u+1),w=g.slice(h,f).map((y,C)=>({row:y,id:c(y),rowIndex:m+h+C})),p=[...x,...w,...v],b=new Set;return p.filter(y=>b.has(y.id)?!1:(b.add(y.id),!0))},[t,o,n,r,i,l,c])}const Os=100;function Or(e){const{scrollTop:t,scrollHeight:o,clientHeight:n}=e;return o-t-n>=Os?null:{visibleTop:t,visibleBottom:t+n,viewportHeight:n}}function Ds(e){return e<.5?3:e<3?5:e<15?12:e<40?20:30}function As(e){const{onRowsScrollEnd:t,overscanRowCount:o=3,rowCount:n=0,autoHeight:r=!1}=e,i=a.useRef({scrollTop:0,scrollLeft:0,velocity:0}),l=a.useRef({scrollTop:0,scrollLeft:0,time:0}),c=a.useRef(null),d=a.useRef(null),u=a.useRef(null),g=a.useRef(!0),m=a.useRef(t),[x,v]=a.useState({scrollTop:0,scrollLeft:0,velocityOverscan:0});a.useEffect(()=>{m.current=t},[t]),a.useEffect(()=>()=>{c.current!==null&&cancelAnimationFrame(c.current),d.current!==null&&clearTimeout(d.current)},[]);const h=a.useCallback(p=>{const b=Or(p);if(!b){g.current=!0;return}if(!g.current)return;const y=m.current;y&&(g.current=!1,y(b))},[]),f=a.useCallback(p=>{const b=p.currentTarget,y=performance.now(),C=Math.abs(b.scrollTop-l.current.scrollTop)+Math.abs(b.scrollLeft-l.current.scrollLeft),N=y-l.current.time,T=N>0?C/N:0,E=b.scrollTop!==l.current.scrollTop;l.current={scrollTop:b.scrollTop,scrollLeft:b.scrollLeft,time:y},i.current={scrollTop:b.scrollTop,scrollLeft:b.scrollLeft,velocity:T},c.current!==null&&cancelAnimationFrame(c.current),c.current=requestAnimationFrame(()=>{c.current=null;const{scrollTop:P,scrollLeft:O,velocity:W}=i.current;v({scrollTop:P,scrollLeft:O,velocityOverscan:Ds(W)})}),d.current!==null&&clearTimeout(d.current),d.current=setTimeout(()=>{d.current=null,v(P=>P.velocityOverscan===0?P:{...P,velocityOverscan:0})},200),E&&h(b)},[h]);a.useEffect(()=>{g.current=!0;const p=u.current;!p||r||n<=0||p.clientHeight===0||h(p)},[n,r,h]);const w=a.useCallback(p=>{if(u.current=p,!p)return;const{scrollTop:b,scrollLeft:y}=i.current;if(b===0&&y===0)return;p.scrollTop=b,p.scrollLeft=y;const C={scrollTop:p.scrollTop,scrollLeft:p.scrollLeft};(C.scrollTop!==b||C.scrollLeft!==y)&&(i.current={...i.current,...C},l.current={...l.current,...C},v(N=>({...N,...C})))},[]);return{scrollTop:x.scrollTop,scrollLeft:x.scrollLeft,overscanRows:Math.max(x.velocityOverscan,o),handleScroll:f,attachViewport:w}}function $s(e){const t=a.useRef(null);return a.useCallback(o=>{if(t.current?.disconnect(),t.current=null,!o||typeof ResizeObserver>"u")return;const n=new ResizeObserver(r=>{for(const i of r){const{width:l,height:c}=i.contentRect;e(l,c)}});n.observe(o),t.current=n},[e])}function Gs(e){const{setDimensions:t,viewportRef:o,...n}=e,{scrollTop:r,scrollLeft:i,overscanRows:l,handleScroll:c,attachViewport:d}=As(n),u=$s(t),g=a.useCallback(m=>{o.current=m,u(m),d(m)},[o,u,d]);return{scrollTop:r,scrollLeft:i,overscanRows:l,handleScroll:c,setViewportElement:g}}function Ws(){const[e,t]=a.useState(()=>new Map),o=a.useCallback((n,r)=>{t(i=>{if(i.get(n)===r)return i;const l=new Map(i);return l.set(n,r),l})},[]);return{detailPanelHeights:e,reportDetailPanelHeight:o}}function Hs(e){const{hasDetailPanel:t,controlledExpandedRowIds:o,onDetailPanelExpandedRowIdsChange:n,rowMetaMap:r}=e,[i,l]=a.useState(new Set),c=o??i,d=a.useMemo(()=>Pl(c,r),[c,r]),u=a.useCallback(x=>{if(r.get(x)?.isGroupRow)return;const v=new Set(c);v.has(x)?v.delete(x):v.add(x),o===void 0&&l(v),n?.(v)},[c,r,o,n]),{detailPanelHeights:g,reportDetailPanelHeight:m}=Ws();return{hasDetailPanel:t,expandedRowIds:d,handleDetailPanelToggle:u,detailPanelHeights:g,reportDetailPanelHeight:m}}const Bs=new Set(["__group__"]),$t=e=>!Bs.has(e);function Dr(e){return Object.keys(e).every($t)?e:Object.fromEntries(Object.entries(e).filter(([o])=>$t(o)))}function Vs(e){const t={...e};return e.left&&(t.left=e.left.filter($t)),e.right&&(t.right=e.right.filter($t)),t}function zs(e){const{onStateChange:t,sortModel:o,filterModel:n,effectivePaginationModel:r,columnWidths:i,effectiveColumnOrder:l,columnVisibilityModel:c,pinnedColumns:d,density:u}=e,g=a.useRef(t);a.useLayoutEffect(()=>{g.current=t});const m=a.useRef(null);a.useEffect(()=>{if(!g.current)return;const x={sorting:{sortModel:o},filter:{filterModel:n},pagination:{paginationModel:r},columns:{columnWidths:Dr(i),columnOrder:l.filter($t),columnVisibilityModel:Dr(c),pinnedColumns:Vs(d)},density:{density:u}},v=JSON.stringify(x);v!==m.current&&(m.current=v,g.current(x))},[o,n,r,i,l,c,d,u])}const Ks=200,js=178e5;function Us(e){const{paginationRequested:t,isRowGrouping:o,autoHeight:n,viewportHeight:r,renderedRowCount:i,totalRowCount:l,pinnedRowsIgnored:c=!1,scrollHeight:d=0,listViewWithoutColumn:u=!1}=e,g=a.useRef(!1),m=a.useRef(!1),x=a.useRef(!1),v=a.useRef(!1),h=a.useRef(!1);a.useEffect(()=>{process.env.NODE_ENV==="production"||h.current||!u||(h.current=!0,console.warn("[OpenGridX] `listView` is set without a `listViewColumn`, so the grid view is shown instead. Pass `listViewColumn` to render list items. See docs/features/list-view.md."))},[u]),a.useEffect(()=>{process.env.NODE_ENV==="production"||x.current||!c||(x.current=!0,console.warn("[OpenGridX] `pinnedRows` is ignored while treeData or rowGroupingModel is active: the rows stay in their place in the hierarchy. See docs/features/pinning.md."))},[c]),a.useEffect(()=>{process.env.NODE_ENV==="production"||v.current||d<=js||(v.current=!0,console.warn(`[OpenGridX] The grid content is ${Math.round(d)}px tall. Browsers cap element heights (about 17.9M px in Firefox, 33.5M px in Chrome and Safari), so the last rows may not be reachable by scrolling. Use pagination, server-side or infinite loading, or a smaller rowHeight. See docs/features/virtualization.md.`))},[d]),a.useEffect(()=>{process.env.NODE_ENV==="production"||g.current||t&&o&&(g.current=!0,console.warn("[OpenGridX] `pagination` is ignored while `rowGroupingModel` is active — all group rows render in one scrollable view. Give the grid a bounded height so it virtualizes. See docs/features/tree-data-grouping.md."))},[t,o]),a.useEffect(()=>{process.env.NODE_ENV==="production"||m.current||n||r>0&&l>Ks&&i>=l&&(m.current=!0,console.warn(`[OpenGridX] The grid viewport is ${Math.round(r)}px tall and is rendering all ${l} rows, so row virtualization is effectively off. The grid container has no bounded height: it grows to fit its content. Give it a fixed height, or if it is a flex child add \`min-height: 0\`. See docs/features/virtualization.md.`))},[n,r,i,l])}function Xs(e){return typeof window>"u"||typeof window.getComputedStyle!="function"||typeof navigator<"u"&&/jsdom/i.test(navigator.userAgent)?!1:window.getComputedStyle(e).display!=="flex"}let Ar=!1;function qs(e){a.useEffect(()=>{if(process.env.NODE_ENV==="production"||Ar)return;const t=e.current;!t||!Xs(t)||(Ar=!0,console.warn("[OpenGridX] The grid stylesheet is not loaded, so the grid is unstyled and renders every row (its viewport does not scroll). Add `import '@opencorestack/opengridx/styles'` once in your app root. See README.md, Getting Started."))},[e])}function ho(e,t,o,n){if(o&&n)return t.length>0?[t[t.length-1]]:Array.from(e);const r=new Set(e);return t.forEach(i=>o?r.add(i):r.delete(i)),Array.from(r)}function Ys(e,t,o){return o?e.has(t)?[]:[t]:ho(e,[t],!e.has(t),!1)}function $r(e,t){return t.length===e.size&&t.every(o=>e.has(o))}function Rs(e){const{selectedRowIds:t,onSelectionModelChange:o,disableMultipleRowSelection:n,selectableRowIds:r}=e,i=a.useCallback(m=>{$r(t,m)||o(m)},[t,o]),l=a.useCallback((m,x)=>{i(ho(t,[m],x,n))},[i,t,n]),c=a.useCallback(m=>{i(Ys(t,m,n))},[i,t,n]),d=a.useCallback(m=>{i(ho(t,r,m,!1))},[i,t,r]),{allSelected:u,someSelected:g}=a.useMemo(()=>{let m=0;for(const v of r)t.has(v)&&m++;const x=r.length>0&&m===r.length;return{allSelected:x,someSelected:!x&&m>0}},[r,t]);return{toggleRow:l,clickRow:c,selectAll:n?void 0:d,allSelected:u,someSelected:g}}function Js(e){const{dataRows:t,getRowId:o,isPivotActive:n,selectedRowIds:r,onSelectionModelChange:i,disableMultipleRowSelection:l,disableRowSelectionOnClick:c,isHierarchyEnabled:d,rowMetaMap:u,activeHierarchyHandlers:g,onRowClick:m}=e,x=a.useMemo(()=>{const w=t.map(o);return n?w.filter(p=>p!==wt):w},[t,o,n]),v=Rs({selectedRowIds:r,onSelectionModelChange:i,disableMultipleRowSelection:l,selectableRowIds:x}),h=a.useCallback(w=>{const{id:p}=w,b=d?u.get(p):void 0;if(b?.isGroupRow){b.hasChildren&&g?.toggleExpansion(p);return}m?.(w),!c&&!qe(p,u)&&v.clickRow(p)},[d,g,m,u,c,v]),f=a.useCallback((w,p)=>{qe(w,u)||v.toggleRow(w,p)},[u,v]);return{rowSelection:v,handleRowClick:h,handleSelectionChange:f}}const Gr=e=>JSON.stringify(Array.from(e,t=>typeof t=="number"?["n",t]:["s",t]));function Qs(e){const{selectedRowIds:t,rowsLookup:o,rowMetaMap:n,enabled:r,onSelectionModelChange:i}=e,l=a.useMemo(()=>{if(!r||t.size===0)return t;let u=!1;const g=new Set;for(const m of t)o.has(m)||n.has(m)?g.add(m):u=!0;return u?g:t},[r,t,o,n]),c=a.useRef(i);a.useLayoutEffect(()=>{c.current=i});const d=a.useRef(null);return a.useEffect(()=>{if(l===t){d.current=null;return}const u=`${Gr(t)}|${Gr(l)}`;d.current!==u&&(d.current=u,c.current(Array.from(l)))},[l,t]),l}function dn(e,t,o,n){return n?Rl(e,t,o):o?[{field:t,sort:o}]:e.filter(r=>r.field!==t)}function Zs(e){const{sortModel:t,onSortModelChange:o}=e,n=a.useCallback((i,l)=>{o(dn(t,i,l,!1))},[t,o]),r=a.useCallback((i,l)=>{o(dn(t,i,l,!0))},[t,o]);return{handleSort:n,handleSortAdd:r}}function ea(e){const{columnVisibilityModel:t,onColumnVisibilityModelChange:o,pinnedColumns:n,onPinnedColumnsChange:r}=e,i=a.useRef({columnVisibilityModel:t,pinnedColumns:n});a.useLayoutEffect(()=>{i.current={columnVisibilityModel:t,pinnedColumns:n}});const l=a.useCallback(d=>{const u={...i.current.columnVisibilityModel,[d]:!1};i.current={...i.current,columnVisibilityModel:u},o(u)},[o]),c=a.useCallback((d,u)=>{const g=kl(i.current.pinnedColumns,d,u);i.current={...i.current,pinnedColumns:g},r(g)},[r]);return{handleHideColumn:l,handlePinColumn:c}}function ta(e){const{apiRef:t}=e,o=a.useRef(e);a.useLayoutEffect(()=>{o.current=e}),a.useLayoutEffect(()=>{const n=t.current,r=()=>o.current;n.getSortModel=()=>r().sortModel,n.sortColumn=(d,u)=>{const{sortModel:g,multiSort:m,onSortModelChange:x}=r(),v=dn(g,d,u,m);o.current={...r(),sortModel:v},x(v)},n.getFilterModel=()=>r().filterModel,n.setFilterModel=d=>{o.current={...r(),filterModel:d},r().onFilterModelChange(d)};const i=d=>{o.current={...r(),paginationModel:d},r().onPaginationModelChange(d)};n.setPage=d=>i({...r().paginationModel,page:d}),n.setPageSize=d=>i({...r().paginationModel,pageSize:d,page:0});const l=()=>{const d=r().getPendingRowSelectionModel?.();return d?new Set(d):r().selectedRowIds},c=(d,u)=>{const{disableMultipleRowSelection:g,onRowSelectionModelChange:m,isSyntheticRowId:x}=r(),v=x?d.filter(w=>!x(w)):d;if(v.length===0)return;const h=l(),f=ho(h,v,u,g);$r(h,f)||(o.current={...r(),selectedRowIds:new Set(f)},m(f))};n.getSelectedRows=()=>Array.from(l()),n.selectRow=(d,u=!0)=>c([d],u),n.selectRows=(d,u=!0)=>c(d,u),n.getVisibleRows=()=>r().getVisibleRows(),n.getAllFilteredRows=()=>r().getAllFilteredRows(),n.getVisibleColumns=()=>r().visibleColumns},[t])}const Wr="\0";function oa(e,t){const o=e.filter(n=>t[n.field]===!1).map(n=>n.field).join(Wr);return a.useMemo(()=>{const n={};if(o)for(const r of o.split(Wr))n[r]=!1;return en(e,n)},[e,o])}function na({paginationModel:e,currentPage:t,enabled:o,onPaginationModelChange:n}){const r=a.useRef({paginationModel:e,onPaginationModelChange:n});a.useLayoutEffect(()=>{r.current={paginationModel:e,onPaginationModelChange:n}});const i=e.page,l=a.useRef(null);a.useEffect(()=>{if(!o)return;if(t===i){l.current=null;return}const c=`${i}>${t}`;if(l.current===c)return;l.current=c;const{paginationModel:d,onPaginationModelChange:u}=r.current;u({...d,page:t})},[o,t,i])}function ra(){const[e,t]=a.useState(!1),[o,n]=a.useState(!1),r=a.useRef(null),i=a.useRef(0),l=a.useMemo(()=>({registerColumnsPanel:()=>(i.current+=1,()=>{i.current-=1})}),[]),c=a.useCallback(()=>{i.current>0?t(!0):n(!0)},[]),d=a.useCallback(()=>t(!1),[]),u=a.useCallback(()=>n(!1),[]);return a.useEffect(()=>{if(!o)return;function g(x){r.current&&!r.current.contains(x.target)&&n(!1)}function m(x){x.key==="Escape"&&n(!1)}return document.addEventListener("mousedown",g),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",m)}},[o]),{toolbarHost:l,toolbarPanelRequested:e,closeToolbarPanel:d,standalonePanelOpen:o,closeStandalonePanel:u,standalonePanelRef:r,openColumnsPanel:c}}const Hr=a.createContext(null);function ia(e){if(typeof e!="function")return!1;const t=e.prototype;return!(typeof t=="object"&&t!==null&&"isReactComponent"in t)}function la({render:e,toolbarProps:t}){return s.jsx(s.Fragment,{children:e(t)})}function sa({component:e,toolbarProps:t}){if(ia(e))return s.jsx(la,{render:e,toolbarProps:t},`fn:${e.toString()}`);const o=e;return s.jsx(o,{...t})}const Br=48;function aa({columns:e,aggregationModel:t,aggregationResult:o,columnWidths:n,rowHeight:r,checkboxSelection:i,hasDetailPanel:l,rowReordering:c,pinCheckboxColumn:d=!0,pinExpandColumn:u=!0,pinnedColumns:g,loading:m=!1}){const x=a.useMemo(()=>Go(e,n,g,i,d,l,u,c),[e,n,g,i,d,l,u,c]),{lastLeft:v,firstRight:h}=a.useMemo(()=>Wo(e,g),[e,g]),f=c?Br:0,w=f+(l&&u?Br:0),p=(b,y,C)=>s.jsx("div",{className:`ogx__aggregation-spacer${y?" ogx__aggregation-spacer--pinned":""}`,style:y?{left:C}:void 0,"aria-hidden":"true"},b);return s.jsxs("div",{className:`ogx__aggregation-footer${m?" ogx__aggregation-footer--loading":""}`,role:"row","aria-label":"Aggregation totals","aria-live":"polite","aria-busy":m||void 0,style:{minHeight:`${r}px`},children:[c&&p("__reorder_col__",!0,0),l&&p("__expand_col__",u,f),i&&p("__checkbox_col__",d,w),e.map(b=>{if(b.isSpacer){const X=typeof b.width=="number"?b.width:0;return s.jsx("div",{style:{width:X,minWidth:X,flexShrink:0},"aria-hidden":"true"},b.field)}const y=t[b.field],C=y&&Uo(b,y)?y:void 0,N=o[b.field],T=ot(b,n,120),E=Xe(b.field,g),P=E?x[b.field]:void 0,O=["ogx__aggregation-cell",E==="left"&&"ogx__aggregation-cell--pinned-left",E==="right"&&"ogx__aggregation-cell--pinned-right",E==="left"&&b.field===v&&"ogx__aggregation-cell--pinned-left-last",E==="right"&&b.field===h&&"ogx__aggregation-cell--pinned-right-first"].filter(Boolean).join(" "),W={width:T,minWidth:T,maxWidth:T,textAlign:b.align||"left"};return E==="left"&&P!==void 0&&(W.left=P),E==="right"&&P!==void 0&&(W.right=P),s.jsx("div",{className:O,role:"gridcell",style:W,children:C?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"ogx__aggregation-label",children:C}),s.jsx("span",{className:"ogx__aggregation-value",children:ao(N,C,b,o)})]}):null},b.field)})]})}function da({noRowsLabel:e,width:t,overlay:o}){return o?s.jsx("div",{className:"ogx__empty",style:{width:t},children:o}):s.jsxs("div",{className:"ogx__empty",style:{width:t},children:[s.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),s.jsx("path",{d:"M3 9h18M9 21V9"})]}),s.jsx("span",{children:e})]})}function Vr({dataSource:e,paginationMode:t,sortingMode:o,filterMode:n}){return!!e&&(t==="server"||t==="infinite"||o==="server"||n==="server")}const zr=Number.MAX_SAFE_INTEGER,ca="An unexpected error occurred while loading the data.";function Kr(e){return typeof e=="string"&&e?e:typeof e=="object"&&e!==null&&"message"in e&&typeof e.message=="string"&&e.message?e.message:ca}function ua({error:e,onRetry:t}){if(!e)return null;const o=Kr(e);return s.jsxs("div",{className:"ogx-error-overlay","aria-live":"assertive",role:"alert",children:[s.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:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),s.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),s.jsx("div",{className:"ogx-error-overlay__title",children:"Oops! Something went wrong"}),s.jsx("div",{className:"ogx-error-overlay__message",children:o}),t&&s.jsx("button",{type:"button",onClick:t,className:"ogx-button ogx-button--primary",children:"Retry"})]})}const Gt=({indeterminate:e=!1,label:t,className:o="",inputRef:n,...r})=>{const i=a.useRef(null),l=a.useCallback(d=>{i.current=d,typeof n=="function"?n(d):n&&(n.current=d)},[n]);a.useEffect(()=>{i.current&&(i.current.indeterminate=e)},[e]);const c=["ogx-checkbox-wrapper",r.disabled&&"ogx-checkbox-wrapper--disabled",o].filter(Boolean).join(" ");return s.jsxs("label",{className:c,children:[s.jsx("input",{ref:l,type:"checkbox",className:"ogx-checkbox__input",...r}),s.jsxs("span",{className:"ogx-checkbox__box",children:[r.checked&&!e&&s.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})}),e&&s.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsx("path",{d:"M19 13H5v-2h14v2z"})})]}),t&&s.jsx("span",{className:"ogx-checkbox__label",children:t})]})},fa=50;function cn(e,t,o,n){const r=Math.min(o??fa,t),i=Math.max(n??1/0,t);return Math.max(r,Math.min(i,e))}const ga=16;function pa(e){e.preventDefault(),e.stopPropagation()}function ha(){const e=t=>{t.stopPropagation(),t.preventDefault()};window.addEventListener("click",e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener("click",e,{capture:!0}),0)}function wa(e){const{field:t,currentWidth:o,onResize:n,minWidth:r,maxWidth:i,edge:l="end"}=e,[c,d]=a.useState(!1),u=a.useRef(null);a.useEffect(()=>()=>{u.current=null},[]);const g=a.useCallback((p,b)=>{const y=b-p.startX,C=p.startWidth+(l==="start"?-y:y);return cn(C,p.startWidth,r,i)},[l,r,i]),m=a.useCallback(p=>{if(p.button===0){p.stopPropagation(),u.current={pointerId:p.pointerId,startX:p.clientX,startWidth:o,lastUpdate:0,moved:!1},d(!0);try{p.currentTarget.setPointerCapture(p.pointerId)}catch{}}},[o]),x=a.useCallback(p=>{const b=u.current;if(!b||p.pointerId!==b.pointerId||(p.clientX!==b.startX&&(b.moved=!0),!b.moved))return;const y=Date.now();y-b.lastUpdate>=ga&&(b.lastUpdate=y,n(t,g(b,p.clientX)))},[t,n,g]),v=a.useCallback((p,b)=>{const y=u.current;!y||p.pointerId!==y.pointerId||(u.current=null,d(!1),(y.moved||p.clientX!==y.startX)&&(ha(),b&&n(t,g(y,p.clientX))))},[t,n,g]),h=a.useCallback(p=>{if(p.key!=="ArrowLeft"&&p.key!=="ArrowRight")return;p.preventDefault(),p.stopPropagation();const b=(p.shiftKey?50:10)*(p.key==="ArrowRight"?1:-1);n(t,cn(o+b,o,r,i))},[t,o,n,r,i]),f=a.useCallback(p=>{p.preventDefault(),p.stopPropagation()},[]),w=["ogx-column-resize-handle",l==="start"&&"ogx-column-resize-handle--start",c&&"ogx-column-resize-handle--dragging"].filter(Boolean).join(" ");return s.jsx("div",{className:w,onPointerDown:m,onMouseDown:pa,onPointerMove:x,onPointerUp:p=>v(p,!0),onPointerCancel:p=>v(p,!1),onClick:p=>p.stopPropagation(),onDragStart:p=>{p.preventDefault(),p.stopPropagation()},onDoubleClick:f,onKeyDown:h,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${t} column`,"aria-valuenow":Math.round(o),"aria-valuemin":Math.round(Math.min(r??50,o)),"aria-valuemax":i,tabIndex:-1,children:s.jsx("div",{className:"ogx-column-resize-handle__line"})})}function jr(e){if(!e)return 0;let t=0;const o=(n,r)=>{t=Math.max(t,r);for(const i of n.children)typeof i!="string"&&o(i,r+1)};return e.forEach(n=>o(n,1)),t}function Ur(e){const t=new Map;if(!e)return t;const o=(n,r)=>{const i=[...r,n];for(const l of n.children)typeof l=="string"?t.has(l)||t.set(l,i):o(l,i)};return e.forEach(n=>o(n,[])),t}function un(e,t,o){if(!e||e.length===0)return!0;const n=Ur(e),r=n.get(t),i=n.get(o);return(r?.[r.length-1]??null)===(i?.[i.length-1]??null)}function ma(e,t,o){const n=[];let r=0,i=null,l=null;for(const c of e){const d=c.isSpacer?null:t.get(c.field)?.[o]??null;(i===null||l!==d||i.pinned!==c.pinned)&&(i={key:`${d?d.groupId:"filler"}-${o}-${c.field}`,isGroup:d!==null,label:d?.headerName??"",headerClassName:d?.headerClassName,width:0,flexGrow:0,fields:[],firstDataIndex:r,pinned:c.pinned},l=d,n.push(i)),i.width+=c.width,i.flexGrow+=c.flex??0,c.isSpacer||(i.fields.push(c.field),r++)}return n}function xt(){return document.documentElement.clientWidth||window.innerWidth}function xa(){return document.documentElement.clientHeight||window.innerHeight}function bt(){return s.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"currentColor",children:s.jsx("circle",{cx:"4",cy:"4",r:"4"})})}function vt(){return s.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:s.jsx("circle",{cx:"4",cy:"4",r:"3"})})}function ba(){return s.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",children:[s.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.3"}),s.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),s.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function va(){return s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),s.jsx("polyline",{points:"5 12 12 5 19 12"})]})}function ya(){return s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),s.jsx("polyline",{points:"19 12 12 19 5 12"})]})}function Ca(){return s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:s.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})})}function _a(){return s.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.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"}),s.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"}),s.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function Sa(){return s.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"4",y1:"2",x2:"4",y2:"22"}),s.jsx("polyline",{points:"11 8 4 12 11 16"}),s.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function ka(){return s.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"20",y1:"2",x2:"20",y2:"22"}),s.jsx("polyline",{points:"13 8 20 12 13 16"}),s.jsx("line",{x1:"20",y1:"12",x2:"4",y2:"12"})]})}function Ea(){return s.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),s.jsx("line",{x1:"4",y1:"4",x2:"4",y2:"20"}),s.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}const Xr=e=>e?Array.from(e.querySelectorAll('[role="menuitem"], [role="menuitemradio"]')):[];function Ma({colDef:e,sortModel:t,onSort:o,onHide:n,onPin:r,pinnedColumns:i,onManageColumns:l,onClose:c,anchorEl:d}){const u=a.useRef(null),g=a.useCallback(W=>{W&&(d?.closest('[role="columnheader"]')??d)?.focus({preventScroll:!0}),c()},[d,c]),m=W=>{const X=Xr(u.current),S=X.indexOf(W.target);let M=-1;if(W.key==="ArrowDown")M=S+1>=X.length?0:S+1;else if(W.key==="ArrowUp")M=S<=0?X.length-1:S-1;else if(W.key==="Home")M=0;else if(W.key==="End")M=X.length-1;else if(W.key==="Tab"){W.preventDefault(),g(!0);return}else return;W.preventDefault(),X[M]?.focus()},[x,v]=a.useState({position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"});a.useLayoutEffect(()=>{if(!d||!u.current)return;const W=d.getBoundingClientRect(),X=u.current.getBoundingClientRect(),S=xt(),M=xa(),I=8;let _=W.left;_+X.width+I>S&&(_=S-X.width-I),_<I&&(_=I);let F=W.bottom+4;F+X.height+I>M&&(F=W.top-X.height-4),v({position:"fixed",zIndex:1300,top:F,left:_,visibility:"visible"})},[d]);const h=x.visibility==="visible";a.useLayoutEffect(()=>{h&&Xr(u.current)[0]?.focus({preventScroll:!0})},[h]),a.useEffect(()=>{function W(S){u.current&&!u.current.contains(S.target)&&d&&!d.contains(S.target)&&c()}function X(S){S.key==="Escape"&&g(!0)}return document.addEventListener("mousedown",W),document.addEventListener("keydown",X),window.addEventListener("scroll",c,!0),window.addEventListener("resize",c),()=>{document.removeEventListener("mousedown",W),document.removeEventListener("keydown",X),window.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c)}},[d,c,g]);const f=W=>{o?.(e.field,W),g(!0)},w=!!n&&e.hideable!==!1,p=!!r&&e.pinnable!==!1,b=()=>{w&&n?.(e.field),g(!0)},y=W=>{p&&r?.(e.field,W),g(!0)},C=t?.find(W=>W.field===e.field)?.sort,N=C==null,T=i?.left?.includes(e.field)??!1,E=i?.right?.includes(e.field)??!1,P=!T&&!E,O=e.headerName||e.field;return tt.createPortal(s.jsxs("div",{ref:u,className:"ogx-column-menu",style:x,role:"menu","aria-label":`Column options for ${O}`,onKeyDown:m,children:[o&&e.sortable!==!1&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:`ogx-menu-item${C==="asc"?" ogx-menu-item--active":""}`,onClick:()=>f("asc"),role:"menuitemradio","aria-checked":C==="asc",children:[s.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:C==="asc"?s.jsx(bt,{}):s.jsx(vt,{})}),s.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:s.jsx(va,{})}),"Sort Ascending"]}),s.jsxs("button",{type:"button",className:`ogx-menu-item${C==="desc"?" ogx-menu-item--active":""}`,onClick:()=>f("desc"),role:"menuitemradio","aria-checked":C==="desc",children:[s.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:C==="desc"?s.jsx(bt,{}):s.jsx(vt,{})}),s.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:s.jsx(ya,{})}),"Sort Descending"]}),s.jsxs("button",{type:"button",className:`ogx-menu-item${N?" ogx-menu-item--active":""}`,onClick:()=>f(null),role:"menuitemradio","aria-checked":N,children:[s.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:N?s.jsx(bt,{}):s.jsx(vt,{})}),s.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:s.jsx(Ca,{})}),"Unsort"]}),s.jsx("div",{className:"ogx-menu-divider"})]}),p&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"ogx-menu-section-label","aria-hidden":"true",children:"Pin column"}),s.jsxs("button",{type:"button",className:`ogx-menu-item${T?" ogx-menu-item--active":""}`,onClick:()=>y("left"),role:"menuitemradio","aria-checked":T,"aria-label":"Pin to left",children:[s.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:T?s.jsx(bt,{}):s.jsx(vt,{})}),s.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:s.jsx(Sa,{})}),"Pin to Left"]}),s.jsxs("button",{type:"button",className:`ogx-menu-item${E?" ogx-menu-item--active":""}`,onClick:()=>y("right"),role:"menuitemradio","aria-checked":E,"aria-label":"Pin to right",children:[s.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:E?s.jsx(bt,{}):s.jsx(vt,{})}),s.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:s.jsx(ka,{})}),"Pin to Right"]}),s.jsxs("button",{type:"button",className:`ogx-menu-item${P?" ogx-menu-item--active":""}`,onClick:()=>y(null),role:"menuitemradio","aria-checked":P,"aria-label":"Unpin column",children:[s.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:P?s.jsx(bt,{}):s.jsx(vt,{})}),s.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:s.jsx(Ea,{})}),"Unpin"]}),s.jsx("div",{className:"ogx-menu-divider"})]}),w&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:"ogx-menu-item",onClick:b,role:"menuitem","aria-label":`Hide ${O} column`,children:[s.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),s.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:s.jsx(_a,{})}),"Hide Column"]}),s.jsx("div",{className:"ogx-menu-divider"})]}),s.jsxs("button",{type:"button",className:"ogx-menu-item",onClick:()=>{l?.(),g(!1)},role:"menuitem","aria-label":"Manage all columns",children:[s.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true"}),s.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:s.jsx(ba,{})}),"Manage columns"]})]}),d?.closest(".ogx-theme-provider")||document.body)}function Na(){return s.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",fill:"currentColor",width:"18",height:"18",children:s.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 Pa(){return s.jsx("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor",children:s.jsx("path",{d:"M6.99 11L3 15l3.99 4v-3H14v-2H6.99v-3zM21 9l-3.99-4v3H10v2h7.01v3L21 9z"})})}function qr(e){const{columns:t,allColumns:o,columnGroupingModel:n,checkboxSelection:r=!1,allSelected:i=!1,someSelected:l=!1,onSelectAll:c,onSort:d,sortModel:u=[],onColumnResize:g,columnWidths:m={},pinnedColumns:x,hasDetailPanel:v=!1,pinCheckboxColumn:h=!0,pinExpandColumn:f=!0,rowReordering:w=!1,aggregationModel:p,draggedColumn:b,dragOverColumn:y,onDragStart:C,onDragOver:N,onDragEnd:T,onDrop:E,focusedCell:P,onHeaderClick:O,onSortAdd:W,multiSort:X=!1,onHideColumn:S,onPinColumn:M,onManageColumns:I,columnIndexMap:_}=e,F=a.useId(),[A,q]=a.useState(null),K=k=>L=>{L.stopPropagation(),q({colDef:k,anchorEl:L.currentTarget})},J=a.useCallback(()=>{q(null)},[]),te=k=>L=>{if(L.altKey&&(L.key==="ArrowLeft"||L.key==="ArrowRight")&&L.target===L.currentTarget){if(k.resizable===!1||!g)return;L.preventDefault(),L.stopPropagation();const ue=ot(k,m),he=(L.shiftKey?50:10)*(L.key==="ArrowRight"?1:-1);g(k.field,cn(ue+he,ue,k.minWidth,k.maxWidth));return}if(!(L.altKey&&L.key==="ArrowDown"||(L.ctrlKey||L.metaKey)&&L.key==="Enter")||k.disableColumnMenu||L.target!==L.currentTarget)return;L.preventDefault(),L.stopPropagation();const ce=L.currentTarget.querySelector(".ogx__menu-icon-btn")??L.currentTarget;q({colDef:k,anchorEl:ce})},ne=k=>P?.id===null&&P.field===k,Z=w?1:0,de=v?Z+1:Z,ae=r?de+1:de,oe=k=>L=>{if(k.sortable===!1)return;const Q=u.find(ce=>ce.field===k.field);let ee="asc";Q&&(Q.sort==="asc"?ee="desc":ee=null),(L.shiftKey||X)&&W?W(k.field,ee):d&&d(k.field,ee)},se=(k,L)=>{const Q=u.some(ce=>ce.field===k);W&&(L===null||Q||X||!d)?W(k,L):d?.(k,L)},re=k=>{const L=u.find(ee=>ee.field===k);if(!L)return null;const Q=u.length>1?u.indexOf(L)+1:null;return s.jsx("span",{className:`ogx__sort-icon ogx__sort-icon--${L.sort}`,"aria-hidden":"true",children:Q!==null&&s.jsx("span",{className:"ogx__sort-badge",children:Q})})},B=a.useMemo(()=>Go(t,m,x,r,h,v,f,w),[t,m,x,r,h,v,f,w]),D=a.useMemo(()=>Wo(t,x),[t,x]),$=jr(n),R=a.useMemo(()=>Ur(n),[n]),U=a.useMemo(()=>$===0?[]:(o??t).map(k=>({field:k.field,width:ot(k,m),flex:k.isSpacer?0:k.flex,pinned:k.isSpacer?null:Xe(k.field,x),isSpacer:k.isSpacer})),[$,o,t,m,x]),H=(w?48:0)+(v?48:0)+(r?48:0),j=(w||v||r)&&(!v||f)&&(!r||h),z=(w?1:0)+(v?1:0)+(r?1:0);return s.jsxs("div",{className:"ogx__header-wrap",children:[$>0&&Array.from({length:$},(k,L)=>{const Q=ma(U,R,L);return s.jsxs("div",{className:"ogx-col-group-row",role:"row","aria-rowindex":L+1,children:[H>0&&s.jsx("div",{className:`ogx-col-group-cell ogx-col-group-cell--filler${j?" ogx-col-group-cell--pinned ogx-col-group-cell--pinned-left":""}`,style:{width:H,minWidth:H,flexShrink:0,position:j?"sticky":void 0,left:j?0:void 0},"aria-hidden":"true"}),Q.map(ee=>{const ce=ee.pinned?` ogx-col-group-cell--pinned ogx-col-group-cell--pinned-${ee.pinned}`:"",ue={width:ee.width,minWidth:ee.width,flexShrink:0,flexGrow:ee.flexGrow};return ee.pinned==="left"?(ue.position="sticky",ue.left=B[ee.fields[0]]):ee.pinned==="right"&&(ue.position="sticky",ue.right=B[ee.fields[ee.fields.length-1]]),ee.isGroup?s.jsx("div",{role:"columnheader","aria-colspan":ee.fields.length,"aria-colindex":z+ee.firstDataIndex+1,className:`ogx-col-group-cell ogx-col-group-cell--group${ce}${ee.headerClassName?` ${ee.headerClassName}`:""}`,style:ue,title:ee.label,children:s.jsx("span",{className:"ogx-col-group-cell__label",children:ee.label})},ee.key):s.jsx("div",{className:`ogx-col-group-cell ogx-col-group-cell--filler${ce}`,style:ue,"aria-hidden":"true"},ee.key)})]},`ogx-grp-${L}`)}),s.jsxs("div",{className:"ogx__header",role:"row","aria-rowindex":$+1,children:[w&&s.jsx("div",{className:`ogx__header-cell ogx__header-cell--pinned ogx__header-cell--pinned-left ${ne("__reorder_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-label":"Row reorder handle","aria-colindex":Z,"data-field":"__reorder_col__",tabIndex:-1,title:"Drag to reorder rows",style:{minWidth:48,maxWidth:48,position:"sticky",left:0}}),v&&s.jsx("div",{className:`ogx__header-cell ogx__header-cell--expand ${f?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""} ${ne("__expand_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-label":"Expand row details","aria-colindex":de,"data-field":"__expand_col__",tabIndex:-1,style:{minWidth:48,maxWidth:48,position:f?"sticky":void 0,left:f?w?48:0:void 0}}),r&&s.jsx("div",{className:`ogx__header-cell ogx__header-cell--checkbox ${h?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""} ${ne("__checkbox_col__")?"ogx__header-cell--focused":""}`,role:"columnheader","aria-colindex":ae,"data-field":"__checkbox_col__",style:{position:h?"sticky":void 0,left:h?(w?48:0)+(v&&f?48:0):void 0},children:c&&s.jsx(Gt,{id:F,name:F,checked:i,indeterminate:l,onChange:k=>c(k.target.checked),"aria-label":i?"Deselect all rows":"Select all rows",tabIndex:-1,onMouseDown:k=>k.preventDefault()})}),t.map((k,L)=>{if(k.isSpacer)return s.jsx("div",{style:{width:k.width,minWidth:k.width,flexShrink:0},"aria-hidden":"true"},k.field);const Q=k.sortable!==!1,ee=u.findIndex(Pe=>Pe.field===k.field),ce=ee!==-1,ue=ce?u[ee].sort:null,he=_?.get(k.field)??L,be=Q?ee===0?ue==="asc"?"ascending":"descending":"none":void 0,Ce=ce&&u.length>1?`Sorted ${ue==="asc"?"ascending":"descending"}, sort priority ${ee+1} of ${u.length}`:void 0,fe=k.resizable!==!1,me=Xe(k.field,x),ve=me!==null,Se=b===k.field,le=y===k.field,ye=["ogx__header-cell",`ogx__header-cell--align-${k.headerAlign||k.align||"left"}`,Q&&"ogx__header-cell--sortable",ce&&"ogx__header-cell--sorted",ve&&"ogx__header-cell--pinned",ve&&`ogx__header-cell--pinned-${me}`,me==="left"&&k.field===D.lastLeft&&"ogx__header-cell--pinned-left-last",me==="right"&&k.field===D.firstRight&&"ogx__header-cell--pinned-right-first",Se&&"ogx__header-cell--dragging",le&&"ogx__header-cell--drag-over",ne(k.field)&&"ogx__header-cell--focused",k.headerClassName].filter(Boolean).join(" "),xe={width:m[k.field]??k.width??100,minWidth:k.minWidth,maxWidth:k.maxWidth,flexGrow:k.flex??0,flexShrink:0,flexBasis:(k.flex,"auto"),boxSizing:"border-box",position:ve?"sticky":"relative",zIndex:k.zIndex,opacity:Se?.5:1};if(ve&&me){const Pe=B[k.field];me==="left"?xe.left=Pe:xe.right=Pe}const Ee=k.renderHeader?k.renderHeader({field:k.field,colDef:k,colIndex:he}):k.headerName||k.field,ie=Pe=>{if(Pe.target.closest(".ogx-column-resize-handle")){Pe.stopPropagation();return}O?.(k.field),Q&&oe(k)(Pe)},ge=C&&!ve?C(k.field):void 0,we=N&&!ve?N(k.field):void 0,Me=E&&!ve?E(k.field):void 0;return s.jsxs("div",{className:ye,style:xe,title:k.description,onClick:ie,role:"columnheader",draggable:!!ge,onDragStart:ge,onDragOver:we,onDragEnd:T,onDrop:Me,onKeyDown:te(k),"aria-sort":be,"aria-description":Ce,"aria-colindex":z+he+1,"data-field":k.field,tabIndex:-1,children:[s.jsxs("div",{className:"ogx__header-cell-content",children:[Se&&s.jsx("div",{className:"ogx__header-drag-icon",children:s.jsx(Pa,{})}),s.jsxs("div",{className:"ogx__header-cell-title-wrapper",children:[s.jsx("span",{className:"ogx__header-cell-title",children:Ee}),p&&p[k.field]&&s.jsx("span",{className:"ogx__header-cell-aggregation",children:p[k.field]})]}),Q&&re(k.field),!k.disableColumnMenu&&s.jsx("button",{type:"button",className:"ogx__menu-icon-btn",onClick:K(k),"aria-label":`Open column menu for ${k.headerName||k.field}`,"aria-haspopup":"menu",tabIndex:-1,children:s.jsx(Na,{})})]}),fe&&g&&s.jsx(wa,{field:k.field,currentWidth:ot(k,m),onResize:g,minWidth:k.minWidth,maxWidth:k.maxWidth,edge:me==="right"?"start":"end"})]},k.field)}),A&&s.jsx(Ma,{colDef:A.colDef,sortModel:u,onSort:d||W?se:void 0,onHide:S,onPin:M,pinnedColumns:x,onManageColumns:I,onClose:J,anchorEl:A.anchorEl})]})]})}const lt=()=>{};function Yr(){return{getRow:()=>null,getAllRows:()=>[],getVisibleRows:()=>[],getAllFilteredRows:()=>[],getGroupedExportRows:()=>null,getAggregationResult:()=>null,getAggregationModel:()=>null,getColumn:()=>null,getAllColumns:()=>[],getVisibleColumns:()=>[],selectRow:lt,selectRows:lt,getSelectedRows:()=>[],sortColumn:lt,getSortModel:()=>[],setFilterModel:lt,getFilterModel:()=>({items:[]}),setPage:lt,setPageSize:lt,scrollToIndexes:lt,copySelectedRows:()=>Promise.resolve()}}const Ia=e=>e.id;let Rr=!1;function Jr(e,t,o){const n=new Map,r=new Map,i=[],l=[];return e.forEach(c=>{const d=o?.get(c)??t(c);if(n.has(d)){l.push(d);return}n.set(d,c),r.set(c,d),i.push(d)}),l.length>0&&!Rr&&process.env.NODE_ENV!=="production"&&(Rr=!0,console.warn(`[OpenGridX] ${l.length} row(s) reuse the id of an earlier row and were ignored (ids: ${l.slice(0,5).map(String).join(", ")}${l.length>5?", …":""}). Every row needs a unique id; pass getRowId if the unique key lives in another field.`)),{idRowsLookup:n,allRows:i,idByRow:r}}function Ta(e,t,o,n={}){const r=new Map,i=[];return o.forEach(l=>{r.set(l.field,l),i.push(l.field)}),{rows:Jr(e,t),columns:{all:o,lookup:r,orderedFields:i,columnVisibilityModel:n},pagination:{rowCount:void 0},pinning:{pinnedColumns:{},pinnedRows:{}},dimensions:{rowHeight:52,headerHeight:56,viewportWidth:0,viewportHeight:0},dataSource:{loading:!1,error:null}}}function Fa(e,t){switch(t.type){case"SET_ROWS":{const o=e.rows.allRows.map(r=>e.rows.idRowsLookup.get(r)),n=typeof t.payload=="function"?t.payload(o):t.payload;return{...e,rows:Jr(n,t.getRowId,e.rows.idByRow)}}case"REPLACE_ROW":{const o=e.rows.idRowsLookup.get(t.id);if(o===void 0)return e;const n=new Map(e.rows.idRowsLookup);n.set(t.id,t.row);const r=new Map(e.rows.idByRow);return r.delete(o),r.set(t.row,t.id),{...e,rows:{...e.rows,idRowsLookup:n,idByRow:r}}}case"SET_COLUMNS":{const o=new Map,n=[];return t.payload.forEach(r=>{o.set(r.field,r),n.push(r.field)}),{...e,columns:{all:t.payload,lookup:o,orderedFields:n,columnVisibilityModel:e.columns.columnVisibilityModel}}}case"SET_DIMENSIONS":return{...e,dimensions:{...e.dimensions,viewportWidth:t.payload.viewportWidth,viewportHeight:t.payload.viewportHeight}};case"SET_DATASOURCE_LOADING":return{...e,dataSource:{...e.dataSource,loading:t.payload}};case"SET_DATASOURCE_ERROR":return{...e,dataSource:{...e.dataSource,error:t.payload}};case"SET_ROW_COUNT":return{...e,pagination:{...e.pagination,rowCount:t.payload}};default:return e}}function La(e){const{rows:t,columns:o,rowHeight:n=52,headerHeight:r=56,columnVisibilityModel:i,initialState:l,syncRows:c=!1}=e,d=e.getRowId??Ia,u=a.useRef(d);a.useLayoutEffect(()=>{u.current=d});const[g]=a.useState(()=>Ta(t,d,o,i)),[m,x]=a.useReducer(Fa,{...g,dataSource:l?.dataSource?{...g.dataSource,...l.dataSource}:g.dataSource,pagination:{rowCount:l?.pagination?.rowCount},dimensions:{...g.dimensions,rowHeight:n,headerHeight:r}}),[v,h]=a.useState({rows:t,syncRows:c});(v.rows!==t||v.syncRows!==c)&&(h({rows:t,syncRows:c}),c&&x({type:"SET_ROWS",payload:t,getRowId:d}));const f=a.useRef(m);a.useLayoutEffect(()=>{f.current=m});const w=a.useCallback((O,W)=>{x({type:"SET_ROWS",payload:O,getRowId:u.current})},[]),p=a.useCallback((O,W)=>{x({type:"REPLACE_ROW",id:O,row:W})},[]),b=a.useCallback(O=>{x({type:"SET_COLUMNS",payload:O})},[]),y=a.useCallback((O,W)=>{x({type:"SET_DIMENSIONS",payload:{viewportWidth:O,viewportHeight:W}})},[]),C=a.useCallback(O=>{x({type:"SET_DATASOURCE_LOADING",payload:O})},[]),N=a.useCallback(O=>{x({type:"SET_DATASOURCE_ERROR",payload:O})},[]),T=a.useCallback(O=>{x({type:"SET_ROW_COUNT",payload:O})},[]),[E]=a.useState(()=>({...Yr(),getRow:O=>f.current.rows.idRowsLookup.get(O)||null,getAllRows:()=>f.current.rows.allRows.map(O=>f.current.rows.idRowsLookup.get(O)),getColumn:O=>f.current.columns.lookup.get(O)||null,getAllColumns:()=>f.current.columns.all})),P=a.useRef(E);return{state:m,dispatch:x,apiRef:P,setRows:w,replaceRow:p,setColumns:b,setDimensions:y,setDataSourceLoading:C,setDataSourceError:N,setRowCount:T}}function Oa(e){const{onRowOrderChange:t,rows:o,getRowId:n,rowReordering:r=!1}=e,[i,l]=a.useState(null),[c,d]=a.useState(null),u=a.useRef(()=>{}),g=a.useMemo(()=>{const w=new Map;return o.forEach((p,b)=>w.set(n?n(p):p.id,b)),w},[o,n]),m=a.useCallback(w=>g.has(w),[g]),x=a.useCallback(()=>{u.current(),u.current=()=>{},l(null),d(null)},[]);a.useEffect(()=>()=>u.current(),[]);const v=a.useCallback(w=>p=>{if(r){if(!g.has(w)){p.preventDefault();return}u.current(),u.current=Tr(p.currentTarget,x),l(w),p.dataTransfer&&(p.dataTransfer.effectAllowed="move",Ir(p,ln,String(w)))}},[r,g,x]),h=a.useCallback(w=>p=>{if(!(!r||i===null)){if(!go(p,ln)){x();return}g.has(w)&&(p.preventDefault(),p.dataTransfer&&(p.dataTransfer.dropEffect="move"),c!==w&&d(w))}},[r,i,c,g,x]),f=a.useCallback(w=>p=>{if(p.preventDefault(),i===null||!go(p,ln)){x();return}const b=g.get(i),y=g.get(w);x(),t&&b!==void 0&&y!==void 0&&b!==y&&t({row:o[b],oldIndex:b,targetIndex:y})},[i,t,o,g,x]);return{draggedRowId:i,dragOverRowId:c,canReorderRow:m,onDragStart:r?v:void 0,onDragOver:r?h:void 0,onDragEnd:r?x:void 0,onDrop:r?f:void 0}}const Qr=new Map,Zr=e=>JSON.stringify(e),Da=e=>`auto-group-${e}`,ei=5,ti=e=>e.slice(0,ei).map(t=>JSON.stringify(t)).join(", ")+(e.length>ei?", …":""),Aa={treeNodes:new Map,rootIds:[],groupingRows:[],syntheticIds:new Set,rowLookup:new Map,issues:[]};function $a(e,t,o){const n=new Map,r=[],i=[],l=new Set,c=new Map,d=new Map,u=[],g=new Array(e.length),m=new Array(e.length),x=[],v=new Map;e.forEach((f,w)=>{const p=t(f),b=o(f),y=Array.isArray(b)?b.map(C=>String(C)):[];if(g[w]=p,m[w]=y,c.set(p,f),y.length===0)x.push(p);else{const C=Zr(y),N=d.get(C);if(N===void 0)d.set(C,p);else{const T=v.get(C)??[N];T.push(p),v.set(C,T)}}n.set(p,{id:p,parentId:null,depth:Math.max(y.length-1,0),groupingKey:y[y.length-1]??"",isExpanded:!1,children:[],serverChildrenCount:f.serverChildrenCount})});const h=f=>{const w=Zr(f),p=d.get(w);if(p!==void 0)return p;const b=Da(w),y=f[f.length-1],C={id:b,parentId:null,depth:f.length-1,groupingKey:y,isExpanded:!1,children:[],label:y};n.set(b,C),d.set(w,b),l.add(b);const N={id:b};if(i.push(N),c.set(b,N),f.length===1)r.push(b);else{const T=h(f.slice(0,-1));C.parentId=T,n.get(T)?.children?.push(b)}return b};return e.forEach((f,w)=>{const p=g[w],b=m[w];if(b.length<=1){r.push(p);return}const y=h(b.slice(0,-1)),C=n.get(p);C&&(C.parentId=y),n.get(y)?.children?.push(p)}),x.length>0&&u.push(`[OpenGridX] treeData: getTreeDataPath returned an empty path for row(s) ${ti(x)}. They are shown as top-level rows.`),v.forEach((f,w)=>{u.push(`[OpenGridX] treeData: rows ${ti(f)} have the same path ${w}. Rows under that path are attached to row ${JSON.stringify(f[0])}.`)}),{treeNodes:n,rootIds:r,groupingRows:i,syntheticIds:l,rowLookup:c,issues:u}}function Ga(e,t){const{treeNodes:o,rootIds:n,syntheticIds:r,rowLookup:i}=e,l=new Set,c=new Map,d=new Map,u=g=>{const m=o.get(g);if(!m)return!1;const x=[];let v=0;for(const p of m.children??[])u(p)&&(x.push(p),v+=(r.has(p)?0:1)+(d.get(p)??0));c.set(g,x),d.set(g,v);const h=i.get(g),w=!r.has(g)&&h!==void 0&&(t?t(h):!0)||x.length>0;return w&&l.add(g),w};return n.forEach(u),{visible:l,visibleChildren:c,descendantCounts:d}}function Wa(e){const{rows:t,getRowId:o,getTreeDataPath:n,treeData:r=!1,defaultGroupingExpansionDepth:i=0,filterModel:l,sortModel:c,onRowExpansionChange:d,columnLookup:u,filterMode:g="client",sortingMode:m="client"}=e,x=r&&!!n,v=a.useMemo(()=>!r||!n?Aa:$a(t,o,n),[t,n,r,o]),{treeNodes:h,rootIds:f,groupingRows:w,syntheticIds:p,rowLookup:b}=v,y=v.issues.join(`
2
+ `);a.useEffect(()=>{process.env.NODE_ENV==="production"||!y||y.split(`
3
+ `).forEach(J=>console.warn(J))},[y]);const C=r&&!n;a.useEffect(()=>{process.env.NODE_ENV==="production"||!C||console.warn("[OpenGridX] treeData is set without getTreeDataPath, so the rows are shown as a flat list. Pass getTreeDataPath={(row) => row.path} to build the tree.")},[C]);const N=a.useMemo(()=>g==="server"?null:co(l,u),[g,l,u]),T=a.useMemo(()=>Ga(v,N),[v,N]),E=`${r}|${i}`,[P,O]=a.useState(()=>({configKey:E,overrides:new Map})),W=P.configKey===E?P.overrides:Qr,X=a.useCallback(J=>((J?.children?.length??0)>0||(J?.serverChildrenCount??0)>0)&&(i===-1||(J?.depth??0)<i),[i]),S=a.useMemo(()=>{const J=new Set;return x&&h.forEach((te,ne)=>{(W.get(ne)??X(te))&&J.add(ne)}),J},[x,h,W,X]),M=a.useCallback(J=>{const te=!S.has(J);if(O(ne=>{const Z=ne.configKey===E?ne.overrides:Qr,de=new Map(Z);return de.set(J,te),{configKey:E,overrides:de}}),te&&d){const ne=h.get(J);ne&&d(ne)}},[S,E,h,d]),I=m!=="server"&&!!(c&&c.length>0),_=a.useCallback(J=>{if(!x)return null;const te=J?.labelField,ne=J?.expandAll??!1,{visible:Z,visibleChildren:de}=T,ae=I&&c?c:[],oe=(D,$)=>{if(p.has(D))return{value:$.field===te?h.get(D)?.label:void 0};const R=b.get(D),U=u?.byField.get($.field);return{value:R?Le(R,$.field,U):void 0,type:U?.type}},se=[],re=new Set,B=D=>{const $=D.filter(U=>Z.has(U)),R=ae.length>0?Zo($,ae,oe):$;for(const U of R){if(re.has(U))continue;const G=b.get(U);if(!G)continue;re.add(U),se.push(G);const V=de.get(U);V&&V.length>0&&(ne||S.has(U))&&B(V)}};return B(f),se},[x,T,I,c,p,h,b,u,f,S]),F=a.useCallback(J=>S.has(J),[S]),A=a.useCallback(J=>h.get(J),[h]),q=a.useCallback(J=>{const te=[];let ne=J;for(;ne!==null;){const Z=h.get(ne);if(!Z)break;te.unshift(Z.groupingKey),ne=Z.parentId}return te},[h]),K=a.useMemo(()=>{const J=new Map,{visibleChildren:te,descendantCounts:ne}=T;return h.forEach((Z,de)=>{const ae=(Z.children?.length??0)===0&&(Z.serverChildrenCount??0)>0,oe=p.has(de),se={hasChildren:(te.get(de)?.length??0)>0||ae,treeDepth:Z.depth,descendantCount:ae?void 0:ne.get(de)??0,isGroupRow:oe,isExpanded:S.has(de)};oe&&(se.groupLabel=Z.label),J.set(de,se)}),J},[h,p,T,S]);return a.useMemo(()=>({treeNodes:h,groupingRows:w,toggleExpansion:M,isGroupExpanded:F,getVisibleRows:_,getNode:A,getNodePath:q,rowMetaMap:K}),[h,w,M,F,_,A,q,K])}const oi=e=>e===null?"footer":"inline";function ni(e,t){return no(()=>e(t),oi(t),"getAggregationPosition","getAggregationPosition threw; the default position is used")}function Ha(e,t,o){const n=`${t}: ${String(o)}`,r=e?.groupingValueFormatter;return r?no(()=>r({field:t,value:o}),n,`groupingValueFormatter:${t}`,`groupingValueFormatter for column "${t}" threw; the group is labelled "${t}: value"`):n}const Ba=[],Va={},ri=new Map,He="";function za(e){if(typeof e=="string")return e;if(e===null)return`${He}null`;if(e===void 0)return`${He}undefined`;if(e instanceof Date)return`${He}date:${e.getTime()}`;if(typeof e=="object")try{return`${He}object:${JSON.stringify(e)}`}catch{return`${He}object:${String(e)}`}return`${He}${typeof e}:${String(e)}`}const Ka=(e,t,o)=>`auto-group-${e}-${t}-${o??"root"}`,ja=e=>`${e}${He}footer`,Ua=e=>e==="footer"?"f":e===null?"n":"i",Xa=e=>e==="f"?"footer":e==="n"?null:"inline";function qa(e){const{rows:t,getRowId:o,columns:n,rowGroupingModel:r=Ba,aggregationModel:i=Va,defaultGroupingExpansionDepth:l=0,filterModel:c,sortModel:d,getAggregationPosition:u=oi,columnLookup:g,filterMode:m="client",sortingMode:x="client"}=e,v=r.join(He),h=a.useMemo(()=>v===""?[]:v.split(He),[v]),f=JSON.stringify(Object.entries(i)),w=a.useMemo(()=>Object.fromEntries(JSON.parse(f)),[f]),p=Object.keys(w).length>0,b=a.useMemo(()=>{const B=new Map;return(n??[]).forEach(D=>B.set(D.field,D)),B},[n]),y=h.length>0,C=a.useMemo(()=>h.filter(B=>b.get(B)?.groupable!==!1),[h,b]),T=`${C.join(He)}|${l}`,[E,P]=a.useState(()=>({configKey:T,overrides:new Map})),O=E.configKey===T?E.overrides:ri,W=a.useMemo(()=>{if(!y||m==="server")return null;const B=co(c,g);return B?new Set(t.filter(D=>B(D))):null},[y,t,m,c,g]),X=a.useMemo(()=>{const B=new Map,D=[],$=[],R=new Map,U=new Map,G=new Map;if(!y)return{treeNodes:B,rootIds:D,groupIds:$,groupRowVariants:R,groupingRows:U,rowLookup:G};const V=(Y,H,j)=>{if(H>=C.length)return(W?Y.filter(ce=>W.has(ce)):Y).map(ce=>{const ue=o(ce);return G.set(ue,ce),B.set(ue,{id:ue,parentId:j,depth:H,groupingKey:"",isExpanded:!1}),ue});const z=C[H],k=b.get(z),L=new Map;for(const ee of Y){const ce=Le(ee,z,k),ue=za(ce);let he=L.get(ue);he||(he={value:ce,rows:[]},L.set(ue,he)),he.rows.push(ee)}const Q=[];return L.forEach((ee,ce)=>{const ue=W?ee.rows.filter(Se=>W.has(Se)):ee.rows;if(ue.length===0)return;const he=Ka(z,ce,j);Q.push(he),$.push(he);const be=p?so(ue,w,b,"useRowGrouping"):{},Ce={[z]:ee.value,...be,id:he},fe={[z]:ee.value,id:he},me=p?{...be,id:ja(he)}:null;R.set(he,{inline:Ce,bare:fe,footer:me}),U.set(he,Ce),me&&U.set(me.id,me);const ve={id:he,parentId:j,depth:H,groupingKey:String(ee.value),groupingField:z,groupingValue:ee.value,aggregatedValues:be,isExpanded:!1,children:[],label:Ha(k,z,ee.value),descendantCount:ue.length};B.set(he,ve),ve.children=V(ee.rows,H+1,he)}),Q};return D.push(...V(t,0,null)),{treeNodes:B,rootIds:D,groupIds:$,groupRowVariants:R,groupingRows:U,rowLookup:G}},[y,t,W,C,p,w,o,b]),{treeNodes:S,rootIds:M,groupIds:I,groupRowVariants:_,groupingRows:F,rowLookup:A}=X,q=a.useCallback(B=>!!(B?.children&&B.children.length>0)&&(l===-1||(B?.depth??0)<l),[l]),K=a.useMemo(()=>{const B=new Set;return S.forEach((D,$)=>{!D.children||D.children.length===0||(O.get($)??q(D))&&B.add($)}),B},[S,O,q]),J=a.useCallback(B=>{P(D=>{const $=D.configKey===T?D.overrides:ri,R=$.get(B)??q(S.get(B)),U=new Map($);return U.set(B,!R),{configKey:T,overrides:U}})},[T,S,q]),te=a.useCallback(B=>K.has(B),[K]),ne=p?I.map(B=>{const D=S.get(B);return D?Ua(ni(u,{...D,isExpanded:K.has(B)})):"i"}).join(""):"",Z=a.useMemo(()=>{const B=new Map;return I.forEach((D,$)=>B.set(D,Xa(ne[$]))),B},[I,ne]),de=p?ni(u,null):"footer",ae=x!=="server"&&!!(d&&d.length>0),oe=a.useCallback(B=>{if(!y)return null;const D=B?.labelField,$=B?.expandAll??!1,R=ae&&d?d:[],U=(H,j)=>{const z=S.get(H);if(z&&_.has(H)){const Q=z.groupingField??"";return j.field===Q||j.field===D?{value:z.groupingValue,type:g?.byField.get(Q)?.type}:z.aggregatedValues&&Object.prototype.hasOwnProperty.call(z.aggregatedValues,j.field)?{value:z.aggregatedValues[j.field],type:g?.byField.get(j.field)?.type}:{value:void 0}}const k=A.get(H),L=g?.byField.get(j.field);return{value:k?Le(k,j.field,L):void 0,type:L?.type}},G=[],V=new Set,Y=H=>{const j=R.length>0?Zo(H,R,U):H;for(const z of j){if(V.has(z))continue;V.add(z);const k=_.get(z);if(!k){const ue=A.get(z);ue&&G.push(ue);continue}const L=S.get(z),Q=K.has(z),ee=Z.has(z)?Z.get(z)??null:"inline",ce=ee==="inline"||ee==="footer"&&!Q;G.push(ce?k.inline:k.bare),(Q||$)&&L?.children&&(Y(L.children),Q&&!$&&ee==="footer"&&k.footer&&G.push(k.footer))}};return Y(M),G},[y,ae,d,S,_,A,g,K,Z,M]),se=a.useCallback(B=>S.get(B),[S]),re=a.useMemo(()=>{const B=new Map;return S.forEach((D,$)=>{const R=_.get($);if(!R){B.set($,{hasChildren:!1,treeDepth:D.depth,isGroupRow:!1});return}const U={hasChildren:!0,treeDepth:D.depth,groupingField:D.groupingField,groupingValue:D.groupingValue,groupLabel:D.label,descendantCount:D.descendantCount,isGroupRow:!0,isExpanded:K.has($)};B.set($,U),R.footer&&Z.get($)==="footer"&&B.set(R.footer.id,{...U,hasChildren:!1,treeDepth:D.depth+1,isExpanded:void 0,isGroupFooter:!0})}),B},[S,_,K,Z]);return a.useMemo(()=>({treeNodes:S,groupingRows:F,toggleExpansion:J,isGroupExpanded:te,getVisibleRows:oe,getNode:se,rowMetaMap:re,aggregationPositions:Z,rootAggregationPosition:de}),[S,F,J,te,oe,se,re,Z,de])}const Ya=new Map;function Ra(e){const{rows:t,getRowId:o,getTreeDataPath:n,isTreeDataRequested:r,isTreeData:i,columns:l,rowGroupingModel:c,isRowGrouping:d,aggregationModel:u,defaultGroupingExpansionDepth:g,filterModel:m,sortModel:x,getAggregationPosition:v,columnLookup:h,filterMode:f,sortingMode:w}=e,p=Wa({rows:t,getRowId:o,getTreeDataPath:n,treeData:r,defaultGroupingExpansionDepth:g,filterModel:m,sortModel:x,columnLookup:h,filterMode:f,sortingMode:w}),b=qa({rows:t,getRowId:o,columns:l,rowGroupingModel:c,aggregationModel:u,defaultGroupingExpansionDepth:g,filterModel:m,sortModel:x,getAggregationPosition:v,columnLookup:h,filterMode:f,sortingMode:w}),y=i?p:d?b:null,C=a.useMemo(()=>i?p.rowMetaMap:d?b.rowMetaMap:Ya,[i,p.rowMetaMap,d,b.rowMetaMap]);return{treeDataHandlers:p,rowGroupingHandlers:b,activeHierarchyHandlers:y,rowMetaMap:C}}const yt=Promise.resolve();class ii extends Error{}function wo(e,t){return e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Object.is(e,t)}function Ja(e){return typeof e=="object"&&e!==null&&typeof e.then=="function"}function Qa(e){const[t,o]=a.useState(null),n=a.useRef(null),r=a.useRef(0),i=a.useRef(new Map),l=a.useRef(new Set),c=a.useRef(!1),d=a.useRef(e);a.useLayoutEffect(()=>{d.current=e}),a.useEffect(()=>(c.current=!0,()=>{c.current=!1}),[]);const u=a.useCallback(h=>{n.current=h,o(h)},[]),g=a.useCallback((h,f)=>{const w=i.current.get(h);if(w)return wo(w.value,f.value)?w.promise:w.promise.then(()=>{const F=n.current;if(!(r.current!==h||!F||wo(F.value,w.value)))return g(h,F)});const p=()=>r.current===h&&n.current!==null;if(wo(f.value,f.originalValue))return p()&&u(null),yt;const{rows:b,getRowId:y,columns:C,processRowUpdate:N}=d.current,T=b.find(F=>y(F)===f.id);if(!T)return p()&&u(null),yt;const E=F=>{const A=d.current.onProcessRowUpdateError;A?A(F):process.env.NODE_ENV!=="production"&&F instanceof ii&&console.error(F.message)},P=F=>{if(typeof F!="object"||F===null){E(new ii(`[OpenGridX] processRowUpdate must return the updated row object (or a Promise of it); it returned ${F===null?"null":typeof F}. The edit was not saved and the editor stays open.`));return}d.current.onRowChange?.(F,f.id);const A=n.current;r.current!==h||!A||(wo(A.value,f.value)?u(null):u({...A,originalValue:f.value}))};let O,W;const X=new Promise((F,A)=>{O=F,W=A}),S={value:f.value,promise:X};i.current.set(h,S);const M=()=>{i.current.get(h)===S&&i.current.delete(h)};let I;try{const F=C?.find(q=>q.field===f.field),A=Za(T,f,F,l.current);I=N?N(A,T):A}catch(F){return M(),E(F),O(),X}const _=F=>{M();try{P(F),O()}catch(A){W(A)}};return Ja(I)?Promise.resolve(I).then(_,F=>{M(),E(F),O()}):_(I),X},[u]),m=a.useCallback(h=>{const f=n.current;if(f){if(f.id===h.id&&f.field===h.field)return;g(r.current,f)}r.current+=1,u({id:h.id,field:h.field,value:h.value,originalValue:h.value})},[g,u]),x=a.useCallback(h=>{const f=n.current;return!f||!c.current||h?.id!==void 0&&h.id!==f.id||h?.field!==void 0&&h.field!==f.field?yt:h?.cancel?(u(null),yt):g(r.current,f)},[g,u]),v=a.useCallback(h=>{const f=n.current;!f||f.id!==h.id||f.field!==h.field||u({...f,value:h.value})},[u]);return a.useMemo(()=>({editingCell:t,startCellEdit:m,stopCellEdit:x,setEditCellValue:v}),[t,m,x,v])}function Za(e,t,o,n){return o?.valueSetter?o.valueSetter({value:t.value,row:e,field:t.field}):(o?.valueGetter&&process.env.NODE_ENV!=="production"&&!n.has(t.field)&&(n.add(t.field),console.warn(`[OpenGridX] Column "${t.field}" is editable and has a valueGetter but no valueSetter. The edited value was written to row["${t.field}"], which the valueGetter may ignore, so the cell can keep showing the old value. Add a valueSetter that maps the value back onto the row.`)),{...e,[t.field]:t.value})}const ed=e=>e.id,td={hasColSpan:!1,hasRowSpan:!1,colspanMap:new Map,rowSpanningCaches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},getSpanOrigin:()=>null,getUnpinnedColSpanRanges:()=>{},getCenterRowSpanStart:e=>e},li="\0",si="";function ai(e){if(typeof e!="number"||Number.isNaN(e))return 1;if(e===1/0)return Number.MAX_SAFE_INTEGER;if(!Number.isFinite(e))return 1;const t=Math.floor(e);return t<1?1:t}function od(e){return e.map(t=>t.field).join(li)}function nd(e){const{pinnedTopRows:t,centerRows:o,pinnedBottomRows:n,columns:r,leftPinnedColumns:i,unpinnedColumns:l,rightPinnedColumns:c,expandedRowIds:d,rowMetaMap:u,getRowId:g=ed}=e,m=a.useMemo(()=>r.some(p=>p.colSpan!==void 0&&p.colSpan!==null),[r]),x=a.useMemo(()=>r.some(p=>p.rowSpan!==void 0&&p.rowSpan!==null),[r]),v=m||x,h=v?[i,l,c].map(od).join(si):"",f=a.useMemo(()=>{if(!h)return{columns:[],leftCount:0,unpinnedCount:0};const p=new Map(r.map(N=>[N.field,N])),b=h.split(si).map(N=>N?N.split(li):[]),y=[];let C=0;for(const N of b){C+=N.length;for(const T of N){const E=p.get(T)??{field:T};y.push({colDef:E,field:T,sectionEnd:C,hasColSpan:E.colSpan!==void 0&&E.colSpan!==null,hasRowSpan:E.rowSpan!==void 0&&E.rowSpan!==null})}}return{columns:y,leftCount:b[0].length,unpinnedCount:b[1].length}},[h,r]),w=a.useMemo(()=>{if(!v||f.columns.length===0)return null;const p={colspanMap:new Map,rowSpanningCaches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},hiddenOriginFields:new Map,unpinnedRanges:new Map,centerRowSpanStart:new Map},y={spanColumns:f,expandedRowIds:d,rowMetaMap:u,getRowId:g,warned:new Set,out:p};return fn(t,0,!1,y),fn(o,t.length,!0,y),fn(n,t.length+o.length,!1,y),p},[v,f,t,o,n,d,u,g]);return a.useMemo(()=>{if(!w)return td;const{colspanMap:p,rowSpanningCaches:b,hiddenOriginFields:y,unpinnedRanges:C,centerRowSpanStart:N}=w,T=f.columns;return{hasColSpan:m,hasRowSpan:x,colspanMap:p,rowSpanningCaches:b,getSpanOrigin:(E,P)=>{const O=p.get(E)?.[P];if(O?.spannedByColSpan)return{rowId:E,field:T[O.leftVisibleCellIndex].field};const W=b.hiddenCellOriginMap[E]?.[P];return W===void 0?null:{rowId:W,field:y.get(E)?.[P]??P}},getUnpinnedColSpanRanges:E=>C.get(E),getCenterRowSpanStart:E=>N.get(E)??E}},[w,m,x,f])}function fn(e,t,o,n){const{spanColumns:r,expandedRowIds:i,rowMetaMap:l,getRowId:c,warned:d,out:u}=n,{columns:g,leftCount:m,unpinnedCount:x}=r,v=g.length,{colspanMap:h,rowSpanningCaches:f,hiddenOriginFields:w,unpinnedRanges:p,centerRowSpanStart:b}=u,y=new Int32Array(v),C=new Array(v),N=new Array(v),T=new Int32Array(v);let E=0;const P=[];g.forEach((X,S)=>{(X.hasColSpan||X.hasRowSpan)&&P.push(S)});const O=(X,S,M)=>{const I=g[M].field;if(Ct(f.hiddenCells,X,I,!0),Ct(f.hiddenCellOriginMap,X,I,C[M]),N[M]!==I&&Ct(w,X,I,N[M]),o){const _=b.get(S);(_===void 0||T[M]<_)&&b.set(S,T[M])}},W=(X,S,M)=>{const I=g[M],_=c(X),F=rd(X,_,I.colDef,t+S,M,l,d);let A=1;if(I.hasColSpan){const K=Math.min(di(I.colDef.colSpan,F,"colSpan",I.field,d),I.sectionEnd-M);for(;A<K&&y[M+A]<=S;)A++}let q=1;if(I.hasRowSpan){q=Math.min(di(I.colDef.rowSpan,F,"rowSpan",I.field,d),e.length-S);for(let K=1;K<q;K++)if(qe(c(e[S+K]),l)){q=K;break}if(q>1&&i&&i.size>0){for(let K=0;K<q-1;K++)if(i.has(c(e[S+K]))){q=K+1;break}}}if(A>1){Ct(h,_,I.field,{spannedByColSpan:!1,cellProps:{colSpan:A}});for(let K=1;K<A;K++){const J=g[M+K];Ct(h,_,J.field,{spannedByColSpan:!0,leftVisibleCellIndex:M,rightVisibleCellIndex:M+A-1})}if(M>=m&&M<m+x){let K=p.get(_);K||(K=[],p.set(_,K)),K.push(M-m,M+A-1-m)}}if(q>1){Ct(f.spannedCells,_,I.field,q);for(let K=M;K<M+A;K++)y[K]=S+q,C[K]=_,N[K]=I.field,T[K]=S;S+q>E&&(E=S+q)}return A};for(let X=0;X<e.length;X++){const S=e[X];if(!S||S._isSkeleton||qe(c(S),l))continue;if(E<=X){let I=0;for(const _ of P)_>=I&&(I=_+W(S,X,_));continue}let M=0;for(;M<v;)y[M]>X?(O(c(S),X,M),M++):g[M].hasColSpan||g[M].hasRowSpan?M+=W(S,X,M):M++}}function rd(e,t,o,n,r,i,l){const c=e[o.field];let d=c;if(o.valueGetter)try{d=o.valueGetter({row:e,field:o.field,value:c})}catch(u){ci(l,`valueGetter:${o.field}`,`valueGetter for column "${o.field}" threw while computing its span`,u),d=void 0}return{row:e,value:d,field:o.field,colDef:o,rowIndex:n,colIndex:r,rowMeta:i?.get(t)}}function di(e,t,o,n,r){if(typeof e=="number")return ai(e);if(typeof e!="function")return 1;try{return ai(e(t))}catch(i){return ci(r,`${o}:${n}`,`${o} for column "${n}" threw; the cell is rendered without a span`,i),1}}function ci(e,t,o,n){process.env.NODE_ENV==="production"||e.has(t)||(e.add(t),console.warn(`[OpenGridX] ${o}.`,n))}function Ct(e,t,o,n){if(e instanceof Map){let i=e.get(t);i||(i={},e.set(t,i)),i[o]=n;return}let r=e[t];r||(r={},e[t]=r),r[o]=n}function id(e){const{spanning:t,renderContext:o,offsetTop:n,cumulativeHeights:r}=e;return a.useMemo(()=>{if(!t.hasRowSpan)return{renderContext:o,offsetTop:n};let i=Math.max(0,o.firstRowIndex);for(let l=t.getCenterRowSpanStart(i);l<i;l=t.getCenterRowSpanStart(i))i=l;return i>=o.firstRowIndex?{renderContext:o,offsetTop:n}:{renderContext:{...o,firstRowIndex:i},offsetTop:i>0?r[i-1]??0:0}},[t,o,n,r])}function ld(e){const{spanning:t,firstColumnIndex:o,lastColumnIndex:n,virtualColumns:r,layout:i,rows:l}=e;return a.useMemo(()=>{if(!t.hasColSpan||i.unpinnedColsWithWidth.length===0)return r;let c=o,d=n,u=!0;for(;u;){u=!1;for(const{row:p,id:b}of l){const y=t.getUnpinnedColSpanRanges(b??p.id);if(y)for(let C=0;C<y.length;C+=2){const N=y[C],T=y[C+1];T<c||N>d||(N<c&&(c=N,u=!0),T>d&&(d=T,u=!0))}}}if(c===o&&d===n)return r;const{leftPinnedCols:g,unpinnedColsWithWidth:m,rightPinnedCols:x,unpinnedAccWidths:v,unpinnedTotalWidth:h}=i,f=c>0?v[c-1]:0,w=h-v[d];return[...g,...f>0?[{field:"__spacer_left__",width:f,isSpacer:!0}]:[],...m.slice(c,d+1),...w>0?[{field:"__spacer_right__",width:w,isSpacer:!0}]:[],...x]},[t,o,n,r,i,l])}function sd(e,t){const{draggedColumn:o,onDragOver:n,onDrop:r,onDragEnd:i}=t,l=a.useMemo(()=>{if(!e||e.length===0)return null;const c=d=>o===null||un(e,o,d);return{onDragOver:n&&(d=>c(d)?n(d):()=>{}),onDrop:r&&(d=>c(d)?r(d):u=>{u.preventDefault(),i?.()})}},[e,o,n,r,i]);return l?{...t,...l}:t}const ad=300,ui=e=>e.id;function dd(e,t){return e==="infinite"?"infinite":e==="server"?t?"all":"page":"all"}function fi(e,t){const o=new Set,n=[];return e.forEach(r=>{const i=t(r);o.has(i)||(o.add(i),n.push({id:i,row:r}))}),n}function gi(e,t,o){const n=new Set(e.map(o)),r=t.filter(i=>!n.has(i.id)).map(i=>i.row);return r.length===0?e:[...e,...r]}function cd(e){const{dataSource:t,sortModel:o,filterModel:n,paginationModel:r,paginationMode:i,sortingMode:l,filterMode:c,aggregationModel:d,rowGroupingActive:u=!1}=e,g=dd(i,u),m=!!t&&i==="server"&&u,x=a.useRef(!1);a.useEffect(()=>{process.env.NODE_ENV==="production"||x.current||!m||(x.current=!0,console.warn("[OpenGridX] `rowGroupingModel` turns pagination off, so the dataSource with `paginationMode: 'server'` is asked for every row (startRow 0, endRow Number.MAX_SAFE_INTEGER) instead of one page. See docs/features/data-source.md."))},[m]);const v=t?.getRows,h=Vr({dataSource:t,paginationMode:i,sortingMode:l,filterMode:c}),f=JSON.stringify([g,g!=="all"||l==="server"?o:null,g!=="all"||c==="server"?n:null,h?d??null:null,g==="all"?null:r.pageSize]),w=g==="all"?0:r.page,p=g==="all"?0:r.pageSize,b=a.useRef({params:e,kind:g});a.useLayoutEffect(()=>{b.current={params:e,kind:g}});const y=a.useRef(0),C=a.useRef(0),N=a.useRef(null),T=a.useRef({page:0,loadedEnd:0,inFlightEnd:null}),E=a.useRef(null),P=a.useRef(!1),O=a.useRef(0),W=a.useRef(!1),X=a.useRef(new Set),S=a.useCallback(()=>{const J=P.current||O.current>0;J!==W.current&&(W.current=J,b.current.params.setDataSourceLoading(J))},[]),M=a.useCallback(()=>{E.current!==null&&(clearTimeout(E.current),E.current=null)},[]),I=a.useCallback(()=>{y.current++,T.current.inFlightEnd=null,P.current=!1},[]),_=a.useCallback(()=>{C.current++,X.current.clear(),O.current=0},[]),F=a.useCallback(async()=>{const{params:J,kind:te}=b.current,ne=J.dataSource;if(!ne)return!1;const Z=T.current,de=J.paginationModel.pageSize;let ae,oe;if(te==="infinite"){if(Z.inFlightEnd!==null)return!1;if(ae=Z.loadedEnd,oe=(Z.page+1)*de,oe<=ae)return P.current=!1,S(),!1;Z.inFlightEnd=oe}else te==="page"?(ae=J.paginationModel.page*de,oe=ae+de):(ae=0,oe=zr);const se=++y.current;P.current=!0,S(),J.setDataSourceError(null);let re;try{re=await ne.getRows({startRow:ae,endRow:oe,sortModel:J.sortModel,filterModel:J.filterModel,groupKeys:[],aggregationModel:J.aggregationModel})}catch(B){return se!==y.current||(Z.inFlightEnd=null,P.current=!1,b.current.params.setDataSourceError(B),console.error("Data Source Error:",B),S()),!1}if(se!==y.current)return!1;try{const{params:B}=b.current,D=B.getRowId??ui,$=fi(re.rows,D);if(te==="infinite"&&ae>0?B.setRows(R=>gi(R,$,D),!0):(B.setRows($.map(R=>R.row),!0),_()),re.aggregationResults&&B.onAggregationResults?.(re.aggregationResults),re.rowCount!==void 0&&B.setRowCount(re.rowCount),te==="infinite"&&(Z.inFlightEnd=null,Z.loadedEnd=ae+re.rows.length,re.rows.length>=oe-ae&&(Z.page+1)*de>oe))return!0}catch(B){return Z.inFlightEnd=null,P.current=!1,b.current.params.setDataSourceError(B),console.error("Data Source Error:",B),S(),!1}return P.current=!1,S(),!1},[S,_]),A=a.useCallback(async()=>{for(;await F(););},[F]);a.useLayoutEffect(()=>{if(!v){N.current&&(N.current=null,M(),I(),_(),b.current.params.setDataSourceError(null),S());return}const J=N.current,te=T.current;if(!J||J.key!==f||J.getRows!==v){N.current={key:f,getRows:v},I(),_();const ne=g==="infinite"&&J!==null&&w!==0;if(te.page=ne?0:w,te.loadedEnd=0,ne){const{params:Z}=b.current;Z.onPaginationModelChange?.({...Z.paginationModel,page:0})}}else g==="infinite"?(w<te.page&&(I(),te.loadedEnd=0),te.page=w):I();if(g==="infinite"){const ne=te.inFlightEnd!==null;if(ne||(te.page+1)*p<=te.loadedEnd){P.current=ne,S();return}}return P.current=!0,S(),E.current=setTimeout(()=>{E.current=null,A()},ad),M},[v,f,g,w,p,M,I,_,S,A]),a.useEffect(()=>()=>{I(),_()},[I,_]);const q=a.useCallback(()=>(M(),A()),[M,A]),K=a.useCallback(async(J,te,ne)=>{const{params:Z}=b.current,de=Z.dataSource;if(!de)return;const ae=JSON.stringify(te),oe=X.current;if(oe.has(ae))return;const se=C.current;oe.add(ae),O.current++,S();try{const re=await de.getRows({startRow:0,endRow:zr,sortModel:Z.sortModel,filterModel:Z.filterModel,groupKeys:te,aggregationModel:Z.aggregationModel});if(se!==C.current)return;if(re.rows.length>0){const{params:B}=b.current,D=B.getRowId??ui,$=fi(re.rows,D);B.setRows(R=>gi(R,$,D),!0)}}catch(re){if(se!==C.current)return;oe.delete(ae),console.error("Failed to fetch children:",re),ne?.(re)}finally{se===C.current&&(O.current--,S())}},[S]);return{fetchRows:q,fetchChildren:K}}function ud(e){return(e.serverChildrenCount??0)>0&&(e.children?.length??0)===0}function fd({enabled:e,treeNodes:t,isGroupExpanded:o,getNodePath:n,toggleExpansion:r,fetchChildren:i}){const l=a.useRef({isGroupExpanded:o,toggleExpansion:r});a.useLayoutEffect(()=>{l.current={isGroupExpanded:o,toggleExpansion:r}}),a.useEffect(()=>{e&&t.forEach((c,d)=>{!ud(c)||!o(d)||i(d,n(d),()=>{const{isGroupExpanded:u,toggleExpansion:g}=l.current;u(d)&&g(d)})})},[e,t,o,n,i])}const pi={};function gd(e){const t=JSON.stringify(e),[o,n]=a.useState(null),r=a.useCallback(i=>n({modelKey:t,results:i}),[t]);return[o&&o.modelKey===t?o.results:null,r]}function hi(e){const{rows:t,columns:o,aggregationModel:n,isServerSide:r,dataSource:i,filterModel:l,sortModel:c,serverAggregationResults:d}=e,u=Object.keys(n).length>0,g=a.useMemo(()=>{const N=new Map;return(o??[]).forEach(T=>N.set(T.field,T)),N},[o]),m=a.useMemo(()=>r||!u?pi:so(t,n,g,"useAggregation"),[t,g,n,r,u]),x=JSON.stringify([n,l??null,c??[]]),v=r&&u&&!!i?.getAggregations&&!d,h=a.useRef({aggregationModel:n,filterModel:l,sortModel:c});a.useEffect(()=>{h.current={aggregationModel:n,filterModel:l,sortModel:c}});const[f,w]=a.useState(null);a.useEffect(()=>{const N=i?.getAggregations;if(!v||!N)return;let T=!1;const E=h.current;let P;try{P=Promise.resolve(N({sortModel:E.sortModel??[],filterModel:E.filterModel??{items:[]},groupKeys:[],aggregationModel:E.aggregationModel}))}catch(O){P=Promise.reject(O)}return P.then(O=>{T||w({key:x,result:O,error:null})},O=>{T||(console.error("[useAggregation] Server aggregation error:",O),w({key:x,result:null,error:O}))}),()=>{T=!0}},[v,i,x]);const p=f&&f.key===x?f:null,b=v&&p===null,y=v?p?.error??null:null;return{aggregationResult:a.useMemo(()=>r?d&&Object.keys(d).length>0?d:p?.result??pi:m,[r,m,d,p]),isLoading:b,error:y}}const pd={items:[]},hd=[];function wd(e){const{rows:t,columns:o,pivotMode:n,pivotModel:r,filterModel:i,sortModel:l,hasDataSource:c,hierarchyRequested:d}=e,u=n&&!c,g=a.useMemo(()=>new Set(o.map(p=>p.field)),[o]),m=a.useMemo(()=>en(o),[o]),x=a.useMemo(()=>ns(i,g),[i,g]),v=a.useMemo(()=>u?Ro(t,x.source,m):t,[u,t,x.source,m]),h=a.useMemo(()=>u?vr(v,o,r,{outputFilterModel:x.output,sortModel:l}):on,[u,v,o,r,x.output,l]),f=u&&h.isValid,w=a.useRef({dataSource:!1,hierarchy:!1});return a.useEffect(()=>{process.env.NODE_ENV!=="production"&&(n&&c&&!w.current.dataSource&&(w.current.dataSource=!0,console.warn("[OpenGridX] `pivotMode` is ignored when a `dataSource` is set: pivoting is client-side and the grid only holds the rows of one server page. Pivot on the server, or pass the full dataset as `rows`.")),f&&d&&!w.current.hierarchy&&(w.current.hierarchy=!0,console.warn("[OpenGridX] `treeData` and `rowGroupingModel` are turned off while `pivotMode` is active: the pivot rows are already grouped by the pivot row fields.")))},[n,c,f,d]),{isActive:f,rows:f?h.pivotRows:t,columns:f?h.pivotColumns:o,pipelineFilterModel:f?pd:i,pipelineSortModel:f?hd:l}}const Wt=({variant:e="text",size:t="medium",color:o="default",disabled:n=!1,className:r="",type:i="button",children:l,...c})=>{const d=["ogx-button",`ogx-button--${e}`,`ogx-button--${t}`,`ogx-button--${o}`,n&&"ogx-button--disabled",r].filter(Boolean).join(" ");return s.jsx("button",{type:i,className:d,disabled:n,...c,children:l})};function gn(e){const t=a.useId(),{page:o,pageSize:n,rowCount:r,onPageChange:i,onPageSizeChange:l,pageSizeOptions:c=[10,25,50,100],showFirstButton:d=!0,showLastButton:u=!0,localeText:g}=e,m=fo(n),x=rn(r,m),v=Pr(o,x),h=c.includes(m)?c:[...c,m].sort((S,M)=>S-M),f=v*m,w=Math.min(f+m,r),p=r===0?0:`${f+1}–${w}`,b=g?.paginationRowsPerPage??"Rows per page:",y=g?.paginationOf?g.paginationOf(r===0?0:f+1,w,r):`${p} of ${r}`,C=g?.paginationPage?g.paginationPage(v+1,x):`Page ${v+1} of ${x}`,N=()=>{i(0)},T=()=>{i(Math.max(0,v-1))},E=()=>{i(Math.min(x-1,v+1))},P=()=>{i(x-1)},O=S=>{const M=parseInt(S.target.value,10);l(M)},W=v===0,X=v>=x-1;return s.jsxs("div",{className:"ogx-pagination",role:"navigation","aria-label":"Pagination",children:[s.jsxs("div",{className:"ogx-pagination__page-size",children:[s.jsx("label",{htmlFor:t,className:"ogx-pagination__label",children:b}),s.jsx("select",{id:t,className:"ogx-pagination__select",value:m,onChange:O,children:h.map(S=>s.jsx("option",{value:S,children:S},S))})]}),s.jsx("div",{className:"ogx-pagination__info","aria-live":"polite","aria-atomic":"true",children:y}),s.jsxs("div",{className:"ogx-pagination__actions",children:[d&&s.jsx(Wt,{variant:"text",size:"small",onClick:N,disabled:W,"aria-label":"Go to first page",title:"First page",children:s.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:s.jsx("path",{d:"M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"})})}),s.jsx(Wt,{variant:"text",size:"small",onClick:T,disabled:W,"aria-label":"Go to previous page",title:"Previous page",children:s.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:s.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),s.jsx("div",{className:"ogx-pagination__page-info","aria-current":"page",children:C}),s.jsx(Wt,{variant:"text",size:"small",onClick:E,disabled:X,"aria-label":"Go to next page",title:"Next page",children:s.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:s.jsx("path",{d:"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"})})}),u&&s.jsx(Wt,{variant:"text",size:"small",onClick:P,disabled:X,"aria-label":"Go to last page",title:"Last page",children:s.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:s.jsx("path",{d:"M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z"})})})]})]})}function md({row:e,rowId:t,rowIndex:o,ariaRowIndex:n,listViewColumn:r,gridColumn:i,rowMeta:l,isSelected:c=!1,checkboxSelection:d=!1,rowHeight:u,onRowClick:g,onRowDoubleClick:m,onSelectionChange:x,tabIndex:v=-1,onFocus:h,onToggleExpansion:f}){const w=t??e.id,p=r.field,b=Le(e,p,i),y=Ho(e,p,b,i)??Bo(b,i),C=l?.isGroupRow===!0||qe(w),N={row:e,value:b,formattedValue:y,field:p,colDef:i??r,rowIndex:o,colIndex:0,rowMeta:l},T=E=>{E.stopPropagation(),x?.(w,E.target.checked)};return s.jsxs("div",{className:`ogx-list-view__row${c?" ogx-list-view__row--selected":""}`,style:u?{minHeight:u}:void 0,onClick:()=>g?.(e),onDoubleClick:m?()=>m(e):void 0,role:"row","aria-rowindex":n??o+1,"aria-selected":c,"aria-level":l?.treeDepth!==void 0?l.treeDepth+1:void 0,"aria-expanded":l?.hasChildren?l.isExpanded===!0:void 0,"data-rowindex":o,tabIndex:v,onFocus:h?E=>{E.target===E.currentTarget&&h(o)}:void 0,children:[d&&s.jsx("div",{className:"ogx-list-view__checkbox",onClick:E=>E.stopPropagation(),children:!C&&s.jsx("input",{type:"checkbox",checked:c,onChange:T,"aria-label":`Select row ${w}`,tabIndex:-1})}),l&&f&&s.jsx("div",{className:"ogx-list-view__expand",style:{paddingLeft:(l.treeDepth??0)*16},onClick:E=>E.stopPropagation(),onDoubleClick:E=>E.stopPropagation(),children:l.hasChildren&&s.jsx(an,{isExpanded:l.isExpanded===!0,onClick:()=>f(w),tabIndex:-1})}),s.jsx("div",{className:"ogx-list-view__cell",role:"gridcell",children:s.jsx(it,{field:p,resetKey:e,renderFn:()=>{const E=r.renderCell(N);return E===void 0&&C?l?.groupLabel:E}})})]})}function xd(e,t){const o=a.useRef(!0),n=a.useRef(e);a.useEffect(()=>{n.current=e},[e]),a.useEffect(()=>{o.current=!0},[t]);const r=a.useCallback(i=>{const l=Or(i.currentTarget);if(!l){o.current=!0;return}if(!o.current)return;const c=n.current;c&&(o.current=!1,c(l))},[]);return e?r:void 0}const bd=e=>e.id;function vd({ariaLabel:e,allRenderableRows:t,dataRowCount:o,pinnedTopRowCount:n,pinnedBottomRowCount:r,unpinnedRowCount:i,pagination:l,effectivePaginationModel:c,currentPage:d,pageSizeOptions:u,selectedRowIds:g,listViewColumn:m,columnsByField:x,rowMetaMap:v,noRowsLabel:h,rowHeight:f,checkboxSelection:w,paginationMode:p,serverRowCount:b,paginationSlot:y,paginationSlotProps:C,localeText:N,onRowClick:T,onRowDoubleClick:E,onSelectionChange:P,onPaginationModelChange:O,onRowsScrollEnd:W,getRowId:X=bd,multiselectable:S=!1,loading:M=!1,loadingOverlay:I,noRowsOverlay:_,showPaginationControls:F=!0,selectable:A=!1,onToggleExpansion:q}){const K=y||gn,J=a.useRef(null),[te,ne]=a.useState(null),Z=te===null?-1:t.findIndex(Y=>X(Y)===te),de=Z===-1?0:Z,ae=Y=>{const H=t[Y];H&&(ne(X(H)),J.current?.querySelector(`:scope > [role="row"][data-rowindex="${Y}"]`)?.focus())},oe=Y=>{const H=Y.target;if(H.getAttribute("role")!=="row"||H.parentElement!==J.current)return;const j=Number(H.getAttribute("data-rowindex")),z=t[j];if(!z)return;const k=X(z),L=t.length-1,Q=v.get(k),ee=!!(Q?.hasChildren&&q);if(Y.altKey&&(Y.key==="ArrowRight"||Y.key==="ArrowLeft")){Y.preventDefault(),ee&&Y.key==="ArrowRight"!=(Q?.isExpanded===!0)&&q?.(k);return}switch(Y.key){case"ArrowDown":Y.preventDefault(),ae(Math.min(j+1,L));return;case"ArrowUp":Y.preventDefault(),ae(Math.max(j-1,0));return;case"Home":Y.preventDefault(),ae(0);return;case"End":Y.preventDefault(),ae(L);return;case"PageDown":Y.preventDefault(),ae(Math.min(j+10,L));return;case"PageUp":Y.preventDefault(),ae(Math.max(j-10,0));return;case"Enter":case" ":if(Y.preventDefault(),Y.key===" "&&Y.shiftKey){A&&!Q?.isGroupRow&&P(k,!g.has(k));return}ee?q?.(k):T({row:z,id:k,rowIndex:j});return}},se=p==="server",re=se?b||0:i,B=se?b||0:o,D=fo(c.pageSize),$=rn(re,D),R=l?d*D:0,U=t.length-n-r,G=Y=>{if(Y<n)return Y+1;const H=Y-n;return H<U?n+R+H+1:n+re+(H-U)+1},V=xd(W,t.length);return s.jsxs("div",{className:"ogx-list-view",role:"grid","aria-label":e||"Data grid list view","aria-rowcount":B,"aria-multiselectable":S,children:[s.jsx("div",{className:"ogx-list-view__toolbar",children:s.jsxs("span",{children:[B," ",B===1?"item":"items",l?` · page ${d+1} of ${$}`:"",g.size>0?` · ${g.size} selected`:""]})}),s.jsx("div",{className:"ogx-list-view__rows",onScroll:V,onKeyDown:oe,ref:J,children:t.length===0&&M?s.jsx("div",{className:"ogx-list-view__loading",children:I??s.jsx("div",{className:"ogx__loading-bar",role:"progressbar","aria-label":"Loading data"})}):t.length===0&&_?s.jsx("div",{className:"ogx-list-view__empty",children:_}):t.length===0?s.jsxs("div",{className:"ogx-list-view__empty",children:[s.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),s.jsx("path",{d:"M3 9h18M9 21V9"})]}),h]}):t.map((Y,H)=>{const j=X(Y);return s.jsx(md,{row:Y,rowId:j,rowIndex:H,ariaRowIndex:G(H),listViewColumn:m,gridColumn:x.get(m.field),rowMeta:v.get(j),isSelected:g.has(j),checkboxSelection:w,rowHeight:f,onRowClick:z=>T({row:z,id:j,rowIndex:H}),onRowDoubleClick:E?z=>E({row:z,id:j,rowIndex:H}):void 0,onSelectionChange:P,tabIndex:H===de?0:-1,onToggleExpansion:q,onFocus:z=>ne(X(t[z]))},j)})}),l&&F&&s.jsx(K,{page:d,pageSize:c.pageSize,rowCount:re,pageSizeOptions:u,onPageChange:Y=>O({...c,page:Y}),onPageSizeChange:Y=>O({...c,pageSize:Y,page:0}),localeText:N,...C})]})}function yd({overlay:e}){return e?s.jsx("div",{className:"ogx__loading-overlay ogx__loading-overlay--over-rows ogx__loading-overlay--custom",children:e}):s.jsx("div",{className:"ogx__loading-overlay ogx__loading-overlay--over-rows",children:s.jsx("div",{className:"ogx__loading-bar",role:"progressbar","aria-label":"Loading data"})})}function Ht(e){return e.headerName||e.field}function Cd(e){return e.nativeEvent.isComposing||e.keyCode===229}function Bt(e,t,o=!0){return n=>{if(Cd(n)){n.stopPropagation();return}o&&n.key==="Enter"&&(n.stopPropagation(),e()),n.key==="Escape"&&(n.stopPropagation(),t())}}function _d({value:e,colDef:t,onValueChange:o,onCommit:n,onCancel:r}){const[i,l]=a.useState(String(e??"")),c=a.useRef(null);return a.useEffect(()=>{c.current?.focus(),c.current?.select()},[]),s.jsx("input",{ref:c,type:"text",className:"ogx__edit-input","aria-label":Ht(t),value:i,onChange:d=>{l(d.target.value),o(d.target.value)},onBlur:n,onKeyDown:Bt(n,r)})}function Sd({value:e,colDef:t,onValueChange:o,onCommit:n,onCancel:r}){const[i,l]=a.useState(typeof e=="number"?e:""),c=a.useRef(null);return a.useEffect(()=>{c.current?.focus(),c.current?.select()},[]),s.jsx("input",{ref:c,type:"number",className:"ogx__edit-input ogx__edit-input--number","aria-label":Ht(t),value:i,onChange:d=>{const u=d.target.value===""?"":Number(d.target.value);l(u),o(u===""?null:u)},onBlur:n,onKeyDown:Bt(n,r)})}function kd({value:e,colDef:t,onValueChange:o,onCommit:n,onCancel:r}){const i=a.useRef(null);a.useEffect(()=>{i.current?.focus()},[]);const l=()=>{o(!e),n()};return s.jsx("div",{className:"ogx__edit-boolean",children:s.jsx("input",{ref:i,type:"checkbox",className:"ogx__edit-checkbox","aria-label":Ht(t),checked:!!e,onChange:l,onBlur:n,onKeyDown:Bt(n,r,!1)})})}const pn=e=>typeof e=="object"?e.value:e,Ed=e=>typeof e=="object"?e.label:String(e);function Md(e,t){return e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Object.is(e,t)}function Nd({value:e,colDef:t,onValueChange:o,onCommit:n,onCancel:r}){const i=a.useRef(null);a.useEffect(()=>{i.current?.focus()},[]);const l=t.valueOptions??[],c=l.map(g=>String(pn(g)));let d=l.findIndex(g=>Md(pn(g),e));d===-1&&e!==null&&e!==void 0&&(d=c.indexOf(String(e)));const u=d===-1;return s.jsxs("select",{ref:i,className:"ogx__edit-select","aria-label":Ht(t),value:u?"":c[d],onChange:g=>{const m=c.indexOf(g.target.value);o(m===-1?null:pn(l[m]))},onBlur:n,onKeyDown:Bt(n,r),children:[u&&s.jsx("option",{value:""}),l.map((g,m)=>s.jsx("option",{value:c[m],children:Ed(g)},m))]})}const wi=e=>String(e).padStart(2,"0"),mi=/^(\d{4}-\d{2}-\d{2})/;function hn(e){if(e instanceof Date)return Number.isNaN(e.getTime())?"":`${e.getFullYear()}-${wi(e.getMonth()+1)}-${wi(e.getDate())}`;if(typeof e=="string"){const t=mi.exec(e);return t?t[1]:e===""?"":hn(new Date(e))}return typeof e=="number"?hn(new Date(e)):""}function Pd(e,t){if(e==="")return null;const[o,n,r]=e.split("-").map(Number),i=l=>{const c=new Date(l.getTime());return c.setFullYear(o,n-1,r),c};return t instanceof Date&&!Number.isNaN(t.getTime())?i(t):typeof t=="number"&&Number.isFinite(t)?i(new Date(t)).getTime():typeof t=="string"&&mi.test(t)&&t.length>10?e+t.slice(10):e}function Id({value:e,colDef:t,onValueChange:o,onCommit:n,onCancel:r}){const[i]=a.useState(e),[l,c]=a.useState(()=>hn(e)),d=a.useRef(null);return a.useEffect(()=>{d.current?.focus()},[]),s.jsx("input",{ref:d,type:"date",className:"ogx__edit-input","aria-label":Ht(t),value:l,onChange:u=>{c(u.target.value),o(Pd(u.target.value,i))},onBlur:n,onKeyDown:Bt(n,r)})}function Td(e){const{colDef:t}=e;switch(t.type){case"number":return s.jsx("div",{className:"ogx__edit-cell",children:s.jsx(Sd,{...e})});case"boolean":return s.jsx("div",{className:"ogx__edit-cell",children:s.jsx(kd,{...e})});case"singleSelect":return s.jsx("div",{className:"ogx__edit-cell",children:s.jsx(Nd,{...e})});case"date":return s.jsx("div",{className:"ogx__edit-cell",children:s.jsx(Id,{...e})});default:return s.jsx("div",{className:"ogx__edit-cell",children:s.jsx(_d,{...e})})}}function Fd(e){const{onCellClick:t,onCellEditStart:o,onCellValueChange:n,value:r,row:i,colDef:l,rowIndex:c,colIndex:d,ariaColIndex:u,isSelected:g,onClick:m,width:x,pinnedPosition:v,pinnedOffset:h,isPinnedEdge:f,isFocused:w,isFocusVisible:p,isEditable:b,isEditing:y,onEditStart:C,onEditStop:N,onValueChange:T,colSpanInfo:E,rowSpan:P,isHiddenByRowSpan:O,rowMeta:W,valueError:X}=e,S=a.useCallback(G=>{n?n(l.field,G):T?.(G)},[n,T,l.field]),M=W?.isGroupRow===!0,{formattedValue:I,error:_}=a.useMemo(()=>{if(l.valueFormatter&&!(M&&r==null))try{return{formattedValue:l.valueFormatter({value:r,row:i,field:l.field})}}catch(G){return{formattedValue:"",error:G??new Error("valueFormatter failed")}}return{formattedValue:Bo(r,l)}},[r,i,l,M]),F=a.useMemo(()=>{if(!l.cellClassName)return"";if(typeof l.cellClassName=="function")try{return l.cellClassName({value:r,formattedValue:I,row:i,field:l.field,colDef:l,rowIndex:c,colIndex:d,rowMeta:W})||""}catch{return""}return l.cellClassName},[l,r,I,i,c,d,W]),A=X??_,q=l.field,K=a.useCallback(()=>{N?.(!1,q)},[N,q]),J=a.useCallback(()=>{N?.(!0,q)},[N,q]),te=a.useMemo(()=>[i,l.renderCell,r],[i,l.renderCell,r]),ne=a.useRef(!1);if(a.useEffect(()=>{if(!(!y||!N))return ne.current=!0,()=>{ne.current=!1,queueMicrotask(()=>{ne.current||N(!1,q)})}},[y,N,q]),E?.spannedByColSpan)return null;const Z=E?.cellProps.colSpan??1,de=Z>1,ae=(de?E?.cellProps.width:void 0)??x??l.width??100,oe={width:"var(--width)","--width":typeof ae=="number"?`${ae}px`:ae,flexGrow:(de?E?.cellProps.flexGrow:void 0)??l.flex??0,flexShrink:0,flexBasis:"auto",boxSizing:"border-box",minWidth:de?void 0:l.minWidth,maxWidth:de?void 0:l.maxWidth};if(O)return s.jsx("div",{className:"ogx__cell ogx__cell--hidden",style:oe,role:"presentation","data-field":l.field,"data-colindex":d});const se=G=>{y||(t&&t({row:i,field:l.field,value:r,colDef:l,rowIndex:c,colIndex:d}),m?.(G))},re=()=>{y||!b||(o?o(l.field,r):C?.())},B=l.renderEditCell,D=v!=null,$=["ogx__cell",`ogx__cell--align-${l.align||"left"}`,g&&"ogx__cell--selected",w&&"ogx__cell--focused",w&&p&&"ogx__cell--focus-visible",l.type&&`ogx__cell--type-${l.type}`,D&&"ogx__cell--pinned",D&&`ogx__cell--pinned-${v}`,D&&f&&`ogx__cell--pinned-${v}-${v==="left"?"last":"first"}`,y&&"ogx__cell--editing",P&&P>1&&"ogx__cell--spanned",F].filter(Boolean).join(" "),R=P||1,U={...oe,position:D?"sticky":void 0,zIndex:l.zIndex??(D?3:void 0),padding:y?0:void 0};return R>1&&(U.height=`calc(var(--height) * ${R} - var(--border-width, 1px))`,U.zIndex=10,D&&(U.zIndex=40)),D&&h!==void 0&&(v==="left"?U.left=h:U.right=h),s.jsx("div",{className:$,style:U,onClick:se,onDoubleClick:re,role:"gridcell","aria-colindex":u??d+1,"aria-readonly":!b||void 0,tabIndex:-1,"data-field":l.field,"data-colindex":d,...Z>1?{"aria-colspan":Z}:{},...R>1?{"aria-rowspan":R}:{},children:s.jsx("div",{className:"ogx__cell-content",children:y&&(n||T)&&N?B?s.jsx(it,{field:l.field,resetKey:i,renderFn:()=>B({value:r,formattedValue:I,row:i,field:l.field,colDef:l,rowIndex:c,colIndex:d,rowMeta:W,onValueChange:S,onCommit:K,onCancel:J})}):s.jsx(Td,{value:r,formattedValue:I,row:i,field:l.field,colDef:l,rowIndex:c,colIndex:d,rowMeta:W,onValueChange:S,onCommit:K,onCancel:J}):A!==void 0?s.jsx(it,{field:l.field,resetKey:i,renderFn:()=>{throw A}}):l.renderCell?s.jsx(it,{field:l.field,resetKey:te,renderFn:()=>l.renderCell({value:r,formattedValue:I,row:i,field:l.field,colDef:l,rowIndex:c,colIndex:d,rowMeta:W})}):l.type==="image"&&typeof r=="string"&&r!==""?s.jsx("img",{className:"ogx__cell-image",src:r,alt:l.headerName??l.field,loading:"lazy"}):I})})}const xi=a.memo(Fd),Ld=({className:e="",...t})=>s.jsx("button",{type:"button",className:`ogx-drag-handle ${e}`,"aria-label":"Drag to reorder row",...t,children:s.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"currentColor","aria-hidden":"true",children:s.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 Od(e){const{rowId:t,content:o,height:n,isExpanded:r,onHeightChange:i,id:l,colSpan:c}=e,d=a.useRef(null),u=n==="auto";if(a.useLayoutEffect(()=>{const m=d.current;if(!m||!u||!r||!i)return;const x=()=>{m.getClientRects().length!==0&&i(t,m.offsetHeight)};if(x(),typeof ResizeObserver>"u")return;const v=new ResizeObserver(x);return v.observe(m),()=>v.disconnect()},[u,r,i,t]),!r)return null;const g={height:u?"auto":`${n}px`,overflow:u?"visible":"auto"};return s.jsx("div",{ref:d,className:"ogx__detail-panel",style:g,role:"row",id:l,children:s.jsx("div",{className:"ogx__detail-panel-content",role:"gridcell","aria-colspan":c,children:o})})}const wn=12;function Dd(e,t,o,n){let r=0,i=0,l=0;for(let c=t;c<e.length&&l<o;c++){const d=e[c];if(d.isSpacer)break;r+=ot(d,n),i+=d.flex??0,l++}return{spannedByColSpan:!1,cellProps:{colSpan:l,width:r,flexGrow:i}}}function mo(e){const{row:t,rowId:o,columns:n,rowIndex:r,isSelected:i=!1,checkboxSelection:l=!1,onRowClick:c,onRowDoubleClick:d,onCellClick:u,onSelectionChange:g,columnWidths:m={},pinnedColumns:x,pinnedRows:v,hasDetailPanel:h=!1,isDetailPanelExpanded:f=!1,onDetailPanelToggle:w,detailPanelContent:p,detailPanelHeight:b=Vo,onDetailPanelHeightChange:y,pinCheckboxColumn:C=!0,pinExpandColumn:N=!0,rowReordering:T=!1,onDragStart:E,onDragOver:P,onDragEnd:O,onDrop:W,isDragging:X,isDragOver:S,editingCell:M,onEditStart:I,onEditStop:_,onEditCellValueChange:F,isCellEditable:A,focusedCellField:q,isFocusVisible:K,colspanMap:J,rowSpanningCaches:te,rowHeight:ne=52,rowMeta:Z,columnIndexMap:de,ariaRowIndex:ae}=e,oe=o??t.id,se=a.useId(),re=a.useId(),B=a.useMemo(()=>Go(n,m,x,l,C,h,N,T),[n,m,x,l,C,h,N,T]),D=a.useMemo(()=>Wo(n,x),[n,x]),$=Z?.hasChildren===!0,R=Z?.isGroupRow===!0,U=h&&!R,G=!R&&!qe(oe),V=a.useCallback((le,ye)=>{I?.({id:oe,field:le,value:ye})},[oe,I]),Y=a.useCallback((le,ye)=>{F?.({id:oe,field:le,value:ye})},[F,oe]),H=a.useCallback((le,ye)=>{_?.({cancel:le,id:oe,field:ye})},[_,oe]);if(t._isSkeleton){const le=Math.max(n.length,5);return s.jsx("div",{className:"ogx__row ogx__row--skeleton",role:"row","aria-hidden":"true",style:{height:ne,minHeight:ne},children:Array.from({length:le}).map((ye,Te)=>s.jsx("div",{className:"ogx__skeleton-cell",children:s.jsx("div",{className:"ogx__skeleton-bar"})},Te))})}const j=le=>{le.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell, .ogx__cell--editing")||c?.({row:t,id:oe,rowIndex:r})},z=le=>{le.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell, .ogx__cell--editing")||d?.({row:t,id:oe,rowIndex:r})},k=le=>{le.stopPropagation(),g?.(oe,le.target.checked)},L=le=>{le.stopPropagation(),w?.(oe)},Q=T?1:0,ee=h?Q+1:Q,ce=l?ee+1:ee,ue=ce,he=de?.size??n.filter(le=>!le.isSpacer).length,be=Z!==void 0,Ce=Z?.hasChildren===!0,fe=zn(oe,v),me=fe==="top",ve=fe==="bottom",Se=["ogx__row",i&&"ogx__row--selected",r%2===0&&"ogx__row--even",r%2===1&&"ogx__row--odd",me&&"ogx__row--pinned-top",ve&&"ogx__row--pinned-bottom",X&&"ogx__row--dragging",S&&"ogx__row--drag-over",$&&"ogx__row--group",Z?.isGroupFooter&&"ogx__row--group-footer"].filter(Boolean).join(" ");return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:Se,onClick:j,onDoubleClick:d?z:void 0,role:"row","aria-rowindex":ae??r+2,"aria-selected":i,"aria-level":be?(Z?.treeDepth??0)+1:void 0,"aria-expanded":Ce?Z?.isExpanded===!0:void 0,"data-rowindex":r,onDragOver:P?P(oe):void 0,onDrop:W?W(oe):void 0,style:{maxHeight:`${ne}px`,minHeight:`${ne}px`,"--height":`${ne}px`,"--border-width":"1px"},children:[T&&s.jsx("div",{className:`ogx__cell ogx__cell--drag-handle ${q==="__reorder_col__"?"ogx__cell--focused":""} ${q==="__reorder_col__"&&K?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":E?"Drag to reorder row":void 0,"aria-colindex":Q,"data-field":"__reorder_col__",tabIndex:-1,style:{position:"sticky",left:0,zIndex:wn},draggable:!!E,onDragStart:E?E(oe):void 0,onDragEnd:O,onClick:le=>le.stopPropagation(),children:E&&s.jsx(Ld,{})}),h&&s.jsx("div",{className:`ogx__cell ogx__cell--expand ${N?"ogx__cell--pinned-left":""} ${q==="__expand_col__"?"ogx__cell--focused":""} ${q==="__expand_col__"&&K?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":U?f?"Collapse row details":"Expand row details":void 0,"aria-expanded":U?f:void 0,"aria-controls":U&&f?re:void 0,"aria-colindex":ee,"data-field":"__expand_col__",style:{position:N?"sticky":void 0,left:N?T?48:0:void 0,zIndex:N?wn:void 0},tabIndex:-1,onClick:le=>{le.stopPropagation(),u?.({row:t,field:"__expand_col__",value:f,colDef:{field:"__expand_col__",width:48},rowIndex:r,colIndex:-1})},children:U&&s.jsx(an,{isExpanded:f,onClick:L,variant:"plus-minus",tabIndex:-1})}),l&&s.jsx("div",{className:`ogx__cell ogx__cell--checkbox ${C?"ogx__cell--pinned-left":""} ${q==="__checkbox_col__"?"ogx__cell--focused":""} ${q==="__checkbox_col__"&&K?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-colindex":ce,"data-field":"__checkbox_col__",style:{position:C?"sticky":void 0,left:C?(T?48:0)+(h&&N?48:0):void 0,zIndex:C?wn:void 0},tabIndex:-1,onClick:le=>{le.stopPropagation(),u?.({row:t,field:"__checkbox_col__",value:i,colDef:{field:"__checkbox_col__",width:48},rowIndex:r,colIndex:-1})},children:G&&s.jsx(Gt,{id:se,name:`ogx-select-row-${oe}`,checked:i,onChange:k,onClick:le=>le.stopPropagation(),"aria-label":i?`Deselect row ${oe}`:`Select row ${oe}`,tabIndex:-1,onMouseDown:le=>le.preventDefault()})}),n.map((le,ye)=>{if(le.isSpacer)return s.jsx("div",{style:{width:le.width,minWidth:le.width,flexShrink:0},"aria-hidden":"true"},le.field);let Te,xe;R?Te=t[le.field]:{value:Te,error:xe}=Un(t,le.field,le);const Ee=de?.get(le.field)??ye,ie=m[le.field]??le.width,ge=Xe(le.field,x),we=!!I&&Jn({row:t,field:le.field,value:Te,colDef:le,rowIndex:r,colIndex:Ee,rowMeta:Z},A),Me=M?.id===oe&&M?.field===le.field,Pe=Me?M?.value:Te,De=J?.get(oe)?.[le.field],Qe=De&&!De.spannedByColSpan&&De.cellProps.colSpan>1?Dd(n,Ee,De.cellProps.colSpan,m):De,qt=Qe&&!Qe.spannedByColSpan?n[Ee+Qe.cellProps.colSpan-1]?.field??le.field:le.field,_o=ge==="right"?qt:le.field,$e=ge?B[_o]:void 0,So=ge==="left"&&qt===D.lastLeft||ge==="right"&&le.field===D.firstRight,Be=te?.spannedCells[oe]?.[le.field],ko=te?.hiddenCells[oe]?.[le.field]||!1;return s.jsx(xi,{value:Pe,row:t,colDef:le,rowIndex:r,colIndex:Ee,ariaColIndex:ue+Ee+1,isSelected:i,onCellClick:u,width:ie,pinnedPosition:ge,pinnedOffset:$e,isPinnedEdge:So,isFocused:q===le.field,isFocusVisible:K,isEditable:we,isEditing:Me,onCellEditStart:V,onEditStop:H,onCellValueChange:Y,colSpanInfo:Qe,rowSpan:Be,isHiddenByRowSpan:ko,rowMeta:Z,valueError:xe},le.field)})]}),U&&s.jsx(Od,{id:re,colSpan:ue+he,row:t,rowId:oe,rowIndex:r,content:p,height:b,isExpanded:f,onHeightChange:y})]})}function bi({getContent:e,params:t}){return s.jsx(it,{field:"detail panel",renderFn:()=>e(t),resetKey:t.row})}const Ad=e=>e.id;function vi({rows:e,position:t,columns:o,selectedRowIds:n,checkboxSelection:r,onRowClick:i,onRowDoubleClick:l,onCellClick:c,onSelectionChange:d,columnWidths:u,pinnedColumns:g,pinnedRows:m,hasDetailPanel:x,expandedRowIds:v,getDetailPanelContent:h,getDetailPanelHeight:f,onDetailPanelToggle:w,onDetailPanelHeightChange:p,pinCheckboxColumn:b,pinExpandColumn:y,focusedCell:C,colspanMap:N,rowSpanningCaches:T,rowHeight:E,rowMetaMap:P,getRowId:O=Ad,rowIndexOffset:W=0,ariaRowIndexBase:X,columnIndexMap:S,editingHandlers:M,isCellEditable:I,rowReordering:_=!1}){return e.length===0?null:s.jsx("div",{className:`ogx__pinned-rows ogx__pinned-rows--${t}`,role:"rowgroup",children:e.map((F,A)=>{const q=O(F),K=W+A;return s.jsx(mo,{row:F,rowId:q,columns:o,rowIndex:K,ariaRowIndex:X!==void 0?X+A:void 0,columnIndexMap:S,isSelected:n.has(q),checkboxSelection:r,onRowClick:i,onRowDoubleClick:l,onCellClick:c,onSelectionChange:d,columnWidths:u,pinnedColumns:g,pinnedRows:m,hasDetailPanel:x,isDetailPanelExpanded:v.has(q),detailPanelContent:v.has(q)&&h?s.jsx(bi,{getContent:h,params:{row:F,id:q,rowIndex:K}}):null,detailPanelHeight:v.has(q)?zo(Ko(f,{row:F,id:q,rowIndex:K})):void 0,onDetailPanelHeightChange:p,onDetailPanelToggle:w,pinCheckboxColumn:b,pinExpandColumn:y,focusedCellField:C?.id===q?C.field:null,colspanMap:N,rowSpanningCaches:T,rowHeight:E,rowMeta:P.get(q),editingCell:M?.editingCell,onEditStart:M?.startCellEdit,onEditStop:M?.stopCellEdit,onEditCellValueChange:M?.setEditCellValue,isCellEditable:I,rowReordering:_},q)})})}const $d=({columns:e,rowHeight:t,checkboxSelection:o=!1,hasDetailPanel:n=!1,rowReordering:r=!1})=>s.jsxs("div",{className:"ogx__row ogx__skeleton-row",style:{height:t},role:"row",children:[o&&s.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:s.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),n&&s.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:s.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),r&&s.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:s.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),e.map((i,l)=>{const c=typeof i.width=="number"?i.width:150,d=Math.min(c*.7,c-20);return s.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:c,minWidth:i.minWidth,maxWidth:i.maxWidth,left:i.left,right:i.right,position:i.isSpacer?"relative":i.pinned?"sticky":"relative",zIndex:i.zIndex},children:!i.isSpacer&&s.jsx("div",{className:"ogx-skeleton-box",style:{width:d,height:16,borderRadius:4}})},i.field||l)})]});function Gd({virtualContainerHeight:e,offsetTop:t,effectiveLoading:o,visibleRows:n,baseColumns:r,virtualColumns:i,viewportWidth:l,checkboxSelection:c,hasDetailPanel:d,rowReordering:u,rowHeight:g,selectedRowIds:m,onRowClick:x,onRowDoubleClick:v,onCellClick:h,onSelectionChange:f,columnWidths:w,pinnedColumns:p,expandedRowIds:b,getDetailPanelContent:y,getDetailPanelHeight:C,onDetailPanelToggle:N,onDetailPanelHeightChange:T,pinCheckboxColumn:E,pinExpandColumn:P,rowReorderHandlers:O,editingHandlers:W,isCellEditable:X,focusedCell:S,colspanMap:M,rowSpanningCaches:I,paginationMode:_,dataSourceLoading:F,sortedUnpinnedRowCount:A,infiniteScrollSkeletonCount:q,unpinnedRowsLength:K,lastRenderedRowIndex:J,rowMetaMap:te,loadingOverlay:ne,ariaRowIndexOffset:Z,columnIndexMap:de}){const ae=r.length>0?r:(()=>{const re=(l||1e3)-(c?48:0)-(d?48:0)-(u?48:0),B=150,D=Math.max(1,Math.ceil(re/B));return Array.from({length:D},($,R)=>({field:`placeholder_${R}`,headerName:"",width:B}))})(),oe=n.filter(re=>!re.pinned),se=_==="infinite"&&F&&A>0&&J>=K-1;return s.jsx("div",{className:"ogx__virtual-container",style:{height:`${e}px`},role:"presentation",children:s.jsxs("div",{className:"ogx__rows",style:{transform:`translateY(${t}px)`},role:"rowgroup",children:[o&&n.length===0&&ne?s.jsx("div",{className:"ogx__loading-overlay",style:{width:l||void 0},children:ne}):o&&n.length===0?Array.from({length:10}).map((re,B)=>s.jsx($d,{columns:ae,rowHeight:g,checkboxSelection:c,hasDetailPanel:d,rowReordering:u},`skeleton-${B}`)):oe.map(({row:re,id:B,rowIndex:D})=>s.jsx(mo,{row:re,rowId:B,columns:i,rowIndex:D,ariaRowIndex:Z!==void 0?D+Z:void 0,columnIndexMap:de,isSelected:m.has(B),checkboxSelection:c,onRowClick:x,onRowDoubleClick:v,onCellClick:h,onSelectionChange:f,columnWidths:w,pinnedColumns:p,hasDetailPanel:d,isDetailPanelExpanded:b.has(B),detailPanelContent:b.has(B)&&y?s.jsx(bi,{getContent:y,params:{row:re,id:B,rowIndex:D}}):null,detailPanelHeight:b.has(B)?zo(Ko(C,{row:re,id:B,rowIndex:D})):void 0,onDetailPanelHeightChange:T,onDetailPanelToggle:N,pinCheckboxColumn:E,pinExpandColumn:P,rowReordering:u,onDragStart:O.canReorderRow(B)?O.onDragStart:void 0,onDragOver:O.onDragOver,onDragEnd:O.onDragEnd,onDrop:O.onDrop,isDragging:O.draggedRowId===B,isDragOver:O.dragOverRowId===B,editingCell:W.editingCell,onEditStart:W.startCellEdit,onEditStop:W.stopCellEdit,onEditCellValueChange:W.setEditCellValue,isCellEditable:X,focusedCellField:S!=null&&S.id===B?S.field:null,colspanMap:M,rowSpanningCaches:I,rowHeight:g,rowMeta:te.get(B)},B)),se&&s.jsx("div",{className:"ogx__skeleton-group",children:Array.from({length:q}).map((re,B)=>s.jsx(mo,{row:{id:`__skeleton_${B}__`,_isSkeleton:!0},columns:i,rowIndex:K+B,rowHeight:g},`__skeleton_${B}__`))})]})})}function Wd(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function Hd(){return s.jsxs("svg",{className:"ogx-column-visibility-panel__drag-handle",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[s.jsx("circle",{cx:"9",cy:"5",r:"1.5"}),s.jsx("circle",{cx:"15",cy:"5",r:"1.5"}),s.jsx("circle",{cx:"9",cy:"12",r:"1.5"}),s.jsx("circle",{cx:"15",cy:"12",r:"1.5"}),s.jsx("circle",{cx:"9",cy:"19",r:"1.5"}),s.jsx("circle",{cx:"15",cy:"19",r:"1.5"})]})}function mn(e){const{columns:t,visibleColumns:o,onVisibilityChange:n,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:c,showNonHideableColumns:d}=e,[u,g]=a.useState(""),m=a.useId(),[x,v]=a.useState(null),h=a.useRef(null),f=a.useMemo(()=>t.filter(P=>P.hideable!==!1),[t]),w=f.every(P=>o.has(P.field)),p=a.useMemo(()=>{const P=d?t:f;if(!u)return P;const O=u.toLowerCase();return P.filter(W=>(W.headerName||W.field).toLowerCase().includes(O))},[t,f,u,d]),b=P=>{P.target.checked?r():i()},y=P=>O=>{h.current=P,O.dataTransfer.effectAllowed="move",O.dataTransfer.setDragImage(O.currentTarget.closest(".ogx-column-visibility-panel__item"),20,20)},C=P=>O=>{O.preventDefault(),O.dataTransfer.dropEffect="move",P!==h.current&&v(P)},N=()=>{v(null)},T=P=>O=>{O.preventDefault();const W=h.current;v(null),h.current=null,W&&W!==P&&l&&l(W,P)},E=()=>{v(null),h.current=null};return s.jsxs("div",{className:"ogx-column-visibility-panel",children:[s.jsx("div",{className:"ogx-column-visibility-panel__search-section",children:s.jsxs("div",{className:"ogx-column-visibility-panel__search-container",children:[s.jsx(Wd,{}),s.jsx("input",{autoComplete:"off",className:"ogx-column-visibility-panel__search-input",placeholder:"Search",value:u,onChange:P=>g(P.target.value)})]})}),s.jsx("div",{className:"ogx-column-visibility-panel__list",children:p.map((P,O)=>{const W=`${m}-col-${O}`,X=o.has(P.field),S=P.hideable!==!1,M=x===P.field,I=!!l&&!u;return s.jsxs("div",{className:["ogx-column-visibility-panel__item",!S&&"ogx-column-visibility-panel__item--disabled",M&&"ogx-column-visibility-panel__item--drag-over"].filter(Boolean).join(" "),draggable:I,onDragOver:I?C(P.field):void 0,onDragLeave:I?N:void 0,onDrop:I?T(P.field):void 0,onDragEnd:I?E:void 0,children:[I&&s.jsx("span",{className:"ogx-column-visibility-panel__drag-handle-wrapper",draggable:!0,onDragStart:y(P.field),title:"Drag to reorder",children:s.jsx(Hd,{})}),s.jsxs("div",{className:"ogx-column-visibility-panel__item-label",style:{display:"flex",alignItems:"center",gap:"var(--ogx-spacing-md)",flex:1,cursor:S?"pointer":"not-allowed"},children:[s.jsx(Gt,{id:W,checked:X,onChange:_=>n(P.field,_.target.checked),disabled:!S}),s.jsx("label",{htmlFor:W,className:"ogx-column-visibility-panel__label",children:P.headerName||P.field})]})]},P.field)})}),s.jsxs("div",{className:"ogx-column-visibility-panel__footer",children:[s.jsxs("div",{className:"ogx-column-visibility-panel__item",children:[s.jsx(Gt,{id:`${m}-all`,checked:w,onChange:b}),s.jsx("label",{htmlFor:`${m}-all`,className:"ogx-column-visibility-panel__label",children:"Show/Hide All"})]}),s.jsx("button",{type:"button",className:"ogx-column-visibility-panel__reset-btn",onClick:()=>{r(),c?.()},children:"Reset"})]})]})}function Bd({isOpen:e,containerRef:t,panelRef:o,columns:n,columnVisibilityModel:r,disableColumnReorder:i,onClose:l,onColumnVisibilityChange:c,onColumnMove:d,onColumnOrderReset:u,columnGroupingModel:g}){const[m,x]=a.useState(null);if(a.useLayoutEffect(()=>{if(!e||!t.current)return;const h=t.current.getBoundingClientRect();x({top:h.top+8,right:xt()-h.right+8,target:t.current.closest(".ogx-theme-provider")||document.body})},[e,t]),!e||!m)return null;const v=i?void 0:(h,f)=>{un(g,h,f)&&d(h,f)};return tt.createPortal(s.jsxs("div",{ref:o,style:{position:"fixed",top:m.top,right:m.right,zIndex:9999,display:"inline-block"},children:[s.jsx("button",{type:"button",onClick:l,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:"×"}),s.jsx(mn,{columns:n,visibleColumns:new Set(n.filter(h=>r[h.field]!==!1).map(h=>h.field)),onVisibilityChange:(h,f)=>{c({...r,[h]:f})},onShowAll:()=>{const h={...r};n.forEach(f=>{f.hideable!==!1&&(h[f.field]=!0)}),c(h)},onHideAll:()=>{const h={...r};n.forEach(f=>{f.hideable!==!1&&(h[f.field]=!1)}),c(h)},onColumnReorder:v,onColumnOrderReset:i?void 0:u})]}),m.target)}const yi=[];function Vd(e){const{isPivotActive:t}=e,o=t?yi:e.rowGroupingModel,n=e.treeData&&!t,r=n&&e.hasTreeDataPath,i=o.length>0;return{rowReordering:e.rowReordering&&!t,hierarchyRowGroupingModel:o,isTreeDataRequested:n,isTreeData:r,isRowGrouping:i,isHierarchyEnabled:r||i,hasGroupingColumn:e.hasGroupingColDef&&(i||r),pagination:e.pagination&&!i&&e.paginationMode!=="infinite",listView:e.listView&&e.hasListViewColumn}}function zd(e){const{baseColumns:t,pinnedColumns:o,hasGroupingColumn:n,groupingColDef:r,isTreeData:i,getTreeDataPath:l}=e,c=a.useMemo(()=>n?{...o,left:["__group__",...(o?.left??[]).filter(u=>u!=="__group__")]}:o,[n,o]);return{activeColumns:a.useMemo(()=>n?[{headerName:"Group",width:220,...i&&l?{valueGetter:({row:u})=>{const g=l(u);return g[g.length-1]}}:{},...r,field:"__group__",hideable:!1,sortable:!1,filterable:!1,pinnable:!1,exportable:!1},...t]:t,[r,n,i,l,t]),effectivePinnedColumns:c}}function Kd(e){return e.id}function jd(e){const t=a.useCallback(r=>e.get(r)??r.id,[e]),o=a.useRef(t);a.useLayoutEffect(()=>{o.current=t});const n=a.useCallback(r=>o.current(r),[]);return{getRowIdOf:t,getRowIdOfInEvents:n}}function Ud(e,t){a.useLayoutEffect(()=>{e&&(e.current=t.current)},[e,t])}function Xd(e){const{hierarchyHandlers:t,pinnedTopRows:o,sortedUnpinnedRows:n,pinnedBottomRows:r,rowMetaMap:i,getRowId:l,hierarchyField:c,dataRows:d}=e,u=t?.getVisibleRows({expandAll:!0,labelField:c});if(!u)return[...o,...n,...r];const g=d?new Set(d):null;return u.filter(m=>!i.get(l(m))?.isGroupRow&&(!g||g.has(m)))}function qd(e,t){if(e===t)return!0;const o=Object.keys(e);if(o.length!==Object.keys(t).length)return!1;const n=e,r=t;return o.every(i=>Object.prototype.hasOwnProperty.call(t,i)&&Object.is(n[i],r[i]))}function Yd(e,t){return e===t?!0:e.length!==t.length?!1:e.every((o,n)=>qd(o,t[n]))}function Rd(e){const[t,o]=a.useState(e),n=Yd(t,e);return n||o(e),n?t:e}function Jd(e){const{rows:t,getRowId:o,rowMetaMap:n,columns:r,aggregationModel:i,aggregationResult:l,isSubtotalHidden:c}=e,d=Object.keys(i).length>0,u=new Map(r.map(v=>[v.field,v])),g=[],m=[],x=v=>{for(;m.length>0&&m[m.length-1].header.depth>=v;){const h=m.pop();d&&!c?.(h.id)&&g.push({type:"group-subtotal",depth:h.header.depth,groupField:h.header.groupField,groupValue:h.header.groupValue,groupLabel:h.header.groupLabel,aggregatedValues:so(h.leaves,i,u,"getGroupedExportRows")})}};for(const v of t){const h=o(v),f=n.get(h);if(!f?.isGroupFooter)if(f?.isGroupRow){const w=f.treeDepth??0;x(w);const p={type:"group-header",depth:w,groupField:f.groupingField,groupValue:f.groupingValue,groupLabel:f.groupLabel};g.push(p),m.push({id:h,header:p,leaves:[]})}else g.push({type:"leaf",depth:f?.treeDepth??m.length,row:v}),m.forEach(w=>w.leaves.push(v))}return x(0),d&&l&&g.push({type:"grand-total",depth:0,aggregatedValues:l}),g}function Qd(e){const{apiRef:t}=e,o=a.useRef(e);a.useLayoutEffect(()=>{o.current=e}),a.useLayoutEffect(()=>{const n=()=>o.current;t.current.getAggregationResult=()=>n().hasAggregation?n().aggregationResult:null,t.current.getAggregationModel=()=>n().hasAggregation?n().aggregationModel:null,t.current.getGroupedExportRows=()=>{const{hasAggregation:r,aggregationResult:i,aggregationModel:l,isRowGrouping:c,rowGroupingHandlers:d,rowMetaMap:u,columns:g,getRowId:m,hierarchyField:x}=n();return c?Jd({rows:d.getVisibleRows({expandAll:!0,labelField:x})??[],getRowId:m,rowMetaMap:u,columns:g,aggregationModel:l,aggregationResult:r&&d.rootAggregationPosition!==null?i:null,isSubtotalHidden:v=>d.aggregationPositions.get(v)===null}):null}},[t])}const Zd=new Set(["__group__","__check__","__actions__"]);function st(e){return e.filter(t=>t.exportable!==!1&&!t.isSpacer&&!rt(t.field)&&!Zd.has(t.field))}function Re(e){return!!e&&e.length>0}function Ci(e,t,o=n=>n.id){const n=new Set(t);return e.filter(r=>n.has(o(r)))}function Vt(e,t,o){return Re(t)?Ci(e,t,o):e}function zt(e,t){return!!e&&e.length>0&&!Re(t)}function _t(e,t,o,n,r){if(!n)return null;if(!t||!r||Object.keys(r).length===0)return n;const i=new Map(o.map(l=>[l.field,l]));return so(e,r,i,"export")}function Kt(e,t){const o=e[t.field];return t.valueGetter?t.valueGetter({row:e,field:t.field,value:o}):o}function xo(e,t,o){if(!t.valueFormatter)return Bo(o,t);if(o==null)try{return String(t.valueFormatter({value:o,row:e,field:t.field})??"")}catch{return""}return String(t.valueFormatter({value:o,row:e,field:t.field})??"")}function xn(e,t,o,n){return o==null?"":ao(o,t??"",e,n)}function St(e,t){return t?`${e}: ${t}`:e}function _i(e,t){const o={};return t.forEach(n=>{Object.prototype.hasOwnProperty.call(e,n.field)&&(o[n.field]=e[n.field])}),o}const ec=/^[=+\-@\t\r]/,tc=/^[-+]?[\d.,\s]*\d[\d.,\s]*%?$/;function bo(e,t=!1){return t||!ec.test(e)||tc.test(e)?e:`'${e}`}function Je(e){return typeof e=="number"||typeof e=="bigint"||typeof e=="boolean"||e instanceof Date}function _e(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const oc=/[\\/?*:[\]]/g,Si=31;function bn(e,t=new Set){let o=String(e??"").replace(oc,"-").trim().replace(/^'+|'+$/g,"").trim();o||(o="Sheet"),o=o.slice(0,Si).trim();const n=i=>t.has(i.toLowerCase())||i.toLowerCase()==="history";let r=o;for(let i=2;n(r);i++){const l=` (${i})`;r=`${o.slice(0,Si-l.length).trim()}${l}`}return t.add(r.toLowerCase()),r}const nc=new Set([Ye,At,Dt]),rc=/[\t\n\r"]/;function ki(e){return rc.test(e)?`"${e.replace(/"/g,'""')}"`:e}function ic(e){return st(e).filter(t=>!nc.has(t.field))}function lc(e,t){const o=t.map(r=>ki(r.headerName||r.field)).join(" "),n=e.map(r=>t.map(i=>ki(xo(r,i,Le(r,i.field,i)))).join(" "));return[o,...n].join(`
4
+ `)}function Ei(e){if(typeof document.execCommand!="function")return!1;const t=document.activeElement instanceof HTMLElement?document.activeElement:null,o=document.getSelection(),n=[];if(o)for(let l=0;l<o.rangeCount;l++)n.push(o.getRangeAt(l));const r=document.createElement("textarea");r.value=e,r.setAttribute("readonly",""),r.setAttribute("aria-hidden","true"),r.style.cssText="position:fixed;top:-9999px;left:-9999px;opacity:0;",document.body.appendChild(r);let i=!1;try{r.focus({preventScroll:!0}),r.select(),i=document.execCommand("copy")}finally{document.body.removeChild(r),t&&t.isConnected&&t.focus({preventScroll:!0}),o&&(o.removeAllRanges(),n.forEach(l=>o.addRange(l)))}return i}async function sc(e){const t=typeof navigator<"u"?navigator.clipboard:void 0;if(t&&typeof t.writeText=="function")try{await t.writeText(e);return}catch(o){if(Ei(e))return;throw o}if(!Ei(e))throw new Error("Clipboard API not available and fallback failed.")}function ac(e){if(!(e.ctrlKey||e.metaKey)||e.altKey||e.shiftKey)return!1;const t=e.key??"";return t.toLowerCase()==="c"?!0:e.code==="KeyC"&&!/^[a-z]$/i.test(t)}function dc(e){const t=a.useRef(e);a.useLayoutEffect(()=>{t.current=e});const o=a.useCallback(async()=>{const{getSelectedRowIds:r,getColumns:i,getRows:l,getRowId:c}=t.current,d=new Set(r());if(d.size===0)return;const u=l().filter(m=>d.has(c(m)));if(u.length===0)return;const g=lc(u,ic(i()));await sc(g)},[]),n=!!e.disableKeyboardShortcut;return a.useEffect(()=>{if(n)return;const r=i=>{if(i.defaultPrevented||!ac(i))return;const l=document.activeElement,c=l?.tagName.toLowerCase(),d=l?.type;if(c==="input"&&d!=="checkbox"&&d!=="radio"||c==="textarea"||c==="select"||l?.isContentEditable)return;const{getRootElement:u}=t.current;if(u){const m=u();if(!m||!l||!m.contains(l))return}const g=window.getSelection();g&&!g.isCollapsed&&g.toString()!==""||o().catch(m=>{console.error("[OpenGridX] Failed to copy to clipboard:",m)})};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[o,n]),{copySelectedRows:o}}function cc(e){const{apiRef:t,columns:o,getRowId:n,containerRef:r,disableKeyboardShortcut:i}=e,l=a.useCallback(()=>r.current,[r]),{copySelectedRows:c}=dc({getSelectedRowIds:()=>t.current.getSelectedRows(),getColumns:()=>o,getRows:()=>t.current.getAllFilteredRows(),getRowId:n,getRootElement:l,disableKeyboardShortcut:i});a.useLayoutEffect(()=>{t.current.copySelectedRows=c},[c,t])}function uc(e){const{apiRef:t}=e,o=a.useRef(e);a.useLayoutEffect(()=>{o.current=e}),a.useLayoutEffect(()=>{t.current.scrollToIndexes=({rowIndex:n,colIndex:r})=>{const{viewportRef:i,layout:l,rowHeight:c}=o.current,d=i.current;if(d&&(n!==void 0&&n>=0&&Rn(d,n,l.cumulativeHeights,l.pinnedBottomHeight,c),r!==void 0&&r>=0)){const g=[...l.leftPinnedCols,...l.unpinnedColsWithWidth,...l.rightPinnedCols][r];if(!g)return;Dl(d,l.unpinnedColsWithWidth.findIndex(m=>m.field===g.field),l)}}},[t])}function fc(e){return a.useCallback(t=>{e.current?.classList.toggle("ogx--kb",t)},[e])}function gc(e){const{ensureGridFocus:t,setKeyboardMode:o,setFocusedCell:n,getRowId:r,onCellClick:i}=e,l=a.useCallback(d=>{t(),o(!1),n({id:r(d.row),field:d.field,rowIndex:d.rowIndex}),i?.(d)},[i,o,n,t,r]),c=a.useCallback(d=>{t(),n({id:null,field:d}),o(!1)},[t,n,o]);return{handleCellClick:l,handleHeaderClick:c}}function pc({paginationSlot:e,paginationSlotProps:t,page:o,paginationModel:n,rowCount:r,pageSizeOptions:i,onPaginationModelChange:l,localeText:c}){const d=e||gn;return s.jsx(d,{page:o,pageSize:n.pageSize,rowCount:r,pageSizeOptions:i,onPageChange:u=>l({...n,page:u}),onPageSizeChange:u=>l({...n,pageSize:u,page:0}),localeText:Nr(c),...t})}function hc({loading:e,error:t,noRowsLabel:o,filteredRowCount:n,dataRowCount:r,filterModel:i}){return s.jsxs("div",{className:"ogx-aria-live-status",role:"status","aria-live":"polite",children:[e?"Loading data...":"",t?`Error: ${Kr(t)}`:"",!e&&!t&&(n===0?o:i&&((i.quickFilterValues?.length||0)>0||(i.items?.length||0)>0)?`${r} ${r===1?"row":"rows"} found`:"")]})}function wc(e){const{headerRowCount:t,pinnedTopCount:o,pinnedBottomCount:n,pageRowCount:r,totalCenterRowCount:i,pageOffset:l}=e;return{rowCount:t+o+i+n,topBase:t+1,centerOffset:t+l+1,bottomBase:t+o+i+1,bottomRowIndexOffset:o+r}}function mc(e){const{columnGroupingModel:t,pinnedTopCount:o,pinnedBottomCount:n,pagination:r,paginationMode:i,paginationModel:l,paginationRowCount:c,paginatedUnpinnedRowCount:d,sortedUnpinnedRowCount:u}=e,{page:g,pageSize:m}=l;return a.useMemo(()=>wc({headerRowCount:1+jr(t),pinnedTopCount:o,pinnedBottomCount:n,pageRowCount:r?d:u,totalCenterRowCount:r&&i==="server"?Math.max(c,d):u,pageOffset:r?g*m:0}),[t,o,n,r,d,u,i,c,g,m])}function xc(e){const{toolbar:t,toolbarSlotProps:o,apiRef:n,orderedColumns:r,baseColumns:i,aggregationModel:l,onAggregationModelChange:c,pivotMode:d,pivotModelProp:u,onPivotModelChangeProp:g,pivotModel:m,onPivotModelChange:x,filterModel:v,onFilterModelChange:h,columnVisibilityModel:f,onColumnVisibilityModelChange:w,disableColumnReorder:p,columnGroupingModel:b,moveColumn:y,resetColumnOrder:C,forceColumnsOpen:N,onColumnsPanelClose:T}=e;return a.useMemo(()=>t?{apiRef:n,columns:r,baseColumns:i,aggregationModel:l,onAggregationModelChange:c,...d||u||g?{pivotModel:m,onPivotModelChange:x}:{},filterModel:v,onFilterModelChange:h,columnVisibilityModel:f,onColumnVisibilityModelChange:w,onColumnReorder:p?void 0:(P,O)=>{un(b,P,O)&&y(P,O)},onColumnOrderReset:p?void 0:C,forceColumnsOpen:N,onColumnsPanelClose:T,...o}:null,[t,p,y,C,r,n,i,l,c,d,u,g,m,x,v,h,f,w,N,T,o,b])}function bc(e){const{rows:t,columns:o,getRowId:n,rowHeight:r,headerHeight:i,autoHeight:l=!1,density:c,checkboxSelection:d=!1,disableRowSelectionOnClick:u=!1,disableMultipleRowSelection:g=!1,disableClipboardCopy:m=!1,rowSelectionModel:x,onRowSelectionModelChange:v,onRowClick:h,onRowDoubleClick:f,onCellClick:w,filterModel:p,onFilterModelChange:b,sortModel:y,onSortModelChange:C,pagination:N=!1,paginationModel:T,onPaginationModelChange:E,pageSizeOptions:P=[10,25,50,100],pinnedColumns:O,onPinnedColumnsChange:W,pinnedRows:X,getDetailPanelContent:S,getDetailPanelHeight:M,detailPanelExpandedRowIds:I,onDetailPanelExpandedRowIdsChange:_,pinCheckboxColumn:F=!0,pinExpandColumn:A=!0,disableColumnReorder:q=!1,columnOrder:K,onColumnOrderChange:J,onColumnOrderModelChange:te,height:ne,rowReordering:Z=!1,onRowOrderChange:de,loading:ae=!1,treeData:oe=!1,getTreeDataPath:se,defaultGroupingExpansionDepth:re,groupingColDef:B,rowGroupingModel:D,aggregationModel:$,onAggregationModelChange:R,getAggregationPosition:U,isCellEditable:G,processRowUpdate:V,onProcessRowUpdateError:Y,dataSource:H,multiSort:j=!1,sortingMode:z="client",filterMode:k="client",paginationMode:L="client",rowCount:Q,slots:ee,slotProps:ce,pivotMode:ue=!1,pivotModel:he,onPivotModelChange:be,className:Ce="",style:fe,onRowsScrollEnd:me,ariaLabel:ve,initialState:Se,onStateChange:le,columnVisibilityModel:ye,onColumnVisibilityModelChange:Te,listView:xe=!1,listViewColumn:Ee,columnGroupingModel:ie,noRowsLabel:ge="No Data",localeText:we,apiRef:Me,overscanRowCount:Pe=3}=e,De=Rd(o),Qe=we?.noRowsLabel??ge,qt=D||yi,_o=ws({initialState:Se,sortModel:y,onSortModelChange:C,filterModel:p,onFilterModelChange:b,aggregationModel:$,onAggregationModelChange:R,columnVisibilityModel:ye,onColumnVisibilityModelChange:Te,pinnedColumns:O,onPinnedColumnsChange:W,pivotModel:he,onPivotModelChange:be,paginationModel:T,onPaginationModelChange:E,pageSizeOptions:P,rowSelectionModel:x,onRowSelectionModelChange:v,density:c}),{sortModel:$e,handleSortModelChange:So,filterModel:Be,handleFilterModelChange:ko,aggregationModel:Ge,handleAggregationModelChange:Lu,columnVisibilityModel:at,handleColumnVisibilityModelChange:Cn,pinnedColumns:_n,handlePinnedColumnsChange:Ou,currentPivotModel:Zi,handlePivotModelChange:Du,effectivePaginationModel:Ae,handlePaginationModelChange:Nt,selectedRowIds:Au,handleRowSelectionModelChange:Sn,density:el}=_o,Yt=wd({rows:t,columns:De,pivotMode:ue,pivotModel:Zi,filterModel:Be,sortModel:$e,hasDataSource:!!H,hierarchyRequested:oe||qt.length>0}),dt=Yt.isActive,{rowReordering:ct,hierarchyRowGroupingModel:$u,isTreeDataRequested:Gu,isTreeData:Eo,isRowGrouping:Pt,isHierarchyEnabled:Mo,hasGroupingColumn:Wu,pagination:Ve,listView:No}=Vd({rowGroupingModel:qt,treeData:oe,hasTreeDataPath:!!se,isPivotActive:dt,rowReordering:Z,hasGroupingColDef:!!B,pagination:N,paginationMode:L,listView:xe,hasListViewColumn:!!Ee}),{rowHeight:Ze,headerHeight:tl}=ys({rowHeight:r,headerHeight:i,density:el}),Hu=Yt.rows,Bu=Yt.columns,{activeColumns:ut,effectivePinnedColumns:Rt}=zd({baseColumns:Bu,pinnedColumns:_n,hasGroupingColumn:Wu,groupingColDef:B,isTreeData:Eo,getTreeDataPath:se}),kn=oa(ut,at),[Vu,zu]=gd(Ge),Jt=a.useRef(null),En=a.useRef(null),ol=!dt&&n||Kd,Mn=fc(Jt),Nn=La({rows:Hu,getRowId:ol,columns:ut,rowHeight:Ze,headerHeight:tl,columnVisibilityModel:at,initialState:e.initialState,syncRows:!H}),{state:ke,apiRef:Qt,setRows:Ku,replaceRow:ju,setColumns:Uu,setDimensions:Xu,setDataSourceLoading:qu,setDataSourceError:Yu,setRowCount:Ru}=Nn,{getRowIdOf:Ne,getRowIdOfInEvents:Ju}=jd(ke.rows.idByRow);Ud(Me,Qt);const Qu=ke.dataSource.loading,et=ae||Qu,Po=a.useMemo(()=>ke.rows.allRows.map(pt=>ke.rows.idRowsLookup.get(pt)),[ke.rows]),{treeDataHandlers:Io,rowGroupingHandlers:Pn,activeHierarchyHandlers:It,rowMetaMap:ze}=Ra({rows:Po,getRowId:Ne,getTreeDataPath:se,isTreeDataRequested:Gu,isTreeData:Eo,columns:ut,rowGroupingModel:$u,isRowGrouping:Pt,aggregationModel:Ge,defaultGroupingExpansionDepth:re,filterModel:Be,sortModel:$e,getAggregationPosition:U,columnLookup:kn,filterMode:k,sortingMode:z}),nl=Qa({rows:Po,getRowId:Ne,columns:ut,processRowUpdate:V,onProcessRowUpdateError:Y,onRowChange:(pt,Nf)=>{ju(Nf,pt)}}),Zt=Qs({selectedRowIds:Au,rowsLookup:ke.rows.idRowsLookup,rowMetaMap:ze,enabled:!H&&!dt&&L==="client"&&k==="client",onSelectionModelChange:Sn}),rl=cd({dataSource:H,sortModel:$e,filterModel:Be,paginationModel:Ae,paginationMode:L,sortingMode:z,filterMode:k,aggregationModel:Ge,rowGroupingActive:Pt,getRowId:ol,setRows:Ku,setRowCount:Ru,setDataSourceLoading:qu,setDataSourceError:Yu,onAggregationResults:zu,onPaginationModelChange:Nt});fd({enabled:Eo&&!!H,treeNodes:Io.treeNodes,isGroupExpanded:Io.isGroupExpanded,getNodePath:Io.getNodePath,toggleExpansion:Io.toggleExpansion,fetchChildren:rl.fetchChildren});const{hasDetailPanel:ft,expandedRowIds:In,handleDetailPanelToggle:il,detailPanelHeights:Zu,reportDetailPanelHeight:ef}=Hs({hasDetailPanel:!!S,controlledExpandedRowIds:I,onDetailPanelExpandedRowIdsChange:_,rowMetaMap:ze}),{effectiveColumns:ll,hierarchyField:Tn,orderedColumns:sl,visibleOrderedColumns:al,renderOrderedColumns:tf,navigationColumns:dl,columnIndexMap:cl,columnWidths:eo,effectiveColumnOrder:of,columnReorderHandlers:nf,moveColumn:ul,resetColumnOrder:fl,handleColumnResize:rf}=Ts({activeColumns:ut,isHierarchyEnabled:Mo,isRowGrouping:Pt,isTreeData:Eo,activeHierarchyHandlers:It,columnVisibilityModel:at,columnOrder:K,onColumnOrderChange:J,onColumnOrderModelChange:te,disableColumnReorder:q,pivotMode:dt,checkboxSelection:d,hasDetailPanel:ft,rowReordering:ct,initialState:Se,setColumns:Uu,pinnedColumns:Rt,getRowId:Ju,aggregationModel:Ge,groupingRows:Pt?Pn.groupingRows:void 0});zs({onStateChange:le,sortModel:$e,filterModel:Be,effectivePaginationModel:Ae,columnWidths:eo,effectiveColumnOrder:of,columnVisibilityModel:at,pinnedColumns:_n,density:el});const To=_s({effectiveRows:Po,activeHierarchyHandlers:It,filterMode:k,filterModel:Yt.pipelineFilterModel,sortModel:Yt.pipelineSortModel,sortingMode:z,pagination:Ve,paginationMode:L,effectivePaginationModel:Ae,pinnedRows:X,getRowId:Ne,columnLookup:kn,hierarchyField:Tn}),{filteredRows:gl,dataRows:Tt,pinnedTopRows:We,pinnedBottomRows:Ke,sortedUnpinnedRows:Ue,paginatedUnpinnedRows:Fo,allRenderableRows:Fn}=To,Ln=Ve?Fo:Ue;na({paginationModel:Ae,currentPage:To.currentPage,enabled:Ve&&!et&&Ue.length>0,onPaginationModelChange:Nt});const Lo=Cs({paginationMode:L,hasDataSource:!!H,dataSourceRowCount:ke.pagination.rowCount,rowCountProp:Q,clientRowCount:Ue.length}),{rowSelection:On,handleRowClick:Dn,handleSelectionChange:An}=Js({dataRows:Tt,getRowId:Ne,isPivotActive:dt,selectedRowIds:Zt,onSelectionModelChange:Sn,disableMultipleRowSelection:g,disableRowSelectionOnClick:u,isHierarchyEnabled:Mo,rowMetaMap:ze,activeHierarchyHandlers:It,onRowClick:h});ta({apiRef:Nn.apiRef,sortModel:$e,multiSort:j,onSortModelChange:So,filterModel:Be,onFilterModelChange:ko,paginationModel:Ae,onPaginationModelChange:Nt,selectedRowIds:Zt,getPendingRowSelectionModel:_o.getPendingRowSelectionModel,onRowSelectionModelChange:Sn,disableMultipleRowSelection:g,isSyntheticRowId:pt=>qe(pt,ze),getVisibleRows:()=>[...We,...Ln,...Ke],getAllFilteredRows:()=>Xd({hierarchyHandlers:It,pinnedTopRows:We,sortedUnpinnedRows:Ue,pinnedBottomRows:Ke,rowMetaMap:ze,getRowId:Ne,hierarchyField:Tn,dataRows:Tt}),visibleColumns:tf});const lf=Oa({rows:Po,getRowId:Ne,onRowOrderChange:de,rowReordering:ct}),{aggregationResult:$n,isLoading:sf}=hi({rows:Tt,columns:ut,aggregationModel:dt?Al:Ge,isServerSide:Vr({dataSource:H,paginationMode:L,sortingMode:z,filterMode:k}),dataSource:H,filterModel:Be,sortModel:$e,serverAggregationResults:Vu}),Gn=Object.keys(Ge).length>0&&!dt;Qd({apiRef:Qt,hasAggregation:Gn,aggregationResult:$n,aggregationModel:Ge,isRowGrouping:Pt,rowGroupingHandlers:Pn,rowMetaMap:ze,columns:ut,getRowId:Ne,hierarchyField:Tn});const Ie=Ll({rowHeight:Ze,pagination:Ve,paginatedUnpinnedRows:Fo,sortedUnpinnedRows:Ue,expandedRowIds:In,getDetailPanelHeight:M,detailPanelHeights:Zu,pinnedTopRowsLength:We.length,pinnedBottomRowsLength:Ke.length,pinnedTopRows:We,pinnedBottomRows:Ke,visibleOrderedColumns:al,pinnedColumns:Rt,columnWidths:eo,viewportWidth:ke.dimensions.viewportWidth||1e3,checkboxSelection:d,hasDetailPanel:ft,rowReordering:ct,pinCheckboxColumn:F,pinExpandColumn:A,paginationMode:L,isLoading:ke.dataSource.loading,pageSize:Ae.pageSize,getRowId:Ne}),to=nd({pinnedTopRows:We,centerRows:Ln,pinnedBottomRows:Ke,columns:al,leftPinnedColumns:Ie.leftPinnedCols,unpinnedColumns:Ie.unpinnedColsWithWidth,rightPinnedColumns:Ie.rightPinnedCols,expandedRowIds:ft?In:void 0,rowMetaMap:ze,getRowId:Ne}),pl=a.useMemo(()=>[...Ie.leftPinnedCols,...Ie.unpinnedColsWithWidth,...Ie.rightPinnedCols],[Ie.leftPinnedCols,Ie.unpinnedColsWithWidth,Ie.rightPinnedCols]);cc({apiRef:Qt,columns:pl,getRowId:Ne,containerRef:Jt,disableKeyboardShortcut:m}),uc({apiRef:Qt,viewportRef:En,layout:Ie,rowHeight:Ze});const{scrollTop:af,scrollLeft:df,overscanRows:cf,handleScroll:uf,setViewportElement:ff}=Gs({onRowsScrollEnd:me,overscanRowCount:Pe,rowCount:Ie.unpinnedRowsLength,autoHeight:l,setDimensions:Xu,viewportRef:En}),Fe=Ss({layout:Ie,scrollTop:af,scrollLeft:df,viewportWidth:ke.dimensions.viewportWidth,viewportHeight:ke.dimensions.viewportHeight,autoHeight:l,rowReordering:ct,hasDetailPanel:ft,checkboxSelection:d,pinCheckboxColumn:F,pinExpandColumn:A,overscanRows:cf}),{handleSort:hl,handleSortAdd:wl}=Zs({sortModel:$e,onSortModelChange:So}),Oo=d||!u,{focusedCell:ml,setFocusedCell:gf,viewportTabIndex:pf,ensureGridFocus:hf,handleFocus:wf,handleBlur:mf,handleKeyDown:xf,handleMouseDownCapture:bf}=gs({allRenderableRows:Fn,navigationColumns:dl,checkboxSelection:d,selectedRowIds:Zt,handleSelectionChange:An,handleDetailPanelToggle:il,editingHandlers:nl,setKeyboardMode:Mn,sortModel:$e,handleSort:hl,handleSortAdd:wl,multiSort:j,isCellEditable:G,pagination:Ve,pageSize:Ae.pageSize,virtualization:Fe,viewportRef:En,pinnedTopRowCount:We.length,getRowId:Ne,rowMetaMap:ze,getSpanOrigin:to.getSpanOrigin,onRowActivate:Dn,toggleRowExpansion:It?.toggleExpansion,handleSelectAll:On.selectAll,rowSelectionEnabled:Oo,multipleRowSelectionEnabled:!g,pinCheckboxColumn:F,pinExpandColumn:A,rowHeight:Ze}),{handleCellClick:vf,handleHeaderClick:yf}=gc({ensureGridFocus:hf,setKeyboardMode:Mn,setFocusedCell:gf,getRowId:Ne,onCellClick:w}),{handleHideColumn:Cf,handlePinColumn:_f}=ea({columnVisibilityModel:at,onColumnVisibilityModelChange:Cn,pinnedColumns:_n,onPinnedColumnsChange:Ou}),oo=mc({columnGroupingModel:ie,pinnedTopCount:We.length,pinnedBottomCount:Ke.length,pagination:Ve,paginationMode:L,paginationModel:Ae,paginationRowCount:Lo,paginatedUnpinnedRowCount:Fo.length,sortedUnpinnedRowCount:Ue.length}),Wn=id({spanning:to,renderContext:Fe.renderContext,offsetTop:Fe.offsetTop,cumulativeHeights:Ie.cumulativeHeights}),Hn=Ls({renderContext:Wn.renderContext,pinnedTopRows:We,pinnedBottomRows:Ke,paginatedUnpinnedRows:Fo,sortedUnpinnedRows:Ue,pagination:Ve,getRowId:Ne}),Do=ld({spanning:to,firstColumnIndex:Fe.renderContext.firstColumnIndex,lastColumnIndex:Fe.renderContext.lastColumnIndex,virtualColumns:Fe.virtualColumns,layout:Ie,rows:Hn});Us({paginationRequested:N,isRowGrouping:Pt,autoHeight:l,viewportHeight:ke.dimensions.viewportHeight,renderedRowCount:Hn.length,totalRowCount:We.length+Ln.length+Ke.length,pinnedRowsIgnored:Mo&&!!(X?.top?.length||X?.bottom?.length),scrollHeight:Fe.totalHeight,listViewWithoutColumn:xe&&!Ee});const{allSelected:Sf,someSelected:kf}=On,Ft=sd(ie,nf),Ef=a.useMemo(()=>ll.some(pt=>!!pt.rowSpan),[ll]),gt=ra();qs(Jt);const xl=ee?.noRowsOverlay,bl=ee?.loadingOverlay,Bn=bl?s.jsx(bl,{...ce?.loadingOverlay}):void 0,vl=xl?s.jsx(xl,{...ce?.noRowsOverlay}):void 0,Ao=ee?.footer,Mf=et&&Fn.length>0&&L!=="infinite",yl=ee?.toolbar,Cl=xc({toolbar:ee?.toolbar,toolbarSlotProps:ce?.toolbar,apiRef:Qt,orderedColumns:sl,baseColumns:De,aggregationModel:Ge,onAggregationModelChange:Lu,pivotMode:ue,pivotModelProp:he,onPivotModelChangeProp:be,pivotModel:Zi,onPivotModelChange:Du,filterModel:Be,onFilterModelChange:ko,columnVisibilityModel:at,onColumnVisibilityModelChange:Cn,disableColumnReorder:q,columnGroupingModel:ie,moveColumn:ul,resetColumnOrder:fl,forceColumnsOpen:gt.toolbarPanelRequested,onColumnsPanelClose:gt.closeToolbarPanel}),Vn={rowReordering:ct,columnIndexMap:cl,editingHandlers:nl,isCellEditable:G,selectedRowIds:Zt,checkboxSelection:d,onRowClick:Dn,onRowDoubleClick:f,onCellClick:vf,onSelectionChange:An,columnWidths:eo,pinnedColumns:Rt,hasDetailPanel:ft,expandedRowIds:In,getDetailPanelContent:S,getDetailPanelHeight:M,onDetailPanelToggle:il,onDetailPanelHeightChange:ef,pinCheckboxColumn:F,pinExpandColumn:A,focusedCell:ml,colspanMap:to.colspanMap,rowSpanningCaches:to.rowSpanningCaches,rowHeight:Ze,rowMetaMap:ze};return s.jsxs("div",{ref:Jt,className:["ogx",Ce,l&&"ogx--auto-height",Ef&&"ogx--row-spanning",No&&"ogx--list-view"].filter(Boolean).join(" "),style:{...fe,height:ne??fe?.height,"--ogx-row-height":`${Ze}px`,"--ogx-header-height":`${tl}px`},"aria-busy":et,children:[yl&&Cl&&s.jsx(Hr.Provider,{value:gt.toolbarHost,children:s.jsx(sa,{component:yl,toolbarProps:Cl})}),s.jsx(Bd,{isOpen:gt.standalonePanelOpen,containerRef:Jt,panelRef:gt.standalonePanelRef,columns:sl,columnVisibilityModel:at,disableColumnReorder:q,onClose:gt.closeStandalonePanel,onColumnVisibilityChange:Cn,onColumnMove:ul,onColumnOrderReset:fl,columnGroupingModel:ie}),No&&Ee&&s.jsx(vd,{ariaLabel:ve,allRenderableRows:Fn,dataRowCount:Tt.length,pinnedTopRowCount:We.length,pinnedBottomRowCount:Ke.length,unpinnedRowCount:Ue.length,pagination:Ve,effectivePaginationModel:Ae,currentPage:To.currentPage,pageSizeOptions:P,selectedRowIds:Zt,listViewColumn:Ee,columnsByField:kn.byField,rowMetaMap:ze,noRowsLabel:Qe,rowHeight:Ze,checkboxSelection:d,paginationMode:L,serverRowCount:Lo,paginationSlot:ee?.pagination,paginationSlotProps:ce?.pagination,localeText:Nr(we),onRowClick:Dn,onRowDoubleClick:f,onSelectionChange:An,onPaginationModelChange:Nt,onRowsScrollEnd:me,getRowId:Ne,multiselectable:Oo&&!g,selectable:Oo,onToggleExpansion:It?.toggleExpansion,loading:et,loadingOverlay:Bn,noRowsOverlay:vl,showPaginationControls:!Ao}),!No&&s.jsx("div",{ref:ff,className:"ogx__viewport",onScroll:uf,role:"grid","aria-label":ve||"Data grid","aria-rowcount":oo.rowCount,"aria-colcount":dl.length,"aria-multiselectable":Oo&&!g,"aria-busy":et,tabIndex:pf,onKeyDownCapture:()=>{Mn(!0)},onMouseDownCapture:bf,onKeyDown:xf,onFocus:wf,onBlur:mf,children:s.jsxs("div",{className:"ogx__content",style:{width:Fe.totalWidth},role:"presentation",children:[s.jsxs("div",{className:"ogx__sticky-top",role:"presentation",children:[s.jsx(qr,{columns:Do,allColumns:pl,columnGroupingModel:ie,checkboxSelection:d,allSelected:Sf,someSelected:kf,onSelectAll:On.selectAll,sortModel:$e,onSort:hl,onSortAdd:wl,multiSort:j,onColumnResize:rf,columnWidths:eo,pinnedColumns:Rt,focusedCell:ml,columnIndexMap:cl,onHeaderClick:yf,onDragStart:Ft.onDragStart,onDragOver:Ft.onDragOver,onDragEnd:Ft.onDragEnd,onDrop:Ft.onDrop,draggedColumn:Ft.draggedColumn,dragOverColumn:Ft.dragOverColumn,rowReordering:ct,hasDetailPanel:ft,pinCheckboxColumn:F,pinExpandColumn:A,aggregationModel:Ge,onHideColumn:Cf,onManageColumns:gt.openColumnsPanel,onPinColumn:_f}),s.jsx(vi,{...Vn,rows:We,position:"top",ariaRowIndexBase:oo.topBase,columns:Do,pinnedRows:X,getRowId:Ne})]}),!et&&!ke.dataSource.error&&gl.length===0&&s.jsx(da,{noRowsLabel:Qe,width:Fe.totalWidth,overlay:vl}),s.jsx(Gd,{...Vn,virtualContainerHeight:Fe.totalHeight-Fe.pinnedTopHeight-Fe.pinnedBottomHeight,offsetTop:Wn.offsetTop,effectiveLoading:et,visibleRows:Hn,baseColumns:De,virtualColumns:Do,viewportWidth:ke.dimensions.viewportWidth,rowReorderHandlers:lf,paginationMode:L,dataSourceLoading:ke.dataSource.loading,sortedUnpinnedRowCount:Ue.length,infiniteScrollSkeletonCount:Math.min(Ae.pageSize,20),unpinnedRowsLength:Ie.unpinnedRowsLength,lastRenderedRowIndex:Wn.renderContext.lastRowIndex,ariaRowIndexOffset:oo.centerOffset,loadingOverlay:Bn}),s.jsxs("div",{className:"ogx__sticky-bottom",role:"presentation",children:[s.jsx(vi,{...Vn,rows:Ke,position:"bottom",rowIndexOffset:oo.bottomRowIndexOffset,ariaRowIndexBase:oo.bottomBase,columns:Do,pinnedRows:X,getRowId:Ne}),Gn&&Pn.rootAggregationPosition!==null&&s.jsx(aa,{columns:Fe.virtualColumns,aggregationModel:Ge,aggregationResult:$n,columnWidths:eo,rowHeight:Ze,checkboxSelection:d,hasDetailPanel:ft,rowReordering:ct,pinCheckboxColumn:F,pinExpandColumn:A,pinnedColumns:Rt,loading:sf})]})]})}),Ao&&s.jsx(Ao,{apiRef:Nn.apiRef,aggregationModel:Ge,aggregationResult:Gn?$n:null,rowCount:Mo&&L!=="server"?Tt.length:Lo,pagination:Ve,paginationModel:Ae,pageSizeOptions:P,onPaginationModelChange:Nt,...ce?.footer}),!No&&!Ao&&Ve&&s.jsx(pc,{paginationSlot:ee?.pagination,paginationSlotProps:ce?.pagination,page:To.currentPage,paginationModel:Ae,rowCount:Lo,pageSizeOptions:P,onPaginationModelChange:Nt,localeText:we}),s.jsx(hc,{loading:et,error:ke.dataSource.error,noRowsLabel:Qe,filteredRowCount:gl.length,dataRowCount:Tt.length,filterModel:Be}),Mf&&s.jsx(yd,{overlay:Bn}),s.jsx(ua,{error:ke.dataSource.error,onRetry:H?rl.fetchRows:void 0})]})}function vc({rows:e=5,columns:t=5}){return s.jsx("div",{className:"ogx__skeleton",children:Array.from({length:e}).map((o,n)=>s.jsx("div",{className:"ogx__skeleton-row",children:Array.from({length:t}).map((r,i)=>s.jsx("div",{className:"ogx__skeleton-cell",children:s.jsx("div",{className:"ogx__skeleton-content"})},i))},n))})}const yc=300;function kt(e){return"field"in e&&!("items"in e)}function Mi(e,t){return e.find(o=>kt(o)&&o.field===t)}function Ni(e,t){return Object.is(e,t)?!0:e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((o,n)=>Ni(o,t[n])):!1}function Cc(e,t){return e===t?!0:kt(e)&&kt(t)?e.id===t.id&&e.field===t.field&&e.operator===t.operator&&Ni(e.value,t.value):!kt(e)&&!kt(t)?e.id===t.id&&e.logicOperator===t.logicOperator&&vn(e.items,t.items):!1}function vn(e,t){return e===t?!0:e.length===t.length&&e.every((o,n)=>Cc(o,t[n]))}function _c(e){return(e.valueOptions??[]).map((t,o)=>t!==null&&typeof t=="object"?{key:String(o),value:t.value,label:t.label}:{key:String(o),value:t,label:String(t)})}function Pi(e,t){return Object.is(e.value,t)?!0:t!=null&&String(e.value).toLowerCase()===String(t).toLowerCase()}function Ii(e,t){return e==null?"":t.type==="date"||e instanceof Date?Xn(e)||(typeof e=="string"?e:""):Array.isArray(e)?e.map(o=>String(o)).join(", "):String(e)}function Ti(e,t){return t==="isAnyOf"?e.split(",").map(o=>o.trim()).filter(o=>o!==""):e}function Sc(e,t){if(!qo.has(t))return t==="isAnyOf"?e==null||e===""?[]:Array.isArray(e)?e:[e]:Array.isArray(e)?e.length>0?e[0]:"":e??""}const kc=({col:e,item:t,resetToken:o,onChange:n})=>{const r=a.useId(),i=jl(e.type),l=i[0],c=t?.operator??l,d=i.includes(c)?i:[c,...i],u=!!t,g=e.headerName||e.field,[m,x]=a.useState(null),[v,h]=a.useState(o);v!==o&&(h(o),x(null));const f=a.useRef(n),w=a.useRef(t),p=a.useRef(e);a.useLayoutEffect(()=>{f.current=n,w.current=t,p.current=e});const b=a.useCallback((M,I)=>({id:w.current?.id??`${e.field}-${Date.now()}`,field:e.field,operator:M,value:I}),[e.field]),y=a.useCallback(M=>{const I=w.current;if(I?M===Ii(I.value,p.current):M.trim()==="")return;const F=I?.operator??l;f.current(b(F,Ti(M,F)))},[l,b]),C=a.useRef(null),N=a.useRef(y);a.useLayoutEffect(()=>{C.current=m,N.current=y}),a.useEffect(()=>()=>{const M=C.current;C.current=null,M!==null&&N.current(M)},[]),a.useEffect(()=>{if(m===null)return;const M=setTimeout(()=>{C.current=null,y(m),x(null)},yc);return()=>clearTimeout(M)},[m,y]);const T=M=>{const I=m!==null?Ti(m,M):t?.value;x(null),n(b(M,Sc(I,M)))},E=()=>{x(null),n(null)},P=!qo.has(c),O=_c(e),W=`ogx-filter__value-input${u?" ogx-filter__value-input--active":""}`,X=`Filter value for ${g}`;let S=null;if(P&&e.type==="boolean")S=s.jsxs("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${W} ogx-filter__value-select`,value:t?.value==null?"":String(t.value),onChange:M=>{M.target.value===""?n(null):n(b(c,M.target.value))},"aria-label":X,children:[s.jsx("option",{value:"",children:"Any"}),s.jsx("option",{value:"true",children:"true"}),s.jsx("option",{value:"false",children:"false"})]});else if(P&&e.type==="singleSelect"&&O.length>0&&c==="isAnyOf"){const M=Array.isArray(t?.value)?t.value:t?.value==null||t.value===""?[]:[t.value];S=s.jsx("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${W} ogx-filter__value-multiselect`,multiple:!0,size:Math.min(O.length,4),value:O.filter(I=>M.some(_=>Pi(I,_))).map(I=>I.key),onChange:I=>{const _=new Set(Array.from(I.target.selectedOptions,F=>F.value));n(b("isAnyOf",O.filter(F=>_.has(F.key)).map(F=>F.value)))},"aria-label":X,children:O.map(I=>s.jsx("option",{value:I.key,children:I.label},I.key))})}else if(P&&e.type==="singleSelect"&&O.length>0&&(c==="is"||c==="not")){const M=O.find(I=>Pi(I,t?.value));S=s.jsxs("select",{id:`${r}-val`,name:`filter-val-${e.field}`,className:`${W} ogx-filter__value-select`,value:M?.key??"",onChange:I=>{const _=O.find(F=>F.key===I.target.value);n(b(c,_?_.value:""))},"aria-label":X,children:[s.jsx("option",{value:"",children:"Any"}),O.map(I=>s.jsx("option",{value:I.key,children:I.label},I.key))]})}else P&&(S=s.jsx("input",{id:`${r}-val`,name:`filter-val-${e.field}`,className:W,type:e.type==="date"?"date":"text",value:m??Ii(t?.value,e),onChange:M=>x(M.target.value),placeholder:e.type==="number"?"Number…":"Value…","aria-label":X}));return s.jsxs("div",{className:`ogx-filter__row${u?" ogx-filter__row--active":""}`,children:[s.jsx("span",{className:"ogx-filter__col-label",title:e.field,children:g}),s.jsxs("div",{className:"ogx-filter__controls",children:[s.jsx("select",{id:`${r}-op`,name:`filter-op-${e.field}`,className:`ogx-filter__op-select${u?" ogx-filter__op-select--active":""}`,value:c,onChange:M=>T(M.target.value),"aria-label":`Filter operator for ${g}`,children:d.map(M=>s.jsx("option",{value:M,children:M},M))}),S,u&&s.jsx("button",{type:"button",className:"ogx-filter__row-clear",onClick:E,"aria-label":`Clear filter for ${g}`,title:"Clear",children:"×"})]})]})},Fi=({filterModel:e,columns:t,onFilterModelChange:o})=>{const n=a.useMemo(()=>e.items??[],[e.items]),r=e.logicOperator??"and",[i,l]=a.useState(null),[c,d]=a.useState(n),[u,g]=a.useState(0);if(c!==n){d(n);const w=!vn(c,n),p=i!==null&&vn(i,n);w&&!p&&g(b=>b+1)}const m=a.useCallback((w,p)=>{const b=n.findIndex(C=>kt(C)&&C.field===w);let y;if(b===-1){if(!p)return;y=[...n,p]}else p?y=n.map((C,N)=>N===b?p:C):y=n.filter((C,N)=>N!==b);l(y),o({...e,items:y})},[n,e,o]),x=a.useCallback(w=>{o({...e,logicOperator:w})},[e,o]),v=t.filter(w=>w.filterable!==!1),h=v.filter(w=>Mi(n,w.field)).length,f=n.length-h;return s.jsxs(s.Fragment,{children:[n.length>1&&s.jsxs("div",{className:"ogx-filter__logic-bar",children:[s.jsx("span",{className:"ogx-filter__logic-label",children:"Match:"}),s.jsx("button",{type:"button",className:`ogx-filter__logic-pill${r==="and"?" ogx-filter__logic-pill--active":""}`,onClick:()=>x("and"),"aria-pressed":r==="and",children:"ALL (AND)"}),s.jsx("button",{type:"button",className:`ogx-filter__logic-pill${r==="or"?" ogx-filter__logic-pill--active":""}`,onClick:()=>x("or"),"aria-pressed":r==="or",children:"ANY (OR)"})]}),f>0&&s.jsx("div",{className:"ogx-filter__hidden-note",role:"note",children:f===1?"1 more condition (a filter group or a second condition on a column) is applied and not shown here.":`${f} more conditions (filter groups or further conditions on a column) are applied and not shown here.`}),v.length===0?s.jsx("div",{className:"ogx-filter__empty",children:"No filterable columns."}):v.map(w=>s.jsx(kc,{col:w,item:Mi(n,w.field),resetToken:u,onChange:p=>m(w.field,p)},w.field))]})},Li=["sum","avg","count","min","max"];function Oi(){return s.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:[s.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),s.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),s.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),s.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1",fill:"currentColor",opacity:"0.25"}),s.jsx("path",{d:"M17 14v-4M17 10l-2 2 2 2"})]})}function Ec({anchorRef:e,columns:t,model:o,onChange:n,onClose:r}){const i=a.useRef(null),[l,c]=a.useState({top:0,right:0}),[d,u]=a.useState(null);a.useLayoutEffect(()=>{u(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const g=a.useCallback(()=>{if(!e.current)return{top:0,right:0};const _=e.current.getBoundingClientRect();return{top:_.bottom+6,right:xt()-_.right}},[e]);a.useEffect(()=>{c(g());const _=()=>c(g());return window.addEventListener("scroll",_,!0),window.addEventListener("resize",_),()=>{window.removeEventListener("scroll",_,!0),window.removeEventListener("resize",_)}},[g]),a.useEffect(()=>{function _(A){i.current&&!i.current.contains(A.target)&&e.current&&!e.current.contains(A.target)&&r()}function F(A){A.key==="Escape"&&r()}return document.addEventListener("mousedown",_),document.addEventListener("keydown",F),()=>{document.removeEventListener("mousedown",_),document.removeEventListener("keydown",F)}},[e,r]);const m=new Set(o.rowFields),x=new Set(o.columnFields),v=new Set(o.valueFields.map(_=>_.field)),h=_=>m.has(_)||x.has(_)||v.has(_),f=_=>t.find(F=>F.field===_),w=_=>f(_)?.headerName??_,p=_=>{const F=f(_)?.availableAggregationFunctions;return F?Li.filter(A=>F.includes(A)):Li},b=_=>_.aggregable!==!1&&(_.type==="number"||_.aggregable===!0)&&p(_.field).length>0,y=_=>_.groupable!==!1;function C(_){m.has(_)||n({...o,rowFields:[...o.rowFields,_]})}function N(_){x.has(_)||n({...o,columnFields:[...o.columnFields,_]})}function T(_){v.has(_)||n({...o,valueFields:[...o.valueFields,{field:_,aggFn:p(_)[0]??"sum"}]})}function E(_){n({...o,rowFields:o.rowFields.filter((F,A)=>A!==_)})}function P(_){n({...o,columnFields:o.columnFields.filter((F,A)=>A!==_)})}function O(_){n({...o,valueFields:o.valueFields.filter((F,A)=>A!==_)})}function W(_,F){n({...o,valueFields:o.valueFields.map((A,q)=>q===_?{...A,aggFn:F}:A)})}function X(){n({rowFields:[],columnFields:[],valueFields:[]})}const S=o.rowFields.length+o.columnFields.length+o.valueFields.length,M=t.filter(_=>!h(_.field)&&(y(_)||b(_))),I=s.jsxs("div",{ref:i,className:"ogx-pivot-panel",role:"dialog","aria-label":"Pivot configuration",style:{top:l.top,right:l.right},children:[s.jsxs("div",{className:"ogx-pivot-panel__header",children:[s.jsxs("span",{className:"ogx-pivot-panel__title",children:[s.jsx(Oi,{}),"Pivot Mode"]}),S>0&&s.jsx("button",{type:"button",className:"ogx-pivot-panel__reset-btn",onClick:X,title:"Reset pivot",children:"Reset"})]}),s.jsxs("div",{className:"ogx-pivot-panel__body",children:[s.jsxs("div",{className:"ogx-pivot-zone",children:[s.jsxs("span",{className:"ogx-pivot-zone__label",children:[s.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--row"}),"Row Fields"]}),s.jsx("div",{className:`ogx-pivot-chips${o.rowFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — each becomes a row label",children:o.rowFields.map((_,F)=>s.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--row",children:[w(_),s.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>E(F),title:`Remove ${w(_)}`,"aria-label":`Remove ${w(_)} from Row Fields`,children:"×"})]},`${F}:${_}`))})]}),s.jsxs("div",{className:"ogx-pivot-zone",children:[s.jsxs("span",{className:"ogx-pivot-zone__label",children:[s.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--col"}),"Column Fields"]}),s.jsx("div",{className:`ogx-pivot-chips${o.columnFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add fields here — unique values become column headers",children:o.columnFields.map((_,F)=>s.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--col",children:[w(_),s.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>P(F),title:`Remove ${w(_)}`,"aria-label":`Remove ${w(_)} from Column Fields`,children:"×"})]},`${F}:${_}`))})]}),s.jsxs("div",{className:"ogx-pivot-zone",children:[s.jsxs("span",{className:"ogx-pivot-zone__label",children:[s.jsx("span",{className:"ogx-pivot-zone__dot ogx-pivot-zone__dot--value"}),"Value Fields (aggregated)"]}),s.jsx("div",{className:`ogx-pivot-chips${o.valueFields.length===0?" ogx-pivot-chips--empty":""}`,"data-placeholder":"Add numeric fields here — values are aggregated",children:o.valueFields.map((_,F)=>{const A=p(_.field),q=A.includes(_.aggFn)?A:[_.aggFn,...A];return s.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--value",children:[w(_.field),s.jsx("select",{className:"ogx-pivot-chip__fn-select",value:_.aggFn,onChange:K=>W(F,K.target.value),title:"Aggregation function","aria-label":`Aggregation function for ${w(_.field)}`,children:q.map(K=>s.jsx("option",{value:K,children:K.toUpperCase()},K))}),s.jsx("button",{type:"button",className:"ogx-pivot-chip__remove",onClick:()=>O(F),title:`Remove ${w(_.field)}`,"aria-label":`Remove ${w(_.field)} (${_.aggFn.toUpperCase()}) from Value Fields`,children:"×"})]},`${F}:${_.field}:${_.aggFn}`)})})]}),s.jsx("hr",{className:"ogx-pivot-panel__divider"}),s.jsxs("div",{children:[s.jsx("div",{className:"ogx-pivot-panel__fields-label",children:"Available Fields"}),s.jsxs("div",{className:"ogx-pivot-fields",children:[M.map(_=>{const F=b(_),A=y(_),q=_.headerName??_.field;return s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3},children:[s.jsx("span",{className:`ogx-pivot-field-btn${F?" ogx-pivot-field-btn--numeric":""}`,children:q}),s.jsxs("div",{className:"ogx-pivot-field-actions",children:[A&&s.jsx("button",{type:"button",className:"ogx-pivot-add-btn ogx-pivot-add-btn--row",onClick:()=>C(_.field),title:"Add to Row Fields","aria-label":`Add ${q} to Row Fields`,children:"Row"}),A&&s.jsx("button",{type:"button",className:"ogx-pivot-add-btn ogx-pivot-add-btn--col",onClick:()=>N(_.field),title:"Add to Column Fields","aria-label":`Add ${q} to Column Fields`,children:"Col"}),F&&s.jsx("button",{type:"button",className:"ogx-pivot-add-btn ogx-pivot-add-btn--value",onClick:()=>T(_.field),title:"Add to Value Fields","aria-label":`Add ${q} to Value Fields`,children:"Val"})]})]},_.field)}),M.length===0&&s.jsx("span",{style:{fontSize:12,color:"var(--ogx-color-gray-400, #94a3b8)"},children:"All fields are in use."})]})]})]})]});return d?tt.createPortal(I,d):null}function Mc(){return s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function Nc(){return s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function Di(e){return e.trim().split(/\s+/).filter(Boolean).join(" ")}function Pc({value:e="",onChange:t,placeholder:o="Search...",debounceMs:n=250}){const[r,i]=a.useState(()=>e.length>0),[l,c]=a.useState(e),d=a.useRef(null),u=a.useRef(null),g=a.useRef(t);a.useLayoutEffect(()=>{g.current=t},[t]);const m=a.useRef(e),x=a.useRef(e);a.useEffect(()=>{e!==x.current&&(x.current=e,Di(e)!==Di(m.current)&&(c(e),m.current=e,i(e.length>0)))},[e]),a.useEffect(()=>{const b=setTimeout(()=>{l!==m.current&&(m.current=l,g.current(l))},n);return()=>clearTimeout(b)},[l,n]);const v=a.useRef(l);a.useLayoutEffect(()=>{v.current=l}),a.useEffect(()=>()=>{const b=v.current;b!==m.current&&(m.current=b,g.current(b))},[]);const h=a.useCallback(()=>{i(!0),requestAnimationFrame(()=>d.current?.focus())},[]),f=a.useCallback(b=>{b.stopPropagation(),c(""),m.current="",g.current(""),d.current?.focus()},[]),w=a.useCallback(()=>{i(!0)},[]),p=a.useCallback(()=>{setTimeout(()=>{u.current&&document.activeElement&&u.current.contains(document.activeElement)||l||i(!1)},150)},[l]);return a.useEffect(()=>{const b=y=>{u.current&&!u.current.contains(y.target)&&(l||i(!1))};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[l]),s.jsxs("div",{ref:u,className:`ogx-global-search${r?" ogx-global-search--expanded":""}`,onClick:r?void 0:h,children:[s.jsx("div",{className:"ogx-global-search__icon-wrapper",children:s.jsx(Mc,{})}),s.jsx("input",{ref:d,className:"ogx-global-search__input",value:l,onChange:b=>c(b.target.value),onFocus:w,onBlur:p,placeholder:o,"aria-label":"Global Search",autoComplete:"off"}),l&&s.jsx("button",{type:"button",className:"ogx-global-search__clear",onClick:f,"aria-label":"Clear search",children:s.jsx(Nc,{})})]})}const vo=8;function jt({title:e,children:t,placement:o="top",enterDelay:n=200,leaveDelay:r=0}){const[i,l]=a.useState(!1),[c,d]=a.useState({top:0,left:0}),[u,g]=a.useState(null),m=a.useRef(null),x=a.useRef(null),v=a.useId(),h=a.useCallback(()=>{if(!x.current)return;const N=x.current.getBoundingClientRect(),T=N.left+N.width/2,E=N.top+N.height/2;switch(o){case"bottom":d({top:N.bottom+vo,left:T});break;case"left":d({top:E,left:N.left-vo});break;case"right":d({top:E,left:N.right+vo});break;default:d({top:N.top-vo,left:T})}},[o]),f=a.useCallback(()=>{m.current&&clearTimeout(m.current),m.current=null},[]);a.useLayoutEffect(()=>{if(!i)return;h();const N=T=>{T.key==="Escape"&&(f(),l(!1))};return window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),document.addEventListener("keydown",N),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h),document.removeEventListener("keydown",N)}},[i,h,f]),a.useEffect(()=>f,[f]);const w=()=>{f(),m.current=setTimeout(()=>{g(x.current?.closest(".ogx-theme-provider")??document.body),l(!0)},n)},p=()=>{f(),m.current=setTimeout(()=>{l(!1)},r)},b=a.useCallback(N=>{x.current=N?N.firstElementChild??N:null},[]),y=i&&!!e&&u!==null;let C=t;if(y&&a.isValidElement(t)){const N=t,T=N.props["aria-describedby"];C=a.cloneElement(N,{"aria-describedby":T?`${T} ${v}`:v})}return s.jsxs(s.Fragment,{children:[s.jsx("span",{ref:b,style:{display:"inline-block",lineHeight:0},onMouseEnter:w,onMouseLeave:p,onFocus:w,onBlur:p,children:C}),y&&u&&tt.createPortal(s.jsx("div",{id:v,role:"tooltip",className:`ogx-tooltip ogx-tooltip--${o}`,style:{top:c.top,left:c.left,position:"fixed",zIndex:99999},children:e}),u)]})}const Ic=Object.keys(lo);function Tc(e){return Object.prototype.hasOwnProperty.call(lo,e)}function Ai(e){return e.availableAggregationFunctions?Array.from(new Set(e.availableAggregationFunctions.filter(Tc))):Ic}function $i(){return s.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:s.jsx("path",{d:"M18 4H6l6 8-6 8h12"})})}function Fc(){return s.jsxs("svg",{focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",children:[s.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("rect",{x:"8.5",y:"4",width:"7",height:"16",fill:"currentColor",opacity:"0.25"}),s.jsx("line",{x1:"8.5",y1:"4",x2:"8.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("line",{x1:"15.5",y1:"4",x2:"15.5",y2:"20",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("line",{x1:"2",y1:"9",x2:"22",y2:"9",stroke:"currentColor",strokeWidth:"1.2"}),s.jsx("line",{x1:"2",y1:"14",x2:"22",y2:"14",stroke:"currentColor",strokeWidth:"1.2"})]})}function Gi(){return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"})})}function Lc({anchorRef:e,aggregationModel:t,aggregableColumns:o,onFunctionChange:n,onClearAll:r,onClose:i,activeCount:l}){const c=a.useRef(null),[d,u]=a.useState({top:0,right:0}),[g,m]=a.useState(null);a.useLayoutEffect(()=>{m(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const x=a.useCallback(()=>{if(!e.current)return{top:0,right:0};const h=e.current.getBoundingClientRect();return{top:h.bottom+6,right:xt()-h.right}},[e]);a.useEffect(()=>{u(x());const h=()=>u(x());return window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}},[x]),a.useEffect(()=>{function h(f){c.current&&!c.current.contains(f.target)&&e.current&&!e.current.contains(f.target)&&i()}return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[e,i]),a.useEffect(()=>{function h(f){f.key==="Escape"&&i()}return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[i]);const v=s.jsxs("div",{ref:c,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Summaries configuration",style:{top:d.top,right:d.right,width:400,maxWidth:"calc(100vw - 24px)"},children:[s.jsxs("div",{className:"ogx-toolbar__panel-header",children:[s.jsxs("span",{className:"ogx-toolbar__panel-title",children:[s.jsx($i,{}),"Summaries"]}),l>0&&s.jsx("button",{type:"button",className:"ogx-toolbar__clear-btn",onClick:r,title:"Clear all summaries",children:"Clear all"})]}),s.jsx("div",{className:"ogx-toolbar__panel-body",children:o.length===0?s.jsxs("p",{className:"ogx-toolbar__empty",children:["No aggregable columns.",s.jsx("br",{}),"Set ",s.jsx("code",{children:"aggregable: true"})," on a column to enable."]}):o.map(h=>{const f=t[h.field]||"none";return s.jsxs("div",{className:"ogx-toolbar__agg-row",children:[s.jsx("span",{className:"ogx-toolbar__agg-label",title:h.field,children:h.headerName||h.field}),s.jsx("div",{className:"ogx-toolbar__agg-pills",children:["none",...Ai(h)].map(w=>s.jsx("button",{type:"button",className:`ogx-toolbar__pill${f===w?" ogx-toolbar__pill--active":""}`,onClick:()=>n(h.field,w),"aria-pressed":f===w,children:w},w))})]},h.field)})})]});return g?tt.createPortal(v,g):null}function Oc({anchorRef:e,columns:t,visibleColumns:o,onVisibilityChange:n,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:c,onClose:d,showNonHideableColumns:u}){const g=a.useRef(null),[m,x]=a.useState({top:0,right:0}),[v,h]=a.useState(null);a.useLayoutEffect(()=>{h(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const f=a.useCallback(()=>{if(!e.current)return{top:0,right:0};const p=e.current.getBoundingClientRect();return{top:p.bottom+6,right:xt()-p.right}},[e]);a.useEffect(()=>{x(f());const p=()=>x(f());return window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)}},[f]),a.useEffect(()=>{function p(b){g.current&&!g.current.contains(b.target)&&e.current&&!e.current.contains(b.target)&&d()}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[e,d]),a.useEffect(()=>{function p(b){b.key==="Escape"&&d()}return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[d]);const w=s.jsx("div",{ref:g,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Column visibility",style:{top:m.top,right:m.right,width:280,padding:0},children:s.jsx(mn,{columns:t,visibleColumns:o,onVisibilityChange:n,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:c,showNonHideableColumns:u})});return v?tt.createPortal(w,v):null}function Dc({anchorRef:e,columns:t,filterModel:o,onFilterModelChange:n,onClose:r}){const i=a.useRef(null),[l,c]=a.useState({top:0,right:0}),d=a.useRef(r);a.useLayoutEffect(()=>{d.current=r},[r]);const[u,g]=a.useState(null);a.useLayoutEffect(()=>{g(e.current?.closest(".ogx-theme-provider")??document.body)},[e]);const m=a.useCallback(()=>{if(!e.current)return{top:0,right:0};const f=e.current.getBoundingClientRect();return{top:f.bottom+6,right:xt()-f.right}},[e]);a.useEffect(()=>{c(m());const f=()=>c(m());return window.addEventListener("scroll",f,!0),window.addEventListener("resize",f),()=>{window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[m]),a.useEffect(()=>{function f(w){w.key==="Escape"&&d.current()}return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[]);const x=o.items?.length??0,v=()=>{n({...o,items:[],logicOperator:"and"})},h=s.jsxs("div",{ref:i,className:"ogx-toolbar__panel ogx-toolbar__panel--filter",role:"dialog","aria-label":"Advanced filters",style:{top:l.top,right:l.right,width:540,maxWidth:"calc(100vw - 24px)"},children:[s.jsxs("div",{className:"ogx-toolbar__panel-header",children:[s.jsxs("span",{className:"ogx-toolbar__panel-title",children:[s.jsx(Gi,{}),"Filters",x>0&&s.jsx("span",{className:"ogx-toolbar__panel-count",children:x})]}),s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[x>0&&s.jsx("button",{type:"button",className:"ogx-toolbar__clear-btn",onClick:v,title:"Clear all filters",children:"Clear all"}),s.jsx("button",{type:"button",className:"ogx-toolbar__close-btn",onClick:()=>d.current(),title:"Close filters","aria-label":"Close filters panel",children:"Close"})]})]}),s.jsx("div",{className:"ogx-toolbar__panel-body ogx-toolbar__panel-body--filter",children:s.jsx(Fi,{columns:t,filterModel:o,onFilterModelChange:n})})]});return u?tt.createPortal(h,u):null}const Ac={rowFields:[],columnFields:[],valueFields:[]};function $c({columns:e=[],baseColumns:t,aggregationModel:o={},onAggregationModelChange:n,pivotModel:r,onPivotModelChange:i,filterModel:l,onFilterModelChange:c,columnVisibilityModel:d={},onColumnVisibilityModelChange:u,onColumnReorder:g,onColumnOrderReset:m,forceColumnsOpen:x,onColumnsPanelClose:v,children:h,rightContent:f,style:w,renderColumnsButton:p,renderFilterButton:b,renderAggregationButton:y,renderExportButton:C,renderQuickFilter:N,className:T,showNonHideableColumns:E}){const[P,O]=a.useState(null),W=P==="summaries",X=P==="pivot",S=P==="columns",M=P==="filters",I=k=>{P==="columns"&&k!=="columns"&&v?.(),O(k)},_=k=>I(P===k?null:k),F=k=>{P===k&&I(null)};a.useEffect(()=>{x&&O("columns")},[x]);const A=a.useContext(Hr),q=x!==void 0&&!!u;a.useEffect(()=>{if(!(!A||!q))return A.registerColumnsPanel()},[A,q]);const K=a.useRef(null),J=a.useRef(null),te=a.useRef(null),ne=a.useRef(null),Z=a.useRef(null),de=a.useRef(null),ae=a.useRef(null),oe=r??Ac,se=oe.rowFields.length>0||oe.columnFields.length>0||oe.valueFields.length>0,re=t?new Set(t.map(k=>k.field)):null,B=e.filter(k=>k.aggregable!==!1&&(k.type==="number"||k.aggregable===!0)&&Ai(k).length>0&&(!re||re.has(k.field))),D=Object.keys(o).filter(k=>o[k]&&o[k]!=="none").length,$=a.useCallback((k,L)=>{if(!n)return;const Q={...o};L==="none"?delete Q[k]:Q[k]=L,n(Q)},[o,n]),R=a.useCallback(()=>{n?.({})},[n]),U=a.useCallback(k=>{if(!c)return;const L=k.trim().split(/\s+/).filter(Boolean),Q={...l||{},quickFilterValues:L,items:l?.items||[]};c(Q)},[l,c]),G=(l?.quickFilterValues??[]).join(" "),V=l?.items?.length||0,Y=new Set(e.filter(k=>d[k.field]!==!1).map(k=>k.field)),H=a.useCallback((k,L)=>{if(!u)return;const Q={...d,[k]:L};u(Q)},[d,u]),j=a.useCallback(()=>{if(!u)return;const k={...d};e.forEach(L=>{L.hideable!==!1&&(k[L.field]=!0)}),u(k)},[e,d,u]),z=a.useCallback(()=>{if(!u)return;const k={...d};e.forEach(L=>{L.hideable!==!1&&(k[L.field]=!1)}),u(k)},[e,d,u]);return s.jsxs("div",{className:["ogx-toolbar",T].filter(Boolean).join(" "),role:"toolbar","aria-label":"Grid toolbar",style:w,children:[h&&s.jsx("div",{className:"ogx-toolbar__left",children:h}),s.jsx("div",{className:"ogx-toolbar__spacer"}),s.jsxs("div",{className:"ogx-toolbar__actions",children:[c&&s.jsx("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:N?N({value:G,onChange:U}):s.jsx(Pc,{value:G,onChange:U,placeholder:"Search..."})}),u&&s.jsxs("div",{ref:Z,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[p?p({onClick:()=>_("columns"),isOpen:S,activeCount:e.length-Y.size}):s.jsx(jt,{title:"Columns",children:s.jsx("button",{type:"button",ref:te,className:`ogx-toolbar__icon-btn${S?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Manage columns","aria-haspopup":"dialog","aria-expanded":S,onClick:()=>_("columns"),children:s.jsx(Fc,{})})}),S&&s.jsx(Oc,{anchorRef:p?Z:te,columns:e,visibleColumns:Y,onVisibilityChange:H,onShowAll:j,onHideAll:z,onColumnReorder:g,onColumnOrderReset:m,onClose:()=>F("columns"),showNonHideableColumns:E})]}),c&&s.jsxs("div",{ref:de,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[b?b({onClick:()=>_("filters"),isOpen:M,activeCount:V}):s.jsx(jt,{title:"Filters",children:s.jsxs("button",{type:"button",ref:ne,className:`ogx-toolbar__icon-btn${M?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Advanced filters","aria-haspopup":"dialog","aria-expanded":M,onClick:()=>_("filters"),children:[s.jsx(Gi,{}),V>0&&s.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Filters active"})]})}),M&&s.jsx(Dc,{anchorRef:b?de:ne,columns:e,filterModel:l||{items:[]},onFilterModelChange:c,onClose:()=>F("filters")})]}),i&&s.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[s.jsx(jt,{title:"Pivot",children:s.jsxs("button",{type:"button",ref:J,className:`ogx-toolbar__icon-btn${X?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure pivot","aria-haspopup":"dialog","aria-expanded":X,onClick:()=>_("pivot"),children:[s.jsx(Oi,{}),se&&s.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Pivot active"})]})}),X&&s.jsx(Ec,{anchorRef:J,columns:t??e,model:oe,onChange:k=>{i?.(k)},onClose:()=>F("pivot")})]}),n&&s.jsxs("div",{ref:ae,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[y?y({onClick:()=>_("summaries"),isOpen:W,activeCount:D}):s.jsx(jt,{title:"Summaries",children:s.jsxs("button",{type:"button",ref:K,className:`ogx-toolbar__icon-btn${W?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure summaries","aria-haspopup":"dialog","aria-expanded":W,onClick:()=>_("summaries"),children:[s.jsx($i,{}),D>0&&s.jsx("span",{className:"ogx-toolbar__dot","aria-label":`${D} active summaries`})]})}),W&&s.jsx(Lc,{anchorRef:y?ae:K,aggregationModel:o,aggregableColumns:B,onFunctionChange:$,onClearAll:R,onClose:()=>F("summaries"),activeCount:D})]}),C&&C(),f]})]})}function Gc(){const[e]=a.useState(Yr);return a.useRef(e)}const Wc=({fullWidth:e=!1,error:t=!1,startAdornment:o,endAdornment:n,className:r="",...i})=>{const l=["ogx-input-wrapper",e&&"ogx-input-wrapper--full-width",t&&"ogx-input-wrapper--error",i.disabled&&"ogx-input-wrapper--disabled",r].filter(Boolean).join(" ");return s.jsxs("div",{className:l,children:[o&&s.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--start",children:o}),s.jsx("input",{className:"ogx-input",...i}),n&&s.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--end",children:n})]})};function Et(e,t){if(e.groupLabel!==void 0)return e.groupLabel;const o=e.groupField??"",n=t.find(r=>r.field===o)?.groupingValueFormatter;return n?n({field:o,value:e.groupValue}):`${o}: ${String(e.groupValue??"")}`}const Hc=new Set([8364,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,381,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,382,376]);function Bc(e){return e>=8192&&e<=8202||e===8239||e===8287||e===12288?" ":e>=8203&&e<=8205||e===8288||e===65279?"":e===8208||e===8209||e===8210||e===8722?"-":null}function Vc(e){let t="",o=!1;for(const n of e){const r=n.codePointAt(0)??0;if(r<=255||Hc.has(r)){t+=n;continue}const i=Bc(r);i!==null?t+=i:(t+="?",o=!0)}return{text:t,lossy:o}}const zc=[79,70,229],Kc=[255,255,255];function Wi(e,t){const o=e.trim().replace(/^#/,""),n=/^[a-f\d]{3}$/i.test(o)?o.split("").map(i=>i+i).join(""):o,r=/^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);return r?[parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16)]:t}function Hi(e,t){return xo(e,t,Kt(e,t))}function Bi(e){return(typeof e.width=="number"?e.width:void 0)??(e.flex??1)*100}function jc(e,t){const o=e.reduce((r,i)=>r+Bi(i),0),n={};return e.forEach((r,i)=>{n[i]={cellWidth:Bi(r)/o*t}}),n}const Uc=new Set(["isEmpty","isNotEmpty"]);function Xc(e,t){const n=t.find(l=>l.field===e.field)?.headerName??e.field;if(Uc.has(e.operator))return`${n} ${e.operator}`;const{value:r}=e;if(r==null||r===""||Array.isArray(r)&&r.length===0)return null;const i=Array.isArray(r)?r.map(String).join(", "):String(r);return`${n} ${e.operator} "${i}"`}function Vi(e,t,o,n){const r=e.map(l=>"items"in l?Vi(l.items,l.logicOperator,o,!0):Xc(l,o)).filter(l=>!!l);if(r.length===0)return"";const i=r.join(t==="or"?" OR ":" AND ");return n&&r.length>1?`(${i})`:i}function qc(e,t){const o=[],n=Vi(e.items??[],e.logicOperator??"and",t,!1);n&&o.push(n);const r=(e.quickFilterValues??[]).filter(i=>i.trim()!=="");return r.length>0&&o.push(`Search: ${r.map(i=>`"${i}"`).join(" ")}`),o.join(" • ")}const Yc=1.15*.3528;async function Rc(e,t,o={}){let n,r;try{const[D,$]=await Promise.all([import("jspdf"),import("jspdf-autotable")]);n=D.default,r=$.default}catch{throw new Error("exportToPdf requires 'jspdf' and 'jspdf-autotable'. Run: npm install jspdf jspdf-autotable")}const{fileName:i="export",title:l,logoUrl:c,orientation:d="landscape",selectedRows:u,getRowId:g,aggregationResult:m,aggregationModel:x,filterModel:v,alternateRowColor:h=!0,headerBackgroundColor:f="#4f46e5",headerTextColor:w="#ffffff",fontSize:p=9,groupedRows:b,font:y}=o,C=new n({orientation:d,unit:"mm",format:"a4"}),N=C.internal.pageSize.getWidth(),T=C.internal.pageSize.getHeight(),E=14,P=N-E*2;let O="helvetica";y&&(C.addFileToVFS(`${y.name}-normal.ttf`,y.data),C.addFont(`${y.name}-normal.ttf`,y.name,"normal"),y.boldData&&C.addFileToVFS(`${y.name}-bold.ttf`,y.boldData),C.addFont(y.boldData?`${y.name}-bold.ttf`:`${y.name}-normal.ttf`,y.name,"bold"),O=y.name);let W=!1;const X=D=>{if(y)return D;const $=Vc(D);return $.lossy&&(W=!0),$.text},S=(D,$,R,U,G)=>{const V=C.splitTextToSize(X(D),U);return C.text(V.length===1?V[0]:V,$,R),Math.max(0,V.length-1)*G*Yc},M=st(t),I=zt(b,u),_=Vt(e,u,g);let F=E;if(l){let D=E,$=E+8;if(c)try{C.addImage(c,"PNG",D,E,10,10),D+=14}catch{}const R=N-E-D;C.setFontSize(16),C.setFont(O,"bold"),C.setTextColor(30,41,59),$+=S(l,D,$,R,16),$+=6,C.setFontSize(8),C.setFont(O,"normal"),C.setTextColor(100,116,139);const U=new Date().toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),G=I?b.filter(V=>V.type==="leaf").length:_.length;if(C.text(X(`Exported: ${U} • ${G} row${G!==1?"s":""}`),D,$),$+=5,v){const V=qc(v,t);V&&($+=S(`Filters: ${V}`,D,$,R,8),$+=5)}C.setDrawColor(226,232,240),C.setLineWidth(.3),C.line(E,$+2,N-E,$+2),F=$+6}const A=[M.map(D=>X(D.headerName??D.field))],q=x||{},K=D=>M.map($=>xn($,q[$.field],D[$.field],D));let J,te;if(I)J=[],b.forEach(D=>{const $=" ".repeat(D.depth*2);if(D.type==="group-header"){const R=`${$}${Et(D,t)}`;J.push(M.map((U,G)=>G===0?R:""))}else if(D.type==="leaf"&&D.row){const R=D.row;J.push(M.map((U,G)=>(G===0?$:"")+Hi(R,U)))}else if(D.type==="group-subtotal"&&D.aggregatedValues){const R=K(D.aggregatedValues);J.push(R.map((U,G)=>G===0?`${$}${St("Subtotal",U)}`:U))}else D.type==="grand-total"&&D.aggregatedValues&&(te=[K(D.aggregatedValues).map((U,G)=>G===0?St("Grand Total",U):U)])});else{J=_.map($=>M.map(R=>Hi($,R)));const D=x?_t(_,Re(u),t,m,x):null;if(D&&x){const $=M.some(U=>x[U.field]);te=[K(D).map((U,G)=>G===0&&$?St("TOTAL",U):U)]}}J=J.map(D=>D.map(X)),te&&(te=te.map(D=>D.map(X))),W&&console.warn('[exportToPdf] Some characters cannot be drawn with the built-in Helvetica font and were replaced with "?". Pass the `font` option (a Unicode .ttf, e.g. Noto Sans) to draw them.');const ne=jc(M,P),[Z,de,ae]=Wi(f,zc),[oe,se,re]=Wi(w,Kc);r(C,{head:A,body:J,...te?{foot:te}:{},startY:F,styles:{fontSize:p,cellPadding:3,font:O,overflow:"linebreak"},headStyles:{fillColor:[Z,de,ae],textColor:[oe,se,re],fontStyle:"bold"},...h?{alternateRowStyles:{fillColor:[248,250,252]}}:{},...te?{footStyles:{fillColor:[241,245,249],fontStyle:"bold",textColor:[0,0,0]}}:{},columnStyles:ne,showFoot:te?"lastPage":"never",showHead:"everyPage",margin:{top:E,left:E,right:E,bottom:E+6}});const B=C.getNumberOfPages();for(let D=1;D<=B;D++)C.setPage(D),C.setFontSize(8),C.setTextColor(150,150,150),C.text(`Page ${D} of ${B}`,N-E,T-8,{align:"right"});C.save(`${i}.pdf`)}function Ut(e,t){const o=Kt(e,t);return{text:xo(e,t,o),raw:o}}function Mt(e,t,o){return e.map(n=>xn(n,o[n.field],t[n.field],t))}const Jc="\uFEFF";function Qc(e,t,o={}){const{fileName:n="export.csv",includeHeaders:r=!0,delimiter:i=",",selectedRows:l,groupedRows:c,escapeFormulas:d=!0,bom:u=!0}=o,g=st(t),m=o.aggregationModel||{},x=(f,w=!1)=>yo(d?bo(f,w):f,i),v=()=>g.map(f=>x(f.headerName||f.field)).join(i)+`
5
+ `;let h="";if(zt(c,l))r&&(h+=v()),c.forEach(f=>{const w=" ".repeat(f.depth);if(f.type==="group-header"){const p=Et(f,t),b=yo(w+(d?bo(p):p),i);h+=g.map((y,C)=>C===0?b:"").join(i)+`
6
+ `}else if(f.type==="leaf"&&f.row){const p=f.row,b=g.map((y,C)=>{const N=Ut(p,y),T=d?bo(N.text,Je(N.raw)):N.text;return yo((C===0?w:"")+T,i)});h+=b.join(i)+`
7
+ `}else if((f.type==="group-subtotal"||f.type==="grand-total")&&f.aggregatedValues){const p=f.aggregatedValues,b=f.type==="grand-total"?"Grand Total":`${w}Subtotal`,y=Mt(g,p,m),C=g.map((N,T)=>T===0?yo(St(b,y[0]),i):x(y[T],Je(p[N.field])));h+=C.join(i)+`
8
+ `}});else{const f=Vt(e,l,o.getRowId);if(f.length===0){console.warn("No rows to export");return}r&&(h+=v()),f.forEach(p=>{const b=g.map(y=>{const C=Ut(p,y);return x(C.text,Je(C.raw))});h+=b.join(i)+`
9
+ `});const w=_t(f,Re(l),t,o.aggregationResult,o.aggregationModel);if(w){const p=g.map(y=>x(m[y.field]?m[y.field].toUpperCase():""));h+=p.join(i)+`
10
+ `;const b=Mt(g,w,m);h+=g.map((y,C)=>x(b[C],Je(w[y.field]))).join(i)+`
11
+ `}}yn((u?Jc:"")+h,n,"text/csv;charset=utf-8;")}function yo(e,t){return t!==""&&e.includes(t)||e.includes('"')||e.includes(`
12
+ `)||e.includes("\r")?`"${e.replace(/"/g,'""')}"`:e}const Co="ogx-xls-text";function Zc(e,t){return e.type!=="number"&&e.type!=="date"&&e.type!=="boolean"&&!Je(t)}function eu(e){if(!/\.xlsx$/i.test(e))return e;const t=e.replace(/\.xlsx$/i,".xls");return console.warn(`[exportToExcel] "${e}" renamed to "${t}": exportToExcel writes an HTML table that Excel refuses to open as .xlsx. Use exportToExcelAdvanced for a real .xlsx file.`),t}function tu(e,t,o={}){const{fileName:n="export.xls",sheetName:r="Sheet1",includeHeaders:i=!0,selectedRows:l,groupedRows:c,escapeFormulas:d=!0}=o,u=st(t),g=o.aggregationModel||{},m=(w,p=!1)=>_e(d?bo(w,p):w),x=w=>`<td class="${Co}">${w}</td>`;let h=`<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>${_e(bn(r))}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--><meta charset="UTF-8"><style>.${Co}{mso-number-format:"\\@";}</style></head><body><table border="1">`;i&&(h+="<thead><tr>",u.forEach(w=>{h+=`<th class="${Co}">${m(w.headerName||w.field)}</th>`}),h+="</tr></thead>"),h+="<tbody>";const f=(w,p,b="")=>{const y=b+m(w.text,Je(w.raw));return Zc(p,w.raw)?x(y):`<td>${y}</td>`};if(zt(c,l))c.forEach(w=>{const p=" ".repeat(w.depth*2);if(w.type==="group-header")h+='<tr style="font-weight:bold;background:#e8eaf6;">',h+=`<td colspan="${u.length}" class="${Co}">${_e(p)}${m(Et(w,t))}</td>`,h+="</tr>";else if(w.type==="leaf"&&w.row){const b=w.row;h+="<tr>",u.forEach((y,C)=>{h+=f(Ut(b,y),y,C===0?_e(p):"")}),h+="</tr>"}else if((w.type==="group-subtotal"||w.type==="grand-total")&&w.aggregatedValues){const b=w.aggregatedValues,y=w.type==="grand-total"?"Grand Total":`${p}Subtotal`,C=Mt(u,b,g);h+='<tr style="font-weight:bold;background:#f5f5f5;">',u.forEach((N,T)=>{if(T===0){h+=x(_e(St(y,C[0])));return}h+=C[T]?`<td style="text-align:right;">${m(C[T],Je(b[N.field]))}</td>`:"<td></td>"}),h+="</tr>"}});else{const w=Vt(e,l,o.getRowId);if(w.length===0){console.warn("No rows to export");return}w.forEach(b=>{h+="<tr>",u.forEach(y=>{h+=f(Ut(b,y),y)}),h+="</tr>"});const p=_t(w,Re(l),t,o.aggregationResult,o.aggregationModel);if(p){h+='<tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',u.forEach(y=>{h+=g[y.field]?`<td style="text-align:right;font-weight:bold;">${_e(g[y.field].toUpperCase())}</td>`:"<td></td>"}),h+='</tr><tr style="font-weight:bold;background-color:#f5f5f5;">';const b=Mt(u,p,g);u.forEach((y,C)=>{h+=b[C]?`<td style="text-align:right;">${m(b[C],Je(p[y.field]))}</td>`:"<td></td>"}),h+="</tr>"}}h+="</tbody></table></body></html>",yn(h,eu(n),"application/vnd.ms-excel")}function ou(e,t,o={}){const{fileName:n="export.json",pretty:r=!0,selectedRows:i,groupedRows:l}=o,c=st(t),d=g=>{const m={};return c.forEach(x=>{m[x.field]=Kt(g,x)}),m};let u;if(zt(l,i)){const g=[],m=[];let x;l.forEach(v=>{if(v.type==="group-header"){const h={group:Et(v,t),field:v.groupField??"",value:v.groupValue,rows:[],children:[]};for(;g.length>v.depth;)g.pop();g.length===0?m.push(h):(g[g.length-1].children??=[]).push(h),g.push(h)}else v.type==="leaf"&&v.row?g.length>0&&g[g.length-1].rows.push(d(v.row)):v.type==="group-subtotal"&&v.aggregatedValues&&g.length>0?(g[g.length-1].subtotals=_i(v.aggregatedValues,c),g.pop()):v.type==="grand-total"&&v.aggregatedValues&&(x=_i(v.aggregatedValues,c))}),u=x?{groups:m,grandTotal:x}:{groups:m}}else{const g=Vt(e,i,o.getRowId);if(g.length===0){console.warn("No rows to export");return}const m=g.map(d),x=_t(g,Re(i),t,o.aggregationResult,o.aggregationModel);if(x){const v=o.aggregationModel||{},h={};c.forEach(w=>{v[w.field]&&(h[w.field]=v[w.field].toUpperCase())});const f={};c.forEach(w=>{x[w.field]!==void 0&&x[w.field]!==null&&(f[w.field]=x[w.field])}),u={data:m,aggregation:{labels:h,values:f}}}else u=m}yn(r?JSON.stringify(u,null,2):JSON.stringify(u),n,"application/json;charset=utf-8;")}const nu=/^(?:https?:|data:image\/|blob:)/i,ru=/^[a-z][a-z\d+.-]*:/i;function iu(e){const t=e.trim();return t?nu.test(t)?t:ru.test(t)?null:t:null}async function lu(e,t,o){const n=window.open("","_blank");if(!n){console.error("Failed to open print window. Please check your popup blocker settings.");return}n.document.write(`
19
13
  <!DOCTYPE html>
20
14
  <html>
21
15
  <head>
@@ -35,16 +29,16 @@ ${x}`;try{await ar(w)}catch(b){console.error("[OpenGridX] Failed to copy to clip
35
29
  </div>
36
30
  </body>
37
31
  </html>
38
- `),o.document.close(),await new Promise(l=>setTimeout(l,100));try{let l="Print",s,d=null,a=null,f;typeof e=="string"?l=e:typeof e=="object"&&(l=e.title||"Print",s=e.selectedRows,d=e.aggregationResult||null,a=e.aggregationModel||null,f=e.groupedRows);const p=t.filter(b=>!(b.exportable===!1||b.field==="__check__"||b.field==="__actions__"));let x=`<!DOCTYPE html><html><head><title>${l||"Print"}</title><style>
32
+ `),n.document.close(),await new Promise(r=>setTimeout(r,100));try{let r="Print",i,l,c=null,d=null,u;typeof o=="string"?r=o:typeof o=="object"&&(r=o.title||"Print",i=o.selectedRows,l=o.getRowId,c=o.aggregationResult||null,d=o.aggregationModel||null,u=o.groupedRows);const g=st(t),m=d||{};let x=`<!DOCTYPE html><html><head><title>${_e(r||"Print")}</title><style>
39
33
  body{font-family:Arial,sans-serif;margin:20px;}
40
34
  h1{font-size:24px;margin-bottom:20px;}
41
35
  table{border-collapse:collapse;width:100%;}
42
36
  th,td{border:1px solid #ddd;padding:8px;text-align:left;}
43
37
  th{background-color:#f5f5f5;font-weight:bold;}
44
38
  tr:nth-child(even){background-color:#f9f9f9;}
45
- .group-header{background:#e8eaf6;font-weight:bold;}
46
- .group-subtotal{background:#f0f4ff;font-style:italic;}
47
- .grand-total{background:#f5f5f5;font-weight:bold;}
39
+ tr.group-header{background:#e8eaf6;font-weight:bold;}
40
+ tr.group-subtotal{background:#f0f4ff;font-style:italic;}
41
+ tr.grand-total{background:#f5f5f5;font-weight:bold;}
48
42
  @media print{body{margin:0;}@page{margin:1cm;}}
49
- </style></head><body>`;if(l&&(x+=`<h1>${we(l)}</h1>`),x+="<table><thead><tr>",p.forEach(b=>{x+=`<th>${we(b.headerName||b.field)}</th>`}),x+="</tr></thead><tbody>",f&&f.length>0){const b=a||{};f.forEach(c=>{if(c.type==="group-header"){const m=`${"&nbsp;".repeat(c.depth*4)}${we(c.groupField??"")}: ${we(String(c.groupValue??""))}`;x+=`<tr class="group-header"><td colspan="${p.length}">${m}</td></tr>`}else if(c.type==="leaf"&&c.row){const g=c.row,m="&nbsp;".repeat(c.depth*4);x+="<tr>",p.forEach((_,E)=>{let v=g[_.field];_.valueGetter&&(v=_.valueGetter({row:g,field:_.field,value:v})),_.valueFormatter&&v!==void 0&&v!==null&&(v=_.valueFormatter({value:v,row:g,field:_.field})),_.type==="image"&&v?x+=`<td><img src="${v}" style="max-height:40px;border-radius:4px;"></td>`:x+=`<td>${(E===0?m:"")+we(String(v??""))}</td>`}),x+="</tr>"}else if((c.type==="group-subtotal"||c.type==="grand-total")&&c.aggregatedValues){const g=c.type==="grand-total",m=g?"":"&nbsp;".repeat(c.depth*4),_=g?"Grand Total":`${m}Subtotal`;x+=`<tr class="${g?"grand-total":"group-subtotal"}">`,p.forEach((v,S)=>{if(S===0){x+=`<td>${_}</td>`;return}const N=c.aggregatedValues[v.field];if(N!=null){let h=N;v.valueFormatter?h=v.valueFormatter({value:N,row:{},field:v.field}):b[v.field]&&(h=_e(N,b[v.field])),x+=`<td style="text-align:right;">${we(String(h))}</td>`}else x+="<td></td>"}),x+="</tr>"}})}else{const b=s&&s.length>0?n.filter(c=>s.includes(c.id)):n;if(b.length===0){o.document.body.innerHTML="<h3>No rows to export</h3>";return}if(b.forEach(c=>{x+="<tr>",p.forEach(g=>{let m=c[g.field];g.valueGetter&&(m=g.valueGetter({row:c,field:g.field,value:m})),g.valueFormatter&&m!==void 0&&m!==null&&(m=g.valueFormatter({value:m,row:c,field:g.field})),g.type==="image"&&m?x+=`<td><div style="display:flex;justify-content:center;"><img src="${m}" alt="${g.headerName}" style="max-height:40px;border-radius:4px;"></div></td>`:x+=`<td>${we(String(m??""))}</td>`}),x+="</tr>"}),d){const c=a||{};x+='<tfoot><tr style="font-size:11px;color:#666;background-color:#f5f5f5;">',p.forEach(g=>{x+=c[g.field]?`<td style="text-align:right;font-weight:bold;">${we(c[g.field].toUpperCase())}</td>`:"<td></td>"}),x+='</tr><tr style="font-weight:bold;background-color:#f5f5f5;">',p.forEach(g=>{const m=d[g.field];if(m!=null){let _=m;g.valueFormatter?_=g.valueFormatter({value:m,row:{},field:g.field}):c[g.field]&&(_=_e(m,c[g.field])),x+=`<td style="text-align:right;">${we(String(_))}</td>`}else x+="<td></td>"}),x+="</tr></tfoot>"}}x+="</tbody></table></body></html>",o.document.open(),o.document.write(x),o.document.close(),o.document.title=l||"Print Preview",o.focus();let w=!1;o.onload=()=>{w||(w=!0,o.print(),setTimeout(()=>{o.close()},100))},setTimeout(()=>{!w&&o&&!o.closed&&(w=!0,o.print(),setTimeout(()=>{o.closed||o.close()},100))},500)}catch(l){if(console.error("Print generation failed:",l),o&&!o.closed){const s=l instanceof Error?l.message:String(l);o.document.body.innerHTML=`<div style="color: red; padding: 20px;"><h3>Error Generating Print Preview</h3><p>${s}</p></div>`}}}function tn(n,t,e){const o=new Blob([n],{type:e}),l=URL.createObjectURL(o),s=document.createElement("a");s.href=l,s.download=t,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(l)}function ti(n,t){return n.type==="number"?"number":n.type==="boolean"?"boolean":n.type==="date"?"date":typeof t=="number"?"number":typeof t=="boolean"?"boolean":t instanceof Date?"date":"string"}function ni(n){if(n.type==="number")return"#,##0.##";if(n.type==="date")return"yyyy-mm-dd"}function oi(n,t){if(t!=null)return t;const e=n.width??120;return Math.min(60,Math.max(8,(e-5)/7))}function ri(n,t){const e=t??"";if(e.includes("jpeg")||e.includes("jpg"))return"jpeg";if(e.includes("gif"))return"gif";const o=n.split("?")[0].toLowerCase();return o.endsWith(".jpg")||o.endsWith(".jpeg")?"jpeg":o.endsWith(".gif")?"gif":"png"}async function ii(n){const t=await Promise.allSettled(n.map(async o=>{if(o.startsWith("data:")){const a=o.indexOf(","),f=o.slice(0,a),p=o.slice(a+1),x=atob(p),w=new Uint8Array(x.length);for(let m=0;m<x.length;m++)w[m]=x.charCodeAt(m);const c=f.match(/data:([^;,]+)/)?.[1]??"image/png";let g="png";return c.includes("jpeg")||c.includes("jpg")?g="jpeg":c.includes("gif")&&(g="gif"),{url:o,buffer:w.buffer,ext:g}}const l=await fetch(o,{mode:"cors"});if(!l.ok)throw new Error(`HTTP ${l.status}`);const s=await l.arrayBuffer(),d=ri(o,l.headers.get("content-type"));return{url:o,buffer:s,ext:d}})),e=new Map;return t.forEach((o,l)=>{o.status==="fulfilled"?e.set(o.value.url,{buffer:o.value.buffer,extension:o.value.ext}):console.warn(`[exportToExcelAdvanced] Cannot embed image "${n[l]}" (CORS/network error — raw URL written as fallback):`,o.reason)}),e}async function li(n,t,e={}){const{fileName:o="export.xlsx",sheets:l,columnStyles:s={},headerFillColor:d="#f1f5f9",headerTextColor:a="#334155",headerFontSize:f=10,bodyFontSize:p=10,aggregationResult:x=null,aggregationModel:w=null,selectedRows:b}=e,c=(await import("exceljs")).default,g=new c.Workbook;g.creator="OpenGridX",g.created=new Date;const m=t.filter(j=>j.exportable!==!1&&j.field!=="__check__"&&j.field!=="__actions__"&&!j.isSpacer),_=n,E=b&&b.length>0?n.filter(j=>b.includes(j.id)):n,v=l??[{name:"Data",rows:"all",includeHeaders:!0,includeSummary:!1}],S=new Map;for(const j of v){if("type"in j&&j.type==="summary"){if(!x||!w)continue;const C=g.addWorksheet(j.name??"Summary");C.addRow(["Summary / Aggregation Totals"]),C.getRow(1).font={bold:!0,size:f+2,color:{argb:$e(a)}},C.addRow([]),C.addRow(["Column","Function","Value"]).eachCell(L=>{L.fill={type:"pattern",pattern:"solid",fgColor:{argb:$e(d)}},L.font={bold:!0,size:f,color:{argb:$e(a)}},L.border=Dn()}),m.forEach(L=>{const O=w[L.field],H=x[L.field];if(O==null||H==null)return;let U=H;L.valueFormatter?U=L.valueFormatter({value:H,row:{},field:L.field}):U=_e(H,O);const K=C.addRow([L.headerName??L.field,O.toUpperCase(),U]);K.getCell(3).alignment={horizontal:"right"},K.getCell(3).font={bold:!0,size:p}}),C.getColumn(1).width=20,C.getColumn(2).width=12,C.getColumn(3).width=18;continue}const P=j,{name:F="Data",rows:k="all",includeHeaders:I=!0,includeSummary:R=!1,autoFilter:W=!0,frozenHeader:$=!0,alternateRowColor:D="#f8fafc"}=P,A=k==="selected"?E:_,z=m.filter(C=>s[C.field]?.embedImage);if(z.length>0){const C=[],M=new Set;if(A.forEach(L=>{z.forEach(O=>{const H=L[O.field];typeof H=="string"&&H&&!S.has(H)&&!M.has(H)&&(C.push(H),M.add(H))})}),C.length>0){const L=await ii(C);for(const[O,{buffer:H,extension:U}]of L){const K=g.addImage({buffer:H,extension:U});S.set(O,K)}}}const Y=g.addWorksheet(F);if(Y.columns=m.map(C=>({key:C.field,width:oi(C,s[C.field]?.width),style:{numFmt:s[C.field]?.numFmt??ni(C)}})),I){const C=m.map(L=>L.headerName??L.field),M=Y.addRow(C);M.height=20,M.eachCell((L,O)=>{const H=m[O-1];L.fill={type:"pattern",pattern:"solid",fgColor:{argb:$e(d)}},L.font={bold:!0,size:f,color:{argb:$e(a)}},L.alignment={horizontal:s[H?.field]?.alignment??(H?.type==="number"?"right":"left"),vertical:"middle"},L.border=Dn()}),W&&(Y.autoFilter={from:{row:1,column:1},to:{row:1,column:m.length}}),$?Y.views=[{state:"frozen",ySplit:1,showGridLines:!1}]:Y.views=[{showGridLines:!1}]}let V=I?1:0;if(A.forEach((C,M)=>{const L=m.map(H=>{if(s[H.field]?.embedImage)return"";let U=C[H.field];return H.valueGetter&&(U=H.valueGetter({row:C,field:H.field,value:U})),ti(H,U)==="string"&&H.valueFormatter&&U!=null&&(U=H.valueFormatter({value:U,row:C,field:H.field})),U}),O=Y.addRow(L);if(O.font={size:p},D&&M%2===1&&O.eachCell(H=>{H.fill={type:"pattern",pattern:"solid",fgColor:{argb:$e(D)}}}),O.eachCell((H,U)=>{const K=m[U-1];K&&(H.alignment={horizontal:s[K.field]?.alignment??(K.type==="number"?"right":"left"),vertical:"middle"},H.border={bottom:{style:"thin",color:{argb:"FFf1f5f9"}}})}),z.length>0){const H=z.reduce((oe,ie)=>Math.max(oe,s[ie.field]?.imageHeight??40),0),U=Math.ceil(H/1.333),K=U*1.333;O.height=U,z.forEach(oe=>{const ie=m.indexOf(oe),ne=C[oe.field],T=typeof ne=="string"?S.get(ne):void 0;if(T===void 0){O.getCell(ie+1).value=typeof ne=="string"?ne:"";return}const le=s[oe.field],te=le?.imageWidth??40,re=le?.imageHeight??40,J=(Y.getColumn(ie+1).width??8)*7+5,de=Math.max(0,J-te)/2,B=Math.max(0,K-re)/2;Y.addImage(T,{tl:{col:ie,row:V,nativeColOff:Math.floor(de*9525),nativeRowOff:Math.floor(B*9525)},ext:{width:te,height:re},editAs:"oneCell"})})}else O.height=16;V++}),R&&x&&w){const C=m.map(H=>{const U=w[H.field];return U?U.toUpperCase():""}),M=Y.addRow(C);M.height=16,M.font={size:p-1,italic:!0,color:{argb:"FF94a3b8"}},M.eachCell(H=>{H.alignment={horizontal:"right",vertical:"middle"},H.border={top:{style:"thin",color:{argb:"FFcbd5e1"}}}});const L=m.map(H=>{const U=w[H.field],K=x[H.field];return U==null||K==null?"":H.valueFormatter?H.valueFormatter({value:K,row:{},field:H.field}):_e(K,U)}),O=Y.addRow(L);O.height=18,O.font={bold:!0,size:p,color:{argb:$e(a)}},O.eachCell(H=>{H.fill={type:"pattern",pattern:"solid",fgColor:{argb:$e(d)}},H.alignment={horizontal:"right",vertical:"middle"},H.border=si()})}}const N=await g.xlsx.writeBuffer(),h=new Blob([N],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),y=URL.createObjectURL(h),u=document.createElement("a");u.href=y,u.download=o.endsWith(".xlsx")?o:`${o}.xlsx`,document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL(y)}function $e(n){const t=n.replace("#","");return t.length===3?"FF"+t.split("").map(e=>e+e).join(""):t.length===6?"FF"+t:"FF"+t.padEnd(6,"0")}function Dn(){return{bottom:{style:"medium",color:{argb:"FFcbd5e1"}}}}function si(){return{top:{style:"medium",color:{argb:"FFcbd5e1"}}}}const ai={"--ogx-color-primary":"#3b82f6","--ogx-color-primary-dark":"#2563eb","--ogx-color-primary-light":"#eff6ff","--ogx-color-primary-focus":"rgba(59, 130, 246, 0.5)","--ogx-color-secondary":"#8b5cf6","--ogx-color-secondary-dark":"#7c3aed","--ogx-color-secondary-light":"#f5f3ff","--ogx-color-white":"#ffffff","--ogx-color-black":"#0f172a","--ogx-border-color":"#e2e8f0","--ogx-border-color-hover":"#cbd5e1","--ogx-shadow-sm":"0 1px 2px 0 rgba(0, 0, 0, 0.05)","--ogx-shadow-md":"0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03)","--ogx-shadow-lg":"0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02)","--ogx-grid-background":"#ffffff","--ogx-grid-border-color":"#e2e8f0","--ogx-grid-header-background":"#f8fafc","--ogx-grid-header-text":"#334155","--ogx-grid-header-hover-background":"#f1f5f9","--ogx-grid-header-sorted-background":"#f8fafc","--ogx-grid-row-text":"#1e293b","--ogx-grid-row-hover-background":"#f8fafc","--ogx-grid-row-alternate-background":"transparent","--ogx-grid-row-selected-background":"#eff6ff","--ogx-grid-row-selected-hover-background":"#dbeafe","--ogx-grid-cell-focus-border":"#3b82f6","--ogx-checkbox-bg":"#ffffff","--ogx-checkbox-border":"#94a3b8","--ogx-grid-pinned-left-shadow":"4px 0 24px -4px rgba(0, 0, 0, 0.05)","--ogx-grid-pinned-right-shadow":"-4px 0 24px -4px rgba(0, 0, 0, 0.05)","--ogx-toolbar-background":"transparent","--ogx-toolbar-text":"#1e293b","--ogx-toolbar-border":"#e2e8f0","--ogx-toolbar-btn-bg":"transparent","--ogx-toolbar-btn-hover":"#f1f5f9","--ogx-toolbar-btn-text":"#334155","--ogx-toolbar-btn-primary-bg":"#3b82f6","--ogx-toolbar-btn-primary-hover":"#2563eb","--ogx-toolbar-btn-primary-text":"#ffffff","--ogx-toolbar-btn-danger-bg":"rgba(239, 68, 68, 0.08)","--ogx-toolbar-btn-danger-hover":"rgba(239, 68, 68, 0.15)","--ogx-toolbar-btn-danger-text":"#ef4444","--ogx-toolbar-input-bg":"#ffffff","--ogx-toolbar-input-text":"#1e293b","--ogx-toolbar-input-border":"#cbd5e1","--ogx-toolbar-input-focus-border":"#3b82f6","--ogx-toolbar-input-focus-shadow":"0 0 0 3px rgba(59, 130, 246, 0.12)","--ogx-toolbar-chip-bg":"#f1f5f9","--ogx-toolbar-chip-text":"#475569","--ogx-toolbar-chip-active-bg":"rgba(59, 130, 246, 0.12)","--ogx-toolbar-chip-active-text":"#2563eb","--ogx-overlay-background":"#ffffff","--ogx-overlay-text":"#1e293b","--ogx-overlay-border":"#e2e8f0","--ogx-overlay-shadow":"0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.06)","--ogx-overlay-item-hover-bg":"#f8fafc","--ogx-overlay-item-hover-text":"#0f172a","--ogx-overlay-item-selected-bg":"rgba(59, 130, 246, 0.08)","--ogx-overlay-item-selected-text":"#2563eb","--ogx-overlay-item-danger-bg":"rgba(239, 68, 68, 0.08)","--ogx-overlay-item-danger-text":"#ef4444","--ogx-scrollbar-thumb":"rgba(148, 163, 184, 0.5)","--ogx-scrollbar-track":"transparent","--ogx-scrollbar-size":"10px","--ogx-skeleton-base":"#f1f5f9","--ogx-skeleton-highlight":"#ffffff","--ogx-skeleton-dark-base":"#e2e8f0","--ogx-skeleton-dark-highlight":"#f8fafc"};function di(n){const t={};function e(o,l){l!==void 0&&(t[o]=l)}if(n.colors){const o=n.colors;e("--ogx-color-primary",o.primary),e("--ogx-color-primary-dark",o.primaryDark),e("--ogx-color-primary-light",o.primaryLight),e("--ogx-color-primary-focus",o.primaryFocus),e("--ogx-color-secondary",o.secondary),e("--ogx-color-secondary-dark",o.secondaryDark),e("--ogx-color-secondary-light",o.secondaryLight),e("--ogx-color-success",o.success),e("--ogx-color-warning",o.warning),e("--ogx-color-error",o.error),e("--ogx-color-info",o.info)}if(n.typography){const o=n.typography;e("--ogx-font-family",o.fontFamily),e("--ogx-font-family-mono",o.fontFamilyMono),e("--ogx-font-size-xs",o.fontSizeXs),e("--ogx-font-size-sm",o.fontSizeSm),e("--ogx-font-size-md",o.fontSizeMd),e("--ogx-font-size-lg",o.fontSizeLg),e("--ogx-font-size-xl",o.fontSizeXl)}if(n.spacing){const o=n.spacing;e("--ogx-spacing-xs",o.xs),e("--ogx-spacing-sm",o.sm),e("--ogx-spacing-md",o.md),e("--ogx-spacing-lg",o.lg),e("--ogx-spacing-xl",o.xl),e("--ogx-spacing-xxl",o.xxl)}if(n.borders){const o=n.borders;e("--ogx-border-width-thin",o.widthThin),e("--ogx-border-width-medium",o.widthMedium),e("--ogx-border-width-thick",o.widthThick),e("--ogx-border-radius-sm",o.radiusSm),e("--ogx-border-radius-md",o.radiusMd),e("--ogx-border-radius-lg",o.radiusLg),e("--ogx-border-radius-xl",o.radiusXl),e("--ogx-border-color",o.color),e("--ogx-border-color-hover",o.colorHover)}if(n.shadows){const o=n.shadows;e("--ogx-shadow-sm",o.sm),e("--ogx-shadow-md",o.md),e("--ogx-shadow-lg",o.lg),e("--ogx-shadow-xl",o.xl)}if(n.grid){const o=n.grid;e("--ogx-grid-row-height-compact",o.rowHeightCompact),e("--ogx-grid-row-height-standard",o.rowHeightStandard),e("--ogx-row-height",o.rowHeightStandard),e("--ogx-grid-row-height-comfortable",o.rowHeightComfortable),e("--ogx-grid-header-height",o.headerHeight),e("--ogx-header-height",o.headerHeight),e("--ogx-grid-cell-padding-x",o.cellPaddingX),e("--ogx-grid-cell-padding-y",o.cellPaddingY),e("--ogx-grid-background",o.background),e("--ogx-grid-border-color",o.borderColor),e("--ogx-grid-header-background",o.headerBackground),e("--ogx-grid-header-text",o.headerText),e("--ogx-grid-header-hover-background",o.headerHoverBackground),e("--ogx-grid-header-sorted-background",o.headerSortedBackground),e("--ogx-grid-row-text",o.rowText),e("--ogx-grid-row-hover-background",o.rowHoverBackground),e("--ogx-grid-row-alternate-background",o.rowAlternateBackground),e("--ogx-grid-row-selected-background",o.rowSelectedBackground),e("--ogx-grid-row-selected-hover-background",o.rowSelectedHoverBackground),e("--ogx-grid-cell-focus-border",o.cellFocusBorder),e("--ogx-grid-pinned-left-shadow",o.pinnedLeftShadow),e("--ogx-grid-pinned-right-shadow",o.pinnedRightShadow),e("--ogx-checkbox-bg",o.checkboxBg),e("--ogx-checkbox-border",o.checkboxBorder)}if(n.transitions){const o=n.transitions;e("--ogx-transition-duration-fast",o.durationFast),e("--ogx-transition-duration-normal",o.durationNormal),e("--ogx-transition-duration-slow",o.durationSlow),e("--ogx-transition-easing",o.easing)}if(n.toolbar){const o=n.toolbar;e("--ogx-toolbar-background",o.background),e("--ogx-toolbar-text",o.text),e("--ogx-toolbar-border",o.border),e("--ogx-toolbar-btn-bg",o.buttonBackground),e("--ogx-toolbar-btn-hover",o.buttonHoverBackground),e("--ogx-toolbar-btn-text",o.buttonText),e("--ogx-toolbar-btn-primary-bg",o.buttonPrimaryBackground),e("--ogx-toolbar-btn-primary-hover",o.buttonPrimaryHoverBackground),e("--ogx-toolbar-btn-primary-text",o.buttonPrimaryText),e("--ogx-toolbar-btn-danger-bg",o.buttonDangerBackground),e("--ogx-toolbar-btn-danger-hover",o.buttonDangerHoverBackground),e("--ogx-toolbar-btn-danger-text",o.buttonDangerText),e("--ogx-toolbar-input-bg",o.inputBackground),e("--ogx-toolbar-input-text",o.inputText),e("--ogx-toolbar-input-border",o.inputBorder),e("--ogx-toolbar-input-focus-border",o.inputFocusBorder),e("--ogx-toolbar-input-focus-shadow",o.inputFocusShadow),e("--ogx-toolbar-chip-bg",o.chipBackground),e("--ogx-toolbar-chip-text",o.chipText),e("--ogx-toolbar-chip-active-bg",o.chipActiveBackground),e("--ogx-toolbar-chip-active-text",o.chipActiveText)}if(n.overlays){const o=n.overlays;e("--ogx-overlay-background",o.background),e("--ogx-overlay-text",o.text),e("--ogx-overlay-border",o.border),e("--ogx-overlay-shadow",o.shadow),e("--ogx-overlay-item-hover-bg",o.itemHoverBackground),e("--ogx-overlay-item-hover-text",o.itemHoverText),e("--ogx-overlay-item-selected-bg",o.itemSelectedBackground),e("--ogx-overlay-item-selected-text",o.itemSelectedText),e("--ogx-overlay-item-danger-bg",o.itemDangerBackground),e("--ogx-overlay-item-danger-text",o.itemDangerText)}if(n.scrollbar){const o=n.scrollbar;e("--ogx-scrollbar-thumb",o.thumbColor),e("--ogx-scrollbar-track",o.trackColor),e("--ogx-scrollbar-size",o.size)}if(n.skeleton){const o=n.skeleton;e("--ogx-skeleton-base",o.baseColor),e("--ogx-skeleton-highlight",o.highlightColor),e("--ogx-skeleton-dark-base",o.darkBaseColor),e("--ogx-skeleton-dark-highlight",o.darkHighlightColor)}return t}function ci({theme:n,children:t,className:e,style:o}){const l=i.useMemo(()=>({...ai,...di(n)}),[n]);return r.jsx("div",{className:`ogx-theme-provider ${e||""}`.trim(),style:{...o,...l},children:t})}const ui={colors:{primary:"#60a5fa",primaryDark:"#3b82f6",primaryLight:"#1e3a5f",primaryFocus:"rgba(96, 165, 250, 0.4)"},grid:{background:"#0f172a",headerBackground:"#1e293b",headerText:"#e2e8f0",headerHoverBackground:"#334155",headerSortedBackground:"#1e3a5f",rowText:"#cbd5e1",borderColor:"#334155",rowHoverBackground:"#1e293b",rowAlternateBackground:"#162032",rowSelectedBackground:"#1e3a5f",rowSelectedHoverBackground:"#1d4ed8",cellFocusBorder:"#60a5fa",checkboxBg:"#1e293b",checkboxBorder:"#64748b"},borders:{color:"#334155",colorHover:"#475569"},shadows:{sm:"0 1px 2px 0 rgba(0, 0, 0, 0.3)",md:"0 4px 6px -1px rgba(0, 0, 0, 0.3)"},toolbar:{background:"transparent",text:"#cbd5e1",border:"#334155",buttonBackground:"transparent",buttonHoverBackground:"#1e293b",buttonText:"#e2e8f0",buttonPrimaryBackground:"#3b82f6",buttonPrimaryHoverBackground:"#2563eb",buttonPrimaryText:"#ffffff",buttonDangerBackground:"rgba(239, 68, 68, 0.15)",buttonDangerHoverBackground:"rgba(239, 68, 68, 0.25)",buttonDangerText:"#fca5a5",inputBackground:"#0f172a",inputText:"#f8fafc",inputBorder:"#334155",inputFocusBorder:"#60a5fa",inputFocusShadow:"0 0 0 3px rgba(96, 165, 250, 0.2)",chipBackground:"#1e293b",chipText:"#94a3b8",chipActiveBackground:"rgba(96, 165, 250, 0.2)",chipActiveText:"#60a5fa"},overlays:{background:"#1e293b",text:"#f8fafc",border:"#334155",shadow:"0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3)",itemHoverBackground:"#334155",itemHoverText:"#ffffff",itemSelectedBackground:"rgba(96, 165, 250, 0.15)",itemSelectedText:"#60a5fa",itemDangerBackground:"rgba(239, 68, 68, 0.15)",itemDangerText:"#fca5a5"},scrollbar:{thumbColor:"rgba(148, 163, 184, 0.2)",trackColor:"transparent"},skeleton:{baseColor:"#1e293b",highlightColor:"#334155",darkBaseColor:"#0f172a",darkHighlightColor:"#1e293b"}},fi={colors:{primary:"#e11d48",primaryDark:"#be123c",primaryLight:"#fff1f2",primaryFocus:"rgba(225, 29, 72, 0.4)"},grid:{headerBackground:"#fff1f2",headerHoverBackground:"#ffe4e6",headerSortedBackground:"#fecdd3",rowAlternateBackground:"#fff8f8",rowSelectedBackground:"#ffe4e6",rowSelectedHoverBackground:"#fecdd3",cellFocusBorder:"#e11d48"}},gi={colors:{primary:"#059669",primaryDark:"#047857",primaryLight:"#ecfdf5",primaryFocus:"rgba(5, 150, 105, 0.4)"},grid:{headerBackground:"#ecfdf5",headerHoverBackground:"#d1fae5",headerSortedBackground:"#a7f3d0",rowAlternateBackground:"#f6fdf9",rowSelectedBackground:"#d1fae5",rowSelectedHoverBackground:"#a7f3d0",cellFocusBorder:"#059669"}},hi={colors:{primary:"#d97706",primaryDark:"#b45309",primaryLight:"#fffbeb",primaryFocus:"rgba(217, 119, 6, 0.4)"},grid:{headerBackground:"#fffbeb",headerHoverBackground:"#fef3c7",headerSortedBackground:"#fde68a",rowAlternateBackground:"#fffdf5",rowSelectedBackground:"#fef3c7",rowSelectedHoverBackground:"#fde68a",cellFocusBorder:"#d97706"}},pi={grid:{rowHeightCompact:"28px",rowHeightStandard:"36px",rowHeightComfortable:"48px",headerHeight:"40px",cellPaddingX:"8px",cellPaddingY:"4px"},typography:{fontSizeSm:"0.8rem",fontSizeMd:"0.875rem"}};function xi(n,t){try{const e=t.getItem(n);return e?JSON.parse(e):void 0}catch{return}}function mi(n,t,e,o){try{const l=e?Object.fromEntries(Object.entries(t).filter(([s])=>e.includes(s))):t;o.setItem(n,JSON.stringify(l))}catch{}}function bi(n){const t=typeof n=="string"?{key:n}:n,{key:e,debounceMs:o=300,include:l,storage:s=typeof window<"u"?window.localStorage:void 0}=t,d=i.useMemo(()=>{if(s)return xi(e,s)},[e,s]),a=i.useRef(null),f=i.useRef(null),p=i.useCallback(()=>{f.current&&s&&mi(e,f.current,l,s)},[e,l,s]),x=i.useCallback(b=>{f.current=b,a.current&&clearTimeout(a.current),a.current=setTimeout(p,o)},[p,o]);i.useEffect(()=>()=>{a.current&&(clearTimeout(a.current),p())},[p]);const w=i.useCallback(()=>{s&&s.removeItem(e)},[e,s]);return{initialState:d,onStateChange:x,clearState:w}}ae.Button=bt,ae.Cell=Tn,ae.Checkbox=mt,ae.DataGrid=Mr,ae.DataGridThemeProvider=ci,ae.FilterPanel=On,ae.GridToolbar=Gr,ae.GridTooltip=vt,ae.Header=Nn,ae.Input=Ur,ae.Row=Ft,ae.Skeleton=Pr,ae.amberTheme=hi,ae.compactTheme=pi,ae.darkTheme=ui,ae.emeraldTheme=gi,ae.exportToCsv=Jr,ae.exportToExcel=Qr,ae.exportToExcelAdvanced=li,ae.exportToJson=Zr,ae.exportToPdf=Xr,ae.formatAggregationValue=_e,ae.printGrid=ei,ae.roseTheme=fi,ae.useAggregation=jn,ae.useGridApiRef=Vr,ae.useGridStateStorage=bi,ae.usePivot=In,Object.defineProperty(ae,Symbol.toStringTag,{value:"Module"})}));
43
+ </style></head><body>`;r&&(x+=`<h1>${_e(r)}</h1>`),x+="<table><thead><tr>",g.forEach(f=>{x+=`<th>${_e(f.headerName||f.field)}</th>`}),x+="</tr></thead><tbody>";const v=(f,w,p="",b=!1)=>{const{text:y}=Ut(f,w),C=w.type==="image"?iu(y):null;if(C!==null){const N=`<img src="${_e(C)}" alt="${_e(w.headerName||w.field)}" style="max-height:40px;border-radius:4px;">`;return b?`<td><div style="display:flex;justify-content:center;">${N}</div></td>`:`<td>${N}</td>`}return`<td>${p}${_e(y)}</td>`};if(zt(u,i))u.forEach(f=>{const w="&nbsp;".repeat(f.depth*4);if(f.type==="group-header")x+=`<tr class="group-header"><td colspan="${g.length}">${w}${_e(Et(f,t))}</td></tr>`;else if(f.type==="leaf"&&f.row){const p=f.row;x+="<tr>",g.forEach((b,y)=>{x+=v(p,b,y===0?w:"")}),x+="</tr>"}else if((f.type==="group-subtotal"||f.type==="grand-total")&&f.aggregatedValues){const p=f.type==="grand-total",b=Mt(g,f.aggregatedValues,m);x+=`<tr class="${p?"grand-total":"group-subtotal"}">`,g.forEach((y,C)=>{if(C===0){x+=`<td>${p?"":w}${_e(St(p?"Grand Total":"Subtotal",b[0]))}</td>`;return}x+=b[C]?`<td style="text-align:right;">${_e(b[C])}</td>`:"<td></td>"}),x+="</tr>"}});else{const f=Vt(e,i,l);if(f.length===0){n.document.body.innerHTML="<h3>No rows to export</h3>";return}f.forEach(p=>{x+="<tr>",g.forEach(b=>{x+=v(p,b,"",!0)}),x+="</tr>"});const w=_t(f,Re(i),t,c,d);w&&(x+='<tfoot><tr style="font-size:11px;color:#666;background-color:#f5f5f5;">',g.forEach(p=>{x+=m[p.field]?`<td style="text-align:right;font-weight:bold;">${_e(m[p.field].toUpperCase())}</td>`:"<td></td>"}),x+='</tr><tr style="font-weight:bold;background-color:#f5f5f5;">',Mt(g,w,m).forEach(p=>{x+=p?`<td style="text-align:right;">${_e(p)}</td>`:"<td></td>"}),x+="</tr></tfoot>")}x+="</tbody></table></body></html>",n.document.open(),n.document.write(x),n.document.close(),n.document.title=r||"Print Preview",n.focus();let h=!1;n.onload=()=>{h||(h=!0,n.print(),setTimeout(()=>{n.close()},100))},setTimeout(()=>{!h&&n&&!n.closed&&(h=!0,n.print(),setTimeout(()=>{n.closed||n.close()},100))},500)}catch(r){if(console.error("Print generation failed:",r),n&&!n.closed){const i=r instanceof Error?r.message:String(r);n.document.body.innerHTML=`<div style="color: red; padding: 20px;"><h3>Error Generating Print Preview</h3><p>${_e(i)}</p></div>`}}}function yn(e,t,o){const n=new Blob([e],{type:o}),r=URL.createObjectURL(n),i=document.createElement("a");i.href=r,i.download=t,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}function su(e,t){return e.type==="number"?"number":e.type==="boolean"?"boolean":e.type==="date"?"date":typeof t=="number"?"number":typeof t=="boolean"?"boolean":t instanceof Date?"date":"string"}function Xt(e){return Number.isNaN(e.getTime())?null:new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()))}const au=/^(\d{4})-(\d{2})-(\d{2})$/,du=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?$/i,cu=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?$/i;function uu(e){if(e instanceof Date)return Xt(e);if(typeof e=="number")return Number.isFinite(e)?Xt(new Date(e)):null;if(typeof e!="string")return;const t=e.trim(),o=au.exec(t);if(o){const[n,r,i]=[Number(o[1]),Number(o[2]),Number(o[3])],l=new Date(Date.UTC(n,r-1,i));return l.getUTCMonth()===r-1&&l.getUTCDate()===i?l:void 0}if(du.test(t)){const n=new Date(t.replace(" ","T"));return Number.isNaN(n.getTime())?void 0:Xt(n)}}function fu(e,t){if(t==null||t==="")return null;if(e==="number"){if(typeof t=="number")return Number.isFinite(t)?t:null;if(typeof t=="bigint"){const o=Number(t);return Number.isSafeInteger(o)?o:void 0}if(typeof t=="string"&&cu.test(t.trim())){const o=Number(t.trim());return Number.isFinite(o)?o:void 0}return}if(e==="boolean"){if(typeof t=="boolean")return t;if(typeof t=="string"){const o=t.trim().toLowerCase();if(o==="true")return!0;if(o==="false")return!1}return}return uu(t)}function zi(e){if(e==null)return null;if(typeof e=="string"||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)?e:null;if(e instanceof Date)return Xt(e);if(typeof e=="object")try{return JSON.stringify(e)??String(e)}catch{return String(e)}return String(e)}function gu(e,t){const o=Kt(e,t),n=su(t,o);if(n!=="string"){const r=fu(n,o);if(r!=null)return r;if(!t.valueFormatter)return r===null?null:zi(o)}return t.valueFormatter?xo(e,t,o):zi(o)}const Ki="#,##0",pu="#,##0.##";function hu(e){return Number.isInteger(e)?Ki:pu}function ji(e,t){if(t?.numFmt)return t.numFmt;if(e.type==="date")return"yyyy-mm-dd"}function Ui(e,t,o){if(!(t?.numFmt||typeof o!="number"||e.type!=="number"))return hu(o)}function wu(e,t){if(t!=null)return t;const o=e.width??120;return Math.min(60,Math.max(8,(o-5)/7))}function mu(e){return e.length>=8&&e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71?"png":e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255?"jpeg":e.length>=6&&e[0]===71&&e[1]===73&&e[2]===70&&e[3]===56?"gif":null}function Xi(e,t){const o=Kt(e,t);return typeof o=="string"&&o?o:null}async function xu(e){const t=await Promise.allSettled(e.map(async n=>{let r;if(n.startsWith("data:")){const l=n.slice(n.indexOf(",")+1),c=atob(l);r=new Uint8Array(c.length);for(let d=0;d<c.length;d++)r[d]=c.charCodeAt(d)}else{const l=await fetch(n,{mode:"cors"});if(!l.ok)throw new Error(`HTTP ${l.status}`);r=new Uint8Array(await l.arrayBuffer())}const i=mu(r);if(!i)throw new Error("unsupported image format (only PNG, JPEG and GIF can be embedded)");return{url:n,buffer:r.slice().buffer,ext:i}})),o=new Map;return t.forEach((n,r)=>{n.status==="fulfilled"?o.set(n.value.url,{buffer:n.value.buffer,extension:n.value.ext}):console.warn(`[exportToExcelAdvanced] Cannot embed image "${e[r]}" (CORS/network error or unsupported format — raw URL written as fallback):`,n.reason)}),o}async function bu(e,t,o={}){const{fileName:n="export.xlsx",sheets:r,columnStyles:i={},headerFillColor:l="#f1f5f9",headerTextColor:c="#334155",headerFontSize:d=10,bodyFontSize:u=10,aggregationResult:g=null,aggregationModel:m=null,selectedRows:x,getRowId:v,groupedRows:h,groupHeaderFillColor:f="#e8eaf6",groupSubtotalFillColor:w="#f0f4ff"}=o,p=(await import("exceljs")).default,b=new p.Workbook;b.creator="OpenGridX",b.created=new Date;const y=t,C=st(y),N=e,T=Re(x)?Ci(N,x,v):[],E=r??[{name:"Data",rows:"all",includeHeaders:!0,includeSummary:!1}],P=new Set,O=new Map,W=(_,F)=>{const A=F[_.field],q=m?.[_.field];if(A==null)return{value:null};const K=tr(_,q,A);return typeof K=="number"?Number.isFinite(K)?er(q)?{value:K,numFmt:Ki}:{value:K,numFmt:Ui(_,i[_.field],K)}:{value:null}:K instanceof Date?{value:Xt(K)}:{value:xn(_,q,A,F)}};for(const _ of E){if("type"in _&&_.type==="summary"){if(!g||!m)continue;const V=b.addWorksheet(bn(_.name??"Summary",P));V.addRow(["Summary / Aggregation Totals"]),V.getRow(1).font={bold:!0,size:d+2,color:{argb:Oe(c)}},V.addRow([]),V.addRow(["Column","Function","Value"]).eachCell(H=>{H.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(l)}},H.font={bold:!0,size:d,color:{argb:Oe(c)}},H.border=qi()}),C.forEach(H=>{const j=m[H.field];if(j==null||g[H.field]==null)return;const{value:z,numFmt:k}=W(H,g),Q=V.addRow([H.headerName??H.field,j.toUpperCase(),z]).getCell(3),ee=k??ji(H,i[H.field]);ee&&(Q.numFmt=ee),Q.alignment={horizontal:"right"},Q.font={bold:!0,size:u}}),V.getColumn(1).width=20,V.getColumn(2).width=12,V.getColumn(3).width=18;continue}const F=_,{name:A="Data",rows:q="all",includeHeaders:K=!0,includeSummary:J=!1,autoFilter:te=!0,frozenHeader:ne=!0,alternateRowColor:Z="#f8fafc"}=F,de=q==="all"&&!!(h&&h.length>0),ae=q==="selected"?T:de?h.flatMap(V=>V.type==="leaf"&&V.row?[V.row]:[]):N,oe=C.filter(V=>i[V.field]?.embedImage);if(oe.length>0){const V=[],Y=new Set;if(ae.forEach(H=>{oe.forEach(j=>{const z=Xi(H,j);z&&!O.has(z)&&!Y.has(z)&&(V.push(z),Y.add(z))})}),V.length>0){const H=await xu(V);for(const[j,{buffer:z,extension:k}]of H){const L=b.addImage({buffer:z,extension:k});O.set(j,L)}}}const se=b.addWorksheet(bn(A,P));se.columns=C.map(V=>({key:V.field,width:wu(V,i[V.field]?.width),style:{numFmt:ji(V,i[V.field])}}));const re=(V,Y)=>{C.forEach((H,j)=>Y(V.getCell(j+1),H,j+1))};if(K){const V=C.map(H=>H.headerName??H.field),Y=se.addRow(V);Y.height=20,re(Y,(H,j)=>{H.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(l)}},H.font={bold:!0,size:d,color:{argb:Oe(c)}},H.alignment={horizontal:i[j.field]?.alignment??(j.type==="number"?"right":"left"),vertical:"middle"},H.border=qi()}),te&&(se.autoFilter={from:{row:1,column:1},to:{row:1,column:C.length}}),ne?se.views=[{state:"frozen",ySplit:1,showGridLines:!1}]:se.views=[{showGridLines:!1}]}let B=K?1:0;const D=(V,Y,H)=>{const j=C.map(L=>i[L.field]?.embedImage?"":gu(V,L)),z=se.addRow(j);z.font={size:u},H>0&&(z.outlineLevel=H);const k=!!Z&&Y%2===1;if(re(z,(L,Q,ee)=>{const ce=Ui(Q,i[Q.field],j[ee-1]);ce&&(L.numFmt=ce),k&&Z&&(L.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(Z)}}),L.alignment={horizontal:i[Q.field]?.alignment??(Q.type==="number"?"right":"left"),vertical:"middle"},L.border={bottom:{style:"thin",color:{argb:"FFf1f5f9"}}}}),oe.length>0){const L=oe.reduce((ce,ue)=>Math.max(ce,i[ue.field]?.imageHeight??40),0),Q=Math.ceil(L/1.333),ee=Q*1.333;z.height=Q,oe.forEach(ce=>{const ue=C.indexOf(ce),he=Xi(V,ce),be=he?O.get(he):void 0;if(be===void 0){z.getCell(ue+1).value=he??"";return}const Ce=i[ce.field],fe=Ce?.imageWidth??40,me=Ce?.imageHeight??40,Se=(se.getColumn(ue+1).width??8)*7+5,le=Math.max(0,Se-fe)/2,ye=Math.max(0,ee-me)/2;se.addImage(be,{tl:{col:ue,row:B,nativeColOff:Math.floor(le*9525),nativeRowOff:Math.floor(ye*9525)},ext:{width:fe,height:me},editAs:"oneCell"})})}else z.height=16;B++},$=V=>Et(V,y),R=(V,Y,H,j,z)=>{const k=C.map((Q,ee)=>ee===0&&Y[Q.field]==null?{value:V}:W(Q,Y)),L=se.addRow(k.map(Q=>Q.value));L.height=18,j>0&&(L.outlineLevel=j),L.font={bold:z,italic:!z,size:u,color:{argb:Oe(c)}},re(L,(Q,ee,ce)=>{const ue=k[ce-1].numFmt;ue&&(Q.numFmt=ue),Q.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(H)}},Q.alignment={horizontal:ce===1?"left":ee.type==="number"?"right":"left",vertical:"middle"},Q.border=Yi()}),B++};let U=!1;if(de){let V=0;h.forEach(Y=>{if(Y.type==="group-header"){const H=se.addRow([$(Y)]);H.height=18,Y.depth>0&&(H.outlineLevel=Y.depth),H.font={bold:!0,size:u,color:{argb:Oe(c)}};for(let j=1;j<=C.length;j++)H.getCell(j).fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(f)}};H.getCell(1).alignment={horizontal:"left",vertical:"middle",indent:Y.depth},B++,V=0}else Y.type==="leaf"&&Y.row?D(Y.row,V++,Y.depth):Y.type==="group-subtotal"&&Y.aggregatedValues?R("Subtotal",Y.aggregatedValues,w,Y.depth,!1):Y.type==="grand-total"&&Y.aggregatedValues&&(R("Grand Total",Y.aggregatedValues,l,0,!0),U=!0)}),se.properties.outlineProperties={summaryBelow:!0,summaryRight:!1}}else ae.forEach((V,Y)=>D(V,Y,0));const G=_t(ae,q==="selected",y,g,m);if(J&&!U&&G&&m){const V=C.map(z=>{const k=m[z.field];return k?k.toUpperCase():""}),Y=se.addRow(V);Y.height=16,Y.font={size:u-1,italic:!0,color:{argb:"FF94a3b8"}},re(Y,z=>{z.alignment={horizontal:"right",vertical:"middle"},z.border={top:{style:"thin",color:{argb:"FFcbd5e1"}}}});const H=C.map(z=>m[z.field]==null?{value:null}:W(z,G)),j=se.addRow(H.map(z=>z.value));j.height=18,j.font={bold:!0,size:u,color:{argb:Oe(c)}},re(j,(z,k,L)=>{const Q=H[L-1].numFmt;Q&&(z.numFmt=Q),z.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(l)}},z.alignment={horizontal:"right",vertical:"middle"},z.border=Yi()})}}const X=await b.xlsx.writeBuffer(),S=new Blob([X],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),M=URL.createObjectURL(S),I=document.createElement("a");I.href=M,I.download=n.endsWith(".xlsx")?n:`${n}.xlsx`,document.body.appendChild(I),I.click(),document.body.removeChild(I),URL.revokeObjectURL(M)}function Oe(e){const t=e.replace("#","");return t.length===3?"FF"+t.split("").map(o=>o+o).join(""):t.length===6?"FF"+t:"FF"+t.padEnd(6,"0")}function qi(){return{bottom:{style:"medium",color:{argb:"FFcbd5e1"}}}}function Yi(){return{top:{style:"medium",color:{argb:"FFcbd5e1"}}}}function vu(e,t,o,n){return a.useMemo(()=>n?vr(e,t,o):on,[e,t,o,n])}const Ri={"--ogx-grid-row-selected-background":"var(--ogx-color-primary-light)","--ogx-grid-row-selected-hover-background":"color-mix(in srgb, var(--ogx-color-primary) 14%, var(--ogx-color-primary-light))","--ogx-grid-cell-focus-border":"var(--ogx-color-primary)","--ogx-toolbar-btn-primary-bg":"var(--ogx-color-primary)","--ogx-toolbar-btn-primary-hover":"var(--ogx-color-primary-dark)","--ogx-toolbar-input-focus-border":"var(--ogx-color-primary)","--ogx-toolbar-input-focus-shadow":"0 0 0 3px color-mix(in srgb, var(--ogx-color-primary) 12%, transparent)","--ogx-toolbar-chip-active-bg":"color-mix(in srgb, var(--ogx-color-primary) 12%, transparent)","--ogx-toolbar-chip-active-text":"var(--ogx-color-primary-dark)","--ogx-overlay-item-selected-bg":"color-mix(in srgb, var(--ogx-color-primary) 8%, transparent)","--ogx-overlay-item-selected-text":"var(--ogx-color-primary-dark)"},Ji={"--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-color-gray-50":"#f8fafc","--ogx-color-gray-100":"#f1f5f9","--ogx-color-gray-200":"#e2e8f0","--ogx-color-gray-300":"#cbd5e1","--ogx-color-gray-400":"#94a3b8","--ogx-color-gray-500":"#64748b","--ogx-color-gray-600":"#475569","--ogx-color-gray-700":"#334155","--ogx-color-gray-800":"#1e293b","--ogx-color-gray-900":"#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-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":"var(--ogx-grid-header-background)","--ogx-toolbar-text":"var(--ogx-grid-header-text)","--ogx-toolbar-border":"var(--ogx-grid-border-color)","--ogx-toolbar-btn-bg":"transparent","--ogx-toolbar-btn-hover":"var(--ogx-grid-header-hover-background)","--ogx-toolbar-btn-text":"var(--ogx-grid-header-text)","--ogx-toolbar-input-bg":"var(--ogx-grid-background)","--ogx-toolbar-input-text":"var(--ogx-grid-row-text)","--ogx-toolbar-chip-bg":"transparent","--ogx-toolbar-chip-text":"var(--ogx-grid-row-text)"},"--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-border":"#cbd5e1","--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-danger-bg":"rgba(239, 68, 68, 0.08)","--ogx-overlay-item-danger-text":"#ef4444","--ogx-scrollbar-thumb":"#cbd5e1","--ogx-scrollbar-track":"transparent","--ogx-scrollbar-size":"8px","--ogx-skeleton-base":"#f1f5f9","--ogx-skeleton-highlight":"#ffffff",...Ri},yu={...Ji,"--ogx-color-primary":"#60a5fa","--ogx-color-primary-dark":"#3b82f6","--ogx-color-primary-light":"#1e3a5f","--ogx-color-primary-focus":"rgba(96, 165, 250, 0.4)","--ogx-color-white":"#0f172a","--ogx-color-black":"#f8fafc","--ogx-color-gray-50":"#1e293b","--ogx-color-gray-100":"#334155","--ogx-color-gray-200":"#475569","--ogx-color-gray-300":"#64748b","--ogx-color-gray-400":"#94a3b8","--ogx-color-gray-500":"#cbd5e1","--ogx-color-gray-600":"#e2e8f0","--ogx-color-gray-700":"#e2e8f0","--ogx-color-gray-800":"#f1f5f9","--ogx-color-gray-900":"#f8fafc","--ogx-border-color":"#334155","--ogx-border-color-hover":"#475569","--ogx-shadow-sm":"0 1px 2px 0 rgba(0, 0, 0, 0.3)","--ogx-shadow-md":"0 4px 6px -1px rgba(0, 0, 0, 0.3)","--ogx-shadow-lg":"0 10px 15px -3px rgba(0, 0, 0, 0.3)","--ogx-grid-background":"#0f172a","--ogx-grid-border-color":"#334155","--ogx-grid-header-background":"#1e293b","--ogx-grid-header-text":"#e2e8f0","--ogx-grid-header-hover-background":"#334155","--ogx-grid-header-sorted-background":"#1e3a5f","--ogx-grid-row-text":"#cbd5e1","--ogx-grid-row-hover-background":"#1e293b","--ogx-grid-row-alternate-background":"#162032","--ogx-checkbox-bg":"#1e293b","--ogx-checkbox-border":"#64748b","--ogx-grid-pinned-left-shadow":"4px 0 24px -4px rgba(0, 0, 0, 0.3)","--ogx-grid-pinned-right-shadow":"-4px 0 24px -4px rgba(0, 0, 0, 0.3)","--ogx-toolbar-btn-danger-bg":"rgba(239, 68, 68, 0.15)","--ogx-toolbar-btn-danger-hover":"rgba(239, 68, 68, 0.25)","--ogx-toolbar-btn-danger-text":"#fca5a5","--ogx-toolbar-input-border":"#334155","--ogx-overlay-background":"#1e293b","--ogx-overlay-text":"#cbd5e1","--ogx-overlay-border":"#334155","--ogx-overlay-shadow":"0 4px 6px -1px rgba(0,0,0,0.4), 0 2px 4px -1px rgba(0,0,0,0.3), 0 0 0 1px rgba(0,0,0,0.2)","--ogx-overlay-item-hover-bg":"#334155","--ogx-overlay-item-hover-text":"#f1f5f9","--ogx-overlay-item-danger-bg":"rgba(239, 68, 68, 0.15)","--ogx-overlay-item-danger-text":"#fca5a5","--ogx-scrollbar-thumb":"#475569","--ogx-skeleton-base":"#1e293b","--ogx-skeleton-highlight":"#334155",...Ri,"--ogx-toolbar-chip-active-text":"var(--ogx-color-primary)","--ogx-overlay-item-selected-text":"var(--ogx-color-primary)"},Cu=[50,100,200,300,400,500,600,700,800,900];function _u(e){const t={};function o(n,r){r!==void 0&&(t[n]=r)}if(e.colors){const n=e.colors;if(o("--ogx-color-primary",n.primary),o("--ogx-color-primary-dark",n.primaryDark),o("--ogx-color-primary-light",n.primaryLight),o("--ogx-color-primary-focus",n.primaryFocus),o("--ogx-color-secondary",n.secondary),o("--ogx-color-secondary-dark",n.secondaryDark),o("--ogx-color-secondary-light",n.secondaryLight),o("--ogx-color-success",n.success),o("--ogx-color-warning",n.warning),o("--ogx-color-error",n.error),o("--ogx-color-info",n.info),o("--ogx-color-white",n.white),o("--ogx-color-black",n.black),n.gray)for(const r of Cu)o(`--ogx-color-gray-${r}`,n.gray[r])}if(e.typography){const n=e.typography;o("--ogx-font-family",n.fontFamily),o("--ogx-font-family-mono",n.fontFamilyMono),o("--ogx-font-size-xs",n.fontSizeXs),o("--ogx-font-size-sm",n.fontSizeSm),o("--ogx-font-size-md",n.fontSizeMd),o("--ogx-font-size-lg",n.fontSizeLg),o("--ogx-font-size-xl",n.fontSizeXl)}if(e.spacing){const n=e.spacing;o("--ogx-spacing-xs",n.xs),o("--ogx-spacing-sm",n.sm),o("--ogx-spacing-md",n.md),o("--ogx-spacing-lg",n.lg),o("--ogx-spacing-xl",n.xl),o("--ogx-spacing-xxl",n.xxl)}if(e.borders){const n=e.borders;o("--ogx-border-width-thin",n.widthThin),o("--ogx-border-width-medium",n.widthMedium),o("--ogx-border-width-thick",n.widthThick),o("--ogx-border-radius-sm",n.radiusSm),o("--ogx-border-radius-md",n.radiusMd),o("--ogx-border-radius-lg",n.radiusLg),o("--ogx-border-radius-xl",n.radiusXl),o("--ogx-border-color",n.color),o("--ogx-border-color-hover",n.colorHover)}if(e.shadows){const n=e.shadows;o("--ogx-shadow-sm",n.sm),o("--ogx-shadow-md",n.md),o("--ogx-shadow-lg",n.lg),o("--ogx-shadow-xl",n.xl)}if(e.grid){const n=e.grid;o("--ogx-grid-row-height-compact",n.rowHeightCompact),o("--ogx-grid-row-height-standard",n.rowHeightStandard),o("--ogx-row-height",n.rowHeightStandard),o("--ogx-grid-row-height-comfortable",n.rowHeightComfortable),o("--ogx-grid-header-height",n.headerHeight),o("--ogx-header-height",n.headerHeight),o("--ogx-grid-cell-padding-x",n.cellPaddingX),o("--ogx-grid-cell-padding-y",n.cellPaddingY),o("--ogx-grid-cell-font-size",n.cellFontSize),o("--ogx-grid-header-font-size",n.headerFontSize),o("--ogx-grid-background",n.background),o("--ogx-grid-border-color",n.borderColor),o("--ogx-grid-header-background",n.headerBackground),o("--ogx-grid-header-text",n.headerText),o("--ogx-grid-header-hover-background",n.headerHoverBackground),o("--ogx-grid-header-sorted-background",n.headerSortedBackground),o("--ogx-grid-row-text",n.rowText),o("--ogx-grid-row-hover-background",n.rowHoverBackground),o("--ogx-grid-row-alternate-background",n.rowAlternateBackground),o("--ogx-grid-row-selected-background",n.rowSelectedBackground),o("--ogx-grid-row-selected-hover-background",n.rowSelectedHoverBackground),o("--ogx-grid-cell-focus-border",n.cellFocusBorder),o("--ogx-grid-pinned-left-shadow",n.pinnedLeftShadow),o("--ogx-grid-pinned-right-shadow",n.pinnedRightShadow),o("--ogx-checkbox-bg",n.checkboxBg),o("--ogx-checkbox-border",n.checkboxBorder)}if(e.transitions){const n=e.transitions;o("--ogx-transition-duration-fast",n.durationFast),o("--ogx-transition-duration-normal",n.durationNormal),o("--ogx-transition-duration-slow",n.durationSlow),o("--ogx-transition-easing",n.easing)}if(e.toolbar){const n=e.toolbar;o("--ogx-toolbar-background",n.background),o("--ogx-toolbar-text",n.text),o("--ogx-toolbar-border",n.border),o("--ogx-toolbar-btn-bg",n.buttonBackground),o("--ogx-toolbar-btn-hover",n.buttonHoverBackground),o("--ogx-toolbar-btn-text",n.buttonText),o("--ogx-toolbar-btn-primary-bg",n.buttonPrimaryBackground),o("--ogx-toolbar-btn-primary-hover",n.buttonPrimaryHoverBackground),o("--ogx-toolbar-btn-primary-text",n.buttonPrimaryText),o("--ogx-toolbar-btn-danger-bg",n.buttonDangerBackground),o("--ogx-toolbar-btn-danger-hover",n.buttonDangerHoverBackground),o("--ogx-toolbar-btn-danger-text",n.buttonDangerText),o("--ogx-toolbar-input-bg",n.inputBackground),o("--ogx-toolbar-input-text",n.inputText),o("--ogx-toolbar-input-border",n.inputBorder),o("--ogx-toolbar-input-focus-border",n.inputFocusBorder),o("--ogx-toolbar-input-focus-shadow",n.inputFocusShadow),o("--ogx-toolbar-chip-bg",n.chipBackground),o("--ogx-toolbar-chip-text",n.chipText),o("--ogx-toolbar-chip-active-bg",n.chipActiveBackground),o("--ogx-toolbar-chip-active-text",n.chipActiveText)}if(e.overlays){const n=e.overlays;o("--ogx-overlay-background",n.background),o("--ogx-overlay-text",n.text),o("--ogx-overlay-border",n.border),o("--ogx-overlay-shadow",n.shadow),o("--ogx-overlay-item-hover-bg",n.itemHoverBackground),o("--ogx-overlay-item-hover-text",n.itemHoverText),o("--ogx-overlay-item-selected-bg",n.itemSelectedBackground),o("--ogx-overlay-item-selected-text",n.itemSelectedText),o("--ogx-overlay-item-danger-bg",n.itemDangerBackground),o("--ogx-overlay-item-danger-text",n.itemDangerText)}if(e.scrollbar){const n=e.scrollbar;o("--ogx-scrollbar-thumb",n.thumbColor),o("--ogx-scrollbar-track",n.trackColor),o("--ogx-scrollbar-size",n.size)}if(e.skeleton){const n=e.skeleton;o("--ogx-skeleton-base",n.baseColor),o("--ogx-skeleton-highlight",n.highlightColor)}return t}function Su({theme:e,children:t,className:o,style:n}){const r=a.useMemo(()=>({...e.mode==="dark"?yu:Ji,..._u(e)}),[e]);return s.jsx(Mr.Provider,{value:e,children:s.jsx("div",{className:`ogx-theme-provider ${o||""}`.trim(),style:{...n,...r},children:t})})}const ku={mode:"dark",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:"#1e293b",text:"#cbd5e1",border:"#334155",buttonBackground:"transparent",buttonHoverBackground:"#334155",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"}},Eu={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"}},Mu={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"}},Nu={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"}},Pu={grid:{rowHeightCompact:"28px",rowHeightStandard:"36px",rowHeightComfortable:"48px",headerHeight:"40px",cellPaddingX:"8px",cellPaddingY:"4px",cellFontSize:"12px",headerFontSize:"12px"},typography:{fontSizeSm:"0.8rem",fontSizeMd:"0.875rem"}};function Iu(){if(!(typeof window>"u"))try{return window.localStorage}catch{return}}function Qi(e,t){try{const o=t.getItem(e);return o?JSON.parse(o):void 0}catch{return}}function Tu(e,t,o,n){try{const r=o?Object.fromEntries(Object.entries(t).filter(([i])=>o.includes(i))):t;n.setItem(e,JSON.stringify(r))}catch{}}function Fu(e){const t=typeof e=="string"?{key:e}:e,{key:o,debounceMs:n=300,include:r,storage:i}=t,[l]=a.useState(Iu),c=i??l,d=a.useRef(r),u=a.useRef(c);a.useLayoutEffect(()=>{d.current=r,u.current=c});const[g,m]=a.useState(()=>({key:o,state:c?Qi(o,c):void 0}));let x=g.state;g.key!==o&&(x=c?Qi(o,c):void 0,m({key:o,state:x}));const v=a.useRef(null),h=a.useRef(null),f=a.useCallback(()=>{v.current&&(clearTimeout(v.current),v.current=null);const b=h.current;h.current=null;const y=u.current;b&&y&&Tu(b.key,b.state,d.current,y)},[]),w=a.useCallback(b=>{h.current&&h.current.key!==o&&f(),h.current={key:o,state:b},v.current&&clearTimeout(v.current),v.current=setTimeout(f,n)},[o,f,n]);a.useEffect(()=>f,[f]);const p=a.useCallback(()=>{v.current&&(clearTimeout(v.current),v.current=null),h.current=null;const b=u.current;if(b)try{b.removeItem(o)}catch{}},[o]);return a.useMemo(()=>({initialState:x,onStateChange:w,clearState:p}),[x,w,p])}pe.Button=Wt,pe.Cell=xi,pe.Checkbox=Gt,pe.ColumnVisibilityPanel=mn,pe.DataGrid=bc,pe.DataGridThemeProvider=Su,pe.FilterPanel=Fi,pe.GridToolbar=$c,pe.GridTooltip=jt,pe.Header=qr,pe.Input=Wc,pe.Pagination=gn,pe.Row=mo,pe.Skeleton=vc,pe.amberTheme=Nu,pe.compactTheme=Pu,pe.darkTheme=ku,pe.emeraldTheme=Mu,pe.exportToCsv=Qc,pe.exportToExcel=tu,pe.exportToExcelAdvanced=bu,pe.exportToJson=ou,pe.exportToPdf=Rc,pe.formatAggregationValue=Xo,pe.printGrid=lu,pe.roseTheme=Eu,pe.useAggregation=hi,pe.useGridApiRef=Gc,pe.useGridStateStorage=Fu,pe.usePivot=vu,Object.defineProperty(pe,Symbol.toStringTag,{value:"Module"})}));
50
44
  //# sourceMappingURL=opengridx.umd.js.map