react-semaphor 0.1.318 → 0.1.320

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 (32) hide show
  1. package/dist/briefings/index.cjs +1 -1
  2. package/dist/briefings/index.js +851 -358
  3. package/dist/chunks/{calendar-preferences-dialog-DgpoCz1l.js → calendar-preferences-dialog-B7Z8OnuZ.js} +1 -1
  4. package/dist/chunks/{calendar-preferences-dialog-DySStYHa.js → calendar-preferences-dialog-CFXQBJ4A.js} +1 -1
  5. package/dist/chunks/{dashboard-briefing-launcher-BrUNYrwk.js → dashboard-briefing-launcher-DB16djcj.js} +3095 -2391
  6. package/dist/chunks/dashboard-briefing-launcher-DjDpGyD7.js +106 -0
  7. package/dist/chunks/{dashboard-controls-CDCpt8iB.js → dashboard-controls-BisfskDD.js} +1 -1
  8. package/dist/chunks/{dashboard-controls-BJb7QHvl.js → dashboard-controls-DPStW1kd.js} +3 -3
  9. package/dist/chunks/{dashboard-json-BYEqzs6b.js → dashboard-json-2nyFJ_-w.js} +1 -1
  10. package/dist/chunks/{dashboard-json-BjFw0Ktj.js → dashboard-json-C8-kkiyT.js} +1 -1
  11. package/dist/chunks/{edit-dashboard-visual-IxtXVkBc.js → edit-dashboard-visual-BP77bJFI.js} +1 -1
  12. package/dist/chunks/{edit-dashboard-visual-VHlDJd5A.js → edit-dashboard-visual-D6oiTlXr.js} +3 -3
  13. package/dist/chunks/{index-CAWSZGCL.js → index-Clw0hJzi.js} +289 -288
  14. package/dist/chunks/{index-BhrZn1Zk.js → index-D8eouWYC.js} +75 -75
  15. package/dist/chunks/{resource-management-panel-X4zxZ4wq.js → resource-management-panel-DTvY5OIq.js} +1 -1
  16. package/dist/chunks/{resource-management-panel-0OlH_Gze.js → resource-management-panel-HcRJRZHO.js} +2 -2
  17. package/dist/chunks/{use-create-flow-overlay-state-WYyQFfGQ.js → use-create-flow-overlay-state-75l5mrVp.js} +2 -2
  18. package/dist/chunks/{use-create-flow-overlay-state-DkZTa6eN.js → use-create-flow-overlay-state-CdCldE6J.js} +1 -1
  19. package/dist/chunks/{use-visual-utils-C8VR6_Cr.js → use-visual-utils-Bd4Cf9_B.js} +1 -1
  20. package/dist/chunks/{use-visual-utils-2l8uDXRH.js → use-visual-utils-CMdEUnM5.js} +1 -1
  21. package/dist/dashboard/index.cjs +1 -1
  22. package/dist/dashboard/index.js +1 -1
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +5 -5
  25. package/dist/style.css +1 -1
  26. package/dist/surfboard/index.cjs +1 -1
  27. package/dist/surfboard/index.js +2 -2
  28. package/dist/types/briefings.d.ts +125 -1
  29. package/dist/types/main.d.ts +29 -1
  30. package/dist/types/types.d.ts +29 -1
  31. package/package.json +1 -1
  32. package/dist/chunks/dashboard-briefing-launcher-Fh6vC1S2.js +0 -101
