@loomcycle/explorer 0.13.0 → 0.14.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 Je(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 $({ 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 Je(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($, {
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,46 @@ 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
2859
2880
  //#region src/components/DocUnavailable.tsx
2860
- function Rt({ documentId: e, scope: t, detail: n }) {
2881
+ function Vt({ documentId: e, scope: t, detail: n }) {
2861
2882
  return /* @__PURE__ */ u("div", {
2862
2883
  className: "doc-unavailable",
2863
2884
  role: "alert",
@@ -2880,11 +2901,11 @@ function Rt({ documentId: e, scope: t, detail: n }) {
2880
2901
  }
2881
2902
  //#endregion
2882
2903
  //#region src/components/HistoryModal.tsx
2883
- function zt(e) {
2904
+ function Ht(e) {
2884
2905
  let t = typeof e == "number" ? e / 1e6 : Date.parse(String(e));
2885
2906
  return !Number.isFinite(t) || t <= 0 ? String(e ?? "") : new Date(t).toLocaleString();
2886
2907
  }
2887
- function Bt({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
2908
+ function Ut({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
2888
2909
  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
2910
  r(() => {
2890
2911
  let t = !1;
@@ -2969,7 +2990,7 @@ function Bt({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
2969
2990
  }),
2970
2991
  /* @__PURE__ */ l("span", {
2971
2992
  className: "doc-hist-rev-time",
2972
- children: zt(e.created_at)
2993
+ children: Ht(e.created_at)
2973
2994
  }),
2974
2995
  /* @__PURE__ */ l("span", {
2975
2996
  className: "doc-hist-rev-actor",
@@ -3017,7 +3038,7 @@ function Bt({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
3017
3038
  children: C ? /* @__PURE__ */ l("p", {
3018
3039
  className: "doc-empty-body",
3019
3040
  children: "loading…"
3020
- }) : _ === "diff" ? /* @__PURE__ */ l(Vt, { text: k }) : _ === "version" ? /* @__PURE__ */ l("pre", {
3041
+ }) : _ === "diff" ? /* @__PURE__ */ l(Wt, { text: k }) : _ === "version" ? /* @__PURE__ */ l("pre", {
3021
3042
  className: "md-pre doc-hist-version",
3022
3043
  children: /* @__PURE__ */ l("code", { children: x || "(empty)" })
3023
3044
  }) : /* @__PURE__ */ l("p", {
@@ -3030,7 +3051,7 @@ function Bt({ chunkId: e, chunkTitle: t, scope: n, browse: i, onClose: a }) {
3030
3051
  })
3031
3052
  });
3032
3053
  }
3033
- function Vt({ text: e }) {
3054
+ function Wt({ text: e }) {
3034
3055
  if (!e.trim()) return /* @__PURE__ */ l("p", {
3035
3056
  className: "doc-empty-body",
3036
3057
  children: "(no differences)"
@@ -3049,17 +3070,17 @@ function Vt({ text: e }) {
3049
3070
  }
3050
3071
  //#endregion
3051
3072
  //#region src/components/Markdown.tsx
3052
- function Ht({ source: e }) {
3073
+ function Gt({ source: e }) {
3053
3074
  return /* @__PURE__ */ l("div", {
3054
3075
  className: "md",
3055
3076
  children: /* @__PURE__ */ l(f, {
3056
3077
  remarkPlugins: [p],
3057
- components: Ut,
3078
+ components: Kt,
3058
3079
  children: e
3059
3080
  })
3060
3081
  });
3061
3082
  }
3062
- var Ut = {
3083
+ var Kt = {
3063
3084
  a({ href: e, children: t }) {
3064
3085
  let n = e ?? "", r = /^https?:\/\//i.test(n);
3065
3086
  return /* @__PURE__ */ l("a", {
@@ -3074,7 +3095,7 @@ var Ut = {
3074
3095
  },
3075
3096
  code({ className: e, children: t }) {
3076
3097
  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", {
3098
+ return n === "mermaid" ? /* @__PURE__ */ l(rt, { code: r.replace(/\n$/, "") }) : n || r.includes("\n") ? /* @__PURE__ */ l("pre", {
3078
3099
  className: "md-pre",
3079
3100
  children: /* @__PURE__ */ l("code", {
3080
3101
  className: e,
@@ -3085,11 +3106,11 @@ var Ut = {
3085
3106
  };
3086
3107
  //#endregion
3087
3108
  //#region src/components/DocumentViewerBody.tsx
3088
- function Wt(e) {
3109
+ function qt(e) {
3089
3110
  let t = e.fields ?? {};
3090
3111
  return typeof t.alt == "string" && t.alt.trim() !== "" ? t.alt : e.title || "image";
3091
3112
  }
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 }) {
3113
+ function Jt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, renderAssistant: p, initialChunkId: m, onOpenDocument: h, onTitle: g, onChunkSelect: v, focusChunk: y }) {
3093
3114
  let b = M(), x = i(() => d && (d.scopeId || d.tenant) ? {
3094
3115
  scopeId: d.scopeId,
3095
3116
  tenant: d.tenant
@@ -3097,20 +3118,20 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3097
3118
  Ae.current = m;
3098
3119
  let je = a(g);
3099
3120
  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(() => {
3121
+ 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);
3122
+ Re.current = v, r(() => {
3123
+ w && Re.current?.(w === X ? void 0 : w);
3124
+ }, [w, X]);
3125
+ let ze = i(() => [...new Set(S.map((e) => e.status).filter((e) => !!e))], [S]), Z = !!W?.color_enabled, Q = i(() => {
3105
3126
  let e = /* @__PURE__ */ new Set();
3106
3127
  for (let t of K) e.add(t.from_id), e.add(t.to_id);
3107
3128
  return e;
3108
- }, [K]), He = i(() => Q ? We(Ve(W?.type, W?.status, Be(W?.color_scheme))) : void 0, [
3109
- Q,
3129
+ }, [K]), He = i(() => Z ? Ve(W?.type, W?.status, Be(W?.color_scheme)) : void 0, [
3130
+ Z,
3110
3131
  W?.type,
3111
3132
  W?.status,
3112
3133
  W?.color_scheme
3113
- ]);
3134
+ ]), Ue = i(() => Ge(He), [He]);
3114
3135
  r(() => {
3115
3136
  let t = !1;
3116
3137
  return le(!0), z(null), V(null), b.documentQueryChunks(e, n, x).then((r) => {
@@ -3129,10 +3150,10 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3129
3150
  fe,
3130
3151
  x
3131
3152
  ]);
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]);
3153
+ 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
3154
  r(() => {
3134
- Ge && je.current?.(e, Ge);
3135
- }, [e, Ge]), r(() => {
3155
+ Ke && je.current?.(e, Ke);
3156
+ }, [e, Ke]), r(() => {
3136
3157
  let t = !1;
3137
3158
  return b.documentGet(e, n, x).then((e) => !t && ge(e)).catch(() => !t && ge(null)), () => {
3138
3159
  t = !0;
@@ -3160,23 +3181,23 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3160
3181
  x,
3161
3182
  q
3162
3183
  ]), r(() => {
3163
- if (!Z || !b.documentAcceptClassification) {
3184
+ if (!X || !b.documentAcceptClassification) {
3164
3185
  ke(void 0);
3165
3186
  return;
3166
3187
  }
3167
3188
  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)), () => {
3189
+ return b.documentGetChunk(X, n, x).then((n) => !t && ke(n.document_id === e ? n.fields : void 0)).catch(() => !t && ke(void 0)), () => {
3169
3190
  t = !0;
3170
3191
  };
3171
3192
  }, [
3172
3193
  b,
3173
3194
  e,
3174
- Z,
3195
+ X,
3175
3196
  n,
3176
3197
  fe,
3177
3198
  x
3178
3199
  ]);
3179
- let Je = i(() => {
3200
+ let qe = i(() => {
3180
3201
  if (b.documentAcceptStatement && b.documentRejectStatement) return async (e, t, r) => {
3181
3202
  t ? await b.documentAcceptStatement(e, n, x, r) : await b.documentRejectStatement(e, r ?? "", n, x), Te((e) => e + 1);
3182
3203
  };
@@ -3184,19 +3205,19 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3184
3205
  b,
3185
3206
  n,
3186
3207
  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), [
3208
+ ]), Je = i(() => Fe(b, n), [b, n]), Xe = i(() => Ie(K, e), [K, e]), $e = t(() => Te((e) => e + 1), []), et = i(() => Le(Je, Xe, Ce, $e), [
3209
+ Je,
3188
3210
  Xe,
3189
- Ze,
3190
3211
  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;
3212
+ $e
3213
+ ]), tt = y?.seq, nt = a(y);
3214
+ nt.current = y;
3215
+ let ot = a(X);
3216
+ ot.current = X, r(() => {
3217
+ if (tt === void 0) return;
3218
+ let e = nt.current?.chunkId ?? ot.current;
3198
3219
  e && T(e);
3199
- }, [rt]), r(() => {
3220
+ }, [tt]), r(() => {
3200
3221
  T(void 0), D(null), j(null), k("chunks"), ge(null), Se([]), we(!1), De(0), ke(void 0);
3201
3222
  }, [e, n]), r(() => {
3202
3223
  if (!w) {
@@ -3235,7 +3256,7 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3235
3256
  j(null);
3236
3257
  return;
3237
3258
  }
3238
- let e = $(Me, w);
3259
+ let e = Ze(Me, w);
3239
3260
  if (!e) return;
3240
3261
  let t = !1, r = [], i = (e, t) => {
3241
3262
  r.push({
@@ -3267,7 +3288,7 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3267
3288
  fe,
3268
3289
  x
3269
3290
  ]);
3270
- let ot = t((e) => T(e.row.id), []), st = t((t, n, r) => h?.({
3291
+ let st = t((e) => T(e.row.id), []), ct = t((t, n, r) => h?.({
3271
3292
  documentId: t,
3272
3293
  chunkId: n,
3273
3294
  title: r
@@ -3280,7 +3301,7 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3280
3301
  e,
3281
3302
  w,
3282
3303
  Ne
3283
- ]), ct = t(async () => {
3304
+ ]), lt = t(async () => {
3284
3305
  try {
3285
3306
  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
3307
  a.href = i, a.download = (t.title || "document").replace(/[^\w.-]+/g, "_") + ".md", a.click(), URL.revokeObjectURL(i);
@@ -3292,7 +3313,7 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3292
3313
  e,
3293
3314
  n,
3294
3315
  x
3295
- ]), lt = t(async () => {
3316
+ ]), ut = t(async () => {
3296
3317
  try {
3297
3318
  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
3319
  a.href = i, a.download = (Ne || "document").replace(/[^\w.-]+/g, "_") + ".canvas", a.click(), URL.revokeObjectURL(i);
@@ -3305,9 +3326,9 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3305
3326
  n,
3306
3327
  x,
3307
3328
  Ne
3308
- ]), ut = !!b.documentCreateChunk && !!Z, dt = t(async (t) => {
3329
+ ]), dt = !!b.documentCreateChunk && !!X, ft = t(async (t) => {
3309
3330
  if (!b.documentCreateChunk || !b.documentSetAsset) return;
3310
- let r = w || Z;
3331
+ let r = w || X;
3311
3332
  if (r) {
3312
3333
  z(null);
3313
3334
  try {
@@ -3326,11 +3347,11 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3326
3347
  n,
3327
3348
  x,
3328
3349
  w,
3329
- Z,
3350
+ X,
3330
3351
  J
3331
- ]), ft = t(async () => {
3352
+ ]), pt = t(async () => {
3332
3353
  if (!b.documentCreateChunk) return;
3333
- let t = w || Z;
3354
+ let t = w || X;
3334
3355
  if (t) {
3335
3356
  z(null);
3336
3357
  try {
@@ -3350,11 +3371,11 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3350
3371
  n,
3351
3372
  x,
3352
3373
  w,
3353
- Z,
3374
+ X,
3354
3375
  J
3355
- ]), pt = t(async () => {
3376
+ ]), mt = t(async () => {
3356
3377
  if (!b.documentCreateChunk) return;
3357
- let t = w && !Y ? w : void 0, r = w || Z;
3378
+ let t = w && !Y ? w : void 0, r = w || X;
3358
3379
  if (r) {
3359
3380
  z(null);
3360
3381
  try {
@@ -3374,9 +3395,9 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3374
3395
  x,
3375
3396
  w,
3376
3397
  Y,
3377
- Z,
3398
+ X,
3378
3399
  J
3379
- ]), mt = t(async () => {
3400
+ ]), ht = t(async () => {
3380
3401
  if (b.documentCreateChunk && w) {
3381
3402
  z(null);
3382
3403
  try {
@@ -3396,7 +3417,7 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3396
3417
  x,
3397
3418
  w,
3398
3419
  J
3399
- ]), ht = i(() => {
3420
+ ]), gt = i(() => {
3400
3421
  if (!E || Y) return {
3401
3422
  canUp: !1,
3402
3423
  canDown: !1
@@ -3430,7 +3451,7 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3430
3451
  z(null);
3431
3452
  let e = E.parent_id;
3432
3453
  try {
3433
- await b.documentDeleteChunk(E.id, n, x), se(!1), T(e || Z), J();
3454
+ await b.documentDeleteChunk(E.id, n, x), se(!1), T(e || X), J();
3434
3455
  } catch (e) {
3435
3456
  z(e instanceof Error ? e.message : String(e)), se(!1);
3436
3457
  }
@@ -3439,24 +3460,24 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3439
3460
  E,
3440
3461
  n,
3441
3462
  x,
3442
- Z,
3463
+ X,
3443
3464
  J
3444
3465
  ]);
3445
3466
  return r(() => {
3446
- if (!ut) return;
3467
+ if (!dt) return;
3447
3468
  let e = (e) => {
3448
3469
  if (ne || G) return;
3449
3470
  let t = document.activeElement, n = t?.tagName;
3450
3471
  if (n === "INPUT" || n === "TEXTAREA" || t?.isContentEditable) return;
3451
3472
  let r = ve(e.clipboardData?.items);
3452
- r && (e.preventDefault(), dt(r));
3473
+ r && (e.preventDefault(), ft(r));
3453
3474
  };
3454
3475
  return window.addEventListener("paste", e), () => window.removeEventListener("paste", e);
3455
3476
  }, [
3456
- ut,
3477
+ dt,
3457
3478
  ne,
3458
3479
  G,
3459
- dt
3480
+ ft
3460
3481
  ]), /* @__PURE__ */ u("div", {
3461
3482
  className: "doc-viewer",
3462
3483
  children: [
@@ -3467,35 +3488,35 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3467
3488
  style: { display: "none" },
3468
3489
  onChange: (e) => {
3469
3490
  let t = e.target.files?.[0];
3470
- e.target.value = "", t && dt(t);
3491
+ e.target.value = "", t && ft(t);
3471
3492
  }
3472
3493
  }),
3473
3494
  /* @__PURE__ */ u("div", {
3474
3495
  className: "doc-toolbar",
3475
- style: He,
3496
+ style: Ue,
3476
3497
  children: [
3477
3498
  /* @__PURE__ */ l("strong", {
3478
3499
  className: "doc-title",
3479
3500
  title: Ne,
3480
3501
  children: Ne
3481
3502
  }),
3482
- /* @__PURE__ */ l(Ke, {
3503
+ /* @__PURE__ */ l($, {
3483
3504
  value: e,
3484
3505
  label: "doc"
3485
3506
  }),
3486
3507
  /* @__PURE__ */ u("div", {
3487
3508
  className: "doc-toolbar-actions",
3488
3509
  children: [
3489
- ut && /* @__PURE__ */ u(c, { children: [
3510
+ dt && /* @__PURE__ */ u(c, { children: [
3490
3511
  /* @__PURE__ */ l("button", {
3491
3512
  type: "button",
3492
- onClick: () => void pt(),
3513
+ onClick: () => void mt(),
3493
3514
  title: "Add a text chunk AFTER the selected chunk, at the same level",
3494
3515
  children: "+ text"
3495
3516
  }),
3496
3517
  /* @__PURE__ */ l("button", {
3497
3518
  type: "button",
3498
- onClick: () => void mt(),
3519
+ onClick: () => void ht(),
3499
3520
  disabled: !w,
3500
3521
  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
3522
  children: "+ child"
@@ -3508,16 +3529,16 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3508
3529
  }),
3509
3530
  /* @__PURE__ */ l("button", {
3510
3531
  type: "button",
3511
- onClick: () => void ft(),
3532
+ onClick: () => void pt(),
3512
3533
  title: "Add a Mermaid diagram chunk",
3513
3534
  children: "+ diagram"
3514
3535
  })
3515
3536
  ] }),
3516
3537
  /* @__PURE__ */ l("button", {
3517
3538
  type: "button",
3518
- className: Q ? "active" : "",
3539
+ className: Z ? "active" : "",
3519
3540
  onClick: () => ye(!0),
3520
- disabled: !Z,
3541
+ disabled: !X,
3521
3542
  title: "Colors — tint chunk tiles + the Path tree by type/status",
3522
3543
  children: "colors"
3523
3544
  }),
@@ -3530,13 +3551,13 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3530
3551
  }),
3531
3552
  /* @__PURE__ */ l("button", {
3532
3553
  type: "button",
3533
- onClick: () => void ct(),
3554
+ onClick: () => void lt(),
3534
3555
  title: "Download the whole document as Markdown (.md)",
3535
3556
  children: "↓ .md"
3536
3557
  }),
3537
3558
  /* @__PURE__ */ l("button", {
3538
3559
  type: "button",
3539
- onClick: () => void lt(),
3560
+ onClick: () => void ut(),
3540
3561
  title: "Download the whole document as a node/edge canvas graph (.canvas)",
3541
3562
  children: "↓ .canvas"
3542
3563
  }),
@@ -3561,7 +3582,7 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3561
3582
  className: "paths-err",
3562
3583
  children: R
3563
3584
  }),
3564
- !Ue && /* @__PURE__ */ l(gt, {
3585
+ !We && /* @__PURE__ */ l(yt, {
3565
3586
  documentId: e,
3566
3587
  scope: n,
3567
3588
  browse: x,
@@ -3570,7 +3591,7 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3570
3591
  onClose: () => De(0),
3571
3592
  onChanged: J
3572
3593
  }, `${n}:${e}`),
3573
- Ue ? /* @__PURE__ */ l(Rt, {
3594
+ We ? /* @__PURE__ */ l(Vt, {
3574
3595
  documentId: e,
3575
3596
  scope: n,
3576
3597
  detail: de ?? void 0
@@ -3585,13 +3606,14 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3585
3606
  children: ce && S.length === 0 ? /* @__PURE__ */ l("div", {
3586
3607
  className: "empty",
3587
3608
  children: /* @__PURE__ */ l("p", { children: "Loading…" })
3588
- }) : /* @__PURE__ */ l(Ye, {
3609
+ }) : /* @__PURE__ */ l(Qe, {
3589
3610
  tree: Me,
3590
3611
  selectedId: w,
3591
- onSelect: ot,
3592
- colorEnabled: Q,
3612
+ onSelect: st,
3613
+ colorEnabled: Z,
3593
3614
  scheme: W?.color_scheme,
3594
- linkedIds: ze
3615
+ documentColor: He,
3616
+ linkedIds: Q
3595
3617
  })
3596
3618
  }), /* @__PURE__ */ l("div", {
3597
3619
  className: "doc-content",
@@ -3599,18 +3621,18 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3599
3621
  /* @__PURE__ */ u("div", {
3600
3622
  className: "doc-content-head",
3601
3623
  children: [
3602
- X.length > 0 && /* @__PURE__ */ u("nav", {
3624
+ Pe.length > 0 && /* @__PURE__ */ u("nav", {
3603
3625
  className: "chunk-ancestry",
3604
3626
  "aria-label": "Chunks above this one",
3605
3627
  children: [/* @__PURE__ */ l("button", {
3606
3628
  type: "button",
3607
3629
  className: "chunk-ancestry-up",
3608
- onClick: () => T(X[X.length - 1].id),
3609
- title: `Up to ${X[X.length - 1].title || "(untitled)"}`,
3630
+ onClick: () => T(Pe[Pe.length - 1].id),
3631
+ title: `Up to ${Pe[Pe.length - 1].title || "(untitled)"}`,
3610
3632
  children: "↰ Up"
3611
3633
  }), /* @__PURE__ */ u("ol", {
3612
3634
  className: "doc-trail-list",
3613
- children: [X.map((e) => /* @__PURE__ */ l("li", {
3635
+ children: [Pe.map((e) => /* @__PURE__ */ l("li", {
3614
3636
  className: "doc-trail-item",
3615
3637
  children: /* @__PURE__ */ l("button", {
3616
3638
  type: "button",
@@ -3650,7 +3672,7 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3650
3672
  className: "chunk-tag",
3651
3673
  children: e
3652
3674
  }, e)),
3653
- /* @__PURE__ */ l(Ke, {
3675
+ /* @__PURE__ */ l($, {
3654
3676
  value: E.id,
3655
3677
  label: "chunk"
3656
3678
  })
@@ -3696,13 +3718,13 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3696
3718
  !Y && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("button", {
3697
3719
  type: "button",
3698
3720
  onClick: () => void _t("up"),
3699
- disabled: !ht.canUp,
3721
+ disabled: !gt.canUp,
3700
3722
  title: "Move this chunk up within its level",
3701
3723
  children: "↑"
3702
3724
  }), /* @__PURE__ */ l("button", {
3703
3725
  type: "button",
3704
3726
  onClick: () => void _t("down"),
3705
- disabled: !ht.canDown,
3727
+ disabled: !gt.canDown,
3706
3728
  title: "Move this chunk down within its level",
3707
3729
  children: "↓"
3708
3730
  })] }),
@@ -3719,7 +3741,7 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3719
3741
  }),
3720
3742
  /* @__PURE__ */ l("div", {
3721
3743
  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", {
3744
+ children: E.type === "mermaid" ? E.body ? /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(rt, { code: E.body }), O === "markdown" && /* @__PURE__ */ l("pre", {
3723
3745
  className: "md-pre doc-mermaid-source",
3724
3746
  children: /* @__PURE__ */ l("code", { children: E.body })
3725
3747
  })] }) : /* @__PURE__ */ l("p", {
@@ -3732,7 +3754,7 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3732
3754
  className: "doc-image",
3733
3755
  children: [/* @__PURE__ */ l("img", {
3734
3756
  src: N,
3735
- alt: Wt(E)
3757
+ alt: qt(E)
3736
3758
  }), E.body && /* @__PURE__ */ l("figcaption", { children: E.body })]
3737
3759
  }) : /* @__PURE__ */ l("p", {
3738
3760
  className: "doc-empty-body",
@@ -3740,29 +3762,29 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3740
3762
  }) : O === "markdown" ? A === null ? /* @__PURE__ */ l("p", {
3741
3763
  className: "doc-empty-body",
3742
3764
  children: "Assembling Markdown…"
3743
- }) : /* @__PURE__ */ l(Ht, { source: A }) : E.body ? /* @__PURE__ */ l(Ht, { source: E.body }) : /* @__PURE__ */ l("p", {
3765
+ }) : /* @__PURE__ */ l(Gt, { source: A }) : E.body ? /* @__PURE__ */ l(Gt, { source: E.body }) : /* @__PURE__ */ l("p", {
3744
3766
  className: "doc-empty-body",
3745
3767
  children: "(empty chunk)"
3746
3768
  })
3747
3769
  }),
3748
- /* @__PURE__ */ l(Mt, {
3770
+ /* @__PURE__ */ l(Ft, {
3749
3771
  edges: K,
3750
3772
  incomplete: Ce,
3751
3773
  documentId: e,
3752
3774
  selectedId: w,
3753
3775
  onSelectChunk: T,
3754
- onOpenDocument: h ? st : void 0,
3755
- onRuleStatement: Je
3776
+ onOpenDocument: h ? ct : void 0,
3777
+ onRuleStatement: qe
3756
3778
  }),
3757
- /* @__PURE__ */ l(At, {
3779
+ /* @__PURE__ */ l(Nt, {
3758
3780
  documentId: e,
3759
3781
  selectedId: w,
3760
3782
  scope: n,
3761
3783
  browse: x,
3762
3784
  onSelectChunk: T,
3763
- onOpenDocument: h ? st : void 0,
3785
+ onOpenDocument: h ? ct : void 0,
3764
3786
  refreshKey: q,
3765
- review: $e
3787
+ review: et
3766
3788
  })
3767
3789
  ] }) : /* @__PURE__ */ l("div", {
3768
3790
  className: "empty",
@@ -3779,33 +3801,33 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3779
3801
  onChanged: J
3780
3802
  })
3781
3803
  }),
3782
- ne && /* @__PURE__ */ l(tt, {
3804
+ ne && /* @__PURE__ */ l(it, {
3783
3805
  chunk: ne,
3784
3806
  scope: n,
3785
3807
  browse: x,
3786
3808
  onClose: () => re(null),
3787
3809
  onSaved: J
3788
3810
  }),
3789
- ie && /* @__PURE__ */ l(nt, {
3811
+ ie && /* @__PURE__ */ l(at, {
3790
3812
  chunk: ie,
3791
3813
  scope: n,
3792
3814
  browse: x,
3793
3815
  onClose: () => ae(null),
3794
3816
  onSaved: J
3795
3817
  }),
3796
- I && E && /* @__PURE__ */ l(Bt, {
3818
+ I && E && /* @__PURE__ */ l(Ut, {
3797
3819
  chunkId: E.id,
3798
3820
  chunkTitle: E.title,
3799
3821
  scope: n,
3800
3822
  browse: x,
3801
3823
  onClose: () => L(!1)
3802
3824
  }),
3803
- G && Z && /* @__PURE__ */ l(yt, {
3825
+ G && X && /* @__PURE__ */ l(St, {
3804
3826
  documentId: e,
3805
- rootChunkId: Z,
3827
+ rootChunkId: X,
3806
3828
  docType: W?.type,
3807
3829
  docStatus: W?.status,
3808
- chunkStatuses: Re,
3830
+ chunkStatuses: ze,
3809
3831
  scope: n,
3810
3832
  browse: x,
3811
3833
  onClose: () => ye(!1),
@@ -3848,7 +3870,7 @@ function Gt({ documentId: e, scope: n, titleHint: s, browse: d, principal: f, re
3848
3870
  }
3849
3871
  //#endregion
3850
3872
  //#region src/components/PathTree.tsx
3851
- function Kt(e, t = "") {
3873
+ function Yt(e, t = "") {
3852
3874
  let n = e.get(t);
3853
3875
  if (!n) return [];
3854
3876
  let r = n.entries.map((n) => {
@@ -3859,7 +3881,7 @@ function Kt(e, t = "") {
3859
3881
  kind: n.kind,
3860
3882
  resourceRef: n.resource_ref,
3861
3883
  listing: r ? e.get(n.full_path) : void 0,
3862
- children: r ? Kt(e, n.full_path) : []
3884
+ children: r ? Yt(e, n.full_path) : []
3863
3885
  };
3864
3886
  });
3865
3887
  return r.sort((e, t) => {
@@ -3867,13 +3889,13 @@ function Kt(e, t = "") {
3867
3889
  return n === (t.kind === "directory") ? e.name.localeCompare(t.name) : n ? -1 : 1;
3868
3890
  }), r;
3869
3891
  }
3870
- var qt = {
3892
+ var Xt = {
3871
3893
  directory: "📁",
3872
3894
  document: "📄",
3873
3895
  volume_mount: "💾",
3874
3896
  memory_entry: "🧠"
3875
3897
  };
3876
- function Jt(e) {
3898
+ function Zt(e) {
3877
3899
  let { tree: t, root: n } = e;
3878
3900
  return !n || !n.loaded && n.loading ? /* @__PURE__ */ l("div", {
3879
3901
  className: "empty",
@@ -3883,17 +3905,17 @@ function Jt(e) {
3883
3905
  children: /* @__PURE__ */ l("p", { children: "This tree is empty. Create a folder or document to begin." })
3884
3906
  }) : /* @__PURE__ */ u("ul", {
3885
3907
  className: "tree path-tree",
3886
- children: [t.map((t) => /* @__PURE__ */ l(Zt, {
3908
+ children: [t.map((t) => /* @__PURE__ */ l(en, {
3887
3909
  node: t,
3888
3910
  ...e
3889
- }, t.fullPath)), /* @__PURE__ */ l(Yt, {
3911
+ }, t.fullPath)), /* @__PURE__ */ l(Qt, {
3890
3912
  dir: "",
3891
3913
  listing: n,
3892
3914
  ...e
3893
3915
  })]
3894
3916
  });
3895
3917
  }
3896
- function Yt({ dir: e, listing: t, onLoadMore: n, onRetry: r }) {
3918
+ function Qt({ dir: e, listing: t, onLoadMore: n, onRetry: r }) {
3897
3919
  let i = [];
3898
3920
  return !t || t.loading && t.entries.length === 0 ? i.push(/* @__PURE__ */ l("li", {
3899
3921
  className: "node path-status",
@@ -3933,13 +3955,13 @@ function Yt({ dir: e, listing: t, onLoadMore: n, onRetry: r }) {
3933
3955
  })
3934
3956
  }, "more")), /* @__PURE__ */ l(c, { children: i });
3935
3957
  }
3936
- function Xt(e, t) {
3958
+ function $t(e, t) {
3937
3959
  if (e.kind !== "document" || !t) return;
3938
3960
  let n = e.resourceRef;
3939
3961
  return n?.document_id ? t.get(n.document_id) : void 0;
3940
3962
  }
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;
3963
+ function en(e) {
3964
+ 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 = $t(t, o), p = f && f.color_enabled ? Ge(Ve(f.type, f.status, Be(f.color_scheme))) : void 0;
3943
3965
  return /* @__PURE__ */ u("li", {
3944
3966
  className: `node path-node kind-${t.kind} ${d ? "selected" : ""}`,
3945
3967
  children: [/* @__PURE__ */ u("div", {
@@ -3964,7 +3986,7 @@ function Zt(e) {
3964
3986
  /* @__PURE__ */ l("span", {
3965
3987
  className: "path-kind-icon",
3966
3988
  "aria-hidden": !0,
3967
- children: qt[t.kind] ?? "•"
3989
+ children: Xt[t.kind] ?? "•"
3968
3990
  }),
3969
3991
  /* @__PURE__ */ l("span", {
3970
3992
  className: "path-name",
@@ -3982,10 +4004,10 @@ function Zt(e) {
3982
4004
  })]
3983
4005
  }), c && /* @__PURE__ */ u("ul", {
3984
4006
  className: "children path-children",
3985
- children: [t.children.map((t) => /* @__PURE__ */ l(Zt, {
4007
+ children: [t.children.map((t) => /* @__PURE__ */ l(en, {
3986
4008
  ...e,
3987
4009
  node: t
3988
- }, t.fullPath)), /* @__PURE__ */ l(Yt, {
4010
+ }, t.fullPath)), /* @__PURE__ */ l(Qt, {
3989
4011
  ...e,
3990
4012
  dir: t.fullPath,
3991
4013
  listing: t.listing
@@ -3995,23 +4017,23 @@ function Zt(e) {
3995
4017
  }
3996
4018
  //#endregion
3997
4019
  //#region src/PathExplorer.tsx
3998
- var Qt = /^[A-Za-z0-9._-]+$/;
3999
- function $t(e, t) {
4020
+ var tn = /^[A-Za-z0-9._-]+$/;
4021
+ function nn(e, t) {
4000
4022
  return `${e}/${t}`;
4001
4023
  }
4002
- function en(e, t) {
4024
+ function rn(e, t) {
4003
4025
  for (let n of e) {
4004
4026
  if (n.fullPath === t) return n;
4005
- let e = en(n.children, t);
4027
+ let e = rn(n.children, t);
4006
4028
  if (e) return e;
4007
4029
  }
4008
4030
  }
4009
- function tn(e) {
4031
+ function an(e) {
4010
4032
  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
4033
  return /* @__PURE__ */ l(z, {
4012
4034
  theme: t,
4013
4035
  dataLayer: f,
4014
- children: /* @__PURE__ */ l(nn, {
4036
+ children: /* @__PURE__ */ l(on, {
4015
4037
  defaultScope: n,
4016
4038
  path: r,
4017
4039
  onPathChange: i,
@@ -4024,7 +4046,7 @@ function tn(e) {
4024
4046
  })
4025
4047
  });
4026
4048
  }
4027
- function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p, renderAssistant: m, renderNavigator: _, navigator: v, onError: y }) {
4049
+ function on({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p, renderAssistant: m, renderNavigator: _, navigator: v, onError: y }) {
4028
4050
  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
4051
  r(() => {
4030
4052
  te.current = d;
@@ -4106,7 +4128,7 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4106
4128
  x,
4107
4129
  B
4108
4130
  ]);
4109
- let je = i(() => Kt(H), [H]), Me = t(async () => {
4131
+ let je = i(() => Yt(H), [H]), Me = t(async () => {
4110
4132
  E(null), ke(), xe((e) => e + 1), await V.refresh(j).catch(U), P && await V.reveal(P).catch(U);
4111
4133
  }, [
4112
4134
  V,
@@ -4119,15 +4141,15 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4119
4141
  let n = new Set(t);
4120
4142
  return n.has(e) ? n.delete(e) : n.add(e), n;
4121
4143
  });
4122
- }, []), Y = t((e) => V.loadMore(e).catch(U), [V, U]), X = t((e) => {
4144
+ }, []), Y = t((e) => V.loadMore(e).catch(U), [V, U]), Pe = t((e) => {
4123
4145
  (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);
4146
+ }, [V, U]), X = i(() => P ? rn(je, P) : void 0, [je, P]), Fe = H.get("")?.error, Ie = X?.kind === "directory" ? X.fullPath : void 0, [Le, Re] = o(null);
4125
4147
  r(() => {
4126
- if (!Fe || !b.pathIsStored) return;
4148
+ if (!Ie || !b.pathIsStored) return;
4127
4149
  let e = !1;
4128
- return b.pathIsStored(Fe, x, B).then((t) => {
4129
- e || Le({
4130
- path: Fe,
4150
+ return b.pathIsStored(Ie, x, B).then((t) => {
4151
+ e || Re({
4152
+ path: Ie,
4131
4153
  explicit: t
4132
4154
  });
4133
4155
  }, () => {}), () => {
@@ -4135,13 +4157,13 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4135
4157
  };
4136
4158
  }, [
4137
4159
  b,
4138
- Fe,
4160
+ Ie,
4139
4161
  x,
4140
4162
  B
4141
4163
  ]);
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(() => {
4164
+ 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 = x !== "tenant", Ve = t(() => {
4143
4165
  O({
4144
- title: `New folder in ${ze}`,
4166
+ title: `New folder in ${Q}`,
4145
4167
  fields: [{
4146
4168
  key: "name",
4147
4169
  label: "Folder name",
@@ -4150,23 +4172,23 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4150
4172
  submitLabel: "Create",
4151
4173
  onSubmit: async (e) => {
4152
4174
  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);
4175
+ if (!tn.test(t)) throw Error("name may contain only [A-Za-z0-9._-]");
4176
+ let n = nn(Z, t);
4155
4177
  await b.pathMkdir(n, x, B), await q(n).catch(U), z(n);
4156
4178
  }
4157
4179
  });
4158
4180
  }, [
4159
4181
  b,
4160
4182
  V,
4183
+ Z,
4161
4184
  Q,
4162
- ze,
4163
4185
  x,
4164
4186
  B,
4165
4187
  U,
4166
4188
  z
4167
4189
  ]), He = t(() => {
4168
4190
  O({
4169
- title: `New document in ${ze}`,
4191
+ title: `New document in ${Q}`,
4170
4192
  fields: [{
4171
4193
  key: "name",
4172
4194
  label: "Path name",
@@ -4179,61 +4201,61 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4179
4201
  submitLabel: "Create",
4180
4202
  onSubmit: async (e) => {
4181
4203
  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);
4204
+ if (!tn.test(t)) throw Error("name may contain only [A-Za-z0-9._-]");
4205
+ let n = e.title.trim() || t, r = nn(Z, t);
4184
4206
  await b.documentCreate(n, r, x, B), await q(r).catch(U), z(r);
4185
4207
  }
4186
4208
  });
4187
4209
  }, [
4188
4210
  b,
4189
4211
  V,
4212
+ Z,
4190
4213
  Q,
4191
- ze,
4192
4214
  x,
4193
4215
  B,
4194
4216
  U,
4195
4217
  z
4196
4218
  ]), Ue = t(() => {
4197
- Z && O({
4198
- title: `Rename / move ${Z.fullPath}`,
4219
+ X && O({
4220
+ title: `Rename / move ${X.fullPath}`,
4199
4221
  fields: [{
4200
4222
  key: "to",
4201
4223
  label: "New path",
4202
- value: Z.fullPath
4224
+ value: X.fullPath
4203
4225
  }],
4204
4226
  submitLabel: "Move",
4205
4227
  onSubmit: async (e) => {
4206
4228
  let t = e.to.trim();
4207
4229
  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);
4230
+ await b.pathMv(X.fullPath, t, x, B), await Promise.all([q(X.fullPath, { dropSubtree: !0 }), q(t)]).catch(U), z(t);
4209
4231
  }
4210
4232
  });
4211
4233
  }, [
4212
4234
  b,
4213
4235
  V,
4214
- Z,
4236
+ X,
4215
4237
  x,
4216
4238
  B,
4217
4239
  U,
4218
4240
  z
4219
4241
  ]), We = t(() => {
4220
- if (!Z) return;
4221
- if (Z.kind === "document") {
4222
- let e = Z.resourceRef?.document_id;
4242
+ if (!X) return;
4243
+ if (X.kind === "document") {
4244
+ let e = X.resourceRef?.document_id;
4223
4245
  O({
4224
- title: `Delete document ${Z.fullPath}`,
4246
+ title: `Delete document ${X.fullPath}`,
4225
4247
  message: "This deletes the document, all its chunks, and its path entry. This cannot be undone.",
4226
4248
  fields: [],
4227
4249
  submitLabel: "Delete",
4228
4250
  danger: !0,
4229
4251
  onSubmit: async () => {
4230
4252
  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);
4253
+ await b.documentDelete(e, x, B), await q(X.fullPath).catch(U), z(void 0);
4232
4254
  }
4233
4255
  });
4234
4256
  return;
4235
4257
  }
4236
- let e = Z;
4258
+ let e = X;
4237
4259
  E(null), (async () => {
4238
4260
  let t;
4239
4261
  try {
@@ -4258,29 +4280,29 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4258
4280
  }, [
4259
4281
  b,
4260
4282
  V,
4261
- Z,
4283
+ X,
4262
4284
  x,
4263
4285
  B,
4264
4286
  U,
4265
4287
  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;
4288
+ ]), Ge = X && (X.kind === "directory" || X.kind === "document"), Ke = !!b.documentsTransfer && !!Ge, qe = t(() => {
4289
+ if (X) {
4290
+ if (X.kind === "document") {
4291
+ let e = X.resourceRef?.document_id;
4270
4292
  if (!e) {
4271
4293
  E("this document entry has no document_id");
4272
4294
  return;
4273
4295
  }
4274
4296
  A({
4275
4297
  documentId: e,
4276
- fromPath: Z.fullPath
4298
+ fromPath: X.fullPath
4277
4299
  });
4278
4300
  } else A({
4279
- underPath: Z.fullPath,
4280
- fromPath: Z.fullPath
4301
+ underPath: X.fullPath,
4302
+ fromPath: X.fullPath
4281
4303
  });
4282
4304
  }
4283
- }, [Z]), Je = t((e) => {
4305
+ }, [X]), Je = t((e) => {
4284
4306
  e.op === "move" ? (q(e.from, { dropSubtree: !0 }).catch(U), L([]), z(void 0)) : e.toScope === x && q(e.to).catch(U);
4285
4307
  }, [
4286
4308
  q,
@@ -4289,12 +4311,12 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4289
4311
  z
4290
4312
  ]), $ = i(() => {
4291
4313
  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
4314
+ if (X?.kind === "document") return {
4315
+ documentId: X.resourceRef?.document_id ?? "",
4316
+ path: X.fullPath,
4317
+ title: X.name
4296
4318
  };
4297
- }, [I, Z]), Ye = t((e, t) => {
4319
+ }, [I, X]), Ye = t((e, t) => {
4298
4320
  let n = ++oe.current, r = fe(V.getSnapshot(), e.documentId);
4299
4321
  L(ce(I, {
4300
4322
  ...t,
@@ -4352,7 +4374,7 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4352
4374
  be,
4353
4375
  ve,
4354
4376
  p?.subject
4355
- ]), et = Ce && $ && Ce.documentId === $.documentId ? Ce : void 0, tt = !!$?.path && Z?.kind === "document" && Z.fullPath === $.path;
4377
+ ]), et = Ce && $ && Ce.documentId === $.documentId ? Ce : void 0, tt = !!$?.path && X?.kind === "document" && X.fullPath === $.path;
4356
4378
  return /* @__PURE__ */ u(c, { children: [
4357
4379
  /* @__PURE__ */ u(he, {
4358
4380
  className: G ? "paths-view paths-view--stars" : "paths-view",
@@ -4413,13 +4435,13 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4413
4435
  children: [!G && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("button", {
4414
4436
  type: "button",
4415
4437
  onClick: Ve,
4416
- title: `New folder in ${ze}`,
4438
+ title: `New folder in ${Q}`,
4417
4439
  children: "+ folder"
4418
4440
  }), /* @__PURE__ */ l("button", {
4419
4441
  type: "button",
4420
4442
  onClick: He,
4421
4443
  disabled: !Be,
4422
- title: Be ? `New document in ${ze}` : "Documents are agent/user scope only",
4444
+ title: Be ? `New document in ${Q}` : "Documents are agent/user scope only",
4423
4445
  children: "+ document"
4424
4446
  })] }), /* @__PURE__ */ l("button", {
4425
4447
  type: "button",
@@ -4434,7 +4456,7 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4434
4456
  className: "paths-context",
4435
4457
  children: [
4436
4458
  "new items → ",
4437
- /* @__PURE__ */ l("code", { children: ze }),
4459
+ /* @__PURE__ */ l("code", { children: Q }),
4438
4460
  B?.scopeId && /* @__PURE__ */ u(c, { children: [
4439
4461
  " · ",
4440
4462
  "subject ",
@@ -4447,20 +4469,20 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4447
4469
  ] })
4448
4470
  ]
4449
4471
  }),
4450
- (T || Pe) && /* @__PURE__ */ l("div", {
4472
+ (T || Fe) && /* @__PURE__ */ l("div", {
4451
4473
  className: "paths-err",
4452
- children: T || Pe
4474
+ children: T || Fe
4453
4475
  }),
4454
4476
  G && _ ? /* @__PURE__ */ l("div", {
4455
4477
  className: "paths-navigator",
4456
4478
  children: _($e)
4457
- }) : /* @__PURE__ */ l(Jt, {
4479
+ }) : /* @__PURE__ */ l(Zt, {
4458
4480
  tree: je,
4459
4481
  root: H.get(""),
4460
4482
  expanded: j,
4461
4483
  onToggle: Ne,
4462
4484
  onLoadMore: Y,
4463
- onRetry: X,
4485
+ onRetry: Pe,
4464
4486
  selectedPath: P,
4465
4487
  onSelect: (e) => z(e.fullPath),
4466
4488
  summaries: Te
@@ -4511,7 +4533,7 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4511
4533
  ]
4512
4534
  })]
4513
4535
  }),
4514
- /* @__PURE__ */ l(Gt, {
4536
+ /* @__PURE__ */ l(Jt, {
4515
4537
  documentId: $.documentId,
4516
4538
  scope: x,
4517
4539
  titleHint: $.title,
@@ -4528,19 +4550,19 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4528
4550
  focusChunk: et
4529
4551
  }, I.length)
4530
4552
  ]
4531
- }) : Z ? /* @__PURE__ */ u("div", {
4553
+ }) : X ? /* @__PURE__ */ u("div", {
4532
4554
  className: "paths-detail",
4533
4555
  children: [
4534
4556
  /* @__PURE__ */ u("h2", { children: [/* @__PURE__ */ l("span", {
4535
4557
  className: "paths-detail-kind",
4536
- children: Z.kind
4537
- }), /* @__PURE__ */ l("code", { children: Z.fullPath })] }),
4558
+ children: X.kind
4559
+ }), /* @__PURE__ */ l("code", { children: X.fullPath })] }),
4538
4560
  /* @__PURE__ */ u("dl", {
4539
4561
  className: "paths-detail-meta",
4540
4562
  children: [
4541
4563
  /* @__PURE__ */ l("dt", { children: "scope" }),
4542
4564
  /* @__PURE__ */ l("dd", { children: x }),
4543
- Re && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("dt", { children: "stored" }), /* @__PURE__ */ l("dd", { children: Re })] })
4565
+ ze && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("dt", { children: "stored" }), /* @__PURE__ */ l("dd", { children: ze })] })
4544
4566
  ]
4545
4567
  }),
4546
4568
  Ge ? /* @__PURE__ */ u("div", {
@@ -4568,7 +4590,7 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4568
4590
  className: "paths-readonly",
4569
4591
  children: [
4570
4592
  "Read-only — ",
4571
- Z.kind,
4593
+ X.kind,
4572
4594
  " entries are managed by their own tool."
4573
4595
  ]
4574
4596
  })
@@ -4579,7 +4601,7 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4579
4601
  })
4580
4602
  })]
4581
4603
  }),
4582
- D && /* @__PURE__ */ l(rn, {
4604
+ D && /* @__PURE__ */ l(sn, {
4583
4605
  state: D,
4584
4606
  onClose: () => O(null)
4585
4607
  }),
@@ -4595,7 +4617,7 @@ function nn({ defaultScope: e, path: n, onPathChange: d, browse: f, principal: p
4595
4617
  })
4596
4618
  ] });
4597
4619
  }
4598
- function rn({ state: e, onClose: t }) {
4620
+ function sn({ state: e, onClose: t }) {
4599
4621
  let [n, r] = o(() => Object.fromEntries(e.fields.map((e) => [e.key, e.value ?? ""]))), [i, a] = o(!1), [s, c] = o(null);
4600
4622
  return /* @__PURE__ */ l("div", {
4601
4623
  className: "modal-overlay",
@@ -4656,22 +4678,22 @@ function rn({ state: e, onClose: t }) {
4656
4678
  }
4657
4679
  //#endregion
4658
4680
  //#region src/DocumentViewer.tsx
4659
- function an(e) {
4681
+ function cn(e) {
4660
4682
  let { documentId: t, scope: n, browse: r, theme: i } = e, a = R(e);
4661
4683
  return /* @__PURE__ */ l(z, {
4662
4684
  theme: i,
4663
4685
  dataLayer: a,
4664
- children: /* @__PURE__ */ l(on, { ...e }, `${n}:${t}:${r?.scopeId ?? ""}:${r?.tenant ?? ""}`)
4686
+ children: /* @__PURE__ */ l(ln, { ...e }, `${n}:${t}:${r?.scopeId ?? ""}:${r?.tenant ?? ""}`)
4665
4687
  });
4666
4688
  }
4667
- function on({ documentId: e, scope: n, titleHint: r, browse: i, principal: a, renderAssistant: s, onOpenDocument: d }) {
4689
+ function ln({ documentId: e, scope: n, titleHint: r, browse: i, principal: a, renderAssistant: s, onOpenDocument: d }) {
4668
4690
  let [f, p] = o([]), m = f[f.length - 1], h = t((e, t) => {
4669
4691
  d ? d(e, t) : p((n) => ce(n, t, e));
4670
4692
  }, [d]), g = t((e) => p((t) => le(t, e)), []), _ = t((e, t) => p((n) => ue(n, e, { title: t })), []);
4671
4693
  return /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(pe, {
4672
4694
  trail: f,
4673
4695
  onJump: g
4674
- }), /* @__PURE__ */ l(Gt, {
4696
+ }), /* @__PURE__ */ l(Jt, {
4675
4697
  documentId: m?.documentId ?? e,
4676
4698
  scope: n,
4677
4699
  titleHint: m ? m.title : r,
@@ -4684,6 +4706,6 @@ function on({ documentId: e, scope: n, titleHint: r, browse: i, principal: a, re
4684
4706
  }, f.length)] });
4685
4707
  }
4686
4708
  //#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 };
4709
+ export { Z as DEFAULT_SCHEME, cn as DocumentViewer, ye as EDGE_PAGE_CAP, an 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
4710
 
4689
4711
  //# sourceMappingURL=index.js.map