@loomcycle/explorer 0.13.0 → 0.16.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
@@ -1121,21 +1121,21 @@ async function Y(e, t) {
1121
1121
  }
1122
1122
  return n;
1123
1123
  }
1124
- function X(e) {
1124
+ function Pe(e) {
1125
1125
  return Math.max(1, Math.ceil(e / J));
1126
1126
  }
1127
1127
  //#endregion
1128
1128
  //#region src/lib/bulkReview.ts
1129
- function Z(e) {
1129
+ function X(e) {
1130
1130
  return e === "tenant" || e === "user" ? e : void 0;
1131
1131
  }
1132
- function Pe(e, t) {
1133
- return e.documentRuleStatements ? Z(t) : void 0;
1134
- }
1135
1132
  function Fe(e, t) {
1133
+ return e.documentRuleStatements ? X(t) : void 0;
1134
+ }
1135
+ function Ie(e, t) {
1136
1136
  return e.filter((e) => q(e) && !!e.id && e.from_document_id === t);
1137
1137
  }
1138
- function Ie(e, t, n, r) {
1138
+ function Le(e, t, n, r) {
1139
1139
  return e ? {
1140
1140
  proposals: t,
1141
1141
  scope: e,
@@ -1143,7 +1143,7 @@ function Ie(e, t, n, r) {
1143
1143
  onChanged: r
1144
1144
  } : void 0;
1145
1145
  }
1146
- function Le(e, t, n) {
1146
+ function Re(e, t, n) {
1147
1147
  return e.documentRuleStatements ? Ne({ rule: (n) => e.documentRuleStatements(n, t.browse) }, {
1148
1148
  action: t.action,
1149
1149
  ...t.ids && t.ids.length > 0 ? { ids: t.ids } : { filter: { from_document_id: t.documentId } },
@@ -1152,13 +1152,13 @@ function Le(e, t, n) {
1152
1152
  ...t.scope === "user" && t.browse?.scopeId ? { scopeId: t.browse.scopeId } : {}
1153
1153
  }, n) : Promise.reject(/* @__PURE__ */ Error("this data layer cannot rule in bulk"));
1154
1154
  }
1155
- function Re(e, t) {
1155
+ function ze(e, t) {
1156
1156
  let n = (e) => e.toLocaleString("en-US"), r = [`${e === "accept" ? "Accepted" : "Rejected"} ${n(t.ruled)} statement${t.ruled === 1 ? "" : "s"}`];
1157
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("; ") + ".";
1158
1158
  }
1159
1159
  //#endregion
1160
1160
  //#region src/lib/colorScheme.ts
1161
- var Q = {
1161
+ var Z = {
1162
1162
  "doc.rfc.draft": "#c99a3a",
1163
1163
  "doc.rfc.review": "#6a7bd6",
1164
1164
  "doc.rfc.confirmed": "#3a9ad6",
@@ -1177,9 +1177,9 @@ var Q = {
1177
1177
  "chunk.backlog": "#8a8f98",
1178
1178
  "chunk.implementation": "#d1863a",
1179
1179
  "chunk.merged": "#3aa06a"
1180
- }, ze = .16;
1180
+ }, Q = .16;
1181
1181
  function Be(e) {
1182
- return e && Object.keys(e).length > 0 ? e : Q;
1182
+ return e && Object.keys(e).length > 0 ? e : Z;
1183
1183
  }
1184
1184
  function Ve(e, t, n) {
1185
1185
  let r = e ?? "", i = t ?? "";
@@ -1191,22 +1191,35 @@ function He(e, t) {
1191
1191
  return n ? t[`chunk.${n}`] : void 0;
1192
1192
  }
1193
1193
  function Ue(e) {
1194
- let t = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());
1195
- if (!t) return;
1196
- let n = t[1];
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})`;
1194
+ let t = String(e["chunk.inherit"] ?? "").trim().toLowerCase();
1195
+ return t !== "false" && t !== "none" && t !== "off" && t !== "0";
1198
1196
  }
1199
- function We(e) {
1197
+ function We(e, t = Q) {
1198
+ let n = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());
1199
+ if (!n) return;
1200
+ let r = n[1];
1201
+ return r.length === 3 && (r = r[0] + r[0] + r[1] + r[1] + r[2] + r[2]), `rgba(${parseInt(r.slice(0, 2), 16)}, ${parseInt(r.slice(2, 4), 16)}, ${parseInt(r.slice(4, 6), 16)}, ${t})`;
1202
+ }
1203
+ function Ge(e) {
1200
1204
  if (!e) return;
1201
- let t = Ue(e);
1205
+ let t = We(e);
1202
1206
  if (t) return {
1203
1207
  background: t,
1204
1208
  borderLeft: `3px solid ${e}`
1205
1209
  };
1206
1210
  }
1211
+ function Ke(e) {
1212
+ if (!e) return;
1213
+ let t = We(e, Q / 2);
1214
+ return t ? { background: t } : void 0;
1215
+ }
1216
+ function qe(e) {
1217
+ let { status: t, isRoot: n, documentColor: r, scheme: i } = e;
1218
+ if (i) return n ? Ge(r) ?? Ge(He(t, i)) : Ge(He(t, i)) ?? (Ue(i) ? Ke(r) : void 0);
1219
+ }
1207
1220
  //#endregion
1208
1221
  //#region src/lib/clipboard.ts
1209
- async function Ge(e) {
1222
+ async function $(e) {
1210
1223
  try {
1211
1224
  return typeof navigator > "u" || !navigator.clipboard ? !1 : (await navigator.clipboard.writeText(e), !0);
1212
1225
  } catch {
@@ -1215,10 +1228,10 @@ async function Ge(e) {
1215
1228
  }
1216
1229
  //#endregion
1217
1230
  //#region src/components/IdCopy.tsx
1218
- function Ke({ value: e, label: t, compact: n, title: r }) {
1231
+ function Je({ value: e, label: t, compact: n, title: r }) {
1219
1232
  let [i, a] = o("idle"), s = async (t) => {
1220
1233
  t.stopPropagation(), t.preventDefault();
1221
- let n = await Ge(e);
1234
+ let n = await $(e);
1222
1235
  a(n ? "copied" : "error"), window.setTimeout(() => a("idle"), n ? 1200 : 1500);
1223
1236
  }, c = i === "copied" ? "✓" : i === "error" ? "✗" : "⎘", d = r ?? `Copy ${t ?? "id"}: ${e}`, f = /* @__PURE__ */ l("button", {
1224
1237
  type: "button",
@@ -1246,7 +1259,7 @@ function Ke({ value: e, label: t, compact: n, title: r }) {
1246
1259
  }
1247
1260
  //#endregion
1248
1261
  //#region src/components/DocumentChunkTree.tsx
1249
- function qe(e) {
1262
+ function Ye(e) {
1250
1263
  let t = /* @__PURE__ */ new Map();
1251
1264
  e.forEach((e) => t.set(e.id, {
1252
1265
  row: e,
@@ -1262,50 +1275,52 @@ function qe(e) {
1262
1275
  };
1263
1276
  return r(n), n;
1264
1277
  }
1265
- function Je(e) {
1278
+ function Xe(e) {
1266
1279
  return e === "image" ? "🖼" : e === "mermaid" ? "📊" : "";
1267
1280
  }
1268
- function $(e, t) {
1281
+ function Ze(e, t) {
1269
1282
  for (let n of e) {
1270
1283
  if (n.row.id === t) return n;
1271
- let e = $(n.children, t);
1284
+ let e = Ze(n.children, t);
1272
1285
  if (e) return e;
1273
1286
  }
1274
1287
  }
1275
- function Ye({ tree: e, selectedId: n, onSelect: i, colorEnabled: a, scheme: s, linkedIds: c }) {
1276
- let [u, d] = o(() => /* @__PURE__ */ new Map()), f = t((e) => {
1277
- d((t) => {
1288
+ function Qe({ tree: e, selectedId: n, onSelect: i, colorEnabled: a, scheme: s, documentColor: c, linkedIds: u }) {
1289
+ let [d, f] = o(() => /* @__PURE__ */ new Map()), p = t((e) => {
1290
+ f((t) => {
1278
1291
  let n = new Map(t);
1279
1292
  return n.set(e, t.get(e) === !1), n;
1280
1293
  });
1281
1294
  }, []);
1282
1295
  r(() => {
1283
1296
  if (!n) return;
1284
- let t = Xe(e, n);
1285
- t.length !== 0 && d((e) => {
1297
+ let t = $e(e, n);
1298
+ t.length !== 0 && f((e) => {
1286
1299
  let n = !1, r = new Map(e);
1287
1300
  for (let e of t) r.get(e) === !1 && (r.set(e, !0), n = !0);
1288
1301
  return n ? r : e;
1289
1302
  });
1290
1303
  }, [e, n]);
1291
- let p = a ? Be(s) : null;
1304
+ let m = a ? Be(s) : null;
1292
1305
  return e.length === 0 ? /* @__PURE__ */ l("div", {
1293
1306
  className: "empty",
1294
1307
  children: /* @__PURE__ */ l("p", { children: "No chunks." })
1295
1308
  }) : /* @__PURE__ */ l("ul", {
1296
1309
  className: "tree chunk-tree",
1297
- children: e.map((e) => /* @__PURE__ */ l(Ze, {
1310
+ children: e.map((e) => /* @__PURE__ */ l(et, {
1298
1311
  node: e,
1299
- expanded: u,
1300
- toggle: f,
1312
+ expanded: d,
1313
+ toggle: p,
1301
1314
  selectedId: n,
1302
1315
  onSelect: i,
1303
- tintScheme: p,
1304
- linkedIds: c
1316
+ tintScheme: m,
1317
+ documentColor: c,
1318
+ isRoot: !0,
1319
+ linkedIds: u
1305
1320
  }, e.row.id))
1306
1321
  });
1307
1322
  }
1308
- function Xe(e, t) {
1323
+ function $e(e, t) {
1309
1324
  let n = [], r = (e, i) => {
1310
1325
  for (let a of e) {
1311
1326
  if (a.row.id === t) return n.push(...i), !0;
@@ -1315,23 +1330,28 @@ function Xe(e, t) {
1315
1330
  };
1316
1331
  return r(e, []), n;
1317
1332
  }
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);
1333
+ function et({ node: e, expanded: t, toggle: n, selectedId: r, onSelect: i, tintScheme: a, documentColor: o, isRoot: s = !1, linkedIds: c }) {
1334
+ let d = e.children.length > 0, f = t.get(e.row.id) !== !1, p = r === e.row.id, m = qe({
1335
+ status: e.row.status,
1336
+ isRoot: s,
1337
+ documentColor: o,
1338
+ scheme: a
1339
+ }), h = c?.has(e.row.id);
1320
1340
  return /* @__PURE__ */ u("li", {
1321
- className: `node chunk-node ${d ? "selected" : ""}`,
1341
+ className: `node chunk-node ${p ? "selected" : ""}`,
1322
1342
  children: [/* @__PURE__ */ u("div", {
1323
1343
  className: "row chunk-row",
1324
- style: f,
1344
+ style: m,
1325
1345
  children: [
1326
1346
  /* @__PURE__ */ l("button", {
1327
1347
  type: "button",
1328
1348
  className: "tree-caret",
1329
- "aria-label": c ? "collapse" : "expand",
1330
- disabled: !s,
1349
+ "aria-label": f ? "collapse" : "expand",
1350
+ disabled: !d,
1331
1351
  onClick: (t) => {
1332
- t.stopPropagation(), s && n(e.row.id);
1352
+ t.stopPropagation(), d && n(e.row.id);
1333
1353
  },
1334
- children: s ? c ? "▼" : "▶" : "·"
1354
+ children: d ? f ? "▼" : "▶" : "·"
1335
1355
  }),
1336
1356
  /* @__PURE__ */ u("button", {
1337
1357
  type: "button",
@@ -1339,10 +1359,10 @@ function Ze({ node: e, expanded: t, toggle: n, selectedId: r, onSelect: i, tintS
1339
1359
  onClick: () => i(e),
1340
1360
  title: e.row.title,
1341
1361
  children: [
1342
- Je(e.row.type) && /* @__PURE__ */ l("span", {
1362
+ Xe(e.row.type) && /* @__PURE__ */ l("span", {
1343
1363
  className: "chunk-type-icon",
1344
1364
  "aria-hidden": !0,
1345
- children: Je(e.row.type)
1365
+ children: Xe(e.row.type)
1346
1366
  }),
1347
1367
  /* @__PURE__ */ l("span", {
1348
1368
  className: "chunk-title",
@@ -1356,7 +1376,7 @@ function Ze({ node: e, expanded: t, toggle: n, selectedId: r, onSelect: i, tintS
1356
1376
  className: "chunk-badge chunk-status",
1357
1377
  children: e.row.status
1358
1378
  }),
1359
- p && /* @__PURE__ */ l("span", {
1379
+ h && /* @__PURE__ */ l("span", {
1360
1380
  className: "chunk-link-badge",
1361
1381
  title: "Has cross-reference links",
1362
1382
  "aria-label": "linked",
@@ -1364,34 +1384,35 @@ function Ze({ node: e, expanded: t, toggle: n, selectedId: r, onSelect: i, tintS
1364
1384
  })
1365
1385
  ]
1366
1386
  }),
1367
- /* @__PURE__ */ l(Ke, {
1387
+ /* @__PURE__ */ l(Je, {
1368
1388
  value: e.row.id,
1369
1389
  compact: !0,
1370
1390
  title: `Copy chunk id: ${e.row.id}`
1371
1391
  })
1372
1392
  ]
1373
- }), s && c && /* @__PURE__ */ l("ul", {
1393
+ }), d && f && /* @__PURE__ */ l("ul", {
1374
1394
  className: "children chunk-children",
1375
- children: e.children.map((e) => /* @__PURE__ */ l(Ze, {
1395
+ children: e.children.map((e) => /* @__PURE__ */ l(et, {
1376
1396
  node: e,
1377
1397
  expanded: t,
1378
1398
  toggle: n,
1379
1399
  selectedId: r,
1380
1400
  onSelect: i,
1381
1401
  tintScheme: a,
1382
- linkedIds: o
1402
+ documentColor: o,
1403
+ linkedIds: c
1383
1404
  }, e.row.id))
1384
1405
  })]
1385
1406
  });
1386
1407
  }
1387
1408
  //#endregion
1388
1409
  //#region src/components/Mermaid.tsx
1389
- var Qe = 0;
1390
- function $e(e) {
1410
+ var tt = 0;
1411
+ function nt(e) {
1391
1412
  let t = e?.closest("g.node");
1392
1413
  return t ? /flowchart-(.+)-\d+$/.exec(t.id)?.[1] : void 0;
1393
1414
  }
1394
- function et({ code: e, onNodeClick: t }) {
1415
+ function rt({ code: e, onNodeClick: t }) {
1395
1416
  let n = a(null), [i, s] = o({});
1396
1417
  return r(() => {
1397
1418
  let t = !1;
@@ -1403,7 +1424,7 @@ function et({ code: e, onNodeClick: t }) {
1403
1424
  theme: a ? "dark" : "default",
1404
1425
  securityLevel: "strict"
1405
1426
  });
1406
- let { svg: o } = await r.render(`lc-mmd-${Qe++}`, e);
1427
+ let { svg: o } = await r.render(`lc-mmd-${tt++}`, e);
1407
1428
  t || s({ svg: o });
1408
1429
  } catch {
1409
1430
  t || s({ err: !0 });
@@ -1419,7 +1440,7 @@ function et({ code: e, onNodeClick: t }) {
1419
1440
  ref: n,
1420
1441
  className: t ? "md-mermaid md-mermaid-nav" : "md-mermaid",
1421
1442
  onClick: t && ((e) => {
1422
- let n = $e(e.target);
1443
+ let n = nt(e.target);
1423
1444
  n && t(n);
1424
1445
  }),
1425
1446
  dangerouslySetInnerHTML: { __html: i.svg }
@@ -1431,7 +1452,7 @@ function et({ code: e, onNodeClick: t }) {
1431
1452
  }
1432
1453
  //#endregion
1433
1454
  //#region src/components/ChunkEditorModal.tsx
1434
- function tt({ chunk: e, scope: t, browse: n, onClose: i, onSaved: a }) {
1455
+ function it({ chunk: e, scope: t, browse: n, onClose: i, onSaved: a }) {
1435
1456
  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);
1436
1457
  r(() => {
1437
1458
  if (!O) return;
@@ -1560,7 +1581,7 @@ function tt({ chunk: e, scope: t, browse: n, onClose: i, onSaved: a }) {
1560
1581
  className: "path-field",
1561
1582
  children: [/* @__PURE__ */ l("span", { children: "Preview" }), /* @__PURE__ */ l("div", {
1562
1583
  className: "chunk-mermaid-preview",
1563
- children: A.trim() ? /* @__PURE__ */ l(et, { code: A }) : /* @__PURE__ */ l("p", {
1584
+ children: A.trim() ? /* @__PURE__ */ l(rt, { code: A }) : /* @__PURE__ */ l("p", {
1564
1585
  className: "doc-empty-body",
1565
1586
  children: "(enter Mermaid source above)"
1566
1587
  })
@@ -1582,7 +1603,7 @@ function tt({ chunk: e, scope: t, browse: n, onClose: i, onSaved: a }) {
1582
1603
  }
1583
1604
  //#endregion
1584
1605
  //#region src/components/SubjectTypeModal.tsx
1585
- function nt({ chunk: e, scope: t, browse: n, onClose: i, onSaved: a }) {
1606
+ function at({ chunk: e, scope: t, browse: n, onClose: i, onSaved: a }) {
1586
1607
  let s = M(), [c, d] = o(null), [f, p] = o(e.type ?? ""), [m, h] = o(!1), [g, _] = o(null), [v, b] = o(null);
1587
1608
  r(() => {
1588
1609
  let e = !1;
@@ -1675,18 +1696,18 @@ function nt({ chunk: e, scope: t, browse: n, onClose: i, onSaved: a }) {
1675
1696
  }
1676
1697
  //#endregion
1677
1698
  //#region src/lib/classify.ts
1678
- function rt(e) {
1699
+ function ot(e) {
1679
1700
  return Array.isArray(e) && e.every((e) => typeof e == "string");
1680
1701
  }
1681
- function it(e) {
1702
+ function st(e) {
1682
1703
  if (!e || typeof e != "object") return;
1683
1704
  let t = e.classification;
1684
1705
  if (!t || typeof t != "object" || Array.isArray(t)) return;
1685
1706
  let n = t, 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;
1707
+ 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), ot(n.proposed_tags) && (r.proposed_tags = n.proposed_tags), ot(n.statements) && (r.statements = n.statements), r;
1687
1708
  }
1688
- function at(e) {
1689
- let t = it(e);
1709
+ function ct(e) {
1710
+ let t = st(e);
1690
1711
  if (!t) return;
1691
1712
  let n = t.proposed_tags ?? [], r = t.statements?.length ?? 0;
1692
1713
  if (t.proposed_type || n.length !== 0 || r !== 0) return {
@@ -1695,7 +1716,7 @@ function at(e) {
1695
1716
  statementCount: r
1696
1717
  };
1697
1718
  }
1698
- function ot(e) {
1719
+ function lt(e) {
1699
1720
  let t = e.write === "report";
1700
1721
  switch (e.result) {
1701
1722
  case "classified": return t ? "would be classified" : "classified";
@@ -1705,46 +1726,46 @@ function ot(e) {
1705
1726
  default: return String(e.result);
1706
1727
  }
1707
1728
  }
1708
- function st(e) {
1729
+ function ut(e) {
1709
1730
  if (!e.class) return;
1710
1731
  if (e.result === "kept") return "not applied";
1711
1732
  let t = e.write === "report";
1712
1733
  return e.live ? t ? "would be applied" : "applied" : t ? "would be proposed" : "proposed";
1713
1734
  }
1714
- function ct(e) {
1735
+ function dt(e) {
1715
1736
  return e.write === "report" ? e.result === "classified" || e.result === "proposed" || (e.concepts?.length ?? 0) > 0 || (e.issued_by?.length ?? 0) > 0 : !1;
1716
1737
  }
1717
- function lt(e) {
1738
+ function ft(e) {
1718
1739
  return e == null || !Number.isFinite(e) ? "" : `${Math.round(e * 100)}%`;
1719
1740
  }
1720
- var ut = {
1741
+ var pt = {
1721
1742
  rules: "Rules",
1722
1743
  vote: "Neighbourhood vote",
1723
1744
  model: "Model"
1724
1745
  };
1725
- function dt(e) {
1726
- return ut[e] ?? e;
1746
+ function mt(e) {
1747
+ return pt[e] ?? e;
1727
1748
  }
1728
- function ft(e) {
1749
+ function ht(e) {
1729
1750
  let t = [];
1730
1751
  e.quote && t.push(e.from ? `“${e.quote}” (${e.from})` : `“${e.quote}”`), e.votes != null && t.push(`${e.votes} vote${e.votes === 1 ? "" : "s"}`);
1731
- let n = lt(e.share);
1752
+ let n = ft(e.share);
1732
1753
  return n && t.push(n), t.join(" · ");
1733
1754
  }
1734
- function pt(e) {
1755
+ function gt(e) {
1735
1756
  return {
1736
- label: dt(e.step),
1757
+ label: mt(e.step),
1737
1758
  ...e.chosen ? { chosen: e.chosen } : {},
1738
1759
  ...e.method ? { method: e.method } : {},
1739
1760
  ...e.neighbours ? { neighbours: e.neighbours } : {},
1740
1761
  ...e.reason ? { reason: e.reason } : {},
1741
1762
  candidates: (e.candidates ?? []).map((e) => ({
1742
1763
  class: e.class,
1743
- detail: ft(e)
1764
+ detail: ht(e)
1744
1765
  }))
1745
1766
  };
1746
1767
  }
1747
- function mt(e) {
1768
+ function _t(e) {
1748
1769
  let t = [];
1749
1770
  e.type && t.push(`type ${e.type}`);
1750
1771
  let n = e.accepted_statements?.length ?? 0;
@@ -1757,18 +1778,18 @@ function mt(e) {
1757
1778
  notices: r
1758
1779
  };
1759
1780
  }
1760
- function ht(e) {
1781
+ function vt(e) {
1761
1782
  let t = e instanceof Error ? e.message : String(e);
1762
1783
  return t.includes("nothing_pending") ? "Nothing is pending for this document — it may already have been accepted." : t;
1763
1784
  }
1764
1785
  //#endregion
1765
1786
  //#region src/components/Classification.tsx
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]);
1787
+ function yt({ documentId: e, scope: t, browse: n, rootFields: a, requestKey: s, onClose: c, onChanged: d }) {
1788
+ 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 ? ct(a) : void 0, [f, a]);
1768
1789
  r(() => {
1769
1790
  if (s === 0 || !f.documentClassify) return;
1770
1791
  let r = !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)), () => {
1792
+ return g(!0), v(null), m(null), f.documentClassify(e, "report", t, n).then((e) => !r && m(e)).catch((e) => !r && v(vt(e))).finally(() => !r && g(!1)), () => {
1772
1793
  r = !0;
1773
1794
  };
1774
1795
  }, [
@@ -1784,7 +1805,7 @@ function gt({ documentId: e, scope: t, browse: n, rootFields: a, requestKey: s,
1784
1805
  try {
1785
1806
  m(await f.documentClassify(e, "propose", t, n)), d();
1786
1807
  } catch (e) {
1787
- v(ht(e));
1808
+ v(vt(e));
1788
1809
  } finally {
1789
1810
  g(!1);
1790
1811
  }
@@ -1795,14 +1816,14 @@ function gt({ documentId: e, scope: t, browse: n, rootFields: a, requestKey: s,
1795
1816
  try {
1796
1817
  w(await f.documentAcceptClassification(e, t, n)), d();
1797
1818
  } catch (e) {
1798
- S(ht(e));
1819
+ S(vt(e));
1799
1820
  } finally {
1800
1821
  b(!1);
1801
1822
  }
1802
1823
  }
1803
1824
  }, O = s > 0;
1804
1825
  if (!O && !T && !C && !x) return null;
1805
- let k = C ? mt(C) : void 0;
1826
+ let k = C ? _t(C) : void 0;
1806
1827
  return /* @__PURE__ */ u("div", {
1807
1828
  className: "doc-classify",
1808
1829
  children: [
@@ -1873,7 +1894,7 @@ function gt({ documentId: e, scope: t, browse: n, rootFields: a, requestKey: s,
1873
1894
  /* @__PURE__ */ l("h4", { children: "Classify" }),
1874
1895
  p && /* @__PURE__ */ l("span", {
1875
1896
  className: `doc-classify-result ${p.result}`,
1876
- children: ot(p)
1897
+ children: lt(p)
1877
1898
  }),
1878
1899
  p?.write === "report" && /* @__PURE__ */ l("span", {
1879
1900
  className: "doc-classify-hint",
@@ -1897,8 +1918,8 @@ function gt({ documentId: e, scope: t, browse: n, rootFields: a, requestKey: s,
1897
1918
  role: "alert",
1898
1919
  children: _
1899
1920
  }),
1900
- p && /* @__PURE__ */ l(_t, { answer: p }),
1901
- p && ct(p) && /* @__PURE__ */ l("div", {
1921
+ p && /* @__PURE__ */ l(bt, { answer: p }),
1922
+ p && dt(p) && /* @__PURE__ */ l("div", {
1902
1923
  className: "doc-classify-actions",
1903
1924
  children: /* @__PURE__ */ l("button", {
1904
1925
  type: "button",
@@ -1913,8 +1934,8 @@ function gt({ documentId: e, scope: t, browse: n, rootFields: a, requestKey: s,
1913
1934
  ]
1914
1935
  });
1915
1936
  }
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;
1937
+ function bt({ answer: e }) {
1938
+ let t = ut(e), n = Object.entries(e.fields ?? {}), r = e.issued_by ?? [], i = e.concepts ?? [], a = (e.steps ?? []).map(gt), o = e.statements?.length ?? 0;
1918
1939
  return /* @__PURE__ */ u(c, { children: [
1919
1940
  /* @__PURE__ */ u("dl", {
1920
1941
  className: "doc-classify-rows",
@@ -1952,7 +1973,7 @@ function _t({ answer: e }) {
1952
1973
  title: e.tag,
1953
1974
  children: [e.concept, /* @__PURE__ */ u("span", {
1954
1975
  className: "doc-classify-hint",
1955
- children: [" ", lt(e.share)]
1976
+ children: [" ", ft(e.share)]
1956
1977
  })]
1957
1978
  }, e.tag)) })] }),
1958
1979
  o > 0 && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("dt", { children: "statements" }), /* @__PURE__ */ u("dd", { children: [
@@ -2020,15 +2041,15 @@ function _t({ answer: e }) {
2020
2041
  }
2021
2042
  //#endregion
2022
2043
  //#region src/components/ColorSchemeEditor.tsx
2023
- function vt(e) {
2044
+ function xt(e) {
2024
2045
  let t = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec((e ?? "").trim());
2025
2046
  if (!t) return "#888888";
2026
2047
  let n = t[1];
2027
2048
  return n.length === 3 && (n = n[0] + n[0] + n[1] + n[1] + n[2] + n[2]), "#" + n.toLowerCase();
2028
2049
  }
2029
- function yt({ documentId: e, rootChunkId: t, docType: n, docStatus: a, chunkStatuses: s, scope: d, browse: f, onClose: p, onSaved: m }) {
2050
+ function St({ documentId: e, rootChunkId: t, docType: n, docStatus: a, chunkStatuses: s, scope: d, browse: f, onClose: p, onSaved: m }) {
2030
2051
  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));
2052
+ let e = new Set(Object.keys(Z));
2032
2053
  n && e.add(`doc.${n}.${a || "draft"}`);
2033
2054
  for (let t of s) t && e.add(`chunk.${t}`);
2034
2055
  return [...e].sort();
@@ -2046,7 +2067,7 @@ function yt({ documentId: e, rootChunkId: t, docType: n, docStatus: a, chunkStat
2046
2067
  y(n.color_enabled === !0);
2047
2068
  let r = n.color_scheme ?? {};
2048
2069
  x({
2049
- ...Q,
2070
+ ...Z,
2050
2071
  ...r
2051
2072
  });
2052
2073
  }).catch((t) => !e && D(t instanceof Error ? t.message : String(t))), () => {
@@ -2136,7 +2157,7 @@ function yt({ documentId: e, rootChunkId: t, docType: n, docStatus: a, chunkStat
2136
2157
  }),
2137
2158
  /* @__PURE__ */ u("div", {
2138
2159
  className: "scheme-group",
2139
- children: [/* @__PURE__ */ l("h4", { children: "Document (type · status)" }), P.map((e) => /* @__PURE__ */ l(bt, {
2160
+ children: [/* @__PURE__ */ l("h4", { children: "Document (type · status)" }), P.map((e) => /* @__PURE__ */ l(Ct, {
2140
2161
  label: e.slice(4),
2141
2162
  value: b[e],
2142
2163
  onChange: (t) => k(e, t)
@@ -2144,7 +2165,7 @@ function yt({ documentId: e, rootChunkId: t, docType: n, docStatus: a, chunkStat
2144
2165
  }),
2145
2166
  /* @__PURE__ */ u("div", {
2146
2167
  className: "scheme-group",
2147
- children: [/* @__PURE__ */ l("h4", { children: "Chunks (status)" }), F.map((e) => /* @__PURE__ */ l(bt, {
2168
+ children: [/* @__PURE__ */ l("h4", { children: "Chunks (status)" }), F.map((e) => /* @__PURE__ */ l(Ct, {
2148
2169
  label: e.slice(6),
2149
2170
  value: b[e],
2150
2171
  onChange: (t) => k(e, t)
@@ -2175,8 +2196,8 @@ function yt({ documentId: e, rootChunkId: t, docType: n, docStatus: a, chunkStat
2175
2196
  })
2176
2197
  });
2177
2198
  }
2178
- function bt({ label: e, value: t, onChange: n }) {
2179
- let r = vt(t);
2199
+ function Ct({ label: e, value: t, onChange: n }) {
2200
+ let r = xt(t);
2180
2201
  return /* @__PURE__ */ u("label", {
2181
2202
  className: "scheme-row",
2182
2203
  children: [
@@ -2198,7 +2219,7 @@ function bt({ label: e, value: t, onChange: n }) {
2198
2219
  }
2199
2220
  //#endregion
2200
2221
  //#region src/components/ChunkTarget.tsx
2201
- function xt({ id: e, title: t, targetDocumentId: n, documentId: r, onSelectChunk: i, onOpenDocument: a }) {
2222
+ function wt({ id: e, title: t, targetDocumentId: n, documentId: r, onSelectChunk: i, onOpenDocument: a }) {
2202
2223
  let o = t || e.slice(0, 8);
2203
2224
  return !n || n === r ? /* @__PURE__ */ l("button", {
2204
2225
  type: "button",
@@ -2219,7 +2240,7 @@ function xt({ id: e, title: t, targetDocumentId: n, documentId: r, onSelectChunk
2219
2240
  }
2220
2241
  //#endregion
2221
2242
  //#region src/components/Statement.tsx
2222
- function St({ statement: e }) {
2243
+ function Tt({ statement: e }) {
2223
2244
  let t = Ce(e), n = we(e), r = De(e), i = Ee(e), { rows: a, more: o } = Oe(e);
2224
2245
  return /* @__PURE__ */ u(c, { children: [
2225
2246
  t && /* @__PURE__ */ l("span", {
@@ -2264,7 +2285,7 @@ function St({ statement: e }) {
2264
2285
  })
2265
2286
  ] });
2266
2287
  }
2267
- function Ct({ id: e, onRule: t }) {
2288
+ function Et({ id: e, onRule: t }) {
2268
2289
  let [n, r] = o(!1), [i, a] = o(""), [s, d] = o(!1), [f, p] = o(null), m = async (n) => {
2269
2290
  d(!0), p(null);
2270
2291
  try {
@@ -2322,8 +2343,8 @@ function Ct({ id: e, onRule: t }) {
2322
2343
  }
2323
2344
  //#endregion
2324
2345
  //#region src/components/ProposalReview.tsx
2325
- var wt = 3;
2326
- function Tt({ documentId: e, proposals: t, incomplete: n, scope: r, browse: i, onChanged: s, onSelectChunk: c, onOpenDocument: d }) {
2346
+ var Dt = 3;
2347
+ function Ot({ documentId: e, proposals: t, incomplete: n, scope: r, browse: i, onChanged: s, onSelectChunk: c, onOpenDocument: d }) {
2327
2348
  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) => {
2328
2349
  b(null), S(null), e === "reject" ? g({
2329
2350
  kind: "reason",
@@ -2338,7 +2359,7 @@ function Tt({ documentId: e, proposals: t, incomplete: n, scope: r, browse: i, o
2338
2359
  });
2339
2360
  let o;
2340
2361
  try {
2341
- o = await Le(f, {
2362
+ o = await Re(f, {
2342
2363
  documentId: e,
2343
2364
  action: t,
2344
2365
  ids: n ? void 0 : T,
@@ -2375,7 +2396,7 @@ function Tt({ documentId: e, proposals: t, incomplete: n, scope: r, browse: i, o
2375
2396
  };
2376
2397
  }
2377
2398
  C.current = null, g({ kind: "idle" }), v(""), o.rulingIds.length > 0 ? (m(/* @__PURE__ */ new Set()), S({
2378
- text: Re(t, o),
2399
+ text: ze(t, o),
2379
2400
  rulingIds: o.rulingIds
2380
2401
  }), s()) : o.error === void 0 && !o.cancelled && S({
2381
2402
  text: "Nothing to rule: no proposals match.",
@@ -2483,7 +2504,7 @@ function Tt({ documentId: e, proposals: t, incomplete: n, scope: r, browse: i, o
2483
2504
  className: "doc-conn-empty",
2484
2505
  children: "counting…"
2485
2506
  }),
2486
- h.kind === "confirm" && /* @__PURE__ */ l(Et, {
2507
+ h.kind === "confirm" && /* @__PURE__ */ l(kt, {
2487
2508
  step: h,
2488
2509
  onAnswer: k
2489
2510
  }),
@@ -2520,7 +2541,7 @@ function Tt({ documentId: e, proposals: t, incomplete: n, scope: r, browse: i, o
2520
2541
  disabled: E,
2521
2542
  onChange: () => j(t.id)
2522
2543
  }),
2523
- /* @__PURE__ */ l(xt, {
2544
+ /* @__PURE__ */ l(wt, {
2524
2545
  id: t.from_id,
2525
2546
  title: t.from_title,
2526
2547
  targetDocumentId: t.from_document_id,
@@ -2532,7 +2553,7 @@ function Tt({ documentId: e, proposals: t, incomplete: n, scope: r, browse: i, o
2532
2553
  className: "doc-ref-kind",
2533
2554
  children: t.kind
2534
2555
  }),
2535
- /* @__PURE__ */ l(xt, {
2556
+ /* @__PURE__ */ l(wt, {
2536
2557
  id: t.to_id,
2537
2558
  title: t.to_title,
2538
2559
  targetDocumentId: t.to_document_id,
@@ -2540,15 +2561,15 @@ function Tt({ documentId: e, proposals: t, incomplete: n, scope: r, browse: i, o
2540
2561
  onSelectChunk: c,
2541
2562
  onOpenDocument: d
2542
2563
  }),
2543
- /* @__PURE__ */ l(St, { statement: t })
2564
+ /* @__PURE__ */ l(Tt, { statement: t })
2544
2565
  ]
2545
2566
  }, t.id))
2546
2567
  })
2547
2568
  ]
2548
2569
  });
2549
2570
  }
2550
- function Et({ step: e, onAnswer: t }) {
2551
- let { dry: n } = e, r = e.action === "accept" ? "Accept" : "Reject", i = X(n.matched);
2571
+ function kt({ step: e, onAnswer: t }) {
2572
+ let { dry: n } = e, r = e.action === "accept" ? "Accept" : "Reject", i = Pe(n.matched);
2552
2573
  return /* @__PURE__ */ u("div", {
2553
2574
  className: "doc-bulk-step doc-bulk-confirm",
2554
2575
  children: [
@@ -2569,7 +2590,7 @@ function Et({ step: e, onAnswer: t }) {
2569
2590
  ] }),
2570
2591
  (n.sample ?? []).length > 0 && /* @__PURE__ */ l("ul", {
2571
2592
  className: "doc-bulk-sample",
2572
- children: (n.sample ?? []).slice(0, wt).map((e) => /* @__PURE__ */ u("li", { children: [
2593
+ children: (n.sample ?? []).slice(0, Dt).map((e) => /* @__PURE__ */ u("li", { children: [
2573
2594
  e.from_title || e.from_id,
2574
2595
  " ",
2575
2596
  /* @__PURE__ */ l("span", {
@@ -2600,26 +2621,26 @@ function Et({ step: e, onAnswer: t }) {
2600
2621
  }
2601
2622
  //#endregion
2602
2623
  //#region src/components/Connections.tsx
2603
- var Dt = 8, Ot = 20;
2604
- function kt(e) {
2624
+ var At = 8, jt = 20;
2625
+ function Mt(e) {
2605
2626
  return /embedder|embedding|vector|semantic|not configured/i.test(e);
2606
2627
  }
2607
- function At({ documentId: e, selectedId: t, scope: n, browse: i, onSelectChunk: a, onOpenDocument: s, refreshKey: d, review: f }) {
2628
+ function Nt({ documentId: e, selectedId: t, scope: n, browse: i, onSelectChunk: a, onOpenDocument: s, refreshKey: d, review: f }) {
2608
2629
  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);
2609
2630
  r(() => {
2610
2631
  if (!m || !t) return;
2611
2632
  let e = t, r = !1;
2612
2633
  return _(!0), Promise.allSettled([
2613
2634
  p.documentBacklinks(e, n, i),
2614
- p.documentRelated(e, n, i, Dt),
2615
- p.documentUnlinkedMentions(e, n, i, Ot)
2635
+ p.documentRelated(e, n, i, At),
2636
+ p.documentUnlinkedMentions(e, n, i, jt)
2616
2637
  ]).then(([t, n, i]) => {
2617
2638
  if (!r) {
2618
2639
  if (x(t.status === "fulfilled" ? t.value.backlinks ?? [] : []), n.status === "fulfilled") C(n.value.related ?? []), T(null);
2619
2640
  else {
2620
2641
  C([]);
2621
2642
  let e = n.reason instanceof Error ? n.reason.message : String(n.reason);
2622
- T(kt(e) ? "semantic search not configured" : e);
2643
+ T(Mt(e) ? "semantic search not configured" : e);
2623
2644
  }
2624
2645
  i.status === "fulfilled" ? (D(i.value.unlinked_mentions ?? []), k(!!i.value.truncated)) : (D([]), k(!1)), y(e), _(!1);
2625
2646
  }
@@ -2634,7 +2655,7 @@ function At({ documentId: e, selectedId: t, scope: n, browse: i, onSelectChunk:
2634
2655
  i,
2635
2656
  d
2636
2657
  ]);
2637
- let A = (t, n, r) => /* @__PURE__ */ l(xt, {
2658
+ let A = (t, n, r) => /* @__PURE__ */ l(wt, {
2638
2659
  id: t,
2639
2660
  title: n,
2640
2661
  targetDocumentId: r,
@@ -2651,7 +2672,7 @@ function At({ documentId: e, selectedId: t, scope: n, browse: i, onSelectChunk:
2651
2672
  children: [m ? "▼" : "▶", " Connections"]
2652
2673
  }), m && /* @__PURE__ */ u("div", {
2653
2674
  className: "doc-conn-body",
2654
- children: [f && /* @__PURE__ */ l(Tt, {
2675
+ children: [f && /* @__PURE__ */ l(Ot, {
2655
2676
  documentId: e,
2656
2677
  proposals: f.proposals,
2657
2678
  incomplete: f.incomplete,
@@ -2681,7 +2702,7 @@ function At({ documentId: e, selectedId: t, scope: n, browse: i, onSelectChunk:
2681
2702
  title: "Auto-linked from a [[wikilink]]",
2682
2703
  children: "auto"
2683
2704
  }),
2684
- /* @__PURE__ */ l(St, { statement: e })
2705
+ /* @__PURE__ */ l(Tt, { statement: e })
2685
2706
  ]
2686
2707
  }, `${e.from_id}-${e.kind}-${t}`))
2687
2708
  })]
@@ -2735,11 +2756,11 @@ function At({ documentId: e, selectedId: t, scope: n, browse: i, onSelectChunk:
2735
2756
  }
2736
2757
  //#endregion
2737
2758
  //#region src/components/CrossReferences.tsx
2738
- var jt = 24;
2739
- function Mt({ edges: e, documentId: t, selectedId: n, onSelectChunk: r, onOpenDocument: i, onRuleStatement: a, incomplete: s }) {
2759
+ var Pt = 24;
2760
+ function Ft({ edges: e, documentId: t, selectedId: n, onSelectChunk: r, onOpenDocument: i, onRuleStatement: a, incomplete: s }) {
2740
2761
  let [d, f] = o(!1), [p, m] = o(!1);
2741
2762
  if (e.length === 0) return null;
2742
- let h = n ? e.filter((e) => e.from_id === n || e.to_id === n) : [], g = p ? e : e.slice(0, jt), _ = Pt(g);
2763
+ let h = n ? e.filter((e) => e.from_id === n || e.to_id === n) : [], g = p ? e : e.slice(0, Pt), _ = Lt(g);
2743
2764
  return /* @__PURE__ */ u("div", {
2744
2765
  className: "doc-refs",
2745
2766
  children: [
@@ -2758,7 +2779,7 @@ function Mt({ edges: e, documentId: t, selectedId: n, onSelectChunk: r, onOpenDo
2758
2779
  children: "This chunk has no links."
2759
2780
  }) : /* @__PURE__ */ l("ul", {
2760
2781
  className: "doc-refs-list",
2761
- children: h.map((e, o) => /* @__PURE__ */ l(Nt, {
2782
+ children: h.map((e, o) => /* @__PURE__ */ l(It, {
2762
2783
  edge: e,
2763
2784
  selectedId: n,
2764
2785
  documentId: t,
@@ -2780,23 +2801,23 @@ function Mt({ edges: e, documentId: t, selectedId: n, onSelectChunk: r, onOpenDo
2780
2801
  e.length,
2781
2802
  ")"
2782
2803
  ]
2783
- }), d && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(et, {
2804
+ }), d && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(rt, {
2784
2805
  code: _,
2785
2806
  onNodeClick: (e) => {
2786
- let n = Ft(g, e);
2807
+ let n = Rt(g, e);
2787
2808
  n && (!n.documentId || n.documentId === t ? r(n.id) : i?.(n.documentId, n.id, n.title));
2788
2809
  }
2789
- }), e.length > jt && /* @__PURE__ */ l("button", {
2810
+ }), e.length > Pt && /* @__PURE__ */ l("button", {
2790
2811
  type: "button",
2791
2812
  className: "doc-graph-more",
2792
2813
  onClick: () => m((e) => !e),
2793
- children: p ? `show top ${jt}` : `show all ${e.length}`
2814
+ children: p ? `show top ${Pt}` : `show all ${e.length}`
2794
2815
  })] })]
2795
2816
  })
2796
2817
  ]
2797
2818
  });
2798
2819
  }
2799
- function Nt({ edge: e, selectedId: t, documentId: n, onSelectChunk: r, onOpenDocument: i, onRuleStatement: a }) {
2820
+ function It({ edge: e, selectedId: t, documentId: n, onSelectChunk: r, onOpenDocument: i, onRuleStatement: a }) {
2800
2821
  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;
2801
2822
  return /* @__PURE__ */ u("li", {
2802
2823
  className: "doc-ref",
@@ -2810,7 +2831,7 @@ function Nt({ edge: e, selectedId: t, documentId: n, onSelectChunk: r, onOpenDoc
2810
2831
  "aria-hidden": !0,
2811
2832
  children: o ? "→" : "←"
2812
2833
  }),
2813
- /* @__PURE__ */ l(xt, {
2834
+ /* @__PURE__ */ l(wt, {
2814
2835
  id: s,
2815
2836
  title: c,
2816
2837
  targetDocumentId: d,
@@ -2818,46 +2839,113 @@ function Nt({ edge: e, selectedId: t, documentId: n, onSelectChunk: r, onOpenDoc
2818
2839
  onSelectChunk: r,
2819
2840
  onOpenDocument: i
2820
2841
  }),
2821
- /* @__PURE__ */ l(St, { statement: e }),
2822
- a && q(e) && /* @__PURE__ */ l(Ct, {
2842
+ /* @__PURE__ */ l(Tt, { statement: e }),
2843
+ a && q(e) && /* @__PURE__ */ l(Et, {
2823
2844
  id: e.id,
2824
2845
  onRule: a
2825
2846
  })
2826
2847
  ]
2827
2848
  });
2828
2849
  }
2829
- function Pt(e) {
2850
+ function Lt(e) {
2830
2851
  let t = ["graph LR"];
2831
2852
  for (let n of e) {
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" ? "-.->" : "-->";
2853
+ let e = `${zt(n.from_id)}["${Bt(n.from_title, n.from_id)}"]`, r = `${zt(n.to_id)}["${Bt(n.to_title, n.to_id)}"]`, i = (n.kind || "link").replace(/[|"]/g, " "), a = n.status === "proposed" ? "-.->" : "-->";
2833
2854
  t.push(` ${e} ${a}|${i}| ${r}`);
2834
2855
  }
2835
2856
  return t.join("\n");
2836
2857
  }
2837
- function Ft(e, t) {
2858
+ function Rt(e, t) {
2838
2859
  for (let n of e) {
2839
- if (It(n.from_id) === t) return {
2860
+ if (zt(n.from_id) === t) return {
2840
2861
  id: n.from_id,
2841
2862
  documentId: n.from_document_id,
2842
2863
  title: n.from_title
2843
2864
  };
2844
- if (It(n.to_id) === t) return {
2865
+ if (zt(n.to_id) === t) return {
2845
2866
  id: n.to_id,
2846
2867
  documentId: n.to_document_id,
2847
2868
  title: n.to_title
2848
2869
  };
2849
2870
  }
2850
2871
  }
2851
- function It(e) {
2872
+ function zt(e) {
2852
2873
  return "n" + e.replace(/[^a-zA-Z0-9]/g, "");
2853
2874
  }
2854
- function Lt(e, t) {
2875
+ function Bt(e, t) {
2855
2876
  let n = (e ?? "").replace(/["[\]{}|<>]/g, " ").replace(/\s+/g, " ").trim() || t.slice(0, 6);
2856
2877
  return n.length > 30 ? n.slice(0, 29) + "…" : n;
2857
2878
  }
2858
2879
  //#endregion
2880
+ //#region src/components/StackSplitter.tsx
2881
+ var Vt = 6;
2882
+ function Ht(e, t, n, r) {
2883
+ let i = Math.max(r, t - n - Vt);
2884
+ return Math.round(Math.max(r, Math.min(e, i)));
2885
+ }
2886
+ function Ut({ children: e, defaultBottomHeight: n = 240, minTopHeight: i = 96, minBottomHeight: s = 48, storageKey: c, className: d }) {
2887
+ let [f, p] = o(() => {
2888
+ if (c) try {
2889
+ let e = parseInt(localStorage.getItem(c) ?? "", 10);
2890
+ if (Number.isFinite(e) && e >= s) return e;
2891
+ } catch {}
2892
+ return n;
2893
+ }), m = a(null), [h, g] = o(!1);
2894
+ r(() => {
2895
+ if (c && !h) try {
2896
+ localStorage.setItem(c, String(f));
2897
+ } catch {}
2898
+ }, [
2899
+ c,
2900
+ f,
2901
+ h
2902
+ ]);
2903
+ let _ = t((e) => {
2904
+ e.preventDefault(), g(!0), e.target.setPointerCapture(e.pointerId);
2905
+ }, []), v = t((e) => {
2906
+ if (!h || !m.current) return;
2907
+ let t = m.current.getBoundingClientRect();
2908
+ p(Ht(t.bottom - e.clientY, t.height, i, s));
2909
+ }, [
2910
+ h,
2911
+ i,
2912
+ s
2913
+ ]), y = t((e) => {
2914
+ g(!1);
2915
+ try {
2916
+ e.target.releasePointerCapture(e.pointerId);
2917
+ } catch {}
2918
+ }, []);
2919
+ return /* @__PURE__ */ u("div", {
2920
+ ref: m,
2921
+ className: `stack-splitter ${d ?? ""} ${h ? "dragging" : ""}`,
2922
+ style: { gridTemplateRows: `minmax(${i}px, 1fr) ${Vt}px min(${f}px, calc(100% - ${i + Vt}px))` },
2923
+ children: [
2924
+ /* @__PURE__ */ l("div", {
2925
+ className: "stack-splitter-pane stack-splitter-top",
2926
+ children: e[0]
2927
+ }),
2928
+ /* @__PURE__ */ l("div", {
2929
+ className: "stack-splitter-handle",
2930
+ role: "separator",
2931
+ "aria-orientation": "horizontal",
2932
+ "aria-valuenow": f,
2933
+ title: "Drag to share the space between the text and its links",
2934
+ onPointerDown: _,
2935
+ onPointerMove: v,
2936
+ onPointerUp: y,
2937
+ onPointerCancel: y
2938
+ }),
2939
+ /* @__PURE__ */ l("div", {
2940
+ className: "stack-splitter-pane stack-splitter-bottom",
2941
+ children: e[1]
2942
+ })
2943
+ ]
2944
+ });
2945
+ }
2946
+ //#endregion
2859
2947
  //#region src/components/DocUnavailable.tsx
2860
- function Rt({ documentId: e, scope: t, detail: n }) {
2948
+ function Wt({ documentId: e, scope: t, detail: n }) {
2861
2949
  return /* @__PURE__ */ u("div", {
2862
2950
  className: "doc-unavailable",
2863
2951
  role: "alert",
@@ -2880,11 +2968,11 @@ function Rt({ documentId: e, scope: t, detail: n }) {
2880
2968
  }
2881
2969
  //#endregion
2882
2970
  //#region src/components/HistoryModal.tsx
2883
- function zt(e) {
2971
+ function Gt(e) {
2884
2972
  let t = typeof e == "number" ? e / 1e6 : Date.parse(String(e));
2885
2973
  return !Number.isFinite(t) || t <= 0 ? String(e ?? "") : new Date(t).toLocaleString();
2886
2974
  }
2887
- function Bt({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
2975
+ function Kt({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
2888
2976
  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("");
2889
2977
  r(() => {
2890
2978
  let t = !1;
@@ -2969,7 +3057,7 @@ function Bt({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
2969
3057
  }),
2970
3058
  /* @__PURE__ */ l("span", {
2971
3059
  className: "doc-hist-rev-time",
2972
- children: zt(e.created_at)
3060
+ children: Gt(e.created_at)
2973
3061
  }),
2974
3062
  /* @__PURE__ */ l("span", {
2975
3063
  className: "doc-hist-rev-actor",
@@ -3017,7 +3105,7 @@ function Bt({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
3017
3105
  children: C ? /* @__PURE__ */ l("p", {
3018
3106
  className: "doc-empty-body",
3019
3107
  children: "loading…"
3020
- }) : _ === "diff" ? /* @__PURE__ */ l(Vt, { text: k }) : _ === "version" ? /* @__PURE__ */ l("pre", {
3108
+ }) : _ === "diff" ? /* @__PURE__ */ l(qt, { text: k }) : _ === "version" ? /* @__PURE__ */ l("pre", {
3021
3109
  className: "md-pre doc-hist-version",
3022
3110
  children: /* @__PURE__ */ l("code", { children: x || "(empty)" })
3023
3111
  }) : /* @__PURE__ */ l("p", {
@@ -3030,7 +3118,7 @@ function Bt({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
3030
3118
  })
3031
3119
  });
3032
3120
  }
3033
- function Vt({ text: e }) {
3121
+ function qt({ text: e }) {
3034
3122
  if (!e.trim()) return /* @__PURE__ */ l("p", {
3035
3123
  className: "doc-empty-body",
3036
3124
  children: "(no differences)"
@@ -3049,17 +3137,17 @@ function Vt({ text: e }) {
3049
3137
  }
3050
3138
  //#endregion
3051
3139
  //#region src/components/Markdown.tsx
3052
- function Ht({ source: e }) {
3140
+ function Jt({ source: e }) {
3053
3141
  return /* @__PURE__ */ l("div", {
3054
3142
  className: "md",
3055
3143
  children: /* @__PURE__ */ l(f, {
3056
3144
  remarkPlugins: [p],
3057
- components: Ut,
3145
+ components: Yt,
3058
3146
  children: e
3059
3147
  })
3060
3148
  });
3061
3149
  }
3062
- var Ut = {
3150
+ var Yt = {
3063
3151
  a({ href: e, children: t }) {
3064
3152
  let n = e ?? "", r = /^https?:\/\//i.test(n);
3065
3153
  return /* @__PURE__ */ l("a", {
@@ -3074,7 +3162,7 @@ var Ut = {
3074
3162
  },
3075
3163
  code({ className: e, children: t }) {
3076
3164
  let n = /language-(\w+)/.exec(e ?? "")?.[1], r = String(t ?? "");
3077
- return n === "mermaid" ? /* @__PURE__ */ l(et, { code: r.replace(/\n$/, "") }) : n || r.includes("\n") ? /* @__PURE__ */ l("pre", {
3165
+ return n === "mermaid" ? /* @__PURE__ */ l(rt, { code: r.replace(/\n$/, "") }) : n || r.includes("\n") ? /* @__PURE__ */ l("pre", {
3078
3166
  className: "md-pre",
3079
3167
  children: /* @__PURE__ */ l("code", {
3080
3168
  className: e,
@@ -3085,11 +3173,11 @@ var Ut = {
3085
3173
  };
3086
3174
  //#endregion
3087
3175
  //#region src/components/DocumentViewerBody.tsx
3088
- function Wt(e) {
3176
+ function Xt(e) {
3089
3177
  let t = e.fields ?? {};
3090
3178
  return typeof t.alt == "string" && t.alt.trim() !== "" ? t.alt : e.title || "image";
3091
3179
  }
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 }) {
3180
+ function Zt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, renderAssistant: p, initialChunkId: m, onOpenDocument: h, onTitle: g, onChunkSelect: v, focusChunk: y }) {
3093
3181
  let b = M(), x = i(() => d && (d.scopeId || d.tenant) ? {
3094
3182
  scopeId: d.scopeId,
3095
3183
  tenant: d.tenant
@@ -3097,20 +3185,20 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3097
3185
  Ae.current = m;
3098
3186
  let je = a(g);
3099
3187
  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(() => {
3188
+ let Me = i(() => Ye(S), [S]), Ne = i(() => S.find((e) => !e.parent_id)?.title || s || "document", [S, s]), Y = i(() => !!E && !E.parent_id, [E]), Pe = i(() => xe(S, E?.id), [S, E]), X = i(() => W?.root_chunk_id ?? S.find((e) => !e.parent_id)?.id, [W, S]), Re = a(v);
3189
+ Re.current = v, r(() => {
3190
+ w && Re.current?.(w === X ? void 0 : w);
3191
+ }, [w, X]);
3192
+ let ze = i(() => [...new Set(S.map((e) => e.status).filter((e) => !!e))], [S]), Z = !!W?.color_enabled, Q = i(() => {
3105
3193
  let e = /* @__PURE__ */ new Set();
3106
3194
  for (let t of K) e.add(t.from_id), e.add(t.to_id);
3107
3195
  return e;
3108
- }, [K]), He = i(() => Q ? We(Ve(W?.type, W?.status, Be(W?.color_scheme))) : void 0, [
3109
- Q,
3196
+ }, [K]), He = i(() => Z ? Ve(W?.type, W?.status, Be(W?.color_scheme)) : void 0, [
3197
+ Z,
3110
3198
  W?.type,
3111
3199
  W?.status,
3112
3200
  W?.color_scheme
3113
- ]);
3201
+ ]), Ue = i(() => Ge(He), [He]);
3114
3202
  r(() => {
3115
3203
  let t = !1;
3116
3204
  return le(!0), z(null), V(null), b.documentQueryChunks(e, n, x).then((r) => {
@@ -3129,10 +3217,10 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3129
3217
  fe,
3130
3218
  x
3131
3219
  ]);
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]);
3220
+ let We = !ce && (de !== null || ue === `${n}:${e}` && S.length === 0), Ke = i(() => S.find((t) => !t.parent_id && t.document_id === e)?.title, [S, e]);
3133
3221
  r(() => {
3134
- Ge && je.current?.(e, Ge);
3135
- }, [e, Ge]), r(() => {
3222
+ Ke && je.current?.(e, Ke);
3223
+ }, [e, Ke]), r(() => {
3136
3224
  let t = !1;
3137
3225
  return b.documentGet(e, n, x).then((e) => !t && ge(e)).catch(() => !t && ge(null)), () => {
3138
3226
  t = !0;
@@ -3160,23 +3248,23 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3160
3248
  x,
3161
3249
  q
3162
3250
  ]), r(() => {
3163
- if (!Z || !b.documentAcceptClassification) {
3251
+ if (!X || !b.documentAcceptClassification) {
3164
3252
  ke(void 0);
3165
3253
  return;
3166
3254
  }
3167
3255
  let t = !1;
3168
- return b.documentGetChunk(Z, n, x).then((n) => !t && ke(n.document_id === e ? n.fields : void 0)).catch(() => !t && ke(void 0)), () => {
3256
+ return b.documentGetChunk(X, n, x).then((n) => !t && ke(n.document_id === e ? n.fields : void 0)).catch(() => !t && ke(void 0)), () => {
3169
3257
  t = !0;
3170
3258
  };
3171
3259
  }, [
3172
3260
  b,
3173
3261
  e,
3174
- Z,
3262
+ X,
3175
3263
  n,
3176
3264
  fe,
3177
3265
  x
3178
3266
  ]);
3179
- let Je = i(() => {
3267
+ let qe = i(() => {
3180
3268
  if (b.documentAcceptStatement && b.documentRejectStatement) return async (e, t, r) => {
3181
3269
  t ? await b.documentAcceptStatement(e, n, x, r) : await b.documentRejectStatement(e, r ?? "", n, x), Te((e) => e + 1);
3182
3270
  };
@@ -3184,19 +3272,21 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3184
3272
  b,
3185
3273
  n,
3186
3274
  x
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), [
3275
+ ]), $ = i(() => Fe(b, n), [b, n]), Xe = i(() => Ie(K, e), [K, e]), $e = t(() => Te((e) => e + 1), []), et = i(() => Le($, Xe, Ce, $e), [
3276
+ $,
3188
3277
  Xe,
3189
- Ze,
3190
3278
  Ce,
3191
- Qe
3192
- ]), rt = y?.seq, it = a(y);
3193
- it.current = y;
3194
- let at = a(Z);
3195
- at.current = Z, r(() => {
3196
- if (rt === void 0) return;
3197
- let e = it.current?.chunkId ?? at.current;
3198
- e && T(e);
3199
- }, [rt]), r(() => {
3279
+ $e
3280
+ ]), tt = y?.seq, nt = a(y);
3281
+ nt.current = y;
3282
+ let ot = a(X);
3283
+ ot.current = X;
3284
+ let st = a(S);
3285
+ st.current = S, r(() => {
3286
+ if (tt === void 0) return;
3287
+ let e = nt.current?.chunkId, t = st.current.length > 0 ? U(st.current, e) : e ?? ot.current;
3288
+ t && T(t);
3289
+ }, [tt]), r(() => {
3200
3290
  T(void 0), D(null), j(null), k("chunks"), ge(null), Se([]), we(!1), De(0), ke(void 0);
3201
3291
  }, [e, n]), r(() => {
3202
3292
  if (!w) {
@@ -3235,7 +3325,7 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3235
3325
  j(null);
3236
3326
  return;
3237
3327
  }
3238
- let e = $(Me, w);
3328
+ let e = Ze(Me, w);
3239
3329
  if (!e) return;
3240
3330
  let t = !1, r = [], i = (e, t) => {
3241
3331
  r.push({
@@ -3267,7 +3357,7 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3267
3357
  fe,
3268
3358
  x
3269
3359
  ]);
3270
- let ot = t((e) => T(e.row.id), []), st = t((t, n, r) => h?.({
3360
+ let ct = t((e) => T(e.row.id), []), lt = t((t, n, r) => h?.({
3271
3361
  documentId: t,
3272
3362
  chunkId: n,
3273
3363
  title: r
@@ -3280,7 +3370,7 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3280
3370
  e,
3281
3371
  w,
3282
3372
  Ne
3283
- ]), ct = t(async () => {
3373
+ ]), ut = t(async () => {
3284
3374
  try {
3285
3375
  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");
3286
3376
  a.href = i, a.download = (t.title || "document").replace(/[^\w.-]+/g, "_") + ".md", a.click(), URL.revokeObjectURL(i);
@@ -3292,7 +3382,7 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3292
3382
  e,
3293
3383
  n,
3294
3384
  x
3295
- ]), lt = t(async () => {
3385
+ ]), dt = t(async () => {
3296
3386
  try {
3297
3387
  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");
3298
3388
  a.href = i, a.download = (Ne || "document").replace(/[^\w.-]+/g, "_") + ".canvas", a.click(), URL.revokeObjectURL(i);
@@ -3305,9 +3395,9 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3305
3395
  n,
3306
3396
  x,
3307
3397
  Ne
3308
- ]), ut = !!b.documentCreateChunk && !!Z, dt = t(async (t) => {
3398
+ ]), ft = !!b.documentCreateChunk && !!X, pt = t(async (t) => {
3309
3399
  if (!b.documentCreateChunk || !b.documentSetAsset) return;
3310
- let r = w || Z;
3400
+ let r = w || X;
3311
3401
  if (r) {
3312
3402
  z(null);
3313
3403
  try {
@@ -3326,11 +3416,11 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3326
3416
  n,
3327
3417
  x,
3328
3418
  w,
3329
- Z,
3419
+ X,
3330
3420
  J
3331
- ]), ft = t(async () => {
3421
+ ]), mt = t(async () => {
3332
3422
  if (!b.documentCreateChunk) return;
3333
- let t = w || Z;
3423
+ let t = w || X;
3334
3424
  if (t) {
3335
3425
  z(null);
3336
3426
  try {
@@ -3350,11 +3440,11 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3350
3440
  n,
3351
3441
  x,
3352
3442
  w,
3353
- Z,
3443
+ X,
3354
3444
  J
3355
- ]), pt = t(async () => {
3445
+ ]), ht = t(async () => {
3356
3446
  if (!b.documentCreateChunk) return;
3357
- let t = w && !Y ? w : void 0, r = w || Z;
3447
+ let t = w && !Y ? w : void 0, r = w || X;
3358
3448
  if (r) {
3359
3449
  z(null);
3360
3450
  try {
@@ -3374,9 +3464,9 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3374
3464
  x,
3375
3465
  w,
3376
3466
  Y,
3377
- Z,
3467
+ X,
3378
3468
  J
3379
- ]), mt = t(async () => {
3469
+ ]), gt = t(async () => {
3380
3470
  if (b.documentCreateChunk && w) {
3381
3471
  z(null);
3382
3472
  try {
@@ -3396,7 +3486,7 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3396
3486
  x,
3397
3487
  w,
3398
3488
  J
3399
- ]), ht = i(() => {
3489
+ ]), _t = i(() => {
3400
3490
  if (!E || Y) return {
3401
3491
  canUp: !1,
3402
3492
  canDown: !1
@@ -3410,7 +3500,7 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3410
3500
  S,
3411
3501
  E,
3412
3502
  Y
3413
- ]), _t = t(async (e) => {
3503
+ ]), vt = t(async (e) => {
3414
3504
  if (b.documentReorderChunk && w) {
3415
3505
  z(null);
3416
3506
  try {
@@ -3425,12 +3515,12 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3425
3515
  n,
3426
3516
  x,
3427
3517
  J
3428
- ]), vt = t(async () => {
3518
+ ]), bt = t(async () => {
3429
3519
  if (!b.documentDeleteChunk || !E) return;
3430
3520
  z(null);
3431
3521
  let e = E.parent_id;
3432
3522
  try {
3433
- await b.documentDeleteChunk(E.id, n, x), se(!1), T(e || Z), J();
3523
+ await b.documentDeleteChunk(E.id, n, x), se(!1), T(e || X), J();
3434
3524
  } catch (e) {
3435
3525
  z(e instanceof Error ? e.message : String(e)), se(!1);
3436
3526
  }
@@ -3439,24 +3529,24 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3439
3529
  E,
3440
3530
  n,
3441
3531
  x,
3442
- Z,
3532
+ X,
3443
3533
  J
3444
3534
  ]);
3445
3535
  return r(() => {
3446
- if (!ut) return;
3536
+ if (!ft) return;
3447
3537
  let e = (e) => {
3448
3538
  if (ne || G) return;
3449
3539
  let t = document.activeElement, n = t?.tagName;
3450
3540
  if (n === "INPUT" || n === "TEXTAREA" || t?.isContentEditable) return;
3451
3541
  let r = ve(e.clipboardData?.items);
3452
- r && (e.preventDefault(), dt(r));
3542
+ r && (e.preventDefault(), pt(r));
3453
3543
  };
3454
3544
  return window.addEventListener("paste", e), () => window.removeEventListener("paste", e);
3455
3545
  }, [
3456
- ut,
3546
+ ft,
3457
3547
  ne,
3458
3548
  G,
3459
- dt
3549
+ pt
3460
3550
  ]), /* @__PURE__ */ u("div", {
3461
3551
  className: "doc-viewer",
3462
3552
  children: [
@@ -3467,35 +3557,35 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3467
3557
  style: { display: "none" },
3468
3558
  onChange: (e) => {
3469
3559
  let t = e.target.files?.[0];
3470
- e.target.value = "", t && dt(t);
3560
+ e.target.value = "", t && pt(t);
3471
3561
  }
3472
3562
  }),
3473
3563
  /* @__PURE__ */ u("div", {
3474
3564
  className: "doc-toolbar",
3475
- style: He,
3565
+ style: Ue,
3476
3566
  children: [
3477
3567
  /* @__PURE__ */ l("strong", {
3478
3568
  className: "doc-title",
3479
3569
  title: Ne,
3480
3570
  children: Ne
3481
3571
  }),
3482
- /* @__PURE__ */ l(Ke, {
3572
+ /* @__PURE__ */ l(Je, {
3483
3573
  value: e,
3484
3574
  label: "doc"
3485
3575
  }),
3486
3576
  /* @__PURE__ */ u("div", {
3487
3577
  className: "doc-toolbar-actions",
3488
3578
  children: [
3489
- ut && /* @__PURE__ */ u(c, { children: [
3579
+ ft && /* @__PURE__ */ u(c, { children: [
3490
3580
  /* @__PURE__ */ l("button", {
3491
3581
  type: "button",
3492
- onClick: () => void pt(),
3582
+ onClick: () => void ht(),
3493
3583
  title: "Add a text chunk AFTER the selected chunk, at the same level",
3494
3584
  children: "+ text"
3495
3585
  }),
3496
3586
  /* @__PURE__ */ l("button", {
3497
3587
  type: "button",
3498
- onClick: () => void mt(),
3588
+ onClick: () => void gt(),
3499
3589
  disabled: !w,
3500
3590
  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",
3501
3591
  children: "+ child"
@@ -3508,16 +3598,16 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3508
3598
  }),
3509
3599
  /* @__PURE__ */ l("button", {
3510
3600
  type: "button",
3511
- onClick: () => void ft(),
3601
+ onClick: () => void mt(),
3512
3602
  title: "Add a Mermaid diagram chunk",
3513
3603
  children: "+ diagram"
3514
3604
  })
3515
3605
  ] }),
3516
3606
  /* @__PURE__ */ l("button", {
3517
3607
  type: "button",
3518
- className: Q ? "active" : "",
3608
+ className: Z ? "active" : "",
3519
3609
  onClick: () => ye(!0),
3520
- disabled: !Z,
3610
+ disabled: !X,
3521
3611
  title: "Colors — tint chunk tiles + the Path tree by type/status",
3522
3612
  children: "colors"
3523
3613
  }),
@@ -3530,13 +3620,13 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3530
3620
  }),
3531
3621
  /* @__PURE__ */ l("button", {
3532
3622
  type: "button",
3533
- onClick: () => void ct(),
3623
+ onClick: () => void ut(),
3534
3624
  title: "Download the whole document as Markdown (.md)",
3535
3625
  children: "↓ .md"
3536
3626
  }),
3537
3627
  /* @__PURE__ */ l("button", {
3538
3628
  type: "button",
3539
- onClick: () => void lt(),
3629
+ onClick: () => void dt(),
3540
3630
  title: "Download the whole document as a node/edge canvas graph (.canvas)",
3541
3631
  children: "↓ .canvas"
3542
3632
  }),
@@ -3561,7 +3651,7 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3561
3651
  className: "paths-err",
3562
3652
  children: R
3563
3653
  }),
3564
- !Ue && /* @__PURE__ */ l(gt, {
3654
+ !We && /* @__PURE__ */ l(yt, {
3565
3655
  documentId: e,
3566
3656
  scope: n,
3567
3657
  browse: x,
@@ -3570,7 +3660,7 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3570
3660
  onClose: () => De(0),
3571
3661
  onChanged: J
3572
3662
  }, `${n}:${e}`),
3573
- Ue ? /* @__PURE__ */ l(Rt, {
3663
+ We ? /* @__PURE__ */ l(Wt, {
3574
3664
  documentId: e,
3575
3665
  scope: n,
3576
3666
  detail: de ?? void 0
@@ -3585,141 +3675,143 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3585
3675
  children: ce && S.length === 0 ? /* @__PURE__ */ l("div", {
3586
3676
  className: "empty",
3587
3677
  children: /* @__PURE__ */ l("p", { children: "Loading…" })
3588
- }) : /* @__PURE__ */ l(Ye, {
3678
+ }) : /* @__PURE__ */ l(Qe, {
3589
3679
  tree: Me,
3590
3680
  selectedId: w,
3591
- onSelect: ot,
3592
- colorEnabled: Q,
3681
+ onSelect: ct,
3682
+ colorEnabled: Z,
3593
3683
  scheme: W?.color_scheme,
3594
- linkedIds: ze
3684
+ documentColor: He,
3685
+ linkedIds: Q
3595
3686
  })
3596
3687
  }), /* @__PURE__ */ l("div", {
3597
3688
  className: "doc-content",
3598
- children: E ? /* @__PURE__ */ u(c, { children: [
3599
- /* @__PURE__ */ u("div", {
3600
- className: "doc-content-head",
3601
- children: [
3602
- X.length > 0 && /* @__PURE__ */ u("nav", {
3603
- className: "chunk-ancestry",
3604
- "aria-label": "Chunks above this one",
3605
- children: [/* @__PURE__ */ l("button", {
3606
- type: "button",
3607
- className: "chunk-ancestry-up",
3608
- onClick: () => T(X[X.length - 1].id),
3609
- title: `Up to ${X[X.length - 1].title || "(untitled)"}`,
3610
- children: "↰ Up"
3611
- }), /* @__PURE__ */ u("ol", {
3612
- className: "doc-trail-list",
3613
- children: [X.map((e) => /* @__PURE__ */ l("li", {
3614
- className: "doc-trail-item",
3615
- children: /* @__PURE__ */ l("button", {
3616
- type: "button",
3617
- className: "doc-trail-crumb",
3618
- onClick: () => T(e.id),
3619
- title: e.title || "(untitled)",
3620
- children: e.title || "(untitled)"
3621
- })
3622
- }, e.id)), /* @__PURE__ */ l("li", {
3623
- className: "doc-trail-item",
3624
- children: /* @__PURE__ */ l("span", {
3625
- className: "doc-trail-current",
3626
- "aria-current": "location",
3627
- title: E.title || "(untitled)",
3628
- children: E.title || "(untitled)"
3629
- })
3630
- })]
3631
- })]
3632
- }),
3633
- /* @__PURE__ */ l("h3", { children: E.title || "(untitled)" }),
3634
- /* @__PURE__ */ u("div", {
3635
- className: "doc-content-meta",
3636
- children: [
3637
- E.type && /* @__PURE__ */ l("span", {
3638
- className: "chunk-badge",
3639
- children: E.type
3640
- }),
3641
- E.status && /* @__PURE__ */ l("span", {
3642
- className: "chunk-badge chunk-status",
3643
- children: E.status
3644
- }),
3645
- /* @__PURE__ */ u("span", {
3646
- className: "chunk-rev",
3647
- children: ["rev ", E.revision]
3648
- }),
3649
- E.tags?.map((e) => /* @__PURE__ */ l("span", {
3650
- className: "chunk-tag",
3651
- children: e
3652
- }, e)),
3653
- /* @__PURE__ */ l(Ke, {
3654
- value: E.id,
3655
- label: "chunk"
3656
- })
3657
- ]
3658
- }),
3659
- /* @__PURE__ */ u("div", {
3660
- className: "doc-content-controls",
3661
- children: [
3662
- /* @__PURE__ */ u("div", {
3663
- className: "doc-mode-toggle",
3664
- children: [/* @__PURE__ */ l("button", {
3665
- type: "button",
3666
- className: O === "chunks" ? "active" : "",
3667
- onClick: () => k("chunks"),
3668
- title: "This chunk's own content",
3669
- children: "chunk"
3670
- }), /* @__PURE__ */ l("button", {
3671
- type: "button",
3672
- className: O === "markdown" ? "active" : "",
3673
- onClick: () => k("markdown"),
3674
- title: Y ? "Whole document as Markdown" : "This chunk + its sub-chunks as Markdown",
3675
- children: "markdown"
3676
- })]
3677
- }),
3678
- /* @__PURE__ */ l("button", {
3679
- type: "button",
3680
- className: "chunk-edit",
3681
- onClick: () => re(E),
3682
- children: "edit"
3683
- }),
3684
- b.documentEntityTypes && _(E) && /* @__PURE__ */ l("button", {
3685
- type: "button",
3686
- onClick: () => ae(E),
3687
- title: "Change this subject's type to another type in force",
3688
- children: "change type"
3689
- }),
3690
- /* @__PURE__ */ l("button", {
3689
+ children: E ? /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ u("div", {
3690
+ className: "doc-content-head",
3691
+ children: [
3692
+ Pe.length > 0 && /* @__PURE__ */ u("nav", {
3693
+ className: "chunk-ancestry",
3694
+ "aria-label": "Chunks above this one",
3695
+ children: [/* @__PURE__ */ l("button", {
3696
+ type: "button",
3697
+ className: "chunk-ancestry-up",
3698
+ onClick: () => T(Pe[Pe.length - 1].id),
3699
+ title: `Up to ${Pe[Pe.length - 1].title || "(untitled)"}`,
3700
+ children: "↰ Up"
3701
+ }), /* @__PURE__ */ u("ol", {
3702
+ className: "doc-trail-list",
3703
+ children: [Pe.map((e) => /* @__PURE__ */ l("li", {
3704
+ className: "doc-trail-item",
3705
+ children: /* @__PURE__ */ l("button", {
3691
3706
  type: "button",
3692
- onClick: () => L(!0),
3693
- title: "View this chunk's edit history + diffs",
3694
- children: "history"
3695
- }),
3696
- !Y && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("button", {
3707
+ className: "doc-trail-crumb",
3708
+ onClick: () => T(e.id),
3709
+ title: e.title || "(untitled)",
3710
+ children: e.title || "(untitled)"
3711
+ })
3712
+ }, e.id)), /* @__PURE__ */ l("li", {
3713
+ className: "doc-trail-item",
3714
+ children: /* @__PURE__ */ l("span", {
3715
+ className: "doc-trail-current",
3716
+ "aria-current": "location",
3717
+ title: E.title || "(untitled)",
3718
+ children: E.title || "(untitled)"
3719
+ })
3720
+ })]
3721
+ })]
3722
+ }),
3723
+ /* @__PURE__ */ l("h3", { children: E.title || "(untitled)" }),
3724
+ /* @__PURE__ */ u("div", {
3725
+ className: "doc-content-meta",
3726
+ children: [
3727
+ E.type && /* @__PURE__ */ l("span", {
3728
+ className: "chunk-badge",
3729
+ children: E.type
3730
+ }),
3731
+ E.status && /* @__PURE__ */ l("span", {
3732
+ className: "chunk-badge chunk-status",
3733
+ children: E.status
3734
+ }),
3735
+ /* @__PURE__ */ u("span", {
3736
+ className: "chunk-rev",
3737
+ children: ["rev ", E.revision]
3738
+ }),
3739
+ E.tags?.map((e) => /* @__PURE__ */ l("span", {
3740
+ className: "chunk-tag",
3741
+ children: e
3742
+ }, e)),
3743
+ /* @__PURE__ */ l(Je, {
3744
+ value: E.id,
3745
+ label: "chunk"
3746
+ })
3747
+ ]
3748
+ }),
3749
+ /* @__PURE__ */ u("div", {
3750
+ className: "doc-content-controls",
3751
+ children: [
3752
+ /* @__PURE__ */ u("div", {
3753
+ className: "doc-mode-toggle",
3754
+ children: [/* @__PURE__ */ l("button", {
3697
3755
  type: "button",
3698
- onClick: () => void _t("up"),
3699
- disabled: !ht.canUp,
3700
- title: "Move this chunk up within its level",
3701
- children: "↑"
3756
+ className: O === "chunks" ? "active" : "",
3757
+ onClick: () => k("chunks"),
3758
+ title: "This chunk's own content",
3759
+ children: "chunk"
3702
3760
  }), /* @__PURE__ */ l("button", {
3703
3761
  type: "button",
3704
- onClick: () => void _t("down"),
3705
- disabled: !ht.canDown,
3706
- title: "Move this chunk down within its level",
3707
- children: "↓"
3708
- })] }),
3709
- !Y && /* @__PURE__ */ l("button", {
3710
- type: "button",
3711
- className: "danger",
3712
- onClick: () => se(!0),
3713
- title: "Delete this chunk and its sub-chunks",
3714
- children: "delete"
3715
- })
3716
- ]
3717
- })
3718
- ]
3719
- }),
3720
- /* @__PURE__ */ l("div", {
3762
+ className: O === "markdown" ? "active" : "",
3763
+ onClick: () => k("markdown"),
3764
+ title: Y ? "Whole document as Markdown" : "This chunk + its sub-chunks as Markdown",
3765
+ children: "markdown"
3766
+ })]
3767
+ }),
3768
+ /* @__PURE__ */ l("button", {
3769
+ type: "button",
3770
+ className: "chunk-edit",
3771
+ onClick: () => re(E),
3772
+ children: "edit"
3773
+ }),
3774
+ b.documentEntityTypes && _(E) && /* @__PURE__ */ l("button", {
3775
+ type: "button",
3776
+ onClick: () => ae(E),
3777
+ title: "Change this subject's type to another type in force",
3778
+ children: "change type"
3779
+ }),
3780
+ /* @__PURE__ */ l("button", {
3781
+ type: "button",
3782
+ onClick: () => L(!0),
3783
+ title: "View this chunk's edit history + diffs",
3784
+ children: "history"
3785
+ }),
3786
+ !Y && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("button", {
3787
+ type: "button",
3788
+ onClick: () => void vt("up"),
3789
+ disabled: !_t.canUp,
3790
+ title: "Move this chunk up within its level",
3791
+ children: "↑"
3792
+ }), /* @__PURE__ */ l("button", {
3793
+ type: "button",
3794
+ onClick: () => void vt("down"),
3795
+ disabled: !_t.canDown,
3796
+ title: "Move this chunk down within its level",
3797
+ children: "↓"
3798
+ })] }),
3799
+ !Y && /* @__PURE__ */ l("button", {
3800
+ type: "button",
3801
+ className: "danger",
3802
+ onClick: () => se(!0),
3803
+ title: "Delete this chunk and its sub-chunks",
3804
+ children: "delete"
3805
+ })
3806
+ ]
3807
+ })
3808
+ ]
3809
+ }), /* @__PURE__ */ u(Ut, {
3810
+ storageKey: "loomcycle.explorer.doc-links-height",
3811
+ className: "doc-content-split",
3812
+ children: [/* @__PURE__ */ l("div", {
3721
3813
  className: "doc-content-body",
3722
- children: E.type === "mermaid" ? E.body ? /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(et, { code: E.body }), O === "markdown" && /* @__PURE__ */ l("pre", {
3814
+ children: E.type === "mermaid" ? E.body ? /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(rt, { code: E.body }), O === "markdown" && /* @__PURE__ */ l("pre", {
3723
3815
  className: "md-pre doc-mermaid-source",
3724
3816
  children: /* @__PURE__ */ l("code", { children: E.body })
3725
3817
  })] }) : /* @__PURE__ */ l("p", {
@@ -3732,7 +3824,7 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3732
3824
  className: "doc-image",
3733
3825
  children: [/* @__PURE__ */ l("img", {
3734
3826
  src: N,
3735
- alt: Wt(E)
3827
+ alt: Xt(E)
3736
3828
  }), E.body && /* @__PURE__ */ l("figcaption", { children: E.body })]
3737
3829
  }) : /* @__PURE__ */ l("p", {
3738
3830
  className: "doc-empty-body",
@@ -3740,31 +3832,32 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3740
3832
  }) : O === "markdown" ? A === null ? /* @__PURE__ */ l("p", {
3741
3833
  className: "doc-empty-body",
3742
3834
  children: "Assembling Markdown…"
3743
- }) : /* @__PURE__ */ l(Ht, { source: A }) : E.body ? /* @__PURE__ */ l(Ht, { source: E.body }) : /* @__PURE__ */ l("p", {
3835
+ }) : /* @__PURE__ */ l(Jt, { source: A }) : E.body ? /* @__PURE__ */ l(Jt, { source: E.body }) : /* @__PURE__ */ l("p", {
3744
3836
  className: "doc-empty-body",
3745
3837
  children: "(empty chunk)"
3746
3838
  })
3747
- }),
3748
- /* @__PURE__ */ l(Mt, {
3749
- edges: K,
3750
- incomplete: Ce,
3751
- documentId: e,
3752
- selectedId: w,
3753
- onSelectChunk: T,
3754
- onOpenDocument: h ? st : void 0,
3755
- onRuleStatement: Je
3756
- }),
3757
- /* @__PURE__ */ l(At, {
3758
- documentId: e,
3759
- selectedId: w,
3760
- scope: n,
3761
- browse: x,
3762
- onSelectChunk: T,
3763
- onOpenDocument: h ? st : void 0,
3764
- refreshKey: q,
3765
- review: $e
3766
- })
3767
- ] }) : /* @__PURE__ */ l("div", {
3839
+ }), /* @__PURE__ */ u("div", {
3840
+ className: "doc-links-pane",
3841
+ children: [/* @__PURE__ */ l(Ft, {
3842
+ edges: K,
3843
+ incomplete: Ce,
3844
+ documentId: e,
3845
+ selectedId: w,
3846
+ onSelectChunk: T,
3847
+ onOpenDocument: h ? lt : void 0,
3848
+ onRuleStatement: qe
3849
+ }), /* @__PURE__ */ l(Nt, {
3850
+ documentId: e,
3851
+ selectedId: w,
3852
+ scope: n,
3853
+ browse: x,
3854
+ onSelectChunk: T,
3855
+ onOpenDocument: h ? lt : void 0,
3856
+ refreshKey: q,
3857
+ review: et
3858
+ })]
3859
+ })]
3860
+ })] }) : /* @__PURE__ */ l("div", {
3768
3861
  className: "empty",
3769
3862
  children: /* @__PURE__ */ l("p", { children: "Select a chunk on the left." })
3770
3863
  })
@@ -3779,33 +3872,33 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3779
3872
  onChanged: J
3780
3873
  })
3781
3874
  }),
3782
- ne && /* @__PURE__ */ l(tt, {
3875
+ ne && /* @__PURE__ */ l(it, {
3783
3876
  chunk: ne,
3784
3877
  scope: n,
3785
3878
  browse: x,
3786
3879
  onClose: () => re(null),
3787
3880
  onSaved: J
3788
3881
  }),
3789
- ie && /* @__PURE__ */ l(nt, {
3882
+ ie && /* @__PURE__ */ l(at, {
3790
3883
  chunk: ie,
3791
3884
  scope: n,
3792
3885
  browse: x,
3793
3886
  onClose: () => ae(null),
3794
3887
  onSaved: J
3795
3888
  }),
3796
- I && E && /* @__PURE__ */ l(Bt, {
3889
+ I && E && /* @__PURE__ */ l(Kt, {
3797
3890
  chunkId: E.id,
3798
3891
  chunkTitle: E.title,
3799
3892
  scope: n,
3800
3893
  browse: x,
3801
3894
  onClose: () => L(!1)
3802
3895
  }),
3803
- G && Z && /* @__PURE__ */ l(yt, {
3896
+ G && X && /* @__PURE__ */ l(St, {
3804
3897
  documentId: e,
3805
- rootChunkId: Z,
3898
+ rootChunkId: X,
3806
3899
  docType: W?.type,
3807
3900
  docStatus: W?.status,
3808
- chunkStatuses: Re,
3901
+ chunkStatuses: ze,
3809
3902
  scope: n,
3810
3903
  browse: x,
3811
3904
  onClose: () => ye(!1),
@@ -3836,7 +3929,7 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3836
3929
  }), /* @__PURE__ */ l("button", {
3837
3930
  type: "button",
3838
3931
  className: "danger",
3839
- onClick: () => void vt(),
3932
+ onClick: () => void bt(),
3840
3933
  children: "delete"
3841
3934
  })]
3842
3935
  })
@@ -3848,7 +3941,7 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3848
3941
  }
3849
3942
  //#endregion
3850
3943
  //#region src/components/PathTree.tsx
3851
- function Kt(e, t = "") {
3944
+ function Qt(e, t = "") {
3852
3945
  let n = e.get(t);
3853
3946
  if (!n) return [];
3854
3947
  let r = n.entries.map((n) => {
@@ -3859,7 +3952,7 @@ function Kt(e, t = "") {
3859
3952
  kind: n.kind,
3860
3953
  resourceRef: n.resource_ref,
3861
3954
  listing: r ? e.get(n.full_path) : void 0,
3862
- children: r ? Kt(e, n.full_path) : []
3955
+ children: r ? Qt(e, n.full_path) : []
3863
3956
  };
3864
3957
  });
3865
3958
  return r.sort((e, t) => {
@@ -3867,13 +3960,13 @@ function Kt(e, t = "") {
3867
3960
  return n === (t.kind === "directory") ? e.name.localeCompare(t.name) : n ? -1 : 1;
3868
3961
  }), r;
3869
3962
  }
3870
- var qt = {
3963
+ var $t = {
3871
3964
  directory: "📁",
3872
3965
  document: "📄",
3873
3966
  volume_mount: "💾",
3874
3967
  memory_entry: "🧠"
3875
3968
  };
3876
- function Jt(e) {
3969
+ function en(e) {
3877
3970
  let { tree: t, root: n } = e;
3878
3971
  return !n || !n.loaded && n.loading ? /* @__PURE__ */ l("div", {
3879
3972
  className: "empty",
@@ -3883,17 +3976,17 @@ function Jt(e) {
3883
3976
  children: /* @__PURE__ */ l("p", { children: "This tree is empty. Create a folder or document to begin." })
3884
3977
  }) : /* @__PURE__ */ u("ul", {
3885
3978
  className: "tree path-tree",
3886
- children: [t.map((t) => /* @__PURE__ */ l(Zt, {
3979
+ children: [t.map((t) => /* @__PURE__ */ l(rn, {
3887
3980
  node: t,
3888
3981
  ...e
3889
- }, t.fullPath)), /* @__PURE__ */ l(Yt, {
3982
+ }, t.fullPath)), /* @__PURE__ */ l(tn, {
3890
3983
  dir: "",
3891
3984
  listing: n,
3892
3985
  ...e
3893
3986
  })]
3894
3987
  });
3895
3988
  }
3896
- function Yt({ dir: e, listing: t, onLoadMore: n, onRetry: r }) {
3989
+ function tn({ dir: e, listing: t, onLoadMore: n, onRetry: r }) {
3897
3990
  let i = [];
3898
3991
  return !t || t.loading && t.entries.length === 0 ? i.push(/* @__PURE__ */ l("li", {
3899
3992
  className: "node path-status",
@@ -3933,13 +4026,13 @@ function Yt({ dir: e, listing: t, onLoadMore: n, onRetry: r }) {
3933
4026
  })
3934
4027
  }, "more")), /* @__PURE__ */ l(c, { children: i });
3935
4028
  }
3936
- function Xt(e, t) {
4029
+ function nn(e, t) {
3937
4030
  if (e.kind !== "document" || !t) return;
3938
4031
  let n = e.resourceRef;
3939
4032
  return n?.document_id ? t.get(n.document_id) : void 0;
3940
4033
  }
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;
4034
+ function rn(e) {
4035
+ 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 = nn(t, o), p = f && f.color_enabled ? Ge(Ve(f.type, f.status, Be(f.color_scheme))) : void 0;
3943
4036
  return /* @__PURE__ */ u("li", {
3944
4037
  className: `node path-node kind-${t.kind} ${d ? "selected" : ""}`,
3945
4038
  children: [/* @__PURE__ */ u("div", {
@@ -3964,7 +4057,7 @@ function Zt(e) {
3964
4057
  /* @__PURE__ */ l("span", {
3965
4058
  className: "path-kind-icon",
3966
4059
  "aria-hidden": !0,
3967
- children: qt[t.kind] ?? "•"
4060
+ children: $t[t.kind] ?? "•"
3968
4061
  }),
3969
4062
  /* @__PURE__ */ l("span", {
3970
4063
  className: "path-name",
@@ -3982,10 +4075,10 @@ function Zt(e) {
3982
4075
  })]
3983
4076
  }), c && /* @__PURE__ */ u("ul", {
3984
4077
  className: "children path-children",
3985
- children: [t.children.map((t) => /* @__PURE__ */ l(Zt, {
4078
+ children: [t.children.map((t) => /* @__PURE__ */ l(rn, {
3986
4079
  ...e,
3987
4080
  node: t
3988
- }, t.fullPath)), /* @__PURE__ */ l(Yt, {
4081
+ }, t.fullPath)), /* @__PURE__ */ l(tn, {
3989
4082
  ...e,
3990
4083
  dir: t.fullPath,
3991
4084
  listing: t.listing
@@ -3995,23 +4088,23 @@ function Zt(e) {
3995
4088
  }
3996
4089
  //#endregion
3997
4090
  //#region src/PathExplorer.tsx
3998
- var Qt = /^[A-Za-z0-9._-]+$/;
3999
- function $t(e, t) {
4091
+ var an = /^[A-Za-z0-9._-]+$/;
4092
+ function on(e, t) {
4000
4093
  return `${e}/${t}`;
4001
4094
  }
4002
- function en(e, t) {
4095
+ function sn(e, t) {
4003
4096
  for (let n of e) {
4004
4097
  if (n.fullPath === t) return n;
4005
- let e = en(n.children, t);
4098
+ let e = sn(n.children, t);
4006
4099
  if (e) return e;
4007
4100
  }
4008
4101
  }
4009
- function tn(e) {
4102
+ function cn(e) {
4010
4103
  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
4104
  return /* @__PURE__ */ l(z, {
4012
4105
  theme: t,
4013
4106
  dataLayer: f,
4014
- children: /* @__PURE__ */ l(nn, {
4107
+ children: /* @__PURE__ */ l(ln, {
4015
4108
  defaultScope: n,
4016
4109
  path: r,
4017
4110
  onPathChange: i,
@@ -4024,7 +4117,7 @@ function tn(e) {
4024
4117
  })
4025
4118
  });
4026
4119
  }
4027
- function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p, renderAssistant: m, renderNavigator: _, navigator: v, onError: y }) {
4120
+ function ln({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p, renderAssistant: m, renderNavigator: _, navigator: v, onError: y }) {
4028
4121
  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);
4029
4122
  r(() => {
4030
4123
  te.current = d;
@@ -4089,7 +4182,6 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4089
4182
  P,
4090
4183
  U
4091
4184
  ]), r(() => {
4092
- if (x === "tenant") return;
4093
4185
  let e = [];
4094
4186
  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
4187
  let t = Oe.current;
@@ -4106,7 +4198,7 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4106
4198
  x,
4107
4199
  B
4108
4200
  ]);
4109
- let je = i(() => Kt(H), [H]), Me = t(async () => {
4201
+ let je = i(() => Qt(H), [H]), Me = t(async () => {
4110
4202
  E(null), ke(), xe((e) => e + 1), await V.refresh(j).catch(U), P && await V.reveal(P).catch(U);
4111
4203
  }, [
4112
4204
  V,
@@ -4119,15 +4211,15 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4119
4211
  let n = new Set(t);
4120
4212
  return n.has(e) ? n.delete(e) : n.add(e), n;
4121
4213
  });
4122
- }, []), Y = t((e) => V.loadMore(e).catch(U), [V, U]), X = t((e) => {
4214
+ }, []), Y = t((e) => V.loadMore(e).catch(U), [V, U]), Pe = t((e) => {
4123
4215
  (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);
4216
+ }, [V, U]), X = i(() => P ? sn(je, P) : void 0, [je, P]), Fe = H.get("")?.error, Ie = X?.kind === "directory" ? X.fullPath : void 0, [Le, Re] = o(null);
4125
4217
  r(() => {
4126
- if (!Fe || !b.pathIsStored) return;
4218
+ if (!Ie || !b.pathIsStored) return;
4127
4219
  let e = !1;
4128
- return b.pathIsStored(Fe, x, B).then((t) => {
4129
- e || Le({
4130
- path: Fe,
4220
+ return b.pathIsStored(Ie, x, B).then((t) => {
4221
+ e || Re({
4222
+ path: Ie,
4131
4223
  explicit: t
4132
4224
  });
4133
4225
  }, () => {}), () => {
@@ -4135,13 +4227,13 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4135
4227
  };
4136
4228
  }, [
4137
4229
  b,
4138
- Fe,
4230
+ Ie,
4139
4231
  x,
4140
4232
  B
4141
4233
  ]);
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(() => {
4234
+ let ze = X ? X.kind === "directory" ? Le?.path === X.fullPath ? Le.explicit ? "yes" : "implicit (no entry)" : void 0 : "yes" : void 0, Z = i(() => X ? X.kind === "directory" ? X.fullPath : F(X.fullPath) : "", [X]), Q = Z || "/", Be = t(() => {
4143
4235
  O({
4144
- title: `New folder in ${ze}`,
4236
+ title: `New folder in ${Q}`,
4145
4237
  fields: [{
4146
4238
  key: "name",
4147
4239
  label: "Folder name",
@@ -4150,23 +4242,23 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4150
4242
  submitLabel: "Create",
4151
4243
  onSubmit: async (e) => {
4152
4244
  let t = e.name.trim();
4153
- if (!Qt.test(t)) throw Error("name may contain only [A-Za-z0-9._-]");
4154
- let n = $t(Q, t);
4245
+ if (!an.test(t)) throw Error("name may contain only [A-Za-z0-9._-]");
4246
+ let n = on(Z, t);
4155
4247
  await b.pathMkdir(n, x, B), await q(n).catch(U), z(n);
4156
4248
  }
4157
4249
  });
4158
4250
  }, [
4159
4251
  b,
4160
4252
  V,
4253
+ Z,
4161
4254
  Q,
4162
- ze,
4163
4255
  x,
4164
4256
  B,
4165
4257
  U,
4166
4258
  z
4167
- ]), He = t(() => {
4259
+ ]), Ve = t(() => {
4168
4260
  O({
4169
- title: `New document in ${ze}`,
4261
+ title: `New document in ${Q}`,
4170
4262
  fields: [{
4171
4263
  key: "name",
4172
4264
  label: "Path name",
@@ -4179,61 +4271,61 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4179
4271
  submitLabel: "Create",
4180
4272
  onSubmit: async (e) => {
4181
4273
  let t = e.name.trim();
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);
4274
+ if (!an.test(t)) throw Error("name may contain only [A-Za-z0-9._-]");
4275
+ let n = e.title.trim() || t, r = on(Z, t);
4184
4276
  await b.documentCreate(n, r, x, B), await q(r).catch(U), z(r);
4185
4277
  }
4186
4278
  });
4187
4279
  }, [
4188
4280
  b,
4189
4281
  V,
4282
+ Z,
4190
4283
  Q,
4191
- ze,
4192
4284
  x,
4193
4285
  B,
4194
4286
  U,
4195
4287
  z
4196
- ]), Ue = t(() => {
4197
- Z && O({
4198
- title: `Rename / move ${Z.fullPath}`,
4288
+ ]), He = t(() => {
4289
+ X && O({
4290
+ title: `Rename / move ${X.fullPath}`,
4199
4291
  fields: [{
4200
4292
  key: "to",
4201
4293
  label: "New path",
4202
- value: Z.fullPath
4294
+ value: X.fullPath
4203
4295
  }],
4204
4296
  submitLabel: "Move",
4205
4297
  onSubmit: async (e) => {
4206
4298
  let t = e.to.trim();
4207
4299
  if (!t.startsWith("/")) throw Error("path must start with /");
4208
- await b.pathMv(Z.fullPath, t, x, B), await Promise.all([q(Z.fullPath, { dropSubtree: !0 }), q(t)]).catch(U), z(t);
4300
+ await b.pathMv(X.fullPath, t, x, B), await Promise.all([q(X.fullPath, { dropSubtree: !0 }), q(t)]).catch(U), z(t);
4209
4301
  }
4210
4302
  });
4211
4303
  }, [
4212
4304
  b,
4213
4305
  V,
4214
- Z,
4306
+ X,
4215
4307
  x,
4216
4308
  B,
4217
4309
  U,
4218
4310
  z
4219
- ]), We = t(() => {
4220
- if (!Z) return;
4221
- if (Z.kind === "document") {
4222
- let e = Z.resourceRef?.document_id;
4311
+ ]), Ue = t(() => {
4312
+ if (!X) return;
4313
+ if (X.kind === "document") {
4314
+ let e = X.resourceRef?.document_id;
4223
4315
  O({
4224
- title: `Delete document ${Z.fullPath}`,
4316
+ title: `Delete document ${X.fullPath}`,
4225
4317
  message: "This deletes the document, all its chunks, and its path entry. This cannot be undone.",
4226
4318
  fields: [],
4227
4319
  submitLabel: "Delete",
4228
4320
  danger: !0,
4229
4321
  onSubmit: async () => {
4230
4322
  if (!e) throw Error("this document dirent has no document_id");
4231
- await b.documentDelete(e, x, B), await q(Z.fullPath).catch(U), z(void 0);
4323
+ await b.documentDelete(e, x, B), await q(X.fullPath).catch(U), z(void 0);
4232
4324
  }
4233
4325
  });
4234
4326
  return;
4235
4327
  }
4236
- let e = Z;
4328
+ let e = X;
4237
4329
  E(null), (async () => {
4238
4330
  let t;
4239
4331
  try {
@@ -4242,7 +4334,7 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4242
4334
  E(`could not list ${e.fullPath} for delete: ${t instanceof Error ? t.message : String(t)}`);
4243
4335
  return;
4244
4336
  }
4245
- let n = x === "tenant" ? [] : ae(t);
4337
+ let n = ae(t);
4246
4338
  O({
4247
4339
  title: `Delete branch ${e.fullPath}`,
4248
4340
  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.` : "."),
@@ -4258,29 +4350,29 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4258
4350
  }, [
4259
4351
  b,
4260
4352
  V,
4261
- Z,
4353
+ X,
4262
4354
  x,
4263
4355
  B,
4264
4356
  U,
4265
4357
  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;
4358
+ ]), We = X && (X.kind === "directory" || X.kind === "document"), Ge = !!b.documentsTransfer && !!We, Ke = t(() => {
4359
+ if (X) {
4360
+ if (X.kind === "document") {
4361
+ let e = X.resourceRef?.document_id;
4270
4362
  if (!e) {
4271
4363
  E("this document entry has no document_id");
4272
4364
  return;
4273
4365
  }
4274
4366
  A({
4275
4367
  documentId: e,
4276
- fromPath: Z.fullPath
4368
+ fromPath: X.fullPath
4277
4369
  });
4278
4370
  } else A({
4279
- underPath: Z.fullPath,
4280
- fromPath: Z.fullPath
4371
+ underPath: X.fullPath,
4372
+ fromPath: X.fullPath
4281
4373
  });
4282
4374
  }
4283
- }, [Z]), Je = t((e) => {
4375
+ }, [X]), qe = t((e) => {
4284
4376
  e.op === "move" ? (q(e.from, { dropSubtree: !0 }).catch(U), L([]), z(void 0)) : e.toScope === x && q(e.to).catch(U);
4285
4377
  }, [
4286
4378
  q,
@@ -4289,12 +4381,12 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4289
4381
  z
4290
4382
  ]), $ = i(() => {
4291
4383
  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
4384
+ if (X?.kind === "document") return {
4385
+ documentId: X.resourceRef?.document_id ?? "",
4386
+ path: X.fullPath,
4387
+ title: X.name
4296
4388
  };
4297
- }, [I, Z]), Ye = t((e, t) => {
4389
+ }, [I, X]), Je = t((e, t) => {
4298
4390
  let n = ++oe.current, r = fe(V.getSnapshot(), e.documentId);
4299
4391
  L(ce(I, {
4300
4392
  ...t,
@@ -4313,10 +4405,10 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4313
4405
  x,
4314
4406
  B,
4315
4407
  R
4316
- ]), Xe = t((e) => {
4408
+ ]), Ye = t((e) => {
4317
4409
  let t = le(I, e);
4318
4410
  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) => {
4411
+ }, [I, R]), Xe = t((e, t) => L((n) => ue(n, e, { title: t })), []), Ze = t((e) => {
4320
4412
  we((t) => ({
4321
4413
  documentId: e.documentId,
4322
4414
  chunkId: e.chunkId,
@@ -4329,7 +4421,7 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4329
4421
  $?.documentId,
4330
4422
  z,
4331
4423
  R
4332
- ]), $e = i(() => ({
4424
+ ]), Qe = i(() => ({
4333
4425
  scope: x,
4334
4426
  browse: B,
4335
4427
  selection: {
@@ -4337,7 +4429,7 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4337
4429
  chunkId: K && K.documentId === $?.documentId ? K.chunkId : void 0,
4338
4430
  path: $?.path
4339
4431
  },
4340
- onSelect: Qe,
4432
+ onSelect: Ze,
4341
4433
  reloadToken: be,
4342
4434
  maximized: ve,
4343
4435
  onToggleMaximize: () => ye((e) => !e),
@@ -4348,11 +4440,11 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4348
4440
  $?.documentId,
4349
4441
  $?.path,
4350
4442
  K,
4351
- Qe,
4443
+ Ze,
4352
4444
  be,
4353
4445
  ve,
4354
4446
  p?.subject
4355
- ]), et = Ce && $ && Ce.documentId === $.documentId ? Ce : void 0, tt = !!$?.path && Z?.kind === "document" && Z.fullPath === $.path;
4447
+ ]), $e = Ce && $ && Ce.documentId === $.documentId ? Ce : void 0, et = !!$?.path && X?.kind === "document" && X.fullPath === $.path;
4356
4448
  return /* @__PURE__ */ u(c, { children: [
4357
4449
  /* @__PURE__ */ u(he, {
4358
4450
  className: G ? "paths-view paths-view--stars" : "paths-view",
@@ -4412,14 +4504,13 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4412
4504
  className: "paths-toolbar-actions",
4413
4505
  children: [!G && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("button", {
4414
4506
  type: "button",
4415
- onClick: Ve,
4416
- title: `New folder in ${ze}`,
4507
+ onClick: Be,
4508
+ title: `New folder in ${Q}`,
4417
4509
  children: "+ folder"
4418
4510
  }), /* @__PURE__ */ l("button", {
4419
4511
  type: "button",
4420
- onClick: He,
4421
- disabled: !Be,
4422
- title: Be ? `New document in ${ze}` : "Documents are agent/user scope only",
4512
+ onClick: Ve,
4513
+ title: `New document in ${Q}`,
4423
4514
  children: "+ document"
4424
4515
  })] }), /* @__PURE__ */ l("button", {
4425
4516
  type: "button",
@@ -4434,7 +4525,7 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4434
4525
  className: "paths-context",
4435
4526
  children: [
4436
4527
  "new items → ",
4437
- /* @__PURE__ */ l("code", { children: ze }),
4528
+ /* @__PURE__ */ l("code", { children: Q }),
4438
4529
  B?.scopeId && /* @__PURE__ */ u(c, { children: [
4439
4530
  " · ",
4440
4531
  "subject ",
@@ -4447,20 +4538,20 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4447
4538
  ] })
4448
4539
  ]
4449
4540
  }),
4450
- (T || Pe) && /* @__PURE__ */ l("div", {
4541
+ (T || Fe) && /* @__PURE__ */ l("div", {
4451
4542
  className: "paths-err",
4452
- children: T || Pe
4543
+ children: T || Fe
4453
4544
  }),
4454
4545
  G && _ ? /* @__PURE__ */ l("div", {
4455
4546
  className: "paths-navigator",
4456
- children: _($e)
4457
- }) : /* @__PURE__ */ l(Jt, {
4547
+ children: _(Qe)
4548
+ }) : /* @__PURE__ */ l(en, {
4458
4549
  tree: je,
4459
4550
  root: H.get(""),
4460
4551
  expanded: j,
4461
4552
  onToggle: Ne,
4462
4553
  onLoadMore: Y,
4463
- onRetry: X,
4554
+ onRetry: Pe,
4464
4555
  selectedPath: P,
4465
4556
  onSelect: (e) => z(e.fullPath),
4466
4557
  summaries: Te
@@ -4473,7 +4564,7 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4473
4564
  children: [
4474
4565
  /* @__PURE__ */ l(pe, {
4475
4566
  trail: I,
4476
- onJump: Xe
4567
+ onJump: Ye
4477
4568
  }),
4478
4569
  /* @__PURE__ */ u("div", {
4479
4570
  className: "paths-doc-head",
@@ -4488,79 +4579,79 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4488
4579
  " ",
4489
4580
  /* @__PURE__ */ l("em", { children: "· opened by id, not in the tree" })
4490
4581
  ]
4491
- }), tt && /* @__PURE__ */ u("div", {
4582
+ }), et && /* @__PURE__ */ u("div", {
4492
4583
  className: "paths-detail-actions",
4493
4584
  children: [
4494
4585
  /* @__PURE__ */ l("button", {
4495
4586
  type: "button",
4496
- onClick: Ue,
4587
+ onClick: He,
4497
4588
  children: "rename / move"
4498
4589
  }),
4499
- Ke && /* @__PURE__ */ l("button", {
4590
+ Ge && /* @__PURE__ */ l("button", {
4500
4591
  type: "button",
4501
- onClick: qe,
4592
+ onClick: Ke,
4502
4593
  title: "Copy or move to another scope",
4503
4594
  children: "copy / move to…"
4504
4595
  }),
4505
4596
  /* @__PURE__ */ l("button", {
4506
4597
  type: "button",
4507
4598
  className: "danger",
4508
- onClick: We,
4599
+ onClick: Ue,
4509
4600
  children: "delete"
4510
4601
  })
4511
4602
  ]
4512
4603
  })]
4513
4604
  }),
4514
- /* @__PURE__ */ l(Gt, {
4605
+ /* @__PURE__ */ l(Zt, {
4515
4606
  documentId: $.documentId,
4516
4607
  scope: x,
4517
4608
  titleHint: $.title,
4518
4609
  browse: B,
4519
4610
  principal: p,
4520
4611
  renderAssistant: m,
4521
- initialChunkId: $.chunkId ?? et?.chunkId,
4522
- onOpenDocument: Ye,
4523
- onTitle: Ze,
4612
+ initialChunkId: $.chunkId ?? $e?.chunkId,
4613
+ onOpenDocument: Je,
4614
+ onTitle: Xe,
4524
4615
  onChunkSelect: (e) => Se({
4525
4616
  documentId: $.documentId,
4526
4617
  chunkId: e
4527
4618
  }),
4528
- focusChunk: et
4619
+ focusChunk: $e
4529
4620
  }, I.length)
4530
4621
  ]
4531
- }) : Z ? /* @__PURE__ */ u("div", {
4622
+ }) : X ? /* @__PURE__ */ u("div", {
4532
4623
  className: "paths-detail",
4533
4624
  children: [
4534
4625
  /* @__PURE__ */ u("h2", { children: [/* @__PURE__ */ l("span", {
4535
4626
  className: "paths-detail-kind",
4536
- children: Z.kind
4537
- }), /* @__PURE__ */ l("code", { children: Z.fullPath })] }),
4627
+ children: X.kind
4628
+ }), /* @__PURE__ */ l("code", { children: X.fullPath })] }),
4538
4629
  /* @__PURE__ */ u("dl", {
4539
4630
  className: "paths-detail-meta",
4540
4631
  children: [
4541
4632
  /* @__PURE__ */ l("dt", { children: "scope" }),
4542
4633
  /* @__PURE__ */ l("dd", { children: x }),
4543
- Re && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("dt", { children: "stored" }), /* @__PURE__ */ l("dd", { children: Re })] })
4634
+ ze && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("dt", { children: "stored" }), /* @__PURE__ */ l("dd", { children: ze })] })
4544
4635
  ]
4545
4636
  }),
4546
- Ge ? /* @__PURE__ */ u("div", {
4637
+ We ? /* @__PURE__ */ u("div", {
4547
4638
  className: "paths-detail-actions",
4548
4639
  children: [
4549
4640
  /* @__PURE__ */ l("button", {
4550
4641
  type: "button",
4551
- onClick: Ue,
4642
+ onClick: He,
4552
4643
  children: "rename / move"
4553
4644
  }),
4554
- Ke && /* @__PURE__ */ l("button", {
4645
+ Ge && /* @__PURE__ */ l("button", {
4555
4646
  type: "button",
4556
- onClick: qe,
4647
+ onClick: Ke,
4557
4648
  title: "Copy or move to another scope",
4558
4649
  children: "copy / move to…"
4559
4650
  }),
4560
4651
  /* @__PURE__ */ l("button", {
4561
4652
  type: "button",
4562
4653
  className: "danger",
4563
- onClick: We,
4654
+ onClick: Ue,
4564
4655
  children: "delete"
4565
4656
  })
4566
4657
  ]
@@ -4568,7 +4659,7 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4568
4659
  className: "paths-readonly",
4569
4660
  children: [
4570
4661
  "Read-only — ",
4571
- Z.kind,
4662
+ X.kind,
4572
4663
  " entries are managed by their own tool."
4573
4664
  ]
4574
4665
  })
@@ -4579,7 +4670,7 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4579
4670
  })
4580
4671
  })]
4581
4672
  }),
4582
- D && /* @__PURE__ */ l(rn, {
4673
+ D && /* @__PURE__ */ l(un, {
4583
4674
  state: D,
4584
4675
  onClose: () => O(null)
4585
4676
  }),
@@ -4591,11 +4682,11 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4591
4682
  underPath: k.underPath,
4592
4683
  fromPath: k.fromPath,
4593
4684
  onClose: () => A(null),
4594
- onDone: Je
4685
+ onDone: qe
4595
4686
  })
4596
4687
  ] });
4597
4688
  }
