react-semaphor 0.1.449 → 0.1.454

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 (147) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +119 -112
  3. package/dist/appearance/index.cjs +1 -1
  4. package/dist/appearance/index.js +1 -1
  5. package/dist/brand-studio/index.cjs +4 -4
  6. package/dist/brand-studio/index.js +15 -13
  7. package/dist/briefings/index.cjs +1 -1
  8. package/dist/briefings/index.js +39 -2131
  9. package/dist/chunks/{analyze-result-contract-T-0Ntzys.js → analyze-result-contract-BbRJ-C06.js} +1 -1
  10. package/dist/chunks/{analyze-result-contract-BHb7sUUW.cjs → analyze-result-contract-LPDNldic.cjs} +1 -1
  11. package/dist/chunks/canonical-result-keys-BA0HCP4e.cjs +1 -0
  12. package/dist/chunks/canonical-result-keys-D6avdjpA.js +467 -0
  13. package/dist/chunks/color-CJvdlFM_.js +2162 -0
  14. package/dist/chunks/color-CyB5o13F.cjs +4 -0
  15. package/dist/chunks/{common-types-CQ6SHfLk.cjs → common-types-C57kJ59w.cjs} +1 -1
  16. package/dist/chunks/{common-types-B7Jk3Rtj.js → common-types-H51FLKB7.js} +1 -1
  17. package/dist/chunks/contracts-CoCOpd_i.js +11 -0
  18. package/dist/chunks/contracts-CtB2VONT.cjs +1 -0
  19. package/dist/chunks/dashboard-briefing-launcher-Dwj1i7lr.cjs +26 -0
  20. package/dist/chunks/{dashboard-briefing-launcher-DCHiEkLE.js → dashboard-briefing-launcher-SYroFdae.js} +86 -84
  21. package/dist/chunks/{dashboard-controls-DwRFCcHV.js → dashboard-controls-1LpeU2sz.js} +15 -13
  22. package/dist/chunks/{dashboard-controls-CaFioayc.cjs → dashboard-controls-CpFoh7-A.cjs} +1 -1
  23. package/dist/chunks/dashboard-date-comparison-definition-Ces4alFm.cjs +1 -0
  24. package/dist/chunks/{dashboard-date-comparison-definition-Ba-clViK.js → dashboard-date-comparison-definition-DC3ekV2S.js} +1 -1
  25. package/dist/chunks/{dashboard-json-WoILbfTe.js → dashboard-json-D-T-sQxU.js} +25 -23
  26. package/dist/chunks/dashboard-json-DwSQopc_.cjs +1 -0
  27. package/dist/chunks/edit-dashboard-visual-BEmoQAET.cjs +172 -0
  28. package/dist/chunks/{edit-dashboard-visual-ciFhxqaI.js → edit-dashboard-visual-DqxUq4Bs.js} +6925 -6947
  29. package/dist/chunks/editor-action-buttons-18r2xwei.cjs +16 -0
  30. package/dist/chunks/{editor-action-buttons-BPo_45pM.js → editor-action-buttons-B2l3WIRC.js} +41 -39
  31. package/dist/chunks/format-types-CFHQoIuk.js +1350 -0
  32. package/dist/chunks/format-types-PSZZ7hG8.cjs +1 -0
  33. package/dist/chunks/index-Bn5wlkHt.cjs +4 -0
  34. package/dist/chunks/index-ByFbacH7.cjs +1 -0
  35. package/dist/chunks/index-CACdoqu3.js +318 -0
  36. package/dist/chunks/index-CLB_NGZ8.cjs +1392 -0
  37. package/dist/chunks/index-Ca784dpx.js +3714 -0
  38. package/dist/chunks/{index-CPuawpXJ.js → index-DAoS4BNU.js} +48514 -48484
  39. package/dist/chunks/index-DSKR3nKn.js +421 -0
  40. package/dist/chunks/index-F25jnH0p.cjs +1 -0
  41. package/dist/chunks/matrix-result-contract-CofATICL.js +437 -0
  42. package/dist/chunks/matrix-result-contract-zamd9euI.cjs +1 -0
  43. package/dist/chunks/pivot-header-presentation-DhyQXxKq.cjs +4 -0
  44. package/dist/chunks/pivot-header-presentation-ckYOQ4aZ.js +557 -0
  45. package/dist/chunks/{pivot-result-identity-CDLRT-YG.cjs → pivot-result-identity-Bb4EixVN.cjs} +1 -1
  46. package/dist/chunks/{pivot-result-identity-CwJWpKI7.js → pivot-result-identity-DU1v-5Xk.js} +1 -1
  47. package/dist/chunks/pivot-result-lifecycle-DmcF1ris.cjs +1 -0
  48. package/dist/chunks/pivot-result-lifecycle-sjzIOpvp.js +1641 -0
  49. package/dist/chunks/raw-temporal-contract-BtjH_G-d.cjs +1 -0
  50. package/dist/chunks/raw-temporal-contract-CxncLze5.js +64 -0
  51. package/dist/chunks/report-preferences-dialog-BgSvlDXa.cjs +1 -0
  52. package/dist/chunks/report-preferences-dialog-DDc2WUa0.js +723 -0
  53. package/dist/chunks/{report-runtime-context-C8LZFsqV.cjs → report-runtime-context-DqxS4wbi.cjs} +1 -1
  54. package/dist/chunks/{report-runtime-context-bCy3CVzK.js → report-runtime-context-SM6YO61_.js} +5 -5
  55. package/dist/chunks/saved-temporal-bucket-format-CFfWXRl9.cjs +1 -0
  56. package/dist/chunks/saved-temporal-bucket-format-SGAV0ivR.js +922 -0
  57. package/dist/chunks/{switch-BXet-Sno.js → switch-BeZW-HnS.js} +4350 -5249
  58. package/dist/chunks/switch-D-CCcfhc.cjs +138 -0
  59. package/dist/chunks/temporal-bucket-5UYEotyQ.js +810 -0
  60. package/dist/chunks/temporal-bucket-DHY1y9lq.cjs +1 -0
  61. package/dist/chunks/temporal-bucket-authoring-K1kE6R_z.js +222 -0
  62. package/dist/chunks/temporal-bucket-authoring-o3Emn05L.cjs +1 -0
  63. package/dist/chunks/{temporal-bucket-contract-ChDBWX8I.cjs → temporal-bucket-contract-D2-93DGr.cjs} +1 -1
  64. package/dist/chunks/{temporal-bucket-contract-_F6vNhhH.js → temporal-bucket-contract-D5d-xEl3.js} +1 -1
  65. package/dist/chunks/{token-types-BdQ8kHBm.cjs → token-types-D7CaaI80.cjs} +1 -1
  66. package/dist/chunks/{token-types-BHR58aTy.js → token-types-GbxRUozo.js} +1 -1
  67. package/dist/chunks/{update-policy-BxvYMYz0.cjs → update-policy-BmiOd0PB.cjs} +1 -1
  68. package/dist/chunks/{update-policy-g0rCQ9BM.js → update-policy-hednMF-0.js} +1 -1
  69. package/dist/chunks/validators-BDYprKI9.cjs +1 -0
  70. package/dist/chunks/{validators-Cs74WVie.js → validators-DEmd8Sin.js} +1561 -1197
  71. package/dist/dashboard/index.cjs +1 -1
  72. package/dist/dashboard/index.js +2 -2
  73. package/dist/dashboard-authoring/index.cjs +3 -3
  74. package/dist/dashboard-authoring/index.js +35 -32
  75. package/dist/data-app-builder/index.cjs +1 -1
  76. package/dist/data-app-builder/index.js +2 -2
  77. package/dist/data-app-codegen/index.cjs +1 -1
  78. package/dist/data-app-codegen/index.js +2 -2
  79. package/dist/data-app-codegen-node/index.cjs +1 -1
  80. package/dist/data-app-codegen-node/index.js +3 -3
  81. package/dist/data-app-sdk/index.cjs +1 -1
  82. package/dist/data-app-sdk/index.js +78 -77
  83. package/dist/data-app-sdk-adapters/index.cjs +1 -1
  84. package/dist/data-app-sdk-adapters/index.js +29 -30
  85. package/dist/data-app-sdk-validation/index.cjs +1 -1
  86. package/dist/data-app-sdk-validation/index.js +21 -21
  87. package/dist/format-utils/index.cjs +3 -3
  88. package/dist/format-utils/index.js +156 -140
  89. package/dist/index.cjs +1 -1
  90. package/dist/index.js +157 -155
  91. package/dist/report-runtime-context/index.cjs +1 -1
  92. package/dist/report-runtime-context/index.js +2 -2
  93. package/dist/style.css +1 -1
  94. package/dist/surfboard/index.cjs +1 -1
  95. package/dist/surfboard/index.js +3 -3
  96. package/dist/types/analytics-protocol.d.ts +81 -11
  97. package/dist/types/briefings.d.ts +727 -19
  98. package/dist/types/dashboard-assistant.d.ts +37 -17
  99. package/dist/types/dashboard-authoring.d.ts +61 -14
  100. package/dist/types/dashboard.d.ts +137 -12
  101. package/dist/types/data-app-builder.d.ts +28 -2
  102. package/dist/types/data-app-codegen-node.d.ts +29 -3
  103. package/dist/types/data-app-codegen.d.ts +29 -3
  104. package/dist/types/data-app-sdk-adapters.d.ts +28 -2
  105. package/dist/types/data-app-sdk-validation.d.ts +51 -7
  106. package/dist/types/data-app-sdk.d.ts +55 -10
  107. package/dist/types/format-utils.d.ts +190 -3
  108. package/dist/types/index.cjs +1 -1
  109. package/dist/types/index.js +4 -4
  110. package/dist/types/main.d.ts +128 -33
  111. package/dist/types/shared.d.ts +14 -12
  112. package/dist/types/surfboard.d.ts +138 -13
  113. package/dist/types/types.d.ts +117 -23
  114. package/dist/types/value-format-preferences.d.ts +3 -0
  115. package/package.json +2 -1
  116. package/dist/chunks/card-config-utils-15sRtebL.cjs +0 -1
  117. package/dist/chunks/card-config-utils-BYZ5MJOh.js +0 -16
  118. package/dist/chunks/catalog-field-grounding-Bnx-3tE0.cjs +0 -1
  119. package/dist/chunks/catalog-field-grounding-S2jKwKGD.js +0 -100
  120. package/dist/chunks/dashboard-briefing-launcher-DDgDr2s3.cjs +0 -26
  121. package/dist/chunks/dashboard-date-comparison-definition-DZq0htjG.cjs +0 -1
  122. package/dist/chunks/dashboard-input-contract-DSt8dGzP.js +0 -18
  123. package/dist/chunks/dashboard-input-contract-DV3cshjz.cjs +0 -1
  124. package/dist/chunks/dashboard-json-CYtvwtvj.cjs +0 -1
  125. package/dist/chunks/edit-dashboard-visual-DwKcvlsF.cjs +0 -177
  126. package/dist/chunks/editor-action-buttons-BVmsk0Aj.cjs +0 -16
  127. package/dist/chunks/format-types-CSv0V7mm.cjs +0 -1
  128. package/dist/chunks/format-types-DZGgYj39.js +0 -1663
  129. package/dist/chunks/index-CJdxSyQq.js +0 -2578
  130. package/dist/chunks/index-DPv8_Ild.cjs +0 -1395
  131. package/dist/chunks/index-DRlMUglg.cjs +0 -4
  132. package/dist/chunks/metric-comparison-97zHGEx5.js +0 -387
  133. package/dist/chunks/metric-comparison-CUAJ8n4y.cjs +0 -1
  134. package/dist/chunks/pivot-result-lifecycle-BBabQ_da.js +0 -914
  135. package/dist/chunks/pivot-result-lifecycle-DPc0ANwk.cjs +0 -4
  136. package/dist/chunks/presentation-execution-BLfPTGX_.js +0 -637
  137. package/dist/chunks/presentation-execution-BTV-Q43g.cjs +0 -1
  138. package/dist/chunks/report-preferences-dialog-D9ZCGh9l.js +0 -691
  139. package/dist/chunks/report-preferences-dialog-DaqTEcac.cjs +0 -1
  140. package/dist/chunks/switch-Cjk6G06r.cjs +0 -138
  141. package/dist/chunks/temporal-bucket-BnPxGrAi.js +0 -446
  142. package/dist/chunks/temporal-bucket-authoring-CPTwHzvs.cjs +0 -1
  143. package/dist/chunks/temporal-bucket-authoring-CgOuakGW.js +0 -205
  144. package/dist/chunks/temporal-bucket-pMnV-4Nj.cjs +0 -1
  145. package/dist/chunks/temporal-result-owner-6peubmhU.js +0 -443
  146. package/dist/chunks/temporal-result-owner-f6-i65Fb.cjs +0 -1
  147. package/dist/chunks/validators-9D4KBqKD.cjs +0 -1
