serverside_pivot 0.0.91 → 0.0.95

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 (166) hide show
  1. package/README.md +182 -182
  2. package/dist/react/chunks/{ContextMenu-Bt5_3bmD.mjs → ContextMenu-1G-o1ms9.mjs} +52 -49
  3. package/dist/react/chunks/{DetailDrawer-Eb4EpVHG.mjs → DetailDrawer-DCKIxSpW.mjs} +1 -1
  4. package/dist/react/chunks/{DetailSidePanel-BTcHOiKr.mjs → DetailSidePanel-DgUWPBQk.mjs} +1 -1
  5. package/dist/react/chunks/{DetailSurfaceContent-B3ZNKh7q.mjs → DetailSurfaceContent-BEL6xuaZ.mjs} +46 -37
  6. package/dist/react/chunks/{ECharts2dRenderer-C3Qv0uAa.mjs → ECharts2dRenderer-Dgkp9_1P.mjs} +412 -410
  7. package/dist/react/chunks/{ECharts3dRenderer-BB_7-fOt.mjs → ECharts3dRenderer-70VOp8V0.mjs} +2211 -3197
  8. package/dist/react/chunks/{EditSidePanel-C2cAvxlK.mjs → EditSidePanel-CygqVXLX.mjs} +77 -65
  9. package/dist/react/chunks/{InlineDetailPanel-BXLAw1o3.mjs → InlineDetailPanel-BUBRWdFW.mjs} +1 -1
  10. package/dist/react/chunks/{PivotCharts-Bw6Swoa3.mjs → PivotCharts-VX5-mEEp.mjs} +2206 -1396
  11. package/dist/react/chunks/{ReportEditor-D4V0ry2B.mjs → ReportEditor-B5j-CU9-.mjs} +614 -319
  12. package/dist/react/chunks/{SidebarPanel-xO59p_2o.mjs → SidebarPanel-LXUE6nPd.mjs} +1793 -1390
  13. package/dist/react/chunks/{SparklineDetailGraph-Bu85X7OJ.mjs → SparklineDetailGraph-Cfe2KcOp.mjs} +88 -58
  14. package/dist/react/chunks/installCanvasRenderer-C4h5pc1p.mjs +21174 -0
  15. package/dist/react/chunks/react-CDa-ADnG.mjs +31199 -0
  16. package/dist/react/chunks/{xlsx.mini.min-vfxHk3Ry.mjs → xlsx.mini.min-CzdkdH3N.mjs} +5 -5
  17. package/dist/react/components/Charts/ChartRenderers.d.ts +5 -73
  18. package/dist/react/components/Charts/ChartWorkspace.d.ts +3 -34
  19. package/dist/react/components/Charts/ECharts2dRenderer.d.ts +2 -5
  20. package/dist/react/components/Charts/ECharts3dRenderer.d.ts +2 -6
  21. package/dist/react/components/Charts/PivotCharts.d.ts +2 -9
  22. package/dist/react/components/Charts/chartEnhancements.d.ts +17 -66
  23. package/dist/react/components/Charts/chartExportPresentation.d.ts +5 -19
  24. package/dist/react/components/Charts/chartMath.d.ts +4 -4
  25. package/dist/react/components/Charts/useChartExportMenu.d.ts +4 -12
  26. package/dist/react/components/DashTanstackPivot.react.d.ts +36 -0
  27. package/dist/react/components/Filters/ColumnFilter.d.ts +2 -12
  28. package/dist/react/components/Filters/DateRangeFilter.d.ts +2 -7
  29. package/dist/react/components/Filters/FilterPopover.d.ts +2 -13
  30. package/dist/react/components/Filters/MultiSelectFilter.d.ts +2 -11
  31. package/dist/react/components/Filters/NumericRangeFilter.d.ts +2 -7
  32. package/dist/react/components/Notification.d.ts +2 -6
  33. package/dist/react/components/PivotAppBar.d.ts +2 -2
  34. package/dist/react/components/PivotErrorBoundary.d.ts +11 -7
  35. package/dist/react/components/PivotSmallComponents.d.ts +2 -3
  36. package/dist/react/components/PivotWorkspaceCanvas.d.ts +2 -5
  37. package/dist/react/components/PivotWorkspaceControls.d.ts +4 -8
  38. package/dist/react/components/PivotWorkspaceShell.d.ts +4 -12
  39. package/dist/react/components/RuntimeDataError.d.ts +2 -7
  40. package/dist/react/components/Sidebar/ColumnTreeItem.d.ts +2 -13
  41. package/dist/react/components/Sidebar/ReportEditor.d.ts +7 -20
  42. package/dist/react/components/Sidebar/SidebarFilterItem.d.ts +2 -13
  43. package/dist/react/components/Sidebar/SidebarPanel.d.ts +1 -2
  44. package/dist/react/components/Sidebar/ToolPanelSection.d.ts +2 -13
  45. package/dist/react/components/Sidebar/customCategoryUtils.d.ts +31 -62
  46. package/dist/react/components/Sidebar/formulaUtils.d.ts +16 -18
  47. package/dist/react/components/SkeletonRow.d.ts +2 -5
  48. package/dist/react/components/Table/ContextMenu.d.ts +2 -8
  49. package/dist/react/components/Table/DetailDrawer.d.ts +2 -11
  50. package/dist/react/components/Table/DetailSidePanel.d.ts +2 -11
  51. package/dist/react/components/Table/DetailSurfaceContent.d.ts +2 -11
  52. package/dist/react/components/Table/EditSidePanel.d.ts +2 -20
  53. package/dist/react/components/Table/EditableCell.d.ts +2 -28
  54. package/dist/react/components/Table/InlineDetailPanel.d.ts +2 -13
  55. package/dist/react/components/Table/PivotTableBody.d.ts +3 -3
  56. package/dist/react/components/Table/SparklineCell.d.ts +2 -17
  57. package/dist/react/components/Table/SparklineDetailGraph.d.ts +2 -5
  58. package/dist/react/components/Table/StatusBar.d.ts +2 -7
  59. package/dist/react/contexts/PivotConfigContext.d.ts +5 -33
  60. package/dist/react/contexts/PivotThemeContext.d.ts +7 -4
  61. package/dist/react/contexts/PivotValueDisplayContext.d.ts +5 -9
  62. package/dist/react/hooks/useChartState.d.ts +2 -71
  63. package/dist/react/hooks/useColumnDefs.d.ts +3 -68
  64. package/dist/react/hooks/useColumnVirtualizer.d.ts +1 -30
  65. package/dist/react/hooks/useDetailDrillThrough.d.ts +2 -36
  66. package/dist/react/hooks/useFilteredData.d.ts +4 -2
  67. package/dist/react/hooks/useFormatState.d.ts +2 -39
  68. package/dist/react/hooks/usePersistence.d.ts +4 -5
  69. package/dist/react/hooks/usePivotFieldInteractions.d.ts +2 -23
  70. package/dist/react/hooks/usePivotNormalization.d.ts +127 -461
  71. package/dist/react/hooks/usePivotRenderCounter.d.ts +2 -1
  72. package/dist/react/hooks/usePivotTransactions.d.ts +2 -23
  73. package/dist/react/hooks/useRenderHelpers.d.ts +3 -71
  74. package/dist/react/hooks/useReportMode.d.ts +2 -28
  75. package/dist/react/hooks/useRowCache.d.ts +16 -15
  76. package/dist/react/hooks/useRuntimeDataCommit.d.ts +2 -22
  77. package/dist/react/hooks/useRuntimeProfiling.d.ts +2 -13
  78. package/dist/react/hooks/useRuntimeTransport.d.ts +2 -18
  79. package/dist/react/hooks/useServerSideRowModel.d.ts +1 -50
  80. package/dist/react/hooks/useServerSideViewportController.d.ts +1 -64
  81. package/dist/react/hooks/useSidebarUI.d.ts +2 -32
  82. package/dist/react/hooks/useStickyStyles.d.ts +2 -23
  83. package/dist/react/index.mjs +15 -9
  84. package/dist/react/presentation/headerFormatting.d.ts +28 -11
  85. package/dist/react/presentation/safeCellContent.d.ts +22 -5
  86. package/dist/react/react.d.ts +3 -0
  87. package/dist/react/runtime/PivotRuntimeRoot.d.ts +1 -1
  88. package/dist/react/runtime/client/clientPivotTransport.d.ts +5 -1
  89. package/dist/react/runtime/client/clientResponsePostProcessor.d.ts +50 -0
  90. package/dist/react/runtime/client/types.d.ts +5 -0
  91. package/dist/react/runtime/createRuntimeCellPresentation.d.ts +2 -7
  92. package/dist/react/runtime/createRuntimeExportCommands.d.ts +2 -71
  93. package/dist/react/runtime/createRuntimeRowPinCommand.d.ts +2 -9
  94. package/dist/react/runtime/displayColumnOrder.d.ts +4 -4
  95. package/dist/react/runtime/httpTransport.d.ts +1 -0
  96. package/dist/react/runtime/runtime-contract.generated.d.ts +3 -0
  97. package/dist/react/runtime/runtimeContract.d.ts +3 -0
  98. package/dist/react/runtime/runtimeDomains.d.ts +18 -0
  99. package/dist/react/runtime/useChartWorkspacePresentation.d.ts +2 -45
  100. package/dist/react/runtime/useCoreRuntime.d.ts +4 -1
  101. package/dist/react/runtime/useCoreRuntimeStage.d.ts +1 -1
  102. package/dist/react/runtime/useRuntimeCellSelection.d.ts +2 -40
  103. package/dist/react/runtime/useRuntimeChartCanvasCommands.d.ts +7 -31
  104. package/dist/react/runtime/useRuntimeChartCanvasResize.d.ts +2 -13
  105. package/dist/react/runtime/useRuntimeChartCanvasVerticalResize.d.ts +2 -9
  106. package/dist/react/runtime/useRuntimeChartDefinitionCommands.d.ts +2 -14
  107. package/dist/react/runtime/useRuntimeChartFloatingInteractions.d.ts +2 -28
  108. package/dist/react/runtime/useRuntimeChartModels.d.ts +2 -62
  109. package/dist/react/runtime/useRuntimeChartPanelSizing.d.ts +2 -12
  110. package/dist/react/runtime/useRuntimeChartRequestDispatch.d.ts +2 -4
  111. package/dist/react/runtime/useRuntimeClipboardExportPresentation.d.ts +2 -152
  112. package/dist/react/runtime/useRuntimeClipboardPaste.d.ts +2 -7
  113. package/dist/react/runtime/useRuntimeColorScalePresentation.d.ts +2 -55
  114. package/dist/react/runtime/useRuntimeColumnAutoSizing.d.ts +2 -26
  115. package/dist/react/runtime/useRuntimeColumnCommands.d.ts +2 -22
  116. package/dist/react/runtime/useRuntimeColumnMeasurement.d.ts +2 -11
  117. package/dist/react/runtime/useRuntimeDataRetry.d.ts +2 -12
  118. package/dist/react/runtime/useRuntimeDisplayNavigation.d.ts +2 -11
  119. package/dist/react/runtime/useRuntimeEditCellIdentity.d.ts +2 -18
  120. package/dist/react/runtime/useRuntimeEditChangeTracking.d.ts +2 -28
  121. package/dist/react/runtime/useRuntimeEditComparisonState.d.ts +2 -35
  122. package/dist/react/runtime/useRuntimeEditDispatch.d.ts +2 -43
  123. package/dist/react/runtime/useRuntimeEditOwnership.d.ts +2 -28
  124. package/dist/react/runtime/useRuntimeEditPresentation.d.ts +2 -32
  125. package/dist/react/runtime/useRuntimeEditStatePersistence.d.ts +2 -24
  126. package/dist/react/runtime/useRuntimeExportState.d.ts +5 -5
  127. package/dist/react/runtime/useRuntimeFilterPopover.d.ts +2 -19
  128. package/dist/react/runtime/useRuntimeLayoutHistory.d.ts +2 -40
  129. package/dist/react/runtime/useRuntimeOptimisticCellState.d.ts +2 -27
  130. package/dist/react/runtime/useRuntimeRequestSession.d.ts +2 -76
  131. package/dist/react/runtime/useRuntimeResponseLifecycle.d.ts +2 -43
  132. package/dist/react/runtime/useRuntimeResponsePostCommit.d.ts +2 -15
  133. package/dist/react/runtime/useRuntimeRowEditSessions.d.ts +2 -28
  134. package/dist/react/runtime/useRuntimeRowEditing.d.ts +2 -18
  135. package/dist/react/runtime/useRuntimeRowSelection.d.ts +2 -14
  136. package/dist/react/runtime/useRuntimeSelectionFormatting.d.ts +2 -30
  137. package/dist/react/runtime/useRuntimeStructuralSync.d.ts +2 -61
  138. package/dist/react/runtime/useRuntimeViewRestoreScroll.d.ts +2 -5
  139. package/dist/react/runtime/useRuntimeViewSnapshot.d.ts +2 -196
  140. package/dist/react/runtime/useRuntimeViewportTableData.d.ts +2 -23
  141. package/dist/react/runtime/useWorkspaceStatusPresentation.d.ts +2 -109
  142. package/dist/react/utils/Icons.d.ts +2 -45
  143. package/dist/react/utils/chartModelBuilders.d.ts +76 -230
  144. package/dist/react/utils/columnOrder.d.ts +8 -12
  145. package/dist/react/utils/dataBars.d.ts +3 -7
  146. package/dist/react/utils/domEvents.d.ts +1 -1
  147. package/dist/react/utils/editing.d.ts +12 -47
  148. package/dist/react/utils/exportUtils.d.ts +30 -101
  149. package/dist/react/utils/fieldPanelLayout.d.ts +12 -61
  150. package/dist/react/utils/filterOptions.d.ts +4 -4
  151. package/dist/react/utils/helpers.d.ts +16 -18
  152. package/dist/react/utils/horizontalViewport.d.ts +1 -12
  153. package/dist/react/utils/layoutRows.d.ts +3 -3
  154. package/dist/react/utils/measureAxis.d.ts +6 -22
  155. package/dist/react/utils/pivotLayoutUtils.d.ts +3 -2
  156. package/dist/react/utils/pivotProfiler.d.ts +3 -3
  157. package/dist/react/utils/reportEditorSelection.d.ts +1 -23
  158. package/dist/react/utils/rowSpanning.d.ts +3 -6
  159. package/dist/react/utils/savedReports.d.ts +4 -7
  160. package/dist/react/utils/sorting.d.ts +8 -14
  161. package/dist/react/utils/sparklineDetail.d.ts +5 -8
  162. package/dist/react/utils/sparklines.d.ts +10 -78
  163. package/dist/react/utils/styles.d.ts +19 -308
  164. package/package.json +114 -114
  165. package/dist/react/chunks/installCanvasRenderer-B7sfDGoL.mjs +0 -21281
  166. package/dist/react/chunks/react-CPZZxtSo.mjs +0 -26999
@@ -1,5 +1,5 @@
1
1
  import e, { useState as be, useRef as mt, useEffect as er } from "react";
2
- import { y as z, Y as fe, Z as Wr, _ as Br, $ as xt, a0 as Je, a1 as Ir, a2 as Lr, a3 as Pr, a4 as Fe, a5 as Qe, a6 as et, E as Or, a7 as Hr, a8 as Ur, a9 as jr, aa as Pe, ab as tr, ac as Vr, ad as Ht, ae as Yr, af as Zr, ag as Kr, ah as Gr, ai as Nr, aj as Xr } from "./react-CPZZxtSo.mjs";
2
+ import { z, Z as fe, _ as Wr, $ as Br, a0 as xt, a1 as Je, a2 as Ir, a3 as Lr, a4 as Pr, a5 as Fe, a6 as Qe, a7 as et, F as Or, a8 as Hr, a9 as Ur, aa as jr, ab as Pe, ac as tr, ad as Vr, ae as Ht, af as Zr, ag as Yr, ah as Kr, ai as Gr, aj as Nr, ak as Xr } from "./react-CDa-ADnG.mjs";
3
3
  const Jr = ({ column: t, theme: n, styles: s, onFilter: a, currentFilter: l, options: g, optionMeta: u, onSearchOptions: E, onLoadMoreOptions: d, onOpen: $ }) => {
4
4
  const [i, m] = be(!1), T = l && (l.conditions || l.value), L = () => m(!1), _ = () => {
5
5
  const D = !i;
@@ -87,21 +87,24 @@ const Jr = ({ column: t, theme: n, styles: s, onFilter: a, currentFilter: l, opt
87
87
  height: `${h.getTotalSize()}px`,
88
88
  width: "100%",
89
89
  position: "relative"
90
- } }, h.getVirtualItems().map((k) => /* @__PURE__ */ e.createElement(
91
- "div",
92
- {
93
- key: k.index,
94
- style: {
95
- position: "absolute",
96
- top: 0,
97
- left: 0,
98
- width: "100%",
99
- height: `${k.size}px`,
100
- transform: `translateY(${k.start}px)`
101
- }
102
- },
103
- a(s[k.index], k.index)
104
- ))) : n
90
+ } }, h.getVirtualItems().map(
91
+ /** @param {any} [virtualRow] @returns {any} */
92
+ (k) => /* @__PURE__ */ e.createElement(
93
+ "div",
94
+ {
95
+ key: k.index,
96
+ style: {
97
+ position: "absolute",
98
+ top: 0,
99
+ left: 0,
100
+ width: "100%",
101
+ height: `${k.size}px`,
102
+ transform: `translateY(${k.start}px)`
103
+ }
104
+ },
105
+ a(s[k.index], k.index)
106
+ )
107
+ )) : n
105
108
  )
106
109
  );
107
110
  }, rr = ({ column: t, level: n, theme: s, styles: a, handlePinColumn: l, colSearch: g, selectedCols: u, setSelectedCols: E, onDrop: d, sectionId: $ }) => {
@@ -123,11 +126,26 @@ const Jr = ({ column: t, theme: n, styles: s, onFilter: a, currentFilter: l, opt
123
126
  const R = (v) => {
124
127
  v.stopPropagation();
125
128
  const U = new Set(u), Q = h ? xt(t) : [t.id];
126
- Q.every((ee) => U.has(ee)) ? Q.forEach((ee) => U.delete(ee)) : Q.forEach((ee) => U.add(ee)), E(U);
129
+ Q.every(
130
+ /** @param {any} [id] @returns {any} */
131
+ (ee) => U.has(ee)
132
+ ) ? Q.forEach(
133
+ /** @param {any} [id] @returns {any} */
134
+ (ee) => U.delete(ee)
135
+ ) : Q.forEach(
136
+ /** @param {any} [id] @returns {any} */
137
+ (ee) => U.add(ee)
138
+ ), E(U);
127
139
  }, B = (v) => {
128
140
  if (v.stopPropagation(), h) {
129
- const U = Ir(t), Q = U.some((V) => !V.getIsVisible());
130
- U.forEach((V) => V.toggleVisibility(Q));
141
+ const U = Ir(t), Q = U.some(
142
+ /** @param {any} [c] @returns {any} */
143
+ (V) => !V.getIsVisible()
144
+ );
145
+ U.forEach(
146
+ /** @param {any} [c] @returns {any} */
147
+ (V) => V.toggleVisibility(Q)
148
+ );
131
149
  } else
132
150
  t.toggleVisibility();
133
151
  }, M = (v, U) => {
@@ -238,22 +256,28 @@ const Jr = ({ column: t, theme: n, styles: s, onFilter: a, currentFilter: l, opt
238
256
  ),
239
257
  !h && /* @__PURE__ */ e.createElement("div", { className: "pin-controls" }, /* @__PURE__ */ e.createElement("button", { onClick: (v) => M(v, "left"), title: "Pin Column Left", "aria-label": "Pin Column Left" }, /* @__PURE__ */ e.createElement(z.PinLeft, null)), /* @__PURE__ */ e.createElement("button", { onClick: (v) => M(v, !1), title: "Unpin Column", "aria-label": "Unpin Column" }, /* @__PURE__ */ e.createElement(z.Unpin, null)), /* @__PURE__ */ e.createElement("button", { onClick: (v) => M(v, "right"), title: "Pin Column Right", "aria-label": "Pin Column Right" }, /* @__PURE__ */ e.createElement(z.PinRight, null)))
240
258
  ),
241
- h && i && /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column" } }, t.columns.filter((v) => Je(v, $)).map((v) => /* @__PURE__ */ e.createElement(
242
- rr,
243
- {
244
- key: v.id,
245
- column: v,
246
- level: n + 1,
247
- theme: s,
248
- styles: a,
249
- handlePinColumn: l,
250
- colSearch: g,
251
- selectedCols: u,
252
- setSelectedCols: E,
253
- onDrop: d,
254
- sectionId: $
255
- }
256
- )))
259
+ h && i && /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column" } }, t.columns.filter(
260
+ /** @param {any} [child] @returns {any} */
261
+ (v) => Je(v, $)
262
+ ).map(
263
+ /** @param {any} [child] @returns {any} */
264
+ (v) => /* @__PURE__ */ e.createElement(
265
+ rr,
266
+ {
267
+ key: v.id,
268
+ column: v,
269
+ level: n + 1,
270
+ theme: s,
271
+ styles: a,
272
+ handlePinColumn: l,
273
+ colSearch: g,
274
+ selectedCols: u,
275
+ setSelectedCols: E,
276
+ onDrop: d,
277
+ sectionId: $
278
+ }
279
+ )
280
+ ))
257
281
  );
258
282
  }, nr = /\b[A-Za-z_][A-Za-z0-9_]*\b/g, lr = /^[A-Za-z_][A-Za-z0-9_]*$/, tt = /\[([^\]]+)\]/g, qr = /* @__PURE__ */ new Set(["abs", "round", "ceil", "floor", "max", "min", "int", "float"]), Qr = /* @__PURE__ */ new Set(["True", "False", "None", "and", "or", "not", "if", "else", "in", "is"]), Ee = {
259
283
  type: "line",
@@ -378,20 +402,29 @@ function ln(t, n) {
378
402
  __isNew: !0
379
403
  };
380
404
  }
381
- const Vt = (t) => String(t || "").split(",").map((n) => n.trim()).filter(Boolean), Yt = (t) => String(t || "").trim().replace(/\s+/g, " ").toLowerCase(), sr = (t) => t && (t.__editingField || t.field) ? t.__editingField || t.field : "";
405
+ const Vt = (t) => String(t || "").split(",").map((n) => n.trim()).filter(Boolean), Zt = (t) => String(t || "").trim().replace(/\s+/g, " ").toLowerCase(), sr = (t) => t && (t.__editingField || t.field) ? t.__editingField || t.field : "";
382
406
  function an(t, n) {
383
407
  const s = Array.isArray(t) ? t : [], a = sr(n);
384
408
  if (!a) return s;
385
- const l = s.findIndex((g) => g && g.field === a);
409
+ const l = s.findIndex(
410
+ /** @param {any} [dimension] @returns {any} */
411
+ (g) => g && g.field === a
412
+ );
386
413
  return l >= 0 ? s.slice(0, l) : s;
387
414
  }
