react-semaphor 0.1.544 → 0.1.546

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 (179) hide show
  1. package/dist/analytics-protocol/index.js +405 -441
  2. package/dist/assistant-context/index.js +1 -1
  3. package/dist/assistant-protocol/index.js +100 -76
  4. package/dist/brand-studio/index.js +5 -5
  5. package/dist/briefings/index.js +55 -52
  6. package/dist/chunks/{class-utils-Df1OVOT1.js → _commonjsHelpers-DimLPMtv.js} +124 -98
  7. package/dist/chunks/{add-to-dashboard-BuAqfA2Y.js → add-to-dashboard-BQRAAnc3.js} +55 -33
  8. package/dist/chunks/{analytics-base-schemas-BFAoRlkU.js → analytics-base-schemas-BKs3flFS.js} +2 -2
  9. package/dist/chunks/{assistant-chat-BNLkCDml.js → assistant-chat-BPXhulAx.js} +2792 -2562
  10. package/dist/chunks/{bookmark-state-CXw7lZ50.js → bookmark-state-C4vetoa0.js} +7 -8
  11. package/dist/chunks/column-catalog-BYnochWQ.js +3363 -0
  12. package/dist/chunks/comparison-window-caption-C2xF-eWw.js +1433 -0
  13. package/dist/chunks/{context-ClREvqCZ.js → context-BerEBuFR.js} +11 -6
  14. package/dist/chunks/custom-visual-inputs-CkJW9pBS.js +295 -0
  15. package/dist/chunks/{dashboard-g5a4DKWq.js → dashboard-C3CoKbGY.js} +1 -1
  16. package/dist/chunks/dashboard-briefing-launcher-Be4h-7My.js +3734 -0
  17. package/dist/chunks/dashboard-controls-bxPrlSyp.js +2307 -0
  18. package/dist/chunks/{dashboard-json-7qT9jmfL.js → dashboard-json-BrjxIiRt.js} +6 -6
  19. package/dist/chunks/document-dashboard-inputs-CRVHpIHp.js +3010 -0
  20. package/dist/chunks/{edit-dashboard-visual-BfJwnRIZ.js → edit-dashboard-visual-DYYYDjY6.js} +5986 -6063
  21. package/dist/chunks/{filter-value-text-CYsVYPuD.js → filter-value-text-Ddf55Ku1.js} +8 -8
  22. package/dist/chunks/global-date-filter-utils-9d6m9-FE.js +11859 -0
  23. package/dist/chunks/index-CtoK1Lgu.js +586 -0
  24. package/dist/chunks/{index-DkAyQvC6.js → index-DkQkMKa1.js} +385 -339
  25. package/dist/chunks/list-filter-DsaTbM3J.js +15 -0
  26. package/dist/chunks/matrix-analytical-definition-B9vW-osb.js +717 -0
  27. package/dist/chunks/{matrix-card-DjwWcCo8.js → matrix-card-LiMEipvq.js} +3 -3
  28. package/dist/chunks/{matrix-formatter-CxJLkztA.js → matrix-formatter-DWEeC0_c.js} +55 -55
  29. package/dist/chunks/{matrix-member-presentation-CQGdVks6.js → matrix-member-presentation-DqzG-UhQ.js} +1 -1
  30. package/dist/chunks/{matrix-operation-contract-8OIO4gob.js → matrix-operation-contract-D6vYkZK4.js} +72 -72
  31. package/dist/chunks/{metric-comparison-DEwi9uc2.js → metric-comparison-zpGw4lD6.js} +2 -2
  32. package/dist/chunks/normalize-dashboard-for-dirty-check-XKgH3GFX.js +119 -0
  33. package/dist/chunks/{pivot-header-presentation-DHcx1XGQ.js → pivot-header-presentation-CQnIDtUv.js} +1 -1
  34. package/dist/chunks/{pivot-result-identity-DJhXXcns.js → pivot-result-identity-C-Q1j1Wb.js} +1 -1
  35. package/dist/chunks/{pivot-result-lifecycle-DM4CyGKs.js → pivot-result-lifecycle-pwq3b7LC.js} +571 -380
  36. package/dist/chunks/{raw-temporal-contract-C51YG48G.js → raw-temporal-contract-WuXA8jBP.js} +1 -1
  37. package/dist/chunks/{raw-temporal-presentation-CLiVi90c.js → raw-temporal-presentation-CBzrDOjM.js} +8 -8
  38. package/dist/chunks/rendered-file-D8xEuVVx.js +108 -0
  39. package/dist/chunks/{report-preferences-dialog-Df7VpRVW.js → report-preferences-dialog-4QEZWe5U.js} +637 -610
  40. package/dist/chunks/{report-runtime-context-Dq8XyODK.js → report-runtime-context-hWiTCzFV.js} +2 -2
  41. package/dist/chunks/resolve-dashboard-input-context-UpK_LBpL.js +5677 -0
  42. package/dist/chunks/{saved-dashboard-context-B-mQ--nV.js → saved-dashboard-context-D_I3Lxk0.js} +184 -212
  43. package/dist/chunks/selection-filter-compiler-BKXmyLrS.js +79 -0
  44. package/dist/chunks/{selection-reducer-Dj_8xD69.js → selection-reducer-CJzkTZio.js} +15 -15
  45. package/dist/chunks/{semaphor-ready-indicator-DDAxk8us.js → semaphor-ready-indicator-4zpRHE-X.js} +56832 -59068
  46. package/dist/chunks/{shelf-drop-preview-context-BSRPwaED.js → shelf-drop-preview-context-Cfw7TRAx.js} +890 -871
  47. package/dist/chunks/{source-entity-resolution-BYn9giz3.js → source-entity-resolution-BIGRvtbG.js} +13 -13
  48. package/dist/chunks/{switch-C3jLxlG0.js → switch-CEBOR4n7.js} +47 -48
  49. package/dist/chunks/{table-export-sheet-CPfGAQ9X.js → table-export-sheet-4X9mAG3V.js} +1 -1
  50. package/dist/chunks/table-settings-CunhoDUi.js +605 -0
  51. package/dist/chunks/{temporal-bucket-D7NBrrtL.js → temporal-bucket-CQOSbv9-.js} +26 -26
  52. package/dist/chunks/{token-types-DBbZVQsm.js → token-types-BMqRmT-C.js} +1 -1
  53. package/dist/chunks/{use-create-flow-overlay-state-BxzFviM-.js → use-create-flow-overlay-state-DZBZiiD-.js} +83 -83
  54. package/dist/chunks/{validators-DMHTpf7a.js → validators-C-aOQlTB.js} +713 -658
  55. package/dist/dashboard/index.js +2 -2
  56. package/dist/dashboard-authoring/index.js +1800 -1135
  57. package/dist/data-app-sdk/index.js +6 -6
  58. package/dist/data-app-sdk-adapters/index.js +3 -3
  59. package/dist/data-app-sdk-validation/index.js +14 -14
  60. package/dist/format-utils/index.js +198 -187
  61. package/dist/index.js +359 -325
  62. package/dist/layouts/index.js +5 -242
  63. package/dist/report-runtime-context/index.js +2 -2
  64. package/dist/shared/index.js +4 -5
  65. package/dist/style.css +1 -1
  66. package/dist/surfboard/index.js +2 -2
  67. package/dist/types/briefings/attachment-outcomes.d.ts +1 -1
  68. package/dist/types/briefings/attachments.d.ts +33 -6
  69. package/dist/types/briefings/index.d.ts +6 -5
  70. package/dist/types/components/index.d.ts +2 -0
  71. package/dist/types/components/surfboard/arrange-layout-button.d.ts +8 -0
  72. package/dist/types/components/surfboard/filter/types.d.ts +0 -14
  73. package/dist/types/components/surfboard/screen-size-preview-button.d.ts +7 -0
  74. package/dist/types/index.js +6 -6
  75. package/dist/types/lib/charts/table-chart-types.d.ts +4 -0
  76. package/dist/types/lib/charts/types.d.ts +2 -2
  77. package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-authoring.d.ts +68 -82
  78. package/dist/types/lib/dashboard-inputs/dashboard-input-target-context.d.ts +0 -8
  79. package/dist/types/lib/dashboard-inputs/dashboard-input-values.d.ts +41 -1
  80. package/dist/types/lib/dashboard-inputs/filter-settings.d.ts +201 -0
  81. package/dist/types/lib/dashboard-inputs/prepare-loaded-dashboard.d.ts +15 -0
  82. package/dist/types/lib/dashboard-inputs/resolve-dashboard-input-context.d.ts +7 -2
  83. package/dist/types/lib/dashboard-inputs/resolve-selection-input.d.ts +1 -1
  84. package/dist/types/lib/dashboard-viewer/captured-runtime-values.d.ts +40 -0
  85. package/dist/types/lib/dashboard-viewer/compatibility-input-storage.d.ts +16 -16
  86. package/dist/types/lib/dashboard-viewer/viewer-state.d.ts +11 -9
  87. package/dist/types/lib/download-pdf.d.ts +75 -1
  88. package/dist/types/lib/hooks/use-date-filter.d.ts +5 -0
  89. package/dist/types/lib/hooks/use-text-filter.d.ts +5 -0
  90. package/dist/types/lib/matrix-table/matrix-delivery-policy.d.ts +5 -4
  91. package/dist/types/lib/matrix-table/matrix-editor.d.ts +52 -0
  92. package/dist/types/lib/query-context/assemble-card-query.d.ts +158 -0
  93. package/dist/types/lib/query-context/build-card-query-context.d.ts +3 -3
  94. package/dist/types/lib/query-context/build-dashboard-card-query-contract.d.ts +15 -6
  95. package/dist/types/lib/query-context/build-dashboard-execution-snapshot.d.ts +11 -13
  96. package/dist/types/lib/query-context/compile-dashboard-card-filters.d.ts +22 -12
  97. package/dist/types/lib/query-context/dashboard-filter-mapping-resolution.d.ts +69 -0
  98. package/dist/types/lib/stores/dashboard-store.d.ts +159 -56
  99. package/dist/types/lib/stores/editor-store.d.ts +0 -3
  100. package/dist/types/lib/types/common-types.d.ts +29 -6
  101. package/dist/types/lib/types/explorer-types.d.ts +10 -0
  102. package/dist/types/lib/types/semantic-types.d.ts +84 -0
  103. package/dist/types/lib/utils/build-saved-editor-card.d.ts +20 -0
  104. package/dist/types/lib/utils/card-type-change.d.ts +16 -0
  105. package/dist/types/lib/utils/field-availability-context.d.ts +25 -0
  106. package/dist/types/lib/utils/field-placement.d.ts +96 -0
  107. package/dist/types/lib/utils/field-state-calculator.d.ts +161 -0
  108. package/dist/types/lib/utils/qualified-entity-name.d.ts +2 -0
  109. package/dist/types/shared/analytics-protocol/field-provenance.d.ts +89 -0
  110. package/dist/types/shared/analytics-protocol/index.d.ts +2 -0
  111. package/dist/types/shared/analytics-protocol/query-policies.d.ts +52 -0
  112. package/dist/types/shared/analytics-protocol/time-window-schema.d.ts +1 -1
  113. package/dist/types/shared/analytics-protocol/time-window.d.ts +40 -1
  114. package/dist/types/shared/assistant-context/saved-dashboard-context.d.ts +8 -12
  115. package/dist/types/shared/assistant-protocol/answer-text.d.ts +20 -0
  116. package/dist/types/shared/assistant-protocol/context.d.ts +21 -21
  117. package/dist/types/shared/assistant-protocol/index.d.ts +1 -0
  118. package/dist/types/shared/assistant-protocol/limits.d.ts +6 -1
  119. package/dist/types/shared/assistant-protocol/parts.d.ts +43 -3
  120. package/dist/types/shared/assistant-protocol/request.d.ts +14 -2
  121. package/dist/types/shared/dashboard-authoring/calculated-field-identity.d.ts +3 -0
  122. package/dist/types/shared/dashboard-authoring/changes/card-query-part.d.ts +487 -0
  123. package/dist/types/shared/dashboard-authoring/changes/card-types.d.ts +34 -0
  124. package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +7886 -0
  125. package/dist/types/shared/dashboard-authoring/changes/diagnostics.d.ts +43 -0
  126. package/dist/types/shared/dashboard-authoring/changes/read-card-query.d.ts +54 -0
  127. package/dist/types/shared/dashboard-authoring/changes/resolve-dashboard-changes.d.ts +89 -0
  128. package/dist/types/shared/dashboard-authoring/column-catalog.d.ts +32 -0
  129. package/dist/types/shared/dashboard-authoring/contracts.d.ts +0 -55
  130. package/dist/types/shared/dashboard-authoring/control-execution-contract.d.ts +16 -6
  131. package/dist/types/shared/dashboard-authoring/dashboard-card-source-index.d.ts +9 -1
  132. package/dist/types/shared/dashboard-authoring/dashboard-filter-mapping-contract.d.ts +7 -0
  133. package/dist/types/shared/dashboard-authoring/dashboard-input-scope.d.ts +118 -0
  134. package/dist/types/shared/dashboard-authoring/filter-applicability.d.ts +75 -0
  135. package/dist/types/shared/dashboard-authoring/filter-model/ad-hoc-filter-values.d.ts +10 -0
  136. package/dist/types/shared/dashboard-authoring/filter-model/filter-definitions.d.ts +29 -0
  137. package/dist/types/shared/dashboard-authoring/filter-model/filter-values.d.ts +58 -0
  138. package/dist/types/shared/dashboard-authoring/filter-model/index.d.ts +7 -0
  139. package/dist/types/shared/dashboard-authoring/filter-model/prototype-document-inputs.d.ts +15 -0
  140. package/dist/types/shared/dashboard-authoring/filter-model/read-dashboard-filter-model.d.ts +78 -0
  141. package/dist/types/shared/dashboard-authoring/filter-model/stored-dashboard.d.ts +18 -0
  142. package/dist/types/shared/dashboard-authoring/filter-model/toolbar-filter-reach.d.ts +23 -0
  143. package/dist/types/shared/dashboard-authoring/index.d.ts +20 -2
  144. package/dist/types/shared/dashboard-authoring/operations/apply-dashboard-operations.d.ts +10 -37
  145. package/dist/types/shared/dashboard-authoring/operations/operation-types.d.ts +189 -0
  146. package/dist/types/shared/dashboard-authoring/outline/outline-dashboard.d.ts +94 -0
  147. package/dist/types/shared/dashboard-authoring/outline/outline-filters.d.ts +78 -0
  148. package/dist/types/shared/dashboard-authoring/validators.d.ts +1 -2
  149. package/dist/types/shared/format-utils/exporters/index.d.ts +2 -0
  150. package/dist/types/shared/format-utils/exporters/rendered-file.d.ts +106 -0
  151. package/dist/types/shared/layouts/engine/grid.d.ts +25 -0
  152. package/dist/types/shared/layouts/engine/index.d.ts +4 -0
  153. package/dist/types/shared/layouts/engine/sheet-layout.d.ts +7 -0
  154. package/dist/types/shared/layouts/engine/types.d.ts +125 -0
  155. package/dist/types/shared/layouts/index.d.ts +1 -2
  156. package/package.json +2 -2
  157. package/dist/chunks/_commonjsHelpers-BkfeUUK-.js +0 -28
  158. package/dist/chunks/apply-dashboard-operations-Bz4n1Lq6.js +0 -2260
  159. package/dist/chunks/calendar-day-equality-BmJAWduY.js +0 -460
  160. package/dist/chunks/comparison-window-caption-BTkrN3W4.js +0 -1623
  161. package/dist/chunks/custom-visual-inputs-DUtpYZOk.js +0 -323
  162. package/dist/chunks/dashboard-briefing-launcher-DQ_8O_e2.js +0 -3725
  163. package/dist/chunks/dashboard-controls-8RyBTQUO.js +0 -2315
  164. package/dist/chunks/dashboard-filter-value-compatibility-CwQ_iSNb.js +0 -108
  165. package/dist/chunks/document-dashboard-inputs-BC6p-ESg.js +0 -8087
  166. package/dist/chunks/document-sheet-utils-Duo9uLoH.js +0 -3619
  167. package/dist/chunks/matrix-analytical-definition-C7Gb0e12.js +0 -117
  168. package/dist/chunks/normalize-dashboard-for-dirty-check-Bk3VYv_q.js +0 -67
  169. package/dist/chunks/numeric-presentation-DESvLiu9.js +0 -5227
  170. package/dist/chunks/sort-target-MT1WK1vX.js +0 -29
  171. package/dist/chunks/stable-serialize-CfqXeiBP.js +0 -6
  172. package/dist/chunks/table-settings-CLZocegs.js +0 -501
  173. package/dist/chunks/use-debounced-dirty-check-BwAbnX_5.js +0 -59
  174. package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-storage-transition.d.ts +0 -88
  175. package/dist/types/lib/dashboard-inputs/dashboard-input-scope.d.ts +0 -10
  176. package/dist/types/shared/dashboard-authoring/change-compiler.d.ts +0 -7
  177. package/dist/types/shared/dashboard-authoring/layout-compiler.d.ts +0 -2
  178. package/dist/types/shared/layouts/create-frame-layouts.d.ts +0 -27
  179. package/dist/types/shared/layouts/frame-layouts.d.ts +0 -23
