react-semaphor 0.1.561 → 0.1.563

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 (138) hide show
  1. package/dist/analytics-protocol/index.js +452 -429
  2. package/dist/assistant-context/index.js +1 -1
  3. package/dist/assistant-protocol/index.js +5 -5
  4. package/dist/brand-studio/index.js +9 -9
  5. package/dist/briefings/index.js +5 -5
  6. package/dist/chunks/{analytics-base-schemas-CB3oFAXk.js → analytics-base-schemas-BaIQrEzX.js} +139 -134
  7. package/dist/chunks/{assistant-chat-DiVHY3Hw.js → assistant-chat-iIp02_77.js} +104 -104
  8. package/dist/chunks/{bookmark-impact-CR09dpkn.js → bookmark-impact-D4Kl4amw.js} +2 -2
  9. package/dist/chunks/{bookmark-state-BusLpkb7.js → bookmark-state-CWeoGbrx.js} +25 -25
  10. package/dist/chunks/{braces-u8VorWJc.js → braces-DzgoQC64.js} +1 -1
  11. package/dist/chunks/{comparison-window-caption-DDsIWJYT.js → comparison-window-caption-D1EUXzaR.js} +562 -437
  12. package/dist/chunks/{context-TUjw9eqr.js → context-R31TSL5V.js} +1 -1
  13. package/dist/chunks/{dashboard-BRdZBPqr.js → dashboard-CmqeP3QZ.js} +1 -1
  14. package/dist/chunks/{dashboard-briefing-launcher-CgvTLndW.js → dashboard-briefing-launcher-TYlSW77S.js} +155 -154
  15. package/dist/chunks/{dashboard-controls-B4vfSzTF.js → dashboard-controls-B253nJS-.js} +970 -968
  16. package/dist/chunks/{dashboard-json-Y3MF59g7.js → dashboard-json-osQuinUZ.js} +5 -5
  17. package/dist/chunks/dates-DFY7Gfss.js +91 -0
  18. package/dist/chunks/{edit-dashboard-visual-DwjZcxj-.js → edit-dashboard-visual-CMar-NhA.js} +4636 -4681
  19. package/dist/chunks/{filter-reach-copy-bijwf_-b.js → filter-reach-copy-CvV7W5dd.js} +1470 -1101
  20. package/dist/chunks/{filter-value-text-DFnhwuEW.js → filter-value-text-CPwFkrMz.js} +11 -10
  21. package/dist/chunks/{global-date-filter-utils-BXgCpvQM.js → global-date-filter-utils-N1kcsOFE.js} +8997 -7417
  22. package/dist/chunks/{index-ClwbY3BL.js → index-CNGkfUp4.js} +91 -85
  23. package/dist/chunks/{layout-grid-CtvCBfOm.js → layout-grid-BM65viQh.js} +1 -1
  24. package/dist/chunks/{list-filter-BklYgciR.js → list-filter-BoeLBfL3.js} +1 -1
  25. package/dist/chunks/{matrix-analytical-definition-pU51-JmY.js → matrix-analytical-definition-hEucouWM.js} +4 -4
  26. package/dist/chunks/{matrix-card-CUorIB7Q.js → matrix-card-CCh9JjP1.js} +3 -3
  27. package/dist/chunks/{matrix-member-presentation-Df5UgCGN.js → matrix-member-presentation-DsAUbuoL.js} +1 -1
  28. package/dist/chunks/{matrix-operation-contract-BSiGEXVC.js → matrix-operation-contract-DsLdFdSa.js} +339 -330
  29. package/dist/chunks/{metric-comparison-95aC0uEO.js → metric-comparison-Bnso1cm1.js} +2 -2
  30. package/dist/chunks/{model-change-B5wQhg5G.js → model-change-T1cRkh3m.js} +1 -1
  31. package/dist/chunks/{palette-DTnMhipt.js → palette-p1XSJFgB.js} +1 -1
  32. package/dist/chunks/{pivot-result-contract-expectations-Bo-86vwS.js → pivot-result-contract-expectations-B53jqszr.js} +5 -5
  33. package/dist/chunks/{pivot-result-identity-olvXJoB9.js → pivot-result-identity-Dq5jm-EC.js} +1 -1
  34. package/dist/chunks/{zoned-wall-clock-CGLVI40Q.js → raw-temporal-value-Bqz8wc7L.js} +97 -46
  35. package/dist/chunks/{report-preferences-dialog-C2YUIwKG.js → report-preferences-dialog-l54wJyYE.js} +68 -63
  36. package/dist/chunks/{report-runtime-context-DoIUr3MP.js → report-runtime-context-BITkNSDa.js} +2 -2
  37. package/dist/chunks/{resolve-dashboard-input-context-q_iiNXE1.js → resolve-dashboard-input-context-DaDrZGuA.js} +3455 -1744
  38. package/dist/chunks/{save-DH4RyrnG.js → save-CHV1B1fL.js} +1 -1
  39. package/dist/chunks/{saved-dashboard-context-8jqfI7hI.js → saved-dashboard-context-DFYBrE6O.js} +94 -95
  40. package/dist/chunks/{selection-filter-compiler-BKXmyLrS.js → selection-filter-compiler-CUDRnUxc.js} +19 -18
  41. package/dist/chunks/{selection-reducer-CV7K4FI6.js → selection-reducer-Bz5aywT4.js} +1 -1
  42. package/dist/chunks/{semaphor-ready-indicator-E2XWyibu.js → semaphor-ready-indicator-C3EQEiD9.js} +36434 -37732
  43. package/dist/chunks/{shelf-drop-preview-context-C29EUzDp.js → shelf-drop-preview-context-BODiBlqT.js} +81 -82
  44. package/dist/chunks/{source-entity-resolution-BXI3nQ5Z.js → source-entity-resolution-DdDVXFB8.js} +6 -6
  45. package/dist/chunks/{switch-balDSHc7.js → switch-BW4yXSYs.js} +3 -3
  46. package/dist/chunks/{table-export-sheet-CK8tvh4d.js → table-export-sheet-bSXxGn-v.js} +1 -1
  47. package/dist/chunks/{temporal-input-presentation-B77JsAzU.js → temporal-input-presentation-sk9gqLi6.js} +699 -741
  48. package/dist/chunks/{token-types-DhYH5YKb.js → token-types-BUK06hU2.js} +1 -1
  49. package/dist/chunks/{upload-Ufj8vjyn.js → upload-BnmuyPqW.js} +1 -1
  50. package/dist/chunks/{use-create-flow-overlay-state-9WsnzEO5.js → use-create-flow-overlay-state-BXY8-Cyz.js} +6 -6
  51. package/dist/chunks/{validators-BtaCFIEB.js → validators-BIM0FE31.js} +764 -885
  52. package/dist/dashboard/index.js +2 -2
  53. package/dist/dashboard-authoring/index.js +2278 -3030
  54. package/dist/data-app-sdk/index.js +43 -43
  55. package/dist/data-app-sdk-adapters/index.js +3 -3
  56. package/dist/data-app-sdk-validation/index.js +22 -22
  57. package/dist/format-utils/index.js +215 -209
  58. package/dist/index.js +225 -224
  59. package/dist/report-runtime-context/index.js +2 -2
  60. package/dist/style.css +1 -1
  61. package/dist/surfboard/index.js +2 -2
  62. package/dist/types/briefings/attachment-outcomes.d.ts +1 -1
  63. package/dist/types/components/dashboard/dashboard-create-dialog.d.ts +23 -0
  64. package/dist/types/components/index.d.ts +1 -2
  65. package/dist/types/components/surfboard/filter/types.d.ts +3 -1
  66. package/dist/types/index.js +5 -5
  67. package/dist/types/lib/formatters/raw-temporal-presentation.d.ts +59 -2
  68. package/dist/types/lib/interactions/get-click-context-from-matrix.d.ts +5 -0
  69. package/dist/types/lib/interactions/get-click-context-from-table.d.ts +45 -0
  70. package/dist/types/lib/print/print-inputs.d.ts +2 -1
  71. package/dist/types/lib/query-context/assemble-card-query.d.ts +2 -0
  72. package/dist/types/lib/query-context/build-dashboard-execution-snapshot.d.ts +5 -0
  73. package/dist/types/lib/selection/selection-from-click-context.d.ts +41 -0
  74. package/dist/types/lib/types/common-types.d.ts +6 -0
  75. package/dist/types/lib/types/explorer-types.d.ts +7 -1
  76. package/dist/types/lib/types/interaction-types.d.ts +3 -1
  77. package/dist/types/lib/types/token-types.d.ts +0 -1
  78. package/dist/types/shared/analytics-protocol/analytics-base-schemas.d.ts +3 -1
  79. package/dist/types/shared/analytics-protocol/contracts.d.ts +9 -40
  80. package/dist/types/shared/analytics-protocol/selection-contract.d.ts +12 -2
  81. package/dist/types/shared/analytics-protocol/validators.d.ts +1 -2
  82. package/dist/types/shared/assistant-protocol/context.d.ts +8 -8
  83. package/dist/types/shared/dashboard-authoring/card-formats/sql-date-pattern.d.ts +7 -1
  84. package/dist/types/shared/dashboard-authoring/card-settings/card-display-write.d.ts +24 -0
  85. package/dist/types/shared/dashboard-authoring/card-settings/card-kinds.d.ts +1 -1
  86. package/dist/types/shared/dashboard-authoring/card-settings/column-polarity-write.d.ts +5 -0
  87. package/dist/types/shared/dashboard-authoring/card-settings/index.d.ts +4 -2
  88. package/dist/types/shared/dashboard-authoring/card-settings/inputs.d.ts +15 -0
  89. package/dist/types/shared/dashboard-authoring/card-settings/resolved.d.ts +12 -1
  90. package/dist/types/shared/dashboard-authoring/card-settings/views.d.ts +5 -3
  91. package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +3230 -4658
  92. package/dist/types/shared/dashboard-authoring/changes/diagnostics.d.ts +24 -2
  93. package/dist/types/shared/dashboard-authoring/changes/field-ref.d.ts +91 -0
  94. package/dist/types/shared/dashboard-authoring/changes/read-card-query.d.ts +7 -0
  95. package/dist/types/shared/dashboard-authoring/changes/resolve-dashboard-changes.d.ts +27 -1
  96. package/dist/types/shared/dashboard-authoring/changes/resolve-dashboard-create.d.ts +26 -0
  97. package/dist/types/shared/dashboard-authoring/click-to-filter-settings.d.ts +2 -1
  98. package/dist/types/shared/dashboard-authoring/conditional-formatting/schema.d.ts +10 -10
  99. package/dist/types/shared/dashboard-authoring/detail-date-presentation.d.ts +9 -0
  100. package/dist/types/shared/dashboard-authoring/index.d.ts +8 -6
  101. package/dist/types/shared/dashboard-authoring/measure-calculations/apply.d.ts +8 -0
  102. package/dist/types/shared/dashboard-authoring/measure-calculations/comparison.d.ts +16 -0
  103. package/dist/types/shared/dashboard-authoring/measure-calculations/dates.d.ts +41 -0
  104. package/dist/types/shared/dashboard-authoring/measure-calculations/index.d.ts +17 -0
  105. package/dist/types/shared/dashboard-authoring/measure-calculations/options.d.ts +63 -0
  106. package/dist/types/shared/dashboard-authoring/measure-calculations/read.d.ts +16 -0
  107. package/dist/types/shared/dashboard-authoring/measure-calculations/resolve.d.ts +79 -0
  108. package/dist/types/shared/dashboard-authoring/measure-calculations/schemas.d.ts +934 -0
  109. package/dist/types/shared/dashboard-authoring/measure-calculations/sentences.d.ts +4 -0
  110. package/dist/types/shared/dashboard-authoring/measure-calculations/set.d.ts +11 -0
  111. package/dist/types/shared/dashboard-authoring/measure-calculations/transform.d.ts +63 -0
  112. package/dist/types/shared/dashboard-authoring/measure-calculations/window-transforms.d.ts +60 -0
  113. package/dist/types/shared/dashboard-authoring/new-card.d.ts +12 -1
  114. package/dist/types/shared/dashboard-authoring/operations/apply-dashboard-operations.d.ts +2 -1
  115. package/dist/types/shared/dashboard-authoring/operations/operation-sentences.d.ts +46 -0
  116. package/dist/types/shared/dashboard-authoring/operations/operation-types.d.ts +52 -2
  117. package/dist/types/shared/dashboard-authoring/outline/outline-dashboard.d.ts +13 -1
  118. package/dist/types/shared/dashboard-authoring/text-card-words/blocks.d.ts +58 -0
  119. package/dist/types/shared/dashboard-authoring/text-card-words/index.d.ts +55 -0
  120. package/dist/types/shared/dashboard-authoring/text-card-words/rich-content.d.ts +18 -0
  121. package/dist/types/shared/format-utils/document-print.d.ts +82 -0
  122. package/dist/types/shared/format-utils/index.d.ts +1 -0
  123. package/dist/types/shared/format-utils/raw-temporal.d.ts +2 -7
  124. package/dist/types/shared/temporal/index.d.ts +1 -0
  125. package/dist/types/shared/temporal/raw-temporal-equality.d.ts +19 -0
  126. package/dist/types/shared/temporal/raw-temporal-value.d.ts +29 -0
  127. package/dist/types/shared/temporal/zoned-wall-clock.d.ts +6 -0
  128. package/package.json +1 -1
  129. package/dist/chunks/custom-visual-inputs-DfolidZ9.js +0 -292
  130. package/dist/chunks/document-dashboard-inputs-CvBbFTUA.js +0 -1718
  131. package/dist/types/components/dashboard/ai-dashboard-create-dialog.d.ts +0 -38
  132. package/dist/types/components/dashboard/dashboard-create-template.d.ts +0 -10
  133. package/dist/types/lib/hooks/use-dashboard-authoring.d.ts +0 -49
  134. package/dist/types/shared/dashboard-authoring/artifact-compiler.d.ts +0 -6
  135. package/dist/types/shared/dashboard-authoring/contracts.d.ts +0 -106
  136. package/dist/types/shared/dashboard-authoring/protocol-adapter.d.ts +0 -7
  137. package/dist/types/shared/dashboard-authoring/source-matching.d.ts +0 -34
  138. package/dist/types/shared/dashboard-authoring/validators.d.ts +0 -2