388
- function Zt(t) {
415
+ function Yt(t) {
389
416
  const n = [];
390
- return (t && Array.isArray(t.rules) ? t.rules : []).forEach((s) => {
391
- (s && s.condition && Array.isArray(s.condition.clauses) ? s.condition.clauses : []).forEach((l) => {
392
- l && l.field && n.push(l.field);
393
- });
394
- }), Array.from(new Set(n));
417
+ return (t && Array.isArray(t.rules) ? t.rules : []).forEach(
418
+ /** @param {any} [rule] @returns {any} */
419
+ (s) => {
420
+ (s && s.condition && Array.isArray(s.condition.clauses) ? s.condition.clauses : []).forEach(
421
+ /** @param {any} [clause] @returns {any} */
422
+ (l) => {
423
+ l && l.field && n.push(l.field);
424
+ }
425
+ );
426
+ }
427
+ ), Array.from(new Set(n));
395
428
  }
396
429
  function on(t, n) {
397
430
  const s = (Array.isArray(t) ? t : []).filter((a) => a && typeof a == "object").filter((a) => !a._isTotal && a._path !== "__grand_total__" && a._path !== "__color_scale_stats__");
@@ -400,12 +433,19 @@ function on(t, n) {
400
433
  function sn(t, n) {
401
434
  return !Array.isArray(t) || t.length === 0 || !Array.isArray(n) || n.length === 0 ? !1 : n.every((s) => t.some((a) => a && Object.prototype.hasOwnProperty.call(a, s)));
402
435
  }
403
- const cn = (t, n) => (n && Array.isArray(n.rules) ? n.rules : []).map((s) => ({
404
- label: s && s.label ? s.label : "Rule",
405
- count: t.reduce((a, l) => Pr(l, s.condition) ? a + 1 : a, 0)
406
- })), un = e.lazy(() => import(
436
+ const cn = (t, n) => (n && Array.isArray(n.rules) ? n.rules : []).map(
437
+ /** @param {any} [rule] @returns {any} */
438
+ (s) => ({
439
+ label: s && s.label ? s.label : "Rule",
440
+ count: t.reduce(
441
+ /** @param {any} [matches] @param {any} [row] @returns {any} */
442
+ (a, l) => Pr(l, s.condition) ? a + 1 : a,
443
+ 0
444
+ )
445
+ })
446
+ ), un = e.lazy(() => import(
407
447
  /* webpackChunkName: "pivot-report-editor" */
408
- "./ReportEditor-D4V0ry2B.mjs"
448
+ "./ReportEditor-B5j-CU9-.mjs"
409
449
  ).then((t) => ({
410
450
  default: t.ReportEditor
411
451
  }))), pn = (t) => /* @__PURE__ */ e.createElement(e.Suspense, { fallback: /* @__PURE__ */ e.createElement("div", { role: "status", style: { padding: "16px" } }, "Loading report builder…") }, /* @__PURE__ */ e.createElement(un, { ...t }));
@@ -420,7 +460,10 @@ function Kt({
420
460
  onDeleteField: E
421
461
  }) {
422
462
  const d = e.useMemo(
423
- () => (t || []).filter((o) => o && !tr(o)),
463
+ () => (t || []).filter(
464
+ /** @param {any} [field] @returns {any} */
465
+ (o) => o && !tr(o)
466
+ ),
424
467
  [t]
425
468
  ), $ = e.useMemo(
426
469
  () => Fe(n || []),
@@ -430,11 +473,17 @@ function Kt({
430
473
  [i, $]
431
474
  ), L = e.useMemo(() => {
432
475
  const o = /* @__PURE__ */ new Set(), A = [];
433
- return d.forEach((R) => {
434
- R && !o.has(R) && (o.add(R), A.push(R));
435
- }), T.forEach((R) => {
436
- R && R.field && !o.has(R.field) && (o.add(R.field), A.push(R.field));
437
- }), A;
476
+ return d.forEach(
477
+ /** @param {any} [field] @returns {any} */
478
+ (R) => {
479
+ R && !o.has(R) && (o.add(R), A.push(R));
480
+ }
481
+ ), T.forEach(
482
+ /** @param {any} [dimension] @returns {any} */
483
+ (R) => {
484
+ R && R.field && !o.has(R.field) && (o.add(R.field), A.push(R.field));
485
+ }
486
+ ), A;
438
487
  }, [T, d]), _ = e.useMemo(
439
488
  () => {
440
489
  const o = qe(a, d, "date");
@@ -480,16 +529,23 @@ function Kt({
480
529
  return window.addEventListener("keydown", o), () => window.removeEventListener("keydown", o);
481
530
  }, [i]);
482
531
  const W = e.useCallback((o, A) => {
483
- m((R) => {
484
- if (!R) return R;
485
- const B = [...R.rules || []];
486
- return B[o] = typeof A == "function" ? A(B[o]) : A, { ...R, rules: B };
487
- });
532
+ m(
533
+ /** @param {any} [current] @returns {any} */
534
+ (R) => {
535
+ if (!R) return R;
536
+ const B = [...R.rules || []];
537
+ return B[o] = typeof A == "function" ? A(B[o]) : A, { ...R, rules: B };
538
+ }
539
+ );
488
540
  }, []), O = e.useCallback((o, A, R) => {
489
- W(o, (B) => {
490
- const M = B.condition || { op: "AND", clauses: [] }, H = [...M.clauses || []];
491
- return H[A] = { ...H[A], ...R }, { ...B, condition: { ...M, clauses: H } };
492
- });
541
+ W(
542
+ o,
543
+ /** @param {any} [rule] @returns {any} */
544
+ (B) => {
545
+ const M = B.condition || { op: "AND", clauses: [] }, H = [...M.clauses || []];
546
+ return H[A] = { ...H[A], ...R }, { ...B, condition: { ...M, clauses: H } };
547
+ }
548
+ );
493
549
  }, [W]), k = e.useCallback(() => {
494
550
  const o = Fe([i])[0];
495
551
  if (!o || !o.name) {
@@ -504,20 +560,29 @@ function Kt({
504
560
  g && g("Choose the source field to group.", "warning");
505
561
  return;
506
562
  }
507
- const A = sr(i), R = Yt(o.name);
508
- if ($.some((M) => M && M.field !== A && Yt(M.name) === R)) {
563
+ const A = sr(i), R = Zt(o.name);
564
+ if ($.some(
565
+ /** @param {any} [dimension] @returns {any} */
566
+ (M) => M && M.field !== A && Zt(M.name) === R
567
+ )) {
509
568
  g && g(`A category named "${o.name}" already exists.`, "warning");
510
569
  return;
511
570
  }
512
571
  if (o.kind === "category") {
513
572
  const M = new Set(L);
514
- if (Zt(o).find((x) => !M.has(x))) {
573
+ if (Yt(o).find(
574
+ /** @param {any} [field] @returns {any} */
575
+ (x) => !M.has(x)
576
+ )) {
515
577
  g && g("A category can only use base fields or categories defined before it.", "warning");
516
578
  return;
517
579
  }
518
- const K = Zt(o);
580
+ const K = Yt(o);
519
581
  if (sn(y, K)) {
520
- const x = cn(y, o).find((F) => F.count === 0);
582
+ const x = cn(y, o).find(
583
+ /** @param {any} [summary] @returns {any} */
584
+ (F) => F.count === 0
585
+ );
521
586
  if (x) {
522
587
  g && g(`"${x.label}" does not match any current row. Adjust the condition before applying.`, "warning");
523
588
  return;
@@ -538,10 +603,22 @@ function Kt({
538
603
  return;
539
604
  }
540
605
  }
541
- s((M) => [...Fe(M || []).filter((x) => x.id !== o.id && x.field !== o.field && x.field !== A), o]), m(null), g && g(`Applied ${o.name}.`, "success");
606
+ s(
607
+ /** @param {any} [previous] @returns {any} */
608
+ (M) => [...Fe(M || []).filter(
609
+ /** @param {any} [dimension] @returns {any} */
610
+ (x) => x.id !== o.id && x.field !== o.field && x.field !== A
611
+ ), o]
612
+ ), m(null), g && g(`Applied ${o.name}.`, "success");
542
613
  }, [L, _, i, $, D, s, g, y]), P = e.useCallback((o) => {
543
614
  const A = Fe([o])[0];
544
- A && (s((R) => Fe(R || []).filter((B) => B.field !== A.field)), typeof E == "function" && E(A.field), i && i.field === A.field && m(null), g && g(`Removed ${A.name}.`, "success"));
615
+ A && (s(
616
+ /** @param {any} [previous] @returns {any} */
617
+ (R) => Fe(R || []).filter(
618
+ /** @param {any} [item] @returns {any} */
619
+ (B) => B.field !== A.field
620
+ )
621
+ ), typeof E == "function" && E(A.field), i && i.field === A.field && m(null), g && g(`Removed ${A.name}.`, "success"));
545
622
  }, [i, E, s, g]);
546
623
  return /* @__PURE__ */ e.createElement("div", { style: {
547
624
  border: `1px solid ${l.border}`,
@@ -582,28 +659,31 @@ function Kt({
582
659
  },
583
660
  /* @__PURE__ */ e.createElement(z.NumberFormat, null),
584
661
  " Number Bins"
585
- )), $.length > 0 && /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "6px" } }, $.map((o) => {
586
- const A = o.kind || "category", R = A === "date_group" ? `${u(o.sourceField)} by ${o.granularity}` : A === "number_group" ? `${u(o.sourceField)} every ${o.binSize}` : `${o.rules.length} rule${o.rules.length === 1 ? "" : "s"} | fallback: ${o.fallbackLabel}`;
587
- return /* @__PURE__ */ e.createElement(
588
- "div",
589
- {
590
- key: o.field,
591
- style: {
592
- border: `1px solid ${l.border}`,
593
- background: l.background,
594
- borderRadius: "10px",
595
- padding: "8px",
596
- display: "flex",
597
- alignItems: "center",
598
- gap: "8px"
599
- }
600
- },
601
- A === "number_group" ? /* @__PURE__ */ e.createElement(z.NumberFormat, null) : /* @__PURE__ */ e.createElement(z.Branch, null),
602
- /* @__PURE__ */ e.createElement("div", { style: { minWidth: 0, flex: 1 } }, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "12px", fontWeight: 800, color: l.text, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } }, o.name), /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", color: l.textSec } }, R)),
603
- /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => m(jt(d, o)), style: w() }, /* @__PURE__ */ e.createElement(z.Edit, null), " Edit"),
604
- /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => P(o), style: { ...w(), color: "#B91C1C" } }, /* @__PURE__ */ e.createElement(z.Delete, null))
605
- );
606
- })), i && /* @__PURE__ */ e.createElement(
662
+ )), $.length > 0 && /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "6px" } }, $.map(
663
+ /** @param {any} [dimension] @returns {any} */
664
+ (o) => {
665
+ const A = o.kind || "category", R = A === "date_group" ? `${u(o.sourceField)} by ${o.granularity}` : A === "number_group" ? `${u(o.sourceField)} every ${o.binSize}` : `${o.rules.length} rule${o.rules.length === 1 ? "" : "s"} | fallback: ${o.fallbackLabel}`;
666
+ return /* @__PURE__ */ e.createElement(
667
+ "div",
668
+ {
669
+ key: o.field,
670
+ style: {
671
+ border: `1px solid ${l.border}`,
672
+ background: l.background,
673
+ borderRadius: "10px",
674
+ padding: "8px",
675
+ display: "flex",
676
+ alignItems: "center",
677
+ gap: "8px"
678
+ }
679
+ },
680
+ A === "number_group" ? /* @__PURE__ */ e.createElement(z.NumberFormat, null) : /* @__PURE__ */ e.createElement(z.Branch, null),
681
+ /* @__PURE__ */ e.createElement("div", { style: { minWidth: 0, flex: 1 } }, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "12px", fontWeight: 800, color: l.text, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } }, o.name), /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", color: l.textSec } }, R)),
682
+ /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => m(jt(d, o)), style: w() }, /* @__PURE__ */ e.createElement(z.Edit, null), " Edit"),
683
+ /* @__PURE__ */ e.createElement("button", { type: "button", onClick: () => P(o), style: { ...w(), color: "#B91C1C" } }, /* @__PURE__ */ e.createElement(z.Delete, null))
684
+ );
685
+ }
686
+ )), i && /* @__PURE__ */ e.createElement(
607
687
  "div",
608
688
  {
609
689
  role: "presentation",
@@ -705,7 +785,10 @@ function Kt({
705
785
  }),
706
786
  style: h
707
787
  },
708
- _.map((o) => /* @__PURE__ */ e.createElement("option", { key: o, value: o }, u(o)))
788
+ _.map(
789
+ /** @param {any} [field] @returns {any} */
790
+ (o) => /* @__PURE__ */ e.createElement("option", { key: o, value: o }, u(o))
791
+ )
709
792
  )), /* @__PURE__ */ e.createElement("label", { style: { display: "flex", flexDirection: "column", gap: "4px", fontSize: "10px", fontWeight: 800, color: l.textSec, textTransform: "uppercase", letterSpacing: "0.4px" } }, "Date Part", /* @__PURE__ */ e.createElement(
710
793
  "select",
711
794
  {
@@ -713,7 +796,7 @@ function Kt({
713
796
  onChange: (o) => m({ ...i, granularity: o.target.value }),
714
797
  style: h
715
798
  },
716
- Array.from(Zr).map((o) => /* @__PURE__ */ e.createElement("option", { key: o, value: o }, fe(o)))
799
+ Array.from(Yr).map((o) => /* @__PURE__ */ e.createElement("option", { key: o, value: o }, fe(o)))
717
800
  )), /* @__PURE__ */ e.createElement("label", { style: { display: "flex", flexDirection: "column", gap: "4px", fontSize: "10px", fontWeight: 800, color: l.textSec, textTransform: "uppercase", letterSpacing: "0.4px" } }, "Fiscal Start", /* @__PURE__ */ e.createElement(
718
801
  "select",
719
802
  {
@@ -741,7 +824,10 @@ function Kt({
741
824
  }),
742
825
  style: h
743
826
  },
744
- D.map((o) => /* @__PURE__ */ e.createElement("option", { key: o, value: o }, u(o)))
827
+ D.map(
828
+ /** @param {any} [field] @returns {any} */
829
+ (o) => /* @__PURE__ */ e.createElement("option", { key: o, value: o }, u(o))
830
+ )
745
831
  )), /* @__PURE__ */ e.createElement("label", { style: { display: "flex", flexDirection: "column", gap: "4px", fontSize: "10px", fontWeight: 800, color: l.textSec, textTransform: "uppercase", letterSpacing: "0.4px" } }, "Bin Size", /* @__PURE__ */ e.createElement(
746
832
  "input",
747
833
  {
@@ -776,73 +862,103 @@ function Kt({
776
862
  onChange: (o) => m({ ...i, precision: o.target.value }),
777
863
  style: h
778
864
  }
779
- ))), (!i.kind || i.kind === "category") && (i.rules || []).map((o, A) => {
780
- const R = o.condition || { op: "AND", clauses: [] }, B = R.clauses || [];
781
- return /* @__PURE__ */ e.createElement("div", { key: o.id || A, style: {
782
- border: `1px solid ${l.border}`,
783
- borderRadius: "10px",
784
- padding: "8px",
785
- background: l.hover || "#F8FAFC",
786
- display: "flex",
787
- flexDirection: "column",
788
- gap: "8px"
789
- } }, /* @__PURE__ */ e.createElement("div", { style: { display: "grid", gridTemplateColumns: "1fr 78px 28px", gap: "8px", alignItems: "center" } }, /* @__PURE__ */ e.createElement(
790
- "input",
791
- {
792
- value: o.label || "",
793
- onChange: (M) => W(A, { ...o, label: M.target.value }),
794
- style: h,
795
- placeholder: "Category value"
796
- }
797
- ), /* @__PURE__ */ e.createElement(
798
- "select",
799
- {
800
- value: R.op || "AND",
801
- onChange: (M) => W(A, { ...o, condition: { ...R, op: M.target.value } }),
802
- style: h
803
- },
804
- /* @__PURE__ */ e.createElement("option", { value: "AND" }, "AND"),
805
- /* @__PURE__ */ e.createElement("option", { value: "OR" }, "OR")
806
- ), /* @__PURE__ */ e.createElement(
807
- "button",
808
- {
809
- type: "button",
810
- onClick: () => m({ ...i, rules: (i.rules || []).filter((M, H) => H !== A) }),
811
- style: { ...w(), padding: "6px", justifyContent: "center", color: "#B91C1C" },
812
- title: "Remove rule"
813
- },
814
- /* @__PURE__ */ e.createElement(z.Close, null)
815
- )), B.map((M, H) => {
816
- const K = tn.has(M.operator), x = Ut.has(M.operator);
817
- return /* @__PURE__ */ e.createElement("div", { key: `${o.id || A}:${H}`, style: { display: "grid", gridTemplateColumns: K ? "1fr 130px 28px" : "1fr 130px 1fr 28px", gap: "6px", alignItems: "center" } }, /* @__PURE__ */ e.createElement(
818
- "select",
865
+ ))), (!i.kind || i.kind === "category") && (i.rules || []).map(
866
+ /** @param {any} [rule] @param {any} [ruleIndex] @returns {any} */
867
+ (o, A) => {
868
+ const R = o.condition || { op: "AND", clauses: [] }, B = R.clauses || [];
869
+ return /* @__PURE__ */ e.createElement("div", { key: o.id || A, style: {
870
+ border: `1px solid ${l.border}`,
871
+ borderRadius: "10px",
872
+ padding: "8px",
873
+ background: l.hover || "#F8FAFC",
874
+ display: "flex",
875
+ flexDirection: "column",
876
+ gap: "8px"
877
+ } }, /* @__PURE__ */ e.createElement("div", { style: { display: "grid", gridTemplateColumns: "1fr 78px 28px", gap: "8px", alignItems: "center" } }, /* @__PURE__ */ e.createElement(
878
+ "input",
819
879
  {
820
- value: M.field || "",
821
- onChange: (F) => O(A, H, { field: F.target.value }),
822
- style: h
823
- },
824
- L.map((F) => /* @__PURE__ */ e.createElement("option", { key: F, value: F }, u(F)))
880
+ value: o.label || "",
881
+ onChange: (M) => W(A, { ...o, label: M.target.value }),
882
+ style: h,
883
+ placeholder: "Category value"
884
+ }
825
885
  ), /* @__PURE__ */ e.createElement(
826
886
  "select",
827
887
  {
828
- value: M.operator || "eq",
829
- onChange: (F) => {
830
- const v = F.target.value;
831
- O(A, H, {
832
- operator: v,
833
- values: Ut.has(v) ? M.values && M.values.length ? M.values : Vt(M.value) : M.values
834
- });
835
- },
888
+ value: R.op || "AND",
889
+ onChange: (M) => W(A, { ...o, condition: { ...R, op: M.target.value } }),
836
890
  style: h
837
891
  },
838
- en.map((F) => /* @__PURE__ */ e.createElement("option", { key: F.value, value: F.value }, F.label))
839
- ), !K && /* @__PURE__ */ e.createElement(
840
- "input",
892
+ /* @__PURE__ */ e.createElement("option", { value: "AND" }, "AND"),
893
+ /* @__PURE__ */ e.createElement("option", { value: "OR" }, "OR")
894
+ ), /* @__PURE__ */ e.createElement(
895
+ "button",
841
896
  {
842
- value: x ? (M.values || []).join(", ") : M.value || "",
843
- onChange: (F) => O(A, H, x ? { values: Vt(F.target.value), value: F.target.value } : { value: F.target.value }),
844
- style: h,
845
- placeholder: x ? "A, B, C" : "Value"
897
+ type: "button",
898
+ onClick: () => m({ ...i, rules: (i.rules || []).filter(
899
+ /** @param {any} [_] @param {any} [index] @returns {any} */
900
+ (M, H) => H !== A
901
+ ) }),
902
+ style: { ...w(), padding: "6px", justifyContent: "center", color: "#B91C1C" },
903
+ title: "Remove rule"
904
+ },
905
+ /* @__PURE__ */ e.createElement(z.Close, null)
906
+ )), B.map(
907
+ /** @param {any} [clause] @param {any} [clauseIndex] @returns {any} */
908
+ (M, H) => {
909
+ const K = tn.has(M.operator), x = Ut.has(M.operator);
910
+ return /* @__PURE__ */ e.createElement("div", { key: `${o.id || A}:${H}`, style: { display: "grid", gridTemplateColumns: K ? "1fr 130px 28px" : "1fr 130px 1fr 28px", gap: "6px", alignItems: "center" } }, /* @__PURE__ */ e.createElement(
911
+ "select",
912
+ {
913
+ value: M.field || "",
914
+ onChange: (F) => O(A, H, { field: F.target.value }),
915
+ style: h
916
+ },
917
+ L.map(
918
+ /** @param {any} [field] @returns {any} */
919
+ (F) => /* @__PURE__ */ e.createElement("option", { key: F, value: F }, u(F))
920
+ )
921
+ ), /* @__PURE__ */ e.createElement(
922
+ "select",
923
+ {
924
+ value: M.operator || "eq",
925
+ onChange: (F) => {
926
+ const v = F.target.value;
927
+ O(A, H, {
928
+ operator: v,
929
+ values: Ut.has(v) ? M.values && M.values.length ? M.values : Vt(M.value) : M.values
930
+ });
931
+ },
932
+ style: h
933
+ },
934
+ en.map((F) => /* @__PURE__ */ e.createElement("option", { key: F.value, value: F.value }, F.label))
935
+ ), !K && /* @__PURE__ */ e.createElement(
936
+ "input",
937
+ {
938
+ value: x ? (M.values || []).join(", ") : M.value || "",
939
+ onChange: (F) => O(A, H, x ? { values: Vt(F.target.value), value: F.target.value } : { value: F.target.value }),
940
+ style: h,
941
+ placeholder: x ? "A, B, C" : "Value"
942
+ }
943
+ ), /* @__PURE__ */ e.createElement(
944
+ "button",
945
+ {
946
+ type: "button",
947
+ onClick: () => W(A, {
948
+ ...o,
949
+ condition: {
950
+ ...R,
951
+ clauses: B.filter(
952
+ /** @param {any} [_] @param {any} [index] @returns {any} */
953
+ (F, v) => v !== H
954
+ )
955
+ }
956
+ }),
957
+ style: { ...w(), padding: "6px", justifyContent: "center", color: "#B91C1C" },
958
+ title: "Remove condition"
959
+ },
960
+ /* @__PURE__ */ e.createElement(z.Close, null)
961
+ ));
846
962
  }
847
963
  ), /* @__PURE__ */ e.createElement(
848
964
  "button",
@@ -852,30 +968,15 @@ function Kt({
852
968
  ...o,
853
969
  condition: {
854
970
  ...R,
855
- clauses: B.filter((F, v) => v !== H)
971
+ clauses: [...B, or(L)]
856
972
  }
857
973
  }),
858
- style: { ...w(), padding: "6px", justifyContent: "center", color: "#B91C1C" },
859
- title: "Remove condition"
974
+ style: { ...w(), alignSelf: "flex-start" }
860
975
  },
861
- /* @__PURE__ */ e.createElement(z.Close, null)
976
+ "+ Condition"
862
977
  ));
863
- }), /* @__PURE__ */ e.createElement(
864
- "button",
865
- {
866
- type: "button",
867
- onClick: () => W(A, {
868
- ...o,
869
- condition: {
870
- ...R,
871
- clauses: [...B, or(L)]
872
- }
873
- }),
874
- style: { ...w(), alignSelf: "flex-start" }
875
- },
876
- "+ Condition"
877
- ));
878
- }), (!i.kind || i.kind === "category") && /* @__PURE__ */ e.createElement(
978
+ }
979
+ ), (!i.kind || i.kind === "category") && /* @__PURE__ */ e.createElement(
879
980
  "button",
880
981
  {
881
982
  type: "button",
@@ -904,13 +1005,24 @@ function Gt(t, n = []) {
904
1005
  };
905
1006
  cr(s).forEach(g);
906
1007
  let u = s.replace(tt, " ");
907
- return (Array.isArray(n) ? n : Array.from(n || [])).map((d) => String(d || "").trim()).filter((d) => d && !lr.test(d)).sort((d, $) => $.length - d.length).forEach((d) => {
908
- const $ = new RegExp(`(^|[^A-Za-z0-9_])${ar(d)}(?=$|[^A-Za-z0-9_])`, "g");
909
- u = u.replace($, (i, m) => (g(d), `${m} `));
910
- }), u.replace(nr, (d, $) => {
911
- const i = u.slice($ + d.length).trimStart();
912
- return Qr.has(d) || qr.has(d) && i.startsWith("(") || g(d), d;
913
- }), a;
1008
+ return (Array.isArray(n) ? n : Array.from(n || [])).map((d) => String(d || "").trim()).filter((d) => d && !lr.test(d)).sort((d, $) => $.length - d.length).forEach(
1009
+ /** @param {any} [reference] @returns {any} */
1010
+ (d) => {
1011
+ const $ = new RegExp(`(^|[^A-Za-z0-9_])${ar(d)}(?=$|[^A-Za-z0-9_])`, "g");
1012
+ u = u.replace(
1013
+ $,
1014
+ /** @param {any} [match] @param {any} [prefix] @returns {any} */
1015
+ (i, m) => (g(d), `${m} `)
1016
+ );
1017
+ }
1018
+ ), u.replace(
1019
+ nr,
1020
+ /** @param {any} [token] @param {any} [offset] @returns {any} */
1021
+ (d, $) => {
1022
+ const i = u.slice($ + d.length).trimStart();
1023
+ return Qr.has(d) || qr.has(d) && i.startsWith("(") || g(d), d;
1024
+ }
1025
+ ), a;
914
1026
  }
915
1027
  function le(t) {
916
1028
  const n = String(t || "").trim();
@@ -939,10 +1051,13 @@ function fn(t, n, s) {
939
1051
  }), u;
940
1052
  }
941
1053
  function yt(t, n, s) {
942
- t((a) => {
943
- const l = [...a];
944
- return l[n] ? (l[n] = s(l[n]), l) : a;
945
- });
1054
+ t(
1055
+ /** @param {any} [prev] @returns {any} */
1056
+ (a) => {
1057
+ const l = [...a];
1058
+ return l[n] ? (l[n] = s(l[n]), l) : a;
1059
+ }
1060
+ );
946
1061
  }
947
1062
  function Nt(t) {
948
1063
  return !t || typeof t.closest != "function" ? !1 : !!t.closest('button, input, select, textarea, [contenteditable="true"]');
@@ -1034,7 +1149,10 @@ function yn(t, n, s = null, a = null, l = "measures", g = [], u = []) {
1034
1149
  return { tone: "warning", text: "Parentheses are unbalanced." };
1035
1150
  if (d) {
1036
1151
  const k = Array.isArray(g) ? g : [], P = new Set(
1037
- k.map((B) => B && B.id).filter(Boolean)
1152
+ k.map(
1153
+ /** @param {any} [option] @returns {any} */
1154
+ (B) => B && B.id
1155
+ ).filter(Boolean)
1038
1156
  ), o = cr(E);
1039
1157
  if (o.length === 0)
1040
1158
  return {
@@ -1048,7 +1166,10 @@ function yn(t, n, s = null, a = null, l = "measures", g = [], u = []) {
1048
1166
  text: `Rendered columns must use brackets: ${R.join(", ")}`
1049
1167
  };
1050
1168
  if (P.size > 0) {
1051
- const B = o.filter((M) => !P.has(M));
1169
+ const B = o.filter(
1170
+ /** @param {any} [columnId] @returns {any} */
1171
+ (M) => !P.has(M)
1172
+ );
1052
1173
  if (B.length > 0)
1053
1174
  return {
1054
1175
  tone: "warning",
@@ -1069,23 +1190,47 @@ function yn(t, n, s = null, a = null, l = "measures", g = [], u = []) {
1069
1190
  tone: "warning",
1070
1191
  text: "Add at least one value or formula reference before creating formulas."
1071
1192
  };
1072
- const m = i.filter((k) => k.agg === "formula"), T = /* @__PURE__ */ new Map();
1073
- m.forEach((k) => {
1074
- const P = k.field === s ? ve(a || N(k), k.field) : N(k);
1075
- P && (T.set(P, P), T.set(P.toLowerCase(), P));
1076
- });
1077
- const L = i.filter((k) => k.agg !== "formula").map((k) => k.field).filter(Boolean), _ = new Set(L), D = /* @__PURE__ */ new Set([...L, ...m.map((k) => k.field === s ? ve(a || N(k), k.field) : N(k)).filter(Boolean), ...Array.isArray(u) ? u : []]), y = Array.from(D), h = Gt(E, y), w = h.map((k) => T.get(k) || T.get(k.toLowerCase()) || k), W = w.filter((k) => !D.has(k) && !_.has(k));
1193
+ const m = i.filter(
1194
+ /** @param {any} [config] @returns {any} */
1195
+ (k) => k.agg === "formula"
1196
+ ), T = /* @__PURE__ */ new Map();
1197
+ m.forEach(
1198
+ /** @param {any} [config] @returns {any} */
1199
+ (k) => {
1200
+ const P = k.field === s ? ve(a || N(k), k.field) : N(k);
1201
+ P && (T.set(P, P), T.set(P.toLowerCase(), P));
1202
+ }
1203
+ );
1204
+ const L = i.filter(
1205
+ /** @param {any} [config] @returns {any} */
1206
+ (k) => k.agg !== "formula"
1207
+ ).map(
1208
+ /** @param {any} [config] @returns {any} */
1209
+ (k) => k.field
1210
+ ).filter(Boolean), _ = new Set(L), D = /* @__PURE__ */ new Set([...L, ...m.map(
1211
+ /** @param {any} [config] @returns {any} */
1212
+ (k) => k.field === s ? ve(a || N(k), k.field) : N(k)
1213
+ ).filter(Boolean), ...Array.isArray(u) ? u : []]), y = Array.from(D), h = Gt(E, y), w = h.map(
1214
+ /** @param {any} [token] @returns {any} */
1215
+ (k) => T.get(k) || T.get(k.toLowerCase()) || k
1216
+ ), W = w.filter(
1217
+ /** @param {any} [token] @returns {any} */
1218
+ (k) => !D.has(k) && !_.has(k)
1219
+ );
1078
1220
  if (W.length > 0)
1079
1221
  return {
1080
1222
  tone: "warning",
1081
1223
  text: `Unknown fields: ${W.join(", ")}`
1082
1224
  };
1083
1225
  const O = s ? ve(a || s, s) : null;
1084
- if (s && O && i.some((P) => {
1085
- if (!P || P.field === s) return !1;
1086
- const o = P.agg === "formula" ? N(P) : P.field;
1087
- return String(o || "").toLowerCase() === O.toLowerCase();
1088
- }))
1226
+ if (s && O && i.some(
1227
+ /** @param {any} [config] @returns {any} */
1228
+ (P) => {
1229
+ if (!P || P.field === s) return !1;
1230
+ const o = P.agg === "formula" ? N(P) : P.field;
1231
+ return String(o || "").toLowerCase() === O.toLowerCase();
1232
+ }
1233
+ ))
1089
1234
  return {
1090
1235
  tone: "warning",
1091
1236
  text: `Reference key "${O}" is already in use.`
@@ -1097,10 +1242,22 @@ function yn(t, n, s = null, a = null, l = "measures", g = [], u = []) {
1097
1242
  };
1098
1243
  if (s && O) {
1099
1244
  const k = {};
1100
- m.forEach((R) => {
1101
- const B = R.field === s ? O : N(R), M = R.field === s ? E : String(R.formula || ""), H = Gt(M, y).map((K) => T.get(K) || T.get(K.toLowerCase()) || K).filter((K) => K !== B && m.some((x) => N(x) === K || x.field === s && O === K));
1102
- k[B] = H;
1103
- });
1245
+ m.forEach(
1246
+ /** @param {any} [config] @returns {any} */
1247
+ (R) => {
1248
+ const B = R.field === s ? O : N(R), M = R.field === s ? E : String(R.formula || ""), H = Gt(M, y).map(
1249
+ /** @param {any} [token] @returns {any} */
1250
+ (K) => T.get(K) || T.get(K.toLowerCase()) || K
1251
+ ).filter(
1252
+ /** @param {any} [token] @returns {any} */
1253
+ (K) => K !== B && m.some(
1254
+ /** @param {any} [candidate] @returns {any} */
1255
+ (x) => N(x) === K || x.field === s && O === K
1256
+ )
1257
+ );
1258
+ k[B] = H;
1259
+ }
1260
+ );
1104
1261
  const P = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(), A = (R) => {
1105
1262
  if (P.has(R)) return !0;
1106
1263
  if (o.has(R)) return !1;
@@ -1173,13 +1330,18 @@ function Sn({ item: t, idx: n, setValConfigs: s, theme: a, colFields: l = [], on
1173
1330
  const y = [];
1174
1331
  return E.canUsePivotSeries && y.push({ value: "pivot", label: "Linked pivot" }), E.canUseFieldSeries && y.push({ value: "field", label: "Series field" }), y;
1175
1332
  }, [E]), $ = vt(u.source || "pivot", E) ? u.source || "pivot" : E.defaultSource, i = e.useCallback((y) => {
1176
- yt(s, n, (h) => {
1177
- const w = bt(h.sparkline) || { ...Ee }, W = pr({ ...w, ...y }, E);
1178
- return W ? {
1179
- ...h,
1180
- sparkline: W
1181
- } : h;
1182
- });
1333
+ yt(
1334
+ s,
1335
+ n,
1336
+ /** @param {any} [current] @returns {any} */
1337
+ (h) => {
1338
+ const w = bt(h.sparkline) || { ...Ee }, W = pr({ ...w, ...y }, E);
1339
+ return W ? {
1340
+ ...h,
1341
+ sparkline: W
1342
+ } : h;
1343
+ }
1344
+ );
1183
1345
  }, [E, n, s]), m = e.useCallback((y) => y.stopPropagation(), []), T = [
1184
1346
  { value: "line", label: "Line" },
1185
1347
  { value: "area", label: "Area" },
@@ -1238,26 +1400,29 @@ function Sn({ item: t, idx: n, setValConfigs: s, theme: a, colFields: l = [], on
1238
1400
  },
1239
1401
  "×"
1240
1402
  )),
1241
- /* @__PURE__ */ e.createElement("div", { style: D }, /* @__PURE__ */ e.createElement("span", { style: _ }, "Data source"), d.length > 0 ? /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "4px" } }, d.map(({ value: y, label: h }) => /* @__PURE__ */ e.createElement(
1242
- "button",
1243
- {
1244
- key: y,
1245
- type: "button",
1246
- onClick: () => i({ source: y }),
1247
- style: {
1248
- flex: 1,
1249
- padding: "4px 0",
1250
- fontSize: "11px",
1251
- fontWeight: 600,
1252
- borderRadius: "6px",
1253
- cursor: "pointer",
1254
- border: `1px solid ${$ === y ? a.primary : a.border}`,
1255
- background: $ === y ? `${a.primary}18` : a.headerSubtleBg || a.background,
1256
- color: $ === y ? a.primary : a.textSec
1257
- }
1258
- },
1259
- h
1260
- ))), /* @__PURE__ */ e.createElement("div", { style: { marginTop: "5px", fontSize: "10px", color: a.textSec, lineHeight: 1.4 } }, $ === "pivot" ? "Trend values are collected across the pivot columns. Source value cells stay numeric unless hidden." : "Each cell already contains the full data series for its row.")) : /* @__PURE__ */ e.createElement(
1403
+ /* @__PURE__ */ e.createElement("div", { style: D }, /* @__PURE__ */ e.createElement("span", { style: _ }, "Data source"), d.length > 0 ? /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "4px" } }, d.map(
1404
+ /** @param {any} p0 @returns {any} */
1405
+ ({ value: y, label: h }) => /* @__PURE__ */ e.createElement(
1406
+ "button",
1407
+ {
1408
+ key: y,
1409
+ type: "button",
1410
+ onClick: () => i({ source: y }),
1411
+ style: {
1412
+ flex: 1,
1413
+ padding: "4px 0",
1414
+ fontSize: "11px",
1415
+ fontWeight: 600,
1416
+ borderRadius: "6px",
1417
+ cursor: "pointer",
1418
+ border: `1px solid ${$ === y ? a.primary : a.border}`,
1419
+ background: $ === y ? `${a.primary}18` : a.headerSubtleBg || a.background,
1420
+ color: $ === y ? a.primary : a.textSec
1421
+ }
1422
+ },
1423
+ h
1424
+ )
1425
+ )), /* @__PURE__ */ e.createElement("div", { style: { marginTop: "5px", fontSize: "10px", color: a.textSec, lineHeight: 1.4 } }, $ === "pivot" ? "Trend values are collected across the pivot columns. Source value cells stay numeric unless hidden." : "Each cell already contains the full data series for its row.")) : /* @__PURE__ */ e.createElement(
1261
1426
  "div",
1262
1427
  {
1263
1428
  "data-value-sparkline-unavailable": "true",
@@ -1426,20 +1591,30 @@ function dr({ item: t, idx: n, setValConfigs: s, theme: a, colFields: l = [], fi
1426
1591
  [l, t]
1427
1592
  ), L = !!$, _ = !!($ && vt($.source || "pivot", T)), D = e.useCallback((W) => W.stopPropagation(), []), y = e.useCallback(() => {
1428
1593
  let W = !1;
1429
- return yt(s, n, (O) => {
1430
- const k = pr(
1431
- O.sparkline || Ee,
1432
- T
1433
- );
1434
- return k ? (W = !0, { ...O, sparkline: k }) : O;
1435
- }), W;
1594
+ return yt(
1595
+ s,
1596
+ n,
1597
+ /** @param {any} [current] @returns {any} */
1598
+ (O) => {
1599
+ const k = pr(
1600
+ O.sparkline || Ee,
1601
+ T
1602
+ );
1603
+ return k ? (W = !0, { ...O, sparkline: k }) : O;
1604
+ }
1605
+ ), W;
1436
1606
  }, [T, n, s]), h = e.useCallback((W) => {
1437
1607
  if (W.stopPropagation(), L) {
1438
1608
  if (m) {
1439
1609
  u && u("This trend is defined by the app. You can adjust its settings, but not remove it here.", "info");
1440
1610
  return;
1441
1611
  }
1442
- yt(s, n, (O) => ({ ...O, sparkline: !1 })), u && u("Removed trend column.", "info");
1612
+ yt(
1613
+ s,
1614
+ n,
1615
+ /** @param {any} [current] @returns {any} */
1616
+ (O) => ({ ...O, sparkline: !1 })
1617
+ ), u && u("Removed trend column.", "info");
1443
1618
  } else T.canUseAny && y() ? (d(!0), u && u("Trend column enabled.", "success")) : u && u("Trend needs a column field, or a Series aggregation for field data.", "warning");
1444
1619
  }, [T.canUseAny, L, y, n, m, s, u]), w = e.useCallback((W) => {
1445
1620
  if (W.stopPropagation(), !T.canUseAny) {
@@ -1624,20 +1799,32 @@ function kn({ item: t, idx: n, valConfigs: s, setValConfigs: a, theme: l, onClos
1624
1799
  i.current.setSelectionRange(x, x);
1625
1800
  }, [t.field]);
1626
1801
  const _ = e.useMemo(
1627
- () => s.filter((x) => x && x.field),
1802
+ () => s.filter(
1803
+ /** @param {any} [config] @returns {any} */
1804
+ (x) => x && x.field
1805
+ ),
1628
1806
  [s]
1629
1807
  ), D = e.useMemo(
1630
- () => _.filter((x) => x.agg !== "formula"),
1808
+ () => _.filter(
1809
+ /** @param {any} [config] @returns {any} */
1810
+ (x) => x.agg !== "formula"
1811
+ ),
1631
1812
  [_]
1632
1813
  ), y = e.useMemo(
1633
- () => _.filter((x) => x.agg === "formula" && x.field !== t.field),
1814
+ () => _.filter(
1815
+ /** @param {any} [config] @returns {any} */
1816
+ (x) => x.agg === "formula" && x.field !== t.field
1817
+ ),
1634
1818
  [t.field, _]
1635
1819
  ), h = e.useMemo(
1636
1820
  () => (Array.isArray(E) ? E : []).filter((x) => x && x.id && x.id !== t.field),
1637
1821
  [E, t.field]
1638
1822
  ), w = e.useMemo(
1639
1823
  () => {
1640
- const x = new Set(_.map((F) => F.field).filter(Boolean));
1824
+ const x = new Set(_.map(
1825
+ /** @param {any} [c] @returns {any} */
1826
+ (F) => F.field
1827
+ ).filter(Boolean));
1641
1828
  return (Array.isArray(d) ? d : []).filter((F) => !x.has(F));
1642
1829
  },
1643
1830
  [d, _]
@@ -1663,37 +1850,40 @@ function kn({ item: t, idx: n, valConfigs: s, setValConfigs: a, theme: l, onClos
1663
1850
  [h, m.formulaRef, m.formulaScope, t.field, D]
1664
1851
  ), o = m.label !== (t.label || "") || m.formula !== (t.formula || "") || m.formulaRef !== N(t) || m.formulaScope !== ze(t.formulaScope), A = e.useCallback(() => {
1665
1852
  const x = ve(m.formulaRef, t.field);
1666
- a((F) => {
1667
- const v = [...F], U = v[n];
1668
- if (!U) return F;
1669
- const Q = N(U);
1670
- let V = x;
1671
- const ee = new Set(
1672
- v.filter((Y, te) => Y && te !== n).map((Y) => Y.agg === "formula" ? N(Y) : Y.field).filter(Boolean).map((Y) => String(Y).toLowerCase())
1673
- );
1674
- if (ee.has(V.toLowerCase())) {
1675
- let Y = 2, te = `${V}${Y}`;
1676
- for (; ee.has(te.toLowerCase()); )
1677
- Y += 1, te = `${V}${Y}`;
1678
- V = te;
1679
- }
1680
- if (v[n] = {
1681
- ...U,
1682
- label: m.label,
1683
- formula: m.formula,
1684
- formulaRef: V,
1685
- formulaScope: m.formulaScope
1686
- }, Q && Q !== V)
1687
- for (let Y = 0; Y < v.length; Y += 1) {
1688
- if (Y === n) continue;
1689
- const te = v[Y];
1690
- !te || te.agg !== "formula" || !te.formula || (v[Y] = {
1691
- ...te,
1692
- formula: fn(te.formula, Q, V)
1693
- });
1853
+ a(
1854
+ /** @param {any} [prev] @returns {any} */
1855
+ (F) => {
1856
+ const v = [...F], U = v[n];
1857
+ if (!U) return F;
1858
+ const Q = N(U);
1859
+ let V = x;
1860
+ const ee = new Set(
1861
+ v.filter((Z, te) => Z && te !== n).map((Z) => Z.agg === "formula" ? N(Z) : Z.field).filter(Boolean).map((Z) => String(Z).toLowerCase())
1862
+ );
1863
+ if (ee.has(V.toLowerCase())) {
1864
+ let Z = 2, te = `${V}${Z}`;
1865
+ for (; ee.has(te.toLowerCase()); )
1866
+ Z += 1, te = `${V}${Z}`;
1867
+ V = te;
1694
1868
  }
1695
- return v;
1696
- });
1869
+ if (v[n] = {
1870
+ ...U,
1871
+ label: m.label,
1872
+ formula: m.formula,
1873
+ formulaRef: V,
1874
+ formulaScope: m.formulaScope
1875
+ }, Q && Q !== V)
1876
+ for (let Z = 0; Z < v.length; Z += 1) {
1877
+ if (Z === n) continue;
1878
+ const te = v[Z];
1879
+ !te || te.agg !== "formula" || !te.formula || (v[Z] = {
1880
+ ...te,
1881
+ formula: fn(te.formula, Q, V)
1882
+ });
1883
+ }
1884
+ return v;
1885
+ }
1886
+ );
1697
1887
  }, [m.formula, m.formulaRef, m.formulaScope, m.label, n, t.field, a]), R = e.useCallback(() => {
1698
1888
  T({
1699
1889
  label: t.label || "",
@@ -1705,7 +1895,10 @@ function kn({ item: t, idx: n, valConfigs: s, setValConfigs: a, theme: l, onClos
1705
1895
  const F = i.current;
1706
1896
  if (!F) return;
1707
1897
  const v = m.formula || "", U = F.selectionStart ?? v.length, Q = F.selectionEnd ?? v.length, V = `${v.slice(0, U)}${x}${v.slice(Q)}`;
1708
- T((Y) => ({ ...Y, formula: V }));
1898
+ T(
1899
+ /** @param {any} [prev] @returns {any} */
1900
+ (Z) => ({ ...Z, formula: V })
1901
+ );
1709
1902
  const ee = U + x.length;
1710
1903
  setTimeout(() => {
1711
1904
  i.current && (i.current.focus(), i.current.setSelectionRange(ee, ee));
@@ -1787,7 +1980,10 @@ function kn({ item: t, idx: n, valConfigs: s, setValConfigs: a, theme: l, onClos
1787
1980
  "input",
1788
1981
  {
1789
1982
  value: m.label,
1790
- onChange: (x) => T((F) => ({ ...F, label: x.target.value })),
1983
+ onChange: (x) => T(
1984
+ /** @param {any} [prev] @returns {any} */
1985
+ (F) => ({ ...F, label: x.target.value })
1986
+ ),
1791
1987
  placeholder: "Formula label",
1792
1988
  style: {
1793
1989
  border: `1px solid ${l.border}`,
@@ -1804,7 +2000,10 @@ function kn({ item: t, idx: n, valConfigs: s, setValConfigs: a, theme: l, onClos
1804
2000
  "input",
1805
2001
  {
1806
2002
  value: m.formulaRef,
1807
- onChange: (x) => T((F) => ({ ...F, formulaRef: ve(x.target.value, t.field) })),
2003
+ onChange: (x) => T(
2004
+ /** @param {any} [prev] @returns {any} */
2005
+ (F) => ({ ...F, formulaRef: ve(x.target.value, t.field) })
2006
+ ),
1808
2007
  placeholder: "formula1",
1809
2008
  style: {
1810
2009
  border: `1px solid ${l.border}`,
@@ -1823,11 +2022,14 @@ function kn({ item: t, idx: n, valConfigs: s, setValConfigs: a, theme: l, onClos
1823
2022
  value: m.formulaScope,
1824
2023
  onChange: (x) => {
1825
2024
  const F = ze(x.target.value);
1826
- T((v) => ({
1827
- ...v,
1828
- formulaScope: F,
1829
- formula: v.formula || (F === "columns" ? Xt(h) : Et(D))
1830
- }));
2025
+ T(
2026
+ /** @param {any} [prev] @returns {any} */
2027
+ (v) => ({
2028
+ ...v,
2029
+ formulaScope: F,
2030
+ formula: v.formula || (F === "columns" ? Xt(h) : Et(D))
2031
+ })
2032
+ );
1831
2033
  },
1832
2034
  style: {
1833
2035
  border: `1px solid ${l.border}`,
@@ -1847,7 +2049,10 @@ function kn({ item: t, idx: n, valConfigs: s, setValConfigs: a, theme: l, onClos
1847
2049
  {
1848
2050
  ref: i,
1849
2051
  value: m.formula,
1850
- onChange: (x) => T((F) => ({ ...F, formula: x.target.value })),
2052
+ onChange: (x) => T(
2053
+ /** @param {any} [prev] @returns {any} */
2054
+ (F) => ({ ...F, formula: x.target.value })
2055
+ ),
1851
2056
  placeholder: P,
1852
2057
  rows: 4,
1853
2058
  style: {
@@ -1875,16 +2080,22 @@ function kn({ item: t, idx: n, valConfigs: s, setValConfigs: a, theme: l, onClos
1875
2080
  fontSize: "10px",
1876
2081
  lineHeight: "14px"
1877
2082
  } }, W.text), /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", color: l.textSec } }, "Ctrl/Cmd + Enter applies")),
1878
- /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "8px", flexWrap: "wrap", marginBottom: "12px" } }, k.map((x) => /* @__PURE__ */ e.createElement(
1879
- "button",
1880
- {
1881
- key: x.label,
1882
- type: "button",
1883
- onClick: () => T((F) => ({ ...F, formula: x.value })),
1884
- style: H
1885
- },
1886
- x.label
1887
- )), ["+", "-", "*", "/", "(", ")", "* 100"].map((x) => /* @__PURE__ */ e.createElement(
2083
+ /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "8px", flexWrap: "wrap", marginBottom: "12px" } }, k.map(
2084
+ /** @param {any} [template] @returns {any} */
2085
+ (x) => /* @__PURE__ */ e.createElement(
2086
+ "button",
2087
+ {
2088
+ key: x.label,
2089
+ type: "button",
2090
+ onClick: () => T(
2091
+ /** @param {any} [prev] @returns {any} */
2092
+ (F) => ({ ...F, formula: x.value })
2093
+ ),
2094
+ style: H
2095
+ },
2096
+ x.label
2097
+ )
2098
+ ), ["+", "-", "*", "/", "(", ")", "* 100"].map((x) => /* @__PURE__ */ e.createElement(
1888
2099
  "button",
1889
2100
  {
1890
2101
  key: x,
@@ -1895,51 +2106,63 @@ function kn({ item: t, idx: n, valConfigs: s, setValConfigs: a, theme: l, onClos
1895
2106
  },
1896
2107
  x
1897
2108
  ))),
1898
- /* @__PURE__ */ e.createElement("div", { style: { display: "grid", gridTemplateColumns: "1fr", gap: "12px", marginBottom: "14px" } }, xe(m.formulaScope) ? /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", color: l.textSec, textTransform: "uppercase", letterSpacing: "0.5px", marginBottom: "6px" } }, "Rendered Columns"), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap" } }, h.map((x) => /* @__PURE__ */ e.createElement(
1899
- "button",
1900
- {
1901
- key: x.id,
1902
- type: "button",
1903
- onMouseDown: (F) => F.preventDefault(),
1904
- onClick: () => B(le(x.id)),
1905
- style: H,
1906
- title: `Insert ${x.id}`
1907
- },
1908
- x.label || x.id
1909
- )), h.length === 0 && /* @__PURE__ */ e.createElement("span", { style: { fontSize: "11px", color: l.textSec } }, "Render the pivot once, or type a bracketed column id directly."))) : /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", color: l.textSec, textTransform: "uppercase", letterSpacing: "0.5px", marginBottom: "6px" } }, "Measures"), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap" } }, D.map((x) => /* @__PURE__ */ e.createElement(
1910
- "button",
1911
- {
1912
- key: x.field,
1913
- type: "button",
1914
- onMouseDown: (F) => F.preventDefault(),
1915
- onClick: () => B(ye(x.field)),
1916
- style: H,
1917
- title: `Insert ${x.field}`
1918
- },
1919
- x.field
1920
- )))), !xe(m.formulaScope) && y.length > 0 && /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", color: l.textSec, textTransform: "uppercase", letterSpacing: "0.5px", marginBottom: "6px" } }, "Formula References"), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap" } }, y.map((x) => /* @__PURE__ */ e.createElement(
1921
- "button",
1922
- {
1923
- key: x.field,
1924
- type: "button",
1925
- onMouseDown: (F) => F.preventDefault(),
1926
- onClick: () => B(ye(N(x))),
1927
- style: H,
1928
- title: `${N(x)}${x.label ? ` (${x.label})` : ""}`
1929
- },
1930
- N(x)
1931
- )))), !xe(m.formulaScope) && w.length > 0 && /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", color: l.textSec, textTransform: "uppercase", letterSpacing: "0.5px", marginBottom: "6px" } }, "Data Fields (auto-aggregated as sum)"), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap" } }, w.map((x) => /* @__PURE__ */ e.createElement(
1932
- "button",
1933
- {
1934
- key: x,
1935
- type: "button",
1936
- onMouseDown: (F) => F.preventDefault(),
1937
- onClick: () => B(ye(x)),
1938
- style: { ...H, borderColor: `${l.primary}66`, color: l.primary, background: `${l.primary}0d` },
1939
- title: `Insert: ${x}`
1940
- },
1941
- fe(x)
1942
- ))))),
2109
+ /* @__PURE__ */ e.createElement("div", { style: { display: "grid", gridTemplateColumns: "1fr", gap: "12px", marginBottom: "14px" } }, xe(m.formulaScope) ? /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", color: l.textSec, textTransform: "uppercase", letterSpacing: "0.5px", marginBottom: "6px" } }, "Rendered Columns"), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap" } }, h.map(
2110
+ /** @param {any} [column] @returns {any} */
2111
+ (x) => /* @__PURE__ */ e.createElement(
2112
+ "button",
2113
+ {
2114
+ key: x.id,
2115
+ type: "button",
2116
+ onMouseDown: (F) => F.preventDefault(),
2117
+ onClick: () => B(le(x.id)),
2118
+ style: H,
2119
+ title: `Insert ${x.id}`
2120
+ },
2121
+ x.label || x.id
2122
+ )
2123
+ ), h.length === 0 && /* @__PURE__ */ e.createElement("span", { style: { fontSize: "11px", color: l.textSec } }, "Render the pivot once, or type a bracketed column id directly."))) : /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", color: l.textSec, textTransform: "uppercase", letterSpacing: "0.5px", marginBottom: "6px" } }, "Measures"), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap" } }, D.map(
2124
+ /** @param {any} [config] @returns {any} */
2125
+ (x) => /* @__PURE__ */ e.createElement(
2126
+ "button",
2127
+ {
2128
+ key: x.field,
2129
+ type: "button",
2130
+ onMouseDown: (F) => F.preventDefault(),
2131
+ onClick: () => B(ye(x.field)),
2132
+ style: H,
2133
+ title: `Insert ${x.field}`
2134
+ },
2135
+ x.field
2136
+ )
2137
+ ))), !xe(m.formulaScope) && y.length > 0 && /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", color: l.textSec, textTransform: "uppercase", letterSpacing: "0.5px", marginBottom: "6px" } }, "Formula References"), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap" } }, y.map(
2138
+ /** @param {any} [config] @returns {any} */
2139
+ (x) => /* @__PURE__ */ e.createElement(
2140
+ "button",
2141
+ {
2142
+ key: x.field,
2143
+ type: "button",
2144
+ onMouseDown: (F) => F.preventDefault(),
2145
+ onClick: () => B(ye(N(x))),
2146
+ style: H,
2147
+ title: `${N(x)}${x.label ? ` (${x.label})` : ""}`
2148
+ },
2149
+ N(x)
2150
+ )
2151
+ ))), !xe(m.formulaScope) && w.length > 0 && /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", color: l.textSec, textTransform: "uppercase", letterSpacing: "0.5px", marginBottom: "6px" } }, "Data Fields (auto-aggregated as sum)"), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap" } }, w.map(
2152
+ /** @param {any} [f] @returns {any} */
2153
+ (x) => /* @__PURE__ */ e.createElement(
2154
+ "button",
2155
+ {
2156
+ key: x,
2157
+ type: "button",
2158
+ onMouseDown: (F) => F.preventDefault(),
2159
+ onClick: () => B(ye(x)),
2160
+ style: { ...H, borderColor: `${l.primary}66`, color: l.primary, background: `${l.primary}0d` },
2161
+ title: `Insert: ${x}`
2162
+ },
2163
+ fe(x)
2164
+ )
2165
+ )))),
1943
2166
  /* @__PURE__ */ e.createElement("div", { style: { display: "flex", justifyContent: "space-between", gap: "8px", flexWrap: "wrap" } }, /* @__PURE__ */ e.createElement(
1944
2167
  "button",
1945
2168
  {
@@ -2147,10 +2370,13 @@ function qt({
2147
2370
  }
2148
2371
  function Qt({ measureAxis: t, setMeasureAxis: n, theme: s, valueSelectStyle: a, regularValueCount: l }) {
2149
2372
  const g = e.useMemo(() => Pe(t), [t]), u = e.useCallback((d) => {
2150
- typeof n == "function" && n(($) => ({
2151
- ...Pe($),
2152
- ...typeof d == "function" ? d(Pe($)) : d
2153
- }));
2373
+ typeof n == "function" && n(
2374
+ /** @param {any} [previous] @returns {any} */
2375
+ ($) => ({
2376
+ ...Pe($),
2377
+ ...typeof d == "function" ? d(Pe($)) : d
2378
+ })
2379
+ );
2154
2380
  }, [n]), E = {
2155
2381
  ...a,
2156
2382
  width: "112px",
@@ -2209,631 +2435,556 @@ function Qt({ measureAxis: t, setMeasureAxis: n, theme: s, valueSelectStyle: a,
2209
2435
  }
2210
2436
  ), "Zero")), /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", color: s.textSec } }, l, " selected"));
2211
2437
  }
2212
- const Fn = e.memo(function({
2213
- sidebarTab: n,
2214
- setSidebarTab: s,
2215
- rowFields: a,
2216
- setRowFields: l,
2217
- colFields: g,
2218
- setColFields: u,
2219
- valConfigs: E,
2220
- setValConfigs: d,
2221
- measureAxis: $ = {},
2222
- setMeasureAxis: i = null,
2223
- columnVisibility: m,
2224
- setColumnVisibility: T,
2225
- columnPinning: L,
2226
- setColumnPinning: _,
2227
- availableFields: D,
2228
- table: y,
2229
- pinningPresets: h,
2230
- showNotification: w,
2231
- filterAnchorEl: W,
2232
- setFilterAnchorEl: O,
2233
- colSearch: k,
2234
- setColSearch: P,
2235
- colTypeFilter: o,
2236
- setColTypeFilter: A,
2237
- selectedCols: R,
2238
- setSelectedCols: B,
2239
- dropLine: M,
2240
- onDragStart: H,
2241
- onDragOver: K,
2242
- onDrop: x,
2243
- onDragEnd: F,
2244
- onKeyboardFieldDrop: v,
2245
- handleHeaderFilter: U,
2246
- handleFilterClick: Q,
2247
- requestFilterOptions: V,
2248
- handleExpandAllRows: ee,
2249
- handlePinColumn: Y,
2250
- toggleAllColumnsPinned: te,
2251
- activeFilterCol: Cn,
2252
- closeFilterPopover: wn,
2253
- filterOptions: Me,
2254
- filterOptionMeta: Oe = {},
2255
- clientFilterOptionMap: He = {},
2256
- data: Se,
2257
- sidebarWidth: rt,
2258
- setSidebarWidth: St,
2259
- fieldPanelSizes: Ue,
2260
- setFieldPanelSizes: nt,
2261
- fixedSparklineValueKeys: lt = [],
2262
- sparklineFields: Rn = null,
2263
- displayedColumnOptions: fr = [],
2264
- reportEditorSelection: gr = null,
2265
- showReportConfigColumn: mr = !0,
2266
- setShowReportConfigColumn: xr = null,
2267
- formulaErrors: he = {},
2268
- serverSide: je = !1
2269
- }) {
2270
- Or("SidebarPanel");
2271
- const { theme: c, styles: Z } = Hr(), {
2272
- filters: ae,
2273
- setFilters: at,
2274
- pivotMode: yr,
2275
- reportDef: br,
2276
- setReportDef: Er,
2277
- savedReports: vr,
2278
- setSavedReports: Sr,
2279
- activeReportId: hr,
2280
- setActiveReportId: kr,
2281
- customDimensions: _e,
2282
- setCustomDimensions: ht
2283
- } = Ur(), [Ve, kt] = e.useState({ columnId: null, anchorEl: null }), [ke, Ce] = e.useState(null), [se, ge] = e.useState(null), [we, Cr] = e.useState("report"), Ye = e.useRef(null), [wr, Ze] = e.useState(null), pe = e.useRef(null), Ct = e.useRef(0), Ke = e.useRef(null), ce = e.useRef(null), [G, ot] = e.useState(null), [it, wt] = e.useState(""), st = e.useMemo(
2284
- () => new Set(Array.isArray(lt) ? lt : []),
2285
- [lt]
2286
- ), X = e.useCallback(
2287
- (r) => jr(r, _e),
2288
- [_e]
2289
- ), Rt = e.useMemo(
2290
- () => Pe($),
2291
- [$]
2292
- ), de = Rt.labelField || "Measure Name", Re = e.useMemo(
2293
- () => (D || []).filter((r) => r),
2294
- [D]
2295
- ), J = e.useMemo(
2296
- () => Re.filter((r) => r && !tr(r)),
2297
- [Re]
2298
- ), Te = Array.isArray(E) && E.length > 0 && de && !Re.includes(de), De = e.useMemo(
2299
- () => Te ? [de, ...Re] : Re,
2300
- [Re, de, Te]
2301
- ), We = it.trim().toLowerCase(), Ge = e.useCallback((r) => {
2302
- if (!We) return !0;
2303
- const f = Te && r === de ? "measure name measure names metric metrics value values" : "";
2304
- return String(r || "").toLowerCase().includes(We) || String(X(r) || "").toLowerCase().includes(We) || f.includes(We);
2305
- }, [X, de, We, Te]), ct = e.useMemo(
2306
- () => De.length > 8 ? De.filter(Ge) : De,
2307
- [De, Ge]
2308
- ), ut = e.useMemo(
2309
- () => J.length > 8 ? J.filter(Ge) : J,
2310
- [J, Ge]
2311
- ), Dt = e.useCallback((r) => {
2312
- l((f) => (f || []).filter((p) => p !== r)), u((f) => (f || []).filter((p) => p !== r)), d((f) => (f || []).filter((p) => !(p && p.field === r))), at((f) => {
2313
- if (!f || !Object.prototype.hasOwnProperty.call(f, r)) return f;
2314
- const p = { ...f };
2315
- return delete p[r], p;
2316
- });
2317
- }, [u, at, l, d]), Rr = e.useCallback((r) => {
2318
- const f = pe.current;
2319
- if (!f) return;
2320
- const p = 60, b = 12, S = f.getBoundingClientRect(), I = r.clientY, q = I - S.top, C = S.bottom - I;
2321
- let j = 0;
2322
- if (q < p && q >= 0 ? j = -1 : C < p && C >= 0 && (j = 1), j === 0) {
2323
- ce.current && (cancelAnimationFrame(ce.current), ce.current = null);
2324
- return;
2325
- }
2326
- const ie = () => {
2327
- pe.current && (pe.current.scrollTop += j * b, ce.current = requestAnimationFrame(ie));
2328
- };
2329
- ce.current || (ce.current = requestAnimationFrame(ie));
2330
- }, []), At = e.useCallback(() => {
2331
- ce.current && (cancelAnimationFrame(ce.current), ce.current = null);
2332
- }, []), oe = e.useMemo(
2333
- () => E.filter((r) => r && r.agg === "formula"),
2334
- [E]
2335
- ), me = e.useMemo(
2336
- () => oe.length,
2337
- [oe]
2338
- ), Ae = e.useMemo(
2339
- () => E.filter((r) => r && r.agg !== "formula").length,
2340
- [E]
2341
- ), Dr = e.useMemo(() => [
2342
- { id: "rows", label: "Rows", icon: /* @__PURE__ */ e.createElement(z.List, null) },
2343
- { id: "cols", label: "Columns", icon: /* @__PURE__ */ e.createElement(z.Columns, null) },
2344
- { id: "vals", label: "Values", icon: /* @__PURE__ */ e.createElement(z.Sigma, null) },
2345
- { id: "filter", label: "Filters", icon: /* @__PURE__ */ e.createElement(z.Filter, null) }
2346
- ], []), Be = e.useMemo(() => ({
2347
- filter: Object.keys(ae || {}).filter((r) => r !== "global"),
2348
- rows: a || [],
2349
- cols: g || [],
2350
- vals: E || []
2351
- }), [g, ae, a, E]), Ne = e.useCallback(() => {
2352
- G && w && w("Keyboard move cancelled.", "info"), ot(null);
2353
- }, [G, w]), $t = e.useCallback((r, f, p, b) => {
2354
- if (typeof v != "function") return;
2355
- ot({ field: r, zone: f, idx: p, label: b }), w && w(`Picked up ${b}. Focus a target field or zone and press Enter.`, "info");
2356
- }, [v, w]), Xe = e.useCallback((r, f = null) => {
2357
- if (!G || typeof v != "function") return !1;
2358
- const p = Be[r] || [], b = Number(f), S = Number.isFinite(b) ? Math.max(0, Math.min(Math.floor(b), p.length)) : p.length, I = v({
2359
- field: G.field,
2360
- srcZone: G.zone,
2361
- srcIdx: G.idx,
2362
- targetZone: r,
2363
- targetIdx: S,
2364
- source: "layout:keyboard-drop"
2365
- });
2366
- return I !== !1 && (w && w(`Moved ${G.label}.`, "success"), ot(null)), I !== !1;
2367
- }, [G, v, w, Be]), Ft = e.useCallback((r, f, p, b, S) => {
2368
- if (!Nt(r.target)) {
2369
- if (r.key === "Escape") {
2370
- r.preventDefault(), r.stopPropagation(), Ne();
2371
- return;
2372
- }
2373
- r.key !== "Enter" && r.key !== " " || (r.preventDefault(), r.stopPropagation(), G ? Xe(p, b) : $t(f, p, b, S));
2374
- }
2375
- }, [Ne, Xe, G, $t]), Ar = e.useCallback((r, f) => {
2376
- if (!Nt(r.target)) {
2377
- if (r.key === "Escape") {
2378
- r.preventDefault(), r.stopPropagation(), Ne();
2438
+ const Fn = e.memo(
2439
+ /** @param {any} p0 @returns {any} */
2440
+ function({
2441
+ sidebarTab: n,
2442
+ setSidebarTab: s,
2443
+ rowFields: a,
2444
+ setRowFields: l,
2445
+ colFields: g,
2446
+ setColFields: u,
2447
+ valConfigs: E,
2448
+ setValConfigs: d,
2449
+ measureAxis: $ = {},
2450
+ setMeasureAxis: i = null,
2451
+ columnVisibility: m,
2452
+ setColumnVisibility: T,
2453
+ columnPinning: L,
2454
+ setColumnPinning: _,
2455
+ availableFields: D,
2456
+ table: y,
2457
+ pinningPresets: h,
2458
+ showNotification: w,
2459
+ filterAnchorEl: W,
2460
+ setFilterAnchorEl: O,
2461
+ colSearch: k,
2462
+ setColSearch: P,
2463
+ colTypeFilter: o,
2464
+ setColTypeFilter: A,
2465
+ selectedCols: R,
2466
+ setSelectedCols: B,
2467
+ dropLine: M,
2468
+ onDragStart: H,
2469
+ onDragOver: K,
2470
+ onDrop: x,
2471
+ onDragEnd: F,
2472
+ onKeyboardFieldDrop: v,
2473
+ handleHeaderFilter: U,
2474
+ handleFilterClick: Q,
2475
+ requestFilterOptions: V,
2476
+ handleExpandAllRows: ee,
2477
+ handlePinColumn: Z,
2478
+ toggleAllColumnsPinned: te,
2479
+ activeFilterCol: Cn,
2480
+ closeFilterPopover: wn,
2481
+ filterOptions: Me,
2482
+ filterOptionMeta: Oe = {},
2483
+ clientFilterOptionMap: He = {},
2484
+ data: Se,
2485
+ sidebarWidth: rt,
2486
+ setSidebarWidth: St,
2487
+ fieldPanelSizes: Ue,
2488
+ setFieldPanelSizes: nt,
2489
+ fixedSparklineValueKeys: lt = [],
2490
+ sparklineFields: Rn = null,
2491
+ displayedColumnOptions: fr = [],
2492
+ reportEditorSelection: gr = null,
2493
+ showReportConfigColumn: mr = !0,
2494
+ setShowReportConfigColumn: xr = null,
2495
+ formulaErrors: he = {},
2496
+ serverSide: je = !1
2497
+ }) {
2498
+ Or("SidebarPanel");
2499
+ const { theme: c, styles: Y } = Hr(), {
2500
+ filters: ae,
2501
+ setFilters: at,
2502
+ pivotMode: yr,
2503
+ reportDef: br,
2504
+ setReportDef: Er,
2505
+ savedReports: vr,
2506
+ setSavedReports: Sr,
2507
+ activeReportId: hr,
2508
+ setActiveReportId: kr,
2509
+ customDimensions: _e,
2510
+ setCustomDimensions: ht
2511
+ } = Ur(), [Ve, kt] = e.useState({ columnId: null, anchorEl: null }), [ke, Ce] = e.useState(null), [se, ge] = e.useState(null), [we, Cr] = e.useState("report"), Ze = e.useRef(null), [wr, Ye] = e.useState(null), pe = e.useRef(null), Ct = e.useRef(0), Ke = e.useRef(null), ce = e.useRef(null), [G, ot] = e.useState(null), [it, wt] = e.useState(""), st = e.useMemo(
2512
+ () => new Set(Array.isArray(lt) ? lt : []),
2513
+ [lt]
2514
+ ), X = e.useCallback(
2515
+ (r) => jr(r, _e),
2516
+ [_e]
2517
+ ), Rt = e.useMemo(
2518
+ () => Pe($),
2519
+ [$]
2520
+ ), de = Rt.labelField || "Measure Name", Re = e.useMemo(
2521
+ () => (D || []).filter(
2522
+ /** @param {any} [field] @returns {any} */
2523
+ (r) => r
2524
+ ),
2525
+ [D]
2526
+ ), J = e.useMemo(
2527
+ () => Re.filter(
2528
+ /** @param {any} [field] @returns {any} */
2529
+ (r) => r && !tr(r)
2530
+ ),
2531
+ [Re]
2532
+ ), Te = Array.isArray(E) && E.length > 0 && de && !Re.includes(de), De = e.useMemo(
2533
+ () => Te ? [de, ...Re] : Re,
2534
+ [Re, de, Te]
2535
+ ), We = it.trim().toLowerCase(), Ge = e.useCallback((r) => {
2536
+ if (!We) return !0;
2537
+ const f = Te && r === de ? "measure name measure names metric metrics value values" : "";
2538
+ return String(r || "").toLowerCase().includes(We) || String(X(r) || "").toLowerCase().includes(We) || f.includes(We);
2539
+ }, [X, de, We, Te]), ct = e.useMemo(
2540
+ () => De.length > 8 ? De.filter(Ge) : De,
2541
+ [De, Ge]
2542
+ ), ut = e.useMemo(
2543
+ () => J.length > 8 ? J.filter(Ge) : J,
2544
+ [J, Ge]
2545
+ ), Dt = e.useCallback((r) => {
2546
+ l(
2547
+ /** @param {any} [prev] @returns {any} */
2548
+ (f) => (f || []).filter(
2549
+ /** @param {any} [item] @returns {any} */
2550
+ (p) => p !== r
2551
+ )
2552
+ ), u(
2553
+ /** @param {any} [prev] @returns {any} */
2554
+ (f) => (f || []).filter(
2555
+ /** @param {any} [item] @returns {any} */
2556
+ (p) => p !== r
2557
+ )
2558
+ ), d(
2559
+ /** @param {any} [prev] @returns {any} */
2560
+ (f) => (f || []).filter(
2561
+ /** @param {any} [item] @returns {any} */
2562
+ (p) => !(p && p.field === r)
2563
+ )
2564
+ ), at(
2565
+ /** @param {any} [prev] @returns {any} */
2566
+ (f) => {
2567
+ if (!f || !Object.prototype.hasOwnProperty.call(f, r)) return f;
2568
+ const p = { ...f };
2569
+ return delete p[r], p;
2570
+ }
2571
+ );
2572
+ }, [u, at, l, d]), Rr = e.useCallback((r) => {
2573
+ const f = pe.current;
2574
+ if (!f) return;
2575
+ const p = 60, b = 12, S = f.getBoundingClientRect(), I = r.clientY, q = I - S.top, C = S.bottom - I;
2576
+ let j = 0;
2577
+ if (q < p && q >= 0 ? j = -1 : C < p && C >= 0 && (j = 1), j === 0) {
2578
+ ce.current && (cancelAnimationFrame(ce.current), ce.current = null);
2379
2579
  return;
2380
2580
  }
2381
- !G || r.key !== "Enter" && r.key !== " " || (r.preventDefault(), r.stopPropagation(), Xe(f, (Be[f] || []).length));
2382
- }
2383
- }, [Ne, Xe, G, Be]), $r = e.useCallback((r) => {
2384
- r.preventDefault();
2385
- const f = r.clientX, p = rt || 288;
2386
- Ke.current = { startX: f, startWidth: p };
2387
- const b = (I) => {
2388
- const q = I.clientX - Ke.current.startX, C = Math.max(200, Math.min(520, Ke.current.startWidth + q));
2389
- St(C);
2390
- }, S = () => {
2391
- Ke.current = null, window.removeEventListener("mousemove", b), window.removeEventListener("mouseup", S);
2392
- };
2393
- window.addEventListener("mousemove", b), window.addEventListener("mouseup", S);
2394
- }, [rt, St]), zt = e.useCallback((r, f) => {
2395
- typeof nt == "function" && nt((p) => {
2396
- const b = Vr(p, r, f), S = p && p[r] ? p[r] : null, I = b[r];
2397
- return S && S.width === I.width && S.height === I.height ? p : b;
2398
- });
2399
- }, [nt]), Mt = Z.dropZone && Z.dropZone.padding || "8px", _t = e.useMemo(() => {
2400
- const r = { ...Z.dropZone || {} };
2401
- return delete r.minHeight, delete r.maxHeight, delete r.overflowY, delete r.padding, delete r.border, delete r.boxShadow, r;
2402
- }, [Z.dropZone]), Tt = e.useCallback((r) => {
2403
- if (Me && Me[r]) return Me[r];
2404
- if (He && He[r]) return He[r];
2405
- if (!y || !y.getColumn) return [];
2406
- if (!y.getColumn(r)) return [];
2407
- const p = /* @__PURE__ */ new Set();
2408
- return (y.getCoreRowModel ? y.getCoreRowModel().rows : []).forEach((S) => {
2409
- const I = S.getValue(r);
2410
- I != null && I !== "" && p.add(I);
2411
- }), Array.from(p).sort((S, I) => String(S).localeCompare(String(I), void 0, { numeric: !0, sensitivity: "base" }));
2412
- }, [He, Me, y]), ue = e.useMemo(() => ({
2413
- border: `1px solid ${c.border}`,
2414
- background: c.headerSubtleBg || c.surfaceInset || c.background,
2415
- color: c.text,
2416
- cursor: "pointer",
2417
- borderRadius: c.radiusSm || "8px",
2418
- fontSize: "9px",
2419
- lineHeight: 1.2,
2420
- padding: "1px 4px",
2421
- minHeight: "20px",
2422
- outline: "none"
2423
- }), [c.background, c.border, c.headerSubtleBg, c.radiusSm, c.surfaceInset, c.text]), Wt = e.useCallback((r, f) => {
2424
- d((p) => {
2425
- const b = [...p], S = b[r];
2426
- if (!S) return p;
2427
- if (Ht(f) && !S.weightField) {
2428
- const I = Array.isArray(J) && J.length > 0 ? J.find((j) => j !== S.field) || J[0] : "", q = typeof window < "u" ? window.prompt(
2429
- `Weight field for weighted average of ${fe(S.field)}`,
2430
- S.weightField || I || ""
2431
- ) : S.weightField || I || "", C = typeof q == "string" ? q.trim() : "";
2432
- return C ? Array.isArray(J) && J.length > 0 && !J.includes(C) ? (w && w(`Unknown weight field: ${C}`, "warning"), p) : (b[r] = { ...S, agg: f, weightField: C }, b) : (w && w("Weighted average requires a weight field.", "warning"), p);
2581
+ const ie = () => {
2582
+ pe.current && (pe.current.scrollTop += j * b, ce.current = requestAnimationFrame(ie));
2583
+ };
2584
+ ce.current || (ce.current = requestAnimationFrame(ie));
2585
+ }, []), At = e.useCallback(() => {
2586
+ ce.current && (cancelAnimationFrame(ce.current), ce.current = null);
2587
+ }, []), oe = e.useMemo(
2588
+ () => E.filter(
2589
+ /** @param {any} [config] @returns {any} */
2590
+ (r) => r && r.agg === "formula"
2591
+ ),
2592
+ [E]
2593
+ ), me = e.useMemo(
2594
+ () => oe.length,
2595
+ [oe]
2596
+ ), Ae = e.useMemo(
2597
+ () => E.filter(
2598
+ /** @param {any} [config] @returns {any} */
2599
+ (r) => r && r.agg !== "formula"
2600
+ ).length,
2601
+ [E]
2602
+ ), Dr = e.useMemo(() => [
2603
+ { id: "rows", label: "Rows", icon: /* @__PURE__ */ e.createElement(z.List, null) },
2604
+ { id: "cols", label: "Columns", icon: /* @__PURE__ */ e.createElement(z.Columns, null) },
2605
+ { id: "vals", label: "Values", icon: /* @__PURE__ */ e.createElement(z.Sigma, null) },
2606
+ { id: "filter", label: "Filters", icon: /* @__PURE__ */ e.createElement(z.Filter, null) }
2607
+ ], []), Be = e.useMemo(() => ({
2608
+ filter: Object.keys(ae || {}).filter((r) => r !== "global"),
2609
+ rows: a || [],
2610
+ cols: g || [],
2611
+ vals: E || []
2612
+ }), [g, ae, a, E]), Ne = e.useCallback(() => {
2613
+ G && w && w("Keyboard move cancelled.", "info"), ot(null);
2614
+ }, [G, w]), $t = e.useCallback((r, f, p, b) => {
2615
+ if (typeof v != "function") return;
2616
+ ot({ field: r, zone: f, idx: p, label: b }), w && w(`Picked up ${b}. Focus a target field or zone and press Enter.`, "info");
2617
+ }, [v, w]), Xe = e.useCallback((r, f = null) => {
2618
+ if (!G || typeof v != "function") return !1;
2619
+ const p = Be[r] || [], b = Number(f), S = Number.isFinite(b) ? Math.max(0, Math.min(Math.floor(b), p.length)) : p.length, I = v({
2620
+ field: G.field,
2621
+ srcZone: G.zone,
2622
+ srcIdx: G.idx,
2623
+ targetZone: r,
2624
+ targetIdx: S,
2625
+ source: "layout:keyboard-drop"
2626
+ });
2627
+ return I !== !1 && (w && w(`Moved ${G.label}.`, "success"), ot(null)), I !== !1;
2628
+ }, [G, v, w, Be]), Ft = e.useCallback((r, f, p, b, S) => {
2629
+ if (!Nt(r.target)) {
2630
+ if (r.key === "Escape") {
2631
+ r.preventDefault(), r.stopPropagation(), Ne();
2632
+ return;
2633
+ }
2634
+ r.key !== "Enter" && r.key !== " " || (r.preventDefault(), r.stopPropagation(), G ? Xe(p, b) : $t(f, p, b, S));
2433
2635
  }
2434
- return b[r] = { ...S, agg: f }, b;
2435
- });
2436
- }, [J, d, w]), Fr = e.useCallback((r, f) => {
2437
- if (!f) {
2438
- w && w("Weighted average requires a weight field.", "warning");
2439
- return;
2440
- }
2441
- d((p) => {
2442
- const b = [...p], S = b[r];
2443
- return S ? (b[r] = { ...S, weightField: f }, b) : p;
2444
- });
2445
- }, [d, w]), zr = e.useCallback((r, f) => {
2446
- d((p) => {
2447
- const b = [...p], S = b[r];
2448
- return S ? (b[r] = {
2449
- ...S,
2450
- windowFn: f === "none" ? null : f
2451
- }, b) : p;
2452
- });
2453
- }, [d]), Bt = e.useCallback(() => {
2454
- const r = xn(E), f = E.filter((I) => I && I.agg !== "formula"), p = `Formula ${me + 1}`, b = Et(f), S = dn(p, E, r);
2455
- Ce(r), ge(r), d((I) => [
2456
- ...I,
2457
- {
2458
- field: r,
2459
- agg: "formula",
2460
- label: p,
2461
- formula: b,
2462
- formulaRef: S,
2463
- formulaScope: "measures"
2636
+ }, [Ne, Xe, G, $t]), Ar = e.useCallback((r, f) => {
2637
+ if (!Nt(r.target)) {
2638
+ if (r.key === "Escape") {
2639
+ r.preventDefault(), r.stopPropagation(), Ne();
2640
+ return;
2641
+ }
2642
+ !G || r.key !== "Enter" && r.key !== " " || (r.preventDefault(), r.stopPropagation(), Xe(f, (Be[f] || []).length));
2464
2643
  }
2465
- ]), w && (f.length === 0 ? w("Added a formula column. Add at least one regular value measure to reference in it.", "warning") : w(`Added ${p}.`, "success"));
2466
- }, [me, ge, d, Ce, w, E]), Mr = (r, f) => {
2467
- r.stopPropagation(), pe.current && (Ct.current = pe.current.scrollTop), kt((p) => p.columnId === f ? { columnId: null, anchorEl: null } : { columnId: f, anchorEl: r.currentTarget }), V && V(f);
2468
- }, _r = () => kt({ columnId: null, anchorEl: null });
2469
- e.useEffect(() => {
2470
- pe.current && Ve.columnId && (pe.current.scrollTop = Ct.current);
2471
- }, [Me, Ve.columnId]), e.useEffect(() => {
2472
- if (oe.length === 0) {
2473
- ke !== null && Ce(null), se !== null && ge(null);
2474
- return;
2475
- }
2476
- oe.some((f) => f.field === ke) || Ce(oe[oe.length - 1].field), se && !oe.some((f) => f.field === se) && ge(null);
2477
- }, [ke, oe, se]);
2478
- const pt = e.useMemo(
2479
- () => E.findIndex((r) => r && r.agg === "formula" && r.field === se),
2480
- [se, E]
2481
- ), dt = pt >= 0 ? E[pt] : null, It = e.useCallback((r) => {
2482
- Ce(r), ge(r);
2483
- }, []), Ie = e.useCallback((r) => {
2484
- const f = E[r] && E[r].agg === "formula" ? E[r].field : null;
2485
- if (d((p) => p.filter((b, S) => S !== r)), f && f === ke) {
2486
- const p = oe.find((b) => b.field !== f);
2487
- Ce(p ? p.field : null);
2488
- }
2489
- f && f === se && ge(null);
2490
- }, [ke, oe, se, d, E]), $e = yr === "report", Lt = Math.max(rt || 288, $e ? 380 : 0), Pt = (r, f) => {
2491
- if (r <= 8) return null;
2492
- const p = it.trim().length > 0;
2493
- return /* @__PURE__ */ e.createElement("div", { style: {
2494
- display: "flex",
2495
- alignItems: "center",
2496
- gap: "6px",
2497
- margin: "0 2px 8px",
2498
- padding: "5px 8px",
2644
+ }, [Ne, Xe, G, Be]), $r = e.useCallback((r) => {
2645
+ r.preventDefault();
2646
+ const f = r.clientX, p = rt || 288;
2647
+ Ke.current = { startX: f, startWidth: p };
2648
+ const b = (I) => {
2649
+ const q = I.clientX - Ke.current.startX, C = Math.max(200, Math.min(520, Ke.current.startWidth + q));
2650
+ St(C);
2651
+ }, S = () => {
2652
+ Ke.current = null, window.removeEventListener("mousemove", b), window.removeEventListener("mouseup", S);
2653
+ };
2654
+ window.addEventListener("mousemove", b), window.addEventListener("mouseup", S);
2655
+ }, [rt, St]), zt = e.useCallback((r, f) => {
2656
+ typeof nt == "function" && nt(
2657
+ /** @param {any} [prev] @returns {any} */
2658
+ (p) => {
2659
+ const b = Vr(p, r, f), S = p && p[r] ? p[r] : null, I = b[r];
2660
+ return S && S.width === I.width && S.height === I.height ? p : b;
2661
+ }
2662
+ );
2663
+ }, [nt]), Mt = Y.dropZone && Y.dropZone.padding || "8px", _t = e.useMemo(() => {
2664
+ const r = { ...Y.dropZone || {} };
2665
+ return delete r.minHeight, delete r.maxHeight, delete r.overflowY, delete r.padding, delete r.border, delete r.boxShadow, r;
2666
+ }, [Y.dropZone]), Tt = e.useCallback((r) => {
2667
+ if (Me && Me[r]) return Me[r];
2668
+ if (He && He[r]) return He[r];
2669
+ if (!y || !y.getColumn) return [];
2670
+ if (!y.getColumn(r)) return [];
2671
+ const p = /* @__PURE__ */ new Set();
2672
+ return (y.getCoreRowModel ? y.getCoreRowModel().rows : []).forEach(
2673
+ /** @param {any} [row] @returns {any} */
2674
+ (S) => {
2675
+ const I = S.getValue(r);
2676
+ I != null && I !== "" && p.add(I);
2677
+ }
2678
+ ), Array.from(p).sort((S, I) => String(S).localeCompare(String(I), void 0, { numeric: !0, sensitivity: "base" }));
2679
+ }, [He, Me, y]), ue = e.useMemo(() => ({
2499
2680
  border: `1px solid ${c.border}`,
2681
+ background: c.headerSubtleBg || c.surfaceInset || c.background,
2682
+ color: c.text,
2683
+ cursor: "pointer",
2500
2684
  borderRadius: c.radiusSm || "8px",
2501
- background: c.headerSubtleBg || c.surfaceInset || c.background
2502
- } }, /* @__PURE__ */ e.createElement(z.Search, { style: { flexShrink: 0, color: c.textSec } }), /* @__PURE__ */ e.createElement(
2503
- "input",
2504
- {
2505
- type: "search",
2506
- "aria-label": "Search available fields",
2507
- placeholder: `Search ${r} fields...`,
2508
- value: it,
2509
- onChange: (b) => wt(b.target.value),
2510
- style: {
2511
- flex: 1,
2512
- minWidth: 0,
2513
- border: "none",
2514
- outline: "none",
2515
- background: "transparent",
2516
- color: c.text,
2517
- fontSize: "12px"
2685
+ fontSize: "9px",
2686
+ lineHeight: 1.2,
2687
+ padding: "1px 4px",
2688
+ minHeight: "20px",
2689
+ outline: "none"
2690
+ }), [c.background, c.border, c.headerSubtleBg, c.radiusSm, c.surfaceInset, c.text]), Wt = e.useCallback((r, f) => {
2691
+ d(
2692
+ /** @param {any} [prev] @returns {any} */
2693
+ (p) => {
2694
+ const b = [...p], S = b[r];
2695
+ if (!S) return p;
2696
+ if (Ht(f) && !S.weightField) {
2697
+ const I = Array.isArray(J) && J.length > 0 ? J.find((j) => j !== S.field) || J[0] : "", q = typeof window < "u" ? window.prompt(
2698
+ `Weight field for weighted average of ${fe(S.field)}`,
2699
+ S.weightField || I || ""
2700
+ ) : S.weightField || I || "", C = typeof q == "string" ? q.trim() : "";
2701
+ return C ? Array.isArray(J) && J.length > 0 && !J.includes(C) ? (w && w(`Unknown weight field: ${C}`, "warning"), p) : (b[r] = { ...S, agg: f, weightField: C }, b) : (w && w("Weighted average requires a weight field.", "warning"), p);
2702
+ }
2703
+ return b[r] = { ...S, agg: f }, b;
2518
2704
  }
2705
+ );
2706
+ }, [J, d, w]), Fr = e.useCallback((r, f) => {
2707
+ if (!f) {
2708
+ w && w("Weighted average requires a weight field.", "warning");
2709
+ return;
2519
2710
  }
2520
- ), p && /* @__PURE__ */ e.createElement(
2521
- "button",
2522
- {
2523
- type: "button",
2524
- "aria-label": "Clear available field search",
2525
- title: "Clear search",
2526
- onClick: () => wt(""),
2527
- style: {
2528
- border: "none",
2529
- background: "transparent",
2530
- color: c.textSec,
2531
- cursor: "pointer",
2532
- padding: 0,
2533
- display: "flex",
2534
- alignItems: "center"
2711
+ d(
2712
+ /** @param {any} [prev] @returns {any} */
2713
+ (p) => {
2714
+ const b = [...p], S = b[r];
2715
+ return S ? (b[r] = { ...S, weightField: f }, b) : p;
2535
2716
  }
2536
- },
2537
- /* @__PURE__ */ e.createElement(z.Close, null)
2538
- ), p && /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", color: c.textSec, whiteSpace: "nowrap" } }, f, "/", r));
2539
- };
2540
- return /* @__PURE__ */ e.createElement("div", { style: { position: "relative", display: "flex", flexShrink: 0 } }, /* @__PURE__ */ e.createElement("div", { ref: pe, style: { ...Z.sidebar, width: `${Lt}px`, minWidth: `${Lt}px` }, role: "complementary", "aria-label": "Tool Panel", onDragOver: Rr, onDragLeave: At, onDrop: At }, /* @__PURE__ */ e.createElement(
2541
- "div",
2542
- {
2543
- id: "pivot-sidebar-keyboard-dnd-help",
2544
- style: { position: "absolute", width: 1, height: 1, padding: 0, margin: -1, overflow: "hidden", clip: "rect(0 0 0 0)", whiteSpace: "nowrap", border: 0 }
2545
- },
2546
- "Press Enter or Space on a field to pick it up. Focus a target field or zone and press Enter or Space to drop it. Press Escape to cancel."
2547
- ), $e ? /* @__PURE__ */ e.createElement("div", { style: { display: "flex", borderBottom: `1px solid ${c.border}`, marginBottom: "16px" } }, [
2548
- { id: "report", label: "Builder", icon: /* @__PURE__ */ e.createElement(z.Report, null) },
2549
- { id: "fields", label: "Fields", icon: /* @__PURE__ */ e.createElement(z.Sigma, null) },
2550
- { id: "columns", label: "Columns", icon: /* @__PURE__ */ e.createElement(z.Columns, null) }
2551
- ].map((r) => /* @__PURE__ */ e.createElement(
2552
- "div",
2553
- {
2554
- key: r.id,
2555
- onClick: () => Cr(r.id),
2556
- style: {
2557
- padding: "8px 14px",
2558
- cursor: "pointer",
2559
- borderBottom: we === r.id ? `2px solid ${c.primary}` : "2px solid transparent",
2560
- fontWeight: we === r.id ? 600 : 400,
2561
- color: we === r.id ? c.primary : c.textSec,
2562
- display: "flex",
2563
- alignItems: "center",
2564
- gap: "5px",
2565
- fontSize: "13px"
2717
+ );
2718
+ }, [d, w]), zr = e.useCallback((r, f) => {
2719
+ d(
2720
+ /** @param {any} [prev] @returns {any} */
2721
+ (p) => {
2722
+ const b = [...p], S = b[r];
2723
+ return S ? (b[r] = {
2724
+ ...S,
2725
+ windowFn: f === "none" ? null : f
2726
+ }, b) : p;
2727
+ }
2728
+ );
2729
+ }, [d]), Bt = e.useCallback(() => {
2730
+ const r = xn(E), f = E.filter(
2731
+ /** @param {any} [config] @returns {any} */
2732
+ (I) => I && I.agg !== "formula"
2733
+ ), p = `Formula ${me + 1}`, b = Et(f), S = dn(p, E, r);
2734
+ Ce(r), ge(r), d(
2735
+ /** @param {any} [prev] @returns {any} */
2736
+ (I) => [
2737
+ ...I,
2738
+ {
2739
+ field: r,
2740
+ agg: "formula",
2741
+ label: p,
2742
+ formula: b,
2743
+ formulaRef: S,
2744
+ formulaScope: "measures"
2745
+ }
2746
+ ]
2747
+ ), w && (f.length === 0 ? w("Added a formula column. Add at least one regular value measure to reference in it.", "warning") : w(`Added ${p}.`, "success"));
2748
+ }, [me, ge, d, Ce, w, E]), Mr = (r, f) => {
2749
+ r.stopPropagation(), pe.current && (Ct.current = pe.current.scrollTop), kt(
2750
+ /** @param {any} [prev] @returns {any} */
2751
+ (p) => p.columnId === f ? { columnId: null, anchorEl: null } : { columnId: f, anchorEl: r.currentTarget }
2752
+ ), V && V(f);
2753
+ }, _r = () => kt({ columnId: null, anchorEl: null });
2754
+ e.useEffect(() => {
2755
+ pe.current && Ve.columnId && (pe.current.scrollTop = Ct.current);
2756
+ }, [Me, Ve.columnId]), e.useEffect(() => {
2757
+ if (oe.length === 0) {
2758
+ ke !== null && Ce(null), se !== null && ge(null);
2759
+ return;
2566
2760
  }
2567
- },
2568
- r.icon,
2569
- r.label
2570
- ))) : /* @__PURE__ */ e.createElement("div", { style: { display: "flex", borderBottom: `1px solid ${c.border}`, marginBottom: "16px" } }, /* @__PURE__ */ e.createElement(
2571
- "div",
2572
- {
2573
- onClick: () => s("fields"),
2574
- style: {
2575
- padding: "8px 16px",
2576
- cursor: "pointer",
2577
- borderBottom: n === "fields" ? `2px solid ${c.primary}` : "none",
2578
- fontWeight: n === "fields" ? 600 : 400,
2579
- color: n === "fields" ? c.primary : c.textSec
2761
+ oe.some(
2762
+ /** @param {any} [config] @returns {any} */
2763
+ (f) => f.field === ke
2764
+ ) || Ce(oe[oe.length - 1].field), se && !oe.some(
2765
+ /** @param {any} [config] @returns {any} */
2766
+ (f) => f.field === se
2767
+ ) && ge(null);
2768
+ }, [ke, oe, se]);
2769
+ const pt = e.useMemo(
2770
+ () => E.findIndex(
2771
+ /** @param {any} [config] @returns {any} */
2772
+ (r) => r && r.agg === "formula" && r.field === se
2773
+ ),
2774
+ [se, E]
2775
+ ), dt = pt >= 0 ? E[pt] : null, It = e.useCallback((r) => {
2776
+ Ce(r), ge(r);
2777
+ }, []), Ie = e.useCallback((r) => {
2778
+ const f = E[r] && E[r].agg === "formula" ? E[r].field : null;
2779
+ if (d(
2780
+ /** @param {any} [prev] @returns {any} */
2781
+ (p) => p.filter(
2782
+ /** @param {any} [_] @param {any} [index] @returns {any} */
2783
+ (b, S) => S !== r
2784
+ )
2785
+ ), f && f === ke) {
2786
+ const p = oe.find(
2787
+ /** @param {any} [config] @returns {any} */
2788
+ (b) => b.field !== f
2789
+ );
2790
+ Ce(p ? p.field : null);
2580
2791
  }
2581
- },
2582
- "Fields"
2583
- ), /* @__PURE__ */ e.createElement(
2584
- "div",
2585
- {
2586
- onClick: () => s("filters"),
2587
- style: {
2588
- padding: "8px 16px",
2589
- cursor: "pointer",
2590
- borderBottom: n === "filters" ? `2px solid ${c.primary}` : "none",
2591
- fontWeight: n === "filters" ? 600 : 400,
2592
- color: n === "filters" ? c.primary : c.textSec,
2792
+ f && f === se && ge(null);
2793
+ }, [ke, oe, se, d, E]), $e = yr === "report", Lt = Math.max(rt || 288, $e ? 380 : 0), Pt = (r, f) => {
2794
+ if (r <= 8) return null;
2795
+ const p = it.trim().length > 0;
2796
+ return /* @__PURE__ */ e.createElement("div", { style: {
2593
2797
  display: "flex",
2594
2798
  alignItems: "center",
2595
- gap: "6px"
2596
- }
2597
- },
2598
- "Filters",
2599
- Object.keys(ae).length > 0 && /* @__PURE__ */ e.createElement("div", { style: { width: "6px", height: "6px", borderRadius: "50%", background: "#d32f2f" } })
2600
- ), /* @__PURE__ */ e.createElement(
2601
- "div",
2602
- {
2603
- onClick: () => s("columns"),
2604
- style: {
2605
- padding: "8px 16px",
2606
- cursor: "pointer",
2607
- borderBottom: n === "columns" ? `2px solid ${c.primary}` : "none",
2608
- fontWeight: n === "columns" ? 600 : 400,
2609
- color: n === "columns" ? c.primary : c.textSec
2610
- }
2611
- },
2612
- "Columns"
2613
- )), $e && we === "report" ? /* @__PURE__ */ e.createElement("div", { style: { flex: 1, overflowY: "auto", padding: "0 12px 12px" } }, /* @__PURE__ */ e.createElement(
2614
- pn,
2615
- {
2616
- reportDef: br,
2617
- setReportDef: Er,
2618
- availableFields: D,
2619
- customDimensions: _e,
2620
- theme: c,
2621
- styles: Z,
2622
- data: Se,
2623
- valConfigs: E,
2624
- colFields: g,
2625
- setColFields: u,
2626
- setValConfigs: d,
2627
- savedReports: vr,
2628
- setSavedReports: Sr,
2629
- activeReportId: hr,
2630
- setActiveReportId: kr,
2631
- showNotification: w,
2632
- requestedSelection: gr,
2633
- showReportConfigColumn: mr,
2634
- setShowReportConfigColumn: xr
2635
- }
2636
- )) : $e && we === "fields" ? /* @__PURE__ */ e.createElement("div", { style: { padding: "0 4px" } }, /* @__PURE__ */ e.createElement(
2637
- Kt,
2638
- {
2639
- availableFields: D,
2640
- customDimensions: _e,
2641
- setCustomDimensions: ht,
2642
- data: Se,
2643
- theme: c,
2644
- showNotification: w,
2645
- getFieldLabel: X,
2646
- onDeleteField: Dt
2647
- }
2648
- ), /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", color: c.textSec, textTransform: "uppercase", letterSpacing: "0.5px", marginBottom: "6px", padding: "0 2px" } }, /* @__PURE__ */ e.createElement(z.Database, { style: { verticalAlign: "middle", marginRight: "4px" } }), "Available Fields — click to add"), Pt(J.length, ut.length), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px", marginBottom: "14px" } }, ut.map((r) => {
2649
- const f = E.some((p) => p && p.field === r && p.agg !== "formula");
2650
- return /* @__PURE__ */ e.createElement(
2799
+ gap: "6px",
2800
+ margin: "0 2px 8px",
2801
+ padding: "5px 8px",
2802
+ border: `1px solid ${c.border}`,
2803
+ borderRadius: c.radiusSm || "8px",
2804
+ background: c.headerSubtleBg || c.surfaceInset || c.background
2805
+ } }, /* @__PURE__ */ e.createElement(z.Search, { style: { flexShrink: 0, color: c.textSec } }), /* @__PURE__ */ e.createElement(
2806
+ "input",
2807
+ {
2808
+ type: "search",
2809
+ "aria-label": "Search available fields",
2810
+ placeholder: `Search ${r} fields...`,
2811
+ value: it,
2812
+ onChange: (b) => wt(b.target.value),
2813
+ style: {
2814
+ flex: 1,
2815
+ minWidth: 0,
2816
+ border: "none",
2817
+ outline: "none",
2818
+ background: "transparent",
2819
+ color: c.text,
2820
+ fontSize: "12px"
2821
+ }
2822
+ }
2823
+ ), p && /* @__PURE__ */ e.createElement(
2824
+ "button",
2825
+ {
2826
+ type: "button",
2827
+ "aria-label": "Clear available field search",
2828
+ title: "Clear search",
2829
+ onClick: () => wt(""),
2830
+ style: {
2831
+ border: "none",
2832
+ background: "transparent",
2833
+ color: c.textSec,
2834
+ cursor: "pointer",
2835
+ padding: 0,
2836
+ display: "flex",
2837
+ alignItems: "center"
2838
+ }
2839
+ },
2840
+ /* @__PURE__ */ e.createElement(z.Close, null)
2841
+ ), p && /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", color: c.textSec, whiteSpace: "nowrap" } }, f, "/", r));
2842
+ };
2843
+ return /* @__PURE__ */ e.createElement("div", { style: { position: "relative", display: "flex", flexShrink: 0 } }, /* @__PURE__ */ e.createElement("div", { ref: pe, style: { ...Y.sidebar, width: `${Lt}px`, minWidth: `${Lt}px` }, role: "complementary", "aria-label": "Tool Panel", onDragOver: Rr, onDragLeave: At, onDrop: At }, /* @__PURE__ */ e.createElement(
2651
2844
  "div",
2652
2845
  {
2653
- key: r,
2654
- onClick: () => {
2655
- f || d((p) => [...p, { field: r, agg: "sum", label: X(r) }]);
2656
- },
2846
+ id: "pivot-sidebar-keyboard-dnd-help",
2847
+ style: { position: "absolute", width: 1, height: 1, padding: 0, margin: -1, overflow: "hidden", clip: "rect(0 0 0 0)", whiteSpace: "nowrap", border: 0 }
2848
+ },
2849
+ "Press Enter or Space on a field to pick it up. Focus a target field or zone and press Enter or Space to drop it. Press Escape to cancel."
2850
+ ), $e ? /* @__PURE__ */ e.createElement("div", { style: { display: "flex", borderBottom: `1px solid ${c.border}`, marginBottom: "16px" } }, [
2851
+ { id: "report", label: "Builder", icon: /* @__PURE__ */ e.createElement(z.Report, null) },
2852
+ { id: "fields", label: "Fields", icon: /* @__PURE__ */ e.createElement(z.Sigma, null) },
2853
+ { id: "columns", label: "Columns", icon: /* @__PURE__ */ e.createElement(z.Columns, null) }
2854
+ ].map((r) => /* @__PURE__ */ e.createElement(
2855
+ "div",
2856
+ {
2857
+ key: r.id,
2858
+ onClick: () => Cr(r.id),
2657
2859
  style: {
2658
- padding: "3px 9px",
2659
- fontSize: "11px",
2660
- lineHeight: 1.4,
2661
- fontWeight: 500,
2662
- borderRadius: "999px",
2663
- border: `1px solid ${f || c.isDark ? c.border : "#D7DDEA"}`,
2664
- background: f ? c.select || c.headerBg : c.isDark ? c.background : "#ffffff",
2665
- color: f ? c.primary : c.text,
2666
- cursor: f ? "default" : "pointer",
2667
- opacity: f ? 0.6 : 1,
2668
- userSelect: "none"
2669
- },
2670
- title: f ? `${X(r)} already in values` : `Add ${X(r)} to values`
2860
+ padding: "8px 14px",
2861
+ cursor: "pointer",
2862
+ borderBottom: we === r.id ? `2px solid ${c.primary}` : "2px solid transparent",
2863
+ fontWeight: we === r.id ? 600 : 400,
2864
+ color: we === r.id ? c.primary : c.textSec,
2865
+ display: "flex",
2866
+ alignItems: "center",
2867
+ gap: "5px",
2868
+ fontSize: "13px"
2869
+ }
2671
2870
  },
2672
- X(r),
2673
- f ? " ✓" : ""
2674
- );
2675
- }), J.length > 8 && ut.length === 0 && /* @__PURE__ */ e.createElement("div", { style: { width: "100%", padding: "8px 2px", fontSize: "11px", color: c.textSec } }, "No fields match the current search.")), /* @__PURE__ */ e.createElement("div", { style: { borderTop: `1px solid ${c.border}`, paddingTop: "10px", marginBottom: "8px" } }, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", gap: "8px", padding: "0 2px 8px 2px", flexWrap: "wrap" } }, /* @__PURE__ */ e.createElement("button", { type: "button", onClick: Bt, style: { border: `1px solid ${c.primary}66`, background: `${c.primary}12`, color: c.primary, borderRadius: "999px", cursor: "pointer", padding: "4px 10px", fontSize: "11px", fontWeight: 700 } }, "+ Add Formula"), /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", color: c.textSec } }, Ae, " value", Ae === 1 ? "" : "s", " · ", me, " formula", me === 1 ? "" : "s")), /* @__PURE__ */ e.createElement(
2676
- Qt,
2677
- {
2678
- measureAxis: $,
2679
- setMeasureAxis: i,
2680
- theme: c,
2681
- valueSelectStyle: ue,
2682
- regularValueCount: Ae
2683
- }
2684
- )), E.map((r, f) => {
2685
- const p = r && r.agg === "formula";
2686
- if (!r) return null;
2687
- const b = wr === f;
2688
- return /* @__PURE__ */ e.createElement(
2871
+ r.icon,
2872
+ r.label
2873
+ ))) : /* @__PURE__ */ e.createElement("div", { style: { display: "flex", borderBottom: `1px solid ${c.border}`, marginBottom: "16px" } }, /* @__PURE__ */ e.createElement(
2689
2874
  "div",
2690
2875
  {
2691
- key: r.field || f,
2692
- draggable: !0,
2693
- onDragStart: () => {
2694
- Ye.current = f;
2695
- },
2696
- onDragOver: (S) => {
2697
- S.preventDefault(), Ze(f);
2698
- },
2699
- onDragLeave: () => Ze(null),
2700
- onDrop: (S) => {
2701
- S.preventDefault();
2702
- const I = Ye.current;
2703
- Ze(null), Ye.current = null, !(I === null || I === f) && d((q) => {
2704
- const C = [...q], [j] = C.splice(I, 1);
2705
- return C.splice(f, 0, j), C;
2706
- });
2707
- },
2708
- onDragEnd: () => {
2709
- Ye.current = null, Ze(null);
2710
- },
2711
- style: { marginBottom: "6px", borderTop: b ? `2px solid ${c.primary}` : "2px solid transparent", cursor: "grab" }
2876
+ onClick: () => s("fields"),
2877
+ style: {
2878
+ padding: "8px 16px",
2879
+ cursor: "pointer",
2880
+ borderBottom: n === "fields" ? `2px solid ${c.primary}` : "none",
2881
+ fontWeight: n === "fields" ? 600 : 400,
2882
+ color: n === "fields" ? c.primary : c.textSec
2883
+ }
2712
2884
  },
2713
- p ? /* @__PURE__ */ e.createElement(Jt, { item: r, idx: f, selected: r.field === se, onSelect: It, onRemove: Ie, setValConfigs: d, theme: c, styles: Z, dropLine: null, zoneId: "vals", valueSelectStyle: ue, colFields: g, fixedSparklineValueKeySet: st, showNotification: w, serverError: he && he[r.field] || null }) : /* @__PURE__ */ e.createElement("div", { style: { ...Z.chip, flexWrap: "wrap", alignItems: "flex-start" } }, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", gap: "8px", minWidth: 0, flex: 1 } }, /* @__PURE__ */ e.createElement(z.DragIndicator, { style: { flexShrink: 0, opacity: 0.4 } }), /* @__PURE__ */ e.createElement("b", { style: { fontWeight: 500, minWidth: 0, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } }, X(r.field))), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", gap: "4px", marginLeft: "8px", flexWrap: "nowrap", flexShrink: 0 } }, /* @__PURE__ */ e.createElement("select", { value: r.agg, onChange: (S) => Wt(f, S.target.value), style: { ...ue, width: "74px" } }, /* @__PURE__ */ e.createElement("option", { value: "sum" }, "Sum"), /* @__PURE__ */ e.createElement("option", { value: "avg" }, "Avg"), /* @__PURE__ */ e.createElement("option", { value: "count" }, "Cnt"), /* @__PURE__ */ e.createElement("option", { value: "min" }, "Min"), /* @__PURE__ */ e.createElement("option", { value: "max" }, "Max"), /* @__PURE__ */ e.createElement("option", { value: "weighted_avg" }, "WAvg")), /* @__PURE__ */ e.createElement("span", { onClick: () => Ie(f), style: { cursor: "pointer", color: "#9CA3AF", display: "flex", alignItems: "center" } }, /* @__PURE__ */ e.createElement(z.Close, null))))
2714
- );
2715
- }), E.length === 0 && /* @__PURE__ */ e.createElement("div", { style: { opacity: 0.5, fontSize: "11px", padding: "12px", textAlign: "center" } }, "No value fields. Click a field above or add a formula.")) : !$e && n === "filters" ? /* @__PURE__ */ e.createElement("div", { style: { flex: 1, overflowY: "auto", display: "flex", flexDirection: "column", padding: "8px" } }, /* @__PURE__ */ e.createElement("div", { style: { marginBottom: "10px", display: "flex", alignItems: "center", background: c.background, borderRadius: "6px", padding: "4px 8px", border: `1px solid ${c.border}` } }, /* @__PURE__ */ e.createElement(z.Search, null), /* @__PURE__ */ e.createElement(
2716
- "input",
2717
- {
2718
- placeholder: "Search columns...",
2719
- value: k,
2720
- onChange: (r) => P(r.target.value),
2721
- style: { border: "none", background: "transparent", marginLeft: "10px", outline: "none", width: "100%", color: c.text, fontSize: "13px" }
2722
- }
2723
- )), (() => {
2724
- const p = D.map((b) => {
2725
- const S = y.getColumn(b);
2726
- return S || { id: b, header: X(b), columnDef: { header: X(b) } };
2727
- }).filter((b) => {
2728
- const S = b.columnDef && typeof b.columnDef.header == "string" ? b.columnDef.header : typeof b.header == "string" ? b.header : b.id;
2729
- return String(S).toLowerCase().includes(k.toLowerCase()) || b.id.toLowerCase().includes(k.toLowerCase());
2730
- });
2731
- return /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column" } }, p.map((b) => /* @__PURE__ */ e.createElement(
2732
- Jr,
2885
+ "Fields"
2886
+ ), /* @__PURE__ */ e.createElement(
2887
+ "div",
2733
2888
  {
2734
- key: b.id,
2735
- column: b,
2736
- theme: c,
2737
- styles: Z,
2738
- onFilter: (S) => U(b.id, S),
2739
- currentFilter: ae[b.id],
2740
- options: Tt(b.id),
2741
- optionMeta: Oe && Oe[b.id],
2742
- onSearchOptions: je ? (S) => V && V(b.id, { search: S, offset: 0 }) : void 0,
2743
- onLoadMoreOptions: je ? (S, I) => V && V(b.id, { search: S, offset: I }) : void 0,
2744
- onOpen: V
2745
- }
2746
- )));
2747
- })()) : ($e ? we !== "columns" : n !== "columns") ? /* @__PURE__ */ e.createElement(e.Fragment, null, n === "fields" && /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement(
2748
- Kt,
2749
- {
2750
- availableFields: D,
2751
- customDimensions: _e,
2752
- setCustomDimensions: ht,
2753
- data: Se,
2754
- theme: c,
2755
- showNotification: w,
2756
- getFieldLabel: X,
2757
- onDeleteField: Dt
2758
- }
2759
- ), /* @__PURE__ */ e.createElement("div", { style: Z.sectionTitleSm }, /* @__PURE__ */ e.createElement(z.Database, null), " Available Fields"), Pt(De.length, ct.length), /* @__PURE__ */ e.createElement(
2760
- qt,
2761
- {
2762
- panelId: "availableFields",
2763
- panelLabel: "Available Fields",
2764
- size: Ue && Ue.availableFields,
2765
- onSizeChange: zt,
2766
- theme: c,
2767
- outerStyle: _t,
2768
- contentStyle: {
2769
- display: "flex",
2770
- flexWrap: "wrap",
2771
- gap: "4px",
2772
- alignContent: "flex-start",
2773
- padding: "2px 12px 12px 2px"
2774
- }
2775
- },
2776
- ct.map((r) => {
2777
- const f = Te && r === de, p = f ? "Measure Names" : X(r), b = f ? "measureAxis" : "pool";
2778
- return /* @__PURE__ */ e.createElement(
2779
- "div",
2780
- {
2781
- key: f ? `__measure_axis__${r}` : r,
2782
- draggable: !0,
2783
- "data-sidebar-field-chip": f ? "measure-axis-label" : "available",
2784
- role: "button",
2785
- tabIndex: 0,
2786
- "aria-describedby": "pivot-sidebar-keyboard-dnd-help",
2787
- "aria-grabbed": G && G.zone === b && G.field === r ? "true" : "false",
2788
- "aria-label": `Move ${p}`,
2789
- onDragStart: (S) => H(S, r, b),
2790
- onDragEnd: F,
2791
- onKeyDown: (S) => Ft(S, r, b, -1, p),
2792
- title: f ? "Drag to Rows or Columns to show measure names" : `Move ${X(r)}`,
2793
- style: {
2794
- padding: "4px 8px",
2795
- fontSize: "11px",
2796
- lineHeight: 1.2,
2797
- fontWeight: f ? 700 : 500,
2798
- fontFamily: "'Inter', ui-sans-serif, system-ui, sans-serif",
2799
- borderRadius: c.radiusSm || c.radius || "10px",
2800
- border: f ? `1px dashed ${c.primary}` : `1px solid ${c.isDark ? c.border : "#D7DDEA"}`,
2801
- background: f ? `${c.primary}12` : c.isDark ? c.background : c.surfaceInset || "#ffffff",
2802
- color: f ? c.primary : c.isDark ? c.text : "#334155",
2803
- display: "inline-flex",
2804
- alignItems: "center",
2805
- gap: "4px",
2806
- boxShadow: c.isDark ? "none" : c.shadowInset || "0 1px 2px rgba(0,0,0,0.04)",
2807
- cursor: "grab",
2808
- userSelect: "none",
2809
- minHeight: "24px"
2810
- }
2811
- },
2812
- f && /* @__PURE__ */ e.createElement(z.Sigma, null),
2813
- p
2814
- );
2815
- }),
2816
- De.length > 8 && ct.length === 0 && /* @__PURE__ */ e.createElement("div", { style: { width: "100%", padding: "8px 2px", fontSize: "11px", color: c.textSec } }, "No fields match the current search.")
2817
- )), Dr.map((r) => {
2818
- const f = Be[r.id] || [];
2819
- return /* @__PURE__ */ e.createElement("div", { key: r.id, style: { marginBottom: "20px" } }, /* @__PURE__ */ e.createElement("div", { style: Z.sectionTitle }, r.icon, r.label), r.id === "vals" && /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", gap: "8px", padding: "0 4px 8px 4px", flexWrap: "wrap" } }, /* @__PURE__ */ e.createElement(
2820
- "button",
2889
+ onClick: () => s("filters"),
2890
+ style: {
2891
+ padding: "8px 16px",
2892
+ cursor: "pointer",
2893
+ borderBottom: n === "filters" ? `2px solid ${c.primary}` : "none",
2894
+ fontWeight: n === "filters" ? 600 : 400,
2895
+ color: n === "filters" ? c.primary : c.textSec,
2896
+ display: "flex",
2897
+ alignItems: "center",
2898
+ gap: "6px"
2899
+ }
2900
+ },
2901
+ "Filters",
2902
+ Object.keys(ae).length > 0 && /* @__PURE__ */ e.createElement("div", { style: { width: "6px", height: "6px", borderRadius: "50%", background: "#d32f2f" } })
2903
+ ), /* @__PURE__ */ e.createElement(
2904
+ "div",
2821
2905
  {
2822
- type: "button",
2823
- onClick: Bt,
2906
+ onClick: () => s("columns"),
2824
2907
  style: {
2825
- border: `1px solid ${c.primary}66`,
2826
- background: `${c.primary}12`,
2827
- color: c.primary,
2828
- borderRadius: "999px",
2908
+ padding: "8px 16px",
2829
2909
  cursor: "pointer",
2830
- padding: "4px 10px",
2831
- fontSize: "11px",
2832
- fontWeight: 700
2910
+ borderBottom: n === "columns" ? `2px solid ${c.primary}` : "none",
2911
+ fontWeight: n === "columns" ? 600 : 400,
2912
+ color: n === "columns" ? c.primary : c.textSec
2833
2913
  }
2834
2914
  },
2835
- "+ Add Formula"
2836
- ), /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", color: c.textSec } }, Ae, " value measure", Ae === 1 ? "" : "s", " available"), me > 0 && /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", color: c.textSec } }, me, " formula", me === 1 ? "" : "s"), /* @__PURE__ */ e.createElement(
2915
+ "Columns"
2916
+ )), $e && we === "report" ? /* @__PURE__ */ e.createElement("div", { style: { flex: 1, overflowY: "auto", padding: "0 12px 12px" } }, /* @__PURE__ */ e.createElement(
2917
+ pn,
2918
+ {
2919
+ reportDef: br,
2920
+ setReportDef: Er,
2921
+ availableFields: D,
2922
+ customDimensions: _e,
2923
+ theme: c,
2924
+ styles: Y,
2925
+ data: Se,
2926
+ valConfigs: E,
2927
+ colFields: g,
2928
+ setColFields: u,
2929
+ setValConfigs: d,
2930
+ savedReports: vr,
2931
+ setSavedReports: Sr,
2932
+ activeReportId: hr,
2933
+ setActiveReportId: kr,
2934
+ showNotification: w,
2935
+ requestedSelection: gr,
2936
+ showReportConfigColumn: mr,
2937
+ setShowReportConfigColumn: xr
2938
+ }
2939
+ )) : $e && we === "fields" ? /* @__PURE__ */ e.createElement("div", { style: { padding: "0 4px" } }, /* @__PURE__ */ e.createElement(
2940
+ Kt,
2941
+ {
2942
+ availableFields: D,
2943
+ customDimensions: _e,
2944
+ setCustomDimensions: ht,
2945
+ data: Se,
2946
+ theme: c,
2947
+ showNotification: w,
2948
+ getFieldLabel: X,
2949
+ onDeleteField: Dt
2950
+ }
2951
+ ), /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", color: c.textSec, textTransform: "uppercase", letterSpacing: "0.5px", marginBottom: "6px", padding: "0 2px" } }, /* @__PURE__ */ e.createElement(z.Database, { style: { verticalAlign: "middle", marginRight: "4px" } }), "Available Fields — click to add"), Pt(J.length, ut.length), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px", marginBottom: "14px" } }, ut.map(
2952
+ /** @param {any} [f] @returns {any} */
2953
+ (r) => {
2954
+ const f = E.some(
2955
+ /** @param {any} [c] @returns {any} */
2956
+ (p) => p && p.field === r && p.agg !== "formula"
2957
+ );
2958
+ return /* @__PURE__ */ e.createElement(
2959
+ "div",
2960
+ {
2961
+ key: r,
2962
+ onClick: () => {
2963
+ f || d(
2964
+ /** @param {any} [prev] @returns {any} */
2965
+ (p) => [...p, { field: r, agg: "sum", label: X(r) }]
2966
+ );
2967
+ },
2968
+ style: {
2969
+ padding: "3px 9px",
2970
+ fontSize: "11px",
2971
+ lineHeight: 1.4,
2972
+ fontWeight: 500,
2973
+ borderRadius: "999px",
2974
+ border: `1px solid ${f || c.isDark ? c.border : "#D7DDEA"}`,
2975
+ background: f ? c.select || c.headerBg : c.isDark ? c.background : "#ffffff",
2976
+ color: f ? c.primary : c.text,
2977
+ cursor: f ? "default" : "pointer",
2978
+ opacity: f ? 0.6 : 1,
2979
+ userSelect: "none"
2980
+ },
2981
+ title: f ? `${X(r)} already in values` : `Add ${X(r)} to values`
2982
+ },
2983
+ X(r),
2984
+ f ? " ✓" : ""
2985
+ );
2986
+ }
2987
+ ), J.length > 8 && ut.length === 0 && /* @__PURE__ */ e.createElement("div", { style: { width: "100%", padding: "8px 2px", fontSize: "11px", color: c.textSec } }, "No fields match the current search.")), /* @__PURE__ */ e.createElement("div", { style: { borderTop: `1px solid ${c.border}`, paddingTop: "10px", marginBottom: "8px" } }, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", gap: "8px", padding: "0 2px 8px 2px", flexWrap: "wrap" } }, /* @__PURE__ */ e.createElement("button", { type: "button", onClick: Bt, style: { border: `1px solid ${c.primary}66`, background: `${c.primary}12`, color: c.primary, borderRadius: "999px", cursor: "pointer", padding: "4px 10px", fontSize: "11px", fontWeight: 700 } }, "+ Add Formula"), /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", color: c.textSec } }, Ae, " value", Ae === 1 ? "" : "s", " · ", me, " formula", me === 1 ? "" : "s")), /* @__PURE__ */ e.createElement(
2837
2988
  Qt,
2838
2989
  {
2839
2990
  measureAxis: $,
@@ -2842,498 +2993,750 @@ const Fn = e.memo(function({
2842
2993
  valueSelectStyle: ue,
2843
2994
  regularValueCount: Ae
2844
2995
  }
2845
- )), r.id === "rows" && a.length > 0 && /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "4px", padding: "0 4px 6px 4px" } }, /* @__PURE__ */ e.createElement(
2846
- "button",
2996
+ )), E.map(
2997
+ /** @param {any} [item] @param {any} [idx] @returns {any} */
2998
+ (r, f) => {
2999
+ const p = r && r.agg === "formula";
3000
+ if (!r) return null;
3001
+ const b = wr === f;
3002
+ return /* @__PURE__ */ e.createElement(
3003
+ "div",
3004
+ {
3005
+ key: r.field || f,
3006
+ draggable: !0,
3007
+ onDragStart: () => {
3008
+ Ze.current = f;
3009
+ },
3010
+ onDragOver: (S) => {
3011
+ S.preventDefault(), Ye(f);
3012
+ },
3013
+ onDragLeave: () => Ye(null),
3014
+ onDrop: (S) => {
3015
+ S.preventDefault();
3016
+ const I = Ze.current;
3017
+ Ye(null), Ze.current = null, !(I === null || I === f) && d(
3018
+ /** @param {any} [prev] @returns {any} */
3019
+ (q) => {
3020
+ const C = [...q], [j] = C.splice(I, 1);
3021
+ return C.splice(f, 0, j), C;
3022
+ }
3023
+ );
3024
+ },
3025
+ onDragEnd: () => {
3026
+ Ze.current = null, Ye(null);
3027
+ },
3028
+ style: { marginBottom: "6px", borderTop: b ? `2px solid ${c.primary}` : "2px solid transparent", cursor: "grab" }
3029
+ },
3030
+ p ? /* @__PURE__ */ e.createElement(Jt, { item: r, idx: f, selected: r.field === se, onSelect: It, onRemove: Ie, setValConfigs: d, theme: c, styles: Y, dropLine: null, zoneId: "vals", valueSelectStyle: ue, colFields: g, fixedSparklineValueKeySet: st, showNotification: w, serverError: he && he[r.field] || null }) : /* @__PURE__ */ e.createElement("div", { style: { ...Y.chip, flexWrap: "wrap", alignItems: "flex-start" } }, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", gap: "8px", minWidth: 0, flex: 1 } }, /* @__PURE__ */ e.createElement(z.DragIndicator, { style: { flexShrink: 0, opacity: 0.4 } }), /* @__PURE__ */ e.createElement("b", { style: { fontWeight: 500, minWidth: 0, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } }, X(r.field))), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", gap: "4px", marginLeft: "8px", flexWrap: "nowrap", flexShrink: 0 } }, /* @__PURE__ */ e.createElement("select", { value: r.agg, onChange: (S) => Wt(f, S.target.value), style: { ...ue, width: "74px" } }, /* @__PURE__ */ e.createElement("option", { value: "sum" }, "Sum"), /* @__PURE__ */ e.createElement("option", { value: "avg" }, "Avg"), /* @__PURE__ */ e.createElement("option", { value: "count" }, "Cnt"), /* @__PURE__ */ e.createElement("option", { value: "min" }, "Min"), /* @__PURE__ */ e.createElement("option", { value: "max" }, "Max"), /* @__PURE__ */ e.createElement("option", { value: "weighted_avg" }, "WAvg")), /* @__PURE__ */ e.createElement("span", { onClick: () => Ie(f), style: { cursor: "pointer", color: "#9CA3AF", display: "flex", alignItems: "center" } }, /* @__PURE__ */ e.createElement(z.Close, null))))
3031
+ );
3032
+ }
3033
+ ), E.length === 0 && /* @__PURE__ */ e.createElement("div", { style: { opacity: 0.5, fontSize: "11px", padding: "12px", textAlign: "center" } }, "No value fields. Click a field above or add a formula.")) : !$e && n === "filters" ? /* @__PURE__ */ e.createElement("div", { style: { flex: 1, overflowY: "auto", display: "flex", flexDirection: "column", padding: "8px" } }, /* @__PURE__ */ e.createElement("div", { style: { marginBottom: "10px", display: "flex", alignItems: "center", background: c.background, borderRadius: "6px", padding: "4px 8px", border: `1px solid ${c.border}` } }, /* @__PURE__ */ e.createElement(z.Search, null), /* @__PURE__ */ e.createElement(
3034
+ "input",
2847
3035
  {
2848
- title: "Expand all hierarchy levels",
2849
- onClick: () => ee(!0),
2850
- style: { flex: 1, border: `1px solid ${c.primary}`, background: c.select, cursor: "pointer", padding: "3px 6px", fontSize: "11px", color: c.primary, borderRadius: "4px", fontWeight: 600 }
2851
- },
2852
- "+ Expand All"
2853
- ), /* @__PURE__ */ e.createElement(
2854
- "button",
3036
+ placeholder: "Search columns...",
3037
+ value: k,
3038
+ onChange: (r) => P(r.target.value),
3039
+ style: { border: "none", background: "transparent", marginLeft: "10px", outline: "none", width: "100%", color: c.text, fontSize: "13px" }
3040
+ }
3041
+ )), (() => {
3042
+ const p = D.map(
3043
+ /** @param {any} [field] @returns {any} */
3044
+ (b) => {
3045
+ const S = y.getColumn(b);
3046
+ return S || { id: b, header: X(b), columnDef: { header: X(b) } };
3047
+ }
3048
+ ).filter(
3049
+ /** @param {any} [col] @returns {any} */
3050
+ (b) => {
3051
+ const S = b.columnDef && typeof b.columnDef.header == "string" ? b.columnDef.header : typeof b.header == "string" ? b.header : b.id;
3052
+ return String(S).toLowerCase().includes(k.toLowerCase()) || b.id.toLowerCase().includes(k.toLowerCase());
3053
+ }
3054
+ );
3055
+ return /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column" } }, p.map(
3056
+ /** @param {any} [col] @returns {any} */
3057
+ (b) => /* @__PURE__ */ e.createElement(
3058
+ Jr,
3059
+ {
3060
+ key: b.id,
3061
+ column: b,
3062
+ theme: c,
3063
+ styles: Y,
3064
+ onFilter: (
3065
+ /** @param {any} [val] @returns {any} */
3066
+ ((S) => U(b.id, S))
3067
+ ),
3068
+ currentFilter: ae[b.id],
3069
+ options: Tt(b.id),
3070
+ optionMeta: Oe && Oe[b.id],
3071
+ onSearchOptions: je ? (
3072
+ /** @param {any} [search] @returns {any} */
3073
+ ((S) => V && V(b.id, { search: S, offset: 0 }))
3074
+ ) : void 0,
3075
+ onLoadMoreOptions: je ? (
3076
+ /** @param {any} [search] @param {any} [offset] @returns {any} */
3077
+ ((S, I) => V && V(b.id, { search: S, offset: I }))
3078
+ ) : void 0,
3079
+ onOpen: V
3080
+ }
3081
+ )
3082
+ ));
3083
+ })()) : ($e ? we !== "columns" : n !== "columns") ? /* @__PURE__ */ e.createElement(e.Fragment, null, n === "fields" && /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement(
3084
+ Kt,
2855
3085
  {
2856
- title: "Collapse all rows",
2857
- onClick: () => ee(!1),
2858
- style: { flex: 1, border: `1px solid ${c.border}`, background: c.background, cursor: "pointer", padding: "3px 6px", fontSize: "11px", color: c.textSec, borderRadius: "4px" }
2859
- },
2860
- "- Collapse All"
2861
- )), /* @__PURE__ */ e.createElement(
3086
+ availableFields: D,
3087
+ customDimensions: _e,
3088
+ setCustomDimensions: ht,
3089
+ data: Se,
3090
+ theme: c,
3091
+ showNotification: w,
3092
+ getFieldLabel: X,
3093
+ onDeleteField: Dt
3094
+ }
3095
+ ), /* @__PURE__ */ e.createElement("div", { style: Y.sectionTitleSm }, /* @__PURE__ */ e.createElement(z.Database, null), " Available Fields"), Pt(De.length, ct.length), /* @__PURE__ */ e.createElement(
2862
3096
  qt,
2863
3097
  {
2864
- panelId: r.id,
2865
- panelLabel: r.label,
2866
- size: Ue && Ue[r.id],
3098
+ panelId: "availableFields",
3099
+ panelLabel: "Available Fields",
3100
+ size: Ue && Ue.availableFields,
2867
3101
  onSizeChange: zt,
2868
3102
  theme: c,
2869
3103
  outerStyle: _t,
2870
- contentStyle: { padding: `${Mt} 12px 12px ${Mt}` }
3104
+ contentStyle: {
3105
+ display: "flex",
3106
+ flexWrap: "wrap",
3107
+ gap: "4px",
3108
+ alignContent: "flex-start",
3109
+ padding: "2px 12px 12px 2px"
3110
+ }
2871
3111
  },
2872
- /* @__PURE__ */ e.createElement(
2873
- "div",
2874
- {
2875
- "data-sidebar-drop-zone": r.id,
2876
- role: "group",
2877
- tabIndex: 0,
2878
- "aria-label": `${r.label} drop zone`,
2879
- "aria-describedby": "pivot-sidebar-keyboard-dnd-help",
2880
- onKeyDown: (p) => Ar(p, r.id),
2881
- onDragOver: (p) => {
2882
- p.target === p.currentTarget ? K(p, r.id, f.length) : (p.preventDefault(), p.dataTransfer && (p.dataTransfer.dropEffect = "move"));
2883
- },
2884
- onDrop: (p) => x(p, r.id)
2885
- },
2886
- f.map((p, b) => {
2887
- const S = r.id === "vals" ? p.field : p, I = r.id === "vals" ? p.agg === "formula" ? p.label || "Formula" : X(p.field) : X(p), q = (r.id === "rows" || r.id === "cols") && S === de && Rt.placement !== "none";
3112
+ ct.map(
3113
+ /** @param {any} [f] @returns {any} */
3114
+ (r) => {
3115
+ const f = Te && r === de, p = f ? "Measure Names" : X(r), b = f ? "measureAxis" : "pool";
2888
3116
  return /* @__PURE__ */ e.createElement(
2889
3117
  "div",
2890
3118
  {
2891
- key: b,
3119
+ key: f ? `__measure_axis__${r}` : r,
2892
3120
  draggable: !0,
2893
- "data-sidebar-field-chip": "zone",
3121
+ "data-sidebar-field-chip": f ? "measure-axis-label" : "available",
2894
3122
  role: "button",
2895
3123
  tabIndex: 0,
2896
3124
  "aria-describedby": "pivot-sidebar-keyboard-dnd-help",
2897
- "aria-grabbed": G && G.zone === r.id && G.idx === b ? "true" : "false",
2898
- "aria-label": `Move ${I}`,
2899
- onKeyDown: (C) => Ft(C, p, r.id, b, I),
2900
- onDragStart: (C) => H(C, p, r.id, b),
2901
- onDragOver: (C) => K(C, r.id, b),
2902
- onDragEnd: F
2903
- },
2904
- r.id === "vals" && p.agg === "formula" ? /* @__PURE__ */ e.createElement(
2905
- Jt,
2906
- {
2907
- item: p,
2908
- idx: b,
2909
- selected: p.field === ke,
2910
- onSelect: It,
2911
- onRemove: Ie,
2912
- setValConfigs: d,
2913
- theme: c,
2914
- styles: Z,
2915
- dropLine: M,
2916
- zoneId: r.id,
2917
- valueSelectStyle: ue,
2918
- colFields: g,
2919
- fixedSparklineValueKeySet: st,
2920
- showNotification: w,
2921
- serverError: he && he[p.field] || null
2922
- }
2923
- ) : /* @__PURE__ */ e.createElement("div", { style: {
2924
- ...Z.chip,
2925
- ...r.id === "vals" ? { flexWrap: "wrap", alignItems: "flex-start" } : {}
2926
- } }, M && M.zone === r.id && M.idx === b && /* @__PURE__ */ e.createElement("div", { style: { ...Z.dropLine, top: -2 } }), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", gap: "8px", minWidth: 0, flex: 1 } }, /* @__PURE__ */ e.createElement(z.DragIndicator, null), /* @__PURE__ */ e.createElement("b", { style: { fontWeight: 500, display: "block", minWidth: 0, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } }, I)), r.id === "vals" && /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", gap: "4px", marginLeft: "8px", flexWrap: "nowrap", flexShrink: 0 } }, /* @__PURE__ */ e.createElement("select", { value: p.agg, onChange: (C) => Wt(b, C.target.value), style: { ...ue, width: "74px" }, title: "Aggregation" }, /* @__PURE__ */ e.createElement("option", { value: "sum" }, "Sum"), /* @__PURE__ */ e.createElement("option", { value: "avg" }, "Avg"), /* @__PURE__ */ e.createElement("option", { value: "count" }, "Cnt"), /* @__PURE__ */ e.createElement("option", { value: "min" }, "Min"), /* @__PURE__ */ e.createElement("option", { value: "max" }, "Max"), /* @__PURE__ */ e.createElement("option", { value: "weighted_avg" }, "WAvg"), /* @__PURE__ */ e.createElement("option", { value: "array_agg" }, "Series")), Ht(p.agg) && /* @__PURE__ */ e.createElement("select", { value: p.weightField || "", onChange: (C) => Fr(b, C.target.value), style: { ...ue, width: "92px" }, title: "Weight field" }, /* @__PURE__ */ e.createElement("option", { value: "", disabled: !0 }, "Weight"), J.map((C) => /* @__PURE__ */ e.createElement("option", { key: C, value: C }, X(C)))), /* @__PURE__ */ e.createElement("select", { value: p.windowFn || "none", onChange: (C) => zr(b, C.target.value), style: { ...ue, width: "56px" } }, /* @__PURE__ */ e.createElement("option", { value: "none" }, "Norm"), /* @__PURE__ */ e.createElement("option", { value: "percent_of_row" }, "%Row"), /* @__PURE__ */ e.createElement("option", { value: "percent_of_col" }, "%Col"), /* @__PURE__ */ e.createElement("option", { value: "percent_of_grand_total" }, "%Tot"))), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "4px", marginLeft: "auto", alignItems: "center" } }, r.id === "filter" && /* @__PURE__ */ e.createElement("div", { onClick: (C) => Mr(C, S), style: { cursor: "pointer", display: "flex", alignItems: "center", padding: "2px", borderRadius: "4px" } }, /* @__PURE__ */ e.createElement(z.Filter, null)), /* @__PURE__ */ e.createElement("span", { onClick: () => {
2927
- if (q && typeof i == "function") {
2928
- i((C) => ({
2929
- ...Pe(C),
2930
- placement: "none"
2931
- }));
2932
- return;
2933
- }
2934
- if (r.id === "filter") {
2935
- const C = { ...ae };
2936
- delete C[S], at(C);
2937
- }
2938
- r.id === "rows" && l((C) => C.filter((j) => j !== S)), r.id === "cols" && u((C) => C.filter((j) => j !== S)), r.id === "vals" && Ie(b);
2939
- }, style: { cursor: "pointer", color: "#9CA3AF", display: "flex", alignItems: "center" } }, /* @__PURE__ */ e.createElement(z.Close, null))), r.id === "filter" && Ve.columnId === S && /* @__PURE__ */ e.createElement(
2940
- Yr,
2941
- {
2942
- column: { header: I, id: S },
2943
- anchorEl: Ve.anchorEl,
2944
- onClose: _r,
2945
- onFilter: (C) => U(S, C),
2946
- currentFilter: ae[S],
2947
- options: Tt(S),
2948
- optionMeta: Oe && Oe[S],
2949
- onSearchOptions: je ? (C) => V && V(S, { search: C, offset: 0 }) : void 0,
2950
- onLoadMoreOptions: je ? (C, j) => V && V(S, { search: C, offset: j }) : void 0,
2951
- theme: c
3125
+ "aria-grabbed": G && G.zone === b && G.field === r ? "true" : "false",
3126
+ "aria-label": `Move ${p}`,
3127
+ onDragStart: (S) => H(S, r, b),
3128
+ onDragEnd: F,
3129
+ onKeyDown: (S) => Ft(S, r, b, -1, p),
3130
+ title: f ? "Drag to Rows or Columns to show measure names" : `Move ${X(r)}`,
3131
+ style: {
3132
+ padding: "4px 8px",
3133
+ fontSize: "11px",
3134
+ lineHeight: 1.2,
3135
+ fontWeight: f ? 700 : 500,
3136
+ fontFamily: "'Inter', ui-sans-serif, system-ui, sans-serif",
3137
+ borderRadius: c.radiusSm || c.radius || "10px",
3138
+ border: f ? `1px dashed ${c.primary}` : `1px solid ${c.isDark ? c.border : "#D7DDEA"}`,
3139
+ background: f ? `${c.primary}12` : c.isDark ? c.background : c.surfaceInset || "#ffffff",
3140
+ color: f ? c.primary : c.isDark ? c.text : "#334155",
3141
+ display: "inline-flex",
3142
+ alignItems: "center",
3143
+ gap: "4px",
3144
+ boxShadow: c.isDark ? "none" : c.shadowInset || "0 1px 2px rgba(0,0,0,0.04)",
3145
+ cursor: "grab",
3146
+ userSelect: "none",
3147
+ minHeight: "24px"
2952
3148
  }
2953
- ), r.id === "vals" && /* @__PURE__ */ e.createElement(
2954
- dr,
2955
- {
2956
- item: p,
2957
- idx: b,
2958
- setValConfigs: d,
2959
- theme: c,
2960
- valueSelectStyle: ue,
2961
- colFields: g,
2962
- fixedSparklineValueKeySet: st,
2963
- showNotification: w
2964
- }
2965
- ), M && M.zone === r.id && M.idx === b + 1 && /* @__PURE__ */ e.createElement("div", { style: { ...Z.dropLine, bottom: -2 } })),
2966
- r.id === "filter" && ae[S] && ae[S].conditions && /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", color: c.primary, padding: "0 8px 4px 8px", marginTop: "-4px" } }, ae[S].conditions.map((C) => `${C.type}: ${C.value}${C.caseSensitive ? " (Match Case)" : ""}`).join(` ${ae[S].operator} `))
3149
+ },
3150
+ f && /* @__PURE__ */ e.createElement(z.Sigma, null),
3151
+ p
2967
3152
  );
