@loomcycle/explorer 0.11.0 → 0.12.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/index.js CHANGED
@@ -293,28 +293,28 @@ function T({ value: e, children: t }) {
293
293
  children: t
294
294
  });
295
295
  }
296
- function E() {
296
+ function ee() {
297
297
  let e = n(w);
298
298
  if (!e) throw Error("useExplorerData must be used within <PathExplorer> or <DocumentViewer> (no ExplorerDataLayer in context)");
299
299
  return e;
300
300
  }
301
- var D = 5e3;
302
- function O(e) {
301
+ var E = 5e3;
302
+ function D(e) {
303
303
  return e === "" ? "/" : e;
304
304
  }
305
- function k(e) {
305
+ function O(e) {
306
306
  let t = e.lastIndexOf("/");
307
307
  return t <= 0 ? "" : e.slice(0, t);
308
308
  }
309
- function A(e) {
309
+ function k(e) {
310
310
  let t = [""], n = e.split("/").filter(Boolean), r = "";
311
311
  for (let e = 0; e < n.length - 1; e++) r = `${r}/${n[e]}`, t.push(r);
312
312
  return t;
313
313
  }
314
- function j(e) {
314
+ function A(e) {
315
315
  return e instanceof Error ? e.message : String(e);
316
316
  }
317
- function M(e, t) {
317
+ function j(e, t) {
318
318
  return {
319
319
  entries: [...t, ...e.entries ?? []],
320
320
  nextCursor: e.next_cursor || void 0,
@@ -322,7 +322,7 @@ function M(e, t) {
322
322
  loading: !1
323
323
  };
324
324
  }
325
- var ee = class {
325
+ var te = class {
326
326
  data;
327
327
  scope;
328
328
  browse;
@@ -356,7 +356,7 @@ var ee = class {
356
356
  }
357
357
  reload(e) {
358
358
  let t = this.dirs.get(e), n = t?.entries.length ?? 0, r = t?.loaded && !t.nextCursor ? n + this.pageLimit : n;
359
- return this.fetchFirst(e, Math.min(D, Math.max(this.pageLimit, r)));
359
+ return this.fetchFirst(e, Math.min(E, Math.max(this.pageLimit, r)));
360
360
  }
361
361
  fetchFirst(e, t) {
362
362
  let n = (this.epoch.get(e) ?? 0) + 1;
@@ -368,15 +368,15 @@ var ee = class {
368
368
  loaded: r?.loaded ?? !1,
369
369
  loading: !0
370
370
  });
371
- let i = this.data.pathLs(O(e), this.scope, !1, this.browse, { limit: t }).then((t) => {
372
- this.epoch.get(e) === n && this.set(e, M(t, []));
371
+ let i = this.data.pathLs(D(e), this.scope, !1, this.browse, { limit: t }).then((t) => {
372
+ this.epoch.get(e) === n && this.set(e, j(t, []));
373
373
  }, (t) => {
374
374
  throw this.epoch.get(e) === n && this.set(e, {
375
375
  entries: r?.entries ?? [],
376
376
  nextCursor: r?.nextCursor,
377
377
  loaded: r?.loaded ?? !1,
378
378
  loading: !1,
379
- error: j(t)
379
+ error: A(t)
380
380
  }), t;
381
381
  });
382
382
  return this.track(e, i);
@@ -392,16 +392,16 @@ var ee = class {
392
392
  loading: !0,
393
393
  error: void 0
394
394
  });
395
- let i = this.data.pathLs(O(e), this.scope, !1, this.browse, {
395
+ let i = this.data.pathLs(D(e), this.scope, !1, this.browse, {
396
396
  limit: this.pageLimit,
397
397
  cursor: n.nextCursor
398
398
  }).then((t) => {
399
- this.epoch.get(e) === r && this.set(e, M(t, n.entries));
399
+ this.epoch.get(e) === r && this.set(e, j(t, n.entries));
400
400
  }, (t) => {
401
401
  throw this.epoch.get(e) === r && this.set(e, {
402
402
  ...n,
403
403
  loading: !1,
404
- error: j(t)
404
+ error: A(t)
405
405
  }), t;
406
406
  });
407
407
  return this.track(e, i);
@@ -427,7 +427,7 @@ var ee = class {
427
427
  for (let t of [...this.dirs.keys()]) (t === e || t.startsWith(`${e}/`)) && (this.dirs.delete(t), this.epoch.set(t, (this.epoch.get(t) ?? 0) + 1), this.inflight.delete(t));
428
428
  this.publish();
429
429
  }
430
- let n = A(e).filter((e) => this.dirs.has(e));
430
+ let n = k(e).filter((e) => this.dirs.has(e));
431
431
  await Promise.all(n.map((e) => this.reload(e)));
432
432
  }
433
433
  async refresh(e) {
@@ -439,11 +439,11 @@ var ee = class {
439
439
  await Promise.all(n.map((e) => this.reload(e)));
440
440
  }
441
441
  };
442
- async function te(e, t, n, r) {
442
+ async function ne(e, t, n, r) {
443
443
  let i = [], a;
444
444
  for (;;) {
445
- let o = await e.pathLs(O(t), n, !0, r, {
446
- limit: D,
445
+ let o = await e.pathLs(D(t), n, !0, r, {
446
+ limit: E,
447
447
  cursor: a
448
448
  });
449
449
  i.push(...o.entries ?? []);
@@ -452,7 +452,7 @@ async function te(e, t, n, r) {
452
452
  a = s;
453
453
  }
454
454
  }
455
- function ne(e) {
455
+ function re(e) {
456
456
  let t = [];
457
457
  for (let n of e) {
458
458
  if (n.kind !== "document") continue;
@@ -463,7 +463,7 @@ function ne(e) {
463
463
  }
464
464
  //#endregion
465
465
  //#region src/lib/createClient.ts
466
- function N(e) {
466
+ function ie(e) {
467
467
  let t = e.fetch;
468
468
  return new d({
469
469
  baseUrl: e.baseUrl,
@@ -471,21 +471,21 @@ function N(e) {
471
471
  fetch: (e, n) => t ? t(e, n) : fetch(e, n)
472
472
  });
473
473
  }
474
- function re(e) {
474
+ function M(e) {
475
475
  let t = e.fetch, n = (e, n) => t ? t(e, n) : fetch(e, n);
476
476
  return (t) => {
477
477
  let r = {};
478
478
  return e.token && (r.Authorization = `Bearer ${e.token}`), n(e.baseUrl + t, { headers: r });
479
479
  };
480
480
  }
481
- var ie = class extends Error {
481
+ var ae = class extends Error {
482
482
  status;
483
483
  code;
484
484
  constructor(e, t, n) {
485
485
  super(e), this.name = "RequestError", this.status = t, this.code = n;
486
486
  }
487
487
  };
488
- function P(e) {
488
+ function oe(e) {
489
489
  let t = e.fetch, n = (e, n) => t ? t(e, n) : fetch(e, n);
490
490
  return async (t, r) => {
491
491
  let i = {
@@ -503,16 +503,16 @@ function P(e) {
503
503
  } catch {}
504
504
  if (!a.ok) {
505
505
  let e = s && typeof s == "object" ? s : {};
506
- throw new ie(typeof e.error == "string" && e.error ? e.error : `${a.status} ${a.statusText}`.trim(), a.status, typeof e.code == "string" ? e.code : void 0);
506
+ throw new ae(typeof e.error == "string" && e.error ? e.error : `${a.status} ${a.statusText}`.trim(), a.status, typeof e.code == "string" ? e.code : void 0);
507
507
  }
508
508
  return s;
509
509
  };
510
510
  }
511
511
  //#endregion
512
512
  //#region src/components/ExplorerRoot.tsx
513
- function F(e) {
513
+ function N(e) {
514
514
  let { dataLayer: t, client: n, connection: r } = e;
515
- return i(() => t || (n ? S(n) : r ? S(N(r), re(r), P(r)) : null), [
515
+ return i(() => t || (n ? S(n) : r ? S(ie(r), M(r), oe(r)) : null), [
516
516
  t,
517
517
  n,
518
518
  r?.baseUrl,
@@ -520,7 +520,7 @@ function F(e) {
520
520
  r?.fetch
521
521
  ]);
522
522
  }
523
- function I({ theme: e, dataLayer: t, children: n }) {
523
+ function P({ theme: e, dataLayer: t, children: n }) {
524
524
  let r = e ? { "data-theme": e } : {};
525
525
  return t ? /* @__PURE__ */ l("div", {
526
526
  className: "loomcycle-explorer",
@@ -549,32 +549,32 @@ function I({ theme: e, dataLayer: t, children: n }) {
549
549
  }
550
550
  //#endregion
551
551
  //#region src/lib/docTrail.ts
552
- function ae(e, t, n) {
552
+ function se(e, t, n) {
553
553
  let r = e[e.length - 1];
554
554
  return [...r && r.documentId === t.documentId ? [...e.slice(0, -1), {
555
555
  ...r,
556
- ...L(t)
556
+ ...F(t)
557
557
  }] : [...e, t], n];
558
558
  }
559
- function oe(e, t) {
559
+ function ce(e, t) {
560
560
  return t < 0 || t >= e.length - 1 ? e : e.slice(0, t + 1);
561
561
  }
562
- function se(e, t, n) {
562
+ function le(e, t, n) {
563
563
  let r = e[e.length - 1];
564
564
  if (!r || r.documentId !== t) return e;
565
565
  let i = {
566
566
  ...r,
567
- ...L(n)
567
+ ...F(n)
568
568
  };
569
569
  return i.title === r.title && i.path === r.path ? e : [...e.slice(0, -1), i];
570
570
  }
571
- function L(e) {
571
+ function F(e) {
572
572
  return Object.fromEntries(Object.entries(e).filter(([, e]) => e !== void 0));
573
573
  }
574
- function ce(e) {
574
+ function ue(e) {
575
575
  return e.title ? e.title : e.path ? e.path.slice(e.path.lastIndexOf("/") + 1) || e.path : e.documentId.slice(0, 8);
576
576
  }
577
- function R(e, t = 4) {
577
+ function I(e, t = 4) {
578
578
  let n = Array.from({ length: e }, (e, t) => ({
579
579
  kind: "crumb",
580
580
  index: t
@@ -590,24 +590,24 @@ function R(e, t = 4) {
590
590
  ...n.slice(e - r)
591
591
  ];
592
592
  }
593
- function le(e, t) {
593
+ function de(e, t) {
594
594
  for (let n of e.values()) {
595
- let e = n.entries.find((e) => z(e) === t);
595
+ let e = n.entries.find((e) => L(e) === t);
596
596
  if (e) return e.full_path;
597
597
  }
598
598
  }
599
- function z(e) {
599
+ function L(e) {
600
600
  if (e.kind === "document") return e.resource_ref?.document_id || void 0;
601
601
  }
602
- function B(e, t) {
602
+ function R(e, t) {
603
603
  return t && e.some((e) => e.id === t) ? t : e.find((e) => !e.parent_id)?.id;
604
604
  }
605
605
  //#endregion
606
606
  //#region src/components/DocTrail.tsx
607
- function ue({ trail: e, onJump: t }) {
607
+ function fe({ trail: e, onJump: t }) {
608
608
  let [n, r] = o(!1);
609
609
  if (e.length < 2) return null;
610
- let i = e.length - 1, a = e[i - 1], s = R(e.length, n ? e.length : void 0);
610
+ let i = e.length - 1, a = e[i - 1], s = I(e.length, n ? e.length : void 0);
611
611
  return /* @__PURE__ */ u("nav", {
612
612
  className: "doc-trail",
613
613
  "aria-label": "Documents you came through",
@@ -615,7 +615,7 @@ function ue({ trail: e, onJump: t }) {
615
615
  type: "button",
616
616
  className: "doc-trail-back",
617
617
  onClick: () => t(i - 1),
618
- title: `Back to ${ce(a)}`,
618
+ title: `Back to ${ue(a)}`,
619
619
  children: "← Back"
620
620
  }), /* @__PURE__ */ l("ol", {
621
621
  className: "doc-trail-list",
@@ -625,7 +625,7 @@ function ue({ trail: e, onJump: t }) {
625
625
  type: "button",
626
626
  className: "doc-trail-gap",
627
627
  onClick: () => r(!0),
628
- title: `Show ${n.hidden.length} more: ${n.hidden.map((t) => ce(e[t])).join(" › ")}`,
628
+ title: `Show ${n.hidden.length} more: ${n.hidden.map((t) => ue(e[t])).join(" › ")}`,
629
629
  "aria-label": `Show ${n.hidden.length} hidden documents`,
630
630
  children: "…"
631
631
  })
@@ -634,8 +634,8 @@ function ue({ trail: e, onJump: t }) {
634
634
  children: /* @__PURE__ */ l("span", {
635
635
  className: "doc-trail-current",
636
636
  "aria-current": "page",
637
- title: ce(e[i]),
638
- children: ce(e[i])
637
+ title: ue(e[i]),
638
+ children: ue(e[i])
639
639
  })
640
640
  }, n.index) : /* @__PURE__ */ l("li", {
641
641
  className: "doc-trail-item",
@@ -643,8 +643,8 @@ function ue({ trail: e, onJump: t }) {
643
643
  type: "button",
644
644
  className: "doc-trail-crumb",
645
645
  onClick: () => t(n.index),
646
- title: ce(e[n.index]),
647
- children: ce(e[n.index])
646
+ title: ue(e[n.index]),
647
+ children: ue(e[n.index])
648
648
  })
649
649
  }, n.index))
650
650
  })]
@@ -652,8 +652,8 @@ function ue({ trail: e, onJump: t }) {
652
652
  }
653
653
  //#endregion
654
654
  //#region src/components/Splitter.tsx
655
- var V = 6;
656
- function de({ children: e, defaultLeftWidth: n = 380, minLeftWidth: i = 180, minRightWidth: s = 240, storageKey: c, className: d, hideRight: f = !1 }) {
655
+ var z = 6;
656
+ function pe({ children: e, defaultLeftWidth: n = 380, minLeftWidth: i = 180, minRightWidth: s = 240, storageKey: c, className: d, hideRight: f = !1 }) {
657
657
  let p = () => {
658
658
  if (c) {
659
659
  let e = localStorage.getItem(c), t = e ? parseInt(e, 10) : NaN;
@@ -675,7 +675,7 @@ function de({ children: e, defaultLeftWidth: n = 380, minLeftWidth: i = 180, min
675
675
  e.preventDefault(), b(!0), e.target.setPointerCapture(e.pointerId);
676
676
  }, []), S = t((e) => {
677
677
  if (!y || !v.current) return;
678
- let t = v.current.getBoundingClientRect(), n = e.clientX - t.left, r = t.width - s - V;
678
+ let t = v.current.getBoundingClientRect(), n = e.clientX - t.left, r = t.width - s - z;
679
679
  h(Math.max(i, Math.min(n, r)));
680
680
  }, [
681
681
  y,
@@ -690,7 +690,7 @@ function de({ children: e, defaultLeftWidth: n = 380, minLeftWidth: i = 180, min
690
690
  return /* @__PURE__ */ u("div", {
691
691
  ref: v,
692
692
  className: `splitter ${d ?? ""} ${y ? "dragging" : ""}`,
693
- style: { gridTemplateColumns: f ? "1fr 0 0" : `min(${m}px, calc(100% - ${s + V}px)) ${V}px 1fr` },
693
+ style: { gridTemplateColumns: f ? "1fr 0 0" : `min(${m}px, calc(100% - ${s + z}px)) ${z}px 1fr` },
694
694
  children: [
695
695
  /* @__PURE__ */ l("div", {
696
696
  className: "splitter-pane splitter-left",
@@ -717,18 +717,18 @@ function de({ children: e, defaultLeftWidth: n = 380, minLeftWidth: i = 180, min
717
717
  }
718
718
  //#endregion
719
719
  //#region src/lib/imageUpload.ts
720
- var H = [
720
+ var B = [
721
721
  "image/png",
722
722
  "image/jpeg",
723
723
  "image/gif",
724
724
  "image/webp"
725
725
  ];
726
- function U(e) {
727
- return H.includes(e);
726
+ function V(e) {
727
+ return B.includes(e);
728
728
  }
729
- function fe(e) {
729
+ function H(e) {
730
730
  return new Promise((t, n) => {
731
- if (!U(e.type)) {
731
+ if (!V(e.type)) {
732
732
  n(/* @__PURE__ */ Error(`unsupported image type "${e.type || "unknown"}" (png, jpeg, gif, webp only)`));
733
733
  return;
734
734
  }
@@ -742,11 +742,11 @@ function fe(e) {
742
742
  }, r.readAsDataURL(e);
743
743
  });
744
744
  }
745
- function pe(e) {
745
+ function me(e) {
746
746
  if (!e) return null;
747
747
  for (let t = 0; t < e.length; t++) {
748
748
  let n = e[t];
749
- if (n.kind === "file" && U(n.type)) {
749
+ if (n.kind === "file" && V(n.type)) {
750
750
  let e = n.getAsFile();
751
751
  if (e) return e;
752
752
  }
@@ -755,8 +755,8 @@ function pe(e) {
755
755
  }
756
756
  //#endregion
757
757
  //#region src/lib/edgePages.ts
758
- var W = 20;
759
- async function me(e, t, n, r, i = 20) {
758
+ var he = 20;
759
+ async function U(e, t, n, r, i = 20) {
760
760
  let a = [], o;
761
761
  for (let s = 0; s < i; s++) {
762
762
  let i = await e.documentGetEdges(t, n, r, o ? { after: o } : void 0);
@@ -781,7 +781,7 @@ async function me(e, t, n, r, i = 20) {
781
781
  }
782
782
  //#endregion
783
783
  //#region src/lib/chunkAncestry.ts
784
- function he(e, t) {
784
+ function ge(e, t) {
785
785
  if (!t) return [];
786
786
  let n = new Map(e.map((e) => [e.id, e])), r = /* @__PURE__ */ new Set([t]), i = [], a = n.get(t)?.parent_id;
787
787
  for (; a && !r.has(a);) {
@@ -793,14 +793,14 @@ function he(e, t) {
793
793
  }
794
794
  //#endregion
795
795
  //#region src/lib/statement.ts
796
- var ge = /* @__PURE__ */ new Set(["manual", "wikilink"]), _e = 280;
797
- function ve(e) {
796
+ var _e = /* @__PURE__ */ new Set(["manual", "wikilink"]), ve = 280;
797
+ function ye(e) {
798
798
  return e.status && e.status !== "asserted" ? e.status : void 0;
799
799
  }
800
- function G(e) {
801
- return e.method && !ge.has(e.method) ? e.method : void 0;
800
+ function W(e) {
801
+ return e.method && !_e.has(e.method) ? e.method : void 0;
802
802
  }
803
- function ye(e) {
803
+ function G(e) {
804
804
  return e.status === "proposed" && !!e.id;
805
805
  }
806
806
  function be(e) {
@@ -812,19 +812,19 @@ function xe(e) {
812
812
  if (t) return `valid from ${t}`;
813
813
  if (n) return `valid until ${n}`;
814
814
  }
815
- function K(e) {
815
+ function Se(e) {
816
816
  if (e.judged_at == null) return;
817
817
  let t = `judged by ${e.judged_by || "a judge"} on ${be(e.judged_at)}`;
818
818
  return e.judge_reason ? `${t}: ${e.judge_reason}` : t;
819
819
  }
820
- function Se(e, t = 3) {
820
+ function K(e, t = 3) {
821
821
  let n = (e.evidence ?? []).slice(0, t), r = Math.max(e.evidence_count ?? 0, e.evidence?.length ?? 0);
822
822
  return {
823
823
  rows: n,
824
824
  more: Math.max(0, r - n.length)
825
825
  };
826
826
  }
827
- function Ce(e, t = _e) {
827
+ function Ce(e, t = ve) {
828
828
  let n = e.replace(/\s+/g, " ").trim();
829
829
  return n.length > t ? n.slice(0, t - 1) + "…" : n;
830
830
  }
@@ -926,9 +926,9 @@ function je(e, t) {
926
926
  return e.documentRuleStatements ? q(t) : void 0;
927
927
  }
928
928
  function Me(e, t) {
929
- return e.filter((e) => ye(e) && !!e.id && e.from_document_id === t);
929
+ return e.filter((e) => G(e) && !!e.id && e.from_document_id === t);
930
930
  }
931
- function J(e, t, n, r) {
931
+ function Ne(e, t, n, r) {
932
932
  return e ? {
933
933
  proposals: t,
934
934
  scope: e,
@@ -936,7 +936,7 @@ function J(e, t, n, r) {
936
936
  onChanged: r
937
937
  } : void 0;
938
938
  }
939
- function Ne(e, t, n) {
939
+ function J(e, t, n) {
940
940
  return e.documentRuleStatements ? Oe({ rule: (n) => e.documentRuleStatements(n, t.browse) }, {
941
941
  action: t.action,
942
942
  ...t.ids && t.ids.length > 0 ? { ids: t.ids } : { filter: { from_document_id: t.documentId } },
@@ -1058,14 +1058,14 @@ function Be(e) {
1058
1058
  function Ve(e) {
1059
1059
  return e === "image" ? "🖼" : e === "mermaid" ? "📊" : "";
1060
1060
  }
1061
- function $(e, t) {
1061
+ function He(e, t) {
1062
1062
  for (let n of e) {
1063
1063
  if (n.row.id === t) return n;
1064
- let e = $(n.children, t);
1064
+ let e = He(n.children, t);
1065
1065
  if (e) return e;
1066
1066
  }
1067
1067
  }
1068
- function He({ tree: e, selectedId: n, onSelect: i, colorEnabled: a, scheme: s, linkedIds: c }) {
1068
+ function $({ tree: e, selectedId: n, onSelect: i, colorEnabled: a, scheme: s, linkedIds: c }) {
1069
1069
  let [u, d] = o(() => /* @__PURE__ */ new Map()), f = t((e) => {
1070
1070
  d((t) => {
1071
1071
  let n = new Map(t);
@@ -1225,16 +1225,16 @@ function qe({ code: e, onNodeClick: t }) {
1225
1225
  //#endregion
1226
1226
  //#region src/components/ChunkEditorModal.tsx
1227
1227
  function Je({ chunk: e, scope: t, browse: n, onClose: i, onSaved: a }) {
1228
- let s = E(), [c, d] = o(e.title), [f, p] = o(e.type ?? ""), [m, h] = o(e.status ?? ""), [g, _] = o(e.body ?? ""), [v, y] = o(e.fields ? JSON.stringify(e.fields, null, 2) : ""), [b, x] = o((e.tags ?? []).join(", ")), [S, C] = o(!1), [w, T] = o(null), [D, O] = o(!1), k = f === "mermaid", A = f === "image" || !!e.asset, [j, M] = o(g);
1228
+ let s = ee(), [c, d] = o(e.title), [f, p] = o(e.type ?? ""), [m, h] = o(e.status ?? ""), [g, _] = o(e.body ?? ""), [v, y] = o(e.fields ? JSON.stringify(e.fields, null, 2) : ""), [b, x] = o((e.tags ?? []).join(", ")), [S, C] = o(!1), [w, T] = o(null), [E, D] = o(!1), O = f === "mermaid", k = f === "image" || !!e.asset, [A, j] = o(g);
1229
1229
  r(() => {
1230
- if (!k) return;
1231
- let e = setTimeout(() => M(g), 400);
1230
+ if (!O) return;
1231
+ let e = setTimeout(() => j(g), 400);
1232
1232
  return () => clearTimeout(e);
1233
- }, [g, k]);
1234
- let ee = async (r) => {
1233
+ }, [g, O]);
1234
+ let te = async (r) => {
1235
1235
  T(null), C(!0);
1236
1236
  try {
1237
- let { mediaType: o, data: c } = await fe(r);
1237
+ let { mediaType: o, data: c } = await H(r);
1238
1238
  a(await s.documentSetAsset(e.id, o, c, r.name, t, n)), i();
1239
1239
  } catch (e) {
1240
1240
  T(e instanceof Error ? e.message : String(e)), C(!1);
@@ -1247,7 +1247,7 @@ function Je({ chunk: e, scope: t, browse: n, onClose: i, onSaved: a }) {
1247
1247
  className: "modal chunk-editor",
1248
1248
  onClick: (e) => e.stopPropagation(),
1249
1249
  onSubmit: async (r) => {
1250
- r.preventDefault(), T(null), O(!1);
1250
+ r.preventDefault(), T(null), D(!1);
1251
1251
  let o = {
1252
1252
  body: g,
1253
1253
  title: c,
@@ -1266,7 +1266,7 @@ function Je({ chunk: e, scope: t, browse: n, onClose: i, onSaved: a }) {
1266
1266
  a(await s.documentUpdateChunk(e.id, e.revision, o, t, n)), i();
1267
1267
  } catch (e) {
1268
1268
  let t = e instanceof Error ? e.message : String(e);
1269
- T(t), O(/revision conflict/i.test(t)), C(!1);
1269
+ T(t), D(/revision conflict/i.test(t)), C(!1);
1270
1270
  }
1271
1271
  },
1272
1272
  children: [
@@ -1289,7 +1289,7 @@ function Je({ chunk: e, scope: t, browse: n, onClose: i, onSaved: a }) {
1289
1289
  }),
1290
1290
  w && /* @__PURE__ */ u("div", {
1291
1291
  className: "modal-err",
1292
- children: [w, D && " — reopen the chunk to load the latest, then reapply your edit."]
1292
+ children: [w, E && " — reopen the chunk to load the latest, then reapply your edit."]
1293
1293
  }),
1294
1294
  /* @__PURE__ */ u("label", {
1295
1295
  className: "path-field",
@@ -1328,7 +1328,7 @@ function Je({ chunk: e, scope: t, browse: n, onClose: i, onSaved: a }) {
1328
1328
  onChange: (e) => x(e.target.value)
1329
1329
  })]
1330
1330
  }),
1331
- A && /* @__PURE__ */ u("label", {
1331
+ k && /* @__PURE__ */ u("label", {
1332
1332
  className: "path-field",
1333
1333
  children: [/* @__PURE__ */ l("span", { children: "Replace image" }), /* @__PURE__ */ l("input", {
1334
1334
  type: "file",
@@ -1336,24 +1336,24 @@ function Je({ chunk: e, scope: t, browse: n, onClose: i, onSaved: a }) {
1336
1336
  disabled: S,
1337
1337
  onChange: (e) => {
1338
1338
  let t = e.target.files?.[0];
1339
- t && ee(t);
1339
+ t && te(t);
1340
1340
  }
1341
1341
  })]
1342
1342
  }),
1343
1343
  /* @__PURE__ */ u("label", {
1344
1344
  className: "path-field",
1345
- children: [/* @__PURE__ */ l("span", { children: k ? "Mermaid source" : A ? "Caption (optional)" : "Body (Markdown)" }), /* @__PURE__ */ l("textarea", {
1345
+ children: [/* @__PURE__ */ l("span", { children: O ? "Mermaid source" : k ? "Caption (optional)" : "Body (Markdown)" }), /* @__PURE__ */ l("textarea", {
1346
1346
  className: "modal-textarea chunk-body-input",
1347
- rows: k ? 8 : 12,
1347
+ rows: O ? 8 : 12,
1348
1348
  value: g,
1349
1349
  onChange: (e) => _(e.target.value)
1350
1350
  })]
1351
1351
  }),
1352
- k && /* @__PURE__ */ u("div", {
1352
+ O && /* @__PURE__ */ u("div", {
1353
1353
  className: "path-field",
1354
1354
  children: [/* @__PURE__ */ l("span", { children: "Preview" }), /* @__PURE__ */ l("div", {
1355
1355
  className: "chunk-mermaid-preview",
1356
- children: j.trim() ? /* @__PURE__ */ l(qe, { code: j }) : /* @__PURE__ */ l("p", {
1356
+ children: A.trim() ? /* @__PURE__ */ l(qe, { code: A }) : /* @__PURE__ */ l("p", {
1357
1357
  className: "doc-empty-body",
1358
1358
  children: "(enter Mermaid source above)"
1359
1359
  })
@@ -1376,7 +1376,7 @@ function Je({ chunk: e, scope: t, browse: n, onClose: i, onSaved: a }) {
1376
1376
  //#endregion
1377
1377
  //#region src/components/SubjectTypeModal.tsx
1378
1378
  function Ye({ chunk: e, scope: t, browse: n, onClose: i, onSaved: a }) {
1379
- let s = E(), [c, d] = o(null), [f, p] = o(e.type ?? ""), [m, h] = o(!1), [g, _] = o(null), [v, b] = o(null);
1379
+ let s = ee(), [c, d] = o(null), [f, p] = o(e.type ?? ""), [m, h] = o(!1), [g, _] = o(null), [v, b] = o(null);
1380
1380
  r(() => {
1381
1381
  let e = !1;
1382
1382
  return s.documentEntityTypes?.(t, n).then((t) => {
@@ -1557,7 +1557,7 @@ function ct(e) {
1557
1557
  //#endregion
1558
1558
  //#region src/components/Classification.tsx
1559
1559
  function lt({ documentId: e, scope: t, browse: n, rootFields: a, requestKey: s, onClose: c, onChanged: d }) {
1560
- let f = E(), [p, m] = o(null), [h, g] = o(!1), [_, v] = o(null), [y, b] = o(!1), [x, S] = o(null), [C, w] = o(null), T = i(() => f.documentAcceptClassification ? Qe(a) : void 0, [f, a]);
1560
+ let f = ee(), [p, m] = o(null), [h, g] = o(!1), [_, v] = o(null), [y, b] = o(!1), [x, S] = o(null), [C, w] = o(null), T = i(() => f.documentAcceptClassification ? Qe(a) : void 0, [f, a]);
1561
1561
  r(() => {
1562
1562
  if (s === 0 || !f.documentClassify) return;
1563
1563
  let r = !1;
@@ -1571,7 +1571,7 @@ function lt({ documentId: e, scope: t, browse: n, rootFields: a, requestKey: s,
1571
1571
  n,
1572
1572
  s
1573
1573
  ]);
1574
- let D = async () => {
1574
+ let E = async () => {
1575
1575
  if (f.documentClassify) {
1576
1576
  g(!0), v(null);
1577
1577
  try {
@@ -1582,7 +1582,7 @@ function lt({ documentId: e, scope: t, browse: n, rootFields: a, requestKey: s,
1582
1582
  g(!1);
1583
1583
  }
1584
1584
  }
1585
- }, O = async () => {
1585
+ }, D = async () => {
1586
1586
  if (f.documentAcceptClassification) {
1587
1587
  b(!0), S(null);
1588
1588
  try {
@@ -1593,9 +1593,9 @@ function lt({ documentId: e, scope: t, browse: n, rootFields: a, requestKey: s,
1593
1593
  b(!1);
1594
1594
  }
1595
1595
  }
1596
- }, k = s > 0;
1597
- if (!k && !T && !C && !x) return null;
1598
- let A = C ? st(C) : void 0;
1596
+ }, O = s > 0;
1597
+ if (!O && !T && !C && !x) return null;
1598
+ let k = C ? st(C) : void 0;
1599
1599
  return /* @__PURE__ */ u("div", {
1600
1600
  className: "doc-classify",
1601
1601
  children: [
@@ -1623,7 +1623,7 @@ function lt({ documentId: e, scope: t, browse: n, rootFields: a, requestKey: s,
1623
1623
  /* @__PURE__ */ l("button", {
1624
1624
  type: "button",
1625
1625
  disabled: y,
1626
- onClick: () => void O(),
1626
+ onClick: () => void D(),
1627
1627
  children: y ? "Accepting…" : "Accept"
1628
1628
  })
1629
1629
  ]
@@ -1639,12 +1639,12 @@ function lt({ documentId: e, scope: t, browse: n, rootFields: a, requestKey: s,
1639
1639
  children: "×"
1640
1640
  })]
1641
1641
  }),
1642
- A && /* @__PURE__ */ u("div", {
1642
+ k && /* @__PURE__ */ u("div", {
1643
1643
  className: "doc-classify-notice",
1644
1644
  role: "status",
1645
1645
  children: [
1646
- /* @__PURE__ */ l("span", { children: A.applied }),
1647
- A.notices.map((e, t) => /* @__PURE__ */ l("span", {
1646
+ /* @__PURE__ */ l("span", { children: k.applied }),
1647
+ k.notices.map((e, t) => /* @__PURE__ */ l("span", {
1648
1648
  className: "doc-classify-warn",
1649
1649
  children: e
1650
1650
  }, t)),
@@ -1657,7 +1657,7 @@ function lt({ documentId: e, scope: t, browse: n, rootFields: a, requestKey: s,
1657
1657
  })
1658
1658
  ]
1659
1659
  }),
1660
- k && /* @__PURE__ */ u("div", {
1660
+ O && /* @__PURE__ */ u("div", {
1661
1661
  className: "doc-classify-panel",
1662
1662
  children: [
1663
1663
  /* @__PURE__ */ u("div", {
@@ -1696,7 +1696,7 @@ function lt({ documentId: e, scope: t, browse: n, rootFields: a, requestKey: s,
1696
1696
  children: /* @__PURE__ */ l("button", {
1697
1697
  type: "button",
1698
1698
  disabled: h,
1699
- onClick: () => void D(),
1699
+ onClick: () => void E(),
1700
1700
  title: "Apply a unique rule match to the document; file everything else for review",
1701
1701
  children: h ? "Applying…" : "Apply"
1702
1702
  })
@@ -1820,7 +1820,7 @@ function dt(e) {
1820
1820
  return n.length === 3 && (n = n[0] + n[0] + n[1] + n[1] + n[2] + n[2]), "#" + n.toLowerCase();
1821
1821
  }
1822
1822
  function ft({ documentId: e, rootChunkId: t, docType: n, docStatus: a, chunkStatuses: s, scope: d, browse: f, onClose: p, onSaved: m }) {
1823
- let h = E(), [g, _] = o(null), [v, y] = o(!1), [b, x] = o({}), [S, C] = o(!1), [w, T] = o(null), [D, O] = o(null), k = i(() => {
1823
+ let h = ee(), [g, _] = o(null), [v, y] = o(!1), [b, x] = o({}), [S, C] = o(!1), [w, T] = o(null), [E, D] = o(null), O = i(() => {
1824
1824
  let e = new Set(Object.keys(Y));
1825
1825
  n && e.add(`doc.${n}.${a || "draft"}`);
1826
1826
  for (let t of s) t && e.add(`chunk.${t}`);
@@ -1842,7 +1842,7 @@ function ft({ documentId: e, rootChunkId: t, docType: n, docStatus: a, chunkStat
1842
1842
  ...Y,
1843
1843
  ...r
1844
1844
  });
1845
- }).catch((t) => !e && O(t instanceof Error ? t.message : String(t))), () => {
1845
+ }).catch((t) => !e && D(t instanceof Error ? t.message : String(t))), () => {
1846
1846
  e = !0;
1847
1847
  };
1848
1848
  }, [
@@ -1851,40 +1851,40 @@ function ft({ documentId: e, rootChunkId: t, docType: n, docStatus: a, chunkStat
1851
1851
  d,
1852
1852
  f
1853
1853
  ]);
1854
- let A = (e, t) => x((n) => ({
1854
+ let k = (e, t) => x((n) => ({
1855
1855
  ...n,
1856
1856
  [e]: t
1857
- })), j = (e) => ({
1857
+ })), A = (e) => ({
1858
1858
  ...e ?? {},
1859
1859
  color_enabled: v,
1860
1860
  color_scheme: b
1861
- }), M = async () => {
1861
+ }), j = async () => {
1862
1862
  if (g) {
1863
- C(!0), O(null), T(null);
1863
+ C(!0), D(null), T(null);
1864
1864
  try {
1865
- await h.documentUpdateChunk(t, g.revision, { fields: j(g.fields) }, d, f), m(), p();
1865
+ await h.documentUpdateChunk(t, g.revision, { fields: A(g.fields) }, d, f), m(), p();
1866
1866
  } catch (e) {
1867
- O(e instanceof Error ? e.message : String(e)), C(!1);
1867
+ D(e instanceof Error ? e.message : String(e)), C(!1);
1868
1868
  }
1869
1869
  }
1870
- }, ee = async () => {
1871
- if (!n) O("this document has no type to match");
1870
+ }, te = async () => {
1871
+ if (!n) D("this document has no type to match");
1872
1872
  else {
1873
- C(!0), O(null), T(null);
1873
+ C(!0), D(null), T(null);
1874
1874
  try {
1875
1875
  let { documents: t } = await h.documentsSummary({ underPath: "/" }, d, f), r = (t ?? []).filter((t) => t.type === n && t.document_id !== e && t.root_chunk_id), i = 0;
1876
1876
  for (let e of r) try {
1877
1877
  let t = await h.documentGetChunk(e.root_chunk_id, d, f);
1878
- await h.documentUpdateChunk(e.root_chunk_id, t.revision, { fields: j(t.fields) }, d, f), i++;
1878
+ await h.documentUpdateChunk(e.root_chunk_id, t.revision, { fields: A(t.fields) }, d, f), i++;
1879
1879
  } catch {}
1880
1880
  T(`Applied to ${i} other ${n} document(s).`), m();
1881
1881
  } catch (e) {
1882
- O(e instanceof Error ? e.message : String(e));
1882
+ D(e instanceof Error ? e.message : String(e));
1883
1883
  } finally {
1884
1884
  C(!1);
1885
1885
  }
1886
1886
  }
1887
- }, te = k.filter((e) => e.startsWith("doc.")), ne = k.filter((e) => e.startsWith("chunk."));
1887
+ }, ne = O.filter((e) => e.startsWith("doc.")), re = O.filter((e) => e.startsWith("chunk."));
1888
1888
  return /* @__PURE__ */ l("div", {
1889
1889
  className: "modal-overlay",
1890
1890
  onClick: p,
@@ -1904,15 +1904,15 @@ function ft({ documentId: e, rootChunkId: t, docType: n, docStatus: a, chunkStat
1904
1904
  }), /* @__PURE__ */ l("button", {
1905
1905
  type: "button",
1906
1906
  className: "primary",
1907
- onClick: () => void M(),
1907
+ onClick: () => void j(),
1908
1908
  disabled: S || !g,
1909
1909
  children: S ? "saving…" : "save"
1910
1910
  })]
1911
1911
  })]
1912
1912
  }),
1913
- D && /* @__PURE__ */ l("div", {
1913
+ E && /* @__PURE__ */ l("div", {
1914
1914
  className: "modal-err",
1915
- children: D
1915
+ children: E
1916
1916
  }),
1917
1917
  g ? /* @__PURE__ */ u(c, { children: [
1918
1918
  /* @__PURE__ */ u("label", {
@@ -1929,25 +1929,25 @@ function ft({ documentId: e, rootChunkId: t, docType: n, docStatus: a, chunkStat
1929
1929
  }),
1930
1930
  /* @__PURE__ */ u("div", {
1931
1931
  className: "scheme-group",
1932
- children: [/* @__PURE__ */ l("h4", { children: "Document (type · status)" }), te.map((e) => /* @__PURE__ */ l(pt, {
1932
+ children: [/* @__PURE__ */ l("h4", { children: "Document (type · status)" }), ne.map((e) => /* @__PURE__ */ l(pt, {
1933
1933
  label: e.slice(4),
1934
1934
  value: b[e],
1935
- onChange: (t) => A(e, t)
1935
+ onChange: (t) => k(e, t)
1936
1936
  }, e))]
1937
1937
  }),
1938
1938
  /* @__PURE__ */ u("div", {
1939
1939
  className: "scheme-group",
1940
- children: [/* @__PURE__ */ l("h4", { children: "Chunks (status)" }), ne.map((e) => /* @__PURE__ */ l(pt, {
1940
+ children: [/* @__PURE__ */ l("h4", { children: "Chunks (status)" }), re.map((e) => /* @__PURE__ */ l(pt, {
1941
1941
  label: e.slice(6),
1942
1942
  value: b[e],
1943
- onChange: (t) => A(e, t)
1943
+ onChange: (t) => k(e, t)
1944
1944
  }, e))]
1945
1945
  }),
1946
1946
  /* @__PURE__ */ u("div", {
1947
1947
  className: "scheme-editor-foot",
1948
1948
  children: [/* @__PURE__ */ u("button", {
1949
1949
  type: "button",
1950
- onClick: () => void ee(),
1950
+ onClick: () => void te(),
1951
1951
  disabled: S || !n,
1952
1952
  title: n ? `Apply this palette to every other ${n} document` : "This document has no type",
1953
1953
  children: [
@@ -2013,7 +2013,7 @@ function mt({ id: e, title: t, targetDocumentId: n, documentId: r, onSelectChunk
2013
2013
  //#endregion
2014
2014
  //#region src/components/Statement.tsx
2015
2015
  function ht({ statement: e }) {
2016
- let t = ve(e), n = G(e), r = K(e), i = xe(e), { rows: a, more: o } = Se(e);
2016
+ let t = ye(e), n = W(e), r = Se(e), i = xe(e), { rows: a, more: o } = K(e);
2017
2017
  return /* @__PURE__ */ u(c, { children: [
2018
2018
  t && /* @__PURE__ */ l("span", {
2019
2019
  className: `doc-stmt-status ${t}`,
@@ -2117,13 +2117,13 @@ function gt({ id: e, onRule: t }) {
2117
2117
  //#region src/components/ProposalReview.tsx
2118
2118
  var _t = 3;
2119
2119
  function vt({ documentId: e, proposals: t, incomplete: n, scope: r, browse: i, onChanged: s, onSelectChunk: c, onOpenDocument: d }) {
2120
- let f = E(), [p, m] = o(/* @__PURE__ */ new Set()), [h, g] = o({ kind: "idle" }), [_, v] = o(""), [y, b] = o(null), [x, S] = o(null), C = a(null), w = new Set(t.map((e) => e.id)), T = [...p].filter((e) => w.has(e)), D = h.kind !== "idle" && h.kind !== "reason", O = (e, t) => {
2120
+ let f = ee(), [p, m] = o(/* @__PURE__ */ new Set()), [h, g] = o({ kind: "idle" }), [_, v] = o(""), [y, b] = o(null), [x, S] = o(null), C = a(null), w = new Set(t.map((e) => e.id)), T = [...p].filter((e) => w.has(e)), E = h.kind !== "idle" && h.kind !== "reason", D = (e, t) => {
2121
2121
  b(null), S(null), e === "reject" ? g({
2122
2122
  kind: "reason",
2123
2123
  action: e,
2124
2124
  all: t
2125
- }) : k(e, t, "");
2126
- }, k = async (t, n, a) => {
2125
+ }) : O(e, t, "");
2126
+ }, O = async (t, n, a) => {
2127
2127
  g({
2128
2128
  kind: "counting",
2129
2129
  action: t,
@@ -2131,7 +2131,7 @@ function vt({ documentId: e, proposals: t, incomplete: n, scope: r, browse: i, o
2131
2131
  });
2132
2132
  let o;
2133
2133
  try {
2134
- o = await Ne(f, {
2134
+ o = await J(f, {
2135
2135
  documentId: e,
2136
2136
  action: t,
2137
2137
  ids: n ? void 0 : T,
@@ -2174,12 +2174,12 @@ function vt({ documentId: e, proposals: t, incomplete: n, scope: r, browse: i, o
2174
2174
  text: "Nothing to rule: no proposals match.",
2175
2175
  rulingIds: []
2176
2176
  }), o.error !== void 0 && b(o.error instanceof Error ? o.error.message : String(o.error));
2177
- }, A = (e) => {
2177
+ }, k = (e) => {
2178
2178
  e && h.kind === "confirm" && g({
2179
2179
  kind: "ruling",
2180
2180
  action: h.action
2181
2181
  }), C.current?.(e);
2182
- }, j = async () => {
2182
+ }, A = async () => {
2183
2183
  if (!x || !f.documentRevertRuling) return;
2184
2184
  let e = x, t = await ke((e) => f.documentRevertRuling(e, r, i), e.rulingIds), n = [`${t.reverted} came back to review`];
2185
2185
  t.changed > 0 && n.push(`${t.changed} changed since and left as ruled`), t.errors.length > 0 && n.push(`not undone: ${t.errors.join("; ")}`), S({
@@ -2187,10 +2187,10 @@ function vt({ documentId: e, proposals: t, incomplete: n, scope: r, browse: i, o
2187
2187
  undone: !0,
2188
2188
  text: n.join("; ") + "."
2189
2189
  }), s();
2190
- }, M = (e) => m((t) => {
2190
+ }, j = (e) => m((t) => {
2191
2191
  let n = new Set(t);
2192
2192
  return n.has(e) ? n.delete(e) : n.add(e), n;
2193
- }), ee = t.length > 0 && T.length === t.length, te = t.length === 0 && !n;
2193
+ }), te = t.length > 0 && T.length === t.length, ne = t.length === 0 && !n;
2194
2194
  return /* @__PURE__ */ u("div", {
2195
2195
  className: "doc-conn-group doc-bulk",
2196
2196
  children: [
@@ -2206,17 +2206,17 @@ function vt({ documentId: e, proposals: t, incomplete: n, scope: r, browse: i, o
2206
2206
  /* @__PURE__ */ l("input", {
2207
2207
  type: "checkbox",
2208
2208
  "aria-label": "select every proposal shown",
2209
- checked: ee,
2210
- disabled: D || t.length === 0,
2211
- onChange: () => m(ee ? /* @__PURE__ */ new Set() : new Set(w))
2209
+ checked: te,
2210
+ disabled: E || t.length === 0,
2211
+ onChange: () => m(te ? /* @__PURE__ */ new Set() : new Set(w))
2212
2212
  }),
2213
2213
  " ",
2214
2214
  "all shown"
2215
2215
  ] }),
2216
2216
  /* @__PURE__ */ u("button", {
2217
2217
  type: "button",
2218
- disabled: D || T.length === 0,
2219
- onClick: () => O("accept", !1),
2218
+ disabled: E || T.length === 0,
2219
+ onClick: () => D("accept", !1),
2220
2220
  children: [
2221
2221
  "Accept selected (",
2222
2222
  T.length,
@@ -2226,21 +2226,21 @@ function vt({ documentId: e, proposals: t, incomplete: n, scope: r, browse: i, o
2226
2226
  /* @__PURE__ */ l("button", {
2227
2227
  type: "button",
2228
2228
  className: "danger",
2229
- disabled: D || T.length === 0,
2230
- onClick: () => O("reject", !1),
2229
+ disabled: E || T.length === 0,
2230
+ onClick: () => D("reject", !1),
2231
2231
  children: "Reject selected…"
2232
2232
  }),
2233
2233
  /* @__PURE__ */ l("button", {
2234
2234
  type: "button",
2235
- disabled: D || te,
2236
- onClick: () => O("accept", !0),
2235
+ disabled: E || ne,
2236
+ onClick: () => D("accept", !0),
2237
2237
  children: "Accept all from this document"
2238
2238
  }),
2239
2239
  /* @__PURE__ */ l("button", {
2240
2240
  type: "button",
2241
2241
  className: "danger",
2242
- disabled: D || te,
2243
- onClick: () => O("reject", !0),
2242
+ disabled: E || ne,
2243
+ onClick: () => D("reject", !0),
2244
2244
  children: "Reject all…"
2245
2245
  })
2246
2246
  ]
@@ -2248,7 +2248,7 @@ function vt({ documentId: e, proposals: t, incomplete: n, scope: r, browse: i, o
2248
2248
  h.kind === "reason" && /* @__PURE__ */ u("form", {
2249
2249
  className: "doc-bulk-step",
2250
2250
  onSubmit: (e) => {
2251
- e.preventDefault(), _.trim() && k(h.action, h.all, _);
2251
+ e.preventDefault(), _.trim() && O(h.action, h.all, _);
2252
2252
  },
2253
2253
  children: [
2254
2254
  /* @__PURE__ */ l("input", {
@@ -2278,7 +2278,7 @@ function vt({ documentId: e, proposals: t, incomplete: n, scope: r, browse: i, o
2278
2278
  }),
2279
2279
  h.kind === "confirm" && /* @__PURE__ */ l(yt, {
2280
2280
  step: h,
2281
- onAnswer: A
2281
+ onAnswer: k
2282
2282
  }),
2283
2283
  h.kind === "ruling" && /* @__PURE__ */ l("p", {
2284
2284
  className: "doc-conn-empty",
@@ -2294,7 +2294,7 @@ function vt({ documentId: e, proposals: t, incomplete: n, scope: r, browse: i, o
2294
2294
  role: "status",
2295
2295
  children: [x.text, x.rulingIds.length > 0 && !x.undone && f.documentRevertRuling && /* @__PURE__ */ l("button", {
2296
2296
  type: "button",
2297
- onClick: () => void j(),
2297
+ onClick: () => void A(),
2298
2298
  children: "Undo"
2299
2299
  })]
2300
2300
  }),
@@ -2310,8 +2310,8 @@ function vt({ documentId: e, proposals: t, incomplete: n, scope: r, browse: i, o
2310
2310
  type: "checkbox",
2311
2311
  "aria-label": `select ${t.from_title ?? t.from_id} ${t.kind} ${t.to_title ?? t.to_id}`,
2312
2312
  checked: p.has(t.id),
2313
- disabled: D,
2314
- onChange: () => M(t.id)
2313
+ disabled: E,
2314
+ onChange: () => j(t.id)
2315
2315
  }),
2316
2316
  /* @__PURE__ */ l(mt, {
2317
2317
  id: t.from_id,
@@ -2398,7 +2398,7 @@ function St(e) {
2398
2398
  return /embedder|embedding|vector|semantic|not configured/i.test(e);
2399
2399
  }
2400
2400
  function Ct({ documentId: e, selectedId: t, scope: n, browse: i, onSelectChunk: a, onOpenDocument: s, refreshKey: d, review: f }) {
2401
- let p = E(), [m, h] = o(!1), [g, _] = o(!1), [v, y] = o(void 0), [b, x] = o([]), [S, C] = o([]), [w, T] = o(null), [D, O] = o([]), [k, A] = o(!1);
2401
+ let p = ee(), [m, h] = o(!1), [g, _] = o(!1), [v, y] = o(void 0), [b, x] = o([]), [S, C] = o([]), [w, T] = o(null), [E, D] = o([]), [O, k] = o(!1);
2402
2402
  r(() => {
2403
2403
  if (!m || !t) return;
2404
2404
  let e = t, r = !1;
@@ -2414,7 +2414,7 @@ function Ct({ documentId: e, selectedId: t, scope: n, browse: i, onSelectChunk:
2414
2414
  let e = n.reason instanceof Error ? n.reason.message : String(n.reason);
2415
2415
  T(St(e) ? "semantic search not configured" : e);
2416
2416
  }
2417
- i.status === "fulfilled" ? (O(i.value.unlinked_mentions ?? []), A(!!i.value.truncated)) : (O([]), A(!1)), y(e), _(!1);
2417
+ i.status === "fulfilled" ? (D(i.value.unlinked_mentions ?? []), k(!!i.value.truncated)) : (D([]), k(!1)), y(e), _(!1);
2418
2418
  }
2419
2419
  }), () => {
2420
2420
  r = !0;
@@ -2427,14 +2427,14 @@ function Ct({ documentId: e, selectedId: t, scope: n, browse: i, onSelectChunk:
2427
2427
  i,
2428
2428
  d
2429
2429
  ]);
2430
- let j = (t, n, r) => /* @__PURE__ */ l(mt, {
2430
+ let A = (t, n, r) => /* @__PURE__ */ l(mt, {
2431
2431
  id: t,
2432
2432
  title: n,
2433
2433
  targetDocumentId: r,
2434
2434
  documentId: e,
2435
2435
  onSelectChunk: a,
2436
2436
  onOpenDocument: s
2437
- }), M = !!(m && t && !g && v === t);
2437
+ }), j = !!(m && t && !g && v === t);
2438
2438
  return /* @__PURE__ */ u("div", {
2439
2439
  className: "doc-conn",
2440
2440
  children: [/* @__PURE__ */ u("button", {
@@ -2453,7 +2453,7 @@ function Ct({ documentId: e, selectedId: t, scope: n, browse: i, onSelectChunk:
2453
2453
  onChanged: f.onChanged,
2454
2454
  onSelectChunk: a,
2455
2455
  onOpenDocument: s
2456
- }), t ? M ? /* @__PURE__ */ u(c, { children: [
2456
+ }), t ? j ? /* @__PURE__ */ u(c, { children: [
2457
2457
  /* @__PURE__ */ u("div", {
2458
2458
  className: "doc-conn-group",
2459
2459
  children: [/* @__PURE__ */ l("h5", { children: "Backlinks" }), b.length === 0 ? /* @__PURE__ */ l("p", {
@@ -2464,7 +2464,7 @@ function Ct({ documentId: e, selectedId: t, scope: n, browse: i, onSelectChunk:
2464
2464
  children: b.map((e, t) => /* @__PURE__ */ u("li", {
2465
2465
  className: "doc-conn-row",
2466
2466
  children: [
2467
- j(e.from_id, e.from_title, e.from_document_id),
2467
+ A(e.from_id, e.from_title, e.from_document_id),
2468
2468
  /* @__PURE__ */ l("span", {
2469
2469
  className: "doc-ref-kind",
2470
2470
  children: e.kind
@@ -2491,7 +2491,7 @@ function Ct({ documentId: e, selectedId: t, scope: n, browse: i, onSelectChunk:
2491
2491
  className: "doc-conn-list",
2492
2492
  children: S.map((e, t) => /* @__PURE__ */ u("li", {
2493
2493
  className: "doc-conn-row",
2494
- children: [j(e.chunk_id, e.title, e.document_id), /* @__PURE__ */ l("span", {
2494
+ children: [A(e.chunk_id, e.title, e.document_id), /* @__PURE__ */ l("span", {
2495
2495
  className: "doc-conn-score",
2496
2496
  title: "similarity score",
2497
2497
  children: e.score.toFixed(2)
@@ -2501,15 +2501,15 @@ function Ct({ documentId: e, selectedId: t, scope: n, browse: i, onSelectChunk:
2501
2501
  }),
2502
2502
  /* @__PURE__ */ u("div", {
2503
2503
  className: "doc-conn-group",
2504
- children: [/* @__PURE__ */ l("h5", { children: "Unlinked mentions" }), D.length === 0 ? /* @__PURE__ */ l("p", {
2504
+ children: [/* @__PURE__ */ l("h5", { children: "Unlinked mentions" }), E.length === 0 ? /* @__PURE__ */ l("p", {
2505
2505
  className: "doc-conn-empty",
2506
2506
  children: "none"
2507
2507
  }) : /* @__PURE__ */ u("ul", {
2508
2508
  className: "doc-conn-list",
2509
- children: [D.map((e, t) => /* @__PURE__ */ l("li", {
2509
+ children: [E.map((e, t) => /* @__PURE__ */ l("li", {
2510
2510
  className: "doc-conn-row",
2511
- children: j(e.chunk_id, e.title, e.document_id)
2512
- }, `${e.chunk_id}-${t}`)), k && /* @__PURE__ */ l("li", {
2511
+ children: A(e.chunk_id, e.title, e.document_id)
2512
+ }, `${e.chunk_id}-${t}`)), O && /* @__PURE__ */ l("li", {
2513
2513
  className: "doc-conn-more",
2514
2514
  "aria-hidden": !0,
2515
2515
  children: "(more…)"
@@ -2612,7 +2612,7 @@ function Et({ edge: e, selectedId: t, documentId: n, onSelectChunk: r, onOpenDoc
2612
2612
  onOpenDocument: i
2613
2613
  }),
2614
2614
  /* @__PURE__ */ l(ht, { statement: e }),
2615
- a && ye(e) && /* @__PURE__ */ l(gt, {
2615
+ a && G(e) && /* @__PURE__ */ l(gt, {
2616
2616
  id: e.id,
2617
2617
  onRule: a
2618
2618
  })
@@ -2678,7 +2678,7 @@ function Mt(e) {
2678
2678
  return !Number.isFinite(t) || t <= 0 ? String(e ?? "") : new Date(t).toLocaleString();
2679
2679
  }
2680
2680
  function Nt({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
2681
- let s = E(), [d, f] = o([]), [p, m] = o(!0), [h, g] = o(null), [_, v] = o("none"), [y, b] = o(null), [x, S] = o(""), [C, w] = o(!1), [T, D] = o(null), [O, k] = o(null), [A, j] = o("");
2681
+ let s = ee(), [d, f] = o([]), [p, m] = o(!0), [h, g] = o(null), [_, v] = o("none"), [y, b] = o(null), [x, S] = o(""), [C, w] = o(!1), [T, E] = o(null), [D, O] = o(null), [k, A] = o("");
2682
2682
  r(() => {
2683
2683
  let t = !1;
2684
2684
  return m(!0), g(null), s.documentHistory(e, n, i).then((e) => {
@@ -2686,7 +2686,7 @@ function Nt({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
2686
2686
  let n = e.revisions ?? [];
2687
2687
  if (f(n), n.length >= 2) {
2688
2688
  let e = n.map((e) => e.revision);
2689
- D(Math.min(...e)), k(Math.max(...e));
2689
+ E(Math.min(...e)), O(Math.max(...e));
2690
2690
  }
2691
2691
  }).catch((e) => !t && g(e instanceof Error ? e.message : String(e))).finally(() => !t && m(!1)), () => {
2692
2692
  t = !0;
@@ -2697,7 +2697,7 @@ function Nt({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
2697
2697
  n,
2698
2698
  i
2699
2699
  ]);
2700
- let M = async (t) => {
2700
+ let j = async (t) => {
2701
2701
  g(null), w(!0), b(t), v("version");
2702
2702
  try {
2703
2703
  let r = await s.documentGetVersion(e, t, n, i);
@@ -2707,12 +2707,12 @@ function Nt({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
2707
2707
  } finally {
2708
2708
  w(!1);
2709
2709
  }
2710
- }, ee = async () => {
2711
- if (T !== null && O !== null) {
2710
+ }, te = async () => {
2711
+ if (T !== null && D !== null) {
2712
2712
  g(null), w(!0), v("diff");
2713
2713
  try {
2714
- let t = await s.documentDiff(e, T, O, n, i);
2715
- j(t.diff ?? "");
2714
+ let t = await s.documentDiff(e, T, D, n, i);
2715
+ A(t.diff ?? "");
2716
2716
  } catch (e) {
2717
2717
  g(e instanceof Error ? e.message : String(e));
2718
2718
  } finally {
@@ -2754,7 +2754,7 @@ function Nt({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
2754
2754
  children: d.map((e) => /* @__PURE__ */ u("button", {
2755
2755
  type: "button",
2756
2756
  className: "doc-hist-rev" + (_ === "version" && y === e.revision ? " active" : ""),
2757
- onClick: () => void M(e.revision),
2757
+ onClick: () => void j(e.revision),
2758
2758
  children: [
2759
2759
  /* @__PURE__ */ u("span", {
2760
2760
  className: "doc-hist-rev-num",
@@ -2777,7 +2777,7 @@ function Nt({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
2777
2777
  /* @__PURE__ */ l("span", { children: "Compare" }),
2778
2778
  /* @__PURE__ */ l("select", {
2779
2779
  value: T ?? "",
2780
- onChange: (e) => D(e.target.value === "" ? null : Number(e.target.value)),
2780
+ onChange: (e) => E(e.target.value === "" ? null : Number(e.target.value)),
2781
2781
  "aria-label": "diff from revision",
2782
2782
  children: d.map((e) => /* @__PURE__ */ u("option", {
2783
2783
  value: e.revision,
@@ -2789,8 +2789,8 @@ function Nt({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
2789
2789
  children: "→"
2790
2790
  }),
2791
2791
  /* @__PURE__ */ l("select", {
2792
- value: O ?? "",
2793
- onChange: (e) => k(e.target.value === "" ? null : Number(e.target.value)),
2792
+ value: D ?? "",
2793
+ onChange: (e) => O(e.target.value === "" ? null : Number(e.target.value)),
2794
2794
  "aria-label": "diff to revision",
2795
2795
  children: d.map((e) => /* @__PURE__ */ u("option", {
2796
2796
  value: e.revision,
@@ -2799,8 +2799,8 @@ function Nt({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
2799
2799
  }),
2800
2800
  /* @__PURE__ */ l("button", {
2801
2801
  type: "button",
2802
- onClick: () => void ee(),
2803
- disabled: C || T === null || O === null,
2802
+ onClick: () => void te(),
2803
+ disabled: C || T === null || D === null,
2804
2804
  children: "diff"
2805
2805
  })
2806
2806
  ]
@@ -2810,7 +2810,7 @@ function Nt({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
2810
2810
  children: C ? /* @__PURE__ */ l("p", {
2811
2811
  className: "doc-empty-body",
2812
2812
  children: "loading…"
2813
- }) : _ === "diff" ? /* @__PURE__ */ l(Pt, { text: A }) : _ === "version" ? /* @__PURE__ */ l("pre", {
2813
+ }) : _ === "diff" ? /* @__PURE__ */ l(Pt, { text: k }) : _ === "version" ? /* @__PURE__ */ l("pre", {
2814
2814
  className: "md-pre doc-hist-version",
2815
2815
  children: /* @__PURE__ */ l("code", { children: x || "(empty)" })
2816
2816
  }) : /* @__PURE__ */ l("p", {
@@ -2883,65 +2883,65 @@ function Lt(e) {
2883
2883
  return typeof t.alt == "string" && t.alt.trim() !== "" ? t.alt : e.title || "image";
2884
2884
  }
2885
2885
  function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, renderAssistant: p, initialChunkId: m, onOpenDocument: h, onTitle: g, onChunkSelect: v, focusChunk: y }) {
2886
- let b = E(), x = i(() => d && (d.scopeId || d.tenant) ? {
2886
+ let b = ee(), x = i(() => d && (d.scopeId || d.tenant) ? {
2887
2887
  scopeId: d.scopeId,
2888
2888
  tenant: d.tenant
2889
- } : void 0, [d?.scopeId, d?.tenant]), [S, C] = o([]), [w, T] = o(void 0), [D, O] = o(null), [k, A] = o("chunks"), [j, M] = o(null), [ee, te] = o(null), [ne, N] = o(null), re = a(null), [ie, P] = o(null), [F, I] = o(null), [ae, oe] = o(!1), [se, L] = o(!1), [ce, R] = o(null), [le, z] = o(!1), [ue, V] = o(void 0), [H, U] = o(null), [W, ge] = o(0), [_e, ve] = o(!1), [G, ye] = o(null), [be, xe] = o(!1), [K, Se] = o([]), [Ce, we] = o(!1), [Te, Ee] = o(0), [De, Oe] = o(0), [ke, Ae] = o(void 0), q = t(() => ge((e) => e + 1), []), Ne = a(m);
2890
- Ne.current = m;
2889
+ } : void 0, [d?.scopeId, d?.tenant]), [S, C] = o([]), [w, T] = o(void 0), [E, D] = o(null), [O, k] = o("chunks"), [A, j] = o(null), [te, ne] = o(null), [re, ie] = o(null), M = a(null), [ae, oe] = o(null), [N, P] = o(null), [se, ce] = o(!1), [le, F] = o(!1), [ue, I] = o(null), [de, L] = o(!1), [fe, z] = o(void 0), [B, V] = o(null), [he, _e] = o(0), [ve, ye] = o(!1), [W, G] = o(null), [be, xe] = o(!1), [Se, K] = o([]), [Ce, we] = o(!1), [Te, Ee] = o(0), [De, Oe] = o(0), [ke, Ae] = o(void 0), q = t(() => _e((e) => e + 1), []), J = a(m);
2890
+ J.current = m;
2891
2891
  let Pe = a(g);
2892
2892
  Pe.current = g;
2893
- let Y = i(() => Be(S), [S]), Fe = i(() => S.find((e) => !e.parent_id)?.title || s || "document", [S, s]), X = i(() => !!D && !D.parent_id, [D]), Z = i(() => he(S, D?.id), [S, D]), Q = i(() => G?.root_chunk_id ?? S.find((e) => !e.parent_id)?.id, [G, S]), Ve = a(v);
2893
+ let Y = i(() => Be(S), [S]), Fe = i(() => S.find((e) => !e.parent_id)?.title || s || "document", [S, s]), X = i(() => !!E && !E.parent_id, [E]), Z = i(() => ge(S, E?.id), [S, E]), Q = i(() => W?.root_chunk_id ?? S.find((e) => !e.parent_id)?.id, [W, S]), Ve = a(v);
2894
2894
  Ve.current = v, r(() => {
2895
2895
  w && Ve.current?.(w === Q ? void 0 : w);
2896
2896
  }, [w, Q]);
2897
- let Ue = i(() => [...new Set(S.map((e) => e.status).filter((e) => !!e))], [S]), We = !!G?.color_enabled, Ge = i(() => {
2897
+ let Ue = i(() => [...new Set(S.map((e) => e.status).filter((e) => !!e))], [S]), We = !!W?.color_enabled, Ge = i(() => {
2898
2898
  let e = /* @__PURE__ */ new Set();
2899
- for (let t of K) e.add(t.from_id), e.add(t.to_id);
2899
+ for (let t of Se) e.add(t.from_id), e.add(t.to_id);
2900
2900
  return e;
2901
- }, [K]), Ke = i(() => We ? Re(Le(G?.type, G?.status, Ie(G?.color_scheme))) : void 0, [
2901
+ }, [Se]), Ke = i(() => We ? Re(Le(W?.type, W?.status, Ie(W?.color_scheme))) : void 0, [
2902
2902
  We,
2903
- G?.type,
2904
- G?.status,
2905
- G?.color_scheme
2903
+ W?.type,
2904
+ W?.status,
2905
+ W?.color_scheme
2906
2906
  ]);
2907
2907
  r(() => {
2908
2908
  let t = !1;
2909
- return z(!0), R(null), U(null), b.documentQueryChunks(e, n, x).then((r) => {
2909
+ return L(!0), I(null), V(null), b.documentQueryChunks(e, n, x).then((r) => {
2910
2910
  if (t) return;
2911
2911
  let i = r.chunks ?? [];
2912
- C(i), V(`${n}:${e}`), T((e) => e ?? B(i, Ne.current));
2912
+ C(i), z(`${n}:${e}`), T((e) => e ?? R(i, J.current));
2913
2913
  }).catch((e) => {
2914
- t || (C([]), U(e instanceof Error ? e.message : String(e)));
2915
- }).finally(() => !t && z(!1)), () => {
2914
+ t || (C([]), V(e instanceof Error ? e.message : String(e)));
2915
+ }).finally(() => !t && L(!1)), () => {
2916
2916
  t = !0;
2917
2917
  };
2918
2918
  }, [
2919
2919
  b,
2920
2920
  e,
2921
2921
  n,
2922
- W,
2922
+ he,
2923
2923
  x
2924
2924
  ]);
2925
- let Xe = !le && (H !== null || ue === `${n}:${e}` && S.length === 0), Ze = i(() => S.find((t) => !t.parent_id && t.document_id === e)?.title, [S, e]);
2925
+ let Xe = !de && (B !== null || fe === `${n}:${e}` && S.length === 0), Ze = i(() => S.find((t) => !t.parent_id && t.document_id === e)?.title, [S, e]);
2926
2926
  r(() => {
2927
2927
  Ze && Pe.current?.(e, Ze);
2928
2928
  }, [e, Ze]), r(() => {
2929
2929
  let t = !1;
2930
- return b.documentGet(e, n, x).then((e) => !t && ye(e)).catch(() => !t && ye(null)), () => {
2930
+ return b.documentGet(e, n, x).then((e) => !t && G(e)).catch(() => !t && G(null)), () => {
2931
2931
  t = !0;
2932
2932
  };
2933
2933
  }, [
2934
2934
  b,
2935
2935
  e,
2936
2936
  n,
2937
- W,
2937
+ he,
2938
2938
  x
2939
2939
  ]), r(() => {
2940
2940
  let t = !1;
2941
- return me(b, e, n, x).then((e) => {
2942
- t || (Se(e.edges), we(e.incomplete));
2941
+ return U(b, e, n, x).then((e) => {
2942
+ t || (K(e.edges), we(e.incomplete));
2943
2943
  }).catch(() => {
2944
- t || (Se([]), we(!1));
2944
+ t || (K([]), we(!1));
2945
2945
  }), () => {
2946
2946
  t = !0;
2947
2947
  };
@@ -2949,7 +2949,7 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
2949
2949
  b,
2950
2950
  e,
2951
2951
  n,
2952
- W,
2952
+ he,
2953
2953
  x,
2954
2954
  Te
2955
2955
  ]), r(() => {
@@ -2966,7 +2966,7 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
2966
2966
  e,
2967
2967
  Q,
2968
2968
  n,
2969
- W,
2969
+ he,
2970
2970
  x
2971
2971
  ]);
2972
2972
  let Qe = i(() => {
@@ -2977,7 +2977,7 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
2977
2977
  b,
2978
2978
  n,
2979
2979
  x
2980
- ]), $e = i(() => je(b, n), [b, n]), et = i(() => Me(K, e), [K, e]), tt = t(() => Ee((e) => e + 1), []), nt = i(() => J($e, et, Ce, tt), [
2980
+ ]), $e = i(() => je(b, n), [b, n]), et = i(() => Me(Se, e), [Se, e]), tt = t(() => Ee((e) => e + 1), []), nt = i(() => Ne($e, et, Ce, tt), [
2981
2981
  $e,
2982
2982
  et,
2983
2983
  Ce,
@@ -2990,45 +2990,45 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
2990
2990
  let e = it.current?.chunkId ?? at.current;
2991
2991
  e && T(e);
2992
2992
  }, [rt]), r(() => {
2993
- T(void 0), O(null), M(null), A("chunks"), ye(null), Se([]), we(!1), Oe(0), Ae(void 0);
2993
+ T(void 0), D(null), j(null), k("chunks"), G(null), K([]), we(!1), Oe(0), Ae(void 0);
2994
2994
  }, [e, n]), r(() => {
2995
2995
  if (!w) {
2996
- O(null);
2996
+ D(null);
2997
2997
  return;
2998
2998
  }
2999
2999
  let e = !1;
3000
- return b.documentGetChunk(w, n, x).then((t) => !e && O(t)).catch((t) => !e && R(t instanceof Error ? t.message : String(t))), () => {
3000
+ return b.documentGetChunk(w, n, x).then((t) => !e && D(t)).catch((t) => !e && I(t instanceof Error ? t.message : String(t))), () => {
3001
3001
  e = !0;
3002
3002
  };
3003
3003
  }, [
3004
3004
  b,
3005
3005
  w,
3006
3006
  n,
3007
- W,
3007
+ he,
3008
3008
  x
3009
3009
  ]), r(() => {
3010
- let e = D?.type === "image" || !!D?.asset;
3011
- if (!D || !e || !b.documentAssetObjectUrl) {
3012
- te(null), N(null);
3010
+ let e = E?.type === "image" || !!E?.asset;
3011
+ if (!E || !e || !b.documentAssetObjectUrl) {
3012
+ ne(null), ie(null);
3013
3013
  return;
3014
3014
  }
3015
3015
  let t = !1, r = null;
3016
- return N(null), b.documentAssetObjectUrl(D.id, n, x).then((e) => {
3017
- t ? URL.revokeObjectURL(e) : (r = e, te(e));
3018
- }).catch((e) => !t && N(e instanceof Error ? e.message : String(e))), () => {
3016
+ return ie(null), b.documentAssetObjectUrl(E.id, n, x).then((e) => {
3017
+ t ? URL.revokeObjectURL(e) : (r = e, ne(e));
3018
+ }).catch((e) => !t && ie(e instanceof Error ? e.message : String(e))), () => {
3019
3019
  t = !0, r && URL.revokeObjectURL(r);
3020
3020
  };
3021
3021
  }, [
3022
3022
  b,
3023
- D,
3023
+ E,
3024
3024
  n,
3025
3025
  x
3026
3026
  ]), r(() => {
3027
- if (k !== "markdown" || !w) {
3028
- M(null);
3027
+ if (O !== "markdown" || !w) {
3028
+ j(null);
3029
3029
  return;
3030
3030
  }
3031
- let e = $(Y, w);
3031
+ let e = He(Y, w);
3032
3032
  if (!e) return;
3033
3033
  let t = !1, r = [], i = (e, t) => {
3034
3034
  r.push({
@@ -3047,17 +3047,17 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3047
3047
  }
3048
3048
  return a + (i.body ? "\n\n" + i.body : "") + "\n";
3049
3049
  }).join("\n");
3050
- M(n);
3051
- }).catch((e) => !t && R(e instanceof Error ? e.message : String(e))), () => {
3050
+ j(n);
3051
+ }).catch((e) => !t && I(e instanceof Error ? e.message : String(e))), () => {
3052
3052
  t = !0;
3053
3053
  };
3054
3054
  }, [
3055
3055
  b,
3056
- k,
3056
+ O,
3057
3057
  w,
3058
3058
  Y,
3059
3059
  n,
3060
- W,
3060
+ he,
3061
3061
  x
3062
3062
  ]);
3063
3063
  let ot = t((e) => T(e.row.id), []), st = t((t, n, r) => h?.({
@@ -3078,7 +3078,7 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3078
3078
  let t = await b.documentExportMd(e, n, !0, x), r = new Blob([t.markdown], { type: "text/markdown" }), i = URL.createObjectURL(r), a = document.createElement("a");
3079
3079
  a.href = i, a.download = (t.title || "document").replace(/[^\w.-]+/g, "_") + ".md", a.click(), URL.revokeObjectURL(i);
3080
3080
  } catch (e) {
3081
- R(e instanceof Error ? e.message : String(e));
3081
+ I(e instanceof Error ? e.message : String(e));
3082
3082
  }
3083
3083
  }, [
3084
3084
  b,
@@ -3090,7 +3090,7 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3090
3090
  let t = await b.documentExportCanvas(e, n, x), r = new Blob([JSON.stringify(t.canvas, null, 2)], { type: "application/json" }), i = URL.createObjectURL(r), a = document.createElement("a");
3091
3091
  a.href = i, a.download = (Fe || "document").replace(/[^\w.-]+/g, "_") + ".canvas", a.click(), URL.revokeObjectURL(i);
3092
3092
  } catch (e) {
3093
- R(e instanceof Error ? e.message : String(e));
3093
+ I(e instanceof Error ? e.message : String(e));
3094
3094
  }
3095
3095
  }, [
3096
3096
  b,
@@ -3102,15 +3102,15 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3102
3102
  if (!b.documentCreateChunk || !b.documentSetAsset) return;
3103
3103
  let r = w || Q;
3104
3104
  if (r) {
3105
- R(null);
3105
+ I(null);
3106
3106
  try {
3107
- let { mediaType: i, data: a } = await fe(t), o = await b.documentCreateChunk(e, r, {
3107
+ let { mediaType: i, data: a } = await H(t), o = await b.documentCreateChunk(e, r, {
3108
3108
  title: t.name || "image",
3109
3109
  type: "image"
3110
3110
  }, n, x);
3111
3111
  await b.documentSetAsset(o.id, i, a, t.name, n, x), q(), T(o.id);
3112
3112
  } catch (e) {
3113
- R(e instanceof Error ? e.message : String(e));
3113
+ I(e instanceof Error ? e.message : String(e));
3114
3114
  }
3115
3115
  }
3116
3116
  }, [
@@ -3125,16 +3125,16 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3125
3125
  if (!b.documentCreateChunk) return;
3126
3126
  let t = w || Q;
3127
3127
  if (t) {
3128
- R(null);
3128
+ I(null);
3129
3129
  try {
3130
3130
  let r = await b.documentCreateChunk(e, t, {
3131
3131
  title: "Diagram",
3132
3132
  type: "mermaid",
3133
3133
  body: "graph TD\n A[Start] --> B[End]"
3134
3134
  }, n, x);
3135
- q(), T(r.id), P(r);
3135
+ q(), T(r.id), oe(r);
3136
3136
  } catch (e) {
3137
- R(e instanceof Error ? e.message : String(e));
3137
+ I(e instanceof Error ? e.message : String(e));
3138
3138
  }
3139
3139
  }
3140
3140
  }, [
@@ -3149,15 +3149,15 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3149
3149
  if (!b.documentCreateChunk) return;
3150
3150
  let t = w && !X ? w : void 0, r = w || Q;
3151
3151
  if (r) {
3152
- R(null);
3152
+ I(null);
3153
3153
  try {
3154
3154
  let i = await b.documentCreateChunk(e, t ? "" : r, {
3155
3155
  title: "Text",
3156
3156
  body: ""
3157
3157
  }, n, x, t);
3158
- q(), T(i.id), P(i);
3158
+ q(), T(i.id), oe(i);
3159
3159
  } catch (e) {
3160
- R(e instanceof Error ? e.message : String(e));
3160
+ I(e instanceof Error ? e.message : String(e));
3161
3161
  }
3162
3162
  }
3163
3163
  }, [
@@ -3171,15 +3171,15 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3171
3171
  q
3172
3172
  ]), gt = t(async () => {
3173
3173
  if (b.documentCreateChunk && w) {
3174
- R(null);
3174
+ I(null);
3175
3175
  try {
3176
3176
  let t = await b.documentCreateChunk(e, w, {
3177
3177
  title: "Text",
3178
3178
  body: ""
3179
3179
  }, n, x);
3180
- q(), T(t.id), P(t);
3180
+ q(), T(t.id), oe(t);
3181
3181
  } catch (e) {
3182
- R(e instanceof Error ? e.message : String(e));
3182
+ I(e instanceof Error ? e.message : String(e));
3183
3183
  }
3184
3184
  }
3185
3185
  }, [
@@ -3190,26 +3190,26 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3190
3190
  w,
3191
3191
  q
3192
3192
  ]), _t = i(() => {
3193
- if (!D || X) return {
3193
+ if (!E || X) return {
3194
3194
  canUp: !1,
3195
3195
  canDown: !1
3196
3196
  };
3197
- let e = D.parent_id ?? "", t = S.filter((t) => (t.parent_id ?? "") === e).sort((e, t) => e.position - t.position || e.id.localeCompare(t.id)), n = t.findIndex((e) => e.id === D.id);
3197
+ let e = E.parent_id ?? "", t = S.filter((t) => (t.parent_id ?? "") === e).sort((e, t) => e.position - t.position || e.id.localeCompare(t.id)), n = t.findIndex((e) => e.id === E.id);
3198
3198
  return {
3199
3199
  canUp: n > 0,
3200
3200
  canDown: n >= 0 && n < t.length - 1
3201
3201
  };
3202
3202
  }, [
3203
3203
  S,
3204
- D,
3204
+ E,
3205
3205
  X
3206
3206
  ]), vt = t(async (e) => {
3207
3207
  if (b.documentReorderChunk && w) {
3208
- R(null);
3208
+ I(null);
3209
3209
  try {
3210
3210
  await b.documentReorderChunk(w, e, n, x), q();
3211
3211
  } catch (e) {
3212
- R(e instanceof Error ? e.message : String(e));
3212
+ I(e instanceof Error ? e.message : String(e));
3213
3213
  }
3214
3214
  }
3215
3215
  }, [
@@ -3219,17 +3219,17 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3219
3219
  x,
3220
3220
  q
3221
3221
  ]), yt = t(async () => {
3222
- if (!b.documentDeleteChunk || !D) return;
3223
- R(null);
3224
- let e = D.parent_id;
3222
+ if (!b.documentDeleteChunk || !E) return;
3223
+ I(null);
3224
+ let e = E.parent_id;
3225
3225
  try {
3226
- await b.documentDeleteChunk(D.id, n, x), L(!1), T(e || Q), q();
3226
+ await b.documentDeleteChunk(E.id, n, x), F(!1), T(e || Q), q();
3227
3227
  } catch (e) {
3228
- R(e instanceof Error ? e.message : String(e)), L(!1);
3228
+ I(e instanceof Error ? e.message : String(e)), F(!1);
3229
3229
  }
3230
3230
  }, [
3231
3231
  b,
3232
- D,
3232
+ E,
3233
3233
  n,
3234
3234
  x,
3235
3235
  Q,
@@ -3238,23 +3238,23 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3238
3238
  return r(() => {
3239
3239
  if (!dt) return;
3240
3240
  let e = (e) => {
3241
- if (ie || be) return;
3241
+ if (ae || be) return;
3242
3242
  let t = document.activeElement, n = t?.tagName;
3243
3243
  if (n === "INPUT" || n === "TEXTAREA" || t?.isContentEditable) return;
3244
- let r = pe(e.clipboardData?.items);
3244
+ let r = me(e.clipboardData?.items);
3245
3245
  r && (e.preventDefault(), pt(r));
3246
3246
  };
3247
3247
  return window.addEventListener("paste", e), () => window.removeEventListener("paste", e);
3248
3248
  }, [
3249
3249
  dt,
3250
- ie,
3250
+ ae,
3251
3251
  be,
3252
3252
  pt
3253
3253
  ]), /* @__PURE__ */ u("div", {
3254
3254
  className: "doc-viewer",
3255
3255
  children: [
3256
3256
  /* @__PURE__ */ l("input", {
3257
- ref: re,
3257
+ ref: M,
3258
3258
  type: "file",
3259
3259
  accept: "image/png,image/jpeg,image/gif,image/webp",
3260
3260
  style: { display: "none" },
@@ -3295,7 +3295,7 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3295
3295
  }),
3296
3296
  /* @__PURE__ */ l("button", {
3297
3297
  type: "button",
3298
- onClick: () => re.current?.click(),
3298
+ onClick: () => M.current?.click(),
3299
3299
  title: "Add an image chunk (upload — or paste a screenshot into the view)",
3300
3300
  children: "+ image"
3301
3301
  }),
@@ -3335,8 +3335,8 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3335
3335
  }),
3336
3336
  p && /* @__PURE__ */ l("button", {
3337
3337
  type: "button",
3338
- className: _e ? "active" : "",
3339
- onClick: () => ve((e) => !e),
3338
+ className: ve ? "active" : "",
3339
+ onClick: () => ye((e) => !e),
3340
3340
  title: "Document Assistant — instruct an agent to restructure/import/link chunks",
3341
3341
  children: "assistant"
3342
3342
  }),
@@ -3350,9 +3350,9 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3350
3350
  })
3351
3351
  ]
3352
3352
  }),
3353
- ce && /* @__PURE__ */ l("div", {
3353
+ ue && /* @__PURE__ */ l("div", {
3354
3354
  className: "paths-err",
3355
- children: ce
3355
+ children: ue
3356
3356
  }),
3357
3357
  !Xe && /* @__PURE__ */ l(lt, {
3358
3358
  documentId: e,
@@ -3366,8 +3366,8 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3366
3366
  Xe ? /* @__PURE__ */ l(jt, {
3367
3367
  documentId: e,
3368
3368
  scope: n,
3369
- detail: H ?? void 0
3370
- }) : /* @__PURE__ */ u(de, {
3369
+ detail: B ?? void 0
3370
+ }) : /* @__PURE__ */ u(pe, {
3371
3371
  className: "doc-split",
3372
3372
  defaultLeftWidth: 320,
3373
3373
  minLeftWidth: 160,
@@ -3375,20 +3375,20 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3375
3375
  storageKey: "loomcycle.explorer.split.doc",
3376
3376
  children: [/* @__PURE__ */ l("div", {
3377
3377
  className: "doc-chunktree",
3378
- children: le && S.length === 0 ? /* @__PURE__ */ l("div", {
3378
+ children: de && S.length === 0 ? /* @__PURE__ */ l("div", {
3379
3379
  className: "empty",
3380
3380
  children: /* @__PURE__ */ l("p", { children: "Loading…" })
3381
- }) : /* @__PURE__ */ l(He, {
3381
+ }) : /* @__PURE__ */ l($, {
3382
3382
  tree: Y,
3383
3383
  selectedId: w,
3384
3384
  onSelect: ot,
3385
3385
  colorEnabled: We,
3386
- scheme: G?.color_scheme,
3386
+ scheme: W?.color_scheme,
3387
3387
  linkedIds: Ge
3388
3388
  })
3389
3389
  }), /* @__PURE__ */ l("div", {
3390
3390
  className: "doc-content",
3391
- children: D ? /* @__PURE__ */ u(c, { children: [
3391
+ children: E ? /* @__PURE__ */ u(c, { children: [
3392
3392
  /* @__PURE__ */ u("div", {
3393
3393
  className: "doc-content-head",
3394
3394
  children: [
@@ -3417,34 +3417,34 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3417
3417
  children: /* @__PURE__ */ l("span", {
3418
3418
  className: "doc-trail-current",
3419
3419
  "aria-current": "location",
3420
- title: D.title || "(untitled)",
3421
- children: D.title || "(untitled)"
3420
+ title: E.title || "(untitled)",
3421
+ children: E.title || "(untitled)"
3422
3422
  })
3423
3423
  })]
3424
3424
  })]
3425
3425
  }),
3426
- /* @__PURE__ */ l("h3", { children: D.title || "(untitled)" }),
3426
+ /* @__PURE__ */ l("h3", { children: E.title || "(untitled)" }),
3427
3427
  /* @__PURE__ */ u("div", {
3428
3428
  className: "doc-content-meta",
3429
3429
  children: [
3430
- D.type && /* @__PURE__ */ l("span", {
3430
+ E.type && /* @__PURE__ */ l("span", {
3431
3431
  className: "chunk-badge",
3432
- children: D.type
3432
+ children: E.type
3433
3433
  }),
3434
- D.status && /* @__PURE__ */ l("span", {
3434
+ E.status && /* @__PURE__ */ l("span", {
3435
3435
  className: "chunk-badge chunk-status",
3436
- children: D.status
3436
+ children: E.status
3437
3437
  }),
3438
3438
  /* @__PURE__ */ u("span", {
3439
3439
  className: "chunk-rev",
3440
- children: ["rev ", D.revision]
3440
+ children: ["rev ", E.revision]
3441
3441
  }),
3442
- D.tags?.map((e) => /* @__PURE__ */ l("span", {
3442
+ E.tags?.map((e) => /* @__PURE__ */ l("span", {
3443
3443
  className: "chunk-tag",
3444
3444
  children: e
3445
3445
  }, e)),
3446
3446
  /* @__PURE__ */ l(ze, {
3447
- value: D.id,
3447
+ value: E.id,
3448
3448
  label: "chunk"
3449
3449
  })
3450
3450
  ]
@@ -3456,14 +3456,14 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3456
3456
  className: "doc-mode-toggle",
3457
3457
  children: [/* @__PURE__ */ l("button", {
3458
3458
  type: "button",
3459
- className: k === "chunks" ? "active" : "",
3460
- onClick: () => A("chunks"),
3459
+ className: O === "chunks" ? "active" : "",
3460
+ onClick: () => k("chunks"),
3461
3461
  title: "This chunk's own content",
3462
3462
  children: "chunk"
3463
3463
  }), /* @__PURE__ */ l("button", {
3464
3464
  type: "button",
3465
- className: k === "markdown" ? "active" : "",
3466
- onClick: () => A("markdown"),
3465
+ className: O === "markdown" ? "active" : "",
3466
+ onClick: () => k("markdown"),
3467
3467
  title: X ? "Whole document as Markdown" : "This chunk + its sub-chunks as Markdown",
3468
3468
  children: "markdown"
3469
3469
  })]
@@ -3471,18 +3471,18 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3471
3471
  /* @__PURE__ */ l("button", {
3472
3472
  type: "button",
3473
3473
  className: "chunk-edit",
3474
- onClick: () => P(D),
3474
+ onClick: () => oe(E),
3475
3475
  children: "edit"
3476
3476
  }),
3477
- b.documentEntityTypes && _(D) && /* @__PURE__ */ l("button", {
3477
+ b.documentEntityTypes && _(E) && /* @__PURE__ */ l("button", {
3478
3478
  type: "button",
3479
- onClick: () => I(D),
3479
+ onClick: () => P(E),
3480
3480
  title: "Change this subject's type to another type in force",
3481
3481
  children: "change type"
3482
3482
  }),
3483
3483
  /* @__PURE__ */ l("button", {
3484
3484
  type: "button",
3485
- onClick: () => oe(!0),
3485
+ onClick: () => ce(!0),
3486
3486
  title: "View this chunk's edit history + diffs",
3487
3487
  children: "history"
3488
3488
  }),
@@ -3502,7 +3502,7 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3502
3502
  !X && /* @__PURE__ */ l("button", {
3503
3503
  type: "button",
3504
3504
  className: "danger",
3505
- onClick: () => L(!0),
3505
+ onClick: () => F(!0),
3506
3506
  title: "Delete this chunk and its sub-chunks",
3507
3507
  children: "delete"
3508
3508
  })
@@ -3512,34 +3512,34 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3512
3512
  }),
3513
3513
  /* @__PURE__ */ l("div", {
3514
3514
  className: "doc-content-body",
3515
- children: D.type === "mermaid" ? D.body ? /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(qe, { code: D.body }), k === "markdown" && /* @__PURE__ */ l("pre", {
3515
+ children: E.type === "mermaid" ? E.body ? /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(qe, { code: E.body }), O === "markdown" && /* @__PURE__ */ l("pre", {
3516
3516
  className: "md-pre doc-mermaid-source",
3517
- children: /* @__PURE__ */ l("code", { children: D.body })
3517
+ children: /* @__PURE__ */ l("code", { children: E.body })
3518
3518
  })] }) : /* @__PURE__ */ l("p", {
3519
3519
  className: "doc-empty-body",
3520
3520
  children: "(empty diagram)"
3521
- }) : D.type === "image" || D.asset ? ne ? /* @__PURE__ */ u("p", {
3521
+ }) : E.type === "image" || E.asset ? re ? /* @__PURE__ */ u("p", {
3522
3522
  className: "doc-empty-body",
3523
- children: ["Image failed to load: ", ne]
3524
- }) : ee ? /* @__PURE__ */ u("figure", {
3523
+ children: ["Image failed to load: ", re]
3524
+ }) : te ? /* @__PURE__ */ u("figure", {
3525
3525
  className: "doc-image",
3526
3526
  children: [/* @__PURE__ */ l("img", {
3527
- src: ee,
3528
- alt: Lt(D)
3529
- }), D.body && /* @__PURE__ */ l("figcaption", { children: D.body })]
3527
+ src: te,
3528
+ alt: Lt(E)
3529
+ }), E.body && /* @__PURE__ */ l("figcaption", { children: E.body })]
3530
3530
  }) : /* @__PURE__ */ l("p", {
3531
3531
  className: "doc-empty-body",
3532
3532
  children: "Loading image…"
3533
- }) : k === "markdown" ? j === null ? /* @__PURE__ */ l("p", {
3533
+ }) : O === "markdown" ? A === null ? /* @__PURE__ */ l("p", {
3534
3534
  className: "doc-empty-body",
3535
3535
  children: "Assembling Markdown…"
3536
- }) : /* @__PURE__ */ l(Ft, { source: j }) : D.body ? /* @__PURE__ */ l(Ft, { source: D.body }) : /* @__PURE__ */ l("p", {
3536
+ }) : /* @__PURE__ */ l(Ft, { source: A }) : E.body ? /* @__PURE__ */ l(Ft, { source: E.body }) : /* @__PURE__ */ l("p", {
3537
3537
  className: "doc-empty-body",
3538
3538
  children: "(empty chunk)"
3539
3539
  })
3540
3540
  }),
3541
3541
  /* @__PURE__ */ l(Tt, {
3542
- edges: K,
3542
+ edges: Se,
3543
3543
  incomplete: Ce,
3544
3544
  documentId: e,
3545
3545
  selectedId: w,
@@ -3563,7 +3563,7 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3563
3563
  })
3564
3564
  })]
3565
3565
  }),
3566
- _e && p && /* @__PURE__ */ l("div", {
3566
+ ve && p && /* @__PURE__ */ l("div", {
3567
3567
  className: "doc-assistant",
3568
3568
  children: p({
3569
3569
  documentId: e,
@@ -3572,41 +3572,41 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3572
3572
  onChanged: q
3573
3573
  })
3574
3574
  }),
3575
- ie && /* @__PURE__ */ l(Je, {
3576
- chunk: ie,
3575
+ ae && /* @__PURE__ */ l(Je, {
3576
+ chunk: ae,
3577
3577
  scope: n,
3578
3578
  browse: x,
3579
- onClose: () => P(null),
3579
+ onClose: () => oe(null),
3580
3580
  onSaved: q
3581
3581
  }),
3582
- F && /* @__PURE__ */ l(Ye, {
3583
- chunk: F,
3582
+ N && /* @__PURE__ */ l(Ye, {
3583
+ chunk: N,
3584
3584
  scope: n,
3585
3585
  browse: x,
3586
- onClose: () => I(null),
3586
+ onClose: () => P(null),
3587
3587
  onSaved: q
3588
3588
  }),
3589
- ae && D && /* @__PURE__ */ l(Nt, {
3590
- chunkId: D.id,
3591
- chunkTitle: D.title,
3589
+ se && E && /* @__PURE__ */ l(Nt, {
3590
+ chunkId: E.id,
3591
+ chunkTitle: E.title,
3592
3592
  scope: n,
3593
3593
  browse: x,
3594
- onClose: () => oe(!1)
3594
+ onClose: () => ce(!1)
3595
3595
  }),
3596
3596
  be && Q && /* @__PURE__ */ l(ft, {
3597
3597
  documentId: e,
3598
3598
  rootChunkId: Q,
3599
- docType: G?.type,
3600
- docStatus: G?.status,
3599
+ docType: W?.type,
3600
+ docStatus: W?.status,
3601
3601
  chunkStatuses: Ue,
3602
3602
  scope: n,
3603
3603
  browse: x,
3604
3604
  onClose: () => xe(!1),
3605
3605
  onSaved: q
3606
3606
  }),
3607
- se && D && /* @__PURE__ */ l("div", {
3607
+ le && E && /* @__PURE__ */ l("div", {
3608
3608
  className: "modal-overlay",
3609
- onClick: () => L(!1),
3609
+ onClick: () => F(!1),
3610
3610
  children: /* @__PURE__ */ u("div", {
3611
3611
  className: "modal chunk-delete-confirm",
3612
3612
  onClick: (e) => e.stopPropagation(),
@@ -3616,7 +3616,7 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3616
3616
  className: "modal-context",
3617
3617
  children: [
3618
3618
  "Delete “",
3619
- D.title || "(untitled)",
3619
+ E.title || "(untitled)",
3620
3620
  "” and all of its sub-chunks? This cannot be undone."
3621
3621
  ]
3622
3622
  }),
@@ -3624,7 +3624,7 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3624
3624
  className: "modal-buttons",
3625
3625
  children: [/* @__PURE__ */ l("button", {
3626
3626
  type: "button",
3627
- onClick: () => L(!1),
3627
+ onClick: () => F(!1),
3628
3628
  children: "cancel"
3629
3629
  }), /* @__PURE__ */ l("button", {
3630
3630
  type: "button",
@@ -3800,10 +3800,10 @@ function qt(e, t) {
3800
3800
  }
3801
3801
  }
3802
3802
  function Jt(e) {
3803
- let { theme: t, defaultScope: n, path: r, onPathChange: i, browse: a, principal: o, renderAssistant: s, renderNavigator: c, onError: u } = e, d = F(e);
3804
- return /* @__PURE__ */ l(I, {
3803
+ let { theme: t, defaultScope: n, path: r, onPathChange: i, browse: a, principal: o, renderAssistant: s, renderNavigator: c, navigator: u, onError: d } = e, f = N(e);
3804
+ return /* @__PURE__ */ l(P, {
3805
3805
  theme: t,
3806
- dataLayer: d,
3806
+ dataLayer: f,
3807
3807
  children: /* @__PURE__ */ l(Yt, {
3808
3808
  defaultScope: n,
3809
3809
  path: r,
@@ -3812,124 +3812,129 @@ function Jt(e) {
3812
3812
  principal: o,
3813
3813
  renderAssistant: s,
3814
3814
  renderNavigator: c,
3815
- onError: u
3815
+ navigator: u,
3816
+ onError: d
3816
3817
  })
3817
3818
  });
3818
3819
  }
3819
- function Yt({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p, renderAssistant: m, renderNavigator: _, onError: v }) {
3820
- let y = E(), [b, x] = o(e ?? "user"), [S, C] = o(void 0), [w, T] = o(null), [D, O] = o(null), [j, M] = o(() => /* @__PURE__ */ new Set()), N = n === void 0 ? S : n, re = a(d);
3820
+ function Yt({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p, renderAssistant: m, renderNavigator: _, navigator: v, onError: y }) {
3821
+ let b = ee(), [x, S] = o(e ?? "user"), [C, w] = o(void 0), [T, E] = o(null), [D, A] = o(null), [j, ie] = o(() => /* @__PURE__ */ new Set()), M = n === void 0 ? C : n, ae = a(d);
3821
3822
  r(() => {
3822
- re.current = d;
3823
+ ae.current = d;
3823
3824
  }, [d]);
3824
- let ie = a(v);
3825
+ let oe = a(y);
3825
3826
  r(() => {
3826
- ie.current = v;
3827
- }, [v]);
3828
- let [P, F] = o([]), I = a(0), L = a(void 0), R = t((e) => {
3829
- L.current = e, re.current?.(e), C(e);
3830
- }, []), z = t((e) => {
3831
- I.current++, F((e) => e.length > 0 ? [] : e), R(e);
3832
- }, [R]);
3827
+ oe.current = y;
3828
+ }, [y]);
3829
+ let [N, P] = o([]), F = a(0), I = a(void 0), L = t((e) => {
3830
+ I.current = e, ae.current?.(e), w(e);
3831
+ }, []), R = t((e) => {
3832
+ F.current++, P((e) => e.length > 0 ? [] : e), L(e);
3833
+ }, [L]);
3833
3834
  r(() => {
3834
- n !== void 0 && n !== L.current && (I.current++, F((e) => e.length > 0 ? [] : e));
3835
+ n !== void 0 && n !== I.current && (F.current++, P((e) => e.length > 0 ? [] : e));
3835
3836
  }, [n]);
3836
- let B = i(() => f && (f.scopeId || f.tenant) ? {
3837
+ let z = i(() => f && (f.scopeId || f.tenant) ? {
3837
3838
  scopeId: f.scopeId,
3838
3839
  tenant: f.tenant
3839
- } : void 0, [f?.scopeId, f?.tenant]), V = i(() => new ee(y, b, B), [
3840
- y,
3840
+ } : void 0, [f?.scopeId, f?.tenant]), B = i(() => new te(b, x, z), [
3841
3841
  b,
3842
- B
3843
- ]), H = s(V.subscribe, V.getSnapshot), U = t((e) => {
3844
- ie.current?.(e);
3845
- }, []), [fe, pe] = o(() => _ ? h(globalThis.localStorage) : "tree"), W = !!_ && fe === "stars", me = t((e) => {
3846
- pe(e), g(globalThis.localStorage, e), e === "tree" && ge(!1);
3847
- }, []), [he, ge] = o(!1), [_e, ve] = o(0), [G, ye] = o(), [be, xe] = o(), K = t((e, t) => (ve((e) => e + 1), V.invalidate(e, t)), [V]), [Se, Ce] = o(() => /* @__PURE__ */ new Map()), we = a(/* @__PURE__ */ new Set()), Te = a(0), Ee = t(() => {
3848
- Te.current++, we.current = /* @__PURE__ */ new Set(), Ce(/* @__PURE__ */ new Map());
3849
- }, []), De = a(!0);
3842
+ x,
3843
+ z
3844
+ ]), V = s(B.subscribe, B.getSnapshot), H = t((e) => {
3845
+ oe.current?.(e);
3846
+ }, []), [me, he] = o(() => _ ? h(globalThis.localStorage) : "tree"), U = !!_ && me === "stars", ge = t((e) => {
3847
+ he(e), g(globalThis.localStorage, e), e === "tree" && ve(!1);
3848
+ }, []), [_e, ve] = o(!1), [ye, W] = o(0);
3849
+ r(() => {
3850
+ _ && v && ge(v);
3851
+ }, [v]);
3852
+ let [G, be] = o(), [xe, Se] = o(), K = t((e, t) => (W((e) => e + 1), B.invalidate(e, t)), [B]), [Ce, we] = o(() => /* @__PURE__ */ new Map()), Te = a(/* @__PURE__ */ new Set()), Ee = a(0), De = t(() => {
3853
+ Ee.current++, Te.current = /* @__PURE__ */ new Set(), we(/* @__PURE__ */ new Map());
3854
+ }, []), Oe = a(!0);
3850
3855
  r(() => {
3851
- De.current ? De.current = !1 : (z(void 0), T(null), M(/* @__PURE__ */ new Set()), Ee()), V.loadDir("").catch(U);
3856
+ Oe.current ? Oe.current = !1 : (R(void 0), E(null), ie(/* @__PURE__ */ new Set()), De()), B.loadDir("").catch(H);
3852
3857
  }, [
3853
- V,
3854
- z,
3855
- Ee,
3856
- U
3858
+ B,
3859
+ R,
3860
+ De,
3861
+ H
3857
3862
  ]), r(() => {
3858
- for (let e of j) H.has(e) || V.loadDir(e).catch(U);
3863
+ for (let e of j) V.has(e) || B.loadDir(e).catch(H);
3859
3864
  }, [
3860
- V,
3865
+ B,
3861
3866
  j,
3862
- H,
3863
- U
3867
+ V,
3868
+ H
3864
3869
  ]);
3865
- let Oe = a(null);
3870
+ let ke = a(null);
3866
3871
  r(() => {
3867
- let e = Oe.current !== null && Oe.current !== V;
3868
- if (Oe.current = V, !N || e) return;
3869
- let t = A(N).filter((e) => e !== "");
3870
- M((e) => {
3872
+ let e = ke.current !== null && ke.current !== B;
3873
+ if (ke.current = B, !M || e) return;
3874
+ let t = k(M).filter((e) => e !== "");
3875
+ ie((e) => {
3871
3876
  if (t.every((t) => e.has(t))) return e;
3872
3877
  let n = new Set(e);
3873
3878
  return t.forEach((e) => n.add(e)), n;
3874
- }), V.reveal(N).catch(U);
3879
+ }), B.reveal(M).catch(H);
3875
3880
  }, [
3876
- V,
3877
- N,
3878
- U
3881
+ B,
3882
+ M,
3883
+ H
3879
3884
  ]), r(() => {
3880
- if (b === "tenant") return;
3885
+ if (x === "tenant") return;
3881
3886
  let e = [];
3882
- for (let t of H.values()) for (let n of ne(t.entries)) we.current.has(n) || (we.current.add(n), e.push(n));
3883
- let t = Te.current;
3884
- for (let n = 0; n < e.length; n += 500) y.documentsSummary({ documentIds: e.slice(n, n + 500) }, b, B).then((e) => {
3885
- Te.current === t && Ce((t) => {
3887
+ for (let t of V.values()) for (let n of re(t.entries)) Te.current.has(n) || (Te.current.add(n), e.push(n));
3888
+ let t = Ee.current;
3889
+ for (let n = 0; n < e.length; n += 500) b.documentsSummary({ documentIds: e.slice(n, n + 500) }, x, z).then((e) => {
3890
+ Ee.current === t && we((t) => {
3886
3891
  let n = new Map(t);
3887
3892
  for (let t of e.documents ?? []) n.set(t.document_id, t);
3888
3893
  return n;
3889
3894
  });
3890
3895
  }).catch(() => {});
3891
3896
  }, [
3892
- y,
3893
- H,
3894
3897
  b,
3895
- B
3898
+ V,
3899
+ x,
3900
+ z
3896
3901
  ]);
3897
- let ke = i(() => zt(H), [H]), Ae = t(async () => {
3898
- T(null), Ee(), ve((e) => e + 1), await V.refresh(j).catch(U), N && await V.reveal(N).catch(U);
3902
+ let Ae = i(() => zt(V), [V]), q = t(async () => {
3903
+ E(null), De(), W((e) => e + 1), await B.refresh(j).catch(H), M && await B.reveal(M).catch(H);
3899
3904
  }, [
3900
- V,
3905
+ B,
3901
3906
  j,
3902
- N,
3903
- Ee,
3904
- U
3905
- ]), q = t((e) => {
3906
- M((t) => {
3907
+ M,
3908
+ De,
3909
+ H
3910
+ ]), je = t((e) => {
3911
+ ie((t) => {
3907
3912
  let n = new Set(t);
3908
3913
  return n.has(e) ? n.delete(e) : n.add(e), n;
3909
3914
  });
3910
- }, []), je = t((e) => V.loadMore(e).catch(U), [V, U]), Me = t((e) => {
3911
- (V.getSnapshot().get(e)?.loaded ? V.loadMore(e) : V.loadDir(e)).catch(U);
3912
- }, [V, U]), J = i(() => N ? qt(ke, N) : void 0, [ke, N]), Ne = H.get("")?.error, Pe = J?.kind === "directory" ? J.fullPath : void 0, [Y, Fe] = o(null);
3915
+ }, []), Me = t((e) => B.loadMore(e).catch(H), [B, H]), Ne = t((e) => {
3916
+ (B.getSnapshot().get(e)?.loaded ? B.loadMore(e) : B.loadDir(e)).catch(H);
3917
+ }, [B, H]), J = i(() => M ? qt(Ae, M) : void 0, [Ae, M]), Pe = V.get("")?.error, Y = J?.kind === "directory" ? J.fullPath : void 0, [Fe, Ie] = o(null);
3913
3918
  r(() => {
3914
- if (!Pe || !y.pathIsStored) return;
3919
+ if (!Y || !b.pathIsStored) return;
3915
3920
  let e = !1;
3916
- return y.pathIsStored(Pe, b, B).then((t) => {
3917
- e || Fe({
3918
- path: Pe,
3921
+ return b.pathIsStored(Y, x, z).then((t) => {
3922
+ e || Ie({
3923
+ path: Y,
3919
3924
  explicit: t
3920
3925
  });
3921
3926
  }, () => {}), () => {
3922
3927
  e = !0;
3923
3928
  };
3924
3929
  }, [
3925
- y,
3926
- Pe,
3927
3930
  b,
3928
- B
3931
+ Y,
3932
+ x,
3933
+ z
3929
3934
  ]);
3930
- let Ie = J ? J.kind === "directory" ? Y?.path === J.fullPath ? Y.explicit ? "yes" : "implicit (no entry)" : void 0 : "yes" : void 0, Le = i(() => J ? J.kind === "directory" ? J.fullPath : k(J.fullPath) : "", [J]), X = Le || "/", Z = b !== "tenant", Re = t(() => {
3931
- O({
3932
- title: `New folder in ${X}`,
3935
+ let Le = J ? J.kind === "directory" ? Fe?.path === J.fullPath ? Fe.explicit ? "yes" : "implicit (no entry)" : void 0 : "yes" : void 0, X = i(() => J ? J.kind === "directory" ? J.fullPath : O(J.fullPath) : "", [J]), Z = X || "/", Re = x !== "tenant", Q = t(() => {
3936
+ A({
3937
+ title: `New folder in ${Z}`,
3933
3938
  fields: [{
3934
3939
  key: "name",
3935
3940
  label: "Folder name",
@@ -3939,22 +3944,22 @@ function Yt({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
3939
3944
  onSubmit: async (e) => {
3940
3945
  let t = e.name.trim();
3941
3946
  if (!Gt.test(t)) throw Error("name may contain only [A-Za-z0-9._-]");
3942
- let n = Kt(Le, t);
3943
- await y.pathMkdir(n, b, B), await K(n).catch(U), z(n);
3947
+ let n = Kt(X, t);
3948
+ await b.pathMkdir(n, x, z), await K(n).catch(H), R(n);
3944
3949
  }
3945
3950
  });
3946
3951
  }, [
3947
- y,
3948
- V,
3949
- Le,
3950
- X,
3951
3952
  b,
3952
3953
  B,
3953
- U,
3954
- z
3955
- ]), Q = t(() => {
3956
- O({
3957
- title: `New document in ${X}`,
3954
+ X,
3955
+ Z,
3956
+ x,
3957
+ z,
3958
+ H,
3959
+ R
3960
+ ]), ze = t(() => {
3961
+ A({
3962
+ title: `New document in ${Z}`,
3958
3963
  fields: [{
3959
3964
  key: "name",
3960
3965
  label: "Path name",
@@ -3968,21 +3973,21 @@ function Yt({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
3968
3973
  onSubmit: async (e) => {
3969
3974
  let t = e.name.trim();
3970
3975
  if (!Gt.test(t)) throw Error("name may contain only [A-Za-z0-9._-]");
3971
- let n = e.title.trim() || t, r = Kt(Le, t);
3972
- await y.documentCreate(n, r, b, B), await K(r).catch(U), z(r);
3976
+ let n = e.title.trim() || t, r = Kt(X, t);
3977
+ await b.documentCreate(n, r, x, z), await K(r).catch(H), R(r);
3973
3978
  }
3974
3979
  });
3975
3980
  }, [
3976
- y,
3977
- V,
3978
- Le,
3979
- X,
3980
3981
  b,
3981
3982
  B,
3982
- U,
3983
- z
3984
- ]), ze = t(() => {
3985
- J && O({
3983
+ X,
3984
+ Z,
3985
+ x,
3986
+ z,
3987
+ H,
3988
+ R
3989
+ ]), Be = t(() => {
3990
+ J && A({
3986
3991
  title: `Rename / move ${J.fullPath}`,
3987
3992
  fields: [{
3988
3993
  key: "to",
@@ -3993,22 +3998,22 @@ function Yt({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
3993
3998
  onSubmit: async (e) => {
3994
3999
  let t = e.to.trim();
3995
4000
  if (!t.startsWith("/")) throw Error("path must start with /");
3996
- await y.pathMv(J.fullPath, t, b, B), await Promise.all([K(J.fullPath, { dropSubtree: !0 }), K(t)]).catch(U), z(t);
4001
+ await b.pathMv(J.fullPath, t, x, z), await Promise.all([K(J.fullPath, { dropSubtree: !0 }), K(t)]).catch(H), R(t);
3997
4002
  }
3998
4003
  });
3999
4004
  }, [
4000
- y,
4001
- V,
4002
- J,
4003
4005
  b,
4004
4006
  B,
4005
- U,
4006
- z
4007
- ]), Be = t(() => {
4007
+ J,
4008
+ x,
4009
+ z,
4010
+ H,
4011
+ R
4012
+ ]), Ve = t(() => {
4008
4013
  if (!J) return;
4009
4014
  if (J.kind === "document") {
4010
4015
  let e = J.resourceRef?.document_id;
4011
- O({
4016
+ A({
4012
4017
  title: `Delete document ${J.fullPath}`,
4013
4018
  message: "This deletes the document, all its chunks, and its path entry. This cannot be undone.",
4014
4019
  fields: [],
@@ -4016,114 +4021,114 @@ function Yt({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4016
4021
  danger: !0,
4017
4022
  onSubmit: async () => {
4018
4023
  if (!e) throw Error("this document dirent has no document_id");
4019
- await y.documentDelete(e, b, B), await K(J.fullPath).catch(U), z(void 0);
4024
+ await b.documentDelete(e, x, z), await K(J.fullPath).catch(H), R(void 0);
4020
4025
  }
4021
4026
  });
4022
4027
  return;
4023
4028
  }
4024
4029
  let e = J;
4025
- T(null), (async () => {
4030
+ E(null), (async () => {
4026
4031
  let t;
4027
4032
  try {
4028
- t = await te(y, e.fullPath, b, B);
4033
+ t = await ne(b, e.fullPath, x, z);
4029
4034
  } catch (t) {
4030
- T(`could not list ${e.fullPath} for delete: ${t instanceof Error ? t.message : String(t)}`);
4035
+ E(`could not list ${e.fullPath} for delete: ${t instanceof Error ? t.message : String(t)}`);
4031
4036
  return;
4032
4037
  }
4033
- let n = b === "tenant" ? [] : ne(t);
4034
- O({
4038
+ let n = x === "tenant" ? [] : re(t);
4039
+ A({
4035
4040
  title: `Delete branch ${e.fullPath}`,
4036
4041
  message: t.length === 0 ? "This removes the (empty) folder." : "This removes the folder and everything under it" + (n.length > 0 ? ` — including ${n.length} document(s), whose chunks are deleted.` : "."),
4037
4042
  fields: [],
4038
4043
  submitLabel: "Delete",
4039
4044
  danger: !0,
4040
4045
  onSubmit: async () => {
4041
- for (let e of n) await y.documentDelete(e, b, B);
4042
- await y.pathRm(e.fullPath, b, !0, B), await K(e.fullPath, { dropSubtree: !0 }).catch(U), z(void 0);
4046
+ for (let e of n) await b.documentDelete(e, x, z);
4047
+ await b.pathRm(e.fullPath, x, !0, z), await K(e.fullPath, { dropSubtree: !0 }).catch(H), R(void 0);
4043
4048
  }
4044
4049
  });
4045
4050
  })();
4046
4051
  }, [
4047
- y,
4048
- V,
4049
- J,
4050
4052
  b,
4051
4053
  B,
4052
- U,
4053
- z
4054
- ]), Ve = J && (J.kind === "directory" || J.kind === "document"), $ = i(() => {
4055
- if (P.length > 0) return P[P.length - 1];
4054
+ J,
4055
+ x,
4056
+ z,
4057
+ H,
4058
+ R
4059
+ ]), He = J && (J.kind === "directory" || J.kind === "document"), $ = i(() => {
4060
+ if (N.length > 0) return N[N.length - 1];
4056
4061
  if (J?.kind === "document") return {
4057
4062
  documentId: J.resourceRef?.document_id ?? "",
4058
4063
  path: J.fullPath,
4059
4064
  title: J.name
4060
4065
  };
4061
- }, [P, J]), He = t((e, t) => {
4062
- let n = ++I.current, r = le(V.getSnapshot(), e.documentId);
4063
- F(ae(P, {
4066
+ }, [N, J]), Ue = t((e, t) => {
4067
+ let n = ++F.current, r = de(B.getSnapshot(), e.documentId);
4068
+ P(se(N, {
4064
4069
  ...t,
4065
4070
  path: $?.path
4066
4071
  }, {
4067
4072
  ...e,
4068
4073
  path: r
4069
- })), R(r), !r && y.documentPath && y.documentPath(e.documentId, b, B).then((t) => {
4070
- t && I.current === n && (F((n) => se(n, e.documentId, { path: t })), R(t));
4074
+ })), L(r), !r && b.documentPath && b.documentPath(e.documentId, x, z).then((t) => {
4075
+ t && F.current === n && (P((n) => le(n, e.documentId, { path: t })), L(t));
4071
4076
  }, () => {});
4072
4077
  }, [
4073
- y,
4074
- V,
4075
- P,
4076
- $?.path,
4077
4078
  b,
4078
4079
  B,
4079
- R
4080
- ]), Ue = t((e) => {
4081
- let t = oe(P, e);
4082
- t !== P && (I.current++, F(t), R(t[t.length - 1].path));
4083
- }, [P, R]), We = t((e, t) => F((n) => se(n, e, { title: t })), []), Ge = t((e) => {
4084
- xe((t) => ({
4080
+ N,
4081
+ $?.path,
4082
+ x,
4083
+ z,
4084
+ L
4085
+ ]), We = t((e) => {
4086
+ let t = ce(N, e);
4087
+ t !== N && (F.current++, P(t), L(t[t.length - 1].path));
4088
+ }, [N, L]), Ge = t((e, t) => P((n) => le(n, e, { title: t })), []), Ke = t((e) => {
4089
+ Se((t) => ({
4085
4090
  documentId: e.documentId,
4086
4091
  chunkId: e.chunkId,
4087
4092
  seq: (t?.seq ?? 0) + 1
4088
- })), $?.documentId !== e.documentId && (e.path ? z(e.path) : (I.current++, F([{
4093
+ })), $?.documentId !== e.documentId && (e.path ? R(e.path) : (F.current++, P([{
4089
4094
  documentId: e.documentId,
4090
4095
  chunkId: e.chunkId
4091
- }]), R(void 0)));
4096
+ }]), L(void 0)));
4092
4097
  }, [
4093
4098
  $?.documentId,
4094
- z,
4095
- R
4096
- ]), Ke = i(() => ({
4097
- scope: b,
4098
- browse: B,
4099
+ R,
4100
+ L
4101
+ ]), qe = i(() => ({
4102
+ scope: x,
4103
+ browse: z,
4099
4104
  selection: {
4100
4105
  documentId: $?.documentId,
4101
4106
  chunkId: G && G.documentId === $?.documentId ? G.chunkId : void 0,
4102
4107
  path: $?.path
4103
4108
  },
4104
- onSelect: Ge,
4105
- reloadToken: _e,
4106
- maximized: he,
4107
- onToggleMaximize: () => ge((e) => !e),
4109
+ onSelect: Ke,
4110
+ reloadToken: ye,
4111
+ maximized: _e,
4112
+ onToggleMaximize: () => ve((e) => !e),
4108
4113
  subject: p?.subject
4109
4114
  }), [
4110
- b,
4111
- B,
4115
+ x,
4116
+ z,
4112
4117
  $?.documentId,
4113
4118
  $?.path,
4114
4119
  G,
4115
- Ge,
4120
+ Ke,
4121
+ ye,
4116
4122
  _e,
4117
- he,
4118
4123
  p?.subject
4119
- ]), qe = be && $ && be.documentId === $.documentId ? be : void 0, Je = !!$?.path && J?.kind === "document" && J.fullPath === $.path;
4120
- return /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ u(de, {
4121
- className: W ? "paths-view paths-view--stars" : "paths-view",
4122
- defaultLeftWidth: W ? 720 : 420,
4124
+ ]), Je = xe && $ && xe.documentId === $.documentId ? xe : void 0, Ye = !!$?.path && J?.kind === "document" && J.fullPath === $.path;
4125
+ return /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ u(pe, {
4126
+ className: U ? "paths-view paths-view--stars" : "paths-view",
4127
+ defaultLeftWidth: U ? 720 : 420,
4123
4128
  minLeftWidth: 280,
4124
4129
  minRightWidth: 300,
4125
- storageKey: W ? "loomcycle.explorer.split.stars" : "loomcycle.explorer.split.paths",
4126
- hideRight: W && he,
4130
+ storageKey: U ? "loomcycle.explorer.split.stars" : "loomcycle.explorer.split.paths",
4131
+ hideRight: U && _e,
4127
4132
  children: [/* @__PURE__ */ u("div", {
4128
4133
  className: "left",
4129
4134
  children: [
@@ -4133,8 +4138,8 @@ function Yt({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4133
4138
  /* @__PURE__ */ u("label", {
4134
4139
  className: "paths-scope",
4135
4140
  children: [/* @__PURE__ */ l("span", { children: "scope" }), /* @__PURE__ */ u("select", {
4136
- value: b,
4137
- onChange: (e) => x(e.target.value),
4141
+ value: x,
4142
+ onChange: (e) => S(e.target.value),
4138
4143
  children: [
4139
4144
  /* @__PURE__ */ l("option", {
4140
4145
  value: "user",
@@ -4157,76 +4162,76 @@ function Yt({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4157
4162
  "aria-label": "Navigator",
4158
4163
  children: [/* @__PURE__ */ l("button", {
4159
4164
  type: "button",
4160
- "aria-pressed": !W,
4161
- className: W ? void 0 : "active",
4162
- onClick: () => me("tree"),
4165
+ "aria-pressed": !U,
4166
+ className: U ? void 0 : "active",
4167
+ onClick: () => ge("tree"),
4163
4168
  title: "Browse the Path tree",
4164
4169
  children: "tree"
4165
4170
  }), /* @__PURE__ */ l("button", {
4166
4171
  type: "button",
4167
- "aria-pressed": W,
4168
- className: W ? "active" : void 0,
4169
- onClick: () => me("stars"),
4172
+ "aria-pressed": U,
4173
+ className: U ? "active" : void 0,
4174
+ onClick: () => ge("stars"),
4170
4175
  title: "Browse the scope as a 3D star map",
4171
4176
  children: "stars"
4172
4177
  })]
4173
4178
  }),
4174
4179
  /* @__PURE__ */ u("div", {
4175
4180
  className: "paths-toolbar-actions",
4176
- children: [!W && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("button", {
4181
+ children: [!U && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("button", {
4177
4182
  type: "button",
4178
- onClick: Re,
4179
- title: `New folder in ${X}`,
4183
+ onClick: Q,
4184
+ title: `New folder in ${Z}`,
4180
4185
  children: "+ folder"
4181
4186
  }), /* @__PURE__ */ l("button", {
4182
4187
  type: "button",
4183
- onClick: Q,
4184
- disabled: !Z,
4185
- title: Z ? `New document in ${X}` : "Documents are agent/user scope only",
4188
+ onClick: ze,
4189
+ disabled: !Re,
4190
+ title: Re ? `New document in ${Z}` : "Documents are agent/user scope only",
4186
4191
  children: "+ document"
4187
4192
  })] }), /* @__PURE__ */ l("button", {
4188
4193
  type: "button",
4189
- onClick: () => void Ae(),
4194
+ onClick: () => void q(),
4190
4195
  title: "Reload the tree",
4191
4196
  children: "↻"
4192
4197
  })]
4193
4198
  })
4194
4199
  ]
4195
4200
  }),
4196
- !W && /* @__PURE__ */ u("p", {
4201
+ !U && /* @__PURE__ */ u("p", {
4197
4202
  className: "paths-context",
4198
4203
  children: [
4199
4204
  "new items → ",
4200
- /* @__PURE__ */ l("code", { children: X }),
4201
- B?.scopeId && /* @__PURE__ */ u(c, { children: [
4205
+ /* @__PURE__ */ l("code", { children: Z }),
4206
+ z?.scopeId && /* @__PURE__ */ u(c, { children: [
4202
4207
  " · ",
4203
4208
  "subject ",
4204
- /* @__PURE__ */ l("code", { children: B.scopeId })
4209
+ /* @__PURE__ */ l("code", { children: z.scopeId })
4205
4210
  ] }),
4206
- B?.tenant && /* @__PURE__ */ u(c, { children: [
4211
+ z?.tenant && /* @__PURE__ */ u(c, { children: [
4207
4212
  " · ",
4208
4213
  "tenant ",
4209
- /* @__PURE__ */ l("code", { children: B.tenant })
4214
+ /* @__PURE__ */ l("code", { children: z.tenant })
4210
4215
  ] })
4211
4216
  ]
4212
4217
  }),
4213
- (w || Ne) && /* @__PURE__ */ l("div", {
4218
+ (T || Pe) && /* @__PURE__ */ l("div", {
4214
4219
  className: "paths-err",
4215
- children: w || Ne
4220
+ children: T || Pe
4216
4221
  }),
4217
- W && _ ? /* @__PURE__ */ l("div", {
4222
+ U && _ ? /* @__PURE__ */ l("div", {
4218
4223
  className: "paths-navigator",
4219
- children: _(Ke)
4224
+ children: _(qe)
4220
4225
  }) : /* @__PURE__ */ l(Vt, {
4221
- tree: ke,
4222
- root: H.get(""),
4226
+ tree: Ae,
4227
+ root: V.get(""),
4223
4228
  expanded: j,
4224
- onToggle: q,
4225
- onLoadMore: je,
4226
- onRetry: Me,
4227
- selectedPath: N,
4228
- onSelect: (e) => z(e.fullPath),
4229
- summaries: Se
4229
+ onToggle: je,
4230
+ onLoadMore: Me,
4231
+ onRetry: Ne,
4232
+ selectedPath: M,
4233
+ onSelect: (e) => R(e.fullPath),
4234
+ summaries: Ce
4230
4235
  })
4231
4236
  ]
4232
4237
  }), /* @__PURE__ */ l("div", {
@@ -4234,9 +4239,9 @@ function Yt({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4234
4239
  children: $ ? /* @__PURE__ */ u("div", {
4235
4240
  className: "paths-doc",
4236
4241
  children: [
4237
- /* @__PURE__ */ l(ue, {
4238
- trail: P,
4239
- onJump: Ue
4242
+ /* @__PURE__ */ l(fe, {
4243
+ trail: N,
4244
+ onJump: We
4240
4245
  }),
4241
4246
  /* @__PURE__ */ u("div", {
4242
4247
  className: "paths-doc-head",
@@ -4247,40 +4252,40 @@ function Yt({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4247
4252
  className: "paths-doc-path paths-doc-unfiled",
4248
4253
  title: "Opened by id — no entry for this document was found in the Path tree",
4249
4254
  children: [
4250
- ce($),
4255
+ ue($),
4251
4256
  " ",
4252
4257
  /* @__PURE__ */ l("em", { children: "· opened by id, not in the tree" })
4253
4258
  ]
4254
- }), Je && /* @__PURE__ */ u("div", {
4259
+ }), Ye && /* @__PURE__ */ u("div", {
4255
4260
  className: "paths-detail-actions",
4256
4261
  children: [/* @__PURE__ */ l("button", {
4257
4262
  type: "button",
4258
- onClick: ze,
4263
+ onClick: Be,
4259
4264
  children: "rename / move"
4260
4265
  }), /* @__PURE__ */ l("button", {
4261
4266
  type: "button",
4262
4267
  className: "danger",
4263
- onClick: Be,
4268
+ onClick: Ve,
4264
4269
  children: "delete"
4265
4270
  })]
4266
4271
  })]
4267
4272
  }),
4268
4273
  /* @__PURE__ */ l(Rt, {
4269
4274
  documentId: $.documentId,
4270
- scope: b,
4275
+ scope: x,
4271
4276
  titleHint: $.title,
4272
- browse: B,
4277
+ browse: z,
4273
4278
  principal: p,
4274
4279
  renderAssistant: m,
4275
- initialChunkId: $.chunkId ?? qe?.chunkId,
4276
- onOpenDocument: He,
4277
- onTitle: We,
4278
- onChunkSelect: (e) => ye({
4280
+ initialChunkId: $.chunkId ?? Je?.chunkId,
4281
+ onOpenDocument: Ue,
4282
+ onTitle: Ge,
4283
+ onChunkSelect: (e) => be({
4279
4284
  documentId: $.documentId,
4280
4285
  chunkId: e
4281
4286
  }),
4282
- focusChunk: qe
4283
- }, P.length)
4287
+ focusChunk: Je
4288
+ }, N.length)
4284
4289
  ]
4285
4290
  }) : J ? /* @__PURE__ */ u("div", {
4286
4291
  className: "paths-detail",
@@ -4293,20 +4298,20 @@ function Yt({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4293
4298
  className: "paths-detail-meta",
4294
4299
  children: [
4295
4300
  /* @__PURE__ */ l("dt", { children: "scope" }),
4296
- /* @__PURE__ */ l("dd", { children: b }),
4297
- Ie && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("dt", { children: "stored" }), /* @__PURE__ */ l("dd", { children: Ie })] })
4301
+ /* @__PURE__ */ l("dd", { children: x }),
4302
+ Le && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("dt", { children: "stored" }), /* @__PURE__ */ l("dd", { children: Le })] })
4298
4303
  ]
4299
4304
  }),
4300
- Ve ? /* @__PURE__ */ u("div", {
4305
+ He ? /* @__PURE__ */ u("div", {
4301
4306
  className: "paths-detail-actions",
4302
4307
  children: [/* @__PURE__ */ l("button", {
4303
4308
  type: "button",
4304
- onClick: ze,
4309
+ onClick: Be,
4305
4310
  children: "rename / move"
4306
4311
  }), /* @__PURE__ */ l("button", {
4307
4312
  type: "button",
4308
4313
  className: "danger",
4309
- onClick: Be,
4314
+ onClick: Ve,
4310
4315
  children: "delete"
4311
4316
  })]
4312
4317
  }) : /* @__PURE__ */ u("p", {
@@ -4325,7 +4330,7 @@ function Yt({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4325
4330
  })]
4326
4331
  }), D && /* @__PURE__ */ l(Xt, {
4327
4332
  state: D,
4328
- onClose: () => O(null)
4333
+ onClose: () => A(null)
4329
4334
  })] });
4330
4335
  }
4331
4336
  function Xt({ state: e, onClose: t }) {
@@ -4390,8 +4395,8 @@ function Xt({ state: e, onClose: t }) {
4390
4395
  //#endregion
4391
4396
  //#region src/DocumentViewer.tsx
4392
4397
  function Zt(e) {
4393
- let { documentId: t, scope: n, browse: r, theme: i } = e, a = F(e);
4394
- return /* @__PURE__ */ l(I, {
4398
+ let { documentId: t, scope: n, browse: r, theme: i } = e, a = N(e);
4399
+ return /* @__PURE__ */ l(P, {
4395
4400
  theme: i,
4396
4401
  dataLayer: a,
4397
4402
  children: /* @__PURE__ */ l(Qt, { ...e }, `${n}:${t}:${r?.scopeId ?? ""}:${r?.tenant ?? ""}`)
@@ -4399,9 +4404,9 @@ function Zt(e) {
4399
4404
  }
4400
4405
  function Qt({ documentId: e, scope: n, titleHint: r, browse: i, principal: a, renderAssistant: s, onOpenDocument: d }) {
4401
4406
  let [f, p] = o([]), m = f[f.length - 1], h = t((e, t) => {
4402
- d ? d(e, t) : p((n) => ae(n, t, e));
4403
- }, [d]), g = t((e) => p((t) => oe(t, e)), []), _ = t((e, t) => p((n) => se(n, e, { title: t })), []);
4404
- return /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(ue, {
4407
+ d ? d(e, t) : p((n) => se(n, t, e));
4408
+ }, [d]), g = t((e) => p((t) => ce(t, e)), []), _ = t((e, t) => p((n) => le(n, e, { title: t })), []);
4409
+ return /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(fe, {
4405
4410
  trail: f,
4406
4411
  onJump: g
4407
4412
  }), /* @__PURE__ */ l(Rt, {
@@ -4417,6 +4422,6 @@ function Qt({ documentId: e, scope: n, titleHint: r, browse: i, principal: a, re
4417
4422
  }, f.length)] });
4418
4423
  }
4419
4424
  //#endregion
4420
- export { Y as DEFAULT_SCHEME, Zt as DocumentViewer, W as EDGE_PAGE_CAP, Jt as PathExplorer, Te as QUEUE_CHANGED_RETRIES, we as RULING_CHUNK, ie as RequestError, re as assetFetchFromConnection, X as chunkColor, Ae as chunkCount, N as createLoomcycleClient, S as dataLayerFromClient, Le as docColor, Ie as effectiveScheme, Z as hexToTint, De as isQueueChanged, P as jsonPostFromConnection, me as loadDocumentEdges, Oe as runRuling, Re as tintStyle, ke as undoRulings };
4425
+ export { Y as DEFAULT_SCHEME, Zt as DocumentViewer, he as EDGE_PAGE_CAP, Jt as PathExplorer, Te as QUEUE_CHANGED_RETRIES, we as RULING_CHUNK, ae as RequestError, M as assetFetchFromConnection, X as chunkColor, Ae as chunkCount, ie as createLoomcycleClient, S as dataLayerFromClient, Le as docColor, Ie as effectiveScheme, Z as hexToTint, De as isQueueChanged, oe as jsonPostFromConnection, U as loadDocumentEdges, Oe as runRuling, Re as tintStyle, ke as undoRulings };
4421
4426
 
4422
4427
  //# sourceMappingURL=index.js.map