@loomcycle/explorer 0.6.0 → 0.7.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
@@ -1,8 +1,8 @@
1
1
  import { jsx as t, jsxs as l, Fragment as Y } from "react/jsx-runtime";
2
- import { createContext as nt, useContext as at, useMemo as q, useState as f, useRef as ne, useEffect as B, useCallback as j } from "react";
3
- import { LoomcycleClient as rt } from "@loomcycle/client";
4
- import ot from "react-markdown";
5
- import ct from "remark-gfm";
2
+ import { createContext as at, useContext as rt, useMemo as q, useState as f, useRef as ne, useEffect as B, useCallback as O } from "react";
3
+ import { LoomcycleClient as ot } from "@loomcycle/client";
4
+ import ct from "react-markdown";
5
+ import it from "remark-gfm";
6
6
  function _e(e, r) {
7
7
  return {
8
8
  pathLs: (n, a, o, i) => e.path(
@@ -172,51 +172,51 @@ function _e(e, r) {
172
172
  } : {}
173
173
  };
174
174
  }
175
- const Te = nt(null);
176
- function it({
175
+ const Te = at(null);
176
+ function st({
177
177
  value: e,
178
178
  children: r
179
179
  }) {
180
180
  return /* @__PURE__ */ t(Te.Provider, { value: e, children: r });
181
181
  }
182
182
  function ae() {
183
- const e = at(Te);
183
+ const e = rt(Te);
184
184
  if (!e)
185
185
  throw new Error(
186
186
  "useExplorerData must be used within <PathExplorer> or <DocumentViewer> (no ExplorerDataLayer in context)"
187
187
  );
188
188
  return e;
189
189
  }
190
- function st(e) {
190
+ function lt(e) {
191
191
  const r = e.fetch;
192
- return new rt({
192
+ return new ot({
193
193
  baseUrl: e.baseUrl,
194
194
  authToken: e.token || void 0,
195
195
  fetch: (n, a) => r ? r(n, a) : fetch(n, a)
196
196
  });
197
197
  }
198
- function lt(e) {
198
+ function dt(e) {
199
199
  const r = e.fetch, n = (a, o) => r ? r(a, o) : fetch(a, o);
200
200
  return (a) => {
201
201
  const o = {};
202
202
  return e.token && (o.Authorization = `Bearer ${e.token}`), n(e.baseUrl + a, { headers: o });
203
203
  };
204
204
  }
205
- function Pe(e) {
205
+ function Ae(e) {
206
206
  const { dataLayer: r, client: n, connection: a } = e;
207
207
  return q(() => r || (n ? _e(n) : a ? _e(
208
- st(a),
209
- lt(a)
208
+ lt(a),
209
+ dt(a)
210
210
  // RFC BO — binary image-asset GET
211
211
  ) : null), [r, n, a?.baseUrl, a?.token, a?.fetch]);
212
212
  }
213
- function Ae({
213
+ function Pe({
214
214
  theme: e,
215
215
  dataLayer: r,
216
216
  children: n
217
217
  }) {
218
218
  const a = e ? { "data-theme": e } : {};
219
- return r ? /* @__PURE__ */ t("div", { className: "loomcycle-explorer", ...a, children: /* @__PURE__ */ t(it, { value: r, children: n }) }) : /* @__PURE__ */ t("div", { className: "loomcycle-explorer", ...a, children: /* @__PURE__ */ l("div", { className: "error-banner", children: [
219
+ return r ? /* @__PURE__ */ t("div", { className: "loomcycle-explorer", ...a, children: /* @__PURE__ */ t(st, { value: r, children: n }) }) : /* @__PURE__ */ t("div", { className: "loomcycle-explorer", ...a, children: /* @__PURE__ */ l("div", { className: "error-banner", children: [
220
220
  "@loomcycle/explorer: provide a ",
221
221
  /* @__PURE__ */ t("code", { children: "connection" }),
222
222
  ", ",
@@ -228,7 +228,7 @@ function Ae({
228
228
  ] }) });
229
229
  }
230
230
  const Se = 6;
231
- function dt({
231
+ function ut({
232
232
  children: e,
233
233
  defaultLeftWidth: r = 380,
234
234
  minLeftWidth: n = 180,
@@ -242,21 +242,21 @@ function dt({
242
242
  if (Number.isFinite(L) && L >= n) return L;
243
243
  }
244
244
  return r;
245
- }), d = ne(null), [g, m] = f(!1);
245
+ }), u = ne(null), [g, h] = f(!1);
246
246
  B(() => {
247
247
  !o || g || localStorage.setItem(o, String(Math.round(c)));
248
248
  }, [o, c, g]);
249
- const k = j((C) => {
250
- C.preventDefault(), m(!0), C.target.setPointerCapture(C.pointerId);
251
- }, []), h = j(
249
+ const v = O((C) => {
250
+ C.preventDefault(), h(!0), C.target.setPointerCapture(C.pointerId);
251
+ }, []), m = O(
252
252
  (C) => {
253
- if (!g || !d.current) return;
254
- const L = d.current.getBoundingClientRect(), F = C.clientX - L.left, O = L.width - a - Se, A = Math.max(n, Math.min(F, O));
255
- s(A);
253
+ if (!g || !u.current) return;
254
+ const L = u.current.getBoundingClientRect(), F = C.clientX - L.left, I = L.width - a - Se, P = Math.max(n, Math.min(F, I));
255
+ s(P);
256
256
  },
257
257
  [g, n, a]
258
- ), P = j((C) => {
259
- m(!1);
258
+ ), A = O((C) => {
259
+ h(!1);
260
260
  try {
261
261
  C.target.releasePointerCapture(C.pointerId);
262
262
  } catch {
@@ -265,7 +265,7 @@ function dt({
265
265
  return /* @__PURE__ */ l(
266
266
  "div",
267
267
  {
268
- ref: d,
268
+ ref: u,
269
269
  className: `splitter ${i ?? ""} ${g ? "dragging" : ""}`,
270
270
  style: {
271
271
  gridTemplateColumns: `${c}px ${Se}px 1fr`
@@ -279,10 +279,10 @@ function dt({
279
279
  role: "separator",
280
280
  "aria-orientation": "vertical",
281
281
  "aria-valuenow": Math.round(c),
282
- onPointerDown: k,
283
- onPointerMove: h,
284
- onPointerUp: P,
285
- onPointerCancel: P
282
+ onPointerDown: v,
283
+ onPointerMove: m,
284
+ onPointerUp: A,
285
+ onPointerCancel: A
286
286
  }
287
287
  ),
288
288
  /* @__PURE__ */ t("div", { className: "splitter-pane splitter-right", children: e[1] })
@@ -290,9 +290,9 @@ function dt({
290
290
  }
291
291
  );
292
292
  }
293
- const ut = ["image/png", "image/jpeg", "image/gif", "image/webp"];
293
+ const ht = ["image/png", "image/jpeg", "image/gif", "image/webp"];
294
294
  function Ue(e) {
295
- return ut.includes(e);
295
+ return ht.includes(e);
296
296
  }
297
297
  function Oe(e) {
298
298
  return new Promise((r, n) => {
@@ -311,7 +311,7 @@ function Oe(e) {
311
311
  }, a.readAsDataURL(e);
312
312
  });
313
313
  }
314
- function ht(e) {
314
+ function mt(e) {
315
315
  if (!e) return null;
316
316
  for (let r = 0; r < e.length; r++) {
317
317
  const n = e[r];
@@ -343,8 +343,8 @@ const be = {
343
343
  "chunk.backlog": "#8a8f98",
344
344
  "chunk.implementation": "#d1863a",
345
345
  "chunk.merged": "#3aa06a"
346
- }, mt = 0.16;
347
- function ke(e) {
346
+ }, pt = 0.16;
347
+ function ve(e) {
348
348
  return e && Object.keys(e).length > 0 ? e : be;
349
349
  }
350
350
  function Ie(e, r, n) {
@@ -352,25 +352,25 @@ function Ie(e, r, n) {
352
352
  if (a && o && n[`doc.${a}.${o}`]) return n[`doc.${a}.${o}`];
353
353
  if (a && n[`doc.${a}`]) return n[`doc.${a}`];
354
354
  }
355
- function pt(e, r) {
355
+ function ft(e, r) {
356
356
  const n = e ?? "";
357
357
  return n ? r[`chunk.${n}`] : void 0;
358
358
  }
359
- function ft(e) {
359
+ function gt(e) {
360
360
  const r = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());
361
361
  if (!r) return;
362
362
  let n = r[1];
363
363
  n.length === 3 && (n = n[0] + n[0] + n[1] + n[1] + n[2] + n[2]);
364
364
  const a = parseInt(n.slice(0, 2), 16), o = parseInt(n.slice(2, 4), 16), i = parseInt(n.slice(4, 6), 16);
365
- return `rgba(${a}, ${o}, ${i}, ${mt})`;
365
+ return `rgba(${a}, ${o}, ${i}, ${pt})`;
366
366
  }
367
367
  function Ne(e) {
368
368
  if (!e) return;
369
- const r = ft(e);
369
+ const r = gt(e);
370
370
  if (r)
371
371
  return { background: r, borderLeft: `3px solid ${e}` };
372
372
  }
373
- function gt(e) {
373
+ function yt(e) {
374
374
  const r = /* @__PURE__ */ new Map();
375
375
  e.forEach((o) => r.set(o.id, { row: o, children: [] }));
376
376
  const n = [];
@@ -393,7 +393,7 @@ function je(e, r) {
393
393
  if (a) return a;
394
394
  }
395
395
  }
396
- function yt({
396
+ function bt({
397
397
  tree: e,
398
398
  selectedId: r,
399
399
  onSelect: n,
@@ -401,39 +401,39 @@ function yt({
401
401
  scheme: o,
402
402
  linkedIds: i
403
403
  }) {
404
- const [c, s] = f(() => /* @__PURE__ */ new Map()), d = j((m) => {
405
- s((k) => {
406
- const h = new Map(k);
407
- return h.set(m, k.get(m) === !1), h;
404
+ const [c, s] = f(() => /* @__PURE__ */ new Map()), u = O((h) => {
405
+ s((v) => {
406
+ const m = new Map(v);
407
+ return m.set(h, v.get(h) === !1), m;
408
408
  });
409
409
  }, []);
410
410
  B(() => {
411
411
  if (!r) return;
412
- const m = bt(e, r);
413
- m.length !== 0 && s((k) => {
414
- let h = !1;
415
- const P = new Map(k);
416
- for (const C of m)
417
- P.get(C) === !1 && (P.set(C, !0), h = !0);
418
- return h ? P : k;
412
+ const h = kt(e, r);
413
+ h.length !== 0 && s((v) => {
414
+ let m = !1;
415
+ const A = new Map(v);
416
+ for (const C of h)
417
+ A.get(C) === !1 && (A.set(C, !0), m = !0);
418
+ return m ? A : v;
419
419
  });
420
420
  }, [e, r]);
421
- const g = a ? ke(o) : null;
422
- return e.length === 0 ? /* @__PURE__ */ t("div", { className: "empty", children: /* @__PURE__ */ t("p", { children: "No chunks." }) }) : /* @__PURE__ */ t("ul", { className: "tree chunk-tree", children: e.map((m) => /* @__PURE__ */ t(
421
+ const g = a ? ve(o) : null;
422
+ return e.length === 0 ? /* @__PURE__ */ t("div", { className: "empty", children: /* @__PURE__ */ t("p", { children: "No chunks." }) }) : /* @__PURE__ */ t("ul", { className: "tree chunk-tree", children: e.map((h) => /* @__PURE__ */ t(
423
423
  Be,
424
424
  {
425
- node: m,
425
+ node: h,
426
426
  expanded: c,
427
- toggle: d,
427
+ toggle: u,
428
428
  selectedId: r,
429
429
  onSelect: n,
430
430
  tintScheme: g,
431
431
  linkedIds: i
432
432
  },
433
- m.row.id
433
+ h.row.id
434
434
  )) });
435
435
  }
436
- function bt(e, r) {
436
+ function kt(e, r) {
437
437
  const n = [], a = (o, i) => {
438
438
  for (const c of o) {
439
439
  if (c.row.id === r)
@@ -445,20 +445,20 @@ function bt(e, r) {
445
445
  return a(e, []), n;
446
446
  }
447
447
  function Be({ node: e, expanded: r, toggle: n, selectedId: a, onSelect: o, tintScheme: i, linkedIds: c }) {
448
- const s = e.children.length > 0, d = r.get(e.row.id) !== !1, g = a === e.row.id, m = i ? Ne(pt(e.row.status, i)) : void 0, k = c?.has(e.row.id);
448
+ const s = e.children.length > 0, u = r.get(e.row.id) !== !1, g = a === e.row.id, h = i ? Ne(ft(e.row.status, i)) : void 0, v = c?.has(e.row.id);
449
449
  return /* @__PURE__ */ l("li", { className: `node chunk-node ${g ? "selected" : ""}`, children: [
450
- /* @__PURE__ */ l("div", { className: "row chunk-row", style: m, children: [
450
+ /* @__PURE__ */ l("div", { className: "row chunk-row", style: h, children: [
451
451
  /* @__PURE__ */ t(
452
452
  "button",
453
453
  {
454
454
  type: "button",
455
455
  className: "tree-caret",
456
- "aria-label": d ? "collapse" : "expand",
456
+ "aria-label": u ? "collapse" : "expand",
457
457
  disabled: !s,
458
- onClick: (h) => {
459
- h.stopPropagation(), s && n(e.row.id);
458
+ onClick: (m) => {
459
+ m.stopPropagation(), s && n(e.row.id);
460
460
  },
461
- children: s ? d ? "▼" : "▶" : "·"
461
+ children: s ? u ? "▼" : "▶" : "·"
462
462
  }
463
463
  ),
464
464
  /* @__PURE__ */ l(
@@ -473,15 +473,15 @@ function Be({ node: e, expanded: r, toggle: n, selectedId: a, onSelect: o, tintS
473
473
  /* @__PURE__ */ t("span", { className: "chunk-title", children: e.row.title || "(untitled)" }),
474
474
  e.row.type && /* @__PURE__ */ t("span", { className: "chunk-badge", children: e.row.type }),
475
475
  e.row.status && /* @__PURE__ */ t("span", { className: "chunk-badge chunk-status", children: e.row.status }),
476
- k && /* @__PURE__ */ t("span", { className: "chunk-link-badge", title: "Has cross-reference links", "aria-label": "linked", children: "🔗" })
476
+ v && /* @__PURE__ */ t("span", { className: "chunk-link-badge", title: "Has cross-reference links", "aria-label": "linked", children: "🔗" })
477
477
  ]
478
478
  }
479
479
  )
480
480
  ] }),
481
- s && d && /* @__PURE__ */ t("ul", { className: "children chunk-children", children: e.children.map((h) => /* @__PURE__ */ t(
481
+ s && u && /* @__PURE__ */ t("ul", { className: "children chunk-children", children: e.children.map((m) => /* @__PURE__ */ t(
482
482
  Be,
483
483
  {
484
- node: h,
484
+ node: m,
485
485
  expanded: r,
486
486
  toggle: n,
487
487
  selectedId: a,
@@ -489,7 +489,7 @@ function Be({ node: e, expanded: r, toggle: n, selectedId: a, onSelect: o, tintS
489
489
  tintScheme: i,
490
490
  linkedIds: c
491
491
  },
492
- h.row.id
492
+ m.row.id
493
493
  )) })
494
494
  ] });
495
495
  }
@@ -502,8 +502,8 @@ function ue({ code: e }) {
502
502
  try {
503
503
  const i = (await import("mermaid")).default, c = r.current?.closest("[data-theme]")?.getAttribute("data-theme"), s = c ? c === "dark" : !0;
504
504
  i.initialize({ startOnLoad: !1, theme: s ? "dark" : "default", securityLevel: "strict" });
505
- const { svg: d } = await i.render(`lc-mmd-${vt++}`, e);
506
- o || a({ svg: d });
505
+ const { svg: u } = await i.render(`lc-mmd-${vt++}`, e);
506
+ o || a({ svg: u });
507
507
  } catch {
508
508
  o || a({ err: !0 });
509
509
  }
@@ -512,15 +512,15 @@ function ue({ code: e }) {
512
512
  };
513
513
  }, [e]), n.err ? /* @__PURE__ */ t("pre", { className: "md-pre md-mermaid-error", title: "diagram failed to render", children: /* @__PURE__ */ t("code", { children: e }) }) : n.svg ? /* @__PURE__ */ t("div", { ref: r, className: "md-mermaid", dangerouslySetInnerHTML: { __html: n.svg } }) : /* @__PURE__ */ t("div", { ref: r, className: "md-mermaid md-mermaid-loading", children: "rendering diagram…" });
514
514
  }
515
- function kt({ chunk: e, scope: r, browse: n, onClose: a, onSaved: o }) {
516
- const i = ae(), [c, s] = f(e.title), [d, g] = f(e.type ?? ""), [m, k] = f(e.status ?? ""), [h, P] = f(e.body ?? ""), [C, L] = f(
515
+ function Nt({ chunk: e, scope: r, browse: n, onClose: a, onSaved: o }) {
516
+ const i = ae(), [c, s] = f(e.title), [u, g] = f(e.type ?? ""), [h, v] = f(e.status ?? ""), [m, A] = f(e.body ?? ""), [C, L] = f(
517
517
  e.fields ? JSON.stringify(e.fields, null, 2) : ""
518
- ), [F, O] = f((e.tags ?? []).join(", ")), [A, M] = f(!1), [I, $] = f(null), [G, R] = f(!1), y = d === "mermaid", D = d === "image" || !!e.asset, [J, V] = f(h);
518
+ ), [F, I] = f((e.tags ?? []).join(", ")), [P, M] = f(!1), [j, $] = f(null), [G, R] = f(!1), y = u === "mermaid", D = u === "image" || !!e.asset, [J, z] = f(m);
519
519
  B(() => {
520
520
  if (!y) return;
521
- const w = setTimeout(() => V(h), 400);
521
+ const w = setTimeout(() => z(m), 400);
522
522
  return () => clearTimeout(w);
523
- }, [h, y]);
523
+ }, [m, y]);
524
524
  const N = async (w) => {
525
525
  $(null), M(!0);
526
526
  try {
@@ -533,10 +533,10 @@ function kt({ chunk: e, scope: r, browse: n, onClose: a, onSaved: o }) {
533
533
  return /* @__PURE__ */ t("div", { className: "modal-overlay", onClick: a, children: /* @__PURE__ */ l("form", { className: "modal chunk-editor", onClick: (w) => w.stopPropagation(), onSubmit: async (w) => {
534
534
  w.preventDefault(), $(null), R(!1);
535
535
  const S = {
536
- body: h,
536
+ body: m,
537
537
  title: c,
538
- type: d,
539
- status: m,
538
+ type: u,
539
+ status: h,
540
540
  // Parse the comma-separated list; replace-set is intentional (the box shows
541
541
  // the chunk's tags, so saving makes it exactly what's in the box).
542
542
  tags: F.split(",").map((T) => T.trim()).filter((T) => T !== "")
@@ -560,12 +560,12 @@ function kt({ chunk: e, scope: r, browse: n, onClose: a, onSaved: o }) {
560
560
  /* @__PURE__ */ l("div", { className: "modal-header sticky-top", children: [
561
561
  /* @__PURE__ */ t("h3", { children: "Edit chunk" }),
562
562
  /* @__PURE__ */ l("div", { className: "modal-buttons modal-buttons-top", children: [
563
- /* @__PURE__ */ t("button", { type: "button", onClick: a, disabled: A, children: "cancel" }),
564
- /* @__PURE__ */ t("button", { type: "submit", className: "primary", disabled: A, children: A ? "saving…" : "save" })
563
+ /* @__PURE__ */ t("button", { type: "button", onClick: a, disabled: P, children: "cancel" }),
564
+ /* @__PURE__ */ t("button", { type: "submit", className: "primary", disabled: P, children: P ? "saving…" : "save" })
565
565
  ] })
566
566
  ] }),
567
- I && /* @__PURE__ */ l("div", { className: "modal-err", children: [
568
- I,
567
+ j && /* @__PURE__ */ l("div", { className: "modal-err", children: [
568
+ j,
569
569
  G && " — reopen the chunk to load the latest, then reapply your edit."
570
570
  ] }),
571
571
  /* @__PURE__ */ l("label", { className: "path-field", children: [
@@ -579,7 +579,7 @@ function kt({ chunk: e, scope: r, browse: n, onClose: a, onSaved: o }) {
579
579
  "input",
580
580
  {
581
581
  className: "path-modal-input",
582
- value: d,
582
+ value: u,
583
583
  placeholder: "(none)",
584
584
  onChange: (w) => g(w.target.value)
585
585
  }
@@ -591,9 +591,9 @@ function kt({ chunk: e, scope: r, browse: n, onClose: a, onSaved: o }) {
591
591
  "input",
592
592
  {
593
593
  className: "path-modal-input",
594
- value: m,
594
+ value: h,
595
595
  placeholder: "(none)",
596
- onChange: (w) => k(w.target.value)
596
+ onChange: (w) => v(w.target.value)
597
597
  }
598
598
  )
599
599
  ] })
@@ -606,7 +606,7 @@ function kt({ chunk: e, scope: r, browse: n, onClose: a, onSaved: o }) {
606
606
  className: "path-modal-input",
607
607
  value: F,
608
608
  placeholder: "comma-separated, nest with a slash: area/sub, priority/high",
609
- onChange: (w) => O(w.target.value)
609
+ onChange: (w) => I(w.target.value)
610
610
  }
611
611
  )
612
612
  ] }),
@@ -617,7 +617,7 @@ function kt({ chunk: e, scope: r, browse: n, onClose: a, onSaved: o }) {
617
617
  {
618
618
  type: "file",
619
619
  accept: "image/png,image/jpeg,image/gif,image/webp",
620
- disabled: A,
620
+ disabled: P,
621
621
  onChange: (w) => {
622
622
  const S = w.target.files?.[0];
623
623
  S && N(S);
@@ -632,8 +632,8 @@ function kt({ chunk: e, scope: r, browse: n, onClose: a, onSaved: o }) {
632
632
  {
633
633
  className: "modal-textarea chunk-body-input",
634
634
  rows: y ? 8 : 12,
635
- value: h,
636
- onChange: (w) => P(w.target.value)
635
+ value: m,
636
+ onChange: (w) => A(w.target.value)
637
637
  }
638
638
  )
639
639
  ] }),
@@ -656,13 +656,13 @@ function kt({ chunk: e, scope: r, browse: n, onClose: a, onSaved: o }) {
656
656
  ] })
657
657
  ] }) });
658
658
  }
659
- function Nt(e) {
659
+ function wt(e) {
660
660
  const r = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec((e ?? "").trim());
661
661
  if (!r) return "#888888";
662
662
  let n = r[1];
663
663
  return n.length === 3 && (n = n[0] + n[0] + n[1] + n[1] + n[2] + n[2]), "#" + n.toLowerCase();
664
664
  }
665
- function wt({
665
+ function Ct({
666
666
  documentId: e,
667
667
  rootChunkId: r,
668
668
  docType: n,
@@ -671,9 +671,9 @@ function wt({
671
671
  scope: i,
672
672
  browse: c,
673
673
  onClose: s,
674
- onSaved: d
674
+ onSaved: u
675
675
  }) {
676
- const g = ae(), [m, k] = f(null), [h, P] = f(!1), [C, L] = f({}), [F, O] = f(!1), [A, M] = f(null), [I, $] = f(null), G = q(() => {
676
+ const g = ae(), [h, v] = f(null), [m, A] = f(!1), [C, L] = f({}), [F, I] = f(!1), [P, M] = f(null), [j, $] = f(null), G = q(() => {
677
677
  const b = new Set(Object.keys(be));
678
678
  n && b.add(`doc.${n}.${a || "draft"}`);
679
679
  for (const p of o) p && b.add(`chunk.${p}`);
@@ -683,9 +683,9 @@ function wt({
683
683
  let b = !1;
684
684
  return g.documentGetChunk(r, i, c).then((p) => {
685
685
  if (b) return;
686
- k(p);
686
+ v(p);
687
687
  const w = p.fields ?? {};
688
- P(w.color_enabled === !0);
688
+ A(w.color_enabled === !0);
689
689
  const S = w.color_scheme ?? {};
690
690
  L({ ...be, ...S });
691
691
  }).catch((p) => !b && $(p instanceof Error ? p.message : String(p))), () => {
@@ -694,21 +694,21 @@ function wt({
694
694
  }, [g, r, i, c]);
695
695
  const R = (b, p) => L((w) => ({ ...w, [b]: p })), y = (b) => ({
696
696
  ...b ?? {},
697
- color_enabled: h,
697
+ color_enabled: m,
698
698
  color_scheme: C
699
699
  }), D = async () => {
700
- if (m) {
701
- O(!0), $(null), M(null);
700
+ if (h) {
701
+ I(!0), $(null), M(null);
702
702
  try {
703
703
  await g.documentUpdateChunk(
704
704
  r,
705
- m.revision,
706
- { fields: y(m.fields) },
705
+ h.revision,
706
+ { fields: y(h.fields) },
707
707
  i,
708
708
  c
709
- ), d(), s();
709
+ ), u(), s();
710
710
  } catch (b) {
711
- $(b instanceof Error ? b.message : String(b)), O(!1);
711
+ $(b instanceof Error ? b.message : String(b)), I(!1);
712
712
  }
713
713
  }
714
714
  }, J = async () => {
@@ -716,7 +716,7 @@ function wt({
716
716
  $("this document has no type to match");
717
717
  return;
718
718
  }
719
- O(!0), $(null), M(null);
719
+ I(!0), $(null), M(null);
720
720
  try {
721
721
  const { documents: b } = await g.documentsSummary({ underPath: "/" }, i, c), p = (b ?? []).filter(
722
722
  (S) => S.type === n && S.document_id !== e && S.root_chunk_id
@@ -734,13 +734,13 @@ function wt({
734
734
  ), w++;
735
735
  } catch {
736
736
  }
737
- M(`Applied to ${w} other ${n} document(s).`), d();
737
+ M(`Applied to ${w} other ${n} document(s).`), u();
738
738
  } catch (b) {
739
739
  $(b instanceof Error ? b.message : String(b));
740
740
  } finally {
741
- O(!1);
741
+ I(!1);
742
742
  }
743
- }, V = G.filter((b) => b.startsWith("doc.")), N = G.filter((b) => b.startsWith("chunk."));
743
+ }, z = G.filter((b) => b.startsWith("doc.")), N = G.filter((b) => b.startsWith("chunk."));
744
744
  return /* @__PURE__ */ t("div", { className: "modal-overlay", onClick: s, children: /* @__PURE__ */ l("div", { className: "modal scheme-editor", onClick: (b) => b.stopPropagation(), children: [
745
745
  /* @__PURE__ */ l("div", { className: "scheme-editor-head", children: [
746
746
  /* @__PURE__ */ t("h3", { children: "Document colors" }),
@@ -748,18 +748,18 @@ function wt({
748
748
  /* @__PURE__ */ t("button", { type: "button", onClick: s, disabled: F, children: "cancel" }),
749
749
  /* @__PURE__ */ t("button", { type: "button", className: "primary", onClick: () => {
750
750
  D();
751
- }, disabled: F || !m, children: F ? "saving…" : "save" })
751
+ }, disabled: F || !h, children: F ? "saving…" : "save" })
752
752
  ] })
753
753
  ] }),
754
- I && /* @__PURE__ */ t("div", { className: "modal-err", children: I }),
755
- m ? /* @__PURE__ */ l(Y, { children: [
754
+ j && /* @__PURE__ */ t("div", { className: "modal-err", children: j }),
755
+ h ? /* @__PURE__ */ l(Y, { children: [
756
756
  /* @__PURE__ */ l("label", { className: "scheme-toggle", children: [
757
757
  /* @__PURE__ */ t(
758
758
  "input",
759
759
  {
760
760
  type: "checkbox",
761
- checked: h,
762
- onChange: (b) => P(b.target.checked)
761
+ checked: m,
762
+ onChange: (b) => A(b.target.checked)
763
763
  }
764
764
  ),
765
765
  /* @__PURE__ */ t("span", { children: "Enable coloring for this document" })
@@ -767,7 +767,7 @@ function wt({
767
767
  /* @__PURE__ */ t("p", { className: "modal-context", children: "Document rows are tinted by type + status; chunk tiles by status. Colors apply as a semi-transparent wash so text stays readable." }),
768
768
  /* @__PURE__ */ l("div", { className: "scheme-group", children: [
769
769
  /* @__PURE__ */ t("h4", { children: "Document (type · status)" }),
770
- V.map((b) => /* @__PURE__ */ t(xe, { label: b.slice(4), value: C[b], onChange: (p) => R(b, p) }, b))
770
+ z.map((b) => /* @__PURE__ */ t(xe, { label: b.slice(4), value: C[b], onChange: (p) => R(b, p) }, b))
771
771
  ] }),
772
772
  /* @__PURE__ */ l("div", { className: "scheme-group", children: [
773
773
  /* @__PURE__ */ t("h4", { children: "Chunks (status)" }),
@@ -781,49 +781,49 @@ function wt({
781
781
  n || "same-type",
782
782
  " documents"
783
783
  ] }),
784
- A && /* @__PURE__ */ t("span", { className: "scheme-status", children: A })
784
+ P && /* @__PURE__ */ t("span", { className: "scheme-status", children: P })
785
785
  ] })
786
786
  ] }) : /* @__PURE__ */ t("p", { className: "modal-context", children: "Loading…" })
787
787
  ] }) });
788
788
  }
789
789
  function xe({ label: e, value: r, onChange: n }) {
790
- const a = Nt(r);
790
+ const a = wt(r);
791
791
  return /* @__PURE__ */ l("label", { className: "scheme-row", children: [
792
792
  /* @__PURE__ */ t("input", { type: "color", value: a, onChange: (o) => n(o.target.value) }),
793
793
  /* @__PURE__ */ t("span", { className: "scheme-key", children: e }),
794
794
  /* @__PURE__ */ t("code", { className: "scheme-hex", children: a })
795
795
  ] });
796
796
  }
797
- const Ct = 8, _t = 20;
798
- function St(e) {
797
+ const _t = 8, St = 20;
798
+ function Et(e) {
799
799
  return /embedder|embedding|vector|semantic|not configured/i.test(e);
800
800
  }
801
- function Et({
801
+ function xt({
802
802
  documentId: e,
803
803
  selectedId: r,
804
804
  scope: n,
805
805
  browse: a,
806
806
  onSelectChunk: o
807
807
  }) {
808
- const i = ae(), [c, s] = f(!1), [d, g] = f(!1), [m, k] = f(void 0), [h, P] = f([]), [C, L] = f([]), [F, O] = f(null), [A, M] = f([]), [I, $] = f(!1);
808
+ const i = ae(), [c, s] = f(!1), [u, g] = f(!1), [h, v] = f(void 0), [m, A] = f([]), [C, L] = f([]), [F, I] = f(null), [P, M] = f([]), [j, $] = f(!1);
809
809
  B(() => {
810
810
  if (!c || !r) return;
811
811
  const y = r;
812
812
  let D = !1;
813
813
  return g(!0), Promise.allSettled([
814
814
  i.documentBacklinks(y, n, a),
815
- i.documentRelated(y, n, a, Ct),
816
- i.documentUnlinkedMentions(y, n, a, _t)
817
- ]).then(([J, V, N]) => {
815
+ i.documentRelated(y, n, a, _t),
816
+ i.documentUnlinkedMentions(y, n, a, St)
817
+ ]).then(([J, z, N]) => {
818
818
  if (!D) {
819
- if (P(J.status === "fulfilled" ? J.value.backlinks ?? [] : []), V.status === "fulfilled")
820
- L(V.value.related ?? []), O(null);
819
+ if (A(J.status === "fulfilled" ? J.value.backlinks ?? [] : []), z.status === "fulfilled")
820
+ L(z.value.related ?? []), I(null);
821
821
  else {
822
822
  L([]);
823
- const b = V.reason instanceof Error ? V.reason.message : String(V.reason);
824
- O(St(b) ? "semantic search not configured" : b);
823
+ const b = z.reason instanceof Error ? z.reason.message : String(z.reason);
824
+ I(Et(b) ? "semantic search not configured" : b);
825
825
  }
826
- N.status === "fulfilled" ? (M(N.value.unlinked_mentions ?? []), $(!!N.value.truncated)) : (M([]), $(!1)), k(y), g(!1);
826
+ N.status === "fulfilled" ? (M(N.value.unlinked_mentions ?? []), $(!!N.value.truncated)) : (M([]), $(!1)), v(y), g(!1);
827
827
  }
828
828
  }), () => {
829
829
  D = !0;
@@ -843,10 +843,10 @@ function Et({
843
843
  ]
844
844
  }
845
845
  ),
846
- c && /* @__PURE__ */ t("div", { className: "doc-conn-body", children: r ? !!(c && r && !d && m === r) ? /* @__PURE__ */ l(Y, { children: [
846
+ c && /* @__PURE__ */ t("div", { className: "doc-conn-body", children: r ? !!(c && r && !u && h === r) ? /* @__PURE__ */ l(Y, { children: [
847
847
  /* @__PURE__ */ l("div", { className: "doc-conn-group", children: [
848
848
  /* @__PURE__ */ t("h5", { children: "Backlinks" }),
849
- h.length === 0 ? /* @__PURE__ */ t("p", { className: "doc-conn-empty", children: "none" }) : /* @__PURE__ */ t("ul", { className: "doc-conn-list", children: h.map((y, D) => /* @__PURE__ */ l("li", { className: "doc-conn-row", children: [
849
+ m.length === 0 ? /* @__PURE__ */ t("p", { className: "doc-conn-empty", children: "none" }) : /* @__PURE__ */ t("ul", { className: "doc-conn-list", children: m.map((y, D) => /* @__PURE__ */ l("li", { className: "doc-conn-row", children: [
850
850
  /* @__PURE__ */ t(
851
851
  ge,
852
852
  {
@@ -877,8 +877,8 @@ function Et({
877
877
  ] }),
878
878
  /* @__PURE__ */ l("div", { className: "doc-conn-group", children: [
879
879
  /* @__PURE__ */ t("h5", { children: "Unlinked mentions" }),
880
- A.length === 0 ? /* @__PURE__ */ t("p", { className: "doc-conn-empty", children: "none" }) : /* @__PURE__ */ l("ul", { className: "doc-conn-list", children: [
881
- A.map((y, D) => /* @__PURE__ */ t("li", { className: "doc-conn-row", children: /* @__PURE__ */ t(
880
+ P.length === 0 ? /* @__PURE__ */ t("p", { className: "doc-conn-empty", children: "none" }) : /* @__PURE__ */ l("ul", { className: "doc-conn-list", children: [
881
+ P.map((y, D) => /* @__PURE__ */ t("li", { className: "doc-conn-row", children: /* @__PURE__ */ t(
882
882
  ge,
883
883
  {
884
884
  id: y.chunk_id,
@@ -887,7 +887,7 @@ function Et({
887
887
  onSelect: o
888
888
  }
889
889
  ) }, `${y.chunk_id}-${D}`)),
890
- I && /* @__PURE__ */ t("li", { className: "doc-conn-more", "aria-hidden": !0, children: "(more…)" })
890
+ j && /* @__PURE__ */ t("li", { className: "doc-conn-more", "aria-hidden": !0, children: "(more…)" })
891
891
  ] })
892
892
  ] })
893
893
  ] }) : /* @__PURE__ */ t("p", { className: "doc-conn-empty", children: "loading…" }) : /* @__PURE__ */ t("p", { className: "doc-conn-empty", children: "Select a chunk." }) })
@@ -906,7 +906,7 @@ function ge({
906
906
  ] }) : /* @__PURE__ */ t("button", { type: "button", className: "doc-ref-target", onClick: () => a(e), children: o });
907
907
  }
908
908
  const ye = 24;
909
- function xt({
909
+ function Dt({
910
910
  edges: e,
911
911
  documentId: r,
912
912
  selectedId: n,
@@ -914,52 +914,52 @@ function xt({
914
914
  }) {
915
915
  const [o, i] = f(!1), [c, s] = f(!1);
916
916
  if (e.length === 0) return null;
917
- const d = n ? e.filter((k) => k.from_id === n || k.to_id === n) : [], g = c ? e : e.slice(0, ye), m = Rt(g);
917
+ const u = n ? e.filter((v) => v.from_id === n || v.to_id === n) : [], g = c ? e : e.slice(0, ye), h = Mt(g);
918
918
  return /* @__PURE__ */ l("div", { className: "doc-refs", children: [
919
919
  n && /* @__PURE__ */ l("div", { className: "doc-refs-list-wrap", children: [
920
920
  /* @__PURE__ */ t("h4", { children: "References" }),
921
- d.length === 0 ? /* @__PURE__ */ t("p", { className: "doc-refs-empty", children: "This chunk has no links." }) : /* @__PURE__ */ t("ul", { className: "doc-refs-list", children: d.map((k, h) => /* @__PURE__ */ t(
922
- Dt,
921
+ u.length === 0 ? /* @__PURE__ */ t("p", { className: "doc-refs-empty", children: "This chunk has no links." }) : /* @__PURE__ */ t("ul", { className: "doc-refs-list", children: u.map((v, m) => /* @__PURE__ */ t(
922
+ Rt,
923
923
  {
924
- edge: k,
924
+ edge: v,
925
925
  selectedId: n,
926
926
  documentId: r,
927
927
  onSelectChunk: a
928
928
  },
929
- `${k.from_id}-${k.to_id}-${k.kind}-${h}`
929
+ `${v.from_id}-${v.to_id}-${v.kind}-${m}`
930
930
  )) })
931
931
  ] }),
932
932
  /* @__PURE__ */ l("div", { className: "doc-graph", children: [
933
- /* @__PURE__ */ l("button", { type: "button", className: "doc-graph-toggle", onClick: () => i((k) => !k), children: [
933
+ /* @__PURE__ */ l("button", { type: "button", className: "doc-graph-toggle", onClick: () => i((v) => !v), children: [
934
934
  o ? "▼" : "▶",
935
935
  " relationship graph (",
936
936
  e.length,
937
937
  ")"
938
938
  ] }),
939
939
  o && /* @__PURE__ */ l(Y, { children: [
940
- /* @__PURE__ */ t(ue, { code: m }),
941
- e.length > ye && /* @__PURE__ */ t("button", { type: "button", className: "doc-graph-more", onClick: () => s((k) => !k), children: c ? `show top ${ye}` : `show all ${e.length}` })
940
+ /* @__PURE__ */ t(ue, { code: h }),
941
+ e.length > ye && /* @__PURE__ */ t("button", { type: "button", className: "doc-graph-more", onClick: () => s((v) => !v), children: c ? `show top ${ye}` : `show all ${e.length}` })
942
942
  ] })
943
943
  ] })
944
944
  ] });
945
945
  }
946
- function Dt({
946
+ function Rt({
947
947
  edge: e,
948
948
  selectedId: r,
949
949
  documentId: n,
950
950
  onSelectChunk: a
951
951
  }) {
952
- const o = e.from_id === r, i = o ? e.to_id : e.from_id, c = (o ? e.to_title : e.from_title) || i.slice(0, 8), s = o ? e.to_document_id : e.from_document_id, d = !s || s === n;
952
+ const o = e.from_id === r, i = o ? e.to_id : e.from_id, c = (o ? e.to_title : e.from_title) || i.slice(0, 8), s = o ? e.to_document_id : e.from_document_id, u = !s || s === n;
953
953
  return /* @__PURE__ */ l("li", { className: "doc-ref", children: [
954
954
  /* @__PURE__ */ t("span", { className: "doc-ref-kind", children: e.kind }),
955
955
  /* @__PURE__ */ t("span", { className: "doc-ref-arrow", "aria-hidden": !0, children: o ? "→" : "←" }),
956
- d ? /* @__PURE__ */ t("button", { type: "button", className: "doc-ref-target", onClick: () => a(i), children: c }) : /* @__PURE__ */ l("span", { className: "doc-ref-target external", title: "In another document", children: [
956
+ u ? /* @__PURE__ */ t("button", { type: "button", className: "doc-ref-target", onClick: () => a(i), children: c }) : /* @__PURE__ */ l("span", { className: "doc-ref-target external", title: "In another document", children: [
957
957
  c,
958
958
  " ↗"
959
959
  ] })
960
960
  ] });
961
961
  }
962
- function Rt(e) {
962
+ function Mt(e) {
963
963
  const r = ["graph LR"];
964
964
  for (const n of e) {
965
965
  const a = `${De(n.from_id)}["${Re(n.from_title, n.from_id)}"]`, o = `${De(n.to_id)}["${Re(n.to_title, n.to_id)}"]`, i = (n.kind || "link").replace(/[|"]/g, " ");
@@ -975,49 +975,49 @@ function Re(e, r) {
975
975
  const a = (e ?? "").replace(/["[\]{}|<>]/g, " ").replace(/\s+/g, " ").trim() || r.slice(0, 6);
976
976
  return a.length > 30 ? a.slice(0, 29) + "…" : a;
977
977
  }
978
- function Mt(e) {
978
+ function $t(e) {
979
979
  const r = typeof e == "number" ? e / 1e6 : Date.parse(String(e));
980
980
  return !Number.isFinite(r) || r <= 0 ? String(e ?? "") : new Date(r).toLocaleString();
981
981
  }
982
- function $t({
982
+ function Lt({
983
983
  chunkId: e,
984
984
  chunkTitle: r,
985
985
  scope: n,
986
986
  browse: a,
987
987
  onClose: o
988
988
  }) {
989
- const i = ae(), [c, s] = f([]), [d, g] = f(!0), [m, k] = f(null), [h, P] = f("none"), [C, L] = f(null), [F, O] = f(""), [A, M] = f(!1), [I, $] = f(null), [G, R] = f(null), [y, D] = f("");
989
+ const i = ae(), [c, s] = f([]), [u, g] = f(!0), [h, v] = f(null), [m, A] = f("none"), [C, L] = f(null), [F, I] = f(""), [P, M] = f(!1), [j, $] = f(null), [G, R] = f(null), [y, D] = f("");
990
990
  B(() => {
991
991
  let N = !1;
992
- return g(!0), k(null), i.documentHistory(e, n, a).then((b) => {
992
+ return g(!0), v(null), i.documentHistory(e, n, a).then((b) => {
993
993
  if (N) return;
994
994
  const p = b.revisions ?? [];
995
995
  if (s(p), p.length >= 2) {
996
996
  const w = p.map((S) => S.revision);
997
997
  $(Math.min(...w)), R(Math.max(...w));
998
998
  }
999
- }).catch((b) => !N && k(b instanceof Error ? b.message : String(b))).finally(() => !N && g(!1)), () => {
999
+ }).catch((b) => !N && v(b instanceof Error ? b.message : String(b))).finally(() => !N && g(!1)), () => {
1000
1000
  N = !0;
1001
1001
  };
1002
1002
  }, [i, e, n, a]);
1003
1003
  const J = async (N) => {
1004
- k(null), M(!0), L(N), P("version");
1004
+ v(null), M(!0), L(N), A("version");
1005
1005
  try {
1006
1006
  const b = await i.documentGetVersion(e, N, n, a);
1007
- O(b.body ?? "");
1007
+ I(b.body ?? "");
1008
1008
  } catch (b) {
1009
- k(b instanceof Error ? b.message : String(b));
1009
+ v(b instanceof Error ? b.message : String(b));
1010
1010
  } finally {
1011
1011
  M(!1);
1012
1012
  }
1013
- }, V = async () => {
1014
- if (!(I === null || G === null)) {
1015
- k(null), M(!0), P("diff");
1013
+ }, z = async () => {
1014
+ if (!(j === null || G === null)) {
1015
+ v(null), M(!0), A("diff");
1016
1016
  try {
1017
- const N = await i.documentDiff(e, I, G, n, a);
1017
+ const N = await i.documentDiff(e, j, G, n, a);
1018
1018
  D(N.diff ?? "");
1019
1019
  } catch (N) {
1020
- k(N instanceof Error ? N.message : String(N));
1020
+ v(N instanceof Error ? N.message : String(N));
1021
1021
  } finally {
1022
1022
  M(!1);
1023
1023
  }
@@ -1031,13 +1031,13 @@ function $t({
1031
1031
  ] }),
1032
1032
  /* @__PURE__ */ t("div", { className: "modal-buttons modal-buttons-top", children: /* @__PURE__ */ t("button", { type: "button", onClick: o, children: "close" }) })
1033
1033
  ] }),
1034
- m && /* @__PURE__ */ t("div", { className: "modal-err", children: m }),
1035
- d ? /* @__PURE__ */ t("p", { className: "doc-empty-body", children: "loading…" }) : c.length === 0 ? /* @__PURE__ */ t("p", { className: "doc-empty-body", children: "No history recorded for this chunk." }) : /* @__PURE__ */ l(Y, { children: [
1034
+ h && /* @__PURE__ */ t("div", { className: "modal-err", children: h }),
1035
+ u ? /* @__PURE__ */ t("p", { className: "doc-empty-body", children: "loading…" }) : c.length === 0 ? /* @__PURE__ */ t("p", { className: "doc-empty-body", children: "No history recorded for this chunk." }) : /* @__PURE__ */ l(Y, { children: [
1036
1036
  /* @__PURE__ */ t("div", { className: "doc-hist-revs", children: c.map((N) => /* @__PURE__ */ l(
1037
1037
  "button",
1038
1038
  {
1039
1039
  type: "button",
1040
- className: "doc-hist-rev" + (h === "version" && C === N.revision ? " active" : ""),
1040
+ className: "doc-hist-rev" + (m === "version" && C === N.revision ? " active" : ""),
1041
1041
  onClick: () => {
1042
1042
  J(N.revision);
1043
1043
  },
@@ -1046,7 +1046,7 @@ function $t({
1046
1046
  "rev ",
1047
1047
  N.revision
1048
1048
  ] }),
1049
- /* @__PURE__ */ t("span", { className: "doc-hist-rev-time", children: Mt(N.created_at) }),
1049
+ /* @__PURE__ */ t("span", { className: "doc-hist-rev-time", children: $t(N.created_at) }),
1050
1050
  /* @__PURE__ */ t("span", { className: "doc-hist-rev-actor", children: N.actor || "unknown" })
1051
1051
  ]
1052
1052
  },
@@ -1057,7 +1057,7 @@ function $t({
1057
1057
  /* @__PURE__ */ t(
1058
1058
  "select",
1059
1059
  {
1060
- value: I ?? "",
1060
+ value: j ?? "",
1061
1061
  onChange: (N) => $(N.target.value === "" ? null : Number(N.target.value)),
1062
1062
  "aria-label": "diff from revision",
1063
1063
  children: c.map((N) => /* @__PURE__ */ l("option", { value: N.revision, children: [
@@ -1084,18 +1084,18 @@ function $t({
1084
1084
  {
1085
1085
  type: "button",
1086
1086
  onClick: () => {
1087
- V();
1087
+ z();
1088
1088
  },
1089
- disabled: A || I === null || G === null,
1089
+ disabled: P || j === null || G === null,
1090
1090
  children: "diff"
1091
1091
  }
1092
1092
  )
1093
1093
  ] }),
1094
- /* @__PURE__ */ t("div", { className: "doc-hist-output", children: A ? /* @__PURE__ */ t("p", { className: "doc-empty-body", children: "loading…" }) : h === "diff" ? /* @__PURE__ */ t(Lt, { text: y }) : h === "version" ? /* @__PURE__ */ t("pre", { className: "md-pre doc-hist-version", children: /* @__PURE__ */ t("code", { children: F || "(empty)" }) }) : /* @__PURE__ */ t("p", { className: "doc-empty-body", children: "Select a revision to view it, or compare two." }) })
1094
+ /* @__PURE__ */ t("div", { className: "doc-hist-output", children: P ? /* @__PURE__ */ t("p", { className: "doc-empty-body", children: "loading…" }) : m === "diff" ? /* @__PURE__ */ t(Tt, { text: y }) : m === "version" ? /* @__PURE__ */ t("pre", { className: "md-pre doc-hist-version", children: /* @__PURE__ */ t("code", { children: F || "(empty)" }) }) : /* @__PURE__ */ t("p", { className: "doc-empty-body", children: "Select a revision to view it, or compare two." }) })
1095
1095
  ] })
1096
1096
  ] }) });
1097
1097
  }
1098
- function Lt({ text: e }) {
1098
+ function Tt({ text: e }) {
1099
1099
  if (!e.trim()) return /* @__PURE__ */ t("p", { className: "doc-empty-body", children: "(no differences)" });
1100
1100
  const r = e.split(`
1101
1101
  `);
@@ -1109,9 +1109,9 @@ function Lt({ text: e }) {
1109
1109
  }) });
1110
1110
  }
1111
1111
  function Me({ source: e }) {
1112
- return /* @__PURE__ */ t("div", { className: "md", children: /* @__PURE__ */ t(ot, { remarkPlugins: [ct], components: Tt, children: e }) });
1112
+ return /* @__PURE__ */ t("div", { className: "md", children: /* @__PURE__ */ t(ct, { remarkPlugins: [it], components: At, children: e }) });
1113
1113
  }
1114
- const Tt = {
1114
+ const At = {
1115
1115
  // react-markdown already sanitized the href; add target/rel for external links.
1116
1116
  a({ href: e, children: r }) {
1117
1117
  const n = e ?? "", a = /^https?:\/\//i.test(n);
@@ -1143,92 +1143,92 @@ function Fe({
1143
1143
  const c = ae(), s = q(
1144
1144
  () => a && (a.scopeId || a.tenant) ? { scopeId: a.scopeId, tenant: a.tenant } : void 0,
1145
1145
  [a?.scopeId, a?.tenant]
1146
- ), [d, g] = f([]), [m, k] = f(void 0), [h, P] = f(null), [C, L] = f("chunks"), [F, O] = f(null), [A, M] = f(null), [I, $] = f(null), G = ne(null), [R, y] = f(null), [D, J] = f(!1), [V, N] = f(!1), [b, p] = f(null), [w, S] = f(!1), [T, ee] = f(0), [oe, ce] = f(!1), [Z, re] = f(null), [x, H] = f(!1), [W, Q] = f([]), z = j(() => ee((u) => u + 1), []), he = q(() => gt(d), [d]), ie = q(() => d.find((v) => !v.parent_id)?.title || n || "document", [d, n]), te = q(
1147
- () => !!h && !h.parent_id,
1148
- [h]
1146
+ ), [u, g] = f([]), [h, v] = f(void 0), [m, A] = f(null), [C, L] = f("chunks"), [F, I] = f(null), [P, M] = f(null), [j, $] = f(null), G = ne(null), [R, y] = f(null), [D, J] = f(!1), [z, N] = f(!1), [b, p] = f(null), [w, S] = f(!1), [T, ee] = f(0), [oe, ce] = f(!1), [Z, re] = f(null), [x, H] = f(!1), [W, Q] = f([]), V = O(() => ee((d) => d + 1), []), he = q(() => yt(u), [u]), ie = q(() => u.find((k) => !k.parent_id)?.title || n || "document", [u, n]), te = q(
1147
+ () => !!m && !m.parent_id,
1148
+ [m]
1149
1149
  ), X = q(
1150
- () => Z?.root_chunk_id ?? d.find((u) => !u.parent_id)?.id,
1151
- [Z, d]
1150
+ () => Z?.root_chunk_id ?? u.find((d) => !d.parent_id)?.id,
1151
+ [Z, u]
1152
1152
  ), We = q(
1153
- () => [...new Set(d.map((u) => u.status).filter((u) => !!u))],
1154
- [d]
1153
+ () => [...new Set(u.map((d) => d.status).filter((d) => !!d))],
1154
+ [u]
1155
1155
  ), se = !!Z?.color_enabled, Ve = q(() => {
1156
- const u = /* @__PURE__ */ new Set();
1157
- for (const v of W)
1158
- u.add(v.from_id), u.add(v.to_id);
1159
- return u;
1156
+ const d = /* @__PURE__ */ new Set();
1157
+ for (const k of W)
1158
+ d.add(k.from_id), d.add(k.to_id);
1159
+ return d;
1160
1160
  }, [W]), ze = q(
1161
- () => se ? Ne(Ie(Z?.type, Z?.status, ke(Z?.color_scheme))) : void 0,
1161
+ () => se ? Ne(Ie(Z?.type, Z?.status, ve(Z?.color_scheme))) : void 0,
1162
1162
  [se, Z?.type, Z?.status, Z?.color_scheme]
1163
1163
  );
1164
1164
  B(() => {
1165
- let u = !1;
1166
- return S(!0), p(null), c.documentQueryChunks(e, r, s).then((v) => {
1167
- if (u) return;
1168
- const _ = v.chunks ?? [];
1169
- g(_), k((E) => E ?? _.find((U) => !U.parent_id)?.id);
1170
- }).catch((v) => !u && p(v instanceof Error ? v.message : String(v))).finally(() => !u && S(!1)), () => {
1171
- u = !0;
1165
+ let d = !1;
1166
+ return S(!0), p(null), c.documentQueryChunks(e, r, s).then((k) => {
1167
+ if (d) return;
1168
+ const _ = k.chunks ?? [];
1169
+ g(_), v((E) => E ?? _.find((U) => !U.parent_id)?.id);
1170
+ }).catch((k) => !d && p(k instanceof Error ? k.message : String(k))).finally(() => !d && S(!1)), () => {
1171
+ d = !0;
1172
1172
  };
1173
1173
  }, [c, e, r, T, s]), B(() => {
1174
- let u = !1;
1175
- return c.documentGet(e, r, s).then((v) => !u && re(v)).catch(() => !u && re(null)), () => {
1176
- u = !0;
1174
+ let d = !1;
1175
+ return c.documentGet(e, r, s).then((k) => !d && re(k)).catch(() => !d && re(null)), () => {
1176
+ d = !0;
1177
1177
  };
1178
1178
  }, [c, e, r, T, s]), B(() => {
1179
- let u = !1;
1180
- return c.documentGetEdges(e, r, s).then((v) => !u && Q(v.edges ?? [])).catch(() => !u && Q([])), () => {
1181
- u = !0;
1179
+ let d = !1;
1180
+ return c.documentGetEdges(e, r, s).then((k) => !d && Q(k.edges ?? [])).catch(() => !d && Q([])), () => {
1181
+ d = !0;
1182
1182
  };
1183
1183
  }, [c, e, r, T, s]), B(() => {
1184
- k(void 0), P(null), O(null), L("chunks"), re(null), Q([]);
1184
+ v(void 0), A(null), I(null), L("chunks"), re(null), Q([]);
1185
1185
  }, [e, r]), B(() => {
1186
- if (!m) {
1187
- P(null);
1186
+ if (!h) {
1187
+ A(null);
1188
1188
  return;
1189
1189
  }
1190
- let u = !1;
1191
- return c.documentGetChunk(m, r, s).then((v) => !u && P(v)).catch((v) => !u && p(v instanceof Error ? v.message : String(v))), () => {
1192
- u = !0;
1190
+ let d = !1;
1191
+ return c.documentGetChunk(h, r, s).then((k) => !d && A(k)).catch((k) => !d && p(k instanceof Error ? k.message : String(k))), () => {
1192
+ d = !0;
1193
1193
  };
1194
- }, [c, m, r, T, s]), B(() => {
1195
- const u = h?.type === "image" || !!h?.asset;
1196
- if (!h || !u || !c.documentAssetObjectUrl) {
1194
+ }, [c, h, r, T, s]), B(() => {
1195
+ const d = m?.type === "image" || !!m?.asset;
1196
+ if (!m || !d || !c.documentAssetObjectUrl) {
1197
1197
  M(null), $(null);
1198
1198
  return;
1199
1199
  }
1200
- let v = !1, _ = null;
1201
- return $(null), c.documentAssetObjectUrl(h.id, r, s).then((E) => {
1202
- if (v) {
1200
+ let k = !1, _ = null;
1201
+ return $(null), c.documentAssetObjectUrl(m.id, r, s).then((E) => {
1202
+ if (k) {
1203
1203
  URL.revokeObjectURL(E);
1204
1204
  return;
1205
1205
  }
1206
1206
  _ = E, M(E);
1207
- }).catch((E) => !v && $(E instanceof Error ? E.message : String(E))), () => {
1208
- v = !0, _ && URL.revokeObjectURL(_);
1207
+ }).catch((E) => !k && $(E instanceof Error ? E.message : String(E))), () => {
1208
+ k = !0, _ && URL.revokeObjectURL(_);
1209
1209
  };
1210
- }, [c, h, r, s]), B(() => {
1211
- if (C !== "markdown" || !m) {
1212
- O(null);
1210
+ }, [c, m, r, s]), B(() => {
1211
+ if (C !== "markdown" || !h) {
1212
+ I(null);
1213
1213
  return;
1214
1214
  }
1215
- const u = je(he, m);
1216
- if (!u) return;
1217
- let v = !1;
1215
+ const d = je(he, h);
1216
+ if (!d) return;
1217
+ let k = !1;
1218
1218
  const _ = [], E = (U, le) => {
1219
1219
  _.push({ node: U, depth: le }), U.children.forEach((de) => E(de, le + 1));
1220
1220
  };
1221
- return E(u, 0), Promise.all(_.map((U) => c.documentGetChunk(U.node.row.id, r, s))).then((U) => {
1222
- if (v) return;
1223
- const le = _.map((de, Ke) => {
1224
- const et = Math.min(de.depth + 1, 6), K = U[Ke], fe = "#".repeat(et) + " " + de.node.row.title;
1221
+ return E(d, 0), Promise.all(_.map((U) => c.documentGetChunk(U.node.row.id, r, s))).then((U) => {
1222
+ if (k) return;
1223
+ const le = _.map((de, et) => {
1224
+ const tt = Math.min(de.depth + 1, 6), K = U[et], fe = "#".repeat(tt) + " " + de.node.row.title;
1225
1225
  if (K.type === "mermaid" && K.body)
1226
1226
  return fe + "\n\n```mermaid\n" + K.body + "\n```\n";
1227
1227
  if (K.type === "image" || K.asset) {
1228
- const tt = K.body ? " — " + K.body : "";
1228
+ const nt = K.body ? " — " + K.body : "";
1229
1229
  return fe + `
1230
1230
 
1231
- _🖼 image chunk_` + tt + `
1231
+ _🖼 image chunk_` + nt + `
1232
1232
  `;
1233
1233
  }
1234
1234
  return fe + (K.body ? `
@@ -1237,123 +1237,139 @@ _🖼 image chunk_` + tt + `
1237
1237
  `;
1238
1238
  }).join(`
1239
1239
  `);
1240
- O(le);
1241
- }).catch((U) => !v && p(U instanceof Error ? U.message : String(U))), () => {
1242
- v = !0;
1240
+ I(le);
1241
+ }).catch((U) => !k && p(U instanceof Error ? U.message : String(U))), () => {
1242
+ k = !0;
1243
1243
  };
1244
- }, [c, C, m, he, r, T, s]);
1245
- const Je = j((u) => k(u.row.id), []), Ze = j(async () => {
1244
+ }, [c, C, h, he, r, T, s]);
1245
+ const Je = O((d) => v(d.row.id), []), Ze = O(async () => {
1246
1246
  try {
1247
- const u = await c.documentExportMd(e, r, !0, s), v = new Blob([u.markdown], { type: "text/markdown" }), _ = URL.createObjectURL(v), E = document.createElement("a");
1248
- E.href = _, E.download = (u.title || "document").replace(/[^\w.-]+/g, "_") + ".md", E.click(), URL.revokeObjectURL(_);
1249
- } catch (u) {
1250
- p(u instanceof Error ? u.message : String(u));
1247
+ const d = await c.documentExportMd(e, r, !0, s), k = new Blob([d.markdown], { type: "text/markdown" }), _ = URL.createObjectURL(k), E = document.createElement("a");
1248
+ E.href = _, E.download = (d.title || "document").replace(/[^\w.-]+/g, "_") + ".md", E.click(), URL.revokeObjectURL(_);
1249
+ } catch (d) {
1250
+ p(d instanceof Error ? d.message : String(d));
1251
1251
  }
1252
- }, [c, e, r, s]), qe = j(async () => {
1252
+ }, [c, e, r, s]), qe = O(async () => {
1253
1253
  try {
1254
- const u = await c.documentExportCanvas(e, r, s), v = new Blob([JSON.stringify(u.canvas, null, 2)], {
1254
+ const d = await c.documentExportCanvas(e, r, s), k = new Blob([JSON.stringify(d.canvas, null, 2)], {
1255
1255
  type: "application/json"
1256
- }), _ = URL.createObjectURL(v), E = document.createElement("a");
1256
+ }), _ = URL.createObjectURL(k), E = document.createElement("a");
1257
1257
  E.href = _, E.download = (ie || "document").replace(/[^\w.-]+/g, "_") + ".canvas", E.click(), URL.revokeObjectURL(_);
1258
- } catch (u) {
1259
- p(u instanceof Error ? u.message : String(u));
1258
+ } catch (d) {
1259
+ p(d instanceof Error ? d.message : String(d));
1260
1260
  }
1261
- }, [c, e, r, s, ie]), me = !!c.documentCreateChunk && !!X, pe = j(
1262
- async (u) => {
1261
+ }, [c, e, r, s, ie]), me = !!c.documentCreateChunk && !!X, pe = O(
1262
+ async (d) => {
1263
1263
  if (!c.documentCreateChunk || !c.documentSetAsset) return;
1264
- const v = m || X;
1265
- if (v) {
1264
+ const k = h || X;
1265
+ if (k) {
1266
1266
  p(null);
1267
1267
  try {
1268
- const { mediaType: _, data: E } = await Oe(u), U = await c.documentCreateChunk(
1268
+ const { mediaType: _, data: E } = await Oe(d), U = await c.documentCreateChunk(
1269
1269
  e,
1270
- v,
1271
- { title: u.name || "image", type: "image" },
1270
+ k,
1271
+ { title: d.name || "image", type: "image" },
1272
1272
  r,
1273
1273
  s
1274
1274
  );
1275
- await c.documentSetAsset(U.id, _, E, u.name, r, s), z(), k(U.id);
1275
+ await c.documentSetAsset(U.id, _, E, d.name, r, s), V(), v(U.id);
1276
1276
  } catch (_) {
1277
1277
  p(_ instanceof Error ? _.message : String(_));
1278
1278
  }
1279
1279
  }
1280
1280
  },
1281
- [c, e, r, s, m, X, z]
1282
- ), Qe = j(async () => {
1281
+ [c, e, r, s, h, X, V]
1282
+ ), Qe = O(async () => {
1283
1283
  if (!c.documentCreateChunk) return;
1284
- const u = m || X;
1285
- if (u) {
1284
+ const d = h || X;
1285
+ if (d) {
1286
1286
  p(null);
1287
1287
  try {
1288
- const v = await c.documentCreateChunk(
1288
+ const k = await c.documentCreateChunk(
1289
1289
  e,
1290
- u,
1290
+ d,
1291
1291
  { title: "Diagram", type: "mermaid", body: `graph TD
1292
1292
  A[Start] --> B[End]` },
1293
1293
  r,
1294
1294
  s
1295
1295
  );
1296
- z(), k(v.id), y(v);
1297
- } catch (v) {
1298
- p(v instanceof Error ? v.message : String(v));
1296
+ V(), v(k.id), y(k);
1297
+ } catch (k) {
1298
+ p(k instanceof Error ? k.message : String(k));
1299
1299
  }
1300
1300
  }
1301
- }, [c, e, r, s, m, X, z]), Xe = j(async () => {
1301
+ }, [c, e, r, s, h, X, V]), Xe = O(async () => {
1302
1302
  if (!c.documentCreateChunk) return;
1303
- const u = m && !te ? m : void 0, v = m || X;
1304
- if (v) {
1303
+ const d = h && !te ? h : void 0, k = h || X;
1304
+ if (k) {
1305
1305
  p(null);
1306
1306
  try {
1307
1307
  const _ = await c.documentCreateChunk(
1308
1308
  e,
1309
- u ? "" : v,
1309
+ d ? "" : k,
1310
1310
  // after_id resolves the parent server-side
1311
1311
  { title: "Text", body: "" },
1312
1312
  r,
1313
1313
  s,
1314
- u
1314
+ d
1315
1315
  );
1316
- z(), k(_.id), y(_);
1316
+ V(), v(_.id), y(_);
1317
1317
  } catch (_) {
1318
1318
  p(_ instanceof Error ? _.message : String(_));
1319
1319
  }
1320
1320
  }
1321
- }, [c, e, r, s, m, te, X, z]), we = q(() => {
1322
- if (!h || te) return { canUp: !1, canDown: !1 };
1323
- const u = h.parent_id ?? "", v = d.filter((E) => (E.parent_id ?? "") === u).sort((E, U) => E.position - U.position || E.id.localeCompare(U.id)), _ = v.findIndex((E) => E.id === h.id);
1324
- return { canUp: _ > 0, canDown: _ >= 0 && _ < v.length - 1 };
1325
- }, [d, h, te]), Ce = j(
1326
- async (u) => {
1327
- if (!(!c.documentReorderChunk || !m)) {
1321
+ }, [c, e, r, s, h, te, X, V]), Ye = O(async () => {
1322
+ if (!(!c.documentCreateChunk || !h)) {
1323
+ p(null);
1324
+ try {
1325
+ const d = await c.documentCreateChunk(
1326
+ e,
1327
+ h,
1328
+ { title: "Text", body: "" },
1329
+ r,
1330
+ s
1331
+ );
1332
+ V(), v(d.id), y(d);
1333
+ } catch (d) {
1334
+ p(d instanceof Error ? d.message : String(d));
1335
+ }
1336
+ }
1337
+ }, [c, e, r, s, h, V]), we = q(() => {
1338
+ if (!m || te) return { canUp: !1, canDown: !1 };
1339
+ const d = m.parent_id ?? "", k = u.filter((E) => (E.parent_id ?? "") === d).sort((E, U) => E.position - U.position || E.id.localeCompare(U.id)), _ = k.findIndex((E) => E.id === m.id);
1340
+ return { canUp: _ > 0, canDown: _ >= 0 && _ < k.length - 1 };
1341
+ }, [u, m, te]), Ce = O(
1342
+ async (d) => {
1343
+ if (!(!c.documentReorderChunk || !h)) {
1328
1344
  p(null);
1329
1345
  try {
1330
- await c.documentReorderChunk(m, u, r, s), z();
1331
- } catch (v) {
1332
- p(v instanceof Error ? v.message : String(v));
1346
+ await c.documentReorderChunk(h, d, r, s), V();
1347
+ } catch (k) {
1348
+ p(k instanceof Error ? k.message : String(k));
1333
1349
  }
1334
1350
  }
1335
1351
  },
1336
- [c, m, r, s, z]
1337
- ), Ye = j(async () => {
1338
- if (!c.documentDeleteChunk || !h) return;
1352
+ [c, h, r, s, V]
1353
+ ), Ke = O(async () => {
1354
+ if (!c.documentDeleteChunk || !m) return;
1339
1355
  p(null);
1340
- const u = h.parent_id;
1356
+ const d = m.parent_id;
1341
1357
  try {
1342
- await c.documentDeleteChunk(h.id, r, s), N(!1), k(u || X), z();
1343
- } catch (v) {
1344
- p(v instanceof Error ? v.message : String(v)), N(!1);
1358
+ await c.documentDeleteChunk(m.id, r, s), N(!1), v(d || X), V();
1359
+ } catch (k) {
1360
+ p(k instanceof Error ? k.message : String(k)), N(!1);
1345
1361
  }
1346
- }, [c, h, r, s, X, z]);
1362
+ }, [c, m, r, s, X, V]);
1347
1363
  return B(() => {
1348
1364
  if (!me) return;
1349
- const u = (v) => {
1365
+ const d = (k) => {
1350
1366
  if (R || x) return;
1351
1367
  const _ = document.activeElement, E = _?.tagName;
1352
1368
  if (E === "INPUT" || E === "TEXTAREA" || _?.isContentEditable) return;
1353
- const U = ht(v.clipboardData?.items);
1354
- U && (v.preventDefault(), pe(U));
1369
+ const U = mt(k.clipboardData?.items);
1370
+ U && (k.preventDefault(), pe(U));
1355
1371
  };
1356
- return window.addEventListener("paste", u), () => window.removeEventListener("paste", u);
1372
+ return window.addEventListener("paste", d), () => window.removeEventListener("paste", d);
1357
1373
  }, [me, R, x, pe]), /* @__PURE__ */ l("div", { className: "doc-viewer", children: [
1358
1374
  /* @__PURE__ */ t(
1359
1375
  "input",
@@ -1362,9 +1378,9 @@ _🖼 image chunk_` + tt + `
1362
1378
  type: "file",
1363
1379
  accept: "image/png,image/jpeg,image/gif,image/webp",
1364
1380
  style: { display: "none" },
1365
- onChange: (u) => {
1366
- const v = u.target.files?.[0];
1367
- u.target.value = "", v && pe(v);
1381
+ onChange: (d) => {
1382
+ const k = d.target.files?.[0];
1383
+ d.target.value = "", k && pe(k);
1368
1384
  }
1369
1385
  }
1370
1386
  ),
@@ -1379,10 +1395,22 @@ _🖼 image chunk_` + tt + `
1379
1395
  onClick: () => {
1380
1396
  Xe();
1381
1397
  },
1382
- title: "Add a text chunk after the selected chunk",
1398
+ title: "Add a text chunk AFTER the selected chunk, at the same level",
1383
1399
  children: "+ text"
1384
1400
  }
1385
1401
  ),
1402
+ /* @__PURE__ */ t(
1403
+ "button",
1404
+ {
1405
+ type: "button",
1406
+ onClick: () => {
1407
+ Ye();
1408
+ },
1409
+ disabled: !h,
1410
+ title: h ? "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",
1411
+ children: "+ child"
1412
+ }
1413
+ ),
1386
1414
  /* @__PURE__ */ t(
1387
1415
  "button",
1388
1416
  {
@@ -1434,38 +1462,38 @@ _🖼 image chunk_` + tt + `
1434
1462
  {
1435
1463
  type: "button",
1436
1464
  className: oe ? "active" : "",
1437
- onClick: () => ce((u) => !u),
1465
+ onClick: () => ce((d) => !d),
1438
1466
  title: "Document Assistant — instruct an agent to restructure/import/link chunks",
1439
1467
  children: "assistant"
1440
1468
  }
1441
1469
  ),
1442
- /* @__PURE__ */ t("button", { type: "button", onClick: z, title: "Reload", children: "↻" })
1470
+ /* @__PURE__ */ t("button", { type: "button", onClick: V, title: "Reload", children: "↻" })
1443
1471
  ] })
1444
1472
  ] }),
1445
1473
  b && /* @__PURE__ */ t("div", { className: "paths-err", children: b }),
1446
1474
  /* @__PURE__ */ l("div", { className: "doc-split", children: [
1447
- /* @__PURE__ */ t("div", { className: "doc-chunktree", children: w && d.length === 0 ? /* @__PURE__ */ t("div", { className: "empty", children: /* @__PURE__ */ t("p", { children: "Loading…" }) }) : /* @__PURE__ */ t(
1448
- yt,
1475
+ /* @__PURE__ */ t("div", { className: "doc-chunktree", children: w && u.length === 0 ? /* @__PURE__ */ t("div", { className: "empty", children: /* @__PURE__ */ t("p", { children: "Loading…" }) }) : /* @__PURE__ */ t(
1476
+ bt,
1449
1477
  {
1450
1478
  tree: he,
1451
- selectedId: m,
1479
+ selectedId: h,
1452
1480
  onSelect: Je,
1453
1481
  colorEnabled: se,
1454
1482
  scheme: Z?.color_scheme,
1455
1483
  linkedIds: Ve
1456
1484
  }
1457
1485
  ) }),
1458
- /* @__PURE__ */ t("div", { className: "doc-content", children: h ? /* @__PURE__ */ l(Y, { children: [
1486
+ /* @__PURE__ */ t("div", { className: "doc-content", children: m ? /* @__PURE__ */ l(Y, { children: [
1459
1487
  /* @__PURE__ */ l("div", { className: "doc-content-head", children: [
1460
- /* @__PURE__ */ t("h3", { children: h.title || "(untitled)" }),
1488
+ /* @__PURE__ */ t("h3", { children: m.title || "(untitled)" }),
1461
1489
  /* @__PURE__ */ l("div", { className: "doc-content-meta", children: [
1462
- h.type && /* @__PURE__ */ t("span", { className: "chunk-badge", children: h.type }),
1463
- h.status && /* @__PURE__ */ t("span", { className: "chunk-badge chunk-status", children: h.status }),
1490
+ m.type && /* @__PURE__ */ t("span", { className: "chunk-badge", children: m.type }),
1491
+ m.status && /* @__PURE__ */ t("span", { className: "chunk-badge chunk-status", children: m.status }),
1464
1492
  /* @__PURE__ */ l("span", { className: "chunk-rev", children: [
1465
1493
  "rev ",
1466
- h.revision
1494
+ m.revision
1467
1495
  ] }),
1468
- h.tags?.map((u) => /* @__PURE__ */ t("span", { className: "chunk-tag", children: u }, u))
1496
+ m.tags?.map((d) => /* @__PURE__ */ t("span", { className: "chunk-tag", children: d }, d))
1469
1497
  ] }),
1470
1498
  /* @__PURE__ */ l("div", { className: "doc-content-controls", children: [
1471
1499
  /* @__PURE__ */ l("div", { className: "doc-mode-toggle", children: [
@@ -1490,7 +1518,7 @@ _🖼 image chunk_` + tt + `
1490
1518
  }
1491
1519
  )
1492
1520
  ] }),
1493
- /* @__PURE__ */ t("button", { type: "button", onClick: () => y(h), children: "edit" }),
1521
+ /* @__PURE__ */ t("button", { type: "button", onClick: () => y(m), children: "edit" }),
1494
1522
  /* @__PURE__ */ t(
1495
1523
  "button",
1496
1524
  {
@@ -1538,39 +1566,39 @@ _🖼 image chunk_` + tt + `
1538
1566
  )
1539
1567
  ] })
1540
1568
  ] }),
1541
- /* @__PURE__ */ t("div", { className: "doc-content-body", children: h.type === "mermaid" ? (
1569
+ /* @__PURE__ */ t("div", { className: "doc-content-body", children: m.type === "mermaid" ? (
1542
1570
  // RFC BO — a diagram chunk: body IS the Mermaid source.
1543
- h.body ? /* @__PURE__ */ l(Y, { children: [
1544
- /* @__PURE__ */ t(ue, { code: h.body }),
1545
- C === "markdown" && /* @__PURE__ */ t("pre", { className: "md-pre doc-mermaid-source", children: /* @__PURE__ */ t("code", { children: h.body }) })
1571
+ m.body ? /* @__PURE__ */ l(Y, { children: [
1572
+ /* @__PURE__ */ t(ue, { code: m.body }),
1573
+ C === "markdown" && /* @__PURE__ */ t("pre", { className: "md-pre doc-mermaid-source", children: /* @__PURE__ */ t("code", { children: m.body }) })
1546
1574
  ] }) : /* @__PURE__ */ t("p", { className: "doc-empty-body", children: "(empty diagram)" })
1547
- ) : h.type === "image" || h.asset ? (
1575
+ ) : m.type === "image" || m.asset ? (
1548
1576
  // RFC BO — an image chunk: bytes come from the auth'd asset GET.
1549
- I ? /* @__PURE__ */ l("p", { className: "doc-empty-body", children: [
1577
+ j ? /* @__PURE__ */ l("p", { className: "doc-empty-body", children: [
1550
1578
  "Image failed to load: ",
1551
- I
1552
- ] }) : A ? /* @__PURE__ */ l("figure", { className: "doc-image", children: [
1553
- /* @__PURE__ */ t("img", { src: A, alt: Pt(h) }),
1554
- h.body && /* @__PURE__ */ t("figcaption", { children: h.body })
1579
+ j
1580
+ ] }) : P ? /* @__PURE__ */ l("figure", { className: "doc-image", children: [
1581
+ /* @__PURE__ */ t("img", { src: P, alt: Pt(m) }),
1582
+ m.body && /* @__PURE__ */ t("figcaption", { children: m.body })
1555
1583
  ] }) : /* @__PURE__ */ t("p", { className: "doc-empty-body", children: "Loading image…" })
1556
- ) : C === "markdown" ? F !== null ? /* @__PURE__ */ t(Me, { source: F }) : /* @__PURE__ */ t("p", { className: "doc-empty-body", children: "Assembling Markdown…" }) : h.body ? /* @__PURE__ */ t(Me, { source: h.body }) : /* @__PURE__ */ t("p", { className: "doc-empty-body", children: "(empty chunk)" }) }),
1584
+ ) : C === "markdown" ? F !== null ? /* @__PURE__ */ t(Me, { source: F }) : /* @__PURE__ */ t("p", { className: "doc-empty-body", children: "Assembling Markdown…" }) : m.body ? /* @__PURE__ */ t(Me, { source: m.body }) : /* @__PURE__ */ t("p", { className: "doc-empty-body", children: "(empty chunk)" }) }),
1557
1585
  /* @__PURE__ */ t(
1558
- xt,
1586
+ Dt,
1559
1587
  {
1560
1588
  edges: W,
1561
1589
  documentId: e,
1562
- selectedId: m,
1563
- onSelectChunk: k
1590
+ selectedId: h,
1591
+ onSelectChunk: v
1564
1592
  }
1565
1593
  ),
1566
1594
  /* @__PURE__ */ t(
1567
- Et,
1595
+ xt,
1568
1596
  {
1569
1597
  documentId: e,
1570
- selectedId: m,
1598
+ selectedId: h,
1571
1599
  scope: r,
1572
1600
  browse: s,
1573
- onSelectChunk: k
1601
+ onSelectChunk: v
1574
1602
  }
1575
1603
  )
1576
1604
  ] }) : /* @__PURE__ */ t("div", { className: "empty", children: /* @__PURE__ */ t("p", { children: "Select a chunk on the left." }) }) })
@@ -1581,30 +1609,30 @@ _🖼 image chunk_` + tt + `
1581
1609
  subject: o?.subject,
1582
1610
  // Pass the viewer's own reload so the injected assistant can refresh
1583
1611
  // the tree + selected chunk after a turn mutates the document.
1584
- onChanged: z
1612
+ onChanged: V
1585
1613
  }) }),
1586
1614
  R && /* @__PURE__ */ t(
1587
- kt,
1615
+ Nt,
1588
1616
  {
1589
1617
  chunk: R,
1590
1618
  scope: r,
1591
1619
  browse: s,
1592
1620
  onClose: () => y(null),
1593
- onSaved: z
1621
+ onSaved: V
1594
1622
  }
1595
1623
  ),
1596
- D && h && /* @__PURE__ */ t(
1597
- $t,
1624
+ D && m && /* @__PURE__ */ t(
1625
+ Lt,
1598
1626
  {
1599
- chunkId: h.id,
1600
- chunkTitle: h.title,
1627
+ chunkId: m.id,
1628
+ chunkTitle: m.title,
1601
1629
  scope: r,
1602
1630
  browse: s,
1603
1631
  onClose: () => J(!1)
1604
1632
  }
1605
1633
  ),
1606
1634
  x && X && /* @__PURE__ */ t(
1607
- wt,
1635
+ Ct,
1608
1636
  {
1609
1637
  documentId: e,
1610
1638
  rootChunkId: X,
@@ -1614,26 +1642,26 @@ _🖼 image chunk_` + tt + `
1614
1642
  scope: r,
1615
1643
  browse: s,
1616
1644
  onClose: () => H(!1),
1617
- onSaved: z
1645
+ onSaved: V
1618
1646
  }
1619
1647
  ),
1620
- V && h && /* @__PURE__ */ t("div", { className: "modal-overlay", onClick: () => N(!1), children: /* @__PURE__ */ l("div", { className: "modal chunk-delete-confirm", onClick: (u) => u.stopPropagation(), children: [
1648
+ z && m && /* @__PURE__ */ t("div", { className: "modal-overlay", onClick: () => N(!1), children: /* @__PURE__ */ l("div", { className: "modal chunk-delete-confirm", onClick: (d) => d.stopPropagation(), children: [
1621
1649
  /* @__PURE__ */ t("h3", { children: "Delete chunk" }),
1622
1650
  /* @__PURE__ */ l("p", { className: "modal-context", children: [
1623
1651
  "Delete “",
1624
- h.title || "(untitled)",
1652
+ m.title || "(untitled)",
1625
1653
  "” and all of its sub-chunks? This cannot be undone."
1626
1654
  ] }),
1627
1655
  /* @__PURE__ */ l("div", { className: "modal-buttons", children: [
1628
1656
  /* @__PURE__ */ t("button", { type: "button", onClick: () => N(!1), children: "cancel" }),
1629
1657
  /* @__PURE__ */ t("button", { type: "button", className: "danger", onClick: () => {
1630
- Ye();
1658
+ Ke();
1631
1659
  }, children: "delete" })
1632
1660
  ] })
1633
1661
  ] }) })
1634
1662
  ] });
1635
1663
  }
1636
- function At(e) {
1664
+ function Ut(e) {
1637
1665
  const r = {
1638
1666
  name: "",
1639
1667
  fullPath: "",
@@ -1643,14 +1671,14 @@ function At(e) {
1643
1671
  }, n = /* @__PURE__ */ new Map([["", r]]), a = (i) => {
1644
1672
  const c = n.get(i);
1645
1673
  if (c) return c;
1646
- const s = i.lastIndexOf("/"), d = s <= 0 ? "" : i.slice(0, s), g = i.slice(s + 1), m = a(d), k = {
1674
+ const s = i.lastIndexOf("/"), u = s <= 0 ? "" : i.slice(0, s), g = i.slice(s + 1), h = a(u), v = {
1647
1675
  name: g,
1648
1676
  fullPath: i,
1649
1677
  kind: "directory",
1650
1678
  explicit: !1,
1651
1679
  children: []
1652
1680
  };
1653
- return m.children.push(k), n.set(i, k), k;
1681
+ return h.children.push(v), n.set(i, v), v;
1654
1682
  };
1655
1683
  for (const i of e) {
1656
1684
  const c = a(i.full_path);
@@ -1658,17 +1686,17 @@ function At(e) {
1658
1686
  }
1659
1687
  const o = (i) => {
1660
1688
  i.sort((c, s) => {
1661
- const d = c.kind === "directory", g = s.kind === "directory";
1662
- return d !== g ? d ? -1 : 1 : c.name.localeCompare(s.name);
1689
+ const u = c.kind === "directory", g = s.kind === "directory";
1690
+ return u !== g ? u ? -1 : 1 : c.name.localeCompare(s.name);
1663
1691
  }), i.forEach((c) => o(c.children));
1664
1692
  };
1665
1693
  return o(r.children), r.children;
1666
1694
  }
1667
- function ve(e) {
1695
+ function ke(e) {
1668
1696
  const r = e.lastIndexOf("/");
1669
1697
  return r <= 0 ? "" : e.slice(0, r);
1670
1698
  }
1671
- function Ut(e) {
1699
+ function Ot(e) {
1672
1700
  const r = [], n = (a) => {
1673
1701
  if (a.kind === "document") {
1674
1702
  const o = a.resourceRef;
@@ -1678,27 +1706,27 @@ function Ut(e) {
1678
1706
  };
1679
1707
  return n(e), r;
1680
1708
  }
1681
- const Ot = {
1709
+ const It = {
1682
1710
  directory: "📁",
1683
1711
  document: "📄",
1684
1712
  volume_mount: "💾",
1685
1713
  memory_entry: "🧠"
1686
1714
  };
1687
- function It({ tree: e, selectedPath: r, onSelect: n, summaries: a }) {
1688
- const [o, i] = f(() => /* @__PURE__ */ new Map()), c = j((s) => {
1689
- i((d) => {
1690
- const g = new Map(d);
1691
- return g.set(s, d.get(s) === !1), g;
1715
+ function jt({ tree: e, selectedPath: r, onSelect: n, summaries: a }) {
1716
+ const [o, i] = f(() => /* @__PURE__ */ new Map()), c = O((s) => {
1717
+ i((u) => {
1718
+ const g = new Map(u);
1719
+ return g.set(s, u.get(s) === !1), g;
1692
1720
  });
1693
1721
  }, []);
1694
1722
  return B(() => {
1695
1723
  r && i((s) => {
1696
- let d = !1;
1724
+ let u = !1;
1697
1725
  const g = new Map(s);
1698
- let m = ve(r);
1699
- for (; m !== ""; )
1700
- g.get(m) === !1 && (g.set(m, !0), d = !0), m = ve(m);
1701
- return d ? g : s;
1726
+ let h = ke(r);
1727
+ for (; h !== ""; )
1728
+ g.get(h) === !1 && (g.set(h, !0), u = !0), h = ke(h);
1729
+ return u ? g : s;
1702
1730
  });
1703
1731
  }, [r]), e.length === 0 ? /* @__PURE__ */ t("div", { className: "empty", children: /* @__PURE__ */ t("p", { children: "This tree is empty. Create a folder or document to begin." }) }) : /* @__PURE__ */ t("ul", { className: "tree path-tree", children: e.map((s) => /* @__PURE__ */ t(
1704
1732
  Ge,
@@ -1713,15 +1741,15 @@ function It({ tree: e, selectedPath: r, onSelect: n, summaries: a }) {
1713
1741
  s.fullPath
1714
1742
  )) });
1715
1743
  }
1716
- function jt(e, r) {
1744
+ function Bt(e, r) {
1717
1745
  if (e.kind !== "document" || !r) return;
1718
1746
  const n = e.resourceRef;
1719
1747
  return n?.document_id ? r.get(n.document_id) : void 0;
1720
1748
  }
1721
1749
  function Ge({ node: e, expanded: r, toggle: n, selectedPath: a, onSelect: o, summaries: i }) {
1722
- const c = e.children.length > 0, s = r.get(e.fullPath) !== !1, d = a === e.fullPath, g = jt(e, i), m = g && g.color_enabled ? Ne(Ie(g.type, g.status, ke(g.color_scheme))) : void 0;
1723
- return /* @__PURE__ */ l("li", { className: `node path-node kind-${e.kind} ${d ? "selected" : ""}`, children: [
1724
- /* @__PURE__ */ l("div", { className: "row path-row", style: m, children: [
1750
+ const c = e.children.length > 0, s = r.get(e.fullPath) !== !1, u = a === e.fullPath, g = Bt(e, i), h = g && g.color_enabled ? Ne(Ie(g.type, g.status, ve(g.color_scheme))) : void 0;
1751
+ return /* @__PURE__ */ l("li", { className: `node path-node kind-${e.kind} ${u ? "selected" : ""}`, children: [
1752
+ /* @__PURE__ */ l("div", { className: "row path-row", style: h, children: [
1725
1753
  /* @__PURE__ */ t(
1726
1754
  "button",
1727
1755
  {
@@ -1729,8 +1757,8 @@ function Ge({ node: e, expanded: r, toggle: n, selectedPath: a, onSelect: o, sum
1729
1757
  className: "tree-caret",
1730
1758
  "aria-label": s ? "collapse" : "expand",
1731
1759
  disabled: !c,
1732
- onClick: (k) => {
1733
- k.stopPropagation(), c && n(e.fullPath);
1760
+ onClick: (v) => {
1761
+ v.stopPropagation(), c && n(e.fullPath);
1734
1762
  },
1735
1763
  children: c ? s ? "▼" : "▶" : "·"
1736
1764
  }
@@ -1743,7 +1771,7 @@ function Ge({ node: e, expanded: r, toggle: n, selectedPath: a, onSelect: o, sum
1743
1771
  onClick: () => o(e),
1744
1772
  title: e.fullPath,
1745
1773
  children: [
1746
- /* @__PURE__ */ t("span", { className: "path-kind-icon", "aria-hidden": !0, children: Ot[e.kind] ?? "•" }),
1774
+ /* @__PURE__ */ t("span", { className: "path-kind-icon", "aria-hidden": !0, children: It[e.kind] ?? "•" }),
1747
1775
  /* @__PURE__ */ t("span", { className: "path-name", children: e.name }),
1748
1776
  g?.type && /* @__PURE__ */ t("span", { className: "chunk-badge", children: g.type }),
1749
1777
  g?.status && /* @__PURE__ */ t("span", { className: "chunk-badge chunk-status", children: g.status }),
@@ -1752,17 +1780,17 @@ function Ge({ node: e, expanded: r, toggle: n, selectedPath: a, onSelect: o, sum
1752
1780
  }
1753
1781
  )
1754
1782
  ] }),
1755
- c && s && /* @__PURE__ */ t("ul", { className: "children path-children", children: e.children.map((k) => /* @__PURE__ */ t(
1783
+ c && s && /* @__PURE__ */ t("ul", { className: "children path-children", children: e.children.map((v) => /* @__PURE__ */ t(
1756
1784
  Ge,
1757
1785
  {
1758
- node: k,
1786
+ node: v,
1759
1787
  expanded: r,
1760
1788
  toggle: n,
1761
1789
  selectedPath: a,
1762
1790
  onSelect: o,
1763
1791
  summaries: i
1764
1792
  },
1765
- k.fullPath
1793
+ v.fullPath
1766
1794
  )) })
1767
1795
  ] });
1768
1796
  }
@@ -1777,10 +1805,10 @@ function He(e, r) {
1777
1805
  if (a) return a;
1778
1806
  }
1779
1807
  }
1780
- function Jt(e) {
1781
- const { theme: r, defaultScope: n, path: a, onPathChange: o, browse: i, principal: c, renderAssistant: s, onError: d } = e, g = Pe(e);
1782
- return /* @__PURE__ */ t(Ae, { theme: r, dataLayer: g, children: /* @__PURE__ */ t(
1783
- Bt,
1808
+ function Zt(e) {
1809
+ const { theme: r, defaultScope: n, path: a, onPathChange: o, browse: i, principal: c, renderAssistant: s, onError: u } = e, g = Ae(e);
1810
+ return /* @__PURE__ */ t(Pe, { theme: r, dataLayer: g, children: /* @__PURE__ */ t(
1811
+ Ft,
1784
1812
  {
1785
1813
  defaultScope: n,
1786
1814
  path: a,
@@ -1788,11 +1816,11 @@ function Jt(e) {
1788
1816
  browse: i,
1789
1817
  principal: c,
1790
1818
  renderAssistant: s,
1791
- onError: d
1819
+ onError: u
1792
1820
  }
1793
1821
  ) });
1794
1822
  }
1795
- function Bt({
1823
+ function Ft({
1796
1824
  defaultScope: e,
1797
1825
  path: r,
1798
1826
  onPathChange: n,
@@ -1801,7 +1829,7 @@ function Bt({
1801
1829
  renderAssistant: i,
1802
1830
  onError: c
1803
1831
  }) {
1804
- const s = ae(), [d, g] = f(e ?? "user"), [m, k] = f([]), [h, P] = f(void 0), [C, L] = f(null), [F, O] = f(!1), [A, M] = f(null), I = r !== void 0 ? r : h, $ = ne(n);
1832
+ const s = ae(), [u, g] = f(e ?? "user"), [h, v] = f([]), [m, A] = f(void 0), [C, L] = f(null), [F, I] = f(!1), [P, M] = f(null), j = r !== void 0 ? r : m, $ = ne(n);
1805
1833
  B(() => {
1806
1834
  $.current = n;
1807
1835
  }, [n]);
@@ -1809,52 +1837,52 @@ function Bt({
1809
1837
  B(() => {
1810
1838
  G.current = c;
1811
1839
  }, [c]);
1812
- const R = j((x) => {
1813
- $.current?.(x), P(x);
1840
+ const R = O((x) => {
1841
+ $.current?.(x), A(x);
1814
1842
  }, []), y = q(
1815
1843
  () => a && (a.scopeId || a.tenant) ? { scopeId: a.scopeId, tenant: a.tenant } : void 0,
1816
1844
  [a?.scopeId, a?.tenant]
1817
- ), D = j(async () => {
1818
- O(!0), L(null);
1845
+ ), D = O(async () => {
1846
+ I(!0), L(null);
1819
1847
  try {
1820
- const x = await s.pathLs("/", d, !0, y);
1821
- k(x.entries ?? []);
1848
+ const x = await s.pathLs("/", u, !0, y);
1849
+ v(x.entries ?? []);
1822
1850
  } catch (x) {
1823
- L(x instanceof Error ? x.message : String(x)), k([]), G.current?.(x);
1851
+ L(x instanceof Error ? x.message : String(x)), v([]), G.current?.(x);
1824
1852
  } finally {
1825
- O(!1);
1853
+ I(!1);
1826
1854
  }
1827
- }, [s, d, y]), J = ne(!0);
1855
+ }, [s, u, y]), J = ne(!0);
1828
1856
  B(() => {
1829
1857
  J.current ? J.current = !1 : R(void 0), D();
1830
1858
  }, [D, R]);
1831
- const V = q(() => At(m), [m]), [N, b] = f(() => /* @__PURE__ */ new Map());
1859
+ const z = q(() => Ut(h), [h]), [N, b] = f(() => /* @__PURE__ */ new Map());
1832
1860
  B(() => {
1833
- if (d === "tenant") {
1861
+ if (u === "tenant") {
1834
1862
  b(/* @__PURE__ */ new Map());
1835
1863
  return;
1836
1864
  }
1837
- const x = m.filter((W) => W.kind === "document").map((W) => W.resource_ref?.document_id).filter((W) => !!W);
1865
+ const x = h.filter((W) => W.kind === "document").map((W) => W.resource_ref?.document_id).filter((W) => !!W);
1838
1866
  if (x.length === 0) {
1839
1867
  b(/* @__PURE__ */ new Map());
1840
1868
  return;
1841
1869
  }
1842
1870
  let H = !1;
1843
- return s.documentsSummary({ documentIds: x }, d, y).then((W) => {
1871
+ return s.documentsSummary({ documentIds: x }, u, y).then((W) => {
1844
1872
  if (H) return;
1845
1873
  const Q = /* @__PURE__ */ new Map();
1846
- for (const z of W.documents ?? []) Q.set(z.document_id, z);
1874
+ for (const V of W.documents ?? []) Q.set(V.document_id, V);
1847
1875
  b(Q);
1848
1876
  }).catch(() => {
1849
1877
  H || b(/* @__PURE__ */ new Map());
1850
1878
  }), () => {
1851
1879
  H = !0;
1852
1880
  };
1853
- }, [s, m, d, y]);
1881
+ }, [s, h, u, y]);
1854
1882
  const p = q(
1855
- () => I ? He(V, I) : void 0,
1856
- [V, I]
1857
- ), w = q(() => p ? p.kind === "directory" ? p.fullPath : ve(p.fullPath) : "", [p]), S = w || "/", T = d !== "tenant", ee = j(() => {
1883
+ () => j ? He(z, j) : void 0,
1884
+ [z, j]
1885
+ ), w = q(() => p ? p.kind === "directory" ? p.fullPath : ke(p.fullPath) : "", [p]), S = w || "/", T = u !== "tenant", ee = O(() => {
1858
1886
  M({
1859
1887
  title: `New folder in ${S}`,
1860
1888
  fields: [{ key: "name", label: "Folder name", placeholder: "e.g. launches" }],
@@ -1863,10 +1891,10 @@ function Bt({
1863
1891
  const H = x.name.trim();
1864
1892
  if (!$e.test(H)) throw new Error("name may contain only [A-Za-z0-9._-]");
1865
1893
  const W = Le(w, H);
1866
- await s.pathMkdir(W, d, y), await D(), R(W);
1894
+ await s.pathMkdir(W, u, y), await D(), R(W);
1867
1895
  }
1868
1896
  });
1869
- }, [s, w, S, d, y, D, R]), oe = j(() => {
1897
+ }, [s, w, S, u, y, D, R]), oe = O(() => {
1870
1898
  M({
1871
1899
  title: `New document in ${S}`,
1872
1900
  fields: [
@@ -1878,10 +1906,10 @@ function Bt({
1878
1906
  const H = x.name.trim();
1879
1907
  if (!$e.test(H)) throw new Error("name may contain only [A-Za-z0-9._-]");
1880
1908
  const W = x.title.trim() || H, Q = Le(w, H);
1881
- await s.documentCreate(W, Q, d, y), await D(), R(Q);
1909
+ await s.documentCreate(W, Q, u, y), await D(), R(Q);
1882
1910
  }
1883
1911
  });
1884
- }, [s, w, S, d, y, D, R]), ce = j(() => {
1912
+ }, [s, w, S, u, y, D, R]), ce = O(() => {
1885
1913
  p && M({
1886
1914
  title: `Rename / move ${p.fullPath}`,
1887
1915
  fields: [{ key: "to", label: "New path", value: p.fullPath }],
@@ -1889,10 +1917,10 @@ function Bt({
1889
1917
  onSubmit: async (x) => {
1890
1918
  const H = x.to.trim();
1891
1919
  if (!H.startsWith("/")) throw new Error("path must start with /");
1892
- await s.pathMv(p.fullPath, H, d, y), await D(), R(H);
1920
+ await s.pathMv(p.fullPath, H, u, y), await D(), R(H);
1893
1921
  }
1894
1922
  });
1895
- }, [s, p, d, y, D, R]), Z = j(() => {
1923
+ }, [s, p, u, y, D, R]), Z = O(() => {
1896
1924
  if (!p) return;
1897
1925
  if (p.kind === "document") {
1898
1926
  const Q = p.resourceRef?.document_id;
@@ -1904,12 +1932,12 @@ function Bt({
1904
1932
  danger: !0,
1905
1933
  onSubmit: async () => {
1906
1934
  if (!Q) throw new Error("this document dirent has no document_id");
1907
- await s.documentDelete(Q, d, y), await D(), R(void 0);
1935
+ await s.documentDelete(Q, u, y), await D(), R(void 0);
1908
1936
  }
1909
1937
  });
1910
1938
  return;
1911
1939
  }
1912
- const x = d === "tenant" ? [] : Ut(p), H = p.children.length;
1940
+ const x = u === "tenant" ? [] : Ot(p), H = p.children.length;
1913
1941
  M({
1914
1942
  title: `Delete branch ${p.fullPath}`,
1915
1943
  message: H === 0 ? "This removes the (empty) folder." : "This removes the folder and everything under it" + (x.length > 0 ? ` — including ${x.length} document(s), whose chunks are deleted.` : "."),
@@ -1918,14 +1946,14 @@ function Bt({
1918
1946
  danger: !0,
1919
1947
  onSubmit: async () => {
1920
1948
  for (const W of x)
1921
- await s.documentDelete(W, d, y);
1922
- await s.pathRm(p.fullPath, d, !0, y), await D(), R(void 0);
1949
+ await s.documentDelete(W, u, y);
1950
+ await s.pathRm(p.fullPath, u, !0, y), await D(), R(void 0);
1923
1951
  }
1924
1952
  });
1925
- }, [s, p, d, y, D, R]), re = p && (p.kind === "directory" || p.kind === "document");
1953
+ }, [s, p, u, y, D, R]), re = p && (p.kind === "directory" || p.kind === "document");
1926
1954
  return /* @__PURE__ */ l(Y, { children: [
1927
1955
  /* @__PURE__ */ l(
1928
- dt,
1956
+ ut,
1929
1957
  {
1930
1958
  className: "paths-view",
1931
1959
  defaultLeftWidth: 420,
@@ -1937,7 +1965,7 @@ function Bt({
1937
1965
  /* @__PURE__ */ l("div", { className: "paths-toolbar", children: [
1938
1966
  /* @__PURE__ */ l("label", { className: "paths-scope", children: [
1939
1967
  /* @__PURE__ */ t("span", { children: "scope" }),
1940
- /* @__PURE__ */ l("select", { value: d, onChange: (x) => g(x.target.value), children: [
1968
+ /* @__PURE__ */ l("select", { value: u, onChange: (x) => g(x.target.value), children: [
1941
1969
  /* @__PURE__ */ t("option", { value: "user", children: "user" }),
1942
1970
  /* @__PURE__ */ t("option", { value: "agent", children: "agent" }),
1943
1971
  /* @__PURE__ */ t("option", { value: "tenant", children: "tenant" })
@@ -1975,11 +2003,11 @@ function Bt({
1975
2003
  ] })
1976
2004
  ] }),
1977
2005
  C && /* @__PURE__ */ t("div", { className: "paths-err", children: C }),
1978
- F && m.length === 0 ? /* @__PURE__ */ t("div", { className: "empty", children: /* @__PURE__ */ t("p", { children: "Loading…" }) }) : /* @__PURE__ */ t(
1979
- It,
2006
+ F && h.length === 0 ? /* @__PURE__ */ t("div", { className: "empty", children: /* @__PURE__ */ t("p", { children: "Loading…" }) }) : /* @__PURE__ */ t(
2007
+ jt,
1980
2008
  {
1981
- tree: V,
1982
- selectedPath: I,
2009
+ tree: z,
2010
+ selectedPath: j,
1983
2011
  onSelect: (x) => R(x.fullPath),
1984
2012
  summaries: N
1985
2013
  }
@@ -1997,7 +2025,7 @@ function Bt({
1997
2025
  Fe,
1998
2026
  {
1999
2027
  documentId: p.resourceRef?.document_id ?? "",
2000
- scope: d,
2028
+ scope: u,
2001
2029
  titleHint: p.name,
2002
2030
  browse: y,
2003
2031
  principal: o,
@@ -2011,7 +2039,7 @@ function Bt({
2011
2039
  ] }),
2012
2040
  /* @__PURE__ */ l("dl", { className: "paths-detail-meta", children: [
2013
2041
  /* @__PURE__ */ t("dt", { children: "scope" }),
2014
- /* @__PURE__ */ t("dd", { children: d }),
2042
+ /* @__PURE__ */ t("dd", { children: u }),
2015
2043
  /* @__PURE__ */ t("dt", { children: "stored" }),
2016
2044
  /* @__PURE__ */ t("dd", { children: p.explicit ? "yes" : "implicit (no entry)" })
2017
2045
  ] }),
@@ -2027,10 +2055,10 @@ function Bt({
2027
2055
  ]
2028
2056
  }
2029
2057
  ),
2030
- A && /* @__PURE__ */ t(Ft, { state: A, onClose: () => M(null) })
2058
+ P && /* @__PURE__ */ t(Gt, { state: P, onClose: () => M(null) })
2031
2059
  ] });
2032
2060
  }
2033
- function Ft({ state: e, onClose: r }) {
2061
+ function Gt({ state: e, onClose: r }) {
2034
2062
  const [n, a] = f(
2035
2063
  () => Object.fromEntries(e.fields.map((g) => [g.key, g.value ?? ""]))
2036
2064
  ), [o, i] = f(!1), [c, s] = f(null);
@@ -2038,8 +2066,8 @@ function Ft({ state: e, onClose: r }) {
2038
2066
  g.preventDefault(), i(!0), s(null);
2039
2067
  try {
2040
2068
  await e.onSubmit(n), r();
2041
- } catch (m) {
2042
- s(m instanceof Error ? m.message : String(m)), i(!1);
2069
+ } catch (h) {
2070
+ s(h instanceof Error ? h.message : String(h)), i(!1);
2043
2071
  }
2044
2072
  }, children: [
2045
2073
  /* @__PURE__ */ l("div", { className: "modal-header sticky-top", children: [
@@ -2050,7 +2078,7 @@ function Ft({ state: e, onClose: r }) {
2050
2078
  ] })
2051
2079
  ] }),
2052
2080
  e.message && /* @__PURE__ */ t("p", { className: "modal-context", children: e.message }),
2053
- e.fields.map((g, m) => /* @__PURE__ */ l("label", { className: "path-field", children: [
2081
+ e.fields.map((g, h) => /* @__PURE__ */ l("label", { className: "path-field", children: [
2054
2082
  /* @__PURE__ */ t("span", { children: g.label }),
2055
2083
  /* @__PURE__ */ t(
2056
2084
  "input",
@@ -2058,17 +2086,17 @@ function Ft({ state: e, onClose: r }) {
2058
2086
  className: "path-modal-input",
2059
2087
  value: n[g.key],
2060
2088
  placeholder: g.placeholder,
2061
- autoFocus: m === 0,
2062
- onChange: (k) => a((h) => ({ ...h, [g.key]: k.target.value }))
2089
+ autoFocus: h === 0,
2090
+ onChange: (v) => a((m) => ({ ...m, [g.key]: v.target.value }))
2063
2091
  }
2064
2092
  )
2065
2093
  ] }, g.key)),
2066
2094
  c && /* @__PURE__ */ t("div", { className: "modal-err", children: c })
2067
2095
  ] }) });
2068
2096
  }
2069
- function Zt(e) {
2070
- const { documentId: r, scope: n, titleHint: a, browse: o, theme: i, principal: c, renderAssistant: s } = e, d = Pe(e);
2071
- return /* @__PURE__ */ t(Ae, { theme: i, dataLayer: d, children: /* @__PURE__ */ t(
2097
+ function qt(e) {
2098
+ const { documentId: r, scope: n, titleHint: a, browse: o, theme: i, principal: c, renderAssistant: s } = e, u = Ae(e);
2099
+ return /* @__PURE__ */ t(Pe, { theme: i, dataLayer: u, children: /* @__PURE__ */ t(
2072
2100
  Fe,
2073
2101
  {
2074
2102
  documentId: r,
@@ -2082,15 +2110,15 @@ function Zt(e) {
2082
2110
  }
2083
2111
  export {
2084
2112
  be as DEFAULT_SCHEME,
2085
- Zt as DocumentViewer,
2086
- Jt as PathExplorer,
2087
- lt as assetFetchFromConnection,
2088
- pt as chunkColor,
2089
- st as createLoomcycleClient,
2113
+ qt as DocumentViewer,
2114
+ Zt as PathExplorer,
2115
+ dt as assetFetchFromConnection,
2116
+ ft as chunkColor,
2117
+ lt as createLoomcycleClient,
2090
2118
  _e as dataLayerFromClient,
2091
2119
  Ie as docColor,
2092
- ke as effectiveScheme,
2093
- ft as hexToTint,
2120
+ ve as effectiveScheme,
2121
+ gt as hexToTint,
2094
2122
  Ne as tintStyle
2095
2123
  };
2096
2124
  //# sourceMappingURL=index.js.map