2968
- }),
2969
- f.length === 0 && /* @__PURE__ */ e.createElement("div", { style: { opacity: 0.5, fontSize: "11px", padding: "8px", textAlign: "center", pointerEvents: "none" } }, "Drag fields here"),
2970
- /* @__PURE__ */ e.createElement("div", { style: { height: 20 }, onDragOver: (p) => K(p, r.id, f.length), onDrop: (p) => x(p, r.id) })
2971
- )
2972
- ));
2973
- })) : /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "16px", height: "100%", overflow: "hidden" } }, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "10px", padding: "8px", background: c.headerBg, borderRadius: "8px", boxShadow: "0 1px 3px rgba(0,0,0,0.08)" } }, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", background: c.background, borderRadius: "6px", padding: "8px 12px", border: `2px solid ${c.border}`, transition: "border-color 0.2s" } }, /* @__PURE__ */ e.createElement(z.Search, null), /* @__PURE__ */ e.createElement(
2974
- "input",
2975
- {
2976
- placeholder: "Search columns...",
2977
- value: k,
2978
- onChange: (r) => P(r.target.value),
2979
- style: {
2980
- border: "none",
2981
- background: "transparent",
2982
- marginLeft: "10px",
2983
- outline: "none",
2984
- width: "100%",
2985
- color: c.text,
2986
- fontSize: "13px",
2987
- fontWeight: 500
3153
+ }
3154
+ ),
3155
+ De.length > 8 && ct.length === 0 && /* @__PURE__ */ e.createElement("div", { style: { width: "100%", padding: "8px 2px", fontSize: "11px", color: c.textSec } }, "No fields match the current search.")
3156
+ )), Dr.map(
3157
+ /** @param {any} [zone] @returns {any} */
3158
+ (r) => {
3159
+ const f = Be[r.id] || [];
3160
+ return /* @__PURE__ */ e.createElement("div", { key: r.id, style: { marginBottom: "20px" } }, /* @__PURE__ */ e.createElement("div", { style: Y.sectionTitle }, r.icon, r.label), r.id === "vals" && /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", gap: "8px", padding: "0 4px 8px 4px", flexWrap: "wrap" } }, /* @__PURE__ */ e.createElement(
3161
+ "button",
3162
+ {
3163
+ type: "button",
3164
+ onClick: Bt,
3165
+ style: {
3166
+ border: `1px solid ${c.primary}66`,
3167
+ background: `${c.primary}12`,
3168
+ color: c.primary,
3169
+ borderRadius: "999px",
3170
+ cursor: "pointer",
3171
+ padding: "4px 10px",
3172
+ fontSize: "11px",
3173
+ fontWeight: 700
3174
+ }
3175
+ },
3176
+ "+ Add Formula"
3177
+ ), /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", color: c.textSec } }, Ae, " value measure", Ae === 1 ? "" : "s", " available"), me > 0 && /* @__PURE__ */ e.createElement("span", { style: { fontSize: "10px", color: c.textSec } }, me, " formula", me === 1 ? "" : "s"), /* @__PURE__ */ e.createElement(
3178
+ Qt,
3179
+ {
3180
+ measureAxis: $,
3181
+ setMeasureAxis: i,
3182
+ theme: c,
3183
+ valueSelectStyle: ue,
3184
+ regularValueCount: Ae
3185
+ }
3186
+ )), r.id === "rows" && a.length > 0 && /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "4px", padding: "0 4px 6px 4px" } }, /* @__PURE__ */ e.createElement(
3187
+ "button",
3188
+ {
3189
+ title: "Expand all hierarchy levels",
3190
+ onClick: () => ee(!0),
3191
+ style: { flex: 1, border: `1px solid ${c.primary}`, background: c.select, cursor: "pointer", padding: "3px 6px", fontSize: "11px", color: c.primary, borderRadius: "4px", fontWeight: 600 }
3192
+ },
3193
+ "+ Expand All"
3194
+ ), /* @__PURE__ */ e.createElement(
3195
+ "button",
3196
+ {
3197
+ title: "Collapse all rows",
3198
+ onClick: () => ee(!1),
3199
+ style: { flex: 1, border: `1px solid ${c.border}`, background: c.background, cursor: "pointer", padding: "3px 6px", fontSize: "11px", color: c.textSec, borderRadius: "4px" }
3200
+ },
3201
+ "- Collapse All"
3202
+ )), /* @__PURE__ */ e.createElement(
3203
+ qt,
3204
+ {
3205
+ panelId: r.id,
3206
+ panelLabel: r.label,
3207
+ size: Ue && Ue[r.id],
3208
+ onSizeChange: zt,
3209
+ theme: c,
3210
+ outerStyle: _t,
3211
+ contentStyle: { padding: `${Mt} 12px 12px ${Mt}` }
3212
+ },
3213
+ /* @__PURE__ */ e.createElement(
3214
+ "div",
3215
+ {
3216
+ "data-sidebar-drop-zone": r.id,
3217
+ role: "group",
3218
+ tabIndex: 0,
3219
+ "aria-label": `${r.label} drop zone`,
3220
+ "aria-describedby": "pivot-sidebar-keyboard-dnd-help",
3221
+ onKeyDown: (p) => Ar(p, r.id),
3222
+ onDragOver: (p) => {
3223
+ p.target === p.currentTarget ? K(p, r.id, f.length) : (p.preventDefault(), p.dataTransfer && (p.dataTransfer.dropEffect = "move"));
3224
+ },
3225
+ onDrop: (p) => x(p, r.id)
3226
+ },
3227
+ f.map(
3228
+ /** @param {any} [item] @param {any} [idx] @returns {any} */
3229
+ (p, b) => {
3230
+ const S = r.id === "vals" ? p.field : p, I = r.id === "vals" ? p.agg === "formula" ? p.label || "Formula" : X(p.field) : X(p), q = (r.id === "rows" || r.id === "cols") && S === de && Rt.placement !== "none";
3231
+ return /* @__PURE__ */ e.createElement(
3232
+ "div",
3233
+ {
3234
+ key: b,
3235
+ draggable: !0,
3236
+ "data-sidebar-field-chip": "zone",
3237
+ role: "button",
3238
+ tabIndex: 0,
3239
+ "aria-describedby": "pivot-sidebar-keyboard-dnd-help",
3240
+ "aria-grabbed": G && G.zone === r.id && G.idx === b ? "true" : "false",
3241
+ "aria-label": `Move ${I}`,
3242
+ onKeyDown: (C) => Ft(C, p, r.id, b, I),
3243
+ onDragStart: (C) => H(C, p, r.id, b),
3244
+ onDragOver: (C) => K(C, r.id, b),
3245
+ onDragEnd: F
3246
+ },
3247
+ r.id === "vals" && p.agg === "formula" ? /* @__PURE__ */ e.createElement(
3248
+ Jt,
3249
+ {
3250
+ item: p,
3251
+ idx: b,
3252
+ selected: p.field === ke,
3253
+ onSelect: It,
3254
+ onRemove: Ie,
3255
+ setValConfigs: d,
3256
+ theme: c,
3257
+ styles: Y,
3258
+ dropLine: M,
3259
+ zoneId: r.id,
3260
+ valueSelectStyle: ue,
3261
+ colFields: g,
3262
+ fixedSparklineValueKeySet: st,
3263
+ showNotification: w,
3264
+ serverError: he && he[p.field] || null
3265
+ }
3266
+ ) : /* @__PURE__ */ e.createElement("div", { style: {
3267
+ ...Y.chip,
3268
+ ...r.id === "vals" ? { flexWrap: "wrap", alignItems: "flex-start" } : {}
3269
+ } }, M && M.zone === r.id && M.idx === b && /* @__PURE__ */ e.createElement("div", { style: { ...Y.dropLine, top: -2 } }), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", gap: "8px", minWidth: 0, flex: 1 } }, /* @__PURE__ */ e.createElement(z.DragIndicator, null), /* @__PURE__ */ e.createElement("b", { style: { fontWeight: 500, display: "block", minWidth: 0, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } }, I)), r.id === "vals" && /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", gap: "4px", marginLeft: "8px", flexWrap: "nowrap", flexShrink: 0 } }, /* @__PURE__ */ e.createElement("select", { value: p.agg, onChange: (C) => Wt(b, C.target.value), style: { ...ue, width: "74px" }, title: "Aggregation" }, /* @__PURE__ */ e.createElement("option", { value: "sum" }, "Sum"), /* @__PURE__ */ e.createElement("option", { value: "avg" }, "Avg"), /* @__PURE__ */ e.createElement("option", { value: "count" }, "Cnt"), /* @__PURE__ */ e.createElement("option", { value: "min" }, "Min"), /* @__PURE__ */ e.createElement("option", { value: "max" }, "Max"), /* @__PURE__ */ e.createElement("option", { value: "weighted_avg" }, "WAvg"), /* @__PURE__ */ e.createElement("option", { value: "array_agg" }, "Series")), Ht(p.agg) && /* @__PURE__ */ e.createElement("select", { value: p.weightField || "", onChange: (C) => Fr(b, C.target.value), style: { ...ue, width: "92px" }, title: "Weight field" }, /* @__PURE__ */ e.createElement("option", { value: "", disabled: !0 }, "Weight"), J.map(
3270
+ /** @param {any} [fieldName] @returns {any} */
3271
+ (C) => /* @__PURE__ */ e.createElement("option", { key: C, value: C }, X(C))
3272
+ )), /* @__PURE__ */ e.createElement("select", { value: p.windowFn || "none", onChange: (C) => zr(b, C.target.value), style: { ...ue, width: "56px" } }, /* @__PURE__ */ e.createElement("option", { value: "none" }, "Norm"), /* @__PURE__ */ e.createElement("option", { value: "percent_of_row" }, "%Row"), /* @__PURE__ */ e.createElement("option", { value: "percent_of_col" }, "%Col"), /* @__PURE__ */ e.createElement("option", { value: "percent_of_grand_total" }, "%Tot"))), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "4px", marginLeft: "auto", alignItems: "center" } }, r.id === "filter" && /* @__PURE__ */ e.createElement("div", { onClick: (C) => Mr(C, S), style: { cursor: "pointer", display: "flex", alignItems: "center", padding: "2px", borderRadius: "4px" } }, /* @__PURE__ */ e.createElement(z.Filter, null)), /* @__PURE__ */ e.createElement("span", { onClick: () => {
3273
+ if (q && typeof i == "function") {
3274
+ i(
3275
+ /** @param {any} [previous] @returns {any} */
3276
+ (C) => ({
3277
+ ...Pe(C),
3278
+ placement: "none"
3279
+ })
3280
+ );
3281
+ return;
3282
+ }
3283
+ if (r.id === "filter") {
3284
+ const C = { ...ae };
3285
+ delete C[S], at(C);
3286
+ }
3287
+ r.id === "rows" && l(
3288
+ /** @param {any} [p] @returns {any} */
3289
+ (C) => C.filter(
3290
+ /** @param {any} [x] @returns {any} */
3291
+ (j) => j !== S
3292
+ )
3293
+ ), r.id === "cols" && u(
3294
+ /** @param {any} [p] @returns {any} */
3295
+ (C) => C.filter(
3296
+ /** @param {any} [x] @returns {any} */
3297
+ (j) => j !== S
3298
+ )
3299
+ ), r.id === "vals" && Ie(b);
3300
+ }, style: { cursor: "pointer", color: "#9CA3AF", display: "flex", alignItems: "center" } }, /* @__PURE__ */ e.createElement(z.Close, null))), r.id === "filter" && Ve.columnId === S && /* @__PURE__ */ e.createElement(
3301
+ Zr,
3302
+ {
3303
+ column: { header: I, id: S },
3304
+ anchorEl: Ve.anchorEl,
3305
+ onClose: _r,
3306
+ onFilter: (
3307
+ /** @param {any} [filterValue] @returns {any} */
3308
+ ((C) => U(S, C))
3309
+ ),
3310
+ currentFilter: ae[S],
3311
+ options: Tt(S),
3312
+ optionMeta: Oe && Oe[S],
3313
+ onSearchOptions: je ? (
3314
+ /** @param {any} [search] @returns {any} */
3315
+ ((C) => V && V(S, { search: C, offset: 0 }))
3316
+ ) : void 0,
3317
+ onLoadMoreOptions: je ? (
3318
+ /** @param {any} [search] @param {any} [offset] @returns {any} */
3319
+ ((C, j) => V && V(S, { search: C, offset: j }))
3320
+ ) : void 0,
3321
+ theme: c
3322
+ }
3323
+ ), r.id === "vals" && /* @__PURE__ */ e.createElement(
3324
+ dr,
3325
+ {
3326
+ item: p,
3327
+ idx: b,
3328
+ setValConfigs: d,
3329
+ theme: c,
3330
+ valueSelectStyle: ue,
3331
+ colFields: g,
3332
+ fixedSparklineValueKeySet: st,
3333
+ showNotification: w
3334
+ }
3335
+ ), M && M.zone === r.id && M.idx === b + 1 && /* @__PURE__ */ e.createElement("div", { style: { ...Y.dropLine, bottom: -2 } })),
3336
+ r.id === "filter" && ae[S] && ae[S].conditions && /* @__PURE__ */ e.createElement("div", { style: { fontSize: "10px", color: c.primary, padding: "0 8px 4px 8px", marginTop: "-4px" } }, ae[S].conditions.map(
3337
+ /** @param {any} [c] @returns {any} */
3338
+ (C) => `${C.type}: ${C.value}${C.caseSensitive ? " (Match Case)" : ""}`
3339
+ ).join(` ${ae[S].operator} `))
3340
+ );
3341
+ }
3342
+ ),
3343
+ f.length === 0 && /* @__PURE__ */ e.createElement("div", { style: { opacity: 0.5, fontSize: "11px", padding: "8px", textAlign: "center", pointerEvents: "none" } }, "Drag fields here"),
3344
+ /* @__PURE__ */ e.createElement("div", { style: { height: 20 }, onDragOver: (p) => K(p, r.id, f.length), onDrop: (p) => x(p, r.id) })
3345
+ )
3346
+ ));
2988
3347
  }