4598
- function rn({ state: e, onClose: t }) {
4689
+ function un({ state: e, onClose: t }) {
4599
4690
  let [n, r] = o(() => Object.fromEntries(e.fields.map((e) => [e.key, e.value ?? ""]))), [i, a] = o(!1), [s, c] = o(null);
4600
4691
  return /* @__PURE__ */ l("div", {
4601
4692
  className: "modal-overlay",
@@ -4656,34 +4747,42 @@ function rn({ state: e, onClose: t }) {
4656
4747
  }
4657
4748
  //#endregion
4658
4749
  //#region src/DocumentViewer.tsx
4659
- function an(e) {
4750
+ function dn(e) {
4660
4751
  let { documentId: t, scope: n, browse: r, theme: i } = e, a = R(e);
4661
4752
  return /* @__PURE__ */ l(z, {
4662
4753
  theme: i,
4663
4754
  dataLayer: a,
4664
- children: /* @__PURE__ */ l(on, { ...e }, `${n}:${t}:${r?.scopeId ?? ""}:${r?.tenant ?? ""}`)
4755
+ children: /* @__PURE__ */ l(fn, { ...e }, `${n}:${t}:${r?.scopeId ?? ""}:${r?.tenant ?? ""}`)
4665
4756
  });
4666
4757
  }
4667
- function on({ documentId: e, scope: n, titleHint: r, browse: i, principal: a, renderAssistant: s, onOpenDocument: d }) {
4668
- let [f, p] = o([]), m = f[f.length - 1], h = t((e, t) => {
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 })), []);
4758
+ function fn({ documentId: e, chunkId: n, scope: i, titleHint: s, browse: d, principal: f, renderAssistant: p, onOpenDocument: m }) {
4759
+ let [h, g] = o([]), _ = h[h.length - 1], [v, y] = o(), b = a(n);
4760
+ r(() => {
4761
+ n !== b.current && (b.current = n, h.length > 0 ? (y(void 0), g([])) : y((e) => ({
4762
+ chunkId: n,
4763
+ seq: (e?.seq ?? 0) + 1
4764
+ })));
4765
+ }, [n]);
4766
+ let x = t((e, t) => {
4767
+ m ? m(e, t) : g((n) => ce(n, t, e));
4768
+ }, [m]), S = t((e) => g((t) => le(t, e)), []), C = t((e, t) => g((n) => ue(n, e, { title: t })), []);
4671
4769
  return /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(pe, {
4672
- trail: f,
4673
- onJump: g
4674
- }), /* @__PURE__ */ l(Gt, {
4675
- documentId: m?.documentId ?? e,
4676
- scope: n,
4677
- titleHint: m ? m.title : r,
4678
- browse: i,
4679
- principal: a,
4680
- renderAssistant: s,
4681
- initialChunkId: m?.chunkId,
4682
- onOpenDocument: h,
4683
- onTitle: _
4684
- }, f.length)] });
4770
+ trail: h,
4771
+ onJump: S
4772
+ }), /* @__PURE__ */ l(Zt, {
4773
+ documentId: _?.documentId ?? e,
4774
+ scope: i,
4775
+ titleHint: _ ? _.title : s,
4776
+ browse: d,
4777
+ principal: f,
4778
+ renderAssistant: p,
4779
+ initialChunkId: _ ? _.chunkId : n,
4780
+ focusChunk: _ ? void 0 : v,
4781
+ onOpenDocument: x,
4782
+ onTitle: C
4783
+ }, h.length)] });
4685
4784
  }
4686
4785
  //#endregion
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 };
4786
+ export { Z as DEFAULT_SCHEME, dn as DocumentViewer, ye as EDGE_PAGE_CAP, cn as PathExplorer, Ae as QUEUE_CHANGED_RETRIES, J as RULING_CHUNK, oe as RequestError, L as assetFetchFromConnection, He as chunkColor, Pe as chunkCount, Ue as chunkInheritsDocColor, qe as chunkRowStyle, I as createLoomcycleClient, O as dataLayerFromClient, Ve as docColor, Be as effectiveScheme, We as hexToTint, Me as isQueueChanged, se as jsonPostFromConnection, be as loadDocumentEdges, Ne as runRuling, Ge as tintStyle, b as transferInput, Y as undoRulings, Ke as washStyle };
4688
4787
 
4689
4788
  //# sourceMappingURL=index.js.map