react-semaphor 0.1.507 → 0.1.508

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 (247) hide show
  1. package/DATA_APP_SDK.md +56 -0
  2. package/dist/analytics-protocol/index.cjs +1 -1
  3. package/dist/analytics-protocol/index.js +194 -172
  4. package/dist/appearance/index.cjs +1 -1
  5. package/dist/appearance/index.js +1 -1
  6. package/dist/appearance-runtime/index.cjs +1 -1
  7. package/dist/appearance-runtime/index.js +1 -1
  8. package/dist/brand-studio/index.cjs +2 -2
  9. package/dist/brand-studio/index.js +139 -119
  10. package/dist/briefings/index.cjs +1 -1
  11. package/dist/briefings/index.js +3 -3
  12. package/dist/chunks/appearance-context-DzqCdhB4.cjs +1 -0
  13. package/dist/chunks/{appearance-context-XviHOhWJ.js → appearance-context-VJdrKi7r.js} +2 -1
  14. package/dist/chunks/{appearance-runtime-provider-D0xVQWnH.js → appearance-runtime-provider-CC4HT2Gi.js} +2 -2
  15. package/dist/chunks/{appearance-runtime-provider-Ca8rxO86.cjs → appearance-runtime-provider-D5pkvgE4.cjs} +1 -1
  16. package/dist/chunks/calculated-field-identity-BiTGmnST.cjs +1 -0
  17. package/dist/chunks/calculated-field-identity-CJL54uFx.js +1373 -0
  18. package/dist/chunks/{constants-NUleP4DY.js → card-config-utils-Bq1enstT.js} +260 -260
  19. package/dist/chunks/card-config-utils-CMO4_zVs.cjs +1 -0
  20. package/dist/chunks/{dashboard-briefing-launcher-DXTpU85p.js → dashboard-briefing-launcher-B9l0ZAbv.js} +12 -12
  21. package/dist/chunks/{dashboard-briefing-launcher-C8nDSDnV.cjs → dashboard-briefing-launcher-C4zsM3Hd.cjs} +1 -1
  22. package/dist/chunks/{dashboard-controls-CyL0yimg.js → dashboard-controls-BCQv4xWM.js} +16 -14
  23. package/dist/chunks/dashboard-controls-CWwllVOe.cjs +52 -0
  24. package/dist/chunks/{dashboard-json-5Jr3RudV.js → dashboard-json-BtU_q_0A.js} +9 -9
  25. package/dist/chunks/dashboard-json-DVj2xLsH.cjs +1 -0
  26. package/dist/chunks/edit-dashboard-visual-CO2IVBOq.cjs +172 -0
  27. package/dist/chunks/{edit-dashboard-visual-C7X-um9g.js → edit-dashboard-visual-RgFUx-py.js} +1986 -1990
  28. package/dist/chunks/{editor-action-buttons-CcDm8nA5.cjs → editor-action-buttons-BE8Fby6n.cjs} +2 -2
  29. package/dist/chunks/{editor-action-buttons-C5Wja_J4.js → editor-action-buttons-D-MaqTIs.js} +6 -6
  30. package/dist/chunks/field-aggregations-DUb0NU6c.js +1229 -0
  31. package/dist/chunks/field-aggregations-jSi77h9Z.cjs +1 -0
  32. package/dist/chunks/{field-dependencies-DVl2p1Nm.js → field-dependencies-Cl97kkHy.js} +30 -34
  33. package/dist/chunks/{field-dependencies-r_U0CGQ-.cjs → field-dependencies-DIab72rQ.cjs} +1 -1
  34. package/dist/chunks/{index-BVr4fcCB.js → index-0pdaQ9e1.js} +5 -5
  35. package/dist/chunks/index-BaIrLSBb.cjs +1422 -0
  36. package/dist/chunks/{index-De2QNsqV.js → index-ByiS9sB4.js} +45343 -43665
  37. package/dist/chunks/{index-C9KXfCkC.js → index-CLIro-EG.js} +3 -0
  38. package/dist/chunks/index-Cx3qmRUB.cjs +1 -0
  39. package/dist/chunks/{index-BlYf8gNa.cjs → index-DhlVxvyI.cjs} +1 -1
  40. package/dist/chunks/{matrix-card-DACDwdTq.js → matrix-card-CnKQpnsj.js} +1 -1
  41. package/dist/chunks/{matrix-card-CRXcmAjp.cjs → matrix-card-U4c72doZ.cjs} +1 -1
  42. package/dist/chunks/{matrix-control-sources-ClQzIk7E.js → matrix-control-sources-CRRdP03Q.js} +165 -134
  43. package/dist/chunks/matrix-control-sources-FjxGIbqk.cjs +1 -0
  44. package/dist/chunks/{matrix-formatter-7GLTcBuy.cjs → matrix-formatter-CveLJo6S.cjs} +1 -1
  45. package/dist/chunks/{matrix-formatter-xsq7n_e6.js → matrix-formatter-ZVS5QOuq.js} +2 -2
  46. package/dist/chunks/matrix-member-presentation-CFHjdrxT.cjs +1 -0
  47. package/dist/chunks/matrix-member-presentation-CzGZJd3a.js +182 -0
  48. package/dist/chunks/matrix-operation-contract-DoiWTUbT.cjs +1 -0
  49. package/dist/chunks/matrix-operation-contract-xL8IhFzp.js +1802 -0
  50. package/dist/chunks/{pivot-header-presentation-3wqWChFd.cjs → pivot-header-presentation-Cxz8-06f.cjs} +1 -1
  51. package/dist/chunks/{pivot-header-presentation-D44ODZGn.js → pivot-header-presentation-DVylCBHB.js} +2 -2
  52. package/dist/chunks/{pivot-result-lifecycle-DZ0ZSMoM.cjs → pivot-result-lifecycle-BiERyXnS.cjs} +1 -1
  53. package/dist/chunks/{pivot-result-lifecycle-BSmqVkVG.js → pivot-result-lifecycle-CmjpW7qG.js} +1 -1
  54. package/dist/chunks/{report-preferences-dialog-xADifRXs.js → report-preferences-dialog-BbkXcnnn.js} +4 -4
  55. package/dist/chunks/report-preferences-dialog-C9rpWgQZ.cjs +1 -0
  56. package/dist/chunks/{search-BHsQIWBV.js → selection-reducer-B94WgZ9V.js} +55 -11
  57. package/dist/chunks/selection-reducer-CGKKsaPa.cjs +26 -0
  58. package/dist/chunks/{semantic-format-BhIL1PXP.cjs → semantic-format-BzH69TRq.cjs} +1 -1
  59. package/dist/chunks/{semantic-format-C3amkGmY.js → semantic-format-CBlRO8Aw.js} +1 -1
  60. package/dist/chunks/{switch-DHGiC0aU.js → switch-CD4uGTZI.js} +7450 -7694
  61. package/dist/chunks/switch-iC1x2dcE.cjs +134 -0
  62. package/dist/chunks/token-types-Ahh5u4iT.cjs +1 -0
  63. package/dist/chunks/token-types-CPde8_LG.js +8 -0
  64. package/dist/chunks/{update-policy-Cc9h57pA.cjs → update-policy-COjFudhl.cjs} +1 -1
  65. package/dist/chunks/{update-policy-eTcz52jO.js → update-policy-D9q1Tz8k.js} +1 -1
  66. package/dist/dashboard/index.cjs +1 -1
  67. package/dist/dashboard/index.js +1 -1
  68. package/dist/dashboard-authoring/index.cjs +3 -3
  69. package/dist/dashboard-authoring/index.js +734 -622
  70. package/dist/data-app-builder/index.cjs +1 -1
  71. package/dist/data-app-builder/index.js +3 -3
  72. package/dist/data-app-codegen/index.cjs +1 -1
  73. package/dist/data-app-codegen/index.js +2 -2
  74. package/dist/data-app-codegen-node/index.cjs +94 -92
  75. package/dist/data-app-codegen-node/index.js +337 -333
  76. package/dist/data-app-sdk/index.cjs +9 -9
  77. package/dist/data-app-sdk/index.js +1091 -969
  78. package/dist/data-app-sdk-adapters/index.cjs +1 -1
  79. package/dist/data-app-sdk-adapters/index.js +104 -96
  80. package/dist/data-app-sdk-validation/index.cjs +1 -1
  81. package/dist/data-app-sdk-validation/index.js +2 -2
  82. package/dist/format-utils/index.cjs +1 -1
  83. package/dist/format-utils/index.js +8 -8
  84. package/dist/index.cjs +1 -1
  85. package/dist/index.js +15 -15
  86. package/dist/style.css +1 -1
  87. package/dist/surfboard/index.cjs +1 -1
  88. package/dist/surfboard/index.js +2 -2
  89. package/dist/types/brand-studio/brand-studio-draft.d.ts +3 -1
  90. package/dist/types/components/dashboard/card-selection-pill.d.ts +5 -0
  91. package/dist/types/components/dashboard/dashboard-container.d.ts +1 -1
  92. package/dist/types/components/dashboard/drill-breadcrumb.d.ts +1 -0
  93. package/dist/types/components/dashboard/drill-navigation-controls.d.ts +3 -3
  94. package/dist/types/components/interactions/applied-filters-display.d.ts +6 -1
  95. package/dist/types/components/interactions/click-to-filter-review-dialog.d.ts +21 -0
  96. package/dist/types/components/interactions/dashboard-drill-host.d.ts +13 -0
  97. package/dist/types/components/interactions/filter-badge-tooltip.d.ts +4 -4
  98. package/dist/types/components/interactions/insight-modal.d.ts +4 -14
  99. package/dist/types/components/interactions/insight-viewer.d.ts +7 -19
  100. package/dist/types/components/interactions/interactions-sheet.d.ts +6 -0
  101. package/dist/types/components/interactions/panels/click-to-filter-panel.d.ts +20 -0
  102. package/dist/types/components/interactions/reusable/interaction-selection-popover.d.ts +2 -2
  103. package/dist/types/components/interactions/sheet/action-editor.d.ts +17 -0
  104. package/dist/types/components/interactions/sheet/action-meta.d.ts +45 -0
  105. package/dist/types/components/interactions/sheet/action-picker.d.ts +7 -0
  106. package/dist/types/components/interactions/sheet/click-outcome-preview.d.ts +10 -0
  107. package/dist/types/components/interactions/sheet/interactions-home.d.ts +28 -0
  108. package/dist/types/components/interactions/sheet/sheet-parts.d.ts +37 -0
  109. package/dist/types/components/surfboard/filter/dashboard-filter-mapping-panel.d.ts +28 -1
  110. package/dist/types/components/surfboard/filter/selection-chip.d.ts +11 -0
  111. package/dist/types/components/surfboard/filter/selection-filter-section.d.ts +4 -0
  112. package/dist/types/components/surfboard/filter/use-dashboard-filter-mapping-popover.d.ts +3 -0
  113. package/dist/types/components/ui/resizable.d.ts +1 -1
  114. package/dist/types/components/visual/matrix-table/matrix-interaction-actions.d.ts +13 -1
  115. package/dist/types/components/visual/matrix-table/matrix-selection-click.d.ts +6 -0
  116. package/dist/types/data-app-sdk/adapters.d.ts +3 -2
  117. package/dist/types/data-app-sdk/builders.d.ts +2 -1
  118. package/dist/types/data-app-sdk/contracts.d.ts +44 -2
  119. package/dist/types/data-app-sdk/index.d.ts +1 -0
  120. package/dist/types/data-app-sdk/query-request.d.ts +7 -2
  121. package/dist/types/data-app-sdk/selection.d.ts +2 -0
  122. package/dist/types/index.cjs +1 -1
  123. package/dist/types/index.js +24 -23
  124. package/dist/types/lib/appearance/types.d.ts +3 -1
  125. package/dist/types/lib/briefings/briefing-attachment-model.d.ts +0 -2
  126. package/dist/types/lib/contexts/interactions-popover-context.d.ts +1 -8
  127. package/dist/types/lib/dashboard/click-to-filter-card-references.d.ts +23 -0
  128. package/dist/types/lib/dashboard-inputs/build-normalized-dashboard-inputs.d.ts +16 -2
  129. package/dist/types/lib/dashboard-inputs/build-selection-dashboard-inputs.d.ts +31 -0
  130. package/dist/types/lib/dashboard-inputs/click-to-filter-emitted-fields.d.ts +17 -0
  131. package/dist/types/lib/dashboard-inputs/click-to-filter-mapping-draft.d.ts +99 -0
  132. package/dist/types/lib/dashboard-inputs/click-to-filter-sheet-reach.d.ts +12 -0
  133. package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-authoring.d.ts +18 -1
  134. package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-candidate-metadata.d.ts +4 -1
  135. package/dist/types/lib/dashboard-inputs/dashboard-input-scope.d.ts +10 -0
  136. package/dist/types/lib/dashboard-inputs/dashboard-input-snapshot.d.ts +8 -1
  137. package/dist/types/lib/dashboard-inputs/index.d.ts +1 -0
  138. package/dist/types/lib/dashboard-inputs/resolve-dashboard-input-context.d.ts +18 -7
  139. package/dist/types/lib/dashboard-inputs/resolve-field-date-comparison-coverage.d.ts +5 -2
  140. package/dist/types/lib/dashboard-inputs/resolve-selection-input.d.ts +77 -0
  141. package/dist/types/lib/dashboard-inputs/selection-targets.d.ts +26 -0
  142. package/dist/types/lib/dashboard-inputs/transient-input-context.d.ts +102 -0
  143. package/dist/types/lib/dashboard-navigation/build-carried-click-context.d.ts +50 -0
  144. package/dist/types/lib/dashboard-navigation/describe-carried-context.d.ts +11 -0
  145. package/dist/types/lib/dashboard-navigation/index.d.ts +1 -0
  146. package/dist/types/lib/dashboard-navigation/navigation-state.d.ts +120 -0
  147. package/dist/types/lib/dashboard-navigation/run-one-off-drill.d.ts +11 -0
  148. package/dist/types/lib/dashboard-navigation/use-transient-contexts.d.ts +17 -0
  149. package/dist/types/lib/dashboard-view-state/card-view-state.d.ts +48 -0
  150. package/dist/types/lib/dashboard-view-state/drill-path.d.ts +20 -0
  151. package/dist/types/lib/dashboard-view-state/index.d.ts +2 -0
  152. package/dist/types/lib/download-pdf.d.ts +0 -3
  153. package/dist/types/lib/formatters/metric-formatting.d.ts +1 -1
  154. package/dist/types/lib/hooks/ai/dashboard-context.d.ts +15 -8
  155. package/dist/types/lib/hooks/chartjs/use-chart-blur.d.ts +10 -2
  156. package/dist/types/lib/hooks/interactions/{use-event-engine.d.ts → use-drill-actions.d.ts} +28 -7
  157. package/dist/types/lib/hooks/selection/use-active-selections.d.ts +15 -0
  158. package/dist/types/lib/hooks/selection/use-click-to-filter-mapping-draft.d.ts +20 -0
  159. package/dist/types/lib/hooks/selection/use-selection-click.d.ts +34 -0
  160. package/dist/types/lib/hooks/selection/use-selection-gestures.d.ts +38 -0
  161. package/dist/types/lib/hooks/selection/use-table-row-selection.d.ts +46 -0
  162. package/dist/types/lib/hooks/use-dashboard-card.d.ts +0 -2
  163. package/dist/types/lib/hooks/use-dashboard-filter-mapping-candidates.d.ts +18 -0
  164. package/dist/types/lib/hooks/use-dashboard-frame-query.d.ts +0 -1
  165. package/dist/types/lib/hooks/use-dashboard.d.ts +1 -3
  166. package/dist/types/lib/hooks/use-interactions-popover.d.ts +1 -8
  167. package/dist/types/lib/hooks/use-resolved-card-config.d.ts +6 -0
  168. package/dist/types/lib/interactions/click-outcome.d.ts +25 -0
  169. package/dist/types/lib/interactions/get-click-context-from-chartjs.d.ts +3 -1
  170. package/dist/types/lib/interactions/get-click-context-from-matrix.d.ts +1 -1
  171. package/dist/types/lib/interactions/get-click-context-from-table.d.ts +7 -0
  172. package/dist/types/lib/interactions/interaction-utils.d.ts +17 -1
  173. package/dist/types/lib/matrix-table/build-matrix-drill-to-detail.d.ts +15 -0
  174. package/dist/types/lib/matrix-table/matrix-card-interactions.d.ts +14 -3
  175. package/dist/types/lib/query-context/build-card-query-context.d.ts +19 -8
  176. package/dist/types/lib/query-context/build-dashboard-execution-snapshot.d.ts +5 -3
  177. package/dist/types/lib/query-context/build-dashboard-frame-base-query-contexts.d.ts +12 -4
  178. package/dist/types/lib/query-context/compile-selection-filters.d.ts +5 -0
  179. package/dist/types/lib/query-context/dashboard-filter-mapping-resolution.d.ts +46 -0
  180. package/dist/types/lib/query-context/filter-group-utils.d.ts +3 -0
  181. package/dist/types/lib/query-context/resolve-runtime-card-filters.d.ts +29 -0
  182. package/dist/types/lib/selection/click-to-filter-authoring-support.d.ts +9 -0
  183. package/dist/types/lib/selection/selection-from-click-context.d.ts +41 -0
  184. package/dist/types/lib/selection/selection-labels.d.ts +3 -0
  185. package/dist/types/lib/selection/selection-notices.d.ts +9 -0
  186. package/dist/types/lib/selection/selection-reducer.d.ts +46 -0
  187. package/dist/types/lib/stores/dashboard-store.d.ts +62 -17
  188. package/dist/types/lib/stores/editor-store.d.ts +1 -2
  189. package/dist/types/lib/stores/index.d.ts +0 -2
  190. package/dist/types/lib/types/common-types.d.ts +60 -6
  191. package/dist/types/lib/types/explorer-types.d.ts +1 -22
  192. package/dist/types/lib/types/interaction-types.d.ts +6 -198
  193. package/dist/types/lib/utils/calculate-context-aware-filters.d.ts +21 -12
  194. package/dist/types/lib/utils/card-utils.d.ts +11 -0
  195. package/dist/types/lib/utils/date-hierarchy-utils.d.ts +3 -1
  196. package/dist/types/lib/utils/drag-and-drop-utils.d.ts +1 -1
  197. package/dist/types/lib/utils/interaction-icons.d.ts +1 -1
  198. package/dist/types/shared/analytics-protocol/execution-input-schemas.d.ts +32 -32
  199. package/dist/types/shared/analytics-protocol/index.d.ts +2 -0
  200. package/dist/types/shared/analytics-protocol/selection-contract.d.ts +100 -0
  201. package/dist/types/shared/analytics-protocol/selection-filter-compiler.d.ts +12 -0
  202. package/dist/types/shared/dashboard-authoring/apply-group-by-override.d.ts +19 -0
  203. package/dist/types/shared/dashboard-authoring/click-to-filter-settings.d.ts +88 -0
  204. package/dist/types/shared/dashboard-authoring/contracts.d.ts +8 -0
  205. package/dist/types/shared/dashboard-authoring/index.d.ts +3 -0
  206. package/dist/types/shared/dashboard-authoring/linked-click-to-filter-overrides.d.ts +32 -0
  207. package/dist/types/shared/format-utils/matrix-continuation.d.ts +3 -3
  208. package/package.json +1 -1
  209. package/src/data-app-sdk/README.md +58 -1
  210. package/dist/chunks/appearance-context-tNjvTJj3.cjs +0 -1
  211. package/dist/chunks/calculated-field-identity-BTpUqfEu.js +0 -1276
  212. package/dist/chunks/calculated-field-identity-rMuXuzEY.cjs +0 -1
  213. package/dist/chunks/constants-vtu7_IUo.cjs +0 -1
  214. package/dist/chunks/dashboard-controls-DlxeddZN.cjs +0 -52
  215. package/dist/chunks/dashboard-json-DhS4yJfc.cjs +0 -1
  216. package/dist/chunks/edit-dashboard-visual-X3OCnivL.cjs +0 -172
  217. package/dist/chunks/field-aggregations-BU_3gHKR.js +0 -957
  218. package/dist/chunks/field-aggregations-CDCamEsQ.cjs +0 -1
  219. package/dist/chunks/index-C8XCKzB6.cjs +0 -1
  220. package/dist/chunks/index-DSa6RSdg.cjs +0 -1417
  221. package/dist/chunks/matrix-control-sources-CeC5EMyq.cjs +0 -1
  222. package/dist/chunks/matrix-member-presentation-E2B4k3ws.cjs +0 -1
  223. package/dist/chunks/matrix-member-presentation-qiHxv67e.js +0 -105
  224. package/dist/chunks/matrix-operation-contract-Cqy4EW2H.js +0 -1638
  225. package/dist/chunks/matrix-operation-contract-D9dLX-Wr.cjs +0 -1
  226. package/dist/chunks/report-preferences-dialog-7Vsc_fsG.cjs +0 -1
  227. package/dist/chunks/search-BqqhaMx9.cjs +0 -26
  228. package/dist/chunks/switch-BytP6QY8.cjs +0 -139
  229. package/dist/types/components/interactions/configuration-popover.d.ts +0 -1
  230. package/dist/types/components/interactions/interaction-card.d.ts +0 -59
  231. package/dist/types/components/interactions/interaction-event-handler.d.ts +0 -11
  232. package/dist/types/components/interactions/interactions-list.d.ts +0 -50
  233. package/dist/types/components/interactions/panels/cross-filter-panel.d.ts +0 -24
  234. package/dist/types/components/interactions/panels/inline-drill-panel.d.ts +0 -24
  235. package/dist/types/components/interactions/selectors/action-selector.d.ts +0 -31
  236. package/dist/types/components/interactions/selectors/trigger-selector.d.ts +0 -38
  237. package/dist/types/components/surfboard/filter/click-filter-section.d.ts +0 -5
  238. package/dist/types/lib/interactions/build-interaction-event.d.ts +0 -25
  239. package/dist/types/lib/interactions/convert-click-filters-to-filter-group.d.ts +0 -10
  240. package/dist/types/lib/interactions/execute-interaction-event.d.ts +0 -80
  241. package/dist/types/lib/interactions/field-utils.d.ts +0 -11
  242. package/dist/types/lib/interactions/handle-chart-click.d.ts +0 -75
  243. package/dist/types/lib/interactions/linked-interaction-utils.d.ts +0 -14
  244. package/dist/types/lib/interactions/source-card-filter-utils.d.ts +0 -9
  245. package/dist/types/lib/stores/drill-actions.d.ts +0 -139
  246. package/dist/types/lib/stores/interaction-store.d.ts +0 -113
  247. package/dist/types/lib/stores/pointer-interaction-store.d.ts +0 -18
