react-semaphor 0.1.474 → 0.1.476

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 (60) hide show
  1. package/dist/brand-studio/index.cjs +1 -1
  2. package/dist/brand-studio/index.js +1 -1
  3. package/dist/briefings/index.cjs +1 -1
  4. package/dist/briefings/index.js +20 -20
  5. package/dist/chunks/{dashboard-briefing-launcher-BjCkA5vw.cjs → dashboard-briefing-launcher-ZfuxdRN2.cjs} +1 -1
  6. package/dist/chunks/{dashboard-briefing-launcher-B0f28WrK.js → dashboard-briefing-launcher-eBsB9kr8.js} +5 -5
  7. package/dist/chunks/{dashboard-controls-CMJqSLgo.js → dashboard-controls-BX6p6z8a.js} +5 -5
  8. package/dist/chunks/{dashboard-controls-BRclCQEX.cjs → dashboard-controls-DwjEc7sO.cjs} +1 -1
  9. package/dist/chunks/dashboard-filter-value-compatibility-BCVF9IHg.js +1026 -0
  10. package/dist/chunks/dashboard-filter-value-compatibility-DLkdeypb.cjs +1 -0
  11. package/dist/chunks/{dashboard-json-1ohpjO_q.js → dashboard-json-BfgitBXc.js} +3 -3
  12. package/dist/chunks/{dashboard-json-DmtGHdDq.cjs → dashboard-json-CdwYFOsc.cjs} +1 -1
  13. package/dist/chunks/{edit-dashboard-visual-DNqJHdHE.cjs → edit-dashboard-visual-Cbougpzc.cjs} +1 -1
  14. package/dist/chunks/{edit-dashboard-visual-D9oKtOo6.js → edit-dashboard-visual-D80DLF7C.js} +6 -6
  15. package/dist/chunks/{editor-action-buttons-DwI3FcSw.cjs → editor-action-buttons-BDRLfaW-.cjs} +1 -1
  16. package/dist/chunks/{editor-action-buttons-C_B8Wzkf.js → editor-action-buttons-DjsEDQok.js} +3 -3
  17. package/dist/chunks/index-CneWIz__.cjs +1404 -0
  18. package/dist/chunks/{index-DsvIlrI-.js → index-D9S3j7_z.js} +532 -463
  19. package/dist/chunks/{index-DalKzjEZ.js → index-Dv5hbC1r.js} +40833 -40225
  20. package/dist/chunks/index-v2MZLyus.cjs +4 -0
  21. package/dist/chunks/{pivot-header-presentation-Be3FyR0N.js → pivot-header-presentation-CaERAWpl.js} +144 -128
  22. package/dist/chunks/pivot-header-presentation-CePk1R6g.cjs +4 -0
  23. package/dist/chunks/{pivot-result-lifecycle-PxmbJWkm.js → pivot-result-lifecycle-B9FTybxN.js} +176 -165
  24. package/dist/chunks/pivot-result-lifecycle-CcGt_29N.cjs +1 -0
  25. package/dist/chunks/{report-preferences-dialog-C9mJffNQ.js → report-preferences-dialog-BXBlvW79.js} +2 -2
  26. package/dist/chunks/{report-preferences-dialog-DGMd-eTT.cjs → report-preferences-dialog-cSMJYqns.cjs} +1 -1
  27. package/dist/chunks/switch-B1mZx2k9.cjs +138 -0
  28. package/dist/chunks/{switch-D20CIzj6.js → switch-C8NihGV4.js} +3326 -3318
  29. package/dist/dashboard/index.cjs +1 -1
  30. package/dist/dashboard/index.js +1 -1
  31. package/dist/dashboard-authoring/index.cjs +3 -3
  32. package/dist/dashboard-authoring/index.js +298 -287
  33. package/dist/data-app-builder/index.cjs +1 -1
  34. package/dist/data-app-builder/index.js +2 -2
  35. package/dist/format-utils/index.cjs +3 -3
  36. package/dist/format-utils/index.js +92 -82
  37. package/dist/index.cjs +1 -1
  38. package/dist/index.js +6 -6
  39. package/dist/pdf-export-policy/index.cjs +1 -0
  40. package/dist/pdf-export-policy/index.js +32 -0
  41. package/dist/surfboard/index.cjs +1 -1
  42. package/dist/surfboard/index.js +2 -2
  43. package/dist/types/briefings.d.ts +13 -1
  44. package/dist/types/dashboard-assistant.d.ts +2 -0
  45. package/dist/types/dashboard-authoring.d.ts +13 -1
  46. package/dist/types/dashboard.d.ts +19 -1
  47. package/dist/types/format-utils.d.ts +46 -0
  48. package/dist/types/main.d.ts +19 -1
  49. package/dist/types/pdf-export-policy.d.ts +28 -0
  50. package/dist/types/shared.d.ts +13 -1
  51. package/dist/types/surfboard.d.ts +19 -1
  52. package/dist/types/types.d.ts +19 -1
  53. package/package.json +6 -1
  54. package/dist/chunks/dashboard-filter-value-compatibility-9W8Ckcle.js +0 -846
  55. package/dist/chunks/dashboard-filter-value-compatibility-Co1dn9Bc.cjs +0 -1
  56. package/dist/chunks/index-B4VxBoJg.cjs +0 -4
  57. package/dist/chunks/index-B6zSYUN4.cjs +0 -1404
  58. package/dist/chunks/pivot-header-presentation-Cr6pU5JL.cjs +0 -4
  59. package/dist/chunks/pivot-result-lifecycle-DJgO2P0H.cjs +0 -1
  60. package/dist/chunks/switch-B4eH4guz.cjs +0 -138