@@ -1,2134 +1,42 @@
1
- var se = Object.defineProperty;
2
- var me = (t, n, e) => n in t ? se(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
3
- var H = (t, n, e) => me(t, typeof n != "symbol" ? n + "" : n, e);
4
- import { i as W, b as fe, l as pe } from "../chunks/presentation-execution-BLfPTGX_.js";
1
+ import "../chunks/pivot-result-lifecycle-sjzIOpvp.js";
5
2
  import "../value-format-preferences/index.js";
6
- import "../chunks/validators-Cs74WVie.js";
7
- import "../chunks/analyze-result-contract-T-0Ntzys.js";
8
- import { b as ue } from "../chunks/report-runtime-context-bCy3CVzK.js";
9
- import { i as he } from "../chunks/card-config-utils-BYZ5MJOh.js";
10
- function ye(t) {
11
- return !!t && typeof t == "object" && !Array.isArray(t);
12
- }
13
- function E(t, n, e) {
14
- return ye(t) ? t : (e.push({ field: n, message: "Expected an object." }), {});
15
- }
16
- function C(t, n, e, r) {
17
- const o = new Set(e);
18
- Object.keys(t).forEach((a) => {
19
- o.has(a) || r.push({
20
- field: `${n}.${a}`,
21
- message: "Unexpected property."
22
- });
23
- });
24
- }
25
- function T(t, n, e, r, o = {}) {
26
- if (t == null)
27
- return;
28
- if (typeof t != "string") {
29
- r.push({ field: n, message: "Expected a string." });
30
- return;
31
- }
32
- const a = o.trim === !1 ? t : t.trim();
33
- if (!o.allowEmpty && a.length === 0) {
34
- r.push({ field: n, message: "Expected a non-empty string." });
35
- return;
36
- }
37
- if (a.length > e) {
38
- r.push({
39
- field: n,
40
- message: `Expected ${e} characters or fewer.`
41
- });
42
- return;
43
- }
44
- return a;
45
- }
46
- function L(t, n, e) {
47
- const r = T(t, n, 2e3, e);
48
- if (r)
49
- try {
50
- return new URL(r), r;
51
- } catch {
52
- e.push({ field: n, message: "Expected an absolute URL." });
53
- return;
54
- }
55
- }
56
- function G(t, n, e) {
57
- const r = E(t, n, e);
58
- C(r, n, ["tokens", "components"], e);
59
- const o = {};
60
- if (r.tokens !== void 0) {
61
- const a = E(r.tokens, `${n}.tokens`, e);
62
- C(
63
- a,
64
- `${n}.tokens`,
65
- ["color", "typography"],
66
- e
67
- );
68
- const i = {};
69
- if (a.color !== void 0) {
70
- const c = E(
71
- a.color,
72
- `${n}.tokens.color`,
73
- e
74
- ), l = [
75
- "background",
76
- "foreground",
77
- "muted",
78
- "mutedForeground",
79
- "border",
80
- "primary",
81
- "primaryForeground",
82
- "positive",
83
- "negative",
84
- "warning",
85
- "info"
86
- ];
87
- C(c, `${n}.tokens.color`, l, e);
88
- const s = {};
89
- l.forEach((f) => {
90
- const v = T(
91
- c[f],
92
- `${n}.tokens.color.${f}`,
93
- 120,
94
- e
95
- );
96
- v !== void 0 && (s[f] = v);
97
- }), i.color = s;
98
- }
99
- if (a.typography !== void 0) {
100
- const c = E(
101
- a.typography,
102
- `${n}.tokens.typography`,
103
- e
104
- );
105
- C(
106
- c,
107
- `${n}.tokens.typography`,
108
- ["fontFamily", "monoFontFamily"],
109
- e
110
- );
111
- const l = T(
112
- c.fontFamily,
113
- `${n}.tokens.typography.fontFamily`,
114
- 500,
115
- e,
116
- { allowEmpty: !0 }
117
- ), s = T(
118
- c.monoFontFamily,
119
- `${n}.tokens.typography.monoFontFamily`,
120
- 500,
121
- e,
122
- { allowEmpty: !0 }
123
- );
124
- i.typography = {
125
- ...l !== void 0 ? { fontFamily: l } : {},
126
- ...s !== void 0 ? { monoFontFamily: s } : {}
127
- };
128
- }
129
- o.tokens = i;
130
- }
131
- if (r.components !== void 0) {
132
- const a = E(
133
- r.components,
134
- `${n}.components`,
135
- e
136
- );
137
- if (C(a, `${n}.components`, ["chart"], e), a.chart !== void 0) {
138
- const i = E(
139
- a.chart,
140
- `${n}.components.chart`,
141
- e
142
- );
143
- C(i, `${n}.components.chart`, ["palette"], e);
144
- let c;
145
- i.palette !== void 0 && (Array.isArray(i.palette) ? i.palette.length > 20 ? e.push({
146
- field: `${n}.components.chart.palette`,
147
- message: "Expected 20 colors or fewer."
148
- }) : c = i.palette.map(
149
- (l, s) => T(
150
- l,
151
- `${n}.components.chart.palette.${s}`,
152
- 120,
153
- e
154
- )
155
- ).filter((l) => l !== void 0) : e.push({
156
- field: `${n}.components.chart.palette`,
157
- message: "Expected an array."
158
- })), o.components = {
159
- chart: c ? { palette: c } : {}
160
- };
161
- }
162
- }
163
- return o;
164
- }
165
- function ge(t, n) {
166
- const e = "presentation.appearance", r = E(t, e, n);
167
- C(r, e, ["version", "schemes"], n);
168
- const o = {};
169
- if (r.version !== void 0 && (typeof r.version != "number" || !Number.isFinite(r.version) ? n.push({ field: `${e}.version`, message: "Expected a number." }) : o.version = r.version), r.schemes !== void 0) {
170
- const a = E(r.schemes, `${e}.schemes`, n);
171
- C(a, `${e}.schemes`, ["light", "dark"], n), o.schemes = {
172
- ...a.light !== void 0 ? {
173
- light: G(
174
- a.light,
175
- `${e}.schemes.light`,
176
- n
177
- )
178
- } : {},
179
- ...a.dark !== void 0 ? {
180
- dark: G(
181
- a.dark,
182
- `${e}.schemes.dark`,
183
- n
184
- )
185
- } : {}
186
- };
187
- }
188
- return o;
189
- }
190
- function ve(t, n) {
191
- const e = "presentation.brandOverrides", r = E(t, e, n);
192
- C(r, e, ["brandName", "logoUrl", "link"], n);
193
- const o = T(
194
- r.brandName,
195
- `${e}.brandName`,
196
- 200,
197
- n
198
- ), a = L(r.logoUrl, `${e}.logoUrl`, n), i = T(r.link, `${e}.link`, 120, n);
199
- return {
200
- ...o !== void 0 ? { brandName: o } : {},
201
- ...a !== void 0 ? { logoUrl: a } : {},
202
- ...i !== void 0 ? { link: i } : {}
203
- };
204
- }
205
- function be(t, n) {
206
- const e = "presentation.fragments", r = E(t, e, n), o = [
207
- "preHeaderText",
208
- "headerBannerHtml",
209
- "signatureHtml",
210
- "footerHtml",
211
- "disclaimerHtml",
212
- "unsubscribeUrl"
213
- ];
214
- C(r, e, o, n);
215
- const a = {};
216
- return o.forEach((i) => {
217
- const c = i === "unsubscribeUrl" ? L(r[i], `${e}.${i}`, n) : T(
218
- r[i],
219
- `${e}.${i}`,
220
- i === "preHeaderText" ? 200 : 5e3,
221
- n,
222
- { trim: i === "preHeaderText" }
223
- );
224
- c !== void 0 && (a[i] = c);
225
- }), a;
226
- }
227
- function $e(t) {
228
- const n = [], e = {};
229
- if (t.appearance !== void 0 && (e.appearance = ge(t.appearance, n)), t.brandOverrides !== void 0 && (e.brandOverrides = ve(t.brandOverrides, n)), t.fragments !== void 0 && (e.fragments = be(t.fragments, n)), t.viewUrl !== void 0) {
230
- const r = L(t.viewUrl, "presentation.viewUrl", n);
231
- r !== void 0 && (e.viewUrl = r);
232
- }
233
- return { value: e, issues: n };
234
- }
235
- const Z = [
236
- "SUN",
237
- "MON",
238
- "TUE",
239
- "WED",
240
- "THU",
241
- "FRI",
242
- "SAT"
243
- ], Ie = new Map(
244
- Z.map((t, n) => [t, n])
245
- ), xt = {
246
- cadence: "weekly",
247
- hour: 9,
248
- minute: 0,
249
- weekdays: [1]
250
- };
251
- function Tt(t) {
252
- if (typeof t != "string" || t.length === 0 || t !== t.trim() || /^(?:(?:UTC|GMT)[+-]|[+-]\d{2}:\d{2}$)/.test(t))
253
- return !1;
254
- try {
255
- return new Intl.DateTimeFormat("en-US", { timeZone: t }).format(), !0;
256
- } catch {
257
- return !1;
258
- }
259
- }
260
- function Ee(t) {
261
- return Number.isInteger(t.minute) && t.minute >= 0 && t.minute <= 59 && Number.isInteger(t.hour) && t.hour >= 0 && t.hour <= 23;
262
- }
263
- function Y(t) {
264
- if (t.length === 0) return null;
265
- const n = [...t].sort((e, r) => e - r);
266
- return n.some(
267
- (e, r) => !Number.isInteger(e) || e < 0 || e > 6 || r > 0 && e === n[r - 1]
268
- ) ? null : n;
269
- }
270
- function At(t) {
271
- if (!Ee(t))
272
- throw new Error("Choose a valid schedule time.");
273
- const n = `${t.minute} ${t.hour}`;
274
- switch (t.cadence) {
275
- case "daily":
276
- return `${n} * * *`;
277
- case "weekly": {
278
- const e = Y(t.weekdays);
279
- if (!e) throw new Error("Choose at least one weekday.");
280
- return `${n} * * ${e.map((r) => Z[r]).join(",")}`;
281
- }
282
- case "twice_monthly":
283
- return `${n} 1,15 * *`;
284
- case "monthly":
285
- return `${n} 1 * *`;
286
- }
287
- }
288
- function Ce(t) {
289
- if (typeof t != "string" || t.length === 0)
290
- return { ok: !1, issue: "Choose a supported schedule." };
291
- if (t !== t.trim() || t.includes(" "))
292
- return { ok: !1, issue: "Choose a supported schedule." };
293
- const n = t.split(" ");
294
- if (n.length !== 5)
295
- return { ok: !1, issue: "Choose a supported schedule." };
296
- const [e, r, o, a, i] = n;
297
- if (!/^(0|[1-9]\d?)$/.test(e) || !/^(0|[1-9]\d?)$/.test(r))
298
- return { ok: !1, issue: "Choose a supported schedule." };
299
- const c = Number(e), l = Number(r);
300
- if (c > 59 || l > 23 || a !== "*")
301
- return { ok: !1, issue: "Choose a supported schedule." };
302
- if (o === "*" && i === "*")
303
- return {
304
- ok: !0,
305
- value: { cadence: "daily", hour: l, minute: c, weekdays: [] }
306
- };
307
- if (o === "*" && i !== "*") {
308
- const f = i.split(",").map((y) => Ie.get(y));
309
- if (f.some((y) => y === void 0))
310
- return { ok: !1, issue: "Choose a supported schedule." };
311
- const v = f, b = Y(v);
312
- return !b || b.some((y, k) => y !== v[k]) ? { ok: !1, issue: "Choose a supported schedule." } : {
313
- ok: !0,
314
- value: { cadence: "weekly", hour: l, minute: c, weekdays: b }
315
- };
316
- }
317
- return o === "1,15" && i === "*" ? {
318
- ok: !0,
319
- value: { cadence: "twice_monthly", hour: l, minute: c, weekdays: [] }
320
- } : o === "1" && i === "*" ? {
321
- ok: !0,
322
- value: { cadence: "monthly", hour: l, minute: c, weekdays: [] }
323
- } : { ok: !1, issue: "Choose a supported schedule." };
324
- }
325
- function ke(t, n, e) {
326
- return new Intl.DateTimeFormat(e, {
327
- hour: "numeric",
328
- minute: "2-digit",
329
- timeZone: "UTC"
330
- }).format(new Date(Date.UTC(2020, 0, 1, t, n)));
331
- }
332
- function xe(t, n) {
333
- var e;
334
- if (t === "UTC") return "UTC";
335
- try {
336
- return ((e = new Intl.DateTimeFormat(n, {
337
- timeZone: t,
338
- timeZoneName: "longGeneric"
339
- }).formatToParts(new Date(Date.UTC(2020, 0, 1))).find((o) => o.type === "timeZoneName")) == null ? void 0 : e.value) ?? t;
340
- } catch {
341
- return null;
342
- }
343
- }
344
- function St(t, n, e = "en-US") {
345
- const r = Ce(t);
346
- if (!r.ok) return null;
347
- try {
348
- const o = ke(r.value.hour, r.value.minute, e), a = xe(n, e);
349
- if (!a) return null;
350
- switch (r.value.cadence) {
351
- case "daily":
352
- return `Daily at ${o} ${a}`;
353
- case "weekly": {
354
- const i = new Intl.DateTimeFormat(e, {
355
- weekday: "long",
356
- timeZone: "UTC"
357
- });
358
- return `${r.value.weekdays.map(
359
- (l) => i.format(new Date(Date.UTC(2023, 0, 1 + l)))
360
- ).join(" and ")} at ${o} ${a}`;
361
- }
362
- case "twice_monthly":
363
- return `On the 1st and 15th at ${o} ${a}`;
364
- case "monthly":
365
- return `Monthly on the 1st at ${o} ${a}`;
366
- }
367
- } catch {
368
- return null;
369
- }
370
- }
371
- const Te = /* @__PURE__ */ new Set([
372
- "table",
373
- "aggregateTable",
374
- "pivotTable",
375
- "detailTable"
376
- ]), Ae = /* @__PURE__ */ new Set([
377
- "bar",
378
- "horizontalBar",
379
- "line",
380
- "area",
381
- "stackedArea",
382
- "combo",
383
- "pie",
384
- "doughnut",
385
- "radar",
386
- "polarArea",
387
- "bubble",
388
- "scatter",
389
- "stackedBar",
390
- "stackedLine",
391
- "table",
392
- "pivotTable",
393
- "aggregateTable",
394
- "matrixTable",
395
- "detailTable",
396
- "kpi",
397
- "pyramid",
398
- "tornado",
399
- "range",
400
- "map",
401
- "funnel",
402
- "bullet",
403
- "heatmap",
404
- "treemap",
405
- "custom"
406
- ]);
407
- function wt(t) {
408
- var r, o, a;
409
- const n = Ae.has(t.type) && (t.type !== "custom" || !!((r = t.customCardPreferences) != null && r.url));
410
- return t.type === "text" || !n || he(t) ? { formats: [], defaultFormat: null } : {
411
- formats: Se({
412
- cardType: t.type,
413
- allowDownload: (o = t.preferences) == null ? void 0 : o.allowDownload
414
- }),
415
- defaultFormat: we({
416
- cardType: t.type,
417
- allowDownload: (a = t.preferences) == null ? void 0 : a.allowDownload
418
- })
419
- };
420
- }
421
- function Se(t) {
422
- return t.allowDownload === !1 ? ["pdf"] : ["pdf", "csv"];
423
- }
424
- function we(t) {
425
- return Te.has(t.cardType) && t.allowDownload !== !1 ? "csv" : "pdf";
426
- }
427
- function Ft(t) {
428
- return t != null && t.role ? t.type === "tenant" ? t.role === "POWER_USER" : ["AUTHOR", "ADMIN", "SUPER_ADMIN"].includes(t.role) : !1;
429
- }
430
- function Dt(t) {
431
- return t.canCreate ? [
432
- ...t.scheduledReportAvailable ? ["scheduled_report"] : [],
433
- ...t.analyticalBriefingsEnabled ? ["analytical_briefing"] : []
434
- ] : [];
435
- }
436
- function Fe(t) {
437
- const n = (t == null ? void 0 : t.channels) ?? [];
438
- return n.length === 1 && n[0] === "EMAIL";
439
- }
440
- function De(t) {
441
- return t.body.type === "generated_analysis" ? "Analytical briefing" : t.body.type === "custom_message" && t.attachments.length > 0 && Fe(t.deliveryConfig) ? t.scheduleExpr ? "Scheduled report" : "On-demand report" : "Plain briefing";
442
- }
443
- function _t(t) {
444
- const n = De(t), e = n === "Scheduled report" || n === "On-demand report" ? "report" : "briefing";
445
- return {
446
- typeLabel: n,
447
- noun: e,
448
- pluralNoun: e === "report" ? "reports" : "briefings"
449
- };
450
- }
451
- const R = "BRIEFING", _e = ["markdown", "html"], O = ["markdown"], D = 20, m = {
452
- name: 500,
453
- description: 2e3,
454
- instruction: 5e4,
455
- customMessage: 5e4,
456
- contentTitle: 500,
457
- contentSummary: 2e4,
458
- contentText: 5e3,
459
- contentSql: 5e4,
460
- contentItem: 2e3,
461
- contentCell: 500,
462
- attachmentTitle: 500,
463
- presentationAudience: 1e3,
464
- presentationTone: 500,
465
- presentationFormat: 2e3,
466
- id: 500
467
- }, $ = {
468
- maxBlocks: 50,
469
- maxTableRows: 100,
470
- maxTableColumns: 20,
471
- maxTableCellCharacters: m.contentCell,
472
- maxParagraphCharacters: m.contentText,
473
- maxFindingCharacters: m.contentText,
474
- maxListItems: 100,
475
- // A kpi_grid is rendered as a 2-up tile arrangement in emails. Cap at 8 so
476
- // the visual stays at most 4 rows (4 columns wide on desktop would force
477
- // tiny tiles in narrow client panels; 2-up was the chosen layout).
478
- maxKpiTiles: 8
479
- };
480
- function Be(t) {
481
- if (t === null || typeof t != "object" || Array.isArray(t))
482
- return !1;
483
- const n = t;
484
- if (typeof n.value != "number" || !Number.isFinite(n.value))
485
- return !1;
486
- const e = n.target;
487
- if (e === null || typeof e != "object" || Array.isArray(e))
488
- return !1;
489
- const r = e;
490
- 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()) && W(n.format).ok;
491
- }
492
- function Ne(t) {
493
- return t == null ? "" : Be(t) ? fe(t.value, t.format) : String(t);
494
- }
495
- function Bt(t) {
496
- return [t.delta, t.percentChange].filter(
497
- (n) => n != null
498
- ).map(Ne).filter(Boolean).join(" / ");
499
- }
500
- const J = new Set(_e), Re = /* @__PURE__ */ new Set([
501
- "EMAIL",
502
- "WEBHOOK",
503
- "SLACK",
504
- "IN_APP",
505
- "TELEGRAM"
506
- ]), _ = {
507
- maxToolCalls: { min: 1, max: 100 },
508
- maxPlanningIterations: { min: 1, max: 10 },
509
- maxRows: { min: 1, max: 1e5 },
510
- timeoutMs: { min: 1e3, max: 30 * 6e4 }
511
- }, Oe = /* @__PURE__ */ new Set([
512
- "letter",
513
- "legal",
514
- "a4",
515
- "a3",
516
- "tabloid"
517
- ]), Le = /* @__PURE__ */ new Set([
518
- "portrait",
519
- "landscape"
520
- ]), ze = /* @__PURE__ */ new Set([",", ";", " "]), Ve = /* @__PURE__ */ new Set([
521
- "current",
522
- "all"
523
- ]), Ue = /* @__PURE__ */ new Set([
524
- "concise",
525
- "balanced",
526
- "detailed"
527
- ]), Pe = /* @__PURE__ */ new Set([
528
- "info",
529
- "positive",
530
- "warning",
531
- "critical"
532
- ]), je = /* @__PURE__ */ new Set([
533
- "text",
534
- "number",
535
- "currency",
536
- "percent",
537
- "date",
538
- "boolean"
539
- ]), Me = /* @__PURE__ */ new Set([
540
- "left",
541
- "center",
542
- "right"
543
- ]), Ke = [
544
- "pageSize",
545
- "orientation",
546
- "includeFilters",
547
- "includeTimestamp",
548
- "delimiter",
549
- "includeHeaders",
550
- "useFormattedValues",
551
- "sheetSelection",
552
- "currentSheetId",
553
- "currentSheetName",
554
- "filterValues",
555
- "inlineFilterValues",
556
- "sheetFilterValues",
557
- "filterLine",
558
- "controlValues",
559
- "controlDefinitions",
560
- "cardControlDefinitions",
561
- "controlBindings",
562
- "tablePreferences",
563
- "dashboardInputExecutionSnapshot",
564
- "selectedSheetId",
565
- "cardType",
566
- "allowDownload",
567
- "theme"
568
- ];
569
- class F extends Error {
570
- constructor(e) {
571
- super(e.map((r) => `${r.field}: ${r.message}`).join("; "));
572
- H(this, "issues");
573
- this.name = "BriefingContractError", this.issues = e;
574
- }
575
- }
576
- function X(t) {
577
- return typeof t == "object" && t !== null && !Array.isArray(t);
578
- }
579
- function d(t, n, e) {
580
- t.push({ field: n, message: e });
581
- }
582
- function g(t, n, e) {
583
- return X(t) ? t : (d(e, n, "Expected an object."), {});
584
- }
585
- function p(t, n, e, r) {
586
- const o = new Set(e);
587
- Object.keys(t).forEach((a) => {
588
- o.has(a) || d(
589
- r,
590
- n ? `${n}.${a}` : a,
591
- `Unexpected field "${a}".`
592
- );
593
- });
594
- }
595
- function u(t, n, e, r) {
596
- if (typeof t != "string")
597
- return d(r, n, "Expected a string."), "";
598
- const o = t.trim();
599
- return o ? (o.length > e && d(r, n, `Must be ${e} characters or fewer.`), o) : (d(r, n, "Required value cannot be empty."), "");
600
- }
601
- function h(t, n, e, r) {
602
- if (t == null)
603
- return;
604
- if (typeof t != "string") {
605
- d(r, n, "Expected a string.");
606
- return;
607
- }
608
- const o = t.trim();
609
- if (o)
610
- return o.length > e && d(r, n, `Must be ${e} characters or fewer.`), o;
611
- }
612
- function qe(t, n, e, r) {
613
- if (typeof t != "string")
614
- return d(r, n, "Expected a string."), "";
615
- const o = t.trim();
616
- return o.length > e && d(r, n, `Must be ${e} characters or fewer.`), o;
617
- }
618
- function He(t, n, e) {
619
- if (t != null) {
620
- if (!Number.isInteger(t) || Number(t) < 0) {
621
- d(e, n, "Expected a non-negative integer.");
622
- return;
623
- }
624
- return Number(t);
625
- }
626
- }
627
- function I(t, n, e, r = {}) {
628
- if (t == null)
629
- return r.required ? (d(e, n, "Expected at least one evidence id."), []) : void 0;
630
- if (!Array.isArray(t))
631
- return d(e, n, "Expected an array."), r.required ? [] : void 0;
632
- const o = [];
633
- return t.forEach((a, i) => {
634
- const c = u(
635
- a,
636
- `${n}.${i}`,
637
- m.id,
638
- e
639
- );
640
- c && !o.includes(c) && o.push(c);
641
- }), r.required && o.length === 0 && d(e, n, "Expected at least one evidence id."), o.length > 0 || r.required ? o : void 0;
642
- }
643
- function S(t, n, e, r) {
644
- return t == null ? n : typeof t != "boolean" ? (d(r, e, "Expected a boolean."), n) : t;
645
- }
646
- function Ge(t, n) {
647
- return t == null ? "ACTIVE" : t === "ACTIVE" || t === "PAUSED" || t === "DISABLED" ? t : (d(n, "status", "Expected ACTIVE, PAUSED, or DISABLED."), "ACTIVE");
648
- }
649
- function We(t) {
650
- return t.includes("@") && t.includes(".") && !t.includes(" ");
651
- }
652
- function Q(t, n) {
653
- if (t == null)
654
- return { type: "project" };
655
- const e = g(t, "source", n), r = e.type;
656
- return r === "project" ? (p(e, "source", ["type"], n), { type: "project" }) : r === "dashboard" ? (p(e, "source", ["type", "dashboardId"], n), {
657
- type: "dashboard",
658
- dashboardId: u(
659
- e.dashboardId,
660
- "source.dashboardId",
661
- m.id,
662
- n
663
- )
664
- }) : (d(n, "source.type", "Expected project or dashboard."), { type: "project" });
665
- }
666
- function ee(t, n) {
667
- const e = g(t, "body", n), r = e.type;
668
- return r === "generated_analysis" ? (p(e, "body", ["type", "instruction"], n), {
669
- type: "generated_analysis",
670
- instruction: u(
671
- e.instruction,
672
- "body.instruction",
673
- m.instruction,
674
- n
675
- )
676
- }) : r === "custom_message" ? (p(e, "body", ["type", "message"], n), {
677
- type: "custom_message",
678
- message: qe(
679
- e.message,
680
- "body.message",
681
- m.customMessage,
682
- n
683
- )
684
- }) : r === "none" ? (p(e, "body", ["type"], n), { type: "none" }) : (d(
685
- n,
686
- "body.type",
687
- "Expected generated_analysis, custom_message, or none."
688
- ), { type: "none" });
689
- }
690
- function Ze(t, n) {
691
- if (t == null)
692
- return [...O];
693
- if (!Array.isArray(t))
694
- return d(n, "presentation.artifactFormats", "Expected an array."), [...O];
695
- if (t.length === 0)
696
- return d(
697
- n,
698
- "presentation.artifactFormats",
699
- "Choose at least one artifact format."
700
- ), [];
701
- const e = [];
702
- return t.forEach((r, o) => {
703
- if (typeof r != "string" || !J.has(r)) {
704
- d(
705
- n,
706
- `presentation.artifactFormats.${o}`,
707
- "Expected markdown or html."
708
- );
709
- return;
710
- }
711
- e.includes(r) || e.push(r);
712
- }), e;
713
- }
714
- function te(t, n) {
715
- if (t == null)
716
- return {
717
- artifactFormats: [...O],
718
- includeEvidence: !0,
719
- includeSql: !0
720
- };
721
- const e = g(t, "presentation", n);
722
- p(
723
- e,
724
- "presentation",
725
- [
726
- "artifactFormats",
727
- "includeEvidence",
728
- "includeSql",
729
- "audience",
730
- "tone",
731
- "format",
732
- "appearance",
733
- "brandOverrides",
734
- "fragments",
735
- "viewUrl"
736
- ],
737
- n
738
- );
739
- const r = {
740
- artifactFormats: Ze(e.artifactFormats, n),
741
- includeEvidence: S(
742
- e.includeEvidence,
743
- !0,
744
- "presentation.includeEvidence",
745
- n
746
- ),
747
- includeSql: S(
748
- e.includeSql,
749
- !0,
750
- "presentation.includeSql",
751
- n
752
- )
753
- }, o = h(
754
- e.audience,
755
- "presentation.audience",
756
- m.presentationAudience,
757
- n
758
- ), a = h(
759
- e.tone,
760
- "presentation.tone",
761
- m.presentationTone,
762
- n
763
- ), i = h(
764
- e.format,
765
- "presentation.format",
766
- m.presentationFormat,
767
- n
768
- );
769
- o && (r.audience = o), a && (r.tone = a), i && (r.format = i);
770
- const c = $e(e);
771
- return c.issues.forEach((l) => d(n, l.field, l.message)), Object.assign(r, c.value), r;
772
- }
773
- function Ye(t, n, e) {
774
- return Array.isArray(t) ? (t.length === 0 && d(e, n, "Expected at least one item."), t.length > $.maxListItems && d(
775
- e,
776
- n,
777
- `Must have ${$.maxListItems} items or fewer.`
778
- ), t.slice(0, $.maxListItems).map(
779
- (r, o) => u(
780
- r,
781
- `${n}.${o}`,
782
- m.contentItem,
783
- e
784
- )
785
- ).filter(Boolean)) : (d(e, n, "Expected an array."), []);
786
- }
787
- function Je(t, n, e) {
788
- const r = g(t, n, e);
789
- if (r.kind === "metric")
790
- return p(r, n, ["kind", "metricId"], e), {
791
- kind: "metric",
792
- metricId: u(
793
- r.metricId,
794
- `${n}.metricId`,
795
- m.id,
796
- e
797
- )
798
- };
799
- if (r.kind === "column")
800
- return p(r, n, ["kind", "columnKey"], e), {
801
- kind: "column",
802
- columnKey: u(
803
- r.columnKey,
804
- `${n}.columnKey`,
805
- m.id,
806
- e
807
- )
808
- };
809
- if (r.kind === "matrix_measure")
810
- return p(r, n, ["kind", "measureId"], e), {
811
- kind: "matrix_measure",
812
- measureId: u(
813
- r.measureId,
814
- `${n}.measureId`,
815
- m.id,
816
- e
817
- )
818
- };
819
- d(
820
- e,
821
- `${n}.kind`,
822
- "Expected metric, column, or matrix_measure."
823
- );
824
- }
825
- function ne(t, n, e) {
826
- if (t === null || typeof t != "object" || Array.isArray(t))
827
- return;
828
- const r = g(t, n, e);
829
- if (!Object.prototype.hasOwnProperty.call(r, "target") && !Object.prototype.hasOwnProperty.call(r, "format"))
830
- return;
831
- p(r, n, ["value", "target", "format"], e), (typeof r.value != "number" || !Number.isFinite(r.value)) && d(e, `${n}.value`, "Expected a finite number.");
832
- const o = Je(
833
- r.target,
834
- `${n}.target`,
835
- e
836
- ), a = W(r.format);
837
- if (a.ok || a.issues.forEach(
838
- (i) => d(
839
- e,
840
- i.path === "$" ? `${n}.format` : `${n}.format.${i.path}`,
841
- i.message
842
- )
843
- ), !(typeof r.value != "number" || !Number.isFinite(r.value) || !o || !a.ok))
844
- return { value: r.value, target: o, format: a.value };
845
- }
846
- function x(t, n, e) {
847
- if (typeof t == "string")
848
- return t;
849
- if (typeof t == "number") {
850
- if (!Number.isFinite(t)) {
851
- d(e, n, "Expected a finite number.");
852
- return;
853
- }
854
- return t;
855
- }
856
- const r = ne(t, n, e);
857
- if (r) return r;
858
- d(
859
- e,
860
- n,
861
- "Expected a string, number, or structured numeric value."
862
- );
863
- }
864
- function Xe(t, n, e) {
865
- if (t === null || typeof t == "string" || typeof t == "number" || typeof t == "boolean")
866
- return typeof t == "string" && t.length > m.contentCell ? (d(
867
- e,
868
- n,
869
- `Must be ${m.contentCell} characters or fewer.`
870
- ), t.slice(0, m.contentCell)) : typeof t == "number" && !Number.isFinite(t) ? (d(e, n, "Expected a finite number."), null) : t;
871
- const r = ne(t, n, e);
872
- return r || (d(
873
- e,
874
- n,
875
- "Expected a string, number, boolean, structured numeric value, or null."
876
- ), null);
877
- }
878
- function Qe(t, n, e) {
879
- if (!Array.isArray(t))
880
- return d(e, n, "Expected an array."), [];
881
- t.length === 0 && d(e, n, "Expected at least one column."), t.length > $.maxTableColumns && d(
882
- e,
883
- n,
884
- `Must have ${$.maxTableColumns} columns or fewer.`
885
- );
886
- const r = /* @__PURE__ */ new Set();
887
- return t.slice(0, $.maxTableColumns).map((o, a) => {
888
- const i = `${n}.${a}`, c = g(o, i, e);
889
- p(c, i, ["key", "label", "kind", "align"], e);
890
- const l = u(
891
- c.key,
892
- `${i}.key`,
893
- m.id,
894
- e
895
- );
896
- l && (r.has(l) && d(e, `${i}.key`, "Column key must be unique."), r.add(l));
897
- const s = u(
898
- c.label,
899
- `${i}.label`,
900
- m.contentTitle,
901
- e
902
- ), f = A(
903
- c.kind,
904
- `${i}.kind`,
905
- je,
906
- "text, number, currency, percent, date, or boolean",
907
- e
908
- ), v = A(
909
- c.align,
910
- `${i}.align`,
911
- Me,
912
- "left, center, or right",
913
- e
914
- );
915
- return {
916
- key: l,
917
- label: s,
918
- ...f ? { kind: f } : {},
919
- ...v ? { align: v } : {}
920
- };
921
- });
922
- }
923
- function et(t, n, e, r) {
924
- if (!Array.isArray(t))
925
- return d(r, n, "Expected an array."), [];
926
- t.length > $.maxTableRows && d(
927
- r,
928
- n,
929
- `Must have ${$.maxTableRows} rows or fewer.`
930
- );
931
- const o = new Set(e.map((a) => a.key).filter(Boolean));
932
- return t.slice(0, $.maxTableRows).map((a, i) => {
933
- const c = `${n}.${i}`, l = g(a, c, r);
934
- return Object.keys(l).forEach((s) => {
935
- o.has(s) || d(r, `${c}.${s}`, `Unexpected table cell "${s}".`);
936
- }), Object.fromEntries(
937
- e.map((s) => [
938
- s.key,
939
- Xe(l[s.key] ?? null, `${c}.${s.key}`, r)
940
- ])
941
- );
942
- });
943
- }
944
- function tt(t, n, e) {
945
- const r = `content.blocks.${n}`, o = g(t, r, e), a = o.type;
946
- if (a === "heading") {
947
- p(o, r, ["type", "text", "level", "evidenceIds"], e);
948
- const i = o.level === void 0 || o.level === null ? void 0 : o.level === 2 || o.level === 3 ? o.level : void 0;
949
- o.level !== void 0 && o.level !== null && i === void 0 && d(e, `${r}.level`, "Expected 2 or 3.");
950
- const c = I(o.evidenceIds, `${r}.evidenceIds`, e);
951
- return {
952
- type: "heading",
953
- text: u(
954
- o.text,
955
- `${r}.text`,
956
- m.contentTitle,
957
- e
958
- ),
959
- ...i ? { level: i } : {},
960
- ...c ? { evidenceIds: c } : {}
961
- };
962
- }
963
- if (a === "paragraph") {
964
- p(o, r, ["type", "text", "evidenceIds"], e);
965
- const i = I(o.evidenceIds, `${r}.evidenceIds`, e);
966
- return {
967
- type: "paragraph",
968
- text: u(
969
- o.text,
970
- `${r}.text`,
971
- m.contentText,
972
- e
973
- ),
974
- ...i ? { evidenceIds: i } : {}
975
- };
976
- }
977
- if (a === "finding") {
978
- p(o, r, ["type", "title", "text", "severity", "evidenceIds"], e);
979
- const i = h(
980
- o.title,
981
- `${r}.title`,
982
- m.contentTitle,
983
- e
984
- ), c = A(
985
- o.severity,
986
- `${r}.severity`,
987
- Pe,
988
- "info, positive, warning, or critical",
989
- e
990
- );
991
- return {
992
- type: "finding",
993
- ...i ? { title: i } : {},
994
- text: u(
995
- o.text,
996
- `${r}.text`,
997
- m.contentText,
998
- e
999
- ),
1000
- ...c ? { severity: c } : {},
1001
- evidenceIds: I(o.evidenceIds, `${r}.evidenceIds`, e, {
1002
- required: !0
1003
- }) ?? []
1004
- };
1005
- }
1006
- if (a === "bullets" || a === "actions" || a === "limitations") {
1007
- p(o, r, ["type", "title", "items", "evidenceIds"], e);
1008
- const i = h(
1009
- o.title,
1010
- `${r}.title`,
1011
- m.contentTitle,
1012
- e
1013
- ), c = I(o.evidenceIds, `${r}.evidenceIds`, e);
1014
- return {
1015
- type: a,
1016
- ...i ? { title: i } : {},
1017
- items: Ye(o.items, `${r}.items`, e),
1018
- ...c ? { evidenceIds: c } : {}
1019
- };
1020
- }
1021
- if (a === "metric") {
1022
- p(
1023
- o,
1024
- r,
1025
- [
1026
- "type",
1027
- "label",
1028
- "value",
1029
- "previousValue",
1030
- "delta",
1031
- "percentChange",
1032
- "unit",
1033
- "evidenceIds"
1034
- ],
1035
- e
1036
- );
1037
- const i = x(o.value, `${r}.value`, e) ?? "";
1038
- i === "" && d(
1039
- e,
1040
- `${r}.value`,
1041
- "Expected a non-empty string, number, or structured numeric value."
1042
- );
1043
- const c = o.previousValue === void 0 || o.previousValue === null ? o.previousValue : x(
1044
- o.previousValue,
1045
- `${r}.previousValue`,
1046
- e
1047
- ), l = o.delta === void 0 || o.delta === null ? o.delta : x(
1048
- o.delta,
1049
- `${r}.delta`,
1050
- e
1051
- ), s = o.percentChange === void 0 || o.percentChange === null ? o.percentChange : x(
1052
- o.percentChange,
1053
- `${r}.percentChange`,
1054
- e
1055
- ), f = h(
1056
- o.unit,
1057
- `${r}.unit`,
1058
- m.contentTitle,
1059
- e
1060
- ), v = I(o.evidenceIds, `${r}.evidenceIds`, e);
1061
- return {
1062
- type: "metric",
1063
- label: u(
1064
- o.label,
1065
- `${r}.label`,
1066
- m.contentTitle,
1067
- e
1068
- ),
1069
- value: i,
1070
- ...c !== void 0 ? { previousValue: c } : {},
1071
- ...l !== void 0 ? { delta: l } : {},
1072
- ...s !== void 0 ? { percentChange: s } : {},
1073
- ...f ? { unit: f } : {},
1074
- ...v ? { evidenceIds: v } : {}
1075
- };
1076
- }
1077
- if (a === "kpi_grid") {
1078
- p(o, r, ["type", "title", "tiles", "evidenceIds"], e);
1079
- const i = h(
1080
- o.title,
1081
- `${r}.title`,
1082
- m.contentTitle,
1083
- e
1084
- ), c = Array.isArray(o.tiles) ? o.tiles : [];
1085
- Array.isArray(o.tiles) || d(e, `${r}.tiles`, "Expected an array."), c.length === 0 && d(e, `${r}.tiles`, "Expected at least one tile."), c.length > $.maxKpiTiles && d(
1086
- e,
1087
- `${r}.tiles`,
1088
- `Must have ${$.maxKpiTiles} tiles or fewer.`
1089
- );
1090
- const l = c.slice(0, $.maxKpiTiles).map((f, v) => {
1091
- const b = `${r}.tiles.${v}`, y = g(f, b, e);
1092
- p(
1093
- y,
1094
- b,
1095
- [
1096
- "label",
1097
- "value",
1098
- "previousValue",
1099
- "delta",
1100
- "percentChange",
1101
- "unit",
1102
- "evidenceIds"
1103
- ],
1104
- e
1105
- );
1106
- const k = x(
1107
- y.value,
1108
- `${b}.value`,
1109
- e
1110
- ) ?? "";
1111
- k === "" && d(
1112
- e,
1113
- `${b}.value`,
1114
- "Expected a non-empty string, number, or structured numeric value."
1115
- );
1116
- const P = y.previousValue === void 0 || y.previousValue === null ? y.previousValue : x(
1117
- y.previousValue,
1118
- `${b}.previousValue`,
1119
- e
1120
- ), j = y.delta === void 0 || y.delta === null ? y.delta : x(
1121
- y.delta,
1122
- `${b}.delta`,
1123
- e
1124
- ), M = y.percentChange === void 0 || y.percentChange === null ? y.percentChange : x(
1125
- y.percentChange,
1126
- `${b}.percentChange`,
1127
- e
1128
- ), K = h(
1129
- y.unit,
1130
- `${b}.unit`,
1131
- m.contentTitle,
1132
- e
1133
- ), q = I(
1134
- y.evidenceIds,
1135
- `${b}.evidenceIds`,
1136
- e
1137
- );
1138
- return {
1139
- label: u(
1140
- y.label,
1141
- `${b}.label`,
1142
- m.contentTitle,
1143
- e
1144
- ),
1145
- value: k,
1146
- ...P !== void 0 ? { previousValue: P } : {},
1147
- ...j !== void 0 ? { delta: j } : {},
1148
- ...M !== void 0 ? { percentChange: M } : {},
1149
- ...K ? { unit: K } : {},
1150
- ...q ? { evidenceIds: q } : {}
1151
- };
1152
- }), s = I(
1153
- o.evidenceIds,
1154
- `${r}.evidenceIds`,
1155
- e
1156
- );
1157
- return {
1158
- type: "kpi_grid",
1159
- ...i ? { title: i } : {},
1160
- tiles: l,
1161
- ...s ? { evidenceIds: s } : {}
1162
- };
1163
- }
1164
- if (a === "progress") {
1165
- p(o, r, ["type", "label", "value", "detail", "evidenceIds"], e);
1166
- const i = typeof o.value == "number" && Number.isFinite(o.value) ? o.value : 0;
1167
- (typeof o.value != "number" || !Number.isFinite(o.value)) && d(e, `${r}.value`, "Expected a finite number.");
1168
- const c = h(
1169
- o.detail,
1170
- `${r}.detail`,
1171
- m.contentText,
1172
- e
1173
- ), l = I(o.evidenceIds, `${r}.evidenceIds`, e);
1174
- return {
1175
- type: "progress",
1176
- label: u(
1177
- o.label,
1178
- `${r}.label`,
1179
- m.contentTitle,
1180
- e
1181
- ),
1182
- value: i,
1183
- ...c ? { detail: c } : {},
1184
- ...l ? { evidenceIds: l } : {}
1185
- };
1186
- }
1187
- if (a === "table") {
1188
- p(
1189
- o,
1190
- r,
1191
- ["type", "id", "title", "columns", "rows", "caption", "totalRows", "evidenceIds"],
1192
- e
1193
- );
1194
- const i = Qe(o.columns, `${r}.columns`, e), c = h(
1195
- o.title,
1196
- `${r}.title`,
1197
- m.contentTitle,
1198
- e
1199
- ), l = h(
1200
- o.id,
1201
- `${r}.id`,
1202
- m.id,
1203
- e
1204
- ), s = h(
1205
- o.caption,
1206
- `${r}.caption`,
1207
- m.contentItem,
1208
- e
1209
- ), f = He(
1210
- o.totalRows,
1211
- `${r}.totalRows`,
1212
- e
1213
- ), v = I(o.evidenceIds, `${r}.evidenceIds`, e);
1214
- return {
1215
- type: "table",
1216
- ...l ? { id: l } : {},
1217
- ...c ? { title: c } : {},
1218
- columns: i,
1219
- rows: et(o.rows, `${r}.rows`, i, e),
1220
- ...s ? { caption: s } : {},
1221
- ...f !== void 0 ? { totalRows: f } : {},
1222
- ...v ? { evidenceIds: v } : {}
1223
- };
1224
- }
1225
- if (a === "evidence_appendix") {
1226
- p(o, r, ["type", "title", "evidenceIds"], e);
1227
- const i = h(
1228
- o.title,
1229
- `${r}.title`,
1230
- m.contentTitle,
1231
- e
1232
- );
1233
- return {
1234
- type: "evidence_appendix",
1235
- ...i ? { title: i } : {},
1236
- evidenceIds: I(o.evidenceIds, `${r}.evidenceIds`, e, {
1237
- required: !0
1238
- }) ?? []
1239
- };
1240
- }
1241
- if (a === "sql") {
1242
- p(o, r, ["type", "title", "sql", "evidenceIds"], e);
1243
- const i = h(
1244
- o.title,
1245
- `${r}.title`,
1246
- m.contentTitle,
1247
- e
1248
- ), c = u(
1249
- o.sql,
1250
- `${r}.sql`,
1251
- m.contentSql,
1252
- e
1253
- ), l = I(o.evidenceIds, `${r}.evidenceIds`, e);
1254
- return {
1255
- type: "sql",
1256
- ...i ? { title: i } : {},
1257
- sql: c,
1258
- ...l ? { evidenceIds: l } : {}
1259
- };
1260
- }
1261
- return d(
1262
- e,
1263
- `${r}.type`,
1264
- "Expected heading, paragraph, finding, bullets, metric, kpi_grid, progress, table, actions, limitations, sql, or evidence_appendix."
1265
- ), {
1266
- type: "paragraph",
1267
- text: ""
1268
- };
1269
- }
1270
- function nt(t) {
1271
- const n = [], e = g(t, "content", n);
1272
- p(e, "content", ["version", "title", "summary", "blocks"], n), e.version !== 1 && d(n, "content.version", "Expected version 1.");
1273
- const r = h(
1274
- e.title,
1275
- "content.title",
1276
- m.contentTitle,
1277
- n
1278
- ), o = h(
1279
- e.summary,
1280
- "content.summary",
1281
- m.contentSummary,
1282
- n
1283
- );
1284
- Array.isArray(e.blocks) || d(n, "content.blocks", "Expected an array.");
1285
- const a = Array.isArray(e.blocks) ? e.blocks : [];
1286
- a.length === 0 && d(n, "content.blocks", "Expected at least one block."), a.length > $.maxBlocks && d(
1287
- n,
1288
- "content.blocks",
1289
- `Must have ${$.maxBlocks} blocks or fewer.`
1290
- );
1291
- const i = a.slice(0, $.maxBlocks).map((c, l) => tt(c, l, n));
1292
- return z(n), {
1293
- version: 1,
1294
- ...r ? { title: r } : {},
1295
- ...o ? { summary: o } : {},
1296
- blocks: i
1297
- };
1298
- }
1299
- function Nt(t) {
1300
- try {
1301
- return {
1302
- valid: !0,
1303
- value: nt(t),
1304
- issues: []
1305
- };
1306
- } catch (n) {
1307
- if (n instanceof F)
1308
- return { valid: !1, issues: n.issues };
1309
- throw n;
1310
- }
1311
- }
1312
- function w(t, n, e, r) {
1313
- return typeof t == "string" && e.includes(t) ? t : (d(r, n, `Expected ${e.join(" or ")}.`), e[0]);
1314
- }
1315
- function A(t, n, e, r, o) {
1316
- if (t != null) {
1317
- if (typeof t == "string" && e.has(t))
1318
- return t;
1319
- d(o, n, `Expected ${r}.`);
1320
- }
1321
- }
1322
- function rt(t, n, e) {
1323
- if (t != null) {
1324
- if (!Array.isArray(t)) {
1325
- d(e, n, "Expected an array.");
1326
- return;
1327
- }
1328
- return t;
1329
- }
1330
- }
1331
- function ot(t, n, e) {
1332
- if (t != null) {
1333
- if (!X(t)) {
1334
- d(e, n, "Expected an object.");
1335
- return;
1336
- }
1337
- return t;
1338
- }
1339
- }
1340
- function at(t, n, e) {
1341
- if (t == null)
1342
- return;
1343
- const r = g(t, n, e);
1344
- p(r, n, Ke, e);
1345
- const o = {}, a = A(
1346
- r.pageSize,
1347
- `${n}.pageSize`,
1348
- Oe,
1349
- "letter, legal, a4, a3, or tabloid",
1350
- e
1351
- ), i = A(
1352
- r.orientation,
1353
- `${n}.orientation`,
1354
- Le,
1355
- "portrait or landscape",
1356
- e
1357
- ), c = A(
1358
- r.delimiter,
1359
- `${n}.delimiter`,
1360
- ze,
1361
- "comma, semicolon, or tab",
1362
- e
1363
- ), l = A(
1364
- r.sheetSelection,
1365
- `${n}.sheetSelection`,
1366
- Ve,
1367
- "current or all",
1368
- e
1369
- );
1370
- a && (o.pageSize = a), i && (o.orientation = i), c && (o.delimiter = c), l && (o.sheetSelection = l);
1371
- for (const s of [
1372
- "includeFilters",
1373
- "includeTimestamp",
1374
- "includeHeaders",
1375
- "useFormattedValues",
1376
- "allowDownload"
1377
- ])
1378
- if (!(r[s] === void 0 || r[s] === null)) {
1379
- if (typeof r[s] != "boolean") {
1380
- d(e, `${n}.${s}`, "Expected a boolean.");
1381
- continue;
1382
- }
1383
- o[s] = r[s];
1384
- }
1385
- for (const s of [
1386
- "currentSheetId",
1387
- "currentSheetName",
1388
- "filterLine",
1389
- "selectedSheetId",
1390
- "cardType",
1391
- "theme"
1392
- ]) {
1393
- const f = h(
1394
- r[s],
1395
- `${n}.${s}`,
1396
- m.id,
1397
- e
1398
- );
1399
- f && (o[s] = f);
1400
- }
1401
- for (const s of [
1402
- "filterValues",
1403
- "inlineFilterValues",
1404
- "sheetFilterValues",
1405
- "controlDefinitions",
1406
- "cardControlDefinitions",
1407
- "controlBindings"
1408
- ]) {
1409
- const f = rt(r[s], `${n}.${s}`, e);
1410
- f && (o[s] = f);
1411
- }
1412
- for (const s of [
1413
- "controlValues",
1414
- "tablePreferences",
1415
- "dashboardInputExecutionSnapshot"
1416
- ]) {
1417
- const f = ot(r[s], `${n}.${s}`, e);
1418
- f && (o[s] = f);
1419
- }
1420
- return Object.keys(o).length > 0 ? o : void 0;
1421
- }
1422
- function B(t, n, e, r) {
1423
- const o = h(
1424
- n,
1425
- e,
1426
- m.attachmentTitle,
1427
- r
1428
- );
1429
- return o && (t.title = o), t;
1430
- }
1431
- function N(t, n, e, r) {
1432
- const o = at(n, e, r);
1433
- return o && (t.settings = o), t;
1434
- }
1435
- function it(t, n, e) {
1436
- const r = `attachments.${n}`, o = g(t, r, e), a = o.type;
1437
- if (a === "dashboard") {
1438
- p(
1439
- o,
1440
- r,
1441
- ["type", "dashboardId", "format", "title", "settings"],
1442
- e
1443
- );
1444
- const i = B(
1445
- {
1446
- type: "dashboard",
1447
- dashboardId: u(
1448
- o.dashboardId,
1449
- `${r}.dashboardId`,
1450
- m.id,
1451
- e
1452
- ),
1453
- format: w(o.format, `${r}.format`, ["pdf"], e)
1454
- },
1455
- o.title,
1456
- `${r}.title`,
1457
- e
1458
- );
1459
- return N(i, o.settings, `${r}.settings`, e);
1460
- }
1461
- if (a === "dashboard_sheet" || a === "document_sheet") {
1462
- p(
1463
- o,
1464
- r,
1465
- ["type", "dashboardId", "sheetId", "format", "title", "settings"],
1466
- e
1467
- );
1468
- const i = B(
1469
- {
1470
- type: a,
1471
- dashboardId: u(
1472
- o.dashboardId,
1473
- `${r}.dashboardId`,
1474
- m.id,
1475
- e
1476
- ),
1477
- sheetId: u(
1478
- o.sheetId,
1479
- `${r}.sheetId`,
1480
- m.id,
1481
- e
1482
- ),
1483
- format: w(o.format, `${r}.format`, ["pdf"], e)
1484
- },
1485
- o.title,
1486
- `${r}.title`,
1487
- e
1488
- );
1489
- return N(i, o.settings, `${r}.settings`, e);
1490
- }
1491
- if (a === "card") {
1492
- p(
1493
- o,
1494
- r,
1495
- ["type", "dashboardId", "cardId", "format", "title", "settings"],
1496
- e
1497
- );
1498
- const i = B(
1499
- {
1500
- type: "card",
1501
- dashboardId: u(
1502
- o.dashboardId,
1503
- `${r}.dashboardId`,
1504
- m.id,
1505
- e
1506
- ),
1507
- cardId: u(
1508
- o.cardId,
1509
- `${r}.cardId`,
1510
- m.id,
1511
- e
1512
- ),
1513
- format: w(
1514
- o.format,
1515
- `${r}.format`,
1516
- ["csv", "pdf"],
1517
- e
1518
- )
1519
- },
1520
- o.title,
1521
- `${r}.title`,
1522
- e
1523
- );
1524
- return N(i, o.settings, `${r}.settings`, e);
1525
- }
1526
- return d(
1527
- e,
1528
- `${r}.type`,
1529
- "Expected dashboard, dashboard_sheet, document_sheet, or card."
1530
- ), { type: "dashboard", dashboardId: "", format: "pdf" };
1531
- }
1532
- function ct(t) {
1533
- switch (t.type) {
1534
- case "dashboard":
1535
- return `${t.type}:${t.dashboardId}:${t.format}`;
1536
- case "dashboard_sheet":
1537
- case "document_sheet":
1538
- return `${t.type}:${t.dashboardId}:${t.sheetId}:${t.format}`;
1539
- case "card":
1540
- return `${t.type}:${t.dashboardId}:${t.cardId}:${t.format}`;
1541
- }
1542
- }
1543
- function re(t, n) {
1544
- if (t == null)
1545
- return [];
1546
- if (!Array.isArray(t))
1547
- return d(n, "attachments", "Expected an array."), [];
1548
- t.length > D && d(
1549
- n,
1550
- "attachments",
1551
- `Choose ${D} attachments or fewer.`
1552
- );
1553
- const e = t.slice(0, D).map((o, a) => it(o, a, n)), r = /* @__PURE__ */ new Set();
1554
- return e.forEach((o, a) => {
1555
- const i = ct(o);
1556
- r.has(i) && d(n, `attachments.${a}`, "Duplicate attachment."), r.add(i);
1557
- }), e;
1558
- }
1559
- function oe(t, n) {
1560
- if (t == null)
1561
- return;
1562
- const e = g(t, "limits", n);
1563
- p(e, "limits", Object.keys(_), n);
1564
- const r = {};
1565
- return Object.keys(_).forEach((o) => {
1566
- const a = e[o];
1567
- if (a == null)
1568
- return;
1569
- const i = _[o];
1570
- if (typeof a != "number" || !Number.isInteger(a) || a < i.min || a > i.max) {
1571
- d(
1572
- n,
1573
- `limits.${o}`,
1574
- `Expected an integer between ${i.min} and ${i.max}.`
1575
- );
1576
- return;
1577
- }
1578
- r[o] = a;
1579
- }), Object.keys(r).length > 0 ? r : void 0;
1580
- }
1581
- function z(t) {
1582
- if (t.length > 0)
1583
- throw new F(t);
1584
- }
1585
- function ae(t, n, e) {
1586
- !(t.type === "generated_analysis" || t.type === "custom_message" && !!t.message.trim()) && n.length === 0 && d(
1587
- e,
1588
- "body",
1589
- "Add briefing instructions, a custom message, or at least one attachment."
1590
- );
1591
- }
1592
- function ie(t, n, e) {
1593
- if (t !== void 0)
1594
- try {
1595
- return pe(t);
1596
- } catch (r) {
1597
- d(
1598
- e,
1599
- n,
1600
- r instanceof Error ? r.message : "Invalid resolved formats."
1601
- );
1602
- return;
1603
- }
1604
- }
1605
- function ce(t, n, e, r) {
1606
- t == null || t.forEach((o, a) => {
1607
- const i = `${e}.${a}.scope`, c = o.scope.attachmentIndex;
1608
- if (c === void 0) {
1609
- d(
1610
- r,
1611
- `${i}.attachmentIndex`,
1612
- "Expected the index of the attachment that owns this presentation entry."
1613
- );
1614
- return;
1615
- }
1616
- const l = n[c];
1617
- if (!l) {
1618
- d(
1619
- r,
1620
- `${i}.attachmentIndex`,
1621
- "Expected an index for an existing attachment."
1622
- );
1623
- return;
1624
- }
1625
- o.scope.dashboardId !== l.dashboardId && d(
1626
- r,
1627
- `${i}.dashboardId`,
1628
- "Expected the dashboard selected by the referenced attachment."
1629
- ), l.type === "card" && o.scope.cardId !== l.cardId && d(
1630
- r,
1631
- `${i}.cardId`,
1632
- "Expected the card selected by the referenced attachment."
1633
- );
1634
- });
1635
- }
1636
- function de(t) {
1637
- const n = [], e = g(t, "jobConfig", n);
1638
- p(
1639
- e,
1640
- "jobConfig",
1641
- [
1642
- "kind",
1643
- "reportContext",
1644
- "resolvedFormats",
1645
- "source",
1646
- "body",
1647
- "attachments",
1648
- "presentation",
1649
- "limits"
1650
- ],
1651
- n
1652
- ), e.kind !== R && d(n, "kind", "Expected BRIEFING.");
1653
- const r = ue(e.reportContext);
1654
- r.ok || r.issues.forEach(
1655
- (f) => d(
1656
- n,
1657
- f.path === "$" ? "jobConfig.reportContext" : `jobConfig.reportContext.${f.path}`,
1658
- f.message
1659
- )
1660
- );
1661
- const o = Q(e.source, n), a = ie(
1662
- e.resolvedFormats,
1663
- "jobConfig.resolvedFormats",
1664
- n
1665
- ), i = ee(e.body, n), c = re(e.attachments, n), l = te(e.presentation, n), s = oe(e.limits, n);
1666
- return ae(i, c, n), ce(
1667
- a,
1668
- c,
1669
- "jobConfig.resolvedFormats",
1670
- n
1671
- ), z(n), {
1672
- kind: R,
1673
- reportContext: r.ok ? r.value : e.reportContext,
1674
- ...a ? { resolvedFormats: a } : {},
1675
- source: o,
1676
- body: i,
1677
- attachments: c,
1678
- presentation: l,
1679
- ...s ? { limits: s } : {}
1680
- };
1681
- }
1682
- function Rt(t) {
1683
- return de({
1684
- ...t,
1685
- kind: R
1686
- });
1687
- }
1688
- function V(t, n, e, r = "deliveryConfig.recipients") {
1689
- const o = `${r}.${n}`, a = g(t, o, e), i = a.type;
1690
- if (i === "email") {
1691
- p(a, o, ["type", "address", "name"], e);
1692
- const c = u(
1693
- a.address,
1694
- `${o}.address`,
1695
- m.id,
1696
- e
1697
- ), l = h(
1698
- a.name,
1699
- `${o}.name`,
1700
- m.attachmentTitle,
1701
- e
1702
- );
1703
- return c && !We(c) && d(e, `${o}.address`, "Email address is invalid."), {
1704
- type: "email",
1705
- address: c,
1706
- ...l ? { name: l } : {}
1707
- };
1708
- }
1709
- return i === "user" ? (p(a, o, ["type", "userId"], e), {
1710
- type: "user",
1711
- userId: u(
1712
- a.userId,
1713
- `${o}.userId`,
1714
- m.id,
1715
- e
1716
- )
1717
- }) : i === "tenant_user" ? (p(a, o, ["type", "tenantUserId"], e), {
1718
- type: "tenant_user",
1719
- tenantUserId: u(
1720
- a.tenantUserId,
1721
- `${o}.tenantUserId`,
1722
- m.id,
1723
- e
1724
- )
1725
- }) : i === "group" ? (p(a, o, ["type", "groupId"], e), {
1726
- type: "group",
1727
- groupId: u(
1728
- a.groupId,
1729
- `${o}.groupId`,
1730
- m.id,
1731
- e
1732
- )
1733
- }) : (d(
1734
- e,
1735
- `${o}.type`,
1736
- "Expected email, user, tenant_user, or group."
1737
- ), { type: "email", address: "" });
1738
- }
1739
- function dt(t, n) {
1740
- return t == null ? [] : Array.isArray(t) ? t.map(
1741
- (e, r) => V(e, r, n)
1742
- ) : (d(n, "deliveryConfig.recipients", "Expected an array."), []);
1743
- }
1744
- function lt(t, n) {
1745
- if (!Array.isArray(t))
1746
- return d(n, "deliveryConfig.channels", "Expected an array."), [];
1747
- const e = [];
1748
- return t.forEach((r, o) => {
1749
- if (!le(r)) {
1750
- d(
1751
- n,
1752
- `deliveryConfig.channels.${o}`,
1753
- "Expected EMAIL, WEBHOOK, SLACK, IN_APP, or TELEGRAM."
1754
- );
1755
- return;
1756
- }
1757
- e.includes(r) || e.push(r);
1758
- }), e;
1759
- }
1760
- function st(t, n, e) {
1761
- if (t == null)
1762
- return;
1763
- const r = g(t, n, e), o = {};
1764
- return Object.entries(r).forEach(([a, i]) => {
1765
- if (typeof i != "string") {
1766
- d(e, `${n}.${a}`, "Expected a string.");
1767
- return;
1768
- }
1769
- o[a] = i.trim();
1770
- }), Object.keys(o).length > 0 ? o : void 0;
1771
- }
1772
- function mt(t, n, e) {
1773
- if (t == null)
1774
- return;
1775
- const r = g(t, n, e);
1776
- p(
1777
- r,
1778
- n,
1779
- ["url", "method", "headers", "secretEncrypted"],
1780
- e
1781
- );
1782
- const o = r.method === void 0 || r.method === null ? void 0 : w(r.method, `${n}.method`, ["POST", "PUT"], e), a = st(r.headers, `${n}.headers`, e), i = h(
1783
- r.secretEncrypted,
1784
- `${n}.secretEncrypted`,
1785
- 2e3,
1786
- e
1787
- );
1788
- return {
1789
- url: u(r.url, `${n}.url`, 2e3, e),
1790
- ...o ? { method: o } : {},
1791
- ...a ? { headers: a } : {},
1792
- ...i ? { secretEncrypted: i } : {}
1793
- };
1794
- }
1795
- function ft(t, n, e) {
1796
- const r = g(t, n, e), o = r.type;
1797
- if (o === "channel") {
1798
- p(
1799
- r,
1800
- n,
1801
- ["type", "channelId", "channelName", "isPrivate"],
1802
- e
1803
- );
1804
- const a = h(
1805
- r.channelName,
1806
- `${n}.channelName`,
1807
- m.attachmentTitle,
1808
- e
1809
- ), i = r.isPrivate === void 0 || r.isPrivate === null ? void 0 : S(
1810
- r.isPrivate,
1811
- !1,
1812
- `${n}.isPrivate`,
1813
- e
1814
- );
1815
- return {
1816
- type: "channel",
1817
- channelId: u(
1818
- r.channelId,
1819
- `${n}.channelId`,
1820
- m.id,
1821
- e
1822
- ),
1823
- ...a ? { channelName: a } : {},
1824
- ...i !== void 0 ? { isPrivate: i } : {}
1825
- };
1826
- }
1827
- return o === "dm" ? (p(r, n, ["type", "recipient"], e), d(
1828
- e,
1829
- `${n}.type`,
1830
- "Slack DM delivery is not supported in V1."
1831
- ), {
1832
- type: "dm",
1833
- recipient: V(r.recipient, 0, e, `${n}.recipient`)
1834
- }) : (d(e, `${n}.type`, "Expected channel."), { type: "channel", channelId: "" });
1835
- }
1836
- function pt(t, n, e) {
1837
- if (t == null)
1838
- return;
1839
- if (!Array.isArray(t)) {
1840
- d(e, n, "Expected an array.");
1841
- return;
1842
- }
1843
- const r = t.map(
1844
- (o, a) => V(o, a, e, n)
1845
- );
1846
- return r.length > 0 ? r : void 0;
1847
- }
1848
- function ut(t, n, e) {
1849
- if (t == null)
1850
- return;
1851
- const r = g(t, n, e);
1852
- p(
1853
- r,
1854
- n,
1855
- [
1856
- "destination",
1857
- "threadMentions",
1858
- "postThreadDetail",
1859
- "includeDashboardLink",
1860
- "includeBriefingLink"
1861
- ],
1862
- e
1863
- );
1864
- const o = pt(
1865
- r.threadMentions,
1866
- `${n}.threadMentions`,
1867
- e
1868
- ), a = S(
1869
- r.postThreadDetail,
1870
- !0,
1871
- `${n}.postThreadDetail`,
1872
- e
1873
- ), i = S(
1874
- r.includeDashboardLink,
1875
- !0,
1876
- `${n}.includeDashboardLink`,
1877
- e
1878
- ), c = S(
1879
- r.includeBriefingLink,
1880
- !0,
1881
- `${n}.includeBriefingLink`,
1882
- e
1883
- );
1884
- return {
1885
- destination: ft(
1886
- r.destination,
1887
- `${n}.destination`,
1888
- e
1889
- ),
1890
- ...o ? { threadMentions: o } : {},
1891
- ...r.postThreadDetail !== void 0 ? { postThreadDetail: a } : {},
1892
- ...r.includeDashboardLink !== void 0 ? { includeDashboardLink: i } : {},
1893
- ...r.includeBriefingLink !== void 0 ? { includeBriefingLink: c } : {}
1894
- };
1895
- }
1896
- function ht(t, n, e) {
1897
- const r = g(t, n, e);
1898
- p(
1899
- r,
1900
- n,
1901
- [
1902
- "subjectOverride",
1903
- "titleOverride",
1904
- "summaryOverride",
1905
- "actionBlockVisible",
1906
- "formatProfile",
1907
- "slackConfig",
1908
- "webhookConfig"
1909
- ],
1910
- e
1911
- );
1912
- const o = A(
1913
- r.formatProfile,
1914
- `${n}.formatProfile`,
1915
- Ue,
1916
- "concise, balanced, or detailed",
1917
- e
1918
- ), a = h(
1919
- r.subjectOverride,
1920
- `${n}.subjectOverride`,
1921
- 500,
1922
- e
1923
- ), i = h(
1924
- r.titleOverride,
1925
- `${n}.titleOverride`,
1926
- 500,
1927
- e
1928
- ), c = h(
1929
- r.summaryOverride,
1930
- `${n}.summaryOverride`,
1931
- 2e3,
1932
- e
1933
- ), l = S(
1934
- r.actionBlockVisible,
1935
- !0,
1936
- `${n}.actionBlockVisible`,
1937
- e
1938
- ), s = mt(
1939
- r.webhookConfig,
1940
- `${n}.webhookConfig`,
1941
- e
1942
- ), f = ut(
1943
- r.slackConfig,
1944
- `${n}.slackConfig`,
1945
- e
1946
- );
1947
- return {
1948
- ...o ? { formatProfile: o } : {},
1949
- ...a ? { subjectOverride: a } : {},
1950
- ...i ? { titleOverride: i } : {},
1951
- ...c ? { summaryOverride: c } : {},
1952
- ...r.actionBlockVisible !== void 0 ? { actionBlockVisible: l } : {},
1953
- ...f ? { slackConfig: f } : {},
1954
- ...s ? { webhookConfig: s } : {}
1955
- };
1956
- }
1957
- function yt(t, n) {
1958
- if (t == null)
1959
- return;
1960
- const e = g(t, "deliveryConfig.channelConfigs", n), r = {};
1961
- return Object.entries(e).forEach(([o, a]) => {
1962
- if (!le(o)) {
1963
- d(
1964
- n,
1965
- `deliveryConfig.channelConfigs.${o}`,
1966
- "Expected a supported delivery channel."
1967
- );
1968
- return;
1969
- }
1970
- r[o] = ht(
1971
- a,
1972
- `deliveryConfig.channelConfigs.${o}`,
1973
- n
1974
- );
1975
- }), Object.keys(r).length > 0 ? r : void 0;
1976
- }
1977
- function gt(t, n) {
1978
- var l, s, f;
1979
- if (t == null)
1980
- return null;
1981
- const e = g(t, "deliveryConfig", n);
1982
- p(
1983
- e,
1984
- "deliveryConfig",
1985
- ["recipients", "channels", "channelConfigs"],
1986
- n
1987
- );
1988
- const r = yt(e.channelConfigs, n), o = dt(e.recipients, n), a = lt(e.channels, n), i = ((s = (l = r == null ? void 0 : r.SLACK) == null ? void 0 : l.slackConfig) == null ? void 0 : s.destination.type) === "channel" && !!r.SLACK.slackConfig.destination.channelId.trim();
1989
- return a.some(
1990
- (v) => v !== "SLACK"
1991
- ) && o.length === 0 && d(
1992
- n,
1993
- "deliveryConfig.recipients",
1994
- "Add at least one recipient or remove delivery config."
1995
- ), a.length === 0 && d(
1996
- n,
1997
- "deliveryConfig.channels",
1998
- "Choose at least one delivery channel or remove delivery config."
1999
- ), a.includes("SLACK") && !i && d(
2000
- n,
2001
- "deliveryConfig.channelConfigs.SLACK.slackConfig.destination.channelId",
2002
- "Choose a Slack channel destination."
2003
- ), !a.includes("SLACK") && ((f = r == null ? void 0 : r.SLACK) != null && f.slackConfig) && d(
2004
- n,
2005
- "deliveryConfig.channelConfigs.SLACK",
2006
- "Slack config requires SLACK in deliveryConfig.channels."
2007
- ), {
2008
- recipients: o,
2009
- channels: a,
2010
- ...r ? { channelConfigs: r } : {}
2011
- };
2012
- }
2013
- function U(t) {
2014
- const n = [], e = g(t, "draft", n);
2015
- p(
2016
- e,
2017
- "draft",
2018
- [
2019
- "name",
2020
- "description",
2021
- "status",
2022
- "scheduleExpr",
2023
- "timezone",
2024
- "source",
2025
- "body",
2026
- "attachments",
2027
- "presentation",
2028
- "limits",
2029
- "deliveryConfig",
2030
- "resolvedFormats"
2031
- ],
2032
- n
2033
- );
2034
- const r = u(
2035
- e.name,
2036
- "name",
2037
- m.name,
2038
- n
2039
- ), o = h(
2040
- e.description,
2041
- "description",
2042
- m.description,
2043
- n
2044
- ) ?? null, a = h(e.scheduleExpr, "scheduleExpr", 500, n) ?? null, i = h(e.timezone, "timezone", 200, n) ?? "UTC", c = Ge(e.status, n), l = Q(e.source, n), s = ee(e.body, n), f = re(e.attachments, n), v = te(e.presentation, n), b = oe(e.limits, n), y = gt(e.deliveryConfig, n), k = ie(
2045
- e.resolvedFormats,
2046
- "resolvedFormats",
2047
- n
2048
- );
2049
- return ae(s, f, n), ce(
2050
- k,
2051
- f,
2052
- "resolvedFormats",
2053
- n
2054
- ), z(n), {
2055
- name: r,
2056
- description: o,
2057
- status: c,
2058
- scheduleExpr: a,
2059
- timezone: i,
2060
- source: l,
2061
- body: s,
2062
- attachments: f,
2063
- presentation: v,
2064
- ...b ? { limits: b } : {},
2065
- deliveryConfig: y,
2066
- ...k ? { resolvedFormats: k } : {}
2067
- };
2068
- }
2069
- function Ot(t) {
2070
- return U(t);
2071
- }
2072
- function Lt(t) {
2073
- return U(t);
2074
- }
2075
- function zt(t) {
2076
- try {
2077
- return { valid: !0, value: U(t), issues: [] };
2078
- } catch (n) {
2079
- if (n instanceof F)
2080
- return { valid: !1, issues: n.issues };
2081
- throw n;
2082
- }
2083
- }
2084
- function Vt(t) {
2085
- try {
2086
- return { valid: !0, value: de(t), issues: [] };
2087
- } catch (n) {
2088
- if (n instanceof F)
2089
- return { valid: !1, issues: n.issues };
2090
- throw n;
2091
- }
2092
- }
2093
- function Ut(t) {
2094
- return typeof t == "string" && J.has(t);
2095
- }
2096
- function le(t) {
2097
- return typeof t == "string" && Re.has(t);
2098
- }
3
+ import "../chunks/validators-DEmd8Sin.js";
4
+ import "../chunks/analyze-result-contract-BbRJ-C06.js";
5
+ import { a3 as t, a7 as f, a2 as g, a6 as o, ab as B, a4 as l, X as m, a5 as I, af as T, W as d, ah as C, A as E, ai as u, Z as F, d as p, aa as A, a9 as c, S as D, T as _, a as b, ao as R, g as N, an as S, al as h, am as y, a8 as G, Y as L, U as M, ac as U, ag as v, ae as V, V as z, ad as O, aj as x, ak as J } from "../chunks/index-Ca784dpx.js";
2099
6
  export {
2100
- _e as BRIEFING_ARTIFACT_FORMATS,
2101
- $ as BRIEFING_CONTENT_LIMITS,
2102
- R as BRIEFING_KIND,
2103
- m as BRIEFING_TEXT_LIMITS,
2104
- F as BriefingContractError,
2105
- O as DEFAULT_BRIEFING_ARTIFACT_FORMATS,
2106
- xt as DEFAULT_BRIEFING_SCHEDULE,
2107
- D as MAX_BRIEFING_ATTACHMENTS,
2108
- Rt as buildBriefingJobConfig,
2109
- At as buildBriefingScheduleExpr,
2110
- Ot as buildCreateBriefingRequest,
2111
- Lt as buildUpdateBriefingRequest,
2112
- Ft as canCreateBriefingForUser,
2113
- St as describeBriefingSchedule,
2114
- Bt as formatBriefingComparisonValues,
2115
- Ne as formatBriefingDisplayValue,
2116
- wt as getBriefingCardAttachmentCapability,
2117
- Se as getBriefingCardAttachmentFormats,
2118
- Dt as getBriefingCreationIntents,
2119
- De as getBriefingDisplayTypeLabel,
2120
- _t as getBriefingPresentation,
2121
- we as getDefaultBriefingCardAttachmentFormat,
2122
- Ut as isBriefingArtifactFormat,
2123
- le as isBriefingDeliveryChannel,
2124
- Be as isBriefingNumericValue,
2125
- Fe as isEmailOnlyBriefingDelivery,
2126
- Tt as isValidBriefingTimezone,
2127
- nt as normalizeBriefingContentDocument,
2128
- U as normalizeBriefingDraft,
2129
- de as normalizeBriefingJobConfig,
2130
- Ce as parseBriefingScheduleExpr,
2131
- Nt as validateBriefingContentDocument,
2132
- zt as validateBriefingDraft,
2133
- Vt as validateBriefingJobConfig
7
+ t as BRIEFING_ARTIFACT_FORMATS,
8
+ f as BRIEFING_CONTENT_LIMITS,
9
+ g as BRIEFING_KIND,
10
+ o as BRIEFING_TEXT_LIMITS,
11
+ B as BriefingContractError,
12
+ l as DEFAULT_BRIEFING_ARTIFACT_FORMATS,
13
+ m as DEFAULT_BRIEFING_SCHEDULE,
14
+ I as MAX_BRIEFING_ATTACHMENTS,
15
+ T as buildBriefingJobConfig,
16
+ d as buildBriefingScheduleExpr,
17
+ C as buildCreateBriefingRequest,
18
+ E as buildDashboardTemporalSnapshotEntries,
19
+ u as buildUpdateBriefingRequest,
20
+ F as canCreateBriefingForUser,
21
+ p as describeBriefingSchedule,
22
+ A as formatBriefingComparisonValues,
23
+ c as formatBriefingDisplayValue,
24
+ D as getBriefingCardAttachmentCapability,
25
+ _ as getBriefingCardAttachmentFormats,
26
+ b as getBriefingCreationIntents,
27
+ R as getBriefingDisplayTypeLabel,
28
+ N as getBriefingPresentation,
29
+ S as getDefaultBriefingCardAttachmentFormat,
30
+ h as isBriefingArtifactFormat,
31
+ y as isBriefingDeliveryChannel,
32
+ G as isBriefingNumericValue,
33
+ L as isEmailOnlyBriefingDelivery,
34
+ M as isValidBriefingTimezone,
35
+ U as normalizeBriefingContentDocument,
36
+ v as normalizeBriefingDraft,
37
+ V as normalizeBriefingJobConfig,
38
+ z as parseBriefingScheduleExpr,
39
+ O as validateBriefingContentDocument,
40
+ x as validateBriefingDraft,
41
+ J as validateBriefingJobConfig
2134
42
  };