react-semaphor 0.1.563 → 0.1.565

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 (139) hide show
  1. package/DATA_APP_SDK.md +3 -3
  2. package/README.md +2 -2
  3. package/dist/analytics-protocol/index.js +8 -8
  4. package/dist/assistant-context/index.js +3 -2
  5. package/dist/brand-studio/index.js +28 -29
  6. package/dist/briefings/index.js +4 -4
  7. package/dist/chunks/{assistant-chat-iIp02_77.js → assistant-chat-DNfb5fbF.js} +294 -294
  8. package/dist/chunks/{bookmark-impact-D4Kl4amw.js → bookmark-impact-CHr7b1J2.js} +2 -2
  9. package/dist/chunks/bookmark-state-ByODVqee.js +1613 -0
  10. package/dist/chunks/card-filter-builder-CcEcfaYz.js +4100 -0
  11. package/dist/chunks/{switch-BW4yXSYs.js → code-editor-DJNOsgJH.js} +463 -442
  12. package/dist/chunks/{comparison-window-caption-D1EUXzaR.js → comparison-window-caption-CMLb3mut.js} +451 -419
  13. package/dist/chunks/{dashboard-CmqeP3QZ.js → dashboard-CtIfxycc.js} +1 -1
  14. package/dist/chunks/dashboard-briefing-launcher-D3mc6peE.js +4910 -0
  15. package/dist/chunks/{dashboard-controls-B253nJS-.js → dashboard-controls-BFv0zdws.js} +684 -674
  16. package/dist/chunks/{dashboard-json-osQuinUZ.js → dashboard-json-CXn_3OYb.js} +4 -4
  17. package/dist/chunks/{dates-DFY7Gfss.js → dates-DcRxw17S.js} +13 -13
  18. package/dist/chunks/{edit-dashboard-visual-CMar-NhA.js → edit-dashboard-visual-Y6HatqBd.js} +7704 -10337
  19. package/dist/chunks/filter-reach-copy-DbggA5B7.js +4673 -0
  20. package/dist/chunks/{filter-value-text-CPwFkrMz.js → filter-value-text-7zhmth1S.js} +2 -2
  21. package/dist/chunks/{index-CNGkfUp4.js → index-DDa_rklN.js} +69 -64
  22. package/dist/chunks/index-RNaTnE3m.js +585 -0
  23. package/dist/chunks/{layout-grid-BM65viQh.js → layout-grid-0hIlqEtk.js} +1 -1
  24. package/dist/chunks/{list-filter-BoeLBfL3.js → list-filter-DkgoCeBm.js} +1 -1
  25. package/dist/chunks/{matrix-analytical-definition-hEucouWM.js → matrix-analytical-definition-C9xB_T84.js} +18 -18
  26. package/dist/chunks/{matrix-card-CCh9JjP1.js → matrix-card-BSUeSXpD.js} +2 -2
  27. package/dist/chunks/{matrix-member-presentation-DsAUbuoL.js → matrix-member-presentation-DZNgQpUq.js} +1 -1
  28. package/dist/chunks/{matrix-operation-contract-DsLdFdSa.js → matrix-operation-contract-Eb6elidS.js} +1 -1
  29. package/dist/chunks/{metric-comparison-Bnso1cm1.js → metric-comparison-ChXUFaZu.js} +1 -1
  30. package/dist/chunks/{palette-p1XSJFgB.js → palette-4vf2BEEg.js} +1 -1
  31. package/dist/chunks/{pivot-result-contract-expectations-B53jqszr.js → pivot-result-contract-expectations-Ddh1rNz5.js} +4 -4
  32. package/dist/chunks/{pivot-result-identity-Dq5jm-EC.js → pivot-result-identity-BlbLrqaC.js} +1 -1
  33. package/dist/chunks/{report-preferences-dialog-l54wJyYE.js → report-preferences-dialog-Db-b04B4.js} +122 -131
  34. package/dist/chunks/{report-runtime-context-BITkNSDa.js → report-runtime-context-DnA_PiKo.js} +1 -1
  35. package/dist/chunks/resolve-dashboard-input-context-C18J-YZC.js +21394 -0
  36. package/dist/chunks/{save-CHV1B1fL.js → save-D6pHmSSP.js} +1 -1
  37. package/dist/chunks/saved-dashboard-context-DhC_EVus.js +629 -0
  38. package/dist/chunks/{selection-reducer-Bz5aywT4.js → selection-reducer-OaJ-N5uN.js} +1 -1
  39. package/dist/chunks/{semaphor-ready-indicator-C3EQEiD9.js → semaphor-ready-indicator-T6TsiBMT.js} +80879 -80744
  40. package/dist/chunks/{shelf-drop-preview-context-BODiBlqT.js → shelf-drop-preview-context-CNWL_b0S.js} +407 -407
  41. package/dist/chunks/{source-entity-resolution-DdDVXFB8.js → source-entity-resolution-DF6GulDn.js} +1 -1
  42. package/dist/chunks/stored-dashboard-IdmtrNkA.js +5026 -0
  43. package/dist/chunks/{table-export-sheet-bSXxGn-v.js → table-export-sheet--DUKWk6o.js} +1 -1
  44. package/dist/chunks/{temporal-input-presentation-sk9gqLi6.js → temporal-input-presentation--2r9BLr0.js} +392 -377
  45. package/dist/chunks/{token-types-BUK06hU2.js → token-types-C8JymO8s.js} +1 -1
  46. package/dist/chunks/{upload-BnmuyPqW.js → upload-Cf3wXZT8.js} +1 -1
  47. package/dist/chunks/{validators-BIM0FE31.js → validators-wtjw0aw6.js} +7 -7
  48. package/dist/chunks/variable-draft-3xseULxR.js +241 -0
  49. package/dist/dashboard/index.js +2 -2
  50. package/dist/dashboard-authoring/index.js +2226 -1704
  51. package/dist/data-app-sdk/index.js +4 -4
  52. package/dist/data-app-sdk-adapters/index.js +2 -2
  53. package/dist/data-app-sdk-validation/index.js +5 -5
  54. package/dist/format-utils/index.js +174 -167
  55. package/dist/index.js +190 -188
  56. package/dist/layouts/index.js +1 -1
  57. package/dist/pdf-export-policy/index.js +80 -28
  58. package/dist/pdf-table-layout/index.js +65 -65
  59. package/dist/report-runtime-context/index.js +1 -1
  60. package/dist/style.css +1 -1
  61. package/dist/surfboard/index.js +2 -2
  62. package/dist/types/briefings/attachment-outcomes.d.ts +1 -1
  63. package/dist/types/components/activity/activity-bell.d.ts +5 -1
  64. package/dist/types/components/activity/activity-types.d.ts +12 -4
  65. package/dist/types/components/dashboard-variables/data-variables-menu.d.ts +8 -0
  66. package/dist/types/components/dashboard-variables/variable-editor-host.d.ts +1 -0
  67. package/dist/types/components/index.d.ts +2 -0
  68. package/dist/types/index.js +5 -5
  69. package/dist/types/lib/dashboard-inputs/build-normalized-dashboard-inputs.d.ts +62 -0
  70. package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-authoring.d.ts +33 -2
  71. package/dist/types/lib/dashboard-inputs/filter-settings.d.ts +7 -2
  72. package/dist/types/lib/dashboard-inputs/prepare-loaded-dashboard.d.ts +4 -2
  73. package/dist/types/lib/dashboard-variables/data-text.d.ts +33 -0
  74. package/dist/types/lib/dashboard-variables/types.d.ts +207 -0
  75. package/dist/types/lib/document/document-edits.d.ts +16 -1
  76. package/dist/types/lib/document/document-panel-target.d.ts +1 -1
  77. package/dist/types/lib/document/document-section-query-options.d.ts +29 -0
  78. package/dist/types/lib/document/document-table-data-policy.d.ts +0 -1
  79. package/dist/types/lib/hooks/use-dashboard-frame-query.d.ts +92 -0
  80. package/dist/types/lib/query-context/build-card-query-context.d.ts +6 -0
  81. package/dist/types/lib/query-context/describe-card-execution-snapshot.d.ts +1 -0
  82. package/dist/types/lib/query-context/use-semantic-execution-payload-for-cards.d.ts +24 -0
  83. package/dist/types/lib/stores/dashboard-store.d.ts +36 -0
  84. package/dist/types/lib/text-variables/temporal-input-text.d.ts +28 -0
  85. package/dist/types/lib/text-variables/text-variable-types.d.ts +72 -0
  86. package/dist/types/lib/types/common-types.d.ts +155 -51
  87. package/dist/types/lib/utils/card-definition.d.ts +2 -2
  88. package/dist/types/shared/assistant-context/index.d.ts +1 -1
  89. package/dist/types/shared/assistant-context/saved-dashboard-context.d.ts +51 -1
  90. package/dist/types/shared/dashboard-authoring/card-query-request.d.ts +7 -1
  91. package/dist/types/shared/dashboard-authoring/card-settings/resolve-card-highlights.d.ts +10 -0
  92. package/dist/types/shared/dashboard-authoring/changes/card-query-part.d.ts +7 -1
  93. package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +1088 -431
  94. package/dist/types/shared/dashboard-authoring/changes/diagnostics.d.ts +18 -1
  95. package/dist/types/shared/dashboard-authoring/changes/read-card-query.d.ts +8 -1
  96. package/dist/types/shared/dashboard-authoring/changes/resolve-dashboard-changes.d.ts +1 -1
  97. package/dist/types/shared/dashboard-authoring/conditional-formatting/kpi.d.ts +10 -0
  98. package/dist/types/shared/dashboard-authoring/conditional-formatting/schema.d.ts +40 -40
  99. package/dist/types/shared/dashboard-authoring/control-execution-contract.d.ts +16 -16
  100. package/dist/types/shared/dashboard-authoring/dashboard-card-source-index.d.ts +1 -0
  101. package/dist/types/shared/dashboard-authoring/dashboard-filter-targets.d.ts +29 -0
  102. package/dist/types/shared/dashboard-authoring/dashboard-input-scope.d.ts +7 -4
  103. package/dist/types/shared/dashboard-authoring/dashboard-variable-card.d.ts +159 -0
  104. package/dist/types/shared/dashboard-authoring/dashboard-variable-changes.d.ts +61 -0
  105. package/dist/types/shared/dashboard-authoring/document-section-cards.d.ts +7 -0
  106. package/dist/types/shared/dashboard-authoring/filter-model/index.d.ts +2 -0
  107. package/dist/types/shared/dashboard-authoring/filter-model/read-dashboard-filter-model.d.ts +10 -0
  108. package/dist/types/shared/dashboard-authoring/index.d.ts +6 -0
  109. package/dist/types/shared/dashboard-authoring/measure-calculations/comparison.d.ts +2 -0
  110. package/dist/types/shared/dashboard-authoring/measure-calculations/schemas.d.ts +1 -1
  111. package/dist/types/shared/dashboard-authoring/operations/operation-sentences.d.ts +1 -1
  112. package/dist/types/shared/dashboard-authoring/operations/operation-types.d.ts +50 -3
  113. package/dist/types/shared/dashboard-authoring/outline/outline-dashboard.d.ts +48 -1
  114. package/dist/types/shared/dashboard-authoring/outline/outline-filters.d.ts +2 -2
  115. package/dist/types/shared/dashboard-authoring/text-card-words/blocks.d.ts +87 -13
  116. package/dist/types/shared/dashboard-authoring/text-card-words/chip-colors.d.ts +23 -0
  117. package/dist/types/shared/dashboard-authoring/text-card-words/index.d.ts +90 -8
  118. package/dist/types/shared/dashboard-authoring/text-card-words/rich-content.d.ts +31 -3
  119. package/dist/types/shared/dashboard-authoring/text-card-words/variable-words.d.ts +8 -0
  120. package/dist/types/shared/dashboard-authoring/variable-draft.d.ts +125 -0
  121. package/dist/types/shared/dashboard-authoring/variable-editability.d.ts +24 -0
  122. package/dist/types/shared/dashboard-authoring/variable-references.d.ts +39 -0
  123. package/dist/types/shared/format-utils/document-print.d.ts +4 -2
  124. package/dist/types/shared/format-utils/index.d.ts +1 -0
  125. package/dist/types/shared/format-utils/pdf-capacity-lines.d.ts +17 -0
  126. package/dist/types/shared/format-utils/pdf-delivery.d.ts +8 -1
  127. package/dist/types/shared/format-utils/pdf-export-policy.d.ts +74 -6
  128. package/dist/types/shared/format-utils/presentation-execution.d.ts +9 -0
  129. package/package.json +2 -2
  130. package/src/data-app-sdk/README.md +3 -3
  131. package/dist/chunks/bookmark-state-CWeoGbrx.js +0 -743
  132. package/dist/chunks/braces-DzgoQC64.js +0 -23
  133. package/dist/chunks/dashboard-briefing-launcher-TYlSW77S.js +0 -3828
  134. package/dist/chunks/filter-reach-copy-CvV7W5dd.js +0 -3965
  135. package/dist/chunks/global-date-filter-utils-N1kcsOFE.js +0 -16722
  136. package/dist/chunks/index-CJW5BdWT.js +0 -583
  137. package/dist/chunks/resolve-dashboard-input-context-DaDrZGuA.js +0 -8214
  138. package/dist/chunks/saved-dashboard-context-DFYBrE6O.js +0 -564
  139. package/dist/chunks/use-create-flow-overlay-state-BXY8-Cyz.js +0 -1436
