@opencorestack/opengridx 2.1.0 → 3.0.1

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 (225) hide show
  1. package/CHANGELOG.md +399 -0
  2. package/README.md +95 -72
  3. package/dist/index.d.ts +590 -131
  4. package/dist/opengridx.css +1 -1
  5. package/dist/opengridx.es.js +7891 -5631
  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 -166
  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 +6 -7
  29. package/docs/components/datagrid.md +15 -13
  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 +90 -38
  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 +126 -39
  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 +72 -19
  54. package/docs/features/pinning.md +24 -5
  55. package/docs/features/selection.md +50 -10
  56. package/docs/features/sorting-pagination.md +64 -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 +36 -8
  60. package/docs/features/virtualization.md +37 -14
  61. package/docs/migration/v1-to-v2.md +115 -0
  62. package/docs/migration/v2-to-v3.md +1233 -0
  63. package/docs/performance.md +124 -0
  64. package/docs/roadmap.md +5 -5
  65. package/lib/components/Cell/Cell.css +17 -1
  66. package/lib/components/Cell/Cell.tsx +129 -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 +15 -2
  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 +85 -12
  76. package/lib/components/DataGrid/DataGrid.tsx +582 -876
  77. package/lib/components/DataGrid/GridAggregationFooter.tsx +53 -17
  78. package/lib/components/DataGrid/GridErrorOverlay.tsx +15 -12
  79. package/lib/components/DataGrid/GridListView.tsx +165 -24
  80. package/lib/components/DataGrid/GridLiveRegion.tsx +31 -0
  81. package/lib/components/DataGrid/GridLoadingOverlay.tsx +27 -0
  82. package/lib/components/DataGrid/GridPaginationArea.tsx +44 -0
  83. package/lib/components/DataGrid/GridPinnedRows.tsx +62 -11
  84. package/lib/components/DataGrid/GridStandaloneColumnPanel.tsx +40 -38
  85. package/lib/components/DataGrid/GridToolbarSlot.tsx +51 -0
  86. package/lib/components/DataGrid/GridVirtualRows.tsx +40 -24
  87. package/lib/components/DetailPanel/DetailPanel.css +0 -6
  88. package/lib/components/DetailPanel/DetailPanel.tsx +34 -5
  89. package/lib/components/DetailPanel/DetailPanelContent.tsx +17 -0
  90. package/lib/components/FilterPanel/FilterPanel.css +13 -2
  91. package/lib/components/FilterPanel/FilterPanel.tsx +272 -99
  92. package/lib/components/Header/ColumnMenu.tsx +91 -39
  93. package/lib/components/Header/Header.css +6 -3
  94. package/lib/components/Header/Header.tsx +181 -160
  95. package/lib/components/ListView/ListView.css +25 -0
  96. package/lib/components/ListView/ListViewRow.tsx +76 -10
  97. package/lib/components/Pagination/Pagination.tsx +15 -7
  98. package/lib/components/Row/Row.tsx +177 -77
  99. package/lib/components/Toolbar/GlobalSearch.css +6 -3
  100. package/lib/components/Toolbar/GlobalSearch.tsx +26 -27
  101. package/lib/components/Toolbar/GridToolbar.css +12 -11
  102. package/lib/components/Toolbar/GridToolbar.tsx +133 -89
  103. package/lib/components/Toolbar/PivotPanel.tsx +89 -49
  104. package/lib/components/Tooltip/Tooltip.css +20 -0
  105. package/lib/components/Tooltip/Tooltip.tsx +68 -35
  106. package/lib/components/ui/Button.tsx +3 -0
  107. package/lib/components/ui/Checkbox.tsx +2 -1
  108. package/lib/components/ui/ExpandIcon.css +0 -9
  109. package/lib/components/ui/ExpandIcon.tsx +4 -1
  110. package/lib/hooks/core/gridApiPlaceholder.ts +34 -0
  111. package/lib/hooks/core/gridToolbarHostContext.ts +14 -0
  112. package/lib/hooks/core/useDataGrid.ts +115 -173
  113. package/lib/hooks/core/useGridAggregationApi.ts +72 -0
  114. package/lib/hooks/core/useGridApiMethods.ts +115 -0
  115. package/lib/hooks/core/useGridApiRef.ts +19 -4
  116. package/lib/hooks/core/useGridApiRefBinding.ts +18 -0
  117. package/lib/hooks/core/useGridAriaRows.ts +38 -0
  118. package/lib/hooks/core/useGridClipboardApi.ts +38 -0
  119. package/lib/hooks/core/useGridColumnLookup.ts +30 -0
  120. package/lib/hooks/core/useGridColumns.tsx +279 -76
  121. package/lib/hooks/core/useGridColumnsPanel.ts +77 -0
  122. package/lib/hooks/core/useGridControlledState.ts +99 -6
  123. package/lib/hooks/core/useGridDetailPanel.ts +51 -0
  124. package/lib/hooks/core/useGridDevWarnings.ts +104 -5
  125. package/lib/hooks/core/useGridFocusHandlers.ts +50 -0
  126. package/lib/hooks/core/useGridGroupingColumn.ts +62 -0
  127. package/lib/hooks/core/useGridHeaderHandlers.ts +92 -0
  128. package/lib/hooks/core/useGridHierarchy.ts +81 -0
  129. package/lib/hooks/core/useGridKeyboardNavigation.ts +447 -243
  130. package/lib/hooks/core/useGridLiveRowSelection.ts +67 -0
  131. package/lib/hooks/core/useGridPageCorrection.ts +55 -0
  132. package/lib/hooks/core/useGridRowIdOf.ts +32 -0
  133. package/lib/hooks/core/useGridRowInteractions.ts +81 -0
  134. package/lib/hooks/core/useGridRowPipeline.ts +69 -39
  135. package/lib/hooks/core/useGridRowSelection.ts +91 -0
  136. package/lib/hooks/core/useGridScrollSync.ts +80 -32
  137. package/lib/hooks/core/useGridScrollToIndexesApi.ts +45 -0
  138. package/lib/hooks/core/useGridStateSnapshot.ts +40 -5
  139. package/lib/hooks/core/useGridThemeDimensions.ts +49 -0
  140. package/lib/hooks/core/useGridToolbarProps.ts +97 -0
  141. package/lib/hooks/core/useGridViewport.ts +38 -0
  142. package/lib/hooks/core/useGridViewportSize.ts +26 -0
  143. package/lib/hooks/core/useGridVisibleRows.ts +17 -5
  144. package/lib/hooks/core/useLayout.ts +215 -195
  145. package/lib/hooks/core/useRowsScrollEndLatch.ts +41 -0
  146. package/lib/hooks/core/useStableColumns.ts +34 -0
  147. package/lib/hooks/features/useAggregation.ts +82 -51
  148. package/lib/hooks/features/useColumnGroupReorderGuard.ts +34 -0
  149. package/lib/hooks/features/useDetailPanelHeights.ts +29 -0
  150. package/lib/hooks/features/useGridClipboard.ts +133 -73
  151. package/lib/hooks/features/useGridDataSource.ts +354 -128
  152. package/lib/hooks/features/useGridEditing.ts +211 -51
  153. package/lib/hooks/features/useGridPivot.ts +92 -0
  154. package/lib/hooks/features/useGridSpanRenderWindow.ts +104 -0
  155. package/lib/hooks/features/useGridSpanning.ts +410 -306
  156. package/lib/hooks/features/usePivot.ts +0 -0
  157. package/lib/hooks/features/useServerTreeChildren.ts +50 -0
  158. package/lib/hooks/useColumnReorder.ts +38 -44
  159. package/lib/hooks/useRowGrouping.ts +298 -160
  160. package/lib/hooks/useRowReorder.ts +62 -31
  161. package/lib/hooks/useTreeData.ts +287 -220
  162. package/lib/index.ts +28 -2
  163. package/lib/state/index.ts +1 -0
  164. package/lib/state/types.ts +7 -1
  165. package/lib/state/useGridStateStorage.ts +88 -29
  166. package/lib/theme/DataGridThemeProvider.tsx +143 -38
  167. package/lib/theme/gridThemeContext.ts +5 -0
  168. package/lib/theme/index.ts +5 -0
  169. package/lib/theme/presets.ts +5 -4
  170. package/lib/theme/types.ts +40 -2
  171. package/lib/types/index.ts +313 -116
  172. package/lib/utils/aggregation/index.ts +119 -24
  173. package/lib/utils/aria/index.ts +40 -0
  174. package/lib/utils/columnGroups.ts +110 -0
  175. package/lib/utils/columnLookup.ts +33 -0
  176. package/lib/utils/columnWidth.ts +22 -0
  177. package/lib/utils/dataSource/index.ts +46 -0
  178. package/lib/utils/detailPanel.ts +66 -0
  179. package/lib/utils/dragData.ts +44 -0
  180. package/lib/utils/editing/index.ts +30 -0
  181. package/lib/utils/export/exportShared.ts +197 -0
  182. package/lib/utils/export/exportToExcelAdvanced.ts +278 -139
  183. package/lib/utils/export/exportToPdf.ts +143 -92
  184. package/lib/utils/export/groupLabel.ts +14 -0
  185. package/lib/utils/export/index.ts +278 -272
  186. package/lib/utils/export/pdfText.ts +50 -0
  187. package/lib/utils/filtering/index.ts +277 -148
  188. package/lib/utils/focus/index.ts +115 -0
  189. package/lib/utils/gridApiRows.ts +35 -0
  190. package/lib/utils/gridModes.ts +77 -0
  191. package/lib/utils/grouping/groupedExportRows.ts +91 -0
  192. package/lib/utils/pagination/index.ts +56 -0
  193. package/lib/utils/pinning/index.ts +77 -33
  194. package/lib/utils/pivot/index.ts +368 -0
  195. package/lib/utils/scroll/index.ts +55 -5
  196. package/lib/utils/scroll/scrollEnd.ts +18 -0
  197. package/lib/utils/sorting/index.ts +154 -30
  198. package/lib/utils/syntheticRows.ts +12 -0
  199. package/lib/utils/values.ts +206 -0
  200. package/lib/utils/viewport.ts +14 -0
  201. package/llms.txt +261 -164
  202. package/package.json +13 -5
  203. package/lib/components/ColumnGroupHeader/ColumnGroupHeader.tsx +0 -220
  204. package/lib/components/ColumnVisibilityPanel/ColumnVisibilityPanel.test.tsx +0 -85
  205. package/lib/components/DataGrid/DataGrid.defects.test.tsx +0 -103
  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/DataGrid/DataGrid.virtualization.browser.test.tsx +0 -183
  210. package/lib/components/Header/Header.test.tsx +0 -135
  211. package/lib/components/Pagination/Pagination.test.tsx +0 -64
  212. package/lib/hooks/core/useDataGrid.regression.test.ts +0 -66
  213. package/lib/hooks/core/useGridControlledState.test.ts +0 -86
  214. package/lib/hooks/core/useGridKeyboardNavigation.test.ts +0 -176
  215. package/lib/hooks/core/useGridRowPipeline.test.ts +0 -117
  216. package/lib/hooks/features/useAggregation.test.ts +0 -175
  217. package/lib/hooks/features/usePivot.test.ts +0 -202
  218. package/lib/hooks/useRowGrouping.test.ts +0 -298
  219. package/lib/hooks/useTreeData.test.ts +0 -83
  220. package/lib/utils/aggregation/aggregation.test.ts +0 -16
  221. package/lib/utils/export/exportToExcelAdvanced.test.ts +0 -109
  222. package/lib/utils/export/exportToPdf.test.ts +0 -120
  223. package/lib/utils/export/groupedExport.test.ts +0 -144
  224. package/lib/utils/filtering/filtering.test.ts +0 -178
  225. package/lib/utils/sorting/sorting.test.ts +0 -88