@@ -1,144 +1,149 @@
1
- var we = Object.defineProperty;
2
- var Fe = (e, t, a) => t in e ? we(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a;
3
- var z = (e, t, a) => Fe(e, typeof t != "symbol" ? t + "" : t, a);
4
- import { D as L, a as xe, r as H } from "../chunks/apply-dashboard-operations-Bz4n1Lq6.js";
5
- import { N as ca, b as la, u as ua, e as fa, j as pa, l as ma, k as ha, f as ga, i as ba, c as Ia, t as Ca, m as ya, o as _a, q as Da, g as Sa, p as va, h as Ta, n as wa, d as Fa, s as xa } from "../chunks/apply-dashboard-operations-Bz4n1Lq6.js";
6
- import { c as ke, a as Ae, v as Oe, f as Re, d as Ee, p as Ne } from "../chunks/numeric-presentation-DESvLiu9.js";
7
- import { A as Aa, Q as Oa, R as Ra, T as Ea, N as Na, O as Ma, P as Pa, J as $a, K as Ba, M as La, L as qa, U as Va, a4 as za, S as ja, V as Ua, b as Ga, a3 as Ha, a2 as Wa, o as Ka, x as Qa, q as Xa, u as Ya, w as Ja, a7 as Za, I as er, H as tr, C as ar, a8 as rr, h as nr, j as ir, $ as or, i as sr, a0 as dr, a1 as cr, B as lr, D as ur, z as fr, a5 as pr, a6 as mr, e as hr, a9 as gr, F as br, l as Ir, X as Cr, m as yr, Z as _r, _ as Dr, Y as Sr, k as vr, E as Tr, y as wr, s as Fr, t as xr, G as kr, W as Ar } from "../chunks/numeric-presentation-DESvLiu9.js";
8
- import { q as Me, A as Y, au as Pe, B as fe, l as $e, ag as Be } from "../chunks/validators-DMHTpf7a.js";
9
- import "../chunks/matrix-operation-contract-8OIO4gob.js";
10
- import "../chunks/analytics-base-schemas-BFAoRlkU.js";
1
+ var Rt = Object.defineProperty;
2
+ var Et = (e, t, a) => t in e ? Rt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a;
3
+ var Te = (e, t, a) => Et(e, typeof t != "symbol" ? t + "" : t, a);
4
+ import { D as at, r as gt, b as Ot, c as Nt, a as st, d as qt } from "../chunks/column-catalog-BYnochWQ.js";
5
+ import { N as bi, f as Ii, j as yi, l as _i, k as Ci, u as Si, q as vi, e as xi, i as wi, s as Di, t as Ti, m as ki, n as $i, p as Fi, g as Ai, o as Ri, h as Ei } from "../chunks/column-catalog-BYnochWQ.js";
6
+ import { M as Pt, N as Mt, O as ke, P as Lt, Q as Bt, R as Vt, S as Gt, T as Ut, U as jt, V as zt, W as Qt, X as de, Y as Kt, Z as Wt, _ as ve, $ as Ht, a0 as Yt, a1 as Me, a2 as bt, a3 as oe, a4 as ne, a5 as Re, a6 as Xt, a7 as Le, a8 as Jt, a9 as Zt, aa as ea, ab as it, ac as ta, ad as aa, ae as It, af as ie, ag as nt, ah as sa, ai as ia, aj as Ee, ak as na, al as ot, am as oa, an as rt, ao as ra, ap as ce, aq as da, ar as dt, b as la, as as ca, at as ua, au as fa, av as ha, aw as lt, ax as pa, ay as ma, az as ga, aA as ba, aB as Ia, aC as ya, aD as _a, aE as Ca, aF as Sa, aG as $e, aH as va } from "../chunks/global-date-filter-utils-9d6m9-FE.js";
7
+ import { cs as Ni, aR as qi, c3 as Pi, c4 as Mi, cj as Li, ci as Bi, cc as Vi, ck as Gi, cl as Ui, bJ as ji, bK as zi, bL as Qi, bG as Ki, bH as Wi, bI as Hi, bC as Yi, bD as Xi, bF as Ji, bE as Zi, bM as en, cF as tn, c5 as an, b2 as sn, b1 as nn, bZ as on, cu as rn, bc as dn, cy as ln, cg as cn, ch as un, aO as fn, cx as hn, bf as pn, cv as mn, bt as gn, cb as bn, bN as In, bu as yn, cH as _n, aJ as Cn, cz as Sn, cf as vn, aK as xn, bY as wn, bX as Dn, b6 as Tn, aZ as kn, cD as $n, bo as Fn, d as An, a as Rn, bg as En, aL as On, cr as Nn, a_ as qn, a$ as Pn, b0 as Mn, bb as Ln, bd as Bn, c0 as Vn, g as Gn, bB as Un, bk as jn, bA as zn, bx as Qn, c1 as Kn, aT as Wn, aU as Hn, cB as Yn, bh as Xn, b3 as Jn, cd as Zn, b8 as eo, cp as to, bm as ao, bT as so, aP as io, bV as no, bW as oo, cE as ro, br as lo, bj as co, bl as uo, b7 as fo, bn as ho, cm as po, cA as mo, aM as go, ct as bo, bq as Io, b4 as yo, bw as _o, cn as Co, b_ as So, b$ as vo, aS as xo, cG as wo, c2 as Do, c9 as To, bz as ko, aW as $o, co as Fo, cC as Ao, cq as Ro, bs as Eo, b5 as Oo, bP as No, aY as qo, c6 as Po, c7 as Mo, aX as Lo, bR as Bo, bS as Vo, bQ as Go, aV as Uo, by as jo, c8 as zo, bp as Qo, ce as Ko, aI as Wo, bv as Ho, bU as Yo, aQ as Xo, cw as Jo, be as Zo, bi as er, aN as tr, bO as ar, ba as sr, b9 as ir, ca as nr } from "../chunks/global-date-filter-utils-9d6m9-FE.js";
8
+ import { x as xa, ao as Be, ap as wa, a3 as yt, ab as Da, a6 as Ta, ad as _t, aD as ka, aB as Ct, aC as $a } from "../chunks/validators-C-aOQlTB.js";
9
+ import "../chunks/matrix-operation-contract-D6vYkZK4.js";
10
+ import "../chunks/analytics-base-schemas-BKs3flFS.js";
11
11
  import "zod";
12
- import { m as j } from "../chunks/document-sheet-utils-Duo9uLoH.js";
13
- import { p as Rr, D as Er, l as Nr, v as Mr, b as Pr, k as $r, g as Br, d as Lr, f as qr, n as Vr, u as zr, j as jr, r as Ur, h as Gr, q as Hr, s as Wr, i as Kr, o as Qr, t as Xr, w as Yr } from "../chunks/document-sheet-utils-Duo9uLoH.js";
14
- import { n as Le } from "../chunks/operators-B3zZoskU.js";
15
- import { a as Zr, b as en, r as tn } from "../chunks/raw-temporal-presentation-CLiVi90c.js";
16
- import { D as rn, w as nn, z as on, x as sn, v as dn, y as cn } from "../chunks/table-settings-CLZocegs.js";
17
- import { D as un, d as fn, i as pn, v as mn } from "../chunks/dashboard-filter-value-compatibility-CwQ_iSNb.js";
18
- import { D as gn, C as bn, A as In, B as Cn, E as yn, F as _n } from "../chunks/pivot-result-lifecycle-DM4CyGKs.js";
19
- import { e as qe, w as Ve } from "../chunks/metric-comparison-DEwi9uc2.js";
20
- import { p as ze } from "../chunks/report-runtime-context-Dq8XyODK.js";
21
- import { m as Sn, a as vn, r as Tn } from "../chunks/matrix-card-DjwWcCo8.js";
22
- function S(e) {
12
+ import { a as Fa, r as Aa } from "../chunks/index-CtoK1Lgu.js";
13
+ import { n as Ra } from "../chunks/operators-B3zZoskU.js";
14
+ import { a as rr, b as dr, r as lr } from "../chunks/raw-temporal-presentation-CBzrDOjM.js";
15
+ import { w as re } from "../chunks/table-settings-CunhoDUi.js";
16
+ import { D as ur, x as fr, y as hr, F as pr, B as mr, z as gr, G as br, A as Ir, v as yr } from "../chunks/table-settings-CunhoDUi.js";
17
+ import { v as Ea, w as Oe, x as Oa } from "../chunks/resolve-dashboard-input-context-UpK_LBpL.js";
18
+ import { M as Cr, S as Sr, N as vr, b as xr, Q as wr, L as Dr, A as Tr, T as kr, U as $r, P as Fr, F as Ar, G as Rr, J as Er, K as Or, I as Nr, y as qr, z as Pr, p as Mr, R as Lr, H as Br, B as Vr, C as Gr, D as Ur, O as jr, E as zr } from "../chunks/resolve-dashboard-input-context-UpK_LBpL.js";
19
+ import { G as Kr, F as Wr, D as Hr, E as Yr, H as Xr, I as Jr } from "../chunks/pivot-result-lifecycle-pwq3b7LC.js";
20
+ import { e as Na, w as qa } from "../chunks/metric-comparison-zpGw4lD6.js";
21
+ import { p as Pa } from "../chunks/report-runtime-context-hWiTCzFV.js";
22
+ import { m as ed, a as td, r as ad } from "../chunks/matrix-card-LiMEipvq.js";
23
+ import { n as ct, t as Ma } from "../chunks/matrix-analytical-definition-B9vW-osb.js";
24
+ import "../chunks/index-CuHybtft.js";
25
+ import "../value-format-preferences/index.js";
26
+ import "../chunks/_commonjsHelpers-DimLPMtv.js";
27
+ function H(e) {
23
28
  return e && typeof e == "object" ? e : null;
24
29
  }
25
- function T(e) {
30
+ function Z(e) {
26
31
  return typeof e == "string" ? e : null;
27
32
  }
28
- function je(e) {
29
- var t, a, r;
30
- return !!(e && typeof e == "object") && (((t = S(e)) == null ? void 0 : t.kind) === "semantic" || ((a = S(e)) == null ? void 0 : a.kind) === "physical" || ((r = S(e)) == null ? void 0 : r.kind) === "sql");
33
+ function La(e) {
34
+ var t, a, s;
35
+ return !!(e && typeof e == "object") && (((t = H(e)) == null ? void 0 : t.kind) === "semantic" || ((a = H(e)) == null ? void 0 : a.kind) === "physical" || ((s = H(e)) == null ? void 0 : s.kind) === "sql");
31
36
  }
32
- function R(e) {
33
- return je(e) ? e.kind === "semantic" ? !!(e.domainId && e.datasetName) : e.kind === "physical" ? !!(e.connectionId && e.tableName) : !1 : !1;
37
+ function pe(e) {
38
+ return La(e) ? e.kind === "semantic" ? !!(e.domainId && e.datasetName) : e.kind === "physical" ? !!(e.connectionId && e.tableName) : !1 : !1;
34
39
  }
35
- function Xt(e) {
36
- return Me(e);
40
+ function si(e) {
41
+ return xa(e);
37
42
  }
38
- function pe(e, t) {
39
- return Y(e, t);
43
+ function St(e, t) {
44
+ return Be(e, t);
40
45
  }
41
- function Ue(e, t) {
42
- return Pe(e, t);
46
+ function Ba(e, t) {
47
+ return wa(e, t);
43
48
  }
44
- function q(e) {
49
+ function xe(e) {
45
50
  const t = [];
46
51
  for (const a of e) {
47
- const r = t.findIndex(
48
- (n) => pe(n, a)
52
+ const s = t.findIndex(
53
+ (d) => St(d, a)
49
54
  );
50
- r === -1 ? t.push(a) : t[r] = Ue(
51
- t[r],
55
+ s === -1 ? t.push(a) : t[s] = Ba(
56
+ t[s],
52
57
  a
53
58
  );
54
59
  }
55
60
  return t;
56
61
  }
57
- function Yt(e) {
58
- return q(e)[0];
62
+ function ii(e) {
63
+ return xe(e)[0];
59
64
  }
60
- function W(e, t) {
61
- return e.kind !== "semantic" || e.connectionId || (t == null ? void 0 : t.kind) !== "semantic" || !Y(e, t) || !t.connectionId ? e : { ...e, connectionId: t.connectionId };
65
+ function Ne(e, t) {
66
+ return e.kind !== "semantic" || e.connectionId || (t == null ? void 0 : t.kind) !== "semantic" || !Be(e, t) || !t.connectionId ? e : { ...e, connectionId: t.connectionId };
62
67
  }
63
- function K(e) {
64
- return R(e) ? e : void 0;
68
+ function qe(e) {
69
+ return pe(e) ? e : void 0;
65
70
  }
66
- function le(e, t) {
71
+ function ut(e, t) {
67
72
  if (!(e.kind !== "semantic" || e.connectionId))
68
73
  return t.find(
69
- (a) => (a == null ? void 0 : a.kind) === "semantic" && Y(e, a) && !!a.connectionId
74
+ (a) => (a == null ? void 0 : a.kind) === "semantic" && Be(e, a) && !!a.connectionId
70
75
  );
71
76
  }
72
- function v(e, t) {
73
- const a = K(e == null ? void 0 : e.source);
74
- return a ? W(a, t) : void 0;
77
+ function J(e, t) {
78
+ const a = qe(e == null ? void 0 : e.source);
79
+ return a ? Ne(a, t) : void 0;
75
80
  }
76
- function Ge({
81
+ function Va({
77
82
  explicitSource: e,
78
83
  field: t,
79
84
  defaultSource: a,
80
- fallbackSources: r
85
+ fallbackSources: s
81
86
  }) {
82
- const n = [a, ...r || []], i = K(e), o = i ? W(
87
+ const d = [a, ...s || []], i = qe(e), n = i ? Ne(
83
88
  i,
84
- le(i, n)
89
+ ut(i, d)
85
90
  ) : void 0;
86
- if (o)
87
- return o;
91
+ if (n)
92
+ return n;
88
93
  if (e !== void 0)
89
94
  return;
90
- const s = v(t, a), l = s ? W(
91
- s,
92
- le(s, n)
95
+ const o = J(t, a), p = o ? Ne(
96
+ o,
97
+ ut(o, d)
93
98
  ) : void 0;
94
- if (l)
95
- return l;
99
+ if (p)
100
+ return p;
96
101
  if ((t == null ? void 0 : t.source) === void 0)
97
- return K(a);
102
+ return qe(a);
98
103
  }
99
- function Jt(e, t) {
104
+ function ni(e, t) {
100
105
  if (!(e != null && e.name) || !(t != null && t.name) || e.name !== t.name)
101
106
  return !1;
102
- const a = v(e), r = v(t);
103
- return !a || !r ? !0 : pe(a, r);
107
+ const a = J(e), s = J(t);
108
+ return !a || !s ? !0 : St(a, s);
104
109
  }
105
- function k(e) {
110
+ function se(e) {
106
111
  var t;
107
- return T((t = S(e)) == null ? void 0 : t.kind);
112
+ return Z((t = H(e)) == null ? void 0 : t.kind);
108
113
  }
109
- function me(e) {
114
+ function vt(e) {
110
115
  var t, a;
111
- return k(e) !== "semantic" ? null : ((a = T((t = S(e)) == null ? void 0 : t.domainId)) == null ? void 0 : a.trim()) || null;
116
+ return se(e) !== "semantic" ? null : ((a = Z((t = H(e)) == null ? void 0 : t.domainId)) == null ? void 0 : a.trim()) || null;
112
117
  }
113
- function He(e) {
118
+ function Ga(e) {
114
119
  var t;
115
- return k(e) !== "semantic" ? null : T((t = S(e)) == null ? void 0 : t.datasetName);
120
+ return se(e) !== "semantic" ? null : Z((t = H(e)) == null ? void 0 : t.datasetName);
116
121
  }
117
- function We(e) {
122
+ function Ua(e) {
118
123
  var t;
119
- return k(e) !== "semantic" ? null : T((t = S(e)) == null ? void 0 : t.datasetId);
124
+ return se(e) !== "semantic" ? null : Z((t = H(e)) == null ? void 0 : t.datasetId);
120
125
  }
121
- function Ke(e) {
126
+ function ja(e) {
122
127
  var t;
123
- return k(e) !== "physical" ? null : T((t = S(e)) == null ? void 0 : t.connectionId);
128
+ return se(e) !== "physical" ? null : Z((t = H(e)) == null ? void 0 : t.connectionId);
124
129
  }
125
- function Qe(e) {
130
+ function za(e) {
126
131
  var t;
127
- return k(e) !== "physical" ? null : T((t = S(e)) == null ? void 0 : t.tableName);
132
+ return se(e) !== "physical" ? null : Z((t = H(e)) == null ? void 0 : t.tableName);
128
133
  }
129
- function Xe(e) {
134
+ function Qa(e) {
130
135
  var t;
131
- return k(e) !== "physical" ? "" : T((t = S(e)) == null ? void 0 : t.databaseName) || "";
136
+ return se(e) !== "physical" ? "" : Z((t = H(e)) == null ? void 0 : t.databaseName) || "";
132
137
  }
133
- function Ye(e) {
138
+ function Ka(e) {
134
139
  var t;
135
- return k(e) !== "physical" ? "" : T((t = S(e)) == null ? void 0 : t.schemaName) || "";
140
+ return se(e) !== "physical" ? "" : Z((t = H(e)) == null ? void 0 : t.schemaName) || "";
136
141
  }
137
- function Je(e) {
142
+ function Wa(e) {
138
143
  if (e.analyticsIntent && typeof e.analyticsIntent == "object" && "source" in e.analyticsIntent)
139
144
  return e.analyticsIntent.source;
140
145
  }
141
- function Ze({
146
+ function Ha({
142
147
  datasets: e,
143
148
  requireAtLeastOne: t
144
149
  }) {
@@ -146,27 +151,27 @@ function Ze({
146
151
  return { ok: !1, issue: "invalid_dataset_count" };
147
152
  if (e.length <= 1)
148
153
  return { ok: !0 };
149
- const a = e.map(me), r = new Set(a.filter(Boolean));
150
- return a.some((n) => !n) || r.size !== 1 ? { ok: !1, issue: "invalid_multi_dataset_scope" } : { ok: !0 };
154
+ const a = e.map(vt), s = new Set(a.filter(Boolean));
155
+ return a.some((d) => !d) || s.size !== 1 ? { ok: !1, issue: "invalid_multi_dataset_scope" } : { ok: !0 };
151
156
  }
152
- function J(e, t) {
157
+ function Ve(e, t) {
153
158
  if (!t)
154
159
  return !1;
155
160
  if (t.kind === "semantic") {
156
- const a = We(e);
157
- return me(e) === t.domainId ? a && t.datasetId ? a === t.datasetId : He(e) === t.datasetName : !1;
161
+ const a = Ua(e);
162
+ return vt(e) === t.domainId ? a && t.datasetId ? a === t.datasetId : Ga(e) === t.datasetName : !1;
158
163
  }
159
- return t.kind === "physical" ? Ke(e) === t.connectionId && Qe(e) === t.tableName && Xe(e) === (t.databaseName || "") && Ye(e) === (t.schemaName || "") : !1;
164
+ return t.kind === "physical" ? ja(e) === t.connectionId && za(e) === t.tableName && Qa(e) === (t.databaseName || "") && Ka(e) === (t.schemaName || "") : !1;
160
165
  }
161
- function Zt(e, t) {
166
+ function oi(e, t) {
162
167
  return e.find(
163
- (a) => J(a, t)
168
+ (a) => Ve(a, t)
164
169
  );
165
170
  }
166
- function f(e, t, a) {
171
+ function P(e, t, a) {
167
172
  return a ? { code: e, message: t, cardId: a } : { code: e, message: t };
168
173
  }
169
- function M(e) {
174
+ function ye(e) {
170
175
  const t = /* @__PURE__ */ new Set();
171
176
  for (const a of e) {
172
177
  if (t.has(a))
@@ -175,19 +180,19 @@ function M(e) {
175
180
  }
176
181
  return null;
177
182
  }
178
- function he({
183
+ function Ya({
179
184
  card: e,
180
185
  datasets: t,
181
186
  errors: a
182
187
  }) {
183
188
  if (e.type === "text")
184
189
  return;
185
- const r = Je(e);
186
- if (!r) {
190
+ const s = Wa(e);
191
+ if (!s) {
187
192
  if (t.length <= 1)
188
193
  return;
189
194
  a.push(
190
- f(
195
+ P(
191
196
  "missing_card_analytics_source",
192
197
  "Multi-dataset dashboard cards must include analytics intent with a source so the materializer can choose the correct dataset.",
193
198
  e.id
@@ -195,68 +200,68 @@ function he({
195
200
  );
196
201
  return;
197
202
  }
198
- t.some((n) => J(n, r)) || a.push(
199
- f(
203
+ t.some((d) => Ve(d, s)) || a.push(
204
+ P(
200
205
  "invalid_card_analytics_source",
201
206
  "Dashboard cards with an explicit analytics source must use one of the selected datasets.",
202
207
  e.id
203
208
  )
204
209
  );
205
210
  }
206
- function P(e) {
211
+ function _e(e) {
207
212
  return e.map((t) => t == null ? void 0 : t.source).filter((t) => !!t);
208
213
  }
209
- function U(e) {
214
+ function Fe(e) {
210
215
  return Array.isArray(e) ? e.filter(
211
216
  (t) => !!(t && typeof t == "object")
212
217
  ) : [];
213
218
  }
214
- function ue(e) {
219
+ function ft(e) {
215
220
  return Array.isArray(e) ? e.filter(
216
221
  (t) => !!(t && typeof t == "object")
217
222
  ) : [];
218
223
  }
219
- function et(e) {
220
- var a, r;
224
+ function Xa(e) {
225
+ var a, s;
221
226
  if (!e)
222
227
  return [];
223
228
  const t = [e.source];
224
229
  return e.kind === "metric" ? t.push(
225
- ...P([
226
- ...U(e.measures),
230
+ ..._e([
231
+ ...Fe(e.measures),
227
232
  e.primaryMeasure,
228
233
  e.dateField,
229
- ...U(e.dimensions),
230
- ...ue(e.filters).map((n) => n.field)
234
+ ...Fe(e.dimensions),
235
+ ...ft(e.filters).map((d) => d.field)
231
236
  ])
232
237
  ) : e.kind === "records" ? t.push(
233
- ...P([
234
- ...U(e.fields),
238
+ ..._e([
239
+ ...Fe(e.fields),
235
240
  e.dateField,
236
241
  (a = e.orderBy) == null ? void 0 : a.field,
237
- ...ue(e.filters).map((n) => n.field)
242
+ ...ft(e.filters).map((d) => d.field)
238
243
  ])
239
- ) : e.kind === "inputOptions" ? (((r = e.population) == null ? void 0 : r.kind) === "related_population" && t.push(e.population.baseSource), t.push(
240
- ...P([
244
+ ) : e.kind === "inputOptions" ? (((s = e.population) == null ? void 0 : s.kind) === "related_population" && t.push(e.population.baseSource), t.push(
245
+ ..._e([
241
246
  e.labelField,
242
247
  e.valueField,
243
248
  e.searchField,
244
249
  ...e.disambiguationFields || []
245
250
  ])
246
- )) : e.kind === "sql" && t.push(...P(e.fields || [])), t;
251
+ )) : e.kind === "sql" && t.push(..._e(e.fields || [])), t;
247
252
  }
248
- function ge({
253
+ function Ja({
249
254
  card: e,
250
255
  datasets: t,
251
256
  errors: a
252
257
  }) {
253
258
  if (e.type !== "text") {
254
- for (const r of et(e.analyticsIntent))
255
- if (r && !t.some(
256
- (n) => J(n, r)
259
+ for (const s of Xa(e.analyticsIntent))
260
+ if (s && !t.some(
261
+ (d) => Ve(d, s)
257
262
  )) {
258
263
  a.push(
259
- f(
264
+ P(
260
265
  "invalid_card_query_source",
261
266
  "Dashboard card query field references must use one of the selected datasets.",
262
267
  e.id
@@ -266,36 +271,36 @@ function ge({
266
271
  }
267
272
  }
268
273
  }
269
- function be({
274
+ function Za({
270
275
  card: e,
271
276
  errors: t
272
277
  }) {
273
278
  if (e.type === "text" || !e.analyticsIntent)
274
279
  return;
275
- const a = fe(e.analyticsIntent);
280
+ const a = yt(e.analyticsIntent);
276
281
  if (!a.ok)
277
- for (const r of a.errors)
282
+ for (const s of a.errors)
278
283
  t.push(
279
- f(
280
- r.code,
281
- r.path ? `${r.path}: ${r.message}` : r.message,
284
+ P(
285
+ s.code,
286
+ s.path ? `${s.path}: ${s.message}` : s.message,
282
287
  e.id
283
288
  )
284
289
  );
285
290
  }
286
- function Ie({
291
+ function es({
287
292
  datasets: e,
288
293
  errors: t,
289
294
  requireAtLeastOne: a
290
295
  }) {
291
- const r = Ze({
296
+ const s = Ha({
292
297
  datasets: e,
293
298
  requireAtLeastOne: a
294
299
  });
295
- if (!r.ok) {
296
- if (r.issue === "invalid_dataset_count") {
300
+ if (!s.ok) {
301
+ if (s.issue === "invalid_dataset_count") {
297
302
  t.push(
298
- f(
303
+ P(
299
304
  "invalid_dataset_count",
300
305
  "Dashboard authoring requires at least one selected dataset."
301
306
  )
@@ -303,337 +308,160 @@ function Ie({
303
308
  return;
304
309
  }
305
310
  t.push(
306
- f(
311
+ P(
307
312
  "invalid_multi_dataset_scope",
308
313
  "Multi-dataset dashboard authoring is limited to semantic datasets from one domain."
309
314
  )
310
315
  );
311
316
  }
312
317
  }
313
- function Ce({
318
+ function ts({
314
319
  input: e,
315
320
  errors: t
316
321
  }) {
317
322
  var a;
318
323
  (a = e.filter.sql) != null && a.trim() && t.push(
319
- f(
324
+ P(
320
325
  "generated_filter_sql_out_of_scope",
321
326
  `Generated dashboard filter "${e.label}" must use grounded filter configuration; custom SQL is outside the dashboard-authoring contract.`
322
327
  )
323
328
  );
324
329
  }
325
- function Q({
330
+ function as({
326
331
  card: e,
327
332
  errors: t
328
333
  }) {
329
334
  "interactionConfig" in e && t.push(
330
- f(
335
+ P(
331
336
  "legacy_card_interactions_unsupported",
332
337
  "Dashboard authoring accepts click-to-filter settings only through card.clickToFilter.",
333
338
  e.id
334
339
  )
335
- ), e.clickToFilter !== void 0 && !ke.safeParse(e.clickToFilter).success && t.push(
336
- f(
340
+ ), e.clickToFilter !== void 0 && !Pt.safeParse(e.clickToFilter).success && t.push(
341
+ P(
337
342
  "invalid_click_to_filter",
338
343
  "Dashboard card clickToFilter settings do not match the canonical schema.",
339
344
  e.id
340
345
  )
341
- ), e.respondsToSelections !== void 0 && !Ae.safeParse(e.respondsToSelections).success && t.push(
342
- f(
346
+ ), e.respondsToSelections !== void 0 && !Mt.safeParse(e.respondsToSelections).success && t.push(
347
+ P(
343
348
  "invalid_responds_to_selections",
344
349
  "Dashboard card respondsToSelections must be a boolean.",
345
350
  e.id
346
351
  )
347
352
  );
348
353
  }
349
- function tt(e) {
350
- var m, C;
354
+ function ss(e) {
355
+ var m, f;
351
356
  const t = [];
352
357
  if (!e || typeof e != "object")
353
358
  return {
354
359
  ok: !1,
355
360
  errors: [
356
- f(
361
+ P(
357
362
  "invalid_plan",
358
363
  "Dashboard plan must be a structured object."
359
364
  )
360
365
  ],
361
366
  warnings: []
362
367
  };
363
- const a = e, r = [...a.warnings || []];
364
- a.version !== 1 && t.push(f("invalid_version", "Dashboard plan version must be 1.")), (m = a.title) != null && m.trim() || t.push(f("missing_title", "Dashboard plan needs a title."));
365
- const n = Array.isArray(a.datasets) ? a.datasets : [], i = Array.isArray(a.sheets) ? a.sheets : [];
366
- Ie({ datasets: n, errors: t, requireAtLeastOne: !0 }), i.length !== 1 && t.push(
367
- f(
368
+ const a = e, s = [...a.warnings || []];
369
+ a.version !== 1 && t.push(P("invalid_version", "Dashboard plan version must be 1.")), (m = a.title) != null && m.trim() || t.push(P("missing_title", "Dashboard plan needs a title."));
370
+ const d = Array.isArray(a.datasets) ? a.datasets : [], i = Array.isArray(a.sheets) ? a.sheets : [];
371
+ es({ datasets: d, errors: t, requireAtLeastOne: !0 }), i.length !== 1 && t.push(
372
+ P(
368
373
  "invalid_sheet_count",
369
374
  "MVP dashboard authoring creates exactly one dashboard sheet."
370
375
  )
371
376
  );
372
- const o = i[0];
373
- o && o.kind !== "dashboard" && t.push(
374
- f("invalid_sheet_kind", 'Generated sheet must use kind "dashboard".')
377
+ const n = i[0];
378
+ n && n.kind !== "dashboard" && t.push(
379
+ P("invalid_sheet_kind", 'Generated sheet must use kind "dashboard".')
375
380
  );
376
- const s = (o == null ? void 0 : o.cards) || [];
377
- s.length > L && t.push(
378
- f(
381
+ const o = (n == null ? void 0 : n.cards) || [];
382
+ o.length > at && t.push(
383
+ P(
379
384
  "too_many_cards",
380
- `Generated dashboards can contain at most ${L} cards.`
385
+ `Generated dashboards can contain at most ${at} cards.`
381
386
  )
382
387
  );
383
- const l = M(s.map((u) => u.id));
384
- l && t.push(
385
- f("duplicate_card_id", `Duplicate generated card id: ${l}.`)
388
+ const p = ye(o.map((b) => b.id));
389
+ p && t.push(
390
+ P("duplicate_card_id", `Duplicate generated card id: ${p}.`)
386
391
  );
387
- const d = M(s.map((u) => u.frameId));
388
- d && t.push(
389
- f(
392
+ const y = ye(o.map((b) => b.frameId));
393
+ y && t.push(
394
+ P(
390
395
  "duplicate_frame_id",
391
- `Duplicate generated frame id: ${d}.`
396
+ `Duplicate generated frame id: ${y}.`
392
397
  )
393
398
  );
394
- for (const u of s)
395
- (C = u.title) != null && C.trim() || t.push(f("missing_card_title", "Card title is required.", u.id)), u.type === "custom" && t.push(
396
- f(
399
+ for (const b of o)
400
+ (f = b.title) != null && f.trim() || t.push(P("missing_card_title", "Card title is required.", b.id)), b.type === "custom" && t.push(
401
+ P(
397
402
  "custom_visual_out_of_scope",
398
403
  "Whole-dashboard authoring supports built-in visual types only.",
399
- u.id
404
+ b.id
400
405
  )
401
- ), u.type !== "text" && !u.analyticsIntent && r.push(
402
- f(
406
+ ), b.type !== "text" && !b.analyticsIntent && s.push(
407
+ P(
403
408
  "missing_analytics_intent",
404
409
  "Non-text card has no analytics intent and may be skipped by the app layer.",
405
- u.id
410
+ b.id
406
411
  )
407
- ), he({ card: u, datasets: n, errors: t }), be({ card: u, errors: t }), ge({ card: u, datasets: n, errors: t }), Q({ card: u, errors: t });
408
- const p = Array.isArray(a.filterInputs) ? a.filterInputs : [], h = p.map((u) => u.id), y = M(h);
409
- y && t.push(
410
- f(
412
+ ), Ya({ card: b, datasets: d, errors: t }), Za({ card: b, errors: t }), Ja({ card: b, datasets: d, errors: t }), as({ card: b, errors: t });
413
+ const _ = Array.isArray(a.filterInputs) ? a.filterInputs : [], g = _.map((b) => b.id), C = ye(g);
414
+ C && t.push(
415
+ P(
411
416
  "duplicate_input_id",
412
- `Duplicate dashboard input id: ${y}.`
417
+ `Duplicate dashboard input id: ${C}.`
413
418
  )
414
419
  );
415
- const g = p.map((u) => u.variableName).filter(Boolean) || [], b = M(g);
416
- b && t.push(
417
- f(
420
+ const w = _.map((b) => b.variableName).filter(Boolean) || [], c = ye(w);
421
+ c && t.push(
422
+ P(
418
423
  "duplicate_input_variable",
419
- `Duplicate dashboard input variable name: ${b}.`
424
+ `Duplicate dashboard input variable name: ${c}.`
420
425
  )
421
426
  );
422
- for (const u of p)
423
- Ce({ input: u, errors: t });
424
- const c = Array.isArray(a.calculatedFields) ? a.calculatedFields : [];
425
- for (const u of c)
426
- u.scope === "domain" && u.reuseOnly !== !0 && t.push(
427
- f(
427
+ for (const b of _)
428
+ ts({ input: b, errors: t });
429
+ const R = Array.isArray(a.calculatedFields) ? a.calculatedFields : [];
430
+ for (const b of R)
431
+ b.scope === "domain" && b.reuseOnly !== !0 && t.push(
432
+ P(
428
433
  "domain_calculated_field_create_out_of_scope",
429
- `Creating domain calculated field "${u.name}" is outside MVP.`
434
+ `Creating domain calculated field "${b.name}" is outside MVP.`
430
435
  )
431
436
  );
432
- return { ok: t.length === 0, errors: t, warnings: r };
433
- }
434
- function at(e) {
435
- var o;
436
- const t = [];
437
- if (!e || typeof e != "object")
438
- return {
439
- ok: !1,
440
- errors: [
441
- f(
442
- "invalid_change_plan",
443
- "Dashboard change plan must be a structured object."
444
- )
445
- ],
446
- warnings: []
447
- };
448
- const a = e, r = [...a.warnings || []];
449
- a.version !== 1 && t.push(
450
- f("invalid_version", "Dashboard change plan version must be 1.")
451
- ), (o = a.dashboardId) != null && o.trim() || t.push(
452
- f("missing_dashboard_id", "Dashboard change plan needs a dashboard id.")
453
- );
454
- const n = Array.isArray(a.datasets) ? a.datasets : [], i = Array.isArray(a.operations) ? a.operations : [];
455
- Ie({ datasets: n, errors: t, requireAtLeastOne: !1 });
456
- for (const s of i) {
457
- if (s.kind === "unsupported") {
458
- r.push(
459
- f("unsupported_operation", s.reason || s.requestedAction)
460
- );
461
- continue;
462
- }
463
- if (s.kind === "addCard" && s.card.type === "custom" && t.push(
464
- f(
465
- "custom_visual_out_of_scope",
466
- "Whole-dashboard authoring supports built-in visual types only.",
467
- s.card.id
468
- )
469
- ), s.kind === "addCard" && (he({
470
- card: s.card,
471
- datasets: n,
472
- errors: t
473
- }), be({
474
- card: s.card,
475
- errors: t
476
- }), ge({
477
- card: s.card,
478
- datasets: n,
479
- errors: t
480
- }), Q({ card: s.card, errors: t })), s.kind === "updateCardSelectionSettings") {
481
- const l = s.card;
482
- s.card.clickToFilter === void 0 && s.card.respondsToSelections === void 0 && t.push(
483
- f(
484
- "empty_card_selection_settings_update",
485
- "A card selection-settings update must provide clickToFilter or respondsToSelections.",
486
- s.cardId
487
- )
488
- ), Q({
489
- card: {
490
- id: s.cardId,
491
- frameId: "",
492
- title: "",
493
- type: "table",
494
- role: "table",
495
- priority: 0,
496
- ...l
497
- },
498
- errors: t
499
- });
500
- }
501
- s.kind === "addFilterInput" && Ce({ input: s.input, errors: t }), s.kind === "addCalculatedField" && s.field.scope === "domain" && s.field.reuseOnly !== !0 && t.push(
502
- f(
503
- "domain_calculated_field_create_out_of_scope",
504
- `Creating domain calculated field "${s.field.name}" is outside MVP.`
505
- )
506
- );
507
- }
508
- return { ok: t.length === 0, errors: t, warnings: r };
509
- }
510
- const rt = {
511
- lg: 48,
512
- md: 36,
513
- sm: 24,
514
- xs: 12,
515
- xxs: 6
516
- };
517
- function nt(e, t) {
518
- let a = 0, r = 0, n = 0;
519
- return e.map((i) => {
520
- const o = Math.min(i.w, t);
521
- a > 0 && a + o > t && (a = 0, r += n, n = 0);
522
- const s = {
523
- i: i.frameId,
524
- x: a,
525
- y: r,
526
- w: o,
527
- h: i.h,
528
- minW: Math.min(i.minW, t),
529
- minH: i.minH,
530
- static: !1
531
- };
532
- return a += o, n = Math.max(n, i.h), s;
533
- });
534
- }
535
- function it(e) {
536
- const t = [...e].sort((l, d) => l.priority - d.priority), a = t.filter((l) => l.role === "kpi"), r = t.filter((l) => l.role === "chart"), n = t.filter((l) => l.role === "table"), i = t.filter((l) => l.role === "text"), o = i.slice(0, 1), s = i.slice(o.length);
537
- return { kpis: a, introText: o, charts: r, tables: n, supportingText: s };
538
- }
539
- function ot(e, t, a) {
540
- return t === "xxs" || t === "xs" ? a : t === "sm" ? Math.min(12, a) : t === "md" ? e <= 1 || e === 2 ? 18 : 12 : e <= 1 || e === 2 ? 24 : e === 3 ? 16 : 12;
541
- }
542
- function st(e, t, a, r) {
543
- return a === "xxs" || a === "xs" || a === "sm" || a === "md" || t === 1 || t % 2 === 1 && e === 0 ? r : r / 2;
544
- }
545
- function dt(e) {
546
- const { item: t, band: a, index: r, bandCount: n, breakpoint: i, columns: o } = e;
547
- return a === "kpi" ? {
548
- ...t,
549
- band: a,
550
- w: ot(n, i, o),
551
- h: 15,
552
- minW: Math.min(6, o),
553
- minH: 12
554
- } : a === "table" ? {
555
- ...t,
556
- band: a,
557
- w: o,
558
- h: i === "xxs" || i === "xs" ? 34 : 38,
559
- minW: Math.min(12, o),
560
- minH: 18
561
- } : a === "introText" ? {
562
- ...t,
563
- band: a,
564
- w: o,
565
- h: i === "xxs" || i === "xs" ? 12 : 10,
566
- minW: Math.min(12, o),
567
- minH: 8
568
- } : a === "supportingText" ? {
569
- ...t,
570
- band: a,
571
- w: i === "lg" ? o / 2 : o,
572
- h: i === "xxs" || i === "xs" ? 12 : 10,
573
- minW: Math.min(12, o),
574
- minH: 8
575
- } : {
576
- ...t,
577
- band: a,
578
- w: st(r, n, i, o),
579
- h: i === "xxs" || i === "xs" ? 28 : 30,
580
- minW: Math.min(12, o),
581
- minH: 16
582
- };
583
- }
584
- function A(e, t, a, r) {
585
- return e.map(
586
- (n, i) => dt({
587
- item: n,
588
- band: t,
589
- index: i,
590
- bandCount: e.length,
591
- breakpoint: a,
592
- columns: r
593
- })
594
- );
595
- }
596
- function Z(e) {
597
- const t = it(e);
598
- return Object.fromEntries(
599
- xe.map((a) => {
600
- const r = rt[a], n = [
601
- ...A(t.introText, "introText", a, r),
602
- ...A(t.kpis, "kpi", a, r),
603
- ...A(t.charts, "chart", a, r),
604
- ...A(t.tables, "table", a, r),
605
- ...A(t.supportingText, "supportingText", a, r)
606
- ];
607
- return [a, nt(n, r)];
608
- })
609
- );
437
+ return { ok: t.length === 0, errors: t, warnings: s };
610
438
  }
611
- function ct(e) {
612
- const t = $e(e);
439
+ function is(e) {
440
+ const t = Da(e);
613
441
  return t === "datetime" ? "date" : t === "unknown" ? "string" : t;
614
442
  }
615
- function lt(e) {
443
+ function ns(e) {
616
444
  return !!(e && typeof e == "object" && !Array.isArray(e));
617
445
  }
618
- function ut(e) {
619
- return lt(e) && typeof e.filterId == "string" && typeof e.operation == "string" && Array.isArray(e.values);
446
+ function os(e) {
447
+ return ns(e) && typeof e.filterId == "string" && typeof e.operation == "string" && Array.isArray(e.values);
620
448
  }
621
- function ft(e) {
449
+ function rs(e) {
622
450
  return e.filter(
623
451
  (t) => typeof t == "string" || typeof t == "number"
624
452
  );
625
453
  }
626
- function pt(e) {
454
+ function ds(e) {
627
455
  return e.filter(
628
456
  (t) => t instanceof Date || typeof t == "string"
629
457
  );
630
458
  }
631
- function ee(e, t) {
459
+ function xt(e, t) {
632
460
  if (t === void 0)
633
461
  return;
634
- const a = ct(e.dataType), r = e.operation || "in";
635
- if (ut(t))
636
- return j({
462
+ const a = is(e.dataType), s = e.operation || "in";
463
+ if (os(t))
464
+ return ke({
637
465
  definition: e,
638
466
  sourceValue: t,
639
467
  value: {
@@ -646,13 +474,13 @@ function ee(e, t) {
646
474
  semanticContext: e.semanticContext
647
475
  }
648
476
  });
649
- if (r === "is null" || r === "is not null")
650
- return j({
477
+ if (s === "is null" || s === "is not null")
478
+ return ke({
651
479
  definition: e,
652
480
  value: {
653
481
  filterId: e.id,
654
482
  name: e.column,
655
- operation: r,
483
+ operation: s,
656
484
  valueType: a,
657
485
  values: [],
658
486
  dataType: e.dataType,
@@ -660,14 +488,14 @@ function ee(e, t) {
660
488
  semanticContext: e.semanticContext
661
489
  }
662
490
  });
663
- const n = Array.isArray(t) ? t : [t], i = a === "date" ? pt(n) : ft(n);
664
- if (i.length !== 0 && !((r === "between" || r === "not between") && i.length < 2))
665
- return j({
491
+ const d = Array.isArray(t) ? t : [t], i = a === "date" ? ds(d) : rs(d);
492
+ if (i.length !== 0 && !((s === "between" || s === "not between") && i.length < 2))
493
+ return ke({
666
494
  definition: e,
667
495
  value: {
668
496
  filterId: e.id,
669
497
  name: e.column,
670
- operation: r,
498
+ operation: s,
671
499
  valueType: a,
672
500
  values: i,
673
501
  dataType: e.dataType,
@@ -676,26 +504,26 @@ function ee(e, t) {
676
504
  }
677
505
  });
678
506
  }
679
- function ye(e, t, a) {
507
+ function wt(e, t, a) {
680
508
  return a ? { code: e, message: t, cardId: a } : { code: e, message: t };
681
509
  }
682
- function mt(e, t, a) {
683
- const r = (t || []).filter(
684
- (n) => n.scope === "card" && n.targetCardId === a
685
- ).map((n) => n.field).filter(Boolean);
686
- return r.length === 0 ? e : {
510
+ function ls(e, t, a) {
511
+ const s = (t || []).filter(
512
+ (d) => d.scope === "card" && d.targetCardId === a
513
+ ).map((d) => d.field).filter(Boolean);
514
+ return s.length === 0 ? e : {
687
515
  ...e,
688
516
  calculatedFields: [
689
517
  ...e.calculatedFields || [],
690
- ...r
518
+ ...s
691
519
  ]
692
520
  };
693
521
  }
694
- function ht(e, t, a) {
522
+ function cs(e, t, a) {
695
523
  return t.clickToFilter === void 0 && t.respondsToSelections === void 0 ? e : {
696
524
  ...e,
697
525
  ...t.clickToFilter ? {
698
- clickToFilter: H(
526
+ clickToFilter: Lt(
699
527
  t.clickToFilter,
700
528
  { cardIds: Object.fromEntries(a) }
701
529
  )
@@ -703,58 +531,36 @@ function ht(e, t, a) {
703
531
  ...t.respondsToSelections !== void 0 ? { respondsToSelections: t.respondsToSelections } : {}
704
532
  };
705
533
  }
706
- function X(e, t) {
707
- return Array.from(
708
- new Set(
709
- (e || []).map((a) => t.get(a)).filter((a) => !!a)
710
- )
711
- );
712
- }
713
- function gt(e, t) {
714
- if ((e == null ? void 0 : e.kind) !== "cards")
715
- return e;
716
- const a = X(e.cardIds, t);
717
- return a.length > 0 ? { ...e, cardIds: a } : null;
718
- }
719
- function bt(e, t) {
720
- return !e.applyToCardIds && !e.excludeCardIds ? e : {
721
- ...e,
722
- ...e.applyToCardIds ? {
723
- applyToCardIds: X(
724
- e.applyToCardIds,
725
- t
726
- )
727
- } : {},
728
- ...e.excludeCardIds ? {
729
- excludeCardIds: X(
730
- e.excludeCardIds,
731
- t
732
- )
733
- } : {}
734
- };
534
+ function us(e, t) {
535
+ if (!e) return e;
536
+ const a = Vt(e, {
537
+ renamedCardIds: t,
538
+ keepOnlyRenamedCardIds: !0
539
+ });
540
+ return Gt(a) ? null : a;
735
541
  }
736
- function It(e, t) {
737
- const a = {}, r = [];
542
+ function fs(e, t) {
543
+ const a = {}, s = [];
738
544
  return {
739
545
  inputs: (e.filterInputs || []).flatMap(
740
- (i, o) => {
741
- const s = gt(i.scope, t);
742
- if (s === null)
743
- return r.push(
744
- ye(
546
+ (i, n) => {
547
+ const o = us(i.scope, t);
548
+ if (o === null)
549
+ return s.push(
550
+ wt(
745
551
  "filter_input_scope_empty",
746
- `Filter input "${i.label}" was skipped because all scoped cards were skipped during query validation.`
552
+ `Filter input "${i.label}" was skipped because all scoped cards or tabs were skipped during query validation.`
747
553
  )
748
554
  ), [];
749
- const l = ee(
555
+ const p = xt(
750
556
  i.filter,
751
557
  i.defaultValue
752
558
  );
753
- return l && (a.shared ?? (a.shared = {}), a.shared[i.id] = {
559
+ return p && (a.shared ?? (a.shared = {}), a.shared[i.id] = {
754
560
  status: "set",
755
561
  value: {
756
562
  kind: "filter",
757
- filterValue: l
563
+ filterValue: p
758
564
  }
759
565
  }), [
760
566
  {
@@ -762,76 +568,74 @@ function It(e, t) {
762
568
  kind: "filter",
763
569
  label: i.label,
764
570
  variableName: i.variableName,
765
- scope: s || { kind: "allSheets", sheetKinds: ["dashboard"] },
571
+ scope: o || { kind: "allSheets", sheetKinds: ["dashboard"] },
766
572
  runtimeScope: "shared",
767
573
  presentation: {
768
574
  placement: "toolbar",
769
- order: o
575
+ order: n
770
576
  },
771
577
  exports: ["label", "value", "start", "end", "range"],
772
- filter: bt(i.filter, t)
578
+ // Reach is the scope (S-1): a filter definition stores none.
579
+ filter: Bt(i.filter)
773
580
  }
774
581
  ];
775
582
  }
776
583
  ),
777
- warnings: r,
584
+ warnings: s,
778
585
  defaultInputValues: a.shared && Object.keys(a.shared).length > 0 ? a : void 0
779
586
  };
780
587
  }
781
- function ea(e) {
782
- var g, b;
783
- const t = tt(e.plan);
588
+ function ri(e) {
589
+ var R, m;
590
+ const t = ss(e.plan);
784
591
  if (!t.ok)
785
592
  throw new Error(
786
- t.errors.map((c) => c.message).join(`
593
+ t.errors.map((f) => f.message).join(`
787
594
  `) || "Dashboard plan is invalid."
788
595
  );
789
- const a = e.plan.sheets[0], r = [...t.warnings], n = [], i = new Map(
790
- e.cardArtifacts.map((c) => [c.planCardId, c])
791
- ), o = new Map(
792
- e.cardArtifacts.map((c) => [
793
- c.planCardId,
794
- c.card.id
596
+ const a = e.plan.sheets[0], s = [...t.warnings], d = [], i = new Map(
597
+ e.cardArtifacts.map((f) => [f.planCardId, f])
598
+ ), n = new Map(
599
+ e.cardArtifacts.map((f) => [
600
+ f.planCardId,
601
+ f.card.id
795
602
  ])
796
- ), s = [];
797
- for (const c of a.cards) {
798
- const m = i.get(c.id);
799
- if (!m) {
800
- const u = ye(
603
+ ), o = [];
604
+ for (const f of a.cards) {
605
+ const b = i.get(f.id);
606
+ if (!b) {
607
+ const D = wt(
801
608
  "missing_card_artifact",
802
- `Card "${c.title}" was skipped because no generated artifact was supplied.`,
803
- c.id
609
+ `Card "${f.title}" was skipped because no generated artifact was supplied.`,
610
+ f.id
804
611
  );
805
- n.push(u);
612
+ d.push(D);
806
613
  continue;
807
614
  }
808
- r.push(...m.warnings || []);
809
- const C = ht(
810
- mt(
811
- m.card,
615
+ s.push(...b.warnings || []);
616
+ const A = cs(
617
+ ls(
618
+ b.card,
812
619
  e.plan.calculatedFields,
813
- c.id
620
+ f.id
814
621
  ),
815
- c,
816
- o
622
+ f,
623
+ n
817
624
  );
818
- s.push({
819
- id: c.frameId,
820
- cards: [C],
821
- activeCardId: C.id
625
+ o.push({
626
+ id: f.frameId,
627
+ cards: [A],
628
+ activeCardId: A.id
822
629
  });
823
630
  }
824
- if (s.length === 0)
631
+ if (o.length === 0)
825
632
  throw new Error("Dashboard plan did not produce any persistable cards.");
826
- const { inputs: l, defaultInputValues: d, warnings: p } = It(e.plan, o);
827
- r.push(...p);
828
- const h = Z(
829
- a.cards.filter((c) => s.some((m) => m.id === c.frameId)).map((c) => ({
830
- frameId: c.frameId,
831
- priority: c.priority,
832
- role: c.role
833
- }))
834
- );
633
+ const { inputs: p, defaultInputValues: y, warnings: _ } = fs(e.plan, n);
634
+ s.push(..._);
635
+ const g = new Map(a.cards.map((f) => [f.frameId, f.priority])), C = o.map((f, b) => ({ frame: f, index: b })).sort(
636
+ (f, b) => (g.get(f.frame.id) ?? 0) - (g.get(b.frame.id) ?? 0) || f.index - b.index
637
+ ).map(({ frame: f }) => f), w = Fa({ id: a.id, frames: C, layouts: void 0 }, { kind: "arrange" });
638
+ if (!w.ok) throw new Error(w.failure.message);
835
639
  return { dashboard: {
836
640
  id: e.dashboardId,
837
641
  title: e.plan.title,
@@ -845,403 +649,151 @@ function ea(e) {
845
649
  kind: "dashboard",
846
650
  title: a.title,
847
651
  description: a.description,
848
- frames: s,
849
- layouts: h,
850
- calculatedFields: (g = e.plan.calculatedFields) == null ? void 0 : g.filter((c) => c.scope === "sheet" && c.field).map((c) => c.field)
652
+ frames: w.frames,
653
+ layouts: w.layouts,
654
+ customizedBreakpoints: w.customizedBreakpoints,
655
+ calculatedFields: (R = e.plan.calculatedFields) == null ? void 0 : R.filter((f) => f.scope === "sheet" && f.field).map((f) => f.field)
851
656
  }
852
657
  ],
853
- calculatedFields: (b = e.plan.calculatedFields) == null ? void 0 : b.filter((c) => c.scope === "dashboard" && c.field).map((c) => c.field),
854
- inputs: l,
855
- ...d ? { defaultInputValues: d } : {}
856
- }, warnings: r, skippedOperations: n };
857
- }
858
- function w(e, t, a) {
859
- return a ? { code: e, message: t, cardId: a } : { code: e, message: t };
860
- }
861
- function Ct(e) {
862
- return JSON.parse(JSON.stringify(e));
863
- }
864
- function yt(e) {
865
- var t;
866
- return (t = e.sheets) == null ? void 0 : t.find(
867
- (a) => (a.kind || "dashboard") === "dashboard"
868
- );
869
- }
870
- function $(e, t) {
871
- var a;
872
- for (const r of e.sheets || [])
873
- for (const n of r.frames || []) {
874
- const i = (a = n.cards) == null ? void 0 : a.find((o) => o.id === t);
875
- if (i)
876
- return { sheet: r, frame: n, card: i };
877
- }
878
- return null;
879
- }
880
- function _e(e) {
881
- var a, r;
882
- const t = (r = (a = e.cards) == null ? void 0 : a[0]) == null ? void 0 : r.type;
883
- return t === "kpi" ? "kpi" : t === "table" || t === "detailTable" || t === "pivotTable" ? "table" : t === "text" ? "text" : "chart";
884
- }
885
- function _t(e) {
886
- var t;
887
- return new Map(
888
- (((t = e.layouts) == null ? void 0 : t.lg) || []).map((a, r) => [a.i, r])
889
- );
890
- }
891
- function De(e, t = /* @__PURE__ */ new Map()) {
892
- const a = _t(e), r = Math.max(
893
- a.size,
894
- t.size
895
- ), n = (e.frames || []).map(
896
- (i, o) => ({
897
- frameId: i.id,
898
- role: _e(i),
899
- priority: t.get(i.id) ?? a.get(i.id) ?? r + o
900
- })
901
- );
902
- e.layouts = Z(n);
903
- }
904
- function Dt(e) {
905
- return Object.values(e.layouts || {}).some((t) => t.length > 0);
906
- }
907
- function St(e, t) {
908
- if (!Dt(e)) {
909
- De(e);
910
- return;
911
- }
912
- const a = Z([
913
- { frameId: t.id, role: _e(t), priority: 0 }
914
- ]);
915
- e.layouts ?? (e.layouts = {});
916
- for (const [r, n] of Object.entries(a)) {
917
- const i = e.layouts[r] || [];
918
- if (i.some((l) => l.i === t.id))
919
- continue;
920
- const o = n[0];
921
- if (!o)
922
- continue;
923
- const s = i.reduce(
924
- (l, d) => Math.max(l, d.y + d.h),
925
- 0
926
- );
927
- e.layouts[r] = [
928
- ...i,
929
- { ...o, y: s }
930
- ];
931
- }
932
- }
933
- function vt(e, t) {
934
- var r;
935
- const a = ee(
936
- t.filter,
937
- t.defaultValue
938
- );
939
- a && (e.defaultInputValues ?? (e.defaultInputValues = {}), (r = e.defaultInputValues).shared ?? (r.shared = {}), e.defaultInputValues.shared[t.id] = {
940
- status: "set",
941
- value: {
942
- kind: "filter",
943
- filterValue: a
944
- }
945
- });
946
- }
947
- function ta(e) {
948
- var l;
949
- const t = at(e.changePlan);
950
- if (!t.ok)
951
- throw new Error(
952
- t.errors.map((d) => d.message).join(`
953
- `) || "Dashboard change plan is invalid."
954
- );
955
- const a = Ct(e.dashboard), r = [...t.warnings], n = [], i = new Map(
956
- e.cardArtifacts.map((d) => [d.planCardId, d])
957
- ), o = new Map(
958
- e.cardArtifacts.map((d) => [
959
- d.planCardId,
960
- d.card.id
961
- ])
962
- ), s = yt(a);
963
- if (!s)
964
- throw new Error("Dashboard has no editable dashboard sheet.");
965
- s.frames ?? (s.frames = []);
966
- for (const d of e.changePlan.operations)
967
- switch (d.kind) {
968
- case "addCard": {
969
- if ((s.frames || []).reduce(
970
- (b, c) => {
971
- var m;
972
- return b + (((m = c.cards) == null ? void 0 : m.length) || 0);
973
- },
974
- 0
975
- ) >= L) {
976
- n.push(
977
- w(
978
- "generated_card_limit_reached",
979
- `AI refinement is capped at ${L} cards.`,
980
- d.card.id
981
- )
982
- );
983
- break;
984
- }
985
- const h = i.get(d.card.id);
986
- if (!h) {
987
- n.push(
988
- w(
989
- "missing_card_artifact",
990
- `Card "${d.card.title}" was skipped because no generated artifact was supplied.`,
991
- d.card.id
992
- )
993
- );
994
- break;
995
- }
996
- const y = {
997
- ...h.card,
998
- ...d.card.clickToFilter ? {
999
- clickToFilter: H(
1000
- d.card.clickToFilter,
1001
- { cardIds: Object.fromEntries(o) }
1002
- )
1003
- } : {},
1004
- ...d.card.respondsToSelections !== void 0 ? {
1005
- respondsToSelections: d.card.respondsToSelections
1006
- } : {}
1007
- }, g = {
1008
- id: d.card.frameId,
1009
- cards: [y],
1010
- activeCardId: y.id
1011
- };
1012
- s.frames.push(g), St(s, g);
1013
- break;
1014
- }
1015
- case "addFilterInput": {
1016
- a.inputs ?? (a.inputs = []);
1017
- const p = {
1018
- id: d.input.id,
1019
- kind: "filter",
1020
- label: d.input.label,
1021
- variableName: d.input.variableName,
1022
- scope: d.input.scope || {
1023
- kind: "allSheets",
1024
- sheetKinds: ["dashboard"]
1025
- },
1026
- runtimeScope: "shared",
1027
- presentation: {
1028
- placement: "toolbar",
1029
- order: a.inputs.length
1030
- },
1031
- exports: ["label", "value", "start", "end", "range"],
1032
- filter: d.input.filter
1033
- };
1034
- a.inputs.push(p), vt(a, d.input);
1035
- break;
1036
- }
1037
- case "addCalculatedField": {
1038
- if (d.field.scope === "dashboard" && d.field.field)
1039
- a.calculatedFields ?? (a.calculatedFields = []), a.calculatedFields.push(d.field.field);
1040
- else if (d.field.scope === "sheet" && d.field.field)
1041
- s.calculatedFields ?? (s.calculatedFields = []), s.calculatedFields.push(d.field.field);
1042
- else if (d.field.scope === "card" && d.field.field) {
1043
- const p = d.field.targetCardId ? $(a, d.field.targetCardId) : null;
1044
- p ? ((l = p.card).calculatedFields ?? (l.calculatedFields = []), p.card.calculatedFields.push(d.field.field)) : n.push(
1045
- w(
1046
- "missing_calculated_field_target",
1047
- `Calculated field "${d.field.name}" needs a valid target card.`
1048
- )
1049
- );
1050
- }
1051
- break;
1052
- }
1053
- case "renameCard": {
1054
- const p = $(a, d.cardId);
1055
- if (!p) {
1056
- n.push(
1057
- w(
1058
- "card_not_found",
1059
- `Card "${d.cardId}" could not be renamed because it was not found.`,
1060
- d.cardId
1061
- )
1062
- );
1063
- break;
1064
- }
1065
- p.card.title = d.title, d.description !== void 0 && (p.card.description = d.description);
1066
- break;
1067
- }
1068
- case "updateCardSelectionSettings": {
1069
- const p = o.get(d.cardId) ?? d.cardId, h = $(a, p);
1070
- if (!h) {
1071
- n.push(
1072
- w(
1073
- "card_not_found",
1074
- `Card "${d.cardId}" could not be updated because it was not found.`,
1075
- d.cardId
1076
- )
1077
- );
1078
- break;
1079
- }
1080
- d.card.clickToFilter !== void 0 && (h.card.clickToFilter = H(
1081
- d.card.clickToFilter,
1082
- { cardIds: Object.fromEntries(o) }
1083
- )), d.card.respondsToSelections !== void 0 && (h.card.respondsToSelections = d.card.respondsToSelections);
1084
- break;
1085
- }
1086
- case "reorderCards": {
1087
- const p = /* @__PURE__ */ new Map();
1088
- for (let h = 0; h < d.cardIds.length; h += 1) {
1089
- const y = d.cardIds[h], g = $(a, y);
1090
- g && p.set(g.frame.id, h);
1091
- }
1092
- De(s, p);
1093
- break;
1094
- }
1095
- case "reuseCalculatedField":
1096
- r.push(
1097
- w(
1098
- "reused_calculated_field",
1099
- `Calculated field "${d.fieldId}" is reused by reference.`
1100
- )
1101
- );
1102
- break;
1103
- case "unsupported":
1104
- n.push(
1105
- w("unsupported_operation", d.reason || d.requestedAction)
1106
- );
1107
- break;
1108
- }
1109
- return { dashboard: a, warnings: r, skippedOperations: n };
658
+ calculatedFields: (m = e.plan.calculatedFields) == null ? void 0 : m.filter((f) => f.scope === "dashboard" && f.field).map((f) => f.field),
659
+ inputs: p,
660
+ ...y ? { defaultInputValues: y } : {}
661
+ }, warnings: s, skippedOperations: d };
1110
662
  }
1111
- function _(e, t, a) {
663
+ function K(e, t, a) {
1112
664
  return a ? { code: e, message: t, cardId: a } : { code: e, message: t };
1113
665
  }
1114
- function O(e, t) {
666
+ function fe(e, t) {
1115
667
  return e.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || t;
1116
668
  }
1117
- function Se(e, t) {
669
+ function Dt(e, t) {
1118
670
  if (!t.has(e))
1119
671
  return t.add(e), e;
1120
- let a = 2, r = `${e}-${a}`;
1121
- for (; t.has(r); )
1122
- a += 1, r = `${e}-${a}`;
1123
- return t.add(r), r;
672
+ let a = 2, s = `${e}-${a}`;
673
+ for (; t.has(s); )
674
+ a += 1, s = `${e}-${a}`;
675
+ return t.add(s), s;
1124
676
  }
1125
- function E(e) {
677
+ function me(e) {
1126
678
  return !!(e && typeof e == "object");
1127
679
  }
1128
- function ve(e) {
680
+ function Tt(e) {
1129
681
  return Array.isArray(e.inputs) ? e.inputs.filter(
1130
- (t) => E(t) && typeof t.id == "string"
682
+ (t) => me(t) && typeof t.id == "string"
1131
683
  ) : [];
1132
684
  }
1133
- function te(e) {
685
+ function Ge(e) {
1134
686
  return Array.isArray(e.sections) ? e.sections.filter(
1135
- (t) => E(t)
687
+ (t) => me(t)
1136
688
  ) : [];
1137
689
  }
1138
- function ae(e) {
690
+ function Ue(e) {
1139
691
  return Array.isArray(e.views) ? e.views.filter(
1140
- (t) => E(t)
692
+ (t) => me(t)
1141
693
  ) : [];
1142
694
  }
1143
- function F(e) {
695
+ function te(e) {
1144
696
  if (!Array.isArray(e))
1145
697
  return [];
1146
698
  const t = [];
1147
699
  for (const a of e) {
1148
- const r = v(a);
1149
- r && t.push(r);
700
+ const s = J(a);
701
+ s && t.push(s);
1150
702
  }
1151
703
  return t;
1152
704
  }
1153
- function Tt(e) {
1154
- var r, n, i;
705
+ function hs(e) {
706
+ var s, d, i;
1155
707
  if (!e)
1156
708
  return [];
1157
709
  const t = [];
1158
- if (R(e.source) && t.push(e.source), e.kind === "metric") {
1159
- t.push(...F(e.measures));
1160
- const o = v(e.dateField);
1161
- o && t.push(o), t.push(...F(e.dimensions)), t.push(
1162
- ...F(
1163
- (r = e.filters) == null ? void 0 : r.map((s) => s.field)
710
+ if (pe(e.source) && t.push(e.source), e.kind === "metric") {
711
+ t.push(...te(e.measures));
712
+ const n = J(e.dateField);
713
+ n && t.push(n), t.push(...te(e.dimensions)), t.push(
714
+ ...te(
715
+ (s = e.filters) == null ? void 0 : s.map((o) => o.field)
1164
716
  )
1165
717
  );
1166
718
  } else if (e.kind === "records") {
1167
- const o = v(e.dateField);
1168
- o && t.push(o), t.push(...F(e.fields)), t.push(
1169
- ...F(
1170
- (n = e.filters) == null ? void 0 : n.map((s) => s.field)
719
+ const n = J(e.dateField);
720
+ n && t.push(n), t.push(...te(e.fields)), t.push(
721
+ ...te(
722
+ (d = e.filters) == null ? void 0 : d.map((o) => o.field)
1171
723
  )
1172
724
  );
1173
- } else e.kind === "inputOptions" ? (((i = e.population) == null ? void 0 : i.kind) === "related_population" && R(e.population.baseSource) && t.push(e.population.baseSource), t.push(
1174
- ...F([
725
+ } else e.kind === "inputOptions" ? (((i = e.population) == null ? void 0 : i.kind) === "related_population" && pe(e.population.baseSource) && t.push(e.population.baseSource), t.push(
726
+ ...te([
1175
727
  e.labelField,
1176
728
  e.valueField,
1177
729
  e.searchField,
1178
730
  ...e.disambiguationFields || []
1179
- ].filter((o) => !!o))
1180
- )) : e.kind === "sql" && t.push(...F(e.fields));
731
+ ].filter((n) => !!n))
732
+ )) : e.kind === "sql" && t.push(...te(e.fields));
1181
733
  const a = "inputs" in e && Array.isArray(e.inputs) ? e.inputs : [];
1182
- for (const o of a) {
1183
- const s = v(o.field);
1184
- s && t.push(s);
734
+ for (const n of a) {
735
+ const o = J(n.field);
736
+ o && t.push(o);
1185
737
  }
1186
738
  return t;
1187
739
  }
1188
- function wt(e) {
740
+ function ps(e) {
1189
741
  const t = [];
1190
- for (const a of ve(e)) {
1191
- const r = v(a.field);
1192
- r && t.push(r);
742
+ for (const a of Tt(e)) {
743
+ const s = J(a.field);
744
+ s && t.push(s);
1193
745
  }
1194
- for (const a of te(e))
1195
- for (const r of ae(a))
1196
- t.push(...Tt(r.analytics));
746
+ for (const a of Ge(e))
747
+ for (const s of Ue(a))
748
+ t.push(...hs(s.analytics));
1197
749
  return t;
1198
750
  }
1199
- function Ft(e) {
751
+ function ms(e) {
1200
752
  var a;
1201
753
  const t = [];
1202
- for (const r of te(e))
1203
- for (const n of ae(r))
1204
- R((a = n.analytics) == null ? void 0 : a.source) && t.push(n.analytics.source);
754
+ for (const s of Ge(e))
755
+ for (const d of Ue(s))
756
+ pe((a = d.analytics) == null ? void 0 : a.source) && t.push(d.analytics.source);
1205
757
  return t;
1206
758
  }
1207
- function xt(e, t) {
1208
- const a = q(e).filter(R);
759
+ function gs(e, t) {
760
+ const a = xe(e).filter(pe);
1209
761
  if (a.length === 0)
1210
762
  return t.push(
1211
- _(
763
+ K(
1212
764
  "missing_materializable_dataset",
1213
765
  "No semantic or physical source could be converted into the current dashboard authoring dataset reference."
1214
766
  )
1215
767
  ), [];
1216
- const r = a.every((i) => i.kind === "semantic"), n = Array.from(
768
+ const s = a.every((i) => i.kind === "semantic"), d = Array.from(
1217
769
  new Set(
1218
770
  a.filter((i) => i.kind === "semantic").map((i) => i.domainId)
1219
771
  )
1220
772
  );
1221
- return a.length > 1 && (!r || n.length !== 1) ? (t.push(
1222
- _(
773
+ return a.length > 1 && (!s || d.length !== 1) ? (t.push(
774
+ K(
1223
775
  "multiple_datasets_out_of_scope",
1224
776
  "The dashboard authoring compiler supports multiple datasets only within one semantic domain; using the first source and deferring the rest."
1225
777
  )
1226
778
  ), [a[0]]) : a;
1227
779
  }
1228
- function kt(e, t) {
1229
- const a = te(e), r = ve(e), n = q(wt(e)), i = q(
1230
- Ft(e)
780
+ function bs(e, t) {
781
+ const a = Ge(e), s = Tt(e), d = xe(ps(e)), i = xe(
782
+ ms(e)
1231
783
  );
1232
784
  return {
1233
785
  sections: a,
1234
- inputs: r,
1235
- sources: n,
786
+ inputs: s,
787
+ sources: d,
1236
788
  primarySources: i,
1237
789
  defaultSource: i.length === 1 ? i[0] : void 0,
1238
- datasets: xt(n, t)
790
+ datasets: gs(d, t)
1239
791
  };
1240
792
  }
1241
- function At(e) {
1242
- return e && fe(e).ok ? e : void 0;
793
+ function Is(e) {
794
+ return e && yt(e).ok ? e : void 0;
1243
795
  }
1244
- function Ot(e) {
796
+ function ys(e) {
1245
797
  var t;
1246
798
  switch ((t = e.presentation) == null ? void 0 : t.kind) {
1247
799
  case "kpi":
@@ -1260,12 +812,12 @@ function Ot(e) {
1260
812
  return null;
1261
813
  }
1262
814
  }
1263
- function Rt(e) {
1264
- var t, a, r;
1265
- return ((t = e.presentation) == null ? void 0 : t.kind) === "kpi" ? "kpi" : ((a = e.presentation) == null ? void 0 : a.kind) === "table" ? "table" : ((r = e.presentation) == null ? void 0 : r.kind) === "text" ? "text" : "chart";
815
+ function _s(e) {
816
+ var t, a, s;
817
+ return ((t = e.presentation) == null ? void 0 : t.kind) === "kpi" ? "kpi" : ((a = e.presentation) == null ? void 0 : a.kind) === "table" ? "table" : ((s = e.presentation) == null ? void 0 : s.kind) === "text" ? "text" : "chart";
1266
818
  }
1267
- function Et(e) {
1268
- const t = Le(e);
819
+ function Cs(e) {
820
+ const t = Ra(e);
1269
821
  switch (t) {
1270
822
  case "not_in":
1271
823
  return "not in";
@@ -1279,78 +831,77 @@ function Et(e) {
1279
831
  return t || "in";
1280
832
  }
1281
833
  }
1282
- function Nt(e) {
1283
- return E(e.field) ? e.field.dataType === "datetime" ? "date" : e.field.dataType || "string" : "string";
834
+ function Ss(e) {
835
+ return me(e.field) ? e.field.dataType === "datetime" ? "date" : e.field.dataType || "string" : "string";
1284
836
  }
1285
- function Mt(e) {
837
+ function vs(e) {
1286
838
  if (!(!e || e.kind !== "physical"))
1287
839
  return [e.databaseName, e.schemaName, e.tableName].filter(Boolean).join(".");
1288
840
  }
1289
- function Pt(e, t, a, r, n, i) {
841
+ function xs(e, t, a, s, d, i) {
1290
842
  if (e.kind !== "filter")
1291
843
  return i.push(
1292
- _(
844
+ K(
1293
845
  "control_inputs_deferred",
1294
846
  `Control input "${e.label}" is represented in the protocol but not yet materialized by the dashboard authoring adapter.`
1295
847
  )
1296
848
  ), null;
1297
- if (!E(e.field) || typeof e.field.name != "string")
849
+ if (!me(e.field) || typeof e.field.name != "string")
1298
850
  return i.push(
1299
- _(
851
+ K(
1300
852
  "filter_requires_field",
1301
853
  `Filter "${e.label || e.id}" needs a field before the dashboard compiler can materialize it.`
1302
854
  )
1303
855
  ), null;
1304
- const o = Ge({
856
+ const n = Va({
1305
857
  explicitSource: void 0,
1306
858
  field: e.field,
1307
859
  defaultSource: t,
1308
860
  fallbackSources: a
1309
- }), s = (o == null ? void 0 : o.kind) === "semantic" || (o == null ? void 0 : o.kind) === "physical" ? o.connectionId : void 0;
1310
- if (!s)
861
+ }), o = (n == null ? void 0 : n.kind) === "semantic" || (n == null ? void 0 : n.kind) === "physical" ? n.connectionId : void 0;
862
+ if (!o)
1311
863
  return i.push(
1312
- _(
864
+ K(
1313
865
  "filter_requires_connection_id",
1314
866
  `Filter "${e.label}" needs a source connectionId before the dashboard compiler can materialize it.`
1315
867
  )
1316
868
  ), null;
1317
- const p = {
1318
- id: `filter-${Se(
1319
- O(e.id, e.field.name),
1320
- n
869
+ const _ = {
870
+ id: `filter-${Dt(
871
+ fe(e.id, e.field.name),
872
+ d
1321
873
  )}`,
1322
874
  variableName: e.id,
1323
- connectionId: s,
875
+ connectionId: o,
1324
876
  title: e.label,
1325
877
  column: e.field.name,
1326
- dataType: Nt(e),
1327
- qualifiedTableName: Mt(o),
878
+ dataType: Ss(e),
879
+ qualifiedTableName: vs(n),
1328
880
  sql: "",
1329
- operation: Et(e.operator),
881
+ operation: Cs(e.operator),
1330
882
  type: e.multi === !1 ? "single" : "multiple",
1331
883
  location: "dashboard",
1332
- displayMode: "toolbar",
1333
- fieldMeta: (o == null ? void 0 : o.kind) === "semantic" ? {
884
+ fieldMeta: (n == null ? void 0 : n.kind) === "semantic" ? {
1334
885
  name: e.field.name,
1335
886
  qualifiedFieldName: e.field.name,
1336
887
  dataType: e.field.dataType,
1337
888
  role: e.field.role === "measure" ? "metric" : "groupby"
1338
889
  } : void 0,
1339
- semanticContext: (o == null ? void 0 : o.kind) === "semantic" ? {
1340
- semanticDomainId: o.domainId,
1341
- connectionId: o.connectionId
1342
- } : (o == null ? void 0 : o.kind) === "physical" ? {
1343
- connectionId: o.connectionId,
1344
- connectionType: o.connectionType,
890
+ semanticContext: (n == null ? void 0 : n.kind) === "semantic" ? {
891
+ semanticDomainId: n.domainId,
892
+ connectionId: n.connectionId
893
+ } : (n == null ? void 0 : n.kind) === "physical" ? {
894
+ connectionId: n.connectionId,
895
+ connectionType: n.connectionType,
1345
896
  selectedEntities: [
1346
897
  {
1347
898
  type: "table",
1348
- connectionId: o.connectionId,
1349
- connectionType: o.connectionType,
1350
- dialect: o.dialect,
1351
- database: o.databaseName,
1352
- schema: o.schemaName,
1353
- name: o.tableName
899
+ connectionId: n.connectionId,
900
+ connectionType: n.connectionType,
901
+ dialect: n.dialect,
902
+ database: n.databaseName,
903
+ schema: n.schemaName,
904
+ name: n.tableName
1354
905
  }
1355
906
  ]
1356
907
  } : void 0
@@ -1359,38 +910,38 @@ function Pt(e, t, a, r, n, i) {
1359
910
  id: e.id,
1360
911
  label: e.label,
1361
912
  variableName: e.id,
1362
- scope: r,
1363
- filter: p,
1364
- defaultValue: ee(
1365
- p,
913
+ scope: s,
914
+ filter: _,
915
+ defaultValue: xt(
916
+ _,
1366
917
  e.defaultValue
1367
918
  )
1368
919
  };
1369
920
  }
1370
- function G(e) {
921
+ function Ae(e) {
1371
922
  const t = [], a = [];
1372
- for (const r of e.viewIds) {
1373
- const n = e.viewIdToCardId.get(r);
1374
- n ? t.push(n) : a.push(r);
923
+ for (const s of e.viewIds) {
924
+ const d = e.viewIdToCardId.get(s);
925
+ d ? t.push(d) : a.push(s);
1375
926
  }
1376
927
  return a.length > 0 && e.warnings.push(
1377
- _(
928
+ K(
1378
929
  "input_scope_view_not_found",
1379
930
  `Filter "${e.inputLabel}" referenced unknown view ids: ${a.join(", ")}.`
1380
931
  )
1381
932
  ), Array.from(new Set(t));
1382
933
  }
1383
- function $t(e) {
1384
- var r, n;
934
+ function ws(e) {
935
+ var s, d;
1385
936
  if (!e.protocolScope) {
1386
937
  const i = Array.from(new Set(e.boundCardIds));
1387
938
  return i.length > 0 && i.length < e.allCardIds.length ? { kind: "cards", cardIds: i } : void 0;
1388
939
  }
1389
940
  if (e.protocolScope.level === "dashboard") {
1390
- if (!((r = e.protocolScope.excludeViewIds) != null && r.length))
941
+ if (!((s = e.protocolScope.excludeViewIds) != null && s.length))
1391
942
  return;
1392
943
  const i = new Set(
1393
- G({
944
+ Ae({
1394
945
  inputLabel: e.inputLabel,
1395
946
  viewIds: e.protocolScope.excludeViewIds,
1396
947
  viewIdToCardId: e.viewIdToCardId,
@@ -1399,18 +950,18 @@ function $t(e) {
1399
950
  );
1400
951
  return {
1401
952
  kind: "cards",
1402
- cardIds: e.allCardIds.filter((o) => !i.has(o))
953
+ cardIds: e.allCardIds.filter((n) => !i.has(n))
1403
954
  };
1404
955
  }
1405
956
  if (e.protocolScope.level === "view") {
1406
- const i = G({
957
+ const i = Ae({
1407
958
  inputLabel: e.inputLabel,
1408
959
  viewIds: e.protocolScope.viewIds,
1409
960
  viewIdToCardId: e.viewIdToCardId,
1410
961
  warnings: e.warnings
1411
962
  });
1412
963
  return i.length === 0 ? (e.warnings.push(
1413
- _(
964
+ K(
1414
965
  "input_scope_has_no_materialized_cards",
1415
966
  `Filter "${e.inputLabel}" was deferred because its view scope does not match any materialized cards.`
1416
967
  )
@@ -1419,15 +970,15 @@ function $t(e) {
1419
970
  const t = e.sectionIdToCardIds.get(e.protocolScope.sectionId) || [];
1420
971
  if (t.length === 0)
1421
972
  return e.warnings.push(
1422
- _(
973
+ K(
1423
974
  "input_scope_section_not_found",
1424
975
  `Filter "${e.inputLabel}" was deferred because section "${e.protocolScope.sectionId}" does not match any materialized cards.`
1425
976
  )
1426
977
  ), null;
1427
- if (!((n = e.protocolScope.excludeViewIds) != null && n.length))
978
+ if (!((d = e.protocolScope.excludeViewIds) != null && d.length))
1428
979
  return { kind: "cards", cardIds: t };
1429
980
  const a = new Set(
1430
- G({
981
+ Ae({
1431
982
  inputLabel: e.inputLabel,
1432
983
  viewIds: e.protocolScope.excludeViewIds,
1433
984
  viewIdToCardId: e.viewIdToCardId,
@@ -1439,104 +990,104 @@ function $t(e) {
1439
990
  cardIds: t.filter((i) => !a.has(i))
1440
991
  };
1441
992
  }
1442
- function aa(e) {
1443
- var g, b, c;
1444
- const t = [], a = Be(e);
993
+ function di(e) {
994
+ var w, c, R;
995
+ const t = [], a = Ta(e);
1445
996
  for (const m of a.warnings)
1446
- t.push(_(m.code, m.message));
997
+ t.push(K(m.code, m.message));
1447
998
  for (const m of a.errors)
1448
- t.push(_(m.code, m.message));
1449
- const r = kt(e, t), n = [], i = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set();
1450
- let p = 0;
1451
- for (const [m, C] of r.sections.entries()) {
1452
- const u = typeof C.title == "string" ? C.title : `Section ${m + 1}`, ne = C.id || O(u, `section-${m + 1}`);
1453
- o.set(ne, []);
1454
- for (const [ie, I] of ae(C).entries()) {
1455
- const oe = Ot(I), V = O(
1456
- I.id || `${u}-${I.title || `View ${ie + 1}`}`,
1457
- `card-${m + 1}-${ie + 1}`
999
+ t.push(K(m.code, m.message));
1000
+ const s = bs(e, t), d = [], i = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Set(), y = /* @__PURE__ */ new Set();
1001
+ let _ = 0;
1002
+ for (const [m, f] of s.sections.entries()) {
1003
+ const b = typeof f.title == "string" ? f.title : `Section ${m + 1}`, A = f.id || fe(b, `section-${m + 1}`);
1004
+ n.set(A, []);
1005
+ for (const [D, $] of Ue(f).entries()) {
1006
+ const U = ys($), F = fe(
1007
+ $.id || `${b}-${$.title || `View ${D + 1}`}`,
1008
+ `card-${m + 1}-${D + 1}`
1458
1009
  );
1459
- if (!oe) {
1010
+ if (!U) {
1460
1011
  t.push(
1461
- _(
1012
+ K(
1462
1013
  "unsupported_presentation",
1463
- `Dashboard presentation "${((g = I.presentation) == null ? void 0 : g.kind) || "unknown"}" is not supported by the dashboard authoring adapter.`,
1464
- `card-${V}`
1014
+ `Dashboard presentation "${((w = $.presentation) == null ? void 0 : w.kind) || "unknown"}" is not supported by the dashboard authoring adapter.`,
1015
+ `card-${F}`
1465
1016
  )
1466
1017
  );
1467
1018
  continue;
1468
1019
  }
1469
- if (((b = I.analytics) == null ? void 0 : b.kind) === "sql") {
1020
+ if (((c = $.analytics) == null ? void 0 : c.kind) === "sql") {
1470
1021
  t.push(
1471
- _(
1022
+ K(
1472
1023
  "sql_intent_deferred",
1473
1024
  "SQL analytics intent is valid protocol, but the current dashboard authoring adapter only materializes semantic and physical config-card intents.",
1474
- `card-${V}`
1025
+ `card-${F}`
1475
1026
  )
1476
1027
  );
1477
1028
  continue;
1478
1029
  }
1479
- const se = Se(V, l), N = `card-${se}`;
1480
- I.id && i.set(I.id, N), (c = o.get(ne)) == null || c.push(N);
1481
- const Te = I.analytics && "inputs" in I.analytics ? I.analytics.inputs : void 0;
1482
- for (const de of Te || []) {
1483
- const ce = s.get(de.inputId) || [];
1484
- ce.push(N), s.set(de.inputId, ce);
1030
+ const N = Dt(F, p), O = `card-${N}`;
1031
+ $.id && i.set($.id, O), (R = n.get(A)) == null || R.push(O);
1032
+ const B = $.analytics && "inputs" in $.analytics ? $.analytics.inputs : void 0;
1033
+ for (const j of B || []) {
1034
+ const M = o.get(j.inputId) || [];
1035
+ M.push(O), o.set(j.inputId, M);
1485
1036
  }
1486
- n.push({
1487
- id: N,
1488
- frameId: `frame-${se}`,
1489
- title: I.title,
1490
- description: I.description,
1491
- type: oe,
1492
- role: Rt(I),
1493
- priority: p,
1494
- section: u,
1495
- analyticsIntent: At(I.analytics),
1496
- text: I.text
1497
- }), p += 1;
1037
+ d.push({
1038
+ id: O,
1039
+ frameId: `frame-${N}`,
1040
+ title: $.title,
1041
+ description: $.description,
1042
+ type: U,
1043
+ role: _s($),
1044
+ priority: _,
1045
+ section: b,
1046
+ analyticsIntent: Is($.analytics),
1047
+ text: $.text
1048
+ }), _ += 1;
1498
1049
  }
1499
1050
  }
1500
- const h = r.inputs.map((m) => {
1501
- const C = $t({
1051
+ const g = s.inputs.map((m) => {
1052
+ const f = ws({
1502
1053
  protocolScope: m.scope,
1503
1054
  inputLabel: m.label,
1504
- allCardIds: n.map((u) => u.id),
1505
- boundCardIds: s.get(m.id) || [],
1055
+ allCardIds: d.map((b) => b.id),
1056
+ boundCardIds: o.get(m.id) || [],
1506
1057
  viewIdToCardId: i,
1507
- sectionIdToCardIds: o,
1058
+ sectionIdToCardIds: n,
1508
1059
  warnings: t
1509
1060
  });
1510
- return C === null ? null : Pt(
1061
+ return f === null ? null : xs(
1511
1062
  m,
1512
- r.defaultSource,
1513
- r.sources,
1514
- C,
1515
- d,
1063
+ s.defaultSource,
1064
+ s.sources,
1065
+ f,
1066
+ y,
1516
1067
  t
1517
1068
  );
1518
1069
  }).filter((m) => !!m);
1519
1070
  return { plan: {
1520
1071
  version: 1,
1521
- id: `plan-${O(e.title, "dashboard")}`,
1072
+ id: `plan-${fe(e.title, "dashboard")}`,
1522
1073
  title: e.title,
1523
1074
  description: e.description,
1524
- datasets: r.datasets,
1075
+ datasets: s.datasets,
1525
1076
  sheets: [
1526
1077
  {
1527
- id: `sheet-${O(e.title, "dashboard")}`,
1078
+ id: `sheet-${fe(e.title, "dashboard")}`,
1528
1079
  title: e.title,
1529
1080
  description: e.description,
1530
1081
  kind: "dashboard",
1531
- cards: n
1082
+ cards: d
1532
1083
  }
1533
1084
  ],
1534
- filterInputs: h.length ? h : void 0,
1085
+ filterInputs: g.length ? g : void 0,
1535
1086
  warnings: t.length ? t : void 0,
1536
1087
  unresolvedRequests: a.ok ? void 0 : a.errors.map((m) => m.message)
1537
1088
  }, warnings: t };
1538
1089
  }
1539
- const ra = [
1090
+ const li = [
1540
1091
  "cardType",
1541
1092
  "sql",
1542
1093
  "python",
@@ -1551,120 +1102,120 @@ const ra = [
1551
1102
  "resolvedPrimaryDateField",
1552
1103
  "globalDateComparison",
1553
1104
  "calendarContext"
1554
- ], na = [
1105
+ ], ci = [
1555
1106
  "cardId",
1556
1107
  "cardTitle",
1557
1108
  "cache_config",
1558
1109
  "queryConfig",
1559
1110
  "tableConfig"
1560
1111
  ];
1561
- class D extends Error {
1562
- constructor(a, r, n) {
1112
+ class W extends Error {
1113
+ constructor(a, s, d) {
1563
1114
  super(a);
1564
- z(this, "field");
1565
- z(this, "details");
1566
- Object.setPrototypeOf(this, D.prototype), this.name = "CardQueryRequestError", this.field = r, this.details = n;
1115
+ Te(this, "field");
1116
+ Te(this, "details");
1117
+ Object.setPrototypeOf(this, W.prototype), this.name = "CardQueryRequestError", this.field = s, this.details = d;
1567
1118
  }
1568
1119
  }
1569
- function re(e) {
1120
+ function je(e) {
1570
1121
  return e.label ? `${e.label}.` : "";
1571
1122
  }
1572
- function x(e) {
1123
+ function ae(e) {
1573
1124
  return !e || typeof e != "object" || Array.isArray(e) ? {} : { ...e };
1574
1125
  }
1575
- function B(e) {
1126
+ function Ce(e) {
1576
1127
  return typeof e == "string" ? e : "";
1577
1128
  }
1578
- function Bt(e, t = {}) {
1579
- const a = x(e), r = re(t), n = {};
1129
+ function Ds(e, t = {}) {
1130
+ const a = ae(e), s = je(t), d = {};
1580
1131
  if (a.calendarContext !== void 0) {
1581
- const o = ze(a.calendarContext);
1582
- if (!o.ok)
1583
- throw new D(
1584
- `${r}calendarContext: ${o.issues.map((s) => s.message).join("; ")}`,
1132
+ const n = Pa(a.calendarContext);
1133
+ if (!n.ok)
1134
+ throw new W(
1135
+ `${s}calendarContext: ${n.issues.map((o) => o.message).join("; ")}`,
1585
1136
  "calendarContext",
1586
- o.issues
1137
+ n.issues
1587
1138
  );
1588
- n.calendarContext = o.value;
1139
+ d.calendarContext = n.value;
1589
1140
  }
1590
- const i = Oe(a.resolvedPrimaryDateField);
1141
+ const i = Ut(a.resolvedPrimaryDateField);
1591
1142
  if (!i.ok)
1592
- throw new D(
1593
- `${r}${Re(i.issues)}`,
1143
+ throw new W(
1144
+ `${s}${jt(i.issues)}`,
1594
1145
  "resolvedPrimaryDateField",
1595
1146
  i.issues
1596
1147
  );
1597
- if (a.resolvedPrimaryDateField && (n.resolvedPrimaryDateField = a.resolvedPrimaryDateField), a.globalDateComparison !== void 0) {
1598
- const o = qe(a.globalDateComparison);
1599
- if (!o.ok)
1600
- throw new D(
1601
- `${r}Invalid globalDateComparison: ${o.errors.map((s) => `${s.path}: ${s.message}`).join("; ")}`,
1148
+ if (a.resolvedPrimaryDateField && (d.resolvedPrimaryDateField = a.resolvedPrimaryDateField), a.globalDateComparison !== void 0) {
1149
+ const n = Na(a.globalDateComparison);
1150
+ if (!n.ok)
1151
+ throw new W(
1152
+ `${s}Invalid globalDateComparison: ${n.errors.map((o) => `${o.path}: ${o.message}`).join("; ")}`,
1602
1153
  "globalDateComparison",
1603
- o.errors
1154
+ n.errors
1604
1155
  );
1605
- n.globalDateComparison = Ve(
1156
+ d.globalDateComparison = qa(
1606
1157
  a.globalDateComparison
1607
1158
  );
1608
1159
  }
1609
- return n;
1160
+ return d;
1610
1161
  }
1611
- function ia(e, t = {}) {
1612
- const a = x(e), r = re(t), n = {};
1162
+ function ui(e, t = {}) {
1163
+ const a = ae(e), s = je(t), d = {};
1613
1164
  if (a.pagination !== void 0) {
1614
- const i = x(a.pagination), o = i.page, s = i.pageSize;
1615
- if (!Number.isInteger(o) || o < 1 || !Number.isInteger(s) || s < 1)
1616
- throw new D(
1617
- `${r}pagination must name a page and a page size of at least 1`,
1165
+ const i = ae(a.pagination), n = i.page, o = i.pageSize;
1166
+ if (!Number.isInteger(n) || n < 1 || !Number.isInteger(o) || o < 1)
1167
+ throw new W(
1168
+ `${s}pagination must name a page and a page size of at least 1`,
1618
1169
  "pagination"
1619
1170
  );
1620
- n.pagination = { page: o, pageSize: s };
1171
+ d.pagination = { page: n, pageSize: o };
1621
1172
  }
1622
1173
  if (a.tableTotalsRequest !== void 0) {
1623
1174
  if (!a.tableTotalsRequest || typeof a.tableTotalsRequest != "object" || Array.isArray(a.tableTotalsRequest))
1624
- throw new D(`${r}tableTotalsRequest must be an object`, "tableTotalsRequest");
1625
- n.tableTotalsRequest = a.tableTotalsRequest;
1175
+ throw new W(`${s}tableTotalsRequest must be an object`, "tableTotalsRequest");
1176
+ d.tableTotalsRequest = a.tableTotalsRequest;
1626
1177
  }
1627
1178
  if (a.sourceRowProbe !== void 0) {
1628
- const i = x(a.sourceRowProbe).limit;
1179
+ const i = ae(a.sourceRowProbe).limit;
1629
1180
  if (!Number.isInteger(i) || i < 1)
1630
- throw new D(
1631
- `${r}sourceRowProbe must name a limit of at least 1`,
1181
+ throw new W(
1182
+ `${s}sourceRowProbe must name a limit of at least 1`,
1632
1183
  "sourceRowProbe"
1633
1184
  );
1634
- if (n.pagination)
1635
- throw new D(
1636
- `${r}sourceRowProbe cannot be combined with pagination`,
1185
+ if (d.pagination)
1186
+ throw new W(
1187
+ `${s}sourceRowProbe cannot be combined with pagination`,
1637
1188
  "sourceRowProbe"
1638
1189
  );
1639
- n.sourceRowProbe = { limit: i };
1190
+ d.sourceRowProbe = { limit: i };
1640
1191
  }
1641
- return n;
1642
- }
1643
- function oa(e, t = {}) {
1644
- const a = x(e), r = re(t), n = (c) => new D(`${r}${c} is required`, c), i = B(a.connection_id).trim();
1645
- if (!i) throw n("connection_id");
1646
- const o = B(a.cardType).trim();
1647
- if (!o) throw n("cardType");
1648
- const s = a.resultOwner;
1649
- if (s !== "config" && s !== "freeform" && s !== "none")
1650
- throw n("resultOwner");
1651
- const l = x(a.cardConfig), d = B(a.sql), p = B(a.python), h = !!t.configOptional || Object.keys(l).length > 0;
1652
- if (s === "config" && !h) throw n("cardConfig");
1653
- if (s === "freeform" && !d.trim()) throw n("sql");
1654
- const y = Ee({
1655
- hasExecutableConfig: h,
1656
- sql: d,
1657
- normalizedPython: p
1192
+ return d;
1193
+ }
1194
+ function fi(e, t = {}) {
1195
+ const a = ae(e), s = je(t), d = (R) => new W(`${s}${R} is required`, R), i = Ce(a.connection_id).trim();
1196
+ if (!i) throw d("connection_id");
1197
+ const n = Ce(a.cardType).trim();
1198
+ if (!n) throw d("cardType");
1199
+ const o = a.resultOwner;
1200
+ if (o !== "config" && o !== "freeform" && o !== "none")
1201
+ throw d("resultOwner");
1202
+ const p = ae(a.cardConfig), y = Ce(a.sql), _ = Ce(a.python), g = !!t.configOptional || Object.keys(p).length > 0;
1203
+ if (o === "config" && !g) throw d("cardConfig");
1204
+ if (o === "freeform" && !y.trim()) throw d("sql");
1205
+ const C = zt({
1206
+ hasExecutableConfig: g,
1207
+ sql: y,
1208
+ normalizedPython: _
1658
1209
  });
1659
- if (s !== y)
1660
- throw new D(
1661
- `${r}resultOwner must match the normalized execution owner "${y}"`,
1210
+ if (o !== C)
1211
+ throw new W(
1212
+ `${s}resultOwner must match the normalized execution owner "${C}"`,
1662
1213
  "resultOwner"
1663
1214
  );
1664
- if (s === "none") throw n("cardConfig");
1665
- const g = x(a.cardDataSource);
1666
- if (Object.keys(g).length === 0) throw n("cardDataSource");
1667
- const b = Ne({
1215
+ if (o === "none") throw d("cardConfig");
1216
+ const w = ae(a.cardDataSource);
1217
+ if (Object.keys(w).length === 0) throw d("cardDataSource");
1218
+ const c = Qt({
1668
1219
  controlValues: a.controlValues,
1669
1220
  controlDefinitions: a.controlDefinitions,
1670
1221
  cardControlDefinitions: a.cardControlDefinitions,
@@ -1672,171 +1223,1285 @@ function oa(e, t = {}) {
1672
1223
  });
1673
1224
  return {
1674
1225
  connection_id: i,
1675
- cardType: o,
1676
- sql: d,
1677
- python: p,
1678
- resultOwner: s,
1679
- cardConfig: l,
1680
- cardDataSource: g,
1226
+ cardType: n,
1227
+ sql: y,
1228
+ python: _,
1229
+ resultOwner: o,
1230
+ cardConfig: p,
1231
+ cardDataSource: w,
1681
1232
  active_filters: Array.isArray(a.active_filters) ? a.active_filters : [],
1682
- controlValues: b.controlValues,
1683
- controlDefinitions: b.controlDefinitions,
1684
- cardControlDefinitions: b.cardControlDefinitions,
1685
- controlBindings: b.controlBindings,
1686
- ...Bt(a, t)
1233
+ controlValues: c.controlValues,
1234
+ controlDefinitions: c.controlDefinitions,
1235
+ cardControlDefinitions: c.cardControlDefinitions,
1236
+ controlBindings: c.controlBindings,
1237
+ ...Ds(a, t)
1238
+ };
1239
+ }
1240
+ const Ts = {
1241
+ global_date: "The date filter for the whole report can't be changed through the MCP. Change it in the editor; removing or excluding it works.",
1242
+ not_semantic: "This filter reads a database table, not a dataset, so it can't be changed through the MCP. Change it in the editor; removing or excluding it works.",
1243
+ scope_not_expressible: "This filter applies to chosen cards rather than whole sheets, so it can't be changed through the MCP. Change it in the editor; removing or excluding it works."
1244
+ };
1245
+ function ks(e, t) {
1246
+ var n;
1247
+ const a = de(e), s = Kt(t.scope), d = new Set(re(e).map((o) => o.cardId)), i = {
1248
+ reaches: [],
1249
+ excluded: [
1250
+ .../* @__PURE__ */ new Set([
1251
+ ...(((n = t.application) == null ? void 0 : n.cards) ?? []).filter((o) => o.kind === "excluded").map((o) => o.cardId),
1252
+ ...s.filter((o) => d.has(o))
1253
+ ])
1254
+ ],
1255
+ notReached: []
1256
+ };
1257
+ if (t.filter.kind === "global-date") {
1258
+ const o = new Set(i.excluded);
1259
+ return i.reaches = Wt(e, t.filter).filter(({ card: p }) => !o.has(p.id) && ve(p)).map(({ card: p }) => p.id), i;
1260
+ }
1261
+ for (const o of a.reachedCards({ inputId: t.id })) {
1262
+ const p = Oe(t, o.card);
1263
+ if (p === "bound" || p === "automatic" || p === "sql") i.reaches.push(o.cardId);
1264
+ else if (p === "blocked" || p === "ambiguous")
1265
+ (i.blocked ?? (i.blocked = [])).push({ cardId: o.cardId, title: o.card.title ?? "", reason: p });
1266
+ else if (p !== "excluded") {
1267
+ const y = ve(o.card);
1268
+ if (!y) continue;
1269
+ i.notReached.push({
1270
+ cardId: o.cardId,
1271
+ title: o.card.title ?? "",
1272
+ ...(y == null ? void 0 : y.kind) === "semantic" ? { datasetName: y.datasetName } : {}
1273
+ });
1274
+ }
1275
+ }
1276
+ return i;
1277
+ }
1278
+ function $s(e, t) {
1279
+ var d;
1280
+ const a = t.scope;
1281
+ if (a.kind === "allSheets") {
1282
+ if ((d = a.sheetKinds) != null && d.length && !a.sheetKinds.includes("dashboard")) return;
1283
+ const i = Ht(a);
1284
+ return {
1285
+ sheetIds: "all",
1286
+ ...i.length ? { exceptSheetIds: [...i] } : {},
1287
+ ...Yt(a) ? { includesDocumentSheets: !0 } : {}
1288
+ };
1289
+ }
1290
+ if (a.kind !== "sheets") return;
1291
+ const s = [...Me(e).values()].filter((i) => bt(t, i));
1292
+ return {
1293
+ sheetIds: s.filter((i) => i.sheetKind === "dashboard").map((i) => i.sheetId),
1294
+ // Document sheets it names stay through a change of sheets (`withUnstatedScopeParts`).
1295
+ ...s.some((i) => i.sheetKind === "document") ? { includesDocumentSheets: !0 } : {}
1296
+ };
1297
+ }
1298
+ function kt(e, t) {
1299
+ return e ?? { tz: "UTC", weekStart: 1, anchor: { iso: t ?? "1970-01-01T00:00:00.000Z" } };
1300
+ }
1301
+ function $t(e, t, a) {
1302
+ var c, R, m;
1303
+ const { input: s } = t, d = ks(e, s), i = (f, b) => ({
1304
+ filterId: s.id,
1305
+ label: s.label,
1306
+ editable: !1,
1307
+ kind: b,
1308
+ notEditable: { reason: f, message: Ts[f] },
1309
+ reaches: d.reaches,
1310
+ excluded: d.excluded,
1311
+ ...d.blocked ? { blocked: d.blocked } : {}
1312
+ });
1313
+ if (s.filter.kind === "global-date") return i("global_date", "global_date");
1314
+ const n = Ea(s.filter).filter((f) => f.kind === "semantic");
1315
+ if (n.length !== 1 || n[0].kind !== "semantic") return i("not_semantic", "field");
1316
+ const o = $s(e, s);
1317
+ if (!o || t.origin !== "embeddedInput") return i("scope_not_expressible", "field");
1318
+ const p = ((c = s.filter.fieldMeta) == null ? void 0 : c.name) ?? ((R = s.filter.column) == null ? void 0 : R.split(".").pop()) ?? "", y = gt({
1319
+ dashboard: e,
1320
+ target: { kind: "dashboardInput", input: s, scope: {} },
1321
+ calendar: kt(a, void 0)
1322
+ }).value, _ = _t(s.filter.dataType), g = _ || (m = y == null ? void 0 : y.values) == null ? void 0 : m.filter((f) => ["string", "number", "boolean"].includes(typeof f)), C = y && "relativeMeta" in y ? y.relativeMeta : void 0, w = _ && C ? ka(C) : null;
1323
+ return {
1324
+ filterId: s.id,
1325
+ label: s.label,
1326
+ editable: !0,
1327
+ domainId: n[0].domainId,
1328
+ datasetName: n[0].datasetName,
1329
+ field: p,
1330
+ selection: s.filter.type === "single" ? "single" : "multiple",
1331
+ ...g != null && g.length ? { defaultValues: g } : {},
1332
+ ...w ? { defaultPeriod: w } : {},
1333
+ ..._ ? { datePicker: s.filter.dateSelectionMode === "day" ? "day" : s.filter.dateSelectionMode === "months" ? "month" : "range" } : {},
1334
+ ...o,
1335
+ ...d
1336
+ };
1337
+ }
1338
+ function Ft(e, t) {
1339
+ return de(e).inputs.map((a) => $t(e, a, t));
1340
+ }
1341
+ function he(e, t, a) {
1342
+ const s = de(e).findFilterInput({ inputId: t });
1343
+ return s ? $t(e, s, a) : void 0;
1344
+ }
1345
+ function Fs(e, t, a, s, d) {
1346
+ var f, b, A, D, $, U;
1347
+ const i = oe(e, { sql: !0 });
1348
+ if (!i.editable) return [i.message];
1349
+ const n = i.query, o = t;
1350
+ if ("sql" in t) return o.sql === n.sql && o.connectionId === n.connectionId ? [] : ["the SQL"];
1351
+ const p = (s == null ? void 0 : s.source.kind) === "semantic" ? oe({
1352
+ id: e.id,
1353
+ title: e.title,
1354
+ type: s.type,
1355
+ dataSource: s.source.dataSource,
1356
+ connectionId: s.source.connectionId,
1357
+ config: s.config
1358
+ }, { sql: !0 }) : void 0;
1359
+ if (p && !p.editable) return ["the compiled query"];
1360
+ const y = p != null && p.editable ? p.query : void 0, _ = String(o.datasetName ?? ""), g = [], C = (F) => ne(F, _), w = (F, N, O) => {
1361
+ const B = N ?? [], j = O ?? [];
1362
+ (B.length !== j.length || B.some((M, E) => C(M) !== C(j[E]))) && g.push(F);
1363
+ };
1364
+ for (const F of ["domainId", "datasetName"]) o[F] !== n[F] && g.push(F);
1365
+ if (w("measures", o.measures, n.measures), w("columns", o.columns, n.columns), a || i.matrix) {
1366
+ const F = (O) => new Set(((O == null ? void 0 : O.columns) ?? []).map(C)), N = (O, B) => (O ?? []).filter((j) => !F(B).has(C(j)));
1367
+ w("dimensions", N(o.dimensions, a), N(n.dimensions, i.matrix)), w("matrix.columns", a == null ? void 0 : a.columns, (f = i.matrix) == null ? void 0 : f.columns);
1368
+ } else
1369
+ w("dimensions", o.dimensions, n.dimensions);
1370
+ const c = o.timeWindow !== void 0 && !o.timeGrain, R = c && n.timeWindow === void 0 ? void 0 : c && o.dateField === void 0 ? y == null ? void 0 : y.dateField : o.dateField;
1371
+ R !== void 0 && (n.dateField === void 0 || C(R) !== C(n.dateField)) && g.push("dateField"), o.timeGrain !== void 0 && o.timeGrain !== n.timeGrain && g.push("timeGrain");
1372
+ const m = (b = e.config) != null && b.matrix ? e.config.matrix.spec.measures.map((F) => F.kind === "aggregate" ? { aggregate: F.aggregate } : {}) : ((A = e.config) == null ? void 0 : A.metricColumns) ?? [];
1373
+ (o.measures ?? []).forEach((F, N) => {
1374
+ const O = F && typeof F == "object" ? F.aggregate : void 0;
1375
+ O && ct(m[N] ?? {}) !== O && g.push(`the aggregate of measures[${N}]`);
1376
+ });
1377
+ for (const { key: F, label: N } of Re(t))
1378
+ Xt(e, F) !== N && g.push(`the label "${N}"`);
1379
+ if (!d || d.aspects.includes("filters")) {
1380
+ const F = o.filters ?? [];
1381
+ let N = n.filters ?? [];
1382
+ const O = o.timeWindow, B = n.timeWindow, j = (M, E) => {
1383
+ const Y = (ge) => JSON.stringify((ge ?? []).map(String));
1384
+ return C(M.field) === C(E.field) && M.operator === E.operator && (M.scope ?? "row") === (E.scope ?? "row") && (typeof M.field == "object" ? M.field.aggregate : void 0) === (typeof E.field == "object" ? E.field.aggregate : void 0) && (M.values === void 0 || Y(M.values) === Y(E.values));
1385
+ };
1386
+ if (O && !B) {
1387
+ const M = ((y == null ? void 0 : y.filters) ?? []).filter(
1388
+ (E) => !(y != null && y.timeWindow) && !F.some((Y) => j(Y, E))
1389
+ );
1390
+ (!M.length || M.some((E) => !N.some((Y) => j(E, Y)))) && g.push("timeWindow"), N = N.filter((E) => !M.some((Y) => j(Y, E)));
1391
+ } else O ? Object.keys(O).filter((E) => !(E === "kind" && O.kind === "relative" && (B == null ? void 0 : B.kind) === void 0)).some((E) => !Le(O[E], B == null ? void 0 : B[E])) && g.push("timeWindow") : B && g.push("timeWindow");
1392
+ (F.length !== N.length || F.some((M, E) => !j(M, N[E]))) && g.push("filters");
1393
+ }
1394
+ if (o.orderBy !== void 0) {
1395
+ const F = o.orderBy, N = ($ = (D = e.config) == null ? void 0 : D.sortByColumns) == null ? void 0 : $[0], O = N && Jt(e.config ?? {}, N), B = F.field && typeof F.field == "object" ? F.field.aggregate : void 0;
1396
+ (!N || !O || N.direction !== F.direction || C(F.field) !== Zt(O.name, ea(O)) || B !== void 0 && ct(O) !== B) && g.push("orderBy");
1397
+ }
1398
+ return o.limit !== void 0 && ((U = e.config) == null ? void 0 : U.rowLimit) !== o.limit && g.push("limit"), g;
1399
+ }
1400
+ class ue extends Error {
1401
+ }
1402
+ const Pe = (e) => (e ?? "").trim().toLowerCase(), we = da, ht = { measures: fa, records: ua, sql: ca }, Se = {
1403
+ measures: "a measures query (measures, with optional dimensions)",
1404
+ records: "a records query (columns)",
1405
+ sql: "a SQL query"
1406
+ };
1407
+ function At(e, t) {
1408
+ return t.path.reduce((a, s) => typeof s == "number" ? `${a}[${s}]` : `${a}.${s}`, e);
1409
+ }
1410
+ async function hi(e, t, a) {
1411
+ var ge, Qe, Ke, We, He, Ye, Xe, Je;
1412
+ const s = [], d = [], i = [], n = [], o = /* @__PURE__ */ new Set(), p = [], y = /* @__PURE__ */ new Map(), _ = { calendar: a.calendar };
1413
+ let g = e, C = 0;
1414
+ if (t.length > it)
1415
+ return {
1416
+ ok: !1,
1417
+ problems: [
1418
+ {
1419
+ code: "too_many_changes",
1420
+ message: `A proposal takes at most ${it} changes; this one has ${t.length}.`,
1421
+ path: "changes",
1422
+ fix: "Split the changes into several proposals."
1423
+ }
1424
+ ]
1425
+ };
1426
+ const w = [];
1427
+ if (t.forEach((h, r) => {
1428
+ const l = ta.safeParse(h);
1429
+ if (l.success) {
1430
+ w.push(l.data);
1431
+ return;
1432
+ }
1433
+ for (const u of l.error.issues)
1434
+ s.push({
1435
+ code: "invalid_change",
1436
+ message: u.message,
1437
+ path: At(`changes[${r}]`, u),
1438
+ fix: "Send the change in the shape the tool schema gives."
1439
+ });
1440
+ }), s.length) return { ok: !1, problems: s };
1441
+ const c = (h) => {
1442
+ throw s.push(h), new ue();
1443
+ }, R = (h) => {
1444
+ a.capabilities.sql || c({
1445
+ code: "capability_required",
1446
+ message: "This change creates, reads or changes a SQL card, which needs SQL access.",
1447
+ path: h,
1448
+ fix: "Use a measures or records query, or ask an administrator for SQL access."
1449
+ }), o.add("sql");
1450
+ }, m = (h, r) => {
1451
+ const l = st(g, [h], _);
1452
+ l.ok ? (g = l.dashboard, i.push(h)) : c({ code: "invalid_change", message: l.failedAt.message, path: r, ...l.failedAt.fix ? { fix: l.failedAt.fix } : {} });
1453
+ }, f = (h, r) => {
1454
+ if (h.startsWith("$")) {
1455
+ const l = y.get(h);
1456
+ return (!l || l.kind !== "card") && c({
1457
+ code: "handle_unknown",
1458
+ message: `${h} isn't a card handle defined earlier in this list.`,
1459
+ path: r,
1460
+ fix: "Define the handle with an earlier card.add, or use the card id from the outline."
1461
+ }), l.id;
1462
+ }
1463
+ return re(g).some((l) => l.cardId === h) || c({
1464
+ code: "card_not_found",
1465
+ message: `There's no card ${h} on this dashboard.`,
1466
+ path: r,
1467
+ fix: "Read the outline again and use its card ids."
1468
+ }), h;
1469
+ }, b = (h, r) => {
1470
+ if (h.startsWith("$")) {
1471
+ const u = y.get(h);
1472
+ return (!u || u.kind !== "filter") && c({
1473
+ code: "handle_unknown",
1474
+ message: `${h} isn't a filter handle defined earlier in this list.`,
1475
+ path: r,
1476
+ fix: "Define the handle with an earlier filter.add, or use the filter id from the outline."
1477
+ }), u.id;
1478
+ }
1479
+ return (Array.isArray(g.inputs) ? g.inputs : []).some((u) => u.id === h && u.kind === "filter") || c({
1480
+ code: "filter_not_found",
1481
+ message: `There's no filter ${h} on this dashboard.`,
1482
+ path: r,
1483
+ fix: "Read the outline again and use its filter ids."
1484
+ }), h;
1485
+ }, A = () => (g.sheets ?? []).filter((h) => !dt(h)), D = () => A().map((h) => ({ sheetId: h.id, title: h.title ?? "" })), $ = (h, r) => {
1486
+ const l = (g.sheets ?? []).find((u) => u.id === h);
1487
+ return l || c({ code: "sheet_not_found", message: `There's no sheet ${h} on this dashboard.`, path: r, fix: "Read the outline again and use its sheet ids.", details: { sheets: D() } }), dt(l) && c({ code: "sheet_not_a_grid", message: `"${l.title}" is a Document sheet.`, path: r, fix: "Add the card to a grid sheet; Document sheets are changed in the editor.", details: { sheets: D() } }), l;
1488
+ }, U = (h, r, l, u) => {
1489
+ var k;
1490
+ for (const x of ha(r, l)) c({ ...x, path: `${u}.${x.path}` });
1491
+ const I = ce[h], T = we(r), S = r.dateField;
1492
+ if (S && typeof S != "string" && S.label && !r.timeGrain && c({
1493
+ code: "invalid_change",
1494
+ message: "A label names a column, and the date field is a column only when the card groups by it.",
1495
+ path: `${u}.query.dateField.label`,
1496
+ fix: "Send timeGrain to group by the date, or leave the label out."
1497
+ }), !I.forms.includes(T)) {
1498
+ const x = Object.keys(ce).filter((v) => ce[v].forms.includes(T));
1499
+ c({
1500
+ code: "type_not_supported",
1501
+ message: `A ${h.replace(/_/g, " ")} card takes ${I.forms.map((v) => Se[v]).join(" or ")}, not ${Se[T]}.`,
1502
+ path: `${u}.query`,
1503
+ fix: `Send ${I.forms.map((v) => Se[v]).join(" or ")}, or use a type this query fits: ${x.join(", ")}.`
1504
+ });
1505
+ }
1506
+ if (T === "measures") {
1507
+ const x = r, v = x.measures.length;
1508
+ I.measures && (v < I.measures.min || I.measures.max !== void 0 && v > I.measures.max) && c({
1509
+ code: "type_not_supported",
1510
+ message: `A ${h.replace(/_/g, " ")} card shows exactly ${I.measures.max} measure.`,
1511
+ path: `${u}.query.measures`,
1512
+ fix: "Send one measure, or use a table or chart for several."
1513
+ }), !I.dimensions && ((k = x.dimensions) != null && k.length) && c({
1514
+ code: "type_not_supported",
1515
+ message: `A ${h.replace(/_/g, " ")} card shows one number, so it has no dimensions.`,
1516
+ path: `${u}.query.dimensions`,
1517
+ fix: "Remove the dimensions, or use a table or chart."
1518
+ }), h === "matrix" && (x.orderBy || x.limit) && c({
1519
+ code: "type_not_supported",
1520
+ message: "A Matrix's sorting and top N are set in the editor.",
1521
+ path: `${u}.query`,
1522
+ fix: "Leave out orderBy and limit for a Matrix."
1523
+ });
1524
+ }
1525
+ if (I.matrixColumns && !l && c({
1526
+ code: "type_not_supported",
1527
+ message: "A Matrix needs matrix.columns: the query fields that run across the top.",
1528
+ path: `${u}.matrix`,
1529
+ fix: "Send matrix: { columns: [...] } naming dimensions or the date field of the query (an empty list puts nothing across the top)."
1530
+ }), !I.matrixColumns && l && c({ code: "type_not_supported", message: "matrix.columns is only for Matrix cards.", path: `${u}.matrix`, fix: 'Leave out matrix, or use type "matrix".' }), l && T === "measures") {
1531
+ const x = r, v = x.datasetName, V = [...x.dimensions ?? [], ...x.timeGrain && x.dateField ? [x.dateField] : []];
1532
+ V.length && l.columns.length >= V.length && V.every((q) => l.columns.some((L) => ne(L, v) === ne(q, v))) && c({
1533
+ code: "type_not_supported",
1534
+ message: "A Matrix needs at least one field down the side.",
1535
+ path: `${u}.matrix.columns`,
1536
+ fix: "Leave one dimension or the date field out of matrix.columns."
1537
+ });
1538
+ const Q = new Set([...x.dimensions ?? [], ...x.dateField ? [x.dateField] : []].map((q) => ne(q, v)));
1539
+ l.columns.forEach((q, L) => {
1540
+ Q.has(ne(q, v)) || c({
1541
+ code: "type_not_supported",
1542
+ message: `"${lt(q)}" isn't one of the query's dimensions or its date field.`,
1543
+ path: `${u}.matrix.columns[${L}]`,
1544
+ fix: "Name dimensions or the date field of the query in matrix.columns."
1545
+ });
1546
+ });
1547
+ }
1548
+ }, F = (h, r) => c({
1549
+ code: h.code === "query_not_kept" ? "card_not_editable" : "invalid_change",
1550
+ message: h.message,
1551
+ path: `${r}.query`,
1552
+ fix: h.code === "query_not_kept" ? "Tell the user to make this change in the editor." : "Read the outline again and propose again.",
1553
+ details: { reason: "not_expressible", ..."parts" in h ? { parts: h.parts } : {} }
1554
+ }), N = (h, r, l, u, I, T, S) => {
1555
+ const k = Fs(h, r, l, T, S);
1556
+ k.length && c({
1557
+ code: "card_not_editable",
1558
+ message: `As changed, "${I}" wouldn't run the query asked for, so make this change in the editor.`,
1559
+ path: `${u}.query`,
1560
+ fix: "Tell the user to make this change in the editor.",
1561
+ details: { reason: "not_expressible", detail: `doesn't hold: ${k.join(", ")}` }
1562
+ });
1563
+ }, O = async (h, r, l, u) => {
1564
+ const I = nt(h);
1565
+ if ("sql" in r)
1566
+ return R(`${u}.query`), { type: I, source: { kind: "sql", connectionId: r.connectionId, sql: r.sql } };
1567
+ const T = I === "matrixTable" || I === "detailTable" ? "table" : I, S = await a.compileCardQuery({ query: r, chartType: T });
1568
+ if (!S.ok)
1569
+ throw s.push(...S.problems.map((v) => ({ ...v, path: v.path ? `${u}.query.${v.path}` : `${u}.query` }))), new ue();
1570
+ d.push(...S.warnings.map((v) => ({ ...v, path: v.path ?? `${u}.query` })));
1571
+ let k = { ...S.part, type: I };
1572
+ const x = k.config ?? {};
1573
+ if (I === "detailTable") {
1574
+ const v = pa(ma("table", "detailTable", x)) ?? {};
1575
+ k = { ...k, config: Rs(v) };
1576
+ }
1577
+ return I === "matrixTable" && (k = await B(k, x, r, l, u)), Es(k, Re(r));
1578
+ }, B = async (h, r, l, u, I) => {
1579
+ var Q;
1580
+ const T = await a.loadCardSource({ domainId: l.domainId, datasetName: l.datasetName });
1581
+ if (T || c({ code: "field_not_found", message: `The dataset "${l.datasetName}" isn't available.`, path: `${I}.query.datasetName`, fix: "Find datasets with semaphor_list_datasets." }), h.source.kind !== "semantic") throw new ue();
1582
+ const S = { id: "scratch", title: "", type: "table", dataSource: h.source.dataSource, config: r }, k = Ia(S, "matrixTable", { catalog: T.fields, createId: a.newId }), x = k.status === "changed" ? (Q = k.card.config) == null ? void 0 : Q.matrix : void 0;
1583
+ (k.status !== "changed" || k.leftOut.length || !x) && c({
1584
+ code: "type_not_supported",
1585
+ message: k.status === "changed" && k.leftOut.length ? `These fields can't run in a Matrix: ${k.leftOut.join(", ")}.` : "This query can't be shown as a Matrix.",
1586
+ path: `${I}.query`,
1587
+ fix: "Use plain dataset fields for a Matrix, or use a table."
1588
+ });
1589
+ let v = x;
1590
+ const V = l.datasetName;
1591
+ for (const [q, L] of u.columns.entries()) {
1592
+ const G = [...v.spec.rows, ...v.spec.columns].find(
1593
+ (z) => ya(z.field) === ne(L, V)
1594
+ );
1595
+ G || c({ code: "type_not_supported", message: `"${lt(L)}" isn't a level of this Matrix.`, path: `${I}.matrix.columns[${q}]`, fix: "Name dimensions or the date field of the query in matrix.columns." }), v = _a(v, Ca(v.spec, G.id, "columns")).config;
1596
+ }
1597
+ return { ...h, config: { matrix: v } };
1598
+ }, j = /* @__PURE__ */ new Map(), M = /* @__PURE__ */ new Map();
1599
+ for (const [h, r] of w.entries()) {
1600
+ const l = `changes[${h}]`;
1601
+ try {
1602
+ switch (r.op) {
1603
+ case "card.add": {
1604
+ const u = r.position && typeof r.position == "object" ? (() => {
1605
+ const L = f(r.position.after, `${l}.position.after`), G = re(g).find(
1606
+ (z) => z.cardId === L && z.kind === "frameCard"
1607
+ );
1608
+ return !G || G.kind !== "frameCard" ? c({
1609
+ code: "card_not_found",
1610
+ message: `${r.position.after} isn't a card on a grid sheet.`,
1611
+ path: `${l}.position.after`,
1612
+ fix: "Use a cardId from semaphor_get_dashboard_details on the same sheet, or a handle from this proposal."
1613
+ }) : (r.sheetId && r.sheetId !== G.sheetId && c({
1614
+ code: "invalid_change",
1615
+ message: `position.after names a card on another sheet than ${r.sheetId}.`,
1616
+ path: `${l}.position.after`,
1617
+ fix: "Leave out sheetId, or name the card's sheet."
1618
+ }), { sheetId: G.sheetId, frameId: G.frameId });
1619
+ })() : void 0, I = u ? $(u.sheetId, `${l}.position.after`) : r.sheetId ? $(r.sheetId, `${l}.sheetId`) : (() => {
1620
+ const L = A();
1621
+ return L.length !== 1 && c({
1622
+ code: L.length ? "sheet_required" : "sheet_not_a_grid",
1623
+ message: L.length ? "This dashboard has several grid sheets; say which one gets the card." : "This dashboard has no grid sheet to add a card to.",
1624
+ path: `${l}.sheetId`,
1625
+ fix: L.length ? "Send sheetId: one of details.sheets." : "Add a grid sheet in the editor first.",
1626
+ details: { sheets: D() }
1627
+ }), L[0];
1628
+ })();
1629
+ U(r.type, r.query, r.matrix, l);
1630
+ const T = await O(r.type, r.query, r.matrix, l), S = {
1631
+ ...Nt({ id: a.newId(), title: r.title, ...r.description ? { description: r.description } : {} }),
1632
+ type: T.type
1633
+ }, k = rt(S, T);
1634
+ k.ok || c({ code: "invalid_change", message: k.message, path: l });
1635
+ const x = k.ok ? k.card : S;
1636
+ N(x, r.query, r.matrix, l, r.title, T);
1637
+ const v = { id: a.newId(), cards: [x], activeCardId: x.id }, V = u ? { after: u.frameId } : typeof r.position == "string" ? r.position : void 0, Q = V || r.width ? { ...V ? { position: V } : {}, ...r.width ? { width: r.width } : {} } : void 0;
1638
+ m({ op: "card.add", sheetId: I.id, frame: v, ...Q ? { placement: Q } : {}, changeIndex: h }, l);
1639
+ const q = r.handle ?? `$card_${++C}`;
1640
+ y.has(q) && c({ code: "invalid_change", message: `The handle ${q} is defined twice.`, path: `${l}.handle`, fix: "Give each new card or filter its own handle." }), y.set(q, { kind: "card", id: x.id, title: r.title }), n.push({ ref: q, kind: "card", id: x.id, title: r.title, changeIndex: h }), p.push(x.id);
1641
+ break;
1642
+ }
1643
+ case "card.update": {
1644
+ const u = f(r.cardId, `${l}.cardId`), I = ie(g, u);
1645
+ I || c({ code: "card_not_editable", message: "Cards in Document sections are changed in the editor.", path: `${l}.cardId`, fix: "Tell the user to change it in the editor.", details: { reason: "document_section" } });
1646
+ const T = I.card, S = oe(T, { sql: !0 });
1647
+ ((ge = S.source) == null ? void 0 : ge.kind) === "sql" && R(`${l}.cardId`), S.editable || c({
1648
+ code: "card_not_editable",
1649
+ message: S.message,
1650
+ path: `${l}.cardId`,
1651
+ fix: S.reason === "needs_sql_access" ? "Ask for SQL access." : "Tell the user to change it in the editor.",
1652
+ details: { reason: S.reason, ...S.detail ? { detail: S.detail } : {} }
1653
+ }), I.frame.visualId && d.push({
1654
+ code: "detaches_linked_visual",
1655
+ message: `"${T.title}" will stop following its library visual and become local to this dashboard.`,
1656
+ path: l,
1657
+ details: { cardIds: [u] }
1658
+ });
1659
+ let k = !1;
1660
+ const x = r.type ? nt(r.type) : void 0;
1661
+ if (x && x !== T.type) {
1662
+ const v = S.editable ? S.source : void 0, V = sa(T, x), Q = V && v && v.kind === "semantic" ? (Qe = await a.loadCardSource({ domainId: v.domainId, datasetName: v.datasetName })) == null ? void 0 : Qe.fields : void 0, q = [], L = ia(T, x, {
1663
+ ...Q ? { catalog: Q } : {},
1664
+ ...V && !Q ? { catalogLoading: !0 } : {},
1665
+ createId: () => {
1666
+ const G = a.newId();
1667
+ return q.push(G), G;
1668
+ }
1669
+ });
1670
+ if (L.status === "refused" && c({ code: "type_not_supported", message: "The card's dataset fields couldn't be loaded for a change to or from a Matrix.", path: `${l}.type`, fix: "Send a complete query with the type change." }), L.status === "changed") {
1671
+ const G = [...L.leftOut, ...L.droppedPreferences];
1672
+ G.length && d.push({
1673
+ code: "type_change_drops",
1674
+ message: `Changing "${T.title}" to ${r.type.replace(/_/g, " ")} leaves out ${G.join(", ")}.`,
1675
+ path: `${l}.type`,
1676
+ details: { dropped: G }
1677
+ }), m(
1678
+ { op: "card.update", cardId: u, update: { kind: "retype", type: x, ...Q ? { catalog: Q } : {}, newIds: q }, changeIndex: h },
1679
+ `${l}.type`
1680
+ ), k = !0;
1681
+ }
1682
+ }
1683
+ if (r.query || r.matrix) {
1684
+ const v = ie(g, u).card, V = oe(v, { sql: !0 }), Q = V.editable ? V.query : void 0, q = qs(Q, r.query ?? {}, `${l}.query`, c), L = Ee(v.type), G = r.matrix ?? (V.editable ? V.matrix : void 0);
1685
+ U(L, q, G, l);
1686
+ const z = V.editable ? na(V.query, q, V.matrix, G) : void 0, Ze = !z || z.aspects.length > 0, le = z && !("sql" in q) ? Re(q).filter((X) => !ot(z, X.key.role)) : [], et = oa(v, z, le.map((X) => X.key.role));
1687
+ et && F(et, l);
1688
+ let De = q;
1689
+ if (z && !("sql" in q) && q.orderBy && !z.aspects.includes("order") && ["metric", "group_by", "detail"].some((X) => ot(z, X))) {
1690
+ const { orderBy: X, ...be } = q;
1691
+ De = be;
1692
+ }
1693
+ let tt;
1694
+ if (Ze) {
1695
+ const X = await O(L, De, G, l);
1696
+ tt = X;
1697
+ const be = z ? { ...X, change: z } : X, ee = rt(v, be);
1698
+ if (ee.ok || F(ee, l), ee.ok && ee.droppedBindings.length && d.push({
1699
+ code: "control_binding_dropped",
1700
+ message: `"${v.title}" loses the controls bound to the levels or measures this change removes; they stop changing this card.`,
1701
+ path: `${l}.query`,
1702
+ fix: "Keep those fields in the query, or tell the user the controls no longer apply to this card.",
1703
+ details: { controlIds: ee.droppedBindings }
1704
+ }), ee.ok)
1705
+ for (const Ie of ee.keptLabels)
1706
+ d.push({
1707
+ code: "label_kept_after_change",
1708
+ message: `"${v.title}" keeps the label "${Ie.label}" on ${Ie.field}, whose aggregate or time grain changed.`,
1709
+ path: `${l}.query`,
1710
+ fix: "State a new label on the field ref if the old one no longer fits.",
1711
+ details: { columns: [{ label: Ie.label, field: Ie.field }] }
1712
+ });
1713
+ m({ op: "card.update", cardId: u, update: { kind: "requery", query: be }, changeIndex: h }, `${l}.query`), k = !0;
1714
+ }
1715
+ le.length && ra(ie(g, u).card, le).changed.length && m({ op: "card.update", cardId: u, update: { kind: "relabel", labels: le }, changeIndex: h }, `${l}.query`), (Ze || le.length) && N(ie(g, u).card, De, G, l, v.title ?? "", tt, z);
1716
+ }
1717
+ (r.title !== void 0 || r.description !== void 0) && m(
1718
+ {
1719
+ op: "card.update",
1720
+ cardId: u,
1721
+ update: {
1722
+ kind: "rename",
1723
+ ...r.title !== void 0 ? { title: r.title } : {},
1724
+ ...r.description !== void 0 ? { description: r.description } : {}
1725
+ },
1726
+ changeIndex: h
1727
+ },
1728
+ l
1729
+ ), k && !p.includes(u) && p.push(u), n.push({ ref: r.cardId, kind: "card", id: u, title: T.title ?? "", changeIndex: h });
1730
+ break;
1731
+ }
1732
+ case "card.remove": {
1733
+ const u = f(r.cardId, `${l}.cardId`), I = ie(g, u);
1734
+ I || c({ code: "card_not_editable", message: "Cards in Document sections are removed in the editor.", path: `${l}.cardId`, fix: "Tell the user to remove it in the editor.", details: { reason: "document_section" } }), I.frame.cards.some((S) => {
1735
+ var k, x;
1736
+ return ((k = S.customCardPreferences) == null ? void 0 : k.visualType) === "multiple" || !!((x = S.customCardPreferences) != null && x.dataInputCardIds);
1737
+ }) && I.frame.cards.length > 1 && c({ code: "card_not_editable", message: "This card is an input of a custom visual; remove it in the editor.", path: `${l}.cardId`, fix: "Tell the user to remove it in the editor.", details: { reason: "custom" } }), I.frame.visualId && I.frame.cards.length > 1 && d.push({
1738
+ code: "detaches_linked_visual",
1739
+ message: `Removing "${I.card.title}" makes the rest of its tile local to this dashboard; it stops following its library visual.`,
1740
+ path: l,
1741
+ details: { cardIds: I.frame.cards.filter((S) => S.id !== u).map((S) => S.id) }
1742
+ }), m({ op: "card.remove", cardId: u, changeIndex: h }, l), n.push({ ref: r.cardId, kind: "card", id: u, title: I.card.title ?? "", changeIndex: h });
1743
+ break;
1744
+ }
1745
+ case "filter.add": {
1746
+ const u = await a.loadCardSource({ domainId: r.domainId, datasetName: r.datasetName });
1747
+ u || c({ code: "field_not_found", message: `The dataset "${r.datasetName}" isn't available in this domain.`, path: `${l}.datasetName`, fix: "Find datasets with semaphor_list_datasets." });
1748
+ const I = It(u.fields, r.field, r.datasetName);
1749
+ I || c({
1750
+ code: "field_not_found",
1751
+ message: `"${r.field}" isn't a field of ${r.datasetName}.`,
1752
+ path: `${l}.field`,
1753
+ fix: "Use one of details.available, or read semaphor_get_dataset_schema.",
1754
+ details: { available: u.fields.slice(0, 20).map((v) => v.name) }
1755
+ });
1756
+ const T = pt(r.sheetIds, l, $), S = Ot({
1757
+ field: I,
1758
+ dataSource: u.dataSource,
1759
+ connectionId: u.connectionId,
1760
+ connectionType: u.connectionType,
1761
+ scope: T,
1762
+ existingInputs: Array.isArray(g.inputs) ? g.inputs : [],
1763
+ createId: a.newId,
1764
+ label: r.label
1765
+ }), k = { ...S.filter };
1766
+ k.dateSelectionMode || (k.type = r.selection ?? "multiple"), r.defaultValues && (k.defaultValues = r.defaultValues), r.defaultPeriod && (k.defaultDateFilter = mt(r.defaultPeriod, I, `${l}.defaultPeriod`, c)), m({ op: "filter.add", input: { ...S, filter: k }, changeIndex: h }, l), j.set(S.id, { sheetIds: r.sheetIds ?? "all", changeIndex: h }), (r.defaultValues !== void 0 || r.defaultPeriod !== void 0) && M.set(S.id, { values: r.defaultValues, period: r.defaultPeriod, changeIndex: h });
1767
+ const x = r.handle;
1768
+ x && (y.has(x) && c({ code: "invalid_change", message: `The handle ${x} is defined twice.`, path: `${l}.handle`, fix: "Give each new card or filter its own handle." }), y.set(x, { kind: "filter", id: S.id, title: r.label })), n.push({ ref: x ?? S.id, kind: "filter", id: S.id, title: r.label, changeIndex: h });
1769
+ break;
1770
+ }
1771
+ case "filter.update": {
1772
+ const u = b(r.filterId, `${l}.filterId`), I = he(g, u);
1773
+ I != null && I.editable || c({
1774
+ code: "filter_not_editable",
1775
+ message: I && !I.editable ? I.notEditable.message : "This filter can't be changed through the MCP.",
1776
+ path: `${l}.filterId`,
1777
+ fix: "Tell the user to change it in the editor; removing or excluding it works."
1778
+ });
1779
+ const T = (g.inputs ?? []).find((v) => v.id === u);
1780
+ if ((T == null ? void 0 : T.kind) !== "filter" || !T.filter) throw new ue();
1781
+ const S = { ...T.filter };
1782
+ let k = !1;
1783
+ r.selection && (S.type = r.selection), r.defaultValues !== void 0 && (k = !0, r.defaultValues === null ? delete S.defaultValues : S.defaultValues = r.defaultValues), r.defaultPeriod !== void 0 && (k = !0, r.defaultPeriod === null ? delete S.defaultDateFilter : S.defaultDateFilter = mt(
1784
+ r.defaultPeriod,
1785
+ { dataType: S.dataType },
1786
+ `${l}.defaultPeriod`,
1787
+ c
1788
+ ));
1789
+ const x = {
1790
+ ...r.label !== void 0 ? { label: r.label } : {},
1791
+ ...r.selection !== void 0 || k ? { definition: S } : {},
1792
+ // A change of sheets states the sheets; what else the scope says (the cards it leaves out,
1793
+ // whether it covers Document sheets) stays.
1794
+ ...r.sheetIds !== void 0 ? { scope: aa(
1795
+ T.scope,
1796
+ pt(r.sheetIds ?? void 0, l, $),
1797
+ new Set([...Me(g).values()].filter((v) => v.sheetKind === "document").map((v) => v.sheetId))
1798
+ ) } : {},
1799
+ ...k ? { values: { defaultChanged: !0, target: {} } } : {}
1800
+ };
1801
+ m({ op: "filter.update", filterId: u, settings: x, changeIndex: h }, l), r.sheetIds !== void 0 && j.set(u, { sheetIds: r.sheetIds ?? "all", changeIndex: h }), k && M.set(u, { values: r.defaultValues, period: r.defaultPeriod, changeIndex: h }), n.push({ ref: r.filterId, kind: "filter", id: u, title: T.label, changeIndex: h });
1802
+ break;
1803
+ }
1804
+ case "filter.remove": {
1805
+ const u = b(r.filterId, `${l}.filterId`), I = ((Ke = (g.inputs ?? []).find((T) => T.id === u)) == null ? void 0 : Ke.label) ?? "";
1806
+ m({ op: "filter.remove", filterId: u, changeIndex: h }, l), n.push({ ref: r.filterId, kind: "filter", id: u, title: I, changeIndex: h });
1807
+ break;
1808
+ }
1809
+ case "filter.bind": {
1810
+ const u = b(r.filterId, `${l}.filterId`), I = he(g, u);
1811
+ I != null && I.editable || c({
1812
+ code: "filter_not_editable",
1813
+ message: I && !I.editable ? I.notEditable.message : "This filter can't be changed through the MCP.",
1814
+ path: `${l}.filterId`,
1815
+ fix: "Tell the user to change it in the editor; removing or excluding it works."
1816
+ });
1817
+ const T = f(r.cardId, `${l}.cardId`), S = re(g).find((x) => x.cardId === T).card, k = await Ps(S, r.field, a, `${l}.field`, c);
1818
+ m({ op: "filter.bind", filterId: u, cardId: T, binding: { kind: "bound", cardId: T, bindingId: a.newId(), target: k }, changeIndex: h }, l), n.push({ ref: r.filterId, kind: "filter", id: u, title: I.label, changeIndex: h });
1819
+ break;
1820
+ }
1821
+ case "layout.arrange": {
1822
+ const u = r.sheetId ? $(r.sheetId, `${l}.sheetId`) : (() => {
1823
+ const I = A();
1824
+ return I.length !== 1 && c({
1825
+ code: I.length ? "sheet_required" : "sheet_not_a_grid",
1826
+ message: I.length ? "This dashboard has several grid sheets; say which one to arrange." : "This dashboard has no grid sheet to arrange.",
1827
+ path: `${l}.sheetId`,
1828
+ fix: I.length ? "Send sheetId: one of details.sheets." : "Add a grid sheet in the editor first.",
1829
+ details: { sheets: D() }
1830
+ }), I[0];
1831
+ })();
1832
+ m({ op: "layout.arrange", sheetId: u.id, ...r.keepOrder ? { keepOrder: !0 } : {}, changeIndex: h }, l);
1833
+ break;
1834
+ }
1835
+ case "filter.exclude": {
1836
+ const u = b(r.filterId, `${l}.filterId`), I = f(r.cardId, `${l}.cardId`), T = ((We = (g.inputs ?? []).find((S) => S.id === u)) == null ? void 0 : We.label) ?? "";
1837
+ m({ op: "filter.exclude", filterId: u, cardId: I, changeIndex: h }, l), n.push({ ref: r.filterId, kind: "filter", id: u, title: T, changeIndex: h });
1838
+ break;
1839
+ }
1840
+ }
1841
+ } catch (u) {
1842
+ if (!(u instanceof ue)) throw u;
1843
+ }
1844
+ }
1845
+ if (s.length) return { ok: !1, problems: s };
1846
+ const E = st(e, i, _);
1847
+ if (!E.ok)
1848
+ return {
1849
+ ok: !1,
1850
+ problems: [
1851
+ {
1852
+ code: "invalid_change",
1853
+ message: E.failedAt.message,
1854
+ path: `changes[${((He = i[E.failedAt.index]) == null ? void 0 : He.changeIndex) ?? 0}]`,
1855
+ fix: "Read the outline again and propose again."
1856
+ }
1857
+ ]
1858
+ };
1859
+ for (const h of p) {
1860
+ const r = ie(E.dashboard, h);
1861
+ if (!r) continue;
1862
+ const l = ((Ye = i.find((S) => ze(S) === h)) == null ? void 0 : Ye.changeIndex) ?? 0, u = oe(r.card, { sql: !0 }), I = Ee(r.card.type);
1863
+ u.editable && ("sql" in u.query ? !!u.query.sql : "measures" in u.query ? u.query.measures.length > 0 : u.query.columns.length > 0) && ((Xe = ce[I]) == null ? void 0 : Xe.forms.includes(we(u.query))) || s.push({
1864
+ code: "type_not_supported",
1865
+ message: `As changed, "${r.card.title}" would have no query a ${I.replace(/_/g, " ")} can run.`,
1866
+ path: `changes[${l}]`,
1867
+ fix: `Send a complete query with the type change: ${((Je = ce[I]) == null ? void 0 : Je.forms.map((S) => Se[S]).join(" or ")) ?? "a measures query"}.`
1868
+ });
1869
+ }
1870
+ if (s.push(...Os(e, E.dashboard, i, j)), s.push(...Ns(E.dashboard, M, a.calendar)), s.length) return { ok: !1, problems: s };
1871
+ for (const h of i) {
1872
+ if (h.op !== "filter.add" && !(h.op === "filter.update" && h.settings.scope)) continue;
1873
+ const r = h.op === "filter.add" ? h.input.id : h.filterId, l = he(E.dashboard, r);
1874
+ if (!(l != null && l.editable) || !l.notReached.length) continue;
1875
+ const u = [];
1876
+ for (const I of l.notReached) {
1877
+ const T = I.datasetName ? await a.findRelationshipFields({
1878
+ domainId: l.domainId,
1879
+ fromDataset: l.datasetName,
1880
+ field: l.field,
1881
+ toDataset: I.datasetName
1882
+ }) : [];
1883
+ u.push({ ...I, suggestedFields: T });
1884
+ }
1885
+ d.push({
1886
+ code: "filter_not_reaching_cards",
1887
+ message: `"${l.label}" doesn't reach ${u.length} card${u.length === 1 ? "" : "s"} on its sheets: ${u.map((I) => `"${I.title}"`).join(", ")}.`,
1888
+ path: `changes[${h.changeIndex ?? 0}]`,
1889
+ fix: "Add filter.bind with one of the suggested fields to reach a card, or leave it unfiltered.",
1890
+ details: { cards: u }
1891
+ });
1892
+ }
1893
+ const Y = As(E.dashboard, i, E.descriptions);
1894
+ return {
1895
+ ok: !0,
1896
+ operations: i,
1897
+ context: _,
1898
+ dashboard: E.dashboard,
1899
+ refs: n,
1900
+ descriptions: Y,
1901
+ changedCardIds: p,
1902
+ requires: [...o],
1903
+ warnings: d
1904
+ };
1905
+ }
1906
+ function As(e, t, a) {
1907
+ const s = t.filter((o) => o.op === "card.add");
1908
+ if (!s.length) return [...a];
1909
+ const d = Ft(e);
1910
+ if (!d.length) return [...a];
1911
+ const i = (o) => ga(o.map((p) => `"${p}"`)), n = /* @__PURE__ */ new Map();
1912
+ for (const o of s) {
1913
+ const p = ze(o);
1914
+ if (!p || o.changeIndex === void 0) continue;
1915
+ const y = d.filter((C) => C.reaches.includes(p)).map((C) => C.label), _ = d.filter((C) => {
1916
+ var w;
1917
+ return "notReached" in C && ((w = C.notReached) == null ? void 0 : w.some((c) => c.cardId === p));
1918
+ }).map((C) => C.label), g = [
1919
+ ...y.length ? [`The dashboard's ${i(y)} filter${y.length === 1 ? " applies" : "s apply"} to it.`] : [],
1920
+ ..._.length ? [`${i(_)} ${_.length === 1 ? "doesn't" : "don't"} reach it.`] : []
1921
+ ];
1922
+ g.length && n.set(o.changeIndex, g.join(" "));
1923
+ }
1924
+ return a.map((o) => {
1925
+ const p = o.changeIndex === void 0 ? void 0 : n.get(o.changeIndex);
1926
+ return p ? { ...o, sentence: `${o.sentence} ${p}` } : o;
1927
+ });
1928
+ }
1929
+ function ze(e) {
1930
+ var t;
1931
+ if (e.op === "card.update" || e.op === "card.remove") return e.cardId;
1932
+ if (e.op === "card.add") return (t = e.frame.cards[0]) == null ? void 0 : t.id;
1933
+ }
1934
+ function Rs(e) {
1935
+ return Object.fromEntries(
1936
+ ba.flatMap((t) => e[t] === void 0 ? [] : [[t, e[t]]])
1937
+ );
1938
+ }
1939
+ function Es(e, t) {
1940
+ if (!t.length || !e.config) return e;
1941
+ const a = { ...e.config }, s = [];
1942
+ if (a.matrix) {
1943
+ const i = a.matrix, n = Sa(i), o = [...i.spec.rows, ...i.spec.columns], p = { ...i.presentation.levelLabels }, y = { ...i.presentation.measureLabels };
1944
+ for (const { key: _, label: g } of t) {
1945
+ if (_.role === "metric") {
1946
+ const C = n.measures.findIndex((w) => $e(w, _));
1947
+ if (C < 0) continue;
1948
+ y[i.spec.measures[C].id] = g;
1949
+ } else {
1950
+ const C = n.levels.findIndex((w) => $e(w, _));
1951
+ if (C < 0) continue;
1952
+ p[o[C].id] = g;
1953
+ }
1954
+ s.push(_);
1955
+ }
1956
+ return a.matrix = { ...i, presentation: { ...i.presentation, levelLabels: p, measureLabels: y } }, { ...e, config: a, statedLabels: s };
1957
+ }
1958
+ const d = { metric: "metricColumns", group_by: "groupByColumns", detail: "detailColumns" };
1959
+ for (const { key: i, label: n } of t) {
1960
+ const o = [...a[d[i.role]] ?? []], p = va(i.role, o).findIndex((y) => $e(y, i));
1961
+ p < 0 || (o[p] = Ma(o[p], n), a[d[i.role]] = o, s.push(i));
1962
+ }
1963
+ return { ...e, config: a, statedLabels: s };
1964
+ }
1965
+ function Os(e, t, a, s) {
1966
+ var R;
1967
+ const d = [], i = new Map(re(t).map((m) => [m.cardId, m])), n = Me(t), o = de(t), p = (m) => {
1968
+ var f, b;
1969
+ return ((b = (f = t.sheets) == null ? void 0 : f.find((A) => A.id === m)) == null ? void 0 : b.title) ?? m;
1970
+ }, y = (m, f) => {
1971
+ var b;
1972
+ return ((b = [...a].reverse().find((A) => ze(A) === f || "filterId" in A && A.filterId === m)) == null ? void 0 : b.changeIndex) ?? 0;
1973
+ }, _ = (m, f) => {
1974
+ const b = o.findFilterInput({ inputId: m }).input, A = i.get(f), D = `"${A.card.title ?? ""}"`, $ = `"${b.label}"`;
1975
+ if (A.kind === "documentSectionCard")
1976
+ return {
1977
+ reason: "document_section",
1978
+ message: `${D} is in a Document section, which takes only the filters its Document sheet shows.`,
1979
+ fix: "Tell the user to change where the filter shows in the editor."
1980
+ };
1981
+ const U = n.get(A.sheetId);
1982
+ if (U && !bt(b, U))
1983
+ return {
1984
+ reason: "outside_sheets",
1985
+ message: `${$} isn't shown on "${p(A.sheetId)}", so it can't filter ${D}.`,
1986
+ fix: "Show it on that sheet first with filter.update sheetIds (null for every sheet), in the same proposal."
1987
+ };
1988
+ switch (Oa(b, A.card).status) {
1989
+ case "incompatible":
1990
+ return { reason: "incompatible_field", message: `${D} can't take ${$}'s values on that field: their types differ.`, fix: "Bind a field of the same type (filter.bind)." };
1991
+ case "stale":
1992
+ return {
1993
+ reason: "field_not_on_card",
1994
+ message: `${D} doesn't have the field ${$} is bound to.`,
1995
+ fix: "Bind a field the card has (filter.bind), or exclude the card (filter.exclude), in the same proposal."
1996
+ };
1997
+ case "ambiguous":
1998
+ return {
1999
+ reason: "ambiguous_field",
2000
+ message: `${D} has more than one field ${$} could filter.`,
2001
+ fix: "Bind the field it should use (filter.bind), or exclude the card (filter.exclude), in the same proposal."
2002
+ };
2003
+ default:
2004
+ return { reason: "filter_settings_override", message: `${$} still wouldn't filter ${D}: its settings leave that card out.`, fix: "Tell the user to change the filter's settings in the editor." };
2005
+ }
2006
+ }, g = /* @__PURE__ */ new Set(), C = /* @__PURE__ */ new Map();
2007
+ for (const m of a)
2008
+ (m.op === "filter.bind" || m.op === "filter.exclude") && C.set(`${m.filterId}|${m.cardId}`, m);
2009
+ for (const m of C.values()) {
2010
+ const f = he(t, m.filterId), b = i.get(m.cardId);
2011
+ if (!f || !b) continue;
2012
+ const A = f.reaches.includes(m.cardId);
2013
+ if (m.op === "filter.bind" ? A : !A) continue;
2014
+ g.add(`${m.filterId}|${m.cardId}`);
2015
+ const D = m.op === "filter.bind" ? _(m.filterId, m.cardId) : { reason: "filter_settings_override", message: `"${f.label}" would still filter "${b.card.title ?? ""}".`, fix: "Tell the user to change the filter's settings in the editor." };
2016
+ d.push({
2017
+ code: "filter_not_editable",
2018
+ message: D.message,
2019
+ path: `changes[${m.changeIndex ?? 0}]`,
2020
+ fix: D.fix,
2021
+ details: { reason: D.reason, cardId: m.cardId }
2022
+ });
2023
+ }
2024
+ for (const [m, f] of s) {
2025
+ const b = he(t, m);
2026
+ if (!b) continue;
2027
+ const A = b.editable && ((R = b.exceptSheetIds) == null ? void 0 : R.some((U) => {
2028
+ var F;
2029
+ return ((F = n.get(U)) == null ? void 0 : F.sheetKind) === "dashboard";
2030
+ })), D = b.editable && !A ? b.sheetIds : void 0, $ = f.sheetIds === "all" ? "all" : [...f.sheetIds].sort();
2031
+ Le(D === "all" || !D ? D : [...D].sort(), $) || d.push({
2032
+ code: "filter_not_editable",
2033
+ message: `"${b.label}" wouldn't show on the sheets asked for. Change where it shows in the editor.`,
2034
+ path: `changes[${f.changeIndex}].sheetIds`,
2035
+ fix: "Tell the user to change the filter's sheets in the editor.",
2036
+ details: { reason: "filter_settings_override", ...D ? { sheetIds: D } : {} }
2037
+ });
2038
+ }
2039
+ const w = de(e), c = (m) => m === "blocked" || m === "ambiguous";
2040
+ for (const m of o.inputs) {
2041
+ const f = m.input.id;
2042
+ for (const b of o.reachedCards({ inputId: f })) {
2043
+ if (g.has(`${f}|${b.cardId}`) || !c(Oe(m.input, b.card))) continue;
2044
+ const A = w.findFilterInput({ inputId: f }), D = A && w.reachedCards({ inputId: f }).find((U) => U.cardId === b.cardId);
2045
+ if (A && D && c(Oe(A.input, D.card))) continue;
2046
+ const $ = _(f, b.cardId);
2047
+ d.push({
2048
+ code: "invalid_change",
2049
+ message: `${$.message} The card would stop showing data while "${m.input.label}" has a value.`,
2050
+ path: `changes[${y(f, b.cardId)}]`,
2051
+ fix: $.fix,
2052
+ details: { reason: $.reason, filterId: f, cardId: b.cardId }
2053
+ });
2054
+ }
2055
+ }
2056
+ return d;
2057
+ }
2058
+ function Ns(e, t, a) {
2059
+ const s = [], d = de(e);
2060
+ for (const [i, n] of t) {
2061
+ const o = d.findFilterInput({ inputId: i });
2062
+ if (!o) continue;
2063
+ const p = gt({ dashboard: e, target: { kind: "dashboardInput", input: o.input, scope: {} }, calendar: a }).value, y = o.input.filter.dateSelectionMode, _ = y === "day" ? "its date picker takes one day" : void 0, g = (C, w) => s.push({
2064
+ code: "filter_not_editable",
2065
+ message: C,
2066
+ path: `changes[${n.changeIndex}]`,
2067
+ fix: w,
2068
+ details: { reason: "default_not_applied", ...y ? { datePicker: y } : {} }
2069
+ });
2070
+ if (n.period) {
2071
+ const C = Ct(n.period), w = p && "relativeMeta" in p ? p.relativeMeta : void 0;
2072
+ (!w || !Le(w, C)) && g(
2073
+ `"${o.input.label}" wouldn't load with that default${_ ? `: ${_}` : ""}.`,
2074
+ _ ? "Ask for a default the picker can take, or tell the user to make it a date range in the editor." : "Tell the user to change the filter's default in the editor."
2075
+ );
2076
+ } else if (n.values) {
2077
+ const C = (w) => JSON.stringify((w ?? []).map(String).sort());
2078
+ (!p || C(p.values) !== C(n.values)) && g(`"${o.input.label}" wouldn't load with those values.`, "Tell the user to change the filter's default in the editor.");
2079
+ } else
2080
+ (_t(o.input.filter.dataType) ? n.period === null : n.values === null) && p && g(`"${o.input.label}" would still load with a default.`, "Tell the user to change the filter's default in the editor.");
2081
+ }
2082
+ return s;
2083
+ }
2084
+ function qs(e, t, a, s) {
2085
+ const d = Object.fromEntries(Object.entries(t).filter(([, _]) => _ != null)), i = we(d), n = we(e), o = (_) => ht[_].safeParse(d);
2086
+ if (!e || i && i !== n) {
2087
+ const _ = i ?? n, g = _ ? o(_) : void 0;
2088
+ return g != null && g.success ? g.data : s({
2089
+ code: e ? "query_form_mismatch" : "type_not_supported",
2090
+ message: e ? "This patch changes the query's form (measures, records or SQL) without a complete query." : "This card's current query can't be patched; send a complete query.",
2091
+ path: a,
2092
+ fix: "Send a complete query of the new form: domainId, datasetName and measures (or columns), or connectionId and sql."
2093
+ });
2094
+ }
2095
+ const p = { ...e };
2096
+ for (const [_, g] of Object.entries(t))
2097
+ g !== void 0 && (g === null ? delete p[_] : p[_] = g);
2098
+ const y = ht[n].safeParse(p);
2099
+ if (!y.success) {
2100
+ const _ = y.error.issues[0];
2101
+ return s({
2102
+ code: (_ == null ? void 0 : _.code) === "unrecognized_keys" ? "query_form_mismatch" : "invalid_change",
2103
+ message: (_ == null ? void 0 : _.message) ?? "The merged query is not valid.",
2104
+ path: _ ? At(a, _) : a,
2105
+ fix: "Patch only keys of the card's query form, or send a complete query of a new form."
2106
+ });
2107
+ }
2108
+ return y.data;
2109
+ }
2110
+ function pt(e, t, a) {
2111
+ return e ? (e.forEach((s, d) => a(s, `${t}.sheetIds[${d}]`)), { kind: "sheets", sheetIds: [...e] }) : { kind: "allSheets", sheetKinds: ["dashboard"] };
2112
+ }
2113
+ function mt(e, t, a, s) {
2114
+ ["date", "datetime", "timestamp"].some((n) => Pe(t.dataType).includes(n)) || s({ code: "invalid_change", message: "defaultPeriod is for date filters.", path: a, fix: "Use defaultValues for this field." });
2115
+ const i = Ct(e);
2116
+ if (!i) {
2117
+ const n = "anchor" in e && e.anchor === "latest_available";
2118
+ if (!n && $a(e)) {
2119
+ const o = e.unit;
2120
+ return s({
2121
+ code: "invalid_change",
2122
+ message: `A filter's default can't count a partial ${o} back from now; its presets are whole days with today, complete ${o}s, or a calendar ${o}.`,
2123
+ path: a,
2124
+ fix: `Use completeness "complete_periods", days ({ unit: "day", value: N }), or { kind: "calendar", unit: "${o}", period: "this", toDate: true }; ask the user which they mean.`
2125
+ });
2126
+ }
2127
+ return s({
2128
+ code: "invalid_change",
2129
+ message: n ? "A filter's default runs to now, not to the latest available data." : "This period can't be a filter's default.",
2130
+ path: a,
2131
+ fix: n ? "Leave out anchor (a filter default runs to now)." : 'Use days ({ unit: "day", value: N }), complete periods, or a calendar window ({ kind: "calendar", unit, period }).'
2132
+ });
2133
+ }
2134
+ return i;
2135
+ }
2136
+ async function Ps(e, t, a, s, d) {
2137
+ const i = la(e), n = i.kind === "config" ? i.executableSources : i.kind === "sql" ? i.pinnedCatalogSources.map((c) => c.source) : [], o = ve(e), p = typeof t == "string" ? (o == null ? void 0 : o.kind) === "semantic" ? o.datasetName : void 0 : t.datasetName, y = n.find((c) => c.kind === "semantic" && Pe(c.datasetName) === Pe(p));
2138
+ if (!y || y.kind !== "semantic")
2139
+ return d({
2140
+ code: "field_not_found",
2141
+ message: `"${e.title}" doesn't read ${p ? `the dataset ${p}` : "a dataset"}.`,
2142
+ path: s,
2143
+ fix: "Name a field of the card's own dataset, or { name, datasetName } for a dataset its query joins."
2144
+ });
2145
+ const _ = await a.loadCardSource({ domainId: y.domainId, datasetName: y.datasetName }), g = typeof t == "string" ? t : t.name, C = _ ? It(_.fields, g, y.datasetName) : void 0, w = C ? qt(y, { column_name: C.name, data_type: C.dataType, ...C.sourceField ? { sourceField: C.sourceField } : {} }) : void 0;
2146
+ return w || d({
2147
+ code: "field_not_found",
2148
+ message: `"${g}" isn't a field of ${y.datasetName}.`,
2149
+ path: s,
2150
+ fix: "Use one of details.available, or read semaphor_get_dataset_schema.",
2151
+ details: { available: ((_ == null ? void 0 : _.fields) ?? []).slice(0, 20).map((c) => c.name) }
2152
+ });
2153
+ }
2154
+ const Ms = 50;
2155
+ function pi(e, t) {
2156
+ var C, w;
2157
+ const a = (C = t.sheetIds) != null && C.length ? new Set(t.sheetIds) : void 0, s = (w = t.cardIds) != null && w.length ? new Set(t.cardIds) : void 0, d = (e.sheets ?? []).filter((c) => !a || a.has(c.id)), i = re(e).filter(
2158
+ (c) => (!a || a.has(c.sheetId)) && (!s || s.has(c.cardId))
2159
+ ), n = i.length > (t.maxQueryCards ?? Ms), o = new Map(
2160
+ (e.sheets ?? []).flatMap((c) => (c.frames ?? []).map((R) => [R.id, R]))
2161
+ ), p = /* @__PURE__ */ new Map(), y = (c) => {
2162
+ (c == null ? void 0 : c.kind) === "semantic" && p.set(`${c.domainId}|${c.datasetName}`, { domainId: c.domainId, datasetName: c.datasetName });
2163
+ }, _ = d.map((c) => ({
2164
+ sheetId: c.id,
2165
+ title: c.title ?? "",
2166
+ kind: c.kind === "document" ? "document" : "dashboard",
2167
+ ...c.kind === "document" ? {} : { layout: Ls(c) },
2168
+ cards: i.filter((R) => R.sheetId === c.id).map((R) => {
2169
+ var $;
2170
+ const m = R.card, f = R.kind === "frameCard" ? ($ = o.get(R.frameId)) == null ? void 0 : $.visualId : void 0, b = f ? { linkedVisualId: f } : {}, A = { cardId: R.cardId, title: m.title ?? "" };
2171
+ if (R.kind !== "frameCard") {
2172
+ const U = ve(m);
2173
+ return y(U), {
2174
+ ...A,
2175
+ type: Ee(m.type),
2176
+ ...U ? { source: U } : {},
2177
+ editable: !1,
2178
+ notEditable: R.kind === "documentSectionCard" ? { reason: "document_section", message: "Cards in Document sections can't be changed through the MCP yet. Change them in the editor." } : {
2179
+ reason: "not_expressible",
2180
+ message: "This card isn't in a tile, so it can't be changed through the MCP. Change it in the editor.",
2181
+ detail: "a card outside a tile"
2182
+ }
2183
+ };
2184
+ }
2185
+ const D = oe(m, { sql: t.sql });
2186
+ return y(D.source), D.editable ? {
2187
+ ...A,
2188
+ type: D.type,
2189
+ source: D.source,
2190
+ ...b,
2191
+ editable: !0,
2192
+ ...n ? {} : { query: D.query, ...D.matrix ? { matrix: D.matrix } : {} }
2193
+ } : {
2194
+ ...A,
2195
+ type: D.type,
2196
+ ...D.source ? { source: D.source } : {},
2197
+ ...b,
2198
+ editable: !1,
2199
+ notEditable: { reason: D.reason, message: D.message, ...D.detail ? { detail: D.detail } : {} }
2200
+ };
2201
+ })
2202
+ })), g = Ft(e, kt(t.calendar, t.updatedAt));
2203
+ for (const c of g)
2204
+ c.editable && p.set(`${c.domainId}|${c.datasetName}`, { domainId: c.domainId, datasetName: c.datasetName });
2205
+ return {
2206
+ dashboardId: t.dashboardId,
2207
+ title: e.title ?? "",
2208
+ updatedAt: t.updatedAt,
2209
+ access: t.access,
2210
+ datasets: [...p.values()],
2211
+ sheets: _,
2212
+ filters: g,
2213
+ ...n ? { truncated: !0 } : {}
1687
2214
  };
1688
2215
  }
2216
+ function Ls(e) {
2217
+ const t = new Map((e.frames ?? []).map((a) => [a.id, a]));
2218
+ return Aa(e).rows.map((a) => ({
2219
+ tiles: a.tiles.map((s) => {
2220
+ var o, p;
2221
+ const d = ((o = t.get(s.frameId)) == null ? void 0 : o.cards) ?? [], i = (p = t.get(s.frameId)) == null ? void 0 : p.activeCardId, n = d.map((y) => y.id);
2222
+ return { cardIds: i && n.includes(i) ? [i, ...n.filter((y) => y !== i)] : n, width: s.width };
2223
+ })
2224
+ }));
2225
+ }
1689
2226
  export {
1690
- Aa as AUTOMATIC_TEMPORAL_BUCKET_FORMAT,
1691
- na as CARD_QUERY_REQUEST_DESCRIPTIVE_FIELDS,
1692
- ra as CARD_QUERY_REQUEST_EXECUTED_FIELDS,
1693
- Oa as CONTROL_BINDING_MAPPING_MISSING_ERROR_CODE,
1694
- Ra as CONTROL_BINDING_TARGET_INVALID_ERROR_CODE,
1695
- Ea as CONTROL_BINDING_VALUE_INVALID_ERROR_CODE,
1696
- Na as CONTROL_CONTEXT_UNSUPPORTED_ERROR_CODE,
1697
- Ma as CONTROL_DEFINITION_DUPLICATE_ERROR_CODE,
1698
- Pa as CONTROL_DEFINITION_INVALID_ERROR_CODE,
1699
- $a as CONTROL_PLACEHOLDER_QUOTED_ERROR_CODE,
1700
- Ba as CONTROL_REFERENCE_MISSING_ERROR_CODE,
1701
- La as CONTROL_VALUE_INVALID_ERROR_CODE,
1702
- qa as CONTROL_VALUE_MISSING_ERROR_CODE,
1703
- D as CardQueryRequestError,
1704
- Va as ControlResolutionError,
1705
- xe as DASHBOARD_AUTHORING_BREAKPOINTS,
1706
- L as DASHBOARD_AUTHORING_MAX_GENERATED_CARDS,
1707
- Rr as DASHBOARD_DEFAULT_OPTION_DEPENDENCIES,
1708
- un as DASHBOARD_FILTER_OPERATIONS,
1709
- rn as DOCUMENT_KPI_SECTION_MAX_CARDS,
1710
- nn as DOCUMENT_KPI_SECTION_MAX_TILES,
1711
- Er as DashboardFilterMappingContractError,
1712
- za as ExecutionControlContractError,
1713
- ca as NEW_CARD_TYPE,
1714
- ja as SEMAPHOR_CARTESIAN_CHART_TYPES,
1715
- la as applyCardReferenceRemapping,
1716
- ta as applyDashboardChangePlan,
1717
- ua as applyDashboardOperations,
1718
- Nr as applyGroupByOverride,
1719
- fa as applyLinkedClickToFilterOverrides,
1720
- Mr as applyOptionDependencyOverride,
1721
- pa as buildCardExportFormatOptions,
1722
- Pr as buildCardExportQueryContext,
1723
- ma as buildCardExportRequest,
1724
- ha as buildCardExportRequestFromOptions,
1725
- Ua as buildControlDefinitionIndex,
1726
- Ga as buildDashboardCardSourceIndex,
1727
- ga as buildLinkedClickToFilterOverrides,
1728
- ba as buildTableExportFormatOptions,
1729
- ke as clickToFilterSettingsSchema,
1730
- ea as compileDashboardFromPlan,
1731
- Z as compileResponsiveDashboardLayouts,
1732
- Ia as composeCardReferenceRemapping,
1733
- Ha as controlBindingExecutionSchema,
1734
- Wa as controlDefinitionExecutionSchema,
1735
- $r as createDashboardFilterBindingId,
1736
- gn as createMatrixAuthoringDraft,
1737
- bn as createMatrixConfig,
1738
- Ca as createNewCard,
1739
- J as dashboardAuthoringDatasetMatchesSource,
1740
- Jt as dashboardAuthoringFieldsReferToSameTarget,
1741
- v as dashboardAuthoringSourceFromField,
1742
- Xt as dashboardAuthoringSourceKey,
1743
- pe as dashboardAuthoringSourcesReferToSameDataset,
1744
- Ka as dashboardCardFilterSourceInventoryContains,
1745
- Br as dashboardFilterTargetMatchesLogicalValue,
1746
- fn as dashboardFilterValueTypeForDataType,
1747
- aa as dashboardPlanFromSemaphorDashboardIntent,
1748
- Qa as defaultClickToFilterSettings,
1749
- Zt as findDashboardAuthoringDatasetForSource,
1750
- Xa as findDashboardCardExecutableSource,
1751
- Ya as findDashboardCardPinnedCatalogSource,
1752
- Ja as findDashboardSqlPinnedCatalogSource,
1753
- Re as formatResolvedPrimaryDateFieldIssues,
1754
- ya as getCalculatedFieldAggregateOverrides,
1755
- Za as getCalculatedFieldNamespace,
1756
- _a as getCalculatedFieldParameters,
1757
- Da as getCalculatedFieldShelfOverrides,
1758
- er as getColumnCatalogFieldId,
1759
- Je as getDashboardAuthoringCardSource,
1760
- Sa as getDashboardFilterSubscriptionHint,
1761
- on as getDocumentKpiSectionShapeIssues,
1762
- sn as getDocumentSectionCards,
1763
- va as getDomainCalculatedSelectionOverrides,
1764
- tr as getFieldAggregationOptions,
1765
- ar as getMatrixBindingTargets,
1766
- In as getMatrixLevelLabel,
1767
- Cn as getMatrixMeasureLabel,
1768
- rr as getStableDomainCalculatedFieldId,
1769
- nr as getTemporalBucketAuthoringOptions,
1770
- ir as getTemporalBucketAuthoringSelection,
1771
- Ta as hasDashboardFilterSubscription,
1772
- pn as isDashboardFilterOperationCompatible,
1773
- R as isMaterializableDashboardAuthoringSource,
1774
- or as isPresentationCurrencyBinding,
1775
- sr as isSemaphorCartesianChartType,
1776
- je as isSemaphorSourceRef,
1777
- dr as isStructuralControlBinding,
1778
- cr as isValidControlOptionPresentation,
1779
- lr as linkedClickToFilterOverridesSchema,
1780
- dn as listDashboardCardLocations,
1781
- cn as mapDocumentSectionCards,
1782
- Lr as matrixCatalogSources,
1783
- Sn as matrixDefinitionFields,
1784
- vn as matrixDefinitionSources,
1785
- qr as matrixExecutionSources,
1786
- q as mergeDashboardAuthoringSources,
1787
- yn as mergeMatrixSorts,
1788
- ur as moveMatrixLevel,
1789
- fr as normalizeClickToFilterSettings,
1790
- Vr as normalizeDashboardInputs,
1791
- wa as normalizeLegacyLinkedTargetOverrides,
1792
- oa as parseCardQueryRequest,
1793
- Bt as parseCardQueryRequestContext,
1794
- ia as parseCardQueryRequestExtras,
1795
- pr as parseExecutionControlBindingsShallow,
1796
- Ne as parseExecutionControlContext,
1797
- mr as parseExecutionControlContract,
1798
- Ue as preferDashboardAuthoringSourceMetadata,
1799
- Yt as preferredDashboardAuthoringSource,
1800
- hr as previewTemporalBucketAuthoringFormat,
1801
- gr as readExactDomainCalculatedFieldReference,
1802
- Tn as readMatrixCardConfig,
1803
- zr as rebindDashboardOptionDependencyInputId,
1804
- br as reconcileMatrixSpecStructure,
1805
- Ir as reconcileTemporalBucketAuthoringFormat,
1806
- H as remapClickToFilterReferences,
1807
- Fa as remapLinkedClickToFilterOverrides,
1808
- jr as requireNormalizedDashboardInputs,
1809
- Cr as resolveBindingControlValue,
1810
- Zr as resolveCanonicalDetailResultRawKey,
1811
- en as resolveCanonicalResultOutputKey,
1812
- tn as resolveCanonicalResultRawKey,
1813
- Ge as resolveDashboardAuthoringSource,
1814
- yr as resolveDashboardEntitySource,
1815
- Ur as resolveDashboardFilterAutomaticTarget,
2227
+ Ni as AGGREGATES,
2228
+ qi as AUTOMATIC_TEMPORAL_BUCKET_FORMAT,
2229
+ Pi as CALCULATED_FIELDS_GROUP_ID,
2230
+ Mi as CALCULATED_FIELDS_GROUP_NAME,
2231
+ Li as CARD_CONFIG_KEY_CLASSES,
2232
+ Bi as CARD_KEY_CLASSES,
2233
+ ba as CARD_QUERY_CONFIG_KEYS,
2234
+ ci as CARD_QUERY_REQUEST_DESCRIPTIVE_FIELDS,
2235
+ li as CARD_QUERY_REQUEST_EXECUTED_FIELDS,
2236
+ Vi as CARD_TYPES,
2237
+ ce as CARD_TYPE_RULES,
2238
+ Gi as COLUMN_KEY_CLASSES,
2239
+ Ui as COLUMN_PRESENTATION_KEYS,
2240
+ ji as CONTROL_BINDING_MAPPING_MISSING_ERROR_CODE,
2241
+ zi as CONTROL_BINDING_TARGET_INVALID_ERROR_CODE,
2242
+ Qi as CONTROL_BINDING_VALUE_INVALID_ERROR_CODE,
2243
+ Ki as CONTROL_CONTEXT_UNSUPPORTED_ERROR_CODE,
2244
+ Wi as CONTROL_DEFINITION_DUPLICATE_ERROR_CODE,
2245
+ Hi as CONTROL_DEFINITION_INVALID_ERROR_CODE,
2246
+ Yi as CONTROL_PLACEHOLDER_QUOTED_ERROR_CODE,
2247
+ Xi as CONTROL_REFERENCE_MISSING_ERROR_CODE,
2248
+ Ji as CONTROL_VALUE_INVALID_ERROR_CODE,
2249
+ Zi as CONTROL_VALUE_MISSING_ERROR_CODE,
2250
+ W as CardQueryRequestError,
2251
+ en as ControlResolutionError,
2252
+ at as DASHBOARD_AUTHORING_MAX_GENERATED_CARDS,
2253
+ tn as DASHBOARD_CHANGE_OPS,
2254
+ an as DASHBOARD_DEFAULT_OPTION_DEPENDENCIES,
2255
+ ur as DASHBOARD_FILTER_OPERATIONS,
2256
+ sn as DASHBOARD_INPUT_RUNTIME_SCOPE_KINDS,
2257
+ fr as DOCUMENT_KPI_SECTION_MAX_CARDS,
2258
+ hr as DOCUMENT_KPI_SECTION_MAX_TILES,
2259
+ nn as DashboardFilterMappingContractError,
2260
+ on as ExecutionControlContractError,
2261
+ rn as FILTER_OPERATORS,
2262
+ dn as FilterModelError,
2263
+ it as MAX_PROPOSED_CHANGES,
2264
+ ln as MAX_QUERY_LIMIT,
2265
+ bi as NEW_CARD_TYPE,
2266
+ cn as QUERY_ASPECTS,
2267
+ un as QUERY_CONFIG_KEY_ASPECTS,
2268
+ fn as SEMAPHOR_CARTESIAN_CHART_TYPES,
2269
+ hn as TIME_GRAINS,
2270
+ pn as TOOLBAR_FILTER_REACH_FIELDS,
2271
+ mn as analyticsFilterSchema,
2272
+ Cr as applyCardReferenceRemapping,
2273
+ st as applyDashboardOperations,
2274
+ Sr as applyFilterApplicability,
2275
+ Ii as applyFilterSettingsChange,
2276
+ vr as applyGroupByOverride,
2277
+ gn as applyLinkedClickToFilterOverrides,
2278
+ bn as applyOptionDependencyOverride,
2279
+ yi as buildCardExportFormatOptions,
2280
+ xr as buildCardExportQueryContext,
2281
+ _i as buildCardExportRequest,
2282
+ Ci as buildCardExportRequestFromOptions,
2283
+ Si as buildColumnCatalog,
2284
+ In as buildControlDefinitionIndex,
2285
+ la as buildDashboardCardSourceIndex,
2286
+ vi as buildEntityColumnGroup,
2287
+ xi as buildFilterInputFromDefinition,
2288
+ Ot as buildFilterInputFromField,
2289
+ yn as buildLinkedClickToFilterOverrides,
2290
+ _n as buildProposeChangeInputSchema,
2291
+ Cn as buildSavedEditorCard,
2292
+ wi as buildTableExportFormatOptions,
2293
+ Sn as cardQueryPatchSchema,
2294
+ vn as cardTypeSentenceName,
2295
+ Ia as changeCardType,
2296
+ xn as changeMatrixEditor,
2297
+ Pt as clickToFilterSettingsSchema,
2298
+ wr as collectJoinPlanIdentifiers,
2299
+ ea as columnDataset,
2300
+ ya as columnFieldKey,
2301
+ va as columnKeys,
2302
+ ri as compileDashboardFromPlan,
2303
+ Dr as composeCardReferenceRemapping,
2304
+ wn as controlBindingExecutionSchema,
2305
+ Dn as controlDefinitionExecutionSchema,
2306
+ oa as controlRefusal,
2307
+ Tn as createDashboardFilterBindingId,
2308
+ Kr as createMatrixAuthoringDraft,
2309
+ Wr as createMatrixConfig,
2310
+ Nt as createNewCard,
2311
+ Ve as dashboardAuthoringDatasetMatchesSource,
2312
+ ni as dashboardAuthoringFieldsReferToSameTarget,
2313
+ J as dashboardAuthoringSourceFromField,
2314
+ si as dashboardAuthoringSourceKey,
2315
+ St as dashboardAuthoringSourcesReferToSameDataset,
2316
+ kn as dashboardCardFilterSourceInventoryContains,
2317
+ ta as dashboardChangeSchema,
2318
+ Tr as dashboardFilterTargetMatchesLogicalValue,
2319
+ pr as dashboardFilterValueTypeForDataType,
2320
+ $n as dashboardGenerateSchema,
2321
+ Yt as dashboardInputScopeIncludesDocumentSheets,
2322
+ di as dashboardPlanFromSemaphorDashboardIntent,
2323
+ Fn as defaultClickToFilterSettings,
2324
+ Oe as describeDashboardFilterCardReach,
2325
+ na as describeQueryChange,
2326
+ An as doesDashboardInputApplyToTarget,
2327
+ Rn as doesDashboardInputSurviveCarriedContext,
2328
+ En as doesToolbarFilterReachTab,
2329
+ Di as domainCalculatedFields,
2330
+ On as dropMatrixEditorField,
2331
+ Zt as fieldIdentityKey,
2332
+ Nn as fieldRefSchema,
2333
+ kr as filterApplicabilityContextForCard,
2334
+ $r as filterValueReachForCard,
2335
+ It as findCatalogField,
2336
+ oi as findDashboardAuthoringDatasetForSource,
2337
+ qn as findDashboardCardExecutableSource,
2338
+ Pn as findDashboardCardPinnedCatalogSource,
2339
+ Mn as findDashboardSqlPinnedCatalogSource,
2340
+ Jt as findSortedColumn,
2341
+ Ti as flattenEntityColumns,
2342
+ Ln as foldPrototypeDocumentInputs,
2343
+ Bn as formatFilterModelIssues,
2344
+ jt as formatResolvedPrimaryDateFieldIssues,
2345
+ Fr as formatSkippedFilterWarnings,
2346
+ ki as getCalculatedFieldAggregateOverrides,
2347
+ Vn as getCalculatedFieldNamespace,
2348
+ $i as getCalculatedFieldParameters,
2349
+ Fi as getCalculatedFieldShelfOverrides,
2350
+ Gn as getCardDefinition,
2351
+ Un as getColumnCatalogFieldId,
2352
+ Wa as getDashboardAuthoringCardSource,
2353
+ Ai as getDashboardFilterSubscriptionHint,
2354
+ jn as getDashboardGlobalDateFilter,
2355
+ mr as getDocumentKpiSectionShapeIssues,
2356
+ gr as getDocumentSectionCards,
2357
+ Ri as getDomainCalculatedSelectionOverrides,
2358
+ zn as getFieldAggregationOptions,
2359
+ Qn as getMatrixBindingTargets,
2360
+ Hr as getMatrixLevelLabel,
2361
+ Yr as getMatrixMeasureLabel,
2362
+ Kn as getStableDomainCalculatedFieldId,
2363
+ Wn as getTemporalBucketAuthoringOptions,
2364
+ Hn as getTemporalBucketAuthoringSelection,
2365
+ Yn as handleSchema,
2366
+ Ei as hasDashboardFilterSubscription,
2367
+ Xn as hasToolbarFilterReachField,
2368
+ Ar as hostFilterValueFor,
2369
+ Rr as hostFilterValuesToSlots,
2370
+ Er as isAdHocFilterValueOnTab,
2371
+ Jn as isAllowedDashboardInputScopeCombination,
2372
+ Zn as isCardType,
2373
+ br as isDashboardFilterOperationCompatible,
2374
+ bt as isDashboardInputOnTab,
2375
+ eo as isDashboardInputOwnedBySheet,
2376
+ Gt as isDashboardInputScopeEmpty,
2377
+ to as isGroupedDate,
2378
+ ao as isHiddenFilterInput,
2379
+ pe as isMaterializableDashboardAuthoringSource,
2380
+ so as isPresentationCurrencyBinding,
2381
+ io as isSemaphorCartesianChartType,
2382
+ La as isSemaphorSourceRef,
2383
+ no as isStructuralControlBinding,
2384
+ oo as isValidControlOptionPresentation,
2385
+ Xt as labelAt,
2386
+ ro as layoutArrangeSchema,
2387
+ lo as linkedClickToFilterOverridesSchema,
2388
+ Or as listAdHocFilterValuesOnTab,
2389
+ re as listDashboardCardLocations,
2390
+ co as listDashboardFilterDefinitions,
2391
+ uo as listDashboardFilterInputsOnTab,
2392
+ fo as listDashboardInputReachKeys,
2393
+ Kt as listDashboardInputScopeExceptedCardIds,
2394
+ Ht as listDashboardInputScopeExceptedSheetIds,
2395
+ Me as listDashboardTabTargets,
2396
+ Nr as listFilterInputValueTargets,
2397
+ ho as listStoredFilterDefinitions,
2398
+ Ir as mapDocumentSectionCards,
2399
+ po as matchColumns,
2400
+ qr as matrixCatalogSources,
2401
+ Sa as matrixColumnKeys,
2402
+ mo as matrixColumnsSchema,
2403
+ ed as matrixDefinitionFields,
2404
+ td as matrixDefinitionSources,
2405
+ go as matrixEditorCatalogFromFields,
2406
+ Pr as matrixExecutionSources,
2407
+ bo as measureRefSchema,
2408
+ xe as mergeDashboardAuthoringSources,
2409
+ Xr as mergeMatrixSorts,
2410
+ fa as metricCardQuerySchema,
2411
+ Ca as moveMatrixLevel,
2412
+ Io as normalizeClickToFilterSettings,
2413
+ yo as normalizeDashboardInputs,
2414
+ _o as normalizeLegacyLinkedTargetOverrides,
2415
+ Co as occurrenceKeys,
2416
+ kt as outlineCalendar,
2417
+ pi as outlineDashboard,
2418
+ he as outlineFilter,
2419
+ Ft as outlineFilters,
2420
+ fi as parseCardQueryRequest,
2421
+ Ds as parseCardQueryRequestContext,
2422
+ ui as parseCardQueryRequestExtras,
2423
+ So as parseExecutionControlBindingsShallow,
2424
+ Qt as parseExecutionControlContext,
2425
+ vo as parseExecutionControlContract,
2426
+ ra as planCardLabels,
2427
+ rt as planCardRequery,
2428
+ Ba as preferDashboardAuthoringSourceMetadata,
2429
+ ii as preferredDashboardAuthoringSource,
2430
+ Mr as prepareLoadedDashboard,
2431
+ xo as previewTemporalBucketAuthoringFormat,
2432
+ wo as proposedChangeSchema,
2433
+ Lr as pruneUnrelatedCalculatedFilters,
2434
+ da as queryForm,
2435
+ oe as readCardQuery,
2436
+ ve as readCardSource,
2437
+ de as readDashboardFilterModel,
2438
+ Do as readExactDomainCalculatedFieldReference,
2439
+ Br as readFilterValueList,
2440
+ ad as readMatrixCardConfig,
2441
+ To as rebindDashboardOptionDependencyInputId,
2442
+ ot as rebuildsRole,
2443
+ ko as reconcileMatrixSpecStructure,
2444
+ $o as reconcileTemporalBucketAuthoringFormat,
2445
+ ua as recordsCardQuerySchema,
2446
+ Fo as refDataset,
2447
+ ne as refKey,
2448
+ lt as refName,
2449
+ Ao as relationshipAddSchema,
2450
+ Ro as relativeToTimeWindow,
2451
+ Lt as remapClickToFilterReferences,
2452
+ Eo as remapLinkedClickToFilterOverrides,
2453
+ Oo as requireNormalizedDashboardInputs,
2454
+ No as resolveBindingControlValue,
2455
+ rr as resolveCanonicalDetailResultRawKey,
2456
+ dr as resolveCanonicalResultOutputKey,
2457
+ lr as resolveCanonicalResultRawKey,
2458
+ Va as resolveDashboardAuthoringSource,
2459
+ hi as resolveDashboardChanges,
2460
+ qo as resolveDashboardEntitySource,
2461
+ Vr as resolveDashboardFilterAutomaticTarget,
1816
2462
  Gr as resolveDashboardFilterInheritedTarget,
1817
- Hr as resolveDashboardOptionDependencies,
1818
- Wr as resolveDashboardOptionPopulation,
1819
- Kr as resolveDashboardSqlFilterTarget,
1820
- _r as resolveGroupByFieldTarget,
1821
- Qr as resolveMatrixControlBindings,
1822
- _n as resolveMatrixDefinition,
1823
- Dr as resolveMetricFieldTarget,
1824
- Sr as resolveScalarMappedValue,
1825
- vr as resolveTemporalBucketAuthoringFormat,
1826
- Ee as resolveTemporalResultOwner,
1827
- Ae as respondsToSelectionsSchema,
1828
- Tr as retainMatrixConditionalFormatting,
1829
- Xr as selectDashboardOptionDependencyInputIds,
1830
- wr as selectionFieldFromExplorerField,
1831
- xa as stripInstanceTargetsForLibrarySave,
1832
- Fr as supportsCanonicalDashboardTemporalResult,
1833
- xr as transformComparisonDocument,
1834
- kr as updateMatrixConfig,
1835
- Ar as validateControlValue,
1836
- Ze as validateDashboardAuthoringDatasetScope,
1837
- at as validateDashboardChangePlan,
1838
- mn as validateDashboardFilterValues,
1839
- tt as validateDashboardPlan,
1840
- Oe as validateResolvedPrimaryDateFieldShape,
1841
- Yr as withDashboardOptionDependencyOverride
2463
+ Po as resolveDashboardOptionDependencies,
2464
+ Mo as resolveDashboardOptionPopulation,
2465
+ Ur as resolveDashboardSqlFilterTarget,
2466
+ Lo as resolveFieldSelectedSource,
2467
+ Bo as resolveGroupByFieldTarget,
2468
+ jr as resolveMatrixControlBindings,
2469
+ Jr as resolveMatrixDefinition,
2470
+ Vo as resolveMetricFieldTarget,
2471
+ Go as resolveScalarMappedValue,
2472
+ Uo as resolveTemporalBucketAuthoringFormat,
2473
+ zt as resolveTemporalResultOwner,
2474
+ Mt as respondsToSelectionsSchema,
2475
+ jo as retainMatrixConditionalFormatting,
2476
+ Vt as rewriteDashboardInputScopeIds,
2477
+ $e as sameColumnKey,
2478
+ Le as sameValue,
2479
+ zo as selectDashboardOptionDependencyInputIds,
2480
+ Qo as selectionFieldFromExplorerField,
2481
+ Ko as settableCardType,
2482
+ Wo as sharedCardPreferences,
2483
+ ca as sqlCardQuerySchema,
2484
+ Re as statedLabelsOf,
2485
+ Ho as stripInstanceTargetsForLibrarySave,
2486
+ Yo as structuralControlOverride,
2487
+ $t as summarizeFilter,
2488
+ Xo as supportsCanonicalDashboardTemporalResult,
2489
+ Jo as timeWindowSchema,
2490
+ nt as toChartType,
2491
+ Ee as toPublicCardType,
2492
+ Zo as toolbarFilterInputFields,
2493
+ er as toolbarFilterScope,
2494
+ tr as transformComparisonDocument,
2495
+ _a as updateMatrixConfig,
2496
+ zr as upgradeToStoredDashboard,
2497
+ ar as validateControlValue,
2498
+ Ha as validateDashboardAuthoringDatasetScope,
2499
+ yr as validateDashboardFilterValues,
2500
+ ss as validateDashboardPlan,
2501
+ Ut as validateResolvedPrimaryDateFieldShape,
2502
+ sr as withCardExcludedFromScope,
2503
+ ir as withCardIncludedInScope,
2504
+ nr as withDashboardOptionDependencyOverride,
2505
+ aa as withUnstatedScopeParts,
2506
+ Bt as withoutToolbarFilterReachFields
1842
2507
  };