react-semaphor 0.1.326 → 0.1.327

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 (64) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +1 -1
  3. package/dist/brand-studio/index.cjs +1 -1
  4. package/dist/brand-studio/index.js +4 -4
  5. package/dist/chunks/{braces-dHeaioTd.js → braces-B6qRDu1H.js} +1 -1
  6. package/dist/chunks/{braces-DVaMJoCd.js → braces-BGWZEnQJ.js} +1 -1
  7. package/dist/chunks/{calendar-preferences-dialog--2jD-eKu.js → calendar-preferences-dialog-CjwbE_82.js} +3 -3
  8. package/dist/chunks/{calendar-preferences-dialog-mqU_uOmY.js → calendar-preferences-dialog-fkLUMJyR.js} +1 -1
  9. package/dist/chunks/{chevrons-up-down-CLbzBHoI.js → chevrons-up-down-BpsogQvv.js} +1 -1
  10. package/dist/chunks/{chevrons-up-down-DNQE-uEp.js → chevrons-up-down-xG-bVFD9.js} +1 -1
  11. package/dist/chunks/{dashboard-briefing-launcher-DguNfFr8.js → dashboard-briefing-launcher-Co57xBfS.js} +2 -2
  12. package/dist/chunks/{dashboard-briefing-launcher-DsjXUPFq.js → dashboard-briefing-launcher-Cy1nWZRW.js} +713 -719
  13. package/dist/chunks/{dashboard-controls-DgNkM1yT.js → dashboard-controls-BWnVEFJq.js} +7 -7
  14. package/dist/chunks/{dashboard-controls-XCa9PZuU.js → dashboard-controls-C7rOGZO-.js} +1 -1
  15. package/dist/chunks/{dashboard-json-DkA6Bf0Y.js → dashboard-json-BpRNSsF3.js} +2 -2
  16. package/dist/chunks/{dashboard-json-DiBd65Xf.js → dashboard-json-DBPMknGo.js} +1 -1
  17. package/dist/chunks/date-formatter-B4EBSe9C.js +1 -0
  18. package/dist/chunks/date-formatter-CzcPZx39.js +416 -0
  19. package/dist/chunks/edit-dashboard-visual-B2vkIKEa.js +178 -0
  20. package/dist/chunks/{edit-dashboard-visual-Q5hW5MXk.js → edit-dashboard-visual-CYf26co_.js} +8241 -7784
  21. package/dist/chunks/{index-B1-46PoR.js → index-BD90s-wf.js} +208 -202
  22. package/dist/chunks/{index-DwfDwtv2.js → index-DTlbYpxd.js} +26702 -26334
  23. package/dist/chunks/{palette-DtmNws9a.js → palette-CSF7IVJn.js} +1 -1
  24. package/dist/chunks/{palette-DpcvHAiY.js → palette-CWgEPBoG.js} +1 -1
  25. package/dist/chunks/{resource-management-panel-CGwWKZOP.js → resource-management-panel-D6nbfJY3.js} +1 -1
  26. package/dist/chunks/{resource-management-panel-D2oAQkKi.js → resource-management-panel-D893Onv8.js} +3 -3
  27. package/dist/chunks/{save-Cv_XRb94.js → save-CtQbSub2.js} +1 -1
  28. package/dist/chunks/{save-BY7WF62U.js → save-DRdFKF57.js} +1 -1
  29. package/dist/chunks/switch-DJJJD_g1.js +168 -0
  30. package/dist/chunks/{switch-j3AThLFk.js → switch-DKf6vHfP.js} +2447 -2405
  31. package/dist/chunks/{use-create-flow-overlay-state-BQPXP0AM.js → use-create-flow-overlay-state-C4LgoK8q.js} +1 -1
  32. package/dist/chunks/{use-create-flow-overlay-state-CP6GDQAX.js → use-create-flow-overlay-state-p21zs2p6.js} +4 -4
  33. package/dist/chunks/{use-visual-utils-CSXU-96k.js → use-visual-utils-BKBua6o4.js} +2 -2
  34. package/dist/chunks/{use-visual-utils-NpOW5uZ1.js → use-visual-utils-BqWm0QeW.js} +1 -1
  35. package/dist/chunks/{validators-DvTxl9i0.js → validators-DDAweCzB.js} +67 -48
  36. package/dist/chunks/validators-odlRJblR.js +2 -0
  37. package/dist/dashboard/index.cjs +1 -1
  38. package/dist/dashboard/index.js +1 -1
  39. package/dist/dashboard-authoring/index.cjs +3 -3
  40. package/dist/dashboard-authoring/index.js +907 -527
  41. package/dist/data-app-sdk/index.cjs +1 -1
  42. package/dist/data-app-sdk/index.js +1 -1
  43. package/dist/format-utils/index.cjs +4 -4
  44. package/dist/format-utils/index.js +22 -21
  45. package/dist/index.cjs +1 -1
  46. package/dist/index.js +7 -7
  47. package/dist/style.css +1 -1
  48. package/dist/surfboard/index.cjs +1 -1
  49. package/dist/surfboard/index.js +2 -2
  50. package/dist/types/analytics-protocol.d.ts +1 -0
  51. package/dist/types/dashboard-authoring.d.ts +79 -2
  52. package/dist/types/dashboard.d.ts +17 -2
  53. package/dist/types/data-app-sdk.d.ts +1 -0
  54. package/dist/types/format-utils.d.ts +25 -0
  55. package/dist/types/main.d.ts +65 -10
  56. package/dist/types/shared.d.ts +17 -2
  57. package/dist/types/surfboard.d.ts +17 -2
  58. package/dist/types/types.d.ts +32 -3
  59. package/package.json +1 -1
  60. package/dist/chunks/date-formatter-D9Bvw5Qk.js +0 -1
  61. package/dist/chunks/date-formatter-DyIOb6uC.js +0 -333
  62. package/dist/chunks/edit-dashboard-visual-BC9eOc4U.js +0 -178
  63. package/dist/chunks/switch-5aQ_jcLH.js +0 -168
  64. package/dist/chunks/validators-DJUMR5An.js +0 -2
