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