react-semaphor 0.1.540 → 0.1.542

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 (118) hide show
  1. package/dist/analytics-protocol/index.js +75 -75
  2. package/dist/assistant-context/index.js +1 -1
  3. package/dist/brand-studio/index.js +3 -3
  4. package/dist/briefings/index.js +50 -45
  5. package/dist/chunks/apply-dashboard-operations-Btbp2-6v.js +2260 -0
  6. package/dist/chunks/{assistant-chat-ya7xopaC.js → assistant-chat-oHF5lTjA.js} +12 -12
  7. package/dist/chunks/bookmark-state-CXw7lZ50.js +118 -0
  8. package/dist/chunks/{calendar-day-equality-Bpl15IBo.js → calendar-day-equality-BmJAWduY.js} +180 -207
  9. package/dist/chunks/comparison-window-caption-ChIyd_-L.js +1618 -0
  10. package/dist/chunks/custom-visual-inputs-DUtpYZOk.js +323 -0
  11. package/dist/chunks/{dashboard-briefing-launcher-DJI-zfEq.js → dashboard-briefing-launcher-B-cm719R.js} +18 -18
  12. package/dist/chunks/{dashboard-controls-Dh7HqoKy.js → dashboard-controls-CIn22Qgp.js} +69 -70
  13. package/dist/chunks/{dashboard-filter-value-compatibility-D95O4nd7.js → dashboard-filter-value-compatibility-CwQ_iSNb.js} +2 -2
  14. package/dist/chunks/{dashboard-json-BnmlB71h.js → dashboard-json-ZUYsIExq.js} +4 -4
  15. package/dist/chunks/{dashboard-B6Bithfl.js → dashboard-s5WJBcK8.js} +1 -1
  16. package/dist/chunks/{document-dashboard-inputs-BrYYlRVo.js → document-dashboard-inputs-C6MJVyoI.js} +2357 -4948
  17. package/dist/chunks/document-sheet-utils-BsZUnHRl.js +3619 -0
  18. package/dist/chunks/{edit-dashboard-visual-CydOkSko.js → edit-dashboard-visual-DLdereA7.js} +728 -728
  19. package/dist/chunks/{filter-value-text-BhWugPWE.js → filter-value-text-CYsVYPuD.js} +18 -19
  20. package/dist/chunks/index-CV5rHq5D.js +2673 -0
  21. package/dist/chunks/{matrix-analytical-definition-bcprSe4u.js → matrix-analytical-definition-C7Gb0e12.js} +1 -1
  22. package/dist/chunks/{matrix-card-CJn1hB5V.js → matrix-card-DjwWcCo8.js} +2 -2
  23. package/dist/chunks/{matrix-formatter-DQ8avoIQ.js → matrix-formatter-BnsTX90d.js} +430 -417
  24. package/dist/chunks/{matrix-member-presentation-BNPSDKBG.js → matrix-member-presentation-CQGdVks6.js} +1 -1
  25. package/dist/chunks/{matrix-operation-contract-B8PBF1Gd.js → matrix-operation-contract-8OIO4gob.js} +65 -65
  26. package/dist/chunks/metric-comparison-DEwi9uc2.js +498 -0
  27. package/dist/chunks/numeric-presentation-BSAqPpHt.js +5227 -0
  28. package/dist/chunks/{pivot-header-presentation-MkcKnjn3.js → pivot-header-presentation-DHcx1XGQ.js} +1 -1
  29. package/dist/chunks/{pivot-result-identity-D6hhcRXi.js → pivot-result-identity-DJhXXcns.js} +1 -1
  30. package/dist/chunks/pivot-result-lifecycle-BBlAfBA0.js +1155 -0
  31. package/dist/chunks/raw-temporal-presentation-CZ2r0Vb_.js +585 -0
  32. package/dist/chunks/{report-preferences-dialog-neMDolLg.js → report-preferences-dialog-MRUWpMcJ.js} +75 -75
  33. package/dist/chunks/{report-runtime-context-B984Nq1E.js → report-runtime-context-Dq8XyODK.js} +1 -1
  34. package/dist/chunks/{saved-dashboard-context-CCrLpfSQ.js → saved-dashboard-context-DjPqgFly.js} +233 -206
  35. package/dist/chunks/{selection-reducer-vKIb_jS6.js → selection-reducer-Dj_8xD69.js} +1 -1
  36. package/dist/chunks/{semaphor-ready-indicator--4DWtVBu.js → semaphor-ready-indicator-BWSpRsPj.js} +38555 -40449
  37. package/dist/chunks/{shelf-drop-preview-context-CpdB5ois.js → shelf-drop-preview-context-CQbFLm3q.js} +6 -6
  38. package/dist/chunks/sort-target-MT1WK1vX.js +29 -0
  39. package/dist/chunks/{source-entity-resolution-CVA1a85c.js → source-entity-resolution-BYn9giz3.js} +1 -1
  40. package/dist/chunks/{switch-DWEWiv1J.js → switch-C3jLxlG0.js} +2 -2
  41. package/dist/chunks/table-export-sheet-BHSnuZHd.js +949 -0
  42. package/dist/chunks/table-settings-CLZocegs.js +501 -0
  43. package/dist/chunks/temporal-bucket-D7NBrrtL.js +2071 -0
  44. package/dist/chunks/{token-types-bxUxXDX2.js → token-types-DBbZVQsm.js} +1 -1
  45. package/dist/chunks/{use-create-flow-overlay-state-8g6Zhphh.js → use-create-flow-overlay-state-BJDNqdOh.js} +151 -151
  46. package/dist/chunks/{validators-Ej1DdCXa.js → validators-DMHTpf7a.js} +73 -73
  47. package/dist/dashboard/index.js +2 -2
  48. package/dist/dashboard-authoring/index.js +399 -380
  49. package/dist/data-app-sdk/index.js +5 -5
  50. package/dist/data-app-sdk-adapters/index.js +2 -2
  51. package/dist/data-app-sdk-validation/index.js +9 -9
  52. package/dist/format-utils/index.js +346 -238
  53. package/dist/index.js +174 -175
  54. package/dist/pdf-export-policy/index.js +20 -10
  55. package/dist/report-runtime-context/index.js +1 -1
  56. package/dist/surfboard/index.js +2 -2
  57. package/dist/types/briefings/attachment-outcomes.d.ts +23 -0
  58. package/dist/types/briefings/attachments.d.ts +17 -1
  59. package/dist/types/briefings/index.d.ts +6 -3
  60. package/dist/types/index.js +48 -48
  61. package/dist/types/lib/api/exports-api.d.ts +11 -65
  62. package/dist/types/lib/dashboard-inputs/control-contract-overrides.d.ts +17 -0
  63. package/dist/types/lib/dashboard-viewer/export-table-view.d.ts +2 -0
  64. package/dist/types/lib/hooks/use-dashboard-card.d.ts +2 -0
  65. package/dist/types/lib/hooks/use-dashboard.d.ts +3 -6
  66. package/dist/types/lib/matrix-table/matrix-delivery-policy.d.ts +8 -2
  67. package/dist/types/lib/matrix-table/matrix-delivery.d.ts +8 -6
  68. package/dist/types/lib/query-context/build-dashboard-card-query-contract.d.ts +50 -0
  69. package/dist/types/lib/query-context/card-server-request.d.ts +5 -1
  70. package/dist/types/lib/types/common-types.d.ts +7 -0
  71. package/dist/types/lib/types/explorer-types.d.ts +8 -2
  72. package/dist/types/shared/analytics-protocol/matrix-definition-contract.d.ts +3 -3
  73. package/dist/types/shared/assistant-context/index.d.ts +1 -1
  74. package/dist/types/shared/assistant-context/saved-dashboard-context.d.ts +23 -6
  75. package/dist/types/shared/dashboard-authoring/card-export-request.d.ts +173 -0
  76. package/dist/types/shared/dashboard-authoring/card-query-request.d.ts +20 -0
  77. package/dist/types/shared/dashboard-authoring/index.d.ts +1 -0
  78. package/dist/types/shared/dashboard-authoring/matrix-delivery.d.ts +4 -3
  79. package/dist/types/shared/format-utils/attachment-filter-line.d.ts +14 -0
  80. package/dist/types/shared/format-utils/exporters/export-cells.d.ts +90 -0
  81. package/dist/types/shared/format-utils/exporters/export-file-format.d.ts +44 -0
  82. package/dist/types/shared/format-utils/exporters/index.d.ts +6 -0
  83. package/dist/types/shared/format-utils/exporters/xlsx-file.d.ts +90 -0
  84. package/dist/types/shared/format-utils/filter-line.d.ts +7 -0
  85. package/dist/types/shared/format-utils/formatters/date-formatter.d.ts +8 -12
  86. package/dist/types/shared/format-utils/formatters/index.d.ts +1 -1
  87. package/dist/types/shared/format-utils/formatters/matrix-formatter.d.ts +2 -0
  88. package/dist/types/shared/format-utils/index.d.ts +3 -0
  89. package/dist/types/shared/format-utils/matrix-continuation.d.ts +55 -9
  90. package/dist/types/shared/format-utils/matrix-export-presentation.d.ts +21 -1
  91. package/dist/types/shared/format-utils/matrix-export-xlsx.d.ts +27 -0
  92. package/dist/types/shared/format-utils/pdf-export-policy.d.ts +9 -0
  93. package/dist/types/shared/format-utils/presentation-execution.d.ts +27 -2
  94. package/dist/types/shared/format-utils/raw-temporal.d.ts +8 -0
  95. package/dist/types/shared/format-utils/table-export/index.d.ts +8 -0
  96. package/dist/types/shared/format-utils/table-export/prepare-table-export.d.ts +50 -0
  97. package/dist/types/shared/format-utils/table-export/table-export-formatting.d.ts +47 -0
  98. package/dist/types/shared/format-utils/table-export/table-export-raw-temporal.d.ts +40 -0
  99. package/dist/types/shared/format-utils/table-export/table-export-result.d.ts +31 -0
  100. package/dist/types/shared/format-utils/table-export/table-export-sheet.d.ts +38 -0
  101. package/dist/types/shared/format-utils/temporal-bucket.d.ts +9 -0
  102. package/package.json +2 -1
  103. package/dist/chunks/aggregate-table-row-presentation-BjK9YfMI.js +0 -979
  104. package/dist/chunks/apply-dashboard-operations-C-iahGka.js +0 -402
  105. package/dist/chunks/bookmark-state-k7y5SNGf.js +0 -331
  106. package/dist/chunks/calculated-field-identity-DcBS2NPP.js +0 -2161
  107. package/dist/chunks/canonical-result-keys-CEQefvdO.js +0 -33
  108. package/dist/chunks/common-types-CUf03Htv.js +0 -288
  109. package/dist/chunks/csv-utils-GUfKyT1J.js +0 -56
  110. package/dist/chunks/custom-visual-inputs-BrUOIwln.js +0 -3288
  111. package/dist/chunks/document-sheet-utils-C1eEldxs.js +0 -1076
  112. package/dist/chunks/index-CqMiAkay.js +0 -3164
  113. package/dist/chunks/matrix-definition-DQDI2okF.js +0 -206
  114. package/dist/chunks/metric-comparison-CojWeLqx.js +0 -392
  115. package/dist/chunks/pivot-result-lifecycle-8qCDmpKc.js +0 -804
  116. package/dist/chunks/raw-temporal-D61lr48Y.js +0 -1464
  117. package/dist/chunks/temporal-bucket-D8JF7zKz.js +0 -575
  118. package/dist/chunks/temporal-bucket-contract-DaOajRC7.js +0 -108