@@ -1,957 +0,0 @@
1
- import { A as ee, a_ as D, u as te, ak as oe } from "./validators-BDYzZFgs.js";
2
- import "./matrix-operation-contract-Cqy4EW2H.js";
3
- import { f as ne, C as ie } from "./metric-comparison-C-sYqv0g.js";
4
- import { v as O, a as re, f as se } from "./temporal-bucket-B9hMwemw.js";
5
- import { DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES as Q } from "../value-format-preferences/index.js";
6
- import { m as ae } from "./source-entity-resolution-DZhUckix.js";
7
- import { i as ce, a as pe } from "./matrix-card-DACDwdTq.js";
8
- const E = /* @__PURE__ */ new Set([
9
- "previous_period",
10
- "same_period_last_year",
11
- "start_vs_end",
12
- "target"
13
- ]), le = /* @__PURE__ */ new Set([...E, "none", ""]);
14
- function u(e) {
15
- return !!e && typeof e == "object" && !Array.isArray(e);
16
- }
17
- function W(e) {
18
- const t = u(e.preferences) ? e.preferences : void 0, o = t && u(t.kpiVisualOptions) ? t.kpiVisualOptions : void 0, n = t && u(t.tableVisualOptions) ? t.tableVisualOptions : void 0;
19
- return {
20
- preferences: t,
21
- kpiOptions: o,
22
- kpiComparison: o && u(o.metricComparison) ? o.metricComparison : void 0,
23
- kpiComparisonPresent: !!o && "metricComparison" in o,
24
- tableOptions: n,
25
- tableComparison: n && u(n.metricComparison) ? n.metricComparison : void 0,
26
- tableComparisonPresent: !!n && "metricComparison" in n
27
- };
28
- }
29
- function x(e) {
30
- const t = [], o = (n, i) => {
31
- if (Array.isArray(n)) {
32
- n.forEach((r, s) => o(r, `${i}[${s}]`));
33
- return;
34
- }
35
- if (!u(n)) return;
36
- const p = n.config;
37
- if (u(p)) {
38
- const r = W(n), s = !!(r.kpiComparisonPresent || r.tableComparisonPresent), m = p.metricColumns, a = Array.isArray(m) ? m.flatMap(
39
- (l, c) => u(l) ? [{ index: c, metric: l }] : []
40
- ) : [];
41
- if ((a.some(({ metric: l }) => "comparisonType" in l) || s) && t.push({
42
- path: i,
43
- card: n,
44
- metrics: a,
45
- malformedMetricIndexes: Array.isArray(m) ? m.flatMap(
46
- (l, c) => u(l) ? [] : [c]
47
- ) : [],
48
- malformedMetricColumns: "metricColumns" in p && !Array.isArray(m),
49
- hasLegacyPresentation: s
50
- }), "metricColumns" in p || s) return;
51
- }
52
- Object.entries(n).forEach(
53
- ([r, s]) => o(s, i ? `${i}.${r}` : r)
54
- );
55
- };
56
- return o(e, "$"), t;
57
- }
58
- const K = {
59
- difference: "difference",
60
- change: "percent_change",
61
- change_difference: "both",
62
- ratio: "ratio"
63
- };
64
- function q(e, t) {
65
- if (!e) return;
66
- const o = Object.fromEntries(
67
- t.flatMap(
68
- (n) => typeof e[n] == "string" ? [[n, e[n]]] : []
69
- )
70
- );
71
- return Object.keys(o).length ? o : void 0;
72
- }
73
- function me(e, t, o) {
74
- if (e !== void 0) {
75
- if (!u(e)) {
76
- o.push({
77
- severity: "error",
78
- code: "invalid_legacy_comparison_presentation",
79
- path: t,
80
- message: "Legacy comparison formatOptions must be an object."
81
- });
82
- return;
83
- }
84
- Object.entries(e).forEach(([n, i]) => {
85
- if (n === "decimalPlaces") {
86
- (typeof i != "number" || !Number.isInteger(i) || i < 0 || i > 6) && o.push({
87
- severity: "error",
88
- code: "invalid_legacy_comparison_presentation",
89
- path: `${t}.decimalPlaces`,
90
- message: "Legacy comparison decimalPlaces must be an integer from 0 through 6."
91
- });
92
- return;
93
- }
94
- n === "type" && (i === void 0 || i === "auto") || i !== void 0 && o.push({
95
- severity: "error",
96
- code: "unsupported_comparison_format",
97
- path: `${t}.${n}`,
98
- message: `Legacy comparison format option "${n}" has no canonical presentation mapping.`
99
- });
100
- });
101
- }
102
- }
103
- function N(e, t) {
104
- const o = t === "kpi" ? e.calculationType : e.calculatedAs, n = t === "table" && o === void 0 ? "both" : K[String(o)], i = u(e.formatOptions) ? e.formatOptions : void 0, p = u(e.conditionalLabels) ? e.conditionalLabels : void 0, r = u(
105
- t === "kpi" ? e.colorConfig : e.colors
106
- ) ? t === "kpi" ? e.colorConfig : e.colors : void 0, s = {};
107
- if (n && (s.displayMode = n), typeof (i == null ? void 0 : i.decimalPlaces) == "number" && (s.precision = i.decimalPlaces), t === "kpi") {
108
- const l = e.showArrow !== !1, c = e.showColor !== !1;
109
- s.indicatorStyle = l ? c ? "arrow_badge" : "arrow" : c ? "badge" : "none", s.showColor = c, (e.position === "left" || e.position === "right" || e.position === "top") && (s.position = e.position), typeof e.conditionalLabel == "boolean" && (s.conditionalLabel = e.conditionalLabel), typeof e.labelName == "string" && (s.labelName = e.labelName);
110
- } else (e.indicatorStyle === "arrow_badge" || e.indicatorStyle === "arrow" || e.indicatorStyle === "badge" || e.indicatorStyle === "none") && (s.indicatorStyle = e.indicatorStyle);
111
- const m = p ? {
112
- ...q(p, ["increase", "decrease"]),
113
- ...typeof p.noChange == "string" ? { neutral: p.noChange } : typeof p.neutral == "string" ? { neutral: p.neutral } : {}
114
- } : void 0;
115
- m && Object.keys(m).length && (s.conditionalLabels = m);
116
- const a = r ? {
117
- ...q(r, ["increase", "decrease"]),
118
- ...typeof r.noChange == "string" ? { neutral: r.noChange } : typeof r.neutral == "string" ? { neutral: r.neutral } : {}
119
- } : void 0;
120
- return a && Object.keys(a).length && (s.colors = a), s;
121
- }
122
- function j(e) {
123
- return { ...ie, ...e };
124
- }
125
- function J(e) {
126
- return e.some(({ metric: t }) => t.comparisonType === "previous_period" || t.comparisonType === "same_period_last_year" || t.comparisonType === "target" ? !0 : u(t.comparison) && t.comparison.mode === "explicit");
127
- }
128
- function P(e) {
129
- const t = e.card.config;
130
- return e.metrics.length === 2 && (t.groupByColumns === void 0 || Array.isArray(t.groupByColumns) && t.groupByColumns.length === 0);
131
- }
132
- function U(e, t, o, n) {
133
- const i = t === "kpi" ? [
134
- "enabled",
135
- "calculationType",
136
- "formatOptions",
137
- "showArrow",
138
- "showColor",
139
- "conditionalLabel",
140
- "labelName",
141
- "position",
142
- "conditionalLabels",
143
- "colorConfig",
144
- "lowerIsBetter"
145
- ] : [
146
- "calculatedAs",
147
- "indicatorStyle",
148
- "formatOptions",
149
- "colors",
150
- "lowerIsBetter"
151
- ];
152
- Object.keys(e).forEach((l) => {
153
- i.includes(l) || n.push({
154
- severity: "error",
155
- code: "invalid_legacy_comparison_presentation",
156
- path: `${o}.${l}`,
157
- message: `Unknown legacy comparison presentation field "${l}" cannot be dropped automatically.`
158
- });
159
- });
160
- const p = t === "kpi" ? "calculationType" : "calculatedAs";
161
- e[p] !== void 0 && !K[String(e[p])] && n.push({
162
- severity: "error",
163
- code: "invalid_legacy_comparison_presentation",
164
- path: `${o}.${p}`,
165
- message: `Legacy comparison ${p} is unsupported.`
166
- }), t === "kpi" && e.position !== void 0 && !["left", "right", "top"].includes(String(e.position)) && n.push({
167
- severity: "error",
168
- code: "invalid_legacy_comparison_presentation",
169
- path: `${o}.position`,
170
- message: "Legacy comparison position is unsupported."
171
- }), t === "kpi" && e.labelName !== void 0 && typeof e.labelName != "string" && n.push({
172
- severity: "error",
173
- code: "invalid_legacy_comparison_presentation",
174
- path: `${o}.labelName`,
175
- message: "Legacy comparison labelName must be a string."
176
- }), (t === "kpi" ? [
177
- ["conditionalLabels", ["increase", "decrease", "noChange"]],
178
- ["colorConfig", ["increase", "decrease", "noChange"]]
179
- ] : [["colors", ["increase", "decrease", "neutral"]]]).forEach(([l, c]) => {
180
- if (e[l] !== void 0) {
181
- if (!u(e[l])) {
182
- n.push({
183
- severity: "error",
184
- code: "invalid_legacy_comparison_presentation",
185
- path: `${o}.${l}`,
186
- message: `Legacy comparison ${l} must be an object.`
187
- });
188
- return;
189
- }
190
- Object.entries(e[l]).forEach(([d, b]) => {
191
- c.includes(d) ? typeof b != "string" && n.push({
192
- severity: "error",
193
- code: "invalid_legacy_comparison_presentation",
194
- path: `${o}.${l}.${d}`,
195
- message: `Legacy comparison ${l}.${d} must be a string.`
196
- }) : n.push({
197
- severity: "error",
198
- code: "invalid_legacy_comparison_presentation",
199
- path: `${o}.${l}.${d}`,
200
- message: `Unknown legacy comparison ${l} field "${d}" cannot be dropped automatically.`
201
- });
202
- });
203
- }
204
- }), (t === "kpi" ? ["enabled", "showArrow", "showColor", "conditionalLabel", "lowerIsBetter"] : ["lowerIsBetter"]).forEach((l) => {
205
- e[l] !== void 0 && typeof e[l] != "boolean" && n.push({
206
- severity: "error",
207
- code: "invalid_legacy_comparison_presentation",
208
- path: `${o}.${l}`,
209
- message: `Legacy comparison ${l} must be a boolean.`
210
- });
211
- }), t === "table" && e.indicatorStyle !== void 0 && !["arrow_badge", "arrow", "badge", "none"].includes(
212
- String(e.indicatorStyle)
213
- ) && n.push({
214
- severity: "error",
215
- code: "invalid_legacy_comparison_presentation",
216
- path: `${o}.indicatorStyle`,
217
- message: "Legacy comparison indicatorStyle is unsupported."
218
- }), me(e.formatOptions, `${o}.formatOptions`, n);
219
- const m = N(e, t);
220
- ne(m, o).errors.forEach((l) => {
221
- n.push({
222
- severity: "error",
223
- code: "invalid_legacy_comparison_presentation",
224
- path: l.path || o,
225
- message: l.message
226
- });
227
- });
228
- }
229
- function F(e) {
230
- const t = W(e.card), o = t.kpiComparison ? N(t.kpiComparison, "kpi") : void 0, n = t.tableComparison ? N(t.tableComparison, "table") : void 0;
231
- return { namespaces: t, kpi: o, table: n, presentation: o || n };
232
- }
233
- function fe(e) {
234
- const t = u(e.preferences) ? e.preferences : {}, o = u(t.kpiVisualOptions) ? t.kpiVisualOptions : {}, n = u(o.metricComparison) ? o.metricComparison : {}, i = u(t.tableVisualOptions) ? t.tableVisualOptions : {}, p = u(i.metricComparison) ? i.metricComparison : {};
235
- return o.lowerIsBetter === !0 || n.lowerIsBetter === !0 || p.lowerIsBetter === !0 ? "lower_is_better" : "higher_is_better";
236
- }
237
- function ue(e) {
238
- switch (e.comparisonType) {
239
- case "previous_period":
240
- return { mode: "explicit", spec: { kind: "previous_period" } };
241
- case "same_period_last_year":
242
- return { mode: "explicit", spec: { kind: "previous_year" } };
243
- case "target":
244
- return {
245
- mode: "explicit",
246
- spec: { kind: "target", targetValue: e.targetValue }
247
- };
248
- default:
249
- return;
250
- }
251
- }
252
- function de(e) {
253
- const t = u(e.preferences) ? e.preferences : void 0;
254
- if (!t) return;
255
- const o = u(t.kpiVisualOptions) ? t.kpiVisualOptions : void 0;
256
- o && delete o.lowerIsBetter;
257
- const n = u(t.tableVisualOptions) ? t.tableVisualOptions : void 0, i = n && u(n.metricComparison) ? n.metricComparison : void 0;
258
- i && delete i.lowerIsBetter;
259
- }
260
- function we(e) {
261
- const t = x(e);
262
- if (!t.length)
263
- return { document: e, changed: !1, changes: [], diagnostics: [] };
264
- const o = [];
265
- if (t.forEach((r) => {
266
- var s, m, a, l;
267
- if (r.malformedMetricColumns && o.push({
268
- severity: "error",
269
- code: "malformed_metric_columns",
270
- path: `${r.path}.config.metricColumns`,
271
- message: "Metric columns must be an array before comparison migration."
272
- }), r.malformedMetricIndexes.forEach((c) => {
273
- o.push({
274
- severity: "error",
275
- code: "malformed_metric_columns",
276
- path: `${r.path}.config.metricColumns[${c}]`,
277
- message: "Metric columns must contain objects before comparison migration."
278
- });
279
- }), r.metrics.forEach(({ metric: c, index: d }) => {
280
- if (!("comparisonType" in c)) return;
281
- const b = `${r.path}.config.metricColumns[${d}]`, g = String(c.comparisonType || "");
282
- "comparison" in c && o.push({
283
- severity: "error",
284
- code: "conflicting_comparison_contracts",
285
- path: b,
286
- message: "Metric contains both legacy and canonical comparison configuration; resolve the conflict before migration."
287
- });
288
- const y = u(c.parameters) ? c.parameters : void 0, _ = y && u(y.windowTransform) ? y.windowTransform : void 0;
289
- E.has(g) && (_ == null ? void 0 : _.function) === "previous_period_delta" && o.push({
290
- severity: "error",
291
- code: "conflicting_comparison_window_transform",
292
- path: b,
293
- message: "A metric cannot combine baseline comparison with previous_period_delta; resolve the authoring intent before migration."
294
- }), le.has(g) || o.push({
295
- severity: "error",
296
- code: "unsupported_comparison_type",
297
- path: `${b}.comparisonType`,
298
- message: `Unsupported legacy metric comparison type "${g}".`
299
- }), c.comparisonType === "target" && (typeof c.targetValue != "number" || !Number.isFinite(c.targetValue)) && o.push({
300
- severity: "error",
301
- code: "invalid_target_value",
302
- path: `${b}.targetValue`,
303
- message: "Legacy target comparison requires a finite metric targetValue."
304
- }), c.comparisonType === "start_vs_end" && o.push({
305
- severity: "error",
306
- code: "unsupported_start_vs_end",
307
- path: `${b}.comparisonType`,
308
- message: "start_vs_end is retired and cannot be migrated automatically."
309
- }), c.targetValue !== void 0 && c.comparisonType !== "target" && o.push({
310
- severity: "warning",
311
- code: "stray_target_value",
312
- path: `${b}.targetValue`,
313
- message: "Dead non-target targetValue will be removed without changing the baseline."
314
- });
315
- }), r.hasLegacyPresentation) {
316
- const { namespaces: c, kpi: d, table: b } = F(r), g = [
317
- (s = c.kpiOptions) == null ? void 0 : s.lowerIsBetter,
318
- (m = c.kpiComparison) == null ? void 0 : m.lowerIsBetter,
319
- (a = c.tableComparison) == null ? void 0 : a.lowerIsBetter
320
- ].filter((y) => typeof y == "boolean");
321
- new Set(g).size > 1 && o.push({
322
- severity: "error",
323
- code: "conflicting_legacy_polarity",
324
- path: `${r.path}.preferences`,
325
- message: "Legacy comparison polarity values disagree; resolve the conflict before migration."
326
- }), ((l = c.kpiOptions) == null ? void 0 : l.lowerIsBetter) !== void 0 && typeof c.kpiOptions.lowerIsBetter != "boolean" && o.push({
327
- severity: "error",
328
- code: "invalid_legacy_comparison_presentation",
329
- path: `${r.path}.preferences.kpiVisualOptions.lowerIsBetter`,
330
- message: "Legacy comparison lowerIsBetter must be a boolean."
331
- }), c.kpiComparisonPresent && !c.kpiComparison && o.push({
332
- severity: "error",
333
- code: "invalid_legacy_comparison_presentation",
334
- path: `${r.path}.preferences.kpiVisualOptions.metricComparison`,
335
- message: "Legacy KPI comparison presentation must be an object."
336
- }), c.tableComparisonPresent && !c.tableComparison && o.push({
337
- severity: "error",
338
- code: "invalid_legacy_comparison_presentation",
339
- path: `${r.path}.preferences.tableVisualOptions.metricComparison`,
340
- message: "Legacy table comparison presentation must be an object."
341
- }), "comparisonPresentation" in (c.preferences || {}) && o.push({
342
- severity: "error",
343
- code: "conflicting_comparison_presentation_contracts",
344
- path: `${r.path}.preferences.comparisonPresentation`,
345
- message: "Card contains both legacy and canonical comparison presentation; resolve the conflict before migration."
346
- }), c.kpiComparison && typeof c.kpiComparison.enabled == "boolean" && "metricPairComparisonEnabled" in (c.preferences || {}) && P(r) && o.push({
347
- severity: "error",
348
- code: "conflicting_comparison_presentation_contracts",
349
- path: `${r.path}.preferences.metricPairComparisonEnabled`,
350
- message: "Card contains both legacy and canonical metric-pair enablement; resolve the conflict before migration."
351
- }), c.kpiComparison && U(
352
- c.kpiComparison,
353
- "kpi",
354
- `${r.path}.preferences.kpiVisualOptions.metricComparison`,
355
- o
356
- ), c.tableComparison && U(
357
- c.tableComparison,
358
- "table",
359
- `${r.path}.preferences.tableVisualOptions.metricComparison`,
360
- o
361
- ), d && b && JSON.stringify(j(d)) !== JSON.stringify(j(b)) && o.push({
362
- severity: "error",
363
- code: "conflicting_legacy_presentation_namespaces",
364
- path: `${r.path}.preferences`,
365
- message: "KPI and table comparison presentation values disagree; resolve the conflict before migration."
366
- });
367
- }
368
- }), o.some((r) => r.severity === "error"))
369
- return { document: e, changed: !1, changes: [], diagnostics: o };
370
- const n = JSON.parse(JSON.stringify(e)), i = x(n), p = [];
371
- return i.forEach((r) => {
372
- var m;
373
- const s = fe(r.card);
374
- if (r.metrics.forEach(({ metric: a, index: l }) => {
375
- if (!("comparisonType" in a)) return;
376
- const c = String(a.comparisonType || ""), d = `${r.path}.config.metricColumns[${l}]`, b = ue(a), g = ["comparisonType"];
377
- delete a.comparisonType, "targetValue" in a && (delete a.targetValue, g.push("targetValue")), "comparisonDisplay" in a && (delete a.comparisonDisplay, g.push("comparisonDisplay")), b ? a.comparison = b : delete a.comparison, E.has(c) && (a.comparisonPolarity = s), p.push({
378
- kind: "metric",
379
- path: d,
380
- metricId: typeof a.id == "string" ? a.id : void 0,
381
- legacyType: c,
382
- comparison: b,
383
- comparisonPolarity: E.has(c) ? s : void 0,
384
- removedFields: g
385
- });
386
- }), de(r.card), r.hasLegacyPresentation) {
387
- const { namespaces: a, presentation: l } = F(r), c = (m = a.kpiComparison) == null ? void 0 : m.enabled, d = {
388
- ...l
389
- };
390
- typeof c == "boolean" && J(r.metrics) && (d.showComparison = c);
391
- const b = typeof c == "boolean" && P(r) ? c : void 0, g = typeof c == "boolean" && !J(r.metrics) && !P(r) ? ["kpiVisualOptions.metricComparison.enabled"] : void 0, y = a.preferences, _ = [];
392
- r.metrics.forEach(({ metric: T }) => {
393
- "comparisonPolarity" in T || (T.comparisonPolarity = s, typeof T.id == "string" && _.push(T.id));
394
- }), Object.keys(d).length && (y.comparisonPresentation = d), b !== void 0 && (y.metricPairComparisonEnabled = b), a.kpiOptions && delete a.kpiOptions.metricComparison, a.tableOptions && delete a.tableOptions.metricComparison, p.push({
395
- kind: "presentation",
396
- path: `${r.path}.preferences`,
397
- comparisonPresentation: Object.keys(d).length ? d : void 0,
398
- metricPairComparisonEnabled: b,
399
- comparisonPolarityMetricIds: _,
400
- intentionallyDiscardedFields: g,
401
- removedFields: [
402
- ...a.kpiComparison ? ["kpiVisualOptions.metricComparison"] : [],
403
- ...a.tableComparison ? ["tableVisualOptions.metricComparison"] : []
404
- ]
405
- });
406
- }
407
- }), { document: n, changed: !0, changes: p, diagnostics: o };
408
- }
409
- const he = [
410
- "bar",
411
- "horizontalBar",
412
- "line",
413
- "area",
414
- "stackedArea",
415
- "combo",
416
- "stackedBar",
417
- "stackedLine"
418
- ], be = new Set(
419
- he
420
- );
421
- function ge(e) {
422
- return typeof e == "string" && be.has(e);
423
- }
424
- function Ne(e) {
425
- return e === "detailTable" || e === "table" || e === "aggregateTable" || e === "pivotTable" || e === "custom" || ge(e);
426
- }
427
- function G(e) {
428
- return !!(e != null && e.trim());
429
- }
430
- function Le(e) {
431
- return G(e.sql) || G(e.normalizedPython) ? "freeform" : e.hasExecutableConfig ? "config" : "none";
432
- }
433
- const $ = {
434
- type: "temporal_bucket",
435
- presentation: { mode: "auto" }
436
- }, Y = {
437
- value: "auto",
438
- label: "Automatic",
439
- format: $
440
- };
441
- function h(e, t) {
442
- return {
443
- value: `pattern:${e}`,
444
- label: t,
445
- format: {
446
- type: "temporal_bucket",
447
- presentation: { mode: "pattern", pattern: e }
448
- }
449
- };
450
- }
451
- function M(e, t) {
452
- return {
453
- value: `preset:${e}`,
454
- label: t,
455
- format: {
456
- type: "temporal_bucket",
457
- presentation: { mode: "preset", preset: e }
458
- }
459
- };
460
- }
461
- function C(e) {
462
- return {
463
- ...h(e, "Custom format…"),
464
- value: "custom",
465
- custom: !0
466
- };
467
- }
468
- const S = {
469
- second: [
470
- Y,
471
- h("HH:mm:ss", "14:30:45 (HH:mm:ss)"),
472
- h(
473
- "YYYY-MM-DD HH:mm:ss",
474
- "2024-01-15 14:30:45 (YYYY-MM-DD HH:mm:ss)"
475
- ),
476
- C("DD/MM/YYYY HH:mm:ss")
477
- ],
478
- minute: [
479
- Y,
480
- h("HH:mm", "14:30 (HH:mm)"),
481
- h("YYYY-MM-DD HH:mm", "2024-01-15 14:30 (YYYY-MM-DD HH:mm)"),
482
- C("DD/MM/YYYY HH:mm")
483
- ],
484
- hour: [
485
- Y,
486
- h("HH", "14 (HH)"),
487
- h("YYYY-MM-DD HH", "2024-01-15 14 (YYYY-MM-DD HH)"),
488
- C("DD/MM/YYYY HH")
489
- ],
490
- day: [
491
- Y,
492
- h("YYYY-MM-DD", "2024-01-15 (YYYY-MM-DD)"),
493
- h("MM/DD/YYYY", "01/15/2024 (MM/DD/YYYY)"),
494
- h("DD/MM/YYYY", "15/01/2024 (DD/MM/YYYY)"),
495
- h("MMM DD, YYYY", "Jan 15, 2024 (MMM DD, YYYY)"),
496
- h("MMMM DD, YYYY", "January 15, 2024 (MMMM DD, YYYY)"),
497
- C("YYYY/MM/DD")
498
- ],
499
- week: [
500
- Y,
501
- M("week_of_short", "Week of Jan 15, 2024"),
502
- M("week_of_long", "Week of January 15, 2024"),
503
- h("YYYY-MM-DD", "2024-01-15 (YYYY-MM-DD)"),
504
- C("YYYY/MM/DD")
505
- ],
506
- month: [
507
- Y,
508
- h("MMM YYYY", "Jan 2024 (MMM YYYY)"),
509
- h("MMMM YYYY", "January 2024 (MMMM YYYY)"),
510
- h("YYYY-MM", "2024-01 (YYYY-MM)"),
511
- h("MM/YYYY", "01/2024 (MM/YYYY)"),
512
- h("YYYY MMM", "2024 Jan (YYYY MMM)"),
513
- C("YYYY/MM")
514
- ],
515
- quarter: [
516
- Y,
517
- M("quarter_short", "Q1 2024"),
518
- M("quarter_long", "1st Quarter 2024")
519
- ],
520
- year: [
521
- Y,
522
- h("YYYY", "2024 (YYYY)"),
523
- h("YY", "24 (YY)")
524
- ]
525
- }, ye = {
526
- second: "2026-07-31T14:05:09",
527
- minute: "2026-07-31T14:05:00",
528
- hour: "2026-07-31T14:00:00",
529
- day: "2026-07-31",
530
- week: "2026-07-27",
531
- month: "2026-07-01",
532
- quarter: "2026-07-01",
533
- year: "2026-01-01"
534
- };
535
- function Ye(e, t, o = Q) {
536
- return se({
537
- value: ye[t],
538
- metadata: {
539
- kind: "temporal_bucket",
540
- granularity: t,
541
- calendar: {
542
- tz: "UTC",
543
- weekStart: 1,
544
- ...e.presentation.mode === "preset" && (e.presentation.preset === "fiscal_quarter_short" || e.presentation.preset === "fiscal_year") ? {
545
- fiscalCalendar: {
546
- kind: "month_aligned",
547
- yearStartMonth: 7
548
- }
549
- } : {}
550
- }
551
- },
552
- format: e.presentation.mode === "auto" ? {
553
- type: "temporal_bucket",
554
- locale: o.locale,
555
- presentation: {
556
- mode: "auto",
557
- styles: {
558
- dateStyle: o.dateStyle,
559
- dateTime: { ...o.dateTime }
560
- }
561
- }
562
- } : {
563
- type: "temporal_bucket",
564
- locale: o.locale,
565
- presentation: e.presentation
566
- }
567
- });
568
- }
569
- function Be(e, t, o = Q) {
570
- const n = S[e], i = (t == null ? void 0 : t.presentation.mode) === "preset" ? t.presentation.preset : void 0, p = i && t && O(t, e).ok && !n.some(
571
- (s) => {
572
- var m;
573
- return ((m = s.format) == null ? void 0 : m.presentation.mode) === "preset" && s.format.presentation.preset === i;
574
- }
575
- ) ? M(i, i) : void 0;
576
- return (p ? [...n, p] : n).map((s) => {
577
- if (!s.format || s.custom) return s;
578
- const m = Ye(
579
- s.format,
580
- e,
581
- o
582
- );
583
- return s.format.presentation.mode === "pattern" ? {
584
- ...s,
585
- label: `${m} (${s.format.presentation.pattern})`
586
- } : s.format.presentation.mode === "auto" ? { ...s, label: `Automatic (${m})` } : { ...s, label: m };
587
- });
588
- }
589
- function Ve(e, t) {
590
- const o = S[t];
591
- if (e.presentation.mode === "pattern") {
592
- const n = e.presentation.pattern, i = o.find(
593
- (p) => {
594
- var r;
595
- return ((r = p.format) == null ? void 0 : r.presentation.mode) === "pattern" && p.format.presentation.pattern === n;
596
- }
597
- );
598
- return {
599
- value: (i == null ? void 0 : i.value) ?? "custom",
600
- customPattern: i != null && i.custom || !i ? n : "",
601
- format: e
602
- };
603
- }
604
- if (e.presentation.mode === "preset") {
605
- const n = e.presentation.preset, i = o.find(
606
- (r) => {
607
- var s;
608
- return ((s = r.format) == null ? void 0 : s.presentation.mode) === "preset" && r.format.presentation.preset === n;
609
- }
610
- ), p = O(
611
- e,
612
- t
613
- ).ok;
614
- return i ? { value: i.value, customPattern: "", format: e } : p ? {
615
- value: `preset:${n}`,
616
- customPattern: "",
617
- format: e
618
- } : { value: "auto", customPattern: "", format: $ };
619
- }
620
- return { value: "auto", customPattern: "", format: e };
621
- }
622
- function He(e, t, o = "") {
623
- var r;
624
- const n = S[e].find(
625
- (s) => s.value === t
626
- ), i = t.startsWith("preset:") ? t.slice(7) : void 0, p = t === "custom" ? {
627
- type: "temporal_bucket",
628
- presentation: {
629
- mode: "pattern",
630
- pattern: o.trim() || (((r = n == null ? void 0 : n.format) == null ? void 0 : r.presentation.mode) === "pattern" ? n.format.presentation.pattern : "")
631
- }
632
- } : (n == null ? void 0 : n.format) ?? (i && re(i) ? {
633
- type: "temporal_bucket",
634
- presentation: {
635
- mode: "preset",
636
- preset: i
637
- }
638
- } : void 0);
639
- return !p || !O(p, e).ok ? $ : p;
640
- }
641
- function Re(e, t) {
642
- return O(e, t).ok ? e : $;
643
- }
644
- function f(e) {
645
- return typeof e == "string" && e.trim().length > 0 ? e.trim() : null;
646
- }
647
- function X(e) {
648
- return Array.from(new Set(e.filter((t) => !!t)));
649
- }
650
- function _e(e) {
651
- const t = f(e.table), o = f(e.schema), n = f(e.catalog) || f(e.database);
652
- return t ? X([
653
- t,
654
- o ? `${o}.${t}` : null,
655
- n ? `${n}.${t}` : null,
656
- n && o ? `${n}.${o}.${t}` : null
657
- ]) : [];
658
- }
659
- function z(e) {
660
- const t = f(e.table) || f(e.tableName);
661
- return X([
662
- f(e.name),
663
- f(e.alias),
664
- ..._e({
665
- table: t,
666
- schema: f(e.schema) || f(e.schemaName),
667
- catalog: f(e.catalog),
668
- database: f(e.database) || f(e.databaseName)
669
- })
670
- ]);
671
- }
672
- function Ce(e, t) {
673
- const o = f(e.domainId), n = f(t.domainId);
674
- if (o && n && o !== n)
675
- return !0;
676
- if (e.type === "dataset")
677
- return !1;
678
- const i = f(e.id), p = f(t.id);
679
- if (i && p && i !== p)
680
- return !0;
681
- const r = f(e.connectionId), s = f(t.connectionId);
682
- return !!(r && s && r !== s);
683
- }
684
- function L(e, t = !1) {
685
- return f(e.table) || f(e.tableName) || (e.type !== "dataset" || t ? f(e.name) : null);
686
- }
687
- function B(e) {
688
- return f(e.catalog) || f(e.database) || f(e.databaseName);
689
- }
690
- function V(e) {
691
- return f(e.schema) || f(e.schemaName);
692
- }
693
- function I(e) {
694
- return e.length === 1 ? e[0] : void 0;
695
- }
696
- function ve(e, t) {
697
- const o = L(t, !0), n = B(t), i = V(t);
698
- if (!(!o || !n && !i))
699
- return I(
700
- e.filter((p) => {
701
- const r = p;
702
- return !(L(r) !== o || n && B(r) !== n || i && V(r) !== i);
703
- })
704
- );
705
- }
706
- function A(e, t) {
707
- if (!t || !(e != null && e.length))
708
- return;
709
- const o = e.filter(
710
- (s) => !Ce(s, t)
711
- );
712
- if (t.type === "dataset") {
713
- const s = f(t.id);
714
- if (s)
715
- return I(
716
- o.filter(
717
- (a) => a.type === "dataset" && f(a.id) === s
718
- )
719
- );
720
- if (f(t.domainId)) {
721
- const a = f(t.name);
722
- return I(
723
- o.filter(
724
- (l) => l.type === "dataset" && f(l.name) === a
725
- )
726
- );
727
- }
728
- }
729
- let n = [];
730
- if (t.type === "dataset") {
731
- const s = f(t.name);
732
- if (n = o.filter(
733
- (m) => m.type === "dataset" && f(m.name) === s
734
- ), n.length === 1)
735
- return n[0];
736
- }
737
- if (!!(L(t, !0) && (B(t) || V(t))))
738
- return ve(o, t);
739
- if (n.length > 1)
740
- return;
741
- const p = z(t);
742
- if (p.length === 0)
743
- return;
744
- const r = o.filter((s) => z(
745
- s
746
- ).some(
747
- (a) => p.includes(a)
748
- ));
749
- return I(r);
750
- }
751
- function w(e, t) {
752
- const o = A(e, t);
753
- return o ? { ...t, ...o } : t;
754
- }
755
- function Se(e, t) {
756
- const o = t || [];
757
- return o.length === 0 ? e : {
758
- ...e,
759
- baseEntity: w(o, e.baseEntity),
760
- joins: e.joins.map((n) => ({
761
- ...n,
762
- source: w(o, n.source),
763
- target: w(o, n.target)
764
- }))
765
- };
766
- }
767
- function xe(e, t) {
768
- if (!(e != null && e.joins.length))
769
- return [];
770
- const o = [
771
- e.baseEntity,
772
- ...e.joins.flatMap((i) => [i.source, i.target])
773
- ], n = [];
774
- return o.forEach((i) => {
775
- !A(t, i) && !A(n, i) && n.push(i);
776
- }), n;
777
- }
778
- function v(e) {
779
- return !!e && typeof e == "object" && !Array.isArray(e);
780
- }
781
- function k(e) {
782
- return v(e) && typeof e.name == "string";
783
- }
784
- function H(e) {
785
- return !v(e) || e.kind !== "semantic" && e.kind !== "physical" || (e.kind === "semantic" ? [e.datasetId, e.datasetName, e.connectionId] : [e.databaseName, e.schemaName]).some(
786
- (o) => o !== void 0 && typeof o != "string"
787
- ) ? !1 : ee(
788
- e
789
- );
790
- }
791
- function R(e, t) {
792
- var a, l;
793
- const o = Array.isArray(t == null ? void 0 : t.selectedEntities) ? t.selectedEntities.filter(k) : void 0, n = A(o, e), i = n ? { ...e, ...n } : e, p = "domainId" in i && typeof i.domainId == "string" && !!i.domainId.trim();
794
- if ((t == null ? void 0 : t.mode) === "semanticDomain" && !p)
795
- return;
796
- if ((t == null ? void 0 : t.mode) !== "database" && i.type === "dataset") {
797
- const c = ae(
798
- {
799
- entities: [i],
800
- semanticDomainId: t == null ? void 0 : t.semanticDomainId,
801
- connectionId: t == null ? void 0 : t.connectionId,
802
- fieldEntityType: "dataset"
803
- },
804
- { includePhysicalDatasets: !0 }
805
- );
806
- if (c.kind === "resolved") {
807
- const d = "label" in i && typeof i.label == "string" ? i.label : void 0;
808
- return {
809
- ...c.source,
810
- ...d ? { label: d } : {}
811
- };
812
- }
813
- }
814
- if ((t == null ? void 0 : t.mode) === "semanticDomain")
815
- return;
816
- const r = i.connectionId || (t == null ? void 0 : t.connectionId), s = i.type === "dataset" && "table" in i && i.table ? i.table : i.name;
817
- if (!r || !s)
818
- return;
819
- const m = {
820
- kind: "physical",
821
- connectionId: r,
822
- connectionType: i.connectionType || (t == null ? void 0 : t.connectionType),
823
- tableName: s,
824
- databaseName: i.database || ((a = t == null ? void 0 : t.dbSelection) == null ? void 0 : a.database),
825
- schemaName: i.schema || ((l = t == null ? void 0 : t.dbSelection) == null ? void 0 : l.schema),
826
- dialect: i.dialect
827
- };
828
- return H(m) ? m : void 0;
829
- }
830
- function Me(e, t) {
831
- var s, m;
832
- const o = R(e, t);
833
- if (!o) return;
834
- const n = e.type === "dataset" && "table" in e && typeof e.table == "string" ? e.table.trim() : void 0, i = o.kind === "physical" ? o.tableName : n, p = e.connectionId || (t == null ? void 0 : t.connectionId), r = i && p ? {
835
- connectionId: p,
836
- databaseName: e.database || ((s = t == null ? void 0 : t.dbSelection) == null ? void 0 : s.database),
837
- schemaName: e.schema || ((m = t == null ? void 0 : t.dbSelection) == null ? void 0 : m.schema),
838
- tableName: i
839
- } : void 0;
840
- return { source: o, ...r ? { executionTable: r } : {} };
841
- }
842
- function qe(e) {
843
- const t = v(e.dataSource) ? e.dataSource : void 0;
844
- if (typeof e.sql == "string" && e.sql.trim()) {
845
- const r = [], s = Array.isArray(t == null ? void 0 : t.selectedEntities) ? t.selectedEntities : [];
846
- for (const m of s) {
847
- if (!k(m)) continue;
848
- const a = Me(m, t);
849
- a && !r.some(
850
- (l) => D(
851
- l.source,
852
- a.source
853
- )
854
- ) && r.push(a);
855
- }
856
- return {
857
- cardId: e.id,
858
- kind: "sql",
859
- pinnedCatalogSources: r
860
- };
861
- }
862
- if (!v(e.config))
863
- return { cardId: e.id, kind: "unconfigured" };
864
- const o = [], n = ce(e);
865
- if (n.status === "invalid") return { cardId: e.id, kind: "unconfigured" };
866
- const i = n.status === "ready" ? n.config : void 0;
867
- if (e.type === "matrixTable" && !i) return { cardId: e.id, kind: "unconfigured" };
868
- i && o.push(...pe(i.spec).filter(H));
869
- const p = (i == null ? void 0 : i.spec.joinPlan) ?? (v(e.config.joinPlan) ? e.config.joinPlan : void 0);
870
- if (p) {
871
- const r = Array.isArray(p.joins) ? p.joins : [], s = [p.baseEntity];
872
- for (const a of r)
873
- v(a) && s.push(a.source, a.target);
874
- let m = !1;
875
- for (const a of s) {
876
- if (!k(a)) {
877
- m = !0;
878
- continue;
879
- }
880
- const l = R(a, t);
881
- l ? o.push(l) : m = !0;
882
- }
883
- m && (o.length = 0);
884
- } else if (e.type !== "matrixTable") {
885
- const r = Array.isArray(t == null ? void 0 : t.selectedEntities) ? t.selectedEntities : [];
886
- if (r.length === 1 && k(r[0])) {
887
- const s = R(r[0], t);
888
- s && o.push(s);
889
- }
890
- }
891
- if (!o.length && !p && e.type !== "matrixTable") {
892
- const r = e.config.queryBaseSource;
893
- H(r) && o.push(r);
894
- }
895
- return {
896
- cardId: e.id,
897
- kind: "config",
898
- executableSources: te(o)
899
- };
900
- }
901
- function je(e, t) {
902
- return (e.kind === "config" ? e.executableSources : e.kind === "sql" ? e.pinnedCatalogSources.map((n) => n.source) : []).some(
903
- (n) => D(n, t)
904
- );
905
- }
906
- function Je(e, t) {
907
- if (e.kind === "config")
908
- return e.executableSources.find(
909
- (o) => D(o, t)
910
- );
911
- }
912
- function Ue(e, t) {
913
- var o;
914
- return (o = Te(e, t)) == null ? void 0 : o.source;
915
- }
916
- function Te(e, t) {
917
- if (e.kind === "sql")
918
- return e.pinnedCatalogSources.find(
919
- (o) => D(o.source, t)
920
- );
921
- }
922
- const Z = [
923
- { value: "COUNT", label: "Count" },
924
- { value: "DISTINCT", label: "Count Distinct" }
925
- ], Ee = [
926
- ...Z,
927
- { value: "SUM", label: "Sum" },
928
- { value: "AVG", label: "Average" },
929
- { value: "MIN", label: "Min" },
930
- { value: "MAX", label: "Max" },
931
- { value: "MEDIAN", label: "Median" }
932
- ];
933
- function Fe(e) {
934
- return oe(e) === "number" ? Ee : Z;
935
- }
936
- export {
937
- $ as A,
938
- he as S,
939
- Be as a,
940
- Ve as b,
941
- He as c,
942
- Re as d,
943
- R as e,
944
- qe as f,
945
- Fe as g,
946
- je as h,
947
- ge as i,
948
- Je as j,
949
- Ue as k,
950
- Te as l,
951
- xe as m,
952
- Se as n,
953
- Ye as p,
954
- Le as r,
955
- Ne as s,
956
- we as t
957
- };