@loomcycle/explorer 0.1.0 → 0.2.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/components/ColorSchemeEditor.d.ts +13 -0
- package/dist/components/CrossReferences.d.ts +8 -0
- package/dist/components/DocumentChunkTree.d.ts +5 -1
- package/dist/components/Mermaid.d.ts +4 -0
- package/dist/components/PathTree.d.ts +3 -1
- package/dist/index.cjs +5 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +945 -613
- package/dist/index.js.map +1 -1
- package/dist/lib/colorScheme.d.ts +26 -0
- package/dist/lib/dataLayer.d.ts +12 -1
- package/dist/styles.css +257 -0
- package/dist/types.d.ts +13 -0
- package/package.json +12 -1
package/dist/index.js
CHANGED
|
@@ -1,231 +1,302 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { LoomcycleClient as
|
|
4
|
-
|
|
1
|
+
import { jsx as n, jsxs as d, Fragment as q } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as Pe, useContext as Te, useMemo as A, useState as b, useRef as ee, useEffect as I, useCallback as G } from "react";
|
|
3
|
+
import { LoomcycleClient as Oe } from "@loomcycle/client";
|
|
4
|
+
import Ie from "react-markdown";
|
|
5
|
+
import Ae from "remark-gfm";
|
|
6
|
+
function he(e) {
|
|
5
7
|
return {
|
|
6
|
-
pathLs: (
|
|
7
|
-
{ op: "ls", path:
|
|
8
|
-
|
|
8
|
+
pathLs: (a, t, r, c) => e.path(
|
|
9
|
+
{ op: "ls", path: a, scope: t, recursive: r },
|
|
10
|
+
c
|
|
9
11
|
),
|
|
10
|
-
pathMkdir: (
|
|
11
|
-
pathMv: (
|
|
12
|
-
pathRm: (
|
|
13
|
-
documentCreate: (
|
|
14
|
-
{ op: "create_document", title:
|
|
15
|
-
|
|
12
|
+
pathMkdir: (a, t, r) => e.path({ op: "mkdir", path: a, scope: t }, r),
|
|
13
|
+
pathMv: (a, t, r, c) => e.path({ op: "mv", path: a, to: t, scope: r }, c),
|
|
14
|
+
pathRm: (a, t, r, c) => e.path({ op: "rm", path: a, scope: t, recursive: r }, c),
|
|
15
|
+
documentCreate: (a, t, r, c) => e.document(
|
|
16
|
+
{ op: "create_document", title: a, path: t, scope: r },
|
|
17
|
+
c
|
|
16
18
|
),
|
|
17
|
-
documentDelete: (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
documentDelete: (a, t, r) => e.document({ op: "delete_document", id: a, scope: t }, r),
|
|
20
|
+
documentGet: (a, t, r) => e.document({ op: "get_document", id: a, scope: t }, r),
|
|
21
|
+
documentsSummary: (a, t, r) => e.document(
|
|
22
|
+
// documents_summary + document_ids are RFC BN wire additions the pinned
|
|
23
|
+
// SDK type doesn't enumerate; the /v1/_document passthrough accepts them
|
|
24
|
+
// verbatim, so cast past DocumentToolInput (same pattern as update_chunk).
|
|
25
|
+
{
|
|
26
|
+
op: "documents_summary",
|
|
27
|
+
scope: t,
|
|
28
|
+
...a.documentIds ? { document_ids: a.documentIds } : {},
|
|
29
|
+
...a.underPath ? { under_path: a.underPath } : {}
|
|
30
|
+
},
|
|
31
|
+
r
|
|
21
32
|
),
|
|
22
|
-
|
|
23
|
-
|
|
33
|
+
documentQueryChunks: (a, t, r) => e.document(
|
|
34
|
+
{ op: "query_chunks", document_id: a, scope: t, limit: 1e3 },
|
|
35
|
+
r
|
|
36
|
+
),
|
|
37
|
+
documentGetChunk: (a, t, r) => e.document({ op: "get_chunk", id: a, scope: t }, r),
|
|
38
|
+
documentGetEdges: (a, t, r) => e.document(
|
|
39
|
+
// get_edges is an RFC BN P4 wire op the pinned SDK type doesn't
|
|
40
|
+
// enumerate; the /v1/_document passthrough accepts it verbatim.
|
|
41
|
+
{ op: "get_edges", document_id: a, scope: t },
|
|
42
|
+
r
|
|
43
|
+
),
|
|
44
|
+
documentUpdateChunk: (a, t, r, c, l) => e.document(
|
|
24
45
|
// `patch.fields` is unknown but DocumentToolInput.fields is a typed
|
|
25
46
|
// Record; the cast reconciles the spread (the server accepts arbitrary
|
|
26
47
|
// JSON there). Op order + arg names mirror the wire contract exactly.
|
|
27
48
|
{
|
|
28
49
|
op: "update_chunk",
|
|
29
|
-
id:
|
|
30
|
-
revision:
|
|
31
|
-
scope:
|
|
32
|
-
...
|
|
50
|
+
id: a,
|
|
51
|
+
revision: t,
|
|
52
|
+
scope: c,
|
|
53
|
+
...r
|
|
33
54
|
},
|
|
34
|
-
|
|
55
|
+
l
|
|
35
56
|
),
|
|
36
|
-
documentExportMd: (
|
|
57
|
+
documentExportMd: (a, t, r, c) => e.document(
|
|
37
58
|
{
|
|
38
59
|
op: "export_md",
|
|
39
|
-
document_id:
|
|
40
|
-
scope:
|
|
41
|
-
include_metadata:
|
|
60
|
+
document_id: a,
|
|
61
|
+
scope: t,
|
|
62
|
+
include_metadata: r
|
|
42
63
|
},
|
|
43
|
-
|
|
64
|
+
c
|
|
44
65
|
)
|
|
45
66
|
};
|
|
46
67
|
}
|
|
47
|
-
const
|
|
48
|
-
function
|
|
49
|
-
value:
|
|
50
|
-
children:
|
|
68
|
+
const ve = Pe(null);
|
|
69
|
+
function Ge({
|
|
70
|
+
value: e,
|
|
71
|
+
children: a
|
|
51
72
|
}) {
|
|
52
|
-
return /* @__PURE__ */
|
|
73
|
+
return /* @__PURE__ */ n(ve.Provider, { value: e, children: a });
|
|
53
74
|
}
|
|
54
|
-
function
|
|
55
|
-
const
|
|
56
|
-
if (!
|
|
75
|
+
function ce() {
|
|
76
|
+
const e = Te(ve);
|
|
77
|
+
if (!e)
|
|
57
78
|
throw new Error(
|
|
58
79
|
"useExplorerData must be used within <PathExplorer> or <DocumentViewer> (no ExplorerDataLayer in context)"
|
|
59
80
|
);
|
|
60
|
-
return
|
|
61
|
-
}
|
|
62
|
-
function
|
|
63
|
-
const
|
|
64
|
-
return new
|
|
65
|
-
baseUrl:
|
|
66
|
-
authToken:
|
|
67
|
-
fetch: (
|
|
81
|
+
return e;
|
|
82
|
+
}
|
|
83
|
+
function je(e) {
|
|
84
|
+
const a = e.fetch;
|
|
85
|
+
return new Oe({
|
|
86
|
+
baseUrl: e.baseUrl,
|
|
87
|
+
authToken: e.token || void 0,
|
|
88
|
+
fetch: (t, r) => a ? a(t, r) : fetch(t, r)
|
|
68
89
|
});
|
|
69
90
|
}
|
|
70
|
-
function
|
|
71
|
-
const { dataLayer:
|
|
72
|
-
return
|
|
91
|
+
function Ne(e) {
|
|
92
|
+
const { dataLayer: a, client: t, connection: r } = e;
|
|
93
|
+
return A(() => a || (t ? he(t) : r ? he(je(r)) : null), [a, t, r?.baseUrl, r?.token, r?.fetch]);
|
|
73
94
|
}
|
|
74
|
-
function
|
|
75
|
-
theme:
|
|
76
|
-
dataLayer:
|
|
77
|
-
children:
|
|
95
|
+
function we({
|
|
96
|
+
theme: e,
|
|
97
|
+
dataLayer: a,
|
|
98
|
+
children: t
|
|
78
99
|
}) {
|
|
79
|
-
const
|
|
80
|
-
return
|
|
100
|
+
const r = e ? { "data-theme": e } : {};
|
|
101
|
+
return a ? /* @__PURE__ */ n("div", { className: "loomcycle-explorer", ...r, children: /* @__PURE__ */ n(Ge, { value: a, children: t }) }) : /* @__PURE__ */ n("div", { className: "loomcycle-explorer", ...r, children: /* @__PURE__ */ d("div", { className: "error-banner", children: [
|
|
81
102
|
"@loomcycle/explorer: provide a ",
|
|
82
|
-
/* @__PURE__ */
|
|
103
|
+
/* @__PURE__ */ n("code", { children: "connection" }),
|
|
83
104
|
", ",
|
|
84
|
-
/* @__PURE__ */
|
|
105
|
+
/* @__PURE__ */ n("code", { children: "client" }),
|
|
85
106
|
", or",
|
|
86
107
|
" ",
|
|
87
|
-
/* @__PURE__ */
|
|
108
|
+
/* @__PURE__ */ n("code", { children: "dataLayer" }),
|
|
88
109
|
" prop."
|
|
89
110
|
] }) });
|
|
90
111
|
}
|
|
91
|
-
const
|
|
92
|
-
function
|
|
93
|
-
children:
|
|
94
|
-
defaultLeftWidth:
|
|
95
|
-
minLeftWidth:
|
|
96
|
-
minRightWidth:
|
|
97
|
-
storageKey:
|
|
98
|
-
className:
|
|
112
|
+
const me = 6;
|
|
113
|
+
function Ue({
|
|
114
|
+
children: e,
|
|
115
|
+
defaultLeftWidth: a = 380,
|
|
116
|
+
minLeftWidth: t = 180,
|
|
117
|
+
minRightWidth: r = 240,
|
|
118
|
+
storageKey: c,
|
|
119
|
+
className: l
|
|
99
120
|
}) {
|
|
100
|
-
const [
|
|
101
|
-
if (
|
|
102
|
-
const
|
|
103
|
-
if (Number.isFinite(E) && E >=
|
|
121
|
+
const [s, o] = b(() => {
|
|
122
|
+
if (c) {
|
|
123
|
+
const v = localStorage.getItem(c), E = v ? parseInt(v, 10) : NaN;
|
|
124
|
+
if (Number.isFinite(E) && E >= t) return E;
|
|
104
125
|
}
|
|
105
|
-
return
|
|
106
|
-
}),
|
|
107
|
-
|
|
108
|
-
!
|
|
109
|
-
}, [
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
}, []),
|
|
113
|
-
(
|
|
114
|
-
if (!u || !
|
|
115
|
-
const E =
|
|
116
|
-
|
|
126
|
+
return a;
|
|
127
|
+
}), i = ee(null), [u, h] = b(!1);
|
|
128
|
+
I(() => {
|
|
129
|
+
!c || u || localStorage.setItem(c, String(Math.round(s)));
|
|
130
|
+
}, [c, s, u]);
|
|
131
|
+
const f = G((v) => {
|
|
132
|
+
v.preventDefault(), h(!0), v.target.setPointerCapture(v.pointerId);
|
|
133
|
+
}, []), g = G(
|
|
134
|
+
(v) => {
|
|
135
|
+
if (!u || !i.current) return;
|
|
136
|
+
const E = i.current.getBoundingClientRect(), O = v.clientX - E.left, R = E.width - r - me, j = Math.max(t, Math.min(O, R));
|
|
137
|
+
o(j);
|
|
117
138
|
},
|
|
118
|
-
[u,
|
|
119
|
-
), M =
|
|
139
|
+
[u, t, r]
|
|
140
|
+
), M = G((v) => {
|
|
120
141
|
h(!1);
|
|
121
142
|
try {
|
|
122
|
-
|
|
143
|
+
v.target.releasePointerCapture(v.pointerId);
|
|
123
144
|
} catch {
|
|
124
145
|
}
|
|
125
146
|
}, []);
|
|
126
147
|
return /* @__PURE__ */ d(
|
|
127
148
|
"div",
|
|
128
149
|
{
|
|
129
|
-
ref:
|
|
130
|
-
className: `splitter ${
|
|
150
|
+
ref: i,
|
|
151
|
+
className: `splitter ${l ?? ""} ${u ? "dragging" : ""}`,
|
|
131
152
|
style: {
|
|
132
|
-
gridTemplateColumns: `${
|
|
153
|
+
gridTemplateColumns: `${s}px ${me}px 1fr`
|
|
133
154
|
},
|
|
134
155
|
children: [
|
|
135
|
-
/* @__PURE__ */
|
|
136
|
-
/* @__PURE__ */
|
|
156
|
+
/* @__PURE__ */ n("div", { className: "splitter-pane splitter-left", children: e[0] }),
|
|
157
|
+
/* @__PURE__ */ n(
|
|
137
158
|
"div",
|
|
138
159
|
{
|
|
139
160
|
className: "splitter-handle",
|
|
140
161
|
role: "separator",
|
|
141
162
|
"aria-orientation": "vertical",
|
|
142
|
-
"aria-valuenow": Math.round(
|
|
143
|
-
onPointerDown:
|
|
144
|
-
onPointerMove:
|
|
163
|
+
"aria-valuenow": Math.round(s),
|
|
164
|
+
onPointerDown: f,
|
|
165
|
+
onPointerMove: g,
|
|
145
166
|
onPointerUp: M,
|
|
146
167
|
onPointerCancel: M
|
|
147
168
|
}
|
|
148
169
|
),
|
|
149
|
-
/* @__PURE__ */
|
|
170
|
+
/* @__PURE__ */ n("div", { className: "splitter-pane splitter-right", children: e[1] })
|
|
150
171
|
]
|
|
151
172
|
}
|
|
152
173
|
);
|
|
153
174
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
175
|
+
const se = {
|
|
176
|
+
"doc.rfc.draft": "#c99a3a",
|
|
177
|
+
"doc.rfc.review": "#6a7bd6",
|
|
178
|
+
"doc.rfc.confirmed": "#3a9ad6",
|
|
179
|
+
"doc.rfc.done": "#3aa06a",
|
|
180
|
+
"doc.document.done": "#3aa06a",
|
|
181
|
+
"doc.research.done": "#8a6ad6",
|
|
182
|
+
"doc.publication.draft": "#c99a3a",
|
|
183
|
+
"chunk.draft": "#c99a3a",
|
|
184
|
+
"chunk.review": "#6a7bd6",
|
|
185
|
+
"chunk.confirmed": "#3a9ad6",
|
|
186
|
+
"chunk.done": "#3aa06a"
|
|
187
|
+
}, Be = 0.16;
|
|
188
|
+
function ie(e) {
|
|
189
|
+
return e && Object.keys(e).length > 0 ? e : se;
|
|
190
|
+
}
|
|
191
|
+
function Ce(e, a, t) {
|
|
192
|
+
const r = e ?? "", c = a ?? "";
|
|
193
|
+
if (r && c && t[`doc.${r}.${c}`]) return t[`doc.${r}.${c}`];
|
|
194
|
+
if (r && t[`doc.${r}`]) return t[`doc.${r}`];
|
|
195
|
+
}
|
|
196
|
+
function Fe(e, a) {
|
|
197
|
+
const t = e ?? "";
|
|
198
|
+
return t ? a[`chunk.${t}`] : void 0;
|
|
199
|
+
}
|
|
200
|
+
function He(e) {
|
|
201
|
+
const a = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());
|
|
202
|
+
if (!a) return;
|
|
203
|
+
let t = a[1];
|
|
204
|
+
t.length === 3 && (t = t[0] + t[0] + t[1] + t[1] + t[2] + t[2]);
|
|
205
|
+
const r = parseInt(t.slice(0, 2), 16), c = parseInt(t.slice(2, 4), 16), l = parseInt(t.slice(4, 6), 16);
|
|
206
|
+
return `rgba(${r}, ${c}, ${l}, ${Be})`;
|
|
207
|
+
}
|
|
208
|
+
function de(e) {
|
|
209
|
+
if (!e) return;
|
|
210
|
+
const a = He(e);
|
|
211
|
+
if (a)
|
|
212
|
+
return { background: a, borderLeft: `3px solid ${e}` };
|
|
213
|
+
}
|
|
214
|
+
function We(e) {
|
|
215
|
+
const a = /* @__PURE__ */ new Map();
|
|
216
|
+
e.forEach((c) => a.set(c.id, { row: c, children: [] }));
|
|
217
|
+
const t = [];
|
|
218
|
+
e.forEach((c) => {
|
|
219
|
+
const l = a.get(c.id);
|
|
220
|
+
c.parent_id && a.has(c.parent_id) ? a.get(c.parent_id).children.push(l) : t.push(l);
|
|
161
221
|
});
|
|
162
|
-
const
|
|
163
|
-
|
|
222
|
+
const r = (c) => {
|
|
223
|
+
c.sort((l, s) => l.row.position - s.row.position), c.forEach((l) => r(l.children));
|
|
164
224
|
};
|
|
165
|
-
return
|
|
225
|
+
return r(t), t;
|
|
166
226
|
}
|
|
167
|
-
function
|
|
168
|
-
for (const
|
|
169
|
-
if (
|
|
170
|
-
const
|
|
171
|
-
if (
|
|
227
|
+
function _e(e, a) {
|
|
228
|
+
for (const t of e) {
|
|
229
|
+
if (t.row.id === a) return t;
|
|
230
|
+
const r = _e(t.children, a);
|
|
231
|
+
if (r) return r;
|
|
172
232
|
}
|
|
173
233
|
}
|
|
174
|
-
function
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
234
|
+
function ze({
|
|
235
|
+
tree: e,
|
|
236
|
+
selectedId: a,
|
|
237
|
+
onSelect: t,
|
|
238
|
+
colorEnabled: r,
|
|
239
|
+
scheme: c,
|
|
240
|
+
linkedIds: l
|
|
241
|
+
}) {
|
|
242
|
+
const [s, o] = b(() => /* @__PURE__ */ new Map()), i = G((h) => {
|
|
243
|
+
o((f) => {
|
|
244
|
+
const g = new Map(f);
|
|
245
|
+
return g.set(h, f.get(h) === !1), g;
|
|
179
246
|
});
|
|
180
247
|
}, []);
|
|
181
|
-
|
|
182
|
-
if (!
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
let
|
|
186
|
-
const
|
|
187
|
-
for (const
|
|
188
|
-
|
|
189
|
-
return
|
|
248
|
+
I(() => {
|
|
249
|
+
if (!a) return;
|
|
250
|
+
const h = Je(e, a);
|
|
251
|
+
h.length !== 0 && o((f) => {
|
|
252
|
+
let g = !1;
|
|
253
|
+
const M = new Map(f);
|
|
254
|
+
for (const v of h)
|
|
255
|
+
M.get(v) === !1 && (M.set(v, !0), g = !0);
|
|
256
|
+
return g ? M : f;
|
|
190
257
|
});
|
|
191
|
-
}, [
|
|
192
|
-
|
|
258
|
+
}, [e, a]);
|
|
259
|
+
const u = r ? ie(c) : null;
|
|
260
|
+
return e.length === 0 ? /* @__PURE__ */ n("div", { className: "empty", children: /* @__PURE__ */ n("p", { children: "No chunks." }) }) : /* @__PURE__ */ n("ul", { className: "tree chunk-tree", children: e.map((h) => /* @__PURE__ */ n(
|
|
261
|
+
xe,
|
|
193
262
|
{
|
|
194
|
-
node:
|
|
195
|
-
expanded:
|
|
196
|
-
toggle:
|
|
197
|
-
selectedId:
|
|
198
|
-
onSelect:
|
|
263
|
+
node: h,
|
|
264
|
+
expanded: s,
|
|
265
|
+
toggle: i,
|
|
266
|
+
selectedId: a,
|
|
267
|
+
onSelect: t,
|
|
268
|
+
tintScheme: u,
|
|
269
|
+
linkedIds: l
|
|
199
270
|
},
|
|
200
|
-
|
|
271
|
+
h.row.id
|
|
201
272
|
)) });
|
|
202
273
|
}
|
|
203
|
-
function
|
|
204
|
-
const
|
|
205
|
-
for (const
|
|
206
|
-
if (
|
|
207
|
-
return
|
|
208
|
-
if (
|
|
274
|
+
function Je(e, a) {
|
|
275
|
+
const t = [], r = (c, l) => {
|
|
276
|
+
for (const s of c) {
|
|
277
|
+
if (s.row.id === a)
|
|
278
|
+
return t.push(...l), !0;
|
|
279
|
+
if (r(s.children, [...l, s.row.id])) return !0;
|
|
209
280
|
}
|
|
210
281
|
return !1;
|
|
211
282
|
};
|
|
212
|
-
return
|
|
283
|
+
return r(e, []), t;
|
|
213
284
|
}
|
|
214
|
-
function
|
|
215
|
-
const
|
|
216
|
-
return /* @__PURE__ */ d("li", { className: `node chunk-node ${
|
|
217
|
-
/* @__PURE__ */ d("div", { className: "row chunk-row", children: [
|
|
218
|
-
/* @__PURE__ */
|
|
285
|
+
function xe({ node: e, expanded: a, toggle: t, selectedId: r, onSelect: c, tintScheme: l, linkedIds: s }) {
|
|
286
|
+
const o = e.children.length > 0, i = a.get(e.row.id) !== !1, u = r === e.row.id, h = l ? de(Fe(e.row.status, l)) : void 0, f = s?.has(e.row.id);
|
|
287
|
+
return /* @__PURE__ */ d("li", { className: `node chunk-node ${u ? "selected" : ""}`, children: [
|
|
288
|
+
/* @__PURE__ */ d("div", { className: "row chunk-row", style: h, children: [
|
|
289
|
+
/* @__PURE__ */ n(
|
|
219
290
|
"button",
|
|
220
291
|
{
|
|
221
292
|
type: "button",
|
|
222
293
|
className: "tree-caret",
|
|
223
|
-
"aria-label":
|
|
224
|
-
disabled: !
|
|
225
|
-
onClick: (
|
|
226
|
-
|
|
294
|
+
"aria-label": i ? "collapse" : "expand",
|
|
295
|
+
disabled: !o,
|
|
296
|
+
onClick: (g) => {
|
|
297
|
+
g.stopPropagation(), o && t(e.row.id);
|
|
227
298
|
},
|
|
228
|
-
children:
|
|
299
|
+
children: o ? i ? "▼" : "▶" : "·"
|
|
229
300
|
}
|
|
230
301
|
),
|
|
231
302
|
/* @__PURE__ */ d(
|
|
@@ -233,469 +304,695 @@ function oe({ node: a, expanded: e, toggle: r, selectedId: n, onSelect: s }) {
|
|
|
233
304
|
{
|
|
234
305
|
type: "button",
|
|
235
306
|
className: "chunk-link",
|
|
236
|
-
onClick: () =>
|
|
237
|
-
title:
|
|
307
|
+
onClick: () => c(e),
|
|
308
|
+
title: e.row.title,
|
|
238
309
|
children: [
|
|
239
|
-
/* @__PURE__ */
|
|
240
|
-
|
|
241
|
-
|
|
310
|
+
/* @__PURE__ */ n("span", { className: "chunk-title", children: e.row.title || "(untitled)" }),
|
|
311
|
+
e.row.type && /* @__PURE__ */ n("span", { className: "chunk-badge", children: e.row.type }),
|
|
312
|
+
e.row.status && /* @__PURE__ */ n("span", { className: "chunk-badge chunk-status", children: e.row.status }),
|
|
313
|
+
f && /* @__PURE__ */ n("span", { className: "chunk-link-badge", title: "Has cross-reference links", "aria-label": "linked", children: "🔗" })
|
|
242
314
|
]
|
|
243
315
|
}
|
|
244
316
|
)
|
|
245
317
|
] }),
|
|
246
|
-
|
|
247
|
-
|
|
318
|
+
o && i && /* @__PURE__ */ n("ul", { className: "children chunk-children", children: e.children.map((g) => /* @__PURE__ */ n(
|
|
319
|
+
xe,
|
|
248
320
|
{
|
|
249
|
-
node:
|
|
250
|
-
expanded:
|
|
251
|
-
toggle:
|
|
252
|
-
selectedId:
|
|
253
|
-
onSelect:
|
|
321
|
+
node: g,
|
|
322
|
+
expanded: a,
|
|
323
|
+
toggle: t,
|
|
324
|
+
selectedId: r,
|
|
325
|
+
onSelect: c,
|
|
326
|
+
tintScheme: l,
|
|
327
|
+
linkedIds: s
|
|
254
328
|
},
|
|
255
|
-
|
|
329
|
+
g.row.id
|
|
256
330
|
)) })
|
|
257
331
|
] });
|
|
258
332
|
}
|
|
259
|
-
function
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
), [
|
|
263
|
-
return /* @__PURE__ */
|
|
264
|
-
|
|
333
|
+
function Ve({ chunk: e, scope: a, browse: t, onClose: r, onSaved: c }) {
|
|
334
|
+
const l = ce(), [s, o] = b(e.title), [i, u] = b(e.type ?? ""), [h, f] = b(e.status ?? ""), [g, M] = b(e.body ?? ""), [v, E] = b(
|
|
335
|
+
e.fields ? JSON.stringify(e.fields, null, 2) : ""
|
|
336
|
+
), [O, R] = b(!1), [j, D] = b(null), [U, $] = b(!1);
|
|
337
|
+
return /* @__PURE__ */ n("div", { className: "modal-overlay", onClick: r, children: /* @__PURE__ */ d("form", { className: "modal chunk-editor", onClick: (k) => k.stopPropagation(), onSubmit: async (k) => {
|
|
338
|
+
k.preventDefault(), D(null), $(!1);
|
|
265
339
|
const N = {
|
|
266
|
-
body:
|
|
267
|
-
title:
|
|
268
|
-
type:
|
|
340
|
+
body: g,
|
|
341
|
+
title: s,
|
|
342
|
+
type: i,
|
|
269
343
|
status: h
|
|
270
344
|
};
|
|
271
|
-
if (
|
|
345
|
+
if (v.trim() !== "")
|
|
272
346
|
try {
|
|
273
|
-
N.fields = JSON.parse(
|
|
347
|
+
N.fields = JSON.parse(v);
|
|
274
348
|
} catch {
|
|
275
349
|
D("fields must be valid JSON");
|
|
276
350
|
return;
|
|
277
351
|
}
|
|
278
|
-
|
|
352
|
+
R(!0);
|
|
279
353
|
try {
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
-
} catch (
|
|
283
|
-
const
|
|
284
|
-
D(
|
|
354
|
+
const _ = await l.documentUpdateChunk(e.id, e.revision, N, a, t);
|
|
355
|
+
c(_), r();
|
|
356
|
+
} catch (_) {
|
|
357
|
+
const F = _ instanceof Error ? _.message : String(_);
|
|
358
|
+
D(F), $(/revision conflict/i.test(F)), R(!1);
|
|
285
359
|
}
|
|
286
360
|
}, children: [
|
|
287
|
-
/* @__PURE__ */
|
|
361
|
+
/* @__PURE__ */ d("div", { className: "modal-header sticky-top", children: [
|
|
362
|
+
/* @__PURE__ */ n("h3", { children: "Edit chunk" }),
|
|
363
|
+
/* @__PURE__ */ d("div", { className: "modal-buttons modal-buttons-top", children: [
|
|
364
|
+
/* @__PURE__ */ n("button", { type: "button", onClick: r, disabled: O, children: "cancel" }),
|
|
365
|
+
/* @__PURE__ */ n("button", { type: "submit", className: "primary", disabled: O, children: O ? "saving…" : "save" })
|
|
366
|
+
] })
|
|
367
|
+
] }),
|
|
368
|
+
j && /* @__PURE__ */ d("div", { className: "modal-err", children: [
|
|
369
|
+
j,
|
|
370
|
+
U && " — reopen the chunk to load the latest, then reapply your edit."
|
|
371
|
+
] }),
|
|
288
372
|
/* @__PURE__ */ d("label", { className: "path-field", children: [
|
|
289
|
-
/* @__PURE__ */
|
|
290
|
-
/* @__PURE__ */
|
|
373
|
+
/* @__PURE__ */ n("span", { children: "Title" }),
|
|
374
|
+
/* @__PURE__ */ n("input", { className: "path-modal-input", value: s, onChange: (k) => o(k.target.value) })
|
|
291
375
|
] }),
|
|
292
376
|
/* @__PURE__ */ d("div", { className: "chunk-editor-row", children: [
|
|
293
377
|
/* @__PURE__ */ d("label", { className: "path-field", children: [
|
|
294
|
-
/* @__PURE__ */
|
|
295
|
-
/* @__PURE__ */
|
|
378
|
+
/* @__PURE__ */ n("span", { children: "Type" }),
|
|
379
|
+
/* @__PURE__ */ n(
|
|
296
380
|
"input",
|
|
297
381
|
{
|
|
298
382
|
className: "path-modal-input",
|
|
299
|
-
value:
|
|
383
|
+
value: i,
|
|
300
384
|
placeholder: "(none)",
|
|
301
|
-
onChange: (
|
|
385
|
+
onChange: (k) => u(k.target.value)
|
|
302
386
|
}
|
|
303
387
|
)
|
|
304
388
|
] }),
|
|
305
389
|
/* @__PURE__ */ d("label", { className: "path-field", children: [
|
|
306
|
-
/* @__PURE__ */
|
|
307
|
-
/* @__PURE__ */
|
|
390
|
+
/* @__PURE__ */ n("span", { children: "Status" }),
|
|
391
|
+
/* @__PURE__ */ n(
|
|
308
392
|
"input",
|
|
309
393
|
{
|
|
310
394
|
className: "path-modal-input",
|
|
311
395
|
value: h,
|
|
312
396
|
placeholder: "(none)",
|
|
313
|
-
onChange: (
|
|
397
|
+
onChange: (k) => f(k.target.value)
|
|
314
398
|
}
|
|
315
399
|
)
|
|
316
400
|
] })
|
|
317
401
|
] }),
|
|
318
402
|
/* @__PURE__ */ d("label", { className: "path-field", children: [
|
|
319
|
-
/* @__PURE__ */
|
|
320
|
-
/* @__PURE__ */
|
|
403
|
+
/* @__PURE__ */ n("span", { children: "Body (Markdown)" }),
|
|
404
|
+
/* @__PURE__ */ n(
|
|
321
405
|
"textarea",
|
|
322
406
|
{
|
|
323
407
|
className: "modal-textarea chunk-body-input",
|
|
324
408
|
rows: 12,
|
|
325
|
-
value:
|
|
326
|
-
onChange: (
|
|
409
|
+
value: g,
|
|
410
|
+
onChange: (k) => M(k.target.value)
|
|
327
411
|
}
|
|
328
412
|
)
|
|
329
413
|
] }),
|
|
330
414
|
/* @__PURE__ */ d("label", { className: "path-field", children: [
|
|
331
|
-
/* @__PURE__ */
|
|
332
|
-
/* @__PURE__ */
|
|
415
|
+
/* @__PURE__ */ n("span", { children: "Fields (JSON, optional)" }),
|
|
416
|
+
/* @__PURE__ */ n(
|
|
333
417
|
"textarea",
|
|
334
418
|
{
|
|
335
419
|
className: "modal-textarea chunk-fields-input",
|
|
336
420
|
rows: 4,
|
|
337
|
-
value:
|
|
421
|
+
value: v,
|
|
338
422
|
placeholder: "{}",
|
|
339
|
-
onChange: (
|
|
423
|
+
onChange: (k) => E(k.target.value)
|
|
340
424
|
}
|
|
341
425
|
)
|
|
342
|
-
] }),
|
|
343
|
-
P && /* @__PURE__ */ d("div", { className: "modal-err", children: [
|
|
344
|
-
P,
|
|
345
|
-
W && " — reopen the chunk to load the latest, then reapply your edit."
|
|
346
|
-
] }),
|
|
347
|
-
/* @__PURE__ */ d("div", { className: "modal-buttons", children: [
|
|
348
|
-
/* @__PURE__ */ t("button", { type: "button", onClick: n, disabled: T, children: "cancel" }),
|
|
349
|
-
/* @__PURE__ */ t("button", { type: "submit", className: "primary", disabled: T, children: T ? "saving…" : "save" })
|
|
350
426
|
] })
|
|
351
427
|
] }) });
|
|
352
428
|
}
|
|
353
|
-
function
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
429
|
+
function Ze(e) {
|
|
430
|
+
const a = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec((e ?? "").trim());
|
|
431
|
+
if (!a) return "#888888";
|
|
432
|
+
let t = a[1];
|
|
433
|
+
return t.length === 3 && (t = t[0] + t[0] + t[1] + t[1] + t[2] + t[2]), "#" + t.toLowerCase();
|
|
434
|
+
}
|
|
435
|
+
function qe({
|
|
436
|
+
documentId: e,
|
|
437
|
+
rootChunkId: a,
|
|
438
|
+
docType: t,
|
|
439
|
+
docStatus: r,
|
|
440
|
+
chunkStatuses: c,
|
|
441
|
+
scope: l,
|
|
442
|
+
browse: s,
|
|
443
|
+
onClose: o,
|
|
444
|
+
onSaved: i
|
|
445
|
+
}) {
|
|
446
|
+
const u = ce(), [h, f] = b(null), [g, M] = b(!1), [v, E] = b({}), [O, R] = b(!1), [j, D] = b(null), [U, $] = b(null), J = A(() => {
|
|
447
|
+
const p = new Set(Object.keys(se));
|
|
448
|
+
t && p.add(`doc.${t}.${r || "draft"}`);
|
|
449
|
+
for (const m of c) m && p.add(`chunk.${m}`);
|
|
450
|
+
return [...p].sort();
|
|
451
|
+
}, [t, r, c]);
|
|
452
|
+
I(() => {
|
|
453
|
+
let p = !1;
|
|
454
|
+
return u.documentGetChunk(a, l, s).then((m) => {
|
|
455
|
+
if (p) return;
|
|
456
|
+
f(m);
|
|
457
|
+
const T = m.fields ?? {};
|
|
458
|
+
M(T.color_enabled === !0);
|
|
459
|
+
const S = T.color_scheme ?? {};
|
|
460
|
+
E({ ...se, ...S });
|
|
461
|
+
}).catch((m) => !p && $(m instanceof Error ? m.message : String(m))), () => {
|
|
462
|
+
p = !0;
|
|
463
|
+
};
|
|
464
|
+
}, [u, a, l, s]);
|
|
465
|
+
const k = (p, m) => E((T) => ({ ...T, [p]: m })), N = (p) => ({
|
|
466
|
+
...p ?? {},
|
|
467
|
+
color_enabled: g,
|
|
468
|
+
color_scheme: v
|
|
469
|
+
}), _ = async () => {
|
|
470
|
+
if (h) {
|
|
471
|
+
R(!0), $(null), D(null);
|
|
472
|
+
try {
|
|
473
|
+
await u.documentUpdateChunk(
|
|
474
|
+
a,
|
|
475
|
+
h.revision,
|
|
476
|
+
{ fields: N(h.fields) },
|
|
477
|
+
l,
|
|
478
|
+
s
|
|
479
|
+
), i(), o();
|
|
480
|
+
} catch (p) {
|
|
481
|
+
$(p instanceof Error ? p.message : String(p)), R(!1);
|
|
482
|
+
}
|
|
376
483
|
}
|
|
377
|
-
|
|
378
|
-
if (
|
|
379
|
-
|
|
380
|
-
|
|
484
|
+
}, F = async () => {
|
|
485
|
+
if (!t) {
|
|
486
|
+
$("this document has no type to match");
|
|
487
|
+
return;
|
|
381
488
|
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
r.push(
|
|
387
|
-
/* @__PURE__ */ t("blockquote", { children: z(h.join(" ")) }, s++)
|
|
489
|
+
R(!0), $(null), D(null);
|
|
490
|
+
try {
|
|
491
|
+
const { documents: p } = await u.documentsSummary({ underPath: "/" }, l, s), m = (p ?? []).filter(
|
|
492
|
+
(S) => S.type === t && S.document_id !== e && S.root_chunk_id
|
|
388
493
|
);
|
|
389
|
-
|
|
494
|
+
let T = 0;
|
|
495
|
+
for (const S of m)
|
|
496
|
+
try {
|
|
497
|
+
const W = await u.documentGetChunk(S.root_chunk_id, l, s);
|
|
498
|
+
await u.documentUpdateChunk(
|
|
499
|
+
S.root_chunk_id,
|
|
500
|
+
W.revision,
|
|
501
|
+
{ fields: N(W.fields) },
|
|
502
|
+
l,
|
|
503
|
+
s
|
|
504
|
+
), T++;
|
|
505
|
+
} catch {
|
|
506
|
+
}
|
|
507
|
+
D(`Applied to ${T} other ${t} document(s).`), i();
|
|
508
|
+
} catch (p) {
|
|
509
|
+
$(p instanceof Error ? p.message : String(p));
|
|
510
|
+
} finally {
|
|
511
|
+
R(!1);
|
|
390
512
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
513
|
+
}, Z = J.filter((p) => p.startsWith("doc.")), P = J.filter((p) => p.startsWith("chunk."));
|
|
514
|
+
return /* @__PURE__ */ n("div", { className: "modal-overlay", onClick: o, children: /* @__PURE__ */ d("div", { className: "modal scheme-editor", onClick: (p) => p.stopPropagation(), children: [
|
|
515
|
+
/* @__PURE__ */ d("div", { className: "scheme-editor-head", children: [
|
|
516
|
+
/* @__PURE__ */ n("h3", { children: "Document colors" }),
|
|
517
|
+
/* @__PURE__ */ d("div", { className: "scheme-editor-actions", children: [
|
|
518
|
+
/* @__PURE__ */ n("button", { type: "button", onClick: o, disabled: O, children: "cancel" }),
|
|
519
|
+
/* @__PURE__ */ n("button", { type: "button", className: "primary", onClick: () => {
|
|
520
|
+
_();
|
|
521
|
+
}, disabled: O || !h, children: O ? "saving…" : "save" })
|
|
522
|
+
] })
|
|
523
|
+
] }),
|
|
524
|
+
U && /* @__PURE__ */ n("div", { className: "modal-err", children: U }),
|
|
525
|
+
h ? /* @__PURE__ */ d(q, { children: [
|
|
526
|
+
/* @__PURE__ */ d("label", { className: "scheme-toggle", children: [
|
|
527
|
+
/* @__PURE__ */ n(
|
|
528
|
+
"input",
|
|
529
|
+
{
|
|
530
|
+
type: "checkbox",
|
|
531
|
+
checked: g,
|
|
532
|
+
onChange: (p) => M(p.target.checked)
|
|
533
|
+
}
|
|
534
|
+
),
|
|
535
|
+
/* @__PURE__ */ n("span", { children: "Enable coloring for this document" })
|
|
536
|
+
] }),
|
|
537
|
+
/* @__PURE__ */ n("p", { className: "modal-context", children: "Document rows are tinted by type + status; chunk tiles by status. Colors apply as a semi-transparent wash so text stays readable." }),
|
|
538
|
+
/* @__PURE__ */ d("div", { className: "scheme-group", children: [
|
|
539
|
+
/* @__PURE__ */ n("h4", { children: "Document (type · status)" }),
|
|
540
|
+
Z.map((p) => /* @__PURE__ */ n(pe, { label: p.slice(4), value: v[p], onChange: (m) => k(p, m) }, p))
|
|
541
|
+
] }),
|
|
542
|
+
/* @__PURE__ */ d("div", { className: "scheme-group", children: [
|
|
543
|
+
/* @__PURE__ */ n("h4", { children: "Chunks (status)" }),
|
|
544
|
+
P.map((p) => /* @__PURE__ */ n(pe, { label: p.slice(6), value: v[p], onChange: (m) => k(p, m) }, p))
|
|
545
|
+
] }),
|
|
546
|
+
/* @__PURE__ */ d("div", { className: "scheme-editor-foot", children: [
|
|
547
|
+
/* @__PURE__ */ d("button", { type: "button", onClick: () => {
|
|
548
|
+
F();
|
|
549
|
+
}, disabled: O || !t, title: t ? `Apply this palette to every other ${t} document` : "This document has no type", children: [
|
|
550
|
+
"copy to all ",
|
|
551
|
+
t || "same-type",
|
|
552
|
+
" documents"
|
|
553
|
+
] }),
|
|
554
|
+
j && /* @__PURE__ */ n("span", { className: "scheme-status", children: j })
|
|
555
|
+
] })
|
|
556
|
+
] }) : /* @__PURE__ */ n("p", { className: "modal-context", children: "Loading…" })
|
|
557
|
+
] }) });
|
|
558
|
+
}
|
|
559
|
+
function pe({ label: e, value: a, onChange: t }) {
|
|
560
|
+
const r = Ze(a);
|
|
561
|
+
return /* @__PURE__ */ d("label", { className: "scheme-row", children: [
|
|
562
|
+
/* @__PURE__ */ n("input", { type: "color", value: r, onChange: (c) => t(c.target.value) }),
|
|
563
|
+
/* @__PURE__ */ n("span", { className: "scheme-key", children: e }),
|
|
564
|
+
/* @__PURE__ */ n("code", { className: "scheme-hex", children: r })
|
|
565
|
+
] });
|
|
566
|
+
}
|
|
567
|
+
let Qe = 0;
|
|
568
|
+
function Se({ code: e }) {
|
|
569
|
+
const a = ee(null), [t, r] = b({});
|
|
570
|
+
return I(() => {
|
|
571
|
+
let c = !1;
|
|
572
|
+
return (async () => {
|
|
573
|
+
try {
|
|
574
|
+
const l = (await import("mermaid")).default, s = a.current?.closest("[data-theme]")?.getAttribute("data-theme"), o = s ? s === "dark" : !0;
|
|
575
|
+
l.initialize({ startOnLoad: !1, theme: o ? "dark" : "default", securityLevel: "strict" });
|
|
576
|
+
const { svg: i } = await l.render(`lc-mmd-${Qe++}`, e);
|
|
577
|
+
c || r({ svg: i });
|
|
578
|
+
} catch {
|
|
579
|
+
c || r({ err: !0 });
|
|
398
580
|
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
for (; n < e.length && e[n].trim() !== "" && !e[n].startsWith("```") && !/^(#{1,6})\s+/.test(e[n]) && !/^>\s?/.test(e[n]) && !i.test(e[n]) && !o.test(e[n]); )
|
|
404
|
-
u.push(e[n]), n++;
|
|
405
|
-
r.push(/* @__PURE__ */ t("p", { children: z(u.join(" ")) }, s++));
|
|
406
|
-
}
|
|
407
|
-
return r;
|
|
408
|
-
}
|
|
409
|
-
function Ee(a, e, r) {
|
|
410
|
-
switch (a) {
|
|
411
|
-
case 1:
|
|
412
|
-
return /* @__PURE__ */ t("h1", { children: e }, r);
|
|
413
|
-
case 2:
|
|
414
|
-
return /* @__PURE__ */ t("h2", { children: e }, r);
|
|
415
|
-
case 3:
|
|
416
|
-
return /* @__PURE__ */ t("h3", { children: e }, r);
|
|
417
|
-
case 4:
|
|
418
|
-
return /* @__PURE__ */ t("h4", { children: e }, r);
|
|
419
|
-
case 5:
|
|
420
|
-
return /* @__PURE__ */ t("h5", { children: e }, r);
|
|
421
|
-
default:
|
|
422
|
-
return /* @__PURE__ */ t("h6", { children: e }, r);
|
|
423
|
-
}
|
|
581
|
+
})(), () => {
|
|
582
|
+
c = !0;
|
|
583
|
+
};
|
|
584
|
+
}, [e]), t.err ? /* @__PURE__ */ n("pre", { className: "md-pre md-mermaid-error", title: "diagram failed to render", children: /* @__PURE__ */ n("code", { children: e }) }) : t.svg ? /* @__PURE__ */ n("div", { ref: a, className: "md-mermaid", dangerouslySetInnerHTML: { __html: t.svg } }) : /* @__PURE__ */ n("div", { ref: a, className: "md-mermaid md-mermaid-loading", children: "rendering diagram…" });
|
|
424
585
|
}
|
|
425
|
-
const
|
|
426
|
-
function
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
)
|
|
448
|
-
}
|
|
449
|
-
|
|
586
|
+
const oe = 24;
|
|
587
|
+
function Xe({
|
|
588
|
+
edges: e,
|
|
589
|
+
documentId: a,
|
|
590
|
+
selectedId: t,
|
|
591
|
+
onSelectChunk: r
|
|
592
|
+
}) {
|
|
593
|
+
const [c, l] = b(!1), [s, o] = b(!1);
|
|
594
|
+
if (e.length === 0) return null;
|
|
595
|
+
const i = t ? e.filter((f) => f.from_id === t || f.to_id === t) : [], u = s ? e : e.slice(0, oe), h = Ye(u);
|
|
596
|
+
return /* @__PURE__ */ d("div", { className: "doc-refs", children: [
|
|
597
|
+
t && /* @__PURE__ */ d("div", { className: "doc-refs-list-wrap", children: [
|
|
598
|
+
/* @__PURE__ */ n("h4", { children: "References" }),
|
|
599
|
+
i.length === 0 ? /* @__PURE__ */ n("p", { className: "doc-refs-empty", children: "This chunk has no links." }) : /* @__PURE__ */ n("ul", { className: "doc-refs-list", children: i.map((f, g) => /* @__PURE__ */ n(
|
|
600
|
+
Ke,
|
|
601
|
+
{
|
|
602
|
+
edge: f,
|
|
603
|
+
selectedId: t,
|
|
604
|
+
documentId: a,
|
|
605
|
+
onSelectChunk: r
|
|
606
|
+
},
|
|
607
|
+
`${f.from_id}-${f.to_id}-${f.kind}-${g}`
|
|
608
|
+
)) })
|
|
609
|
+
] }),
|
|
610
|
+
/* @__PURE__ */ d("div", { className: "doc-graph", children: [
|
|
611
|
+
/* @__PURE__ */ d("button", { type: "button", className: "doc-graph-toggle", onClick: () => l((f) => !f), children: [
|
|
612
|
+
c ? "▼" : "▶",
|
|
613
|
+
" relationship graph (",
|
|
614
|
+
e.length,
|
|
615
|
+
")"
|
|
616
|
+
] }),
|
|
617
|
+
c && /* @__PURE__ */ d(q, { children: [
|
|
618
|
+
/* @__PURE__ */ n(Se, { code: h }),
|
|
619
|
+
e.length > oe && /* @__PURE__ */ n("button", { type: "button", className: "doc-graph-more", onClick: () => o((f) => !f), children: s ? `show top ${oe}` : `show all ${e.length}` })
|
|
620
|
+
] })
|
|
621
|
+
] })
|
|
622
|
+
] });
|
|
623
|
+
}
|
|
624
|
+
function Ke({
|
|
625
|
+
edge: e,
|
|
626
|
+
selectedId: a,
|
|
627
|
+
documentId: t,
|
|
628
|
+
onSelectChunk: r
|
|
629
|
+
}) {
|
|
630
|
+
const c = e.from_id === a, l = c ? e.to_id : e.from_id, s = (c ? e.to_title : e.from_title) || l.slice(0, 8), o = c ? e.to_document_id : e.from_document_id, i = !o || o === t;
|
|
631
|
+
return /* @__PURE__ */ d("li", { className: "doc-ref", children: [
|
|
632
|
+
/* @__PURE__ */ n("span", { className: "doc-ref-kind", children: e.kind }),
|
|
633
|
+
/* @__PURE__ */ n("span", { className: "doc-ref-arrow", "aria-hidden": !0, children: c ? "→" : "←" }),
|
|
634
|
+
i ? /* @__PURE__ */ n("button", { type: "button", className: "doc-ref-target", onClick: () => r(l), children: s }) : /* @__PURE__ */ d("span", { className: "doc-ref-target external", title: "In another document", children: [
|
|
635
|
+
s,
|
|
636
|
+
" ↗"
|
|
637
|
+
] })
|
|
638
|
+
] });
|
|
639
|
+
}
|
|
640
|
+
function Ye(e) {
|
|
641
|
+
const a = ["graph LR"];
|
|
642
|
+
for (const t of e) {
|
|
643
|
+
const r = `${fe(t.from_id)}["${be(t.from_title, t.from_id)}"]`, c = `${fe(t.to_id)}["${be(t.to_title, t.to_id)}"]`, l = (t.kind || "link").replace(/[|"]/g, " ");
|
|
644
|
+
a.push(` ${r} -->|${l}| ${c}`);
|
|
450
645
|
}
|
|
451
|
-
return
|
|
646
|
+
return a.join(`
|
|
647
|
+
`);
|
|
452
648
|
}
|
|
453
|
-
function
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
649
|
+
function fe(e) {
|
|
650
|
+
return "n" + e.replace(/[^a-zA-Z0-9]/g, "");
|
|
651
|
+
}
|
|
652
|
+
function be(e, a) {
|
|
653
|
+
const r = (e ?? "").replace(/["[\]{}|<>]/g, " ").replace(/\s+/g, " ").trim() || a.slice(0, 6);
|
|
654
|
+
return r.length > 30 ? r.slice(0, 29) + "…" : r;
|
|
655
|
+
}
|
|
656
|
+
function ye({ source: e }) {
|
|
657
|
+
return /* @__PURE__ */ n("div", { className: "md", children: /* @__PURE__ */ n(Ie, { remarkPlugins: [Ae], components: et, children: e }) });
|
|
658
|
+
}
|
|
659
|
+
const et = {
|
|
660
|
+
// react-markdown already sanitized the href; add target/rel for external links.
|
|
661
|
+
a({ href: e, children: a }) {
|
|
662
|
+
const t = e ?? "", r = /^https?:\/\//i.test(t);
|
|
663
|
+
return /* @__PURE__ */ n("a", { href: t, target: r ? "_blank" : void 0, rel: r ? "noopener noreferrer" : void 0, children: a });
|
|
664
|
+
},
|
|
665
|
+
// Let the code renderer own the block wrapper so a mermaid fence isn't wrapped
|
|
666
|
+
// in a <pre> (and a normal code block gets exactly one <pre>).
|
|
667
|
+
pre({ children: e }) {
|
|
668
|
+
return /* @__PURE__ */ n(q, { children: e });
|
|
669
|
+
},
|
|
670
|
+
code({ className: e, children: a }) {
|
|
671
|
+
const t = /language-(\w+)/.exec(e ?? "")?.[1], r = String(a ?? "");
|
|
672
|
+
return t === "mermaid" ? /* @__PURE__ */ n(Se, { code: r.replace(/\n$/, "") }) : t || r.includes(`
|
|
673
|
+
`) ? /* @__PURE__ */ n("pre", { className: "md-pre", children: /* @__PURE__ */ n("code", { className: e, children: a }) }) : /* @__PURE__ */ n("code", { children: a });
|
|
674
|
+
}
|
|
675
|
+
};
|
|
676
|
+
function Ee({
|
|
677
|
+
documentId: e,
|
|
678
|
+
scope: a,
|
|
679
|
+
titleHint: t,
|
|
680
|
+
browse: r,
|
|
681
|
+
principal: c,
|
|
682
|
+
renderAssistant: l
|
|
460
683
|
}) {
|
|
461
|
-
const
|
|
462
|
-
() =>
|
|
463
|
-
[
|
|
464
|
-
), [
|
|
465
|
-
() => !!
|
|
466
|
-
[
|
|
684
|
+
const s = ce(), o = A(
|
|
685
|
+
() => r && (r.scopeId || r.tenant) ? { scopeId: r.scopeId, tenant: r.tenant } : void 0,
|
|
686
|
+
[r?.scopeId, r?.tenant]
|
|
687
|
+
), [i, u] = b([]), [h, f] = b(void 0), [g, M] = b(null), [v, E] = b("chunks"), [O, R] = b(null), [j, D] = b(null), [U, $] = b(null), [J, k] = b(!1), [N, _] = b(0), [F, Z] = b(!1), [P, p] = b(null), [m, T] = b(!1), [S, W] = b([]), Q = G(() => _((y) => y + 1), []), X = A(() => We(i), [i]), K = A(() => i.find((C) => !C.parent_id)?.title || t || "document", [i, t]), te = A(
|
|
688
|
+
() => !!g && !g.parent_id,
|
|
689
|
+
[g]
|
|
690
|
+
), Y = A(
|
|
691
|
+
() => P?.root_chunk_id ?? i.find((y) => !y.parent_id)?.id,
|
|
692
|
+
[P, i]
|
|
693
|
+
), w = A(
|
|
694
|
+
() => [...new Set(i.map((y) => y.status).filter((y) => !!y))],
|
|
695
|
+
[i]
|
|
696
|
+
), x = !!P?.color_enabled, L = A(() => {
|
|
697
|
+
const y = /* @__PURE__ */ new Set();
|
|
698
|
+
for (const C of S)
|
|
699
|
+
y.add(C.from_id), y.add(C.to_id);
|
|
700
|
+
return y;
|
|
701
|
+
}, [S]), H = A(
|
|
702
|
+
() => x ? de(Ce(P?.type, P?.status, ie(P?.color_scheme))) : void 0,
|
|
703
|
+
[x, P?.type, P?.status, P?.color_scheme]
|
|
467
704
|
);
|
|
468
|
-
|
|
469
|
-
let
|
|
470
|
-
return
|
|
471
|
-
if (
|
|
472
|
-
const
|
|
473
|
-
u(
|
|
474
|
-
}).catch((
|
|
475
|
-
|
|
705
|
+
I(() => {
|
|
706
|
+
let y = !1;
|
|
707
|
+
return k(!0), $(null), s.documentQueryChunks(e, a, o).then((C) => {
|
|
708
|
+
if (y) return;
|
|
709
|
+
const z = C.chunks ?? [];
|
|
710
|
+
u(z), f((V) => V ?? z.find((B) => !B.parent_id)?.id);
|
|
711
|
+
}).catch((C) => !y && $(C instanceof Error ? C.message : String(C))).finally(() => !y && k(!1)), () => {
|
|
712
|
+
y = !0;
|
|
713
|
+
};
|
|
714
|
+
}, [s, e, a, N, o]), I(() => {
|
|
715
|
+
let y = !1;
|
|
716
|
+
return s.documentGet(e, a, o).then((C) => !y && p(C)).catch(() => !y && p(null)), () => {
|
|
717
|
+
y = !0;
|
|
718
|
+
};
|
|
719
|
+
}, [s, e, a, N, o]), I(() => {
|
|
720
|
+
let y = !1;
|
|
721
|
+
return s.documentGetEdges(e, a, o).then((C) => !y && W(C.edges ?? [])).catch(() => !y && W([])), () => {
|
|
722
|
+
y = !0;
|
|
476
723
|
};
|
|
477
|
-
}, [
|
|
478
|
-
|
|
479
|
-
}, [
|
|
724
|
+
}, [s, e, a, N, o]), I(() => {
|
|
725
|
+
f(void 0), M(null), R(null), E("chunks"), p(null), W([]);
|
|
726
|
+
}, [e, a]), I(() => {
|
|
480
727
|
if (!h) {
|
|
481
728
|
M(null);
|
|
482
729
|
return;
|
|
483
730
|
}
|
|
484
|
-
let
|
|
485
|
-
return
|
|
486
|
-
|
|
731
|
+
let y = !1;
|
|
732
|
+
return s.documentGetChunk(h, a, o).then((C) => !y && M(C)).catch((C) => !y && $(C instanceof Error ? C.message : String(C))), () => {
|
|
733
|
+
y = !0;
|
|
487
734
|
};
|
|
488
|
-
}, [
|
|
489
|
-
if (
|
|
490
|
-
|
|
735
|
+
}, [s, h, a, N, o]), I(() => {
|
|
736
|
+
if (v !== "markdown" || !h) {
|
|
737
|
+
R(null);
|
|
491
738
|
return;
|
|
492
739
|
}
|
|
493
|
-
const
|
|
494
|
-
if (!
|
|
495
|
-
let
|
|
496
|
-
const
|
|
497
|
-
|
|
740
|
+
const y = _e(X, h);
|
|
741
|
+
if (!y) return;
|
|
742
|
+
let C = !1;
|
|
743
|
+
const z = [], V = (B, ae) => {
|
|
744
|
+
z.push({ node: B, depth: ae }), B.children.forEach((re) => V(re, ae + 1));
|
|
498
745
|
};
|
|
499
|
-
return
|
|
500
|
-
if (
|
|
501
|
-
const
|
|
502
|
-
const
|
|
503
|
-
return "#".repeat(
|
|
746
|
+
return V(y, 0), Promise.all(z.map((B) => s.documentGetChunk(B.node.row.id, a, o))).then((B) => {
|
|
747
|
+
if (C) return;
|
|
748
|
+
const ae = z.map((re, Le) => {
|
|
749
|
+
const Re = Math.min(re.depth + 1, 6), ue = B[Le];
|
|
750
|
+
return "#".repeat(Re) + " " + re.node.row.title + (ue.body ? `
|
|
504
751
|
|
|
505
|
-
` +
|
|
752
|
+
` + ue.body : "") + `
|
|
506
753
|
`;
|
|
507
754
|
}).join(`
|
|
508
755
|
`);
|
|
509
|
-
|
|
510
|
-
}).catch((
|
|
511
|
-
|
|
756
|
+
R(ae);
|
|
757
|
+
}).catch((B) => !C && $(B instanceof Error ? B.message : String(B))), () => {
|
|
758
|
+
C = !0;
|
|
512
759
|
};
|
|
513
|
-
}, [
|
|
514
|
-
const
|
|
760
|
+
}, [s, v, h, X, a, N, o]);
|
|
761
|
+
const ne = G((y) => f(y.row.id), []), De = G(async () => {
|
|
515
762
|
try {
|
|
516
|
-
const
|
|
517
|
-
|
|
518
|
-
} catch (
|
|
519
|
-
|
|
763
|
+
const y = await s.documentExportMd(e, a, !0, o), C = new Blob([y.markdown], { type: "text/markdown" }), z = URL.createObjectURL(C), V = document.createElement("a");
|
|
764
|
+
V.href = z, V.download = (y.title || "document").replace(/[^\w.-]+/g, "_") + ".md", V.click(), URL.revokeObjectURL(z);
|
|
765
|
+
} catch (y) {
|
|
766
|
+
$(y instanceof Error ? y.message : String(y));
|
|
520
767
|
}
|
|
521
|
-
}, [
|
|
768
|
+
}, [s, e, a, o]);
|
|
522
769
|
return /* @__PURE__ */ d("div", { className: "doc-viewer", children: [
|
|
523
|
-
/* @__PURE__ */ d("div", { className: "doc-toolbar", children: [
|
|
524
|
-
/* @__PURE__ */
|
|
770
|
+
/* @__PURE__ */ d("div", { className: "doc-toolbar", style: H, children: [
|
|
771
|
+
/* @__PURE__ */ n("strong", { className: "doc-title", title: K, children: K }),
|
|
525
772
|
/* @__PURE__ */ d("div", { className: "doc-toolbar-actions", children: [
|
|
526
|
-
/* @__PURE__ */
|
|
527
|
-
|
|
773
|
+
/* @__PURE__ */ n(
|
|
774
|
+
"button",
|
|
775
|
+
{
|
|
776
|
+
type: "button",
|
|
777
|
+
className: x ? "active" : "",
|
|
778
|
+
onClick: () => T(!0),
|
|
779
|
+
disabled: !Y,
|
|
780
|
+
title: "Colors — tint chunk tiles + the Path tree by type/status",
|
|
781
|
+
children: "colors"
|
|
782
|
+
}
|
|
783
|
+
),
|
|
784
|
+
/* @__PURE__ */ n("button", { type: "button", onClick: () => {
|
|
785
|
+
De();
|
|
528
786
|
}, title: "Download the whole document as Markdown (.md)", children: "↓ .md" }),
|
|
529
|
-
|
|
787
|
+
l && /* @__PURE__ */ n(
|
|
530
788
|
"button",
|
|
531
789
|
{
|
|
532
790
|
type: "button",
|
|
533
|
-
className:
|
|
534
|
-
onClick: () =>
|
|
791
|
+
className: F ? "active" : "",
|
|
792
|
+
onClick: () => Z((y) => !y),
|
|
535
793
|
title: "Document Assistant — instruct an agent to restructure/import/link chunks",
|
|
536
794
|
children: "assistant"
|
|
537
795
|
}
|
|
538
796
|
),
|
|
539
|
-
/* @__PURE__ */
|
|
797
|
+
/* @__PURE__ */ n("button", { type: "button", onClick: Q, title: "Reload", children: "↻" })
|
|
540
798
|
] })
|
|
541
799
|
] }),
|
|
542
|
-
|
|
800
|
+
U && /* @__PURE__ */ n("div", { className: "paths-err", children: U }),
|
|
543
801
|
/* @__PURE__ */ d("div", { className: "doc-split", children: [
|
|
544
|
-
/* @__PURE__ */
|
|
545
|
-
|
|
802
|
+
/* @__PURE__ */ n("div", { className: "doc-chunktree", children: J && i.length === 0 ? /* @__PURE__ */ n("div", { className: "empty", children: /* @__PURE__ */ n("p", { children: "Loading…" }) }) : /* @__PURE__ */ n(
|
|
803
|
+
ze,
|
|
804
|
+
{
|
|
805
|
+
tree: X,
|
|
806
|
+
selectedId: h,
|
|
807
|
+
onSelect: ne,
|
|
808
|
+
colorEnabled: x,
|
|
809
|
+
scheme: P?.color_scheme,
|
|
810
|
+
linkedIds: L
|
|
811
|
+
}
|
|
812
|
+
) }),
|
|
813
|
+
/* @__PURE__ */ n("div", { className: "doc-content", children: g ? /* @__PURE__ */ d(q, { children: [
|
|
546
814
|
/* @__PURE__ */ d("div", { className: "doc-content-head", children: [
|
|
547
|
-
/* @__PURE__ */
|
|
815
|
+
/* @__PURE__ */ n("h3", { children: g.title || "(untitled)" }),
|
|
548
816
|
/* @__PURE__ */ d("div", { className: "doc-content-meta", children: [
|
|
549
|
-
|
|
550
|
-
|
|
817
|
+
g.type && /* @__PURE__ */ n("span", { className: "chunk-badge", children: g.type }),
|
|
818
|
+
g.status && /* @__PURE__ */ n("span", { className: "chunk-badge chunk-status", children: g.status }),
|
|
551
819
|
/* @__PURE__ */ d("span", { className: "chunk-rev", children: [
|
|
552
820
|
"rev ",
|
|
553
|
-
|
|
821
|
+
g.revision
|
|
554
822
|
] })
|
|
555
823
|
] }),
|
|
556
824
|
/* @__PURE__ */ d("div", { className: "doc-content-controls", children: [
|
|
557
825
|
/* @__PURE__ */ d("div", { className: "doc-mode-toggle", children: [
|
|
558
|
-
/* @__PURE__ */
|
|
826
|
+
/* @__PURE__ */ n(
|
|
559
827
|
"button",
|
|
560
828
|
{
|
|
561
829
|
type: "button",
|
|
562
|
-
className:
|
|
830
|
+
className: v === "chunks" ? "active" : "",
|
|
563
831
|
onClick: () => E("chunks"),
|
|
564
832
|
title: "This chunk's own content",
|
|
565
833
|
children: "chunk"
|
|
566
834
|
}
|
|
567
835
|
),
|
|
568
|
-
/* @__PURE__ */
|
|
836
|
+
/* @__PURE__ */ n(
|
|
569
837
|
"button",
|
|
570
838
|
{
|
|
571
839
|
type: "button",
|
|
572
|
-
className:
|
|
840
|
+
className: v === "markdown" ? "active" : "",
|
|
573
841
|
onClick: () => E("markdown"),
|
|
574
|
-
title:
|
|
842
|
+
title: te ? "Whole document as Markdown" : "This chunk + its sub-chunks as Markdown",
|
|
575
843
|
children: "markdown"
|
|
576
844
|
}
|
|
577
845
|
)
|
|
578
846
|
] }),
|
|
579
|
-
/* @__PURE__ */
|
|
847
|
+
/* @__PURE__ */ n("button", { type: "button", onClick: () => D(g), children: "edit" })
|
|
580
848
|
] })
|
|
581
849
|
] }),
|
|
582
|
-
/* @__PURE__ */
|
|
583
|
-
|
|
850
|
+
/* @__PURE__ */ n("div", { className: "doc-content-body", children: v === "markdown" ? O !== null ? /* @__PURE__ */ n(ye, { source: O }) : /* @__PURE__ */ n("p", { className: "doc-empty-body", children: "Assembling Markdown…" }) : g.body ? /* @__PURE__ */ n(ye, { source: g.body }) : /* @__PURE__ */ n("p", { className: "doc-empty-body", children: "(empty chunk)" }) }),
|
|
851
|
+
/* @__PURE__ */ n(
|
|
852
|
+
Xe,
|
|
853
|
+
{
|
|
854
|
+
edges: S,
|
|
855
|
+
documentId: e,
|
|
856
|
+
selectedId: h,
|
|
857
|
+
onSelectChunk: f
|
|
858
|
+
}
|
|
859
|
+
)
|
|
860
|
+
] }) : /* @__PURE__ */ n("div", { className: "empty", children: /* @__PURE__ */ n("p", { children: "Select a chunk on the left." }) }) })
|
|
584
861
|
] }),
|
|
585
|
-
|
|
586
|
-
documentId:
|
|
587
|
-
scope:
|
|
588
|
-
subject:
|
|
862
|
+
F && l && /* @__PURE__ */ n("div", { className: "doc-assistant", children: l({
|
|
863
|
+
documentId: e,
|
|
864
|
+
scope: a,
|
|
865
|
+
subject: c?.subject,
|
|
589
866
|
// Pass the viewer's own reload so the injected assistant can refresh
|
|
590
867
|
// the tree + selected chunk after a turn mutates the document.
|
|
591
|
-
onChanged:
|
|
868
|
+
onChanged: Q
|
|
592
869
|
}) }),
|
|
593
|
-
|
|
594
|
-
|
|
870
|
+
j && /* @__PURE__ */ n(
|
|
871
|
+
Ve,
|
|
595
872
|
{
|
|
596
|
-
chunk:
|
|
597
|
-
scope:
|
|
598
|
-
browse:
|
|
873
|
+
chunk: j,
|
|
874
|
+
scope: a,
|
|
875
|
+
browse: o,
|
|
599
876
|
onClose: () => D(null),
|
|
600
|
-
onSaved:
|
|
877
|
+
onSaved: Q
|
|
878
|
+
}
|
|
879
|
+
),
|
|
880
|
+
m && Y && /* @__PURE__ */ n(
|
|
881
|
+
qe,
|
|
882
|
+
{
|
|
883
|
+
documentId: e,
|
|
884
|
+
rootChunkId: Y,
|
|
885
|
+
docType: P?.type,
|
|
886
|
+
docStatus: P?.status,
|
|
887
|
+
chunkStatuses: w,
|
|
888
|
+
scope: a,
|
|
889
|
+
browse: o,
|
|
890
|
+
onClose: () => T(!1),
|
|
891
|
+
onSaved: Q
|
|
601
892
|
}
|
|
602
893
|
)
|
|
603
894
|
] });
|
|
604
895
|
}
|
|
605
|
-
function
|
|
606
|
-
const
|
|
896
|
+
function tt(e) {
|
|
897
|
+
const a = {
|
|
607
898
|
name: "",
|
|
608
899
|
fullPath: "",
|
|
609
900
|
kind: "directory",
|
|
610
901
|
explicit: !0,
|
|
611
902
|
children: []
|
|
612
|
-
},
|
|
613
|
-
const
|
|
614
|
-
if (
|
|
615
|
-
const
|
|
903
|
+
}, t = /* @__PURE__ */ new Map([["", a]]), r = (l) => {
|
|
904
|
+
const s = t.get(l);
|
|
905
|
+
if (s) return s;
|
|
906
|
+
const o = l.lastIndexOf("/"), i = o <= 0 ? "" : l.slice(0, o), u = l.slice(o + 1), h = r(i), f = {
|
|
616
907
|
name: u,
|
|
617
|
-
fullPath:
|
|
908
|
+
fullPath: l,
|
|
618
909
|
kind: "directory",
|
|
619
910
|
explicit: !1,
|
|
620
911
|
children: []
|
|
621
912
|
};
|
|
622
|
-
return h.children.push(
|
|
913
|
+
return h.children.push(f), t.set(l, f), f;
|
|
623
914
|
};
|
|
624
|
-
for (const
|
|
625
|
-
const
|
|
626
|
-
|
|
915
|
+
for (const l of e) {
|
|
916
|
+
const s = r(l.full_path);
|
|
917
|
+
s.kind = l.kind, s.explicit = !0, s.resourceRef = l.resource_ref;
|
|
627
918
|
}
|
|
628
|
-
const
|
|
629
|
-
|
|
630
|
-
const
|
|
631
|
-
return
|
|
632
|
-
}),
|
|
919
|
+
const c = (l) => {
|
|
920
|
+
l.sort((s, o) => {
|
|
921
|
+
const i = s.kind === "directory", u = o.kind === "directory";
|
|
922
|
+
return i !== u ? i ? -1 : 1 : s.name.localeCompare(o.name);
|
|
923
|
+
}), l.forEach((s) => c(s.children));
|
|
633
924
|
};
|
|
634
|
-
return
|
|
925
|
+
return c(a.children), a.children;
|
|
635
926
|
}
|
|
636
|
-
function
|
|
637
|
-
const
|
|
638
|
-
return
|
|
927
|
+
function le(e) {
|
|
928
|
+
const a = e.lastIndexOf("/");
|
|
929
|
+
return a <= 0 ? "" : e.slice(0, a);
|
|
639
930
|
}
|
|
640
|
-
function
|
|
641
|
-
const
|
|
642
|
-
if (
|
|
643
|
-
const
|
|
644
|
-
|
|
931
|
+
function nt(e) {
|
|
932
|
+
const a = [], t = (r) => {
|
|
933
|
+
if (r.kind === "document") {
|
|
934
|
+
const c = r.resourceRef;
|
|
935
|
+
c?.document_id && a.push(c.document_id);
|
|
645
936
|
}
|
|
646
|
-
|
|
937
|
+
r.children.forEach(t);
|
|
647
938
|
};
|
|
648
|
-
return
|
|
939
|
+
return t(e), a;
|
|
649
940
|
}
|
|
650
|
-
const
|
|
941
|
+
const at = {
|
|
651
942
|
directory: "📁",
|
|
652
943
|
document: "📄",
|
|
653
944
|
volume_mount: "💾",
|
|
654
945
|
memory_entry: "🧠"
|
|
655
946
|
};
|
|
656
|
-
function
|
|
657
|
-
const [
|
|
658
|
-
|
|
659
|
-
const
|
|
660
|
-
return
|
|
947
|
+
function rt({ tree: e, selectedPath: a, onSelect: t, summaries: r }) {
|
|
948
|
+
const [c, l] = b(() => /* @__PURE__ */ new Map()), s = G((o) => {
|
|
949
|
+
l((i) => {
|
|
950
|
+
const u = new Map(i);
|
|
951
|
+
return u.set(o, i.get(o) === !1), u;
|
|
661
952
|
});
|
|
662
953
|
}, []);
|
|
663
|
-
return
|
|
664
|
-
|
|
954
|
+
return I(() => {
|
|
955
|
+
a && l((o) => {
|
|
665
956
|
let i = !1;
|
|
666
|
-
const
|
|
667
|
-
let
|
|
668
|
-
for (;
|
|
669
|
-
|
|
670
|
-
return i ?
|
|
957
|
+
const u = new Map(o);
|
|
958
|
+
let h = le(a);
|
|
959
|
+
for (; h !== ""; )
|
|
960
|
+
u.get(h) === !1 && (u.set(h, !0), i = !0), h = le(h);
|
|
961
|
+
return i ? u : o;
|
|
671
962
|
});
|
|
672
|
-
}, [
|
|
673
|
-
|
|
963
|
+
}, [a]), e.length === 0 ? /* @__PURE__ */ n("div", { className: "empty", children: /* @__PURE__ */ n("p", { children: "This tree is empty. Create a folder or document to begin." }) }) : /* @__PURE__ */ n("ul", { className: "tree path-tree", children: e.map((o) => /* @__PURE__ */ n(
|
|
964
|
+
$e,
|
|
674
965
|
{
|
|
675
|
-
node:
|
|
676
|
-
expanded:
|
|
677
|
-
toggle:
|
|
678
|
-
selectedPath:
|
|
679
|
-
onSelect:
|
|
966
|
+
node: o,
|
|
967
|
+
expanded: c,
|
|
968
|
+
toggle: s,
|
|
969
|
+
selectedPath: a,
|
|
970
|
+
onSelect: t,
|
|
971
|
+
summaries: r
|
|
680
972
|
},
|
|
681
|
-
|
|
973
|
+
o.fullPath
|
|
682
974
|
)) });
|
|
683
975
|
}
|
|
684
|
-
function
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
976
|
+
function ct(e, a) {
|
|
977
|
+
if (e.kind !== "document" || !a) return;
|
|
978
|
+
const t = e.resourceRef;
|
|
979
|
+
return t?.document_id ? a.get(t.document_id) : void 0;
|
|
980
|
+
}
|
|
981
|
+
function $e({ node: e, expanded: a, toggle: t, selectedPath: r, onSelect: c, summaries: l }) {
|
|
982
|
+
const s = e.children.length > 0, o = a.get(e.fullPath) !== !1, i = r === e.fullPath, u = ct(e, l), h = u && u.color_enabled ? de(Ce(u.type, u.status, ie(u.color_scheme))) : void 0;
|
|
983
|
+
return /* @__PURE__ */ d("li", { className: `node path-node kind-${e.kind} ${i ? "selected" : ""}`, children: [
|
|
984
|
+
/* @__PURE__ */ d("div", { className: "row path-row", style: h, children: [
|
|
985
|
+
/* @__PURE__ */ n(
|
|
689
986
|
"button",
|
|
690
987
|
{
|
|
691
988
|
type: "button",
|
|
692
989
|
className: "tree-caret",
|
|
693
|
-
"aria-label":
|
|
694
|
-
disabled: !
|
|
695
|
-
onClick: (
|
|
696
|
-
|
|
990
|
+
"aria-label": o ? "collapse" : "expand",
|
|
991
|
+
disabled: !s,
|
|
992
|
+
onClick: (f) => {
|
|
993
|
+
f.stopPropagation(), s && t(e.fullPath);
|
|
697
994
|
},
|
|
698
|
-
children:
|
|
995
|
+
children: s ? o ? "▼" : "▶" : "·"
|
|
699
996
|
}
|
|
700
997
|
),
|
|
701
998
|
/* @__PURE__ */ d(
|
|
@@ -703,136 +1000,162 @@ function de({ node: a, expanded: e, toggle: r, selectedPath: n, onSelect: s }) {
|
|
|
703
1000
|
{
|
|
704
1001
|
type: "button",
|
|
705
1002
|
className: "path-link",
|
|
706
|
-
onClick: () =>
|
|
707
|
-
title:
|
|
1003
|
+
onClick: () => c(e),
|
|
1004
|
+
title: e.fullPath,
|
|
708
1005
|
children: [
|
|
709
|
-
/* @__PURE__ */
|
|
710
|
-
/* @__PURE__ */
|
|
711
|
-
|
|
1006
|
+
/* @__PURE__ */ n("span", { className: "path-kind-icon", "aria-hidden": !0, children: at[e.kind] ?? "•" }),
|
|
1007
|
+
/* @__PURE__ */ n("span", { className: "path-name", children: e.name }),
|
|
1008
|
+
u?.type && /* @__PURE__ */ n("span", { className: "chunk-badge", children: u.type }),
|
|
1009
|
+
u?.status && /* @__PURE__ */ n("span", { className: "chunk-badge chunk-status", children: u.status }),
|
|
1010
|
+
!e.explicit && /* @__PURE__ */ n("span", { className: "path-implicit", title: "Implicit directory (no stored entry)", children: "implicit" })
|
|
712
1011
|
]
|
|
713
1012
|
}
|
|
714
1013
|
)
|
|
715
1014
|
] }),
|
|
716
|
-
|
|
717
|
-
|
|
1015
|
+
s && o && /* @__PURE__ */ n("ul", { className: "children path-children", children: e.children.map((f) => /* @__PURE__ */ n(
|
|
1016
|
+
$e,
|
|
718
1017
|
{
|
|
719
|
-
node:
|
|
720
|
-
expanded:
|
|
721
|
-
toggle:
|
|
722
|
-
selectedPath:
|
|
723
|
-
onSelect:
|
|
1018
|
+
node: f,
|
|
1019
|
+
expanded: a,
|
|
1020
|
+
toggle: t,
|
|
1021
|
+
selectedPath: r,
|
|
1022
|
+
onSelect: c,
|
|
1023
|
+
summaries: l
|
|
724
1024
|
},
|
|
725
|
-
|
|
1025
|
+
f.fullPath
|
|
726
1026
|
)) })
|
|
727
1027
|
] });
|
|
728
1028
|
}
|
|
729
|
-
const
|
|
730
|
-
function
|
|
731
|
-
return `${
|
|
1029
|
+
const ge = /^[A-Za-z0-9._-]+$/;
|
|
1030
|
+
function ke(e, a) {
|
|
1031
|
+
return `${e}/${a}`;
|
|
732
1032
|
}
|
|
733
|
-
function
|
|
734
|
-
for (const
|
|
735
|
-
if (
|
|
736
|
-
const
|
|
737
|
-
if (
|
|
1033
|
+
function Me(e, a) {
|
|
1034
|
+
for (const t of e) {
|
|
1035
|
+
if (t.fullPath === a) return t;
|
|
1036
|
+
const r = Me(t.children, a);
|
|
1037
|
+
if (r) return r;
|
|
738
1038
|
}
|
|
739
1039
|
}
|
|
740
|
-
function
|
|
741
|
-
const { theme:
|
|
742
|
-
return /* @__PURE__ */
|
|
743
|
-
|
|
1040
|
+
function mt(e) {
|
|
1041
|
+
const { theme: a, defaultScope: t, path: r, onPathChange: c, browse: l, principal: s, renderAssistant: o, onError: i } = e, u = Ne(e);
|
|
1042
|
+
return /* @__PURE__ */ n(we, { theme: a, dataLayer: u, children: /* @__PURE__ */ n(
|
|
1043
|
+
ot,
|
|
744
1044
|
{
|
|
745
|
-
defaultScope:
|
|
746
|
-
path:
|
|
747
|
-
onPathChange:
|
|
748
|
-
browse:
|
|
749
|
-
principal:
|
|
750
|
-
renderAssistant:
|
|
751
|
-
onError:
|
|
1045
|
+
defaultScope: t,
|
|
1046
|
+
path: r,
|
|
1047
|
+
onPathChange: c,
|
|
1048
|
+
browse: l,
|
|
1049
|
+
principal: s,
|
|
1050
|
+
renderAssistant: o,
|
|
1051
|
+
onError: i
|
|
752
1052
|
}
|
|
753
1053
|
) });
|
|
754
1054
|
}
|
|
755
|
-
function
|
|
756
|
-
defaultScope:
|
|
757
|
-
path:
|
|
758
|
-
onPathChange:
|
|
759
|
-
browse:
|
|
760
|
-
principal:
|
|
761
|
-
renderAssistant:
|
|
762
|
-
onError:
|
|
1055
|
+
function ot({
|
|
1056
|
+
defaultScope: e,
|
|
1057
|
+
path: a,
|
|
1058
|
+
onPathChange: t,
|
|
1059
|
+
browse: r,
|
|
1060
|
+
principal: c,
|
|
1061
|
+
renderAssistant: l,
|
|
1062
|
+
onError: s
|
|
763
1063
|
}) {
|
|
764
|
-
const
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
}, [
|
|
768
|
-
const
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
}, [
|
|
772
|
-
const
|
|
773
|
-
|
|
774
|
-
}, []), N =
|
|
775
|
-
() =>
|
|
776
|
-
[
|
|
777
|
-
),
|
|
778
|
-
|
|
1064
|
+
const o = ce(), [i, u] = b(e ?? "user"), [h, f] = b([]), [g, M] = b(void 0), [v, E] = b(null), [O, R] = b(!1), [j, D] = b(null), U = a !== void 0 ? a : g, $ = ee(t);
|
|
1065
|
+
I(() => {
|
|
1066
|
+
$.current = t;
|
|
1067
|
+
}, [t]);
|
|
1068
|
+
const J = ee(s);
|
|
1069
|
+
I(() => {
|
|
1070
|
+
J.current = s;
|
|
1071
|
+
}, [s]);
|
|
1072
|
+
const k = G((w) => {
|
|
1073
|
+
$.current?.(w), M(w);
|
|
1074
|
+
}, []), N = A(
|
|
1075
|
+
() => r && (r.scopeId || r.tenant) ? { scopeId: r.scopeId, tenant: r.tenant } : void 0,
|
|
1076
|
+
[r?.scopeId, r?.tenant]
|
|
1077
|
+
), _ = G(async () => {
|
|
1078
|
+
R(!0), E(null);
|
|
779
1079
|
try {
|
|
780
|
-
const
|
|
781
|
-
|
|
782
|
-
} catch (
|
|
783
|
-
E(
|
|
1080
|
+
const w = await o.pathLs("/", i, !0, N);
|
|
1081
|
+
f(w.entries ?? []);
|
|
1082
|
+
} catch (w) {
|
|
1083
|
+
E(w instanceof Error ? w.message : String(w)), f([]), J.current?.(w);
|
|
784
1084
|
} finally {
|
|
785
|
-
|
|
1085
|
+
R(!1);
|
|
1086
|
+
}
|
|
1087
|
+
}, [o, i, N]), F = ee(!0);
|
|
1088
|
+
I(() => {
|
|
1089
|
+
F.current ? F.current = !1 : k(void 0), _();
|
|
1090
|
+
}, [_, k]);
|
|
1091
|
+
const Z = A(() => tt(h), [h]), [P, p] = b(() => /* @__PURE__ */ new Map());
|
|
1092
|
+
I(() => {
|
|
1093
|
+
if (i === "tenant") {
|
|
1094
|
+
p(/* @__PURE__ */ new Map());
|
|
1095
|
+
return;
|
|
786
1096
|
}
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
1097
|
+
const w = h.filter((L) => L.kind === "document").map((L) => L.resource_ref?.document_id).filter((L) => !!L);
|
|
1098
|
+
if (w.length === 0) {
|
|
1099
|
+
p(/* @__PURE__ */ new Map());
|
|
1100
|
+
return;
|
|
1101
|
+
}
|
|
1102
|
+
let x = !1;
|
|
1103
|
+
return o.documentsSummary({ documentIds: w }, i, N).then((L) => {
|
|
1104
|
+
if (x) return;
|
|
1105
|
+
const H = /* @__PURE__ */ new Map();
|
|
1106
|
+
for (const ne of L.documents ?? []) H.set(ne.document_id, ne);
|
|
1107
|
+
p(H);
|
|
1108
|
+
}).catch(() => {
|
|
1109
|
+
x || p(/* @__PURE__ */ new Map());
|
|
1110
|
+
}), () => {
|
|
1111
|
+
x = !0;
|
|
1112
|
+
};
|
|
1113
|
+
}, [o, h, i, N]);
|
|
1114
|
+
const m = A(
|
|
1115
|
+
() => U ? Me(Z, U) : void 0,
|
|
1116
|
+
[Z, U]
|
|
1117
|
+
), T = A(() => m ? m.kind === "directory" ? m.fullPath : le(m.fullPath) : "", [m]), S = T || "/", W = i !== "tenant", Q = G(() => {
|
|
795
1118
|
D({
|
|
796
|
-
title: `New folder in ${
|
|
1119
|
+
title: `New folder in ${S}`,
|
|
797
1120
|
fields: [{ key: "name", label: "Folder name", placeholder: "e.g. launches" }],
|
|
798
1121
|
submitLabel: "Create",
|
|
799
|
-
onSubmit: async (
|
|
800
|
-
const
|
|
801
|
-
if (!
|
|
802
|
-
const
|
|
803
|
-
await
|
|
1122
|
+
onSubmit: async (w) => {
|
|
1123
|
+
const x = w.name.trim();
|
|
1124
|
+
if (!ge.test(x)) throw new Error("name may contain only [A-Za-z0-9._-]");
|
|
1125
|
+
const L = ke(T, x);
|
|
1126
|
+
await o.pathMkdir(L, i, N), await _(), k(L);
|
|
804
1127
|
}
|
|
805
1128
|
});
|
|
806
|
-
}, [
|
|
1129
|
+
}, [o, T, S, i, N, _, k]), X = G(() => {
|
|
807
1130
|
D({
|
|
808
|
-
title: `New document in ${
|
|
1131
|
+
title: `New document in ${S}`,
|
|
809
1132
|
fields: [
|
|
810
1133
|
{ key: "name", label: "Path name", placeholder: "e.g. launch-plan" },
|
|
811
1134
|
{ key: "title", label: "Title", placeholder: "e.g. Launch Plan" }
|
|
812
1135
|
],
|
|
813
1136
|
submitLabel: "Create",
|
|
814
|
-
onSubmit: async (
|
|
815
|
-
const
|
|
816
|
-
if (!
|
|
817
|
-
const
|
|
818
|
-
await
|
|
1137
|
+
onSubmit: async (w) => {
|
|
1138
|
+
const x = w.name.trim();
|
|
1139
|
+
if (!ge.test(x)) throw new Error("name may contain only [A-Za-z0-9._-]");
|
|
1140
|
+
const L = w.title.trim() || x, H = ke(T, x);
|
|
1141
|
+
await o.documentCreate(L, H, i, N), await _(), k(H);
|
|
819
1142
|
}
|
|
820
1143
|
});
|
|
821
|
-
}, [
|
|
1144
|
+
}, [o, T, S, i, N, _, k]), K = G(() => {
|
|
822
1145
|
m && D({
|
|
823
1146
|
title: `Rename / move ${m.fullPath}`,
|
|
824
1147
|
fields: [{ key: "to", label: "New path", value: m.fullPath }],
|
|
825
1148
|
submitLabel: "Move",
|
|
826
|
-
onSubmit: async (
|
|
827
|
-
const
|
|
828
|
-
if (!
|
|
829
|
-
await
|
|
1149
|
+
onSubmit: async (w) => {
|
|
1150
|
+
const x = w.to.trim();
|
|
1151
|
+
if (!x.startsWith("/")) throw new Error("path must start with /");
|
|
1152
|
+
await o.pathMv(m.fullPath, x, i, N), await _(), k(x);
|
|
830
1153
|
}
|
|
831
1154
|
});
|
|
832
|
-
}, [
|
|
1155
|
+
}, [o, m, i, N, _, k]), te = G(() => {
|
|
833
1156
|
if (!m) return;
|
|
834
1157
|
if (m.kind === "document") {
|
|
835
|
-
const
|
|
1158
|
+
const H = m.resourceRef?.document_id;
|
|
836
1159
|
D({
|
|
837
1160
|
title: `Delete document ${m.fullPath}`,
|
|
838
1161
|
message: "This deletes the document, all its chunks, and its path entry. This cannot be undone.",
|
|
@@ -840,29 +1163,29 @@ function Re({
|
|
|
840
1163
|
submitLabel: "Delete",
|
|
841
1164
|
danger: !0,
|
|
842
1165
|
onSubmit: async () => {
|
|
843
|
-
if (!
|
|
844
|
-
await
|
|
1166
|
+
if (!H) throw new Error("this document dirent has no document_id");
|
|
1167
|
+
await o.documentDelete(H, i, N), await _(), k(void 0);
|
|
845
1168
|
}
|
|
846
1169
|
});
|
|
847
1170
|
return;
|
|
848
1171
|
}
|
|
849
|
-
const
|
|
1172
|
+
const w = i === "tenant" ? [] : nt(m), x = m.children.length;
|
|
850
1173
|
D({
|
|
851
1174
|
title: `Delete branch ${m.fullPath}`,
|
|
852
|
-
message:
|
|
1175
|
+
message: x === 0 ? "This removes the (empty) folder." : "This removes the folder and everything under it" + (w.length > 0 ? ` — including ${w.length} document(s), whose chunks are deleted.` : "."),
|
|
853
1176
|
fields: [],
|
|
854
1177
|
submitLabel: "Delete",
|
|
855
1178
|
danger: !0,
|
|
856
1179
|
onSubmit: async () => {
|
|
857
|
-
for (const
|
|
858
|
-
await
|
|
859
|
-
await
|
|
1180
|
+
for (const L of w)
|
|
1181
|
+
await o.documentDelete(L, i, N);
|
|
1182
|
+
await o.pathRm(m.fullPath, i, !0, N), await _(), k(void 0);
|
|
860
1183
|
}
|
|
861
1184
|
});
|
|
862
|
-
}, [
|
|
863
|
-
return /* @__PURE__ */ d(
|
|
1185
|
+
}, [o, m, i, N, _, k]), Y = m && (m.kind === "directory" || m.kind === "document");
|
|
1186
|
+
return /* @__PURE__ */ d(q, { children: [
|
|
864
1187
|
/* @__PURE__ */ d(
|
|
865
|
-
|
|
1188
|
+
Ue,
|
|
866
1189
|
{
|
|
867
1190
|
className: "paths-view",
|
|
868
1191
|
defaultLeftWidth: 420,
|
|
@@ -873,151 +1196,160 @@ function Re({
|
|
|
873
1196
|
/* @__PURE__ */ d("div", { className: "left", children: [
|
|
874
1197
|
/* @__PURE__ */ d("div", { className: "paths-toolbar", children: [
|
|
875
1198
|
/* @__PURE__ */ d("label", { className: "paths-scope", children: [
|
|
876
|
-
/* @__PURE__ */
|
|
877
|
-
/* @__PURE__ */ d("select", { value:
|
|
878
|
-
/* @__PURE__ */
|
|
879
|
-
/* @__PURE__ */
|
|
880
|
-
/* @__PURE__ */
|
|
1199
|
+
/* @__PURE__ */ n("span", { children: "scope" }),
|
|
1200
|
+
/* @__PURE__ */ d("select", { value: i, onChange: (w) => u(w.target.value), children: [
|
|
1201
|
+
/* @__PURE__ */ n("option", { value: "user", children: "user" }),
|
|
1202
|
+
/* @__PURE__ */ n("option", { value: "agent", children: "agent" }),
|
|
1203
|
+
/* @__PURE__ */ n("option", { value: "tenant", children: "tenant" })
|
|
881
1204
|
] })
|
|
882
1205
|
] }),
|
|
883
1206
|
/* @__PURE__ */ d("div", { className: "paths-toolbar-actions", children: [
|
|
884
|
-
/* @__PURE__ */
|
|
885
|
-
/* @__PURE__ */
|
|
1207
|
+
/* @__PURE__ */ n("button", { type: "button", onClick: Q, title: `New folder in ${S}`, children: "+ folder" }),
|
|
1208
|
+
/* @__PURE__ */ n(
|
|
886
1209
|
"button",
|
|
887
1210
|
{
|
|
888
1211
|
type: "button",
|
|
889
|
-
onClick:
|
|
890
|
-
disabled: !
|
|
891
|
-
title:
|
|
1212
|
+
onClick: X,
|
|
1213
|
+
disabled: !W,
|
|
1214
|
+
title: W ? `New document in ${S}` : "Documents are agent/user scope only",
|
|
892
1215
|
children: "+ document"
|
|
893
1216
|
}
|
|
894
1217
|
),
|
|
895
|
-
/* @__PURE__ */
|
|
896
|
-
|
|
1218
|
+
/* @__PURE__ */ n("button", { type: "button", onClick: () => {
|
|
1219
|
+
_();
|
|
897
1220
|
}, title: "Reload the tree", children: "↻" })
|
|
898
1221
|
] })
|
|
899
1222
|
] }),
|
|
900
1223
|
/* @__PURE__ */ d("p", { className: "paths-context", children: [
|
|
901
1224
|
"new items → ",
|
|
902
|
-
/* @__PURE__ */
|
|
903
|
-
N?.scopeId && /* @__PURE__ */ d(
|
|
1225
|
+
/* @__PURE__ */ n("code", { children: S }),
|
|
1226
|
+
N?.scopeId && /* @__PURE__ */ d(q, { children: [
|
|
904
1227
|
" · ",
|
|
905
1228
|
"subject ",
|
|
906
|
-
/* @__PURE__ */
|
|
1229
|
+
/* @__PURE__ */ n("code", { children: N.scopeId })
|
|
907
1230
|
] }),
|
|
908
|
-
N?.tenant && /* @__PURE__ */ d(
|
|
1231
|
+
N?.tenant && /* @__PURE__ */ d(q, { children: [
|
|
909
1232
|
" · ",
|
|
910
1233
|
"tenant ",
|
|
911
|
-
/* @__PURE__ */
|
|
1234
|
+
/* @__PURE__ */ n("code", { children: N.tenant })
|
|
912
1235
|
] })
|
|
913
1236
|
] }),
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
1237
|
+
v && /* @__PURE__ */ n("div", { className: "paths-err", children: v }),
|
|
1238
|
+
O && h.length === 0 ? /* @__PURE__ */ n("div", { className: "empty", children: /* @__PURE__ */ n("p", { children: "Loading…" }) }) : /* @__PURE__ */ n(
|
|
1239
|
+
rt,
|
|
917
1240
|
{
|
|
918
|
-
tree:
|
|
919
|
-
selectedPath:
|
|
920
|
-
onSelect: (
|
|
1241
|
+
tree: Z,
|
|
1242
|
+
selectedPath: U,
|
|
1243
|
+
onSelect: (w) => k(w.fullPath),
|
|
1244
|
+
summaries: P
|
|
921
1245
|
}
|
|
922
1246
|
)
|
|
923
1247
|
] }),
|
|
924
|
-
/* @__PURE__ */
|
|
1248
|
+
/* @__PURE__ */ n("div", { className: "right", children: m ? m.kind === "document" ? /* @__PURE__ */ d("div", { className: "paths-doc", children: [
|
|
925
1249
|
/* @__PURE__ */ d("div", { className: "paths-doc-head", children: [
|
|
926
|
-
/* @__PURE__ */
|
|
1250
|
+
/* @__PURE__ */ n("code", { className: "paths-doc-path", children: m.fullPath }),
|
|
927
1251
|
/* @__PURE__ */ d("div", { className: "paths-detail-actions", children: [
|
|
928
|
-
/* @__PURE__ */
|
|
929
|
-
/* @__PURE__ */
|
|
1252
|
+
/* @__PURE__ */ n("button", { type: "button", onClick: K, children: "rename / move" }),
|
|
1253
|
+
/* @__PURE__ */ n("button", { type: "button", className: "danger", onClick: te, children: "delete" })
|
|
930
1254
|
] })
|
|
931
1255
|
] }),
|
|
932
|
-
/* @__PURE__ */
|
|
933
|
-
|
|
1256
|
+
/* @__PURE__ */ n(
|
|
1257
|
+
Ee,
|
|
934
1258
|
{
|
|
935
1259
|
documentId: m.resourceRef?.document_id ?? "",
|
|
936
|
-
scope:
|
|
1260
|
+
scope: i === "agent" ? "agent" : "user",
|
|
937
1261
|
titleHint: m.name,
|
|
938
1262
|
browse: N,
|
|
939
|
-
principal:
|
|
940
|
-
renderAssistant:
|
|
1263
|
+
principal: c,
|
|
1264
|
+
renderAssistant: l
|
|
941
1265
|
}
|
|
942
1266
|
)
|
|
943
1267
|
] }) : /* @__PURE__ */ d("div", { className: "paths-detail", children: [
|
|
944
1268
|
/* @__PURE__ */ d("h2", { children: [
|
|
945
|
-
/* @__PURE__ */
|
|
946
|
-
/* @__PURE__ */
|
|
1269
|
+
/* @__PURE__ */ n("span", { className: "paths-detail-kind", children: m.kind }),
|
|
1270
|
+
/* @__PURE__ */ n("code", { children: m.fullPath })
|
|
947
1271
|
] }),
|
|
948
1272
|
/* @__PURE__ */ d("dl", { className: "paths-detail-meta", children: [
|
|
949
|
-
/* @__PURE__ */
|
|
950
|
-
/* @__PURE__ */
|
|
951
|
-
/* @__PURE__ */
|
|
952
|
-
/* @__PURE__ */
|
|
1273
|
+
/* @__PURE__ */ n("dt", { children: "scope" }),
|
|
1274
|
+
/* @__PURE__ */ n("dd", { children: i }),
|
|
1275
|
+
/* @__PURE__ */ n("dt", { children: "stored" }),
|
|
1276
|
+
/* @__PURE__ */ n("dd", { children: m.explicit ? "yes" : "implicit (no entry)" })
|
|
953
1277
|
] }),
|
|
954
|
-
|
|
955
|
-
/* @__PURE__ */
|
|
956
|
-
/* @__PURE__ */
|
|
1278
|
+
Y ? /* @__PURE__ */ d("div", { className: "paths-detail-actions", children: [
|
|
1279
|
+
/* @__PURE__ */ n("button", { type: "button", onClick: K, children: "rename / move" }),
|
|
1280
|
+
/* @__PURE__ */ n("button", { type: "button", className: "danger", onClick: te, children: "delete" })
|
|
957
1281
|
] }) : /* @__PURE__ */ d("p", { className: "paths-readonly", children: [
|
|
958
1282
|
"Read-only — ",
|
|
959
1283
|
m.kind,
|
|
960
1284
|
" entries are managed by their own tool."
|
|
961
1285
|
] })
|
|
962
|
-
] }) : /* @__PURE__ */
|
|
1286
|
+
] }) : /* @__PURE__ */ n("div", { className: "empty", children: /* @__PURE__ */ n("p", { children: "Select a path on the left, or create a folder / document." }) }) })
|
|
963
1287
|
]
|
|
964
1288
|
}
|
|
965
1289
|
),
|
|
966
|
-
|
|
1290
|
+
j && /* @__PURE__ */ n(st, { state: j, onClose: () => D(null) })
|
|
967
1291
|
] });
|
|
968
1292
|
}
|
|
969
|
-
function
|
|
970
|
-
const [
|
|
971
|
-
() => Object.fromEntries(
|
|
972
|
-
), [
|
|
973
|
-
return /* @__PURE__ */
|
|
974
|
-
u.preventDefault(),
|
|
1293
|
+
function st({ state: e, onClose: a }) {
|
|
1294
|
+
const [t, r] = b(
|
|
1295
|
+
() => Object.fromEntries(e.fields.map((u) => [u.key, u.value ?? ""]))
|
|
1296
|
+
), [c, l] = b(!1), [s, o] = b(null);
|
|
1297
|
+
return /* @__PURE__ */ n("div", { className: "modal-overlay", onClick: a, children: /* @__PURE__ */ d("form", { className: "modal", onClick: (u) => u.stopPropagation(), onSubmit: async (u) => {
|
|
1298
|
+
u.preventDefault(), l(!0), o(null);
|
|
975
1299
|
try {
|
|
976
|
-
await
|
|
1300
|
+
await e.onSubmit(t), a();
|
|
977
1301
|
} catch (h) {
|
|
978
|
-
|
|
1302
|
+
o(h instanceof Error ? h.message : String(h)), l(!1);
|
|
979
1303
|
}
|
|
980
1304
|
}, children: [
|
|
981
|
-
/* @__PURE__ */
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
1305
|
+
/* @__PURE__ */ d("div", { className: "modal-header sticky-top", children: [
|
|
1306
|
+
/* @__PURE__ */ n("h3", { children: e.title }),
|
|
1307
|
+
/* @__PURE__ */ d("div", { className: "modal-buttons modal-buttons-top", children: [
|
|
1308
|
+
/* @__PURE__ */ n("button", { type: "button", onClick: a, disabled: c, children: "cancel" }),
|
|
1309
|
+
/* @__PURE__ */ n("button", { type: "submit", className: e.danger ? "danger" : "primary", disabled: c, children: c ? "working…" : e.submitLabel })
|
|
1310
|
+
] })
|
|
1311
|
+
] }),
|
|
1312
|
+
e.message && /* @__PURE__ */ n("p", { className: "modal-context", children: e.message }),
|
|
1313
|
+
e.fields.map((u, h) => /* @__PURE__ */ d("label", { className: "path-field", children: [
|
|
1314
|
+
/* @__PURE__ */ n("span", { children: u.label }),
|
|
1315
|
+
/* @__PURE__ */ n(
|
|
986
1316
|
"input",
|
|
987
1317
|
{
|
|
988
1318
|
className: "path-modal-input",
|
|
989
|
-
value:
|
|
1319
|
+
value: t[u.key],
|
|
990
1320
|
placeholder: u.placeholder,
|
|
991
1321
|
autoFocus: h === 0,
|
|
992
|
-
onChange: (
|
|
1322
|
+
onChange: (f) => r((g) => ({ ...g, [u.key]: f.target.value }))
|
|
993
1323
|
}
|
|
994
1324
|
)
|
|
995
1325
|
] }, u.key)),
|
|
996
|
-
|
|
997
|
-
/* @__PURE__ */ d("div", { className: "modal-buttons", children: [
|
|
998
|
-
/* @__PURE__ */ t("button", { type: "button", onClick: e, disabled: s, children: "cancel" }),
|
|
999
|
-
/* @__PURE__ */ t("button", { type: "submit", className: a.danger ? "danger" : "primary", disabled: s, children: s ? "working…" : a.submitLabel })
|
|
1000
|
-
] })
|
|
1326
|
+
s && /* @__PURE__ */ n("div", { className: "modal-err", children: s })
|
|
1001
1327
|
] }) });
|
|
1002
1328
|
}
|
|
1003
|
-
function
|
|
1004
|
-
const { documentId:
|
|
1005
|
-
return /* @__PURE__ */
|
|
1006
|
-
|
|
1329
|
+
function pt(e) {
|
|
1330
|
+
const { documentId: a, scope: t, titleHint: r, browse: c, theme: l, principal: s, renderAssistant: o } = e, i = Ne(e);
|
|
1331
|
+
return /* @__PURE__ */ n(we, { theme: l, dataLayer: i, children: /* @__PURE__ */ n(
|
|
1332
|
+
Ee,
|
|
1007
1333
|
{
|
|
1008
|
-
documentId:
|
|
1009
|
-
scope:
|
|
1010
|
-
titleHint:
|
|
1011
|
-
browse:
|
|
1012
|
-
principal:
|
|
1013
|
-
renderAssistant:
|
|
1334
|
+
documentId: a,
|
|
1335
|
+
scope: t,
|
|
1336
|
+
titleHint: r,
|
|
1337
|
+
browse: c,
|
|
1338
|
+
principal: s,
|
|
1339
|
+
renderAssistant: o
|
|
1014
1340
|
}
|
|
1015
1341
|
) });
|
|
1016
1342
|
}
|
|
1017
1343
|
export {
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1344
|
+
se as DEFAULT_SCHEME,
|
|
1345
|
+
pt as DocumentViewer,
|
|
1346
|
+
mt as PathExplorer,
|
|
1347
|
+
Fe as chunkColor,
|
|
1348
|
+
je as createLoomcycleClient,
|
|
1349
|
+
he as dataLayerFromClient,
|
|
1350
|
+
Ce as docColor,
|
|
1351
|
+
ie as effectiveScheme,
|
|
1352
|
+
He as hexToTint,
|
|
1353
|
+
de as tintStyle
|
|
1022
1354
|
};
|
|
1023
1355
|
//# sourceMappingURL=index.js.map
|