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