@loomcycle/explorer 0.12.0 → 0.13.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
@@ -37,11 +37,59 @@ function y(e, t) {
37
37
  return n === "" || e.some((e) => e.toLowerCase() === n.toLowerCase()) ? e : [n, ...e];
38
38
  }
39
39
  //#endregion
40
+ //#region src/lib/transfer.ts
41
+ function b(e) {
42
+ let t = {
43
+ op: e.op === "copy" ? "copy_documents" : "move_documents",
44
+ scope: e.scope,
45
+ to_scope: e.toScope,
46
+ dry_run: e.dryRun
47
+ };
48
+ e.documentId && (t.document_ids = [e.documentId]), e.underPath && (t.under_path = e.underPath);
49
+ let n = w(e.from), r = w(e.to);
50
+ return n && r && n !== r && (t.path_map = { [n]: r }), e.op === "move" && (e.dropDangling && (t.dangling = "drop"), e.dryRun || (t.expect_count = e.expectCount ?? 0)), t;
51
+ }
52
+ function x(e) {
53
+ let t = e.to.trim();
54
+ return t.startsWith("/") ? e.op === "move" && e.toScope === e.scope ? "a move goes to another scope; to rename within this one, use rename / move" : e.op === "copy" && e.toScope === e.scope && w(t) === w(e.from) ? "a copy into the same scope needs a new path" : null : "the new path must start with /";
55
+ }
56
+ function S(e, t) {
57
+ let n = t.counts ?? {}, r = n.documents ?? 0, i = e === "copy" ? "copied" : "moved", a = [], o = `${n.chunks ?? 0} parts, ${n.revisions ?? 0} revisions, ${n.statements ?? 0} relations, ${n.assets ?? 0} images`;
58
+ if (t.dry_run) a.push(`${r} ${T(r, "document")} would be ${i}: ${o}.`), t.to_finish?.length && a.push(`${t.to_finish.length} ${T(t.to_finish.length, "document")} left by an earlier interrupted move will be finished.`);
59
+ else if (e === "move") {
60
+ let e = t.moved?.length ?? 0;
61
+ a.push(`${e} ${T(e, "document")} moved: ${o}.`);
62
+ } else a.push(`${r} ${T(r, "document")} copied: ${o}.`);
63
+ let s = t.refused_count ?? t.refused?.length ?? 0;
64
+ if (s > 0) {
65
+ a.push(`${s} ${T(s, "document")} refused:`);
66
+ for (let e of t.refused ?? []) a.push(` ${e.document_id}: ${e.code}${e.detail ? ` — ${e.detail}` : ""}`);
67
+ }
68
+ if (t.dangling_count > 0) {
69
+ e === "copy" ? a.push(`${t.dangling_count} ${T(t.dangling_count, "relation")} to documents outside the set stay behind.`) : t.dropped === void 0 ? t.blocked_by === "dangling_relations" ? a.push(`${t.dangling_count} ${T(t.dangling_count, "relation")} join these documents to ones outside the set. A relation cannot span two scopes: include the other documents, or drop these relations.`) : a.push(`${t.dangling_count} ${T(t.dangling_count, "relation")} to documents outside the set will be dropped.`) : a.push(`${t.dropped} ${T(t.dropped, "relation")} to documents outside the set were dropped.`);
70
+ for (let e of t.dangling ?? []) a.push(` ${e.kind}: ${e.from} → ${e.to} (outside: ${e.outside})`);
71
+ }
72
+ for (let e of t.unfinished ?? []) a.push(`not finished: ${e.document_id}: ${e.code}${e.detail ? ` — ${e.detail}` : ""}. Run the move again.`);
73
+ for (let e of t.name_failures ?? []) a.push(`no name ${e.path} for ${e.document_id}: ${e.error}`);
74
+ return t.body_failures && a.push(`${t.body_failures} ${T(t.body_failures, "body", "bodies")} could not be written.`), t.statements_failed && a.push(`${t.statements_failed} ${T(t.statements_failed, "relation")} could not be written${t.statement_error ? `: ${t.statement_error}` : ""}.`), a;
75
+ }
76
+ function C(e, t, n) {
77
+ return e === "move" && t.dangling_count > 0 && !n || (t.counts?.documents ?? 0) === 0 && !(t.to_finish?.length ?? 0);
78
+ }
79
+ function w(e) {
80
+ let t = e.trim(), n = t.length;
81
+ for (; n > 1 && t[n - 1] === "/";) n--;
82
+ return t.slice(0, n);
83
+ }
84
+ function T(e, t, n = t + "s") {
85
+ return e === 1 ? t : n;
86
+ }
87
+ //#endregion
40
88
  //#region src/lib/dataLayer.tsx
