react-semaphor 0.1.335 → 0.1.336

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