@@ -1,36 +1,72 @@
1
- var P = Object.defineProperty;
2
- var G = (t, n, e) => n in t ? P(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
3
- var x = (t, n, e) => G(t, typeof n != "symbol" ? n + "" : n, e);
4
- const A = "BRIEFING", U = ["markdown", "html"], v = ["markdown"], ue = 20, c = {
1
+ var G = Object.defineProperty;
2
+ var U = (n, t, e) => t in n ? G(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
+ var z = (n, t, e) => U(n, typeof t != "symbol" ? t + "" : t, e);
4
+ const S = "BRIEFING", H = ["markdown", "html"], k = ["markdown"], Le = 20, l = {
5
5
  name: 500,
6
6
  description: 2e3,
7
7
  instruction: 5e4,
8
8
  customMessage: 5e4,
9
+ contentTitle: 500,
10
+ contentSummary: 2e4,
11
+ contentText: 5e3,
12
+ contentItem: 2e3,
13
+ contentCell: 500,
9
14
  attachmentTitle: 500,
10
15
  presentationAudience: 1e3,
11
16
  presentationTone: 500,
12
17
  presentationFormat: 2e3,
13
18
  id: 500
14
- }, z = new Set(U), H = /* @__PURE__ */ new Set([
19
+ }, g = {
20
+ maxBlocks: 50,
21
+ maxTableRows: 100,
22
+ maxTableColumns: 20,
23
+ maxTableCellCharacters: l.contentCell,
24
+ maxParagraphCharacters: l.contentText,
25
+ maxFindingCharacters: l.contentText,
26
+ maxListItems: 100
27
+ }, D = new Set(H), X = /* @__PURE__ */ new Set([
15
28
  "EMAIL",
16
29
  "WEBHOOK",
17
30
  "SLACK",
18
31
  "IN_APP",
19
32
  "TELEGRAM"
20
- ]), $ = {
33
+ ]), T = {
21
34
  maxToolCalls: { min: 1, max: 100 },
22
35
  maxRows: { min: 1, max: 1e5 },
23
36
  timeoutMs: { min: 1e3, max: 30 * 6e4 }
24
- }, q = /* @__PURE__ */ new Set([
37
+ }, J = /* @__PURE__ */ new Set([
25
38
  "letter",
26
39
  "legal",
27
40
  "a4",
28
41
  "a3",
29
42
  "tabloid"
30
- ]), K = /* @__PURE__ */ new Set([
43
+ ]), W = /* @__PURE__ */ new Set([
31
44
  "portrait",
32
45
  "landscape"
33
- ]), X = /* @__PURE__ */ new Set([",", ";", " "]), J = [
46
+ ]), Y = /* @__PURE__ */ new Set([",", ";", " "]), Z = /* @__PURE__ */ new Set([
47
+ "current",
48
+ "all"
49
+ ]), Q = /* @__PURE__ */ new Set([
50
+ "concise",
51
+ "balanced",
52
+ "detailed"
53
+ ]), ee = /* @__PURE__ */ new Set([
54
+ "info",
55
+ "positive",
56
+ "warning",
57
+ "critical"
58
+ ]), te = /* @__PURE__ */ new Set([
59
+ "text",
60
+ "number",
61
+ "currency",
62
+ "percent",
63
+ "date",
64
+ "boolean"
65
+ ]), ne = /* @__PURE__ */ new Set([
66
+ "left",
67
+ "center",
68
+ "right"
69
+ ]), re = [
34
70
  "pageSize",
35
71
  "orientation",
36
72
  "includeFilters",
@@ -55,112 +91,137 @@ const A = "BRIEFING", U = ["markdown", "html"], v = ["markdown"], ue = 20, c = {
55
91
  "cardType",
56
92
  "theme"
57
93
  ];
58
- class S extends Error {
94
+ class A extends Error {
59
95
  constructor(e) {
60
96
  super(e.map((r) => `${r.field}: ${r.message}`).join("; "));
61
- x(this, "issues");
97
+ z(this, "issues");
62
98
  this.name = "BriefingContractError", this.issues = e;
63
99
  }
64
100
  }
65
- function F(t) {
66
- return typeof t == "object" && t !== null && !Array.isArray(t);
101
+ function N(n) {
102
+ return typeof n == "object" && n !== null && !Array.isArray(n);
67
103
  }
68
- function d(t, n, e) {
69
- t.push({ field: n, message: e });
104
+ function c(n, t, e) {
105
+ n.push({ field: t, message: e });
70
106
  }
71
- function m(t, n, e) {
72
- return F(t) ? t : (d(e, n, "Expected an object."), {});
107
+ function h(n, t, e) {
108
+ return N(n) ? n : (c(e, t, "Expected an object."), {});
73
109
  }
74
- function l(t, n, e, r) {
110
+ function f(n, t, e, r) {
75
111
  const o = new Set(e);
76
- Object.keys(t).forEach((i) => {
77
- o.has(i) || d(
112
+ Object.keys(n).forEach((i) => {
113
+ o.has(i) || c(
78
114
  r,
79
- n ? `${n}.${i}` : i,
115
+ t ? `${t}.${i}` : i,
80
116
  `Unexpected field "${i}".`
81
117
  );
82
118
  });
83
119
  }
84
- function f(t, n, e, r) {
85
- if (typeof t != "string")
86
- return d(r, n, "Expected a string."), "";
87
- const o = t.trim();
88
- return o ? (o.length > e && d(r, n, `Must be ${e} characters or fewer.`), o) : (d(r, n, "Required value cannot be empty."), "");
120
+ function u(n, t, e, r) {
121
+ if (typeof n != "string")
122
+ return c(r, t, "Expected a string."), "";
123
+ const o = n.trim();
124
+ return o ? (o.length > e && c(r, t, `Must be ${e} characters or fewer.`), o) : (c(r, t, "Required value cannot be empty."), "");
89
125
  }
90
- function u(t, n, e, r) {
91
- if (t == null)
126
+ function y(n, t, e, r) {
127
+ if (n == null)
92
128
  return;
93
- if (typeof t != "string") {
94
- d(r, n, "Expected a string.");
129
+ if (typeof n != "string") {
130
+ c(r, t, "Expected a string.");
95
131
  return;
96
132
  }
97
- const o = t.trim();
133
+ const o = n.trim();
98
134
  if (o)
99
- return o.length > e && d(r, n, `Must be ${e} characters or fewer.`), o;
135
+ return o.length > e && c(r, t, `Must be ${e} characters or fewer.`), o;
100
136
  }
101
- function C(t, n, e, r) {
102
- return t == null ? n : typeof t != "boolean" ? (d(r, e, "Expected a boolean."), n) : t;
137
+ function oe(n, t, e) {
138
+ if (n != null) {
139
+ if (!Number.isInteger(n) || Number(n) < 0) {
140
+ c(e, t, "Expected a non-negative integer.");
141
+ return;
142
+ }
143
+ return Number(n);
144
+ }
103
145
  }
104
- function W(t, n) {
105
- return t == null ? "ACTIVE" : t === "ACTIVE" || t === "PAUSED" || t === "DISABLED" ? t : (d(n, "status", "Expected ACTIVE, PAUSED, or DISABLED."), "ACTIVE");
146
+ function b(n, t, e, r = {}) {
147
+ if (n == null)
148
+ return r.required ? (c(e, t, "Expected at least one evidence id."), []) : void 0;
149
+ if (!Array.isArray(n))
150
+ return c(e, t, "Expected an array."), r.required ? [] : void 0;
151
+ const o = [];
152
+ return n.forEach((i, a) => {
153
+ const d = u(
154
+ i,
155
+ `${t}.${a}`,
156
+ l.id,
157
+ e
158
+ );
159
+ d && !o.includes(d) && o.push(d);
160
+ }), r.required && o.length === 0 && c(e, t, "Expected at least one evidence id."), o.length > 0 || r.required ? o : void 0;
161
+ }
162
+ function $(n, t, e, r) {
163
+ return n == null ? t : typeof n != "boolean" ? (c(r, e, "Expected a boolean."), t) : n;
106
164
  }
107
- function Y(t) {
108
- return t.includes("@") && t.includes(".") && !t.includes(" ");
165
+ function ie(n, t) {
166
+ return n == null ? "ACTIVE" : n === "ACTIVE" || n === "PAUSED" || n === "DISABLED" ? n : (c(t, "status", "Expected ACTIVE, PAUSED, or DISABLED."), "ACTIVE");
109
167
  }
110
- function O(t, n) {
111
- if (t == null)
168
+ function ae(n) {
169
+ return n.includes("@") && n.includes(".") && !n.includes(" ");
170
+ }
171
+ function O(n, t) {
172
+ if (n == null)
112
173
  return { type: "project" };
113
- const e = m(t, "source", n), r = e.type;
114
- return r === "project" ? (l(e, "source", ["type"], n), { type: "project" }) : r === "dashboard" ? (l(e, "source", ["type", "dashboardId"], n), {
174
+ const e = h(n, "source", t), r = e.type;
175
+ return r === "project" ? (f(e, "source", ["type"], t), { type: "project" }) : r === "dashboard" ? (f(e, "source", ["type", "dashboardId"], t), {
115
176
  type: "dashboard",
116
- dashboardId: f(
177
+ dashboardId: u(
117
178
  e.dashboardId,
118
179
  "source.dashboardId",
119
- c.id,
120
- n
180
+ l.id,
181
+ t
121
182
  )
122
- }) : (d(n, "source.type", "Expected project or dashboard."), { type: "project" });
183
+ }) : (c(t, "source.type", "Expected project or dashboard."), { type: "project" });
123
184
  }
124
- function B(t, n) {
125
- const e = m(t, "body", n), r = e.type;
126
- return r === "generated_analysis" ? (l(e, "body", ["type", "instruction"], n), {
185
+ function R(n, t) {
186
+ const e = h(n, "body", t), r = e.type;
187
+ return r === "generated_analysis" ? (f(e, "body", ["type", "instruction"], t), {
127
188
  type: "generated_analysis",
128
- instruction: f(
189
+ instruction: u(
129
190
  e.instruction,
130
191
  "body.instruction",
131
- c.instruction,
132
- n
192
+ l.instruction,
193
+ t
133
194
  )
134
- }) : r === "custom_message" ? (l(e, "body", ["type", "message"], n), {
195
+ }) : r === "custom_message" ? (f(e, "body", ["type", "message"], t), {
135
196
  type: "custom_message",
136
- message: f(
197
+ message: u(
137
198
  e.message,
138
199
  "body.message",
139
- c.customMessage,
140
- n
200
+ l.customMessage,
201
+ t
141
202
  )
142
- }) : r === "none" ? (l(e, "body", ["type"], n), { type: "none" }) : (d(
143
- n,
203
+ }) : r === "none" ? (f(e, "body", ["type"], t), { type: "none" }) : (c(
204
+ t,
144
205
  "body.type",
145
206
  "Expected generated_analysis, custom_message, or none."
146
207
  ), { type: "none" });
147
208
  }
148
- function Z(t, n) {
149
- if (t == null)
150
- return [...v];
151
- if (!Array.isArray(t))
152
- return d(n, "presentation.artifactFormats", "Expected an array."), [...v];
153
- if (t.length === 0)
154
- return d(
155
- n,
209
+ function ce(n, t) {
210
+ if (n == null)
211
+ return [...k];
212
+ if (!Array.isArray(n))
213
+ return c(t, "presentation.artifactFormats", "Expected an array."), [...k];
214
+ if (n.length === 0)
215
+ return c(
216
+ t,
156
217
  "presentation.artifactFormats",
157
218
  "Choose at least one artifact format."
158
219
  ), [];
159
220
  const e = [];
160
- return t.forEach((r, o) => {
161
- if (typeof r != "string" || !z.has(r)) {
162
- d(
163
- n,
221
+ return n.forEach((r, o) => {
222
+ if (typeof r != "string" || !D.has(r)) {
223
+ c(
224
+ t,
164
225
  `presentation.artifactFormats.${o}`,
165
226
  "Expected markdown or html."
166
227
  );
@@ -169,111 +230,414 @@ function Z(t, n) {
169
230
  e.includes(r) || e.push(r);
170
231
  }), e;
171
232
  }
172
- function R(t, n) {
173
- if (t == null)
233
+ function F(n, t) {
234
+ if (n == null)
174
235
  return {
175
- artifactFormats: [...v],
236
+ artifactFormats: [...k],
176
237
  includeEvidence: !0,
177
238
  includeSql: !0
178
239
  };
179
- const e = m(t, "presentation", n);
180
- l(
240
+ const e = h(n, "presentation", t);
241
+ f(
181
242
  e,
182
243
  "presentation",
183
244
  ["artifactFormats", "includeEvidence", "includeSql", "audience", "tone", "format"],
184
- n
245
+ t
185
246
  );
186
247
  const r = {
187
- artifactFormats: Z(e.artifactFormats, n),
188
- includeEvidence: C(
248
+ artifactFormats: ce(e.artifactFormats, t),
249
+ includeEvidence: $(
189
250
  e.includeEvidence,
190
251
  !0,
191
252
  "presentation.includeEvidence",
192
- n
253
+ t
193
254
  ),
194
- includeSql: C(
255
+ includeSql: $(
195
256
  e.includeSql,
196
257
  !0,
197
258
  "presentation.includeSql",
198
- n
259
+ t
199
260
  )
200
- }, o = u(
261
+ }, o = y(
201
262
  e.audience,
202
263
  "presentation.audience",
203
- c.presentationAudience,
204
- n
205
- ), i = u(
264
+ l.presentationAudience,
265
+ t
266
+ ), i = y(
206
267
  e.tone,
207
268
  "presentation.tone",
208
- c.presentationTone,
209
- n
210
- ), a = u(
269
+ l.presentationTone,
270
+ t
271
+ ), a = y(
211
272
  e.format,
212
273
  "presentation.format",
213
- c.presentationFormat,
214
- n
274
+ l.presentationFormat,
275
+ t
215
276
  );
216
277
  return o && (r.audience = o), i && (r.tone = i), a && (r.format = a), r;
217
278
  }
218
- function g(t, n, e, r) {
219
- return typeof t == "string" && e.includes(t) ? t : (d(r, n, `Expected ${e.join(" or ")}.`), e[0]);
279
+ function de(n, t, e) {
280
+ return Array.isArray(n) ? (n.length === 0 && c(e, t, "Expected at least one item."), n.length > g.maxListItems && c(
281
+ e,
282
+ t,
283
+ `Must have ${g.maxListItems} items or fewer.`
284
+ ), n.slice(0, g.maxListItems).map(
285
+ (r, o) => u(
286
+ r,
287
+ `${t}.${o}`,
288
+ l.contentItem,
289
+ e
290
+ )
291
+ ).filter(Boolean)) : (c(e, t, "Expected an array."), []);
292
+ }
293
+ function le(n, t, e) {
294
+ return n === null || typeof n == "string" || typeof n == "number" || typeof n == "boolean" ? typeof n == "string" && n.length > l.contentCell ? (c(
295
+ e,
296
+ t,
297
+ `Must be ${l.contentCell} characters or fewer.`
298
+ ), n.slice(0, l.contentCell)) : typeof n == "number" && !Number.isFinite(n) ? (c(e, t, "Expected a finite number."), null) : n : (c(e, t, "Expected a string, number, boolean, or null."), null);
299
+ }
300
+ function se(n, t, e) {
301
+ if (!Array.isArray(n))
302
+ return c(e, t, "Expected an array."), [];
303
+ n.length === 0 && c(e, t, "Expected at least one column."), n.length > g.maxTableColumns && c(
304
+ e,
305
+ t,
306
+ `Must have ${g.maxTableColumns} columns or fewer.`
307
+ );
308
+ const r = /* @__PURE__ */ new Set();
309
+ return n.slice(0, g.maxTableColumns).map((o, i) => {
310
+ const a = `${t}.${i}`, d = h(o, a, e);
311
+ f(d, a, ["key", "label", "kind", "align"], e);
312
+ const m = u(
313
+ d.key,
314
+ `${a}.key`,
315
+ l.id,
316
+ e
317
+ );
318
+ m && (r.has(m) && c(e, `${a}.key`, "Column key must be unique."), r.add(m));
319
+ const s = u(
320
+ d.label,
321
+ `${a}.label`,
322
+ l.contentTitle,
323
+ e
324
+ ), p = I(
325
+ d.kind,
326
+ `${a}.kind`,
327
+ te,
328
+ "text, number, currency, percent, date, or boolean",
329
+ e
330
+ ), v = I(
331
+ d.align,
332
+ `${a}.align`,
333
+ ne,
334
+ "left, center, or right",
335
+ e
336
+ );
337
+ return {
338
+ key: m,
339
+ label: s,
340
+ ...p ? { kind: p } : {},
341
+ ...v ? { align: v } : {}
342
+ };
343
+ });
344
+ }
345
+ function fe(n, t, e, r) {
346
+ if (!Array.isArray(n))
347
+ return c(r, t, "Expected an array."), [];
348
+ n.length > g.maxTableRows && c(
349
+ r,
350
+ t,
351
+ `Must have ${g.maxTableRows} rows or fewer.`
352
+ );
353
+ const o = new Set(e.map((i) => i.key).filter(Boolean));
354
+ return n.slice(0, g.maxTableRows).map((i, a) => {
355
+ const d = `${t}.${a}`, m = h(i, d, r);
356
+ return Object.keys(m).forEach((s) => {
357
+ o.has(s) || c(r, `${d}.${s}`, `Unexpected table cell "${s}".`);
358
+ }), Object.fromEntries(
359
+ e.map((s) => [
360
+ s.key,
361
+ le(m[s.key] ?? null, `${d}.${s.key}`, r)
362
+ ])
363
+ );
364
+ });
220
365
  }
221
- function I(t, n, e, r, o) {
222
- if (t != null) {
223
- if (typeof t == "string" && e.has(t))
224
- return t;
225
- d(o, n, `Expected ${r}.`);
366
+ function me(n, t, e) {
367
+ const r = `content.blocks.${t}`, o = h(n, r, e), i = o.type;
368
+ if (i === "heading") {
369
+ f(o, r, ["type", "text", "level", "evidenceIds"], e);
370
+ const a = o.level === void 0 || o.level === null ? void 0 : o.level === 2 || o.level === 3 ? o.level : void 0;
371
+ o.level !== void 0 && o.level !== null && a === void 0 && c(e, `${r}.level`, "Expected 2 or 3.");
372
+ const d = b(o.evidenceIds, `${r}.evidenceIds`, e);
373
+ return {
374
+ type: "heading",
375
+ text: u(
376
+ o.text,
377
+ `${r}.text`,
378
+ l.contentTitle,
379
+ e
380
+ ),
381
+ ...a ? { level: a } : {},
382
+ ...d ? { evidenceIds: d } : {}
383
+ };
226
384
  }
385
+ if (i === "paragraph") {
386
+ f(o, r, ["type", "text", "evidenceIds"], e);
387
+ const a = b(o.evidenceIds, `${r}.evidenceIds`, e);
388
+ return {
389
+ type: "paragraph",
390
+ text: u(
391
+ o.text,
392
+ `${r}.text`,
393
+ l.contentText,
394
+ e
395
+ ),
396
+ ...a ? { evidenceIds: a } : {}
397
+ };
398
+ }
399
+ if (i === "finding") {
400
+ f(o, r, ["type", "title", "text", "severity", "evidenceIds"], e);
401
+ const a = y(
402
+ o.title,
403
+ `${r}.title`,
404
+ l.contentTitle,
405
+ e
406
+ ), d = I(
407
+ o.severity,
408
+ `${r}.severity`,
409
+ ee,
410
+ "info, positive, warning, or critical",
411
+ e
412
+ );
413
+ return {
414
+ type: "finding",
415
+ ...a ? { title: a } : {},
416
+ text: u(
417
+ o.text,
418
+ `${r}.text`,
419
+ l.contentText,
420
+ e
421
+ ),
422
+ ...d ? { severity: d } : {},
423
+ evidenceIds: b(o.evidenceIds, `${r}.evidenceIds`, e, {
424
+ required: !0
425
+ }) ?? []
426
+ };
427
+ }
428
+ if (i === "bullets" || i === "actions" || i === "limitations") {
429
+ f(o, r, ["type", "title", "items", "evidenceIds"], e);
430
+ const a = y(
431
+ o.title,
432
+ `${r}.title`,
433
+ l.contentTitle,
434
+ e
435
+ ), d = b(o.evidenceIds, `${r}.evidenceIds`, e);
436
+ return {
437
+ type: i,
438
+ ...a ? { title: a } : {},
439
+ items: de(o.items, `${r}.items`, e),
440
+ ...d ? { evidenceIds: d } : {}
441
+ };
442
+ }
443
+ if (i === "metric") {
444
+ f(
445
+ o,
446
+ r,
447
+ ["type", "label", "value", "previousValue", "delta", "unit", "evidenceIds"],
448
+ e
449
+ );
450
+ const a = typeof o.value == "string" || typeof o.value == "number" ? o.value : "";
451
+ a === "" && c(e, `${r}.value`, "Expected a string or number.");
452
+ const d = o.previousValue === void 0 || o.previousValue === null || typeof o.previousValue == "string" || typeof o.previousValue == "number" ? o.previousValue : void 0;
453
+ o.previousValue !== void 0 && o.previousValue !== null && d === void 0 && c(e, `${r}.previousValue`, "Expected a string, number, or null.");
454
+ const m = o.delta === void 0 || o.delta === null || typeof o.delta == "string" || typeof o.delta == "number" ? o.delta : void 0;
455
+ o.delta !== void 0 && o.delta !== null && m === void 0 && c(e, `${r}.delta`, "Expected a string, number, or null.");
456
+ const s = y(
457
+ o.unit,
458
+ `${r}.unit`,
459
+ l.contentTitle,
460
+ e
461
+ ), p = b(o.evidenceIds, `${r}.evidenceIds`, e);
462
+ return {
463
+ type: "metric",
464
+ label: u(
465
+ o.label,
466
+ `${r}.label`,
467
+ l.contentTitle,
468
+ e
469
+ ),
470
+ value: a,
471
+ ...d !== void 0 ? { previousValue: d } : {},
472
+ ...m !== void 0 ? { delta: m } : {},
473
+ ...s ? { unit: s } : {},
474
+ ...p ? { evidenceIds: p } : {}
475
+ };
476
+ }
477
+ if (i === "table") {
478
+ f(
479
+ o,
480
+ r,
481
+ ["type", "id", "title", "columns", "rows", "caption", "totalRows", "evidenceIds"],
482
+ e
483
+ );
484
+ const a = se(o.columns, `${r}.columns`, e), d = y(
485
+ o.title,
486
+ `${r}.title`,
487
+ l.contentTitle,
488
+ e
489
+ ), m = y(
490
+ o.id,
491
+ `${r}.id`,
492
+ l.id,
493
+ e
494
+ ), s = y(
495
+ o.caption,
496
+ `${r}.caption`,
497
+ l.contentItem,
498
+ e
499
+ ), p = oe(
500
+ o.totalRows,
501
+ `${r}.totalRows`,
502
+ e
503
+ ), v = b(o.evidenceIds, `${r}.evidenceIds`, e);
504
+ return {
505
+ type: "table",
506
+ ...m ? { id: m } : {},
507
+ ...d ? { title: d } : {},
508
+ columns: a,
509
+ rows: fe(o.rows, `${r}.rows`, a, e),
510
+ ...s ? { caption: s } : {},
511
+ ...p !== void 0 ? { totalRows: p } : {},
512
+ ...v ? { evidenceIds: v } : {}
513
+ };
514
+ }
515
+ if (i === "evidence_appendix") {
516
+ f(o, r, ["type", "title", "evidenceIds"], e);
517
+ const a = y(
518
+ o.title,
519
+ `${r}.title`,
520
+ l.contentTitle,
521
+ e
522
+ );
523
+ return {
524
+ type: "evidence_appendix",
525
+ ...a ? { title: a } : {},
526
+ evidenceIds: b(o.evidenceIds, `${r}.evidenceIds`, e, {
527
+ required: !0
528
+ }) ?? []
529
+ };
530
+ }
531
+ return c(
532
+ e,
533
+ `${r}.type`,
534
+ "Expected heading, paragraph, finding, bullets, metric, table, actions, limitations, or evidence_appendix."
535
+ ), {
536
+ type: "paragraph",
537
+ text: ""
538
+ };
227
539
  }
228
- function Q(t, n, e) {
229
- if (t != null) {
230
- if (!Array.isArray(t)) {
231
- d(e, n, "Expected an array.");
540
+ function pe(n) {
541
+ const t = [], e = h(n, "content", t);
542
+ f(e, "content", ["version", "title", "summary", "blocks"], t), e.version !== 1 && c(t, "content.version", "Expected version 1.");
543
+ const r = y(
544
+ e.title,
545
+ "content.title",
546
+ l.contentTitle,
547
+ t
548
+ ), o = y(
549
+ e.summary,
550
+ "content.summary",
551
+ l.contentSummary,
552
+ t
553
+ );
554
+ Array.isArray(e.blocks) || c(t, "content.blocks", "Expected an array.");
555
+ const i = Array.isArray(e.blocks) ? e.blocks : [];
556
+ i.length === 0 && c(t, "content.blocks", "Expected at least one block."), i.length > g.maxBlocks && c(
557
+ t,
558
+ "content.blocks",
559
+ `Must have ${g.maxBlocks} blocks or fewer.`
560
+ );
561
+ const a = i.slice(0, g.maxBlocks).map((d, m) => me(d, m, t));
562
+ return _(t), {
563
+ version: 1,
564
+ ...r ? { title: r } : {},
565
+ ...o ? { summary: o } : {},
566
+ blocks: a
567
+ };
568
+ }
569
+ function we(n) {
570
+ try {
571
+ return {
572
+ valid: !0,
573
+ value: pe(n),
574
+ issues: []
575
+ };
576
+ } catch (t) {
577
+ if (t instanceof A)
578
+ return { valid: !1, issues: t.issues };
579
+ throw t;
580
+ }
581
+ }
582
+ function E(n, t, e, r) {
583
+ return typeof n == "string" && e.includes(n) ? n : (c(r, t, `Expected ${e.join(" or ")}.`), e[0]);
584
+ }
585
+ function I(n, t, e, r, o) {
586
+ if (n != null) {
587
+ if (typeof n == "string" && e.has(n))
588
+ return n;
589
+ c(o, t, `Expected ${r}.`);
590
+ }
591
+ }
592
+ function ue(n, t, e) {
593
+ if (n != null) {
594
+ if (!Array.isArray(n)) {
595
+ c(e, t, "Expected an array.");
232
596
  return;
233
597
  }
234
- return t;
598
+ return n;
235
599
  }
236
600
  }
237
- function ee(t, n, e) {
238
- if (t != null) {
239
- if (!F(t)) {
240
- d(e, n, "Expected an object.");
601
+ function ye(n, t, e) {
602
+ if (n != null) {
603
+ if (!N(n)) {
604
+ c(e, t, "Expected an object.");
241
605
  return;
242
606
  }
243
- return t;
607
+ return n;
244
608
  }
245
609
  }
246
- function te(t, n, e) {
247
- if (t == null)
610
+ function he(n, t, e) {
611
+ if (n == null)
248
612
  return;
249
- const r = m(t, n, e);
250
- l(r, n, J, e);
613
+ const r = h(n, t, e);
614
+ f(r, t, re, e);
251
615
  const o = {}, i = I(
252
616
  r.pageSize,
253
- `${n}.pageSize`,
254
- q,
617
+ `${t}.pageSize`,
618
+ J,
255
619
  "letter, legal, a4, a3, or tabloid",
256
620
  e
257
621
  ), a = I(
258
622
  r.orientation,
259
- `${n}.orientation`,
260
- K,
623
+ `${t}.orientation`,
624
+ W,
261
625
  "portrait or landscape",
262
626
  e
263
- ), p = I(
627
+ ), d = I(
264
628
  r.delimiter,
265
- `${n}.delimiter`,
266
- X,
629
+ `${t}.delimiter`,
630
+ Y,
267
631
  "comma, semicolon, or tab",
268
632
  e
269
- ), y = I(
633
+ ), m = I(
270
634
  r.sheetSelection,
271
- `${n}.sheetSelection`,
272
- /* @__PURE__ */ new Set(["current", "all"]),
635
+ `${t}.sheetSelection`,
636
+ Z,
273
637
  "current or all",
274
638
  e
275
639
  );
276
- i && (o.pageSize = i), a && (o.orientation = a), p && (o.delimiter = p), y && (o.sheetSelection = y);
640
+ i && (o.pageSize = i), a && (o.orientation = a), d && (o.delimiter = d), m && (o.sheetSelection = m);
277
641
  for (const s of [
278
642
  "includeFilters",
279
643
  "includeTimestamp",
@@ -282,7 +646,7 @@ function te(t, n, e) {
282
646
  ])
283
647
  if (!(r[s] === void 0 || r[s] === null)) {
284
648
  if (typeof r[s] != "boolean") {
285
- d(e, `${n}.${s}`, "Expected a boolean.");
649
+ c(e, `${t}.${s}`, "Expected a boolean.");
286
650
  continue;
287
651
  }
288
652
  o[s] = r[s];
@@ -295,13 +659,13 @@ function te(t, n, e) {
295
659
  "cardType",
296
660
  "theme"
297
661
  ]) {
298
- const h = u(
662
+ const p = y(
299
663
  r[s],
300
- `${n}.${s}`,
301
- c.id,
664
+ `${t}.${s}`,
665
+ l.id,
302
666
  e
303
667
  );
304
- h && (o[s] = h);
668
+ p && (o[s] = p);
305
669
  }
306
670
  for (const s of [
307
671
  "filterValues",
@@ -311,111 +675,111 @@ function te(t, n, e) {
311
675
  "cardControlDefinitions",
312
676
  "controlBindings"
313
677
  ]) {
314
- const h = Q(r[s], `${n}.${s}`, e);
315
- h && (o[s] = h);
678
+ const p = ue(r[s], `${t}.${s}`, e);
679
+ p && (o[s] = p);
316
680
  }
317
681
  for (const s of [
318
682
  "controlValues",
319
683
  "tablePreferences",
320
684
  "dashboardInputExecutionSnapshot"
321
685
  ]) {
322
- const h = ee(r[s], `${n}.${s}`, e);
323
- h && (o[s] = h);
686
+ const p = ye(r[s], `${t}.${s}`, e);
687
+ p && (o[s] = p);
324
688
  }
325
689
  return Object.keys(o).length > 0 ? o : void 0;
326
690
  }
327
- function b(t, n, e, r) {
328
- const o = u(
329
- n,
691
+ function C(n, t, e, r) {
692
+ const o = y(
693
+ t,
330
694
  e,
331
- c.attachmentTitle,
695
+ l.attachmentTitle,
332
696
  r
333
697
  );
334
- return o && (t.title = o), t;
698
+ return o && (n.title = o), n;
335
699
  }
336
- function E(t, n, e, r) {
337
- const o = te(n, e, r);
338
- return o && (t.settings = o), t;
700
+ function x(n, t, e, r) {
701
+ const o = he(t, e, r);
702
+ return o && (n.settings = o), n;
339
703
  }
340
- function ne(t, n, e) {
341
- const r = `attachments.${n}`, o = m(t, r, e), i = o.type;
704
+ function ge(n, t, e) {
705
+ const r = `attachments.${t}`, o = h(n, r, e), i = o.type;
342
706
  if (i === "dashboard") {
343
- l(
707
+ f(
344
708
  o,
345
709
  r,
346
710
  ["type", "dashboardId", "format", "title", "settings"],
347
711
  e
348
712
  );
349
- const a = b(
713
+ const a = C(
350
714
  {
351
715
  type: "dashboard",
352
- dashboardId: f(
716
+ dashboardId: u(
353
717
  o.dashboardId,
354
718
  `${r}.dashboardId`,
355
- c.id,
719
+ l.id,
356
720
  e
357
721
  ),
358
- format: g(o.format, `${r}.format`, ["pdf"], e)
722
+ format: E(o.format, `${r}.format`, ["pdf"], e)
359
723
  },
360
724
  o.title,
361
725
  `${r}.title`,
362
726
  e
363
727
  );
364
- return E(a, o.settings, `${r}.settings`, e);
728
+ return x(a, o.settings, `${r}.settings`, e);
365
729
  }
366
730
  if (i === "dashboard_sheet" || i === "document_sheet") {
367
- l(
731
+ f(
368
732
  o,
369
733
  r,
370
734
  ["type", "dashboardId", "sheetId", "format", "title", "settings"],
371
735
  e
372
736
  );
373
- const a = b(
737
+ const a = C(
374
738
  {
375
739
  type: i,
376
- dashboardId: f(
740
+ dashboardId: u(
377
741
  o.dashboardId,
378
742
  `${r}.dashboardId`,
379
- c.id,
743
+ l.id,
380
744
  e
381
745
  ),
382
- sheetId: f(
746
+ sheetId: u(
383
747
  o.sheetId,
384
748
  `${r}.sheetId`,
385
- c.id,
749
+ l.id,
386
750
  e
387
751
  ),
388
- format: g(o.format, `${r}.format`, ["pdf"], e)
752
+ format: E(o.format, `${r}.format`, ["pdf"], e)
389
753
  },
390
754
  o.title,
391
755
  `${r}.title`,
392
756
  e
393
757
  );
394
- return E(a, o.settings, `${r}.settings`, e);
758
+ return x(a, o.settings, `${r}.settings`, e);
395
759
  }
396
760
  if (i === "visual") {
397
- l(
761
+ f(
398
762
  o,
399
763
  r,
400
764
  ["type", "dashboardId", "visualId", "format", "title", "settings"],
401
765
  e
402
766
  );
403
- const a = b(
767
+ const a = C(
404
768
  {
405
769
  type: "visual",
406
- dashboardId: f(
770
+ dashboardId: u(
407
771
  o.dashboardId,
408
772
  `${r}.dashboardId`,
409
- c.id,
773
+ l.id,
410
774
  e
411
775
  ),
412
- visualId: f(
776
+ visualId: u(
413
777
  o.visualId,
414
778
  `${r}.visualId`,
415
- c.id,
779
+ l.id,
416
780
  e
417
781
  ),
418
- format: g(
782
+ format: E(
419
783
  o.format,
420
784
  `${r}.format`,
421
785
  ["pdf", "png"],
@@ -426,31 +790,31 @@ function ne(t, n, e) {
426
790
  `${r}.title`,
427
791
  e
428
792
  );
429
- return E(a, o.settings, `${r}.settings`, e);
793
+ return x(a, o.settings, `${r}.settings`, e);
430
794
  }
431
795
  if (i === "card") {
432
- l(
796
+ f(
433
797
  o,
434
798
  r,
435
799
  ["type", "dashboardId", "cardId", "format", "title", "settings"],
436
800
  e
437
801
  );
438
- const a = b(
802
+ const a = C(
439
803
  {
440
804
  type: "card",
441
- dashboardId: f(
805
+ dashboardId: u(
442
806
  o.dashboardId,
443
807
  `${r}.dashboardId`,
444
- c.id,
808
+ l.id,
445
809
  e
446
810
  ),
447
- cardId: f(
811
+ cardId: u(
448
812
  o.cardId,
449
813
  `${r}.cardId`,
450
- c.id,
814
+ l.id,
451
815
  e
452
816
  ),
453
- format: g(
817
+ format: E(
454
818
  o.format,
455
819
  `${r}.format`,
456
820
  ["csv", "pdf", "png"],
@@ -461,57 +825,57 @@ function ne(t, n, e) {
461
825
  `${r}.title`,
462
826
  e
463
827
  );
464
- return E(a, o.settings, `${r}.settings`, e);
828
+ return x(a, o.settings, `${r}.settings`, e);
465
829
  }
466
- return d(
830
+ return c(
467
831
  e,
468
832
  `${r}.type`,
469
833
  "Expected dashboard, dashboard_sheet, document_sheet, visual, or card."
470
834
  ), { type: "dashboard", dashboardId: "", format: "pdf" };
471
835
  }
472
- function re(t) {
473
- switch (t.type) {
836
+ function ve(n) {
837
+ switch (n.type) {
474
838
  case "dashboard":
475
- return `${t.type}:${t.dashboardId}:${t.format}`;
839
+ return `${n.type}:${n.dashboardId}:${n.format}`;
476
840
  case "dashboard_sheet":
477
841
  case "document_sheet":
478
- return `${t.type}:${t.dashboardId}:${t.sheetId}:${t.format}`;
842
+ return `${n.type}:${n.dashboardId}:${n.sheetId}:${n.format}`;
479
843
  case "visual":
480
- return `${t.type}:${t.dashboardId}:${t.visualId}:${t.format}`;
844
+ return `${n.type}:${n.dashboardId}:${n.visualId}:${n.format}`;
481
845
  case "card":
482
- return `${t.type}:${t.dashboardId}:${t.cardId}:${t.format}`;
846
+ return `${n.type}:${n.dashboardId}:${n.cardId}:${n.format}`;
483
847
  }
484
848
  }
485
- function D(t, n) {
486
- if (t == null)
849
+ function V(n, t) {
850
+ if (n == null)
487
851
  return [];
488
- if (!Array.isArray(t))
489
- return d(n, "attachments", "Expected an array."), [];
490
- t.length > 20 && d(
491
- n,
852
+ if (!Array.isArray(n))
853
+ return c(t, "attachments", "Expected an array."), [];
854
+ n.length > 20 && c(
855
+ t,
492
856
  "attachments",
493
857
  "Choose 20 attachments or fewer."
494
858
  );
495
- const e = t.slice(0, 20).map((o, i) => ne(o, i, n)), r = /* @__PURE__ */ new Set();
859
+ const e = n.slice(0, 20).map((o, i) => ge(o, i, t)), r = /* @__PURE__ */ new Set();
496
860
  return e.forEach((o, i) => {
497
- const a = re(o);
498
- r.has(a) && d(n, `attachments.${i}`, "Duplicate attachment."), r.add(a);
861
+ const a = ve(o);
862
+ r.has(a) && c(t, `attachments.${i}`, "Duplicate attachment."), r.add(a);
499
863
  }), e;
500
864
  }
501
- function V(t, n) {
502
- if (t == null)
865
+ function M(n, t) {
866
+ if (n == null)
503
867
  return;
504
- const e = m(t, "limits", n);
505
- l(e, "limits", Object.keys($), n);
868
+ const e = h(n, "limits", t);
869
+ f(e, "limits", Object.keys(T), t);
506
870
  const r = {};
507
- return Object.keys($).forEach((o) => {
871
+ return Object.keys(T).forEach((o) => {
508
872
  const i = e[o];
509
873
  if (i == null)
510
874
  return;
511
- const a = $[o];
875
+ const a = T[o];
512
876
  if (typeof i != "number" || !Number.isInteger(i) || i < a.min || i > a.max) {
513
- d(
514
- n,
877
+ c(
878
+ t,
515
879
  `limits.${o}`,
516
880
  `Expected an integer between ${a.min} and ${a.max}.`
517
881
  );
@@ -520,105 +884,105 @@ function V(t, n) {
520
884
  r[o] = i;
521
885
  }), Object.keys(r).length > 0 ? r : void 0;
522
886
  }
523
- function N(t) {
524
- if (t.length > 0)
525
- throw new S(t);
887
+ function _(n) {
888
+ if (n.length > 0)
889
+ throw new A(n);
526
890
  }
527
- function j(t, n, e) {
528
- t.type === "none" && n.length === 0 && d(
891
+ function P(n, t, e) {
892
+ n.type === "none" && t.length === 0 && c(
529
893
  e,
530
894
  "body",
531
895
  "Add briefing instructions, a custom message, or at least one attachment."
532
896
  );
533
897
  }
534
- function w(t) {
535
- const n = [], e = m(t, "jobConfig", n);
536
- l(
898
+ function j(n) {
899
+ const t = [], e = h(n, "jobConfig", t);
900
+ f(
537
901
  e,
538
902
  "jobConfig",
539
903
  ["kind", "source", "body", "attachments", "presentation", "limits"],
540
- n
541
- ), e.kind !== A && d(n, "kind", "Expected BRIEFING.");
542
- const r = O(e.source, n), o = B(e.body, n), i = D(e.attachments, n), a = R(e.presentation, n), p = V(e.limits, n);
543
- return j(o, i, n), N(n), {
544
- kind: A,
904
+ t
905
+ ), e.kind !== S && c(t, "kind", "Expected BRIEFING.");
906
+ const r = O(e.source, t), o = R(e.body, t), i = V(e.attachments, t), a = F(e.presentation, t), d = M(e.limits, t);
907
+ return P(o, i, t), _(t), {
908
+ kind: S,
545
909
  source: r,
546
910
  body: o,
547
911
  attachments: i,
548
912
  presentation: a,
549
- ...p ? { limits: p } : {}
913
+ ...d ? { limits: d } : {}
550
914
  };
551
915
  }
552
- function pe(t) {
553
- return w({
554
- ...t,
555
- kind: A
916
+ function Be(n) {
917
+ return j({
918
+ ...n,
919
+ kind: S
556
920
  });
557
921
  }
558
- function oe(t, n, e) {
559
- const r = `deliveryConfig.recipients.${n}`, o = m(t, r, e), i = o.type;
560
- if (i === "email") {
561
- l(o, r, ["type", "address", "name"], e);
562
- const a = f(
563
- o.address,
564
- `${r}.address`,
565
- c.id,
922
+ function L(n, t, e, r = "deliveryConfig.recipients") {
923
+ const o = `${r}.${t}`, i = h(n, o, e), a = i.type;
924
+ if (a === "email") {
925
+ f(i, o, ["type", "address", "name"], e);
926
+ const d = u(
927
+ i.address,
928
+ `${o}.address`,
929
+ l.id,
566
930
  e
567
- ), p = u(
568
- o.name,
569
- `${r}.name`,
570
- c.attachmentTitle,
931
+ ), m = y(
932
+ i.name,
933
+ `${o}.name`,
934
+ l.attachmentTitle,
571
935
  e
572
936
  );
573
- return a && !Y(a) && d(e, `${r}.address`, "Email address is invalid."), {
937
+ return d && !ae(d) && c(e, `${o}.address`, "Email address is invalid."), {
574
938
  type: "email",
575
- address: a,
576
- ...p ? { name: p } : {}
939
+ address: d,
940
+ ...m ? { name: m } : {}
577
941
  };
578
942
  }
579
- return i === "user" ? (l(o, r, ["type", "userId"], e), {
943
+ return a === "user" ? (f(i, o, ["type", "userId"], e), {
580
944
  type: "user",
581
- userId: f(
582
- o.userId,
583
- `${r}.userId`,
584
- c.id,
945
+ userId: u(
946
+ i.userId,
947
+ `${o}.userId`,
948
+ l.id,
585
949
  e
586
950
  )
587
- }) : i === "tenant_user" ? (l(o, r, ["type", "tenantUserId"], e), {
951
+ }) : a === "tenant_user" ? (f(i, o, ["type", "tenantUserId"], e), {
588
952
  type: "tenant_user",
589
- tenantUserId: f(
590
- o.tenantUserId,
591
- `${r}.tenantUserId`,
592
- c.id,
953
+ tenantUserId: u(
954
+ i.tenantUserId,
955
+ `${o}.tenantUserId`,
956
+ l.id,
593
957
  e
594
958
  )
595
- }) : i === "group" ? (l(o, r, ["type", "groupId"], e), {
959
+ }) : a === "group" ? (f(i, o, ["type", "groupId"], e), {
596
960
  type: "group",
597
- groupId: f(
598
- o.groupId,
599
- `${r}.groupId`,
600
- c.id,
961
+ groupId: u(
962
+ i.groupId,
963
+ `${o}.groupId`,
964
+ l.id,
601
965
  e
602
966
  )
603
- }) : (d(
967
+ }) : (c(
604
968
  e,
605
- `${r}.type`,
969
+ `${o}.type`,
606
970
  "Expected email, user, tenant_user, or group."
607
971
  ), { type: "email", address: "" });
608
972
  }
609
- function ie(t, n) {
610
- return Array.isArray(t) ? t.map(
611
- (e, r) => oe(e, r, n)
612
- ) : (d(n, "deliveryConfig.recipients", "Expected an array."), []);
973
+ function Ie(n, t) {
974
+ return n == null ? [] : Array.isArray(n) ? n.map(
975
+ (e, r) => L(e, r, t)
976
+ ) : (c(t, "deliveryConfig.recipients", "Expected an array."), []);
613
977
  }
614
- function ae(t, n) {
615
- if (!Array.isArray(t))
616
- return d(n, "deliveryConfig.channels", "Expected an array."), [];
978
+ function be(n, t) {
979
+ if (!Array.isArray(n))
980
+ return c(t, "deliveryConfig.channels", "Expected an array."), [];
617
981
  const e = [];
618
- return t.forEach((r, o) => {
619
- if (!M(r)) {
620
- d(
621
- n,
982
+ return n.forEach((r, o) => {
983
+ if (!q(r)) {
984
+ c(
985
+ t,
622
986
  `deliveryConfig.channels.${o}`,
623
987
  "Expected EMAIL, WEBHOOK, SLACK, IN_APP, or TELEGRAM."
624
988
  );
@@ -627,136 +991,262 @@ function ae(t, n) {
627
991
  e.includes(r) || e.push(r);
628
992
  }), e;
629
993
  }
630
- function de(t, n, e) {
631
- if (t == null)
994
+ function $e(n, t, e) {
995
+ if (n == null)
632
996
  return;
633
- const r = m(t, n, e), o = {};
997
+ const r = h(n, t, e), o = {};
634
998
  return Object.entries(r).forEach(([i, a]) => {
635
999
  if (typeof a != "string") {
636
- d(e, `${n}.${i}`, "Expected a string.");
1000
+ c(e, `${t}.${i}`, "Expected a string.");
637
1001
  return;
638
1002
  }
639
1003
  o[i] = a.trim();
640
1004
  }), Object.keys(o).length > 0 ? o : void 0;
641
1005
  }
642
- function ce(t, n, e) {
643
- if (t == null)
1006
+ function Ee(n, t, e) {
1007
+ if (n == null)
644
1008
  return;
645
- const r = m(t, n, e);
646
- l(
1009
+ const r = h(n, t, e);
1010
+ f(
647
1011
  r,
648
- n,
1012
+ t,
649
1013
  ["url", "method", "headers", "secretEncrypted"],
650
1014
  e
651
1015
  );
652
- const o = r.method === void 0 || r.method === null ? void 0 : g(r.method, `${n}.method`, ["POST", "PUT"], e), i = de(r.headers, `${n}.headers`, e), a = u(
1016
+ const o = r.method === void 0 || r.method === null ? void 0 : E(r.method, `${t}.method`, ["POST", "PUT"], e), i = $e(r.headers, `${t}.headers`, e), a = y(
653
1017
  r.secretEncrypted,
654
- `${n}.secretEncrypted`,
1018
+ `${t}.secretEncrypted`,
655
1019
  2e3,
656
1020
  e
657
1021
  );
658
1022
  return {
659
- url: f(r.url, `${n}.url`, 2e3, e),
1023
+ url: u(r.url, `${t}.url`, 2e3, e),
660
1024
  ...o ? { method: o } : {},
661
1025
  ...i ? { headers: i } : {},
662
1026
  ...a ? { secretEncrypted: a } : {}
663
1027
  };
664
1028
  }
665
- function se(t, n, e) {
666
- const r = m(t, n, e);
667
- l(
1029
+ function Ce(n, t, e) {
1030
+ const r = h(n, t, e), o = r.type;
1031
+ if (o === "channel") {
1032
+ f(
1033
+ r,
1034
+ t,
1035
+ ["type", "channelId", "channelName", "isPrivate"],
1036
+ e
1037
+ );
1038
+ const i = y(
1039
+ r.channelName,
1040
+ `${t}.channelName`,
1041
+ l.attachmentTitle,
1042
+ e
1043
+ ), a = r.isPrivate === void 0 || r.isPrivate === null ? void 0 : $(
1044
+ r.isPrivate,
1045
+ !1,
1046
+ `${t}.isPrivate`,
1047
+ e
1048
+ );
1049
+ return {
1050
+ type: "channel",
1051
+ channelId: u(
1052
+ r.channelId,
1053
+ `${t}.channelId`,
1054
+ l.id,
1055
+ e
1056
+ ),
1057
+ ...i ? { channelName: i } : {},
1058
+ ...a !== void 0 ? { isPrivate: a } : {}
1059
+ };
1060
+ }
1061
+ return o === "dm" ? (f(r, t, ["type", "recipient"], e), c(
1062
+ e,
1063
+ `${t}.type`,
1064
+ "Slack DM delivery is not supported in V1."
1065
+ ), {
1066
+ type: "dm",
1067
+ recipient: L(r.recipient, 0, e, `${t}.recipient`)
1068
+ }) : (c(e, `${t}.type`, "Expected channel."), { type: "channel", channelId: "" });
1069
+ }
1070
+ function xe(n, t, e) {
1071
+ if (n == null)
1072
+ return;
1073
+ if (!Array.isArray(n)) {
1074
+ c(e, t, "Expected an array.");
1075
+ return;
1076
+ }
1077
+ const r = n.map(
1078
+ (o, i) => L(o, i, e, t)
1079
+ );
1080
+ return r.length > 0 ? r : void 0;
1081
+ }
1082
+ function Ae(n, t, e) {
1083
+ if (n == null)
1084
+ return;
1085
+ const r = h(n, t, e);
1086
+ f(
1087
+ r,
1088
+ t,
1089
+ [
1090
+ "destination",
1091
+ "threadMentions",
1092
+ "postThreadDetail",
1093
+ "includeDashboardLink",
1094
+ "includeBriefingLink"
1095
+ ],
1096
+ e
1097
+ );
1098
+ const o = xe(
1099
+ r.threadMentions,
1100
+ `${t}.threadMentions`,
1101
+ e
1102
+ ), i = $(
1103
+ r.postThreadDetail,
1104
+ !0,
1105
+ `${t}.postThreadDetail`,
1106
+ e
1107
+ ), a = $(
1108
+ r.includeDashboardLink,
1109
+ !0,
1110
+ `${t}.includeDashboardLink`,
1111
+ e
1112
+ ), d = $(
1113
+ r.includeBriefingLink,
1114
+ !0,
1115
+ `${t}.includeBriefingLink`,
1116
+ e
1117
+ );
1118
+ return {
1119
+ destination: Ce(
1120
+ r.destination,
1121
+ `${t}.destination`,
1122
+ e
1123
+ ),
1124
+ ...o ? { threadMentions: o } : {},
1125
+ ...r.postThreadDetail !== void 0 ? { postThreadDetail: i } : {},
1126
+ ...r.includeDashboardLink !== void 0 ? { includeDashboardLink: a } : {},
1127
+ ...r.includeBriefingLink !== void 0 ? { includeBriefingLink: d } : {}
1128
+ };
1129
+ }
1130
+ function Te(n, t, e) {
1131
+ const r = h(n, t, e);
1132
+ f(
668
1133
  r,
669
- n,
1134
+ t,
670
1135
  [
671
1136
  "subjectOverride",
672
1137
  "titleOverride",
673
1138
  "summaryOverride",
674
1139
  "actionBlockVisible",
1140
+ "formatProfile",
1141
+ "slackConfig",
675
1142
  "webhookConfig"
676
1143
  ],
677
1144
  e
678
1145
  );
679
- const o = u(
1146
+ const o = I(
1147
+ r.formatProfile,
1148
+ `${t}.formatProfile`,
1149
+ Q,
1150
+ "concise, balanced, or detailed",
1151
+ e
1152
+ ), i = y(
680
1153
  r.subjectOverride,
681
- `${n}.subjectOverride`,
1154
+ `${t}.subjectOverride`,
682
1155
  500,
683
1156
  e
684
- ), i = u(
1157
+ ), a = y(
685
1158
  r.titleOverride,
686
- `${n}.titleOverride`,
1159
+ `${t}.titleOverride`,
687
1160
  500,
688
1161
  e
689
- ), a = u(
1162
+ ), d = y(
690
1163
  r.summaryOverride,
691
- `${n}.summaryOverride`,
1164
+ `${t}.summaryOverride`,
692
1165
  2e3,
693
1166
  e
694
- ), p = C(
1167
+ ), m = $(
695
1168
  r.actionBlockVisible,
696
1169
  !0,
697
- `${n}.actionBlockVisible`,
1170
+ `${t}.actionBlockVisible`,
698
1171
  e
699
- ), y = ce(
1172
+ ), s = Ee(
700
1173
  r.webhookConfig,
701
- `${n}.webhookConfig`,
1174
+ `${t}.webhookConfig`,
1175
+ e
1176
+ ), p = Ae(
1177
+ r.slackConfig,
1178
+ `${t}.slackConfig`,
702
1179
  e
703
1180
  );
704
1181
  return {
705
- ...o ? { subjectOverride: o } : {},
706
- ...i ? { titleOverride: i } : {},
707
- ...a ? { summaryOverride: a } : {},
708
- ...r.actionBlockVisible !== void 0 ? { actionBlockVisible: p } : {},
709
- ...y ? { webhookConfig: y } : {}
1182
+ ...o ? { formatProfile: o } : {},
1183
+ ...i ? { subjectOverride: i } : {},
1184
+ ...a ? { titleOverride: a } : {},
1185
+ ...d ? { summaryOverride: d } : {},
1186
+ ...r.actionBlockVisible !== void 0 ? { actionBlockVisible: m } : {},
1187
+ ...p ? { slackConfig: p } : {},
1188
+ ...s ? { webhookConfig: s } : {}
710
1189
  };
711
1190
  }
712
- function le(t, n) {
713
- if (t == null)
1191
+ function Se(n, t) {
1192
+ if (n == null)
714
1193
  return;
715
- const e = m(t, "deliveryConfig.channelConfigs", n), r = {};
1194
+ const e = h(n, "deliveryConfig.channelConfigs", t), r = {};
716
1195
  return Object.entries(e).forEach(([o, i]) => {
717
- if (!M(o)) {
718
- d(
719
- n,
1196
+ if (!q(o)) {
1197
+ c(
1198
+ t,
720
1199
  `deliveryConfig.channelConfigs.${o}`,
721
1200
  "Expected a supported delivery channel."
722
1201
  );
723
1202
  return;
724
1203
  }
725
- r[o] = se(
1204
+ r[o] = Te(
726
1205
  i,
727
1206
  `deliveryConfig.channelConfigs.${o}`,
728
- n
1207
+ t
729
1208
  );
730
1209
  }), Object.keys(r).length > 0 ? r : void 0;
731
1210
  }
732
- function fe(t, n) {
733
- if (t == null)
1211
+ function ke(n, t) {
1212
+ var m, s, p;
1213
+ if (n == null)
734
1214
  return null;
735
- const e = m(t, "deliveryConfig", n);
736
- l(
1215
+ const e = h(n, "deliveryConfig", t);
1216
+ f(
737
1217
  e,
738
1218
  "deliveryConfig",
739
1219
  ["recipients", "channels", "channelConfigs"],
740
- n
1220
+ t
741
1221
  );
742
- const r = le(e.channelConfigs, n), o = ie(e.recipients, n), i = ae(e.channels, n);
743
- return o.length === 0 && d(
744
- n,
1222
+ const r = Se(e.channelConfigs, t), o = Ie(e.recipients, t), i = be(e.channels, t), a = ((s = (m = r == null ? void 0 : r.SLACK) == null ? void 0 : m.slackConfig) == null ? void 0 : s.destination.type) === "channel" && !!r.SLACK.slackConfig.destination.channelId.trim();
1223
+ return i.some(
1224
+ (v) => v !== "SLACK"
1225
+ ) && o.length === 0 && c(
1226
+ t,
745
1227
  "deliveryConfig.recipients",
746
1228
  "Add at least one recipient or remove delivery config."
747
- ), i.length === 0 && d(
748
- n,
1229
+ ), i.length === 0 && c(
1230
+ t,
749
1231
  "deliveryConfig.channels",
750
1232
  "Choose at least one delivery channel or remove delivery config."
1233
+ ), i.includes("SLACK") && !a && c(
1234
+ t,
1235
+ "deliveryConfig.channelConfigs.SLACK.slackConfig.destination.channelId",
1236
+ "Choose a Slack channel destination."
1237
+ ), !i.includes("SLACK") && ((p = r == null ? void 0 : r.SLACK) != null && p.slackConfig) && c(
1238
+ t,
1239
+ "deliveryConfig.channelConfigs.SLACK",
1240
+ "Slack config requires SLACK in deliveryConfig.channels."
751
1241
  ), {
752
1242
  recipients: o,
753
1243
  channels: i,
754
1244
  ...r ? { channelConfigs: r } : {}
755
1245
  };
756
1246
  }
757
- function T(t) {
758
- const n = [], e = m(t, "draft", n);
759
- l(
1247
+ function w(n) {
1248
+ const t = [], e = h(n, "draft", t);
1249
+ f(
760
1250
  e,
761
1251
  "draft",
762
1252
  [
@@ -772,77 +1262,80 @@ function T(t) {
772
1262
  "limits",
773
1263
  "deliveryConfig"
774
1264
  ],
775
- n
1265
+ t
776
1266
  );
777
- const r = f(
1267
+ const r = u(
778
1268
  e.name,
779
1269
  "name",
780
- c.name,
781
- n
782
- ), o = u(
1270
+ l.name,
1271
+ t
1272
+ ), o = y(
783
1273
  e.description,
784
1274
  "description",
785
- c.description,
786
- n
787
- ) ?? null, i = u(e.scheduleExpr, "scheduleExpr", 500, n) ?? null, a = u(e.timezone, "timezone", 200, n) ?? "UTC", p = W(e.status, n), y = O(e.source, n), s = B(e.body, n), h = D(e.attachments, n), k = R(e.presentation, n), _ = V(e.limits, n), L = fe(e.deliveryConfig, n);
788
- return j(s, h, n), N(n), {
1275
+ l.description,
1276
+ t
1277
+ ) ?? null, i = y(e.scheduleExpr, "scheduleExpr", 500, t) ?? null, a = y(e.timezone, "timezone", 200, t) ?? "UTC", d = ie(e.status, t), m = O(e.source, t), s = R(e.body, t), p = V(e.attachments, t), v = F(e.presentation, t), B = M(e.limits, t), K = ke(e.deliveryConfig, t);
1278
+ return P(s, p, t), _(t), {
789
1279
  name: r,
790
1280
  description: o,
791
- status: p,
1281
+ status: d,
792
1282
  scheduleExpr: i,
793
1283
  timezone: a,
794
- source: y,
1284
+ source: m,
795
1285
  body: s,
796
- attachments: h,
797
- presentation: k,
798
- ..._ ? { limits: _ } : {},
799
- deliveryConfig: L
1286
+ attachments: p,
1287
+ presentation: v,
1288
+ ...B ? { limits: B } : {},
1289
+ deliveryConfig: K
800
1290
  };
801
1291
  }
802
- function he(t) {
803
- return T(t);
1292
+ function ze(n) {
1293
+ return w(n);
804
1294
  }
805
- function ye(t) {
806
- return T(t);
1295
+ function De(n) {
1296
+ return w(n);
807
1297
  }
808
- function ge(t) {
1298
+ function Ne(n) {
809
1299
  try {
810
- return { valid: !0, value: T(t), issues: [] };
811
- } catch (n) {
812
- if (n instanceof S)
813
- return { valid: !1, issues: n.issues };
814
- throw n;
1300
+ return { valid: !0, value: w(n), issues: [] };
1301
+ } catch (t) {
1302
+ if (t instanceof A)
1303
+ return { valid: !1, issues: t.issues };
1304
+ throw t;
815
1305
  }
816
1306
  }
817
- function Ie(t) {
1307
+ function Oe(n) {
818
1308
  try {
819
- return { valid: !0, value: w(t), issues: [] };
820
- } catch (n) {
821
- if (n instanceof S)
822
- return { valid: !1, issues: n.issues };
823
- throw n;
1309
+ return { valid: !0, value: j(n), issues: [] };
1310
+ } catch (t) {
1311
+ if (t instanceof A)
1312
+ return { valid: !1, issues: t.issues };
1313
+ throw t;
824
1314
  }
825
1315
  }
826
- function be(t) {
827
- return typeof t == "string" && z.has(t);
1316
+ function Re(n) {
1317
+ return typeof n == "string" && D.has(n);
828
1318
  }
829
- function M(t) {
830
- return typeof t == "string" && H.has(t);
1319
+ function q(n) {
1320
+ return typeof n == "string" && X.has(n);
831
1321
  }
832
1322
  export {
833
- U as BRIEFING_ARTIFACT_FORMATS,
834
- A as BRIEFING_KIND,
835
- c as BRIEFING_TEXT_LIMITS,
836
- S as BriefingContractError,
837
- v as DEFAULT_BRIEFING_ARTIFACT_FORMATS,
838
- ue as MAX_BRIEFING_ATTACHMENTS,
839
- pe as buildBriefingJobConfig,
840
- he as buildCreateBriefingRequest,
841
- ye as buildUpdateBriefingRequest,
842
- be as isBriefingArtifactFormat,
843
- M as isBriefingDeliveryChannel,
844
- T as normalizeBriefingDraft,
845
- w as normalizeBriefingJobConfig,
846
- ge as validateBriefingDraft,
847
- Ie as validateBriefingJobConfig
1323
+ H as BRIEFING_ARTIFACT_FORMATS,
1324
+ g as BRIEFING_CONTENT_LIMITS,
1325
+ S as BRIEFING_KIND,
1326
+ l as BRIEFING_TEXT_LIMITS,
1327
+ A as BriefingContractError,
1328
+ k as DEFAULT_BRIEFING_ARTIFACT_FORMATS,
1329
+ Le as MAX_BRIEFING_ATTACHMENTS,
1330
+ Be as buildBriefingJobConfig,
1331
+ ze as buildCreateBriefingRequest,
1332
+ De as buildUpdateBriefingRequest,
1333
+ Re as isBriefingArtifactFormat,
1334
+ q as isBriefingDeliveryChannel,
1335
+ pe as normalizeBriefingContentDocument,
1336
+ w as normalizeBriefingDraft,
1337
+ j as normalizeBriefingJobConfig,
1338
+ we as validateBriefingContentDocument,
1339
+ Ne as validateBriefingDraft,
1340
+ Oe as validateBriefingJobConfig
848
1341
  };