react-semaphor 0.1.477 → 0.1.478

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 (109) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +9 -9
  3. package/dist/brand-studio/index.cjs +1 -1
  4. package/dist/brand-studio/index.js +4 -4
  5. package/dist/briefings/index.cjs +1 -1
  6. package/dist/briefings/index.js +4 -4
  7. package/dist/chunks/{analyze-result-contract-OgPk-zGu.cjs → analyze-result-contract-BX_nQmPN.cjs} +1 -1
  8. package/dist/chunks/{analyze-result-contract-C8s8EUL5.js → analyze-result-contract-DsiAzCYn.js} +1 -1
  9. package/dist/chunks/{saved-temporal-bucket-format-CHsXUPJI.js → card-config-utils-CyDKaPNT.js} +190 -190
  10. package/dist/chunks/card-config-utils-D3Xuu0ub.cjs +1 -0
  11. package/dist/chunks/{common-types-C1IM7gao.cjs → common-types-BCSbPclk.cjs} +1 -1
  12. package/dist/chunks/{common-types-BLPy5_E0.js → common-types-D3r4PILe.js} +1 -1
  13. package/dist/chunks/{dashboard-briefing-launcher-CXHq6ime.cjs → dashboard-briefing-launcher-7qAW16mO.cjs} +2 -2
  14. package/dist/chunks/{dashboard-briefing-launcher-C9d8CPxv.js → dashboard-briefing-launcher-DAhtLQPc.js} +134 -134
  15. package/dist/chunks/{dashboard-controls-BqDm4ARp.js → dashboard-controls-C_CBmEwW.js} +13 -12
  16. package/dist/chunks/{dashboard-controls-d7Yd2fJb.cjs → dashboard-controls-CoVqAeKG.cjs} +10 -10
  17. package/dist/chunks/{dashboard-input-contract-JFJZgenC.cjs → dashboard-date-comparison-definition-C93wv8Ua.cjs} +1 -1
  18. package/dist/chunks/{dashboard-input-contract-BrGdGFz0.js → dashboard-date-comparison-definition-KohOqBqR.js} +19 -19
  19. package/dist/chunks/dashboard-filter-value-compatibility-BAatYtUS.js +1215 -0
  20. package/dist/chunks/dashboard-filter-value-compatibility-Bco2gN96.cjs +1 -0
  21. package/dist/chunks/{dashboard-json-CL_vgcWq.js → dashboard-json-0w58H39L.js} +7 -7
  22. package/dist/chunks/dashboard-json-B3XSl7b_.cjs +1 -0
  23. package/dist/chunks/{edit-dashboard-visual-Dklel3MC.cjs → edit-dashboard-visual-BsLRKeuO.cjs} +6 -6
  24. package/dist/chunks/{edit-dashboard-visual-C0Zvyo-X.js → edit-dashboard-visual-BsWEU8xf.js} +277 -277
  25. package/dist/chunks/{editor-action-buttons-BOyUtX9j.js → editor-action-buttons-B3CB5c__.js} +39 -39
  26. package/dist/chunks/{editor-action-buttons-AcaZsiDy.cjs → editor-action-buttons-DMLDvrJD.cjs} +1 -1
  27. package/dist/chunks/{index-Cd8qGOXl.cjs → index--0Il-Bpd.cjs} +238 -238
  28. package/dist/chunks/{format-types-CFHQoIuk.js → index-BS0_dp0l.js} +168 -168
  29. package/dist/chunks/{index-D9S3j7_z.js → index-BvRREsU9.js} +9 -9
  30. package/dist/chunks/index-ByQgqT9d.cjs +1 -0
  31. package/dist/chunks/{index-v2MZLyus.cjs → index-CXeIDdjd.cjs} +1 -1
  32. package/dist/chunks/{index-DrdF7QR7.js → index-DgGcVyUs.js} +30518 -31308
  33. package/dist/chunks/matrix-result-contract-CFPnlcLm.cjs +1 -0
  34. package/dist/chunks/{matrix-result-contract-BpzhImar.js → matrix-result-contract-DFfUvb1r.js} +3 -3
  35. package/dist/chunks/{temporal-bucket-CtP7hKLa.js → metric-comparison-CTexJ8V1.js} +705 -705
  36. package/dist/chunks/metric-comparison-x0lipytf.cjs +1 -0
  37. package/dist/chunks/pivot-header-presentation-8Ra1RfHg.cjs +4 -0
  38. package/dist/chunks/{pivot-header-presentation-CaERAWpl.js → pivot-header-presentation-tpb_J900.js} +118 -118
  39. package/dist/chunks/{pivot-result-identity-CIZXsI53.js → pivot-result-identity-BIeP9v8I.js} +1 -1
  40. package/dist/chunks/{pivot-result-identity-DRUlTWUq.cjs → pivot-result-identity-BVnhG2rR.cjs} +1 -1
  41. package/dist/chunks/pivot-result-lifecycle-D_bRCqaB.cjs +1 -0
  42. package/dist/chunks/{pivot-result-lifecycle-B9FTybxN.js → pivot-result-lifecycle-mjJ1rBvV.js} +7 -7
  43. package/dist/chunks/{raw-temporal-contract-U8J9RlEH.js → raw-temporal-contract-BuQIB31z.js} +1 -1
  44. package/dist/chunks/{raw-temporal-contract-D8YuxTAg.cjs → raw-temporal-contract-vnNwLy9R.cjs} +1 -1
  45. package/dist/chunks/{report-preferences-dialog-BjygtSP3.js → report-preferences-dialog-Bytgubvz.js} +25 -25
  46. package/dist/chunks/report-preferences-dialog-I0Pbn_Yb.cjs +1 -0
  47. package/dist/chunks/{report-runtime-context-DNbgCsko.js → report-runtime-context-B_pAmqxl.js} +1 -1
  48. package/dist/chunks/{report-runtime-context-RFiWq4wK.cjs → report-runtime-context-BfW4qiMJ.cjs} +1 -1
  49. package/dist/chunks/{source-entity-resolution-BDC-Qngk.cjs → source-entity-resolution-DCAAS-y8.cjs} +1 -1
  50. package/dist/chunks/{source-entity-resolution-ugN3sZUk.js → source-entity-resolution-WUstJID6.js} +1 -1
  51. package/dist/chunks/{switch-C8NihGV4.js → switch-BsGTOjuD.js} +12342 -11110
  52. package/dist/chunks/switch-Cpj3DrCZ.cjs +138 -0
  53. package/dist/chunks/{temporal-bucket-authoring-DJ9kK2wD.js → temporal-bucket-authoring-CyTCHy1K.js} +3 -3
  54. package/dist/chunks/temporal-bucket-authoring-DueSgLJU.cjs +1 -0
  55. package/dist/chunks/{temporal-bucket-contract-CZl5D7FZ.js → temporal-bucket-contract-BeOx0uYe.js} +1 -1
  56. package/dist/chunks/{temporal-bucket-contract-BD862TAa.cjs → temporal-bucket-contract-Cp-usD9Z.cjs} +1 -1
  57. package/dist/chunks/{token-types-CoHsSJ4E.cjs → token-types-D9eN35rf.cjs} +1 -1
  58. package/dist/chunks/{token-types-DfDtCqlw.js → token-types-Dvomvqw0.js} +1 -1
  59. package/dist/chunks/{update-policy-BGNXFgBU.cjs → update-policy-Buw2LmvX.cjs} +1 -1
  60. package/dist/chunks/{update-policy-BybMiM61.js → update-policy-MWg0aH3d.js} +1 -1
  61. package/dist/chunks/{validators-D-T-2HOR.js → validators-D3AarM2T.js} +662 -663
  62. package/dist/chunks/validators-DqIM0B3C.cjs +1 -0
  63. package/dist/dashboard/index.cjs +1 -1
  64. package/dist/dashboard/index.js +2 -2
  65. package/dist/dashboard-authoring/index.cjs +3 -3
  66. package/dist/dashboard-authoring/index.js +81 -79
  67. package/dist/data-app-builder/index.cjs +1 -1
  68. package/dist/data-app-builder/index.js +2 -2
  69. package/dist/data-app-codegen/index.cjs +1 -1
  70. package/dist/data-app-codegen/index.js +2 -2
  71. package/dist/data-app-codegen-node/index.cjs +1 -1
  72. package/dist/data-app-codegen-node/index.js +3 -3
  73. package/dist/data-app-sdk/index.cjs +1 -1
  74. package/dist/data-app-sdk/index.js +3 -3
  75. package/dist/data-app-sdk-adapters/index.cjs +1 -1
  76. package/dist/data-app-sdk-adapters/index.js +2 -2
  77. package/dist/data-app-sdk-validation/index.cjs +1 -1
  78. package/dist/data-app-sdk-validation/index.js +3 -3
  79. package/dist/format-utils/index.cjs +3 -3
  80. package/dist/format-utils/index.js +9 -9
  81. package/dist/index.cjs +1 -1
  82. package/dist/index.js +177 -176
  83. package/dist/report-runtime-context/index.cjs +1 -1
  84. package/dist/report-runtime-context/index.js +2 -2
  85. package/dist/surfboard/index.cjs +1 -1
  86. package/dist/surfboard/index.js +3 -3
  87. package/dist/types/briefings.d.ts +11 -0
  88. package/dist/types/dashboard-authoring.d.ts +17 -0
  89. package/dist/types/dashboard.d.ts +11 -0
  90. package/dist/types/index.cjs +1 -1
  91. package/dist/types/index.js +4 -4
  92. package/dist/types/main.d.ts +12 -0
  93. package/dist/types/shared.d.ts +11 -0
  94. package/dist/types/surfboard.d.ts +11 -0
  95. package/dist/types/types.d.ts +11 -0
  96. package/package.json +1 -1
  97. package/dist/chunks/dashboard-filter-value-compatibility-BCVF9IHg.js +0 -1026
  98. package/dist/chunks/dashboard-filter-value-compatibility-DLkdeypb.cjs +0 -1
  99. package/dist/chunks/dashboard-json-BYQjTmqD.cjs +0 -1
  100. package/dist/chunks/format-types-PSZZ7hG8.cjs +0 -1
  101. package/dist/chunks/matrix-result-contract-Bhg60NtS.cjs +0 -1
  102. package/dist/chunks/pivot-header-presentation-CePk1R6g.cjs +0 -4
  103. package/dist/chunks/pivot-result-lifecycle-CcGt_29N.cjs +0 -1
  104. package/dist/chunks/report-preferences-dialog-DW40ECz1.cjs +0 -1
  105. package/dist/chunks/saved-temporal-bucket-format-DNMtD77o.cjs +0 -1
  106. package/dist/chunks/switch-B1mZx2k9.cjs +0 -138
  107. package/dist/chunks/temporal-bucket-9Wz9Ds6H.cjs +0 -1
  108. package/dist/chunks/temporal-bucket-authoring-DSpzgXHc.cjs +0 -1
  109. package/dist/chunks/validators-DcshgK7w.cjs +0 -1