@@ -1,743 +0,0 @@
1
- import { k as Y, u as H, H as W } from "./validators-BIM0FE31.js";
2
- import { z as c } from "zod";
3
- import { G as J, v as Z } from "./matrix-operation-contract-DsLdFdSa.js";
4
- import { d as X } from "./metric-comparison-Bnso1cm1.js";
5
- import "./analytics-base-schemas-BaIQrEzX.js";
6
- const _ = 8, V = 6, C = Object.freeze([]);
7
- function ee(e) {
8
- switch (e.type) {
9
- case "table":
10
- case "chart":
11
- return e.card ? [e.card] : C;
12
- case "kpi":
13
- return Array.isArray(e.cards) ? e.cards : C;
14
- default:
15
- return C;
16
- }
17
- }
18
- function te(e, t) {
19
- switch (e.type) {
20
- case "table":
21
- case "chart": {
22
- if (!e.card) return e;
23
- const n = t(e.card);
24
- return n === e.card ? e : { ...e, card: n };
25
- }
26
- case "kpi": {
27
- if (!Array.isArray(e.cards)) return e;
28
- const n = e.cards.map(t);
29
- return n.every((r, i) => r === e.cards[i]) ? e : { ...e, cards: n };
30
- }
31
- default:
32
- return e;
33
- }
34
- }
35
- function L(e) {
36
- var n;
37
- const t = [];
38
- for (const r of e.sheets || []) {
39
- const i = r.id;
40
- for (const s of r.cards || [])
41
- t.push({ kind: "sheetCard", sheetId: i, cardId: s.id, card: s });
42
- for (const s of r.frames || [])
43
- for (const a of s.cards || [])
44
- t.push({
45
- kind: "frameCard",
46
- sheetId: i,
47
- frameId: s.id,
48
- cardId: a.id,
49
- card: a
50
- });
51
- for (const s of ((n = r.document) == null ? void 0 : n.sections) || [])
52
- for (const a of ee(s))
53
- t.push({
54
- kind: "documentSectionCard",
55
- sheetId: i,
56
- sectionId: s.id,
57
- cardId: a.id,
58
- card: a
59
- });
60
- }
61
- return t;
62
- }
63
- function Fe(e, t) {
64
- const n = (i, s) => {
65
- const a = i.map((o) => t(o, s(o)));
66
- return a.every((o, u) => o === i[u]) ? i : a;
67
- }, r = (e.sheets || []).map((i) => {
68
- var b, p, f;
69
- const s = i.id, a = i.cards && n(i.cards, (d) => ({ kind: "sheetCard", sheetId: s, cardId: d.id, card: d })), o = (b = i.frames) == null ? void 0 : b.map((d) => {
70
- if (!d.cards) return d;
71
- const m = n(d.cards, (F) => ({ kind: "frameCard", sheetId: s, frameId: d.id, cardId: F.id, card: F }));
72
- return m === d.cards ? d : { ...d, cards: m };
73
- }), u = (f = (p = i.document) == null ? void 0 : p.sections) == null ? void 0 : f.map(
74
- (d) => te(d, (m) => t(m, { kind: "documentSectionCard", sheetId: s, sectionId: d.id, cardId: m.id, card: m }))
75
- ), l = !!o && o.some((d, m) => d !== i.frames[m]), h = !!u && u.some((d, m) => d !== i.document.sections[m]);
76
- return a === i.cards && !l && !h ? i : {
77
- ...i,
78
- ...a === i.cards ? {} : { cards: a },
79
- ...l ? { frames: o } : {},
80
- ...h ? { document: { ...i.document, sections: u } } : {}
81
- };
82
- });
83
- return r.every((i, s) => i === e.sheets[s]) ? e : { ...e, sheets: r };
84
- }
85
- function E(e) {
86
- return !!e && typeof e == "object" && !Array.isArray(e);
87
- }
88
- function _e(e) {
89
- if (!E(e))
90
- return [{ path: "", message: "must be an object." }];
91
- const t = [];
92
- e.title !== void 0 && typeof e.title != "string" && t.push({ path: "title", message: "must be a string." });
93
- const n = e.cards;
94
- if (!Array.isArray(n))
95
- t.push({ path: "cards", message: "must be an array of KPI cards." });
96
- else {
97
- (n.length < 1 || n.length > _) && t.push({
98
- path: "cards",
99
- message: `must hold 1 to ${_} KPI cards.`
100
- });
101
- const i = /* @__PURE__ */ new Set();
102
- n.forEach((s, a) => {
103
- if (!E(s)) {
104
- t.push({ path: `cards[${a}]`, message: "must be a card." });
105
- return;
106
- }
107
- typeof s.id != "string" || !s.id ? t.push({
108
- path: `cards[${a}].id`,
109
- message: "must be a non-empty string."
110
- }) : i.has(s.id) ? t.push({
111
- path: `cards[${a}].id`,
112
- message: `duplicates card id '${s.id}'.`
113
- }) : i.add(s.id), s.type !== "kpi" && t.push({ path: `cards[${a}].type`, message: "must be 'kpi'." });
114
- });
115
- }
116
- const r = e.kpi;
117
- return E(r) ? (r.layout !== "tiles" && r.layout !== "lines" ? t.push({
118
- path: "kpi.layout",
119
- message: "must be 'tiles' or 'lines'."
120
- }) : r.layout === "tiles" && Array.isArray(n) && n.length > V && t.push({
121
- path: "kpi.layout",
122
- message: `must be 'lines' for more than ${V} KPI cards.`
123
- }), r.columns !== void 0 && r.columns !== 1 && r.columns !== 2 && t.push({ path: "kpi.columns", message: "must be 1 or 2." })) : t.push({ path: "kpi", message: "must be an object." }), t;
124
- }
125
- const ne = ["new", "edit", "delete", "create", "update", "remove"];
126
- function B(e, t) {
127
- return (e.sheets || []).flatMap(
128
- (n) => L({ sheets: [n] }).filter(t).map((r) => ({
129
- card: r.card,
130
- sheet: n,
131
- ...r.kind === "frameCard" && { frameId: r.frameId },
132
- ...r.kind === "documentSectionCard" && {
133
- sectionId: r.sectionId
134
- }
135
- }))
136
- );
137
- }
138
- function S(e) {
139
- return B(e, (t) => t.kind !== "documentSectionCard");
140
- }
141
- function Ve(e) {
142
- return [
143
- ...S(e),
144
- ...B(e, (t) => t.kind === "documentSectionCard")
145
- ];
146
- }
147
- function $e(e) {
148
- return S(e).map((t) => t.card);
149
- }
150
- function Re(e, t, n) {
151
- return n && t === n ? !0 : !L(e).some(
152
- (r) => r.cardId === t
153
- );
154
- }
155
- function Me(e) {
156
- return !e || e.trim().length === 0 ? { isValid: !1, error: "Card ID cannot be empty" } : e.length < 3 ? { isValid: !1, error: "Card ID must be at least 3 characters" } : e.length > 50 ? { isValid: !1, error: "Card ID must be less than 50 characters" } : /^[a-zA-Z0-9-_]+$/.test(e) ? /^[a-zA-Z0-9]/.test(e) ? ne.includes(e.toLowerCase()) ? {
157
- isValid: !1,
158
- error: `"${e}" is a reserved keyword and cannot be used`
159
- } : { isValid: !0 } : {
160
- isValid: !1,
161
- error: "Card ID must start with a letter or number"
162
- } : {
163
- isValid: !1,
164
- error: "Card ID can only contain letters, numbers, hyphens, and underscores"
165
- };
166
- }
167
- function Le(e, t) {
168
- var n;
169
- return (n = re(e, t)) == null ? void 0 : n.card;
170
- }
171
- function re(e, t) {
172
- for (const n of S(e))
173
- if (n.card.id === t)
174
- return n;
175
- }
176
- function Be(e, t) {
177
- for (const n of e.sheets || [])
178
- for (const r of n.frames || [])
179
- for (const i of r.cards || [])
180
- if (i.id === t)
181
- return { card: i, sheet: n };
182
- }
183
- const k = {
184
- includeMetricFilterDatasets: !0,
185
- preferQualifiedIdentity: !1
186
- };
187
- function P(e) {
188
- if (!e) return;
189
- if (e.kind === "semantic")
190
- return { entityName: e.datasetName, entityId: e.datasetId, label: e.label };
191
- const t = [e.databaseName, e.schemaName, e.tableName].filter((n) => !!(n && n.trim())).join(".");
192
- return {
193
- entityName: e.tableName,
194
- qualifiedEntityName: t.includes(".") ? t : void 0,
195
- label: e.label
196
- };
197
- }
198
- function ie(e) {
199
- var n;
200
- const t = P(e.source);
201
- return t ? `${(n = e.source) == null ? void 0 : n.kind}:${t.qualifiedEntityName || t.entityName}` : "";
202
- }
203
- function se(e) {
204
- return [
205
- e.id,
206
- e.qualifiedEntityName,
207
- e.entityId,
208
- e.entityName,
209
- e.qualifiedFieldName,
210
- e.name,
211
- // Source-only fields from different datasets can otherwise share a key
212
- // and the second dataset would be silently dropped.
213
- ie(e)
214
- ].join("|");
215
- }
216
- function ae(e) {
217
- return [e.entityName, e.qualifiedEntityName || "", e.entityId || ""].join("|");
218
- }
219
- function Pe(e) {
220
- return e.entityName || e.qualifiedEntityName || "";
221
- }
222
- function oe(e) {
223
- var t, n;
224
- return !!(e.expression || e.derivedField || (n = (t = e.calculatedFormula) == null ? void 0 : t.inputFields) != null && n.length);
225
- }
226
- function ce(e) {
227
- return Y(e) ? !0 : e.entityName || e.qualifiedEntityName ? !1 : !e.source || oe(e);
228
- }
229
- function w(e, t) {
230
- const n = ae(t);
231
- e.found.has(n) || e.found.set(n, t);
232
- }
233
- function I(e, t) {
234
- var l, h, b;
235
- if (!e) return;
236
- const n = se(e);
237
- if (t.visitedFields.has(n)) return;
238
- t.visitedFields.add(n);
239
- const r = ce(e);
240
- if (!r) {
241
- const p = !e.entityName && !e.qualifiedEntityName ? P(e.source) : void 0;
242
- w(
243
- t,
244
- p || {
245
- // May be empty for qualified-only metadata; identity then comes from
246
- // `qualifiedEntityName` (see `identityFor` and the calculator).
247
- entityName: e.entityName || "",
248
- entityId: e.entityId,
249
- qualifiedEntityName: e.qualifiedEntityName,
250
- label: e.source && e.source.kind === "semantic" ? e.source.label : void 0
251
- }
252
- );
253
- }
254
- t.includeMetricFilterDatasets && "parameters" in e && ((l = e.parameters) != null && l.filters) && O(e.parameters.filters, t);
255
- const i = (h = e.calculatedFormula) == null ? void 0 : h.inputFields, s = !!(i && i.length > 0);
256
- s && i.forEach((p) => I(p, t));
257
- let a = !1, o = !1;
258
- const u = s || (b = e.derivedField) == null ? void 0 : b.inputs;
259
- if (u && Object.keys(u).length > 0)
260
- for (const p of Object.values(u)) {
261
- const f = p.field.source;
262
- if (!f) {
263
- s || (o = !0);
264
- continue;
265
- }
266
- if (f.kind === "sql") {
267
- o = !0;
268
- continue;
269
- }
270
- if (f.kind === "semantic")
271
- w(t, {
272
- entityName: f.datasetName,
273
- entityId: f.datasetId,
274
- label: f.label
275
- });
276
- else {
277
- const d = [f.databaseName, f.schemaName, f.tableName].filter((m) => !!(m && m.trim())).join(".");
278
- w(t, {
279
- entityName: f.tableName,
280
- qualifiedEntityName: d.includes(".") ? d : void 0,
281
- label: f.label
282
- });
283
- }
284
- a = !0;
285
- }
286
- o && (t.complete = !1), r && !s && !a && (t.complete = !1);
287
- }
288
- function O(e, t) {
289
- if (e && !t.visitedGroups.has(e.id)) {
290
- t.visitedGroups.add(e.id);
291
- for (const n of e.conditions || [])
292
- I(n.field, t);
293
- for (const n of e.groups || [])
294
- O(n, t);
295
- }
296
- }
297
- function v(e, t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set()) {
298
- return {
299
- found: /* @__PURE__ */ new Map(),
300
- complete: !0,
301
- visitedFields: t,
302
- visitedGroups: n,
303
- includeMetricFilterDatasets: e
304
- };
305
- }
306
- function A(e, t) {
307
- var r;
308
- const n = (r = e.qualifiedEntityName) != null && r.includes(".") ? e.qualifiedEntityName : void 0;
309
- return t === "qualifiedOnly" ? n : t === "preferQualified" ? n || e.entityName || void 0 : e.entityName || void 0;
310
- }
311
- function qe(e) {
312
- const t = v(!1);
313
- return I(e, t), { datasets: Array.from(t.found.values()), complete: t.complete };
314
- }
315
- function q(e, t, n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = k) {
316
- const s = { ...k, ...i }, a = v(s.includeMetricFilterDatasets, n, r);
317
- I(e, a), a.found.forEach((o) => {
318
- const u = A(o, s.preferQualifiedIdentity ? "preferQualified" : "name");
319
- u && t.add(u);
320
- });
321
- }
322
- function xe(e, t) {
323
- q(e, t, /* @__PURE__ */ new Set(), /* @__PURE__ */ new Set(), {
324
- preferQualifiedIdentity: !0
325
- });
326
- }
327
- function Ke(e, t, n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set()) {
328
- const i = v(!0, n, r);
329
- I(e, i), i.found.forEach((s) => {
330
- const a = A(s, "qualifiedOnly");
331
- a && t.add(a);
332
- });
333
- }
334
- function je(e, t, n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set()) {
335
- q(e, t, n, r, {
336
- includeMetricFilterDatasets: !1
337
- });
338
- }
339
- function Ue(e, t, n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = k) {
340
- const s = { ...k, ...i }, a = v(s.includeMetricFilterDatasets, n, r);
341
- O(e, a), a.found.forEach((o) => {
342
- const u = A(o, s.preferQualifiedIdentity ? "preferQualified" : "name");
343
- u && t.add(u);
344
- });
345
- }
346
- function ze(e, t) {
347
- return t != null && t[e] ? t[e] : (e.includes(".") ? e.slice(e.lastIndexOf(".") + 1) : e).replace(/[_-]+/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").replace(/\s+/g, " ").trim().replace(/\b\w/g, (r) => r.toUpperCase());
348
- }
349
- const ue = {
350
- date: /* @__PURE__ */ new Set([
351
- "between",
352
- "not between",
353
- "=",
354
- "!=",
355
- ">",
356
- ">=",
357
- "<",
358
- "<=",
359
- "is null",
360
- "is not null"
361
- ]),
362
- number: /* @__PURE__ */ new Set([
363
- "between",
364
- "not between",
365
- "=",
366
- "!=",
367
- ">",
368
- ">=",
369
- "<",
370
- "<=",
371
- "in",
372
- "not in",
373
- "is null",
374
- "is not null"
375
- ]),
376
- string: /* @__PURE__ */ new Set([
377
- "=",
378
- "!=",
379
- "in",
380
- "not in",
381
- "like",
382
- "not like",
383
- "is null",
384
- "is not null"
385
- ]),
386
- boolean: /* @__PURE__ */ new Set(["=", "!=", "in", "not in", "is null", "is not null"])
387
- };
388
- function de(e) {
389
- const t = W(e);
390
- return t === "number" || t === "boolean" ? t : t === "date" || t === "datetime" ? "date" : "string";
391
- }
392
- function Qe(e, t) {
393
- return typeof t != "string" ? !1 : ue[de(e)].has(t);
394
- }
395
- const le = /* @__PURE__ */ new Set([
396
- "=",
397
- ">",
398
- "<",
399
- ">=",
400
- "<=",
401
- "!=",
402
- "in",
403
- "not in",
404
- "like",
405
- "not like",
406
- "between",
407
- "not between",
408
- "is null",
409
- "is not null"
410
- ]);
411
- function fe(e, t) {
412
- return t === "number" ? typeof e == "number" && Number.isFinite(e) : t === "boolean" ? typeof e == "boolean" : t === "date" ? e instanceof Date || typeof e == "string" && e.trim().length > 0 : typeof e == "string" || typeof e == "number" || typeof e == "boolean";
413
- }
414
- function me(e, t, n, r) {
415
- if (H(e.relativeMeta)) {
416
- r.push(
417
- `${n}.relativeMeta counts back from the latest data; a dashboard filter's dates run to now. Use a period counted back from today.`
418
- );
419
- return;
420
- }
421
- pe(e.operation, e.values, t, `${n}.values`, r);
422
- }
423
- function pe(e, t, n, r, i) {
424
- if (e === "is null" || e === "is not null") {
425
- t.length !== 0 && i.push(`${r} must be empty for null filter operations.`);
426
- return;
427
- }
428
- if (e === "between" || e === "not between") {
429
- if (t.length !== 2) {
430
- i.push(
431
- `${r} must contain exactly two values for between operations.`
432
- );
433
- return;
434
- }
435
- } else if (e === "in" || e === "not in") {
436
- if (t.length === 0) {
437
- i.push(
438
- `${r} must contain at least one value for set operations.`
439
- );
440
- return;
441
- }
442
- } else if (t.length !== 1) {
443
- i.push(
444
- `${r} must contain exactly one value for '${String(e)}' operations.`
445
- );
446
- return;
447
- }
448
- for (const s of t)
449
- if (!fe(s, n)) {
450
- i.push(
451
- `${r} contains a value that is incompatible with valueType '${n}'.`
452
- );
453
- return;
454
- }
455
- }
456
- const Ge = {
457
- database: null,
458
- schema: null,
459
- table: null
460
- }, Ye = "__card_default__", x = {
461
- bookmarksPerViewerPerDashboard: 20,
462
- bookmarkNameMaxChars: 100,
463
- columnLabelMaxChars: 120,
464
- tableSettingsMaxBytes: 65536,
465
- rememberedTableSettingsMaxBytes: 262144,
466
- bookmarkStateMaxBytes: 65536
467
- }, K = 1;
468
- function He(e) {
469
- return new TextEncoder().encode(JSON.stringify(e ?? null)).length;
470
- }
471
- function he(e) {
472
- const t = encodeURIComponent;
473
- switch (e.kind) {
474
- case "dimension":
475
- return `dim:${e.role}:${t(e.fieldId)}`;
476
- case "metric":
477
- return `metric:${t(e.metricId)}:${t(
478
- e.metricAlias
479
- )}`;
480
- case "result":
481
- return `result:${t(e.key)}`;
482
- }
483
- }
484
- function g(e) {
485
- if (e)
486
- try {
487
- return decodeURIComponent(e);
488
- } catch {
489
- return;
490
- }
491
- }
492
- function be(e) {
493
- if (typeof e != "string") return;
494
- const t = e.split(":");
495
- let n;
496
- if (t[0] === "dim" && t.length === 3) {
497
- const r = t[1], i = g(t[2]);
498
- (r === "detail" || r === "groupby") && i && (n = { kind: "dimension", role: r, fieldId: i });
499
- } else if (t[0] === "metric" && t.length === 3) {
500
- const r = g(t[1]), i = g(t[2]);
501
- r && i && (n = { kind: "metric", metricId: r, metricAlias: i });
502
- } else if (t[0] === "result" && t.length === 2) {
503
- const r = g(t[1]);
504
- r && (n = { kind: "result", key: r });
505
- }
506
- return n && he(n) === e ? n : void 0;
507
- }
508
- function T(e) {
509
- return typeof e == "string" && be(e) !== void 0;
510
- }
511
- const $ = c.array(c.string()).max(2e3), ye = c.object({
512
- order: $.optional(),
513
- hidden: $.optional(),
514
- labels: c.record(c.string(), c.string().max(x.columnLabelMaxChars)).optional(),
515
- sort: c.array(
516
- c.object({
517
- columnId: c.string(),
518
- direction: c.enum(["asc", "desc"])
519
- }).strict()
520
- ).max(2e3).optional()
521
- }).strict();
522
- function R(e) {
523
- const t = /* @__PURE__ */ new Set(), n = [];
524
- for (const r of e)
525
- !T(r) || t.has(r) || (t.add(r), n.push(r));
526
- return n;
527
- }
528
- function j(e) {
529
- if (!e) return;
530
- const t = e.order ? R(e.order) : void 0, n = e.hidden ? R(e.hidden) : void 0, r = Object.entries(e.labels ?? {}).flatMap(
531
- ([o, u]) => {
532
- const l = typeof u == "string" ? u.trim() : "";
533
- return T(o) && l ? [
534
- [
535
- o,
536
- l.slice(0, x.columnLabelMaxChars)
537
- ]
538
- ] : [];
539
- }
540
- ), i = /* @__PURE__ */ new Set(), s = e.sort ? e.sort.filter((o) => !T(o.columnId) || i.has(o.columnId) ? !1 : (i.add(o.columnId), !0)) : void 0, a = {};
541
- return t != null && t.length && (a.order = t), n != null && n.length && (a.hidden = n), r.length && (a.labels = Object.fromEntries(r)), s && (a.sort = s.map(({ columnId: o, direction: u }) => ({
542
- columnId: o,
543
- direction: u
544
- }))), Object.keys(a).length ? a : void 0;
545
- }
546
- function U(e) {
547
- return j(e) === void 0;
548
- }
549
- function z(e, t) {
550
- if (t !== K)
551
- return {
552
- ok: !1,
553
- error: `Unsupported table settings version ${t}.`
554
- };
555
- const n = ye.safeParse(e);
556
- return n.success ? {
557
- ok: !0,
558
- value: j(n.data) ?? {}
559
- } : { ok: !1, error: "Table settings are invalid." };
560
- }
561
- function We(e, t, n) {
562
- if (!e || typeof e != "object" || Array.isArray(e)) return {};
563
- const r = {};
564
- for (const [i, s] of Object.entries(
565
- e
566
- )) {
567
- if (!n.has(i)) continue;
568
- const a = z(s, t);
569
- a.ok && !U(a.value) && (r[i] = a.value);
570
- }
571
- return r;
572
- }
573
- const Se = /* @__PURE__ */ new Set([
574
- "table",
575
- "detailTable"
576
- ]);
577
- function Q(e) {
578
- return Se.has(e.type);
579
- }
580
- function Ie(e) {
581
- var t, n;
582
- return Q(e) && ((n = (t = e.preferences) == null ? void 0 : t.tablePrefs) == null ? void 0 : n.allowViewerColumnCustomization) !== !1;
583
- }
584
- function Je(e) {
585
- return new Set(
586
- S(e).filter(({ card: t }) => Q(t)).map(({ card: t }) => t.id)
587
- );
588
- }
589
- function Ze(e) {
590
- return new Set(
591
- S(e).filter(({ card: t }) => Ie(t)).map(({ card: t }) => t.id)
592
- );
593
- }
594
- const N = 1, Xe = ["PRIVATE", "TEAM", "DASHBOARD"], ge = c.object({
595
- filterId: c.string().min(1),
596
- name: c.string(),
597
- operation: c.string(),
598
- valueType: c.enum(["string", "number", "date", "boolean"]),
599
- values: c.array(c.unknown())
600
- }).passthrough().superRefine((e, t) => {
601
- const n = [];
602
- le.has(e.operation) ? me(e, e.valueType, "filterValue", n) : n.push("filterValue.operation must be a valid filter operation.");
603
- for (const r of n) t.addIssue({ code: "custom", message: r });
604
- }), D = c.unknown().superRefine((e, t) => {
605
- for (const n of X(e).errors)
606
- t.addIssue({ code: "custom", message: n.message });
607
- }), ke = c.discriminatedUnion("kind", [
608
- c.object({ kind: c.literal("filter"), filterValue: ge }).strict(),
609
- c.object({ kind: c.literal("control"), value: c.unknown() }).strict(),
610
- c.object({
611
- kind: c.literal("selection"),
612
- selection: J
613
- }).strict()
614
- ]), ve = c.union([
615
- c.object({
616
- status: c.literal("set"),
617
- value: ke,
618
- comparisonSelection: D.optional()
619
- }).strict(),
620
- c.object({
621
- status: c.literal("cleared"),
622
- comparisonSelection: D.optional()
623
- }).strict(),
624
- c.object({ comparisonSelection: D }).strict()
625
- ]), G = ["bySheetId", "byCardId", "byDocumentSectionId"], Ce = /* @__PURE__ */ new Set(["version", "selectedSheetId", "inputs", "tableSettings"]), Ee = /* @__PURE__ */ new Set(["shared", ...G]), y = (e) => !!e && typeof e == "object" && !Array.isArray(e);
626
- function M(e, t, n) {
627
- if (e === void 0) return;
628
- if (!y(e)) {
629
- t.push({ target: "input", id: n });
630
- return;
631
- }
632
- const r = {};
633
- for (const [i, s] of Object.entries(e)) {
634
- const a = i ? ve.safeParse(s) : void 0;
635
- a != null && a.success ? r[i] = a.data : t.push({
636
- target: Z(i) ? "selection" : "input",
637
- id: i
638
- });
639
- }
640
- return Object.keys(r).length ? r : void 0;
641
- }
642
- function we(e, t) {
643
- if (t !== N)
644
- return { ok: !1, error: `Unsupported bookmark version ${t}.` };
645
- if (!y(e) || e.version !== N)
646
- return { ok: !1, error: "The bookmark state is invalid." };
647
- const n = [], r = Object.keys(e).filter((o) => !Ce.has(o));
648
- let i;
649
- typeof e.selectedSheetId == "string" && e.selectedSheetId ? i = e.selectedSheetId : e.selectedSheetId !== void 0 && n.push({ target: "sheet", id: String(e.selectedSheetId) });
650
- const s = {};
651
- if (y(e.inputs)) {
652
- r.push(
653
- ...Object.keys(e.inputs).filter((u) => !Ee.has(u)).map((u) => `inputs.${u}`)
654
- );
655
- const o = M(e.inputs.shared, n, "shared");
656
- o && (s.shared = o);
657
- for (const u of G) {
658
- const l = e.inputs[u];
659
- if (l === void 0) continue;
660
- if (!y(l)) {
661
- n.push({ target: "input", id: u });
662
- continue;
663
- }
664
- const h = {};
665
- for (const [b, p] of Object.entries(l)) {
666
- const f = M(p, n, `${u}.${b}`);
667
- f && (h[b] = f);
668
- }
669
- Object.keys(h).length && (s[u] = h);
670
- }
671
- } else e.inputs !== void 0 && r.push("inputs");
672
- const a = {};
673
- if (y(e.tableSettings))
674
- for (const [o, u] of Object.entries(e.tableSettings)) {
675
- const l = o ? z(u, K) : void 0;
676
- l != null && l.ok ? U(l.value) || (a[o] = l.value) : n.push({ target: "card", id: o });
677
- }
678
- else e.tableSettings !== void 0 && r.push("tableSettings");
679
- return {
680
- ok: !0,
681
- value: {
682
- version: N,
683
- ...i ? { selectedSheetId: i } : {},
684
- ...Object.keys(s).length ? { inputs: s } : {},
685
- ...Object.keys(a).length ? { tableSettings: a } : {}
686
- },
687
- issues: n,
688
- unknownKeys: r
689
- };
690
- }
691
- function et(e, t) {
692
- const n = we(e, t);
693
- return n.ok ? n.issues.some((r) => r.target === "card") ? { ok: !1, error: "The bookmark table settings are invalid." } : n.issues.length || n.unknownKeys.length ? { ok: !1, error: "The bookmark state is invalid." } : { ok: !0, value: n.value } : n;
694
- }
695
- export {
696
- ee as A,
697
- N as B,
698
- Ye as C,
699
- _ as D,
700
- Ge as E,
701
- V as F,
702
- te as G,
703
- Fe as H,
704
- _e as I,
705
- de as J,
706
- Qe as K,
707
- le as L,
708
- me as M,
709
- re as N,
710
- $e as O,
711
- S as P,
712
- Ve as Q,
713
- Re as R,
714
- Me as S,
715
- Be as T,
716
- x as V,
717
- Pe as a,
718
- xe as b,
719
- q as c,
720
- P as d,
721
- Ke as e,
722
- je as f,
723
- Ue as g,
724
- ze as h,
725
- we as i,
726
- K as j,
727
- be as k,
728
- U as l,
729
- He as m,
730
- j as n,
731
- z as o,
732
- et as p,
733
- We as q,
734
- qe as r,
735
- Q as s,
736
- he as t,
737
- Ie as u,
738
- Je as v,
739
- Ze as w,
740
- Xe as x,
741
- Le as y,
742
- L as z
743
- };