@@ -1,1718 +0,0 @@
1
- import { y as xe, O as B, N as H, G as Se } from "./bookmark-state-BusLpkb7.js";
2
- import { X as qe, Q as Ee, a3 as Re, a4 as we, a5 as U, a6 as ke, Y as Ae, E as Be, a7 as Ne, a8 as Oe, a9 as Ge, aa as _e, ab as ze, ac as Le, ad as He, U as Qe, ae as je, c as $e, af as Y, r as Z, ag as Ke, ah as Ue, F as Ye, ai as Ze, R as Xe, aj as X, ak as We, al as Je } from "./resolve-dashboard-input-context-q_iiNXE1.js";
3
- import { aC as et } from "./validators-BtaCFIEB.js";
4
- import "./matrix-operation-contract-BSiGEXVC.js";
5
- import "./analytics-base-schemas-CB3oFAXk.js";
6
- import "zod";
7
- import { dX as W, dY as tt, i as w, dZ as it, d_ as nt, d$ as R, e0 as G, e1 as A, e2 as J, e3 as ot, e4 as rt, e5 as at, v as ee, e6 as st, e7 as lt, e8 as dt, e9 as ut, cH as te, ea as ie, a2 as ne, eb as oe, n as re, a as ae, ec as ct, c9 as ft, a7 as pt, d as se, aX as le, c8 as de, ed as mt, bW as gt, ac as ue, ab as Ct, ee as ce, ef as Q } from "./global-date-filter-utils-BXgCpvQM.js";
8
- import "./index-CuHybtft.js";
9
- import "../value-format-preferences/index.js";
10
- import "./_commonjsHelpers-DimLPMtv.js";
11
- import { aA as j } from "./temporal-input-presentation-B77JsAzU.js";
12
- import "./index-CJW5BdWT.js";
13
- import { r as bt, i as fe } from "./matrix-card-CUorIB7Q.js";
14
- import { D as Dt } from "./report-runtime-context-DoIUr3MP.js";
15
- import { c as vt } from "./selection-filter-compiler-BKXmyLrS.js";
16
- function Ft(e, t) {
17
- return {
18
- id: t,
19
- field: e.field,
20
- operator: e.operator,
21
- value: e.value,
22
- label: e.label,
23
- temporalBucket: e.temporalBucket
24
- };
25
- }
26
- function It(e, t) {
27
- return W(e) ? yt(e, t) : e.config ?? {};
28
- }
29
- function yt(e, t) {
30
- var n;
31
- const i = (n = t == null ? void 0 : t.steps[t.steps.length - 1]) == null ? void 0 : n.toField;
32
- return i ? qe(e.config ?? {}, i, {
33
- sortPolicy: "retargetDimensionSort"
34
- }) : e.config ?? {};
35
- }
36
- function ht(e, t) {
37
- const i = (e == null ? void 0 : e.steps) ?? [];
38
- if (i.length !== 0)
39
- return {
40
- id: `${t}-drill-root`,
41
- logicalOperator: "AND",
42
- negate: !1,
43
- conditions: [],
44
- groups: i.map((n, r) => ({
45
- id: `breadcrumb-${r}`,
46
- logicalOperator: "OR",
47
- negate: !1,
48
- conditions: [],
49
- groups: [
50
- {
51
- id: `breadcrumb-${r}-group-0`,
52
- logicalOperator: "AND",
53
- negate: !1,
54
- conditions: n.conditions.map(
55
- (o) => Ft(
56
- o,
57
- `${o.field.id}-${o.value}`
58
- )
59
- ),
60
- groups: []
61
- }
62
- ]
63
- }))
64
- };
65
- }
66
- function hi(e, t) {
67
- const { controlContractOverrides: i, cardId: n } = t;
68
- if (!i || (i.controlDefinitions !== void 0 && (e.controls = i.controlDefinitions), typeof n != "string" || n.trim().length === 0))
69
- return e;
70
- const r = xe(e, n);
71
- return r && (i.cardControlDefinitions !== void 0 && (r.controls = i.cardControlDefinitions), i.controlBindings !== void 0 && (r.controlBindings = i.controlBindings)), e;
72
- }
73
- function Vi(e) {
74
- const { dashboard: t, capture: i, calendar: n } = e, r = Ee(t, i.filterValues, {
75
- calendar: n
76
- }), o = i.dashboardInputExecutionSnapshot, a = i.controlValues, l = {
77
- ...we(
78
- t,
79
- {
80
- adHocFilterValues: r.adHocFilterValues,
81
- controlOverrides: a,
82
- // The snapshot replays exactly over the listed values.
83
- dashboardInputValues: o ? tt(
84
- r.slots,
85
- U({
86
- dashboard: t,
87
- dashboardInputValues: o.dashboardInputValues,
88
- sheetId: o.sheetId,
89
- cardId: o.cardId
90
- })
91
- ) : r.slots
92
- },
93
- n
94
- ),
95
- cardViewState: o ? Re(o.cardViewState) : {}
96
- }, u = o ? ke(o.transientContexts) : void 0;
97
- return {
98
- runtimeValues: l,
99
- controlOverrides: a,
100
- ...u != null && u.length ? { transientContexts: u } : {}
101
- };
102
- }
103
- function $(e) {
104
- const t = w(e.filter);
105
- return {
106
- inputId: e.inputId,
107
- filterId: e.filterId,
108
- label: e.label,
109
- selection: e.selection,
110
- owner: t ? { kind: "global_date" } : {
111
- kind: "field_date",
112
- filterId: e.filterId,
113
- label: e.label
114
- }
115
- };
116
- }
117
- function Vt(e) {
118
- var r, o;
119
- if ((r = e.card.sql) != null && r.trim())
120
- return {
121
- inputs: e.inputs,
122
- fieldCandidates: [],
123
- resolution: { status: "none" }
124
- };
125
- const t = e.inputs.filter((a) => !w(a.filter)).map((a) => ({
126
- input: a,
127
- resolution: it({
128
- filter: a.filter,
129
- filterValue: a.filterValue,
130
- effectiveFilterValue: a.effectiveFilterValue,
131
- mappedFilterValue: a.mappedFilterValue,
132
- temporalBinding: e.temporalBinding,
133
- card: e.card
134
- })
135
- }));
136
- if (!e.temporalBinding)
137
- return { inputs: e.inputs, fieldCandidates: t, resolution: { status: "none" } };
138
- const i = e.inputs.find(
139
- (a) => w(a.filter)
140
- );
141
- if (i && ((o = i.filterValue) == null ? void 0 : o.filterId) === i.filterId && i.effectiveFilterValue.filterId === i.filterId && nt(i.effectiveFilterValue))
142
- return {
143
- inputs: e.inputs,
144
- fieldCandidates: t,
145
- resolution: {
146
- status: "resolved",
147
- resolvedOwner: $(i)
148
- }
149
- };
150
- const n = t.filter(
151
- (a) => a.resolution.status === "eligible"
152
- );
153
- return n.length === 1 ? {
154
- inputs: e.inputs,
155
- fieldCandidates: t,
156
- resolution: {
157
- status: "resolved",
158
- resolvedOwner: $(n[0].input)
159
- }
160
- } : n.length > 1 ? {
161
- inputs: e.inputs,
162
- fieldCandidates: t,
163
- resolution: {
164
- status: "ambiguous",
165
- candidateInputIds: n.map(
166
- (a) => a.input.inputId
167
- )
168
- }
169
- } : { inputs: e.inputs, fieldCandidates: t, resolution: { status: "none" } };
170
- }
171
- function Mi(e) {
172
- var i, n;
173
- const t = {
174
- ownerCardCount: 0,
175
- matchingCardCount: 0,
176
- globalPrecedenceCardCount: 0,
177
- ambiguousCardCount: 0,
178
- authorControlledCardCount: 0
179
- };
180
- for (const r of e.targets) {
181
- const o = r.plan.fieldCandidates.find(
182
- (l) => l.input.inputId === e.inputId
183
- );
184
- if (!o || o.resolution.status !== "eligible") continue;
185
- t.matchingCardCount += 1;
186
- const { resolution: a } = r.plan;
187
- a.status === "resolved" && a.resolvedOwner.inputId === e.inputId ? t.ownerCardCount += 1 : a.status === "resolved" && a.resolvedOwner.owner.kind === "global_date" ? t.globalPrecedenceCardCount += 1 : a.status === "ambiguous" && a.candidateInputIds.includes(e.inputId) && (t.ambiguousCardCount += 1), (((i = r.card.preferences) == null ? void 0 : i.inheritGlobalComparison) === !1 || (((n = r.card.config) == null ? void 0 : n.metricColumns) || []).some(
188
- (l) => l.comparison !== void 0
189
- )) && (t.authorControlledCardCount += 1);
190
- }
191
- return t;
192
- }
193
- const Mt = /* @__PURE__ */ new Set([
194
- "between",
195
- "not between",
196
- "=",
197
- "!=",
198
- ">",
199
- ">=",
200
- "<",
201
- "<=",
202
- "is null",
203
- "is not null"
204
- ]), Pt = /^(\d{4}-\d{2}-\d{2})T/, Tt = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?(?:Z|[+-]\d{2}:\d{2})$/;
205
- function _(e) {
206
- return Mt.has(e);
207
- }
208
- function xt(e, t) {
209
- if (e instanceof Date)
210
- return Number.isNaN(e.getTime()) ? e : t ? j(e, t, "yyyy-MM-dd") : e.toISOString().slice(0, 10);
211
- if (typeof e != "string")
212
- return e;
213
- const i = e.trim();
214
- if (t && Tt.test(i)) {
215
- const r = new Date(i);
216
- if (!Number.isNaN(r.getTime()))
217
- return j(r, t, "yyyy-MM-dd");
218
- }
219
- const n = Pt.exec(i);
220
- return n ? n[1] : e;
221
- }
222
- function pe(e, t) {
223
- return Array.isArray(e) ? e.map(
224
- (i) => xt(i, t)
225
- ) : e;
226
- }
227
- function me(e) {
228
- return typeof e.allowMinutePrecision == "boolean" ? e.allowMinutePrecision : G(
229
- e.dashboard,
230
- e.semanticExecutionPayload
231
- ).allEligibleTargetsAreDateTime;
232
- }
233
- function ge(e) {
234
- const {
235
- globalDateFilter: t,
236
- globalDateFilterValue: i,
237
- timezone: n,
238
- allowMinutePrecision: r = !1
239
- } = e;
240
- if (!t || !i)
241
- return;
242
- if (!_(i.operation))
243
- return {
244
- ...i,
245
- filterId: t.id
246
- };
247
- const o = i, a = o.temporalPrecision === "minute" || A(o.relativeMeta), l = !r && a, u = o.operation === "is null" || o.operation === "is not null" ? [] : l ? pe(o.values, n) : o.values, c = r || !A(o.relativeMeta) ? o.relativeMeta : void 0, s = r && o.temporalPrecision === "minute" ? o.temporalPrecision : void 0, {
248
- relativeMeta: d,
249
- temporalPrecision: f,
250
- values: p,
251
- ...v
252
- } = i;
253
- return {
254
- ...v,
255
- filterId: t.id,
256
- values: u,
257
- ...c ? { relativeMeta: c } : {},
258
- ...s ? { temporalPrecision: s } : {}
259
- };
260
- }
261
- function St(e) {
262
- const t = R(e.filters);
263
- if (!t)
264
- return e.filterValues;
265
- const i = me(e);
266
- return e.filterValues.map((n) => n.filterId !== t.id ? n : ge({
267
- globalDateFilter: t,
268
- globalDateFilterValue: n,
269
- timezone: e.timezone,
270
- allowMinutePrecision: i
271
- }) || n);
272
- }
273
- function Ce(e) {
274
- const {
275
- globalDateFilter: t,
276
- globalDateFilterValue: i,
277
- resolvedPrimaryDateField: n,
278
- semanticContext: r,
279
- timezone: o,
280
- allowMinutePrecision: a = !1
281
- } = e;
282
- if (!t || !i || !n || !_(i.operation))
283
- return null;
284
- const l = i, u = ot(
285
- n.dataType
286
- ), c = a && u, s = l.temporalPrecision === "minute" || A(l.relativeMeta), d = c && l.temporalPrecision === "minute" ? l.temporalPrecision : void 0, f = c || !A(l.relativeMeta) ? l.relativeMeta : void 0, p = !c && s;
287
- return {
288
- filterId: t.id,
289
- dateOwner: "global_date",
290
- name: n.qualifiedFieldName || n.name,
291
- operation: l.operation,
292
- valueType: "date",
293
- values: l.operation === "is null" || l.operation === "is not null" ? [] : p ? pe(
294
- l.values,
295
- o
296
- ) : l.values,
297
- dataType: n.dataType || "date",
298
- // The exact type travels with the filter, so the server formats the predicate for
299
- // the column's storage type (it read it from `dataType` before 2.1 split the two).
300
- ...n.nativeDataType ? { nativeDataType: n.nativeDataType } : {},
301
- fieldMeta: {
302
- name: n.name,
303
- qualifiedFieldName: n.qualifiedFieldName,
304
- qualifiedEntityName: n.qualifiedEntityName,
305
- entityId: n.entityId,
306
- entityName: n.entityName,
307
- entityType: n.entityType,
308
- dataType: n.dataType,
309
- ...n.nativeDataType ? { nativeDataType: n.nativeDataType } : {},
310
- role: "groupby",
311
- ...t != null && t.title ? { label: t.title } : {}
312
- },
313
- ...r ? { semanticContext: r } : {},
314
- ...f ? { relativeMeta: f } : {},
315
- ...d ? { temporalPrecision: d } : {}
316
- };
317
- }
318
- function S(e) {
319
- return typeof e == "string" ? e.trim() : "";
320
- }
321
- function qt(e) {
322
- var t;
323
- return (((t = e.semanticContext) == null ? void 0 : t.selectedEntities) || []).filter((i) => typeof i == "object" && i !== null).filter((i) => i.type === "dataset").map((i) => {
324
- var n;
325
- return {
326
- domainId: S(i.domainId) || S((n = e.semanticContext) == null ? void 0 : n.semanticDomainId),
327
- datasetName: S(i.name),
328
- selectedEntityId: S(i.id)
329
- };
330
- }).filter((i) => i.domainId && i.datasetName);
331
- }
332
- function Et(e) {
333
- var u, c, s, d, f;
334
- if (w(e) || (u = e.sql) != null && u.trim())
335
- return null;
336
- const t = qt(e), i = S((c = e.semanticContext) == null ? void 0 : c.semanticDomainId), n = S((s = e.fieldMeta) == null ? void 0 : s.entityId), r = S((d = e.fieldMeta) == null ? void 0 : d.entityName), o = S((f = e.fieldMeta) == null ? void 0 : f.entityType) === "dataset", a = t.find(
337
- (p) => n && p.selectedEntityId === n
338
- );
339
- if (a)
340
- return a;
341
- const l = t.find(
342
- (p) => r && p.datasetName === r && (!i || p.domainId === i)
343
- );
344
- return l || (t.length === 1 ? t[0] : o && r && i ? {
345
- domainId: i,
346
- datasetName: r
347
- } : null);
348
- }
349
- function Rt(e) {
350
- var r, o;
351
- const { filter: t, semanticExecutionPayload: i } = e;
352
- if (!i)
353
- return null;
354
- const n = Et(t);
355
- return n && ((o = (r = i.domainsById[n.domainId]) == null ? void 0 : r.datasetsByName[n.datasetName]) == null ? void 0 : o.primaryDateField) || null;
356
- }
357
- function be(e) {
358
- const t = R(e.filters);
359
- return t ? e.filterValues.filter(
360
- (i) => i.filterId !== t.id
361
- ) : e.filterValues;
362
- }
363
- function Pi(e) {
364
- const t = R(e.filters), i = be({
365
- filters: e.filters,
366
- filterValues: e.filterValues
367
- });
368
- if (!t || w(e.filter))
369
- return i;
370
- const n = e.filterValues.find(
371
- (a) => a.filterId === t.id
372
- ), r = Rt({
373
- filter: e.filter,
374
- semanticExecutionPayload: e.semanticExecutionPayload
375
- }), o = Ce({
376
- globalDateFilter: t,
377
- globalDateFilterValue: n,
378
- resolvedPrimaryDateField: r || void 0,
379
- semanticContext: e.filter.semanticContext,
380
- timezone: e.timezone,
381
- allowMinutePrecision: e.allowMinutePrecision
382
- });
383
- return o ? [o, ...i] : i;
384
- }
385
- function wt(e) {
386
- var s;
387
- const t = R(e.filters), i = t ? e.cardFilterValues.find(
388
- (d) => d.filterId === t.id
389
- ) : void 0, n = t ? e.cardFilterValues.filter(
390
- (d) => d.filterId !== t.id
391
- ) : e.cardFilterValues, r = e.resolvedPrimaryDateField ?? J({
392
- card: e.card,
393
- cardConfig: e.cardConfig,
394
- resolvedFields: e.resolvedFields,
395
- semanticExecutionPayload: e.semanticExecutionPayload
396
- }), o = Ce({
397
- globalDateFilter: t,
398
- globalDateFilterValue: i,
399
- resolvedPrimaryDateField: r || void 0,
400
- timezone: e.timezone,
401
- allowMinutePrecision: e.allowMinutePrecision
402
- }), a = o ? [o, ...n] : n, l = new Map(
403
- a.map((d) => [
404
- d.filterId,
405
- d
406
- ])
407
- ), u = ((s = e.dateComparisonInputs) == null ? void 0 : s.flatMap((d) => {
408
- var p;
409
- const f = l.get(
410
- d.filterId
411
- );
412
- return f ? [{
413
- ...d,
414
- effectiveFilterValue: f,
415
- mappedFilterValue: (p = e.mappedFilterValuesByInputId) == null ? void 0 : p.get(d.inputId)
416
- }] : [];
417
- })) || [], c = Vt({
418
- inputs: u,
419
- temporalBinding: r,
420
- card: e.card
421
- });
422
- return {
423
- cardFilterValues: a,
424
- resolvedPrimaryDateField: r,
425
- dateComparisonPlan: c
426
- };
427
- }
428
- function Ti(e) {
429
- const t = R(e.filters), i = me(e), n = t ? e.filterValues.find(
430
- (a) => a.filterId === t.id
431
- ) : void 0, r = be(e);
432
- return !t || !n || !_(n.operation) ? r : [
433
- {
434
- ...ge({
435
- globalDateFilter: t,
436
- globalDateFilterValue: n,
437
- timezone: e.timezone,
438
- allowMinutePrecision: i
439
- }) || n,
440
- filterId: t.id,
441
- name: t.title || t.column
442
- },
443
- ...r
444
- ];
445
- }
446
- class kt extends Error {
447
- }
448
- function xi(e, t) {
449
- const i = new Map((e ? B(e) : []).map(({ card: n }) => [n.id, n]));
450
- return t && i.set(t.id, t), [...i.values()].flatMap((n) => {
451
- const r = fe(n);
452
- return r.status === "ready" ? Be(r.config.spec, n.controlBindings) : [];
453
- });
454
- }
455
- function At(e, t, i) {
456
- const n = bt(e);
457
- if (!n) throw new Error("Matrix card definition is required.");
458
- const r = i && Ae({
459
- ...i,
460
- spec: n.spec,
461
- catalog: t.map((s) => ({ ...s, id: s.resolvedField.id }))
462
- }), o = r ? { ...n, spec: r.spec } : n, a = rt(t), l = at(t), u = (s) => {
463
- const d = l(s, o.spec.source);
464
- if (!(!d && s.derivedField)) {
465
- if (!d) throw new kt(`Matrix field metadata is unavailable: ${s.name}`);
466
- return { ...d, ...s.derivedField ? { derivedField: s.derivedField } : {} };
467
- }
468
- }, c = {
469
- rows: o.spec.rows.flatMap((s) => {
470
- const d = u(s.field);
471
- return d ? [{ ...d, id: s.id, granularity: s.grain, role: "groupby" }] : [];
472
- }),
473
- columns: o.spec.columns.flatMap((s) => {
474
- const d = u(s.field);
475
- return d ? [{ ...d, id: s.id, granularity: s.grain, role: "pivotby" }] : [];
476
- }),
477
- // Aggregate-stage expressions have no source-column filter target. They stay
478
- // authoritative in matrix.spec, including all dependencies and controls.
479
- metrics: o.spec.measures.flatMap((s) => {
480
- if (s.kind !== "aggregate" || s.field.name === "*") return [];
481
- const d = u(s.field);
482
- return d ? [{ ...d, id: s.id, aggregate: s.aggregate, role: "metric" }] : [];
483
- })
484
- };
485
- return { config: o, fields: c, resolveField: a };
486
- }
487
- function Bt(e) {
488
- const t = e.filter(Boolean);
489
- if (t.length !== 0)
490
- return t.length === 1 ? t[0] : {
491
- id: ee(),
492
- logicalOperator: "AND",
493
- negate: !1,
494
- conditions: [],
495
- groups: t
496
- };
497
- }
498
- function Nt(e) {
499
- if (!e) return;
500
- const t = (i) => ({
501
- logicalOperator: i.logicalOperator,
502
- negate: i.negate,
503
- conditions: i.conditions.map((n) => ({
504
- field: n.field.id,
505
- operator: n.operator,
506
- value: n.value,
507
- temporalBucket: n.temporalBucket,
508
- // The run-time markers decide what runs, so they belong in the key.
509
- relativeMeta: n.relativeMeta,
510
- latestValue: n.latestValue
511
- })),
512
- groups: i.groups.map(t)
513
- });
514
- return JSON.stringify(t(e));
515
- }
516
- function Ot(e, t) {
517
- const i = e.metricColumns || [];
518
- if (i.length === 0) return e;
519
- const n = lt.includes(
520
- t
521
- ), r = dt.includes(
522
- t
523
- ), o = (u) => {
524
- var c;
525
- return (c = u.parameters) != null && c.windowTransform ? {
526
- ...u,
527
- parameters: {
528
- ...u.parameters,
529
- windowTransform: void 0
530
- }
531
- } : u;
532
- };
533
- let a = !1;
534
- const l = i.map(
535
- (u) => {
536
- var d;
537
- const c = st(u);
538
- if (c === "none")
539
- return u;
540
- let s = u;
541
- return (d = s.parameters) != null && d.windowTransform && (a = !0, s = o(s)), n ? c === "target" && !r ? (a = !0, {
542
- ...s,
543
- comparison: void 0
544
- }) : s : (a = !0, { ...s, comparison: void 0 });
545
- }
546
- );
547
- return a ? {
548
- ...e,
549
- metricColumns: l
550
- } : e;
551
- }
552
- function Si(e, t = {}) {
553
- return De(ve(e, t));
554
- }
555
- function De(e) {
556
- return Bt([e.authored, e.drill, e.selections]);
557
- }
558
- function ve(e, t = {}) {
559
- return {
560
- authored: t.includeAuthoredFilters === !1 ? void 0 : ut(e),
561
- drill: ht(t.drill, e.id),
562
- selections: vt(t.selections ?? [])
563
- };
564
- }
565
- function Gt(e, t, i) {
566
- const n = It(e, t);
567
- return W(e) ? Ot(
568
- { ...n, filters: i },
569
- e.type
570
- ) : n;
571
- }
572
- function _t(e) {
573
- const t = Ne(e);
574
- return {
575
- contextMode: t,
576
- shouldApplyDashboardFilters: !t || t === "full"
577
- };
578
- }
579
- function zt(e) {
580
- const t = e.dashboardControls || [], i = e.card.controls || [], n = /* @__PURE__ */ new Set([
581
- ...t.map((r) => r.id),
582
- ...i.map((r) => r.id)
583
- ]);
584
- return Fe(
585
- e.card,
586
- {
587
- controlValues: ie({
588
- relevantControlIds: n,
589
- dashboardValues: e.dashboardControlValues,
590
- cardValues: e.cardControlValues
591
- }),
592
- controlDefinitions: t,
593
- cardControlDefinitions: i,
594
- controlBindings: e.card.controlBindings || []
595
- },
596
- e.presentationControlIds
597
- );
598
- }
599
- function Fe(e, t, i) {
600
- const r = t.controlBindings.filter(
601
- (f) => !te(f)
602
- ), o = new Set(
603
- Oe({
604
- sql: e.sql,
605
- controlBindings: r
606
- })
607
- ), a = new Set(
608
- [...i].filter(
609
- (f) => !o.has(f)
610
- )
611
- ), l = t.controlDefinitions.filter(
612
- (f) => !a.has(f.id)
613
- ), u = t.cardControlDefinitions.filter(
614
- (f) => !a.has(f.id)
615
- ), c = /* @__PURE__ */ new Set([
616
- ...l.map((f) => f.id),
617
- ...u.map((f) => f.id)
618
- ]), s = r.filter(
619
- (f) => c.has(f.controlId)
620
- );
621
- return {
622
- controlValues: ie({
623
- relevantControlIds: c,
624
- dashboardValues: t.controlValues
625
- }),
626
- controlDefinitions: l,
627
- cardControlDefinitions: u,
628
- controlBindings: s
629
- };
630
- }
631
- function Lt({
632
- card: e,
633
- dashboard: t,
634
- transientContexts: i,
635
- cardViewState: n,
636
- viewerTableSettings: r,
637
- adHocFilterValues: o,
638
- selectedSheetId: a,
639
- inlineFilterValuesMap: l,
640
- dashboardControls: u,
641
- dashboardControlValues: c,
642
- cardControlValuesMap: s,
643
- dashboardInputContext: d,
644
- includeAuthoredFilters: f
645
- }) {
646
- var P;
647
- const p = Ge(t);
648
- for (const V of e.controlBindings || [])
649
- te(V) && p.add(V.controlId);
650
- const { shouldApplyDashboardFilters: v } = _t(i), m = d != null && d.inputs.length ? d : void 0, F = ve(e, {
651
- includeAuthoredFilters: f,
652
- // Blocked and skipped conditions are already projected away, so a
653
- // selection can only ever narrow this card on its own fields. Carried
654
- // selections are among them.
655
- selections: ((d == null ? void 0 : d.selections) ?? []).filter(
656
- (V) => V.status === "apply"
657
- ),
658
- drill: n == null ? void 0 : n.drill
659
- }), I = De(F), C = f === !1 ? _e(I, !0) : I, g = Gt(
660
- e,
661
- n == null ? void 0 : n.drill,
662
- C
663
- ), D = ze({ ...e, config: g }, r) ?? g, b = Le(D, {
664
- cardType: e.type,
665
- dataSource: e.dataSource,
666
- temporalResultOwner: ne({
667
- hasExecutableConfig: oe(D, e.type),
668
- sql: e.sql,
669
- normalizedPython: re(e.python || "")
670
- })
671
- }) || D, M = Nt(C) || "", k = m ? Fe(
672
- e,
673
- {
674
- controlValues: m.controlValues,
675
- controlDefinitions: m.controlDefinitions,
676
- cardControlDefinitions: m.cardControlDefinitions,
677
- controlBindings: m.controlBindings
678
- },
679
- p
680
- ) : zt({
681
- card: e,
682
- presentationControlIds: p,
683
- dashboardControls: u,
684
- dashboardControlValues: c,
685
- cardControlValues: s == null ? void 0 : s[e.id]
686
- });
687
- return {
688
- filterCompilationInput: {
689
- adHocFilterValues: o || [],
690
- selectedSheetId: a,
691
- inlineFilterValues: (l == null ? void 0 : l[e.id]) || [],
692
- shouldApplyDashboardFilters: v,
693
- ...m ? {
694
- dashboardInputContext: {
695
- inputs: m.inputs,
696
- resolvedInputs: m.resolvedInputs,
697
- activeFilters: m.activeFilters
698
- }
699
- } : {},
700
- ...m != null && m.globalDateComparisonSelection ? {
701
- globalDateComparisonSelection: m.globalDateComparisonSelection
702
- } : {},
703
- ...m != null && m.dateComparisonInputs ? {
704
- dateComparisonInputs: m.dateComparisonInputs
705
- } : {}
706
- },
707
- ...k,
708
- resolvedFilters: C,
709
- resolvedFilterParts: F,
710
- drillSteps: ((P = n == null ? void 0 : n.drill) == null ? void 0 : P.steps) ?? He,
711
- finalConfig: D,
712
- queryRelevantConfig: b,
713
- finalFiltersKey: M
714
- };
715
- }
716
- function Ie(e, t, i) {
717
- var n;
718
- if (t)
719
- return {
720
- selection: t,
721
- ...((n = e.preferences) == null ? void 0 : n.inheritGlobalComparison) === !1 ? { inheritGlobalComparison: !1 } : {},
722
- ...i ? { owner: i } : {}
723
- };
724
- }
725
- function Ht(e) {
726
- if (e.resolution.status === "resolved")
727
- return Ie(
728
- e.card,
729
- e.resolution.resolvedOwner.selection,
730
- e.resolution.resolvedOwner.owner
731
- );
732
- }
733
- function Qt(e) {
734
- return `Set ${e.join(", ")} to run this card.`;
735
- }
736
- function jt({
737
- dashboardInputContext: e,
738
- shouldApplyDashboardFilters: t
739
- }) {
740
- if (t)
741
- return e.activeFilters;
742
- const i = new Set(
743
- e.inputs.flatMap(
744
- (n) => n.kind === "filter" && ae(n) ? [n.filter.id] : []
745
- )
746
- );
747
- return e.activeFilters.filter(
748
- (n) => i.has(n.filterId)
749
- );
750
- }
751
- function $t({
752
- dashboardInputFilterValues: e,
753
- adHocFilterValues: t
754
- }) {
755
- const i = [...e], n = new Set(
756
- i.map((r) => r.filterId)
757
- );
758
- for (const r of t)
759
- n.has(r.filterId) || (i.push(r), n.add(r.filterId));
760
- return i;
761
- }
762
- function N(e, t) {
763
- const i = t.shouldApplyDashboardFilters ? Qe(t.adHocFilterValues, t.selectedSheetId) : [];
764
- if (!t.dashboardInputContext)
765
- return {
766
- status: "ready",
767
- filterValues: [...i, ...t.inlineFilterValues],
768
- mappingDispositions: []
769
- };
770
- const n = t.dashboardInputContext.inputs.filter(
771
- (s) => s.kind === "filter" && !!s.application
772
- ), r = new Set(
773
- n.map((s) => s.filter.id)
774
- ), o = new Set(
775
- t.dashboardInputContext.inputs.flatMap(
776
- (s) => {
777
- var d;
778
- return s.kind === "filter" && ((d = s.compatibility) == null ? void 0 : d.source) === "cardInlineFilter" ? [s.filter.id] : [];
779
- }
780
- )
781
- ), a = jt({
782
- dashboardInputContext: t.dashboardInputContext,
783
- shouldApplyDashboardFilters: t.shouldApplyDashboardFilters
784
- }).filter((s) => !r.has(s.filterId)), l = a.filter(
785
- (s) => !o.has(s.filterId)
786
- ), u = a.filter(
787
- (s) => o.has(s.filterId)
788
- ), c = je({
789
- card: e,
790
- inputs: n,
791
- resolvedInputs: t.dashboardInputContext.resolvedInputs,
792
- activeFilterValues: t.dashboardInputContext.activeFilters,
793
- shouldApplyDashboardFilters: t.shouldApplyDashboardFilters
794
- });
795
- return c.status === "blocked" ? {
796
- status: "blocked",
797
- mappingDispositions: c.dispositions
798
- } : {
799
- status: "ready",
800
- filterValues: [
801
- ...$t({
802
- dashboardInputFilterValues: [
803
- ...l,
804
- ...c.filterValues
805
- ],
806
- adHocFilterValues: i
807
- }),
808
- ...u
809
- ],
810
- mappingDispositions: c.dispositions
811
- };
812
- }
813
- function Kt(e, t) {
814
- const i = e.dashboardInputContext;
815
- if (!i) return [];
816
- const n = new Set(
817
- t.flatMap(
818
- (o) => o.status === "skip" && (o.reason === "explicitlyExcluded" || o.reason === "outsideScope") ? [o.inputId] : []
819
- )
820
- ), r = new Map(i.inputs.map((o) => [o.id, o]));
821
- return i.resolvedInputs.flatMap((o) => {
822
- if (!o.missingRequiredValue) return [];
823
- const a = r.get(o.id);
824
- return a ? a.kind === "filter" && (!e.shouldApplyDashboardFilters && !ae(a) || n.has(a.id)) ? [] : [o.label] : [];
825
- });
826
- }
827
- function Ut({
828
- card: e,
829
- cardConfig: t,
830
- input: i,
831
- resolvedPrimaryDateField: n,
832
- resolvedFields: r,
833
- semanticExecutionPayload: o,
834
- timezone: a,
835
- allowMinutePrecision: l
836
- }) {
837
- var m;
838
- const u = i.dashboardInputContext ? i.dashboardInputContext.inputs.flatMap(
839
- (F) => F.kind === "filter" ? [F.filter] : []
840
- ) : [], c = N(e, i), s = Kt(
841
- i,
842
- c.mappingDispositions
843
- );
844
- if (s.length)
845
- return {
846
- status: "blocked",
847
- cardId: e.id,
848
- reason: "requiredInput",
849
- mappingDispositions: c.mappingDispositions,
850
- missingRequiredLabels: s
851
- };
852
- if (c.status === "blocked")
853
- return {
854
- status: "blocked",
855
- cardId: e.id,
856
- reason: "mapping",
857
- mappingDispositions: c.mappingDispositions,
858
- missingRequiredLabels: []
859
- };
860
- const d = wt({
861
- card: e,
862
- cardConfig: t,
863
- filters: u,
864
- cardFilterValues: c.filterValues,
865
- resolvedPrimaryDateField: n,
866
- resolvedFields: r,
867
- semanticExecutionPayload: o,
868
- timezone: a,
869
- allowMinutePrecision: l,
870
- dateComparisonInputs: i.dateComparisonInputs,
871
- mappedFilterValuesByInputId: new Map(
872
- c.mappingDispositions.flatMap(
873
- (F) => F.status === "apply" ? [[F.inputId, F.filterValue]] : []
874
- )
875
- )
876
- }), f = R(u), p = !!(f && d.cardFilterValues.some(
877
- (F) => F.filterId === f.id
878
- )), v = d.resolvedPrimaryDateField && !((m = e.sql) != null && m.trim()) ? d.dateComparisonPlan.inputs.length ? Ht({
879
- card: e,
880
- resolution: d.dateComparisonPlan.resolution
881
- }) : p ? Ie(
882
- e,
883
- i.globalDateComparisonSelection
884
- ) : void 0 : void 0;
885
- return {
886
- status: "ready",
887
- ...d,
888
- queryFilterDefinitions: u,
889
- globalDateComparison: v,
890
- mappingDispositions: c.mappingDispositions
891
- };
892
- }
893
- function ye(e, t, i) {
894
- const n = Ut({
895
- resolvedFields: t.resolvedDateFields,
896
- ...i,
897
- card: e,
898
- cardConfig: t.queryRelevantConfig,
899
- input: t.filterCompilationInput
900
- });
901
- if (n.status === "blocked") return n;
902
- const { filterCompilationInput: r, ...o } = t;
903
- return { status: "ready", queryContext: {
904
- ...o,
905
- cardFilterValues: n.cardFilterValues,
906
- queryFilterDefinitions: n.queryFilterDefinitions,
907
- resolvedPrimaryDateField: n.resolvedPrimaryDateField,
908
- globalDateComparison: n.globalDateComparison,
909
- globalDateComparisonSelection: r.globalDateComparisonSelection,
910
- dateComparisonInputs: r.dateComparisonInputs
911
- }, compiledFilters: n };
912
- }
913
- function Yt(e, t, i) {
914
- const n = ct(e), r = ye(e, t, {
915
- resolvedPrimaryDateField: i.resolvedPrimaryDateField,
916
- timezone: i.calendarContext.tz,
917
- allowMinutePrecision: i.allowGlobalDateMinutePrecision
918
- });
919
- if (r.status === "blocked")
920
- return { ...r, tableConfig: n };
921
- const { compiledFilters: o } = r, {
922
- cardFilterValues: a,
923
- resolvedPrimaryDateField: l,
924
- globalDateComparison: u
925
- } = o, { queryKey: c, queryInputIdentity: s, paginationConfig: d } = $e(
926
- e,
927
- r.queryContext,
928
- i.calendarContext,
929
- { resolvePaginationConfig: i.resolvePaginationConfig }
930
- ), f = t.queryRelevantConfig, p = re(e.python || ""), v = ne({
931
- hasExecutableConfig: oe(f, e.type),
932
- sql: e.sql,
933
- normalizedPython: p
934
- });
935
- return {
936
- status: "ready",
937
- queryKey: c,
938
- queryInputIdentity: s,
939
- paginationConfig: d,
940
- tableConfig: n,
941
- compiledFilters: o,
942
- requestPayloadBase: {
943
- cardId: e.id,
944
- sql: (e == null ? void 0 : e.sql) || "",
945
- python: p,
946
- resultOwner: v,
947
- active_filters: a,
948
- controlValues: t.controlValues,
949
- controlDefinitions: t.controlDefinitions,
950
- cardControlDefinitions: t.cardControlDefinitions,
951
- controlBindings: t.controlBindings,
952
- cache_config: i.globalCacheConfig,
953
- queryConfig: e.queryConfig,
954
- tableConfig: n,
955
- cardType: e.type,
956
- cardTitle: e.title || "",
957
- cardConfig: f,
958
- cardDataSource: e.dataSource,
959
- resolvedPrimaryDateField: l || void 0,
960
- calendarContext: i.calendarContext,
961
- ...u ? { globalDateComparison: u } : {}
962
- }
963
- };
964
- }
965
- const K = [], Zt = [], Xt = {};
966
- function qi(e, t) {
967
- return {
968
- sheetId: e.sheetId,
969
- sectionId: e.sectionId,
970
- documentFilterValues: e.documentFilterValues ?? K,
971
- documentControlDefinitions: e.documentControlDefinitions ?? Zt,
972
- documentControlValues: e.documentControlValues ?? Xt,
973
- editorFilterValues: t ?? K
974
- };
975
- }
976
- function Wt({
977
- card: e,
978
- dashboard: t,
979
- runtime: i,
980
- dashboardRuntimeValues: n,
981
- calendar: r
982
- }) {
983
- const o = Y({
984
- dashboard: t,
985
- dashboardInputValues: n.dashboardInputValues,
986
- transientContexts: void 0
987
- }) ? Z({
988
- transientContexts: void 0,
989
- dashboard: t,
990
- sheetId: i.sheetId,
991
- sheetKind: "document",
992
- sectionId: i.sectionId,
993
- card: e,
994
- runtimeValues: {
995
- ...n,
996
- dashboardInputValues: i.documentDashboardInputValues || n.dashboardInputValues
997
- },
998
- calendar: r
999
- }) : void 0, a = o && (o.inputs.length > 0 || o.selections.length > 0) ? o : void 0, l = !!(o != null && o.inputs.length), u = [
1000
- ...i.editorFilterValues || [],
1001
- ...i.documentFilterValues
1002
- ];
1003
- return {
1004
- card: l ? e : Jt(
1005
- e,
1006
- i.documentControlDefinitions
1007
- ),
1008
- dashboard: t,
1009
- transientContexts: void 0,
1010
- // Document section cards do not drill.
1011
- cardViewState: void 0,
1012
- // Document section cards are not viewer-customizable tables.
1013
- viewerTableSettings: void 0,
1014
- adHocFilterValues: [],
1015
- inlineFilterValuesMap: !l && u.length ? { [e.id]: u } : {},
1016
- dashboardControls: [],
1017
- dashboardControlValues: {},
1018
- cardControlValuesMap: !l && Object.keys(i.documentControlValues).length > 0 ? { [e.id]: i.documentControlValues } : {},
1019
- dashboardInputContext: a
1020
- };
1021
- }
1022
- function Jt(e, t) {
1023
- if (t.length === 0)
1024
- return e;
1025
- const i = /* @__PURE__ */ new Map();
1026
- for (const n of e.controls || [])
1027
- i.set(n.id, n);
1028
- for (const n of t)
1029
- i.set(n.id, n);
1030
- return {
1031
- ...e,
1032
- controls: Array.from(i.values())
1033
- };
1034
- }
1035
- function Ei({
1036
- card: e,
1037
- place: t,
1038
- source: i
1039
- }) {
1040
- const n = O(e, t, i);
1041
- return {
1042
- card: n.card,
1043
- context: n.context,
1044
- inputContext: n.inputContext
1045
- };
1046
- }
1047
- function ei(e, t, i) {
1048
- return {
1049
- calendarContext: i ?? Dt,
1050
- allowGlobalDateMinutePrecision: G(
1051
- e,
1052
- t
1053
- ).allEligibleTargetsAreDateTime,
1054
- semanticExecutionPayload: t,
1055
- globalCacheConfig: e.globalCacheConfig
1056
- };
1057
- }
1058
- function Ri(e, t) {
1059
- return Ve(
1060
- e,
1061
- t,
1062
- t.allowGlobalDateMinutePrecision
1063
- );
1064
- }
1065
- function ti(e, t, i = {}) {
1066
- const n = he(e, t);
1067
- return {
1068
- ...Yt(e.card, e.context, {
1069
- resolvedPrimaryDateField: n,
1070
- calendarContext: t.calendarContext,
1071
- allowGlobalDateMinutePrecision: t.allowGlobalDateMinutePrecision,
1072
- globalCacheConfig: t.globalCacheConfig,
1073
- resolvePaginationConfig: i.resolvePaginationConfig
1074
- }),
1075
- resolvedPrimaryDateField: n
1076
- };
1077
- }
1078
- function ii({
1079
- card: e,
1080
- place: t,
1081
- source: i,
1082
- semanticExecutionPayload: n,
1083
- matrixCatalog: r,
1084
- withRequest: o = !1
1085
- }) {
1086
- var m, F;
1087
- const { dashboard: a } = i, l = e.id, u = (I, C) => {
1088
- var D;
1089
- let g;
1090
- try {
1091
- const b = fe(I);
1092
- if (b.status === "invalid") throw b.error;
1093
- const M = O(
1094
- I,
1095
- C,
1096
- i,
1097
- b.status === "absent"
1098
- );
1099
- if (g = M.context, b.status === "absent")
1100
- return { status: "ready", value: { assembled: M } };
1101
- if (!r)
1102
- return {
1103
- status: "blocked",
1104
- reason: "metadata",
1105
- message: "Matrix field metadata is required.",
1106
- context: g
1107
- };
1108
- const k = Ye(b.config.spec, g), P = r.filter(
1109
- (y) => y.field.source && k.some(
1110
- (T) => et(T, y.field.source)
1111
- )
1112
- ), V = At(I, P, g), { params: q } = M, x = q.dashboardInputContext;
1113
- V.config = {
1114
- ...V.config,
1115
- presentation: Ze(
1116
- I,
1117
- V.config,
1118
- {
1119
- controls: x ? [
1120
- ...x.controlDefinitions,
1121
- ...x.cardControlDefinitions
1122
- ] : [
1123
- ...q.dashboardControls ?? a.controls ?? [],
1124
- ...q.card.controls ?? []
1125
- ],
1126
- values: (x == null ? void 0 : x.controlValues) ?? {
1127
- ...q.dashboardControlValues,
1128
- ...(D = q.cardControlValuesMap) == null ? void 0 : D[I.id]
1129
- }
1130
- },
1131
- P
1132
- )
1133
- };
1134
- const E = {
1135
- ...I,
1136
- config: { matrix: V.config }
1137
- }, h = O(E, C, i, !1);
1138
- return {
1139
- status: "ready",
1140
- value: {
1141
- assembled: {
1142
- card: E,
1143
- context: { ...h.context, resolvedDateFields: V.fields },
1144
- inputContext: h.inputContext
1145
- },
1146
- matrix: V
1147
- }
1148
- };
1149
- } catch (b) {
1150
- return {
1151
- status: "blocked",
1152
- reason: "configuration",
1153
- message: b instanceof Error ? b.message : "Card configuration is invalid.",
1154
- context: g
1155
- };
1156
- }
1157
- }, c = u(e, t);
1158
- if (c.status === "blocked")
1159
- return {
1160
- status: "blocked",
1161
- cardId: l,
1162
- mappingDispositions: [],
1163
- reason: c.reason,
1164
- missingRequiredLabels: [],
1165
- message: c.message
1166
- };
1167
- const { assembled: s, matrix: d } = c.value, f = ei(
1168
- a,
1169
- n,
1170
- i.calendar
1171
- ), p = s.context.filterCompilationInput, v = ft(a);
1172
- try {
1173
- const I = N(s.card, p), C = d && v && I.status === "ready" && I.filterValues.some((M) => M.filterId === v.id);
1174
- let g = f.allowGlobalDateMinutePrecision;
1175
- if (C) {
1176
- const M = (m = p.dashboardInputContext) == null ? void 0 : m.inputs.find(
1177
- (h) => h.kind === "filter" && h.filter.id === v.id
1178
- ), P = pt(a, v).filter(
1179
- ({ card: h, sheet: y }) => !M || se(M, {
1180
- cardId: h.id,
1181
- sheetId: y.id,
1182
- sheetKind: le(y) ? "document" : "dashboard"
1183
- })
1184
- ).map(({ card: h, sheet: y }) => ({
1185
- card: h,
1186
- value: h.id === l ? c : u(h, { kind: "sheet", sheetId: y.id })
1187
- })), V = new Map(
1188
- P.map(({ card: h, value: y }) => [
1189
- h.id,
1190
- y.status === "ready" ? y.value.assembled.card : null
1191
- ])
1192
- ), q = new Map(
1193
- P.map(({ card: h, value: y }) => {
1194
- var T;
1195
- return [
1196
- h.id,
1197
- y.status === "ready" ? (T = y.value.matrix) == null ? void 0 : T.fields : void 0
1198
- ];
1199
- })
1200
- ), x = P.flatMap(
1201
- ({ card: h, value: y }) => {
1202
- const T = h.id, z = y.status === "ready" ? y.value.assembled.context : y.context;
1203
- if (!z) return [T];
1204
- const Pe = y.status === "ready" ? y.value.assembled.card : h;
1205
- try {
1206
- const L = N(
1207
- Pe,
1208
- z.filterCompilationInput
1209
- );
1210
- return L.status === "blocked" || L.filterValues.some((Te) => Te.filterId === v.id) ? [T] : [];
1211
- } catch {
1212
- return V.set(T, null), [T];
1213
- }
1214
- }
1215
- ), E = G(
1216
- a,
1217
- n,
1218
- v,
1219
- V,
1220
- q,
1221
- x
1222
- );
1223
- if ((F = E.unresolvedCardIds) != null && F.length)
1224
- return {
1225
- status: "blocked",
1226
- cardId: l,
1227
- mappingDispositions: [],
1228
- reason: "coverage",
1229
- missingRequiredLabels: [],
1230
- message: `Date precision requires field metadata and valid inputs for: ${E.unresolvedCardIds.join(", ")}.`
1231
- };
1232
- g = E.allEligibleTargetsAreDateTime;
1233
- }
1234
- const D = Ve(s, f, g);
1235
- if (D.status === "blocked")
1236
- return {
1237
- status: "blocked",
1238
- cardId: D.cardId,
1239
- mappingDispositions: D.mappingDispositions,
1240
- reason: D.reason,
1241
- missingRequiredLabels: D.missingRequiredLabels,
1242
- ...D.reason === "requiredInput" ? { message: Qt(D.missingRequiredLabels) } : {}
1243
- };
1244
- const b = o && !d ? ti(s, f) : void 0;
1245
- return {
1246
- ...D,
1247
- ...d ? { matrix: d } : {},
1248
- // The whole request a card runs with: the contract's payload and its
1249
- // extras (server pagination, table totals) from the one extras owner,
1250
- // on the first page a new viewer opens (ledger P3-78).
1251
- ...(b == null ? void 0 : b.status) === "ready" ? {
1252
- request: {
1253
- ...b.requestPayloadBase,
1254
- ...Ke({
1255
- card: s.card,
1256
- finalConfig: s.context.finalConfig,
1257
- documentSection: t.kind === "documentSection" ? {} : void 0,
1258
- page: Ue(s.card)
1259
- })
1260
- }
1261
- } : {}
1262
- };
1263
- } catch (I) {
1264
- return {
1265
- status: "blocked",
1266
- cardId: l,
1267
- mappingDispositions: [],
1268
- reason: "configuration",
1269
- missingRequiredLabels: [],
1270
- message: I instanceof Error ? I.message : "Card filter configuration is invalid."
1271
- };
1272
- }
1273
- }
1274
- function ni(e) {
1275
- const t = e.editor ? {
1276
- ...e.inlineFilterValuesMap,
1277
- ...Object.fromEntries(
1278
- Object.entries(e.editor.inlineFilterValuesMap).filter(
1279
- (i) => i[1] !== void 0
1280
- )
1281
- )
1282
- } : e.inlineFilterValuesMap;
1283
- return {
1284
- dashboardInputValues: e.dashboardInputValues,
1285
- adHocFilterValues: e.adHocFilterValues,
1286
- controlValues: e.controlValues,
1287
- inlineFilterValuesMap: t,
1288
- cardControlValuesMap: e.cardControlValuesMap
1289
- };
1290
- }
1291
- function O(e, t, i, n) {
1292
- const { dashboard: r } = i, o = ni(i), a = t.kind === "documentSection" ? {
1293
- ...Wt({
1294
- card: e,
1295
- dashboard: r,
1296
- runtime: t.section,
1297
- dashboardRuntimeValues: o,
1298
- calendar: i.calendar
1299
- }),
1300
- selectedSheetId: t.section.sheetId,
1301
- includeAuthoredFilters: n
1302
- } : oi(e, t.sheetId, i, o, n);
1303
- return {
1304
- card: a.card,
1305
- params: a,
1306
- context: Lt(a),
1307
- inputContext: a.dashboardInputContext
1308
- };
1309
- }
1310
- function oi(e, t, i, n, r) {
1311
- var u, c;
1312
- const { dashboard: o, transientContexts: a } = i, l = Y({
1313
- dashboard: o,
1314
- dashboardInputValues: n.dashboardInputValues,
1315
- transientContexts: a
1316
- }) ? Z({
1317
- transientContexts: a,
1318
- dashboard: o,
1319
- sheetId: t,
1320
- card: e,
1321
- runtimeValues: n,
1322
- calendar: i.calendar
1323
- }) : void 0;
1324
- return {
1325
- card: e,
1326
- dashboard: o,
1327
- transientContexts: a,
1328
- cardViewState: (u = i.cardViewStates) == null ? void 0 : u[e.id],
1329
- viewerTableSettings: i.editor || (c = i.viewerTableSettings) == null ? void 0 : c[e.id],
1330
- adHocFilterValues: n.adHocFilterValues,
1331
- selectedSheetId: t,
1332
- inlineFilterValuesMap: n.inlineFilterValuesMap,
1333
- dashboardControls: o.controls,
1334
- dashboardControlValues: n.controlValues,
1335
- cardControlValuesMap: n.cardControlValuesMap,
1336
- // Keep a selection-only context so the query has one resolved-input contract.
1337
- dashboardInputContext: l && (l.inputs.length > 0 || l.selections.length > 0) ? l : void 0,
1338
- includeAuthoredFilters: r
1339
- };
1340
- }
1341
- function he({ card: e, context: t }, i) {
1342
- return J({
1343
- card: e,
1344
- cardConfig: t.queryRelevantConfig,
1345
- resolvedFields: t.resolvedDateFields,
1346
- semanticExecutionPayload: i.semanticExecutionPayload
1347
- });
1348
- }
1349
- function Ve(e, t, i) {
1350
- const { card: n } = e, r = he(e, t), o = ye(n, e.context, {
1351
- resolvedPrimaryDateField: r,
1352
- timezone: t.calendarContext.tz,
1353
- allowMinutePrecision: i
1354
- });
1355
- return o.status === "blocked" ? { ...o, card: n, resolvedPrimaryDateField: r } : {
1356
- status: "ready",
1357
- card: n,
1358
- queryContext: o.queryContext,
1359
- compiledFilters: o.compiledFilters,
1360
- resolvedPrimaryDateField: r
1361
- };
1362
- }
1363
- function wi({
1364
- dashboard: e,
1365
- dashboardInputValues: t,
1366
- adHocFilterValues: i,
1367
- calendar: n,
1368
- selectedSheetId: r,
1369
- sheetSelection: o = "current",
1370
- dashboardControlValues: a,
1371
- cardControlValuesMap: l,
1372
- semanticExecutionPayload: u,
1373
- timezone: c
1374
- }) {
1375
- const s = e ? [...de(e)] : void 0, d = r ?? null, f = (C) => {
1376
- var g;
1377
- return e ? Xe({
1378
- dashboard: e,
1379
- runtimeValues: { dashboardInputValues: t },
1380
- adHocFilterValues: i,
1381
- sheetId: C,
1382
- sheetKind: le(
1383
- (g = e.sheets) == null ? void 0 : g.find((D) => D.id === C)
1384
- ) ? "document" : "dashboard",
1385
- calendar: n
1386
- }) : [];
1387
- }, p = o === "all" ? Array.from(
1388
- new Map(
1389
- ((e == null ? void 0 : e.sheets) || []).flatMap(
1390
- (C) => f(C.id).map(
1391
- (g) => [g.filterId, g]
1392
- )
1393
- )
1394
- ).values()
1395
- ) : f(d), v = {
1396
- ...a || {}
1397
- }, m = o === "all" ? B({ sheets: (e == null ? void 0 : e.sheets) || [] }) : d ? B({ sheets: (e == null ? void 0 : e.sheets) || [] }).filter(
1398
- (C) => C.sheet.id === d
1399
- ) : [];
1400
- for (const C of m)
1401
- Object.assign(v, (l == null ? void 0 : l[C.card.id]) || {});
1402
- const F = mt({
1403
- filterDefinitions: s,
1404
- filterValues: p
1405
- }), I = St({
1406
- filters: s,
1407
- filterValues: F,
1408
- dashboard: e,
1409
- semanticExecutionPayload: u,
1410
- timezone: c
1411
- });
1412
- return {
1413
- selectedSheetId: d,
1414
- filterValues: I,
1415
- controlValues: v
1416
- };
1417
- }
1418
- function ki({
1419
- dashboard: e,
1420
- cardId: t,
1421
- transientContexts: i,
1422
- cardViewStates: n,
1423
- viewerTableSettings: r,
1424
- semanticExecutionPayload: o,
1425
- adHocFilterValues: a,
1426
- inlineFilterValuesMap: l,
1427
- dashboardControlValues: u,
1428
- cardControlValuesMap: c,
1429
- dashboardInputValues: s,
1430
- calendar: d,
1431
- matrixCatalog: f,
1432
- cardOverride: p,
1433
- sheetId: v,
1434
- documentSection: m,
1435
- editor: F,
1436
- withRequest: I
1437
- }) {
1438
- var D;
1439
- if (!e)
1440
- return null;
1441
- p && !H(e, t) && v && (e = { ...e, sheets: (D = e.sheets) == null ? void 0 : D.map((b) => b.id === v ? { ...b, cards: [...b.cards ?? [], p] } : b) });
1442
- const C = H(e, t);
1443
- if (!C)
1444
- return null;
1445
- const g = ii({
1446
- card: p ?? C.card,
1447
- place: m ? { kind: "documentSection", section: m } : { kind: "sheet", sheetId: C.sheet.id },
1448
- source: {
1449
- dashboard: e,
1450
- adHocFilterValues: a,
1451
- controlValues: u,
1452
- inlineFilterValuesMap: l,
1453
- cardControlValuesMap: c ? Object.fromEntries(
1454
- Object.entries(c).filter(
1455
- (b) => b[1] !== void 0
1456
- )
1457
- ) : void 0,
1458
- dashboardInputValues: s,
1459
- transientContexts: i,
1460
- cardViewStates: n,
1461
- viewerTableSettings: r,
1462
- calendar: d,
1463
- ...F ? { editor: F } : {}
1464
- },
1465
- semanticExecutionPayload: o,
1466
- matrixCatalog: f,
1467
- withRequest: I
1468
- });
1469
- return g.status === "blocked" ? g : {
1470
- status: "ready",
1471
- card: p ?? C.card,
1472
- sheetId: C.sheet.id,
1473
- queryContext: g.queryContext,
1474
- ...g.matrix ? { matrix: g.matrix } : {},
1475
- ...g.request ? { request: g.request } : {}
1476
- };
1477
- }
1478
- function ri(e, t) {
1479
- const i = gt({
1480
- inputs: e.inputs,
1481
- dashboardFilters: [...de(e)]
1482
- }), n = Me(e, t);
1483
- return i.filter(
1484
- (r) => se(r, { sheetId: t, sheetKind: "document" }) || r.kind === "filter" && (r.runtimeScope === "shared" || r.runtimeScope === "perSheet") && ue(r, n)
1485
- );
1486
- }
1487
- function Me(e, t) {
1488
- return {
1489
- ...Ct(e).get(t) ?? {
1490
- sheetId: t,
1491
- cardIds: /* @__PURE__ */ new Set()
1492
- },
1493
- sheetKind: "document"
1494
- };
1495
- }
1496
- function Ai(e, t) {
1497
- const i = Me(e, t);
1498
- return (e.inputs || []).some(
1499
- (n) => ue(n, i)
1500
- );
1501
- }
1502
- function ai(e) {
1503
- const t = {
1504
- id: e.id,
1505
- label: e.label,
1506
- variableName: e.variableName,
1507
- requiredAtExecution: !!e.requiredAtExecution,
1508
- documentPlacement: "input_bar",
1509
- description: e.description
1510
- };
1511
- return e.kind === "filter" ? {
1512
- ...t,
1513
- kind: "filter",
1514
- filter: e.filter,
1515
- exports: e.exports
1516
- } : {
1517
- ...t,
1518
- kind: "control",
1519
- control: e.control,
1520
- exports: e.exports
1521
- };
1522
- }
1523
- function Bi({
1524
- control: e,
1525
- existingInputs: t,
1526
- sheetId: i,
1527
- inputId: n
1528
- }) {
1529
- const r = ce(
1530
- e.id || e.label,
1531
- t
1532
- ), o = e.id === r ? e : { ...e, id: r };
1533
- return {
1534
- id: n || ee(),
1535
- kind: "control",
1536
- label: o.label,
1537
- variableName: r,
1538
- requiredAtExecution: o.requiredAtExecution,
1539
- scope: { kind: "sheets", sheetIds: [i] },
1540
- runtimeScope: "perSheet",
1541
- presentation: { placement: "toolbar" },
1542
- control: o,
1543
- exports: X(o)
1544
- };
1545
- }
1546
- function Ni({
1547
- input: e,
1548
- allInputs: t,
1549
- label: i,
1550
- variableName: n
1551
- }) {
1552
- const r = (i == null ? void 0 : i.trim()) || e.label, o = n === void 0 ? e.variableName : ce(
1553
- n,
1554
- t.filter((l) => l.id !== e.id)
1555
- );
1556
- if (e.kind === "filter") {
1557
- if (!e.filter)
1558
- throw new Error(
1559
- `Referenced dashboard input '${e.id}' cannot be edited as a document input.`
1560
- );
1561
- const l = {
1562
- ...e.filter,
1563
- title: r,
1564
- variableName: o
1565
- };
1566
- return {
1567
- ...e,
1568
- label: r,
1569
- variableName: o,
1570
- filter: l,
1571
- exports: We(l)
1572
- };
1573
- }
1574
- const a = {
1575
- ...e.control,
1576
- id: o,
1577
- label: r
1578
- };
1579
- return {
1580
- ...e,
1581
- label: r,
1582
- variableName: o,
1583
- requiredAtExecution: a.requiredAtExecution,
1584
- control: a,
1585
- exports: X(a)
1586
- };
1587
- }
1588
- function Oi(e, t, i) {
1589
- return !t || !i || t === i ? e : {
1590
- ...e,
1591
- sections: e.sections.map(
1592
- (n) => Se(
1593
- n,
1594
- (r) => si(r, t, i)
1595
- )
1596
- )
1597
- };
1598
- }
1599
- function si(e, t, i) {
1600
- var o;
1601
- const n = `[[param.${t}]]`, r = `[[param.${i}]]`;
1602
- return {
1603
- ...e,
1604
- ...(o = e.sql) != null && o.includes(n) ? { sql: e.sql.split(n).join(r) } : {},
1605
- ...e.controls ? {
1606
- controls: e.controls.map(
1607
- (a) => a.id === t ? { ...a, id: i } : a
1608
- )
1609
- } : {},
1610
- ...e.controlBindings ? {
1611
- controlBindings: e.controlBindings.map((a) => ({
1612
- ...a,
1613
- controlId: a.controlId === t ? i : a.controlId,
1614
- ...a.target === "sql_param" && a.paramId === t ? { paramId: i } : {}
1615
- }))
1616
- } : {}
1617
- };
1618
- }
1619
- function Gi(e, t) {
1620
- return e.kind === "filter" && Je(
1621
- ai(e),
1622
- t
1623
- );
1624
- }
1625
- function _i(e) {
1626
- var i;
1627
- const t = {};
1628
- for (const n of e)
1629
- n.kind === "filter" && (t[n.id] = ((i = n.slot) == null ? void 0 : i.status) === "cleared" ? void 0 : n.filterValue);
1630
- return t;
1631
- }
1632
- function zi(e) {
1633
- var i;
1634
- const t = {};
1635
- for (const n of e)
1636
- n.kind === "control" && ((i = n.slot) == null ? void 0 : i.status) === "set" && (t[n.id] = n.controlValue);
1637
- return t;
1638
- }
1639
- function Li({
1640
- dashboard: e,
1641
- sheetId: t,
1642
- filterValuesByInputId: i,
1643
- controlValuesByInputId: n
1644
- }) {
1645
- const r = ri(e, t);
1646
- let o = {};
1647
- for (const a of r) {
1648
- if (a.kind === "filter" && i && Object.prototype.hasOwnProperty.call(i, a.id)) {
1649
- const l = i[a.id];
1650
- o = Q(
1651
- o,
1652
- a,
1653
- { sheetId: t },
1654
- l ? {
1655
- status: "set",
1656
- value: {
1657
- kind: "filter",
1658
- filterValue: l
1659
- }
1660
- } : { status: "cleared" }
1661
- );
1662
- }
1663
- if (a.kind === "control" && n && Object.prototype.hasOwnProperty.call(n, a.id)) {
1664
- const l = n[a.id];
1665
- o = Q(
1666
- o,
1667
- a,
1668
- { sheetId: t },
1669
- l === void 0 ? { status: "cleared" } : {
1670
- status: "set",
1671
- value: {
1672
- kind: "control",
1673
- value: l
1674
- }
1675
- }
1676
- );
1677
- }
1678
- }
1679
- return U({
1680
- dashboard: e,
1681
- dashboardInputValues: o,
1682
- sheetId: t
1683
- });
1684
- }
1685
- export {
1686
- Oi as A,
1687
- Li as B,
1688
- _i as C,
1689
- zi as D,
1690
- Ai as E,
1691
- kt as M,
1692
- hi as a,
1693
- Vi as b,
1694
- ki as c,
1695
- Bi as d,
1696
- Ri as e,
1697
- ei as f,
1698
- ri as g,
1699
- Qt as h,
1700
- wi as i,
1701
- Gt as j,
1702
- Si as k,
1703
- Ei as l,
1704
- ti as m,
1705
- qi as n,
1706
- Ti as o,
1707
- ii as p,
1708
- xi as q,
1709
- _t as r,
1710
- Pi as s,
1711
- Mi as t,
1712
- ge as u,
1713
- N as v,
1714
- Ce as w,
1715
- ai as x,
1716
- Gi as y,
1717
- Ni as z
1718
- };