@@ -0,0 +1,1215 @@
1
+ var de = Object.defineProperty;
2
+ var ce = (e, t, n) => t in e ? de(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var G = (e, t, n) => ce(e, typeof t != "symbol" ? t + "" : t, n);
4
+ import { ai as I, ak as le, j, C as T, F as x } from "./validators-D3AarM2T.js";
5
+ import "./analyze-result-contract-DsiAzCYn.js";
6
+ import "../value-format-preferences/index.js";
7
+ import { l as fe } from "./source-entity-resolution-WUstJID6.js";
8
+ const ue = (e, t) => {
9
+ const n = {};
10
+ if (e === null || t === null)
11
+ return t;
12
+ const s = /* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(t)]);
13
+ for (const i of s) {
14
+ if (!(i in e) && i in t) {
15
+ n[i] = t[i];
16
+ continue;
17
+ }
18
+ if (i in e && !(i in t)) {
19
+ n[i] = void 0;
20
+ continue;
21
+ }
22
+ const r = e[i], o = t[i];
23
+ if (!w(r, o))
24
+ if (Array.isArray(r) && Array.isArray(o))
25
+ n[i] = o;
26
+ else if (U(r) && U(o)) {
27
+ const d = ue(r, o);
28
+ Object.keys(d).length > 0 && (n[i] = d);
29
+ } else
30
+ n[i] = o;
31
+ }
32
+ return n;
33
+ }, w = (e, t) => {
34
+ if (e === t) return !0;
35
+ if (e && t && typeof e == "object" && typeof t == "object") {
36
+ if (Array.isArray(e) && Array.isArray(t))
37
+ return e.length !== t.length ? !1 : e.every((i, r) => w(i, t[r]));
38
+ const n = Object.keys(e), s = Object.keys(t);
39
+ return n.length !== s.length ? !1 : n.every((i) => w(e[i], t[i]));
40
+ }
41
+ return !1;
42
+ }, U = (e) => e !== null && typeof e == "object" && !Array.isArray(e), O = (e) => {
43
+ if (e === null || typeof e != "object")
44
+ return e;
45
+ if (e instanceof Date)
46
+ return new Date(e);
47
+ if (e instanceof RegExp)
48
+ return new RegExp(e);
49
+ if (Array.isArray(e))
50
+ return e.map((n) => O(n));
51
+ const t = {};
52
+ for (const n in e)
53
+ Object.prototype.hasOwnProperty.call(e, n) && (t[n] = O(e[n]));
54
+ return t;
55
+ }, K = /\[\[\s*param\.([A-Za-z0-9_.-]+)\s*\]\]/g, Q = /\bparam\s*\(\s*(['"])([^'"]+)\1/g;
56
+ function me(e) {
57
+ const t = [];
58
+ let n = 0;
59
+ for (; n < e.length; ) {
60
+ const s = e.indexOf("{{", n), i = e.indexOf("{%", n);
61
+ let r = -1, o = "";
62
+ if (s === -1 ? (r = i, o = "%}") : i === -1 || s < i ? (r = s, o = "}}") : (r = i, o = "%}"), r === -1)
63
+ break;
64
+ const d = e.indexOf(o, r + 2);
65
+ if (d === -1) {
66
+ n = r + 2;
67
+ continue;
68
+ }
69
+ t.push(e.slice(r + 2, d)), n = d + 2;
70
+ }
71
+ return t;
72
+ }
73
+ function te(e) {
74
+ var s, i;
75
+ if (!e)
76
+ return [];
77
+ const t = /* @__PURE__ */ new Set();
78
+ let n;
79
+ for (K.lastIndex = 0; (n = K.exec(e)) !== null; ) {
80
+ const r = (s = n[1]) == null ? void 0 : s.trim();
81
+ r && t.add(r);
82
+ }
83
+ for (const r of me(e))
84
+ for (Q.lastIndex = 0; (n = Q.exec(r)) !== null; ) {
85
+ const o = (i = n[2]) == null ? void 0 : i.trim();
86
+ o && t.add(o);
87
+ }
88
+ return Array.from(t);
89
+ }
90
+ function Se(e) {
91
+ const t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Map();
92
+ for (const s of e.controlBindings || [])
93
+ t.add(s.controlId), s.target === "sql_param" && n.set(s.paramId, s.controlId);
94
+ for (const s of te(e.sql))
95
+ t.add(n.get(s) ?? s);
96
+ return Array.from(t);
97
+ }
98
+ function ge(e) {
99
+ const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
100
+ for (const s of e.controlBindings || [])
101
+ s.target === "sql_param" && n.set(s.paramId, s.controlId);
102
+ for (const s of te(e.sql))
103
+ t.set(s, {
104
+ paramId: s,
105
+ controlId: n.get(s) ?? s
106
+ });
107
+ return Array.from(t.values());
108
+ }
109
+ function he(e, t) {
110
+ var i;
111
+ const n = (i = e.controlBindings) == null ? void 0 : i.map((r) => ({
112
+ ...r,
113
+ controlId: t.get(r.controlId) ?? r.controlId
114
+ })), s = ge(e).flatMap(
115
+ ({ paramId: r, controlId: o }) => {
116
+ var c;
117
+ const d = t.get(o);
118
+ return !d || d === o || (c = e.controlBindings) != null && c.some(
119
+ (a) => a.target === "sql_param" && a.paramId === r
120
+ ) ? [] : [{ target: "sql_param", paramId: r, controlId: d }];
121
+ }
122
+ );
123
+ return s.length ? [...n ?? [], ...s] : n;
124
+ }
125
+ function ne(e, t) {
126
+ var i, r;
127
+ const n = e.source === "dashboardInputAlias" ? ((i = t.inputAliases) == null ? void 0 : i[e.variableName]) ?? e : e, s = e.source === "dashboardInputAlias" && n !== e ? { ...n, export: e.export ?? "label" } : n;
128
+ return s.source === "dashboardInput" ? {
129
+ ...s,
130
+ inputId: ((r = t.inputIds) == null ? void 0 : r[s.inputId]) ?? s.inputId
131
+ } : s;
132
+ }
133
+ function Xe(e, t) {
134
+ var i;
135
+ const n = {};
136
+ for (const r of [
137
+ "cardIds",
138
+ "sheetIds",
139
+ "inputIds",
140
+ "controlIds",
141
+ "filterIds"
142
+ ]) {
143
+ const o = { ...t[r] };
144
+ for (const [d, c] of Object.entries((e == null ? void 0 : e[r]) ?? {}))
145
+ o[d] = ((i = t[r]) == null ? void 0 : i[c]) ?? c;
146
+ Object.keys(o).length && (n[r] = o);
147
+ }
148
+ const s = { ...t.inputAliases };
149
+ for (const [r, o] of Object.entries((e == null ? void 0 : e.inputAliases) ?? {}))
150
+ s[r] = ne(o, t);
151
+ return Object.keys(s).length && (n.inputAliases = s), n;
152
+ }
153
+ function Ze(e, t) {
154
+ var i, r, o, d;
155
+ const n = O(e);
156
+ n.controlBindings = he(
157
+ e,
158
+ new Map(Object.entries(t.controlIds ?? {}))
159
+ );
160
+ for (const c of n.controls ?? [])
161
+ c.id = ((i = t.controlIds) == null ? void 0 : i[c.id]) ?? c.id;
162
+ for (const c of n.inlineFilters ?? [])
163
+ c.id = ((r = t.filterIds) == null ? void 0 : r[c.id]) ?? c.id;
164
+ const s = (c) => {
165
+ var m, f, u;
166
+ if (!c || typeof c != "object") return;
167
+ if (Array.isArray(c)) {
168
+ c.forEach(s);
169
+ return;
170
+ }
171
+ const a = c;
172
+ if (a.type === "variable" && a.ref && typeof a.ref == "object") {
173
+ const g = a.ref;
174
+ a.ref = g.source === "input" ? { ...g, inputId: ((m = t.inputIds) == null ? void 0 : m[g.inputId]) ?? g.inputId } : ne(g, t);
175
+ }
176
+ if (typeof a.entityId == "string") {
177
+ const g = a.entityId;
178
+ a.fieldScope === "card" && (a.entityId = ((f = t.cardIds) == null ? void 0 : f[g]) ?? g), a.fieldScope === "sheet" && (a.entityId = ((u = t.sheetIds) == null ? void 0 : u[g]) ?? g);
179
+ }
180
+ for (const [g, b] of Object.entries(a))
181
+ g !== "linkedReferenceOverrides" && s(b);
182
+ };
183
+ s(n);
184
+ for (const c of Object.values(
185
+ ((o = n.customCardPreferences) == null ? void 0 : o.dataInputCardIds) ?? {}
186
+ ))
187
+ c.cardId = ((d = t.cardIds) == null ? void 0 : d[c.cardId]) ?? c.cardId;
188
+ return n;
189
+ }
190
+ function R(e) {
191
+ return (e == null ? void 0 : e.trim()) || void 0;
192
+ }
193
+ function Y(e) {
194
+ return e.split(".").at(-1) || e;
195
+ }
196
+ function S(e, t) {
197
+ var c, a;
198
+ const n = R(t);
199
+ if (!n) return;
200
+ const s = Y(n), i = R((c = e.fieldMeta) == null ? void 0 : c.name);
201
+ if (i && i !== n && i !== s)
202
+ return;
203
+ const r = R(
204
+ (a = e.fieldMeta) == null ? void 0 : a.qualifiedFieldName
205
+ );
206
+ if (r && Y(r) !== s)
207
+ return;
208
+ const o = n.includes(".") ? n : void 0, d = r != null && r.includes(".") ? r : void 0;
209
+ if (!(o && d && o !== d))
210
+ return {
211
+ leafName: s,
212
+ ...o || d ? {
213
+ qualifiedFieldName: o || d
214
+ } : {}
215
+ };
216
+ }
217
+ function X(e, t) {
218
+ return S(e, t) || S({}, t);
219
+ }
220
+ function Z({
221
+ source: e,
222
+ sourceFieldName: t,
223
+ target: n,
224
+ targetFieldName: s
225
+ }) {
226
+ const i = X(
227
+ e,
228
+ t
229
+ ), r = X(
230
+ n,
231
+ s
232
+ );
233
+ return !i || !r || i.leafName !== r.leafName ? !1 : r.qualifiedFieldName ? i.qualifiedFieldName === r.qualifiedFieldName : !0;
234
+ }
235
+ function k(e, t) {
236
+ var i, r;
237
+ const n = pe(e);
238
+ if (n) return n;
239
+ const s = (r = (i = e == null ? void 0 : e.fieldMeta) == null ? void 0 : i.nativeDataType) == null ? void 0 : r.trim();
240
+ if (L(e == null ? void 0 : e.fieldMeta, t) && s && s !== "date" && s !== "datetime")
241
+ return s;
242
+ }
243
+ function pe(e) {
244
+ var n;
245
+ const t = (n = e == null ? void 0 : e.nativeDataType) == null ? void 0 : n.trim();
246
+ return t && t !== "date" && t !== "datetime" ? t : void 0;
247
+ }
248
+ function L(e, t) {
249
+ var o, d;
250
+ const n = t.trim();
251
+ if (!n) return !1;
252
+ const s = n.split(".").at(-1), i = (o = e == null ? void 0 : e.qualifiedFieldName) == null ? void 0 : o.trim();
253
+ if (i && !(i === n || !i.includes(".") && i === s))
254
+ return !1;
255
+ const r = (d = e == null ? void 0 : e.name) == null ? void 0 : d.trim();
256
+ return r && r !== n && r !== s ? !1 : !!(i || r);
257
+ }
258
+ function be({
259
+ fieldName: e,
260
+ definition: t,
261
+ value: n
262
+ }) {
263
+ if ((t == null ? void 0 : t.column) === e) {
264
+ const s = k(t, e);
265
+ if (s)
266
+ return s;
267
+ }
268
+ return (n == null ? void 0 : n.name) === e ? k(n, e) : void 0;
269
+ }
270
+ function ye({
271
+ definition: e,
272
+ value: t,
273
+ sourceValue: n = t
274
+ }) {
275
+ const s = e && Z({
276
+ source: e,
277
+ sourceFieldName: e.column,
278
+ target: t,
279
+ targetFieldName: t.name
280
+ }) ? e : void 0, i = n && Z({
281
+ source: n,
282
+ sourceFieldName: n.name,
283
+ target: t,
284
+ targetFieldName: t.name
285
+ }) ? n : void 0, r = (s ? k(s, s.column) : void 0) || (i ? k(i, i.name) : void 0);
286
+ return ie({
287
+ carrier: t,
288
+ nativeDataType: r,
289
+ projectNestedNativeDataType: L(
290
+ t.fieldMeta,
291
+ t.name
292
+ )
293
+ });
294
+ }
295
+ function Ve({
296
+ filterDefinitions: e,
297
+ filterValues: t
298
+ }) {
299
+ if (!(e != null && e.length) || !t.length)
300
+ return t;
301
+ const n = new Map(
302
+ e.map((r) => [r.id, r])
303
+ );
304
+ let s = !1;
305
+ const i = t.map((r) => {
306
+ if (typeof r.name != "string" || !r.name.trim())
307
+ return r;
308
+ const o = n.get(r.filterId);
309
+ if (!o)
310
+ return r;
311
+ const d = ye({
312
+ definition: o,
313
+ value: r
314
+ });
315
+ return s || (s = d !== r), d;
316
+ });
317
+ return s ? i : t;
318
+ }
319
+ function et(e) {
320
+ const t = be({
321
+ fieldName: e.column,
322
+ definition: e
323
+ });
324
+ return ie({
325
+ carrier: e,
326
+ nativeDataType: t,
327
+ projectNestedNativeDataType: L(
328
+ e.fieldMeta,
329
+ e.column
330
+ )
331
+ });
332
+ }
333
+ function ie({
334
+ carrier: e,
335
+ nativeDataType: t,
336
+ projectNestedNativeDataType: n
337
+ }) {
338
+ var a;
339
+ const s = (a = e.fieldMeta) == null ? void 0 : a.nativeDataType;
340
+ if (t) {
341
+ if (e.nativeDataType === t && (!e.fieldMeta || (n ? s === t : !s)))
342
+ return e;
343
+ const { nativeDataType: m, ...f } = e.fieldMeta || {};
344
+ return {
345
+ ...e,
346
+ nativeDataType: t,
347
+ ...e.fieldMeta ? {
348
+ fieldMeta: n ? {
349
+ ...e.fieldMeta,
350
+ nativeDataType: t
351
+ } : f
352
+ } : {}
353
+ };
354
+ }
355
+ if (e.nativeDataType === void 0 && s === void 0)
356
+ return e;
357
+ const {
358
+ nativeDataType: i,
359
+ fieldMeta: r,
360
+ ...o
361
+ } = e, { nativeDataType: d, ...c } = r || {};
362
+ return {
363
+ ...o,
364
+ ...r ? { fieldMeta: c } : {}
365
+ };
366
+ }
367
+ function l(e) {
368
+ return typeof e == "string" && e.trim().length > 0 ? e.trim() : null;
369
+ }
370
+ function se(e) {
371
+ return Array.from(new Set(e.filter((t) => !!t)));
372
+ }
373
+ function Ie(e) {
374
+ const t = l(e.table), n = l(e.schema), s = l(e.catalog) || l(e.database);
375
+ return t ? se([
376
+ t,
377
+ n ? `${n}.${t}` : null,
378
+ s ? `${s}.${t}` : null,
379
+ s && n ? `${s}.${n}.${t}` : null
380
+ ]) : [];
381
+ }
382
+ function V(e) {
383
+ const t = l(e.table) || l(e.tableName);
384
+ return se([
385
+ l(e.name),
386
+ l(e.alias),
387
+ ...Ie({
388
+ table: t,
389
+ schema: l(e.schema) || l(e.schemaName),
390
+ catalog: l(e.catalog),
391
+ database: l(e.database) || l(e.databaseName)
392
+ })
393
+ ]);
394
+ }
395
+ function Fe(e, t) {
396
+ const n = l(e.domainId), s = l(t.domainId);
397
+ if (n && s && n !== s)
398
+ return !0;
399
+ if (e.type === "dataset")
400
+ return !1;
401
+ const i = l(e.id), r = l(t.id);
402
+ if (i && r && i !== r)
403
+ return !0;
404
+ const o = l(e.connectionId), d = l(t.connectionId);
405
+ return !!(o && d && o !== d);
406
+ }
407
+ function B(e, t = !1) {
408
+ return l(e.table) || l(e.tableName) || (e.type !== "dataset" || t ? l(e.name) : null);
409
+ }
410
+ function M(e) {
411
+ return l(e.catalog) || l(e.database) || l(e.databaseName);
412
+ }
413
+ function P(e) {
414
+ return l(e.schema) || l(e.schemaName);
415
+ }
416
+ function v(e) {
417
+ return e.length === 1 ? e[0] : void 0;
418
+ }
419
+ function Te(e, t) {
420
+ const n = B(t, !0), s = M(t), i = P(t);
421
+ if (!(!n || !s && !i))
422
+ return v(
423
+ e.filter((r) => {
424
+ const o = r;
425
+ return !(B(o) !== n || s && M(o) !== s || i && P(o) !== i);
426
+ })
427
+ );
428
+ }
429
+ function E(e, t) {
430
+ if (!t || !(e != null && e.length))
431
+ return;
432
+ const n = e.filter(
433
+ (d) => !Fe(d, t)
434
+ );
435
+ if (t.type === "dataset") {
436
+ const d = l(t.id);
437
+ if (d)
438
+ return v(
439
+ n.filter(
440
+ (a) => a.type === "dataset" && l(a.id) === d
441
+ )
442
+ );
443
+ if (l(t.domainId)) {
444
+ const a = l(t.name);
445
+ return v(
446
+ n.filter(
447
+ (m) => m.type === "dataset" && l(m.name) === a
448
+ )
449
+ );
450
+ }
451
+ }
452
+ let s = [];
453
+ if (t.type === "dataset") {
454
+ const d = l(t.name);
455
+ if (s = n.filter(
456
+ (c) => c.type === "dataset" && l(c.name) === d
457
+ ), s.length === 1)
458
+ return s[0];
459
+ }
460
+ if (!!(B(t, !0) && (M(t) || P(t))))
461
+ return Te(n, t);
462
+ if (s.length > 1)
463
+ return;
464
+ const r = V(t);
465
+ if (r.length === 0)
466
+ return;
467
+ const o = n.filter((d) => V(
468
+ d
469
+ ).some(
470
+ (a) => r.includes(a)
471
+ ));
472
+ return v(o);
473
+ }
474
+ function C(e, t) {
475
+ const n = E(e, t);
476
+ return n ? { ...t, ...n } : t;
477
+ }
478
+ function tt(e, t) {
479
+ const n = t || [];
480
+ return n.length === 0 ? e : {
481
+ ...e,
482
+ baseEntity: C(n, e.baseEntity),
483
+ joins: e.joins.map((s) => ({
484
+ ...s,
485
+ source: C(n, s.source),
486
+ target: C(n, s.target)
487
+ }))
488
+ };
489
+ }
490
+ function nt(e, t) {
491
+ if (!(e != null && e.joins.length))
492
+ return [];
493
+ const n = [
494
+ e.baseEntity,
495
+ ...e.joins.flatMap((i) => [i.source, i.target])
496
+ ], s = [];
497
+ return n.forEach((i) => {
498
+ !E(t, i) && !E(s, i) && s.push(i);
499
+ }), s;
500
+ }
501
+ function F(e) {
502
+ return !!e && typeof e == "object" && !Array.isArray(e);
503
+ }
504
+ function $(e) {
505
+ return F(e) && typeof e.name == "string";
506
+ }
507
+ function q(e) {
508
+ return !F(e) || e.kind !== "semantic" && e.kind !== "physical" || (e.kind === "semantic" ? [e.datasetId, e.datasetName, e.connectionId] : [e.databaseName, e.schemaName]).some(
509
+ (n) => n !== void 0 && typeof n != "string"
510
+ ) ? !1 : j(
511
+ e
512
+ );
513
+ }
514
+ function z(e, t) {
515
+ var a, m;
516
+ const n = Array.isArray(t == null ? void 0 : t.selectedEntities) ? t.selectedEntities.filter($) : void 0, s = E(n, e), i = s ? { ...e, ...s } : e, r = "domainId" in i && typeof i.domainId == "string" && !!i.domainId.trim();
517
+ if ((t == null ? void 0 : t.mode) === "semanticDomain" && !r)
518
+ return;
519
+ if ((t == null ? void 0 : t.mode) !== "database" && i.type === "dataset") {
520
+ const f = fe(
521
+ {
522
+ entities: [i],
523
+ semanticDomainId: t == null ? void 0 : t.semanticDomainId,
524
+ connectionId: t == null ? void 0 : t.connectionId,
525
+ fieldEntityType: "dataset"
526
+ },
527
+ { includePhysicalDatasets: !0 }
528
+ );
529
+ if (f.kind === "resolved") {
530
+ const u = "label" in i && typeof i.label == "string" ? i.label : void 0;
531
+ return {
532
+ ...f.source,
533
+ ...u ? { label: u } : {}
534
+ };
535
+ }
536
+ }
537
+ if ((t == null ? void 0 : t.mode) === "semanticDomain")
538
+ return;
539
+ const o = i.connectionId || (t == null ? void 0 : t.connectionId), d = i.type === "dataset" && "table" in i && i.table ? i.table : i.name;
540
+ if (!o || !d)
541
+ return;
542
+ const c = {
543
+ kind: "physical",
544
+ connectionId: o,
545
+ connectionType: i.connectionType || (t == null ? void 0 : t.connectionType),
546
+ tableName: d,
547
+ databaseName: i.database || ((a = t == null ? void 0 : t.dbSelection) == null ? void 0 : a.database),
548
+ schemaName: i.schema || ((m = t == null ? void 0 : t.dbSelection) == null ? void 0 : m.schema),
549
+ dialect: i.dialect
550
+ };
551
+ return q(c) ? c : void 0;
552
+ }
553
+ function Ne(e, t) {
554
+ var d, c;
555
+ const n = z(e, t);
556
+ if (!n) return;
557
+ const s = e.type === "dataset" && "table" in e && typeof e.table == "string" ? e.table.trim() : void 0, i = n.kind === "physical" ? n.tableName : s, r = e.connectionId || (t == null ? void 0 : t.connectionId), o = i && r ? {
558
+ connectionId: r,
559
+ databaseName: e.database || ((d = t == null ? void 0 : t.dbSelection) == null ? void 0 : d.database),
560
+ schemaName: e.schema || ((c = t == null ? void 0 : t.dbSelection) == null ? void 0 : c.schema),
561
+ tableName: i
562
+ } : void 0;
563
+ return { source: n, ...o ? { executionTable: o } : {} };
564
+ }
565
+ function _e(e) {
566
+ const t = F(e.dataSource) ? e.dataSource : void 0;
567
+ if (typeof e.sql == "string" && e.sql.trim()) {
568
+ const o = [], d = Array.isArray(t == null ? void 0 : t.selectedEntities) ? t.selectedEntities : [];
569
+ for (const c of d) {
570
+ if (!$(c)) continue;
571
+ const a = Ne(c, t);
572
+ a && !o.some(
573
+ (m) => I(
574
+ m.source,
575
+ a.source
576
+ )
577
+ ) && o.push(a);
578
+ }
579
+ return {
580
+ cardId: e.id,
581
+ kind: "sql",
582
+ pinnedCatalogSources: o
583
+ };
584
+ }
585
+ if (!F(e.config))
586
+ return { cardId: e.id, kind: "unconfigured" };
587
+ const n = [], s = F(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;
588
+ q(i) && n.push(i);
589
+ const r = F(e.config.joinPlan) ? e.config.joinPlan : void 0;
590
+ if (r) {
591
+ const o = Array.isArray(r.joins) ? r.joins : [], d = [r.baseEntity];
592
+ for (const a of o)
593
+ F(a) && d.push(a.source, a.target);
594
+ let c = !1;
595
+ for (const a of d) {
596
+ if (!$(a)) {
597
+ c = !0;
598
+ continue;
599
+ }
600
+ const m = z(a, t);
601
+ m ? n.push(m) : c = !0;
602
+ }
603
+ c && (n.length = 0);
604
+ } else if (e.type !== "matrixTable") {
605
+ const o = Array.isArray(t == null ? void 0 : t.selectedEntities) ? t.selectedEntities : [];
606
+ if (o.length === 1 && $(o[0])) {
607
+ const d = z(o[0], t);
608
+ d && n.push(d);
609
+ }
610
+ }
611
+ if (!n.length && !r && e.type !== "matrixTable") {
612
+ const o = e.config.queryBaseSource;
613
+ q(o) && n.push(o);
614
+ }
615
+ return {
616
+ cardId: e.id,
617
+ kind: "config",
618
+ executableSources: le(n)
619
+ };
620
+ }
621
+ function ve(e, t) {
622
+ return (e.kind === "config" ? e.executableSources : e.kind === "sql" ? e.pinnedCatalogSources.map((s) => s.source) : []).some(
623
+ (s) => I(s, t)
624
+ );
625
+ }
626
+ function it(e, t) {
627
+ if (e.kind === "config")
628
+ return e.executableSources.find(
629
+ (n) => I(n, t)
630
+ );
631
+ }
632
+ function st(e, t) {
633
+ var n;
634
+ return (n = re(e, t)) == null ? void 0 : n.source;
635
+ }
636
+ function re(e, t) {
637
+ if (e.kind === "sql")
638
+ return e.pinnedCatalogSources.find(
639
+ (n) => I(n.source, t)
640
+ );
641
+ }
642
+ function ee(e) {
643
+ const t = /* @__PURE__ */ new Set();
644
+ for (const n of [e.name, e.sourceField]) {
645
+ if (!n) continue;
646
+ const s = T(n);
647
+ if (!s) continue;
648
+ t.add(s);
649
+ const i = s.split("."), r = i[i.length - 1];
650
+ r && t.add(r);
651
+ }
652
+ return t;
653
+ }
654
+ function oe(e, t) {
655
+ const n = x(e), s = x(t);
656
+ return n === "unknown" || s === "unknown" ? !1 : (n === "date" || n === "datetime") && (s === "date" || s === "datetime") ? !0 : n === s;
657
+ }
658
+ function $e(e, t) {
659
+ return I(e.field.source, t.field.source) && T(e.field.name) === T(t.field.name) && T(e.field.sourceField || e.field.name) === T(t.field.sourceField || t.field.name);
660
+ }
661
+ function ke(e, t) {
662
+ if (e.kind !== "field") return !1;
663
+ const n = ee(t), s = ee(e.field);
664
+ return oe(t.dataType, e.field.dataType) && [...s].some((i) => n.has(i));
665
+ }
666
+ function rt(e) {
667
+ const t = e.candidates.filter(
668
+ (n) => ke(
669
+ n,
670
+ e.logicalValueField
671
+ )
672
+ );
673
+ return t.length === 1 ? { status: "matched", target: t[0] } : t.length > 1 ? { status: "ambiguous" } : { status: "notApplicable" };
674
+ }
675
+ function ot(e) {
676
+ const t = [];
677
+ for (const n of e.acceptedTargets)
678
+ !oe(
679
+ e.logicalValueField.dataType,
680
+ n.field.dataType
681
+ ) || t.some(
682
+ (s) => $e(s, n)
683
+ ) || t.push(n);
684
+ return t.length === 1 ? { status: "matched", target: t[0] } : t.length > 1 ? { status: "ambiguous" } : { status: "notApplicable" };
685
+ }
686
+ const Ee = /\{\{-?\s*filters\s*\|\s*where\s*-?\}\}/i, De = /\{\{-?\s*filters\s*\|\s*and\s*-?\}\}/i, Ae = /\bwhere\b/i;
687
+ function Re(e) {
688
+ return e != null && e.trim() ? Ee.test(e) || De.test(e) : !1;
689
+ }
690
+ function at(e) {
691
+ return !(e != null && e.trim()) || Re(e) ? null : Ae.test(e) ? {
692
+ helper: "{{ filters | and }}",
693
+ description: "For queries with an existing WHERE clause."
694
+ } : {
695
+ helper: "{{ filters | where }}",
696
+ description: "For queries without a WHERE clause."
697
+ };
698
+ }
699
+ function Ce(e) {
700
+ return (e.field.sourceField || e.field.name).trim() || void 0;
701
+ }
702
+ function dt(e) {
703
+ if (e.inventory.kind !== "sql" || e.target.kind !== "field")
704
+ return { status: "ineligible" };
705
+ const t = re(
706
+ e.inventory,
707
+ e.target.field.source
708
+ ), n = Ce(e.target);
709
+ if (!t || !n) return { status: "ineligible" };
710
+ if (t.executionTable) {
711
+ const o = [
712
+ t.executionTable.databaseName,
713
+ t.executionTable.schemaName,
714
+ t.executionTable.tableName,
715
+ n
716
+ ].filter(Boolean).join(".");
717
+ return {
718
+ status: "eligible",
719
+ source: t.source,
720
+ executionIdentifier: o
721
+ };
722
+ }
723
+ if (e.inventory.pinnedCatalogSources.length !== 1)
724
+ return { status: "ineligible" };
725
+ const s = T(n), i = (e.candidateTargets || []).filter(
726
+ (o) => T(
727
+ o.field.sourceField || o.field.name
728
+ ) === s
729
+ ), r = [];
730
+ for (const o of i)
731
+ r.some(
732
+ (d) => I(d, o.field.source)
733
+ ) || r.push(o.field.source);
734
+ return r.length > 1 ? { status: "ineligible" } : {
735
+ status: "eligible",
736
+ source: t.source,
737
+ executionIdentifier: n
738
+ };
739
+ }
740
+ class xe extends Error {
741
+ constructor(n) {
742
+ super(n.map((s) => s.message).join(" "));
743
+ G(this, "issues");
744
+ this.name = "DashboardFilterMappingContractError", this.issues = n;
745
+ }
746
+ }
747
+ const we = {
748
+ string: !0,
749
+ number: !0,
750
+ boolean: !0,
751
+ date: !0,
752
+ datetime: !0
753
+ };
754
+ function p(e) {
755
+ return typeof e == "string" && e.trim().length > 0;
756
+ }
757
+ function h(e) {
758
+ return !!e && typeof e == "object" && !Array.isArray(e);
759
+ }
760
+ function _(e) {
761
+ return Array.isArray(e) && e.every((t) => typeof t == "string");
762
+ }
763
+ function Oe(e) {
764
+ if (!h(e)) return !1;
765
+ switch (e.kind) {
766
+ case "allSheets":
767
+ return e.sheetKinds === void 0 || _(e.sheetKinds) && e.sheetKinds.every(
768
+ (t) => t === "dashboard" || t === "document"
769
+ );
770
+ case "sheets":
771
+ return _(e.sheetIds);
772
+ case "cards":
773
+ return _(e.cardIds);
774
+ case "documentSections":
775
+ return p(e.sheetId) && _(e.sectionIds);
776
+ default:
777
+ return !1;
778
+ }
779
+ }
780
+ function Be(e) {
781
+ return e === "shared" || e === "perSheet" || e === "perCard" || e === "perDocumentSection";
782
+ }
783
+ function Me(e) {
784
+ return h(e) ? p(e.id) && p(e.column) && p(e.dataType) : !1;
785
+ }
786
+ function Pe(e, t, n, s) {
787
+ var d;
788
+ if (!h(t)) {
789
+ s.push({
790
+ code: "invalid_option_source",
791
+ path: n,
792
+ message: `${n} must be a semantic or physical option source.`,
793
+ inputId: e
794
+ });
795
+ return;
796
+ }
797
+ const i = t.source, r = [
798
+ ["labelField", t.labelField],
799
+ ["valueField", t.valueField],
800
+ ["searchField", t.searchField]
801
+ ];
802
+ if (!h(i) || i.kind !== "semantic" && i.kind !== "physical" || !j(i) || !h(t.labelField) || !h(t.valueField) || t.searchField !== void 0 && !h(t.searchField) || t.disambiguationFields !== void 0 && (!Array.isArray(t.disambiguationFields) || !t.disambiguationFields.every(h))) {
803
+ s.push({
804
+ code: "invalid_option_source",
805
+ path: n,
806
+ message: `${n} must contain a valid semantic or physical source and field references.`,
807
+ inputId: e
808
+ });
809
+ return;
810
+ }
811
+ for (const [c, a] of r)
812
+ a !== void 0 && h(a) && (!p(a.name) || a.source !== void 0 && !I(
813
+ a.source,
814
+ i
815
+ )) && s.push({
816
+ code: "invalid_option_source",
817
+ path: `${n}.${c}`,
818
+ message: `${n}.${c} must be a named field belonging to the declared option source.`,
819
+ inputId: e
820
+ });
821
+ for (const [c, a] of ((d = t.disambiguationFields) == null ? void 0 : d.entries()) || [])
822
+ (!h(a) || !p(a.name) || a.source !== void 0 && !I(
823
+ a.source,
824
+ i
825
+ )) && s.push({
826
+ code: "invalid_option_source",
827
+ path: `${n}.disambiguationFields[${c}]`,
828
+ message: `${n}.disambiguationFields[${c}] must be a named field belonging to the declared option source.`,
829
+ inputId: e
830
+ });
831
+ const o = t.valueField;
832
+ ["string", "number", "boolean", "date", "datetime"].includes(
833
+ String(o.dataType)
834
+ ) || s.push({
835
+ code: "invalid_option_source",
836
+ path: `${n}.valueField.dataType`,
837
+ message: `${n}.valueField.dataType must be a known option-value datatype.`,
838
+ inputId: e
839
+ });
840
+ }
841
+ function qe(e, t, n, s, i, r) {
842
+ var a;
843
+ if (p(t.bindingId) || i.push({
844
+ code: "invalid_binding_id",
845
+ path: `${n}.bindingId`,
846
+ message: `${n}.bindingId must be an opaque non-empty id.`,
847
+ inputId: e,
848
+ cardId: t.cardId
849
+ }), ((a = t.target) == null ? void 0 : a.kind) !== "field") {
850
+ i.push({
851
+ code: "unsupported_target",
852
+ path: `${n}.target`,
853
+ message: `${n}.target must be one direct field target.`,
854
+ inputId: e,
855
+ cardId: t.cardId,
856
+ bindingId: t.bindingId
857
+ });
858
+ return;
859
+ }
860
+ const o = t.target.field;
861
+ if (!p(o == null ? void 0 : o.name) || !o.source || o.source.kind !== "semantic" && o.source.kind !== "physical" || !j(o.source)) {
862
+ i.push({
863
+ code: "invalid_target_field",
864
+ path: `${n}.target.field`,
865
+ message: `${n}.target.field must have a name and a source-qualified semantic or physical identity.`,
866
+ inputId: e,
867
+ cardId: t.cardId,
868
+ bindingId: t.bindingId
869
+ });
870
+ return;
871
+ }
872
+ if (Object.prototype.hasOwnProperty.call(
873
+ we,
874
+ o.dataType
875
+ ) || i.push({
876
+ code: "unknown_target_data_type",
877
+ path: `${n}.target.field.dataType`,
878
+ message: `${n}.target.field.dataType must be known.`,
879
+ inputId: e,
880
+ cardId: t.cardId,
881
+ bindingId: t.bindingId
882
+ }), o.sourceField !== void 0 && !p(o.sourceField) && i.push({
883
+ code: "invalid_target_field",
884
+ path: `${n}.target.field.sourceField`,
885
+ message: `${n}.target.field.sourceField must be a non-empty catalog-grounded column when provided.`,
886
+ inputId: e,
887
+ cardId: t.cardId,
888
+ bindingId: t.bindingId
889
+ }), !r) return;
890
+ const d = s.get(t.cardId);
891
+ if (!d) {
892
+ i.push({
893
+ code: "unknown_card",
894
+ path: `${n}.cardId`,
895
+ message: `${n}.cardId '${t.cardId}' does not exist.`,
896
+ inputId: e,
897
+ cardId: t.cardId,
898
+ bindingId: t.bindingId
899
+ });
900
+ return;
901
+ }
902
+ const c = _e(d);
903
+ (c.kind === "unconfigured" || !ve(c, o.source)) && i.push({
904
+ code: "unavailable_card_source",
905
+ path: `${n}.target.field.source`,
906
+ message: `${n}.target field source is not declared by card '${d.id}'.`,
907
+ inputId: e,
908
+ cardId: d.id,
909
+ bindingId: t.bindingId
910
+ });
911
+ }
912
+ function ze(e, t, n, s, i, r) {
913
+ if (t === void 0) return;
914
+ if (!h(t) || t.kind !== "cardMappings" || !Array.isArray(t.cards)) {
915
+ i.push({
916
+ code: "invalid_application",
917
+ path: n,
918
+ message: `${n} must be a cardMappings application with a cards array.`,
919
+ inputId: e
920
+ });
921
+ return;
922
+ }
923
+ const o = /* @__PURE__ */ new Set();
924
+ t.cards.forEach((d, c) => {
925
+ const a = `${n}.cards[${c}]`;
926
+ if (!p(d == null ? void 0 : d.cardId)) {
927
+ i.push({
928
+ code: "unknown_card",
929
+ path: `${a}.cardId`,
930
+ message: `${a}.cardId is required.`,
931
+ inputId: e
932
+ });
933
+ return;
934
+ }
935
+ if (o.has(d.cardId)) {
936
+ i.push({
937
+ code: "duplicate_card_application",
938
+ path: `${a}.cardId`,
939
+ message: `${n} contains more than one entry for card '${d.cardId}'.`,
940
+ inputId: e,
941
+ cardId: d.cardId
942
+ });
943
+ return;
944
+ }
945
+ if (o.add(d.cardId), r && !s.has(d.cardId)) {
946
+ i.push({
947
+ code: "unknown_card",
948
+ path: `${a}.cardId`,
949
+ message: `${a}.cardId '${d.cardId}' does not exist.`,
950
+ inputId: e,
951
+ cardId: d.cardId
952
+ });
953
+ return;
954
+ }
955
+ d.kind === "bound" ? qe(
956
+ e,
957
+ d,
958
+ a,
959
+ s,
960
+ i,
961
+ r
962
+ ) : d.kind !== "excluded" && i.push({
963
+ code: "invalid_application",
964
+ path: a,
965
+ message: `${a}.kind must be 'bound' or 'excluded'.`,
966
+ inputId: e,
967
+ cardId: d.cardId
968
+ });
969
+ });
970
+ }
971
+ function je({
972
+ inputs: e,
973
+ dashboardFilters: t,
974
+ cards: n = [],
975
+ validateCardTargets: s = !1
976
+ }) {
977
+ const i = [], r = new Map(
978
+ (t || []).map((a) => [a.id, a])
979
+ ), o = new Map(
980
+ s ? n.map((a) => [a.id, a]) : []
981
+ ), d = [], c = /* @__PURE__ */ new Map();
982
+ return e != null && !Array.isArray(e) ? (i.push({
983
+ code: "invalid_input",
984
+ path: "dashboard.inputs",
985
+ message: "dashboard.inputs must be an array when present."
986
+ }), { ok: !1, inputs: d, issues: i }) : ((Array.isArray(e) ? e : []).forEach((a, m) => {
987
+ const f = `dashboard.inputs[${m}]`;
988
+ if (!h(a) || a.kind !== "filter" && a.kind !== "control" || !p(a.id) || !p(a.label) || !p(a.variableName) || !Oe(a.scope) || !Be(a.runtimeScope)) {
989
+ i.push({
990
+ code: "invalid_input",
991
+ path: f,
992
+ message: `${f} must be a complete filter or control Dashboard Input envelope.`,
993
+ inputId: h(a) && typeof a.id == "string" ? a.id : void 0
994
+ });
995
+ return;
996
+ }
997
+ if (a.kind === "control" && !h(a.control)) {
998
+ i.push({
999
+ code: "invalid_input",
1000
+ path: `${f}.control`,
1001
+ message: `${f}.control must be a control definition.`,
1002
+ inputId: a.id
1003
+ });
1004
+ return;
1005
+ }
1006
+ const u = a;
1007
+ if (u.kind === "control") {
1008
+ d.push(u);
1009
+ return;
1010
+ }
1011
+ const g = u.filter, b = u.filterReference, N = g !== void 0, J = !!b;
1012
+ if (N && J) {
1013
+ i.push({
1014
+ code: "both_filter_definitions",
1015
+ path: f,
1016
+ message: `${f} must contain either filter or filterReference, not both.`,
1017
+ inputId: u.id
1018
+ });
1019
+ return;
1020
+ }
1021
+ if (!N && !J) {
1022
+ i.push({
1023
+ code: "missing_filter_definition",
1024
+ path: f,
1025
+ message: `${f} must contain filter or filterReference.`,
1026
+ inputId: u.id
1027
+ });
1028
+ return;
1029
+ }
1030
+ if (N && !Me(g)) {
1031
+ i.push({
1032
+ code: "invalid_input",
1033
+ path: `${f}.filter`,
1034
+ message: `${f}.filter must be a complete dashboard filter definition.`,
1035
+ inputId: u.id
1036
+ });
1037
+ return;
1038
+ }
1039
+ let y, D;
1040
+ if (N)
1041
+ y = g, D = "embedded";
1042
+ else {
1043
+ if ((b == null ? void 0 : b.kind) !== "dashboardFilter") {
1044
+ i.push({
1045
+ code: "invalid_filter_reference",
1046
+ path: `${f}.filterReference.kind`,
1047
+ message: `${f}.filterReference.kind must be 'dashboardFilter'.`,
1048
+ inputId: u.id
1049
+ });
1050
+ return;
1051
+ }
1052
+ const A = typeof (b == null ? void 0 : b.filterId) == "string" ? b.filterId : void 0;
1053
+ if (y = A ? r.get(A) : void 0, D = "dashboardFilter", !y) {
1054
+ i.push({
1055
+ code: "orphaned_filter_reference",
1056
+ path: `${f}.filterReference.filterId`,
1057
+ message: `${f}.filterReference cannot resolve dashboard filter '${A || ""}'.`,
1058
+ inputId: u.id
1059
+ });
1060
+ return;
1061
+ }
1062
+ if (y.kind === "global-date") {
1063
+ i.push({
1064
+ code: "global_date_reference",
1065
+ path: `${f}.filterReference`,
1066
+ message: `${f}.filterReference cannot reference the Global Date filter.`,
1067
+ inputId: u.id
1068
+ });
1069
+ return;
1070
+ }
1071
+ const W = c.get(y.id);
1072
+ if (W) {
1073
+ i.push({
1074
+ code: "duplicate_filter_reference",
1075
+ path: `${f}.filterReference.filterId`,
1076
+ message: `${f}.filterReference duplicates dashboard filter '${y.id}' already owned by Dashboard Input '${W}'.`,
1077
+ inputId: u.id
1078
+ });
1079
+ return;
1080
+ }
1081
+ c.set(y.id, u.id);
1082
+ }
1083
+ if (!y) return;
1084
+ if (u.optionSource !== void 0 && Pe(
1085
+ u.id,
1086
+ u.optionSource,
1087
+ `${f}.optionSource`,
1088
+ i
1089
+ ), u.application && y.kind === "global-date") {
1090
+ i.push({
1091
+ code: "global_date_reference",
1092
+ path: `${f}.application`,
1093
+ message: `${f}.application cannot map the Global Date filter.`,
1094
+ inputId: u.id
1095
+ });
1096
+ return;
1097
+ }
1098
+ u.application && u.scope.kind !== "allSheets" && u.scope.kind !== "sheets" && i.push({
1099
+ code: "unsupported_mapped_scope",
1100
+ path: `${f}.scope`,
1101
+ message: `${f}.scope must be allSheets or sheets when cardMappings are present.`,
1102
+ inputId: u.id
1103
+ }), ze(
1104
+ u.id,
1105
+ u.application,
1106
+ `${f}.application`,
1107
+ o,
1108
+ i,
1109
+ s
1110
+ );
1111
+ const {
1112
+ filter: He,
1113
+ filterReference: We,
1114
+ // A reference-backed authored input must shadow the generated
1115
+ // dashboard-filter compatibility input. Older writers may have copied
1116
+ // the compatibility marker onto the reference; never preserve it.
1117
+ compatibility: H,
1118
+ ...ae
1119
+ } = u;
1120
+ d.push({
1121
+ ...ae,
1122
+ filter: y,
1123
+ ...N && H ? { compatibility: H } : {},
1124
+ ...u.optionSource ? {
1125
+ optionSource: u.optionSource
1126
+ } : {},
1127
+ definitionOrigin: D
1128
+ });
1129
+ }), i.length ? { ok: !1, inputs: d, issues: i } : { ok: !0, inputs: d });
1130
+ }
1131
+ function ct(e) {
1132
+ const t = je(e);
1133
+ if (!t.ok) throw new xe(t.issues);
1134
+ return t.inputs;
1135
+ }
1136
+ function lt(e = () => globalThis.crypto.randomUUID()) {
1137
+ return e();
1138
+ }
1139
+ const Le = {
1140
+ date: /* @__PURE__ */ new Set([
1141
+ "between",
1142
+ "not between",
1143
+ "=",
1144
+ "!=",
1145
+ ">",
1146
+ ">=",
1147
+ "<",
1148
+ "<=",
1149
+ "is null",
1150
+ "is not null"
1151
+ ]),
1152
+ number: /* @__PURE__ */ new Set([
1153
+ "between",
1154
+ "not between",
1155
+ "=",
1156
+ "!=",
1157
+ ">",
1158
+ ">=",
1159
+ "<",
1160
+ "<=",
1161
+ "in",
1162
+ "not in",
1163
+ "is null",
1164
+ "is not null"
1165
+ ]),
1166
+ string: /* @__PURE__ */ new Set([
1167
+ "=",
1168
+ "!=",
1169
+ "in",
1170
+ "not in",
1171
+ "like",
1172
+ "not like",
1173
+ "is null",
1174
+ "is not null"
1175
+ ]),
1176
+ boolean: /* @__PURE__ */ new Set(["=", "!=", "in", "not in", "is null", "is not null"])
1177
+ };
1178
+ function Je(e) {
1179
+ const t = x(e);
1180
+ return t === "number" || t === "boolean" ? t : t === "date" || t === "datetime" ? "date" : "string";
1181
+ }
1182
+ function ft(e, t) {
1183
+ return typeof t != "string" ? !1 : Le[Je(e)].has(t);
1184
+ }
1185
+ export {
1186
+ Ve as A,
1187
+ te as B,
1188
+ xe as D,
1189
+ st as a,
1190
+ _e as b,
1191
+ O as c,
1192
+ ve as d,
1193
+ re as e,
1194
+ it as f,
1195
+ ke as g,
1196
+ ot as h,
1197
+ Re as i,
1198
+ at as j,
1199
+ dt as k,
1200
+ ct as l,
1201
+ ye as m,
1202
+ je as n,
1203
+ lt as o,
1204
+ Je as p,
1205
+ ft as q,
1206
+ rt as r,
1207
+ Xe as s,
1208
+ Ze as t,
1209
+ tt as u,
1210
+ nt as v,
1211
+ ue as w,
1212
+ ge as x,
1213
+ et as y,
1214
+ Se as z
1215
+ };