@@ -0,0 +1,2673 @@
1
+ var _e = Object.defineProperty;
2
+ var Oe = (e, n, t) => n in e ? _e(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
3
+ var L = (e, n, t) => Oe(e, typeof n != "symbol" ? n + "" : n, t);
4
+ import { r as ae, q as de, j as Fe } from "./temporal-bucket-D7NBrrtL.js";
5
+ import { a8 as J, l as Ne, t as Re } from "./validators-DMHTpf7a.js";
6
+ import { n as Be, a1 as Me, L as Le, C as Ue, K as Pe, P as B } from "./pivot-result-lifecycle-BBlAfBA0.js";
7
+ import { z as y } from "zod";
8
+ import { af as Ve, ah as ze, V as je } from "./matrix-operation-contract-8OIO4gob.js";
9
+ import "./analytics-base-schemas-BFAoRlkU.js";
10
+ import "../value-format-preferences/index.js";
11
+ import { aa as qe, ab as Ke, ac as He, r as Ge, n as We } from "./numeric-presentation-BSAqPpHt.js";
12
+ import { r as Xe } from "./matrix-card-DjwWcCo8.js";
13
+ import { x as Ze } from "./table-settings-CLZocegs.js";
14
+ import { r as Ye, a as Je, b as Qe, c as et, d as tt } from "./raw-temporal-presentation-CZ2r0Vb_.js";
15
+ import { f as nt, r as rt, b as ot, g as at } from "./custom-visual-inputs-DUtpYZOk.js";
16
+ const it = /* @__PURE__ */ new Set([
17
+ "table",
18
+ "aggregateTable",
19
+ "pivotTable",
20
+ "detailTable"
21
+ ]), ct = /* @__PURE__ */ new Set([
22
+ "bar",
23
+ "horizontalBar",
24
+ "line",
25
+ "area",
26
+ "stackedArea",
27
+ "combo",
28
+ "pie",
29
+ "doughnut",
30
+ "radar",
31
+ "polarArea",
32
+ "bubble",
33
+ "scatter",
34
+ "stackedBar",
35
+ "stackedLine",
36
+ "table",
37
+ "pivotTable",
38
+ "aggregateTable",
39
+ "matrixTable",
40
+ "detailTable",
41
+ "kpi",
42
+ "pyramid",
43
+ "tornado",
44
+ "range",
45
+ "map",
46
+ "funnel",
47
+ "bullet",
48
+ "heatmap",
49
+ "treemap",
50
+ "custom"
51
+ ]);
52
+ function Pn(e) {
53
+ var o, a, i;
54
+ const n = ct.has(e.type) && (e.type !== "custom" || !!((o = e.customCardPreferences) != null && o.url));
55
+ let t = !1;
56
+ try {
57
+ t = !!Xe(e);
58
+ } catch {
59
+ return { formats: [], defaultFormat: null };
60
+ }
61
+ return e.type === "text" || !n || !t && qe(e) ? { formats: [], defaultFormat: null } : {
62
+ formats: lt({
63
+ cardType: e.type,
64
+ allowDownload: (a = e.preferences) == null ? void 0 : a.allowDownload
65
+ }).filter((c) => c !== "xlsx" || e.type !== "matrixTable" || t),
66
+ defaultFormat: dt({
67
+ cardType: e.type,
68
+ allowDownload: (i = e.preferences) == null ? void 0 : i.allowDownload
69
+ })
70
+ };
71
+ }
72
+ function Q(e) {
73
+ return e === "table" || e === "detailTable";
74
+ }
75
+ function Vn(e) {
76
+ var n, t;
77
+ return e.type !== "card" || e.format === "pdf" ? !1 : !!((n = e.settings) != null && n.matrix) || Q((t = e.settings) == null ? void 0 : t.cardType);
78
+ }
79
+ function lt(e) {
80
+ return e.allowDownload === !1 ? ["pdf"] : e.cardType === "matrixTable" || Q(e.cardType) ? ["pdf", "csv", "xlsx"] : ["pdf", "csv"];
81
+ }
82
+ function zn(e) {
83
+ return e === "pdf" ? "PDF" : Be(e).label;
84
+ }
85
+ function dt(e) {
86
+ return it.has(e.cardType) && e.allowDownload !== !1 ? "csv" : "pdf";
87
+ }
88
+ function jn(e) {
89
+ const { config: n } = e, t = Me({
90
+ spec: n.spec,
91
+ presentation: n.presentation,
92
+ defaults: n.defaultView,
93
+ session: e.purpose === "manual" ? e.session : void 0
94
+ });
95
+ return J.parse({
96
+ spec: t.spec,
97
+ presentation: t.presentation,
98
+ ...e.content === "flat" ? { mode: "flat", format: e.format === "xlsx" ? "xlsx" : "csv" } : {
99
+ mode: "layout",
100
+ format: e.format,
101
+ expansion: e.content === "all" ? { kind: "all" } : {
102
+ kind: "current",
103
+ rows: t.view.rows,
104
+ columns: t.view.columns
105
+ }
106
+ }
107
+ });
108
+ }
109
+ const st = y.object({
110
+ connection_id: y.string().min(1),
111
+ cardType: y.literal("matrixTable"),
112
+ resultOwner: y.literal("config"),
113
+ sql: y.literal("").optional(),
114
+ python: y.literal("").optional(),
115
+ tableStructure: y.never().optional(),
116
+ cardDataSource: y.object({
117
+ connectionId: y.string().min(1),
118
+ connectionType: y.string().min(1),
119
+ mode: y.enum(["database", "semanticDomain"]),
120
+ selectedEntities: y.array(y.unknown()),
121
+ semanticDomainId: y.string().optional()
122
+ }).passthrough(),
123
+ active_filters: y.array(y.unknown()).default([])
124
+ }).passthrough(), qn = st.extend({
125
+ dashboardId: y.string().min(1),
126
+ cardId: y.string().min(1),
127
+ formatOptions: y.object({
128
+ matrix: J,
129
+ acquisition: y.literal("continuation").optional(),
130
+ presentationExecutionSnapshot: y.unknown()
131
+ }).passthrough().superRefine((e, n) => {
132
+ e.matrix.format !== "pdf" != (e.acquisition === "continuation") && n.addIssue({
133
+ code: y.ZodIssueCode.custom,
134
+ path: ["acquisition"],
135
+ message: "CSV and Excel require continuation acquisition; PDF must not specify acquisition."
136
+ });
137
+ })
138
+ });
139
+ function Kn(e) {
140
+ return {
141
+ ...e.controls,
142
+ type: "card",
143
+ dashboardId: e.dashboardId,
144
+ cardId: e.cardId,
145
+ title: e.title,
146
+ cardType: "matrixTable",
147
+ resultOwner: "config",
148
+ sql: "",
149
+ python: "",
150
+ connection_id: e.dataSource.connectionId,
151
+ // Editor metadata can omit mode; the captured source owns dataset identity.
152
+ cardDataSource: {
153
+ ...e.dataSource,
154
+ mode: e.matrix.spec.source.kind === "semantic" ? "semanticDomain" : "database",
155
+ semanticDomainId: e.matrix.spec.source.kind === "semantic" ? e.matrix.spec.source.domainId : void 0
156
+ },
157
+ active_filters: e.activeFilters,
158
+ formatOptions: {
159
+ ...e.matrix.format !== "pdf" ? {
160
+ acquisition: "continuation",
161
+ ...e.csvEncoding ? { csvEncoding: e.csvEncoding } : {}
162
+ } : {},
163
+ matrix: e.matrix,
164
+ delimiter: e.delimiter,
165
+ includeHeaders: e.includeHeaders,
166
+ timezone: e.reportContext.calendar.tz,
167
+ presentationExecutionSnapshot: Le({
168
+ reportContext: e.reportContext,
169
+ resolvedFormats: []
170
+ })
171
+ }
172
+ };
173
+ }
174
+ const K = y.number().int().nonnegative(), Hn = y.discriminatedUnion("status", [
175
+ y.object({
176
+ status: y.literal("ok"),
177
+ request: J,
178
+ layout: Ve,
179
+ rows: y.array(ze).readonly(),
180
+ usage: y.object({ rows: K, cells: K, bytes: K }).strict()
181
+ }).strict(),
182
+ y.object({
183
+ status: y.literal("failed"),
184
+ failure: y.object({
185
+ code: y.enum(je),
186
+ limit: y.enum(["rows", "bytes"]).optional(),
187
+ message: y.string().min(1),
188
+ retryable: y.boolean()
189
+ }).strict()
190
+ }).strict()
191
+ ]);
192
+ function ie(e) {
193
+ return !e || typeof e != "object" ? !1 : Array.isArray(e.cards);
194
+ }
195
+ function mt(e) {
196
+ if (!e)
197
+ return null;
198
+ if (typeof e == "string")
199
+ try {
200
+ const n = JSON.parse(e);
201
+ return ie(n) ? n : null;
202
+ } catch {
203
+ return null;
204
+ }
205
+ return ie(e) ? e : null;
206
+ }
207
+ function se(e) {
208
+ var n;
209
+ return (n = e == null ? void 0 : e.cards) != null && n.length ? e.activeCardId && e.cards.find((t) => t.id === e.activeCardId) || e.cards[0] : null;
210
+ }
211
+ function Gn(e) {
212
+ var t;
213
+ const n = (e == null ? void 0 : e.frameObject) ?? ((t = e == null ? void 0 : e.visual) == null ? void 0 : t.frameObject);
214
+ return se(mt(n));
215
+ }
216
+ class U extends Error {
217
+ constructor(t) {
218
+ const r = t.cardId ? `card "${t.cardId}"` : t.sheetId ? `sheet "${t.sheetId}"` : `dashboard "${t.dashboardId}"`;
219
+ super(
220
+ `Unable to resolve ${r} while capturing report presentation. Refresh the authoring page and select the attachment again.`
221
+ );
222
+ L(this, "code", "temporal_snapshot_target_not_found");
223
+ L(this, "selection");
224
+ this.name = "TemporalSnapshotSelectionError", this.selection = t;
225
+ }
226
+ }
227
+ function ft(e, n) {
228
+ var o;
229
+ const t = [], r = /* @__PURE__ */ new Map();
230
+ for (const a of n) {
231
+ if (a.dashboardId !== e.id)
232
+ throw new U(a);
233
+ const i = (e.sheets || []).filter(
234
+ (l) => !a.sheetId || a.sheetId === l.id
235
+ );
236
+ if (a.sheetId && i.length === 0)
237
+ throw new U(a);
238
+ let c = !a.cardId;
239
+ for (const l of i) {
240
+ const m = (((o = l.document) == null ? void 0 : o.sections) || []).flatMap(
241
+ (h) => Ze(h)
242
+ ), s = (l.frames || []).flatMap(
243
+ (h) => ut(h, a.cardId)
244
+ );
245
+ s.length > 0 && (c = !0);
246
+ const u = [
247
+ ...s,
248
+ ...(l.cards || []).filter(
249
+ (h) => !a.cardId || a.cardId === h.id
250
+ ),
251
+ ...m.filter(
252
+ (h) => !a.cardId || a.cardId === h.id
253
+ )
254
+ ];
255
+ for (const h of u) {
256
+ c = !0;
257
+ const g = r.get(a.attachmentIndex) ?? /* @__PURE__ */ new Set();
258
+ g.has(h.id) || (g.add(h.id), r.set(a.attachmentIndex, g), t.push({
259
+ card: h,
260
+ ...a.attachmentIndex !== void 0 ? { attachmentIndex: a.attachmentIndex } : {}
261
+ }));
262
+ }
263
+ }
264
+ if (!c)
265
+ throw new U(a);
266
+ }
267
+ return t;
268
+ }
269
+ function ut(e, n) {
270
+ var i;
271
+ const t = n ? (i = e.cards) == null ? void 0 : i.find((c) => c.id === n) : se(e);
272
+ if (!t) return [];
273
+ const r = nt(e, t), o = (e.cards || []).filter(
274
+ (c) => {
275
+ var l;
276
+ return typeof ((l = c.customCardPreferences) == null ? void 0 : l.slotIndex) == "number";
277
+ }
278
+ ).length > 1, a = r != null && (rt(r) === "multiple" || o);
279
+ return !r || !a ? [t] : ot(
280
+ at({
281
+ frame: e,
282
+ configCard: r,
283
+ isMultiInputVisual: !0
284
+ })
285
+ ).filter((c) => c !== null);
286
+ }
287
+ function Wn(e) {
288
+ return ft(e.dashboard, e.selections).flatMap(
289
+ ({ card: n, attachmentIndex: t }) => {
290
+ var s, u, h, g;
291
+ const r = ((s = e.resolveCardConfig) == null ? void 0 : s.call(e, n)) ?? n.config, o = Ke({
292
+ card: n,
293
+ cardConfig: r
294
+ }), a = {
295
+ dashboardId: e.dashboard.id,
296
+ cardId: n.id,
297
+ ...t !== void 0 ? { attachmentIndex: t } : {}
298
+ }, i = o ? o.fields.map((E) => ({
299
+ scope: a,
300
+ target: {
301
+ kind: "field",
302
+ fieldId: E.id,
303
+ role: E.role
304
+ },
305
+ format: He(
306
+ E,
307
+ {
308
+ dateStyle: e.valueFormatPreferences.dateStyle,
309
+ dateTime: { ...e.valueFormatPreferences.dateTime }
310
+ },
311
+ e.valueFormatPreferences.locale
312
+ )
313
+ })) : [], c = [], l = Ge(n, r), m = We(
314
+ n.python || ""
315
+ );
316
+ if (n.type === "detailTable" && l === "config") {
317
+ const E = (r == null ? void 0 : r.detailColumns) || [], x = [
318
+ ...((r == null ? void 0 : r.groupByColumns) || []).map(($) => ({
319
+ field: $,
320
+ role: "groupby"
321
+ })),
322
+ ...((r == null ? void 0 : r.metricColumns) || []).map(($) => ({
323
+ field: $,
324
+ role: "metric"
325
+ })),
326
+ ...((r == null ? void 0 : r.pivotByColumns) || []).map(($) => ({
327
+ field: $,
328
+ role: "pivotby"
329
+ })),
330
+ ...E.map(($) => ({
331
+ field: $,
332
+ role: "detail"
333
+ }))
334
+ ], _ = /* @__PURE__ */ new Map(), M = new Set(
335
+ x.map(
336
+ ({ field: $, role: T }) => Ye($, T)
337
+ )
338
+ );
339
+ for (const { field: $ } of x) {
340
+ const T = $.label;
341
+ T && _.set(T, (_.get(T) || 0) + 1);
342
+ }
343
+ for (const $ of E) {
344
+ const T = Ne($.dataType);
345
+ if (T !== "date" && T !== "datetime") continue;
346
+ const De = Je($), q = $.label, oe = Qe({
347
+ label: q,
348
+ labelCount: q && _.get(q) || 0,
349
+ rawKey: De,
350
+ rawKeys: M
351
+ });
352
+ if (!oe) throw new U(a);
353
+ c.push({
354
+ scope: a,
355
+ target: { kind: "column", columnKey: oe },
356
+ format: ae({
357
+ format: et($),
358
+ preferences: e.valueFormatPreferences,
359
+ calendar: e.calendar
360
+ })
361
+ });
362
+ }
363
+ } else if (l === "freeform" && ((u = n.sql) != null && u.trim()) && !m.trim())
364
+ for (const [E, x] of Object.entries(
365
+ ((g = (h = n.preferences) == null ? void 0 : h.tablePrefs) == null ? void 0 : g.columnSettingsMap) || {}
366
+ )) {
367
+ if (x.type !== "date") continue;
368
+ const _ = tt(
369
+ x.dateFormat
370
+ );
371
+ _ && c.push({
372
+ scope: a,
373
+ target: { kind: "column", columnKey: E },
374
+ format: ae({
375
+ format: _,
376
+ preferences: e.valueFormatPreferences,
377
+ calendar: e.calendar
378
+ })
379
+ });
380
+ }
381
+ return [...i, ...c];
382
+ }
383
+ );
384
+ }
385
+ function pt(e) {
386
+ return !!e && typeof e == "object" && !Array.isArray(e);
387
+ }
388
+ function A(e, n, t) {
389
+ return pt(e) ? e : (t.push({ field: n, message: "Expected an object." }), {});
390
+ }
391
+ function w(e, n, t, r) {
392
+ const o = new Set(t);
393
+ Object.keys(e).forEach((a) => {
394
+ o.has(a) || r.push({
395
+ field: `${n}.${a}`,
396
+ message: "Unexpected property."
397
+ });
398
+ });
399
+ }
400
+ function F(e, n, t, r, o = {}) {
401
+ if (e == null)
402
+ return;
403
+ if (typeof e != "string") {
404
+ r.push({ field: n, message: "Expected a string." });
405
+ return;
406
+ }
407
+ const a = o.trim === !1 ? e : e.trim();
408
+ if (!o.allowEmpty && a.length === 0) {
409
+ r.push({ field: n, message: "Expected a non-empty string." });
410
+ return;
411
+ }
412
+ if (a.length > t) {
413
+ r.push({
414
+ field: n,
415
+ message: `Expected ${t} characters or fewer.`
416
+ });
417
+ return;
418
+ }
419
+ return a;
420
+ }
421
+ function ee(e, n, t) {
422
+ const r = F(e, n, 2e3, t);
423
+ if (r)
424
+ try {
425
+ return new URL(r), r;
426
+ } catch {
427
+ t.push({ field: n, message: "Expected an absolute URL." });
428
+ return;
429
+ }
430
+ }
431
+ function ce(e, n, t) {
432
+ const r = A(e, n, t);
433
+ w(r, n, ["tokens", "components"], t);
434
+ const o = {};
435
+ if (r.tokens !== void 0) {
436
+ const a = A(r.tokens, `${n}.tokens`, t);
437
+ w(
438
+ a,
439
+ `${n}.tokens`,
440
+ ["color", "typography"],
441
+ t
442
+ );
443
+ const i = {};
444
+ if (a.color !== void 0) {
445
+ const c = A(
446
+ a.color,
447
+ `${n}.tokens.color`,
448
+ t
449
+ ), l = [
450
+ "background",
451
+ "foreground",
452
+ "muted",
453
+ "mutedForeground",
454
+ "border",
455
+ "primary",
456
+ "primaryForeground",
457
+ "positive",
458
+ "negative",
459
+ "warning",
460
+ "info"
461
+ ];
462
+ w(c, `${n}.tokens.color`, l, t);
463
+ const m = {};
464
+ l.forEach((s) => {
465
+ const u = F(
466
+ c[s],
467
+ `${n}.tokens.color.${s}`,
468
+ 120,
469
+ t
470
+ );
471
+ u !== void 0 && (m[s] = u);
472
+ }), i.color = m;
473
+ }
474
+ if (a.typography !== void 0) {
475
+ const c = A(
476
+ a.typography,
477
+ `${n}.tokens.typography`,
478
+ t
479
+ );
480
+ w(
481
+ c,
482
+ `${n}.tokens.typography`,
483
+ ["fontFamily", "monoFontFamily"],
484
+ t
485
+ );
486
+ const l = F(
487
+ c.fontFamily,
488
+ `${n}.tokens.typography.fontFamily`,
489
+ 500,
490
+ t,
491
+ { allowEmpty: !0 }
492
+ ), m = F(
493
+ c.monoFontFamily,
494
+ `${n}.tokens.typography.monoFontFamily`,
495
+ 500,
496
+ t,
497
+ { allowEmpty: !0 }
498
+ );
499
+ i.typography = {
500
+ ...l !== void 0 ? { fontFamily: l } : {},
501
+ ...m !== void 0 ? { monoFontFamily: m } : {}
502
+ };
503
+ }
504
+ o.tokens = i;
505
+ }
506
+ if (r.components !== void 0) {
507
+ const a = A(
508
+ r.components,
509
+ `${n}.components`,
510
+ t
511
+ );
512
+ if (w(a, `${n}.components`, ["chart"], t), a.chart !== void 0) {
513
+ const i = A(
514
+ a.chart,
515
+ `${n}.components.chart`,
516
+ t
517
+ );
518
+ w(i, `${n}.components.chart`, ["palette"], t);
519
+ let c;
520
+ i.palette !== void 0 && (Array.isArray(i.palette) ? i.palette.length > 20 ? t.push({
521
+ field: `${n}.components.chart.palette`,
522
+ message: "Expected 20 colors or fewer."
523
+ }) : c = i.palette.map(
524
+ (l, m) => F(
525
+ l,
526
+ `${n}.components.chart.palette.${m}`,
527
+ 120,
528
+ t
529
+ )
530
+ ).filter((l) => l !== void 0) : t.push({
531
+ field: `${n}.components.chart.palette`,
532
+ message: "Expected an array."
533
+ })), o.components = {
534
+ chart: c ? { palette: c } : {}
535
+ };
536
+ }
537
+ }
538
+ return o;
539
+ }
540
+ function ht(e, n) {
541
+ const t = "presentation.appearance", r = A(e, t, n);
542
+ w(r, t, ["version", "schemes"], n);
543
+ const o = {};
544
+ if (r.version !== void 0 && (typeof r.version != "number" || !Number.isFinite(r.version) ? n.push({ field: `${t}.version`, message: "Expected a number." }) : o.version = r.version), r.schemes !== void 0) {
545
+ const a = A(r.schemes, `${t}.schemes`, n);
546
+ w(a, `${t}.schemes`, ["light", "dark"], n), o.schemes = {
547
+ ...a.light !== void 0 ? {
548
+ light: ce(
549
+ a.light,
550
+ `${t}.schemes.light`,
551
+ n
552
+ )
553
+ } : {},
554
+ ...a.dark !== void 0 ? {
555
+ dark: ce(
556
+ a.dark,
557
+ `${t}.schemes.dark`,
558
+ n
559
+ )
560
+ } : {}
561
+ };
562
+ }
563
+ return o;
564
+ }
565
+ function yt(e, n) {
566
+ const t = "presentation.brandOverrides", r = A(e, t, n);
567
+ w(r, t, ["brandName", "logoUrl", "link"], n);
568
+ const o = F(
569
+ r.brandName,
570
+ `${t}.brandName`,
571
+ 200,
572
+ n
573
+ ), a = ee(r.logoUrl, `${t}.logoUrl`, n), i = F(r.link, `${t}.link`, 120, n);
574
+ return {
575
+ ...o !== void 0 ? { brandName: o } : {},
576
+ ...a !== void 0 ? { logoUrl: a } : {},
577
+ ...i !== void 0 ? { link: i } : {}
578
+ };
579
+ }
580
+ function gt(e, n) {
581
+ const t = "presentation.fragments", r = A(e, t, n), o = [
582
+ "preHeaderText",
583
+ "headerBannerHtml",
584
+ "signatureHtml",
585
+ "footerHtml",
586
+ "disclaimerHtml",
587
+ "unsubscribeUrl"
588
+ ];
589
+ w(r, t, o, n);
590
+ const a = {};
591
+ return o.forEach((i) => {
592
+ const c = i === "unsubscribeUrl" ? ee(r[i], `${t}.${i}`, n) : F(
593
+ r[i],
594
+ `${t}.${i}`,
595
+ i === "preHeaderText" ? 200 : 5e3,
596
+ n,
597
+ { trim: i === "preHeaderText" }
598
+ );
599
+ c !== void 0 && (a[i] = c);
600
+ }), a;
601
+ }
602
+ function bt(e) {
603
+ const n = [], t = {};
604
+ if (e.appearance !== void 0 && (t.appearance = ht(e.appearance, n)), e.brandOverrides !== void 0 && (t.brandOverrides = yt(e.brandOverrides, n)), e.fragments !== void 0 && (t.fragments = gt(e.fragments, n)), e.viewUrl !== void 0) {
605
+ const r = ee(e.viewUrl, "presentation.viewUrl", n);
606
+ r !== void 0 && (t.viewUrl = r);
607
+ }
608
+ return { value: t, issues: n };
609
+ }
610
+ const P = [
611
+ "SUN",
612
+ "MON",
613
+ "TUE",
614
+ "WED",
615
+ "THU",
616
+ "FRI",
617
+ "SAT"
618
+ ], me = new Map(
619
+ P.map((e, n) => [e, n])
620
+ ), z = [1, 2, 3, 4, 5], fe = [1, 2, 3, 6, 12], ue = {
621
+ 1: "first",
622
+ 2: "second",
623
+ 3: "third",
624
+ 4: "fourth",
625
+ [-1]: "last"
626
+ }, Xn = {
627
+ frequency: "weekly",
628
+ hour: 9,
629
+ minute: 0,
630
+ weekdays: [1]
631
+ }, S = { ok: !1, issue: "Choose a supported schedule." };
632
+ function It(e) {
633
+ if (typeof e != "string" || e.length === 0 || e !== e.trim() || /^(?:(?:UTC|GMT)[+-]|[+-]\d{2}:\d{2}$)/.test(e))
634
+ return !1;
635
+ try {
636
+ return new Intl.DateTimeFormat("en-US", { timeZone: e }).format(), !0;
637
+ } catch {
638
+ return !1;
639
+ }
640
+ }
641
+ function vt(e) {
642
+ return Number.isInteger(e.minute) && e.minute >= 0 && e.minute <= 59 && Number.isInteger(e.hour) && e.hour >= 0 && e.hour <= 23;
643
+ }
644
+ function pe(e) {
645
+ if (e.length === 0) return null;
646
+ const n = [...e].sort((t, r) => t - r);
647
+ return n.some(
648
+ (t, r) => !Number.isInteger(t) || t < 0 || t > 6 || r > 0 && t === n[r - 1]
649
+ ) ? null : n;
650
+ }
651
+ function he(e) {
652
+ const t = [...e.filter((o) => o !== "last")].sort((o, a) => o - a);
653
+ if (t.some(
654
+ (o, a) => !Number.isInteger(o) || o < 1 || o > 31 || a > 0 && o === t[a - 1]
655
+ ) || e.filter((o) => o === "last").length > 1)
656
+ return null;
657
+ const r = e.includes("last") ? [...t, "last"] : t;
658
+ return r.length > 0 ? r : null;
659
+ }
660
+ function R(e, n) {
661
+ const t = [];
662
+ for (let r = 0; r < 12 / e; r += 1)
663
+ t.push((n + r * e) % 12);
664
+ return t.sort((r, o) => r - o);
665
+ }
666
+ function Et(e, n) {
667
+ return e === 1 ? "*" : R(e, n).map((t) => t + 1).join(",");
668
+ }
669
+ function ye(e, n) {
670
+ return e.every((t) => wt(t, n));
671
+ }
672
+ function Zn(e) {
673
+ if (!vt(e))
674
+ throw new Error("Choose a valid schedule time.");
675
+ const n = `${e.minute} ${e.hour}`;
676
+ switch (e.frequency) {
677
+ case "daily":
678
+ return e.weekdaysOnly ? `${n} * * ${z.map((t) => P[t]).join(",")}` : `${n} * * *`;
679
+ case "weekly": {
680
+ const t = pe(e.weekdays);
681
+ if (!t) throw new Error("Choose at least one weekday.");
682
+ return `${n} * * ${t.map((r) => P[r]).join(",")}`;
683
+ }
684
+ case "monthly": {
685
+ if (!fe.includes(e.interval) || !Number.isInteger(e.startMonth) || e.startMonth < 0 || e.startMonth >= e.interval)
686
+ throw new Error("Choose a valid month cycle.");
687
+ const t = Et(e.interval, e.startMonth);
688
+ if (e.on.type === "days") {
689
+ const i = he(e.on.days);
690
+ if (!i) throw new Error("Choose at least one day of the month.");
691
+ const c = R(e.interval, e.startMonth);
692
+ if (!ye(i, c))
693
+ throw new Error("Choose a day that occurs in the chosen months.");
694
+ const l = i.map((m) => m === "last" ? "L" : String(m)).join(",");
695
+ return `${n} ${l} ${t} *`;
696
+ }
697
+ const { ordinal: r, weekday: o } = e.on;
698
+ if (!Number.isInteger(o) || o < 0 || o > 6 || !(r in ue))
699
+ throw new Error("Choose a valid weekday.");
700
+ const a = P[o];
701
+ return `${n} * ${t} ${r === -1 ? `${a}L` : `${a}#${r}`}`;
702
+ }
703
+ }
704
+ }
705
+ function $t(e) {
706
+ if (e === "*") return { interval: 1, startMonth: 0 };
707
+ const n = e.split(",");
708
+ if (n.some((i) => !/^([1-9]|1[0-2])$/.test(i))) return null;
709
+ const t = n.map((i) => Number(i) - 1), r = 12 / t.length;
710
+ if (!fe.includes(r))
711
+ return null;
712
+ const o = t[0], a = R(
713
+ r,
714
+ o
715
+ );
716
+ return o >= r || a.length !== t.length || a.some((i, c) => i !== t[c]) ? null : { interval: r, startMonth: o };
717
+ }
718
+ function Ct(e) {
719
+ const n = e.split(",");
720
+ if (n.some((o) => !/^(L|[1-9]|[12]\d|3[01])$/.test(o))) return null;
721
+ const t = n.map(
722
+ (o) => o === "L" ? "last" : Number(o)
723
+ ), r = he(t);
724
+ return !r || r.some((o, a) => o !== t[a]) ? null : r;
725
+ }
726
+ function xt(e) {
727
+ const n = /^([A-Z]{3})(?:#([1-4])|(L))$/.exec(e);
728
+ if (!n) return null;
729
+ const t = me.get(n[1]);
730
+ return t === void 0 ? null : {
731
+ weekday: t,
732
+ ordinal: n[3] ? -1 : Number(n[2])
733
+ };
734
+ }
735
+ function ge(e) {
736
+ if (typeof e != "string" || e.length === 0 || e !== e.trim() || e.includes(" "))
737
+ return S;
738
+ const n = e.split(" ");
739
+ if (n.length !== 5) return S;
740
+ const [t, r, o, a, i] = n;
741
+ if (!/^(0|[1-9]\d?)$/.test(t) || !/^(0|[1-9]\d?)$/.test(r))
742
+ return S;
743
+ const c = Number(t), l = Number(r);
744
+ if (c > 59 || l > 23) return S;
745
+ if (a === "*" && o === "*" && i === "*")
746
+ return {
747
+ ok: !0,
748
+ value: { frequency: "daily", hour: l, minute: c, weekdaysOnly: !1 }
749
+ };
750
+ if (a === "*" && o === "*" && !i.includes("#") && !i.endsWith("L")) {
751
+ const u = i.split(",").map((E) => me.get(E));
752
+ if (u.some((E) => E === void 0)) return S;
753
+ const h = u, g = pe(h);
754
+ return !g || g.some((E, x) => E !== h[x]) ? S : g.length === z.length && g.every((E, x) => E === z[x]) ? {
755
+ ok: !0,
756
+ value: { frequency: "daily", hour: l, minute: c, weekdaysOnly: !0 }
757
+ } : {
758
+ ok: !0,
759
+ value: { frequency: "weekly", hour: l, minute: c, weekdays: g }
760
+ };
761
+ }
762
+ const m = $t(a);
763
+ if (!m) return S;
764
+ if (o !== "*" && i === "*") {
765
+ const s = Ct(o), u = R(m.interval, m.startMonth);
766
+ return !s || !ye(s, u) ? S : {
767
+ ok: !0,
768
+ value: {
769
+ frequency: "monthly",
770
+ hour: l,
771
+ minute: c,
772
+ ...m,
773
+ on: { type: "days", days: s }
774
+ }
775
+ };
776
+ }
777
+ if (o === "*" && i !== "*") {
778
+ const s = xt(i);
779
+ return s ? {
780
+ ok: !0,
781
+ value: {
782
+ frequency: "monthly",
783
+ hour: l,
784
+ minute: c,
785
+ ...m,
786
+ on: { type: "weekday", ...s }
787
+ }
788
+ } : S;
789
+ }
790
+ return S;
791
+ }
792
+ function Tt(e, n, t) {
793
+ return new Intl.DateTimeFormat(t, {
794
+ hour: "numeric",
795
+ minute: "2-digit",
796
+ timeZone: "UTC"
797
+ }).format(new Date(Date.UTC(2020, 0, 1, e, n)));
798
+ }
799
+ function St(e, n) {
800
+ var t;
801
+ if (e === "UTC") return "UTC";
802
+ try {
803
+ return ((t = new Intl.DateTimeFormat(n, {
804
+ timeZone: e,
805
+ timeZoneName: "longGeneric"
806
+ }).formatToParts(new Date(Date.UTC(2020, 0, 1))).find((o) => o.type === "timeZoneName")) == null ? void 0 : t.value) ?? e;
807
+ } catch {
808
+ return null;
809
+ }
810
+ }
811
+ function le(e) {
812
+ return e.length <= 1 ? e.join("") : e.length === 2 ? `${e[0]} and ${e[1]}` : `${e.slice(0, -1).join(", ")} and ${e[e.length - 1]}`;
813
+ }
814
+ function kt(e) {
815
+ const n = e % 100;
816
+ return n >= 11 && n <= 13 ? `${e}th` : `${e}${["th", "st", "nd", "rd"][e % 10] ?? "th"}`;
817
+ }
818
+ function At(e, n, t) {
819
+ const r = (a, i) => new Intl.DateTimeFormat(t, { month: i, timeZone: "UTC" }).format(
820
+ new Date(Date.UTC(2020, a, 1))
821
+ );
822
+ if (e === 1) return "every month";
823
+ if (e === 12) return `${r(n, "long")} each year`;
824
+ const o = R(e, n).map((a) => r(a, "short")).join(", ");
825
+ return e === 3 ? `each quarter (${o})` : `every ${e} months (${o})`;
826
+ }
827
+ function Yn(e, n, t = "en-US") {
828
+ const r = ge(e);
829
+ if (!r.ok) return null;
830
+ try {
831
+ const o = r.value, a = St(n, t);
832
+ if (!a) return null;
833
+ const i = `at ${Tt(o.hour, o.minute, t)} ${a}`, c = (l) => new Intl.DateTimeFormat(t, {
834
+ weekday: "long",
835
+ timeZone: "UTC"
836
+ }).format(new Date(Date.UTC(2023, 0, 1 + l)));
837
+ switch (o.frequency) {
838
+ case "daily":
839
+ return o.weekdaysOnly ? `Every weekday, Monday to Friday, ${i}` : `Every day ${i}`;
840
+ case "weekly":
841
+ return `Every ${le(o.weekdays.map(c))} ${i}`;
842
+ case "monthly": {
843
+ const l = At(o.interval, o.startMonth, t);
844
+ if (o.on.type === "weekday")
845
+ return `On the ${ue[o.on.ordinal]} ${c(o.on.weekday)} of ${l} ${i}`;
846
+ const m = o.on.days.map(
847
+ (s) => s === "last" ? "last day" : kt(s)
848
+ );
849
+ return `On the ${le(m)} of ${l} ${i}`;
850
+ }
851
+ }
852
+ } catch {
853
+ return null;
854
+ }
855
+ }
856
+ const be = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
857
+ function wt(e, n) {
858
+ return e === "last" || n.some((t) => e <= be[t]);
859
+ }
860
+ function Jn(e) {
861
+ if (e.frequency !== "monthly" || e.on.type !== "days") return null;
862
+ const n = e.on.days.filter((o) => o !== "last");
863
+ if (n.length === 0) return null;
864
+ const t = Math.max(...n), r = R(e.interval, e.startMonth).filter(
865
+ (o) => t > (o === 1 ? 28 : be[o])
866
+ );
867
+ return r.length > 0 ? { day: t, months: r } : null;
868
+ }
869
+ function Dt(e, n) {
870
+ return new Date(Date.UTC(e, n + 1, 0)).getUTCDate();
871
+ }
872
+ function _t(e, n, t, r) {
873
+ const o = new Date(Date.UTC(n, t, r)).getUTCDay();
874
+ switch (e.frequency) {
875
+ case "daily":
876
+ return !e.weekdaysOnly || z.includes(o);
877
+ case "weekly":
878
+ return e.weekdays.includes(o);
879
+ case "monthly": {
880
+ if (!R(e.interval, e.startMonth).includes(t))
881
+ return !1;
882
+ const a = Dt(n, t);
883
+ return e.on.type === "days" ? e.on.days.some(
884
+ (i) => i === "last" ? r === a : i === r
885
+ ) : o !== e.on.weekday ? !1 : e.on.ordinal === -1 ? r + 7 > a : Math.ceil(r / 7) === e.on.ordinal;
886
+ }
887
+ }
888
+ }
889
+ function Qn(e, n, t, r) {
890
+ const o = ge(e);
891
+ if (!o.ok || !It(n)) return [];
892
+ const a = o.value, i = new Intl.DateTimeFormat("en-US", {
893
+ timeZone: n,
894
+ hourCycle: "h23",
895
+ year: "numeric",
896
+ month: "numeric",
897
+ day: "numeric",
898
+ hour: "numeric",
899
+ minute: "numeric"
900
+ }).formatToParts(t), c = (s) => {
901
+ var u;
902
+ return Number((u = i.find((h) => h.type === s)) == null ? void 0 : u.value);
903
+ }, l = new Date(Date.UTC(c("year"), c("month") - 1, c("day")));
904
+ c("hour") * 60 + c("minute") >= a.hour * 60 + a.minute && l.setUTCDate(l.getUTCDate() + 1);
905
+ const m = [];
906
+ for (let s = 0; s < 366 * 4 * (r + 1) && m.length < r; s += 1)
907
+ _t(a, l.getUTCFullYear(), l.getUTCMonth(), l.getUTCDate()) && m.push(l.toISOString().slice(0, 10)), l.setUTCDate(l.getUTCDate() + 1);
908
+ return m;
909
+ }
910
+ const Ot = Object.freeze([
911
+ "PDF_ROW_LIMIT_EXCEEDED",
912
+ "PDF_SIZE_LIMIT_EXCEEDED",
913
+ "TABLE_COMPLETENESS_UNVERIFIED",
914
+ "CARD_QUERY_FAILED",
915
+ "RENDER_NOT_READY",
916
+ "RENDER_TIMED_OUT",
917
+ "EXPORT_JOB_FAILED",
918
+ "ATTACHMENT_UNAVAILABLE",
919
+ // A Table or Detail Table export the server starts (Excel exports Phase 6).
920
+ "EXCEL_LIMIT_EXCEEDED",
921
+ "EXPORT_ROW_LIMIT_EXCEEDED",
922
+ "EXPORT_COUNT_UNAVAILABLE",
923
+ "EXPORT_NO_ROWS"
924
+ ]), Ft = new Set(Ot);
925
+ function Nt(e) {
926
+ return typeof e == "string" && Ft.has(e);
927
+ }
928
+ function Rt(e) {
929
+ if (!e || typeof e != "object" || Array.isArray(e)) return null;
930
+ const n = e;
931
+ return typeof n.index != "number" || !Number.isInteger(n.index) || n.index < 0 || typeof n.title != "string" || n.format !== "pdf" && n.format !== "csv" && n.format !== "xlsx" || !Nt(n.code) || typeof n.reason != "string" || typeof n.diagnostic != "string" ? null : {
932
+ index: n.index,
933
+ title: n.title,
934
+ format: n.format,
935
+ code: n.code,
936
+ reason: n.reason,
937
+ diagnostic: n.diagnostic
938
+ };
939
+ }
940
+ function er(e) {
941
+ if (!e || typeof e != "object" || Array.isArray(e)) return [];
942
+ const n = e.omittedAttachments;
943
+ return Array.isArray(n) ? n.flatMap((t) => {
944
+ const r = Rt(t);
945
+ return r ? [r] : [];
946
+ }) : [];
947
+ }
948
+ function tr(e) {
949
+ return e != null && e.role ? e.type === "tenant" ? e.role === "POWER_USER" : ["AUTHOR", "ADMIN", "SUPER_ADMIN"].includes(e.role) : !1;
950
+ }
951
+ function nr(e) {
952
+ return e.canCreate ? [
953
+ ...e.scheduledReportAvailable ? ["scheduled_report"] : [],
954
+ ...e.analyticalBriefingsEnabled ? ["analytical_briefing"] : []
955
+ ] : [];
956
+ }
957
+ function Bt(e) {
958
+ const n = (e == null ? void 0 : e.channels) ?? [];
959
+ return n.length === 1 && n[0] === "EMAIL";
960
+ }
961
+ function Mt(e) {
962
+ return e.body.type === "generated_analysis" ? "Analytical briefing" : e.body.type === "custom_message" && e.attachments.length > 0 && Bt(e.deliveryConfig) ? e.scheduleExpr ? "Scheduled report" : "On-demand report" : "Plain briefing";
963
+ }
964
+ function rr(e) {
965
+ const n = Mt(e), t = n === "Scheduled report" || n === "On-demand report" ? "report" : "briefing";
966
+ return {
967
+ typeLabel: n,
968
+ noun: t,
969
+ pluralNoun: t === "report" ? "reports" : "briefings"
970
+ };
971
+ }
972
+ const Z = "BRIEFING", Lt = ["markdown", "html"], Y = ["markdown"], H = 20, f = {
973
+ name: 500,
974
+ description: 2e3,
975
+ instruction: 5e4,
976
+ customMessage: 5e4,
977
+ contentTitle: 500,
978
+ contentSummary: 2e4,
979
+ contentText: 5e3,
980
+ contentSql: 5e4,
981
+ contentItem: 2e3,
982
+ contentCell: 500,
983
+ attachmentTitle: 500,
984
+ presentationAudience: 1e3,
985
+ presentationTone: 500,
986
+ presentationFormat: 2e3,
987
+ id: 500
988
+ }, C = {
989
+ maxBlocks: 50,
990
+ maxTableRows: 100,
991
+ maxTableColumns: 20,
992
+ maxTableCellCharacters: f.contentCell,
993
+ maxParagraphCharacters: f.contentText,
994
+ maxFindingCharacters: f.contentText,
995
+ maxListItems: 100,
996
+ // A kpi_grid is rendered as a 2-up tile arrangement in emails. Cap at 8 so
997
+ // the visual stays at most 4 rows (4 columns wide on desktop would force
998
+ // tiny tiles in narrow client panels; 2-up was the chosen layout).
999
+ maxKpiTiles: 8
1000
+ };
1001
+ function Ut(e) {
1002
+ if (e === null || typeof e != "object" || Array.isArray(e))
1003
+ return !1;
1004
+ const n = e;
1005
+ if (typeof n.value != "number" || !Number.isFinite(n.value))
1006
+ return !1;
1007
+ const t = n.target;
1008
+ if (t === null || typeof t != "object" || Array.isArray(t))
1009
+ return !1;
1010
+ const r = t;
1011
+ return (r.kind === "metric" && typeof r.metricId == "string" && !!r.metricId.trim() || r.kind === "column" && typeof r.columnKey == "string" && !!r.columnKey.trim() || r.kind === "matrix_measure" && typeof r.measureId == "string" && !!r.measureId.trim()) && de(n.format).ok;
1012
+ }
1013
+ function Pt(e) {
1014
+ return e == null ? "" : Ut(e) ? Fe(e.value, e.format) : String(e);
1015
+ }
1016
+ function or(e) {
1017
+ return [e.delta, e.percentChange].filter(
1018
+ (n) => n != null
1019
+ ).map(Pt).filter(Boolean).join(" / ");
1020
+ }
1021
+ const Ie = new Set(Lt), Vt = /* @__PURE__ */ new Set([
1022
+ "EMAIL",
1023
+ "WEBHOOK",
1024
+ "SLACK",
1025
+ "IN_APP",
1026
+ "TELEGRAM"
1027
+ ]), G = {
1028
+ maxToolCalls: { min: 1, max: 100 },
1029
+ maxPlanningIterations: { min: 1, max: 10 },
1030
+ maxRows: { min: 1, max: 1e5 },
1031
+ timeoutMs: { min: 1e3, max: 30 * 6e4 }
1032
+ }, zt = /* @__PURE__ */ new Set([
1033
+ "letter",
1034
+ "legal",
1035
+ "a4",
1036
+ "a3",
1037
+ "tabloid"
1038
+ ]), jt = /* @__PURE__ */ new Set([
1039
+ "portrait",
1040
+ "landscape"
1041
+ ]), qt = /* @__PURE__ */ new Set([",", ";", " "]), Kt = new Set(Ue), Ht = /* @__PURE__ */ new Set([
1042
+ "current",
1043
+ "all"
1044
+ ]), Gt = /* @__PURE__ */ new Set([
1045
+ "concise",
1046
+ "balanced",
1047
+ "detailed"
1048
+ ]), Wt = /* @__PURE__ */ new Set([
1049
+ "info",
1050
+ "positive",
1051
+ "warning",
1052
+ "critical"
1053
+ ]), Xt = /* @__PURE__ */ new Set([
1054
+ "text",
1055
+ "number",
1056
+ "currency",
1057
+ "percent",
1058
+ "date",
1059
+ "boolean"
1060
+ ]), Zt = /* @__PURE__ */ new Set([
1061
+ "left",
1062
+ "center",
1063
+ "right"
1064
+ ]), Yt = [
1065
+ "matrix",
1066
+ "pageSize",
1067
+ "orientation",
1068
+ "includeFilters",
1069
+ "includeTimestamp",
1070
+ "delimiter",
1071
+ "csvEncoding",
1072
+ "includeHeaders",
1073
+ "useFormattedValues",
1074
+ "sheetSelection",
1075
+ "currentSheetId",
1076
+ "currentSheetName",
1077
+ "filterValues",
1078
+ "inlineFilterValues",
1079
+ "sheetFilterValues",
1080
+ // Saved by earlier versions and still accepted, then dropped: each run
1081
+ // builds its filter line from `filterValues` at its own time.
1082
+ "filterLine",
1083
+ "controlValues",
1084
+ "controlDefinitions",
1085
+ "cardControlDefinitions",
1086
+ "controlBindings",
1087
+ "tablePreferences",
1088
+ "dashboardInputExecutionSnapshot",
1089
+ "printInputCapture",
1090
+ "selectedSheetId",
1091
+ "cardType",
1092
+ "allowDownload",
1093
+ "theme"
1094
+ ];
1095
+ class j extends Error {
1096
+ constructor(t) {
1097
+ super(t.map((r) => `${r.field}: ${r.message}`).join("; "));
1098
+ L(this, "issues");
1099
+ this.name = "BriefingContractError", this.issues = t;
1100
+ }
1101
+ }
1102
+ function ve(e) {
1103
+ return typeof e == "object" && e !== null && !Array.isArray(e);
1104
+ }
1105
+ function d(e, n, t) {
1106
+ e.push({ field: n, message: t });
1107
+ }
1108
+ function v(e, n, t) {
1109
+ return ve(e) ? e : (d(t, n, "Expected an object."), {});
1110
+ }
1111
+ function p(e, n, t, r) {
1112
+ const o = new Set(t);
1113
+ Object.keys(e).forEach((a) => {
1114
+ o.has(a) || d(
1115
+ r,
1116
+ n ? `${n}.${a}` : a,
1117
+ `Unexpected field "${a}".`
1118
+ );
1119
+ });
1120
+ }
1121
+ function b(e, n, t, r) {
1122
+ if (typeof e != "string")
1123
+ return d(r, n, "Expected a string."), "";
1124
+ const o = e.trim();
1125
+ return o ? (o.length > t && d(r, n, `Must be ${t} characters or fewer.`), o) : (d(r, n, "Required value cannot be empty."), "");
1126
+ }
1127
+ function I(e, n, t, r) {
1128
+ if (e == null)
1129
+ return;
1130
+ if (typeof e != "string") {
1131
+ d(r, n, "Expected a string.");
1132
+ return;
1133
+ }
1134
+ const o = e.trim();
1135
+ if (o)
1136
+ return o.length > t && d(r, n, `Must be ${t} characters or fewer.`), o;
1137
+ }
1138
+ function Jt(e, n, t, r) {
1139
+ if (typeof e != "string")
1140
+ return d(r, n, "Expected a string."), "";
1141
+ const o = e.trim();
1142
+ return o.length > t && d(r, n, `Must be ${t} characters or fewer.`), o;
1143
+ }
1144
+ function Qt(e, n, t) {
1145
+ if (e != null) {
1146
+ if (!Number.isInteger(e) || Number(e) < 0) {
1147
+ d(t, n, "Expected a non-negative integer.");
1148
+ return;
1149
+ }
1150
+ return Number(e);
1151
+ }
1152
+ }
1153
+ function k(e, n, t, r = {}) {
1154
+ if (e == null)
1155
+ return r.required ? (d(t, n, "Expected at least one evidence id."), []) : void 0;
1156
+ if (!Array.isArray(e))
1157
+ return d(t, n, "Expected an array."), r.required ? [] : void 0;
1158
+ const o = [];
1159
+ return e.forEach((a, i) => {
1160
+ const c = b(
1161
+ a,
1162
+ `${n}.${i}`,
1163
+ f.id,
1164
+ t
1165
+ );
1166
+ c && !o.includes(c) && o.push(c);
1167
+ }), r.required && o.length === 0 && d(t, n, "Expected at least one evidence id."), o.length > 0 || r.required ? o : void 0;
1168
+ }
1169
+ function N(e, n, t, r) {
1170
+ return e == null ? n : typeof e != "boolean" ? (d(r, t, "Expected a boolean."), n) : e;
1171
+ }
1172
+ function en(e, n) {
1173
+ return e == null ? "ACTIVE" : e === "ACTIVE" || e === "PAUSED" || e === "DISABLED" ? e : (d(n, "status", "Expected ACTIVE, PAUSED, or DISABLED."), "ACTIVE");
1174
+ }
1175
+ function tn(e) {
1176
+ return e.includes("@") && e.includes(".") && !e.includes(" ");
1177
+ }
1178
+ function Ee(e, n) {
1179
+ if (e == null)
1180
+ return { type: "project" };
1181
+ const t = v(e, "source", n), r = t.type;
1182
+ return r === "project" ? (p(t, "source", ["type"], n), { type: "project" }) : r === "dashboard" ? (p(t, "source", ["type", "dashboardId"], n), {
1183
+ type: "dashboard",
1184
+ dashboardId: b(
1185
+ t.dashboardId,
1186
+ "source.dashboardId",
1187
+ f.id,
1188
+ n
1189
+ )
1190
+ }) : (d(n, "source.type", "Expected project or dashboard."), { type: "project" });
1191
+ }
1192
+ function $e(e, n) {
1193
+ const t = v(e, "body", n), r = t.type;
1194
+ return r === "generated_analysis" ? (p(t, "body", ["type", "instruction"], n), {
1195
+ type: "generated_analysis",
1196
+ instruction: b(
1197
+ t.instruction,
1198
+ "body.instruction",
1199
+ f.instruction,
1200
+ n
1201
+ )
1202
+ }) : r === "custom_message" ? (p(t, "body", ["type", "message"], n), {
1203
+ type: "custom_message",
1204
+ message: Jt(
1205
+ t.message,
1206
+ "body.message",
1207
+ f.customMessage,
1208
+ n
1209
+ )
1210
+ }) : r === "none" ? (p(t, "body", ["type"], n), { type: "none" }) : (d(
1211
+ n,
1212
+ "body.type",
1213
+ "Expected generated_analysis, custom_message, or none."
1214
+ ), { type: "none" });
1215
+ }
1216
+ function nn(e, n) {
1217
+ if (e == null)
1218
+ return [...Y];
1219
+ if (!Array.isArray(e))
1220
+ return d(n, "presentation.artifactFormats", "Expected an array."), [...Y];
1221
+ if (e.length === 0)
1222
+ return d(
1223
+ n,
1224
+ "presentation.artifactFormats",
1225
+ "Choose at least one artifact format."
1226
+ ), [];
1227
+ const t = [];
1228
+ return e.forEach((r, o) => {
1229
+ if (typeof r != "string" || !Ie.has(r)) {
1230
+ d(
1231
+ n,
1232
+ `presentation.artifactFormats.${o}`,
1233
+ "Expected markdown or html."
1234
+ );
1235
+ return;
1236
+ }
1237
+ t.includes(r) || t.push(r);
1238
+ }), t;
1239
+ }
1240
+ function Ce(e, n) {
1241
+ if (e == null)
1242
+ return {
1243
+ artifactFormats: [...Y],
1244
+ includeEvidence: !0,
1245
+ includeSql: !0
1246
+ };
1247
+ const t = v(e, "presentation", n);
1248
+ p(
1249
+ t,
1250
+ "presentation",
1251
+ [
1252
+ "artifactFormats",
1253
+ "includeEvidence",
1254
+ "includeSql",
1255
+ "audience",
1256
+ "tone",
1257
+ "format",
1258
+ "appearance",
1259
+ "brandOverrides",
1260
+ "fragments",
1261
+ "viewUrl"
1262
+ ],
1263
+ n
1264
+ );
1265
+ const r = {
1266
+ artifactFormats: nn(t.artifactFormats, n),
1267
+ includeEvidence: N(
1268
+ t.includeEvidence,
1269
+ !0,
1270
+ "presentation.includeEvidence",
1271
+ n
1272
+ ),
1273
+ includeSql: N(
1274
+ t.includeSql,
1275
+ !0,
1276
+ "presentation.includeSql",
1277
+ n
1278
+ )
1279
+ }, o = I(
1280
+ t.audience,
1281
+ "presentation.audience",
1282
+ f.presentationAudience,
1283
+ n
1284
+ ), a = I(
1285
+ t.tone,
1286
+ "presentation.tone",
1287
+ f.presentationTone,
1288
+ n
1289
+ ), i = I(
1290
+ t.format,
1291
+ "presentation.format",
1292
+ f.presentationFormat,
1293
+ n
1294
+ );
1295
+ o && (r.audience = o), a && (r.tone = a), i && (r.format = i);
1296
+ const c = bt(t);
1297
+ return c.issues.forEach((l) => d(n, l.field, l.message)), Object.assign(r, c.value), r;
1298
+ }
1299
+ function rn(e, n, t) {
1300
+ return Array.isArray(e) ? (e.length === 0 && d(t, n, "Expected at least one item."), e.length > C.maxListItems && d(
1301
+ t,
1302
+ n,
1303
+ `Must have ${C.maxListItems} items or fewer.`
1304
+ ), e.slice(0, C.maxListItems).map(
1305
+ (r, o) => b(
1306
+ r,
1307
+ `${n}.${o}`,
1308
+ f.contentItem,
1309
+ t
1310
+ )
1311
+ ).filter(Boolean)) : (d(t, n, "Expected an array."), []);
1312
+ }
1313
+ function on(e, n, t) {
1314
+ const r = v(e, n, t);
1315
+ if (r.kind === "metric")
1316
+ return p(r, n, ["kind", "metricId"], t), {
1317
+ kind: "metric",
1318
+ metricId: b(
1319
+ r.metricId,
1320
+ `${n}.metricId`,
1321
+ f.id,
1322
+ t
1323
+ )
1324
+ };
1325
+ if (r.kind === "column")
1326
+ return p(r, n, ["kind", "columnKey"], t), {
1327
+ kind: "column",
1328
+ columnKey: b(
1329
+ r.columnKey,
1330
+ `${n}.columnKey`,
1331
+ f.id,
1332
+ t
1333
+ )
1334
+ };
1335
+ if (r.kind === "matrix_measure")
1336
+ return p(r, n, ["kind", "measureId"], t), {
1337
+ kind: "matrix_measure",
1338
+ measureId: b(
1339
+ r.measureId,
1340
+ `${n}.measureId`,
1341
+ f.id,
1342
+ t
1343
+ )
1344
+ };
1345
+ d(
1346
+ t,
1347
+ `${n}.kind`,
1348
+ "Expected metric, column, or matrix_measure."
1349
+ );
1350
+ }
1351
+ function xe(e, n, t) {
1352
+ if (e === null || typeof e != "object" || Array.isArray(e))
1353
+ return;
1354
+ const r = v(e, n, t);
1355
+ if (!Object.prototype.hasOwnProperty.call(r, "target") && !Object.prototype.hasOwnProperty.call(r, "format"))
1356
+ return;
1357
+ p(r, n, ["value", "target", "format"], t), (typeof r.value != "number" || !Number.isFinite(r.value)) && d(t, `${n}.value`, "Expected a finite number.");
1358
+ const o = on(
1359
+ r.target,
1360
+ `${n}.target`,
1361
+ t
1362
+ ), a = de(r.format);
1363
+ if (a.ok || a.issues.forEach(
1364
+ (i) => d(
1365
+ t,
1366
+ i.path === "$" ? `${n}.format` : `${n}.format.${i.path}`,
1367
+ i.message
1368
+ )
1369
+ ), !(typeof r.value != "number" || !Number.isFinite(r.value) || !o || !a.ok))
1370
+ return { value: r.value, target: o, format: a.value };
1371
+ }
1372
+ function O(e, n, t) {
1373
+ if (typeof e == "string")
1374
+ return e;
1375
+ if (typeof e == "number") {
1376
+ if (!Number.isFinite(e)) {
1377
+ d(t, n, "Expected a finite number.");
1378
+ return;
1379
+ }
1380
+ return e;
1381
+ }
1382
+ const r = xe(e, n, t);
1383
+ if (r) return r;
1384
+ d(
1385
+ t,
1386
+ n,
1387
+ "Expected a string, number, or structured numeric value."
1388
+ );
1389
+ }
1390
+ function an(e, n, t) {
1391
+ if (e === null || typeof e == "string" || typeof e == "number" || typeof e == "boolean")
1392
+ return typeof e == "string" && e.length > f.contentCell ? (d(
1393
+ t,
1394
+ n,
1395
+ `Must be ${f.contentCell} characters or fewer.`
1396
+ ), e.slice(0, f.contentCell)) : typeof e == "number" && !Number.isFinite(e) ? (d(t, n, "Expected a finite number."), null) : e;
1397
+ const r = xe(e, n, t);
1398
+ return r || (d(
1399
+ t,
1400
+ n,
1401
+ "Expected a string, number, boolean, structured numeric value, or null."
1402
+ ), null);
1403
+ }
1404
+ function cn(e, n, t) {
1405
+ if (!Array.isArray(e))
1406
+ return d(t, n, "Expected an array."), [];
1407
+ e.length === 0 && d(t, n, "Expected at least one column."), e.length > C.maxTableColumns && d(
1408
+ t,
1409
+ n,
1410
+ `Must have ${C.maxTableColumns} columns or fewer.`
1411
+ );
1412
+ const r = /* @__PURE__ */ new Set();
1413
+ return e.slice(0, C.maxTableColumns).map((o, a) => {
1414
+ const i = `${n}.${a}`, c = v(o, i, t);
1415
+ p(c, i, ["key", "label", "kind", "align"], t);
1416
+ const l = b(
1417
+ c.key,
1418
+ `${i}.key`,
1419
+ f.id,
1420
+ t
1421
+ );
1422
+ l && (r.has(l) && d(t, `${i}.key`, "Column key must be unique."), r.add(l));
1423
+ const m = b(
1424
+ c.label,
1425
+ `${i}.label`,
1426
+ f.contentTitle,
1427
+ t
1428
+ ), s = D(
1429
+ c.kind,
1430
+ `${i}.kind`,
1431
+ Xt,
1432
+ "text, number, currency, percent, date, or boolean",
1433
+ t
1434
+ ), u = D(
1435
+ c.align,
1436
+ `${i}.align`,
1437
+ Zt,
1438
+ "left, center, or right",
1439
+ t
1440
+ );
1441
+ return {
1442
+ key: l,
1443
+ label: m,
1444
+ ...s ? { kind: s } : {},
1445
+ ...u ? { align: u } : {}
1446
+ };
1447
+ });
1448
+ }
1449
+ function ln(e, n, t, r) {
1450
+ if (!Array.isArray(e))
1451
+ return d(r, n, "Expected an array."), [];
1452
+ e.length > C.maxTableRows && d(
1453
+ r,
1454
+ n,
1455
+ `Must have ${C.maxTableRows} rows or fewer.`
1456
+ );
1457
+ const o = new Set(t.map((a) => a.key).filter(Boolean));
1458
+ return e.slice(0, C.maxTableRows).map((a, i) => {
1459
+ const c = `${n}.${i}`, l = v(a, c, r);
1460
+ return Object.keys(l).forEach((m) => {
1461
+ o.has(m) || d(r, `${c}.${m}`, `Unexpected table cell "${m}".`);
1462
+ }), Object.fromEntries(
1463
+ t.map((m) => [
1464
+ m.key,
1465
+ an(l[m.key] ?? null, `${c}.${m.key}`, r)
1466
+ ])
1467
+ );
1468
+ });
1469
+ }
1470
+ function dn(e, n, t) {
1471
+ const r = `content.blocks.${n}`, o = v(e, r, t), a = o.type;
1472
+ if (a === "heading") {
1473
+ p(o, r, ["type", "text", "level", "evidenceIds"], t);
1474
+ const i = o.level === void 0 || o.level === null ? void 0 : o.level === 2 || o.level === 3 ? o.level : void 0;
1475
+ o.level !== void 0 && o.level !== null && i === void 0 && d(t, `${r}.level`, "Expected 2 or 3.");
1476
+ const c = k(o.evidenceIds, `${r}.evidenceIds`, t);
1477
+ return {
1478
+ type: "heading",
1479
+ text: b(
1480
+ o.text,
1481
+ `${r}.text`,
1482
+ f.contentTitle,
1483
+ t
1484
+ ),
1485
+ ...i ? { level: i } : {},
1486
+ ...c ? { evidenceIds: c } : {}
1487
+ };
1488
+ }
1489
+ if (a === "paragraph") {
1490
+ p(o, r, ["type", "text", "evidenceIds"], t);
1491
+ const i = k(o.evidenceIds, `${r}.evidenceIds`, t);
1492
+ return {
1493
+ type: "paragraph",
1494
+ text: b(
1495
+ o.text,
1496
+ `${r}.text`,
1497
+ f.contentText,
1498
+ t
1499
+ ),
1500
+ ...i ? { evidenceIds: i } : {}
1501
+ };
1502
+ }
1503
+ if (a === "finding") {
1504
+ p(o, r, ["type", "title", "text", "severity", "evidenceIds"], t);
1505
+ const i = I(
1506
+ o.title,
1507
+ `${r}.title`,
1508
+ f.contentTitle,
1509
+ t
1510
+ ), c = D(
1511
+ o.severity,
1512
+ `${r}.severity`,
1513
+ Wt,
1514
+ "info, positive, warning, or critical",
1515
+ t
1516
+ );
1517
+ return {
1518
+ type: "finding",
1519
+ ...i ? { title: i } : {},
1520
+ text: b(
1521
+ o.text,
1522
+ `${r}.text`,
1523
+ f.contentText,
1524
+ t
1525
+ ),
1526
+ ...c ? { severity: c } : {},
1527
+ evidenceIds: k(o.evidenceIds, `${r}.evidenceIds`, t, {
1528
+ required: !0
1529
+ }) ?? []
1530
+ };
1531
+ }
1532
+ if (a === "bullets" || a === "actions" || a === "limitations") {
1533
+ p(o, r, ["type", "title", "items", "evidenceIds"], t);
1534
+ const i = I(
1535
+ o.title,
1536
+ `${r}.title`,
1537
+ f.contentTitle,
1538
+ t
1539
+ ), c = k(o.evidenceIds, `${r}.evidenceIds`, t);
1540
+ return {
1541
+ type: a,
1542
+ ...i ? { title: i } : {},
1543
+ items: rn(o.items, `${r}.items`, t),
1544
+ ...c ? { evidenceIds: c } : {}
1545
+ };
1546
+ }
1547
+ if (a === "metric") {
1548
+ p(
1549
+ o,
1550
+ r,
1551
+ [
1552
+ "type",
1553
+ "label",
1554
+ "value",
1555
+ "previousValue",
1556
+ "delta",
1557
+ "percentChange",
1558
+ "unit",
1559
+ "evidenceIds"
1560
+ ],
1561
+ t
1562
+ );
1563
+ const i = O(o.value, `${r}.value`, t) ?? "";
1564
+ i === "" && d(
1565
+ t,
1566
+ `${r}.value`,
1567
+ "Expected a non-empty string, number, or structured numeric value."
1568
+ );
1569
+ const c = o.previousValue === void 0 || o.previousValue === null ? o.previousValue : O(
1570
+ o.previousValue,
1571
+ `${r}.previousValue`,
1572
+ t
1573
+ ), l = o.delta === void 0 || o.delta === null ? o.delta : O(
1574
+ o.delta,
1575
+ `${r}.delta`,
1576
+ t
1577
+ ), m = o.percentChange === void 0 || o.percentChange === null ? o.percentChange : O(
1578
+ o.percentChange,
1579
+ `${r}.percentChange`,
1580
+ t
1581
+ ), s = I(
1582
+ o.unit,
1583
+ `${r}.unit`,
1584
+ f.contentTitle,
1585
+ t
1586
+ ), u = k(o.evidenceIds, `${r}.evidenceIds`, t);
1587
+ return {
1588
+ type: "metric",
1589
+ label: b(
1590
+ o.label,
1591
+ `${r}.label`,
1592
+ f.contentTitle,
1593
+ t
1594
+ ),
1595
+ value: i,
1596
+ ...c !== void 0 ? { previousValue: c } : {},
1597
+ ...l !== void 0 ? { delta: l } : {},
1598
+ ...m !== void 0 ? { percentChange: m } : {},
1599
+ ...s ? { unit: s } : {},
1600
+ ...u ? { evidenceIds: u } : {}
1601
+ };
1602
+ }
1603
+ if (a === "kpi_grid") {
1604
+ p(o, r, ["type", "title", "tiles", "evidenceIds"], t);
1605
+ const i = I(
1606
+ o.title,
1607
+ `${r}.title`,
1608
+ f.contentTitle,
1609
+ t
1610
+ ), c = Array.isArray(o.tiles) ? o.tiles : [];
1611
+ Array.isArray(o.tiles) || d(t, `${r}.tiles`, "Expected an array."), c.length === 0 && d(t, `${r}.tiles`, "Expected at least one tile."), c.length > C.maxKpiTiles && d(
1612
+ t,
1613
+ `${r}.tiles`,
1614
+ `Must have ${C.maxKpiTiles} tiles or fewer.`
1615
+ );
1616
+ const l = c.slice(0, C.maxKpiTiles).map((s, u) => {
1617
+ const h = `${r}.tiles.${u}`, g = v(s, h, t);
1618
+ p(
1619
+ g,
1620
+ h,
1621
+ [
1622
+ "label",
1623
+ "value",
1624
+ "previousValue",
1625
+ "delta",
1626
+ "percentChange",
1627
+ "unit",
1628
+ "evidenceIds"
1629
+ ],
1630
+ t
1631
+ );
1632
+ const E = O(
1633
+ g.value,
1634
+ `${h}.value`,
1635
+ t
1636
+ ) ?? "";
1637
+ E === "" && d(
1638
+ t,
1639
+ `${h}.value`,
1640
+ "Expected a non-empty string, number, or structured numeric value."
1641
+ );
1642
+ const x = g.previousValue === void 0 || g.previousValue === null ? g.previousValue : O(
1643
+ g.previousValue,
1644
+ `${h}.previousValue`,
1645
+ t
1646
+ ), _ = g.delta === void 0 || g.delta === null ? g.delta : O(
1647
+ g.delta,
1648
+ `${h}.delta`,
1649
+ t
1650
+ ), M = g.percentChange === void 0 || g.percentChange === null ? g.percentChange : O(
1651
+ g.percentChange,
1652
+ `${h}.percentChange`,
1653
+ t
1654
+ ), $ = I(
1655
+ g.unit,
1656
+ `${h}.unit`,
1657
+ f.contentTitle,
1658
+ t
1659
+ ), T = k(
1660
+ g.evidenceIds,
1661
+ `${h}.evidenceIds`,
1662
+ t
1663
+ );
1664
+ return {
1665
+ label: b(
1666
+ g.label,
1667
+ `${h}.label`,
1668
+ f.contentTitle,
1669
+ t
1670
+ ),
1671
+ value: E,
1672
+ ...x !== void 0 ? { previousValue: x } : {},
1673
+ ..._ !== void 0 ? { delta: _ } : {},
1674
+ ...M !== void 0 ? { percentChange: M } : {},
1675
+ ...$ ? { unit: $ } : {},
1676
+ ...T ? { evidenceIds: T } : {}
1677
+ };
1678
+ }), m = k(
1679
+ o.evidenceIds,
1680
+ `${r}.evidenceIds`,
1681
+ t
1682
+ );
1683
+ return {
1684
+ type: "kpi_grid",
1685
+ ...i ? { title: i } : {},
1686
+ tiles: l,
1687
+ ...m ? { evidenceIds: m } : {}
1688
+ };
1689
+ }
1690
+ if (a === "progress") {
1691
+ p(o, r, ["type", "label", "value", "detail", "evidenceIds"], t);
1692
+ const i = typeof o.value == "number" && Number.isFinite(o.value) ? o.value : 0;
1693
+ (typeof o.value != "number" || !Number.isFinite(o.value)) && d(t, `${r}.value`, "Expected a finite number.");
1694
+ const c = I(
1695
+ o.detail,
1696
+ `${r}.detail`,
1697
+ f.contentText,
1698
+ t
1699
+ ), l = k(o.evidenceIds, `${r}.evidenceIds`, t);
1700
+ return {
1701
+ type: "progress",
1702
+ label: b(
1703
+ o.label,
1704
+ `${r}.label`,
1705
+ f.contentTitle,
1706
+ t
1707
+ ),
1708
+ value: i,
1709
+ ...c ? { detail: c } : {},
1710
+ ...l ? { evidenceIds: l } : {}
1711
+ };
1712
+ }
1713
+ if (a === "table") {
1714
+ p(
1715
+ o,
1716
+ r,
1717
+ ["type", "id", "title", "columns", "rows", "caption", "totalRows", "evidenceIds"],
1718
+ t
1719
+ );
1720
+ const i = cn(o.columns, `${r}.columns`, t), c = I(
1721
+ o.title,
1722
+ `${r}.title`,
1723
+ f.contentTitle,
1724
+ t
1725
+ ), l = I(
1726
+ o.id,
1727
+ `${r}.id`,
1728
+ f.id,
1729
+ t
1730
+ ), m = I(
1731
+ o.caption,
1732
+ `${r}.caption`,
1733
+ f.contentItem,
1734
+ t
1735
+ ), s = Qt(
1736
+ o.totalRows,
1737
+ `${r}.totalRows`,
1738
+ t
1739
+ ), u = k(o.evidenceIds, `${r}.evidenceIds`, t);
1740
+ return {
1741
+ type: "table",
1742
+ ...l ? { id: l } : {},
1743
+ ...c ? { title: c } : {},
1744
+ columns: i,
1745
+ rows: ln(o.rows, `${r}.rows`, i, t),
1746
+ ...m ? { caption: m } : {},
1747
+ ...s !== void 0 ? { totalRows: s } : {},
1748
+ ...u ? { evidenceIds: u } : {}
1749
+ };
1750
+ }
1751
+ if (a === "evidence_appendix") {
1752
+ p(o, r, ["type", "title", "evidenceIds"], t);
1753
+ const i = I(
1754
+ o.title,
1755
+ `${r}.title`,
1756
+ f.contentTitle,
1757
+ t
1758
+ );
1759
+ return {
1760
+ type: "evidence_appendix",
1761
+ ...i ? { title: i } : {},
1762
+ evidenceIds: k(o.evidenceIds, `${r}.evidenceIds`, t, {
1763
+ required: !0
1764
+ }) ?? []
1765
+ };
1766
+ }
1767
+ if (a === "sql") {
1768
+ p(o, r, ["type", "title", "sql", "evidenceIds"], t);
1769
+ const i = I(
1770
+ o.title,
1771
+ `${r}.title`,
1772
+ f.contentTitle,
1773
+ t
1774
+ ), c = b(
1775
+ o.sql,
1776
+ `${r}.sql`,
1777
+ f.contentSql,
1778
+ t
1779
+ ), l = k(o.evidenceIds, `${r}.evidenceIds`, t);
1780
+ return {
1781
+ type: "sql",
1782
+ ...i ? { title: i } : {},
1783
+ sql: c,
1784
+ ...l ? { evidenceIds: l } : {}
1785
+ };
1786
+ }
1787
+ return d(
1788
+ t,
1789
+ `${r}.type`,
1790
+ "Expected heading, paragraph, finding, bullets, metric, kpi_grid, progress, table, actions, limitations, sql, or evidence_appendix."
1791
+ ), {
1792
+ type: "paragraph",
1793
+ text: ""
1794
+ };
1795
+ }
1796
+ function sn(e) {
1797
+ const n = [], t = v(e, "content", n);
1798
+ p(t, "content", ["version", "title", "summary", "blocks"], n), t.version !== 1 && d(n, "content.version", "Expected version 1.");
1799
+ const r = I(
1800
+ t.title,
1801
+ "content.title",
1802
+ f.contentTitle,
1803
+ n
1804
+ ), o = I(
1805
+ t.summary,
1806
+ "content.summary",
1807
+ f.contentSummary,
1808
+ n
1809
+ );
1810
+ Array.isArray(t.blocks) || d(n, "content.blocks", "Expected an array.");
1811
+ const a = Array.isArray(t.blocks) ? t.blocks : [];
1812
+ a.length === 0 && d(n, "content.blocks", "Expected at least one block."), a.length > C.maxBlocks && d(
1813
+ n,
1814
+ "content.blocks",
1815
+ `Must have ${C.maxBlocks} blocks or fewer.`
1816
+ );
1817
+ const i = a.slice(0, C.maxBlocks).map((c, l) => dn(c, l, n));
1818
+ return te(n), {
1819
+ version: 1,
1820
+ ...r ? { title: r } : {},
1821
+ ...o ? { summary: o } : {},
1822
+ blocks: i
1823
+ };
1824
+ }
1825
+ function ar(e) {
1826
+ try {
1827
+ return {
1828
+ valid: !0,
1829
+ value: sn(e),
1830
+ issues: []
1831
+ };
1832
+ } catch (n) {
1833
+ if (n instanceof j)
1834
+ return { valid: !1, issues: n.issues };
1835
+ throw n;
1836
+ }
1837
+ }
1838
+ function V(e, n, t, r) {
1839
+ return typeof e == "string" && t.includes(e) ? e : (d(r, n, `Expected ${t.join(" or ")}.`), t[0]);
1840
+ }
1841
+ function D(e, n, t, r, o) {
1842
+ if (e != null) {
1843
+ if (typeof e == "string" && t.has(e))
1844
+ return e;
1845
+ d(o, n, `Expected ${r}.`);
1846
+ }
1847
+ }
1848
+ function mn(e, n, t) {
1849
+ if (e != null) {
1850
+ if (!Array.isArray(e)) {
1851
+ d(t, n, "Expected an array.");
1852
+ return;
1853
+ }
1854
+ return e;
1855
+ }
1856
+ }
1857
+ function fn(e, n, t) {
1858
+ if (e != null) {
1859
+ if (!ve(e)) {
1860
+ d(t, n, "Expected an object.");
1861
+ return;
1862
+ }
1863
+ return e;
1864
+ }
1865
+ }
1866
+ function un(e, n, t) {
1867
+ if (e == null)
1868
+ return;
1869
+ const r = v(e, n, t);
1870
+ p(r, n, Yt, t);
1871
+ const o = {};
1872
+ if (r.matrix !== void 0) {
1873
+ const s = v(r.matrix, `${n}.matrix`, t);
1874
+ p(s, `${n}.matrix`, ["config", "content"], t);
1875
+ const u = Re.safeParse(s.config);
1876
+ u.success || d(t, `${n}.matrix.config`, "Expected a valid Matrix definition.");
1877
+ const h = D(
1878
+ s.content,
1879
+ `${n}.matrix.content`,
1880
+ /* @__PURE__ */ new Set(["current", "all", "flat"]),
1881
+ "current, all, or flat",
1882
+ t
1883
+ );
1884
+ h || d(t, `${n}.matrix.content`, "Choose Matrix export content."), u.success && h && (o.matrix = { config: u.data, content: h });
1885
+ }
1886
+ const a = D(
1887
+ r.pageSize,
1888
+ `${n}.pageSize`,
1889
+ zt,
1890
+ "letter, legal, a4, a3, or tabloid",
1891
+ t
1892
+ ), i = D(
1893
+ r.orientation,
1894
+ `${n}.orientation`,
1895
+ jt,
1896
+ "portrait or landscape",
1897
+ t
1898
+ ), c = D(
1899
+ r.delimiter,
1900
+ `${n}.delimiter`,
1901
+ qt,
1902
+ "comma, semicolon, or tab",
1903
+ t
1904
+ ), l = D(
1905
+ r.csvEncoding,
1906
+ `${n}.csvEncoding`,
1907
+ Kt,
1908
+ "utf-8-bom or utf-8",
1909
+ t
1910
+ ), m = D(
1911
+ r.sheetSelection,
1912
+ `${n}.sheetSelection`,
1913
+ Ht,
1914
+ "current or all",
1915
+ t
1916
+ );
1917
+ a && (o.pageSize = a), i && (o.orientation = i), c && (o.delimiter = c), l && (o.csvEncoding = l), m && (o.sheetSelection = m);
1918
+ for (const s of [
1919
+ "includeFilters",
1920
+ "includeTimestamp",
1921
+ "includeHeaders",
1922
+ "useFormattedValues",
1923
+ "allowDownload"
1924
+ ])
1925
+ if (!(r[s] === void 0 || r[s] === null)) {
1926
+ if (typeof r[s] != "boolean") {
1927
+ d(t, `${n}.${s}`, "Expected a boolean.");
1928
+ continue;
1929
+ }
1930
+ o[s] = r[s];
1931
+ }
1932
+ for (const s of [
1933
+ "currentSheetId",
1934
+ "currentSheetName",
1935
+ "selectedSheetId",
1936
+ "cardType",
1937
+ "theme"
1938
+ ]) {
1939
+ const u = I(
1940
+ r[s],
1941
+ `${n}.${s}`,
1942
+ f.id,
1943
+ t
1944
+ );
1945
+ u && (o[s] = u);
1946
+ }
1947
+ for (const s of [
1948
+ "filterValues",
1949
+ "inlineFilterValues",
1950
+ "sheetFilterValues",
1951
+ "controlDefinitions",
1952
+ "cardControlDefinitions",
1953
+ "controlBindings"
1954
+ ]) {
1955
+ const u = mn(r[s], `${n}.${s}`, t);
1956
+ u && (o[s] = u);
1957
+ }
1958
+ for (const s of [
1959
+ "controlValues",
1960
+ "tablePreferences",
1961
+ "dashboardInputExecutionSnapshot",
1962
+ "printInputCapture"
1963
+ ]) {
1964
+ const u = fn(r[s], `${n}.${s}`, t);
1965
+ u && (o[s] = u);
1966
+ }
1967
+ return Object.keys(o).length > 0 ? o : void 0;
1968
+ }
1969
+ function W(e, n, t, r) {
1970
+ const o = I(
1971
+ n,
1972
+ t,
1973
+ f.attachmentTitle,
1974
+ r
1975
+ );
1976
+ return o && (e.title = o), e;
1977
+ }
1978
+ function X(e, n, t, r) {
1979
+ const o = un(n, t, r);
1980
+ return o != null && o.printInputCapture && e.type !== "dashboard" && d(
1981
+ r,
1982
+ `${t}.printInputCapture`,
1983
+ "Only a full dashboard attachment can carry printInputCapture."
1984
+ ), o && (e.settings = o), e;
1985
+ }
1986
+ function pn(e, n, t) {
1987
+ const r = `attachments.${n}`, o = v(e, r, t), a = o.type;
1988
+ if (a === "dashboard") {
1989
+ p(
1990
+ o,
1991
+ r,
1992
+ ["type", "dashboardId", "format", "title", "settings"],
1993
+ t
1994
+ );
1995
+ const i = W(
1996
+ {
1997
+ type: "dashboard",
1998
+ dashboardId: b(
1999
+ o.dashboardId,
2000
+ `${r}.dashboardId`,
2001
+ f.id,
2002
+ t
2003
+ ),
2004
+ format: V(o.format, `${r}.format`, ["pdf"], t)
2005
+ },
2006
+ o.title,
2007
+ `${r}.title`,
2008
+ t
2009
+ );
2010
+ return X(i, o.settings, `${r}.settings`, t);
2011
+ }
2012
+ if (a === "dashboard_sheet" || a === "document_sheet") {
2013
+ p(
2014
+ o,
2015
+ r,
2016
+ ["type", "dashboardId", "sheetId", "format", "title", "settings"],
2017
+ t
2018
+ );
2019
+ const i = W(
2020
+ {
2021
+ type: a,
2022
+ dashboardId: b(
2023
+ o.dashboardId,
2024
+ `${r}.dashboardId`,
2025
+ f.id,
2026
+ t
2027
+ ),
2028
+ sheetId: b(
2029
+ o.sheetId,
2030
+ `${r}.sheetId`,
2031
+ f.id,
2032
+ t
2033
+ ),
2034
+ format: V(o.format, `${r}.format`, ["pdf"], t)
2035
+ },
2036
+ o.title,
2037
+ `${r}.title`,
2038
+ t
2039
+ );
2040
+ return X(i, o.settings, `${r}.settings`, t);
2041
+ }
2042
+ if (a === "card") {
2043
+ p(
2044
+ o,
2045
+ r,
2046
+ ["type", "dashboardId", "cardId", "format", "title", "settings"],
2047
+ t
2048
+ );
2049
+ const i = W(
2050
+ {
2051
+ type: "card",
2052
+ dashboardId: b(
2053
+ o.dashboardId,
2054
+ `${r}.dashboardId`,
2055
+ f.id,
2056
+ t
2057
+ ),
2058
+ cardId: b(
2059
+ o.cardId,
2060
+ `${r}.cardId`,
2061
+ f.id,
2062
+ t
2063
+ ),
2064
+ format: V(
2065
+ o.format,
2066
+ `${r}.format`,
2067
+ ["csv", "pdf", "xlsx"],
2068
+ t
2069
+ )
2070
+ },
2071
+ o.title,
2072
+ `${r}.title`,
2073
+ t
2074
+ );
2075
+ return X(i, o.settings, `${r}.settings`, t);
2076
+ }
2077
+ return d(
2078
+ t,
2079
+ `${r}.type`,
2080
+ "Expected dashboard, dashboard_sheet, document_sheet, or card."
2081
+ ), { type: "dashboard", dashboardId: "", format: "pdf" };
2082
+ }
2083
+ function hn(e) {
2084
+ switch (e.type) {
2085
+ case "dashboard":
2086
+ return `${e.type}:${e.dashboardId}:${e.format}`;
2087
+ case "dashboard_sheet":
2088
+ case "document_sheet":
2089
+ return `${e.type}:${e.dashboardId}:${e.sheetId}:${e.format}`;
2090
+ case "card":
2091
+ return `${e.type}:${e.dashboardId}:${e.cardId}:${e.format}`;
2092
+ }
2093
+ }
2094
+ function Te(e, n) {
2095
+ if (e == null)
2096
+ return [];
2097
+ if (!Array.isArray(e))
2098
+ return d(n, "attachments", "Expected an array."), [];
2099
+ e.length > H && d(
2100
+ n,
2101
+ "attachments",
2102
+ `Choose ${H} attachments or fewer.`
2103
+ );
2104
+ const t = e.slice(0, H).map((o, a) => pn(o, a, n)), r = /* @__PURE__ */ new Set();
2105
+ return t.forEach((o, a) => {
2106
+ var c, l, m;
2107
+ (c = o.settings) != null && c.matrix && (o.type !== "card" || o.settings.cardType !== "matrixTable" || o.settings.matrix.content === "flat" && o.format === "pdf") && d(n, `attachments.${a}.settings.matrix`, "Matrix settings require a matrixTable card attachment; flat content requires CSV or Excel."), o.format === "xlsx" && !((l = o.settings) != null && l.matrix) && !Q((m = o.settings) == null ? void 0 : m.cardType) && d(n, `attachments.${a}.format`, "Excel attachments require a Table, Detail Table or Matrix card.");
2108
+ const i = hn(o);
2109
+ r.has(i) && d(n, `attachments.${a}`, "Duplicate attachment."), r.add(i);
2110
+ }), t;
2111
+ }
2112
+ function Se(e, n) {
2113
+ if (e == null)
2114
+ return;
2115
+ const t = v(e, "limits", n);
2116
+ p(t, "limits", Object.keys(G), n);
2117
+ const r = {};
2118
+ return Object.keys(G).forEach((o) => {
2119
+ const a = t[o];
2120
+ if (a == null)
2121
+ return;
2122
+ const i = G[o];
2123
+ if (typeof a != "number" || !Number.isInteger(a) || a < i.min || a > i.max) {
2124
+ d(
2125
+ n,
2126
+ `limits.${o}`,
2127
+ `Expected an integer between ${i.min} and ${i.max}.`
2128
+ );
2129
+ return;
2130
+ }
2131
+ r[o] = a;
2132
+ }), Object.keys(r).length > 0 ? r : void 0;
2133
+ }
2134
+ function te(e) {
2135
+ if (e.length > 0)
2136
+ throw new j(e);
2137
+ }
2138
+ function ke(e, n, t) {
2139
+ !(e.type === "generated_analysis" || e.type === "custom_message" && !!e.message.trim()) && n.length === 0 && d(
2140
+ t,
2141
+ "body",
2142
+ "Add briefing instructions, a custom message, or at least one attachment."
2143
+ );
2144
+ }
2145
+ function yn(e, n, t) {
2146
+ e == null || e.forEach((r, o) => {
2147
+ const a = `${t}.${o}.scope`, i = r.scope.attachmentIndex;
2148
+ if (i === void 0)
2149
+ throw new B(
2150
+ `${a}.attachmentIndex must identify the attachment that owns this presentation entry.`
2151
+ );
2152
+ const c = n[i];
2153
+ if (!c)
2154
+ throw new B(
2155
+ `${a}.attachmentIndex must identify an existing attachment.`
2156
+ );
2157
+ if (r.scope.dashboardId !== c.dashboardId)
2158
+ throw new B(
2159
+ `${a}.dashboardId must match the dashboard selected by the referenced attachment.`
2160
+ );
2161
+ if (c.type === "card" && r.scope.cardId !== c.cardId)
2162
+ throw new B(
2163
+ `${a}.cardId must match the card selected by the referenced attachment.`
2164
+ );
2165
+ });
2166
+ }
2167
+ function Ae(e) {
2168
+ const n = [], t = v(e, "jobConfig", n);
2169
+ p(
2170
+ t,
2171
+ "jobConfig",
2172
+ [
2173
+ "kind",
2174
+ "presentationExecutionSnapshot",
2175
+ "source",
2176
+ "body",
2177
+ "attachments",
2178
+ "presentation",
2179
+ "limits"
2180
+ ],
2181
+ n
2182
+ ), t.kind !== Z && d(n, "kind", "Expected BRIEFING.");
2183
+ let r;
2184
+ try {
2185
+ r = Pe(
2186
+ t.presentationExecutionSnapshot
2187
+ );
2188
+ } catch (m) {
2189
+ if (m instanceof B)
2190
+ throw m;
2191
+ d(
2192
+ n,
2193
+ "jobConfig.presentationExecutionSnapshot",
2194
+ m instanceof Error ? m.message : "Invalid presentation snapshot."
2195
+ );
2196
+ }
2197
+ const o = Ee(t.source, n), a = $e(t.body, n), i = Te(t.attachments, n), c = Ce(t.presentation, n), l = Se(t.limits, n);
2198
+ return ke(a, i, n), yn(
2199
+ r == null ? void 0 : r.resolvedFormats,
2200
+ i,
2201
+ "jobConfig.presentationExecutionSnapshot.resolvedFormats"
2202
+ ), te(n), {
2203
+ kind: Z,
2204
+ presentationExecutionSnapshot: r,
2205
+ source: o,
2206
+ body: a,
2207
+ attachments: i,
2208
+ presentation: c,
2209
+ ...l ? { limits: l } : {}
2210
+ };
2211
+ }
2212
+ function ir(e) {
2213
+ return Ae({
2214
+ ...e,
2215
+ kind: Z
2216
+ });
2217
+ }
2218
+ function ne(e, n, t, r = "deliveryConfig.recipients") {
2219
+ const o = `${r}.${n}`, a = v(e, o, t), i = a.type;
2220
+ if (i === "email") {
2221
+ p(a, o, ["type", "address", "name"], t);
2222
+ const c = b(
2223
+ a.address,
2224
+ `${o}.address`,
2225
+ f.id,
2226
+ t
2227
+ ), l = I(
2228
+ a.name,
2229
+ `${o}.name`,
2230
+ f.attachmentTitle,
2231
+ t
2232
+ );
2233
+ return c && !tn(c) && d(t, `${o}.address`, "Email address is invalid."), {
2234
+ type: "email",
2235
+ address: c,
2236
+ ...l ? { name: l } : {}
2237
+ };
2238
+ }
2239
+ return i === "user" ? (p(a, o, ["type", "userId"], t), {
2240
+ type: "user",
2241
+ userId: b(
2242
+ a.userId,
2243
+ `${o}.userId`,
2244
+ f.id,
2245
+ t
2246
+ )
2247
+ }) : i === "tenant_user" ? (p(a, o, ["type", "tenantUserId"], t), {
2248
+ type: "tenant_user",
2249
+ tenantUserId: b(
2250
+ a.tenantUserId,
2251
+ `${o}.tenantUserId`,
2252
+ f.id,
2253
+ t
2254
+ )
2255
+ }) : i === "group" ? (p(a, o, ["type", "groupId"], t), {
2256
+ type: "group",
2257
+ groupId: b(
2258
+ a.groupId,
2259
+ `${o}.groupId`,
2260
+ f.id,
2261
+ t
2262
+ )
2263
+ }) : (d(
2264
+ t,
2265
+ `${o}.type`,
2266
+ "Expected email, user, tenant_user, or group."
2267
+ ), { type: "email", address: "" });
2268
+ }
2269
+ function gn(e, n) {
2270
+ return e == null ? [] : Array.isArray(e) ? e.map(
2271
+ (t, r) => ne(t, r, n)
2272
+ ) : (d(n, "deliveryConfig.recipients", "Expected an array."), []);
2273
+ }
2274
+ function bn(e, n) {
2275
+ if (!Array.isArray(e))
2276
+ return d(n, "deliveryConfig.channels", "Expected an array."), [];
2277
+ const t = [];
2278
+ return e.forEach((r, o) => {
2279
+ if (!we(r)) {
2280
+ d(
2281
+ n,
2282
+ `deliveryConfig.channels.${o}`,
2283
+ "Expected EMAIL, WEBHOOK, SLACK, IN_APP, or TELEGRAM."
2284
+ );
2285
+ return;
2286
+ }
2287
+ t.includes(r) || t.push(r);
2288
+ }), t;
2289
+ }
2290
+ function In(e, n, t) {
2291
+ if (e == null)
2292
+ return;
2293
+ const r = v(e, n, t), o = {};
2294
+ return Object.entries(r).forEach(([a, i]) => {
2295
+ if (typeof i != "string") {
2296
+ d(t, `${n}.${a}`, "Expected a string.");
2297
+ return;
2298
+ }
2299
+ o[a] = i.trim();
2300
+ }), Object.keys(o).length > 0 ? o : void 0;
2301
+ }
2302
+ function vn(e, n, t) {
2303
+ if (e == null)
2304
+ return;
2305
+ const r = v(e, n, t);
2306
+ p(
2307
+ r,
2308
+ n,
2309
+ ["url", "method", "headers", "secretEncrypted"],
2310
+ t
2311
+ );
2312
+ const o = r.method === void 0 || r.method === null ? void 0 : V(r.method, `${n}.method`, ["POST", "PUT"], t), a = In(r.headers, `${n}.headers`, t), i = I(
2313
+ r.secretEncrypted,
2314
+ `${n}.secretEncrypted`,
2315
+ 2e3,
2316
+ t
2317
+ );
2318
+ return {
2319
+ url: b(r.url, `${n}.url`, 2e3, t),
2320
+ ...o ? { method: o } : {},
2321
+ ...a ? { headers: a } : {},
2322
+ ...i ? { secretEncrypted: i } : {}
2323
+ };
2324
+ }
2325
+ function En(e, n, t) {
2326
+ const r = v(e, n, t), o = r.type;
2327
+ if (o === "channel") {
2328
+ p(
2329
+ r,
2330
+ n,
2331
+ ["type", "channelId", "channelName", "isPrivate"],
2332
+ t
2333
+ );
2334
+ const a = I(
2335
+ r.channelName,
2336
+ `${n}.channelName`,
2337
+ f.attachmentTitle,
2338
+ t
2339
+ ), i = r.isPrivate === void 0 || r.isPrivate === null ? void 0 : N(
2340
+ r.isPrivate,
2341
+ !1,
2342
+ `${n}.isPrivate`,
2343
+ t
2344
+ );
2345
+ return {
2346
+ type: "channel",
2347
+ channelId: b(
2348
+ r.channelId,
2349
+ `${n}.channelId`,
2350
+ f.id,
2351
+ t
2352
+ ),
2353
+ ...a ? { channelName: a } : {},
2354
+ ...i !== void 0 ? { isPrivate: i } : {}
2355
+ };
2356
+ }
2357
+ return o === "dm" ? (p(r, n, ["type", "recipient"], t), d(
2358
+ t,
2359
+ `${n}.type`,
2360
+ "Slack DM delivery is not supported in V1."
2361
+ ), {
2362
+ type: "dm",
2363
+ recipient: ne(r.recipient, 0, t, `${n}.recipient`)
2364
+ }) : (d(t, `${n}.type`, "Expected channel."), { type: "channel", channelId: "" });
2365
+ }
2366
+ function $n(e, n, t) {
2367
+ if (e == null)
2368
+ return;
2369
+ if (!Array.isArray(e)) {
2370
+ d(t, n, "Expected an array.");
2371
+ return;
2372
+ }
2373
+ const r = e.map(
2374
+ (o, a) => ne(o, a, t, n)
2375
+ );
2376
+ return r.length > 0 ? r : void 0;
2377
+ }
2378
+ function Cn(e, n, t) {
2379
+ if (e == null)
2380
+ return;
2381
+ const r = v(e, n, t);
2382
+ p(
2383
+ r,
2384
+ n,
2385
+ [
2386
+ "destination",
2387
+ "threadMentions",
2388
+ "postThreadDetail",
2389
+ "includeDashboardLink",
2390
+ "includeBriefingLink"
2391
+ ],
2392
+ t
2393
+ );
2394
+ const o = $n(
2395
+ r.threadMentions,
2396
+ `${n}.threadMentions`,
2397
+ t
2398
+ ), a = N(
2399
+ r.postThreadDetail,
2400
+ !0,
2401
+ `${n}.postThreadDetail`,
2402
+ t
2403
+ ), i = N(
2404
+ r.includeDashboardLink,
2405
+ !0,
2406
+ `${n}.includeDashboardLink`,
2407
+ t
2408
+ ), c = N(
2409
+ r.includeBriefingLink,
2410
+ !0,
2411
+ `${n}.includeBriefingLink`,
2412
+ t
2413
+ );
2414
+ return {
2415
+ destination: En(
2416
+ r.destination,
2417
+ `${n}.destination`,
2418
+ t
2419
+ ),
2420
+ ...o ? { threadMentions: o } : {},
2421
+ ...r.postThreadDetail !== void 0 ? { postThreadDetail: a } : {},
2422
+ ...r.includeDashboardLink !== void 0 ? { includeDashboardLink: i } : {},
2423
+ ...r.includeBriefingLink !== void 0 ? { includeBriefingLink: c } : {}
2424
+ };
2425
+ }
2426
+ function xn(e, n, t) {
2427
+ const r = v(e, n, t);
2428
+ p(
2429
+ r,
2430
+ n,
2431
+ [
2432
+ "subjectOverride",
2433
+ "titleOverride",
2434
+ "summaryOverride",
2435
+ "actionBlockVisible",
2436
+ "formatProfile",
2437
+ "slackConfig",
2438
+ "webhookConfig"
2439
+ ],
2440
+ t
2441
+ );
2442
+ const o = D(
2443
+ r.formatProfile,
2444
+ `${n}.formatProfile`,
2445
+ Gt,
2446
+ "concise, balanced, or detailed",
2447
+ t
2448
+ ), a = I(
2449
+ r.subjectOverride,
2450
+ `${n}.subjectOverride`,
2451
+ 500,
2452
+ t
2453
+ ), i = I(
2454
+ r.titleOverride,
2455
+ `${n}.titleOverride`,
2456
+ 500,
2457
+ t
2458
+ ), c = I(
2459
+ r.summaryOverride,
2460
+ `${n}.summaryOverride`,
2461
+ 2e3,
2462
+ t
2463
+ ), l = N(
2464
+ r.actionBlockVisible,
2465
+ !0,
2466
+ `${n}.actionBlockVisible`,
2467
+ t
2468
+ ), m = vn(
2469
+ r.webhookConfig,
2470
+ `${n}.webhookConfig`,
2471
+ t
2472
+ ), s = Cn(
2473
+ r.slackConfig,
2474
+ `${n}.slackConfig`,
2475
+ t
2476
+ );
2477
+ return {
2478
+ ...o ? { formatProfile: o } : {},
2479
+ ...a ? { subjectOverride: a } : {},
2480
+ ...i ? { titleOverride: i } : {},
2481
+ ...c ? { summaryOverride: c } : {},
2482
+ ...r.actionBlockVisible !== void 0 ? { actionBlockVisible: l } : {},
2483
+ ...s ? { slackConfig: s } : {},
2484
+ ...m ? { webhookConfig: m } : {}
2485
+ };
2486
+ }
2487
+ function Tn(e, n) {
2488
+ if (e == null)
2489
+ return;
2490
+ const t = v(e, "deliveryConfig.channelConfigs", n), r = {};
2491
+ return Object.entries(t).forEach(([o, a]) => {
2492
+ if (!we(o)) {
2493
+ d(
2494
+ n,
2495
+ `deliveryConfig.channelConfigs.${o}`,
2496
+ "Expected a supported delivery channel."
2497
+ );
2498
+ return;
2499
+ }
2500
+ r[o] = xn(
2501
+ a,
2502
+ `deliveryConfig.channelConfigs.${o}`,
2503
+ n
2504
+ );
2505
+ }), Object.keys(r).length > 0 ? r : void 0;
2506
+ }
2507
+ function Sn(e, n) {
2508
+ var l, m, s;
2509
+ if (e == null)
2510
+ return null;
2511
+ const t = v(e, "deliveryConfig", n);
2512
+ p(
2513
+ t,
2514
+ "deliveryConfig",
2515
+ ["recipients", "channels", "channelConfigs"],
2516
+ n
2517
+ );
2518
+ const r = Tn(t.channelConfigs, n), o = gn(t.recipients, n), a = bn(t.channels, n), i = ((m = (l = r == null ? void 0 : r.SLACK) == null ? void 0 : l.slackConfig) == null ? void 0 : m.destination.type) === "channel" && !!r.SLACK.slackConfig.destination.channelId.trim();
2519
+ return a.some(
2520
+ (u) => u !== "SLACK"
2521
+ ) && o.length === 0 && d(
2522
+ n,
2523
+ "deliveryConfig.recipients",
2524
+ "Add at least one recipient or remove delivery config."
2525
+ ), a.length === 0 && d(
2526
+ n,
2527
+ "deliveryConfig.channels",
2528
+ "Choose at least one delivery channel or remove delivery config."
2529
+ ), a.includes("SLACK") && !i && d(
2530
+ n,
2531
+ "deliveryConfig.channelConfigs.SLACK.slackConfig.destination.channelId",
2532
+ "Choose a Slack channel destination."
2533
+ ), !a.includes("SLACK") && ((s = r == null ? void 0 : r.SLACK) != null && s.slackConfig) && d(
2534
+ n,
2535
+ "deliveryConfig.channelConfigs.SLACK",
2536
+ "Slack config requires SLACK in deliveryConfig.channels."
2537
+ ), {
2538
+ recipients: o,
2539
+ channels: a,
2540
+ ...r ? { channelConfigs: r } : {}
2541
+ };
2542
+ }
2543
+ function re(e) {
2544
+ const n = [], t = v(e, "draft", n);
2545
+ p(
2546
+ t,
2547
+ "draft",
2548
+ [
2549
+ "name",
2550
+ "description",
2551
+ "status",
2552
+ "scheduleExpr",
2553
+ "timezone",
2554
+ "source",
2555
+ "body",
2556
+ "attachments",
2557
+ "presentation",
2558
+ "limits",
2559
+ "deliveryConfig"
2560
+ ],
2561
+ n
2562
+ );
2563
+ const r = b(
2564
+ t.name,
2565
+ "name",
2566
+ f.name,
2567
+ n
2568
+ ), o = I(
2569
+ t.description,
2570
+ "description",
2571
+ f.description,
2572
+ n
2573
+ ) ?? null, a = I(t.scheduleExpr, "scheduleExpr", 500, n) ?? null, i = I(t.timezone, "timezone", 200, n) ?? "UTC", c = en(t.status, n), l = Ee(t.source, n), m = $e(t.body, n), s = Te(t.attachments, n), u = Ce(t.presentation, n), h = Se(t.limits, n), g = Sn(t.deliveryConfig, n);
2574
+ return ke(m, s, n), te(n), {
2575
+ name: r,
2576
+ description: o,
2577
+ status: c,
2578
+ scheduleExpr: a,
2579
+ timezone: i,
2580
+ source: l,
2581
+ body: m,
2582
+ attachments: s,
2583
+ presentation: u,
2584
+ ...h ? { limits: h } : {},
2585
+ deliveryConfig: g
2586
+ };
2587
+ }
2588
+ function cr(e) {
2589
+ return re(e);
2590
+ }
2591
+ function lr(e) {
2592
+ return re(e);
2593
+ }
2594
+ function dr(e) {
2595
+ try {
2596
+ return { valid: !0, value: re(e), issues: [] };
2597
+ } catch (n) {
2598
+ if (n instanceof j)
2599
+ return { valid: !1, issues: n.issues };
2600
+ throw n;
2601
+ }
2602
+ }
2603
+ function sr(e) {
2604
+ try {
2605
+ return { valid: !0, value: Ae(e), issues: [] };
2606
+ } catch (n) {
2607
+ if (n instanceof j)
2608
+ return { valid: !1, issues: n.issues };
2609
+ throw n;
2610
+ }
2611
+ }
2612
+ function mr(e) {
2613
+ return typeof e == "string" && Ie.has(e);
2614
+ }
2615
+ function we(e) {
2616
+ return typeof e == "string" && Vt.has(e);
2617
+ }
2618
+ export {
2619
+ Mt as $,
2620
+ f as A,
2621
+ Z as B,
2622
+ C,
2623
+ Xn as D,
2624
+ Ut as E,
2625
+ Pt as F,
2626
+ or as G,
2627
+ j as H,
2628
+ sn as I,
2629
+ ar as J,
2630
+ Ae as K,
2631
+ ir as L,
2632
+ H as M,
2633
+ re as N,
2634
+ cr as O,
2635
+ lr as P,
2636
+ dr as Q,
2637
+ sr as R,
2638
+ mr as S,
2639
+ we as T,
2640
+ qn as U,
2641
+ st as V,
2642
+ Vn as W,
2643
+ dt as X,
2644
+ Q as Y,
2645
+ Ot as Z,
2646
+ Nt as _,
2647
+ nr as a,
2648
+ lt as b,
2649
+ jn as c,
2650
+ Yn as d,
2651
+ Kn as e,
2652
+ Wn as f,
2653
+ rr as g,
2654
+ Pn as h,
2655
+ zn as i,
2656
+ It as j,
2657
+ Zn as k,
2658
+ R as l,
2659
+ Jn as m,
2660
+ wt as n,
2661
+ Qn as o,
2662
+ ge as p,
2663
+ he as q,
2664
+ Bt as r,
2665
+ er as s,
2666
+ tr as t,
2667
+ mt as u,
2668
+ se as v,
2669
+ Gn as w,
2670
+ Hn as x,
2671
+ Lt as y,
2672
+ Y as z
2673
+ };