@@ -1,846 +0,0 @@
1
- var K = Object.defineProperty;
2
- var Q = (e, n, t) => n in e ? K(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
3
- var j = (e, n, t) => Q(e, typeof n != "symbol" ? n + "" : n, t);
4
- import { ai as y, ak as Y, j as P, C as $, F as C } from "./validators-D-T-2HOR.js";
5
- import "./analyze-result-contract-C8s8EUL5.js";
6
- import "../value-format-preferences/index.js";
7
- import { l as G } from "./source-entity-resolution-ugN3sZUk.js";
8
- function c(e) {
9
- return typeof e == "string" && e.trim().length > 0 ? e.trim() : null;
10
- }
11
- function J(e) {
12
- return Array.from(new Set(e.filter((n) => !!n)));
13
- }
14
- function X(e) {
15
- const n = c(e.table), t = c(e.schema), s = c(e.catalog) || c(e.database);
16
- return n ? J([
17
- n,
18
- t ? `${t}.${n}` : null,
19
- s ? `${s}.${n}` : null,
20
- s && t ? `${s}.${t}.${n}` : null
21
- ]) : [];
22
- }
23
- function H(e) {
24
- const n = c(e.table) || c(e.tableName);
25
- return J([
26
- c(e.name),
27
- c(e.alias),
28
- ...X({
29
- table: n,
30
- schema: c(e.schema) || c(e.schemaName),
31
- catalog: c(e.catalog),
32
- database: c(e.database) || c(e.databaseName)
33
- })
34
- ]);
35
- }
36
- function Z(e, n) {
37
- const t = c(e.domainId), s = c(n.domainId);
38
- if (t && s && t !== s)
39
- return !0;
40
- if (e.type === "dataset")
41
- return !1;
42
- const i = c(e.id), d = c(n.id);
43
- if (i && d && i !== d)
44
- return !0;
45
- const a = c(e.connectionId), o = c(n.connectionId);
46
- return !!(a && o && a !== o);
47
- }
48
- function R(e, n = !1) {
49
- return c(e.table) || c(e.tableName) || (e.type !== "dataset" || n ? c(e.name) : null);
50
- }
51
- function x(e) {
52
- return c(e.catalog) || c(e.database) || c(e.databaseName);
53
- }
54
- function w(e) {
55
- return c(e.schema) || c(e.schemaName);
56
- }
57
- function T(e) {
58
- return e.length === 1 ? e[0] : void 0;
59
- }
60
- function S(e, n) {
61
- const t = R(n, !0), s = x(n), i = w(n);
62
- if (!(!t || !s && !i))
63
- return T(
64
- e.filter((d) => {
65
- const a = d;
66
- return !(R(a) !== t || s && x(a) !== s || i && w(a) !== i);
67
- })
68
- );
69
- }
70
- function E(e, n) {
71
- if (!n || !(e != null && e.length))
72
- return;
73
- const t = e.filter(
74
- (o) => !Z(o, n)
75
- );
76
- if (n.type === "dataset") {
77
- const o = c(n.id);
78
- if (o)
79
- return T(
80
- t.filter(
81
- (r) => r.type === "dataset" && c(r.id) === o
82
- )
83
- );
84
- if (c(n.domainId)) {
85
- const r = c(n.name);
86
- return T(
87
- t.filter(
88
- (g) => g.type === "dataset" && c(g.name) === r
89
- )
90
- );
91
- }
92
- }
93
- let s = [];
94
- if (n.type === "dataset") {
95
- const o = c(n.name);
96
- if (s = t.filter(
97
- (l) => l.type === "dataset" && c(l.name) === o
98
- ), s.length === 1)
99
- return s[0];
100
- }
101
- if (!!(R(n, !0) && (x(n) || w(n))))
102
- return S(t, n);
103
- if (s.length > 1)
104
- return;
105
- const d = H(n);
106
- if (d.length === 0)
107
- return;
108
- const a = t.filter((o) => H(
109
- o
110
- ).some(
111
- (r) => d.includes(r)
112
- ));
113
- return T(a);
114
- }
115
- function A(e, n) {
116
- const t = E(e, n);
117
- return t ? { ...n, ...t } : n;
118
- }
119
- function Ne(e, n) {
120
- const t = n || [];
121
- return t.length === 0 ? e : {
122
- ...e,
123
- baseEntity: A(t, e.baseEntity),
124
- joins: e.joins.map((s) => ({
125
- ...s,
126
- source: A(t, s.source),
127
- target: A(t, s.target)
128
- }))
129
- };
130
- }
131
- function Ae(e, n) {
132
- if (!(e != null && e.joins.length))
133
- return [];
134
- const t = [
135
- e.baseEntity,
136
- ...e.joins.flatMap((i) => [i.source, i.target])
137
- ], s = [];
138
- return t.forEach((i) => {
139
- !E(n, i) && !E(s, i) && s.push(i);
140
- }), s;
141
- }
142
- function I(e) {
143
- return !!e && typeof e == "object" && !Array.isArray(e);
144
- }
145
- function k(e) {
146
- return I(e) && typeof e.name == "string";
147
- }
148
- function B(e) {
149
- return !I(e) || e.kind !== "semantic" && e.kind !== "physical" || (e.kind === "semantic" ? [e.datasetId, e.datasetName, e.connectionId] : [e.databaseName, e.schemaName]).some(
150
- (t) => t !== void 0 && typeof t != "string"
151
- ) ? !1 : P(
152
- e
153
- );
154
- }
155
- function M(e, n) {
156
- var r, g;
157
- const t = Array.isArray(n == null ? void 0 : n.selectedEntities) ? n.selectedEntities.filter(k) : void 0, s = E(t, e), i = s ? { ...e, ...s } : e, d = "domainId" in i && typeof i.domainId == "string" && !!i.domainId.trim();
158
- if ((n == null ? void 0 : n.mode) === "semanticDomain" && !d)
159
- return;
160
- if ((n == null ? void 0 : n.mode) !== "database" && i.type === "dataset") {
161
- const u = G(
162
- {
163
- entities: [i],
164
- semanticDomainId: n == null ? void 0 : n.semanticDomainId,
165
- connectionId: n == null ? void 0 : n.connectionId,
166
- fieldEntityType: "dataset"
167
- },
168
- { includePhysicalDatasets: !0 }
169
- );
170
- if (u.kind === "resolved") {
171
- const f = "label" in i && typeof i.label == "string" ? i.label : void 0;
172
- return {
173
- ...u.source,
174
- ...f ? { label: f } : {}
175
- };
176
- }
177
- }
178
- if ((n == null ? void 0 : n.mode) === "semanticDomain")
179
- return;
180
- const a = i.connectionId || (n == null ? void 0 : n.connectionId), o = i.type === "dataset" && "table" in i && i.table ? i.table : i.name;
181
- if (!a || !o)
182
- return;
183
- const l = {
184
- kind: "physical",
185
- connectionId: a,
186
- connectionType: i.connectionType || (n == null ? void 0 : n.connectionType),
187
- tableName: o,
188
- databaseName: i.database || ((r = n == null ? void 0 : n.dbSelection) == null ? void 0 : r.database),
189
- schemaName: i.schema || ((g = n == null ? void 0 : n.dbSelection) == null ? void 0 : g.schema),
190
- dialect: i.dialect
191
- };
192
- return B(l) ? l : void 0;
193
- }
194
- function ee(e, n) {
195
- var o, l;
196
- const t = M(e, n);
197
- if (!t) return;
198
- const s = e.type === "dataset" && "table" in e && typeof e.table == "string" ? e.table.trim() : void 0, i = t.kind === "physical" ? t.tableName : s, d = e.connectionId || (n == null ? void 0 : n.connectionId), a = i && d ? {
199
- connectionId: d,
200
- databaseName: e.database || ((o = n == null ? void 0 : n.dbSelection) == null ? void 0 : o.database),
201
- schemaName: e.schema || ((l = n == null ? void 0 : n.dbSelection) == null ? void 0 : l.schema),
202
- tableName: i
203
- } : void 0;
204
- return { source: t, ...a ? { executionTable: a } : {} };
205
- }
206
- function ne(e) {
207
- const n = I(e.dataSource) ? e.dataSource : void 0;
208
- if (typeof e.sql == "string" && e.sql.trim()) {
209
- const a = [], o = Array.isArray(n == null ? void 0 : n.selectedEntities) ? n.selectedEntities : [];
210
- for (const l of o) {
211
- if (!k(l)) continue;
212
- const r = ee(l, n);
213
- r && !a.some(
214
- (g) => y(
215
- g.source,
216
- r.source
217
- )
218
- ) && a.push(r);
219
- }
220
- return {
221
- cardId: e.id,
222
- kind: "sql",
223
- pinnedCatalogSources: a
224
- };
225
- }
226
- if (!I(e.config))
227
- return { cardId: e.id, kind: "unconfigured" };
228
- const t = [], s = I(e.config.matrixIntent) ? e.config.matrixIntent : void 0, i = e.type === "matrixTable" ? (s == null ? void 0 : s.kind) === "matrix" ? s.source : e.config.source : void 0;
229
- B(i) && t.push(i);
230
- const d = I(e.config.joinPlan) ? e.config.joinPlan : void 0;
231
- if (d) {
232
- const a = Array.isArray(d.joins) ? d.joins : [], o = [d.baseEntity];
233
- for (const r of a)
234
- I(r) && o.push(r.source, r.target);
235
- let l = !1;
236
- for (const r of o) {
237
- if (!k(r)) {
238
- l = !0;
239
- continue;
240
- }
241
- const g = M(r, n);
242
- g ? t.push(g) : l = !0;
243
- }
244
- l && (t.length = 0);
245
- } else if (e.type !== "matrixTable") {
246
- const a = Array.isArray(n == null ? void 0 : n.selectedEntities) ? n.selectedEntities : [];
247
- if (a.length === 1 && k(a[0])) {
248
- const o = M(a[0], n);
249
- o && t.push(o);
250
- }
251
- }
252
- if (!t.length && !d && e.type !== "matrixTable") {
253
- const a = e.config.queryBaseSource;
254
- B(a) && t.push(a);
255
- }
256
- return {
257
- cardId: e.id,
258
- kind: "config",
259
- executableSources: Y(t)
260
- };
261
- }
262
- function te(e, n) {
263
- return (e.kind === "config" ? e.executableSources : e.kind === "sql" ? e.pinnedCatalogSources.map((s) => s.source) : []).some(
264
- (s) => y(s, n)
265
- );
266
- }
267
- function Ce(e, n) {
268
- if (e.kind === "config")
269
- return e.executableSources.find(
270
- (t) => y(t, n)
271
- );
272
- }
273
- function Re(e, n) {
274
- var t;
275
- return (t = U(e, n)) == null ? void 0 : t.source;
276
- }
277
- function U(e, n) {
278
- if (e.kind === "sql")
279
- return e.pinnedCatalogSources.find(
280
- (t) => y(t.source, n)
281
- );
282
- }
283
- function L(e) {
284
- const n = /* @__PURE__ */ new Set();
285
- for (const t of [e.name, e.sourceField]) {
286
- if (!t) continue;
287
- const s = $(t);
288
- if (!s) continue;
289
- n.add(s);
290
- const i = s.split("."), d = i[i.length - 1];
291
- d && n.add(d);
292
- }
293
- return n;
294
- }
295
- function V(e, n) {
296
- const t = C(e), s = C(n);
297
- return t === "unknown" || s === "unknown" ? !1 : (t === "date" || t === "datetime") && (s === "date" || s === "datetime") ? !0 : t === s;
298
- }
299
- function ie(e, n) {
300
- return y(e.field.source, n.field.source) && $(e.field.name) === $(n.field.name) && $(e.field.sourceField || e.field.name) === $(n.field.sourceField || n.field.name);
301
- }
302
- function se(e, n) {
303
- if (e.kind !== "field") return !1;
304
- const t = L(n), s = L(e.field);
305
- return V(n.dataType, e.field.dataType) && [...s].some((i) => t.has(i));
306
- }
307
- function xe(e) {
308
- const n = e.candidates.filter(
309
- (t) => se(
310
- t,
311
- e.logicalValueField
312
- )
313
- );
314
- return n.length === 1 ? { status: "matched", target: n[0] } : n.length > 1 ? { status: "ambiguous" } : { status: "notApplicable" };
315
- }
316
- function we(e) {
317
- const n = [];
318
- for (const t of e.acceptedTargets)
319
- !V(
320
- e.logicalValueField.dataType,
321
- t.field.dataType
322
- ) || n.some(
323
- (s) => ie(s, t)
324
- ) || n.push(t);
325
- return n.length === 1 ? { status: "matched", target: n[0] } : n.length > 1 ? { status: "ambiguous" } : { status: "notApplicable" };
326
- }
327
- const re = /\{\{-?\s*filters\s*\|\s*where\s*-?\}\}/i, oe = /\{\{-?\s*filters\s*\|\s*and\s*-?\}\}/i, ae = /\bwhere\b/i;
328
- function de(e) {
329
- return e != null && e.trim() ? re.test(e) || oe.test(e) : !1;
330
- }
331
- function Be(e) {
332
- return !(e != null && e.trim()) || de(e) ? null : ae.test(e) ? {
333
- helper: "{{ filters | and }}",
334
- description: "For queries with an existing WHERE clause."
335
- } : {
336
- helper: "{{ filters | where }}",
337
- description: "For queries without a WHERE clause."
338
- };
339
- }
340
- function ce(e) {
341
- return (e.field.sourceField || e.field.name).trim() || void 0;
342
- }
343
- function Me(e) {
344
- if (e.inventory.kind !== "sql" || e.target.kind !== "field")
345
- return { status: "ineligible" };
346
- const n = U(
347
- e.inventory,
348
- e.target.field.source
349
- ), t = ce(e.target);
350
- if (!n || !t) return { status: "ineligible" };
351
- if (n.executionTable) {
352
- const a = [
353
- n.executionTable.databaseName,
354
- n.executionTable.schemaName,
355
- n.executionTable.tableName,
356
- t
357
- ].filter(Boolean).join(".");
358
- return {
359
- status: "eligible",
360
- source: n.source,
361
- executionIdentifier: a
362
- };
363
- }
364
- if (e.inventory.pinnedCatalogSources.length !== 1)
365
- return { status: "ineligible" };
366
- const s = $(t), i = (e.candidateTargets || []).filter(
367
- (a) => $(
368
- a.field.sourceField || a.field.name
369
- ) === s
370
- ), d = [];
371
- for (const a of i)
372
- d.some(
373
- (o) => y(o, a.field.source)
374
- ) || d.push(a.field.source);
375
- return d.length > 1 ? { status: "ineligible" } : {
376
- status: "eligible",
377
- source: n.source,
378
- executionIdentifier: t
379
- };
380
- }
381
- class le extends Error {
382
- constructor(t) {
383
- super(t.map((s) => s.message).join(" "));
384
- j(this, "issues");
385
- this.name = "DashboardFilterMappingContractError", this.issues = t;
386
- }
387
- }
388
- const fe = {
389
- string: !0,
390
- number: !0,
391
- boolean: !0,
392
- date: !0,
393
- datetime: !0
394
- };
395
- function h(e) {
396
- return typeof e == "string" && e.trim().length > 0;
397
- }
398
- function m(e) {
399
- return !!e && typeof e == "object" && !Array.isArray(e);
400
- }
401
- function F(e) {
402
- return Array.isArray(e) && e.every((n) => typeof n == "string");
403
- }
404
- function ue(e) {
405
- if (!m(e)) return !1;
406
- switch (e.kind) {
407
- case "allSheets":
408
- return e.sheetKinds === void 0 || F(e.sheetKinds) && e.sheetKinds.every(
409
- (n) => n === "dashboard" || n === "document"
410
- );
411
- case "sheets":
412
- return F(e.sheetIds);
413
- case "cards":
414
- return F(e.cardIds);
415
- case "documentSections":
416
- return h(e.sheetId) && F(e.sectionIds);
417
- default:
418
- return !1;
419
- }
420
- }
421
- function me(e) {
422
- return e === "shared" || e === "perSheet" || e === "perCard" || e === "perDocumentSection";
423
- }
424
- function he(e) {
425
- return m(e) ? h(e.id) && h(e.column) && h(e.dataType) : !1;
426
- }
427
- function ge(e, n, t, s) {
428
- var o;
429
- if (!m(n)) {
430
- s.push({
431
- code: "invalid_option_source",
432
- path: t,
433
- message: `${t} must be a semantic or physical option source.`,
434
- inputId: e
435
- });
436
- return;
437
- }
438
- const i = n.source, d = [
439
- ["labelField", n.labelField],
440
- ["valueField", n.valueField],
441
- ["searchField", n.searchField]
442
- ];
443
- if (!m(i) || i.kind !== "semantic" && i.kind !== "physical" || !P(i) || !m(n.labelField) || !m(n.valueField) || n.searchField !== void 0 && !m(n.searchField) || n.disambiguationFields !== void 0 && (!Array.isArray(n.disambiguationFields) || !n.disambiguationFields.every(m))) {
444
- s.push({
445
- code: "invalid_option_source",
446
- path: t,
447
- message: `${t} must contain a valid semantic or physical source and field references.`,
448
- inputId: e
449
- });
450
- return;
451
- }
452
- for (const [l, r] of d)
453
- r !== void 0 && m(r) && (!h(r.name) || r.source !== void 0 && !y(
454
- r.source,
455
- i
456
- )) && s.push({
457
- code: "invalid_option_source",
458
- path: `${t}.${l}`,
459
- message: `${t}.${l} must be a named field belonging to the declared option source.`,
460
- inputId: e
461
- });
462
- for (const [l, r] of ((o = n.disambiguationFields) == null ? void 0 : o.entries()) || [])
463
- (!m(r) || !h(r.name) || r.source !== void 0 && !y(
464
- r.source,
465
- i
466
- )) && s.push({
467
- code: "invalid_option_source",
468
- path: `${t}.disambiguationFields[${l}]`,
469
- message: `${t}.disambiguationFields[${l}] must be a named field belonging to the declared option source.`,
470
- inputId: e
471
- });
472
- const a = n.valueField;
473
- ["string", "number", "boolean", "date", "datetime"].includes(
474
- String(a.dataType)
475
- ) || s.push({
476
- code: "invalid_option_source",
477
- path: `${t}.valueField.dataType`,
478
- message: `${t}.valueField.dataType must be a known option-value datatype.`,
479
- inputId: e
480
- });
481
- }
482
- function be(e, n, t, s, i, d) {
483
- var r;
484
- if (h(n.bindingId) || i.push({
485
- code: "invalid_binding_id",
486
- path: `${t}.bindingId`,
487
- message: `${t}.bindingId must be an opaque non-empty id.`,
488
- inputId: e,
489
- cardId: n.cardId
490
- }), ((r = n.target) == null ? void 0 : r.kind) !== "field") {
491
- i.push({
492
- code: "unsupported_target",
493
- path: `${t}.target`,
494
- message: `${t}.target must be one direct field target.`,
495
- inputId: e,
496
- cardId: n.cardId,
497
- bindingId: n.bindingId
498
- });
499
- return;
500
- }
501
- const a = n.target.field;
502
- if (!h(a == null ? void 0 : a.name) || !a.source || a.source.kind !== "semantic" && a.source.kind !== "physical" || !P(a.source)) {
503
- i.push({
504
- code: "invalid_target_field",
505
- path: `${t}.target.field`,
506
- message: `${t}.target.field must have a name and a source-qualified semantic or physical identity.`,
507
- inputId: e,
508
- cardId: n.cardId,
509
- bindingId: n.bindingId
510
- });
511
- return;
512
- }
513
- if (Object.prototype.hasOwnProperty.call(
514
- fe,
515
- a.dataType
516
- ) || i.push({
517
- code: "unknown_target_data_type",
518
- path: `${t}.target.field.dataType`,
519
- message: `${t}.target.field.dataType must be known.`,
520
- inputId: e,
521
- cardId: n.cardId,
522
- bindingId: n.bindingId
523
- }), a.sourceField !== void 0 && !h(a.sourceField) && i.push({
524
- code: "invalid_target_field",
525
- path: `${t}.target.field.sourceField`,
526
- message: `${t}.target.field.sourceField must be a non-empty catalog-grounded column when provided.`,
527
- inputId: e,
528
- cardId: n.cardId,
529
- bindingId: n.bindingId
530
- }), !d) return;
531
- const o = s.get(n.cardId);
532
- if (!o) {
533
- i.push({
534
- code: "unknown_card",
535
- path: `${t}.cardId`,
536
- message: `${t}.cardId '${n.cardId}' does not exist.`,
537
- inputId: e,
538
- cardId: n.cardId,
539
- bindingId: n.bindingId
540
- });
541
- return;
542
- }
543
- const l = ne(o);
544
- (l.kind === "unconfigured" || !te(l, a.source)) && i.push({
545
- code: "unavailable_card_source",
546
- path: `${t}.target.field.source`,
547
- message: `${t}.target field source is not declared by card '${o.id}'.`,
548
- inputId: e,
549
- cardId: o.id,
550
- bindingId: n.bindingId
551
- });
552
- }
553
- function pe(e, n, t, s, i, d) {
554
- if (n === void 0) return;
555
- if (!m(n) || n.kind !== "cardMappings" || !Array.isArray(n.cards)) {
556
- i.push({
557
- code: "invalid_application",
558
- path: t,
559
- message: `${t} must be a cardMappings application with a cards array.`,
560
- inputId: e
561
- });
562
- return;
563
- }
564
- const a = /* @__PURE__ */ new Set();
565
- n.cards.forEach((o, l) => {
566
- const r = `${t}.cards[${l}]`;
567
- if (!h(o == null ? void 0 : o.cardId)) {
568
- i.push({
569
- code: "unknown_card",
570
- path: `${r}.cardId`,
571
- message: `${r}.cardId is required.`,
572
- inputId: e
573
- });
574
- return;
575
- }
576
- if (a.has(o.cardId)) {
577
- i.push({
578
- code: "duplicate_card_application",
579
- path: `${r}.cardId`,
580
- message: `${t} contains more than one entry for card '${o.cardId}'.`,
581
- inputId: e,
582
- cardId: o.cardId
583
- });
584
- return;
585
- }
586
- if (a.add(o.cardId), d && !s.has(o.cardId)) {
587
- i.push({
588
- code: "unknown_card",
589
- path: `${r}.cardId`,
590
- message: `${r}.cardId '${o.cardId}' does not exist.`,
591
- inputId: e,
592
- cardId: o.cardId
593
- });
594
- return;
595
- }
596
- o.kind === "bound" ? be(
597
- e,
598
- o,
599
- r,
600
- s,
601
- i,
602
- d
603
- ) : o.kind !== "excluded" && i.push({
604
- code: "invalid_application",
605
- path: r,
606
- message: `${r}.kind must be 'bound' or 'excluded'.`,
607
- inputId: e,
608
- cardId: o.cardId
609
- });
610
- });
611
- }
612
- function ye({
613
- inputs: e,
614
- dashboardFilters: n,
615
- cards: t = [],
616
- validateCardTargets: s = !1
617
- }) {
618
- const i = [], d = new Map(
619
- (n || []).map((r) => [r.id, r])
620
- ), a = new Map(
621
- s ? t.map((r) => [r.id, r]) : []
622
- ), o = [], l = /* @__PURE__ */ new Map();
623
- return e != null && !Array.isArray(e) ? (i.push({
624
- code: "invalid_input",
625
- path: "dashboard.inputs",
626
- message: "dashboard.inputs must be an array when present."
627
- }), { ok: !1, inputs: o, issues: i }) : ((Array.isArray(e) ? e : []).forEach((r, g) => {
628
- const u = `dashboard.inputs[${g}]`;
629
- if (!m(r) || r.kind !== "filter" && r.kind !== "control" || !h(r.id) || !h(r.label) || !h(r.variableName) || !ue(r.scope) || !me(r.runtimeScope)) {
630
- i.push({
631
- code: "invalid_input",
632
- path: u,
633
- message: `${u} must be a complete filter or control Dashboard Input envelope.`,
634
- inputId: m(r) && typeof r.id == "string" ? r.id : void 0
635
- });
636
- return;
637
- }
638
- if (r.kind === "control" && !m(r.control)) {
639
- i.push({
640
- code: "invalid_input",
641
- path: `${u}.control`,
642
- message: `${u}.control must be a control definition.`,
643
- inputId: r.id
644
- });
645
- return;
646
- }
647
- const f = r;
648
- if (f.kind === "control") {
649
- o.push(f);
650
- return;
651
- }
652
- const v = f.filter, p = f.filterReference, _ = v !== void 0, z = !!p;
653
- if (_ && z) {
654
- i.push({
655
- code: "both_filter_definitions",
656
- path: u,
657
- message: `${u} must contain either filter or filterReference, not both.`,
658
- inputId: f.id
659
- });
660
- return;
661
- }
662
- if (!_ && !z) {
663
- i.push({
664
- code: "missing_filter_definition",
665
- path: u,
666
- message: `${u} must contain filter or filterReference.`,
667
- inputId: f.id
668
- });
669
- return;
670
- }
671
- if (_ && !he(v)) {
672
- i.push({
673
- code: "invalid_input",
674
- path: `${u}.filter`,
675
- message: `${u}.filter must be a complete dashboard filter definition.`,
676
- inputId: f.id
677
- });
678
- return;
679
- }
680
- let b, D;
681
- if (_)
682
- b = v, D = "embedded";
683
- else {
684
- if ((p == null ? void 0 : p.kind) !== "dashboardFilter") {
685
- i.push({
686
- code: "invalid_filter_reference",
687
- path: `${u}.filterReference.kind`,
688
- message: `${u}.filterReference.kind must be 'dashboardFilter'.`,
689
- inputId: f.id
690
- });
691
- return;
692
- }
693
- const N = typeof (p == null ? void 0 : p.filterId) == "string" ? p.filterId : void 0;
694
- if (b = N ? d.get(N) : void 0, D = "dashboardFilter", !b) {
695
- i.push({
696
- code: "orphaned_filter_reference",
697
- path: `${u}.filterReference.filterId`,
698
- message: `${u}.filterReference cannot resolve dashboard filter '${N || ""}'.`,
699
- inputId: f.id
700
- });
701
- return;
702
- }
703
- if (b.kind === "global-date") {
704
- i.push({
705
- code: "global_date_reference",
706
- path: `${u}.filterReference`,
707
- message: `${u}.filterReference cannot reference the Global Date filter.`,
708
- inputId: f.id
709
- });
710
- return;
711
- }
712
- const q = l.get(b.id);
713
- if (q) {
714
- i.push({
715
- code: "duplicate_filter_reference",
716
- path: `${u}.filterReference.filterId`,
717
- message: `${u}.filterReference duplicates dashboard filter '${b.id}' already owned by Dashboard Input '${q}'.`,
718
- inputId: f.id
719
- });
720
- return;
721
- }
722
- l.set(b.id, f.id);
723
- }
724
- if (!b) return;
725
- if (f.optionSource !== void 0 && ge(
726
- f.id,
727
- f.optionSource,
728
- `${u}.optionSource`,
729
- i
730
- ), f.application && b.kind === "global-date") {
731
- i.push({
732
- code: "global_date_reference",
733
- path: `${u}.application`,
734
- message: `${u}.application cannot map the Global Date filter.`,
735
- inputId: f.id
736
- });
737
- return;
738
- }
739
- f.application && f.scope.kind !== "allSheets" && f.scope.kind !== "sheets" && i.push({
740
- code: "unsupported_mapped_scope",
741
- path: `${u}.scope`,
742
- message: `${u}.scope must be allSheets or sheets when cardMappings are present.`,
743
- inputId: f.id
744
- }), pe(
745
- f.id,
746
- f.application,
747
- `${u}.application`,
748
- a,
749
- i,
750
- s
751
- );
752
- const {
753
- filter: _e,
754
- filterReference: Fe,
755
- // A reference-backed authored input must shadow the generated
756
- // dashboard-filter compatibility input. Older writers may have copied
757
- // the compatibility marker onto the reference; never preserve it.
758
- compatibility: O,
759
- ...W
760
- } = f;
761
- o.push({
762
- ...W,
763
- filter: b,
764
- ..._ && O ? { compatibility: O } : {},
765
- ...f.optionSource ? {
766
- optionSource: f.optionSource
767
- } : {},
768
- definitionOrigin: D
769
- });
770
- }), i.length ? { ok: !1, inputs: o, issues: i } : { ok: !0, inputs: o });
771
- }
772
- function Pe(e) {
773
- const n = ye(e);
774
- if (!n.ok) throw new le(n.issues);
775
- return n.inputs;
776
- }
777
- function ze(e = () => globalThis.crypto.randomUUID()) {
778
- return e();
779
- }
780
- const Ie = {
781
- date: /* @__PURE__ */ new Set([
782
- "between",
783
- "not between",
784
- "=",
785
- "!=",
786
- ">",
787
- ">=",
788
- "<",
789
- "<=",
790
- "is null",
791
- "is not null"
792
- ]),
793
- number: /* @__PURE__ */ new Set([
794
- "between",
795
- "not between",
796
- "=",
797
- "!=",
798
- ">",
799
- ">=",
800
- "<",
801
- "<=",
802
- "in",
803
- "not in",
804
- "is null",
805
- "is not null"
806
- ]),
807
- string: /* @__PURE__ */ new Set([
808
- "=",
809
- "!=",
810
- "in",
811
- "not in",
812
- "like",
813
- "not like",
814
- "is null",
815
- "is not null"
816
- ]),
817
- boolean: /* @__PURE__ */ new Set(["=", "!=", "in", "not in", "is null", "is not null"])
818
- };
819
- function $e(e) {
820
- const n = C(e);
821
- return n === "number" || n === "boolean" ? n : n === "date" || n === "datetime" ? "date" : "string";
822
- }
823
- function Oe(e, n) {
824
- return typeof n != "string" ? !1 : Ie[$e(e)].has(n);
825
- }
826
- export {
827
- le as D,
828
- Re as a,
829
- ne as b,
830
- U as c,
831
- te as d,
832
- se as e,
833
- Ce as f,
834
- we as g,
835
- de as h,
836
- Be as i,
837
- Me as j,
838
- Pe as k,
839
- ze as l,
840
- $e as m,
841
- ye as n,
842
- Oe as o,
843
- Ne as p,
844
- Ae as q,
845
- xe as r
846
- };