react-semaphor 0.1.545 → 0.1.547

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