@@ -1,21 +1,15 @@
1
- (function(se,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],s):(se=typeof globalThis<"u"?globalThis:se||self,s(se.OpenGridX={},se.React,se.ReactDOM))})(this,(function(se,s,Ve){"use strict";var Ft={exports:{}},xt={};var jn;function bo(){if(jn)return xt;jn=1;var n=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function e(o,i,l){var a=null;if(l!==void 0&&(a=""+l),i.key!==void 0&&(a=""+i.key),"key"in i){l={};for(var d in i)d!=="key"&&(l[d]=i[d])}else l=i;return i=l.ref,{$$typeof:n,type:o,key:a,ref:i!==void 0?i:null,props:l}}return xt.Fragment=t,xt.jsx=e,xt.jsxs=e,xt}var mt={};var En;function vo(){return En||(En=1,process.env.NODE_ENV!=="production"&&(function(){function n(_){if(_==null)return null;if(typeof _=="function")return _.$$typeof===b?null:_.displayName||_.name||null;if(typeof _=="string")return _;switch(_){case v:return"Fragment";case m:return"Profiler";case E:return"StrictMode";case k:return"Suspense";case C:return"SuspenseList";case P:return"Activity"}if(typeof _=="object")switch(typeof _.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),_.$$typeof){case h:return"Portal";case M:return _.displayName||"Context";case y:return(_._context.displayName||"Context")+".Consumer";case N:var T=_.render;return _=_.displayName,_||(_=T.displayName||T.name||"",_=_!==""?"ForwardRef("+_+")":"ForwardRef"),_;case S:return T=_.displayName||null,T!==null?T:n(_.type)||"Memo";case j:T=_._payload,_=_._init;try{return n(_(T))}catch{}}return null}function t(_){return""+_}function e(_){try{t(_);var T=!1}catch{T=!0}if(T){T=console;var I=T.error,O=typeof Symbol=="function"&&Symbol.toStringTag&&_[Symbol.toStringTag]||_.constructor.name||"Object";return I.call(T,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",O),t(_)}}function o(_){if(_===v)return"<>";if(typeof _=="object"&&_!==null&&_.$$typeof===j)return"<...>";try{var T=n(_);return T?"<"+T+">":"<...>"}catch{return"<...>"}}function i(){var _=F.A;return _===null?null:_.getOwner()}function l(){return Error("react-stack-top-frame")}function a(_){if(z.call(_,"key")){var T=Object.getOwnPropertyDescriptor(_,"key").get;if(T&&T.isReactWarning)return!1}return _.key!==void 0}function d(_,T){function I(){$||($=!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)",T))}I.isReactWarning=!0,Object.defineProperty(_,"key",{get:I,configurable:!0})}function c(){var _=n(this.type);return H[_]||(H[_]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),_=this.props.ref,_!==void 0?_:null}function u(_,T,I,O,X,te){var Z=I.ref;return _={$$typeof:f,type:_,key:T,props:I,_owner:O},(Z!==void 0?Z:null)!==null?Object.defineProperty(_,"ref",{enumerable:!1,get:c}):Object.defineProperty(_,"ref",{enumerable:!1,value:null}),_._store={},Object.defineProperty(_._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(_,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(_,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:X}),Object.defineProperty(_,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:te}),Object.freeze&&(Object.freeze(_.props),Object.freeze(_)),_}function p(_,T,I,O,X,te){var Z=T.children;if(Z!==void 0)if(O)if(K(Z)){for(O=0;O<Z.length;O++)w(Z[O]);Object.freeze&&Object.freeze(Z)}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(Z);if(z.call(T,"key")){Z=n(_);var ce=Object.keys(T).filter(function(G){return G!=="key"});O=0<ce.length?"{key: someKey, "+ce.join(": ..., ")+": ...}":"{key: someKey}",D[Z+O]||(ce=0<ce.length?"{"+ce.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,Z,ce,Z),D[Z+O]=!0)}if(Z=null,I!==void 0&&(e(I),Z=""+I),a(T)&&(e(T.key),Z=""+T.key),"key"in T){I={};for(var le in T)le!=="key"&&(I[le]=T[le])}else I=T;return Z&&d(I,typeof _=="function"?_.displayName||_.name||"Unknown":_),u(_,Z,I,i(),X,te)}function w(_){x(_)?_._store&&(_._store.validated=1):typeof _=="object"&&_!==null&&_.$$typeof===j&&(_._payload.status==="fulfilled"?x(_._payload.value)&&_._payload.value._store&&(_._payload.value._store.validated=1):_._store&&(_._store.validated=1))}function x(_){return typeof _=="object"&&_!==null&&_.$$typeof===f}var g=s,f=Symbol.for("react.transitional.element"),h=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),m=Symbol.for("react.profiler"),y=Symbol.for("react.consumer"),M=Symbol.for("react.context"),N=Symbol.for("react.forward_ref"),k=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),P=Symbol.for("react.activity"),b=Symbol.for("react.client.reference"),F=g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,z=Object.prototype.hasOwnProperty,K=Array.isArray,W=console.createTask?console.createTask:function(){return null};g={react_stack_bottom_frame:function(_){return _()}};var $,H={},L=g.react_stack_bottom_frame.bind(g,l)(),B=W(o(l)),D={};mt.Fragment=v,mt.jsx=function(_,T,I){var O=1e4>F.recentlyCreatedOwnerStacks++;return p(_,T,I,!1,O?Error("react-stack-top-frame"):L,O?W(o(_)):B)},mt.jsxs=function(_,T,I){var O=1e4>F.recentlyCreatedOwnerStacks++;return p(_,T,I,!0,O?Error("react-stack-top-frame"):L,O?W(o(_)):B)}})()),mt}var Nn;function Co(){return Nn||(Nn=1,process.env.NODE_ENV==="production"?Ft.exports=bo():Ft.exports=vo()),Ft.exports}var r=Co();function wt(n,t){return t?t.left?.includes(n)?"left":t.right?.includes(n)?"right":null:null}function _o(n,t){const e=[],o=[],i=[];return t?(n.forEach(l=>{const a=wt(l.field,t);a==="left"?e.push(l):a==="right"?i.push(l):o.push(l)}),t.left&&e.sort((l,a)=>{const d=t.left.indexOf(l.field),c=t.left.indexOf(a.field);return d-c}),t.right&&i.sort((l,a)=>{const d=t.right.indexOf(l.field),c=t.right.indexOf(a.field);return d-c}),{left:e,center:o,right:i}):{left:e,center:n,right:i}}function en(n,t,e,o,i,l,a,d){const c={};if(!e)return c;const u=_o(n,e);let p=0;d&&(p+=48),l&&a&&(p+=48),o&&i&&(p+=48),u.left.forEach(x=>{c[x.field]=p;const g=t[x.field]??x.width??100;p+=g});let w=0;return[...u.right].reverse().forEach(x=>{const g=t[x.field]??x.width??100;c[x.field]=w,w+=g}),c}function tn(n,t){return t?t.top?.includes(n)?"top":t.bottom?.includes(n)?"bottom":null:null}function yo(n,t){const e=[],o=[],i=[];return t?(n.forEach(l=>{const a=tn(l.id,t);a==="top"?e.push(l):a==="bottom"?i.push(l):o.push(l)}),t.top&&e.sort((l,a)=>{const d=t.top.indexOf(l.id),c=t.top.indexOf(a.id);return d-c}),t.bottom&&i.sort((l,a)=>{const d=t.bottom.indexOf(l.id),c=t.bottom.indexOf(a.id);return d-c}),{top:e,center:o,bottom:i}):{top:e,center:n,bottom:i}}function Je(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 ko(n){const{rowHeight:t,pagination:e,paginatedUnpinnedRows:o,sortedUnpinnedRows:i,expandedRowIds:l,getDetailPanelHeight:a,pinnedTopRowsLength:d,pinnedBottomRowsLength:c,visibleOrderedColumns:u,pinnedColumns:p,columnWidths:w,viewportWidth:x,checkboxSelection:g,hasDetailPanel:f,rowReordering:h,paginationMode:v,isLoading:E,pageSize:m}=n;return s.useMemo(()=>{const y=e?o:i,M=y.map((A,ee)=>{let ie=t;if(l.has(A.id)){const ae=a?.({row:A,id:A.id,rowIndex:d+ee})??200;ie+=typeof ae=="number"?ae:parseInt(String(ae),10)||200}return ie}),N=M.reduce((A,ee,ie)=>(A.push((A[ie-1]||0)+ee),A),[]),k=v==="infinite"&&E&&y.length>0?Math.min(m,20):0,C=(N[N.length-1]||0)+k*t,S=d*t,j=c*t,P=[],b=[],F=[],z=[];u.forEach(A=>{const ee=wt(A.field,p);ee==="left"?P.push(A):ee==="right"?b.push(A):F.push(A)});const K=(g?48:0)+(f?48:0)+(h?48:0),W=A=>w[A.field]??A.width,$=P.reduce((A,ee)=>{const ie=Je(W(ee));return A+(ie.type==="fixed"?ie.value:100)},0),H=b.reduce((A,ee)=>{const ie=Je(W(ee));return A+(ie.type==="fixed"?ie.value:100)},0),L=F.reduce((A,ee)=>{if(!Object.prototype.hasOwnProperty.call(w,ee.field)&&ee.flex&&ee.flex>0){const fe=ee.minWidth??150,he=typeof ee.width=="number"?ee.width:150;return A+(fe||he)}const ae=Je(W(ee));return ae.type==="fixed"?A+ae.value:ae.type==="percentage"?A+100:A+(ee.minWidth??150)},0),B=Math.max(x-K-$-H,L),D=[],_=[],T=[];F.forEach(A=>{const ee=Object.prototype.hasOwnProperty.call(w,A.field),ie=Je(W(A));if(!ee&&A.flex&&A.flex>0){T.push({col:A,flex:A.flex});return}ie.type==="fixed"?D.push({col:A,width:ie.value}):ie.type==="percentage"?_.push({col:A,percentage:ie.value}):T.push({col:A,flex:1})});const I=D.reduce((A,{width:ee})=>A+ee,0);let O=Math.max(0,B-I);const X=new Map;_.forEach(({col:A,percentage:ee})=>{const ie=ee/100*O;X.set(A.field,ie),O-=ie}),O=Math.max(0,O);const te=new Map,Z=T.map(A=>({...A,minWidth:A.col.minWidth??50,maxWidth:A.col.maxWidth??1/0,frozen:!1,computedWidth:0}));(()=>{let A=0;const ee=Z.length*2;for(;A<ee;){A++;const ie=Z.filter(oe=>!oe.frozen);if(ie.length===0)break;const ae=ie.reduce((oe,je)=>oe+je.flex,0),fe=Z.reduce((oe,je)=>je.frozen?oe+je.computedWidth:oe,0),he=Math.max(0,O-fe);if(ae<=0){ie.forEach(oe=>{oe.computedWidth=oe.minWidth,oe.frozen=!0});break}const Me=he/ae;let ke=0;const Pe=[],Se=[];if(ie.forEach(oe=>{const je=Me*oe.flex;je<oe.minWidth?(ke+=oe.minWidth-je,Pe.push(oe)):je>oe.maxWidth?(ke+=oe.maxWidth-je,Se.push(oe)):oe.computedWidth=je}),Pe.length===0&&Se.length===0){ie.forEach(oe=>oe.frozen=!0);break}ke>0?Pe.forEach(oe=>{oe.computedWidth=oe.minWidth,oe.frozen=!0}):ke<0?Se.forEach(oe=>{oe.computedWidth=oe.maxWidth,oe.frozen=!0}):(Pe.forEach(oe=>{oe.computedWidth=oe.minWidth,oe.frozen=!0}),Se.forEach(oe=>{oe.computedWidth=oe.maxWidth,oe.frozen=!0}))}})(),Z.forEach(A=>te.set(A.col.field,A.computedWidth));const le=new Map;F.forEach(A=>{let ee;if(te.has(A.field))ee=te.get(A.field);else{const ie=D.find(fe=>fe.col.field===A.field),ae=_.find(fe=>fe.col.field===A.field);if(ie)ee=ie.width;else if(ae){const fe=X.get(A.field)||0;ee=Math.max(A.minWidth??50,fe||100)}else ee=100}z.push(ee),le.set(A.field,ee)});const G=F.map(A=>{const ee=Z.find(ie=>ie.col.field===A.field);return{...A,width:le.get(A.field)??(typeof A.width=="number"?A.width:100),flex:ee?ee.flex:A.flex}}),R=11,Y=P.map((A,ee)=>{const ie=Je(W(A));return{...A,width:ie.type==="fixed"?ie.value:100,zIndex:R+ee}}),Q=11,J=b.map((A,ee)=>{const ie=Je(W(A));return{...A,width:ie.type==="fixed"?ie.value:100,zIndex:Q+(b.length-1-ee)}}),re=z.reduce((A,ee)=>A+ee,0),q=$+re+H+K,V=z.reduce((A,ee,ie)=>(A.push((A[ie-1]||0)+ee),A),[]);return{rowHeights:M,cumulativeHeights:N,unpinnedRowsHeight:C,pinnedTopHeight:S,pinnedBottomHeight:j,leftPinnedCols:Y,rightPinnedCols:J,unpinnedColsWithWidth:G,unpinnedColWidths:z,unpinnedAccWidths:V,totalWidth:q,leftWidth:$,rightWidth:H,unpinnedTotalWidth:re,systemColumnsWidth:K,pinnedTopRowsLength:d,pinnedBottomRowsLength:c,unpinnedRowsLength:y.length}},[t,e,o,i,l,a,d,c,u,p,w,x,g,f,h,v,E,m])}function Mn(n,t,e,o){if(t<0||t>=e.length)return;const i=n.querySelector(".ogx__virtual-container");if(!i)return;const{scrollTop:l,clientHeight:a}=n,d=i.getBoundingClientRect().top-n.getBoundingClientRect().top+l,c=d+(t===0?0:e[t-1]),u=d+e[t];c<l+d?n.scrollTop=Math.max(0,c-d):u>l+a-o&&(n.scrollTop=u-a+o)}function So(n){const{allRenderableRows:t,navigationColumns:e,checkboxSelection:o,selectedRowIds:i,handleSelectionChange:l,handleDetailPanelToggle:a,editingHandlers:d,setKeyboardMode:c,sortModel:u,handleSort:p,isCellEditable:w,pagination:x,pageSize:g,virtualization:f,viewportRef:h,pinnedTopRowCount:v=0}=n,[E,m]=s.useState(null),y=s.useCallback(k=>{k.target===k.currentTarget&&m(C=>{if(C)return C;if(o)return{id:"HEADER",field:"__checkbox_col__"};const S=t[0],j=e[0];return S&&j?{id:S.id,field:j.field}:null})},[t,e,o]),M=s.useCallback(k=>{k.currentTarget.contains(k.relatedTarget)||m(null)},[]),N=s.useCallback(k=>{if(c(!0),!E)return;const{id:C,field:S}=E,j=!!d.editingCell;if(C==="HEADER"&&(k.key==="Enter"||k.key===" ")){k.preventDefault();const L=e.find(B=>B.field===S);if(L&&L.sortable!==!1){const B=u.find(_=>_.field===S);let D="asc";B&&(D=B.sort==="asc"?"desc":null),p(S,D)}return}if(k.key==="Enter"){if(k.preventDefault(),j)d.stopCellEdit();else if(e.find(B=>B.field===S)?.editable){const B=t.find(D=>D.id===C);B&&d.startCellEdit({id:C,field:S,value:B[S]})}return}if((k.key===" "||k.key==="Spacebar")&&!j){if(S==="__checkbox_col__"){k.preventDefault(),l(C,!i.has(C));return}if(S==="__expand_col__"){k.preventDefault(),a(C);return}}if(k.key==="Escape"){j&&(k.preventDefault(),d.stopCellEdit({cancel:!0}));return}if(j&&k.key!=="Tab")return;const P=C==="HEADER",b=P?-1:t.findIndex(L=>L.id===C),F=e.findIndex(L=>L.field===S);if(!P&&b===-1||F===-1)return;const z=(L,B,D,_,T,I=!1)=>{let O=L+D,X=B+_;return T&&_!==0&&(_>0&&X>=e.length?(X=0,O++):_<0&&X<0&&(X=e.length-1,O--)),!T&&(X<0||X>=e.length)||O<(I?-1:0)||O>=t.length?null:{r:O,c:X}},K=(L,B,D,_,T,I=!1)=>{let O=L,X=B,te=0;const Z=t.length*e.length+e.length;for(;te<Z;){if(te++,O+=D,X+=_,_!==0)_>0?X>=e.length&&(X=0,O++):X<0&&(X=e.length-1,O--);else if(X<0||X>=e.length)return null;if(O<-1||O>=t.length)return null;if(O===-1){if(!I)continue;const Y=e[X],Q=Y.sortable!==!1;if(["__checkbox_col__"].includes(Y.field)||Q)return{r:O,c:X};continue}const ce=t[O],le=e[X],G=["__checkbox_col__","__expand_col__","__reorder_col__"].includes(le.field);let R=le.editable||G;if(w&&!G)try{R=w({row:ce,field:le.field,value:ce[le.field],colDef:le,rowIndex:O,colIndex:X})}catch{}if(R)return{r:O,c:X}}return null};let W=b,$=F,H=!1;if(k.key==="Tab"){const L=k.shiftKey?-1:1,B=K(b,F,0,L,!0,!1);B&&(W=B.r,$=B.c,H=!0)}else if(k.key==="ArrowRight"){const L=z(b,F,0,1,!0,!0);L&&(W=L.r,$=L.c,H=!0)}else if(k.key==="ArrowLeft"){const L=z(b,F,0,-1,!0,!0);L&&(W=L.r,$=L.c,H=!0)}else if(k.key==="ArrowDown"){const L=z(b,F,1,0,!1,!0);L&&(W=L.r,$=L.c,H=!0)}else if(k.key==="ArrowUp"){const L=z(b,F,-1,0,!1,!0);L&&(W=L.r,$=L.c,H=!0)}else if(k.key==="Home")$=0,(k.ctrlKey||k.metaKey)&&(W=-1),H=!0;else if(k.key==="End")$=e.length-1,(k.ctrlKey||k.metaKey)&&(W=t.length-1),H=!0;else if(k.key==="PageUp")W=Math.max(-1,W-(x?g:10)),H=!0;else if(k.key==="PageDown"){const L=x?g:10;W=Math.min(t.length-1,W+L),H=!0}if(H&&(k.preventDefault(),j&&k.key==="Tab"&&d.stopCellEdit(),W>=-1&&W<t.length&&$>=0&&$<e.length)){const L=e[$];m(W===-1?{id:"HEADER",field:L.field}:{id:t[W].id,field:L.field});const B=h.current;if(B){const{cumulativeHeights:D,pinnedBottomHeight:_,columnMetrics:T}=f,{clientWidth:I,scrollLeft:O}=B;if(W>=0&&Mn(B,W-v,D,_),T){const{leftPinnedWidth:X,rightPinnedWidth:te,unpinnedAccWidths:Z,unpinnedCols:ce,totalSpecialsWidth:le,pinnedSpecialsWidth:G}=T,R=ce.findIndex(Y=>Y.field===L.field);if(R!==-1){const Y=le+X+(R>0?Z[R-1]:0),Q=le+X+Z[R],J=O+G+X,re=O+I-te;let q=O;Y<J?q=Math.max(0,Y-G-X):Q>re&&(q=Q-I+te),q!==O&&(B.scrollLeft=q)}}}}},[E,t,e,d,f,i,l,a,c,u,p,w,x,g,h,v]);return{focusedCell:E,setFocusedCell:m,handleFocus:y,handleBlur:M,handleKeyDown:N}}const jo={rowFields:[],columnFields:[],valueFields:[]};function Eo(n){const{initialState:t,sortModel:e,aggregationModel:o,onAggregationModelChange:i,columnVisibilityModel:l,onColumnVisibilityModelChange:a,pinnedColumns:d,onPinnedColumnsChange:c,pivotModel:u,onPivotModelChange:p,paginationModel:w,onPaginationModelChange:x,rowSelectionModel:g}=n,[f,h]=s.useState(()=>t?.sorting?.sortModel??[]),v=e!==void 0,E=v?e:f,m=o!==void 0,[y,M]=s.useState(()=>o??{}),N=m?o:y,k=s.useCallback(R=>{m||M(R),i?.(R)},[m,i]),C=l!==void 0,[S,j]=s.useState(()=>t?.columns?.columnVisibilityModel??{}),P=C?l:S,b=s.useCallback(R=>{C||j(R),a?.(R)},[C,a]),F=d!==void 0,[z,K]=s.useState(()=>t?.columns?.pinnedColumns??{}),W=F?d:z,$=s.useCallback(R=>{F||K(R),c?.(R)},[F,c]),[H,L]=s.useState(()=>u??jo),B=u??H,D=s.useCallback(R=>{L(R),p?.(R)},[p]),_=w!==void 0,[T,I]=s.useState(()=>t?.pagination?.paginationModel??w??{page:0,pageSize:100}),O=_?w:T,X=s.useCallback(R=>{_||I(R),x?.(R)},[_,x]),te=g!==void 0,[Z,ce]=s.useState([]),le=te?g:Z,G=s.useMemo(()=>new Set(le),[le]);return{sortModel:E,isSortControlled:v,setInternalSortModel:h,aggregationModel:N,handleAggregationModelChange:k,columnVisibilityModel:P,handleColumnVisibilityModelChange:b,pinnedColumns:W,handlePinnedColumnsChange:$,currentPivotModel:B,handlePivotModelChange:D,effectivePaginationModel:O,handlePaginationModelChange:X,rowSelectionModel:le,selectedRowIds:G,isSelectionControlled:te,setInternalRowSelectionModel:ce}}const No={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:i}=t,l=n[e],a=No[o];return a?a(l,i):(console.warn(`Unknown filter operator: ${o}`),!0)}function Po(n,t){return!t||t.length===0?!0:t.every(e=>{const o=e.toLowerCase();return Object.values(n).some(i=>i==null?!1:String(i).toLowerCase().includes(o))})}function nn(n,t){const e=t.items??[],o=t.logicOperator??"and",i=("quickFilterValues"in t?t.quickFilterValues:void 0)??[];if(i.length>0&&!Po(n,i))return!1;if(e.length===0)return!0;const l=a=>{if("logicOperator"in a&&"items"in a){const d=a,c=d.items;return c.length===0?!0:d.logicOperator==="and"?c.every(l):c.some(l)}else return Mo(n,a)};return o==="and"?e.every(l):e.some(l)}function Ro(n,t){if(!t)return n;const{items:e=[],quickFilterValues:o=[]}=t;return e.length===0&&(!o||o.length===0)?n:n.filter(i=>nn(i,t))}function To(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 on(n,t,e){if(n==null&&t==null)return 0;if(n==null)return e==="asc"?1:-1;if(t==null)return e==="asc"?-1:1;if(typeof n=="number"&&typeof t=="number")return e==="asc"?n-t:t-n;if(n instanceof Date&&t instanceof Date)return e==="asc"?n.getTime()-t.getTime():t.getTime()-n.getTime();const o=String(n).toLowerCase(),i=String(t).toLowerCase();return e==="asc"?o<i?-1:o>i?1:0:o>i?-1:o<i?1:0}function Io(n,t){if(t.length===0)return n;const e=[...n];return e.sort((o,i)=>{for(const l of t){const a=o[l.field],d=i[l.field],c=on(a,d,l.sort);if(c!==0)return c}return 0}),e}function Lo(n){const{effectiveRows:t,activeHierarchyHandlers:e,filterMode:o,filterModel:i,dataSource:l,sortModel:a,sortingMode:d,pagination:c,paginationMode:u,effectivePaginationModel:p,pinnedRows:w,isLoading:x,pageSize:g}=n,f=s.useMemo(()=>e?e.getVisibleRows()||[]:o==="server"&&l?t:Ro(t,i),[t,i,e,o,l]),{top:h,center:v,bottom:E}=s.useMemo(()=>e?{top:[],center:f,bottom:[]}:yo(f,w),[f,w,e]),m=s.useMemo(()=>e||d==="server"&&l?v:Io(v,a),[v,a,e,d,l]),y=s.useMemo(()=>{if(!c||u==="server"&&l)return m;const N=p.page*p.pageSize;return m.slice(N,N+p.pageSize)},[m,c,p.page,p.pageSize,u,l]),M=s.useMemo(()=>{if(e)return v;const N=c?y:m,k=[...h,...N,...E];if(u==="infinite"&&x&&k.length>0){const C=Math.min(g,20),S=Array.from({length:C},(j,P)=>({id:`__skeleton_${P}__`,_isSkeleton:!0}));return[...k,...S]}return k},[h,y,m,E,c,e,v,u,x,g]);return{filteredRows:f,pinnedTopRows:h,unpinnedRows:v,pinnedBottomRows:E,sortedUnpinnedRows:m,paginatedUnpinnedRows:y,allRenderableRows:M}}function Fo(n){const{layout:t,scrollTop:e,scrollLeft:o,viewportWidth:i,viewportHeight:l,autoHeight:a,rowReordering:d,hasDetailPanel:c,checkboxSelection:u,pinCheckboxColumn:p,pinExpandColumn:w,overscanRows:x=5}=n;return s.useMemo(()=>{const{unpinnedAccWidths:g,unpinnedColsWithWidth:f,leftPinnedCols:h,rightPinnedCols:v,totalWidth:E,leftWidth:m,rightWidth:y,unpinnedTotalWidth:M,systemColumnsWidth:N,cumulativeHeights:k,pinnedTopHeight:C,pinnedBottomHeight:S,unpinnedRowsHeight:j,rowHeights:P,unpinnedRowsLength:b}=t,F=i||1e3,z=a?C+j+S+50:l||600,K=6,W=Math.max(0,o-m),$=o+F-m;let H=0,L=f.length-1,B=0,D=g.length-1;for(;B<=D;){const Q=B+D>>>1;g[Q]<W?B=Q+1:D=Q-1}H=Math.max(0,B-K);for(let Q=H;Q<g.length;Q++){if((Q===0?0:g[Q-1])>$){L=Math.min(f.length-1,Q+K);break}L=Math.min(f.length-1,Q+K)}const _=H>0?g[H-1]:0,T=M-g[L],I=[...h,..._>0?[{field:"__spacer_left__",width:_,isSpacer:!0}]:[],...f.slice(H,L+1),...T>0?[{field:"__spacer_right__",width:T,isSpacer:!0}]:[],...v],X=F>0&&E>F?16:0,te=C+j+S+X+2;let Z=0,ce=b-1,le=0,G=0,R=k.length-1;for(;G<=R;){const Q=G+R>>>1;k[Q]<e?G=Q+1:R=Q-1}Z=Math.max(0,G-x),le=Z>0?k[Z-1]:0;for(let Q=Z;Q<k.length;Q++)if(k[Q]>=e+z){ce=Math.min(b-1,Q+x);break}const Y=(d?48:0)+(c&&w?48:0)+(u&&p?48:0);return{renderContext:{firstRowIndex:Z,lastRowIndex:ce,firstColumnIndex:H,lastColumnIndex:L},offsetTop:le,offsetLeft:0,totalHeight:te,pinnedTopHeight:C,pinnedBottomHeight:S,totalWidth:E,rowHeights:P,cumulativeHeights:k,virtualColumns:I,columnMetrics:{leftPinnedWidth:m,rightPinnedWidth:y,unpinnedAccWidths:g,unpinnedCols:f,totalSpecialsWidth:N,pinnedSpecialsWidth:Y}}},[t,e,o,i,l,a,d,c,u,p,w,x])}function Oo(n){const{columns:t,onColumnOrderChange:e,disableColumnReorder:o=!1}=n,[i,l]=s.useState(null),[a,d]=s.useState(null),c=s.useRef(-1),u=s.useCallback(g=>f=>{if(o)return;const h=t.findIndex(E=>E.field===g);if(t[h]?.pinnable===!1){f.preventDefault();return}l(g),c.current=h,f.dataTransfer&&(f.dataTransfer.effectAllowed="move",f.dataTransfer.setData("text/plain",g))},[t,o]),p=s.useCallback(g=>f=>{o||!i||(f.preventDefault(),f.dataTransfer.dropEffect="move",d(g))},[i,o]),w=s.useCallback(g=>f=>{if(f.preventDefault(),o||!i||i===g){l(null),d(null);return}const h=t.findIndex(m=>m.field===i),v=t.findIndex(m=>m.field===g);if(h===-1||v===-1){l(null),d(null);return}const E=t[h];e&&e({column:E,oldIndex:h,targetIndex:v}),l(null),d(null),c.current=-1},[t,i,o,e]),x=s.useCallback(()=>{l(null),d(null),c.current=-1},[]);return{draggedColumn:i,dragOverColumn:a,onDragStart:o?void 0:u,onDragOver:o?void 0:p,onDragEnd:o?void 0:x,onDrop:o?void 0:w}}function Pn({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"})})})}const rn=n=>n.formattedValue??n.value;function Wo(n){const{activeColumns:t,isHierarchyEnabled:e,isRowGrouping:o,isTreeData:i,activeHierarchyHandlers:l,columnVisibilityModel:a,columnOrder:d,onColumnOrderChange:c,disableColumnReorder:u,pivotMode:p,checkboxSelection:w,hasDetailPanel:x,rowReordering:g,initialState:f,setColumns:h}=n,v=s.useMemo(()=>e?t.map((b,F)=>F===0?{...b,renderCell:z=>{const K=z.rowMeta,W=K?.treeDepth??0,$=!!K?.hasChildren,H=!!K?.isExpanded,L=K?.groupingField,B=K?.groupingValue,D=K?.descendantCount,_=!!K?.isGroupRow;let T=b.renderCell?b.renderCell(z):rn(z);if(i&&$&&_&&(T=r.jsxs("div",{className:"ogx__group-cell-content",children:[z.value,D!==void 0&&D>0?` (${D})`:""]})),o&&$&&L){const I=K?.groupLabel??`${L}: ${String(B)}`;T=r.jsxs("div",{className:"ogx__group-cell-content",children:[I,D!==void 0?` (${D})`:""]})}return r.jsxs("div",{style:{display:"flex",alignItems:"center",paddingLeft:W*24,width:"100%",height:"100%"},children:[r.jsx("div",{style:{marginRight:4,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",cursor:$?"pointer":"default",flexShrink:0},children:$?r.jsx("div",{onClick:I=>{I.stopPropagation(),I.preventDefault(),l?.toggleExpansion(z.row.id)},onMouseDown:I=>{I.stopPropagation()},style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:10,position:"relative"},children:r.jsx(Pn,{isExpanded:H,onClick:I=>{I.stopPropagation(),I.preventDefault(),l?.toggleExpansion(z.row.id)}})}):null}),r.jsx("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:T})]})}}:{...b,renderCell:z=>{const K=z.rowMeta,W=!!K?.hasChildren,$=K?.groupingField;return o&&W?b.field===$?null:z.value!==void 0&&z.value!==null?b.renderCell?b.renderCell(z):rn(z):null:b.renderCell?b.renderCell(z):rn(z)}}):t,[t,e,o,i,l]),[E,m]=s.useState(()=>f?.columns?.columnWidths??{}),y=s.useCallback((b,F)=>{m(z=>({...z,[b]:F}))},[]),[M,N]=s.useState(()=>f?.columns?.columnOrder??t.map(b=>b.field)),k=d??M;s.useEffect(()=>{h(t)},[t,h]),s.useEffect(()=>{p&&N(t.map(b=>b.field))},[p,t]);const C=s.useMemo(()=>{if(u)return v;const b=new Map(k.map((F,z)=>[F,z]));return[...v].sort((F,z)=>{const K=b.get(F.field)??v.indexOf(F),W=b.get(z.field)??v.indexOf(z);return K-W})},[v,k,u]),S=s.useMemo(()=>C.filter(b=>a[b.field]!==!1),[C,a]),j=Oo({columns:C,onColumnOrderChange:s.useCallback(b=>{const{oldIndex:F,targetIndex:z}=b,K=[...k],[W]=K.splice(F,1);K.splice(z,0,W),d||N(K),c?.(b)},[k,d,c]),disableColumnReorder:u}),P=s.useMemo(()=>{const b=[];return g&&b.push({field:"__reorder_col__"}),x&&b.push({field:"__expand_col__"}),w&&b.push({field:"__checkbox_col__"}),[...b,...C]},[C,w,x,g]);return{effectiveColumns:v,orderedColumns:C,visibleOrderedColumns:S,navigationColumns:P,columnWidths:E,effectiveColumnOrder:k,setInternalColumnOrder:N,columnReorderHandlers:j,handleColumnResize:y}}function Ao(n){const{renderContext:t,pinnedTopRows:e,pinnedBottomRows:o,paginatedUnpinnedRows:i,sortedUnpinnedRows:l,pagination:a}=n;return s.useMemo(()=>{const{firstRowIndex:d,lastRowIndex:c}=t,u=a?i:l,p=e.length,w=e.map((m,y)=>({row:m,rowIndex:y})),x=o.map((m,y)=>({row:m,rowIndex:p+u.length+y})),g=Math.max(0,d),f=Math.min(u.length,c+1),h=u.slice(g,f).map((m,y)=>({row:m,rowIndex:p+g+y})),v=[...w,...h,...x],E=new Set;return v.filter(m=>E.has(m.row.id)?!1:(E.add(m.row.id),!0))},[t,e,o,i,l,a])}function $o(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 zo(n){const{onRowsScrollEnd:t,overscanRowCount:e=3}=n,o=s.useRef({scrollTop:0,scrollLeft:0,velocity:0}),i=s.useRef({scrollTop:0,scrollLeft:0,time:0}),l=s.useRef(null),a=s.useRef(null),[d,c]=s.useState({scrollTop:0,scrollLeft:0,overscanRows:e});s.useEffect(()=>()=>{l.current!==null&&cancelAnimationFrame(l.current),a.current!==null&&clearTimeout(a.current)},[]);const u=s.useCallback(p=>{const w=p.currentTarget,x=performance.now(),g=Math.abs(w.scrollTop-i.current.scrollTop)+Math.abs(w.scrollLeft-i.current.scrollLeft),f=x-i.current.time,h=f>0?g/f:0;if(i.current={scrollTop:w.scrollTop,scrollLeft:w.scrollLeft,time:x},o.current={scrollTop:w.scrollTop,scrollLeft:w.scrollLeft,velocity:h},l.current!==null&&cancelAnimationFrame(l.current),l.current=requestAnimationFrame(()=>{l.current=null;const{scrollTop:v,scrollLeft:E,velocity:m}=o.current;c({scrollTop:v,scrollLeft:E,overscanRows:$o(m,e)})}),a.current!==null&&clearTimeout(a.current),a.current=setTimeout(()=>{a.current=null,c(v=>({...v,overscanRows:e}))},200),t){const{scrollTop:v,scrollHeight:E,clientHeight:m}=w;E-v-m<100&&t({visibleTop:v,visibleBottom:v+m,viewportHeight:m})}},[t,e]);return{scrollTop:d.scrollTop,scrollLeft:d.scrollLeft,overscanRows:d.overscanRows,handleScroll:u}}function Bo(n){const{onStateChange:t,sortModel:e,filterModel:o,effectivePaginationModel:i,columnWidths:l,effectiveColumnOrder:a,columnVisibilityModel:d,pinnedColumns:c}=n,u=s.useRef(t);s.useLayoutEffect(()=>{u.current=t}),s.useEffect(()=>{if(!u.current)return;const p={sorting:{sortModel:e},filter:{filterModel:o},pagination:{paginationModel:i},columns:{columnWidths:l,columnOrder:a,columnVisibilityModel:d,pinnedColumns:c}};u.current(p)},[e,o,i,l,a,d,c])}const Do=200;function Ho(n){const{paginationRequested:t,isRowGrouping:e,autoHeight:o,viewportHeight:i,renderedRowCount:l,totalRowCount:a}=n,d=s.useRef(!1),c=s.useRef(!1);s.useEffect(()=>{process.env.NODE_ENV==="production"||d.current||t&&e&&(d.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,e]),s.useEffect(()=>{process.env.NODE_ENV==="production"||c.current||o||i>0&&a>Do&&l>=a&&(c.current=!0,console.warn(`[OpenGridX] The grid viewport is ${Math.round(i)}px tall and is rendering all ${a} 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.`))},[o,i,l,a])}const Ot=n=>{const t=[];for(const e of n){if(e==null)continue;const o=Number(e);isNaN(o)||t.push(o)}return t},Vo=n=>{if(n.length===0)return null;let t=n[0];for(let e=1;e<n.length;e++)n[e]<t&&(t=n[e]);return t},Go=n=>{if(n.length===0)return null;let t=n[0];for(let e=1;e<n.length;e++)n[e]>t&&(t=n[e]);return t},Uo={sum:n=>Ot(n).reduce((t,e)=>t+e,0),avg:n=>{const t=Ot(n);return t.length?t.reduce((e,o)=>e+o,0)/t.length:null},count:n=>n.filter(t=>t!=null).length,min:n=>Vo(Ot(n)),max:n=>Go(Ot(n)),unique:n=>new Set(n.filter(t=>t!=null)).size};function Rn(n,t,e,o){const i={};for(const[l,a]of Object.entries(t)){const d=e.get(l);if(d?.availableAggregationFunctions&&!d.availableAggregationFunctions.includes(a))continue;const c=Uo[a];if(!c){console.warn(`[${o}] Unknown aggregation function: "${a}"`);continue}i[l]=c(n.map(u=>u[l]))}return i}function ve(n,t){return n==null?"—":typeof n=="number"?t==="avg"?n.toLocaleString(void 0,{maximumFractionDigits:2}):n.toLocaleString():String(n)}function Tn(n){const{rows:t,columns:e,aggregationModel:o,isServerSide:i,dataSource:l,filterModel:a,sortModel:d,serverAggregationResults:c}=n,u=s.useMemo(()=>{const M=new Map;return(e??[]).forEach(N=>M.set(N.field,N)),M},[e]),p=s.useMemo(()=>i||Object.keys(o).length===0?{}:Rn(t,o,u,"useAggregation"),[t,u,o,i]),[w,x]=s.useState({}),[g,f]=s.useState(!1),[h,v]=s.useState(null),E=s.useRef(0),m=s.useCallback(async()=>{if(!l?.getAggregations||Object.keys(o).length===0)return;const M=++E.current;f(!0),v(null);try{const N=await l.getAggregations({sortModel:d??[],filterModel:a??{items:[]},groupKeys:[],aggregationModel:o});M===E.current&&x(N)}catch(N){M===E.current&&(v(N),console.error("[useAggregation] Server aggregation error:",N))}finally{M===E.current&&f(!1)}},[l,o,a,d]);return s.useEffect(()=>{i&&l?.getAggregations&&!c&&m()},[m,i,l,c]),{aggregationResult:s.useMemo(()=>i?c&&Object.keys(c).length>0?c:w:p,[i,p,c,w]),isLoading:g,error:h}}function Ko({columns:n,aggregationModel:t,aggregationResult:e,columnWidths:o,rowHeight:i,checkboxSelection:l,hasDetailPanel:a,rowReordering:d,pinnedColumns:c}){const u=s.useMemo(()=>en(n,o,c,l,!0,a,!0,d),[n,o,c,l,a,d]),p=c?.left?.[c.left.length-1],w=c?.right?.[0];return r.jsxs("div",{className:"ogx__aggregation-footer",role:"row","aria-label":"Aggregation totals","aria-live":"polite",style:{minHeight:`${i}px`},children:[l&&r.jsx("div",{style:{width:48,flexShrink:0}}),a&&r.jsx("div",{style:{width:48,flexShrink:0}}),d&&r.jsx("div",{style:{width:48,flexShrink:0}}),n.map(x=>{const g=t[x.field],f=e[x.field],h=o[x.field]??(typeof x.width=="number"?x.width:120),v=wt(x.field,c),E=v?u[x.field]:void 0,m=["ogx__aggregation-cell",v==="left"&&"ogx__aggregation-cell--pinned-left",v==="right"&&"ogx__aggregation-cell--pinned-right",v==="left"&&x.field===p&&"ogx__aggregation-cell--pinned-left-last",v==="right"&&x.field===w&&"ogx__aggregation-cell--pinned-right-first"].filter(Boolean).join(" "),y={width:h,minWidth:h,maxWidth:h,textAlign:x.align||"left"};return v==="left"&&E!==void 0&&(y.left=E),v==="right"&&E!==void 0&&(y.right=E),r.jsx("div",{className:m,role:"gridcell",style:y,children:g?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"ogx__aggregation-label",children:g}),r.jsx("span",{className:"ogx__aggregation-value",children:ve(f,g)})]}):null},x.field)})]})}function Yo({noRowsLabel:n,width:t,overlay:e}){return e?r.jsx("div",{className:"ogx__empty",style:{width:t},children:e}):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 qo({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 bt=({indeterminate:n=!1,label:t,className:e="",inputRef:o,...i})=>{const l=s.useRef(null),a=s.useCallback(c=>{l.current=c,typeof o=="function"?o(c):o&&(o.current=c)},[o]);s.useEffect(()=>{l.current&&(l.current.indeterminate=n)},[n]);const d=["ogx-checkbox-wrapper",i.disabled&&"ogx-checkbox-wrapper--disabled",e].filter(Boolean).join(" ");return r.jsxs("label",{className:d,children:[r.jsx("input",{ref:a,type:"checkbox",className:"ogx-checkbox__input","aria-label":t||i["aria-label"]||(n?"Select some":i.checked?"Deselect":"Select"),...i}),r.jsxs("span",{className:"ogx-checkbox__box",children:[i.checked&&!n&&r.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:r.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})}),n&&r.jsx("svg",{className:"ogx-checkbox__icon",viewBox:"0 0 24 24","aria-hidden":"true",children:r.jsx("path",{d:"M19 13H5v-2h14v2z"})})]}),t&&r.jsx("span",{className:"ogx-checkbox__label",children:t})]})};function Xo(n){const{field:t,currentWidth:e,onResize:o,minWidth:i=50,maxWidth:l=1e3}=n,[a,d]=s.useState(!1),c=s.useRef(0),u=s.useRef(0),p=s.useCallback(g=>{g.preventDefault(),g.stopPropagation(),d(!0),c.current=g.clientX,u.current=e;let f=0;const h=16,v=m=>{const y=m.clientX-c.current,M=Math.max(i,Math.min(l,u.current+y)),N=Date.now();N-f>=h&&(o(t,M),f=N)},E=m=>{d(!1);const y=m.clientX-c.current,M=Math.max(i,Math.min(l,u.current+y));o(t,M),document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",E)};document.addEventListener("mousemove",v),document.addEventListener("mouseup",E)},[t,e,o,i,l]),w=s.useCallback(g=>{g.preventDefault(),g.stopPropagation()},[]),x=["ogx-column-resize-handle",a&&"ogx-column-resize-handle--dragging"].filter(Boolean).join(" ");return r.jsx("div",{className:x,onMouseDown:p,onClick:g=>g.stopPropagation(),onDragStart:g=>{g.preventDefault(),g.stopPropagation()},onDoubleClick:w,role:"separator","aria-orientation":"vertical","aria-label":`Resize ${t} column`,children:r.jsx("div",{className:"ogx-column-resize-handle__line"})})}function Qe(){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 Ze(){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 Jo(){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 Qo(){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 Zo(){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 er(){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 tr(){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 nr(){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 or(){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 rr(){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 ir({colDef:n,sortModel:t,onSort:e,onHide:o,onPin:i,pinnedColumns:l,onManageColumns:a,onClose:d,anchorEl:c}){const u=s.useRef(null),[p,w]=s.useState({position:"fixed",zIndex:1300,top:0,left:0,visibility:"hidden"});s.useLayoutEffect(()=>{if(!c||!u.current)return;const N=c.getBoundingClientRect(),k=u.current.getBoundingClientRect(),C=window.innerWidth,S=window.innerHeight,j=8;let P=N.left;P+k.width+j>C&&(P=C-k.width-j),P<j&&(P=j);let b=N.bottom+4;b+k.height+j>S&&(b=N.top-k.height-4),w({position:"fixed",zIndex:1300,top:b,left:P,visibility:"visible"})},[c]),s.useEffect(()=>{function N(C){u.current&&!u.current.contains(C.target)&&c&&!c.contains(C.target)&&d()}function k(C){C.key==="Escape"&&d()}return document.addEventListener("mousedown",N),document.addEventListener("keydown",k),window.addEventListener("scroll",d,!0),window.addEventListener("resize",d),()=>{document.removeEventListener("mousedown",N),document.removeEventListener("keydown",k),window.removeEventListener("scroll",d,!0),window.removeEventListener("resize",d)}},[c,d]);const x=N=>{e?.(n.field,N),d()},g=()=>{o?.(n.field),d()},f=N=>{i?.(n.field,N),d()},h=t?.find(N=>N.field===n.field)?.sort,v=h==null,E=l?.left?.includes(n.field)??!1,m=l?.right?.includes(n.field)??!1,y=!E&&!m,M=n.headerName||n.field;return Ve.createPortal(r.jsxs("div",{ref:u,className:"ogx-column-menu",style:p,role:"menu","aria-label":`Column options for ${M}`,children:[e&&n.sortable!==!1&&r.jsxs(r.Fragment,{children:[r.jsxs("button",{className:`ogx-menu-item${h==="asc"?" ogx-menu-item--active":""}`,onClick:()=>x("asc"),role:"menuitemradio","aria-checked":h==="asc",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:h==="asc"?r.jsx(Qe,{}):r.jsx(Ze,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(Qo,{})}),"Sort Ascending"]}),r.jsxs("button",{className:`ogx-menu-item${h==="desc"?" ogx-menu-item--active":""}`,onClick:()=>x("desc"),role:"menuitemradio","aria-checked":h==="desc",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:h==="desc"?r.jsx(Qe,{}):r.jsx(Ze,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(Zo,{})}),"Sort Descending"]}),r.jsxs("button",{className:`ogx-menu-item${v?" ogx-menu-item--active":""}`,onClick:()=>x(null),role:"menuitemradio","aria-checked":v,children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:v?r.jsx(Qe,{}):r.jsx(Ze,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(er,{})}),"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:()=>f("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(Qe,{}):r.jsx(Ze,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(nr,{})}),"Pin to Left"]}),r.jsxs("button",{className:`ogx-menu-item${m?" ogx-menu-item--active":""}`,onClick:()=>f("right"),role:"menuitemradio","aria-checked":m,"aria-label":"Pin to right",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:m?r.jsx(Qe,{}):r.jsx(Ze,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(or,{})}),"Pin to Right"]}),r.jsxs("button",{className:`ogx-menu-item${y?" ogx-menu-item--active":""}`,onClick:()=>f(null),role:"menuitemradio","aria-checked":y,"aria-label":"Unpin column",children:[r.jsx("span",{className:"ogx-menu-item__indicator","aria-hidden":"true",children:y?r.jsx(Qe,{}):r.jsx(Ze,{})}),r.jsx("span",{className:"ogx-menu-item__icon","aria-hidden":"true",children:r.jsx(rr,{})}),"Unpin"]}),r.jsx("div",{className:"ogx-menu-divider"}),r.jsxs("button",{className:"ogx-menu-item",onClick:g,role:"menuitem","aria-label":`Hide ${M} 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(tr,{})}),"Hide Column"]}),r.jsx("div",{className:"ogx-menu-divider"}),r.jsxs("button",{className:"ogx-menu-item",onClick:()=>{a?.(),d()},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(Jo,{})}),"Manage columns"]})]}),c?.closest(".ogx-theme-provider")||document.body)}function lr(){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 sr(){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 In(n){const t=[];for(const e of n.children)typeof e=="string"?t.push(e):t.push(...In(e));return t}function ar(n){let t=0;function e(o,i){t=Math.max(t,i);for(const l of o.children)typeof l!="string"&&e(l,i+1)}return n.forEach(o=>e(o,1)),t}function dr(n,t,e){function o(d,c,u){if(!In(d).includes(c))return null;if(u===e)return d;for(const p of d.children)if(typeof p!="string"){const w=o(p,c,u+1);if(w)return w}return null}const i=new Map;for(const d of t){let c=null;for(const u of n)if(c=o(u,d.field,0),c)break;i.set(d.field,c)}const l=[];let a=0;for(;a<t.length;){const d=t[a],c=i.get(d.field)??null,u=d.width;if(!c)l.push({key:`fg-${d.field}-${e}`,label:"",width:u,isGroup:!1}),a++;else{let p=0,w=a;for(;w<t.length&&i.get(t[w].field)===c;)p+=t[w].width,w++;l.push({key:`${c.groupId}-${e}`,label:c.headerName,width:p,isGroup:!0}),a=w}}return l}function Ln(n){const{columns:t,allColumns:e,columnGroupingModel:o,checkboxSelection:i=!1,allSelected:l=!1,someSelected:a=!1,onSelectAll:d,onSort:c,sortModel:u=[],onColumnResize:p,columnWidths:w={},pinnedColumns:x,hasDetailPanel:g=!1,pinCheckboxColumn:f=!0,pinExpandColumn:h=!0,rowReordering:v=!1,aggregationModel:E,draggedColumn:m,dragOverColumn:y,onDragStart:M,onDragOver:N,onDragEnd:k,onDrop:C,focusedCell:S,onHeaderClick:j,onSortAdd:P,multiSort:b=!1,onHideColumn:F,onPinColumn:z,onManageColumns:K}=n,W=s.useId(),$=s.useRef({}),[H,L]=s.useState(null),B=R=>Y=>{Y.stopPropagation(),L({colDef:R,anchorEl:Y.currentTarget})},D=()=>{L(null)};s.useLayoutEffect(()=>{if(S?.id==="HEADER"){const R=$.current[S.field];R&&R.focus()}},[S]);const _=R=>Y=>{if(R.sortable===!1)return;const Q=u.find(re=>re.field===R.field);let J="asc";Q&&(Q.sort==="asc"?J="desc":J=null),(Y.shiftKey||b)&&P?P(R.field,J):c&&c(R.field,J)},T=R=>{const Y=u.find(J=>J.field===R);if(!Y)return null;const Q=u.length>1?u.indexOf(Y)+1:null;return r.jsx("span",{className:`ogx__sort-icon ogx__sort-icon--${Y.sort}`,"aria-hidden":"true",children:Q!==null&&r.jsx("span",{className:"ogx__sort-badge",children:Q})})},I=s.useMemo(()=>en(t,w,x,i,f,g,h,v),[t,w,x,i,f,g,h,v]),O=o?ar(o):0,te=(e??t).filter(R=>!R.isSpacer).map(R=>({field:R.field,width:w[R.field]??R.width??100})),G=(v?48:0)+(g?48:0)+(i?48:0);return r.jsxs("div",{className:"ogx__header-wrap",children:[O>0&&Array.from({length:O},(R,Y)=>{const Q=dr(o,te,Y);return r.jsxs("div",{className:"ogx-col-group-row",role:"row",children:[G>0&&r.jsx("div",{className:"ogx-col-group-cell ogx-col-group-cell--filler",style:{width:G,minWidth:G,flexShrink:0},role:"columnheader"}),Q.map(J=>r.jsx("div",{role:"columnheader",className:`ogx-col-group-cell ${J.isGroup?"ogx-col-group-cell--group":"ogx-col-group-cell--filler"}`,style:{width:J.width,minWidth:J.width,flexShrink:0},title:J.isGroup?J.label:void 0,children:J.isGroup&&r.jsx("span",{className:"ogx-col-group-cell__label",children:J.label})},J.key))]},`ogx-grp-${Y}`)}),r.jsxs("div",{className:"ogx__header",role:"row",children:[v&&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}}),g&&r.jsx("div",{className:`ogx__header-cell ogx__header-cell--expand ${h?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""}`,role:"columnheader","aria-label":"Expand row details",style:{minWidth:48,maxWidth:48,position:h?"sticky":void 0,left:h?v?48:0:void 0,zIndex:h?5:void 0}}),i&&r.jsx("div",{className:`ogx__header-cell ogx__header-cell--checkbox ${f?"ogx__header-cell--pinned ogx__header-cell--pinned-left":""}`,role:"columnheader",style:{position:f?"sticky":void 0,left:f?(v?48:0)+(g&&h?48:0):void 0},children:r.jsx(bt,{id:W,name:W,checked:l,indeterminate:a,onChange:R=>d?.(R.target.checked),"aria-label":l?"Deselect all rows":"Select all rows",tabIndex:S?.id==="HEADER"&&S.field==="__checkbox_col__"?0:-1,onMouseDown:R=>R.preventDefault(),inputRef:R=>{$.current.__checkbox_col__=R}})}),t.map((R,Y)=>{if(R.isSpacer)return r.jsx("div",{style:{width:R.width,minWidth:R.width,flexShrink:0},"aria-hidden":"true"},R.field);const Q=R.sortable!==!1,J=u.some(oe=>oe.field===R.field),re=R.resizable!==!1,q=wt(R.field,x),V=q!==null,A=m===R.field,ee=y===R.field,ie=["ogx__header-cell",`ogx__header-cell--align-${R.headerAlign||R.align||"left"}`,Q&&"ogx__header-cell--sortable",J&&"ogx__header-cell--sorted",V&&"ogx__header-cell--pinned",V&&`ogx__header-cell--pinned-${q}`,A&&"ogx__header-cell--dragging",ee&&"ogx__header-cell--drag-over",S?.id==="HEADER"&&S.field===R.field&&"ogx__header-cell--focused",R.headerClassName].filter(Boolean).join(" "),ae=w[R.field]??R.width??100,fe={width:ae,minWidth:R.minWidth,maxWidth:R.maxWidth,flexGrow:R.flex??0,flexShrink:0,flexBasis:(R.flex,"auto"),boxSizing:"border-box",position:V?"sticky":"relative",zIndex:R.zIndex,opacity:A?.5:1};if(V&&q){const oe=I[R.field];q==="left"?fe.left=oe:fe.right=oe}const he=R.renderHeader?R.renderHeader({field:R.field,colDef:R,colIndex:Y}):R.headerName||R.field,Me=oe=>{if(oe.target.closest(".ogx-column-resize-handle")){oe.stopPropagation();return}j?.(R.field),Q&&_(R)(oe)},ke=M?M(R.field):void 0,Pe=N?N(R.field):void 0,Se=C?C(R.field):void 0;return r.jsxs("div",{className:ie,style:fe,title:R.description,onClick:Me,role:"columnheader",draggable:!!M,onDragStart:ke,onDragOver:Pe,onDragEnd:k,onDrop:Se,"aria-sort":Q?J?u.find(oe=>oe.field===R.field)?.sort==="asc"?"ascending":"descending":"none":void 0,"aria-colindex":Y+1+(i?1:0),"data-field":R.field,tabIndex:-1,ref:oe=>{$.current[R.field]=oe},children:[r.jsxs("div",{className:"ogx__header-cell-content",children:[A&&r.jsx("div",{className:"ogx__header-drag-icon",children:r.jsx(sr,{})}),r.jsxs("div",{className:"ogx__header-cell-title-wrapper",children:[r.jsx("span",{className:"ogx__header-cell-title",children:he}),E&&E[R.field]&&r.jsx("span",{className:"ogx__header-cell-aggregation",children:E[R.field]})]}),Q&&T(R.field),!R.disableColumnMenu&&r.jsx("button",{className:"ogx__menu-icon-btn",onClick:B(R),"aria-label":`Open column menu for ${R.headerName||R.field}`,"aria-haspopup":"menu",tabIndex:-1,children:r.jsx(lr,{})})]}),re&&p&&r.jsx(Xo,{field:R.field,currentWidth:ae,onResize:p,minWidth:R.minWidth,maxWidth:R.maxWidth})]},R.field)}),H&&r.jsx(ir,{colDef:H.colDef,sortModel:u,onSort:c,onHide:F,onPin:z,pinnedColumns:x,onManageColumns:K,onClose:D,anchorEl:H.anchorEl})]})]})}const vt=({variant:n="text",size:t="medium",color:e="default",disabled:o=!1,className:i="",children:l,...a})=>{const d=["ogx-button",`ogx-button--${n}`,`ogx-button--${t}`,`ogx-button--${e}`,o&&"ogx-button--disabled",i].filter(Boolean).join(" ");return r.jsx("button",{className:d,disabled:o,...a,children:l})};function Fn(n){const t=s.useId(),{page:e,pageSize:o,rowCount:i,onPageChange:l,onPageSizeChange:a,pageSizeOptions:d=[10,25,50,100],showFirstButton:c=!0,showLastButton:u=!0,localeText:p}=n,w=Math.max(1,Math.ceil(i/o)),x=Math.min(e,w-1),g=x*o,f=Math.min(g+o,i),h=i===0?0:`${g+1}–${f}`,v=p?.paginationRowsPerPage??"Rows per page:",E=p?.paginationOf?p.paginationOf(i===0?0:g+1,f,i):`${h} of ${i}`,m=p?.paginationPage?p.paginationPage(x+1,w):`Page ${x+1} of ${w}`,y=()=>{l(0)},M=()=>{l(Math.max(0,x-1))},N=()=>{l(Math.min(w-1,x+1))},k=()=>{l(w-1)},C=P=>{const b=parseInt(P.target.value,10);a(b)},S=x===0,j=x>=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:v}),r.jsx("select",{id:t,className:"ogx-pagination__select",value:o,onChange:C,"aria-label":"Rows per page",children:d.map(P=>r.jsx("option",{value:P,children:P},P))})]}),r.jsx("div",{className:"ogx-pagination__info","aria-live":"polite","aria-atomic":"true",children:E}),r.jsxs("div",{className:"ogx-pagination__actions",children:[c&&r.jsx(vt,{variant:"text",size:"small",onClick:y,disabled:S,"aria-label":"Go to first page",title:"First page",children:r.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:r.jsx("path",{d:"M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z"})})}),r.jsx(vt,{variant:"text",size:"small",onClick:M,disabled:S,"aria-label":"Go to previous page",title:"Previous page",children:r.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:r.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),r.jsx("div",{className:"ogx-pagination__page-info","aria-current":"page",children:m}),r.jsx(vt,{variant:"text",size:"small",onClick:N,disabled:j,"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"})})}),u&&r.jsx(vt,{variant:"text",size:"small",onClick:k,disabled:j,"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 cr(n,t,e={}){const o=new Map,i=[];n.forEach(d=>{o.set(d.id,d),i.push(d.id)});const l=new Map,a=[];return t.forEach(d=>{l.set(d.field,d),a.push(d.field)}),{rows:{idRowsLookup:o,allRows:i},columns:{all:t,lookup:l,orderedFields:a,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 ur(n,t){switch(t.type){case"SET_ROWS":{const e=Array.from(n.rows.idRowsLookup.values()),o=typeof t.payload=="function"?t.payload(e):t.payload,i=new Map,l=[];return o.forEach(a=>{i.set(a.id,a),l.push(a.id)}),{...n,rows:{idRowsLookup:i,allRows:l},pagination:{...n.pagination,rowCount:t.preserveRowCount?n.pagination.rowCount:o.length}}}case"SET_COLUMNS":{const e=new Map,o=[];return t.payload.forEach(i=>{e.set(i.field,i),o.push(i.field)}),{...n,columns:{all:t.payload,lookup:e,orderedFields:o,columnVisibilityModel:n.columns.columnVisibilityModel}}}case"SET_SORT_MODEL":return{...n,sorting:{sortModel:t.payload}};case"SET_FILTER_MODEL":return{...n,filter:{filterModel:t.payload}};case"SET_PAGINATION_MODEL":return{...n,pagination:{...n.pagination,paginationModel:t.payload}};case"SET_SELECTION":return{...n,selection:{selectedRows:t.payload}};case"SET_DIMENSIONS":return{...n,dimensions:{...n.dimensions,viewportWidth:t.payload.viewportWidth,viewportHeight:t.payload.viewportHeight}};case"SET_DATASOURCE_LOADING":return{...n,dataSource:{...n.dataSource,loading:t.payload}};case"SET_DATASOURCE_ERROR":return{...n,dataSource:{...n.dataSource,error:t.payload}};case"SET_ROW_COUNT":return{...n,pagination:{...n.pagination,rowCount:t.payload}};default:return n}}function fr(n){const{rows:t,columns:e,rowHeight:o=52,headerHeight:i=56,columnVisibilityModel:l,initialState:a}=n,[d]=s.useState(()=>cr(t,e,l)),[c,u]=s.useReducer(ur,{...d,sorting:a?.sorting||d.sorting,filter:a?.filter||d.filter,dataSource:a?.dataSource?{...d.dataSource,...a.dataSource}:d.dataSource,pagination:{...d.pagination,...a?.pagination||{},rowCount:n.rowCount??a?.pagination?.rowCount??d.pagination.rowCount},dimensions:{...d.dimensions,rowHeight:o,headerHeight:i}}),p=s.useRef(c);s.useLayoutEffect(()=>{p.current=c});const w=s.useRef(t);s.useEffect(()=>{t!==w.current&&(w.current=t,u({type:"SET_ROWS",payload:t}))},[t]);const x=s.useCallback((C,S)=>{u({type:"SET_ROWS",payload:C,preserveRowCount:S})},[]),g=s.useCallback(C=>{u({type:"SET_COLUMNS",payload:C})},[]),f=s.useCallback(C=>{u({type:"SET_SORT_MODEL",payload:C})},[]),h=s.useCallback(C=>{u({type:"SET_FILTER_MODEL",payload:C})},[]),v=s.useCallback(C=>{u({type:"SET_PAGINATION_MODEL",payload:C})},[]),E=s.useCallback(C=>{u({type:"SET_SELECTION",payload:C})},[]),m=s.useCallback((C,S)=>{u({type:"SET_DIMENSIONS",payload:{viewportWidth:C,viewportHeight:S}})},[]),y=s.useCallback(C=>{u({type:"SET_DATASOURCE_LOADING",payload:C})},[]),M=s.useCallback(C=>{u({type:"SET_DATASOURCE_ERROR",payload:C})},[]),N=s.useCallback(C=>{u({type:"SET_ROW_COUNT",payload:C})},[]),k=s.useRef({getRow:C=>p.current.rows.idRowsLookup.get(C)||null,getAllRows:()=>Array.from(p.current.rows.idRowsLookup.values()),getVisibleRows:()=>Array.from(p.current.rows.idRowsLookup.values()),getAllFilteredRows:()=>Array.from(p.current.rows.idRowsLookup.values()),getGroupedExportRows:()=>null,getAggregationResult:()=>null,getAggregationModel:()=>null,getColumn:C=>p.current.columns.lookup.get(C)||null,getAllColumns:()=>p.current.columns.all,getVisibleColumns:()=>p.current.columns.all,selectRow:(C,S=!0)=>{const j=new Set(p.current.selection.selectedRows);S?j.add(C):j.delete(C),E(j)},selectRows:(C,S=!0)=>{const j=new Set(p.current.selection.selectedRows);C.forEach(P=>{S?j.add(P):j.delete(P)}),E(j)},getSelectedRows:()=>Array.from(p.current.selection.selectedRows),sortColumn:(C,S)=>{if(S===null)f(p.current.sorting.sortModel.filter(j=>j.field!==C));else{const j=p.current.sorting.sortModel.findIndex(P=>P.field===C);if(j>=0){const P=[...p.current.sorting.sortModel];P[j]={field:C,sort:S},f(P)}else f([...p.current.sorting.sortModel,{field:C,sort:S}])}},getSortModel:()=>p.current.sorting.sortModel,setFilterModel:h,getFilterModel:()=>p.current.filter.filterModel,setPage:C=>{v({...p.current.pagination.paginationModel,page:C})},setPageSize:C=>{v({...p.current.pagination.paginationModel,pageSize:C,page:0})},scrollToIndexes:()=>{},copySelectedRows:()=>Promise.resolve()});return{state:c,dispatch:u,apiRef:k,setRows:x,setColumns:g,setSortModel:f,setFilterModel:h,setPaginationModel:v,setSelection:E,setDimensions:m,setDataSourceLoading:y,setDataSourceError:M,setRowCount:N}}function gr(n){const{onRowOrderChange:t,rows:e,getRowId:o,rowReordering:i=!1}=n,[l,a]=s.useState(null),[d,c]=s.useState(null),u=s.useCallback(f=>o?o(f):f.id,[o]),p=s.useCallback(f=>h=>{i&&(a(f),h.dataTransfer.effectAllowed="move")},[i]),w=s.useCallback(f=>h=>{!i||!l||(h.preventDefault(),h.dataTransfer.dropEffect="move",d!==f&&c(f))},[i,l,d]),x=s.useCallback(()=>{a(null),c(null)},[]),g=s.useCallback(f=>h=>{if(h.preventDefault(),!l||!t){x();return}const v=e.findIndex(m=>u(m)===l),E=e.findIndex(m=>u(m)===f);v!==-1&&E!==-1&&v!==E&&t({row:e[v],oldIndex:v,targetIndex:E}),x()},[l,t,e,u,x]);return{draggedRowId:l,dragOverRowId:d,onDragStart:i?p:void 0,onDragOver:i?w:void 0,onDragEnd:i?x:void 0,onDrop:i?g:void 0}}const On=new Map;function hr(n){const{rows:t,getRowId:e,getTreeDataPath:o,treeData:i=!1,defaultGroupingExpansionDepth:l=0,filterModel:a,sortModel:d,onRowExpansionChange:c}=n,{treeNodes:u,rootIds:p,groupingRows:w}=s.useMemo(()=>{if(!i||!o)return{treeNodes:new Map,rootIds:[],groupingRows:[]};const S=new Map,j=[],P=[],b=new Map,F=z=>z.join("/");return t.forEach(z=>{const K=e(z),W=o(z),$=F(W);b.set($,K),S.set(K,{id:K,parentId:null,depth:W.length-1,groupingKey:W[W.length-1],isExpanded:!1,children:[],serverChildrenCount:z.serverChildrenCount})}),t.forEach(z=>{const K=e(z),W=o(z);if(W.length===1){j.push(K);return}const $=L=>{if(L.length<=1)return;const B=L.slice(0,-1),D=F(B);let _=b.get(D);if(_===void 0&&(_=`auto-group-${D}`,!S.has(_))){const T=B[B.length-1];S.set(_,{id:_,parentId:null,depth:B.length-1,groupingKey:T,isExpanded:!1,children:[],label:T}),b.set(D,_);const I={id:_,name:T,_isGroupRow:!0};P.push(I),B.length===1&&j.push(_),$(B)}return _},H=$(W);if(H!==void 0){const L=S.get(H),B=S.get(K);L&&B&&(B.parentId=H,L.children=L.children||[],L.children.includes(K)||L.children.push(K))}}),P.forEach(z=>{const K=z.id,W=S.get(K);if(!W)return;const H=K.replace("auto-group-","").split("/");if(H.length>1){const L=H.slice(0,-1),B=F(L),D=b.get(B);if(D&&S.has(D)){W.parentId=D;const _=S.get(D);_&&(_.children=_.children||[],_.children.includes(K)||_.children.push(K))}}}),{treeNodes:S,rootIds:j,groupingRows:P}},[t,o,i,e]),x=`${i}|${l}`,[g,f]=s.useState(()=>({configKey:x,overrides:new Map})),h=g.configKey===x?g.overrides:On,v=s.useCallback(S=>!!(S?.children&&S.children.length>0)&&(l===-1||(S?.depth??0)<l),[l]),E=s.useMemo(()=>{const S=new Set;return i&&u.forEach((j,P)=>{(h.get(P)??v(j))&&S.add(P)}),S},[i,u,h,v]),m=s.useCallback(S=>{const j=!E.has(S);if(f(P=>{const b=P.configKey===x?P.overrides:On,F=new Map(b);return F.set(S,j),{configKey:x,overrides:F}}),j&&c){const P=u.get(S);P&&c(P)}},[E,x,u,c]),y=s.useCallback(()=>{if(!i)return null;const S=new Map;t.forEach($=>S.set(e($),$)),w.forEach($=>S.set($.id,$));const j=$=>a?nn($,a):!0,P=new Map,b=$=>{if(P.has($))return P.get($);const H=S.get($);if(!H)return!1;if(j(H))return P.set($,!0),!0;const B=u.get($);return B&&B.children&&B.children.some(_=>b(_))?(P.set($,!0),!0):(P.set($,!1),!1)},F=($,H)=>{if(!d||d.length===0)return 0;const L=S.get($),B=S.get(H);if(!L||!B)return 0;for(const D of d){const _=L[D.field],T=B[D.field],I=on(_,T,D.sort);if(I!==0)return I}return 0},z=[],K=new Set,W=$=>{const H=$.filter(L=>b(L));H.sort(F),H.forEach(L=>{if(K.has(L))return;const B=S.get(L),D=u.get(L);if(B&&D){K.add(L);const _={...B,_treeDepth:D.depth,_isExpanded:E.has(L),_hasChildren:!!(D.children&&D.children.length>0||D.serverChildrenCount&&D.serverChildrenCount>0),_descendantCount:D.children?D.children.length:0};z.push(_),E.has(L)&&D.children&&D.children.length>0&&W(D.children)}})};return W(p),z},[i,t,w,p,u,E,a,d,e]),M=s.useCallback(S=>E.has(S),[E]),N=s.useCallback(S=>u.get(S),[u]),k=s.useCallback(S=>{const j=[];let P=S;for(;P!==null;){const b=u.get(P);if(!b)break;j.unshift(b.groupingKey),P=b.parentId}return j},[u]),C=s.useMemo(()=>{const S=new Map,j=new Set(w.map(P=>P.id));return u.forEach((P,b)=>{S.set(b,{hasChildren:!!(P.children&&P.children.length>0||P.serverChildrenCount&&P.serverChildrenCount>0),treeDepth:P.depth,descendantCount:P.children?P.children.length:void 0,isGroupRow:j.has(b),isExpanded:E.has(b)})}),S},[u,w,E]);return s.useMemo(()=>({treeNodes:u,groupingRows:w,toggleExpansion:m,isGroupExpanded:M,getVisibleRows:y,getNode:N,getNodePath:k,rowMetaMap:C}),[u,w,m,M,y,N,k,C])}const pr=n=>n?.depth===-1?"footer":"inline",xr=[],mr={},Wn=new Map;function wr(n){const{rows:t,getRowId:e,columns:o,rowGroupingModel:i=xr,aggregationModel:l=mr,defaultGroupingExpansionDepth:a=0,filterModel:d,sortModel:c,getAggregationPosition:u=pr}=n,p=s.useMemo(()=>{const j=new Map;return(o??[]).forEach(P=>j.set(P.field,P)),j},[o]),w=`${i.join("")}|${a}`,[x,g]=s.useState(()=>({configKey:w,overrides:new Map})),f=x.configKey===w?x.overrides:Wn,{treeNodes:h,rootIds:v,groupingRows:E}=s.useMemo(()=>{const j=new Map,P=new Map,b=[];if(i.length===0)return{treeNodes:j,rootIds:b,groupingRows:P};const F=(W,$,H)=>`auto-group-${W}-${$}-${H||"root"}`,z=(W,$,H)=>{if($>=i.length)return W.map(T=>{const I=e(T);return j.set(I,{id:I,parentId:H,depth:$,groupingKey:"",isExpanded:!1}),I});const L=i[$],B=p.get(L);if(B&&B.groupable===!1)return z(W,$+1,H);const D=new Map;W.forEach(T=>{const I=T[L],O=String(I);D.has(O)||D.set(O,[]),D.get(O).push(T)});const _=[];return D.forEach((T,I)=>{const X=T[0][L],te=F(L,I,H);_.push(te);const Z=Rn(T,l,p,"useRowGrouping"),ce={[L]:X,...Z,id:te};P.set(te,ce);const le={id:te,parentId:H,depth:$,groupingKey:I,groupingField:L,groupingValue:X,aggregatedValues:Z,isExpanded:!1,children:[],label:B?.groupingValueFormatter?B.groupingValueFormatter({field:L,value:X}):`${L}: ${String(X)}`};le.aggregationPosition=u(le),j.set(te,le);const G=z(T,$+1,te);j.get(te).children=G;const R=T.length;j.get(te).descendantCount=R}),_},K=z(t,0,null);return b.push(...K),{treeNodes:j,rootIds:b,groupingRows:P}},[t,i,l,e,u,p]),m=s.useCallback(j=>!!(j?.children&&j.children.length>0)&&(a===-1||(j?.depth??0)<a),[a]),y=s.useMemo(()=>{const j=new Set;return h.forEach((P,b)=>{!P.children||P.children.length===0||(f.get(b)??m(P))&&j.add(b)}),j},[h,f,m]),M=s.useCallback(j=>{g(P=>{const b=P.configKey===w?P.overrides:Wn,F=b.get(j)??m(h.get(j)),z=new Map(b);return z.set(j,!F),{configKey:w,overrides:z}})},[w,h,m]),N=s.useCallback(j=>y.has(j),[y]),k=s.useCallback(()=>{if(i.length===0)return null;const j=[],P=new Set,b=new Map;t.forEach(K=>b.set(e(K),K));const F=K=>{const W=h.get(K);if(!W)return!1;if(!W.children||W.children.length===0){const $=b.get(K);return!(!$||d&&!nn($,d))}return W.children.some($=>F($))},z=K=>{const W=d?K.filter(F):[...K];c&&c.length>0&&W.sort(($,H)=>{const L=E.get($)||b.get($),B=E.get(H)||b.get(H);if(!L||!B)return 0;for(const D of c){const _=L[D.field],T=B[D.field],I=on(_,T,D.sort);if(I!==0)return I}return 0}),W.forEach($=>{if(P.has($))return;const H=h.get($),L=H?.children&&H.children.length>0,B=L?E.get($):b.get($);if(B&&H){P.add($);const D={...B,_treeDepth:H.depth,_isExpanded:y.has($),_hasChildren:L,_groupingField:H.groupingField,_groupingValue:H.groupingValue,_descendantCount:H.descendantCount};j.push(D),y.has($)&&L&&z(H.children)}})};return z(v),j},[t,e,h,v,E,d,c,y,i]),C=s.useCallback(j=>h.get(j),[h]),S=s.useMemo(()=>{const j=new Map;return h.forEach((P,b)=>{const F=!!(P.children&&P.children.length>0);j.set(b,{hasChildren:F,treeDepth:P.depth,groupingField:P.groupingField,groupingValue:P.groupingValue,groupLabel:P.label,descendantCount:P.descendantCount,isGroupRow:F,isExpanded:F?y.has(b):void 0})}),j},[h,y]);return s.useMemo(()=>({treeNodes:h,groupingRows:E,toggleExpansion:M,isGroupExpanded:N,getVisibleRows:k,getNode:C,rowMetaMap:S}),[h,E,M,N,k,C,S])}function br(n){const{rows:t,getRowId:e,processRowUpdate:o,onProcessRowUpdateError:i,onRowChange:l}=n,[a,d]=s.useState(null),c=s.useRef(null),u=s.useCallback(g=>{d(g),c.current=typeof g=="function"?g(c.current):g},[]),p=s.useCallback(g=>{u({id:g.id,field:g.field,value:g.value,originalValue:g.value})},[u]),w=s.useCallback(async g=>{const f=c.current;if(!f)return;if(g?.cancel){u(null);return}const{id:h,field:v,value:E,originalValue:m}=f;if(E===m){u(null);return}const y=t.find(N=>e(N)===h);if(!y){u(null);return}const M={...y,[v]:E};try{if(o){const N=await o(M,y);l?.(N)}else l?.(M);u(null)}catch(N){i?.(N)}},[u,t,e,o,l,i]),x=s.useCallback(g=>{a&&a.id===g.id&&a.field===g.field&&u(f=>f?{...f,value:g.value}:null)},[a,u]);return{editingCell:a,startCellEdit:p,stopCellEdit:w,setEditCellValue:x}}function vr(n,t,e){const[o,i]=s.useState(new Map),[l,a]=s.useState({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}}),d=s.useCallback(()=>{i(new Map)},[]),c=s.useCallback((h,v)=>o.get(h)?.[v],[o]),u=s.useCallback((h,v,E,m,y)=>{const M=new Map(o);for(let N=m;N<y;N++){const k=t[N];if(!k)continue;let C=1;if(k.colSpan)if(typeof k.colSpan=="function"){const j={row:v,value:v[k.field],field:k.field,colDef:k,rowIndex:E,colIndex:N};C=k.colSpan(j)}else C=k.colSpan;if(C<=1){et(M,h,k.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:e[k.field]||100}});continue}let S=e[k.field]||100;for(let j=1;j<C;j++)if(N+j<y){const P=t[N+j];P&&(S+=e[P.field]||100,et(M,h,P.field,{spannedByColSpan:!0,leftVisibleCellIndex:N,rightVisibleCellIndex:Math.min(N+C-1,t.length-1)}))}et(M,h,k.field,{spannedByColSpan:!1,cellProps:{colSpan:C,width:S}}),N+=C-1}i(M)},[o,t,e]),p=s.useCallback((h,v)=>{const E={},m={},y={};t.forEach((M,N)=>{if(M.rowSpan)for(let k=h;k<v;k++){const C=n[k];if(!C||m[C.id]?.[M.field])continue;const S=M.valueGetter?M.valueGetter({row:C,field:M.field,value:C[M.field]}):C[M.field];let j=1;if(typeof M.rowSpan=="function"){const P={row:C,value:S,field:M.field,colDef:M,rowIndex:k,colIndex:N};j=M.rowSpan(P)}else typeof M.rowSpan=="number"&&(j=M.rowSpan);if(j>1){E[C.id]||(E[C.id]={}),E[C.id][M.field]=j;for(let P=1;P<j;P++){const b=k+P;if(b<v&&n[b]){const F=n[b];m[F.id]||(m[F.id]={}),m[F.id][M.field]=!0,y[b]||(y[b]={}),y[b][M.field]=k}}}}}),a({caches:{spannedCells:E,hiddenCells:m,hiddenCellOriginMap:y},processedRange:{firstRowIndex:h,lastRowIndex:v}})},[n,t]),w=s.useCallback(()=>{a({caches:{spannedCells:{},hiddenCells:{},hiddenCellOriginMap:{}},processedRange:{firstRowIndex:0,lastRowIndex:0}})},[]);s.useEffect(()=>{const h=new Map;n.forEach((y,M)=>{for(let N=0;N<t.length;N++){const k=t[N];if(!k)continue;let C=1;if(k.colSpan)if(typeof k.colSpan=="function"){const j={row:y,value:y[k.field],field:k.field,colDef:k,rowIndex:M,colIndex:N};C=k.colSpan(j)}else C=k.colSpan;if(C<=1){const j=e[k.field]||(typeof k.width=="number"?k.width:100);et(h,y.id,k.field,{spannedByColSpan:!1,cellProps:{colSpan:1,width:j}});continue}let S=e[k.field]||(typeof k.width=="number"?k.width:100);for(let j=1;j<C;j++)if(N+j<t.length){const P=t[N+j];if(P){const b=e[P.field]||(typeof P.width=="number"?P.width:100);S+=b,et(h,y.id,P.field,{spannedByColSpan:!0,leftVisibleCellIndex:N,rightVisibleCellIndex:Math.min(N+C-1,t.length-1)})}}et(h,y.id,k.field,{spannedByColSpan:!1,cellProps:{colSpan:C,width:S}}),N+=C-1}}),i(h);const v={},E={},m={};t.forEach((y,M)=>{if(y.rowSpan)for(let N=0;N<n.length;N++){const k=n[N];if(!k||E[k.id]?.[y.field])continue;const C=y.valueGetter?y.valueGetter({row:k,field:y.field,value:k[y.field]}):k[y.field];let S=1;if(typeof y.rowSpan=="function"){const j={row:k,value:C,field:y.field,colDef:y,rowIndex:N,colIndex:M};S=y.rowSpan(j)}else typeof y.rowSpan=="number"&&(S=y.rowSpan);if(S>1){v[k.id]||(v[k.id]={}),v[k.id][y.field]=S;for(let j=1;j<S;j++){const P=N+j;if(P<n.length&&n[P]){const b=n[P];E[b.id]||(E[b.id]={}),E[b.id][y.field]=!0,m[P]||(m[P]={}),m[P][y.field]=N}}}}}),a({caches:{spannedCells:v,hiddenCells:E,hiddenCellOriginMap:m},processedRange:{firstRowIndex:0,lastRowIndex:n.length}})},[n,t,e]);const x=s.useCallback(()=>l.caches.spannedCells,[l]),g=s.useCallback(()=>l.caches.hiddenCells,[l]),f=s.useCallback(()=>l.caches.hiddenCellOriginMap,[l]);return{colspanMap:o,resetColSpan:d,getCellColSpanInfo:c,calculateColSpan:u,rowSpanningState:l,calculateRowSpan:p,resetRowSpan:w,getSpannedCells:x,getHiddenCells:g,getHiddenCellOriginMap:f}}function et(n,t,e,o){let i=n.get(t);i||(i={},n.set(t,i)),i[e]=o}function Cr(n){const{dataSource:t,sortModel:e,filterModel:o,paginationModel:i,paginationMode:l,sortingMode:a,filterMode:d,aggregationModel:c,setRows:u,setRowCount:p,setDataSourceLoading:w,setDataSourceError:x,onAggregationResults:g}=n,f=s.useRef(null),h=s.useRef(0),v=s.useCallback(async()=>{if(!t)return;const m=++h.current;w(!0),x(null);const y=i.page*i.pageSize,M=y+i.pageSize,N={startRow:y,endRow:M,sortModel:e,filterModel:o,groupKeys:[],aggregationModel:c};try{const k=await t.getRows(N);if(m!==h.current)return;let C=!1;if(l==="infinite"){const S=f.current;if(S){const j=JSON.stringify(S.sortModel)!==JSON.stringify(e),P=JSON.stringify(S.filterModel)!==JSON.stringify(o),b=S.pageSize!==i.pageSize;!j&&!P&&!b&&i.page>S.page&&(C=!0)}}u(C?S=>[...S,...k.rows]:k.rows,!0),k.aggregationResults&&g&&g(k.aggregationResults),k.rowCount!==void 0&&p(k.rowCount),f.current={sortModel:e,filterModel:o,page:i.page,pageSize:i.pageSize}}catch(k){m===h.current&&(x(k),console.error("Data Source Error:",k))}finally{m===h.current&&w(!1)}},[t,i.page,i.pageSize,e,o,l,c,g,u,p,w,x]);s.useEffect(()=>{if(t&&(l==="server"||l==="infinite"||a==="server"||d==="server")){const y=setTimeout(()=>{v()},300);return()=>clearTimeout(y)}},[v,t,l,a,d]);const E=s.useCallback(async(m,y)=>{if(t){w(!0);try{const M=await t.getRows({startRow:0,endRow:-1,sortModel:e,filterModel:o,groupKeys:y});M.rows.length>0&&u(N=>{const k=new Set(N.map(S=>S.id)),C=M.rows.filter(S=>!k.has(S.id));return[...N,...C]})}catch(M){x(M),console.error("Failed to fetch children:",M)}finally{w(!1)}}},[t,e,o,u,w,x]);return{fetchRows:v,fetchChildren:E}}const An="\0",Ct="";function _r(n,t){const e=n.filter(o=>o!=null&&!isNaN(o));if(e.length===0)return null;switch(t){case"sum":return e.reduce((o,i)=>o+i,0);case"avg":return e.reduce((o,i)=>o+i,0)/e.length;case"count":return e.length;case"min":return Math.min(...e);case"max":return Math.max(...e)}}function Wt(n,t){return t.map(e=>String(n[e]??"")).join(An)}function ln(n,t,e,o){return o?`${n}${Ct}${t}${Ct}${e}`:`${t}${Ct}${e}`}function $n(n,t,e,o){return s.useMemo(()=>{const i={pivotRows:[],pivotColumns:[],colKeys:[],isValid:!1};if(!o)return i;const{rowFields:l,columnFields:a,valueFields:d}=e;if(l.length===0||d.length===0)return i;const c=a.length>0,u=new Map(t.map(m=>[m.field,m])),p=new Set;for(const m of n)p.add(Wt(m,a));const w=Array.from(p).sort(),x=new Map;for(const m of n){const y=Wt(m,l);if(!x.has(y)){const C={};for(const S of l)C[S]=m[S];x.set(y,{labelValues:C,bucket:new Map})}const M=x.get(y),N=Wt(m,a);M.bucket.has(N)||M.bucket.set(N,new Map);const k=M.bucket.get(N);for(const C of d){const S=m[C.field];k.has(C.field)||k.set(C.field,[]),S!=null&&!isNaN(Number(S))&&k.get(C.field).push(Number(S))}}let g=0;const f=[];for(const[,m]of x){const y={id:g++,...m.labelValues};for(const M of w){const N=m.bucket.get(M);for(const k of d){const C=ln(M,k.field,k.aggFn,c),S=N?.get(k.field)??[];y[C]=S.length>0?_r(S,k.aggFn):null}}f.push(y)}const h=new Map;for(const m of n){const y=Wt(m,a);for(const M of d){if(M.aggFn!=="avg"&&M.aggFn!=="min"&&M.aggFn!=="max")continue;const N=`${y}${Ct}${M.field}`;h.has(N)||h.set(N,[]);const k=m[M.field];k!=null&&!isNaN(Number(k))&&h.get(N).push(Number(k))}}const v={id:"__pivot_grand_total__"};for(let m=0;m<l.length;m++)v[l[m]]=m===0?"Grand Total":"";for(const m of w)for(const y of d){const M=ln(m,y.field,y.aggFn,c),N=f.map(C=>C[M]).filter(C=>C!=null&&!isNaN(Number(C))).map(Number);if(N.length===0){v[M]=null;continue}const k=`${m}${Ct}${y.field}`;switch(y.aggFn){case"sum":case"count":v[M]=N.reduce((C,S)=>C+S,0);break;case"avg":{const C=h.get(k)??[];v[M]=C.length>0?C.reduce((S,j)=>S+j,0)/C.length:null;break}case"min":v[M]=Math.min(...h.get(k)??N);break;case"max":v[M]=Math.max(...h.get(k)??N);break}}f.push(v);const E=[];for(const m of l){const y=u.get(m);E.push({field:m,headerName:y?.headerName??m,width:y?.width??140,sortable:!0})}for(const m of w){const y=c?m.split(An).map((M,N)=>{const k=u.get(a[N]);return k?.headerName?`${k.headerName}: ${M}`:M}).join(" / "):"";for(const M of d){const N=u.get(M.field),k=ln(m,M.field,M.aggFn,c),C=M.headerName??N?.headerName??M.field,S=y?`${y} — ${C} (${M.aggFn})`:`${C} (${M.aggFn})`;E.push({field:k,headerName:S,width:140,type:"number",align:"right",headerAlign:"right",sortable:!0,valueFormatter:({value:j})=>{if(j==null)return"—";const P=Number(j);return M.aggFn==="avg"?P.toFixed(2):M.aggFn==="count"?P.toLocaleString():N?.valueFormatter?N.valueFormatter({value:j,row:{},field:M.field}):P.toLocaleString()}})}}return{pivotRows:f,pivotColumns:E,colKeys:w,isValid:!0}},[n,t,e,o])}function yr(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 kr(n){let t=!1;try{t=yr(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 Sr(n){const{selectedRowIds:t,columns:e,getVisibleRows:o,getRowId:i}=n,l=s.useCallback(async()=>{if(t.size===0)return;const d=o().filter(x=>t.has(i(x)));if(d.length===0)return;const c=e.filter(x=>!x.field.startsWith("__")),u=c.map(x=>x.headerName||x.field).join(" "),p=d.map(x=>c.map(g=>{const f=x[g.field];return g.valueFormatter?g.valueFormatter({value:f,row:x,field:g.field}):f??""}).join(" ")).join(`
7
- `),w=`${u}
8
- ${p}`;try{await kr(w)}catch(x){console.error("[OpenGridX] Failed to copy to clipboard:",x)}},[t,e,o,i]);return s.useEffect(()=>{const a=d=>{if(!(d.ctrlKey||d.metaKey)||d.key!=="c")return;const c=document.activeElement,u=c?.tagName.toLowerCase(),p=c?.type;u==="input"&&p!=="checkbox"&&p!=="radio"||u==="textarea"||u==="select"||c?.isContentEditable||l()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[l]),{copySelectedRows:l}}function jr({row:n,rowIndex:t,listViewColumn:e,isSelected:o=!1,checkboxSelection:i=!1,rowHeight:l,onRowClick:a,onRowDoubleClick:d,onSelectionChange:c}){const u={row:n,value:void 0,field:e.field,colDef:{field:e.field},rowIndex:t,colIndex:0},p=w=>{w.stopPropagation(),c?.(n.id,w.target.checked)};return r.jsxs("div",{className:`ogx-list-view__row${o?" ogx-list-view__row--selected":""}`,style:l?{minHeight:l}:void 0,onClick:()=>a?.(n),onDoubleClick:d?()=>d(n):void 0,role:"row","aria-rowindex":t+2,"aria-selected":o,children:[i&&r.jsx("div",{className:"ogx-list-view__checkbox",onClick:w=>w.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(u)})]})}function Er({ariaLabel:n,allRenderableRows:t,filteredRows:e,pagination:o,effectivePaginationModel:i,pageSizeOptions:l,selectedRowIds:a,listViewColumn:d,noRowsLabel:c,rowHeight:u,checkboxSelection:p,paginationMode:w,dataSource:x,serverRowCount:g,paginationSlot:f,paginationSlotProps:h,localeText:v,onRowClick:E,onRowDoubleClick:m,onSelectionChange:y,onPaginationModelChange:M}){const N=f||Fn,k=w==="server"&&x?g||0:e.length;return r.jsxs("div",{className:"ogx-list-view",role:"grid","aria-label":n||"Data grid list view","aria-rowcount":t.length+1,children:[r.jsx("div",{className:"ogx-list-view__toolbar",children:r.jsxs("span",{children:[e.length," ",e.length===1?"item":"items",o?` · page ${i.page+1} of ${Math.ceil(e.length/i.pageSize)||1}`:"",a.size>0?` · ${a.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"})]}),c]}):t.map((C,S)=>r.jsx(jr,{row:C,rowIndex:S,listViewColumn:d,isSelected:a.has(C.id),checkboxSelection:p,rowHeight:u,onRowClick:j=>E({row:j,id:j.id,rowIndex:S}),onRowDoubleClick:m?j=>m({row:j,id:j.id,rowIndex:S}):void 0,onSelectionChange:y},C.id))}),o&&r.jsx(N,{page:i.page,pageSize:i.pageSize,rowCount:k,pageSizeOptions:l,onPageChange:C=>M({...i,page:C}),onPageSizeChange:C=>M({...i,pageSize:C,page:0}),localeText:v,...h})]})}function Nr({value:n,onValueChange:t,onCommit:e,onCancel:o}){const[i,l]=s.useState(String(n??"")),a=s.useRef(null);return s.useEffect(()=>{a.current?.focus(),a.current?.select()},[]),r.jsx("input",{ref:a,type:"text",className:"ogx__edit-input",value:i,onChange:d=>{l(d.target.value),t(d.target.value)},onBlur:e,onKeyDown:d=>{d.key==="Enter"&&(d.stopPropagation(),e()),d.key==="Escape"&&(d.stopPropagation(),o())}})}function Mr({value:n,onValueChange:t,onCommit:e,onCancel:o}){const[i,l]=s.useState(typeof n=="number"?n:""),a=s.useRef(null);return s.useEffect(()=>{a.current?.focus(),a.current?.select()},[]),r.jsx("input",{ref:a,type:"number",className:"ogx__edit-input ogx__edit-input--number",value:i,onChange:d=>{const c=d.target.value===""?"":Number(d.target.value);l(c),t(c===""?null:c)},onBlur:e,onKeyDown:d=>{d.key==="Enter"&&(d.stopPropagation(),e()),d.key==="Escape"&&(d.stopPropagation(),o())}})}function Pr({value:n,onValueChange:t,onCommit:e,onCancel:o}){const i=s.useRef(null);s.useEffect(()=>{i.current?.focus()},[]);const l=()=>{t(!n),setTimeout(e,0)};return r.jsx("div",{className:"ogx__edit-boolean",children:r.jsx("input",{ref:i,type:"checkbox",className:"ogx__edit-checkbox",checked:!!n,onChange:l,onKeyDown:a=>{a.key==="Escape"&&(a.stopPropagation(),o())}})})}function Rr({value:n,colDef:t,onValueChange:e,onCommit:o,onCancel:i}){const l=s.useRef(null);s.useEffect(()=>{l.current?.focus()},[]);const a=t.valueOptions??[];return r.jsx("select",{ref:l,className:"ogx__edit-select",value:String(n??""),onChange:d=>{e(d.target.value)},onBlur:o,onKeyDown:d=>{d.key==="Enter"&&(d.stopPropagation(),o()),d.key==="Escape"&&(d.stopPropagation(),i())},children:a.map(d=>{const c=typeof d=="object"?d.value:d,u=typeof d=="object"?d.label:String(d);return r.jsx("option",{value:String(c),children:u},String(c))})})}function Tr({value:n,onValueChange:t,onCommit:e,onCancel:o}){const[i,l]=s.useState(typeof n=="string"?n:String(n??"")),a=s.useRef(null);return s.useEffect(()=>{a.current?.focus()},[]),r.jsx("input",{ref:a,type:"date",className:"ogx__edit-input",value:i,onChange:d=>{l(d.target.value),t(d.target.value)},onBlur:e,onKeyDown:d=>{d.key==="Enter"&&(d.stopPropagation(),e()),d.key==="Escape"&&(d.stopPropagation(),o())}})}function Ir(n){const{colDef:t}=n;switch(t.type){case"number":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(Mr,{...n})});case"boolean":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(Pr,{...n})});case"singleSelect":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(Rr,{...n})});case"date":return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(Tr,{...n})});default:return r.jsx("div",{className:"ogx__edit-cell",children:r.jsx(Nr,{...n})})}}function Lr({renderFn:n}){return r.jsx(r.Fragment,{children:n()})}class Fr extends s.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(Lr,{renderFn:this.props.renderFn})}}function Or(n){const{onCellClick:t,onCellEditStart:e,onCellValueChange:o,value:i,row:l,colDef:a,rowIndex:d,colIndex:c,isSelected:u,onClick:p,width:w,pinnedPosition:x,pinnedOffset:g,isFocused:f,isFocusVisible:h,isEditable:v,isEditing:E,onEditStart:m,onEditStop:y,onValueChange:M,colSpanInfo:N,rowSpan:k,isHiddenByRowSpan:C,rowMeta:S}=n,j=s.useCallback(_=>{o?o(a.field,_):M?.(_)},[o,M,a.field]),P=s.useMemo(()=>a.valueFormatter?a.valueFormatter({value:i,row:l,field:a.field}):i==null?"":String(i),[i,l,a]),b=s.useMemo(()=>a.cellClassName?typeof a.cellClassName=="function"?a.cellClassName({value:i,row:l,field:a.field,colDef:a,rowIndex:d,colIndex:c})||"":a.cellClassName:"",[a,i,l,d,c]),F=s.useRef(null);if(s.useLayoutEffect(()=>{f&&F.current&&F.current.focus({preventScroll:!0})},[f]),N?.spannedByColSpan)return null;if(C)return r.jsx("div",{className:"ogx__cell ogx__cell--hidden",style:{width:w??a.width??100},role:"presentation","data-field":a.field,"data-colindex":c});const z=_=>{t&&t({row:l,field:a.field,value:i,colDef:a,rowIndex:d,colIndex:c}),p?.(_)},K=_=>{v&&(m||e)&&(_.stopPropagation(),e?e(a.field,i):m?.())},W=x!=null,$=["ogx__cell",`ogx__cell--align-${a.align||"left"}`,u&&"ogx__cell--selected",f&&"ogx__cell--focused",f&&h&&"ogx__cell--focus-visible",a.type&&`ogx__cell--type-${a.type}`,W&&"ogx__cell--pinned",W&&`ogx__cell--pinned-${x}`,E&&"ogx__cell--editing",k&&k>1&&"ogx__cell--spanned",b].filter(Boolean).join(" "),H=N?.cellProps?.colSpan||1,L=k||1,B=N?.cellProps?.width??w??a.width??100,D={width:"var(--width)","--width":typeof B=="number"?`${B}px`:B,flexGrow:a.flex??0,flexShrink:0,flexBasis:(a.flex,"auto"),boxSizing:"border-box",minWidth:a.minWidth,maxWidth:a.maxWidth,position:W?"sticky":void 0,zIndex:a.zIndex??(W?3:void 0),padding:E?0:void 0};return L>1&&(D.height=`calc(var(--height) * ${L} - var(--border-width, 1px))`,D.zIndex=10,W&&(D.zIndex=40)),W&&g!==void 0&&(x==="left"?D.left=g:D.right=g),r.jsx("div",{ref:F,className:$,style:D,onClick:z,onDoubleClick:K,role:"gridcell","aria-colindex":c+1,"aria-readonly":!v||void 0,tabIndex:-1,"data-field":a.field,"data-colindex":c,...H>1?{"aria-colspan":H}:{},...L>1?{"aria-rowspan":L}:{},children:r.jsx("div",{className:"ogx__cell-content",children:E&&(o||M)&&y?a.renderEditCell?a.renderEditCell({value:i,row:l,field:a.field,colDef:a,rowIndex:d,colIndex:c,rowMeta:S}):r.jsx(Ir,{value:i,row:l,field:a.field,colDef:a,rowIndex:d,colIndex:c,onValueChange:j,onCommit:()=>y(),onCancel:()=>y(!0)}):a.renderCell?r.jsx(Fr,{field:a.field,resetKey:l,renderFn:()=>a.renderCell({value:i,formattedValue:P,row:l,field:a.field,colDef:a,rowIndex:d,colIndex:c,rowMeta:S})}):P})})}const zn=s.memo(Or),Wr=({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 Ar(n){const{content:t,height:e,isExpanded:o}=n;if(!o)return null;const i={height:e==="auto"?"auto":`${e}px`,overflow:e==="auto"?"visible":"auto"};return r.jsx("div",{className:"ogx__detail-panel",style:i,children:r.jsx("div",{className:"ogx__detail-panel-content",children:t})})}function At(n){const{row:t,columns:e,rowIndex:o,isSelected:i=!1,checkboxSelection:l=!1,onRowClick:a,onRowDoubleClick:d,onCellClick:c,onSelectionChange:u,columnWidths:p={},pinnedColumns:w,pinnedRows:x,hasDetailPanel:g=!1,isDetailPanelExpanded:f=!1,onDetailPanelToggle:h,detailPanelContent:v,detailPanelHeight:E=200,pinCheckboxColumn:m=!0,pinExpandColumn:y=!0,rowReordering:M=!1,onDragStart:N,onDragOver:k,onDragEnd:C,onDrop:S,isDragging:j,isDragOver:P,editingCell:b,onEditStart:F,onEditStop:z,onEditCellValueChange:K,focusedCellField:W,isFocusVisible:$,colspanMap:H,rowSpanningCaches:L,rowHeight:B=52,rowMeta:D}=n,_=s.useId(),T=s.useRef(null),I=s.useRef(null);s.useLayoutEffect(()=>{W==="__expand_col__"&&T.current&&T.current.focus({preventScroll:!0}),W==="__checkbox_col__"&&I.current&&I.current.focus({preventScroll:!0})},[W]);const O=s.useMemo(()=>en(e,p,w,l,m,g,y,M),[e,p,w,l,m,g,y,M]),X=D?.hasChildren===!0,te=s.useCallback((V,A)=>{X||F?.({id:t.id,field:V,value:A})},[X,t.id,F]),Z=s.useCallback((V,A)=>{K?.({id:t.id,field:V,value:A})},[K,t.id]),ce=s.useCallback(V=>{z?.({cancel:V})},[z]);if(t._isSkeleton){const V=Math.max(e.length,5);return r.jsx("div",{className:"ogx__row ogx__row--skeleton",role:"row","aria-hidden":"true",style:{height:B,minHeight:B},children:Array.from({length:V}).map((A,ee)=>r.jsx("div",{className:"ogx__skeleton-cell",children:r.jsx("div",{className:"ogx__skeleton-bar"})},ee))})}const le=V=>{V.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell")||a?.({row:t,id:t.id,rowIndex:o})},G=V=>{V.target.closest(".ogx-checkbox-wrapper, .ogx-expand-icon, .ogx-drag-handle, .ogx__edit-cell")||d?.({row:t,id:t.id,rowIndex:o})},R=V=>{V.stopPropagation(),u?.(t.id,V.target.checked)},Y=V=>{V.stopPropagation(),h?.(t.id)},Q=tn(t.id,x),J=Q==="top",re=Q==="bottom",q=["ogx__row",i&&"ogx__row--selected",o%2===0&&"ogx__row--even",o%2===1&&"ogx__row--odd",J&&"ogx__row--pinned-top",re&&"ogx__row--pinned-bottom",j&&"ogx__row--dragging",P&&"ogx__row--drag-over",X&&"ogx__row--group"].filter(Boolean).join(" ");return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:q,onClick:le,onDoubleClick:d?G:void 0,role:"row","aria-rowindex":o+1,"aria-selected":i,"data-rowindex":o,onDragOver:k?k(t.id):void 0,onDrop:S?S(t.id):void 0,style:{maxHeight:`${B}px`,minHeight:`${B}px`,"--height":`${B}px`,"--border-width":"1px"},children:[M&&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:C,onClick:V=>V.stopPropagation(),children:r.jsx(Wr,{})}),g&&r.jsx("div",{className:`ogx__cell ogx__cell--expand ${y?"ogx__cell--pinned-left":""} ${W==="__expand_col__"?"ogx__cell--focused":""} ${W==="__expand_col__"&&$?"ogx__cell--focus-visible":""}`,role:"gridcell","aria-label":f?"Collapse row details":"Expand row details","aria-expanded":f,style:{position:y?"sticky":void 0,left:y?M?48:0:void 0,zIndex:y?5:void 0},ref:T,tabIndex:-1,onClick:V=>{V.stopPropagation(),c?.({row:t,field:"__expand_col__",value:f,colDef:{field:"__expand_col__",width:48},rowIndex:o,colIndex:-1})},children:r.jsx(Pn,{isExpanded:f,onClick:Y,variant:"plus-minus"})}),l&&r.jsx("div",{className:`ogx__cell ogx__cell--checkbox ${m?"ogx__cell--pinned-left":""} ${W==="__checkbox_col__"?"ogx__cell--focused":""} ${W==="__checkbox_col__"&&$?"ogx__cell--focus-visible":""}`,role:"gridcell",style:{position:m?"sticky":void 0,left:m?(M?48:0)+(g&&y?48:0):void 0,zIndex:m?11:void 0},ref:I,tabIndex:-1,onClick:V=>{V.stopPropagation(),c?.({row:t,field:"__checkbox_col__",value:i,colDef:{field:"__checkbox_col__",width:48},rowIndex:o,colIndex:-1})},children:r.jsx(bt,{id:_,name:`ogx-select-row-${t.id}`,checked:i,onChange:R,onClick:V=>V.stopPropagation(),"aria-label":i?`Deselect row ${t.id}`:`Select row ${t.id}`,tabIndex:-1,onMouseDown:V=>V.preventDefault()})}),e.map((V,A)=>{if(V.isSpacer)return r.jsx("div",{style:{width:V.width,minWidth:V.width,flexShrink:0},"aria-hidden":"true"},V.field);const ee=V.valueGetter?V.valueGetter({row:t,field:V.field,value:t[V.field]}):t[V.field],ie=p[V.field]??V.width,ae=wt(V.field,w),fe=ae?O[V.field]:void 0,he=b?.id===t.id&&b?.field===V.field,Me=he?b?.value:ee,ke=H?.get(t.id)?.[V.field],Pe=L?.spannedCells[t.id]?.[V.field],Se=L?.hiddenCells[t.id]?.[V.field]||!1;return r.jsx(zn,{value:Me,row:t,colDef:V,rowIndex:o,colIndex:A,isSelected:i,onCellClick:c,width:ie,pinnedPosition:ae,pinnedOffset:fe,isFocused:W===V.field,isFocusVisible:$,isEditable:V.editable,isEditing:he,onCellEditStart:te,onEditStop:ce,onCellValueChange:Z,colSpanInfo:ke,rowSpan:Pe,isHiddenByRowSpan:Se,rowMeta:D},V.field)})]}),g&&r.jsx(Ar,{row:t,rowId:t.id,rowIndex:o,content:v,height:E,isExpanded:f})]})}function Bn({rows:n,position:t,columns:e,selectedRowIds:o,checkboxSelection:i,onRowClick:l,onRowDoubleClick:a,onCellClick:d,onSelectionChange:c,columnWidths:u,pinnedColumns:p,pinnedRows:w,hasDetailPanel:x,expandedRowIds:g,getDetailPanelContent:f,getDetailPanelHeight:h,onDetailPanelToggle:v,pinCheckboxColumn:E,pinExpandColumn:m,focusedCell:y,colspanMap:M,rowSpanningCaches:N,rowHeight:k,rowMetaMap:C}){return n.length===0?null:r.jsx("div",{className:`ogx__pinned-rows ogx__pinned-rows--${t}`,role:"rowgroup",children:n.map((S,j)=>r.jsx(At,{row:S,columns:e,rowIndex:j,isSelected:o.has(S.id),checkboxSelection:i,onRowClick:l,onRowDoubleClick:a,onCellClick:d,onSelectionChange:c,columnWidths:u,pinnedColumns:p,pinnedRows:w,hasDetailPanel:x,isDetailPanelExpanded:g.has(S.id),detailPanelContent:f?f({row:S,id:S.id,rowIndex:j}):null,detailPanelHeight:h?.({row:S,id:S.id,rowIndex:j})||200,onDetailPanelToggle:v,pinCheckboxColumn:E,pinExpandColumn:m,focusedCellField:y?.id===S.id?y.field:null,colspanMap:M,rowSpanningCaches:N,rowHeight:k,rowMeta:C.get(S.id)},S.id))})}const $r=({columns:n,rowHeight:t,checkboxSelection:e=!1,hasDetailPanel:o=!1,rowReordering:i=!1})=>r.jsxs("div",{className:"ogx__row ogx__skeleton-row",style:{height:t},role:"row",children:[e&&r.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:r.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),o&&r.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:r.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),i&&r.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:48,minWidth:48},children:r.jsx("div",{className:"ogx-skeleton-box",style:{width:18,height:18,borderRadius:2}})}),n.map((l,a)=>{const d=typeof l.width=="number"?l.width:150,c=Math.min(d*.7,d-20);return r.jsx("div",{className:"ogx__cell ogx__skeleton-cell",style:{width:d,minWidth:l.minWidth,maxWidth:l.maxWidth,left:l.left,right:l.right,position:l.isSpacer?"relative":l.pinned?"sticky":"relative",zIndex:l.zIndex},children:!l.isSpacer&&r.jsx("div",{className:"ogx-skeleton-box",style:{width:c,height:16,borderRadius:4}})},l.field||a)})]});function zr({virtualContainerHeight:n,offsetTop:t,effectiveLoading:e,visibleRows:o,baseColumns:i,virtualColumns:l,viewportWidth:a,checkboxSelection:d,hasDetailPanel:c,rowReordering:u,rowHeight:p,pinnedRows:w,selectedRowIds:x,onRowClick:g,onRowDoubleClick:f,onCellClick:h,onSelectionChange:v,columnWidths:E,pinnedColumns:m,expandedRowIds:y,getDetailPanelContent:M,getDetailPanelHeight:N,onDetailPanelToggle:k,pinCheckboxColumn:C,pinExpandColumn:S,rowReorderHandlers:j,editingHandlers:P,focusedCell:b,colspanMap:F,rowSpanningCaches:z,paginationMode:K,dataSourceLoading:W,sortedUnpinnedRowCount:$,infiniteScrollSkeletonCount:H,unpinnedRowsLength:L,rowMetaMap:B,loadingOverlay:D}){const _=i.length>0?i:(()=>{const I=(a||1e3)-(d?48:0)-(c?48:0)-(u?48:0),O=150,X=Math.max(1,Math.ceil(I/O));return Array.from({length:X},(te,Z)=>({field:`placeholder_${Z}`,headerName:"",width:O}))})(),T=o.filter(({row:I})=>!tn(I.id,w)).filter((I,O,X)=>O===X.findIndex(te=>te.row.id===I.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&&D?r.jsx("div",{className:"ogx__loading-overlay",style:{width:a||void 0},children:D}):e&&o.length===0?Array.from({length:10}).map((I,O)=>r.jsx($r,{columns:_,rowHeight:p,checkboxSelection:d,hasDetailPanel:c,rowReordering:u},`skeleton-${O}`)):T.map(({row:I,rowIndex:O})=>r.jsx(At,{row:I,columns:l,rowIndex:O,isSelected:x.has(I.id),checkboxSelection:d,onRowClick:g,onRowDoubleClick:f,onCellClick:h,onSelectionChange:v,columnWidths:E,pinnedColumns:m,pinnedRows:w,hasDetailPanel:c,isDetailPanelExpanded:y.has(I.id),detailPanelContent:M?M({row:I,id:I.id,rowIndex:O}):null,detailPanelHeight:N?.({row:I,id:I.id,rowIndex:O})||200,onDetailPanelToggle:k,pinCheckboxColumn:C,pinExpandColumn:S,rowReordering:u,onDragStart:j.onDragStart,onDragOver:j.onDragOver,onDragEnd:j.onDragEnd,onDrop:j.onDrop,isDragging:j.draggedRowId===I.id,isDragOver:j.dragOverRowId===I.id,editingCell:P.editingCell,onEditStart:P.startCellEdit,onEditStop:P.stopCellEdit,onEditCellValueChange:P.setEditCellValue,focusedCellField:b!=null&&b.id===I.id?b.field:null,colspanMap:F,rowSpanningCaches:z,rowHeight:p,rowMeta:B.get(I.id)},I.id)),K==="infinite"&&W&&$>0&&r.jsx("div",{className:"ogx__skeleton-group",children:Array.from({length:H}).map((I,O)=>r.jsx(At,{row:{id:`__skeleton_${O}__`,_isSkeleton:!0},columns:l,rowIndex:L+O,rowHeight:p},`__skeleton_${O}__`))})]})})}function Br(){return r.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function Dr(){return r.jsxs("svg",{className:"ogx-column-visibility-panel__drag-handle",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[r.jsx("circle",{cx:"9",cy:"5",r:"1.5"}),r.jsx("circle",{cx:"15",cy:"5",r:"1.5"}),r.jsx("circle",{cx:"9",cy:"12",r:"1.5"}),r.jsx("circle",{cx:"15",cy:"12",r:"1.5"}),r.jsx("circle",{cx:"9",cy:"19",r:"1.5"}),r.jsx("circle",{cx:"15",cy:"19",r:"1.5"})]})}function sn(n){const{columns:t,visibleColumns:e,onVisibilityChange:o,onShowAll:i,onHideAll:l,onColumnReorder:a,onColumnOrderReset:d,showNonHideableColumns:c}=n,[u,p]=s.useState(""),[w,x]=s.useState(null),g=s.useRef(null),f=s.useMemo(()=>t.filter(C=>C.hideable!==!1),[t]),h=f.every(C=>e.has(C.field)),v=s.useMemo(()=>{const C=c?t:f;if(!u)return C;const S=u.toLowerCase();return C.filter(j=>(j.headerName||j.field).toLowerCase().includes(S))},[t,f,u,c]),E=C=>{C.target.checked?i():l()},m=C=>S=>{g.current=C,S.dataTransfer.effectAllowed="move",S.dataTransfer.setDragImage(S.currentTarget.closest(".ogx-column-visibility-panel__item"),20,20)},y=C=>S=>{S.preventDefault(),S.dataTransfer.dropEffect="move",C!==g.current&&x(C)},M=()=>{x(null)},N=C=>S=>{S.preventDefault();const j=g.current;x(null),g.current=null,j&&j!==C&&a&&a(j,C)},k=()=>{x(null),g.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(Br,{}),r.jsx("input",{autoComplete:"off",className:"ogx-column-visibility-panel__search-input",placeholder:"Search",value:u,onChange:C=>p(C.target.value)})]})}),r.jsx("div",{className:"ogx-column-visibility-panel__list",children:v.map(C=>{const S=e.has(C.field),j=C.hideable!==!1,P=w===C.field,b=!!a&&!u;return r.jsxs("div",{className:["ogx-column-visibility-panel__item",!j&&"ogx-column-visibility-panel__item--disabled",P&&"ogx-column-visibility-panel__item--drag-over"].filter(Boolean).join(" "),draggable:b,onDragOver:b?y(C.field):void 0,onDragLeave:b?M:void 0,onDrop:b?N(C.field):void 0,onDragEnd:b?k:void 0,children:[b&&r.jsx("span",{className:"ogx-column-visibility-panel__drag-handle-wrapper",draggable:!0,onDragStart:m(C.field),title:"Drag to reorder",children:r.jsx(Dr,{})}),r.jsxs("label",{className:"ogx-column-visibility-panel__item-label",style:{display:"flex",alignItems:"center",gap:"var(--ogx-spacing-md)",flex:1,cursor:j?"pointer":"not-allowed"},children:[r.jsx(bt,{checked:S,onChange:F=>o(C.field,F.target.checked),disabled:!j}),r.jsx("span",{className:"ogx-column-visibility-panel__label",children:C.headerName||C.field})]})]},C.field)})}),r.jsxs("div",{className:"ogx-column-visibility-panel__footer",children:[r.jsxs("label",{className:"ogx-column-visibility-panel__item",children:[r.jsx(bt,{checked:h,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:()=>{i(),d?.()},children:"Reset"})]})]})}function Hr({isOpen:n,containerRef:t,panelRef:e,effectiveColumns:o,columnVisibilityModel:i,effectiveColumnOrder:l,columnOrder:a,disableColumnReorder:d,onClose:c,onColumnVisibilityChange:u,onColumnOrderChange:p,setInternalColumnOrder:w}){const[x,g]=s.useState(16),[f,h]=s.useState(16),[v,E]=s.useState(()=>document.body);if(s.useLayoutEffect(()=>{if(!n||!t.current)return;const y=t.current.getBoundingClientRect();g(y.top+8),h(window.innerWidth-y.right+8),E(t.current.closest(".ogx-theme-provider")||document.body)},[n,t]),!n)return null;const m=d?void 0:(y,M)=>{const N=[...l],k=N.indexOf(y),C=N.indexOf(M);if(k===-1||C===-1)return;const S=[...N];S.splice(k,1),S.splice(C,0,y),a||w(S),p?.({oldIndex:k,targetIndex:C,column:o.find(j=>j.field===y)})};return Ve.createPortal(r.jsxs("div",{ref:e,style:{position:"fixed",top:x,right:f,zIndex:9999,display:"inline-block"},children:[r.jsx("button",{onClick:c,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(sn,{columns:o,visibleColumns:new Set(o.filter(y=>i[y.field]!==!1).map(y=>y.field)),onVisibilityChange:(y,M)=>{u({...i,[y]:M})},onShowAll:()=>{const y={...i};o.forEach(M=>{M.hideable!==!1&&(y[M.field]=!0)}),u(y)},onHideAll:()=>{const y={...i};o.forEach(M=>{M.hideable!==!1&&(y[M.field]=!1)}),u(y)},onColumnReorder:m})]}),v)}const Vr=new Map;function Gr(n){const{rows:t,columns:e,getRowId:o,rowHeight:i=52,headerHeight:l=56,autoHeight:a=!1,density:d,checkboxSelection:c=!1,disableRowSelectionOnClick:u=!1,disableMultipleRowSelection:p=!1,rowSelectionModel:w,onRowSelectionModelChange:x,onRowClick:g,onRowDoubleClick:f,onCellClick:h,filterModel:v,onFilterModelChange:E,sortModel:m,onSortModelChange:y,pagination:M=!1,paginationModel:N,onPaginationModelChange:k,pageSizeOptions:C=[10,25,50,100],pinnedColumns:S,onPinnedColumnsChange:j,pinnedRows:P,getDetailPanelContent:b,getDetailPanelHeight:F,detailPanelExpandedRowIds:z,onDetailPanelExpandedRowIdsChange:K,pinCheckboxColumn:W=!0,pinExpandColumn:$=!0,disableColumnReorder:H=!1,columnOrder:L,onColumnOrderChange:B,height:D,rowReordering:_=!1,onRowOrderChange:T,loading:I=!1,treeData:O=!1,getTreeDataPath:X,defaultGroupingExpansionDepth:te,groupingColDef:Z,rowGroupingModel:ce,aggregationModel:le,onAggregationModelChange:G,getAggregationPosition:R,isCellEditable:Y,processRowUpdate:Q,onProcessRowUpdateError:J,dataSource:re,multiSort:q=!1,sortingMode:V="client",filterMode:A="client",paginationMode:ee="client",rowCount:ie,slots:ae,slotProps:fe,pivotMode:he=!1,pivotModel:Me,onPivotModelChange:ke,className:Pe="",style:Se,onRowsScrollEnd:oe,ariaLabel:je,initialState:Qn,onStateChange:Li,columnVisibilityModel:Fi,onColumnVisibilityModelChange:Oi,listView:yt=!1,listViewColumn:Zn,columnGroupingModel:Ge,noRowsLabel:Wi="No Data",localeText:$e,apiRef:dn,overscanRowCount:Ai=3}=n,cn=$e?.noRowsLabel??Wi,$i=s.useMemo(()=>({items:[]}),[]),Le=v||$i,zi=s.useMemo(()=>[],[]),un=ce||zi,eo=s.useRef(ae?.toolbar);eo.current=ae?.toolbar;const Bi=s.useRef(U=>{const ne=eo.current;return ne?ne(U):null}).current,Di=Eo({initialState:Qn,sortModel:m,aggregationModel:le,onAggregationModelChange:G,columnVisibilityModel:Fi,onColumnVisibilityModelChange:Oi,pinnedColumns:S,onPinnedColumnsChange:j,pivotModel:Me,onPivotModelChange:ke,paginationModel:N,onPaginationModelChange:k,rowSelectionModel:w}),{sortModel:We,isSortControlled:$t,setInternalSortModel:zt,aggregationModel:Re,handleAggregationModelChange:to,columnVisibilityModel:Ue,handleColumnVisibilityModelChange:Bt,pinnedColumns:tt,handlePinnedColumnsChange:fn,currentPivotModel:gn,handlePivotModelChange:no,effectivePaginationModel:Ee,handlePaginationModelChange:Dt,selectedRowIds:Ce,isSelectionControlled:nt,setInternalRowSelectionModel:ot}=Di,rt=x,Ht=$n(t,e,gn,he),De=d==="compact"?32:d==="comfortable"?72:i,oo=he&&Ht.isValid?Ht.pivotRows:t,hn=he&&Ht.isValid?Ht.pivotColumns:e,Vt=!!(ce&&ce.length>0),Ke=s.useMemo(()=>Z&&Vt&&!he?{...tt,left:["__group__",...(tt?.left??[]).filter(U=>U!=="__group__")]}:tt,[Z,Vt,he,tt]),kt=s.useMemo(()=>Z&&Vt&&!he?[{headerName:"Group",width:220,...Z,field:"__group__",hideable:!1,sortable:!1,pinnable:!1,exportable:!1},...hn]:hn,[Z,Vt,he,hn]),[Hi,ro]=s.useState(null);s.useEffect(()=>{ro(null)},[Re]);const it=s.useRef(null),Vi=s.useRef(null),Gt=s.useRef(null),Gi=s.useCallback(U=>U.id,[]),lt=o||Gi,pn=s.useMemo(()=>oo.map(U=>{const ne=lt(U);return ne===U.id?U:{...U,id:ne}}),[oo,lt]),st=s.useCallback(U=>{yn.current?.classList.toggle("ogx--kb",U)},[]),io=s.useRef(re);io.current=re;const lo=s.useRef(null),so=s.useRef(null),Ui=s.useCallback(U=>{if(io.current&&O&&(U.serverChildrenCount??0)>0&&(U.children??[]).length===0){const ne=so.current?.getNodePath(U.id)||[U.groupingKey];lo.current?.(U.id,ne)}},[O]),_e=fr({rows:pn,columns:kt,rowHeight:De,headerHeight:l,rowCount:ie,columnVisibilityModel:Ue,initialState:n.initialState}),{state:pe,apiRef:at,setRows:xn,setColumns:Ki,setDimensions:ao,setDataSourceLoading:Yi,setDataSourceError:qi,setRowCount:Xi}=_e,{scrollTop:Ji,scrollLeft:Qi,overscanRows:Zi,handleScroll:el}=zo({onRowsScrollEnd:oe,overscanRowCount:Ai});s.useEffect(()=>{dn&&(dn.current=at.current)},[dn,at]);const{copySelectedRows:co}=Sr({selectedRowIds:Ce,columns:kt,getVisibleRows:()=>at.current.getVisibleRows(),getRowId:lt});s.useEffect(()=>{at.current.copySelectedRows=co,at.current.getSelectedRows=()=>Array.from(Ce)},[co,Ce,at]);const tl=pe.dataSource.loading,St=I||tl,Ye=s.useMemo(()=>pe.rows.allRows.map(U=>pe.rows.idRowsLookup.get(U)),[pe.rows]),jt=hr({rows:Ye,getRowId:lt,getTreeDataPath:X,treeData:O,defaultGroupingExpansionDepth:te,filterModel:Le,sortModel:We,onRowExpansionChange:Ui});s.useEffect(()=>{so.current=jt},[jt]);const Et=wr({rows:Ye,getRowId:lt,columns:kt,rowGroupingModel:un,aggregationModel:Re,defaultGroupingExpansionDepth:te,filterModel:Le,sortModel:We,getAggregationPosition:R}),dt=br({rows:Ye,getRowId:lt,processRowUpdate:Q,onProcessRowUpdateError:J,onRowChange:U=>{const{dispatch:ne}=_e,ue=Array.from(_e.state.rows.idRowsLookup.values()).map(ge=>ge.id===U.id?U:ge);ne({type:"SET_ROWS",payload:ue})}}),Nt=O,Ae=!!(un&&un.length>0),mn=Nt||Ae,Ut=Nt?jt:Ae?Et:null,Mt=s.useMemo(()=>Nt?jt.rowMetaMap:Ae?Et.rowMetaMap:Vr,[Nt,jt.rowMetaMap,Ae,Et.rowMetaMap]),Fe=M&&!Ae,Kt=s.useCallback(U=>{const{row:ne,id:de}=U;if(mn&&Mt.get(ne.id)?.hasChildren){Ut?.toggleExpansion(de);return}if(g?.(U),!u){let ue;if(p)ue=Ce.has(de)?[]:[de];else{const ge=new Set(Ce);ge.has(de)?ge.delete(de):ge.add(de),ue=Array.from(ge)}nt||ot(ue),rt?.(ue)}},[mn,Ut,g,Mt,u,p,Ce,nt,ot,rt]),wn=Cr({dataSource:re,sortModel:We,filterModel:Le,paginationModel:Ee,paginationMode:ee,sortingMode:V,filterMode:A,aggregationModel:Re,setRows:xn,setRowCount:Xi,setDataSourceLoading:Yi,setDataSourceError:qi,onAggregationResults:ro});s.useEffect(()=>{wn.fetchChildren&&(lo.current=wn.fetchChildren)},[wn.fetchChildren]),s.useEffect(()=>{re||xn(pn)},[pn,xn,re]);const ze=!!b,[nl,ol]=s.useState(new Set),ct=z??nl,Yt=s.useCallback(U=>{const ne=new Set(ct);ne.has(U)?ne.delete(U):ne.add(U),z===void 0&&ol(ne),K?.(ne)},[ct,z,K]),{effectiveColumns:He,orderedColumns:bn,visibleOrderedColumns:rl,navigationColumns:uo,columnWidths:Be,effectiveColumnOrder:qt,setInternalColumnOrder:Xt,columnReorderHandlers:ut,handleColumnResize:il}=Wo({activeColumns:kt,isHierarchyEnabled:mn,isRowGrouping:Ae,isTreeData:Nt,activeHierarchyHandlers:Ut,columnVisibilityModel:Ue,columnOrder:L,onColumnOrderChange:B,disableColumnReorder:H,pivotMode:he,checkboxSelection:c,hasDetailPanel:ze,rowReordering:_,initialState:Qn,setColumns:Ki});Bo({onStateChange:Li,sortModel:We,filterModel:Le,effectivePaginationModel:Ee,columnWidths:Be,effectiveColumnOrder:qt,columnVisibilityModel:Ue,pinnedColumns:Ke});const ft=Lo({effectiveRows:Ye,activeHierarchyHandlers:Ut,filterMode:A,filterModel:Le,dataSource:re,sortModel:We,sortingMode:V,pagination:Fe,paginationMode:ee,effectivePaginationModel:Ee,pinnedRows:P,isLoading:pe.dataSource.loading,pageSize:Ee.pageSize}),qe=ft.filteredRows,Pt=ft.pinnedTopRows,Jt=ft.pinnedBottomRows,Oe=ft.sortedUnpinnedRows,gt=ft.paginatedUnpinnedRows,vn=ft.allRenderableRows;s.useEffect(()=>{_e.apiRef.current.getVisibleRows=()=>Fe?gt:Oe,_e.apiRef.current.getAllFilteredRows=()=>Oe,_e.apiRef.current.getVisibleColumns=()=>He},[Oe,gt,Fe,He,_e.apiRef]);const ll=gr({rows:Fe?gt:Oe,getRowId:U=>U.id,onRowOrderChange:T,rowReordering:_}),ht=vr(vn,uo,Be),{aggregationResult:pt}=Tn({rows:qe,columns:kt,aggregationModel:Re,isServerSide:!!(re&&(ee==="server"||V==="server")),dataSource:re,filterModel:Le,sortModel:We,serverAggregationResults:Hi}),Xe=Object.keys(Re).length>0;s.useEffect(()=>{_e.apiRef.current.getAggregationResult=()=>Xe?pt:null,_e.apiRef.current.getAggregationModel=()=>Xe?Re:null,_e.apiRef.current.getGroupedExportRows=()=>{if(!Ae)return null;const{treeNodes:U,groupingRows:ne}=Et,de=new Map;Oe.forEach(xe=>de.set(xe.id,xe));const ue=[],ge=xe=>{xe.forEach(ye=>{const we=U.get(ye);if(!we)return;if(!!(we.children&&we.children.length>0))ue.push({type:"group-header",depth:we.depth,groupField:we.groupingField,groupValue:we.groupingValue}),ge(we.children),Xe&&we.aggregatedValues&&ue.push({type:"group-subtotal",depth:we.depth,groupField:we.groupingField,groupValue:we.groupingValue,aggregatedValues:we.aggregatedValues});else{const Lt=de.get(ye)??ne.get(ye);Lt&&ue.push({type:"leaf",depth:we.depth,row:Lt})}})};return ge(Array.from(U.keys()).filter(xe=>U.get(xe)?.parentId===null)),Xe&&pt&&ue.push({type:"grand-total",depth:0,aggregatedValues:pt}),ue}},[pt,Re,Xe,_e.apiRef,Ae,Et,Oe]);const me=ko({rowHeight:De,pagination:Fe,paginatedUnpinnedRows:gt,sortedUnpinnedRows:Oe,expandedRowIds:ct,getDetailPanelHeight:F,pinnedTopRowsLength:Pt.length,pinnedBottomRowsLength:Jt.length,visibleOrderedColumns:rl,pinnedColumns:Ke,columnWidths:Be,viewportWidth:pe.dimensions.viewportWidth||1e3,checkboxSelection:c,hasDetailPanel:ze,rowReordering:_,paginationMode:ee,isLoading:pe.dataSource.loading,pageSize:Ee.pageSize}),sl=s.useMemo(()=>{const U={};for(const ne of[...me.leftPinnedCols,...me.unpinnedColsWithWidth,...me.rightPinnedCols])ne.isSpacer||(U[ne.field]=ne.width);return{...U,...Be}},[me.leftPinnedCols,me.unpinnedColsWithWidth,me.rightPinnedCols,Be]);s.useEffect(()=>{_e.apiRef.current.scrollToIndexes=({rowIndex:U,colIndex:ne})=>{const de=it.current;if(de&&(U!==void 0&&U>=0&&Mn(de,U,me.cumulativeHeights,me.pinnedBottomHeight),ne!==void 0&&ne>=0)){const ge=[...me.leftPinnedCols,...me.unpinnedColsWithWidth,...me.rightPinnedCols][ne];if(!ge)return;const xe=me.unpinnedColsWithWidth.findIndex(xl=>xl.field===ge.field);if(xe===-1)return;const ye=xe>0?me.unpinnedAccWidths[xe-1]:0,we=me.unpinnedAccWidths[xe]??ye,It=me.leftWidth+we,{scrollLeft:Lt,clientWidth:wo}=de;ye<Lt?de.scrollLeft=ye:It>Lt+wo&&(de.scrollLeft=It-wo)}}},[me,it,_e.apiRef]);const Te=Fo({layout:me,scrollTop:Ji,scrollLeft:Qi,viewportWidth:pe.dimensions.viewportWidth,viewportHeight:pe.dimensions.viewportHeight,autoHeight:a,rowReordering:_,hasDetailPanel:ze,checkboxSelection:c,pinCheckboxColumn:W,pinExpandColumn:$,overscanRows:Zi});s.useEffect(()=>{if(!it.current)return;const U=new ResizeObserver(ne=>{for(const de of ne){const{width:ue,height:ge}=de.contentRect;ao(ue,ge)}});return U.observe(it.current),()=>{U.disconnect()}},[ao]);const Rt=s.useCallback((U,ne)=>{const de=new Set(Ce);ne?de.add(U):de.delete(U);const ue=Array.from(de);nt||ot(ue),rt?.(ue)},[Ce,nt,rt,ot]),al=s.useCallback(U=>{let ne=[];U&&(ne=Ye.map(de=>de.id)),nt||ot(ne),rt?.(ne)},[Ye,nt,rt,ot]),fo=s.useCallback((U,ne)=>{const de=ne?[{field:U,sort:ne}]:[];$t||zt(de),y?.(de)},[$t,y,zt]),dl=s.useCallback((U,ne)=>{const de=We.filter(ge=>ge.field!==U),ue=ne?[...de,{field:U,sort:ne}]:de;$t||zt(ue),y?.(ue)},[We,$t,y,zt]),{focusedCell:Qt,setFocusedCell:Cn,handleFocus:cl,handleBlur:ul,handleKeyDown:fl}=So({allRenderableRows:vn,navigationColumns:uo,checkboxSelection:c,selectedRowIds:Ce,handleSelectionChange:Rt,handleDetailPanelToggle:Yt,editingHandlers:dt,setKeyboardMode:st,sortModel:We,handleSort:fo,isCellEditable:Y,pagination:Fe,pageSize:Ee.pageSize,virtualization:Te,viewportRef:it,pinnedTopRowCount:Pt.length}),_n=s.useCallback(U=>{st(!1),Cn({id:U.row.id,field:U.field}),Gt.current?.focus({preventScroll:!0}),h?.(U)},[h,st,Cn]),go=s.useRef(dt.editingCell);s.useEffect(()=>{const U=!!go.current,ne=!!dt.editingCell;U&&!ne&&Gt.current?.focus({preventScroll:!0}),go.current=dt.editingCell},[dt.editingCell]);const ho=Ao({renderContext:Te.renderContext,pinnedTopRows:Pt,pinnedBottomRows:Jt,paginatedUnpinnedRows:gt,sortedUnpinnedRows:Oe,pagination:Fe});Ho({paginationRequested:M,isRowGrouping:Ae,autoHeight:a,viewportHeight:pe.dimensions.viewportHeight,renderedRowCount:ho.length,totalRowCount:Pt.length+(Fe?gt.length:Oe.length)+Jt.length});const gl=t.length>0&&Ce.size===t.length,hl=Ce.size>0&&Ce.size<t.length,pl=s.useMemo(()=>He.some(U=>!!U.rowSpan),[He]),[Tt,Zt]=s.useState(!1),yn=s.useRef(null),kn=s.useRef(null),po=ae?.noRowsOverlay,xo=ae?.loadingOverlay,Sn=ae?.footer,mo=s.useMemo(()=>{if(!ae?.toolbar)return null;const U=H?void 0:(ne,de)=>{const ue=[...qt],ge=ue.indexOf(ne),xe=ue.indexOf(de);if(ge===-1||xe===-1)return;const ye=[...ue];ye.splice(ge,1),ye.splice(xe,0,ne),L||Xt(ye);const we=He.find(It=>It.field===ne);we&&B?.({oldIndex:ge,targetIndex:xe,column:we})};return{apiRef:_e.apiRef,columns:bn,baseColumns:e,aggregationModel:Re,onAggregationModelChange:to,...he||Me||ke?{pivotModel:gn,onPivotModelChange:no}:{},filterModel:Le,onFilterModelChange:E,columnVisibilityModel:Ue,onColumnVisibilityModelChange:Bt,onColumnReorder:U,onColumnOrderReset:H?void 0:()=>Xt(e.map(ne=>ne.field)),forceColumnsOpen:Tt,onColumnsPanelClose:()=>Zt(!1),...fe?.toolbar}},[ae?.toolbar,H,qt,bn,He,L,B,Xt,_e.apiRef,e,Re,to,he,Me,ke,gn,no,Le,E,Ue,Bt,Tt,fe?.toolbar]);return s.useEffect(()=>{if(!Tt||ae?.toolbar)return;function U(ne){kn.current&&!kn.current.contains(ne.target)&&Zt(!1)}return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[Tt,ae?.toolbar]),r.jsxs("div",{ref:yn,className:["ogx",Pe,a&&"ogx--auto-height",pl&&"ogx--row-spanning",yt&&"ogx--list-view"].filter(Boolean).join(" "),style:{...Se,height:D??Se?.height,"--ogx-row-height":`${De}px`,"--ogx-header-height":`${l}px`},"aria-busy":St,children:[mo&&r.jsx(Bi,{...mo}),!ae?.toolbar&&r.jsx(Hr,{isOpen:Tt,containerRef:yn,panelRef:kn,effectiveColumns:He,columnVisibilityModel:Ue,effectiveColumnOrder:qt,columnOrder:L,disableColumnReorder:H,onClose:()=>Zt(!1),onColumnVisibilityChange:Bt,onColumnOrderChange:B,setInternalColumnOrder:Xt}),yt&&Zn&&r.jsx(Er,{ariaLabel:je,allRenderableRows:vn,filteredRows:qe,pagination:Fe,effectivePaginationModel:Ee,pageSizeOptions:C,selectedRowIds:Ce,listViewColumn:Zn,noRowsLabel:cn,rowHeight:De,checkboxSelection:c,paginationMode:ee,dataSource:re,serverRowCount:pe.pagination.rowCount||0,paginationSlot:ae?.pagination,paginationSlotProps:fe?.pagination,localeText:$e?{paginationRowsPerPage:$e.paginationRowsPerPage,paginationOf:$e.paginationOf,paginationPage:$e.paginationPage}:void 0,onRowClick:Kt,onRowDoubleClick:f,onSelectionChange:Rt,onPaginationModelChange:Dt}),!yt&&r.jsx("div",{ref:U=>{it.current=U,Gt.current=U},className:"ogx__viewport",onScroll:el,role:"grid","aria-label":je||"Data grid","aria-rowcount":qe.length+1,"aria-colcount":e.length+(c?1:0)+(ze?1:0)+(_?1:0),"aria-busy":St,tabIndex:0,onKeyDownCapture:()=>{st(!0)},onMouseDownCapture:()=>{st(!1)},onKeyDown:fl,onFocus:cl,onBlur:ul,children:r.jsxs("div",{ref:Vi,className:"ogx__content",style:{width:Te.totalWidth},role:"presentation",children:[r.jsx(Ln,{columns:Te.virtualColumns,allColumns:He,columnGroupingModel:Ge,checkboxSelection:c,allSelected:gl,someSelected:hl,onSelectAll:al,sortModel:We,onSort:fo,onSortAdd:dl,multiSort:q,onColumnResize:il,columnWidths:Be,pinnedColumns:Ke,focusedCell:Qt,onHeaderClick:U=>{Cn({id:"HEADER",field:U}),st(!1),Gt.current?.focus({preventScroll:!0})},onDragStart:Ge?void 0:ut.onDragStart,onDragOver:Ge?void 0:ut.onDragOver,onDragEnd:Ge?void 0:ut.onDragEnd,onDrop:Ge?void 0:ut.onDrop,draggedColumn:Ge?void 0:ut.draggedColumn,dragOverColumn:Ge?void 0:ut.dragOverColumn,rowReordering:_,hasDetailPanel:ze,pinCheckboxColumn:W,pinExpandColumn:$,aggregationModel:Re,onHideColumn:U=>{Bt({...Ue,[U]:!1})},onManageColumns:()=>Zt(!0),onPinColumn:(U,ne)=>{const de=[...tt?.left??[]],ue=[...tt?.right??[]],ge=de.filter(ye=>ye!==U),xe=ue.filter(ye=>ye!==U);fn(ne==="left"?{left:[...ge,U],right:xe}:ne==="right"?{left:ge,right:[...xe,U]}:{left:ge,right:xe})}}),!St&&!pe.dataSource.error&&qe.length===0&&r.jsx(Yo,{noRowsLabel:cn,width:Te.totalWidth,overlay:po?r.jsx(po,{...fe?.noRowsOverlay}):void 0}),r.jsx(Bn,{rows:Pt,position:"top",columns:Te.virtualColumns,selectedRowIds:Ce,checkboxSelection:c,onRowClick:Kt,onRowDoubleClick:f,onCellClick:_n,onSelectionChange:Rt,columnWidths:Be,pinnedColumns:Ke,pinnedRows:P,hasDetailPanel:ze,expandedRowIds:ct,getDetailPanelContent:b,getDetailPanelHeight:F,onDetailPanelToggle:Yt,pinCheckboxColumn:W,pinExpandColumn:$,focusedCell:Qt,colspanMap:ht.colspanMap,rowSpanningCaches:ht.rowSpanningState.caches,rowHeight:De,rowMetaMap:Mt}),r.jsx(zr,{virtualContainerHeight:Te.totalHeight-Te.pinnedTopHeight-Te.pinnedBottomHeight,offsetTop:Te.offsetTop,effectiveLoading:St,visibleRows:ho,baseColumns:e,virtualColumns:Te.virtualColumns,viewportWidth:pe.dimensions.viewportWidth,checkboxSelection:c,hasDetailPanel:ze,rowReordering:_,rowHeight:De,pinnedRows:P,selectedRowIds:Ce,onRowClick:Kt,onRowDoubleClick:f,onCellClick:_n,onSelectionChange:Rt,columnWidths:Be,pinnedColumns:Ke,expandedRowIds:ct,getDetailPanelContent:b,getDetailPanelHeight:F,onDetailPanelToggle:Yt,pinCheckboxColumn:W,pinExpandColumn:$,rowReorderHandlers:ll,editingHandlers:dt,focusedCell:Qt,colspanMap:ht.colspanMap,rowSpanningCaches:ht.rowSpanningState.caches,paginationMode:ee,dataSourceLoading:pe.dataSource.loading,sortedUnpinnedRowCount:Oe.length,infiniteScrollSkeletonCount:Math.min(Ee.pageSize,20),unpinnedRowsLength:me.unpinnedRowsLength,rowMetaMap:Mt,loadingOverlay:xo?r.jsx(xo,{...fe?.loadingOverlay}):void 0}),r.jsx(Bn,{rows:Jt,position:"bottom",columns:Te.virtualColumns,selectedRowIds:Ce,checkboxSelection:c,onRowClick:Kt,onRowDoubleClick:f,onCellClick:_n,onSelectionChange:Rt,columnWidths:Be,pinnedColumns:Ke,pinnedRows:P,hasDetailPanel:ze,expandedRowIds:ct,getDetailPanelContent:b,getDetailPanelHeight:F,onDetailPanelToggle:Yt,pinCheckboxColumn:W,pinExpandColumn:$,focusedCell:Qt,colspanMap:ht.colspanMap,rowSpanningCaches:ht.rowSpanningState.caches,rowHeight:De,rowMetaMap:Mt}),Xe&&!he&&r.jsx(Ko,{columns:bn,aggregationModel:Re,aggregationResult:pt,columnWidths:sl,rowHeight:De,checkboxSelection:c,hasDetailPanel:ze,rowReordering:_,pinnedColumns:Ke})]})}),!yt&&Sn&&r.jsx(Sn,{apiRef:_e.apiRef,aggregationModel:Re,aggregationResult:Xe?pt:null,rowCount:Ae?Ye.length:Oe.length,pagination:Fe,paginationModel:Ee,pageSizeOptions:C,onPaginationModelChange:Dt,...fe?.footer}),!yt&&!Sn&&Fe&&(()=>{const U=ae?.pagination||Fn;return r.jsx(U,{page:Ee.page,pageSize:Ee.pageSize,rowCount:pe.pagination.rowCount,pageSizeOptions:C,onPageChange:ne=>Dt({...Ee,page:ne}),onPageSizeChange:ne=>Dt({...Ee,pageSize:ne,page:0}),localeText:$e?{paginationRowsPerPage:$e.paginationRowsPerPage,paginationOf:$e.paginationOf,paginationPage:$e.paginationPage}:void 0,...fe?.pagination})})(),r.jsxs("div",{className:"ogx-aria-live-status",role:"status","aria-live":"polite",children:[St?"Loading data...":"",pe.dataSource.error?`Error: ${pe.dataSource.error instanceof Error?pe.dataSource.error.message:"Unknown error"}`:"",!I&&!pe.dataSource.error&&(qe.length===0?cn:Le&&((Le.quickFilterValues?.length||0)>0||(Le.items?.length||0)>0)?`${qe.length} ${qe.length===1?"row":"rows"} found`:"")]}),r.jsx(qo,{error:pe.dataSource.error})]})}function Ur({rows:n=5,columns:t=5}){return r.jsx("div",{className:"ogx__skeleton",children:Array.from({length:n}).map((e,o)=>r.jsx("div",{className:"ogx__skeleton-row",children:Array.from({length:t}).map((i,l)=>r.jsx("div",{className:"ogx__skeleton-cell",children:r.jsx("div",{className:"ogx__skeleton-content"})},l))},o))})}const Dn=new Set(["isEmpty","isNotEmpty"]);function Kr(n,t){return n.find(e=>"field"in e&&e.field===t)}const Yr=({col:n,item:t,onChange:e})=>{const o=s.useId(),i=To(n.type),l=!!t,a=t?.operator??i[0],[d,c]=s.useState(t?.value!=null?String(t.value):""),u=s.useRef(e),p=s.useRef(t),w=s.useRef(n.field),x=s.useRef(a);s.useLayoutEffect(()=>{u.current=e,p.current=t,w.current=n.field,x.current=a});const g=s.useRef(t?.value);s.useEffect(()=>{t?.value!==g.current&&(g.current=t?.value,c(t?.value!=null?String(t.value):""))},[t?.value]),s.useEffect(()=>{const y=setTimeout(()=>{const M=p.current,N=M?.value??"";d!==N&&u.current({id:M?.id??`${w.current}-${Date.now()}`,field:w.current,operator:x.current,value:d})},300);return()=>clearTimeout(y)},[d]);const f=y=>{const M=Dn.has(y),N={id:t?.id??`${n.field}-${Date.now()}`,field:n.field,operator:y,value:M?void 0:t?.value??(n.type==="boolean"?"true":"")};e(N)},h=()=>{c(""),e(null)},v=Dn.has(String(a)),E=n.type==="boolean",m=!v;return r.jsxs("div",{className:`ogx-filter__row${l?" 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${l?" ogx-filter__op-select--active":""}`,value:String(a),onChange:y=>f(y.target.value),"aria-label":`Filter operator for ${n.headerName||n.field}`,children:i.map(y=>r.jsx("option",{value:y,children:y},y))}),m&&E&&r.jsxs("select",{id:`${o}-val`,name:`filter-val-${n.field}`,className:`ogx-filter__value-input ogx-filter__value-select${l?" ogx-filter__value-input--active":""}`,value:String(t?.value??"true"),onChange:y=>{c(y.target.value),e({id:t?.id??`${n.field}-${Date.now()}`,field:n.field,operator:a,value:y.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"})]}),m&&!E&&r.jsx("input",{id:`${o}-val`,name:`filter-val-${n.field}`,className:`ogx-filter__value-input${l?" ogx-filter__value-input--active":""}`,type:"text",value:d,onChange:y=>c(y.target.value),placeholder:n.type==="number"?"Number…":"Value…","aria-label":`Filter value for ${n.headerName||n.field}`}),l&&r.jsx("button",{className:"ogx-filter__row-clear",onClick:h,"aria-label":`Clear filter for ${n.headerName||n.field}`,title:"Clear",children:"×"})]})]})},Hn=({filterModel:n,columns:t,onFilterModelChange:e})=>{const o=s.useMemo(()=>n.items??[],[n.items]),i=n.logicOperator??"and",l=s.useCallback((c,u)=>{const p=o.filter(x=>"field"in x&&x.field!==c),w=u?[...p,u]:p;e({...n,items:w})},[o,n,e]),a=s.useCallback(c=>{e({...n,logicOperator:c})},[n,e]),d=t.filter(c=>c.filterable!==!1);return r.jsxs(r.Fragment,{children:[o.length>1&&r.jsxs("div",{className:"ogx-filter__logic-bar",children:[r.jsx("span",{className:"ogx-filter__logic-label",children:"Match:"}),r.jsx("button",{className:`ogx-filter__logic-pill${i==="and"?" ogx-filter__logic-pill--active":""}`,onClick:()=>a("and"),"aria-pressed":i==="and",children:"ALL (AND)"}),r.jsx("button",{className:`ogx-filter__logic-pill${i==="or"?" ogx-filter__logic-pill--active":""}`,onClick:()=>a("or"),"aria-pressed":i==="or",children:"ANY (OR)"})]}),d.length===0?r.jsx("div",{className:"ogx-filter__empty",children:"No filterable columns."}):d.map(c=>r.jsx(Yr,{col:c,item:Kr(o,c.field),onChange:u=>l(c.field,u)},c.field))]})},qr=["sum","avg","count","min","max"];function Vn(){return r.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[r.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),r.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),r.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),r.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1",fill:"currentColor",opacity:"0.25"}),r.jsx("path",{d:"M17 14v-4M17 10l-2 2 2 2"})]})}function Xr({anchorRef:n,columns:t,model:e,onChange:o,onClose:i}){const l=s.useRef(null),[a,d]=s.useState({top:0,right:0}),[c,u]=s.useState(document.body);s.useLayoutEffect(()=>{u(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const p=s.useCallback(()=>{if(!n.current)return{top:0,right:0};const b=n.current.getBoundingClientRect();return{top:b.bottom+6,right:window.innerWidth-b.right}},[n]);s.useEffect(()=>{d(p());const b=()=>d(p());return window.addEventListener("scroll",b,!0),window.addEventListener("resize",b),()=>{window.removeEventListener("scroll",b,!0),window.removeEventListener("resize",b)}},[p]),s.useEffect(()=>{function b(z){l.current&&!l.current.contains(z.target)&&n.current&&!n.current.contains(z.target)&&i()}function F(z){z.key==="Escape"&&i()}return document.addEventListener("mousedown",b),document.addEventListener("keydown",F),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",F)}},[n,i]);const w=new Set(e.rowFields),x=new Set(e.columnFields),g=new Set(e.valueFields.map(b=>b.field)),f=b=>w.has(b)||x.has(b)||g.has(b);function h(b){w.has(b)||o({...e,rowFields:[...e.rowFields,b]})}function v(b){x.has(b)||o({...e,columnFields:[...e.columnFields,b]})}function E(b,F="sum"){g.has(b)||o({...e,valueFields:[...e.valueFields,{field:b,aggFn:F}]})}function m(b){o({...e,rowFields:e.rowFields.filter(F=>F!==b)})}function y(b){o({...e,columnFields:e.columnFields.filter(F=>F!==b)})}function M(b){o({...e,valueFields:e.valueFields.filter(F=>F.field!==b)})}function N(b,F){o({...e,valueFields:e.valueFields.map(z=>z.field===b?{...z,aggFn:F}:z)})}function k(){o({rowFields:[],columnFields:[],valueFields:[]})}const C=new Set(t.filter(b=>b.type==="number"||b.aggregable).map(b=>b.field)),S=e.rowFields.length+e.columnFields.length+e.valueFields.length,j=b=>t.find(F=>F.field===b)?.headerName??b,P=r.jsxs("div",{ref:l,className:"ogx-pivot-panel",role:"dialog","aria-label":"Pivot configuration",style:{top:a.top,right:a.right},children:[r.jsxs("div",{className:"ogx-pivot-panel__header",children:[r.jsxs("span",{className:"ogx-pivot-panel__title",children:[r.jsx(Vn,{}),"Pivot Mode"]}),S>0&&r.jsx("button",{className:"ogx-pivot-panel__reset-btn",onClick:k,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(b=>r.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--row",children:[j(b),r.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>m(b),title:`Remove ${j(b)}`,children:"×"})]},b))})]}),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(b=>r.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--col",children:[j(b),r.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>y(b),title:`Remove ${j(b)}`,children:"×"})]},b))})]}),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(b=>r.jsxs("span",{className:"ogx-pivot-chip ogx-pivot-chip--value",children:[j(b.field),r.jsx("select",{className:"ogx-pivot-chip__fn-select",value:b.aggFn,onChange:F=>N(b.field,F.target.value),title:"Aggregation function",children:qr.map(F=>r.jsx("option",{value:F,children:F.toUpperCase()},F))}),r.jsx("button",{className:"ogx-pivot-chip__remove",onClick:()=>M(b.field),title:`Remove ${j(b.field)}`,children:"×"})]},b.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(b=>{const F=C.has(b.field);return f(b.field)?null:r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3},children:[r.jsx("span",{className:`ogx-pivot-field-btn${F?" ogx-pivot-field-btn--numeric":""}`,children:b.headerName??b.field}),r.jsxs("div",{className:"ogx-pivot-field-actions",children:[r.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--row",onClick:()=>h(b.field),title:"Add to Row Fields",children:"Row"}),r.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--col",onClick:()=>v(b.field),title:"Add to Column Fields",children:"Col"}),F&&r.jsx("button",{className:"ogx-pivot-add-btn ogx-pivot-add-btn--value",onClick:()=>E(b.field),title:"Add to Value Fields",children:"Val"})]})]},b.field)}),t.every(b=>f(b.field))&&r.jsx("span",{style:{fontSize:12,color:"var(--ogx-color-gray-400, #94a3b8)"},children:"All fields are in use."})]})]})]})]});return Ve.createPortal(P,c)}function Jr(){return r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function Qr(){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 Zr({value:n="",onChange:t,placeholder:e="Search...",debounceMs:o=250}){const[i,l]=s.useState(()=>n.length>0),[a,d]=s.useState(n),c=s.useRef(null),u=s.useRef(null),p=s.useRef(t);s.useLayoutEffect(()=>{p.current=t},[t]);const w=s.useRef(n),x=s.useRef(n),g=s.useRef(!1);s.useLayoutEffect(()=>{g.current&&document.activeElement!==c.current&&c.current?.focus()}),s.useEffect(()=>{n!==x.current&&(x.current=n,n!==w.current&&(d(n),w.current=n,n?l(!0):(g.current=!1,l(!1))))},[n]),s.useEffect(()=>{const m=setTimeout(()=>{a!==w.current&&(w.current=a,p.current(a))},o);return()=>clearTimeout(m)},[a,o]);const f=s.useCallback(()=>{l(!0),requestAnimationFrame(()=>c.current?.focus())},[]),h=s.useCallback(m=>{m.stopPropagation(),d(""),w.current="",p.current(""),c.current?.focus()},[]),v=s.useCallback(()=>{g.current=!0,l(!0)},[]),E=s.useCallback(()=>{g.current=!1,setTimeout(()=>{if(u.current&&document.activeElement&&u.current.contains(document.activeElement)){g.current=!0;return}a||l(!1)},150)},[a]);return s.useEffect(()=>{const m=y=>{u.current&&!u.current.contains(y.target)&&(a||l(!1))};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[a]),r.jsxs("div",{ref:u,className:`ogx-global-search${i?" ogx-global-search--expanded":""}`,onClick:i?void 0:f,children:[r.jsx("div",{className:"ogx-global-search__icon-wrapper",children:r.jsx(Jr,{})}),r.jsx("input",{ref:c,className:"ogx-global-search__input",value:a,onChange:m=>d(m.target.value),onFocus:v,onBlur:E,placeholder:e,"aria-label":"Global Search",autoComplete:"off"}),a&&r.jsx("button",{className:"ogx-global-search__clear",onClick:h,"aria-label":"Clear search",children:r.jsx(Qr,{})})]})}function _t({title:n,children:t,placement:e="top",enterDelay:o=200,leaveDelay:i=0}){const[l,a]=s.useState(!1),[d,c]=s.useState({top:0,left:0}),u=s.useRef(null),p=s.useRef(null),w=s.useCallback(()=>{if(!p.current)return;const h=p.current.getBoundingClientRect();let v=0,E=0;const m=window.pageXOffset||document.documentElement.scrollLeft,y=window.pageYOffset||document.documentElement.scrollTop;e==="top"?(v=h.top+y-8,E=h.left+m+h.width/2):e==="bottom"&&(v=h.bottom+y+8,E=h.left+m+h.width/2),c({top:v,left:E})},[e]);s.useLayoutEffect(()=>(l&&(w(),window.addEventListener("scroll",w,!0),window.addEventListener("resize",w)),()=>{window.removeEventListener("scroll",w,!0),window.removeEventListener("resize",w)}),[l,w]);const x=()=>{u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{a(!0)},o)},g=()=>{u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{a(!1)},i)},f=s.useCallback(h=>{p.current=h?h.firstElementChild??h:null},[]);return r.jsxs(r.Fragment,{children:[r.jsx("span",{ref:f,style:{display:"inline-block",lineHeight:0},onMouseEnter:x,onMouseLeave:g,children:t}),l&&n&&Ve.createPortal(r.jsx("div",{className:`ogx-tooltip ogx-tooltip--${e}`,style:{top:d.top,left:d.left,position:"absolute",zIndex:99999},children:n}),document.body)]})}const ei=["none","sum","avg","count","min","max"];function Gn(){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 ti(){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 Un(){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 ni({anchorRef:n,aggregationModel:t,aggregableColumns:e,onFunctionChange:o,onClearAll:i,onClose:l,activeCount:a}){const d=s.useRef(null),[c,u]=s.useState({top:0,right:0}),[p,w]=s.useState(document.body);s.useLayoutEffect(()=>{w(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const x=s.useCallback(()=>{if(!n.current)return{top:0,right:0};const f=n.current.getBoundingClientRect();return{top:f.bottom+6,right:window.innerWidth-f.right}},[n]);s.useEffect(()=>{u(x());const f=()=>u(x());return window.addEventListener("scroll",f,!0),window.addEventListener("resize",f),()=>{window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}},[x]),s.useEffect(()=>{function f(h){d.current&&!d.current.contains(h.target)&&n.current&&!n.current.contains(h.target)&&l()}return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[n,l]),s.useEffect(()=>{function f(h){h.key==="Escape"&&l()}return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[l]);const g=r.jsxs("div",{ref:d,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Summaries configuration",style:{top:c.top,right:c.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(Gn,{}),"Summaries"]}),a>0&&r.jsx("button",{className:"ogx-toolbar__clear-btn",onClick:i,title:"Clear all summaries",children:"Clear all"})]}),r.jsx("div",{className:"ogx-toolbar__panel-body",children:e.length===0?r.jsxs("p",{className:"ogx-toolbar__empty",children:["No aggregable columns.",r.jsx("br",{}),"Set ",r.jsx("code",{children:"aggregable: true"})," on a column to enable."]}):e.map(f=>{const h=t[f.field]||"none";return r.jsxs("div",{className:"ogx-toolbar__agg-row",children:[r.jsx("span",{className:"ogx-toolbar__agg-label",title:f.field,children:f.headerName||f.field}),r.jsx("div",{className:"ogx-toolbar__agg-pills",children:ei.map(v=>r.jsx("button",{className:`ogx-toolbar__pill${h===v?" ogx-toolbar__pill--active":""}`,onClick:()=>o(f.field,v),"aria-pressed":h===v,children:v},v))})]},f.field)})})]});return Ve.createPortal(g,p)}function oi({anchorRef:n,columns:t,visibleColumns:e,onVisibilityChange:o,onShowAll:i,onHideAll:l,onColumnReorder:a,onColumnOrderReset:d,onClose:c,showNonHideableColumns:u}){const p=s.useRef(null),[w,x]=s.useState({top:0,right:0}),[g,f]=s.useState(document.body);s.useLayoutEffect(()=>{f(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const h=s.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]);s.useEffect(()=>{x(h());const E=()=>x(h());return window.addEventListener("scroll",E,!0),window.addEventListener("resize",E),()=>{window.removeEventListener("scroll",E,!0),window.removeEventListener("resize",E)}},[h]),s.useEffect(()=>{function E(m){p.current&&!p.current.contains(m.target)&&n.current&&!n.current.contains(m.target)&&c()}return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[n,c]);const v=r.jsx("div",{ref:p,className:"ogx-toolbar__panel",role:"dialog","aria-label":"Column visibility",style:{top:w.top,right:w.right,width:280,padding:0},children:r.jsx(sn,{columns:t,visibleColumns:e,onVisibilityChange:o,onShowAll:i,onHideAll:l,onColumnReorder:a,onColumnOrderReset:d,showNonHideableColumns:u})});return Ve.createPortal(v,g)}function ri({anchorRef:n,columns:t,filterModel:e,onFilterModelChange:o,onClose:i}){const l=s.useRef(null),[a,d]=s.useState({top:0,right:0}),c=s.useRef(i);s.useLayoutEffect(()=>{c.current=i},[i]);const[u,p]=s.useState(document.body);s.useLayoutEffect(()=>{p(n.current?.closest(".ogx-theme-provider")??document.body)},[n]);const w=s.useCallback(()=>{if(!n.current)return{top:0,right:0};const h=n.current.getBoundingClientRect();return{top:h.bottom+6,right:window.innerWidth-h.right}},[n]);s.useEffect(()=>{d(w());const h=()=>d(w());return window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}},[w]),s.useEffect(()=>{function h(v){v.key==="Escape"&&c.current()}return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[]);const x=e.items?.length??0,g=()=>{o({...e,items:[],logicOperator:"and"})},f=r.jsxs("div",{ref:l,className:"ogx-toolbar__panel ogx-toolbar__panel--filter",role:"dialog","aria-label":"Advanced filters",style:{top:a.top,right:a.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(Un,{}),"Filters",x>0&&r.jsx("span",{className:"ogx-toolbar__panel-count",children:x})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[x>0&&r.jsx("button",{className:"ogx-toolbar__clear-btn",onClick:g,title:"Clear all filters",children:"Clear all"}),r.jsx("button",{className:"ogx-toolbar__close-btn",onClick:()=>c.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(Hn,{columns:t,filterModel:e,onFilterModelChange:o})})]});return Ve.createPortal(f,u)}const ii={rowFields:[],columnFields:[],valueFields:[]};function li({columns:n=[],baseColumns:t,aggregationModel:e={},onAggregationModelChange:o,pivotModel:i,onPivotModelChange:l,filterModel:a,onFilterModelChange:d,columnVisibilityModel:c={},onColumnVisibilityModelChange:u,onColumnReorder:p,onColumnOrderReset:w,forceColumnsOpen:x,onColumnsPanelClose:g,children:f,rightContent:h,style:v,renderColumnsButton:E,renderFilterButton:m,renderAggregationButton:y,renderExportButton:M,renderQuickFilter:N,className:k,showNonHideableColumns:C}){const[S,j]=s.useState(!1),[P,b]=s.useState(!1),[F,z]=s.useState(!1),[K,W]=s.useState(!1);s.useEffect(()=>{x&&(z(!0),j(!1),b(!1),W(!1))},[x]);const $=s.useRef(null),H=s.useRef(null),L=s.useRef(null),B=s.useRef(null),D=s.useRef(null),_=s.useRef(null),T=s.useRef(null),I=i??ii,O=I.rowFields.length>0||I.columnFields.length>0||I.valueFields.length>0,X=n.filter(q=>q.aggregable!==!1&&(q.type==="number"||q.aggregable===!0)),te=Object.keys(e).filter(q=>e[q]&&e[q]!=="none").length,Z=s.useCallback((q,V)=>{if(!o)return;const A={...e};V==="none"?delete A[q]:A[q]=V,o(A)},[e,o]),ce=s.useCallback(()=>{o?.({})},[o]),le=s.useCallback(q=>{if(!d)return;const A={...a||{},quickFilterValues:q?[q]:[],items:a?.items||[]};d(A)},[a,d]),G=a?.quickFilterValues?.[0]||"",R=a?.items?.length||0,Y=new Set(n.filter(q=>c[q.field]!==!1).map(q=>q.field)),Q=s.useCallback((q,V)=>{if(!u)return;const A={...c,[q]:V};u(A)},[c,u]),J=s.useCallback(()=>{if(!u)return;const q={...c};n.forEach(V=>{V.hideable!==!1&&(q[V.field]=!0)}),u(q)},[n,c,u]),re=s.useCallback(()=>{if(!u)return;const q={...c};n.forEach(V=>{V.hideable!==!1&&(q[V.field]=!1)}),u(q)},[n,c,u]);return r.jsxs("div",{className:["ogx-toolbar",k].filter(Boolean).join(" "),role:"toolbar","aria-label":"Grid toolbar",style:v,children:[f&&r.jsx("div",{className:"ogx-toolbar__left",children:f}),r.jsx("div",{className:"ogx-toolbar__spacer"}),r.jsxs("div",{className:"ogx-toolbar__actions",children:[d&&r.jsx("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:N?N({value:G,onChange:le}):r.jsx(Zr,{value:G,onChange:le,placeholder:"Search..."})}),u&&r.jsxs("div",{ref:D,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[E?E({onClick:()=>{z(q=>!q),j(!1),b(!1),W(!1)},isOpen:F,activeCount:n.length-Y.size}):r.jsx(_t,{title:"Columns",children:r.jsx("button",{ref:L,className:`ogx-toolbar__icon-btn${F?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Manage columns",onClick:()=>{z(!F),j(!1),b(!1),W(!1)},children:r.jsx(ti,{})})}),F&&r.jsx(oi,{anchorRef:E?D:L,columns:n,visibleColumns:Y,onVisibilityChange:Q,onShowAll:J,onHideAll:re,onColumnReorder:p,onColumnOrderReset:w,onClose:()=>{z(!1),g?.()},showNonHideableColumns:C})]}),d&&r.jsxs("div",{ref:_,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[m?m({onClick:()=>{W(q=>!q),j(!1),b(!1),z(!1)},isOpen:K,activeCount:R}):r.jsx(_t,{title:"Filters",children:r.jsxs("button",{ref:B,className:`ogx-toolbar__icon-btn${K?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Advanced filters",onClick:()=>{W(!K),j(!1),b(!1),z(!1)},children:[r.jsx(Un,{}),R>0&&r.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Filters active"})]})}),K&&r.jsx(ri,{anchorRef:m?_:B,columns:n,filterModel:a||{items:[]},onFilterModelChange:d,onClose:()=>W(!1)})]}),l&&r.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[r.jsx(_t,{title:"Pivot",children:r.jsxs("button",{ref:H,className:`ogx-toolbar__icon-btn${P?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure pivot","aria-expanded":P,onClick:()=>{b(!P),j(!1),z(!1),W(!1)},children:[r.jsx(Vn,{}),O&&r.jsx("span",{className:"ogx-toolbar__dot","aria-label":"Pivot active"})]})}),P&&r.jsx(Xr,{anchorRef:H,columns:t??n,model:I,onChange:q=>{l?.(q)},onClose:()=>b(!1)})]}),r.jsxs("div",{ref:T,className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[y?y({onClick:()=>{j(q=>!q),b(!1),z(!1),W(!1)},isOpen:S,activeCount:te}):r.jsx(_t,{title:"Summaries",children:r.jsxs("button",{ref:$,className:`ogx-toolbar__icon-btn${S?" ogx-toolbar__icon-btn--active":""}`,"aria-label":"Configure summaries","aria-expanded":S,onClick:()=>{j(!S),b(!1),z(!1),W(!1)},children:[r.jsx(Gn,{}),te>0&&r.jsx("span",{className:"ogx-toolbar__dot","aria-label":`${te} active summaries`})]})}),S&&r.jsx(ni,{anchorRef:y?T:$,aggregationModel:e,aggregableColumns:X,onFunctionChange:Z,onClearAll:ce,onClose:()=>j(!1),activeCount:te})]}),M&&M(),h]})]})}function si(){return s.useRef(null)}const ai=({fullWidth:n=!1,error:t=!1,startAdornment:e,endAdornment:o,className:i="",...l})=>{const a=["ogx-input-wrapper",n&&"ogx-input-wrapper--full-width",t&&"ogx-input-wrapper--error",l.disabled&&"ogx-input-wrapper--disabled",i].filter(Boolean).join(" ");return r.jsxs("div",{className:a,children:[e&&r.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--start",children:e}),r.jsx("input",{className:"ogx-input",...l}),o&&r.jsx("div",{className:"ogx-input__adornment ogx-input__adornment--end",children:o})]})};function Kn(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 di(n){return n.filter(t=>!(t.exportable===!1||t.field==="__check__"||t.field==="__actions__"))}function Yn(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 qn(n){return(typeof n.width=="number"?n.width:void 0)??(n.flex??1)*100}function ci(n,t){const e=n.reduce((i,l)=>i+qn(l),0),o={};return n.forEach((i,l)=>{o[l]={cellWidth:qn(i)/e*t}}),o}function ui(n,t){return!n.items||n.items.length===0?"":n.items.flatMap(e=>{if("items"in e)return[];const i=t.find(a=>a.field===e.field)?.headerName??e.field,l=e.value!==void 0&&e.value!==null?String(e.value):"";return[`${i} ${e.operator} "${l}"`]}).join(" • ")}async function fi(n,t,e={}){let o,i;try{const[_,T]=await Promise.all([import("jspdf"),import("jspdf-autotable")]);o=_.default,i=T.default}catch{throw new Error("exportToPdf requires 'jspdf' and 'jspdf-autotable'. Run: npm install jspdf jspdf-autotable")}const{fileName:l="export",title:a,logoUrl:d,orientation:c="landscape",selectedRows:u,aggregationResult:p,aggregationModel:w,filterModel:x,alternateRowColor:g=!0,headerBackgroundColor:f="#4f46e5",headerTextColor:h="#ffffff",fontSize:v=9,groupedRows:E}=e,m=new o({orientation:c,unit:"mm",format:"a4"}),y=m.internal.pageSize.getWidth(),M=m.internal.pageSize.getHeight(),N=14,k=y-N*2,C=di(t),S=u&&u.length>0?n.filter(_=>u.includes(_.id)):n;let j=N;if(a){let _=N,T=N+8;if(d)try{m.addImage(d,"PNG",_,N,10,10),_+=14}catch{}m.setFontSize(16),m.setFont("helvetica","bold"),m.setTextColor(30,41,59),m.text(a,_,T),T+=6,m.setFontSize(8),m.setFont("helvetica","normal"),m.setTextColor(100,116,139);const I=new Date().toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),O=E?E.filter(X=>X.type==="leaf").length:S.length;if(m.text(`Exported: ${I} • ${O} row${O!==1?"s":""}`,_,T),T+=5,x){const X=ui(x,t);X&&(m.text(`Filters: ${X}`,_,T),T+=5)}m.setDrawColor(226,232,240),m.setLineWidth(.3),m.line(N,T+2,y-N,T+2),j=T+6}const P=[C.map(_=>_.headerName??_.field)];let b,F;if(E&&E.length>0){b=[];const _=w||{};E.forEach(T=>{if(T.type==="group-header"){const O=`${" ".repeat(T.depth*2)}${T.groupField??""}: ${String(T.groupValue??"")}`;b.push(C.map((X,te)=>te===0?O:""))}else if(T.type==="leaf"&&T.row){const I=T.row,O=" ".repeat(T.depth*2);b.push(C.map((X,te)=>(te===0?O:"")+Yn(I,X)))}else if(T.type==="group-subtotal"&&T.aggregatedValues){const I=" ".repeat(T.depth*2);b.push(C.map((O,X)=>{if(X===0)return`${I}Subtotal`;const te=T.aggregatedValues[O.field];if(te==null)return"";let Z=te;return O.valueFormatter?Z=O.valueFormatter({value:te,row:{},field:O.field}):_[O.field]&&(Z=ve(te,_[O.field])),String(Z)}))}else T.type==="grand-total"&&T.aggregatedValues&&(F=[C.map((O,X)=>{if(X===0)return"Grand Total";const te=T.aggregatedValues[O.field];if(te==null)return"";let Z=te;return O.valueFormatter?Z=O.valueFormatter({value:te,row:{},field:O.field}):_[O.field]&&(Z=ve(te,_[O.field])),String(Z)})])})}else b=S.map(_=>C.map(T=>Yn(_,T))),p&&w&&(F=[C.map((T,I)=>{if(I===0)return C.some(Z=>w[Z.field])?"TOTAL":"";const O=p[T.field];if(O==null)return"";let X=O;return T.valueFormatter?X=T.valueFormatter({value:O,row:{},field:T.field}):w[T.field]&&(X=ve(O,w[T.field])),String(X)})]);const z=ci(C,k),[K,W,$]=Kn(f),[H,L,B]=Kn(h);i(m,{head:P,body:b,...F?{foot:F}:{},startY:j,styles:{fontSize:v,cellPadding:3,font:"helvetica",overflow:"linebreak"},headStyles:{fillColor:[K,W,$],textColor:[H,L,B],fontStyle:"bold"},...g?{alternateRowStyles:{fillColor:[248,250,252]}}:{},...F?{footStyles:{fillColor:[241,245,249],fontStyle:"bold",textColor:[0,0,0]}}:{},columnStyles:z,showFoot:F?"lastPage":"never",showHead:"everyPage",margin:{top:N,left:N,right:N,bottom:N+6}});const D=m.getNumberOfPages();for(let _=1;_<=D;_++)m.setPage(_),m.setFontSize(8),m.setTextColor(150,150,150),m.text(`Page ${_} of ${D}`,y-N,M-8,{align:"right"});m.save(`${l}.pdf`)}function gi(n,t,e={}){const{fileName:o="export.csv",includeHeaders:i=!0,delimiter:l=",",selectedRows:a,groupedRows:d}=e,c=t.filter(p=>!(p.exportable===!1||p.field==="__check__"||p.field==="__actions__"));let u="";if(d&&d.length>0)i&&(u+=c.map(p=>Ie(p.headerName||p.field)).join(l)+`
9
- `),d.forEach(p=>{if(p.type==="group-header"){const x=`${" ".repeat(p.depth)}${p.groupField??""}: ${String(p.groupValue??"")}`,g=c.map((f,h)=>h===0?Ie(x):"");u+=g.join(l)+`
10
- `}else if(p.type==="leaf"&&p.row){const w=p.row,x=" ".repeat(p.depth),g=c.map((f,h)=>{let v=w[f.field];return f.valueGetter&&(v=f.valueGetter({row:w,field:f.field,value:v})),f.valueFormatter&&v!==void 0&&v!==null&&(v=f.valueFormatter({value:v,row:w,field:f.field})),Ie((h===0?x:"")+String(v??""))});u+=g.join(l)+`
11
- `}else if(p.type==="group-subtotal"&&p.aggregatedValues){const w=" ".repeat(p.depth),x=e.aggregationModel||{},g=c.map((f,h)=>{if(h===0)return Ie(`${w}Subtotal`);const v=p.aggregatedValues[f.field];if(v!=null){let E=v;return f.valueFormatter?E=f.valueFormatter({value:v,row:{},field:f.field}):x[f.field]&&(E=ve(v,x[f.field])),Ie(String(E))}return""});u+=g.join(l)+`
12
- `}else if(p.type==="grand-total"&&p.aggregatedValues){const w=e.aggregationModel||{},x=c.map((g,f)=>{if(f===0)return Ie("Grand Total");const h=p.aggregatedValues[g.field];if(h!=null){let v=h;return g.valueFormatter?v=g.valueFormatter({value:h,row:{},field:g.field}):w[g.field]&&(v=ve(h,w[g.field])),Ie(String(v))}return""});u+=x.join(l)+`
13
- `}});else{const p=a&&a.length>0?n.filter(w=>a.includes(w.id)):n;if(p.length===0){console.warn("No rows to export");return}if(i&&(u+=c.map(w=>Ie(w.headerName||w.field)).join(l)+`
14
- `),p.forEach(w=>{const x=c.map(g=>{let f=w[g.field];return g.valueGetter&&(f=g.valueGetter({row:w,field:g.field,value:f})),g.valueFormatter&&f!==void 0&&f!==null&&(f=g.valueFormatter({value:f,row:w,field:g.field})),Ie(String(f??""))});u+=x.join(l)+`
15
- `}),e.aggregationResult){const w=e.aggregationResult,x=e.aggregationModel||{},g=c.map(h=>Ie(x[h.field]?x[h.field].toUpperCase():""));u+=g.join(l)+`
16
- `;const f=c.map(h=>{const v=w[h.field];if(v!=null){let E=v;return h.valueFormatter?E=h.valueFormatter({value:v,row:{},field:h.field}):x[h.field]&&(E=ve(v,x[h.field])),Ie(String(E))}return""});u+=f.join(l)+`
17
- `}}an(u,o,"text/csv;charset=utf-8;")}function Ie(n){return n.includes(",")||n.includes('"')||n.includes(`
18
- `)?`"${n.replace(/"/g,'""')}"`:n}function hi(n,t,e={}){const{fileName:o="export.xls",sheetName:i="Sheet1",includeHeaders:l=!0,selectedRows:a,groupedRows:d}=e,c=t.filter(w=>!(w.exportable===!1||w.field==="__check__"||w.field==="__actions__"));let p=`<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>${i}</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(l&&(p+="<thead><tr>",c.forEach(w=>{p+=`<th>${be(w.headerName||w.field)}</th>`}),p+="</tr></thead>"),p+="<tbody>",d&&d.length>0){const w=e.aggregationModel||{};d.forEach(x=>{if(x.type==="group-header"){const f=`${"  ".repeat(x.depth*2)}${x.groupField??""}: ${String(x.groupValue??"")}`;p+='<tr style="font-weight:bold;background:#e8eaf6;">',p+=`<td colspan="${c.length}">${be(f)}</td>`,p+="</tr>"}else if(x.type==="leaf"&&x.row){const g=x.row,f="  ".repeat(x.depth*2);p+="<tr>",c.forEach((h,v)=>{let E=g[h.field];h.valueGetter&&(E=h.valueGetter({row:g,field:h.field,value:E})),h.valueFormatter&&E!==void 0&&E!==null&&(E=h.valueFormatter({value:E,row:g,field:h.field})),p+=`<td>${be((v===0?f:"")+String(E??""))}</td>`}),p+="</tr>"}else if((x.type==="group-subtotal"||x.type==="grand-total")&&x.aggregatedValues){const g=x.type==="grand-total",f=g?"":"  ".repeat(x.depth*2),h=g?"Grand Total":`${f}Subtotal`;p+='<tr style="font-weight:bold;background:#f5f5f5;">',c.forEach((v,E)=>{if(E===0){p+=`<td>${be(h)}</td>`;return}const m=x.aggregatedValues[v.field];if(m!=null){let y=m;v.valueFormatter?y=v.valueFormatter({value:m,row:{},field:v.field}):w[v.field]&&(y=ve(m,w[v.field])),p+=`<td style="text-align:right;">${be(String(y))}</td>`}else p+="<td></td>"}),p+="</tr>"}})}else{const w=a&&a.length>0?n.filter(x=>a.includes(x.id)):n;if(w.length===0){console.warn("No rows to export");return}if(w.forEach(x=>{p+="<tr>",c.forEach(g=>{let f=x[g.field];g.valueGetter&&(f=g.valueGetter({row:x,field:g.field,value:f})),g.valueFormatter&&f!==void 0&&f!==null&&(f=g.valueFormatter({value:f,row:x,field:g.field})),p+=`<td>${be(String(f??""))}</td>`}),p+="</tr>"}),e.aggregationResult){const x=e.aggregationResult,g=e.aggregationModel||{};p+='<tr style="font-size: 11px; color: #666; background-color: #f5f5f5;">',c.forEach(f=>{p+=g[f.field]?`<td style="text-align:right;font-weight:bold;">${be(g[f.field].toUpperCase())}</td>`:"<td></td>"}),p+='</tr><tr style="font-weight:bold;background-color:#f5f5f5;">',c.forEach(f=>{const h=x[f.field];if(h!=null){let v=h;f.valueFormatter?v=f.valueFormatter({value:h,row:{},field:f.field}):g[f.field]&&(v=ve(h,g[f.field])),p+=`<td style="text-align:right;">${be(String(v))}</td>`}else p+="<td></td>"}),p+="</tr>"}}p+="</tbody></table></body></html>",an(p,o,"application/vnd.ms-excel")}function be(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function pi(n,t,e={}){const{fileName:o="export.json",pretty:i=!0,selectedRows:l,groupedRows:a}=e,d=t.filter(u=>!(u.exportable===!1||u.field==="__check__"||u.field==="__actions__"));let c;if(a&&a.length>0){const u=[],p=[];let w;a.forEach(x=>{if(x.type==="group-header"){const g={group:`${x.groupField??""}: ${String(x.groupValue??"")}`,field:x.groupField??"",value:x.groupValue,rows:[],children:[]};for(;u.length>x.depth;)u.pop();u.length===0?p.push(g):(u[u.length-1].children??=[]).push(g),u.push(g)}else if(x.type==="leaf"&&x.row){const g=x.row,f={};d.forEach(h=>{let v=g[h.field];h.valueGetter&&(v=h.valueGetter({row:g,field:h.field,value:v})),f[h.field]=v}),u.length>0&&u[u.length-1].rows.push(f)}else x.type==="group-subtotal"&&x.aggregatedValues&&u.length>0?(u[u.length-1].subtotals={...x.aggregatedValues},u.pop()):x.type==="grand-total"&&x.aggregatedValues&&(w={...x.aggregatedValues})}),c=w?{groups:p,grandTotal:w}:{groups:p}}else{const u=l&&l.length>0?n.filter(w=>l.includes(w.id)):n;if(u.length===0){console.warn("No rows to export");return}const p=u.map(w=>{const x={};return d.forEach(g=>{let f=w[g.field];g.valueGetter&&(f=g.valueGetter({row:w,field:g.field,value:f})),x[g.field]=f}),x});if(e.aggregationResult){const w=e.aggregationResult,x=e.aggregationModel||{},g={};d.forEach(h=>{x[h.field]&&(g[h.field]=x[h.field].toUpperCase())});const f={};d.forEach(h=>{if(w[h.field]!==void 0&&w[h.field]!==null){let v=w[h.field];h.valueFormatter?v=h.valueFormatter({value:v,row:{},field:h.field}):x[h.field]&&(v=ve(v,x[h.field])),f[h.field]=v}}),c={data:p,aggregation:{labels:g,values:f}}}else c=p}an(i?JSON.stringify(c,null,2):JSON.stringify(c),o,"application/json;charset=utf-8;")}async function xi(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(he,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):(he=typeof globalThis<"u"?globalThis:he||self,s(he.OpenGridX={},he.ReactJSXRuntime,he.React,he.ReactDOM))})(this,(function(he,s,a,tt){"use strict";function Go(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 Go(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 Wo(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 Ho(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 ro(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 Fe(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 Bo(e,t,o,n){const r=n?.valueFormatter;if(r)return ro(()=>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 io(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 lo(e){const t=io(e);return t?t.getFullYear()*1e4+(t.getMonth()+1)*100+t.getDate():null}function Xn(e){const t=io(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 Vo(e,t){if(e==null)return"";switch(t?.type){case"date":{const o=io(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 zo=200;function Ko(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:zo}function jo(e,t){if(e)return ro(()=>e(t),void 0,"getDetailPanelHeight","getDetailPanelHeight threw; the panel uses the default height")}function Nl(e,t){const o=Ko(e);return o==="auto"?t??zo: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 Ll(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:Go(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=Go(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 Fl(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 F=jo(l,{row:j,id:k,rowIndex:z});return t+Nl(F,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,F,Q)=>k+W(F,Q),0):z*t,L=_(g,d),A=_(m,u),{left:q,center:K,right:J}=_l(x,v),te=(w?je:0)+(p?je:0)+(b?je:0),oe=(b?je:0)+(p&&C?je:0)+(w&&y?je:0),{widths:Z,flexByField:de}=Ll([...q,...K,...J],h,f-te),ae=j=>Z.get(j.field)??100,ne=j=>({...j,width:ae(j),flex:de.get(j.field)??j.flex}),se=11,re=q.map((j,z)=>({...ne(j),zIndex:se+z})),B=11,D=J.map((j,z)=>({...ne(j),zIndex:B+(J.length-1-z)})),$=K.map(ne),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:L,pinnedBottomHeight:A,leftPinnedCols:re,rightPinnedCols:D,unpinnedColsWithWidth:$,unpinnedColWidths:R,unpinnedAccWidths:H,totalWidth:Y,leftWidth:U,rightWidth:G,unpinnedTotalWidth:V,systemColumnsWidth:te,pinnedSystemColumnsWidth:oe,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={},Uo=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},so={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=>!Uo(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=>!Uo(t))).size};function Xo(e,t){return e?e.aggregable===!1?!1:!e.availableAggregationFunctions||e.availableAggregationFunctions.includes(t):!0}function ao(e,t,o,n){const r={};for(const[i,l]of Object.entries(t)){const c=o.get(i);if(!Xo(c,l))continue;const d=so[l];if(!d){console.warn(`[${n}] Unknown aggregation function: "${l}"`);continue}r[i]=d(e.map(u=>Fe(u,i,c)))}return r}function qo(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 co(e,t,o,n){if(e==null)return"—";if(er(t))return qo(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):qo(r,t)}const Yo=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 Ot=e=>(t,o)=>{const n=nt(t),r=nt(o);return n===null||r===null?!1:e(n,r)},Dt=e=>(t,o)=>{const n=lo(t),r=lo(o);return n===null||r===null?!1:e(n,r)},nr=Dt((e,t)=>e===t),rr=(e,t)=>{const o=lo(e),n=lo(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()!=="","=":Ot((e,t)=>e===t),">":Ot((e,t)=>e>t),">=":Ot((e,t)=>e>=t),"<":Ot((e,t)=>e<t),"<=":Ot((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:Dt((e,t)=>e>t),onOrAfter:Dt((e,t)=>e>=t),before:Dt((e,t)=>e<t),onOrBefore:Dt((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(!Yo.has(n)&&or(r))return null;const i=t.columns?.byField.get(o),l=Hl(n,i);return l?c=>l(Fe(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 Ro(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")&&Ro(e,o)}}function sr(e,t){const o=[];if(!t){for(const n of Object.values(e))Ro(o,n);return o}for(const n of t.quickFilterColumns){const r=Fe(e,n.field,n),i=Bo(e,n.field,r,n);i!=null&&i!==""&&o.push(String(i).toLowerCase()),Ro(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 uo(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 Jo(e,t,o){const n=uo(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"}),Qo=0,dr=1,Xl=2,cr=3,ur=4;function ht(e,t){return{rank:e,num:t,str:""}}function Zo(e,t){if(e==null)return null;if(t==="number"){const o=nt(e);return o===null?null:ht(Qo,o)}if(t==="date"){const o=io(e);return o?ht(dr,o.getTime()):null}switch(typeof e){case"number":return Number.isNaN(e)?null:ht(Qo,e);case"bigint":return ht(Qo,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(Zo(e,n),Zo(t,n)),o)}function Yl(e,t,o){return t.length===0?e:en(e,t,(n,r)=>{const i=o?.byField.get(r.field);return{value:Fe(n,r.field,i),type:i?.type}})}function en(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 Zo(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 tn(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="",on=`${mt}id`,wr=e=>e==="id"?on:e,nn={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=so[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(!Xo(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 nn;const g=c.length>0,m=Array.from(new Set(u.map(S=>S.field))),x=(S,M)=>Fe(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 L=c.map(J=>x(S,J)),A=g?mr(L):"",q=h.get(A);q?q.sample||(q.sample=S):h.set(A,{values:L.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(Uo(te))continue;let oe=K.get(J);oe||(oe=[],K.set(J,oe)),oe.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((_,L)=>{I[wr(_)]=M.labels[L]}),I.id=pr(S);for(const _ of f){const L=M.cells.get(_);for(const A of u)I[w(_,A)]=br(L?.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=uo(N,tn(S));M&&(b=b.filter(({row:I})=>M(I)))}const E=(S,M)=>M==="id"&&y("id")?S[on]: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:L}of b){const A=L.cells.get(M)?.get(I);if(A)for(const q of A)_.push(q)}for(const L of u)L.field===I&&(S[w(M,L)]=br(_,L.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((_,L)=>{const A=r.get(_),q=rs(A,_,M.values[L],M.sample);return A?.headerName?`${A.headerName}: ${q}`:q}).join(" / "):"";for(const _ of u){const L=r.get(_.field),A=_.headerName??L?.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})=>co(q,_.aggFn,L,K)})}}return{pivotRows:P,pivotColumns:X,colKeys:f,isValid:!0}}function rs(e,t,o,n){const r=n?Bo(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[on]);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 At="__reorder_col__",$t="__expand_col__",Ye="__checkbox_col__",rt=e=>e===At||e===$t||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 rn(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),[L,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),oe=a.useRef(!1),Z=a.useRef(!1),de=a.useRef(null),ae=a.useCallback(G=>{oe.current=!0,G.focus({preventScroll:!0}),oe.current=!1},[]),ne=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===At||V===$t&&X||V===Ye&&W)&&Y.scrollLeft>0&&(Y.scrollLeft=0);return}if(!z)return;const{clientWidth:k,scrollLeft:F}=Y,{leftPinnedWidth:Q,rightPinnedWidth:ee,unpinnedAccWidths:ce,unpinnedCols:fe,totalSpecialsWidth:ge,pinnedSpecialsWidth:be}=z,Ce=fe.findIndex(ye=>ye.field===V);if(Ce===-1)return;const ue=ge+Q+(Ce>0?ce[Ce-1]:0),me=ge+Q+ce[Ce],ve=F+be+Q,Se=F+k-ee;let le=F;ue<ve?le=Math.max(0,ue-be-Q):me>Se&&(le=me-k+ee),le!==F&&(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=rn(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),oe.current)return;if(G.target===V){if(!H)return;if(j||d(!0),K){const F=rn(V,K,J);F?F.focus({preventScroll:!0}):B(J,K.field);return}const k=re();k&&(_(F=>F??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,pe)=>{const we=o[pe];!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:F,field:Q}=K,ee=J,ce=o.findIndex(ie=>ie.field===Q),fe=o.filter(ie=>rt(ie.field)).length,ge=ie=>qe(ie,C),be=(ie,pe,we)=>{const Me=o[we];return rt(Me.field)?!1:Jn({row:ie,field:Me.field,value:Fe(ie,Me.field,Me),colDef:Me,rowIndex:pe,colIndex:we-fe,rowMeta:C?.get(y(ie))},v)},Ce=ie=>{let pe=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,pe++):we<0&&(we=o.length-1,pe--),pe<0||pe>=t.length)return null;const De=t[pe];if(!M?.(y(De),o[we].field)&&be(De,pe,we))return{r:pe,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"&&F!==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(F===null){if(H==="Enter"||j){if(G.preventDefault(),Q===Ye){rn(V,K,-1)?.click();return}const ie=o[ce];if(!ie||rt(Q)||ie.sortable===!1)return;const pe=u.find(Me=>Me.field===Q),we=pe?pe.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(F,!r.has(F));return}if(Q===$t){G.shiftKey||l(F);return}if(j){G.shiftKey&&P&&!ge(F)&&i(F,!r.has(F));return}if(Q===At)return;if(be(ie,ee,ce)){c.startCellEdit({id:F,field:Q,value:Fe(ie,Q,o[ce])});return}if(T&&C?.get(F)?.hasChildren){T(F);return}N?.({row:ie,id:F,rowIndex:ee});return}if(G.altKey&&(H==="ArrowRight"||H==="ArrowLeft")&&T&&F!==null){G.preventDefault();const ie=C?.get(F);ie?.hasChildren&&!!ie.isExpanded!=(H==="ArrowRight")&&T(F);return}if(!kr.has(H))return;G.preventDefault();const ue=t.length-1,me=o.length-1,ve=G.ctrlKey||G.metaKey,Se=h?f:10,le=(ie,pe)=>{switch(H){case"ArrowRight":return pe+1>me?{r:ie+1,c:0}:{r:ie,c:pe+1};case"ArrowLeft":return pe-1<0?{r:ie-1,c:me}:{r:ie,c:pe-1};case"ArrowDown":return{r:ie+1,c:pe};case"ArrowUp":return{r:ie-1,c:pe};case"Home":return{r:ve?-1:ie,c:0};case"End":return{r:ve?ue:ie,c:me};case"PageUp":return{r:Math.max(-1,ie-Se),c:pe};default:return{r:Math.min(ue,ie+Se),c:pe}}},ye=({r:ie,c:pe})=>ie>=-1&&ie<=ue&&pe>=0&&pe<=me,Le=({r:ie,c:pe})=>ie>=0?M?.(y(t[ie]),o[pe].field)??null:null;let xe=le(ee,ce);if(H.startsWith("Arrow"))for(let ie=ye(xe)?Le(xe):null;ie&&ie.rowId===F&&ie.field===Q;ie=ye(xe)?Le(xe):null)xe=le(xe.r,xe.c);if(!ye(xe))return;const ke=Le(xe);if(ke){const ie=t.findIndex(we=>y(we)===ke.rowId),pe=o.findIndex(we=>we.field===ke.field);ie!==-1&&pe!==-1&&(xe={r:ie,c:pe})}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:L?-1:0,ensureGridFocus:ne,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(ue=>{T||N(ue),n?.(ue)},[T,n]),[O,W]=a.useState(()=>t?.filter?.filterModel??{items:[]}),X=r!=null,S=X?r:O,M=a.useCallback(ue=>{X||W(ue),i?.(ue)},[X,i]),I=l!==void 0,[_,L]=a.useState(()=>l??{}),A=JSON.stringify(I?l:_),q=a.useMemo(()=>JSON.parse(A),[A]),K=a.useCallback(ue=>{I||L(ue),c?.(ue)},[I,c]),J=d!==void 0,[te,oe]=a.useState(()=>t?.columns?.columnVisibilityModel??{}),Z=J?d:te,de=a.useCallback(ue=>{J||oe(ue),u?.(ue)},[J,u]),ae=g!==void 0,[ne,se]=a.useState(()=>t?.columns?.pinnedColumns??{}),re=ae?g:ne,B=a.useCallback(ue=>{ae||se(ue),m?.(ue)},[ae,m]),[D,$]=a.useState(()=>x??ps),R=x??D,U=a.useCallback(ue=>{$(ue),v?.(ue)},[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(ue=>{G||Y(ue),f?.(ue)},[G,f]),z=p!==void 0,[k,F]=a.useState([]),Q=z?p:k,ee=a.useMemo(()=>new Set(Q),[Q]),ce=a.useRef(null);a.useLayoutEffect(()=>{ce.current=null});const fe=a.useCallback(()=>ce.current,[]),ge=a.useCallback(ue=>{ce.current=ue,z||F(ue),b?.(ue)},[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:F,handleRowSelectionModelChange:ge,getPendingRowSelectionModel:fe,density:y??be}}const Mr=a.createContext(null),ms=52,xs=56,bs=32,vs=72;function fo(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=fo(r?.rowHeightCompact)??bs:n==="comfortable"?i=fo(r?.rowHeightComfortable)??vs:i=t??fo(r?.rowHeightStandard)??ms,{rowHeight:i,headerHeight:o??fo(r?.headerHeight)??xs}}function go(e){return e>=1?Math.floor(e):1}function ln(e,t){return Math.max(1,Math.ceil(Math.max(0,e)/go(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:Jo(t,r,x),[t,r,o,v,n,x]),f=a.useMemo(()=>o?n==="server"?t:Jo(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=go(u.pageSize),T=C?Pr(u.page,ln(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),L=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])>L){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,oe=C-v[q],Z=[...f,...te>0?[{field:"__spacer_left__",width:te,isSpacer:!0}]:[],...h.slice(A,q+1),...oe>0?[{field:"__spacer_right__",width:oe,isSpacer:!0}]:[],...w],ae=S>0&&p>S?16:0,ne=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:ne,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 sn="application/x-ogx-row",an="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 po(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,an,v))}},[t,n,u]),m=a.useCallback(v=>h=>{if(!(n||r===null)){if(!po(h,an)){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||!po(h,an)){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 dn({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)?co(l.value,t,e,l.row):i?i(l):l.value==null?"":String(l.value)}}function Lr(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 ho=e=>e.formattedValue??e.value;function Fr(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 ho(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})`:""]}):ho(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]),L=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(Lr(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===L?{...R,...U,renderCell:G=>{const V=G.rowMeta,Y=V?.treeDepth??0,H=!!V?.hasChildren,j=!!V?.isExpanded,z=Fr(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:F=>{F.stopPropagation(),F.preventDefault(),i?.toggleExpansion(b(G.row))},onMouseDown:F=>{F.stopPropagation()},style:{cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:10,position:"relative"},children:s.jsx(dn,{isExpanded:j,tabIndex:-1,onClick:F=>{F.stopPropagation(),F.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):ho(G);const Y=Fr(R,G,!1);return Y.useDefault?R.field===V.groupingField&&!V.isGroupFooter||G.value==null?null:ho(G):Y.content}}})},[t,o,n,r,i,L,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]),oe=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}),ne=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(()=>Lr(oe,p),[oe,p]),B=a.useMemo(()=>{const $=[];return h&&$.push({field:At,sortable:!1,editable:!1}),v&&$.push({field:$t,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:L,orderedColumns:te,visibleOrderedColumns:oe,renderOrderedColumns:re,navigationColumns:B,columnIndexMap:D,columnWidths:q,effectiveColumnOrder:M,setInternalColumnOrder:I,columnReorderHandlers:ae,moveColumn:ne,resetColumnOrder:se,handleColumnResize:J}}const Ls=e=>e.id;function Fs(e){const{renderContext:t,pinnedTopRows:o,pinnedBottomRows:n,paginatedUnpinnedRows:r,sortedUnpinnedRows:i,pagination:l,getRowId:c=Ls}=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__"]),Gt=e=>!Bs.has(e);function Dr(e){return Object.keys(e).every(Gt)?e:Object.fromEntries(Object.entries(e).filter(([o])=>Gt(o)))}function Vs(e){const t={...e};return e.left&&(t.left=e.left.filter(Gt)),e.right&&(t.right=e.right.filter(Gt)),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(Gt),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=2e3,Us=178e5;function Xs(e){const{paginationRequested:t,isRowGrouping:o,autoHeight:n,viewportHeight:r,renderedRowCount:i,totalRowCount:l,pinnedRowsIgnored:c=!1,scrollHeight:d=0,listViewWithoutColumn:u=!1,listViewRowCount:g=0}=e,m=a.useRef(!1),x=a.useRef(!1),v=a.useRef(!1),h=a.useRef(!1),f=a.useRef(!1),w=a.useRef(!1);a.useEffect(()=>{process.env.NODE_ENV==="production"||w.current||g<=js||(w.current=!0,console.warn(`[OpenGridX] The list view is rendering all ${g} items: it does not virtualize. Above a few thousand items use \`pagination\`, server-side loading, or the grid view. See docs/features/list-view.md.`))},[g]),a.useEffect(()=>{process.env.NODE_ENV==="production"||f.current||!u||(f.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"||v.current||!c||(v.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"||h.current||d<=Us||(h.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"||m.current||t&&o&&(m.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"||x.current||n||r>0&&l>Ks&&i>=l&&r>=d&&(x.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 fills its container, and the container grows to fit every row. Give the container a definite height (for example \`height: 600px\` or \`100vh\`). If the container, or any ancestor up to the sized one, is a flex or grid item, add \`min-height: 0\` to it. Alternatively pass a \`height\` prop, or \`autoHeight\` if rendering every row is intended. See docs/features/virtualization.md.`))},[n,r,i,l,d])}function qs(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 Ys(e){a.useEffect(()=>{if(process.env.NODE_ENV==="production"||Ar)return;const t=e.current;!t||!qs(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 wo(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 Rs(e,t,o){return o?e.has(t)?[]:[t]:wo(e,[t],!e.has(t),!1)}function $r(e,t){return t.length===e.size&&t.every(o=>e.has(o))}function Js(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(wo(t,[m],x,n))},[i,t,n]),c=a.useCallback(m=>{i(Rs(t,m,n))},[i,t,n]),d=a.useCallback(m=>{i(wo(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 Qs(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=Js({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 Zs(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 cn(e,t,o,n){return n?Rl(e,t,o):o?[{field:t,sort:o}]:e.filter(r=>r.field!==t)}function ea(e){const{sortModel:t,onSortModelChange:o}=e,n=a.useCallback((i,l)=>{o(cn(t,i,l,!1))},[t,o]),r=a.useCallback((i,l)=>{o(cn(t,i,l,!0))},[t,o]);return{handleSort:n,handleSortAdd:r}}function ta(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 oa(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=cn(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=wo(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 na(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 tn(e,n)},[e,o])}function ra({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 ia(){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 la(e){if(typeof e!="function")return!1;const t=e.prototype;return!(typeof t=="object"&&t!==null&&"isReactComponent"in t)}function sa({render:e,toolbarProps:t}){return s.jsx(s.Fragment,{children:e(t)})}function aa({component:e,toolbarProps:t}){if(la(e))return s.jsx(sa,{render:e,toolbarProps:t},`fn:${e.toString()}`);const o=e;return s.jsx(o,{...t})}const Br=48;function da({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(()=>Wo(e,n,g,i,d,l,u,c),[e,n,g,i,d,l,u,c]),{lastLeft:v,firstRight:h}=a.useMemo(()=>Ho(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&&Xo(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:co(N,C,b,o)})]}):null},b.field)})]})}function ca({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,ua="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:ua}function fa({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 Wt=({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})]})},ga=50;function un(e,t,o,n){const r=Math.min(o??ga,t),i=Math.max(n??1/0,t);return Math.max(r,Math.min(i,e))}const pa=16;function ha(e){e.preventDefault(),e.stopPropagation()}function wa(){const e=t=>{t.stopPropagation(),t.preventDefault()};window.addEventListener("click",e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener("click",e,{capture:!0}),0)}function ma(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 un(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>=pa&&(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)&&(wa(),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,un(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:ha,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 fn(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 xa(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 ba(){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 va(){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 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:"19",x2:"12",y2:"5"}),s.jsx("polyline",{points:"5 12 12 5 19 12"})]})}function Ca(){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 _a(){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 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("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 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:"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 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:"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 Ma(){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 Na({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=ba(),I=8;let _=W.left;_+X.width+I>S&&(_=S-X.width-I),_<I&&(_=I);let L=W.bottom+4;L+X.height+I>M&&(L=W.top-X.height-4),v({position:"fixed",zIndex:1300,top:L,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(ya,{})}),"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(Ca,{})}),"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(_a,{})}),"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(ka,{})}),"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(Ea,{})}),"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(Ma,{})}),"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(Sa,{})}),"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(va,{})}),"Manage columns"]})]}),d?.closest(".ogx-theme-provider")||document.body)}function Pa(){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 Ia(){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,L=a.useId(),[A,q]=a.useState(null),K=k=>F=>{F.stopPropagation(),q({colDef:k,anchorEl:F.currentTarget})},J=a.useCallback(()=>{q(null)},[]),te=k=>F=>{if(F.altKey&&(F.key==="ArrowLeft"||F.key==="ArrowRight")&&F.target===F.currentTarget){if(k.resizable===!1||!g)return;F.preventDefault(),F.stopPropagation();const fe=ot(k,m),ge=(F.shiftKey?50:10)*(F.key==="ArrowRight"?1:-1);g(k.field,un(fe+ge,fe,k.minWidth,k.maxWidth));return}if(!(F.altKey&&F.key==="ArrowDown"||(F.ctrlKey||F.metaKey)&&F.key==="Enter")||k.disableColumnMenu||F.target!==F.currentTarget)return;F.preventDefault(),F.stopPropagation();const ce=F.currentTarget.querySelector(".ogx__menu-icon-btn")??F.currentTarget;q({colDef:k,anchorEl:ce})},oe=k=>P?.id===null&&P.field===k,Z=w?1:0,de=v?Z+1:Z,ae=r?de+1:de,ne=k=>F=>{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),(F.shiftKey||X)&&W?W(k.field,ee):d&&d(k.field,ee)},se=(k,F)=>{const Q=u.some(ce=>ce.field===k);W&&(F===null||Q||X||!d)?W(k,F):d?.(k,F)},re=k=>{const F=u.find(ee=>ee.field===k);if(!F)return null;const Q=u.length>1?u.indexOf(F)+1:null;return s.jsx("span",{className:`ogx__sort-icon ogx__sort-icon--${F.sort}`,"aria-hidden":"true",children:Q!==null&&s.jsx("span",{className:"ogx__sort-badge",children:Q})})},B=a.useMemo(()=>Wo(t,m,x,r,h,v,f,w),[t,m,x,r,h,v,f,w]),D=a.useMemo(()=>Ho(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,F)=>{const Q=xa(U,R,F);return s.jsxs("div",{className:"ogx-col-group-row",role:"row","aria-rowindex":F+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,ce)=>{const fe=ee.pinned?` ogx-col-group-cell--pinned ogx-col-group-cell--pinned-${ee.pinned}`:"",ge={width:ee.width,minWidth:ee.width,flexShrink:0,flexGrow:ee.flexGrow};return ee.pinned==="left"?(ge.position="sticky",ge.left=B[ee.fields[0]]):ee.pinned==="right"&&(ge.position="sticky",ge.right=B[ee.fields[ee.fields.length-1]],Q[ce-1]?.pinned!=="right"&&(ge.marginLeft="auto")),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${fe}${ee.headerClassName?` ${ee.headerClassName}`:""}`,style:ge,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${fe}`,style:ge,"aria-hidden":"true"},ee.key)})]},`ogx-grp-${F}`)}),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 ${oe("__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":""} ${oe("__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":""} ${oe("__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(Wt,{id:L,name:L,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,F)=>{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,fe=ce?u[ee].sort:null,ge=_?.get(k.field)??F,be=Q?ee===0?fe==="asc"?"ascending":"descending":"none":void 0,Ce=ce&&u.length>1?`Sorted ${fe==="asc"?"ascending":"descending"}, sort priority ${ee+1} of ${u.length}`:void 0,ue=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",oe(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 ke=k.renderHeader?k.renderHeader({field:k.field,colDef:k,colIndex:ge}):k.headerName||k.field,ie=Pe=>{if(Pe.target.closest(".ogx-column-resize-handle")){Pe.stopPropagation();return}O?.(k.field),Q&&ne(k)(Pe)},pe=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:!!pe,onDragStart:pe,onDragOver:we,onDragEnd:T,onDrop:Me,onKeyDown:te(k),"aria-sort":be,"aria-description":Ce,"aria-colindex":z+ge+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(Ia,{})}),s.jsxs("div",{className:"ogx__header-cell-title-wrapper",children:[s.jsx("span",{className:"ogx__header-cell-title",children:ke}),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(Pa,{})})]}),ue&&g&&s.jsx(ma,{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(Na,{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 Ta=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 La(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 Oa(e){const{rows:t,columns:o,rowHeight:n=52,headerHeight:r=56,columnVisibilityModel:i,initialState:l,syncRows:c=!1}=e,d=e.getRowId??Ta,u=a.useRef(d);a.useLayoutEffect(()=>{u.current=d});const[g]=a.useState(()=>La(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 Da(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,sn,String(w)))}},[r,g,x]),h=a.useCallback(w=>p=>{if(!(!r||i===null)){if(!po(p,sn)){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||!po(p,sn)){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),Aa=e=>`auto-group-${e}`,ei=5,ti=e=>e.slice(0,ei).map(t=>JSON.stringify(t)).join(", ")+(e.length>ei?", …":""),$a={treeNodes:new Map,rootIds:[],groupingRows:[],syntheticIds:new Set,rowLookup:new Map,issues:[]};function Ga(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=Aa(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 Wa(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 Ha(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?$a:Ga(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:uo(l,u),[g,l,u]),T=a.useMemo(()=>Wa(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,oe)=>{(W.get(oe)??X(te))&&J.add(oe)}),J},[x,h,W,X]),M=a.useCallback(J=>{const te=!S.has(J);if(O(oe=>{const Z=oe.configKey===E?oe.overrides:Qr,de=new Map(Z);return de.set(J,te),{configKey:E,overrides:de}}),te&&d){const oe=h.get(J);oe&&d(oe)}},[S,E,h,d]),I=m!=="server"&&!!(c&&c.length>0),_=a.useCallback(J=>{if(!x)return null;const te=J?.labelField,oe=J?.expandAll??!1,{visible:Z,visibleChildren:de}=T,ae=I&&c?c:[],ne=(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?Fe(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?en($,ae,ne):$;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&&(oe||S.has(U))&&B(V)}};return B(f),se},[x,T,I,c,p,h,b,u,f,S]),L=a.useCallback(J=>S.has(J),[S]),A=a.useCallback(J=>h.get(J),[h]),q=a.useCallback(J=>{const te=[];let oe=J;for(;oe!==null;){const Z=h.get(oe);if(!Z)break;te.unshift(Z.groupingKey),oe=Z.parentId}return te},[h]),K=a.useMemo(()=>{const J=new Map,{visibleChildren:te,descendantCounts:oe}=T;return h.forEach((Z,de)=>{const ae=(Z.children?.length??0)===0&&(Z.serverChildrenCount??0)>0,ne=p.has(de),se={hasChildren:(te.get(de)?.length??0)>0||ae,treeDepth:Z.depth,descendantCount:ae?void 0:oe.get(de)??0,isGroupRow:ne,isExpanded:S.has(de)};ne&&(se.groupLabel=Z.label),J.set(de,se)}),J},[h,p,T,S]);return a.useMemo(()=>({treeNodes:h,groupingRows:w,toggleExpansion:M,isGroupExpanded:L,getVisibleRows:_,getNode:A,getNodePath:q,rowMetaMap:K}),[h,w,M,L,_,A,q,K])}const oi=e=>e===null?"footer":"inline";function ni(e,t){return ro(()=>e(t),oi(t),"getAggregationPosition","getAggregationPosition threw; the default position is used")}function Ba(e,t,o){const n=`${t}: ${String(o)}`,r=e?.groupingValueFormatter;return r?ro(()=>r({field:t,value:o}),n,`groupingValueFormatter:${t}`,`groupingValueFormatter for column "${t}" threw; the group is labelled "${t}: value"`):n}const Va=[],za={},ri=new Map,He="";function Ka(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 ja=(e,t,o)=>`auto-group-${e}-${t}-${o??"root"}`,Ua=e=>`${e}${He}footer`,Xa=e=>e==="footer"?"f":e===null?"n":"i",qa=e=>e==="f"?"footer":e==="n"?null:"inline";function Ya(e){const{rows:t,getRowId:o,columns:n,rowGroupingModel:r=Va,aggregationModel:i=za,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=uo(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 fe=o(ce);return G.set(fe,ce),B.set(fe,{id:fe,parentId:j,depth:H,groupingKey:"",isExpanded:!1}),fe});const z=C[H],k=b.get(z),F=new Map;for(const ee of Y){const ce=Fe(ee,z,k),fe=Ka(ce);let ge=F.get(fe);ge||(ge={value:ce,rows:[]},F.set(fe,ge)),ge.rows.push(ee)}const Q=[];return F.forEach((ee,ce)=>{const fe=W?ee.rows.filter(Se=>W.has(Se)):ee.rows;if(fe.length===0)return;const ge=ja(z,ce,j);Q.push(ge),$.push(ge);const be=p?ao(fe,w,b,"useRowGrouping"):{},Ce={[z]:ee.value,...be,id:ge},ue={[z]:ee.value,id:ge},me=p?{...be,id:Ua(ge)}:null;R.set(ge,{inline:Ce,bare:ue,footer:me}),U.set(ge,Ce),me&&U.set(me.id,me);const ve={id:ge,parentId:j,depth:H,groupingKey:String(ee.value),groupingField:z,groupingValue:ee.value,aggregatedValues:be,isExpanded:!1,children:[],label:Ba(k,z,ee.value),descendantCount:fe.length};B.set(ge,ve),ve.children=V(ee.rows,H+1,ge)}),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:L,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]),oe=p?I.map(B=>{const D=S.get(B);return D?Xa(ni(u,{...D,isExpanded:K.has(B)})):"i"}).join(""):"",Z=a.useMemo(()=>{const B=new Map;return I.forEach((D,$)=>B.set(D,qa(oe[$]))),B},[I,oe]),de=p?ni(u,null):"footer",ae=x!=="server"&&!!(d&&d.length>0),ne=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),F=g?.byField.get(j.field);return{value:k?Fe(k,j.field,F):void 0,type:F?.type}},G=[],V=new Set,Y=H=>{const j=R.length>0?en(H,R,U):H;for(const z of j){if(V.has(z))continue;V.add(z);const k=_.get(z);if(!k){const fe=A.get(z);fe&&G.push(fe);continue}const F=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||$)&&F?.children&&(Y(F.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:L,toggleExpansion:J,isGroupExpanded:te,getVisibleRows:ne,getNode:se,rowMetaMap:re,aggregationPositions:Z,rootAggregationPosition:de}),[S,L,J,te,ne,se,re,Z,de])}const Ra=new Map;function Ja(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=Ha({rows:t,getRowId:o,getTreeDataPath:n,treeData:r,defaultGroupingExpansionDepth:g,filterModel:m,sortModel:x,columnLookup:h,filterMode:f,sortingMode:w}),b=Ya({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:Ra,[i,p.rowMetaMap,d,b.rowMetaMap]);return{treeDataHandlers:p,rowGroupingHandlers:b,activeHierarchyHandlers:y,rowMetaMap:C}}const yt=Promise.resolve();class ii extends Error{}function mo(e,t){return e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Object.is(e,t)}function Qa(e){return typeof e=="object"&&e!==null&&typeof e.then=="function"}function Za(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 mo(w.value,f.value)?w.promise:w.promise.then(()=>{const L=n.current;if(!(r.current!==h||!L||mo(L.value,w.value)))return g(h,L)});const p=()=>r.current===h&&n.current!==null;if(mo(f.value,f.originalValue))return p()&&u(null),yt;const{rows:b,getRowId:y,columns:C,processRowUpdate:N}=d.current,T=b.find(L=>y(L)===f.id);if(!T)return p()&&u(null),yt;const E=L=>{const A=d.current.onProcessRowUpdateError;A?A(L):process.env.NODE_ENV!=="production"&&L instanceof ii&&console.error(L.message)},P=L=>{if(typeof L!="object"||L===null){E(new ii(`[OpenGridX] processRowUpdate must return the updated row object (or a Promise of it); it returned ${L===null?"null":typeof L}. The edit was not saved and the editor stays open.`));return}d.current.onRowChange?.(L,f.id);const A=n.current;r.current!==h||!A||(mo(A.value,f.value)?u(null):u({...A,originalValue:f.value}))};let O,W;const X=new Promise((L,A)=>{O=L,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 L=C?.find(q=>q.field===f.field),A=ed(T,f,L,l.current);I=N?N(A,T):A}catch(L){return M(),E(L),O(),X}const _=L=>{M();try{P(L),O()}catch(A){W(A)}};return Qa(I)?Promise.resolve(I).then(_,L=>{M(),E(L),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 ed(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 td=e=>e.id,od={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 nd(e){return e.map(t=>t.field).join(li)}function rd(e){const{pinnedTopRows:t,centerRows:o,pinnedBottomRows:n,columns:r,leftPinnedColumns:i,unpinnedColumns:l,rightPinnedColumns:c,expandedRowIds:d,rowMetaMap:u,getRowId:g=td}=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(nd).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 gn(t,0,!1,y),gn(o,t.length,!0,y),gn(n,t.length+o.length,!1,y),p},[v,f,t,o,n,d,u,g]);return a.useMemo(()=>{if(!w)return od;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 gn(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),L=id(X,_,I.colDef,t+S,M,l,d);let A=1;if(I.hasColSpan){const K=Math.min(di(I.colDef.colSpan,L,"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,L,"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 id(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 ld(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 sd(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 ad(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||fn(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 dd=300,ui=e=>e.id;function cd(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 ud(e){const{dataSource:t,sortModel:o,filterModel:n,paginationModel:r,paginationMode:i,sortingMode:l,filterMode:c,aggregationModel:d,rowGroupingActive:u=!1}=e,g=cd(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},[]),L=a.useCallback(async()=>{const{params:J,kind:te}=b.current,oe=J.dataSource;if(!oe)return!1;const Z=T.current,de=J.paginationModel.pageSize;let ae,ne;if(te==="infinite"){if(Z.inFlightEnd!==null)return!1;if(ae=Z.loadedEnd,ne=(Z.page+1)*de,ne<=ae)return P.current=!1,S(),!1;Z.inFlightEnd=ne}else te==="page"?(ae=J.paginationModel.page*de,ne=ae+de):(ae=0,ne=zr);const se=++y.current;P.current=!0,S(),J.setDataSourceError(null);let re;try{re=await oe.getRows({startRow:ae,endRow:ne,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>=ne-ae&&(Z.page+1)*de>ne))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 L(););},[L]);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 oe=g==="infinite"&&J!==null&&w!==0;if(te.page=oe?0:w,te.loadedEnd=0,oe){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 oe=te.inFlightEnd!==null;if(oe||(te.page+1)*p<=te.loadedEnd){P.current=oe,S();return}}return P.current=!0,S(),E.current=setTimeout(()=>{E.current=null,A()},dd),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,oe)=>{const{params:Z}=b.current,de=Z.dataSource;if(!de)return;const ae=JSON.stringify(te),ne=X.current;if(ne.has(ae))return;const se=C.current;ne.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;ne.delete(ae),console.error("Failed to fetch children:",re),oe?.(re)}finally{se===C.current&&(O.current--,S())}},[S]);return{fetchRows:q,fetchChildren:K}}function fd(e){return(e.serverChildrenCount??0)>0&&(e.children?.length??0)===0}function gd({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)=>{!fd(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 pd(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:ao(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 hd={items:[]},wd=[];function md(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(()=>tn(o),[o]),x=a.useMemo(()=>ns(i,g),[i,g]),v=a.useMemo(()=>u?Jo(t,x.source,m):t,[u,t,x.source,m]),h=a.useMemo(()=>u?vr(v,o,r,{outputFilterModel:x.output,sortModel:l}):nn,[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?hd:i,pipelineSortModel:f?wd:l}}const Ht=({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 pn(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=go(n),x=ln(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(Ht,{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(Ht,{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(Ht,{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(Ht,{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 xd({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=Fe(e,p,i),y=Bo(e,p,b,i)??Vo(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(dn,{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 bd(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 vd=e=>e.id;function yd({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=vd,multiselectable:S=!1,loading:M=!1,loadingOverlay:I,noRowsOverlay:_,showPaginationControls:L=!0,selectable:A=!1,onToggleExpansion:q}){const K=y||pn,J=a.useRef(null),[te,oe]=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&&(oe(X(H)),J.current?.querySelector(`:scope > [role="row"][data-rowindex="${Y}"]`)?.focus())},ne=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),F=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,F));return;case"ArrowUp":Y.preventDefault(),ae(Math.max(j-1,0));return;case"Home":Y.preventDefault(),ae(0);return;case"End":Y.preventDefault(),ae(F);return;case"PageDown":Y.preventDefault(),ae(Math.min(j+10,F));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=go(c.pageSize),$=ln(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=bd(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",tabIndex:-1,onScroll:V,onKeyDown:ne,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(xd,{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=>oe(X(t[z]))},j)})}),l&&L&&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 Cd({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 Bt(e){return e.headerName||e.field}function _d(e){return e.nativeEvent.isComposing||e.keyCode===229}function Vt(e,t,o=!0){return n=>{if(_d(n)){n.stopPropagation();return}o&&n.key==="Enter"&&(n.stopPropagation(),e()),n.key==="Escape"&&(n.stopPropagation(),t())}}function Sd({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":Bt(t),value:i,onChange:d=>{l(d.target.value),o(d.target.value)},onBlur:n,onKeyDown:Vt(n,r)})}function kd({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":Bt(t),value:i,onChange:d=>{const u=d.target.value===""?"":Number(d.target.value);l(u),o(u===""?null:u)},onBlur:n,onKeyDown:Vt(n,r)})}function Ed({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":Bt(t),checked:!!e,onChange:l,onBlur:n,onKeyDown:Vt(n,r,!1)})})}const hn=e=>typeof e=="object"?e.value:e,Md=e=>typeof e=="object"?e.label:String(e);function Nd(e,t){return e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():Object.is(e,t)}function Pd({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(hn(g)));let d=l.findIndex(g=>Nd(hn(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":Bt(t),value:u?"":c[d],onChange:g=>{const m=c.indexOf(g.target.value);o(m===-1?null:hn(l[m]))},onBlur:n,onKeyDown:Vt(n,r),children:[u&&s.jsx("option",{value:""}),l.map((g,m)=>s.jsx("option",{value:c[m],children:Md(g)},m))]})}const wi=e=>String(e).padStart(2,"0"),mi=/^(\d{4}-\d{2}-\d{2})/;function wn(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===""?"":wn(new Date(e))}return typeof e=="number"?wn(new Date(e)):""}function Id(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 Td({value:e,colDef:t,onValueChange:o,onCommit:n,onCancel:r}){const[i]=a.useState(e),[l,c]=a.useState(()=>wn(e)),d=a.useRef(null);return a.useEffect(()=>{d.current?.focus()},[]),s.jsx("input",{ref:d,type:"date",className:"ogx__edit-input","aria-label":Bt(t),value:l,onChange:u=>{c(u.target.value),o(Id(u.target.value,i))},onBlur:n,onKeyDown:Vt(n,r)})}function Ld(e){const{colDef:t}=e;switch(t.type){case"number":return s.jsx("div",{className:"ogx__edit-cell",children:s.jsx(kd,{...e})});case"boolean":return s.jsx("div",{className:"ogx__edit-cell",children:s.jsx(Ed,{...e})});case"singleSelect":return s.jsx("div",{className:"ogx__edit-cell",children:s.jsx(Pd,{...e})});case"date":return s.jsx("div",{className:"ogx__edit-cell",children:s.jsx(Td,{...e})});default:return s.jsx("div",{className:"ogx__edit-cell",children:s.jsx(Sd,{...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:Vo(r,l)}},[r,i,l,M]),L=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]),oe=a.useRef(!1);if(a.useEffect(()=>{if(!(!y||!N))return oe.current=!0,()=>{oe.current=!1,queueMicrotask(()=>{oe.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,ne={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:ne,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",L].filter(Boolean).join(" "),R=P||1,U={...ne,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(Ld,{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),Od=({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 Dd(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 mn=12;function Ad(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 xo(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=zo,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:L,isCellEditable:A,focusedCellField:q,isFocusVisible:K,colspanMap:J,rowSpanningCaches:te,rowHeight:oe=52,rowMeta:Z,columnIndexMap:de,ariaRowIndex:ae}=e,ne=o??t.id,se=a.useId(),re=a.useId(),B=a.useMemo(()=>Wo(n,m,x,l,C,h,N,T),[n,m,x,l,C,h,N,T]),D=a.useMemo(()=>Ho(n,x),[n,x]),$=Z?.hasChildren===!0,R=Z?.isGroupRow===!0,U=h&&!R,G=!R&&!qe(ne),V=a.useCallback((le,ye)=>{I?.({id:ne,field:le,value:ye})},[ne,I]),Y=a.useCallback((le,ye)=>{L?.({id:ne,field:le,value:ye})},[L,ne]),H=a.useCallback((le,ye)=>{_?.({cancel:le,id:ne,field:ye})},[_,ne]);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:oe,minHeight:oe},children:Array.from({length:le}).map((ye,Le)=>s.jsx("div",{className:"ogx__skeleton-cell",children:s.jsx("div",{className:"ogx__skeleton-bar"})},Le))})}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:ne,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:ne,rowIndex:r})},k=le=>{le.stopPropagation(),g?.(ne,le.target.checked)},F=le=>{le.stopPropagation(),w?.(ne)},Q=T?1:0,ee=h?Q+1:Q,ce=l?ee+1:ee,fe=ce,ge=de?.size??n.filter(le=>!le.isSpacer).length,be=Z!==void 0,Ce=Z?.hasChildren===!0,ue=zn(ne,v),me=ue==="top",ve=ue==="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(ne):void 0,onDrop:W?W(ne):void 0,style:{maxHeight:`${oe}px`,minHeight:`${oe}px`,"--height":`${oe}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:mn},draggable:!!E,onDragStart:E?E(ne):void 0,onDragEnd:O,onClick:le=>le.stopPropagation(),children:E&&s.jsx(Od,{})}),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?mn: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(dn,{isExpanded:f,onClick:F,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?mn: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(Wt,{id:se,name:`ogx-select-row-${ne}`,checked:i,onChange:k,onClick:le=>le.stopPropagation(),"aria-label":i?`Deselect row ${ne}`:`Select row ${ne}`,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 Le,xe;R?Le=t[le.field]:{value:Le,error:xe}=Un(t,le.field,le);const ke=de?.get(le.field)??ye,ie=m[le.field]??le.width,pe=Xe(le.field,x),we=!!I&&Jn({row:t,field:le.field,value:Le,colDef:le,rowIndex:r,colIndex:ke,rowMeta:Z},A),Me=M?.id===ne&&M?.field===le.field,Pe=Me?M?.value:Le,De=J?.get(ne)?.[le.field],Qe=De&&!De.spannedByColSpan&&De.cellProps.colSpan>1?Ad(n,ke,De.cellProps.colSpan,m):De,Yt=Qe&&!Qe.spannedByColSpan?n[ke+Qe.cellProps.colSpan-1]?.field??le.field:le.field,So=pe==="right"?Yt:le.field,$e=pe?B[So]:void 0,ko=pe==="left"&&Yt===D.lastLeft||pe==="right"&&le.field===D.firstRight,Be=te?.spannedCells[ne]?.[le.field],Eo=te?.hiddenCells[ne]?.[le.field]||!1;return s.jsx(xi,{value:Pe,row:t,colDef:le,rowIndex:r,colIndex:ke,ariaColIndex:fe+ke+1,isSelected:i,onCellClick:u,width:ie,pinnedPosition:pe,pinnedOffset:$e,isPinnedEdge:ko,isFocused:q===le.field,isFocusVisible:K,isEditable:we,isEditing:Me,onCellEditStart:V,onEditStop:H,onCellValueChange:Y,colSpanInfo:Qe,rowSpan:Be,isHiddenByRowSpan:Eo,rowMeta:Z,valueError:xe},le.field)})]}),U&&s.jsx(Dd,{id:re,colSpan:fe+ge,row:t,rowId:ne,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 $d=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=$d,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((L,A)=>{const q=O(L),K=W+A;return s.jsx(xo,{row:L,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:L,id:q,rowIndex:K}}):null,detailPanelHeight:v.has(q)?Ko(jo(f,{row:L,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 Gd=({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 Wd({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:L,sortedUnpinnedRowCount:A,infiniteScrollSkeletonCount:q,unpinnedRowsLength:K,lastRenderedRowIndex:J,rowMetaMap:te,loadingOverlay:oe,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}))})(),ne=n.filter(re=>!re.pinned),se=_==="infinite"&&L&&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&&oe?s.jsx("div",{className:"ogx__loading-overlay",style:{width:l||void 0},children:oe}):o&&n.length===0?Array.from({length:10}).map((re,B)=>s.jsx(Gd,{columns:ae,rowHeight:g,checkboxSelection:c,hasDetailPanel:d,rowReordering:u},`skeleton-${B}`)):ne.map(({row:re,id:B,rowIndex:D})=>s.jsx(xo,{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)?Ko(jo(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(xo,{row:{id:`__skeleton_${B}__`,_isSkeleton:!0},columns:i,rowIndex:K+B,rowHeight:g},`__skeleton_${B}__`))})]})})}function Hd(){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 Bd(){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 xn(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(Hd,{}),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(Bd,{})}),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(Wt,{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(Wt,{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 Vd({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)=>{fn(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(xn,{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 zd(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 Kd(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 jd(e){return e.id}function Ud(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 Xd(e,t){a.useLayoutEffect(()=>{e&&(e.current=t.current)},[e,t])}function qd(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 Yd(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 Rd(e,t){return e===t?!0:e.length!==t.length?!1:e.every((o,n)=>Yd(o,t[n]))}function Jd(e){const[t,o]=a.useState(e),n=Rd(t,e);return n||o(e),n?t:e}function Qd(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:ao(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 Zd(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?Qd({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 ec=new Set(["__group__","__check__","__actions__"]);function st(e){return e.filter(t=>t.exportable!==!1&&!t.isSpacer&&!rt(t.field)&&!ec.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 zt(e,t,o){return Re(t)?Ci(e,t,o):e}function Kt(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 ao(e,r,i,"export")}function jt(e,t){const o=e[t.field];return t.valueGetter?t.valueGetter({row:e,field:t.field,value:o}):o}function bo(e,t,o){if(!t.valueFormatter)return Vo(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 bn(e,t,o,n){return o==null?"":co(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 tc=/^[=+\-@\t\r]/,oc=/^[-+]?[\d.,\s]*\d[\d.,\s]*%?$/;function vo(e,t=!1){return t||!tc.test(e)||oc.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 nc=/[\\/?*:[\]]/g,Si=31;function vn(e,t=new Set){let o=String(e??"").replace(nc,"-").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 rc=new Set([Ye,$t,At]),ic=/[\t\n\r"]/;function ki(e){return ic.test(e)?`"${e.replace(/"/g,'""')}"`:e}function lc(e){return st(e).filter(t=>!rc.has(t.field))}function sc(e,t){const o=t.map(r=>ki(r.headerName||r.field)).join(" "),n=e.map(r=>t.map(i=>ki(bo(r,i,Fe(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 ac(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 dc(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 cc(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=sc(u,lc(i()));await ac(g)},[]),n=!!e.disableKeyboardShortcut;return a.useEffect(()=>{if(n)return;const r=i=>{if(i.defaultPrevented||!dc(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 uc(e){const{apiRef:t,columns:o,getRowId:n,containerRef:r,disableKeyboardShortcut:i}=e,l=a.useCallback(()=>r.current,[r]),{copySelectedRows:c}=cc({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 fc(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 gc(e){return a.useCallback(t=>{e.current?.classList.toggle("ogx--kb",t)},[e])}function pc(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 hc({paginationSlot:e,paginationSlotProps:t,page:o,paginationModel:n,rowCount:r,pageSizeOptions:i,onPaginationModelChange:l,localeText:c}){const d=e||pn;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 wc({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 mc(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 xc(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(()=>mc({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 bc(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)=>{fn(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 vc(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:L=!0,pinExpandColumn:A=!0,disableColumnReorder:q=!1,columnOrder:K,onColumnOrderChange:J,onColumnOrderModelChange:te,height:oe,rowReordering:Z=!1,onRowOrderChange:de,loading:ae=!1,treeData:ne=!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:F="client",rowCount:Q,slots:ee,slotProps:ce,pivotMode:fe=!1,pivotModel:ge,onPivotModelChange:be,className:Ce="",style:ue,onRowsScrollEnd:me,ariaLabel:ve,initialState:Se,onStateChange:le,columnVisibilityModel:ye,onColumnVisibilityModelChange:Le,listView:xe=!1,listViewColumn:ke,columnGroupingModel:ie,noRowsLabel:pe="No Data",localeText:we,apiRef:Me,overscanRowCount:Pe=3}=e,De=Jd(o),Qe=we?.noRowsLabel??pe,Yt=D||yi,So=ws({initialState:Se,sortModel:y,onSortModelChange:C,filterModel:p,onFilterModelChange:b,aggregationModel:$,onAggregationModelChange:R,columnVisibilityModel:ye,onColumnVisibilityModelChange:Le,pinnedColumns:O,onPinnedColumnsChange:W,pivotModel:ge,onPivotModelChange:be,paginationModel:T,onPaginationModelChange:E,pageSizeOptions:P,rowSelectionModel:x,onRowSelectionModelChange:v,density:c}),{sortModel:$e,handleSortModelChange:ko,filterModel:Be,handleFilterModelChange:Eo,aggregationModel:Ge,handleAggregationModelChange:Ou,columnVisibilityModel:at,handleColumnVisibilityModelChange:_n,pinnedColumns:Sn,handlePinnedColumnsChange:Du,currentPivotModel:Zi,handlePivotModelChange:Au,effectivePaginationModel:Ae,handlePaginationModelChange:Nt,selectedRowIds:$u,handleRowSelectionModelChange:kn,density:el}=So,Rt=md({rows:t,columns:De,pivotMode:fe,pivotModel:Zi,filterModel:Be,sortModel:$e,hasDataSource:!!H,hierarchyRequested:ne||Yt.length>0}),dt=Rt.isActive,{rowReordering:ct,hierarchyRowGroupingModel:Gu,isTreeDataRequested:Wu,isTreeData:Mo,isRowGrouping:Pt,isHierarchyEnabled:No,hasGroupingColumn:Hu,pagination:Ve,listView:Jt}=zd({rowGroupingModel:Yt,treeData:ne,hasTreeDataPath:!!se,isPivotActive:dt,rowReordering:Z,hasGroupingColDef:!!B,pagination:N,paginationMode:F,listView:xe,hasListViewColumn:!!ke}),{rowHeight:Ze,headerHeight:tl}=ys({rowHeight:r,headerHeight:i,density:el}),Bu=Rt.rows,Vu=Rt.columns,{activeColumns:ut,effectivePinnedColumns:It}=Kd({baseColumns:Vu,pinnedColumns:Sn,hasGroupingColumn:Hu,groupingColDef:B,isTreeData:Mo,getTreeDataPath:se}),En=na(ut,at),[zu,Ku]=pd(Ge),Qt=a.useRef(null),Mn=a.useRef(null),ol=!dt&&n||jd,Nn=gc(Qt),Pn=Oa({rows:Bu,getRowId:ol,columns:ut,rowHeight:Ze,headerHeight:tl,columnVisibilityModel:at,initialState:e.initialState,syncRows:!H}),{state:Ee,apiRef:Zt,setRows:ju,replaceRow:Uu,setColumns:Xu,setDimensions:qu,setDataSourceLoading:Yu,setDataSourceError:Ru,setRowCount:Ju}=Pn,{getRowIdOf:Ne,getRowIdOfInEvents:Qu}=Ud(Ee.rows.idByRow);Xd(Me,Zt);const Zu=Ee.dataSource.loading,et=ae||Zu,Po=a.useMemo(()=>Ee.rows.allRows.map(pt=>Ee.rows.idRowsLookup.get(pt)),[Ee.rows]),{treeDataHandlers:Io,rowGroupingHandlers:In,activeHierarchyHandlers:Tt,rowMetaMap:ze}=Ja({rows:Po,getRowId:Ne,getTreeDataPath:se,isTreeDataRequested:Wu,isTreeData:Mo,columns:ut,rowGroupingModel:Gu,isRowGrouping:Pt,aggregationModel:Ge,defaultGroupingExpansionDepth:re,filterModel:Be,sortModel:$e,getAggregationPosition:U,columnLookup:En,filterMode:k,sortingMode:z}),nl=Za({rows:Po,getRowId:Ne,columns:ut,processRowUpdate:V,onProcessRowUpdateError:Y,onRowChange:(pt,Pf)=>{Uu(Pf,pt)}}),eo=Zs({selectedRowIds:$u,rowsLookup:Ee.rows.idRowsLookup,rowMetaMap:ze,enabled:!H&&!dt&&F==="client"&&k==="client",onSelectionModelChange:kn}),rl=ud({dataSource:H,sortModel:$e,filterModel:Be,paginationModel:Ae,paginationMode:F,sortingMode:z,filterMode:k,aggregationModel:Ge,rowGroupingActive:Pt,getRowId:ol,setRows:ju,setRowCount:Ju,setDataSourceLoading:Yu,setDataSourceError:Ru,onAggregationResults:Ku,onPaginationModelChange:Nt});gd({enabled:Mo&&!!H,treeNodes:Io.treeNodes,isGroupExpanded:Io.isGroupExpanded,getNodePath:Io.getNodePath,toggleExpansion:Io.toggleExpansion,fetchChildren:rl.fetchChildren});const{hasDetailPanel:ft,expandedRowIds:Tn,handleDetailPanelToggle:il,detailPanelHeights:ef,reportDetailPanelHeight:tf}=Hs({hasDetailPanel:!!S,controlledExpandedRowIds:I,onDetailPanelExpandedRowIdsChange:_,rowMetaMap:ze}),{effectiveColumns:ll,hierarchyField:Ln,orderedColumns:sl,visibleOrderedColumns:al,renderOrderedColumns:of,navigationColumns:dl,columnIndexMap:cl,columnWidths:to,effectiveColumnOrder:nf,columnReorderHandlers:rf,moveColumn:ul,resetColumnOrder:fl,handleColumnResize:lf}=Ts({activeColumns:ut,isHierarchyEnabled:No,isRowGrouping:Pt,isTreeData:Mo,activeHierarchyHandlers:Tt,columnVisibilityModel:at,columnOrder:K,onColumnOrderChange:J,onColumnOrderModelChange:te,disableColumnReorder:q,pivotMode:dt,checkboxSelection:d,hasDetailPanel:ft,rowReordering:ct,initialState:Se,setColumns:Xu,pinnedColumns:It,getRowId:Qu,aggregationModel:Ge,groupingRows:Pt?In.groupingRows:void 0});zs({onStateChange:le,sortModel:$e,filterModel:Be,effectivePaginationModel:Ae,columnWidths:to,effectiveColumnOrder:nf,columnVisibilityModel:at,pinnedColumns:Sn,density:el});const To=_s({effectiveRows:Po,activeHierarchyHandlers:Tt,filterMode:k,filterModel:Rt.pipelineFilterModel,sortModel:Rt.pipelineSortModel,sortingMode:z,pagination:Ve,paginationMode:F,effectivePaginationModel:Ae,pinnedRows:X,getRowId:Ne,columnLookup:En,hierarchyField:Ln}),{filteredRows:gl,dataRows:Lt,pinnedTopRows:We,pinnedBottomRows:Ke,sortedUnpinnedRows:Ue,paginatedUnpinnedRows:Lo,allRenderableRows:Fo}=To,Fn=Ve?Lo:Ue;ra({paginationModel:Ae,currentPage:To.currentPage,enabled:Ve&&!et&&Ue.length>0,onPaginationModelChange:Nt});const Oo=Cs({paginationMode:F,hasDataSource:!!H,dataSourceRowCount:Ee.pagination.rowCount,rowCountProp:Q,clientRowCount:Ue.length}),{rowSelection:On,handleRowClick:Dn,handleSelectionChange:An}=Qs({dataRows:Lt,getRowId:Ne,isPivotActive:dt,selectedRowIds:eo,onSelectionModelChange:kn,disableMultipleRowSelection:g,disableRowSelectionOnClick:u,isHierarchyEnabled:No,rowMetaMap:ze,activeHierarchyHandlers:Tt,onRowClick:h});oa({apiRef:Pn.apiRef,sortModel:$e,multiSort:j,onSortModelChange:ko,filterModel:Be,onFilterModelChange:Eo,paginationModel:Ae,onPaginationModelChange:Nt,selectedRowIds:eo,getPendingRowSelectionModel:So.getPendingRowSelectionModel,onRowSelectionModelChange:kn,disableMultipleRowSelection:g,isSyntheticRowId:pt=>qe(pt,ze),getVisibleRows:()=>[...We,...Fn,...Ke],getAllFilteredRows:()=>qd({hierarchyHandlers:Tt,pinnedTopRows:We,sortedUnpinnedRows:Ue,pinnedBottomRows:Ke,rowMetaMap:ze,getRowId:Ne,hierarchyField:Ln,dataRows:Lt}),visibleColumns:of});const sf=Da({rows:Po,getRowId:Ne,onRowOrderChange:de,rowReordering:ct}),{aggregationResult:$n,isLoading:af}=hi({rows:Lt,columns:ut,aggregationModel:dt?Al:Ge,isServerSide:Vr({dataSource:H,paginationMode:F,sortingMode:z,filterMode:k}),dataSource:H,filterModel:Be,sortModel:$e,serverAggregationResults:zu}),Gn=Object.keys(Ge).length>0&&!dt;Zd({apiRef:Zt,hasAggregation:Gn,aggregationResult:$n,aggregationModel:Ge,isRowGrouping:Pt,rowGroupingHandlers:In,rowMetaMap:ze,columns:ut,getRowId:Ne,hierarchyField:Ln});const Ie=Fl({rowHeight:Ze,pagination:Ve,paginatedUnpinnedRows:Lo,sortedUnpinnedRows:Ue,expandedRowIds:Tn,getDetailPanelHeight:M,detailPanelHeights:ef,pinnedTopRowsLength:We.length,pinnedBottomRowsLength:Ke.length,pinnedTopRows:We,pinnedBottomRows:Ke,visibleOrderedColumns:al,pinnedColumns:It,columnWidths:to,viewportWidth:Ee.dimensions.viewportWidth||1e3,checkboxSelection:d,hasDetailPanel:ft,rowReordering:ct,pinCheckboxColumn:L,pinExpandColumn:A,paginationMode:F,isLoading:Ee.dataSource.loading,pageSize:Ae.pageSize,getRowId:Ne}),oo=rd({pinnedTopRows:We,centerRows:Fn,pinnedBottomRows:Ke,columns:al,leftPinnedColumns:Ie.leftPinnedCols,unpinnedColumns:Ie.unpinnedColsWithWidth,rightPinnedColumns:Ie.rightPinnedCols,expandedRowIds:ft?Tn:void 0,rowMetaMap:ze,getRowId:Ne}),pl=a.useMemo(()=>[...Ie.leftPinnedCols,...Ie.unpinnedColsWithWidth,...Ie.rightPinnedCols],[Ie.leftPinnedCols,Ie.unpinnedColsWithWidth,Ie.rightPinnedCols]);uc({apiRef:Zt,columns:pl,getRowId:Ne,containerRef:Qt,disableKeyboardShortcut:m}),fc({apiRef:Zt,viewportRef:Mn,layout:Ie,rowHeight:Ze});const{scrollTop:df,scrollLeft:cf,overscanRows:uf,handleScroll:ff,setViewportElement:gf}=Gs({onRowsScrollEnd:me,overscanRowCount:Pe,rowCount:Ie.unpinnedRowsLength,autoHeight:l,setDimensions:qu,viewportRef:Mn}),Te=Ss({layout:Ie,scrollTop:df,scrollLeft:cf,viewportWidth:Ee.dimensions.viewportWidth,viewportHeight:Ee.dimensions.viewportHeight,autoHeight:l,rowReordering:ct,hasDetailPanel:ft,checkboxSelection:d,pinCheckboxColumn:L,pinExpandColumn:A,overscanRows:uf}),{handleSort:hl,handleSortAdd:wl}=ea({sortModel:$e,onSortModelChange:ko}),Do=d||!u,{focusedCell:ml,setFocusedCell:pf,viewportTabIndex:hf,ensureGridFocus:wf,handleFocus:mf,handleBlur:xf,handleKeyDown:bf,handleMouseDownCapture:vf}=gs({allRenderableRows:Fo,navigationColumns:dl,checkboxSelection:d,selectedRowIds:eo,handleSelectionChange:An,handleDetailPanelToggle:il,editingHandlers:nl,setKeyboardMode:Nn,sortModel:$e,handleSort:hl,handleSortAdd:wl,multiSort:j,isCellEditable:G,pagination:Ve,pageSize:Ae.pageSize,virtualization:Te,viewportRef:Mn,pinnedTopRowCount:We.length,getRowId:Ne,rowMetaMap:ze,getSpanOrigin:oo.getSpanOrigin,onRowActivate:Dn,toggleRowExpansion:Tt?.toggleExpansion,handleSelectAll:On.selectAll,rowSelectionEnabled:Do,multipleRowSelectionEnabled:!g,pinCheckboxColumn:L,pinExpandColumn:A,rowHeight:Ze}),{handleCellClick:yf,handleHeaderClick:Cf}=pc({ensureGridFocus:wf,setKeyboardMode:Nn,setFocusedCell:pf,getRowId:Ne,onCellClick:w}),{handleHideColumn:_f,handlePinColumn:Sf}=ta({columnVisibilityModel:at,onColumnVisibilityModelChange:_n,pinnedColumns:Sn,onPinnedColumnsChange:Du}),no=xc({columnGroupingModel:ie,pinnedTopCount:We.length,pinnedBottomCount:Ke.length,pagination:Ve,paginationMode:F,paginationModel:Ae,paginationRowCount:Oo,paginatedUnpinnedRowCount:Lo.length,sortedUnpinnedRowCount:Ue.length}),Wn=ld({spanning:oo,renderContext:Te.renderContext,offsetTop:Te.offsetTop,cumulativeHeights:Ie.cumulativeHeights}),Hn=Fs({renderContext:Wn.renderContext,pinnedTopRows:We,pinnedBottomRows:Ke,paginatedUnpinnedRows:Lo,sortedUnpinnedRows:Ue,pagination:Ve,getRowId:Ne}),Ao=sd({spanning:oo,firstColumnIndex:Te.renderContext.firstColumnIndex,lastColumnIndex:Te.renderContext.lastColumnIndex,virtualColumns:Te.virtualColumns,layout:Ie,rows:Hn});Xs({paginationRequested:N,isRowGrouping:Pt,autoHeight:l,viewportHeight:Ee.dimensions.viewportHeight,renderedRowCount:Hn.length,totalRowCount:We.length+Fn.length+Ke.length,pinnedRowsIgnored:No&&!!(X?.top?.length||X?.bottom?.length),scrollHeight:Te.totalHeight,listViewWithoutColumn:xe&&!ke,listViewRowCount:Jt&&ke?Fo.length:0});const{allSelected:kf,someSelected:Ef}=On,Ft=ad(ie,rf),Mf=a.useMemo(()=>ll.some(pt=>!!pt.rowSpan),[ll]),gt=ia();Ys(Qt);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,$o=ee?.footer,Nf=et&&Fo.length>0&&F!=="infinite",yl=ee?.toolbar,Cl=bc({toolbar:ee?.toolbar,toolbarSlotProps:ce?.toolbar,apiRef:Zt,orderedColumns:sl,baseColumns:De,aggregationModel:Ge,onAggregationModelChange:Ou,pivotMode:fe,pivotModelProp:ge,onPivotModelChangeProp:be,pivotModel:Zi,onPivotModelChange:Au,filterModel:Be,onFilterModelChange:Eo,columnVisibilityModel:at,onColumnVisibilityModelChange:_n,disableColumnReorder:q,columnGroupingModel:ie,moveColumn:ul,resetColumnOrder:fl,forceColumnsOpen:gt.toolbarPanelRequested,onColumnsPanelClose:gt.closeToolbarPanel}),Vn={rowReordering:ct,columnIndexMap:cl,editingHandlers:nl,isCellEditable:G,selectedRowIds:eo,checkboxSelection:d,onRowClick:Dn,onRowDoubleClick:f,onCellClick:yf,onSelectionChange:An,columnWidths:to,pinnedColumns:It,hasDetailPanel:ft,expandedRowIds:Tn,getDetailPanelContent:S,getDetailPanelHeight:M,onDetailPanelToggle:il,onDetailPanelHeightChange:tf,pinCheckboxColumn:L,pinExpandColumn:A,focusedCell:ml,colspanMap:oo.colspanMap,rowSpanningCaches:oo.rowSpanningCaches,rowHeight:Ze,rowMetaMap:ze};return s.jsxs("div",{ref:Qt,className:["ogx",Ce,l&&"ogx--auto-height",!l&&oe===void 0&&ue?.height===void 0&&"ogx--fill",Mf&&"ogx--row-spanning",Jt&&"ogx--list-view"].filter(Boolean).join(" "),style:{...ue,height:oe??ue?.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(aa,{component:yl,toolbarProps:Cl})}),s.jsx(Vd,{isOpen:gt.standalonePanelOpen,containerRef:Qt,panelRef:gt.standalonePanelRef,columns:sl,columnVisibilityModel:at,disableColumnReorder:q,onClose:gt.closeStandalonePanel,onColumnVisibilityChange:_n,onColumnMove:ul,onColumnOrderReset:fl,columnGroupingModel:ie}),Jt&&ke&&s.jsx(yd,{ariaLabel:ve,allRenderableRows:Fo,dataRowCount:Lt.length,pinnedTopRowCount:We.length,pinnedBottomRowCount:Ke.length,unpinnedRowCount:Ue.length,pagination:Ve,effectivePaginationModel:Ae,currentPage:To.currentPage,pageSizeOptions:P,selectedRowIds:eo,listViewColumn:ke,columnsByField:En.byField,rowMetaMap:ze,noRowsLabel:Qe,rowHeight:Ze,checkboxSelection:d,paginationMode:F,serverRowCount:Oo,paginationSlot:ee?.pagination,paginationSlotProps:ce?.pagination,localeText:Nr(we),onRowClick:Dn,onRowDoubleClick:f,onSelectionChange:An,onPaginationModelChange:Nt,onRowsScrollEnd:me,getRowId:Ne,multiselectable:Do&&!g,selectable:Do,onToggleExpansion:Tt?.toggleExpansion,loading:et,loadingOverlay:Bn,noRowsOverlay:vl,showPaginationControls:!$o}),!Jt&&s.jsx("div",{ref:gf,className:"ogx__viewport",onScroll:ff,role:"grid","aria-label":ve||"Data grid","aria-rowcount":no.rowCount,"aria-colcount":dl.length,"aria-multiselectable":Do&&!g,"aria-busy":et,tabIndex:hf,onKeyDownCapture:()=>{Nn(!0)},onMouseDownCapture:vf,onKeyDown:bf,onFocus:mf,onBlur:xf,children:s.jsxs("div",{className:"ogx__content",style:{width:It?.right?.length?`max(100%, ${Te.totalWidth}px)`:Te.totalWidth},role:"presentation",children:[s.jsxs("div",{className:"ogx__sticky-top",role:"presentation",children:[s.jsx(qr,{columns:Ao,allColumns:pl,columnGroupingModel:ie,checkboxSelection:d,allSelected:kf,someSelected:Ef,onSelectAll:On.selectAll,sortModel:$e,onSort:hl,onSortAdd:wl,multiSort:j,onColumnResize:lf,columnWidths:to,pinnedColumns:It,focusedCell:ml,columnIndexMap:cl,onHeaderClick:Cf,onDragStart:Ft.onDragStart,onDragOver:Ft.onDragOver,onDragEnd:Ft.onDragEnd,onDrop:Ft.onDrop,draggedColumn:Ft.draggedColumn,dragOverColumn:Ft.dragOverColumn,rowReordering:ct,hasDetailPanel:ft,pinCheckboxColumn:L,pinExpandColumn:A,aggregationModel:Ge,onHideColumn:_f,onManageColumns:gt.openColumnsPanel,onPinColumn:Sf}),s.jsx(vi,{...Vn,rows:We,position:"top",ariaRowIndexBase:no.topBase,columns:Ao,pinnedRows:X,getRowId:Ne})]}),!et&&!Ee.dataSource.error&&gl.length===0&&s.jsx(ca,{noRowsLabel:Qe,width:Te.totalWidth,overlay:vl}),s.jsx(Wd,{...Vn,virtualContainerHeight:Te.totalHeight-Te.pinnedTopHeight-Te.pinnedBottomHeight,offsetTop:Wn.offsetTop,effectiveLoading:et,visibleRows:Hn,baseColumns:De,virtualColumns:Ao,viewportWidth:Ee.dimensions.viewportWidth,rowReorderHandlers:sf,paginationMode:F,dataSourceLoading:Ee.dataSource.loading,sortedUnpinnedRowCount:Ue.length,infiniteScrollSkeletonCount:Math.min(Ae.pageSize,20),unpinnedRowsLength:Ie.unpinnedRowsLength,lastRenderedRowIndex:Wn.renderContext.lastRowIndex,ariaRowIndexOffset:no.centerOffset,loadingOverlay:Bn}),s.jsxs("div",{className:"ogx__sticky-bottom",role:"presentation",children:[s.jsx(vi,{...Vn,rows:Ke,position:"bottom",rowIndexOffset:no.bottomRowIndexOffset,ariaRowIndexBase:no.bottomBase,columns:Ao,pinnedRows:X,getRowId:Ne}),Gn&&In.rootAggregationPosition!==null&&s.jsx(da,{columns:Te.virtualColumns,aggregationModel:Ge,aggregationResult:$n,columnWidths:to,rowHeight:Ze,checkboxSelection:d,hasDetailPanel:ft,rowReordering:ct,pinCheckboxColumn:L,pinExpandColumn:A,pinnedColumns:It,loading:af})]})]})}),$o&&s.jsx($o,{apiRef:Pn.apiRef,aggregationModel:Ge,aggregationResult:Gn?$n:null,rowCount:No&&F!=="server"?Lt.length:Oo,pagination:Ve,paginationModel:Ae,pageSizeOptions:P,onPaginationModelChange:Nt,...ce?.footer}),!Jt&&!$o&&Ve&&s.jsx(hc,{paginationSlot:ee?.pagination,paginationSlotProps:ce?.pagination,page:To.currentPage,paginationModel:Ae,rowCount:Oo,pageSizeOptions:P,onPaginationModelChange:Nt,localeText:we}),s.jsx(wc,{loading:et,error:Ee.dataSource.error,noRowsLabel:Qe,filteredRowCount:gl.length,dataRowCount:Lt.length,filterModel:Be}),Nf&&s.jsx(Cd,{overlay:Bn}),s.jsx(fa,{error:Ee.dataSource.error,onRetry:H?rl.fetchRows:void 0})]})}function yc({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 Cc=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 _c(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&&yn(e.items,t.items):!1}function yn(e,t){return e===t?!0:e.length===t.length&&e.every((o,n)=>_c(o,t[n]))}function Sc(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 kc(e,t){if(!Yo.has(t))return t==="isAnyOf"?e==null||e===""?[]:Array.isArray(e)?e:[e]:Array.isArray(e)?e.length>0?e[0]:"":e??""}const Ec=({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 L=I?.operator??l;f.current(b(L,Ti(M,L)))},[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)},Cc);return()=>clearTimeout(M)},[m,y]);const T=M=>{const I=m!==null?Ti(m,M):t?.value;x(null),n(b(M,kc(I,M)))},E=()=>{x(null),n(null)},P=!Yo.has(c),O=Sc(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,L=>L.value));n(b("isAnyOf",O.filter(L=>_.has(L.key)).map(L=>L.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(L=>L.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:"×"})]})]})},Li=({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=!yn(c,n),p=i!==null&&yn(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(Ec,{col:w,item:Mi(n,w.field),resetToken:u,onChange:p=>m(w.field,p)},w.field))]})},Fi=["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 Mc({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 L(A){A.key==="Escape"&&r()}return document.addEventListener("mousedown",_),document.addEventListener("keydown",L),()=>{document.removeEventListener("mousedown",_),document.removeEventListener("keydown",L)}},[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(L=>L.field===_),w=_=>f(_)?.headerName??_,p=_=>{const L=f(_)?.availableAggregationFunctions;return L?Fi.filter(A=>L.includes(A)):Fi},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((L,A)=>A!==_)})}function P(_){n({...o,columnFields:o.columnFields.filter((L,A)=>A!==_)})}function O(_){n({...o,valueFields:o.valueFields.filter((L,A)=>A!==_)})}function W(_,L){n({...o,valueFields:o.valueFields.map((A,q)=>q===_?{...A,aggFn:L}: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((_,L)=>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(L),title:`Remove ${w(_)}`,"aria-label":`Remove ${w(_)} from Row Fields`,children:"×"})]},`${L}:${_}`))})]}),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((_,L)=>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(L),title:`Remove ${w(_)}`,"aria-label":`Remove ${w(_)} from Column Fields`,children:"×"})]},`${L}:${_}`))})]}),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((_,L)=>{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(L,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(L),title:`Remove ${w(_.field)}`,"aria-label":`Remove ${w(_.field)} (${_.aggFn.toUpperCase()}) from Value Fields`,children:"×"})]},`${L}:${_.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 L=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${L?" 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"}),L&&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 Nc(){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 Pc(){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 Ic({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(Nc,{})}),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(Pc,{})})]})}const yo=8;function Ut({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+yo,left:T});break;case"left":d({top:E,left:N.left-yo});break;case"right":d({top:E,left:N.right+yo});break;default:d({top:N.top-yo,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 Tc=Object.keys(so);function Lc(e){return Object.prototype.hasOwnProperty.call(so,e)}function Ai(e){return e.availableAggregationFunctions?Array.from(new Set(e.availableAggregationFunctions.filter(Lc))):Tc}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 Oc({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 Dc({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(xn,{columns:t,visibleColumns:o,onVisibilityChange:n,onShowAll:r,onHideAll:i,onColumnReorder:l,onColumnOrderReset:c,showNonHideableColumns:u})});return v?tt.createPortal(w,v):null}function Ac({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(Li,{columns:t,filterModel:o,onFilterModelChange:n})})]});return u?tt.createPortal(h,u):null}const $c={rowFields:[],columnFields:[],valueFields:[]};function Gc({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),L=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),oe=a.useRef(null),Z=a.useRef(null),de=a.useRef(null),ae=a.useRef(null),ne=r??$c,se=ne.rowFields.length>0||ne.columnFields.length>0||ne.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,F)=>{if(!n)return;const Q={...o};F==="none"?delete Q[k]:Q[k]=F,n(Q)},[o,n]),R=a.useCallback(()=>{n?.({})},[n]),U=a.useCallback(k=>{if(!c)return;const F=k.trim().split(/\s+/).filter(Boolean),Q={...l||{},quickFilterValues:F,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,F)=>{if(!u)return;const Q={...d,[k]:F};u(Q)},[d,u]),j=a.useCallback(()=>{if(!u)return;const k={...d};e.forEach(F=>{F.hideable!==!1&&(k[F.field]=!0)}),u(k)},[e,d,u]),z=a.useCallback(()=>{if(!u)return;const k={...d};e.forEach(F=>{F.hideable!==!1&&(k[F.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(Ic,{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(Ut,{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(Dc,{anchorRef:p?Z:te,columns:e,visibleColumns:Y,onVisibilityChange:H,onShowAll:j,onHideAll:z,onColumnReorder:g,onColumnOrderReset:m,onClose:()=>L("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(Ut,{title:"Filters",children:s.jsxs("button",{type:"button",ref:oe,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(Ac,{anchorRef:b?de:oe,columns:e,filterModel:l||{items:[]},onFilterModelChange:c,onClose:()=>L("filters")})]}),i&&s.jsxs("div",{className:"ogx-toolbar__dropdown-wrapper",style:{marginRight:4},children:[s.jsx(Ut,{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(Mc,{anchorRef:J,columns:t??e,model:ne,onChange:k=>{i?.(k)},onClose:()=>L("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(Ut,{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(Oc,{anchorRef:y?ae:K,aggregationModel:o,aggregableColumns:B,onFunctionChange:$,onClearAll:R,onClose:()=>L("summaries"),activeCount:D})]}),C&&C(),f]})]})}function Wc(){const[e]=a.useState(Yr);return a.useRef(e)}const Hc=({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 Bc=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 Vc(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 zc(e){let t="",o=!1;for(const n of e){const r=n.codePointAt(0)??0;if(r<=255||Bc.has(r)){t+=n;continue}const i=Vc(r);i!==null?t+=i:(t+="?",o=!0)}return{text:t,lossy:o}}const Kc=[79,70,229],jc=[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 bo(e,t,jt(e,t))}function Bi(e){return(typeof e.width=="number"?e.width:void 0)??(e.flex??1)*100}function Uc(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 Xc=new Set(["isEmpty","isNotEmpty"]);function qc(e,t){const n=t.find(l=>l.field===e.field)?.headerName??e.field;if(Xc.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):qc(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 Yc(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 Rc=1.15*.3528;async function Jc(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 $=zc(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*Rc},M=st(t),I=Kt(b,u),_=zt(e,u,g);let L=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=Yc(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),L=$+6}const A=[M.map(D=>X(D.headerName??D.field))],q=x||{},K=D=>M.map($=>bn($,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 oe=Uc(M,P),[Z,de,ae]=Wi(f,Kc),[ne,se,re]=Wi(w,jc);r(C,{head:A,body:J,...te?{foot:te}:{},startY:L,styles:{fontSize:p,cellPadding:3,font:O,overflow:"linebreak"},headStyles:{fillColor:[Z,de,ae],textColor:[ne,se,re],fontStyle:"bold"},...h?{alternateRowStyles:{fillColor:[248,250,252]}}:{},...te?{footStyles:{fillColor:[241,245,249],fontStyle:"bold",textColor:[0,0,0]}}:{},columnStyles:oe,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 Xt(e,t){const o=jt(e,t);return{text:bo(e,t,o),raw:o}}function Mt(e,t,o){return e.map(n=>bn(n,o[n.field],t[n.field],t))}const Qc="\uFEFF";function Zc(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)=>Co(d?vo(f,w):f,i),v=()=>g.map(f=>x(f.headerName||f.field)).join(i)+`
5
+ `;let h="";if(Kt(c,l))r&&(h+=v()),c.forEach(f=>{const w=" ".repeat(f.depth);if(f.type==="group-header"){const p=Et(f,t),b=Co(w+(d?vo(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=Xt(p,y),T=d?vo(N.text,Je(N.raw)):N.text;return Co((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?Co(St(b,y[0]),i):x(y[T],Je(p[N.field])));h+=C.join(i)+`
8
+ `}});else{const f=zt(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=Xt(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
+ `}}Cn((u?Qc:"")+h,n,"text/csv;charset=utf-8;")}function Co(e,t){return t!==""&&e.includes(t)||e.includes('"')||e.includes(`
12
+ `)||e.includes("\r")?`"${e.replace(/"/g,'""')}"`:e}const _o="ogx-xls-text";function eu(e,t){return e.type!=="number"&&e.type!=="date"&&e.type!=="boolean"&&!Je(t)}function tu(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 ou(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?vo(w,p):w),x=w=>`<td class="${_o}">${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(vn(r))}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--><meta charset="UTF-8"><style>.${_o}{mso-number-format:"\\@";}</style></head><body><table border="1">`;i&&(h+="<thead><tr>",u.forEach(w=>{h+=`<th class="${_o}">${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 eu(p,w.raw)?x(y):`<td>${y}</td>`};if(Kt(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="${_o}">${_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(Xt(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=zt(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(Xt(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>",Cn(h,tu(n),"application/vnd.ms-excel")}function nu(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]=jt(g,x)}),m};let u;if(Kt(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=zt(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}Cn(r?JSON.stringify(u,null,2):JSON.stringify(u),n,"application/json;charset=utf-8;")}const ru=/^(?:https?:|data:image\/|blob:)/i,iu=/^[a-z][a-z\d+.-]*:/i;function lu(e){const t=e.trim();return t?ru.test(t)?t:iu.test(t)?null:t:null}async function su(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 @@ ${p}`;try{await kr(w)}catch(x){console.error("[OpenGridX] Failed to copy to clip
35
29
  </div>
36
30
  </body>
37
31
  </html>
38
- `),o.document.close(),await new Promise(i=>setTimeout(i,100));try{let i="Print",l,a=null,d=null,c;typeof e=="string"?i=e:typeof e=="object"&&(i=e.title||"Print",l=e.selectedRows,a=e.aggregationResult||null,d=e.aggregationModel||null,c=e.groupedRows);const u=t.filter(x=>!(x.exportable===!1||x.field==="__check__"||x.field==="__actions__"));let p=`<!DOCTYPE html><html><head><title>${i||"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(i&&(p+=`<h1>${be(i)}</h1>`),p+="<table><thead><tr>",u.forEach(x=>{p+=`<th>${be(x.headerName||x.field)}</th>`}),p+="</tr></thead><tbody>",c&&c.length>0){const x=d||{};c.forEach(g=>{if(g.type==="group-header"){const h=`${"&nbsp;".repeat(g.depth*4)}${be(g.groupField??"")}: ${be(String(g.groupValue??""))}`;p+=`<tr class="group-header"><td colspan="${u.length}">${h}</td></tr>`}else if(g.type==="leaf"&&g.row){const f=g.row,h="&nbsp;".repeat(g.depth*4);p+="<tr>",u.forEach((v,E)=>{let m=f[v.field];v.valueGetter&&(m=v.valueGetter({row:f,field:v.field,value:m})),v.valueFormatter&&m!==void 0&&m!==null&&(m=v.valueFormatter({value:m,row:f,field:v.field})),v.type==="image"&&m?p+=`<td><img src="${m}" style="max-height:40px;border-radius:4px;"></td>`:p+=`<td>${(E===0?h:"")+be(String(m??""))}</td>`}),p+="</tr>"}else if((g.type==="group-subtotal"||g.type==="grand-total")&&g.aggregatedValues){const f=g.type==="grand-total",h=f?"":"&nbsp;".repeat(g.depth*4),v=f?"Grand Total":`${h}Subtotal`;p+=`<tr class="${f?"grand-total":"group-subtotal"}">`,u.forEach((m,y)=>{if(y===0){p+=`<td>${v}</td>`;return}const M=g.aggregatedValues[m.field];if(M!=null){let N=M;m.valueFormatter?N=m.valueFormatter({value:M,row:{},field:m.field}):x[m.field]&&(N=ve(M,x[m.field])),p+=`<td style="text-align:right;">${be(String(N))}</td>`}else p+="<td></td>"}),p+="</tr>"}})}else{const x=l&&l.length>0?n.filter(g=>l.includes(g.id)):n;if(x.length===0){o.document.body.innerHTML="<h3>No rows to export</h3>";return}if(x.forEach(g=>{p+="<tr>",u.forEach(f=>{let h=g[f.field];f.valueGetter&&(h=f.valueGetter({row:g,field:f.field,value:h})),f.valueFormatter&&h!==void 0&&h!==null&&(h=f.valueFormatter({value:h,row:g,field:f.field})),f.type==="image"&&h?p+=`<td><div style="display:flex;justify-content:center;"><img src="${h}" alt="${f.headerName}" style="max-height:40px;border-radius:4px;"></div></td>`:p+=`<td>${be(String(h??""))}</td>`}),p+="</tr>"}),a){const g=d||{};p+='<tfoot><tr style="font-size:11px;color:#666;background-color:#f5f5f5;">',u.forEach(f=>{p+=g[f.field]?`<td style="text-align:right;font-weight:bold;">${be(g[f.field].toUpperCase())}</td>`:"<td></td>"}),p+='</tr><tr style="font-weight:bold;background-color:#f5f5f5;">',u.forEach(f=>{const h=a[f.field];if(h!=null){let v=h;f.valueFormatter?v=f.valueFormatter({value:h,row:{},field:f.field}):g[f.field]&&(v=ve(h,g[f.field])),p+=`<td style="text-align:right;">${be(String(v))}</td>`}else p+="<td></td>"}),p+="</tr></tfoot>"}}p+="</tbody></table></body></html>",o.document.open(),o.document.write(p),o.document.close(),o.document.title=i||"Print Preview",o.focus();let w=!1;o.onload=()=>{w||(w=!0,o.print(),setTimeout(()=>{o.close()},100))},setTimeout(()=>{!w&&o&&!o.closed&&(w=!0,o.print(),setTimeout(()=>{o.closed||o.close()},100))},500)}catch(i){if(console.error("Print generation failed:",i),o&&!o.closed){const l=i instanceof Error?i.message:String(i);o.document.body.innerHTML=`<div style="color: red; padding: 20px;"><h3>Error Generating Print Preview</h3><p>${l}</p></div>`}}}function an(n,t,e){const o=new Blob([n],{type:e}),i=URL.createObjectURL(o),l=document.createElement("a");l.href=i,l.download=t,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(i)}function mi(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 wi(n){if(n.type==="number")return"#,##0.##";if(n.type==="date")return"yyyy-mm-dd"}function bi(n,t){if(t!=null)return t;const e=n.width??120;return Math.min(60,Math.max(8,(e-5)/7))}function vi(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 Ci(n){const t=await Promise.allSettled(n.map(async o=>{if(o.startsWith("data:")){const d=o.indexOf(","),c=o.slice(0,d),u=o.slice(d+1),p=atob(u),w=new Uint8Array(p.length);for(let h=0;h<p.length;h++)w[h]=p.charCodeAt(h);const g=c.match(/data:([^;,]+)/)?.[1]??"image/png";let f="png";return g.includes("jpeg")||g.includes("jpg")?f="jpeg":g.includes("gif")&&(f="gif"),{url:o,buffer:w.buffer,ext:f}}const i=await fetch(o,{mode:"cors"});if(!i.ok)throw new Error(`HTTP ${i.status}`);const l=await i.arrayBuffer(),a=vi(o,i.headers.get("content-type"));return{url:o,buffer:l,ext:a}})),e=new Map;return t.forEach((o,i)=>{o.status==="fulfilled"?e.set(o.value.url,{buffer:o.value.buffer,extension:o.value.ext}):console.warn(`[exportToExcelAdvanced] Cannot embed image "${n[i]}" (CORS/network error — raw URL written as fallback):`,o.reason)}),e}async function _i(n,t,e={}){const{fileName:o="export.xlsx",sheets:i,columnStyles:l={},headerFillColor:a="#f1f5f9",headerTextColor:d="#334155",headerFontSize:c=10,bodyFontSize:u=10,aggregationResult:p=null,aggregationModel:w=null,selectedRows:x,groupedRows:g,groupHeaderFillColor:f="#e8eaf6",groupSubtotalFillColor:h="#f0f4ff"}=e,v=(await import("exceljs")).default,E=new v.Workbook;E.creator="OpenGridX",E.created=new Date;const m=t.filter(b=>b.exportable!==!1&&b.field!=="__check__"&&b.field!=="__actions__"&&!b.isSpacer),y=n,M=x&&x.length>0?n.filter(b=>x.includes(b.id)):n,N=i??[{name:"Data",rows:"all",includeHeaders:!0,includeSummary:!1}],k=new Map;for(const b of N){if("type"in b&&b.type==="summary"){if(!p||!w)continue;const G=E.addWorksheet(b.name??"Summary");G.addRow(["Summary / Aggregation Totals"]),G.getRow(1).font={bold:!0,size:c+2,color:{argb:Ne(d)}},G.addRow([]),G.addRow(["Column","Function","Value"]).eachCell(Y=>{Y.fill={type:"pattern",pattern:"solid",fgColor:{argb:Ne(a)}},Y.font={bold:!0,size:c,color:{argb:Ne(d)}},Y.border=Xn()}),m.forEach(Y=>{const Q=w[Y.field],J=p[Y.field];if(Q==null||J==null)return;let re=J;Y.valueFormatter?re=Y.valueFormatter({value:J,row:{},field:Y.field}):re=ve(J,Q);const q=G.addRow([Y.headerName??Y.field,Q.toUpperCase(),re]);q.getCell(3).alignment={horizontal:"right"},q.getCell(3).font={bold:!0,size:u}}),G.getColumn(1).width=20,G.getColumn(2).width=12,G.getColumn(3).width=18;continue}const F=b,{name:z="Data",rows:K="all",includeHeaders:W=!0,includeSummary:$=!1,autoFilter:H=!0,frozenHeader:L=!0,alternateRowColor:B="#f8fafc"}=F,D=K==="all"&&!!(g&&g.length>0),_=K==="selected"?M:D?g.flatMap(G=>G.type==="leaf"&&G.row?[G.row]:[]):y,T=m.filter(G=>l[G.field]?.embedImage);if(T.length>0){const G=[],R=new Set;if(_.forEach(Y=>{T.forEach(Q=>{const J=Y[Q.field];typeof J=="string"&&J&&!k.has(J)&&!R.has(J)&&(G.push(J),R.add(J))})}),G.length>0){const Y=await Ci(G);for(const[Q,{buffer:J,extension:re}]of Y){const q=E.addImage({buffer:J,extension:re});k.set(Q,q)}}}const I=E.addWorksheet(z);if(I.columns=m.map(G=>({key:G.field,width:bi(G,l[G.field]?.width),style:{numFmt:l[G.field]?.numFmt??wi(G)}})),W){const G=m.map(Y=>Y.headerName??Y.field),R=I.addRow(G);R.height=20,R.eachCell((Y,Q)=>{const J=m[Q-1];Y.fill={type:"pattern",pattern:"solid",fgColor:{argb:Ne(a)}},Y.font={bold:!0,size:c,color:{argb:Ne(d)}},Y.alignment={horizontal:l[J?.field]?.alignment??(J?.type==="number"?"right":"left"),vertical:"middle"},Y.border=Xn()}),H&&(I.autoFilter={from:{row:1,column:1},to:{row:1,column:m.length}}),L?I.views=[{state:"frozen",ySplit:1,showGridLines:!1}]:I.views=[{showGridLines:!1}]}let O=W?1:0;const X=(G,R,Y)=>{const Q=m.map(re=>{if(l[re.field]?.embedImage)return"";let q=G[re.field];return re.valueGetter&&(q=re.valueGetter({row:G,field:re.field,value:q})),mi(re,q)==="string"&&re.valueFormatter&&q!=null&&(q=re.valueFormatter({value:q,row:G,field:re.field})),q}),J=I.addRow(Q);if(J.font={size:u},Y>0&&(J.outlineLevel=Y),B&&R%2===1&&J.eachCell(re=>{re.fill={type:"pattern",pattern:"solid",fgColor:{argb:Ne(B)}}}),J.eachCell((re,q)=>{const V=m[q-1];V&&(re.alignment={horizontal:l[V.field]?.alignment??(V.type==="number"?"right":"left"),vertical:"middle"},re.border={bottom:{style:"thin",color:{argb:"FFf1f5f9"}}})}),T.length>0){const re=T.reduce((A,ee)=>Math.max(A,l[ee.field]?.imageHeight??40),0),q=Math.ceil(re/1.333),V=q*1.333;J.height=q,T.forEach(A=>{const ee=m.indexOf(A),ie=G[A.field],ae=typeof ie=="string"?k.get(ie):void 0;if(ae===void 0){J.getCell(ee+1).value=typeof ie=="string"?ie:"";return}const fe=l[A.field],he=fe?.imageWidth??40,Me=fe?.imageHeight??40,Pe=(I.getColumn(ee+1).width??8)*7+5,Se=Math.max(0,Pe-he)/2,oe=Math.max(0,V-Me)/2;I.addImage(ae,{tl:{col:ee,row:O,nativeColOff:Math.floor(Se*9525),nativeRowOff:Math.floor(oe*9525)},ext:{width:he,height:Me},editAs:"oneCell"})})}else J.height=16;O++},te=G=>{const R=m.find(Y=>Y.field===G.groupField);return R?.groupingValueFormatter&&G.groupField?R.groupingValueFormatter({field:G.groupField,value:G.groupValue}):`${R?.headerName??G.groupField??""}: ${String(G.groupValue??"")}`},Z=(G,R)=>{const Y=R[G.field];return Y==null?"":typeof Y=="number"?Y:G.valueFormatter?G.valueFormatter({value:Y,row:{},field:G.field}):ve(Y,w?.[G.field]??"")},ce=(G,R,Y,Q,J)=>{const re=m.map((V,A)=>A===0&&R[V.field]==null?G:Z(V,R)),q=I.addRow(re);q.height=18,Q>0&&(q.outlineLevel=Q),q.font={bold:J,italic:!J,size:u,color:{argb:Ne(d)}},q.eachCell((V,A)=>{V.fill={type:"pattern",pattern:"solid",fgColor:{argb:Ne(Y)}};const ee=m[A-1];V.alignment={horizontal:A===1?"left":ee?.type==="number"?"right":"left",vertical:"middle"},V.border=Jn()}),O++};let le=!1;if(D){let G=0;g.forEach(R=>{if(R.type==="group-header"){const Y=I.addRow([te(R)]);Y.height=18,R.depth>0&&(Y.outlineLevel=R.depth),Y.font={bold:!0,size:u,color:{argb:Ne(d)}};for(let Q=1;Q<=m.length;Q++)Y.getCell(Q).fill={type:"pattern",pattern:"solid",fgColor:{argb:Ne(f)}};Y.getCell(1).alignment={horizontal:"left",vertical:"middle",indent:R.depth},O++,G=0}else R.type==="leaf"&&R.row?X(R.row,G++,R.depth):R.type==="group-subtotal"&&R.aggregatedValues?ce("Subtotal",R.aggregatedValues,h,R.depth,!1):R.type==="grand-total"&&R.aggregatedValues&&(ce("Grand Total",R.aggregatedValues,a,0,!0),le=!0)}),I.properties.outlineProperties={summaryBelow:!0,summaryRight:!1}}else _.forEach((G,R)=>X(G,R,0));if($&&!le&&p&&w){const G=m.map(J=>{const re=w[J.field];return re?re.toUpperCase():""}),R=I.addRow(G);R.height=16,R.font={size:u-1,italic:!0,color:{argb:"FF94a3b8"}},R.eachCell(J=>{J.alignment={horizontal:"right",vertical:"middle"},J.border={top:{style:"thin",color:{argb:"FFcbd5e1"}}}});const Y=m.map(J=>{const re=w[J.field],q=p[J.field];return re==null||q==null?"":J.valueFormatter?J.valueFormatter({value:q,row:{},field:J.field}):ve(q,re)}),Q=I.addRow(Y);Q.height=18,Q.font={bold:!0,size:u,color:{argb:Ne(d)}},Q.eachCell(J=>{J.fill={type:"pattern",pattern:"solid",fgColor:{argb:Ne(a)}},J.alignment={horizontal:"right",vertical:"middle"},J.border=Jn()})}}const C=await E.xlsx.writeBuffer(),S=new Blob([C],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),j=URL.createObjectURL(S),P=document.createElement("a");P.href=j,P.download=o.endsWith(".xlsx")?o:`${o}.xlsx`,document.body.appendChild(P),P.click(),document.body.removeChild(P),URL.revokeObjectURL(j)}function Ne(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 Xn(){return{bottom:{style:"medium",color:{argb:"FFcbd5e1"}}}}function Jn(){return{top:{style:"medium",color:{argb:"FFcbd5e1"}}}}const yi={"--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 ki(n){const t={};function e(o,i){i!==void 0&&(t[o]=i)}if(n.colors){const o=n.colors;e("--ogx-color-primary",o.primary),e("--ogx-color-primary-dark",o.primaryDark),e("--ogx-color-primary-light",o.primaryLight),e("--ogx-color-primary-focus",o.primaryFocus),e("--ogx-color-secondary",o.secondary),e("--ogx-color-secondary-dark",o.secondaryDark),e("--ogx-color-secondary-light",o.secondaryLight),e("--ogx-color-success",o.success),e("--ogx-color-warning",o.warning),e("--ogx-color-error",o.error),e("--ogx-color-info",o.info)}if(n.typography){const o=n.typography;e("--ogx-font-family",o.fontFamily),e("--ogx-font-family-mono",o.fontFamilyMono),e("--ogx-font-size-xs",o.fontSizeXs),e("--ogx-font-size-sm",o.fontSizeSm),e("--ogx-font-size-md",o.fontSizeMd),e("--ogx-font-size-lg",o.fontSizeLg),e("--ogx-font-size-xl",o.fontSizeXl)}if(n.spacing){const o=n.spacing;e("--ogx-spacing-xs",o.xs),e("--ogx-spacing-sm",o.sm),e("--ogx-spacing-md",o.md),e("--ogx-spacing-lg",o.lg),e("--ogx-spacing-xl",o.xl),e("--ogx-spacing-xxl",o.xxl)}if(n.borders){const o=n.borders;e("--ogx-border-width-thin",o.widthThin),e("--ogx-border-width-medium",o.widthMedium),e("--ogx-border-width-thick",o.widthThick),e("--ogx-border-radius-sm",o.radiusSm),e("--ogx-border-radius-md",o.radiusMd),e("--ogx-border-radius-lg",o.radiusLg),e("--ogx-border-radius-xl",o.radiusXl),e("--ogx-border-color",o.color),e("--ogx-border-color-hover",o.colorHover)}if(n.shadows){const o=n.shadows;e("--ogx-shadow-sm",o.sm),e("--ogx-shadow-md",o.md),e("--ogx-shadow-lg",o.lg),e("--ogx-shadow-xl",o.xl)}if(n.grid){const o=n.grid;e("--ogx-grid-row-height-compact",o.rowHeightCompact),e("--ogx-grid-row-height-standard",o.rowHeightStandard),e("--ogx-row-height",o.rowHeightStandard),e("--ogx-grid-row-height-comfortable",o.rowHeightComfortable),e("--ogx-grid-header-height",o.headerHeight),e("--ogx-header-height",o.headerHeight),e("--ogx-grid-cell-padding-x",o.cellPaddingX),e("--ogx-grid-cell-padding-y",o.cellPaddingY),e("--ogx-grid-background",o.background),e("--ogx-grid-border-color",o.borderColor),e("--ogx-grid-header-background",o.headerBackground),e("--ogx-grid-header-text",o.headerText),e("--ogx-grid-header-hover-background",o.headerHoverBackground),e("--ogx-grid-header-sorted-background",o.headerSortedBackground),e("--ogx-grid-row-text",o.rowText),e("--ogx-grid-row-hover-background",o.rowHoverBackground),e("--ogx-grid-row-alternate-background",o.rowAlternateBackground),e("--ogx-grid-row-selected-background",o.rowSelectedBackground),e("--ogx-grid-row-selected-hover-background",o.rowSelectedHoverBackground),e("--ogx-grid-cell-focus-border",o.cellFocusBorder),e("--ogx-grid-pinned-left-shadow",o.pinnedLeftShadow),e("--ogx-grid-pinned-right-shadow",o.pinnedRightShadow),e("--ogx-checkbox-bg",o.checkboxBg),e("--ogx-checkbox-border",o.checkboxBorder)}if(n.transitions){const o=n.transitions;e("--ogx-transition-duration-fast",o.durationFast),e("--ogx-transition-duration-normal",o.durationNormal),e("--ogx-transition-duration-slow",o.durationSlow),e("--ogx-transition-easing",o.easing)}if(n.toolbar){const o=n.toolbar;e("--ogx-toolbar-background",o.background),e("--ogx-toolbar-text",o.text),e("--ogx-toolbar-border",o.border),e("--ogx-toolbar-btn-bg",o.buttonBackground),e("--ogx-toolbar-btn-hover",o.buttonHoverBackground),e("--ogx-toolbar-btn-text",o.buttonText),e("--ogx-toolbar-btn-primary-bg",o.buttonPrimaryBackground),e("--ogx-toolbar-btn-primary-hover",o.buttonPrimaryHoverBackground),e("--ogx-toolbar-btn-primary-text",o.buttonPrimaryText),e("--ogx-toolbar-btn-danger-bg",o.buttonDangerBackground),e("--ogx-toolbar-btn-danger-hover",o.buttonDangerHoverBackground),e("--ogx-toolbar-btn-danger-text",o.buttonDangerText),e("--ogx-toolbar-input-bg",o.inputBackground),e("--ogx-toolbar-input-text",o.inputText),e("--ogx-toolbar-input-border",o.inputBorder),e("--ogx-toolbar-input-focus-border",o.inputFocusBorder),e("--ogx-toolbar-input-focus-shadow",o.inputFocusShadow),e("--ogx-toolbar-chip-bg",o.chipBackground),e("--ogx-toolbar-chip-text",o.chipText),e("--ogx-toolbar-chip-active-bg",o.chipActiveBackground),e("--ogx-toolbar-chip-active-text",o.chipActiveText)}if(n.overlays){const o=n.overlays;e("--ogx-overlay-background",o.background),e("--ogx-overlay-text",o.text),e("--ogx-overlay-border",o.border),e("--ogx-overlay-shadow",o.shadow),e("--ogx-overlay-item-hover-bg",o.itemHoverBackground),e("--ogx-overlay-item-hover-text",o.itemHoverText),e("--ogx-overlay-item-selected-bg",o.itemSelectedBackground),e("--ogx-overlay-item-selected-text",o.itemSelectedText),e("--ogx-overlay-item-danger-bg",o.itemDangerBackground),e("--ogx-overlay-item-danger-text",o.itemDangerText)}if(n.scrollbar){const o=n.scrollbar;e("--ogx-scrollbar-thumb",o.thumbColor),e("--ogx-scrollbar-track",o.trackColor),e("--ogx-scrollbar-size",o.size)}if(n.skeleton){const o=n.skeleton;e("--ogx-skeleton-base",o.baseColor),e("--ogx-skeleton-highlight",o.highlightColor),e("--ogx-skeleton-dark-base",o.darkBaseColor),e("--ogx-skeleton-dark-highlight",o.darkHighlightColor)}return t}function Si({theme:n,children:t,className:e,style:o}){const i=s.useMemo(()=>({...yi,...ki(n)}),[n]);return r.jsx("div",{className:`ogx-theme-provider ${e||""}`.trim(),style:{...o,...i},children:t})}const ji={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"}},Ei={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"}},Ni={colors:{primary:"#059669",primaryDark:"#047857",primaryLight:"#ecfdf5",primaryFocus:"rgba(5, 150, 105, 0.4)"},grid:{headerBackground:"#ecfdf5",headerHoverBackground:"#d1fae5",headerSortedBackground:"#a7f3d0",rowAlternateBackground:"#f6fdf9",rowSelectedBackground:"#d1fae5",rowSelectedHoverBackground:"#a7f3d0",cellFocusBorder:"#059669"}},Mi={colors:{primary:"#d97706",primaryDark:"#b45309",primaryLight:"#fffbeb",primaryFocus:"rgba(217, 119, 6, 0.4)"},grid:{headerBackground:"#fffbeb",headerHoverBackground:"#fef3c7",headerSortedBackground:"#fde68a",rowAlternateBackground:"#fffdf5",rowSelectedBackground:"#fef3c7",rowSelectedHoverBackground:"#fde68a",cellFocusBorder:"#d97706"}},Pi={grid:{rowHeightCompact:"28px",rowHeightStandard:"36px",rowHeightComfortable:"48px",headerHeight:"40px",cellPaddingX:"8px",cellPaddingY:"4px"},typography:{fontSizeSm:"0.8rem",fontSizeMd:"0.875rem"}};function Ri(n,t){try{const e=t.getItem(n);return e?JSON.parse(e):void 0}catch{return}}function Ti(n,t,e,o){try{const i=e?Object.fromEntries(Object.entries(t).filter(([l])=>e.includes(l))):t;o.setItem(n,JSON.stringify(i))}catch{}}function Ii(n){const t=typeof n=="string"?{key:n}:n,{key:e,debounceMs:o=300,include:i,storage:l=typeof window<"u"?window.localStorage:void 0}=t,a=s.useMemo(()=>{if(l)return Ri(e,l)},[e,l]),d=s.useRef(null),c=s.useRef(null),u=s.useCallback(()=>{c.current&&l&&Ti(e,c.current,i,l)},[e,i,l]),p=s.useCallback(x=>{c.current=x,d.current&&clearTimeout(d.current),d.current=setTimeout(u,o)},[u,o]);s.useEffect(()=>()=>{d.current&&(clearTimeout(d.current),u())},[u]);const w=s.useCallback(()=>{l&&l.removeItem(e)},[e,l]);return{initialState:a,onStateChange:p,clearState:w}}se.Button=vt,se.Cell=zn,se.Checkbox=bt,se.ColumnVisibilityPanel=sn,se.DataGrid=Gr,se.DataGridThemeProvider=Si,se.FilterPanel=Hn,se.GridToolbar=li,se.GridTooltip=_t,se.Header=Ln,se.Input=ai,se.Row=At,se.Skeleton=Ur,se.amberTheme=Mi,se.compactTheme=Pi,se.darkTheme=ji,se.emeraldTheme=Ni,se.exportToCsv=gi,se.exportToExcel=hi,se.exportToExcelAdvanced=_i,se.exportToJson=pi,se.exportToPdf=fi,se.formatAggregationValue=ve,se.printGrid=xi,se.roseTheme=Ei,se.useAggregation=Tn,se.useGridApiRef=si,se.useGridStateStorage=Ii,se.usePivot=$n,Object.defineProperty(se,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}=Xt(f,w),C=w.type==="image"?lu(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(Kt(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=zt(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 Cn(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 au(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 qt(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 du=/^(\d{4})-(\d{2})-(\d{2})$/,cu=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?$/i,uu=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?$/i;function fu(e){if(e instanceof Date)return qt(e);if(typeof e=="number")return Number.isFinite(e)?qt(new Date(e)):null;if(typeof e!="string")return;const t=e.trim(),o=du.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(cu.test(t)){const n=new Date(t.replace(" ","T"));return Number.isNaN(n.getTime())?void 0:qt(n)}}function gu(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"&&uu.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 fu(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 qt(e);if(typeof e=="object")try{return JSON.stringify(e)??String(e)}catch{return String(e)}return String(e)}function pu(e,t){const o=jt(e,t),n=au(t,o);if(n!=="string"){const r=gu(n,o);if(r!=null)return r;if(!t.valueFormatter)return r===null?null:zi(o)}return t.valueFormatter?bo(e,t,o):zi(o)}const Ki="#,##0",hu="#,##0.##";function wu(e){return Number.isInteger(e)?Ki:hu}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 wu(o)}function mu(e,t){if(t!=null)return t;const o=e.width??120;return Math.min(60,Math.max(8,(o-5)/7))}function xu(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=jt(e,t);return typeof o=="string"&&o?o:null}async function bu(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=xu(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 vu(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=(_,L)=>{const A=L[_.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:qt(K)}:{value:bn(_,q,A,L)}};for(const _ of E){if("type"in _&&_.type==="summary"){if(!g||!m)continue;const V=b.addWorksheet(vn(_.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 L=_,{name:A="Data",rows:q="all",includeHeaders:K=!0,includeSummary:J=!1,autoFilter:te=!0,frozenHeader:oe=!0,alternateRowColor:Z="#f8fafc"}=L,de=q==="all"&&!!(h&&h.length>0),ae=q==="selected"?T:de?h.flatMap(V=>V.type==="leaf"&&V.row?[V.row]:[]):N,ne=C.filter(V=>i[V.field]?.embedImage);if(ne.length>0){const V=[],Y=new Set;if(ae.forEach(H=>{ne.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 bu(V);for(const[j,{buffer:z,extension:k}]of H){const F=b.addImage({buffer:z,extension:k});O.set(j,F)}}}const se=b.addWorksheet(vn(A,P));se.columns=C.map(V=>({key:V.field,width:mu(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}}),oe?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(F=>i[F.field]?.embedImage?"":pu(V,F)),z=se.addRow(j);z.font={size:u},H>0&&(z.outlineLevel=H);const k=!!Z&&Y%2===1;if(re(z,(F,Q,ee)=>{const ce=Ui(Q,i[Q.field],j[ee-1]);ce&&(F.numFmt=ce),k&&Z&&(F.fill={type:"pattern",pattern:"solid",fgColor:{argb:Oe(Z)}}),F.alignment={horizontal:i[Q.field]?.alignment??(Q.type==="number"?"right":"left"),vertical:"middle"},F.border={bottom:{style:"thin",color:{argb:"FFf1f5f9"}}}}),ne.length>0){const F=ne.reduce((ce,fe)=>Math.max(ce,i[fe.field]?.imageHeight??40),0),Q=Math.ceil(F/1.333),ee=Q*1.333;z.height=Q,ne.forEach(ce=>{const fe=C.indexOf(ce),ge=Xi(V,ce),be=ge?O.get(ge):void 0;if(be===void 0){z.getCell(fe+1).value=ge??"";return}const Ce=i[ce.field],ue=Ce?.imageWidth??40,me=Ce?.imageHeight??40,Se=(se.getColumn(fe+1).width??8)*7+5,le=Math.max(0,Se-ue)/2,ye=Math.max(0,ee-me)/2;se.addImage(be,{tl:{col:fe,row:B,nativeColOff:Math.floor(le*9525),nativeRowOff:Math.floor(ye*9525)},ext:{width:ue,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)),F=se.addRow(k.map(Q=>Q.value));F.height=18,j>0&&(F.outlineLevel=j),F.font={bold:z,italic:!z,size:u,color:{argb:Oe(c)}},re(F,(Q,ee,ce)=>{const fe=k[ce-1].numFmt;fe&&(Q.numFmt=fe),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,F)=>{const Q=H[F-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 yu(e,t,o,n){return a.useMemo(()=>n?vr(e,t,o):nn,[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},Cu={...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)"},_u=[50,100,200,300,400,500,600,700,800,900];function Su(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 _u)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 ku({theme:e,children:t,className:o,style:n}){const r=a.useMemo(()=>({...e.mode==="dark"?Cu:Ji,...Su(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 Eu={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"}},Mu={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"}},Nu={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"}},Pu={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"}},Iu={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 Tu(){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 Lu(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(Tu),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&&Lu(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])}he.Button=Ht,he.Cell=xi,he.Checkbox=Wt,he.ColumnVisibilityPanel=xn,he.DataGrid=vc,he.DataGridThemeProvider=ku,he.FilterPanel=Li,he.GridToolbar=Gc,he.GridTooltip=Ut,he.Header=qr,he.Input=Hc,he.Pagination=pn,he.Row=xo,he.Skeleton=yc,he.amberTheme=Pu,he.compactTheme=Iu,he.darkTheme=Eu,he.emeraldTheme=Nu,he.exportToCsv=Zc,he.exportToExcel=ou,he.exportToExcelAdvanced=vu,he.exportToJson=nu,he.exportToPdf=Jc,he.formatAggregationValue=qo,he.printGrid=su,he.roseTheme=Mu,he.useAggregation=hi,he.useGridApiRef=Wc,he.useGridStateStorage=Fu,he.usePivot=yu,Object.defineProperty(he,Symbol.toStringTag,{value:"Module"})}));
50
44
  //# sourceMappingURL=opengridx.umd.js.map