@@ -1,407 +1,687 @@
1
- import { a as Z, v as ee } from "../chunks/validators-DvTxl9i0.js";
2
- const te = [
1
+ import { a as be, v as Ie } from "../chunks/validators-DDAweCzB.js";
2
+ const ge = [
3
3
  "lg",
4
4
  "md",
5
5
  "sm",
6
6
  "xs",
7
7
  "xxs"
8
- ], $ = 10;
9
- function f(e, t, a) {
10
- return a ? { code: e, message: t, cardId: a } : { code: e, message: t };
8
+ ], M = 10;
9
+ function _(e) {
10
+ return e && typeof e == "object" ? e : null;
11
11
  }
12
- function D(e) {
12
+ function k(e) {
13
+ return typeof e == "string" ? e : null;
14
+ }
15
+ function ye(e) {
16
+ var t, n, r;
17
+ return !!(e && typeof e == "object") && (((t = _(e)) == null ? void 0 : t.kind) === "semantic" || ((n = _(e)) == null ? void 0 : n.kind) === "physical" || ((r = _(e)) == null ? void 0 : r.kind) === "sql");
18
+ }
19
+ function N(e) {
20
+ return ye(e) ? e.kind === "semantic" ? !!(e.domainId && e.datasetName) : e.kind === "physical" ? !!(e.connectionId && e.tableName) : !1 : !1;
21
+ }
22
+ function ee(e) {
23
+ return e.kind === "semantic" ? [
24
+ "semantic",
25
+ e.domainId,
26
+ e.datasetId || "",
27
+ e.datasetName
28
+ ].join(":") : e.kind === "physical" ? [
29
+ "physical",
30
+ e.connectionId,
31
+ e.databaseName || "",
32
+ e.schemaName || "",
33
+ e.tableName
34
+ ].join(":") : ["sql", e.connectionId, e.sql].join(":");
35
+ }
36
+ function O(e, t) {
37
+ return e.domainId !== t.domainId ? !1 : e.datasetId && t.datasetId ? e.datasetId === t.datasetId : e.datasetName === t.datasetName;
38
+ }
39
+ function ae(e, t) {
40
+ return e.kind === "semantic" && t.kind === "semantic" ? O(e, t) : ee(e) === ee(t);
41
+ }
42
+ function _e(e, t) {
43
+ return e.kind !== "semantic" || t.kind !== "semantic" ? e : {
44
+ ...e,
45
+ datasetId: e.datasetId || t.datasetId,
46
+ label: e.label || t.label,
47
+ connectionId: e.connectionId || t.connectionId
48
+ };
49
+ }
50
+ function q(e) {
51
+ const t = [];
52
+ for (const n of e) {
53
+ const r = t.findIndex(
54
+ (i) => ae(i, n)
55
+ );
56
+ r === -1 ? t.push(n) : t[r] = _e(
57
+ t[r],
58
+ n
59
+ );
60
+ }
61
+ return t;
62
+ }
63
+ function wt(e) {
64
+ return q(e)[0];
65
+ }
66
+ function z(e, t) {
67
+ return e.kind !== "semantic" || e.connectionId || (t == null ? void 0 : t.kind) !== "semantic" || !O(e, t) || !t.connectionId ? e : { ...e, connectionId: t.connectionId };
68
+ }
69
+ function L(e) {
70
+ return N(e) ? e : void 0;
71
+ }
72
+ function te(e, t) {
73
+ if (!(e.kind !== "semantic" || e.connectionId))
74
+ return t.find(
75
+ (n) => (n == null ? void 0 : n.kind) === "semantic" && O(e, n) && !!n.connectionId
76
+ );
77
+ }
78
+ function v(e, t) {
79
+ const n = L(e == null ? void 0 : e.source);
80
+ return n ? z(n, t) : void 0;
81
+ }
82
+ function we({
83
+ explicitSource: e,
84
+ field: t,
85
+ defaultSource: n,
86
+ fallbackSources: r
87
+ }) {
88
+ const i = [n, ...r || []], a = L(e), s = a ? z(
89
+ a,
90
+ te(a, i)
91
+ ) : void 0;
92
+ if (s)
93
+ return s;
94
+ if (e !== void 0)
95
+ return;
96
+ const d = v(t, n), o = d ? z(
97
+ d,
98
+ te(d, i)
99
+ ) : void 0;
100
+ if (o)
101
+ return o;
102
+ if ((t == null ? void 0 : t.source) === void 0)
103
+ return L(n);
104
+ }
105
+ function ve(e, t) {
106
+ if (!(e != null && e.name) || !(t != null && t.name) || e.name !== t.name)
107
+ return !1;
108
+ const n = v(e), r = v(t);
109
+ return !n || !r ? !0 : ae(n, r);
110
+ }
111
+ function A(e) {
112
+ var t;
113
+ return k((t = _(e)) == null ? void 0 : t.kind);
114
+ }
115
+ function ie(e) {
116
+ var t, n;
117
+ return A(e) !== "semantic" ? null : ((n = k((t = _(e)) == null ? void 0 : t.domainId)) == null ? void 0 : n.trim()) || null;
118
+ }
119
+ function ke(e) {
120
+ var t;
121
+ return A(e) !== "semantic" ? null : k((t = _(e)) == null ? void 0 : t.datasetName);
122
+ }
123
+ function Se(e) {
124
+ var t;
125
+ return A(e) !== "semantic" ? null : k((t = _(e)) == null ? void 0 : t.datasetId);
126
+ }
127
+ function Ae(e) {
128
+ var t;
129
+ return A(e) !== "physical" ? null : k((t = _(e)) == null ? void 0 : t.connectionId);
130
+ }
131
+ function Ce(e) {
132
+ var t;
133
+ return A(e) !== "physical" ? null : k((t = _(e)) == null ? void 0 : t.tableName);
134
+ }
135
+ function xe(e) {
136
+ var t;
137
+ return A(e) !== "physical" ? "" : k((t = _(e)) == null ? void 0 : t.databaseName) || "";
138
+ }
139
+ function De(e) {
140
+ var t;
141
+ return A(e) !== "physical" ? "" : k((t = _(e)) == null ? void 0 : t.schemaName) || "";
142
+ }
143
+ function Fe(e) {
144
+ if (e.analyticsIntent && typeof e.analyticsIntent == "object" && "source" in e.analyticsIntent)
145
+ return e.analyticsIntent.source;
146
+ }
147
+ function Ne({
148
+ datasets: e,
149
+ requireAtLeastOne: t
150
+ }) {
151
+ if (t && e.length < 1)
152
+ return { ok: !1, issue: "invalid_dataset_count" };
153
+ if (e.length <= 1)
154
+ return { ok: !0 };
155
+ const n = e.map(ie), r = new Set(n.filter(Boolean));
156
+ return n.some((i) => !i) || r.size !== 1 ? { ok: !1, issue: "invalid_multi_dataset_scope" } : { ok: !0 };
157
+ }
158
+ function W(e, t) {
159
+ if (!t)
160
+ return !1;
161
+ if (t.kind === "semantic") {
162
+ const n = Se(e);
163
+ return ie(e) === t.domainId ? n && t.datasetId ? n === t.datasetId : ke(e) === t.datasetName : !1;
164
+ }
165
+ return t.kind === "physical" ? Ae(e) === t.connectionId && Ce(e) === t.tableName && xe(e) === (t.databaseName || "") && De(e) === (t.schemaName || "") : !1;
166
+ }
167
+ function vt(e, t) {
168
+ return e.find(
169
+ (n) => W(n, t)
170
+ );
171
+ }
172
+ function u(e, t, n) {
173
+ return n ? { code: e, message: t, cardId: n } : { code: e, message: t };
174
+ }
175
+ function $(e) {
13
176
  const t = /* @__PURE__ */ new Set();
14
- for (const a of e) {
15
- if (t.has(a))
16
- return a;
17
- t.add(a);
177
+ for (const n of e) {
178
+ if (t.has(n))
179
+ return n;
180
+ t.add(n);
18
181
  }
19
182
  return null;
20
183
  }
21
- function ae(e) {
22
- var w, C;
184
+ function se({
185
+ card: e,
186
+ datasets: t,
187
+ errors: n
188
+ }) {
189
+ if (e.type === "text")
190
+ return;
191
+ const r = Fe(e);
192
+ if (!r) {
193
+ if (t.length <= 1)
194
+ return;
195
+ n.push(
196
+ u(
197
+ "missing_card_analytics_source",
198
+ "Multi-dataset dashboard cards must include analytics intent with a source so the materializer can choose the correct dataset.",
199
+ e.id
200
+ )
201
+ );
202
+ return;
203
+ }
204
+ t.some((i) => W(i, r)) || n.push(
205
+ u(
206
+ "invalid_card_analytics_source",
207
+ "Dashboard cards with an explicit analytics source must use one of the selected datasets.",
208
+ e.id
209
+ )
210
+ );
211
+ }
212
+ function Te(e) {
213
+ var t;
214
+ return e ? [
215
+ (t = e.dateFieldRef) == null ? void 0 : t.source,
216
+ ...Array.isArray(e.dimensionRefs) ? e.dimensionRefs.map((n) => n.source) : []
217
+ ].filter(
218
+ (n) => !!n
219
+ ) : [];
220
+ }
221
+ function oe({
222
+ card: e,
223
+ datasets: t,
224
+ errors: n
225
+ }) {
226
+ if (e.type !== "text") {
227
+ for (const r of Te(e.query))
228
+ if (r && !t.some(
229
+ (i) => W(i, r)
230
+ )) {
231
+ n.push(
232
+ u(
233
+ "invalid_card_query_source",
234
+ "Dashboard card query field references must use one of the selected datasets.",
235
+ e.id
236
+ )
237
+ );
238
+ return;
239
+ }
240
+ }
241
+ }
242
+ function $e(e, t) {
243
+ return e.length === t.length && e.every((n, r) => n === t[r]);
244
+ }
245
+ function de({
246
+ card: e,
247
+ errors: t
248
+ }) {
249
+ if (e.type === "text" || !e.query)
250
+ return;
251
+ const { dateField: n, dateFieldRef: r, dimensions: i, dimensionRefs: a } = e.query;
252
+ if (r && r.name !== n) {
253
+ t.push(
254
+ u(
255
+ "invalid_card_query_ref",
256
+ "Dashboard card source-aware date field reference must match the query date field.",
257
+ e.id
258
+ )
259
+ );
260
+ return;
261
+ }
262
+ if (!Array.isArray(a))
263
+ return;
264
+ const s = Array.isArray(i) ? i : [], d = a.map((o) => o.name);
265
+ $e(d, s) || t.push(
266
+ u(
267
+ "invalid_card_query_ref",
268
+ "Dashboard card source-aware dimension references must match the query dimensions.",
269
+ e.id
270
+ )
271
+ );
272
+ }
273
+ function ce({
274
+ datasets: e,
275
+ errors: t,
276
+ requireAtLeastOne: n
277
+ }) {
278
+ const r = Ne({
279
+ datasets: e,
280
+ requireAtLeastOne: n
281
+ });
282
+ if (!r.ok) {
283
+ if (r.issue === "invalid_dataset_count") {
284
+ t.push(
285
+ u(
286
+ "invalid_dataset_count",
287
+ "Dashboard authoring requires at least one selected dataset."
288
+ )
289
+ );
290
+ return;
291
+ }
292
+ t.push(
293
+ u(
294
+ "invalid_multi_dataset_scope",
295
+ "Multi-dataset dashboard authoring is limited to semantic datasets from one domain."
296
+ )
297
+ );
298
+ }
299
+ }
300
+ function Me(e) {
301
+ var m, w;
23
302
  const t = [];
24
303
  if (!e || typeof e != "object")
25
304
  return {
26
305
  ok: !1,
27
306
  errors: [
28
- f(
307
+ u(
29
308
  "invalid_plan",
30
309
  "Dashboard plan must be a structured object."
31
310
  )
32
311
  ],
33
312
  warnings: []
34
313
  };
35
- const a = e, n = [...a.warnings || []];
36
- a.version !== 1 && t.push(f("invalid_version", "Dashboard plan version must be 1.")), (w = a.title) != null && w.trim() || t.push(f("missing_title", "Dashboard plan needs a title."));
37
- const i = Array.isArray(a.datasets) ? a.datasets : [], r = Array.isArray(a.sheets) ? a.sheets : [];
38
- i.length !== 1 && t.push(
39
- f(
40
- "invalid_dataset_count",
41
- "MVP dashboard authoring requires exactly one selected dataset."
42
- )
43
- ), r.length !== 1 && t.push(
44
- f(
314
+ const n = e, r = [...n.warnings || []];
315
+ n.version !== 1 && t.push(u("invalid_version", "Dashboard plan version must be 1.")), (m = n.title) != null && m.trim() || t.push(u("missing_title", "Dashboard plan needs a title."));
316
+ const i = Array.isArray(n.datasets) ? n.datasets : [], a = Array.isArray(n.sheets) ? n.sheets : [];
317
+ ce({ datasets: i, errors: t, requireAtLeastOne: !0 }), a.length !== 1 && t.push(
318
+ u(
45
319
  "invalid_sheet_count",
46
320
  "MVP dashboard authoring creates exactly one dashboard sheet."
47
321
  )
48
322
  );
49
- const d = r[0];
50
- d && d.kind !== "dashboard" && t.push(
51
- f("invalid_sheet_kind", 'Generated sheet must use kind "dashboard".')
323
+ const s = a[0];
324
+ s && s.kind !== "dashboard" && t.push(
325
+ u("invalid_sheet_kind", 'Generated sheet must use kind "dashboard".')
52
326
  );
53
- const l = (d == null ? void 0 : d.cards) || [];
54
- l.length > $ && t.push(
55
- f(
327
+ const d = (s == null ? void 0 : s.cards) || [];
328
+ d.length > M && t.push(
329
+ u(
56
330
  "too_many_cards",
57
- `Generated dashboards can contain at most ${$} cards.`
331
+ `Generated dashboards can contain at most ${M} cards.`
58
332
  )
59
333
  );
60
- const s = D(l.map((u) => u.id));
61
- s && t.push(
62
- f("duplicate_card_id", `Duplicate generated card id: ${s}.`)
334
+ const o = $(d.map((l) => l.id));
335
+ o && t.push(
336
+ u("duplicate_card_id", `Duplicate generated card id: ${o}.`)
63
337
  );
64
- const c = D(l.map((u) => u.frameId));
65
- c && t.push(
66
- f(
338
+ const f = $(d.map((l) => l.frameId));
339
+ f && t.push(
340
+ u(
67
341
  "duplicate_frame_id",
68
- `Duplicate generated frame id: ${c}.`
342
+ `Duplicate generated frame id: ${f}.`
69
343
  )
70
344
  );
71
- for (const u of l)
72
- (C = u.title) != null && C.trim() || t.push(f("missing_card_title", "Card title is required.", u.id)), u.type === "custom" && t.push(
73
- f(
345
+ for (const l of d)
346
+ (w = l.title) != null && w.trim() || t.push(u("missing_card_title", "Card title is required.", l.id)), l.type === "custom" && t.push(
347
+ u(
74
348
  "custom_visual_out_of_scope",
75
349
  "Whole-dashboard authoring supports built-in visual types only.",
76
- u.id
350
+ l.id
77
351
  )
78
- ), u.type !== "text" && !u.query && n.push(
79
- f(
352
+ ), l.type !== "text" && !l.query && r.push(
353
+ u(
80
354
  "missing_query_intent",
81
355
  "Non-text card has no query intent and may be skipped by the app layer.",
82
- u.id
356
+ l.id
83
357
  )
84
- );
85
- const m = Array.isArray(a.filterInputs) ? a.filterInputs : [], y = m.map((u) => u.id), g = D(y);
86
- g && t.push(
87
- f(
358
+ ), se({ card: l, datasets: i, errors: t }), de({ card: l, errors: t }), oe({ card: l, datasets: i, errors: t });
359
+ const p = Array.isArray(n.filterInputs) ? n.filterInputs : [], I = p.map((l) => l.id), y = $(I);
360
+ y && t.push(
361
+ u(
88
362
  "duplicate_input_id",
89
- `Duplicate dashboard input id: ${g}.`
363
+ `Duplicate dashboard input id: ${y}.`
90
364
  )
91
365
  );
92
- const o = m.map((u) => u.variableName).filter(Boolean) || [], b = D(o);
366
+ const c = p.map((l) => l.variableName).filter(Boolean) || [], b = $(c);
93
367
  b && t.push(
94
- f(
368
+ u(
95
369
  "duplicate_input_variable",
96
370
  `Duplicate dashboard input variable name: ${b}.`
97
371
  )
98
372
  );
99
- const x = Array.isArray(a.calculatedFields) ? a.calculatedFields : [];
100
- for (const u of x)
101
- u.scope === "domain" && u.reuseOnly !== !0 && t.push(
102
- f(
373
+ const S = Array.isArray(n.calculatedFields) ? n.calculatedFields : [];
374
+ for (const l of S)
375
+ l.scope === "domain" && l.reuseOnly !== !0 && t.push(
376
+ u(
103
377
  "domain_calculated_field_create_out_of_scope",
104
- `Creating domain calculated field "${u.name}" is outside MVP.`
378
+ `Creating domain calculated field "${l.name}" is outside MVP.`
105
379
  )
106
380
  );
107
- return { ok: t.length === 0, errors: t, warnings: n };
381
+ return { ok: t.length === 0, errors: t, warnings: r };
108
382
  }
109
- function ne(e) {
110
- var d;
383
+ function qe(e) {
384
+ var s;
111
385
  const t = [];
112
386
  if (!e || typeof e != "object")
113
387
  return {
114
388
  ok: !1,
115
389
  errors: [
116
- f(
390
+ u(
117
391
  "invalid_change_plan",
118
392
  "Dashboard change plan must be a structured object."
119
393
  )
120
394
  ],
121
395
  warnings: []
122
396
  };
123
- const a = e, n = [...a.warnings || []];
124
- a.version !== 1 && t.push(
125
- f("invalid_version", "Dashboard change plan version must be 1.")
126
- ), (d = a.dashboardId) != null && d.trim() || t.push(
127
- f("missing_dashboard_id", "Dashboard change plan needs a dashboard id.")
128
- );
129
- const i = Array.isArray(a.datasets) ? a.datasets : [], r = Array.isArray(a.operations) ? a.operations : [];
130
- i.length > 1 && t.push(
131
- f(
132
- "invalid_dataset_count",
133
- "MVP dashboard refinement can ground new AI operations in at most one selected dataset."
134
- )
397
+ const n = e, r = [...n.warnings || []];
398
+ n.version !== 1 && t.push(
399
+ u("invalid_version", "Dashboard change plan version must be 1.")
400
+ ), (s = n.dashboardId) != null && s.trim() || t.push(
401
+ u("missing_dashboard_id", "Dashboard change plan needs a dashboard id.")
135
402
  );
136
- for (const l of r) {
137
- if (l.kind === "unsupported") {
138
- n.push(
139
- f("unsupported_operation", l.reason || l.requestedAction)
403
+ const i = Array.isArray(n.datasets) ? n.datasets : [], a = Array.isArray(n.operations) ? n.operations : [];
404
+ ce({ datasets: i, errors: t, requireAtLeastOne: !1 });
405
+ for (const d of a) {
406
+ if (d.kind === "unsupported") {
407
+ r.push(
408
+ u("unsupported_operation", d.reason || d.requestedAction)
140
409
  );
141
410
  continue;
142
411
  }
143
- l.kind === "addCard" && l.card.type === "custom" && t.push(
144
- f(
412
+ d.kind === "addCard" && d.card.type === "custom" && t.push(
413
+ u(
145
414
  "custom_visual_out_of_scope",
146
415
  "Whole-dashboard authoring supports built-in visual types only.",
147
- l.card.id
416
+ d.card.id
148
417
  )
149
- ), l.kind === "addCalculatedField" && l.field.scope === "domain" && l.field.reuseOnly !== !0 && t.push(
150
- f(
418
+ ), d.kind === "addCard" && (se({
419
+ card: d.card,
420
+ datasets: i,
421
+ errors: t
422
+ }), de({
423
+ card: d.card,
424
+ errors: t
425
+ }), oe({
426
+ card: d.card,
427
+ datasets: i,
428
+ errors: t
429
+ })), d.kind === "addCalculatedField" && d.field.scope === "domain" && d.field.reuseOnly !== !0 && t.push(
430
+ u(
151
431
  "domain_calculated_field_create_out_of_scope",
152
- `Creating domain calculated field "${l.field.name}" is outside MVP.`
432
+ `Creating domain calculated field "${d.field.name}" is outside MVP.`
153
433
  )
154
434
  );
155
435
  }
156
- return { ok: t.length === 0, errors: t, warnings: n };
436
+ return { ok: t.length === 0, errors: t, warnings: r };
157
437
  }
158
- const re = {
438
+ const Re = {
159
439
  lg: 48,
160
440
  md: 36,
161
441
  sm: 24,
162
442
  xs: 12,
163
443
  xxs: 6
164
444
  };
165
- function ie(e, t) {
166
- let a = 0, n = 0, i = 0;
167
- return e.map((r) => {
168
- const d = Math.min(r.w, t);
169
- a > 0 && a + d > t && (a = 0, n += i, i = 0);
170
- const l = {
171
- i: r.frameId,
172
- x: a,
173
- y: n,
174
- w: d,
175
- h: r.h,
176
- minW: Math.min(r.minW, t),
177
- minH: r.minH,
445
+ function Pe(e, t) {
446
+ let n = 0, r = 0, i = 0;
447
+ return e.map((a) => {
448
+ const s = Math.min(a.w, t);
449
+ n > 0 && n + s > t && (n = 0, r += i, i = 0);
450
+ const d = {
451
+ i: a.frameId,
452
+ x: n,
453
+ y: r,
454
+ w: s,
455
+ h: a.h,
456
+ minW: Math.min(a.minW, t),
457
+ minH: a.minH,
178
458
  static: !1
179
459
  };
180
- return a += d, i = Math.max(i, r.h), l;
460
+ return n += s, i = Math.max(i, a.h), d;
181
461
  });
182
462
  }
183
- function se(e) {
184
- const t = [...e].sort((s, c) => s.priority - c.priority), a = t.filter((s) => s.role === "kpi"), n = t.filter((s) => s.role === "chart"), i = t.filter((s) => s.role === "table"), r = t.filter((s) => s.role === "text"), d = r.slice(0, 1), l = r.slice(d.length);
185
- return { kpis: a, introText: d, charts: n, tables: i, supportingText: l };
463
+ function Be(e) {
464
+ const t = [...e].sort((o, f) => o.priority - f.priority), n = t.filter((o) => o.role === "kpi"), r = t.filter((o) => o.role === "chart"), i = t.filter((o) => o.role === "table"), a = t.filter((o) => o.role === "text"), s = a.slice(0, 1), d = a.slice(s.length);
465
+ return { kpis: n, introText: s, charts: r, tables: i, supportingText: d };
186
466
  }
187
- function de(e, t, a) {
188
- 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;
467
+ function Ve(e, t, n) {
468
+ return t === "xxs" || t === "xs" ? n : t === "sm" ? Math.min(12, n) : t === "md" ? e <= 1 || e === 2 ? 18 : 12 : e <= 1 || e === 2 ? 24 : e === 3 ? 16 : 12;
189
469
  }
190
- function oe(e, t, a, n) {
191
- return a === "xxs" || a === "xs" || a === "sm" || a === "md" || t === 1 || t % 2 === 1 && e === 0 ? n : n / 2;
470
+ function ze(e, t, n, r) {
471
+ return n === "xxs" || n === "xs" || n === "sm" || n === "md" || t === 1 || t % 2 === 1 && e === 0 ? r : r / 2;
192
472
  }
193
- function le(e) {
194
- const { item: t, band: a, index: n, bandCount: i, breakpoint: r, columns: d } = e;
195
- return a === "kpi" ? {
473
+ function Le(e) {
474
+ const { item: t, band: n, index: r, bandCount: i, breakpoint: a, columns: s } = e;
475
+ return n === "kpi" ? {
196
476
  ...t,
197
- band: a,
198
- w: de(i, r, d),
477
+ band: n,
478
+ w: Ve(i, a, s),
199
479
  h: 15,
200
- minW: Math.min(6, d),
480
+ minW: Math.min(6, s),
201
481
  minH: 12
202
- } : a === "table" ? {
482
+ } : n === "table" ? {
203
483
  ...t,
204
- band: a,
205
- w: d,
206
- h: r === "xxs" || r === "xs" ? 34 : 38,
207
- minW: Math.min(12, d),
484
+ band: n,
485
+ w: s,
486
+ h: a === "xxs" || a === "xs" ? 34 : 38,
487
+ minW: Math.min(12, s),
208
488
  minH: 18
209
- } : a === "introText" ? {
489
+ } : n === "introText" ? {
210
490
  ...t,
211
- band: a,
212
- w: d,
213
- h: r === "xxs" || r === "xs" ? 12 : 10,
214
- minW: Math.min(12, d),
491
+ band: n,
492
+ w: s,
493
+ h: a === "xxs" || a === "xs" ? 12 : 10,
494
+ minW: Math.min(12, s),
215
495
  minH: 8
216
- } : a === "supportingText" ? {
496
+ } : n === "supportingText" ? {
217
497
  ...t,
218
- band: a,
219
- w: r === "lg" ? d / 2 : d,
220
- h: r === "xxs" || r === "xs" ? 12 : 10,
221
- minW: Math.min(12, d),
498
+ band: n,
499
+ w: a === "lg" ? s / 2 : s,
500
+ h: a === "xxs" || a === "xs" ? 12 : 10,
501
+ minW: Math.min(12, s),
222
502
  minH: 8
223
503
  } : {
224
504
  ...t,
225
- band: a,
226
- w: oe(n, i, r, d),
227
- h: r === "xxs" || r === "xs" ? 28 : 30,
228
- minW: Math.min(12, d),
505
+ band: n,
506
+ w: ze(r, i, a, s),
507
+ h: a === "xxs" || a === "xs" ? 28 : 30,
508
+ minW: Math.min(12, s),
229
509
  minH: 16
230
510
  };
231
511
  }
232
- function A(e, t, a, n) {
512
+ function D(e, t, n, r) {
233
513
  return e.map(
234
- (i, r) => le({
514
+ (i, a) => Le({
235
515
  item: i,
236
516
  band: t,
237
- index: r,
517
+ index: a,
238
518
  bandCount: e.length,
239
- breakpoint: a,
240
- columns: n
519
+ breakpoint: n,
520
+ columns: r
241
521
  })
242
522
  );
243
523
  }
244
- function P(e) {
245
- const t = se(e);
524
+ function E(e) {
525
+ const t = Be(e);
246
526
  return Object.fromEntries(
247
- te.map((a) => {
248
- const n = re[a], i = [
249
- ...A(t.introText, "introText", a, n),
250
- ...A(t.kpis, "kpi", a, n),
251
- ...A(t.charts, "chart", a, n),
252
- ...A(t.tables, "table", a, n),
253
- ...A(t.supportingText, "supportingText", a, n)
527
+ ge.map((n) => {
528
+ const r = Re[n], i = [
529
+ ...D(t.introText, "introText", n, r),
530
+ ...D(t.kpis, "kpi", n, r),
531
+ ...D(t.charts, "chart", n, r),
532
+ ...D(t.tables, "table", n, r),
533
+ ...D(t.supportingText, "supportingText", n, r)
254
534
  ];
255
- return [a, ie(i, n)];
535
+ return [n, Pe(i, r)];
256
536
  })
257
537
  );
258
538
  }
259
- function ce(e) {
539
+ function je(e) {
260
540
  const t = String(e || "").trim().toLowerCase();
261
541
  return t.includes("date") || t.includes("time") || t.includes("timestamp") ? "date" : t.includes("int") || t.includes("float") || t.includes("double") || t.includes("decimal") || t.includes("numeric") || t.includes("number") || t.includes("currency") || t.includes("percent") ? "number" : t.includes("bool") ? "boolean" : "string";
262
542
  }
263
- function ue(e) {
543
+ function Oe(e) {
264
544
  return !!(e && typeof e == "object" && !Array.isArray(e));
265
545
  }
266
- function fe(e) {
267
- return ue(e) && typeof e.filterId == "string" && typeof e.operation == "string" && Array.isArray(e.values);
546
+ function We(e) {
547
+ return Oe(e) && typeof e.filterId == "string" && typeof e.operation == "string" && Array.isArray(e.values);
268
548
  }
269
- function pe(e) {
549
+ function Ee(e) {
270
550
  return e.filter(
271
551
  (t) => typeof t == "string" || typeof t == "number"
272
552
  );
273
553
  }
274
- function me(e) {
554
+ function He(e) {
275
555
  return e.filter(
276
556
  (t) => t instanceof Date || typeof t == "string"
277
557
  );
278
558
  }
279
- function q(e, t) {
559
+ function H(e, t) {
280
560
  if (t === void 0)
281
561
  return;
282
- const a = ce(e.dataType), n = e.operation || "in";
283
- if (fe(t))
562
+ const n = je(e.dataType), r = e.operation || "in";
563
+ if (We(t))
284
564
  return {
285
565
  ...t,
286
566
  filterId: e.id,
287
567
  name: t.name || e.column,
288
- valueType: a,
568
+ valueType: n,
289
569
  dataType: e.dataType,
290
570
  fieldMeta: e.fieldMeta,
291
571
  semanticContext: e.semanticContext
292
572
  };
293
- if (n === "is null" || n === "is not null")
573
+ if (r === "is null" || r === "is not null")
294
574
  return {
295
575
  filterId: e.id,
296
576
  name: e.column,
297
- operation: n,
298
- valueType: a,
577
+ operation: r,
578
+ valueType: n,
299
579
  values: [],
300
580
  dataType: e.dataType,
301
581
  fieldMeta: e.fieldMeta,
302
582
  semanticContext: e.semanticContext
303
583
  };
304
- const i = Array.isArray(t) ? t : [t], r = a === "date" ? me(i) : pe(i);
305
- if (r.length !== 0 && !((n === "between" || n === "not between") && r.length < 2))
584
+ const i = Array.isArray(t) ? t : [t], a = n === "date" ? He(i) : Ee(i);
585
+ if (a.length !== 0 && !((r === "between" || r === "not between") && a.length < 2))
306
586
  return {
307
587
  filterId: e.id,
308
588
  name: e.column,
309
- operation: n,
310
- valueType: a,
311
- values: r,
589
+ operation: r,
590
+ valueType: n,
591
+ values: a,
312
592
  dataType: e.dataType,
313
593
  fieldMeta: e.fieldMeta,
314
594
  semanticContext: e.semanticContext
315
595
  };
316
596
  }
317
- function he(e, t, a) {
318
- return a ? { code: e, message: t, cardId: a } : { code: e, message: t };
597
+ function Ge(e, t, n) {
598
+ return n ? { code: e, message: t, cardId: n } : { code: e, message: t };
319
599
  }
320
- function be(e, t, a) {
321
- const n = (t || []).filter(
322
- (i) => i.scope === "card" && i.targetCardId === a
600
+ function Ue(e, t, n) {
601
+ const r = (t || []).filter(
602
+ (i) => i.scope === "card" && i.targetCardId === n
323
603
  ).map((i) => i.field).filter(Boolean);
324
- return n.length === 0 ? e : {
604
+ return r.length === 0 ? e : {
325
605
  ...e,
326
606
  calculatedFields: [
327
607
  ...e.calculatedFields || [],
328
- ...n
608
+ ...r
329
609
  ]
330
610
  };
331
611
  }
332
- function ge(e) {
612
+ function Ke(e) {
333
613
  const t = {};
334
614
  return {
335
- inputs: (e.filterInputs || []).map((n, i) => {
336
- const r = q(
337
- n.filter,
338
- n.defaultValue
615
+ inputs: (e.filterInputs || []).map((r, i) => {
616
+ const a = H(
617
+ r.filter,
618
+ r.defaultValue
339
619
  );
340
- return r && (t.shared ?? (t.shared = {}), t.shared[n.id] = {
620
+ return a && (t.shared ?? (t.shared = {}), t.shared[r.id] = {
341
621
  status: "set",
342
622
  value: {
343
623
  kind: "filter",
344
- filterValue: r
624
+ filterValue: a
345
625
  }
346
626
  }), {
347
- id: n.id,
627
+ id: r.id,
348
628
  kind: "filter",
349
- label: n.label,
350
- variableName: n.variableName,
351
- scope: n.scope || { kind: "allSheets", sheetKinds: ["dashboard"] },
629
+ label: r.label,
630
+ variableName: r.variableName,
631
+ scope: r.scope || { kind: "allSheets", sheetKinds: ["dashboard"] },
352
632
  runtimeScope: "shared",
353
633
  presentation: {
354
634
  placement: "toolbar",
355
635
  order: i
356
636
  },
357
637
  exports: ["label", "value", "start", "end", "range"],
358
- filter: n.filter
638
+ filter: r.filter
359
639
  };
360
640
  }),
361
641
  defaultInputValues: t.shared && Object.keys(t.shared).length > 0 ? t : void 0
362
642
  };
363
643
  }
364
- function Oe(e) {
365
- var y, g;
366
- const t = ae(e.plan);
644
+ function kt(e) {
645
+ var I, y;
646
+ const t = Me(e.plan);
367
647
  if (!t.ok)
368
648
  throw new Error(
369
- t.errors.map((o) => o.message).join(`
649
+ t.errors.map((c) => c.message).join(`
370
650
  `) || "Dashboard plan is invalid."
371
651
  );
372
- const a = e.plan.sheets[0], n = [...t.warnings], i = [], r = new Map(
373
- e.cardArtifacts.map((o) => [o.planCardId, o])
374
- ), d = [];
375
- for (const o of a.cards) {
376
- const b = r.get(o.id);
652
+ const n = e.plan.sheets[0], r = [...t.warnings], i = [], a = new Map(
653
+ e.cardArtifacts.map((c) => [c.planCardId, c])
654
+ ), s = [];
655
+ for (const c of n.cards) {
656
+ const b = a.get(c.id);
377
657
  if (!b) {
378
- const w = he(
658
+ const m = Ge(
379
659
  "missing_card_artifact",
380
- `Card "${o.title}" was skipped because no generated artifact was supplied.`,
381
- o.id
660
+ `Card "${c.title}" was skipped because no generated artifact was supplied.`,
661
+ c.id
382
662
  );
383
- i.push(w);
663
+ i.push(m);
384
664
  continue;
385
665
  }
386
- n.push(...b.warnings || []);
387
- const x = be(
666
+ r.push(...b.warnings || []);
667
+ const S = Ue(
388
668
  b.card,
389
669
  e.plan.calculatedFields,
390
- o.id
670
+ c.id
391
671
  );
392
- d.push({
393
- id: o.frameId,
394
- cards: [x],
395
- activeCardId: x.id
672
+ s.push({
673
+ id: c.frameId,
674
+ cards: [S],
675
+ activeCardId: S.id
396
676
  });
397
677
  }
398
- if (d.length === 0)
678
+ if (s.length === 0)
399
679
  throw new Error("Dashboard plan did not produce any persistable cards.");
400
- const { inputs: l, defaultInputValues: s } = ge(e.plan), c = P(
401
- a.cards.filter((o) => d.some((b) => b.id === o.frameId)).map((o) => ({
402
- frameId: o.frameId,
403
- priority: o.priority,
404
- role: o.role
680
+ const { inputs: d, defaultInputValues: o } = Ke(e.plan), f = E(
681
+ n.cards.filter((c) => s.some((b) => b.id === c.frameId)).map((c) => ({
682
+ frameId: c.frameId,
683
+ priority: c.priority,
684
+ role: c.role
405
685
  }))
406
686
  );
407
687
  return { dashboard: {
@@ -410,291 +690,273 @@ function Oe(e) {
410
690
  description: e.plan.description || "",
411
691
  sheets: [
412
692
  {
413
- id: a.id,
693
+ id: n.id,
414
694
  kind: "dashboard",
415
- title: a.title,
416
- description: a.description,
417
- frames: d,
418
- layouts: c,
419
- calculatedFields: (y = e.plan.calculatedFields) == null ? void 0 : y.filter((o) => o.scope === "sheet" && o.field).map((o) => o.field)
695
+ title: n.title,
696
+ description: n.description,
697
+ frames: s,
698
+ layouts: f,
699
+ calculatedFields: (I = e.plan.calculatedFields) == null ? void 0 : I.filter((c) => c.scope === "sheet" && c.field).map((c) => c.field)
420
700
  }
421
701
  ],
422
- calculatedFields: (g = e.plan.calculatedFields) == null ? void 0 : g.filter((o) => o.scope === "dashboard" && o.field).map((o) => o.field),
423
- inputs: l,
424
- ...s ? { defaultInputValues: s } : {}
425
- }, warnings: n, skippedOperations: i };
702
+ calculatedFields: (y = e.plan.calculatedFields) == null ? void 0 : y.filter((c) => c.scope === "dashboard" && c.field).map((c) => c.field),
703
+ inputs: d,
704
+ ...o ? { defaultInputValues: o } : {}
705
+ }, warnings: r, skippedOperations: i };
426
706
  }
427
- function k(e, t, a) {
428
- return a ? { code: e, message: t, cardId: a } : { code: e, message: t };
707
+ function C(e, t, n) {
708
+ return n ? { code: e, message: t, cardId: n } : { code: e, message: t };
429
709
  }
430
- function Ie(e) {
710
+ function Qe(e) {
431
711
  return JSON.parse(JSON.stringify(e));
432
712
  }
433
- function ye(e) {
713
+ function Je(e) {
434
714
  var t;
435
715
  return (t = e.sheets) == null ? void 0 : t.find(
436
- (a) => (a.kind || "dashboard") === "dashboard"
716
+ (n) => (n.kind || "dashboard") === "dashboard"
437
717
  );
438
718
  }
439
- function M(e, t) {
440
- var a;
441
- for (const n of e.sheets || [])
442
- for (const i of n.frames || []) {
443
- const r = (a = i.cards) == null ? void 0 : a.find((d) => d.id === t);
444
- if (r)
445
- return { sheet: n, frame: i, card: r };
719
+ function P(e, t) {
720
+ var n;
721
+ for (const r of e.sheets || [])
722
+ for (const i of r.frames || []) {
723
+ const a = (n = i.cards) == null ? void 0 : n.find((s) => s.id === t);
724
+ if (a)
725
+ return { sheet: r, frame: i, card: a };
446
726
  }
447
727
  return null;
448
728
  }
449
- function W(e) {
450
- var a, n;
451
- const t = (n = (a = e.cards) == null ? void 0 : a[0]) == null ? void 0 : n.type;
729
+ function le(e) {
730
+ var n, r;
731
+ const t = (r = (n = e.cards) == null ? void 0 : n[0]) == null ? void 0 : r.type;
452
732
  return t === "kpi" ? "kpi" : t === "table" || t === "detailTable" || t === "pivotTable" ? "table" : t === "text" ? "text" : "chart";
453
733
  }
454
- function we(e) {
734
+ function Xe(e) {
455
735
  var t;
456
736
  return new Map(
457
- (((t = e.layouts) == null ? void 0 : t.lg) || []).map((a, n) => [a.i, n])
737
+ (((t = e.layouts) == null ? void 0 : t.lg) || []).map((n, r) => [n.i, r])
458
738
  );
459
739
  }
460
- function G(e, t = /* @__PURE__ */ new Map()) {
461
- const a = we(e), n = Math.max(
462
- a.size,
740
+ function ue(e, t = /* @__PURE__ */ new Map()) {
741
+ const n = Xe(e), r = Math.max(
742
+ n.size,
463
743
  t.size
464
744
  ), i = (e.frames || []).map(
465
- (r, d) => ({
466
- frameId: r.id,
467
- role: W(r),
468
- priority: t.get(r.id) ?? a.get(r.id) ?? n + d
745
+ (a, s) => ({
746
+ frameId: a.id,
747
+ role: le(a),
748
+ priority: t.get(a.id) ?? n.get(a.id) ?? r + s
469
749
  })
470
750
  );
471
- e.layouts = P(i);
751
+ e.layouts = E(i);
472
752
  }
473
- function _e(e) {
753
+ function Ye(e) {
474
754
  return Object.values(e.layouts || {}).some((t) => t.length > 0);
475
755
  }
476
- function ve(e, t) {
477
- if (!_e(e)) {
478
- G(e);
756
+ function Ze(e, t) {
757
+ if (!Ye(e)) {
758
+ ue(e);
479
759
  return;
480
760
  }
481
- const a = P([
482
- { frameId: t.id, role: W(t), priority: 0 }
761
+ const n = E([
762
+ { frameId: t.id, role: le(t), priority: 0 }
483
763
  ]);
484
764
  e.layouts ?? (e.layouts = {});
485
- for (const [n, i] of Object.entries(a)) {
486
- const r = e.layouts[n] || [];
487
- if (r.some((s) => s.i === t.id))
765
+ for (const [r, i] of Object.entries(n)) {
766
+ const a = e.layouts[r] || [];
767
+ if (a.some((o) => o.i === t.id))
488
768
  continue;
489
- const d = i[0];
490
- if (!d)
769
+ const s = i[0];
770
+ if (!s)
491
771
  continue;
492
- const l = r.reduce(
493
- (s, c) => Math.max(s, c.y + c.h),
772
+ const d = a.reduce(
773
+ (o, f) => Math.max(o, f.y + f.h),
494
774
  0
495
775
  );
496
- e.layouts[n] = [
497
- ...r,
498
- { ...d, y: l }
776
+ e.layouts[r] = [
777
+ ...a,
778
+ { ...s, y: d }
499
779
  ];
500
780
  }
501
781
  }
502
- function ke(e, t) {
503
- var n;
504
- const a = q(
782
+ function et(e, t) {
783
+ var r;
784
+ const n = H(
505
785
  t.filter,
506
786
  t.defaultValue
507
787
  );
508
- a && (e.defaultInputValues ?? (e.defaultInputValues = {}), (n = e.defaultInputValues).shared ?? (n.shared = {}), e.defaultInputValues.shared[t.id] = {
788
+ n && (e.defaultInputValues ?? (e.defaultInputValues = {}), (r = e.defaultInputValues).shared ?? (r.shared = {}), e.defaultInputValues.shared[t.id] = {
509
789
  status: "set",
510
790
  value: {
511
791
  kind: "filter",
512
- filterValue: a
792
+ filterValue: n
513
793
  }
514
794
  });
515
795
  }
516
- function Ee(e) {
517
- var l;
518
- const t = ne(e.changePlan);
796
+ function St(e) {
797
+ var d;
798
+ const t = qe(e.changePlan);
519
799
  if (!t.ok)
520
800
  throw new Error(
521
- t.errors.map((s) => s.message).join(`
801
+ t.errors.map((o) => o.message).join(`
522
802
  `) || "Dashboard change plan is invalid."
523
803
  );
524
- const a = Ie(e.dashboard), n = [...t.warnings], i = [], r = new Map(
525
- e.cardArtifacts.map((s) => [s.planCardId, s])
526
- ), d = ye(a);
527
- if (!d)
804
+ const n = Qe(e.dashboard), r = [...t.warnings], i = [], a = new Map(
805
+ e.cardArtifacts.map((o) => [o.planCardId, o])
806
+ ), s = Je(n);
807
+ if (!s)
528
808
  throw new Error("Dashboard has no editable dashboard sheet.");
529
- d.frames ?? (d.frames = []);
530
- for (const s of e.changePlan.operations)
531
- switch (s.kind) {
809
+ s.frames ?? (s.frames = []);
810
+ for (const o of e.changePlan.operations)
811
+ switch (o.kind) {
532
812
  case "addCard": {
533
- if ((d.frames || []).reduce(
534
- (g, o) => {
813
+ if ((s.frames || []).reduce(
814
+ (y, c) => {
535
815
  var b;
536
- return g + (((b = o.cards) == null ? void 0 : b.length) || 0);
816
+ return y + (((b = c.cards) == null ? void 0 : b.length) || 0);
537
817
  },
538
818
  0
539
- ) >= $) {
819
+ ) >= M) {
540
820
  i.push(
541
- k(
821
+ C(
542
822
  "generated_card_limit_reached",
543
- `MVP AI refinement is capped at ${$} cards.`,
544
- s.card.id
823
+ `MVP AI refinement is capped at ${M} cards.`,
824
+ o.card.id
545
825
  )
546
826
  );
547
827
  break;
548
828
  }
549
- const m = r.get(s.card.id);
550
- if (!m) {
829
+ const p = a.get(o.card.id);
830
+ if (!p) {
551
831
  i.push(
552
- k(
832
+ C(
553
833
  "missing_card_artifact",
554
- `Card "${s.card.title}" was skipped because no generated artifact was supplied.`,
555
- s.card.id
834
+ `Card "${o.card.title}" was skipped because no generated artifact was supplied.`,
835
+ o.card.id
556
836
  )
557
837
  );
558
838
  break;
559
839
  }
560
- const y = {
561
- id: s.card.frameId,
562
- cards: [m.card],
563
- activeCardId: m.card.id
840
+ const I = {
841
+ id: o.card.frameId,
842
+ cards: [p.card],
843
+ activeCardId: p.card.id
564
844
  };
565
- d.frames.push(y), ve(d, y);
845
+ s.frames.push(I), Ze(s, I);
566
846
  break;
567
847
  }
568
848
  case "addFilterInput": {
569
- a.inputs ?? (a.inputs = []);
570
- const c = {
571
- id: s.input.id,
849
+ n.inputs ?? (n.inputs = []);
850
+ const f = {
851
+ id: o.input.id,
572
852
  kind: "filter",
573
- label: s.input.label,
574
- variableName: s.input.variableName,
575
- scope: s.input.scope || {
853
+ label: o.input.label,
854
+ variableName: o.input.variableName,
855
+ scope: o.input.scope || {
576
856
  kind: "allSheets",
577
857
  sheetKinds: ["dashboard"]
578
858
  },
579
859
  runtimeScope: "shared",
580
860
  presentation: {
581
861
  placement: "toolbar",
582
- order: a.inputs.length
862
+ order: n.inputs.length
583
863
  },
584
864
  exports: ["label", "value", "start", "end", "range"],
585
- filter: s.input.filter
865
+ filter: o.input.filter
586
866
  };
587
- a.inputs.push(c), ke(a, s.input);
867
+ n.inputs.push(f), et(n, o.input);
588
868
  break;
589
869
  }
590
870
  case "addCalculatedField": {
591
- if (s.field.scope === "dashboard" && s.field.field)
592
- a.calculatedFields ?? (a.calculatedFields = []), a.calculatedFields.push(s.field.field);
593
- else if (s.field.scope === "sheet" && s.field.field)
594
- d.calculatedFields ?? (d.calculatedFields = []), d.calculatedFields.push(s.field.field);
595
- else if (s.field.scope === "card" && s.field.field) {
596
- const c = s.field.targetCardId ? M(a, s.field.targetCardId) : null;
597
- c ? ((l = c.card).calculatedFields ?? (l.calculatedFields = []), c.card.calculatedFields.push(s.field.field)) : i.push(
598
- k(
871
+ if (o.field.scope === "dashboard" && o.field.field)
872
+ n.calculatedFields ?? (n.calculatedFields = []), n.calculatedFields.push(o.field.field);
873
+ else if (o.field.scope === "sheet" && o.field.field)
874
+ s.calculatedFields ?? (s.calculatedFields = []), s.calculatedFields.push(o.field.field);
875
+ else if (o.field.scope === "card" && o.field.field) {
876
+ const f = o.field.targetCardId ? P(n, o.field.targetCardId) : null;
877
+ f ? ((d = f.card).calculatedFields ?? (d.calculatedFields = []), f.card.calculatedFields.push(o.field.field)) : i.push(
878
+ C(
599
879
  "missing_calculated_field_target",
600
- `Calculated field "${s.field.name}" needs a valid target card.`
880
+ `Calculated field "${o.field.name}" needs a valid target card.`
601
881
  )
602
882
  );
603
883
  }
604
884
  break;
605
885
  }
606
886
  case "renameCard": {
607
- const c = M(a, s.cardId);
608
- if (!c) {
887
+ const f = P(n, o.cardId);
888
+ if (!f) {
609
889
  i.push(
610
- k(
890
+ C(
611
891
  "card_not_found",
612
- `Card "${s.cardId}" could not be renamed because it was not found.`,
613
- s.cardId
892
+ `Card "${o.cardId}" could not be renamed because it was not found.`,
893
+ o.cardId
614
894
  )
615
895
  );
616
896
  break;
617
897
  }
618
- c.card.title = s.title, s.description !== void 0 && (c.card.description = s.description);
898
+ f.card.title = o.title, o.description !== void 0 && (f.card.description = o.description);
619
899
  break;
620
900
  }
621
901
  case "reorderCards": {
622
- const c = /* @__PURE__ */ new Map();
623
- for (let m = 0; m < s.cardIds.length; m += 1) {
624
- const y = s.cardIds[m], g = M(a, y);
625
- g && c.set(g.frame.id, m);
902
+ const f = /* @__PURE__ */ new Map();
903
+ for (let p = 0; p < o.cardIds.length; p += 1) {
904
+ const I = o.cardIds[p], y = P(n, I);
905
+ y && f.set(y.frame.id, p);
626
906
  }
627
- G(d, c);
907
+ ue(s, f);
628
908
  break;
629
909
  }
630
910
  case "reuseCalculatedField":
631
- n.push(
632
- k(
911
+ r.push(
912
+ C(
633
913
  "reused_calculated_field",
634
- `Calculated field "${s.fieldId}" is reused by reference.`
914
+ `Calculated field "${o.fieldId}" is reused by reference.`
635
915
  )
636
916
  );
637
917
  break;
638
918
  case "unsupported":
639
919
  i.push(
640
- k("unsupported_operation", s.reason || s.requestedAction)
920
+ C("unsupported_operation", o.reason || o.requestedAction)
641
921
  );
642
922
  break;
643
923
  }
644
- return { dashboard: a, warnings: n, skippedOperations: i };
924
+ return { dashboard: n, warnings: r, skippedOperations: i };
645
925
  }
646
- function I(e, t, a) {
647
- return a ? { code: e, message: t, cardId: a } : { code: e, message: t };
926
+ function g(e, t, n) {
927
+ return n ? { code: e, message: t, cardId: n } : { code: e, message: t };
648
928
  }
649
- function S(e, t) {
929
+ function F(e, t) {
650
930
  return e.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || t;
651
931
  }
652
- function K(e, t) {
932
+ function fe(e, t) {
653
933
  if (!t.has(e))
654
934
  return t.add(e), e;
655
- let a = 2, n = `${e}-${a}`;
656
- for (; t.has(n); )
657
- a += 1, n = `${e}-${a}`;
658
- return t.add(n), n;
935
+ let n = 2, r = `${e}-${n}`;
936
+ for (; t.has(r); )
937
+ n += 1, r = `${e}-${n}`;
938
+ return t.add(r), r;
659
939
  }
660
- function xe(e) {
661
- return e.kind === "semantic" ? [
662
- "semantic",
663
- e.domainId,
664
- e.datasetId || "",
665
- e.datasetName,
666
- e.connectionId || ""
667
- ].join(":") : e.kind === "physical" ? [
668
- "physical",
669
- e.connectionId,
670
- e.databaseName || "",
671
- e.schemaName || "",
672
- e.tableName
673
- ].join(":") : ["sql", e.connectionId, e.sql].join(":");
674
- }
675
- function v(e) {
940
+ function x(e) {
676
941
  return !!(e && typeof e == "object");
677
942
  }
678
- function E(e) {
679
- return v(e) && (e.kind === "semantic" || e.kind === "physical" || e.kind === "sql");
680
- }
681
- function U(e) {
943
+ function me(e) {
682
944
  return Array.isArray(e.inputs) ? e.inputs.filter(
683
- (t) => v(t) && typeof t.id == "string"
945
+ (t) => x(t) && typeof t.id == "string"
684
946
  ) : [];
685
947
  }
686
- function J(e) {
948
+ function G(e) {
687
949
  return Array.isArray(e.sections) ? e.sections.filter(
688
- (t) => v(t)
950
+ (t) => x(t)
689
951
  ) : [];
690
952
  }
691
- function X(e) {
953
+ function U(e) {
692
954
  return Array.isArray(e.views) ? e.views.filter(
693
- (t) => v(t)
955
+ (t) => x(t)
694
956
  ) : [];
695
957
  }
696
- function Ce(e) {
697
- return e.kind === "semantic" ? {
958
+ function tt(e) {
959
+ return N(e) ? e.kind === "semantic" ? {
698
960
  kind: "semantic",
699
961
  domainId: e.domainId,
700
962
  datasetName: e.datasetName,
@@ -708,95 +970,193 @@ function Ce(e) {
708
970
  schemaName: e.schemaName,
709
971
  tableName: e.tableName,
710
972
  label: e.label
711
- } : null;
973
+ } : null : null;
712
974
  }
713
- function Fe(e) {
714
- return (e == null ? void 0 : e.source) || null;
975
+ function B(e) {
976
+ if (!Array.isArray(e))
977
+ return [];
978
+ const t = [];
979
+ for (const n of e) {
980
+ const r = v(n);
981
+ r && t.push(r);
982
+ }
983
+ return t;
715
984
  }
716
- function Y(e) {
985
+ function nt(e) {
986
+ if (!e)
987
+ return [];
717
988
  const t = [];
718
- for (const a of U(e))
719
- E(a.source) && t.push(a.source);
720
- for (const a of J(e))
721
- for (const n of X(a)) {
722
- const i = Fe(n.analytics);
723
- E(i) && t.push(i);
724
- }
989
+ if (N(e.source) && t.push(e.source), e.kind === "metric") {
990
+ const r = v(e.dateField);
991
+ r && t.push(r), t.push(...B(e.dimensions));
992
+ } else if (e.kind === "records") {
993
+ const r = v(e.dateField);
994
+ r && t.push(r), t.push(...B(e.fields));
995
+ } else if (e.kind === "inputOptions") {
996
+ const r = v(e.field);
997
+ r && t.push(r);
998
+ } else e.kind === "sql" && t.push(...B(e.fields));
999
+ const n = "inputs" in e && Array.isArray(e.inputs) ? e.inputs : [];
1000
+ for (const r of n) {
1001
+ const i = v(r.field);
1002
+ i && t.push(i);
1003
+ }
725
1004
  return t;
726
1005
  }
727
- function Ae(e, t) {
728
- const a = /* @__PURE__ */ new Map();
729
- for (const i of Y(e))
730
- a.set(xe(i), i);
731
- const n = [...a.values()].map(Ce).filter((i) => !!i);
732
- return n.length === 0 ? (t.push(
733
- I(
734
- "missing_materializable_dataset",
735
- "No semantic or physical source could be converted into the current dashboard authoring dataset reference."
1006
+ function rt(e) {
1007
+ const t = [];
1008
+ for (const n of me(e)) {
1009
+ N(n.source) && t.push(n.source);
1010
+ const r = v(n.field);
1011
+ r && t.push(r);
1012
+ }
1013
+ for (const n of G(e))
1014
+ for (const r of U(n))
1015
+ t.push(...nt(r.analytics));
1016
+ return t;
1017
+ }
1018
+ function at(e) {
1019
+ var n;
1020
+ const t = [];
1021
+ for (const r of G(e))
1022
+ for (const i of U(r))
1023
+ N((n = i.analytics) == null ? void 0 : n.source) && t.push(i.analytics.source);
1024
+ return t;
1025
+ }
1026
+ function it(e, t) {
1027
+ const n = q(e).map(tt).filter((a) => !!a);
1028
+ if (n.length === 0)
1029
+ return t.push(
1030
+ g(
1031
+ "missing_materializable_dataset",
1032
+ "No semantic or physical source could be converted into the current dashboard authoring dataset reference."
1033
+ )
1034
+ ), [];
1035
+ const r = n.every((a) => a.kind === "semantic"), i = Array.from(
1036
+ new Set(
1037
+ n.filter((a) => a.kind === "semantic").map((a) => a.domainId)
736
1038
  )
737
- ), []) : (n.length > 1 && t.push(
738
- I(
1039
+ );
1040
+ return n.length > 1 && (!r || i.length !== 1) ? (t.push(
1041
+ g(
739
1042
  "multiple_datasets_out_of_scope",
740
- "The current dashboard authoring compiler supports one selected dataset; using the first source and deferring the rest."
1043
+ "The dashboard authoring compiler supports multiple datasets only within one semantic domain; using the first source and deferring the rest."
741
1044
  )
742
- ), [n[0]]);
1045
+ ), [n[0]]) : n;
743
1046
  }
744
- function Se(e) {
745
- return (Array.isArray(e.fields) ? e.fields : []).map((t) => t.name).filter((t) => {
746
- var a;
747
- return t !== ((a = e.dateField) == null ? void 0 : a.name);
748
- });
1047
+ function st(e, t) {
1048
+ const n = G(e), r = me(e), i = q(rt(e)), a = q(
1049
+ at(e)
1050
+ );
1051
+ return {
1052
+ sections: n,
1053
+ inputs: r,
1054
+ sources: i,
1055
+ primarySources: a,
1056
+ defaultSource: a.length === 1 ? a[0] : void 0,
1057
+ datasets: it(i, t)
1058
+ };
749
1059
  }
750
- function Te(e) {
1060
+ function ot(e) {
1061
+ return pe(e).map((t) => t.name).filter(Boolean);
1062
+ }
1063
+ function pe(e) {
1064
+ return (Array.isArray(e.fields) ? e.fields : []).filter(
1065
+ (t) => !ve(t, e.dateField)
1066
+ );
1067
+ }
1068
+ function dt(e) {
751
1069
  const t = Array.isArray(e.metrics) ? e.metrics.filter(
752
- (a) => typeof a == "string" && a.trim().length > 0
1070
+ (n) => typeof n == "string" && n.trim().length > 0
753
1071
  ) : [];
754
1072
  return Array.from(
755
1073
  new Set(
756
1074
  [e.metric, ...t].filter(
757
- (a) => typeof a == "string" && a.trim().length > 0
1075
+ (n) => typeof n == "string" && n.trim().length > 0
758
1076
  )
759
1077
  )
760
1078
  );
761
1079
  }
762
- function De(e) {
763
- return v(e) && typeof e.name == "string" && e.name.trim().length > 0;
1080
+ function ct(e) {
1081
+ return x(e) && typeof e.name == "string" && e.name.trim().length > 0;
764
1082
  }
765
- function $e(e) {
1083
+ function lt(e) {
766
1084
  if (!Array.isArray(e.dimensions))
767
1085
  return;
768
- const t = e.dimensions.filter(De).map((a) => a.name);
1086
+ const t = e.dimensions.filter(ct).map((n) => n.name);
769
1087
  return t.length ? t : void 0;
770
1088
  }
771
- function H(e) {
1089
+ function ne(e) {
772
1090
  return e === "hour" ? "day" : e;
773
1091
  }
774
- function Ne(e) {
775
- var t, a;
1092
+ function j(e, t = {}) {
1093
+ var n, r;
1094
+ if (e != null && e.name) {
1095
+ if (((n = e.source) == null ? void 0 : n.kind) === "semantic")
1096
+ return !e.source.domainId || !e.source.datasetName ? void 0 : {
1097
+ name: e.name,
1098
+ source: {
1099
+ kind: "semantic",
1100
+ domainId: e.source.domainId,
1101
+ datasetName: e.source.datasetName,
1102
+ datasetId: e.source.datasetId,
1103
+ label: e.source.label,
1104
+ connectionId: e.source.connectionId
1105
+ }
1106
+ };
1107
+ if (((r = e.source) == null ? void 0 : r.kind) === "physical")
1108
+ return !e.source.connectionId || !e.source.tableName ? void 0 : {
1109
+ name: e.name,
1110
+ source: {
1111
+ kind: "physical",
1112
+ connectionId: e.source.connectionId,
1113
+ tableName: e.source.tableName,
1114
+ databaseName: e.source.databaseName,
1115
+ schemaName: e.source.schemaName,
1116
+ label: e.source.label
1117
+ }
1118
+ };
1119
+ if (!(e.source !== void 0 || !t.includeUnsourced))
1120
+ return { name: e.name };
1121
+ }
1122
+ }
1123
+ function re(e) {
1124
+ if (!Array.isArray(e))
1125
+ return;
1126
+ const t = e.map((n) => j(n, { includeUnsourced: !0 })).filter(Boolean);
1127
+ if (t.length === e.length)
1128
+ return t.some((n) => n.source) ? t : void 0;
1129
+ }
1130
+ function ut(e) {
1131
+ var t, n;
776
1132
  if (e) {
777
1133
  if (e.kind === "metric")
778
1134
  return {
779
1135
  metric: e.metric,
780
- metrics: Te(e),
1136
+ metrics: dt(e),
781
1137
  dateField: (t = e.dateField) == null ? void 0 : t.name,
782
- timeGrain: H(e.timeGrain),
783
- dimensions: $e(e),
1138
+ dateFieldRef: j(e.dateField),
1139
+ timeGrain: ne(e.timeGrain),
1140
+ dimensions: lt(e),
1141
+ dimensionRefs: re(e.dimensions),
784
1142
  limit: e.limit
785
1143
  };
786
1144
  if (e.kind === "records")
787
1145
  return {
788
1146
  metrics: e.measures,
789
- dateField: (a = e.dateField) == null ? void 0 : a.name,
790
- timeGrain: H(e.timeGrain),
791
- dimensions: Se(e),
1147
+ dateField: (n = e.dateField) == null ? void 0 : n.name,
1148
+ dateFieldRef: j(e.dateField),
1149
+ timeGrain: ne(e.timeGrain),
1150
+ dimensions: ot(e),
1151
+ dimensionRefs: re(pe(e)),
792
1152
  limit: e.limit
793
1153
  };
794
1154
  }
795
1155
  }
796
- function Me(e) {
797
- return e && ee(e).ok ? e : void 0;
1156
+ function ft(e) {
1157
+ return e && Ie(e).ok ? e : void 0;
798
1158
  }
799
- function Ve(e) {
1159
+ function mt(e) {
800
1160
  var t;
801
1161
  switch ((t = e.presentation) == null ? void 0 : t.kind) {
802
1162
  case "kpi":
@@ -815,11 +1175,11 @@ function Ve(e) {
815
1175
  return null;
816
1176
  }
817
1177
  }
818
- function Pe(e) {
819
- var t, a, n;
820
- return ((t = e.presentation) == null ? void 0 : t.kind) === "kpi" ? "kpi" : ((a = e.presentation) == null ? void 0 : a.kind) === "table" ? "table" : ((n = e.presentation) == null ? void 0 : n.kind) === "text" ? "text" : "chart";
1178
+ function pt(e) {
1179
+ var t, n, r;
1180
+ return ((t = e.presentation) == null ? void 0 : t.kind) === "kpi" ? "kpi" : ((n = e.presentation) == null ? void 0 : n.kind) === "table" ? "table" : ((r = e.presentation) == null ? void 0 : r.kind) === "text" ? "text" : "chart";
821
1181
  }
822
- function qe(e) {
1182
+ function ht(e) {
823
1183
  switch (e) {
824
1184
  case "not_in":
825
1185
  return "not in";
@@ -829,98 +1189,103 @@ function qe(e) {
829
1189
  return e || "in";
830
1190
  }
831
1191
  }
832
- function Be(e) {
833
- return v(e.field) ? e.field.dataType === "datetime" ? "date" : e.field.dataType || "string" : "string";
1192
+ function bt(e) {
1193
+ return x(e.field) ? e.field.dataType === "datetime" ? "date" : e.field.dataType || "string" : "string";
834
1194
  }
835
- function Le(e) {
1195
+ function It(e) {
836
1196
  if (!(!e || e.kind !== "physical"))
837
1197
  return [e.databaseName, e.schemaName, e.tableName].filter(Boolean).join(".");
838
1198
  }
839
- function ze(e, t, a, n, i) {
1199
+ function gt(e, t, n, r, i, a) {
840
1200
  if (e.kind !== "filter")
841
- return i.push(
842
- I(
1201
+ return a.push(
1202
+ g(
843
1203
  "control_inputs_deferred",
844
1204
  `Control input "${e.label}" is represented in the protocol but not yet materialized by the dashboard authoring adapter.`
845
1205
  )
846
1206
  ), null;
847
- if (!v(e.field) || typeof e.field.name != "string")
848
- return i.push(
849
- I(
1207
+ if (!x(e.field) || typeof e.field.name != "string")
1208
+ return a.push(
1209
+ g(
850
1210
  "filter_requires_field",
851
1211
  `Filter "${e.label || e.id}" needs a field before the dashboard compiler can materialize it.`
852
1212
  )
853
1213
  ), null;
854
- const r = e.source || t, d = (r == null ? void 0 : r.kind) === "semantic" || (r == null ? void 0 : r.kind) === "physical" || (r == null ? void 0 : r.kind) === "sql" ? r.connectionId : void 0;
1214
+ const s = we({
1215
+ explicitSource: e.source,
1216
+ field: e.field,
1217
+ defaultSource: t,
1218
+ fallbackSources: n
1219
+ }), d = (s == null ? void 0 : s.kind) === "semantic" || (s == null ? void 0 : s.kind) === "physical" ? s.connectionId : void 0;
855
1220
  if (!d)
856
- return i.push(
857
- I(
1221
+ return a.push(
1222
+ g(
858
1223
  "filter_requires_connection_id",
859
1224
  `Filter "${e.label}" needs a source connectionId before the dashboard compiler can materialize it.`
860
1225
  )
861
1226
  ), null;
862
- const c = {
863
- id: `filter-${K(
864
- S(e.id, e.field.name),
865
- n
1227
+ const p = {
1228
+ id: `filter-${fe(
1229
+ F(e.id, e.field.name),
1230
+ i
866
1231
  )}`,
867
1232
  variableName: e.id,
868
1233
  connectionId: d,
869
1234
  title: e.label,
870
1235
  column: e.field.name,
871
- dataType: Be(e),
872
- qualifiedTableName: Le(r),
1236
+ dataType: bt(e),
1237
+ qualifiedTableName: It(s),
873
1238
  sql: "",
874
- operation: qe(e.operator),
1239
+ operation: ht(e.operator),
875
1240
  type: e.multi === !1 ? "single" : "multiple",
876
1241
  location: "dashboard",
877
1242
  displayMode: "toolbar",
878
- fieldMeta: (r == null ? void 0 : r.kind) === "semantic" ? {
1243
+ fieldMeta: (s == null ? void 0 : s.kind) === "semantic" ? {
879
1244
  name: e.field.name,
880
1245
  qualifiedFieldName: e.field.name,
881
1246
  dataType: e.field.dataType,
882
1247
  role: e.field.role === "measure" ? "metric" : "groupby"
883
1248
  } : void 0,
884
- semanticContext: (r == null ? void 0 : r.kind) === "semantic" ? {
885
- semanticDomainId: r.domainId,
886
- connectionId: r.connectionId
1249
+ semanticContext: (s == null ? void 0 : s.kind) === "semantic" ? {
1250
+ semanticDomainId: s.domainId,
1251
+ connectionId: s.connectionId
887
1252
  } : void 0
888
1253
  };
889
1254
  return {
890
1255
  id: e.id,
891
1256
  label: e.label,
892
1257
  variableName: e.id,
893
- scope: a,
894
- filter: c,
895
- defaultValue: q(
896
- c,
1258
+ scope: r,
1259
+ filter: p,
1260
+ defaultValue: H(
1261
+ p,
897
1262
  e.defaultValue
898
1263
  )
899
1264
  };
900
1265
  }
901
1266
  function V(e) {
902
- const t = [], a = [];
903
- for (const n of e.viewIds) {
904
- const i = e.viewIdToCardId.get(n);
905
- i ? t.push(i) : a.push(n);
1267
+ const t = [], n = [];
1268
+ for (const r of e.viewIds) {
1269
+ const i = e.viewIdToCardId.get(r);
1270
+ i ? t.push(i) : n.push(r);
906
1271
  }
907
- return a.length > 0 && e.warnings.push(
908
- I(
1272
+ return n.length > 0 && e.warnings.push(
1273
+ g(
909
1274
  "input_scope_view_not_found",
910
- `Filter "${e.inputLabel}" referenced unknown view ids: ${a.join(", ")}.`
1275
+ `Filter "${e.inputLabel}" referenced unknown view ids: ${n.join(", ")}.`
911
1276
  )
912
1277
  ), Array.from(new Set(t));
913
1278
  }
914
- function Re(e) {
915
- var n, i;
1279
+ function yt(e) {
1280
+ var r, i;
916
1281
  if (!e.protocolScope) {
917
- const r = Array.from(new Set(e.boundCardIds));
918
- return r.length > 0 && r.length < e.allCardIds.length ? { kind: "cards", cardIds: r } : void 0;
1282
+ const a = Array.from(new Set(e.boundCardIds));
1283
+ return a.length > 0 && a.length < e.allCardIds.length ? { kind: "cards", cardIds: a } : void 0;
919
1284
  }
920
1285
  if (e.protocolScope.level === "dashboard") {
921
- if (!((n = e.protocolScope.excludeViewIds) != null && n.length))
1286
+ if (!((r = e.protocolScope.excludeViewIds) != null && r.length))
922
1287
  return;
923
- const r = new Set(
1288
+ const a = new Set(
924
1289
  V({
925
1290
  inputLabel: e.inputLabel,
926
1291
  viewIds: e.protocolScope.excludeViewIds,
@@ -930,34 +1295,34 @@ function Re(e) {
930
1295
  );
931
1296
  return {
932
1297
  kind: "cards",
933
- cardIds: e.allCardIds.filter((d) => !r.has(d))
1298
+ cardIds: e.allCardIds.filter((s) => !a.has(s))
934
1299
  };
935
1300
  }
936
1301
  if (e.protocolScope.level === "view") {
937
- const r = V({
1302
+ const a = V({
938
1303
  inputLabel: e.inputLabel,
939
1304
  viewIds: e.protocolScope.viewIds,
940
1305
  viewIdToCardId: e.viewIdToCardId,
941
1306
  warnings: e.warnings
942
1307
  });
943
- return r.length === 0 ? (e.warnings.push(
944
- I(
1308
+ return a.length === 0 ? (e.warnings.push(
1309
+ g(
945
1310
  "input_scope_has_no_materialized_cards",
946
1311
  `Filter "${e.inputLabel}" was deferred because its view scope does not match any materialized cards.`
947
1312
  )
948
- ), null) : { kind: "cards", cardIds: r };
1313
+ ), null) : { kind: "cards", cardIds: a };
949
1314
  }
950
1315
  const t = e.sectionIdToCardIds.get(e.protocolScope.sectionId) || [];
951
1316
  if (t.length === 0)
952
1317
  return e.warnings.push(
953
- I(
1318
+ g(
954
1319
  "input_scope_section_not_found",
955
1320
  `Filter "${e.inputLabel}" was deferred because section "${e.protocolScope.sectionId}" does not match any materialized cards.`
956
1321
  )
957
1322
  ), null;
958
1323
  if (!((i = e.protocolScope.excludeViewIds) != null && i.length))
959
1324
  return { kind: "cards", cardIds: t };
960
- const a = new Set(
1325
+ const n = new Set(
961
1326
  V({
962
1327
  inputLabel: e.inputLabel,
963
1328
  viewIds: e.protocolScope.excludeViewIds,
@@ -967,113 +1332,128 @@ function Re(e) {
967
1332
  );
968
1333
  return {
969
1334
  kind: "cards",
970
- cardIds: t.filter((r) => !a.has(r))
1335
+ cardIds: t.filter((a) => !n.has(a))
971
1336
  };
972
1337
  }
973
- function He(e) {
974
- var w, C, u;
975
- const t = [], a = Z(e);
976
- for (const p of a.warnings)
977
- t.push(I(p.code, p.message));
978
- for (const p of a.errors)
979
- t.push(I(p.code, p.message));
980
- const n = J(e), i = U(e), r = Ae(e, t), d = Y(e)[0], l = [], s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Set();
981
- let o = 0;
982
- for (const [p, _] of n.entries()) {
983
- const F = typeof _.title == "string" ? _.title : `Section ${p + 1}`, B = _.id || S(F, `section-${p + 1}`);
984
- c.set(B, []);
985
- for (const [L, h] of X(_).entries()) {
986
- const z = Ve(h), N = S(
987
- h.id || `${F}-${h.title || `View ${L + 1}`}`,
988
- `card-${p + 1}-${L + 1}`
1338
+ function At(e) {
1339
+ var c, b, S;
1340
+ const t = [], n = be(e);
1341
+ for (const m of n.warnings)
1342
+ t.push(g(m.code, m.message));
1343
+ for (const m of n.errors)
1344
+ t.push(g(m.code, m.message));
1345
+ const r = st(e, t), i = [], a = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set();
1346
+ let p = 0;
1347
+ for (const [m, w] of r.sections.entries()) {
1348
+ const l = typeof w.title == "string" ? w.title : `Section ${m + 1}`, K = w.id || F(l, `section-${m + 1}`);
1349
+ s.set(K, []);
1350
+ for (const [Q, h] of U(w).entries()) {
1351
+ const J = mt(h), R = F(
1352
+ h.id || `${l}-${h.title || `View ${Q + 1}`}`,
1353
+ `card-${m + 1}-${Q + 1}`
989
1354
  );
990
- if (!z) {
1355
+ if (!J) {
991
1356
  t.push(
992
- I(
1357
+ g(
993
1358
  "unsupported_presentation",
994
- `Dashboard presentation "${((w = h.presentation) == null ? void 0 : w.kind) || "unknown"}" is not supported by the dashboard authoring adapter.`,
995
- `card-${N}`
1359
+ `Dashboard presentation "${((c = h.presentation) == null ? void 0 : c.kind) || "unknown"}" is not supported by the dashboard authoring adapter.`,
1360
+ `card-${R}`
996
1361
  )
997
1362
  );
998
1363
  continue;
999
1364
  }
1000
- if (((C = h.analytics) == null ? void 0 : C.kind) === "sql") {
1365
+ if (((b = h.analytics) == null ? void 0 : b.kind) === "sql") {
1001
1366
  t.push(
1002
- I(
1367
+ g(
1003
1368
  "sql_intent_deferred",
1004
1369
  "SQL analytics intent is valid protocol, but the current dashboard authoring adapter only materializes semantic and physical config-card intents.",
1005
- `card-${N}`
1370
+ `card-${R}`
1006
1371
  )
1007
1372
  );
1008
1373
  continue;
1009
1374
  }
1010
- const R = K(N, y), T = `card-${R}`;
1011
- h.id && s.set(h.id, T), (u = c.get(B)) == null || u.push(T);
1012
- const Q = h.analytics && "inputs" in h.analytics ? h.analytics.inputs : void 0;
1013
- for (const j of Q || []) {
1014
- const O = m.get(j.inputId) || [];
1015
- O.push(T), m.set(j.inputId, O);
1375
+ const X = fe(R, o), T = `card-${X}`;
1376
+ h.id && a.set(h.id, T), (S = s.get(K)) == null || S.push(T);
1377
+ const he = h.analytics && "inputs" in h.analytics ? h.analytics.inputs : void 0;
1378
+ for (const Y of he || []) {
1379
+ const Z = d.get(Y.inputId) || [];
1380
+ Z.push(T), d.set(Y.inputId, Z);
1016
1381
  }
1017
- l.push({
1382
+ i.push({
1018
1383
  id: T,
1019
- frameId: `frame-${R}`,
1384
+ frameId: `frame-${X}`,
1020
1385
  title: h.title,
1021
1386
  description: h.description,
1022
- type: z,
1023
- role: Pe(h),
1024
- priority: o,
1025
- section: F,
1026
- query: Ne(h.analytics),
1027
- analyticsIntent: Me(h.analytics),
1387
+ type: J,
1388
+ role: pt(h),
1389
+ priority: p,
1390
+ section: l,
1391
+ query: ut(h.analytics),
1392
+ analyticsIntent: ft(h.analytics),
1028
1393
  text: h.text
1029
- }), o += 1;
1394
+ }), p += 1;
1030
1395
  }
1031
1396
  }
1032
- const b = i.map((p) => {
1033
- const _ = Re({
1034
- protocolScope: p.scope,
1035
- inputLabel: p.label,
1036
- allCardIds: l.map((F) => F.id),
1037
- boundCardIds: m.get(p.id) || [],
1038
- viewIdToCardId: s,
1039
- sectionIdToCardIds: c,
1397
+ const I = r.inputs.map((m) => {
1398
+ const w = yt({
1399
+ protocolScope: m.scope,
1400
+ inputLabel: m.label,
1401
+ allCardIds: i.map((l) => l.id),
1402
+ boundCardIds: d.get(m.id) || [],
1403
+ viewIdToCardId: a,
1404
+ sectionIdToCardIds: s,
1040
1405
  warnings: t
1041
1406
  });
1042
- return _ === null ? null : ze(
1043
- p,
1044
- d,
1045
- _,
1046
- g,
1407
+ return w === null ? null : gt(
1408
+ m,
1409
+ r.defaultSource,
1410
+ r.sources,
1411
+ w,
1412
+ f,
1047
1413
  t
1048
1414
  );
1049
- }).filter((p) => !!p);
1415
+ }).filter((m) => !!m);
1050
1416
  return { plan: {
1051
1417
  version: 1,
1052
- id: `plan-${S(e.title, "dashboard")}`,
1418
+ id: `plan-${F(e.title, "dashboard")}`,
1053
1419
  title: e.title,
1054
1420
  description: e.description,
1055
- datasets: r,
1421
+ datasets: r.datasets,
1056
1422
  sheets: [
1057
1423
  {
1058
- id: `sheet-${S(e.title, "dashboard")}`,
1424
+ id: `sheet-${F(e.title, "dashboard")}`,
1059
1425
  title: e.title,
1060
1426
  description: e.description,
1061
1427
  kind: "dashboard",
1062
- cards: l
1428
+ cards: i
1063
1429
  }
1064
1430
  ],
1065
- filterInputs: b.length ? b : void 0,
1431
+ filterInputs: I.length ? I : void 0,
1066
1432
  warnings: t.length ? t : void 0,
1067
- unresolvedRequests: a.ok ? void 0 : a.errors.map((p) => p.message)
1433
+ unresolvedRequests: n.ok ? void 0 : n.errors.map((m) => m.message)
1068
1434
  }, warnings: t };
1069
1435
  }
1070
1436
  export {
1071
- te as DASHBOARD_AUTHORING_BREAKPOINTS,
1072
- $ as DASHBOARD_AUTHORING_MAX_GENERATED_CARDS,
1073
- Ee as applyDashboardChangePlan,
1074
- Oe as compileDashboardFromPlan,
1075
- P as compileResponsiveDashboardLayouts,
1076
- He as dashboardPlanFromSemaphorDashboardIntent,
1077
- ne as validateDashboardChangePlan,
1078
- ae as validateDashboardPlan
1437
+ ge as DASHBOARD_AUTHORING_BREAKPOINTS,
1438
+ M as DASHBOARD_AUTHORING_MAX_GENERATED_CARDS,
1439
+ St as applyDashboardChangePlan,
1440
+ kt as compileDashboardFromPlan,
1441
+ E as compileResponsiveDashboardLayouts,
1442
+ W as dashboardAuthoringDatasetMatchesSource,
1443
+ ve as dashboardAuthoringFieldsReferToSameTarget,
1444
+ v as dashboardAuthoringSourceFromField,
1445
+ ee as dashboardAuthoringSourceKey,
1446
+ ae as dashboardAuthoringSourcesReferToSameDataset,
1447
+ At as dashboardPlanFromSemaphorDashboardIntent,
1448
+ vt as findDashboardAuthoringDatasetForSource,
1449
+ Fe as getDashboardAuthoringCardSource,
1450
+ N as isMaterializableDashboardAuthoringSource,
1451
+ ye as isSemaphorSourceRef,
1452
+ q as mergeDashboardAuthoringSources,
1453
+ _e as preferDashboardAuthoringSourceMetadata,
1454
+ wt as preferredDashboardAuthoringSource,
1455
+ we as resolveDashboardAuthoringSource,
1456
+ Ne as validateDashboardAuthoringDatasetScope,
1457
+ qe as validateDashboardChangePlan,
1458
+ Me as validateDashboardPlan
1079
1459
  };