react-open-source-grid 1.5.0 → 1.5.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 (85) hide show
  1. package/dist/assets/components/AccessibilityDemo.d.ts +8 -0
  2. package/dist/assets/components/ApiReferencePage.d.ts +2 -0
  3. package/dist/assets/components/BenchmarkDemo.d.ts +2 -0
  4. package/dist/assets/components/CellRenderersDemo.d.ts +16 -0
  5. package/dist/assets/components/CodeBlock.d.ts +10 -0
  6. package/dist/assets/components/ColumnFiltersDemo.d.ts +5 -0
  7. package/dist/assets/components/CompleteApiReferencePage.d.ts +2 -0
  8. package/dist/assets/components/ContextMenuDemo.d.ts +12 -0
  9. package/dist/assets/components/DataGrid/ARCHITECTURE.md.d.ts +288 -0
  10. package/dist/assets/components/DataGrid/AdvancedFilterBuilder.d.ts +12 -0
  11. package/dist/assets/components/DataGrid/CellRenderers.d.ts +64 -0
  12. package/dist/assets/components/DataGrid/ColumnChooser.d.ts +12 -0
  13. package/dist/assets/components/DataGrid/ColumnFilters.d.ts +16 -0
  14. package/dist/assets/components/DataGrid/ContextMenu.d.ts +10 -0
  15. package/dist/assets/components/DataGrid/DataGrid.d.ts +22 -0
  16. package/dist/assets/components/DataGrid/DensityToggle.d.ts +23 -0
  17. package/dist/assets/components/DataGrid/DragHandle.d.ts +7 -0
  18. package/dist/assets/components/DataGrid/DraggableRow.d.ts +14 -0
  19. package/dist/assets/components/DataGrid/ExportMenu.d.ts +12 -0
  20. package/dist/assets/components/DataGrid/FacetedSearch.d.ts +29 -0
  21. package/dist/assets/components/DataGrid/FilteredSearchBar.d.ts +36 -0
  22. package/dist/assets/components/DataGrid/FocusTrap.d.ts +12 -0
  23. package/dist/assets/components/DataGrid/GridApiDemo.d.ts +6 -0
  24. package/dist/assets/components/DataGrid/GridBody.d.ts +42 -0
  25. package/dist/assets/components/DataGrid/GridFooter.d.ts +18 -0
  26. package/dist/assets/components/DataGrid/GridHeader.d.ts +18 -0
  27. package/dist/assets/components/DataGrid/GridPagination.d.ts +10 -0
  28. package/dist/assets/components/DataGrid/GroupByPanel.d.ts +9 -0
  29. package/dist/assets/components/DataGrid/GroupRow.d.ts +31 -0
  30. package/dist/assets/components/DataGrid/InfiniteScrollDataGrid.d.ts +39 -0
  31. package/dist/assets/components/DataGrid/LayoutPresetsManager.d.ts +11 -0
  32. package/dist/assets/components/DataGrid/MarketDataEngine.d.ts +165 -0
  33. package/dist/assets/components/DataGrid/MarketDataGrid.d.ts +33 -0
  34. package/dist/assets/components/DataGrid/MarketDataGridUtils.d.ts +13 -0
  35. package/dist/assets/components/DataGrid/ScreenReaderAnnouncer.d.ts +8 -0
  36. package/dist/assets/components/DataGrid/ServerSideDataSource.d.ts +136 -0
  37. package/dist/assets/components/DataGrid/ThemeSelector.d.ts +12 -0
  38. package/dist/assets/components/DataGrid/Tooltip.d.ts +15 -0
  39. package/dist/assets/components/DataGrid/TreeRow.d.ts +31 -0
  40. package/dist/assets/components/DataGrid/VirtualScroller.d.ts +35 -0
  41. package/dist/assets/components/DataGrid/WebSocketMockFeed.d.ts +121 -0
  42. package/dist/assets/components/DataGrid/aggregationUtils.d.ts +25 -0
  43. package/dist/assets/components/DataGrid/contextMenuUtils.d.ts +36 -0
  44. package/dist/assets/components/DataGrid/demos/TooltipDemo.d.ts +1 -0
  45. package/dist/assets/components/DataGrid/densityModes.d.ts +42 -0
  46. package/dist/assets/components/DataGrid/dragRowUtils.d.ts +98 -0
  47. package/dist/assets/components/DataGrid/exportUtils.d.ts +30 -0
  48. package/dist/assets/components/DataGrid/filterUtils.d.ts +17 -0
  49. package/dist/assets/components/DataGrid/gridApi.d.ts +142 -0
  50. package/dist/assets/components/DataGrid/gridApi.types.d.ts +348 -0
  51. package/dist/assets/components/DataGrid/gridReducer.d.ts +4 -0
  52. package/dist/assets/components/DataGrid/groupingUtils.d.ts +17 -0
  53. package/dist/assets/components/DataGrid/index.d.ts +41 -0
  54. package/dist/assets/components/DataGrid/layoutPersistence.d.ts +95 -0
  55. package/dist/assets/components/DataGrid/themes.d.ts +113 -0
  56. package/dist/assets/components/DataGrid/treeDataUtils.d.ts +97 -0
  57. package/dist/assets/components/DataGrid/types.d.ts +536 -0
  58. package/dist/assets/components/DataGrid/useContextMenu.d.ts +31 -0
  59. package/dist/assets/components/DataGrid/useDensityMode.d.ts +36 -0
  60. package/dist/assets/components/DataGrid/useFocusTrap.d.ts +14 -0
  61. package/dist/assets/components/DataGrid/useMarketData.d.ts +57 -0
  62. package/dist/assets/components/DataGrid/useScreenReaderAnnouncements.d.ts +23 -0
  63. package/dist/assets/components/DataGrid/useTooltip.d.ts +21 -0
  64. package/dist/assets/components/DemoGridPage.d.ts +2 -0
  65. package/dist/assets/components/DensityModeDemo.d.ts +12 -0
  66. package/dist/assets/components/FacetedSearchDemo.d.ts +8 -0
  67. package/dist/assets/components/FeatureGallery.d.ts +2 -0
  68. package/dist/assets/components/FilteredSearchDemo.d.ts +7 -0
  69. package/dist/assets/components/GridApiDemoPage.d.ts +2 -0
  70. package/dist/assets/components/HomePage.d.ts +1 -0
  71. package/dist/assets/components/InfiniteScrollDemo.d.ts +13 -0
  72. package/dist/assets/components/LayoutPersistenceDemo.d.ts +2 -0
  73. package/dist/assets/components/LiveMarketDemo.d.ts +18 -0
  74. package/dist/assets/components/MarketDataExamples.d.ts +42 -0
  75. package/dist/assets/components/RowDraggingDemo.d.ts +3 -0
  76. package/dist/assets/components/RowPinningDemo.d.ts +12 -0
  77. package/dist/assets/components/ThemesDemo.d.ts +17 -0
  78. package/dist/assets/components/TooltipDemo.d.ts +1 -0
  79. package/dist/assets/components/TreeDataDemo.d.ts +3 -0
  80. package/dist/assets/components/VirtualScrollDemo.d.ts +13 -0
  81. package/dist/assets/{index-BCK5Ko4P.js → index-bQ7aqGuU.js} +2 -2
  82. package/dist/assets/index.js +1 -1
  83. package/dist/assets/{layoutPersistence-BHB0W18y.js → layoutPersistence-B2lMGbE7.js} +1 -1
  84. package/dist/index.html +1 -1
  85. package/package.json +14 -4
@@ -37,13 +37,13 @@ use chrome, FireFox or Internet Explorer 11`)}var a=e(`safe-buffer`),o=e(`random
37
37
  `,n.NAME_START_CHAR=`:A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿`,n.NAME_CHAR=`-`+n.NAME_START_CHAR+`.0-9·̀-ͯ‿-⁀`,n.CHAR_RE=RegExp(`^[`+n.CHAR+`]$`,`u`),n.S_RE=RegExp(`^[`+n.S+`]+$`,`u`),n.NAME_START_CHAR_RE=RegExp(`^[`+n.NAME_START_CHAR+`]$`,`u`),n.NAME_CHAR_RE=RegExp(`^[`+n.NAME_CHAR+`]$`,`u`),n.NAME_RE=RegExp(`^[`+n.NAME_START_CHAR+`][`+n.NAME_CHAR+`]*$`,`u`),n.NMTOKEN_RE=RegExp(`^[`+n.NAME_CHAR+`]+$`,`u`);function r(e){return e>=65&&e<=90||e>=97&&e<=122||e===58||e===95||e===8204||e===8205||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}n.S_LIST=[32,10,13,9],n.isChar=function(e){return e>=32&&e<=55295||e===10||e===13||e===9||e>=57344&&e<=65533||e>=65536&&e<=1114111},n.isS=function(e){return e===32||e===10||e===13||e===9},n.isNameStartChar=r,n.isNameChar=function(e){return r(e)||e>=48&&e<=57||e===45||e===46||e===183||e>=768&&e<=879||e>=8255&&e<=8256}},{}],544:[function(e,t,n){Object.defineProperty(n,`__esModule`,{value:!0}),n.CHAR=`-퟿-�𐀀-􏿿`,n.RESTRICTED_CHAR=`-\b\v\f--„†-Ÿ`,n.S=` \r
38
38
  `,n.NAME_START_CHAR=`:A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿`,n.NAME_CHAR=`-`+n.NAME_START_CHAR+`.0-9·̀-ͯ‿-⁀`,n.CHAR_RE=RegExp(`^[`+n.CHAR+`]$`,`u`),n.RESTRICTED_CHAR_RE=RegExp(`^[`+n.RESTRICTED_CHAR+`]$`,`u`),n.S_RE=RegExp(`^[`+n.S+`]+$`,`u`),n.NAME_START_CHAR_RE=RegExp(`^[`+n.NAME_START_CHAR+`]$`,`u`),n.NAME_CHAR_RE=RegExp(`^[`+n.NAME_CHAR+`]$`,`u`),n.NAME_RE=RegExp(`^[`+n.NAME_START_CHAR+`][`+n.NAME_CHAR+`]*$`,`u`),n.NMTOKEN_RE=RegExp(`^[`+n.NAME_CHAR+`]+$`,`u`);function r(e){return e>=65&&e<=90||e>=97&&e<=122||e===58||e===95||e===8204||e===8205||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}n.S_LIST=[32,10,13,9],n.isChar=function(e){return e>=1&&e<=55295||e>=57344&&e<=65533||e>=65536&&e<=1114111},n.isRestrictedChar=function(e){return e>=1&&e<=8||e===11||e===12||e>=14&&e<=31||e>=127&&e<=132||e>=134&&e<=159},n.isCharAndNotRestricted=function(e){return e===9||e===10||e===13||e>31&&e<127||e===133||e>159&&e<=55295||e>=57344&&e<=65533||e>=65536&&e<=1114111},n.isS=function(e){return e===32||e===10||e===13||e===9},n.isNameStartChar=r,n.isNameChar=function(e){return r(e)||e>=48&&e<=57||e===45||e===46||e===183||e>=768&&e<=879||e>=8255&&e<=8256}},{}],545:[function(e,t,n){function r(e){return e>=65&&e<=90||e===95||e>=97&&e<=122||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e>=8204&&e<=8205||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}Object.defineProperty(n,`__esModule`,{value:!0}),n.NC_NAME_START_CHAR=`A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�𐀀-󯿿`,n.NC_NAME_CHAR=`-`+n.NC_NAME_START_CHAR+`.0-9·̀-ͯ‿-⁀`,n.NC_NAME_START_CHAR_RE=RegExp(`^[`+n.NC_NAME_START_CHAR+`]$`,`u`),n.NC_NAME_CHAR_RE=RegExp(`^[`+n.NC_NAME_CHAR+`]$`,`u`),n.NC_NAME_RE=RegExp(`^[`+n.NC_NAME_START_CHAR+`][`+n.NC_NAME_CHAR+`]*$`,`u`),n.isNCNameStartChar=r,n.isNCNameChar=function(e){return r(e)||e===45||e===46||e>=48&&e<=57||e===183||e>=768&&e<=879||e>=8255&&e<=8256}},{}]},{},[15])(15)}))}))(),1);const Vn=(e,t,n=`export.csv`)=>{let r=t.map(e=>e.headerName),i=e.map(e=>t.map(t=>{let n=e[t.field];if(n==null)return``;let r=String(n);return r.includes(`,`)||r.includes(`
39
39
  `)||r.includes(`"`)?`"${r.replace(/"/g,`""`)}"`:r}).join(`,`)),a=[r.join(`,`),...i].join(`
40
- `);Wn(new Blob([a],{type:`text/csv;charset=utf-8;`}),n)},Hn=async(e,t,n={})=>{let{filename:r=`export.xlsx`,styling:i=`basic`}=n,a=new Bn.default.Workbook,o=a.addWorksheet(`Sheet1`),s=t.map(e=>e.headerName);o.addRow(s),e.forEach(e=>{let n=t.map(t=>e[t.field]??``);o.addRow(n)}),o.columns=t.map(t=>{let n=t.headerName.length,r=Math.max(...e.map(e=>String(e[t.field]??``).length)),i=Math.max(n,r)+2;return{width:Math.min(i,50)}}),i===`professional`&&Un(o,t);let c=await a.xlsx.writeBuffer();Wn(new Blob([c],{type:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`}),r)};var Un=(e,t)=>{let n=e.getRow(1);n.font={bold:!0,color:{argb:`FFFFFFFF`},size:11},n.fill={type:`pattern`,pattern:`solid`,fgColor:{argb:`FF2F5496`}},n.alignment={horizontal:`center`,vertical:`middle`,wrapText:!0},n.height=20,e.eachRow((e,t)=>{e.eachCell(e=>{e.border={top:{style:`thin`,color:{argb:`FFD3D3D3`}},left:{style:`thin`,color:{argb:`FFD3D3D3`}},bottom:{style:`thin`,color:{argb:`FFD3D3D3`}},right:{style:`thin`,color:{argb:`FFD3D3D3`}}},t>1&&t%2==0&&(e.fill={type:`pattern`,pattern:`solid`,fgColor:{argb:`FFF2F2F2`}}),t>1&&(e.alignment={horizontal:`left`,vertical:`middle`})})}),e.views=[{state:`frozen`,ySplit:1}]},Wn=(e,t)=>{let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)};const Gn=(e,t)=>{let n=new Date().toISOString().replace(/[:.]/g,`-`).slice(0,-5);return`data_export_${t===`all`?`full`:t}_${n}.${e}`},Kn=async(e,t,n)=>{if(e.length===0){alert(`No data to export`);return}let r=n.filename||Gn(n.format,n.scope);n.format===`csv`?Vn(e,t,r):n.format===`xlsx`&&await Hn(e,t,{filename:r,styling:n.styling})},qn=({columns:e,fullDataset:t,filteredData:n,selectedRows:r,currentPageData:i,onExport:a})=>{let[o,s]=(0,b.useState)(!1),[c,l]=(0,b.useState)(`csv`),[u,d]=(0,b.useState)(`filtered`),[f,p]=(0,b.useState)(`basic`),[m,h]=(0,b.useState)(null),g=b.useRef(null),_=()=>{switch(u){case`all`:return t;case`filtered`:return n;case`selected`:return r.size>0?n.filter(e=>r.has(e.id)):[];case`page`:return i;default:return n}},v=()=>{let t=_();if(t.length===0){alert(`No ${u===`selected`?`selected`:u} data to export`);return}Kn(t,e,{format:c,scope:u,styling:c===`xlsx`?f:void 0}),a?.(!0),s(!1)},y=[{value:`all`,label:`Full Dataset`,disabled:!1},{value:`filtered`,label:`Filtered Data`,disabled:n.length===0},{value:`selected`,label:`Selected Rows (${r.size})`,disabled:r.size===0},{value:`page`,label:`Current Page`,disabled:i.length===0}];return(0,Z.jsxs)(`div`,{style:{position:`relative`},children:[(0,Z.jsxs)(`button`,{ref:g,onClick:()=>{if(!o){let e=g.current?.getBoundingClientRect();e&&h(e)}s(!o)},style:{padding:`8px 12px`,backgroundColor:`#2563eb`,color:`white`,borderRadius:`6px`,border:`none`,fontSize:`14px`,fontWeight:`500`,display:`flex`,alignItems:`center`,gap:`8px`,cursor:`pointer`,transition:`background-color 0.2s`},onMouseEnter:e=>{e.currentTarget.style.backgroundColor=`#1d4ed8`},onMouseLeave:e=>{e.currentTarget.style.backgroundColor=`#2563eb`},title:`Export data to CSV or XLSX format`,children:[(0,Z.jsx)(`svg`,{style:{width:`16px`,height:`16px`},fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,Z.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M12 19l9 2-9-18-9 18 9-2m0 0v-8m0 8l-6-4m6 4l6-4`})}),`Export`]}),o&&m&&(0,Z.jsxs)(`div`,{style:{position:`fixed`,left:`${m.left}px`,top:`${m.bottom+8}px`,backgroundColor:`#ffffff`,border:`1px solid #e5e7eb`,borderRadius:`8px`,boxShadow:`0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.05)`,zIndex:50,padding:`20px`,width:`420px`,minWidth:`420px`,maxWidth:`420px`,maxHeight:`90vh`,overflowY:`auto`},children:[(0,Z.jsxs)(`div`,{style:{marginBottom:`20px`},children:[(0,Z.jsx)(`label`,{style:{display:`block`,fontSize:`14px`,fontWeight:`600`,color:`#1f2937`,marginBottom:`12px`},children:`Format`}),(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:`16px`},children:[(0,Z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,cursor:`pointer`},children:[(0,Z.jsx)(`input`,{type:`radio`,name:`format`,value:`csv`,checked:c===`csv`,onChange:e=>l(e.target.value),style:{width:`16px`,height:`16px`,cursor:`pointer`}}),(0,Z.jsx)(`span`,{style:{fontSize:`14px`,color:`#374151`},children:`CSV`})]}),(0,Z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,cursor:`pointer`},children:[(0,Z.jsx)(`input`,{type:`radio`,name:`format`,value:`xlsx`,checked:c===`xlsx`,onChange:e=>l(e.target.value),style:{width:`16px`,height:`16px`,cursor:`pointer`}}),(0,Z.jsx)(`span`,{style:{fontSize:`14px`,color:`#374151`},children:`XLSX (Excel)`})]})]})]}),(0,Z.jsxs)(`div`,{style:{marginBottom:`20px`},children:[(0,Z.jsx)(`label`,{style:{display:`block`,fontSize:`14px`,fontWeight:`600`,color:`#1f2937`,marginBottom:`12px`},children:`Data Scope`}),(0,Z.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`10px`},children:y.map(e=>(0,Z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`10px`,padding:`10px 12px`,borderRadius:`6px`,cursor:e.disabled?`not-allowed`:`pointer`,opacity:e.disabled?.5:1,backgroundColor:`transparent`,transition:`background-color 0.15s`,userSelect:`none`},onMouseEnter:t=>{e.disabled||(t.currentTarget.style.backgroundColor=`#f3f4f6`)},onMouseLeave:e=>{e.currentTarget.style.backgroundColor=`transparent`},children:[(0,Z.jsx)(`input`,{type:`radio`,name:`scope`,value:e.value,checked:u===e.value,onChange:e=>d(e.target.value),disabled:e.disabled,style:{width:`16px`,height:`16px`,cursor:e.disabled?`not-allowed`:`pointer`}}),(0,Z.jsx)(`span`,{style:{fontSize:`14px`,color:`#374151`},children:e.label})]},e.value))})]}),c===`xlsx`&&(0,Z.jsxs)(`div`,{style:{marginBottom:`20px`},children:[(0,Z.jsx)(`label`,{style:{display:`block`,fontSize:`14px`,fontWeight:`600`,color:`#1f2937`,marginBottom:`12px`},children:`Styling`}),(0,Z.jsx)(`div`,{style:{marginBottom:`10px`},children:(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:`16px`},children:[(0,Z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,cursor:`pointer`},children:[(0,Z.jsx)(`input`,{type:`radio`,name:`styling`,value:`basic`,checked:f===`basic`,onChange:e=>p(e.target.value),style:{width:`16px`,height:`16px`,cursor:`pointer`}}),(0,Z.jsx)(`span`,{style:{fontSize:`14px`,color:`#374151`},children:`Basic`})]}),(0,Z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,cursor:`pointer`},children:[(0,Z.jsx)(`input`,{type:`radio`,name:`styling`,value:`professional`,checked:f===`professional`,onChange:e=>p(e.target.value),style:{width:`16px`,height:`16px`,cursor:`pointer`}}),(0,Z.jsx)(`span`,{style:{fontSize:`14px`,color:`#374151`},children:`Professional`})]})]})}),(0,Z.jsx)(`p`,{style:{fontSize:`12px`,color:`#6b7280`,margin:`0`},children:`Professional adds colors, borders, and frozen header row`})]}),(0,Z.jsxs)(`div`,{style:{backgroundColor:`#f3f4f6`,borderRadius:`6px`,padding:`12px`,marginBottom:`20px`,fontSize:`13px`,color:`#4b5563`},children:[(0,Z.jsxs)(`p`,{style:{margin:`6px 0`},children:[(0,Z.jsx)(`strong`,{children:`Data to export:`}),` `,_().length,` row(s)`]}),(0,Z.jsxs)(`p`,{style:{margin:`6px 0`},children:[(0,Z.jsx)(`strong`,{children:`Columns:`}),` `,e.length]})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:`10px`,justifyContent:`flex-end`},children:[(0,Z.jsx)(`button`,{onClick:()=>s(!1),style:{padding:`10px 16px`,border:`1px solid #d1d5db`,color:`#374151`,backgroundColor:`#ffffff`,borderRadius:`6px`,fontSize:`14px`,fontWeight:`500`,cursor:`pointer`,transition:`background-color 0.2s`},onMouseEnter:e=>{e.currentTarget.style.backgroundColor=`#f9fafb`},onMouseLeave:e=>{e.currentTarget.style.backgroundColor=`#ffffff`},children:`Cancel`}),(0,Z.jsx)(`button`,{onClick:v,disabled:_().length===0,style:{padding:`10px 16px`,backgroundColor:_().length===0?`#9ca3af`:`#2563eb`,color:`#ffffff`,borderRadius:`6px`,border:`none`,fontSize:`14px`,fontWeight:`500`,cursor:_().length===0?`not-allowed`:`pointer`,opacity:_().length===0?.6:1,transition:`background-color 0.2s`},onMouseEnter:e=>{_().length>0&&(e.currentTarget.style.backgroundColor=`#1d4ed8`)},onMouseLeave:e=>{_().length>0&&(e.currentTarget.style.backgroundColor=`#2563eb`)},children:`Export Now`})]})]}),o&&(0,Z.jsx)(`div`,{style:{position:`fixed`,inset:0,zIndex:40},onClick:()=>s(!1)})]})};var Jn=e=>{if(e.filterType)return e.filterType===`multi`?`set`:e.filterType;let t=e.field.toLowerCase();return t.includes(`date`)||t.includes(`time`)?`date`:t.includes(`salary`)||t.includes(`price`)||t.includes(`amount`)||t.includes(`count`)?`number`:t.includes(`status`)||t.includes(`department`)||t.includes(`category`)?`set`:`text`},Yn=e=>{switch(e){case`text`:return[{value:`contains`,label:`Contains`},{value:`notContains`,label:`Not Contains`},{value:`equals`,label:`Equals`},{value:`notEquals`,label:`Not Equals`},{value:`startsWith`,label:`Starts With`},{value:`endsWith`,label:`Ends With`},{value:`isEmpty`,label:`Is Empty`},{value:`isNotEmpty`,label:`Is Not Empty`}];case`number`:return[{value:`equals`,label:`Equals`},{value:`notEquals`,label:`Not Equals`},{value:`greaterThan`,label:`Greater Than`},{value:`greaterThanOrEqual`,label:`Greater Than or Equal`},{value:`lessThan`,label:`Less Than`},{value:`lessThanOrEqual`,label:`Less Than or Equal`},{value:`inRange`,label:`In Range`},{value:`isEmpty`,label:`Is Empty`},{value:`isNotEmpty`,label:`Is Not Empty`}];case`date`:return[{value:`equals`,label:`Equals`},{value:`before`,label:`Before`},{value:`after`,label:`After`},{value:`inRange`,label:`In Range`},{value:`isEmpty`,label:`Is Empty`},{value:`isNotEmpty`,label:`Is Not Empty`}];case`set`:return[{value:`in`,label:`In`},{value:`notIn`,label:`Not In`}];default:return[]}},Xn=e=>![`isEmpty`,`isNotEmpty`].includes(e),Zn=e=>e===`inRange`,Qn=e=>[`in`,`notIn`].includes(e);const $n=({column:e,filterValue:t,onApply:n,onClose:r,rows:i,anchorEl:a})=>{let o=Jn(e),s=Yn(o),c=t?.conditions||[{type:s[0]?.value||`contains`,value:``,value2:``,values:[]}],[l,u]=(0,b.useState)(t?.operator||`AND`),[d,f]=(0,b.useState)(c),[p,m]=(0,b.useState)({}),h=o===`set`?Array.from(new Set(i.map(t=>t[e.field]).filter(e=>e!=null))):[],g=()=>{f([...d,{type:s[0]?.value||`contains`,value:``,value2:``,values:[]}])},_=e=>{if(d.length>1){f(d.filter((t,n)=>n!==e));let t={...p};delete t[e],m(t)}},v=(e,t)=>{f(d.map((n,r)=>r===e?{...n,...t}:n))},y=(e,t)=>{m({...p,[e]:t})},x=()=>{let e=d.filter(e=>Xn(e.type)?Qn(e.type)?e.values&&e.values.length>0:Zn(e.type)?e.value!=null&&e.value!==``&&e.value2!=null&&e.value2!==``:e.value!=null&&e.value!==``:!0);e.length===0?n(null):n({operator:l,conditions:e}),r()},S=()=>{f([{type:s[0]?.value||`contains`,value:``,value2:``,values:[]}]),m({}),n(null)},C=()=>{f([{type:s[0]?.value||`contains`,value:``,value2:``,values:[]}]),u(`AND`),m({})},w=(e,t)=>{if(Qn(e.type)){let n=new Set(e.values||[]),r=p[t]?.searchTerm||``,i=h.filter(e=>String(e).toLowerCase().includes(r.toLowerCase())),a=e=>{let r=new Set(n);r.has(e)?r.delete(e):r.add(e),v(t,{values:Array.from(r)})};return(0,Z.jsxs)(`div`,{style:{marginTop:`8px`},children:[(0,Z.jsx)(`input`,{type:`text`,style:{width:`100%`,padding:`6px 10px`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 4px)`,fontSize:`var(--grid-font-size-sm, 12px)`,outline:`none`,backgroundColor:`var(--grid-bg)`,color:`var(--grid-text)`,marginBottom:`8px`},value:r,onChange:e=>y(t,{searchTerm:e.target.value}),placeholder:`Search values...`}),(0,Z.jsxs)(`div`,{style:{maxHeight:`150px`,overflowY:`auto`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 4px)`,padding:`4px`},children:[(0,Z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`6px`,cursor:`pointer`,padding:`4px 6px`,fontSize:`var(--grid-font-size-sm, 12px)`},children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:n.size===i.length&&i.length>0,onChange:()=>{n.size===i.length?v(t,{values:[]}):v(t,{values:i})},style:{width:`14px`,height:`14px`,cursor:`pointer`}}),(0,Z.jsx)(`span`,{style:{fontWeight:500,color:`var(--grid-text)`},children:`(Select All)`})]}),i.map((e,t)=>(0,Z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`6px`,cursor:`pointer`,padding:`4px 6px`,fontSize:`var(--grid-font-size-sm, 12px)`},children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:n.has(e),onChange:()=>a(e),style:{width:`14px`,height:`14px`,cursor:`pointer`}}),(0,Z.jsx)(`span`,{style:{color:`var(--grid-text)`},children:String(e)})]},t))]}),n.size>0&&(0,Z.jsxs)(`div`,{style:{marginTop:`6px`,fontSize:`var(--grid-font-size-sm, 12px)`,color:`var(--grid-primary)`,fontWeight:500},children:[n.size,` selected`]})]})}return Xn(e.type)?Zn(e.type)?(0,Z.jsxs)(`div`,{style:{marginTop:`8px`,display:`flex`,gap:`8px`,alignItems:`center`},children:[(0,Z.jsx)(`input`,{type:o===`date`?`date`:o===`number`?`number`:`text`,style:{flex:1,padding:`6px 10px`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 4px)`,fontSize:`var(--grid-font-size-sm, 12px)`,outline:`none`,backgroundColor:`var(--grid-bg)`,color:`var(--grid-text)`},value:e.value||``,onChange:e=>v(t,{value:e.target.value}),placeholder:`From`}),(0,Z.jsx)(`span`,{style:{color:`var(--grid-text-secondary)`,fontSize:`var(--grid-font-size-sm, 12px)`},children:`to`}),(0,Z.jsx)(`input`,{type:o===`date`?`date`:o===`number`?`number`:`text`,style:{flex:1,padding:`6px 10px`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 4px)`,fontSize:`var(--grid-font-size-sm, 12px)`,outline:`none`,backgroundColor:`var(--grid-bg)`,color:`var(--grid-text)`},value:e.value2||``,onChange:e=>v(t,{value2:e.target.value}),placeholder:`To`})]}):(0,Z.jsx)(`div`,{style:{marginTop:`8px`},children:(0,Z.jsx)(`input`,{type:o===`date`?`date`:o===`number`?`number`:`text`,style:{width:`100%`,padding:`6px 10px`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 4px)`,fontSize:`var(--grid-font-size-sm, 12px)`,outline:`none`,backgroundColor:`var(--grid-bg)`,color:`var(--grid-text)`},value:e.value||``,onChange:e=>v(t,{value:e.target.value}),placeholder:`Enter ${o}...`})}):null};return(0,Z.jsxs)(`div`,{style:{position:`fixed`,top:a?a.getBoundingClientRect().bottom+5:0,left:a?a.getBoundingClientRect().left:0,minWidth:`380px`,maxWidth:`450px`,maxHeight:`600px`,backgroundColor:`var(--grid-bg)`,boxShadow:`0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.1)`,borderRadius:`var(--grid-border-radius, 8px)`,border:`1px solid var(--grid-border)`,padding:`16px`,zIndex:1001,display:`flex`,flexDirection:`column`,overflowY:`auto`},onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(`div`,{style:{marginBottom:`16px`,paddingBottom:`12px`,borderBottom:`1px solid var(--grid-border)`},children:[(0,Z.jsxs)(`h4`,{style:{margin:0,fontSize:`var(--grid-font-size, 14px)`,fontWeight:600,color:`var(--grid-text)`},children:[`Advanced Filter: `,e.headerName]}),(0,Z.jsx)(`p`,{style:{margin:`4px 0 0 0`,fontSize:`var(--grid-font-size-sm, 12px)`,color:`var(--grid-text-secondary)`},children:`Add multiple conditions with AND/OR logic`})]}),d.length>1&&(0,Z.jsxs)(`div`,{style:{marginBottom:`16px`},children:[(0,Z.jsx)(`label`,{style:{display:`block`,fontSize:`var(--grid-font-size-sm, 12px)`,fontWeight:500,color:`var(--grid-text)`,marginBottom:`6px`},children:`Combine Conditions`}),(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:`8px`},children:[(0,Z.jsx)(`button`,{style:{flex:1,padding:`6px 12px`,fontSize:`var(--grid-font-size-sm, 12px)`,fontWeight:500,color:l===`AND`?`var(--grid-text-inverse)`:`var(--grid-text)`,backgroundColor:l===`AND`?`var(--grid-primary)`:`var(--grid-bg-alt)`,border:l===`AND`?`none`:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,cursor:`pointer`,transition:`all 0.15s`},onClick:()=>u(`AND`),children:`AND`}),(0,Z.jsx)(`button`,{style:{flex:1,padding:`6px 12px`,fontSize:`var(--grid-font-size-sm, 12px)`,fontWeight:500,color:l===`OR`?`var(--grid-text-inverse)`:`var(--grid-text)`,backgroundColor:l===`OR`?`var(--grid-primary)`:`var(--grid-bg-alt)`,border:l===`OR`?`none`:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,cursor:`pointer`,transition:`all 0.15s`},onClick:()=>u(`OR`),children:`OR`})]})]}),(0,Z.jsx)(`div`,{style:{flex:1,overflowY:`auto`,marginBottom:`12px`},children:d.map((e,t)=>(0,Z.jsxs)(`div`,{style:{marginBottom:`12px`,padding:`12px`,backgroundColor:`var(--grid-bg-alt)`,borderRadius:`var(--grid-border-radius, 6px)`,border:`1px solid var(--grid-border)`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:`8px`},children:[(0,Z.jsxs)(`label`,{style:{fontSize:`var(--grid-font-size-sm, 12px)`,fontWeight:500,color:`var(--grid-text)`},children:[`Condition `,t+1]}),d.length>1&&(0,Z.jsx)(`button`,{style:{padding:`2px 8px`,fontSize:`var(--grid-font-size-sm, 12px)`,color:`var(--grid-danger, #dc2626)`,backgroundColor:`transparent`,border:`none`,cursor:`pointer`,borderRadius:`var(--grid-border-radius, 4px)`},onClick:()=>_(t),onMouseEnter:e=>e.currentTarget.style.backgroundColor=`var(--grid-danger-bg, rgba(220, 38, 38, 0.1))`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`transparent`,title:`Remove condition`,children:`✕`})]}),(0,Z.jsx)(`select`,{style:{width:`100%`,padding:`6px 10px`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 4px)`,fontSize:`var(--grid-font-size-sm, 12px)`,outline:`none`,backgroundColor:`var(--grid-bg)`,color:`var(--grid-text)`},value:e.type,onChange:e=>v(t,{type:e.target.value,value:``,value2:``,values:[]}),children:s.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value))}),w(e,t),t<d.length-1&&d.length>1&&(0,Z.jsx)(`div`,{style:{marginTop:`12px`,padding:`4px 8px`,textAlign:`center`,fontSize:`var(--grid-font-size-sm, 12px)`,fontWeight:600,color:`var(--grid-primary)`,backgroundColor:`var(--grid-primary-bg)`,borderRadius:`var(--grid-border-radius, 4px)`},children:l})]},t))}),(0,Z.jsx)(`button`,{style:{width:`100%`,padding:`8px 12px`,marginBottom:`12px`,fontSize:`var(--grid-font-size-sm, 12px)`,fontWeight:500,color:`var(--grid-primary)`,backgroundColor:`var(--grid-primary-bg)`,border:`1px dashed var(--grid-primary)`,borderRadius:`var(--grid-border-radius, 6px)`,cursor:`pointer`,transition:`all 0.15s`},onClick:g,onMouseEnter:e=>e.currentTarget.style.backgroundColor=`var(--grid-primary-hover-bg)`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`var(--grid-primary-bg)`,children:`+ Add Condition`}),(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,paddingTop:`12px`,borderTop:`1px solid var(--grid-border)`},children:[(0,Z.jsx)(`button`,{style:{flex:1,padding:`8px 12px`,fontSize:`var(--grid-font-size-sm, 12px)`,fontWeight:500,color:`var(--grid-text)`,backgroundColor:`var(--grid-bg-alt)`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,cursor:`pointer`,transition:`all 0.15s`},onClick:C,onMouseEnter:e=>e.currentTarget.style.backgroundColor=`var(--grid-hover)`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`var(--grid-bg-alt)`,children:`Reset`}),(0,Z.jsx)(`button`,{style:{flex:1,padding:`8px 12px`,fontSize:`var(--grid-font-size-sm, 12px)`,fontWeight:500,color:`var(--grid-text)`,backgroundColor:`var(--grid-bg-alt)`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,cursor:`pointer`,transition:`all 0.15s`},onClick:S,onMouseEnter:e=>e.currentTarget.style.backgroundColor=`var(--grid-hover)`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`var(--grid-bg-alt)`,children:`Clear`}),(0,Z.jsx)(`button`,{style:{flex:1,padding:`8px 12px`,fontSize:`var(--grid-font-size-sm, 12px)`,fontWeight:500,color:`var(--grid-text-inverse)`,backgroundColor:`var(--grid-primary)`,border:`none`,borderRadius:`var(--grid-border-radius, 6px)`,cursor:`pointer`,transition:`all 0.15s`},onClick:x,onMouseEnter:e=>e.currentTarget.style.backgroundColor=`var(--grid-primary-hover)`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`var(--grid-primary)`,children:`Apply`})]})]})};var er=e=>e!=null&&`operator`in e&&`conditions`in e,tr=({filterValue:e,onApplyFilter:t,onClose:n,anchorEl:r,showAdvancedButton:i,onSwitchToAdvanced:a})=>{let o=er(e)?null:e,s=o?.type||`contains`,c=o?.value||``,[l,u]=(0,b.useState)(s),[d,f]=(0,b.useState)(c);return(0,Z.jsxs)(`div`,{style:{position:`fixed`,top:r?r.getBoundingClientRect().bottom+5:0,left:r?r.getBoundingClientRect().left:0,minWidth:`280px`,backgroundColor:`var(--grid-bg)`,boxShadow:`var(--grid-shadow-medium, 0 10px 15px -3px rgba(0, 0, 0, 0.1))`,borderRadius:`var(--grid-border-radius, 8px)`,border:`var(--grid-border-width, 1px) solid var(--grid-border)`,padding:`16px`,zIndex:1e3},onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(`div`,{style:{marginBottom:`12px`},children:[(0,Z.jsx)(`label`,{style:{display:`block`,fontSize:`var(--grid-font-size, 14px)`,fontWeight:500,color:`var(--grid-text)`,marginBottom:`4px`},children:`Filter Type`}),(0,Z.jsxs)(`select`,{style:{width:`100%`,padding:`8px 12px`,border:`var(--grid-border-width, 1px) solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,fontSize:`var(--grid-font-size, 14px)`,outline:`none`,backgroundColor:`var(--grid-bg)`,color:`var(--grid-text)`},value:l,onChange:e=>u(e.target.value),children:[(0,Z.jsx)(`option`,{value:`contains`,children:`Contains`}),(0,Z.jsx)(`option`,{value:`notContains`,children:`Not Contains`}),(0,Z.jsx)(`option`,{value:`equals`,children:`Equals`}),(0,Z.jsx)(`option`,{value:`startsWith`,children:`Starts With`}),(0,Z.jsx)(`option`,{value:`endsWith`,children:`Ends With`})]})]}),(0,Z.jsxs)(`div`,{style:{marginBottom:`12px`},children:[(0,Z.jsx)(`label`,{style:{display:`block`,fontSize:`var(--grid-font-size, 14px)`,fontWeight:500,color:`var(--grid-text)`,marginBottom:`4px`},children:`Value`}),(0,Z.jsx)(`input`,{type:`text`,style:{width:`100%`,padding:`8px 12px`,border:`var(--grid-border-width, 1px) solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,fontSize:`var(--grid-font-size, 14px)`,outline:`none`,backgroundColor:`var(--grid-bg)`,color:`var(--grid-text)`},value:d,onChange:e=>f(e.target.value),placeholder:`Enter text...`,autoFocus:!0})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,justifyContent:`flex-end`},children:[(0,Z.jsx)(`button`,{style:{padding:`6px 12px`,fontSize:`var(--grid-font-size, 14px)`,color:`var(--grid-text)`,backgroundColor:`var(--grid-bg-alt)`,border:`none`,borderRadius:`var(--grid-border-radius, 6px)`,cursor:`pointer`},onClick:()=>{f(``),t(null),n()},onMouseEnter:e=>e.currentTarget.style.backgroundColor=`var(--grid-hover)`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`var(--grid-bg-alt)`,children:`Clear`}),(0,Z.jsx)(`button`,{style:{padding:`6px 12px`,fontSize:`var(--grid-font-size, 14px)`,color:`var(--grid-text-inverse)`,backgroundColor:`var(--grid-primary)`,border:`none`,borderRadius:`var(--grid-border-radius, 6px)`,cursor:`pointer`},onClick:()=>{t(d?{type:l,value:d}:null),n()},onMouseEnter:e=>e.currentTarget.style.backgroundColor=`var(--grid-primary-hover)`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`var(--grid-primary)`,children:`Apply`})]})]})},nr=({filterValue:e,onApplyFilter:t,onClose:n,anchorEl:r,showAdvancedButton:i,onSwitchToAdvanced:a})=>{let o=er(e)?null:e,s=o?.type||`equals`,c=o?.value||``,l=o?.value2||``,[u,d]=(0,b.useState)(s),[f,p]=(0,b.useState)(c),[m,h]=(0,b.useState)(l);return(0,Z.jsxs)(`div`,{style:{position:`fixed`,top:r?r.getBoundingClientRect().bottom+5:0,left:r?r.getBoundingClientRect().left:0,minWidth:`280px`,backgroundColor:`var(--grid-bg)`,boxShadow:`var(--grid-shadow, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05))`,borderRadius:`var(--grid-border-radius, 8px)`,border:`1px solid var(--grid-border)`,padding:`16px`,zIndex:1e3},onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(`div`,{style:{marginBottom:`12px`},children:[(0,Z.jsx)(`label`,{style:{display:`block`,fontSize:`var(--grid-font-size, 14px)`,fontWeight:500,color:`var(--grid-text)`,marginBottom:`4px`},children:`Filter Type`}),(0,Z.jsxs)(`select`,{style:{width:`100%`,padding:`8px 12px`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,fontSize:`var(--grid-font-size, 14px)`,outline:`none`,backgroundColor:`var(--grid-bg)`,color:`var(--grid-text)`},value:u,onChange:e=>d(e.target.value),children:[(0,Z.jsx)(`option`,{value:`equals`,children:`Equals`}),(0,Z.jsx)(`option`,{value:`notEquals`,children:`Not Equals`}),(0,Z.jsx)(`option`,{value:`greaterThan`,children:`Greater Than`}),(0,Z.jsx)(`option`,{value:`greaterThanOrEqual`,children:`Greater Than or Equal`}),(0,Z.jsx)(`option`,{value:`lessThan`,children:`Less Than`}),(0,Z.jsx)(`option`,{value:`lessThanOrEqual`,children:`Less Than or Equal`}),(0,Z.jsx)(`option`,{value:`inRange`,children:`In Range`})]})]}),(0,Z.jsxs)(`div`,{style:{marginBottom:`12px`},children:[(0,Z.jsx)(`label`,{style:{display:`block`,fontSize:`var(--grid-font-size, 14px)`,fontWeight:500,color:`var(--grid-text)`,marginBottom:`4px`},children:`Value`}),(0,Z.jsx)(`input`,{type:`number`,style:{width:`100%`,padding:`8px 12px`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,fontSize:`var(--grid-font-size, 14px)`,outline:`none`,backgroundColor:`var(--grid-bg)`,color:`var(--grid-text)`},value:f,onChange:e=>p(e.target.value),placeholder:`Enter number...`,autoFocus:!0})]}),u===`inRange`&&(0,Z.jsxs)(`div`,{style:{marginBottom:`12px`},children:[(0,Z.jsx)(`label`,{style:{display:`block`,fontSize:`var(--grid-font-size, 14px)`,fontWeight:500,color:`var(--grid-text)`,marginBottom:`4px`},children:`To`}),(0,Z.jsx)(`input`,{type:`number`,style:{width:`100%`,padding:`8px 12px`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,fontSize:`var(--grid-font-size, 14px)`,outline:`none`,backgroundColor:`var(--grid-bg)`,color:`var(--grid-text)`},value:m,onChange:e=>h(e.target.value),placeholder:`Enter max value...`})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,justifyContent:`flex-end`},children:[(0,Z.jsx)(`button`,{style:{padding:`6px 12px`,fontSize:`var(--grid-font-size, 14px)`,color:`var(--grid-text)`,backgroundColor:`var(--grid-bg-alt)`,border:`none`,borderRadius:`var(--grid-border-radius, 6px)`,cursor:`pointer`},onClick:()=>{p(``),h(``),t(null),n()},onMouseEnter:e=>e.currentTarget.style.backgroundColor=`var(--grid-hover)`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`var(--grid-bg-alt)`,children:`Clear`}),(0,Z.jsx)(`button`,{style:{padding:`6px 12px`,fontSize:`var(--grid-font-size, 14px)`,color:`var(--grid-text-inverse)`,backgroundColor:`var(--grid-primary)`,border:`none`,borderRadius:`var(--grid-border-radius, 6px)`,cursor:`pointer`},onClick:()=>{if(f){let e={type:u,value:parseFloat(f)};u===`inRange`&&m&&(e.value2=parseFloat(m)),t(e)}else t(null);n()},onMouseEnter:e=>e.currentTarget.style.backgroundColor=`var(--grid-primary-hover)`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`var(--grid-primary)`,children:`Apply`})]})]})},rr=({filterValue:e,onApplyFilter:t,onClose:n,anchorEl:r,showAdvancedButton:i,onSwitchToAdvanced:a})=>{let o=er(e)?null:e,s=o?.type||`equals`,c=o?.value||``,l=o?.value2||``,[u,d]=(0,b.useState)(s),[f,p]=(0,b.useState)(c),[m,h]=(0,b.useState)(l);return(0,Z.jsxs)(`div`,{style:{position:`fixed`,top:r?r.getBoundingClientRect().bottom+5:0,left:r?r.getBoundingClientRect().left:0,minWidth:`280px`,backgroundColor:`var(--grid-bg)`,boxShadow:`var(--grid-shadow, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05))`,borderRadius:`var(--grid-border-radius, 8px)`,border:`1px solid var(--grid-border)`,padding:`16px`,zIndex:1e3},onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(`div`,{style:{marginBottom:`12px`},children:[(0,Z.jsx)(`label`,{style:{display:`block`,fontSize:`var(--grid-font-size, 14px)`,fontWeight:500,color:`var(--grid-text)`,marginBottom:`4px`},children:`Filter Type`}),(0,Z.jsxs)(`select`,{style:{width:`100%`,padding:`8px 12px`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,fontSize:`var(--grid-font-size, 14px)`,outline:`none`,backgroundColor:`var(--grid-bg)`,color:`var(--grid-text)`},value:u,onChange:e=>d(e.target.value),children:[(0,Z.jsx)(`option`,{value:`equals`,children:`Equals`}),(0,Z.jsx)(`option`,{value:`before`,children:`Before`}),(0,Z.jsx)(`option`,{value:`after`,children:`After`}),(0,Z.jsx)(`option`,{value:`inRange`,children:`In Range`})]})]}),(0,Z.jsxs)(`div`,{style:{marginBottom:`12px`},children:[(0,Z.jsx)(`label`,{style:{display:`block`,fontSize:`var(--grid-font-size, 14px)`,fontWeight:500,color:`var(--grid-text)`,marginBottom:`4px`},children:`Date`}),(0,Z.jsx)(`input`,{type:`date`,style:{width:`100%`,padding:`8px 12px`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,fontSize:`var(--grid-font-size, 14px)`,outline:`none`,backgroundColor:`var(--grid-bg)`,color:`var(--grid-text)`},value:f,onChange:e=>p(e.target.value),autoFocus:!0})]}),u===`inRange`&&(0,Z.jsxs)(`div`,{style:{marginBottom:`12px`},children:[(0,Z.jsx)(`label`,{style:{display:`block`,fontSize:`var(--grid-font-size, 14px)`,fontWeight:500,color:`var(--grid-text)`,marginBottom:`4px`},children:`To`}),(0,Z.jsx)(`input`,{type:`date`,style:{width:`100%`,padding:`8px 12px`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,fontSize:`var(--grid-font-size, 14px)`,outline:`none`,backgroundColor:`var(--grid-bg)`,color:`var(--grid-text)`},value:m,onChange:e=>h(e.target.value)})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,justifyContent:`flex-end`},children:[(0,Z.jsx)(`button`,{style:{padding:`6px 12px`,fontSize:`var(--grid-font-size, 14px)`,color:`var(--grid-text)`,backgroundColor:`var(--grid-bg-alt)`,border:`none`,borderRadius:`var(--grid-border-radius, 6px)`,cursor:`pointer`},onClick:()=>{p(``),h(``),t(null),n()},onMouseEnter:e=>e.currentTarget.style.backgroundColor=`var(--grid-hover)`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`var(--grid-bg-alt)`,children:`Clear`}),(0,Z.jsx)(`button`,{style:{padding:`6px 12px`,fontSize:`var(--grid-font-size, 14px)`,color:`var(--grid-text-inverse)`,backgroundColor:`var(--grid-primary)`,border:`none`,borderRadius:`var(--grid-border-radius, 6px)`,cursor:`pointer`},onClick:()=>{if(f){let e={type:u,value:f};u===`inRange`&&m&&(e.value2=m),t(e)}else t(null);n()},onMouseEnter:e=>e.currentTarget.style.backgroundColor=`var(--grid-primary-hover)`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`var(--grid-primary)`,children:`Apply`})]})]})},ir=({column:e,filterValue:t,onApplyFilter:n,onClose:r,rows:i,anchorEl:a,showAdvancedButton:o,onSwitchToAdvanced:s})=>{let c=Array.from(new Set(i.map(t=>t[e.field]).filter(e=>e!=null))),l=er(t)?null:t,[u,d]=(0,b.useState)(l&&l.values?new Set(l.values):new Set),[f,p]=(0,b.useState)(``),m=c.filter(e=>String(e).toLowerCase().includes(f.toLowerCase())),h=e=>{let t=new Set(u);t.has(e)?t.delete(e):t.add(e),d(t)};return(0,Z.jsxs)(`div`,{style:{position:`fixed`,top:a?a.getBoundingClientRect().bottom+5:0,left:a?a.getBoundingClientRect().left:0,minWidth:`280px`,maxHeight:`400px`,backgroundColor:`var(--grid-bg)`,boxShadow:`var(--grid-shadow, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05))`,borderRadius:`var(--grid-border-radius, 8px)`,border:`1px solid var(--grid-border)`,padding:`16px`,zIndex:1e3,display:`flex`,flexDirection:`column`},onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`div`,{style:{marginBottom:`12px`},children:(0,Z.jsx)(`input`,{type:`text`,style:{width:`100%`,padding:`8px 12px`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,fontSize:`var(--grid-font-size, 14px)`,outline:`none`,backgroundColor:`var(--grid-bg)`,color:`var(--grid-text)`},value:f,onChange:e=>p(e.target.value),placeholder:`Search values...`,autoFocus:!0})}),(0,Z.jsx)(`div`,{style:{marginBottom:`8px`},children:(0,Z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,cursor:`pointer`,padding:`8px`,borderRadius:`4px`},onMouseEnter:e=>e.currentTarget.style.backgroundColor=`var(--grid-hover)`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`transparent`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:u.size===m.length&&m.length>0,onChange:()=>{u.size===m.length?d(new Set):d(new Set(m))},style:{width:`16px`,height:`16px`,cursor:`pointer`}}),(0,Z.jsx)(`span`,{style:{fontSize:`var(--grid-font-size, 14px)`,fontWeight:500,color:`var(--grid-text)`},children:`(Select All)`})]})}),(0,Z.jsx)(`div`,{style:{flex:1,overflowY:`auto`,marginBottom:`12px`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,maxHeight:`200px`},children:m.map((e,t)=>(0,Z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,cursor:`pointer`,padding:`8px`},onMouseEnter:e=>e.currentTarget.style.backgroundColor=`var(--grid-hover)`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`transparent`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:u.has(e),onChange:()=>h(e),style:{width:`16px`,height:`16px`,cursor:`pointer`}}),(0,Z.jsx)(`span`,{style:{fontSize:`var(--grid-font-size, 14px)`,color:`var(--grid-text)`},children:String(e)})]},t))}),(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,justifyContent:`flex-end`,paddingTop:`8px`,borderTop:`1px solid var(--grid-border)`},children:[(0,Z.jsx)(`button`,{style:{padding:`6px 12px`,fontSize:`var(--grid-font-size, 14px)`,color:`var(--grid-text)`,backgroundColor:`var(--grid-bg-alt)`,border:`none`,borderRadius:`var(--grid-border-radius, 6px)`,cursor:`pointer`},onClick:()=>{d(new Set),n(null),r()},onMouseEnter:e=>e.currentTarget.style.backgroundColor=`var(--grid-hover)`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`var(--grid-bg-alt)`,children:`Clear`}),(0,Z.jsxs)(`button`,{style:{padding:`6px 12px`,fontSize:`var(--grid-font-size, 14px)`,color:`var(--grid-text-inverse)`,backgroundColor:`var(--grid-primary)`,border:`none`,borderRadius:`var(--grid-border-radius, 6px)`,cursor:`pointer`},onClick:()=>{u.size>0?n({type:`set`,values:Array.from(u)}):n(null),r()},onMouseEnter:e=>e.currentTarget.style.backgroundColor=`var(--grid-primary-hover)`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`var(--grid-primary)`,children:[`Apply (`,u.size,`)`]})]})]})},ar=({column:e,filterValue:t,onApplyFilter:n,onClose:r,rows:i,anchorEl:a})=>(0,Z.jsx)(ir,{column:e,filterValue:t,onApplyFilter:n,onClose:r,rows:i,anchorEl:a});const or=({columns:e,displayColumnOrder:t,columnWidths:n,filterConfig:r,dispatch:i,pinnedLeft:a,pinnedRight:o,rows:s})=>{let[c,l]=(0,b.useState)(null),[u,d]=(0,b.useState)({}),[f,p]=(0,b.useState)(null),m=new Set(a),h=new Set(o),g={},_=0;a.forEach(e=>{g[e]=_,_+=n[e]||150});let v={},y=0;[...o].reverse().forEach(e=>{v[e]=y,y+=n[e]||150});let x=new Map(e.map(e=>[e.field,e])),S=e=>{let t={width:`${n[e]||150}px`};return m.has(e)?(t.position=`sticky`,t.left=`${g[e]}px`,t.zIndex=20,t.backgroundColor=`var(--grid-header-bg)`):h.has(e)&&(t.position=`sticky`,t.right=`${v[e]}px`,t.zIndex=20,t.backgroundColor=`var(--grid-header-bg)`),t},C=e=>{if(e.filterType)return e.filterType;let t=e.field.toLowerCase();return t.includes(`date`)||t.includes(`time`)?`date`:t.includes(`salary`)||t.includes(`price`)||t.includes(`amount`)||t.includes(`count`)?`number`:t.includes(`status`)||t.includes(`department`)||t.includes(`category`)?`set`:`text`},w=(e,t)=>{t.stopPropagation();let n=r[e];er(n)||t.shiftKey?(d({...u,[e]:t.currentTarget}),p(e),l(null)):(d({...u,[e]:t.currentTarget}),l(e),p(null))},T=()=>{l(null),p(null)},E=(e,t)=>{i({type:`SET_FILTER`,payload:{field:e,value:t}})},D=e=>{l(null),p(e)};(0,b.useEffect)(()=>{let e=()=>{c&&l(null)};if(c)return document.addEventListener(`click`,e),()=>document.removeEventListener(`click`,e)},[c]);let O=e=>{let t=C(e),n={column:e,filterValue:r[e.field],onApplyFilter:t=>E(e.field,t),onClose:T,rows:s,anchorEl:u[e.field],showAdvancedButton:!0,onSwitchToAdvanced:()=>D(e.field)};switch(t){case`number`:return(0,Z.jsx)(nr,{...n});case`date`:return(0,Z.jsx)(rr,{...n});case`set`:return(0,Z.jsx)(ir,{...n});case`multi`:return(0,Z.jsx)(ar,{...n});default:return(0,Z.jsx)(tr,{...n})}},k=e=>{let t=r[e.field],n=u[e.field];return(0,Z.jsx)($n,{column:e,filterValue:er(t)?t:null,onApply:t=>E(e.field,t),onClose:T,rows:s,anchorEl:n})},A=e=>{let t=r[e];if(!t)return``;if(er(t)){let e=t.conditions.length;return`${e} condition${e>1?`s`:``} (${t.operator})`}return t.type===`set`&&t.values?`${t.values.length} selected`:t.type===`inRange`?`${t.value} - ${t.value2}`:String(t.value||``)},j=e=>!!r[e];return(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(`div`,{style:{display:`flex`,minWidth:`100%`,borderBottom:`1px solid var(--grid-border)`,backgroundColor:`var(--grid-header-bg)`},children:t.map(e=>{let t=x.get(e);if(!t||t.filterable===!1)return(0,Z.jsx)(`div`,{style:{...S(e),borderRight:`1px solid var(--grid-border)`,flexShrink:0,minHeight:`38px`}},e);let n=j(e);return(0,Z.jsxs)(`div`,{style:{...S(e),borderRight:`1px solid var(--grid-border)`,flexShrink:0,padding:`6px 8px`,position:`relative`,display:`flex`,alignItems:`center`},children:[(0,Z.jsx)(`div`,{style:{width:`100%`,cursor:`pointer`},onClick:t=>w(e,t),title:`Click to filter, Shift+Click for advanced filter`,children:(0,Z.jsxs)(`div`,{style:{width:`100%`,padding:`4px 8px`,fontSize:`var(--grid-font-size-sm, 12px)`,border:`1px solid`,borderColor:n?`var(--grid-primary)`:`var(--grid-border)`,borderRadius:`var(--grid-border-radius, 4px)`,backgroundColor:n?`var(--grid-primary-bg)`:`var(--grid-bg)`,color:n?`var(--grid-primary)`:`var(--grid-text-secondary)`,display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:`6px`,transition:`border-color 0.15s`},onMouseEnter:e=>{n||(e.currentTarget.style.borderColor=`var(--grid-border-hover)`)},onMouseLeave:e=>{n||(e.currentTarget.style.borderColor=`var(--grid-border)`)},children:[(0,Z.jsx)(`span`,{style:{flex:1,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:n?A(e):`Filter...`}),(0,Z.jsx)(`svg`,{style:{flexShrink:0,color:n?`var(--grid-primary)`:`var(--grid-text-muted)`},width:`12`,height:`12`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,strokeWidth:`2.5`,children:(0,Z.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M3 4h18v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V20l-4-2v-3.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z`})})]})}),c===e&&O(t),f===e&&k(t)]},e)})})})};var sr=class{async save(e,t){try{let n=localStorage.getItem(e),r=n?JSON.parse(n):[],i=r.findIndex(e=>e.id===t.id);i===-1?r.push(t):r[i]=t,localStorage.setItem(e,JSON.stringify(r))}catch(e){throw console.error(`Failed to save preset to localStorage:`,e),e}}async load(e,t){try{let n=localStorage.getItem(e);if(!n)return null;let r=JSON.parse(n);return t?r.find(e=>e.id===t)||null:r}catch(e){throw console.error(`Failed to load preset from localStorage:`,e),e}}async delete(e,t){try{let n=localStorage.getItem(e);if(!n)return;let r=JSON.parse(n).filter(e=>e.id!==t);localStorage.setItem(e,JSON.stringify(r))}catch(e){throw console.error(`Failed to delete preset from localStorage:`,e),e}}async list(e){try{let t=localStorage.getItem(e);return t?JSON.parse(t):[]}catch(e){throw console.error(`Failed to list presets from localStorage:`,e),e}}},cr=class{config;constructor(e){this.config=e}async save(e,t){let n=this.config.saveEndpoint||`${this.config.baseUrl}/layouts`;try{let r=await fetch(n,{method:`POST`,headers:{"Content-Type":`application/json`,...this.config.headers},body:JSON.stringify({key:e,preset:t})});if(!r.ok)throw Error(`Server responded with ${r.status}`)}catch(e){throw console.error(`Failed to save preset to server:`,e),e}}async load(e,t){let n=this.config.loadEndpoint||`${this.config.baseUrl}/layouts`,r=t?`${n}/${e}/${t}`:`${n}/${e}`;try{let e=await fetch(r,{method:`GET`,headers:{"Content-Type":`application/json`,...this.config.headers}});if(e.status===404)return null;if(!e.ok)throw Error(`Server responded with ${e.status}`);return await e.json()}catch(e){throw console.error(`Failed to load preset from server:`,e),e}}async delete(e,t){let n=`${this.config.deleteEndpoint||`${this.config.baseUrl}/layouts`}/${e}/${t}`;try{let e=await fetch(n,{method:`DELETE`,headers:this.config.headers});if(!e.ok)throw Error(`Server responded with ${e.status}`)}catch(e){throw console.error(`Failed to delete preset from server:`,e),e}}async list(e){let t=`${this.config.listEndpoint||`${this.config.baseUrl}/layouts`}/${e}`;try{let e=await fetch(t,{method:`GET`,headers:{"Content-Type":`application/json`,...this.config.headers}});if(e.status===404)return[];if(!e.ok)throw Error(`Server responded with ${e.status}`);return await e.json()}catch(e){throw console.error(`Failed to list presets from server:`,e),e}}},lr=class{config;baseAdapter;constructor(e){this.config=e,this.baseAdapter=e.adapter||new sr}getUserKey(e){return`${this.config.profileKey||`user-layouts`}:${this.config.userId}:${e}`}async save(e,t){return this.baseAdapter.save(this.getUserKey(e),t)}async load(e,t){return this.baseAdapter.load(this.getUserKey(e),t)}async delete(e,t){return this.baseAdapter.delete(this.getUserKey(e),t)}async list(e){return this.baseAdapter.list(this.getUserKey(e))}};function ur(e){if(e.customAdapter)return e.customAdapter;switch(e.strategy){case`server`:if(!e.serverConfig)throw Error(`Server configuration is required for server storage strategy`);return new cr(e.serverConfig);case`userProfile`:if(!e.userProfileConfig)throw Error(`User profile configuration is required for userProfile storage strategy`);return new lr(e.userProfileConfig);case`localStorage`:default:return new sr}}function dr(){return`preset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function fr(e,t,n,r){let i=Date.now();return{id:r||dr(),name:e,description:n,createdAt:i,updatedAt:i,layout:t}}var pr=class{adapter;storageKey;constructor(e){this.adapter=ur(e),this.storageKey=e.storageKey}async savePreset(e){let t={...e,updatedAt:Date.now()};await this.adapter.save(this.storageKey,t)}async loadPreset(e){let t=await this.adapter.load(this.storageKey,e);return Array.isArray(t)?t.find(t=>t.id===e)||null:t}async loadLastPreset(){let e=await this.listPresets();return e.length===0?null:e.reduce((e,t)=>t.updatedAt>e.updatedAt?t:e)}async deletePreset(e){await this.adapter.delete(this.storageKey,e)}async listPresets(){return await this.adapter.list(this.storageKey)}async hasPreset(e){return await this.loadPreset(e)!==null}async autoSave(e){let t=fr(`Auto-saved Layout`,e,`Automatically saved layout`,`__autosave__`);await this.savePreset(t)}async loadAutoSave(){return await this.loadPreset(`__autosave__`)}};function mr(e,t){let n=null;return function(...r){n&&clearTimeout(n),n=setTimeout(()=>{e.apply(this,r),n=null},t)}}const hr=({manager:e,currentLayout:t,onLoadPreset:n,onResetLayout:r})=>{let[i,a]=(0,b.useState)([]),[o,s]=(0,b.useState)(!1),[c,l]=(0,b.useState)(!1),[u,d]=(0,b.useState)(``),[f,p]=(0,b.useState)(``),[m,h]=(0,b.useState)(!1),[g,_]=(0,b.useState)(null),v=(0,b.useCallback)(async()=>{try{h(!0),a((await e.listPresets()).filter(e=>e.id!==`__autosave__`)),_(null)}catch(e){_(`Failed to load presets`),console.error(e)}finally{h(!1)}},[e]);(0,b.useEffect)(()=>{v()},[v]);let y=async()=>{if(!u.trim()){_(`Please enter a preset name`);return}try{h(!0);let{createPreset:n}=await w(async()=>{let{createPreset:e}=await import(`./layoutPersistence-BHB0W18y.js`);return{createPreset:e}},[]),r=n(u.trim(),t,f.trim());await e.savePreset(r),await v(),l(!1),d(``),p(``),_(null)}catch(e){_(`Failed to save preset`),console.error(e)}finally{h(!1)}},x=async t=>{try{h(!0);let r=await e.loadPreset(t);r&&(n(r.layout),s(!1),_(null))}catch(e){_(`Failed to load preset`),console.error(e)}finally{h(!1)}},S=async(t,n)=>{if(n.stopPropagation(),confirm(`Are you sure you want to delete this preset?`))try{h(!0),await e.deletePreset(t),await v(),_(null)}catch(e){_(`Failed to delete preset`),console.error(e)}finally{h(!1)}},C=async(n,r)=>{if(r.stopPropagation(),confirm(`Update this preset with current layout?`))try{h(!0);let r={...n,layout:t};await e.savePreset(r),await v(),_(null)}catch(e){_(`Failed to update preset`),console.error(e)}finally{h(!1)}},T=e=>new Date(e).toLocaleString();return(0,Z.jsxs)(`div`,{className:`relative inline-block`,children:[(0,Z.jsxs)(`button`,{onClick:()=>s(!o),style:{padding:`6px 12px`,fontSize:`14px`,backgroundColor:`white`,border:`1px solid #d1d5db`,borderRadius:`4px`,cursor:`pointer`,display:`flex`,alignItems:`center`,gap:`8px`},disabled:m,children:[(0,Z.jsx)(`svg`,{style:{width:`14px`,height:`14px`,flexShrink:0},fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,Z.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M4 7h16M4 12h16M4 17h16`})}),`Layout Presets`,(0,Z.jsx)(`svg`,{style:{width:`14px`,height:`14px`,flexShrink:0,transform:o?`rotate(180deg)`:`rotate(0deg)`,transition:`transform 0.2s`},fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,Z.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M19 9l-7 7-7-7`})})]}),o&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{style:{position:`fixed`,inset:0,zIndex:10},onClick:()=>s(!1)}),(0,Z.jsxs)(`div`,{style:{position:`absolute`,right:0,marginTop:`8px`,width:`320px`,backgroundColor:`white`,border:`1px solid #d1d5db`,borderRadius:`8px`,boxShadow:`0 10px 15px -3px rgba(0, 0, 0, 0.1)`,zIndex:20,maxHeight:`384px`,overflowY:`auto`},children:[(0,Z.jsx)(`div`,{style:{padding:`12px`,borderBottom:`1px solid #e5e7eb`,backgroundColor:`#f9fafb`},children:(0,Z.jsx)(`h3`,{style:{fontWeight:`600`,fontSize:`14px`,color:`#111827`},children:`Layout Presets`})}),g&&(0,Z.jsx)(`div`,{style:{padding:`12px`,backgroundColor:`#fef2f2`,borderBottom:`1px solid #fecaca`},children:(0,Z.jsx)(`p`,{style:{fontSize:`14px`,color:`#dc2626`},children:g})}),(0,Z.jsxs)(`div`,{style:{padding:`8px`,borderBottom:`1px solid #e5e7eb`,display:`flex`,gap:`8px`},children:[(0,Z.jsxs)(`button`,{onClick:()=>{l(!0),s(!1)},style:{flex:1,padding:`8px 12px`,fontSize:`14px`,backgroundColor:`#2563eb`,color:`white`,border:`none`,borderRadius:`4px`,cursor:`pointer`,display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`8px`},children:[(0,Z.jsx)(`svg`,{style:{width:`14px`,height:`14px`,flexShrink:0},fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,Z.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M8 7H5a2 2 0 00-2 2v9a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-3m-1 4l-3 3m0 0l-3-3m3 3V4`})}),`Save Current`]}),(0,Z.jsxs)(`button`,{onClick:()=>{r(),s(!1)},style:{flex:1,padding:`8px 12px`,fontSize:`14px`,backgroundColor:`#4b5563`,color:`white`,border:`none`,borderRadius:`4px`,cursor:`pointer`,display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`8px`},children:[(0,Z.jsx)(`svg`,{style:{width:`14px`,height:`14px`,flexShrink:0},fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,Z.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15`})}),`Reset`]})]}),(0,Z.jsx)(`div`,{style:{maxHeight:`256px`,overflowY:`auto`},children:m&&i.length===0?(0,Z.jsx)(`div`,{style:{padding:`16px`,textAlign:`center`,color:`#6b7280`,fontSize:`14px`},children:`Loading presets...`}):i.length===0?(0,Z.jsx)(`div`,{style:{padding:`16px`,textAlign:`center`,color:`#6b7280`,fontSize:`14px`},children:`No saved presets. Save your current layout to get started.`}):(0,Z.jsx)(`div`,{children:i.map(e=>(0,Z.jsx)(`div`,{style:{padding:`12px`,cursor:`pointer`,borderBottom:`1px solid #e5e7eb`},onClick:()=>x(e.id),onMouseEnter:e=>{e.currentTarget.style.backgroundColor=`#f9fafb`;let t=e.currentTarget.querySelector(`.preset-actions`);t&&(t.style.opacity=`1`)},onMouseLeave:e=>{e.currentTarget.style.backgroundColor=`transparent`;let t=e.currentTarget.querySelector(`.preset-actions`);t&&(t.style.opacity=`0`)},children:(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,justifyContent:`space-between`},children:[(0,Z.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,Z.jsx)(`h4`,{style:{fontSize:`14px`,fontWeight:`500`,color:`#111827`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.name}),e.description&&(0,Z.jsx)(`p`,{style:{fontSize:`12px`,color:`#6b7280`,marginTop:`4px`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.description}),(0,Z.jsxs)(`p`,{style:{fontSize:`12px`,color:`#9ca3af`,marginTop:`4px`},children:[`Updated: `,T(e.updatedAt)]})]}),(0,Z.jsxs)(`div`,{className:`preset-actions`,style:{display:`flex`,gap:`4px`,marginLeft:`8px`,opacity:0,transition:`opacity 0.2s`},children:[(0,Z.jsx)(`button`,{onClick:t=>C(e,t),style:{padding:`4px`,color:`#2563eb`,backgroundColor:`transparent`,border:`none`,borderRadius:`4px`,cursor:`pointer`},onMouseEnter:e=>e.currentTarget.style.backgroundColor=`#eff6ff`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`transparent`,title:`Update with current layout`,children:(0,Z.jsx)(`svg`,{style:{width:`14px`,height:`14px`},fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,Z.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15`})})}),(0,Z.jsx)(`button`,{onClick:t=>S(e.id,t),style:{padding:`4px`,color:`#dc2626`,backgroundColor:`transparent`,border:`none`,borderRadius:`4px`,cursor:`pointer`},onMouseEnter:e=>e.currentTarget.style.backgroundColor=`#fef2f2`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`transparent`,title:`Delete preset`,children:(0,Z.jsx)(`svg`,{style:{width:`14px`,height:`14px`},fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,Z.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16`})})})]})]})},e.id))})})]})]}),c&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{style:{position:`fixed`,inset:0,backgroundColor:`rgba(0, 0, 0, 0.5)`,zIndex:30,display:`flex`,alignItems:`center`,justifyContent:`center`},onClick:()=>l(!1)}),(0,Z.jsx)(`div`,{style:{position:`fixed`,inset:0,zIndex:40,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`16px`},children:(0,Z.jsxs)(`div`,{style:{backgroundColor:`white`,borderRadius:`8px`,boxShadow:`0 25px 50px -12px rgba(0, 0, 0, 0.25)`,maxWidth:`448px`,width:`100%`,padding:`24px`},onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`h2`,{style:{fontSize:`20px`,fontWeight:`600`,marginBottom:`16px`},children:`Save Layout Preset`}),g&&(0,Z.jsx)(`div`,{style:{marginBottom:`16px`,padding:`12px`,backgroundColor:`#fef2f2`,border:`1px solid #fecaca`,borderRadius:`4px`},children:(0,Z.jsx)(`p`,{style:{fontSize:`14px`,color:`#dc2626`},children:g})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{style:{marginBottom:`16px`},children:[(0,Z.jsx)(`label`,{htmlFor:`preset-name`,style:{display:`block`,fontSize:`14px`,fontWeight:`500`,color:`#374151`,marginBottom:`4px`},children:`Preset Name *`}),(0,Z.jsx)(`input`,{id:`preset-name`,type:`text`,value:u,onChange:e=>d(e.target.value),style:{width:`100%`,padding:`8px 12px`,border:`1px solid #d1d5db`,borderRadius:`4px`,fontSize:`14px`},placeholder:`e.g., Sales Dashboard Layout`,autoFocus:!0})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{htmlFor:`preset-description`,style:{display:`block`,fontSize:`14px`,fontWeight:`500`,color:`#374151`,marginBottom:`4px`},children:`Description (optional)`}),(0,Z.jsx)(`textarea`,{id:`preset-description`,value:f,onChange:e=>p(e.target.value),style:{width:`100%`,padding:`8px 12px`,border:`1px solid #d1d5db`,borderRadius:`4px`,fontSize:`14px`},placeholder:`Add a description...`,rows:3})]})]}),(0,Z.jsxs)(`div`,{style:{marginTop:`24px`,display:`flex`,gap:`12px`,justifyContent:`flex-end`},children:[(0,Z.jsx)(`button`,{onClick:()=>{l(!1),d(``),p(``),_(null)},style:{padding:`8px 16px`,fontSize:`14px`,color:`#374151`,backgroundColor:`#f3f4f6`,border:`none`,borderRadius:`4px`,cursor:`pointer`},onMouseEnter:e=>e.currentTarget.style.backgroundColor=`#e5e7eb`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`#f3f4f6`,disabled:m,children:`Cancel`}),(0,Z.jsx)(`button`,{onClick:y,style:{padding:`8px 16px`,fontSize:`14px`,color:`white`,backgroundColor:`#2563eb`,border:`none`,borderRadius:`4px`,cursor:`pointer`},onMouseEnter:e=>e.currentTarget.style.backgroundColor=`#1d4ed8`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`#2563eb`,disabled:m,children:m?`Saving...`:`Save Preset`})]})]})})]})]})},gr=({x:e,y:t,items:n,onClose:r})=>{let i=(0,b.useRef)(null);(0,b.useEffect)(()=>{let e=e=>{i.current&&!i.current.contains(e.target)&&r()},t=e=>{i.current&&!i.current.contains(e.target)&&(e.preventDefault(),r())},n=setTimeout(()=>{document.addEventListener(`mousedown`,e),document.addEventListener(`contextmenu`,t)},100);return()=>{clearTimeout(n),document.removeEventListener(`mousedown`,e),document.removeEventListener(`contextmenu`,t)}},[r]),(0,b.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[r]),(0,b.useEffect)(()=>{if(i.current){let n=i.current,r=n.getBoundingClientRect(),a=window.innerWidth,o=window.innerHeight,s=e,c=t;r.right>a&&(s=a-r.width-10),r.bottom>o&&(c=o-r.height-10),(s!==e||c!==t)&&(n.style.left=`${s}px`,n.style.top=`${c}px`)}},[e,t]);let a=(0,b.useCallback)(e=>{e.disabled||e.type===`separator`||(e.onClick&&e.onClick(),e.submenu||r())},[r]),o=(e,t)=>e.type===`separator`?(0,Z.jsx)(`div`,{className:`context-menu-separator`,role:`separator`},`separator-${t}`):(0,Z.jsxs)(`div`,{className:`context-menu-item ${e.disabled?`disabled`:``} ${e.danger?`danger`:``}`,onClick:()=>a(e),role:`menuitem`,"aria-disabled":e.disabled,tabIndex:e.disabled?-1:0,children:[e.icon&&(0,Z.jsx)(`span`,{className:`context-menu-icon`,children:e.icon}),(0,Z.jsx)(`span`,{className:`context-menu-label`,children:e.label}),e.shortcut&&(0,Z.jsx)(`span`,{className:`context-menu-shortcut`,children:e.shortcut}),e.submenu&&(0,Z.jsx)(`span`,{className:`context-menu-arrow`,children:`▶`})]},e.id||t);return(0,Z.jsx)(`div`,{ref:i,className:`context-menu`,style:{left:e,top:t},role:`menu`,"aria-label":`Context menu`,children:n.map((e,t)=>o(e,t))})},_r=async(e,t,n,r=!1)=>{let i=Array.from(e),a=n.filter(e=>i.includes(e.id));if(a.length===0)return;let o=``;r&&(o+=t.map(e=>e.headerName).join(` `)+`
40
+ `);Wn(new Blob([a],{type:`text/csv;charset=utf-8;`}),n)},Hn=async(e,t,n={})=>{let{filename:r=`export.xlsx`,styling:i=`basic`}=n,a=new Bn.default.Workbook,o=a.addWorksheet(`Sheet1`),s=t.map(e=>e.headerName);o.addRow(s),e.forEach(e=>{let n=t.map(t=>e[t.field]??``);o.addRow(n)}),o.columns=t.map(t=>{let n=t.headerName.length,r=Math.max(...e.map(e=>String(e[t.field]??``).length)),i=Math.max(n,r)+2;return{width:Math.min(i,50)}}),i===`professional`&&Un(o,t);let c=await a.xlsx.writeBuffer();Wn(new Blob([c],{type:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`}),r)};var Un=(e,t)=>{let n=e.getRow(1);n.font={bold:!0,color:{argb:`FFFFFFFF`},size:11},n.fill={type:`pattern`,pattern:`solid`,fgColor:{argb:`FF2F5496`}},n.alignment={horizontal:`center`,vertical:`middle`,wrapText:!0},n.height=20,e.eachRow((e,t)=>{e.eachCell(e=>{e.border={top:{style:`thin`,color:{argb:`FFD3D3D3`}},left:{style:`thin`,color:{argb:`FFD3D3D3`}},bottom:{style:`thin`,color:{argb:`FFD3D3D3`}},right:{style:`thin`,color:{argb:`FFD3D3D3`}}},t>1&&t%2==0&&(e.fill={type:`pattern`,pattern:`solid`,fgColor:{argb:`FFF2F2F2`}}),t>1&&(e.alignment={horizontal:`left`,vertical:`middle`})})}),e.views=[{state:`frozen`,ySplit:1}]},Wn=(e,t)=>{let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)};const Gn=(e,t)=>{let n=new Date().toISOString().replace(/[:.]/g,`-`).slice(0,-5);return`data_export_${t===`all`?`full`:t}_${n}.${e}`},Kn=async(e,t,n)=>{if(e.length===0){alert(`No data to export`);return}let r=n.filename||Gn(n.format,n.scope);n.format===`csv`?Vn(e,t,r):n.format===`xlsx`&&await Hn(e,t,{filename:r,styling:n.styling})},qn=({columns:e,fullDataset:t,filteredData:n,selectedRows:r,currentPageData:i,onExport:a})=>{let[o,s]=(0,b.useState)(!1),[c,l]=(0,b.useState)(`csv`),[u,d]=(0,b.useState)(`filtered`),[f,p]=(0,b.useState)(`basic`),[m,h]=(0,b.useState)(null),g=b.useRef(null),_=()=>{switch(u){case`all`:return t;case`filtered`:return n;case`selected`:return r.size>0?n.filter(e=>r.has(e.id)):[];case`page`:return i;default:return n}},v=()=>{let t=_();if(t.length===0){alert(`No ${u===`selected`?`selected`:u} data to export`);return}Kn(t,e,{format:c,scope:u,styling:c===`xlsx`?f:void 0}),a?.(!0),s(!1)},y=[{value:`all`,label:`Full Dataset`,disabled:!1},{value:`filtered`,label:`Filtered Data`,disabled:n.length===0},{value:`selected`,label:`Selected Rows (${r.size})`,disabled:r.size===0},{value:`page`,label:`Current Page`,disabled:i.length===0}];return(0,Z.jsxs)(`div`,{style:{position:`relative`},children:[(0,Z.jsxs)(`button`,{ref:g,onClick:()=>{if(!o){let e=g.current?.getBoundingClientRect();e&&h(e)}s(!o)},style:{padding:`8px 12px`,backgroundColor:`#2563eb`,color:`white`,borderRadius:`6px`,border:`none`,fontSize:`14px`,fontWeight:`500`,display:`flex`,alignItems:`center`,gap:`8px`,cursor:`pointer`,transition:`background-color 0.2s`},onMouseEnter:e=>{e.currentTarget.style.backgroundColor=`#1d4ed8`},onMouseLeave:e=>{e.currentTarget.style.backgroundColor=`#2563eb`},title:`Export data to CSV or XLSX format`,children:[(0,Z.jsx)(`svg`,{style:{width:`16px`,height:`16px`},fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,Z.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M12 19l9 2-9-18-9 18 9-2m0 0v-8m0 8l-6-4m6 4l6-4`})}),`Export`]}),o&&m&&(0,Z.jsxs)(`div`,{style:{position:`fixed`,left:`${m.left}px`,top:`${m.bottom+8}px`,backgroundColor:`#ffffff`,border:`1px solid #e5e7eb`,borderRadius:`8px`,boxShadow:`0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.05)`,zIndex:50,padding:`20px`,width:`420px`,minWidth:`420px`,maxWidth:`420px`,maxHeight:`90vh`,overflowY:`auto`},children:[(0,Z.jsxs)(`div`,{style:{marginBottom:`20px`},children:[(0,Z.jsx)(`label`,{style:{display:`block`,fontSize:`14px`,fontWeight:`600`,color:`#1f2937`,marginBottom:`12px`},children:`Format`}),(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:`16px`},children:[(0,Z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,cursor:`pointer`},children:[(0,Z.jsx)(`input`,{type:`radio`,name:`format`,value:`csv`,checked:c===`csv`,onChange:e=>l(e.target.value),style:{width:`16px`,height:`16px`,cursor:`pointer`}}),(0,Z.jsx)(`span`,{style:{fontSize:`14px`,color:`#374151`},children:`CSV`})]}),(0,Z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,cursor:`pointer`},children:[(0,Z.jsx)(`input`,{type:`radio`,name:`format`,value:`xlsx`,checked:c===`xlsx`,onChange:e=>l(e.target.value),style:{width:`16px`,height:`16px`,cursor:`pointer`}}),(0,Z.jsx)(`span`,{style:{fontSize:`14px`,color:`#374151`},children:`XLSX (Excel)`})]})]})]}),(0,Z.jsxs)(`div`,{style:{marginBottom:`20px`},children:[(0,Z.jsx)(`label`,{style:{display:`block`,fontSize:`14px`,fontWeight:`600`,color:`#1f2937`,marginBottom:`12px`},children:`Data Scope`}),(0,Z.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`10px`},children:y.map(e=>(0,Z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`10px`,padding:`10px 12px`,borderRadius:`6px`,cursor:e.disabled?`not-allowed`:`pointer`,opacity:e.disabled?.5:1,backgroundColor:`transparent`,transition:`background-color 0.15s`,userSelect:`none`},onMouseEnter:t=>{e.disabled||(t.currentTarget.style.backgroundColor=`#f3f4f6`)},onMouseLeave:e=>{e.currentTarget.style.backgroundColor=`transparent`},children:[(0,Z.jsx)(`input`,{type:`radio`,name:`scope`,value:e.value,checked:u===e.value,onChange:e=>d(e.target.value),disabled:e.disabled,style:{width:`16px`,height:`16px`,cursor:e.disabled?`not-allowed`:`pointer`}}),(0,Z.jsx)(`span`,{style:{fontSize:`14px`,color:`#374151`},children:e.label})]},e.value))})]}),c===`xlsx`&&(0,Z.jsxs)(`div`,{style:{marginBottom:`20px`},children:[(0,Z.jsx)(`label`,{style:{display:`block`,fontSize:`14px`,fontWeight:`600`,color:`#1f2937`,marginBottom:`12px`},children:`Styling`}),(0,Z.jsx)(`div`,{style:{marginBottom:`10px`},children:(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:`16px`},children:[(0,Z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,cursor:`pointer`},children:[(0,Z.jsx)(`input`,{type:`radio`,name:`styling`,value:`basic`,checked:f===`basic`,onChange:e=>p(e.target.value),style:{width:`16px`,height:`16px`,cursor:`pointer`}}),(0,Z.jsx)(`span`,{style:{fontSize:`14px`,color:`#374151`},children:`Basic`})]}),(0,Z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,cursor:`pointer`},children:[(0,Z.jsx)(`input`,{type:`radio`,name:`styling`,value:`professional`,checked:f===`professional`,onChange:e=>p(e.target.value),style:{width:`16px`,height:`16px`,cursor:`pointer`}}),(0,Z.jsx)(`span`,{style:{fontSize:`14px`,color:`#374151`},children:`Professional`})]})]})}),(0,Z.jsx)(`p`,{style:{fontSize:`12px`,color:`#6b7280`,margin:`0`},children:`Professional adds colors, borders, and frozen header row`})]}),(0,Z.jsxs)(`div`,{style:{backgroundColor:`#f3f4f6`,borderRadius:`6px`,padding:`12px`,marginBottom:`20px`,fontSize:`13px`,color:`#4b5563`},children:[(0,Z.jsxs)(`p`,{style:{margin:`6px 0`},children:[(0,Z.jsx)(`strong`,{children:`Data to export:`}),` `,_().length,` row(s)`]}),(0,Z.jsxs)(`p`,{style:{margin:`6px 0`},children:[(0,Z.jsx)(`strong`,{children:`Columns:`}),` `,e.length]})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:`10px`,justifyContent:`flex-end`},children:[(0,Z.jsx)(`button`,{onClick:()=>s(!1),style:{padding:`10px 16px`,border:`1px solid #d1d5db`,color:`#374151`,backgroundColor:`#ffffff`,borderRadius:`6px`,fontSize:`14px`,fontWeight:`500`,cursor:`pointer`,transition:`background-color 0.2s`},onMouseEnter:e=>{e.currentTarget.style.backgroundColor=`#f9fafb`},onMouseLeave:e=>{e.currentTarget.style.backgroundColor=`#ffffff`},children:`Cancel`}),(0,Z.jsx)(`button`,{onClick:v,disabled:_().length===0,style:{padding:`10px 16px`,backgroundColor:_().length===0?`#9ca3af`:`#2563eb`,color:`#ffffff`,borderRadius:`6px`,border:`none`,fontSize:`14px`,fontWeight:`500`,cursor:_().length===0?`not-allowed`:`pointer`,opacity:_().length===0?.6:1,transition:`background-color 0.2s`},onMouseEnter:e=>{_().length>0&&(e.currentTarget.style.backgroundColor=`#1d4ed8`)},onMouseLeave:e=>{_().length>0&&(e.currentTarget.style.backgroundColor=`#2563eb`)},children:`Export Now`})]})]}),o&&(0,Z.jsx)(`div`,{style:{position:`fixed`,inset:0,zIndex:40},onClick:()=>s(!1)})]})};var Jn=e=>{if(e.filterType)return e.filterType===`multi`?`set`:e.filterType;let t=e.field.toLowerCase();return t.includes(`date`)||t.includes(`time`)?`date`:t.includes(`salary`)||t.includes(`price`)||t.includes(`amount`)||t.includes(`count`)?`number`:t.includes(`status`)||t.includes(`department`)||t.includes(`category`)?`set`:`text`},Yn=e=>{switch(e){case`text`:return[{value:`contains`,label:`Contains`},{value:`notContains`,label:`Not Contains`},{value:`equals`,label:`Equals`},{value:`notEquals`,label:`Not Equals`},{value:`startsWith`,label:`Starts With`},{value:`endsWith`,label:`Ends With`},{value:`isEmpty`,label:`Is Empty`},{value:`isNotEmpty`,label:`Is Not Empty`}];case`number`:return[{value:`equals`,label:`Equals`},{value:`notEquals`,label:`Not Equals`},{value:`greaterThan`,label:`Greater Than`},{value:`greaterThanOrEqual`,label:`Greater Than or Equal`},{value:`lessThan`,label:`Less Than`},{value:`lessThanOrEqual`,label:`Less Than or Equal`},{value:`inRange`,label:`In Range`},{value:`isEmpty`,label:`Is Empty`},{value:`isNotEmpty`,label:`Is Not Empty`}];case`date`:return[{value:`equals`,label:`Equals`},{value:`before`,label:`Before`},{value:`after`,label:`After`},{value:`inRange`,label:`In Range`},{value:`isEmpty`,label:`Is Empty`},{value:`isNotEmpty`,label:`Is Not Empty`}];case`set`:return[{value:`in`,label:`In`},{value:`notIn`,label:`Not In`}];default:return[]}},Xn=e=>![`isEmpty`,`isNotEmpty`].includes(e),Zn=e=>e===`inRange`,Qn=e=>[`in`,`notIn`].includes(e);const $n=({column:e,filterValue:t,onApply:n,onClose:r,rows:i,anchorEl:a})=>{let o=Jn(e),s=Yn(o),c=t?.conditions||[{type:s[0]?.value||`contains`,value:``,value2:``,values:[]}],[l,u]=(0,b.useState)(t?.operator||`AND`),[d,f]=(0,b.useState)(c),[p,m]=(0,b.useState)({}),h=o===`set`?Array.from(new Set(i.map(t=>t[e.field]).filter(e=>e!=null))):[],g=()=>{f([...d,{type:s[0]?.value||`contains`,value:``,value2:``,values:[]}])},_=e=>{if(d.length>1){f(d.filter((t,n)=>n!==e));let t={...p};delete t[e],m(t)}},v=(e,t)=>{f(d.map((n,r)=>r===e?{...n,...t}:n))},y=(e,t)=>{m({...p,[e]:t})},x=()=>{let e=d.filter(e=>Xn(e.type)?Qn(e.type)?e.values&&e.values.length>0:Zn(e.type)?e.value!=null&&e.value!==``&&e.value2!=null&&e.value2!==``:e.value!=null&&e.value!==``:!0);e.length===0?n(null):n({operator:l,conditions:e}),r()},S=()=>{f([{type:s[0]?.value||`contains`,value:``,value2:``,values:[]}]),m({}),n(null)},C=()=>{f([{type:s[0]?.value||`contains`,value:``,value2:``,values:[]}]),u(`AND`),m({})},w=(e,t)=>{if(Qn(e.type)){let n=new Set(e.values||[]),r=p[t]?.searchTerm||``,i=h.filter(e=>String(e).toLowerCase().includes(r.toLowerCase())),a=e=>{let r=new Set(n);r.has(e)?r.delete(e):r.add(e),v(t,{values:Array.from(r)})};return(0,Z.jsxs)(`div`,{style:{marginTop:`8px`},children:[(0,Z.jsx)(`input`,{type:`text`,style:{width:`100%`,padding:`6px 10px`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 4px)`,fontSize:`var(--grid-font-size-sm, 12px)`,outline:`none`,backgroundColor:`var(--grid-bg)`,color:`var(--grid-text)`,marginBottom:`8px`},value:r,onChange:e=>y(t,{searchTerm:e.target.value}),placeholder:`Search values...`}),(0,Z.jsxs)(`div`,{style:{maxHeight:`150px`,overflowY:`auto`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 4px)`,padding:`4px`},children:[(0,Z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`6px`,cursor:`pointer`,padding:`4px 6px`,fontSize:`var(--grid-font-size-sm, 12px)`},children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:n.size===i.length&&i.length>0,onChange:()=>{n.size===i.length?v(t,{values:[]}):v(t,{values:i})},style:{width:`14px`,height:`14px`,cursor:`pointer`}}),(0,Z.jsx)(`span`,{style:{fontWeight:500,color:`var(--grid-text)`},children:`(Select All)`})]}),i.map((e,t)=>(0,Z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`6px`,cursor:`pointer`,padding:`4px 6px`,fontSize:`var(--grid-font-size-sm, 12px)`},children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:n.has(e),onChange:()=>a(e),style:{width:`14px`,height:`14px`,cursor:`pointer`}}),(0,Z.jsx)(`span`,{style:{color:`var(--grid-text)`},children:String(e)})]},t))]}),n.size>0&&(0,Z.jsxs)(`div`,{style:{marginTop:`6px`,fontSize:`var(--grid-font-size-sm, 12px)`,color:`var(--grid-primary)`,fontWeight:500},children:[n.size,` selected`]})]})}return Xn(e.type)?Zn(e.type)?(0,Z.jsxs)(`div`,{style:{marginTop:`8px`,display:`flex`,gap:`8px`,alignItems:`center`},children:[(0,Z.jsx)(`input`,{type:o===`date`?`date`:o===`number`?`number`:`text`,style:{flex:1,padding:`6px 10px`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 4px)`,fontSize:`var(--grid-font-size-sm, 12px)`,outline:`none`,backgroundColor:`var(--grid-bg)`,color:`var(--grid-text)`},value:e.value||``,onChange:e=>v(t,{value:e.target.value}),placeholder:`From`}),(0,Z.jsx)(`span`,{style:{color:`var(--grid-text-secondary)`,fontSize:`var(--grid-font-size-sm, 12px)`},children:`to`}),(0,Z.jsx)(`input`,{type:o===`date`?`date`:o===`number`?`number`:`text`,style:{flex:1,padding:`6px 10px`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 4px)`,fontSize:`var(--grid-font-size-sm, 12px)`,outline:`none`,backgroundColor:`var(--grid-bg)`,color:`var(--grid-text)`},value:e.value2||``,onChange:e=>v(t,{value2:e.target.value}),placeholder:`To`})]}):(0,Z.jsx)(`div`,{style:{marginTop:`8px`},children:(0,Z.jsx)(`input`,{type:o===`date`?`date`:o===`number`?`number`:`text`,style:{width:`100%`,padding:`6px 10px`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 4px)`,fontSize:`var(--grid-font-size-sm, 12px)`,outline:`none`,backgroundColor:`var(--grid-bg)`,color:`var(--grid-text)`},value:e.value||``,onChange:e=>v(t,{value:e.target.value}),placeholder:`Enter ${o}...`})}):null};return(0,Z.jsxs)(`div`,{style:{position:`fixed`,top:a?a.getBoundingClientRect().bottom+5:0,left:a?a.getBoundingClientRect().left:0,minWidth:`380px`,maxWidth:`450px`,maxHeight:`600px`,backgroundColor:`var(--grid-bg)`,boxShadow:`0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.1)`,borderRadius:`var(--grid-border-radius, 8px)`,border:`1px solid var(--grid-border)`,padding:`16px`,zIndex:1001,display:`flex`,flexDirection:`column`,overflowY:`auto`},onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(`div`,{style:{marginBottom:`16px`,paddingBottom:`12px`,borderBottom:`1px solid var(--grid-border)`},children:[(0,Z.jsxs)(`h4`,{style:{margin:0,fontSize:`var(--grid-font-size, 14px)`,fontWeight:600,color:`var(--grid-text)`},children:[`Advanced Filter: `,e.headerName]}),(0,Z.jsx)(`p`,{style:{margin:`4px 0 0 0`,fontSize:`var(--grid-font-size-sm, 12px)`,color:`var(--grid-text-secondary)`},children:`Add multiple conditions with AND/OR logic`})]}),d.length>1&&(0,Z.jsxs)(`div`,{style:{marginBottom:`16px`},children:[(0,Z.jsx)(`label`,{style:{display:`block`,fontSize:`var(--grid-font-size-sm, 12px)`,fontWeight:500,color:`var(--grid-text)`,marginBottom:`6px`},children:`Combine Conditions`}),(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:`8px`},children:[(0,Z.jsx)(`button`,{style:{flex:1,padding:`6px 12px`,fontSize:`var(--grid-font-size-sm, 12px)`,fontWeight:500,color:l===`AND`?`var(--grid-text-inverse)`:`var(--grid-text)`,backgroundColor:l===`AND`?`var(--grid-primary)`:`var(--grid-bg-alt)`,border:l===`AND`?`none`:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,cursor:`pointer`,transition:`all 0.15s`},onClick:()=>u(`AND`),children:`AND`}),(0,Z.jsx)(`button`,{style:{flex:1,padding:`6px 12px`,fontSize:`var(--grid-font-size-sm, 12px)`,fontWeight:500,color:l===`OR`?`var(--grid-text-inverse)`:`var(--grid-text)`,backgroundColor:l===`OR`?`var(--grid-primary)`:`var(--grid-bg-alt)`,border:l===`OR`?`none`:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,cursor:`pointer`,transition:`all 0.15s`},onClick:()=>u(`OR`),children:`OR`})]})]}),(0,Z.jsx)(`div`,{style:{flex:1,overflowY:`auto`,marginBottom:`12px`},children:d.map((e,t)=>(0,Z.jsxs)(`div`,{style:{marginBottom:`12px`,padding:`12px`,backgroundColor:`var(--grid-bg-alt)`,borderRadius:`var(--grid-border-radius, 6px)`,border:`1px solid var(--grid-border)`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:`8px`},children:[(0,Z.jsxs)(`label`,{style:{fontSize:`var(--grid-font-size-sm, 12px)`,fontWeight:500,color:`var(--grid-text)`},children:[`Condition `,t+1]}),d.length>1&&(0,Z.jsx)(`button`,{style:{padding:`2px 8px`,fontSize:`var(--grid-font-size-sm, 12px)`,color:`var(--grid-danger, #dc2626)`,backgroundColor:`transparent`,border:`none`,cursor:`pointer`,borderRadius:`var(--grid-border-radius, 4px)`},onClick:()=>_(t),onMouseEnter:e=>e.currentTarget.style.backgroundColor=`var(--grid-danger-bg, rgba(220, 38, 38, 0.1))`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`transparent`,title:`Remove condition`,children:`✕`})]}),(0,Z.jsx)(`select`,{style:{width:`100%`,padding:`6px 10px`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 4px)`,fontSize:`var(--grid-font-size-sm, 12px)`,outline:`none`,backgroundColor:`var(--grid-bg)`,color:`var(--grid-text)`},value:e.type,onChange:e=>v(t,{type:e.target.value,value:``,value2:``,values:[]}),children:s.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value))}),w(e,t),t<d.length-1&&d.length>1&&(0,Z.jsx)(`div`,{style:{marginTop:`12px`,padding:`4px 8px`,textAlign:`center`,fontSize:`var(--grid-font-size-sm, 12px)`,fontWeight:600,color:`var(--grid-primary)`,backgroundColor:`var(--grid-primary-bg)`,borderRadius:`var(--grid-border-radius, 4px)`},children:l})]},t))}),(0,Z.jsx)(`button`,{style:{width:`100%`,padding:`8px 12px`,marginBottom:`12px`,fontSize:`var(--grid-font-size-sm, 12px)`,fontWeight:500,color:`var(--grid-primary)`,backgroundColor:`var(--grid-primary-bg)`,border:`1px dashed var(--grid-primary)`,borderRadius:`var(--grid-border-radius, 6px)`,cursor:`pointer`,transition:`all 0.15s`},onClick:g,onMouseEnter:e=>e.currentTarget.style.backgroundColor=`var(--grid-primary-hover-bg)`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`var(--grid-primary-bg)`,children:`+ Add Condition`}),(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,paddingTop:`12px`,borderTop:`1px solid var(--grid-border)`},children:[(0,Z.jsx)(`button`,{style:{flex:1,padding:`8px 12px`,fontSize:`var(--grid-font-size-sm, 12px)`,fontWeight:500,color:`var(--grid-text)`,backgroundColor:`var(--grid-bg-alt)`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,cursor:`pointer`,transition:`all 0.15s`},onClick:C,onMouseEnter:e=>e.currentTarget.style.backgroundColor=`var(--grid-hover)`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`var(--grid-bg-alt)`,children:`Reset`}),(0,Z.jsx)(`button`,{style:{flex:1,padding:`8px 12px`,fontSize:`var(--grid-font-size-sm, 12px)`,fontWeight:500,color:`var(--grid-text)`,backgroundColor:`var(--grid-bg-alt)`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,cursor:`pointer`,transition:`all 0.15s`},onClick:S,onMouseEnter:e=>e.currentTarget.style.backgroundColor=`var(--grid-hover)`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`var(--grid-bg-alt)`,children:`Clear`}),(0,Z.jsx)(`button`,{style:{flex:1,padding:`8px 12px`,fontSize:`var(--grid-font-size-sm, 12px)`,fontWeight:500,color:`var(--grid-text-inverse)`,backgroundColor:`var(--grid-primary)`,border:`none`,borderRadius:`var(--grid-border-radius, 6px)`,cursor:`pointer`,transition:`all 0.15s`},onClick:x,onMouseEnter:e=>e.currentTarget.style.backgroundColor=`var(--grid-primary-hover)`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`var(--grid-primary)`,children:`Apply`})]})]})};var er=e=>e!=null&&`operator`in e&&`conditions`in e,tr=({filterValue:e,onApplyFilter:t,onClose:n,anchorEl:r,showAdvancedButton:i,onSwitchToAdvanced:a})=>{let o=er(e)?null:e,s=o?.type||`contains`,c=o?.value||``,[l,u]=(0,b.useState)(s),[d,f]=(0,b.useState)(c);return(0,Z.jsxs)(`div`,{style:{position:`fixed`,top:r?r.getBoundingClientRect().bottom+5:0,left:r?r.getBoundingClientRect().left:0,minWidth:`280px`,backgroundColor:`var(--grid-bg)`,boxShadow:`var(--grid-shadow-medium, 0 10px 15px -3px rgba(0, 0, 0, 0.1))`,borderRadius:`var(--grid-border-radius, 8px)`,border:`var(--grid-border-width, 1px) solid var(--grid-border)`,padding:`16px`,zIndex:1e3},onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(`div`,{style:{marginBottom:`12px`},children:[(0,Z.jsx)(`label`,{style:{display:`block`,fontSize:`var(--grid-font-size, 14px)`,fontWeight:500,color:`var(--grid-text)`,marginBottom:`4px`},children:`Filter Type`}),(0,Z.jsxs)(`select`,{style:{width:`100%`,padding:`8px 12px`,border:`var(--grid-border-width, 1px) solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,fontSize:`var(--grid-font-size, 14px)`,outline:`none`,backgroundColor:`var(--grid-bg)`,color:`var(--grid-text)`},value:l,onChange:e=>u(e.target.value),children:[(0,Z.jsx)(`option`,{value:`contains`,children:`Contains`}),(0,Z.jsx)(`option`,{value:`notContains`,children:`Not Contains`}),(0,Z.jsx)(`option`,{value:`equals`,children:`Equals`}),(0,Z.jsx)(`option`,{value:`startsWith`,children:`Starts With`}),(0,Z.jsx)(`option`,{value:`endsWith`,children:`Ends With`})]})]}),(0,Z.jsxs)(`div`,{style:{marginBottom:`12px`},children:[(0,Z.jsx)(`label`,{style:{display:`block`,fontSize:`var(--grid-font-size, 14px)`,fontWeight:500,color:`var(--grid-text)`,marginBottom:`4px`},children:`Value`}),(0,Z.jsx)(`input`,{type:`text`,style:{width:`100%`,padding:`8px 12px`,border:`var(--grid-border-width, 1px) solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,fontSize:`var(--grid-font-size, 14px)`,outline:`none`,backgroundColor:`var(--grid-bg)`,color:`var(--grid-text)`},value:d,onChange:e=>f(e.target.value),placeholder:`Enter text...`,autoFocus:!0})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,justifyContent:`flex-end`},children:[(0,Z.jsx)(`button`,{style:{padding:`6px 12px`,fontSize:`var(--grid-font-size, 14px)`,color:`var(--grid-text)`,backgroundColor:`var(--grid-bg-alt)`,border:`none`,borderRadius:`var(--grid-border-radius, 6px)`,cursor:`pointer`},onClick:()=>{f(``),t(null),n()},onMouseEnter:e=>e.currentTarget.style.backgroundColor=`var(--grid-hover)`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`var(--grid-bg-alt)`,children:`Clear`}),(0,Z.jsx)(`button`,{style:{padding:`6px 12px`,fontSize:`var(--grid-font-size, 14px)`,color:`var(--grid-text-inverse)`,backgroundColor:`var(--grid-primary)`,border:`none`,borderRadius:`var(--grid-border-radius, 6px)`,cursor:`pointer`},onClick:()=>{t(d?{type:l,value:d}:null),n()},onMouseEnter:e=>e.currentTarget.style.backgroundColor=`var(--grid-primary-hover)`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`var(--grid-primary)`,children:`Apply`})]})]})},nr=({filterValue:e,onApplyFilter:t,onClose:n,anchorEl:r,showAdvancedButton:i,onSwitchToAdvanced:a})=>{let o=er(e)?null:e,s=o?.type||`equals`,c=o?.value||``,l=o?.value2||``,[u,d]=(0,b.useState)(s),[f,p]=(0,b.useState)(c),[m,h]=(0,b.useState)(l);return(0,Z.jsxs)(`div`,{style:{position:`fixed`,top:r?r.getBoundingClientRect().bottom+5:0,left:r?r.getBoundingClientRect().left:0,minWidth:`280px`,backgroundColor:`var(--grid-bg)`,boxShadow:`var(--grid-shadow, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05))`,borderRadius:`var(--grid-border-radius, 8px)`,border:`1px solid var(--grid-border)`,padding:`16px`,zIndex:1e3},onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(`div`,{style:{marginBottom:`12px`},children:[(0,Z.jsx)(`label`,{style:{display:`block`,fontSize:`var(--grid-font-size, 14px)`,fontWeight:500,color:`var(--grid-text)`,marginBottom:`4px`},children:`Filter Type`}),(0,Z.jsxs)(`select`,{style:{width:`100%`,padding:`8px 12px`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,fontSize:`var(--grid-font-size, 14px)`,outline:`none`,backgroundColor:`var(--grid-bg)`,color:`var(--grid-text)`},value:u,onChange:e=>d(e.target.value),children:[(0,Z.jsx)(`option`,{value:`equals`,children:`Equals`}),(0,Z.jsx)(`option`,{value:`notEquals`,children:`Not Equals`}),(0,Z.jsx)(`option`,{value:`greaterThan`,children:`Greater Than`}),(0,Z.jsx)(`option`,{value:`greaterThanOrEqual`,children:`Greater Than or Equal`}),(0,Z.jsx)(`option`,{value:`lessThan`,children:`Less Than`}),(0,Z.jsx)(`option`,{value:`lessThanOrEqual`,children:`Less Than or Equal`}),(0,Z.jsx)(`option`,{value:`inRange`,children:`In Range`})]})]}),(0,Z.jsxs)(`div`,{style:{marginBottom:`12px`},children:[(0,Z.jsx)(`label`,{style:{display:`block`,fontSize:`var(--grid-font-size, 14px)`,fontWeight:500,color:`var(--grid-text)`,marginBottom:`4px`},children:`Value`}),(0,Z.jsx)(`input`,{type:`number`,style:{width:`100%`,padding:`8px 12px`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,fontSize:`var(--grid-font-size, 14px)`,outline:`none`,backgroundColor:`var(--grid-bg)`,color:`var(--grid-text)`},value:f,onChange:e=>p(e.target.value),placeholder:`Enter number...`,autoFocus:!0})]}),u===`inRange`&&(0,Z.jsxs)(`div`,{style:{marginBottom:`12px`},children:[(0,Z.jsx)(`label`,{style:{display:`block`,fontSize:`var(--grid-font-size, 14px)`,fontWeight:500,color:`var(--grid-text)`,marginBottom:`4px`},children:`To`}),(0,Z.jsx)(`input`,{type:`number`,style:{width:`100%`,padding:`8px 12px`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,fontSize:`var(--grid-font-size, 14px)`,outline:`none`,backgroundColor:`var(--grid-bg)`,color:`var(--grid-text)`},value:m,onChange:e=>h(e.target.value),placeholder:`Enter max value...`})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,justifyContent:`flex-end`},children:[(0,Z.jsx)(`button`,{style:{padding:`6px 12px`,fontSize:`var(--grid-font-size, 14px)`,color:`var(--grid-text)`,backgroundColor:`var(--grid-bg-alt)`,border:`none`,borderRadius:`var(--grid-border-radius, 6px)`,cursor:`pointer`},onClick:()=>{p(``),h(``),t(null),n()},onMouseEnter:e=>e.currentTarget.style.backgroundColor=`var(--grid-hover)`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`var(--grid-bg-alt)`,children:`Clear`}),(0,Z.jsx)(`button`,{style:{padding:`6px 12px`,fontSize:`var(--grid-font-size, 14px)`,color:`var(--grid-text-inverse)`,backgroundColor:`var(--grid-primary)`,border:`none`,borderRadius:`var(--grid-border-radius, 6px)`,cursor:`pointer`},onClick:()=>{if(f){let e={type:u,value:parseFloat(f)};u===`inRange`&&m&&(e.value2=parseFloat(m)),t(e)}else t(null);n()},onMouseEnter:e=>e.currentTarget.style.backgroundColor=`var(--grid-primary-hover)`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`var(--grid-primary)`,children:`Apply`})]})]})},rr=({filterValue:e,onApplyFilter:t,onClose:n,anchorEl:r,showAdvancedButton:i,onSwitchToAdvanced:a})=>{let o=er(e)?null:e,s=o?.type||`equals`,c=o?.value||``,l=o?.value2||``,[u,d]=(0,b.useState)(s),[f,p]=(0,b.useState)(c),[m,h]=(0,b.useState)(l);return(0,Z.jsxs)(`div`,{style:{position:`fixed`,top:r?r.getBoundingClientRect().bottom+5:0,left:r?r.getBoundingClientRect().left:0,minWidth:`280px`,backgroundColor:`var(--grid-bg)`,boxShadow:`var(--grid-shadow, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05))`,borderRadius:`var(--grid-border-radius, 8px)`,border:`1px solid var(--grid-border)`,padding:`16px`,zIndex:1e3},onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(`div`,{style:{marginBottom:`12px`},children:[(0,Z.jsx)(`label`,{style:{display:`block`,fontSize:`var(--grid-font-size, 14px)`,fontWeight:500,color:`var(--grid-text)`,marginBottom:`4px`},children:`Filter Type`}),(0,Z.jsxs)(`select`,{style:{width:`100%`,padding:`8px 12px`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,fontSize:`var(--grid-font-size, 14px)`,outline:`none`,backgroundColor:`var(--grid-bg)`,color:`var(--grid-text)`},value:u,onChange:e=>d(e.target.value),children:[(0,Z.jsx)(`option`,{value:`equals`,children:`Equals`}),(0,Z.jsx)(`option`,{value:`before`,children:`Before`}),(0,Z.jsx)(`option`,{value:`after`,children:`After`}),(0,Z.jsx)(`option`,{value:`inRange`,children:`In Range`})]})]}),(0,Z.jsxs)(`div`,{style:{marginBottom:`12px`},children:[(0,Z.jsx)(`label`,{style:{display:`block`,fontSize:`var(--grid-font-size, 14px)`,fontWeight:500,color:`var(--grid-text)`,marginBottom:`4px`},children:`Date`}),(0,Z.jsx)(`input`,{type:`date`,style:{width:`100%`,padding:`8px 12px`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,fontSize:`var(--grid-font-size, 14px)`,outline:`none`,backgroundColor:`var(--grid-bg)`,color:`var(--grid-text)`},value:f,onChange:e=>p(e.target.value),autoFocus:!0})]}),u===`inRange`&&(0,Z.jsxs)(`div`,{style:{marginBottom:`12px`},children:[(0,Z.jsx)(`label`,{style:{display:`block`,fontSize:`var(--grid-font-size, 14px)`,fontWeight:500,color:`var(--grid-text)`,marginBottom:`4px`},children:`To`}),(0,Z.jsx)(`input`,{type:`date`,style:{width:`100%`,padding:`8px 12px`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,fontSize:`var(--grid-font-size, 14px)`,outline:`none`,backgroundColor:`var(--grid-bg)`,color:`var(--grid-text)`},value:m,onChange:e=>h(e.target.value)})]}),(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,justifyContent:`flex-end`},children:[(0,Z.jsx)(`button`,{style:{padding:`6px 12px`,fontSize:`var(--grid-font-size, 14px)`,color:`var(--grid-text)`,backgroundColor:`var(--grid-bg-alt)`,border:`none`,borderRadius:`var(--grid-border-radius, 6px)`,cursor:`pointer`},onClick:()=>{p(``),h(``),t(null),n()},onMouseEnter:e=>e.currentTarget.style.backgroundColor=`var(--grid-hover)`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`var(--grid-bg-alt)`,children:`Clear`}),(0,Z.jsx)(`button`,{style:{padding:`6px 12px`,fontSize:`var(--grid-font-size, 14px)`,color:`var(--grid-text-inverse)`,backgroundColor:`var(--grid-primary)`,border:`none`,borderRadius:`var(--grid-border-radius, 6px)`,cursor:`pointer`},onClick:()=>{if(f){let e={type:u,value:f};u===`inRange`&&m&&(e.value2=m),t(e)}else t(null);n()},onMouseEnter:e=>e.currentTarget.style.backgroundColor=`var(--grid-primary-hover)`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`var(--grid-primary)`,children:`Apply`})]})]})},ir=({column:e,filterValue:t,onApplyFilter:n,onClose:r,rows:i,anchorEl:a,showAdvancedButton:o,onSwitchToAdvanced:s})=>{let c=Array.from(new Set(i.map(t=>t[e.field]).filter(e=>e!=null))),l=er(t)?null:t,[u,d]=(0,b.useState)(l&&l.values?new Set(l.values):new Set),[f,p]=(0,b.useState)(``),m=c.filter(e=>String(e).toLowerCase().includes(f.toLowerCase())),h=e=>{let t=new Set(u);t.has(e)?t.delete(e):t.add(e),d(t)};return(0,Z.jsxs)(`div`,{style:{position:`fixed`,top:a?a.getBoundingClientRect().bottom+5:0,left:a?a.getBoundingClientRect().left:0,minWidth:`280px`,maxHeight:`400px`,backgroundColor:`var(--grid-bg)`,boxShadow:`var(--grid-shadow, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05))`,borderRadius:`var(--grid-border-radius, 8px)`,border:`1px solid var(--grid-border)`,padding:`16px`,zIndex:1e3,display:`flex`,flexDirection:`column`},onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`div`,{style:{marginBottom:`12px`},children:(0,Z.jsx)(`input`,{type:`text`,style:{width:`100%`,padding:`8px 12px`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,fontSize:`var(--grid-font-size, 14px)`,outline:`none`,backgroundColor:`var(--grid-bg)`,color:`var(--grid-text)`},value:f,onChange:e=>p(e.target.value),placeholder:`Search values...`,autoFocus:!0})}),(0,Z.jsx)(`div`,{style:{marginBottom:`8px`},children:(0,Z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,cursor:`pointer`,padding:`8px`,borderRadius:`4px`},onMouseEnter:e=>e.currentTarget.style.backgroundColor=`var(--grid-hover)`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`transparent`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:u.size===m.length&&m.length>0,onChange:()=>{u.size===m.length?d(new Set):d(new Set(m))},style:{width:`16px`,height:`16px`,cursor:`pointer`}}),(0,Z.jsx)(`span`,{style:{fontSize:`var(--grid-font-size, 14px)`,fontWeight:500,color:`var(--grid-text)`},children:`(Select All)`})]})}),(0,Z.jsx)(`div`,{style:{flex:1,overflowY:`auto`,marginBottom:`12px`,border:`1px solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,maxHeight:`200px`},children:m.map((e,t)=>(0,Z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,cursor:`pointer`,padding:`8px`},onMouseEnter:e=>e.currentTarget.style.backgroundColor=`var(--grid-hover)`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`transparent`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:u.has(e),onChange:()=>h(e),style:{width:`16px`,height:`16px`,cursor:`pointer`}}),(0,Z.jsx)(`span`,{style:{fontSize:`var(--grid-font-size, 14px)`,color:`var(--grid-text)`},children:String(e)})]},t))}),(0,Z.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,justifyContent:`flex-end`,paddingTop:`8px`,borderTop:`1px solid var(--grid-border)`},children:[(0,Z.jsx)(`button`,{style:{padding:`6px 12px`,fontSize:`var(--grid-font-size, 14px)`,color:`var(--grid-text)`,backgroundColor:`var(--grid-bg-alt)`,border:`none`,borderRadius:`var(--grid-border-radius, 6px)`,cursor:`pointer`},onClick:()=>{d(new Set),n(null),r()},onMouseEnter:e=>e.currentTarget.style.backgroundColor=`var(--grid-hover)`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`var(--grid-bg-alt)`,children:`Clear`}),(0,Z.jsxs)(`button`,{style:{padding:`6px 12px`,fontSize:`var(--grid-font-size, 14px)`,color:`var(--grid-text-inverse)`,backgroundColor:`var(--grid-primary)`,border:`none`,borderRadius:`var(--grid-border-radius, 6px)`,cursor:`pointer`},onClick:()=>{u.size>0?n({type:`set`,values:Array.from(u)}):n(null),r()},onMouseEnter:e=>e.currentTarget.style.backgroundColor=`var(--grid-primary-hover)`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`var(--grid-primary)`,children:[`Apply (`,u.size,`)`]})]})]})},ar=({column:e,filterValue:t,onApplyFilter:n,onClose:r,rows:i,anchorEl:a})=>(0,Z.jsx)(ir,{column:e,filterValue:t,onApplyFilter:n,onClose:r,rows:i,anchorEl:a});const or=({columns:e,displayColumnOrder:t,columnWidths:n,filterConfig:r,dispatch:i,pinnedLeft:a,pinnedRight:o,rows:s})=>{let[c,l]=(0,b.useState)(null),[u,d]=(0,b.useState)({}),[f,p]=(0,b.useState)(null),m=new Set(a),h=new Set(o),g={},_=0;a.forEach(e=>{g[e]=_,_+=n[e]||150});let v={},y=0;[...o].reverse().forEach(e=>{v[e]=y,y+=n[e]||150});let x=new Map(e.map(e=>[e.field,e])),S=e=>{let t={width:`${n[e]||150}px`};return m.has(e)?(t.position=`sticky`,t.left=`${g[e]}px`,t.zIndex=20,t.backgroundColor=`var(--grid-header-bg)`):h.has(e)&&(t.position=`sticky`,t.right=`${v[e]}px`,t.zIndex=20,t.backgroundColor=`var(--grid-header-bg)`),t},C=e=>{if(e.filterType)return e.filterType;let t=e.field.toLowerCase();return t.includes(`date`)||t.includes(`time`)?`date`:t.includes(`salary`)||t.includes(`price`)||t.includes(`amount`)||t.includes(`count`)?`number`:t.includes(`status`)||t.includes(`department`)||t.includes(`category`)?`set`:`text`},w=(e,t)=>{t.stopPropagation();let n=r[e];er(n)||t.shiftKey?(d({...u,[e]:t.currentTarget}),p(e),l(null)):(d({...u,[e]:t.currentTarget}),l(e),p(null))},T=()=>{l(null),p(null)},E=(e,t)=>{i({type:`SET_FILTER`,payload:{field:e,value:t}})},D=e=>{l(null),p(e)};(0,b.useEffect)(()=>{let e=()=>{c&&l(null)};if(c)return document.addEventListener(`click`,e),()=>document.removeEventListener(`click`,e)},[c]);let O=e=>{let t=C(e),n={column:e,filterValue:r[e.field],onApplyFilter:t=>E(e.field,t),onClose:T,rows:s,anchorEl:u[e.field],showAdvancedButton:!0,onSwitchToAdvanced:()=>D(e.field)};switch(t){case`number`:return(0,Z.jsx)(nr,{...n});case`date`:return(0,Z.jsx)(rr,{...n});case`set`:return(0,Z.jsx)(ir,{...n});case`multi`:return(0,Z.jsx)(ar,{...n});default:return(0,Z.jsx)(tr,{...n})}},k=e=>{let t=r[e.field],n=u[e.field];return(0,Z.jsx)($n,{column:e,filterValue:er(t)?t:null,onApply:t=>E(e.field,t),onClose:T,rows:s,anchorEl:n})},A=e=>{let t=r[e];if(!t)return``;if(er(t)){let e=t.conditions.length;return`${e} condition${e>1?`s`:``} (${t.operator})`}return t.type===`set`&&t.values?`${t.values.length} selected`:t.type===`inRange`?`${t.value} - ${t.value2}`:String(t.value||``)},j=e=>!!r[e];return(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(`div`,{style:{display:`flex`,minWidth:`100%`,borderBottom:`1px solid var(--grid-border)`,backgroundColor:`var(--grid-header-bg)`},children:t.map(e=>{let t=x.get(e);if(!t||t.filterable===!1)return(0,Z.jsx)(`div`,{style:{...S(e),borderRight:`1px solid var(--grid-border)`,flexShrink:0,minHeight:`38px`}},e);let n=j(e);return(0,Z.jsxs)(`div`,{style:{...S(e),borderRight:`1px solid var(--grid-border)`,flexShrink:0,padding:`6px 8px`,position:`relative`,display:`flex`,alignItems:`center`},children:[(0,Z.jsx)(`div`,{style:{width:`100%`,cursor:`pointer`},onClick:t=>w(e,t),title:`Click to filter, Shift+Click for advanced filter`,children:(0,Z.jsxs)(`div`,{style:{width:`100%`,padding:`4px 8px`,fontSize:`var(--grid-font-size-sm, 12px)`,border:`1px solid`,borderColor:n?`var(--grid-primary)`:`var(--grid-border)`,borderRadius:`var(--grid-border-radius, 4px)`,backgroundColor:n?`var(--grid-primary-bg)`:`var(--grid-bg)`,color:n?`var(--grid-primary)`:`var(--grid-text-secondary)`,display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:`6px`,transition:`border-color 0.15s`},onMouseEnter:e=>{n||(e.currentTarget.style.borderColor=`var(--grid-border-hover)`)},onMouseLeave:e=>{n||(e.currentTarget.style.borderColor=`var(--grid-border)`)},children:[(0,Z.jsx)(`span`,{style:{flex:1,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:n?A(e):`Filter...`}),(0,Z.jsx)(`svg`,{style:{flexShrink:0,color:n?`var(--grid-primary)`:`var(--grid-text-muted)`},width:`12`,height:`12`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,strokeWidth:`2.5`,children:(0,Z.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M3 4h18v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V20l-4-2v-3.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z`})})]})}),c===e&&O(t),f===e&&k(t)]},e)})})})};var sr=class{async save(e,t){try{let n=localStorage.getItem(e),r=n?JSON.parse(n):[],i=r.findIndex(e=>e.id===t.id);i===-1?r.push(t):r[i]=t,localStorage.setItem(e,JSON.stringify(r))}catch(e){throw console.error(`Failed to save preset to localStorage:`,e),e}}async load(e,t){try{let n=localStorage.getItem(e);if(!n)return null;let r=JSON.parse(n);return t?r.find(e=>e.id===t)||null:r}catch(e){throw console.error(`Failed to load preset from localStorage:`,e),e}}async delete(e,t){try{let n=localStorage.getItem(e);if(!n)return;let r=JSON.parse(n).filter(e=>e.id!==t);localStorage.setItem(e,JSON.stringify(r))}catch(e){throw console.error(`Failed to delete preset from localStorage:`,e),e}}async list(e){try{let t=localStorage.getItem(e);return t?JSON.parse(t):[]}catch(e){throw console.error(`Failed to list presets from localStorage:`,e),e}}},cr=class{config;constructor(e){this.config=e}async save(e,t){let n=this.config.saveEndpoint||`${this.config.baseUrl}/layouts`;try{let r=await fetch(n,{method:`POST`,headers:{"Content-Type":`application/json`,...this.config.headers},body:JSON.stringify({key:e,preset:t})});if(!r.ok)throw Error(`Server responded with ${r.status}`)}catch(e){throw console.error(`Failed to save preset to server:`,e),e}}async load(e,t){let n=this.config.loadEndpoint||`${this.config.baseUrl}/layouts`,r=t?`${n}/${e}/${t}`:`${n}/${e}`;try{let e=await fetch(r,{method:`GET`,headers:{"Content-Type":`application/json`,...this.config.headers}});if(e.status===404)return null;if(!e.ok)throw Error(`Server responded with ${e.status}`);return await e.json()}catch(e){throw console.error(`Failed to load preset from server:`,e),e}}async delete(e,t){let n=`${this.config.deleteEndpoint||`${this.config.baseUrl}/layouts`}/${e}/${t}`;try{let e=await fetch(n,{method:`DELETE`,headers:this.config.headers});if(!e.ok)throw Error(`Server responded with ${e.status}`)}catch(e){throw console.error(`Failed to delete preset from server:`,e),e}}async list(e){let t=`${this.config.listEndpoint||`${this.config.baseUrl}/layouts`}/${e}`;try{let e=await fetch(t,{method:`GET`,headers:{"Content-Type":`application/json`,...this.config.headers}});if(e.status===404)return[];if(!e.ok)throw Error(`Server responded with ${e.status}`);return await e.json()}catch(e){throw console.error(`Failed to list presets from server:`,e),e}}},lr=class{config;baseAdapter;constructor(e){this.config=e,this.baseAdapter=e.adapter||new sr}getUserKey(e){return`${this.config.profileKey||`user-layouts`}:${this.config.userId}:${e}`}async save(e,t){return this.baseAdapter.save(this.getUserKey(e),t)}async load(e,t){return this.baseAdapter.load(this.getUserKey(e),t)}async delete(e,t){return this.baseAdapter.delete(this.getUserKey(e),t)}async list(e){return this.baseAdapter.list(this.getUserKey(e))}};function ur(e){if(e.customAdapter)return e.customAdapter;switch(e.strategy){case`server`:if(!e.serverConfig)throw Error(`Server configuration is required for server storage strategy`);return new cr(e.serverConfig);case`userProfile`:if(!e.userProfileConfig)throw Error(`User profile configuration is required for userProfile storage strategy`);return new lr(e.userProfileConfig);case`localStorage`:default:return new sr}}function dr(){return`preset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function fr(e,t,n,r){let i=Date.now();return{id:r||dr(),name:e,description:n,createdAt:i,updatedAt:i,layout:t}}var pr=class{adapter;storageKey;constructor(e){this.adapter=ur(e),this.storageKey=e.storageKey}async savePreset(e){let t={...e,updatedAt:Date.now()};await this.adapter.save(this.storageKey,t)}async loadPreset(e){let t=await this.adapter.load(this.storageKey,e);return Array.isArray(t)?t.find(t=>t.id===e)||null:t}async loadLastPreset(){let e=await this.listPresets();return e.length===0?null:e.reduce((e,t)=>t.updatedAt>e.updatedAt?t:e)}async deletePreset(e){await this.adapter.delete(this.storageKey,e)}async listPresets(){return await this.adapter.list(this.storageKey)}async hasPreset(e){return await this.loadPreset(e)!==null}async autoSave(e){let t=fr(`Auto-saved Layout`,e,`Automatically saved layout`,`__autosave__`);await this.savePreset(t)}async loadAutoSave(){return await this.loadPreset(`__autosave__`)}};function mr(e,t){let n=null;return function(...r){n&&clearTimeout(n),n=setTimeout(()=>{e.apply(this,r),n=null},t)}}const hr=({manager:e,currentLayout:t,onLoadPreset:n,onResetLayout:r})=>{let[i,a]=(0,b.useState)([]),[o,s]=(0,b.useState)(!1),[c,l]=(0,b.useState)(!1),[u,d]=(0,b.useState)(``),[f,p]=(0,b.useState)(``),[m,h]=(0,b.useState)(!1),[g,_]=(0,b.useState)(null),v=(0,b.useCallback)(async()=>{try{h(!0),a((await e.listPresets()).filter(e=>e.id!==`__autosave__`)),_(null)}catch(e){_(`Failed to load presets`),console.error(e)}finally{h(!1)}},[e]);(0,b.useEffect)(()=>{v()},[v]);let y=async()=>{if(!u.trim()){_(`Please enter a preset name`);return}try{h(!0);let{createPreset:n}=await w(async()=>{let{createPreset:e}=await import(`./layoutPersistence-B2lMGbE7.js`);return{createPreset:e}},[]),r=n(u.trim(),t,f.trim());await e.savePreset(r),await v(),l(!1),d(``),p(``),_(null)}catch(e){_(`Failed to save preset`),console.error(e)}finally{h(!1)}},x=async t=>{try{h(!0);let r=await e.loadPreset(t);r&&(n(r.layout),s(!1),_(null))}catch(e){_(`Failed to load preset`),console.error(e)}finally{h(!1)}},S=async(t,n)=>{if(n.stopPropagation(),confirm(`Are you sure you want to delete this preset?`))try{h(!0),await e.deletePreset(t),await v(),_(null)}catch(e){_(`Failed to delete preset`),console.error(e)}finally{h(!1)}},C=async(n,r)=>{if(r.stopPropagation(),confirm(`Update this preset with current layout?`))try{h(!0);let r={...n,layout:t};await e.savePreset(r),await v(),_(null)}catch(e){_(`Failed to update preset`),console.error(e)}finally{h(!1)}},T=e=>new Date(e).toLocaleString();return(0,Z.jsxs)(`div`,{className:`relative inline-block`,children:[(0,Z.jsxs)(`button`,{onClick:()=>s(!o),style:{padding:`6px 12px`,fontSize:`14px`,backgroundColor:`white`,border:`1px solid #d1d5db`,borderRadius:`4px`,cursor:`pointer`,display:`flex`,alignItems:`center`,gap:`8px`},disabled:m,children:[(0,Z.jsx)(`svg`,{style:{width:`14px`,height:`14px`,flexShrink:0},fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,Z.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M4 7h16M4 12h16M4 17h16`})}),`Layout Presets`,(0,Z.jsx)(`svg`,{style:{width:`14px`,height:`14px`,flexShrink:0,transform:o?`rotate(180deg)`:`rotate(0deg)`,transition:`transform 0.2s`},fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,Z.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M19 9l-7 7-7-7`})})]}),o&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{style:{position:`fixed`,inset:0,zIndex:10},onClick:()=>s(!1)}),(0,Z.jsxs)(`div`,{style:{position:`absolute`,right:0,marginTop:`8px`,width:`320px`,backgroundColor:`white`,border:`1px solid #d1d5db`,borderRadius:`8px`,boxShadow:`0 10px 15px -3px rgba(0, 0, 0, 0.1)`,zIndex:20,maxHeight:`384px`,overflowY:`auto`},children:[(0,Z.jsx)(`div`,{style:{padding:`12px`,borderBottom:`1px solid #e5e7eb`,backgroundColor:`#f9fafb`},children:(0,Z.jsx)(`h3`,{style:{fontWeight:`600`,fontSize:`14px`,color:`#111827`},children:`Layout Presets`})}),g&&(0,Z.jsx)(`div`,{style:{padding:`12px`,backgroundColor:`#fef2f2`,borderBottom:`1px solid #fecaca`},children:(0,Z.jsx)(`p`,{style:{fontSize:`14px`,color:`#dc2626`},children:g})}),(0,Z.jsxs)(`div`,{style:{padding:`8px`,borderBottom:`1px solid #e5e7eb`,display:`flex`,gap:`8px`},children:[(0,Z.jsxs)(`button`,{onClick:()=>{l(!0),s(!1)},style:{flex:1,padding:`8px 12px`,fontSize:`14px`,backgroundColor:`#2563eb`,color:`white`,border:`none`,borderRadius:`4px`,cursor:`pointer`,display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`8px`},children:[(0,Z.jsx)(`svg`,{style:{width:`14px`,height:`14px`,flexShrink:0},fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,Z.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M8 7H5a2 2 0 00-2 2v9a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-3m-1 4l-3 3m0 0l-3-3m3 3V4`})}),`Save Current`]}),(0,Z.jsxs)(`button`,{onClick:()=>{r(),s(!1)},style:{flex:1,padding:`8px 12px`,fontSize:`14px`,backgroundColor:`#4b5563`,color:`white`,border:`none`,borderRadius:`4px`,cursor:`pointer`,display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`8px`},children:[(0,Z.jsx)(`svg`,{style:{width:`14px`,height:`14px`,flexShrink:0},fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,Z.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15`})}),`Reset`]})]}),(0,Z.jsx)(`div`,{style:{maxHeight:`256px`,overflowY:`auto`},children:m&&i.length===0?(0,Z.jsx)(`div`,{style:{padding:`16px`,textAlign:`center`,color:`#6b7280`,fontSize:`14px`},children:`Loading presets...`}):i.length===0?(0,Z.jsx)(`div`,{style:{padding:`16px`,textAlign:`center`,color:`#6b7280`,fontSize:`14px`},children:`No saved presets. Save your current layout to get started.`}):(0,Z.jsx)(`div`,{children:i.map(e=>(0,Z.jsx)(`div`,{style:{padding:`12px`,cursor:`pointer`,borderBottom:`1px solid #e5e7eb`},onClick:()=>x(e.id),onMouseEnter:e=>{e.currentTarget.style.backgroundColor=`#f9fafb`;let t=e.currentTarget.querySelector(`.preset-actions`);t&&(t.style.opacity=`1`)},onMouseLeave:e=>{e.currentTarget.style.backgroundColor=`transparent`;let t=e.currentTarget.querySelector(`.preset-actions`);t&&(t.style.opacity=`0`)},children:(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,justifyContent:`space-between`},children:[(0,Z.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,Z.jsx)(`h4`,{style:{fontSize:`14px`,fontWeight:`500`,color:`#111827`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.name}),e.description&&(0,Z.jsx)(`p`,{style:{fontSize:`12px`,color:`#6b7280`,marginTop:`4px`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.description}),(0,Z.jsxs)(`p`,{style:{fontSize:`12px`,color:`#9ca3af`,marginTop:`4px`},children:[`Updated: `,T(e.updatedAt)]})]}),(0,Z.jsxs)(`div`,{className:`preset-actions`,style:{display:`flex`,gap:`4px`,marginLeft:`8px`,opacity:0,transition:`opacity 0.2s`},children:[(0,Z.jsx)(`button`,{onClick:t=>C(e,t),style:{padding:`4px`,color:`#2563eb`,backgroundColor:`transparent`,border:`none`,borderRadius:`4px`,cursor:`pointer`},onMouseEnter:e=>e.currentTarget.style.backgroundColor=`#eff6ff`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`transparent`,title:`Update with current layout`,children:(0,Z.jsx)(`svg`,{style:{width:`14px`,height:`14px`},fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,Z.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15`})})}),(0,Z.jsx)(`button`,{onClick:t=>S(e.id,t),style:{padding:`4px`,color:`#dc2626`,backgroundColor:`transparent`,border:`none`,borderRadius:`4px`,cursor:`pointer`},onMouseEnter:e=>e.currentTarget.style.backgroundColor=`#fef2f2`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`transparent`,title:`Delete preset`,children:(0,Z.jsx)(`svg`,{style:{width:`14px`,height:`14px`},fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,Z.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16`})})})]})]})},e.id))})})]})]}),c&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{style:{position:`fixed`,inset:0,backgroundColor:`rgba(0, 0, 0, 0.5)`,zIndex:30,display:`flex`,alignItems:`center`,justifyContent:`center`},onClick:()=>l(!1)}),(0,Z.jsx)(`div`,{style:{position:`fixed`,inset:0,zIndex:40,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`16px`},children:(0,Z.jsxs)(`div`,{style:{backgroundColor:`white`,borderRadius:`8px`,boxShadow:`0 25px 50px -12px rgba(0, 0, 0, 0.25)`,maxWidth:`448px`,width:`100%`,padding:`24px`},onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`h2`,{style:{fontSize:`20px`,fontWeight:`600`,marginBottom:`16px`},children:`Save Layout Preset`}),g&&(0,Z.jsx)(`div`,{style:{marginBottom:`16px`,padding:`12px`,backgroundColor:`#fef2f2`,border:`1px solid #fecaca`,borderRadius:`4px`},children:(0,Z.jsx)(`p`,{style:{fontSize:`14px`,color:`#dc2626`},children:g})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{style:{marginBottom:`16px`},children:[(0,Z.jsx)(`label`,{htmlFor:`preset-name`,style:{display:`block`,fontSize:`14px`,fontWeight:`500`,color:`#374151`,marginBottom:`4px`},children:`Preset Name *`}),(0,Z.jsx)(`input`,{id:`preset-name`,type:`text`,value:u,onChange:e=>d(e.target.value),style:{width:`100%`,padding:`8px 12px`,border:`1px solid #d1d5db`,borderRadius:`4px`,fontSize:`14px`},placeholder:`e.g., Sales Dashboard Layout`,autoFocus:!0})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{htmlFor:`preset-description`,style:{display:`block`,fontSize:`14px`,fontWeight:`500`,color:`#374151`,marginBottom:`4px`},children:`Description (optional)`}),(0,Z.jsx)(`textarea`,{id:`preset-description`,value:f,onChange:e=>p(e.target.value),style:{width:`100%`,padding:`8px 12px`,border:`1px solid #d1d5db`,borderRadius:`4px`,fontSize:`14px`},placeholder:`Add a description...`,rows:3})]})]}),(0,Z.jsxs)(`div`,{style:{marginTop:`24px`,display:`flex`,gap:`12px`,justifyContent:`flex-end`},children:[(0,Z.jsx)(`button`,{onClick:()=>{l(!1),d(``),p(``),_(null)},style:{padding:`8px 16px`,fontSize:`14px`,color:`#374151`,backgroundColor:`#f3f4f6`,border:`none`,borderRadius:`4px`,cursor:`pointer`},onMouseEnter:e=>e.currentTarget.style.backgroundColor=`#e5e7eb`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`#f3f4f6`,disabled:m,children:`Cancel`}),(0,Z.jsx)(`button`,{onClick:y,style:{padding:`8px 16px`,fontSize:`14px`,color:`white`,backgroundColor:`#2563eb`,border:`none`,borderRadius:`4px`,cursor:`pointer`},onMouseEnter:e=>e.currentTarget.style.backgroundColor=`#1d4ed8`,onMouseLeave:e=>e.currentTarget.style.backgroundColor=`#2563eb`,disabled:m,children:m?`Saving...`:`Save Preset`})]})]})})]})]})},gr=({x:e,y:t,items:n,onClose:r})=>{let i=(0,b.useRef)(null);(0,b.useEffect)(()=>{let e=e=>{i.current&&!i.current.contains(e.target)&&r()},t=e=>{i.current&&!i.current.contains(e.target)&&(e.preventDefault(),r())},n=setTimeout(()=>{document.addEventListener(`mousedown`,e),document.addEventListener(`contextmenu`,t)},100);return()=>{clearTimeout(n),document.removeEventListener(`mousedown`,e),document.removeEventListener(`contextmenu`,t)}},[r]),(0,b.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[r]),(0,b.useEffect)(()=>{if(i.current){let n=i.current,r=n.getBoundingClientRect(),a=window.innerWidth,o=window.innerHeight,s=e,c=t;r.right>a&&(s=a-r.width-10),r.bottom>o&&(c=o-r.height-10),(s!==e||c!==t)&&(n.style.left=`${s}px`,n.style.top=`${c}px`)}},[e,t]);let a=(0,b.useCallback)(e=>{e.disabled||e.type===`separator`||(e.onClick&&e.onClick(),e.submenu||r())},[r]),o=(e,t)=>e.type===`separator`?(0,Z.jsx)(`div`,{className:`context-menu-separator`,role:`separator`},`separator-${t}`):(0,Z.jsxs)(`div`,{className:`context-menu-item ${e.disabled?`disabled`:``} ${e.danger?`danger`:``}`,onClick:()=>a(e),role:`menuitem`,"aria-disabled":e.disabled,tabIndex:e.disabled?-1:0,children:[e.icon&&(0,Z.jsx)(`span`,{className:`context-menu-icon`,children:e.icon}),(0,Z.jsx)(`span`,{className:`context-menu-label`,children:e.label}),e.shortcut&&(0,Z.jsx)(`span`,{className:`context-menu-shortcut`,children:e.shortcut}),e.submenu&&(0,Z.jsx)(`span`,{className:`context-menu-arrow`,children:`▶`})]},e.id||t);return(0,Z.jsx)(`div`,{ref:i,className:`context-menu`,style:{left:e,top:t},role:`menu`,"aria-label":`Context menu`,children:n.map((e,t)=>o(e,t))})},_r=async(e,t,n,r=!1)=>{let i=Array.from(e),a=n.filter(e=>i.includes(e.id));if(a.length===0)return;let o=``;r&&(o+=t.map(e=>e.headerName).join(` `)+`
41
41
  `),o+=a.map(e=>t.map(t=>{let n=e[t.field];return n==null?``:typeof n==`object`?JSON.stringify(n):String(n)}).join(` `)).join(`
42
42
  `);try{await navigator.clipboard.writeText(o)}catch(e){console.error(`Failed to copy to clipboard:`,e);let t=document.createElement(`textarea`);t.value=o,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select(),document.execCommand(`copy`),document.body.removeChild(t)}},vr=(e,t,n,r=`export.csv`)=>{let i=Array.from(e),a=n.filter(e=>i.includes(e.id));if(a.length===0)return;let o=``;o+=t.map(e=>`"${e.headerName}"`).join(`,`)+`
43
43
  `,o+=a.map(e=>t.map(t=>{let n=e[t.field];return n==null?`""`:typeof n==`object`?`"${JSON.stringify(n).replace(/"/g,`""`)}"`:`"${String(n).replace(/"/g,`""`)}"`}).join(`,`)).join(`
44
44
  `);let s=new Blob([o],{type:`text/csv;charset=utf-8;`}),c=document.createElement(`a`),l=URL.createObjectURL(s);c.setAttribute(`href`,l),c.setAttribute(`download`,r),c.style.visibility=`hidden`,document.body.appendChild(c),c.click(),document.body.removeChild(c),URL.revokeObjectURL(l)},yr=(e,t,n=60,r=500,i=32)=>{let a=document.createElement(`canvas`).getContext(`2d`);if(!a)return e.width||150;a.font=`14px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`;let o=a.measureText(e.headerName).width+i,s=Math.min(t.length,100),c=t.slice(0,s),l=0;for(let t of c){let n=t[e.field],r=n==null?``:String(n),o=a.measureText(r).width+i;l=Math.max(l,o)}let u=Math.max(o,l);return Math.max(n,Math.min(r,u))},br=(e,t)=>{let n={};return e.forEach(e=>{n[e.field]=yr(e,t)}),n},xr=e=>({type:`equals`,value:e}),Sr=(e,t,n=100)=>{let r=new Set;for(let i of t){let t=i[e.field];if(t!=null&&r.add(t),r.size>=n)break}return Array.from(r).sort((e,t)=>{if(typeof e==`string`&&typeof t==`string`)return e.localeCompare(t);if(typeof e==`number`&&typeof t==`number`)return e-t;let n=String(e),r=String(t);return n.localeCompare(r)})},Cr=({config:e={},columns:t,rows:n,selectedRows:r,onPinColumn:i,onUnpinColumn:a,onToggleColumnVisibility:o,onResizeColumn:s,onAutoSizeAllColumns:c,onSetFilter:l,onPinRowTop:u,onPinRowBottom:d,onUnpinRow:f,pinnedColumnsLeft:p=[],pinnedColumnsRight:m=[],pinnedRowsTop:h=[],pinnedRowsBottom:g=[]})=>{let[_,v]=(0,b.useState)({isOpen:!1,x:0,y:0,items:[],contextType:null}),y=(0,b.useMemo)(()=>({enabled:e?.enabled!==!1,showCopy:e?.showCopy!==!1,showExport:e?.showExport!==!1,showColumnOptions:e?.showColumnOptions!==!1,showFilterByValue:e?.showFilterByValue!==!1,customItems:e?.customItems||[],onBeforeShow:e?.onBeforeShow}),[e?.enabled,e?.showCopy,e?.showExport,e?.showColumnOptions,e?.showFilterByValue,e?.customItems,e?.onBeforeShow]),x=(0,b.useCallback)((e,i)=>{let a=[],o=r.size>0,s=e.id,c=h.includes(s),p=g.includes(s);if(u&&d&&f&&(c||p?a.push({id:`unpin-row`,label:`Unpin Row`,icon:`📍`,onClick:()=>f(s)}):(a.push({id:`pin-row-top`,label:`Pin Row to Top`,icon:`📌`,onClick:()=>u(s)}),a.push({id:`pin-row-bottom`,label:`Pin Row to Bottom`,icon:`📌`,onClick:()=>d(s)})),a.push({type:`separator`})),y.showCopy&&(a.push({id:`copy`,label:`Copy`,icon:`📋`,shortcut:`Ctrl+C`,onClick:()=>{if(o)_r(r,t,n,!1);else{let t=e[i.field],n=t==null?``:String(t);navigator.clipboard.writeText(n)}}}),a.push({id:`copy-with-headers`,label:`Copy with Headers`,icon:`📋`,onClick:()=>{o&&_r(r,t,n,!0)},disabled:!o})),y.showExport&&o&&a.push({id:`export-selected`,label:`Export Selected Range`,icon:`📤`,onClick:()=>{vr(r,t,n)}}),a.length>0&&(y.showFilterByValue||y.customItems.length>0)&&a.push({type:`separator`}),y.showFilterByValue&&l){let t=e[i.field];a.push({id:`filter-by-value`,label:`Filter by "${String(t)}"`,icon:`🔍`,onClick:()=>{l(i.field,xr(t))},disabled:t==null})}return y.customItems.length>0&&(a.length>0&&a.push({type:`separator`}),a.push(...y.customItems)),a},[y,r,t,n,l,u,d,f,h,g]),S=(0,b.useCallback)(e=>{let r=[],u=p.includes(e.field),d=m.includes(e.field),f=u||d;if(y.showColumnOptions&&e.pinnable!==!1&&(f?r.push({id:`unpin`,label:`Unpin Column`,icon:`📍`,onClick:()=>a?.(e.field)}):(r.push({id:`pin-left`,label:`Pin Left`,icon:`📌`,onClick:()=>i?.(e.field,`left`)}),r.push({id:`pin-right`,label:`Pin Right`,icon:`📌`,onClick:()=>i?.(e.field,`right`)})),r.push({type:`separator`})),y.showColumnOptions&&(r.push({id:`auto-size`,label:`Auto-size This Column`,icon:`↔️`,onClick:()=>{let t=yr(e,n);s?.(e.field,t)}}),r.push({id:`resize-to-fit`,label:`Resize to Fit`,icon:`↔️`,onClick:()=>{let t=yr(e,n);s?.(e.field,t)}}),r.push({id:`auto-size-all`,label:`Auto-size All Columns`,icon:`⇔`,onClick:()=>{let e=br(t,n);c?.(e)}}),r.push({type:`separator`})),y.showColumnOptions&&r.push({id:`hide`,label:`Hide Column`,icon:`👁️`,onClick:()=>o?.(e.field)}),y.showFilterByValue&&l&&e.filterable!==!1){r.push({type:`separator`});let t=Sr(e,n,10);t.length>0&&r.push({id:`filter-by-value-header`,label:`Filter by Value`,icon:`🔍`,submenu:t.map((t,n)=>({id:`filter-value-${n}`,label:String(t),onClick:()=>{l(e.field,xr(t))}}))})}return y.customItems.length>0&&(r.push({type:`separator`}),r.push(...y.customItems)),r},[y,p,m,t,n,i,a,s,c,o,l]);return{contextMenu:_,handleContextMenu:(0,b.useCallback)(e=>{if(!y.enabled)return;e.event.preventDefault();let t=[];if(e.type===`cell`&&e.row&&e.column?t=x(e.row,e.column):e.type===`header`&&e.column&&(t=S(e.column)),y.onBeforeShow){let n=y.onBeforeShow(e);n!==null&&(t=n)}t.length>0&&v({isOpen:!0,x:e.event.clientX,y:e.event.clientY,items:t,contextType:e.type,targetRow:e.row,targetColumn:e.column,targetRowIndex:e.rowIndex,targetColumnIndex:e.columnIndex})},[y,x,S]),closeContextMenu:(0,b.useCallback)(()=>{v({isOpen:!1,x:0,y:0,items:[],contextType:null})},[])}};var wr=g();const Tr=({state:e,maxWidth:t=300,offset:n=8})=>{let r=(0,b.useRef)(null),[i,a]=(0,b.useState)({x:0,y:0}),[o,s]=(0,b.useState)(e.placement);if((0,b.useLayoutEffect)(()=>{if(!e.isVisible||!r.current||!e.targetRect)return;let t=r.current.getBoundingClientRect(),i=window.innerWidth,o=window.innerHeight,c=e.targetRect,l=e.x,u=e.y,d=e.placement;if(e.placement===`auto`||e.placement===`top`||e.placement===`bottom`){let r=c.top,a=o-c.bottom,s=c.left,f=i-c.right;e.placement===`auto`&&(d=a>=t.height+n?`bottom`:r>=t.height+n?`top`:f>=t.width+n?`right`:s>=t.width+n?`left`:`bottom`),d===`top`?(l=c.left+c.width/2-t.width/2,u=c.top-t.height-n):d===`bottom`?(l=c.left+c.width/2-t.width/2,u=c.bottom+n):d===`left`?(l=c.left-t.width-n,u=c.top+c.height/2-t.height/2):d===`right`&&(l=c.right+n,u=c.top+c.height/2-t.height/2),l<10?l=10:l+t.width>i-10&&(l=i-t.width-10),u<10?u=10:u+t.height>o-10&&(u=o-t.height-10)}else e.placement===`left`?(l=c.left-t.width-n,u=c.top+c.height/2-t.height/2):e.placement===`right`&&(l=c.right+n,u=c.top+c.height/2-t.height/2),u<10?u=10:u+t.height>o-10&&(u=o-t.height-10),l<10?l=10:l+t.width>i-10&&(l=i-t.width-10);setTimeout(()=>a({x:l,y:u}),0),setTimeout(()=>s(d),0)},[e.isVisible,e.x,e.y,e.targetRect,e.placement,n]),!e.isVisible||!e.content)return null;let c=typeof e.content==`string`?{content:e.content}:e.content;return(0,wr.createPortal)((0,Z.jsxs)(`div`,{ref:r,role:`tooltip`,"aria-live":`polite`,style:{position:`fixed`,left:`${i.x}px`,top:`${i.y}px`,maxWidth:`${t}px`,zIndex:99999,pointerEvents:`none`,opacity:e.isVisible?1:0,transition:`opacity 0.15s ease-in-out`},children:[(0,Z.jsxs)(`div`,{style:{backgroundColor:`rgba(0, 0, 0, 0.9)`,color:`white`,padding:`8px 12px`,borderRadius:`6px`,fontSize:`13px`,lineHeight:`1.5`,boxShadow:`0 4px 12px rgba(0, 0, 0, 0.3)`,wordWrap:`break-word`},children:[c.title&&(0,Z.jsx)(`div`,{style:{fontWeight:`600`,marginBottom:`4px`,fontSize:`14px`},children:c.title}),(0,Z.jsx)(`div`,{children:c.content})]}),(0,Z.jsx)(`div`,{style:{position:`absolute`,width:0,height:0,borderStyle:`solid`,...o===`top`&&{bottom:`-6px`,left:`50%`,transform:`translateX(-50%)`,borderWidth:`6px 6px 0 6px`,borderColor:`rgba(0, 0, 0, 0.9) transparent transparent transparent`},...o===`bottom`&&{top:`-6px`,left:`50%`,transform:`translateX(-50%)`,borderWidth:`0 6px 6px 6px`,borderColor:`transparent transparent rgba(0, 0, 0, 0.9) transparent`},...o===`left`&&{right:`-6px`,top:`50%`,transform:`translateY(-50%)`,borderWidth:`6px 0 6px 6px`,borderColor:`transparent transparent transparent rgba(0, 0, 0, 0.9)`},...o===`right`&&{left:`-6px`,top:`50%`,transform:`translateY(-50%)`,borderWidth:`6px 6px 6px 0`,borderColor:`transparent rgba(0, 0, 0, 0.9) transparent transparent`}}})]}),document.body)},Er=({config:e={}}={})=>{let[t,n]=(0,b.useState)({isVisible:!1,x:0,y:0,placement:e.placement||`auto`,content:null,targetRect:null}),r=(0,b.useRef)(null),i=(0,b.useRef)(null),a=(0,b.useRef)(!1),{enabled:o=!0,showDelay:s=500,hideDelay:c=0,placement:l=`auto`,showCellTooltips:u=!1,showRowTooltips:d=!1,getCellTooltip:f,getRowTooltip:p}=e,m=(0,b.useCallback)(()=>{r.current&&=(clearTimeout(r.current),null),i.current&&=(clearTimeout(i.current),null)},[]),h=(0,b.useCallback)((e,t)=>{if(!o||!t)return;m(),a.current=!0;let i=e.currentTarget.getBoundingClientRect(),c=typeof t==`string`?{content:t}:t;r.current=setTimeout(()=>{a.current&&n({isVisible:!0,x:i.left+i.width/2,y:i.top,placement:l,content:c,targetRect:i})},s)},[o,s,l,m]),g=(0,b.useCallback)(()=>{m(),a.current=!1,c>0?i.current=setTimeout(()=>{n(e=>({...e,isVisible:!1}))},c):n(e=>({...e,isVisible:!1}))},[c,m]),_=(0,b.useCallback)((e,t,n,r)=>{if(!o||!u||!f)return;let i=f(t,n,r);i&&h(e,i)},[o,u,f,h]),v=(0,b.useCallback)(()=>{g()},[g]),y=(0,b.useCallback)((e,t,n)=>{if(!o||!d||!p)return;let r=p(t,n);r&&h(e,r)},[o,d,p,h]),x=(0,b.useCallback)(()=>{g()},[g]);return(0,b.useEffect)(()=>()=>{m()},[m]),(0,b.useEffect)(()=>{let e=()=>{t.isVisible&&g()};return window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`scroll`,e,!0)}},[t.isVisible,g]),{tooltipState:t,tooltipHandlers:{onCellMouseEnter:_,onCellMouseLeave:v,onRowMouseEnter:y,onRowMouseLeave:x},hideTooltip:g}},Dr={ultraCompact:{mode:`ultraCompact`,rowHeight:`24px`,cellPadding:`2px 6px`,headerPadding:`4px 6px`,fontSize:`12px`,fontSizeSmall:`10px`},compact:{mode:`compact`,rowHeight:`32px`,cellPadding:`4px 8px`,headerPadding:`6px 8px`,fontSize:`13px`,fontSizeSmall:`11px`},normal:{mode:`normal`,rowHeight:`44px`,cellPadding:`10px 12px`,headerPadding:`10px 12px`,fontSize:`14px`,fontSizeSmall:`12px`},comfortable:{mode:`comfortable`,rowHeight:`56px`,cellPadding:`14px 16px`,headerPadding:`14px 16px`,fontSize:`15px`,fontSizeSmall:`13px`}};function Or(e=`normal`){return Dr[e]}function kr(e){let t=Or(e);return{"--grid-row-height":t.rowHeight,"--grid-cell-padding":t.cellPadding,"--grid-header-padding":t.headerPadding,"--grid-font-size":t.fontSize,"--grid-font-size-sm":t.fontSizeSmall}}function Ar(e){return{ultraCompact:`Ultra Compact`,compact:`Compact`,normal:`Normal`,comfortable:`Comfortable`}[e]}function jr(e,t=`grid-density-mode`){try{localStorage.setItem(t,e)}catch(e){console.warn(`Failed to save density mode:`,e)}}function Mr(e=`grid-density-mode`){try{let t=localStorage.getItem(e);if(t&&(t===`ultraCompact`||t===`compact`||t===`normal`||t===`comfortable`))return t}catch(e){console.warn(`Failed to load density mode:`,e)}return null}const Nr=({value:e,onChange:t,className:n=``,disabled:r=!1})=>{let i=[`ultraCompact`,`compact`,`normal`,`comfortable`];return(0,Z.jsx)(`div`,{className:`density-toggle ${n}`,style:{display:`inline-flex`,backgroundColor:`var(--grid-bg-alt, #f3f4f6)`,borderRadius:`6px`,padding:`2px`,border:`1px solid var(--grid-border, #e5e7eb)`,gap:`2px`},role:`group`,"aria-label":`Density mode selector`,children:i.map(n=>(0,Z.jsx)(`button`,{onClick:()=>t(n),disabled:r,className:`density-toggle-button ${e===n?`active`:``}`,style:{padding:`6px 14px`,fontSize:`13px`,fontWeight:e===n?`600`:`500`,color:e===n?`var(--grid-primary, #3b82f6)`:`var(--grid-text-secondary, #6b7280)`,backgroundColor:e===n?`var(--grid-bg, #ffffff)`:`transparent`,border:`none`,borderRadius:`4px`,cursor:r?`not-allowed`:`pointer`,transition:`all 0.2s ease`,opacity:r?.5:1,outline:`none`,whiteSpace:`nowrap`,boxShadow:e===n?`0 1px 2px rgba(0, 0, 0, 0.05)`:`none`},onMouseEnter:t=>{!r&&e!==n&&(t.currentTarget.style.color=`var(--grid-text, #111827)`,t.currentTarget.style.backgroundColor=`rgba(0, 0, 0, 0.02)`)},onMouseLeave:t=>{!r&&e!==n&&(t.currentTarget.style.color=`var(--grid-text-secondary, #6b7280)`,t.currentTarget.style.backgroundColor=`transparent`)},onFocus:e=>{e.currentTarget.style.boxShadow=`0 0 0 2px var(--grid-primary-light, #93c5fd)`},onBlur:t=>{t.currentTarget.style.boxShadow=e===n?`0 1px 2px rgba(0, 0, 0, 0.05)`:`none`},"aria-pressed":e===n,"aria-label":`${Ar(n)} density mode`,type:`button`,children:Ar(n)},n))})};function Pr(e={}){let{initialMode:t=`normal`,persist:n=!0,persistenceKey:r=`grid-density-mode`,onChange:i}=e,[a,o]=(0,b.useState)(()=>{if(n){let e=Mr(r);if(e)return e}return t});return{densityMode:a,setDensityMode:e=>{o(e),n&&jr(e,r),i?.(e)},densityConfig:Or(a),densityStyles:kr(a)}}var Fr=(e,t)=>{if(t.type===`isEmpty`)return e==null||String(e).trim()===``;if(t.type===`isNotEmpty`)return e!=null&&String(e).trim()!==``;if(e==null)return!1;let n=String(e).toLowerCase(),r=String(t.value||``).toLowerCase();switch(t.type){case`contains`:return n.includes(r);case`notContains`:return!n.includes(r);case`equals`:return n===r;case`notEquals`:return n!==r;case`startsWith`:return n.startsWith(r);case`endsWith`:return n.endsWith(r);default:return n.includes(r)}},Ir=(e,t)=>{if(t.type===`isEmpty`)return e==null||typeof e==`number`&&isNaN(e);if(t.type===`isNotEmpty`)return e!=null&&!(typeof e==`number`&&isNaN(e));if(e==null)return!1;let n=typeof e==`number`?e:parseFloat(e);if(isNaN(n))return!1;let r=parseFloat(t.value);if(isNaN(r))return!1;switch(t.type){case`equals`:return n===r;case`notEquals`:return n!==r;case`greaterThan`:return n>r;case`greaterThanOrEqual`:return n>=r;case`lessThan`:return n<r;case`lessThanOrEqual`:return n<=r;case`inRange`:{let e=parseFloat(t.value2);return isNaN(e)?n>=r:n>=r&&n<=e}default:return n===r}},Lr=(e,t)=>{if(t.type===`isEmpty`)return e==null;if(t.type===`isNotEmpty`)return e!=null;if(e==null)return!1;let n;if(n=e instanceof Date?e:new Date(e),isNaN(n.getTime()))return!1;let r=new Date(t.value);if(isNaN(r.getTime()))return!1;let i=new Date(n.getFullYear(),n.getMonth(),n.getDate()),a=new Date(r.getFullYear(),r.getMonth(),r.getDate());switch(t.type){case`equals`:return i.getTime()===a.getTime();case`before`:return i.getTime()<a.getTime();case`after`:return i.getTime()>a.getTime();case`inRange`:{let e=new Date(t.value2);if(isNaN(e.getTime()))return i.getTime()>=a.getTime();let n=new Date(e.getFullYear(),e.getMonth(),e.getDate());return i.getTime()>=a.getTime()&&i.getTime()<=n.getTime()}default:return i.getTime()===a.getTime()}},Rr=(e,t)=>{if(!t.values||t.values.length===0)return!0;let n=t.values.includes(e);return t.type===`notIn`?!n:n},zr=e=>e.type===`set`||e.type===`in`||e.type===`notIn`||e.values?`set`:[`equals`,`notEquals`,`greaterThan`,`lessThan`,`greaterThanOrEqual`,`lessThanOrEqual`,`inRange`].includes(e.type||``)&&(typeof e.value==`number`||!isNaN(parseFloat(e.value)))?`number`:[`before`,`after`].includes(e.type||``)||e.value&&!isNaN(new Date(e.value).getTime())&&String(e.value).match(/\d{4}-\d{2}-\d{2}|\\d{1,2}\/\d{1,2}\/\d{4}/)?`date`:`text`,Br=e=>e!=null&&`operator`in e&&`conditions`in e,Vr=(e,t,n)=>{let r=e[t];switch(zr(n)){case`number`:return Ir(r,n);case`date`:return Lr(r,n);case`set`:return Rr(r,n);default:return Fr(r,n)}},Hr=(e,t,n)=>{let{operator:r,conditions:i}=n;return!i||i.length===0?!0:r===`AND`?i.every(n=>Vr(e,t,n)):i.some(n=>Vr(e,t,n))},Ur=(e,t,n)=>{if(!n)return!0;if(Br(n))return Hr(e,t,n);let r=e[t];switch(zr(n)){case`number`:return Ir(r,n);case`date`:return Lr(r,n);case`set`:return Rr(r,n);default:return Fr(r,n)}};const Wr=(e,t)=>!t||Object.keys(t).length===0?e:e.filter(e=>Object.entries(t).every(([t,n])=>n?Ur(e,t,n):!0)),Gr=e=>Object.values(e).some(e=>e!=null),Kr={name:`quartz`,displayName:`Quartz (Modern White)`,colors:{background:`#ffffff`,backgroundAlt:`#f9fafb`,headerBackground:`#f3f4f6`,footerBackground:`#f9fafb`,border:`#e5e7eb`,borderLight:`#f3f4f6`,text:`#111827`,textSecondary:`#6b7280`,textInverse:`#ffffff`,headerText:`#374151`,hover:`#f3f4f6`,active:`#e5e7eb`,selected:`#dbeafe`,primary:`#3b82f6`,primaryHover:`#2563eb`,primaryLight:`#93c5fd`,primaryDark:`#1e40af`,primaryBackground:`#eff6ff`,textMuted:`#6b7280`,borderHover:`#9ca3af`,success:`#10b981`,warning:`#f59e0b`,error:`#ef4444`,info:`#3b82f6`},spacing:{cellPadding:`12px 16px`,headerPadding:`12px 16px`,rowHeight:`48px`},typography:{fontFamily:`-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`,fontSize:`14px`,fontSizeSmall:`12px`,fontWeight:`400`,headerFontWeight:`600`},borders:{width:`1px`,radius:`8px`,style:`solid`},shadows:{light:`0 1px 2px 0 rgba(0, 0, 0, 0.05)`,medium:`0 4px 6px -1px rgba(0, 0, 0, 0.1)`,heavy:`0 10px 15px -3px rgba(0, 0, 0, 0.1)`}},qr={name:`alpine`,displayName:`Alpine (Classic Business)`,colors:{background:`#ffffff`,backgroundAlt:`#fafafa`,headerBackground:`#f5f5f5`,footerBackground:`#f5f5f5`,border:`#d9d9d9`,borderLight:`#e8e8e8`,text:`#262626`,textSecondary:`#595959`,textInverse:`#ffffff`,headerText:`#262626`,hover:`#f5f5f5`,active:`#e8e8e8`,selected:`#e6f7ff`,primary:`#1890ff`,primaryHover:`#096dd9`,primaryLight:`#91d5ff`,primaryDark:`#0050b3`,primaryBackground:`#e6f7ff`,textMuted:`#8c8c8c`,borderHover:`#bfbfbf`,success:`#52c41a`,warning:`#faad14`,error:`#f5222d`,info:`#1890ff`},spacing:{cellPadding:`10px 12px`,headerPadding:`10px 12px`,rowHeight:`44px`},typography:{fontFamily:`"Segoe UI", Tahoma, Geneva, Verdana, sans-serif`,fontSize:`13px`,fontSizeSmall:`11px`,fontWeight:`400`,headerFontWeight:`600`},borders:{width:`1px`,radius:`4px`,style:`solid`},shadows:{light:`0 1px 2px rgba(0, 0, 0, 0.08)`,medium:`0 2px 8px rgba(0, 0, 0, 0.12)`,heavy:`0 4px 12px rgba(0, 0, 0, 0.15)`}},Jr={name:`material`,displayName:`Material`,colors:{background:`#ffffff`,backgroundAlt:`#fafafa`,headerBackground:`#f5f5f5`,footerBackground:`#f5f5f5`,border:`#e0e0e0`,borderLight:`#eeeeee`,text:`#212121`,textSecondary:`#757575`,textInverse:`#ffffff`,headerText:`#424242`,hover:`#f5f5f5`,active:`#eeeeee`,selected:`#e3f2fd`,primary:`#2196f3`,primaryHover:`#1976d2`,primaryLight:`#90caf9`,primaryDark:`#0d47a1`,primaryBackground:`#e3f2fd`,textMuted:`#757575`,borderHover:`#bdbdbd`,success:`#4caf50`,warning:`#ff9800`,error:`#f44336`,info:`#2196f3`},spacing:{cellPadding:`14px 16px`,headerPadding:`14px 16px`,rowHeight:`52px`},typography:{fontFamily:`Roboto, "Helvetica Neue", Arial, sans-serif`,fontSize:`14px`,fontSizeSmall:`12px`,fontWeight:`400`,headerFontWeight:`500`},borders:{width:`1px`,radius:`4px`,style:`solid`},shadows:{light:`0 2px 1px -1px rgba(0,0,0,.2), 0 1px 1px 0 rgba(0,0,0,.14), 0 1px 3px 0 rgba(0,0,0,.12)`,medium:`0 3px 3px -2px rgba(0,0,0,.2), 0 3px 4px 0 rgba(0,0,0,.14), 0 1px 8px 0 rgba(0,0,0,.12)`,heavy:`0 5px 5px -3px rgba(0,0,0,.2), 0 8px 10px 1px rgba(0,0,0,.14), 0 3px 14px 2px rgba(0,0,0,.12)`}},Yr={name:`dark`,displayName:`Dark Mode`,colors:{background:`#1e1e1e`,backgroundAlt:`#252526`,headerBackground:`#2d2d30`,footerBackground:`#252526`,border:`#3e3e42`,borderLight:`#333333`,text:`#d4d4d4`,textSecondary:`#969696`,textInverse:`#1e1e1e`,headerText:`#e0e0e0`,hover:`#2a2d2e`,active:`#37373d`,selected:`#264f78`,primary:`#4a9eff`,primaryHover:`#6eb4ff`,primaryLight:`#80b9ff`,primaryDark:`#2d7dd2`,primaryBackground:`#1e3a5f`,textMuted:`#858585`,borderHover:`#505050`,success:`#4ec9b0`,warning:`#dcdcaa`,error:`#f48771`,info:`#4a9eff`},spacing:{cellPadding:`12px 16px`,headerPadding:`12px 16px`,rowHeight:`48px`},typography:{fontFamily:`-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`,fontSize:`14px`,fontSizeSmall:`12px`,fontWeight:`400`,headerFontWeight:`600`},borders:{width:`1px`,radius:`6px`,style:`solid`},shadows:{light:`0 2px 4px rgba(0, 0, 0, 0.3)`,medium:`0 4px 8px rgba(0, 0, 0, 0.4)`,heavy:`0 8px 16px rgba(0, 0, 0, 0.5)`}},Xr={name:`nord`,displayName:`Nord (Arctic)`,colors:{background:`#eceff4`,backgroundAlt:`#e5e9f0`,headerBackground:`#d8dee9`,footerBackground:`#e5e9f0`,border:`#d8dee9`,borderLight:`#e5e9f0`,text:`#2e3440`,textSecondary:`#4c566a`,textInverse:`#eceff4`,headerText:`#2e3440`,hover:`#e5e9f0`,active:`#d8dee9`,selected:`#d8dee9`,primary:`#5e81ac`,primaryHover:`#81a1c1`,primaryLight:`#88c0d0`,primaryDark:`#5e81ac`,primaryBackground:`#d8dee9`,textMuted:`#4c566a`,borderHover:`#4c566a`,success:`#a3be8c`,warning:`#ebcb8b`,error:`#bf616a`,info:`#88c0d0`},spacing:{cellPadding:`12px 16px`,headerPadding:`12px 16px`,rowHeight:`48px`},typography:{fontFamily:`-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`,fontSize:`14px`,fontSizeSmall:`12px`,fontWeight:`400`,headerFontWeight:`600`},borders:{width:`1px`,radius:`6px`,style:`solid`},shadows:{light:`0 1px 3px rgba(0, 0, 0, 0.12)`,medium:`0 3px 6px rgba(0, 0, 0, 0.15)`,heavy:`0 8px 16px rgba(0, 0, 0, 0.18)`}},Zr={name:`dracula`,displayName:`Dracula`,colors:{background:`#282a36`,backgroundAlt:`#21222c`,headerBackground:`#44475a`,footerBackground:`#21222c`,border:`#44475a`,borderLight:`#6272a4`,text:`#f8f8f2`,textSecondary:`#6272a4`,textInverse:`#282a36`,headerText:`#f8f8f2`,hover:`#44475a`,active:`#6272a4`,selected:`#44475a`,primary:`#bd93f9`,primaryHover:`#caa9fa`,primaryLight:`#d6bcfb`,primaryDark:`#9b72dd`,primaryBackground:`#44475a`,textMuted:`#6272a4`,borderHover:`#bd93f9`,success:`#50fa7b`,warning:`#f1fa8c`,error:`#ff5555`,info:`#8be9fd`},spacing:{cellPadding:`12px 16px`,headerPadding:`12px 16px`,rowHeight:`48px`},typography:{fontFamily:`"Fira Code", "Consolas", monospace, -apple-system, BlinkMacSystemFont, "Segoe UI"`,fontSize:`14px`,fontSizeSmall:`12px`,fontWeight:`400`,headerFontWeight:`600`},borders:{width:`1px`,radius:`8px`,style:`solid`},shadows:{light:`0 2px 4px rgba(0, 0, 0, 0.4)`,medium:`0 4px 8px rgba(0, 0, 0, 0.5)`,heavy:`0 8px 16px rgba(0, 0, 0, 0.6)`}},Qr={name:`solarized-light`,displayName:`Solarized Light`,colors:{background:`#fdf6e3`,backgroundAlt:`#eee8d5`,headerBackground:`#eee8d5`,footerBackground:`#eee8d5`,border:`#93a1a1`,borderLight:`#eee8d5`,text:`#657b83`,textSecondary:`#93a1a1`,textInverse:`#fdf6e3`,headerText:`#586e75`,hover:`#eee8d5`,active:`#93a1a1`,selected:`#d3cbb7`,primary:`#268bd2`,primaryHover:`#2aa198`,primaryLight:`#6c71c4`,primaryDark:`#073642`,primaryBackground:`#eee8d5`,textMuted:`#93a1a1`,borderHover:`#657b83`,success:`#859900`,warning:`#b58900`,error:`#dc322f`,info:`#268bd2`},spacing:{cellPadding:`12px 16px`,headerPadding:`12px 16px`,rowHeight:`48px`},typography:{fontFamily:`"Source Code Pro", "Menlo", "Monaco", monospace`,fontSize:`14px`,fontSizeSmall:`12px`,fontWeight:`400`,headerFontWeight:`600`},borders:{width:`1px`,radius:`4px`,style:`solid`},shadows:{light:`0 1px 3px rgba(0, 0, 0, 0.08)`,medium:`0 3px 6px rgba(0, 0, 0, 0.12)`,heavy:`0 8px 16px rgba(0, 0, 0, 0.15)`}},$r={name:`solarized-dark`,displayName:`Solarized Dark`,colors:{background:`#002b36`,backgroundAlt:`#073642`,headerBackground:`#073642`,footerBackground:`#073642`,border:`#586e75`,borderLight:`#073642`,text:`#839496`,textSecondary:`#657b83`,textInverse:`#002b36`,headerText:`#93a1a1`,hover:`#073642`,active:`#586e75`,selected:`#094757`,primary:`#268bd2`,primaryHover:`#2aa198`,primaryLight:`#6c71c4`,primaryDark:`#073642`,primaryBackground:`#073642`,textMuted:`#657b83`,borderHover:`#839496`,success:`#859900`,warning:`#b58900`,error:`#dc322f`,info:`#268bd2`},spacing:{cellPadding:`12px 16px`,headerPadding:`12px 16px`,rowHeight:`48px`},typography:{fontFamily:`"Source Code Pro", "Menlo", "Monaco", monospace`,fontSize:`14px`,fontSizeSmall:`12px`,fontWeight:`400`,headerFontWeight:`600`},borders:{width:`1px`,radius:`4px`,style:`solid`},shadows:{light:`0 2px 4px rgba(0, 0, 0, 0.3)`,medium:`0 4px 8px rgba(0, 0, 0, 0.4)`,heavy:`0 8px 16px rgba(0, 0, 0, 0.5)`}},ei={name:`monokai`,displayName:`Monokai`,colors:{background:`#272822`,backgroundAlt:`#1e1f1c`,headerBackground:`#3e3d32`,footerBackground:`#1e1f1c`,border:`#49483e`,borderLight:`#3e3d32`,text:`#f8f8f2`,textSecondary:`#75715e`,textInverse:`#272822`,headerText:`#f8f8f2`,hover:`#3e3d32`,active:`#49483e`,selected:`#49483e`,primary:`#66d9ef`,primaryHover:`#a6e22e`,primaryLight:`#e6db74`,primaryDark:`#ae81ff`,primaryBackground:`#3e3d32`,textMuted:`#75715e`,borderHover:`#66d9ef`,success:`#a6e22e`,warning:`#e6db74`,error:`#f92672`,info:`#66d9ef`},spacing:{cellPadding:`12px 16px`,headerPadding:`12px 16px`,rowHeight:`48px`},typography:{fontFamily:`"Fira Code", "Monaco", "Consolas", monospace`,fontSize:`14px`,fontSizeSmall:`12px`,fontWeight:`400`,headerFontWeight:`600`},borders:{width:`1px`,radius:`6px`,style:`solid`},shadows:{light:`0 2px 4px rgba(0, 0, 0, 0.5)`,medium:`0 4px 8px rgba(0, 0, 0, 0.6)`,heavy:`0 8px 16px rgba(0, 0, 0, 0.7)`}},ti={name:`one-dark`,displayName:`One Dark`,colors:{background:`#282c34`,backgroundAlt:`#21252b`,headerBackground:`#2c313c`,footerBackground:`#21252b`,border:`#3e4451`,borderLight:`#2c313c`,text:`#abb2bf`,textSecondary:`#5c6370`,textInverse:`#282c34`,headerText:`#abb2bf`,hover:`#2c313c`,active:`#3e4451`,selected:`#3e4451`,primary:`#61afef`,primaryHover:`#528bff`,primaryLight:`#84b9f0`,primaryDark:`#4e88c7`,primaryBackground:`#2c313c`,textMuted:`#5c6370`,borderHover:`#528bff`,success:`#98c379`,warning:`#e5c07b`,error:`#e06c75`,info:`#61afef`},spacing:{cellPadding:`12px 16px`,headerPadding:`12px 16px`,rowHeight:`48px`},typography:{fontFamily:`"Fira Code", "Menlo", "Monaco", "Consolas", monospace`,fontSize:`14px`,fontSizeSmall:`12px`,fontWeight:`400`,headerFontWeight:`600`},borders:{width:`1px`,radius:`6px`,style:`solid`},shadows:{light:`0 2px 4px rgba(0, 0, 0, 0.4)`,medium:`0 4px 8px rgba(0, 0, 0, 0.5)`,heavy:`0 8px 16px rgba(0, 0, 0, 0.6)`}},ni={quartz:Kr,alpine:qr,material:Jr,dark:Yr,nord:Xr,dracula:Zr,"solarized-light":Qr,"solarized-dark":$r,monokai:ei,"one-dark":ti};function ri(e){return ni[e]||Kr}function ii(e){return{"--grid-bg":e.colors.background,"--grid-bg-alt":e.colors.backgroundAlt,"--grid-header-bg":e.colors.headerBackground,"--grid-footer-bg":e.colors.footerBackground,"--grid-border":e.colors.border,"--grid-border-light":e.colors.borderLight,"--grid-text":e.colors.text,"--grid-text-secondary":e.colors.textSecondary,"--grid-text-inverse":e.colors.textInverse,"--grid-header-text":e.colors.headerText,"--grid-hover":e.colors.hover,"--grid-active":e.colors.active,"--grid-selected":e.colors.selected,"--grid-primary":e.colors.primary,"--grid-primary-hover":e.colors.primaryHover,"--grid-primary-light":e.colors.primaryLight,"--grid-primary-dark":e.colors.primaryDark,"--grid-primary-bg":e.colors.primaryBackground,"--grid-text-muted":e.colors.textMuted,"--grid-border-hover":e.colors.borderHover,"--grid-success":e.colors.success,"--grid-warning":e.colors.warning,"--grid-error":e.colors.error,"--grid-info":e.colors.info,"--grid-cell-padding":e.spacing.cellPadding,"--grid-header-padding":e.spacing.headerPadding,"--grid-row-height":e.spacing.rowHeight,"--grid-font-family":e.typography.fontFamily,"--grid-font-size":e.typography.fontSize,"--grid-font-size-sm":e.typography.fontSizeSmall,"--grid-font-weight":e.typography.fontWeight,"--grid-header-font-weight":e.typography.headerFontWeight,"--grid-border-width":e.borders.width,"--grid-border-radius":e.borders.radius,"--grid-border-style":e.borders.style,"--grid-shadow-light":e.shadows.light,"--grid-shadow-medium":e.shadows.medium,"--grid-shadow-heavy":e.shadows.heavy}}const ai=()=>{let e=b.useRef(``),t=(0,b.useRef)(null);(0,b.useEffect)(()=>()=>{t.current&&clearTimeout(t.current)},[]);let n=(0,b.useCallback)((n,r={})=>{let{delay:i=0}=r;t.current&&clearTimeout(t.current),i>0?t.current=setTimeout(()=>{e.current=n},i):e.current=n},[]);return{announcementRef:e,announce:n,announceSorting:(0,b.useCallback)((e,t)=>{n(t?`Sorted by ${e} ${t===`asc`?`ascending`:`descending`}`:`Sorting cleared`)},[n]),announceSelection:(0,b.useCallback)(e=>{n(e===0?`All rows deselected`:e===1?`1 row selected`:`${e} rows selected`)},[n]),announceFiltering:(0,b.useCallback)((e,t,r)=>{n(t?`Filter applied to ${e}${r===void 0?``:`, ${r} results found`}`:`Filter cleared from ${e}`)},[n]),announcePagination:(0,b.useCallback)((e,t,r)=>{n(`Page ${e+1} of ${t}, showing ${r} rows`)},[n]),announceFocus:(0,b.useCallback)((e,t,r)=>{let i=r==null?``:`, value: ${r}`;n(`Row ${e+1}, ${t}${i}`,{delay:100})},[n]),announceEditing:(0,b.useCallback)((e,t)=>{n(t?`Editing ${e}. Press Enter to save, Escape to cancel`:`Edit saved for ${e}`)},[n]),announceRowReorder:(0,b.useCallback)((e,t)=>{n(`Row moved from position ${e+1} to position ${t+1}`)},[n]),announceColumnVisibility:(0,b.useCallback)((e,t)=>{n(t?`${e} column shown`:`${e} column hidden`)},[n]),announceLoading:(0,b.useCallback)((e,t)=>{e?n(t||`Loading data...`,{priority:`assertive`}):n(`Data loaded`,{priority:`polite`})},[n])}},oi=({message:e,priority:t=`polite`})=>(0,Z.jsx)(`div`,{role:t===`assertive`?`alert`:`status`,"aria-live":t,"aria-atomic":`true`,style:{position:`absolute`,left:`-10000px`,width:`1px`,height:`1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`},children:e});var si=class{state;dispatch;columns;rows;persistenceManager=null;destroyed=!1;containerRef;eventListeners=new Map;setInternalRows;constructor(e,t,n,r,i,a,o){this.state=e,this.dispatch=t,this.columns=n,this.rows=r,this.containerRef=i,this.persistenceManager=a||null,this.setInternalRows=o}updateState(e){this.state=e}updateData(e,t){this.columns=e,this.rows=t}updateCallbacks(e){this.setInternalRows=e}setRowData(e){this.ensureNotDestroyed(),this.rows=e,this.setInternalRows&&this.setInternalRows(e),this.dispatch({type:`SET_ROW_DATA`,payload:e}),this.fireEvent(`rowDataChanged`,{api:this,rows:e})}applyTransaction(e){this.ensureNotDestroyed();let t={add:[],remove:[],update:[]},n=[...this.rows];if(e.remove&&e.remove.length>0){let r=new Set(e.remove.map(e=>e.id)),i=n.filter(e=>r.has(e.id));n=n.filter(e=>!r.has(e.id)),t.remove=i.map((e,t)=>this.createRowNode(e,t))}if(e.update&&e.update.length>0){let r=new Map(e.update.map(e=>[e.id,e]));n=n.map(e=>{let n=r.get(e.id);return n?(t.update.push(this.createRowNode(n,0)),{...e,...n}):e})}if(e.add&&e.add.length>0){let r=e.addIndex??n.length;n.splice(r,0,...e.add),t.add=e.add.map((e,t)=>this.createRowNode(e,r+t))}return this.setRowData(n),this.fireEvent(`rowDataUpdated`,{api:this,transaction:t}),t}async applyTransactionAsync(e){return Promise.resolve(this.applyTransaction(e))}getModel(){return{getRowCount:()=>this.rows.length,getRow:e=>{let t=this.rows[e];return t?this.createRowNode(t,e):null},forEachNode:e=>{this.rows.forEach((t,n)=>{e(this.createRowNode(t,n),n)})}}}getDisplayedRowCount(){return this.ensureNotDestroyed(),this.getDisplayedRows().length}getDisplayedRowAtIndex(e){this.ensureNotDestroyed();let t=this.getDisplayedRows()[e];return t?this.createRowNode(t,e):null}forEachNode(e){this.ensureNotDestroyed(),this.rows.forEach((t,n)=>{e(this.createRowNode(t,n),n)})}forEachNodeAfterFilter(e){this.ensureNotDestroyed(),this.getFilteredRows().forEach((t,n)=>{e(this.createRowNode(t,n),n)})}forEachNodeAfterFilterAndSort(e){this.ensureNotDestroyed(),this.getDisplayedRows().forEach((t,n)=>{e(this.createRowNode(t,n),n)})}getFirstDisplayedRow(){return 0}getLastDisplayedRow(){return Math.max(0,this.getDisplayedRowCount()-1)}getColumnDefs(){return this.ensureNotDestroyed(),[...this.columns]}setColumnDefs(e){this.ensureNotDestroyed(),this.columns=e,this.dispatch({type:`SET_COLUMN_DEFS`,payload:e}),this.fireEvent(`columnDefsChanged`,{api:this,columnDefs:e})}getAllColumns(){return this.getColumnDefs()}getDisplayedCenterColumns(){this.ensureNotDestroyed();let e=new Set(this.state.pinnedColumnsLeft),t=new Set(this.state.pinnedColumnsRight),n=new Set(this.state.hiddenColumns);return this.state.columnOrder.filter(r=>!e.has(r)&&!t.has(r)&&!n.has(r)).map(e=>this.columns.find(t=>t.field===e)).filter(e=>e!==void 0)}getDisplayedLeftColumns(){this.ensureNotDestroyed();let e=new Set(this.state.hiddenColumns);return this.state.pinnedColumnsLeft.filter(t=>!e.has(t)).map(e=>this.columns.find(t=>t.field===e)).filter(e=>e!==void 0)}getDisplayedRightColumns(){this.ensureNotDestroyed();let e=new Set(this.state.hiddenColumns);return this.state.pinnedColumnsRight.filter(t=>!e.has(t)).map(e=>this.columns.find(t=>t.field===e)).filter(e=>e!==void 0)}setColumnVisible(e,t){this.ensureNotDestroyed();let n=this.resolveColKey(e);n&&(this.dispatch({type:`SET_COLUMN_VISIBILITY`,payload:{field:n,visible:t}}),this.fireEvent(`columnVisible`,{api:this,column:n,visible:t}))}setColumnsVisible(e,t){this.ensureNotDestroyed(),e.forEach(e=>this.setColumnVisible(e,t))}setColumnPinned(e,t){this.ensureNotDestroyed();let n=this.resolveColKey(e);n&&(t?this.dispatch({type:`PIN_COLUMN`,payload:{field:n,side:t}}):this.dispatch({type:`UNPIN_COLUMN`,payload:n}),this.fireEvent(`columnPinned`,{api:this,column:n,pinned:t}))}autoSizeColumns(e){if(this.ensureNotDestroyed(),!e||e.length===0){this.autoSizeAllColumns();return}e.forEach(e=>{let t=this.resolveColKey(e);if(t){let e=this.calculateColumnWidth(t);this.dispatch({type:`RESIZE_COLUMN`,payload:{field:t,width:e}})}}),this.fireEvent(`columnResized`,{api:this,columns:e})}autoSizeAllColumns(){this.ensureNotDestroyed();let e={};this.columns.forEach(t=>{e[t.field]=this.calculateColumnWidth(t.field)}),Object.entries(e).forEach(([e,t])=>{this.dispatch({type:`RESIZE_COLUMN`,payload:{field:e,width:t}})}),this.fireEvent(`columnResized`,{api:this,columns:Object.keys(e)})}moveColumn(e,t){this.ensureNotDestroyed();let n=this.resolveColKey(e);if(n){let e=this.state.columnOrder.indexOf(n);e!==-1&&(this.dispatch({type:`REORDER_COLUMNS`,payload:{fromIndex:e,toIndex:t}}),this.fireEvent(`columnMoved`,{api:this,column:n,toIndex:t}))}}moveColumns(e,t){this.ensureNotDestroyed(),e.forEach((e,n)=>{this.moveColumn(e,t+n)})}getColumnState(){this.ensureNotDestroyed();let e=new Set(this.state.pinnedColumnsLeft),t=new Set(this.state.pinnedColumnsRight);return this.state.columnOrder.map(n=>{let r=this.state.hiddenColumns.includes(n),i=this.state.sortConfig.field===n;return{colId:n,width:this.state.columnWidths[n],hide:r,pinned:e.has(n)?`left`:t.has(n)?`right`:null,sort:i?this.state.sortConfig.direction:null,sortIndex:i?0:void 0}})}applyColumnState(e){this.ensureNotDestroyed(),e.forEach(e=>{let{colId:t,width:n,hide:r,pinned:i,sort:a}=e;n!==void 0&&this.dispatch({type:`RESIZE_COLUMN`,payload:{field:t,width:n}}),r!==void 0&&r!==this.state.hiddenColumns.includes(t)&&this.dispatch({type:`TOGGLE_COLUMN_VISIBILITY`,payload:t}),i!==void 0&&this.setColumnPinned(t,i),a!=null&&this.dispatch({type:`SORT_COLUMN`,payload:t})}),this.fireEvent(`columnStateChanged`,{api:this,state:e})}resetColumnState(){this.ensureNotDestroyed(),this.dispatch({type:`RESET_COLUMN_STATE`}),this.fireEvent(`columnStateReset`,{api:this})}getColumn(e){let t=this.resolveColKey(e);return t&&this.columns.find(e=>e.field===t)||null}isAnyFilterPresent(){return this.ensureNotDestroyed(),Object.keys(this.state.filterConfig).length>0}getFilterModel(){return this.ensureNotDestroyed(),{...this.state.filterConfig}}setFilterModel(e){this.ensureNotDestroyed(),Object.entries(e).forEach(([e,t])=>{this.dispatch({type:`SET_FILTER`,payload:{field:e,value:t}})}),this.fireEvent(`filterChanged`,{api:this,filterModel:e})}onFilterChanged(){this.ensureNotDestroyed(),this.fireEvent(`filterChanged`,{api:this,filterModel:this.getFilterModel()})}destroyFilter(e){this.ensureNotDestroyed();let t=this.resolveColKey(e);t&&this.dispatch({type:`SET_FILTER`,payload:{field:t,value:null}})}getFilterInstance(e){return null}clearAllFilters(){this.ensureNotDestroyed(),this.dispatch({type:`CLEAR_FILTERS`}),this.fireEvent(`filterChanged`,{api:this,filterModel:{}})}getSortModel(){return this.ensureNotDestroyed(),this.state.sortConfig.field&&this.state.sortConfig.direction?[this.state.sortConfig]:[]}setSortModel(e){this.ensureNotDestroyed();let t=e.length>0?e[0]:{field:``,direction:null};this.dispatch({type:`SET_SORT`,payload:t}),this.fireEvent(`sortChanged`,{api:this,sortModel:e})}onSortChanged(){this.ensureNotDestroyed(),this.fireEvent(`sortChanged`,{api:this,sortModel:this.getSortModel()})}clearAllSorting(){this.ensureNotDestroyed(),this.dispatch({type:`SET_SORT`,payload:{field:``,direction:null}}),this.fireEvent(`sortChanged`,{api:this,sortModel:[]})}getSelectedNodes(){this.ensureNotDestroyed();let e=Array.from(this.state.selection.selectedRows);return this.rows.filter(t=>e.includes(t.id)).map((e,t)=>this.createRowNode(e,t,!0))}getSelectedRows(){this.ensureNotDestroyed();let e=Array.from(this.state.selection.selectedRows);return this.rows.filter(t=>e.includes(t.id))}selectAll(){this.ensureNotDestroyed();let e=this.rows.map(e=>e.id);this.dispatch({type:`SELECT_RANGE`,payload:{startIndex:0,endIndex:this.rows.length-1,rowIds:e}}),this.fireEvent(`selectionChanged`,{api:this})}deselectAll(){this.ensureNotDestroyed(),this.dispatch({type:`DESELECT_ALL_ROWS`}),this.fireEvent(`selectionChanged`,{api:this})}selectAllFiltered(){this.ensureNotDestroyed();let e=this.getFilteredRows(),t=e.map(e=>e.id);this.dispatch({type:`SELECT_RANGE`,payload:{startIndex:0,endIndex:e.length-1,rowIds:t}}),this.fireEvent(`selectionChanged`,{api:this})}deselectAllFiltered(){this.ensureNotDestroyed();let e=this.getFilteredRows(),t=new Set(e.map(e=>e.id));Array.from(this.state.selection.selectedRows).forEach(e=>{t.has(e)&&this.dispatch({type:`DESELECT_ROW`,payload:e})}),this.fireEvent(`selectionChanged`,{api:this})}getSelectedRowCount(){return this.state.selection.selectedRows.size}ensureIndexVisible(e,t){if(this.ensureNotDestroyed(),!this.containerRef.current)return;let n=this.containerRef.current.querySelector(`[data-row-index="${e}"]`);if(n){let e={behavior:`smooth`,block:t===`top`?`start`:t===`bottom`?`end`:`center`};n.scrollIntoView(e)}}ensureNodeVisible(e,t){this.ensureIndexVisible(e.rowIndex,t)}setFocusedCell(e,t){this.ensureNotDestroyed();let n=this.resolveColKey(t);if(n){let t=this.state.columnOrder.indexOf(n);t!==-1&&(this.dispatch({type:`SET_FOCUS`,payload:{rowIndex:e,columnIndex:t}}),this.fireEvent(`cellFocused`,{api:this,rowIndex:e,column:n}))}}clearFocusedCell(){this.ensureNotDestroyed(),this.dispatch({type:`CLEAR_FOCUS`}),this.fireEvent(`cellFocusCleared`,{api:this})}getFocusedCell(){if(!this.state.focusState)return null;let e=this.state.columnOrder[this.state.focusState.columnIndex],t=this.columns.find(t=>t.field===e);return t?{rowIndex:this.state.focusState.rowIndex,column:t}:null}startEditingCell(e){this.ensureNotDestroyed();let t=this.resolveColKey(e.colKey);if(t){let n=this.getDisplayedRowAtIndex(e.rowIndex);n&&(this.dispatch({type:`START_EDITING`,payload:{rowId:n.id,field:t,value:n.data[t]}}),this.fireEvent(`cellEditingStarted`,{api:this,...e}))}}stopEditing(e=!1){this.ensureNotDestroyed(),e?this.dispatch({type:`CANCEL_EDITING`}):this.dispatch({type:`SAVE_EDIT`}),this.fireEvent(`cellEditingStopped`,{api:this,cancel:e})}getEditingCells(){if(!this.state.editState.rowId)return[];let e=this.columns.find(e=>e.field===this.state.editState.field);if(!e)return[];let t=this.rows.findIndex(e=>e.id===this.state.editState.rowId);return t===-1?[]:[{rowIndex:t,column:e}]}refreshCells(e){this.ensureNotDestroyed(),this.dispatch({type:`REFRESH_CELLS`,payload:e}),this.fireEvent(`cellsRefreshed`,{api:this,params:e})}refreshHeader(){this.ensureNotDestroyed(),this.dispatch({type:`REFRESH_HEADER`}),this.fireEvent(`headerRefreshed`,{api:this})}refreshToolPanel(){this.ensureNotDestroyed(),this.fireEvent(`toolPanelRefreshed`,{api:this})}redrawRows(e){this.ensureNotDestroyed(),this.dispatch({type:`REDRAW_ROWS`,payload:e}),this.fireEvent(`rowsRedrawn`,{api:this,params:e})}sizeColumnsToFit(){if(this.ensureNotDestroyed(),!this.containerRef.current)return;let e=this.containerRef.current.clientWidth,t=this.getDisplayedCenterColumns().concat(this.getDisplayedLeftColumns()).concat(this.getDisplayedRightColumns());if(t.length===0)return;let n=e/t.reduce((e,t)=>e+(this.state.columnWidths[t.field]||t.width||150),0);t.forEach(e=>{let t=this.state.columnWidths[e.field]||e.width||150,r=Math.max(50,Math.floor(t*n));this.dispatch({type:`RESIZE_COLUMN`,payload:{field:e.field,width:r}})}),this.fireEvent(`columnResized`,{api:this,reason:`sizeColumnsToFit`})}doLayout(){this.ensureNotDestroyed(),this.dispatch({type:`RECALCULATE_LAYOUT`}),this.fireEvent(`layoutChanged`,{api:this})}exportDataAsCsv(e){this.ensureNotDestroyed();let t=this.getDataAsCsv(e),n=(e?.fileName||`export`)+`.csv`,r=new Blob([t],{type:`text/csv;charset=utf-8;`}),i=document.createElement(`a`),a=URL.createObjectURL(r);i.setAttribute(`href`,a),i.setAttribute(`download`,n),i.style.visibility=`hidden`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(a),this.fireEvent(`csvExported`,{api:this,params:e})}getDataAsCsv(e){this.ensureNotDestroyed();let t=e?.columnSeparator||`,`,n=e?.suppressQuotes||!1,r=this.columns;e?.columnKeys&&(r=e.columnKeys.map(e=>this.resolveColKey(e)).filter(Boolean).map(e=>this.columns.find(t=>t.field===e)).filter(e=>e!==void 0));let i=e?.onlySelected?this.getSelectedRows():e?.onlyFiltered?this.getFilteredRows():this.rows,a=[];if(!e?.skipHeader){let e=r.map(e=>this.formatCsvValue(e.headerName,n)).join(t);a.push(e)}return i.forEach((i,o)=>{let s=this.createRowNode(i,o),c=r.map(t=>{let r=i[t.field],a=r;return e?.processCellCallback&&(a=e.processCellCallback({value:r,column:t,node:s})),this.formatCsvValue(a,n)}).join(t);a.push(c)}),a.join(`
45
45
  `)}exportDataAsExcel(e){this.ensureNotDestroyed(),console.warn(`Excel export not fully implemented, exporting as CSV instead`),this.exportDataAsCsv(e)}copySelectedRowsToClipboard(){this.ensureNotDestroyed();let e=this.getDataAsCsv({onlySelected:!0});this.copyToClipboard(e),this.fireEvent(`clipboardCopy`,{api:this,type:`selectedRows`})}copySelectedRangeToClipboard(){this.ensureNotDestroyed(),this.copySelectedRowsToClipboard()}showLoadingOverlay(){this.ensureNotDestroyed(),this.dispatch({type:`SHOW_OVERLAY`,payload:`loading`}),this.fireEvent(`overlayChanged`,{api:this,overlay:`loading`})}showNoRowsOverlay(){this.ensureNotDestroyed(),this.dispatch({type:`SHOW_OVERLAY`,payload:`noRows`}),this.fireEvent(`overlayChanged`,{api:this,overlay:`noRows`})}hideOverlay(){this.ensureNotDestroyed(),this.dispatch({type:`HIDE_OVERLAY`}),this.fireEvent(`overlayChanged`,{api:this,overlay:null})}paginationGetCurrentPage(){return this.state.currentPage}paginationGoToPage(e){this.ensureNotDestroyed(),this.dispatch({type:`SET_PAGE`,payload:e}),this.fireEvent(`paginationChanged`,{api:this,currentPage:e})}paginationGoToNextPage(){let e=this.paginationGetTotalPages(),t=this.paginationGetCurrentPage();t<e-1&&this.paginationGoToPage(t+1)}paginationGoToPreviousPage(){let e=this.paginationGetCurrentPage();e>0&&this.paginationGoToPage(e-1)}paginationGetTotalPages(){let e=this.paginationGetPageSize(),t=this.getFilteredRows().length;return Math.ceil(t/e)}paginationGetPageSize(){return this.state.pageSize}paginationSetPageSize(e){this.ensureNotDestroyed(),this.dispatch({type:`SET_PAGE_SIZE`,payload:e}),this.fireEvent(`paginationChanged`,{api:this,pageSize:e})}setRowGroupColumns(e){this.ensureNotDestroyed();let t=e.map(e=>this.resolveColKey(e)).filter(Boolean);this.dispatch({type:`SET_GROUP_BY`,payload:t}),this.fireEvent(`columnRowGroupChanged`,{api:this,columns:t})}addRowGroupColumn(e){this.ensureNotDestroyed();let t=this.resolveColKey(e);t&&!this.state.groupBy.includes(t)&&(this.dispatch({type:`SET_GROUP_BY`,payload:[...this.state.groupBy,t]}),this.fireEvent(`columnRowGroupChanged`,{api:this,columns:this.state.groupBy}))}removeRowGroupColumn(e){this.ensureNotDestroyed();let t=this.resolveColKey(e);if(t){let e=this.state.groupBy.filter(e=>e!==t);this.dispatch({type:`SET_GROUP_BY`,payload:e}),this.fireEvent(`columnRowGroupChanged`,{api:this,columns:e})}}getRowGroupColumns(){return this.state.groupBy.map(e=>this.columns.find(t=>t.field===e)).filter(e=>e!==void 0)}expandAll(){this.ensureNotDestroyed(),this.dispatch({type:`EXPAND_ALL_NODES`}),this.fireEvent(`expandedChanged`,{api:this,expanded:!0})}collapseAll(){this.ensureNotDestroyed(),this.dispatch({type:`COLLAPSE_ALL_NODES`}),this.fireEvent(`expandedChanged`,{api:this,expanded:!1})}onGroupExpandedOrCollapsed(e){this.ensureNotDestroyed(),this.fireEvent(`rowGroupOpened`,{api:this,node:e})}async saveLayout(e){if(this.ensureNotDestroyed(),!this.persistenceManager)throw Error(`Persistence not enabled`);let t=this.getLayoutState(),n={id:Date.now().toString(),name:e,createdAt:Date.now(),updatedAt:Date.now(),layout:t};await this.persistenceManager.savePreset(n),this.fireEvent(`layoutSaved`,{api:this,name:e})}async loadLayout(e){if(this.ensureNotDestroyed(),!this.persistenceManager)throw Error(`Persistence not enabled`);let t=await this.persistenceManager.loadPreset(e);t&&(this.applyLayoutState(t.layout),this.fireEvent(`layoutLoaded`,{api:this,name:e}))}getLayoutState(){return{columnOrder:this.state.columnOrder,columnWidths:this.state.columnWidths,pinnedColumnsLeft:this.state.pinnedColumnsLeft,pinnedColumnsRight:this.state.pinnedColumnsRight,hiddenColumns:this.state.hiddenColumns,sortConfig:this.state.sortConfig,filterConfig:this.state.filterConfig,pageSize:this.state.pageSize,groupBy:this.state.groupBy}}applyLayoutState(e){this.ensureNotDestroyed(),this.dispatch({type:`LOAD_LAYOUT_PRESET`,payload:e}),this.fireEvent(`layoutApplied`,{api:this,layout:e})}destroy(){this.destroyed||(this.destroyed=!0,this.eventListeners.clear(),this.fireEvent(`gridDestroyed`,{api:this}))}isDestroyed(){return this.destroyed}addEventListener(e,t){this.eventListeners.has(e)||this.eventListeners.set(e,new Set),this.eventListeners.get(e).add(t)}removeEventListener(e,t){let n=this.eventListeners.get(e);n&&n.delete(t)}ensureNotDestroyed(){if(this.destroyed)throw Error(`Grid API has been destroyed`)}createRowNode(e,t,n=!1){let r=n||this.state.selection.selectedRows.has(e.id);return{id:e.id,data:e,rowIndex:t,selected:r,setSelected:(t,n=!1)=>{n&&this.deselectAll(),t?this.dispatch({type:`SELECT_ROW`,payload:{rowId:e.id,ctrlKey:!0}}):this.dispatch({type:`DESELECT_ROW`,payload:e.id})}}}resolveColKey(e){return typeof e==`string`?e:typeof e==`number`&&this.state.columnOrder[e]||null}getDisplayedRows(){let e=this.getFilteredRows();return this.state.sortConfig.field&&this.state.sortConfig.direction&&(e=this.applySorting(e)),e}getFilteredRows(){return Object.keys(this.state.filterConfig).length===0?this.rows:this.rows.filter(e=>Object.entries(this.state.filterConfig).every(([t,n])=>{if(!n)return!0;let r=e[t];if(`operator`in n&&`conditions`in n)return!0;let i=n.value;return i==null?!0:r==null?!1:String(r).toLowerCase().includes(String(i).toLowerCase())}))}applySorting(e){let t=this.state.sortConfig;return!t.field||!t.direction?e:[...e].sort((e,n)=>{let r=e[t.field],i=n[t.field],a=0;return r<i&&(a=-1),r>i&&(a=1),t.direction===`asc`?a:-a})}calculateColumnWidth(e){let t=this.columns.find(t=>t.field===e);if(!t)return 150;let n=t.headerName.length*8+40,r=this.rows.slice(0,10).reduce((t,n)=>{let r=String(n[e]||``);return Math.max(t,r.length*8+20)},0);return Math.max(100,Math.min(400,Math.max(n,r)))}formatCsvValue(e,t){if(e==null)return``;let n=String(e);return t?n:n.includes(`,`)||n.includes(`"`)||n.includes(`
46
- `)?`"${n.replace(/"/g,`""`)}"`:n}copyToClipboard(e){if(navigator.clipboard)navigator.clipboard.writeText(e).catch(e=>{console.error(`Failed to copy to clipboard:`,e)});else{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select(),document.execCommand(`copy`),document.body.removeChild(t)}}fireEvent(e,t){let n=this.eventListeners.get(e);n&&n.forEach(n=>{try{n(t)}catch(t){console.error(`Error in ${e} listener:`,t)}})}};const ci=(0,b.forwardRef)(({columns:e,rows:t,pageSize:n=10,showColumnPinning:r=!0,footerConfig:i,virtualScrollConfig:a,persistenceConfig:o,treeConfig:s,dragRowConfig:c,rowPinConfig:l,contextMenuConfig:u,tooltipConfig:d,tableId:f,theme:p=`quartz`,densityMode:m=`normal`,showDensityToggle:h=!1,onDensityChange:g,onRowClick:_,onCellEdit:v,onSelectionChange:y,onLayoutChange:x,onRowReorder:S,onGridReady:C},w)=>{let[T]=(0,b.useState)(``),[E,D]=(0,b.useReducer)(fn,{columns:e,pageSize:n},e=>dn(e.columns,e.pageSize)),[O,k]=(0,b.useState)(null),A=O===null?t:O,j=(0,b.useRef)(t);(0,b.useEffect)(()=>{if(t!==j.current){j.current=t;let e=setTimeout(()=>k(null),0);return()=>clearTimeout(e)}},[t]);let M=(0,b.useRef)(null),N=(0,b.useRef)(null),{densityMode:P,setDensityMode:F,densityStyles:I}=Pr({initialMode:m,persist:!0,onChange:g});(0,b.useEffect)(()=>{m&&m!==P&&F(m)},[m,P,F]);let L=(0,b.useMemo)(()=>ii(ri(p)),[p]),{announceSorting:R,announceSelection:z,announcePagination:ee}=ai(),[B,V]=(0,b.useState)(null),te=(0,b.useRef)(null),H=(0,b.useRef)(null),{tooltipState:U,tooltipHandlers:ne}=Er({config:d}),{contextMenu:W,handleContextMenu:G,closeContextMenu:re}=Cr({config:u,columns:e,rows:t,selectedRows:E.selection.selectedRows,onPinColumn:(e,t)=>D({type:`PIN_COLUMN`,payload:{field:e,side:t}}),onUnpinColumn:e=>D({type:`UNPIN_COLUMN`,payload:e}),onToggleColumnVisibility:e=>D({type:`TOGGLE_COLUMN_VISIBILITY`,payload:e}),onResizeColumn:(e,t)=>D({type:`RESIZE_COLUMN`,payload:{field:e,width:t}}),onAutoSizeAllColumns:e=>{Object.entries(e).forEach(([e,t])=>{D({type:`RESIZE_COLUMN`,payload:{field:e,width:t}})})},onSetFilter:(e,t)=>D({type:`SET_FILTER`,payload:{field:e,value:t}}),onPinRowTop:l?.enabled?e=>D({type:`PIN_ROW_TOP`,payload:e}):void 0,onPinRowBottom:l?.enabled?e=>D({type:`PIN_ROW_BOTTOM`,payload:e}):void 0,onUnpinRow:l?.enabled?e=>D({type:`UNPIN_ROW`,payload:e}):void 0,pinnedColumnsLeft:E.pinnedColumnsLeft,pinnedColumnsRight:E.pinnedColumnsRight,pinnedRowsTop:E.pinnedRowsTop,pinnedRowsBottom:E.pinnedRowsBottom});(0,b.useEffect)(()=>{if(o?.enabled){let e=new pr(o),t=setTimeout(()=>V(e),0);return o.autoLoad&&e.loadAutoSave().then(e=>{e&&D({type:`LOAD_LAYOUT_PRESET`,payload:e.layout})}).catch(e=>{console.error(`Failed to load auto-saved layout:`,e)}),()=>clearTimeout(t)}},[o]);let K=(0,b.useMemo)(()=>JSON.stringify(E.sortConfig),[E.sortConfig]),ie=(0,b.useMemo)(()=>JSON.stringify(E.filterConfig),[E.filterConfig]),ae=(0,b.useCallback)(()=>({columnOrder:E.columnOrder,columnWidths:E.columnWidths,pinnedColumnsLeft:E.pinnedColumnsLeft,pinnedColumnsRight:E.pinnedColumnsRight,hiddenColumns:E.hiddenColumns,sortConfig:E.sortConfig,filterConfig:E.filterConfig,pageSize:E.pageSize,groupBy:E.groupBy}),[E.columnOrder,E.columnWidths,E.pinnedColumnsLeft,E.pinnedColumnsRight,E.hiddenColumns,E.sortConfig,E.filterConfig,E.pageSize,E.groupBy]);(0,b.useEffect)(()=>{(!N.current||N.current.isDestroyed())&&(N.current=new si(E,D,e,A,M,B,k))},[]),(0,b.useEffect)(()=>{N.current&&!N.current.isDestroyed()&&(N.current.updateState(E),N.current.updateData(e,A),N.current.updateCallbacks(k))},[E,e,A,k]),(0,b.useImperativeHandle)(w,()=>((!N.current||N.current.isDestroyed())&&(N.current=new si(E,D,e,A,M,B,k)),N.current),[E,e,A,B]);let oe=(0,b.useRef)(!1),q=(0,b.useRef)(C);(0,b.useEffect)(()=>{q.current=C},[C]),(0,b.useEffect)(()=>{N.current&&q.current&&!oe.current&&(oe.current=!0,q.current(N.current))},[]),(0,b.useEffect)(()=>()=>{N.current&&N.current.destroy()},[]),(0,b.useEffect)(()=>{if(!o?.enabled||!o.autoSave||!B)return;let e=mr(()=>{let e=ae();B.autoSave(e).catch(e=>{console.error(`Failed to auto-save layout:`,e)})},o.autoSaveDelay||1e3);return te.current=e,e(),()=>{te.current=null}},[o,B,E.columnOrder,E.columnWidths,E.pinnedColumnsLeft,E.pinnedColumnsRight,E.hiddenColumns,K,ie,E.pageSize,E.groupBy]),(0,b.useEffect)(()=>{if(x){let e=ae(),t=JSON.stringify(e);H.current!==t&&(H.current=t,x(e))}},[x,E.columnOrder,E.columnWidths,E.pinnedColumnsLeft,E.pinnedColumnsRight,E.hiddenColumns,K,ie,E.pageSize,E.groupBy]);let se=new Set(E.hiddenColumns),ce=E.columnOrder.filter(e=>!se.has(e)),J=E.pinnedColumnsLeft.filter(e=>ce.includes(e)),le=E.pinnedColumnsRight.filter(e=>ce.includes(e)),ue=new Set(J),Y=new Set(le),de=ce.filter(e=>!ue.has(e)&&!Y.has(e)),fe=[...J,...de,...le];(0,b.useEffect)(()=>{D({type:`RESET_COLUMNS`,payload:e})},[e]),(0,b.useEffect)(()=>{y&&y(Array.from(E.selection.selectedRows)),z(E.selection.selectedRows.size)},[E.selection.selectedRows]);let X=(0,b.useRef)(!1);(0,b.useEffect)(()=>{X.current&&l?.onPinChange&&l.onPinChange(E.pinnedRowsTop,E.pinnedRowsBottom),X.current=!0},[E.pinnedRowsTop,E.pinnedRowsBottom]),(0,b.useEffect)(()=>{if(E.sortConfig.field){let t=e.find(e=>e.field===E.sortConfig.field);t&&R(t.headerName,E.sortConfig.direction)}},[E.sortConfig.field,E.sortConfig.direction]);let pe=(0,b.useMemo)(()=>{if(!E.sortConfig.field||!E.sortConfig.direction)return A;let e=[...A].sort((e,t)=>{let n=e[E.sortConfig.field],r=t[E.sortConfig.field];return n==null&&r==null?0:n==null?1:r==null?-1:typeof n==`string`&&typeof r==`string`?n.localeCompare(r):n<r?-1:n>r?1:0});return E.sortConfig.direction===`desc`&&e.reverse(),e},[A,E.sortConfig]),me=(0,b.useMemo)(()=>Gr(E.filterConfig)?Wr(pe,E.filterConfig):pe,[pe,E.filterConfig]),he=(0,b.useMemo)(()=>s?.enabled?Dn(En(me,s),E.expandedNodes,s):me,[me,s,E.expandedNodes]),ge=(0,b.useMemo)(()=>s?.enabled?he:E.groupBy.length===0?me:Sn(me,E.groupBy,E.expandedGroups),[me,he,s,E.groupBy,E.expandedGroups]),_e=(0,b.useMemo)(()=>E.groupBy.length===0?ge:Cn(ge),[ge,E.groupBy]);(0,b.useEffect)(()=>{let e=Math.ceil(_e.length/E.pageSize),t=Math.min(E.pageSize,_e.length-E.currentPage*E.pageSize);t>0&&ee(E.currentPage,e,t)},[E.currentPage,E.pageSize]);let{pinnedRowsTopData:ve,pinnedRowsBottomData:ye,unpinnedRows:be}=(0,b.useMemo)(()=>{let e=new Set(E.pinnedRowsTop),t=new Set(E.pinnedRowsBottom),n=[],r=[],i=[];return _e.forEach(a=>{let o=`id`in a?a.id:`groupKey`in a?a.groupKey:null;o===null?i.push(a):e.has(o)?n.push(a):t.has(o)?r.push(a):i.push(a)}),{pinnedRowsTopData:E.pinnedRowsTop.map(e=>n.find(t=>(`id`in t?t.id:`groupKey`in t?t.groupKey:null)===e)).filter(e=>e!==void 0),pinnedRowsBottomData:E.pinnedRowsBottom.map(e=>r.find(t=>(`id`in t?t.id:`groupKey`in t?t.groupKey:null)===e)).filter(e=>e!==void 0),unpinnedRows:i}},[_e,E.pinnedRowsTop,E.pinnedRowsBottom]),xe=(0,b.useMemo)(()=>{let e=E.currentPage*E.pageSize,t=e+E.pageSize;return be.slice(e,t)},[be,E.currentPage,E.pageSize]),Se=(0,b.useMemo)(()=>!i?.show||!i.aggregates?{}:hn(me.filter(e=>!(`isGroup`in e)),i.aggregates),[me,i]),Ce=(0,b.useMemo)(()=>!i?.showGroupFooters||!i.aggregates||E.groupBy.length===0?new Map:gn(ge,i.aggregates),[ge,i,E.groupBy]);(0,b.useEffect)(()=>{let t={...E.columnWidths},n=!1;e.forEach(e=>{if(e.width)t[e.field]!==e.width&&(t[e.field]=e.width,n=!0);else{let r=e.headerName.length,i=Math.max(150,Math.min(300,r*10+50));t[e.field]||(t[e.field]=i,n=!0)}}),n&&e.forEach(e=>{D({type:`RESIZE_COLUMN`,payload:{field:e.field,width:t[e.field]}})})},[e]);let we=(0,b.useCallback)((e,n,r)=>{if(v){let i=xe[e];`id`in i&&v(t.findIndex(e=>e.id===i.id),n,r)}},[v,xe,t]);return(0,Z.jsxs)(`div`,{ref:M,"data-testid":`data-grid`,role:`grid`,"aria-label":`Data Grid`,"aria-rowcount":_e.length,"aria-colcount":fe.length,style:{...L,...I,border:`var(--grid-border-width, 1px) solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,overflow:`hidden`,backgroundColor:`var(--grid-bg)`,boxShadow:`var(--grid-shadow-light, 0 1px 3px 0 rgba(0, 0, 0, 0.08))`,fontFamily:`var(--grid-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif)`},className:`data-grid density-${P}`,children:[(0,Z.jsx)(oi,{message:T,priority:`polite`}),`// ...existing code...`,(0,Z.jsxs)(`div`,{style:{position:`relative`,display:`flex`,alignItems:`center`,justifyContent:`space-between`,paddingLeft:`16px`,paddingRight:`16px`,paddingTop:`10px`,paddingBottom:`10px`,backgroundColor:`var(--grid-bg-alt)`,borderBottom:`var(--grid-border-width, 1px) solid var(--grid-border)`,zIndex:30},children:[(0,Z.jsxs)(`div`,{style:{position:`relative`,display:`flex`,alignItems:`center`,gap:`8px`},children:[(0,Z.jsx)(zn,{columns:e,columnOrder:E.columnOrder,hiddenColumns:E.hiddenColumns,onToggleVisibility:e=>D({type:`TOGGLE_COLUMN_VISIBILITY`,payload:e}),onReorderColumns:(e,t)=>D({type:`REORDER_COLUMNS`,payload:{fromIndex:e,toIndex:t}}),onResetLayout:()=>D({type:`RESET_COLUMN_LAYOUT`})}),(0,Z.jsx)(qn,{columns:e,fullDataset:t,filteredData:me.filter(e=>!(`isGroup`in e)),selectedRows:E.selection.selectedRows,currentPageData:xe.filter(e=>!(`isGroup`in e))}),o?.enabled&&B&&(0,Z.jsx)(hr,{manager:B,currentLayout:ae(),onLoadPreset:e=>D({type:`LOAD_LAYOUT_PRESET`,payload:e}),onResetLayout:()=>D({type:`RESET_COLUMN_LAYOUT`})})]}),h&&(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`},children:[(0,Z.jsx)(`span`,{style:{fontSize:`13px`,color:`var(--grid-text-secondary)`,fontWeight:`500`},children:`Density:`}),(0,Z.jsx)(Nr,{value:P,onChange:F})]})]}),(0,Z.jsx)(Ln,{columns:e,groupBy:E.groupBy,dispatch:D}),(0,Z.jsxs)(`div`,{role:`rowgroup`,style:{position:`sticky`,top:0,zIndex:20,width:`100%`},children:[(0,Z.jsx)(pn,{columns:e,columnOrder:E.columnOrder,displayColumnOrder:fe,columnWidths:E.columnWidths,sortConfig:E.sortConfig,dispatch:D,pinnedLeft:J,pinnedRight:le,showColumnPinning:r,onContextMenu:(e,t,n)=>G({type:`header`,column:t,columnIndex:n,event:e})}),(0,Z.jsx)(or,{columns:e,displayColumnOrder:fe,columnWidths:E.columnWidths,filterConfig:E.filterConfig,dispatch:D,pinnedLeft:J,pinnedRight:le,rows:me})]}),(0,Z.jsx)(Fn,{columns:e,rows:a?.enabled?be:xe,pinnedRowsTop:ve,pinnedRowsBottom:ye,columnOrder:E.columnOrder,displayColumnOrder:fe,columnWidths:E.columnWidths,selectedRows:E.selection.selectedRows,editState:E.editState,focusState:E.focusState,dispatch:D,onRowClick:_,onCellEdit:we,pinnedLeft:J,pinnedRight:le,showGroupFooters:i?.showGroupFooters,groupAggregates:Ce,aggregateConfigs:i?.aggregates,virtualScrollConfig:a,treeConfig:s,dragRowConfig:c,tableId:f,onRowReorder:S,currentPage:E.currentPage,pageSize:E.pageSize,totalRows:be.length,onContextMenu:(e,t,n,r,i)=>G({type:`cell`,row:t,column:n,rowIndex:r,columnIndex:i,event:e}),...ne}),i?.show&&i.aggregates&&(0,Z.jsx)(Rn,{columns:e,displayColumnOrder:fe,columnWidths:E.columnWidths,aggregates:Se,aggregateConfigs:i.aggregates,pinnedLeft:J,pinnedRight:le}),!a?.enabled&&(0,Z.jsx)(In,{currentPage:E.currentPage,pageSize:E.pageSize,totalRows:be.length,dispatch:D}),W.isOpen&&(0,Z.jsx)(gr,{x:W.x,y:W.y,items:W.items,onClose:re}),d?.enabled&&(0,Z.jsx)(Tr,{state:U,maxWidth:d.maxWidth,offset:d.offset})]})});ci.displayName=`DataGrid`;var li=()=>(0,Z.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,Z.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]}),ui=()=>(0,Z.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,Z.jsx)(`path`,{d:`m21 21-4.35-4.35`})]}),di=()=>(0,Z.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,Z.jsx)(`polyline`,{points:`6 9 12 15 18 9`})}),fi=()=>(0,Z.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,Z.jsx)(`polyline`,{points:`9 18 15 12 9 6`})}),pi=()=>(0,Z.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,Z.jsx)(`polygon`,{points:`22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3`})}),mi=(e,t,n,r)=>{let i=new Map;return e.filter(e=>Object.entries(n).every(([t,n])=>{if(t===r||!n)return!0;if(n&&`values`in n&&n.values){let r=e[t];return n.values.includes(r)}return!0})).forEach(e=>{let n=e[t];if(n!=null){let e=i.get(n)||0;i.set(n,e+1)}}),i},hi=(e,t)=>{let n=[...e];switch(t){case`count`:n.sort((e,t)=>t.count===e.count?e.label.localeCompare(t.label):t.count-e.count);break;case`alpha`:n.sort((e,t)=>e.label.localeCompare(t.label));break;case`value`:n.sort((e,t)=>typeof e.value==`number`&&typeof t.value==`number`?e.value-t.value:String(e.value).localeCompare(String(t.value)));break}return n};const gi=({columns:e,rows:t,facetConfigs:n,filterConfig:r,onFilterChange:i,onClearAll:a,className:o=``,showSearch:s=!0,collapsible:c=!0})=>{let[l,u]=(0,b.useState)(new Map),d=(0,b.useMemo)(()=>n.map(n=>{let i=e.find(e=>e.field===n.field),a=n.label||i?.headerName||n.field,o=r[n.field],s=o&&`values`in o?new Set(o.values||[]):new Set,c=mi(t,n.field,r,n.field),u=[];c.forEach((e,t)=>{u.push({value:t,label:String(t),count:e,selected:s.has(t)})});let d=hi(u,n.sortBy||`count`),f=l.get(n.field)||{expanded:n.expanded!==!1,searchTerm:``,showAll:!1};return{field:n.field,label:a,values:d,expanded:f.expanded,searchTerm:f.searchTerm,showAll:f.showAll}}),[n,e,t,r,l]),f=(e,t)=>{u(n=>{let r=new Map(n),i=r.get(e)||{expanded:!0,searchTerm:``,showAll:!1};return r.set(e,{...i,...t}),r})},p=(e,t)=>{let n=r[e],a=n&&`values`in n?new Set(n.values||[]):new Set;a.has(t)?a.delete(t):a.add(t),a.size===0?i(e,null):i(e,Array.from(a))},m=(e,t)=>{i(e,t)},h=e=>{i(e,null)},g=(0,b.useMemo)(()=>Object.values(r).filter(e=>e?!!(`values`in e&&e.values&&e.values.length>0):!1).length,[r]);return(0,Z.jsxs)(`div`,{className:`faceted-search ${o||``}`,style:{backgroundColor:`#ffffff`,borderRight:`1px solid #e5e7eb`,display:`flex`,flexDirection:`column`,height:`100%`},children:[(0,Z.jsx)(`div`,{style:{position:`sticky`,top:0,zIndex:10,backgroundColor:`#ffffff`,borderBottom:`1px solid #e5e7eb`,padding:`16px`,flexShrink:0},children:(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:`8px`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`},children:[(0,Z.jsx)(pi,{}),(0,Z.jsx)(`h3`,{style:{fontSize:`18px`,fontWeight:600,color:`#111827`,margin:0},children:`Filters`}),g>0&&(0,Z.jsx)(`span`,{style:{padding:`2px 8px`,fontSize:`12px`,fontWeight:500,backgroundColor:`#dbeafe`,color:`#1e40af`,borderRadius:`9999px`},children:g})]}),g>0&&a&&(0,Z.jsx)(`button`,{onClick:a,style:{fontSize:`14px`,color:`#2563eb`,fontWeight:500,background:`none`,border:`none`,cursor:`pointer`,padding:0},onMouseOver:e=>e.currentTarget.style.color=`#1d4ed8`,onMouseOut:e=>e.currentTarget.style.color=`#2563eb`,children:`Clear All`})]})}),(0,Z.jsxs)(`div`,{style:{overflowY:`auto`,flex:1},children:[d.map(e=>{let t=n.find(t=>t.field===e.field)?.maxItems||10,r=e.searchTerm?e.values.filter(t=>t.label.toLowerCase().includes(e.searchTerm.toLowerCase())):e.values,i=e.showAll?r:r.slice(0,t),a=r.length>t,o=e.values.filter(e=>e.selected).length;return(0,Z.jsxs)(`div`,{style:{borderBottom:`1px solid #e5e7eb`},children:[(0,Z.jsxs)(`div`,{style:{padding:`16px`,backgroundColor:`#f9fafb`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`},children:[(0,Z.jsxs)(`button`,{onClick:()=>f(e.field,{expanded:!e.expanded}),disabled:!c,style:{display:`flex`,alignItems:`center`,gap:`8px`,fontSize:`14px`,fontWeight:600,color:`#111827`,background:`none`,border:`none`,cursor:c?`pointer`:`default`,padding:0},onMouseOver:e=>c&&(e.currentTarget.style.color=`#374151`),onMouseOut:e=>c&&(e.currentTarget.style.color=`#111827`),children:[c&&(e.expanded?(0,Z.jsx)(di,{}):(0,Z.jsx)(fi,{})),(0,Z.jsx)(`span`,{children:e.label}),o>0&&(0,Z.jsx)(`span`,{style:{padding:`2px 8px`,fontSize:`12px`,fontWeight:500,backgroundColor:`#dbeafe`,color:`#1e40af`,borderRadius:`9999px`},children:o})]}),o>0&&(0,Z.jsx)(`button`,{onClick:()=>h(e.field),style:{fontSize:`12px`,color:`#6b7280`,background:`none`,border:`none`,cursor:`pointer`,padding:0,display:`flex`,alignItems:`center`},onMouseOver:e=>e.currentTarget.style.color=`#374151`,onMouseOut:e=>e.currentTarget.style.color=`#6b7280`,children:(0,Z.jsx)(li,{})})]}),s&&e.expanded&&e.values.length>5&&(0,Z.jsxs)(`div`,{style:{marginTop:`8px`,position:`relative`},children:[(0,Z.jsx)(`div`,{style:{position:`absolute`,left:`8px`,top:`8px`,color:`#9ca3af`},children:(0,Z.jsx)(ui,{})}),(0,Z.jsx)(`input`,{type:`text`,value:e.searchTerm,onChange:t=>f(e.field,{searchTerm:t.target.value}),placeholder:`Search...`,style:{width:`100%`,paddingLeft:`32px`,paddingRight:`12px`,paddingTop:`6px`,paddingBottom:`6px`,fontSize:`14px`,border:`1px solid #d1d5db`,borderRadius:`4px`,outline:`none`},onFocus:e=>e.currentTarget.style.boxShadow=`0 0 0 2px #3b82f6`,onBlur:e=>e.currentTarget.style.boxShadow=`none`})]})]}),e.expanded&&(0,Z.jsx)(`div`,{style:{padding:`16px`,display:`flex`,flexDirection:`column`,gap:`4px`},children:i.length===0?(0,Z.jsx)(`div`,{style:{fontSize:`14px`,color:`#6b7280`,fontStyle:`italic`},children:`No values found`}):(0,Z.jsxs)(Z.Fragment,{children:[r.length>1&&o<r.length&&(0,Z.jsxs)(`button`,{onClick:()=>m(e.field,r.map(e=>e.value)),style:{width:`100%`,textAlign:`left`,fontSize:`14px`,color:`#2563eb`,fontWeight:500,padding:`4px 0`,background:`none`,border:`none`,cursor:`pointer`},onMouseOver:e=>e.currentTarget.style.color=`#1d4ed8`,onMouseOut:e=>e.currentTarget.style.color=`#2563eb`,children:[`Select All (`,r.length,`)`]}),i.map((t,n)=>(0,Z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,paddingTop:`6px`,paddingBottom:`6px`,paddingLeft:`8px`,paddingRight:`8px`,borderRadius:`4px`,cursor:`pointer`},onMouseOver:e=>e.currentTarget.style.backgroundColor=`#f9fafb`,onMouseOut:e=>e.currentTarget.style.backgroundColor=`transparent`,children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,flex:1,minWidth:0},children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:t.selected,onChange:()=>p(e.field,t.value),style:{width:`16px`,height:`16px`,cursor:`pointer`,accentColor:`#2563eb`}}),(0,Z.jsx)(`span`,{style:{fontSize:`14px`,color:`#374151`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,flex:1},children:t.label})]}),(0,Z.jsx)(`span`,{style:{fontSize:`12px`,color:`#6b7280`,fontWeight:500,marginLeft:`8px`,flexShrink:0},children:t.count})]},`${t.value}-${n}`)),a&&!e.searchTerm&&(0,Z.jsx)(`button`,{onClick:()=>f(e.field,{showAll:!e.showAll}),style:{width:`100%`,textAlign:`left`,fontSize:`14px`,color:`#2563eb`,fontWeight:500,padding:`4px 0`,marginTop:`8px`,background:`none`,border:`none`,cursor:`pointer`},onMouseOver:e=>e.currentTarget.style.color=`#1d4ed8`,onMouseOut:e=>e.currentTarget.style.color=`#2563eb`,children:e.showAll?`Show Less`:`Show More (${r.length-t} more)`})]})})]},e.field)}),d.length===0&&(0,Z.jsxs)(`div`,{style:{padding:`32px`,textAlign:`center`,color:`#6b7280`},children:[(0,Z.jsx)(`div`,{style:{width:`48px`,height:`48px`,margin:`0 auto 12px`,color:`#9ca3af`},children:(0,Z.jsx)(`svg`,{width:`48`,height:`48`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,Z.jsx)(`polygon`,{points:`22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3`})})}),(0,Z.jsx)(`p`,{style:{fontSize:`14px`,margin:0},children:`No facets configured`})]})]})]})};var _i,vi=new Uint8Array(16);function yi(){if(!_i&&(_i=typeof crypto<`u`&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<`u`&&typeof msCrypto.getRandomValues==`function`&&msCrypto.getRandomValues.bind(msCrypto),!_i))throw Error(`crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported`);return _i(vi)}var bi=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function xi(e){return typeof e==`string`&&bi.test(e)}for(var Si=xi,Ci=[],wi=0;wi<256;++wi)Ci.push((wi+256).toString(16).substr(1));function Ti(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(Ci[e[t+0]]+Ci[e[t+1]]+Ci[e[t+2]]+Ci[e[t+3]]+`-`+Ci[e[t+4]]+Ci[e[t+5]]+`-`+Ci[e[t+6]]+Ci[e[t+7]]+`-`+Ci[e[t+8]]+Ci[e[t+9]]+`-`+Ci[e[t+10]]+Ci[e[t+11]]+Ci[e[t+12]]+Ci[e[t+13]]+Ci[e[t+14]]+Ci[e[t+15]]).toLowerCase();if(!Si(n))throw TypeError(`Stringified UUID is invalid`);return n}var Ei=Ti;function Di(e,t,n){e||={};var r=e.random||(e.rng||yi)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){n||=0;for(var i=0;i<16;++i)t[n+i]=r[i];return t}return Ei(r)}var Oi=Di;const ki=({filters:e,onSearch:t,placeholder:n=`Search or add filters...`,maxTokens:r=10})=>{let[i,a]=(0,b.useState)([]),[o,s]=(0,b.useState)(``),[c,l]=(0,b.useState)(!1),[u,d]=(0,b.useState)(null),f=b.useMemo(()=>{if(u){let t=e.find(e=>e.field===u);if(t?.type===`select`||t?.type===`multiselect`){let e=t.options?.filter(e=>e.toLowerCase().includes(o.toLowerCase()))||[];return[{...t,options:e}]}}else return e.filter(e=>e.label.toLowerCase().includes(o.toLowerCase())||e.field.toLowerCase().includes(o.toLowerCase()));return e},[o,u,e]),[p,m]=(0,b.useState)(0),h=(0,b.useRef)(null),g=(0,b.useRef)(null),_=(n,o)=>{let c=e.find(e=>e.field===n);if(!c||i.length>=r)return;let u={id:`${n}-${Oi()}`,field:n,label:c.label,value:o,operator:Array.isArray(o)?`in`:`contains`,color:c.color||C(e.indexOf(c))},f=[...i,u];a(f),t(f),s(``),d(null),l(!1)},v=e=>{let n=i.filter(t=>t.id!==e);a(n),t(n)},y=e=>{(e.type===`text`||e.type===`number`||e.type===`date`||e.type===`select`)&&(d(e.field),s(``),l(!0))},x=e=>{u&&_(u,e)},S=e=>{if(e.key===`ArrowDown`)e.preventDefault(),m(e=>Math.min(e+1,(u?f[0]?.options?.length||0:f.length)-1));else if(e.key===`ArrowUp`)e.preventDefault(),m(e=>Math.max(e-1,0));else if(e.key===`Enter`)if(e.preventDefault(),u){let e=f[0]?.options||[];e[p]?x(e[p]):o.trim()&&_(u,o.trim())}else f[p]&&y(f[p]);else e.key===`Escape`?(l(!1),d(null),s(``)):e.key===`Backspace`&&!o&&i.length>0&&v(i[i.length-1].id)},C=e=>{let t=[`#3b82f6`,`#8b5cf6`,`#ec4899`,`#f59e0b`,`#10b981`,`#06b6d4`];return t[e%t.length]};return(0,b.useEffect)(()=>{let e=e=>{g.current&&!g.current.contains(e.target)&&h.current&&!h.current.contains(e.target)&&l(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,Z.jsxs)(`div`,{style:{position:`relative`,width:`100%`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,flexWrap:`wrap`,gap:`6px`,padding:`8px 12px`,backgroundColor:`#ffffff`,border:`2px solid #e2e8f0`,borderRadius:`8px`,minHeight:`44px`,cursor:`text`,transition:`border-color 0.2s`,...c&&{borderColor:`#3b82f6`}},onClick:()=>h.current?.focus(),children:[i.map(e=>(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`6px`,padding:`4px 8px`,backgroundColor:e.color,color:`#ffffff`,borderRadius:`6px`,fontSize:`13px`,fontWeight:`500`},children:[(0,Z.jsxs)(`span`,{style:{fontWeight:`600`},children:[e.label,`:`]}),(0,Z.jsx)(`span`,{children:Array.isArray(e.value)?e.value.join(`, `):e.value}),(0,Z.jsx)(`button`,{onClick:t=>{t.stopPropagation(),v(e.id)},style:{background:`none`,border:`none`,color:`#ffffff`,cursor:`pointer`,padding:`0 2px`,fontSize:`16px`,lineHeight:`1`,opacity:.8},onMouseEnter:e=>e.currentTarget.style.opacity=`1`,onMouseLeave:e=>e.currentTarget.style.opacity=`0.8`,children:`×`})]},e.id)),(0,Z.jsx)(`input`,{ref:h,type:`text`,value:o,onChange:e=>s(e.target.value),onFocus:()=>l(!0),onKeyDown:S,placeholder:i.length===0?n:``,style:{flex:1,minWidth:`200px`,border:`none`,outline:`none`,fontSize:`14px`,padding:`4px`,backgroundColor:`transparent`},disabled:i.length>=r})]}),c&&(0,Z.jsx)(`div`,{ref:g,style:{position:`absolute`,top:`100%`,left:0,right:0,marginTop:`4px`,backgroundColor:`#ffffff`,border:`1px solid #e2e8f0`,borderRadius:`8px`,boxShadow:`0 4px 6px -1px rgba(0, 0, 0, 0.1)`,maxHeight:`300px`,overflowY:`auto`,zIndex:1e3},children:u?(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{style:{padding:`8px 12px`,fontSize:`12px`,fontWeight:`600`,color:`#64748b`,borderBottom:`1px solid #e2e8f0`,display:`flex`,alignItems:`center`,gap:`8px`},children:[(0,Z.jsx)(`button`,{onClick:()=>{d(null),s(``)},style:{background:`none`,border:`none`,cursor:`pointer`,padding:`2px`,fontSize:`16px`,color:`#64748b`},children:`←`}),e.find(e=>e.field===u)?.label]}),f[0]?.options?.map((e,t)=>(0,Z.jsx)(`div`,{onClick:()=>x(e),style:{padding:`10px 16px`,cursor:`pointer`,fontSize:`14px`,backgroundColor:p===t?`#f1f5f9`:`transparent`,transition:`background-color 0.15s`},onMouseEnter:()=>m(t),children:e},e))]}):(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{style:{padding:`8px 12px`,fontSize:`12px`,fontWeight:`600`,color:`#64748b`,borderBottom:`1px solid #e2e8f0`},children:`Filter by`}),f.map((t,n)=>(0,Z.jsxs)(`div`,{onClick:()=>y(t),style:{padding:`10px 16px`,cursor:`pointer`,fontSize:`14px`,display:`flex`,alignItems:`center`,gap:`10px`,backgroundColor:p===n?`#f1f5f9`:`transparent`,transition:`background-color 0.15s`},onMouseEnter:()=>m(n),children:[(0,Z.jsx)(`div`,{style:{width:`8px`,height:`8px`,borderRadius:`50%`,backgroundColor:t.color||C(e.indexOf(t))}}),(0,Z.jsx)(`span`,{style:{fontWeight:`500`},children:t.label}),(0,Z.jsx)(`span`,{style:{marginLeft:`auto`,fontSize:`12px`,color:`#94a3b8`},children:t.type})]},t.field))]})})]})};var Ai={LOADING:`loading`,LOADED:`loaded`,FAILED:`failed`},ji=class{blockSize;maxConcurrentRequests;cacheBlockCount;cacheTimeout;getRows;blockCache;blockStatus;activeRequests;requestQueue;totalRows;sortModel;filterModel;observers;constructor(e){this.blockSize=e.blockSize||100,this.maxConcurrentRequests=e.maxConcurrentRequests||4,this.cacheBlockCount=e.cacheBlockCount||20,this.cacheTimeout=e.cacheTimeout||300*1e3,this.getRows=e.getRows,this.blockCache=new Map,this.blockStatus=new Map,this.activeRequests=0,this.requestQueue=[],this.totalRows=void 0,this.sortModel=[],this.filterModel={},this.observers=new Set}subscribe(e){return this.observers.add(e),()=>this.observers.delete(e)}notifyObservers(){this.observers.forEach(e=>e())}getBlockIndex(e){return Math.floor(e/this.blockSize)}getBlockStartRow(e){return e*this.blockSize}getBlockEndRow(e){return(e+1)*this.blockSize}isBlockCached(e){let t=this.blockCache.get(e);return t?Date.now()-t.timestamp>this.cacheTimeout?(this.blockCache.delete(e),this.blockStatus.delete(e),!1):!0:!1}purgeCache(){if(this.blockCache.size<=this.cacheBlockCount)return;let e=Array.from(this.blockCache.entries()).sort((e,t)=>e[1].timestamp-t[1].timestamp);e.slice(0,e.length-this.cacheBlockCount).forEach(([e])=>{this.blockCache.delete(e),this.blockStatus.delete(e)})}async fetchBlock(e){let t=this.getBlockStartRow(e),n=this.getBlockEndRow(e),r={startRow:t,endRow:n,sortModel:this.sortModel,filterModel:this.filterModel};try{let i=await this.getRows(r);this.blockCache.set(e,{startRow:t,endRow:n,rows:i.rows,timestamp:Date.now()}),this.blockStatus.set(e,{status:Ai.LOADED,rows:i.rows}),i.lastRow===void 0?i.totalRows!==void 0&&(this.totalRows=i.totalRows):this.totalRows=i.lastRow,this.purgeCache(),this.notifyObservers()}catch(t){console.error(`Failed to fetch block ${e}:`,t),this.blockStatus.set(e,{status:Ai.FAILED,error:t}),this.notifyObservers()}}queueBlockRequest(e){if(this.blockStatus.get(e)?.status===Ai.LOADING||this.isBlockCached(e))return;let t=async()=>{this.activeRequests++,this.blockStatus.set(e,{status:Ai.LOADING});try{await this.fetchBlock(e)}finally{this.activeRequests--,this.processQueue()}};this.activeRequests<this.maxConcurrentRequests?t():this.requestQueue.push(t)}processQueue(){for(;this.activeRequests<this.maxConcurrentRequests&&this.requestQueue.length>0;){let e=this.requestQueue.shift();e&&e()}}ensureBlocksLoaded(e,t){let n=this.getBlockIndex(e),r=this.getBlockIndex(t);for(let e=n;e<=r;e++)this.queueBlockRequest(e);this.queueBlockRequest(n-1),this.queueBlockRequest(r+1)}getRowsInRange(e,t){this.ensureBlocksLoaded(e,t);let n=[],r=this.getBlockIndex(e),i=this.getBlockIndex(t);for(let a=r;a<=i;a++){let r=this.blockCache.get(a);if(r){let i=this.getBlockStartRow(a);r.rows.forEach((r,a)=>{let o=i+a;o>=e&&o<t&&n.push(r)})}else{let r=this.getBlockStartRow(a),i=this.getBlockEndRow(a);for(let a=Math.max(e,r);a<Math.min(t,i);a++)n.push({id:`loading-${a}`,_loading:!0})}}return n}getRow(e){let t=this.getBlockIndex(e);if(!this.isBlockCached(t))return this.queueBlockRequest(t),{id:`loading-${e}`,_loading:!0};let n=this.blockCache.get(t);if(!n)return;let r=e-this.getBlockStartRow(t);return n.rows[r]}getTotalRows(){return this.totalRows}isBlockLoading(e){return this.blockStatus.get(e)?.status===Ai.LOADING}setSortModel(e){this.sortModel=e,this.refresh()}setFilterModel(e){this.filterModel=e,this.refresh()}refresh(){this.blockCache.clear(),this.blockStatus.clear(),this.totalRows=void 0,this.notifyObservers()}purgeBlock(e){this.blockCache.delete(e),this.blockStatus.delete(e)}destroy(){this.blockCache.clear(),this.blockStatus.clear(),this.requestQueue=[],this.observers.clear()}};function Mi(e=1e6,t=300){return new ji({blockSize:100,maxConcurrentRequests:2,cacheBlockCount:20,getRows:async n=>{await new Promise(e=>setTimeout(e,t));let{startRow:r,endRow:i,sortModel:a,filterModel:o}=n,s=[];for(let t=r;t<Math.min(i,e);t++)s.push({id:t,name:`User ${t}`,email:`user${t}@example.com`,age:20+t%50,country:[`USA`,`UK`,`Canada`,`Germany`,`France`][t%5],salary:3e4+t%100*1e3,department:[`Engineering`,`Sales`,`Marketing`,`HR`,`Finance`][t%5]});let c=s;if(o&&Object.keys(o).length>0&&(c=s.filter(e=>Object.entries(o).every(([t,n])=>{if(!n||`operator`in n)return!0;let r=e[t],i=n.value;return n.type===`contains`?String(r).toLowerCase().includes(String(i).toLowerCase()):n.type===`equals`?r===i:n.type===`greaterThan`?r>i:n.type===`lessThan`?r<i:!0}))),a&&a.length>0){let e=a[0];e.field&&e.direction&&c.sort((t,n)=>{let r=t[e.field],i=n[e.field];return r<i?e.direction===`asc`?-1:1:r>i?e.direction===`asc`?1:-1:0})}return{rows:c,totalRows:e,lastRow:s.length<i-r?r+s.length:void 0}}})}const Ni=({columns:e,dataSource:t,pageSize:n=100,showColumnPinning:r=!0,virtualScrollConfig:i,theme:a=`quartz`,onRowClick:o,onCellEdit:s,onSelectionChange:c})=>{let[l,u]=(0,b.useReducer)(fn,{columns:e,pageSize:n},e=>dn(e.columns,e.pageSize)),[d,f]=(0,b.useState)(null),[p,m]=(0,b.useState)(void 0),h=(0,b.useMemo)(()=>ii(ri(a)),[a]);(0,b.useLayoutEffect)(()=>{let e;e=t instanceof ji?t:new ji(t);let n=e.subscribe(()=>{m(e.getTotalRows())});return setTimeout(()=>f(e),0),()=>{n(),t instanceof ji||e.destroy()}},[t]),(0,b.useEffect)(()=>{d&&setTimeout(()=>m(d.getTotalRows()),0)},[d]),(0,b.useEffect)(()=>{d&&l.sortConfig.field&&d.setSortModel([l.sortConfig])},[d,l.sortConfig]),(0,b.useEffect)(()=>{d&&d.setFilterModel(l.filterConfig)},[d,l.filterConfig]);let g=new Set(l.hiddenColumns),_=l.columnOrder.filter(e=>!g.has(e)),v=l.pinnedColumnsLeft.filter(e=>_.includes(e)),y=l.pinnedColumnsRight.filter(e=>_.includes(e)),x=new Set(v),S=new Set(y),C=_.filter(e=>!x.has(e)&&!S.has(e)),w=[...v,...C,...y];(0,b.useEffect)(()=>{u({type:`RESET_COLUMNS`,payload:e})},[e]),(0,b.useEffect)(()=>{c&&c(Array.from(l.selection.selectedRows))},[l.selection.selectedRows]);let[T,E]=(0,b.useState)({start:0,end:n*15}),[D,O]=(0,b.useState)(0),k=(0,b.useMemo)(()=>d?d.getRowsInRange(T.start,T.end):[],[d,T,D]);(0,b.useEffect)(()=>{if(d)return d.subscribe(()=>{O(e=>e+1)})},[d]);let A=(0,b.useCallback)(e=>{if(!d||p===void 0)return;let t=i?.containerHeight||600,n=typeof i?.rowHeight==`number`?i.rowHeight:35,r=Math.ceil(t/n),a=Math.floor(e/n),o=r*5,s=Math.max(0,a-o),c=Math.min(p,a+r+o);(s<T.start||c>T.end)&&E({start:Math.max(0,Math.min(s,T.start)),end:Math.max(c,T.end)})},[d,p,i,T]);(0,b.useEffect)(()=>{let t={...l.columnWidths},n=!1;e.forEach(e=>{if(e.width)t[e.field]!==e.width&&(t[e.field]=e.width,n=!0);else{let r=e.headerName.length,i=Math.max(150,Math.min(300,r*10+50));t[e.field]||(t[e.field]=i,n=!0)}}),n&&e.forEach(e=>{u({type:`RESIZE_COLUMN`,payload:{field:e.field,width:t[e.field]}})})},[e]);let j=(0,b.useCallback)((e,t,r)=>{s&&s(l.currentPage*n+e,t,r)},[s,l.currentPage,n]);return d?(0,Z.jsxs)(`div`,{style:{...h,border:`var(--grid-border-width, 1px) solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,backgroundColor:`var(--grid-bg)`,boxShadow:`var(--grid-shadow-light, 0 1px 3px 0 rgba(0, 0, 0, 0.08))`,fontFamily:`var(--grid-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif)`,display:`flex`,flexDirection:`column`,height:i?.containerHeight?`${i.containerHeight+150}px`:`auto`},children:[(0,Z.jsx)(`div`,{style:{position:`relative`,display:`flex`,alignItems:`center`,justifyContent:`space-between`,paddingLeft:`16px`,paddingRight:`16px`,paddingTop:`10px`,paddingBottom:`10px`,backgroundColor:`var(--grid-bg-alt)`,borderBottom:`var(--grid-border-width, 1px) solid var(--grid-border)`,zIndex:30},children:(0,Z.jsxs)(`div`,{style:{position:`relative`,display:`flex`,alignItems:`center`,gap:`8px`},children:[(0,Z.jsx)(zn,{columns:e,columnOrder:l.columnOrder,hiddenColumns:l.hiddenColumns,onToggleVisibility:e=>u({type:`TOGGLE_COLUMN_VISIBILITY`,payload:e}),onReorderColumns:(e,t)=>u({type:`REORDER_COLUMNS`,payload:{fromIndex:e,toIndex:t}}),onResetLayout:()=>u({type:`RESET_COLUMN_LAYOUT`})}),(0,Z.jsx)(`div`,{style:{fontSize:`14px`,color:`#64748b`,marginLeft:`12px`},children:p===void 0?`Loading...`:`${p.toLocaleString()} total rows`})]})}),(0,Z.jsx)(Ln,{columns:e,groupBy:l.groupBy,dispatch:u}),(0,Z.jsxs)(`div`,{style:{position:`sticky`,top:0,zIndex:20},children:[(0,Z.jsx)(pn,{columns:e,columnOrder:l.columnOrder,displayColumnOrder:w,columnWidths:l.columnWidths,sortConfig:l.sortConfig,dispatch:u,pinnedLeft:v,pinnedRight:y,showColumnPinning:r}),(0,Z.jsx)(or,{columns:e,displayColumnOrder:w,columnWidths:l.columnWidths,filterConfig:l.filterConfig,dispatch:u,pinnedLeft:v,pinnedRight:y,rows:k})]}),(0,Z.jsx)(Fn,{columns:e,rows:k,columnOrder:l.columnOrder,displayColumnOrder:w,columnWidths:l.columnWidths,selectedRows:l.selection.selectedRows,editState:l.editState,focusState:l.focusState,dispatch:u,onRowClick:o,onCellEdit:j,pinnedLeft:v,pinnedRight:y,onScroll:A,virtualScrollConfig:{...i,enabled:!0}}),(0,Z.jsxs)(`div`,{style:{padding:`8px 16px`,backgroundColor:`var(--grid-footer-bg)`,borderTop:`var(--grid-border-width, 1px) solid var(--grid-border)`,fontSize:`var(--grid-font-size-sm, 12px)`,color:`var(--grid-text-secondary)`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,Z.jsx)(`div`,{children:`Server-side infinite scrolling enabled`}),(0,Z.jsxs)(`div`,{children:[`Rows loaded: `,k.length]})]})]}):(0,Z.jsx)(`div`,{style:{padding:`20px`,textAlign:`center`,border:`1px solid #e2e8f0`,borderRadius:`6px`},children:`Loading data source...`})},Pi=({currentTheme:e,onThemeChange:t})=>{let n=[{value:`quartz`,label:`Quartz (Modern White)`},{value:`alpine`,label:`Alpine (Classic Business)`},{value:`material`,label:`Material`},{value:`dark`,label:`Dark Mode`},{value:`nord`,label:`Nord (Arctic)`},{value:`dracula`,label:`Dracula`},{value:`solarized-light`,label:`Solarized Light`},{value:`solarized-dark`,label:`Solarized Dark`},{value:`monokai`,label:`Monokai`},{value:`one-dark`,label:`One Dark`}],r=e=>{t(e.target.value)},i=ri(e);return(0,Z.jsxs)(`div`,{style:{display:`inline-flex`,alignItems:`center`,gap:`8px`},children:[(0,Z.jsx)(`label`,{htmlFor:`theme-selector`,style:{fontSize:`14px`,fontWeight:`500`,color:i.colors.text},children:`Theme:`}),(0,Z.jsx)(`select`,{id:`theme-selector`,value:e,onChange:r,style:{padding:`6px 32px 6px 12px`,fontSize:`14px`,fontFamily:i.typography.fontFamily,color:i.colors.text,backgroundColor:i.colors.background,border:`1px solid ${i.colors.border}`,borderRadius:i.borders.radius,cursor:`pointer`,outline:`none`,appearance:`none`,backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 9L1 4h10z'/%3E%3C/svg%3E")`,backgroundRepeat:`no-repeat`,backgroundPosition:`right 8px center`,transition:`border-color 0.2s`},onMouseEnter:e=>{e.currentTarget.style.borderColor=i.colors.primary},onMouseLeave:e=>{e.currentTarget.style.borderColor=i.colors.border},children:n.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})},Fi=({status:e})=>{let t=(e=>{switch(e.toLowerCase()){case`active`:return{bg:`#dcfce7`,text:`#15803d`,border:`#86efac`};case`inactive`:return{bg:`#fee2e2`,text:`#991b1b`,border:`#fca5a5`};case`pending`:return{bg:`#fef3c7`,text:`#92400e`,border:`#fde047`};case`completed`:return{bg:`#dbeafe`,text:`#1e40af`,border:`#93c5fd`};default:return{bg:`#f3f4f6`,text:`#374151`,border:`#d1d5db`}}})(e);return(0,Z.jsx)(`span`,{style:{display:`inline-flex`,alignItems:`center`,padding:`4px 10px`,borderRadius:`12px`,fontSize:`12px`,fontWeight:600,backgroundColor:t.bg,color:t.text,border:`1px solid ${t.border}`},children:e})},Ii=({value:e,color:t=`#3b82f6`,showLabel:n=!0})=>{let r=Math.max(0,Math.min(100,e));return(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,width:`100%`},children:[(0,Z.jsx)(`div`,{style:{flex:1,height:`8px`,backgroundColor:`#e5e7eb`,borderRadius:`4px`,overflow:`hidden`},children:(0,Z.jsx)(`div`,{style:{width:`${r}%`,height:`100%`,backgroundColor:t,transition:`width 0.3s ease`}})}),n&&(0,Z.jsxs)(`span`,{style:{fontSize:`12px`,fontWeight:500,color:`#6b7280`,minWidth:`35px`},children:[r,`%`]})]})},Li=({src:e,alt:t,text:n,size:r=32})=>(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`},children:[(0,Z.jsx)(`img`,{src:e,alt:t,style:{width:`${r}px`,height:`${r}px`,borderRadius:`50%`,objectFit:`cover`,border:`2px solid #e5e7eb`}}),n&&(0,Z.jsx)(`span`,{style:{fontSize:`13px`},children:n})]}),Ri=({label:e,onClick:t,variant:n=`primary`,disabled:r=!1})=>{let i=(()=>{if(r)return{bg:`#e5e7eb`,text:`#9ca3af`,border:`#d1d5db`,cursor:`not-allowed`};switch(n){case`primary`:return{bg:`#3b82f6`,text:`#ffffff`,border:`#2563eb`,cursor:`pointer`};case`secondary`:return{bg:`#ffffff`,text:`#374151`,border:`#d1d5db`,cursor:`pointer`};case`danger`:return{bg:`#ef4444`,text:`#ffffff`,border:`#dc2626`,cursor:`pointer`}}})();return(0,Z.jsx)(`button`,{onClick:e=>{e.stopPropagation(),r||t(e)},disabled:r,style:{padding:`6px 12px`,fontSize:`12px`,fontWeight:500,backgroundColor:i.bg,color:i.text,border:`1px solid ${i.border}`,borderRadius:`4px`,cursor:i.cursor,transition:`all 0.2s ease`},onMouseEnter:e=>{!r&&n===`primary`?e.currentTarget.style.backgroundColor=`#2563eb`:!r&&n===`secondary`?e.currentTarget.style.backgroundColor=`#f9fafb`:!r&&n===`danger`&&(e.currentTarget.style.backgroundColor=`#dc2626`)},onMouseLeave:e=>{r||(e.currentTarget.style.backgroundColor=i.bg)},children:e})},zi=({text:e,color:t=`#1f2937`,backgroundColor:n=`#f3f4f6`})=>(0,Z.jsx)(`span`,{style:{display:`inline-flex`,alignItems:`center`,padding:`4px 8px`,borderRadius:`4px`,fontSize:`12px`,fontWeight:500,backgroundColor:n,color:t},children:e}),Bi=({priority:e})=>{let t=(()=>{switch(e){case`low`:return{icon:`●`,color:`#10b981`,text:`Low`};case`medium`:return{icon:`●`,color:`#f59e0b`,text:`Medium`};case`high`:return{icon:`●`,color:`#ef4444`,text:`High`};case`critical`:return{icon:`●`,color:`#991b1b`,text:`Critical`}}})();return(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`6px`},children:[(0,Z.jsx)(`span`,{style:{color:t.color,fontSize:`18px`},children:t.icon}),(0,Z.jsx)(`span`,{style:{fontSize:`13px`,fontWeight:500},children:t.text})]})},Vi=({rating:e,maxRating:t=5})=>(0,Z.jsx)(`div`,{style:{display:`flex`,gap:`2px`,fontSize:`14px`,color:`#f59e0b`},children:Array.from({length:t},(t,n)=>n<e?`★`:`☆`).map((e,t)=>(0,Z.jsx)(`span`,{children:e},t))}),Hi=({amount:e,currency:t=`USD`,locale:n=`en-US`})=>{let r=new Intl.NumberFormat(n,{style:`currency`,currency:t}).format(e);return(0,Z.jsx)(`span`,{style:{fontWeight:500,color:e<0?`#ef4444`:`#059669`},children:r})},Ui=()=>{let e=(0,b.useRef)(null),[t,n]=(0,b.useState)([]),[r,i]=(0,b.useState)(!1),a=e=>{n(t=>[...t.slice(-9),`${new Date().toLocaleTimeString()}: ${e}`])},o=e=>{i(!0),a(`✅ Grid API is ready! You can now call API methods.`)},[s]=(0,b.useState)([{field:`id`,headerName:`ID`,width:80},{field:`name`,headerName:`Name`,width:150,sortable:!0,filterable:!0},{field:`email`,headerName:`Email`,width:200,sortable:!0,filterable:!0},{field:`role`,headerName:`Role`,width:120,sortable:!0,filterable:!0},{field:`status`,headerName:`Status`,width:100,sortable:!0,filterable:!0},{field:`score`,headerName:`Score`,width:100,sortable:!0,filterable:!0}]),[c]=(0,b.useState)(()=>{let e=[`Admin`,`User`,`Manager`],t=[`Active`,`Inactive`,`Pending`],n=`Alice Johnson.Bob Smith.Charlie Brown.Diana Prince.Eve Wilson.Frank Miller.Grace Lee.Henry Ford.Ivy Green.Jack Black.Karen White.Leo King.Mona Lisa.Nina Brown.Oscar Wilde.Paul Allen.Quinn Fox.Rita Ora.Sam Hunt.Tina Fey.Uma Thurman.Victor Hugo.Wendy Wu.Xander Cage.Yara Shahidi.Zane Grey`.split(`.`),r=[];for(let i=1;i<=100;i++){let a=n[i%n.length]+` `+i;r.push({id:i,name:a,email:a.replace(/\s+/g,``).toLowerCase()+`@example.com`,role:e[i%e.length],status:t[i%t.length],score:Math.floor(Math.random()*100)})}return r});return(0,Z.jsxs)(`div`,{style:{padding:`20px`,maxWidth:`1400px`,margin:`0 auto`},children:[(0,Z.jsxs)(`div`,{style:{marginBottom:`20px`},children:[(0,Z.jsx)(`h2`,{children:`Grid API Demo`}),(0,Z.jsx)(`p`,{style:{color:`#666`},children:`Demonstrates programmatic control of the DataGrid using the GridApi ref (AG Grid-inspired API)`})]}),(0,Z.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(200px, 1fr))`,gap:`10px`,marginBottom:`20px`,padding:`15px`,backgroundColor:`#f5f5f5`,borderRadius:`8px`},children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{style:{margin:`0 0 10px 0`,fontSize:`14px`,fontWeight:`600`},children:`Data Operations`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;if(!t)return;let n={id:Date.now(),name:`New User ${Math.floor(Math.random()*1e3)}`,email:`user${Date.now()}@example.com`,role:`User`,status:`Pending`,score:Math.floor(Math.random()*100)};t.applyTransaction({add:[n]}),a(`Added new row: ${n.name}`)},style:Wi,children:`Add Row`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;if(!t)return;let n=t.getSelectedRows();if(n.length===0){a(`No rows selected`);return}let r=n.map(e=>({...e,score:Math.floor(Math.random()*100)}));t.applyTransaction({update:r}),a(`Updated ${r.length} row(s)`)},style:Wi,children:`Update Selected`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;if(!t)return;let n=t.getSelectedRows();if(n.length===0){a(`No rows selected`);return}t.applyTransaction({remove:n}),a(`Removed ${n.length} row(s)`)},style:Wi,children:`Remove Selected`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{style:{margin:`0 0 10px 0`,fontSize:`14px`,fontWeight:`600`},children:`Column Operations`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.setColumnVisible(`email`,!1),a(`Hidden Email column`))},style:Wi,children:`Hide Email`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.setColumnVisible(`email`,!0),a(`Shown Email column`))},style:Wi,children:`Show Email`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.setColumnPinned(`name`,`left`),a(`Pinned Name column to left`))},style:Wi,children:`Pin Name`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.setColumnPinned(`name`,null),a(`Unpinned Name column`))},style:Wi,children:`Unpin Name`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.autoSizeAllColumns(),a(`Auto-sized all columns`))},style:Wi,children:`Auto-size Columns`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.sizeColumnsToFit(),a(`Resized columns to fit grid width`))},style:Wi,children:`Fit to Width`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{style:{margin:`0 0 10px 0`,fontSize:`14px`,fontWeight:`600`},children:`Filter & Sort`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.setFilterModel({status:{type:`equals`,value:`Active`}}),a(`Filtered by Status = Active`))},style:Wi,children:`Filter Active`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.clearAllFilters(),a(`Cleared all filters`))},style:Wi,children:`Clear Filters`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.setSortModel([{field:`score`,direction:`desc`}]),a(`Sorted by Score descending`))},style:Wi,children:`Sort by Score`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.clearAllSorting(),a(`Cleared sorting`))},style:Wi,children:`Clear Sort`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{style:{margin:`0 0 10px 0`,fontSize:`14px`,fontWeight:`600`},children:`Selection`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.selectAll(),a(`Selected all rows`))},style:Wi,children:`Select All`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.deselectAll(),a(`Deselected all rows`))},style:Wi,children:`Deselect All`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.selectAllFiltered(),a(`Selected all filtered rows`))},style:Wi,children:`Select Filtered`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&a(`Selected ${t.getSelectedRows().length} row(s)`)},style:Wi,children:`Get Selection`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{style:{margin:`0 0 10px 0`,fontSize:`14px`,fontWeight:`600`},children:`Export & Clipboard`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.exportDataAsCsv({fileName:`grid-export`,onlySelected:!1,onlyFiltered:!0}),a(`Exported to CSV`))},style:Wi,children:`Export CSV`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;if(!t)return;let n=t.getSelectedRowCount();if(n===0){a(`⚠️ No rows selected! Please select rows first.`);return}t.copySelectedRowsToClipboard(),a(`✓ Copied ${n} selected row(s) to clipboard`)},style:Wi,children:`Copy to Clipboard`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{style:{margin:`0 0 10px 0`,fontSize:`14px`,fontWeight:`600`},children:`Navigation`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;if(!t)return;let n=t.paginationGetCurrentPage(),r=t.paginationGetPageSize(),i=n*r,o=Math.min(r,t.getDisplayedRowCount()-i),s=Math.floor(o/2);t.ensureIndexVisible(s,`middle`),a(`Scrolled to row ${s} (middle of page ${n+1})`)},style:Wi,children:`Scroll to Middle`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.setFocusedCell(2,`name`),a(`Focused cell at row 2, column Name`))},style:Wi,children:`Focus Cell`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.paginationGoToNextPage(),a(`Navigated to page ${t.paginationGetCurrentPage()+1}`))},style:Wi,children:`Next Page`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.paginationGoToPreviousPage(),a(`Navigated to page ${t.paginationGetCurrentPage()+1}`))},style:Wi,children:`Previous Page`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.paginationSetPageSize(20),a(`Set page size to 20`))},style:Wi,children:`Page Size: 20`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{style:{margin:`0 0 10px 0`,fontSize:`14px`,fontWeight:`600`},children:`Info`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;if(!t)return;let n=t.getDisplayedRowCount(),r=t.getSelectedRowCount(),i=t.isAnyFilterPresent(),o=t.paginationGetCurrentPage(),s=t.paginationGetTotalPages();a(`Rows: ${n}, Selected: ${r}, Filters: ${i}, Page: ${o+1}/${s}`)},style:Wi,children:`Get Grid Info`})]})]}),(0,Z.jsxs)(`div`,{style:{marginBottom:`20px`,padding:`10px`,backgroundColor:`#f9f9f9`,borderRadius:`4px`,border:`1px solid #ddd`,height:`120px`,overflow:`auto`,fontFamily:`monospace`,fontSize:`12px`},children:[(0,Z.jsx)(`div`,{style:{fontWeight:`600`,marginBottom:`5px`},children:`Activity Log:`}),t.length===0?(0,Z.jsx)(`div`,{style:{color:`#999`},children:`No actions yet. Click buttons above to interact with the grid.`}):t.map((e,t)=>(0,Z.jsx)(`div`,{style:{padding:`2px 0`},children:e},t))]}),(0,Z.jsxs)(`div`,{style:{marginBottom:`10px`,padding:`10px`,backgroundColor:r?`#d4edda`:`#f8d7da`,borderRadius:`4px`,border:`1px solid ${r?`#c3e6cb`:`#f5c6cb`}`},children:[(0,Z.jsx)(`strong`,{children:`Grid Status:`}),` `,r?`✅ Ready`:`⏳ Initializing...`]}),(0,Z.jsx)(ci,{ref:e,columns:s,rows:c,pageSize:10,theme:`quartz`,densityMode:`normal`,showDensityToggle:!0,onGridReady:o,onSelectionChange:e=>{a(`Selection changed: ${e.length} row(s)`)}}),(0,Z.jsxs)(`div`,{style:{marginTop:`30px`,padding:`20px`,backgroundColor:`#e8f5e9`,borderRadius:`8px`,marginBottom:`20px`},children:[(0,Z.jsx)(`h3`,{style:{marginTop:0},children:`📘 Using onGridReady Event`}),(0,Z.jsxs)(`p`,{style:{fontSize:`14px`,lineHeight:`1.6`},children:[`The `,(0,Z.jsx)(`code`,{children:`onGridReady`}),` callback is fired when the grid API is fully initialized and ready to use. This is similar to AG-Grid's `,(0,Z.jsx)(`code`,{children:`onGridReady`}),` event.`]}),(0,Z.jsx)(`pre`,{style:{backgroundColor:`#fff`,padding:`15px`,borderRadius:`4px`,overflow:`auto`,fontSize:`13px`},children:`// Example usage
46
+ `)?`"${n.replace(/"/g,`""`)}"`:n}copyToClipboard(e){if(navigator.clipboard)navigator.clipboard.writeText(e).catch(e=>{console.error(`Failed to copy to clipboard:`,e)});else{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select(),document.execCommand(`copy`),document.body.removeChild(t)}}fireEvent(e,t){let n=this.eventListeners.get(e);n&&n.forEach(n=>{try{n(t)}catch(t){console.error(`Error in ${e} listener:`,t)}})}};const ci=(0,b.forwardRef)(({columns:e,rows:t,pageSize:n=10,showColumnPinning:r=!0,footerConfig:i,virtualScrollConfig:a,persistenceConfig:o,treeConfig:s,dragRowConfig:c,rowPinConfig:l,contextMenuConfig:u,tooltipConfig:d,tableId:f,theme:p=`quartz`,densityMode:m=`normal`,showDensityToggle:h=!1,onDensityChange:g,onRowClick:_,onCellEdit:v,onSelectionChange:y,onLayoutChange:x,onRowReorder:S,onGridReady:C},w)=>{let[T]=(0,b.useState)(``),[E,D]=(0,b.useReducer)(fn,{columns:e,pageSize:n},e=>dn(e.columns,e.pageSize)),[O,k]=(0,b.useState)(null),A=O===null?t:O,j=(0,b.useRef)(t);(0,b.useEffect)(()=>{if(t!==j.current){j.current=t;let e=setTimeout(()=>k(null),0);return()=>clearTimeout(e)}},[t]);let M=(0,b.useRef)(null),N=(0,b.useRef)(null),{densityMode:P,setDensityMode:F,densityStyles:I}=Pr({initialMode:m,persist:!0,onChange:g});(0,b.useEffect)(()=>{m&&m!==P&&F(m)},[m,P,F]);let L=(0,b.useMemo)(()=>ii(ri(p)),[p]),{announceSorting:R,announceSelection:z,announcePagination:ee}=ai(),[B,V]=(0,b.useState)(null),te=(0,b.useRef)(null),H=(0,b.useRef)(null),{tooltipState:U,tooltipHandlers:ne}=Er({config:d}),{contextMenu:W,handleContextMenu:G,closeContextMenu:re}=Cr({config:u,columns:e,rows:t,selectedRows:E.selection.selectedRows,onPinColumn:(e,t)=>D({type:`PIN_COLUMN`,payload:{field:e,side:t}}),onUnpinColumn:e=>D({type:`UNPIN_COLUMN`,payload:e}),onToggleColumnVisibility:e=>D({type:`TOGGLE_COLUMN_VISIBILITY`,payload:e}),onResizeColumn:(e,t)=>D({type:`RESIZE_COLUMN`,payload:{field:e,width:t}}),onAutoSizeAllColumns:e=>{Object.entries(e).forEach(([e,t])=>{D({type:`RESIZE_COLUMN`,payload:{field:e,width:t}})})},onSetFilter:(e,t)=>D({type:`SET_FILTER`,payload:{field:e,value:t}}),onPinRowTop:l?.enabled?e=>D({type:`PIN_ROW_TOP`,payload:e}):void 0,onPinRowBottom:l?.enabled?e=>D({type:`PIN_ROW_BOTTOM`,payload:e}):void 0,onUnpinRow:l?.enabled?e=>D({type:`UNPIN_ROW`,payload:e}):void 0,pinnedColumnsLeft:E.pinnedColumnsLeft,pinnedColumnsRight:E.pinnedColumnsRight,pinnedRowsTop:E.pinnedRowsTop,pinnedRowsBottom:E.pinnedRowsBottom});(0,b.useEffect)(()=>{if(o?.enabled){let e=new pr(o),t=setTimeout(()=>V(e),0);return o.autoLoad&&e.loadAutoSave().then(e=>{e&&D({type:`LOAD_LAYOUT_PRESET`,payload:e.layout})}).catch(e=>{console.error(`Failed to load auto-saved layout:`,e)}),()=>clearTimeout(t)}},[o]);let K=(0,b.useMemo)(()=>JSON.stringify(E.sortConfig),[E.sortConfig]),ie=(0,b.useMemo)(()=>JSON.stringify(E.filterConfig),[E.filterConfig]),ae=(0,b.useCallback)(()=>({columnOrder:E.columnOrder,columnWidths:E.columnWidths,pinnedColumnsLeft:E.pinnedColumnsLeft,pinnedColumnsRight:E.pinnedColumnsRight,hiddenColumns:E.hiddenColumns,sortConfig:E.sortConfig,filterConfig:E.filterConfig,pageSize:E.pageSize,groupBy:E.groupBy}),[E.columnOrder,E.columnWidths,E.pinnedColumnsLeft,E.pinnedColumnsRight,E.hiddenColumns,E.sortConfig,E.filterConfig,E.pageSize,E.groupBy]);(0,b.useEffect)(()=>{(!N.current||N.current.isDestroyed())&&(N.current=new si(E,D,e,A,M,B,k))},[]),(0,b.useEffect)(()=>{N.current&&!N.current.isDestroyed()&&(N.current.updateState(E),N.current.updateData(e,A),N.current.updateCallbacks(k))},[E,e,A,k]),(0,b.useImperativeHandle)(w,()=>((!N.current||N.current.isDestroyed())&&(N.current=new si(E,D,e,A,M,B,k)),N.current),[E,e,A,B]);let oe=(0,b.useRef)(!1),q=(0,b.useRef)(C);(0,b.useEffect)(()=>{q.current=C},[C]),(0,b.useEffect)(()=>{N.current&&q.current&&!oe.current&&(oe.current=!0,q.current(N.current))},[]),(0,b.useEffect)(()=>()=>{N.current&&N.current.destroy()},[]),(0,b.useEffect)(()=>{if(!o?.enabled||!o.autoSave||!B)return;let e=mr(()=>{let e=ae();B.autoSave(e).catch(e=>{console.error(`Failed to auto-save layout:`,e)})},o.autoSaveDelay||1e3);return te.current=e,e(),()=>{te.current=null}},[o,B,E.columnOrder,E.columnWidths,E.pinnedColumnsLeft,E.pinnedColumnsRight,E.hiddenColumns,K,ie,E.pageSize,E.groupBy]),(0,b.useEffect)(()=>{if(x){let e=ae(),t=JSON.stringify(e);H.current!==t&&(H.current=t,x(e))}},[x,E.columnOrder,E.columnWidths,E.pinnedColumnsLeft,E.pinnedColumnsRight,E.hiddenColumns,K,ie,E.pageSize,E.groupBy]);let se=new Set(E.hiddenColumns),ce=E.columnOrder.filter(e=>!se.has(e)),J=E.pinnedColumnsLeft.filter(e=>ce.includes(e)),le=E.pinnedColumnsRight.filter(e=>ce.includes(e)),ue=new Set(J),Y=new Set(le),de=ce.filter(e=>!ue.has(e)&&!Y.has(e)),fe=[...J,...de,...le];(0,b.useEffect)(()=>{D({type:`RESET_COLUMNS`,payload:e})},[e]),(0,b.useEffect)(()=>{y&&y(Array.from(E.selection.selectedRows)),z(E.selection.selectedRows.size)},[E.selection.selectedRows]);let X=(0,b.useRef)(!1);(0,b.useEffect)(()=>{X.current&&l?.onPinChange&&l.onPinChange(E.pinnedRowsTop,E.pinnedRowsBottom),X.current=!0},[E.pinnedRowsTop,E.pinnedRowsBottom]),(0,b.useEffect)(()=>{if(E.sortConfig.field){let t=e.find(e=>e.field===E.sortConfig.field);t&&R(t.headerName,E.sortConfig.direction)}},[E.sortConfig.field,E.sortConfig.direction]);let pe=(0,b.useMemo)(()=>{if(!E.sortConfig.field||!E.sortConfig.direction)return A;let e=[...A].sort((e,t)=>{let n=e[E.sortConfig.field],r=t[E.sortConfig.field];return n==null&&r==null?0:n==null?1:r==null?-1:typeof n==`string`&&typeof r==`string`?n.localeCompare(r):n<r?-1:n>r?1:0});return E.sortConfig.direction===`desc`&&e.reverse(),e},[A,E.sortConfig]),me=(0,b.useMemo)(()=>Gr(E.filterConfig)?Wr(pe,E.filterConfig):pe,[pe,E.filterConfig]),he=(0,b.useMemo)(()=>s?.enabled?Dn(En(me,s),E.expandedNodes,s):me,[me,s,E.expandedNodes]),ge=(0,b.useMemo)(()=>s?.enabled?he:E.groupBy.length===0?me:Sn(me,E.groupBy,E.expandedGroups),[me,he,s,E.groupBy,E.expandedGroups]),_e=(0,b.useMemo)(()=>E.groupBy.length===0?ge:Cn(ge),[ge,E.groupBy]);(0,b.useEffect)(()=>{let e=Math.ceil(_e.length/E.pageSize),t=Math.min(E.pageSize,_e.length-E.currentPage*E.pageSize);t>0&&ee(E.currentPage,e,t)},[E.currentPage,E.pageSize]);let{pinnedRowsTopData:ve,pinnedRowsBottomData:ye,unpinnedRows:be}=(0,b.useMemo)(()=>{let e=new Set(E.pinnedRowsTop),t=new Set(E.pinnedRowsBottom),n=[],r=[],i=[];return _e.forEach(a=>{let o=`id`in a?a.id:`groupKey`in a?a.groupKey:null;o===null?i.push(a):e.has(o)?n.push(a):t.has(o)?r.push(a):i.push(a)}),{pinnedRowsTopData:E.pinnedRowsTop.map(e=>n.find(t=>(`id`in t?t.id:`groupKey`in t?t.groupKey:null)===e)).filter(e=>e!==void 0),pinnedRowsBottomData:E.pinnedRowsBottom.map(e=>r.find(t=>(`id`in t?t.id:`groupKey`in t?t.groupKey:null)===e)).filter(e=>e!==void 0),unpinnedRows:i}},[_e,E.pinnedRowsTop,E.pinnedRowsBottom]),xe=(0,b.useMemo)(()=>{let e=E.currentPage*E.pageSize,t=e+E.pageSize;return be.slice(e,t)},[be,E.currentPage,E.pageSize]),Se=(0,b.useMemo)(()=>!i?.show||!i.aggregates?{}:hn(me.filter(e=>!(`isGroup`in e)),i.aggregates),[me,i]),Ce=(0,b.useMemo)(()=>!i?.showGroupFooters||!i.aggregates||E.groupBy.length===0?new Map:gn(ge,i.aggregates),[ge,i,E.groupBy]);(0,b.useEffect)(()=>{let t={...E.columnWidths},n=!1;e.forEach(e=>{if(e.width)t[e.field]!==e.width&&(t[e.field]=e.width,n=!0);else{let r=e.headerName.length,i=Math.max(150,Math.min(300,r*10+50));t[e.field]||(t[e.field]=i,n=!0)}}),n&&e.forEach(e=>{D({type:`RESIZE_COLUMN`,payload:{field:e.field,width:t[e.field]}})})},[e]);let we=(0,b.useCallback)((e,n,r)=>{if(v){let i=xe[e];`id`in i&&v(t.findIndex(e=>e.id===i.id),n,r)}},[v,xe,t]);return(0,Z.jsxs)(`div`,{ref:M,"data-testid":`data-grid`,role:`grid`,"aria-label":`Data Grid`,"aria-rowcount":_e.length,"aria-colcount":fe.length,style:{...L,...I,border:`var(--grid-border-width, 1px) solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,overflow:`hidden`,backgroundColor:`var(--grid-bg)`,boxShadow:`var(--grid-shadow-light, 0 1px 3px 0 rgba(0, 0, 0, 0.08))`,fontFamily:`var(--grid-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif)`},className:`data-grid density-${P}`,children:[(0,Z.jsx)(oi,{message:T,priority:`polite`}),``,(0,Z.jsxs)(`div`,{style:{position:`relative`,display:`flex`,alignItems:`center`,justifyContent:`space-between`,paddingLeft:`16px`,paddingRight:`16px`,paddingTop:`10px`,paddingBottom:`10px`,backgroundColor:`var(--grid-bg-alt)`,borderBottom:`var(--grid-border-width, 1px) solid var(--grid-border)`,zIndex:30},children:[(0,Z.jsxs)(`div`,{style:{position:`relative`,display:`flex`,alignItems:`center`,gap:`8px`},children:[(0,Z.jsx)(zn,{columns:e,columnOrder:E.columnOrder,hiddenColumns:E.hiddenColumns,onToggleVisibility:e=>D({type:`TOGGLE_COLUMN_VISIBILITY`,payload:e}),onReorderColumns:(e,t)=>D({type:`REORDER_COLUMNS`,payload:{fromIndex:e,toIndex:t}}),onResetLayout:()=>D({type:`RESET_COLUMN_LAYOUT`})}),(0,Z.jsx)(qn,{columns:e,fullDataset:t,filteredData:me.filter(e=>!(`isGroup`in e)),selectedRows:E.selection.selectedRows,currentPageData:xe.filter(e=>!(`isGroup`in e))}),o?.enabled&&B&&(0,Z.jsx)(hr,{manager:B,currentLayout:ae(),onLoadPreset:e=>D({type:`LOAD_LAYOUT_PRESET`,payload:e}),onResetLayout:()=>D({type:`RESET_COLUMN_LAYOUT`})})]}),h&&(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`},children:[(0,Z.jsx)(`span`,{style:{fontSize:`13px`,color:`var(--grid-text-secondary)`,fontWeight:`500`},children:`Density:`}),(0,Z.jsx)(Nr,{value:P,onChange:F})]})]}),(0,Z.jsx)(Ln,{columns:e,groupBy:E.groupBy,dispatch:D}),(0,Z.jsxs)(`div`,{role:`rowgroup`,style:{position:`sticky`,top:0,zIndex:20,width:`100%`},children:[(0,Z.jsx)(pn,{columns:e,columnOrder:E.columnOrder,displayColumnOrder:fe,columnWidths:E.columnWidths,sortConfig:E.sortConfig,dispatch:D,pinnedLeft:J,pinnedRight:le,showColumnPinning:r,onContextMenu:(e,t,n)=>G({type:`header`,column:t,columnIndex:n,event:e})}),(0,Z.jsx)(or,{columns:e,displayColumnOrder:fe,columnWidths:E.columnWidths,filterConfig:E.filterConfig,dispatch:D,pinnedLeft:J,pinnedRight:le,rows:me})]}),(0,Z.jsx)(Fn,{columns:e,rows:a?.enabled?be:xe,pinnedRowsTop:ve,pinnedRowsBottom:ye,columnOrder:E.columnOrder,displayColumnOrder:fe,columnWidths:E.columnWidths,selectedRows:E.selection.selectedRows,editState:E.editState,focusState:E.focusState,dispatch:D,onRowClick:_,onCellEdit:we,pinnedLeft:J,pinnedRight:le,showGroupFooters:i?.showGroupFooters,groupAggregates:Ce,aggregateConfigs:i?.aggregates,virtualScrollConfig:a,treeConfig:s,dragRowConfig:c,tableId:f,onRowReorder:S,currentPage:E.currentPage,pageSize:E.pageSize,totalRows:be.length,onContextMenu:(e,t,n,r,i)=>G({type:`cell`,row:t,column:n,rowIndex:r,columnIndex:i,event:e}),...ne}),i?.show&&i.aggregates&&(0,Z.jsx)(Rn,{columns:e,displayColumnOrder:fe,columnWidths:E.columnWidths,aggregates:Se,aggregateConfigs:i.aggregates,pinnedLeft:J,pinnedRight:le}),!a?.enabled&&(0,Z.jsx)(In,{currentPage:E.currentPage,pageSize:E.pageSize,totalRows:be.length,dispatch:D}),W.isOpen&&(0,Z.jsx)(gr,{x:W.x,y:W.y,items:W.items,onClose:re}),d?.enabled&&(0,Z.jsx)(Tr,{state:U,maxWidth:d.maxWidth,offset:d.offset})]})});ci.displayName=`DataGrid`;var li=()=>(0,Z.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,Z.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]}),ui=()=>(0,Z.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Z.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,Z.jsx)(`path`,{d:`m21 21-4.35-4.35`})]}),di=()=>(0,Z.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,Z.jsx)(`polyline`,{points:`6 9 12 15 18 9`})}),fi=()=>(0,Z.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,Z.jsx)(`polyline`,{points:`9 18 15 12 9 6`})}),pi=()=>(0,Z.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,Z.jsx)(`polygon`,{points:`22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3`})}),mi=(e,t,n,r)=>{let i=new Map;return e.filter(e=>Object.entries(n).every(([t,n])=>{if(t===r||!n)return!0;if(n&&`values`in n&&n.values){let r=e[t];return n.values.includes(r)}return!0})).forEach(e=>{let n=e[t];if(n!=null){let e=i.get(n)||0;i.set(n,e+1)}}),i},hi=(e,t)=>{let n=[...e];switch(t){case`count`:n.sort((e,t)=>t.count===e.count?e.label.localeCompare(t.label):t.count-e.count);break;case`alpha`:n.sort((e,t)=>e.label.localeCompare(t.label));break;case`value`:n.sort((e,t)=>typeof e.value==`number`&&typeof t.value==`number`?e.value-t.value:String(e.value).localeCompare(String(t.value)));break}return n};const gi=({columns:e,rows:t,facetConfigs:n,filterConfig:r,onFilterChange:i,onClearAll:a,className:o=``,showSearch:s=!0,collapsible:c=!0})=>{let[l,u]=(0,b.useState)(new Map),d=(0,b.useMemo)(()=>n.map(n=>{let i=e.find(e=>e.field===n.field),a=n.label||i?.headerName||n.field,o=r[n.field],s=o&&`values`in o?new Set(o.values||[]):new Set,c=mi(t,n.field,r,n.field),u=[];c.forEach((e,t)=>{u.push({value:t,label:String(t),count:e,selected:s.has(t)})});let d=hi(u,n.sortBy||`count`),f=l.get(n.field)||{expanded:n.expanded!==!1,searchTerm:``,showAll:!1};return{field:n.field,label:a,values:d,expanded:f.expanded,searchTerm:f.searchTerm,showAll:f.showAll}}),[n,e,t,r,l]),f=(e,t)=>{u(n=>{let r=new Map(n),i=r.get(e)||{expanded:!0,searchTerm:``,showAll:!1};return r.set(e,{...i,...t}),r})},p=(e,t)=>{let n=r[e],a=n&&`values`in n?new Set(n.values||[]):new Set;a.has(t)?a.delete(t):a.add(t),a.size===0?i(e,null):i(e,Array.from(a))},m=(e,t)=>{i(e,t)},h=e=>{i(e,null)},g=(0,b.useMemo)(()=>Object.values(r).filter(e=>e?!!(`values`in e&&e.values&&e.values.length>0):!1).length,[r]);return(0,Z.jsxs)(`div`,{className:`faceted-search ${o||``}`,style:{backgroundColor:`#ffffff`,borderRight:`1px solid #e5e7eb`,display:`flex`,flexDirection:`column`,height:`100%`},children:[(0,Z.jsx)(`div`,{style:{position:`sticky`,top:0,zIndex:10,backgroundColor:`#ffffff`,borderBottom:`1px solid #e5e7eb`,padding:`16px`,flexShrink:0},children:(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:`8px`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`},children:[(0,Z.jsx)(pi,{}),(0,Z.jsx)(`h3`,{style:{fontSize:`18px`,fontWeight:600,color:`#111827`,margin:0},children:`Filters`}),g>0&&(0,Z.jsx)(`span`,{style:{padding:`2px 8px`,fontSize:`12px`,fontWeight:500,backgroundColor:`#dbeafe`,color:`#1e40af`,borderRadius:`9999px`},children:g})]}),g>0&&a&&(0,Z.jsx)(`button`,{onClick:a,style:{fontSize:`14px`,color:`#2563eb`,fontWeight:500,background:`none`,border:`none`,cursor:`pointer`,padding:0},onMouseOver:e=>e.currentTarget.style.color=`#1d4ed8`,onMouseOut:e=>e.currentTarget.style.color=`#2563eb`,children:`Clear All`})]})}),(0,Z.jsxs)(`div`,{style:{overflowY:`auto`,flex:1},children:[d.map(e=>{let t=n.find(t=>t.field===e.field)?.maxItems||10,r=e.searchTerm?e.values.filter(t=>t.label.toLowerCase().includes(e.searchTerm.toLowerCase())):e.values,i=e.showAll?r:r.slice(0,t),a=r.length>t,o=e.values.filter(e=>e.selected).length;return(0,Z.jsxs)(`div`,{style:{borderBottom:`1px solid #e5e7eb`},children:[(0,Z.jsxs)(`div`,{style:{padding:`16px`,backgroundColor:`#f9fafb`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`},children:[(0,Z.jsxs)(`button`,{onClick:()=>f(e.field,{expanded:!e.expanded}),disabled:!c,style:{display:`flex`,alignItems:`center`,gap:`8px`,fontSize:`14px`,fontWeight:600,color:`#111827`,background:`none`,border:`none`,cursor:c?`pointer`:`default`,padding:0},onMouseOver:e=>c&&(e.currentTarget.style.color=`#374151`),onMouseOut:e=>c&&(e.currentTarget.style.color=`#111827`),children:[c&&(e.expanded?(0,Z.jsx)(di,{}):(0,Z.jsx)(fi,{})),(0,Z.jsx)(`span`,{children:e.label}),o>0&&(0,Z.jsx)(`span`,{style:{padding:`2px 8px`,fontSize:`12px`,fontWeight:500,backgroundColor:`#dbeafe`,color:`#1e40af`,borderRadius:`9999px`},children:o})]}),o>0&&(0,Z.jsx)(`button`,{onClick:()=>h(e.field),style:{fontSize:`12px`,color:`#6b7280`,background:`none`,border:`none`,cursor:`pointer`,padding:0,display:`flex`,alignItems:`center`},onMouseOver:e=>e.currentTarget.style.color=`#374151`,onMouseOut:e=>e.currentTarget.style.color=`#6b7280`,children:(0,Z.jsx)(li,{})})]}),s&&e.expanded&&e.values.length>5&&(0,Z.jsxs)(`div`,{style:{marginTop:`8px`,position:`relative`},children:[(0,Z.jsx)(`div`,{style:{position:`absolute`,left:`8px`,top:`8px`,color:`#9ca3af`},children:(0,Z.jsx)(ui,{})}),(0,Z.jsx)(`input`,{type:`text`,value:e.searchTerm,onChange:t=>f(e.field,{searchTerm:t.target.value}),placeholder:`Search...`,style:{width:`100%`,paddingLeft:`32px`,paddingRight:`12px`,paddingTop:`6px`,paddingBottom:`6px`,fontSize:`14px`,border:`1px solid #d1d5db`,borderRadius:`4px`,outline:`none`},onFocus:e=>e.currentTarget.style.boxShadow=`0 0 0 2px #3b82f6`,onBlur:e=>e.currentTarget.style.boxShadow=`none`})]})]}),e.expanded&&(0,Z.jsx)(`div`,{style:{padding:`16px`,display:`flex`,flexDirection:`column`,gap:`4px`},children:i.length===0?(0,Z.jsx)(`div`,{style:{fontSize:`14px`,color:`#6b7280`,fontStyle:`italic`},children:`No values found`}):(0,Z.jsxs)(Z.Fragment,{children:[r.length>1&&o<r.length&&(0,Z.jsxs)(`button`,{onClick:()=>m(e.field,r.map(e=>e.value)),style:{width:`100%`,textAlign:`left`,fontSize:`14px`,color:`#2563eb`,fontWeight:500,padding:`4px 0`,background:`none`,border:`none`,cursor:`pointer`},onMouseOver:e=>e.currentTarget.style.color=`#1d4ed8`,onMouseOut:e=>e.currentTarget.style.color=`#2563eb`,children:[`Select All (`,r.length,`)`]}),i.map((t,n)=>(0,Z.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,paddingTop:`6px`,paddingBottom:`6px`,paddingLeft:`8px`,paddingRight:`8px`,borderRadius:`4px`,cursor:`pointer`},onMouseOver:e=>e.currentTarget.style.backgroundColor=`#f9fafb`,onMouseOut:e=>e.currentTarget.style.backgroundColor=`transparent`,children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,flex:1,minWidth:0},children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:t.selected,onChange:()=>p(e.field,t.value),style:{width:`16px`,height:`16px`,cursor:`pointer`,accentColor:`#2563eb`}}),(0,Z.jsx)(`span`,{style:{fontSize:`14px`,color:`#374151`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,flex:1},children:t.label})]}),(0,Z.jsx)(`span`,{style:{fontSize:`12px`,color:`#6b7280`,fontWeight:500,marginLeft:`8px`,flexShrink:0},children:t.count})]},`${t.value}-${n}`)),a&&!e.searchTerm&&(0,Z.jsx)(`button`,{onClick:()=>f(e.field,{showAll:!e.showAll}),style:{width:`100%`,textAlign:`left`,fontSize:`14px`,color:`#2563eb`,fontWeight:500,padding:`4px 0`,marginTop:`8px`,background:`none`,border:`none`,cursor:`pointer`},onMouseOver:e=>e.currentTarget.style.color=`#1d4ed8`,onMouseOut:e=>e.currentTarget.style.color=`#2563eb`,children:e.showAll?`Show Less`:`Show More (${r.length-t} more)`})]})})]},e.field)}),d.length===0&&(0,Z.jsxs)(`div`,{style:{padding:`32px`,textAlign:`center`,color:`#6b7280`},children:[(0,Z.jsx)(`div`,{style:{width:`48px`,height:`48px`,margin:`0 auto 12px`,color:`#9ca3af`},children:(0,Z.jsx)(`svg`,{width:`48`,height:`48`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,Z.jsx)(`polygon`,{points:`22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3`})})}),(0,Z.jsx)(`p`,{style:{fontSize:`14px`,margin:0},children:`No facets configured`})]})]})]})};var _i,vi=new Uint8Array(16);function yi(){if(!_i&&(_i=typeof crypto<`u`&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<`u`&&typeof msCrypto.getRandomValues==`function`&&msCrypto.getRandomValues.bind(msCrypto),!_i))throw Error(`crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported`);return _i(vi)}var bi=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function xi(e){return typeof e==`string`&&bi.test(e)}for(var Si=xi,Ci=[],wi=0;wi<256;++wi)Ci.push((wi+256).toString(16).substr(1));function Ti(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(Ci[e[t+0]]+Ci[e[t+1]]+Ci[e[t+2]]+Ci[e[t+3]]+`-`+Ci[e[t+4]]+Ci[e[t+5]]+`-`+Ci[e[t+6]]+Ci[e[t+7]]+`-`+Ci[e[t+8]]+Ci[e[t+9]]+`-`+Ci[e[t+10]]+Ci[e[t+11]]+Ci[e[t+12]]+Ci[e[t+13]]+Ci[e[t+14]]+Ci[e[t+15]]).toLowerCase();if(!Si(n))throw TypeError(`Stringified UUID is invalid`);return n}var Ei=Ti;function Di(e,t,n){e||={};var r=e.random||(e.rng||yi)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){n||=0;for(var i=0;i<16;++i)t[n+i]=r[i];return t}return Ei(r)}var Oi=Di;const ki=({filters:e,onSearch:t,placeholder:n=`Search or add filters...`,maxTokens:r=10})=>{let[i,a]=(0,b.useState)([]),[o,s]=(0,b.useState)(``),[c,l]=(0,b.useState)(!1),[u,d]=(0,b.useState)(null),f=b.useMemo(()=>{if(u){let t=e.find(e=>e.field===u);if(t?.type===`select`||t?.type===`multiselect`){let e=t.options?.filter(e=>e.toLowerCase().includes(o.toLowerCase()))||[];return[{...t,options:e}]}}else return e.filter(e=>e.label.toLowerCase().includes(o.toLowerCase())||e.field.toLowerCase().includes(o.toLowerCase()));return e},[o,u,e]),[p,m]=(0,b.useState)(0),h=(0,b.useRef)(null),g=(0,b.useRef)(null),_=(n,o)=>{let c=e.find(e=>e.field===n);if(!c||i.length>=r)return;let u={id:`${n}-${Oi()}`,field:n,label:c.label,value:o,operator:Array.isArray(o)?`in`:`contains`,color:c.color||C(e.indexOf(c))},f=[...i,u];a(f),t(f),s(``),d(null),l(!1)},v=e=>{let n=i.filter(t=>t.id!==e);a(n),t(n)},y=e=>{(e.type===`text`||e.type===`number`||e.type===`date`||e.type===`select`)&&(d(e.field),s(``),l(!0))},x=e=>{u&&_(u,e)},S=e=>{if(e.key===`ArrowDown`)e.preventDefault(),m(e=>Math.min(e+1,(u?f[0]?.options?.length||0:f.length)-1));else if(e.key===`ArrowUp`)e.preventDefault(),m(e=>Math.max(e-1,0));else if(e.key===`Enter`)if(e.preventDefault(),u){let e=f[0]?.options||[];e[p]?x(e[p]):o.trim()&&_(u,o.trim())}else f[p]&&y(f[p]);else e.key===`Escape`?(l(!1),d(null),s(``)):e.key===`Backspace`&&!o&&i.length>0&&v(i[i.length-1].id)},C=e=>{let t=[`#3b82f6`,`#8b5cf6`,`#ec4899`,`#f59e0b`,`#10b981`,`#06b6d4`];return t[e%t.length]};return(0,b.useEffect)(()=>{let e=e=>{g.current&&!g.current.contains(e.target)&&h.current&&!h.current.contains(e.target)&&l(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,Z.jsxs)(`div`,{style:{position:`relative`,width:`100%`},children:[(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,flexWrap:`wrap`,gap:`6px`,padding:`8px 12px`,backgroundColor:`#ffffff`,border:`2px solid #e2e8f0`,borderRadius:`8px`,minHeight:`44px`,cursor:`text`,transition:`border-color 0.2s`,...c&&{borderColor:`#3b82f6`}},onClick:()=>h.current?.focus(),children:[i.map(e=>(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`6px`,padding:`4px 8px`,backgroundColor:e.color,color:`#ffffff`,borderRadius:`6px`,fontSize:`13px`,fontWeight:`500`},children:[(0,Z.jsxs)(`span`,{style:{fontWeight:`600`},children:[e.label,`:`]}),(0,Z.jsx)(`span`,{children:Array.isArray(e.value)?e.value.join(`, `):e.value}),(0,Z.jsx)(`button`,{onClick:t=>{t.stopPropagation(),v(e.id)},style:{background:`none`,border:`none`,color:`#ffffff`,cursor:`pointer`,padding:`0 2px`,fontSize:`16px`,lineHeight:`1`,opacity:.8},onMouseEnter:e=>e.currentTarget.style.opacity=`1`,onMouseLeave:e=>e.currentTarget.style.opacity=`0.8`,children:`×`})]},e.id)),(0,Z.jsx)(`input`,{ref:h,type:`text`,value:o,onChange:e=>s(e.target.value),onFocus:()=>l(!0),onKeyDown:S,placeholder:i.length===0?n:``,style:{flex:1,minWidth:`200px`,border:`none`,outline:`none`,fontSize:`14px`,padding:`4px`,backgroundColor:`transparent`},disabled:i.length>=r})]}),c&&(0,Z.jsx)(`div`,{ref:g,style:{position:`absolute`,top:`100%`,left:0,right:0,marginTop:`4px`,backgroundColor:`#ffffff`,border:`1px solid #e2e8f0`,borderRadius:`8px`,boxShadow:`0 4px 6px -1px rgba(0, 0, 0, 0.1)`,maxHeight:`300px`,overflowY:`auto`,zIndex:1e3},children:u?(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{style:{padding:`8px 12px`,fontSize:`12px`,fontWeight:`600`,color:`#64748b`,borderBottom:`1px solid #e2e8f0`,display:`flex`,alignItems:`center`,gap:`8px`},children:[(0,Z.jsx)(`button`,{onClick:()=>{d(null),s(``)},style:{background:`none`,border:`none`,cursor:`pointer`,padding:`2px`,fontSize:`16px`,color:`#64748b`},children:`←`}),e.find(e=>e.field===u)?.label]}),f[0]?.options?.map((e,t)=>(0,Z.jsx)(`div`,{onClick:()=>x(e),style:{padding:`10px 16px`,cursor:`pointer`,fontSize:`14px`,backgroundColor:p===t?`#f1f5f9`:`transparent`,transition:`background-color 0.15s`},onMouseEnter:()=>m(t),children:e},e))]}):(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{style:{padding:`8px 12px`,fontSize:`12px`,fontWeight:`600`,color:`#64748b`,borderBottom:`1px solid #e2e8f0`},children:`Filter by`}),f.map((t,n)=>(0,Z.jsxs)(`div`,{onClick:()=>y(t),style:{padding:`10px 16px`,cursor:`pointer`,fontSize:`14px`,display:`flex`,alignItems:`center`,gap:`10px`,backgroundColor:p===n?`#f1f5f9`:`transparent`,transition:`background-color 0.15s`},onMouseEnter:()=>m(n),children:[(0,Z.jsx)(`div`,{style:{width:`8px`,height:`8px`,borderRadius:`50%`,backgroundColor:t.color||C(e.indexOf(t))}}),(0,Z.jsx)(`span`,{style:{fontWeight:`500`},children:t.label}),(0,Z.jsx)(`span`,{style:{marginLeft:`auto`,fontSize:`12px`,color:`#94a3b8`},children:t.type})]},t.field))]})})]})};var Ai={LOADING:`loading`,LOADED:`loaded`,FAILED:`failed`},ji=class{blockSize;maxConcurrentRequests;cacheBlockCount;cacheTimeout;getRows;blockCache;blockStatus;activeRequests;requestQueue;totalRows;sortModel;filterModel;observers;constructor(e){this.blockSize=e.blockSize||100,this.maxConcurrentRequests=e.maxConcurrentRequests||4,this.cacheBlockCount=e.cacheBlockCount||20,this.cacheTimeout=e.cacheTimeout||300*1e3,this.getRows=e.getRows,this.blockCache=new Map,this.blockStatus=new Map,this.activeRequests=0,this.requestQueue=[],this.totalRows=void 0,this.sortModel=[],this.filterModel={},this.observers=new Set}subscribe(e){return this.observers.add(e),()=>this.observers.delete(e)}notifyObservers(){this.observers.forEach(e=>e())}getBlockIndex(e){return Math.floor(e/this.blockSize)}getBlockStartRow(e){return e*this.blockSize}getBlockEndRow(e){return(e+1)*this.blockSize}isBlockCached(e){let t=this.blockCache.get(e);return t?Date.now()-t.timestamp>this.cacheTimeout?(this.blockCache.delete(e),this.blockStatus.delete(e),!1):!0:!1}purgeCache(){if(this.blockCache.size<=this.cacheBlockCount)return;let e=Array.from(this.blockCache.entries()).sort((e,t)=>e[1].timestamp-t[1].timestamp);e.slice(0,e.length-this.cacheBlockCount).forEach(([e])=>{this.blockCache.delete(e),this.blockStatus.delete(e)})}async fetchBlock(e){let t=this.getBlockStartRow(e),n=this.getBlockEndRow(e),r={startRow:t,endRow:n,sortModel:this.sortModel,filterModel:this.filterModel};try{let i=await this.getRows(r);this.blockCache.set(e,{startRow:t,endRow:n,rows:i.rows,timestamp:Date.now()}),this.blockStatus.set(e,{status:Ai.LOADED,rows:i.rows}),i.lastRow===void 0?i.totalRows!==void 0&&(this.totalRows=i.totalRows):this.totalRows=i.lastRow,this.purgeCache(),this.notifyObservers()}catch(t){console.error(`Failed to fetch block ${e}:`,t),this.blockStatus.set(e,{status:Ai.FAILED,error:t}),this.notifyObservers()}}queueBlockRequest(e){if(this.blockStatus.get(e)?.status===Ai.LOADING||this.isBlockCached(e))return;let t=async()=>{this.activeRequests++,this.blockStatus.set(e,{status:Ai.LOADING});try{await this.fetchBlock(e)}finally{this.activeRequests--,this.processQueue()}};this.activeRequests<this.maxConcurrentRequests?t():this.requestQueue.push(t)}processQueue(){for(;this.activeRequests<this.maxConcurrentRequests&&this.requestQueue.length>0;){let e=this.requestQueue.shift();e&&e()}}ensureBlocksLoaded(e,t){let n=this.getBlockIndex(e),r=this.getBlockIndex(t);for(let e=n;e<=r;e++)this.queueBlockRequest(e);this.queueBlockRequest(n-1),this.queueBlockRequest(r+1)}getRowsInRange(e,t){this.ensureBlocksLoaded(e,t);let n=[],r=this.getBlockIndex(e),i=this.getBlockIndex(t);for(let a=r;a<=i;a++){let r=this.blockCache.get(a);if(r){let i=this.getBlockStartRow(a);r.rows.forEach((r,a)=>{let o=i+a;o>=e&&o<t&&n.push(r)})}else{let r=this.getBlockStartRow(a),i=this.getBlockEndRow(a);for(let a=Math.max(e,r);a<Math.min(t,i);a++)n.push({id:`loading-${a}`,_loading:!0})}}return n}getRow(e){let t=this.getBlockIndex(e);if(!this.isBlockCached(t))return this.queueBlockRequest(t),{id:`loading-${e}`,_loading:!0};let n=this.blockCache.get(t);if(!n)return;let r=e-this.getBlockStartRow(t);return n.rows[r]}getTotalRows(){return this.totalRows}isBlockLoading(e){return this.blockStatus.get(e)?.status===Ai.LOADING}setSortModel(e){this.sortModel=e,this.refresh()}setFilterModel(e){this.filterModel=e,this.refresh()}refresh(){this.blockCache.clear(),this.blockStatus.clear(),this.totalRows=void 0,this.notifyObservers()}purgeBlock(e){this.blockCache.delete(e),this.blockStatus.delete(e)}destroy(){this.blockCache.clear(),this.blockStatus.clear(),this.requestQueue=[],this.observers.clear()}};function Mi(e=1e6,t=300){return new ji({blockSize:100,maxConcurrentRequests:2,cacheBlockCount:20,getRows:async n=>{await new Promise(e=>setTimeout(e,t));let{startRow:r,endRow:i,sortModel:a,filterModel:o}=n,s=[];for(let t=r;t<Math.min(i,e);t++)s.push({id:t,name:`User ${t}`,email:`user${t}@example.com`,age:20+t%50,country:[`USA`,`UK`,`Canada`,`Germany`,`France`][t%5],salary:3e4+t%100*1e3,department:[`Engineering`,`Sales`,`Marketing`,`HR`,`Finance`][t%5]});let c=s;if(o&&Object.keys(o).length>0&&(c=s.filter(e=>Object.entries(o).every(([t,n])=>{if(!n||`operator`in n)return!0;let r=e[t],i=n.value;return n.type===`contains`?String(r).toLowerCase().includes(String(i).toLowerCase()):n.type===`equals`?r===i:n.type===`greaterThan`?r>i:n.type===`lessThan`?r<i:!0}))),a&&a.length>0){let e=a[0];e.field&&e.direction&&c.sort((t,n)=>{let r=t[e.field],i=n[e.field];return r<i?e.direction===`asc`?-1:1:r>i?e.direction===`asc`?1:-1:0})}return{rows:c,totalRows:e,lastRow:s.length<i-r?r+s.length:void 0}}})}const Ni=({columns:e,dataSource:t,pageSize:n=100,showColumnPinning:r=!0,virtualScrollConfig:i,theme:a=`quartz`,onRowClick:o,onCellEdit:s,onSelectionChange:c})=>{let[l,u]=(0,b.useReducer)(fn,{columns:e,pageSize:n},e=>dn(e.columns,e.pageSize)),[d,f]=(0,b.useState)(null),[p,m]=(0,b.useState)(void 0),h=(0,b.useMemo)(()=>ii(ri(a)),[a]);(0,b.useLayoutEffect)(()=>{let e;e=t instanceof ji?t:new ji(t);let n=e.subscribe(()=>{m(e.getTotalRows())});return setTimeout(()=>f(e),0),()=>{n(),t instanceof ji||e.destroy()}},[t]),(0,b.useEffect)(()=>{d&&setTimeout(()=>m(d.getTotalRows()),0)},[d]),(0,b.useEffect)(()=>{d&&l.sortConfig.field&&d.setSortModel([l.sortConfig])},[d,l.sortConfig]),(0,b.useEffect)(()=>{d&&d.setFilterModel(l.filterConfig)},[d,l.filterConfig]);let g=new Set(l.hiddenColumns),_=l.columnOrder.filter(e=>!g.has(e)),v=l.pinnedColumnsLeft.filter(e=>_.includes(e)),y=l.pinnedColumnsRight.filter(e=>_.includes(e)),x=new Set(v),S=new Set(y),C=_.filter(e=>!x.has(e)&&!S.has(e)),w=[...v,...C,...y];(0,b.useEffect)(()=>{u({type:`RESET_COLUMNS`,payload:e})},[e]),(0,b.useEffect)(()=>{c&&c(Array.from(l.selection.selectedRows))},[l.selection.selectedRows]);let[T,E]=(0,b.useState)({start:0,end:n*15}),[D,O]=(0,b.useState)(0),k=(0,b.useMemo)(()=>d?d.getRowsInRange(T.start,T.end):[],[d,T,D]);(0,b.useEffect)(()=>{if(d)return d.subscribe(()=>{O(e=>e+1)})},[d]);let A=(0,b.useCallback)(e=>{if(!d||p===void 0)return;let t=i?.containerHeight||600,n=typeof i?.rowHeight==`number`?i.rowHeight:35,r=Math.ceil(t/n),a=Math.floor(e/n),o=r*5,s=Math.max(0,a-o),c=Math.min(p,a+r+o);(s<T.start||c>T.end)&&E({start:Math.max(0,Math.min(s,T.start)),end:Math.max(c,T.end)})},[d,p,i,T]);(0,b.useEffect)(()=>{let t={...l.columnWidths},n=!1;e.forEach(e=>{if(e.width)t[e.field]!==e.width&&(t[e.field]=e.width,n=!0);else{let r=e.headerName.length,i=Math.max(150,Math.min(300,r*10+50));t[e.field]||(t[e.field]=i,n=!0)}}),n&&e.forEach(e=>{u({type:`RESIZE_COLUMN`,payload:{field:e.field,width:t[e.field]}})})},[e]);let j=(0,b.useCallback)((e,t,r)=>{s&&s(l.currentPage*n+e,t,r)},[s,l.currentPage,n]);return d?(0,Z.jsxs)(`div`,{style:{...h,border:`var(--grid-border-width, 1px) solid var(--grid-border)`,borderRadius:`var(--grid-border-radius, 6px)`,backgroundColor:`var(--grid-bg)`,boxShadow:`var(--grid-shadow-light, 0 1px 3px 0 rgba(0, 0, 0, 0.08))`,fontFamily:`var(--grid-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif)`,display:`flex`,flexDirection:`column`,height:i?.containerHeight?`${i.containerHeight+150}px`:`auto`},children:[(0,Z.jsx)(`div`,{style:{position:`relative`,display:`flex`,alignItems:`center`,justifyContent:`space-between`,paddingLeft:`16px`,paddingRight:`16px`,paddingTop:`10px`,paddingBottom:`10px`,backgroundColor:`var(--grid-bg-alt)`,borderBottom:`var(--grid-border-width, 1px) solid var(--grid-border)`,zIndex:30},children:(0,Z.jsxs)(`div`,{style:{position:`relative`,display:`flex`,alignItems:`center`,gap:`8px`},children:[(0,Z.jsx)(zn,{columns:e,columnOrder:l.columnOrder,hiddenColumns:l.hiddenColumns,onToggleVisibility:e=>u({type:`TOGGLE_COLUMN_VISIBILITY`,payload:e}),onReorderColumns:(e,t)=>u({type:`REORDER_COLUMNS`,payload:{fromIndex:e,toIndex:t}}),onResetLayout:()=>u({type:`RESET_COLUMN_LAYOUT`})}),(0,Z.jsx)(`div`,{style:{fontSize:`14px`,color:`#64748b`,marginLeft:`12px`},children:p===void 0?`Loading...`:`${p.toLocaleString()} total rows`})]})}),(0,Z.jsx)(Ln,{columns:e,groupBy:l.groupBy,dispatch:u}),(0,Z.jsxs)(`div`,{style:{position:`sticky`,top:0,zIndex:20},children:[(0,Z.jsx)(pn,{columns:e,columnOrder:l.columnOrder,displayColumnOrder:w,columnWidths:l.columnWidths,sortConfig:l.sortConfig,dispatch:u,pinnedLeft:v,pinnedRight:y,showColumnPinning:r}),(0,Z.jsx)(or,{columns:e,displayColumnOrder:w,columnWidths:l.columnWidths,filterConfig:l.filterConfig,dispatch:u,pinnedLeft:v,pinnedRight:y,rows:k})]}),(0,Z.jsx)(Fn,{columns:e,rows:k,columnOrder:l.columnOrder,displayColumnOrder:w,columnWidths:l.columnWidths,selectedRows:l.selection.selectedRows,editState:l.editState,focusState:l.focusState,dispatch:u,onRowClick:o,onCellEdit:j,pinnedLeft:v,pinnedRight:y,onScroll:A,virtualScrollConfig:{...i,enabled:!0}}),(0,Z.jsxs)(`div`,{style:{padding:`8px 16px`,backgroundColor:`var(--grid-footer-bg)`,borderTop:`var(--grid-border-width, 1px) solid var(--grid-border)`,fontSize:`var(--grid-font-size-sm, 12px)`,color:`var(--grid-text-secondary)`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,Z.jsx)(`div`,{children:`Server-side infinite scrolling enabled`}),(0,Z.jsxs)(`div`,{children:[`Rows loaded: `,k.length]})]})]}):(0,Z.jsx)(`div`,{style:{padding:`20px`,textAlign:`center`,border:`1px solid #e2e8f0`,borderRadius:`6px`},children:`Loading data source...`})},Pi=({currentTheme:e,onThemeChange:t})=>{let n=[{value:`quartz`,label:`Quartz (Modern White)`},{value:`alpine`,label:`Alpine (Classic Business)`},{value:`material`,label:`Material`},{value:`dark`,label:`Dark Mode`},{value:`nord`,label:`Nord (Arctic)`},{value:`dracula`,label:`Dracula`},{value:`solarized-light`,label:`Solarized Light`},{value:`solarized-dark`,label:`Solarized Dark`},{value:`monokai`,label:`Monokai`},{value:`one-dark`,label:`One Dark`}],r=e=>{t(e.target.value)},i=ri(e);return(0,Z.jsxs)(`div`,{style:{display:`inline-flex`,alignItems:`center`,gap:`8px`},children:[(0,Z.jsx)(`label`,{htmlFor:`theme-selector`,style:{fontSize:`14px`,fontWeight:`500`,color:i.colors.text},children:`Theme:`}),(0,Z.jsx)(`select`,{id:`theme-selector`,value:e,onChange:r,style:{padding:`6px 32px 6px 12px`,fontSize:`14px`,fontFamily:i.typography.fontFamily,color:i.colors.text,backgroundColor:i.colors.background,border:`1px solid ${i.colors.border}`,borderRadius:i.borders.radius,cursor:`pointer`,outline:`none`,appearance:`none`,backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 9L1 4h10z'/%3E%3C/svg%3E")`,backgroundRepeat:`no-repeat`,backgroundPosition:`right 8px center`,transition:`border-color 0.2s`},onMouseEnter:e=>{e.currentTarget.style.borderColor=i.colors.primary},onMouseLeave:e=>{e.currentTarget.style.borderColor=i.colors.border},children:n.map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})},Fi=({status:e})=>{let t=(e=>{switch(e.toLowerCase()){case`active`:return{bg:`#dcfce7`,text:`#15803d`,border:`#86efac`};case`inactive`:return{bg:`#fee2e2`,text:`#991b1b`,border:`#fca5a5`};case`pending`:return{bg:`#fef3c7`,text:`#92400e`,border:`#fde047`};case`completed`:return{bg:`#dbeafe`,text:`#1e40af`,border:`#93c5fd`};default:return{bg:`#f3f4f6`,text:`#374151`,border:`#d1d5db`}}})(e);return(0,Z.jsx)(`span`,{style:{display:`inline-flex`,alignItems:`center`,padding:`4px 10px`,borderRadius:`12px`,fontSize:`12px`,fontWeight:600,backgroundColor:t.bg,color:t.text,border:`1px solid ${t.border}`},children:e})},Ii=({value:e,color:t=`#3b82f6`,showLabel:n=!0})=>{let r=Math.max(0,Math.min(100,e));return(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,width:`100%`},children:[(0,Z.jsx)(`div`,{style:{flex:1,height:`8px`,backgroundColor:`#e5e7eb`,borderRadius:`4px`,overflow:`hidden`},children:(0,Z.jsx)(`div`,{style:{width:`${r}%`,height:`100%`,backgroundColor:t,transition:`width 0.3s ease`}})}),n&&(0,Z.jsxs)(`span`,{style:{fontSize:`12px`,fontWeight:500,color:`#6b7280`,minWidth:`35px`},children:[r,`%`]})]})},Li=({src:e,alt:t,text:n,size:r=32})=>(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`},children:[(0,Z.jsx)(`img`,{src:e,alt:t,style:{width:`${r}px`,height:`${r}px`,borderRadius:`50%`,objectFit:`cover`,border:`2px solid #e5e7eb`}}),n&&(0,Z.jsx)(`span`,{style:{fontSize:`13px`},children:n})]}),Ri=({label:e,onClick:t,variant:n=`primary`,disabled:r=!1})=>{let i=(()=>{if(r)return{bg:`#e5e7eb`,text:`#9ca3af`,border:`#d1d5db`,cursor:`not-allowed`};switch(n){case`primary`:return{bg:`#3b82f6`,text:`#ffffff`,border:`#2563eb`,cursor:`pointer`};case`secondary`:return{bg:`#ffffff`,text:`#374151`,border:`#d1d5db`,cursor:`pointer`};case`danger`:return{bg:`#ef4444`,text:`#ffffff`,border:`#dc2626`,cursor:`pointer`}}})();return(0,Z.jsx)(`button`,{onClick:e=>{e.stopPropagation(),r||t(e)},disabled:r,style:{padding:`6px 12px`,fontSize:`12px`,fontWeight:500,backgroundColor:i.bg,color:i.text,border:`1px solid ${i.border}`,borderRadius:`4px`,cursor:i.cursor,transition:`all 0.2s ease`},onMouseEnter:e=>{!r&&n===`primary`?e.currentTarget.style.backgroundColor=`#2563eb`:!r&&n===`secondary`?e.currentTarget.style.backgroundColor=`#f9fafb`:!r&&n===`danger`&&(e.currentTarget.style.backgroundColor=`#dc2626`)},onMouseLeave:e=>{r||(e.currentTarget.style.backgroundColor=i.bg)},children:e})},zi=({text:e,color:t=`#1f2937`,backgroundColor:n=`#f3f4f6`})=>(0,Z.jsx)(`span`,{style:{display:`inline-flex`,alignItems:`center`,padding:`4px 8px`,borderRadius:`4px`,fontSize:`12px`,fontWeight:500,backgroundColor:n,color:t},children:e}),Bi=({priority:e})=>{let t=(()=>{switch(e){case`low`:return{icon:`●`,color:`#10b981`,text:`Low`};case`medium`:return{icon:`●`,color:`#f59e0b`,text:`Medium`};case`high`:return{icon:`●`,color:`#ef4444`,text:`High`};case`critical`:return{icon:`●`,color:`#991b1b`,text:`Critical`}}})();return(0,Z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`6px`},children:[(0,Z.jsx)(`span`,{style:{color:t.color,fontSize:`18px`},children:t.icon}),(0,Z.jsx)(`span`,{style:{fontSize:`13px`,fontWeight:500},children:t.text})]})},Vi=({rating:e,maxRating:t=5})=>(0,Z.jsx)(`div`,{style:{display:`flex`,gap:`2px`,fontSize:`14px`,color:`#f59e0b`},children:Array.from({length:t},(t,n)=>n<e?`★`:`☆`).map((e,t)=>(0,Z.jsx)(`span`,{children:e},t))}),Hi=({amount:e,currency:t=`USD`,locale:n=`en-US`})=>{let r=new Intl.NumberFormat(n,{style:`currency`,currency:t}).format(e);return(0,Z.jsx)(`span`,{style:{fontWeight:500,color:e<0?`#ef4444`:`#059669`},children:r})},Ui=()=>{let e=(0,b.useRef)(null),[t,n]=(0,b.useState)([]),[r,i]=(0,b.useState)(!1),a=e=>{n(t=>[...t.slice(-9),`${new Date().toLocaleTimeString()}: ${e}`])},o=e=>{i(!0),a(`✅ Grid API is ready! You can now call API methods.`)},[s]=(0,b.useState)([{field:`id`,headerName:`ID`,width:80},{field:`name`,headerName:`Name`,width:150,sortable:!0,filterable:!0},{field:`email`,headerName:`Email`,width:200,sortable:!0,filterable:!0},{field:`role`,headerName:`Role`,width:120,sortable:!0,filterable:!0},{field:`status`,headerName:`Status`,width:100,sortable:!0,filterable:!0},{field:`score`,headerName:`Score`,width:100,sortable:!0,filterable:!0}]),[c]=(0,b.useState)(()=>{let e=[`Admin`,`User`,`Manager`],t=[`Active`,`Inactive`,`Pending`],n=`Alice Johnson.Bob Smith.Charlie Brown.Diana Prince.Eve Wilson.Frank Miller.Grace Lee.Henry Ford.Ivy Green.Jack Black.Karen White.Leo King.Mona Lisa.Nina Brown.Oscar Wilde.Paul Allen.Quinn Fox.Rita Ora.Sam Hunt.Tina Fey.Uma Thurman.Victor Hugo.Wendy Wu.Xander Cage.Yara Shahidi.Zane Grey`.split(`.`),r=[];for(let i=1;i<=100;i++){let a=n[i%n.length]+` `+i;r.push({id:i,name:a,email:a.replace(/\s+/g,``).toLowerCase()+`@example.com`,role:e[i%e.length],status:t[i%t.length],score:Math.floor(Math.random()*100)})}return r});return(0,Z.jsxs)(`div`,{style:{padding:`20px`,maxWidth:`1400px`,margin:`0 auto`},children:[(0,Z.jsxs)(`div`,{style:{marginBottom:`20px`},children:[(0,Z.jsx)(`h2`,{children:`Grid API Demo`}),(0,Z.jsx)(`p`,{style:{color:`#666`},children:`Demonstrates programmatic control of the DataGrid using the GridApi ref (AG Grid-inspired API)`})]}),(0,Z.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(200px, 1fr))`,gap:`10px`,marginBottom:`20px`,padding:`15px`,backgroundColor:`#f5f5f5`,borderRadius:`8px`},children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{style:{margin:`0 0 10px 0`,fontSize:`14px`,fontWeight:`600`},children:`Data Operations`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;if(!t)return;let n={id:Date.now(),name:`New User ${Math.floor(Math.random()*1e3)}`,email:`user${Date.now()}@example.com`,role:`User`,status:`Pending`,score:Math.floor(Math.random()*100)};t.applyTransaction({add:[n]}),a(`Added new row: ${n.name}`)},style:Wi,children:`Add Row`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;if(!t)return;let n=t.getSelectedRows();if(n.length===0){a(`No rows selected`);return}let r=n.map(e=>({...e,score:Math.floor(Math.random()*100)}));t.applyTransaction({update:r}),a(`Updated ${r.length} row(s)`)},style:Wi,children:`Update Selected`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;if(!t)return;let n=t.getSelectedRows();if(n.length===0){a(`No rows selected`);return}t.applyTransaction({remove:n}),a(`Removed ${n.length} row(s)`)},style:Wi,children:`Remove Selected`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{style:{margin:`0 0 10px 0`,fontSize:`14px`,fontWeight:`600`},children:`Column Operations`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.setColumnVisible(`email`,!1),a(`Hidden Email column`))},style:Wi,children:`Hide Email`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.setColumnVisible(`email`,!0),a(`Shown Email column`))},style:Wi,children:`Show Email`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.setColumnPinned(`name`,`left`),a(`Pinned Name column to left`))},style:Wi,children:`Pin Name`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.setColumnPinned(`name`,null),a(`Unpinned Name column`))},style:Wi,children:`Unpin Name`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.autoSizeAllColumns(),a(`Auto-sized all columns`))},style:Wi,children:`Auto-size Columns`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.sizeColumnsToFit(),a(`Resized columns to fit grid width`))},style:Wi,children:`Fit to Width`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{style:{margin:`0 0 10px 0`,fontSize:`14px`,fontWeight:`600`},children:`Filter & Sort`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.setFilterModel({status:{type:`equals`,value:`Active`}}),a(`Filtered by Status = Active`))},style:Wi,children:`Filter Active`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.clearAllFilters(),a(`Cleared all filters`))},style:Wi,children:`Clear Filters`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.setSortModel([{field:`score`,direction:`desc`}]),a(`Sorted by Score descending`))},style:Wi,children:`Sort by Score`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.clearAllSorting(),a(`Cleared sorting`))},style:Wi,children:`Clear Sort`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{style:{margin:`0 0 10px 0`,fontSize:`14px`,fontWeight:`600`},children:`Selection`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.selectAll(),a(`Selected all rows`))},style:Wi,children:`Select All`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.deselectAll(),a(`Deselected all rows`))},style:Wi,children:`Deselect All`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.selectAllFiltered(),a(`Selected all filtered rows`))},style:Wi,children:`Select Filtered`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&a(`Selected ${t.getSelectedRows().length} row(s)`)},style:Wi,children:`Get Selection`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{style:{margin:`0 0 10px 0`,fontSize:`14px`,fontWeight:`600`},children:`Export & Clipboard`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.exportDataAsCsv({fileName:`grid-export`,onlySelected:!1,onlyFiltered:!0}),a(`Exported to CSV`))},style:Wi,children:`Export CSV`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;if(!t)return;let n=t.getSelectedRowCount();if(n===0){a(`⚠️ No rows selected! Please select rows first.`);return}t.copySelectedRowsToClipboard(),a(`✓ Copied ${n} selected row(s) to clipboard`)},style:Wi,children:`Copy to Clipboard`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{style:{margin:`0 0 10px 0`,fontSize:`14px`,fontWeight:`600`},children:`Navigation`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;if(!t)return;let n=t.paginationGetCurrentPage(),r=t.paginationGetPageSize(),i=n*r,o=Math.min(r,t.getDisplayedRowCount()-i),s=Math.floor(o/2);t.ensureIndexVisible(s,`middle`),a(`Scrolled to row ${s} (middle of page ${n+1})`)},style:Wi,children:`Scroll to Middle`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.setFocusedCell(2,`name`),a(`Focused cell at row 2, column Name`))},style:Wi,children:`Focus Cell`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.paginationGoToNextPage(),a(`Navigated to page ${t.paginationGetCurrentPage()+1}`))},style:Wi,children:`Next Page`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.paginationGoToPreviousPage(),a(`Navigated to page ${t.paginationGetCurrentPage()+1}`))},style:Wi,children:`Previous Page`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;t&&(t.paginationSetPageSize(20),a(`Set page size to 20`))},style:Wi,children:`Page Size: 20`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{style:{margin:`0 0 10px 0`,fontSize:`14px`,fontWeight:`600`},children:`Info`}),(0,Z.jsx)(`button`,{onClick:()=>{let t=e.current;if(!t)return;let n=t.getDisplayedRowCount(),r=t.getSelectedRowCount(),i=t.isAnyFilterPresent(),o=t.paginationGetCurrentPage(),s=t.paginationGetTotalPages();a(`Rows: ${n}, Selected: ${r}, Filters: ${i}, Page: ${o+1}/${s}`)},style:Wi,children:`Get Grid Info`})]})]}),(0,Z.jsxs)(`div`,{style:{marginBottom:`20px`,padding:`10px`,backgroundColor:`#f9f9f9`,borderRadius:`4px`,border:`1px solid #ddd`,height:`120px`,overflow:`auto`,fontFamily:`monospace`,fontSize:`12px`},children:[(0,Z.jsx)(`div`,{style:{fontWeight:`600`,marginBottom:`5px`},children:`Activity Log:`}),t.length===0?(0,Z.jsx)(`div`,{style:{color:`#999`},children:`No actions yet. Click buttons above to interact with the grid.`}):t.map((e,t)=>(0,Z.jsx)(`div`,{style:{padding:`2px 0`},children:e},t))]}),(0,Z.jsxs)(`div`,{style:{marginBottom:`10px`,padding:`10px`,backgroundColor:r?`#d4edda`:`#f8d7da`,borderRadius:`4px`,border:`1px solid ${r?`#c3e6cb`:`#f5c6cb`}`},children:[(0,Z.jsx)(`strong`,{children:`Grid Status:`}),` `,r?`✅ Ready`:`⏳ Initializing...`]}),(0,Z.jsx)(ci,{ref:e,columns:s,rows:c,pageSize:10,theme:`quartz`,densityMode:`normal`,showDensityToggle:!0,onGridReady:o,onSelectionChange:e=>{a(`Selection changed: ${e.length} row(s)`)}}),(0,Z.jsxs)(`div`,{style:{marginTop:`30px`,padding:`20px`,backgroundColor:`#e8f5e9`,borderRadius:`8px`,marginBottom:`20px`},children:[(0,Z.jsx)(`h3`,{style:{marginTop:0},children:`📘 Using onGridReady Event`}),(0,Z.jsxs)(`p`,{style:{fontSize:`14px`,lineHeight:`1.6`},children:[`The `,(0,Z.jsx)(`code`,{children:`onGridReady`}),` callback is fired when the grid API is fully initialized and ready to use. This is similar to AG-Grid's `,(0,Z.jsx)(`code`,{children:`onGridReady`}),` event.`]}),(0,Z.jsx)(`pre`,{style:{backgroundColor:`#fff`,padding:`15px`,borderRadius:`4px`,overflow:`auto`,fontSize:`13px`},children:`// Example usage
47
47
  const MyComponent = () => {
48
48
  const gridRef = useRef<GridApi>(null);
49
49