2989
- }
2990
- ), k && /* @__PURE__ */ e.createElement(
2991
- "span",
2992
- {
2993
- onClick: () => P(""),
2994
- style: {
2995
- cursor: "pointer",
2996
- display: "flex",
2997
- padding: "4px",
2998
- borderRadius: "4px",
2999
- background: c.hover,
3000
- transition: "background 0.2s"
3001
- },
3002
- onMouseEnter: (r) => r.currentTarget.style.background = c.select,
3003
- onMouseLeave: (r) => r.currentTarget.style.background = c.hover
3004
- },
3005
- /* @__PURE__ */ e.createElement(z.Close, null)
3006
- )), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap" } }, [
3007
- { value: "all", label: "All", icon: "📊" },
3008
- { value: "number", label: "Numbers", icon: "🔢" },
3009
- { value: "string", label: "Text", icon: "📝" },
3010
- { value: "date", label: "Dates", icon: "📅" }
3011
- ].map((r) => /* @__PURE__ */ e.createElement(
3012
- "button",
3013
- {
3014
- key: r.value,
3015
- onClick: () => A(r.value),
3016
- style: {
3017
- padding: "6px 12px",
3018
- borderRadius: "6px",
3019
- border: "none",
3020
- background: o === r.value ? c.primary : c.background,
3021
- color: o === r.value ? "#fff" : c.text,
3022
- cursor: "pointer",
3023
- fontSize: "11px",
3024
- fontWeight: 600,
3025
- display: "flex",
3026
- alignItems: "center",
3027
- gap: "4px",
3028
- transition: "all 0.2s",
3029
- boxShadow: o === r.value ? "0 2px 4px rgba(0,0,0,0.1)" : "none"
3030
- },
3031
- onMouseEnter: (f) => {
3032
- o !== r.value && (f.currentTarget.style.background = c.hover);
3033
- },
3034
- onMouseLeave: (f) => {
3035
- o !== r.value && (f.currentTarget.style.background = c.background);
3348
+ )) : /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "16px", height: "100%", overflow: "hidden" } }, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "10px", padding: "8px", background: c.headerBg, borderRadius: "8px", boxShadow: "0 1px 3px rgba(0,0,0,0.08)" } }, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", alignItems: "center", background: c.background, borderRadius: "6px", padding: "8px 12px", border: `2px solid ${c.border}`, transition: "border-color 0.2s" } }, /* @__PURE__ */ e.createElement(z.Search, null), /* @__PURE__ */ e.createElement(
3349
+ "input",
3350
+ {
3351
+ placeholder: "Search columns...",
3352
+ value: k,
3353
+ onChange: (r) => P(r.target.value),
3354
+ style: {
3355
+ border: "none",
3356
+ background: "transparent",
3357
+ marginLeft: "10px",
3358
+ outline: "none",
3359
+ width: "100%",
3360
+ color: c.text,
3361
+ fontSize: "13px",
3362
+ fontWeight: 500
3363
+ }
3036
3364
  }
