@knkcs/contenthub-ui 0.5.0 → 0.6.0

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.
package/dist/testing.js CHANGED
@@ -1,37 +1,37 @@
1
- import { C as e, D as t, E as n, F as r, M as i, N as a, P as o, S as s, T as c, _ as l, b as u, f as d, g as f, h as p, i as ee, k as m, n as h, o as te, r as g, s as ne, t as re, u as ie, v as ae, w as _, x as v, y as oe } from "./heads-BrvZ_GYT.js";
2
- import { Code as y, ConnectError as b } from "@connectrpc/connect";
3
- import { createHostMembers as x } from "@knkcs/anker/host";
1
+ import { A as e, C as t, D as n, E as r, F as i, I as a, N as o, O as s, P as c, S as l, T as u, _ as d, b as f, d as p, g as m, i as h, n as g, o as ee, p as te, r as _, s as ne, t as re, u as ie, v as ae, w as oe, x as se, y as ce } from "./heads-BT8RZ-Gs.js";
2
+ import { Code as v, ConnectError as y } from "@connectrpc/connect";
3
+ import { createHostMembers as le } from "@knkcs/anker/host";
4
4
  //#region src/testing/fixtures.ts
5
- var S = "ws_stub", C = "user_stub", w = "user_ben", T = "2026-10-01T09:00:00.000Z";
6
- function E() {
5
+ var ue = "ws_stub", b = "user_stub", x = "user_ben", S = "2026-10-01T09:00:00.000Z";
6
+ function C() {
7
7
  return {
8
- userId: C,
9
- workspaceId: S,
10
- members: x([{
11
- userId: C,
8
+ userId: b,
9
+ workspaceId: ue,
10
+ members: le([{
11
+ userId: b,
12
12
  displayName: "Ada Editor",
13
13
  email: "ada@example.com"
14
14
  }, {
15
- userId: w,
15
+ userId: x,
16
16
  displayName: "Ben Reviewer",
17
17
  email: "ben@example.com"
18
18
  }])
19
19
  };
20
20
  }
21
- function se() {
21
+ function de() {
22
22
  return [{
23
23
  id: "br_author",
24
24
  name: "Being revised by the author",
25
- createTime: T,
26
- updateTime: T
25
+ createTime: S,
26
+ updateTime: S
27
27
  }, {
28
28
  id: "br_embargo",
29
29
  name: "Embargoed until publication",
30
- createTime: T,
31
- updateTime: T
30
+ createTime: S,
31
+ updateTime: S
32
32
  }];
33
33
  }
34
- function ce() {
34
+ function fe() {
35
35
  return [
36
36
  {
37
37
  slug: "in_progress",
@@ -56,7 +56,7 @@ function ce() {
56
56
  }
57
57
  ];
58
58
  }
59
- function le() {
59
+ function pe() {
60
60
  return {
61
61
  in_progress: ["in_review", "on_hold"],
62
62
  in_review: [
@@ -68,7 +68,7 @@ function le() {
68
68
  on_hold: ["in_progress"]
69
69
  };
70
70
  }
71
- function ue() {
71
+ function me() {
72
72
  return [
73
73
  {
74
74
  id: "cs_bgbl_270",
@@ -78,7 +78,7 @@ function ue() {
78
78
  reference: "BGBl. 2026 I Nr. 270"
79
79
  },
80
80
  state: "open",
81
- createdBy: C,
81
+ createdBy: b,
82
82
  createTime: "2026-09-30T08:00:00.000Z",
83
83
  chains: [{
84
84
  id: "chain_para_1",
@@ -111,7 +111,7 @@ function ue() {
111
111
  }],
112
112
  dependsOnChangeSetIds: [],
113
113
  status: "in_progress",
114
- assigneeIds: [C],
114
+ assigneeIds: [b],
115
115
  plannedReleases: [
116
116
  {
117
117
  id: "rls_p1_2",
@@ -171,19 +171,19 @@ function ue() {
171
171
  reference: "BGBl. 2026 I Nr. 255"
172
172
  },
173
173
  state: "open",
174
- createdBy: w,
174
+ createdBy: x,
175
175
  createTime: "2026-09-25T08:00:00.000Z",
176
176
  chains: [],
177
177
  dependsOnChangeSetIds: [],
178
178
  status: "",
179
- assigneeIds: [w],
179
+ assigneeIds: [x],
180
180
  plannedReleases: []
181
181
  },
182
182
  {
183
183
  id: "cs_correction_3",
184
184
  name: "Correction of § 3",
185
185
  state: "published",
186
- createdBy: C,
186
+ createdBy: b,
187
187
  createTime: "2026-09-01T08:00:00.000Z",
188
188
  closeTime: "2026-09-02T08:00:00.000Z",
189
189
  chains: [],
@@ -194,7 +194,7 @@ function ue() {
194
194
  }
195
195
  ];
196
196
  }
197
- function de() {
197
+ function he() {
198
198
  return [{
199
199
  id: "rc_print",
200
200
  name: "Druckprobe",
@@ -209,7 +209,7 @@ function de() {
209
209
  independent: !0
210
210
  }];
211
211
  }
212
- function fe() {
212
+ function ge() {
213
213
  return [
214
214
  {
215
215
  id: "col_bgb",
@@ -237,23 +237,26 @@ function fe() {
237
237
  }
238
238
  ];
239
239
  }
240
- function pe() {
240
+ function _e() {
241
241
  return [
242
242
  {
243
243
  id: "bp_commentary",
244
- name: "Commentary"
244
+ name: "Commentary",
245
+ accessor: "commentary"
245
246
  },
246
247
  {
247
248
  id: "bp_footnote",
248
- name: "Footnote"
249
+ name: "Footnote",
250
+ accessor: "footnote"
249
251
  },
250
252
  {
251
253
  id: "bp_paragraph",
252
- name: "Paragraph"
254
+ name: "Paragraph",
255
+ accessor: "paragraph"
253
256
  }
254
257
  ];
255
258
  }
256
- function me() {
259
+ function ve() {
257
260
  return [
258
261
  {
259
262
  id: "bpr_paragraph_2",
@@ -275,7 +278,7 @@ function me() {
275
278
  }
276
279
  ];
277
280
  }
278
- function he() {
281
+ function ye() {
279
282
  let e = (e, t) => ({
280
283
  field_type: "text",
281
284
  config: {
@@ -311,7 +314,7 @@ function he() {
311
314
  }
312
315
  };
313
316
  }
314
- function D() {
317
+ function w() {
315
318
  let e = "2026-09-01T08:00:00.000Z";
316
319
  return {
317
320
  id: "content_note_1",
@@ -341,7 +344,7 @@ function D() {
341
344
  }]
342
345
  };
343
346
  }
344
- function ge() {
347
+ function be() {
345
348
  let e = "2001-11-01T08:00:00.000Z";
346
349
  return {
347
350
  id: "content_para_3",
@@ -372,7 +375,7 @@ function ge() {
372
375
  }]
373
376
  };
374
377
  }
375
- function _e() {
378
+ function xe() {
376
379
  let e = "2026-09-01T08:00:00.000Z";
377
380
  return [
378
381
  {
@@ -405,7 +408,7 @@ function _e() {
405
408
  blueprintId: "bp_paragraph",
406
409
  blueprintReleaseId: "bpr_paragraph_1",
407
410
  collectionIds: ["col_bgb"],
408
- assigneeIds: [C, w],
411
+ assigneeIds: [b, x],
409
412
  main: {
410
413
  revisionId: "rev_p1_main",
411
414
  data: {
@@ -472,7 +475,7 @@ function _e() {
472
475
  secondParentId: "",
473
476
  blueprintReleaseId: "bpr_paragraph_1",
474
477
  createTime: "2026-09-30T09:00:00.000Z",
475
- author: C,
478
+ author: b,
476
479
  cause: "save",
477
480
  branchId: "br_para_1_b",
478
481
  changeSetId: "cs_bgbl_270",
@@ -488,7 +491,7 @@ function _e() {
488
491
  secondParentId: "",
489
492
  blueprintReleaseId: "bpr_paragraph_1",
490
493
  createTime: "2026-09-30T08:30:00.000Z",
491
- author: w,
494
+ author: x,
492
495
  cause: "save",
493
496
  branchId: "br_para_1_a",
494
497
  changeSetId: "cs_bgbl_270",
@@ -504,7 +507,7 @@ function _e() {
504
507
  secondParentId: "",
505
508
  blueprintReleaseId: "bpr_paragraph_1",
506
509
  createTime: e,
507
- author: C,
510
+ author: b,
508
511
  cause: "create",
509
512
  branchId: "br_para_1_main",
510
513
  changeSetId: "cs_correction_3"
@@ -588,7 +591,7 @@ function _e() {
588
591
  blueprintId: "bp_paragraph",
589
592
  blueprintReleaseId: "bpr_paragraph_1",
590
593
  collectionIds: ["col_stgb"],
591
- assigneeIds: [w],
594
+ assigneeIds: [x],
592
595
  main: {
593
596
  revisionId: "rev_s211_main",
594
597
  data: {
@@ -625,7 +628,7 @@ function _e() {
625
628
  }
626
629
  //#endregion
627
630
  //#region src/testing/stub-blueprint-source.ts
628
- function ve(e = pe(), t = me()) {
631
+ function T(e = _e(), t = ve()) {
629
632
  return {
630
633
  async searchBlueprints({ query: t }) {
631
634
  let n = t.trim().toLocaleLowerCase();
@@ -637,6 +640,9 @@ function ve(e = pe(), t = me()) {
637
640
  async getBlueprints(t) {
638
641
  return e.filter((e) => t.includes(e.id)).map((e) => ({ ...e }));
639
642
  },
643
+ async getBlueprintsByAccessor(t) {
644
+ return e.filter((e) => t.includes(e.accessor)).map((e) => ({ ...e }));
645
+ },
640
646
  async listReleases(e) {
641
647
  return t.filter((t) => t.blueprintId === e).map((e) => ({ ...e }));
642
648
  }
@@ -644,56 +650,78 @@ function ve(e = pe(), t = me()) {
644
650
  }
645
651
  //#endregion
646
652
  //#region src/testing/stub-client.ts
647
- function ye(e) {
653
+ function Se(e) {
648
654
  let t = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
649
655
  return t.setUTCDate(t.getUTCDate() - 1), t.toISOString().slice(0, 10);
650
656
  }
651
- function be(e, t) {
657
+ function Ce(e, t) {
652
658
  let n = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
653
659
  return n.setUTCDate(n.getUTCDate() + t), n.toISOString().slice(0, 10);
654
660
  }
655
- function O(e, t, n) {
661
+ function E(e, t, n) {
656
662
  let r = e.trim();
657
- if (r === "") throw new _(`${t} is required`);
658
- if ([...r].length > n) throw new _(`${t} is at most ${n} characters`);
659
- if (/[\u0000-\u001f\u007f]/.test(r)) throw new _(`${t} is one line of text`);
663
+ if (r === "") throw new u(`${t} is required`);
664
+ if ([...r].length > n) throw new u(`${t} is at most ${n} characters`);
665
+ if (/[\u0000-\u001f\u007f]/.test(r)) throw new u(`${t} is one line of text`);
660
666
  return r;
661
667
  }
662
- function xe(e) {
663
- if (!/^\d{4}-\d{2}-\d{2}$/.test(e.date.trim())) throw new _(`source.date "${e.date}" is not a day as YYYY-MM-DD`);
668
+ function we(e) {
669
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(e.date.trim())) throw new u(`source.date "${e.date}" is not a day as YYYY-MM-DD`);
664
670
  return {
665
671
  date: e.date.trim(),
666
- reference: O(e.reference, "source.reference", 500)
672
+ reference: E(e.reference, "source.reference", 500)
667
673
  };
668
674
  }
669
- function Se(e) {
675
+ function Te(e) {
670
676
  let t = e.trim();
671
- if (t === "") throw new _("a Block Reason needs a name");
672
- if ([...t].length > 200) throw new _("a Block Reason's name is at most 200 characters");
673
- if (/[\u0000-\u001f\u007f]/.test(t)) throw new _("a Block Reason's name is one line of text");
677
+ if (t === "") throw new u("a Block Reason needs a name");
678
+ if ([...t].length > 200) throw new u("a Block Reason's name is at most 200 characters");
679
+ if (/[\u0000-\u001f\u007f]/.test(t)) throw new u("a Block Reason's name is one line of text");
674
680
  return t;
675
681
  }
676
- function Ce(e) {
677
- let t = O(e.name, "a Required Check's name", 200);
678
- if (e.scope !== "branch" && e.scope !== "change_set") throw new _("a Required Check's scope is Branch or Change Set");
682
+ function Ee(e) {
683
+ let t = E(e.name, "a Required Check's name", 200);
684
+ if (e.scope !== "branch" && e.scope !== "change_set") throw new u("a Required Check's scope is Branch or Change Set");
679
685
  let n = e.blueprintAccessors.map((e) => {
680
686
  let t = e.trim();
681
- if (t === "" || [...t].length > 200 || /[\u0000-\u001f\u007f]/.test(t)) throw new _(`"${t}" is not a Blueprint accessor`);
687
+ if (t === "" || [...t].length > 200 || /[\u0000-\u001f\u007f]/.test(t)) throw new u(`"${t}" is not a Blueprint accessor`);
682
688
  return t;
683
- });
689
+ }), r = [...new Set(n)].sort();
690
+ if (e.everyBlueprint && r.length > 0) throw new u("a Required Check applies to every Blueprint or names Blueprints, not both");
691
+ if (!e.everyBlueprint && r.length === 0) throw new u("a Required Check names the Blueprints it applies to, or applies to every Blueprint");
684
692
  return {
685
693
  name: t,
686
694
  scope: e.scope,
687
- blueprintAccessors: [...new Set(n)].sort(),
695
+ blueprintAccessors: r,
696
+ everyBlueprint: e.everyBlueprint,
688
697
  independent: e.independent
689
698
  };
690
699
  }
691
- var we = "who records a Required Check can be narrowed only in authz.mode guardian: in workspace mode every member records every check (ADR 0017)", Te = "this Change Set holds work you can't see: publishing, discarding or updating all of it needs you to see every Content in it", Ee = "Restricted Collections need authz.mode guardian: in workspace mode a restriction could not be enforced (ADR 0017)";
692
- function k(e, t) {
693
- return new b(`${e} ${t}: not found`, y.NotFound);
700
+ function De(e, t) {
701
+ let n = [];
702
+ for (let r of t) {
703
+ let t = e.find((e) => e.accessor === r);
704
+ t ? t.archived && n.push({
705
+ accessor: r,
706
+ reason: "archived"
707
+ }) : n.push({
708
+ accessor: r,
709
+ reason: "unknown"
710
+ });
711
+ }
712
+ if (n.length > 0) throw new p(n);
694
713
  }
695
- var A = (e) => structuredClone(e);
696
- function j(e, t = {}) {
714
+ var Oe = (e) => ({
715
+ id: e.id,
716
+ name: e.name,
717
+ accessor: e.accessor,
718
+ archived: e.archived ?? !1
719
+ }), ke = "who records a Required Check can be narrowed only in authz.mode guardian: in workspace mode every member records every check (ADR 0017)", Ae = "this Change Set holds work you can't see: publishing, discarding or updating all of it needs you to see every Content in it", je = "Restricted Collections need authz.mode guardian: in workspace mode a restriction could not be enforced (ADR 0017)";
720
+ function D(e, t) {
721
+ return new y(`${e} ${t}: not found`, v.NotFound);
722
+ }
723
+ var O = (e) => structuredClone(e);
724
+ function k(e, t = {}) {
697
725
  return {
698
726
  code: e,
699
727
  contentId: "",
@@ -713,55 +741,55 @@ function j(e, t = {}) {
713
741
  ...t
714
742
  };
715
743
  }
716
- function M(y = {}) {
717
- let b = y.now ?? (() => "2026-10-01T09:00:00.000Z"), x = y.userId ?? "user_stub", S = y.statuses ?? ce(), C = y.statusTransitions ?? le(), w = (y.blockReasons ?? se()).map((e) => ({ ...e })), T = (y.changeSets ?? ue()).map(A), E = (y.collections ?? fe()).map((e) => ({ ...e })), D = structuredClone(y.contents ?? _e()), ge = y.blueprints ?? pe(), ve = y.blueprintReleases ?? me(), M = y.resolvedReleases ?? he(), N = structuredClone(y.requiredChecks ?? de()), P = y.authzMode ?? "guardian", Oe = new Set(y.withheld ?? []), ke = (e) => {
718
- if (Oe.has(e)) throw new r(Te);
719
- }, F = new Map(Object.entries(structuredClone(y.collectionGrants ?? {}))), I = new Map(Object.entries(structuredClone(y.recorders ?? {}))), Ae = (e) => I.get(e) ?? {
744
+ function A(p = {}) {
745
+ let v = p.now ?? (() => "2026-10-01T09:00:00.000Z"), y = p.userId ?? "user_stub", le = p.statuses ?? fe(), ue = p.statusTransitions ?? pe(), b = (p.blockReasons ?? de()).map((e) => ({ ...e })), x = (p.changeSets ?? me()).map(O), S = (p.collections ?? ge()).map((e) => ({ ...e })), C = structuredClone(p.contents ?? xe()), w = p.blueprints ?? _e(), be = p.blueprintReleases ?? ve(), T = p.resolvedReleases ?? ye(), A = structuredClone(p.requiredChecks ?? he()), j = p.authzMode ?? "guardian", Ne = new Set(p.withheld ?? []), M = (e) => {
746
+ if (Ne.has(e)) throw new a(Ae);
747
+ }, N = new Map(Object.entries(structuredClone(p.collectionGrants ?? {}))), P = new Map(Object.entries(structuredClone(p.recorders ?? {}))), Pe = (e) => P.get(e) ?? {
720
748
  everyMember: !0,
721
749
  userIds: []
722
- }, je = y.memberIds ?? ["user_stub", "user_ben"], Me = y.admin ?? !0, Ne = y.editingSettings ?? {
750
+ }, Fe = p.memberIds ?? ["user_stub", "user_ben"], F = p.admin ?? !0, Ie = p.editingSettings ?? {
723
751
  editingMode: "change_sets",
724
752
  editingBlock: !1
725
- }, L = structuredClone({
726
- ...Ne,
727
- forceGroup: Ne.forceGroup ?? []
728
- }), R = structuredClone(y.editingOverrides ?? []), z = (e) => ({
729
- editingMode: e?.editingMode ?? L.editingMode,
730
- editingBlock: e?.editingBlock ?? L.editingBlock,
731
- forceGroup: [...e?.forceGroup ?? L.forceGroup]
732
- }), Pe = (e) => ({
753
+ }, I = structuredClone({
754
+ ...Ie,
755
+ forceGroup: Ie.forceGroup ?? []
756
+ }), L = structuredClone(p.editingOverrides ?? []), R = (e) => ({
757
+ editingMode: e?.editingMode ?? I.editingMode,
758
+ editingBlock: e?.editingBlock ?? I.editingBlock,
759
+ forceGroup: [...e?.forceGroup ?? I.forceGroup]
760
+ }), Le = (e) => ({
733
761
  ...structuredClone(e),
734
762
  forceGroup: e.forceGroup ?? null,
735
- effective: z(e)
736
- }), Fe = (e) => M[e.blueprintReleaseId]?.accessor || e.blueprintId, Ie = (e) => Me || e.includes(x), Le = (e) => [...new Set(e.map((e) => O(e, "a user id", 200)))].sort(), Re = [
763
+ effective: R(e)
764
+ }), Re = (e) => T[e.blueprintReleaseId]?.accessor || e.blueprintId, ze = (e) => F || e.includes(y), Be = (e) => [...new Set(e.map((e) => E(e, "a user id", 200)))].sort(), Ve = [
737
765
  "direct_edits",
738
766
  "change_sets",
739
767
  "both"
740
- ], ze = () => {
741
- if (!Me) throw new ne("permission denied");
742
- }, Be = structuredClone(y.checkResults ?? []), Ve = y.publishBlockers ?? {}, He = y.pendingMerges ?? {}, Ue = structuredClone(y.conflicts ?? {}), We = new Set(y.behind ?? []), B = /* @__PURE__ */ new Map(), Ge = /* @__PURE__ */ new Map(), V = async (e, t, n) => {
768
+ ], He = () => {
769
+ if (!F) throw new ne("permission denied");
770
+ }, Ue = structuredClone(p.checkResults ?? []), We = p.publishBlockers ?? {}, Ge = p.pendingMerges ?? {}, Ke = structuredClone(p.conflicts ?? {}), qe = new Set(p.behind ?? []), z = /* @__PURE__ */ new Map(), Je = /* @__PURE__ */ new Map(), B = async (e, t, n) => {
743
771
  if (!e) return n();
744
- let r = JSON.stringify(t), i = Ge.get(e);
772
+ let r = JSON.stringify(t), i = Je.get(e);
745
773
  if (i) {
746
- if (i.asked !== r) throw new _(`idempotency key ${e} names another request`);
774
+ if (i.asked !== r) throw new u(`idempotency key ${e} names another request`);
747
775
  return structuredClone(i.answer);
748
776
  }
749
777
  let a = await n();
750
- return Ge.set(e, {
778
+ return Je.set(e, {
751
779
  asked: r,
752
780
  answer: structuredClone(a)
753
781
  }), a;
754
- }, Ke = /* @__PURE__ */ new Map(), qe = /* @__PURE__ */ new Map(), H = 1, U = (e) => {
755
- let t = D.find((t) => t.id === e);
756
- if (!t) throw k("Content", e);
782
+ }, Ye = /* @__PURE__ */ new Map(), Xe = /* @__PURE__ */ new Map(), V = 1, H = (e) => {
783
+ let t = C.find((t) => t.id === e);
784
+ if (!t) throw D("Content", e);
757
785
  return t;
758
- }, W = (e) => structuredClone({
786
+ }, U = (e) => structuredClone({
759
787
  collectionIds: [...e.collectionIds].sort(),
760
788
  assigneeIds: e.assigneeIds ?? [],
761
789
  block: e.block,
762
790
  archiveTime: e.archiveTime,
763
791
  editingBlock: e.editingBlock
764
- }), Je = () => b().slice(0, 10), G = (e) => M[e.blueprintReleaseId]?.dated ?? !1, K = (e) => {
792
+ }), Ze = () => v().slice(0, 10), W = (e) => T[e.blueprintReleaseId]?.dated ?? !1, G = (e) => {
765
793
  let t = [...e.revisions ?? []], n = [...Object.entries(e.branches).map(([e, t]) => ({
766
794
  ...t,
767
795
  changeSetId: e
@@ -777,70 +805,70 @@ function M(y = {}) {
777
805
  secondParentId: "",
778
806
  blueprintReleaseId: e.blueprintReleaseId,
779
807
  createTime: r.revisionCreateTime,
780
- author: x,
808
+ author: y,
781
809
  cause: "create",
782
810
  branchId: r.branchId,
783
811
  changeSetId: r.changeSetId,
784
812
  data: r.data
785
813
  });
786
814
  return t.sort((e, t) => e.createTime < t.createTime ? 1 : e.createTime > t.createTime ? -1 : 0);
787
- }, q = (e, t) => [
815
+ }, K = (e, t) => [
788
816
  e.main,
789
817
  e.inForce,
790
818
  ...Object.values(e.branches)
791
- ].find((e) => e?.revisionId === t)?.data ?? e.revisions?.find((e) => e.id === t)?.data, Ye = (e, t) => {
819
+ ].find((e) => e?.revisionId === t)?.data ?? e.revisions?.find((e) => e.id === t)?.data, Qe = (e, t) => {
792
820
  let n = (e) => e == null || e === "" || Array.isArray(e) && e.length === 0;
793
821
  return (e ?? []).filter((e) => e.config.required === !0 && n(t[e.config.api_accessor])).map((e) => e.config.api_accessor);
794
- }, J = (e) => {
795
- if (e.archiveTime) throw new l(e.id);
796
- if (e.block && !e.block.allowedUserIds.includes(x)) throw new ae(e.id, e.block.blockReasonId);
797
- }, Xe = (e) => D.flatMap((t) => (t.edges ?? []).filter((n) => n.targetContentId === e && n.pinReleaseId === "" && t.inForce?.revisionId === n.sourceRevisionId).map((e) => ({
822
+ }, q = (e) => {
823
+ if (e.archiveTime) throw new ae(e.id);
824
+ if (e.block && !e.block.allowedUserIds.includes(y)) throw new ce(e.id, e.block.blockReasonId);
825
+ }, $e = (e) => C.flatMap((t) => (t.edges ?? []).filter((n) => n.targetContentId === e && n.pinReleaseId === "" && t.inForce?.revisionId === n.sourceRevisionId).map((e) => ({
798
826
  edge: { ...e },
799
827
  releaseId: t.inForce?.releaseId ?? ""
800
- }))), Ze = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id), Qe = (e, t) => w.some((n) => n.name === e && n.id !== t), $e = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id), Y = (e) => {
801
- let t = E.find((t) => t.id === e);
802
- if (!t) throw k("Collection", e);
828
+ }))), et = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id), tt = (e, t) => b.some((n) => n.name === e && n.id !== t), nt = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id), J = (e) => {
829
+ let t = S.find((t) => t.id === e);
830
+ if (!t) throw D("Collection", e);
803
831
  return t;
804
- }, et = (e, t, n) => E.some((r) => r.parentId === e && r.name === t && r.id !== n), tt = (e) => {
805
- if (P === "workspace") throw new m(Ee);
806
- if (!Y(e).restricted) throw new _(`Collection ${e} is open: only a Restricted Collection takes grants`);
807
- let t = (F.get(e) ?? []).some((e) => e.userId === x && e.level === "owner");
808
- if (!Me && !t) throw new ne("only its owner or a workspace admin manages its grants");
809
- }, nt = (t) => {
810
- if (P === "workspace") throw new e("required_check_recorders", we);
811
- if (!Me) throw new ne("permission denied");
812
- if (t === "") throw new _("required_check_id is required");
813
- if (!N.some((e) => e.id === t)) throw k("Required Check", t);
814
- return Ae(t);
815
- }, rt = async ({ changeSetId: e, branchId: t, expectedHeadId: n, data: r, fieldMask: a }) => {
816
- let o = Z(e).chains.find((e) => e.branches.some((e) => e.id === t)), s = o?.branches.find((e) => e.id === t);
817
- if (!o || !s) throw k("Branch", t);
818
- let c = U(o.contentId);
819
- if (J(c), B.has(t)) throw new _("a Pending Merge waits on this Branch: resolve or abort it first");
820
- if (n === "") throw new _("expected_head_id is required");
821
- if (s.headRevisionId !== n) throw new i({
832
+ }, rt = (e, t, n) => S.some((r) => r.parentId === e && r.name === t && r.id !== n), it = (t) => {
833
+ if (j === "workspace") throw new e(je);
834
+ if (!J(t).restricted) throw new u(`Collection ${t} is open: only a Restricted Collection takes grants`);
835
+ let n = (N.get(t) ?? []).some((e) => e.userId === y && e.level === "owner");
836
+ if (!F && !n) throw new ne("only its owner or a workspace admin manages its grants");
837
+ }, at = (e) => {
838
+ if (j === "workspace") throw new oe("required_check_recorders", ke);
839
+ if (!F) throw new ne("permission denied");
840
+ if (e === "") throw new u("required_check_id is required");
841
+ if (!A.some((t) => t.id === e)) throw D("Required Check", e);
842
+ return Pe(e);
843
+ }, ot = async ({ changeSetId: e, branchId: t, expectedHeadId: n, data: r, fieldMask: i }) => {
844
+ let a = X(e).chains.find((e) => e.branches.some((e) => e.id === t)), s = a?.branches.find((e) => e.id === t);
845
+ if (!a || !s) throw D("Branch", t);
846
+ let c = H(a.contentId);
847
+ if (q(c), z.has(t)) throw new u("a Pending Merge waits on this Branch: resolve or abort it first");
848
+ if (n === "") throw new u("expected_head_id is required");
849
+ if (s.headRevisionId !== n) throw new o({
822
850
  contentId: c.id,
823
851
  branchId: t,
824
852
  expectedHeadId: n,
825
853
  currentHeadId: s.headRevisionId
826
854
  });
827
- let l = q(c, s.headRevisionId) ?? {}, u = JSON.parse(JSON.stringify(r)), d;
828
- if (a) {
829
- let e = Object.keys(u).filter((e) => !a.includes(e));
830
- if (e.length > 0) throw new _(`data holds ${e.join(", ")}, which the mask doesn't name`);
831
- d = structuredClone(l);
832
- for (let e of a) e in u ? d[e] = u[e] : delete d[e];
833
- } else d = u;
834
- return it({
855
+ let l = K(c, s.headRevisionId) ?? {}, d = JSON.parse(JSON.stringify(r)), f;
856
+ if (i) {
857
+ let e = Object.keys(d).filter((e) => !i.includes(e));
858
+ if (e.length > 0) throw new u(`data holds ${e.join(", ")}, which the mask doesn't name`);
859
+ f = structuredClone(l);
860
+ for (let e of i) e in d ? f[e] = d[e] : delete f[e];
861
+ } else f = d;
862
+ return st({
835
863
  changeSetId: e,
836
- chain: o,
864
+ chain: a,
837
865
  branch: s,
838
866
  c,
839
- data: d,
867
+ data: f,
840
868
  cause: "save"
841
869
  });
842
- }, it = ({ changeSetId: e, chain: t, branch: n, c: r, data: i, cause: a, secondParentId: o = "" }) => {
843
- let s = n.id, c = `rev_stub_${H++}`, l = b();
870
+ }, st = ({ changeSetId: e, chain: t, branch: n, c: r, data: i, cause: a, secondParentId: o = "" }) => {
871
+ let s = n.id, c = `rev_stub_${V++}`, l = v();
844
872
  return r.revisions = [{
845
873
  id: c,
846
874
  contentId: r.id,
@@ -848,7 +876,7 @@ function M(y = {}) {
848
876
  secondParentId: o,
849
877
  blueprintReleaseId: r.blueprintReleaseId,
850
878
  createTime: l,
851
- author: x,
879
+ author: y,
852
880
  cause: a,
853
881
  branchId: s,
854
882
  changeSetId: e,
@@ -869,17 +897,17 @@ function M(y = {}) {
869
897
  revisionCreateTime: l,
870
898
  releaseId: ""
871
899
  };
872
- }, at = (e, t) => {
873
- let n = Z(e), r = n.chains.find((e) => e.branches.some((e) => e.id === t)), i = r?.branches.find((e) => e.id === t);
874
- if (!r || !i) throw k("Branch", t);
900
+ }, ct = (e, t) => {
901
+ let n = X(e), r = n.chains.find((e) => e.branches.some((e) => e.id === t)), i = r?.branches.find((e) => e.id === t);
902
+ if (!r || !i) throw D("Branch", t);
875
903
  return {
876
904
  cs: n,
877
905
  chain: r,
878
906
  branch: i,
879
- c: U(r.contentId)
907
+ c: H(r.contentId)
880
908
  };
881
- }, ot = (e, t) => {
882
- for (let n of T) for (let r of n.chains) {
909
+ }, lt = (e, t) => {
910
+ for (let n of x) for (let r of n.chains) {
883
911
  let n = r.branches.find((t) => t.id === e);
884
912
  if (!n) continue;
885
913
  let i = {
@@ -892,37 +920,37 @@ function M(y = {}) {
892
920
  fields: structuredClone(t.fields),
893
921
  merged: structuredClone(t.merged)
894
922
  };
895
- B.set(e, i), n.hasPendingMerge = !0, delete Ue[e];
923
+ z.set(e, i), n.hasPendingMerge = !0, delete Ke[e];
896
924
  return;
897
925
  }
898
- throw k("Branch", e);
899
- }, st = (e) => {
900
- B.delete(e);
901
- for (let t of T) for (let n of t.chains) {
926
+ throw D("Branch", e);
927
+ }, ut = (e) => {
928
+ z.delete(e);
929
+ for (let t of x) for (let n of t.chains) {
902
930
  let t = n.branches.find((t) => t.id === e);
903
931
  t && (t.hasPendingMerge = !1);
904
932
  }
905
- }, ct = (e, t) => {
933
+ }, dt = (e, t) => {
906
934
  let n = t.validityPeriod;
907
- if (G(e)) {
908
- if (!n || !g.test(n.firstDay)) throw new _("validity_period.first_day is required for Dated Content");
909
- if (n.lastDay !== "" && (!g.test(n.lastDay) || n.lastDay < n.firstDay)) throw new _("validity_period.last_day is a day on or after first_day");
910
- } else if (n) throw new _("validity_period is refused for undated Content");
911
- let r = Ye(M[e.blueprintReleaseId]?.releaseSpec, t.releaseSpec ?? {}).map((e) => ({
935
+ if (W(e)) {
936
+ if (!n || !_.test(n.firstDay)) throw new u("validity_period.first_day is required for Dated Content");
937
+ if (n.lastDay !== "" && (!_.test(n.lastDay) || n.lastDay < n.firstDay)) throw new u("validity_period.last_day is a day on or after first_day");
938
+ } else if (n) throw new u("validity_period is refused for undated Content");
939
+ let r = Qe(T[e.blueprintReleaseId]?.releaseSpec, t.releaseSpec ?? {}).map((e) => ({
912
940
  source: "fieldkit",
913
941
  code: "required",
914
942
  path: `/${e}`
915
943
  }));
916
- if (r.length > 0) throw new oe("the Release Spec values break the Blueprint Release", r);
944
+ if (r.length > 0) throw new f("the Release Spec values break the Blueprint Release", r);
917
945
  if (n && n.lastDay !== "") {
918
946
  let r = (e.timeline ?? []).filter((e) => e.validityPeriod && e.validityPeriod.lastDay !== "" && n.firstDay <= e.validityPeriod.firstDay && e.validityPeriod.lastDay <= n.lastDay && !t.supersedesReleaseIds.includes(e.releaseId)).map((e) => e.releaseId);
919
- if (r.length > 0) throw new u(e.id, r);
947
+ if (r.length > 0) throw new se(e.id, r);
920
948
  }
921
- }, lt = (e, t) => {
949
+ }, ft = (e, t) => {
922
950
  let n = e.plannedReleases.filter((e) => e.contentId === t.id && e.proposed), r = e.plannedReleases.filter((e) => !(e.contentId === t.id && e.proposed)), i = [], a = (e, r, a) => {
923
951
  let o = n.find((t) => t.proposedForReleaseId === e.releaseId && t.splitFromReleaseId === a);
924
952
  i.push({
925
- id: o?.id ?? `rls_stub_${H++}`,
953
+ id: o?.id ?? `rls_stub_${V++}`,
926
954
  contentId: t.id,
927
955
  kind: "date_only",
928
956
  branchId: "",
@@ -941,23 +969,23 @@ function M(y = {}) {
941
969
  let t = r.validityPeriod;
942
970
  t && !e.supersedesReleaseIds.includes(r.releaseId) && t.firstDay < n.firstDay && (t.lastDay === "" || t.lastDay >= n.firstDay) && (a(r, {
943
971
  firstDay: t.firstDay,
944
- lastDay: be(n.firstDay, -1)
972
+ lastDay: Ce(n.firstDay, -1)
945
973
  }, ""), n.lastDay !== "" && (t.lastDay === "" || t.lastDay > n.lastDay) && a(r, {
946
- firstDay: be(n.lastDay, 1),
974
+ firstDay: Ce(n.lastDay, 1),
947
975
  lastDay: t.lastDay
948
976
  }, r.releaseId));
949
977
  }
950
978
  }
951
979
  e.plannedReleases = [...r, ...i];
952
- }, X = (e) => {
953
- let t = T.find((t) => t.id === e);
954
- if (!t) throw k("Change Set", e);
980
+ }, Y = (e) => {
981
+ let t = x.find((t) => t.id === e);
982
+ if (!t) throw D("Change Set", e);
955
983
  return t;
956
- }, Z = (e) => {
957
- let t = X(e);
958
- if (t.state !== "open") throw new p(t.state);
984
+ }, X = (e) => {
985
+ let t = Y(e);
986
+ if (t.state !== "open") throw new m(t.state);
959
987
  return t;
960
- }, ut = (e) => S.find((t) => t.slug === e)?.name ?? e, dt = (e, t, n = /* @__PURE__ */ new Set()) => e === t || !n.has(e) && (n.add(e), (T.find((t) => t.id === e)?.dependsOnChangeSetIds ?? []).some((e) => dt(e, t, n))), ft = (e) => [...e.chains.flatMap((e) => e.branches.map((t) => ({
988
+ }, pt = (e) => le.find((t) => t.slug === e)?.name ?? e, mt = (e, t, n = /* @__PURE__ */ new Set()) => e === t || !n.has(e) && (n.add(e), (x.find((t) => t.id === e)?.dependsOnChangeSetIds ?? []).some((e) => mt(e, t, n))), ht = (e) => [...e.chains.flatMap((e) => e.branches.map((t) => ({
961
989
  key: t.id,
962
990
  branchless: !1,
963
991
  contentId: e.contentId,
@@ -967,9 +995,12 @@ function M(y = {}) {
967
995
  branchless: !0,
968
996
  contentId: e.contentId,
969
997
  revision: e.revisionId
970
- }))], pt = (e) => D.find((t) => t.id === e)?.blueprintId, mt = (e, t) => e.blueprintAccessors.length === 0 || e.blueprintAccessors.includes(pt(t) ?? ""), ht = (e) => {
971
- let t = ft(e), n = (t, n) => Be.filter((n) => n.changeSetId === e.id && n.requiredCheckId === t.id).filter((e) => (t.scope === "change_set" ? "" : Object.keys(e.heads)[0]) === n).reverse().map(({ changeSetId: e, ...t }) => structuredClone(t)), r = (e, t, n) => {
972
- let r = n[0], i = r ? !h(r.heads, t.heads) : !1;
998
+ }))], gt = (e) => {
999
+ let t = C.find((t) => t.id === e)?.blueprintId;
1000
+ return w.find((e) => e.id === t)?.accessor;
1001
+ }, _t = (e, t) => e.blueprintAccessors.length === 0 || e.blueprintAccessors.includes(gt(t) ?? ""), vt = (e) => {
1002
+ let t = ht(e), n = (t, n) => Ue.filter((n) => n.changeSetId === e.id && n.requiredCheckId === t.id).filter((e) => (t.scope === "change_set" ? "" : Object.keys(e.heads)[0]) === n).reverse().map(({ changeSetId: e, ...t }) => structuredClone(t)), r = (e, t, n) => {
1003
+ let r = n[0], i = r ? !g(r.heads, t.heads) : !1;
973
1004
  return {
974
1005
  check: structuredClone(e),
975
1006
  ...t,
@@ -978,8 +1009,8 @@ function M(y = {}) {
978
1009
  cleared: !!r && !i && r.outcome !== "failed"
979
1010
  };
980
1011
  }, i = [], a = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id);
981
- for (let e of [...N].sort(a)) {
982
- let a = t.filter((t) => mt(e, t.contentId));
1012
+ for (let e of [...A].sort(a)) {
1013
+ let a = t.filter((t) => _t(e, t.contentId));
983
1014
  if (e.scope === "change_set") {
984
1015
  if (a.length === 0) continue;
985
1016
  let o = Object.fromEntries(t.map((e) => [e.key, e.revision]));
@@ -999,48 +1030,48 @@ function M(y = {}) {
999
1030
  }, n(e, t.key)));
1000
1031
  }
1001
1032
  return i;
1002
- }, gt = (e, t) => {
1033
+ }, yt = (e, t) => {
1003
1034
  let n = [], r = re(e);
1004
- for (let r of e.chains) for (let e of r.branches) t[e.id] !== e.headRevisionId && n.push(j("moved_head", {
1035
+ for (let r of e.chains) for (let e of r.branches) t[e.id] !== e.headRevisionId && n.push(k("moved_head", {
1005
1036
  contentId: r.contentId,
1006
1037
  branchId: e.id,
1007
1038
  expectedHeadId: t[e.id] ?? "",
1008
1039
  currentHeadId: e.headRevisionId
1009
1040
  }));
1010
- for (let [e, i] of Object.entries(t)) e in r || n.push(j("moved_head", {
1041
+ for (let [e, i] of Object.entries(t)) e in r || n.push(k("moved_head", {
1011
1042
  branchId: e,
1012
1043
  expectedHeadId: i
1013
1044
  }));
1014
- for (let t of e.chains) for (let e of t.branches) We.has(e.id) && n.push(j("behind_base", {
1045
+ for (let t of e.chains) for (let e of t.branches) qe.has(e.id) && n.push(k("behind_base", {
1015
1046
  contentId: t.contentId,
1016
1047
  branchId: e.id
1017
- })), B.has(e.id) && n.push(j("pending_merge", {
1048
+ })), z.has(e.id) && n.push(k("pending_merge", {
1018
1049
  contentId: t.contentId,
1019
1050
  branchId: e.id
1020
1051
  }));
1021
1052
  for (let t of e.dependsOnChangeSetIds) {
1022
- let e = T.find((e) => e.id === t)?.state;
1023
- e === "open" ? n.push(j("unpublished_dependency", { dependencyChangeSetId: t })) : e === "discarded" && n.push(j("discarded_dependency", { dependencyChangeSetId: t }));
1053
+ let e = x.find((e) => e.id === t)?.state;
1054
+ e === "open" ? n.push(k("unpublished_dependency", { dependencyChangeSetId: t })) : e === "discarded" && n.push(k("discarded_dependency", { dependencyChangeSetId: t }));
1024
1055
  }
1025
- for (let t of ht(e)) t.cleared || n.push(j("outstanding_check", {
1056
+ for (let t of vt(e)) t.cleared || n.push(k("outstanding_check", {
1026
1057
  requiredCheckId: t.check.id,
1027
1058
  contentId: t.contentId,
1028
1059
  branchId: t.branchId,
1029
1060
  releaseId: t.releaseId
1030
1061
  }));
1031
1062
  for (let t of e.chains) {
1032
- let e = D.find((e) => e.id === t.contentId);
1063
+ let e = C.find((e) => e.id === t.contentId);
1033
1064
  for (let r of t.branches) {
1034
- let t = e && q(e, r.headRevisionId);
1035
- if (e && t) for (let i of Ye(M[e.blueprintReleaseId]?.fields, t)) n.push(j("missing_required_field", {
1065
+ let t = e && K(e, r.headRevisionId);
1066
+ if (e && t) for (let i of Qe(T[e.blueprintReleaseId]?.fields, t)) n.push(k("missing_required_field", {
1036
1067
  contentId: e.id,
1037
1068
  revisionId: r.headRevisionId,
1038
1069
  path: `/${i}`
1039
1070
  }));
1040
1071
  }
1041
1072
  }
1042
- return [...n, ...structuredClone(Ve[e.id] ?? [])];
1043
- }, Q = (e) => {
1073
+ return [...n, ...structuredClone(We[e.id] ?? [])];
1074
+ }, Z = (e) => {
1044
1075
  let t = re(e);
1045
1076
  return e.plannedReleases.filter((e) => !e.withheld).map((n) => ({
1046
1077
  id: n.id,
@@ -1053,33 +1084,33 @@ function M(y = {}) {
1053
1084
  validityPeriod: n.validityPeriod ? { ...n.validityPeriod } : void 0
1054
1085
  }));
1055
1086
  };
1056
- for (let [e, t] of Object.entries(Ue)) t.pending && ot(e, t);
1057
- let _t = (e, t) => {
1087
+ for (let [e, t] of Object.entries(Ke)) t.pending && lt(e, t);
1088
+ let bt = (e, t) => {
1058
1089
  for (let n of Object.keys(e)) n in t || delete e[n];
1059
1090
  Object.assign(e, t);
1060
- }, vt = (e, t) => {
1091
+ }, xt = (e, t) => {
1061
1092
  let n = e.chains[0], r = n?.branches[0], i = r?.effectiveOn ?? "";
1062
- if (!n || !r || !i) throw new _("the Direct Edit's Content is undated: no period to plan");
1063
- let a = U(n.contentId), o = a.timeline ?? [], s = o.find((e) => e.releaseId === r.carriedReleaseId), c = s?.validityPeriod && i <= e.createTime.slice(0, 10) ? s : void 0, l = c?.validityPeriod ? { ...c.validityPeriod } : {
1093
+ if (!n || !r || !i) throw new u("the Direct Edit's Content is undated: no period to plan");
1094
+ let a = H(n.contentId), o = a.timeline ?? [], s = o.find((e) => e.releaseId === r.carriedReleaseId), c = s?.validityPeriod && i <= e.createTime.slice(0, 10) ? s : void 0, l = c?.validityPeriod ? { ...c.validityPeriod } : {
1064
1095
  firstDay: i,
1065
1096
  lastDay: ""
1066
1097
  };
1067
1098
  if (t !== void 0) {
1068
- if (t !== "" && (!g.test(t) || t < l.firstDay)) throw new _("validity_last_day is YYYY-MM-DD, not before the first day");
1099
+ if (t !== "" && (!_.test(t) || t < l.firstDay)) throw new u("validity_last_day is YYYY-MM-DD, not before the first day");
1069
1100
  l.lastDay = t;
1070
1101
  }
1071
1102
  let d = o.filter((e) => e.releaseId !== c?.releaseId && e.validityPeriod && l.lastDay !== "" && l.firstDay <= e.validityPeriod.firstDay && e.validityPeriod.lastDay !== "" && e.validityPeriod.lastDay <= l.lastDay).map((e) => e.releaseId);
1072
- if (d.length > 0) throw new u(a.id, d, !0);
1103
+ if (d.length > 0) throw new se(a.id, d, !0);
1073
1104
  let f = [];
1074
1105
  !c && s?.validityPeriod && s.validityPeriod.firstDay < i && f.push({
1075
- id: `rls_stub_${H++}`,
1106
+ id: `rls_stub_${V++}`,
1076
1107
  contentId: a.id,
1077
1108
  kind: "date_only",
1078
1109
  branchId: "",
1079
1110
  revisionId: s.revisionId,
1080
1111
  validityPeriod: {
1081
1112
  firstDay: s.validityPeriod.firstDay,
1082
- lastDay: ye(i)
1113
+ lastDay: Se(i)
1083
1114
  },
1084
1115
  supersedesReleaseIds: [s.releaseId],
1085
1116
  proposed: !0,
@@ -1100,19 +1131,19 @@ function M(y = {}) {
1100
1131
  dateOnlyReleases: f,
1101
1132
  laterWordings: p
1102
1133
  };
1103
- }, yt = async (e, t, n, r = {}) => {
1134
+ }, St = async (e, t, n, r = {}) => {
1104
1135
  let i = e.id, a = e.chains[0], o = a?.branches[0];
1105
1136
  if (!a || !o) throw Error(`Direct Edit ${i} has no Branch`);
1106
1137
  let s = !!o.effectiveOn;
1107
- if (!s && (r.validityLastDay !== void 0 || (r.carryForward ?? []).length > 0)) throw new _("validity_last_day and carry_forward are for Dated Content");
1138
+ if (!s && (r.validityLastDay !== void 0 || (r.carryForward ?? []).length > 0)) throw new u("validity_last_day and carry_forward are for Dated Content");
1108
1139
  if (e.state === "open") {
1109
- let t = s ? vt(e, r.validityLastDay) : void 0, c = e.plannedReleases.find((e) => e.branchId === o.id && !e.proposed);
1110
- if (c ? (n || t) && await $.updatePlannedRelease({
1140
+ let t = s ? xt(e, r.validityLastDay) : void 0, c = e.plannedReleases.find((e) => e.branchId === o.id && !e.proposed);
1141
+ if (c ? (n || t) && await Q.updatePlannedRelease({
1111
1142
  changeSetId: i,
1112
1143
  plannedReleaseId: c.id,
1113
1144
  releaseSpec: n,
1114
1145
  validityPeriod: t?.validityPeriod
1115
- }) : await $.planRelease({
1146
+ }) : await Q.planRelease({
1116
1147
  changeSetId: i,
1117
1148
  branchId: o.id,
1118
1149
  releaseSpec: n,
@@ -1120,12 +1151,12 @@ function M(y = {}) {
1120
1151
  supersedesReleaseIds: t?.correctsReleaseId ? [t.correctsReleaseId] : void 0
1121
1152
  }), t) {
1122
1153
  let n = new Map((r.carryForward ?? []).map((e) => [e.releaseId, e.carry])), i = t.laterWordings.filter((e) => !n.has(e.releaseId));
1123
- if (i.length > 0) throw new _(`carry_forward has no answer for the later wordings ${i.map((e) => e.releaseId).join(", ")}`);
1154
+ if (i.length > 0) throw new u(`carry_forward has no answer for the later wordings ${i.map((e) => e.releaseId).join(", ")}`);
1124
1155
  e.plannedReleases.push(...t.dateOnlyReleases);
1125
1156
  for (let r of a.branches.slice(1)) {
1126
1157
  let i = t.laterWordings.find((e) => e.releaseId === r.carriedReleaseId);
1127
1158
  i && n.get(i.releaseId) && e.plannedReleases.push({
1128
- id: `rls_stub_${H++}`,
1159
+ id: `rls_stub_${V++}`,
1129
1160
  contentId: a.contentId,
1130
1161
  kind: "revision",
1131
1162
  branchId: r.id,
@@ -1140,61 +1171,61 @@ function M(y = {}) {
1140
1171
  }
1141
1172
  }
1142
1173
  }
1143
- let c = await $.publish({
1174
+ let c = await Q.publish({
1144
1175
  id: i,
1145
1176
  reviewedHeads: {
1146
1177
  ...re(e),
1147
1178
  [o.id]: t
1148
1179
  }
1149
- }), l = U(a.contentId);
1180
+ }), l = H(a.contentId);
1150
1181
  l.editingBlock?.changeSetId === i && (l.editingBlock = void 0);
1151
- let u = l.branches[i], d = c.releases.find((e) => e.branchId === o.id), f = a.branches.length > 1;
1152
- if (u && d && !f && l.main?.revisionId !== u.revisionId) {
1153
- let { branchId: e, ...t } = structuredClone(u);
1182
+ let d = l.branches[i], f = c.releases.find((e) => e.branchId === o.id), p = a.branches.length > 1;
1183
+ if (d && f && !p && l.main?.revisionId !== d.revisionId) {
1184
+ let { branchId: e, ...t } = structuredClone(d);
1154
1185
  l.main = t, l.inForce = {
1155
1186
  ...structuredClone(t),
1156
- releaseId: d.id
1187
+ releaseId: f.id
1157
1188
  }, l.timeline = [...l.timeline ?? [], {
1158
1189
  ordinal: (l.timeline?.length ?? 0) + 1,
1159
- releaseId: d.id,
1190
+ releaseId: f.id,
1160
1191
  kind: "revision",
1161
- revisionId: u.revisionId,
1192
+ revisionId: d.revisionId,
1162
1193
  blueprintReleaseId: l.blueprintReleaseId,
1163
1194
  publishTime: c.publishTime,
1164
1195
  first: !1
1165
1196
  }];
1166
1197
  }
1167
1198
  return c;
1168
- }, $ = {
1199
+ }, Q = {
1169
1200
  async listBlockReasons() {
1170
- return [...w].sort(Ze).map((e) => ({ ...e }));
1201
+ return [...b].sort(et).map((e) => ({ ...e }));
1171
1202
  },
1172
1203
  async createBlockReason({ name: e }) {
1173
- let t = Se(e);
1174
- if (Qe(t)) throw new ie(t);
1204
+ let t = Te(e);
1205
+ if (tt(t)) throw new ie(t);
1175
1206
  let n = {
1176
- id: `br_stub_${H++}`,
1207
+ id: `br_stub_${V++}`,
1177
1208
  name: t,
1178
- createTime: b(),
1179
- updateTime: b()
1209
+ createTime: v(),
1210
+ updateTime: v()
1180
1211
  };
1181
- return w.push(n), { ...n };
1212
+ return b.push(n), { ...n };
1182
1213
  },
1183
1214
  async renameBlockReason({ id: e, name: t }) {
1184
- let n = Se(t), r = w.find((t) => t.id === e);
1185
- if (!r) throw k("Block Reason", e);
1186
- if (Qe(n, e)) throw new ie(n);
1187
- return r.name = n, r.updateTime = b(), { ...r };
1215
+ let n = Te(t), r = b.find((t) => t.id === e);
1216
+ if (!r) throw D("Block Reason", e);
1217
+ if (tt(n, e)) throw new ie(n);
1218
+ return r.name = n, r.updateTime = v(), { ...r };
1188
1219
  },
1189
1220
  async deleteBlockReason({ id: e }) {
1190
- if (!w.some((t) => t.id === e)) throw k("Block Reason", e);
1191
- w = w.filter((t) => t.id !== e);
1221
+ if (!b.some((t) => t.id === e)) throw D("Block Reason", e);
1222
+ b = b.filter((t) => t.id !== e);
1192
1223
  },
1193
1224
  async listChangeSets(e = {}) {
1194
- let t = T.filter((t) => (!e.state || t.state === e.state) && (!e.assigneeId || t.assigneeIds.includes(e.assigneeId)) && (!e.contentId || t.chains.some((t) => t.contentId === e.contentId)) && (!e.kind || (t.kind ?? "change_set") === e.kind) && (!e.editorId || t.editorId === e.editorId)), n = Math.min(e.pageSize || 50, 200), r = e.pageToken ? Number(e.pageToken) : 0;
1225
+ let t = x.filter((t) => (!e.state || t.state === e.state) && (!e.assigneeId || t.assigneeIds.includes(e.assigneeId)) && (!e.contentId || t.chains.some((t) => t.contentId === e.contentId)) && (!e.kind || (t.kind ?? "change_set") === e.kind) && (!e.editorId || t.editorId === e.editorId)), n = Math.min(e.pageSize || 50, 200), r = e.pageToken ? Number(e.pageToken) : 0;
1195
1226
  return {
1196
1227
  changeSets: t.slice(r, r + n).map((e) => ({
1197
- ...A(e),
1228
+ ...O(e),
1198
1229
  chains: [],
1199
1230
  dependsOnChangeSetIds: [],
1200
1231
  plannedReleases: []
@@ -1203,115 +1234,115 @@ function M(y = {}) {
1203
1234
  };
1204
1235
  },
1205
1236
  async createChangeSet({ name: e, source: t }) {
1206
- let n = O(e, "name", 200), r = t ? xe(t) : void 0, i = {
1207
- id: `cs_stub_${H++}`,
1237
+ let n = E(e, "name", 200), r = t ? we(t) : void 0, i = {
1238
+ id: `cs_stub_${V++}`,
1208
1239
  name: n,
1209
1240
  source: r,
1210
1241
  state: "open",
1211
- createdBy: x,
1212
- createTime: b(),
1242
+ createdBy: y,
1243
+ createTime: v(),
1213
1244
  chains: [],
1214
1245
  dependsOnChangeSetIds: [],
1215
1246
  status: "",
1216
1247
  assigneeIds: [],
1217
1248
  plannedReleases: []
1218
1249
  };
1219
- return T.unshift(i), A(i);
1250
+ return x.unshift(i), O(i);
1220
1251
  },
1221
1252
  async getChangeSet(e) {
1222
- return A(X(e));
1253
+ return O(Y(e));
1223
1254
  },
1224
1255
  async updateChangeSet({ id: e, updateMask: t, name: n, source: r }) {
1225
- let i = Z(e);
1226
- if (t.length === 0) throw new _("update_mask is required");
1227
- let a = t.includes("name") ? O(n ?? "", "name", 200) : i.name, o = i.source;
1228
- return t.includes("source") && (o = r ? xe(r) : void 0), i.name = a, i.source = o, A(i);
1256
+ let i = X(e);
1257
+ if (t.length === 0) throw new u("update_mask is required");
1258
+ let a = t.includes("name") ? E(n ?? "", "name", 200) : i.name, o = i.source;
1259
+ return t.includes("source") && (o = r ? we(r) : void 0), i.name = a, i.source = o, O(i);
1229
1260
  },
1230
1261
  async setChangeSetStatus({ id: e, expectedStatus: t, status: n }) {
1231
- let r = Z(e);
1232
- if (r.status !== t) throw new a(r.status);
1233
- if (r.status === n) return A(r);
1234
- if (!S.some((e) => e.slug === n)) throw new _(`status "${n}" is not in the workspace's catalogue`);
1235
- if (S.some((e) => e.slug === r.status) && !(C[r.status] ?? []).includes(n)) throw new o({
1262
+ let r = X(e);
1263
+ if (r.status !== t) throw new c(r.status);
1264
+ if (r.status === n) return O(r);
1265
+ if (!le.some((e) => e.slug === n)) throw new u(`status "${n}" is not in the workspace's catalogue`);
1266
+ if (le.some((e) => e.slug === r.status) && !(ue[r.status] ?? []).includes(n)) throw new i({
1236
1267
  fromStatus: r.status,
1237
1268
  toStatus: n,
1238
- reason: `There is no transition from ${ut(r.status)} to ${ut(n)}.`,
1269
+ reason: `There is no transition from ${pt(r.status)} to ${pt(n)}.`,
1239
1270
  requiresPermission: !1
1240
1271
  });
1241
- return r.status = n, A(r);
1272
+ return r.status = n, O(r);
1242
1273
  },
1243
1274
  async setChangeSetAssignees({ id: e, assigneeIds: t }) {
1244
- let n = X(e);
1245
- if (new Set(t).size !== t.length) throw new _("each assignee is given once");
1246
- if (t.length > 50) throw new _("at most 50 assignees");
1247
- return n.assigneeIds = [...t], A(n);
1275
+ let n = Y(e);
1276
+ if (new Set(t).size !== t.length) throw new u("each assignee is given once");
1277
+ if (t.length > 50) throw new u("at most 50 assignees");
1278
+ return n.assigneeIds = [...t], O(n);
1248
1279
  },
1249
1280
  async addDependency({ id: e, dependsOnId: t }) {
1250
- let n = Z(e), r = X(t);
1251
- if (r.state !== "open") throw new _(`Change Set ${t} is ${r.state}`);
1252
- if (dt(t, e)) throw new _("the dependency would close a cycle");
1253
- return n.dependsOnChangeSetIds.includes(t) || n.dependsOnChangeSetIds.push(t), A(n);
1281
+ let n = X(e), r = Y(t);
1282
+ if (r.state !== "open") throw new u(`Change Set ${t} is ${r.state}`);
1283
+ if (mt(t, e)) throw new u("the dependency would close a cycle");
1284
+ return n.dependsOnChangeSetIds.includes(t) || n.dependsOnChangeSetIds.push(t), O(n);
1254
1285
  },
1255
1286
  async removeDependency({ id: e, dependsOnId: t }) {
1256
- let n = Z(e);
1257
- if (!n.dependsOnChangeSetIds.includes(t)) throw k(`dependency of Change Set ${e} on`, t);
1258
- return n.dependsOnChangeSetIds = n.dependsOnChangeSetIds.filter((e) => e !== t), A(n);
1287
+ let n = X(e);
1288
+ if (!n.dependsOnChangeSetIds.includes(t)) throw D(`dependency of Change Set ${e} on`, t);
1289
+ return n.dependsOnChangeSetIds = n.dependsOnChangeSetIds.filter((e) => e !== t), O(n);
1259
1290
  },
1260
1291
  async validatePublish({ id: e, reviewedHeads: t }) {
1261
- let n = X(e);
1262
- ke(e);
1263
- let r = Ke.get(e);
1264
- if (r && h(r, t)) return {
1292
+ let n = Y(e);
1293
+ M(e);
1294
+ let r = Ye.get(e);
1295
+ if (r && g(r, t)) return {
1265
1296
  blockers: [],
1266
- releases: Q(n),
1297
+ releases: Z(n),
1267
1298
  published: !0
1268
1299
  };
1269
- if (n.state !== "open") throw new p(n.state);
1300
+ if (n.state !== "open") throw new m(n.state);
1270
1301
  return {
1271
- blockers: gt(n, t),
1272
- releases: Q(n),
1302
+ blockers: yt(n, t),
1303
+ releases: Z(n),
1273
1304
  published: !1
1274
1305
  };
1275
1306
  },
1276
- async publish({ id: e, reviewedHeads: n }) {
1277
- let r = X(e);
1278
- ke(e);
1279
- let i = Ke.get(e);
1280
- if (i && h(i, n)) return {
1281
- changeSet: A(r),
1282
- publishTime: r.closeTime ?? b(),
1283
- releases: Q(r)
1307
+ async publish({ id: e, reviewedHeads: t }) {
1308
+ let n = Y(e);
1309
+ M(e);
1310
+ let r = Ye.get(e);
1311
+ if (r && g(r, t)) return {
1312
+ changeSet: O(n),
1313
+ publishTime: n.closeTime ?? v(),
1314
+ releases: Z(n)
1284
1315
  };
1285
- if (r.state !== "open") throw new p(r.state);
1286
- let a = gt(r, n);
1287
- if (a.length > 0) throw new t(a);
1288
- let o = Q(r);
1289
- return r.state = "published", r.closeTime = b(), Ke.set(e, { ...n }), {
1290
- changeSet: A(r),
1291
- publishTime: r.closeTime,
1292
- releases: o
1316
+ if (n.state !== "open") throw new m(n.state);
1317
+ let i = yt(n, t);
1318
+ if (i.length > 0) throw new s(i);
1319
+ let a = Z(n);
1320
+ return n.state = "published", n.closeTime = v(), Ye.set(e, { ...t }), {
1321
+ changeSet: O(n),
1322
+ publishTime: n.closeTime,
1323
+ releases: a
1293
1324
  };
1294
1325
  },
1295
1326
  async changeValidity({ releaseId: e, validityPeriod: n, changeSetName: r, idempotencyKey: i }) {
1296
- return V(i, [
1327
+ return B(i, [
1297
1328
  "changeValidity",
1298
1329
  e,
1299
1330
  n,
1300
1331
  r
1301
1332
  ], async () => {
1302
- let i = D.find((t) => (t.timeline ?? []).some((t) => t.releaseId === e));
1303
- if (!i) throw k("Release", e);
1304
- J(i);
1333
+ let i = C.find((t) => (t.timeline ?? []).some((t) => t.releaseId === e));
1334
+ if (!i) throw D("Release", e);
1335
+ q(i);
1305
1336
  let a = i.timeline ?? [], o = a.find((t) => t.releaseId === e);
1306
- if (!o?.validityPeriod || !G(i)) throw new _("undated Releases carry no Validity Period");
1337
+ if (!o?.validityPeriod || !W(i)) throw new u("undated Releases carry no Validity Period");
1307
1338
  let { firstDay: c, lastDay: l = "" } = n;
1308
- if (!g.test(c) || l !== "" && (!g.test(l) || l < c)) throw new _("validity_period is YYYY-MM-DD, the last day not before the first");
1309
- let d = M[i.blueprintReleaseId]?.accessor ?? "", f = R.find((e) => e.blueprintAccessor === d);
1310
- if (z(f).editingMode === "change_sets") throw new s(i.id, d);
1339
+ if (!_.test(c) || l !== "" && (!_.test(l) || l < c)) throw new u("validity_period is YYYY-MM-DD, the last day not before the first");
1340
+ let d = T[i.blueprintReleaseId]?.accessor ?? "", f = L.find((e) => e.blueprintAccessor === d);
1341
+ if (R(f).editingMode === "change_sets") throw new t(i.id, d);
1311
1342
  let p = a.filter((t) => t.releaseId !== e && t.validityPeriod && c <= t.validityPeriod.firstDay && (l === "" || t.validityPeriod.lastDay !== "" && t.validityPeriod.lastDay <= l)).map((e) => e.releaseId);
1312
- if (p.length > 0) throw new u(i.id, p, !0);
1313
- let ee = {
1314
- id: `rls_stub_${H++}`,
1343
+ if (p.length > 0) throw new se(i.id, p, !0);
1344
+ let m = {
1345
+ id: `rls_stub_${V++}`,
1315
1346
  contentId: i.id,
1316
1347
  kind: "date_only",
1317
1348
  branchId: "",
@@ -1325,68 +1356,68 @@ function M(y = {}) {
1325
1356
  proposedForReleaseId: "",
1326
1357
  splitFromReleaseId: "",
1327
1358
  withheld: !1
1328
- }, m = {
1329
- id: `cs_stub_${H++}`,
1359
+ }, h = {
1360
+ id: `cs_stub_${V++}`,
1330
1361
  name: r?.trim() || `Change of validity of ${i.id}`,
1331
1362
  state: "open",
1332
- createdBy: x,
1333
- createTime: b(),
1363
+ createdBy: y,
1364
+ createTime: v(),
1334
1365
  chains: [],
1335
1366
  dependsOnChangeSetIds: [],
1336
1367
  status: "",
1337
1368
  assigneeIds: [],
1338
- plannedReleases: [ee]
1339
- }, h = gt(m, {});
1340
- if (h.length > 0) throw new t(h);
1341
- let te = Q(m);
1342
- return m.state = "published", m.closeTime = b(), T.unshift(m), Ke.set(m.id, {}), i.timeline = a.map((t) => t.releaseId === e ? {
1369
+ plannedReleases: [m]
1370
+ }, g = yt(h, {});
1371
+ if (g.length > 0) throw new s(g);
1372
+ let ee = Z(h);
1373
+ return h.state = "published", h.closeTime = v(), x.unshift(h), Ye.set(h.id, {}), i.timeline = a.map((t) => t.releaseId === e ? {
1343
1374
  ...t,
1344
- releaseId: ee.id,
1375
+ releaseId: m.id,
1345
1376
  kind: "date_only",
1346
1377
  validityPeriod: {
1347
1378
  firstDay: c,
1348
1379
  lastDay: l
1349
1380
  },
1350
- publishTime: m.closeTime ?? b()
1381
+ publishTime: h.closeTime ?? v()
1351
1382
  } : t), {
1352
- changeSet: A(m),
1353
- publishTime: m.closeTime,
1354
- releases: te
1383
+ changeSet: O(h),
1384
+ publishTime: h.closeTime,
1385
+ releases: ee
1355
1386
  };
1356
1387
  });
1357
1388
  },
1358
1389
  async updateFromMain({ id: e, chainId: t, idempotencyKey: n }) {
1359
- return V(n, [
1390
+ return B(n, [
1360
1391
  "updateFromMain",
1361
1392
  e,
1362
1393
  t
1363
1394
  ], async () => {
1364
- let n = Z(e);
1365
- t || ke(e);
1395
+ let n = X(e);
1396
+ t || M(e);
1366
1397
  let r = t ? n.chains.filter((e) => e.id === t) : n.chains;
1367
- if (t && r.length === 0) throw k("Chain", t);
1368
- let i = structuredClone(He[e] ?? []), a = [], o = [];
1398
+ if (t && r.length === 0) throw D("Chain", t);
1399
+ let i = structuredClone(Ge[e] ?? []), a = [], o = [];
1369
1400
  for (let t of r) for (let n of t.branches) {
1370
1401
  let r = {
1371
1402
  branchId: n.id,
1372
1403
  contentId: t.contentId
1373
- }, s = Ue[n.id];
1374
- if (B.has(n.id)) a.push(r);
1375
- else if (s) ot(n.id, s), i.push(r);
1376
- else if (We.has(n.id)) {
1377
- let r = U(t.contentId);
1378
- it({
1404
+ }, s = Ke[n.id];
1405
+ if (z.has(n.id)) a.push(r);
1406
+ else if (s) lt(n.id, s), i.push(r);
1407
+ else if (qe.has(n.id)) {
1408
+ let r = H(t.contentId);
1409
+ st({
1379
1410
  changeSetId: e,
1380
1411
  chain: t,
1381
1412
  branch: n,
1382
1413
  c: r,
1383
- data: structuredClone(q(r, n.headRevisionId) ?? {}),
1414
+ data: structuredClone(K(r, n.headRevisionId) ?? {}),
1384
1415
  cause: "merge"
1385
- }), We.delete(n.id), o.push(n.id);
1416
+ }), qe.delete(n.id), o.push(n.id);
1386
1417
  }
1387
1418
  }
1388
1419
  return {
1389
- changeSet: A(n),
1420
+ changeSet: O(n),
1390
1421
  mergedBranchIds: o,
1391
1422
  conflicted: i,
1392
1423
  pending: a,
@@ -1395,27 +1426,27 @@ function M(y = {}) {
1395
1426
  });
1396
1427
  },
1397
1428
  async discardChangeSet(e) {
1398
- let t = Z(e);
1399
- return ke(e), t.state = "discarded", t.closeTime = b(), t.chains = [], A(t);
1429
+ let t = X(e);
1430
+ return M(e), t.state = "discarded", t.closeTime = v(), t.chains = [], O(t);
1400
1431
  },
1401
1432
  async listCheckResults(e) {
1402
- return ht(X(e));
1403
- },
1404
- async recordCheckResult({ changeSetId: e, requiredCheckId: t, heads: n, outcome: r, note: a }) {
1405
- let o = Z(e);
1406
- if (r === "waived" && a.trim() === "") throw new _("a waived result needs a note saying why");
1407
- if ([...a].length > 2e3) throw new _(`a note is at most ${d} characters`);
1408
- let s = N.find((e) => e.id === t);
1409
- if (!s) throw k("Required Check", t);
1410
- let c = Ae(t);
1411
- if (P === "guardian" && !c.everyMember && !c.userIds.includes(x)) throw new f(`recording results of Required Check ${t} needs its recorder relation`);
1412
- let l = ft(o), u = Object.keys(n);
1413
- if (s.scope === "branch" && u.length !== 1) throw new _("a Branch-scope result names one head");
1414
- if (s.scope === "change_set" && u.length !== l.length) throw new _("a Change Set-scope result names every head of the Change Set");
1415
- for (let e of u) {
1433
+ return vt(Y(e));
1434
+ },
1435
+ async recordCheckResult({ changeSetId: e, requiredCheckId: t, heads: n, outcome: r, note: i }) {
1436
+ let a = X(e);
1437
+ if (r === "waived" && i.trim() === "") throw new u("a waived result needs a note saying why");
1438
+ if ([...i].length > 2e3) throw new u(`a note is at most ${te} characters`);
1439
+ let s = A.find((e) => e.id === t);
1440
+ if (!s) throw D("Required Check", t);
1441
+ let c = Pe(t);
1442
+ if (j === "guardian" && !c.everyMember && !c.userIds.includes(y)) throw new d(`recording results of Required Check ${t} needs its recorder relation`);
1443
+ let l = ht(a), f = Object.keys(n);
1444
+ if (s.scope === "branch" && f.length !== 1) throw new u("a Branch-scope result names one head");
1445
+ if (s.scope === "change_set" && f.length !== l.length) throw new u("a Change Set-scope result names every head of the Change Set");
1446
+ for (let e of f) {
1416
1447
  let t = l.find((t) => t.key === e);
1417
- if (!t) throw new _(`heads name ${e}, which this Change Set doesn't hold`);
1418
- if (t.revision !== n[e]) throw new i({
1448
+ if (!t) throw new u(`heads name ${e}, which this Change Set doesn't hold`);
1449
+ if (t.revision !== n[e]) throw new o({
1419
1450
  contentId: t.contentId,
1420
1451
  branchId: t.branchless ? "" : t.key,
1421
1452
  expectedHeadId: n[e],
@@ -1423,105 +1454,106 @@ function M(y = {}) {
1423
1454
  });
1424
1455
  }
1425
1456
  let p = {
1426
- id: `cr_stub_${H++}`,
1457
+ id: `cr_stub_${V++}`,
1427
1458
  requiredCheckId: t,
1428
1459
  heads: { ...n },
1429
1460
  outcome: r,
1430
- note: a,
1431
- recordedBy: x,
1432
- recordTime: b()
1461
+ note: i,
1462
+ recordedBy: y,
1463
+ recordTime: v()
1433
1464
  };
1434
- return Be.push({
1465
+ return Ue.push({
1435
1466
  ...p,
1436
1467
  changeSetId: e
1437
1468
  }), structuredClone(p);
1438
1469
  },
1439
1470
  async getEditingSettings() {
1440
- let e = [...R].sort((e, t) => e.blueprintAccessor < t.blueprintAccessor ? -1 : 1);
1471
+ let e = [...L].sort((e, t) => e.blueprintAccessor < t.blueprintAccessor ? -1 : 1);
1441
1472
  return {
1442
- workspace: structuredClone(L),
1443
- overrides: e.map(Pe)
1473
+ workspace: structuredClone(I),
1474
+ overrides: e.map(Le)
1444
1475
  };
1445
1476
  },
1446
1477
  async getEffectiveEditingSettings(e) {
1447
- let t = R.find((t) => t.blueprintAccessor === e.trim());
1478
+ let t = L.find((t) => t.blueprintAccessor === e.trim());
1448
1479
  return {
1449
- effective: z(t),
1480
+ effective: R(t),
1450
1481
  editingModeOverridden: (t?.editingMode ?? null) !== null,
1451
1482
  editingBlockOverridden: (t?.editingBlock ?? null) !== null,
1452
1483
  forceGroupOverridden: (t?.forceGroup ?? null) !== null,
1453
- callerInForceGroup: Ie(z(t).forceGroup)
1484
+ callerInForceGroup: ze(R(t).forceGroup)
1454
1485
  };
1455
1486
  },
1456
1487
  async setEditingSettings(e) {
1457
- if (ze(), !Re.includes(e.editingMode)) throw new _("the workspace's editing settings need an Editing Mode");
1458
- return L = {
1488
+ if (He(), !Ve.includes(e.editingMode)) throw new u("the workspace's editing settings need an Editing Mode");
1489
+ return I = {
1459
1490
  ...e,
1460
- forceGroup: Le(e.forceGroup)
1461
- }, structuredClone(L);
1491
+ forceGroup: Be(e.forceGroup)
1492
+ }, structuredClone(I);
1462
1493
  },
1463
1494
  async setBlueprintEditingOverride({ blueprintAccessor: e, editingMode: t, editingBlock: n, forceGroup: r }) {
1464
- ze();
1465
- let i = O(e, "a Blueprint accessor", 200);
1466
- if (t === null && n === null && r === null) throw new _(`an override of "${i}" sets the Editing Mode, the Editing Block, the Force Group or several`);
1495
+ He();
1496
+ let i = E(e, "a Blueprint accessor", 200);
1497
+ if (t === null && n === null && r === null) throw new u(`an override of "${i}" sets the Editing Mode, the Editing Block, the Force Group or several`);
1498
+ L.some((e) => e.blueprintAccessor === i) || De(w, [i]);
1467
1499
  let a = {
1468
1500
  blueprintAccessor: i,
1469
1501
  editingMode: t,
1470
1502
  editingBlock: n,
1471
- forceGroup: r === null ? null : Le(r)
1503
+ forceGroup: r === null ? null : Be(r)
1472
1504
  };
1473
- return R = [...R.filter((e) => e.blueprintAccessor !== i), a], Pe(a);
1505
+ return L = [...L.filter((e) => e.blueprintAccessor !== i), a], Le(a);
1474
1506
  },
1475
1507
  async deleteBlueprintEditingOverride({ blueprintAccessor: e }) {
1476
- ze();
1508
+ He();
1477
1509
  let t = e.trim();
1478
- if (!R.some((e) => e.blueprintAccessor === t)) throw k("an editing override of", t);
1479
- R = R.filter((e) => e.blueprintAccessor !== t);
1510
+ if (!L.some((e) => e.blueprintAccessor === t)) throw D("an editing override of", t);
1511
+ L = L.filter((e) => e.blueprintAccessor !== t);
1480
1512
  },
1481
1513
  async listRequiredChecks() {
1482
1514
  let e = (e, t) => e.name < t.name ? -1 : e.name > t.name ? 1 : e.id < t.id ? -1 : +(e.id > t.id);
1483
- return structuredClone([...N].sort(e));
1515
+ return structuredClone([...A].sort(e));
1484
1516
  },
1485
1517
  async createRequiredCheck(e) {
1486
- let t = Ce(e);
1487
- if (N.some((e) => e.name === t.name)) throw new n(t.name);
1488
- let r = {
1489
- id: `rc_stub_${H++}`,
1490
- ...t
1518
+ let { everyBlueprint: t, ...r } = Ee(e);
1519
+ if (De(w, r.blueprintAccessors), A.some((e) => e.name === r.name)) throw new n(r.name);
1520
+ let i = {
1521
+ id: `rc_stub_${V++}`,
1522
+ ...r
1491
1523
  };
1492
- return N.push(r), structuredClone(r);
1524
+ return A.push(i), structuredClone(i);
1493
1525
  },
1494
1526
  async updateRequiredCheck({ id: e, ...t }) {
1495
- let r = Ce(t), i = N.find((t) => t.id === e);
1496
- if (!i) throw k("Required Check", e);
1497
- if (N.some((t) => t.name === r.name && t.id !== e)) throw new n(r.name);
1498
- return Object.assign(i, r), structuredClone(i);
1527
+ let { everyBlueprint: r, ...i } = Ee(t), a = A.find((t) => t.id === e);
1528
+ if (!a) throw D("Required Check", e);
1529
+ if (De(w, i.blueprintAccessors.filter((e) => !a.blueprintAccessors.includes(e))), A.some((t) => t.name === i.name && t.id !== e)) throw new n(i.name);
1530
+ return Object.assign(a, i), structuredClone(a);
1499
1531
  },
1500
1532
  async deleteRequiredCheck({ id: e }) {
1501
- if (!N.some((t) => t.id === e)) throw k("Required Check", e);
1502
- N = N.filter((t) => t.id !== e), I.delete(e);
1533
+ if (!A.some((t) => t.id === e)) throw D("Required Check", e);
1534
+ A = A.filter((t) => t.id !== e), P.delete(e);
1503
1535
  },
1504
1536
  async listRequiredCheckRecorders(e) {
1505
- return structuredClone(nt(e));
1537
+ return structuredClone(at(e));
1506
1538
  },
1507
1539
  async grantRequiredCheckRecorder({ requiredCheckId: e, recorder: t }) {
1508
- let n = nt(e);
1540
+ let n = at(e);
1509
1541
  if ("everyMember" in t) {
1510
- I.set(e, {
1542
+ P.set(e, {
1511
1543
  ...n,
1512
1544
  everyMember: !0
1513
1545
  });
1514
1546
  return;
1515
1547
  }
1516
- if (!je.includes(t.userId)) throw new _(`user ${t.userId} is not a member of the workspace`);
1517
- I.set(e, {
1548
+ if (!Fe.includes(t.userId)) throw new u(`user ${t.userId} is not a member of the workspace`);
1549
+ P.set(e, {
1518
1550
  ...n,
1519
1551
  userIds: [.../* @__PURE__ */ new Set([...n.userIds, t.userId])].sort()
1520
1552
  });
1521
1553
  },
1522
1554
  async revokeRequiredCheckRecorder({ requiredCheckId: e, recorder: t }) {
1523
- let n = nt(e);
1524
- I.set(e, "everyMember" in t ? {
1555
+ let n = at(e);
1556
+ P.set(e, "everyMember" in t ? {
1525
1557
  ...n,
1526
1558
  everyMember: !1
1527
1559
  } : {
@@ -1529,25 +1561,23 @@ function M(y = {}) {
1529
1561
  userIds: n.userIds.filter((e) => e !== t.userId)
1530
1562
  });
1531
1563
  },
1532
- async searchBlueprints({ query: e }) {
1533
- let t = e.trim().toLocaleLowerCase();
1564
+ async searchBlueprints({ query: e, includeWithoutRelease: t = !1 }) {
1565
+ let n = e.trim().toLocaleLowerCase();
1534
1566
  return {
1535
- blueprints: ge.filter((e) => !e.archived).filter((e) => e.name.toLocaleLowerCase().includes(t)).filter((e) => ve.some((t) => t.blueprintId === e.id)).map((e) => ({
1536
- id: e.id,
1537
- name: e.name
1538
- })),
1567
+ blueprints: w.filter((e) => !e.archived).filter((e) => e.name.toLocaleLowerCase().includes(n) || e.accessor.toLocaleLowerCase().includes(n)).filter((e) => t || be.some((t) => t.blueprintId === e.id)).sort((e, t) => e.accessor < t.accessor ? -1 : 1).map(Oe),
1539
1568
  nextPageToken: ""
1540
1569
  };
1541
1570
  },
1542
1571
  async getBlueprints(e) {
1543
- if (e.length > 1e3) throw new _(`at most ${c} Blueprint ids`);
1544
- return ge.filter((t) => e.includes(t.id)).map((e) => ({
1545
- id: e.id,
1546
- name: e.name
1547
- }));
1572
+ if (e.length > 1e3) throw new u(`at most ${r} Blueprint ids`);
1573
+ return w.filter((t) => e.includes(t.id)).map(Oe);
1574
+ },
1575
+ async getBlueprintsByAccessor(e) {
1576
+ if (e.length > 1e3) throw new u(`at most ${r} Blueprint accessors`);
1577
+ return w.filter((t) => e.includes(t.accessor)).map(Oe);
1548
1578
  },
1549
1579
  async listBlueprintReleases(e) {
1550
- return ve.filter((t) => t.blueprintId === e).map((e) => ({
1580
+ return be.filter((t) => t.blueprintId === e).map((e) => ({
1551
1581
  id: e.id,
1552
1582
  blueprintId: e.blueprintId,
1553
1583
  name: e.name ?? e.id,
@@ -1556,94 +1586,94 @@ function M(y = {}) {
1556
1586
  }));
1557
1587
  },
1558
1588
  async listCollections() {
1559
- return [...E].sort($e).map((e) => ({ ...e }));
1560
- },
1561
- async createCollection({ name: e, parentId: t = "", restricted: r = !1 }) {
1562
- let i = O(e, "a Collection's name", 200);
1563
- if (t !== "" && Y(t), r && P === "workspace") throw new m(Ee);
1564
- if (et(t, i)) throw new n(i);
1565
- let a = {
1566
- id: `col_stub_${H++}`,
1567
- name: i,
1568
- parentId: t,
1569
- restricted: r
1589
+ return [...S].sort(nt).map((e) => ({ ...e }));
1590
+ },
1591
+ async createCollection({ name: t, parentId: r = "", restricted: i = !1 }) {
1592
+ let a = E(t, "a Collection's name", 200);
1593
+ if (r !== "" && J(r), i && j === "workspace") throw new e(je);
1594
+ if (rt(r, a)) throw new n(a);
1595
+ let o = {
1596
+ id: `col_stub_${V++}`,
1597
+ name: a,
1598
+ parentId: r,
1599
+ restricted: i
1570
1600
  };
1571
- return E.push(a), r && F.set(a.id, [{
1572
- userId: x,
1601
+ return S.push(o), i && N.set(o.id, [{
1602
+ userId: y,
1573
1603
  level: "owner"
1574
- }]), { ...a };
1604
+ }]), { ...o };
1575
1605
  },
1576
1606
  async renameCollection({ id: e, name: t }) {
1577
- let r = O(t, "a Collection's name", 200), i = Y(e);
1578
- if (et(i.parentId, r, e)) throw new n(r);
1607
+ let r = E(t, "a Collection's name", 200), i = J(e);
1608
+ if (rt(i.parentId, r, e)) throw new n(r);
1579
1609
  return i.name = r, { ...i };
1580
1610
  },
1581
1611
  async moveCollection({ id: e, parentId: t }) {
1582
- let r = Y(e);
1583
- for (let n = t; n !== ""; n = Y(n).parentId) if (n === e) throw new _(`Collection ${e} can't move under itself or a Collection under it`);
1584
- if (et(t, r.name, e)) throw new n("");
1612
+ let r = J(e);
1613
+ for (let n = t; n !== ""; n = J(n).parentId) if (n === e) throw new u(`Collection ${e} can't move under itself or a Collection under it`);
1614
+ if (rt(t, r.name, e)) throw new n("");
1585
1615
  return r.parentId = t, { ...r };
1586
1616
  },
1587
1617
  async removeCollection({ id: e }) {
1588
- if (Y(e), E.some((t) => t.parentId === e)) throw new _(`Collection ${e} has Collections under it: remove or move those first`);
1589
- E.splice(E.findIndex((t) => t.id === e), 1), F.delete(e);
1618
+ if (J(e), S.some((t) => t.parentId === e)) throw new u(`Collection ${e} has Collections under it: remove or move those first`);
1619
+ S.splice(S.findIndex((t) => t.id === e), 1), N.delete(e);
1590
1620
  let t = [];
1591
- for (let n of D) n.collectionIds.includes(e) && (n.collectionIds = n.collectionIds.filter((t) => t !== e), t.push(n.id));
1621
+ for (let n of C) n.collectionIds.includes(e) && (n.collectionIds = n.collectionIds.filter((t) => t !== e), t.push(n.id));
1592
1622
  return t;
1593
1623
  },
1594
- async setCollectionRestricted({ id: e, restricted: t, acknowledgeDisclosure: n = !1 }) {
1595
- if (t && P === "workspace") throw new m(Ee);
1596
- let r = Y(e);
1597
- if (r.restricted === t) return { ...r };
1598
- if (!t && !n) throw new _(`unrestricting Collection ${e} discloses its Content to every viewer: confirm it with acknowledge_disclosure`);
1599
- return r.restricted = t, t ? F.set(e, [{
1600
- userId: x,
1624
+ async setCollectionRestricted({ id: t, restricted: n, acknowledgeDisclosure: r = !1 }) {
1625
+ if (n && j === "workspace") throw new e(je);
1626
+ let i = J(t);
1627
+ if (i.restricted === n) return { ...i };
1628
+ if (!n && !r) throw new u(`unrestricting Collection ${t} discloses its Content to every viewer: confirm it with acknowledge_disclosure`);
1629
+ return i.restricted = n, n ? N.set(t, [{
1630
+ userId: y,
1601
1631
  level: "owner"
1602
- }]) : F.delete(e), { ...r };
1632
+ }]) : N.delete(t), { ...i };
1603
1633
  },
1604
1634
  async listCollectionGrants(e) {
1605
- return tt(e), structuredClone(F.get(e) ?? []).sort((e, t) => e.userId < t.userId ? -1 : +(e.userId > t.userId));
1635
+ return it(e), structuredClone(N.get(e) ?? []).sort((e, t) => e.userId < t.userId ? -1 : +(e.userId > t.userId));
1606
1636
  },
1607
1637
  async grantCollectionAccess({ collectionId: e, userId: t, level: n }) {
1608
- if (tt(e), n !== "viewer" && n !== "editor") throw new _("a grant is viewer or editor");
1609
- if (!je.includes(t)) throw new _(`${t} is not a member of the workspace`);
1610
- let r = F.get(e) ?? [];
1611
- r.some((e) => e.level === "owner" && e.userId === t) || F.set(e, [...r.filter((e) => e.userId !== t), {
1638
+ if (it(e), n !== "viewer" && n !== "editor") throw new u("a grant is viewer or editor");
1639
+ if (!Fe.includes(t)) throw new u(`${t} is not a member of the workspace`);
1640
+ let r = N.get(e) ?? [];
1641
+ r.some((e) => e.level === "owner" && e.userId === t) || N.set(e, [...r.filter((e) => e.userId !== t), {
1612
1642
  userId: t,
1613
1643
  level: n
1614
1644
  }]);
1615
1645
  },
1616
1646
  async revokeCollectionAccess({ collectionId: e, userId: t }) {
1617
- tt(e), F.set(e, (F.get(e) ?? []).filter((e) => e.userId !== t || e.level === "owner"));
1647
+ it(e), N.set(e, (N.get(e) ?? []).filter((e) => e.userId !== t || e.level === "owner"));
1618
1648
  },
1619
1649
  async listContents(e = {}) {
1620
1650
  let t = e.view ?? { kind: "main" }, n = (e.search ?? "").trim();
1621
- if (n !== "" && t.kind === "in_force") throw new _("filter.search: Editor Search covers Main and open Branch heads, never Releases");
1622
- if ([...n].length > 200) throw new _("filter.search is at most 200 characters");
1623
- if (e.collectionId && !E.some((t) => t.id === e.collectionId)) throw k("Collection", e.collectionId);
1624
- t.kind === "change_set" && X(t.changeSetId);
1625
- let r = D.filter((e) => !e.archiveTime).filter((t) => !e.collectionId || t.collectionIds.includes(e.collectionId)).filter((t) => !e.blueprintIds?.length || e.blueprintIds.includes(t.blueprintId)).filter((t) => !e.assigneeId || (t.assigneeIds ?? []).includes(e.assigneeId)).sort((e, t) => e.id < t.id ? -1 : +(e.id > t.id)).flatMap((e) => xt(e, t, n)), i = Math.min(e.pageSize || 50, 200), a = e.pageToken ? Number(e.pageToken) : 0;
1651
+ if (n !== "" && t.kind === "in_force") throw new u("filter.search: Editor Search covers Main and open Branch heads, never Releases");
1652
+ if ([...n].length > 200) throw new u("filter.search is at most 200 characters");
1653
+ if (e.collectionId && !S.some((t) => t.id === e.collectionId)) throw D("Collection", e.collectionId);
1654
+ t.kind === "change_set" && Y(t.changeSetId);
1655
+ let r = C.filter((e) => !e.archiveTime).filter((t) => !e.collectionId || t.collectionIds.includes(e.collectionId)).filter((t) => !e.blueprintIds?.length || e.blueprintIds.includes(t.blueprintId)).filter((t) => !e.assigneeId || (t.assigneeIds ?? []).includes(e.assigneeId)).sort((e, t) => e.id < t.id ? -1 : +(e.id > t.id)).flatMap((e) => $(e, t, n)), i = Math.min(e.pageSize || 50, 200), a = e.pageToken ? Number(e.pageToken) : 0;
1626
1656
  return {
1627
1657
  contents: r.slice(a, a + i),
1628
1658
  nextPageToken: a + i < r.length ? String(a + i) : ""
1629
1659
  };
1630
1660
  },
1631
1661
  async createContent({ changeSetId: e, blueprintReleaseId: t, copyFrom: n }) {
1632
- let r = Z(e), i = {}, a = t;
1662
+ let r = X(e), i = {}, a = t;
1633
1663
  if (n) {
1634
- let e = "revisionId" in n ? n.revisionId : D.find((e) => e.inForce?.releaseId === n.releaseId)?.inForce?.revisionId, r = D.find((t) => e && q(t, e));
1635
- if (!r || !e) throw k("copy source", JSON.stringify(n));
1636
- i = structuredClone(q(r, e) ?? {}), a = t || r.blueprintReleaseId;
1664
+ let e = "revisionId" in n ? n.revisionId : C.find((e) => e.inForce?.releaseId === n.releaseId)?.inForce?.revisionId, r = C.find((t) => e && K(t, e));
1665
+ if (!r || !e) throw D("copy source", JSON.stringify(n));
1666
+ i = structuredClone(K(r, e) ?? {}), a = t || r.blueprintReleaseId;
1637
1667
  }
1638
- let o = ve.find((e) => e.id === a);
1639
- if (!o) throw new oe(`Blueprint Release ${a} can't be loaded`, [{
1668
+ let o = be.find((e) => e.id === a);
1669
+ if (!o) throw new f(`Blueprint Release ${a} can't be loaded`, [{
1640
1670
  source: "contenthub",
1641
1671
  code: "release_not_found",
1642
1672
  path: ""
1643
1673
  }]);
1644
- if (o.refusals?.length) throw new oe(`Blueprint Release ${a} can't be loaded`, o.refusals.map((e) => ({ ...e })));
1645
- let s = H++, c = `content_stub_${s}`, l = `br_stub_${s}`, u = `rev_stub_${s}`;
1646
- return D.push({
1674
+ if (o.refusals?.length) throw new f(`Blueprint Release ${a} can't be loaded`, o.refusals.map((e) => ({ ...e })));
1675
+ let s = V++, c = `content_stub_${s}`, l = `br_stub_${s}`, u = `rev_stub_${s}`;
1676
+ return C.push({
1647
1677
  id: c,
1648
1678
  blueprintId: o.blueprintId,
1649
1679
  blueprintReleaseId: a,
@@ -1652,7 +1682,7 @@ function M(y = {}) {
1652
1682
  branchId: l,
1653
1683
  revisionId: u,
1654
1684
  data: i,
1655
- revisionCreateTime: b()
1685
+ revisionCreateTime: v()
1656
1686
  } }
1657
1687
  }), r.chains.push({
1658
1688
  id: `chain_stub_${s}`,
@@ -1672,35 +1702,35 @@ function M(y = {}) {
1672
1702
  data: structuredClone(i),
1673
1703
  changeSetId: e,
1674
1704
  branchId: l,
1675
- revisionCreateTime: b(),
1705
+ revisionCreateTime: v(),
1676
1706
  releaseId: ""
1677
1707
  };
1678
1708
  },
1679
1709
  async saveRevision({ idempotencyKey: e, ...t }) {
1680
- if (!e) return rt(t);
1681
- let n = JSON.stringify(t), r = qe.get(e);
1710
+ if (!e) return ot(t);
1711
+ let n = JSON.stringify(t), r = Xe.get(e);
1682
1712
  if (r) {
1683
- if (r.asked !== n) throw new _(`idempotency key ${e} names another save`);
1713
+ if (r.asked !== n) throw new u(`idempotency key ${e} names another save`);
1684
1714
  return structuredClone(r.content);
1685
1715
  }
1686
- let i = await rt(t);
1687
- return qe.set(e, {
1716
+ let i = await ot(t);
1717
+ return Xe.set(e, {
1688
1718
  asked: n,
1689
1719
  content: structuredClone(i)
1690
1720
  }), i;
1691
1721
  },
1692
1722
  async getContent({ id: e, changeSetId: t, branchId: n }) {
1693
- let r = U(e), i = t ? {
1723
+ let r = H(e), i = t ? {
1694
1724
  kind: "change_set",
1695
1725
  changeSetId: t
1696
1726
  } : { kind: "main" };
1697
- if (n && !t) throw new _("branch_id names a Branch of a Change Set: give its change_set_id too");
1698
- let [a] = xt(r, i, "");
1699
- if (!a) throw k("Content", e);
1727
+ if (n && !t) throw new u("branch_id names a Branch of a Change Set: give its change_set_id too");
1728
+ let [a] = $(r, i, "");
1729
+ if (!a) throw D("Content", e);
1700
1730
  if (n && n !== a.branchId) {
1701
- let i = T.find((e) => e.id === t)?.chains.find((t) => t.contentId === e)?.branches.find((e) => e.id === n);
1702
- if (!i) throw k("Branch", n);
1703
- let o = K(r).find((e) => e.id === i.headRevisionId), s = o?.data ?? (r.main?.revisionId === i.headRevisionId ? r.main.data : {});
1731
+ let i = x.find((e) => e.id === t)?.chains.find((t) => t.contentId === e)?.branches.find((e) => e.id === n);
1732
+ if (!i) throw D("Branch", n);
1733
+ let o = G(r).find((e) => e.id === i.headRevisionId), s = o?.data ?? (r.main?.revisionId === i.headRevisionId ? r.main.data : {});
1704
1734
  a = {
1705
1735
  ...a,
1706
1736
  revisionId: i.headRevisionId,
@@ -1709,15 +1739,15 @@ function M(y = {}) {
1709
1739
  revisionCreateTime: o?.createTime ?? a.revisionCreateTime
1710
1740
  };
1711
1741
  }
1712
- let o = M[r.blueprintReleaseId];
1742
+ let o = T[r.blueprintReleaseId];
1713
1743
  return {
1714
1744
  content: a,
1715
1745
  blueprintRelease: o ? structuredClone(o) : void 0,
1716
- attributes: W(r)
1746
+ attributes: U(r)
1717
1747
  };
1718
1748
  },
1719
1749
  async getTimeline(e) {
1720
- let t = U(e), n = (e) => T.find((t) => t.id === e)?.state === "open";
1750
+ let t = H(e), n = (e) => x.find((t) => t.id === e)?.state === "open";
1721
1751
  return structuredClone({
1722
1752
  entries: t.timeline ?? [],
1723
1753
  plannedReleases: (t.plannedReleases ?? []).filter((e) => n(e.changeSetId))
@@ -1726,13 +1756,13 @@ function M(y = {}) {
1726
1756
  async listRevisions({ target: e, pageSize: t, pageToken: n }) {
1727
1757
  let r;
1728
1758
  if ("contentId" in e) {
1729
- let t = U(e.contentId);
1730
- if (!t.main) throw k("Content", e.contentId);
1731
- r = K(t);
1759
+ let t = H(e.contentId);
1760
+ if (!t.main) throw D("Content", e.contentId);
1761
+ r = G(t);
1732
1762
  } else {
1733
- let t = D.find((t) => K(t).some((t) => t.branchId === e.branchId));
1734
- if (!t) throw k("Branch", e.branchId);
1735
- r = K(t).filter((t) => t.branchId === e.branchId);
1763
+ let t = C.find((t) => G(t).some((t) => t.branchId === e.branchId));
1764
+ if (!t) throw D("Branch", e.branchId);
1765
+ r = G(t).filter((t) => t.branchId === e.branchId);
1736
1766
  }
1737
1767
  let i = Math.min(t || 50, 200), a = n ? Number(n) : 0;
1738
1768
  return {
@@ -1741,17 +1771,17 @@ function M(y = {}) {
1741
1771
  };
1742
1772
  },
1743
1773
  async compare({ revisionId: e, base: t }) {
1744
- let n = D.find((t) => K(t).some((t) => t.id === e));
1745
- if (!n) throw k("Revision", e);
1746
- let r = K(n), i = r.find((t) => t.id === e), a;
1774
+ let n = C.find((t) => G(t).some((t) => t.id === e));
1775
+ if (!n) throw D("Revision", e);
1776
+ let r = G(n), i = r.find((t) => t.id === e), a;
1747
1777
  if (t.kind === "revision") a = t.revisionId;
1748
1778
  else if (t.kind === "main_head") {
1749
- if (!n.main) throw new _("the Content is not published: it has no Main Branch");
1779
+ if (!n.main) throw new u("the Content is not published: it has no Main Branch");
1750
1780
  a = n.main.revisionId;
1751
1781
  } else a = r.find((e) => e.branchId === t.branchId)?.parentId ?? "";
1752
1782
  let o = r.find((e) => e.id === a);
1753
- if (!o) throw k("Revision", a);
1754
- let s = q(n, i.id) ?? {}, c = q(n, o.id) ?? {}, l = [];
1783
+ if (!o) throw D("Revision", a);
1784
+ let s = K(n, i.id) ?? {}, c = K(n, o.id) ?? {}, l = [];
1755
1785
  for (let e of [.../* @__PURE__ */ new Set([...Object.keys(s), ...Object.keys(c)])]) e in c ? e in s ? JSON.stringify(s[e]) !== JSON.stringify(c[e]) && l.push({
1756
1786
  path: `/${e}`,
1757
1787
  kind: "changed",
@@ -1766,32 +1796,32 @@ function M(y = {}) {
1766
1796
  kind: "added",
1767
1797
  after: s[e]
1768
1798
  });
1769
- let u = ({ data: e, ...t }) => t;
1799
+ let d = ({ data: e, ...t }) => t;
1770
1800
  return {
1771
- base: u(o),
1772
- revision: u(i),
1801
+ base: d(o),
1802
+ revision: d(i),
1773
1803
  changes: l
1774
1804
  };
1775
1805
  },
1776
1806
  async listReferences({ contentId: e, revisionId: t }) {
1777
- return (U(e).edges ?? []).filter((e) => e.sourceRevisionId === t).map((e) => ({ ...e }));
1807
+ return (H(e).edges ?? []).filter((e) => e.sourceRevisionId === t).map((e) => ({ ...e }));
1778
1808
  },
1779
1809
  async listReferrers({ contentId: e, includeOpenChangeSets: t, pageSize: n, pageToken: r }) {
1780
- U(e);
1810
+ H(e);
1781
1811
  let i = (e) => {
1782
1812
  let t = Math.min(n || 100, 1e3), i = r ? Number(r) : 0;
1783
1813
  return {
1784
1814
  referrers: e.slice(i, i + t),
1785
1815
  nextPageToken: i + t < e.length ? String(i + t) : ""
1786
1816
  };
1787
- }, a = D.flatMap((t) => (t.edges ?? []).filter((n) => n.targetContentId === e && t.inForce?.revisionId === n.sourceRevisionId).map((e) => ({
1817
+ }, a = C.flatMap((t) => (t.edges ?? []).filter((n) => n.targetContentId === e && t.inForce?.revisionId === n.sourceRevisionId).map((e) => ({
1788
1818
  edge: { ...e },
1789
1819
  releaseId: t.inForce?.releaseId ?? "",
1790
1820
  changeSetId: "",
1791
1821
  branchId: ""
1792
1822
  })));
1793
1823
  if (!t) return i(a);
1794
- let o = D.flatMap((t) => Object.entries(t.branches).flatMap(([n, r]) => T.find((e) => e.id === n)?.state === "open" ? (t.edges ?? []).filter((t) => t.targetContentId === e && t.sourceRevisionId === r.revisionId).map((e) => ({
1824
+ let o = C.flatMap((t) => Object.entries(t.branches).flatMap(([n, r]) => x.find((e) => e.id === n)?.state === "open" ? (t.edges ?? []).filter((t) => t.targetContentId === e && t.sourceRevisionId === r.revisionId).map((e) => ({
1795
1825
  edge: { ...e },
1796
1826
  releaseId: "",
1797
1827
  changeSetId: n,
@@ -1803,14 +1833,14 @@ function M(y = {}) {
1803
1833
  let t;
1804
1834
  if ("revisionId" in e) t = e.revisionId;
1805
1835
  else {
1806
- for (let n of D) {
1836
+ for (let n of C) {
1807
1837
  let r = Object.values(n.branches).find((t) => t.branchId === e.branchId);
1808
1838
  r && (t = r.revisionId);
1809
1839
  }
1810
- if (!t) throw k("Branch", e.branchId);
1840
+ if (!t) throw D("Branch", e.branchId);
1811
1841
  }
1812
- return D.flatMap((e) => (e.edges ?? []).filter((e) => e.sourceRevisionId === t)).filter((e) => e.pinReleaseId !== "").flatMap((e) => {
1813
- let t = D.find((t) => t.id === e.targetContentId)?.inForce?.releaseId ?? "";
1842
+ return C.flatMap((e) => (e.edges ?? []).filter((e) => e.sourceRevisionId === t)).filter((e) => e.pinReleaseId !== "").flatMap((e) => {
1843
+ let t = C.find((t) => t.id === e.targetContentId)?.inForce?.releaseId ?? "";
1814
1844
  return t === e.pinReleaseId ? [] : [{
1815
1845
  edge: { ...e },
1816
1846
  supersededByReleaseId: t,
@@ -1819,104 +1849,104 @@ function M(y = {}) {
1819
1849
  });
1820
1850
  },
1821
1851
  async setContentCollections({ contentId: e, collectionIds: t }) {
1822
- let n = U(e), r = [...new Set(t)];
1823
- if (r.length > 100) throw new _("at most 100 Collections");
1824
- for (let e of r) if (!E.some((t) => t.id === e)) throw k("Collection", e);
1852
+ let n = H(e), r = [...new Set(t)];
1853
+ if (r.length > 100) throw new u("at most 100 Collections");
1854
+ for (let e of r) if (!S.some((t) => t.id === e)) throw D("Collection", e);
1825
1855
  return n.collectionIds = r.sort(), [...n.collectionIds];
1826
1856
  },
1827
1857
  async setContentAssignees({ contentId: e, assigneeIds: t }) {
1828
- let n = U(e);
1829
- if (new Set(t).size !== t.length) throw new _("each assignee is given once");
1830
- if (t.length > 50) throw new _("at most 50 assignees");
1831
- return n.assigneeIds = [...t], W(n);
1858
+ let n = H(e);
1859
+ if (new Set(t).size !== t.length) throw new u("each assignee is given once");
1860
+ if (t.length > 50) throw new u("at most 50 assignees");
1861
+ return n.assigneeIds = [...t], U(n);
1832
1862
  },
1833
1863
  async blockContent({ contentId: e, blockReasonId: t, allowedUserIds: n }) {
1834
- let r = U(e);
1835
- if (!w.some((e) => e.id === t)) throw k("Block Reason", t);
1836
- if (new Set(n).size !== n.length) throw new _("each allowed user is given once");
1864
+ let r = H(e);
1865
+ if (!b.some((e) => e.id === t)) throw D("Block Reason", t);
1866
+ if (new Set(n).size !== n.length) throw new u("each allowed user is given once");
1837
1867
  return r.block = {
1838
1868
  blockReasonId: t,
1839
1869
  allowedUserIds: [...n],
1840
- blockedBy: x,
1841
- blockTime: b()
1842
- }, W(r);
1870
+ blockedBy: y,
1871
+ blockTime: v()
1872
+ }, U(r);
1843
1873
  },
1844
1874
  async unblockContent(e) {
1845
- let t = U(e);
1846
- if (!t.block && t.editingBlock) throw new _(`Content ${e} is being edited by ${t.editingBlock.editorId} in a Direct Edit: its Editing Block can't be lifted`);
1847
- return t.block = void 0, W(t);
1875
+ let t = H(e);
1876
+ if (!t.block && t.editingBlock) throw new u(`Content ${e} is being edited by ${t.editingBlock.editorId} in a Direct Edit: its Editing Block can't be lifted`);
1877
+ return t.block = void 0, U(t);
1848
1878
  },
1849
1879
  async archiveContent(e) {
1850
- let t = U(e);
1851
- if (t.archiveTime) return W(t);
1852
- if (!t.main) throw new _(`Content ${e} is not published: discard its Change Set instead of archiving it`);
1853
- if (ee(t.timeline ?? [], Je())) throw new _(`Content ${e} has a Release In Force today or later: end its force first`);
1854
- return t.archiveTime = b(), W(t);
1880
+ let t = H(e);
1881
+ if (t.archiveTime) return U(t);
1882
+ if (!t.main) throw new u(`Content ${e} is not published: discard its Change Set instead of archiving it`);
1883
+ if (h(t.timeline ?? [], Ze())) throw new u(`Content ${e} has a Release In Force today or later: end its force first`);
1884
+ return t.archiveTime = v(), U(t);
1855
1885
  },
1856
1886
  async unarchiveContent(e) {
1857
- let t = U(e);
1858
- return t.archiveTime = void 0, W(t);
1887
+ let t = H(e);
1888
+ return t.archiveTime = void 0, U(t);
1859
1889
  },
1860
- async openDirectEdit({ contentId: e, effectiveOn: t, idempotencyKey: n }) {
1861
- return V(n, [
1890
+ async openDirectEdit({ contentId: e, effectiveOn: n, idempotencyKey: r }) {
1891
+ return B(r, [
1862
1892
  "openDirectEdit",
1863
1893
  e,
1864
- t
1894
+ n
1865
1895
  ], async () => {
1866
- let n = U(e), r = T.find((t) => t.kind === "direct_edit" && t.state === "open" && t.editorId === x && t.chains[0]?.contentId === e);
1867
- if (r) {
1868
- let [e] = xt(n, {
1896
+ let r = H(e), i = x.find((t) => t.kind === "direct_edit" && t.state === "open" && t.editorId === y && t.chains[0]?.contentId === e);
1897
+ if (i) {
1898
+ let [e] = $(r, {
1869
1899
  kind: "change_set",
1870
- changeSetId: r.id
1900
+ changeSetId: i.id
1871
1901
  }, "");
1872
1902
  return {
1873
- changeSet: A(r),
1903
+ changeSet: O(i),
1874
1904
  content: e,
1875
1905
  reopened: !0
1876
1906
  };
1877
1907
  }
1878
- let i = G(n);
1879
- if (!i && t) throw new _("effective_on is refused for undated Content");
1880
- let a = Fe(n), o = z(R.find((e) => e.blueprintAccessor === a)), c = o.editingMode;
1881
- if (n.main && c === "change_sets") throw new s(e, a, c);
1882
- if (n.editingBlock && n.editingBlock.editorId !== x) throw new v("editing_blocked", `Content ${e} is being edited by ${n.editingBlock.editorId} in a Direct Edit`, e, n.editingBlock.editorId);
1883
- let l = i ? t || Je() : void 0, u = await $.startEditing({
1908
+ let a = W(r);
1909
+ if (!a && n) throw new u("effective_on is refused for undated Content");
1910
+ let o = Re(r), s = R(L.find((e) => e.blueprintAccessor === o)), c = s.editingMode;
1911
+ if (r.main && c === "change_sets") throw new t(e, o, c);
1912
+ if (r.editingBlock && r.editingBlock.editorId !== y) throw new l("editing_blocked", `Content ${e} is being edited by ${r.editingBlock.editorId} in a Direct Edit`, e, r.editingBlock.editorId);
1913
+ let d = a ? n || Ze() : void 0, f = await Q.startEditing({
1884
1914
  contentId: e,
1885
1915
  changeSetName: `Direct Edit of ${e}`,
1886
- effectiveOn: l
1887
- }), d = X(u.changeSet.id);
1888
- d.kind = "direct_edit", d.editorId = x;
1889
- let f = d.chains[0];
1890
- if (l && f?.branches[0]) {
1891
- let e = n.timeline ?? [], t = (e) => !!e.validityPeriod && e.validityPeriod.firstDay <= l && (e.validityPeriod.lastDay === "" || l <= e.validityPeriod.lastDay), r = [...e].reverse().find(t);
1892
- f.branches[0].effectiveOn = l, f.branches[0].carriedReleaseId = r?.releaseId ?? "";
1893
- for (let t of e) !t.validityPeriod || t.validityPeriod.firstDay <= l || f.branches.push({
1894
- id: `br_stub_${H++}`,
1895
- position: f.branches.length,
1916
+ effectiveOn: d
1917
+ }), p = Y(f.changeSet.id);
1918
+ p.kind = "direct_edit", p.editorId = y;
1919
+ let m = p.chains[0];
1920
+ if (d && m?.branches[0]) {
1921
+ let e = r.timeline ?? [], t = (e) => !!e.validityPeriod && e.validityPeriod.firstDay <= d && (e.validityPeriod.lastDay === "" || d <= e.validityPeriod.lastDay), n = [...e].reverse().find(t);
1922
+ m.branches[0].effectiveOn = d, m.branches[0].carriedReleaseId = n?.releaseId ?? "";
1923
+ for (let t of e) !t.validityPeriod || t.validityPeriod.firstDay <= d || m.branches.push({
1924
+ id: `br_stub_${V++}`,
1925
+ position: m.branches.length,
1896
1926
  kind: "carry_forward",
1897
1927
  headRevisionId: t.revisionId,
1898
1928
  effectiveOn: t.validityPeriod.firstDay,
1899
1929
  carriedReleaseId: t.releaseId
1900
1930
  });
1901
1931
  }
1902
- return o.editingBlock && (n.editingBlock = {
1903
- editorId: x,
1904
- changeSetId: d.id,
1905
- blockTime: b()
1932
+ return s.editingBlock && (r.editingBlock = {
1933
+ editorId: y,
1934
+ changeSetId: p.id,
1935
+ blockTime: v()
1906
1936
  }), {
1907
- changeSet: A(d),
1908
- content: u.content,
1937
+ changeSet: O(p),
1938
+ content: f.content,
1909
1939
  reopened: !1
1910
1940
  };
1911
1941
  });
1912
1942
  },
1913
1943
  async previewDirectEditPublish({ id: e, validityLastDay: t }) {
1914
- let n = X(e);
1915
- if (n.kind !== "direct_edit") throw new v("not_a_direct_edit", `Change Set ${e} is not a Direct Edit`);
1916
- return structuredClone(vt(n, t));
1944
+ let n = Y(e);
1945
+ if (n.kind !== "direct_edit") throw new l("not_a_direct_edit", `Change Set ${e} is not a Direct Edit`);
1946
+ return structuredClone(xt(n, t));
1917
1947
  },
1918
1948
  async publishDirectEdit({ id: e, expectedHeadId: t, releaseSpec: n, validityLastDay: r, carryForward: i, idempotencyKey: a }) {
1919
- return V(a, [
1949
+ return B(a, [
1920
1950
  "publishDirectEdit",
1921
1951
  e,
1922
1952
  t,
@@ -1924,24 +1954,24 @@ function M(y = {}) {
1924
1954
  r,
1925
1955
  i
1926
1956
  ], async () => {
1927
- let a = X(e);
1928
- if (a.kind !== "direct_edit") throw new v("not_a_direct_edit", `Change Set ${e} is not a Direct Edit`);
1929
- let o = U(a.chains[0]?.contentId ?? ""), s = {
1957
+ let a = Y(e);
1958
+ if (a.kind !== "direct_edit") throw new l("not_a_direct_edit", `Change Set ${e} is not a Direct Edit`);
1959
+ let o = H(a.chains[0]?.contentId ?? ""), s = {
1930
1960
  cs: structuredClone(a),
1931
1961
  c: structuredClone(o)
1932
1962
  };
1933
1963
  try {
1934
- return await yt(a, t, n, {
1964
+ return await St(a, t, n, {
1935
1965
  validityLastDay: r,
1936
1966
  carryForward: i
1937
1967
  });
1938
1968
  } catch (e) {
1939
- throw _t(a, s.cs), _t(o, s.c), e;
1969
+ throw bt(a, s.cs), bt(o, s.c), e;
1940
1970
  }
1941
1971
  });
1942
1972
  },
1943
1973
  async saveAndPublishDirectEdit({ id: e, expectedHeadId: t, data: n, fieldMask: r, releaseSpec: i, validityLastDay: a, carryForward: o, idempotencyKey: s }) {
1944
- return V(s, [
1974
+ return B(s, [
1945
1975
  "saveAndPublishDirectEdit",
1946
1976
  e,
1947
1977
  t,
@@ -1951,16 +1981,16 @@ function M(y = {}) {
1951
1981
  a,
1952
1982
  o
1953
1983
  ], async () => {
1954
- let s = X(e);
1955
- if (s.kind !== "direct_edit") throw new v("not_a_direct_edit", `Change Set ${e} is not a Direct Edit`);
1984
+ let s = Y(e);
1985
+ if (s.kind !== "direct_edit") throw new l("not_a_direct_edit", `Change Set ${e} is not a Direct Edit`);
1956
1986
  let c = s.chains[0]?.branches[0];
1957
1987
  if (!c) throw Error(`Direct Edit ${e} has no Branch`);
1958
- let l = U(s.chains[0]?.contentId ?? ""), u = {
1988
+ let u = H(s.chains[0]?.contentId ?? ""), d = {
1959
1989
  cs: structuredClone(s),
1960
- c: structuredClone(l)
1990
+ c: structuredClone(u)
1961
1991
  };
1962
1992
  try {
1963
- let l = await rt({
1993
+ let l = await ot({
1964
1994
  changeSetId: e,
1965
1995
  branchId: c.id,
1966
1996
  expectedHeadId: t,
@@ -1969,76 +1999,76 @@ function M(y = {}) {
1969
1999
  });
1970
2000
  return {
1971
2001
  content: l,
1972
- outcome: await yt(s, l.revisionId, i, {
2002
+ outcome: await St(s, l.revisionId, i, {
1973
2003
  validityLastDay: a,
1974
2004
  carryForward: o
1975
2005
  })
1976
2006
  };
1977
2007
  } catch (e) {
1978
- throw _t(s, u.cs), _t(l, u.c), e;
2008
+ throw bt(s, d.cs), bt(u, d.c), e;
1979
2009
  }
1980
2010
  });
1981
2011
  },
1982
2012
  async discardDirectEdit({ id: e, idempotencyKey: t }) {
1983
- return V(t, ["discardDirectEdit", e], async () => {
1984
- if (X(e).kind !== "direct_edit") throw new v("not_a_direct_edit", `Change Set ${e} is not a Direct Edit`);
1985
- let t = await $.discardChangeSet(e);
1986
- for (let t of D) t.editingBlock?.changeSetId === e && (t.editingBlock = void 0);
2013
+ return B(t, ["discardDirectEdit", e], async () => {
2014
+ if (Y(e).kind !== "direct_edit") throw new l("not_a_direct_edit", `Change Set ${e} is not a Direct Edit`);
2015
+ let t = await Q.discardChangeSet(e);
2016
+ for (let t of C) t.editingBlock?.changeSetId === e && (t.editingBlock = void 0);
1987
2017
  return t;
1988
2018
  });
1989
2019
  },
1990
2020
  async forceDirectEdit({ id: e, idempotencyKey: t }) {
1991
- return V(t, ["forceDirectEdit", e], async () => {
1992
- let t = X(e);
1993
- if (t.kind !== "direct_edit") throw new v("not_a_direct_edit", `Change Set ${e} is not a Direct Edit`);
1994
- let n = t.chains[0]?.contentId ?? "", r = U(n);
1995
- if (t.state !== "open" || r.editingBlock?.changeSetId !== e) throw new v("no_editing_block", `Change Set ${e} holds no Editing Block`);
1996
- let i = z(R.find((e) => e.blueprintAccessor === Fe(r))).forceGroup;
1997
- if (!Ie(i)) throw new ne(`forcing the Editing Block of Content ${n} needs the Force Group`);
1998
- let a = T.find((e) => e.kind === "direct_edit" && e.state === "open" && e.editorId === x && e.chains[0]?.contentId === n);
1999
- if (a) throw new v("own_direct_edit", `you have a Direct Edit of Content ${n}, ${a.id}`, n);
2021
+ return B(t, ["forceDirectEdit", e], async () => {
2022
+ let t = Y(e);
2023
+ if (t.kind !== "direct_edit") throw new l("not_a_direct_edit", `Change Set ${e} is not a Direct Edit`);
2024
+ let n = t.chains[0]?.contentId ?? "", r = H(n);
2025
+ if (t.state !== "open" || r.editingBlock?.changeSetId !== e) throw new l("no_editing_block", `Change Set ${e} holds no Editing Block`);
2026
+ let i = R(L.find((e) => e.blueprintAccessor === Re(r))).forceGroup;
2027
+ if (!ze(i)) throw new ne(`forcing the Editing Block of Content ${n} needs the Force Group`);
2028
+ let a = x.find((e) => e.kind === "direct_edit" && e.state === "open" && e.editorId === y && e.chains[0]?.contentId === n);
2029
+ if (a) throw new l("own_direct_edit", `you have a Direct Edit of Content ${n}, ${a.id}`, n);
2000
2030
  let o = t.editorId ?? "";
2001
- t.editorId = x, r.editingBlock = {
2002
- editorId: x,
2031
+ t.editorId = y, r.editingBlock = {
2032
+ editorId: y,
2003
2033
  changeSetId: e,
2004
- blockTime: b()
2034
+ blockTime: v()
2005
2035
  };
2006
- let [s] = xt(r, {
2036
+ let [s] = $(r, {
2007
2037
  kind: "change_set",
2008
2038
  changeSetId: e
2009
2039
  }, "");
2010
2040
  return {
2011
- changeSet: A(t),
2041
+ changeSet: O(t),
2012
2042
  content: s,
2013
2043
  previousEditorId: o
2014
2044
  };
2015
2045
  });
2016
2046
  },
2017
2047
  async startEditing({ contentId: e, changeSetId: t, effectiveOn: n = "", changeSetName: r = "" }) {
2018
- let i = U(e);
2019
- if (!i.main) throw new _(`Content ${e} is not published`);
2020
- if (J(i), G(i) && !g.test(n)) throw new _("effective_on is required for Dated Content, as YYYY-MM-DD");
2021
- if (!G(i) && n !== "") throw new _("effective_on is refused for undated Content");
2048
+ let i = H(e);
2049
+ if (!i.main) throw new u(`Content ${e} is not published`);
2050
+ if (q(i), W(i) && !_.test(n)) throw new u("effective_on is required for Dated Content, as YYYY-MM-DD");
2051
+ if (!W(i) && n !== "") throw new u("effective_on is refused for undated Content");
2022
2052
  let a;
2023
2053
  if (t) {
2024
- if (a = Z(t), a.kind === "direct_edit") throw new v("one_branch", `Change Set ${t} is a Direct Edit`);
2025
- if (a.chains.some((t) => t.contentId === e)) throw new _(`Content ${e} already has a Chain in this Change Set`);
2054
+ if (a = X(t), a.kind === "direct_edit") throw new l("one_branch", `Change Set ${t} is a Direct Edit`);
2055
+ if (a.chains.some((t) => t.contentId === e)) throw new u(`Content ${e} already has a Chain in this Change Set`);
2026
2056
  } else {
2027
2057
  let t = Object.values(i.main.data).filter((e) => typeof e == "string").slice(0, 2).join(" ");
2028
2058
  a = {
2029
- id: `cs_stub_${H++}`,
2030
- name: r.trim() ? O(r, "change_set_name", 200) : t || e,
2059
+ id: `cs_stub_${V++}`,
2060
+ name: r.trim() ? E(r, "change_set_name", 200) : t || e,
2031
2061
  state: "open",
2032
- createdBy: x,
2033
- createTime: b(),
2062
+ createdBy: y,
2063
+ createTime: v(),
2034
2064
  chains: [],
2035
2065
  dependsOnChangeSetIds: [],
2036
2066
  status: "",
2037
2067
  assigneeIds: [],
2038
2068
  plannedReleases: []
2039
- }, T.unshift(a);
2069
+ }, x.unshift(a);
2040
2070
  }
2041
- let o = H++, s = `br_stub_${o}`, c = {
2071
+ let o = V++, s = `br_stub_${o}`, c = {
2042
2072
  ...structuredClone(i.main),
2043
2073
  branchId: s
2044
2074
  };
@@ -2053,21 +2083,21 @@ function M(y = {}) {
2053
2083
  headRevisionId: c.revisionId
2054
2084
  }]
2055
2085
  });
2056
- let [l] = xt(i, {
2086
+ let [d] = $(i, {
2057
2087
  kind: "change_set",
2058
2088
  changeSetId: a.id
2059
2089
  }, "");
2060
2090
  return {
2061
- changeSet: A(a),
2062
- content: l
2091
+ changeSet: O(a),
2092
+ content: d
2063
2093
  };
2064
2094
  },
2065
2095
  async previewChain({ changeSetId: e, contentId: t, effectiveOn: n, validityPeriod: r }) {
2066
- Z(e);
2067
- let i = U(t);
2068
- if (!i.main) throw new _(`Content ${t} is not published`);
2069
- if (!G(i)) throw new _("undated Content's Chain takes no date");
2070
- if (!g.test(n)) throw new _("effective_on is YYYY-MM-DD");
2096
+ X(e);
2097
+ let i = H(t);
2098
+ if (!i.main) throw new u(`Content ${t} is not published`);
2099
+ if (!W(i)) throw new u("undated Content's Chain takes no date");
2100
+ if (!_.test(n)) throw new u("effective_on is YYYY-MM-DD");
2071
2101
  let a = i.timeline ?? [], o = a.find((e) => e.validityPeriod && e.validityPeriod.firstDay <= n && (e.validityPeriod.lastDay === "" || n <= e.validityPeriod.lastDay));
2072
2102
  return {
2073
2103
  forkReleaseId: o?.releaseId ?? "",
@@ -2078,31 +2108,31 @@ function M(y = {}) {
2078
2108
  };
2079
2109
  },
2080
2110
  async planRepeal({ changeSetId: e, contentId: t, lastDay: n }) {
2081
- Z(e);
2082
- let r = U(t);
2083
- if (J(r), !G(r)) throw new _("a Repeal is for Dated Content");
2084
- if (!g.test(n)) throw new _("last_day is YYYY-MM-DD");
2085
- return bt(r, e, {
2111
+ X(e);
2112
+ let r = H(t);
2113
+ if (q(r), !W(r)) throw new u("a Repeal is for Dated Content");
2114
+ if (!_.test(n)) throw new u("last_day is YYYY-MM-DD");
2115
+ return Ct(r, e, {
2086
2116
  kind: "repeal",
2087
2117
  validityPeriod: {
2088
- firstDay: te(r.timeline ?? [], n)?.validityPeriod?.firstDay ?? n,
2118
+ firstDay: ee(r.timeline ?? [], n)?.validityPeriod?.firstDay ?? n,
2089
2119
  lastDay: n
2090
2120
  }
2091
2121
  });
2092
2122
  },
2093
2123
  async planWithdrawal({ changeSetId: e, contentId: t }) {
2094
- Z(e);
2095
- let n = U(t);
2096
- if (J(n), G(n)) throw new _("a Withdrawal is for undated Content");
2097
- return bt(n, e, { kind: "withdrawal" });
2124
+ X(e);
2125
+ let n = H(t);
2126
+ if (q(n), W(n)) throw new u("a Withdrawal is for undated Content");
2127
+ return Ct(n, e, { kind: "withdrawal" });
2098
2128
  },
2099
2129
  async planRelease({ idempotencyKey: e, ...t }) {
2100
- return V(e, ["planRelease", t], async () => {
2101
- let { changeSetId: e, branchId: n, validityPeriod: r, releaseSpec: i, supersedesReleaseIds: a } = t, { cs: o, chain: s, branch: c, c: l } = at(e, n);
2102
- if (J(l), c.kind !== "editorial") throw new _("only an editorial Branch's head is released");
2103
- if (o.plannedReleases.some((e) => e.branchId === n)) throw new _(`Branch ${n} is planned already`);
2104
- let u = {
2105
- id: `rls_stub_${H++}`,
2130
+ return B(e, ["planRelease", t], async () => {
2131
+ let { changeSetId: e, branchId: n, validityPeriod: r, releaseSpec: i, supersedesReleaseIds: a } = t, { cs: o, chain: s, branch: c, c: l } = ct(e, n);
2132
+ if (q(l), c.kind !== "editorial") throw new u("only an editorial Branch's head is released");
2133
+ if (o.plannedReleases.some((e) => e.branchId === n)) throw new u(`Branch ${n} is planned already`);
2134
+ let d = {
2135
+ id: `rls_stub_${V++}`,
2106
2136
  contentId: s.contentId,
2107
2137
  kind: "revision",
2108
2138
  branchId: n,
@@ -2115,35 +2145,35 @@ function M(y = {}) {
2115
2145
  splitFromReleaseId: "",
2116
2146
  withheld: !1
2117
2147
  };
2118
- return ct(l, u), o.plannedReleases.push(u), lt(o, l), structuredClone(u);
2148
+ return dt(l, d), o.plannedReleases.push(d), ft(o, l), structuredClone(d);
2119
2149
  });
2120
2150
  },
2121
2151
  async updatePlannedRelease({ idempotencyKey: e, ...t }) {
2122
- return V(e, ["updatePlannedRelease", t], async () => {
2123
- let { changeSetId: e, plannedReleaseId: n, validityPeriod: r, releaseSpec: i, supersedesReleaseIds: a } = t, o = Z(e), s = o.plannedReleases.findIndex((e) => e.id === n);
2124
- if (s < 0) throw k("Planned Release", n);
2152
+ return B(e, ["updatePlannedRelease", t], async () => {
2153
+ let { changeSetId: e, plannedReleaseId: n, validityPeriod: r, releaseSpec: i, supersedesReleaseIds: a } = t, o = X(e), s = o.plannedReleases.findIndex((e) => e.id === n);
2154
+ if (s < 0) throw D("Planned Release", n);
2125
2155
  let c = o.plannedReleases[s];
2126
- if (c.proposed) throw new _("a proposal is derived from the plans and can't be set");
2127
- let l = U(c.contentId);
2128
- J(l);
2129
- let u = {
2156
+ if (c.proposed) throw new u("a proposal is derived from the plans and can't be set");
2157
+ let l = H(c.contentId);
2158
+ q(l);
2159
+ let d = {
2130
2160
  ...structuredClone(c),
2131
2161
  ...r ? { validityPeriod: { ...r } } : {},
2132
2162
  ...i ? { releaseSpec: structuredClone(i) } : {},
2133
2163
  ...a ? { supersedesReleaseIds: [...a] } : {}
2134
2164
  };
2135
- return ct(l, u), o.plannedReleases[s] = u, lt(o, l), structuredClone(u);
2165
+ return dt(l, d), o.plannedReleases[s] = d, ft(o, l), structuredClone(d);
2136
2166
  });
2137
2167
  },
2138
2168
  async appendBranch({ idempotencyKey: e, ...t }) {
2139
- return V(e, ["appendBranch", t], async () => {
2140
- let { changeSetId: e, chainId: n, effectiveOn: r } = t, i = Z(e), a = i.chains.find((e) => e.id === n);
2141
- if (!a) throw k("Chain", n);
2142
- let o = U(a.contentId);
2143
- if (a.born || !G(o)) throw new _("only a Chain on published Dated Content takes dates");
2169
+ return B(e, ["appendBranch", t], async () => {
2170
+ let { changeSetId: e, chainId: n, effectiveOn: r } = t, i = X(e), a = i.chains.find((e) => e.id === n);
2171
+ if (!a) throw D("Chain", n);
2172
+ let o = H(a.contentId);
2173
+ if (a.born || !W(o)) throw new u("only a Chain on published Dated Content takes dates");
2144
2174
  let s = a.branches.filter((e) => e.kind === "editorial").at(-1);
2145
- if (!g.test(r) || s?.effectiveOn && r <= s.effectiveOn) throw new _("effective_on is a day after the Chain's last editorial Branch's");
2146
- let c = a.branches.at(-1), l = `br_stub_${H++}`;
2175
+ if (!_.test(r) || s?.effectiveOn && r <= s.effectiveOn) throw new u("effective_on is a day after the Chain's last editorial Branch's");
2176
+ let c = a.branches.at(-1), l = `br_stub_${V++}`;
2147
2177
  a.branches.push({
2148
2178
  id: l,
2149
2179
  position: a.branches.length,
@@ -2151,66 +2181,66 @@ function M(y = {}) {
2151
2181
  headRevisionId: c?.headRevisionId ?? "",
2152
2182
  effectiveOn: r
2153
2183
  });
2154
- let u = o.branches[e];
2155
- return u && (o.branches[e] = {
2156
- ...u,
2184
+ let d = o.branches[e];
2185
+ return d && (o.branches[e] = {
2186
+ ...d,
2157
2187
  branchId: l
2158
2188
  }), {
2159
- changeSet: A(i),
2189
+ changeSet: O(i),
2160
2190
  branchId: l
2161
2191
  };
2162
2192
  });
2163
2193
  },
2164
2194
  async dropChain({ idempotencyKey: e, ...t }) {
2165
- return V(e, ["dropChain", t], async () => {
2166
- let { changeSetId: e, chainId: n } = t, r = Z(e), i = r.chains.find((e) => e.id === n);
2167
- if (!i) throw k("Chain", n);
2168
- if (i.born) throw new _("the Chain of Content born in the Change Set can't be dropped: discard the Change Set");
2169
- for (let e of i.branches) st(e.id);
2170
- return r.chains = r.chains.filter((e) => e.id !== n), r.plannedReleases = r.plannedReleases.filter((e) => e.contentId !== i.contentId), delete U(i.contentId).branches[e], A(r);
2195
+ return B(e, ["dropChain", t], async () => {
2196
+ let { changeSetId: e, chainId: n } = t, r = X(e), i = r.chains.find((e) => e.id === n);
2197
+ if (!i) throw D("Chain", n);
2198
+ if (i.born) throw new u("the Chain of Content born in the Change Set can't be dropped: discard the Change Set");
2199
+ for (let e of i.branches) ut(e.id);
2200
+ return r.chains = r.chains.filter((e) => e.id !== n), r.plannedReleases = r.plannedReleases.filter((e) => e.contentId !== i.contentId), delete H(i.contentId).branches[e], O(r);
2171
2201
  });
2172
2202
  },
2173
2203
  async getPendingMerge(e) {
2174
- let t = B.get(e);
2204
+ let t = z.get(e);
2175
2205
  return t ? structuredClone(t) : null;
2176
2206
  },
2177
2207
  async resolveMerge({ idempotencyKey: e, ...t }) {
2178
- return V(e, ["resolveMerge", t], async () => {
2179
- let { changeSetId: e, branchId: n, expectedHeadId: r, resolutions: a } = t, { chain: o, branch: s, c } = at(e, n), l = B.get(n);
2180
- if (!l) throw new _(`Branch ${n} has no Pending Merge`);
2181
- if (s.headRevisionId !== r) throw new i({
2208
+ return B(e, ["resolveMerge", t], async () => {
2209
+ let { changeSetId: e, branchId: n, expectedHeadId: r, resolutions: i } = t, { chain: a, branch: s, c } = ct(e, n), l = z.get(n);
2210
+ if (!l) throw new u(`Branch ${n} has no Pending Merge`);
2211
+ if (s.headRevisionId !== r) throw new o({
2182
2212
  contentId: c.id,
2183
2213
  branchId: n,
2184
2214
  expectedHeadId: r,
2185
2215
  currentHeadId: s.headRevisionId
2186
2216
  });
2187
- let u = a.map((e) => e.path), d = l.fields.map((e) => e.path);
2188
- if (new Set(u).size !== u.length || u.some((e) => !d.includes(e)) || d.some((e) => !u.includes(e))) throw new _("decide every field the Pending Merge lists, once");
2189
- let f = structuredClone(l.merged);
2190
- for (let e of a) {
2217
+ let d = i.map((e) => e.path), f = l.fields.map((e) => e.path);
2218
+ if (new Set(d).size !== d.length || d.some((e) => !f.includes(e)) || f.some((e) => !d.includes(e))) throw new u("decide every field the Pending Merge lists, once");
2219
+ let p = structuredClone(l.merged);
2220
+ for (let e of i) {
2191
2221
  let t = l.fields.find((t) => t.path === e.path), n = "side" in e ? e.side === "ours" ? t.ours : t.theirs : e.value, r = e.path.replace(/^\//, "");
2192
- n === void 0 ? delete f[r] : f[r] = structuredClone(n);
2222
+ n === void 0 ? delete p[r] : p[r] = structuredClone(n);
2193
2223
  }
2194
- let p = it({
2224
+ let m = st({
2195
2225
  changeSetId: e,
2196
- chain: o,
2226
+ chain: a,
2197
2227
  branch: s,
2198
2228
  c,
2199
- data: f,
2229
+ data: p,
2200
2230
  cause: "resolve",
2201
2231
  secondParentId: l.theirsRevisionId
2202
2232
  });
2203
- return st(n), We.delete(n), p;
2233
+ return ut(n), qe.delete(n), m;
2204
2234
  });
2205
2235
  },
2206
2236
  async abortMerge({ idempotencyKey: e, ...t }) {
2207
- return V(e, ["abortMerge", t], async () => {
2208
- if (at(t.changeSetId, t.branchId), !B.has(t.branchId)) throw new _(`Branch ${t.branchId} has no Pending Merge`);
2209
- st(t.branchId);
2237
+ return B(e, ["abortMerge", t], async () => {
2238
+ if (ct(t.changeSetId, t.branchId), !z.has(t.branchId)) throw new u(`Branch ${t.branchId} has no Pending Merge`);
2239
+ ut(t.branchId);
2210
2240
  });
2211
2241
  },
2212
2242
  async previewInForce({ contentId: e, changeSetId: t, validOn: n }) {
2213
- let r = Z(t), i = U(e), a = n || Je(), o = r.chains.find((t) => t.contentId === e), s = (e) => !e.validityPeriod || e.validityPeriod.firstDay <= a && (e.validityPeriod.lastDay === "" || a <= e.validityPeriod.lastDay), c = r.plannedReleases.find((t) => t.contentId === e && t.kind !== "repeal" && s(t));
2243
+ let r = X(t), i = H(e), a = n || Ze(), o = r.chains.find((t) => t.contentId === e), s = (e) => !e.validityPeriod || e.validityPeriod.firstDay <= a && (e.validityPeriod.lastDay === "" || a <= e.validityPeriod.lastDay), c = r.plannedReleases.find((t) => t.contentId === e && t.kind !== "repeal" && s(t));
2214
2244
  if (c) {
2215
2245
  let e = c.branchId ? o?.branches.find((e) => e.id === c.branchId)?.headRevisionId ?? "" : c.revisionId;
2216
2246
  return {
@@ -2219,24 +2249,24 @@ function M(y = {}) {
2219
2249
  planned: !0,
2220
2250
  withheld: !1,
2221
2251
  validityPeriod: c.validityPeriod ? { ...c.validityPeriod } : void 0,
2222
- data: structuredClone(q(i, e) ?? {})
2252
+ data: structuredClone(K(i, e) ?? {})
2223
2253
  };
2224
2254
  }
2225
- let l = te(i.timeline ?? [], a);
2255
+ let l = ee(i.timeline ?? [], a);
2226
2256
  return l ? {
2227
2257
  releaseId: l.releaseId,
2228
2258
  revisionId: l.revisionId,
2229
2259
  planned: !1,
2230
2260
  withheld: !1,
2231
2261
  validityPeriod: l.validityPeriod ? { ...l.validityPeriod } : void 0,
2232
- data: structuredClone(q(i, l.revisionId) ?? {})
2262
+ data: structuredClone(K(i, l.revisionId) ?? {})
2233
2263
  } : null;
2234
2264
  }
2235
2265
  };
2236
- return $;
2237
- function bt(e, t, n) {
2266
+ return Q;
2267
+ function Ct(e, t, n) {
2238
2268
  let r = {
2239
- id: `rls_stub_${H++}`,
2269
+ id: `rls_stub_${V++}`,
2240
2270
  contentId: e.id,
2241
2271
  branchId: "",
2242
2272
  revisionId: e.inForce?.revisionId ?? e.main?.revisionId ?? "",
@@ -2252,10 +2282,10 @@ function M(y = {}) {
2252
2282
  plannedRelease: r
2253
2283
  }], structuredClone({
2254
2284
  plannedRelease: r,
2255
- gapReferrers: Xe(e.id)
2285
+ gapReferrers: $e(e.id)
2256
2286
  });
2257
2287
  }
2258
- function xt(e, t, n) {
2288
+ function $(e, t, n) {
2259
2289
  let r = (t, n) => ({
2260
2290
  id: e.id,
2261
2291
  blueprintId: e.blueprintId,
@@ -2270,33 +2300,33 @@ function M(y = {}) {
2270
2300
  if (t.kind === "in_force") return e.inForce ? [r(e.inForce, { releaseId: e.inForce.releaseId })] : [];
2271
2301
  if (t.kind === "change_set") {
2272
2302
  let i = e.branches[t.changeSetId];
2273
- return !i || n && !De(i.data, n) ? [] : [r(i, {
2303
+ return !i || n && !Me(i.data, n) ? [] : [r(i, {
2274
2304
  changeSetId: t.changeSetId,
2275
2305
  branchId: i.branchId
2276
2306
  })];
2277
2307
  }
2278
2308
  if (!n) return e.main ? [r(e.main, {})] : [];
2279
2309
  let i = [];
2280
- e.main && De(e.main.data, n) && i.push(r(e.main, {}));
2281
- for (let [t, a] of Object.entries(e.branches).sort(([, e], [, t]) => e.branchId < t.branchId ? -1 : 1)) T.find((e) => e.id === t)?.state === "open" && De(a.data, n) && i.push(r(a, {
2310
+ e.main && Me(e.main.data, n) && i.push(r(e.main, {}));
2311
+ for (let [t, a] of Object.entries(e.branches).sort(([, e], [, t]) => e.branchId < t.branchId ? -1 : 1)) x.find((e) => e.id === t)?.state === "open" && Me(a.data, n) && i.push(r(a, {
2282
2312
  changeSetId: t,
2283
2313
  branchId: a.branchId
2284
2314
  }));
2285
2315
  return i;
2286
2316
  }
2287
2317
  }
2288
- function De(e, t) {
2318
+ function Me(e, t) {
2289
2319
  let n = (e) => e.toLocaleLowerCase().replace(/\s+/g, " "), r = n(t);
2290
2320
  return Object.values(e).some((e) => typeof e == "string" && n(e).includes(r));
2291
2321
  }
2292
2322
  //#endregion
2293
2323
  //#region src/testing/stub-status-source.ts
2294
- function N(e = ce()) {
2324
+ function j(e = fe()) {
2295
2325
  return { async listChangeSetStatuses() {
2296
2326
  return e.map((e) => ({ ...e }));
2297
2327
  } };
2298
2328
  }
2299
2329
  //#endregion
2300
- export { T as STUB_NOW, w as STUB_OTHER_USER_ID, C as STUB_USER_ID, S as STUB_WORKSPACE_ID, ve as createStubBlueprintSource, M as createStubContenthubClient, N as createStubStatusSource, se as stubBlockReasons, j as stubBlocker, me as stubBlueprintReleases, pe as stubBlueprints, ce as stubChangeSetStatuses, ue as stubChangeSets, fe as stubCollections, _e as stubContents, E as stubIdentity, ge as stubRepealedContent, de as stubRequiredChecks, he as stubResolvedReleases, le as stubStatusTransitions, D as stubUndatedContent };
2330
+ export { S as STUB_NOW, x as STUB_OTHER_USER_ID, b as STUB_USER_ID, ue as STUB_WORKSPACE_ID, T as createStubBlueprintSource, A as createStubContenthubClient, j as createStubStatusSource, de as stubBlockReasons, k as stubBlocker, ve as stubBlueprintReleases, _e as stubBlueprints, fe as stubChangeSetStatuses, me as stubChangeSets, ge as stubCollections, xe as stubContents, C as stubIdentity, be as stubRepealedContent, he as stubRequiredChecks, ye as stubResolvedReleases, pe as stubStatusTransitions, w as stubUndatedContent };
2301
2331
 
2302
2332
  //# sourceMappingURL=testing.js.map