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