3037
- },
3038
- /* @__PURE__ */ e.createElement("span", null, r.icon),
3039
- /* @__PURE__ */ e.createElement("span", null, r.label)
3040
- )))), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", padding: "0 8px" } }, /* @__PURE__ */ e.createElement(
3041
- "button",
3042
- {
3043
- onClick: () => y.toggleAllColumnsVisible(!0),
3044
- style: {
3045
- ...Z.btn,
3046
- padding: "8px 12px",
3047
- fontSize: "11px",
3048
- flex: 1,
3049
- justifyContent: "center",
3050
- background: c.background,
3051
- fontWeight: 600,
3052
- boxShadow: "0 1px 2px rgba(0,0,0,0.05)",
3053
- transition: "all 0.2s"
3054
- },
3055
- onMouseEnter: (r) => r.currentTarget.style.boxShadow = "0 2px 4px rgba(0,0,0,0.1)",
3056
- onMouseLeave: (r) => r.currentTarget.style.boxShadow = "0 1px 2px rgba(0,0,0,0.05)"
3057
- },
3058
- /* @__PURE__ */ e.createElement(z.Visibility, { style: { fontSize: "14px" } }),
3059
- /* @__PURE__ */ e.createElement("span", null, "Show All")
3060
- ), /* @__PURE__ */ e.createElement(
3061
- "button",
3062
- {
3063
- onClick: () => y.toggleAllColumnsVisible(!1),
3064
- style: {
3065
- ...Z.btn,
3066
- padding: "8px 12px",
3067
- fontSize: "11px",
3068
- flex: 1,
3069
- justifyContent: "center",
3070
- background: c.background,
3071
- fontWeight: 600,
3072
- boxShadow: "0 1px 2px rgba(0,0,0,0.05)",
3073
- transition: "all 0.2s"
3365
+ ), k && /* @__PURE__ */ e.createElement(
3366
+ "span",
3367
+ {
3368
+ onClick: () => P(""),
3369
+ style: {
3370
+ cursor: "pointer",
3371
+ display: "flex",
3372
+ padding: "4px",
3373
+ borderRadius: "4px",
3374
+ background: c.hover,
3375
+ transition: "background 0.2s"
3376
+ },
3377
+ onMouseEnter: (r) => r.currentTarget.style.background = c.select,
3378
+ onMouseLeave: (r) => r.currentTarget.style.background = c.hover
3074
3379
  },
3075
- onMouseEnter: (r) => r.currentTarget.style.boxShadow = "0 2px 4px rgba(0,0,0,0.1)",
3076
- onMouseLeave: (r) => r.currentTarget.style.boxShadow = "0 1px 2px rgba(0,0,0,0.05)"
3077
- },
3078
- /* @__PURE__ */ e.createElement(z.VisibilityOff, { style: { fontSize: "14px" } }),
3079
- /* @__PURE__ */ e.createElement("span", null, "Hide All")
3080
- ), /* @__PURE__ */ e.createElement(
3081
- "button",
3082
- {
3083
- onClick: () => te(!1),
3084
- style: {
3085
- ...Z.btn,
3086
- padding: "8px 12px",
3087
- fontSize: "11px",
3088
- flex: 1,
3089
- justifyContent: "center",
3090
- background: c.background,
3091
- fontWeight: 600,
3092
- boxShadow: "0 1px 2px rgba(0,0,0,0.05)",
3093
- transition: "all 0.2s"
3380
+ /* @__PURE__ */ e.createElement(z.Close, null)
3381
+ )), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap" } }, [
3382
+ { value: "all", label: "All", icon: "📊" },
3383
+ { value: "number", label: "Numbers", icon: "🔢" },
3384
+ { value: "string", label: "Text", icon: "📝" },
3385
+ { value: "date", label: "Dates", icon: "📅" }
3386
+ ].map((r) => /* @__PURE__ */ e.createElement(
3387
+ "button",
3388
+ {
3389
+ key: r.value,
3390
+ onClick: () => A(r.value),
3391
+ style: {
3392
+ padding: "6px 12px",
3393
+ borderRadius: "6px",
3394
+ border: "none",
3395
+ background: o === r.value ? c.primary : c.background,
3396
+ color: o === r.value ? "#fff" : c.text,
3397
+ cursor: "pointer",
3398
+ fontSize: "11px",
3399
+ fontWeight: 600,
3400
+ display: "flex",
3401
+ alignItems: "center",
3402
+ gap: "4px",
3403
+ transition: "all 0.2s",
3404
+ boxShadow: o === r.value ? "0 2px 4px rgba(0,0,0,0.1)" : "none"
3405
+ },
3406
+ onMouseEnter: (f) => {
3407
+ o !== r.value && (f.currentTarget.style.background = c.hover);
3408
+ },
3409
+ onMouseLeave: (f) => {
3410
+ o !== r.value && (f.currentTarget.style.background = c.background);
3411
+ }
3094
3412
  },
3095
- onMouseEnter: (r) => r.currentTarget.style.boxShadow = "0 2px 4px rgba(0,0,0,0.1)",
3096
- onMouseLeave: (r) => r.currentTarget.style.boxShadow = "0 1px 2px rgba(0,0,0,0.05)"
3097
- },
3098
- /* @__PURE__ */ e.createElement(z.Unpin, { style: { fontSize: "14px" } }),
3099
- /* @__PURE__ */ e.createElement("span", null, "Unpin All")
3100
- )), R.size > 0 && /* @__PURE__ */ e.createElement("div", { style: {
3101
- display: "flex",
3102
- flexDirection: "column",
3103
- gap: "8px",
3104
- background: `linear-gradient(135deg, ${c.select}ee, ${c.select}dd)`,
3105
- padding: "12px",
3106
- borderRadius: "8px",
3107
- border: `2px solid ${c.primary}66`,
3108
- boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
3109
- margin: "0 8px"
3110
- } }, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" } }, /* @__PURE__ */ e.createElement("span", { style: {
3111
- fontSize: "12px",
3112
- fontWeight: 700,
3113
- padding: "4px 10px",
3114
- color: c.primary,
3115
- background: c.background,
3116
- borderRadius: "6px",
3117
- boxShadow: "0 1px 2px rgba(0,0,0,0.05)"
3118
- } }, R.size, " Column", R.size > 1 ? "s" : "", " Selected"), /* @__PURE__ */ e.createElement(
3119
- "button",
3120
- {
3121
- onClick: () => B(/* @__PURE__ */ new Set()),
3122
- style: {
3123
- border: "none",
3124
- background: c.background,
3125
- cursor: "pointer",
3126
- display: "flex",
3127
- color: c.textSec,
3128
- padding: "4px",
3129
- borderRadius: "4px",
3130
- transition: "all 0.2s"
3413
+ /* @__PURE__ */ e.createElement("span", null, r.icon),
3414
+ /* @__PURE__ */ e.createElement("span", null, r.label)
3415
+ )))), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", padding: "0 8px" } }, /* @__PURE__ */ e.createElement(
3416
+ "button",
3417
+ {
3418
+ onClick: () => y.toggleAllColumnsVisible(!0),
3419
+ style: {
3420
+ ...Y.btn,
3421
+ padding: "8px 12px",
3422
+ fontSize: "11px",
3423
+ flex: 1,
3424
+ justifyContent: "center",
3425
+ background: c.background,
3426
+ fontWeight: 600,
3427
+ boxShadow: "0 1px 2px rgba(0,0,0,0.05)",
3428
+ transition: "all 0.2s"
3429
+ },
3430
+ onMouseEnter: (r) => r.currentTarget.style.boxShadow = "0 2px 4px rgba(0,0,0,0.1)",
3431
+ onMouseLeave: (r) => r.currentTarget.style.boxShadow = "0 1px 2px rgba(0,0,0,0.05)"
3131
3432
  },