41
- var b = 4, x = 5e3;
42
- function S(e, t, n) {
89
+ var E = 4, D = 5e3;
90
+ function O(e, t, n) {
43
91
  return {
44
- ...C(e, n),
92
+ ...k(e, n),
45
93
  pathLs: (t, n, r, i, a) => e.path({
46
94
  op: "ls",
47
95
  path: t,
@@ -60,14 +108,14 @@ function S(e, t, n) {
60
108
  }),
61
109
  documentPath: async (t, n, r) => {
62
110
  let i;
63
- for (let a = 0; a < b; a++) {
111
+ for (let a = 0; a < E; a++) {
64
112
  let a = await e.path({
65
113
  op: "ls",
66
114
  path: "/",
67
115
  scope: n,
68
116
  recursive: !0,
69
117
  kind_filter: "document",
70
- limit: x,
118
+ limit: D,
71
119
  ...i ? { cursor: i } : {}
72
120
  }, r), o = (a.entries ?? []).find((e) => e.resource_ref?.document_id === t);
73
121
  if (o) return o.full_path;
@@ -102,6 +150,7 @@ function S(e, t, n) {
102
150
  id: t,
103
151
  scope: n
104
152
  }, r),
153
+ documentsTransfer: (t, n) => e.document(b(t), n),
105
154
  documentGet: (t, n, r) => e.document({
106
155
  op: "get_document",
107
156
  id: t,
@@ -261,7 +310,7 @@ function S(e, t, n) {
261
310
  } } : {}
262
311
  };
263
312
  }
264
- function C(e, t) {
313
+ function k(e, t) {
265
314
  let n = e, r = (e) => e?.tenant ? `?tenant=${encodeURIComponent(e.tenant)}` : "", i = {};
266
315
  typeof n.ruleStatements == "function" ? i.documentRuleStatements = (e, t) => n.ruleStatements(e.action, e.ids ? { ids: e.ids } : { filter: e.filter }, {
267
316
  reason: e.reason,
@@ -286,35 +335,35 @@ function C(e, t) {
286
335
  });
287
336
  }), i;
288
337
  }
289
- var w = e(null);
290
- function T({ value: e, children: t }) {
291
- return /* @__PURE__ */ l(w.Provider, {
338
+ var A = e(null);
339
+ function j({ value: e, children: t }) {
340
+ return /* @__PURE__ */ l(A.Provider, {
292
341
  value: e,
293
342
  children: t
294
343
  });
295
344
  }
296
- function ee() {
297
- let e = n(w);
345
+ function M() {
346
+ let e = n(A);
298
347
  if (!e) throw Error("useExplorerData must be used within <PathExplorer> or <DocumentViewer> (no ExplorerDataLayer in context)");
299
348
  return e;
300
349
  }
301
- var E = 5e3;
302
- function D(e) {
350
+ var N = 5e3;
351
+ function P(e) {
303
352
  return e === "" ? "/" : e;
304
353
  }
305
- function O(e) {
354
+ function F(e) {
306
355
  let t = e.lastIndexOf("/");
307
356
  return t <= 0 ? "" : e.slice(0, t);
308
357
  }
309
- function k(e) {
358
+ function ee(e) {
310
359
  let t = [""], n = e.split("/").filter(Boolean), r = "";
311
360
  for (let e = 0; e < n.length - 1; e++) r = `${r}/${n[e]}`, t.push(r);
312
361
  return t;
313
362
  }
314
- function A(e) {
363
+ function te(e) {
315
364
  return e instanceof Error ? e.message : String(e);
316
365
  }
317
- function j(e, t) {
366
+ function ne(e, t) {
318
367
  return {
319
368
  entries: [...t, ...e.entries ?? []],
320
369
  nextCursor: e.next_cursor || void 0,
@@ -322,7 +371,7 @@ function j(e, t) {
322
371
  loading: !1
323
372
  };
324
373
  }
325
- var te = class {
374
+ var re = class {
326
375
  data;
327
376
  scope;
328
377
  browse;
@@ -356,7 +405,7 @@ var te = class {
356
405
  }
357
406
  reload(e) {
358
407
  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(E, Math.max(this.pageLimit, r)));
408
+ return this.fetchFirst(e, Math.min(N, Math.max(this.pageLimit, r)));
360
409
  }
361
410
  fetchFirst(e, t) {
362
411
  let n = (this.epoch.get(e) ?? 0) + 1;
@@ -368,15 +417,15 @@ var te = class {
368
417
  loaded: r?.loaded ?? !1,
369
418
  loading: !0
370
419
  });
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, []));
420
+ let i = this.data.pathLs(P(e), this.scope, !1, this.browse, { limit: t }).then((t) => {
421
+ this.epoch.get(e) === n && this.set(e, ne(t, []));
373
422
  }, (t) => {
374
423
  throw this.epoch.get(e) === n && this.set(e, {
375
424
  entries: r?.entries ?? [],
376
425
  nextCursor: r?.nextCursor,
377
426
  loaded: r?.loaded ?? !1,
378
427
  loading: !1,
379
- error: A(t)
428
+ error: te(t)
380
429
  }), t;
381
430
  });
382
431
  return this.track(e, i);
@@ -392,16 +441,16 @@ var te = class {
392
441
  loading: !0,
393
442
  error: void 0
394
443
  });
395
- let i = this.data.pathLs(D(e), this.scope, !1, this.browse, {
444
+ let i = this.data.pathLs(P(e), this.scope, !1, this.browse, {
396
445
  limit: this.pageLimit,
397
446
  cursor: n.nextCursor
398
447
  }).then((t) => {
399
- this.epoch.get(e) === r && this.set(e, j(t, n.entries));
448
+ this.epoch.get(e) === r && this.set(e, ne(t, n.entries));
400
449
  }, (t) => {
401
450
  throw this.epoch.get(e) === r && this.set(e, {
402
451
  ...n,
403
452
  loading: !1,
404
- error: A(t)
453
+ error: te(t)
405
454
  }), t;
406
455
  });
407
456
  return this.track(e, i);
@@ -427,7 +476,7 @@ var te = class {
427
476
  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
477
  this.publish();
429
478
  }
430
- let n = k(e).filter((e) => this.dirs.has(e));
479
+ let n = ee(e).filter((e) => this.dirs.has(e));
431
480
  await Promise.all(n.map((e) => this.reload(e)));
432
481
  }
433
482
  async refresh(e) {
@@ -439,11 +488,11 @@ var te = class {
439
488
  await Promise.all(n.map((e) => this.reload(e)));
440
489
  }
441
490
  };
442
- async function ne(e, t, n, r) {
491
+ async function ie(e, t, n, r) {
443
492
  let i = [], a;
444
493
  for (;;) {
445
- let o = await e.pathLs(D(t), n, !0, r, {
446
- limit: E,
494
+ let o = await e.pathLs(P(t), n, !0, r, {
495
+ limit: N,
447
496
  cursor: a
448
497
  });
449
498
  i.push(...o.entries ?? []);
@@ -452,7 +501,7 @@ async function ne(e, t, n, r) {
452
501
  a = s;
453
502
  }
454
503
  }
455
- function re(e) {
504
+ function ae(e) {
456
505
  let t = [];
457
506
  for (let n of e) {
458
507
  if (n.kind !== "document") continue;
@@ -463,7 +512,7 @@ function re(e) {
463
512
  }
464
513
  //#endregion
465
514
  //#region src/lib/createClient.ts
466
- function ie(e) {
515
+ function I(e) {
467
516
  let t = e.fetch;
468
517
  return new d({
469
518
  baseUrl: e.baseUrl,
@@ -471,21 +520,21 @@ function ie(e) {
471
520
  fetch: (e, n) => t ? t(e, n) : fetch(e, n)
472
521
  });
473
522
  }
474
- function M(e) {
523
+ function L(e) {
475
524
  let t = e.fetch, n = (e, n) => t ? t(e, n) : fetch(e, n);
476
525
  return (t) => {
477
526
  let r = {};
478
527
  return e.token && (r.Authorization = `Bearer ${e.token}`), n(e.baseUrl + t, { headers: r });
479
528
  };
480
529
  }
481
- var ae = class extends Error {
530
+ var oe = class extends Error {
482
531
  status;
483
532
  code;
484
533
  constructor(e, t, n) {
485
534
  super(e), this.name = "RequestError", this.status = t, this.code = n;
486
535
  }
487
536
  };
488
- function oe(e) {
537
+ function se(e) {
489
538
  let t = e.fetch, n = (e, n) => t ? t(e, n) : fetch(e, n);
490
539
  return async (t, r) => {
491
540
  let i = {
@@ -503,16 +552,16 @@ function oe(e) {
503
552
  } catch {}
504
553
  if (!a.ok) {
505
554
  let e = s && typeof s == "object" ? s : {};
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);
555
+ throw new oe(typeof e.error == "string" && e.error ? e.error : `${a.status} ${a.statusText}`.trim(), a.status, typeof e.code == "string" ? e.code : void 0);
507
556
  }
508
557
  return s;
509
558
  };
510
559
  }
511
560
  //#endregion
512
561
  //#region src/components/ExplorerRoot.tsx
513
- function N(e) {
562
+ function R(e) {
514
563
  let { dataLayer: t, client: n, connection: r } = e;
515
- return i(() => t || (n ? S(n) : r ? S(ie(r), M(r), oe(r)) : null), [
564
+ return i(() => t || (n ? O(n) : r ? O(I(r), L(r), se(r)) : null), [
516
565
  t,
517
566
  n,
518
567
  r?.baseUrl,
@@ -520,12 +569,12 @@ function N(e) {
520
569
  r?.fetch
521
570
  ]);
522
571
  }
523
- function P({ theme: e, dataLayer: t, children: n }) {
572
+ function z({ theme: e, dataLayer: t, children: n }) {
524
573
  let r = e ? { "data-theme": e } : {};
525
574
  return t ? /* @__PURE__ */ l("div", {
526
575
  className: "loomcycle-explorer",
527
576
  ...r,
528
- children: /* @__PURE__ */ l(T, {
577
+ children: /* @__PURE__ */ l(j, {
529
578
  value: t,
530
579
  children: n
531
580
  })
@@ -549,32 +598,32 @@ function P({ theme: e, dataLayer: t, children: n }) {
549
598
  }
550
599
  //#endregion
551
600
  //#region src/lib/docTrail.ts
552
- function se(e, t, n) {
601
+ function ce(e, t, n) {
553
602
  let r = e[e.length - 1];
554
603
  return [...r && r.documentId === t.documentId ? [...e.slice(0, -1), {
555
604
  ...r,
556
- ...F(t)
605
+ ...B(t)
557
606
  }] : [...e, t], n];
558
607
  }
559
- function ce(e, t) {
608
+ function le(e, t) {
560
609
  return t < 0 || t >= e.length - 1 ? e : e.slice(0, t + 1);
561
610
  }
562
- function le(e, t, n) {
611
+ function ue(e, t, n) {
563
612
  let r = e[e.length - 1];
564
613
  if (!r || r.documentId !== t) return e;
565
614
  let i = {
566
615
  ...r,
567
- ...F(n)
616
+ ...B(n)
568
617
  };
569
618
  return i.title === r.title && i.path === r.path ? e : [...e.slice(0, -1), i];
570
619
  }
571
- function F(e) {
620
+ function B(e) {
572
621
  return Object.fromEntries(Object.entries(e).filter(([, e]) => e !== void 0));
573
622
  }
574
- function ue(e) {
623
+ function de(e) {
575
624
  return e.title ? e.title : e.path ? e.path.slice(e.path.lastIndexOf("/") + 1) || e.path : e.documentId.slice(0, 8);
576
625
  }
577
- function I(e, t = 4) {
626
+ function V(e, t = 4) {
578
627
  let n = Array.from({ length: e }, (e, t) => ({
579
628
  kind: "crumb",
580
629
  index: t
@@ -590,24 +639,24 @@ function I(e, t = 4) {
590
639
  ...n.slice(e - r)
591
640
  ];
592
641
  }
593
- function de(e, t) {
642
+ function fe(e, t) {
594
643
  for (let n of e.values()) {
595
- let e = n.entries.find((e) => L(e) === t);
644
+ let e = n.entries.find((e) => H(e) === t);
596
645
  if (e) return e.full_path;
597
646
  }
598
647
  }
599
- function L(e) {
648
+ function H(e) {
600
649
  if (e.kind === "document") return e.resource_ref?.document_id || void 0;
601
650
  }
602
- function R(e, t) {
651
+ function U(e, t) {
603
652
  return t && e.some((e) => e.id === t) ? t : e.find((e) => !e.parent_id)?.id;
604
653
  }
605
654
  //#endregion
606
655
  //#region src/components/DocTrail.tsx
607
- function fe({ trail: e, onJump: t }) {
656
+ function pe({ trail: e, onJump: t }) {
608
657
  let [n, r] = o(!1);
609
658
  if (e.length < 2) return null;
610
- let i = e.length - 1, a = e[i - 1], s = I(e.length, n ? e.length : void 0);
659
+ let i = e.length - 1, a = e[i - 1], s = V(e.length, n ? e.length : void 0);
611
660
  return /* @__PURE__ */ u("nav", {
612
661
  className: "doc-trail",
613
662
  "aria-label": "Documents you came through",
@@ -615,7 +664,7 @@ function fe({ trail: e, onJump: t }) {
615
664
  type: "button",
616
665
  className: "doc-trail-back",
617
666
  onClick: () => t(i - 1),
618
- title: `Back to ${ue(a)}`,
667
+ title: `Back to ${de(a)}`,
619
668
  children: "← Back"
620
669
  }), /* @__PURE__ */ l("ol", {
621
670
  className: "doc-trail-list",
@@ -625,7 +674,7 @@ function fe({ trail: e, onJump: t }) {
625
674
  type: "button",
626
675
  className: "doc-trail-gap",
627
676
  onClick: () => r(!0),
628
- title: `Show ${n.hidden.length} more: ${n.hidden.map((t) => ue(e[t])).join(" › ")}`,
677
+ title: `Show ${n.hidden.length} more: ${n.hidden.map((t) => de(e[t])).join(" › ")}`,
629
678
  "aria-label": `Show ${n.hidden.length} hidden documents`,
630
679
  children: "…"
631
680
  })
@@ -634,8 +683,8 @@ function fe({ trail: e, onJump: t }) {
634
683
  children: /* @__PURE__ */ l("span", {
635
684
  className: "doc-trail-current",
636
685
  "aria-current": "page",
637
- title: ue(e[i]),
638
- children: ue(e[i])
686
+ title: de(e[i]),
687
+ children: de(e[i])
639
688
  })
640
689
  }, n.index) : /* @__PURE__ */ l("li", {
641
690
  className: "doc-trail-item",
@@ -643,17 +692,175 @@ function fe({ trail: e, onJump: t }) {
643
692
  type: "button",
644
693
  className: "doc-trail-crumb",
645
694
  onClick: () => t(n.index),
646
- title: ue(e[n.index]),
647
- children: ue(e[n.index])
695
+ title: de(e[n.index]),
696
+ children: de(e[n.index])
648
697
  })
649
698
  }, n.index))
650
699
  })]
651
700
  });
652
701
  }
653
702
  //#endregion
703
+ //#region src/components/TransferModal.tsx
704
+ function me({ data: e, scope: t, browse: n, documentId: r, underPath: a, fromPath: s, onClose: c, onDone: d }) {
705
+ let [f, p] = o("copy"), [m, h] = o(t === "tenant" ? "user" : "tenant"), [g, _] = o(s), [v, y] = o(!1), [w, T] = o(null), [E, D] = o(null), [O, k] = o(!1), [A, j] = o(null), M = i(() => ({
706
+ op: f,
707
+ scope: t,
708
+ toScope: m,
709
+ documentId: r,
710
+ underPath: a,
711
+ from: s,
712
+ to: g,
713
+ dropDangling: v,
714
+ dryRun: !0
715
+ }), [
716
+ f,
717
+ t,
718
+ m,
719
+ r,
720
+ a,
721
+ s,
722
+ g,
723
+ v
724
+ ]), N = JSON.stringify(b(M)), P = x(M), F = w && w.key === N ? w.res : null, ee = F ? C(f, F, v) : !1, te = F ? f === "move" ? (F.counts?.documents ?? 0) + (F.to_finish?.length ?? 0) : F.counts?.documents ?? 0 : 0, ne = async (t) => {
725
+ if (t.preventDefault(), E) c();
726
+ else if (!P && e.documentsTransfer) {
727
+ k(!0), j(null);
728
+ try {
729
+ if (!F) T({
730
+ key: N,
731
+ res: await e.documentsTransfer(M, n)
732
+ });
733
+ else {
734
+ let t = {
735
+ ...M,
736
+ dryRun: !1,
737
+ expectCount: F.counts?.documents ?? 0
738
+ }, r = await e.documentsTransfer(t, n);
739
+ D(r), d(t, r);
740
+ }
741
+ } catch (e) {
742
+ j(e instanceof Error ? e.message : String(e));
743
+ } finally {
744
+ k(!1);
745
+ }
746
+ }
747
+ }, re = E ? "close" : O ? "working…" : F ? `${f} ${te} document${te === 1 ? "" : "s"}` : "check", ie = E ?? F;
748
+ return /* @__PURE__ */ l("div", {
749
+ className: "modal-overlay",
750
+ onClick: O ? void 0 : c,
751
+ children: /* @__PURE__ */ u("form", {
752
+ className: "modal",
753
+ onClick: (e) => e.stopPropagation(),
754
+ onSubmit: ne,
755
+ children: [
756
+ /* @__PURE__ */ u("div", {
757
+ className: "modal-header sticky-top",
758
+ children: [/* @__PURE__ */ u("h3", { children: [
759
+ "Copy or move the ",
760
+ r ? "document" : "documents under",
761
+ " ",
762
+ s
763
+ ] }), /* @__PURE__ */ u("div", {
764
+ className: "modal-buttons modal-buttons-top",
765
+ children: [!E && /* @__PURE__ */ l("button", {
766
+ type: "button",
767
+ onClick: c,
768
+ disabled: O,
769
+ children: "cancel"
770
+ }), /* @__PURE__ */ l("button", {
771
+ type: "submit",
772
+ className: F && f === "move" && !E ? "danger" : "primary",
773
+ disabled: O || !E && (!!P || ee),
774
+ children: re
775
+ })]
776
+ })]
777
+ }),
778
+ /* @__PURE__ */ u("p", {
779
+ className: "modal-context",
780
+ children: [
781
+ "A copy gets new ids and leaves the source as it is. A move keeps every id and removes the documents from ",
782
+ /* @__PURE__ */ l("code", { children: t }),
783
+ ". Relations between the documents go with them."
784
+ ]
785
+ }),
786
+ /* @__PURE__ */ l("div", {
787
+ className: "paths-nav-switch",
788
+ role: "group",
789
+ "aria-label": "Copy or move",
790
+ children: ["copy", "move"].map((e) => /* @__PURE__ */ l("button", {
791
+ type: "button",
792
+ "aria-pressed": f === e,
793
+ className: f === e ? "active" : void 0,
794
+ disabled: O || !!E,
795
+ onClick: () => p(e),
796
+ children: e
797
+ }, e))
798
+ }),
799
+ /* @__PURE__ */ u("label", {
800
+ className: "path-field",
801
+ children: [/* @__PURE__ */ l("span", { children: "To scope" }), /* @__PURE__ */ u("select", {
802
+ value: m,
803
+ disabled: O || !!E,
804
+ onChange: (e) => h(e.target.value),
805
+ children: [
806
+ /* @__PURE__ */ l("option", {
807
+ value: "user",
808
+ children: "user"
809
+ }),
810
+ /* @__PURE__ */ l("option", {
811
+ value: "agent",
812
+ children: "agent"
813
+ }),
814
+ /* @__PURE__ */ l("option", {
815
+ value: "tenant",
816
+ children: "tenant"
817
+ })
818
+ ]
819
+ })]
820
+ }),
821
+ /* @__PURE__ */ u("label", {
822
+ className: "path-field",
823
+ children: [/* @__PURE__ */ l("span", { children: "New path" }), /* @__PURE__ */ l("input", {
824
+ className: "path-modal-input",
825
+ value: g,
826
+ disabled: O || !!E,
827
+ onChange: (e) => _(e.target.value)
828
+ })]
829
+ }),
830
+ f === "move" && /* @__PURE__ */ l("label", {
831
+ className: "path-field",
832
+ children: /* @__PURE__ */ u("span", { children: [
833
+ /* @__PURE__ */ l("input", {
834
+ type: "checkbox",
835
+ checked: v,
836
+ disabled: O || !!E,
837
+ onChange: (e) => y(e.target.checked)
838
+ }),
839
+ " ",
840
+ "Drop relations to documents outside the set"
841
+ ] })
842
+ }),
843
+ P && /* @__PURE__ */ l("div", {
844
+ className: "modal-err",
845
+ children: P
846
+ }),
847
+ ie && /* @__PURE__ */ l("div", {
848
+ className: "modal-context",
849
+ "aria-live": "polite",
850
+ children: S(f, ie).map((e, t) => e.startsWith(" ") ? /* @__PURE__ */ l("div", { children: /* @__PURE__ */ l("code", { children: e.trim() }) }, t) : /* @__PURE__ */ l("div", { children: e }, t))
851
+ }),
852
+ A && /* @__PURE__ */ l("div", {
853
+ className: "modal-err",
854
+ children: A
855
+ })
856
+ ]
857
+ })
858
+ });
859
+ }
860
+ //#endregion
654
861
  //#region src/components/Splitter.tsx
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 }) {
862
+ var W = 6;
863
+ function he({ children: e, defaultLeftWidth: n = 380, minLeftWidth: i = 180, minRightWidth: s = 240, storageKey: c, className: d, hideRight: f = !1 }) {
657
864
  let p = () => {
658
865
  if (c) {
659
866
  let e = localStorage.getItem(c), t = e ? parseInt(e, 10) : NaN;
@@ -675,7 +882,7 @@ function pe({ children: e, defaultLeftWidth: n = 380, minLeftWidth: i = 180, min
675
882
  e.preventDefault(), b(!0), e.target.setPointerCapture(e.pointerId);
676
883
  }, []), S = t((e) => {
677
884
  if (!y || !v.current) return;
678
- let t = v.current.getBoundingClientRect(), n = e.clientX - t.left, r = t.width - s - z;
885
+ let t = v.current.getBoundingClientRect(), n = e.clientX - t.left, r = t.width - s - W;
679
886
  h(Math.max(i, Math.min(n, r)));
680
887
  }, [
681
888
  y,
@@ -690,7 +897,7 @@ function pe({ children: e, defaultLeftWidth: n = 380, minLeftWidth: i = 180, min
690
897
  return /* @__PURE__ */ u("div", {
691
898
  ref: v,
692
899
  className: `splitter ${d ?? ""} ${y ? "dragging" : ""}`,
693
- style: { gridTemplateColumns: f ? "1fr 0 0" : `min(${m}px, calc(100% - ${s + z}px)) ${z}px 1fr` },
900
+ style: { gridTemplateColumns: f ? "1fr 0 0" : `min(${m}px, calc(100% - ${s + W}px)) ${W}px 1fr` },
694
901
  children: [
695
902
  /* @__PURE__ */ l("div", {
696
903
  className: "splitter-pane splitter-left",
@@ -717,18 +924,18 @@ function pe({ children: e, defaultLeftWidth: n = 380, minLeftWidth: i = 180, min
717
924
  }
718
925
  //#endregion
719
926
  //#region src/lib/imageUpload.ts
720
- var B = [
927
+ var ge = [
721
928
  "image/png",
722
929
  "image/jpeg",
723
930
  "image/gif",
724
931
  "image/webp"
725
932
  ];
726
- function V(e) {
727
- return B.includes(e);
933
+ function G(e) {
934
+ return ge.includes(e);
728
935
  }
729
- function H(e) {
936
+ function _e(e) {
730
937
  return new Promise((t, n) => {
731
- if (!V(e.type)) {
938
+ if (!G(e.type)) {
732
939
  n(/* @__PURE__ */ Error(`unsupported image type "${e.type || "unknown"}" (png, jpeg, gif, webp only)`));
733
940
  return;
734
941
  }
@@ -742,11 +949,11 @@ function H(e) {
742
949
  }, r.readAsDataURL(e);
743
950
  });
744
951
  }
745
- function me(e) {
952
+ function ve(e) {
746
953
  if (!e) return null;
747
954
  for (let t = 0; t < e.length; t++) {
748
955
  let n = e[t];
749
- if (n.kind === "file" && V(n.type)) {
956
+ if (n.kind === "file" && G(n.type)) {
750
957
  let e = n.getAsFile();
751
958
  if (e) return e;
752
959
  }
@@ -755,8 +962,8 @@ function me(e) {
755
962
  }
756
963
  //#endregion
757
964
  //#region src/lib/edgePages.ts
758
- var he = 20;
759
- async function U(e, t, n, r, i = 20) {
965
+ var ye = 20;
966
+ async function be(e, t, n, r, i = 20) {
760
967
  let a = [], o;
761
968
  for (let s = 0; s < i; s++) {
762
969
  let i = await e.documentGetEdges(t, n, r, o ? { after: o } : void 0);
@@ -781,7 +988,7 @@ async function U(e, t, n, r, i = 20) {
781
988
  }
782
989
  //#endregion
783
990
  //#region src/lib/chunkAncestry.ts
784
- function ge(e, t) {
991
+ function xe(e, t) {
785
992
  if (!t) return [];
786
993
  let n = new Map(e.map((e) => [e.id, e])), r = /* @__PURE__ */ new Set([t]), i = [], a = n.get(t)?.parent_id;
787
994
  for (; a && !r.has(a);) {
@@ -793,48 +1000,48 @@ function ge(e, t) {
793
1000
  }
794
1001
  //#endregion
795
1002
  //#region src/lib/statement.ts
796
- var _e = /* @__PURE__ */ new Set(["manual", "wikilink"]), ve = 280;
797
- function ye(e) {
1003
+ var K = /* @__PURE__ */ new Set(["manual", "wikilink"]), Se = 280;
1004
+ function Ce(e) {
798
1005
  return e.status && e.status !== "asserted" ? e.status : void 0;
799
1006
  }
800
- function W(e) {
801
- return e.method && !_e.has(e.method) ? e.method : void 0;
1007
+ function we(e) {
1008
+ return e.method && !K.has(e.method) ? e.method : void 0;
802
1009
  }
803
- function G(e) {
1010
+ function q(e) {
804
1011
  return e.status === "proposed" && !!e.id;
805
1012
  }
806
- function be(e) {
1013
+ function Te(e) {
807
1014
  return new Date(Math.floor(e / 1e6)).toISOString().slice(0, 10);
808
1015
  }
809
- function xe(e) {
810
- let t = e.valid_at == null ? void 0 : be(e.valid_at), n = e.invalid_at == null ? void 0 : be(e.invalid_at);
1016
+ function Ee(e) {
1017
+ let t = e.valid_at == null ? void 0 : Te(e.valid_at), n = e.invalid_at == null ? void 0 : Te(e.invalid_at);
811
1018
  if (t && n) return `valid ${t} → ${n}`;
812
1019
  if (t) return `valid from ${t}`;
813
1020
  if (n) return `valid until ${n}`;
814
1021
  }
815
- function Se(e) {
1022
+ function De(e) {
816
1023
  if (e.judged_at == null) return;
817
- let t = `judged by ${e.judged_by || "a judge"} on ${be(e.judged_at)}`;
1024
+ let t = `judged by ${e.judged_by || "a judge"} on ${Te(e.judged_at)}`;
818
1025
  return e.judge_reason ? `${t}: ${e.judge_reason}` : t;
819
1026
  }
820
- function K(e, t = 3) {
1027
+ function Oe(e, t = 3) {
821
1028
  let n = (e.evidence ?? []).slice(0, t), r = Math.max(e.evidence_count ?? 0, e.evidence?.length ?? 0);
822
1029
  return {
823
1030
  rows: n,
824
1031
  more: Math.max(0, r - n.length)
825
1032
  };
826
1033
  }
827
- function Ce(e, t = ve) {
1034
+ function ke(e, t = Se) {
828
1035
  let n = e.replace(/\s+/g, " ").trim();
829
1036
  return n.length > t ? n.slice(0, t - 1) + "…" : n;
830
1037
  }
831
1038
  //#endregion
832
1039
  //#region src/lib/ruling.ts
833
- var we = 1e3, Te = 3, Ee = 1e3;
834
- function De(e) {
1040
+ var J = 1e3, Ae = 3, je = 1e3;
1041
+ function Me(e) {
835
1042
  return !!e && typeof e == "object" && e.code === "queue_changed";
836
1043
  }
837
- async function Oe(e, t, n = {}) {
1044
+ async function Ne(e, t, n = {}) {
838
1045
  let r = {
839
1046
  action: t.action,
840
1047
  ...t.ids ? { ids: t.ids } : { filter: t.filter ?? {} },
@@ -863,7 +1070,7 @@ async function Oe(e, t, n = {}) {
863
1070
  }
864
1071
  if (s.matched === 0 || !await o(s, "first")) return i;
865
1072
  let c = 0;
866
- for (let t = 0; t < Ee && s.to_rule !== 0; t++) {
1073
+ for (let t = 0; t < je && s.to_rule !== 0; t++) {
867
1074
  let t;
868
1075
  try {
869
1076
  t = await e.rule({
@@ -872,7 +1079,7 @@ async function Oe(e, t, n = {}) {
872
1079
  expect_count: s.matched
873
1080
  });
874
1081
  } catch (e) {
875
- if (!De(e) || c >= 3) return i.error = e, i;
1082
+ if (!Me(e) || c >= 3) return i.error = e, i;
876
1083
  c++;
877
1084
  try {
878
1085
  s = await a();
@@ -900,7 +1107,7 @@ async function Oe(e, t, n = {}) {
900
1107
  }
901
1108
  return i;
902
1109
  }
903
- async function ke(e, t) {
1110
+ async function Y(e, t) {
904
1111
  let n = {
905
1112
  reverted: 0,
906
1113
  changed: 0,
@@ -914,21 +1121,21 @@ async function ke(e, t) {
914
1121
  }
915
1122
  return n;
916
1123
  }
917
- function Ae(e) {
918
- return Math.max(1, Math.ceil(e / we));
1124
+ function X(e) {
1125
+ return Math.max(1, Math.ceil(e / J));
919
1126
  }
920
1127
  //#endregion
921
1128
  //#region src/lib/bulkReview.ts
922
- function q(e) {
1129
+ function Z(e) {
923
1130
  return e === "tenant" || e === "user" ? e : void 0;
924
1131
  }
925
- function je(e, t) {
926
- return e.documentRuleStatements ? q(t) : void 0;
1132
+ function Pe(e, t) {
1133
+ return e.documentRuleStatements ? Z(t) : void 0;
927
1134
  }
928
- function Me(e, t) {
929
- return e.filter((e) => G(e) && !!e.id && e.from_document_id === t);
1135
+ function Fe(e, t) {
1136
+ return e.filter((e) => q(e) && !!e.id && e.from_document_id === t);
930
1137
  }
931
- function Ne(e, t, n, r) {
1138
+ function Ie(e, t, n, r) {
932
1139
  return e ? {
933
1140
  proposals: t,
934
1141
  scope: e,
@@ -936,8 +1143,8 @@ function Ne(e, t, n, r) {
936
1143
  onChanged: r
937
1144
  } : void 0;
938
1145
  }
939
- function J(e, t, n) {
940
- return e.documentRuleStatements ? Oe({ rule: (n) => e.documentRuleStatements(n, t.browse) }, {
1146
+ function Le(e, t, n) {
1147
+ return e.documentRuleStatements ? Ne({ rule: (n) => e.documentRuleStatements(n, t.browse) }, {
941
1148
  action: t.action,
942
1149
  ...t.ids && t.ids.length > 0 ? { ids: t.ids } : { filter: { from_document_id: t.documentId } },
943
1150
  ...t.reason ? { reason: t.reason } : {},
@@ -945,13 +1152,13 @@ function J(e, t, n) {
945
1152
  ...t.scope === "user" && t.browse?.scopeId ? { scopeId: t.browse.scopeId } : {}
946
1153
  }, n) : Promise.reject(/* @__PURE__ */ Error("this data layer cannot rule in bulk"));
947
1154
  }
948
- function Pe(e, t) {
1155
+ function Re(e, t) {
949
1156
  let n = (e) => e.toLocaleString("en-US"), r = [`${e === "accept" ? "Accepted" : "Rejected"} ${n(t.ruled)} statement${t.ruled === 1 ? "" : "s"}`];
950
1157
  return t.failed > 0 && r.push(`${n(t.failed)} did not take the ruling`), t.skipped > 0 && r.push(`${n(t.skipped)} skipped: not yours to rule`), r.join("; ") + ".";
951
1158
  }
952
1159
  //#endregion
953
1160
  //#region src/lib/colorScheme.ts
954
- var Y = {
1161
+ var Q = {
955
1162
  "doc.rfc.draft": "#c99a3a",
956
1163
  "doc.rfc.review": "#6a7bd6",
957
1164
  "doc.rfc.confirmed": "#3a9ad6",
@@ -970,28 +1177,28 @@ var Y = {
970
1177
  "chunk.backlog": "#8a8f98",
971
1178
  "chunk.implementation": "#d1863a",
972
1179
  "chunk.merged": "#3aa06a"
973
- }, Fe = .16;
974
- function Ie(e) {
975
- return e && Object.keys(e).length > 0 ? e : Y;
1180
+ }, ze = .16;
1181
+ function Be(e) {
1182
+ return e && Object.keys(e).length > 0 ? e : Q;
976
1183
  }
977
- function Le(e, t, n) {
1184
+ function Ve(e, t, n) {
978
1185
  let r = e ?? "", i = t ?? "";
979
1186
  if (r && i && n[`doc.${r}.${i}`]) return n[`doc.${r}.${i}`];
980
1187
  if (r && n[`doc.${r}`]) return n[`doc.${r}`];
981
1188
  }
982
- function X(e, t) {
1189
+ function He(e, t) {
983
1190
  let n = e ?? "";
984
1191
  return n ? t[`chunk.${n}`] : void 0;
985
1192
  }
986
- function Z(e) {
1193
+ function Ue(e) {
987
1194
  let t = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());
988
1195
  if (!t) return;
989
1196
  let n = t[1];
990
- return n.length === 3 && (n = n[0] + n[0] + n[1] + n[1] + n[2] + n[2]), `rgba(${parseInt(n.slice(0, 2), 16)}, ${parseInt(n.slice(2, 4), 16)}, ${parseInt(n.slice(4, 6), 16)}, ${Fe})`;
1197
+ return n.length === 3 && (n = n[0] + n[0] + n[1] + n[1] + n[2] + n[2]), `rgba(${parseInt(n.slice(0, 2), 16)}, ${parseInt(n.slice(2, 4), 16)}, ${parseInt(n.slice(4, 6), 16)}, ${ze})`;
991
1198
  }
992
- function Re(e) {
1199
+ function We(e) {
993
1200
  if (!e) return;
994
- let t = Z(e);
1201
+ let t = Ue(e);
995
1202
  if (t) return {
996
1203
  background: t,
997
1204
  borderLeft: `3px solid ${e}`
@@ -999,7 +1206,7 @@ function Re(e) {
999
1206
  }
1000
1207
  //#endregion
1001
1208
  //#region src/lib/clipboard.ts
1002
- async function Q(e) {
1209
+ async function Ge(e) {
1003
1210
  try {
1004
1211
  return typeof navigator > "u" || !navigator.clipboard ? !1 : (await navigator.clipboard.writeText(e), !0);
1005
1212
  } catch {
@@ -1008,10 +1215,10 @@ async function Q(e) {
1008
1215
  }
1009
1216
  //#endregion
1010
1217
  //#region src/components/IdCopy.tsx
1011
- function ze({ value: e, label: t, compact: n, title: r }) {
1218
+ function Ke({ value: e, label: t, compact: n, title: r }) {
1012
1219
  let [i, a] = o("idle"), s = async (t) => {
1013
1220
  t.stopPropagation(), t.preventDefault();
1014
- let n = await Q(e);
1221
+ let n = await Ge(e);
1015
1222
  a(n ? "copied" : "error"), window.setTimeout(() => a("idle"), n ? 1200 : 1500);
1016
1223
  }, c = i === "copied" ? "✓" : i === "error" ? "✗" : "⎘", d = r ?? `Copy ${t ?? "id"}: ${e}`, f = /* @__PURE__ */ l("button", {
1017
1224
  type: "button",
@@ -1039,7 +1246,7 @@ function ze({ value: e, label: t, compact: n, title: r }) {
1039
1246
  }
1040
1247
  //#endregion
1041
1248
  //#region src/components/DocumentChunkTree.tsx
1042
- function Be(e) {
1249
+ function qe(e) {
1043
1250
  let t = /* @__PURE__ */ new Map();
1044
1251
  e.forEach((e) => t.set(e.id, {
1045
1252
  row: e,
@@ -1055,17 +1262,17 @@ function Be(e) {
1055
1262
  };
1056
1263
  return r(n), n;
1057
1264
  }
1058
- function Ve(e) {
1265
+ function Je(e) {
1059
1266
  return e === "image" ? "🖼" : e === "mermaid" ? "📊" : "";
1060
1267
  }
1061
- function He(e, t) {
1268
+ function $(e, t) {
1062
1269
  for (let n of e) {
1063
1270
  if (n.row.id === t) return n;
1064
- let e = He(n.children, t);
1271
+ let e = $(n.children, t);
1065
1272
  if (e) return e;
1066
1273
  }
1067
1274
  }
1068
- function $({ tree: e, selectedId: n, onSelect: i, colorEnabled: a, scheme: s, linkedIds: c }) {
1275
+ function Ye({ tree: e, selectedId: n, onSelect: i, colorEnabled: a, scheme: s, linkedIds: c }) {
1069
1276
  let [u, d] = o(() => /* @__PURE__ */ new Map()), f = t((e) => {
1070
1277
  d((t) => {
1071
1278
  let n = new Map(t);
@@ -1074,20 +1281,20 @@ function $({ tree: e, selectedId: n, onSelect: i, colorEnabled: a, scheme: s, li
1074
1281
  }, []);
1075
1282
  r(() => {
1076
1283
  if (!n) return;
1077
- let t = Ue(e, n);
1284
+ let t = Xe(e, n);
1078
1285
  t.length !== 0 && d((e) => {
1079
1286
  let n = !1, r = new Map(e);
1080
1287
  for (let e of t) r.get(e) === !1 && (r.set(e, !0), n = !0);
1081
1288
  return n ? r : e;
1082
1289
  });
1083
1290
  }, [e, n]);
1084
- let p = a ? Ie(s) : null;
1291
+ let p = a ? Be(s) : null;
1085
1292
  return e.length === 0 ? /* @__PURE__ */ l("div", {
1086
1293
  className: "empty",
1087
1294
  children: /* @__PURE__ */ l("p", { children: "No chunks." })
1088
1295
  }) : /* @__PURE__ */ l("ul", {
1089
1296
  className: "tree chunk-tree",
1090
- children: e.map((e) => /* @__PURE__ */ l(We, {
1297
+ children: e.map((e) => /* @__PURE__ */ l(Ze, {
1091
1298
  node: e,
1092
1299
  expanded: u,
1093
1300
  toggle: f,
@@ -1098,7 +1305,7 @@ function $({ tree: e, selectedId: n, onSelect: i, colorEnabled: a, scheme: s, li
1098
1305
  }, e.row.id))
1099
1306
  });
1100
1307
  }
1101
- function Ue(e, t) {
1308
+ function Xe(e, t) {
1102
1309
  let n = [], r = (e, i) => {
1103
1310
  for (let a of e) {
1104
1311
  if (a.row.id === t) return n.push(...i), !0;
@@ -1108,8 +1315,8 @@ function Ue(e, t) {
1108
1315
  };
1109
1316
  return r(e, []), n;
1110
1317
  }
1111
- function We({ node: e, expanded: t, toggle: n, selectedId: r, onSelect: i, tintScheme: a, linkedIds: o }) {
1112
- let s = e.children.length > 0, c = t.get(e.row.id) !== !1, d = r === e.row.id, f = a ? Re(X(e.row.status, a)) : void 0, p = o?.has(e.row.id);
1318
+ function Ze({ node: e, expanded: t, toggle: n, selectedId: r, onSelect: i, tintScheme: a, linkedIds: o }) {
1319
+ let s = e.children.length > 0, c = t.get(e.row.id) !== !1, d = r === e.row.id, f = a ? We(He(e.row.status, a)) : void 0, p = o?.has(e.row.id);
1113
1320
  return /* @__PURE__ */ u("li", {
1114
1321
  className: `node chunk-node ${d ? "selected" : ""}`,
1115
1322
  children: [/* @__PURE__ */ u("div", {
@@ -1132,10 +1339,10 @@ function We({ node: e, expanded: t, toggle: n, selectedId: r, onSelect: i, tintS
1132
1339
  onClick: () => i(e),
1133
1340
  title: e.row.title,
1134
1341
  children: [
1135
- Ve(e.row.type) && /* @__PURE__ */ l("span", {
1342
+ Je(e.row.type) && /* @__PURE__ */ l("span", {
1136
1343
  className: "chunk-type-icon",
1137
1344
  "aria-hidden": !0,
1138
- children: Ve(e.row.type)
1345
+ children: Je(e.row.type)
1139
1346
  }),
1140
1347
  /* @__PURE__ */ l("span", {
1141
1348
  className: "chunk-title",
@@ -1157,7 +1364,7 @@ function We({ node: e, expanded: t, toggle: n, selectedId: r, onSelect: i, tintS
1157
1364
  })
1158
1365
  ]
1159
1366
  }),
1160
- /* @__PURE__ */ l(ze, {
1367
+ /* @__PURE__ */ l(Ke, {
1161
1368
  value: e.row.id,
1162
1369
  compact: !0,
1163
1370
  title: `Copy chunk id: ${e.row.id}`
@@ -1165,7 +1372,7 @@ function We({ node: e, expanded: t, toggle: n, selectedId: r, onSelect: i, tintS
1165
1372
  ]
1166
1373
  }), s && c && /* @__PURE__ */ l("ul", {
1167
1374
  className: "children chunk-children",
1168
- children: e.children.map((e) => /* @__PURE__ */ l(We, {
1375
+ children: e.children.map((e) => /* @__PURE__ */ l(Ze, {
1169
1376
  node: e,
1170
1377
  expanded: t,
1171
1378
  toggle: n,
@@ -1179,12 +1386,12 @@ function We({ node: e, expanded: t, toggle: n, selectedId: r, onSelect: i, tintS
1179
1386
  }
1180
1387
  //#endregion
1181
1388
  //#region src/components/Mermaid.tsx
1182
- var Ge = 0;
1183
- function Ke(e) {
1389
+ var Qe = 0;
1390
+ function $e(e) {
1184
1391
  let t = e?.closest("g.node");
1185
1392
  return t ? /flowchart-(.+)-\d+$/.exec(t.id)?.[1] : void 0;
1186
1393
  }
1187
- function qe({ code: e, onNodeClick: t }) {
1394
+ function et({ code: e, onNodeClick: t }) {
1188
1395
  let n = a(null), [i, s] = o({});
1189
1396
  return r(() => {
1190
1397
  let t = !1;
@@ -1196,7 +1403,7 @@ function qe({ code: e, onNodeClick: t }) {
1196
1403
  theme: a ? "dark" : "default",
1197
1404
  securityLevel: "strict"
1198
1405
  });
1199
- let { svg: o } = await r.render(`lc-mmd-${Ge++}`, e);
1406
+ let { svg: o } = await r.render(`lc-mmd-${Qe++}`, e);
1200
1407
  t || s({ svg: o });
1201
1408
  } catch {
1202
1409
  t || s({ err: !0 });
@@ -1212,7 +1419,7 @@ function qe({ code: e, onNodeClick: t }) {
1212
1419
  ref: n,
1213
1420
  className: t ? "md-mermaid md-mermaid-nav" : "md-mermaid",
1214
1421
  onClick: t && ((e) => {
1215
- let n = Ke(e.target);
1422
+ let n = $e(e.target);
1216
1423
  n && t(n);
1217
1424
  }),
1218
1425
  dangerouslySetInnerHTML: { __html: i.svg }
@@ -1224,17 +1431,17 @@ function qe({ code: e, onNodeClick: t }) {
1224
1431
  }
1225
1432
  //#endregion
1226
1433
  //#region src/components/ChunkEditorModal.tsx
1227
- function Je({ chunk: e, scope: t, browse: n, onClose: i, onSaved: a }) {
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);
1434
+ function tt({ chunk: e, scope: t, browse: n, onClose: i, onSaved: a }) {
1435
+ let s = M(), [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
1436
  r(() => {
1230
1437
  if (!O) return;
1231
1438
  let e = setTimeout(() => j(g), 400);
1232
1439
  return () => clearTimeout(e);
1233
1440
  }, [g, O]);
1234
- let te = async (r) => {
1441
+ let N = async (r) => {
1235
1442
  T(null), C(!0);
1236
1443
  try {
1237
- let { mediaType: o, data: c } = await H(r);
1444
+ let { mediaType: o, data: c } = await _e(r);
1238
1445
  a(await s.documentSetAsset(e.id, o, c, r.name, t, n)), i();
1239
1446
  } catch (e) {
1240
1447
  T(e instanceof Error ? e.message : String(e)), C(!1);
@@ -1336,7 +1543,7 @@ function Je({ chunk: e, scope: t, browse: n, onClose: i, onSaved: a }) {
1336
1543
  disabled: S,
1337
1544
  onChange: (e) => {
1338
1545
  let t = e.target.files?.[0];
1339
- t && te(t);
1546
+ t && N(t);
1340
1547
  }
1341
1548
  })]
1342
1549
  }),
@@ -1353,7 +1560,7 @@ function Je({ chunk: e, scope: t, browse: n, onClose: i, onSaved: a }) {
1353
1560
  className: "path-field",
1354
1561
  children: [/* @__PURE__ */ l("span", { children: "Preview" }), /* @__PURE__ */ l("div", {
1355
1562
  className: "chunk-mermaid-preview",
1356
- children: A.trim() ? /* @__PURE__ */ l(qe, { code: A }) : /* @__PURE__ */ l("p", {
1563
+ children: A.trim() ? /* @__PURE__ */ l(et, { code: A }) : /* @__PURE__ */ l("p", {
1357
1564
  className: "doc-empty-body",
1358
1565
  children: "(enter Mermaid source above)"
1359
1566
  })
@@ -1375,8 +1582,8 @@ function Je({ chunk: e, scope: t, browse: n, onClose: i, onSaved: a }) {
1375
1582
  }
1376
1583
  //#endregion
1377
1584
  //#region src/components/SubjectTypeModal.tsx
1378
- function Ye({ chunk: e, scope: t, browse: n, onClose: i, onSaved: a }) {
1379
- let s = ee(), [c, d] = o(null), [f, p] = o(e.type ?? ""), [m, h] = o(!1), [g, _] = o(null), [v, b] = o(null);
1585
+ function nt({ chunk: e, scope: t, browse: n, onClose: i, onSaved: a }) {
1586
+ let s = M(), [c, d] = o(null), [f, p] = o(e.type ?? ""), [m, h] = o(!1), [g, _] = o(null), [v, b] = o(null);
1380
1587
  r(() => {
1381
1588
  let e = !1;
1382
1589
  return s.documentEntityTypes?.(t, n).then((t) => {
@@ -1468,18 +1675,18 @@ function Ye({ chunk: e, scope: t, browse: n, onClose: i, onSaved: a }) {
1468
1675
  }
1469
1676
  //#endregion
1470
1677
  //#region src/lib/classify.ts
1471
- function Xe(e) {
1678
+ function rt(e) {
1472
1679
  return Array.isArray(e) && e.every((e) => typeof e == "string");
1473
1680
  }
1474
- function Ze(e) {
1681
+ function it(e) {
1475
1682
  if (!e || typeof e != "object") return;
1476
1683
  let t = e.classification;
1477
1684
  if (!t || typeof t != "object" || Array.isArray(t)) return;
1478
1685
  let n = t, r = {};
1479
- return typeof n.by == "string" && (r.by = n.by), typeof n.at == "number" && (r.at = n.at), typeof n.applied_type == "string" && n.applied_type && (r.applied_type = n.applied_type), typeof n.proposed_type == "string" && n.proposed_type && (r.proposed_type = n.proposed_type), n.proposed_fields && typeof n.proposed_fields == "object" && !Array.isArray(n.proposed_fields) && (r.proposed_fields = n.proposed_fields), Xe(n.proposed_tags) && (r.proposed_tags = n.proposed_tags), Xe(n.statements) && (r.statements = n.statements), r;
1686
+ return typeof n.by == "string" && (r.by = n.by), typeof n.at == "number" && (r.at = n.at), typeof n.applied_type == "string" && n.applied_type && (r.applied_type = n.applied_type), typeof n.proposed_type == "string" && n.proposed_type && (r.proposed_type = n.proposed_type), n.proposed_fields && typeof n.proposed_fields == "object" && !Array.isArray(n.proposed_fields) && (r.proposed_fields = n.proposed_fields), rt(n.proposed_tags) && (r.proposed_tags = n.proposed_tags), rt(n.statements) && (r.statements = n.statements), r;
1480
1687
  }
1481
- function Qe(e) {
1482
- let t = Ze(e);
1688
+ function at(e) {
1689
+ let t = it(e);
1483
1690
  if (!t) return;
1484
1691
  let n = t.proposed_tags ?? [], r = t.statements?.length ?? 0;
1485
1692
  if (t.proposed_type || n.length !== 0 || r !== 0) return {
@@ -1488,7 +1695,7 @@ function Qe(e) {
1488
1695
  statementCount: r
1489
1696
  };
1490
1697
  }
1491
- function $e(e) {
1698
+ function ot(e) {
1492
1699
  let t = e.write === "report";
1493
1700
  switch (e.result) {
1494
1701
  case "classified": return t ? "would be classified" : "classified";
@@ -1498,46 +1705,46 @@ function $e(e) {
1498
1705
  default: return String(e.result);
1499
1706
  }
1500
1707
  }
1501
- function et(e) {
1708
+ function st(e) {
1502
1709
  if (!e.class) return;
1503
1710
  if (e.result === "kept") return "not applied";
1504
1711
  let t = e.write === "report";
1505
1712
  return e.live ? t ? "would be applied" : "applied" : t ? "would be proposed" : "proposed";
1506
1713
  }
1507
- function tt(e) {
1714
+ function ct(e) {
1508
1715
  return e.write === "report" ? e.result === "classified" || e.result === "proposed" || (e.concepts?.length ?? 0) > 0 || (e.issued_by?.length ?? 0) > 0 : !1;
1509
1716
  }
1510
- function nt(e) {
1717
+ function lt(e) {
1511
1718
  return e == null || !Number.isFinite(e) ? "" : `${Math.round(e * 100)}%`;
1512
1719
  }
1513
- var rt = {
1720
+ var ut = {
1514
1721
  rules: "Rules",
1515
1722
  vote: "Neighbourhood vote",
1516
1723
  model: "Model"
1517
1724
  };
1518
- function it(e) {
1519
- return rt[e] ?? e;
1725
+ function dt(e) {
1726
+ return ut[e] ?? e;
1520
1727
  }
1521
- function at(e) {
1728
+ function ft(e) {
1522
1729
  let t = [];
1523
1730
  e.quote && t.push(e.from ? `“${e.quote}” (${e.from})` : `“${e.quote}”`), e.votes != null && t.push(`${e.votes} vote${e.votes === 1 ? "" : "s"}`);
1524
- let n = nt(e.share);
1731
+ let n = lt(e.share);
1525
1732
  return n && t.push(n), t.join(" · ");
1526
1733
  }
1527
- function ot(e) {
1734
+ function pt(e) {
1528
1735
  return {
1529
- label: it(e.step),
1736
+ label: dt(e.step),
1530
1737
  ...e.chosen ? { chosen: e.chosen } : {},
1531
1738
  ...e.method ? { method: e.method } : {},
1532
1739
  ...e.neighbours ? { neighbours: e.neighbours } : {},
1533
1740
  ...e.reason ? { reason: e.reason } : {},
1534
1741
  candidates: (e.candidates ?? []).map((e) => ({
1535
1742
  class: e.class,
1536
- detail: at(e)
1743
+ detail: ft(e)
1537
1744
  }))
1538
1745
  };
1539
1746
  }
1540
- function st(e) {
1747
+ function mt(e) {
1541
1748
  let t = [];
1542
1749
  e.type && t.push(`type ${e.type}`);
1543
1750
  let n = e.accepted_statements?.length ?? 0;
@@ -1550,18 +1757,18 @@ function st(e) {
1550
1757
  notices: r
1551
1758
  };
1552
1759
  }
1553
- function ct(e) {
1760
+ function ht(e) {
1554
1761
  let t = e instanceof Error ? e.message : String(e);
1555
1762
  return t.includes("nothing_pending") ? "Nothing is pending for this document — it may already have been accepted." : t;
1556
1763
  }
1557
1764
  //#endregion
1558
1765
  //#region src/components/Classification.tsx
1559
- function lt({ documentId: e, scope: t, browse: n, rootFields: a, requestKey: s, onClose: c, onChanged: d }) {
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]);
1766
+ function gt({ documentId: e, scope: t, browse: n, rootFields: a, requestKey: s, onClose: c, onChanged: d }) {
1767
+ let f = M(), [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 ? at(a) : void 0, [f, a]);
1561
1768
  r(() => {
1562
1769
  if (s === 0 || !f.documentClassify) return;
1563
1770
  let r = !1;
1564
- return g(!0), v(null), m(null), f.documentClassify(e, "report", t, n).then((e) => !r && m(e)).catch((e) => !r && v(ct(e))).finally(() => !r && g(!1)), () => {
1771
+ return g(!0), v(null), m(null), f.documentClassify(e, "report", t, n).then((e) => !r && m(e)).catch((e) => !r && v(ht(e))).finally(() => !r && g(!1)), () => {
1565
1772
  r = !0;
1566
1773
  };
1567
1774
  }, [
@@ -1577,7 +1784,7 @@ function lt({ documentId: e, scope: t, browse: n, rootFields: a, requestKey: s,
1577
1784
  try {
1578
1785
  m(await f.documentClassify(e, "propose", t, n)), d();
1579
1786
  } catch (e) {
1580
- v(ct(e));
1787
+ v(ht(e));
1581
1788
  } finally {
1582
1789
  g(!1);
1583
1790
  }
@@ -1588,14 +1795,14 @@ function lt({ documentId: e, scope: t, browse: n, rootFields: a, requestKey: s,
1588
1795
  try {
1589
1796
  w(await f.documentAcceptClassification(e, t, n)), d();
1590
1797
  } catch (e) {
1591
- S(ct(e));
1798
+ S(ht(e));
1592
1799
  } finally {
1593
1800
  b(!1);
1594
1801
  }
1595
1802
  }
1596
1803
  }, O = s > 0;
1597
1804
  if (!O && !T && !C && !x) return null;
1598
- let k = C ? st(C) : void 0;
1805
+ let k = C ? mt(C) : void 0;
1599
1806
  return /* @__PURE__ */ u("div", {
1600
1807
  className: "doc-classify",
1601
1808
  children: [
@@ -1666,7 +1873,7 @@ function lt({ documentId: e, scope: t, browse: n, rootFields: a, requestKey: s,
1666
1873
  /* @__PURE__ */ l("h4", { children: "Classify" }),
1667
1874
  p && /* @__PURE__ */ l("span", {
1668
1875
  className: `doc-classify-result ${p.result}`,
1669
- children: $e(p)
1876
+ children: ot(p)
1670
1877
  }),
1671
1878
  p?.write === "report" && /* @__PURE__ */ l("span", {
1672
1879
  className: "doc-classify-hint",
@@ -1690,8 +1897,8 @@ function lt({ documentId: e, scope: t, browse: n, rootFields: a, requestKey: s,
1690
1897
  role: "alert",
1691
1898
  children: _
1692
1899
  }),
1693
- p && /* @__PURE__ */ l(ut, { answer: p }),
1694
- p && tt(p) && /* @__PURE__ */ l("div", {
1900
+ p && /* @__PURE__ */ l(_t, { answer: p }),
1901
+ p && ct(p) && /* @__PURE__ */ l("div", {
1695
1902
  className: "doc-classify-actions",
1696
1903
  children: /* @__PURE__ */ l("button", {
1697
1904
  type: "button",
@@ -1706,8 +1913,8 @@ function lt({ documentId: e, scope: t, browse: n, rootFields: a, requestKey: s,
1706
1913
  ]
1707
1914
  });
1708
1915
  }
1709
- function ut({ answer: e }) {
1710
- let t = et(e), n = Object.entries(e.fields ?? {}), r = e.issued_by ?? [], i = e.concepts ?? [], a = (e.steps ?? []).map(ot), o = e.statements?.length ?? 0;
1916
+ function _t({ answer: e }) {
1917
+ let t = st(e), n = Object.entries(e.fields ?? {}), r = e.issued_by ?? [], i = e.concepts ?? [], a = (e.steps ?? []).map(pt), o = e.statements?.length ?? 0;
1711
1918
  return /* @__PURE__ */ u(c, { children: [
1712
1919
  /* @__PURE__ */ u("dl", {
1713
1920
  className: "doc-classify-rows",
@@ -1745,7 +1952,7 @@ function ut({ answer: e }) {
1745
1952
  title: e.tag,
1746
1953
  children: [e.concept, /* @__PURE__ */ u("span", {
1747
1954
  className: "doc-classify-hint",
1748
- children: [" ", nt(e.share)]
1955
+ children: [" ", lt(e.share)]
1749
1956
  })]
1750
1957
  }, e.tag)) })] }),
1751
1958
  o > 0 && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("dt", { children: "statements" }), /* @__PURE__ */ u("dd", { children: [
@@ -1813,15 +2020,15 @@ function ut({ answer: e }) {
1813
2020
  }
1814
2021
  //#endregion
1815
2022
  //#region src/components/ColorSchemeEditor.tsx
1816
- function dt(e) {
2023
+ function vt(e) {
1817
2024
  let t = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec((e ?? "").trim());
1818
2025
  if (!t) return "#888888";
1819
2026
  let n = t[1];
1820
2027
  return n.length === 3 && (n = n[0] + n[0] + n[1] + n[1] + n[2] + n[2]), "#" + n.toLowerCase();
1821
2028
  }
1822
- function ft({ documentId: e, rootChunkId: t, docType: n, docStatus: a, chunkStatuses: s, scope: d, browse: f, onClose: p, onSaved: m }) {
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
- let e = new Set(Object.keys(Y));
2029
+ function yt({ documentId: e, rootChunkId: t, docType: n, docStatus: a, chunkStatuses: s, scope: d, browse: f, onClose: p, onSaved: m }) {
2030
+ let h = M(), [g, _] = o(null), [v, y] = o(!1), [b, x] = o({}), [S, C] = o(!1), [w, T] = o(null), [E, D] = o(null), O = i(() => {
2031
+ let e = new Set(Object.keys(Q));
1825
2032
  n && e.add(`doc.${n}.${a || "draft"}`);
1826
2033
  for (let t of s) t && e.add(`chunk.${t}`);
1827
2034
  return [...e].sort();
@@ -1839,7 +2046,7 @@ function ft({ documentId: e, rootChunkId: t, docType: n, docStatus: a, chunkStat
1839
2046
  y(n.color_enabled === !0);
1840
2047
  let r = n.color_scheme ?? {};
1841
2048
  x({
1842
- ...Y,
2049
+ ...Q,
1843
2050
  ...r
1844
2051
  });
1845
2052
  }).catch((t) => !e && D(t instanceof Error ? t.message : String(t))), () => {
@@ -1867,7 +2074,7 @@ function ft({ documentId: e, rootChunkId: t, docType: n, docStatus: a, chunkStat
1867
2074
  D(e instanceof Error ? e.message : String(e)), C(!1);
1868
2075
  }
1869
2076
  }
1870
- }, te = async () => {
2077
+ }, N = async () => {
1871
2078
  if (!n) D("this document has no type to match");
1872
2079
  else {
1873
2080
  C(!0), D(null), T(null);
@@ -1884,7 +2091,7 @@ function ft({ documentId: e, rootChunkId: t, docType: n, docStatus: a, chunkStat
1884
2091
  C(!1);
1885
2092
  }
1886
2093
  }
1887
- }, ne = O.filter((e) => e.startsWith("doc.")), re = O.filter((e) => e.startsWith("chunk."));
2094
+ }, P = O.filter((e) => e.startsWith("doc.")), F = O.filter((e) => e.startsWith("chunk."));
1888
2095
  return /* @__PURE__ */ l("div", {
1889
2096
  className: "modal-overlay",
1890
2097
  onClick: p,
@@ -1929,7 +2136,7 @@ function ft({ documentId: e, rootChunkId: t, docType: n, docStatus: a, chunkStat
1929
2136
  }),
1930
2137
  /* @__PURE__ */ u("div", {
1931
2138
  className: "scheme-group",
1932
- children: [/* @__PURE__ */ l("h4", { children: "Document (type · status)" }), ne.map((e) => /* @__PURE__ */ l(pt, {
2139
+ children: [/* @__PURE__ */ l("h4", { children: "Document (type · status)" }), P.map((e) => /* @__PURE__ */ l(bt, {
1933
2140
  label: e.slice(4),
1934
2141
  value: b[e],
1935
2142
  onChange: (t) => k(e, t)
@@ -1937,7 +2144,7 @@ function ft({ documentId: e, rootChunkId: t, docType: n, docStatus: a, chunkStat
1937
2144
  }),
1938
2145
  /* @__PURE__ */ u("div", {
1939
2146
  className: "scheme-group",
1940
- children: [/* @__PURE__ */ l("h4", { children: "Chunks (status)" }), re.map((e) => /* @__PURE__ */ l(pt, {
2147
+ children: [/* @__PURE__ */ l("h4", { children: "Chunks (status)" }), F.map((e) => /* @__PURE__ */ l(bt, {
1941
2148
  label: e.slice(6),
1942
2149
  value: b[e],
1943
2150
  onChange: (t) => k(e, t)
@@ -1947,7 +2154,7 @@ function ft({ documentId: e, rootChunkId: t, docType: n, docStatus: a, chunkStat
1947
2154
  className: "scheme-editor-foot",
1948
2155
  children: [/* @__PURE__ */ u("button", {
1949
2156
  type: "button",
1950
- onClick: () => void te(),
2157
+ onClick: () => void N(),
1951
2158
  disabled: S || !n,
1952
2159
  title: n ? `Apply this palette to every other ${n} document` : "This document has no type",
1953
2160
  children: [
@@ -1968,8 +2175,8 @@ function ft({ documentId: e, rootChunkId: t, docType: n, docStatus: a, chunkStat
1968
2175
  })
1969
2176
  });
1970
2177
  }
1971
- function pt({ label: e, value: t, onChange: n }) {
1972
- let r = dt(t);
2178
+ function bt({ label: e, value: t, onChange: n }) {
2179
+ let r = vt(t);
1973
2180
  return /* @__PURE__ */ u("label", {
1974
2181
  className: "scheme-row",
1975
2182
  children: [
@@ -1991,7 +2198,7 @@ function pt({ label: e, value: t, onChange: n }) {
1991
2198
  }
1992
2199
  //#endregion
1993
2200
  //#region src/components/ChunkTarget.tsx
1994
- function mt({ id: e, title: t, targetDocumentId: n, documentId: r, onSelectChunk: i, onOpenDocument: a }) {
2201
+ function xt({ id: e, title: t, targetDocumentId: n, documentId: r, onSelectChunk: i, onOpenDocument: a }) {
1995
2202
  let o = t || e.slice(0, 8);
1996
2203
  return !n || n === r ? /* @__PURE__ */ l("button", {
1997
2204
  type: "button",
@@ -2012,8 +2219,8 @@ function mt({ id: e, title: t, targetDocumentId: n, documentId: r, onSelectChunk
2012
2219
  }
2013
2220
  //#endregion
2014
2221
  //#region src/components/Statement.tsx
2015
- function ht({ statement: e }) {
2016
- let t = ye(e), n = W(e), r = Se(e), i = xe(e), { rows: a, more: o } = K(e);
2222
+ function St({ statement: e }) {
2223
+ let t = Ce(e), n = we(e), r = De(e), i = Ee(e), { rows: a, more: o } = Oe(e);
2017
2224
  return /* @__PURE__ */ u(c, { children: [
2018
2225
  t && /* @__PURE__ */ l("span", {
2019
2226
  className: `doc-stmt-status ${t}`,
@@ -2039,7 +2246,7 @@ function ht({ statement: e }) {
2039
2246
  title: e.quote,
2040
2247
  children: [
2041
2248
  "“",
2042
- Ce(e.quote),
2249
+ ke(e.quote),
2043
2250
  "”",
2044
2251
  e.stale && /* @__PURE__ */ l("span", {
2045
2252
  className: "doc-stmt-stale",
@@ -2057,7 +2264,7 @@ function ht({ statement: e }) {
2057
2264
  })
2058
2265
  ] });
2059
2266
  }
2060
- function gt({ id: e, onRule: t }) {
2267
+ function Ct({ id: e, onRule: t }) {
2061
2268
  let [n, r] = o(!1), [i, a] = o(""), [s, d] = o(!1), [f, p] = o(null), m = async (n) => {
2062
2269
  d(!0), p(null);
2063
2270
  try {
@@ -2115,9 +2322,9 @@ function gt({ id: e, onRule: t }) {
2115
2322
  }
2116
2323
  //#endregion
2117
2324
  //#region src/components/ProposalReview.tsx
2118
- var _t = 3;
2119
- function vt({ documentId: e, proposals: t, incomplete: n, scope: r, browse: i, onChanged: s, onSelectChunk: c, onOpenDocument: d }) {
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) => {
2325
+ var wt = 3;
2326
+ function Tt({ documentId: e, proposals: t, incomplete: n, scope: r, browse: i, onChanged: s, onSelectChunk: c, onOpenDocument: d }) {
2327
+ let f = M(), [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
2328
  b(null), S(null), e === "reject" ? g({
2122
2329
  kind: "reason",
2123
2330
  action: e,
@@ -2131,7 +2338,7 @@ function vt({ documentId: e, proposals: t, incomplete: n, scope: r, browse: i, o
2131
2338
  });
2132
2339
  let o;
2133
2340
  try {
2134
- o = await J(f, {
2341
+ o = await Le(f, {
2135
2342
  documentId: e,
2136
2343
  action: t,
2137
2344
  ids: n ? void 0 : T,
@@ -2168,7 +2375,7 @@ function vt({ documentId: e, proposals: t, incomplete: n, scope: r, browse: i, o
2168
2375
  };
2169
2376
  }
2170
2377
  C.current = null, g({ kind: "idle" }), v(""), o.rulingIds.length > 0 ? (m(/* @__PURE__ */ new Set()), S({
2171
- text: Pe(t, o),
2378
+ text: Re(t, o),
2172
2379
  rulingIds: o.rulingIds
2173
2380
  }), s()) : o.error === void 0 && !o.cancelled && S({
2174
2381
  text: "Nothing to rule: no proposals match.",
@@ -2181,7 +2388,7 @@ function vt({ documentId: e, proposals: t, incomplete: n, scope: r, browse: i, o
2181
2388
  }), C.current?.(e);
2182
2389
  }, A = async () => {
2183
2390
  if (!x || !f.documentRevertRuling) return;
2184
- let e = x, t = await ke((e) => f.documentRevertRuling(e, r, i), e.rulingIds), n = [`${t.reverted} came back to review`];
2391
+ let e = x, t = await Y((e) => f.documentRevertRuling(e, r, i), e.rulingIds), n = [`${t.reverted} came back to review`];
2185
2392
  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({
2186
2393
  ...e,
2187
2394
  undone: !0,
@@ -2190,7 +2397,7 @@ function vt({ documentId: e, proposals: t, incomplete: n, scope: r, browse: i, o
2190
2397
  }, j = (e) => m((t) => {
2191
2398
  let n = new Set(t);
2192
2399
  return n.has(e) ? n.delete(e) : n.add(e), n;
2193
- }), te = t.length > 0 && T.length === t.length, ne = t.length === 0 && !n;
2400
+ }), N = t.length > 0 && T.length === t.length, P = t.length === 0 && !n;
2194
2401
  return /* @__PURE__ */ u("div", {
2195
2402
  className: "doc-conn-group doc-bulk",
2196
2403
  children: [
@@ -2206,9 +2413,9 @@ function vt({ documentId: e, proposals: t, incomplete: n, scope: r, browse: i, o
2206
2413
  /* @__PURE__ */ l("input", {
2207
2414
  type: "checkbox",
2208
2415
  "aria-label": "select every proposal shown",
2209
- checked: te,
2416
+ checked: N,
2210
2417
  disabled: E || t.length === 0,
2211
- onChange: () => m(te ? /* @__PURE__ */ new Set() : new Set(w))
2418
+ onChange: () => m(N ? /* @__PURE__ */ new Set() : new Set(w))
2212
2419
  }),
2213
2420
  " ",
2214
2421
  "all shown"
@@ -2232,14 +2439,14 @@ function vt({ documentId: e, proposals: t, incomplete: n, scope: r, browse: i, o
2232
2439
  }),
2233
2440
  /* @__PURE__ */ l("button", {
2234
2441
  type: "button",
2235
- disabled: E || ne,
2442
+ disabled: E || P,
2236
2443
  onClick: () => D("accept", !0),
2237
2444
  children: "Accept all from this document"
2238
2445
  }),
2239
2446
  /* @__PURE__ */ l("button", {
2240
2447
  type: "button",
2241
2448
  className: "danger",
2242
- disabled: E || ne,
2449
+ disabled: E || P,
2243
2450
  onClick: () => D("reject", !0),
2244
2451
  children: "Reject all…"
2245
2452
  })
@@ -2276,7 +2483,7 @@ function vt({ documentId: e, proposals: t, incomplete: n, scope: r, browse: i, o
2276
2483
  className: "doc-conn-empty",
2277
2484
  children: "counting…"
2278
2485
  }),
2279
- h.kind === "confirm" && /* @__PURE__ */ l(yt, {
2486
+ h.kind === "confirm" && /* @__PURE__ */ l(Et, {
2280
2487
  step: h,
2281
2488
  onAnswer: k
2282
2489
  }),
@@ -2313,7 +2520,7 @@ function vt({ documentId: e, proposals: t, incomplete: n, scope: r, browse: i, o
2313
2520
  disabled: E,
2314
2521
  onChange: () => j(t.id)
2315
2522
  }),
2316
- /* @__PURE__ */ l(mt, {
2523
+ /* @__PURE__ */ l(xt, {
2317
2524
  id: t.from_id,
2318
2525
  title: t.from_title,
2319
2526
  targetDocumentId: t.from_document_id,
@@ -2325,7 +2532,7 @@ function vt({ documentId: e, proposals: t, incomplete: n, scope: r, browse: i, o
2325
2532
  className: "doc-ref-kind",
2326
2533
  children: t.kind
2327
2534
  }),
2328
- /* @__PURE__ */ l(mt, {
2535
+ /* @__PURE__ */ l(xt, {
2329
2536
  id: t.to_id,
2330
2537
  title: t.to_title,
2331
2538
  targetDocumentId: t.to_document_id,
@@ -2333,15 +2540,15 @@ function vt({ documentId: e, proposals: t, incomplete: n, scope: r, browse: i, o
2333
2540
  onSelectChunk: c,
2334
2541
  onOpenDocument: d
2335
2542
  }),
2336
- /* @__PURE__ */ l(ht, { statement: t })
2543
+ /* @__PURE__ */ l(St, { statement: t })
2337
2544
  ]
2338
2545
  }, t.id))
2339
2546
  })
2340
2547
  ]
2341
2548
  });
2342
2549
  }
2343
- function yt({ step: e, onAnswer: t }) {
2344
- let { dry: n } = e, r = e.action === "accept" ? "Accept" : "Reject", i = Ae(n.matched);
2550
+ function Et({ step: e, onAnswer: t }) {
2551
+ let { dry: n } = e, r = e.action === "accept" ? "Accept" : "Reject", i = X(n.matched);
2345
2552
  return /* @__PURE__ */ u("div", {
2346
2553
  className: "doc-bulk-step doc-bulk-confirm",
2347
2554
  children: [
@@ -2362,7 +2569,7 @@ function yt({ step: e, onAnswer: t }) {
2362
2569
  ] }),
2363
2570
  (n.sample ?? []).length > 0 && /* @__PURE__ */ l("ul", {
2364
2571
  className: "doc-bulk-sample",
2365
- children: (n.sample ?? []).slice(0, _t).map((e) => /* @__PURE__ */ u("li", { children: [
2572
+ children: (n.sample ?? []).slice(0, wt).map((e) => /* @__PURE__ */ u("li", { children: [
2366
2573
  e.from_title || e.from_id,
2367
2574
  " ",
2368
2575
  /* @__PURE__ */ l("span", {
@@ -2393,26 +2600,26 @@ function yt({ step: e, onAnswer: t }) {
2393
2600
  }
2394
2601
  //#endregion
2395
2602
  //#region src/components/Connections.tsx
2396
- var bt = 8, xt = 20;
2397
- function St(e) {
2603
+ var Dt = 8, Ot = 20;
2604
+ function kt(e) {
2398
2605
  return /embedder|embedding|vector|semantic|not configured/i.test(e);
2399
2606
  }
2400
- function Ct({ documentId: e, selectedId: t, scope: n, browse: i, onSelectChunk: a, onOpenDocument: s, refreshKey: d, review: f }) {
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);
2607
+ function At({ documentId: e, selectedId: t, scope: n, browse: i, onSelectChunk: a, onOpenDocument: s, refreshKey: d, review: f }) {
2608
+ let p = M(), [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
2609
  r(() => {
2403
2610
  if (!m || !t) return;
2404
2611
  let e = t, r = !1;
2405
2612
  return _(!0), Promise.allSettled([
2406
2613
  p.documentBacklinks(e, n, i),
2407
- p.documentRelated(e, n, i, bt),
2408
- p.documentUnlinkedMentions(e, n, i, xt)
2614
+ p.documentRelated(e, n, i, Dt),
2615
+ p.documentUnlinkedMentions(e, n, i, Ot)
2409
2616
  ]).then(([t, n, i]) => {
2410
2617
  if (!r) {
2411
2618
  if (x(t.status === "fulfilled" ? t.value.backlinks ?? [] : []), n.status === "fulfilled") C(n.value.related ?? []), T(null);
2412
2619
  else {
2413
2620
  C([]);
2414
2621
  let e = n.reason instanceof Error ? n.reason.message : String(n.reason);
2415
- T(St(e) ? "semantic search not configured" : e);
2622
+ T(kt(e) ? "semantic search not configured" : e);
2416
2623
  }
2417
2624
  i.status === "fulfilled" ? (D(i.value.unlinked_mentions ?? []), k(!!i.value.truncated)) : (D([]), k(!1)), y(e), _(!1);
2418
2625
  }
@@ -2427,7 +2634,7 @@ function Ct({ documentId: e, selectedId: t, scope: n, browse: i, onSelectChunk:
2427
2634
  i,
2428
2635
  d
2429
2636
  ]);
2430
- let A = (t, n, r) => /* @__PURE__ */ l(mt, {
2637
+ let A = (t, n, r) => /* @__PURE__ */ l(xt, {
2431
2638
  id: t,
2432
2639
  title: n,
2433
2640
  targetDocumentId: r,
@@ -2444,7 +2651,7 @@ function Ct({ documentId: e, selectedId: t, scope: n, browse: i, onSelectChunk:
2444
2651
  children: [m ? "▼" : "▶", " Connections"]
2445
2652
  }), m && /* @__PURE__ */ u("div", {
2446
2653
  className: "doc-conn-body",
2447
- children: [f && /* @__PURE__ */ l(vt, {
2654
+ children: [f && /* @__PURE__ */ l(Tt, {
2448
2655
  documentId: e,
2449
2656
  proposals: f.proposals,
2450
2657
  incomplete: f.incomplete,
@@ -2474,7 +2681,7 @@ function Ct({ documentId: e, selectedId: t, scope: n, browse: i, onSelectChunk:
2474
2681
  title: "Auto-linked from a [[wikilink]]",
2475
2682
  children: "auto"
2476
2683
  }),
2477
- /* @__PURE__ */ l(ht, { statement: e })
2684
+ /* @__PURE__ */ l(St, { statement: e })
2478
2685
  ]
2479
2686
  }, `${e.from_id}-${e.kind}-${t}`))
2480
2687
  })]
@@ -2528,11 +2735,11 @@ function Ct({ documentId: e, selectedId: t, scope: n, browse: i, onSelectChunk:
2528
2735
  }
2529
2736
  //#endregion
2530
2737
  //#region src/components/CrossReferences.tsx
2531
- var wt = 24;
2532
- function Tt({ edges: e, documentId: t, selectedId: n, onSelectChunk: r, onOpenDocument: i, onRuleStatement: a, incomplete: s }) {
2738
+ var jt = 24;
2739
+ function Mt({ edges: e, documentId: t, selectedId: n, onSelectChunk: r, onOpenDocument: i, onRuleStatement: a, incomplete: s }) {
2533
2740
  let [d, f] = o(!1), [p, m] = o(!1);
2534
2741
  if (e.length === 0) return null;
2535
- let h = n ? e.filter((e) => e.from_id === n || e.to_id === n) : [], g = p ? e : e.slice(0, wt), _ = Dt(g);
2742
+ let h = n ? e.filter((e) => e.from_id === n || e.to_id === n) : [], g = p ? e : e.slice(0, jt), _ = Pt(g);
2536
2743
  return /* @__PURE__ */ u("div", {
2537
2744
  className: "doc-refs",
2538
2745
  children: [
@@ -2551,7 +2758,7 @@ function Tt({ edges: e, documentId: t, selectedId: n, onSelectChunk: r, onOpenDo
2551
2758
  children: "This chunk has no links."
2552
2759
  }) : /* @__PURE__ */ l("ul", {
2553
2760
  className: "doc-refs-list",
2554
- children: h.map((e, o) => /* @__PURE__ */ l(Et, {
2761
+ children: h.map((e, o) => /* @__PURE__ */ l(Nt, {
2555
2762
  edge: e,
2556
2763
  selectedId: n,
2557
2764
  documentId: t,
@@ -2573,23 +2780,23 @@ function Tt({ edges: e, documentId: t, selectedId: n, onSelectChunk: r, onOpenDo
2573
2780
  e.length,
2574
2781
  ")"
2575
2782
  ]
2576
- }), d && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(qe, {
2783
+ }), d && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(et, {
2577
2784
  code: _,
2578
2785
  onNodeClick: (e) => {
2579
- let n = Ot(g, e);
2786
+ let n = Ft(g, e);
2580
2787
  n && (!n.documentId || n.documentId === t ? r(n.id) : i?.(n.documentId, n.id, n.title));
2581
2788
  }
2582
- }), e.length > wt && /* @__PURE__ */ l("button", {
2789
+ }), e.length > jt && /* @__PURE__ */ l("button", {
2583
2790
  type: "button",
2584
2791
  className: "doc-graph-more",
2585
2792
  onClick: () => m((e) => !e),
2586
- children: p ? `show top ${wt}` : `show all ${e.length}`
2793
+ children: p ? `show top ${jt}` : `show all ${e.length}`
2587
2794
  })] })]
2588
2795
  })
2589
2796
  ]
2590
2797
  });
2591
2798
  }
2592
- function Et({ edge: e, selectedId: t, documentId: n, onSelectChunk: r, onOpenDocument: i, onRuleStatement: a }) {
2799
+ function Nt({ edge: e, selectedId: t, documentId: n, onSelectChunk: r, onOpenDocument: i, onRuleStatement: a }) {
2593
2800
  let o = e.from_id === t, s = o ? e.to_id : e.from_id, c = o ? e.to_title : e.from_title, d = o ? e.to_document_id : e.from_document_id;
2594
2801
  return /* @__PURE__ */ u("li", {
2595
2802
  className: "doc-ref",
@@ -2603,7 +2810,7 @@ function Et({ edge: e, selectedId: t, documentId: n, onSelectChunk: r, onOpenDoc
2603
2810
  "aria-hidden": !0,
2604
2811
  children: o ? "→" : "←"
2605
2812
  }),
2606
- /* @__PURE__ */ l(mt, {
2813
+ /* @__PURE__ */ l(xt, {
2607
2814
  id: s,
2608
2815
  title: c,
2609
2816
  targetDocumentId: d,
@@ -2611,46 +2818,46 @@ function Et({ edge: e, selectedId: t, documentId: n, onSelectChunk: r, onOpenDoc
2611
2818
  onSelectChunk: r,
2612
2819
  onOpenDocument: i
2613
2820
  }),
2614
- /* @__PURE__ */ l(ht, { statement: e }),
2615
- a && G(e) && /* @__PURE__ */ l(gt, {
2821
+ /* @__PURE__ */ l(St, { statement: e }),
2822
+ a && q(e) && /* @__PURE__ */ l(Ct, {
2616
2823
  id: e.id,
2617
2824
  onRule: a
2618
2825
  })
2619
2826
  ]
2620
2827
  });
2621
2828
  }
2622
- function Dt(e) {
2829
+ function Pt(e) {
2623
2830
  let t = ["graph LR"];
2624
2831
  for (let n of e) {
2625
- let e = `${kt(n.from_id)}["${At(n.from_title, n.from_id)}"]`, r = `${kt(n.to_id)}["${At(n.to_title, n.to_id)}"]`, i = (n.kind || "link").replace(/[|"]/g, " "), a = n.status === "proposed" ? "-.->" : "-->";
2832
+ let e = `${It(n.from_id)}["${Lt(n.from_title, n.from_id)}"]`, r = `${It(n.to_id)}["${Lt(n.to_title, n.to_id)}"]`, i = (n.kind || "link").replace(/[|"]/g, " "), a = n.status === "proposed" ? "-.->" : "-->";
2626
2833
  t.push(` ${e} ${a}|${i}| ${r}`);
2627
2834
  }
2628
2835
  return t.join("\n");
2629
2836
  }
2630
- function Ot(e, t) {
2837
+ function Ft(e, t) {
2631
2838
  for (let n of e) {
2632
- if (kt(n.from_id) === t) return {
2839
+ if (It(n.from_id) === t) return {
2633
2840
  id: n.from_id,
2634
2841
  documentId: n.from_document_id,
2635
2842
  title: n.from_title
2636
2843
  };
2637
- if (kt(n.to_id) === t) return {
2844
+ if (It(n.to_id) === t) return {
2638
2845
  id: n.to_id,
2639
2846
  documentId: n.to_document_id,
2640
2847
  title: n.to_title
2641
2848
  };
2642
2849
  }
2643
2850
  }
2644
- function kt(e) {
2851
+ function It(e) {
2645
2852
  return "n" + e.replace(/[^a-zA-Z0-9]/g, "");
2646
2853
  }
2647
- function At(e, t) {
2854
+ function Lt(e, t) {
2648
2855
  let n = (e ?? "").replace(/["[\]{}|<>]/g, " ").replace(/\s+/g, " ").trim() || t.slice(0, 6);
2649
2856
  return n.length > 30 ? n.slice(0, 29) + "…" : n;
2650
2857
  }
2651
2858
  //#endregion
2652
2859
  //#region src/components/DocUnavailable.tsx
2653
- function jt({ documentId: e, scope: t, detail: n }) {
2860
+ function Rt({ documentId: e, scope: t, detail: n }) {
2654
2861
  return /* @__PURE__ */ u("div", {
2655
2862
  className: "doc-unavailable",
2656
2863
  role: "alert",
@@ -2673,12 +2880,12 @@ function jt({ documentId: e, scope: t, detail: n }) {
2673
2880
  }
2674
2881
  //#endregion
2675
2882
  //#region src/components/HistoryModal.tsx
2676
- function Mt(e) {
2883
+ function zt(e) {
2677
2884
  let t = typeof e == "number" ? e / 1e6 : Date.parse(String(e));
2678
2885
  return !Number.isFinite(t) || t <= 0 ? String(e ?? "") : new Date(t).toLocaleString();
2679
2886
  }
2680
- function Nt({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
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("");
2887
+ function Bt({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
2888
+ let s = M(), [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
2889
  r(() => {
2683
2890
  let t = !1;
2684
2891
  return m(!0), g(null), s.documentHistory(e, n, i).then((e) => {
@@ -2707,7 +2914,7 @@ function Nt({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
2707
2914
  } finally {
2708
2915
  w(!1);
2709
2916
  }
2710
- }, te = async () => {
2917
+ }, N = async () => {
2711
2918
  if (T !== null && D !== null) {
2712
2919
  g(null), w(!0), v("diff");
2713
2920
  try {
@@ -2762,7 +2969,7 @@ function Nt({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
2762
2969
  }),
2763
2970
  /* @__PURE__ */ l("span", {
2764
2971
  className: "doc-hist-rev-time",
2765
- children: Mt(e.created_at)
2972
+ children: zt(e.created_at)
2766
2973
  }),
2767
2974
  /* @__PURE__ */ l("span", {
2768
2975
  className: "doc-hist-rev-actor",
@@ -2799,7 +3006,7 @@ function Nt({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
2799
3006
  }),
2800
3007
  /* @__PURE__ */ l("button", {
2801
3008
  type: "button",
2802
- onClick: () => void te(),
3009
+ onClick: () => void N(),
2803
3010
  disabled: C || T === null || D === null,
2804
3011
  children: "diff"
2805
3012
  })
@@ -2810,7 +3017,7 @@ function Nt({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
2810
3017
  children: C ? /* @__PURE__ */ l("p", {
2811
3018
  className: "doc-empty-body",
2812
3019
  children: "loading…"
2813
- }) : _ === "diff" ? /* @__PURE__ */ l(Pt, { text: k }) : _ === "version" ? /* @__PURE__ */ l("pre", {
3020
+ }) : _ === "diff" ? /* @__PURE__ */ l(Vt, { text: k }) : _ === "version" ? /* @__PURE__ */ l("pre", {
2814
3021
  className: "md-pre doc-hist-version",
2815
3022
  children: /* @__PURE__ */ l("code", { children: x || "(empty)" })
2816
3023
  }) : /* @__PURE__ */ l("p", {
@@ -2823,7 +3030,7 @@ function Nt({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
2823
3030
  })
2824
3031
  });
2825
3032
  }
2826
- function Pt({ text: e }) {
3033
+ function Vt({ text: e }) {
2827
3034
  if (!e.trim()) return /* @__PURE__ */ l("p", {
2828
3035
  className: "doc-empty-body",
2829
3036
  children: "(no differences)"
@@ -2842,17 +3049,17 @@ function Pt({ text: e }) {
2842
3049
  }
2843
3050
  //#endregion
2844
3051
  //#region src/components/Markdown.tsx
2845
- function Ft({ source: e }) {
3052
+ function Ht({ source: e }) {
2846
3053
  return /* @__PURE__ */ l("div", {
2847
3054
  className: "md",
2848
3055
  children: /* @__PURE__ */ l(f, {
2849
3056
  remarkPlugins: [p],
2850
- components: It,
3057
+ components: Ut,
2851
3058
  children: e
2852
3059
  })
2853
3060
  });
2854
3061
  }
2855
- var It = {
3062
+ var Ut = {
2856
3063
  a({ href: e, children: t }) {
2857
3064
  let n = e ?? "", r = /^https?:\/\//i.test(n);
2858
3065
  return /* @__PURE__ */ l("a", {
@@ -2867,7 +3074,7 @@ var It = {
2867
3074
  },
2868
3075
  code({ className: e, children: t }) {
2869
3076
  let n = /language-(\w+)/.exec(e ?? "")?.[1], r = String(t ?? "");
2870
- return n === "mermaid" ? /* @__PURE__ */ l(qe, { code: r.replace(/\n$/, "") }) : n || r.includes("\n") ? /* @__PURE__ */ l("pre", {
3077
+ return n === "mermaid" ? /* @__PURE__ */ l(et, { code: r.replace(/\n$/, "") }) : n || r.includes("\n") ? /* @__PURE__ */ l("pre", {
2871
3078
  className: "md-pre",
2872
3079
  children: /* @__PURE__ */ l("code", {
2873
3080
  className: e,
@@ -2878,70 +3085,70 @@ var It = {
2878
3085
  };
2879
3086
  //#endregion
2880
3087
  //#region src/components/DocumentViewerBody.tsx
2881
- function Lt(e) {
3088
+ function Wt(e) {
2882
3089
  let t = e.fields ?? {};
2883
3090
  return typeof t.alt == "string" && t.alt.trim() !== "" ? t.alt : e.title || "image";
2884
3091
  }
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 = ee(), x = i(() => d && (d.scopeId || d.tenant) ? {
3092
+ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, renderAssistant: p, initialChunkId: m, onOpenDocument: h, onTitle: g, onChunkSelect: v, focusChunk: y }) {
3093
+ let b = M(), x = i(() => d && (d.scopeId || d.tenant) ? {
2887
3094
  scopeId: d.scopeId,
2888
3095
  tenant: d.tenant
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
- let Pe = a(g);
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(() => !!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
- Ve.current = v, r(() => {
2895
- w && Ve.current?.(w === Q ? void 0 : w);
2896
- }, [w, Q]);
2897
- let Ue = i(() => [...new Set(S.map((e) => e.status).filter((e) => !!e))], [S]), We = !!W?.color_enabled, Ge = i(() => {
3096
+ } : 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), [N, P] = o(null), [F, ee] = o(null), te = a(null), [ne, re] = o(null), [ie, ae] = o(null), [I, L] = o(!1), [oe, se] = o(!1), [R, z] = o(null), [ce, le] = o(!1), [ue, B] = o(void 0), [de, V] = o(null), [fe, H] = o(0), [pe, me] = o(!1), [W, ge] = o(null), [G, ye] = o(!1), [K, Se] = o([]), [Ce, we] = o(!1), [q, Te] = o(0), [Ee, De] = o(0), [Oe, ke] = o(void 0), J = t(() => H((e) => e + 1), []), Ae = a(m);
3097
+ Ae.current = m;
3098
+ let je = a(g);
3099
+ je.current = g;
3100
+ let Me = i(() => qe(S), [S]), Ne = i(() => S.find((e) => !e.parent_id)?.title || s || "document", [S, s]), Y = i(() => !!E && !E.parent_id, [E]), X = i(() => xe(S, E?.id), [S, E]), Z = i(() => W?.root_chunk_id ?? S.find((e) => !e.parent_id)?.id, [W, S]), Le = a(v);
3101
+ Le.current = v, r(() => {
3102
+ w && Le.current?.(w === Z ? void 0 : w);
3103
+ }, [w, Z]);
3104
+ let Re = i(() => [...new Set(S.map((e) => e.status).filter((e) => !!e))], [S]), Q = !!W?.color_enabled, ze = i(() => {
2898
3105
  let e = /* @__PURE__ */ new Set();
2899
- for (let t of Se) e.add(t.from_id), e.add(t.to_id);
3106
+ for (let t of K) e.add(t.from_id), e.add(t.to_id);
2900
3107
  return e;
2901
- }, [Se]), Ke = i(() => We ? Re(Le(W?.type, W?.status, Ie(W?.color_scheme))) : void 0, [
2902
- We,
3108
+ }, [K]), He = i(() => Q ? We(Ve(W?.type, W?.status, Be(W?.color_scheme))) : void 0, [
3109
+ Q,
2903
3110
  W?.type,
2904
3111
  W?.status,
2905
3112
  W?.color_scheme
2906
3113
  ]);
2907
3114
  r(() => {
2908
3115
  let t = !1;
2909
- return L(!0), I(null), V(null), b.documentQueryChunks(e, n, x).then((r) => {
3116
+ return le(!0), z(null), V(null), b.documentQueryChunks(e, n, x).then((r) => {
2910
3117
  if (t) return;
2911
3118
  let i = r.chunks ?? [];
2912
- C(i), z(`${n}:${e}`), T((e) => e ?? R(i, J.current));
3119
+ C(i), B(`${n}:${e}`), T((e) => e ?? U(i, Ae.current));
2913
3120
  }).catch((e) => {
2914
3121
  t || (C([]), V(e instanceof Error ? e.message : String(e)));
2915
- }).finally(() => !t && L(!1)), () => {
3122
+ }).finally(() => !t && le(!1)), () => {
2916
3123
  t = !0;
2917
3124
  };
2918
3125
  }, [
2919
3126
  b,
2920
3127
  e,
2921
3128
  n,
2922
- he,
3129
+ fe,
2923
3130
  x
2924
3131
  ]);
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]);
3132
+ let Ue = !ce && (de !== null || ue === `${n}:${e}` && S.length === 0), Ge = i(() => S.find((t) => !t.parent_id && t.document_id === e)?.title, [S, e]);
2926
3133
  r(() => {
2927
- Ze && Pe.current?.(e, Ze);
2928
- }, [e, Ze]), r(() => {
3134
+ Ge && je.current?.(e, Ge);
3135
+ }, [e, Ge]), r(() => {
2929
3136
  let t = !1;
2930
- return b.documentGet(e, n, x).then((e) => !t && G(e)).catch(() => !t && G(null)), () => {
3137
+ return b.documentGet(e, n, x).then((e) => !t && ge(e)).catch(() => !t && ge(null)), () => {
2931
3138
  t = !0;
2932
3139
  };
2933
3140
  }, [
2934
3141
  b,
2935
3142
  e,
2936
3143
  n,
2937
- he,
3144
+ fe,
2938
3145
  x
2939
3146
  ]), r(() => {
2940
3147
  let t = !1;
2941
- return U(b, e, n, x).then((e) => {
2942
- t || (K(e.edges), we(e.incomplete));
3148
+ return be(b, e, n, x).then((e) => {
3149
+ t || (Se(e.edges), we(e.incomplete));
2943
3150
  }).catch(() => {
2944
- t || (K([]), we(!1));
3151
+ t || (Se([]), we(!1));
2945
3152
  }), () => {
2946
3153
  t = !0;
2947
3154
  };
@@ -2949,73 +3156,73 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
2949
3156
  b,
2950
3157
  e,
2951
3158
  n,
2952
- he,
3159
+ fe,
2953
3160
  x,
2954
- Te
3161
+ q
2955
3162
  ]), r(() => {
2956
- if (!Q || !b.documentAcceptClassification) {
2957
- Ae(void 0);
3163
+ if (!Z || !b.documentAcceptClassification) {
3164
+ ke(void 0);
2958
3165
  return;
2959
3166
  }
2960
3167
  let t = !1;
2961
- return b.documentGetChunk(Q, n, x).then((n) => !t && Ae(n.document_id === e ? n.fields : void 0)).catch(() => !t && Ae(void 0)), () => {
3168
+ return b.documentGetChunk(Z, n, x).then((n) => !t && ke(n.document_id === e ? n.fields : void 0)).catch(() => !t && ke(void 0)), () => {
2962
3169
  t = !0;
2963
3170
  };
2964
3171
  }, [
2965
3172
  b,
2966
3173
  e,
2967
- Q,
3174
+ Z,
2968
3175
  n,
2969
- he,
3176
+ fe,
2970
3177
  x
2971
3178
  ]);
2972
- let Qe = i(() => {
3179
+ let Je = i(() => {
2973
3180
  if (b.documentAcceptStatement && b.documentRejectStatement) return async (e, t, r) => {
2974
- t ? await b.documentAcceptStatement(e, n, x, r) : await b.documentRejectStatement(e, r ?? "", n, x), Ee((e) => e + 1);
3181
+ t ? await b.documentAcceptStatement(e, n, x, r) : await b.documentRejectStatement(e, r ?? "", n, x), Te((e) => e + 1);
2975
3182
  };
2976
3183
  }, [
2977
3184
  b,
2978
3185
  n,
2979
3186
  x
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
- $e,
2982
- et,
3187
+ ]), Xe = i(() => Pe(b, n), [b, n]), Ze = i(() => Fe(K, e), [K, e]), Qe = t(() => Te((e) => e + 1), []), $e = i(() => Ie(Xe, Ze, Ce, Qe), [
3188
+ Xe,
3189
+ Ze,
2983
3190
  Ce,
2984
- tt
3191
+ Qe
2985
3192
  ]), rt = y?.seq, it = a(y);
2986
3193
  it.current = y;
2987
- let at = a(Q);
2988
- at.current = Q, r(() => {
3194
+ let at = a(Z);
3195
+ at.current = Z, r(() => {
2989
3196
  if (rt === void 0) return;
2990
3197
  let e = it.current?.chunkId ?? at.current;
2991
3198
  e && T(e);
2992
3199
  }, [rt]), r(() => {
2993
- T(void 0), D(null), j(null), k("chunks"), G(null), K([]), we(!1), Oe(0), Ae(void 0);
3200
+ T(void 0), D(null), j(null), k("chunks"), ge(null), Se([]), we(!1), De(0), ke(void 0);
2994
3201
  }, [e, n]), r(() => {
2995
3202
  if (!w) {
2996
3203
  D(null);
2997
3204
  return;
2998
3205
  }
2999
3206
  let e = !1;
3000
- return b.documentGetChunk(w, n, x).then((t) => !e && D(t)).catch((t) => !e && I(t instanceof Error ? t.message : String(t))), () => {
3207
+ return b.documentGetChunk(w, n, x).then((t) => !e && D(t)).catch((t) => !e && z(t instanceof Error ? t.message : String(t))), () => {
3001
3208
  e = !0;
3002
3209
  };
3003
3210
  }, [
3004
3211
  b,
3005
3212
  w,
3006
3213
  n,
3007
- he,
3214
+ fe,
3008
3215
  x
3009
3216
  ]), r(() => {
3010
3217
  let e = E?.type === "image" || !!E?.asset;
3011
3218
  if (!E || !e || !b.documentAssetObjectUrl) {
3012
- ne(null), ie(null);
3219
+ P(null), ee(null);
3013
3220
  return;
3014
3221
  }
3015
3222
  let t = !1, r = null;
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))), () => {
3223
+ return ee(null), b.documentAssetObjectUrl(E.id, n, x).then((e) => {
3224
+ t ? URL.revokeObjectURL(e) : (r = e, P(e));
3225
+ }).catch((e) => !t && ee(e instanceof Error ? e.message : String(e))), () => {
3019
3226
  t = !0, r && URL.revokeObjectURL(r);
3020
3227
  };
3021
3228
  }, [
@@ -3028,7 +3235,7 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3028
3235
  j(null);
3029
3236
  return;
3030
3237
  }
3031
- let e = He(Y, w);
3238
+ let e = $(Me, w);
3032
3239
  if (!e) return;
3033
3240
  let t = !1, r = [], i = (e, t) => {
3034
3241
  r.push({
@@ -3048,16 +3255,16 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3048
3255
  return a + (i.body ? "\n\n" + i.body : "") + "\n";
3049
3256
  }).join("\n");
3050
3257
  j(n);
3051
- }).catch((e) => !t && I(e instanceof Error ? e.message : String(e))), () => {
3258
+ }).catch((e) => !t && z(e instanceof Error ? e.message : String(e))), () => {
3052
3259
  t = !0;
3053
3260
  };
3054
3261
  }, [
3055
3262
  b,
3056
3263
  O,
3057
3264
  w,
3058
- Y,
3265
+ Me,
3059
3266
  n,
3060
- he,
3267
+ fe,
3061
3268
  x
3062
3269
  ]);
3063
3270
  let ot = t((e) => T(e.row.id), []), st = t((t, n, r) => h?.({
@@ -3067,50 +3274,50 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3067
3274
  }, {
3068
3275
  documentId: e,
3069
3276
  chunkId: w,
3070
- title: Fe
3277
+ title: Ne
3071
3278
  }), [
3072
3279
  h,
3073
3280
  e,
3074
3281
  w,
3075
- Fe
3282
+ Ne
3076
3283
  ]), ct = t(async () => {
3077
3284
  try {
3078
3285
  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
3286
  a.href = i, a.download = (t.title || "document").replace(/[^\w.-]+/g, "_") + ".md", a.click(), URL.revokeObjectURL(i);
3080
3287
  } catch (e) {
3081
- I(e instanceof Error ? e.message : String(e));
3288
+ z(e instanceof Error ? e.message : String(e));
3082
3289
  }
3083
3290
  }, [
3084
3291
  b,
3085
3292
  e,
3086
3293
  n,
3087
3294
  x
3088
- ]), ut = t(async () => {
3295
+ ]), lt = t(async () => {
3089
3296
  try {
3090
3297
  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
- a.href = i, a.download = (Fe || "document").replace(/[^\w.-]+/g, "_") + ".canvas", a.click(), URL.revokeObjectURL(i);
3298
+ a.href = i, a.download = (Ne || "document").replace(/[^\w.-]+/g, "_") + ".canvas", a.click(), URL.revokeObjectURL(i);
3092
3299
  } catch (e) {
3093
- I(e instanceof Error ? e.message : String(e));
3300
+ z(e instanceof Error ? e.message : String(e));
3094
3301
  }
3095
3302
  }, [
3096
3303
  b,
3097
3304
  e,
3098
3305
  n,
3099
3306
  x,
3100
- Fe
3101
- ]), dt = !!b.documentCreateChunk && !!Q, pt = t(async (t) => {
3307
+ Ne
3308
+ ]), ut = !!b.documentCreateChunk && !!Z, dt = t(async (t) => {
3102
3309
  if (!b.documentCreateChunk || !b.documentSetAsset) return;
3103
- let r = w || Q;
3310
+ let r = w || Z;
3104
3311
  if (r) {
3105
- I(null);
3312
+ z(null);
3106
3313
  try {
3107
- let { mediaType: i, data: a } = await H(t), o = await b.documentCreateChunk(e, r, {
3314
+ let { mediaType: i, data: a } = await _e(t), o = await b.documentCreateChunk(e, r, {
3108
3315
  title: t.name || "image",
3109
3316
  type: "image"
3110
3317
  }, n, x);
3111
- await b.documentSetAsset(o.id, i, a, t.name, n, x), q(), T(o.id);
3318
+ await b.documentSetAsset(o.id, i, a, t.name, n, x), J(), T(o.id);
3112
3319
  } catch (e) {
3113
- I(e instanceof Error ? e.message : String(e));
3320
+ z(e instanceof Error ? e.message : String(e));
3114
3321
  }
3115
3322
  }
3116
3323
  }, [
@@ -3119,22 +3326,22 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3119
3326
  n,
3120
3327
  x,
3121
3328
  w,
3122
- Q,
3123
- q
3124
- ]), mt = t(async () => {
3329
+ Z,
3330
+ J
3331
+ ]), ft = t(async () => {
3125
3332
  if (!b.documentCreateChunk) return;
3126
- let t = w || Q;
3333
+ let t = w || Z;
3127
3334
  if (t) {
3128
- I(null);
3335
+ z(null);
3129
3336
  try {
3130
3337
  let r = await b.documentCreateChunk(e, t, {
3131
3338
  title: "Diagram",
3132
3339
  type: "mermaid",
3133
3340
  body: "graph TD\n A[Start] --> B[End]"
3134
3341
  }, n, x);
3135
- q(), T(r.id), oe(r);
3342
+ J(), T(r.id), re(r);
3136
3343
  } catch (e) {
3137
- I(e instanceof Error ? e.message : String(e));
3344
+ z(e instanceof Error ? e.message : String(e));
3138
3345
  }
3139
3346
  }
3140
3347
  }, [
@@ -3143,21 +3350,21 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3143
3350
  n,
3144
3351
  x,
3145
3352
  w,
3146
- Q,
3147
- q
3148
- ]), ht = t(async () => {
3353
+ Z,
3354
+ J
3355
+ ]), pt = t(async () => {
3149
3356
  if (!b.documentCreateChunk) return;
3150
- let t = w && !X ? w : void 0, r = w || Q;
3357
+ let t = w && !Y ? w : void 0, r = w || Z;
3151
3358
  if (r) {
3152
- I(null);
3359
+ z(null);
3153
3360
  try {
3154
3361
  let i = await b.documentCreateChunk(e, t ? "" : r, {
3155
3362
  title: "Text",
3156
3363
  body: ""
3157
3364
  }, n, x, t);
3158
- q(), T(i.id), oe(i);
3365
+ J(), T(i.id), re(i);
3159
3366
  } catch (e) {
3160
- I(e instanceof Error ? e.message : String(e));
3367
+ z(e instanceof Error ? e.message : String(e));
3161
3368
  }
3162
3369
  }
3163
3370
  }, [
@@ -3166,20 +3373,20 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3166
3373
  n,
3167
3374
  x,
3168
3375
  w,
3169
- X,
3170
- Q,
3171
- q
3172
- ]), gt = t(async () => {
3376
+ Y,
3377
+ Z,
3378
+ J
3379
+ ]), mt = t(async () => {
3173
3380
  if (b.documentCreateChunk && w) {
3174
- I(null);
3381
+ z(null);
3175
3382
  try {
3176
3383
  let t = await b.documentCreateChunk(e, w, {
3177
3384
  title: "Text",
3178
3385
  body: ""
3179
3386
  }, n, x);
3180
- q(), T(t.id), oe(t);
3387
+ J(), T(t.id), re(t);
3181
3388
  } catch (e) {
3182
- I(e instanceof Error ? e.message : String(e));
3389
+ z(e instanceof Error ? e.message : String(e));
3183
3390
  }
3184
3391
  }
3185
3392
  }, [
@@ -3188,9 +3395,9 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3188
3395
  n,
3189
3396
  x,
3190
3397
  w,
3191
- q
3192
- ]), _t = i(() => {
3193
- if (!E || X) return {
3398
+ J
3399
+ ]), ht = i(() => {
3400
+ if (!E || Y) return {
3194
3401
  canUp: !1,
3195
3402
  canDown: !1
3196
3403
  };
@@ -3202,14 +3409,14 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3202
3409
  }, [
3203
3410
  S,
3204
3411
  E,
3205
- X
3206
- ]), vt = t(async (e) => {
3412
+ Y
3413
+ ]), _t = t(async (e) => {
3207
3414
  if (b.documentReorderChunk && w) {
3208
- I(null);
3415
+ z(null);
3209
3416
  try {
3210
- await b.documentReorderChunk(w, e, n, x), q();
3417
+ await b.documentReorderChunk(w, e, n, x), J();
3211
3418
  } catch (e) {
3212
- I(e instanceof Error ? e.message : String(e));
3419
+ z(e instanceof Error ? e.message : String(e));
3213
3420
  }
3214
3421
  }
3215
3422
  }, [
@@ -3217,107 +3424,107 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3217
3424
  w,
3218
3425
  n,
3219
3426
  x,
3220
- q
3221
- ]), yt = t(async () => {
3427
+ J
3428
+ ]), vt = t(async () => {
3222
3429
  if (!b.documentDeleteChunk || !E) return;
3223
- I(null);
3430
+ z(null);
3224
3431
  let e = E.parent_id;
3225
3432
  try {
3226
- await b.documentDeleteChunk(E.id, n, x), F(!1), T(e || Q), q();
3433
+ await b.documentDeleteChunk(E.id, n, x), se(!1), T(e || Z), J();
3227
3434
  } catch (e) {
3228
- I(e instanceof Error ? e.message : String(e)), F(!1);
3435
+ z(e instanceof Error ? e.message : String(e)), se(!1);
3229
3436
  }
3230
3437
  }, [
3231
3438
  b,
3232
3439
  E,
3233
3440
  n,
3234
3441
  x,
3235
- Q,
3236
- q
3442
+ Z,
3443
+ J
3237
3444
  ]);
3238
3445
  return r(() => {
3239
- if (!dt) return;
3446
+ if (!ut) return;
3240
3447
  let e = (e) => {
3241
- if (ae || be) return;
3448
+ if (ne || G) return;
3242
3449
  let t = document.activeElement, n = t?.tagName;
3243
3450
  if (n === "INPUT" || n === "TEXTAREA" || t?.isContentEditable) return;
3244
- let r = me(e.clipboardData?.items);
3245
- r && (e.preventDefault(), pt(r));
3451
+ let r = ve(e.clipboardData?.items);
3452
+ r && (e.preventDefault(), dt(r));
3246
3453
  };
3247
3454
  return window.addEventListener("paste", e), () => window.removeEventListener("paste", e);
3248
3455
  }, [
3249
- dt,
3250
- ae,
3251
- be,
3252
- pt
3456
+ ut,
3457
+ ne,
3458
+ G,
3459
+ dt
3253
3460
  ]), /* @__PURE__ */ u("div", {
3254
3461
  className: "doc-viewer",
3255
3462
  children: [
3256
3463
  /* @__PURE__ */ l("input", {
3257
- ref: M,
3464
+ ref: te,
3258
3465
  type: "file",
3259
3466
  accept: "image/png,image/jpeg,image/gif,image/webp",
3260
3467
  style: { display: "none" },
3261
3468
  onChange: (e) => {
3262
3469
  let t = e.target.files?.[0];
3263
- e.target.value = "", t && pt(t);
3470
+ e.target.value = "", t && dt(t);
3264
3471
  }
3265
3472
  }),
3266
3473
  /* @__PURE__ */ u("div", {
3267
3474
  className: "doc-toolbar",
3268
- style: Ke,
3475
+ style: He,
3269
3476
  children: [
3270
3477
  /* @__PURE__ */ l("strong", {
3271
3478
  className: "doc-title",
3272
- title: Fe,
3273
- children: Fe
3479
+ title: Ne,
3480
+ children: Ne
3274
3481
  }),
3275
- /* @__PURE__ */ l(ze, {
3482
+ /* @__PURE__ */ l(Ke, {
3276
3483
  value: e,
3277
3484
  label: "doc"
3278
3485
  }),
3279
3486
  /* @__PURE__ */ u("div", {
3280
3487
  className: "doc-toolbar-actions",
3281
3488
  children: [
3282
- dt && /* @__PURE__ */ u(c, { children: [
3489
+ ut && /* @__PURE__ */ u(c, { children: [
3283
3490
  /* @__PURE__ */ l("button", {
3284
3491
  type: "button",
3285
- onClick: () => void ht(),
3492
+ onClick: () => void pt(),
3286
3493
  title: "Add a text chunk AFTER the selected chunk, at the same level",
3287
3494
  children: "+ text"
3288
3495
  }),
3289
3496
  /* @__PURE__ */ l("button", {
3290
3497
  type: "button",
3291
- onClick: () => void gt(),
3498
+ onClick: () => void mt(),
3292
3499
  disabled: !w,
3293
3500
  title: w ? "Add a chunk NESTED UNDER the selected chunk (in the ontology, a child is a subclass)" : "Select a chunk first — this nests a new chunk under it",
3294
3501
  children: "+ child"
3295
3502
  }),
3296
3503
  /* @__PURE__ */ l("button", {
3297
3504
  type: "button",
3298
- onClick: () => M.current?.click(),
3505
+ onClick: () => te.current?.click(),
3299
3506
  title: "Add an image chunk (upload — or paste a screenshot into the view)",
3300
3507
  children: "+ image"
3301
3508
  }),
3302
3509
  /* @__PURE__ */ l("button", {
3303
3510
  type: "button",
3304
- onClick: () => void mt(),
3511
+ onClick: () => void ft(),
3305
3512
  title: "Add a Mermaid diagram chunk",
3306
3513
  children: "+ diagram"
3307
3514
  })
3308
3515
  ] }),
3309
3516
  /* @__PURE__ */ l("button", {
3310
3517
  type: "button",
3311
- className: We ? "active" : "",
3312
- onClick: () => xe(!0),
3313
- disabled: !Q,
3518
+ className: Q ? "active" : "",
3519
+ onClick: () => ye(!0),
3520
+ disabled: !Z,
3314
3521
  title: "Colors — tint chunk tiles + the Path tree by type/status",
3315
3522
  children: "colors"
3316
3523
  }),
3317
3524
  b.documentClassify && /* @__PURE__ */ l("button", {
3318
3525
  type: "button",
3319
- className: De > 0 ? "active" : "",
3320
- onClick: () => Oe((e) => e > 0 ? 0 : 1),
3526
+ className: Ee > 0 ? "active" : "",
3527
+ onClick: () => De((e) => e > 0 ? 0 : 1),
3321
3528
  title: "Classify — what this document is, by the confirmed ontology (a report first; nothing is written until Apply)",
3322
3529
  children: "classify"
3323
3530
  }),
@@ -3329,20 +3536,20 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3329
3536
  }),
3330
3537
  /* @__PURE__ */ l("button", {
3331
3538
  type: "button",
3332
- onClick: () => void ut(),
3539
+ onClick: () => void lt(),
3333
3540
  title: "Download the whole document as a node/edge canvas graph (.canvas)",
3334
3541
  children: "↓ .canvas"
3335
3542
  }),
3336
3543
  p && /* @__PURE__ */ l("button", {
3337
3544
  type: "button",
3338
- className: ve ? "active" : "",
3339
- onClick: () => ye((e) => !e),
3545
+ className: pe ? "active" : "",
3546
+ onClick: () => me((e) => !e),
3340
3547
  title: "Document Assistant — instruct an agent to restructure/import/link chunks",
3341
3548
  children: "assistant"
3342
3549
  }),
3343
3550
  /* @__PURE__ */ l("button", {
3344
3551
  type: "button",
3345
- onClick: q,
3552
+ onClick: J,
3346
3553
  title: "Reload",
3347
3554
  children: "↻"
3348
3555
  })
@@ -3350,24 +3557,24 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3350
3557
  })
3351
3558
  ]
3352
3559
  }),
3353
- ue && /* @__PURE__ */ l("div", {
3560
+ R && /* @__PURE__ */ l("div", {
3354
3561
  className: "paths-err",
3355
- children: ue
3562
+ children: R
3356
3563
  }),
3357
- !Xe && /* @__PURE__ */ l(lt, {
3564
+ !Ue && /* @__PURE__ */ l(gt, {
3358
3565
  documentId: e,
3359
3566
  scope: n,
3360
3567
  browse: x,
3361
- rootFields: ke,
3362
- requestKey: De,
3363
- onClose: () => Oe(0),
3364
- onChanged: q
3568
+ rootFields: Oe,
3569
+ requestKey: Ee,
3570
+ onClose: () => De(0),
3571
+ onChanged: J
3365
3572
  }, `${n}:${e}`),
3366
- Xe ? /* @__PURE__ */ l(jt, {
3573
+ Ue ? /* @__PURE__ */ l(Rt, {
3367
3574
  documentId: e,
3368
3575
  scope: n,
3369
- detail: B ?? void 0
3370
- }) : /* @__PURE__ */ u(pe, {
3576
+ detail: de ?? void 0
3577
+ }) : /* @__PURE__ */ u(he, {
3371
3578
  className: "doc-split",
3372
3579
  defaultLeftWidth: 320,
3373
3580
  minLeftWidth: 160,
@@ -3375,16 +3582,16 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3375
3582
  storageKey: "loomcycle.explorer.split.doc",
3376
3583
  children: [/* @__PURE__ */ l("div", {
3377
3584
  className: "doc-chunktree",
3378
- children: de && S.length === 0 ? /* @__PURE__ */ l("div", {
3585
+ children: ce && S.length === 0 ? /* @__PURE__ */ l("div", {
3379
3586
  className: "empty",
3380
3587
  children: /* @__PURE__ */ l("p", { children: "Loading…" })
3381
- }) : /* @__PURE__ */ l($, {
3382
- tree: Y,
3588
+ }) : /* @__PURE__ */ l(Ye, {
3589
+ tree: Me,
3383
3590
  selectedId: w,
3384
3591
  onSelect: ot,
3385
- colorEnabled: We,
3592
+ colorEnabled: Q,
3386
3593
  scheme: W?.color_scheme,
3387
- linkedIds: Ge
3594
+ linkedIds: ze
3388
3595
  })
3389
3596
  }), /* @__PURE__ */ l("div", {
3390
3597
  className: "doc-content",
@@ -3392,18 +3599,18 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3392
3599
  /* @__PURE__ */ u("div", {
3393
3600
  className: "doc-content-head",
3394
3601
  children: [
3395
- Z.length > 0 && /* @__PURE__ */ u("nav", {
3602
+ X.length > 0 && /* @__PURE__ */ u("nav", {
3396
3603
  className: "chunk-ancestry",
3397
3604
  "aria-label": "Chunks above this one",
3398
3605
  children: [/* @__PURE__ */ l("button", {
3399
3606
  type: "button",
3400
3607
  className: "chunk-ancestry-up",
3401
- onClick: () => T(Z[Z.length - 1].id),
3402
- title: `Up to ${Z[Z.length - 1].title || "(untitled)"}`,
3608
+ onClick: () => T(X[X.length - 1].id),
3609
+ title: `Up to ${X[X.length - 1].title || "(untitled)"}`,
3403
3610
  children: "↰ Up"
3404
3611
  }), /* @__PURE__ */ u("ol", {
3405
3612
  className: "doc-trail-list",
3406
- children: [Z.map((e) => /* @__PURE__ */ l("li", {
3613
+ children: [X.map((e) => /* @__PURE__ */ l("li", {
3407
3614
  className: "doc-trail-item",
3408
3615
  children: /* @__PURE__ */ l("button", {
3409
3616
  type: "button",
@@ -3443,7 +3650,7 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3443
3650
  className: "chunk-tag",
3444
3651
  children: e
3445
3652
  }, e)),
3446
- /* @__PURE__ */ l(ze, {
3653
+ /* @__PURE__ */ l(Ke, {
3447
3654
  value: E.id,
3448
3655
  label: "chunk"
3449
3656
  })
@@ -3464,45 +3671,45 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3464
3671
  type: "button",
3465
3672
  className: O === "markdown" ? "active" : "",
3466
3673
  onClick: () => k("markdown"),
3467
- title: X ? "Whole document as Markdown" : "This chunk + its sub-chunks as Markdown",
3674
+ title: Y ? "Whole document as Markdown" : "This chunk + its sub-chunks as Markdown",
3468
3675
  children: "markdown"
3469
3676
  })]
3470
3677
  }),
3471
3678
  /* @__PURE__ */ l("button", {
3472
3679
  type: "button",
3473
3680
  className: "chunk-edit",
3474
- onClick: () => oe(E),
3681
+ onClick: () => re(E),
3475
3682
  children: "edit"
3476
3683
  }),
3477
3684
  b.documentEntityTypes && _(E) && /* @__PURE__ */ l("button", {
3478
3685
  type: "button",
3479
- onClick: () => P(E),
3686
+ onClick: () => ae(E),
3480
3687
  title: "Change this subject's type to another type in force",
3481
3688
  children: "change type"
3482
3689
  }),
3483
3690
  /* @__PURE__ */ l("button", {
3484
3691
  type: "button",
3485
- onClick: () => ce(!0),
3692
+ onClick: () => L(!0),
3486
3693
  title: "View this chunk's edit history + diffs",
3487
3694
  children: "history"
3488
3695
  }),
3489
- !X && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("button", {
3696
+ !Y && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("button", {
3490
3697
  type: "button",
3491
- onClick: () => void vt("up"),
3492
- disabled: !_t.canUp,
3698
+ onClick: () => void _t("up"),
3699
+ disabled: !ht.canUp,
3493
3700
  title: "Move this chunk up within its level",
3494
3701
  children: "↑"
3495
3702
  }), /* @__PURE__ */ l("button", {
3496
3703
  type: "button",
3497
- onClick: () => void vt("down"),
3498
- disabled: !_t.canDown,
3704
+ onClick: () => void _t("down"),
3705
+ disabled: !ht.canDown,
3499
3706
  title: "Move this chunk down within its level",
3500
3707
  children: "↓"
3501
3708
  })] }),
3502
- !X && /* @__PURE__ */ l("button", {
3709
+ !Y && /* @__PURE__ */ l("button", {
3503
3710
  type: "button",
3504
3711
  className: "danger",
3505
- onClick: () => F(!0),
3712
+ onClick: () => se(!0),
3506
3713
  title: "Delete this chunk and its sub-chunks",
3507
3714
  children: "delete"
3508
3715
  })
@@ -3512,20 +3719,20 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3512
3719
  }),
3513
3720
  /* @__PURE__ */ l("div", {
3514
3721
  className: "doc-content-body",
3515
- children: E.type === "mermaid" ? E.body ? /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(qe, { code: E.body }), O === "markdown" && /* @__PURE__ */ l("pre", {
3722
+ children: E.type === "mermaid" ? E.body ? /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(et, { code: E.body }), O === "markdown" && /* @__PURE__ */ l("pre", {
3516
3723
  className: "md-pre doc-mermaid-source",
3517
3724
  children: /* @__PURE__ */ l("code", { children: E.body })
3518
3725
  })] }) : /* @__PURE__ */ l("p", {
3519
3726
  className: "doc-empty-body",
3520
3727
  children: "(empty diagram)"
3521
- }) : E.type === "image" || E.asset ? re ? /* @__PURE__ */ u("p", {
3728
+ }) : E.type === "image" || E.asset ? F ? /* @__PURE__ */ u("p", {
3522
3729
  className: "doc-empty-body",
3523
- children: ["Image failed to load: ", re]
3524
- }) : te ? /* @__PURE__ */ u("figure", {
3730
+ children: ["Image failed to load: ", F]
3731
+ }) : N ? /* @__PURE__ */ u("figure", {
3525
3732
  className: "doc-image",
3526
3733
  children: [/* @__PURE__ */ l("img", {
3527
- src: te,
3528
- alt: Lt(E)
3734
+ src: N,
3735
+ alt: Wt(E)
3529
3736
  }), E.body && /* @__PURE__ */ l("figcaption", { children: E.body })]
3530
3737
  }) : /* @__PURE__ */ l("p", {
3531
3738
  className: "doc-empty-body",
@@ -3533,29 +3740,29 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3533
3740
  }) : O === "markdown" ? A === null ? /* @__PURE__ */ l("p", {
3534
3741
  className: "doc-empty-body",
3535
3742
  children: "Assembling Markdown…"
3536
- }) : /* @__PURE__ */ l(Ft, { source: A }) : E.body ? /* @__PURE__ */ l(Ft, { source: E.body }) : /* @__PURE__ */ l("p", {
3743
+ }) : /* @__PURE__ */ l(Ht, { source: A }) : E.body ? /* @__PURE__ */ l(Ht, { source: E.body }) : /* @__PURE__ */ l("p", {
3537
3744
  className: "doc-empty-body",
3538
3745
  children: "(empty chunk)"
3539
3746
  })
3540
3747
  }),
3541
- /* @__PURE__ */ l(Tt, {
3542
- edges: Se,
3748
+ /* @__PURE__ */ l(Mt, {
3749
+ edges: K,
3543
3750
  incomplete: Ce,
3544
3751
  documentId: e,
3545
3752
  selectedId: w,
3546
3753
  onSelectChunk: T,
3547
3754
  onOpenDocument: h ? st : void 0,
3548
- onRuleStatement: Qe
3755
+ onRuleStatement: Je
3549
3756
  }),
3550
- /* @__PURE__ */ l(Ct, {
3757
+ /* @__PURE__ */ l(At, {
3551
3758
  documentId: e,
3552
3759
  selectedId: w,
3553
3760
  scope: n,
3554
3761
  browse: x,
3555
3762
  onSelectChunk: T,
3556
3763
  onOpenDocument: h ? st : void 0,
3557
- refreshKey: Te,
3558
- review: nt
3764
+ refreshKey: q,
3765
+ review: $e
3559
3766
  })
3560
3767
  ] }) : /* @__PURE__ */ l("div", {
3561
3768
  className: "empty",
@@ -3563,50 +3770,50 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3563
3770
  })
3564
3771
  })]
3565
3772
  }),
3566
- ve && p && /* @__PURE__ */ l("div", {
3773
+ pe && p && /* @__PURE__ */ l("div", {
3567
3774
  className: "doc-assistant",
3568
3775
  children: p({
3569
3776
  documentId: e,
3570
3777
  scope: n,
3571
3778
  subject: f?.subject,
3572
- onChanged: q
3779
+ onChanged: J
3573
3780
  })
3574
3781
  }),
3575
- ae && /* @__PURE__ */ l(Je, {
3576
- chunk: ae,
3782
+ ne && /* @__PURE__ */ l(tt, {
3783
+ chunk: ne,
3577
3784
  scope: n,
3578
3785
  browse: x,
3579
- onClose: () => oe(null),
3580
- onSaved: q
3786
+ onClose: () => re(null),
3787
+ onSaved: J
3581
3788
  }),
3582
- N && /* @__PURE__ */ l(Ye, {
3583
- chunk: N,
3789
+ ie && /* @__PURE__ */ l(nt, {
3790
+ chunk: ie,
3584
3791
  scope: n,
3585
3792
  browse: x,
3586
- onClose: () => P(null),
3587
- onSaved: q
3793
+ onClose: () => ae(null),
3794
+ onSaved: J
3588
3795
  }),
3589
- se && E && /* @__PURE__ */ l(Nt, {
3796
+ I && E && /* @__PURE__ */ l(Bt, {
3590
3797
  chunkId: E.id,
3591
3798
  chunkTitle: E.title,
3592
3799
  scope: n,
3593
3800
  browse: x,
3594
- onClose: () => ce(!1)
3801
+ onClose: () => L(!1)
3595
3802
  }),
3596
- be && Q && /* @__PURE__ */ l(ft, {
3803
+ G && Z && /* @__PURE__ */ l(yt, {
3597
3804
  documentId: e,
3598
- rootChunkId: Q,
3805
+ rootChunkId: Z,
3599
3806
  docType: W?.type,
3600
3807
  docStatus: W?.status,
3601
- chunkStatuses: Ue,
3808
+ chunkStatuses: Re,
3602
3809
  scope: n,
3603
3810
  browse: x,
3604
- onClose: () => xe(!1),
3605
- onSaved: q
3811
+ onClose: () => ye(!1),
3812
+ onSaved: J
3606
3813
  }),
3607
- le && E && /* @__PURE__ */ l("div", {
3814
+ oe && E && /* @__PURE__ */ l("div", {
3608
3815
  className: "modal-overlay",
3609
- onClick: () => F(!1),
3816
+ onClick: () => se(!1),
3610
3817
  children: /* @__PURE__ */ u("div", {
3611
3818
  className: "modal chunk-delete-confirm",
3612
3819
  onClick: (e) => e.stopPropagation(),
@@ -3624,12 +3831,12 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3624
3831
  className: "modal-buttons",
3625
3832
  children: [/* @__PURE__ */ l("button", {
3626
3833
  type: "button",
3627
- onClick: () => F(!1),
3834
+ onClick: () => se(!1),
3628
3835
  children: "cancel"
3629
3836
  }), /* @__PURE__ */ l("button", {
3630
3837
  type: "button",
3631
3838
  className: "danger",
3632
- onClick: () => void yt(),
3839
+ onClick: () => void vt(),
3633
3840
  children: "delete"
3634
3841
  })]
3635
3842
  })
@@ -3641,7 +3848,7 @@ function Rt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3641
3848
  }
3642
3849
  //#endregion
3643
3850
  //#region src/components/PathTree.tsx
3644
- function zt(e, t = "") {
3851
+ function Kt(e, t = "") {
3645
3852
  let n = e.get(t);
3646
3853
  if (!n) return [];
3647
3854
  let r = n.entries.map((n) => {
@@ -3652,7 +3859,7 @@ function zt(e, t = "") {
3652
3859
  kind: n.kind,
3653
3860
  resourceRef: n.resource_ref,
3654
3861
  listing: r ? e.get(n.full_path) : void 0,
3655
- children: r ? zt(e, n.full_path) : []
3862
+ children: r ? Kt(e, n.full_path) : []
3656
3863
  };
3657
3864
  });
3658
3865
  return r.sort((e, t) => {
@@ -3660,13 +3867,13 @@ function zt(e, t = "") {
3660
3867
  return n === (t.kind === "directory") ? e.name.localeCompare(t.name) : n ? -1 : 1;
3661
3868
  }), r;
3662
3869
  }
3663
- var Bt = {
3870
+ var qt = {
3664
3871
  directory: "📁",
3665
3872
  document: "📄",
3666
3873
  volume_mount: "💾",
3667
3874
  memory_entry: "🧠"
3668
3875
  };
3669
- function Vt(e) {
3876
+ function Jt(e) {
3670
3877
  let { tree: t, root: n } = e;
3671
3878
  return !n || !n.loaded && n.loading ? /* @__PURE__ */ l("div", {
3672
3879
  className: "empty",
@@ -3676,17 +3883,17 @@ function Vt(e) {
3676
3883
  children: /* @__PURE__ */ l("p", { children: "This tree is empty. Create a folder or document to begin." })
3677
3884
  }) : /* @__PURE__ */ u("ul", {
3678
3885
  className: "tree path-tree",
3679
- children: [t.map((t) => /* @__PURE__ */ l(Wt, {
3886
+ children: [t.map((t) => /* @__PURE__ */ l(Zt, {
3680
3887
  node: t,
3681
3888
  ...e
3682
- }, t.fullPath)), /* @__PURE__ */ l(Ht, {
3889
+ }, t.fullPath)), /* @__PURE__ */ l(Yt, {
3683
3890
  dir: "",
3684
3891
  listing: n,
3685
3892
  ...e
3686
3893
  })]
3687
3894
  });
3688
3895
  }
3689
- function Ht({ dir: e, listing: t, onLoadMore: n, onRetry: r }) {
3896
+ function Yt({ dir: e, listing: t, onLoadMore: n, onRetry: r }) {
3690
3897
  let i = [];
3691
3898
  return !t || t.loading && t.entries.length === 0 ? i.push(/* @__PURE__ */ l("li", {
3692
3899
  className: "node path-status",
@@ -3726,13 +3933,13 @@ function Ht({ dir: e, listing: t, onLoadMore: n, onRetry: r }) {
3726
3933
  })
3727
3934
  }, "more")), /* @__PURE__ */ l(c, { children: i });
3728
3935
  }
3729
- function Ut(e, t) {
3936
+ function Xt(e, t) {
3730
3937
  if (e.kind !== "document" || !t) return;
3731
3938
  let n = e.resourceRef;
3732
3939
  return n?.document_id ? t.get(n.document_id) : void 0;
3733
3940
  }
3734
- function Wt(e) {
3735
- let { node: t, expanded: n, onToggle: r, selectedPath: i, onSelect: a, summaries: o } = e, s = t.kind === "directory", c = s && n.has(t.fullPath), d = i === t.fullPath, f = Ut(t, o), p = f && f.color_enabled ? Re(Le(f.type, f.status, Ie(f.color_scheme))) : void 0;
3941
+ function Zt(e) {
3942
+ let { node: t, expanded: n, onToggle: r, selectedPath: i, onSelect: a, summaries: o } = e, s = t.kind === "directory", c = s && n.has(t.fullPath), d = i === t.fullPath, f = Xt(t, o), p = f && f.color_enabled ? We(Ve(f.type, f.status, Be(f.color_scheme))) : void 0;
3736
3943
  return /* @__PURE__ */ u("li", {
3737
3944
  className: `node path-node kind-${t.kind} ${d ? "selected" : ""}`,
3738
3945
  children: [/* @__PURE__ */ u("div", {
@@ -3757,7 +3964,7 @@ function Wt(e) {
3757
3964
  /* @__PURE__ */ l("span", {
3758
3965
  className: "path-kind-icon",
3759
3966
  "aria-hidden": !0,
3760
- children: Bt[t.kind] ?? "•"
3967
+ children: qt[t.kind] ?? "•"
3761
3968
  }),
3762
3969
  /* @__PURE__ */ l("span", {
3763
3970
  className: "path-name",
@@ -3775,10 +3982,10 @@ function Wt(e) {
3775
3982
  })]
3776
3983
  }), c && /* @__PURE__ */ u("ul", {
3777
3984
  className: "children path-children",
3778
- children: [t.children.map((t) => /* @__PURE__ */ l(Wt, {
3985
+ children: [t.children.map((t) => /* @__PURE__ */ l(Zt, {
3779
3986
  ...e,
3780
3987
  node: t
3781
- }, t.fullPath)), /* @__PURE__ */ l(Ht, {
3988
+ }, t.fullPath)), /* @__PURE__ */ l(Yt, {
3782
3989
  ...e,
3783
3990
  dir: t.fullPath,
3784
3991
  listing: t.listing
@@ -3788,23 +3995,23 @@ function Wt(e) {
3788
3995
  }
3789
3996
  //#endregion
3790
3997
  //#region src/PathExplorer.tsx
3791
- var Gt = /^[A-Za-z0-9._-]+$/;
3792
- function Kt(e, t) {
3998
+ var Qt = /^[A-Za-z0-9._-]+$/;
3999
+ function $t(e, t) {
3793
4000
  return `${e}/${t}`;
3794
4001
  }
3795
- function qt(e, t) {
4002
+ function en(e, t) {
3796
4003
  for (let n of e) {
3797
4004
  if (n.fullPath === t) return n;
3798
- let e = qt(n.children, t);
4005
+ let e = en(n.children, t);
3799
4006
  if (e) return e;
3800
4007
  }
3801
4008
  }
3802
- function Jt(e) {
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, {
4009
+ function tn(e) {
4010
+ let { theme: t, defaultScope: n, path: r, onPathChange: i, browse: a, principal: o, renderAssistant: s, renderNavigator: c, navigator: u, onError: d } = e, f = R(e);
4011
+ return /* @__PURE__ */ l(z, {
3805
4012
  theme: t,
3806
4013
  dataLayer: f,
3807
- children: /* @__PURE__ */ l(Yt, {
4014
+ children: /* @__PURE__ */ l(nn, {
3808
4015
  defaultScope: n,
3809
4016
  path: r,
3810
4017
  onPathChange: i,
@@ -3817,77 +4024,77 @@ function Jt(e) {
3817
4024
  })
3818
4025
  });
3819
4026
  }
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);
4027
+ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p, renderAssistant: m, renderNavigator: _, navigator: v, onError: y }) {
4028
+ let b = M(), [x, S] = o(e ?? "user"), [C, w] = o(void 0), [T, E] = o(null), [D, O] = o(null), [k, A] = o(null), [j, N] = o(() => /* @__PURE__ */ new Set()), P = n === void 0 ? C : n, te = a(d);
3822
4029
  r(() => {
3823
- ae.current = d;
4030
+ te.current = d;
3824
4031
  }, [d]);
3825
- let oe = a(y);
4032
+ let ne = a(y);
3826
4033
  r(() => {
3827
- oe.current = y;
4034
+ ne.current = y;
3828
4035
  }, [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]);
4036
+ let [I, L] = o([]), oe = a(0), se = a(void 0), R = t((e) => {
4037
+ se.current = e, te.current?.(e), w(e);
4038
+ }, []), z = t((e) => {
4039
+ oe.current++, L((e) => e.length > 0 ? [] : e), R(e);
4040
+ }, [R]);
3834
4041
  r(() => {
3835
- n !== void 0 && n !== I.current && (F.current++, P((e) => e.length > 0 ? [] : e));
4042
+ n !== void 0 && n !== se.current && (oe.current++, L((e) => e.length > 0 ? [] : e));
3836
4043
  }, [n]);
3837
- let z = i(() => f && (f.scopeId || f.tenant) ? {
4044
+ let B = i(() => f && (f.scopeId || f.tenant) ? {
3838
4045
  scopeId: f.scopeId,
3839
4046
  tenant: f.tenant
3840
- } : void 0, [f?.scopeId, f?.tenant]), B = i(() => new te(b, x, z), [
4047
+ } : void 0, [f?.scopeId, f?.tenant]), V = i(() => new re(b, x, B), [
3841
4048
  b,
3842
4049
  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);
4050
+ B
4051
+ ]), H = s(V.subscribe, V.getSnapshot), U = t((e) => {
4052
+ ne.current?.(e);
4053
+ }, []), [W, ge] = o(() => _ ? h(globalThis.localStorage) : "tree"), G = !!_ && W === "stars", _e = t((e) => {
4054
+ ge(e), g(globalThis.localStorage, e), e === "tree" && ye(!1);
4055
+ }, []), [ve, ye] = o(!1), [be, xe] = o(0);
3849
4056
  r(() => {
3850
- _ && v && ge(v);
4057
+ _ && v && _e(v);
3851
4058
  }, [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);
4059
+ let [K, Se] = o(), [Ce, we] = o(), q = t((e, t) => (xe((e) => e + 1), V.invalidate(e, t)), [V]), [Te, Ee] = o(() => /* @__PURE__ */ new Map()), De = a(/* @__PURE__ */ new Set()), Oe = a(0), ke = t(() => {
4060
+ Oe.current++, De.current = /* @__PURE__ */ new Set(), Ee(/* @__PURE__ */ new Map());
4061
+ }, []), J = a(!0);
3855
4062
  r(() => {
3856
- Oe.current ? Oe.current = !1 : (R(void 0), E(null), ie(/* @__PURE__ */ new Set()), De()), B.loadDir("").catch(H);
4063
+ J.current ? J.current = !1 : (z(void 0), E(null), N(/* @__PURE__ */ new Set()), ke()), V.loadDir("").catch(U);
3857
4064
  }, [
3858
- B,
3859
- R,
3860
- De,
3861
- H
4065
+ V,
4066
+ z,
4067
+ ke,
4068
+ U
3862
4069
  ]), r(() => {
3863
- for (let e of j) V.has(e) || B.loadDir(e).catch(H);
4070
+ for (let e of j) H.has(e) || V.loadDir(e).catch(U);
3864
4071
  }, [
3865
- B,
3866
- j,
3867
4072
  V,
3868
- H
4073
+ j,
4074
+ H,
4075
+ U
3869
4076
  ]);
3870
- let ke = a(null);
4077
+ let Ae = a(null);
3871
4078
  r(() => {
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) => {
4079
+ let e = Ae.current !== null && Ae.current !== V;
4080
+ if (Ae.current = V, !P || e) return;
4081
+ let t = ee(P).filter((e) => e !== "");
4082
+ N((e) => {
3876
4083
  if (t.every((t) => e.has(t))) return e;
3877
4084
  let n = new Set(e);
3878
4085
  return t.forEach((e) => n.add(e)), n;
3879
- }), B.reveal(M).catch(H);
4086
+ }), V.reveal(P).catch(U);
3880
4087
  }, [
3881
- B,
3882
- M,
3883
- H
4088
+ V,
4089
+ P,
4090
+ U
3884
4091
  ]), r(() => {
3885
4092
  if (x === "tenant") return;
3886
4093
  let e = [];
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) => {
4094
+ for (let t of H.values()) for (let n of ae(t.entries)) De.current.has(n) || (De.current.add(n), e.push(n));
4095
+ let t = Oe.current;
4096
+ for (let n = 0; n < e.length; n += 500) b.documentsSummary({ documentIds: e.slice(n, n + 500) }, x, B).then((e) => {
4097
+ Oe.current === t && Ee((t) => {
3891
4098
  let n = new Map(t);
3892
4099
  for (let t of e.documents ?? []) n.set(t.document_id, t);
3893
4100
  return n;
@@ -3895,32 +4102,32 @@ function Yt({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
3895
4102
  }).catch(() => {});
3896
4103
  }, [
3897
4104
  b,
3898
- V,
4105
+ H,
3899
4106
  x,
3900
- z
4107
+ B
3901
4108
  ]);
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);
4109
+ let je = i(() => Kt(H), [H]), Me = t(async () => {
4110
+ E(null), ke(), xe((e) => e + 1), await V.refresh(j).catch(U), P && await V.reveal(P).catch(U);
3904
4111
  }, [
3905
- B,
4112
+ V,
3906
4113
  j,
3907
- M,
3908
- De,
3909
- H
3910
- ]), je = t((e) => {
3911
- ie((t) => {
4114
+ P,
4115
+ ke,
4116
+ U
4117
+ ]), Ne = t((e) => {
4118
+ N((t) => {
3912
4119
  let n = new Set(t);
3913
4120
  return n.has(e) ? n.delete(e) : n.add(e), n;
3914
4121
  });
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);
4122
+ }, []), Y = t((e) => V.loadMore(e).catch(U), [V, U]), X = t((e) => {
4123
+ (V.getSnapshot().get(e)?.loaded ? V.loadMore(e) : V.loadDir(e)).catch(U);
4124
+ }, [V, U]), Z = i(() => P ? en(je, P) : void 0, [je, P]), Pe = H.get("")?.error, Fe = Z?.kind === "directory" ? Z.fullPath : void 0, [Ie, Le] = o(null);
3918
4125
  r(() => {
3919
- if (!Y || !b.pathIsStored) return;
4126
+ if (!Fe || !b.pathIsStored) return;
3920
4127
  let e = !1;
3921
- return b.pathIsStored(Y, x, z).then((t) => {
3922
- e || Ie({
3923
- path: Y,
4128
+ return b.pathIsStored(Fe, x, B).then((t) => {
4129
+ e || Le({
4130
+ path: Fe,
3924
4131
  explicit: t
3925
4132
  });
3926
4133
  }, () => {}), () => {
@@ -3928,13 +4135,13 @@ function Yt({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
3928
4135
  };
3929
4136
  }, [
3930
4137
  b,
3931
- Y,
4138
+ Fe,
3932
4139
  x,
3933
- z
4140
+ B
3934
4141
  ]);
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}`,
4142
+ let Re = Z ? Z.kind === "directory" ? Ie?.path === Z.fullPath ? Ie.explicit ? "yes" : "implicit (no entry)" : void 0 : "yes" : void 0, Q = i(() => Z ? Z.kind === "directory" ? Z.fullPath : F(Z.fullPath) : "", [Z]), ze = Q || "/", Be = x !== "tenant", Ve = t(() => {
4143
+ O({
4144
+ title: `New folder in ${ze}`,
3938
4145
  fields: [{
3939
4146
  key: "name",
3940
4147
  label: "Folder name",
@@ -3943,23 +4150,23 @@ function Yt({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
3943
4150
  submitLabel: "Create",
3944
4151
  onSubmit: async (e) => {
3945
4152
  let t = e.name.trim();
3946
- if (!Gt.test(t)) throw Error("name may contain only [A-Za-z0-9._-]");
3947
- let n = Kt(X, t);
3948
- await b.pathMkdir(n, x, z), await K(n).catch(H), R(n);
4153
+ if (!Qt.test(t)) throw Error("name may contain only [A-Za-z0-9._-]");
4154
+ let n = $t(Q, t);
4155
+ await b.pathMkdir(n, x, B), await q(n).catch(U), z(n);
3949
4156
  }
3950
4157
  });
3951
4158
  }, [
3952
4159
  b,
3953
- B,
3954
- X,
3955
- Z,
4160
+ V,
4161
+ Q,
4162
+ ze,
3956
4163
  x,
3957
- z,
3958
- H,
3959
- R
3960
- ]), ze = t(() => {
3961
- A({
3962
- title: `New document in ${Z}`,
4164
+ B,
4165
+ U,
4166
+ z
4167
+ ]), He = t(() => {
4168
+ O({
4169
+ title: `New document in ${ze}`,
3963
4170
  fields: [{
3964
4171
  key: "name",
3965
4172
  label: "Path name",
@@ -3972,368 +4179,423 @@ function Yt({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
3972
4179
  submitLabel: "Create",
3973
4180
  onSubmit: async (e) => {
3974
4181
  let t = e.name.trim();
3975
- if (!Gt.test(t)) throw Error("name may contain only [A-Za-z0-9._-]");
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);
4182
+ if (!Qt.test(t)) throw Error("name may contain only [A-Za-z0-9._-]");
4183
+ let n = e.title.trim() || t, r = $t(Q, t);
4184
+ await b.documentCreate(n, r, x, B), await q(r).catch(U), z(r);
3978
4185
  }
3979
4186
  });
3980
4187
  }, [
3981
4188
  b,
3982
- B,
3983
- X,
3984
- Z,
4189
+ V,
4190
+ Q,
4191
+ ze,
3985
4192
  x,
3986
- z,
3987
- H,
3988
- R
3989
- ]), Be = t(() => {
3990
- J && A({
3991
- title: `Rename / move ${J.fullPath}`,
4193
+ B,
4194
+ U,
4195
+ z
4196
+ ]), Ue = t(() => {
4197
+ Z && O({
4198
+ title: `Rename / move ${Z.fullPath}`,
3992
4199
  fields: [{
3993
4200
  key: "to",
3994
4201
  label: "New path",
3995
- value: J.fullPath
4202
+ value: Z.fullPath
3996
4203
  }],
3997
4204
  submitLabel: "Move",
3998
4205
  onSubmit: async (e) => {
3999
4206
  let t = e.to.trim();
4000
4207
  if (!t.startsWith("/")) throw Error("path must start with /");
4001
- await b.pathMv(J.fullPath, t, x, z), await Promise.all([K(J.fullPath, { dropSubtree: !0 }), K(t)]).catch(H), R(t);
4208
+ await b.pathMv(Z.fullPath, t, x, B), await Promise.all([q(Z.fullPath, { dropSubtree: !0 }), q(t)]).catch(U), z(t);
4002
4209
  }
4003
4210
  });
4004
4211
  }, [
4005
4212
  b,
4006
- B,
4007
- J,
4213
+ V,
4214
+ Z,
4008
4215
  x,
4009
- z,
4010
- H,
4011
- R
4012
- ]), Ve = t(() => {
4013
- if (!J) return;
4014
- if (J.kind === "document") {
4015
- let e = J.resourceRef?.document_id;
4016
- A({
4017
- title: `Delete document ${J.fullPath}`,
4216
+ B,
4217
+ U,
4218
+ z
4219
+ ]), We = t(() => {
4220
+ if (!Z) return;
4221
+ if (Z.kind === "document") {
4222
+ let e = Z.resourceRef?.document_id;
4223
+ O({
4224
+ title: `Delete document ${Z.fullPath}`,
4018
4225
  message: "This deletes the document, all its chunks, and its path entry. This cannot be undone.",
4019
4226
  fields: [],
4020
4227
  submitLabel: "Delete",
4021
4228
  danger: !0,
4022
4229
  onSubmit: async () => {
4023
4230
  if (!e) throw Error("this document dirent has no document_id");
4024
- await b.documentDelete(e, x, z), await K(J.fullPath).catch(H), R(void 0);
4231
+ await b.documentDelete(e, x, B), await q(Z.fullPath).catch(U), z(void 0);
4025
4232
  }
4026
4233
  });
4027
4234
  return;
4028
4235
  }
4029
- let e = J;
4236
+ let e = Z;
4030
4237
  E(null), (async () => {
4031
4238
  let t;
4032
4239
  try {
4033
- t = await ne(b, e.fullPath, x, z);
4240
+ t = await ie(b, e.fullPath, x, B);
4034
4241
  } catch (t) {
4035
4242
  E(`could not list ${e.fullPath} for delete: ${t instanceof Error ? t.message : String(t)}`);
4036
4243
  return;
4037
4244
  }
4038
- let n = x === "tenant" ? [] : re(t);
4039
- A({
4245
+ let n = x === "tenant" ? [] : ae(t);
4246
+ O({
4040
4247
  title: `Delete branch ${e.fullPath}`,
4041
4248
  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.` : "."),
4042
4249
  fields: [],
4043
4250
  submitLabel: "Delete",
4044
4251
  danger: !0,
4045
4252
  onSubmit: async () => {
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);
4253
+ for (let e of n) await b.documentDelete(e, x, B);
4254
+ await b.pathRm(e.fullPath, x, !0, B), await q(e.fullPath, { dropSubtree: !0 }).catch(U), z(void 0);
4048
4255
  }
4049
4256
  });
4050
4257
  })();
4051
4258
  }, [
4052
4259
  b,
4260
+ V,
4261
+ Z,
4262
+ x,
4053
4263
  B,
4054
- J,
4264
+ U,
4265
+ z
4266
+ ]), Ge = Z && (Z.kind === "directory" || Z.kind === "document"), Ke = !!b.documentsTransfer && !!Ge, qe = t(() => {
4267
+ if (Z) {
4268
+ if (Z.kind === "document") {
4269
+ let e = Z.resourceRef?.document_id;
4270
+ if (!e) {
4271
+ E("this document entry has no document_id");
4272
+ return;
4273
+ }
4274
+ A({
4275
+ documentId: e,
4276
+ fromPath: Z.fullPath
4277
+ });
4278
+ } else A({
4279
+ underPath: Z.fullPath,
4280
+ fromPath: Z.fullPath
4281
+ });
4282
+ }
4283
+ }, [Z]), Je = t((e) => {
4284
+ e.op === "move" ? (q(e.from, { dropSubtree: !0 }).catch(U), L([]), z(void 0)) : e.toScope === x && q(e.to).catch(U);
4285
+ }, [
4286
+ q,
4287
+ U,
4055
4288
  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];
4061
- if (J?.kind === "document") return {
4062
- documentId: J.resourceRef?.document_id ?? "",
4063
- path: J.fullPath,
4064
- title: J.name
4289
+ z
4290
+ ]), $ = i(() => {
4291
+ if (I.length > 0) return I[I.length - 1];
4292
+ if (Z?.kind === "document") return {
4293
+ documentId: Z.resourceRef?.document_id ?? "",
4294
+ path: Z.fullPath,
4295
+ title: Z.name
4065
4296
  };
4066
- }, [N, J]), Ue = t((e, t) => {
4067
- let n = ++F.current, r = de(B.getSnapshot(), e.documentId);
4068
- P(se(N, {
4297
+ }, [I, Z]), Ye = t((e, t) => {
4298
+ let n = ++oe.current, r = fe(V.getSnapshot(), e.documentId);
4299
+ L(ce(I, {
4069
4300
  ...t,
4070
4301
  path: $?.path
4071
4302
  }, {
4072
4303
  ...e,
4073
4304
  path: r
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));
4305
+ })), R(r), !r && b.documentPath && b.documentPath(e.documentId, x, B).then((t) => {
4306
+ t && oe.current === n && (L((n) => ue(n, e.documentId, { path: t })), R(t));
4076
4307
  }, () => {});
4077
4308
  }, [
4078
4309
  b,
4079
- B,
4080
- N,
4310
+ V,
4311
+ I,
4081
4312
  $?.path,
4082
4313
  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) => ({
4314
+ B,
4315
+ R
4316
+ ]), Xe = t((e) => {
4317
+ let t = le(I, e);
4318
+ t !== I && (oe.current++, L(t), R(t[t.length - 1].path));
4319
+ }, [I, R]), Ze = t((e, t) => L((n) => ue(n, e, { title: t })), []), Qe = t((e) => {
4320
+ we((t) => ({
4090
4321
  documentId: e.documentId,
4091
4322
  chunkId: e.chunkId,
4092
4323
  seq: (t?.seq ?? 0) + 1
4093
- })), $?.documentId !== e.documentId && (e.path ? R(e.path) : (F.current++, P([{
4324
+ })), $?.documentId !== e.documentId && (e.path ? z(e.path) : (oe.current++, L([{
4094
4325
  documentId: e.documentId,
4095
4326
  chunkId: e.chunkId
4096
- }]), L(void 0)));
4327
+ }]), R(void 0)));
4097
4328
  }, [
4098
4329
  $?.documentId,
4099
- R,
4100
- L
4101
- ]), qe = i(() => ({
4330
+ z,
4331
+ R
4332
+ ]), $e = i(() => ({
4102
4333
  scope: x,
4103
- browse: z,
4334
+ browse: B,
4104
4335
  selection: {
4105
4336
  documentId: $?.documentId,
4106
- chunkId: G && G.documentId === $?.documentId ? G.chunkId : void 0,
4337
+ chunkId: K && K.documentId === $?.documentId ? K.chunkId : void 0,
4107
4338
  path: $?.path
4108
4339
  },
4109
- onSelect: Ke,
4110
- reloadToken: ye,
4111
- maximized: _e,
4112
- onToggleMaximize: () => ve((e) => !e),
4340
+ onSelect: Qe,
4341
+ reloadToken: be,
4342
+ maximized: ve,
4343
+ onToggleMaximize: () => ye((e) => !e),
4113
4344
  subject: p?.subject
4114
4345
  }), [
4115
4346
  x,
4116
- z,
4347
+ B,
4117
4348
  $?.documentId,
4118
4349
  $?.path,
4119
- G,
4120
- Ke,
4121
- ye,
4122
- _e,
4350
+ K,
4351
+ Qe,
4352
+ be,
4353
+ ve,
4123
4354
  p?.subject
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,
4128
- minLeftWidth: 280,
4129
- minRightWidth: 300,
4130
- storageKey: U ? "loomcycle.explorer.split.stars" : "loomcycle.explorer.split.paths",
4131
- hideRight: U && _e,
4132
- children: [/* @__PURE__ */ u("div", {
4133
- className: "left",
4134
- children: [
4135
- /* @__PURE__ */ u("div", {
4136
- className: "paths-toolbar",
4355
+ ]), et = Ce && $ && Ce.documentId === $.documentId ? Ce : void 0, tt = !!$?.path && Z?.kind === "document" && Z.fullPath === $.path;
4356
+ return /* @__PURE__ */ u(c, { children: [
4357
+ /* @__PURE__ */ u(he, {
4358
+ className: G ? "paths-view paths-view--stars" : "paths-view",
4359
+ defaultLeftWidth: G ? 720 : 420,
4360
+ minLeftWidth: 280,
4361
+ minRightWidth: 300,
4362
+ storageKey: G ? "loomcycle.explorer.split.stars" : "loomcycle.explorer.split.paths",
4363
+ hideRight: G && ve,
4364
+ children: [/* @__PURE__ */ u("div", {
4365
+ className: "left",
4366
+ children: [
4367
+ /* @__PURE__ */ u("div", {
4368
+ className: "paths-toolbar",
4369
+ children: [
4370
+ /* @__PURE__ */ u("label", {
4371
+ className: "paths-scope",
4372
+ children: [/* @__PURE__ */ l("span", { children: "scope" }), /* @__PURE__ */ u("select", {
4373
+ value: x,
4374
+ onChange: (e) => S(e.target.value),
4375
+ children: [
4376
+ /* @__PURE__ */ l("option", {
4377
+ value: "user",
4378
+ children: "user"
4379
+ }),
4380
+ /* @__PURE__ */ l("option", {
4381
+ value: "agent",
4382
+ children: "agent"
4383
+ }),
4384
+ /* @__PURE__ */ l("option", {
4385
+ value: "tenant",
4386
+ children: "tenant"
4387
+ })
4388
+ ]
4389
+ })]
4390
+ }),
4391
+ _ && /* @__PURE__ */ u("div", {
4392
+ className: "paths-nav-switch",
4393
+ role: "group",
4394
+ "aria-label": "Navigator",
4395
+ children: [/* @__PURE__ */ l("button", {
4396
+ type: "button",
4397
+ "aria-pressed": !G,
4398
+ className: G ? void 0 : "active",
4399
+ onClick: () => _e("tree"),
4400
+ title: "Browse the Path tree",
4401
+ children: "tree"
4402
+ }), /* @__PURE__ */ l("button", {
4403
+ type: "button",
4404
+ "aria-pressed": G,
4405
+ className: G ? "active" : void 0,
4406
+ onClick: () => _e("stars"),
4407
+ title: "Browse the scope as a 3D star map",
4408
+ children: "stars"
4409
+ })]
4410
+ }),
4411
+ /* @__PURE__ */ u("div", {
4412
+ className: "paths-toolbar-actions",
4413
+ children: [!G && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("button", {
4414
+ type: "button",
4415
+ onClick: Ve,
4416
+ title: `New folder in ${ze}`,
4417
+ children: "+ folder"
4418
+ }), /* @__PURE__ */ l("button", {
4419
+ type: "button",
4420
+ onClick: He,
4421
+ disabled: !Be,
4422
+ title: Be ? `New document in ${ze}` : "Documents are agent/user scope only",
4423
+ children: "+ document"
4424
+ })] }), /* @__PURE__ */ l("button", {
4425
+ type: "button",
4426
+ onClick: () => void Me(),
4427
+ title: "Reload the tree",
4428
+ children: "↻"
4429
+ })]
4430
+ })
4431
+ ]
4432
+ }),
4433
+ !G && /* @__PURE__ */ u("p", {
4434
+ className: "paths-context",
4435
+ children: [
4436
+ "new items → ",
4437
+ /* @__PURE__ */ l("code", { children: ze }),
4438
+ B?.scopeId && /* @__PURE__ */ u(c, { children: [
4439
+ " · ",
4440
+ "subject ",
4441
+ /* @__PURE__ */ l("code", { children: B.scopeId })
4442
+ ] }),
4443
+ B?.tenant && /* @__PURE__ */ u(c, { children: [
4444
+ " · ",
4445
+ "tenant ",
4446
+ /* @__PURE__ */ l("code", { children: B.tenant })
4447
+ ] })
4448
+ ]
4449
+ }),
4450
+ (T || Pe) && /* @__PURE__ */ l("div", {
4451
+ className: "paths-err",
4452
+ children: T || Pe
4453
+ }),
4454
+ G && _ ? /* @__PURE__ */ l("div", {
4455
+ className: "paths-navigator",
4456
+ children: _($e)
4457
+ }) : /* @__PURE__ */ l(Jt, {
4458
+ tree: je,
4459
+ root: H.get(""),
4460
+ expanded: j,
4461
+ onToggle: Ne,
4462
+ onLoadMore: Y,
4463
+ onRetry: X,
4464
+ selectedPath: P,
4465
+ onSelect: (e) => z(e.fullPath),
4466
+ summaries: Te
4467
+ })
4468
+ ]
4469
+ }), /* @__PURE__ */ l("div", {
4470
+ className: "right",
4471
+ children: $ ? /* @__PURE__ */ u("div", {
4472
+ className: "paths-doc",
4137
4473
  children: [
4138
- /* @__PURE__ */ u("label", {
4139
- className: "paths-scope",
4140
- children: [/* @__PURE__ */ l("span", { children: "scope" }), /* @__PURE__ */ u("select", {
4141
- value: x,
4142
- onChange: (e) => S(e.target.value),
4474
+ /* @__PURE__ */ l(pe, {
4475
+ trail: I,
4476
+ onJump: Xe
4477
+ }),
4478
+ /* @__PURE__ */ u("div", {
4479
+ className: "paths-doc-head",
4480
+ children: [$.path ? /* @__PURE__ */ l("code", {
4481
+ className: "paths-doc-path",
4482
+ children: $.path
4483
+ }) : /* @__PURE__ */ u("span", {
4484
+ className: "paths-doc-path paths-doc-unfiled",
4485
+ title: "Opened by id — no entry for this document was found in the Path tree",
4486
+ children: [
4487
+ de($),
4488
+ " ",
4489
+ /* @__PURE__ */ l("em", { children: "· opened by id, not in the tree" })
4490
+ ]
4491
+ }), tt && /* @__PURE__ */ u("div", {
4492
+ className: "paths-detail-actions",
4143
4493
  children: [
4144
- /* @__PURE__ */ l("option", {
4145
- value: "user",
4146
- children: "user"
4494
+ /* @__PURE__ */ l("button", {
4495
+ type: "button",
4496
+ onClick: Ue,
4497
+ children: "rename / move"
4147
4498
  }),
4148
- /* @__PURE__ */ l("option", {
4149
- value: "agent",
4150
- children: "agent"
4499
+ Ke && /* @__PURE__ */ l("button", {
4500
+ type: "button",
4501
+ onClick: qe,
4502
+ title: "Copy or move to another scope",
4503
+ children: "copy / move to…"
4151
4504
  }),
4152
- /* @__PURE__ */ l("option", {
4153
- value: "tenant",
4154
- children: "tenant"
4505
+ /* @__PURE__ */ l("button", {
4506
+ type: "button",
4507
+ className: "danger",
4508
+ onClick: We,
4509
+ children: "delete"
4155
4510
  })
4156
4511
  ]
4157
4512
  })]
4158
4513
  }),
4159
- _ && /* @__PURE__ */ u("div", {
4160
- className: "paths-nav-switch",
4161
- role: "group",
4162
- "aria-label": "Navigator",
4163
- children: [/* @__PURE__ */ l("button", {
4164
- type: "button",
4165
- "aria-pressed": !U,
4166
- className: U ? void 0 : "active",
4167
- onClick: () => ge("tree"),
4168
- title: "Browse the Path tree",
4169
- children: "tree"
4170
- }), /* @__PURE__ */ l("button", {
4171
- type: "button",
4172
- "aria-pressed": U,
4173
- className: U ? "active" : void 0,
4174
- onClick: () => ge("stars"),
4175
- title: "Browse the scope as a 3D star map",
4176
- children: "stars"
4177
- })]
4178
- }),
4179
- /* @__PURE__ */ u("div", {
4180
- className: "paths-toolbar-actions",
4181
- children: [!U && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("button", {
4182
- type: "button",
4183
- onClick: Q,
4184
- title: `New folder in ${Z}`,
4185
- children: "+ folder"
4186
- }), /* @__PURE__ */ l("button", {
4187
- type: "button",
4188
- onClick: ze,
4189
- disabled: !Re,
4190
- title: Re ? `New document in ${Z}` : "Documents are agent/user scope only",
4191
- children: "+ document"
4192
- })] }), /* @__PURE__ */ l("button", {
4193
- type: "button",
4194
- onClick: () => void q(),
4195
- title: "Reload the tree",
4196
- children: "↻"
4197
- })]
4198
- })
4514
+ /* @__PURE__ */ l(Gt, {
4515
+ documentId: $.documentId,
4516
+ scope: x,
4517
+ titleHint: $.title,
4518
+ browse: B,
4519
+ principal: p,
4520
+ renderAssistant: m,
4521
+ initialChunkId: $.chunkId ?? et?.chunkId,
4522
+ onOpenDocument: Ye,
4523
+ onTitle: Ze,
4524
+ onChunkSelect: (e) => Se({
4525
+ documentId: $.documentId,
4526
+ chunkId: e
4527
+ }),
4528
+ focusChunk: et
4529
+ }, I.length)
4199
4530
  ]
4200
- }),
4201
- !U && /* @__PURE__ */ u("p", {
4202
- className: "paths-context",
4531
+ }) : Z ? /* @__PURE__ */ u("div", {
4532
+ className: "paths-detail",
4203
4533
  children: [
4204
- "new items → ",
4205
- /* @__PURE__ */ l("code", { children: Z }),
4206
- z?.scopeId && /* @__PURE__ */ u(c, { children: [
4207
- " · ",
4208
- "subject ",
4209
- /* @__PURE__ */ l("code", { children: z.scopeId })
4210
- ] }),
4211
- z?.tenant && /* @__PURE__ */ u(c, { children: [
4212
- " · ",
4213
- "tenant ",
4214
- /* @__PURE__ */ l("code", { children: z.tenant })
4215
- ] })
4216
- ]
4217
- }),
4218
- (T || Pe) && /* @__PURE__ */ l("div", {
4219
- className: "paths-err",
4220
- children: T || Pe
4221
- }),
4222
- U && _ ? /* @__PURE__ */ l("div", {
4223
- className: "paths-navigator",
4224
- children: _(qe)
4225
- }) : /* @__PURE__ */ l(Vt, {
4226
- tree: Ae,
4227
- root: V.get(""),
4228
- expanded: j,
4229
- onToggle: je,
4230
- onLoadMore: Me,
4231
- onRetry: Ne,
4232
- selectedPath: M,
4233
- onSelect: (e) => R(e.fullPath),
4234
- summaries: Ce
4235
- })
4236
- ]
4237
- }), /* @__PURE__ */ l("div", {
4238
- className: "right",
4239
- children: $ ? /* @__PURE__ */ u("div", {
4240
- className: "paths-doc",
4241
- children: [
4242
- /* @__PURE__ */ l(fe, {
4243
- trail: N,
4244
- onJump: We
4245
- }),
4246
- /* @__PURE__ */ u("div", {
4247
- className: "paths-doc-head",
4248
- children: [$.path ? /* @__PURE__ */ l("code", {
4249
- className: "paths-doc-path",
4250
- children: $.path
4251
- }) : /* @__PURE__ */ u("span", {
4252
- className: "paths-doc-path paths-doc-unfiled",
4253
- title: "Opened by id — no entry for this document was found in the Path tree",
4534
+ /* @__PURE__ */ u("h2", { children: [/* @__PURE__ */ l("span", {
4535
+ className: "paths-detail-kind",
4536
+ children: Z.kind
4537
+ }), /* @__PURE__ */ l("code", { children: Z.fullPath })] }),
4538
+ /* @__PURE__ */ u("dl", {
4539
+ className: "paths-detail-meta",
4254
4540
  children: [
4255
- ue($),
4256
- " ",
4257
- /* @__PURE__ */ l("em", { children: "· opened by id, not in the tree" })
4541
+ /* @__PURE__ */ l("dt", { children: "scope" }),
4542
+ /* @__PURE__ */ l("dd", { children: x }),
4543
+ Re && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("dt", { children: "stored" }), /* @__PURE__ */ l("dd", { children: Re })] })
4258
4544
  ]
4259
- }), Ye && /* @__PURE__ */ u("div", {
4260
- className: "paths-detail-actions",
4261
- children: [/* @__PURE__ */ l("button", {
4262
- type: "button",
4263
- onClick: Be,
4264
- children: "rename / move"
4265
- }), /* @__PURE__ */ l("button", {
4266
- type: "button",
4267
- className: "danger",
4268
- onClick: Ve,
4269
- children: "delete"
4270
- })]
4271
- })]
4272
- }),
4273
- /* @__PURE__ */ l(Rt, {
4274
- documentId: $.documentId,
4275
- scope: x,
4276
- titleHint: $.title,
4277
- browse: z,
4278
- principal: p,
4279
- renderAssistant: m,
4280
- initialChunkId: $.chunkId ?? Je?.chunkId,
4281
- onOpenDocument: Ue,
4282
- onTitle: Ge,
4283
- onChunkSelect: (e) => be({
4284
- documentId: $.documentId,
4285
- chunkId: e
4286
4545
  }),
4287
- focusChunk: Je
4288
- }, N.length)
4289
- ]
4290
- }) : J ? /* @__PURE__ */ u("div", {
4291
- className: "paths-detail",
4292
- children: [
4293
- /* @__PURE__ */ u("h2", { children: [/* @__PURE__ */ l("span", {
4294
- className: "paths-detail-kind",
4295
- children: J.kind
4296
- }), /* @__PURE__ */ l("code", { children: J.fullPath })] }),
4297
- /* @__PURE__ */ u("dl", {
4298
- className: "paths-detail-meta",
4299
- children: [
4300
- /* @__PURE__ */ l("dt", { children: "scope" }),
4301
- /* @__PURE__ */ l("dd", { children: x }),
4302
- Le && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("dt", { children: "stored" }), /* @__PURE__ */ l("dd", { children: Le })] })
4303
- ]
4304
- }),
4305
- He ? /* @__PURE__ */ u("div", {
4306
- className: "paths-detail-actions",
4307
- children: [/* @__PURE__ */ l("button", {
4308
- type: "button",
4309
- onClick: Be,
4310
- children: "rename / move"
4311
- }), /* @__PURE__ */ l("button", {
4312
- type: "button",
4313
- className: "danger",
4314
- onClick: Ve,
4315
- children: "delete"
4316
- })]
4317
- }) : /* @__PURE__ */ u("p", {
4318
- className: "paths-readonly",
4319
- children: [
4320
- "Read-only — ",
4321
- J.kind,
4322
- " entries are managed by their own tool."
4323
- ]
4324
- })
4325
- ]
4326
- }) : /* @__PURE__ */ l("div", {
4327
- className: "empty",
4328
- children: /* @__PURE__ */ l("p", { children: "Select a path on the left, or create a folder / document." })
4329
- })
4330
- })]
4331
- }), D && /* @__PURE__ */ l(Xt, {
4332
- state: D,
4333
- onClose: () => A(null)
4334
- })] });
4546
+ Ge ? /* @__PURE__ */ u("div", {
4547
+ className: "paths-detail-actions",
4548
+ children: [
4549
+ /* @__PURE__ */ l("button", {
4550
+ type: "button",
4551
+ onClick: Ue,
4552
+ children: "rename / move"
4553
+ }),
4554
+ Ke && /* @__PURE__ */ l("button", {
4555
+ type: "button",
4556
+ onClick: qe,
4557
+ title: "Copy or move to another scope",
4558
+ children: "copy / move to…"
4559
+ }),
4560
+ /* @__PURE__ */ l("button", {
4561
+ type: "button",
4562
+ className: "danger",
4563
+ onClick: We,
4564
+ children: "delete"
4565
+ })
4566
+ ]
4567
+ }) : /* @__PURE__ */ u("p", {
4568
+ className: "paths-readonly",
4569
+ children: [
4570
+ "Read-only — ",
4571
+ Z.kind,
4572
+ " entries are managed by their own tool."
4573
+ ]
4574
+ })
4575
+ ]
4576
+ }) : /* @__PURE__ */ l("div", {
4577
+ className: "empty",
4578
+ children: /* @__PURE__ */ l("p", { children: "Select a path on the left, or create a folder / document." })
4579
+ })
4580
+ })]
4581
+ }),
4582
+ D && /* @__PURE__ */ l(rn, {
4583
+ state: D,
4584
+ onClose: () => O(null)
4585
+ }),
4586
+ k && /* @__PURE__ */ l(me, {
4587
+ data: b,
4588
+ scope: x,
4589
+ browse: B,
4590
+ documentId: k.documentId,
4591
+ underPath: k.underPath,
4592
+ fromPath: k.fromPath,
4593
+ onClose: () => A(null),
4594
+ onDone: Je
4595
+ })
4596
+ ] });
4335
4597
  }
4336
- function Xt({ state: e, onClose: t }) {
4598
+ function rn({ state: e, onClose: t }) {
4337
4599
  let [n, r] = o(() => Object.fromEntries(e.fields.map((e) => [e.key, e.value ?? ""]))), [i, a] = o(!1), [s, c] = o(null);
4338
4600
  return /* @__PURE__ */ l("div", {
4339
4601
  className: "modal-overlay",
@@ -4394,22 +4656,22 @@ function Xt({ state: e, onClose: t }) {
4394
4656
  }
4395
4657
  //#endregion
4396
4658
  //#region src/DocumentViewer.tsx
4397
- function Zt(e) {
4398
- let { documentId: t, scope: n, browse: r, theme: i } = e, a = N(e);
4399
- return /* @__PURE__ */ l(P, {
4659
+ function an(e) {
4660
+ let { documentId: t, scope: n, browse: r, theme: i } = e, a = R(e);
4661
+ return /* @__PURE__ */ l(z, {
4400
4662
  theme: i,
4401
4663
  dataLayer: a,
4402
- children: /* @__PURE__ */ l(Qt, { ...e }, `${n}:${t}:${r?.scopeId ?? ""}:${r?.tenant ?? ""}`)
4664
+ children: /* @__PURE__ */ l(on, { ...e }, `${n}:${t}:${r?.scopeId ?? ""}:${r?.tenant ?? ""}`)
4403
4665
  });
4404
4666
  }
4405
- function Qt({ documentId: e, scope: n, titleHint: r, browse: i, principal: a, renderAssistant: s, onOpenDocument: d }) {
4667
+ function on({ documentId: e, scope: n, titleHint: r, browse: i, principal: a, renderAssistant: s, onOpenDocument: d }) {
4406
4668
  let [f, p] = o([]), m = f[f.length - 1], h = t((e, t) => {
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, {
4669
+ d ? d(e, t) : p((n) => ce(n, t, e));
4670
+ }, [d]), g = t((e) => p((t) => le(t, e)), []), _ = t((e, t) => p((n) => ue(n, e, { title: t })), []);
4671
+ return /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(pe, {
4410
4672
  trail: f,
4411
4673
  onJump: g
4412
- }), /* @__PURE__ */ l(Rt, {
4674
+ }), /* @__PURE__ */ l(Gt, {
4413
4675
  documentId: m?.documentId ?? e,
4414
4676
  scope: n,
4415
4677
  titleHint: m ? m.title : r,
@@ -4422,6 +4684,6 @@ function Qt({ documentId: e, scope: n, titleHint: r, browse: i, principal: a, re
4422
4684
  }, f.length)] });
4423
4685
  }
4424
4686
  //#endregion
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 };
4687
+ export { Q as DEFAULT_SCHEME, an as DocumentViewer, ye as EDGE_PAGE_CAP, tn as PathExplorer, Ae as QUEUE_CHANGED_RETRIES, J as RULING_CHUNK, oe as RequestError, L as assetFetchFromConnection, He as chunkColor, X as chunkCount, I as createLoomcycleClient, O as dataLayerFromClient, Ve as docColor, Be as effectiveScheme, Ue as hexToTint, Me as isQueueChanged, se as jsonPostFromConnection, be as loadDocumentEdges, Ne as runRuling, We as tintStyle, b as transferInput, Y as undoRulings };
4426
4688
 
4427
4689
  //# sourceMappingURL=index.js.map