3132
- onMouseEnter: (r) => r.currentTarget.style.background = c.hover,
3133
- onMouseLeave: (r) => r.currentTarget.style.background = c.background
3134
- },
3135
- /* @__PURE__ */ e.createElement(z.Close, null)
3136
- )), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap" } }, /* @__PURE__ */ e.createElement(
3137
- "button",
3138
- {
3139
- onClick: () => {
3140
- Array.from(R).forEach((r) => Y(r, "left")), B(/* @__PURE__ */ new Set());
3433
+ /* @__PURE__ */ e.createElement(z.Visibility, { style: { fontSize: "14px" } }),
3434
+ /* @__PURE__ */ e.createElement("span", null, "Show All")
3435
+ ), /* @__PURE__ */ e.createElement(
3436
+ "button",
3437
+ {
3438
+ onClick: () => y.toggleAllColumnsVisible(!1),
3439
+ style: {
3440
+ ...Y.btn,
3441
+ padding: "8px 12px",
3442
+ fontSize: "11px",
3443
+ flex: 1,
3444
+ justifyContent: "center",
3445
+ background: c.background,
3446
+ fontWeight: 600,
3447
+ boxShadow: "0 1px 2px rgba(0,0,0,0.05)",
3448
+ transition: "all 0.2s"
3449
+ },
3450
+ onMouseEnter: (r) => r.currentTarget.style.boxShadow = "0 2px 4px rgba(0,0,0,0.1)",
3451
+ onMouseLeave: (r) => r.currentTarget.style.boxShadow = "0 1px 2px rgba(0,0,0,0.05)"
3141
3452
  },
3142
- style: {
3143
- ...Z.btn,
3144
- padding: "6px 12px",
3145
- fontSize: "11px",
3146
- background: c.background,
3147
- flex: 1,
3148
- justifyContent: "center",
3149
- fontWeight: 600,
3150
- boxShadow: "0 1px 2px rgba(0,0,0,0.05)",
3151
- transition: "all 0.2s"
3453
+ /* @__PURE__ */ e.createElement(z.VisibilityOff, { style: { fontSize: "14px" } }),
3454
+ /* @__PURE__ */ e.createElement("span", null, "Hide All")
3455
+ ), /* @__PURE__ */ e.createElement(
3456
+ "button",
3457
+ {
3458
+ onClick: () => te(!1),
3459
+ style: {
3460
+ ...Y.btn,
3461
+ padding: "8px 12px",
3462
+ fontSize: "11px",
3463
+ flex: 1,
3464
+ justifyContent: "center",
3465
+ background: c.background,
3466
+ fontWeight: 600,
3467
+ boxShadow: "0 1px 2px rgba(0,0,0,0.05)",
3468
+ transition: "all 0.2s"
3469
+ },
3470
+ onMouseEnter: (r) => r.currentTarget.style.boxShadow = "0 2px 4px rgba(0,0,0,0.1)",
3471
+ onMouseLeave: (r) => r.currentTarget.style.boxShadow = "0 1px 2px rgba(0,0,0,0.05)"
3152
3472
  },
3153
- onMouseEnter: (r) => r.currentTarget.style.boxShadow = "0 2px 4px rgba(0,0,0,0.1)",
3154
- onMouseLeave: (r) => r.currentTarget.style.boxShadow = "0 1px 2px rgba(0,0,0,0.05)"
3155
- },
3156
- /* @__PURE__ */ e.createElement(z.PinLeft, null),
3157
- /* @__PURE__ */ e.createElement("span", null, "Pin Left")
3158
- ), /* @__PURE__ */ e.createElement(
3159
- "button",
3160
- {
3161
- onClick: () => {
3162
- Array.from(R).forEach((r) => Y(r, !1)), B(/* @__PURE__ */ new Set());
3473
+ /* @__PURE__ */ e.createElement(z.Unpin, { style: { fontSize: "14px" } }),
3474
+ /* @__PURE__ */ e.createElement("span", null, "Unpin All")
3475
+ )), R.size > 0 && /* @__PURE__ */ e.createElement("div", { style: {
3476
+ display: "flex",
3477
+ flexDirection: "column",
3478
+ gap: "8px",
3479
+ background: `linear-gradient(135deg, ${c.select}ee, ${c.select}dd)`,
3480
+ padding: "12px",
3481
+ borderRadius: "8px",
3482
+ border: `2px solid ${c.primary}66`,
3483
+ boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
3484
+ margin: "0 8px"
3485
+ } }, /* @__PURE__ */ e.createElement("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" } }, /* @__PURE__ */ e.createElement("span", { style: {
3486
+ fontSize: "12px",
3487
+ fontWeight: 700,
3488
+ padding: "4px 10px",
3489
+ color: c.primary,
3490
+ background: c.background,
3491
+ borderRadius: "6px",
3492
+ boxShadow: "0 1px 2px rgba(0,0,0,0.05)"
3493
+ } }, R.size, " Column", R.size > 1 ? "s" : "", " Selected"), /* @__PURE__ */ e.createElement(
3494
+ "button",
3495
+ {
3496
+ onClick: () => B(/* @__PURE__ */ new Set()),
3497
+ style: {
3498
+ border: "none",
3499
+ background: c.background,
3500
+ cursor: "pointer",
3501
+ display: "flex",
3502
+ color: c.textSec,
3503
+ padding: "4px",
3504
+ borderRadius: "4px",
3505
+ transition: "all 0.2s"
3506
+ },
3507
+ onMouseEnter: (r) => r.currentTarget.style.background = c.hover,
3508
+ onMouseLeave: (r) => r.currentTarget.style.background = c.background
3163
3509
  },
3164
- style: {
3165
- ...Z.btn,
3166
- padding: "6px 12px",
3167
- fontSize: "11px",
3168
- background: c.background,
3169
- flex: 1,
3170
- justifyContent: "center",
3171
- fontWeight: 600,
3172
- boxShadow: "0 1px 2px rgba(0,0,0,0.05)",
3173
- transition: "all 0.2s"
3510
+ /* @__PURE__ */ e.createElement(z.Close, null)
3511
+ )), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap" } }, /* @__PURE__ */ e.createElement(
3512
+ "button",
3513
+ {
3514
+ onClick: () => {
3515
+ Array.from(R).forEach((r) => Z(r, "left")), B(/* @__PURE__ */ new Set());
3516
+ },
3517
+ style: {
3518
+ ...Y.btn,
3519
+ padding: "6px 12px",
3520
+ fontSize: "11px",
3521
+ background: c.background,
3522
+ flex: 1,
3523
+ justifyContent: "center",
3524
+ fontWeight: 600,
3525
+ boxShadow: "0 1px 2px rgba(0,0,0,0.05)",
3526
+ transition: "all 0.2s"
3527
+ },
3528
+ onMouseEnter: (r) => r.currentTarget.style.boxShadow = "0 2px 4px rgba(0,0,0,0.1)",
3529
+ onMouseLeave: (r) => r.currentTarget.style.boxShadow = "0 1px 2px rgba(0,0,0,0.05)"
3174
3530
  },
3175
- onMouseEnter: (r) => r.currentTarget.style.boxShadow = "0 2px 4px rgba(0,0,0,0.1)",
3176
- onMouseLeave: (r) => r.currentTarget.style.boxShadow = "0 1px 2px rgba(0,0,0,0.05)"
3177
- },
3178
- /* @__PURE__ */ e.createElement(z.Unpin, null),
3179
- /* @__PURE__ */ e.createElement("span", null, "Unpin")
3180
- ), /* @__PURE__ */ e.createElement(
3181
- "button",
3182
- {
3183
- onClick: () => {
3184
- Array.from(R).forEach((r) => Y(r, "right")), B(/* @__PURE__ */ new Set());
3531
+ /* @__PURE__ */ e.createElement(z.PinLeft, null),
3532
+ /* @__PURE__ */ e.createElement("span", null, "Pin Left")
3533
+ ), /* @__PURE__ */ e.createElement(
3534
+ "button",
3535
+ {
3536
+ onClick: () => {
3537
+ Array.from(R).forEach((r) => Z(r, !1)), B(/* @__PURE__ */ new Set());
3538
+ },
3539
+ style: {
3540
+ ...Y.btn,
3541
+ padding: "6px 12px",
3542
+ fontSize: "11px",
3543
+ background: c.background,
3544
+ flex: 1,
3545
+ justifyContent: "center",
3546
+ fontWeight: 600,
3547
+ boxShadow: "0 1px 2px rgba(0,0,0,0.05)",
3548
+ transition: "all 0.2s"
3549
+ },
3550
+ onMouseEnter: (r) => r.currentTarget.style.boxShadow = "0 2px 4px rgba(0,0,0,0.1)",
3551
+ onMouseLeave: (r) => r.currentTarget.style.boxShadow = "0 1px 2px rgba(0,0,0,0.05)"
3185
3552
  },
3186
- style: {
3187
- ...Z.btn,
3188
- padding: "6px 12px",
3189
- fontSize: "11px",
3190
- background: c.background,
3191
- flex: 1,
3192
- justifyContent: "center",
3193
- fontWeight: 600,
3194
- boxShadow: "0 1px 2px rgba(0,0,0,0.05)",
3195
- transition: "all 0.2s"
3553
+ /* @__PURE__ */ e.createElement(z.Unpin, null),
3554
+ /* @__PURE__ */ e.createElement("span", null, "Unpin")
3555
+ ), /* @__PURE__ */ e.createElement(
3556
+ "button",
3557
+ {
3558
+ onClick: () => {
3559
+ Array.from(R).forEach((r) => Z(r, "right")), B(/* @__PURE__ */ new Set());
3560
+ },
3561
+ style: {
3562
+ ...Y.btn,
3563
+ padding: "6px 12px",
3564
+ fontSize: "11px",
3565
+ background: c.background,
3566
+ flex: 1,
3567
+ justifyContent: "center",
3568
+ fontWeight: 600,
3569
+ boxShadow: "0 1px 2px rgba(0,0,0,0.05)",
3570
+ transition: "all 0.2s"
3571
+ },
3572
+ onMouseEnter: (r) => r.currentTarget.style.boxShadow = "0 2px 4px rgba(0,0,0,0.1)",
3573
+ onMouseLeave: (r) => r.currentTarget.style.boxShadow = "0 1px 2px rgba(0,0,0,0.05)"
3196
3574
  },
3197
- onMouseEnter: (r) => r.currentTarget.style.boxShadow = "0 2px 4px rgba(0,0,0,0.1)",
3198
- onMouseLeave: (r) => r.currentTarget.style.boxShadow = "0 1px 2px rgba(0,0,0,0.05)"
3199
- },
3200
- /* @__PURE__ */ e.createElement(z.PinRight, null),
3201
- /* @__PURE__ */ e.createElement("span", null, "Pin Right")
3202
- ))), /* @__PURE__ */ e.createElement("div", { style: { flex: 1, overflowY: "auto", display: "flex", flexDirection: "column" } }, (() => {
3203
- const f = y.getAllColumns().filter((C) => !C.parent && C.id !== "no_data").filter((C) => {
3204
- if (o === "all") return !0;
3205
- let j = "string";
3206
- if (E.find((re) => C.id.includes(re.field)))
3207
- j = "number";
3208
- else if (Se && Se.length > 0) {
3209
- const re = Se[0];
3210
- let ne = re[C.id];
3211
- if (ne === void 0 && C.accessorFn)
3212
- try {
3213
- ne = C.accessorFn(re);
3214
- } catch {
3575
+ /* @__PURE__ */ e.createElement(z.PinRight, null),
3576
+ /* @__PURE__ */ e.createElement("span", null, "Pin Right")
3577
+ ))), /* @__PURE__ */ e.createElement("div", { style: { flex: 1, overflowY: "auto", display: "flex", flexDirection: "column" } }, (() => {
3578
+ const f = y.getAllColumns().filter(
3579
+ /** @param {any} [c] @returns {any} */
3580
+ (C) => !C.parent && C.id !== "no_data"
3581
+ ).filter(
3582
+ /** @param {any} [col] @returns {any} */
3583
+ (C) => {
3584
+ if (o === "all") return !0;
3585
+ let j = "string";
3586
+ if (E.find(
3587
+ /** @param {any} [v] @returns {any} */
3588
+ (re) => C.id.includes(re.field)
3589
+ ))
3590
+ j = "number";
3591
+ else if (Se && Se.length > 0) {
3592
+ const re = Se[0];
3593
+ let ne = re[C.id];
3594
+ if (ne === void 0 && C.accessorFn)
3595
+ try {
3596
+ ne = C.accessorFn(re);
3597
+ } catch {
3598
+ }
3599
+ typeof ne == "number" ? j = "number" : ne instanceof Date ? j = "date" : typeof ne == "string" && (!isNaN(Number(ne)) && ne.trim() !== "" ? j = "number" : !isNaN(Date.parse(ne)) && ne.includes("-") && (j = "date"));
3215
3600
  }
3216
- typeof ne == "number" ? j = "number" : ne instanceof Date ? j = "date" : typeof ne == "string" && (!isNaN(Number(ne)) && ne.trim() !== "" ? j = "number" : !isNaN(Date.parse(ne)) && ne.includes("-") && (j = "date"));
3217
- }
3218
- return j === o;
3219
- }), p = f.filter((C) => Je(C, "left")), b = f.filter((C) => Je(C, "right")), S = f.filter((C) => Je(C, "unpinned")), I = (C, j) => C.map((ie) => /* @__PURE__ */ e.createElement(
3220
- rr,
3221
- {
3222
- key: ie.id,
3223
- column: ie,
3224
- level: 0,
3225
- theme: c,
3226
- styles: Z,
3227
- handlePinColumn: Y,
3228
- colSearch: k,
3229
- selectedCols: R,
3230
- setSelectedCols: B,
3231
- onDrop: q,
3232
- sectionId: j
3233
- }
3234
- )), q = (C, j, ie) => {
3235
- let re;
3236
- const ne = L || { left: [], right: [] };
3237
- if (ie) {
3238
- const Le = j === "left" ? ne.left : j === "right" ? ne.right : null;
3239
- if (Le) {
3240
- if (re = Le.indexOf(ie), re === -1) {
3241
- const ft = y.getColumn(ie);
3242
- if (ft && Nr(ft)) {
3243
- const Ot = xt(ft).find((Tr) => Le.includes(Tr));
3244
- Ot && (re = Le.indexOf(Ot));
3601
+ return j === o;
3602
+ }
3603
+ ), p = f.filter(
3604
+ /** @param {any} [c] @returns {any} */
3605
+ (C) => Je(C, "left")
3606
+ ), b = f.filter(
3607
+ /** @param {any} [c] @returns {any} */
3608
+ (C) => Je(C, "right")
3609
+ ), S = f.filter(
3610
+ /** @param {any} [c] @returns {any} */
3611
+ (C) => Je(C, "unpinned")
3612
+ ), I = (C, j) => C.map(
3613
+ /** @param {any} [column] @returns {any} */
3614
+ (ie) => /* @__PURE__ */ e.createElement(
3615
+ rr,
3616
+ {
3617
+ key: ie.id,
3618
+ column: ie,
3619
+ level: 0,
3620
+ theme: c,
3621
+ styles: Y,
3622
+ handlePinColumn: Z,
3623
+ colSearch: k,
3624
+ selectedCols: R,
3625
+ setSelectedCols: B,
3626
+ onDrop: q,
3627
+ sectionId: j
3628
+ }
3629
+ )
3630
+ ), q = (C, j, ie) => {
3631
+ let re;
3632
+ const ne = L || { left: [], right: [] };
3633
+ if (ie) {
3634
+ const Le = j === "left" ? ne.left : j === "right" ? ne.right : null;
3635
+ if (Le) {
3636
+ if (re = Le.indexOf(ie), re === -1) {
3637
+ const ft = y.getColumn(ie);
3638
+ if (ft && Nr(ft)) {
3639
+ const Ot = xt(ft).find(
3640
+ /** @param {any} [id] @returns {any} */
3641
+ (Tr) => Le.includes(Tr)
3642
+ );
3643
+ Ot && (re = Le.indexOf(Ot));
3644
+ }
3245
3645
  }
3646
+ re === -1 && (re = void 0);
3246
3647
  }
3247
- re === -1 && (re = void 0);
3248
3648
  }
3249
- }
3250
- j === "left" ? Y(C, "left", re) : j === "right" ? Y(C, "right", re) : Y(C, !1);
3251
- };
3252
- return /* @__PURE__ */ e.createElement(e.Fragment, null, p.length > 0 && /* @__PURE__ */ e.createElement(
3253
- gt,
3254
- {
3255
- title: "Pinned Left",
3256
- count: p.length,
3257
- theme: c,
3258
- styles: Z,
3259
- sectionId: "left",
3260
- onDrop: q
3261
- },
3262
- I(p, "left")
3263
- ), b.length > 0 && /* @__PURE__ */ e.createElement(
3264
- gt,
3649
+ j === "left" ? Z(C, "left", re) : j === "right" ? Z(C, "right", re) : Z(C, !1);
3650
+ };
3651
+ return /* @__PURE__ */ e.createElement(e.Fragment, null, p.length > 0 && /* @__PURE__ */ e.createElement(
3652
+ gt,
3653
+ {
3654
+ title: "Pinned Left",
3655
+ count: p.length,
3656
+ theme: c,
3657
+ styles: Y,
3658
+ sectionId: "left",
3659
+ onDrop: q
3660
+ },
3661
+ I(p, "left")
3662
+ ), b.length > 0 && /* @__PURE__ */ e.createElement(
3663
+ gt,
3664
+ {
3665
+ title: "Pinned Right",
3666
+ count: b.length,
3667
+ theme: c,
3668
+ styles: Y,
3669
+ sectionId: "right",
3670
+ onDrop: q
3671
+ },
3672
+ I(b, "right")
3673
+ ), /* @__PURE__ */ e.createElement(
3674
+ gt,
3675
+ {
3676
+ title: "Columns",
3677
+ count: S.length,
3678
+ theme: c,
3679
+ styles: Y,
3680
+ sectionId: "unpinned",
3681
+ onDrop: q
3682
+ },
3683
+ I(S, "unpinned")
3684
+ ));
3685
+ })()), h && h.length > 0 && /* @__PURE__ */ e.createElement("div", { style: { padding: "8px", borderTop: `1px solid ${c.border}` } }, /* @__PURE__ */ e.createElement("div", { style: Y.sectionTitle }, "Pinning Presets"), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "4px", flexWrap: "wrap" } }, h.map(
3686
+ /** @param {any} [preset] @param {any} [i] @returns {any} */
3687
+ (r, f) => /* @__PURE__ */ e.createElement(
3688
+ "button",
3689
+ {
3690
+ key: f,
3691
+ onClick: () => {
3692
+ _(r.config), w(`Applied preset: ${r.name}`);
3693
+ },
3694
+ style: { ...Y.btn, fontSize: "11px", background: c.headerBg }
3695
+ },
3696
+ r.name
3697
+ )
3698
+ ))), /* @__PURE__ */ e.createElement("div", { style: { fontSize: "11px", color: c.textSec, fontStyle: "italic", padding: "8px", background: c.headerBg, borderTop: `1px solid ${c.border}44` } }, /* @__PURE__ */ e.createElement(z.Lock, { style: { verticalAlign: "middle", marginRight: "4px", opacity: 0.5 } }), "Drag columns or use pin icons to freeze areas."))), dt && /* @__PURE__ */ e.createElement(
3699
+ kn,
3265
3700
  {
3266
- title: "Pinned Right",
3267
- count: b.length,
3701
+ item: dt,
3702
+ idx: pt,
3703
+ valConfigs: E,
3704
+ setValConfigs: d,
3268
3705
  theme: c,
3269
- styles: Z,
3270
- sectionId: "right",
3271
- onDrop: q
3272
- },
3273
- I(b, "right")
3706
+ onClose: () => ge(null),
3707
+ onRemove: Ie,
3708
+ displayedColumnOptions: fr,
3709
+ availableRawFields: J,
3710
+ serverError: he && he[dt.field] || null
3711
+ }
3274
3712
  ), /* @__PURE__ */ e.createElement(
3275
- gt,
3713
+ "div",
3276
3714
  {
3277
- title: "Columns",
3278
- count: S.length,
3279
- theme: c,
3280
- styles: Z,
3281
- sectionId: "unpinned",
3282
- onDrop: q
3283
- },
3284
- I(S, "unpinned")
3285
- ));
3286
- })()), h && h.length > 0 && /* @__PURE__ */ e.createElement("div", { style: { padding: "8px", borderTop: `1px solid ${c.border}` } }, /* @__PURE__ */ e.createElement("div", { style: Z.sectionTitle }, "Pinning Presets"), /* @__PURE__ */ e.createElement("div", { style: { display: "flex", gap: "4px", flexWrap: "wrap" } }, h.map((r, f) => /* @__PURE__ */ e.createElement(
3287
- "button",
3288
- {
3289
- key: f,
3290
- onClick: () => {
3291
- _(r.config), w(`Applied preset: ${r.name}`);
3715
+ onMouseDown: $r,
3716
+ style: {
3717
+ position: "absolute",
3718
+ right: 0,
3719
+ top: 0,
3720
+ bottom: 0,
3721
+ width: "5px",
3722
+ cursor: "col-resize",
3723
+ zIndex: 10,
3724
+ background: "transparent"
3725
+ },
3726
+ title: "Drag to resize panel"
3292
3727
  },
3293
- style: { ...Z.btn, fontSize: "11px", background: c.headerBg }
3294
- },
3295
- r.name
3296
- )))), /* @__PURE__ */ e.createElement("div", { style: { fontSize: "11px", color: c.textSec, fontStyle: "italic", padding: "8px", background: c.headerBg, borderTop: `1px solid ${c.border}44` } }, /* @__PURE__ */ e.createElement(z.Lock, { style: { verticalAlign: "middle", marginRight: "4px", opacity: 0.5 } }), "Drag columns or use pin icons to freeze areas."))), dt && /* @__PURE__ */ e.createElement(
3297
- kn,
3298
- {
3299
- item: dt,
3300
- idx: pt,
3301
- valConfigs: E,
3302
- setValConfigs: d,
3303
- theme: c,
3304
- onClose: () => ge(null),
3305
- onRemove: Ie,
3306
- displayedColumnOptions: fr,
3307
- availableRawFields: J,
3308
- serverError: he && he[dt.field] || null
3309
- }
3310
- ), /* @__PURE__ */ e.createElement(
3311
- "div",
3312
- {
3313
- onMouseDown: $r,
3314
- style: {
3728
+ /* @__PURE__ */ e.createElement("div", { style: {
3315
3729
  position: "absolute",
3316
3730
  right: 0,
3317
3731
  top: 0,
3318
3732
  bottom: 0,
3319
- width: "5px",
3320
- cursor: "col-resize",
3321
- zIndex: 10,
3322
- background: "transparent"
3323
- },
3324
- title: "Drag to resize panel"
3325
- },
3326
- /* @__PURE__ */ e.createElement("div", { style: {
3327
- position: "absolute",
3328
- right: 0,
3329
- top: 0,
3330
- bottom: 0,
3331
- width: "2px",
3332
- background: c.border,
3333
- transition: "background 0.15s"
3334
- } })
3335
- ));
3336
- });
3733
+ width: "2px",
3734
+ background: c.border,
3735
+ transition: "background 0.15s"
3736
+ } })
3737
+ ));
3738
+ }
3739
+ );
3337
3740
  export {
3338
3741
  Fn as SidebarPanel
3339
3742
  };